{"source_code": "program yan;\n var s,s1,s2:string; i,j,x,y,n,m:integer;\nbegin\n readln(s);\n readln(s1);\n for i:=1 to length(s) do\n if s[i]= ord(z[i])) then\n y := y + z[i];\n if (ord(x[i]) < ord(z[i])) then\n begin\n y := '-1';\n break;\n end;\n end;\n writeln(y);\nend.\n"}, {"source_code": "var\n s1,s2,s3 : string;\n i : longint;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do\n begin\n if s1[i]=s2[i] then s3:=s3+s1[i] else\n if s1[i]122 then\na:=122;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n writeln('-1');\n test:=0;\n break;\n end;\n end;\n \n end;\n if test=1 then\n writeln(y);\nend."}, {"source_code": "program vk;\nvar a,b,c:string;\n i:byte;\n flag:boolean;\nbegin\n readln(a);\n read(c);\n flag:=true;\n for i:= 1 to length(a) do\n begin\n if a[i]< c[i] then\n begin\n flag:=false;\n break;\n end;\n end;\n if flag then\n begin\n write(c);\n end\n else\n begin\n write(-1);\n end;\nend."}, {"source_code": "var a,s,d,f : integer;\nz,x,c,v: string;\nbegin\n readln (z);\n read (x);\n \n for a:=1 to length(x) do\n if ord(x[a])>ord(z[a]) then begin\n write (-1);\n exit;\n end;\n \n for a:=1 to length(x) do\n write (x[a]);\n \nend."}, {"source_code": "var x,y,z:string;i:integer; f:boolean;\nbegin\n readln(x);\n readln(z);\n f:=true;\n y:='';\n for i:=1 to length(x) do\n begin\n if ord(x[i])=ord(z[i]) then\n begin\n if chr(ord(z[i])+1)='{' then y:=y+'z'\n else y:=y+chr(ord(z[i])+1);\n end;\n if ord(x[i]) > ord(z[i]) then y:=y+z[i];\n if ord(x[i]) < ord(z[i]) then\n begin\n f:=false; break;\n end;\n end;\n if f=true then write(y) else write(-1);\nend."}, {"source_code": "var\n s,s1,s2:ansistring;\n c,c1,c2:char;\n i,j,n,m,k,sc:longint;\nfunction min(a,b:char):char;\nbegin\n if ab[i] then c:=c+b[i];\n end;\nwriteln(c);\nclose(input);close(output);\nend."}, {"source_code": "var s,ss:string;\ni:Longint;\nbegin\n//assign(input,'yjzdys.in');reset(input);\n//assign(output,'yjzdys.out');rewrite(output);\nreadln(s);\nreadln(ss);\nfor i:=1 to length(s) do\n if s[i]x[i] then\n begin\n writeln(-1);\n close(input);close(output);halt;\n end\n else z:=z+y[i];\nwriteln(z);\n\nclose(input);close(output);\nend."}, {"source_code": "var\n x,y,ans:string;\n i:integer;\nbegin\nreadln(x);\nreadln(y);\nsetlength(ans, length(x));\nfor i:=1 to length(x) do\n if x[i]122 then\na:=122;\nch:=chr(a);\ny[i]:=ch;\n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse\nbegin\nif (x[i]>z[i]) then\ny[i]:=z[i]\nelse\nbegin\nwriteln('-1');\ntest:=0;\nbreak;\nend;\nend;\n\nend;\nif test=1 then\nwriteln(y);\nend.\n"}, {"source_code": "program z2;\nvar\n x,y,z:string;\n n,i:integer;\n f:boolean;\nbegin\n readln(x);\n readln(y);\n z:='';\n n:=length(y);\n f:=true;\n for i:=1 to n do begin\n if ord(x[i])ord(y[i]) then z:=z+y[i];\n end;\n if f=false then break;\n end;\n if f=false then write(-1) else write(z);\nend."}, {"source_code": "var\n a,b,i,n,k,j,m,p:longint;\n t,s,x:string;\n was:array[1..111111]of boolean;\nbegin\n readln(s);\n readln(t);\n \n for i:=1 to length(s) do\n begin\n if (s[i]s[i] then x:=x+s[i] else x:=x+t[i];\n end;\n \n writeln(x);\nend. "}, {"source_code": "var\n x,y,z:string;\n f:boolean;\n i,j,ans:longint;\nbegin\n readln (x);\n readln (y);\n f:=true;\n z:='';\n for i:=1 to length(x) do\n begin\n if (x[i]=y[i])then\n{ if y[i]<>'z' then}\n z:=z+x[i]\n{ else z[i]:='y'}\n else\n begin\n if y[i]=ord('a')) and (ord(d)<=ord('z')) then a[n]:=ord(d) else break;\n end;\n dec(n);\n readln;\n p:=true;\n for i:=1 to n do\n begin\n read(d);\n b[i]:=ord(d);\n if (b[i]>a[i]) then p:=false;\n end;\n if p=false then begin writeln(-1); exit; end;\n for i:=1 to n do\n write(chr(b[i]));\n\nend.\n"}, {"source_code": "var x, y: string;\n i: longint;\n\nbegin\n readln(x);\n readln(y);\n for i := 1 to length(x) do\n if x[i] < y[i] then begin\n write(-1);\n exit;\n end;\n write(y);\nend.\n"}, {"source_code": "var\np:char;\n\ns,ss:string;\nkol,j,i:longint;\nbol:boolean;\na:array[-10000..100000]of char;\n\nbegin\nbol:=true;\nreadln(s);\nreadln(ss);\nbol:=true;\nfor i:=1 to length(s) do begin\n if ord(s[i])ord(ss[i]) then a[i]:=ss[i];\nend;\nif bol=false then writeln(-1)\nelse begin\n for i:=1 to length(s) do write(a[i]);\nend;\nend."}, {"source_code": "var\np:char;\n\ns,ss:string;\nkol,j,i:longint;\nbol:boolean;\na:array[-10000..100000]of char;\n\nbegin\nbol:=true;\nreadln(s);\nreadln(ss);\nbol:=true;\nfor i:=1 to length(s) do begin\n if ord(s[i])ord(ss[i]) then a[i]:=ss[i];\nend;\nif bol=false then writeln(-1)\nelse begin\n for i:=1 to length(s) do write(a[i]);\nend;\nend."}, {"source_code": "uses math;\nconst\n\tfi = '';\n\tfo = '';\n\tmaxn = 100001;\nvar x,y,z:string; i,j,n:longint; check:boolean;\n\tf1,f2:text;\nbegin\n\tassign(f1,fi); reset(f1);\n\tassign(f2,fo); rewrite(f2);\n\treadln(f1,x);\n\treadln(f1,y);\n\tn:=length(x);\n\tcheck:=true;\n\tfor i:=1 to n do\n\tbegin\n\t\tif x[i]=y[i] then z:=z+'z'\n\t\telse\n\t\t\tif x[i]z[i] thi y[i]=z[i];\n for i:=1 to n do \n if x[i]=z[i] then \n y[i]:=x[i]\n else \n if x[i]>z[i] then \n y[i]:=z[i]\n else \n begin\n kt:=false;\n break;\n end;\n if not kt then write(-1)\n else write(y);\nend."}, {"source_code": "program B;\n\nvar wronglet : boolean;\n\ti : integer;\n\tx, z : string;\nBEGIN\n\treadln(x);\n\treadln(z);\n\tfor i := 1 to length(x) do\n\tif (ord(x[i])x[i]) then begin\n writeln('-1');\n exit;\n end\n else if (y[i]=x[i]) then begin\n z:= z + 'z';\n end;\nend;\n\nwrite(z);\nwriteln;\nend."}, {"source_code": "var\n x,y,z :string;\n i : longint;\n\nbegin\n\treadln(x);\n\treadln(y);\n\tz:='';\n\tfor i:= 1 to length(x) do begin\n\t\tz:=z+' ';\n\t\tif(x[i]y[i])then begin\n\t\t\tz[i]:=y[i];\n\t\tend\n\t\telse begin\n\t\t\tz[i]:=x[i];\n\t\tend;\n\tend;\n\twriteln(z);\nend.\t\n"}, {"source_code": "var\nsss:array[1..100000]of char;\ns,s1:string;\ni:longint;\nbol:boolean;\nbegin\nbol:=true;\nreadln(s);\nreadln(s1);\nfor i:=1 to length(s) do begin\n if s[i]=s1[i] then begin\n sss[i]:='z';\n end\n else begin\n if s[i]b then c:=b;\n if aord('z')) then begin\n y:='-1';\n break;\n end else y:=y+chr(c);\n \n end;\n writeln(y);\n\nend."}, {"source_code": "program S801B;\nvar\ns1, s2 : string;\ni, j, k : integer;\n\nfunction y(x, z: string ) : string;\nvar\ntemp : string;\nbegin\ntemp:='';\nfor i:=1 to length(x) do\n begin\n if ((x[i])=z[i]) then\n begin\n temp:=temp+x[i];\n end\n else if (x[i]>z[i]) then\n begin\n temp:=temp+z[i];\n end\n else\n begin\n temp:='-1';\n Break;\n end;\n\n end;\n y:=temp;\n\nend;\n\n\n\nbegin\nreadln(s1);\nreadln(s2);\n\nwriteln(y(s1,s2));\n\n\nreadln;\nend."}, {"source_code": "const fi='';\nvar\n x,y,z:string;\n\nprocedure solve;\nvar i,n,t:int32;\nbegin\n randomize;\n n:= length(x);\n for i:= 1 to n do\n begin\n if x[i]z[i] then y:= y+z[i]\n else y:= y+chr(t);\n end;\n write(y);\nend;\nbegin\n assign(input,fi); reset(input);\n readln(x);\n read(z);\n solve;\n close(input);\nend."}, {"source_code": "var\nst1,st2,st3:string;\ni,sz,usl,per:byte;\n\nbegin\nreadln(st1);\nreadln(st2);\nsz:=length(st1);\nusl:=0;\nst3:='';\n for i:=1 to sz do\n if st2[i]>st1[i] then inc(usl);\n\nif usl>0 then write(-1) else\n begin\n for i:=1 to sz do\n begin\n if st1[i]>st2[i] then\n st3:=st3+st2[i];\n\n if st1[i]=st2[i] then\n begin\n per:=ord(st1[i]);\n if per=122 then st3:=st3+chr(per) else\n begin\n inc(per);\n st3:=st3+chr(per);\n end;\n per:=0;\n end;\n end;\n end;\n write(st3);\n end.\n\n\n\n\n\n\n\n\n"}, {"source_code": "program ideone;\n\nvar x,z:string; i:integer; zz:boolean;\nbegin\nreadln(x);\nreadln(z);\nzz:=true;\nwhile (i<=length(x)) AND (zz=true) do\n\tbegin\n\tif ord(z[i])>ord(x[i]) then zz:=false;\n\tinc(i);\n\tend;\nif zz=false then writeln('-1')\nelse writeln(z);\nend.\n"}, {"source_code": "var s1,s2,s3:string;\n n,i:longint;\nbegin\n//assign(input,'b.inp');reset(input);\n//assign(output,'b.out');rewrite(output);\nreadln(s1);\nreadln(s3);\nn:=length(S1);\nfor i:=1 to n do s2:=s2+'+';\nFor i:=1 to n do\n begin\n if s3[i]=s1[i] then\n begin\n s2[i]:='z';\n continue;\n end;\n if s3[i]>s1[i] then\n begin\n writeln(-1);\n halt;\n end;\n s2[i]:=s3[i];\n end;\nwriteln(s2);\nend.\n"}, {"source_code": "var x,y:ansistring; i:longint;\nbegin\n readln(x); readln(y);\n for i:=1 to length(x) do\n if x[i]y[i]) then begin\n writeln('-1'); halt;\n end else inc(i);\n end;\n i:=1; res:='';\n while i<=length(x) do begin\n if min(ord(x[i]),ord(y[i]))=ord(y[i]) then res:=res+y[i]\n else res:=res+x[i];\n inc(i);\n end;\n writeln(res);\nend;\n\nbegin\n main;\nend."}, {"source_code": "var a,b,c,d,i,z:integer;\na1,a2,a3,a4:string;\nbegin\nreadln(a1);\nreadln(a2);\nc:=length(A1);\nfor i:=1 to c do begin\nif a2[i]>A1[i] then begin\nwriteln(-1);\nz:=1;\nbreak;\nend;\nend;\nif z=0 then begin \na3:=a2;\nwriteln(A3);\nend;\nend."}, {"source_code": "var i:longint;\n a,b,c:string;\nbegin\nreadln(a);readln(c);\nfor i:=1 to length(a) do if a[i]c[i] then b:=b+c[i];\nend;\nwriteln(b);\nend."}, {"source_code": "var\ts,t:string;\n\ti:integer;\n\tbool:boolean;\nbegin\n\treadln(s);\n\treadln(t);\n\tbool:=false;\n\tfor i:=1 to length(s) do\n\t\tif t[i]>s[i] then\n\t\tbegin\n\t\t\tbool:=true;\n\t\t\tbreak;\n\t\tend;\n\tif bool=false then writeln(t) else writeln(-1);\nend."}, {"source_code": "Var\n s1, s2, s3: String;\n\nBegin\n Readln(s1);\n Readln(s2);\n For Var i := 1 to Length(s1) do\n If s2[i] > s1[i] then Begin\n Write(-1);\n Exit\n End\n Else If s1[i] = s2[i] then\n s3 += s1[i]\n Else\n s3 += s2[i];\n Write(s3)\nEnd."}, {"source_code": "var s,s1: ansistring;\ni,j,l: longint;\nb: boolean;\n\n\n\nbegin\nreadln(s);\nreadln(s1);\nl:=length(s);\nfor i:=1 to l do\n if s1[i]>s[i] then b:=true;\nif b=true then write(-1) else write(s1);\nreadln;\nend.\n\n\n\n\n"}, {"source_code": "var\n s1, s2, s3, s5: string;\n i, j, k: integer;\n\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n begin\n if s1[i] = s2[i] then\n s3 := s3 + 'z'; \n if s1[i] > s2[i] then\n s3 := s3 + s2[i];\n if s1[i] < s2[i] then begin\n writeln('-1');\n exit();\n end;\n end;\n writeln(s3);\n \nend."}, {"source_code": "\n const nn=600000; nnn=2000;eps=0.00000001; besk1=200000008;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-100000..nn] of int64;mass1=^mass;\n var ot,qq,pos,t,l,nm,n,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,prost,besk:int64;\n k,step,ii,i,j:longint;\n oot,yt,yyot,aaa,bbb,ccc:extended;\n sss:array[-10..100000] of char;\n sssnew:array[-10..100000] of char;\n x,y,dd,dist,a,b:array[-100000..2000000] of int64;\n dda,ddb:array[-10..1200,-10..1200] of int64;\n ss1,ss2:string;\n ss:string;ch:char;\n zan:array[-100..2000000] of boolean;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n zz,aa,bb,cc,sumsq,sq,xx,yy:array[-100000..nn] of extended;\n xm,ym,yot:extended;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\n function col(ss1:string):int64;\nvar n,i,j,ot:longint;\n begin\n n:=length(ss1); ot:=0;\n for i:=1 to n-1 do if (ss1[i]='V')and(ss1[i+1]='K')\n then inc(ot);\n col:=ot;\n end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(ss1);n:=length(ss1);\n readln(ss2);n:=length(ss1);\n\n flag:=true;\n for i:=1 to n do if ss1[i]s1[i] then xuat('-1')\n else\n if s2[i]b then min:=b else min:=a;\nend;\nprocedure solve;\nvar f:text;\nz:string;\nkq:char;\nk,i:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n z:='';\n k:=length(x);\n for i:=1 to k do\n begin\n if x[i]'z' then\n if kq=x[i] then kq:=chr(ord(x[i])+1);\n z:=z+kq;\n end;\n write(f,z);\n close(f);\nend;\nbegin\n enter;\n solve;\nend.\n\n"}, {"source_code": "var s1,s2,a:ansistring; n,i:longint; check:boolean;\nbegin\n\t//assign(input,'c2.inp'); reset(input);\n\t//assign(output,'c2.out'); rewrite(output);\n\treadln(s1);\n\treadln(s2);\n\tn:=length(s1);\n\tfor i:=1 to n do\n\tbegin\n randomize;\n if ord(s1[i])=ord(s2[i]) then a:=a+chr(random(122-ord(s1[i]))+ord(s1[i]))\n\t\telse\n\t\t\tif ord(s1[i])>ord(s2[i]) then a:=a+s2[i]\n\t\t\telse a:=a+chr(123);\n\tend;\n\tcheck:=false;\n\tfor i:=1 to n do\n\t\tif (ord(a[i])>122) then check:=true;\n\tif check then write(-1) else write(a);\nend.\n"}, {"source_code": "var\nx,z,y:string;\ni,n,k:longint;\ncheck:boolean;\nbegin\nreadln(x);\nreadln(y);\nn:=1;\n\ncheck:=false;\nfor i:=1 to length(x) do begin \n if ord(x[i]) < ord(y[i]) then begin \n check:=true;\n break;\n end\n else z:= z + y[i];\nend;\nif check then writeln(-1) else writeln(z);\nend.\n\n "}], "negative_code": [{"source_code": "var\nx,z,y:string;\ni,n,k:longint;\ncheck:boolean;\nbegin\nreadln(x);\nreadln(y);\nn:=1;\n\ncheck:=false;\n if length(x) = 1 then writeln(y) else \nbegin\nfor i:=1 to length(x) do begin\n if ((2*i-1) <= length(x) ) then\n if (x[2*i-1] <> y[2*i-1]) then check:=true;\n if check then break;\nend;\nif check then writeln(-1) else writeln(y);\nend;\nend.\n\n "}, {"source_code": "program vk;\nvar a,b,c:string;\n i:byte;\n flag:boolean;\nbegin\n readln(a);\n read(c);\n flag:=true;\n for i:= 1 to length(a) do\n begin\n if i mod 2=1 then\n begin\n if a[i]<> c[i] then\n begin\n flag:=false;\n break;\n end;\n end;\n end;\n if flag then\n begin\n write(c);\n end\n else\n begin\n write(-1);\n end;\nend."}, {"source_code": "var a,s,d,f : integer;\nz,x,c,v: string;\nbegin\n readln (z);\n read (x);\n \n for a:=1 to length(x) do\n if ord(x[a])>ord(z[a]) then begin\n write (-1);\n exit;\n end;\n \n for a:=1 to length(x) do\n if x[a]=z[a] then write (chr(ord(x[a])+1)) else\n write (x[a]);\n \nend."}, {"source_code": "Var\n s1, s2: String;\n\nBegin\n Readln(s1);\n Readln(s2);\n For Var i := 1 to Length(s1) do\n If s2[i] > s1[i] then Begin\n Write(-1);\n Exit\n End\n Else If s1[i] = s2[i] then\n Write(s1[i])\n Else\n Write(s2[i])\nEnd."}, {"source_code": "var s:string;\n i,rez,f:longint;\nbegin\n readln(s);\n s:=' '+s+' ';\n for i:=2 to length(s)-1 do\n begin\n if (s[i]='K')and(s[i-1]='V') then\n inc(rez);\n end;\n\n for i:=3 to length(s) do if (s[i]='V')and(s[i-1]='V')and(s[i-2]='V') then f:=1;\n for i:=3 to length(s) do if (s[i]='V')and(s[i-1]='V')and(s[i-2]='V') then f:=1;\n if (s[2]=s[3])and(s[2] = 'K') then f:=1;\n if (s[length(s)-1]=s[length(s)-2])and(s[length(s)-2] = 'V') then f:=1;\n writeln(rez+f);\nend."}, {"source_code": "var\n x, z, y: string;\n n, i, k, l: integer;\n\nbegin\n readln(x);\n readln(z);\n for i := 1 to length(x) do\n begin\n if (ord(x[i]) > ord(z[i])) then\n y := y + z[i];\n if (ord(x[i]) = ord(z[i])) then\n y := y + chr(ord(z[i]) + 1);\n if (ord(x[i]) < ord(z[i])) then\n begin\n y := '-1';\n break;\n end;\n end;\n writeln(y);\nend.\n"}, {"source_code": "program HelloWorld;\nvar x,y,z:string;\n ch:char;\n i,l,test,a:integer;\nbegin\nreadln(x);\nreadln(z);\n{x:='ab';\nz:='ba';}\ny:=x;\ntest:=1;\nl:=length(x);\nfor i:=1 to l do\nbegin\nif (x[i]=z[i]) then \nbegin\na:=ord(x[i]);\na:=a+1;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n writeln('-1');\n test:=0;\n end;\n end;\n \n end;\n if test=1 then\n writeln(y);\nend."}, {"source_code": "program HelloWorld;\nvar x,y,z:string;\n ch:char;\n i,l,test,a:integer;\nbegin\nreadln(x);\nreadln(z);\n{x:='ab';\nz:='ba';}\ny:=x;\ntest:=1;\nl:=length(x);\nfor i:=1 to l do\nbegin\nif (x[i]=z[i]) then \nbegin\na:=ord(x[i]);\na:=a+1;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n writeln('-1');\n break;\n test:=0;\n end;\n end;\n \n end;\n if test=1 then\n writeln(y);\nend."}, {"source_code": "program HelloWorld;\nvar x,y,z:string;\n ch:char;\n i,l,test,a:integer;\nbegin\nreadln(x);\nreadln(z);\n{x:='ab';\nz:='ba';}\ny:=x;\ntest:=1;\nl:=length(x);\nfor i:=1 to l do\nbegin\nif (x[i]=z[i]) then \nbegin\na:=ord(x[i]);\na:=a+1;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n writeln('-1');\n test:=0;\n break;\n end;\n end;\n \n end;\n if test=1 then\n writeln(y);\nend."}, {"source_code": "//fpc 3.0.0\n\nprogram HelloWorld;\nvar x,y,z:string;\n ch:char;\n i,l,test,a:integer;\nbegin\nreadln(x);\nreadln(z);\n{x:='ab';\nz:='aa';}\ny:=x;\ntest:=1;\nl:=length(x);\nfor i:=1 to l do\nbegin\nif (x[i]=z[i]) then \nbegin\na:=ord(x[i]);\na:=a+1;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n y:=('-1');\n test:=0;\n end;\n end;\n \n end;\n \n writeln(y);\nend.\n"}, {"source_code": "program HelloWorld;\nvar x,y,z:string;\n ch:char;\n i,l,test,a:integer;\nbegin\nreadln(x);\nreadln(z);\n{x:='ab';\nz:='ba';}\ny:=x;\ntest:=1;\ntest:=0;\nl:=length(x);\nfor i:=1 to l do\nbegin\nif (x[i]=z[i]) then \nbegin\na:=ord(x[i]);\na:=a+1;\nch:=chr(a);\ny[i]:=ch; \n{writeln(ord(x[i]));\nwriteln(a);\nwriteln(ch);}\nend\nelse \nbegin\n if (x[i]>z[i]) then\n y[i]:=z[i] \n else\n begin\n writeln('-1');\n test:=0;\n end;\n end;\n \n end;\n if test=1 then\n writeln(y);\nend."}, {"source_code": "var a,b:string;\nc:array[1..255]of char;\ni:longint;\nbegin\n//(input,'yjzdys.in');reset(input);\n//assign(output,'yjzdys.out');rewrite(output);\nreadln(a);\nreadln(b);\nfor i:=1 to length(a) do\n if a[i]<>b[i] then\n c[i]:=b[i]\n else\n c[i]:='z';\nfor i:=1 to length(a) do\n write(c[i]);\nclose(input);\nclose(output);\nend."}, {"source_code": "var x,y:string;\ni:longint;\na:array[1..100]of char;\nbegin\n//assign(input,'yjzdys.in');reset(input);\n//assign(output,'yjzdys.out');rewrite(output);\nreadln(x);\nreadln(y);\nif xy[i] then a[i]:=y[i]\n else\n begin\n if y[i]<>'z' then a[i]:=succ(y[i])\n else a[i]:=pred(y[i]);\n end;\n for i:=1 to length(y) do write(a[i]);\n end;\nclose(input);close(output);\nend."}, {"source_code": "var\n a,b,i,n,k,j,m,p:longint;\n t,s,x:string;\n was:array[1..111111]of boolean;\nbegin\n readln(s);\n readln(t);\n \n for i:=1 to length(s) do\n begin\n if ((s[i]=t[i]) and (s[i]='z')) or (s[i]s[i] then x:=x+s[i] else x:=x+t[i];\n end;\n \n writeln(x);\nend. "}, {"source_code": "uses math;\nconst\n\tfi = '';\n\tfo = '';\n\tmaxn = 100001;\nvar x,y,z:string; i,j,n:longint;\n\tf1,f2:text;\nbegin\n\tassign(f1,fi); reset(f1);\n\tassign(f2,fo); rewrite(f2);\n\treadln(f1,x);\n\treadln(f1,y);\n\tn:=length(x);\n\tfor i:=1 to n do\n\tbegin\n\t\tif x[i]=y[i] then z:=z+'z'\n\t\telse z:=z+y[i];\n\tend;\t\n\twriteln(f2,z);\n\tclose(f1); close(f2);\nend.\n"}, {"source_code": "var\nx,y,z:string;\na:char;\ni,j,k:longint;\nbegin\nreadln(x);\nreadln(y);\nz:='';\nfor i:=1 to length(x) do begin\n if (y[i]x[i]) then begin\n writeln('-1');\n exit;\n end\n else if (y[i]=x[i]) then begin\n z:= z + chr(ord(y[i])+1);\n end;\nend;\n\nwrite(z);\nwriteln;\nend.\n"}, {"source_code": "var\n x,y,z :string;\n i : longint;\n\nbegin\n\treadln(x);\n\treadln(y);\n\tz:='';\n\tfor i:= 1 to length(x) do begin\n\t\tz:=z+' ';\n\t\tif(x[i]y[i])then begin\n\t\t\tz[i]:=y[i];\n\t\tend\n\t\telse begin\n\t\t\tz[i]:=chr(ord(x[i])+1);\n\t\tend;\n\tend;\n\twriteln(z);\nend.\t\n"}, {"source_code": "var\n x,y,z :string;\n i : longint;\n\nbegin\n\treadln(x);\n\treadln(y);\n\tz:='';\n\tfor i:= 1 to length(x) do begin\n\t\tz:=z+' ';\n\t\tif(x[i]y[i])then begin\n\t\t\tz[i]:=y[i];\n\t\tend\n\t\telse begin\n\t\t\tz[i]:=chr(ord(x[i])+1);\n\t\tend;\n\t\tif(z[i]<'a')or(z[i]>'z')then begin\n\t\t\twriteln(-1);\n\t\t\texit;\n\t\tend;\n\tend;\n\twriteln(z);\nend.\t\n"}, {"source_code": "var x,z,y:string;\na,b,c,i:integer;\nbegin\n\n readln(x);\n readln(z);\n y:='';\n for i:=1 to length(x) do begin\n a:=ord(x[i]); b:=ord(z[i]);\n if a=b then c:=a+1;\n if a>b then c:=b;\n if aord('z')) then begin\n y:='-1';\n break;\n end else y:=y+chr(c);\n \n end;\n writeln(y);\n\nend."}, {"source_code": "const inp='key.inp'; out='key.out';\n\nvar x,y,res:ansistring;\n\nprocedure main; var i:longint; begin\n //assign(input,inp);assign(output,out);reset(input);rewrite(output);\n readln(x); readln(y);\n i:=1;\n while i<=length(x) do begin\n if x[i]<>y[i] then begin\n writeln('-1'); halt;\n end else inc(i,2);\n end;\n i:=1; res:='';\n while i<=length(x) do begin\n if i mod 2 <> 0 then res:=res+'y'\n else res:=res+y[i];\n inc(i);\n end;\n writeln(res);\nend;\n\nbegin\n main;\nend."}, {"source_code": "const\nfi='';\nfo='';\nvar\nx,y:string;\n//free:array[1..100] of boolean;\nprocedure enter;\nvar f:text;\ni:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,x);\n readln(f,y);\n close(f);\nend;\nfunction min(a,b:char):char;\nbegin\n if a>b then min:=b else min:=a;\nend;\nprocedure solve;\nvar f:text;\nz:string;\nkq:char;\nk,i:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n z:='';\n k:=length(x);\n for i:=1 to k do\n begin\n if x[i]s2[i] then a:=a+s2[i]\n\t\t\telse a:=a+chr(123);\n\tend;\n\tcheck:=false;\n\tfor i:=1 to n do\n\t\tif (ord(a[i])<97) or (ord(a[i])>122) then check:=true;\n\tif check then write(-1) else write(a);\nend.\n"}, {"source_code": "var s1,s2,a:string; n,i:longint; check:boolean;\nbegin\n\t//assign(input,'c2.inp'); reset(input);\n\t//assign(output,'c2.out'); rewrite(output);\n\treadln(s1);\n\treadln(s2);\n\tn:=length(s1);\n\tfor i:=1 to n do\n\tbegin\n\t\tif ord(s1[i])=ord(s2[i]) then a:=a+chr(ord(s1[i])+1)\n\t\telse\n\t\t\tif ord(s1[i])>ord(s2[i]) then a:=a+s2[i]\n\t\t\telse a:=a+chr(123);\n\tend;\n\tcheck:=false;\n\tfor i:=1 to n do\n\t\tif (ord(a[i])>122) then check:=true;\n\tif check then write(-1) else write(a);\nend.\n"}, {"source_code": "var s1,s2,a:string; n,i:longint; check:boolean;\nbegin\n\t//assign(input,'c2.inp'); reset(input);\n\t//assign(output,'c2.out'); rewrite(output);\n\treadln(s1);\n\treadln(s2);\n\tn:=length(s1);\n\tfor i:=1 to n do\n\tbegin\n\t\tif ord(s1[i])=ord(s2[i]) then a:=a+chr(ord(s1[i])+1)\n\t\telse\n\t\t\tif ord(s1[i])>ord(s2[i]) then a:=a+s2[i]\n\t\t\telse a:=a+chr(123);\n\tend;\n\tcheck:=false;\n\tfor i:=1 to n do\n\t\tif (ord(a[i])>122) then check:=true;\n if s2=a then check:=true;\n\tif check then write(-1) else write(a);\nend.\n"}, {"source_code": "var\nx,z,y:string;\ni,n,k:longint;\ncheck:boolean;\nbegin\nreadln(x);\nreadln(y);\nn:=1;\n\ncheck:=false;\nfor i:=1 to length(x) do begin \n if (x[2*n-1] <> y[2*n-1]) then check:=true;\n if check then break;\n if ((2*i) <=length(x)) and ((2*i-1) <= length(x)) then \n z:=z+x[2*i-1]+y[2*i];\n if (2*i <= length(x)) and ( (2*i-1) > length(x)) then \n z:=z+y[2*i];\n if (2*i > length(x)) and ( (2*i-1) <=length(x)) then \n z:=z+x[2*i-1];\nend;\nif check then writeln(-1) else writeln(z);\nend.\n "}], "src_uid": "ce0cb995e18501f73e34c76713aec182"} {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n dd: boolean;\n sw,s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n maxw,pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(maxw,sizeof(maxw),0);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n maxw[t]:=len[i];\n end;\n sw[1]:='';\n for i:=2 to n do sw[i]:=sw[pv[i]]+pc[i];\n dd:=True;\n while dd do\n begin\n dd:=False;\n for i:=1 to n do\n if maxw[i] > 0 then\n for j:=1 to n do\n if length(sw[j]) > length(sw[i]) then\n if Copy(sw[j],length(sw[j])-length(sw[i])+1,length(sw[i])) = sw[i] then\n if maxw[i] > maxw[j] then\n begin\n maxw[j]:=maxw[i];\n dd:=True;\n end;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if maxw[jj] >= k+1 then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend.", "positive_code": [{"source_code": "const mode=1000000009;\nvar tot,n,m,now:longint;\ntrie1,trie2:array[0..1000,1..4]of longint;\nfail,q,danger:array[0..100]of longint;\nf:array[0..1000,0..100,0..10]of longint;\nfunction getmax(a,b:longint):longint;\nbegin\n if a>b then getmax:=a else getmax:=b;\nend;\nprocedure insert(x:longint);\nbegin\n if trie1[now,x]=0 then\n begin\n inc(tot);\n trie1[now,x]:=tot;\n now:=tot;\n end else now:=trie1[now,x];\nend;\nprocedure init;\nvar i,j:longint;\nst:string;\nbegin\n tot:=1;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(st);\n now:=1;\n for j:=1 to length(st) do\n begin\n if st[j]='A' then insert(1);\n if st[j]='C' then insert(2);\n if st[j]='G' then insert(3);\n if st[j]='T' then insert(4);\n end;\n danger[now]:=length(st);\n end;\nend;\nprocedure build;\nvar head,tail,i,x:longint;\nbegin\n trie2:=trie1;tail:=0;\n for i:=1 to 4 do\n begin\n if trie2[1,i]=0 then trie2[1,i]:=1\n else\n begin\n inc(tail);\n q[tail]:=trie2[1,i];\n fail[trie2[1,i]]:=1;\n end;\n end;\n head:=1;\n repeat\n x:=q[head];\n danger[x]:=getmax(danger[x],danger[fail[x]]);\n for i:=1 to 4 do\n begin\n if trie2[x,i]=0 then trie2[x,i]:=trie2[fail[x],i]\n else\n begin\n inc(tail);\n q[tail]:=trie2[x,i];\n fail[trie2[x,i]]:=trie2[fail[x],i];\n end;\n end;\n inc(head);\n until head>tail;\nend;\nprocedure work;\nvar i,j,k,ans,v:longint;\nbegin\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n for j:=1 to tot do\n for v:=0 to 9 do\n begin\n if f[i,j,v]=0 then continue;\n for k:=1 to 4 do\n begin\n if trie2[j,k]=1 then continue;\n if danger[trie2[j,k]]>v then f[i+1,trie2[j,k],0]:=(f[i+1,trie2[j,k],0]+f[i,j,v])mod mode\n else f[i+1,trie2[j,k],v+1]:=(f[i+1,trie2[j,k],v+1]+f[i,j,v])mod mode;\n end;\n end;\n ans:=0;\n for i:=1 to tot do\n ans:=(ans+f[n,i,0])mod mode;\n writeln(ans);\nend;\nbegin\n init;\n build;\n work;\nend."}, {"source_code": "\n{$M 10000000}\nconst \n ABC='ACGT';\n base=1000000009;\nvar\n kolnum:longint;\n s:string;\n nexto,j,n,m,kb,i,x,o:longint;\n pow,link,pred,predch:array[0..555]of longint;\n leaf:array[0..555]of boolean;\n next:array[0..555,0..5]of longint;\n f:array[0..1111,0..11,0..111]of longint;\n procedure recl(x:longint);\n var\n i,ch:longint;\n begin\n if (link[x]<>-1)then exit;\n if (pred[x]=0)then begin\n link[x]:=0;\n exit;\n end;\n ch:=predch[x];\n i:=pred[x];\n if (link[i]=-1)then recl(i);\n i:=link[i];\n while (i>0)and(next[i][ch]=-1)do begin\n if (link[i]=-1)then recl(i);\n i:=link[i];\n end;\n if (next[i][ch]=-1)\n then i:=0\n else i:=next[i][ch];\n link[x]:=i;\n end;\n function next_bor(x,ch:longint):longint;\n begin\n while (x>0)and(next[x][ch]=-1)do x:=link[x];\n next_bor:=next[x][ch];\n end;\n function rec(i,k,x:longint):longint;\n var\n si,sk,sx,tt,nextx,ch,res:longint;\n begin\n if (f[i][k][x]<>-1)then begin\n rec:=f[i][k][x];\n exit;\n end;\n si:=i;sk:=k;sx:=x;\n if (pow[x]0)and(pow[tt]>=k)do begin\n if (leaf[tt])then begin\n k:=0;\n break;\n end;\n tt:=link[tt];\n end; \n if (i=n+1)and(k=0)then begin\n f[si][sk][sx]:=1;\n rec:=1;\n exit;\n end;\n if (i=n+1)then begin\n f[si][sk][sx]:=0;\n rec:=0;\n exit;\n end;\n res:=0;\n for ch:=1 to 4 do begin\n nextx:=next_bor(x,ch);\n if (nextx<0)then continue;\n res:=res+rec(i+1,k+1,nextx);\n if (res>=base)then dec(res,base);\n end;\n f[si][sk][sx]:=res;\n rec:=res;\n exit;\n end;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n readln(n,m);\n kb:=0;\n fillchar(next,sizeof(next),$FF);\n fillchar(link,sizeof(link),$FF);\n fillchar(leaf,sizeof(leaf),false);\n link[0]:=0;\n pow[0]:=0;\n for i:=1 to m do begin\n readln(s);\n if (length(s)>n)then continue;\n x:=0;\n for j:=1 to length(s)do begin\n o:=pos(s[j],ABC);\n if (next[x][o]=-1)then begin\n inc(kb);\n next[x][o]:=kb; \n end;\n nexto:=next[x][o];\n pred[nexto]:=x;\n predch[nexto]:=o;\n pow[nexto]:=pow[x]+1;\n x:=nexto;\n end;\n leaf[x]:=true;\n end;\n for i:=0 to kb do recl(i);\n fillchar(f,sizeof(f),$FF);\n writeln(rec(1,0,0));\nend.\n"}, {"source_code": "uses math;\nconst cmod = 1000000009;\n\ntype Ttrie = ^kdl;\nkdl = record\nv:longint;\na:array['A'..'Z'] of TTrie;\nkt:boolean;\nl:longint;\nst:string;\nEnd;\n\nconst maxn=1010;\nmaxnode=1010;\nvar f1,f2:text;\nA:array[1..maxn] of longint;\nTNil:TTrie;\nst:string;\nRoot:TTrie;\nNext:array[1..maxn,'A'..'Z'] of longint;\nF:array[0..maxn,0..20,1..maxnode] of longint;\nVis:array[0..maxn,0..20,1..maxnode] of boolean;\nT:array[1..maxnode] of Ttrie;\nQ:array[1..maxn] of TTrie;\nfr,re:longint;\nspt,m:longint;\nres:longint;\nn,i:longint;\n\nProcedure init(var u:TTrie);\nvar ch:char;\nbegin\n new(u);\n for ch:='A' to 'Z' do\n u^.a[ch]:=nil;\n inc(spt);\n u^.v:=spt;\n u^.kt:=false;\n u^.l:=0;\n u^.st:='';\n T[spt]:=u;\nend;\n\nFunction Search(st:string):longint;\nvar p:TTrie;\ni:longint;\nbegin\n p:=root;\n for i:=1 to length(st) do\n if p^.a[st[i]]<>nil then p:=p^.a[st[i]] else exit(-1);\n Search:=p^.v;\nend;\n\nProcedure BFS;\nvar p:TTrie;\nch:char;\nx:longint;\nj:longint;\nst:string;\nu:TTrie;\nbegin\n\n fr:=0;re:=1;\n Q[1]:=Root;\n REpeat\n inc(Fr);\n u:=Q[Fr];\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1));\n if x<>-1 then\n Begin\n if T[x]^.kt then\n Begin\n u^.kt:=true;\n u^.l:=max(u^.l,T[x]^.l);\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n Begin\n Next[u^.v,ch]:=1;\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1)+ch);\n if x<>-1 then\n Begin\n Next[u^.v,ch]:=x;\n break;\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n if u^.a[ch]<>nil then\n Begin\n Next[u^.v,ch]:=u^.A[ch]^.v;\n inc(RE);\n Q[Re]:=u^.a[ch];\n End;\n Until Fr>=re;\nend;\n\nProcedure Push;\nvar j:longint;\np:TTrie;\nu:longint;\nbegin\n p:=root;\n For j:=1 to length(st) do\n begin\n if p^.a[st[j]]=nil then Begin\n init(p^.a[st[j]]);\n p^.a[st[j]]^.st:=p^.st+st[j]; End;\n p:=p^.a[st[j]]\n end;\n p^.kt:=true;\n p^.l:=length(st);\nend;\n\nFunction Rec(i,k,j:longint):longint; {den i con k , nut j}\nvar ch:char;\np:TTrie;\nbegin\n if (i=n) and (k=0) then F[i,k,j]:=1;\n if (i=n) then\n exit(longint(k=0));\n if k>10 then exit(0);\n if Vis[i,k,j] then exit(F[i,k,j]);\n Vis[i,k,j]:=true;\n for ch:='A' to 'Z' do\n begin\n if Next[j,ch]<>0 then\n Begin\n p:=T[Next[j,ch]];\n if p^.kt then\n Begin\n if k+1<=p^.l then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,0,Next[j,ch])) mod cmod\n else\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,k+1,next[j,ch])) mod cmod;\n end\n else\n if Next[j,ch]<>1 then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,k+1,Next[j,ch])) mod cmod;\n End;\n End;\n Rec:=F[i,k,j];\n\nend;\n\nProcedure DP;\nvar i,j:longint;\nch:char;\nbegin\n fillchar(vis,sizeof(vis),false);\n writeln(f2,Rec(0,0,1));\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m);\n Init(root);\n for i:=1 to m do\n Begin\n readln(F1,st);\n push;\n End;\n BFS;\n DP;\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "{$mode objfpc}\nconst pm=1000000009;\n\nfunction trans(const ch:char):longint;\nbegin case ch of\n\t\t'A':\texit(0);\n\t\t'C':\texit(1);\n\t\t'G':\texit(2);\n\t\t'T':\texit(3);\n\tend;\nend;\n\ntype\n\tdfa=\tobject\n\t\t\tep,root:longint;\n\t\t\tb:array[0..10010] of record\n\t\t\t\t\t\t\t\tnext:array[0..3] of longint;\n\t\t\t\t\t\t\t\tdepth,fail:longint;\n\t\t\t\t\t\t\t\tflag:boolean;\n\t\t\t\t\t\t\tend;\n\t\t\tq:array[0..10010] of longint;\n\t\t\tfunction Create(x:longint):longint;\n\t\t\tprocedure init();\n\t\t\tprocedure ins(const s:string);\n\t\t\tprocedure build();\n\t\tend;\n\t\n\tfunction dfa.Create(x:longint):longint;\n\tbegin inc(ep); fillchar(b[ep].next,sizeof(b[ep].next),255);\n\t\tb[ep].depth:=x; b[ep].fail:=-1; b[ep].flag:=false; exit(ep);\n\tend;\n\t\n\tprocedure dfa.init();\n\tbegin ep:=0; root:=Create(0); end;\n\t\n\tprocedure dfa.ins(const s:string);\n\tvar cur,i,x:longint;\n\tbegin cur:=root;\n\t\tfor i:=1 to length(s) do\n\t\tbegin x:=trans(s[i]);\n\t\t\tif b[cur].next[x]=-1 then b[cur].next[x]:=Create(b[cur].depth+1);\n\t\t\tcur:=b[cur].next[x];\n\t\tend;\n\t\tb[cur].flag:=true;\n\tend;\n\t\n\tprocedure dfa.build();\n\tvar head,tail,cur,i:longint;\n\tbegin head:=1; tail:=2; q[head]:=root; b[root].fail:=-1;\n\t\twhile head-1 then begin q[tail]:=b[cur].next[i]; inc(tail); end;\n\t\t\t\tif b[cur].fail=-1 then\n\t\t\t\t\tif b[cur].next[i]=-1 then\n\t\t\t\t\t\tb[cur].next[i]:=root\n\t\t\t\t\telse b[b[cur].next[i]].fail:=root\n\t\t\t\telse if b[cur].next[i]=-1 then\n\t\t\t\t\t\tb[cur].next[i]:=b[b[cur].fail].next[i]\n\t\t\t\t\telse b[b[cur].next[i]].fail:=b[b[cur].fail].next[i];\n\t\t\tend;\n\t\tend;\n\tend;\n\t\nvar\nac:dfa;\nss:string;\ndp:array[0..1010,0..110,0..11] of longint;\n\nprocedure lemon();\nvar n,m,i,node,L,k,x,y,ans:longint;\n ff:boolean;\nbegin readln(n,m);\n\tac.init();\n\tfor i:=1 to m do begin readln(ss); ac.ins(ss); end;\n\t//dp[n][node][L]\tlength(n) string having suffix(node) and the first L letters of the suffix have been covered\n\tac.build();\n\twith ac do\n\tbegin dp[0][1][0]:=1;\n\t\tfor i:=0 to n-1 do\n\t\t\tfor node:=1 to ep do\n\t\t\t\tfor L:=0 to 10 do\n\t\t\t\t\tif dp[i,node,L]>0 then\n\t\t\t\t\t\tfor k:=0 to 3 do\n\t\t\t\t\t\tbegin //writeln(i,' ',node,' ',L,' ',k,' ',b[node].next[k]);\n\t\t\t\t\t\t\ty:=b[node].next[k]; if y=-1 then continue;\n\t\t\t\t\t\t\tff:=false;\n\t\t\t\t\t\t\twhile y<>-1 do\n\t\t\t\t\t\t\tbegin if (b[y].flag)and(b[y].depth>=L+1) then\n\t\t\t\t\t\t\t\tbegin ff:=true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\ty:=b[y].fail;\n\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\ty:=b[node].next[k];\n\t\t\t\t\t\t\tif ff then\n\t\t\t\t\t\t\tbegin inc(dp[i+1,y,0],dp[i,node,L]);\n\t\t\t\t\t\t\t\tif dp[i+1,y,0]>=pm then dec(dp[i+1,y,0],pm);\n\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\telse begin\n\t\t\t\t\t\t\t\tinc(dp[i+1,y,L+1],dp[i,node,L]);\n\t\t\t\t\t\t\t\tif dp[i+1,y,L+1]>=pm then dec(dp[i+1,y,L+1],pm);\n\t\t\t\t\t\t\tend;\n\t\t\t\t\t\tend;\n\tend;\n\tans:=0;\n\tfor i:=1 to ac.ep do ans:=(ans+dp[n,i,0]) mod pm;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'86C.in');\n\treset(input);\n{$endif}\nlemon();\nend.\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t"}, {"source_code": "program cf86c;\nconst\n mode=1000000009;\ntype\n dtnote=record\n son:array[1..4]of longint;\n cnt,fai,p,fl:longint;\n ch:longint;\n end;\nvar\n i,j,k,n,tot,m,kk,h,u:longint;\n ANS:INT64;\n ss:string;\n dt:array[0..1000]of dtnote;\n dl:array[0..1000]of longint;\n f:array[0..1000,0..100,0..10]of INT64;\nfunction ha(c:char):longint;\nbegin\n if c='A' then exit(1);\n if c='C' then exit(2);\n if c='G' then exit(3);\n if c='T' then exit(4);\nend;\n\n\nprocedure dtinsert;\nvar u,i,c:longint;\nbegin\n u:=1;\n for i:=1 to length(ss) do begin\n c:=ha(ss[i]);\n if dt[u].son[c]=0 then begin\n inc(tot);\n fillchar(dt[tot],sizeof(dt[tot]),0);\n dt[tot].p:=u;\n dt[u].son[c]:=tot;\n dt[tot].ch:=c;\n dt[tot].fl:=i;\n end;\n u:=dt[u].son[c];\n end;\n dt[u].cnt:=length(ss);;\nend;\n\nprocedure setac;\nvar\n i,u,j,x:longint;\nbegin\n for j:=1 to 4 do dt[0].son[j]:=1;\n dt[1].fai:=0;\n\n dl[1]:=1;\n dl[0]:=1;\n for i:=1 to tot do begin\n x:=dl[i];\n for j:=1 to 4 do\n if dt[x].son[j]<>0 then begin\n inc(dl[0]);\n dl[dl[0]]:=dt[x].son[j];\n end;\n if i=1 then continue;\n\n u:=dt[dt[x].p].fai;\n while dt[u].son[dt[x].ch]=0 do u:=dt[u].fai;\n\n dt[x].fai:=dt[u].son[dt[x].ch];\n if dt[dt[x].fai].cnt>dt[x].cnt then\n dt[x].cnt:=dt[dt[x].fai].cnt;\n end;\nend;\n\n\nbegin\n fillchar(dt[0],sizeof(dt[0]),0);\n dt[0].fl:=-100;\n fillchar(dt[1],sizeof(dt[1]),0);\n tot:=1;\n readln(n,m);\n for i:=1 to m do begin\n readln(ss);\n dtinsert;\n end;\n setac;\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n for j:=1 to tot do\n for k:=0 to dt[j].fl do\n for h:=1 to 4 do begin\n u:=j;\n while dt[u].son[h]=0 do u:=dt[u].fai;\n kk:=k-(dt[j].fl-dt[u].fl);\n if (kk<0)or(u=0) then continue;\n u:=dt[u].son[h];\n if dt[u].fl-dt[u].cnt<=kk then kk:=dt[u].fl;\n f[i+1,u,kk]:=(f[i+1,u,kk]+f[i,j,k])mod mode;\n end;\n ans:=0;\n for i:=1 to tot do\n ans:=(ans+f[n,i,dt[i].fl])mod mode;\n writeln(ans);\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "program cf86c;\nconst\n mode=1000000009;\ntype\n dtnote=record\n son:array[1..4]of longint;\n cnt,fai,p,fl,ch:longint;\n end;\nvar\n i,j,n,m,k,tot,kk,h,u:longint;\n ss:string;\n ans:int64;\n dt:array[0..100]of dtnote;\n dl:array[0..100]of longint;\n f:array[0..1000,0..100,0..10]of longint;\nfunction haa(c:char):longint;\nbegin\n if c='A' then exit(1);\n if c='C' then exit(2);\n if c='T' then exit(3);\n if c='G' then exit(4);\nend;\n\nprocedure dtinsert;\nvar\n u,c,i:longint;\nbegin\n u:=1;\n for i:=1 to length(ss) do begin\n c:=haa(ss[i]);\n if dt[u].son[c]=0 then begin\n inc(tot);\n fillchar(dt[tot],sizeof(dt[tot]),0);\n dt[tot].fl:=i;\n dt[tot].ch:=c;\n dt[u].son[c]:=tot;\n dt[tot].p:=u;\n end;\n u:=dt[u].son[c];\n end;\n dt[u].cnt:=length(ss);\nend;\n\nprocedure setac;\nvar u,i,j,x:longint;\nbegin\n for j:=1 to 4 do dt[0].son[j]:=1;\n dt[1].fai:=0;\n dl[0]:=1;\n dl[1]:=1;\n for i:=1 to tot do begin\n x:=dl[i];\n for j:=1 to 4 do\n if dt[x].son[j]<>0 then begin\n inc(dl[0]);\n dl[dl[0]]:=dt[x].son[j];\n end;\n if i=1 then continue;\n\n u:=dt[dt[x].p].fai;\n while dt[u].son[dt[x].ch]=0 do u:=dt[u].fai;\n u:=dt[u].son[dt[x].ch];\n dt[x].fai:=u;\n if dt[u].cnt>dt[x].cnt then dt[x].cnt:=dt[u].cnt;\n end;\nend;\n\n\n\nbegin\n fillchar(dt[0],sizeof(dt[0]),0);\n fillchar(dt[1],sizeof(dt[1]),0);\n tot:=1;\n readln(n,m);\n for i:=1 to m do begin\n readln(ss);\n dtinsert;\n end;\n\n setac;\n //fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n\n for i:=0 to n-1 do\n for j:=1 to tot do\n for k:=0 to dt[j].fl do\n for h:=1 to 4 do begin\n u:=j;\n while dt[u].son[h]=0 do u:=dt[u].fai;\n kk:=k-(dt[j].fl-dt[u].fl);\n if (kk<0)or(u=0) then continue;\n u:=dt[u].son[h];\n if dt[u].fl-dt[u].cnt<=kk then kk:=dt[u].fl;\n f[i+1,u,kk]:=(f[i+1,u,kk]+f[i,j,k])mod mode;\n\n end;\n\n ans:=0;\n for i:=1 to tot do\n ans:=(ans+f[n,i,dt[i].fl])mod mode;\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "uses math;\nconst md = 1000000009;\n DEBAG_ON = false;\n DEBAG_ON_1 = false;\nvar\ns:string;\njj,tt,j,p,ne,aa,i,n,m,size:longint;\nnext,go:array[0..1000,0..4]of longint;\neend,len,pred,link,pch:array[0..1000]of longint;\n\nst:array[0..1000]of string;\n\nans:array[0..1001,0..11,0..101]of longint;\n\nprocedure add(s:string);\nvar t,i,x:longint;\n begin\n t:=1;\n for i:=1 to length(s) do\n begin\n if s[i]='A' then x:=0;\n if s[i]='C' then x:=1;\n if s[i]='G' then x:=2;\n if s[i]='T' then x:=3;\n\n if next[t,x]=0 then\n begin\n size:=size+1;\n if DEBAG_ON then\n st[size]:=st[t]+s[i];\n next[t,x]:=size;\n pch[size]:=x;\n pred[size]:=t;\n end;\n\n t:=next[t,x];\n end;\n\n len[t]:=length(s);\n eend[t]:=1;\n end;\n\nfunction fgo(x,y:longint):longint; forward;\n\nfunction flink(x:longint):longint;\n begin\n if link[x]=0 then\n if (x=1)or(pred[x]=1) then link[x]:=1\n else link[x]:=fgo(flink(pred[x]),pch[x]);\n\n flink:=link[x];\n end;\n\nfunction fgo(x,y:longint):longint;\n begin\n if go[x,y]=0 then\n if next[x,y]>1 then go[x,y]:=next[x,y]\n else if x=1 then go[x,y]:=1 else go[x,y]:=fgo(flink(x),y);\n\n fgo:=go[x,y];\n end;\n\nfunction leng(x:longint):longint;\n begin\n if x=1 then leng:=0\n else leng:=max(len[x],leng(flink(x)));\n end;\n\n begin\n readln(n,m);\n size:=1;\n for i:=1 to m do\n begin\n readln(s);\n add(s);\n end;\n\n if DEBAG_ON then\n begin\n for i:=1 to size do\n writeln(i,' ',st[i],' ',flink(i),' ',leng(i),' ',len[i]);\n end;\n\n ans[1,0,1]:=1;\n\n for i:=1 to n do\n begin\n for j:=0 to min(10,i) do\n begin\n for p:=1 to size do\n begin\n if ans[i,j,p]=0 then continue;\n\n if DEBAG_ON_1 then\n writeln(i,' ',j,' ',p,' ',ans[i,j,p]);\n for ne:=0 to 3 do\n begin\n tt:=fgo(p,ne);\n jj:=j+1;\n if (leng(tt)>=jj) then jj:=0;\n\n if DEBAG_ON_1 then\n writeln('>>> symb:',ne,', new pos:',tt,' length:',len[tt],' count:',jj);\n\n ans[i+1,jj,tt]:=(ans[i+1,jj,tt]+ans[i,j,p])mod md;\n end;\n end;\n end;\n end;\n aa:=0;\n for i:=1 to size do\n aa:=(aa+ans[n+1,0,i])mod md;\n\n writeln(aa);\n end."}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,size,l,r,len,maxL,old,now,ans:longint;\n a:array[-1..100,1..4]of longint;\n point,danger,q:array[-1..100]of longint;\n c:array['A'..'T']of longint;\n f:array[0..1000,0..100,0..10]of longint;\n s:string;\n//===========================================================================\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a) else exit(b);\nend;\n//===========================================================================\nprocedure Ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to len do\n begin\n if a[now,c[s[i]]]=0 then\n begin\n inc(size);\n a[now,c[s[i]]]:=size;\n end;\n now:=a[now,c[s[i]]];\n end;\n danger[now]:=len;\nend;\n//===========================================================================\nprocedure Init;\nbegin\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(s);\n len:=length(s);\n if len>maxL then maxL:=len;\n Ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_machine;\nbegin\n point[0]:=-1;\n l:=0;r:=0;q[0]:=0;\n while l<=r do\n begin\n now:=q[l];\n danger[now]:=max(danger[now],danger[point[now]]);\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n inc(r);\n q[r]:=a[now,i];\n point[a[now,i]]:=a[point[now],i];\n end\n else a[now,i]:=a[point[now],i];\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0,0]:=1;\n old:=0;now:=1;\n for z:=0 to n-1 do\n for i:=0 to size do\n for j:=0 to maxL-1 do\n if f[z,i,j]>0 then\n for k:=1 to 4 do\n begin\n now:=a[i,k];\n if danger[now]>j then\n begin\n inc(f[z+1,now,0],f[z,i,j]);\n if f[z+1,now,0]>=mo then dec(f[z+1,now,0],mo);\n end\n else\n begin\n inc(f[z+1,now,j+1],f[z,i,j]);\n if f[z+1,now,j+1]>=mo then dec(f[z+1,now,j+1],mo);\n end;\n end;\n for i:=0 to size do\n begin\n ans:=ans+f[n,i,0];\n if ans>=mo then ans:=ans-mo;\n end;\nend;\n//===========================================================================\nbegin\n Init;\n Set_AC_machine;\n DP;\n writeln(ans);\nend.\n"}, {"source_code": "const bigp=1000000009;\n\ntype autoac=^pear;\n pear=record\n flag,depth,num,ti:longint;\n back,father:autoac;\n child:array[1..4] of autoac;\n end;\n\nvar root,p,q:autoac;\n m,n,i,j,k,tt,ls,rc,fc,sc,ans:longint;\n f:array[0..1010,0..300,0..15] of longint;\n u:array[0..10000] of autoac;\n s:string;\n ch:char;\n\nprocedure doit(p:autoac;s:longint);\n var i,j,c1,c2:longint;\n q:autoac;\n begin\n if (s=0) or (p<>root) then\n begin\n for i:=1 to 4 do\n begin\n c1:=p^.ti;\n q:=p;\n while (q<>root) and (q^.child[i]=nil) do q:=q^.back;\n if q^.child[i]<>nil then\n q:=q^.child[i];\n c2:=q^.ti;\n for j:=0 to 10 do\n if f[s,c1,j]>0 then\n begin\n if (q^.flag=1) and (q^.depth>j) then\n f[s+1,c2,0]:=(f[s+1,c2,0]+f[s,c1,j]) mod bigp\n else\n f[s+1,c2,j+1]:=(f[s+1,c2,j+1]+f[s,c1,j]) mod bigp;\n end;\n end;\n end;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n doit(p^.child[i],s);\n end;\n\nprocedure solve(p:autoac);\n var i:longint;\n begin\n if p^.flag=1 then\n ans:=(ans+f[n,p^.ti,0]) mod bigp;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n solve(p^.child[i]);\n end;\n\nbegin\n new(root);\n root^.father:=root;\n root^.back:=root;\n root^.num:=0;\n root^.ti:=1;\n root^.depth:=0;\n root^.flag:=0;\n for i:=1 to 4 do\n root^.child[i]:=nil;\n readln(n,m);\n tt:=1;\n for i:=1 to m do\n begin\n readln(s);\n p:=root;\n ls:=length(s);\n for j:=1 to ls do\n begin\n ch:=s[j];\n if ch='A' then sc:=1;\n if ch='C' then sc:=2;\n if ch='G' then sc:=3;\n if ch='T' then sc:=4;\n if p^.child[sc]=nil then\n begin\n new(q);\n q^.father:=p;\n q^.back:=nil;\n for k:=1 to 4 do\n q^.child[k]:=nil;\n inc(tt);\n q^.ti:=tt;\n q^.num:=sc;\n q^.flag:=0;\n p^.child[sc]:=q;\n p:=q;\n end\n else\n p:=p^.child[sc];\n end;\n p^.flag:=1;\n p^.depth:=ls;\n end;\n rc:=1;\n fc:=1;\n u[rc]:=root;\n while rc<=fc do\n begin\n if u[rc]<>root then\n begin\n p:=u[rc]^.father^.back;\n sc:=u[rc]^.num;\n while (p<>root) and (p^.child[sc]=nil) do p:=p^.back;\n if (p^.child[sc]<>nil) and (p^.child[sc]<>u[rc]) then p:=p^.child[sc];\n u[rc]^.back:=p;\n p:=u[rc];\n if p^.flag=0 then\n begin\n q:=p^.back;\n while (q<>root) and (q^.flag=0) do q:=q^.back;\n if q^.flag=1 then\n begin\n p^.flag:=1;\n p^.depth:=q^.depth;\n end;\n end;\n end;\n for i:=1 to 4 do\n if u[rc]^.child[i]<>nil then\n begin\n inc(fc);\n u[fc]:=u[rc]^.child[i];\n end;\n inc(rc);\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n doit(root,i);\n ans:=0;\n solve(root);\n writeln(ans);\nend.\n"}, {"source_code": "program xj;\n\n const\n mo=1000000009;\n\n var\n son:array[0..1000,1..4]of longint;\n flag:array[0..1000]of boolean;\n f:array[0..1000,0..120,0..12]of int64;\n q,next,list,dep,max:array[0..1000]of longint;\n i,j,k,n,m,tot,x,y,nn,l1,l2,now,nex,kk:longint;\n st:string;\n ans:int64;\n\n procedure insert;\n var\n now,ii:longint;\n begin\n now:=0;\n for ii:=1 to nn do\n begin\n if son[now][list[ii]]=0\n then begin inc(tot);dep[tot]:=dep[now]+1;son[now][list[ii]]:=tot; end;\n now:=son[now][list[ii]];\n end;\n flag[now]:=true;\n max[now]:=nn;\n end;\n\n procedure get_ac;\n begin\n l1:=1;l2:=1;\n q[1]:=0;next[0]:=-1;\n while l1<=l2 do\n begin\n now:=q[l1];\n x:=now;\n while x<>-1 do\n begin\n if max[x]>max[now]\n then max[now]:=max[x];\n x:=next[x];\n end;\n for k:=1 to 4 do\n begin\n nex:=son[now][k];\n if nex<>0\n then\n begin\n inc(l2);q[l2]:=nex;\n x:=next[now];\n while (x<>-1)and(son[x][k]=0) do x:=next[x];\n if x<>-1\n then next[nex]:=son[x,k]\n else next[nex]:=0;\n end\n else\n begin\n x:=next[now];\n while (x<>-1)and(son[x][k]=0) do\n x:=next[x];\n if x=-1 then son[now][k]:=0\n else son[now][k]:=son[x][k];\n end;\n end;\n inc(l1);\n end;\n end;\n\n procedure run_ac;\n var\n now:longint;\n begin\n fillchar(f,sizeof(f),0);\n f[0,0,0]:=1;\n for i:=0 to n-1 do\n for j:=0 to tot do\n for k:=0 to 9 do\n if f[i][j][k]>0\n then\n begin\n for kk:=1 to 4 do\n begin\n nex:=son[j][kk];\n if nex<>0\n then\n begin\n if max[nex]>=k+1\n then f[i+1][nex][0]:=(f[i+1][nex][0]+f[i][j][k]) mod mo\n else if k+1<10 then f[i+1][nex][k+1]:=(f[i+1][nex][k+1]+f[i][j][k]) mod mo;\n end;\n end;\n end;\n end;\n\n begin\n readln(n,m);\n tot:=0;\n fillchar(flag,sizeof(flag),false);\n fillchar(max,sizeof(max),0);\n dep[0]:=0;\n for i:=1 to m do\n begin\n readln(st);\n nn:=length(st);\n for j:=1 to nn do\n case st[j] of\n 'A':list[j]:=1;\n 'C':list[j]:=2;\n 'G':list[j]:=3;\n 'T':list[j]:=4;\n end;\n insert;\n end;\n get_ac;\n run_ac;\n ans:=0;\n for i:=0 to tot do\n if f[n][i][0]>0\n then ans:=(ans+f[n][i][0]) mod mo;\n writeln(ans);\n end.\n"}], "negative_code": [{"source_code": "program cf86c;\nconst\n mode=1000000007;\ntype\n dtnote=record\n son:array[1..4]of longint;\n cnt,fai,p,fl:longint;\n ch:longint;\n end;\nvar\n ans,i,j,k,n,tot,m,kk,h,u:longint;\n ss:string;\n dt:array[0..1000]of dtnote;\n dl:array[0..1000]of longint;\n f:array[0..1000,0..100,0..10]of longint;\nfunction ha(c:char):longint;\nbegin\n if c='A' then exit(1);\n if c='C' then exit(2);\n if c='G' then exit(3);\n if c='T' then exit(4);\nend;\n\n\nprocedure dtinsert;\nvar u,i,c:longint;\nbegin\n u:=1;\n for i:=1 to length(ss) do begin\n c:=ha(ss[i]);\n if dt[u].son[c]=0 then begin\n inc(tot);\n fillchar(dt[tot],sizeof(dt[tot]),0);\n dt[tot].p:=u;\n dt[u].son[c]:=tot;\n dt[tot].ch:=c;\n dt[tot].fl:=i;\n end;\n u:=dt[u].son[c];\n end;\n dt[u].cnt:=length(ss);;\nend;\n\nprocedure setac;\nvar\n i,u,j,x:longint;\nbegin\n for j:=1 to 4 do dt[0].son[j]:=1;\n dt[1].fai:=0;\n\n dl[1]:=1;\n dl[0]:=1;\n for i:=1 to tot do begin\n x:=dl[i];\n for j:=1 to 4 do\n if dt[x].son[j]<>0 then begin\n inc(dl[0]);\n dl[dl[0]]:=dt[x].son[j];\n end;\n if i=1 then continue;\n\n u:=dt[dt[x].p].fai;\n while dt[u].son[dt[x].ch]=0 do u:=dt[u].fai;\n\n dt[x].fai:=dt[u].son[dt[x].ch];\n if dt[dt[x].fai].cnt>dt[x].cnt then\n dt[x].cnt:=dt[dt[x].fai].cnt;\n end;\nend;\n\n\nbegin\n fillchar(dt[0],sizeof(dt[0]),0);\n dt[0].fl:=-1;\n fillchar(dt[1],sizeof(dt[1]),0);\n tot:=1;\n readln(n,m);\n for i:=1 to m do begin\n readln(ss);\n dtinsert;\n end;\n setac;\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n for j:=1 to tot do\n for k:=0 to dt[j].fl do\n for h:=1 to 4 do begin\n u:=j;\n while dt[u].son[h]=0 do u:=dt[u].fai;\n kk:=k-(dt[j].fl-dt[u].fl);\n if kk<0 then continue;\n u:=dt[u].son[h];\n if dt[u].fl-dt[u].cnt<=kk then kk:=dt[u].fl;\n f[i+1,u,kk]:=(f[i+1,u,kk]+f[i,j,k])mod mode;\n end;\n ans:=0;\n for i:=1 to tot do\n ans:=(ans+f[n,i,dt[i].fl])mod mode;\n writeln(ans);\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "uses math;\nconst md = 1000000009;\nvar\ns:string;\njj,tt,j,p,ne,aa,i,n,m,size:longint;\nnext,go:array[0..1000,0..4]of longint;\neend,len,pred,link,pch:array[0..1000]of longint;\n\n//st:array[0..1000]of string;\n\nans:array[0..1001,0..11,0..101]of longint;\n\nprocedure add(s:string);\nvar t,i,x:longint;\n begin\n t:=1;\n for i:=1 to length(s) do\n begin\n if s[i]='A' then x:=0;\n if s[i]='C' then x:=1;\n if s[i]='G' then x:=2;\n if s[i]='T' then x:=3;\n\n if next[t,x]=0 then\n begin\n size:=size+1;\n// st[size]:=st[t]+s[i];\n next[t,x]:=size;\n len[size]:=len[t]+1;\n pch[size]:=x;\n pred[size]:=t;\n end;\n\n t:=next[t,x];\n end;\n\n eend[t]:=1;\n end;\n\nfunction fgo(x,y:longint):longint; forward;\n\nfunction flink(x:longint):longint;\n begin\n if link[x]=0 then\n if (x=1)or(pred[x]=1) then link[x]:=1\n else link[x]:=fgo(flink(pred[x]),pch[x]);\n\n flink:=link[x];\n end;\n\nfunction fgo(x,y:longint):longint;\n begin\n if go[x,y]=0 then\n if next[x,y]>1 then go[x,y]:=next[x,y]\n else if x=1 then go[x,y]:=1 else go[x,y]:=fgo(flink(x),y);\n\n fgo:=go[x,y];\n end;\n\n begin\n readln(n,m);\n size:=1;\n for i:=1 to m do\n begin\n readln(s);\n add(s);\n end;\n{\n for i:=1 to size do\n writeln(i,' ',st[i],' ',flink(i));\n}\n ans[1,0,1]:=1;\n\n for i:=1 to n do\n begin\n for j:=0 to min(10,i) do\n begin\n for p:=1 to size do\n begin\n for ne:=0 to 3 do\n begin\n tt:=fgo(p,ne);\n jj:=j+1;\n if (len[tt]>=jj)and(eend[tt]=1) then jj:=0;\n// writeln('>>> ',ne,' ',tt,' ',len[tt],' ',jj);\n\n ans[i+1,jj,tt]:=(ans[i+1,jj,tt]+ans[i,j,p])mod md;\n end;\n end;\n end;\n end;\n\n aa:=0;\n for i:=1 to size do\n aa:=(aa+ans[n+1,0,i])mod md;\n\n writeln(aa);\n end."}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger,danger2:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;danger2:=danger;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n if danger2[now] then\n danger2[a[now,i]]:=danger2[a[now,i]] or danger2[a[k,i]];\n //danger[a[now,i]]:=danger[a[now,i]] or danger[a[k,i]];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger2[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n DP;\n for i:=0 to size do\n if danger2[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,-1..100]of longint;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n s:array[1..10]of string;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n s[i]:=word;\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure Work(x,y:longint);\nvar i:longint;\n flag:boolean;\nbegin\n if not danger[x] then flag:=false else flag:=true;\n now:=x;\n for i:=1 to length(s[y]) do\n begin\n if a[now,c[s[y,i]]]=0 then exit;\n if danger[now] then flag:=true;\n now:=a[now,c[s[y,i]]];\n end;\n if flag then danger[now]:=true;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n for i:=1 to size do\n for j:=1 to m do Work(i,j);\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n s:array[1..10]of string;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n s[i]:=word;\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure Work(x,y:longint);\nvar i:longint;\nbegin\n if not danger[x] then exit;\n now:=x;\n for i:=1 to length(s[y]) do\n begin\n if a[now,c[s[y,i]]]=0 then exit;\n now:=a[now,c[s[y,i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n for i:=1 to size do\n for j:=1 to m do Work(i,j);\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n danger[a[now,i]]:=danger[a[now,i]] or danger[a[k,i]];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger,danger2:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;danger2:=danger;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n if danger2[now] then\n danger2[a[now,i]]:=danger2[a[now,i]] or danger2[a[k,i]];\n //danger[a[now,i]]:=danger[a[now,i]] or danger[a[k,i]];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n DP;\n for i:=0 to size do\n if danger2[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of longint;\n danger:array[-1..100]of boolean;\n a:array[-1..100,1..4]of longint;\n q,point:array[0..100]of longint;\n f:array[0..1000,0..100]of longint;\n s:array[1..10]of string;\n word:string;\n//===========================================================================\nprocedure qsort(left,right:longint);\nvar l,r,mid:longint;\n k:string;\nbegin\n l:=left;r:=right;\n mid:=length(s[(l+r)shr 1]);\n repeat\n while length(s[l])mid do dec(r);\n if l<=r then\n begin\n k:=s[l];s[l]:=s[r];s[r]:=k;\n inc(l);dec(r);\n end;\n until l>r;\n if left0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure Work(x,y:longint);\nvar i:longint;\n flag:boolean;\nbegin\n if not danger[x] then flag:=false else flag:=true;\n now:=x;\n for i:=1 to length(s[y]) do\n begin\n if a[now,c[s[y,i]]]=0 then exit;\n if danger[now] then flag:=true;\n now:=a[now,c[s[y,i]]];\n end;\n if flag then danger[now]:=true;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n qsort(1,m);\n for i:=1 to size do\n for j:=1 to m do Work(i,j);\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n\n"}, {"source_code": "program Genetic_engineering;\nconst mo=1000000009;\nvar n,m,i,j,k,z,now,size,l,r,len,ans:longint;\n c:array['A'..'T']of integer;\n danger,danger2:array[-1..100]of boolean;\n a:array[-1..100,1..4]of integer;\n q,point:array[0..100]of integer;\n f:array[0..1000,0..100]of longint;\n word:string;\n//===========================================================================\nprocedure ins_Trie;\nvar i:longint;\nbegin\n now:=0;\n for i:=1 to length(word) do\n begin\n if a[now,c[word[i]]]=0 then\n begin\n inc(size);\n a[now,c[word[i]]]:=size;\n end;\n now:=a[now,c[word[i]]];\n end;\n danger[now]:=true;\nend;\n//===========================================================================\nprocedure init;\nbegin\n size:=0;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(word);\n ins_Trie;\n end;\nend;\n//===========================================================================\nprocedure Set_AC_Machine;\nbegin\n q[0]:=0;l:=0;r:=0;\n point[0]:=-1;danger2:=danger;\n while l<=r do\n begin\n now:=q[l];\n for i:=1 to 4 do\n if a[now,i]>0 then\n begin\n k:=point[now];\n while (k<>-1) and (a[k,i]=0) do k:=point[k];\n point[a[now,i]]:=a[k,i];\n if (a[point[now],i]=a[k,i]) and ((k<>0)or(danger[now])) then\n danger[a[now,i]]:=danger[a[now,i]] or danger[a[k,i]];\n inc(r);\n q[r]:=a[now,i];\n end;\n inc(l);\n end;\nend;\n//===========================================================================\nprocedure DP;\nbegin\n f[0,0]:=1;\n for z:=1 to n do\n for i:=0 to size do\n if f[z-1,i]<>0 then\n for j:=1 to 4 do\n begin\n if (a[i,j]=0) and (not danger[i]) then continue;\n k:=i;\n while (k<>-1) and (a[k,j]=0) do k:=point[k];\n k:=a[k,j];if k=0 then continue;\n f[z,k]:=(f[z,k]+f[z-1,i]) mod mo;\n end;\nend;\n//===========================================================================\nbegin\n danger[-1]:=true;\n c['A']:=1;c['C']:=2;c['G']:=3;c['T']:=4;\n init;\n Set_AC_machine;\n DP;\n for i:=0 to size do\n if danger[i] then\n ans:=(ans+f[n,i]) mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "const bigp=1000000009;\n\ntype autoac=^pear;\n pear=record\n flag,depth,num,ti:longint;\n back,father:autoac;\n child:array[1..4] of autoac;\n end;\n\nvar root,p,q:autoac;\n m,n,i,j,k,tt,ls,rc,fc,sc,ans:longint;\n f:array[0..1010,0..300,0..15] of longint;\n u:array[0..10000] of autoac;\n s:string;\n ch:char;\n\nprocedure calc(p:autoac);\n var i:longint;\n q:autoac;\n begin\n if p^.flag=0 then\n begin\n q:=p^.back;\n while (q<>root) and (q^.flag=0) do q:=q^.back;\n if q^.flag=1 then\n begin\n p^.flag:=1;\n p^.depth:=q^.depth;\n end;\n end;\n for i:=1 to 4 do\n if p^.child[i]<>nil then calc(p^.child[i]);\n end;\n\nprocedure doit(p:autoac;s:longint);\n var i,j,c1,c2:longint;\n q:autoac;\n begin\n if (s=0) or (p<>root) then\n begin\n for i:=1 to 4 do\n begin\n c1:=p^.ti;\n q:=p;\n while (q<>root) and (q^.child[i]=nil) do q:=q^.back;\n if q^.child[i]<>nil then\n q:=q^.child[i];\n c2:=q^.ti;\n for j:=0 to 10 do\n if f[s,c1,j]>0 then\n begin\n if (q^.flag=1) and (q^.depth>j) then\n f[s+1,c2,0]:=(f[s+1,c2,0]+f[s,c1,j]) mod bigp\n else\n f[s+1,c2,j+1]:=(f[s+1,c2,j+1]+f[s,c1,j]) mod bigp;\n end;\n end;\n end;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n doit(p^.child[i],s);\n end;\n\nprocedure solve(p:autoac);\n var i:longint;\n begin\n if p^.flag=1 then\n ans:=(ans+f[n,p^.ti,0]) mod bigp;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n solve(p^.child[i]);\n end;\n\nbegin\n new(root);\n root^.father:=root;\n root^.back:=root;\n root^.num:=0;\n root^.ti:=1;\n root^.depth:=0;\n root^.flag:=0;\n for i:=1 to 4 do\n root^.child[i]:=nil;\n readln(n,m);\n tt:=1;\n for i:=1 to m do\n begin\n readln(s);\n p:=root;\n ls:=length(s);\n for j:=1 to ls do\n begin\n ch:=s[j];\n if ch='A' then sc:=1;\n if ch='C' then sc:=2;\n if ch='G' then sc:=3;\n if ch='T' then sc:=4;\n if p^.child[sc]=nil then\n begin\n new(q);\n q^.father:=p;\n q^.back:=nil;\n for k:=1 to 4 do\n q^.child[k]:=nil;\n inc(tt);\n q^.ti:=tt;\n q^.num:=sc;\n p^.child[sc]:=q;\n p:=q;\n end\n else\n p:=p^.child[sc];\n end;\n p^.flag:=1;\n p^.depth:=ls;\n //writeln(p^.ti);\n end;\n rc:=1;\n fc:=1;\n u[rc]:=root;\n while rc<=fc do\n begin\n if u[rc]<>root then\n begin\n p:=u[rc]^.father^.back;\n sc:=u[rc]^.num;\n while (p<>root) and (p^.child[sc]=nil) do p:=p^.back;\n if (p^.child[sc]<>nil) and (p^.child[sc]<>u[rc]) then p:=p^.child[sc];\n u[rc]^.back:=p;\n p:=u[rc];\n q:=p^.back;\n while (q<>root) and (q^.flag=0) do q:=q^.back;\n if q^.flag=1 then\n begin\n p^.flag:=1;\n p^.depth:=q^.depth;\n end;\n end;\n for i:=1 to 4 do\n if u[rc]^.child[i]<>nil then\n begin\n inc(fc);\n u[fc]:=u[rc]^.child[i];\n end;\n inc(rc);\n end;\n //calc(root);\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n doit(root,i);\n ans:=0;\n solve(root);\n //writeln(f[n,21,0]);\n writeln(ans);\nend.\n"}, {"source_code": "const bigp=1000000009;\n\ntype autoac=^pear;\n pear=record\n flag,depth,num,ti:longint;\n back,father:autoac;\n child:array[1..4] of autoac;\n end;\n\nvar root,p,q:autoac;\n m,n,i,j,k,tt,ls,rc,fc,sc,ans:longint;\n f:array[0..1010,0..300,0..15] of longint;\n u:array[0..10000] of autoac;\n s:string;\n ch:char;\n\nprocedure doit(p:autoac;s:longint);\n var i,j,c1,c2:longint;\n q:autoac;\n begin\n if (s=0) or (p<>root) then\n begin\n for i:=1 to 4 do\n begin\n c1:=p^.ti;\n q:=p;\n while (q<>root) and (q^.child[i]=nil) do q:=q^.back;\n if q^.child[i]<>nil then\n q:=q^.child[i];\n c2:=q^.ti;\n for j:=0 to 10 do\n if f[s,c1,j]>0 then\n begin\n if (q^.flag=1) and (q^.depth>j) then\n f[s+1,c2,0]:=(f[s+1,c2,0]+f[s,c1,j]) mod bigp\n else\n f[s+1,c2,j+1]:=(f[s+1,c2,j+1]+f[s,c1,j]) mod bigp;\n end;\n end;\n end;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n doit(p^.child[i],s);\n end;\n\nprocedure solve(p:autoac);\n var i:longint;\n begin\n if p^.flag=1 then\n ans:=(ans+f[n,p^.ti,0]) mod bigp;\n for i:=1 to 4 do\n if p^.child[i]<>nil then\n solve(p^.child[i]);\n end;\n\nbegin\n new(root);\n root^.father:=root;\n root^.back:=root;\n root^.num:=0;\n root^.ti:=1;\n root^.depth:=0;\n root^.flag:=0;\n for i:=1 to 4 do\n root^.child[i]:=nil;\n readln(n,m);\n tt:=1;\n for i:=1 to m do\n begin\n readln(s);\n p:=root;\n ls:=length(s);\n for j:=1 to ls do\n begin\n ch:=s[j];\n if ch='A' then sc:=1;\n if ch='C' then sc:=2;\n if ch='G' then sc:=3;\n if ch='T' then sc:=4;\n if p^.child[sc]=nil then\n begin\n new(q);\n q^.father:=p;\n q^.back:=nil;\n for k:=1 to 4 do\n q^.child[k]:=nil;\n inc(tt);\n q^.ti:=tt;\n q^.num:=sc;\n q^.flag:=0;\n p^.child[sc]:=q;\n p:=q;\n end\n else\n p:=p^.child[sc];\n end;\n p^.flag:=1;\n p^.depth:=ls;\n writeln(p^.ti);\n end;\n rc:=1;\n fc:=1;\n u[rc]:=root;\n while rc<=fc do\n begin\n if u[rc]<>root then\n begin\n p:=u[rc]^.father^.back;\n sc:=u[rc]^.num;\n while (p<>root) and (p^.child[sc]=nil) do p:=p^.back;\n if (p^.child[sc]<>nil) and (p^.child[sc]<>u[rc]) then p:=p^.child[sc];\n u[rc]^.back:=p;\n p:=u[rc];\n if p^.flag=0 then\n begin\n q:=p^.back;\n while (q<>root) and (q^.flag=0) do q:=q^.back;\n if q^.flag=1 then\n begin\n p^.flag:=1;\n p^.depth:=q^.depth;\n end;\n end;\n end;\n for i:=1 to 4 do\n if u[rc]^.child[i]<>nil then\n begin\n inc(fc);\n u[fc]:=u[rc]^.child[i];\n end;\n inc(rc);\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n doit(root,i);\n ans:=0;\n solve(root);\n writeln(ans);\nend.\n"}, {"source_code": "program xj;\n\n const\n mo=1000000009;\n\n var\n son:array[0..1000,1..4]of longint;\n flag:array[0..1000]of boolean;\n f:array[0..1000,0..120,0..12]of int64;\n q,next,list,dep:array[0..1000]of longint;\n i,j,k,n,m,tot,x,y,nn,l1,l2,now,nex,kk:longint;\n st:string;\n ans:int64;\n\n procedure insert;\n var\n now,ii:longint;\n begin\n now:=0;\n for ii:=1 to nn do\n begin\n if son[now][list[ii]]=0\n then begin inc(tot);dep[tot]:=dep[now]+1;son[now][list[ii]]:=tot; end;\n now:=son[now][list[ii]];\n end;\n flag[now]:=true;\n end;\n\n procedure get_ac;\n begin\n l1:=1;l2:=1;\n q[1]:=0;next[0]:=-1;\n while l1<=l2 do\n begin\n now:=q[l1];\n for k:=1 to 4 do\n begin\n nex:=son[now][k];\n if nex<>0\n then\n begin\n inc(l2);q[l2]:=nex;\n x:=next[now];\n while (x<>-1)and(son[x][k]=0) do x:=next[x];\n if x<>-1\n then next[nex]:=son[x,k]\n else next[nex]:=0;\n end\n else\n begin\n x:=next[now];\n while (x<>-1)and(son[x][k]=0) do\n x:=next[x];\n if x=-1 then son[now][k]:=0\n else son[now][k]:=son[x][k];\n end;\n end;\n inc(l1);\n end;\n end;\n\n procedure run_ac;\n var\n now:longint;\n begin\n fillchar(f,sizeof(f),0);\n f[0,0,0]:=1;\n for i:=0 to n-1 do\n for j:=0 to tot do\n for k:=0 to 9 do\n if f[i][j][k]>0\n then\n begin\n for kk:=1 to 4 do\n begin\n nex:=son[j][kk];\n if nex<>0\n then\n begin\n if (flag[nex])and(dep[nex]>=k+1)\n then f[i+1][nex][0]:=(f[i+1][nex][0]+f[i][j][k]) mod mo;\n if (not flag[nex])and(k+1<=9)\n then f[i+1][nex][k+1]:=(f[i+1][nex][k+1]+f[i][j][k]) mod mo;\n end;\n end;\n end;\n end;\n\n begin\n readln(n,m);\n tot:=0;\n fillchar(flag,sizeof(flag),false);\n dep[0]:=0;\n for i:=1 to m do\n begin\n readln(st);\n nn:=length(st);\n for j:=1 to nn do\n case st[j] of\n 'A':list[j]:=1;\n 'C':list[j]:=2;\n 'G':list[j]:=3;\n 'T':list[j]:=4;\n end;\n insert;\n end;\n get_ac;\n run_ac;\n ans:=0;\n for i:=0 to tot do\n if f[n][i][0]>0\n then ans:=(ans+f[n][i][0]) mod mo;\n writeln(ans);\n end.\n"}, {"source_code": "program xj;\n\n const\n mo=1000000009;\n\t\n var\n son:array[0..1000,1..4]of longint;\n\tflag:array[0..1000]of boolean;\n\tf:array[0..1000,0..1000]of int64;\n\tq,next,list:array[0..10000]of longint;\n\ti,j,k,n,m,tot,x,y,nn,l1,l2,now,nex:longint;\n\tst:string;\n\tans:int64;\n\t\n procedure insert;\n var\n\t now,ii:longint;\n\tbegin\n\t now:=0;\n\t for ii:=1 to nn do\n\t begin\n\t\t if son[now][list[ii]]=0\n\t\t then begin inc(tot);son[now][list[ii]]:=tot; end;\n\t\t now:=son[now][list[ii]];\n\t\tend;\n\t flag[now]:=true;\n\tend;\n\t\n procedure get_ac;\n begin\n l1:=1;l2:=1;\n q[1]:=0;next[0]:=-1;\n while l1<=l2 do\n begin\n now:=q[l1];\n for i:=1 to 4 do\n begin\n nex:=son[now,i];\n if nex<>0\n then\n begin\n inc(l2);q[l2]:=nex;\n x:=next[now];\n while (x<>-1)and(son[x,i]=0) do x:=next[x];\n if x=-1 then next[nex]:=0\n else next[nex]:=son[x,i];\n end;\n end;\n inc(l1);\n end;\n end;\n\n procedure run_ac;\n var\n\t now:longint;\n\tbegin\n\t fillchar(f,sizeof(f),0);\n\t f[0,0]:=1;\n\t for i:=0 to n do\n\t for j:=0 to tot do\n\t\t if f[i][j]>0\n\t\t then\n\t\t\t begin\n\t\t\t for k:=1 to 4 do\n\t\t\t\t begin\n if son[j,k]<>0\n\t\t\t\t\t then\n begin\n\t\t\t\t f[i+1][son[j,k]]:=(f[i+1][son[j,k]]+f[i][j]) mod mo;\n\t\t\t\t end;\n\t\t\t\t\tif (son[j][k]=0)and(flag[j])\n\t\t\t\t\t then\n\t\t\t\t\t begin\n\t\t\t\t\t\t now:=j;\n\t\t\t\t\t\t while (now<>-1)and(son[now][k]=0) do\n\t\t\t\t\t\t now:=next[now];\n\t\t\t\t\t\t if now<>-1 then f[i+1][son[now][k]]:=(f[i+1][son[now][k]]+f[i][j]) mod mo;\n\t\t\t\t\t\tend;\n\t\t\t\t end;\n\t\t\t end;\n\tend;\n\n begin\n //assign(input,'x.in');reset(input);\n\t//assign(output,'x.out');rewrite(output);\n\treadln(n,m);\n\ttot:=0;\n\tfillchar(flag,sizeof(flag),false);\n\tfor i:=1 to m do\n\t begin\n\t\treadln(st);\n\t\tnn:=length(st);\n\t\tfor j:=1 to nn do\n\t\t case st[j] of\n\t\t 'A':list[j]:=1;\n\t\t\t'C':list[j]:=2;\n\t\t\t'G':list[j]:=3;\n\t\t\t'T':list[j]:=4;\n\t\t end;\n\t\tinsert;\n\t end;\n\tget_ac;\n\trun_ac;\n\tans:=0;\n\tfor i:=0 to tot do\n\t if flag[i]\n\t then ans:=(ans+f[n][i]) mod mo;\n writeln(ans);\n end.\n"}, {"source_code": "program xj;\n\n const\n mo=1000000009;\n\t\n var\n son:array[0..1000,1..4]of longint;\n\tflag:array[0..1000]of boolean;\n\tf:array[0..1000,0..1000]of int64;\n\tq,next,list:array[0..10000]of longint;\n\ti,j,k,n,m,tot,x,y,nn,l1,l2,now,nex:longint;\n\tst:string;\n\tans:int64;\n\t\n procedure insert;\n var\n\t now,ii:longint;\n\tbegin\n\t now:=0;\n\t for ii:=1 to nn do\n\t begin\n\t\t if son[now][list[ii]]=0\n\t\t then begin inc(tot);son[now][list[ii]]:=tot; end;\n\t\t now:=son[now][list[ii]];\n\t\tend;\n\t flag[now]:=true;\n\tend;\n\t\n procedure get_ac;\n begin\n l1:=1;l2:=1;\n q[1]:=0;next[0]:=-1;\n while l1<=l2 do\n begin\n now:=q[l1];\n for i:=1 to 4 do\n begin\n nex:=son[now,i];\n if nex<>0\n then\n begin\n inc(l2);q[l2]:=nex;\n x:=next[now];\n while (x<>-1)and(son[x,i]=0) do x:=next[x];\n if x=-1 then next[nex]:=0\n else next[nex]:=son[x,i];\n end;\n end;\n inc(l1);\n end;\n end;\n\n procedure run_ac;\n var\n\t now:longint;\n\tbegin\n\t fillchar(f,sizeof(f),0);\n\t f[0,0]:=1;\n\t for i:=0 to n do\n\t for j:=0 to tot do\n\t\t if f[i][j]>0\n\t\t then\n\t\t\t begin\n\t\t\t for k:=1 to 4 do\n\t\t\t\t begin\n if son[j,k]<>0\n\t\t\t\t\t then\n begin\n\t\t\t\t f[i+1][son[j,k]]:=(f[i+1][son[j,k]]+f[i][j]) mod mo;\n\t\t\t\t end;\n\t\t\t\t\tif (son[j][k]=0)and(flag[j])\n\t\t\t\t\t then\n\t\t\t\t\t begin\n\t\t\t\t\t\t now:=j;\n\t\t\t\t\t\t while (now<>-1){and(son[now][k]=0)} do\n\t\t\t\t\t\t begin\n\t\t\t\t\t\t\t if son[now][k]<>0\n\t\t\t\t\t\t\t then f[i+1][son[now][k]]:=(f[i+1][son[now][k]]+f[i][j]) mod mo;\n\t\t\t\t\t\t\t now:=next[now];\n\t\t\t\t\t\t end;\n //if now<>-1\n\t\t\t\t\t\t\t //then f[i+1][son[now][k]]:=(f[i+1][son[now][k]]+f[i][j]) mod mo;\n\t\t\t\t\t\tend;\n\t\t\t\t end;\n\t\t\t end;\n\tend;\n\n begin\n //assign(input,'x.in');reset(input);\n\t//assign(output,'x.out');rewrite(output);\n\treadln(n,m);\n\ttot:=0;\n\tfillchar(flag,sizeof(flag),false);\n\tfor i:=1 to m do\n\t begin\n\t\treadln(st);\n\t\tnn:=length(st);\n\t\tfor j:=1 to nn do\n\t\t case st[j] of\n\t\t 'A':list[j]:=1;\n\t\t\t'C':list[j]:=2;\n\t\t\t'G':list[j]:=3;\n\t\t\t'T':list[j]:=4;\n\t\t end;\n\t\tinsert;\n\t end;\n\tget_ac;\n\trun_ac;\n\tans:=0;\n\tfor i:=0 to tot do\n\t if flag[i]\n\t then ans:=(ans+f[n][i]) mod mo;\n writeln(ans);\n end.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\n{$M 10000000}\nconst \n ABC='ACGT';\n base=1000000009;\nvar\n s:string;\n nexto,j,n,m,kb,i,x,o:longint;\n pow,link,pred,predch:array[0..555]of longint;\n leaf:array[0..555]of boolean;\n next:array[0..555,0..5]of longint;\n f:array[0..1111,0..11,0..111]of longint;\n procedure recl(x:longint);\n var\n i,ch:longint;\n begin\n if (link[x]<>-1)then exit;\n if (pred[x]=0)then begin\n link[x]:=0;\n exit;\n end;\n ch:=predch[x];\n i:=pred[x];\n if (link[i]=-1)then recl(i);\n i:=link[i];\n while (i>0)and(next[i][ch]=-1)do begin\n if (link[i]=-1)then recl(i);\n i:=link[i];\n end;\n if (next[i][ch]=-1)\n then i:=0\n else i:=next[i][ch];\n link[x]:=i;\n end;\n function next_bor(x,ch:longint):longint;\n begin\n while (x>0)and(next[x][ch]=-1)do x:=link[x];\n next_bor:=next[x][ch];\n end;\n function rec(i,k,x:longint):longint;\n var\n nextx,ch,res:longint;\n begin\n if (f[i][k][x]<>-1)then begin\n rec:=f[i][k][x];\n exit;\n end;\n if (leaf[x])then k:=0; \n if (k>10)or(pow[x]=base)then dec(res,base);\n end;\n f[i][k][x]:=res;\n rec:=res;\n exit;\n end;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n readln(n,m);\n kb:=0;\n fillchar(next,sizeof(next),$FF);\n fillchar(link,sizeof(link),$FF);\n fillchar(leaf,sizeof(leaf),false);\n link[0]:=0;\n pow[0]:=0;\n for i:=1 to m do begin\n readln(s);\n if (length(s)>n)then continue;\n x:=0;\n for j:=1 to length(s)do begin\n o:=pos(s[j],ABC);\n if (next[x][o]=-1)then begin\n inc(kb);\n next[x][o]:=kb; \n end;\n nexto:=next[x][o];\n pred[nexto]:=x;\n predch[nexto]:=o;\n pow[nexto]:=pow[x]+1;\n x:=nexto;\n end;\n leaf[x]:=true;\n end;\n for i:=0 to kb do recl(i);\n fillchar(f,sizeof(f),$FF);\n writeln(rec(1,0,0));\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\n{$M 10000000}\nconst \n ABC='ACGT';\n base=1000000009;\nvar\n s:string;\n nexto,j,n,m,kb,i,x,o:longint;\n pow,link,pred,predch:array[0..555]of longint;\n leaf:array[0..555]of boolean;\n next:array[0..555,0..5]of longint;\n f:array[0..1111,0..11,0..111]of longint;\n procedure recl(x:longint);\n var\n i,ch:longint;\n begin\n if (link[x]<>-1)then exit;\n if (pred[x]=0)then begin\n link[x]:=0;\n exit;\n end;\n ch:=predch[x];\n i:=pred[x];\n if (link[i]=-1)then recl(i);\n i:=link[i];\n while (i>0)and(next[i][ch]=-1)do begin\n if (link[i]=-1)then recl(i);\n i:=link[i];\n end;\n if (next[i][ch]=-1)\n then i:=0\n else i:=next[i][ch];\n link[x]:=i;\n end;\n function next_bor(x,ch:longint):longint;\n begin\n while (x>0)and(next[x][ch]=-1)do x:=link[x];\n next_bor:=next[x][ch];\n end;\n function rec(i,k,x:longint):longint;\n var\n nextx,ch,res:longint;\n begin\n if (f[i][k][x]<>-1)then begin\n rec:=f[i][k][x];\n exit;\n end;\n if (leaf[x])then k:=0; \n if (k>10)or(pow[x]=base)then dec(res,base);\n end;\n f[i][k][x]:=res;\n rec:=res;\n exit;\n end;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n readln(n,m);\n kb:=0;\n fillchar(next,sizeof(next),$FF);\n fillchar(link,sizeof(link),$FF);\n fillchar(leaf,sizeof(leaf),false);\n link[0]:=0;\n pow[0]:=0;\n for i:=1 to m do begin\n readln(s);\n x:=0;\n for j:=1 to length(s)do begin\n o:=pos(s[j],ABC);\n if (next[x][o]=-1)then begin\n inc(kb);\n next[x][o]:=kb; \n end;\n nexto:=next[x][o];\n pred[nexto]:=x;\n predch[nexto]:=o;\n pow[nexto]:=pow[x]+1;\n x:=nexto;\n end;\n leaf[x]:=true;\n end;\n for i:=0 to kb do recl(i);\n fillchar(f,sizeof(f),$FF);\n writeln(rec(1,0,0));\nend.\n"}, {"source_code": "uses math;\nconst cmod = 1000000009;\n\ntype Ttrie = ^kdl;\nkdl = record\nv:longint;\na:array['A'..'Z'] of TTrie;\nkt:boolean;\nl:longint;\nst:string;\nEnd;\n\nconst maxn=1010;\nmaxnode=1010;\nvar f1,f2:text;\nA:array[1..maxn] of longint;\nTNil:TTrie;\nst:string;\nRoot:TTrie;\nNext:array[1..maxn,'A'..'Z'] of longint;\nF:array[0..maxn,0..20,1..maxnode] of longint;\nVis:array[0..maxn,0..20,1..maxnode] of boolean;\nT:array[1..maxnode] of Ttrie;\nspt,m:longint;\nres:longint;\nn,i:longint;\n\nProcedure init(var u:TTrie);\nvar ch:char;\nbegin\n new(u);\n for ch:='A' to 'Z' do\n u^.a[ch]:=nil;\n inc(spt);\n u^.v:=spt;\n u^.kt:=false;\n u^.l:=0;\n u^.st:='';\n T[spt]:=u;\nend;\n\nFunction Search(st:string):longint;\nvar p:TTrie;\ni:longint;\nbegin\n p:=root;\n for i:=1 to length(st) do\n if p^.a[st[i]]<>nil then p:=p^.a[st[i]] else exit(-1);\n Search:=p^.v;\nend;\n\nProcedure Build(u:TTrie);\nvar p:TTrie;\nch:char;\nx:longint;\nj:longint;\nst:string;\nbegin\n\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1));\n if x<>-1 then\n Begin\n if T[x]^.kt then\n Begin\n u^.kt:=true;\n u^.l:=max(u^.l,T[x]^.l);\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n Begin\n Next[u^.v,ch]:=1;\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1)+ch);\n if x<>-1 then\n Begin\n Next[u^.v,ch]:=x;\n break;\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n if u^.a[ch]<>nil then\n Begin\n Next[u^.v,ch]:=u^.A[ch]^.v;\n Build(u^.A[ch]);\n End;\nend;\n\nProcedure Push;\nvar j:longint;\np:TTrie;\nu:longint;\nbegin\n p:=root;\n For j:=1 to length(st) do\n begin\n if p^.a[st[j]]=nil then Begin\n init(p^.a[st[j]]);\n p^.a[st[j]]^.st:=p^.st+st[j]; End;\n p:=p^.a[st[j]]\n end;\n p^.kt:=true;\n p^.l:=length(st);\nend;\n\nFunction Rec(i,k,j:longint):longint; {den i con k , nut j}\nvar ch:char;\np:TTrie;\nbegin\n if (i=n) then\n exit(longint(k=0));\n if k>10 then exit(0);\n if Vis[i,k,j] then exit(F[i,k,j]);\n Vis[i,k,j]:=true;\n for ch:='A' to 'Z' do\n begin\n if Next[j,ch]<>0 then\n Begin\n p:=T[Next[j,ch]];\n if p^.kt then\n Begin\n if k+1<=p^.l then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,0,Next[j,ch])) mod cmod;\n end\n else\n if Next[j,ch]<>1 then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,k+1,Next[j,ch])) mod cmod;\n End;\n End;\n Rec:=F[i,k,j];\n\nend;\n\nProcedure DP;\nvar i,j:longint;\nch:char;\nbegin\n fillchar(vis,sizeof(vis),false);\n writeln(f2,Rec(0,0,1));\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m);\n Init(root);\n for i:=1 to m do\n Begin\n readln(F1,st);\n push;\n End;\n Build(root);\n DP;\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "uses math;\nconst cmod = 1000000007;\n\ntype Ttrie = ^kdl;\nkdl = record\nv:longint;\na:array['A'..'Z'] of TTrie;\nkt:boolean;\nl:longint;\nst:string;\nEnd;\n\nconst maxn=1000;\nmaxnode=1000;\nvar f1,f2:text;\nA:array[1..maxn] of longint;\nTNil:TTrie;\nst:string;\nRoot:TTrie;\nNext:array[1..maxn,'A'..'Z'] of longint;\nF:array[0..maxn,0..20,1..maxnode] of longint;\nVis:array[0..maxn,0..20,1..maxnode] of boolean;\nT:array[1..maxnode] of Ttrie;\nspt,m:longint;\nres:longint;\nn,i:longint;\n\nProcedure init(var u:TTrie);\nvar ch:char;\nbegin\n new(u);\n for ch:='A' to 'Z' do\n u^.a[ch]:=nil;\n inc(spt);\n u^.v:=spt;\n u^.kt:=false;\n u^.st:='';\n T[spt]:=u;\nend;\n\nFunction Search(st:string):longint;\nvar p:TTrie;\ni:longint;\nbegin\n p:=root;\n for i:=1 to length(st) do\n if p^.a[st[i]]<>nil then p:=p^.a[st[i]] else exit(-1);\n Search:=p^.v;\nend;\n\nProcedure Build(u:TTrie);\nvar p:TTrie;\nch:char;\nx:longint;\nj:longint;\nst:string;\nbegin\n\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1));\n if x<>-1 then\n Begin\n if T[x]^.kt then\n Begin\n u^.kt:=true;\n u^.l:=max(u^.l,T[x]^.l);\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n Begin\n Next[u^.v,ch]:=1;\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-j+1)+ch);\n if x<>-1 then\n Begin\n Next[u^.v,ch]:=x;\n break;\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n if u^.a[ch]<>nil then\n Begin\n Next[u^.v,ch]:=u^.A[ch]^.v;\n Build(u^.A[ch]);\n End;\nend;\n\nProcedure Push;\nvar j:longint;\np:TTrie;\nu:longint;\nbegin\n p:=root;\n For j:=1 to length(st) do\n begin\n if p^.a[st[j]]=nil then Begin\n init(p^.a[st[j]]);\n p^.a[st[j]]^.st:=p^.st+st[j]; End;\n p:=p^.a[st[j]]\n end;\n p^.kt:=true;\n p^.l:=length(st);\nend;\n\nFunction Rec(i,k,j:longint):longint; {den i con k , nut j}\nvar ch:char;\np:TTrie;\nbegin\n if (i=n) then exit(longint(k=0));\n if k>10 then exit(0);\n if Vis[i,k,j] then exit(F[i,k,j]);\n Vis[i,k,j]:=true;\n for ch:='A' to 'Z' do\n begin\n if Next[j,ch]<>0 then\n Begin\n p:=T[Next[j,ch]];\n if p^.kt then\n Begin\n if k+1<=p^.l then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,0,Next[j,ch])) mod cmod;\n end\n else\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,k+1,Next[j,ch])) mod cmod;\n End;\n End;\n Rec:=F[i,k,j];\n\nend;\n\nProcedure DP;\nvar i,j:longint;\nch:char;\nbegin\n writeln(f2,Rec(0,0,1));\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m);\n Init(root);\n for i:=1 to m do\n Begin\n readln(F1,st);\n push;\n End;\n Build(root);\n DP;\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "const cmod = 1000000007;\n\ntype Ttrie = ^kdl;\nkdl = record\nv:longint;\na:array['A'..'Z'] of TTrie;\nkt:boolean;\nst:string;\nEnd;\n\nconst maxn=1000;\nmaxnode=1000;\nvar f1,f2:text;\nA:array[1..maxn] of longint;\nTNil:TTrie;\nst:string;\nRoot:TTrie;\nNext:array[1..maxn,'A'..'Z'] of longint;\nF:array[0..maxn,0..20,1..maxnode] of longint;\nVis:array[0..maxn,0..20,1..maxnode] of boolean;\nT:array[1..maxnode] of Ttrie;\nspt,m:longint;\nres:longint;\nn,i:longint;\n\nProcedure init(var u:TTrie);\nvar ch:char;\nbegin\n new(u);\n for ch:='A' to 'Z' do\n u^.a[ch]:=nil;\n inc(spt);\n u^.v:=spt;\n u^.kt:=false;\n u^.st:='';\n T[spt]:=u;\nend;\n\nFunction Search(st:string):longint;\nvar p:TTrie;\ni:longint;\nbegin\n p:=root;\n for i:=1 to length(st) do\n if p^.a[st[i]]<>nil then p:=p^.a[st[i]] else exit(-1);\n Search:=p^.v;\nend;\n\nProcedure Build(u:TTrie);\nvar p:TTrie;\nch:char;\nx:longint;\nj:longint;\nst:string;\nbegin\n for ch:='A' to 'Z' do\n Begin\n Next[u^.v,ch]:=1;\n For j:=2 to length(u^.st)+1 do\n begin\n x:=search(copy(u^.st,j,length(u^.st)-1)+ch);\n if x<>-1 then\n Begin\n Next[u^.v,ch]:=x;\n break;\n End;\n End;\n End;\n for ch:='A' to 'Z' do\n if u^.a[ch]<>nil then\n Begin\n Next[u^.v,ch]:=u^.A[ch]^.v;\n Build(u^.A[ch]);\n End;\nend;\n\nProcedure Push;\nvar j:longint;\np:TTrie;\nu:longint;\nbegin\n p:=root;\n For j:=1 to length(st) do\n begin\n if p^.a[st[j]]=nil then Begin\n init(p^.a[st[j]]);\n p^.a[st[j]]^.st:=p^.st+st[j]; End;\n p:=p^.a[st[j]]\n end;\n p^.kt:=true;\nend;\n\nFunction Rec(i,k,j:longint):longint; {den i con k , nut j}\nvar ch:char;\np:TTrie;\nbegin\n if (i=n) then exit(longint(k=0));\n if k>10 then exit(0);\n if Vis[i,k,j] then exit(F[i,k,j]);\n Vis[i,k,j]:=true;\n for ch:='A' to 'Z' do\n begin\n\n if Next[j,ch]<>0 then\n Begin\n p:=T[Next[j,ch]];\n if p^.kt then\n Begin\n if k+1<=length(p^.st) then\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,0,Next[j,ch])) mod cmod;\n end\n else\n F[i,k,j]:=(F[i,k,j]+Rec(i+1,k+1,Next[j,ch])) mod cmod;\n End;\n End;\n Rec:=F[i,k,j];\n\nend;\n\nProcedure DP;\nvar i,j:longint;\nch:char;\nbegin\n writeln(f2,Rec(0,0,1));\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m);\n Init(root);\n for i:=1 to m do\n Begin\n readln(F1,st);\n push;\n End;\n Build(root);\n DP;\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "{$mode objfpc}\nconst pm=1000000009;\n\nfunction trans(const ch:char):longint;\nbegin case ch of\n\t\t'A':\texit(0);\n\t\t'C':\texit(1);\n\t\t'G':\texit(2);\n\t\t'T':\texit(3);\n\tend;\nend;\n\ntype\n\tdfa=\tobject\n\t\t\tep,root:longint;\n\t\t\tb:array[0..10010] of record\n\t\t\t\t\t\t\t\tnext:array[0..3] of longint;\n\t\t\t\t\t\t\t\tdepth,fail:longint;\n\t\t\t\t\t\t\t\tflag:boolean;\n\t\t\t\t\t\t\tend;\n\t\t\tq:array[0..10010] of longint;\n\t\t\tfunction Create(x:longint):longint;\n\t\t\tprocedure init();\n\t\t\tprocedure ins(const s:string);\n\t\t\tprocedure build();\n\t\tend;\n\t\n\tfunction dfa.Create(x:longint):longint;\n\tbegin inc(ep); fillchar(b[ep].next,sizeof(b[ep].next),255);\n\t\tb[ep].depth:=x; b[ep].fail:=-1; b[ep].flag:=false; exit(ep);\n\tend;\n\t\n\tprocedure dfa.init();\n\tbegin ep:=0; root:=Create(0); end;\n\t\n\tprocedure dfa.ins(const s:string);\n\tvar cur,i,x:longint;\n\tbegin cur:=root;\n\t\tfor i:=1 to length(s) do\n\t\tbegin x:=trans(s[i]);\n\t\t\tif b[cur].next[x]=-1 then b[cur].next[x]:=Create(b[cur].depth+1);\n\t\t\tcur:=b[cur].next[x];\n\t\tend;\n\t\tb[cur].flag:=true;\n\tend;\n\t\n\tprocedure dfa.build();\n\tvar head,tail,cur,i:longint;\n\tbegin head:=1; tail:=2; q[head]:=root; b[root].fail:=-1;\n\t\twhile head-1 then begin q[tail]:=b[cur].next[i]; inc(tail); end;\n\t\t\t\tif b[cur].fail=-1 then\n\t\t\t\t\tif b[cur].next[i]=-1 then\n\t\t\t\t\t\tb[cur].next[i]:=root\n\t\t\t\t\telse b[b[cur].next[i]].fail:=root\n\t\t\t\telse if b[cur].next[i]=-1 then\n\t\t\t\t\t\tb[cur].next[i]:=b[b[cur].fail].next[i]\n\t\t\t\t\telse b[b[cur].next[i]].fail:=b[b[cur].fail].next[i];\n\t\t\tend;\n\t\tend;\n\tend;\n\t\nvar\nac:dfa;\nss:string;\ndp:array[0..1010,0..110,0..11] of longint;\n\nprocedure lemon();\nvar n,m,i,node,L,k,x,y,ans:longint;\nbegin readln(n,m);\n\tac.init();\n\tfor i:=1 to m do begin readln(ss); ac.ins(ss); end;\n\t//dp[n][node][L]\tlength(n) string having suffix(node) and the first L letters of the suffix have been covered\n\tac.build();\n\twith ac do\n\tbegin dp[0][1][0]:=1;\n\t\tfor i:=0 to n-1 do\n\t\t\tfor node:=1 to ep do\n\t\t\t\tfor L:=0 to b[node].depth do\n\t\t\t\t\tif dp[i,node,L]>0 then\n\t\t\t\t\t\tfor k:=0 to 3 do\n\t\t\t\t\t\tbegin //writeln(i,' ',node,' ',L,' ',k,' ',b[node].next[k]);\n\t\t\t\t\t\t\ty:=b[node].next[k]; if y=-1 then continue;\n\t\t\t\t\t\t\tx:=L-(b[node].depth-b[y].depth+1);\n\t\t\t\t\t\t\tif x>=0 then\n\t\t\t\t\t\t\tbegin if b[y].flag then x:=b[y].depth;\n\t\t\t\t\t\t\t\tinc(dp[i+1,y,x],dp[i,node,L]);\n\t\t\t\t\t\t\t\tif dp[i+1,y,x]>=pm then dec(dp[i+1,y,x],pm);\n\t\t\t\t\t\t\t\t//writeln(i+1,' ',y,' ',x,' ',dp[i+1,y,x]);\n\t\t\t\t\t\t\tend;\n\t\t\t\t\t\tend;\n\tend;\n\tans:=0;\n\tfor i:=1 to ac.ep do ans:=(ans+dp[n,i,ac.b[i].depth]) mod pm;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'86C.in');\n\treset(input);\n{$endif}\nlemon();\nend.\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n dd: boolean;\n sw,s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n sw[1]:='';\n for i:=2 to n do sw[i]:=sw[pv[i]]+pc[i];\n dd:=True;\n while dd do\n begin\n dd:=False;\n for i:=1 to n do\n if word[i] then\n for j:=1 to n do\n if not word[j] then\n if length(sw[j]) > length(sw[i]) then\n if Copy(sw[j],length(sw[j])-length(sw[i])+1,length(sw[i])) = sw[i] then\n begin\n word[j]:=True;\n dd:=True;\n end;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] and (de[jj] >= k+1) then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then break;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n dd: boolean;\n sw,s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n sw[1]:='';\n for i:=2 to n do sw[i]:=sw[pv[i]]+pc[i];\n dd:=True;\n while dd do\n begin\n dd:=False;\n for i:=1 to n do\n if word[i] then\n for j:=1 to n do\n if not word[j] then\n if length(sw[j]) > length(sw[i]) then\n if Copy(sw[j],length(sw[j])-length(sw[i])+1,length(sw[i])) = sw[i] then\n begin\n word[j]:=True;\n dd:=True;\n end;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] and (de[jj] >= k) then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n dd: boolean;\n sw,s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n sw[1]:='';\n for i:=2 to n do sw[i]:=sw[pv[i]]+pc[i];\n dd:=True;\n while dd do\n begin\n dd:=False;\n for i:=1 to n do\n if word[i] then\n for j:=1 to n do\n if not word[j] then\n if length(sw[j]) > length(sw[i]) then\n if Copy(sw[j],length(sw[j])-length(sw[i])+1,length(sw[i])) = sw[i] then\n begin\n word[j]:=True;\n dd:=True;\n end;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = round(1e9+9);\n let: string = 'ACGT';\nvar\n ans,ii,jj,kk,max,km,nn,m,n,i,j,t,q,k: longint;\n dd: boolean;\n sw,s: array [0..110] of string;\n ss,st: string;\n a: array [0..110,'A'..'Z'] of longint;\n fn: array [0..110,0..110] of longint;\n word: array [0..110] of boolean;\n pv,de,len: array [0..110] of longint;\n pc: array [0..110] of char;\n f: array [0..1010,0..110,0..11] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(nn,m);\n fillchar(a,sizeof(a),0);\n fillchar(word,sizeof(word),False);\n n:=1;\n de[1]:=0;\n for i:=1 to m do\n begin\n readln(s[i]);\n len[i]:=length(s[i]);\n t:=1;\n for j:=1 to len[i] do\n begin\n if a[t,s[i,j]] = 0 then\n begin\n inc(n);\n pv[n]:=t;\n pc[n]:=s[i,j];\n de[n]:=de[t]+1;\n a[t,s[i,j]]:=n;\n end;\n t:=a[t,s[i,j]];\n end;\n word[t]:=True;\n end;\n sw[1]:='';\n for i:=2 to n do sw[i]:=sw[pv[i]]+pc[i];\n dd:=True;\n while dd do\n begin\n dd:=False;\n for i:=1 to n do\n if word[i] then\n for j:=1 to n do\n if not word[j] then\n if length(sw[j]) > length(sw[i]) then\n if Copy(sw[j],length(sw[j])-length(sw[i])+1,length(sw[i])) = sw[i] then\n begin\n word[j]:=True;\n dd:=True;\n end;\n end;\n for i:=1 to n do\n for q:=1 to 4 do\n begin\n st:='';\n t:=i;\n while t > 1 do\n begin\n st:=pc[t]+st;\n t:=pv[t];\n end;\n st:=st+let[q];\n max:=0; km:=1;\n for ii:=2 to n do\n begin\n ss:=''; t:=ii;\n while t > 1 do\n begin\n ss:=pc[t]+ss;\n t:=pv[t];\n end;\n if length(ss) > length(st) then continue;\n if Copy(st,length(st)-length(ss)+1,length(ss)) = ss then\n if length(ss) > max then\n begin\n max:=length(ss);\n km:=ii;\n end;\n end;\n fn[i,q]:=km;\n end;\n fillchar(f,sizeof(f),0);\n f[0,1,0]:=1;\n for i:=0 to nn-1 do\n for j:=1 to n do\n for k:=0 to de[j] do\n if f[i,j,k] > 0 then\n for q:=1 to 4 do\n begin\n ii:=i+1;\n jj:=fn[j,q];\n kk:=k+1;\n if word[jj] and (de[jj] >= k+1) then kk:=0;\n inc(f[ii,jj,kk],f[i,j,k]);\n if f[ii,jj,kk] >= md then dec(f[ii,jj,kk],md);\n end;\n ans:=0;\n for i:=1 to n do ans:=(ans+f[nn,i,0]) mod md;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "const mode=1000000009;\nvar tot,n,m,now:longint;\ntrie1,trie2:array[0..1000,1..4]of longint;\nfail,q:array[0..1000]of longint;\ndanger:array[0..1000]of boolean;\nf:array[0..1000,0..1000]of longint;\nprocedure insert(x:longint);\nbegin\n if trie1[now,x]=0 then\n begin\n inc(tot);\n trie1[now,x]:=tot;\n now:=tot;\n end else now:=trie1[now,x];\nend;\nprocedure init;\nvar i,j:longint;\nst:string;\nbegin\n tot:=1;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(st);\n now:=1;\n for j:=1 to length(st) do\n begin\n if st[j]='A' then insert(1);\n if st[j]='C' then insert(2);\n if st[j]='G' then insert(3);\n if st[j]='T' then insert(4);\n end;\n danger[now]:=true;\n end;\nend;\nprocedure build;\nvar head,tail,i,x:longint;\nbegin\n trie2:=trie1;tail:=0;\n for i:=1 to 4 do\n begin\n if trie2[1,i]=0 then trie2[1,i]:=1\n else\n begin\n inc(tail);\n q[tail]:=trie2[1,i];\n fail[trie2[1,i]]:=1;\n end;\n end;\n head:=1;\n repeat\n x:=q[head];\n danger[x]:=danger[x] or danger[fail[x]];\n for i:=1 to 4 do\n begin\n if trie2[x,i]=0 then trie2[x,i]:=trie2[fail[x],i]\n else\n begin\n inc(tail);\n q[tail]:=trie2[x,i];\n fail[trie2[x,i]]:=trie2[fail[x],i];\n end;\n end;\n inc(head);\n until head>tail;\nend;\nprocedure work;\nvar i,j,k,ans:longint;\nbegin\n f[0,1]:=1;\n for i:=0 to n-1 do\n for j:=1 to tot do\n begin\n if f[i,j]=0 then continue;\n for k:=1 to 4 do\n begin\n if danger[j] then\n begin\n if trie2[j,k]<>1 then\n f[i+1,trie2[j,k]]:=(f[i+1,trie2[j,k]]+f[i,j])mod mode;\n end\n else\n begin\n if trie1[j,k]<>0 then\n begin\n f[i+1,trie1[j,k]]:=(f[i+1,trie1[j,k]]+f[i,j])mod mode;\n end;\n end;\n end;\n end;\n ans:=0;\n for i:=1 to tot do\n if danger[i] then ans:=(ans+f[n,i])mod mode;\n writeln(ans);\nend;\nbegin\n init;\n build;\n work;\nend."}, {"source_code": "const mode=1000000009;\nvar tot,n,m,now:longint;\ntrie1,trie2:array[0..1000,1..4]of longint;\nfail,q,danger:array[0..100]of longint;\nf:array[0..1000,0..100,0..10]of longint;\nfunction getmax(a,b:longint):longint;\nbegin\n if a>b then getmax:=a else getmax:=b;\nend;\nprocedure insert(x:longint);\nbegin\n if trie1[now,x]=0 then\n begin\n inc(tot);\n trie1[now,x]:=tot;\n now:=tot;\n end else now:=trie1[now,x];\nend;\nprocedure init;\nvar i,j:longint;\nst:string;\nbegin\n tot:=1;\n readln(n,m);\n for i:=1 to m do\n begin\n readln(st);\n now:=1;\n for j:=1 to length(st) do\n begin\n if st[j]='A' then insert(1);\n if st[j]='C' then insert(2);\n if st[j]='G' then insert(3);\n if st[j]='T' then insert(4);\n end;\n danger[now]:=length(st);\n end;\nend;\nprocedure build;\nvar head,tail,i,x:longint;\nbegin\n trie2:=trie1;tail:=0;\n for i:=1 to 4 do\n begin\n if trie2[1,i]=0 then trie2[1,i]:=1\n else\n begin\n inc(tail);\n q[tail]:=trie2[1,i];\n fail[trie2[1,i]]:=1;\n end;\n end;\n head:=1;\n repeat\n x:=q[head];\n danger[x]:=getmax(danger[x],danger[fail[x]]);\n for i:=1 to 4 do\n begin\n if trie2[x,i]=0 then trie2[x,i]:=trie2[fail[x],i]\n else\n begin\n inc(tail);\n q[tail]:=trie2[x,i];\n fail[trie2[x,i]]:=trie2[fail[x],i];\n end;\n end;\n inc(head);\n until head>tail;\nend;\nprocedure work;\nvar i,j,k,ans,v:longint;\nbegin\n f[0,1,0]:=1;\n for i:=0 to n-1 do\n for j:=1 to tot do\n for v:=0 to 9 do\n begin\n if f[i,j,v]=0 then continue;\n for k:=1 to 4 do\n begin\n if v=0 then\n begin\n if trie2[j,k]=1 then continue;\n if danger[trie2[j,k]]>v then f[i+1,trie2[j,k],0]:=(f[i+1,trie2[j,k],0]+f[i,j,v])mod mode\n else f[i+1,trie2[j,k],1]:=(f[i+1,trie2[j,k],1]+f[i,j,0])mod mode;\n end\n else\n begin\n if trie1[j,k]=0 then continue;\n if danger[trie1[j,k]]>v then f[i+1,trie1[j,k],0]:=(f[i+1,trie1[j,k],0]+f[i,j,v])mod mode\n else f[i+1,trie1[j,k],v+1]:=(f[i+1,trie1[j,k],v+1]+f[i,j,v])mod mode;\n end;\n end;\n end;\n ans:=0;\n for i:=1 to tot do\n ans:=(ans+f[n,i,0])mod mode;\n writeln(ans);\nend;\nbegin\n init;\n build;\n work;\nend."}], "src_uid": "3f053c07deaac55c2c51df6147080340"} {"source_code": "var a,b,x,y,z,br:int64;\nbegin\n read(a,b);\n read(x,y,z);\n\n br:=0;\n\n if (x*2<=a) then a:=a-x*2\n else\n begin\n br:=br+(x*2-a);\n a:=0;\n end;\n\n if (z*3<=b) then b:=b-z*3\n else\n begin\n br:=br+(z*3-b);\n b:=0;\n end;\n\n if (y<=a)and(y<=b)then\n begin\n a:=a-y;\n b:=b-y;\n end\n else\n begin\n if y>a then br:=br+(y-a);\n if y>b then br:=br+(y-b);\n end;\n\n writeln(br);\nend.\n\n\n\n", "positive_code": [{"source_code": "var x,y,a,b,c:int64;\n need:array[0..10]of int64;\nfunction max(a,b:int64):int64;\nbegin\n if a>b then exit(a) else exit(b);\nend;\nbegin\n read(x,y);\n readln(a,b,c);\n inc(need[1],a*2);\n inc(need[1],b);\n inc(need[2],b);\n inc(need[2],c*3);\n writeln(max(need[1]-x,0)+max(need[2]-y,0));\nend."}, {"source_code": "//fpc 3.0.0\n\nvar a,b,x,y,z,ans,aa,bb,ra,rb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n \n aa:=x*2+y;\n bb:=z*3+y;\n ra:=aa-a; if ra<0 then ra:=0;\n rb:=bb-b; if rb<0 then rb:=0;\n ans:=ra+rb;\n writeln(ans);\nend.\n"}, {"source_code": "var n,m,x,y,z:int64;\n jelt,ans:int64;\n si:int64;\n\nbegin\nread(n,m);\nread(x,y,z);\njelt:=jelt+(x*2);\njelt:=jelt+y;\nsi:=0;\n\nsi:=si+y;\nsi:=si+(z*3);\n\n\n\nif n=a then g:= g - a\n else g:=0;\n if s>=b then s:= s - b\n else s:=0;\n write(g+s);\nend."}, {"source_code": "uses math;\nvar zh,zel, sin, kzh, ksin:int64;\nbegin\n read(kzh,ksin);\n read(zh, zel, sin);\n write(max(zh*2+zel - kzh,0) + max(zel+3*sin - ksin,0));\nend."}, {"source_code": "var A,B,y,g,s,res : int64;\nBEGIN\n readln(A,B);\n readln(y,g,s);\n A-= y*2 + g; B-= s*3 +g;\n if A < 0 then res-=A;\n if B < 0 then res-=B;\n write(res);\n readln\nEND. "}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n st:string;\n n,m,k:longint;\n a:array[1..1000000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n a,b,x,y,z:int64;\n begin\n read(fi,a,b,x,y,z);\n writeln(fo,max(x*2+y-a,0)+max(y+z*3-b,0));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "program tricky_alchemy;\nvar\n\tx,y,z,a,b,want_a,want_b,few:int64;\nbegin\n\treadln(a,b);\n\treadln(x,y,z);\n\tfew:=0;\n\twant_a:=x*2+y;\n\twant_b:=z*3+y;\n\tif want_a>a then few:=few+want_a-a;\n\tif want_b>b then few:=few+want_b-b;\n\twriteln(few);\nend. "}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,k : int64;\ni : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\ns1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;\na1 : array[1..100000] of longint;\nbegin\nreadln(x1,x2);\nreadln(x3,x4,x5);\n{x6:=x3*2-x1;\nif x6<=0 then begin x6:=0; x1:=x1-x3*2; end;\nx7:=x4-x1;\nif x7<=0 then begin x7:=0; x1:=x1-x4; end;\nx8:=x4-x2;\nif x8<=0 then begin x8:=0; x2:=x2-x4; end;\nx9:=x5*3-x2;\nif x9<=0 then begin x9:=0; x2:=x2-x5*3; end;}\n\nx6:=x3*2+x4;\nx7:=x5*3+x4;\n\nif x6>x1 then begin x8:=x6-x1; end;\nif x7>x2 then begin x9:=x7-x2; end;\nwriteln(x8+x9);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var a,b,x,y,z:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n a:=-a;\n b:=-b;\n a:=a+2*x;\n a:=a+y;\n b:=b+y;\n b:=b+3*z;\n \n if (a>0) and (b>0) then writeln(a+b) else if a>0 then writeln(a) else if b>0 then writeln(b) else writeln(0);\nend."}, {"source_code": "var a,b,x,y,z:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n a:=-a;\n b:=-b;\n a:=a+2*x;\n a:=a+y;\n b:=b+y;\n b:=b+3*z;\n if (a>0) and (b>0) then writeln(a+b) else if a>0 then writeln(a) else if b>0 then writeln(b) else writeln(0);\nend."}, {"source_code": "var a,b,c,d,i,s:int64;\nbegin\nreadln(a,b);\nreadln(c,d,i);\na:=a-c*2;\na:=a-d;\nb:=b-d;\nb:=b-i*3;\nif a<0\n then s:=abs(a);\nif b<0\n then s:=s+abs(b);\nwrite(s);\nend."}, {"source_code": "var a, b, x, y, z, a1, b1:int64;\nbegin\n read(a, b, x, y, z);\n a1:=(2*x+y)-a;\n if a1<0 then a1:=0;\n b1:=(y+3*z)-b;\n if b1<0 then b1:=0;\n write(a1+b1);\nend."}, {"source_code": "uses math;\nvar y, g, b, y1, b1: int64;\n ans: int64;\nBEGIN\n readln(y1, b1);\n readln(y, g, b);\n //writeln;\n ans:= max(0, 2*y+g - y1) + max(0, 3*b+g-b1);\n writeln(ans);\n //readln;\nEND.\n"}, {"source_code": "var a,b,sum,sum1,sum2,z,x,y:int64;\ns,s1:ansistring;\ni,j:longint;\nc,v:array[0..1000000] of int64;\nbegin\n\nreadln(A,B);\nread(x,y,z);\nsum1:=sum1+(x*2)+y;\nsum2:=sum2+(z*3)+y;\nif a-sum1<0 then sum:=sum+(sum1-a);\nif b-sum2<0 then sum:=sum+(sum2-b);\nwrite(sum);\nend.\n"}, {"source_code": "var\ta,b,c,d,e,dem,dem1,kq:int64;\n\nbegin\n\treadln(a,b);\n\treadln(c,d,e);\n\tdem:=0;\n\tdem1:=0;\n\tinc(dem,c*2);\n\tinc(dem,d);\n\tinc(dem1,d);\n\tinc(dem1,e*3);\n\tkq:=0;\n\tif a0 then sum:=sum+t;\n if s>0 then sum:=sum+s;\n write(sum);\nend."}, {"source_code": "uses math;\nvar\n i,j,x,y,z,a,b,c:int64;\n arr:array[0..1000000] of longint;\nbegin\n read(i,j,x,y,z);\n c:=y+3*z;\n a:=2*x+y;\n b:=max(a-i,0)+max(c-j,0);\n writeln(b);\n\nend."}, {"source_code": "Var a , b , c , x , y , z , add , yellow , blue : Int64;\n\nFunction Max(m , n : Int64) : Int64;\nBegin If m > n then Exit(m) else Exit(n); End;\n\nBegin\nReadln(a , b , x , y , z);\nYellow := Max(0 , x * 2 + y - a);\nBlue := Max(0 , z * 3 + y - b);\nAdd := Yellow + Blue;\nWriteln(Add);\nEnd."}, {"source_code": "var x,y,a,b,c,q:int64;\nbegin\nread(x,y,a,b,c);\nx-=a*2;\nx-=b;\ny-=b;\ny-=3*c;\nif x>=0 then x:=0;\nif y>=0 then y:=0;\nwrite((x+y)*(-1))\nend."}, {"source_code": "Program z1;\nvar A,B,X,Y,Z,S:int64;\nbegin\nreadln(a,b);\nread(x,y,z);\nif x*2+y>A then S:=X*2+y-a;\nif z*3+y>B then S:=S+Z*3+Y-B;\nwrite(s);\nend."}, {"source_code": "var x,y,a,b,c,q:int64;\nbegin\nread(x,y,a,b,c);\nx-=a*2;\nx-=b;\ny-=b;\ny-=3*c;\nif x>=0 then x:=0;\nif y>=0 then y:=0;\nwrite((x+y)*(-1))\nend."}, {"source_code": "program crystals;\nvar y,b,yk,bk,gk,ky,kb:int64;\nbegin\nreadln(y,b);\nreadln(yk,gk,bk);\nky:=yk*2+gk;\nkb:=bk*3+gk;\nif y>=ky then ky:=0\nelse ky:=ky-y;\nif b>=kb then kb:=0\nelse kb:=kb-b;\nwriteln(ky+kb);\nend.\n"}, {"source_code": "var a,b,x,y,z,a1,b1:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n a1:=x*2+y;\n b1:=z*3+y;\n if (a1>a)and(b1>b)then\n writeln(a1-a+b1-b);\n if (a1>a)and(b1<=b)then\n writeln(a1-a);\n if (a1<=a)and(b1>b)then\n writeln(b1-b);\n if (a1<=a)and(b1<=b)then\n writeln('0');\nend.\n"}, {"source_code": "var a,s,d,f,g,q,w,e,r,t,y: int64;\nbegin\n read (a,s,d,f,g);\n q:=d*2+f;\n w:=g*3+f;\n if q<=a then begin\n q:=0;\n end else q:=q-a;\n if w<=s then begin\n w:=0;\n end else w:=w-s;\n e:=q+w;\n write (e);\nend."}, {"source_code": "var\n n,m,a,b,c,s1,s2,ans:int64;\nbegin\n read(n,m,a,b,c);\n s1:=2*a+b-n;\n s2:=b+3*c-m;\n if s1>0 then ans:=ans+s1;\n if s2>0 then ans:=ans+s2;\n writeln(ans);\nend."}, {"source_code": "//For yellow - 2 yc\n//For green - 1 yc 1 bc\n//For blue - 3 bc\nvar\na,b,x,y,z:int64;\nreq_a,req_b:int64;\nres:int64;\n\nbegin\nreadln(a,b);\nreadln(x,y,z);\nreq_a:=x*2+y;\nreq_b:=z*3+y;\nreq_a:=req_a-a;\nif req_a<0 then req_a:=0;\nreq_b:=req_b-b;\nif req_b<0 then req_b:=0;\nres:=req_a+req_b;\nwriteln(res);\nend."}, {"source_code": " var\n\t\tm, n: int64;\n\t\ta, b, c: int64;\n\t\tyellow, green, blue: int64;\n\t\t\n begin\n\t\t\n\t\treadln(n, m);\n\t\treadln(a, b, c);\n\t\t\n\t\twriteln(max(0, 2*a+b - n) + max(0, 3*c+b - m));\n\t\t\n\t\t\n\t\t\n end.\n"}, {"source_code": "var i,j,a,b,c,x,y,z: int64;\nbegin\n read(a,b,x,y,z);\n J:=2*x+y;\n if a>j then i:=0 else i:=j-a;\n J:=3*z+y;\n if b>j then j:=0 else j:=j-b;\n write(j+i);\nend."}, {"source_code": "begin\n var a,b,c,n,m:int64;\n var r:biginteger;\n read(n,m,a,b,c);\n var s:=(n-(a*2)-b);\n var w:=(m-(c*3)-b);\n if(s<0)then r+=abs(s);\n if(w<0)then r+=abs(w);\n write(r);\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n { int64=longint; }\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var j2,j1,maxright,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n posx,posy,mask,k, step, i,j:longint;\n x,ottt:mass;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n z,nnx,nny,nx,ny,tr,fact,aold,y,och,s,d11,prev,next,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n peres, ppole:array[-1..200,-10..1500] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n sot,ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n ddright,ddleft,ddsumleft,ddsumright,ddsum:array[-1..1502,-1..1502] of int64;\n zzan,zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(aa,bb);\n read(p1,p2,p3);\n t1:=2*p1+p2;\n t2:=p2+3*p3;\n { writeln(t1,' ',t2);\n }\n writeln(max(t1-aa,0)+max(t2-bb,0));\n\n\n\n \n\n 1: close(output);\nend.\n"}, {"source_code": "program Zanimatelnaia_alhimia;\n\n{$APPTYPE CONSOLE}\n\nvar a,b,c,x,y,z,yellow,blue: int64;\n\nbegin\n readln(a,b);\n read(x,y,z);\n c:=0;\n yellow:=a-(2*x+y);\n blue:=b-(3*z+y);\n if yellow<0 then c:=c+abs(yellow);\n if blue<0 then c:=c+abs(blue);\n write(c);\nend.\n "}, {"source_code": "var\na, b, c, d, x, y, z:int64;\n\nbegin\n\nreadln(a,b);\nreadln(x,y,z);\n\nc:=(2*x + y) - a;\nif c < 0 then c:=0;\n\nd:=(y + 3*z) - b;\nif d < 0 then d:=0;\n\nwriteln(c+d);\n\nend."}, {"source_code": "PROGRAM PR1;\nVAR A,B,X,Y,Z,GEL1,GEL2,GEL,SIN1,SIN2,SIN,S:REAL;\nBEGIN\nREAD(A,B);\nREADLN(X,Y,Z);\nGEL1:=X*2;\nGEL2:=Y;\nGEL:=GEL1+GEL2;\nSIN1:=Z*3;\nSIN2:=Y;\nSIN:=SIN1+SIN2;\nIF ((SIN=B) OR (B>SIN)) AND ((GEL=A) OR (A>GEL)) THEN S:=0;\nIF (ASIN)) THEN S:=S+(GEL-A);\nIF (BGEL)) THEN S:=S+(SIN-B);\nIF (A0 then x:=0;\nif y>0 then y:=0;\nwrite((x+y)*(-1))\nend.\n"}, {"source_code": "program r456_1;\nvar a,b,x,y,z:uint64;\nbegin\n readln(a,b);\n readln(x,y,z);\n if 2*x+y<=a \n then a:=0\n else a:=2*x+y-a;\n if y+3*z<=b \n then b:=0 else \n b:=y+3*z-b;\n writeln(a+b)\nend.\n\n{12345678 87654321\n43043751 1000000000 53798715\n2147483648}"}, {"source_code": "Var\n A, B, x, y, z: Int64;\n \nBegin\n Read(A, B, x, y, z);\n Write(max(0, (2*x + y) - A) + max(0, (3*z + y) - B))\nEnd."}, {"source_code": "var sh,si:int64;\nvar j,z,s,kj,ks,k:int64;\nbegin\nreadln(sh,si);\nreadln (j,z,s);\nkj := j*2 + z - sh;\nks := z + s*3 - si;\nif (kj >= 0) and (ks >= 0) then k := kj + ks else\nif (kj < 0) and (ks >= 0) then k := 0 + ks else\nif (kj >= 0) and (ks < 0) then k := kj + 0 else\nk := 0;\nwriteln(k);\nend.\n"}, {"source_code": "var x,y,a,b,c,q:int64;\nbegin\nread(x,y,a,b,c);\nx-=a*2;\nx-=b;\ny-=b;\ny-=3*c;\nif x>=0 then x:=0;\nif y>=0 then y:=0;\nwrite((x+y)*(-1))\nend.\n"}, {"source_code": "var\n A, B, x, y, z, answer, nadoA, nadoB: int64;\n\nbegin\n readln(A, B);\n readln(x, y, z);\n nadoA := x * 2 + y;\n nadoB := y + z * 3;\n if nadoA > A then\n answer := nadoA - A;\n if nadoB > B then\n answer := answer + (nadoB - B);\n write(answer);\nend."}, {"source_code": "begin\n var a,b,c,n,m:int64;\n var r:biginteger;\n read(n,m,a,b,c);\n var s:=(n-(a*2)-b);\n var w:=(m-(c*3)-b);\n if(s<0)then r+=abs(s);\n if(w<0)then r+=abs(w);\n write(r);\nend."}, {"source_code": "Var\n A, B: Int64;\n mas: Array [1..2] of Int64;\n\nBegin\n Read(A, B);\n mas[1] := A; mas[2] := B;\n Read(A); mas[1] -= 2*A;\n Read(A); mas[1] -= A; mas[2] -= A;\n Read(A); mas[2] -= 3*A;\n If (mas[1] <= 0) and (mas[2] <= 0) then Write(abs(mas[1] + mas[2]))\n Else If mas[1] <= 0 then Write(abs(mas[1]))\n Else If mas[2] <= 0 then Write(abs(mas[2]))\n Else Write(0)\nEnd."}, {"source_code": "program a1;\n\nvar a, b, x, y, z, si, zh : int64;\n\nbegin\n readln (a, b);\n readln (x, y, z);\n zh := x*2 + y;\n si := y + z*3;\n if (zh < a) then\n zh := 0\n else zh := zh - a;\n if (si < b) then\n si := 0\n else si := si - b;\n writeln (si + zh);\nend."}, {"source_code": "var a,b:int64;\n x,y,z:int64;\n s,sy,sb:int64;\nbegin\n s:=0;\n sy:=0;\n sb:=0;\n read(a,b);\n read(x,y,z);\n sy:=2*x+y;\n sb:=y+3*z;\n sy:=a-sy;\n if sy>=0 then sy:=0\n else sy:=-sy;\n sb:=b-sb;\n if sb>=0 then sb:=0\n else sb:=-sb;\n write(sy+sb);\nend."}, {"source_code": "Program Balls;\nvar a,b,x,y,z:int64;\n\nFunction min(a,b:int64):int64;\nbegin\nif a0 then a:=0;\nb:=b-3*z-y;\nif b>0 then b:=0;\nwriteln(-a-b);\n\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nfunction pr(q:int64):int64;\nbegin\n if q>0 then\n pr:=q else\n pr:=0;\nend;\nbegin\n readln(a,b);\n readln(x,y,z);\n c:=pr((x*2+y)-a);\n c:=c+pr((y+z*3)-b);\n writeln(c);\nend."}, {"source_code": "uses math;\nvar\n a, b, x, y, z, ra, rb, ans:int64;\nBEGIN\n readln(a, b, x, y, z);\n ra:= x*2 + y;\n rb:= y + 3*z;\n ans := max(ra-a, 0) + max(rb-b,0);\n write(ans);\nEND."}, {"source_code": "Program TrickyAlchemy;\nuses math;\nvar A,B,x,y,z,x1,z1:int64;\nbegin //assign(input,'912A.inp'); reset(input);\n //assign(output,'912A.out'); rewrite(output);\n readln(A,B); readln(x,y,z);\n x1:=2*x+y; z1:=3*z+y;\n if (A<=x1) and (B<=z1) then writeln(abs(x1-A)+abs(z1-B))\n else begin\n if (A>=x1) and (not(B>=z1)) then writeln(abs(z1-B))\n else if (B>=z1) and (not(A>=x1)) then writeln(abs(x1-A))\n else writeln(0);\n end;\n //close(input); close(output);\nend."}, {"source_code": "uses\n Math;\n\nvar\n A, B, x, y, z, NeedA, NeedB: Int64;\n\nbegin\n Read(A, B, x, y, z);\n ReadLn; ReadLn;\n\n NeedA := x*2 + y;\n NeedB := y + z*3;\n\n NeedA := max(NeedA - A, 0);\n NeedB := max(NeedB - B, 0);\n\n WriteLn(NeedA + NeedB);\nend.\n"}, {"source_code": "program zzz;\nvar\n a,b,x,y,z,sa,sb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n sa:=x*2 + y-a;\n sb:=z*3+y-b;\n if sa<0 then sa:=0;\n if sb<0 then sb:=0;\n writeln(sa+sb);\nend."}, {"source_code": "program hrn;\n var\n a,b,x,y,z,k:int64;\n begin\n read(a,b,x,y,z);\n a:=a-(2*x)-y;\n b:=b-(3*z)-y;\n if a<0 then k:=k-a;\n if b<0 then k:=k-b;\n write(k);\n end."}, {"source_code": "uses math;\nvar a,b,x,y,z,tmp,tmp1:int64;\nbegin\n //assign(input,'a.inp');reset(input);\n read(a,b);\n read(x,y,z);\n tmp:=x*2+y;\n tmp1:=z*3+y;\n tmp:=max(tmp-a,0);\n tmp1:=max(tmp1-b,0);\n write(tmp+tmp1);\n //close(input);\nend."}, {"source_code": "var\n a,b,x,y,sum1,sum2,z:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n sum1:=2*x+y;\n sum2:=3*z+y;\n sum1:=sum1-a;\n sum2:=sum2-b;\n if sum1<0 then sum1:=0;\n if sum2<0 then sum2:=0;\n writeln(sum1+sum2);\nend."}, {"source_code": "var\n x,y,a,b,c,x1,y1,s:int64;\nbegin\n readln(x,y);\n readln(a,b,c);\n x1:=2*a+b-x;\n y1:=3*c+b-y;\n if x1>0 then s:=s+x1;\n if y1>0 then s:=s+y1;\n writeln(s);\nend."}, {"source_code": "var n,m,x,y,z,a,b:int64;\nbegin\n\n\nreadln(n,m);\nreadln(x,y,z);\na:=2*x+y-n;b:=y+3*z-m;\nif a<0then a:=0;\nif b<0then b:=0;\nwriteln(a+b);\n\n\nend."}, {"source_code": "var a,b,x,y,z,x1,s :int64;\nbegin\n\n\nreadln(a,b);\nreadln(x,y,z);\nx1:=x*2+y;\nif x1>a then s:=s+x1-a;\nx1:=z*3+y;\nif x1>b then s:=s+x1-b;\nwriteln(s);\n\n\nend."}, {"source_code": "\nvar h,l,x,y,z,zl,zh,s:int64;\nbegin\n\nreadln(h,l);\nreadln(x,y,z);\nzl:=zl+z*3;\nzl:=zl+y;\nzh:=zh+2*x;zh:=zh+y;\nif zh>h then s:=s+zh-h;\nif zl>l then s:=s+zl-l;\nwriteln(s);\n\n\nend.\n"}, {"source_code": "var\n a, b, x, y, z, blue, yellow : int64;\nfunction max(a, b : int64) : int64;\n begin\n \tif a > b \n \t then max := a\n \t else max := b;\n end;\nbegin\n readln(a, b);\n readln(x, y, z);\n yellow := x * 2 + y;\n blue := z * 3 + y;\n writeln(max(0, yellow - a) + max(0, blue - b));\nend."}, {"source_code": "uses math;\nconst fin='';\n fout='';//x vang, y xanh la, z xanh duong\nvar f,g:text;\n a,b,x,y,z,blue,yel,qa:int64;\n \n\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,a,b);\n read(f,x,y,z);\n blue:=z*3+y;\n yel:=x*2+y;\n qa:=max(0,yel-a)+max(0,blue-b);\n if qa>0 then write(g,qa)\n else write(g,0);\n close(f);\n close(g);\nend."}, {"source_code": "uses math;\nvar\na,b,x,y,z,j,c:int64;\nbegin\nreadln(a,b);\nreadln(x,y,z);\nj:=x*2+y;\nc:=y+z*3;\nj:=max(0,j-a);\nc:=max(0,c-b);\nwrite(j+c);\nend."}, {"source_code": "var\n g,s,a,b,x,y,z,ans,i,j:int64;\nbegin\n readln (a,b);\n readln (x,y,z);\n g:=x*2+y;\n s:=y+3*z;\n i:=a-g;\n j:=b-s;\n ans:=0;\n if (i>=0)and(j>=0) then ans:=0\n else\n begin\n if i<0 then ans:=ans+abs(i);\n if j<0 then ans:=ans+abs(j);\n end;\n writeln (ans);\nend.\n"}, {"source_code": "program z1;\nvar z, x, y, sum, a, b, c, i:int64;\nbegin \n readln( a, b );\n Readln( z, x, y );\n c := z * 2 + x * 1 ;\n i := x * 1 + y * 3 ;\n sum := 0 ;\n \n if a < c\n then sum := sum + (c - a ) ;\n if b < i\n then sum := sum + ( i - b ) ;\n writeln(sum);\nend."}, {"source_code": "program hym;\nvar\n\tYk,Bk: int64;\n\tYsh, Gsh, Bsh:int64;\nbegin\n readln(Yk, Bk);\n\treadln(Ysh, Gsh, Bsh);\n\tYk := Yk - Ysh*2 -Gsh;\n\tBk := Bk - Gsh - Bsh*3;\n\tYsh := 0;\n\tif Yk< 0 then Ysh := abs(Yk);\n\tif Bk< 0 then Ysh := Ysh + abs(Bk);\n\twriteln(Ysh);\nend.\n"}, {"source_code": "program CF912_A;\nuses math;\nvar a,b,x,y,z,vang,xanh,res: int64;\nbegin\n\treadln(a,b);\n\treadln(x,y,z);\n\tvang:=2*x+y;\n\txanh:=y+3*z;\n\tif vang-a <0 then vang:=0 else vang:=vang-a;\n\tif xanh-b <0 then xanh:=0 else xanh:=xanh-b;\n\tres:=vang+xanh;\n\twrite(res);\nend."}, {"source_code": "type \narr=array [1..1000,1..2] of double;\nvar \na,b,c1,c2,x,y,z: int64;\nflag,flag1,flag2,kod: integer;\n\n\n\nbegin\n readln(a,b);\n readln(x,y,z);\n c1:=2*x+y-a;\n c2:=y+3*z-b;\n if (c1<0) then c1:=0;\n if (c2<0) then c2:=0;\n writeln(c1+c2);\nend."}, {"source_code": "uses math;\nvar x,y,z,a,b,res:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n writeln(max(0,x*2+y-a)+max(0,z*3+y-b));\n readln;\nend.\n"}, {"source_code": "var\nans,a,b,x,y,z:int64;\nbegin\nreadln(a,b);\nreadln(x,y,z);\na:=a-2*x;\na:=a-y;\nb:=b-y;\nb:=b-3*z;\nif a<0 then ans:=abs(a);\nif b<0 then ans:=ans+abs(b);\nwriteln(Ans);\nend."}, {"source_code": "var b, a, c: int64;\n\nbegin\n readln(a,b);\n read(c);\n a := a - 2*c;\n read(c);\n a := a - c;\n b := b - c;\n read(c);\n b := b - 3*c;\n \n c:=0;\n if a < 0 then c := abs(a);\n if b < 0 then c := c + abs(b);\n writeln(c);\nend."}, {"source_code": "Var a,b,x,y,z,k1,k3:Int64;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(a,b);\nreadln(x,y,z);\nk1:=2*x+y-a;\nk3:=3*z+y-b;\nif (k1<0) and (k3<0) then begin writeln('0'); halt; end;\nif (k1>=0) and (k3<0) then begin writeln(k1); halt; end;\nif (k1<0) and (k3>=0) then begin writeln(k3); halt; end;\nwriteln(k1+k3);\nEnd.\n\n\n\n\n\n\n\n\n"}, {"source_code": "const fi='problemA.inp';\n fo='problemA.out';\nvar f,g:text;\n xa,va,a,b,x,y,z:int64;\n\n\n begin\n \n readln(b,a);\n readln(x,y,z);\n xa:=y+3*z;\n va:=2*x+y;\n // writeln(g,xa,' ',va);\n if (xa-a>0) and (va-b>0) then writeln(xa-a+va-b)\n else if (xa-a<=0) and (va-b<=0) then\n writeln(0)\n else\n if xa-a<=0 then writeln(va-b)\n else writeln(xa-a);\n \n end."}, {"source_code": "{$MACRO ON}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n{$DEFINE wait:=readln;readln;}\n{$DEFINE maxN:=trunc(1e5)+1}\n\nuses gvector,garrayutils,math;\nconst\tfi='';\n\t\tfo='';\n\nvar n : int32;\n\tt1,t2 : dword;\n\ta,b,c : dword;\n\nprocedure readData();\n\tvar i : int32;\n\t\ttmp1,tmp2 : dword;\n begin\n \treadln(t1,t2);\n\t\treadln(a,b,c);\n tmp1 := a*2 + b;\n\t\ttmp2 := b + c*3;\n write(max(tmp1-t1,0) + max(tmp2-t2,0));\n\t\twait;\n end;\n\nprocedure main();\n var i : int32;\n\tbegin\n readData();\n\n end;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\tmain();\n close(input); close(output);\nend."}, {"source_code": "var a,b,a1,b1,x,y,z,c:double;\n\nbegin\n readln (a,b);\n readln (x,y,z);\n a1:=2*x+y;\n b1:=y+3*z;\n \n if a1<=a then a1:=0;\n if b1<=b then b1:=0;\n if a1>a then a1:=a1-a;\n if b1>b then b1:=b1-b;\n c:=a1+b1;\n writeln(c:0:0);\nend."}, {"source_code": " var a,b,x,y,z,k:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n a:=a-2*x;\n if a<0 then begin\n dec(k,a);\n a:=0;\n end;\n a:=a-y;\n b:=b-y;\n if a<0 then begin\n dec(k,a);\n a:=0;\n end;\n if b<0 then begin\n dec(k,b);\n b:=0;\n end;\n b:=b-3*z;\n if b<0 then\n dec(k,b);\n writeln(k);\nend."}, {"source_code": "var\n a,b,x,y,z,s,s1,s2:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n s1:=x*2+y-a;s2:=z*3+y-b;\n if s1>0 then s:=s+s1;if s2>0 then s:=s+s2;\n writeln(s);\nend."}, {"source_code": "var n,m,x,y,z,r:int64;\nbegin\n read(n,m,x,y,z);\n n:=n-x*2;\n if n<0 then\n begin\n r:=abs(n);\n n:=0;\n end;\n n:=n-y;\n m:=m-y;\n if n<0 then\n begin\n r:=r+abs(n);\n n:=0;\n end;\n if m<0 then\n begin\n r:=r+abs(m);\n m:=0;\n end;\n m:=m-z*3;\n if m<0 then\n begin\n r:=r+abs(m);\n end;\n write(r);\nend."}], "negative_code": [{"source_code": "//For yellow - 2 yc\n//For green - 1 yc 1 bc\n//For blue - 3 bc\nvar\na,b,x,y,z:integer;\nreq_a,req_b:integer;\n\nbegin\nreadln(a,b);\nreadln(x,y,z);\nreq_a:=x*2+y;\nreq_b:=z*3+y;\nreq_a:=req_a-a;\nif req_a<0 then req_a:=0;\nreq_b:=req_b-b;\nif req_b<0 then req_b:=0;\nwriteln(req_a+req_b);\nend."}, {"source_code": "program cf_456_A\n;\n\nvar a,b, x,y,z: integer; // +-2.1E09\n yel, blu: int64;\n// a: array[1..9, 1..9] of integer;\n// in_row: string;\n answer: int64; \n\nbegin\n read(a, b);\n read(x,y,z);\n // ����:\n yel:= x*2+y; // ������ ���������� \n blu:= z*3+y; // ����� ����������\n answer:=0;\n if yel>a then\n answer:=answer+yel-a;\n if blu>b then \n answer:=answer+blu-b;\n \n writeln(answer);\nend."}, {"source_code": " var\n\t\tm, n: int64;\n\t\ta, b, c: int64;\n\t\tyellow, green, blue: int64;\n\t\t\n begin\n\t\t\n\t\treadln(n, m);\n\t\treadln(a, b, c);\n\t\t\n\t\tif ((n+m) - (a*2 + b * 2 + c*3) < 0) then\n\t\t\twriteln((a*2 + b * 2 + c*3) - (n+m))\n\t\telse\n\t\t\twriteln(0);\n\t\t\n\t\t\n\t\t\n end.\n"}, {"source_code": "begin\n var a,b,c,n,m:integer;\n var r:biginteger;\n read(n,m,a,b,c);\n var s:=(n-(a*2)-b);\n var w:=(m-(c*3)-b);\n if(s<0)then r+=abs(s);\n if(w<0)then r+=abs(w);\n write(r);\nend."}, {"source_code": "PROGRAM PR1;\nVAR A,B,X,Y,Z,GEL1,GEL2,GEL,SIN1,SIN2,SIN:INTEGER;S:REAL;\nBEGIN\nREAD(A,B);\nREADLN(X,Y,Z);\nGEL1:=X*2;\nGEL2:=Y;\nGEL:=GEL1+GEL2;\nSIN1:=Z*3;\nSIN2:=Y;\nSIN:=SIN1+SIN2;\nIF (ASIN)) THEN S:=S+(GEL-A);\nIF (BGEL)) THEN S:=S+(SIN-B);\nIF (ASIN)) AND ((GEL=A) OR (A>GEL)) THEN S:=0;\nIF (ASIN)) THEN S:=S+(GEL-A);\nIF (BGEL)) THEN S:=S+(SIN-B);\nIF (ASIN)) THEN S:=S+(GEL-A);\nIF (BGEL)) THEN S:=S+(SIN-B);\nIF (AGEL) THEN BEGIN S:=S+0;END;\nIF (SIN=B) OR (B>SIN) THEN BEGIN S:=S+0;END;\nIF (A=x1) and (not(B>=z1)) then writeln(abs(z1-B))\n else if (B>=z1) and (not(A>=x1)) then writeln(abs(x1-A))\n else writeln(0);\n end;\n //close(input); close(output);\nend."}, {"source_code": "Program TrickyAlchemy;\nuses math;\nvar A,B,x,y,z:longint; x1,z1:int64;\nbegin //assign(input,'912A.inp'); reset(input);\n //assign(output,'912A.out'); rewrite(output);\n readln(A,B); readln(x,y,z);\n x1:=2*x+y; z1:=3*z+y;\n if (A<=x1) and (B<=z1) then writeln(abs(x1-A)+abs(z1-B))\n else begin\n if A>=x1 then writeln(abs(z1-B))\n else if B>=z1 then writeln(abs(x1-A))\n else writeln(0);\n end;\n //close(input); close(output);\nend."}, {"source_code": "program zzz;\nvar\n a,b,x,y,z,sa,sb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n sa:=x*2 + y-a;\n sb:=z*3+y-b;\n writeln(sa+sb);\nend."}, {"source_code": "program zzz;\nvar\n a,b,x,y,z,sa,sb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n sa:=x*2 + y-a;\n sb:=z*3+y-b;\n if sa+sb >=0 then\n writeln(sa+sb)\n else writeln('0');\n \nend."}, {"source_code": "var\n a,b,x,y,z:longint;\n s:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n while (a>1) and (x>0) do\n begin\n a:=a-2;\n dec(x);\n end;\n s:=x*2;\n while (a>0) and (b>0) and (y>0) do\n begin\n dec(a); dec(b); dec(y);\n end;\n s:=s+y*2;\n while (b>2) and (z>0) do\n begin\n b:=b-3;\n dec(z);\n end;\n s:=s+z*3;\n if z<>0 then s:=s-b;\n writeln(s);\nend."}, {"source_code": "var n,m,a,b,c,s:int64;\nbegin\n\n\nreadln(n,m);\nreadln(a,b,c);\nif a*2+b>n then s:=s+a*2+b-n;\nif c*3+c>m then s:=s+c*3+b-m;\nwriteln(s);\n\n\nend."}, {"source_code": "uses math;\nconst fin='';\n fout='';//x vang, y xanh la, z xanh duong\nvar f,g:text;\n a,b,x,y,z,blue,yel,qa:int64;\n \n\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,a,b);\n read(f,x,y,z);\n blue:=z*3+y;\n yel:=x*2+y;\n qa:=yel-a+blue-b;\n if qa>0 then write(g,qa)\n else write(g,0);\n close(f);\n close(g);\nend."}, {"source_code": "uses math;\nvar\na,b,x,y,z,j,c:int64;\nbegin\nreadln(a,b);\nreadln(x,y,z);\nj:=x*2+y;\nc:=y+z*3;\nwrite(max(0,j+c-a-b));\nend."}, {"source_code": "var\na,b,x,y,z,j,c:int64;\nbegin\nreadln(a,b);\nreadln(x,y,z);\nj:=x*2+y;\nc:=y+z*3;\nwrite(j+c-a-b);\nend."}, {"source_code": "program z1;\nvar z, x, y, sum, a, b, c, i:longint;\nbegin \n readln( a, b );\n Readln( z, x, y );\n c := z * 2 + x * 1 ;\n i := x * 1 + y * 3 ;\n sum := 0 ;\n if a < c\n then sum := sum + ( c - a );\n if b < i\n then sum := sum + ( i - b ); \n writeln(sum);\nend."}, {"source_code": "//http://codeforces.com/contest/912/problem/A\nprogram CF912_A;\nuses math;\nvar a,b,x,y,z,vang,xanh,res: int64;\nbegin\n\treadln(a,b);\n\treadln(x,y,z);\n\tvang:=2*x+y;\n\txanh:=y+3*z;\n\tres:=(vang-a)+(xanh-b);\n\twrite(max(0,res));\nend.\n"}, {"source_code": "//http://codeforces.com/contest/912/problem/A\nprogram CF912_A;\nvar a,b,x,y,z,vang,xanh,res: int64;\nbegin\n\treadln(a,b);\n\treadln(x,y,z);\n\tvang:=2*x+y;\n\txanh:=y+3*z;\n\tres:=(vang-a)+(xanh-b);\n\twrite(res);\nend.\n"}, {"source_code": "type \narr=array [1..1000,1..2] of double;\nvar \na,b,c,x,y,z: int64;\nflag,flag1,flag2,kod: integer;\n\n\n\nbegin\n readln(a,b);\n readln(x,y,z);\n c:=(a+b-2*x-2*y-3*z);\n writeln(c);\n \nend."}, {"source_code": "type \narr=array [1..1000,1..2] of double;\nvar \na,b,c,x,y,z: int64;\nflag,flag1,flag2,kod: integer;\n\n\n\nbegin\n readln(a,b);\n readln(x,y,z);\n c:=(a+b-2*x-2*y-3*z);\n if (c<=0) then writeln(-1*c)\n else writeln(0);\nend."}, {"source_code": "type \narr=array [1..1000,1..2] of double;\nvar \na,b,c,x,y,z: int64;\nflag,flag1,flag2,kod: integer;\n\n\n\nbegin\n readln(a,b);\n readln(x,y,z);\n c:=(a+b-2*x-2*y-3*z);\n writeln(-1*c);\n \nend.\n"}, {"source_code": "var x,y,z,a,b,res:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n if (a<=x*2) then\n begin\n a:=0;\n res:=res+x*2-a;\n end\n else a:=a-x*2;\n if (b<=z*3) then\n begin\n b:=0;\n res:=res+z*3-b;\n end\n else b:=b-z*3;\n if (a<=y) then res:=res+y-a;\n if (b<=y) then res:=res+y-b;\n writeln(res);\n readln;\nend.\n"}, {"source_code": "var a,b,x,y,z,br:int64;\nbegin\n read(a,b);\n read(x,y,z);\n\n if (x*2<=a) then a:=a-x*2\n else\n begin\n br:=br+(x*2-a);\n a:=0;\n end;\n\n if (z*3<=b) then\n begin\n b:=b-z*3;\n writeln('DA');\n end\n else\n begin\n br:=br+(z*3-b);\n b:=0;\n end;\n\n if (y<=a)and(y<=b)then\n begin\n a:=a-y;\n b:=b-y;\n end\n else\n begin\n br:=br+(y-a);\n br:=br+(y-b);\n a:=0;\n b:=0;\n end;\n\n writeln(br);\nend.\n\n\n\n"}, {"source_code": "var a,b,x,y,z,br:int64;\nbegin\n read(a,b);\n read(x,y,z);\n\n if (x*2<=a) then a:=a-x*2\n else\n begin\n br:=br+(x*2-a);\n a:=0;\n end;\n\n if (z*3<=b) then b:=b-z*3\n else\n begin\n br:=br+(z*3-b);\n b:=0;\n end;\n\n if (y<=a)and(y<=b)then\n begin\n a:=a-y;\n b:=b-y;\n end\n else\n begin\n br:=br+(y-a);\n br:=br+(y-b);\n a:=0;\n b:=0;\n end;\n\n writeln(br);\nend.\n\n\n\n"}, {"source_code": "Var a,b,x,y,z,k1,k2:Int64;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(a,b);\nreadln(x,y,z);\nk1:=(2*x+y-a);\nk2:=(3*z+y-b);\nwriteln(k1+k2);\nEnd.\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var a,b,x,y,z,k1,k2:Int64;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(a,b);\nreadln(x,y,z);\nif (a=12) and (b=12) and (x=3) and (y=5) and (z=2) then begin writeln('0'); halt; end;\nk1:=abs(2*x+y-a);\nk2:=abs(3*z+y-b);\nwriteln(k1+k2);\nEnd.\n\n\n\n\n\n\n\n\n"}, {"source_code": "const fi='problemA.inp';\n fo='problemA.out';\nvar f,g:text;\n xa,va,a,b,x,y,z:int64;\n\n\n begin\n \n readln(a,b);\n readln(x,y,z);\n xa:=y+3*z;\n va:=2*x+y;\n writeln(xa-a+va-b);\n \n end."}, {"source_code": "const fi='problemA.inp';\n fo='problemA.out';\nvar f,g:text;\n xa,va,a,b,x,y,z:int64;\n\n\n begin\n \n readln(a,b);\n readln(x,y,z);\n xa:=y+3*z;\n va:=2*x+y;\n if (xa-a>0) and (va-b>0) then writeln(xa-a+va-b)\n else if (xa-a<=0) and (va-b<=0) then\n writeln(0)\n else\n if xa-a<=0 then writeln(va-b)\n else writeln(xa-a);\n \n end."}, {"source_code": "const fi='problemA.inp';\n fo='problemA.out';\nvar f,g:text;\n xa,va,a,b,x,y,z:int64;\n\n\n begin\n \n readln(a,b);\n readln(x,y,z);\n xa:=y+3*z;\n va:=2*x+y;\n if xa-a+va-b>0 then writeln(xa-a+va-b)\n else writeln(0);\n \n end."}, {"source_code": "var\n a,b,x,y,z,s,s1,s2:longint;\nbegin\n readln(a,b);\n readln(x,y,z);\n s1:=x*2+y-a;s2:=z*3+y-b;\n if s1>0 then s:=s+s1;if s2>0 then s:=s+s2;\n writeln(s);\nend."}, {"source_code": "var x,y,a,b,c:int64;\n need:array[0..10]of int64;\nfunction max(a,b:int64):int64;\nbegin\n if a>b then exit(a) else exit(b);\nend;\nbegin\n read(x,y);\n readln(a,b,c);\n inc(need[1],a*2);\n inc(need[1],b);\n inc(need[2],b);\n inc(need[2],c*3);\n writeln(max(need[1]+need[2]-x-y,0));\nend."}, {"source_code": "//fpc 3.0.0\n\nvar a,b,x,y,z,ans,aa,bb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n \n aa:=x*2+y;\n bb:=z*3+y;\n ans:=(aa-a)+(bb-b);\n writeln(ans);\nend.\n"}, {"source_code": "//fpc 3.0.0\n\nvar a,b,x,y,z,ans,aa,bb:int64;\nbegin\n readln(a,b);\n readln(x,y,z);\n \n aa:=x*2+y;\n bb:=z*3+y;\n ans:=(aa-a)+(bb-b);\n if ans<0 then ans:=0;\n writeln(ans);\nend.\n"}, {"source_code": "var n,m,x,y,z:longint;\n sin,jelt,ans:int64;\nbegin\nreadln(n,m);\nreadln(x,y,z);\njelt:=jelt+x*2;\njelt:=jelt+y;\nsin:=sin+y;\nsin:=sin+z*3;\nif n= 0)and(g >= 0) then write(s+g)\n else write('0');\nend."}, {"source_code": "var a,b,x,y,z,g,s:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n g:= 2*x + y;\n s:= y + 3*z;\n if g>=a then g:= g - a\n else g:=0;\n if s>=a then s:= s - b\n else s:=0;\n write(g+s);\nend."}, {"source_code": "var a,b,x,y,z,g,s:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n g:= 2*x + y;\n s:= y + 3*z;\n g:= g - a;\n s:= s - b;\n if (s >= 0)and(g >= 0) then write(s+g)\n else if (s <= 0) then write(g)\n else if (g <= 0) then write(s)\n else write('0');\nend."}, {"source_code": "var A,B,y,g,s,res : integer;\nBEGIN\n readln(A,B);\n readln(y,g,s);\n A-= y*2 + g; B-= s*3 +g;\n if A < 0 then res-=A;\n if B < 0 then res-=B;\n write(res);\n readln\nEND. "}, {"source_code": "var A,B,y,g,s,res : integer;\nBEGIN\n readln(A,B);\n readln(y,g,s);\n A-= y*2 + g; B-= s*3 +g;\n if A+B < 0 then res-=A+B;\n write(res);\nEND. "}, {"source_code": "program tricky_alchemy;\nvar\n\tx,y,z,a,b,want_a,want_b,few:int64;\nbegin\n\treadln(a,b);\n\treadln(x,y,z);\n\tfew:=0;\n\twant_a:=x*2+y;\n\twant_b:=z*3+y;\n\tfew:=(want_a-a)+(want_b-b);\n\tif few<=0 then few:=0;\n\twriteln(few);\nend. "}, {"source_code": "var\n x,y,a,b,c,a1,c1,bx1,by1,s:longint;\nbegin\n readln(x,y);\n readln(a,b,c);\n a1:=a*2;\n if x-a1<0 then begin s:=s+abs(x-a1); x:=x+abs(x-a1); end;\n x:=x-a1;\n bx1:=b;\n by1:=b;\n if x-bx1<0 then begin s:=s+abs(x-bx1); x:=x+abs(x-bx1); end;\n if y-by1<0 then begin s:=s+abs(x-by1); y:=y+abs(y-by1); end;\n y:=y-by1;\n x:=x-bx1;\n c1:=3*c;\n if y-c1<0 then begin s:=s+abs(y-c1); y:=y+abs(y-c1); end;\n writeln(s);\nend."}, {"source_code": "var a,b,x,y,z:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n a:=-a;\n b:=-b;\n a:=a+2*x;\n a:=a+y;\n b:=b+y;\n b:=b+3*z;\n if a+b>0 then writeln(a+b) else writeln(0);\nend."}, {"source_code": "var a,b,x,y,z:int64;\n\nbegin\n readln(a,b);\n readln(x,y,z);\n a:=-a;\n b:=-b;\n a:=a+2*x;\n a:=a+y;\n b:=b+y;\n b:=b+3*z;\n writeln(a+b);\nend."}, {"source_code": "uses math;\nvar y, g, b, y1, b1: Qword;\n ans: int64;\nBEGIN\n readln(y1, b1);\n readln(y, g, b);\n //writeln;\n ans:= (2*y+g - y1) + (3*b+g-b1);\n writeln(max(ans, 0));\n //readln;\nEND.\n"}, {"source_code": "uses math;\nvar y, g, b, y1, b1: int64;\n ans: int64;\nBEGIN\n readln(y1, b1);\n readln(y, g, b);\n //writeln;\n ans:= (2*y+g - y1) + (3*b+g-b1);\n writeln(max(ans, 0));\n //readln;\nEND.\n"}, {"source_code": "var y, g, b, y1, b1: int64;\n dem: array [1..2] of int64;\n ans: int64;\nBEGIN\n readln(y1, b1);\n readln(y, g, b);\n //writeln;\n inc(dem[1],2 * y + g);\n inc(dem[2],g + 3 * b);\n ans:= dem[1] + dem[2] - y1 - b1;\n writeln(ans);\n //readln;\nEND.\n"}, {"source_code": "uses math;\nvar y, g, b, y1, b1: int64;\n ans: int64;\nBEGIN\n readln(y1, b1);\n readln(y, g, b);\n //writeln;\n ans:= (2*y+g - y1) + (3*b+g-b1);\n writeln(max(ans, 0));\n //readln;\nEND.\n"}, {"source_code": "program cristale;\nvar a,b,x,y,z,f:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n a:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n x:=x+y+z;\n f:=x-a;\n if x>a then\n writeln(f) else writeln(abs(f));\n readln;\nend.\n"}, {"source_code": "program cristale;\nvar a,b,x,y,z,f,l,g:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n g:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n l:=x+y+z;\n if ga then\n writeln(f) else writeln('0');\n readln;\nend."}, {"source_code": "program cristale;\n\nvar a,b,x,y,z,f:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n a:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n x:=x+y+z;\n f:=x-a;\n if f<>0 then\n writeln(abs(f)) else writeln('0');\n readln;\nend."}, {"source_code": "program cristale;\nvar a,b,x,y,z,f:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n a:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n x:=x+y+z;\n f:=x-a;\n if x>a then\n writeln(f) else writeln('0');\n readln;\nend.\n"}, {"source_code": "program cristale;\nvar a,b,x,y,z,f:longint;\nbegin\n read(a,b);\n read(x,y,z);\n a:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n x:=x+y+z;\n f:=x-a;\n if x>a then\n writeln(f) else writeln('0');\n readln;\nend."}, {"source_code": "program cristale;\nvar a,b,x,y,z,f,l,g:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n g:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n l:=x+y+z;\n f:=abs(l-g) ;\n writeln(f);\n readln;\nend."}, {"source_code": "program cristale;\nvar a,b,x,y,z,f,l,g:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n g:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n l:=x+y+z;\n if g 0 then\n writeln(f) else writeln('0');\n readln;\nend."}, {"source_code": "program cristale;\nvar a,b,x,y,z,f,l,g:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n g:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n l:=x+y+z;\n if l>g then\n f:=x-a;\n writeln(f);\n readln;\nend.\n"}, {"source_code": "program cristale;\nvar a,b,x,y,z,f,l,g:longint;\nbegin\n read(a,b);\n \n read(x,y,z);\n g:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n l:=x+y+z;\n if g>l then\n f:=g-l;\n writeln(f);\n readln;\nend.\n"}, {"source_code": "program cristale;\nvar a,b,x,y,z,f:longint;\nbegin\n read(a,b);\n read(x,y,z);\n a:=a+b;\n x:=x*2;\n y:=y*2;\n z:=z*3;\n x:=x+y+z;\n f:=x-a;\n writeln(f);\n readln;\nend."}, {"source_code": "var a,s,d,f,g,q,w,e,r,t,y: longword;\nbegin\n read (a,s,d,f,g);\n q:=d*2+f;\n w:=g*3+f;\n if q<=a then begin\n q:=0;\n end else q:=q-a;\n if w<=s then begin\n w:=0;\n end else w:=w-s;\n e:=q+w;\n write (e);\nend."}, {"source_code": "var a,s,d,f,g,q,w,e,r,t,y: longword;\nbegin\n read (a,s,d,f,g);\n q:=d*2+f;\n w:=g*3+f;\n e:=q+w-a-s;\n write (e);\nend."}], "src_uid": "35202a4601a03d25e18dda1539c5beba"} {"source_code": "Var b:array[0..4000*6000]of boolean;\n n,s,i,j,x,y,k:longint;\n c:array[0..7000]of longint;\n Begin\n Read(n);\n fillchar(b,sizeof(b),true);\n s:=n*(n+1)div 2;\n for i:=2 to s do\n begin\n if b[i] then begin\n x:=i+i;\n While x<=s do\n begin\n b[x]:=false;\n x:=x+i;\n end;\n end;\n end;\n b[1]:=false;\n if b[s] then begin\n for i:=1 to n do\n Write(1,' ');\n Writeln;\n end\n else begin\n x:=0;\n for i:=2 to s-2 do\n if b[i] and b[s-i] then begin\n x:=i;\n break;\n end;\n fillchar(c,sizeof(c),0);\n k:=0;\n if x=0 then begin\n c[1]:=1;\n c[2]:=1;\n s:=s-3;\n k:=1;\n end;\n x:=0;\n for i:=2 to s-2 do\n if b[i] and b[s-i] then begin\n x:=i;\n break;\n end;\n inc(k);\n While x<>0 do\n begin\n for j:=x downto 1 do\n if c[j]=0 then begin\n c[j]:=k;\n x:=x-j;\n break;\n end;\n if (j=1)and(c[1]<>0) then break;\n end;\n inc(k);\n for j:=1 to n do\n if c[j]=0 then c[j]:=k;\n for i:=1 to n do\n Write(c[i],' ');\n Writeln;\n end;\n\n End.\n", "positive_code": [{"source_code": "{$A8,B+,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}\nprogram prG;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst size = 20000000;\n\nvar a: array[1..size]of Boolean;\n n, sum: longint;\n ans: array[1..6000]of longint;\n\nprocedure resh;\n var i, m: longint;\nbegin\n i := 2;\n while i * i <= size do\n begin\n if not a[i] then\n begin\n m := i;\n while i + m <= size do\n begin\n m := m + i;\n a[m] := true;\n end;\n end;\n Inc(i);\n end;\nend;\n\nprocedure solve;\n var i, m, j: LongInt;\nbegin\n sum := (n * (n + 1)) div 2;\n for i := 2 to sum - 2 do\n if not a[i]and not(a[sum - i]) then\n begin\n m := n;\n j := i;\n while j >= m do\n begin\n ans[m] := 1;\n j := j - m;\n Dec(m);\n end;\n if j > 0 then ans[j] := 1;\n for j := 1 to n do\n if ans[j] = 0 then write('2 ') else write(ans[j], ' ');\n Halt(0);\n end;\n\n ans[3] := 3;\n sum := sum - 3;\n for i := 2 to sum - 2 do\n if not a[i]and not(a[sum - i]) then\n begin\n m := n;\n j := i;\n while j >= m do\n begin\n if m = 3 then\n begin\n ans[1] := 1;\n ans[2] := 1;\n end else ans[m] := 1;\n j := j - m;\n Dec(m);\n end;\n if j > 0 then\n begin\n if j = 3 then\n begin\n ans[1] := 1;\n ans[2] := 1;\n end else ans[j] := 1;\n end;\n for j := 1 to n do\n if ans[j] = 0 then write('2 ') else write(ans[j], ' ');\n Halt(0);\n end;\nend;\n\nbegin\n//reset(input, 'input.txt'); Rewrite(Output, 'output.txt');\n read(n);\n if n = 2 then\n begin\n Writeln('1 1');\n Halt(0);\n end;\n resh;\n solve;\nend.\n"}, {"source_code": "{$IFNDEF ONLINE_JUDGE} \n\t{$APPTYPE CONSOLE}\n\t{R+,S+,Q+,I+,C+,M+,H+,O+} \n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ELSE} \n\t{$MODE DELPHI} \n\t{R+,S+,Q+,I+,C+,M+,H+,O+}\n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ENDIF}\n{M 40000000}\n\nuses\n\tSysUtils, Math; \n\nconst\n\tMAXN = 18003000;\n\nvar\n\ti, n, ii, cur, cc : longint;\n\tp : array[0..MAXN + 10] of boolean;\n\ta : array[0..6010] of longint;\n\td : array[0..2222222] of longint;\n\tj : int64;\n\tok : boolean;\n\nbegin \n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\tread(n);\n\tfillchar(p, sizeof(p), 1);\n\tp[1] := false;\n\ti := 4;\n\twhile i <= MAXN do begin\n\t\tp[i] := false;\n\t\tinc(i, 2);\n\tend;\n\ti := 3;\n\tcc := 1;\n\td[1] := 2;\n\twhile i <= MAXN do begin\n\t\tif p[i] then begin\n\t\t\tj := int64(i) * i;\n\t\t\tii := i shl 1;\n\t\t\twhile j <= MAXN do begin\n\t\t\t\tp[j] := false;\n\t\t\t\tinc(j, ii);\n\t\t\tend;\n\t\t\tinc(cc);\n\t\t\td[cc] := i;\n\t\tend;\n\t\tinc(i, 2);\n\tend;\n\tfor i := 1 to n do\n\t\ta[i] := 1;\n\tcur := n * (n + 1) shr 1;\n\tif not p[cur] then begin\n\t\tok := true;\n\t\tfor i := 1 to cc do\n\t\t\tif d[i] > n then break else\n\t\t\tif p[cur - d[i]] then begin\n\t\t\t\ta[d[i]] := 2;\n\t\t\t\tok := false;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\tif ok then begin\n\t\t\ta[3] := 3;\n\t\t\tdec(cur, 3);\n\t\t\tfor i := 3 to cc do\n\t\t\t\tif d[i] > n then break else\n\t\t\t\tif p[cur - d[i]] then begin\n\t\t\t\t\ta[d[i]] := 2;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tend;\n\tend;\n\tfor i := 1 to n do\n\t\twrite(a[i], ' ');\nend.\n\n"}, {"source_code": "var i,j,n,m:LongInt;\nprime:array[0..6000*6000+1000] of boolean;\nres:array[0..6000] of LongInt;\nsum:LongInt;\npr:LongInt;\n\nprocedure FillAllArrayWithOnes;\nbegin\n for i:=1 to n do\n write(1,' ');\n halt;\nend;\n\nprocedure THISISIMPOSSIBLE;\nbegin\n writeln(-1);\n halt;\nend;\n\nprocedure Findres(sum:LongINt);\nvar left,i:LongInt;\nbegin\n left:=sum;\n for i:=n downto 1 do\n if (res[i]=0)and(left>=i) then begin res[i]:=1;dec(left,i);end;\n\n for i:=1 to n do\n if res[i]=0 then res[i]:=2;\n\n for i:=1 to n do\n write(res[i],' ');\n halt;\nend;\n\nbegin\n read(n);\n fillchar(prime,sizeof(prime),true);\n fillchar(res,sizeof(res),0);\n pr:=(n*n+n) div 2;\n prime[0]:=false;\n prime[1]:=false;\n for i:=2 to trunc(sqrt(pr)) do\n begin\n // writeln(i);\n if not prime[i] then continue;\n if i>10000 then\n j:=i+i\n else\n j:=i*i;\n while j<=pr do\n begin\n prime[j]:=false;\n inc(j,i);\n end;\n end;\n\n sum:=(n*(n+1)) div 2;\n if prime[sum] then FillAllArrayWithOnes;\n\n if (odd(sum))and(prime[sum-2]) then FindRes(2);\n\n if odd(sum) then\n begin\n dec(sum,3);\n res[3]:=3;\n end;\n\n // writeln(sum);\n for i:=2 to pr do\n begin\n // writeln(i,' ',prime[i],' ',sum-i,' ',prime[sum-i]);\n if (i>sum) then THISISIMPOSSIBLE;\n if (prime[i])and(prime[sum-i]) then FindRes(i);\n end;\nend.\n"}, {"source_code": "{uses crt;}\nconst nn=10000;\nvar i,j,l,m,n,t,maxholm,besk,i0,s,s1,s2,teks:longint;\n a,b:array[0..nn]of longint;\nfunction pr(a:longint):boolean; var i:longint;ot:boolean;\nbegin ot:=true; for i:=2 to trunc(sqrt(a))+1 do if a mod i =0 then ot:=false;if a=1 then ot:=false;pr:=ot;end;\n\n\n\nbegin {clrscr;\nassign (input,'input1.txt');reset(input); }\n { assign (output,'output.txt'); rewrite(output); }\nreadln(n);\nbegin\n\n s:=0;\n for i:=1 to n do s:=s+i ;\n if pr(s) then for i:=1 to n do a[i]:=1;\n if not pr(s) then\n begin\n if not odd(s) then\n begin for s1:=1 to s do if pr(s1)and pr(s-s1) then break;\n s2:=s-s1;\n {if s1>n then writeln(s,'=',s1,'+',s2);}\n for i:=1 to n do a[i]:=2; a[s1]:=1;\n end else\n begin\n if pr(s-2) then begin for i:=1 to n do a[i]:=2; a[2]:=1; end else\n begin\n if pr(s-6) then begin\n for i:=1 to n do a[i]:=3;\n a[1]:=1;a[5]:=2;\n\n end else\n begin s:=s-3;\n for s1:=1 to s do if pr(s1)and pr(s-s1) then break;\n for i:=1 to n do a[i]:=1;\n a[3]:=2;a[s1]:=3;\n end;\n\n\n\n end;\n\n end;\n\n end;\n\n end;\n\nfor i:= 1 to n do write(a[i],' ');\n\n\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n q,u,j,n,s,i: longint;\n a: array [0..6010] of longint;\n\nfunction prime(x:longint):boolean;\nvar\n i: longint;\nbegin\n for i:=2 to x-1 do\n if i*i > x then break else\n if x mod i = 0 then\n begin\n prime:=False;\n exit;\n end;\n prime:=x > 1;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n s:=n*(n+1) div 2;\n for i:=1 to n do a[i]:=1;\n if not prime(s) then\n if prime(s-2) then a[2]:=2 else\n begin\n if s and 1 = 1 then\n for i:=n downto 1 do\n if prime(i) then\n begin\n s:=s-i;\n a[i]:=3;\n break;\n end;\n for q:=1 to s-1 do\n if prime(q) and prime(s-q) then\n begin\n u:=q;\n for j:=n downto 1 do\n if (u >= j) and (a[j] = 1) then\n begin\n dec(u,j);\n a[j]:=2;\n end;\n break;\n end;\n end;\n for i:=1 to n-1 do write(a[i],' ');\n writeln(a[n]);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n q,u,j,n,s,i: longint;\n a: array [0..6010] of longint;\n\nfunction prime(x:longint):boolean;\nvar\n i: longint;\nbegin\n for i:=2 to x-1 do\n if i*i > x then break else\n if x mod i = 0 then\n begin\n prime:=False;\n exit;\n end;\n prime:=x > 1;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n s:=n*(n+1) div 2;\n for i:=1 to n do a[i]:=1;\n if not prime(s) then\n if prime(s-2) then a[2]:=2 else\n begin\n if s and 1 = 1 then\n for i:=n downto 1 do\n if prime(i) then\n begin\n s:=s-i;\n a[i]:=3;\n break;\n end;\n for q:=1 to s-1 do\n if prime(q) and prime(s-q) then\n begin\n u:=q;\n for j:=n downto 1 do\n if (u >= j) and (a[j] = 1) then\n begin\n dec(u,j);\n a[j]:=2;\n end;\n break;\n end;\n end;\n for i:=1 to n-1 do write(a[i],' ');\n writeln(a[n]);\n close(input);\n close(output);\nend."}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, i, j, z, sum : integer;\n p : array[0..6001] of boolean;\n\nfunction check(x : integer) : boolean;\nvar i : integer;\nbegin\n result := true;\n i := 2;\n while i * i <= x do begin\n if x mod i = 0 then begin\n result := false;\n exit;\n end;\n inc(i);\n end;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n);\n for i := 2 to n do\n p[i] := check(i);\n sum := 0;\n for i := 1 to n do\n sum := sum + i;\n if check(sum) then begin\n for i := 1 to n do\n write('1 ');\n halt(0);\n end;\n for i := 1 to n do\n if p[i] then begin\n sum := (n * (n + 1)) div 2 - i;\n if check(sum) then begin\n for j := 1 to n do\n if j = i then\n write('2 ')\n else\n write('1 ');\n halt(0);\n end;\n end;\n for i := 1 to n - 1 do\n for j := i + 1 to n do\n if (p[i]) and (p[j]) then begin\n sum := (n * (n + 1)) div 2 - i - j;\n if check(sum) then begin\n for z := 1 to n do\n if z = i then\n write('2 ')\n else\n if z = j then\n write('3 ')\n else\n write('1 ');\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses\n SysUtils;\ntype\nt = array[0..50000000] of boolean;\nt1 = array[0..6000] of longint;\nvar p, ans : t;\n a : t1;\n i, n, j, x, k, q, y, v : longint;\n ff : boolean;\nbegin\n { assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output); }\n read(n);\n x := n * (n + 1) div 2;\n p[0] := true;\n p[1] := true;\n for i := 2 to trunc(sqrt(x)) do\n if p[i] = false then begin\n j := i * 2;\n while j <= x do begin\n p[j] := true;\n j := j + i;\n end;\n end;\n if p[x] = false then begin\n for i := 1 to n do\n write('1 ');\n halt(0);\n end;\n if x mod 2 = 1 then begin\n if p[x - 2] = false then begin\n for i := 1 to n do\n if (i <> 2) then\n write('1 ')\n else\n write('2 ');\n end else begin\n y := x;\n for i := n downto 2 do\n if p[i] = false then begin\n inc(q);\n a[q] := i;\n end;\n q := 0;\n while ff = false do begin\n fillchar(ans, sizeof(ans), false);\n ff := true;\n inc(q);\n x := y - a[q];\n for i := 2 to x div 2 do\n if (p[i] = false) and (p[x - i] = false) then begin\n v := i;\n break;\n end;\n k := 0;\n while v > n - k do begin\n if n - k = a[q] then begin\n ff := false;\n break;\n end;\n ans[n - k] := true;\n v := v - n + k;\n dec(k);\n end;\n if ff = false then continue;\n if (v <= n - k) and (v > 0) then begin\n if v = a[q] then begin\n ff := false;\n break;\n end;\n ans[v] := true;\n end;\n if ff = false then continue;\n for i := 1 to n do\n if i = a[q] then\n write('3 ')\n else if\n ans[i] then\n write('1 ')\n else\n write('2 ');\n end;\n end;\n halt(0);\n end;\n for i := 2 to x div 2 do\n if (p[i] = false) and (p[x - i] = false) then begin\n v := i;\n break;\n end;\n k := 0;\n while v > n - k do begin\n ans[n - k] := true;\n v := v - n + k;\n dec(k);\n end;\n if (v <= n - k) and (v > 0) then\n ans[v] := true;\n for i := 1 to n do\n if ans[i] then\n write('1 ')\n else\n write('2 ');\nend.\n"}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nb:array[0..6000*6000]of boolean;\nd:array[0..10000]of longint;\n begin\n readln(n);\n begin\n s:=n*(n+1)div 2;\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if b[s] then\n begin\n for i:=1 to n-1 do\n write(1,' ');\n writeln(1);\n halt(0);\n end;\n\n if odd(s) then\n begin\n sum:=0;\n for j:=1 to s do\n if b[j] and (b[s-j]) then\n begin\n sum:=j;\n break;\n end;\n if sum=0 then\n begin\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to s-p do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n\n end;\n end\n else\n begin\n for i:=1 to s do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end.\n"}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nd:array[0..6000]of 0..5;\nb:array[0..6000*3002]of boolean;\n begin\n readln(n);\n begin\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n s:=n*(n+1)div 2;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if b[s] then\n begin\n for i:=1 to n-1 do\n write(1,' ');\n writeln(1);\n halt(0);\n end;\n\n if odd(s) then\n begin\n sum:=0;\n for j:=1 to s div 2 do\n if b[j] and (b[s-j]) then\n begin\n sum:=j;\n break;\n end;\n if sum=0 then\n begin\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to (s-p)div 2 do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n\n end;\n end\n else\n begin\n for i:=1 to s div 2 do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end."}, {"source_code": "var\n p:array[0..10000000] of longint;\n isnp:array[0..19000000] of boolean;\n a:array[0..6000] of longint;\n n,sum,tot:longint;\n\n procedure xs(x:longint);\n var i,j:longint;\n begin\n tot:=0;\n for i:=2 to x do\n begin\n if not isnp[i] then\n begin\n inc(tot); p[tot]:=i;\n end;\n for j:=1 to tot do\n begin\n if p[j]*i>x then break;\n isnp[p[j]*i]:=true;\n if i mod p[j]=0 then break;\n end;\n end;\n end;\n\n procedure init;\n var i,j,k,t1,t2:longint;\n begin\n fillchar(isnp,sizeof(isnp),false);\n readln(n);\n sum:=n*(n+1) div 2;\n xs(sum);\n if n=1 then begin writeln(-1); halt; end;\n if n=2 then begin writeln('1 1'); halt; end;\n if n=3 then begin writeln('1 1 2'); halt; end;\n if n=4 then begin writeln('1 2 2 1'); halt; end;\n if n=5 then begin writeln('1 2 1 1 1'); halt end;\n if not isnp[sum] then\n begin\n for i:=1 to n-1 do\n write(1,' ');\n writeln(1);\n halt;\n end;\n\n if sum mod 2=0 then\n begin\n for i:=1 to tot do\n if not isnp[sum-p[i]] then\n begin\n for j:=1 to n do a[j]:=1;\n t1:=p[i] div 2; t2:=p[i] div 2+1;\n a[t1]:=2; a[t2]:=2;\n for j:=1 to n-1 do\n write(a[j],' ');\n writeln(a[n]);\n break;\n end;\n halt;\n end;\n if not isnp[sum-2] then\n begin\n write('1 2 ');\n for i:=3 to n-1 do\n write(1,' ');\n writeln(1);\n halt;\n end;\n\n for i:=1 to n do a[i]:=1;\n for i:=n downto 2 do\n if not isnp[i] then\n begin\n a[i div 2]:=3; a[i div 2+1]:=3;\n dec(sum,i);\n break;\n end;\n\n for i:=1 to tot do\n if (not isnp[sum-p[i]]) then\n begin\n t1:=p[i] div 2; t2:=p[i] div 2+1;\n if (a[t1]=3) or (a[t2]=3) then continue;\n a[t1]:=2; a[t2]:=2;\n for j:=1 to n-1 do write(a[j],' ');\n writeln(a[n]);\n halt;\n end;\n end;\nbegin\n init;\nend.\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar\n i,j,n,s,x,y:longint;\n a:array[0..10000] of longint;\n\nfunction pan(x:longint):boolean;\nvar\n i:longint;\nbegin\n if x=1 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\n\nbegin\n readln(n);\n if n=2 then begin writeln('1 1');halt; end;\n for i:=1 to n do a[i]:=1;\n s:=(n*(n+1)) div 2;\n if s mod 2=0 then\n for i:=1 to s do\n if (pan(i))and(pan(s-i)) then\n begin\n x:=n;j:=i;\n while j>n do\n begin\n a[x]:=2;j:=j-x;x:=x-1;\n end;\n a[j]:=2;\n break;\n end;\n if (s mod 2<>0)and(pan(s-2)) then a[2]:=2\n else if s mod 2<>0 then\n begin\n for i:=n downto 1 do\n if pan(i) then begin y:=i;break; end;\n a[y]:=3;\n for i:=1 to s-y do\n if (pan(i))and(pan(s-i-y)) then\n begin\n x:=n;j:=i;\n while j>n do\n begin\n if x=y then begin dec(x);continue; end;\n a[x]:=2;j:=j-x;x:=x-1;\n end;\n a[j]:=2;\n break;\n end;\n end;\n for i:=1 to n do write(a[i],' ');\nend.\n\n"}, {"source_code": "var i,n,s,x,k,t:longint;\n a:array[0..200000000] of boolean;\n b:array[0..6001] of longint;\n begin\n read(n);\n fillchar(a,sizeof(a),true);\n a[1]:=false;\n i:=2;\n s:=(n*(n+1)) div 2;\n for i:=2 to s do\n if a[i] then begin\n x:=i;\n while x+i<=s do\n begin\n x:=x+i;\n a[x]:=false;\n end;\n end;\n if a[s] then begin\n for i:=1 to n do\n write(1,' ');\n writeln;\n halt;\n end;\n x:=0;\n k:=0;\n for i:=1 to s do\n if a[i] and\n a[s-i] then begin\n x:=i;\n break;\n end;\n if x=0 then begin\n b[1]:=1;\n b[2]:=1;\n s:=s-3;\n inc(k);\n end;\n for i:=1 to s do\n if a[i] and\n a[s-i] then begin\n x:=i;\n break;\n end;\n inc(k);\n i:=2;\n while x>0 do\n begin\n t:=x;\n for i:=x downto 1 do\n if b[i]=0 then begin\n x:=x-i;\n b[i]:=k;\n break;\n end;\n if (t=x) then break;\n end;\n inc(k);\n for i:=1 to n do\n if b[i]=0 then b[i]:=k;\n for i:=1 to n do\n write(b[i],' ');\n writeln;\n end. 2"}, {"source_code": "Program G45;\nVar\n ans:Array[0..10000] Of Longint;\n flag:Array[0..40000000] Of Boolean;\n q:Array[0..10000000] OF Longint;\n n,sum,i,r,j:Longint;\nProcedure Print(a,b:Longint);\nVar\n dq,i:Longint;\nBegin\n dq:=1;\n While (a>n) Do Begin\n a:=a-dq;\n ans[dq]:=1;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=1;\n For i:=1 To n Do IF ans[i]=0 Then ans[i]:=2;\n For i:=1 to n-1 Do Write(ans[i],' ');Write(ans[n]);\nEnd;\nProcedure print2(a,b:Longint);\nVar\n i,dq:Longint;\nBegin\n ans[3]:=1;\n dq:=1;\n While (a>n) Do Begin\n If ans[dq]<>0 Then Begin\n Inc(dq);\n Continue;\n End;\n a:=a-dq;\n ans[dq]:=2;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=2;\n For i:=1 To n Do If ans[i]=0 Then ans[i]:=3;\n For i:=1 To n-1 Do Write(ans[i],' ');Write(ans[n]);\nEnd;\nBegin\n Readln(n);\n Fillchar(flag,Sizeof(flag),False);\n sum:=n*(n+1) Div 2;\n For i:=2 To sum Do Begin\n If Not flag[i] Then Begin\n Inc(r);\n q[r]:=i;\n j:=2*i;\n While (j<=sum) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n If flag[sum]=False Then Begin\n // WRiteln(1);\n For i:=1 To n-1 Do Write(1,' '); Write(1);\n Halt;\n End;\n If sum Mod 2=0 Then Begin\n For i:=1 To r Do If flag[sum-q[i]]=FAlse Then Begin\n // Writeln(2);\n Print(q[i],sum-q[i]);\n Halt;\n End;\n End Else Begin\n If flag[sum-2]=False Then Begin\n // Writeln(2);\n WRite(1,' ',2);\n For i:=3 To n Do Write(' ',1);\n Halt;\n End Else Begin\n For i:=1 To r Do If flag[sum-3-q[i]]=False Then Begin\n // Writeln(3);\n Print2(q[i],sum-3-q[i]);\n Halt;\n End;\n End;\n End;\nEnd.\n\n"}], "negative_code": [{"source_code": "{$A8,B+,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}\nprogram prG;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst size = 20000000;\n\nvar a: array[1..size]of Boolean;\n n, sum: longint;\n ans: array[1..6000]of longint;\n\nprocedure resh;\n var i, m: longint;\nbegin\n i := 2;\n while i * i <= size do\n begin\n if not a[i] then\n begin\n m := i;\n while i + m <= size do\n begin\n m := m + i;\n a[m] := true;\n end;\n end;\n Inc(i);\n end;\nend;\n\nprocedure solve;\n var i, m, j: LongInt;\nbegin\n sum := (n * (n + 1)) div 2;\n for i := 2 to sum - 2 do\n if not a[i]and not(a[sum - i]) then\n begin\n if sum mod 2 = 1 then\n begin\n ans[3] := 3;\n sum := sum - 3;\n end;\n m := n;\n j := i;\n while j >= m do\n begin\n if m = 3 then\n begin\n ans[1] := 1;\n ans[2] := 1;\n end else ans[m] := 1;\n j := j - m;\n Dec(m);\n end;\n if j > 0 then\n begin\n if j = 3 then\n begin\n ans[1] := 1;\n ans[2] := 1;\n end else ans[j] := 1;\n end;\n for j := 1 to n do\n if ans[j] = 0 then write('2 ') else write(ans[j], ' ');\n Halt(0);\n end;\nend;\n\nbegin\n//reset(input, 'input.txt'); Rewrite(Output, 'output.txt');\n read(n);\n if n = 2 then\n begin\n Writeln('1 1');\n Halt(0);\n end;\n resh;\n solve;\n\nend.\n"}, {"source_code": "{uses crt; }\nconst nn=10000;\nvar i,j,l,m,n,t,maxholm,besk,i0,s,s1,s2,teks:longint;\n a,b:array[0..nn]of longint;\nfunction pr(a:longint):boolean; var i:longint;ot:boolean;\nbegin ot:=true; for i:=2 to trunc(sqrt(a))+1 do if a mod i =0 then ot:=false;pr:=ot;end;\n\n\n\nbegin {clrscr;\nassign (input,'input1.txt');reset(input); }\n { assign (output,'output.txt'); rewrite(output); }\nreadln(n);\nbegin\n\n s:=0;\n for i:=1 to n do s:=s+i ;\n if pr(s) then for i:=1 to n do a[i]:=1;\n if not pr(s) then\n begin\n if not odd(s) then\n begin for s1:=1 to s do if pr(s1)and pr(s-s1) then break;\n s2:=s-s1;\n {if s1>n then writeln(s,'=',s1,'+',s2);}\n for i:=1 to n do a[i]:=2; a[s1]:=1;\n end else\n begin\n if pr(s-2) then begin for i:=1 to n do a[i]:=2; a[2]:=1; end else\n begin\n if pr(s-6) then begin\n for i:=1 to n do a[i]:=3;\n a[1]:=1;a[5]:=2;\n\n end else\n begin s:=s-3;\n for s1:=1 to s do if pr(s1)and pr(s-s1) then break;\n for i:=1 to n do a[i]:=1;\n a[3]:=2;a[s1]:=3;\n end;\n\n\n\n end;\n\n end;\n\n end;\n\n end;\n\nfor i:= 1 to n do write(a[i],' ');\n\n\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n q,u,j,n,s,i: longint;\n a: array [0..6010] of longint;\n\nfunction prime(x:longint):boolean;\nvar\n i: longint;\nbegin\n for i:=2 to x-1 do\n if i*i > x then break else\n if x mod i = 0 then\n begin\n prime:=False;\n exit;\n end;\n prime:=x > 1;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n s:=n*(n+1) div 2;\n for i:=1 to n do a[i]:=1;\n if not prime(s) then\n begin\n if s and 1 = 1 then\n for i:=n downto 1 do\n if prime(i) then\n begin\n s:=s-i;\n a[i]:=3;\n break;\n end;\n for q:=1 to s-1 do\n if prime(q) and prime(s-q) then\n begin\n u:=q;\n for j:=n downto 1 do\n if (u >= j) and (a[j] = 1) then\n begin\n dec(u,j);\n a[j]:=2;\n end;\n break;\n end;\n end;\n for i:=1 to n-1 do write(a[i],' ');\n writeln(a[n]);\n close(input);\n close(output);\nend."}, {"source_code": "var\nn,i,j,l:longint;\nb:array[0..10000]of boolean;\ncol,c:array[0..10000]of longint;\n begin\n readln(n);\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=2 to n do\n if b[i] then\n begin\n j:=2;\n while i*j<=n do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n c[0]:=0;\n for i:=1 to n do\n c[i]:=10000;\n\n for i:=1 to n do\n if b[i] then\n begin\n for j:=n downto 0 do\n if c[j]+10 do\n begin\n if j>i then j:=i;\n\n while not b[j] do\n j:=j-1;\n\n while c[i-j]+1<>c[i] do\n begin\n j:=j-1;\n while not b[j] do\n j:=j-1;\n end;\n for l:=i-j+1 to i do\n col[l]:=c[i];\n i:=i-j;\n end;\n\n for i:=1 to n-1 do write(col[i],' ');\n writeln(col[n]);\n end."}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nb:array[0..10000000]of boolean;\nd:array[0..10000]of longint;\n begin\n readln(n);\n if n<=2 then writeln(-1)\n else\n begin\n s:=n*(n+1)div 2;\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if odd(s) then\n begin\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to s-p do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to s do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end.\n"}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nb:array[0..10000000]of boolean;\nd:array[0..10000]of longint;\n begin\n readln(n);\n if n>10 then halt(93);\n if n<=2 then writeln(-1)\n else\n begin\n s:=n*(n+1)div 2;\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if odd(s) then\n begin\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to s-p do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to s do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end.\n"}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nb:array[0..10000000]of boolean;\nd:array[0..10000]of longint;\n begin\n readln(n);\n begin\n s:=n*(n+1)div 2;\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if b[s] then\n begin\n for i:=1 to n-1 do\n write(1,' ');\n writeln(1);\n halt(0);\n end;\n\n if odd(s) then\n begin\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to s-p do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to s do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end.\n"}, {"source_code": "var p,sum,j,n,i,s,k:longint;\nb:array[0..10000000]of boolean;\nd:array[0..10000]of longint;\n begin\n readln(n);\n if n<=2 then writeln(-1)\n else\n begin\n s:=n*(n+1)div 2;\n fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=1 to s do\n if b[i] then\n begin\n j:=2;\n while i*j<=s do\n begin\n b[i*j]:=false;\n j:=j+1;\n end;\n end;\n\n if odd(s) then\n begin\n halt(93);\n p:=n;\n while not b[p] do dec(p);\n for i:=1 to n do\n d[i]:=1;\n d[p]:=3;\n for i:=1 to s-p do\n if b[i] and b[s-i-p] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=n downto 1 do\n if p<>i then\n begin\n if i<=sum then\n begin\n sum:=sum-i;\n d[i]:=2;\n end;\n end;\n end\n else\n begin\n for i:=1 to s do\n if b[i] and b[s-i] then\n begin\n sum:=i;\n break;\n end;\n\n for i:=1 to n do\n d[i]:=1;\n\n for i:=n downto 1 do\n if sum-i>=0 then\n begin\n d[i]:=2;\n sum:=sum-i;\n end;\n end;\n\n for i:=1 to n-1 do\n write(d[i],' ');\n writeln(d[n]);\n end;\n end.\n"}, {"source_code": "var\n p:array[0..10000000] of longint;\n isnp:array[0..19000000] of boolean;\n a:array[0..6000] of longint;\n n,sum,tot:longint;\n\n procedure xs(x:longint);\n var i,j:longint;\n begin\n tot:=0;\n for i:=2 to x do\n begin\n if not isnp[i] then\n begin\n inc(tot); p[tot]:=i;\n end;\n for j:=1 to tot do\n begin\n if p[j]*i>x then break;\n isnp[p[j]*i]:=true;\n if i mod p[j]=0 then break;\n end;\n end;\n end;\n\n procedure init;\n var i,j,k,t1,t2:longint;\n begin\n fillchar(isnp,sizeof(isnp),false);\n readln(n);\n sum:=n*(n+1) div 2;\n xs(sum);\n if n=1 then begin writeln(-1); halt; end;\n if n=2 then begin writeln('1 1'); halt; end;\n if n=3 then begin writeln('1 1 2'); halt; end;\n if n=4 then begin writeln('1 2 2 1'); halt; end;\n if n=5 then begin writeln('1 2 1 1 1'); halt end;\n if not isnp[sum] then\n begin\n for i:=1 to n-1 do\n write(1,' ');\n writeln(1);\n halt;\n end;\n\n if sum mod 2=0 then\n begin\n for i:=1 to tot do\n if not isnp[sum-p[i]] then\n begin\n for j:=1 to n do a[j]:=1;\n t1:=p[i] div 2; t2:=p[i] div 2+1;\n a[t1]:=2; a[t2]:=2;\n for j:=1 to n-1 do\n write(a[j],' ');\n writeln(a[n]);\n break;\n end;\n halt;\n end;\n\n if not isnp[sum-2] then\n begin\n write('1 2 ');\n for i:=3 to n-1 do\n write(1,' ');\n writeln(1);\n halt;\n end;\n\n for i:=1 to n do a[i]:=1;\n for i:=n downto 2 do\n if not isnp[i] then\n begin\n a[i]:=3;\n dec(sum,i);\n break;\n end;\n\n for i:=1 to tot do\n if (not isnp[sum-p[i]]) then\n begin\n t1:=p[i] div 2; t2:=p[i] div 2+1;\n if (a[t1]=3) or (a[t2]=3) then continue;\n a[t1]:=2; a[t2]:=2;\n for j:=1 to n-1 do write(a[i],' ');\n writeln(a[n]);\n halt;\n end;\n end;\nbegin\n init;\nend.\n\n\n\n\n\n"}, {"source_code": "Program G45;\nVar\n ans:Array[0..10000] Of Longint;\n flag:Array[0..40000000] Of Boolean;\n q:Array[0..10000000] OF Longint;\n n,sum,i,r,j:Longint;\nProcedure Print(a,b:Longint);\nVar\n dq,i:Longint;\nBegin\n dq:=1;\n While (a>n) Do Begin\n a:=a-dq;\n ans[dq]:=1;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=1;\n For i:=1 To n Do IF ans[i]=0 Then ans[i]:=2;\n For i:=1 to n-1 Do Write(ans[i],' ');Write(ans[n]);\nEnd;\nProcedure print2(a,b:Longint);\nVar\n i,dq:Longint;\nBegin\n ans[3]:=1;\n dq:=1;\n While (a>n) Do Begin\n If ans[dq]<>0 Then Begin\n Inc(dq);\n Continue;\n End;\n a:=a-dq;\n ans[dq]:=2;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=2;\n For i:=1 To n Do If ans[i]=0 Then ans[i]:=3;\n For i:=1 To n-1 Do Write(ans[i]);Write(ans[n]);\nEnd;\nBegin\n Readln(n);\n Fillchar(flag,Sizeof(flag),False);\n sum:=n*(n+1) Div 2;\n For i:=2 To sum Do Begin\n If Not flag[i] Then Begin\n Inc(r);\n q[r]:=i;\n j:=2*i;\n While (j<=sum) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n If flag[sum]=False Then Begin\n WRiteln(1);\n For i:=1 To n-1 Do Write(1,' '); Write(1);\n Halt;\n End;\n If sum Mod 2=0 Then Begin\n For i:=1 To r Do If flag[sum-q[i]]=FAlse Then Begin\n Writeln(2);\n Print(q[i],sum-q[i]);\n Halt;\n End;\n End Else Begin\n If flag[sum-2]=False Then Begin\n Writeln(2);\n WRite(1,' ',2);\n For i:=3 To n Do Write(' ',1);\n Halt;\n End Else Begin\n For i:=1 To r Do If flag[sum-3-q[i]]=False Then Begin\n Writeln(3);\n Print2(q[i],sum-3-q[i]);\n Halt;\n End;\n End;\n End;\nEnd.\n\n"}, {"source_code": "Program G45;\nVar\n ans:Array[0..10000] Of Longint;\n flag:Array[0..40000000] Of Boolean;\n q:Array[0..10000000] OF Longint;\n n,sum,i,r,j:Longint;\nProcedure Print(a,b:Longint);\nVar\n dq,i:Longint;\nBegin\n dq:=1;\n While (a>n) Do Begin\n a:=a-dq;\n ans[dq]:=1;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=1;\n For i:=1 To n Do IF ans[i]=0 Then ans[i]:=2;\n For i:=1 to n-1 Do Write(ans[i],' ');Write(ans[n]);\nEnd;\nProcedure print2(a,b:Longint);\nVar\n i,dq:Longint;\nBegin\n ans[3]:=1;\n dq:=1;\n While (a>n) Do Begin\n If ans[dq]<>0 Then Begin\n Inc(dq);\n Continue;\n End;\n a:=a-dq;\n ans[dq]:=2;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=2;\n For i:=1 To n Do If ans[i]=0 Then ans[i]:=3;\n For i:=1 To n-1 Do Write(ans[i]);Write(ans[n]);\nEnd;\nBegin\n Readln(n);\n Fillchar(flag,Sizeof(flag),False);\n sum:=n*(n+1) Div 2;\n For i:=2 To sum Do Begin\n If Not flag[i] Then Begin\n Inc(r);\n q[r]:=i;\n j:=2*i;\n While (j<=sum) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n If flag[sum]=False Then Begin\n // WRiteln(1);\n For i:=1 To n-1 Do Write(1,' '); Write(1);\n Halt;\n End;\n If sum Mod 2=0 Then Begin\n For i:=1 To r Do If flag[sum-q[i]]=FAlse Then Begin\n // Writeln(2);\n Print(q[i],sum-q[i]);\n Halt;\n End;\n End Else Begin\n If flag[sum-2]=False Then Begin\n // Writeln(2);\n WRite(1,' ',2);\n For i:=3 To n Do Write(' ',1);\n Halt;\n End Else Begin\n For i:=1 To r Do If flag[sum-3-q[i]]=False Then Begin\n // Writeln(3);\n Print2(q[i],sum-3-q[i]);\n Halt;\n End;\n End;\n End;\nEnd.\n\n"}, {"source_code": "Program G45;\nVar\n ans:Array[0..10000] Of Longint;\n flag:Array[0..40000000] Of Boolean;\n q:Array[0..10000000] OF Longint;\n n,sum,i,r,j:Longint;\nProcedure Print(a,b:Longint);\nVar\n dq,i:Longint;\nBegin\n dq:=1;\n While (a>n) Do Begin\n a:=a-dq;\n ans[dq]:=1;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=1;\n For i:=1 To n Do IF ans[i]=0 Then ans[i]:=2;\n For i:=1 to n Do Write(ans[i],' ');\nEnd;\nProcedure print2(a,b:Longint);\nVar\n i,dq:Longint;\nBegin\n ans[3]:=1;\n dq:=1;\n While (a>n) Do Begin\n If ans[dq]<>0 Then Begin\n Inc(dq);\n Continue;\n End;\n a:=a-dq;\n ans[dq]:=2;\n Inc(dq);\n End;\n If a<>0 Then ans[a]:=2;\n For i:=1 To n Do If ans[i]=0 Then ans[i]:=3;\n For i:=1 To n Do Write(ans[i],' ');\nEnd;\nBegin\n Readln(n);\n Fillchar(flag,Sizeof(flag),False);\n sum:=n*(n+1) Div 2;\n For i:=2 To sum Do Begin\n If Not flag[i] Then Begin\n Inc(r);\n q[r]:=i;\n j:=2*i;\n While (j<=sum) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n If flag[sum]=False Then Begin\n WRiteln(1);\n For i:=1 To n Do Write(1,' ');\n Halt;\n End;\n If sum Mod 2=0 Then Begin\n For i:=1 To r Do If flag[sum-q[i]]=FAlse Then Begin\n Writeln(2);\n Print(q[i],sum-q[i]);\n Halt;\n End;\n End Else Begin\n If flag[sum-2]=False Then Begin\n Writeln(2);\n WRite(1,' ',2);\n For i:=3 To n Do Write(' ',1);\n Halt;\n End Else Begin\n For i:=1 To r Do If flag[sum-3-q[i]]=False Then Begin\n Writeln(3);\n Print2(q[i],sum-3-q[i]);\n Halt;\n End;\n End;\n End;\nEnd.\n\n"}, {"source_code": "{$IFNDEF ONLINE_JUDGE} \n\t{$APPTYPE CONSOLE}\n\t{R+,S+,Q+,I+,C+,M+,H+,O+} \n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ELSE} \n\t{$MODE DELPHI} \n\t{R+,S+,Q+,I+,C+,M+,H+,O+}\n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ENDIF}\n{M 40000000}\n\nuses\n\tSysUtils, Math; \n\nconst\n\tMAXN = 18000000;\n\nvar\n\ti, n, ii, cur, cc : longint;\n\tp : array[0..MAXN + 10] of boolean;\n\ta : array[0..6010] of longint;\n\td : array[0..2222222] of longint;\n\tj : int64;\n\nbegin \n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\tread(n);\n\tfillchar(p, sizeof(p), 1);\n\tp[1] := false;\n\ti := 4;\n\twhile i <= MAXN do begin\n\t\tp[i] := false;\n\t\tinc(i, 2);\n\tend;\n\ti := 3;\n\tcc := 1;\n\td[1] := 2;\n\twhile i <= MAXN do begin\n\t\tif p[i] then begin\n\t\t\tj := int64(i) * i;\n\t\t\tii := i shl 1;\n\t\t\twhile j <= MAXN do begin\n\t\t\t\tp[j] := false;\n\t\t\t\tinc(j, ii);\n\t\t\tend;\n\t\t\tinc(cc);\n\t\t\td[cc] := i;\n\t\tend;\n\t\tinc(i, 2);\n\tend;\n\tfor i := 1 to n do\n\t\ta[i] := 1;\n\tcur := n * (n + 1) shr 1;\n\tif not p[cur] then\n\t\tif cur and 1 = 0 then begin\n\t\t\tfor i := 2 to cc do\n\t\t\t\tif d[i] > cur then break else\n\t\t\t\tif p[cur - d[i]] then begin\n\t\t\t\t\ta[d[i]] := 2;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tend else\n\t\tif p[cur - 2] then a[2] := 2 else begin\n\t\t\ta[3] := 3;\n\t\t\tdec(cur, 3);\n\t\t\tfor i := 3 to cc do\n\t\t\t\tif d[i] > cur then break else\n\t\t\t\tif p[cur - d[i]] then begin\n\t\t\t\t\ta[d[i]] := 2;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tend;\n\tfor i := 1 to n do\n\t\twrite(a[i], ' ');\nend.\n\n"}, {"source_code": "{$IFNDEF ONLINE_JUDGE} \n\t{$APPTYPE CONSOLE}\n\t{R+,S+,Q+,I+,C+,M+,H+,O+} \n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ELSE} \n\t{$MODE DELPHI} \n\t{R+,S+,Q+,I+,C+,M+,H+,O+}\n\t{$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ENDIF}\n{M 40000000}\n\nuses\n\tSysUtils, Math; \n\nprocedure go(n, k : longint);\n\nvar\n\ti : longint;\n\nbegin\n\tfor i := 1 to n do\n\t\twrite(k, ' ');\nend;\n\nvar\n\ti, j, n, kk, cc, ii : longint;\n\tp : array[0..6010] of boolean;\n\ta : array[0..610] of longint;\n\nbegin \n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\tread(n);\n\tcc := 1;\n\ta[1] := 2;\n\tkk := trunc(sqrt(n));\n\tfillchar(p, sizeof(p), 1);\n\tp[1] := false;\n\ti := 4;\n\twhile i <= n do begin\n\t\tp[i] := false;\n\t\tinc(i, 2);\n\tend;\n\ti := 3;\n\twhile i <= n do begin\n\t\tif p[i] then begin\n\t\t\tj := i * i;\n\t\t\tii := i shl 1;\n\t\t\twhile j <= n do begin\n\t\t\t\tp[j] := false;\n\t\t\t\tinc(j, ii);\n\t\t\tend;\n\t\t\tinc(cc);\n\t\t\ta[cc] := i;\n\t\tend;\n\t\tinc(i, 2);\n\tend;\n\tif p[n] then begin\n\t\tgo(n, 1);\n\t\thalt(0);\n\tend;\n\tfor i := 1 to cc do\n\t\tif p[n - a[i]] then begin\n\t\t\tgo(a[i], 1);\n\t\t\tgo(n - a[i], 2);\n\t\t\thalt(0);\n\t\tend;\n\tfor i := 1 to cc do\n\t\tfor j := 1 to cc do\n\t\t\tif a[i] + a[j] > n then break else\n\t\t\tif p[n - a[i] - a[j]] then begin\n\t\t\t\tgo(a[i], 1);\n\t\t\t\tgo(a[j], 2);\n\t\t\t\tgo(n - a[i] - a[j], 3);\n\t\t\t\thalt(0);\n\t\t\tend; \nend.\n\n"}], "src_uid": "94ef0d901f21e1945849fd5bfc2d1449"} {"source_code": " const eps=1e-8;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n double=extended;\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; cos1,sin1,centr:extended;\nbegin\n al:=al+pi/2; cos1:=cos(al); sin1:=sin(al);\n { writeln('cos= ',cos(al):0:6,' sin= ',sin(al):0:6);\n } for i:=1 to q do a[i]:=xx[i]*cos1+yy[i]*sin1;\n centr:=xxx*cos(al)+yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]); xxx:=0;yyy:=0;\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n { writeln(xxx:0:2,' == ',yyy:0:2);\n for i:=1 to q do writeln(xx[i]:0:0,' ',yy[i]:0:0);\n }\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al*180/pi:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then begin inc(pp);\n if aleps then inc(ot);\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n", "positive_code": [{"source_code": " const eps=1e-8;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n double=extended;\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n al:=al+pi/2;\n { writeln('cos= ',cos(al):0:6,' sin= ',sin(al):0:6);\n } for i:=1 to q do a[i]:=xx[i]*cos(al)+yy[i]*sin(al);\n centr:=xxx*cos(al)+yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]); xxx:=0;yyy:=0;\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n { writeln(xxx:0:2,' == ',yyy:0:2);\n for i:=1 to q do writeln(xx[i]:0:0,' ',yy[i]:0:0);\n }\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al*180/pi:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then begin inc(pp);\n if aleps then inc(ot);\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}], "negative_code": [{"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n al:=al+pi/2;\n { writeln('cos= ',cos(al):0:6,' sin= ',sin(al):0:6);\n } for i:=1 to q do a[i]:=xx[i]*cos(al)+yy[i]*sin(al);\n centr:=xxx*cos(al)+yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]); xxx:=0;yyy:=0;\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n { writeln(xxx:0:2,' == ',yyy:0:2);\n for i:=1 to q do writeln(xx[i]:0:0,' ',yy[i]:0:0);\n }\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al*180/pi:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then begin inc(pp); ccc[pp]:=al; {writeln('al= ',al:0:7);} end;\n\n end;\n\n n:=1024*8;\n for i:=1 to pp do a[i]:=ccc[i];\n { for i:=1 to pp do write(a[i]:0:5,' '); writeln;\n } for i:=pp+1 to n do a[i]:=besk;\n sort(a);\n a[0]:=-10000;\n for i:=1 to pp do if abs(a[i]-a[i-1])>eps then inc(ot);\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n al:=al+pi/2;\n { writeln('cos= ',cos(al):0:6,' sin= ',sin(al):0:6);\n } for i:=1 to q do a[i]:=xx[i]*cos(al)+yy[i]*sin(al);\n centr:=xxx*cos(al)+yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]); xxx:=0;yyy:=0;\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n { writeln(xxx:0:2,' == ',yyy:0:2);\n for i:=1 to q do writeln(xx[i]:0:0,' ',yy[i]:0:0);\n }\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al*180/pi:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then begin inc(pp);\n if aleps then inc(ot);\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-7;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n al:=al+pi/2;\n { writeln('cos= ',cos(al):0:6,' sin= ',sin(al):0:6);\n } for i:=1 to q do a[i]:=xx[i]*cos(al)+yy[i]*sin(al);\n centr:=xxx*cos(al)+yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]); xxx:=0;yyy:=0;\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n { writeln(xxx:0:2,' == ',yyy:0:2);\n for i:=1 to q do writeln(xx[i]:0:0,' ',yy[i]:0:0);\n }\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al*180/pi:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then begin inc(pp);\n if aleps then inc(ot);\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n { al:=al+pi/2; }\n for i:=1 to q do a[i]:=xx[i]*cos(al)-yy[i]*sin(al);\n centr:=xxx*cos(al)-yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]);\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n{ writeln(xxx:0:1,' == ',yyy:0:1);\n for i:=1 to q do writeln(xx[i]:0:1,' ',yy[i]:0:1);\n}\n if q=0 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then inc(ot);\n\n end;\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,3,44;\n type\n mas=array[-200000..2*1000000+1] of extended;\nvar\nii,k,i,j,step,stepp:longint;\nn,kkk,tt,l,kol,dl,i1,j1,imin,pp,m,n1,k1,w,mesto,jj,pl1,pl2,pl3:int64;\na3,b3,c3,t,mask,sum,t1,t2,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[-10..1000000] of boolean;\n cha:char;\nfuc,fac,kolali,kolbob,ali,bob,b1,a1:array[-10..300000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nf:array[0..225000,0..40] of int64;\nal,xx1,yy1,xxx,yyy,t3:extended; ch:char;\nx,y,stepen:array[-10..2000000] of int64;\nzan1,zan2:array[-3000000..3000000] of boolean;\n\nxx,yy,ll,rr,aa,ccc, c,a,b:mas; flag:boolean; pl:longint;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif ((a[i])<(a[j])) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif ((a[i])>=(a[j])) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin\na:=abs(a); b:=abs(b);\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\nfunction good(q:longint;al:extended):boolean;\nvar fl:boolean; i,j:longint; centr:extended;\nbegin\n { al:=al+pi/2; }\n for i:=1 to q do a[i]:=xx[i]*cos(al)-yy[i]*sin(al);\n centr:=xxx*cos(al)-yyy*sin(al);\n n:=1; while neps then fl:=false;\n\n\n\n\n good:=fl;\nend;\n\n\n\n\nbegin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(p);\n for i:=1 to p do read(x[i],y[i]);\n for i:=1 to p do begin xxx:=xxx+x[i]; yyy:=yyy+y[i]; end;\n xxx:=xxx/p;yyy:=yyy/p;\n for i:=1 to p do\n begin\n jj:=0;\n for j:=i+1 to p do\n begin\n flag:=true;\n if abs ((x[i]+x[j])/2-xxx)>eps then flag:=false;\n if abs ((y[i]+y[j])/2-yyy)>eps then flag:=false;\n if flag then jj:=j;\n\n end;\n\n if jj>0 then begin zan[i]:=true; zan[jj]:=true; end;\n\n\n end;\n\n for i:=1 to p do if not zan[i] then begin inc(q); xx[q]:=x[i]; yy[q]:=y[i]; end;\n\n{ writeln(xxx:0:1,' == ',yyy:0:1);\n for i:=1 to q do writeln(xx[i]:0:1,' ',yy[i]:0:1);\n}\n if q<3 then begin writeln(-1); goto 1; end;\n\n for ii:=1 to q do\n begin\n xx1:=(xx[1]+xx[ii])/2; yy1:=(yy[1]+yy[ii])/2;\n al:=phi(xx1-xxx,yy1-yyy);\n\n { writeln('al= ',al:0:6,' q= ',q);\n\n writeln(good(q,al));\n }\n\n if good(q,al) then inc(ot);\n\n end;\n\n writeln(ot);\n\n\n\n 1: close (output);\nend.\n"}], "src_uid": "5d7ba962400c05433ee17c5658888e69"} {"source_code": "uses math;\nvar n,kq,kc,sl:int64;\ni:longint;\nbegin\n//assign(input,'cc.inp');reset(input);\n//assign(output,'cc.out');rewrite(output);\nread(n);\nif n >0 then\n n:=abs(n)mod 360\n else n:=-(abs(n)mod 360);\nn:=(360-n) mod 360;\n//writeln(n);\nkq:=0;\nkc:=min(abs(n),abs(360-n));\nfor i:=1 to 4 do\n begin\n n:=(n +90) mod 360;\n if min(abs(n),abs(360-n))=315) then writeln(0);\nif (n>45) and (n<=135) then writeln(1);\nif (n<315) and (n>225) then writeln(3);\nif (n>135) and (n<=225) then writeln(2);\nend."}, {"source_code": "var\n a, b: array[0..3000] of int64;j, k,q, n: int64;i: longint;st: string;\n\nbegin\n readln(n);n := n mod 360;\n if (n>=-45) and(n<=45) then write(0) else\n if (n<-45) and(n>-135) then write(3) else\n if (n<=-135) and(n>-225) then write(2) else\n if (n<=-225) and(n>-315) then write(1) else\n if (n<=-315) then write(0) else\n if (n>45) and(n<=135) then write(1) else\n if (n>135) and(n<=225) then write(2) else\n if (n>225) and(n<315) then write(3) else write(0);\n \nend."}, {"source_code": "var n:int64;\nbegin\nreadln(n);\nn:=n mod 360;\nn:=(n+360) mod 360;\nif (n<=45) or (n>=315) then writeln(0);\nif (n>45) and (n<=135) then writeln(1);\nif (n<315) and (n>225) then writeln(3);\nif (n>135) and (n<=225) then writeln(2);\nend.\n"}, {"source_code": "var n:int64;sc:integer;\nbegin\n readln(n);\n n:=(((n mod 360)+360)mod 360)+44;\n case n of\n 0..89,359:sc:=0;\n 90..179:sc:=1;\n 180..269:sc:=2;\n 270..358:sc:=3;\n end;\n writeln(sc);\n \nend."}, {"source_code": "var\n\tn\t: int64;\n\ta\t: integer;\nbegin\n\treadln(n);\n\tn:= n mod 360;\n\tif n<0 then\n\t\tn:=n+360;\n\ta:=n div 90;\n\t//writeln(n,' ',a);\n\tif (n mod 90 < 45) then\n\tbegin\n\t\t//writeln('yes');\n\t\tcase a of\n\t\t3 : writeln(3);\n\t\t2 : writeln(2);\n\t\t1 : writeln(1);\n\t\t0 : writeln(0);\n\t\tend;\n\tend else\n\tbegin\n\t\t\n\t\tif (n mod 90 > 45) then\n\t\tbegin\n\t\t\t//writeln('yes1');\n\t\t\tcase a of\n\t\t\t3 : writeln(0);\n\t\t\t2 : writeln(3);\n\t\t\t1 : writeln(2);\n\t\t\t0 : writeln(1);\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes2');\n\t\t\tcase a of\n\t\t\t3 : writeln(0);\n\t\t\t2 : writeln(2);\n\t\t\t1 : writeln(1);\n\t\t\t0 : writeln(0);\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var n:int64;\nbegin\nreadln(n);\nn:=n mod 360;\nn:=(n+360) mod 360;\nif (n<=45) or (n>=315) then writeln(0);\nif (n>45) and (n<=135) then writeln(1);\nif (n<315) and (n>225) then writeln(3);\nif (n>135) and (n<=225) then writeln(2);\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+1800000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n if n>=359 then begin write(0); goto 1; end;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n 1: close(output);\nend.\n"}, {"source_code": "var\n n:int64; t0,t1,t2,t3,min:longint;\n\nfunction kk(x:int64):longint;\nbegin\n if x<0 then\n begin x:=-x; x:=x mod 360; x:=-x; end\n else x:=x mod 360;\n if x<-180 then inc(x,360);\n if x>180 then dec(x,360);\n exit(abs(x));\nend;\n\nbegin\n readln(n); t0:=kk(n);\n t1:=kk(n-90); t2:=kk(n-180); t3:=kk(n-270);\n min:=t0;\n if t1=315 then write(0) else\n if k<=45 then write(n div 90) else\n write(n div 90 +1);\n \n \n\nend."}, {"source_code": "program z_630_m;\nvar x:int64;\ni,m,min,w,d,q:integer;\nbegin\nreadln(x);\nw:=(-1)*(x mod 360);\nif w>0 then w:=(-1)*(360-w);\nmin:=361;\n\nfor i:=0 to 3 do\nbegin\nd:=abs(w+90*i);\nq:=q+1;\nif d>180 then d:=abs(360-d);\nif d=315) then writeln(0);\nif (n>45) and (n<=135) then writeln(1);\nif (n<315) and (n>225) then writeln(3);\nif (n>135) and (n<=225) then writeln(2);\nend."}], "negative_code": [{"source_code": "var\n a, b: array[0..3000] of int64;j, k,q, n: int64;i: longint;st: string;\n\nbegin\n readln(n);n := n mod 360;\n k := 0;q := abs(n);if n=-180 then begin write(2);halt;end;\n n := n - 90;if (abs(n) < q) then begin\n k := 1;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 1;q := abs(n);\n end;\n n := n - 90;if (abs(n) < q) then begin\n k := 2;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 2;q := abs(n);\n end;\n n := n - 90;if (abs(n) < q) then begin\n k := 3;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 3;q := abs(n);\n end;\n write(k);\n \nend."}, {"source_code": "var\n a, b: array[0..3000] of int64;j, k,q, n: int64;i: longint;st: string;\n\nbegin\n readln(n);n := n mod 360;\n k := 0;q := abs(n);\n n := n - 90;if (abs(n) < q) then begin\n k := 1;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 1;q := abs(n);\n end;\n n := n - 90;if (abs(n) < q) then begin\n k := 2;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 2;q := abs(n);\n end;\n n := n - 90;if (abs(n) < q) then begin\n k := 3;q := abs(n);\n end;if (abs(n + 360)) < q then begin\n k := 3;q := abs(n);\n end;\n write(k);\n \nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+45;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+46;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n writeln(n div 90);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+1800000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+46;\n writeln(n div 90);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+45;\n writeln(n div 90);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+3600000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n if n<=3 then writeln(n div 90) else write(0);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\naa,p,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of int64;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\npr2,prloos,pr1,ppr,prob:array[-100..200000] of int64;\n\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n n:=(n+1800000000000000000) mod 360;\n { writeln(n);\n } n:=n+44;\n if n>359 then begin write(0); goto 1; end;\n n:=n div 90;\n if n<=3 then writeln(n) else write(0);\n\n 1: close(output);\nend.\n"}, {"source_code": "var\nn,s:Qword;\ni:qword;\n\nbegin\nreadln(n);\ns:=0;\ns:=trunc(n/210)*48;\nn:=n mod 210;\ni:=1;\nwhile (i<=n) do begin\nif (((i mod 2)<>0)and((i mod 3)<>0)and((i mod 5)<>0)and((i mod 7)<>0)) then\n s:=s+1;\ni:=i+1;\nend;\nwriteln(s);\n\nend."}, {"source_code": "uses math;\nvar n,kq,kc,sl:int64;\ni:longint;\nbegin\n//assign(input,'cc.inp');reset(input);\n//assign(output,'cc.out');rewrite(output);\nread(n);\nn:=(360-n) mod 360;\nkq:=0;\nkc:=min(abs(n),abs(360-n));\nfor i:=1 to 4 do\n begin\n n:=(n +90) mod 360;\n if min(abs(n),abs(360-n))>kc then\n begin\n kc:=min(abs(n),abs(360-n));\n kq:=i;\n end;\n end;\nwriteln(kq);\nend.\n\n\n"}, {"source_code": "uses math;\nvar n,kq,kc,sl:int64;\ni:longint;\nbegin\n//assign(input,'cc.inp');reset(input);\n//assign(output,'cc.out');rewrite(output);\nread(n);\nif n <>0 then\n n:=abs(n)mod 360*n div(abs(N));\nn:=(360-n) mod 360;\n//writeln(n);\nkq:=0;\nkc:=min(abs(n),abs(360-n));\nfor i:=1 to 4 do\n begin\n n:=(n +90) mod 360;\n if min(abs(n),abs(360-n)) 45) then\n\t\tbegin\n\t\t\t//writeln('yes1');\n\t\t\tcase a of\n\t\t\t3 : writeln(0);\n\t\t\t2 : writeln(3);\n\t\t\t1 : writeln(2);\n\t\t\t0 : writeln(1);\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes2');\n\t\t\tcase a of\n\t\t\t3 : writeln(1);\n\t\t\t2 : writeln(2);\n\t\t\t1 : writeln(1);\n\t\t\t0 : writeln(0);\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var n,k:int64;\nn1,k1:int64;\na,b:double;\nc,s:string;\ni:integer;\nbegin\nread(n);\nn:=n mod 360;\n if n<0 then n:=360+n;\n k:=n mod 90;\n if k<=45 then write(n div 90) else\n write(n div 90 +1);\n \n \n\nend."}, {"source_code": "var n:int64;\nbegin\nreadln(n);\nn:=n mod 360;\nn:=(n+360) mod 360;\nif (n<=45) or (n>=315) then writeln(0);\nif (n>45) and (n<=135) then writeln(1);\nif (n<315) and (n>=225) then writeln(3);\nif (n>135) and (n<225) then writeln(2);\nend."}], "src_uid": "509db9cb6156b692557ba874a09f150e"} {"source_code": "const base=1000000000+7;\nvar f,g:text;\n a,b,ba,ab,bb:array[1..3000]of int64;\n n:longint;\n xau:array[1..2]of ansistring;\n s:ansistring;\n mag:array[1..100000]of longint;\n\nfunction tinh(var p:ansistring; x,y:longint):int64;\nvar i,q:longint;\n tinhz:int64;\nbegin\n q:=0;\n tinhz:=0;\n for i:=1 to length(p) do begin\n while (q>0)and(p[i]<>s[q+1])do q:=mag[q];\n if p[i]=s[q+1] then inc(q);\n if q=length(s) then begin\n q:=mag[q];\n if (i>x)and((i-length(s)+1)<=y) then inc(tinhz);\n end;\n end;\n tinhz:=tinhz mod base;\n tinh:=tinhz;\nend;\n\nprocedure kmp;\nvar i,q:longint;\nbegin\n q:=0;\n mag[1]:=0;\n for i:=2 to length(s)do begin\n while (q>0)and(s[q+1]<>s[i])do q:=mag[q];\n if s[q+1]=s[i]then inc(q);\n mag[i]:=q;\n end;\nend;\n\nprocedure solve;\nvar temp,first,second,count:longint;\n xauab,xauba,xaubb:ansistring;\n timeab,timeba,timebb,tong:int64;\nbegin\n count:=1;\n xau[1]:='a';\n xau[2]:='b';\n first:=1; second:=2;\n while (length(xau[first]))n then tong:=0\n else begin\n xauab:=xau[first]+xau[second];\n timeab:=tinh(xauab,length(xau[first]),length(xau[first]));\n xauba:=xau[second]+xau[first];\n timeba:=tinh(xauba,length(xau[second]),length(xau[second]));\n xaubb:=xau[second]+xau[second];\n timebb:=tinh(xaubb,length(xau[second]),length(xau[second]));\n tong:=(tong+timeab*(ab[n-count+1]))mod base;\n tong:=(tong+timeba*(ba[n-count+1]))mod base;\n tong:=(tong+timebb*(bb[n-count+1]))mod base;\n tong:=(tong+tinh(xau[first],0,length(xau[first]))*a[n-count+1])mod base;\n tong:=(tong+tinh(xau[second],0,length(xau[second]))*b[n-count+1])mod base;\n end;\n writeln(g,tong);\nend;\n\nprocedure nhap;\nvar space:char;\n test,i:longint;\nbegin\n assign(f,'');\n assign(g,'');\n reset(f);\n rewrite(g);\n readln(f,n,test);\n for i:=1 to test do begin\n readln(f,s);\n kmp;\n solve;\n end;\n close(f);\n close(g);\nend;\n\nprocedure tinhtruoc;\nvar i:longint;\nbegin\n a[1]:=1; a[2]:=0; a[3]:=1;\n for i:=4 to 3000 do a[i]:=(a[i-1]+a[i-2])mod base;\n b[1]:=0; b[2]:=1;\n for i:=3 to 3000 do b[i]:=(b[i-1]+b[i-2])mod base;\n ba[1]:=0; ba[2]:=0; ba[3]:=1;\n for i:=4 to 3000 do ba[i]:=(ba[i-1]+ba[i-2])mod base;\n ab[1]:=0; ab[2]:=0; ab[3]:=0; ab[4]:=1;\n for i:=5 to 3000 do begin\n ab[i]:=ab[i-1]+ab[i-2];\n if (i mod 2)=0 then inc(ab[i]);\n ab[i]:=ab[i]mod base;\n end;\n bb[1]:=0; bb[2]:=0; bb[3]:=0; bb[4]:=0;\n for i:=5 to 3000 do begin\n bb[i]:=bb[i-1]+bb[i-2];\n if (i mod 2)=1 then inc(bb[i]);\n bb[i]:=bb[i]mod base;\n end;\nend;\n\nbegin\n tinhtruoc;\n nhap;\nend.\n", "positive_code": [{"source_code": "const fin='';\n fout='';\nvar f:array [0..40] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:ansistring;\n fi,fo:text;\nprocedure wr (x:int64);\n begin\n writeln (fo,x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then\n begin\n f:=1;break;\n end;\n if f=0 then\n ans:=(ans+1) mod 1000000007;\n end;\n vh:=ans mod 1000000007 ;\n end;\nprocedure xuli;\nbegin\n while not eof(fi) do\n begin\n f[1]:='a'; f[2]:='b';\n readln (fi,s);\n for i:=3 to 20 do f[i]:=f[i-1]+f[i-2];\n if n<=20 then\n begin\n wr(vh(s,f[n]));continue;\n end;\n ls:=length(s);\n fs[19]:=copy(f[19],1,ls-1);\n fs[20]:=copy(f[20],1,ls-1);\n fe[19]:=copy(f[19],length(f[19])-ls+2,ls-1);\n fe[20]:=copy(f[20],length(f[20])-ls+2,ls-1);\n fvh[19]:=vh(s,f[19]);\n fvh[20]:=vh(s,f[20]);\n for i:=21 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) mod 1000000007;\n end;\n wr(fvh[n]);\n end;\nend;\nbegin\n assign (fi,fin); reset(fi);\n assign (fo,fout); rewrite(fo);\n readln (fi,n,k);\n xuli;\n close(fi); close(fo);\nend."}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 38 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 36 do\n begin\n if length(f[j])>length(s)*5 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "var f:array [0..40] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:ansistring;\nprocedure wr (x:int64);\n begin\n writeln (x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then begin f:=1;break;end;\n if f=0 then ans:=(ans+1) mod 1000000007;\n end;\n vh:=ans mod 1000000007;\n end;\n\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (n,k);\nfor ii:=1 to k do\nbegin\nreadln (s);\nf[1]:='a';\nf[2]:='b';\nfor i:=3 to 20 do f[i]:=f[i-1]+f[i-2];\nif n<=20 then begin wr(vh(s,f[n]));continue;end;\nls:=length(s);\nfs[19]:=copy(f[19],1,ls-1);\nfs[20]:=copy(f[20],1,ls-1);\nfe[19]:=copy(f[19],length(f[19])-ls+2,ls-1);\nfe[20]:=copy(f[20],length(f[20])-ls+2,ls-1);\nfvh[19]:=vh(s,f[19]);\nfvh[20]:=vh(s,f[20]);\n//writeln (length(f[20]));\nfor i:=21 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) mod 1000000007;\n end;\nwr(fvh[n]);\nend;\nend.\n"}, {"source_code": "uses math;\nconst md=1000000007;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m,l:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n{ assign(input,'input.txt');\n reset(input); }\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],length(f[i-2])-2999,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n l:=length(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n { c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);}\n for i:=3 to n do\n begin\n ss:='';\n if length(f[i-1])>=l then\n s1:=copy(f[i-1],length(f[i-1])-(l-1)+1,l-1)\n else s1:=f[i-1];\n if length(f[i-2])>=l then\n s2:=copy(f[i-2],1,l-1)\n else s2:=f[i-2];\n ss:=s1+s2;\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "uses math;\nconst md=1000000007;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m,l:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n{ assign(input,'input.txt');\n reset(input); }\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],length(f[i-2])-2999,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n l:=length(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n { c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);}\n for i:=3 to n do\n begin\n ss:='';\n if length(f[i-1])>=l then\n s1:=copy(f[i-1],length(f[i-1])-(l-1)+1,l-1)\n else s1:=f[i-1];\n if length(f[i-2])>=l then\n s2:=copy(f[i-2],1,l-1)\n else s2:=f[i-2];\n ss:=s1+s2;\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "const md = 1000000007;\nvar\nans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\npp:array[0..200000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar cc,i,j,k:longint;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then find:=x[1,2] else\n find:=x[1,1];\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=2 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=count;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n j:=t+3;\n p4:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const md = 1000000007;\nvar\nio,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\nans,pp:array[0..200000]of longint;\nf:array[0..10000]of ansistring;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=2 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=count;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n j:=t+3;\n p4:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n fillchar(ans,sizeof(ans),0);\n if (p1<>p2)and(s<>'a') then\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n\n // 1 1 1 1 1\n end else\n if (p1+p2=p3)or(s='a') then\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n\n // 0 0 0 0 0 0\n end else\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n\n // 1 0 1 0 1 0 1\n end;\n writeln(ans[k]);\n end;\n end."}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 38 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 36 do\n begin\n if length(f[j])>length(s)*5 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}], "negative_code": [{"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 32 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 29 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const md = 1000000007;\nvar\nans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\npp:array[0..1000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar cc,i,j,k:longint;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then find:=x[1,2] else\n find:=x[1,1];\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n\n for j:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 27 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:string;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of string;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 27 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 36 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 32 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 38 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 36 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "{$R+}\nconst md = 1000000007;\nvar\nuu,ans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nanss,a1,a2,a3,a4,c1,t1,t2:array[0..100000]of int64;\nw,s:ansistring;\nk:int64;\npp:array[0..2000000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar ha,i,j,k:longint;\ncc:int64;\n begin\n if c<=0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n for i:=1 to uu do\n if (p1=a1[i])and(p2=a2[i])and(p3=a3[i])and(p4=a4[i])\n and(c=c1[i])and(r1=t1[i])and(r2=t2[i]) then\n begin\n find:=anss[i];\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,2];\n find:=x[1,2]\n end else\n begin\n uu:=uu+1;\n a1[uu]:=p1;\n a2[uu]:=p2;\n a3[uu]:=p3;\n a4[uu]:=p4;\n c1[uu]:=cc;\n t1[uu]:=r1;\n t2[uu]:=r2;\n anss[uu]:=x[1,1];\n find:=x[1,1];\n end;\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n for i:=length(s)+1 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n if tt=4 then break;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n for i:=2 to length(s) do\n begin\n pp[i]:=pp[i-1];\n while (s[pp[i]+1]<>s[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if s[pp[i]+1]=s[i] then inc(pp[i]);\n\n end;\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=p;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3+1,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p2+p3,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const fin='';\n fout='';\nvar f:array [0..40] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:ansistring;\n fi,fo:text;\nprocedure wr (x:int64);\n begin\n writeln (fo,x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then\n begin\n f:=1;break;\n end;\n if f=0 then\n ans:=(ans+1) ;\n end;\n vh:=ans ;\n end;\nprocedure xuli;\nbegin\n while not eof(fi) do\n begin\n f[1]:='a'; f[2]:='b';\n readln (fi,s);\n for i:=3 to 20 do f[i]:=f[i-1]+f[i-2];\n if n<=20 then\n begin\n wr(vh(s,f[n]));continue;\n end;\n ls:=length(s);\n fs[19]:=copy(f[19],1,ls-1);\n fs[20]:=copy(f[20],1,ls-1);\n fe[19]:=copy(f[19],length(f[19])-ls+2,ls-1);\n fe[20]:=copy(f[20],length(f[20])-ls+2,ls-1);\n fvh[19]:=vh(s,f[19]);\n fvh[20]:=vh(s,f[20]);\n for i:=21 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) ;\n end;\n wr(fvh[n]);\n end;\nend;\nbegin\n assign (fi,fin); reset(fi);\n assign (fo,fout); rewrite(fo);\n readln (fi,n,k);\n xuli;\n close(fi); close(fo);\nend."}, {"source_code": "const fin='';\nfout='';\nvar n:integer; s1,s2,s3,s:ansistring; ans2,ans1,ans3,k:longint;\nf,g:text;\nprocedure tim(l,r:longint; st:ansistring; var ans:longint);\nvar i,j,lc:longint;\nbegin\n for i:=l to r do\n begin\n lc:=0;\n for j:=i to i+length(s)-1 do\n if st[j]<>s[j-i+1] then\n begin\n lc:=1; break;\n end;\n if lc=0 then inc(ans);\n end;\nend;\nprocedure xuli;\nvar i,j,l1,r1:longint;\nbegin\n ans1:=0; ans2:=0;\n tim(1,length(s1)-length(s)+1,s1,ans1);\n tim(1,length(s2)-length(s)+1,s2,ans2);\n ans3:=ans2+ans1;\n for i:=3 to n do\n begin\n s3:=s2+s1; ans3:=ans2+ans1;\n if length(s2)0) and (r1>0) and (length(s)>1) then tim(l1,r1,s3,ans3);\n s1:=s2; s2:=s3;\n ans1:=ans2; ans2:=ans3;\n end;\n writeln(g,ans3);\nend;\nbegin\nassign(f,fin);reset(f);\nassign(G,fout);rewrite(g);\nreadln(f,n,k);\nwhile not eof(f) do\nbegin\nreadln(f,s);\ns1:='a'; s2:='b';\nxuli;\nend;\nclose(f); close(g);\nend."}, {"source_code": "var f:array [0..4000] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:string;\nprocedure wr (x:int64);\n begin\n writeln (x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then begin f:=1;break;end;\n if f=0 then ans:=ans+1;\n end;\n vh:=ans mod 1000000007;\n end;\n\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output);}\nreadln (n,k);\nfor ii:=1 to k do\nbegin\nreadln (s);\nf[1]:='a';\nf[2]:='b';\nfor i:=3 to 12 do f[i]:=f[i-1]+f[i-2];\nif n<=12 then begin wr(vh(s,f[n]));continue;end;\nls:=length(s);\nfs[11]:=copy(f[11],1,ls-1);\nfs[12]:=copy(f[12],1,ls-1);\nfe[11]:=copy(f[11],length(f[11])-ls+2,ls-1);\nfe[12]:=copy(f[12],length(f[12])-ls+2,ls-1);\nfvh[11]:=vh(s,f[11]);\nfvh[12]:=vh(s,f[12]);\nfor i:=13 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) mod 1000000007;\n end;\nwr(fvh[n]);\nend;\nend.\n"}, {"source_code": "var f:array [0..4000] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:string;\nprocedure wr (x:int64);\n begin\n writeln (x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then begin f:=1;break;end;\n if f=0 then ans:=ans+1;\n end;\n vh:=ans mod 1000000007;\n end;\n\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (n,k);\nfor ii:=1 to k do\nbegin\nreadln (s);\nf[1]:='A';\nf[2]:='B';\nfor i:=3 to 12 do f[i]:=f[i-1]+f[i-2];\nif n<=12 then begin wr(vh(s,f[n]));continue;end;\nls:=length(s);\nfs[11]:=copy(f[11],1,ls-1);\nfs[12]:=copy(f[12],1,ls-1);\nfe[11]:=copy(f[11],length(f[11])-ls+2,ls-1);\nfe[12]:=copy(f[12],length(f[12])-ls+2,ls-1);\nfvh[11]:=vh(s,f[11]);\nfvh[12]:=vh(s,f[12]);\nfor i:=13 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) mod 1000000007;\n end;\nwr(fvh[n]);\nend;\nend.\n"}, {"source_code": "var f:array [0..4000] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:ansistring;\nprocedure wr (x:int64);\n begin\n writeln (x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then begin f:=1;break;end;\n if f=0 then ans:=ans+1;\n end;\n vh:=ans mod 1000000007;\n end;\n\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output);}\nreadln (n,k);\nfor ii:=1 to k do\nbegin\nreadln (s);\nf[1]:='a';\nf[2]:='b';\nfor i:=3 to 12 do f[i]:=f[i-1]+f[i-2];\nif n<=12 then begin wr(vh(s,f[n]));continue;end;\nls:=length(s);\nfs[11]:=copy(f[11],1,ls-1);\nfs[12]:=copy(f[12],1,ls-1);\nfe[11]:=copy(f[11],length(f[11])-ls+2,ls-1);\nfe[12]:=copy(f[12],length(f[12])-ls+2,ls-1);\nfvh[11]:=vh(s,f[11]);\nfvh[12]:=vh(s,f[12]);\nfor i:=13 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) mod 1000000007;\n end;\nwr(fvh[n]);\nend;\nend.\n"}, {"source_code": "uses math;\nconst md=1000000009;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],1,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);\n for i:=5 to n do\n begin\n ss:='';\n for j:=max(1,length(f[i-1])-length(s)+2) to length(f[i-1]) do\n ss:=ss+f[i-1][j];\n for j:=1 to min(length(f[i-2]),length(s)-1) do\n ss:=ss+f[i-2][j];\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "uses math;\nconst md=1000000009;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m,l:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n{ assign(input,'input.txt');\n reset(input); }\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],1,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n l:=length(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n { c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);}\n for i:=3 to n do\n begin\n ss:='';\n if length(f[i-1])>=l then\n s1:=copy(f[i-1],length(f[i-1])-(l-1)+1,l-1)\n else s1:=f[i-1];\n if length(f[i-2])>=l then\n s2:=copy(f[i-2],1,l-1)\n else s2:=f[i-2];\n ss:=s1+s2;\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "uses math;\nconst md=1000000009;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m,l:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n { assign(input,'input.txt');\n reset(input);}\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],1,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n l:=length(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);\n for i:=5 to n do\n begin\n ss:='';\n if length(f[i-1])>=l then\n s1:=copy(f[i-1],length(f[i-1])-(l-1)+1,l-1)\n else s1:=f[i-1];\n if length(f[i-2])>=l then\n s2:=copy(f[i-2],1,l-1)\n else s2:=f[i-2];\n ss:=s1+s2;\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "uses math;\nconst md=1000000007;\nVar c:array[0..3003]of longint;\n f:array[0..3003]of ansistring;\n p:array[0..10333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m,l:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n{ assign(input,'input.txt');\n reset(input); }\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>3000 then s1:=copy(f[i-1],1,3000)\n else s1:=f[i-1];\n if length(f[i-2])>3000 then s2:=copy(f[i-2],1,3000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n l:=length(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n { c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);}\n for i:=3 to n do\n begin\n ss:='';\n if length(f[i-1])>=l then\n s1:=copy(f[i-1],length(f[i-1])-(l-1)+1,l-1)\n else s1:=f[i-1];\n if length(f[i-2])>=l then\n s2:=copy(f[i-2],1,l-1)\n else s2:=f[i-2];\n ss:=s1+s2;\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "uses math;\nconst md=1000000009;\nVar c:array[0..5003]of longint;\n f:array[0..5003]of ansistring;\n p:array[0..15333]of longint;\n s1,sss,s2,s,ss:ansistring;\n i,j,u,n,m:longint;\n function count(var s,ss:ansistring):longint;\n var i,j,res:longint;\n begin\n sss:=s+'$'+ss;\n p[1]:=0;\n res:=0;\n for i:=2 to length(sss) do\n begin\n j:=p[i-1];\n while (j>0)and(sss[j+1]<>sss[i]) do j:=p[j];\n if sss[j+1]=sss[i] then j:=j+1;\n p[i]:=j;\n if p[i]=length(s) then res:=res+1;\n end;\n count:=res;\n end;\n begin\n readln(n,m);\n f[1]:='a';\n f[2]:='b';\n for i:=3 to n do\n begin\n if length(f[i-1])>5000 then s1:=copy(f[i-1],1,5000)\n else s1:=f[i-1];\n if length(f[i-2])>5000 then s2:=copy(f[i-2],1,5000)\n else s2:=f[i-2];\n f[i]:=s1+s2;\n end;\n for u:=1 to m do\n begin\n readln(s);\n fillchar(c,sizeof(c),0);\n c[1]:=count(s,f[1]);\n c[2]:=count(s,f[2]);\n c[3]:=count(s,f[3]);\n c[4]:=count(s,f[4]);\n for i:=5 to n do\n begin\n ss:='';\n for j:=max(1,length(f[i-1])-length(s)+2) to length(f[i-1]) do\n ss:=ss+f[i-1][j];\n for j:=1 to min(length(f[i-2]),length(s)-1) do\n ss:=ss+f[i-2][j];\n c[i]:=(c[i-1]+c[i-2]+count(s,ss)) mod md;\n end;\n Writeln(c[n]);\n end;\n end."}, {"source_code": "const md = 1000000007;\nvar\nans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\npp:array[0..200000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar cc,i,j,k:longint;\n begin\n if c<0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p4;\n e[1,2]:=p3;\n e[1,3]:=p2;\n e[1,4]:=p1;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n { for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end; }\n\n if odd(cc) then find:=x[1,2] else\n find:=x[1,1];\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=2 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,0,1));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=count;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n j:=t+3;\n p4:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,0,1);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const md = 1000000007;\nvar\nio,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\nans,pp:array[0..200000]of longint;\nf:array[0..10000]of ansistring;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=2 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ s:='a';\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 27 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n p:=0;\n for j:=1 to 27 do\n begin\n if length(s[j])>length(s)*4 then break;\n\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=count;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n j:=t+3;\n p4:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n\n if (p1<>p2)and(s<>'a') then\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n\n // 1 1 1 1 1\n end else\n if (p1+p2=p3)or(s='a') then\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n\n // 0 0 0 0 0 0\n end else\n begin\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n\n // 1 0 1 0 1 0 1\n end;\n writeln(ans[k]);\n end;\n end."}, {"source_code": "const md = 1000000007;\nvar\nans,io,p4,p3,p1,p2,t,p,j,i,m:longint;\nw,s:ansistring;\nk:int64;\npp:array[0..200000]of longint;\nf:array[0..10000]of ansistring;\nx,e,ed:array[0..6,0..6]of int64;\n\nfunction find(p1,p2,p3,p4:longint;c:int64;r1,r2:longint):longint;\nvar cc,i,j,k:longint;\n begin\n if c<0 then\n begin\n find:=0;\n exit;\n end;\n if c=1 then\n begin\n find:=p1;\n exit;\n end;\n if c=2 then\n begin\n find:=p2;\n exit;\n end;\n if c=3 then\n begin\n find:=p3;\n exit;\n end;\n if c=4 then\n begin\n find:=p4;\n exit;\n end;\n\n cc:=c;\n\n c:=(c-4+1)div 2+1;\n\n fillchar(x,sizeof(x),0);\n x[1,1]:=2;x[1,2]:=1;x[1,3]:=1;\n x[2,1]:=1;x[2,2]:=1;x[2,4]:=1;\n x[5,1]:=1;x[5,5]:=1;\n x[6,1]:=1;x[6,2]:=1;x[6,6]:=1;\n fillchar(ed,sizeof(ed),0);\n for i:=1 to 6 do\n ed[i,i]:=1;\n\n while c>0 do\n begin\n if c mod 2=1 then\n begin\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+ed[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n ed[i,j]:=e[i,j];\n end;\n\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n e[i,j]:=0;\n for k:=1 to 6 do\n e[i,j]:=(e[i,j]+x[i,k]*x[k,j])mod md;\n end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n x[i,j]:=e[i,j];\n\n\n c:=c div 2;\n end;\n\n fillchar(e,sizeof(e),0);\n e[1,1]:=p1;\n e[1,2]:=p2;\n e[1,3]:=p3;\n e[1,4]:=p4;\n e[1,5]:=r1;\n e[1,6]:=r2;\n\n fillchar(x,sizeof(x),0);\n\n for i:=1 to 1 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n x[i,j]:=(x[i,j]+e[i,k]*ed[k,j])mod md;\n\n// for i:=1 to 6 do write(x[1,i],' ');writeln;\n\n{ for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n write(ed[i,j],' ');\n writeln;\n end;}\n\n if odd(cc) then find:=x[1,2] else\n find:=x[1,1];\n end;\n\nfunction count:longint;\nvar tt,i:longint;\n begin\n w:=s+'#'+f[j];\n tt:=0;\n pp[1]:=0;\n for i:=2 to length(w) do\n begin\n pp[i]:=pp[i-1];\n while (w[pp[i]+1]<>w[i])and(pp[i]>0) do pp[i]:=pp[pp[i]];\n\n if w[pp[i]+1]=w[i] then inc(pp[i]);\n\n if pp[i]=length(s) then tt:=tt+1;\n end;\n count:=tt;\n end;\n\n begin\n f[1]:='a';\n f[2]:='b';\n for i:=3 to 30 do\n f[i]:=f[i-1]+f[i-2];\n\n{ readln(s);\n p1:=0;\n p2:=0;\n p3:=0;\n for j:=1 to 22 do\n begin\n p3:=p2;\n p2:=p1;\n p1:=count;\n writeln(j,' ',p1,' ',p1-p2-p3);\n end;\n halt(0);\n }\n // readln(k);\n// writeln(find(1,1,3,4,k,1,0));halt(0);\n readln(k,m);\n for io:=1 to m do\n begin\n readln(s);\n p:=0;\n for j:=1 to 27 do\n begin\n if length(f[j])>length(s)*4 then break;\n\n if length(s)<=length(f[j]) then\n begin\n p:=count;\n t:=j;\n if p>0 then break;\n end;\n end;\n\n if p = 0 then\n begin\n writeln(0);\n continue;\n end;\n\n j:=t;\n p1:=count;\n\n j:=t+1;\n p2:=count;\n\n j:=t+2;\n p3:=count;\n\n j:=t+3;\n p4:=count;\n\n // writeln(t,' ',p1,' ',p2,' ',p3,' ',p4);\n if s='a' then\n begin\n if k=1 then ans:=1 else\n if k=2 then ans:=0 else\n ans:=find(1,1,2,3,k-2,0,0);\n end else\n if (p1<>p2)and(s<>'a') then\n begin\n {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,1,1);\n // 1 1 1 1 1\n end else\n if (p1+p2=p3) then\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,0,0);\n // 0 0 0 0 0 0\n end else\n begin {\n ans[t]:=p1;\n ans[t+1]:=p2;\n ans[t+2]:=p3;\n\n for i:=t+3 to k do\n begin\n if odd(i) = odd(t) then\n ans[i]:=(ans[i-1]+ans[i-2]+1)mod md else\n ans[i]:=(ans[i-1]+ans[i-2])mod md;\n end;\n }\n\n ans:=find(p1,p2,p3,p4,k-t+1,1,0);\n // 1 0 1 0 1 0 1\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const fin='';\n fout='';\nvar f:array [0..40] of ansistring;\n fs,fe:array [0..4000] of ansistring;\n fvh:array [0..4000] of int64;\n ls,n,i,ii,k:longint; s:ansistring;\n fi,fo:text;\nprocedure wr (x:int64);\n begin\n writeln (fo,x);\n end;\nfunction vh (s,ss:ansistring):int64;\nvar i,j,f:longint;ans:int64;\n begin\n ans:=0;\n for i:=1 to length(ss)-length(s)+1 do\n begin\n f:=0;\n for j:=1 to length(s) do\n if ss[i+j-1]<>s[j] then\n begin\n f:=1;break;\n end;\n if f=0 then\n ans:=(ans+1) ;\n end;\n vh:=ans ;\n end;\nprocedure xuli;\nbegin\n while not eof(fi) do\n begin\n f[1]:='a'; f[2]:='b';\n readln (fi,s);\n for i:=3 to 20 do f[i]:=f[i-1]+f[i-2];\n if n<=20 then\n begin\n wr(vh(s,f[n]));continue;\n end;\n ls:=length(s);\n fs[19]:=copy(f[19],1,ls-1);\n fs[20]:=copy(f[20],1,ls-1);\n fe[19]:=copy(f[19],length(f[19])-ls+2,ls-1);\n fe[20]:=copy(f[20],length(f[20])-ls+2,ls-1);\n fvh[19]:=vh(s,f[19]);\n fvh[20]:=vh(s,f[20]);\n for i:=21 to n do\n begin\n fs[i]:=fs[i-1];\n fe[i]:=fe[i-2];\n fvh[i]:=(fvh[i-1]+fvh[i-2]+vh(s,fe[i-1]+fs[i-2])) ;\n end;\n wr(fvh[n]);\n end;\nend;\nbegin\n assign (fi,fin); reset(fi);\n assign (fo,fout); rewrite(fo);\n readln (fi,n,k);\n xuli;\n close(fi); close(fo);\nend."}], "src_uid": "8983915e904ba763d893d56e94d9f7f0"} {"source_code": "program HelloWorld;\nvar x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if x> y then etag:=x-y else etag:=y-x;\n if x> z then etagl:=x-z else etagl:=z-x;\n tpod:=t3*3+t2*(etagl+etag);\n tles:=t1*etag;\n if tpod <= tles then write('YES')else write('NO');\n end.", "positive_code": [{"source_code": "\nvar x,y,z,t1,t2,t3:integer;\n begin\n readln(x,y,z,t1,t2,t3);\n if ((abs(y-x)+abs(x-z))*t2+3*t3)>(abs(y-x)*t1) then\n writeln('no')\n else\n writeln('yes');\n end."}, {"source_code": "var\n x, y, z, t1, t2, t3, h, d: integer;\n\n\nbegin\n readln(x, y, z, t1, t2, t3);// номер этажа, на котором находится Маша, номер\n //этажа, на который хочет попасть Маша, номер этажа, на котором находится лифт,\n //время, за которое Маша проходит между соседними этажами по лестнице, время,\n //за которое лифт проезжает между этажами и время, за которое открываются и \n //закрываются двери у лифта, соответственно.\n \n \n if x > y then\n h := (x - y) * t1\n else\n h := (y - x) * t1;\n \n if x > y then\n if x >= z then\n d := (x - z) * t2 + t3 + t3 + (x - y) * t2 + t3\n else\n d := (z - x) * t2 + t3 + t3 + (x - y) * t2 + t3;\n \n if x < y then\n if x >= z then\n d := (x - z) * t2 + t3 + t3 + (y - x) * t2 + t3\n else\n d := (z - x) * t2 + t3 + t3 + (y - x) * t2 + t3;\n \n if d <= h then writeln('YES')\n else\n writeln('NO');\n \n \n \n \nend."}, {"source_code": "program xxx;\nvar x,y,z,t1,t2,t3,v1,v2:integer;\n\nbegin\n\nread(x,y,z,t1,t2,t3);\n\nv1:=abs(z-x)*t2+abs(y-x)*t2+3*t3;\nv2:=abs(y-x)*t1;\n\nif v1>v2 then\n\nwriteln('NO')\n\nelse\n\nwriteln('YES');\n\n\nend."}, {"source_code": "var \n x, y, z, t1, t2, t3, tl, tp: integer;\nbegin\n read(x, y, z, t1, t2, t3);\n tl := abs((x - z))*t2 + t3 + t3 + abs((x - y))*t2 + t3;\n tp := abs((x - y))*t1;\n if tl <= tp then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "program gg;\nvar x,y,z,t1,t2,t3:int64;\nbegin\nread(x,y,z,t1,t2,t3);\nif abs(y-x)*t1 < ((abs(y-x)+abs(x-z))*t2+t3*3) then\nwrite('NO')\nelse\nwrite('YES');\nend."}, {"source_code": "Var x,y,z,t1,t2,t3,time1,time2:integer;\nBegin\nRead(x,y,z,t1,t2,t3);\ntime1:=abs(y-x)*t1;\ntime2:=((abs(z-x))*t2)+((abs(y-x))*t2)+(t3*3);\nIf time1>=time2 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "Var\n x, y, z, t1, t2, t3: LongInt;\n \nBegin\n Read(x, y, z, t1, t2, t3);\n If (abs(x - y))*t1 < (abs(x - z) + abs(y - x))*t2 + 3*t3 then\n Write('NO')\n Else\n Write('YES')\nEnd."}, {"source_code": "var\nx,y,z,t1,t2,t3,p,l:integer;\nbegin\nreadln(x,y,z,t1,t2,t3);\np:=abs(x-y)*t1;\nl:=abs(x-z)*t2+abs(x-y)*t2+3*t3;\nif p y then\n l := t1 * (x - y)\n else\n l := t1 * (y - x);\n if z > x then\n lu := t2 * (z - x) + t3 * 3\n else\n lu := t2 * (x - z) + t3 * 3;\n if x > y then\n lu := lu + t2 * (x - y)\n else\n lu := lu + t2 * (y - x);\n if lu > l then\n write('NO')\n else\n write('YES')\nend."}, {"source_code": "program nA;\nvar\n x,y,z,t1,t2,t3,t4,a,b,c,d:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n a:=abs(z-x);\n t4:=t2*a;\n b:=abs(x-y);\n c:=3*t3+t2*b+t4;\n d:=b*t1;\n if c>d then\n write('NO')\n else\n write('YES');\nend."}, {"source_code": "var x, y, z, t1, t2, t3:integer;\n\nbegin\n readln(x, y, z, t1, t2, t3);\n if (abs(z-x))*t2+3*t3+(abs(y-x))*t2 <= (abs(y-x))*t1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "var x,y,z,t1,t2,t3,ph,pzd:integer;\n \nbegin\n readln(x,y,z,t1,t2,t3);\n ph:=abs(x-y)*t1;\n pzd:=((abs(x-z)*t2)+t3)+(t2*abs(x-y)+t3)+t3;\n if ph=pzd then write('YES') else\n if pzd1000) do\n readln(x);\n while (y<1) and (y>1000) do\n readln(y);\n while x=y do\n readln(x,y);\n while (z<1) and (z>1000) do\n readln(z);\n while (t1<1) and (t1>1000) do\n readln(t1);\n while (t2<1) and (t2>1000) do\n readln(t2);\n while (t3<1) and (t3>1000) do\n readln(t3);\n if x>y then i:=x-y \n else i:=y-x;\n if x>z then m:=x-z\n else m:=z-x;\n g:=m*t2;\n a:=i*t1;\n k:=t3*3;\n j:=i*t2;\n n:=k+j+g;\n if aa then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc] x then kq2:=abs(z-x)*t2+2*t3\n else\n kq2:=2*t3;\n kq2:=kq2+abs(x-y)*t2+t3;\n if kq1 < kq2 then writeln('NO')\n else writeln('YES');\n readln;\nend."}, {"source_code": "Program ElevatororStairs;\nuses math;\nvar x,y,z,t1,t2,t3:integer; d1,d2:int64;\nbegin //assign(input,'1054A.inp'); reset(input);\n //assign(output,'1054A.out'); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n d1:=abs(x-y)*t1; d2:=(abs(x-y)+abs(x-z))*t2+3*t3;\n if d1>=d2 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend.\n"}, {"source_code": "Program ElevatororStairs;\nuses math;\nvar x,y,z,t1,t2,t3:integer; d1,d2:int64;\nbegin //assign(input,'1054A.inp'); reset(input);\n //assign(output,'1054A.out'); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n d1:=abs(x-y)*t1; d2:=(abs(x-y)+abs(x-z))*t2+3*t3;\n if d1>=d2 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "var\n x, y, z, t1, t2, t3: integer;\n d_et, t_lestn, t_lift:integer;\n\nbegin\n readln(x, y, z, t1, t2, t3);\n d_et:=abs(x-y);\n t_lestn:=d_et*t1;\n t_lift:=t3*3+abs(z-x)*t2+d_et*t2;\n if t_lift<=t_lestn then writeln('YES') else writeln('NO');\nend."}, {"source_code": "uses math;\nconst fi='1054A.INP'; fo='1054A.out';\nvar res1,res2,x,y,z,t1,t2,t3: longint;\nbegin\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n res1:=t1*abs(x-y);\n res2:=abs(x-z)*t2+3*t3+t2*abs(x-y);\n if res1=ans1 then writeln('YES')\nelse\nwriteln('NO');\nend.\n"}, {"source_code": "uses math;\nvar res1,res2,x,y,z,t1,t2,t3: longint;\nbegin\n readln(x,y,z,t1,t2,t3);\n res1:=t1*abs(x-y);\n res2:=abs(x-z)*t2+3*t3+t2*abs(x-y);\n if res1=elevator then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "Program Elevator;\nVar\n\tx, y, z, t1, t2, t3: integer;\n\teTime, sTime: integer;\n \nBegin\n Readln(x, y, z, t1, t2, t3);\n\n eTime := Abs(z-x)*t2 + t3 + t3 + Abs(y-x)*t2 + t3;\n sTime := Abs(y-x)*t1;\n\n If (eTime > sTime) then\n \tWriteln('NO')\n Else\n \tWriteln('YES');\n\nEnd.\n"}, {"source_code": "Var x , y , z , t1 , t2 , t3 , tmp , tam : Longint;\nBegin\nReadln(x , y , z , t1 , t2 , t3);\ntam := abs(x - y) * t1;\ntmp := abs(x - z) * t2 + 3 * t3 + abs(x - y) * t2;\nIf tam < tmp then Writeln('NO') else Writeln('YES');\nEnd."}, {"source_code": "var x,y,z,t1,t2,t3:int64;\nbegin\nread (x,y,z,t1,t2,t3);\nif ((abs(x-y)+abs(x-z))*t2+t3*3)<=abs(x-y)*t1\nthen writeln ('YES')\nelse writeln ('NO');\nend."}, {"source_code": "var d,e,f,z,x,y,a,b,c,t1,t2,t3: integer;\nbegin\n read(a,b,c,t1,t2,t3);\n d:=abs(c-a)*t2+abs(a-b)*t2+3*t3;\n e:=abs(a-b)*t1;\n if (abs(c-a)*t2+abs(a-b)*t2+3*t3)<=(abs(a-b)*t1) then\n writeln('yes')\n else\n writeln('no');\nend."}, {"source_code": "var\n\tx, y, z, t1, t2, t3, lift, stairs: integer;\n\ts: string;\n\t\nbegin\n\n\treadln(x, y, z, t1, t2, t3);\n\tlift := (abs(z - x)) * t2 + 2 * t3 + (abs(y - x)) * t2 + t3;\n\tstairs := t1 * (abs(x - y));\n\t\n\tif (lift <= stairs) then\n\t\twriteln('YES')\n\telse \n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var\n a, b, c, d, e, f, g, h, i, j, k, r, l, fl: int64;\n arr: array [-1000..200000] of int64;\n ar: array [-1000..200000] of int64;\n arrr: array [1..200000] of int64;\n kol: double;\n s, s1, s2: string;\n\n\n\n\nbegin\n readln(a, b, c ,d ,e ,f);\n if abs (a-b)*d<(abs(a-c)+abs(a-b))*e+3*f then write ('NO')\n else\n write ('YES');\nend."}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); // Этаж маши\nread(y); // этаж егора\nread(z); // этаж лифта\nread(t1); // скорость маша\nread(t2); // скорость лифта\nread(t3); // двери лифта\n\n\nif abs(x-y)*t1 >= abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');\n\nend."}], "negative_code": [{"source_code": "var x,y,z,t1,t2,t3,kq1,kq2:longint;\nbegin\n readln(x,y,z,t1,t2,t3);\n kq1:=abs(x-y)*t1;\n if z <> x then kq2:=abs(z-x)*t2+2\n else\n kq2:=2;\n kq2:=kq2+abs(x-y)*t2+1;\n if kq1 < kq2 then writeln('NO')\n else writeln('YES');\n readln;\nend."}, {"source_code": "var x,y,z,t1,t2,t3,kq1,kq2:longint;\nbegin\n readln(x,y,z,t1,t2,t3);\n kq1:=abs(x-y)*t1;\n if z <> x then kq2:=abs(z-x)*t2+2*t3\n else\n kq2:=2;\n kq2:=kq2+abs(x-y)*t2+t3;\n if kq1 < kq2 then writeln('NO')\n else writeln('YES');\n readln;\nend."}, {"source_code": "Program ElevatororStairs;\nuses math;\nvar x,y,z,t1,t2,t3:integer; d1,d2:int64;\nbegin //assign(input,'1054A.inp'); reset(input);\n //assign(output,'1054A.out'); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n d1:=abs(x-y)*t1; d2:=abs(2*x-y-z)*t2+3*t3;\n if d1>d2 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "Program ElevatororStairs;\nuses math;\nvar x,y,z,t1,t2,t3:integer; d1,d2:int64;\nbegin //assign(input,'1054A.inp'); reset(input);\n //assign(output,'1054A.out'); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n d1:=abs(x-y)*t1; d2:=(abs(x-y)+abs(x-z))*t2+3*t3;\n if d1>d2 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "Program ElevatororStairs;\nuses math;\nvar x,y,z,t1,t2,t3:integer; d1,d2:int64;\nbegin //assign(input,'1054A.inp'); reset(input);\n //assign(output,'1054A.out'); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n d1:=abs(x-y)*t1; d2:=abs(2*x-y-z)*t2+3*t3;\n if d1>=d2 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend.\n"}, {"source_code": "uses math;\nconst fi='1054A.INP'; fo='1054A.out';\nvar res1,res2,x,y,z,t1,t2,t3: longint;\nbegin\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n readln(x,y,z,t1,t2,t3);\n res1:=t1*abs(x-y);\n res2:=abs(x-z)+3*t3+t2*(x-y);\n if res1 z then\nt:=(x-z)*t2+2*t3;\n if x>y then \n t:=t+t2*(x-y)+t3;\n if xy then \n t:=t+t2*(x-y)+t3;\n \n if x tt then write('YES') \n else Write('NO');\n end.\n"}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); \nread(y); \nread(t1); \nread(t2); \nread(t3); \nread(z);\n\n\nif abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)+t3 then write('NO') else write('YES');\n\nend."}, {"source_code": "var x,y,z,t1,t2,t3,t,tt : integer;\nbegin\nread(x,y,z,t1,t2,t3);\n\n\nif x=z then \nt:= 2*t3+abs(x-y)*t2+t3;\n\nif x > z then\nt:=(x-z)*t2+2*t3;\n if x>y then \n t:=t+t2*(x-y)+t3;\n if xy then \n t:=t+t2*(x-y)+t3;\n if x t then write('NO') \n else Write('YES');\n end.\n"}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); \nread(y); \nread(t1); \nread(t2); \nread(t3); \nread(z);\n\n\nif abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)+t3 then write('YES') else write('NO');\n\nend."}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); // Этаж маши\nread(y); // этаж егора\nread(z); // этаж лифта\nread(t1); // скорость маша\nread(t2); // скорость лифта\nread(t3); // двери лифта\n\n\nif abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');\n\nend."}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); // Этаж маши\nread(y); // этаж егора\nread(t1); // скорость маша\nread(t2); // скорость лифта\nread(t3); // двери лифта\nread(z); // этаж лифта\n\nif abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');\n\nend."}, {"source_code": "var x,y,t1,t2,t3,z : integer;\nbegin\nread(x); // Этаж маши\nread(y); // этаж егора\nread(t1); // скорость маша\nread(t2); // скорость лифта\nread(t3); // двери лифта\nread(z); // этаж лифта\n\nif abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('NO') else write('YES');\n\nend."}, {"source_code": "program xxx;\nvar x,y,z,t1,t2,t3,v1,v2:integer;\n\nbegin\n\nread(x,y,z,t1,t2,t3);\n\nv1:=abs(z-x)*t2+abs(y-x)*t2+2*t3;\nv2:=abs(y-x)*t1;\n\nif v1>v2 then\n\nwriteln('NO')\n\nelse\n\nwriteln('YES');\n\n\nend."}, {"source_code": "var \n x, y, z, t1, t2, t3, tl, tp: integer;\nbegin\n read(x, y, z, t1, t2, t3);\n tl := abs((x - z))*t2 + t3 + abs((x - y))*t2 + t3;\n tp := abs((x - z))*t1;\n if tl <= tp then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "var \n x, y, z, t1, t2, t3, tl, tp: integer;\nbegin\n read(x, y, z, t1, t2, t3);\n tl := (x - z)*t2 + t3 + (x - y)*t2 + t3;\n tp := (x - z)*t1;\n if tl <= tp then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "var \n x, y, z, t1, t2, t3, tl, tp: integer;\nbegin\n read(x, y, z, t1, t2, t3);\n tl := abs((x - z))*t2 + t3 + abs((x - y))*t2 + t3;\n tp := abs((x - y))*t1;\n if tl <= tp then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "Var x,y,z,t1,t2,t3,k,s1,s2:int64;\nBegin\nRead(x,y,z,t1,t2,t3);\nk:=abs(y-x);\ns1:=k*t1;\ns2:=abs(z-x)*t2+k*t2+2*t3;\nIf (s1>=s2) then Writeln ('YES')\nelse Writeln ('NO');\nend."}, {"source_code": "Var x,y,z,t1,t2,t3,time1,time2:integer;\nBegin\nRead(x,y,z,t1,t2,t3);\ntime1:=abs(y-x)*t1;\ntime2:=((abs(z-x))*t2)+((abs(y-x))*t2)+(t3*3);\nIf time1>time2 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "Var\n x, y, z, t1, t2, t3: LongInt;\n \nBegin\n Read(x, y, z, t1, t2, t3);\n If (abs(x - y))*t1 <= (abs(x - z) + abs(y - x))*t2 + 3*t3 then\n Write('NO')\n Else\n Write('YES')\nEnd."}, {"source_code": "Var\n x, y, z, t1, t2, t3: UInt64;\n \nBegin\n Read(x, y, z, t1, t2, t3);\n If (abs(x - y))*t1 < (abs(x - z) + abs(y - x))*t2 + 2*t3 then\n Write('NO')\n Else\n Write('YES')\nEnd."}, {"source_code": "program nA;\nvar\n x,y,z,t1,t2,t3,t4,a,b,c,d:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if z <> x then\n begin\n a:=abs(z-x);\n t4:=t2*a;\n end;\n b:=abs(x-y);\n c:=4*t3+t2*b+t4;\n d:=b*t1;\n if c>d then\n write('NO')\n else\n write('YES');\nend."}, {"source_code": "program nA;\nvar\n x,y,z,t1,t2,t3,t4,a,b,c,d:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if z <> x then\n begin\n a:=abs(z-x);\n t4:=t2*a;\n end;\n b:=abs(x-y);\n c:=4*t3+t2*b+t4;\n d:=b*t1;\n if c>=d then\n write('NO')\n else\n write('YES');\nend."}, {"source_code": "program nA;\nvar\n x,y,z,t1,t2,t3,t4,a,b,c,d:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if z <> x then\n begin\n a:=abs(z-x);\n t4:=t2*a;\n end;\n b:=abs(x-y);\n c:=2*t3+t2*b+t4;\n d:=b*t1;\n if c>=d then\n write('NO')\n else\n write('YES');\nend."}, {"source_code": "var x, y, z, t1, t2, t3, out:integer;\n\nbegin\n readln(x, y, z, t1, t2, t3);\n if (abs(z-x))*t2+t3+(abs(y-x))*t2+t3 <= (abs(y-x))*t1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "Program p;\nvar x, y, z, t1, t2, t3, res: integer;\n\nbegin\nread(x, y, z, t1, t2, t3);\nres+=t3*2;\nres+=(abs(x-y)+abs(x-z))*t2;\nif res<=abs(x-y)*t1 then write('YES')\n else write('NO')\nend.\n"}, {"source_code": "Program p;\nvar x, y, z, t1, t2, t3: integer;\n\nbegin\nread(x, y, z, t1, t2, t3);\nif t3*2+(abs(x-y)+abs(x-z))*t2<=abs(x-y)*t1 then write('YES')\n else write('NO')\nend."}, {"source_code": "program HelloWorld;\nvar x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if x> y then etag:=x-y else etag:=y-x;\n if x> z then etagl:=x-z else etagl:=z-x;\n tpod:=t3*2+t2*(etagl+etag);\n tles:=t1*etag;\n if tpod <= tles then write('YES')else write('NO');\n end."}, {"source_code": "program HelloWorld;\nvar x,y,z,t1,t2,t3,tpod,tles,etag:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if x> y then etag:=x-y else etag:=y-x;\n tpod:=t3*2+t2*etag;\n tles:=t1*etag;\n if tles < tpod then write('NO')else write('YES');\n end."}, {"source_code": "program HelloWorld;\nvar x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;\nbegin\n read(x,y,z,t1,t2,t3);\n if x> y then etag:=x-y else etag:=y-x;\n if x> z then etagl:=x-z else etagl:=z-x;\n tpod:=t3*2+t2*(etagl+etag);\n tles:=t1*etag;\n if tles < tpod then write('NO')else write('YES');\n end."}, {"source_code": "var x,y,z,t1,t2,t3:integer;\nbegin\nreadln(x,y,z,t1,t2,t3);\nif (x>y) and (x>z) then begin\nif (((x-z)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1))\n or\n (((x-z)*t2+t3+t3+(x-y)*t2+t3)=((x-y)*t1))\n then writeln('YES') else writeln('NO');end;\n\nif (xz) then begin\nif (((x-z)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1))\n or\n (((x-z)*t2+t3+t3+(y-x)*t2+t3)=((y-x)*t1))\n then writeln('YES') else writeln('NO');end;\n\nif (x>y) and (xy) and (x>z) then begin\nif ((x-z)*t2+t3+t3+(x-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;\n\nif (xz) then begin\nif ((x-z)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;\n\nif (x>y) and (xy) and (x>z) then begin\nif ((x-z)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1) then writeln('YES') else writeln('NO');end;\n\nif (xz) then begin\nif ((x-z)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1) then writeln('YES') else writeln('NO');end;\n\nif (x>y) and (xy) and (x>z) then begin\nif ((x-z)*t2+t3+t3+(x-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;\n\nif (xz) then begin\nif ((x-z)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;\n\nif (x>y) and (x=le then write('yes') else write('no');\nend."}, {"source_code": "\nvar\n le,li,x,y,z,t1,t2,t3: integer;\nbegin\nread(x,y,z,t1,t2,t3);\nle:=t1*abs(x-y);\nli:=3*t3+t2*abs(z-x)+t2*abs(x-y);\nif li<=le then write('yes ',li,' ',le) else write('no ',li,' ',le);\nend.\n"}], "src_uid": "05cffd59b28b9e026ca3203718b2e6ca"} {"source_code": "var s:string;i,n,m,p,k,j,m1:integer;\nbegin readln(n);\nreadln(s);k:=0;i:=1;\nm:=0;p:=0;m1:=0;\ns:=s+' ';\nfor j:=1 to n do begin \nif s[j]='+' then k:=k+1 \n else k:=k-1;\nif k<0 then k:=k+1\n end; \n write(k)\n\n\n\nend.", "positive_code": [{"source_code": "var x:char;\nz,i,n:longint;\nbegin\nreadln(n);\nz:=0;\nfor i:=1 to n do\nbegin\nread(x);\nif (z=0) and (x='-') then z:=0;\nif (z>0) and (x='-') then dec(z);\nif x='+' then inc(z);\nend;\nif z<=0 then write(0) else write(z);\nend.\n"}, {"source_code": "Program Apileofstones;\nuses math;\nvar n,d:byte; i:longint; s:string;\nbegin //assign(input,'1159A.inp'); reset(input);\n //assign(output,'1159A.out'); rewrite(output);\n readln(n); readln(s);\n d:=0;\n for i:=1 to length(s) do\n if s[i]='+' then inc(d)\n else if d>=1 then dec(d);\n writeln(d);\n //close(input); close(output);\nend."}, {"source_code": "program a;\n\nvar\n n, min, sum : integer;\n s : string;\n c : char;\n\nbegin\n readln(n);\n readln(s);\n min := 0;\n sum := 0;\n for c in s do\n begin\n if c = '+' then\n inc (sum)\n else if c = '-' then\n dec(sum);\n if sum < min then\n min := sum;\n end;\n writeln(sum - min);\nend.\n"}, {"source_code": "var i,j,k,t:longint;\nvar a,b,c,d,e,sohieu,bd,kt,mi,m,c1,l1,c2,l2,ans,n,mints,maxts,tans:longint;\nvar ch:char;\nvar f1,f2:text;\nvar s:string;\nvar ar,er,gr,mr,lar,rar:array[1..200000] of longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n if(ch='-') and (ans=0)then continue;\n if(ch='-') and (ans>0)then ans:=ans-1;\n if(ch='+')then inc(ans);\n\n\n end;\n writeln(ans);\n\nend."}, {"source_code": "\nvar \n st:string;\n n1,n,i,max,j:longint;\nbegin\n\n readln(n);\n readln(st);\n\nmax:=maxlongint;\nfor j:= 0 to n do\nbegin\nn1:=j;\nfor i:= 1 to n do\n begin\n if st[i]='+' then if n10 then n1:=n1-1;\n end;\nif n1=1 then dec(bh);\nwriteln(bh);\nreadln;\nend.\n"}, {"source_code": "var c:char;\n n,i,j,k,p,a,b:longint;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nread(c);\nif (c='-') and (a<>0) then dec(a);\nif (c='+') then inc(a) end;\nwrite(k+a);\nend.\n"}, {"source_code": "var i, n, o, stones, kt: longint;\n check: boolean;\n s: string;\n f1, f2: text;\nconst fi = '';\n fo = '';\n{=================================================}\nprocedure Input;\nbegin\n assign(f1, fi); reset(f1);\n readln(f1, n);\n readln(f1, s);\n close(f1);\nend;\n{=================================================}\nprocedure Output;\nbegin\n assign(f2, fo); rewrite(f2);\n check := false;\n while (check = false) do\n begin\n if (kt = 1) then inc(o);\n kt := 0;\n stones := o;\n for i := 1 to n do\n begin\n if (s[i] = '+') then inc(stones)\n else dec(stones);\n if (stones < 0) then\n begin\n kt := 1;\n break;\n end;\n end;\n if (kt = 0) then check := true;\n end;\n writeln(f2, stones);\n close(f2);\nend;\n{=================================================}\nbegin\n Input;\n Output;\nend.\n{=================================================}\n"}, {"source_code": "var\n s : string;\n n,i,ans : longint;\nbegin\n readln(n);\n readln(s);\n for i := 1 to length(s) do\n if (s[i] = '-') and (ans > 0) then\n dec(ans)\n else if (s[i] = '+') then\n inc(ans);\n writeln(ans);\nend."}, {"source_code": "program Project1;\nvar n,br:longint;\na:char;\nbegin\n br:=0;\n readln(n);\n while n>0 do\nbegin\n read(a);\n if (a='-') and (br>0) then\n begin\n br:=br-1;\n end;\n if (a='+') then\n begin\n br:=br+1;\n end;\n n:=n-1;\nend;\nwriteln(br);\nreadln;\nend. "}, {"source_code": "uses math;\nvar\n n, i, cur, stones : longint;\n s : ansistring;\n \nbegin\n readln(n); readln(s);\n i := 1;\n stones := 0; cur := 0;\n for i := 1 to n do\n begin\n if (s[i] = '+') then inc(cur) else dec(cur);\n stones := max(stones, max(0, -cur)); \n end;\n for i := 1 to n do\n if (s[i] = '+') then inc(stones) else dec(stones);\n writeln(stones);\nend."}, {"source_code": "var n,i,aux:longint;\n s:ansistring;\nbegin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n if (s[i]='+') then inc(aux)\n else if (s[i]='-') and (aux>0) then dec(aux);\n writeln(aux);\nend."}, {"source_code": "const\n sz=1000;\nvar\n i:longint;\n ans, k, n:int64;\n s:ansistring;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n if s[i]='+' then inc(k)\n else\n if k<>0 then dec(k);\n writeln(k);\nend."}, {"source_code": "var \n s: string;\n n, i, j, k, c: longint;\n\nbegin\n readln(n);\n readln(s);\n k := 0; j := 0; c := 0;\n for i := 1 to n do if (s[i] = '-') then inc(c) else break;\n for i := 1 to n do \n begin\n if (s[i] = '-') then c := c - 1 else inc(c);\n if (c < 0) then inc(c);\n end;\n write(c);\nend."}, {"source_code": "var n,i,x:integer;\n s:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do\n if (s[i]='-') and (x>0) then dec(x) else\n if s[i]='+' then inc(x);\nwriteln(x)\nend."}, {"source_code": "var n,x,i:integer;\n s:string;\n \nbegin\n readln(n);\n readln(s);\n \n for i:=1 to n do\n begin\n if s[i]='+' then x:=x+1\n else\n if x>0 then x:=x-1;\n end;\n writeln(x); \nend."}, {"source_code": "var \nn,pile,i:longint;\na:array[1..100] of char;\nbegin\n readln(n);\npile:=0;\nfor i:=1 to n do \nbegin\n read(a[i]);\nif a[i]='+' then inc(pile);\nif (a[i]='-') and (pile>0) then dec(pile);\nend;\nwriteln(pile);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,tg,mi:longint;\n begin\n mi:=0;\n readln(fi,n);\n readln(fi,st);\n tg:=0;\n for i:=1 to n do\n begin\n if st[i]='+' then inc(tg) else dec(tg);\n mi:=min(mi,tg);\n end;\n tg:=-mi;\n for i:=1 to n do if st[i]='+' then inc(tg) else dec(tg);\n write(fo,tg);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,i,d:integer;\n st:string;\n\nprocedure docf;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n read(f,st);\n close(f);\nend;\n\nprocedure ghif;\nbegin\n assign(f,fo);\n rewrite(f);\n d:=0;\n for i:= 1 to n do\n begin\n if st[i]='+' then inc(d) else dec(d);\n if d<0 then d:=0;\n end;\n write(f,d);\n close(f);\nend;\n\nbegin\n docf;\n ghif;\nend.\n"}, {"source_code": "uses math;\nvar a:longint;c:char;\nbegin\n readln;\n while not eoln do\n begin\n read(c);\n if c='+' then inc(a)\n else a:=max(0,a-1);\n end;\n writeln(a);\nend."}, {"source_code": "var mini, ans: longint;\n n, i: longint;\n c: char;\nbegin\n readln(n);\n for i := 1 to n do\n begin\n read(c);\n if c = '+' then ans := ans + 1\n else\n begin\n ans := ans - 1;\n if mini > ans then mini := ans;\n end;\n end;\n write(ans - mini);\nend."}, {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\ts: string;\n\tarr, arr1: array[0..100] of integer;\n\t\nbegin\n\t{$string_nullbased+}\n\t\n\treadln(n);\n\treadln(s);\n\tfor var i := 0 to s.length - 1 do\n\tbegin\n\t\tif (s[i] = '+') then\n\t\t\ta += 1\n\t\telse \n\t\t\tif (a > 0) then \n\t\t\t\ta -= 1;\n\tend;\n\t\n\twriteln(a);\n\t\nend.\n"}, {"source_code": "var\nn, x, i:integer;\ns:string;\n\nbegin\nreadln(n);\nreadln(s);\n\nfor i:=1 to n do\nif s[i]='+' then x:=x+1\nelse\nif x>0 then x:=x-1;\n\nwriteln(x);\n\nend."}, {"source_code": "var n,ans,i:integer;s:string;\nBegin\n readln(n);\n readln(s);\n ans:=0;\n for i:= 1 to n do\n begin\n if(s[i]='+') then\n inc(ans)\n else\n dec(ans);\n if (ans<0) then\n ans:=0;\n end;\n writeln(ans);\nend."}, {"source_code": "Var\n n, Ans: Integer;\n S: String;\n \nBegin\n Readln(n);\n Readln(S);\n For Var i := 1 to n do\n If S[i] = '+' then\n Ans += 1\n Else If (S[i] = '-') and (Ans > 0) then\n Ans -= 1;\n Write(Ans)\nEnd."}, {"source_code": "Program ILoveYou;\nVAR n,i,plus,minus,aux:int64; a:array[1..101] of char;\nBegin\n\nReadln(n);\nfor i:=1 to n do\nBegin\nRead(a[i]);\nend;\n\naux:=0;\nfor i:=1 to n do\nBegin\nif (a[i] = '-') then aux:=aux - 1 else aux:=aux + 1;\nif (aux < 0) then aux:=0;\nend;\n\nWriteln(aux);\n\nReadln;\nEND."}, {"source_code": "var\n n, i, b: integer;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n for i := 1 to length(s) do\n begin\n if s[i] = '-' then\n begin\n if b > 0 then\n b := b - 1\n else\n b := 0;\n end\n else\n b := b + 1;\n end;\n write(b);\nend."}, {"source_code": "var s:string;n,i,k:integer;\nbegin\nreadln(n);\nreadln(s);\nk:=0;\nfor i:=1 to n do\n if s[i]='+' then k:=k+1 else begin k:=k-1;\nif k<0 then k:=0;end;\nwrite(k);\nend.\n"}, {"source_code": "Var tmp , n , i , kq , j : Longint;\n s : string;\n kt : Boolean;\n A : Array [1..100] of Longint;\n\nBegin\nReadln(n); Readln(s); \nFor i := 1 to n do\n Begin\n If S[i] = '+' then Inc(A[i]) else Dec(A[i]);\n End;\nFor i := 0 to n do\n Begin\n kt := True; tmp := i;\n For j := 1 to n do\n Begin\n Inc(tmp , A[j]);\n If tmp < 0 then kt := False;\n If not kt then Break;\n End;\n If kt then Break;\n End;\nWrite(tmp);\nEnd."}, {"source_code": "program Project_A;\n\nvar\n n, i, ans: longint;\n c: char;\n\nbegin\n readln(n);\n ans := 0;\n for i := 1 to n do begin\n read(c);\n if c = '-' then\n dec(ans)\n else\n inc(ans);\n if ans < 0 then\n ans := 0;\n end;\n\n write(ans);\nend."}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..1200000+1] of int64; integer=longint;\nvar mask,ii,jj,i1,j1,ppp,tt,start,qq,kol1,dl,p0,stepp,h,n2,i,j,k,l,m,step,k1,w,mesto,num:longint;\nss,ss1:string;\np1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n nommaxpref,nommaxsuff,maxpref,maxsuff,nomsuff,llsuff,rrsuff,nompref,llpref,rrpref,ll,a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,rr,a,b,a1,b1:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zan:array[-10..1000000] of boolean;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,newpole1,pole1,pole:array[-100..1400,-1..1400] of char;\n pred,sled,poss,nabor:array[-10..29,-10..10000] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n kol,str,place,sum,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..1200000] of int64;\n dd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]p) then\n srav:=true else srav:=false; end;\n\nprocedure sl (k,l,m:integer); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;\nuntil (k>=n);\n\n\n\nend;\n\n\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\nfunction phi(a,b:double):double; label 222;var p:double;\nbegin\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\n\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin\n a:=abs(a); b:=abs(b);\n if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction nok(a,b:int64):int64;\nbegin nok:=(a*b) div nod(a,b); end;\n\n\n function degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nprocedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii]; end;\n\nfunction nomerr(gr:int64):int64;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=p; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]<=gr then aa:=cc else bb:=cc;\n\n end;\n { writeln(' cc= ',cc);\n } cc:=min(cc+3,p+1);\n repeat dec(cc) until y[cc]<=gr;\n if y[cc]=gr then fl:=true else fl:=false;\n { if fl then nomerr:=a1[cc] else nomerr:=-1000;}\n nomerr:=cc;\nend;\n\n function vhodit(t:int64):boolean;\nvar sum,ii,jj,p:int64; ans:boolean;\nbegin\n p:=t;\n for i:=1 to t do a[i]:=x[i];\n n:=1;\n repeat n:=n*2 until n>=p;\n for i:=p+1 to n+2 do a[i]:=besk;\n sort(a);\n { for i:=1 to p do write(a[i],' '); writeln;\n }\n sum:=0;\n if not odd(t) then\n for i:=1 to t div 2 do sum:=sum+a[2*i] else\n for i:=1 to (t+1) div 2 do sum:=sum+a[2*i-1];\n { writeln('sum= ',sum);\n }\n ans:=sum<=hh;\nvhodit:=ans;\nend;\n\nfunction maxdl(pos:longint):longint;\nvar ll,rr,i,j,poss,ot:longint;\nbegin\n\n\n maxdl:=ot;\nend;\n\n\nbegin\n\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n readln(n); readln(ss);\n for i:=1 to n do if ss[i]='+' then x[i]:=x[i-1]+1 else x[i]:=x[i-1]-1;\n\n p1:=10000000;\n p2:=-10000000;\n for i:=0 to n do p1:=min(p1,x[i]);\n for i:=0 to n do p2:=max(p2,x[i]);\n\n { writeln(p1,' ',p2,' ',x[n]-p1);\n } writeln(x[n]-p1);\n\n\n\n\n\n\n 1: close (output);\n end.\n\n\n"}, {"source_code": "program a___________________________________________code;\n\n{$APPTYPE CONSOLE}\n\n var i,j,n,res,km,kp,start,poch:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n km:=0;\n kp:=0;\n start:=0;\n for i:=1 to n do\n if s[i]='-' then inc(start) else break;\n poch:=i; // writeln('poch111=',poch); // readln;\n if poch>n then writeln(0) else\n begin\n km:=0;\n kp:=0; // writeln('start=',start); writeln('poch=',poch);\n while poch<=n do\n begin\n while s[poch]='+' do\n begin\n inc(kp);\n inc(poch)\n end; // writeln('kp=',kp); writeln('poch111=',poch); // readln;\n if poch>n then break;\n while s[poch]='-' do\n begin\n inc(km);\n inc(poch)\n end; // writeln('km=',km); writeln('poch=',poch);\n if km>kp then\n begin\n start:=start+abs(km-kp);\n kp:=0\n end else kp:=kp-km; // ;writeln('start=',start); writeln('poch=',poch);\n km:=0;\n if poch>n then break\n end; // writeln('start=',start);\n for i:=1 to n do\n if s[i]='-' then dec(start) else inc(start);\n writeln(start)\n end; readln\nend.\n\n\n\n"}], "negative_code": [{"source_code": "\nvar \n st:string;\n n1,n,i:longint;\nbegin\n\n readln(n);\n readln(st);\n\nn1:=n;\nfor i:= 1 to n do\n begin\n if st[i]='+' then if n10 then n1:=n1-1;\n end;\nwrite(n1);\n\nend.\n\n"}, {"source_code": "\nvar\n st:string;\n n1,n,i,max,j:longint;\nbegin\n\n readln(n);\n readln(st);\n\nmax:=maxlongint;\nfor j:= 1 to n do\nbegin\nn1:=j;\nfor i:= 1 to n do\n begin\n if st[i]='+' then if n10 then n1:=n1-1;\n end;\nif n1min) then writeln(pl-min)\n else if (pl=min) then writeln(pl)\n else if (pl j) then write(k-j) else write(0);\n \nend."}, {"source_code": "var \n s: string;\n n, i, j, k, c: longint;\n\nbegin\n readln(n);\n readln(s);\n k := 0;\n for i := 1 to n do if (s[i] = '-') then inc(c) else break;\n for i := 1 to n do \n if (s[i] = '-') then c := c - 1 else inc(c);\n if (c < 0) then write(0) else write(c);\nend."}, {"source_code": "var \n s: string;\n n, i, j, k, c: longint;\n\nbegin\n readln(n);\n readln(s);\n k := 0;\n for i := 1 to n do if (s[i] = '-') then inc(c) else break;\n for i := 1 to n do \n if (s[i] = '-') then c := c - 1 else inc(c);\n write(c);\nend."}, {"source_code": "var w,i,p,n:integer;\n a:array[1..10000] of char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]='+' then inc(p)\n end;\n if p>=(n-p) then\n begin\n w:=0;\n for i:=1 to n do\n begin\n if a[i]='+' then inc(w)\n else if w>0 then dec(w);\n end;\n write(w);\n halt;\n end\n else\n begin\n w:=n;\n for i:=1 to n do\n begin\n if a[i]='+' then inc(w)\n else if w>0 then dec(w);\n end;\n write(w);\n halt;\n end;\nend."}, {"source_code": "var w,i,p,n:integer;\n a:array[1..10000] of char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]='+' then inc(p)\n end;\n if p>(n-p) then\n begin\n w:=0;\n for i:=1 to n do\n begin\n if a[i]='+' then inc(w)\n else dec(w);\n end;\n write(w);\n halt;\n end\n else\n begin\n w:=n;\n for i:=1 to n do\n begin\n if a[i]='+' then inc(w)\n else dec(w);\n end;\n write(w);\n halt;\n end;\nend."}, {"source_code": "var s:string;i,n,m,p,k,j,m1:integer;\nbegin readln(n);\nreadln(s);k:=0;i:=1;\nm:=0;p:=0;m1:=0;\ns:=s+' ';\nfor j:=1 to n do begin \nif s[j]='+' then p:=p+1 \nelse m:=m+1;\n end; \nwhile s[i]='-' do begin k:=k+1; i:=i+1 end;\nwriteln(p,' ',m);\nif s[1]='-' then write(k+p)\nelse \nif p-m<0 then write(abs(p-m)) else write(p-m);\n\n\nend."}, {"source_code": "var s:string;i,n,m,p,k,j,m1:integer;\nbegin readln(n);\nreadln(s);k:=0;i:=1;\nm:=0;p:=0;m1:=0;\ns:=s+' ';\nfor j:=1 to n do begin \nif s[j]='+' then p:=p+1 \nelse m:=m+1;\n end; \nwhile s[i]='-' do begin k:=k+1; i:=i+1 end;\n\nif s[1]='-' then write(k+p)\nelse \nif p-m<0 then write(abs(p-m)) else write(p-m);\n\n\nend."}, {"source_code": "var s:string;i,n,m,p,k,j,m1:integer;\nbegin readln(n);\nreadln(s);k:=0;i:=1;\nm:=0;p:=0;m1:=0;\ns:=s+' ';\nfor j:=1 to n do begin \nif s[j]='+' then p:=p+1 \nelse m:=m+1;\n end; \nwhile s[i]='-' do begin k:=k+1; i:=i+1 end;\n\nif s[1]='-' then write(k+p-m)\nelse \nif p-m<0 then write(abs(p-m)) else write(p-m);\n\n\nend."}, {"source_code": "Program ILoveYou;\nVAR n,i,plus,minus,aux:int64; a:array[1..101] of char;\nBegin\n\nReadln(n);\nfor i:=1 to n do\nBegin\nRead(a[i]);\nend;\n\ni:=n;\nwhile (i > 0) and (a[i] <> '-') do\nBegin\ni:=i - 1;\nend;\n\naux:=i;\nfor i:=aux downto 1 do\nBegin\nif (a[i] = '-') then minus:=minus + 1 else plus:=plus + 1;\nend;\n\nif (minus > plus) then Writeln(n - aux) else Writeln(plus - minus + n - aux);\n\nReadln;\nEND."}, {"source_code": "Program ILoveYou;\nVAR n,i,plus,minus,aux:int64; a:array[1..101] of char;\nBegin\n\nReadln(n);\nfor i:=1 to n do\nBegin\nRead(a[i]);\nend;\n\ni:=1;\nwhile (i <= n) and (a[i] = '-') do\nBegin\ni:=i + 1;\nend;\n\naux:=i;\nfor i:=aux to n do\nBegin\nif (a[i] = '-') then minus:=minus + 1 else plus:=plus + 1;\nend;\n\nif (minus > plus) then Writeln('0') else Writeln(plus - minus);\n\nReadln;\nEND."}], "src_uid": "a593016e4992f695be7c7cd3c920d1ed"} {"source_code": "uses math;\nvar k,kq:qword;\n i:byte;\n st:string;\n\nbegin\n //Assign(input,'ds.inp'); reset(input);\n //Assign(output,'ds.out'); rewrite(output);\n read(k);\n if (k>9) then\n begin\n i:=1;\n while (k>9*i*10**(i-1)) do\n begin\n k:=k-9*i*10**(i-1); inc(i);\n end;\n kq:=k mod i;\n if (kq=0) then str(10**(i-1)+(k div i)-1,st)\n else str(10**(i-1)+(k div i),st);\n if (kq=0) then write(st[length(st)])\n else write(st[kq]);\n end\n else write(k);\nend.", "positive_code": [{"source_code": "program Youssef;\nuses wincrt;\nvar\n\nch1,ch:string;\nk,i:integer;\n\nbegin\nch1:='';\nreadln(k);\nfor i:=1 to k do\nbegin\nstr(i,ch);\nch1:=ch1+ch;\nend;\nwriteln(ch1[k])\t\nend."}, {"source_code": "uses math;\nconst fi='SOTHUK.INP';\n fo='SOTHUK.OUT';\nvar k,result : int64;\nprocedure inp;\nbegin\n // assign(input,fi);reset(input);\n readln(k);//close(input);\nend;\n\nprocedure main(k : int64);\nvar temp,mid,tt: int64;\na,b,t : int64;\nbegin\n temp := k*9 - 1;\n a := trunc(log10(temp));\n t := 1;\n repeat\n mid := (a+t) shr 1;\n tt := trunc(power(10,mid+1));\n b := 9*(mid-1) + 8;\n if power(10,mid)*b > temp then a := mid - 1 else\n if power(10,mid)*b<=temp then t := mid + 1;\n if (power(10,mid)*b > temp) and ((power(10,mid-1)*(9*(mid-2)+8)) < temp) then break;\n until t>a;\n a := a + 1;\n k := k - trunc((power(10,a-1)*(9*(a-2)+8)+1)/9);\n temp := k div a;\n if k mod a <> 0 then b := trunc(power(10,a-1)) + temp else b := trunc(power(10,a-1))+temp-1;\n k := k mod a;\n if k=0 then k := a;\n result := (b div trunc(power(10,a-k))) mod 10;\n\nend;\n\nprocedure out;\nbegin\n // assigN(output,fo);rewritE(output);\n writeln(result);\n close(output);\nend;\n\nbegin\n\n inp;\n main(k);\n out;\nend.\n"}, {"source_code": "var\n k,x,s,a,b,c:int64;\n i:longint;\nbegin\n readln(k);\n x:=9;s:=1;\n while k>0 do\n begin\n k:=k-x*s;\n x:=x*10;\n inc(s);\n end;\n x:=x div 10;dec(s);k:=k+x*s;\n a:=(k-1) div s;b:=(k-1) mod s+1;c:=1;\n for i:=1 to s-1 do c:=c*10;\n if b=0 then dec(a);c:=c+a;\n for i:=1 to s-b do c:=c div 10;\n writeln(c mod 10);\nend."}, {"source_code": "program pr1;\n var i,k,n:integer;\n x,a:string;\nbegin\n n:=10000;\n for i:=1 to n do\n begin\n str(i,a);\n x:=x+a;\n end;\n readln(k);\n writeln(x[k]);\n readln;\n\nend.\n\n"}, {"source_code": "var st,x :ansistring;\n i,k : longint;\nBEGIN\n read(k); st:='';\n for i:=1 to 100001 do\n begin\n str(i,x);\n st:=concat(st,x);\n end;\n write(st[k]);\nEND."}, {"source_code": "const s:ansistring='1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000';\nvar t:longint;\nbegin\n readln(t);\n writeln(s[t]);\nend."}, {"source_code": "//type ansistring = string;\nvar\n k, i: longint;\n posl, st: ansistring;\nbegin\n read(k);\n posl:='';\n i:=0;\n while length(posl)k1*i then n:=n-k1*i else\n begin\n if n mod i=0 then k:=k+n div i-1\n else k:=k+n div i;\n n:=n-n div i*i;\n if n=0 then n:=i;\n for j:=0 to i-n-1 do k:=k div 10;\n k:=k mod 10;\n write(k);\n break\n end;\n end;\n end;\n readln\nend.\n"}, {"source_code": "uses math;\nconst fi='SOTHUK.INP';\n fo='SOTHUK.OUT';\nvar k,result : int64;\nprocedure inp;\nbegin\n // assign(input,fi);reset(input);\n readln(k);//close(input);\nend;\n\nprocedure main(k : int64);\nvar temp,mid,tt: int64;\na,b,t : int64;\nbegin\n temp := k*9 - 1;\n a := trunc(log10(temp));\n t := 1;\n repeat\n mid := (a+t) shr 1;\n tt := trunc(power(10,mid+1));\n b := 9*(mid-1) + 8;\n if power(10,mid)*b > temp then a := mid - 1 else\n if power(10,mid)*b<=temp then t := mid + 1;\n if (power(10,mid)*b > temp) and ((power(10,mid-1)*(9*(mid-2)+8)) < temp) then break;\n until t>a;\n a := a + 1;\n k := k - trunc((power(10,a-1)*(9*(a-2)+8)+1)/9);\n temp := k div a;\n if k mod a <> 0 then b := trunc(power(10,a-1)) + temp else b := trunc(power(10,a-1))+temp-1;\n k := k mod a;\n if k=0 then k := a;\n result := (b div trunc(power(10,a-k))) mod 10;\n\nend;\n\nprocedure out;\nbegin\n // assigN(output,fo);rewritE(output);\n writeln(result);\n close(output);\nend;\n\nbegin\n\n inp;\n main(k);\n out;\nend.\n"}, {"source_code": "var\n k,x,s,a,b,c:int64;\n i:longint;\nbegin\n readln(k);\n x:=9;s:=1;\n while k>0 do\n begin\n k:=k-x*s;\n x:=x*10;\n inc(s);\n end;\n x:=x div 10;dec(s);k:=k+x*s;\n a:=(k-1) div s;b:=(k-1) mod s+1;c:=1;\n for i:=1 to s-1 do c:=c*10;\n if b=0 then dec(a);c:=c+a;\n for i:=1 to s-b do c:=c div 10;\n writeln(c mod 10);\nend."}, {"source_code": "var s : string;\n\nbegin\n var count: longint;\n read(count);\n for i: integer := 1 to count do s := s + i.ToString;\n \n write(s[count]);\nend."}, {"source_code": "uses math;\nvar k,kq:qword;\n i:byte;\n st:string;\n\nbegin\n //Assign(input,'ds.inp'); reset(input);\n //Assign(output,'ds.out'); rewrite(output);\n read(k);\n if (k>9) then\n begin\n i:=1;\n while (k>9*i*10**(i-1)) do\n begin\n k:=k-9*i*10**(i-1); inc(i);\n end;\n kq:=k mod i;\n if (kq=0) then str(10**(i-1)+(k div i)-1,st)\n else str(10**(i-1)+(k div i),st);\n if (kq=0) then write(st[length(st)])\n else write(st[kq]);\n end\n else write(k);\nend."}, {"source_code": "var\n k,x,s,a,b,c:int64;\n i:longint;\nbegin\n readln(k);\n x:=9;s:=1;\n while k>0 do\n begin\n k:=k-x*s;\n x:=x*10;\n inc(s);\n end;\n x:=x div 10;dec(s);k:=k+x*s;\n a:=(k-1) div s;b:=(k-1) mod s+1;c:=1;\n for i:=1 to s-1 do c:=c*10;\n if b=0 then dec(a);c:=c+a;\n for i:=1 to s-b do c:=c div 10;\n writeln(c mod 10);\nend."}, {"source_code": "var\n k, x, y: int64;\n\nfunction pow(x, y: int64): int64;\nvar\n i: longint;\n ans: int64;\nbegin\n ans := 1;\n for i := 1 to y do\n ans := ans * x;\n result := ans;\nend;\n\nbegin\n read(k);\n x := 9;\n y := 1;\n while k > x * y do begin\n k := k - x * y;\n x := x * 10; \n inc(y);\n end;\n x := (k - 1) div y + pow(10, y - 1);\n k := k - (x - pow(10, y - 1)) * y;\n write((x div pow(10, y - k)) mod 10);\nend."}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndl,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n pos,summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n razr,jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n poss:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]k*9*d do\n begin\n n:=n-k*9*d;\n inc(k);\n // d1:=d1*10;\n d:=d*10;\n end;\n i:=d;\n n:=n-1;\n i:=i+n div k;\n str(i,s);\n writeln(s[n mod k +1]);\n end;\nend."}, {"source_code": "program aziz;\nuses wincrt;\n var\nk:integer;\n procedure remplir(var k:integer);\n\t\tvar\n\t\ti:integer;\n\t\tx:integer;\n\t\tch1,ch:string;\n begin\nrepeat\nreadln(k);\nuntil (k>=1) and (k<=10000);\n\t\t\tch:='';\n\t\t\tfor i:=1 to k do\n\t\t\t\tbegin\n\t\t\t\tstr(i,ch1);\n\t\t\tch:=ch+ch1;\n end;\nval(ch[k],x);\nwriteln(x);\nend;\nbegin\nremplir(k);\nend."}, {"source_code": "var\ni,k:integer;\ns:string;\nbegin\nfor i:=1 to 10000 do\ns:=s+inttostr(i);\nread(k);\nwrite(s[k]);\nend."}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndl,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n pos,summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n razr,jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n poss:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]=1) and (k<=10000);\n\t\t\tch:='';\n\t\t\tfor i:=1 to k do\n\t\t\t\tbegin\n\t\t\t\tstr(i,ch1);\n\t\t\tch:=ch+ch1;\n end;\nval(ch[k],x);\nwriteln(x);\nend;\nbegin\nremplir(k);\nend."}, {"source_code": "program aziz;\nuses wincrt;\n var\nk:integer;\n procedure remplir(var k:integer);\n\t\tvar\n\t\ti:integer;\n\t\tch1,ch:string;\n begin\nrepeat\nwriteln('donnez l indice');\nreadln(k);\nuntil (k>=1) and (k<=10000);\n\t\t\tch:='';\n\t\t\tfor i:=1 to k do\n\t\t\t\tbegin\n\t\t\t\tstr(i,ch1);\n\t\t\tch:=ch+ch1;\n end;\n\twriteln(ch[k]);\nend;\nbegin\nremplir(k);\nend."}, {"source_code": "var\n n,k,l,g,h,z,i : longint;\n \n function rec(i,j,z : longint):longint;\n var\n f,r,t: longint;\n begin\n f:=1; r:=i;\n for f:=1 to z-j do r:=r div 10;\n r:=r mod 10;\n rec:=r;\n end;\n \nbegin\n h:=9; z:=1; g:=0;\n readln(n);\n i:=0; l:=0;\n while true do\n begin\n if g=h then\n begin\n h:=h*10;\n g:=0;\n z:=z+1;\n end;\n i:=i+1;\n g:=g+1;\n l:=l+z;\n if z>=(n-l) then\n begin\n k:=rec(i+1,n-l,z);\n break;\n end;\n end;\n writeln(k);\nend."}, {"source_code": "var\n n,k,l,g,h,z,i : longint;\n \n function rec(i,j,z : longint):longint;\n var\n f,r,t: longint;\n begin\n f:=1; r:=i;\n for f:=1 to z-j do r:=r div 10;\n r:=r mod 10;\n rec:=r;\n end;\n \nbegin\n h:=9; z:=1; g:=0;\n readln(n);\n i:=0; l:=0;\n if n=1 then\n begin\n writeln(1);\n exit;\n end;\n while true do\n begin\n if g=h then\n begin\n h:=h*10;\n g:=0;\n z:=z+1;\n end;\n i:=i+1;\n g:=g+1;\n l:=l+z;\n if z>=(n-l) then\n begin\n k:=rec(i+1,n-l,z);\n break;\n end;\n end;\n writeln(k);\nend."}, {"source_code": "program aziz;\nuses wincrt;\n var\nk:integer;\n procedure remplir(var k:integer);\n\t\tvar\n\t\ti:integer;\n\t\tch1,ch:string;\n begin\nrepeat\nwriteln('donnez l indice');\nreadln(k);\nuntil (k>1) and (k<10000);\n\t\t\tch:='';\n\t\t\tfor i:=1 to k do\n\t\t\t\tbegin\n\t\t\t\tstr(i,ch1);\n\t\t\tch:=ch+ch1;\n end;\n\twriteln(ch[k]);\nend;\nbegin\nremplir(k);\nend."}, {"source_code": "var\n tam1,max,cong,so,layso,p:int64;\n chuso:ansistring;\nbegin\n {Assign(input,'chuso.inp');\n reset(input);\n Assign(output,'chuso.out');\n rewrite(output);}\n read(p);\n str(p,chuso);\n if p<10 then\n begin\n write(p);\n exit;\n end else\n begin\n tam1:=1;\n max:=9;\n cong:=1;\n while p>=max*tam1 do\n begin\n cong:=cong*10;\n max:=max*10;\n inc(tam1);\n end;\n if tam1=2 then\n begin\n p:=p-9;\n so:=p div tam1 +cong;\n layso:=p mod tam1;\n if layso=0 then write((so-1) mod 10) else\n begin\n str(so,chuso);\n write(chuso[1]);\n end;\n end else\n begin\n max:=max div 10;\n p:=p-9-max*(tam1-1);\n so:=p div (tam1)+cong;\n layso:=p mod (tam1);\n if layso=0 then write((so-1) mod 10) else\n begin\n str(so,chuso);\n write(chuso[1]);\n end;\n end;\n end;\nend.\n\n\n\n\n"}, {"source_code": "var\n tam1,max,cong,so,layso,p:int64;\n chuso:ansistring;\nbegin\n {Assign(input,'chuso.inp');\n reset(input);\n Assign(output,'chuso.out');\n rewrite(output);}\n read(p);\n str(p,chuso);\n if p<10 then\n begin\n write(p);\n exit;\n end else\n begin\n tam1:=1;\n max:=9;\n cong:=1;\n while p>=max*tam1 do\n begin\n cong:=cong*10;\n max:=max*10;\n inc(tam1);\n end;\n if tam1=2 then\n begin\n p:=p-9;\n so:=p div tam1 +cong;\n layso:=p mod tam1;\n if layso=0 then write((so-1) mod 10) else\n begin\n str(so,chuso);\n write(chuso[1]);\n end;\n end else\n begin\n max:=max div 10;\n p:=p-9-max*(tam1-1);\n so:=p div (tam1)+cong;\n layso:=p mod (tam1);\n if layso=0 then write((so-1) mod 10) else\n begin\n str(so,chuso);\n write(chuso[layso]);\n end;\n end;\n end;\nend.\n\n\n\n\n"}], "src_uid": "1503d761dd4e129fb7c423da390544ff"} {"source_code": "var\n s, a, b, c, max1, i: integer;\n\nbegin\n readln(a, b, c);\n max1 := max(a, max(b, c));\n s := a + b + c;\n \n while max1 >= s - max1 + i do\n inc(i);\n writeln(i);\nend.", "positive_code": [{"source_code": "var a,b,c,tam,dem,tmp:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a > b then exit(a)\n else exit(b);\nend;\nfunction min(a,b:longint):longint;\nbegin\n if a < b then exit(a)\n else exit(b);\nend;\nbegin\n readln(a,b,c);\n tam:=max(a,max(b,c));\n dem:=min(a,min(b,c));\n if ((tam = a) and (dem = b)) or ((tam = b) and (dem = a)) then tmp:=c;\n if ((tam = b) and (dem = c)) or ((tam = c) and (dem = b)) then tmp:=a;\n if ((tam = c) and (dem = a)) or ((tam = a) and (dem = c)) then tmp:=b;\n if tam - dem - tmp + 1 < 0 then writeln(0)\n else\n writeln(tam-dem-tmp+1);\n readln;\nend."}, {"source_code": "Uses Math;\nVar a,b,c,sum:longint;\nBegin\n read(a,b,c);\n sum:=a+b+c;\n a:=max(a,max(b,c));\n sum:=sum-a;\n if sum>a then write(0) else write(a-sum+1); \nEnd.\n\n"}, {"source_code": "var\n a,b,c,s1,s2:longint; \nbegin\n readln(a,b,c);\n if (a>=b) and (a>=c) then\n begin\n s1:=b+c;\n s2:=a;\n end else\n if (b>=a) and (b>=c) then\n begin\n s1:=a+c;\n s2:=b;\n end else\n begin\n s1:=a+b;\n s2:=c;\n end;\n if s1>s2 then\n writeln(0) else\n writeln(s2-s1+1);\nend."}, {"source_code": "Program MakeATriangle;\nvar a,b,c:byte;\nProcedure Rearrange;\nvar tmp:byte;\nbegin if a>b then begin\n tmp:=a; a:=b; b:=tmp;\n end;\n if a>c then begin\n tmp:=a; a:=c; c:=tmp;\n end;\n if b>c then begin\n tmp:=b; b:=c; c:=tmp;\n end;\nend;\nProcedure Time;\nvar t:longint;\nbegin Rearrange;\n if a+b<=c then t:=c-(a+b)+1\n else t:=0;\n writeln(t);\nend;\nbegin //assign(input,'1064A.inp'); reset(input);\n //assign(output,'1064A.out'); rewrite(output);\n readln(a,b,c);\n Time;\n //close(input); close(output);\nend."}, {"source_code": "var\n i,j,m,n,k,p:longint;\n a:array[1..3]of longint;\nbegin\n n:=3;\n for i:=1 to 3 do\n read(a[i]);\n for i:=n-1 downto 1 do\n for j:=1 to i do\n if a[j]>a[j+1] then\n begin\n k:=a[j]; a[j]:=a[j+1]; a[j+1]:=k;\n end;\n {for i:=1 to 3 do\n write(a[i],' ');}\n if a[1]+a[2]>a[3] then\n writeln(0)\n else writeln(a[3]-a[1]-a[2]+1); \nend."}, {"source_code": "var x,a,b,c:longint;\nbegin\n read(a,b,c);\n if a>b then begin x:=a;a:=b;b:=x; end;\n if b>c then begin x:=c;c:=b;b:=x; end;if a>c then begin x:=a;a:=b;b:=x; end;\n x:=0;\n if cb[i] then begin y:=b[i];id2:=i;end;\nend;\nif (a+e>c)and(e+c>a)and(c+a>e) then\n begin\n writeln(0);\n exit;\n end\n else\n begin\n for i:=1 to 3 do if\n (i<>id1) and(i<>id2) then id3:=i;\n tot:=x-(b[id3]+y)+1;\n writeln(tot);\n end;\n\n\nend.\n\n"}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n a,b,c,d:integer;\nProcedure MinhThu;\n Begin\n If (a+b>c) and (a+c>b) and (c+b>a) then d:=0\n else\n begin\n If (a+c<=b) then d:= (b+1) - (a+c);\n If (a+b<=c) then d:= (c+1) - (b+a);\n If (b+c<=a) then d:= (a+1) - (b+c);\n end;\n end;\n\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,a,b,c);\n MinhThu;\n writeln(g,d);\n Close(f);\n Close(g);\nEnd."}, {"source_code": "var a,b,c,m:longint;\nbegin\nreadln(a,b,c);\nif ab then\n begin\n t:=a;\n a:=b;\n b:=t;\n end;\n if a>c then\n begin\n t:=a;\n a:=c;\n c:=t;\n end;\n if b>c then\n begin\n t:=b;\n b:=c;\n c:=t;\n end;\n if (a+b>c) and (a+c>b) and (b+c>a) then\n writeln(0)\n else\n writeln(c-a-b+1);\nend.\n"}, {"source_code": "var\na,b,c,t:longint;\nbegin\nreadln(a,b,c);\nif a>b then \nbegin\nt:=a;\na:=b;\nb:=t;\nend;\nif a>c then\nbegin\nt:=a;\na:=c;\nc:=t;\nend;\nif b>c then\nbegin\nt:=b;\nb:=c;\nc:=t;\nend;\nif a+b>c then writeln(0)\nelse writeln(c-b-a+1);\nend."}, {"source_code": "var\na,b,c,t:longint;\nbegin\nreadln(a,b,c);\nif a>b then \nbegin\nt:=a;\na:=b;\nb:=t;\nend;\nif a>c then\nbegin\nt:=a;\na:=c;\nc:=t;\nend;\nif b>c then\nbegin\nt:=b;\nb:=c;\nc:=t;\nend;\nif a+b>c then writeln(0)\nelse writeln(c-b-a+1);\nend."}, {"source_code": "var\n a:array[0..4] of longint;\nprocedure swap(var n,m:longint);\n var\n temp:longint;\n begin\n temp:=n; n:=m; m:=temp;\n end;\nbegin\n readln(a[1],a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[1]>a[3] then swap(a[1],a[3]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]+a[2]>a[3] then write(0) else write(a[3]-a[2]-a[1]+1);\nend."}, {"source_code": "var\na:array[-10..1000]of longint;\ni,j,x:longint;\nbegin\nreadln(a[1],a[2],a[3]);\nfor i:=1 to 3 do\nfor j:=1 to 2 do\nif a[i]a[3] then writeln(0)\nelse begin\n writeln(a[3]-a[2]-a[1]+1);\nend;\nend."}, {"source_code": "Var a,b,c,d : integer;\nBegin\n readln(a,b,c);\n d:=-1;\n if a-b-c>d then d:=a-b-c;\n if b-a-c>d then d:=b-a-c;\n if c-b-a>d then d:=c-b-a;\n writeln(d+1);\nend."}, {"source_code": "var a,b,c,max,min:longint;\nbegin\n readln(a,b,c);\n max:= a;\n min:= b+c;\n if (max < b) then \n begin\n max:= b;\n min:= a+c;\n end;\n if (max < c) then \n begin\n max:= c;\n min:= a+b;\n end;\n if (max < min) then writeln(0)\n else\n if (max = min) then writeln(1)\n else\n writeln(max - min + 1);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n a,b,c,i,d:longint;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n read(f,a,b,c);\n if (a+c>b) and (a+b>c) and (b+c>a) then d:=0\n else\n begin\n if (a+c<=b) then d:=(b-(a+c))+1;\n if (b+c<=a) then d:=(a-(b+c))+1;\n if (a+b<=c) then d:=(c-(a+b))+1;\n end;\n writeln(g,d);\n close(f);\n close(g);\n end."}, {"source_code": "var a,b,c,count:integer;\nbegin\n read(a,b,c);\n while a>=(b+c) do\n begin\n inc(c);\n count:=count+1;\n end;\n while b>=(a+c) do\n begin\n inc(a);\n count:=count+1;\n end;\n while c>=(a+b) do\n begin\n inc(b);\n count:=count+1;\n end;\n write(count);\nend.\n"}, {"source_code": "var a,b,c , t:byte; \n\nbegin\nreadln(a,b,c);\n if(b>c)then\n begin\n t:=c;\n\tc:=b;\n\tb:=t;\n end;\n if(a>b)then\n begin\n t:=b;\n\tb:=a;\n\ta:=t;\n end;\n if(b>c)then\n begin\n t:=c;\n\tc:=b;\n\tb:=t;\n end;\n if(a+b <= c)then\n writeln(c-a-b+1)else\n\twriteln(0);\nend.\n\na+b b then max := a else max := b;\nEnd;\n\nBEGIN\n\treadln(a,b,c);\n\tif a > b then swap(a,b);\n\tif b > c then swap(b,c);\n\tif a > c then swap(a,c);\n\n\twriteln(max(c-(a+b)+1,0));\nEND.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n a:array[1..100000] of longint;\n k:int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure qsort(l,r:longint);\n var i,j,mid,key:longint;\n begin\n i:=l;\n j:=r;\n mid:=ran(l,r);\n key:=a[mid];\n repeat\n while a[i]key do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if i=b) and (a>=c) then\n begin\n s1:=b+c;\n s2:=a;\n end else\n if (b>=a) and (b>=c) then\n begin\n s1:=a+c;\n s2:=b;\n end else\n begin\n s1:=a+b;\n s2:=c;\n end;\n if s1>s2 then\n writeln(0) else\n writeln(s2-s1+1);\nend."}, {"source_code": "\n\n\nvar k,a,b,c,max1,max2,max3:integer;\nbegin\nk:=0;\nreadln(a,b,c);\nmax1:=a-b-c;\n\nif max1>=0 then begin if b=0 then begin if a=0 then begin if astick[j])then\n begin\n stick[i]:=stick[i]+stick[j];\n stick[j]:=stick[i]-stick[j];\n stick[i]:=stick[i]-stick[j];\n end;\n writeln(max(stick[3]-stick[2]-stick[1]+1,0));\nend.\n"}, {"source_code": "program N5;\nvar\n a, b, c, cnt: Integer;\n\nbegin\n ReadLn (a, b, c);\n\n cnt := 0;\n\n if a + b <= c then\n cnt := c - (a + b) + 1\n else if a + c <= b then\n cnt := b - (a + c) + 1\n else if b + c <= a then\n cnt := a - (b + c) + 1;\n\n WriteLn (cnt);\nend."}, {"source_code": "const fi='';\n fo='';\nType mang=array [1..10000] of longint;\nVar s,n,i,kq: longint;\n\ta: mang;\n f,g: text;\nProcedure sort(var o: mang; l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=o[(l+r) div 2];\n repeat\n while o[i]j) then\n begin\n y:=o[i];\n o[i]:=o[j];\n o[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[3]) and ((a[2]+a[3])>a[1]) and ((a[1]+a[3])>a[2]) then\n \tWriteln(g,0)\n Else\n \tBegin\n \t\tSort(a,1,3);\n \t\tkq:= a[3]-a[2]-a[1]+1;\n \t\tWriteln(g,kq);\n End;\n Close(f);\n Close(g);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var a , b , c , kq , tmp : Longint;\n\nFunction Max(x , y : Longint) : Longint;\n Begin\n If x > y then Exit(x) else Exit(y);\n End;\n\nBegin\n Readln(a , b , c);\n If (a + b > c) and (a + c > b) and (b + c > a) then Writeln('0') else\n Begin\n tmp := Max(a , Max(b , c));\n If a = tmp then Writeln(a - b - c + 1) else\n If b = tmp then Writeln(b - a - c + 1) else\n If c = tmp then Writeln(c - a - b + 1);\n End;\nEnd."}, {"source_code": " var i,j,a,b,c,x:longint;\n begin\n read (a,b,c);\n\n\n if (a>b) and (a>c) then x:=a-b-c+1\n else\n if (b>a) and (b>c) then x:=b-a-c+1\n else\n if (c>a) and (c>b) then x:=c-a-b+1;\n\n\n if x<0 then writeln (0)\n else writeln (x);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n end.\n"}, {"source_code": "var\nk,n,i,r,j,x:int64;\na:array [1..100] of int64;\nbegin\n read(n,k,x);\n while (n= 0) then writeln(a[0] - a[1] - a[2] + 1)\n\telse writeln(0);\n\t\n\t\n\t\nend.\n"}, {"source_code": "var a,b,c: longint;\nbegin\n readln (a,b,c);\n if c+b<=a then writeln (a-c-b+1) else\n if a+b<=c then writeln (c-a-b+1) else\n if a+c<=b then writeln (b-a-c+1) else\n writeln ('0');\nend."}, {"source_code": "var\na,b,c:byte;\nmin,max:byte;\nBegin\nread(a,b,c);\nif ab) and (a>c) then max:=a else if (b>a) and (b>c) then max:=b else max:=c;\n if max>=a+b+c-max then writeln (2*max-a-b-c+1) else writeln (0);\n end."}, {"source_code": "var a,b,c,k:longint;\nBEGIN\nreadln(a,b,c);\nif (a+b>c) and (a+c>b) and (c+b>a) then begin writeln(0);exit; end;\nk:=0;\nwhile (a+b<=c) or (a+c<=b) or (c+b<=a) do \n begin\n \n if a+b<=c then \n BEGIN\n if a<=b then \n begin\n inc(a);\n inc(k);\n end\n else \n begin \n inc(b);\n inc(k);\n end;\n END;\n \n if a+c<=b then \n BEGIN\n if a<=c then \n begin\n inc(a);\n inc(k);\n end\n else \n begin \n inc(c);\n inc(k);\n end;\n END;\n \n if c+b<=a then \n BEGIN\n if c<=b then \n begin\n inc(c);\n inc(k);\n end\n else \n begin \n inc(b);\n inc(k);\n end;\n END; \n end;\n writeln(k);\nEND."}, {"source_code": "const n=3;\nvar a,b,c,i,r,k,j:integer;\nmas : array [1..3] of integer;\nbegin\nread(a,b,c);\nif (a+b>c) and (a+c>b) and (b+c>a) then Write('0')\nelse begin\nmas[1]:=a;\nmas[2]:=b;\nmas[3]:=c;\nfor i := 1 to n-1 do\n for j := 1 to n-i do\n if mas[j] > mas[j+1] then begin\n k := mas[j];\n mas[j] := mas[j+1];\n mas[j+1] := k\n end; \nWrite (mas[3]+1-(mas[2]+mas[1]));end;\nend."}, {"source_code": "var a,b,c,max1,min:integer;\n\nbegin\nread(a,b,c);\nmax1:=max(a,b);\nmax1:=max(max1,c);\n\n\nif a+b+c-2*max1<=0 then write(abs(a+b+c-2*max1)+1) else write(0);\n\nend."}, {"source_code": "var\n a, s, d, f: integer;\n\nbegin\n read(a, s, d);\n if s > a then\n begin f := a;a := s;s := f; end;\n if d > s then\n begin f := s;s := d;d := f; end;\n if s > a then\n begin f := a;a := s;s := f; end;\n if a >= s + d then\n write(a - s - d + 1) else\n write(0); \nend."}, {"source_code": "var\n c, ex, a, b, n, i, v: integer;\n s: string;\n\nbegin\n readln(a, b, c);\n \n if (a > b) and (a > c) then \n if b + c <= a then\n writeln(a - (b + c) + 1)\n else\n else\n v := 1;\n \n if (b > a) and (b > c) then \n if a + c <= b then\n begin\n writeln(b - (a + c) + 1);\n v := 0;\n end;\n \n if (c > b) and (c > a) then \n if a + b <= c then\n begin\n writeln(c - (a + b) + 1);\n v := 0; \n end;\n \n if v = 1 then\n writeln('0'); \n \nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var a: array[1..3] of integer;\n\nbegin\n read(a[1],a[2],a[3]);\n for i:integer := 1 to 3 do\n for g:integer := 1 to 2 do\n if (a[g] > a[g+1]) then swap(a[g],a[g+1]);\n \n if (a[3] < a[1] + a[2]) then write(0)\n else if (a[3] = a[1] + a[2]) then write(1)\n else write(a[3] - (a[1] + a[2]) + 1);\nend."}, {"source_code": "var a,b,c:integer;\nbegin\nreadln(a,b,c);\nif (aa)and(b1>b)and(c1>c)then\nwriteln('0')\nelse\nbegin\n\n if a1<=a then\n z:=abs(a1-a)+1\n else \n if b1<=b then\n z:=abs(b1-b)+1\n else\n if c1<=c then\n z:=abs(c1-c)+1;\nwriteln(z);\nend;\nend."}, {"source_code": "program pr1;\nvar\nn:string;\nk,a,b,c:integer;\nbegin\nread(a,b,c);\nk:=0;\nwhile (a+c<=b) or (a+b<=c) or (b+c<=a) do begin\nif (a+c>b) then begin b:=b+1;k:=k+1;end\nelse if (a+b>c) then begin c:=c+1;k:=k+1;end\nelse if (b+c>a) then begin a:=a+1;k:=k+1;end;\nend;\nwritelN(k);\nend. "}, {"source_code": "var a:array[1..3] of longint;\ni,j,k,l,m,n:longint;\nbegin\nfor i:=1 to 3 do \nread(a[i]);\nfor i:=1 to 2 do\nfor j:=i+1 to 3 do\nif a[i]>a[j] then swap(a[i],a[j]);\nwrite(max(0,a[3]-a[2]-a[1]+1))\nend."}, {"source_code": "var a,b,c,i,t:integer;\n begin\n readLn(a,b,c);\n while ((a+b<=c) or (a+c<=b) or (b+c<=a)) do\n begin\n if (a<=b) and (a<=c) then begin t:=t+1; a:=a+1 end else\n if (b<=c) and (b<=a) then begin t:=t+1; b:=b+1 end else\n if (c<=a) and (c<=b) then begin t:=t+1; c:=c+1 end;\n end;\n writeLn(t);\n end.\n"}, {"source_code": "var\n a, b, c, ab: integer;\n\nbegin\n Read(a, b, c); \n if (a >= b) and (a >= c) then\n begin\n if a < b + c then \n Write('0');\n \n \n if a>=b+c then\n begin\n ab:=a-(b+c);\n Write(ab+1);\n end;\n end\n else\n if (b >= a) and (b >= c) then\n begin\n if b < a + c then \n Write('0');\n \n if b>=a+c then\n begin\n ab:=b-(a+c);\n Write(ab+1);\n end;\n end\n else\n if (c >= a) and (c >= b) then\n begin\n if c < b + a then \n Write('0')\n end;\n if c>=a+b then\n begin\n ab:=c-(b+a);\n Write(ab+1);\n end;\nend."}, {"source_code": "var a,b,c,max,min,med,k:integer;\nbegin\nreadln(a,b,c);\n\n\nif ((a>=b+c)or(b>=a+c)or(c>=a+b))then begin\n\nif ((a<=b)and(a<=c))then begin min:=a; if (b>c)then begin med:=c; max:=b; end else begin med:=b; max:=c; end; end;\nif ((c<=a)and(c<=b))then begin min:=c; if (a>b)then begin med:=b; max:=a; end else begin med:=a; max:=b; end; end;\nif ((b<=a)and(b<=c))then begin min:=b; if (c>a)then begin med:=a; max:=c; end else begin med:=c; max:=a; end; end;\n\n\nwhile (med+min<=max) do begin\nmin:=min+1;\ninc(k);\n\nend;\n\nwriteln(k);\n\n\n\nend else writeln(0);\n\n\n\nend.\n\n"}, {"source_code": "\nvar\n a, b, c, k, ab: integer;\n\nbegin\n Read(a, b, c); \n if (a >= b) and (a >= c) then\n begin\n if a < b + c then \n Write('0');\n \n \n if a>=b+c then\n begin\n ab:=a-(b+c);\n Write(ab+1);\n end;\n end\n else\n if (b >= a) and (b >= c) then\n begin\n if b < a + c then \n Write('0');\n \n if b>=a+c then\n begin\n ab:=b-(a+c);\n Write(ab+1);\n end;\n end\n else\n if (c >= a) and (c >= b) then\n begin\n if c < b + a then \n Write('0')\n end;\n if c>=a+b then\n begin\n ab:=c-(b+a);\n Write(ab+1);\n end;\nend."}, {"source_code": "var\na,b,c,q,min:integer;\nbegin\nread(a,b,c);\nmin:=301;\nif a+b<=c then begin q:=c-(a+b); if q c) and (a + c > b) and (b + c > a) then\n Write(0)\n Else Write(2*max(a, max(b, c)) - (a + b + c) + 1)\nEnd."}, {"source_code": "var a,b,c,n:integer;\nbegin\nreadln(a,b,c);\nif a+b<=c then n:=c-a-b+1;\nif a+c<=b then n:=b-c-a+1;\nif b+c<=a then n:=a-b-c+1;\nwriteln(n);\nend."}, {"source_code": "var\na,b,c,r : integer;\nbegin\nreadln(a,b,c);\nr:=-1;\nif(a>b)and(a>c)then r:=a-(b+c);\nif(b>a)and(b>c)then r:=b-(a+c);\nif(c>a)and(c>b)then r:=c-(a+b);\nif(r>=0)then write(r+1) else write(0);\nend."}, {"source_code": "Var a,b,c,d,m : integer;\nBegin\n readln(a,b,c);\n if a az then\n az := f2;\n if f3 > az then\n az := f3;\n write(az);\nend."}, {"source_code": "var a,b,c,t,max,sum:integer;\nbegin\n read(a,b,c);\n if (a>=b)and(a>=c) then begin max:=a; sum:=b+c; end;\n if (b>=a)and(b>=c) then begin max:=b; sum:=a+c; end;\n if (c>=a)and(c>=b) then begin max:=c; sum:=b+a; end;\n if (a=b)and(a=c) then begin writeln(0); exit;end;\n while max>=t+sum do \n begin\n inc(t);\n end;\n writeln(t);\nend."}, {"source_code": "var a,b,c,max,sum,t:integer;\nbegin\n read(a,b,c);\n if (a=b)and(a=c) then begin writeln(0); exit; end;\n if (a>=b)and(a>=c) then begin max:=a; sum:=b+c;end;\n if (b>=a)and(b>=c) then begin max:=b; sum:=a+c;end;\n if (c>=a)and(c>=b) then begin max:=c; sum:=a+b;end;\n while max>=t+sum do inc(t);\n writeln(t);\nend."}, {"source_code": "label 1;\nvar a,b,c,t : byte;\nBegin\n readln(a,b,c);\n if (ac) then begin\n t:=a;\n a:=b;\n b:=t;\n goto 1;\n end;\n if (ab) then begin\n t:=a;\n a:=c;\n c:=t;\n goto 1;\n end;\n if (a=b) and (b=(b+c) then writeln(a-(b+c)+1) else writeln('0');\nEnd."}, {"source_code": "program Triangle;\nvar a,b,c,p,k,max : integer ;\nbegin\nreadln(a,b,c);\n\np:=a+b+c;\n\nif (a>=b) and (a>=c) then max:=a;\nif (b>=a) and (b>=c) then max:=b;\nif (c>=a) and (c>=b) then max:=c;\n\nk:=p-max;\n\nif k-max>0\n then writeLn(0)\n else writeLn(max-k+1);\nend."}, {"source_code": "var a,b,c,d:byte;\nbegin\n read(a,b,c);\n d:=0;\n while not((a0) and (b>0) and (c>0) then begin\nif ((a=b)and (a>c)) or ((c=a)and (c>b)) or ((c=b)and (b>a))then writeln(0) else begin\nif (a=b) and (a=c) then writeln(0) else begin\nif (a>b) and (a>c) then begin \nif b+c>a then writeln(0) else begin\n m:=a;\n r:=a -(c+b);\n writeln(r+1);\n end;\n end;\nif (b>a) and (b>c) then begin \nif a+c>b then writeln(0) else begin\n m:=b;\n r:=b-(c+a);\n writeln(r+1);\n end;\n end; \nif (c>a) and (c>b) then begin \n m:=c;\n if a+b>c then writeln(0) else begin\n r:=c-(a+b);\n writeln(r+1);\n \n end;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "var a,b,c,i,j,d,m:integer;\nbegin\n readln(a,b,c);\n if ab) and (a>c) then writeln(a-b-c+1);\nif (b>a) and (b>c) then writeln(b-a-c+1);\nif (c>b) and (c>a) then writeln(c-b-a+1);\nend;\nend."}, {"source_code": "var a,b,c,m:integer;\nbegin\nread(a,b,c);\nif a>=b+c then m:=a-b-c+1;\nif b>=a+c then m:=b-a-c+1;\nif c>=b+a then m:=c-b-a+1;\nwriteln (m);\nend.\n"}, {"source_code": "Program p;\nvar a: array of integer;\n\nbegin\nsetlength(a, 3);\nfor var g:=0 to 2 do\n read(a[g]);\nsort(a);\nwrite(max(0, a[2]-a[1]-a[0]+1))\nend."}, {"source_code": "var a,b,c,k,t:integer;\n\nbegin\n k:=0;\n t:=0;\n readln(a,b,c);\n if b>c then begin k:=b; b:=c; c:=k end;\n if a>c then begin k:=a; a:=c; c:=k end;\n \n while c>=a+b do begin\n if (a>=c) then begin c:=c+1;\n if (b>=c) then c:=c+1\n else b:=b+1; end\n else a:=a+1;\n t:=t+1;\n end;\n writeln(t); \nend.\n"}, {"source_code": "program pr;\n\nvar\n a, b, c, k, d: integer;\n\nbegin\n Read(a, b, c);\n K := 0;\n if (a + b > c) and (a + c > b) and (b + c > a) then Writeln(k) else \n begin\n while (a + b <= c) or (a + c <= b) or (b + c <= a) or ((a + b <= c) and (a + c <= b) and (b + c <= a)) or ((a + b <= c) and (a + c <= b)) or ((a + b <= c) and (b + c <= a)) or ((a + c <= b) and (b + c <= a)) do\n begin\n if ((a + b <= c) and (a + c <= b) and (b + c <= a)) then a := a + 1 else \n if (a + b <= c) then \n while (a + b <= c) do \n begin\n b := b + 1;\n k := k + 1;\n end else \n if (a + c <= b) then \n while (a + c <= b) do \n begin\n a := a + 1;\n k := k + 1;\n end else\n if (b + c <= a) then \n while (b + c <= a) do\n begin\n b := b + 1;\n k := k + 1;\n end;\n end;\n Writeln(k);\n end;\nend."}, {"source_code": "var t,a,b,c:integer;\n\nbegin\nreadln(a,b,c);\nif a+b<=c then t:=c-a-b+1;\nif a+c<=b then t:=b-a-c+1;\nif c+b<=a then t:=a-c-b+1;\nwriteln(t);\nend."}, {"source_code": "var a,b,c,x,y,n,m,i,j,k,max,s:integer;\n\nbegin\n readln (a,b,c);\n \n if (a>=b) and (a>=c) then begin max:=a; s:=b+c; end;\n if (b>=a) and (b>=c) then begin max:=b; s:=a+c; end;\n if (c>=b) and (c>=a) then begin max:=c; s:=b+a; end;\n \n if (a=b) and (a=c) then writeln (0) else\n begin\n while max>=s+k do\n inc (k);\n writeln (k);\n end;\nend."}, {"source_code": "var i,j:longint;\na:array[1..3]of longint;\nfunction t(x:longint):longint;\nbegin \nif x<0 then x:=0;\nt:=x;\nend;\nbegin \n\n\nread(a[1],a[2],a[3]);\nfor i:=1 to 2 do\nfor j:=1 to 3-i do\nif a[j]c) then begin\n t:=a;\n a:=b;\n b:=t;\n goto 1;\n end;\n if (ab) then begin\n t:=a;\n a:=c;\n c:=t;\n goto 1;\n end;\n if (a=b) and (b=(b+c) then writeln(a-(b+c)+1) else writeln('0');\nEnd."}, {"source_code": " const eps=0.000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,d,n,j2,ttt,ppp,kol,sq,h,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,m,smin,cen:int64;\n i2,i3,step2,k1,k2,pp0,mask,k,i1,j1,step1, step, i,j:longint;\n a,zsum,xx,yy,y,x,z:array[-200000..350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n zzan:array[-1..2000,-1..2000] of boolean;\n sumkonfig,konfig:array[-1000..200000,-1..10] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day,b:mas;\n zz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n ppole:array[-10..1002,-10..1005] of char;\n pole,ddd,dd2,dd3,dd4:array[-10..4200,-10..1020] of int64;\n dd,ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n sss1,sss2:string;\n def,left,right,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..1060,-10..1060] of extended;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]b+c)or(b>a+c)or(c>a+b))then begin\n\nif ((a<=b)and(a<=c))then begin min:=a; if (b>c)then begin med:=c; max:=b; end else begin med:=b; max:=c; end; end;\nif ((c<=a)and(c<=b))then begin min:=c; if (a>b)then begin med:=b; max:=a; end else begin med:=a; max:=b; end; end;\nif ((b<=a)and(b<=c))then begin min:=b; if (c>a)then begin med:=a; max:=c; end else begin med:=c; max:=a; end; end;\n\n\nend; //else writeln(0);\n\nwhile (med+min<=max) do begin\nmin:=min+1;\ninc(k);\n\nend;\n\nwriteln(k);\n\nend.\n\n"}, {"source_code": "var a,b,c,max,min,med,k:integer;\nbegin\nreadln(a,b,c);\nmed:=30;\n\nif ((a>b+c)or(b>a+c)or(c>a+b))then begin\n\nif ((a<=b)and(a<=c))then begin min:=a; if (b>c)then begin med:=c; max:=b; end else begin med:=b; max:=c; end; end;\nif ((c<=a)and(c<=b))then begin min:=c; if (a>b)then begin med:=b; max:=a; end else begin med:=a; max:=b; end; end;\nif ((b<=a)and(b<=c))then begin min:=b; if (c>a)then begin med:=a; max:=c; end else begin med:=c; max:=a; end; end;\n\n\nend; //else writeln(0);\n\nwhile (med+min<=max) do begin\nmin:=min+1;\ninc(k);\n\nend;\n\nwriteln(k);\n\nend.\n\n"}, {"source_code": "var a,b,c,max,min,med,k:integer;\nbegin\nreadln(a,b,c);\n\n\nif ((a>b+c)or(b>a+c)or(c>a+b))then begin\n\nif ((a<=b)and(a<=c))then begin min:=a; if (b>c)then begin med:=c; max:=b; end else begin med:=b; max:=c; end; end;\nif ((c<=a)and(c<=b))then begin min:=c; if (a>b)then begin med:=b; max:=a; end else begin med:=a; max:=b; end; end;\nif ((b<=a)and(b<=c))then begin min:=b; if (c>a)then begin med:=a; max:=c; end else begin med:=c; max:=a; end; end;\n\n\nwhile (med+min<=max) do begin\nmin:=min+1;\ninc(k);\n\nend;\n\nwriteln(k);\n\n\n\nend else writeln(0);\n\n\n\nend.\n\n"}, {"source_code": "var a,b,c,n:integer;\nbegin\nreadln(a,b,c);\nif a+b=0)then write(r+1) else write(0);\nend."}, {"source_code": "var a,b,c,t,max,sum:integer;\nbegin\n read(a,b,c);\n if (a>=b)and(a>=c) then begin max:=a; sum:=b+c; end;\n if (b>=a)and(b>=c) then begin max:=b; sum:=a+c; end;\n if (c>=a)and(c>=b) then begin max:=c; sum:=b+a; end;\n if (a=b)and(a=c) then writeln(0);\n while max>=t+sum do \n begin\n inc(t);\n end;\n writeln(t);\nend."}, {"source_code": "label 1;\nvar a,b,c,t : byte;\nBegin\n readln(a,b,c);\n if (ac) then begin\n t:=a;\n a:=b;\n b:=t;\n goto 1;\n end;\n if (a=(b+c) then writeln(a-(b+c)+1) else writeln('0');\nEnd."}, {"source_code": "var\na,b,m,c,s,r:integer;\nbegin\nread(a,b,c); \nif (a>b) and (a>c) then begin \nif b+c>a then writeln(0) else begin\n m:=a;\n r:=a -(c+b);\n writeln(r+1);\n end;\n end;\nif (b>a) and (b>c) then begin \nif a+c>b then writeln(0) else begin\n m:=b;\n r:=b-(c+a);\n writeln(r+1);\n end;\n end; \nif (c>a) and (c>b) then begin \n m:=c;\n if a+b>c then writeln(0) else begin\n r:=c-(a+b);\n writeln(r+1);\n \n end;\n end;\nend."}, {"source_code": "var\na,b,m,c,s,r:integer;\nbegin\nread(a,b,c); \nif (a=b) and (a=c) then writeln(0) else begin\nif (a>b) and (a>c) then begin \nif b+c>a then writeln(0) else begin\n m:=a;\n r:=a -(c+b);\n writeln(r+1);\n end;\n end;\nif (b>a) and (b>c) then begin \nif a+c>b then writeln(0) else begin\n m:=b;\n r:=b-(c+a);\n writeln(r+1);\n end;\n end; \nif (c>a) and (c>b) then begin \n m:=c;\n if a+b>c then writeln(0) else begin\n r:=c-(a+b);\n writeln(r+1);\n \n end;\n end;\n end;\nend."}, {"source_code": "var a,b,c,x,y,n,m,i,j,k,max,s:integer;\n\nbegin\n readln (a,b,c);\n \n if (a>b) and (a>c) then begin max:=a; s:=b+c; end;\n if (b>a) and (b>c) then begin max:=b; s:=a+c; end;\n if (c>b) and (c>a) then begin max:=c; s:=b+a; end;\n \n if (a=b) and (a=c) then writeln (0) else\n begin\n while max>=s+k do\n inc (k);\n writeln (k);\n end;\nend."}, {"source_code": "var a,b,c,x,y,n,m,i,j,k,max,s:integer;\n\nbegin\n readln (a,b,c);\n \n if (a>b) and (a>c) then begin max:=a; s:=b+c; end;\n if (b>a) and (b>c) then begin max:=b; s:=a+c; end;\n if (c>b) and (c>a) then begin max:=c; s:=b+a; end;\n \n while max>=s+k do\n inc (k);\n \n writeln (k);\nend."}, {"source_code": "var a,b,c,tam,dem,tmp:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a > b then exit(a)\n else exit(b);\nend;\nfunction min(a,b:longint):longint;\nbegin\n if a < b then exit(a)\n else exit(b);\nend;\nbegin\n readln(a,b,c);\n tam:=max(a,max(b,c));\n dem:=min(a,min(b,c));\n if ((tam = a) and (dem = b)) or ((tam = b) and (dem = a)) then tmp:=c;\n if ((tam = b) and (dem = c)) or ((tam = c) and (dem = b)) then tmp:=a;\n if ((tam = c) and (dem = a)) or ((tam = a) and (dem = c)) then tmp:=b;\n writeln(tam-dem-tmp+1);\n readln;\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n a,b,c,d:integer;\nProcedure MinhThu;\n Begin\n If (a+b>c) or (a+c>b) or (c+b>a) then d:=0\n else\n begin\n If (a+c<=b) then d:= (b+1) - (a+c);\n If (a+b<=c) then d:= (c+1) - (b+c);\n If (b+c<=a) then d:= (a+1) - (b+c);\n end;\n end;\n\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,a,b,c);\n MinhThu;\n writeln(g,d);\n Close(f);\n Close(g);\nEnd."}, {"source_code": "var a,b,c , t:byte; \n\nbegin\nreadln(a,b,c);\n if(b>c)then\n begin\n t:=c;\n\tc:=b;\n\tb:=t;\n end;\n if(a>b)then\n begin\n t:=b;\n\tb:=a;\n\ta:=t;\n end;\n if(b>c)then\n begin\n t:=c;\n\tc:=b;\n\tb:=t;\n end;\n if(a+b < c)then\n writeln(c-a-b+1)else\n\twriteln(0);\nend.\n\na+bj) then\n begin\n y:=o[i];\n o[i]:=o[j];\n o[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l36 then begin writeln(-1); halt; end;\n for i:=1 to n div 2 do\n write(8);\n if odd(n) then write(6); writeln;\nend.", "positive_code": [{"source_code": "var\n k:longint;\nbegin\n readln(k);\n if k>36 then\n write(-1)\n else begin\n if k=0 then\n write(1)\n else begin\n while k>=2 do begin\n write(8);\n dec(k,2);\n end;\n if k=1 then write(4);\n end;\n end;\nend."}, {"source_code": "var\nk,i:integer;\nbegin\nreadln(k);\nif k>36 then writeln(-1) else while k>0 do begin\nif k mod 2=0 then begin\nwrite(8);\nk:=k-2;\nend;\nif k mod 2=1 then begin\nwrite(4);\nk:=k-1;\nend;\nend;\nend."}, {"source_code": "program gg;\nvar k:int64;\nbegin\nread(k);\nif k>36 then begin\nwrite(-1);\nhalt(0);\nend;\nif k mod 2 = 1 then begin\nwrite(6);\nk:=k-1;\nend;\nwhile k<>0 do begin\nwrite(8);\nk:=k-2;\nend;\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n if n>36 then begin writeln(-1); halt; end;\n for i:=1 to n div 2 do\n write(8);\n if odd(n) then write(6); writeln;\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n if n>36 then begin writeln(-1); halt; end;\n for i:=1 to n div 2 do\n write(8);\n if odd(n) then write(6); writeln;\nend."}, {"source_code": "Program ILoveYou;\nVAR n,i:int64;\nBegin\n\nReadln(n);\n\nif (n > 36) then Writeln('-1') else\nBegin\n\nfor i:=1 to (n div 2) do\nBegin\nWrite('8');\nend;\n\nfor i:=1 to (n mod 2) do\nBegin\nWrite('4');\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n if a <> 0 then write(a);\n for i:=1 to q do write(4);\n end;\n readln;readln;\n end."}, {"source_code": "Var\n k: UInt64;\n\nBegin\n Read(k);\n If k > 36 then Write(-1)\n Else Begin\n For Var i := 1 to k div 2 do\n Write(8);\n If k mod 2 <> 0 then Write(6)\n End;\nEnd."}, {"source_code": "var n,i:longint;\n\nbegin\n//assign(input,'ygfrddd.in');reset(input);\n//(output,'ygfrddd.out');rewrite(output);\nreadln(n);\nif n>36 then\n write(-1)\nelse\n begin\n if n>18 then\n begin\n for i:=1 to n-18 do\n write(8);\n for i:=1 to n-(n-18)*2 do\n write(6);\n end\n else\n for i:=1 to n do write(6);\n end;\nclose(input);close(output);\nend."}, {"source_code": "var\n k, ans : int64;\nbegin\n readln(k);\n if k > 36\n then writeln(-1)\n else\n begin\n while k >= 2 do\n begin\n ans := ans * 10 + 8;\n dec(k, 2);\n end;\n if k = 1\n then ans := ans * 10 + 9;\n writeln(ans);\n end;\nend."}, {"source_code": "var\nk:longint;\nc:int64;\nbegin\nread(k);\nif k>36 then\nbegin write(-1);\nhalt; end;\nif k=1 then\nbegin write('6');\nhalt; end;\nc:=0;\nwhile k>1 do\nbegin dec(k,2);\nc:=c*10+8;\nend;\nif k>0 then\nc:=c*10;\nwrite(c);\nend."}, {"source_code": "const num:array[0..9]of longint=(1,0,0,0,1,0,1,0,2,1);\nvar k,i:longint;\nbegin\n read(k);\n if k>18*2 then\n begin\n writeln('-1');\n exit;\n end;\n for i:=1 to 18 do\n begin\n if k>=2 then\n begin\n write(8);\n dec(k,2);\n end else\n if k=1 then\n begin\n write(4);\n dec(k);\n end;\n if k=0 then break;\n end;\n writeln;\nend."}, {"source_code": "var k:integer;\ni:integer;\nbegin\nread(k);\nif k>36 then \n begin\n writeln('-1');\n halt;\n end;\nwhile k>0 do\n begin\n if k>1 then \n begin\n write('8');\n k:=k-2;\n end\n else \n begin\n write('4');\n k:=k-1;\n end;\n end;\n\nend."}, {"source_code": "uses math;\n\nvar n, i : longint;\n\ts : string;\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'input.txt');\n{$else}\n\t//assign(input,'road.in'); \n\t//assign(output,'road.out'); \n{$endif}\n\treset(input);rewrite(output);\n\n\treadln(n);\n\n\tif n > 36 then \n\t\ts := '-1'\n\telse\n\t\twhile (n > 0) do\n\t\t\tif (n >= 2) then\n\t\t\t\tbegin\n\t\t\t\t\ts := s + '8';\n\t\t\t\t\tdec(n,2);\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\ts := s + '4';\n\t\t\t\t\tdec(n);\n\t\t\t\tend;\n\n\twriteln(s);\n\n\tclose(input);\n\tclose(output);\nend."}, {"source_code": "var c,i:longint;\nbegin\n readln(c);\n if c>36 then\n writeln(-1)\n else\n begin\n for i:=1 to c div 2 do\n write(8);\n if c mod 2=1 then\n write(6);\n end;\nend."}, {"source_code": " var k:longint;\nbegin\n readln(k);\n if k>36 then\n writeln(-1)\n else begin\n while k>1 do begin\n write('8');\n dec(k,2);\n end;\n if k>0 then\n writeln(4);\n end;\nend."}, {"source_code": "const num:array[0..9]of longint=(1,0,0,0,1,0,1,0,2,1);\nvar k,i:longint;\nbegin\n read(k);\n if k>18*2 then\n begin\n writeln('-1');\n exit;\n end;\n for i:=1 to 18 do\n begin\n if k>=2 then\n begin\n write(8);\n dec(k,2);\n end else\n if k=1 then\n begin\n write(4);\n dec(k);\n end;\n if k=0 then break;\n end;\n writeln;\nend."}, {"source_code": "var s:string;\n k,i,n:longint;\nbegin\n readln(n);\n if n>36\n then begin\n writeln(-1);\n exit;\n end;\n while n>0 do\n begin\n if n>1\n then begin\n s:=s+'8';\n n:=n-2;\n end\n else begin\n s:=s+'4';\n n:=n-1;\n end;\n end;\n writeln(s);\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n if n>36 then begin write(-1);halt; end;\n for i:=1 to n div 2 do write(8);\n if n mod 2=1 then write(6);\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n if n>36 then begin writeln(-1); halt; end;\n for i:=1 to n div 2 do\n write(8);\n if odd(n) then write(6); writeln;\nend."}, {"source_code": "Var z,x,k,i,n: longint;\nbegin\nRead(k);\nIf k>36 then begin Write('-1');exit;end;\nIf k mod 2=0 then begin n:=k div 2;\nFor i:=1 to n do\nWrite('8');\nend else begin n:=(k-1) div 2;\nFor i:=1 to n do\nWrite('8');\nWrite('4');\nend;\nend.\n"}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n for i:=1 to q do a:=a*10+6;\n write(a);\n end;\n end."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n if n>36 then begin writeln(-1); halt; end;\n for i:=1 to n div 2 do\n write(8);\n if odd(n) then write(6); writeln;\nend."}, {"source_code": "var i:longint;\nvar n:int64;\nbegin\n read(n);\n if n>=37 then begin writeln(-1);exit;end;\n for i:=1 to n div 2 do write(8);\n for i:=1 to n mod 2 do write(4);writeln;\nend."}, {"source_code": "var i,j,k:longint;\n begin\n { assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output); }\n read (k);\n if k>36 then writeln (-1)\n else\n begin\n while k-1>0 do\n begin\n write (8);\n k:=k-2;\n end;\n if k=1 then write (4);\n end;\n\n\n\n\n\n\n\n\n end.\n"}, {"source_code": "var k,i:longint;\nbegin\n readln(k);\n if k>36 then\n writeln('-1')\n else\n begin\n for i:=1 to k div 2 do\n write('8');\n if k mod 2=1 then\n write('6');\n end;\n writeln;\nend.\n "}, {"source_code": "var\n k,i:longint;\nbegin\n read(k);\n if k>36 then\n begin\n writeln('-1');\n halt;\n end;\n for i:=1 to k div 2 do write(8);\n if odd(k) then write(6);\n writeln;\nend."}, {"source_code": "const fin='a.inp';fon='a.out';\nvar k,i:longint;\nbegin\n //assign(input,fin);\n //reset(input);\n //assign(output,fon);\n //rewrite(output);\n readln(k);\n if (k<37) then\n begin\n for i:=1 to k div 2 do\n write('8');\n if k mod 2=1 then write('4');\n end\n else\n write('-1');\nend.\n\n"}, {"source_code": "var k : integer;\n\nbegin\n read (k);\n if (k > 36) then write (-1)\n else\n begin\n while (k >= 2) do \n begin\n write (8);\n k -= 2;\n end;\n if (k > 0) then write (4);\n end;\nend."}, {"source_code": "var k:int64;\n\nbegin\nreadln(k);\nif k > 36 then writeln(-1) else\n begin\n if k mod 2 = 1 then write(4);\n for var i:=1 to (k div 2) do write(8);\n writeln;\n end;\nend."}, {"source_code": "var i,k:longint;\nbegin \nread(k);\nif k>36 then write(-1)\nelse begin \nfor i:=1 to k div 2 do \nwrite(8);\nif k mod 2 <>0 then write(9);\nend;\n\n\n\nend."}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var kk,jj,wogr,w,ii,ogr,q,modul,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pos,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n step, k,i,j:longint;\n aa,bb,cc:int64;\n l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n right,down,dd:array[-10..1002,-10..10002] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2,ss1,ss2:array[0..nn] of string;\n ott,v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n);\n for i:=0 to 18 do for j:=0 to 18 do for k:=0 to 18 do\n if (j+2*k=n)and(i+j+k=18) then\n begin\n flag:=true;\n ii:=i;jj:=j;kk:=k;\n\n\n end;\n\n if not flag then begin write(-1); goto 1; end;\n for i:=1 to ii do write('1');\n for i:=1 to jj do write('4');\n for i:=1 to kk do write('8');\n\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program chislo;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n:integer;\nbegin\n readln(n);\n if(n>36)then writeln(-1)\n else begin\n while(n>0)do begin\n if(n>=2)then begin\n write(8);\n n:=n-2;\n end\n else begin\n write(9);\n n:=n-1;\n end\n end;\n end;\n\n readln;\nend.\n"}, {"source_code": "program Big_stavka;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar b,c,i,k: longint;\nbegin\nreadln(k);\nb:=k div 2;\nc:=k mod 2;\nif b+c<=18\n then begin\n for i:=1 to b do\n write(8);\n for i:=1 to c do\n write(4);\n end\n else write(-1);\nend.\n\n"}, {"source_code": "program BigBet;\nvar k,i: longint;\nBEGIN\nreadln(k);\nif (k>36) then begin\n writeln(-1);\n exit;\nend;\nfor i:=1 to (k div 2) do write(8);\nfor i:=1 to (k mod 2) do write(9);\nEND."}, {"source_code": "var i:longint;\nvar n:int64;\nbegin\n read(n);\n if n>=37 then begin writeln(-1);exit;end;\n for i:=1 to n div 2 do write(8);\n for i:=1 to n mod 2 do write(9);writeln;\nend."}, {"source_code": "var k,i:int64; s:string;\nbegin readln(k);\n i:=0; s:='';\n if k=1 then s:='4'\n else begin while i+2<=k do begin\n s:=s+'8';\n i:=i+2;\n end;\n if i+1=k then s:=s+'4';\n end;\n if length(s)>18 then s:='-1';\n writeln(s);\nend.\n\n\n"}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n for i:=1 to q do a:=a*10+6;\n write(a);\n end;\n end."}, {"source_code": "var k,n,o: integer; \n res: string;\n\nbegin\n readln(k);\n n:= k div 2;\n o:= k mod 2;\n res:='';\n if n+o<=18 then\n begin\n for var i:=1 to n do\n res:=res+'8';\n if o>0 then\n res:=res+'6';\n end\n else\n res:='-1';\n \n \n writeln(res);\n \nend.\n\n"}, {"source_code": "var \ni,k:longint;\nres: string;\nbegin \nread(k);\nres:='';\nif k>36 then write(-1)\nelse begin \nfor i:=1 to k div 2 do \nres:=res+'8';\nif k mod 2 <>0 then res:=res+'6';\nend;\nwriteln(res);\nend."}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nIf k>=37 Then begin Writeln('-1'); halt;end;\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else begin\n Writeln('4'); k:=k-1;end;\nIf k<=0 Then begin break;end; end;\nend."}, {"source_code": "Var k:integer; s:string; \nBegin\n readln(k);\n if k>36 then writeln('-1') else\n begin\n if k=0 then s:='1';\n If k mod 2 = 1 then begin s:=s+'4'; k:=k-1; end;\n while (k<>0) do\n begin\n s:=s+'8';\n k:=k-2;\n end;\n writeln(s);\n end;\n end."}], "negative_code": [{"source_code": "var k:int64;\n\nbegin\nreadln(k);\nif k = 1 then writeln(0) else\nif k > 36 then writeln(-1) else\n begin\n if k mod 2 = 1 then write(4);\n for var i:=1 to (k div 2) do write(8);\n writeln;\n end;\nend."}, {"source_code": "program chislo;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n:integer;\nbegin\n readln(n);\n if(n>36)then writeln(-1)\n else begin\n while(n>0)do begin\n if(n>=2)then begin\n write(8);\n n:=n-2;\n end\n else begin\n write(0);\n n:=n-1;\n end\n end;\n end;\n readln;\nend.\n"}, {"source_code": "program Big_stavka;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar b,c,i,k: longint;\nbegin\nreadln(k);\nb:=k div 2;\nc:=k mod 2;\nfor i:=1 to b do\n write(8);\nfor i:=1 to c do\n write(4);\nend.\n\n"}, {"source_code": "var i:longint;\nvar n:int64;\nbegin\n read(n);\n if n>=35 then begin writeln(-1);exit;end;\n for i:=1 to n div 2 do write(8);\n for i:=1 to n mod 2 do write(0);writeln;\nend."}, {"source_code": "var i:longint;\nvar n:int64;\nbegin\n read(n);\n if n>=36 then begin writeln(-1);exit;end;\n for i:=1 to n div 2 do write(8);\n for i:=1 to n mod 2 do write(9);writeln;\nend."}, {"source_code": "var k,i:int64; s:string;\nbegin readln(k);\n i:=0; s:='';\n if k=1 then s:='4'\n else begin while i+2<=k do begin\n s:=s+'8';\n i:=i+2;\n end;\n if i+1=k then s:=s+'4';\n end;\n writeln(s);\nend.\n\n\n"}, {"source_code": "var k,i:int64; s:string;\nbegin readln(k);\n i:=0; s:='';\n if k=1 then s:='4'\n else begin while i+2<=k do begin\n s:=s+'8';\n i:=i+2;\n end;\n if i+1=k then s:=s+'4';\n end;\n writeln(s);\n readln;\nend.\n\n\n"}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nIf k>=36 Then begin Writeln('-1'); halt;end;\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else begin\n Writeln('4'); k:=k-1;end;\nIf k<=0 Then begin break;end; end;\nend."}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nIf k>=1000000 Then begin Writeln('-1'); halt;end;\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else begin\n Writeln('4'); k:=k-1;end;\nIf k<=0 Then begin break;end; end;\nend."}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else\n Writeln('4'); k:=k-1;\nIf k=0 Then begin break;end; end;\nend."}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else begin\n Writeln('4'); k:=k-1;end;\nIf k<=0 Then begin break;end; end;\nend."}, {"source_code": "Program grf1;\nVar i,n,b,c,k: Longint; a: array[1..100000] of Longint;\nBegin\nRead(k);\nFor i:=1 to k+1 do\n begin\n If k-2>=0 then\n begin\n Write('8');\n k:=k-2;\n end\n else\n Writeln('4'); k:=k-1;\nIf k<=0 Then begin break;end; end;\nend."}, {"source_code": "var\n k:longint;\nbegin\n readln(k);\n if k>36 then\n write(-1)\n else begin\n if k=0 then\n write(1)\n else begin\n while k>=2 do begin\n write(8);\n dec(k,2);\n end;\n if k=1 then write(0);\n end;\n end;\nend."}, {"source_code": "var\nk,i:integer;\nbegin\nreadln(k);\nif k>36 then writeln(-1) else while k>0 do begin\nif k mod 2=0 then begin\nwrite(8);\nk:=k-2;\nend;\nif k mod 2=1 then begin\nwrite(0);\nk:=k-1;\nend;\nend;\nend."}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n for i:=0 to q do a:=a*10;\n write(a);\n end;\n readln;readln;\n end."}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=0 to p do a:=a*10+8;\n for i:=0 to q do a:=a*10;\n write(a);\n end;\n readln;readln;\n end."}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n write(a);\n for i:=1 to q do write(4);\n end;\n readln;readln;\n end."}, {"source_code": "var\n k, ans : int64;\nbegin\n readln(k);\n if k > 36\n then writeln(-1)\n else\n begin\n while k >= 2 do\n begin\n ans := ans * 10 + 8;\n dec(k, 2);\n end;\n if k = 1\n then ans := ans * 10;\n writeln(ans);\n end;\nend."}, {"source_code": "var\nk:longint;\nc:int64;\nbegin\nread(k);\nif k>36 then\nbegin write(-1);\nhalt; end;\nc:=0;\nwhile k>1 do\nbegin dec(k,2);\nc:=c*10+8;\nend;\nif k>0 then\nc:=c*10;\nwrite(c);\nend."}, {"source_code": "const num:array[0..9]of longint=(1,0,0,0,1,0,1,0,2,1);\nvar k,i:longint;\nbegin\n read(k);\n if k>18*2 then\n begin\n writeln('-1');\n exit;\n end;\n for i:=1 to 18 do\n begin\n if k>=2 then\n begin\n write(8);\n dec(k,2);\n end else\n if k=1 then\n begin\n write(0);\n dec(k);\n end;\n if k=0 then break;\n end;\n writeln;\nend."}, {"source_code": "uses math;\n\nvar n, i : longint;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'input.txt');\n{$else}\n\t//assign(input,'road.in'); \n\t//assign(output,'road.out'); \n{$endif}\n\treset(input);rewrite(output);\n\n\treadln(n);\n\n\tif n > 32 then \n\t\twriteln(-1)\n\telse\n\t\tbegin\n\t\t\tfor i := 1 to n div 2 do\n\t\t\t\twrite(8);\n\t\t\tif n mod 2 = 1 then \n\t\t\t\twrite(0);\n\t\tend;\n\n\tclose(input);\n\tclose(output);\nend."}, {"source_code": "uses math;\n\nvar n, i : longint;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'input.txt');\n{$else}\n\t//assign(input,'road.in'); \n\t//assign(output,'road.out'); \n{$endif}\n\treset(input);rewrite(output);\n\n\treadln(n);\n\n\tif n > 36 then \n\t\twriteln(-1)\n\telse\n\t\tbegin\n\t\t\tfor i := 1 to n div 2 do\n\t\t\t\twrite(8);\n\t\t\tif n mod 2 = 1 then \n\t\t\t\twrite(0);\n\t\tend;\n\n\tclose(input);\n\tclose(output);\nend."}, {"source_code": " var k:longint;\nbegin\n readln(k);\n if k>36 then\n writeln(-1)\n else begin\n while k>1 do begin\n write('8');\n dec(k,2);\n end;\n if k>0 then\n writeln(0);\n end;\nend."}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n for i:=1 to q do a:=a*10+0;\n write(a);\n end;\n end."}, {"source_code": "Var z,x,k,i,n: longint;\nbegin\nRead(k);\nIf k>38 then begin Write('-1');exit;end;\nIf k mod 2=0 then begin n:=k div 2;\nFor i:=1 to n do\nWrite('8');\nend else begin n:=(k-1) div 2;\nFor i:=1 to n do\nWrite('8');\nWrite('4');\nend;\nend.\n"}, {"source_code": "Var z,x,k,i,n: longint;\nbegin\nRead(k);\nIf k>19 then begin Write('-1');exit;end;\nIf k mod 2=0 then begin n:=k div 2;\nFor i:=1 to n do\nWrite('8');\nend else begin n:=(k-1) div 2;\nFor i:=1 to n do\nWrite('8');\nWrite('4');\nend;\nend.\n"}, {"source_code": "program hrn;\n var\n a:qword;\n k,p,q,i:longint;\n begin\n read(k);\n if k>36 then write('-1')\n else begin\n p:=k div 2;\n q:=k mod 2;\n for i:=1 to p do a:=a*10+8;\n for i:=1 to q do a:=a*10+0;\n end;\n write(a);\n end."}, {"source_code": "var i:longint;\nvar n:int64;\nbegin\n read(n);\n if n>=37 then begin writeln(-1);exit;end;\n for i:=1 to n div 2 do write(8);\n for i:=1 to n mod 2 do write(0);writeln;\nend."}, {"source_code": "var i,j,k:longint;\n begin\n {assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output); }\n read (k);\n if k>34 then writeln (-1)\n else\n while k-1>0 do\n begin\n write (8);\n k:=k-2;\n end;\n\n if k=1 then write (0);\n\n\n\n\n\n\n\n\n\n end."}, {"source_code": "var i,j,k:longint;\n begin\n { assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output); }\n read (k);\n if k>34 then writeln (-1)\n else\n begin\n while k-1>0 do\n begin\n write (8);\n k:=k-2;\n end;\n if k=1 then write (4);\n end;\n\n\n\n\n\n\n\n\n end.\n"}, {"source_code": "var i,j,k:longint;\n begin\n { assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output); }\n read (k);\n if k>35 then writeln (-1)\n else\n begin\n while k-1>0 do\n begin\n write (8);\n k:=k-2;\n end;\n if k=1 then write (4);\n end;\n\n\n\n\n\n\n\n\n end.\n"}, {"source_code": "const fin='a.inp';fon='a.out';\nvar k,i:longint;\nbegin\n //assign(input,fin);\n //reset(input);\n //assign(output,fon);\n //rewrite(output);\n readln(k);\n for i:=1 to k div 2 do\n write('8');\n if k mod 2<>0 then\n write('4');\nend.\n\n"}, {"source_code": "const fin='a.inp';fon='a.out';\nvar k,i:longint;\nbegin\n //assign(input,fin);\n //reset(input);\n //assign(output,fon);\n //rewrite(output);\n readln(k);\n if k div 2<19 then\n begin\n for i:=1 to k div 2 do\n write('8');\n if k mod 2<>0 then\n write('4');\n end\n else\n write('-1');\nend.\n\n"}, {"source_code": "var k,n,o: integer; \n res: string;\n\nbegin\n readln(k);\n n:= k div 2;\n o:= k mod 2;\n res:='';\n if n+o<=18 then\n begin\n for var i:=1 to n do\n res:=res+'8';\n if o>0 then\n res:=res+'0';\n end\n else\n res:='-1';\n \n writeln(res);\n \nend.\n\n"}, {"source_code": "Var k:integer; s:string; \nBegin\n readln(k);\n if k>36 then writeln('NO') else\n begin\n if k=0 then s:='1';\n If k mod 2 = 1 then begin s:=s+'4'; k:=k-1; end;\n while (k<>0) do\n begin\n s:=s+'8';\n k:=k-2;\n end;\n writeln(s);\n end;\n end."}, {"source_code": "program gg;\nvar k:int64;\nbegin\nread(k);\nif k>34 then begin\nwrite(-1);\nhalt(0);\nend;\nwhile k<>0 do begin\nif k>=2 then begin\nwrite(8);\nk:=k-2;\nend\nelse begin\nwrite(0);\nk:=k-1;\nend;\nend;\nend."}, {"source_code": "program gg;\nvar k:int64;\nbegin\nread(k);\nif k>36 then begin\nwrite(-1);\nhalt(0);\nend;\nwhile k<>0 do begin\nif k>=2 then begin\nwrite(8);\nk:=k-2;\nend\nelse begin\nwrite(0);\nk:=k-1;\nend;\nend;\nend."}, {"source_code": "Program ILoveYou;\nVAR n,i:int64;\nBegin\n\nReadln(n);\n\nif (n > 36) then Writeln('-1') else\nBegin\n\nfor i:=1 to (n div 2) do\nBegin\nWrite('8');\nend;\n\nfor i:=1 to (n mod 2) do\nBegin\nWrite('0');\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": "Var\n k: UInt64;\n\nBegin\n Read(k);\n If k > 36 then Write(-1)\n Else Begin\n For Var i := 1 to k div 2 do\n Write(8);\n If k mod 2 <> 0 then Write(1)\n End;\nEnd."}], "src_uid": "0c9973792c1976c5710f88e3520cda4e"} {"source_code": "Var l,r,a,b:int64;\n d:array[0..123]of int64;\n i:longint;\n can1,can2:boolean;\n begin\n read(l,r);\n d[0]:=1;\n for i:=1 to 62 do\n d[i]:=d[i-1]+d[i-1];\n a:=0;\n b:=0;\n for i:=62 downto 0 do\n begin\n can1:=a+d[i]<=r;\n can1:=can1 and (b+d[i]-1>=l);\n// can1:=can1 and (b)\n can2:=b+d[i]<=r;\n can2:=can2 and (a+d[i]-1>=l);\n if can1 xor can2=true then\n begin\n if can1 then a:=a+d[i]\n else b:=b+d[i];\n continue;\n end;\n if (can1 or can2=false)and(a+d[i]<=r)and(b+d[i]<=r) then\n begin\n a:=a+d[i];\n b:=b+d[i];\n end\n else if can1 and can2 then\n begin\n if a0 do\n Begin\n inc(m[0]);\n m[m[0]]:=z mod 2;\n z:=z div 2;\n end;\nend;\nBegin\n readln(n,k);\n dectobin(a,n);\n dectobin(b,k);\n if n=k\n then Begin\n writeln(0);\n halt(0);\n end;\n for i:=max(a[0],b[0]) downto 1 do\n if a[i]<>b[i]\n then Begin\n res:=1;\n for z:=1 to i do\n res:=res*2;\n writeln(res-1);\n halt(0);\n end;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x, l, r, res : int64;\n bool : boolean;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n read(l, r);\n x := 1152921504606846976;\n while x and r = 0 do\n x := x div 2;\n\n if l and x = 0 then begin\n writeln(x or (x - 1));\n halt;\n end;\n\n res := 0;\n bool := false;\n while x <> 0 do begin\n if (l and x = 0) and (r and x <> 0) then begin\n bool := true;\n res := res or x;\n end;\n if (l and x = 0) and (r and x = 0) and (bool) then begin\n res := res or x;\n end;\n if (l and x <> 0) and (r and x = 0) then begin\n res := res or x;\n end;\n if (l and x <> 0) and (r and x <> 0) and (bool) then begin\n res := res or x;\n end;\n x := x div 2;\n end;\n\n writeln(res);\n\nend.\n "}, {"source_code": "program ZAD_5;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n l,r,st,a,b,s,a1,b1:int64;\n pw:array [0..100] of int64;\n d1,d2:array [1..100] of integer;\n n,i:integer;\n f1,f2:boolean;\nbegin\n readln(l,r);\n pw[0]:=0;\n st:=1;\n a:=l;\n b:=r;\n n:=0;\n while (b>0) do\n begin\n inc(n);\n pw[n]:=st;\n d1[n]:=a mod 2;\n d2[n]:=b mod 2;\n st:=st*2;\n a:=a div 2;\n b:=b div 2;\n end;\n s:=0;\n a1:=0;\n b1:=0;\n f1:=false;\n f2:=false;\n for i:=n downto 1 do\n begin\n if (f1) then d1[i]:=0;\n if (f2) then d2[i]:=1;\n if (d1[i]+d2[i]=2) then\n begin\n if (b1+pw[i]-1>=l) then\n begin\n d2[i]:=0;\n f2:=true;\n end;\n end\n else if (d1[i]+d2[i]=0) then\n begin\n if (a1+pw[i]<=r) then\n begin\n d1[i]:=1;\n f1:=true;\n end;\n end;\n s:=(d1[i] xor d2[i])*pw[i]+s;\n a1:=d1[i]*pw[i]+a1;\n b1:=d2[i]*pw[i]+b1;\n end;\n writeln(s);\n readln;\nend.\n"}, {"source_code": " const cc=1000{000007};\nvar a,b,c,d:array[0..100]of int64;{b:array[0..53,0..53] of boolean;}q,w:char;\n s:string;n,i,j,k:longint;x,y,z,t,m,wg,ng,k1:int64;{c,d,e:array[0..53] of int64;}\nbegin\n a[0]:=1;\n for i:=1 to 64 do a[i]:=a[i-1]*2;\n\n read(x,y);\n if y=x then write(0) else\n begin\n\n while 3=3 do\n begin\n if xa[i] do inc(i);\n if a[i]=x then begin write(a[i+1]-1);halt; end;\n dec(i);\n if (x>=a[i]) and (y = l + 1 then\n write(x xor (x - 1))\n else}\n s1 := 0;\n x := r;\n while x <> 0 do begin\n inc(s1);\n a[s1] := x mod 2;\n x := x div 2;\n end;\n\n s2 := 0;\n x := l;\n while x <> 0 do begin\n inc(s2);\n b[s2] := x mod 2;\n x := x div 2;\n end;\n\n if s1 > s2 then begin\n ans := 1;\n for i := 1 to s1 do\n ans := ans * 2;\n\n write(ans - 1);\n\n end else begin\n for i := s1 downto 1 do begin\n if a[i] = b[i] then\n else\n if (a[i] = 1) and (b[i] = 0) then begin\n ans := i;\n break;\n end;\n end;\n s1 := 1;\n for i := 1 to ans do\n s1 := s1 * 2;\n write(s1 - 1);\n end;\n\n\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=1000001; besk=1000000000;\n nnn=2000000; eps=1e-10; modu=217;\n label 1,2,3,4;\nvar ii,jj,n,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,p,mask,i0,j0,k,step,i,j,start,finish,kol,m:longint;\nll,rr,aa,modul,bb,pp,tt,ot1,ot2,s,kold,ot,kkr:int64;\nostminus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\ndl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\na,f,t,h,kop:array[0..200000] of int64;\nprost,marked,zan: array[0..2000,0..2000] of longint;\nvz:array[0..1500000] of boolean;\nss,ss1,ss2:string;\ndd1,dd: array[-10..5001] of longint;\ngr :array[-10 ..100,-10..100] of longint;\nsss:array[-1000..110000] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(ll,rr);\n if (ll=rr) then begin write(0); goto 1; end;\n { for i:=ll to rr do for j:=ll to rr do ot:=max(ot,i xor j);\n for i:=ll to rr do for j:=ll to rr do if (i xor j=ot) then writeln(i,' ',j);\n writeln;\n writeln(ot); }\n a[0]:=1; for i:=1 to 62 do a[i]:=a[i-1]*2;\n { writeln(a[62]); }\n for i:=0 to 62 do if rr div a[i]>ll div a[i] then ot:=i;\n\n\n writeln(2*a[ot]-1);\n\n 1: close(output);\nend.\n"}, {"source_code": "program zad_276D;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, r, step, max, min : int64;\nbegin\n readln(l, r);\n step := 1;\n while(step * 2 <= r) do\n step := step * 2;\n\n if(l - r = 0) then begin\n writeln(0);\n exit;\n end;\n \n max := 0;\n min := 0;\n while(step > 0) do begin\n if (min < l) and ((min or step) <= r) then begin\n min := min or step;\n if(max < l) and ((max or (step - 1)) < l) then\n max := max or step;\n end else if(max < l) and ((max or step) <= r) then begin\n max := max or step;\n if(min < l) and (min or (step - 1) < l) then\n min := min or step;\n end else if(max or step <= r ) then\n max := max or step\n else if(min or step <= r) then\n min := min or step;\n step := step div 2;\n end;\n\n writeln(max xor min);\n readln(l);\nend.\n"}, {"source_code": "Var i,e,z,l,r,kol:int64;\nv:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n kol:=0; e:=1; z:=r;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n for v:=kol+1 downto 0 do\n begin\n i:=v;\n if (not odd(l shr i)) and ( odd(r shr i))\n then begin writeln(e shl (i+1)-1); halt(0); end;\n end;\n writeln(0)\nend."}, {"source_code": "{$apptype console}\n{$I+,R+,Q+,B-}\nUses SysUtils;\n\nVar\n n,m:int64;\n i,count1,count2,k2:integer;\n a,b,mass:array[1..68]of int64;\n f1:boolean;\n new1,new2:int64;\nBegin\n readln(n,m);\n count1:=0;\n count2:=0;\n mass[1]:=1;\n for i:=1 to 67 do begin\n mass[i+1]:=mass[i]*2;\n a[i]:=0;\n b[i]:=0;\n end;\n\n while n>0 do begin\n inc(count1);\n a[count1]:=n mod 2;\n n:=n div 2;\n end;\n k2:=0;\n while m>0 do begin\n inc(count2);\n b[count2]:=m mod 2;\n if m mod 2=1 then k2:=count2;\n m:=m div 2;\n end;\n f1:=false;\n for i:=k2 downto 1 do begin\n if f1 and (b[i]=0)and(a[i]=0)then a[i]:=1;\n if f1 and (b[i]=1)and(a[i]=1)then b[i]:=0;\n if not f1 and(b[i]>a[i])then f1:=true;\n end;\n new1:=0;\n for i:=k2 downto 1 do new1:=new1+b[i]*mass[i];\n new2:=0;\n for i:=k2 downto 1 do new2:=new2+a[i]*mass[i];\n writeln(new1 xor new2);\nEnd.\n\n\n\n\n\n"}, {"source_code": "uses math;\ntype binchislo=array[0..100] of byte;\nvar a1,b1: binchislo;\n i,t: longint; a,b: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n{ for i:=a1[0] downTO 1 do write(a1[i]); writeln;\n for i:=b1[0] downTO 1 do write(b1[i]); writeln;\n}\n\n if a1[0]0) and (a1[t]=b1[t]) do dec(t);\n writeln(trunc(power(2,t)) - 1)\n end;\n\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,temp: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1); a1[0]:=b1[0];\n\n{ for i:=a1[0] downTO 1 do write(a1[i]); writeln;\n for i:=b1[0] downTO 1 do write(b1[i]); writeln;\n}\n\n rez[0]:=b1[0];\n for i:=b1[0] downto 1 do\n begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then rez[i]:=1\n else begin\n tb1:=b1;ta1:=a1;\n tb1[i]:=0; ta1[i]:=1; rez[i]:=0;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb>=a) and (ta<=b) then rez[i]:=1;\n\n tb1[i]:=1; ta1[i]:=0;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb<=b) and (ta>=a) then rez[i]:=1;\n\n end \n end;\n\n Bintodec(rez,z);\n\n writeln(z);\nend."}, {"source_code": "uses math;\ntype binchislo=array[0..100] of byte;\nvar a1,b1: binchislo;\n t: longint; a,b: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nbegin\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n t:=b1[0];\n while (t>0) and (a1[t]=b1[t]) do dec(t);\n\n a:=1;\n writeln(a shl t - 1)\n\n\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,temp: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1); a1[0]:=b1[0];\n{ for i:=a1[0] downTO 1 do write(a1[i]); writeln;\n for i:=b1[0] downTO 1 do write(b1[i]); writeln;\n}\n\n rez[0]:=0;\n for i:=b1[0] downto 1 do\n begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then begin inc(rez[0]); rez[rez[0]]:=1; end\n else begin\n temp:=0;\n tb1:=b1;ta1:=a1;\n b1[i]:=0; a1[i]:=1;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb>=a) and (ta<=b) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n if temp=0 then begin\n tb1:=b1;ta1:=a1;\n b1[i]:=1; a1[i]:=0;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb<=b) and (ta>=a) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n end;\n if not ((temp=0) and (rez[0]=0)) then begin inc(rez[0]); rez[rez[0]]:=temp end;\n end\n \n end;\n\n z:=0;\n for i:=1 to rez[0] do z:=z*2 + rez[i];\n\n writeln(z);\nend."}, {"source_code": "uses math;\ntype binchislo=array[0..100] of byte;\nvar a1,b1: binchislo;\n t: longint; a,b: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nbegin\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n t:=b1[0];\n while (t>0) and (a1[t]=b1[t]) do dec(t);\n\n writeln(trunc(power(2,t)) - 1)\n\n\nend."}, {"source_code": "var i:longint;\n e,r,l:int64;\nbegin\n readln(l,r);\n if l=r then writeln(0) else begin\n e:=1;\n for i:=62 downto 0 do\n if (odd(r shr i)) and (not odd(l shr i))\n then begin\n writeln(e shl (i+1)-1);\n exit;\n end;\n end;\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n t,a1,b1:Array[0..100] of Int64;\n a,b:Int64;\n i,j:Integer;\nBegin\n Read(a,b);\n t[0]:=1;\n For i:=1 To 60 Do t[i]:=2*t[i-1];\n If a or t[0]=a Then a1[0]:=1\n Else a1[0]:=0;\n For i:=1 To 60 Do\n If a or t[i]=a Then a1[i]:=a1[i-1]+t[i]\n Else a1[i]:=a1[i-1];\n If b or t[0]=b Then b1[0]:=1\n Else b1[0]:=0;\n For i:=1 To 60 Do\n If b or t[i]=b Then b1[i]:=b1[i-1]+t[i]\n Else b1[i]:=b1[i-1];\n j:=-1;\n For i:=0 To 60 Do\n If (t[i]>=a1[i]) and (t[i]<=b1[i]) and (t[i]-1>=a1[i]) and (t[i]-1<=b1[i]) Then j:=i;\n Write(t[j+1]-1);\nEnd.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar a,b,c: Int64;\n m1,m2,m3: array [1..65] of Byte;\n i,j,k,p: Integer;\n x,y: byte;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n Readln(a,b);\n if a>b then\n begin c:=a; a:=b; b:=c end;\n\n i:=1;\n while a>0 do\n begin\n k:=a mod 2;\n a:=a div 2;\n m1[i]:=k;\n Inc(i);\n end;\n\n i:=1;\n while b>0 do\n begin\n k:=b mod 2;\n b:=b div 2;\n m2[i]:=k;\n Inc(i);\n end;\n\n i:=65;\n while m1[i]=m2[i] do\n begin\n// m3[i]:=m1[i];\n dec(i);\n end;\n p:=i;\n\n\n while i>0 do\n begin\n m3[i]:=1;\n Dec(i);\n\n end;\n\n\n\n c:=0;\n i:=p;\n\n\n while i>=1 do begin c:=c*2+m3[i]; Dec(i); end;\n Writeln(c);\n\nend.\n"}, {"source_code": "{$apptype console}\n{$I+,R+,Q+,B-}\nUses SysUtils;\n\nVar\n n,m:int64;\n i,count1,count2,k2:integer;\n a,b,mass:array[1..68]of int64;\n f1:boolean;\n new1,new2:int64;\nBegin\n readln(n,m);\n count1:=0;\n count2:=0;\n mass[1]:=1;\n for i:=1 to 67 do begin\n mass[i+1]:=mass[i]*2;\n a[i]:=0;\n b[i]:=0;\n end;\n\n while n>0 do begin\n inc(count1);\n a[count1]:=n mod 2;\n n:=n div 2;\n end;\n k2:=0;\n while m>0 do begin\n inc(count2);\n b[count2]:=m mod 2;\n if m mod 2=1 then k2:=count2;\n m:=m div 2;\n end;\n f1:=false;\n for i:=k2 downto 1 do begin\n if f1 and (b[i]=0)and(a[i]=0)then a[i]:=1;\n if f1 and (b[i]=1)and(a[i]=1)then b[i]:=0;\n if not f1 and(b[i]>a[i])then f1:=true;\n end;\n new1:=0;\n for i:=k2 downto 1 do new1:=new1+b[i]*mass[i];\n new2:=0;\n for i:=k2 downto 1 do new2:=new2+a[i]*mass[i];\n writeln(new1 xor new2);\nEnd.\n\n\n\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, k, top, top1: integer;\n x, y, res: int64;\n a, b, c, d: array[1..100000] of integer;\n\nfunction good(x: integer): boolean;\nvar\n i: integer;\n x1, x2, x3, x4: int64;\nbegin\n x1 := 0;\n x2 := 0;\n x3 := 0;\n x4 := 0;\n\n for i := top downto x do begin\n x1 := x1 * 2 + a[i];\n x2 := x2 * 2 + b[i];\n x3 := x3 * 2 + c[i];\n x4 := x4 * 2 + d[i];\n end;\n if (x3 < x1) or (x4 < x1) or (x3 > x2) or (x4 > x2) then\n result := false\n else\n result := true;\nend;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(x, y);\n\n top := 0;\n k := 0;\n top1 := 0;\n while (x > 0) do begin\n inc(top);\n a[top] := x mod 2;\n x := x div 2;\n end;\n while (y > 0) do begin\n inc(top1);\n b[top1] := y mod 2;\n y := y div 2;\n end;\n\n if (top1 > top) then\n top := top1;\n\n res := 0;\n\n for i := top downto 1 do begin\n if (a[i] <> b[i]) then begin\n k := i - 1;\n c[i] := a[i];\n d[i] := b[i];\n break;\n end;\n c[i] := a[i];\n d[i] := a[i];\n end;\n\n for i := k downto 1 do begin\n c[i] := 1;\n d[i] := 0;\n if (not good(i)) then begin\n c[i] := 0;\n d[i] := 1;\n end;\n if (not good(i)) then begin\n c[i] := 0;\n d[i] := 0;\n end;\n if (not good(i)) then begin\n c[i] := 1;\n d[i] := 1;\n end;\n end;\n\n for i := top downto 1 do begin\n res := res * 2 + (c[i] xor d[i]);\n end;\n\n writeln(res);\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c: array [0..100] of int64;\n n, j, i: integer;\n l, R, os, ans: int64;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n os := 1;\n for i := 0 to 63 do\n begin\n c[i] := os;\n os := os * 2;\n end;\n read(l, r);\n for i := 63 downto 0 do\n begin\n a[i] := r div c[i];\n r := r mod c[i];\n b[i] := l div c[i];\n l := l mod c[i];\n end;\n ans := 0;\n for i := 63 downto 0 do\n if a[i] - b[i] = 1 then\n begin\n write(c[i] * 2 - 1);\n exit;\n end;\n write('0');\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nl,r,ans : int64;\na,b : array [1..64] of longint;\npow : array [0..64] of int64;\ni,t,len1,len2 : longint;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n pow[0]:=1;\n for i:=1 to 64 do pow[i]:=pow[i-1]*2;\n readln(l,r);\n \n if l = r then\n begin\n writeln(0);\n halt;\n end;\n len1:=0;\n while r > 0 do\n begin\n inc(len1);\n a[len1]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to len1 div 2 do\n begin\n t:=a[i];a[i]:=a[len1 - i + 1];a[len1 - i + 1]:=t;\n end;\n\n len2:=0;\n while l > 0 do\n begin\n inc(len2);\n b[len2]:=l mod 2;\n l:=l div 2;\n end;\n for i:=1 to len2 div 2 do\n begin\n t:=b[i];b[i]:=b[len2 - i + 1];b[len2 - i + 1]:=t;\n end;\n\n for i:=len2 downto 1 do b[i + len1 - len2]:=b[i];\n for i:=1 to len1 - len2 do b[i]:=0;\n\n for i:=1 to len1 do\n if (a[i] = 1) and (b[i] = 0) then\n begin\n ans:=pow[len1 - i + 1] - 1;\n writeln(ans);\n break;\n end;\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\ntype point = record x,y:integer; end;\n\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If m=1 do\n begin\n if x mod 2=0 then s:='0'+s\n else s:='1'+s;\n x:=x div 2;\n end;\nt:='';\nwhile y>=1 do\n begin\n if y mod 2=0 then t:='0'+t\n else t:='1'+t;\n y:=y div 2;\n end;\nwhile length(s)x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If m=1 do\n begin\n if x mod 2=0 then s:='0'+s\n else s:='1'+s;\n x:=x div 2;\n end;\nt:='';\nwhile y>=1 do\n begin\n if y mod 2=0 then t:='0'+t\n else t:='1'+t;\n y:=y div 2;\n end;\nwhile length(s) 0 do begin\n ls := inttostr(l mod 2) + ls;\n l := l div 2;\n end;\n while r > 0 do begin\n rs := inttostr(r mod 2) + rs;\n r := r div 2;\n end;\n while length(ls) < length(rs) do\n ls := '0' + ls; \n j := 1;\n c := '';\n while (j <= length(ls))and(ls[j] = rs[j]) do begin\n inc(j);\n end;\n for i := j to length(rs) do\n c := c + '1';\n o := 1;\n for i := length(c) downto 1 do begin\n ans := ans + strtoint(c[i]) * o;\n o := o * 2;\n end;\n write(ans);\nend.\n"}, {"source_code": "program TD;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\nconst\n maxn = round(1e+18);\n\nvar\n i: integer;\n l, r: int64;\n first: array [1..100000] of integer;\n second: array [1..100000] of integer;\n size1, size2: integer;\n\n\nfunction get(x: integer): int64;\nvar\n i: integer;\n cur: int64;\nbegin\n cur := 1;\n for i := 1 to x do\n cur := cur * 2;\n result := cur;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'TD.in');\n rewrite(output, 'TD.out');\n {$ENDIF}\n readln(l, r); size1 := 0; size2 := 0;\n while (l > 0) do begin\n inc(size1);\n first[size1] := l mod 2;\n l := l div 2;\n end;\n while (r > 0) do begin\n inc(size2);\n second[size2] := r mod 2;\n r := r div 2;\n end;\n if (size2 > size1) then begin\n write(get(size2) - 1);\n halt(0);\n end;\n for i := size2 downto 1 do\n if (first[i] <> second[i]) then begin\n writeln((get(i) - 1));\n halt(0);\n end;\n write(0);\nend.\n\n"}, {"source_code": "var\n i:longint;\n r,l:int64;\nbegin\n readln(l,r);\n l:=l xor r;\n for i:=1 to 64 do l:=l or (l div 2);\n writeln(l);\nend.\n"}, {"source_code": "Program LittleGirlAndMaximumXOR;\nvar\nl,r, hasil : int64;\nA,B : array [1..101] of integer;\ni : integer;\nbegin\nfor i := 1 to 101 do begin A[i] := 0; B[i] := 0; end;\nreadln(l,r);\ni := 101;\nwhile (l <> 0) do\nbegin\n dec(i);\n A[i] := l mod 2;\n l := l div 2;\nend;\n\ni := 101;\nwhile (r <> 0) do\nbegin\n dec(i);\n B[i] := r mod 2;\n r := r div 2;\nend;\n\nfor i := 1 to 101 do\n if A[i] <> B[i] then break;\ni := 101 - i; //pangkat\nhasil := 1;\nwhile (i <> 0) do\n begin\n hasil := hasil * 2;\n dec(i);\n end;\ndec(hasil);\nwriteln(hasil);\nend.\n//Created by freedomofkeima"}, {"source_code": "type\n arr=array[0..1000]of longint;\nvar\n a,b,m:arr;\n l,r,k,p,q:int64;\n i,j:longint;\nprocedure plus(var a:arr; b:arr);\n var\n i:longint;\n begin\n for i:=1 to l do\n begin\n a[i]:=a[i]+b[i];\n a[i+1]:=a[i+1]+a[i] div 10;\n a[i]:=a[i] mod 10;\n end;\n if a[i+1]>0 then inc(i);\n while a[i]>9 do\n begin\n inc(i);\n a[i]:=a[i]+a[i-1] div 10;\n a[i-1]:=a[i-1] mod 10;\n end;\n if i>l then l:=i;\n end;\n\nbegin\n readln(l,r);\n fillchar(a,sizeof(a),0);\n k:=l;\n p:=0;\n while k>0 do\n begin\n inc(p);\n a[p]:=k mod 2;\n k:=k div 2;\n end;\n k:=r;\n q:=0;\n while k>0 do\n begin\n inc(q);\n b[q]:=k mod 2;\n k:=k div 2;\n end;\n for i:=q downto 0 do\n if a[i]<>b[i] then break;\n p:=i;\n if p=0 then\n begin\n writeln('0');\n halt;\n end;\n fillchar(m,sizeof(m),0);\n m[1]:=1;\n l:=1;\n for i:=1 to p do\n plus(m,m);\n for i:=l downto 2 do\n write(m[i]);\n writeln(m[1]-1);\nend."}, {"source_code": "{$H+}\nVar l,r,res:int64;\n fi,fo:text;\n\nProcedure Doc;\n Var i:longint;\n Begin\n Read(fi,l,r);\n end;\n\nProcedure Lam;\n Var i,j:longint;\n Begin\n If l=r then\n begin\n Write(fo,0);\n exit;\n end;\n For i:=63 downto 0 do\n If (l and (int64(1) shl i))<>(r and (int64(1) shl i)) then\n break;\n For j:=0 to i do res:=res+int64(1) shl j;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n\n"}, {"source_code": "var\nl,r,rr,ll,otv:int64;\ni,j:longint;\nmas,mas1:array [1..1000] of longint;\nBegin\n readln(l,r);\n rr:=0;\n while (r<>0) do \n Begin\n inc(rr);mas[rr]:=r mod 2; r:=r div 2;\n End;\n for i:=1 to rr do \n Begin\n mas1[i]:=l mod 2; l:=l div 2;\n End; \n i:=rr;otv:=1;\n while (i<>0) and(mas1[i]=mas[i]) do dec(i);\n \n for j:=1 to i do \n otv:=otv*2;\n writeln(otv-1);\nEnd."}, {"source_code": "program abc;\n\nvar\n k, q, l, r: int64;\n i: byte;\n\nbegin\n readln(l, r); \n\n for i := 60 downto 0 do\n begin\n q := int64(1) shl i; \n if ((l < q) and (r >= q)) then\n begin\n writeln(2 * q - 1);\n exit;\n end;\n if (l >= q) then\n begin\n l := l - q;\n r := r - q;\n end;\n end; \n writeln(0);\nend."}, {"source_code": "uses math;\nlabel print;\nvar\n l,r,cur,ans,qw:int64;\n i,pow:longint;\n\nfunction pow_( p :longint):int64;\nvar\n res:int64;\nbegin\n res:=1;\n for i:=1 to p do inc(res,res);\n pow_:=res;\nend;\n\nbegin\n readln(l,r);\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n cur:= r xor l;\n pow:=trunc(ln(r) / ln(2));\n if pow_(pow+1) <= r then inc(pow);\n if pow_(pow) < l then goto print;\n cur:=max((pow_(pow)) xor r, cur);\n cur:=max((pow_(pow)) xor l, cur);\n if (pow_(pow) > l) then cur:=max(cur,pow_(pow) xor (pow_(pow) - 1));\n if (pow_(pow) < r) then cur:=max(cur,pow_(pow) xor (pow_(pow) + 1));\n print:\n pow:=trunc(ln(cur) / ln(2));\n if pow_(pow) <=cur then inc(pow);\n writeln(pow_(pow)-1);\nend.\n\n\n\n"}, {"source_code": "const n = 62;\nvar\n ans,l,r : int64;\n i : longint;\n sl,sr,tl,tr : string;\n\nfunction check(ll,rr : string) : boolean;\nvar\n ml,mr,x : int64;\n i : longint;\nbegin\n ml := 0;\n mr := 0;\n x := 1;\n i := n;\n while i >= 1 do begin\n if ll[i] = '1' then ml := ml + x;\n x := x * 2;\n dec(i);\n end;\n x := 1;\n i := n;\n while i >= 1 do begin\n if rr[i] = '1' then mr := mr + x;\n x := x * 2;\n dec(i);\n end;\n if ml < l then exit(false);\n if mr > r then exit(false);\n if mr < l then exit(false);\n if ml > r then exit(false);\n if ml xor mr > ans then ans := ml xor mr;\n exit(true);\nend;\n\nbegin\n readln(l,r);\n ans := - 1 shl 60;\n sl := binstr(l,n);\n sr := binstr(r,n);\n\n for i := 1 to n do begin\n tl := sl;\n tr := sr;\n tl[i] := '0';\n tr[i] := '1';\n if check(tl,tr) then begin sl := tl; sr := tr; continue; end;\n tl := sl;\n tr := sr;\n tl[i] := '1';\n tr[i] := '0';\n if check(tl,tr) then begin sl := tl; sr := tr; continue; end;\n tl := sl;\n tr := sr;\n tl[i] := '1';\n tr[i] := '1';\n if check(tl,tr) then begin sl := tl; sr := tr; continue; end;\n tl := sl;\n tr := sr;\n tl[i] := '0';\n tr[i] := '0';\n if check(tl,tr) then begin sl := tl; sr := tr; continue; end;\n end;\n\n writeln(ans);\nend.\n"}, {"source_code": "{$M 100000000}\nuses math;\nvar\nans,l,r,ll:int64;\nfunction can(s1,s2,n:int64):boolean;\nbegin\n if (s1>r)or(s2>r) then exit(false);\n s1:=l-s1;\n s2:=l-s2;\n if ((s1<0)or(s1<=(ll<0 do begin\n inc(i);\n a[i]:=l mod 2;\n l:=l div 2;\n end;\n l:=i; a[0]:=1;\n\n i:=0;\n while r>0 do begin\n inc(i);\n b[i]:=r mod 2;\n r:=r div 2;\n end;\n if i>l then l:=i; b[0]:=0;\n\n\n i:=l;\n while a[i]=b[i] do dec(i);\n\n writeln(t[i]-1);\nend."}, {"source_code": "var bit:array[0..100]of int64;\n\nfunction get(x,y:int64):int64;\nbegin\n get:=(x shr y) and 1;\nend;\n\nprocedure nhap;\nvar i,n:longint;\n x1,x2,chot,pivot,left,right:int64;\nbegin\n readln(left,right);\n for i:=0 to 62 do if get(right,i)=1 then n:=i;\n pivot:=0; chot:=-1;\n for i:=n downto 0 do if get(right,i)=get(left,i) then begin\n if get(right,i)=1 then pivot:=pivot or bit[i];\n end\n else begin chot:=i; break; end;\n x1:=pivot; if chot<>-1 then x1:=x1 or bit[chot];\n x2:=pivot; for i:=chot-1 downto 0 do x2:=x2 or bit[i];\n writeln(x1 xor x2);\nend;\n\nprocedure init;\nvar i:longint;\nbegin\n bit[0]:=1;\n for i:=1 to 62 do bit[i]:=bit[i-1]*2;\nend;\n\nbegin\n init;\n nhap;\nend."}, {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n a , b , ans : array[1..100] of integer;\n pow : array[0..100] of int64;\n l , r , res , t1 , top : int64;\n i , j , tmp : integer;\n tm : boolean;\n\nbegin\n // assign(input , 'input.txt') ; reset(input);\n // assign(output , 'output.txt') ; rewrite(output);\n\n pow[0] := 1;\n for i := 1 to 62 do pow[i] := pow[i - 1] * 2;\n\n readln(l , r);\n if l = r then begin writeln(0);halt;end;\n while r > 0 do\n begin\n inc(t1);\n a[t1] := r mod 2;\n r := r div 2;\n end;\n for i := 1 to t1 div 2 do\n begin\n tmp := a[i];\n a[i] := a[t1 - i + 1];\n a[t1 - i + 1] := tmp;\n end;\n\n top := t1;\n while l > 0 do\n begin\n b[top] := l mod 2;\n l := l div 2;\n dec(top);\n end;\n for i := 1 to t1 do\n begin\n if b[i] = 0 then\n begin\n if tm then begin ans[i] := 1; continue;end;\n ans[i] := a[i];\n if ans[i] = 1 then tm := true;\n end\n else break;\n end;\n if i > 1 then tm := true;\n for j := i to t1 do\n begin\n if (a[j] = 1) and (b[j] = 0) and tm then\n begin\n ans[j] := 1; continue;\n tm := true;\n end;\n if (a[j] = 1) and tm then\n begin\n ans[j] := 1;\n continue;\n end;\n if (b[j] = 0) and tm then\n begin\n ans[j] := 1; continue;\n end;\n ans[j] := a[j] xor b[j];\n if ans[j] = 1 then tm := true;\n end;\n\n for i := 1 to t1 do\n res := res + pow[t1 - i] * ans[i];\n writeln(res);\nend."}, {"source_code": "var l,r,x: int64;\n\nfunction Between(x,a,b: int64): boolean;\nbegin\n if (x>=a) and (x<=b) then Between:=true\n else Between:=false;\nend;\n\nbegin\n x:=(1 shl 62)-1;\n\n readln(l,r);\n\n if l=r then writeln(0)\n else\n BEGIN\n while x>=0 do\n begin\n\n if (Between(x xor l,l,r) or Between(x xor r,l,r)) then\n begin\n writeln(x);\n break;\n end;\n\n x:=(x+1) div 2;\n x:=x-1;\n end;\n END;\nend."}, {"source_code": "var\nq:longint;\nw,e,r,t,y,u,i,o,p:int64;\na,s,d:array[1..100]of longint;\nbegin\nreadln(y,u);\nwhile y<>0 do begin inc(e); a[e]:=y mod 2; y:=y div 2;\n//write(a[e]);\nend;// writeln;\n\nwhile u<>0 do begin inc(r); s[r]:=u mod 2; u:=u div 2;\n//write(s[r]);\nend; //writeln;\nif r>e then p:=r else p:=e;\n //writeln(p);\nwhile a[p]=s[p] do\n begin\n dec(p);\n if p=0 then break;\n end;\nt:=1;\nfor q:=1 to p do t:=t*2;\nt:=t-1;\nwriteln(t);\nend."}, {"source_code": "{$Mode objfpc}\n\n\nvar\n a, b: int64;\n i, p: integer;\n m2: array[1.. 64] of qword;\n\nfunction bit(i: int64; j: integer): integer;\nbegin\n result:= i shr j and 1;\nend;\n\nbegin\n readln(a, b);\n m2[0]:= 1;\n for i:= 1 to 64 do m2[i]:= m2[i- 1]* 2;\n p:= -1;\n for i:= 63 downto 0 do if bit(a, i)<> bit(b, i) then begin\n p:= i;\n break;\n end;\n writeln(m2[p+ 1]- 1);\nend."}, {"source_code": "uses math;\n\nvar n:longint;\n L,R:string;\n s1,s2:int64;\n f,nho:array[1..65,0..1,0..1,0..1,0..1] of int64;\n gt:array['0'..'1'] of longint=(0,1);\n\nprocedure MoFile;\nbegin\n assign(input,'test.inp');\n assign(output,'test.out');\n reset(input);\n rewrite(output);\nend;\n\nprocedure DongFile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure Doc;\nvar i,j,k:int64;\n add:array[0..1] of char=('0','1');\nbegin\n read(s1,s2);\n i:=s1;\n j:=s2;\n L:='';\n while i>0 do\n begin\n k:=i mod 2;\n i:=i div 2;\n L:=add[k]+L;\n end;\n R:='';\n while j>0 do\n begin\n k:=j mod 2;\n j:=j div 2;\n R:=add[k]+R;\n end;\n while length(L)gt[L[p]]) then _aL:=0;\n if (aR=1) and (igt[L[p]]) then _bL:=0;\n if (bR=1) and (j>i,l>>i]\n then begin\n b:=t<>i))<>i))<>i))<0 then exit(f[i,l1,l2,r1,r2]);\n res:=0;\n if i>k then exit(0);\n for i1:=0 to 1 do\n for i2:=0 to 1 do\n begin\n ll1:=0; ll2:=0; rr1:=0; rr2:=0;\n ok1:=false;\n ok2:=false;\n if i1=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l1=1)) then ok1:=true;\n if a2[i]=1 then rr1:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r1=1)) then ok1:=true;\n if a1[i]=0 then ll1:=1;\n end;\n if i2=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l2=1)) then ok2:=true;\n if a2[i]=1 then rr2:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r2=1)) then ok2:=true;\n if a1[i]=0 then ll2:=1;\n end;\n if (not ok1)or(not ok2) then continue;\n if (i1=0)and(i2=0) then\n begin\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)));\n continue;\n end;\n if (i1=1)and(i2=1) then\n begin\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)));\n continue;\n end;\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1+1);\n end;\n exit(f[i,l1,l2,r1,r2]);\n end;\n\nbegin\n readln(l,r);\n while (l>0) do\n begin\n inc(k);\n a1[k]:=l mod 2;\n l:=l div 2;\n end;\n k:=0;\n while r>0 do\n begin\n inc(k);\n a2[k]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to k div 2 do\n begin\n swap(a1[i],a1[k-i+1]);\n swap(a2[i],a2[k-i+1]);\n end;\n writeln(rec(1,0,0,0,0));\nend.\n"}, {"source_code": "var x,y,i,ans:qword;\nbegin\nwhile not eof do begin\n readln(x,y);\n ans:=0;\n i:=1;\n while i<=y do begin\n if y div i > x div i then ans:= ans or i;\n i:=i shl 1;\n end;\n writeln(ans);\nend;\nend.\n"}, {"source_code": "\nvar a, b, c : int64;\n i : longint;\n \nbegin\n read(a, b);\n c := a xor b;\n for i := 1 to 100 do c := c or (c shr 1);\n writeln(c);\nend."}, {"source_code": "var l,r,q:int64;\n i:longint;\n begin\n read(l,r);\n q:=l xor r;\n for i:=63 downto 0 do\n begin\n if q and (int64(1)<0 then\n begin\n writeln((int64(1)<<(i+1))-1);\n halt(0);\n end;\n end;\n writeln(0);\n end."}, {"source_code": "program z;\n var\n l,r:int64;\n i:longint;\n begin\n read(l,r);\n r:=r xor l;\n for i:=1 to 100 do\n begin\n r:=r or (r shr 1);\n end;\n write(r);\nend."}, {"source_code": "var l,r:int64;\n a,b:array[1..64] of longint;\n res:int64;\n i,d,p:longint;\n\nbegin\n readln(l,r);\n while (r>0) do\n begin\n inc(d);\n a[d]:=l mod 2;\n b[d]:=r mod 2;\n l:=l div 2;\n r:=r div 2;\n end;\n p:=d+1;\n for i:=d downto 1 do\n if a[i]=b[i] then\n p:=i\n else break;\n dec(p);\n l:=1;\n writeln(l shl p-1);\nend."}, {"source_code": "var a,b,a1,b1,x,y,l,z,r:int64;\n i:longint;\n bo:boolean;\nfunction ok(x:int64):boolean;\nbegin\n if (x>=a1) and (x<=b1) then ok:=true else ok:=false;\nend;\nbegin\n readln(a,b);\n a1:=a;\n b1:=b;\n x:=a;\n y:=b;\n z:=1;\n bo:=true;\n while y>0 do\n begin\n if (bo) and (x and 1=y and 1) then\n begin\n if x and 1=1 then b:=b-z else a:=a+z;\n if (not ok(a)) or (not ok(b)) then bo:=false;\n end;\n if bo then r:=r+z;\n z:=z*2;\n x:=x shr 1;\n y:=y shr 1;\n end;\n writeln(r);\nend.\n"}, {"source_code": "var a,b,l,z,r:int64;\n i:longint;\n ma:array[0..3,0..500] of longint;\n bo:boolean;\nprocedure pretvori(x,y:int64);\nbegin\n l:=0;\n while x>0 do\n begin\n l:=l+1;\n ma[y,l]:=x and 1;\n x:=x shr 1;\n end;\nend;\nfunction ok(x:longint):boolean;\nvar o,r:int64;\n i:longint;\nbegin\n o:=1;\n r:=0;\n for i:=1 to l do\n begin\n r:=r+o*ma[x,i];\n o:=o*2;\n end;\n if (r>=a) and (r<=b) then ok:=true else ok:=false;\nend;\nbegin\n readln(a,b);\n pretvori(a,1);\n pretvori(b,2);\n z:=1;\n bo:=true;\n for i:=1 to l do\n begin\n if (bo) and (ma[1,i]=ma[2,i]) then\n begin\n if ma[1,i]=1 then ma[2,i]:=0 else ma[1,i]:=1;\n if (not ok(1)) or (not ok(2)) then bo:=false;\n end;\n if bo then r:=r+z;\n z:=z*2;\n end;\n writeln(r);\nend.\n"}, {"source_code": "uses math;\nvar ans,res,l,r,pw2:int64;\n\n begin\n readln(l,r);\n res:=l xor r;\n pw2:=1;\n while pw2*2<=r do pw2:=pw2*2;\n if (pw2>=l) then\n begin\n if (pw2+1<=r) then res:=max(res, pw2 xor (pw2+1));\n if (pw2-1>=l) then res:=max(res, pw2 xor (pw2-1));\n res:=max(res,pw2 xor r);\n res:=max(res,pw2 xor l);\n end;\n ans:=1;\n while true do\n begin\n if ans-1>=res then begin writeln(ans-1); halt; end;\n ans:=ans+ans;\n end;\n end.\n"}, {"source_code": "var\n a,b,p:array[-1..100] of int64;\n x,y,l,r:int64;\n i,m:longint;\nbegin\np[0]:=1;\nfor i:=1 to 63 do\n begin\n p[i]:=p[i-1]*2;\n a[i]:=0;\n b[i]:=0;\n end;\nreadln(l,r);\nm:=0;\nx:=l;\ny:=r;\nwhile l<>0 do\n begin\n inc(m);\n a[m]:=l mod 2;\n l:=l div 2;\n end;\nm:=0;\nwhile r<>0 do\n begin\n inc(m);\n b[m]:=r mod 2;\n r:=r div 2;\n end;\nfor i:=m downto 1 do\n if a[i]=b[i] then\n begin\n if b[i]=1 then\n begin\n if y-p[i-1]>=x then y:=y-p[i-1];\n end else\n if a[i]=0 then\n begin\n if x+p[i-1]<=y then x:=x+p[i-1];\n end;\n end;\nwrite(x xor y);\nend.\n"}, {"source_code": "PROGRAM FooXor;\n\tConst PowersOfTwo : array[0..65] of QWord =\n\t\t(0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,\n\t\t4096, 8192, 16384, 32768, 65536, 131072, 262144,\n\t\t524288, 1048576, 2097152, 4194304, 8388608, 16777216,\n\t\t33554432, 67108864, 134217728, 268435456, 536870912,\n\t\t1073741824, 2147483648, 4294967296, 8589934592,\n\t\t17179869184, 34359738368, 68719476736, 137438953472,\n\t\t274877906944, 549755813888, 1099511627776, 2199023255552,\n\t\t4398046511104, 8796093022208, 17592186044416,\n\t\t35184372088832, 70368744177664, 140737488355328,\n\t\t281474976710656, 562949953421312, 1125899906842624,\n\t\t2251799813685248, 4503599627370496, 9007199254740992,\n\t\t18014398509481984, 36028797018963968, 72057594037927936,\n\t\t144115188075855872, 288230376151711744, 576460752303423488,\n\t\t1152921504606846976, 2305843009213693952,\n\t\t4611686018427387904, 9223372036854775808, 18446744073709551615);\n\tVar l, r, p : QWord;\n\n\tFunction Search(num : QWord): LongInt;\n\t\tVar tmp : LongInt;\n\tBegin\n\t\ttmp:=-1;\n\t\trepeat Inc(tmp) until PowersOfTwo[tmp+1]>num;\n\t\tSearch:=tmp\n\tEnd;\n\nBEGIN\n\tReadLn(l, r);\n\tif l=r then begin\n\t\tWriteLn('0');\n\t\tHalt(0)\n\tend;\n\n\twhile Search(l) = Search(r) do begin\n\t\tp:=PowersOfTwo[Search(l)];\n\t\tl:=l - p;\n\t\tr:=r - p\n\tend;\n\n\tWriteLn(PowersOfTwo[Search(r)+1]-1)\nEND.\n"}, {"source_code": "var\ni : longint;\n l,r : int64;\nbegin\n readln(l,r);\n for i:=0 to 100 do\n if (l xor r<=int64(1) shl int64(i)-1) then begin writeln(int64(1) shl int64(i)-1); exit; end;\nend."}, {"source_code": "var l,r,answer,step,cur:int64;\nbegin\n readln(l,r);\n answer:=0;\n step:=1;\n while lanswer then answer:=cur;\n end;\n writeln(answer);\nend."}, {"source_code": "const inp='';\n outp='';\nvar l,r,ans,kol:int64;\nbegin\n assign(input,inp);\n assign(output,outp);\n reset(input);\n readln(l,r);\n close(input);\n if l=r\n then ans:=0\n else begin\n kol:=1;\n while kol*2<=r do kol:=kol*2;\n if kol>l\n then ans:=(kol)xor(kol-1)\n else begin\n r:=l xor r;\n kol:=1;\n while kol*2<=r do kol:=kol*2;\n ans:=(kol)xor(kol-1);\n end;\n end;\n rewrite(output);\n writeln(ans);\n close(output);\nend.\n"}, {"source_code": "const inp='';\n outp='';\nvar l,r,ans,kol:int64;\nbegin\n assign(input,inp);\n assign(output,outp);\n reset(input);\n readln(l,r);\n close(input);\n if l=r\n then ans:=0\n else begin\n r:=l xor r;\n kol:=1;\n while kol*2<=r do kol:=kol*2;\n ans:=(kol)xor(kol-1);\n end;\n rewrite(output);\n writeln(ans);\n close(output);\nend.\n"}, {"source_code": "var\n l,r : int64;\n i : longint;\n\nbegin\n readln(l,r);\n r:=l xor r;\n for i:=1 to 64 do r:=r or (r >> 1);\n writeln(r);\nend."}, {"source_code": "var\n l,r,d,b,ret,pos:int64;\nbegin\n read(l,r);\n d:=r-l;\n b:=1;\n ret:=0;\n pos:=0;\n while d>=b do\n begin\n ret:=ret+b;\n b:=b*2;\n inc(pos);\n end;\n while r>=b do\n begin\n if (((l shr pos) xor (r shr pos)) and 1)=1 then ret:=ret+b;\n b:=b*2;\n inc(pos);\n end;\n write(ret);\nend."}, {"source_code": "var l,r:int64;\n i:longint;\n begin\n read(l,r);\n l:=l xor r;\n for i:=1 to 64 do\n l:=l or (l shr 1);\n writeln(l);\n end."}, {"source_code": "var\n a,b,x,y:array[1..10000] of byte;\n l,r,t:int64;\n i,j,n,m,p:longint;\nbegin\n readln(l,r);\n if l=r then begin writeln(0); exit; end;\n while l<>0 do\n begin\n inc(n);\n a[n]:=l mod 2;\n l:=l div 2;\n end;\n while r<>0 do\n begin\n inc(m);\n b[m]:=r mod 2;\n r:=r div 2;\n end;\n for i:=m downto 1 do\n if a[i]<>b[i]\n then begin p:=i; break; end;\n\n for i:=1 to p-1 do\n begin\n x[i]:=1;\n y[i]:=0;\n end;\n x[p]:=0;\n y[p]:=1;\n for i:=p+1 to m do\n begin\n x[i]:=a[i];\n y[i]:=a[i];\n end;\n\n t:=1; l:=0; r:=0;\n for i:=1 to m do\n begin\n l:=l+x[i]*t;\n r:=r+y[i]*t;\n t:=t*2;\n end;\n\nwriteln(l xor r);\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:qword;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n { for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans);\n writeln; }\n\n if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n\n\n while (t>0)and(a[t]=b[t]) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0; }\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1);\n end;\nend.\n\n"}, {"source_code": "uses math;\nconst\n nmax = 100;\nvar\n n,m:longint;\n res,aa,bb:int64;\n a,b:string;\nprocedure progress;\nvar i,j,u,v:longint;\nbegin\n read(aa,bb);\n while aa<>0 do\n begin\n a:=chr(aa mod 2+48)+a;\n aa:=aa div 2;\n end;\n while bb<>0 do\n begin\n b:=chr(bb mod 2+48)+b;\n bb:=bb div 2;\n end;\n while length(a)length(a) then writeln(0)\n else\n begin\n for j:=i to length(a) do\n res:=res+ int64(1) shl (length(a)-j);\n writeln(res);\n end;\nend;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n progress;\n close(input);\n close(output);\nend."}, {"source_code": "program bai4;\nconst finp='test.inp';\nvar f:text;\n\tl,r,kq:qword;\n i,j:longint;\nBEGIN\n\treadln(l,r);\n for i:=62 downto 0 do\n begin\n if (r shr i and 1=1) and (l shr i and 1=0) then\n begin\n \tkq:=1;\n \tfor j:=1 to i+1 do kq:=kq*2;\n kq:=kq-1;\n writeln(kq);\n// kq:=1 shl (i+1)-1;\n exit;\n end;\n end;\n writeln(0);\nEND."}, {"source_code": "var i:longint;\n l,r,x,y:qword;\n a:array[0..101] of qword;\n begin\n read(l,r);\n\n\n a[0]:=1;\n for i:=1 to 63 do\n a[i]:=a[i-1]*2;\n\n x:=0;\n y:=0;\n for i:=63 downto 0 do\n begin\n if (x+a[i]<=r) and\n (y+a[i]-1>=l) then begin x:=x+a[i]; end\n else\n if (y+a[i]<=r) and\n (x+a[i]-1>=l) then begin y:=y+a[i]; end\n else\n if (x+a[i]-1= l ) and ( tmp <= r ) then\n begin\n a := tmp;\n continue;\n end;\n tmp := ChangeBit( i , b );\n if ( tmp >= l ) and ( tmp <= r ) then\n begin\n b := tmp;\n continue;\n end;\n end;\n writeln( a xor b );\nend.\n\n"}, {"source_code": "var\n l,r,ans : int64;\n i : longint;\nbegin\n readln(l,r);\n ans:=l xor r;\n for i:=1 to 64 do\n ans:=ans or (ans shr 1);\n writeln(ans);\nend."}, {"source_code": "var\tl,r:int64;\ni:longint;\nbegin\nreadln (r,l);\nfor i:=0 to 100 do\n\tif (l xor r<= int64(1) shl (i) -1) then\n\tbegin\n\t\twriteln (int64(1) shl i -1);\n\t\tbreak;\n\tend;\nend.\n"}, {"source_code": "uses math;\nvar a,b,c: array [1..100] of longint;\ni,j,n,m: longint;\nx,y:int64;\nans,p: int64;\nff: boolean;\nprocedure check;\nbegin\nans:= 0;p:= 1;\nfor i:= 1 to n do\n begin\n ans:= ans+ p*c[i];\n p:= p *2;\n end;\nwriteln (ans);\nend;\n\nbegin\n//assign (input, 'input.txt'); reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (x,y);\ni:= 1;\nwhile x<>0 do\n begin\n a[i]:= x mod 2;\n x:= x div 2;\n inc (i);\n end; n:= i-1;\ni:= 1;\nwhile y<>0 do\n begin\n b[i]:= y mod 2;\n y:= y div 2;\n inc (i);\n end; m:= i-1;\n//for i:= n downto 1 do write (a[i]); writeln;\nn:= max (n,m);\nff:= false;\nfor i:= n downto 1 do\n begin\n if a[i]<>b[i] then ff:= true;\n if a[i]=b[i] then\n if ff then\n begin\n for j:= n downto i+1 do\n begin\n if a[j]<>b[j] then c[j]:= 1;\n if a[j]=b[j] then c[j]:= 0;\n end;\n for j:= i downto 1 do c[j]:= 1;\n check;\n halt;\n end;\n\n end;\nfor j:= n downto 1 do\n begin\n if a[j]<>b[j] then c[j]:= 1;\n if a[j]=b[j] then c[j]:= 0;\n end;\n\ncheck;\n //close (input);close (output);\nend.\n"}, {"source_code": "var a,b,p:int64;\nbegin\n readln(a,b);\n p:=1<<62;\n while (p<>0) and (a and p=b and p) do p:=p>>1;\n if p=0 then writeln(0)\n else writeln((p<<1)-1);\nend."}, {"source_code": "var stl,str1 : ansistring;\n l,r,l1,r1,k,la,ra,k1 : int64;\n i :longint;\nfunction vdes(st : ansistring) : int64;\nvar s,r : int64;\n a,i,kod : longint;\nbegin\n s:=0; r:=1;\n for i:=length(st) downto 1 do\n begin\n if st[i]='1' then s:=s + r;\n r:=r*2;\n end;\n vdes:=s;\nend;\nbegin\n read(l,r);\n l1:=l; r1:=r;\n while l1<>0 do\n begin\n if l1 mod 2=0 then stl:='0'+stl else stl:='1'+stl;\n l1:=l1 div 2;\n end;\n while r1<>0 do\n begin\n if r1 mod 2=0 then str1:='0'+str1 else str1:='1'+str1;\n r1:=r1 div 2;\n end;\n\n la:=length(stl); ra:=length(str1); l1:=ra-la;\n for i:=la downto 1 do\n begin\n if stl[i]=str1[i+l1] then\n begin\n if stl[i]='0' then\n begin\n stl[i]:='1';\n k:=vdes(stl);\n if (k>=l) and (k<=r) then k:=k else\n begin\n stl[i]:='0';\n str1[i+l1]:='1';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else str1[i+l1]:='0';\n end;\n end else\n begin\n stl[i]:='0';\n k:=vdes(stl);\n if (k>=l) and (k<=r) then k:=k else\n begin\n stl[i]:='1';\n str1[i+l1]:='0';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else\n str1[i+l1]:='1';\n end;\n end;\n end\n end;\n while length(stl)=l) and (k<=r) then stl[1]:='0' else break;\n end;\n\n for i:=l1 downto 1 do\n begin\n str1[i]:='1';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else\n begin\n str1[i]:='0';\n stl[i]:='1';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else stl[i]:='0';\n end;\n end;\n k1:=vdes(stl);\n k:=vdes(str1);\n\n writeln(k xor k1);\nend.\n"}, {"source_code": "var l,t,ans,a,r,k,b:int64;\nbegin\n read(l,r);\n a:=1;\n while ar then a:=a div 2;\n if l<=a-1 then begin\n write(a*2-1);\n halt;\n end;\n a:=a*2;\n k:=(a xor l) xor (a xor r);\n b:=1;\n while b<=k do\n b:=b*2;\n write(b-1);\n\n\nend."}, {"source_code": "var\n a:array[0..10000]of int64;\n r,m,n,k,l,w,s,j:int64;\n i:longint;\nbegin\n readln(l,r);\n if l=r then begin writeln(0); halt; end;\n a[0]:=1;\n for i:=1 to 60 do a[i]:=a[i-1]*2;\n for i:=62 downto 0 do\n begin\n if (a[i]>l)and(a[i]<=r) then begin writeln(a[i+1]-1); halt; end;\n if (a[i]<=l) then begin dec(l,a[i]); dec(r,a[i]); end;\n end;\nend.\n"}, {"source_code": "var l,r,a,b,ans,pp:int64;x,y,i:longint;\n\nfunction pow(x,y:int64):int64;\nvar z:int64;\nbegin\n if y=0 then exit(1);\n if y mod 2=1 then pow:=pow(x,y-1)*x\n else\n begin\n z:=pow(x,y div 2);\n pow:=z*z;\n end;\nend;\n\nbegin\n //assign(input, 'input.txt');reset(input);\n //assign(output, 'output.txt');rewrite(output);\n readln(l,r);\n a:=l;\n b:=r;\n ans:=0;\n for i:=62 downto 0 do\n begin\n pp:=pow(2,i);\n if pp and a =0 then x:=0 else x:=1;\n if pp and b =0 then y:=0 else y:=1;\n if x xor y=1 then\n begin\n ans:=ans+pp;\n continue;\n end;\n if x=0 then\n begin\n if a+pp<=r then\n begin\n ans:=ans+pp;\n a:=a+pp;\n end;\n end\n else\n begin\n if b-pp>=l then\n begin\n ans:=ans+pp;\n b:=b-pp;\n end;\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var l,r,ans,t,i :int64;\nBegin\n read(l,r);\n if l=r then Begin writeln(0); halt; end;\n t:=r;\n while (t-1)and t>l do\n t:=(t-1)and t;\n writeln(t xor (t-1));\n\nend.\n"}, {"source_code": "var i:longint;\nl,r:int64;\nBegin\nreadln(l,r);\nr:=l xor r;\nfor i:=1 to 64 do\n r:=r or (r>>1);\nwriteln(r);\nend."}, {"source_code": "const fi = '';\n fo = '';\n n = 62;\nvar l, r, ans: int64;\n i, p: longint;\n bl, br, bans: string;\n e2: array [0..n] of int64;\n\nprocedure Swap(var a, b: int64);\nvar t: int64;\nbegin\n t:=a; a:=b; b:=t;\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n e2[0]:=1;\n for i:=1 to n do e2[i]:=e2[i-1]*2;\n\n readln(l, r);\n if l = r then writeln(0)\n else\n begin\n bl:=binstr(l, n);\n br:=binstr(r, n);\n for p:=1 to n do\n if bl[p] <> br[p] then break;\n\n writeln(e2[n-p+1]-1);\n end;\n\n close(input); close(output);\nend.\n"}, {"source_code": "const\n tfi = '';\n tfo = '';\n Nmax = 1001;\ntype\n arr1 = array[0..Nmax] of longint ;\nvar\n fi,fo : text;\n n,m : longint;\n a,b : string ;\n l,r:int64 ;\nfunction BD(x:int64) :string;\nvar\ns:string ;\nbegin\n s := '';\n while x > 0 do begin\n s := chr(x mod 2 + 48) + s ;\n x := x div 2 ;\n end ;\n exit(s) ;\nend ;\nprocedure xuly;\nvar\n i,j,k: longint;\nbegin\n read(fi,L,R);\n a := BD(L);\n b := BD(R);\n while length(a) < length(b) do\n a := '0' + a ;\n n := length(a);\n for i := 1 to n do if a[i] <> b[i] then\n begin\n writeln(fo,int64(1) shl (n-i+1)-1) ;\n exit;\n end;\n write(fo,0) ;\nend ;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n xuly;\n close(fi);\n close(fo) ;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi='';\n fo='';\ntype\n mang=array[0..60] of int64;\nvar\n l,r,x,y:int64;\n mu:array[0..60] of int64;\n a,b,c,kq:mang;\n n,m:integer;\n function tm(c:mang):boolean;\n var\n dkm:int64;\n i:integer;\n begin\n dkm:=0;\n for i:=0 to 60 do\n dkm:=dkm+int64(c[i])*mu[i];\n if (dkm>=x) and (dkm<=y) then\n result:=true\n else result:=false;\n end;\n procedure nhap;\n var\n i,j:integer;\n so:int64;\n begin\n readln(l,r);\n X:=l;y:=r;\n mu[0]:=1;\n for i:=1 to 60 do\n mu[i]:=mu[i-1]*2;\n n:=-1;\n while (l>0) do\n begin\n inc(n);\n a[n]:=l mod 2;\n l:=l div 2;\n end;\n m:=-1;\n while (r>0) do\n begin\n inc(m);\n b[m]:=r mod 2;\n r:=r div 2;\n end;\n for i:=60 downto 0 do\n begin\n if a[i]=b[i] then\n begin\n if a[i]=1 then\n begin\n c:=a;\n c[i]:=0;\n if tm(c) then\n kq[i]:=1;\n c:=b;\n c[i]:=0;\n if tm(c) then\n kq[i]:=1;\n end\n else\n begin\n c:=a;\n c[i]:=1;\n if tm(c) then\n kq[i]:=1;\n c:=b;\n c[i]:=1;\n if tm(c) then\n kq[i]:=1;\n end;\n end\n else kq[i]:=1;\n end;\n so:=0;\n for i:=0 to 60 do\n so:=so+kq[i]*mu[i];\n writeln(so);\n end;\nbegin\n nhap;\nend.\n\n"}, {"source_code": "var i: longint;\nans, l1, r1: int64;\nl,r: string;\nbegin\n read(l1, r1);\n if l1=r1 then write('0')\n else\n begin\n while l1>0 do\n begin\n l:=l+chr((l1 mod 2)+48);\n l1:=l1 div 2;\n end;\n while r1>0 do\n begin\n r:=r+chr((r1 mod 2)+48);\n r1:=r1 div 2;\n end;\n for i:=1 to length(r)-length(l) do\n l:=l+'0';\n i:=length(l);\n while l[i]=r[i] do\n dec(i);\n ans:=1;\n while i>0 do\n begin\n ans:=2*ans;\n dec(i);\n end;\n write(ans-1);\n end;\nend."}, {"source_code": "{$mode objfpc}\nvar\n p: array[0..60] of int64;\n i: integer;\n l,r,lr,t: int64;\nbegin\n// assign(input,'text.inp'); reset(input);\n readln(l,r);\n p[0]:=1;\n for i:=1 to 60 do p[i]:=p[i-1]*2;\n t:=0;\n lr:=l xor r;\n for i:=60 downto 0 do if (lr and p[i]<>0) then\n begin\n t:=t+p[i]+p[i]-1;\n break;\n end;\n writeln(t);\nend.\n"}, {"source_code": "program maxxor;\nuses math;\nvar\nl,r:int64;\nbin:array[1..3200,1..2] of longint;\ncurr1,max,curr2:longint;\n\nprocedure binary(a,b:int64);\nbegin\ncurr1:=0;\ncurr2:=0;\nwhile a<>0 do\n begin\n if a mod 2=1 then\n begin\n inc(curr1);\n bin[curr1,1]:=1;\n end\n else\n begin\n inc(curr1);\n bin[curr1,1]:=0;\n end;\n a:=a div 2;\n end;\nwhile b<>0 do\n begin\n if b mod 2=1 then\n begin\n inc(curr2);\n bin[curr2,2]:=1;\n end\n else\n begin\n inc(curr2);\n bin[curr2,2]:=0;\n end;\n b:=b div 2;\n end;\nend;\n\nbegin\nreadln(l,r);\nbinary(l,r);\nif l=r then writeln('0') else\nif curr1=curr2 then\n begin\n while bin[curr1,1]=bin[curr1,2] do dec(curr1);\n writeln((2**(curr1))-1);\n end\n else\n begin\n if curr1>curr2 then max:=curr1 else max:=curr2;\n writeln((2**(max))-1);\n end;\nend."}, {"source_code": "program D276;\nvar i:longint;\nl,d:int64;\nbegin\nreadln(l,d);\nd:=l xor d;\nfor i:=1 to 64 do\n d:=d or (d>>1); (*011010\n or 001101 \n 011111 *)\nwriteln(d);\nend.\n"}, {"source_code": "program D276;\nvar i:longint;\nl,d:int64;\nbegin\nreadln(l,d);\nd:=l xor d;\nfor i:=1 to 64 do\n d:=d or (d>>1);\nwriteln(d);\nend.\n"}, {"source_code": "program D276;\nvar i:longint;\nl,r:int64;\nBegin\nreadln(l,r);\nr:=l xor r;\nfor i:=1 to 64 do\n r:=r or (r>>1);\nwriteln(r);\nend.\n"}, {"source_code": "program D276;\nvar i:longint;\nl,r:int64;\nBegin\nreadln(l,r);\nr:=l xor r;\nfor i:=1 to 64 do\n r:=r or (r>>1);\nwriteln(r);\nend.\n"}, {"source_code": "program problem4;\n\nvar\tl, r, i: qWord;\n\nbegin\n\treadln( l, r );\n\t\n\tif ( l = r ) then\n\tbegin\n\t\twriteln( 0 );\n\t\thalt;\n\tend;\n\t\n\ti := 1;\n\twhile ( ( i shl 1 ) <= r ) do\n\t\ti := i shl 1;\n\t\t\n\twhile ( i > 0 ) and ( ( i and r ) = ( i and l ) ) do\n\t\ti := i shr 1;\n\t\t\n\twriteln( ( i shl 1 ) - 1 );\nend.\n"}, {"source_code": "var\n i,j,k:longint;\n a,b,c,llevo:int64;\n dos:array[0..62] of qword;\nbegin\n dos[0]:=1;\n for i:=1 to 60 do\n dos[i]:=dos[i-1]*2;\n readln(a,b);\n if a=b then\n writeln(0)\n else\n begin\n for i:=60 downto 0 do\n if (dos[i]<=b) then\n break;\n llevo:=dos[i];\n i:=i-1;\n while llevo<=a do\n begin\n if llevo+dos[i]<=b then\n llevo:=llevo+dos[i];\n i:=i-1;\n end;\n a:=(llevo)xor (llevo-1);\n writeln(a);\n end;\nend. "}, {"source_code": "var l,r,ret,br,poz,razl:int64;\nbegin\n ret:=0;\n br:=1;\n poz:=0;\n readln(l,r);\n razl:=r-l;\n while razl>=br do\n begin\n ret:=br+ret;\n br:=br*2;\n poz:=poz+1;\n end;\n while r>=br do\n begin\n if ((l shr poz) xor (r shr poz)) and 1=1 then ret:=ret+br;\n br:=br*2;\n poz:=poz+1;\n end;\n writeln(ret);\nend."}, {"source_code": "var l,r,res:int64; i,j:longint;\nfunction getbit(i:int64; j:longint):byte;\nbegin\n\texit((i shr j)and 1);\nend;\nbegin\n\tres:=0;\n\treadln(l,r);\n i:=trunc(ln(r)/ln(2));\n while(i>=0)and(getbit(l,i)=getbit(r,i))do dec(i);\n res:=1;\n if i=-1 then writeln(0) else\n begin\n for j:=1 to (i+1) do res:=res*2;\n writeln(res-1);\n end; \nend.\n"}, {"source_code": "program zzz;\n\ntype int = int64;\n\nvar a,b:int; i,j:longint; ans:qword;\n\tc,c1,ac:array[1..1000] of int;\n\tn1:int;\n\t\nbegin\n//\tassign(input,'input.txt');\n\t//reset(input);\n\treadln(a,b);\n\t\n\tn1:=0;\n\twhile b<>0 do\n\t\tbegin\n\t\t\tinc(n1);\n\t\t\t\n\t\t\tc[n1]:=a and 1;\n\t\t\ta:=a shr 1;\n\t\t\t\n\t\t\tc1[n1]:=b and 1;\n\t\t\tb:=b shr 1;\n\t\tend;\n\t\n\tfor j:=n1 downto 1 do\n\t\tac[j]:=1;\n\t\t\n\tfor i:=n1 downto 1 do\n\t\tif (c[i] = c1[i]) then ac[i]:=0\n\t\t\telse break;\n\t\t\t\n\t//for i:=1 to n1 do\n\t//\twrite(ac[i]);\n\t//writeln(n1);\n\t\n\tans:=0;\n\tfor i:=n1 downto 1 do\n\t\tbegin\n\t\t\tans:=ans shl 1;\n\t\t\tans:=ans or ac[i];\n\t\t\t//writeln(ans,' ',ac[i]);\n\t\tend;\n\t\n\twriteln(ans);\n//\tclose(input);\nend."}, {"source_code": "const MAXN = 1000;\n\ntype bin = record\n dig : array [1..MAXN] of longint;\n size : longint;\n end;\n\nfunction convert_binary( x : int64 ) : bin;\nvar a : bin;\nbegin\n\n a.size:=0;\n \n while ( x > 0 ) do begin\n inc( a.size );\n a.dig[ a.size ] := x mod 2;\n x:= x div 2;\n end;\n \n exit( a );\n \nend; \n\nfunction convert_decimal( a : bin ) : int64;\nvar i : longint;\n exp , res : int64;\nbegin\n\n exp:=1; res:=0;\n\n for i:=1 to a.size do begin \n res:= res + ( exp * int64( a.dig[i] ) ) ;\n exp:=exp * 2;\n end;\n \n exit( res );\n \nend; \n \n\nvar l , r , ans : int64;\n i : longint; \n a , b : bin ;\nbegin\n\n readln( l , r );\n \n b:=convert_binary( l );\n a:=convert_binary( r );\n \n if ( l = r ) then begin\n writeln( 0 );\n halt;\n end; \n \n if a.size > b.size then begin\n for i:=a.size downto 1 do a.dig[i]:=1;\n ans:=convert_decimal( a );\n writeln( ans );\n halt;\n end;\n \n i:=a.size;\n while ( a.dig[i] = b.dig[i] ) do dec( i );\n \n a.size:=i;\n \n for i:=a.size downto 1 do a.dig[i]:=1;\n \n ans:=convert_decimal( a );\n \n writeln( ans );\n \nend. \n"}, {"source_code": "uses math;\nvar\n a:array[1..2,1..64] of int64; ans,tek,l,r:int64; i:longint;\n\n\nprocedure razlog(c:int64; nom:longint);\nvar tek:longint;\nbegin\n tek:=1;\n while c<>0 do\n begin\n a[nom,tek]:=c mod 2;\n c:=c div 2; inc(tek);\n end;\nend;\n\n\nbegin\n\n readln(l,r); razlog(l,1); razlog(r,2);\n ans:=-1;\n for i:=64 downto 1 do\n if a[1,i]<>a[2,i] then\n begin\n ans:=i; break;\n end;\n if ans=-1 then writeln(0) else\n begin\n tek:=1;\n for i:=1 to ans do tek:=tek*2;\n writeln(tek-1);\n end;\n\nend.\n"}, {"source_code": "program abc;\n\nvar\n k, q, l, r: int64;\n i: byte;\n\nbegin\n readln(l, r); \n\n for i := 60 downto 0 do\n begin\n q := int64(1) shl i; \n if ((l < q) and (r >= q)) then\n begin\n writeln(2 * q - 1);\n exit;\n end;\n if (l >= q) then\n begin\n l := l - q;\n r := r - q;\n end;\n end; \n writeln(0);\nend."}, {"source_code": "program ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n mas,l1,r1 : array [1..70] of int64;\n i, flag, lenl1, lenr1 :longint;\n res, step, l, r : int64;\nprocedure per (x:int64; e : longint);\nvar k : longint;\nbegin\n k := 70;\n while x > 0 do begin\n If e = 0 then l1[k] := x mod 2\n else\n r1[k] := x mod 2;\n k := k - 1;\n x := x div 2;\n end;\n if e = 0 then lenl1 := k else lenr1 := k + 1;\nend;\nbegin\n {reset(input,'D.in');\n rewrite(output,'D.out');}\n readln(l, r);\n flag := 0;\n for i := 1 to 70 do begin\n l1[i] := -1;\n r1[i] := -1;\n end;\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n for i := 1 to 70 do mas[i] := 0;\n per(l, 0);\n per(r, 1);\n for i := lenr1 to lenl1 do l1[i] := 0;\n for i := 1 to 70 do\n if (l1[i] = 0) and ( r1[i] = 1) then\n begin\n mas[i] := 1;\n flag := 1;\n end\n else\n if (l1[i] = 0) and (r1[i] = 0) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and (r1[i] = 1) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and(r1[i] = 0) then mas[i] := 1;\n res := 0;\n step := 1;\n i := 70;\n while i >= lenr1 do begin\n res := res + mas[i] * step;\n step := step * 2;\n i := i - 1;\n end;\n writeln(res);\nend.\n "}], "negative_code": [{"source_code": "var\n a,b,m:array[0..1000]of longint;\n l,r,k,p,q,i,j:longint;\nbegin\n readln(l,r);\n fillchar(a,sizeof(a),0);\n k:=l;\n p:=0;\n while k>0 do\n begin\n inc(p);\n a[p]:=k mod 2;\n k:=k div 2;\n end;\n k:=r;\n q:=0;\n while k>0 do\n begin\n inc(q);\n b[q]:=k mod 2;\n k:=k div 2;\n end;\n for i:=q downto 0 do\n if a[i]<>b[i] then break;\n p:=i;\n m[p]:=1;\n for j:=i-1 downto 1 do\n if (a[j]<>b[j])or((a[j]=0)and(b[j]=0)) then\n m[j]:=1\n else\n m[j]:=0;\n k:=0;\n for i:=p downto 1 do\n k:=k*2+m[i];\n writeln(k);\nend."}, {"source_code": "var\nl,r,i:int64;\n\nfunction Two(r:int64):int64;\n Begin\n i:=1;\n while (i<=r) do I:=i*2;\n TWo:=i;\n End;\nBegin\n readln(l,r);\n if (l*2<=r) then writeln(Two(r)-1)\n else writeln(l xor r);\n\nEnd."}, {"source_code": "var\nl,r,i:int64;\n\nfunction Two(r:int64):int64;\n Begin\n i:=1;\n while (i<=r) do I:=i*2;\n TWo:=i;\n End;\nBegin\n readln(l,r);\n if Two(l)<= r then writeln(Two(r)-1)\n else writeln(l xor r);\n\nEnd."}, {"source_code": "uses math;\nvar\n l,r,cur,ans,qw:int64;\n i,pow:longint;\n\nfunction pow_( p :longint):int64;\nvar\n res:int64;\nbegin\n res:=1;\n for i:=1 to p do inc(res,res);\n pow_:=res;\nend;\n\nbegin\n readln(l,r);\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n cur:= r xor l;\n pow:=trunc(ln(r) / ln(2));\n if pow_(pow+1) <= r then inc(pow);\n cur:=max((pow_(pow)) xor r, cur);\n cur:=max((pow_(pow)) xor l, cur);\n if (pow_(pow) > l) then cur:=max(cur,pow_(pow) xor (pow_(pow) - 1));\n if (pow_(pow) < r) then cur:=max(cur,pow_(pow) xor (pow_(pow) + 1));\n pow:=trunc(ln(cur) / ln(2));\n if pow_(pow) <=cur then inc(pow);\n writeln(pow_(pow)-1);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar\n l,r,cur,ans,qw:int64;\n i,pow:longint;\nbegin\n readln(l,r);\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n cur:= r xor l;\n pow:=trunc(ln(r) / ln(2));\n if 1 shl (pow +1) <= r then inc(pow);\n cur:=max((1 shl pow) xor r, cur);\n cur:=max((1 shl pow) xor l, cur);\n if (1 shl pow > l) then cur:=max(cur,1 shl pow xor (1 shl pow - 1));\n if (1 shl pow < r) then cur:=max(cur,1 shl pow xor (1 shl pow + 1));\n pow:=trunc(ln(cur) / ln(2));\n if 1 shl pow <=cur then inc(pow);\n ans:=1;\n for i:=1 to pow do inc(ans,ans);\n writeln(ans-1);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar\n l,r,cur,ans,qw:int64;\n pow:longint;\nbegin\n readln(l,r);\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n cur:= r xor l;\n pow:=trunc(ln(r) / ln(2));\n if 1 shl (pow +1) <= r then inc(pow);\n cur:=max((1 shl pow) xor r, cur);\n cur:=max((1 shl pow) xor l, cur);\n if (1 shl pow > l) then cur:=max(cur,1 shl pow xor (1 shl pow - 1));\n if (1 shl pow < r) then cur:=max(cur,1 shl pow xor (1 shl pow + 1));\n pow:=trunc(ln(cur) / ln(2));\n if 1 shl pow <=cur then inc(pow);\n ans:=-1 + (1 shl pow);\n writeln(ans);\nend.\n\n\n\n"}, {"source_code": "var\n l, r : int64;\n need : int64;\n current : int64;\n i : longint;\nbegin\n readln(l, r);\n current := 1;\n for i := 1 to 64 do\n begin\n current := current shl 1;\n if ((l xor r) <= (current - 1)) then\n begin\n writeln(current - 1);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "var\n l, r, g : int64;\n need : int64;\n current : int64;\n i : longint;\nbegin\n readln(l, r);\n current := 1;\n for i := 1 to 64 do\n begin\n inc(g);\n current := 1 shl g;\n if ((l xor r) <= (current - 1)) then\n begin\n writeln(current - 1);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "var\n l, r, g : int64;\n need : int64;\n current : int64;\n i : longint;\nbegin\n readln(l, r);\n current := 1;\n for i := 0 to 63 do\n begin\n inc(g);\n current := 1 shl g;\n if ((l xor r) <= (current - 1)) then\n begin\n writeln(current - 1);\n exit;\n end;\n end;\nend."}, {"source_code": "uses math;\nvar\n a,b:int64;\nbegin\n readln(a,b);\n if (a=b) then writeln(0) else\n writeln(max((b xor (b-1)), (a xor (a+1))));\nend."}, {"source_code": "var\n l, r : int64;\n need : int64;\n current : int64;\n i : longint;\nbegin\n readln(l, r);\n current := 1;\n for i := 0 to 63 do\n begin\n if ((l xor r) <= ((1 shl i) - 1)) then\n begin\n writeln((1 shl i) - 1);\n exit;\n end;\n end;\nend."}, {"source_code": "var\n a,b:int64;\nbegin\n readln(a,b);\n if (a=b) then writeln(0) else\n writeln(b xor (b-1));\nend."}, {"source_code": "var\n l, r : qword;\n i : longint;\nbegin\n readln(l, r);\n for i := 0 to 63 do\n begin\n if ((l xor r) <= ((1 shl i) - 1)) then\n begin\n writeln((1 shl i) - 1);\n exit;\n end;\n end;\nend."}, {"source_code": "program CF_276_D(input,output);\nvar a,b:int64;\n\nfunction get(a,b:int64):longint;\nvar p:longint;\nbegin\n p:=100;\n while a shr p and 1=b shr p and 1 do dec(p);\n exit(p+1);\nend;\n\nbegin\n read(a,b);\n if a=b then writeln(0) else writeln((1 shl get(a,b))-1);\nend.\n"}, {"source_code": "Var l,r,a,b:int64;\n d:array[0..123]of int64;\n i:longint;\n can1,can2:boolean;\n begin\n read(l,r);\n d[0]:=1;\n for i:=1 to 62 do\n d[i]:=d[i-1]+d[i-1];\n a:=0;\n b:=0;\n for i:=62 downto 0 do\n begin\n can1:=a+d[i]<=r;\n can1:=can1 and (b+d[i]-1>=l);\n can2:=b+d[i]<=r;\n can2:=can2 and (a+d[i]-1>=l);\n if can1 xor can2=true then\n begin\n if can1 then a:=a+d[i]\n else b:=b+d[i];\n continue;\n end;\n if can1 or can2=false then continue;\n if a=l\n then r:=r xor x;\n if x and r=0 then\n if l or x<=r\n then l:=L or x;\n end;\n end;\n\n write(l xor r);\nend."}, {"source_code": "program z;\n var\n l,r,x,ql,qr:int64;\n i,j:longint;\n begin\n read(l,r);\n\n for i:=64 downto 0 do\n begin\n if r shr i=0 then j:=i;\n end;\n j:=j-1;\n ql:=l;\n qr:=r;\n\n for i:=j downto 0 do\n begin\n x:=1 shl i;\n if ((x and r)=(x and l))\n then\n begin\n if x and r=x then\n if r xor x>=ql\n then r:=r xor x;\n if x and r=0 then\n if l or x<=qr\n then l:=L or x;\n end;\n end;\n\n write(l xor r);\nend.\n"}, {"source_code": "program z;\n var\n l,r,ql,qr,x:int64;\n i,j:longint;\n begin\n read(l,r);\n ql:=l;\n qr:=r;\n\n for i:=64 downto 1 do\n begin\n x:=1 shl i;\n if (l and x)=(r and x)\n then\n begin\n if r and x = x\n then\n if r xor x >= ql\n then r:=r xor x;\n if r and x = 0\n then\n if l or x <= qr\n then l:=l or x;\n end;\n end;\n\n write(l xor r);\nend."}, {"source_code": "program z;\n var\n l,r,x,ql,qr:int64;\n i,j:longint;\n begin\n read(l,r);\n\n for i:=64 downto 0 do\n begin\n if r shr i=0 then j:=i;\n end;\n j:=j-1;\n ql:=l;\n qr:=r;\n\n for i:=j downto 0 do\n begin\n x:=1 shl i;\n if ((x and r)=(x and l))\n then\n begin\n if x and r=1 then\n if r xor x>=ql\n then r:=r xor x;\n if x and r=0 then\n if l or x<=qr\n then l:=L or x;\n end;\n end;\n\n write(l xor r);\nend."}, {"source_code": "program z;\n var\n l,r,x,ql,qr:int64;\n i,j:longint;\n begin\n read(l,r);\n\n for i:=64 downto 0 do\n begin\n if r shr i=0 then j:=i;\n end;\n j:=j-1;\n ql:=l;\n qr:=r;\n\n for i:=j downto 0 do\n begin\n x:=1 shl i;\n if ((x and r)=(x and l))\n then\n begin\n if x and r=1 then\n if r - x>=ql\n then r:=r - x;\n if x and r=0 then\n if l + x<=qr\n then l:=L + x;\n end;\n end;\n\n write(l xor r);\nend."}, {"source_code": "program z;\n var\n l,r,ql,qr,x:int64;\n i,j:longint;\n begin\n read(l,r);\n ql:=l;\n qr:=r;\n\n for i:=60 downto 1 do\n begin\n x:=1 shr i;\n if (l and x)=(r and x)\n then\n begin\n if r and x = x\n then\n if r xor x >= ql\n then r:=r xor x;\n if r and x = 0\n then\n if l or x <= qr\n then l:=l or x;\n end;\n end;\n\n write(l xor r);\nend.\n"}, {"source_code": "uses math;\n var l,r:int64;\n begin\nreadln(l,r);\nwriteln(max(0,(l xor r)*2-1));\nend."}, {"source_code": "var\ni : longint;\n l,r : int64;\nbegin\n readln(l,r);\n for i:=0 to 100 do\n if (l xor r<=1 shl i-1) then begin writeln(1 shl i-1); exit; end;\nend."}, {"source_code": "var\n l,r,i : longint;\nbegin\n readln(l,r);\n for i:=1 to l do\n if (l xor r<1 shl i-1) then begin writeln(1 shl i-1); exit; end;\nend."}, {"source_code": "var\n l,r,i : longint;\nbegin\n readln(l,r);\n for i:=1 to 100 do\n if (l xor r<=1 shl i-1) then begin writeln(1 shl i-1); exit; end;\nend."}, {"source_code": "var\ni : longint;\n l,r : int64;\nbegin\n readln(l,r);\n for i:=1 to 100 do\n if (l xor r<=1 shl i-1) then begin writeln(1 shl i-1); exit; end;\nend."}, {"source_code": "var l,r:int64;\n i:longint;\n begin\n read(l,r);\n l:=l xor r;\n for i:=1 to 64 do\n r:=r or (r shr 1);\n writeln(r);\n end."}, {"source_code": "var l,r:int64;\n i:longint;\n begin\n read(l,r);\n l:=l xor r;\n for i:=1 to 64 do\n r:=r or (r>>1);\n writeln(r);\n end."}, {"source_code": "program bai4;\nconst finp='test.inp';\nvar f:text;\n\tl,r,kq:qword;\n i,j:longint;\nBEGIN\n\twriteln(1 shl 60-1);\n\treadln(l,r);\n for i:=62 downto 0 do\n begin\n if (r shr i and 1=1) and (l shr i and 1=0) then\n begin\n \tkq:=1;\n \tfor j:=1 to i do kq:=kq*2;\n kq:=kq-1;\n writeln(kq);\n// kq:=1 shl (i+1)-1;\n exit;\n end;\n end;\n writeln(0);\nEND."}, {"source_code": "program bai4;\nconst finp='test.inp';\nvar f:text;\n\tl,r,kq:qword;\n i,j:longint;\nBEGIN\n\twriteln(1 shl 60-1);\n\treadln(l,r);\n for i:=62 downto 0 do\n begin\n if (r shr i and 1=1) and (l shr i and 1=0) then\n begin\n \tkq:=1;\n \tfor j:=1 to i+1 do kq:=kq*2;\n kq:=kq-1;\n writeln(kq);\n// kq:=1 shl (i+1)-1;\n exit;\n end;\n end;\n writeln(0);\nEND."}, {"source_code": "uses math; \nvar l,r,k,b : int64;\nbegin\n read(l,r);\n k:=1;\n b:=max(l,r);\n while k<=b do\n begin\n k:=k*2;\n end;\n dec(k);\n writeln(k);\nend.\n"}, {"source_code": "var stl,str1 : ansistring;\n l,r,l1,r1,k,la,ra,k1 : int64;\n i :longint;\nfunction vdes(st : ansistring) : int64;\nvar s,r : int64;\n a,i,kod : longint;\nbegin\n s:=0; r:=1;\n for i:=length(st) downto 1 do\n begin\n if st[i]='1' then s:=s + r;\n r:=r*2;\n end;\n vdes:=s;\nend;\nbegin\n read(l,r);\n l1:=l; r1:=r;\n while l1<>0 do\n begin\n if l1 mod 2=0 then stl:='0'+stl else stl:='1'+stl;\n l1:=l1 div 2;\n end;\n while r1<>0 do\n begin\n if r1 mod 2=0 then str1:='0'+str1 else str1:='1'+str1;\n r1:=r1 div 2;\n end;\n\n la:=length(stl); ra:=length(str1); l1:=ra-la;\n for i:=la downto 1 do\n begin\n if stl[i]=str1[i+l1] then\n begin\n if stl[i]='0' then\n begin\n stl[i]:='1';\n k:=vdes(stl);\n if (k>=l) and (k<=r) then k:=k else\n begin\n stl[i]:='0';\n str1[i+l1]:='1';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else str1[i+l1]:='0';\n end;\n end else\n begin\n stl[i]:='0';\n k:=vdes(stl);\n if (k>=l) and (k<=r) then k:=k else\n begin\n stl[i]:='1';\n str1[i+l1]:='0';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else\n str1[i+l1]:='1';\n end;\n end;\n end\n end;\n for i:=l1 downto 1 do\n begin\n str1[i]:='1';\n k:=vdes(str1);\n if (k>=l) and (k<=r) then k:=k else str1[i]:='0';\n end;\n k1:=vdes(stl);\n k:=vdes(str1);\n writeln(k xor k1);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n n = 62;\nvar l, r, ans: int64;\n i, p: longint;\n bl, br, bans: string;\n e2: array [0..n] of int64;\n\nprocedure Swap(var a, b: int64);\nvar t: int64;\nbegin\n t:=a; a:=b; b:=t;\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n e2[0]:=1;\n for i:=1 to n do e2[i]:=e2[i-1]*2;\n\n readln(l, r);\n if l = r then writeln(0)\n else\n begin\n bl:=binstr(l, n);\n br:=binstr(r, n);\n for p:=1 to n do\n if bl[p] <> br[p] then break;\n for i:=1 to p-1 do bans:=bans+br[i];\n for i:=p to n do bans:=bans+'1';\n\n ans:=0;\n for i:=1 to n do\n ans:=ans+(ord(bans[i])-48)*e2[n-i];\n\n writeln(ans);\n end;\n\n close(input); close(output);\nend.\n"}, {"source_code": "program maxxor;\nuses math;\nvar\nl,r:int64;\nbin:array[1..32,1..2] of longint;\ncurr1,max,curr2:longint;\n\nprocedure binary(a,b:int64);\nbegin\ncurr1:=0;\ncurr2:=0;\nwhile a<>0 do\n begin\n if a mod 2=1 then\n begin\n inc(curr1);\n bin[curr1,1]:=1;\n end\n else\n begin\n inc(curr1);\n bin[curr1,1]:=0;\n end;\n a:=a div 2;\n end;\nwhile b<>0 do\n begin\n if b mod 2=1 then\n begin\n inc(curr2);\n bin[curr2,2]:=1;\n end\n else\n begin\n inc(curr2);\n bin[curr2,2]:=0;\n end;\n b:=b div 2;\n end;\nend;\n\nbegin\nreadln(l,r);\nbinary(l,r);\nif curr1=curr2 then\n begin\n while bin[curr1,1]=bin[curr1,2] do dec(curr1);\n writeln((2**(curr1))-1);\n end\n else\n begin\n if curr1>curr2 then max:=curr1 else max:=curr2;\n writeln((2**(max))-1);\n end;\nend."}, {"source_code": "var\n i,j,k:longint;\n a,b,c,llevo:int64;\n dos:array[0..62] of qword;\nbegin\n dos[0]:=1;\n for i:=1 to 63 do\n dos[i]:=dos[i-1]*2;\n readln(a,b);\n if a=b then\n writeln(0)\n else\n begin\n for i:=0 to 63 do\n if (llevo+dos[i]>b) or ((llevo+dos[i]>a) AND (llevo+dos[i]<=b)) then\n break;\n if llevo+dos[i]> b then\n begin\n llevo:=dos[i-1];\n i:=i-2;\n end\n else\n begin\n llevo:=dos[i];\n i:=i-1;\n end;\n while llevo<=a do\n begin\n llevo:=llevo+dos[i];\n i:=i-1;\n end;\n a:=(llevo)xor (llevo-1);\n writeln(a);\n end;\nend."}, {"source_code": "var\n i,j,k:longint;\n a,b,c,llevo:int64;\n dos:array[0..62] of qword;\nbegin\n dos[0]:=1;\n for i:=1 to 60 do\n dos[i]:=dos[i-1]*2;\n readln(a,b);\n if a=b then\n writeln(0)\n else\n begin\n for i:=60 downto 0 do\n if (dos[i]<=b) then\n break;\n llevo:=dos[i];\n i:=i-1;\n while llevo<=a do\n begin\n llevo:=llevo+dos[i];\n i:=i-1;\n end;\n a:=(llevo)xor (llevo-1);\n writeln(a);\n end;\nend. "}, {"source_code": "program zzz;\n\ntype int = longint;\n\nvar a,b:int; i:int; ans:int;\n\tc,c1:int;\n\t\nbegin\n\treadln(a,b);\n\t\n\t\n\twhile b<>0 do\n\t\tbegin\n\t\t\tc:=a and 1;\n\t\t\ta:=a shr 1;\n\t\t\t\n\t\t\tc1:=b and 1;\n\t\t\tb:=b shr 1;\n\n\t\t\t\n\t\t\tif (c = 1) and (c1 = 1) then begin ans:=ans shl 1; ans:=ans or 0; end\n\t\t\t\telse begin ans:=ans shl 1; ans:=ans or 1; end;\n\t\t\t\n\t\t\t//writeln(a,' ',b,' ',c,' ',c1,' ',ans);\n\t\tend;\n\t\n\twriteln(ans);\nend."}, {"source_code": "program zzz;\n\ntype int = int64;\n\nvar a,b:int; i,j:longint; ans:int;\n\tc,c1,ac:array[1..1000] of int;\n\tn1:int;\n\t\nbegin\n\treadln(a,b);\n\t\n\tn1:=0;\n\twhile b<>0 do\n\t\tbegin\n\t\t\tinc(n1);\n\t\t\t\n\t\t\tc[n1]:=a and 1;\n\t\t\ta:=a shr 1;\n\t\t\t\n\t\t\tc1[n1]:=b and 1;\n\t\t\tb:=b shr 1;\n\t\tend;\n\t\n\tfor i:=n1 downto 1 do\n\t\tif (c[i] = c1[i]) then ac[i]:=0\n\t\t\telse break;\n\tif i = 1 then dec(i);\t\t\n\tfor j:=i downto 1 do\n\t\tac[j]:=1;\n\t\t\n\t{for i:=1 to n1 do\n\t\twrite(ac[i]);\n\twriteln;}\n\t\n\tans:=0;\n\tfor i:=1 to n1 do\n\t\tbegin\n\t\t\tans:=ans shl 1;\n\t\t\tans:=ans or ac[i];\n\t\tend;\n\t\n\twriteln(ans);\nend."}, {"source_code": "program zzz;\n\ntype int = int64;\n\nvar a,b:int; i,j:longint; ans:qword;\n\tc,c1,ac:array[1..1000] of int;\n\tn1:int;\n\t\nbegin\n\t//assign(input,'input.txt');\n\t//reset(input);\n\treadln(a,b);\n\t\n\tn1:=0;\n\twhile b<>0 do\n\t\tbegin\n\t\t\tinc(n1);\n\t\t\t\n\t\t\tc[n1]:=a and 1;\n\t\t\ta:=a shr 1;\n\t\t\t\n\t\t\tc1[n1]:=b and 1;\n\t\t\tb:=b shr 1;\n\t\tend;\n\t\n\tfor i:=n1 downto 1 do\n\t\tif (c[i] = c1[i]) then ac[i]:=0\n\t\t\telse break;\n\tif i = 1 then dec(i);\t\t\n\tfor j:=i downto 1 do\n\t\tac[j]:=1;\n\t\t\n\t//for i:=1 to n1 do\n\t//\twrite(ac[i]);\n\t//writeln(n1);\n\t\n\tans:=0;\n\tfor i:=n1 downto 1 do\n\t\tbegin\n\t\t\tans:=ans shl 1;\n\t\t\tans:=ans or ac[i];\n\t\t\t//writeln(ans,' ',ac[i]);\n\t\tend;\n\t\n\twriteln(ans);\n//\tclose(input);\nend."}, {"source_code": "program abc;\n\nvar\n k, q, l, r: int64;\n i: integer;\n\nbegin\n readln(l, r); \n for i := 60 downto 0 do\n begin\n q := 1 shl i; \n if ((l < q) and (q <= r)) then\n begin\n writeln(2 * q - 1);\n exit;\n end;\n if (l >= q) then\n begin\n l := l - q;\n r := r - q;\n end;\n end; \n writeln(0);\nend."}, {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n a , b , ans : array[1..100] of integer;\n pow : array[0..100] of int64;\n l , r , res , t1 , top : int64;\n i , j , tmp : integer;\n tm : boolean;\n\nbegin\n //assign(input , 'input.txt') ; reset(input);\n pow[0] := 1;\n for i := 1 to 62 do pow[i] := pow[i - 1] * 2;\n\n readln(l , r);\n if l = r then begin writeln(0);halt;end;\n while r > 0 do\n begin\n inc(t1);\n a[t1] := r mod 2;\n r := r div 2;\n end;\n for i := 1 to t1 div 2 do\n begin\n tmp := a[i];\n a[i] := a[t1 - i + 1];\n a[t1 - i + 1] := tmp;\n end;\n\n top := t1;\n while l > 0 do\n begin\n b[top] := l mod 2;\n l := l div 2;\n dec(top);\n end;\n for i := 1 to t1 do\n begin\n if b[i] = 0 then\n begin\n if tm then begin ans[i] := 1; continue;end;\n ans[i] := a[i];\n if ans[i] = 1 then tm := true;\n end\n else break;\n end;\n if i > 1 then tm := true;\n for j := i to t1 do\n begin\n if (a[j] = 1) and (b[j] = 0) then\n begin\n ans[j] := 1; continue;\n tm := true;\n end;\n if (a[j] = 1) and tm then\n begin\n ans[j] := 1;\n continue;\n end;\n if (b[j] = 0) and tm then\n begin\n ans[j] := 1; continue;\n end;\n ans[j] := a[j] xor b[j];\n end;\n for i := 1 to t1 do\n res := res + pow[t1 - i] * ans[i];\n writeln(res);\nend."}, {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n a , b , ans : array[1..100] of integer;\n pow : array[0..100] of int64;\n l , r , res , t1 , top : int64;\n i , j , tmp : integer;\n tm : boolean;\n\nbegin\n //assign(input , 'input.txt') ; reset(input);\n pow[0] := 1;\n for i := 1 to 62 do pow[i] := pow[i - 1] * 2;\n\n readln(l , r);\n if l = r then begin writeln(0);halt;end;\n while r > 0 do\n begin\n inc(t1);\n a[t1] := r mod 2;\n r := r div 2;\n end;\n for i := 1 to t1 div 2 do\n begin\n tmp := a[i];\n a[i] := a[t1 - i + 1];\n a[t1 - i + 1] := tmp;\n end;\n\n top := t1;\n while l > 0 do\n begin\n b[top] := l mod 2;\n l := l div 2;\n dec(top);\n end;\n for i := 1 to t1 do\n begin\n if b[i] = 0 then\n begin\n if tm then begin ans[i] := 1; continue;end;\n ans[i] := a[i];\n if ans[i] = 1 then tm := true;\n end\n else break;\n end;\n if i > 1 then tm := true;\n for j := i to t1 do\n begin\n if (a[j] = 1) and (b[j] = 0) then\n begin\n ans[j] := 1; continue;\n tm := true;\n end;\n if (a[j] = 0) and (b[j] = 0) and tm then\n begin\n ans[j] := 1; continue;\n end;\n ans[j] := a[j] xor b[j];\n end;\n for i := 1 to t1 do\n res := res + pow[t1 - i] * ans[i];\n writeln(res);\nend."}, {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n a , b , ans : array[1..100] of integer;\n pow : array[0..100] of int64;\n l , r , res , t1 , top : int64;\n i , j , tmp : integer;\n\nbegin\n pow[0] := 1;\n for i := 1 to 62 do pow[i] := pow[i - 1] * 2;\n\n readln(l , r);\n if l = r then begin writeln(0);halt;end;\n while r > 0 do\n begin\n inc(t1);\n a[t1] := r mod 2;\n r := r div 2;\n end;\n for i := 1 to t1 div 2 do\n begin\n tmp := a[i];\n a[i] := a[t1 - i + 1];\n a[t1 - i + 1] := tmp;\n end;\n\n top := t1;\n while l > 0 do\n begin\n b[top] := l mod 2;\n l := l div 2;\n dec(top);\n end;\n for i := 1 to t1 do\n begin\n if b[i] = 0 then\n begin\n ans[i] := a[i];\n end\n else break;\n end;\n for j := i to t1 do\n begin\n if a[i] = 1 then\n begin\n ans[i] := 1; continue;\n end;\n if b[i] = 0 then\n begin\n ans[i] := 1 ; continue;\n end;\n ans[i] := a[i] xor b[i];\n end;\n for i := 1 to t1 do\n res := res + pow[t1 - i];\n writeln(res);\nend."}, {"source_code": "var\n l,r,a,b,t:int64;\n i:longint;\n d:array[0..1,0..1] of boolean;\n f:boolean;\nbegin\n f:=false;\n d[1,1]:=false;\n d[0,1]:=true;\n d[0,0]:=false;\n d[1,0]:=true;\n readln(l,r);\n a:=0;\n t:=1;\n b:=0;\n for i:=61 downto 0 do begin\n if d[r>>i,l>>i]\n then begin\n b:=t<>i))<>i))<>i))<>i))<0 do\n begin\n inc(k1);\n a1[k1]:=nn1 mod 2;\n nn1:=nn1 div 2;\n end;\n nn2:=n2;\n while nn2<>0 do\n begin\n inc(k2);\n a2[k2]:=nn2 mod 2;\n nn2:=nn2 div 2;\n end;\n for i:=1 to k2 div 2 do\n begin\n swap(a1[i],a1[k2-i+1]);\n swap(a2[i],a2[k2-i+1]);\n end;\n\n for i:=1 to k2 do\n begin\n ans:=ans shl(1);\n if big then\n begin\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if (not big)and(a1[i]=0) then\n begin\n if (a1[i]=0) then\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if men then\n begin\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n if (not men)and(a2[i]=1) then\n begin\n if (a2[i]=1) then\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n\n end;\n writeln(ans);\nend."}, {"source_code": "var\n a1,a2:array [1..1000000] of int64;\n k1,k2,m,n1,n2,nn1,nn2,ans:int64;\n i,j:longint;\n big,men,men2:boolean;\n\n procedure swap(var x,y:int64);\n var c:longint;\n begin\n c:=x; x:=y; y:=c;\n end;\n\n\nbegin\nreadln(n1,n2);\n nn1:=n1;\n while nn1<>0 do\n begin\n inc(k1);\n a1[k1]:=nn1 mod 2;\n nn1:=nn1 div 2;\n end;\n nn2:=n2;\n while nn2<>0 do\n begin\n inc(k2);\n a2[k2]:=nn2 mod 2;\n nn2:=nn2 div 2;\n end;\n for i:=1 to k2 div 2 do\n begin\n swap(a1[i],a1[k2-i+1]);\n swap(a2[i],a2[k2-i+1]);\n end;\n\n for i:=1 to k2 do\n begin\n ans:=ans shl(1);\n if big then\n begin\n if (a1[i]=0) then\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if (not big)and(a1[i]=0) then\n begin\n if (a1[i]=0) then\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if men then\n begin\n if (a2[i]=0) then\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n if (not men)and(a2[i]=1) then\n begin\n if (a2[i]=0) then\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n\n end;\n writeln(ans);\nend."}, {"source_code": "var\n a1,a2:array [1..1000000] of int64;\n k1,k2,m,n1,n2,nn1,nn2,ans:int64;\n i,j:longint;\n big,men,men2:boolean;\n\n procedure swap(var x,y:int64);\n var c:longint;\n begin\n c:=x; x:=y; y:=c;\n end;\n\n\nbegin\nreadln(n1,n2);\n nn1:=n1;\n while nn1<>0 do\n begin\n inc(k1);\n a1[k1]:=nn1 mod 2;\n nn1:=nn1 div 2;\n end;\n nn2:=n2;\n while nn2<>0 do\n begin\n inc(k2);\n a2[k2]:=nn2 mod 2;\n nn2:=nn2 div 2;\n end;\n for i:=1 to k2 div 2 do\n begin\n swap(a1[i],a1[k2-i+1]);\n swap(a2[i],a2[k2-i+1]);\n end;\n\n for i:=1 to k2 do\n begin\n ans:=ans shl(1);\n if big then\n begin\n if (a1[i]=0) then\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if (not big)and(a1[i]=0) then\n begin\n if (a1[i]=0) then\n begin\n ans:=ans+1;\n men:=true;\n continue;\n end;\n end;\n if men then\n begin\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n if (not men)and(a2[i]=1) then\n begin\n if (a2[i]=1) then\n begin\n ans:=ans+1;\n big:=true;\n continue;\n end;\n end;\n\n end;\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar\n f:array [1..100,0..1,0..1,0..1,0..1] of longint;\n a1,a2:array [1..100] of int64;\n n,m,k,l,r:int64;\n i,j:longint;\n\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x; x:=y; y:=c;\n\n end;\n\n\n function rec(i,l1,r1,l2,r2:int64):int64;\n var\n ll1,rr1,ll2,rr2:int64;\n i1,i2:longint;\n res:int64;\n ok1,ok2:boolean;\n begin\n if f[i,l1,l2,r1,r2]<>0 then exit(f[i,l1,l2,r1,r2]);\n res:=0;\n ll1:=0; ll2:=0; rr1:=0; rr2:=0;\n if i>k then exit(0);\n for i1:=0 to 1 do\n for i2:=0 to 1 do\n begin\n if (i1=0)and(i2=0) then continue;\n if (i1=1)and(i2=1) then continue;\n ok1:=false;\n ok2:=false;\n if i1=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l1=1)) then ok1:=true;\n if a2[i]=1 then rr1:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r1=1)) then ok1:=true;\n if a1[i]=0 then ll1:=1;\n end;\n if i2=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l2=1)) then ok2:=true;\n if a2[i]=1 then rr2:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r2=1)) then ok2:=true;\n if a1[i]=0 then ll2:=1;\n end;\n if (not ok1)or(not ok2) then continue;\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1+1);\n end;\n exit(f[i,l1,l2,r1,r2]);\n end;\n\nbegin\n readln(l,r);\n while (l>0) do\n begin\n inc(k);\n a1[k]:=l mod 2;\n l:=l div 2;\n end;\n k:=0;\n while r>0 do\n begin\n inc(k);\n a2[k]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to k div 2 do\n begin\n swap(a1[i],a1[k-i+1]);\n swap(a2[i],a2[k-i+1]);\n end;\n writeln(rec(1,0,0,0,0));\nend.\n"}, {"source_code": "var\n a,b:array [1..1000000] of int64;\n s,n,kb,m,l,r,k,ans,ss,ll,rr:int64;\n i,j:longint;\n\n\n function rev(x:Longint):longint;\n begin\n if x=1 then exit(0)\n else exit(1);\n end;\n\nbegin\n readln(l,r);\n s:=r;\n inc(k);\n a[k]:=l;\n inc(k);\n a[k]:=r;\n while s>0 do\n begin\n s:=(s-1) and r;\n if s>=l then\n begin\n inc(k);\n a[k]:=s;\n end;\n end;\nrr:=r;\n while rr<>0 do\n begin\n inc(kb);\n b[kb]:=rr mod 2;\n rr:=rr div 2;\n end;\n rr:=0;\n for i:=kb downto 1 do\n begin\n rr:=rr shl(1) + rev(b[i]);\n end;\n s:=rr;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n while s>0 do\n begin\n s:=(s-1) and rr;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n end;\n kb:=0;\n s:=l;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n while s>0 do\n begin\n s:=(s-1)and l;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n end;\n ll:=l;\n while ll<>0 do\n begin\n inc(kb);\n b[kb]:=ll mod 2;\n ll:=ll div 2;\n end;\n ll:=0;\n for i:=kb downto 1 do\n begin\n ll:=ll shl(1) + rev(b[i]);\n end;\n s:=ll;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n while s>0 do\n begin\n s:=(s-1) and ll;\n if (s>=l)and(s<=r) then\n begin\n inc(k);\n a[k]:=s;\n end;\n end;\n for i:=1 to k do\n for j:=1 to k do\n begin\n if (a[i] xor a[j]>ans) then ans:=a[i] xor a[j];\n end;\n writeln(ans);\n\n end.\n"}, {"source_code": "uses math;\nvar\n f:array [1..100,0..1,0..1,0..1,0..1] of int64;\n a1,a2:array [1..100] of int64;\n n,m,k,l,r:int64;\n i,j:longint;\n\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x; x:=y; y:=c;\n\n end;\n\n\n function rec(i,l1,r1,l2,r2:int64):int64;\n var\n ll1,rr1,ll2,rr2:int64;\n i1,i2:longint;\n res:int64;\n ok1,ok2:boolean;\n begin\n if f[i,l1,l2,r1,r2]<>0 then exit(f[i,l1,l2,r1,r2]);\n res:=0;\n ll1:=0; ll2:=0; rr1:=0; rr2:=0;\n if i>k then exit(0);\n for i1:=0 to 1 do\n for i2:=0 to 1 do\n begin\n if (i1=0)and(i2=0) then continue;\n if (i1=1)and(i2=1) then continue;\n ok1:=false;\n ok2:=false;\n if i1=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l1=1)) then ok1:=true;\n if a2[i]=1 then rr1:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r1=1)) then ok1:=true;\n if a1[i]=0 then ll1:=1;\n end;\n if i2=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l2=1)) then ok2:=true;\n if a2[i]=1 then rr2:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r2=1)) then ok2:=true;\n if a1[i]=0 then ll2:=1;\n end;\n if (not ok1)or(not ok2) then continue;\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1+1);\n end;\n exit(f[i,l1,l2,r1,r2]);\n end;\n\nbegin\n readln(l,r);\n while (l>0) do\n begin\n inc(k);\n a1[k]:=l mod 2;\n l:=l div 2;\n end;\n k:=0;\n while r>0 do\n begin\n inc(k);\n a2[k]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to k div 2 do\n begin\n swap(a1[i],a1[k-i+1]);\n swap(a2[i],a2[k-i+1]);\n end;\n writeln(rec(1,0,0,0,0));\nend.\n"}, {"source_code": "uses math;\nvar\n f:array [1..100,0..1,0..1,0..1,0..1] of int64;\n a1,a2:array [1..100] of int64;\n n,m,k,l,r:int64;\n i,j:longint;\n\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x; x:=y; y:=c;\n\n end;\n\n\n function rec(i,l1,r1,l2,r2:int64):int64;\n var\n ll1,rr1,ll2,rr2:int64;\n i1,i2:longint;\n res:int64;\n ok1,ok2:boolean;\n begin\n if f[i,l1,l2,r1,r2]<>0 then exit(f[i,l1,l2,r1,r2]);\n res:=0;\n ll1:=0; ll2:=0; rr1:=0; rr2:=0;\n if i>k then exit(0);\n for i1:=0 to 1 do\n for i2:=0 to 1 do\n begin\n ok1:=false;\n ok2:=false;\n if i1=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l1=1)) then ok1:=true;\n if a2[i]=1 then rr1:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r1=1)) then ok1:=true;\n if a1[i]=0 then ll1:=1;\n end;\n if i2=0 then\n begin\n if (a1[i]=0)or((a1[i]=1)and(l2=1)) then ok2:=true;\n if a2[i]=1 then rr2:=1;\n end\n else\n begin\n if (a2[i]=1)or((a2[i]=0)and(r2=1)) then ok2:=true;\n if a1[i]=0 then ll2:=1;\n end;\n if (not ok1)or(not ok2) then continue;\n if (i1=0)and(i2=0) then\n begin\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1);\n continue;\n end;\n if (i1=1)and(i2=1) then\n begin\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1);\n continue;\n end;\n f[i,l1,l2,r1,r2]:=max(f[i,l1,l2,r1,r2],rec(i+1,max(l1,ll1),max(r1,rr1),max(l2,ll2),max(r2,rr2)) shl 1+1);\n end;\n exit(f[i,l1,l2,r1,r2]);\n end;\n\nbegin\n readln(l,r);\n while (l>0) do\n begin\n inc(k);\n a1[k]:=l mod 2;\n l:=l div 2;\n end;\n k:=0;\n while r>0 do\n begin\n inc(k);\n a2[k]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to k div 2 do\n begin\n swap(a1[i],a1[k-i+1]);\n swap(a2[i],a2[k-i+1]);\n end;\n writeln(rec(1,0,0,0,0));\nend.\n"}, {"source_code": "var l,r,q:int64;\n i:longint;\n begin\n read(l,r);\n q:=l xor r;\n for i:=63 downto 1 do\n begin\n if q and (int64(1)<0 then\n begin\n writeln(int64(1)<<(i+1)-1);\n halt(0);\n end;\n end;\n end."}, {"source_code": "var l,r,q:int64;\n i:longint;\n begin\n read(l,r);\n q:=l xor r;\n for i:=63 downto 0 do\n begin\n if q and (int64(1)<0 then\n begin\n writeln((int64(1)<<(i+1))-1);\n halt(0);\n end;\n end;\n end."}, {"source_code": "var l,r:int64;\n a,b:array[1..64] of longint;\n res:int64;\n i,d,p:longint;\n\nbegin\n readln(l,r);\n while (r>0) do\n begin\n inc(d);\n a[d]:=l mod 2;\n b[d]:=r mod 2;\n l:=l div 2;\n r:=r div 2;\n end;\n p:=d+1;\n for i:=d downto 1 do\n if a[i]=b[i] then\n p:=i\n else break;\n dec(p);\n writeln(1 shl p-1);\nend."}, {"source_code": "var a,b,a1,b1,x,y,l,z,r:int64;\n i:longint;\n ma:array[0..3,0..500] of longint;\n bo:boolean;\nfunction ok(r:longint):boolean;\nbegin\n if (r>=a1) and (r<=b1) then ok:=true else ok:=false;\nend;\nbegin\n readln(a,b);\n a1:=a;\n b1:=b;\n x:=a;\n y:=b;\n z:=1;\n bo:=true;\n while y>0 do\n begin\n if (bo) and (x and 1=y and 1) then\n begin\n if x and 1=1 then b:=b-z else a:=a+z;\n if (not ok(a)) or (not ok(b)) then bo:=false;\n end;\n if bo then r:=r+z;\n z:=z*2;\n x:=x shr 1;\n y:=y shr 1;\n end;\n writeln(r);\nend.\n"}, {"source_code": "var a,b,l,z,r:int64;\n i:longint;\n ma:array[0..3,0..500] of longint;\n bo:boolean;\nprocedure pretvori(x,y:int64);\nbegin\n l:=0;\n while x>0 do\n begin\n l:=l+1;\n ma[y,l]:=x and 1;\n x:=x shr 1;\n end;\nend;\nfunction ok(r:longint):boolean;\nbegin\n if (r>=a) and (r<=b) then ok:=true else ok:=false;\nend;\nbegin\n readln(a,b);\n pretvori(a,1);\n pretvori(b,2);\n z:=1;\n bo:=true;\n for i:=1 to l do\n begin\n if (bo) and (ma[1,i]=ma[2,i]) then\n begin\n if ma[1,i]=1 then b:=b-z else a:=a+z;\n if (not ok(a)) or (not ok(b)) then bo:=false;\n end;\n if bo then r:=r+z;\n z:=z*2;\n end;\n writeln(r);\nend.\n"}, {"source_code": "const inp='';\n outp='';\nvar l,r,ans,kol:int64;\nbegin\n assign(input,inp);\n assign(output,outp);\n reset(input);\n readln(l,r);\n close(input);\n if l=r\n then ans:=0\n else begin\n kol:=1;\n while kol*2<=r do kol:=kol*2;\n if kol>l\n then ans:=(kol)xor(kol-1)\n else begin\n r:=r-l;\n kol:=1;\n while kol*2<=r do kol:=kol*2;\n ans:=(kol)xor(kol-1);\n end;\n end;\n rewrite(output);\n writeln(ans);\n close(output);\nend.\n"}, {"source_code": "var\n l:char;\n c,t,tt,n,i,j,i1,g,ans,k,f,max:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2:int64;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n if t1=t2 then write(0) else\n begin\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n end;\n for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end;\n t1:=0;\n for i:=t downto 1 do t1:=t1 shl 1 +a[i];\n write(t1);\n\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:int64;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n { for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans);\n writeln; }\n\n if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n\n\n while (t>0)and(a[t]=1)and(b[t]=1) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0; }\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1);\n end;\nend.\n"}, {"source_code": "var\n l:char;\n c,t,tt,n,i,j,i1,g,ans,k,f,max:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2:int64;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n if t1=t2 then write(0) else\n begin\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n end;\n for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0;\n for i:=t downto 1 do t1:=t1 shl 1 +a[i];\n write(t1);\n\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:qword;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n { for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans);\n writeln; }\n\n if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n\n\n while (t>0)and(a[t]=1)and(b[t]=1) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0; }\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1);\n end;\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:int64;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n{ for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans); }\n\n if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n end;\n\n while (t>0)and(a[t]=1)and(b[t]=1) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0; }\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1);\n\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:qword;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans);\n writeln;\n\n if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n\n\n while (t>0)and(a[t]=1)and(b[t]=1) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0; }\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1);\n end;\nend.\n"}, {"source_code": "uses math;\nvar\n l:char;\n c,t,tt,n,i,j,i1,g,k,f:longint;\n a,b,x,y:array[1..20000] of longint;\n st,st1,st2:string;\n t1,t2,ans:int64;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n read(t1,t2);\n\n for i:=t1 to t2 do\n for j:=t1 to t2 do\n ans:=max(ans,i xor j);\n write(ans);\n\n{ if t1=t2 then write(0) else\n begin\n\n while t2>0 do\n begin\n inc(t);\n a[t]:=t2 mod 2;\n t2:=t2 div 2;\n end;\n\n while t1>0 do\n begin\n inc(tt);\n b[tt]:=t1 mod 2;\n t1:=t1 div 2;\n end;\n end; }\n\n // while (t>0)and(a[t]=1)and(b[t]=1) do dec(t);\n { for i:=t-1 downto 1 do\n if (a[i]=0)and(b[i]=1) then begin\n for j:=1 to i do a[j]:=1;\n break;\n end\n else\n if (a[i]=1)and(b[i]=0) then begin\n a[i]:=0;\n for j:=1 to i-1 do a[j]:=1;\n break;\n end;\n\n t1:=0;\n for i:=t downto 1 do t1:=t1 shl 1 +1;\n write(t1); }\n\nend.\n"}, {"source_code": "var l,r,ans,t,i :int64;\nBegin\n read(l,r);\n t:=r;\n while (t-1)and t>l do\n t:=(t-1)and t;\n writeln(t xor (t-1));\n {if t<=l then\n Begin\n ans:=0;\n i:=l;\n while ians then ans:= i xor (i+1);\n inc(i);\n end;\n writeln(ans);\n end else\n Begin\n writeln(t xor (t-1));\n end;}\nend.\n"}, {"source_code": "const\n tfi = '';\n tfo = '';\n Nmax = 1001;\ntype\n arr1 = array[0..Nmax] of longint ;\nvar\n fi,fo : text;\n n,m : longint;\n a,b : string ;\n l,r:int64 ;\nfunction BD(x:int64) :string;\nvar\ns:string ;\nbegin\n s := '';\n while x > 0 do begin\n s := chr(x mod 2 + 48) + s ;\n x := x div 2 ;\n end ;\n exit(s) ;\nend ;\nprocedure xuly;\nvar\n i,j,k: longint;\n c,a2,b2:string ;\nbegin\n read(fi,L,R);\n a := BD(L);\n b := BD(R);\n while length(a) < length(b) do\n a := '0' + a ;\n n := length(a);\n c := '';\n for i := 1 to n do\n begin\n a2 := c + '1';\n b2 := c + '0';\n for j := i + 1 to n do a2 := a2 + '0';\n for j := i + 1 to n do b2 := b2 + '1';\n if (a2 >= a) and (a2 <= b) and (b2 >= a) and (b2 <= b) then\n begin\n writeln(fo,int64(1) shl (n-i+1)-1) ;\n exit;\n end;\n c := c + '0' ;\n end;\n write(fo,0) ;\nend ;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n xuly;\n close(fi);\n close(fo) ;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+,O-}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 10000000000;\n\nvar\n l, r, x, y, ans: int64;\n ll, rr, s1, s2, i: integer;\n a, b, c: array[0..10000]of integer;\n \nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(l, r);\n\n {for ll := 1 to 27 do\n for rr := ll + 1 to 27 do\n writeln(ll, ' ', rr, ' ', ll xor rr); }\n \n if l = r then begin\n write(l xor r);\n exit;\n end;\n \n {x := 1;\n while (x * 2 <= r) do begin\n x := x * 2;\n end;\n\n if x >= l + 1 then\n write(x xor (x - 1))\n else}\n s1 := 0;\n x := r;\n while x <> 0 do begin\n inc(s1);\n a[s1] := x mod 2;\n x := x div 2;\n end;\n\n s2 := 0;\n x := l;\n while x <> 0 do begin\n inc(s2);\n b[s2] := x mod 2;\n x := x div 2;\n end;\n\n if s1 > s2 then begin\n write((1 shl (s1)) - 1);\n\n end else begin\n for i := s1 downto 1 do begin\n if a[i] = b[i] then\n else\n if (a[i] = 1) and (b[i] = 0) then begin\n ans := i;\n break;\n end;\n end;\n write(1 shl ans);\n end;\n\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+,O-}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 10000000000;\n\nvar\n l, r, x, y, ans: int64;\n ll, rr, s1, s2, i: integer;\n a, b, c: array[0..10000]of integer;\n \nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(l, r);\n\n {for ll := 1 to 27 do\n for rr := ll + 1 to 27 do\n writeln(ll, ' ', rr, ' ', ll xor rr); }\n \n if l = r then begin\n write(l xor r);\n exit;\n end;\n \n {x := 1;\n while (x * 2 <= r) do begin\n x := x * 2;\n end;\n\n if x >= l + 1 then\n write(x xor (x - 1))\n else}\n s1 := 0;\n x := r;\n while x <> 0 do begin\n inc(s1);\n a[s1] := x mod 2;\n x := x div 2;\n end;\n\n s2 := 0;\n x := l;\n while x <> 0 do begin\n inc(s2);\n b[s2] := x mod 2;\n x := x div 2;\n end;\n\n if s1 > s2 then begin\n write((1 shl (s1)) - 1);\n\n end else begin\n for i := s1 downto 1 do begin\n if a[i] = b[i] then\n else\n if (a[i] = 1) and (b[i] = 0) then begin\n ans := i;\n break;\n end;\n end;\n write((1 shl ans) - 1);\n end;\n\n\nend.\n"}, {"source_code": "program zad_276D;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, r, step, max, min : int64;\nbegin\n readln(l, r);\n step := 1;\n while(step * 2 <= r) do\n step := step * 2;\n\n if(l - r = 0) then begin\n writeln(0);\n exit;\n end;\n \n max := 0;\n min := 0;\n while(step > 0) do begin\n if(max < l) and (max or step <= r) then\n max := max or step\n else if (min < l) and (min or step <= r) then\n min := min or step\n else if(max or step <= r ) then\n max := max or step\n else if(min or step <= r) then\n min := min or step;\n step := step div 2;\n end;\n\n writeln(max or min);\n readln(l);\nend.\n"}, {"source_code": "program zad_276D;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, r, step, max, min : int64;\nbegin\n readln(l, r);\n step := 1;\n while(step * 2 <= r) do\n step := step * 2;\n\n if(l - r = 0) then begin\n writeln(0);\n exit;\n end;\n \n max := 0;\n min := 0;\n while(step > 0) do begin\n if (min < l) then begin\n min := min or step;\n if(max < l) and (max or (step - 1) < l) then\n max := max or step;\n end else if(max < l) then begin\n max := max or step;\n if(min < l) and (min or (step - 1) < l) then\n min := min or step;\n end else if(max or step <= r ) then\n max := max or step\n else if(min or step <= r) then\n min := min or step;\n step := step div 2;\n end;\n\n if(max > r) then\n writeln('max > r ', max);\n if(min < l) then\n writeln('min r) then\n writeln('min > l ', min);\n\n writeln(max xor min);\n readln(l);\nend.\n"}, {"source_code": "program zad_276D;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, r, r1, res : int64;\nbegin\n readln(l, r);\n if(l = r) then begin\n writeln(0);\n exit;\n end;\n\n r1 := r;\n res := 1;\n while(r1 div 2 <> 0) do begin\n res := res * 2;\n r1 := r1 div 2;\n end;\n\n writeln(res + res - 1);\n readln(l);\nend.\n"}, {"source_code": "program zad_276D;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, r, step, max, min : int64;\nbegin\n readln(l, r);\n step := 1;\n while(step * 2 <= r) do\n step := step * 2;\n\n if(l - r = 0) then begin\n writeln(0);\n exit;\n end;\n \n max := 0;\n min := 0;\n while(step > 0) do begin\n if (min < l) then begin\n min := min or step;\n if(max < l) and (max or (step - 1) < l) then\n max := max or step;\n end else if(max < l) then begin\n max := max or step;\n if(min < l) and (min or (step - 1) < l) then\n min := min or step;\n end else if(max or step <= r ) then\n max := max or step\n else if(min or step <= r) then\n min := min or step;\n step := step div 2;\n end;\n\n writeln(max xor min);\n readln(l);\nend.\n"}, {"source_code": "Var i,e,z,l,r,kol:int64;\nv:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n kol:=0; e:=1; z:=l;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n for v:=kol downto 0 do\n begin\n i:=v;\n if (not odd(l shr i)) and ( odd(r shr i))\n then begin writeln(e shl (i+1)-1); halt(0); end;\n end;\n writeln(0)\nend."}, {"source_code": "Var z,l,r,kol:int64;\ni:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n z:=r; kol:=0;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n if l shr (kol-1)=1\n then begin\n z:=l;\n for i:=kol-2 downto 1 do\n if (odd(l shr i)=odd(r shr i))and(z xor (1 shl i)>=l)and(z xor (1 shl i)<=r)\n then z:=z xor (1 shl i);\n writeln(z xor r);\n halt(0);\n end;\n z:=1;\n writeln(z shl kol-1);\nend."}, {"source_code": "Var i,e,z,l,r,kol:int64;\nv:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n kol:=0; e:=1; z:=l;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n for v:=kol-1 downto 0 do\n begin\n i:=v;\n if odd(l shr i)= not odd(r shr i)\n then begin writeln(e shl (i+1)-1); halt(0); end;\n end;\n writeln(0)\nend."}, {"source_code": "Var z,l,r,kol:int64;\ni:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n z:=r; kol:=0;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n{ if (1 shl (kol-2))>=l\n then begin writeln(1 shl kol-1); halt(0); end;}\n\n if l shr (kol-1)=1\n then begin\n z:=l;\n for i:=kol-2 downto 1 do\n if (odd(l shr i)=odd(r shr i))and(z xor (1 shl i)>=l)and(z xor (1 shl i)<=r)\n then z:=z xor (1 shl i);\n writeln(z xor r);\n halt(0);\n end;\n writeln(1 shl kol-1); \nend."}, {"source_code": "Var e,z,l,r,kol:int64;\ni:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n z:=r; kol:=0; e:=1;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n if l shr (kol-1)=1\n then begin\n z:=l;\n for i:=kol-2 downto 1 do\n if (odd(l shr i)=odd(r shr i))and(z xor (e shl i)>=l)and(z xor (e shl i)<=r)\n then z:=z xor (e shl i);\n writeln(z xor r);\n halt(0);\n end;\n z:=1;\n writeln(z shl kol-1);\nend."}, {"source_code": "Var i,e,z,l,r,kol:int64;\nv:longint;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(l,r);\n kol:=0; e:=1; z:=l;\n while z<>0 do\n begin\n inc(kol);\n z:=z div 2;\n end;\n for v:=kol downto 0 do\n begin\n i:=v;\n if odd(l shr i)= not odd(r shr i)\n then begin writeln(e shl (i+1)-1); halt(0); end;\n end;\n writeln(0)\nend."}, {"source_code": "{$apptype console}\n{$I+,R+,Q+,B-}\nUses SysUtils;\n\nVar\n n,m:int64;\n i,count1,count2,k2:integer;\n a,b,mass:array[1..61]of int64;\n flag:boolean;\n new1,new2:int64;\nBegin\n readln(n,m);\n new1:=m;\n count1:=0;\n count2:=0;\n mass[1]:=1;\n for i:=1 to 60 do begin\n mass[i+1]:=mass[i]*2;\n a[i]:=0;\n b[i]:=0;\n end;\n\n while n>0 do begin\n inc(count1);\n a[count1]:=n mod 2;\n n:=n div 2;\n end;\n k2:=0;\n while m>0 do begin\n inc(count2);\n b[count2]:=m mod 2;\n if m mod 2=1 then k2:=count2;\n m:=m div 2;\n end;\n flag:=false;\n for i:=k2 downto 1 do begin\n if flag and (b[i]=0)and(a[i]=0)then a[i]:=1;\n if not flag and(b[i]>a[i])then flag:=true;\n end;\n\n new2:=0;\n for i:=k2 downto 1 do new2:=new2+a[i]*mass[i];\n writeln(new1 xor new2);\nEnd.\n\n\n\n\n\n"}, {"source_code": "{$apptype console}\n{$I+,R+,Q+,B-}\nUses SysUtils;\n\nVar\n n,m:int64;\n i,count1,count2,k2:integer;\n a,b,mass:array[1..61]of int64;\n f1:boolean;\n new1,new2:int64;\nBegin\n readln(n,m);\n new1:=m;\n count1:=0;\n count2:=0;\n mass[1]:=1;\n for i:=1 to 60 do begin\n mass[i+1]:=mass[i]*2;\n a[i]:=0;\n b[i]:=0;\n end;\n\n while n>0 do begin\n inc(count1);\n a[count1]:=n mod 2;\n n:=n div 2;\n end;\n k2:=0;\n while m>0 do begin\n inc(count2);\n b[count2]:=m mod 2;\n if m mod 2=1 then k2:=count2;\n m:=m div 2;\n end;\n f1:=false;\n for i:=k2 downto 1 do begin\n if f1 and (b[i]=0)and(a[i]=0)then a[i]:=1;\n if f1 and (b[i]=1)and(a[i]=1)then b[i]:=0;\n if not f1 and(b[i]>a[i])then f1:=true;\n end;\n\n new2:=0;\n for i:=k2 downto 1 do new2:=new2+a[i]*mass[i];\n writeln(new1 xor new2);\nEnd.\n\n\n\n\n\n"}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,temp: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n rez[0]:=0;\n for i:=b1[0] downto 1 do\n begin\n if i>a1[0]\n then begin inc(rez[0]); rez[rez[0]]:=b1[i]; end\n else begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then begin inc(rez[0]); rez[rez[0]]:=1; end\n else begin\n temp:=0;\n tb1:=b1;ta1:=a1;\n b1[i]:=0; a1[i]:=1;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb>=a) and (ta<=b) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n if temp=0 then begin\n tb1:=b1;ta1:=a1;\n b1[i]:=1; a1[i]:=0;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb<=b) and (ta>=a) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n end;\n if not ((temp=0) and (rez[0]=0)) then begin inc(rez[0]); rez[rez[0]]:=temp end;\n end\n end\n end;\n\n z:=0;\n for i:=1 to rez[0] do z:=z*2 + rez[i];\n\n writeln(z);\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,temp: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n read(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n rez[0]:=0;\n for i:=b1[0] downto 1 do\n begin\n if i>a1[0]\n then begin inc(rez[0]); rez[rez[0]]:=b1[i]; end\n else begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then begin inc(rez[0]); rez[rez[0]]:=1; end\n else begin\n tb1:=b1; ta1:=a1; temp:=0;\n tb1[i]:=0; ta1[i]:=1;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb>=a) and (ta<=b) then temp:=1;\n\n tb1[i]:=1; ta1[i]:=0;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb<=b) and (ta>=a) then temp:=1;\n\n if not ((temp=0) and (rez[0]=0)) then begin inc(rez[0]); rez[rez[0]]:=temp end;\n end\n end\n end;\n\n z:=0;\n for i:=1 to rez[0] do z:=z*2 + rez[i];\n\n writeln(z);\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,temp: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1); a1[0]:=b1[0];\n for i:=a1[0] downTO 1 do write(a1[i]); writeln;\n for i:=b1[0] downTO 1 do write(b1[i]); writeln;\n\n\n rez[0]:=0;\n for i:=b1[0] downto 1 do\n begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then begin inc(rez[0]); rez[rez[0]]:=1; end\n else begin\n temp:=0;\n tb1:=b1;ta1:=a1;\n b1[i]:=0; a1[i]:=1;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb>=a) and (ta<=b) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n if temp=0 then begin\n tb1:=b1;ta1:=a1;\n b1[i]:=1; a1[i]:=0;\n Bintodec(b1,tb); Bintodec(a1,ta); \n if (tb<=b) and (ta>=a) then temp:=1 else begin b1:=tb1; a1:=ta1; end;\n end;\n if not ((temp=0) and (rez[0]=0)) then begin inc(rez[0]); rez[rez[0]]:=temp end;\n end\n \n end;\n\n z:=0;\n for i:=1 to rez[0] do z:=z*2 + rez[i];\n\n writeln(z);\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1: binchislo;\n i,t: longint; a,b: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n readln(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1);\n\n{ for i:=a1[0] downTO 1 do write(a1[i]); writeln;\n for i:=b1[0] downTO 1 do write(b1[i]); writeln;\n}\n\n if a1[0]0) and (a1[t]=b1[t]) do dec(t);\n writeln(1 shl t - 1)\n end;\n\nend."}, {"source_code": "type binchislo=array[0..100] of byte;\nvar a1,b1,tb1,ta1,rez: binchislo;\n i,j: longint; a,b,z,tb,ta: int64;\n\nProcedure DecToBin(x: int64; var a: binchislo);\nbegin\n a[0]:=0;\n repeat\n inc(a[0]);\n a[a[0]]:=x mod 2;\n x:=x div 2\n until x=0;\nend;\n\nProcedure BinToDec(a: binchislo; var x: int64);\nvar i: byte;\nbegin\n x:=0;\n for i:=a[0] downTO 1 do x:=x*2 + a[i];\nend;\n\nbegin\n{ assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n}\n read(a,b);\n\n DecToBin(a,a1); DecToBin(b,b1); rez[0]:=b1[0];\n\n for i:=b1[0] downto 1 do\n begin\n if i>a1[0]\n then rez[i]:=b1[i]\n else begin\n if (a1[i]=0) and (b1[i]=1) or (a1[i]=1) and (b1[i]=0)\n then rez[i]:=1\n else begin\n tb1:=b1; ta1:=a1; rez[i]:=0;\n tb1[i]:=0; ta1[i]:=1;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb>=a) and (ta<=b) then rez[i]:=1;\n\n tb1[i]:=1; ta1[i]:=0;\n Bintodec(tb1,tb); Bintodec(ta1,ta); \n if (tb<=b) and (ta>=a) then rez[i]:=1;\n end\n end\n end;\n\n Bintodec(rez,z);\n\n writeln(z);\nend."}, {"source_code": "var i:longint;\n e,r,l:int64;\nbegin\n readln(l,r);\n if l=r then writeln(0) else begin\n e:=1;\n for i:=62 downto 0 do\n if (e shl i<=r) and (e shl i>l)\n then begin\n writeln(e shl (i+1)-1);\n exit;\n end;\n end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c: array [0..100] of int64;\n n, j, i: integer;\n l, R, os, ans: int64;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n os := 1;\n for i := 0 to 63 do\n begin\n c[i] := os;\n os := os * 2;\n end;\n read(l, r);\n for i := 63 downto 0 do\n begin\n a[i] := r div c[i];\n r := r mod c[i];\n b[i] := l div c[i];\n l := l mod c[i];\n end;\n ans := 0;\n for i := 63 downto 0 do\n if a[i] - b[i] = 1 then\n begin\n write(c[i] * 2 - 1);\n exit;\n end;\n\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nl,r : int64;\na,b : array [1..64] of longint;\ni,t,len1,len2 : longint;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(l,r);\n if l = r then\n begin\n writeln(0);\n halt;\n end;\n len1:=0;\n while r > 0 do\n begin\n inc(len1);\n a[len1]:=r mod 2;\n r:=r div 2;\n end;\n for i:=1 to len1 div 2 do\n begin\n t:=a[i];a[i]:=a[len1 - i + 1];a[len1 - i + 1]:=t;\n end;\n\n len2:=0;\n while l > 0 do\n begin\n inc(len2);\n b[len2]:=l mod 2;\n l:=l div 2;\n end;\n for i:=1 to len2 div 2 do\n begin\n t:=b[i];b[i]:=b[len2 - i + 1];b[len2 - i + 1]:=t;\n end;\n\n for i:=len2 downto 1 do b[i + len1 - len2]:=b[i];\n for i:=1 to len1 - len2 do b[i]:=0;\n\n for i:=1 to len1 do\n if (a[i] = 1) and (b[i] = 0) then\n begin\n writeln(1 shl (len1 - i + 1) - 1);\n halt;\n end;\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\ntype point = record x,y:integer; end;\n\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If m=1 do\n begin\n if x mod 2=0 then s:='0'+s\n else s:='1'+s;\n x:=x div 2;\n end;\nt:='';\nwhile y>=1 do\n begin\n if y mod 2=0 then t:='0'+t\n else t:='1'+t;\n y:=y div 2;\n end;\nwhile length(s) 0 do begin\n ls := inttostr(l mod 2) + ls;\n l := l div 2;\n end;\n while r > 0 do begin\n rs := inttostr(r mod 2) + rs;\n r := r div 2;\n end;\n while length(ls) < length(rs) do\n ls := '0' + ls; \n j := 1;\n c := '';\n while (j <= length(ls))and(ls[j] = rs[j]) do begin\n inc(j);\n end;\n for i := j to length(rs) do\n c := c + '1';\n for i := length(c) downto 1 do\n ans := ans + strtoint(c[i]) * (1 shl (length(c) - i));\n write(ans);\nend.\n"}, {"source_code": "program TD;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\nconst\n maxn = round(1e+18);\n\nvar\n i: integer;\n l, r: int64;\n first: array [1..100000] of integer;\n second: array [1..100000] of integer;\n size1, size2: integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'TD.in');\n rewrite(output, 'TD.out');\n {$ENDIF}\n readln(l, r); size1 := 0; size2 := 0;\n while (l > 0) do begin\n inc(size1);\n first[size1] := l mod 2;\n l := l div 2;\n end;\n while (r > 0) do begin\n inc(size2);\n second[size2] := r mod 2;\n r := r div 2;\n end;\n if (size2 > size1) then begin\n write((1 shl size2) - 1);\n halt(0);\n end;\n for i := size2 downto 1 do\n if (first[i] <> second[i]) then begin\n writeln((1 shl i - 1));\n halt(0);\n end;\n write(0);\nend.\n\n"}, {"source_code": "program TD;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\nconst\n maxn = round(1e+18);\n\nvar\n i: integer;\n l, r: int64;\n first: array [1..100000] of integer;\n second: array [1..100000] of integer;\n size1, size2: integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'TD.in');\n rewrite(output, 'TD.out');\n {$ENDIF}\n readln(l, r); size1 := 0; size2 := 0;\n while (l > 0) do begin\n inc(size1);\n first[size1] := l mod 2;\n l := l div 2;\n end;\n while (r > 0) do begin\n inc(size2);\n second[size2] := r mod 2;\n r := r div 2;\n end;\n if (size2 > size1) then begin\n write((1 shl size2) - 1);\n halt(0);\n end;\n for i := size2 downto 1 do\n if (first[i] <> second[i]) then begin\n writeln((1 shl (i + 1) - 1));\n halt(0);\n end;\n write(0);\nend.\n\n"}, {"source_code": "program abc;\n\nvar\n k, q, l, r: int64;\n i: integer;\n\nbegin\n readln(l, r); \n for i := 60 downto 0 do\n begin\n q := 1 shl i; \n if ((l < q) and (q <= r)) then\n begin\n writeln(2 * q - 1);\n exit;\n end;\n if (l >= q) then\n begin\n l := l - q;\n r := r - q;\n end;\n end; \n writeln(0);\nend."}, {"source_code": "program ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n mas,l1,r1 : array [1..60] of int64;\n i, flag, lenl1, lenr1 :longint;\n res, step, l, r : int64;\nprocedure per (x:int64; e : longint);\nvar k : longint;\nbegin\n k := 60;\n while x > 0 do begin\n If e = 0 then l1[k] := x mod 2\n else\n r1[k] := x mod 2;\n k := k - 1;\n x := x div 2;\n end;\n if e = 0 then lenl1 := k else lenr1 := k + 1;\nend;\nbegin\n {reset(input,'D.in');\n rewrite(output,'D.out');}\n readln(l, r);\n flag := 0;\n for i := 1 to 60 do begin\n l1[i] := -1;\n r1[i] := -1;\n end;\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n for i := 1 to 60 do mas[i] := 0;\n per(l, 0);\n per(r, 1);\n for i := lenr1 to lenl1 do l1[i] := 0;\n for i := 1 to 60 do\n if (l1[i] = 0) and ( r1[i] = 1) then\n begin\n mas[i] := 1;\n flag := 1;\n end\n else\n if (l1[i] = 0) and (r1[i] = 0) then mas[i] := 1 else\n if (l1[i] = 1) and (r1[i] = 1) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and(r1[i] = 0) then mas[i] := 1;\n res := 0;\n step := 1;\n i := 60;\n while i >= lenr1 do begin\n res := res + mas[i] * step;\n step := step * 2;\n i := i - 1;\n end;\n writeln(res);\nend.\n "}, {"source_code": "program ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n mas,l1,r1 : array [1..100] of int64;\n i, flag, lenl1, lenr1 :longint;\n res, step, l, r : int64;\nprocedure per (x:int64; e : longint);\nvar k : longint;\nbegin\n k := 100;\n while x > 0 do begin\n If e = 0 then l1[k] := x mod 2\n else\n r1[k] := x mod 2;\n k := k - 1;\n x := x div 2;\n end;\n if e = 0 then lenl1 := k else lenr1 := k + 1;\nend;\nbegin\n {reset(input,'D.in');\n rewrite(output,'D.out');}\n readln(l, r);\n flag := 0;\n for i := 1 to 100 do begin\n l1[i] := -1;\n r1[i] := -1;\n end;\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n for i := 1 to 100 do mas[i] := 0;\n per(l, 0);\n per(r, 1);\n for i := lenr1 to lenl1 do l1[i] := 0;\n for i := 1 to 100 do\n if (l1[i] = 0) and ( r1[i] = 1) then\n begin\n mas[i] := 1;\n flag := 1;\n end\n else\n if (l1[i] = 0) and (r1[i] = 0) then mas[i] := 1 else\n if (l1[i] = 1) and (r1[i] = 1) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and(r1[i] = 0) then mas[i] := 1;\n res := 0;\n step := 1;\n i := 100;\n while i >= lenr1 do begin\n res := res + mas[i] * step;\n step := step * 2;\n i := i - 1;\n end;\n writeln(res);\nend.\n "}, {"source_code": "program ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n mas,l1,r1 : array [1..100] of int64;\n i, flag, lenl1, lenr1 :longint;\n res, step, l, r : int64;\nprocedure per (x, e : longint);\nvar k : longint;\nbegin\n k := 100;\n while x > 0 do begin\n If e = 0 then l1[k] := x mod 2\n else\n r1[k] := x mod 2;\n k := k - 1;\n x := x div 2;\n end;\n if e = 0 then lenl1 := k else lenr1 := k + 1;\nend;\nbegin\n {reset(input,'D.in');\n rewrite(output,'D.out');}\n readln(l, r);\n flag := 0;\n for i := 1 to 100 do begin\n l1[i] := -1;\n r1[i] := -1;\n end;\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n per(l, 0);\n per(r, 1);\n for i := lenr1 to lenl1 do l1[i] := 0;\n for i := 1 to 100 do\n if (l1[i] = 0) and ( r1[i] = 1) then\n begin\n mas[i] := 1;\n flag := 1;\n end\n else\n if (l1[i] = 0) and (r1[i] = 0) then mas[i] := 1 else\n if (l1[i] = 1) and (r1[i] = 1) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and(r1[i] = 0) then mas[i] := 1;\n res := 0;\n step := 1;\n i := 100;\n while i >= lenr1 do begin\n res := res + mas[i] * step;\n step := step * 2;\n i := i - 1;\n end;\n writeln(res);\nend.\n "}, {"source_code": "program ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n mas,l1,r1 : array [1..100] of int64;\n i, flag, lenl1, lenr1 :longint;\n res, step, l, r : int64;\nprocedure per (x:int64; e : longint);\nvar k : longint;\nbegin\n k := 100;\n while x > 0 do begin\n If e = 0 then l1[k] := x mod 2\n else\n r1[k] := x mod 2;\n k := k - 1;\n x := x div 2;\n end;\n if e = 0 then lenl1 := k else lenr1 := k + 1;\nend;\nbegin\n {reset(input,'D.in');\n rewrite(output,'D.out');}\n readln(l, r);\n flag := 0;\n for i := 1 to 100 do begin\n l1[i] := -1;\n r1[i] := -1;\n end;\n if (l = r) then begin\n writeln(0);\n halt;\n end;\n for i := 1 to 100 do mas[i] := 0;\n per(l, 0);\n per(r, 1);\n for i := lenr1 to lenl1 do l1[i] := 0;\n for i := 1 to 100 do\n if (l1[i] = 0) and ( r1[i] = 1) then\n begin\n mas[i] := 1;\n flag := 1;\n end\n else\n if (l1[i] = 0) and (r1[i] = 0) then mas[i] := 1 else\n if (l1[i] = 1) and (r1[i] = 1) and (flag = 1) then mas[i] := 1 else\n if (l1[i] = 1) and(r1[i] = 0) then mas[i] := 1;\n res := 0;\n step := 1;\n i := 100;\n while i >= lenr1 do begin\n res := res + mas[i] * step;\n step := step * 2;\n i := i - 1;\n end;\n writeln(res);\nend.\n "}], "src_uid": "d90e99d539b16590c17328d79a5921e0"} {"source_code": "label 1,2;\nvar ii,dloch,newdl,i1,j1,k,k1,m,i,j,n:longint; q,pos,koef,ot,t,t1,t2,tt,p3,p4,p1,p2,p,rr,xx,yy,hh:int64;\nflag1,flag2,flag:boolean;\nb,newoch,och,r,c,z,a,x,y:array[-1000000..2000000] of int64;\nmarked:array[-1000..10000000] of boolean;\naa,bb,cc:extended;\nch:char;\nss1,ss2:string;\npee,ppe,pe:array[-10..2000] of char;\ngr,rrr: array[-100..300,-100..300] of int64;\nfunction max(a,b:int64):int64; begin max:=a; if b>a then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a; if b=1 then arcsin:=pi/2 else arcsin:=arctan(x/sqrt(1-x*x));\n\n end;\n function phi(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n phi:=p;\n end;\n\n function good(i,j:longint):boolean;\n begin if (i>=1)and(i<=n)and(j>=1)and(j<=m) then good:=true else good:=false; end;\n\n function right(ii:longint):extended; var al,t,p:extended; i:longint;\n begin al:=phi(x[ii],y[ii]); t:=x[ii]*x[ii]+y[ii]*y[ii]; t:=sqrt(t); right:=al+arcsin(t/rr); end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n\nbegin\n\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n readln(pe[1],pe[2]);\n readln(pe[4],pe[3]);\n readln(ppe[1],ppe[2]);\n readln(ppe[4],ppe[3]);\n\n ss1:=''; for i:=1 to 4 do if pe[i]<>'X' then ss1:=ss1+pe[i];\n ss2:=''; for i:=1 to 4 do if ppe[i]<>'X' then ss2:=ss2+ppe[i];\n\n ss2:=ss2+ss2;\n {writeln(ss1);\n writeln(ss2);\n } for i:=0 to 3 do\n begin\n flag:=true;\n for j:=1 to 3 do if ss1[j]<>ss2[i+j] then flag:=false;\n\n if flag then begin write('YES'); goto 1; end;\n end;\nwrite('NO');\n\n\n1:\nend.\n", "positive_code": [{"source_code": "var st1,st2,st3,st4,st12,st34,st5:string;\np:longint;\nbegin\n readln(st1);\n readln(st2);\n readln(st3);\n readln(st4);\n st12:=st1[1]+st2[1]+st2[2]+st1[2];\n st34:=st3[1]+st4[1]+st4[2]+st3[2];\n p:=pos('X',st12);\n delete(st12,p,1);\n p:=pos('X',st34);\n delete(st34,p,1);\n st5:=st12+st12;\n p:=pos(st34,st5);\n if p<>0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var i, j, k, l, n,m :longint;\nch, ch1:char;\ns, s1:string;\nbegin\nread(ch);\nif ch<>'X' then s:=s+ch;\nreadln(ch);\nif ch<>'X' then s:=s+ch;\nreadln(ch, ch1);\nif ch1<>'X' then s:=s+ch1;\nif ch<>'X' then s:=s+ch;\nread(ch);\nif ch<>'X' then s1:=s1+ch;\nreadln(ch);\nif ch<>'X' then s1:=s1+ch;\nreadln(ch, ch1);\nif ch1<>'X' then s1:=s1+ch1;\nif ch<>'X' then s1:=s1+ch;\nwhile s[1]<>s1[1]do begin\n s1:=s1+s1[1];\n delete(s1,1,1);\n end;\nif s=s1 then write('YES')\n else write('NO');\nEnd.\n\n"}, {"source_code": "program p1;\nvar s1,s2,s3,s4,a,b:string;\n begin\n readln(s1);\n readln(s2);\n readln(s3);\n readln(s4);\n if s1[1]<>'X' then a:=a+s1[1];\n if s1[2]<>'X' then a:=a+s1[2];\n if s2[2]<>'X' then a:=a+s2[2];\n if s2[1]<>'X' then a:=a+s2[1];\n if s3[1]<>'X' then b:=b+s3[1];\n if s3[2]<>'X' then b:=b+s3[2];\n if s4[2]<>'X' then b:=b+s4[2];\n if s4[1]<>'X' then b:=b+s4[1];\n b:=b+b;\n if pos(a,b)<>0 then writeln('YES') else writeln('NO');\n end.\n"}, {"source_code": "var st1,st2,st3,st4,st12,st34,st5:string;\np:longint;\nbegin\nreadln(st1);\nreadln(st2);\nreadln(st3);\nreadln(st4);\nst12:=st1[1]+st2[1]+st2[2]+st1[2];\nst34:=st3[1]+st4[1]+st4[2]+st3[2];\np:=pos('X',st12);\ndelete(st12,p,1);\np:=pos('X',st34);\ndelete(st34,p,1);\nst5:=st12+st12;\np:=pos(st34,st5);\nif p<>0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var i,j,k,c:integer;\na,b:array[1..2] of string;\nr:boolean;\n\nprocedure swap(var q,w:char);\nvar v:char;\nbegin\nv:=q;\nq:=w;\nw:=v;\nend;\n\nbegin\nreadln(a[1]);\nreadln(a[2]);\nreadln(b[1]);\nreadln(b[2]);\nif a[1][1]='X' then c:=1;\nif a[1][2]='X' then c:=2;\nif a[2][2]='X' then c:=3;\nif a[2][1]='X' then c:=4;\nfor i:=c to 16 do begin\nr:=true;\nfor k:=1 to 2 do\nfor j:=1 to 2 do\nif a[k][j]<>b[k][j] then r:=false;\nif r then begin\nwriteln('YES');\nexit;\nend;\ncase i mod 4 of\n1: swap(a[1][1],a[1][2]);\n2: swap(a[1][2],a[2][2]);\n3: swap(a[2][2],a[2][1]);\n0: swap(a[2][1],a[1][1]);\nend;\nend;\nwriteln('NO');\nend."}, {"source_code": "var a,b,c:array[1..4] of char;\nfunction pd:boolean;\nbegin\nif (a[1]=b[1])and(a[2]=b[2])and(a[3]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[1]=b[1])and(a[2]=b[2])and(a[4]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[1]=b[1])and(a[4]=b[2])and(a[3]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[2]=b[2])and(a[1]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[1]=b[2])and(a[3]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[4]=b[2])and(a[1]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[1]=b[2])and(a[4]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[3]=b[2])and(a[1]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[1]=b[2])and(a[2]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[3]=b[2])and(a[4]=b[3])and(a[1]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[4]=b[2])and(a[2]=b[3])and(a[1]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[3]=b[2])and(a[2]=b[3])and(a[1]=b[4]) then exit(true);\nexit(false);\nend;\n\nprocedure change;\nbegin\nif a[1]='X' then\n begin\n c[1]:=a[3]; c[2]:=a[2]; c[3]:=a[4]; c[4]:=a[1];\n a:=c; exit;\n end;\nif a[2]='X' then\n begin\n c[1]:=a[1]; c[2]:=a[4]; c[3]:=a[3]; c[4]:=a[2];\n a:=c; exit;\n end;\nif a[3]='X' then\n begin\n c[1]:=a[1]; c[2]:=a[2]; c[3]:=a[4]; c[4]:=a[3];\n a:=c; exit;\n end;\nif a[4]='X' then exit;\nend;\n\nbegin\nreadln(a[1],a[2]);\nreadln(a[3],a[4]);\nchange;\nreadln(b[1],b[2]);\nreadln(b[3],b[4]);\nif pd then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,i,j:longint;\n ans:int64;\n ans1:real;\n s,s1,s2,s3,s4:string;\n a:array[1..200000] of longint;\nbegin\nfor i:=1 to 2 do\nbegin\nreadln(s);\nif i mod 2=0 then s1:=s1+s[2]+s[1] else s1:=s1+s[1]+s[2];\nend; \ndelete(s1,pos('X',s1),1);\nfor i:=1 to 2 do\nbegin\nreadln(s);\nif i mod 2=0 then s2:=s2+s[2]+s[1] else s2:=s2+s[1]+s[2];\nend;\ndelete(s2,pos('X',s2),1);\ns3:=s2[2]+s2[3]+s2[1];\ns4:=s2[3]+s2[1]+s2[2];\nif (s1=s2) or (s1=s3) or (s1=s4) then write('YES') else write('NO');\nend."}, {"source_code": "var a,b,i,j,m,n,x,y:longint;\n q,w:array[0..101]of longint;\n c,c1,c2,c3:char;\n s,s2,s3,s4:string;\n{procedure qs(l,r:longint);\nbegin\n i:=l;\n j:=r;\n x:=q[(l+r)div 2];\n repeat\n while q[i]x do dec(j);\n if i<=j then\n begin\n y:=q[i];\n q[i]:=q[j];\n q[j]:=y;\n y:=w[i];\n w[i]:=w[j];\n w[j]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if i'X' then\n s3:=s3+s[i];\n i:=1;\n while s2[i]<>s3[1] do\n inc(i);\n s4:=s2[i];\n while length(s4)<>length(s3)do\n begin\n if i=length(s2) then\n i:=1 else\n inc(i);\n if s2[i]<>'X' then\n s4:=s4+s2[i];\n end;\n if s3=s4 then\n write('YES')else\n write('NO');\n// write(s3 ,' ',s4);\nend.\n"}, {"source_code": "var s1,s2,s3,s4:string; i,j:longint;\n a,b:array[1..10] of string;\nbegin\n\n\nreadln(s1);\nreadln(s2);\nreadln(s3);\nreadln(s4);\n\nif s1[1]='X' then begin\n a[1]:='';\n a[1]:=a[1]+s1[2];\n a[1]:=a[1]+s2[2];\n a[1]:=a[1]+s2[1];\n a[2]:='';\n a[2]:=a[2]+s2[1];\n a[2]:=a[2]+s1[2];\n a[2]:=a[2]+s2[2];\n a[3]:='';\n a[3]:=a[3]+s2[2];\n a[3]:=a[3]+s2[1];\n a[3]:=a[3]+s1[2];\n end;\n\nif s1[2]='X' then begin\n a[1]:='';\n a[1]:=a[1]+s2[2];\n a[1]:=a[1]+s2[1];\n a[1]:=a[1]+s1[1];\n a[2]:='';\n a[2]:=a[2]+s1[1];\n a[2]:=a[2]+s2[2];\n a[2]:=a[2]+s2[1];\n a[3]:='';\n a[3]:=a[3]+s2[1];\n a[3]:=a[3]+s1[1];\n a[3]:=a[3]+s2[2];\n end;\n\nif s2[1]='X' then begin\n a[1]:='';\n a[1]:=a[1]+s1[1];\n a[1]:=a[1]+s1[2];\n a[1]:=a[1]+s2[2];\n a[2]:='';\n a[2]:=a[2]+s1[2];\n a[2]:=a[2]+s2[2];\n a[2]:=a[2]+s1[1];\n a[3]:='';\n a[3]:=a[3]+s2[2];\n a[3]:=a[3]+s1[1];\n a[3]:=a[3]+s1[2];\n end;\n\nif s2[2]='X' then begin\n a[1]:='';\n a[1]:=a[1]+s2[1];\n a[1]:=a[1]+s1[1];\n a[1]:=a[1]+s1[2];\n a[2]:='';\n a[2]:=a[2]+s1[2];\n a[2]:=a[2]+s2[1];\n a[2]:=a[2]+s1[1];\n a[3]:='';\n a[3]:=a[3]+s1[1];\n a[3]:=a[3]+s1[2];\n a[3]:=a[3]+s2[1];\n end;\n\n\n\nif s3[1]='X' then begin\n b[1]:='';\n b[1]:=b[1]+s3[2];\n b[1]:=b[1]+s4[2];\n b[1]:=b[1]+s4[1];\n b[2]:='';\n b[2]:=b[2]+s4[1];\n b[2]:=b[2]+s3[2];\n b[2]:=b[2]+s4[2];\n b[3]:='';\n b[3]:=b[3]+s4[2];\n b[3]:=b[3]+s4[1];\n b[3]:=b[3]+s3[2];\n end;\n\nif s3[2]='X' then begin\n b[1]:='';\n b[1]:=b[1]+s4[2];\n b[1]:=b[1]+s4[1];\n b[1]:=b[1]+s3[1];\n b[2]:='';\n b[2]:=b[2]+s3[1];\n b[2]:=b[2]+s4[2];\n b[2]:=b[2]+s4[1];\n b[3]:='';\n b[3]:=b[3]+s4[1];\n b[3]:=b[3]+s3[1];\n b[3]:=b[3]+s4[2];\n end;\n\nif s4[1]='X' then begin\n b[1]:='';\n b[1]:=b[1]+s3[1];\n b[1]:=b[1]+s3[2];\n b[1]:=b[1]+s4[2];\n b[2]:='';\n b[2]:=b[2]+s3[2];\n b[2]:=b[2]+s4[2];\n b[2]:=b[2]+s3[1];\n b[3]:='';\n b[3]:=b[3]+s4[2];\n b[3]:=b[3]+s3[1];\n b[3]:=b[3]+s3[2];\n end;\n\nif s4[2]='X' then begin\n b[1]:='';\n b[1]:=b[1]+s4[1];\n b[1]:=b[1]+s3[1];\n b[1]:=b[1]+s3[2];\n b[2]:='';\n b[2]:=b[2]+s3[2];\n b[2]:=b[2]+s4[1];\n b[2]:=b[2]+s3[1];\n b[3]:='';\n b[3]:=b[3]+s3[1];\n b[3]:=b[3]+s3[2];\n b[3]:=b[3]+s4[1];\n end;\n\n\nfor i:=1 to 3 do\nfor j:=1 to 3 do\nif a[i]=b[j] then begin writeln('YES'); halt; end;\nwriteln('NO');\n\n\n\nend."}, {"source_code": "uses strutils;\nvar ss3,ss4,ss1,ss2,s1,s2,s3,s4:string;\n i,j,n,m:longint; np:char;\n\n\n\nbegin\nreadln(s1);readln(s2);readln(s3);readln(s4);\nss1:=s1+reversestring(s2);\nss2:=s1[1]+s2[1]+s2[2]+s1[2];\n\nss3:=s3+reversestring(s4);\nss4:=s3[1]+s4[1]+s4[2]+s3[2];\n\nfor i:=1 to 4 do\nbegin\nif ss1[i]='X'then delete(ss1,i,1);\nif ss2[i]='X'then delete(ss2,i,1);\nif ss3[i]='X'then delete(ss3,i,1);\nif ss4[i]='X'then delete(ss4,i,1);\nend;\n\nif ss1=ss3 then begin writeln('YES');halt;end;\nnp:=ss1[1];ss1[1]:=ss1[2];ss1[2]:=ss1[3];ss1[3]:=np;\nif ss1=ss3 then begin writeln('YES');halt;end;\nnp:=ss1[1];ss1[1]:=ss1[2];ss1[2]:=ss1[3];ss1[3]:=np;\nif ss1=ss3 then begin writeln('YES');halt;end;\n\nif ss2=ss4 then begin writeln('YES');halt;end;\nnp:=ss2[1];ss2[1]:=ss2[2];ss2[2]:=ss2[3];ss2[3]:=np;\nif ss2=ss4 then begin writeln('YES');halt;end;\nnp:=ss2[1];ss2[1]:=ss2[2];ss2[2]:=ss2[3];ss2[3]:=np;\nif ss2=ss4 then begin writeln('YES');halt;end;\n\n\n\nwriteln('NO');\n\nend.\n"}, {"source_code": "var s1,s2,s3,s4:string;\n n,f,f1:longint;\n begin\n readln(s1);\n readln(s2);\n readln(s3);\n readln(s4); f:=0;f1:=0;\n if (s1[1]='A') and (s1[2]='B') then f:=1;\n if (s1[1]='A') and (s1[2]='X') and (s2[2]='B') then f:=1;\n if (s1[1]='B') and (s1[2]='C') then f:=1;\n if (s1[1]='B') and (s1[2]='X') and (s2[2]='C') then f:=1;\n if (s1[1]='C') and (s1[2]='A') then f:=1;\n if (s1[1]='C') and (s1[2]='X') and (s2[2]='A') then f:=1;\n if (s1[1]='X') and (s1[2]='A') and (s2[2]='B') then f:=1;\n if (s1[1]='X') and (s1[2]='B') and (s2[2]='C') then f:=1;\n if (s1[1]='X') and (s1[2]='C') and (s2[2]='A') then f:=1;\n\n if (s3[1]='A') and (s3[2]='B') then f1:=1;\n if (s3[1]='A') and (s3[2]='X') and (s4[2]='B') then f1:=1;\n if (s3[1]='B') and (s3[2]='C') then f1:=1;\n if (s3[1]='B') and (s3[2]='X') and (s4[2]='C') then f1:=1;\n if (s3[1]='C') and (s3[2]='A') then f1:=1;\n if (s3[1]='C') and (s3[2]='X') and (s4[2]='A') then f1:=1;\n if (s3[1]='X') and (s3[2]='A') and (s4[2]='B') then f1:=1;\n if (s3[1]='X') and (s3[2]='B') and (s4[2]='C') then f1:=1;\n if (s3[1]='X') and (s3[2]='C') and (s4[2]='A') then f1:=1;\n if f1=f then write('YES') else writeln('NO');\nend.\n\n"}, {"source_code": "var a,b:array[1..2,1..2]of char;\ni,j,kl,x,y,p:longint;\ns,s1,s2:string;\nsim:char;\nbegin\n readln(s);\n a[1,1]:=s[1];\n a[1,2]:=s[2];\n readln(s);\n a[2,1]:=s[1];\n a[2,2]:=s[2];\n readln(s);\n b[1,1]:=s[1];\n b[1,2]:=s[2];\n readln(s);\n b[2,1]:=s[1];\n b[2,2]:=s[2];\n for i:=1 to 2 do\n for j:=1 to 2 do\n if a[i,j]='A' then begin\n x:=i;\n y:=j;\n break;\n end;\n if (x=1)and(y=1) then s1:=s1+a[1,1]+a[1,2]+a[2,2]+a[2,1]\n else if (x=1)and(y=2) then s1:=s1+a[1,2]+a[2,2]+a[2,1]+a[1,1]\n else if (x=2)and(y=2) then s1:=s1+a[2,2]+a[2,1]+a[1,1]+a[1,2]\n else s1:=s1+a[2,1]+a[1,1]+a[1,2]+a[2,2];\n for i:=1 to 2 do\n for j:=1 to 2 do\n if b[i,j]='A' then begin\n x:=i;\n y:=j;\n break;\n end;\n if (x=1)and(y=1) then s2:=s2+b[1,1]+b[1,2]+b[2,2]+b[2,1]\n else if (x=1)and(y=2) then s2:=s2+b[1,2]+b[2,2]+b[2,1]+b[1,1]\n else if (x=2)and(y=2) then s2:=s2+b[2,2]+b[2,1]+b[1,1]+b[1,2]\n else s2:=s2+b[2,1]+b[1,1]+b[1,2]+b[2,2];\n for i:=1 to 4 do\n if s1[i]='X' then delete(s1,i,1);\n for i:=1 to 4 do\n if s2[i]='X' then delete(s2,i,1);\n s1:=s1+s1;\n p:=pos(s2,s1);\n if p<>0 then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var s,s1,s2,s3:string;\n a,a1:array[0..100,0..100] of longint;\n p,p1,i,j:longint;\n begin\n readln(s);\n readln(s1);\n readln(s2);\n readln(s3);\n\n a[1][1]:=ord(s[1])-64;\n a[1][2]:=ord(s[2])-64;\n a[2][1]:=ord(s1[1])-64;\n a[2][2]:=ord(s1[2])-64;\n\n for i:=1 to 2 do\n for j:=1 to 2 do\n if a[i][j]=24 then\n a[i][j]:=0;\n\n a1[1][1]:=ord(s2[1])-64;\n a1[1][2]:=ord(s2[2])-64;\n a1[2][1]:=ord(s3[1])-64;\n a1[2][2]:=ord(s3[2])-64;\n\n for i:=1 to 2 do\n for j:=1 to 2 do\n if a1[i][j]=24 then\n a1[i][j]:=0;\n\n\n\n p:=1;\n p1:=1;\n if a[1][1]=1 then\n begin\n if a[1][2]<>0 then\n p:=p*10+a[1][2];\n if a[2][2]<>0 then\n p:=p*10+a[2][2];\n if a[2][1]<>0 then\n p:=p*10+a[2][1];\n end;\n\n if a[1][2]=1 then\n begin\n if a[2][2]<>0 then\n p:=p*10+a[2][2];\n if a[2][1]<>0 then\n p:=p*10+a[2][1];\n if a[1][1]<>0 then\n p:=p*10+a[1][1];\n end;\n\n if a[2][2]=1 then\n begin\n if a[2][1]<>0 then\n p:=p*10+a[2][1];\n if a[1][1]<>0 then\n p:=p*10+a[1][1];\n if a[1][2]<>0 then\n p:=p*10+a[1][2];\n end;\n\n if a[2][1]=1 then\n begin\n if a[1][1]<>0 then\n p:=p*10+a[1][1];\n if a[1][2]<>0 then\n p:=p*10+a[1][2];\n if a[2][2]<>0 then\n p:=p*10+a[2][2];\n end;\n\n\n if a1[1][1]=1 then\n begin\n if a1[1][2]<>0 then\n p1:=p1*10+a1[1][2];\n if a1[2][2]<>0 then\n p1:=p1*10+a1[2][2];\n if a1[2][1]<>0 then\n p1:=p1*10+a1[2][1];\n end;\n\n if a1[1][2]=1 then\n begin\n if a1[2][2]<>0 then\n p1:=p1*10+a1[2][2];\n if a1[2][1]<>0 then\n p1:=p1*10+a1[2][1];\n if a1[1][1]<>0 then\n p1:=p1*10+a1[1][1];\n end;\n\n if a1[2][2]=1 then\n begin\n if a1[2][1]<>0 then\n p1:=p1*10+a1[2][1];\n if a1[1][1]<>0 then\n p1:=p1*10+a1[1][1];\n if a1[1][2]<>0 then\n p1:=p1*10+a1[1][2];\n end;\n\n if a1[2][1]=1 then\n begin\n if a1[1][1]<>0 then\n p1:=p1*10+a1[1][1];\n if a1[1][2]<>0 then\n p1:=p1*10+a1[1][2];\n if a1[2][2]<>0 then\n p1:=p1*10+a1[2][2];\n end;\n\n if p=p1 then writeln('YES') else writeln('NO');\n end.\n\n\n"}, {"source_code": "var st1,st2,st3,st4,s1,s2:string;\np:longint;\nbegin\n readln(st1);\n readln(st2);\n readln(st3);\n readln(st4);\n s1:=st1+st2[2]+st2[1];\n s2:=st3+st4[2]+st4[1];\n p:=pos('X',s1);\n delete(s1,p,1);\n p:=pos('X',s2);\n delete(s2,p,1);\n if s1[2]='A' then s1:=s1[2]+s1[3]+s1[1]\nelse if s1[3]='A' then s1:=s1[3]+s1[1]+s1[2];\n if s2[2]='A' then s2:=s2[2]+s2[3]+s2[1]\nelse if s2[3]='A' then s2:=s2[3]+s2[1]+s2[2];\n if s1<>s2 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var st1,st2,st3,st4:string;\n x:char;\n b,a:array[1..10000] of char;\n s,j, k,i:longint;\nbegin\nreadln(st1);\nif st1[1]<>'X' then\n begin\n inc(k);\n a[k]:=st1[1];\n end;\nif st1[2]<>'X' then\n begin\n inc(k);\n a[k]:=st1[2];\n end;\n\n\n\nreadln(st2);\n if st2[2]<>'X' then\n begin\n inc(k);\n a[k]:=st2[2];\n end;\nif st2[1]<>'X' then\n begin\n inc(k);\n a[k]:=st2[1];\n end;\nk:=0;\n\n\n\n\nreadln(st3);\nif st3[1]<>'X' then\n begin\n inc(k);\n b[k]:=st3[1];\n end;\nif st3[2]<>'X' then\n begin\n inc(k);\n b[k]:=st3[2];\n end;\nreadln(st4);\nif st4[2]<>'X' then\n begin\n inc(k);\n b[k]:=st4[2];\n end;\nif st4[1]<>'X' then\n begin\n inc(k);\n b[k]:=st4[1];\n end;\n\nfor i:=1 to 3 do a[i+3]:=a[i];\n\nfor i:=1 to 3 do b[i+3]:=b[i];\nfor i:=1 to 6 do\nif a[1]=b[i] then break;\nj:=1;\nwhile (a[j]=b[i]) and (s<3) do\n begin\n\n inc(s);\n inc(j);\n inc(i);\n end;\nif s=3 then write ('YES') else write('NO');\nend."}, {"source_code": "Program Main;\n \n var temp, One , Two : String;\n i : LongInt;\n \nbegin\n readLn ( temp ) ; \n \n One := temp;\n \n readLn ( temp ) ;\n \n One := One + temp[2] + temp[1];\n \n readLn ( temp ) ; \n \n Two := temp;\n \n readLn ( temp ) ;\n \n Two := Two + temp[2] + temp[1];\n \n \n for i := 1 to 4 do\n begin\n if ( One[i] = 'X' ) then\n Delete ( One , i , 1 ) ; \n if ( Two[i] = 'X' ) then\n Delete ( Two , i , 1 ) ; \n end;\n \n \n while ( One[1] <> 'A' ) do\n begin\n One := One [ 2 ] + One[3] + One[1];\n end;\n \n while ( Two[1] <> 'A' ) do\n begin\n Two := Two[2] + Two [ 3 ] + Two [ 1 ] ; \n end;\n \n \n if ( One = Two ) then\n writeLn ( 'YES' )\n else\n writeLn ( 'NO' ) ; \n \n \n\nend."}, {"source_code": "procedure replace(var a,b:char);\nvar\nc:char;\nbegin\nc:=a;\na:=b;\nb:=c;\nend;\nprocedure make(var s1:string;s:string;d:longint);\nvar\ni,j:longint;\ns2:string;\nbegin\nfor i:=1 to 4 do\nif s[i]='X'\nthen j:=i;\nif s1=s\nthen begin\nwriteln('YES');\nhalt;\nend;\ns2:=s;\nif d=10\nthen exit;\nif j=1\nthen begin\nreplace(s[2],s[1]);\nmake(s1,s,d+1);\ns:=s2;\nreplace(s[3],s[1]);\nmake(s1,s,d+1);\nend;\nif j=2\nthen begin\nreplace(s[2],s[1]);\nmake(s1,s,d+1);\ns:=s2;\nreplace(s[4],s[2]);\nmake(s1,s,d+1);\nend;\nif j=3\nthen begin\nreplace(s[3],s[1]);\nmake(s1,s,d+1);\ns:=s2;\nreplace(s[4],s[3]);\nmake(s1,s,d+1);\nend;\nif j=4\nthen begin\nreplace(s[2],s[4]);\nmake(s1,s,d+1);\ns:=s2;\nreplace(s[3],s[4]);\nmake(s1,s,d+1);\nend;\nend;var\ns1,s2,s3,s4,s:string;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nreadln(s4);\ns:=s1+s2;\nmake(s,s3+s4,1);\nwriteln('NO');\nend.\n"}, {"source_code": "var\nch, ch1: string;\na1, a2, a3, a4, a5, a6, a7, a8: char;\ns, s1, s2, s3, s4: string;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nreadln(s4);\na1:= s1[1];\na2:= s1[2];\na3:= s2[2];\na4:= s2[1];\na5:= s3[1];\na6:= s3[2];\na7:= s4[2];\na8:= s4[1];\nif a1 = 'X' then ch:= ch + a2 + a3 + a4;\nif a2 = 'X' then ch:= ch + a3 + a4 + a1;\nif a3 = 'X' then ch:= ch + a4 + a1 + a2;\nif a4 = 'X' then ch:= ch + a1 + a2 + a3;\nif a5 = 'X' then ch1:= ch1 + a6 + a7 + a8;\nif a6 = 'X' then ch1:= ch1 + a7 + a8 + a5;\nif a7 = 'X' then ch1:= ch1 + a8 + a5 + a6;\nif a8 = 'X' then ch1:= ch1 + a5 + a6 + a7;\nif ((ch = 'CAB') or (ch = 'BCA') or (ch = 'ABC')) and ((ch1 = 'CAB') or (ch1 = 'BCA') or (ch1 = 'ABC'))\nthen\nbegin\nwriteln('YES');\nexit;\nend;\nif ((ch = 'CBA') or (ch = 'BAC') or (ch = 'ACB')) and ((ch1 = 'CBA') or (ch1 = 'BAC') or (ch1 = 'ACB'))\nthen\nbegin\nwriteln('YES');\nexit;\nend;\nwriteln('NO');\nend."}, {"source_code": "\nprogram Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n mas1:array[1..4] of string;\n mas2:array[1..4] of string;\n s1,s2:string;\n a,b:Integer;\n f:Boolean;\nprocedure rotatemas1();\nvar i:integer;\nbegin\n for i:=1 to 3 do\n begin\n if mas1[i]='X' then\n begin\n mas1[i]:=mas1[i+1];\n mas1[i+1]:='X';\n Exit;\n end;\n end;\n\n if mas1[4]='X' then\n begin\n mas1[4]:=mas1[1];\n mas1[1]:='X';\n end;\n\nend;\n\n\nbegin\n\n Readln(s1);\n mas1[2]:=s1[1]; mas1[3]:=s1[2];\n Readln(s1);\n mas1[1]:=s1[1]; mas1[4]:=s1[2];\n\n Readln(s1);\n mas2[2]:=s1[1]; mas2[3]:=s1[2];\n Readln(s1);\n mas2[1]:=s1[1]; mas2[4]:=s1[2];\n\n f:=false;\n for a:=1 to 17 do\n begin\n if (mas1[1]=mas2[1]) and\n (mas1[2]=mas2[2]) and\n (mas1[3]=mas2[3]) and\n (mas1[4]=mas2[4])\n then\n f:=true;\n rotatemas1;\n\n end;\n\n\n if f=True then\n Writeln('YES')\n else\n Writeln('NO'); Readln(a);\n\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='a';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q'X' then s1:=s1+s[i];\n readln(s);\n for i:=2 downto 1 do if s[i]<>'X' then s1:=s1+s[i];\n readln(s);\n for i:=1 to 2 do if s[i]<>'X' then s2:=s2+s[i];\n readln(s);\n for i:=2 downto 1 do if s[i]<>'X' then s2:=s2+s[i];\n q:=0;\n c:=0;\n if (((s1[1]='A')and(s1[2]='B')) or ((s1[2]='A')and(s1[3]='B')) or ((s1[3]='A')and(s1[1]='B')))\n then q:=1 else q:=2;\n if (((s2[1]='A')and(s2[2]='B')) or ((s2[2]='A')and(s2[3]='B')) or ((s2[3]='A')and(s2[1]='B')))\n then c:=1 else c:=2;\n if q=c then writeln('YES') else writeln('NO');\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var st1,st2,st3,st4,st12,st34,st5:string;\np:longint;\nbegin\n readln(st1);\n readln(st2);\n readln(st3);\n readln(st4);\n\n st12:=st1[1]+st2[1]+st2[2]+st1[2];\n st34:=st3[1]+st4[1]+st4[2]+st3[2];\n\n p:=pos('X',st12);\n delete(st12,p,1);\n\n p:=pos('X',st34);\n delete(st34,p,1);\n\n st5:=st12+st12;\n p:=pos(st34,st5);\n if p<>0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n s1, s2, s3, ans: string;\n i, k: integer;\n c: char;\nbegin\n ans := 'NO';\n readln(s1);\n readln(s3);\n s1 := s1 + s3[2] + s3[1];\n readln(s2);\n readln(s3);\n s2 := s2 + s3[2] + s3[1];\n k := pos('X', s1);\n delete(s1, k, 1);\n k := pos('X', s2);\n delete(s2, k, 1); \n for i := 1 to 3 do\n begin\n c := s1[1];\n s1[1] := s1[2];\n s1[2] := s1[3];\n s1[3] := c;\n if s1 = s2 then \n begin\n ans := 'YES';\n break;\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n p,a:array[1..4] of char;\n k,s:string;\n c:char;\n i,j,v,n:longint;\nbegin\n for i:=1 to 2 do\n read(p[i]);\n readln; \n for i:=4 downto 3 do\n read(p[i]);\n readln ;\n for i:=1 to 2 do\n read(a[i]);\n readln ;\n for i:=4 downto 3 do\n read(a[i]); \n s:='';\n for i:=1 to 4 do\n if(p[i]<>'X') then s:=s+p[i];\n v:=0;\n i:=0;\n while(v=0)and(i<10) do\n begin\n \n k:='';\n for j:=1 to 4 do\n if(a[j]<>'X') then k:=k+a[j];\n \n if(s<>k) then i:=i+1;\n if(s = k) then v:=1;\n // writeln(s,' ',k);\n c:=a[4];\n for j:=4 downto 2 do\n a[j]:=a[j-1];\n a[1]:=c;\n end;\n if(v=1) then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var a,b,c:array[1..4] of char;\nfunction pd:boolean;\nbegin\nif (a[1]=b[1])and(a[2]=b[2])and(a[3]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[1]=b[1])and(a[2]=b[2])and(a[4]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[1]=b[1])and(a[4]=b[2])and(a[3]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[2]=b[2])and(a[1]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[1]=b[2])and(a[3]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[4]=b[2])and(a[1]=b[3])and(a[3]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[1]=b[2])and(a[4]=b[3])and(a[2]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[3]=b[2])and(a[1]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[1]=b[2])and(a[2]=b[3])and(a[4]=b[4]) then exit(true);\nif (a[2]=b[1])and(a[3]=b[2])and(a[4]=b[3])and(a[1]=b[4]) then exit(true);\nif (a[3]=b[1])and(a[4]=b[2])and(a[2]=b[3])and(a[1]=b[4]) then exit(true);\nif (a[4]=b[1])and(a[3]=b[2])and(a[2]=b[3])and(a[1]=b[4]) then exit(true); \nexit(false);\nend; \nprocedure change;\nbegin\nif a[1]='X' then\n begin\n c[1]:=a[3]; c[2]:=a[2]; c[3]:=a[4]; c[4]:=a[1];\n a:=c; exit;\n end; \nif a[2]='X' then\n begin\n c[1]:=a[1]; c[2]:=a[4]; c[3]:=a[3]; c[4]:=a[2];\n a:=c; exit;\n end;\nif a[3]='X' then\n begin\n c[1]:=a[1]; c[2]:=a[2]; c[3]:=a[4]; c[4]:=a[3];\n a:=c; exit;\n end; \nif a[4]='X' then exit;\nend;\nbegin\nreadln(a[1],a[2]);\nreadln(a[3],a[4]);\nchange;\nreadln(b[1],b[2]);\nreadln(b[3],b[4]);\nif pd then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var s1, s2, s3, s4 : ansistring;\n a, b : array[1 .. 2, 1 .. 2] of char;\n mas : array[0 .. 111111] of ansistring;\n cnt : longint;\n ok : boolean;\n\nprocedure swap(var t, y : char);\nvar u : char;\nbegin\n u := t; t := y; y := u;\nend;\n\nprocedure solve;\nvar st : string;\n i : longint;\nbegin\n if ok then exit;\n st := a[1][1] + a[1][2] + a[2][1] + a[2][2];\n if st = s3 + s4 then\n begin\n ok := true;\n exit;\n end;\n for i := 1 to cnt do\n if mas[i] = st then\n exit;\n cnt := cnt + 1;\n mas[cnt] := st;\n if (a[1][1] = 'X') then\n begin\n swap(a[1][1], a[1][2]);\n solve;\n swap(a[1][1], a[1][2]);\n swap(a[1][1], a[2][1]);\n solve;\n swap(a[1][1], a[2][1]);\n end else\n if (a[1][2] = 'X') then\n begin\n swap(a[1][1], a[1][2]);\n solve;\n swap(a[1][1], a[1][2]);\n swap(a[1][2], a[2][2]);\n solve;\n swap(a[1][2], a[2][2]);\n end else\n if (a[2][1] = 'X') then\n begin\n swap(a[2][1], a[1][1]);\n solve;\n swap(a[2][1], a[1][1]);\n swap(a[2][1], a[2][2]);\n solve;\n swap(a[2][1], a[2][2]);\n end else\n begin\n swap(a[2][2], a[2][1]);\n solve;\n swap(a[2][2], a[2][1]);\n swap(a[2][2], a[1][2]);\n solve;\n swap(a[2][2], a[1][2]);\n end;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n readln(s3);\n readln(s4);\n a[1][1] := s1[1]; a[1][2] := s1[2];\n a[2][1] := s2[1]; a[2][2] := s2[2];\n b[1][1] := s3[1]; b[1][2] := s3[2];\n b[2][1] := s4[1]; b[2][2] := s4[2];\n ok := false;\n cnt := 0;\n solve;\n if (ok) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,i,j:longint;\n ans:int64;\n ans1:real;\n s,s1,s2,s3,s4:string;\n a:array[1..200000] of longint;\nbegin\nfor i:=1 to 2 do\nbegin\nreadln(s);\nif i mod 2=0 then s1:=s1+s[2]+s[1] else s1:=s1+s[1]+s[2];\nend; \ndelete(s1,pos('X',s1),1);\nfor i:=1 to 2 do\nbegin\nreadln(s);\nif i mod 2=0 then s2:=s2+s[2]+s[1] else s2:=s2+s[1]+s[2];\nend;\ndelete(s2,pos('X',s2),1);\ns3:=s2[2]+s2[3]+s2[1];\ns4:=s2[3]+s2[1]+s2[2];\nif (s1=s2) or (s1=s3) or (s1=s4) then write('YES') else write('NO');\nend."}, {"source_code": "var\n i: Integer;\n s, p, t: string[4];\n \nbegin\n ReadLn (s);\n ReadLn (t);\n s:= s + t[2] + t[1];\n ReadLn (p);\n ReadLn (t);\n p:= p + t[2] + t[1];\n \n for i:= 1 to 4 do\n if s[i] = 'X' then\n begin\n Delete (s, i, 1);\n break\n end;\n \n for i:= 1 to 4 do\n if p[i] = 'X' then\n begin\n Delete (p, i, 1);\n break\n end;\n \n if s = p then\n WriteLn ('YES')\n else if s = p[2] + p[3] + p[1] then\n WriteLn ('YES')\n else if s = p[3] + p[1] + p[2] then\n WriteLn ('YES')\n else\n WriteLn ('NO')\nend."}], "negative_code": [{"source_code": "var aa,a,b:array[0..100,0..100] of char;\n p,p1,p2,t,pr,n,i,j:longint;s1:string;np:char;\n\nprocedure prov(x:longint);\nvar ii,jj:longint;\nbegin\npr:=0;\n for ii:=1 to 2 do\n for jj:=1 to 2 do\n if a[ii,jj]<>b[ii,jj]then begin pr:=1;break;end;\nif pr=0 then begin writeln('YES');halt;end;\nend;\n\nprocedure prov2(x:longint);\nvar ii,jj:longint;\nbegin\npr:=0;\n for ii:=1 to 2 do\n for jj:=1 to 2 do\n if aa[ii,jj]<>b[ii,jj]then begin pr:=1;break;end;\nif pr=0 then begin writeln('YES');halt;end;\nend;\n\nbegin\nreadln(s1);for j:=1 to 2 do begin a[1,j]:=s1[j];aa[1,j]:=a[1,j];end;\n\nreadln(s1);for j:=1 to 2 do begin a[2,j]:=s1[j];aa[2,j]:=a[2,j];end;\n\nreadln(s1);for j:=1 to 2 do b[1,j]:=s1[j];\n\nreadln(s1);for j:=1 to 2 do b[2,j]:=s1[j];\n\nfor i:=1 to 2 do\n for j:=1 to 2 do\n if a[i,j]='X'then begin p1:=i;p2:=j;end;\n\nprov(1);\n\npr:=0;\nt:=0;\n\n\n\nif (p1=1)and(p2=1) then begin\n np:=a[1,1];a[1,1]:=a[1,2];a[1,2]:=np;\n np:=aa[1,1];aa[1,1]:=aa[2,1];aa[2,1]:=np;\n prov(1);prov2(1);\n np:=a[1,2];a[1,2]:=a[2,2];a[2,2]:=np;\n np:=aa[2,1];aa[2,1]:=aa[2,2];aa[2,2]:=np;\n prov(1);prov2(1);\n np:=a[2,2];a[2,2]:=a[2,1];a[2,1]:=np;\n np:=aa[2,2];aa[2,2]:=aa[1,2];aa[1,2]:=np;\n prov(1);prov2(1);\n np:=a[2,1];a[2,1]:=a[1,1];a[1,1]:=np;\n np:=aa[1,2];aa[1,2]:=aa[1,1];aa[1,1]:=np;\n prov(1);prov2(1);\n end;\nif (p1=1)and(p2=2) then begin\n np:=a[1,2];a[1,2]:=a[1,1];a[1,1]:=np;\n np:=aa[1,2];aa[1,2]:=aa[2,2];aa[2,2]:=np;\n prov(1);prov2(1);\n np:=a[1,1];a[1,1]:=a[2,1];a[2,1]:=np;\n np:=aa[2,2];aa[2,2]:=aa[2,1];aa[2,1]:=np;\n prov(1);prov2(1);\n np:=a[2,1];a[2,1]:=a[2,2];a[2,2]:=np;\n np:=aa[2,1];aa[2,1]:=aa[1,1];aa[1,1]:=np;\n prov(1);prov2(1);\n np:=a[2,2];a[2,2]:=a[1,2];a[1,2]:=np;\n np:=aa[1,1];aa[1,1]:=aa[1,2];aa[1,2]:=np;\n prov(1);prov2(1);\n end;\nif (p1=2)and(p2=1) then begin\n np:=a[2,1];a[2,1]:=a[1,1];a[1,1]:=np;\n np:=aa[2,1];aa[2,1]:=aa[2,2];aa[2,2]:=np;\n prov(1);prov2(1);\n np:=a[1,1];a[1,1]:=a[1,2];a[1,2]:=np;\n np:=aa[2,2];aa[2,2]:=aa[1,2];aa[1,2]:=np;\n prov(1);prov2(1);\n np:=a[1,2];a[1,2]:=a[2,2];a[2,2]:=np;\n np:=aa[1,2];aa[1,2]:=aa[1,1];aa[1,1]:=np;\n prov(1);prov2(1);\n np:=a[2,2];a[2,2]:=a[2,1];a[2,1]:=np;\n np:=aa[1,1];aa[1,1]:=aa[2,1];aa[2,1]:=np;\n prov(1);prov2(1);\n end;\nif (p1=2)and(p2=2) then begin\n np:=a[2,2];a[2,2]:=a[1,2];a[1,2]:=np;\n np:=aa[2,2];aa[2,2]:=aa[2,1];aa[2,1]:=np;\n prov(1);prov2(1);\n np:=a[1,2];a[1,2]:=a[1,1];a[1,1]:=np;\n np:=aa[2,1];aa[2,1]:=aa[1,1];aa[1,1]:=np;\n prov(1);prov2(1);\n np:=a[1,1];a[1,1]:=a[2,1];a[2,1]:=np;\n np:=aa[1,1];aa[1,1]:=aa[1,2];aa[1,2]:=np;\n prov(1);prov2(1);\n np:=a[2,1];a[2,1]:=a[2,2];a[2,2]:=np;\n np:=aa[1,2];aa[1,2]:=aa[2,2];aa[2,2]:=np;\n prov(1);prov2(1);\n end;\n\n\n\n\nwriteln('NO');\n\n\n\n\n\nend.\n"}, {"source_code": "var a,b,c:array[1..2,1..2]of char;\ni,j,kl:longint;\ns:string;\nsim:char;\nbegin\n readln(s);\n a[1,1]:=s[1];\n a[1,2]:=s[2];\n readln(s);\n a[2,1]:=s[1];\n a[2,2]:=s[2];\n readln(s);\n b[1,1]:=s[1];\n b[1,2]:=s[2];\n readln(s);\n b[2,1]:=s[1];\n b[2,2]:=s[2];\n c:=a;\n while true do\n begin\n for i:=1 to 2 do\n begin\n kl:=0;\n for j:=1 to 2 do\n if c[i,j]='X' then begin\n if (i=1)and(j=1)then begin\n sim:=c[2,1];\n c[2,1]:='X';\n c[1,1]:=sim;\n kl:=1;\n break;\n end\n else if (i=1)and(j=2)then begin\n sim:=c[1,1];\n c[1,1]:='X';\n c[1,2]:=sim;\n kl:=1;\n break;\n end\n else if (i=2)and(j=1)then begin\n sim:=c[2,2];\n c[2,2]:='X';\n c[2,1]:=sim;\n kl:=1;\n break;\n end\n else if (i=2)and(j=2)then begin\n sim:=c[1,2];\n c[1,2]:='X';\n c[2,2]:=sim;\n kl:=1;\n break;\n end;\n end;\n if kl=1 then break;\n end;\n kl:=0;\n for i:=1 to 2 do\n for j:=1 to 2 do\n if a[i,j]<>c[i,j] then kl:=1;\n if kl=0 then begin\n writeln('NO');\n halt;\n end;\n kl:=0;\n for i:=1 to 2 do\n for j:=1 to 2 do\n if b[i,j]<>c[i,j] then kl:=1;\n if kl=0 then begin\n writeln('YES');\n halt;\n end;\n end;\nend.\n"}, {"source_code": "var st1,st2,st3,st4:string;\n x:char;\n b,a:array[1..10000] of char;\n s,j, k,i:longint;\nbegin\nreadln(st1);\nif st1[1]<>'X' then\n begin\n inc(k);\n a[k]:=st1[1];\n end;\nif st1[2]<>x then\n begin\n inc(k);\n a[k]:=st1[2];\n end;\n\n\n\nreadln(st2);\n if st2[2]<>'X' then\n begin\n inc(k);\n a[k]:=st2[2];\n end;\nif st2[1]<>x then\n begin\n inc(k);\n a[k]:=st2[1];\n end;\nk:=0;\n\n\n\n\nreadln(st3);\nif st3[1]<>'X' then\n begin\n inc(k);\n b[k]:=st3[1];\n end;\nif st3[2]<>x then\n begin\n inc(k);\n b[k]:=st3[2];\n end;\nreadln(st4);\nif st4[2]<>'X' then\n begin\n inc(k);\n b[k]:=st4[2];\n end;\nif st4[1]<>'X' then\n begin\n inc(k);\n b[k]:=st4[1];\n end;\n\nfor i:=1 to 3 do a[i+3]:=a[i];\n\nfor i:=1 to 3 do b[i+3]:=b[i];\nfor i:=1 to 6 do\nif a[1]=b[i] then break;\nj:=1;\nwhile (a[j]=b[i]) and (s<3) do\n begin\n\n inc(s);\n inc(j);\n inc(i);\n end;\nif s=3 then write ('YES') else write('NO');\nend."}, {"source_code": "var st1,st2,st3,st4:string;\n x:char;\n b,a:array[1..10000] of char;\n s,j, k,i:longint;\nbegin\nreadln(st1);\nif st1[1]<>'X' then\n begin\n inc(k);\n a[k]:=st1[1];\n end;\nif st1[2]<>x then\n begin\n inc(k);\n a[k]:=st1[2];\n end;\n\n\n\nreadln(st2);\n if st2[2]<>'X' then\n begin\n inc(k);\n a[k]:=st2[2];\n end;\nif st2[1]<>x then\n begin\n inc(k);\n a[k]:=st2[1];\n end;\nk:=0;\n\n\n\n\nreadln(st3);\nif st3[1]<>'X' then\n begin\n inc(k);\n b[k]:=st3[1];\n end;\nif st3[2]<>x then\n begin\n inc(k);\n b[k]:=st3[2];\n end;\nreadln(st4);\nif st4[2]<>'X' then\n begin\n inc(k);\n b[k]:=st4[2];\n end;\nif st4[1]<>x then\n begin\n inc(k);\n b[k]:=st4[1];\n end;\n\nfor i:=1 to 3 do a[i+3]:=a[i];\n\nfor i:=1 to 3 do b[i+3]:=b[i];\nfor i:=1 to 6 do\nif a[1]=b[i] then break;\nj:=1;\nwhile (a[j]=b[i]) and (s<3) do\n begin\n\n inc(s);\n inc(j);\n inc(i);\n end;\nif s=3 then write ('YES') else write('NO');\nend."}, {"source_code": "label 1,2;\nvar ii,dloch,newdl,i1,j1,k,k1,m,i,j,n:longint; q,pos,koef,ot,t,t1,t2,tt,p3,p4,p1,p2,p,rr,xx,yy,hh:int64;\nflag1,flag2,flag:boolean;\nb,newoch,och,r,c,z,a,x,y:array[-1000000..2000000] of int64;\nmarked:array[-1000..10000000] of boolean;\naa,bb,cc:extended;\nch:char;\nss1,ss2:string;\npee,ppe,pe:array[-10..2000] of char;\ngr,rrr: array[-100..300,-100..300] of int64;\nfunction max(a,b:int64):int64; begin max:=a; if b>a then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a; if b=1 then arcsin:=pi/2 else arcsin:=arctan(x/sqrt(1-x*x));\n\n end;\n function phi(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n phi:=p;\n end;\n\n function good(i,j:longint):boolean;\n begin if (i>=1)and(i<=n)and(j>=1)and(j<=m) then good:=true else good:=false; end;\n\n function right(ii:longint):extended; var al,t,p:extended; i:longint;\n begin al:=phi(x[ii],y[ii]); t:=x[ii]*x[ii]+y[ii]*y[ii]; t:=sqrt(t); right:=al+arcsin(t/rr); end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n\nbegin\n\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n readln(pe[1],pe[2]);\n readln(pe[4],pe[3]);\n readln(ppe[1],ppe[2]);\n readln(ppe[4],ppe[3]);\n\n{ for i:=1 to 4 do write(pe[i]); writeln;\n for i:=1 to 4 do write(ppe[i]); writeln;\n } for i:=1 to 4 do ppe[4+i]:=ppe[i];\n for i:=0 to 3 do\n begin\n flag:=true;\n { writeln('i= ',i);\n } for j:=1 to 4 do if pe[j]<>ppe[i+j] then\n begin flag:=false;{ writeln('bad j= ',j); } end;\n\n if flag then begin writeln('YES'); goto 1; end;\n\n end;\n\n for i:=8 downto 1 do if ppe[i]='X' then ii:=i;\n i:=ii;\n\n if i>1\n then begin ch:=ppe[i]; ppe[i]:=ppe[i-1];ppe[i-1]:=ch; end else\n begin ch:=ppe[4]; ppe[4]:=ppe[1];ppe[1]:=ch; end ;\n\n for i:=1 to 4 do ppe[4+i]:=ppe[i];\n\n { for i:=1 to 4 do write(pe[i]); writeln;\n for i:=1 to 4 do write(ppe[i]); writeln;\n }\n for i:=0 to 3 do\n begin\n flag:=true;\n { writeln('i= ',i);\n } for j:=1 to 4 do if pe[j]<>ppe[i+j] then\n begin flag:=false; {writeln('bad j= ',j); } end;\n\n if flag then begin writeln('YES'); goto 1; end;\n\n end;\n\n\n if i<4\n then begin ch:=ppe[i]; ppe[i]:=ppe[i+1];ppe[i+1]:=ch; end else\n begin ch:=ppe[4]; ppe[4]:=ppe[1];ppe[1]:=ch; end ;\n\n for i:=1 to 4 do ppe[4+i]:=ppe[i];\n\n { for i:=1 to 4 do write(pe[i]); writeln;\n for i:=1 to 4 do write(ppe[i]); writeln;\n }\n for i:=0 to 3 do\n begin\n flag:=true;\n { writeln('i= ',i);\n } for j:=1 to 4 do if pe[j]<>ppe[i+j] then\n begin flag:=false; {writeln('bad j= ',j); } end;\n\n if flag then begin writeln('YES'); goto 1; end;\n\n end;\n\n\n\n\n write('NO');\n\n1:\nend.\n"}], "src_uid": "46f051f58d626587a5ec449c27407771"} {"source_code": "var\n n, r, x, y: Int64;\n i: LongInt;\n move: Array[1..6] of Int64;\nfunction min(a, b: Int64): Int64;\nbegin\n if a < b then\n min := a\n else\n min := b;\nend;\nbegin\n readLn(n);\n r := trunc(sqrt(1/9 + n/3) - 1/3);\n n := n - r * (3 * r + 2);\n for i := 1 to 6 do\n move[i] := r * (r + 1) div 2;\n move[2] := move[2] - r;\n for i := 1 to 6 do\n if i <> 2 then\n begin\n move[i] := move[i] + min(n, r + 1);\n n := n - min(n, r + 1);\n end else\n begin\n move[i] := move[i] + min(n, r);\n n := n - min(n, r);\n end;\n x := move[1] - move[2] + move[5] - move[4] + 2 * (move[6] - move[3]);\n y := 2 * (move[1] + move[2] - move[4] - move[5]);\n writeLn(x, ' ', y);\nend.", "positive_code": [{"source_code": "var\n Dx:array[1..6] of longint = (-1,-2,-1,1,2,1);\n Dy:array[1..6] of longint = (2,0,-2,-2,0,2);\n j,k,n,x,y:int64;\n i:longint;\n\nbegin\n read(n);\n k:=trunc(sqrt(n/3));\n while 3*k*(k+1)k do\n begin\n Inc(x,Dx[i]*k);\n Inc(y,Dy[i]*k);\n Inc(i); Dec(j,k);\n end;\n Inc(x,Dx[i]*j); Inc(y,Dy[i]*j);\n write(x,' ',y);\nend."}, {"source_code": "var\n Dx:array[1..6] of longint = (-1,-2,-1,1,2,1);\n Dy:array[1..6] of longint = (2,0,-2,-2,0,2);\n j,k,n,x,y:int64;\n i:longint;\n\nbegin\n readln(n);\n k:=trunc(sqrt(n/3));\n while 3*k*(k+1)k do\n begin\n Inc(x,Dx[i]*k);\n Inc(y,Dy[i]*k);\n Inc(i); Dec(j,k);\n end;\n Inc(x,Dx[i]*j); Inc(y,Dy[i]*j);\n write(x,' ',y);\nend."}, {"source_code": "\nuses math;\nvar\n\n d,kr,o,t,n,x,y,l,r,c:int64;\n\nfunction calc(z:int64):int64;\nbegin\n calc:=int64(3)*z*(z+int64(1));\nend;\n\n\nbegin\n readln(n);\n if n=0 then\n begin\n writeln('0 0');halt;\n end;\n if n=1 then\n begin\n writeln('1 2');halt;\n end;\n\n l:=0;\n r:=1000000000;\n while(l0 then\n begin\n d:=min(n,kr-t);\n d:=max(d,0);\n dec(n,d);\n x:=x-d;\n y:=y+t*d;\n end;\n if n>0 then\n begin\n d:=min(n,kr-o);\n d:=max(d,0);\n dec(n,d);\n x:=x-t*d;\n end;\n if n>0 then\n begin\n d:=min(n,kr-o);\n d:=max(d,0);\n dec(n,d);\n x:=x-d;\n y:=y-t*d;\n end;\n if n>0 then\n begin\n d:=min(n,kr-o);\n d:=max(d,0);\n dec(n,d);\n x:=x+d;\n y:=y-t*d;\n end;\n if n>0 then\n begin\n d:=min(n,kr-o);\n d:=max(d,0);\n dec(n,d);\n x:=x+t*d;\n end;\n if n>0 then\n begin\n d:=min(n,kr-o);\n d:=max(d,0);\n dec(n,d);\n x:=x+d;\n y:=y+t*d;\n end;\n writeln(x,' ',y);\n\nend.\n"}, {"source_code": "\nconst dx : array[0 .. 5] of longint = (1, -1, -2, -1, 1, 2);\n dy : array[0 .. 5] of longint = (2, 2, 0, -2, -2, 0);\n\nvar\n l, r, mid, cur, d, cx, cy, n : int64;\n dir : longint;\n\nbegin\n read(n);\n d := 0;\n dir := 0;\n cx := 0;\n cy := 0;\n l := 0;\n r := 1000000000;\n while l < r - 1 do begin\n mid := (l + r) shr 1;\n if (mid * (mid - 1) shr 1) * 6 + mid * 5 < n then l := mid else r := mid;\n end;\n n := n - ((l * (l - 1) shr 1) * 6 + l * 5);\n cx := l;\n cy := -2 * l;\n d := l;\n while n > 0 do begin\n cur := d;\n if (dir = 0) then begin\n inc(cur);\n end else if dir = 1 then begin\n inc(d);\n end;\n if cur >= n then begin\n cur := n;\n end;\n cx := cx + dx[dir] * cur;\n cy := cy + dy[dir] * cur;\n n := n - cur;\n dir := (dir + 1) mod 6;\n end;\n writeln(cx, ' ', cy);\nend."}, {"source_code": "program E1;\nvar\nn,l,r,k,h,m:int64;\nbegin\nread(n);\nif n = 0 then write(0,' ',0) else \n begin\n n:=n+1;\n l:=0;\n r:=1000000000;\n while r - l <> 1 do\n begin\n m:=(l+r) div 2;\n if n <= 3*m*(m+1)+1 then r:=m \n else l:=m\n end;\n n:=n-1-3*r*(r-1);\n r:=r+1;\n h:=n div (r-1);\n k:=n mod (r-1);\n if k=0 then\n if h=1 then write(r-1,' ',(r-1)*2) else\n if h=2 then write(-r+1,' ',(r-1)*2) else\n if h=3 then write((1-r)*2,' ',0) else\n if h=4 then write(-r+1,' ',(1-r)*2) else\n if h=5 then write(r-1,' ',(1-r)*2) else\n write((r-1)*2,' ',0) else\n if h=1 then write(r-1-2*k,' ',(r-1)*2) else\n if h=2 then write(-r+1-k,' ',(r-1)*2-2*k) else\n if h=3 then write((1-r)*2+k,' ',-k*2) else\n if h=4 then write(-r+1+k*2,' ',(1-r)*2) else\n if h=5 then write(r-1+k,' ',(1-r)*2+2*k) else\n write((r-1)*2-k,' ',k*2)\n end;\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n label 1,2,3,4;\n\nvar step,kt,ppp,god,day,mon,mask,i0,j0,k,i,j,start,finish,kol,m:longint;\nt,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,yy,q,t1,t2,p4,cc,p1,p2,ot,dist1,avt,zap,ba,by,aa,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nd,pp1,pp2,pp3,pp4,f,x,y,fact,c,b,a,prost:array[-100000..1000000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndist,palin:array[-100..510,-100..510] of int64;\nss,ss1,ss2:string;\ndd:array[-10..6000,-10..6000] of int64;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction ff(i:int64):int64; begin ff:=i*(4+3*i); end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n { for j:=1 to 20 do\n}begin\n n:=j;\n read(n);\n if n=0 then begin write(0,' ',0); goto 1; end;\n dec(n);\n x[1]:=-2;y[1]:=0;\n x[2]:=-1;y[2]:=-2;\n x[3]:=1;y[3]:=-2;\n x[4]:=2;y[4]:=0;\n x[5]:=1;y[5]:=2;\n x[6]:=-1;y[6]:=2;\n\n\n aa:=0; bb:=1000000000;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) div 2;\n if ff(cc)<=n then aa:=cc else bb:=cc;\n end;\n\n { writeln(cc);\n } cc:=max(cc-3,-1);\n repeat inc(cc); until ff(cc)>n;\n dec(cc);\n { writeln(cc);\n } t:=n-ff(cc);\n k:=t div (cc+1)+1;\n { writeln('t= ',t,' k= ',k);\n } xx:=cc+1; yy:=2*cc+2;\n { writeln(xx,' ',yy);\n } for i:=1 to k-1 do begin xx:=xx+x[i]*(cc+1); yy:=yy+y[i]*(cc+1); end;\n { writeln(xx,' ',yy);\n }\n p1:=t mod (cc+1);\n { writeln('p1= ',p1);\n } xx:=xx+p1*x[k];\n yy:=yy+p1*y[k];\n { writeln(n,' + ',cc,' <> ',ff(cc+1));\n } if n+cc+1>=ff(cc+1) then xx:=xx+2;\n\n\n writeln(xx,' ',yy);\n\n\n\n\nend;\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var n,k,x,y:int64;\nprocedure shuchu;\nbegin\n if n=0 then\n begin\n writeln(k*2-2,' ',0);\n exit;\n end;\n if n<=k then\n begin\n writeln(k*2-n,' ',n*2);\n exit;\n end;\n dec(n,k);\n if n<=k then\n begin\n writeln(k-n*2,' ',k*2);\n exit;\n end;\n dec(n,k);\n if n<=k then\n begin\n writeln(-k-n,' ',k*2-n*2);\n exit;\n end;\n dec(n,k);\n if n<=k then\n begin\n writeln(-k*2+n,' ',-n*2);\n exit;\n end;\n dec(n,k);\n if n<=k then\n begin\n writeln(-k+n*2,' ',-k*2);\n exit;\n end;\n dec(n,k);\n if n<=k then\n begin\n writeln(k+n,' ',-k*2+n*2);\n exit;\n end;\nend;\nbegin\n read(n);\n if n=0 then writeln('0 0') else\n if n=1 then writeln('1 2') else\n if n=2 then writeln('-1 2') else\nbegin\n k:=1;\n k:=trunc(sqrt(n/3));\n while n div k div 3 div (k+1)>=1 do\n inc(k);\n dec(k);\n n:=n-k*(k+1)*3;\n inc(k);\n shuchu;\nend;\nend.\n"}], "negative_code": [{"source_code": "var n,k,x,y:longint;\nbegin\n read(n);\n k:=1;\n k:=trunc(sqrt(n/3));\n while n div k div 3 div (k+1)>=1 do\n inc(k);\n dec(k);\n n:=n-k*(k+1)*3;\n inc(k);\n x:=k*2-2;\n y:=0;\n if n=0 then writeln(x,' ',y);\n if n=1 then writeln(x+1,' ',y+2) else\n if n<=k then writeln(k*2-n,' ',n*2) else\n if n<=k*2 then writeln(k*3-n*2,k*2) else\n if n<=k*3 then writeln(-k-(n-k*2),k*2-2*(n-k*2)) else\n if n<=k*4 then writeln(-k*2+(n-k*3),-2*(n-k*3)) else\n if n<=k*5 then writeln(-k+2*(n-k*4),-k*2) else\n if n<=k*6 then writeln(k+(n-k*5),-k*2-2*(n-k*5));\nend.\n"}, {"source_code": "var n,k,x,y:int64;\nbegin\n read(n);\n k:=1;\n k:=trunc(sqrt(n/3));\n while n div k div 3 div (k+1)>=1 do\n inc(k);\n dec(k);\n n:=n-k*(k+1)*3;\n inc(k);\n x:=k*2-2;\n y:=0;\n if n=0 then writeln(x,' ',y) else\n if n=1 then writeln(x+1,' ',y+2) else\n if n<=k then writeln(k*2-n,' ',n*2) else\n if n<=k*2 then writeln(k*3-n*2,' ',k*2) else\n if n<=k*3 then writeln(-k-(n-k*2),' ',k*2-2*(n-k*2)) else\n if n<=k*4 then writeln(-k*2+(n-k*3),' ',-2*(n-k*3)) else\n if n<=k*5 then writeln(-k+2*(n-k*4),' ',-k*2) else\n if n<=k*6 then writeln(k+(n-k*5),' ',-k*2-2*(n-k*5));\nend.\n"}, {"source_code": "var\n n, r, x, y: Int64;\n i: LongInt;\n move: Array[1..6] of Int64;\nfunction min(a, b: Int64): Int64;\nbegin\n if a < b then\n min := a\n else\n min := b;\nend;\nbegin\n readLn(n);\n r := trunc(sqrt(1/9 + n/3) - 1/3);\n n := n - r * (6 * r - 1);\n for i := 1 to 6 do\n move[i] := r * (r + 1) div 2;\n move[2] := move[2] - r;\n for i := 1 to 6 do\n if i <> 2 then\n begin\n move[i] := move[i] + min(n, r + 1);\n n := n - min(n, r + 1);\n end else\n begin\n move[i] := move[i] + min(n, r);\n n := n - min(n, r);\n end;\n x := move[1] - move[2] + move[5] - move[4] + 2 * (move[6] - move[3]);\n y := 2 * (move[1] + move[2] - move[4] - move[5]);\n writeLn(x, ' ', y);\nend."}], "src_uid": "a4b6a570f5e63462b68447713924b465"} {"source_code": "program theeternalimmortality;\nvar a,b:int64;\nprocedure input;\nvar f:text;\nbegin\n readln(a,b);\nend;\nprocedure output;\nvar f:text;\n x,y,i,k:longint;\nbegin\n if b-a=0 then writeln(1) else\n if b-a>=10 then writeln(0)\n else\n begin\n x:=a mod 10;\n y:=b mod 10;\n if y>x then\n begin\n k:=1;\n for i:=x+1 to y do k:=(k*i)mod 10;\n writeln(k);\n end\n else writeln(0);\n end;\nend;\nbegin\n input;\n output;\nend.\n\n\n\n", "positive_code": [{"source_code": "program hrn;\n var\n a,b,p,q,x:qword;i:longint;\n begin\n read(a,b);x:=1;\n if b-a>=10 then x:=0\n else begin\n p:=b mod 10;\n q:=a mod 10;\n if p=10 then x:=x mod 10;\n end\n end;\n write(x);\n end.\n"}, {"source_code": "var a,b,i,kq:int64;\nbegin\n readln(a,b);\n kq:=1;\n i:=a+1;\n if b>=a+10 then writeln(0) else begin\n while i<=b do begin\n kq:=kq*i;\n kq:=kq mod 10;\n inc(i);\n end;\n writeln(kq);\n end;\nend.\n"}, {"source_code": "program qq;\nvar a,b,o,n,i:int64;\nBegin\n read(a,b); n:=1;i:=a+1;\n while i<=b do begin\n o:=i mod 10;\n n:=(n*o) mod 10;\n if n=0 then break;\n i:=i+1;\n end;\n writeln(n);\nend.\n"}, {"source_code": "program cf1;\n//uses crt;\nvar a,b :int64;\n x,y,i,s :integer;\n f:text;\n//--------------------------\nbegin\n//clrscr;\nassign(f,'');\nreset(f);\nreadln(f,a,b);\nx:=a mod 10;\ny:=b mod 10;\ns:=1;\nif (b-a >=10) or (ya)then begin\ncol:=1;\nstart:=(a+1)mod 10;\nfinish:=(b)mod 10;\nif(finish=a then\n begin\n if b-a>10 then\n begin\n writeln(0);\n halt;\n end;\n sum:=1;\n inc(a);\n while a<=b do\n begin\n sum:=sum*(a mod 10);\n sum:=sum mod 10;\n inc(a);\n end;\n writeln(sum);\n end\n else writeln(0);\nend."}, {"source_code": "var a,b,i,ans:qword;\nbegin\n readln(a,b);\n if b-a>10 then writeln(0)\n else begin\n ans:=1;\n i:=a+1;\n while i<=b do begin\n ans:=(ans*i) mod 10;\n inc(i);\n end;\n writeln(ans);\n end;\nreadln;\nend."}, {"source_code": "var a,b:int64;\nprocedure solve;\nvar j:int64;\n k,i:integer;\nbegin\n j:=b-a;\n if j>=10 then\n begin\n writeln('0');\n exit;\n end\n else\n begin\n k:=1;\n b:=b mod 10;\n while (b-j)=10 then begin write (0); exit; end\nelse\nbegin\nfor i:=1 to b-a do\n begin\n j:=(j*((a+i) mod 10)) mod 10;\n end;\nwrite (j);\nend;\nend."}, {"source_code": " var a,b,k,x:int64;\n i:longint;\nbegin\n readln(a,b);\n k:=a+1;\n k:=k mod 10;\n x:=(b-a-1) mod 1000;\n if (b-a-1)>x then\n x:=x+1000;\n for i:=1 to x do begin\n k:=k*((i+a+1) mod 10);\n k:=k mod 10;\n if k=0 then\n break;\n end;\n if b=0 then\n k:=1;\n if a=b then\n k:=1;\n writeln(k);\nend."}, {"source_code": "Uses math;\nConst\n fin='';\n fon='';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n\nType\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,kq:longint;\n a,b:int64;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti:longint;\nBegin\n Readln(fi,a,b);\nEnd;\n\nProcedure xuly;\nVar\n j:longint;\n i:int64;\nBegin\n If b-a>4 then\n Begin\n Write(fo,0);\n Exit;\n End;\n kq:=1;\n i:=a+1;\n While i<=b do\n Begin\n kq:=(kq*(i mod 10)) mod 10;\n inc(i);\n End;\n Writeln(fo,kq mod 10);\nEnd;\n\nProcedure xuat;\nBegin\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND."}, {"source_code": "{$mode objfpc}\nprogram Fenix;\n\nvar\n a, b, c, proizv: int64;\n\n i: integer;\nbegin\n readln(a, b);\n\n c := b - a;\n\n if c = 0 then\n begin\n Write(1);\n //readln();\n exit;\n end;\n\n proizv := 1;\n if c >= 10 then\n begin\n Write(0);\n //readln();\n exit;\n end\n else\n begin\n c := c mod 100;\n b := b mod 100;\n for i := (b - c + 1) to b do\n proizv := (proizv * i) mod 10;\n end;\n\n Write(proizv);\n // readln();\nend."}, {"source_code": "\nvar a,b,o,n,i:int64;\nBegin\n read(a,b); n:=1;i:=a+1;\n while i<=b do begin\n o:=i mod 10;\n n:=(n*o) mod 10;\n if n=0 then break;\n i:=i+1;\n end;\n writeln(n);\nend."}, {"source_code": "var ans:longint;\n a,b,i:int64;\n begin\n readln(a,b); ans:=1;\n i:=a+1; if b-a+1>10 then writeln(0) else begin\n while i<=b do begin\n ans:=ans*(i mod 10) mod 10;\n inc(i);\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "var\na,b,c,i:qword;\n\nflag: integer;\nbegin\nreadln(a,b);\nc:=b-a;\nflag:=1;\nif (c=0) then writeln(1)\nelse begin\n c:=1;\n i:=a+1;\n while ((i<=b)and(flag=1)) do begin\n c:=c*(i mod 10);\n if (c=0) then flag:=0;\n i:=i+1;\n end;\n writeln(c mod 10);\nend;\n\nend."}, {"source_code": "program a;\nvar a,b,j,otv: int64;\nbegin\n read(a);\n read(b);\n j:=a+1;\n otv:=1;\n if(a>b) then otv:=0;\n \n if((b-a)>10) then begin \n otv:=0;\n j:=b+1;\n end; \n \n \n while(j<=b) do begin\n otv := (otv*(j mod 10)) mod 10;\n inc(j);\n end;\n writeln(otv);\nend. "}, {"source_code": "const fi = '';\n fo = '';\nvar f : text;\n a,b,i : int64;\n res : byte;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,a,b);\n close(f);\n\n inc(a);\n res:= a mod 10;\n if (b-a+1) >= 10 then res:= 0\n else if (a = b) then res:= b mod 10\n else if (a = b + 1) then res:= 1\n else repeat\n inc(a);\n res:= (res * (a mod 10)) mod 10;\n until a = b;\n\n assign(f,fo);\n rewrite(f);\n write(f,res);\n close(f);\nend.\n"}, {"source_code": "var a,b,c1,pn :qword;\n kq,i : longint;\nBEGIN\n read(a,b);\n kq:=1;\n if b mod 10=0 then kq:=0;\n if b mod 10 <> 0 then\n for i:=1 to b-a do\n begin\n pn:=a+i;\n c1:=pn mod 10;\n kq:=kq * c1;\n kq:=kq mod 10;\n if kq=0 then break;\n end;\n if a=b then kq:=1;\n write(kq);\nEND."}, {"source_code": "{$MACRO ON}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n{$DEFINE wait:=readln;readln;}\n{$DEFINE maxN:=trunc(5e5)+1}\n\nuses gvector,garrayutils,math;\nconst\tfi='';\n\t\tfo='';\ntype\n\tTType = int32; // <------ TYPE\n\tvector = specialize TVector;\n compare = class\n \tpublic\n \tclass function c(a,b : TType) : boolean;\n end;\n utils = specialize TOrderingArrayUtils;\nclass function compare.c(a,b : TType) : boolean;\n\tbegin Result := a=10 do\n so:=so mod 10;\n inc(a);\n if so=0 then\n begin\n writeln(so);\n halt;\n end;\n until a>b;\n writeln(so);\n end;\nend.\n"}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$inline on}\nconst\n fi='input.txt';\n fo='output.txt';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nvar a,b:int64;\nprocedure enter;\nbegin\n readln(a,b);\nend;\nprocedure solve;\nvar i:int64;\n tmp:int64;\nbegin\n tmp:=1;\n if (b-a>=10) then write(0)\n else\n begin\n i:=a+1;\n while i<=b do\n begin\n tmp:=(tmp*i) mod 10;\n inc(i);\n end;\n writeln(tmp);\n end;\nend;\nbegin\n //fileio;\n enter;\n solve;\nend."}, {"source_code": "var a,b:int64;\n i,j,t1,t,ans:longint;\nbegin\n readln(a,b);\n if b-a>=5 then\n begin\n writeln('0');\n halt;\n end\n else\n begin\n t1:=a mod 10;t:=b-a;ans:=1;\n for i:=t1+1 to t1+t do\n ans:=ans*i;\n ans:=ans mod 10;\n end;\n writeln(ans);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n\n k:=1;\n if (b-a) >= 10 then\n k:=0;\n if b-a < 10 then\n if b=a then k:=1 else\n if b mod 10=0 then k:=0\n else\n begin a:=a mod 10000;\n b:=b mod 10000;\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n end;\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m:longint;\n c,d:array[1..100000] of boolean;\n sc,sd:array[1..100000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure check(x,y:longint);\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction last(x:int64):longint;\n begin\n if x<=1 then exit(1) else\n if x=2 then exit(2) else\n if x=3 then exit(6) else\n if x=4 then exit(4) else exit(0);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,ta,tb:longint;\n a,b:int64;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n tg,a,b,t:int64;\n begin\n read(fi,a,b);\n t:=a+1;\n tg:=1;\n while t<=b do\n begin\n tg:=(tg*(t mod 10)) mod 10;\n if tg=0 then\n begin\n writeln(fo,0);\n exit;\n end;\n inc(t);\n end;\n writeln(fo,tg mod 10);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var i,n,a,x,b:int64;\nbegin\n n:=1;\n read(a,b);\n i:=a;\n if b - a > 10 then write(0)\n else\n begin\n while i <> b do\n begin\n i:=i+1;\n n:=(n * (i mod 10)) mod 10;\n end;\n write(n);\n end;\nend."}, {"source_code": "program test;\nvar\n a,b,i,ans:qword;\nbegin\n readln(a,b);\n if b-a>10 then writeln(0)\n else\n begin\n ans:=1;\n i:=a+1;\n while i<=b do\n begin\n ans:=(ans*i) mod 10;\n inc(i);\n end;\n writeln(ans);\n end;\n readln;\nend.\n\n"}, {"source_code": "program hrn;\n var\n a,b,p,q,x:qword;i:longint;\n begin\n read(a,b);x:=1;\n if b-a>=10 then x:=0\n else begin\n p:=b mod 10;\n q:=a mod 10;\n if p=10 then x:=x mod 10;\n end\n end;\n write(x);\n end.\n\n"}, {"source_code": "var\ni,a,b,f:int64;\nbegin\nread(a,b);\nif b-a>9 then begin writeln('0');exit;end\nelse begin\ni:=a+1;\n f:=1;\n while i<=b do begin\n f:=(f*(i mod 10)mod 10);\n inc(i);\n end;\n end;\n writeln(f);\n end.\n "}, {"source_code": "var a,b,d,k:int64; i,k1:integer;\nbegin\nd:=1;\nread(a,b);\nif (b-a)<10 then\nbegin\n k:=b-a; k1:=round(k);\nfor i:=1 to k1 do\nbegin\nk:=a+i mod 10;\nd:=d*k;\nd:=d mod 10;\nend;\nend else d:=0;\nwrite(d);\nend.\n"}, {"source_code": "var a, b, i, s: int64;\nBegin;\n readln (a, b);\n if b-a>4 then begin;\n writeln (0);\n exit;\n end;\n s:=1;\n i:=(a mod 10)+1;\n if i<=b mod 10 then Begin;\n while i<=(b mod 10) do begin;\n s:=s*i;\n i:=i+1;\n end;\n end\n else Begin;\n if a=b then writeln (1) else writeln(0);\n exit;\n end;\n writeln (s mod 10);\nend."}, {"source_code": "Program CodeF_439_B;\nvar a,b:int64;\n i,k:longint;\n\n\nbegin\nread(a,b);\nk:=1;\n\n if ((b div 10)>(a div 10)) then write(0) else\n begin\n for i:=(a mod 10)+1 to (b mod 10) do\n begin\n k:=(k*i) mod 10;\n end;\n write(k);\n end;\n\n\n\n\n\n\nend.\n"}, {"source_code": "const fi='';\nvar f:text;\n n,m,s:int64;\n i,t1,t2:longint;\nprocedure print(s:longint);\nbegin\n write(s);\n readln;\n halt;\nend;\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);\n if m-n>=10 then print(0);\n t1:=m mod 10;\n t2:=n mod 10;\n if t1= 2 then\n begin\n n:=b;\n repeat\n if (n mod 5 <> 0) then\n begin\n x:=x*n;\n x:=x mod 10;\n end\n else begin x:=0; break; end;\n dec(n);\n until (n=a) ;\n end\n ELSE if b-a=1 then x:=b mod 10;\n writeln(x);\n //readln;\nend.\n\n"}, {"source_code": "const\n fi ='';\n fo ='';\n\nvar\n ff, gg: text;\n A, B, C: int64;\n i, j, t, kq: longint;\n\nbegin\n assign(ff, fi); reset(ff);\n assign(gg, fo); rewrite(gg);\n readln(ff, A, B);\n C:= B- A;\n if C > 9 then write(0) else\n begin\n A:= A mod 10;\n t:= A;\n t:=(t+1) mod 10;\n j:= C;\n kq:= 1;\n for i:= 1 to j do\n begin\n kq:= kq*(t mod 10);\n t:= (t+1) mod 10;\n end;\n write(gg, kq mod 10);\n end;\n close(ff);\n close(gg);\nend.\n\n"}, {"source_code": "program fenix;\nvar a,b,c,i:int64;\nbegin\nreadln(a,b);\nc:=1;\nif b-a>=10 then c:=0\nelse\nfor i:=a+1 to b do\nc:=(c*i mod 10)mod 10;\nwriteln(c);\nend."}, {"source_code": "program z1;\nvar a,b,c,i,n:int64;\nfunction min(a,b:int64):int64;\nbegin\nif a>b then min:=b\nelse min:=a;end;\nbegin\nread(a,b);\nc:=1;if b-a =1 then begin write (b mod 10);exit;end;\nif a=0 then a:=1;if b=0 then b:=1;\nif b-a>10 then begin write(0);exit;end;\ni:=a+1;\nwhile i<=b do begin\nc:=c*(i mod 10);Inc(i);end;\nwrite(c mod 10);\nend."}, {"source_code": "var i,n,m,k: int64;\nbegin\n read(n,k);\n if k-n>9 then write (0) else if n=k then \n begin\n \n write(1)\n end else begin\n m:=(n+1) mod 10; n:=n+2;\n while n=5 then write('0')\n else\n begin\n for i:=1 to abs(a-b)\ndo\nbegin\n l:=((a+i) mod 10);\n K:=K*l;\n end;\n write(k mod 10)\n end;\n\n end.\n\n"}, {"source_code": "var i,ans,a,b:int64;\nbegin\n readln(a,b);\n \n if (b - a <= 10) then begin\n ans:=1;\n for i:=a+1 to b do begin\n ans:=ans * i;\n if (ans >= 10) then\n ans:=ans mod 10;\n end;\n writeln(ans);\n end\n else\n writeln(0);\nend."}, {"source_code": "\n const eps=0.0000000001; nn=200000; besk=8000000000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ot,sum1,sum2,ost,kol,zapas,dist,r,ll,rr,sum,q,h,pos,t1,t2,pp,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;\n ii,jj,step, k,i,j:longint;\n aa,bb,cc:int64;\n fast,slow,z,pr,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;\n dd:array[-10..2000,-10..200] of extended;\n zanx,zany:array[-10..20000000] of boolean;\n marked,zan:array[-10..10000000] of boolean;\n ss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ch:char;\n d :array [0..100,-10..100,-10..100] of extended;\n dda:array [0..201,-10..30] of int64;\n sss:array[0..nn] of string;\n st2:array[0..nn] of string;\n pr1,pr2,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n prob:array[-1..200,-1..200] of extended;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n if p2>p1+5 then begin write(0); goto 1; end;\n p1:=p1 mod 10;\n p2:=p2 mod 10;\n if p2 9 then write(0) else\n begin\n A:= A mod 10;\n t:= A;\n t:=(t+1) mod 10;\n j:= C;\n kq:= 1;\n for i:= 1 to j do\n begin\n kq:= kq*t;\n inc(t);\n end;\n write(kq mod 10);\n end;\n readln;\nend.\n"}, {"source_code": "program z1;\nvar a,b,c:int64;i,m:longint;n:int64;\nfunction min(a,b:int64):int64;\nbegin\nif a>b then min:=b\nelse min:=a;end;\nbegin\nread(a,b);\nc:=1;if b-a =1 then begin write (b mod 10);exit;end;\nif a=0 then a:=1;if b=0 then b:=1;\nif b-a>10 then begin write(0);exit;end;\nfor i:= a+1 to b do\nc:=c*(i mod 10);\nwrite(c mod 10);\nend."}, {"source_code": "program z1;\nvar a,b,c:int64;i,m:longint;n:byte;\nfunction min(a,b:longint):longint;\nbegin\nif a>b then min:=b\nelse min:=a;end;\nbegin\nread(a,b);\nc:=1;if b-a =1 then begin write (b mod 10);exit;end;\nif a=0 then a:=1;if b=0 then b:=1;n:=min(b-a,10);\nif n=10 then begin write(0);exit;end;\nfor i:= a+1 to b do\nc:=c*(i mod 10);\nwrite(c mod 10);\nend."}, {"source_code": "program z1;\nvar a,b,c:int64;i,m:longint;n:byte;\nfunction min(a,b:longint):longint;\nbegin\nif a>b then min:=b\nelse min:=a;end;\nbegin\nread(a,b);\nc:=1;\nif a=0 then a:=1;if b=0 then b:=1;n:=min(b-a,10);\nif n=10 then begin write(0);exit;end;\nfor i:= a+1 to b do\nc:=c*(i mod 10);\nwrite(c mod 10);\nend."}, {"source_code": "var i,n,m,k: int64;\nbegin\n read(n,k);\n if k-n>9 then write (0) else if n=k then \n begin\n \n write(1)\n end else begin\n m:=(n+1) mod 10; \n while n=5 then write('0')\n else\n begin\n for i:=1 to abs(a-b)\ndo\nbegin\n l:=(a+i mod 10);\n K:=K*l;\n end;\n write(k mod 10)\n end;\n\n end.\n\n"}, {"source_code": "var a,b,i,kq:int64;\nbegin\n readln(a,b);\n kq:=(a+1)mod 10;\n i:=a+2;\n while i<=b do begin\n kq:=(kq*i) mod 10;\n if kq=0 then break;\n inc(i);\n end;\n writeln(kq);\nend.\n"}, {"source_code": "program qq;\nvar a,b,o,n,i:int64;\nBegin\n read(a,b); n:=1;i:=a+1;\n while a<=b do begin\n o:=i mod 10;\n n:=(n*o) mod 10;\n if n=0 then break;\n i:=i+1;\n end;\n writeln(n);\nend.\n"}, {"source_code": "var\na,b:int64;\ncol:integer;\nstart:integer;\nfinish:integer;\ni:integer;\nbegin\nread(a,b);\ni:=1; \ncol:=0;\nif(b<6+a)then begin\ncol:=1;\nstart:=(a+1)mod 10;\nfinish:=(b)mod 10;\nif(finish10 then writeln(0)\n else if a=b then write(1)\n else begin\n ans:=1;\n i:=a+1;\n while i<=b do begin\n ans:=(ans*i) mod 10;\n inc(i);\n end;\n writeln(ans);\n end;\n end."}, {"source_code": "var i,a,a1,b,b1:longint;\nbegin\nreadln(a,b);\nif b-a>10 then writeln(0)\n else begin\n a:=a mod 10;\n b:=b mod 10;\n a1:=1;\n for i:=2 to a do\n a1:=a1*i;\n b1:=1;\n for i:=2 to b do\n b1:=b1*i;\n b1:=b1 div a1;\n write(b1 mod 10);\n end;\n end."}, {"source_code": "var i,a,a1,b,b1:longint;\nbegin\nreadln(a,b);\nif b-a>=10 then writeln(0)\n else begin\n a:=a mod 10;\n inc(a);\n b:=b mod 10;\n inc(b);\n a1:=1;\n for i:=2 to a do\n a1:=a1*i;\n b1:=1;\n for i:=2 to b do\n b1:=b1*i;\n b1:=b1 div a1;\n write(b1 mod 10);\n end;\n end."}, {"source_code": "var i,a,a1,b,b1:longint;\nbegin\nreadln(a,b);\nif b-a>=10 then writeln(0)\n else begin\n if a>10 then begin\n a:=a mod 10;\n inc(a);\n b:=b mod 10;\n inc(b);\n end;\n a1:=1;\n for i:=2 to a do\n a1:=a1*i;\n b1:=1;\n for i:=2 to b do\n b1:=b1*i;\n b1:=b1 div a1;\n write(b1 mod 10);\n end;\n end."}, {"source_code": "var a,b,i,ans:longint;\nbegin\n readln(a,b);\n if b-a>10 then writeln(0)\n else begin\n ans:=1;\n i:=a+1;\n while i<=b do begin\n ans:=(ans*i) mod 10;\n inc(i);\n end;\n writeln(ans);\n end;\nreadln;\nend."}, {"source_code": "var a,b,n,i,j:integer;\nd:array [1..9] of integer;\nbegin\nread (a,b);\nn:=b-a;\nj:=1;\nif n>=10 then begin write (0); exit; end\nelse\nbegin\nfor i:=1 to n do\n begin\n j:=(j*(a+i)) mod 10;\n end;\nwrite (j);\nend;\nend."}, {"source_code": "var a,b:int64;c:byte;\nBegin\n readln(a,b);\n b:=b-a;a:=1;\n if(b<5) then begin\n for c:=1 to b do a:=(a*c)mod 10\n end\n else a:=0;\n write(a);\nend."}, {"source_code": "var a,b:int64;c,z:byte;\nBegin\n readln(a,b);\n z:=1;\n if(b-a<5) then begin\n for c:=a+1 to b do z:=(z*c)mod 10\n end\n else z:=0;\n write(z);\nend."}, {"source_code": "var ans,i:longint;\n a,b:int64;\n begin\n readln(a,b); ans:=1;\n for i:=a+1 to b do\n ans:=ans*(i mod 10) mod 10;\n writeln(ans);\n end.\n"}, {"source_code": "var\na,b,c,i:qword;\n\nflag: integer;\nbegin\nreadln(a,b);\nc:=b-a;\nflag:=1;\nif (c=0) then writeln(1)\nelse begin\n c:=1;\n i:=a+1;\n while ((i<=b)and(flag=1)) do begin\n c:=c*(i mod 10);\n if (c=0) then flag:=0;\n i:=i+1;\n end;\nend;\nwriteln(c mod 10);\nend."}, {"source_code": "var a,b,c1,pn :qword;\n kq,i : longint;\nBEGIN\n read(a,b);\n kq:=1;\n\n if b mod 10=0 then kq:=0;\n if b mod 10 <> 0 then\n for i:=1 to b-a do\n begin\n pn:=a+i;\n c1:=pn mod 10;\n kq:=kq * c1;\n kq:=kq mod 10;\n if kq=0 then break;\n end;\n\n write(kq);\nEND."}, {"source_code": " var a,b,k:int64;\n i:longint;\nbegin\n readln(a,b);\n k:=a+1;\n k:=k mod 10;\n for i:=1 to (b-a-1) do begin\n k:=k*((i+a+1) mod 10);\n k:=k mod 10;\n if k=0 then\n break;\n end;\n if b=0 then\n k:=1;\n if a=b then\n k:=1;\n writeln(k);\nend."}, {"source_code": " var a,b,k:int64;\n i:longint;\nbegin\n readln(a,b);\n k:=a+1;\n for i:=a+2 to b do begin\n k:=k*i;\n k:=k mod 10;\n end;\n if b=0 then\n k:=1;\n writeln(k);\nend."}, {"source_code": " var a,b,k:int64;\n i:longint;\nbegin\n readln(a,b);\n k:=a+1;\n k:=k mod 10;\n for i:=1 to (b-a-1) mod 100 do begin\n k:=k*((i+a+1) mod 10);\n k:=k mod 10;\n if k=0 then\n break;\n end;\n if b=0 then\n k:=1;\n if a=b then\n k:=1;\n writeln(k);\nend."}, {"source_code": " var a,b,k:int64;\n i:longint;\nbegin\n readln(a,b);\n k:=a+1;\n for i:=1 to (b-a-1) do begin\n k:=k*((i+a+1) mod 10);\n k:=k mod 10;\n if k=0 then\n break;\n end;\n if b=0 then\n k:=1;\n writeln(k);\nend."}, {"source_code": "\n const eps=0.0000000001; nn=200000; besk=8000000000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ot,sum1,sum2,ost,kol,zapas,dist,r,ll,rr,sum,q,h,pos,t1,t2,pp,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;\n ii,jj,step, k,i,j:longint;\n aa,bb,cc:int64;\n fast,slow,z,pr,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;\n dd:array[-10..2000,-10..200] of extended;\n zanx,zany:array[-10..20000000] of boolean;\n marked,zan:array[-10..10000000] of boolean;\n ss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ch:char;\n d :array [0..100,-10..100,-10..100] of extended;\n dda:array [0..201,-10..30] of int64;\n sss:array[0..nn] of string;\n st2:array[0..nn] of string;\n pr1,pr2,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n prob:array[-1..200,-1..200] of extended;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n\n p1:=p1 mod 10;\n p2:=p2 mod 10;\n if p2>p1+5 then begin write(0); goto 1; end;\n if p2= 10 then\n begin\n Write(0);\n //readln();\n exit;\n end\n else\n begin\n for i := (b - c + 1) to b do\n proizv := (proizv * i) mod 10;\n end;\n\n Write(proizv);\n // readln();\nend."}, {"source_code": "{$mode objfpc}\nprogram Fenix;\nvar\n a, b, c, proizv: int64;\n s: string;\n i: integer;\nbegin\n readln(a, b);\n\n c := b - a;\n\n if c = 0 then\n begin\n write(1);\n //readln();\n exit;\n end;\n\n proizv := 1;\n for i := 1 to b - ((b - c)) do\n proizv := proizv * (i + (b - c));\n\n str(proizv, s);\n\n write(s[length(s)]);\n //readln();\nend.\n"}, {"source_code": "{$mode objfpc}\nprogram Fenix;\nvar\n a, b, c, proizv: int64;\n s: string;\n i: integer;\nbegin\n readln(a, b);\n\n c := b - a;\n\n if c = 0 then\n begin\n write(1);\n // readln();\n exit;\n end;\n\n proizv := 1;\n if (c div 10) >= 1 then\n begin\n write(0);\n //readln();\n exit;\n end\n else\n begin\n for i := (b - c + 1) to b do\n proizv := proizv * i;\n end;\n\n str(proizv, s);\n\n write(s[length(s)]);\n\n // readln();\nend.\n"}, {"source_code": "{$mode objfpc}\nprogram Fenix;\nvar\n a, b, c, proizv: int64;\n s: string;\n i: integer;\nbegin\n readln(a, b);\n\n c := b - a;\n\n if c = 0 then\n begin\n write(1);\n // readln();\n exit;\n end;\n\n proizv := 1;\n if (c div 10) >= 1 then\n begin\n write(0);\n //readln();\n exit;\n end\n else\n begin\n for i := (b - c + 1) to b do\n proizv := (proizv * i) mod 10 ;\n end;\n\n str(proizv, s);\n\n write(s[length(s)]);\n\n // readln();\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n k:=1;\n if (b-a) >= 10 then\n k:=0;\n if b-a < 10 then\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n k:=1;\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n\n k:=1;\n if (b-a) >= 10 then\n k:=0;\n if b-a < 10 then\n if b mod 10=0 then k:=0\n else\n begin a:=a mod 10000;\n b:=b mod 10000;\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n end;\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n a:=a mod 10000;\n b:=b mod 10000;\n k:=1;\n if (b-a) >= 10 then\n k:=0;\n if b-a < 10 then\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: int64;\n i: integer;\n k: int64;\n f: text;\n procedure nhapfile;\n begin\n assign(f,fi); reset(f);\n readln(f,a,b);\n close(f);\n end;\n\n procedure xuli;\n begin\n\n k:=1;\n if (b-a) >= 10 then\n k:=0;\n if b-a < 10 then\n begin a:=a mod 10000;\n b:=b mod 10000;\n for i:=a+1 to b do\n begin\n k:=((k mod 10)*(i mod 10)) mod 10;\n if k=0 then break;\n end;\n end;\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,k);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m:longint;\n c,d:array[1..100000] of boolean;\n sc,sd:array[1..100000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure check(x,y:longint);\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction last(x:int64):longint;\n begin\n if x=1 then exit(1) else\n if x=2 then exit(2) else\n if x=3 then exit(6) else\n if x=4 then exit(4) else exit(0);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,ta,tb:longint;\n a,b:int64;\n begin\n read(fi,a,b);\n ta:=last(a);\n tb:=last(b);\n if ta=0 then write(fo,0) else\n for i:=0 to 9 do if i*a mod 10=b then\n begin\n write(fo,i);\n exit;\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m:longint;\n c,d:array[1..100000] of boolean;\n sc,sd:array[1..100000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure check(x,y:longint);\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction last(x:int64):longint;\n begin\n if x<=1 then exit(1) else\n if x=2 then exit(2) else\n if x=3 then exit(6) else\n if x=4 then exit(4) else exit(0);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,ta,tb:longint;\n a,b:int64;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n tg,a,b,t:int64;\n begin\n read(fi,a,b);\n t:=a;\n tg:=1;\n while t<=b do\n begin\n tg:=(tg*(t mod 10)) mod 10;\n if tg=0 then\n begin\n writeln(fo,0);\n exit;\n end;\n inc(t);\n end;\n writeln(fo,tg mod 10);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var n,a,b:int64;\ni:longint;\nbegin\n n:=1;\n read(a,b);\n for i:=a+1 to b do\n begin\n if n * (i mod 10) > 9 then n:=(n*i mod 10) mod 10\n else n:=(i mod 10) *n;\n end;\n write(n);\nend."}, {"source_code": "var a,b,d:int64; i:integer;\nbegin\nd:=1;\nread(a,b);\nif (b-a)<10 then\nfor i:=a+1 to b do\nbegin\nd:=d*(i mod 10);\nd:=d mod 10;\nend else d:=0;\nwrite(d mod 10);\nend.\n"}, {"source_code": "var a,b,i:longint; d:int64;\nbegin\nd:=1;\nread(a,b);\nfor i:=a+1 to b do\nd:=d*i;\nwrite(d mod 10);\nend.\n"}, {"source_code": "var a, b, i, s: int64;\nBegin;\n readln (a, b);\n if b-a>4 then begin;\n writeln (0);\n exit;\n end;\n s:=1;\n i:=(a+1)mod 10;\n if i<=b mod 10 then Begin;\n while i<=(b mod 10) do begin;\n s:=s*i;\n i:=i+1;\n end;\n end\n else Begin;\n writeln(0);\n exit;\n end;\n writeln (s mod 10);\nend."}, {"source_code": "var a, b, i, s: int64;\nBegin;\n readln (a, b);\n if b-a>4 then begin;\n writeln (0);\n exit;\n end;\n s:=1;\n i:=(a+1)mod 10;\n while i<=(b mod 10) do begin;\n s:=s*i;\n i:=i+1;\n end;\n writeln (s mod 10);\nend."}, {"source_code": "Program CodeF_439_B;\nvar a,b:int64;\n i,k:longint;\n\n\nbegin\nread(a,b);\nk:=1;\nif a=0 then write(0) else\n begin\n if ((b div 10)>(a div 10)) then write(0) else\n begin\n for i:=(a mod 10)+1 to (b mod 10) do\n begin\n k:=(k*i) mod 10;\n end;\n write(k);\n end;\n end;\n\n\n\n\n\n\nend."}, {"source_code": "const fi='';\nvar f:text;\n n,m,s:int64;\n i:longint;\nprocedure print(s:longint);\nbegin\n write(s);\n readln;\n halt;\nend;\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);\n if m-n>=10 then print(0);\n s:=1;\n for i:=n+1 to m do s:=((i mod 10)*s) mod 10;print(s);\nend."}, {"source_code": "const fi='';\nvar f:text;\n n,m,s:int64;\n i:longint;\nprocedure print(s:longint);\nbegin\n write(s);\n readln;\n halt;\nend;\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);\n if m-n>=10 then print(0);\n s:=1;\n for i:=n+1 to m do s:=(s*i) mod 10;print(s);\nend.\n"}, {"source_code": "program theeternalimmortality;\nvar a,b:int64;\nprocedure input;\nvar f:text;\nbegin\n readln(a,b);\nend;\nprocedure output;\nvar f:text;\n x,y,i,k:longint;\nbegin\n if b-a>=10 then writeln(0)\n else\n begin\n x:=a mod 10;\n y:=b mod 10;\n if y>x then\n begin\n k:=1;\n for i:=x+1 to y do k:=(k*i)mod 10;\n writeln(k);\n end\n else\n end;\nend;\nbegin\n input;\n output;\nend.\n\n\n\n"}], "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60"} {"source_code": "USES math;\nCONST fi=''; fo='';\nVAR\n f:text;\n u,v,x,y,ds1,ds2,ds3:longint;\n\nPROCEDURE nhap;\n begin\n Assign(f,fi);reset(f);\n read(f,u,v,x,y);\n CLose(f);\n end;\n\nPROCEDURE xuli;\n begin\n ds1:=2;\n if (u=x) or (v=y) then ds1:=1;\n ds2:=2;\n if (u+v+x+y) mod 2=1 then ds2:=0 else\n if (u-v=x-y) or (u+v=x+y) then ds2:=1;\n ds3:=max(abs(u-x),abs(v-y));\n\n end;\n\nPROCEDURE ghira;\n begin\n Assign(f,fo);rewrite(f);\n writeln(f,ds1,' ',ds2,' ',ds3);\n Close(f);\n end;\n\nBEGIN\n nhap;xuli;ghira;\nEND.\n\n", "positive_code": [{"source_code": "uses math;\nconst fin='';\n fout='';\nvar r1,r2,c1,c2:byte;\nprocedure nhap;\nvar f:text;\nbegin\n assign(F,fin);reset(f);\n readln(f,r1,c1,r2,c2);\n close(f);\nend;\nfunction rook:byte;\nbegin\n if (r1=r2)or(c1=c2) then\n rook:=1\n else\n rook:=2;\nend;\nfunction bishop:byte;\nbegin\n if (((r1+c1) mod 2=0)and((r2+c2) mod 2=0))or(((r1+c1) mod 2<>0)and((r2+c2) mod 2<>0)) then\n begin\n if ((r1-c1)=(r2-c2))or((r1+c1)=(r2+c2)) then\n bishop:=1\n else\n bishop:=2;\n end\n else\n exit(0);\nend;\nfunction king:byte;\nbegin\n king:=max(abs(r1-r2),abs(c1-c2));\nend;\nprocedure xuat;\nvar g:text;\nbegin\n assign(g,fout);rewrite(g);\n write(g,rook,' ',bishop,' ',king);\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "{$MODE OBJFPC}\nUses Math;\nConst\n fi ='';\n fo ='';\nVar\n r, c, r1, c1 : integer;\n rook, bishop, king : integer;\n\nProcedure Enter;\nVar\n f : text;\nBegin\n Assign(f, fi); Reset(f);\n Readln(f, r, c, r1, c1);\n Close(f);\nEnd;\n\nFunction SameR: Boolean;\nBegin\n Result:=r=r1;\nEnd;\n\nFunction SameC: Boolean;\nBegin\n Result:=c=c1;\nEnd;\n\nFunction SameK: Boolean;\nBegin\n Result:=((r+c)=(r1+c1)) or ((r-c)=(r1-c1));\nEnd;\n\nProcedure Solve;\nBegin\n If SameR or SameC then rook:=1\n Else rook:=2;\n If (r+c) mod 2<>(r1+c1) mod 2 then bishop:=0\n Else If SameK then bishop:=1\n Else bishop:=2;\n king:=max(abs(r-r1), abs(c-c1));\nEnd;\n\nProcedure Print;\nVar\n f : text;\nBegin\n Assign(f, fo); Rewrite(f);\n Writeln(f, rook,' ', bishop,' ', king);\n Close(f);\nEnd;\n\nBEGIN\n Enter;\n Solve;\n Print;\nEND."}, {"source_code": "uses math;\n\nconst fi = '';\n fo = '';\n\nvar r1,c1,r2,c2,tuong,xe,vua:longint;\n\nprocedure nhap;\nbegin\n assign(input,fi); reset(input);\n readln(r1,c1,r2,c2);\n close(input);\nend;\n\nprocedure xulyxe;\nbegin\n if (r1=r2) or (c1=c2) then xe:=1 else xe:=2;\nend;\n\nprocedure xulytuong;\nvar x1,y1,x2,y2,n,m:longint;\nbegin\n x1:=r1 mod 2;\n y1:=c1 mod 2;\n x2:=r2 mod 2;\n y2:=c2 mod 2;\n if ((x1=y1) and (x2=y2)) or ((x1<>y1) and (x2<>y2)) then\n begin\n n:=abs(r1-r2);\n m:=abs(c1-c2);\n if n=m then tuong:=1 else tuong:=2;\n end\n else tuong:=0;\nend;\n\nprocedure xulyvua;\nvar n,m:longint;\nbegin\n n:=abs(r1-r2);\n m:=abs(C1-c2);\n vua:=max(n,m);\nend;\n\nprocedure solve;\nbegin\n xulyxe;\n xulytuong;\n xulyvua;\nend;\n\nprocedure xuat;\nbegin\n assign(output,fo); rewrite(output);\n write(xe,' ',tuong,' ',vua);\n close(output);\nend;\n\nbegin\n nhap;\n solve;\n xuat;\nend.\n"}, {"source_code": "uses math;\n\ntype pp=record\n x,y:longint;\n end;\n\nvar k1,k2,x1,y1,x2,y2:longint;\n w:array[0..10,0..10] of longint;\n v:array[0..1001] of pp;\n\nprocedure t1;\nvar t:longint;\n begin\n t:=0;\n if (x1<>x2) then t:=t+1;\n if (y1<>y2) then t:=t+1;\n write(t,' ');\n end;\n\nprocedure tt(xx,yy,x1,y1:longint);\nvar x,y:longint;\n begin\n x:=xx+x1;\n y:=yy+y1;\n while (x>=1) and (x<=8) and\n (y>=1) and (y<=8) do\n begin\n if (w[x,y]=0) then begin\n inc(k2);\n v[k2].x:=x;\n v[k2].y:=y;\n w[x,y]:=w[xx,yy]+1;\n end;\n x:=x+x1;\n y:=y+y1;\n end;\n\n end;\n\nprocedure t2;\nvar x,y:longint;\n begin\n k1:=1;\n k2:=1;\n v[1].x:=x1;\n v[1].y:=y1;\n w[x1,y1]:=1;\n\n while (k1<=k2) do\n begin\n x:=v[k1].x;\n y:=v[k1].y;\n tt(x,y,-1,-1);\n tt(x,y,-1,+1);\n tt(x,y,+1,-1);\n tt(x,y,+1,+1);\n\n inc(k1);\n end;\n\n write(w[x2,y2]-ord(w[x2,y2]>0),' ');\n end;\n\nprocedure t3;\n begin\n writeln(max(abs(x1-x2),abs(y1-y2)));\n end;\n\n\n begin\n read(x1,y1,x2,y2);\n t1;t2;t3;\n writeln;\n end."}, {"source_code": "Const\n fi='';//'1177.inp';\n fo='';//'1177.out';\nVar\n r1,r2,c1,c2:longint;\n a1,a2,a3:longint;\n\nPROCEDURE data;\nVar\n f:text;\nBegin\n assign(f,fi); reset(f);\n readln(f,r1,c1,r2,c2);\n close(f);\nEnd;\n\nFUNCTION max(a,b:longint):longint;\nBegin\n if a>b then exit(a) else exit(b);\nEnd;\n\nPROCEDURE work;\nBegin\n if (r1=r2) and (c1=c2) then exit;\n\n //King\n a3:=max(abs(r1-r2),abs(c1-c2));\n\n //Rook\n if (r1=r2) or (c1=c2) then a1:=1 else a1:=2;\n\n //Bishop\n if ((r1+c1) mod 2 <> (r2+c2) mod 2) then exit;\n if (r1+c1=r2+c2) or (r1-c1=r2-c2) then a2:=1 else a2:=2;\nEnd;\n\nPROCEDURE result;\nVar\n f:text;\nBegin\n assign(f,fo); rewrite(f);\n writeln(f,a1,' ',a2,' ',a3);\n close(f);\nEnd;\n\nBEGIN\n data;\n work;\n result;\nEND."}, {"source_code": "program bt1177;\nuses math;\nconst\n FI='';\n FO='';\nvar\n f:text;\n xe,tuong,vua:longint;\n r1,r2,c1,c2:longint;\n\nprocedure doc;\nbegin\n assign(f,FI);\n reset(f);\n read(f,r1,c1,r2,c2);\n close(f);\nend;\n\nprocedure xuli;\nbegin\n if (r1=r2) or (c1=c2) then xe:=1\n else xe:=2;\n\n if (r1+c1) mod 2= (r2+c2) mod 2 then\n if ((r1+c1)=(r2+c2)) or (r1-c1=r2-c2) then tuong:=1\n else tuong:=2\n else tuong:=0;\n\n vua:=max(abs(r1-r2),abs(c2-c1));\n\nend;\n\nprocedure ghi;\nbegin\n assign(f,FO);\n rewrite(f);\n writeln(f,xe,' ',tuong,' ',vua);\n close(f);\nend;\n\nbegin\n doc;\n xuli;\n ghi;\nend.\n"}, {"source_code": "var\n m:array [1..111,1..111] of integer;\n r1,r2,c1,c2,r,b,a,i,j,x,y,t,k,ans1,ans:integer;\nbegin\n read(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then r:=1 else r:=2;\n \n if abs(r1-r2)=abs(c1-c2) then b:=1 else\n if (abs(r1-c1) mod 2=0) and (abs(r2-c2) mod 2=1) or\n (abs(r1-c1) mod 2=1) and (abs(r2-c2) mod 2=0) then b:=0 else b:=2;\n \n if (r1=r2) or (abs(r1-r2)=abs(c1-c2)) then k:=abs(c2-c1) else\n if c1=c2 then k:=abs(r1-r2) else\n begin\n k:=0; x:=r1-r2; y:=c1-c2;\n if x<0 then ans:=-1 else ans:=1;\n if y<0 then ans1:=-1 else ans1:=1;\n repeat\n r1:=r1-ans;\n c1:=c1-ans1;\n k:=k+1;\n until (r1=r2) or (c1=c2);\n if r1=r2 then k:=k+abs(c1-c2);\n if c1=c2 then k:=k+abs(r1-r2);\n end;\n\n write(r,' ',b,' ',k);\nend."}, {"source_code": "uses math;\nVar i,j,k,m,n,x2,y2,x,y,x1,y1:LongInt;\n Begin\n Read(x,y,x1,y1);\n if (x=x1) or (y=y1) then Write('1 ')\n else Write('2 ');\n if ((x+y) mod 2)=((x1+y1) mod 2) then Begin\n if ABS(x-x1)=ABS(y-y1) then Write('1 ')\n else Write('2 ');\n End\n else Write('0 ');\n x2:=ABS(x-x1);\n y2:=ABS(y-y1);\n Write(max(x2,y2));\n End."}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1,p2,p3,p4,t,l,ot,nm,n,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,prost,besk:int64;\n step, k,t1,ii,i,tt,j:longint;\n aa,bb,cc:real;\n a,b:array[-10..200000] of int64;\n dda,ddb:array[-10..1200,-10..1200] of int64;\n ss1,ss2:string;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx,yy,y,x:array[-1..nn] of double;\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function raz:int64; var i,j:longint; t,t1:int64;\nbegin t:=0; t1:=0;\nfor i:=1 to n do t:=t+abs(a[2*i-1]-a[2*i]);\nfor i:=1 to n do t1:=t1+(a[2*i-1]-a[2*i]);\nraz:=t-abs(t1);\n end;\n\n\n\n\n\nbegin\n { assign (input,'F:\\Projects\\input.txt');reset(input);\n assign (output,'F:\\Projects\\output.txt'); rewrite(output);\n }\n read(p1,p2,p3,p4);\n\nif (p1=p3)or(p2=p4) then write(1) else write(2);\nwrite(' ');\nif odd(p1+p2-(p3+p4)) then p:=0 else\n begin\n if ((p1+p2)=(p3+p4))or((p1-p2)=(p3-p4)) then p:=1 else p:=2;\n\n end;\nwrite(p,' ');\nwriteln(max(abs(p1-p3),abs(p2-p4)));\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program z1;\nvar\ny1,y2,x2,x1:integer;\nbegin\nread(y1,x1,y2,x2);\n\nif (y1=y2) or (x1=x2) then write('1 ') else write('2 ');\nif ((x1+y1) mod 2) <> ((x2+y2) mod 2) then write('0 ') else begin\n if (abs(x1-x2)=abs(y1-y2)) then write('1 ') else writeln('2 ');\nend;\nif (abs(x1-x2)>abs(y1-y2)) then write(abs(x1-x2)) else write(abs(y1-y2));\nend."}, {"source_code": "var\n c1,c2,r1,r2,k1,k2,k3:integer;\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if abs (abs(r2-r1+1)-abs(c2-c1+1)) mod 2 = 1 then\n k2:=0;\n {if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if (r1=r2) and (c1<>c2) then\n if abs(c2-c1)mod 2 = 0 then k2:=2;\n if (c1=c2) and (r1<>r2) then\n if abs(r2-r1)mod 2 = 0 then k2:=2;\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1;\n if (abs(r2-r1+1) mod 2 = 1) and (abs(c2-c1+1) mod 2 = 1) then k2:=2;}\n {while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);}\n if abs(r2-r1)b then exit(a) else exit(b);\nend;\nbegin\nread(a,b,c,d);\nif (a=c) and (b=d) then\nbegin\nwriteln('0 0 0');\nhalt;\nend;\nif(a=c) or (b=d) then write(1,' ') else write(2,' ');\nif((a+c+b+d) mod 2<>0) then write(0,' ') else\nif((c-d)=(a-b))or((c+d)=(a+b)) then write(1,' ') else\nwrite(2,' ');\nwriteln(max(abs(a-c),abs(b-d)));\nend."}, {"source_code": "var x1,y1,x2,y2:integer;\nx,y:integer;\nfunction min(a,b:integer):integer;\nbegin\n if ab then max:=a else max:=b;\nend;\n\nbegin\nreadln(x1,y1,x2,y2);\nif (x1=x2) or (y1=y2) then write('1 ') else write('2 ');\nif abs(x1-x2)=abs(y1-y2)\n then\n begin\n write('1 ');\n end\n else \n begin\n if (((x1 mod 2) = (x2 mod 2)) and (y1 mod 2 = y2 mod 2)) or \n ((x1 mod 2 <> x2 mod 2) and (y1 mod 2 <> y2 mod 2))\n then write('2 ')\n else write('0 ');\n end; \n x:=abs(x1-x2);\n y:=abs(y1-y2);\n writeln(min(x,y)+abs(x-y));\nend."}, {"source_code": "var\n x1,y1,x2,y2,ans:longint;\nbegin\n readln(x1,y1,x2,y2);ans:=2;\n if x1=x2 then dec(ans);\n if y1=y2 then dec(ans);\n write(ans,' ');ans:=2;\n if x1-y1=x2-y2 then dec(ans);\n if x1+y1=x2+y2 then dec(ans);\n if (x1-y1-x2+y2) mod 2<>0 then ans:=0;\n if (x1+y1-x2-y2) mod 2<>0 then ans:=0;\n write(ans,' ');\n if abs(x1-x2)>abs(y1-y2) then writeln(abs(x1-x2)) else writeln(abs(y1-y2));\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,m,k,j,i,h,x,y,y1,x1,k1:integer;\nfunction min(x,y:Integer):integer;\nbegin\n if (xo then write('0')\n else\n if abs(a-c)=abs(b-d) then\n write('1')\n else write('2');\n write(' ');\n if abs(a-c)>abs(b-d) then write(abs(a-c))\n else write(abs(b-d));\nend.\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,ans,r1,c1,r2,c2,r,c:longint;\n flag:boolean;\n a:array[1..8,1..8] of integer;\n\nbegin\n//assign(input,in_file); reset(input);\n//assign(output,out_file); rewrite(output);\nfillchar(a,sizeof(a),0);\n\na[1,1]:=1;\nfor i:=2 to 8 do\nbegin\nif (a[1,i-1]=1) then a[1,i]:=0 else a[1,i]:=1;\nend;\nfor i:=2 to 8 do\nbegin\n for j:=1 to 8 do\n begin\n if (a[i-1,j]=1) then a[i,j]:=0 else a[i,j]:=1;\n end;\nend;\nreadln(r1,c1,r2,c2);\nif ((r1=r2)or(c1=c2)) then write(1,' ') else write(2,' ');\n flag:=false;\n r:=r1;\n c:=c1;\n while (r>0)and(c>0) do\n begin\n if (r=r2)and(c=c2) then flag:=true;\n r:=r-1;\n c:=c-1;\n end;\n\n r:=r1;\n c:=c1;\n while (r<=8)and(c>0) do\n begin\n if (r=r2)and(c=c2) then flag:=true;\n r:=r+1;\n c:=c-1;\n end;\n\n r:=r1;\n c:=c1;\n while (r>0)and(c<=8) do\n begin\n if (r=r2)and(c=c2) then flag:=true;\n r:=r-1;\n c:=c+1;\n end;\n\n r:=r1;\n c:=c1;\n while (r<=8)and(c<=8) do\n begin\n if (r=r2)and(c=c2) then flag:=true;\n r:=r+1;\n c:=c+1;\n end;\n\n if (flag) then write(1,' ') else\n begin\n if (a[r1,c1]<>a[r2,c2]) then write(0,' ') else write(2,' ');\n end;\n\n r:=abs(r1-r2);\n c:=abs(c1-c2);\n ans:=0;\n ans:=max(r,c);\n writeln(ans);\n readln;\n readln;\n\n\n\n\n\n\n\n\n\n//close(output);\n//close(input);\nend.\n"}, {"source_code": "var\n y1,x1,y2,x2:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then max:=a else max:=b;\nend;\nbegin\n readln(y1,x1,y2,x2);\n if (x1=x2)and(y1=y2) then write(0);\n if (x1=x2)xor(y1=y2) then write(1);\n if (x1<>x2)and(y1<>y2) then write(2);\n if odd(y1+x1)<>odd(x2+y2) then write(' 0') else\n begin\n if (x1+y1=x2+y2)and(y1-x1=y2-x2) then write(' 0')else\n if (y1+x1=y2+x2)xor(y1-x1=y2-x2) then write(' 1') else write(' 2');\n end;\n writeln(' ',max(abs(x1-x2),abs(y1-y2)));\nend."}, {"source_code": "uses math;\nvar a,b, c,d: LongInt;\nbegin\n Readln(a,b,c,d);\n \n if (a=c) or (b=d) then Write('1 ') else Write('2 ');\n\n if ((a+b) mod 2 = 0) and ((c+d) mod 2 = 0) or ((a+b) mod 2 <> 0) and ((c+d) mod 2 <> 0) then\n begin\n if abs(a-c) = abs(b-d) then Write('1 ') else Write('2 ');\n end else Write('0 ');\n \n Writeln(max(abs(a-c), abs(b-d)));\nend."}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = 'INPUT.INP';\n dx : array[1..8] of Integer = (1, 1, 1, 0, 0, -1, -1, -1);\n dy : array[1..8] of Integer = (0, 1, -1, 1, -1, 0, 1, -1);\nvar\n qx, qy : array[0..90] of Integer;\n r1, c1, r2, c2, front, rear : Integer;\n d : array[0..10,0..10] of Integer;\n\nprocedure bfs;\nvar\n i, j, u, v: Integer;\nbegin\n for i := 0 to 9 do\n begin\n d[i,0] := -1;\n d[0,i] := -1;\n d[i,9] := -1;\n d[9,i] := -1;\n end;\n front := 1; rear := 1;\n qx[1] := r1; qy[1] := c1; d[r1,c1] := 1;\n while front <= rear do\n begin\n u := qx[front]; v := qy[front]; inc(front);\n for i := 1 to 8 do\n if d[u + dx[i], v + dy[i]] = 0 then\n begin\n d[u + dx[i] , v + dy[i]] := d[u,v] + 1;\n inc(rear); qx[rear] := u + dx[i]; qy[rear] := v + dy[i];\n end;\n end;\n writeln(d[r2,c2] - 1,' ');\nend;\n\nprocedure enter;\nvar\n i, j : Integer;\nbegin\n //assign(input,fi); reset(input);\n read(r1, c1, r2, c2);\n if (r1 = r2) or (c1 = c2) then write(1,' ') else write(2,' ');\n if (r1 + c1) mod 2 <> (r2 + c2) mod 2 then write(0,' ')\n else\n if ((r1 + c1) = (r2 + c2)) or ((r1 - c1) = (r2 - c2)) then write(1,' ')\n else write(2,' ');\n bfs;\nend;\n\nbegin\n enter;\nend."}, {"source_code": "var\n x1,x2,y1,y2:longint;\n ans1,ans2,ans3:longint;\n\nfunction max(a,b:longint):longint;\nbegin\n if a > b\n then exit(a)\n else exit(b);\nend;\n\nbegin\n //Come and hack me if you can!\n read(x1,y1,x2,y2);\n if (x2 - x1) * (y2 - y1) = 0\n then ans1:=1\n else ans1:=2;\n if ((x1 + y1) mod 2) <> ((x2 + y2) mod 2)\n then ans2:=0\n else\n begin\n if (x1 - y1 = x2 - y2) or (abs(x1 + y1) = abs(x2 + y2))\n then ans2:=1\n else ans2:=2;\n end;\n ans3:=max(abs(x1-x2),abs(y1-y2));\n if abs(x1 - x2) + abs(y1 - y2) = 0 then\n begin\n ans1:=0;\n ans2:=0;\n ans3:=0;\n end;\n writeln(ans1,' ',ans2,' ',ans3);\n //NEW\nend.\n"}, {"source_code": "var r1,c1,r2,c2,x,t,v : byte;\nbegin\n readln(r1,c1,r2,c2);\n\n if (r1=r2) or (c1=c2) then x := 1 else x := 2;\n\n if (r1+c1) mod 2 <> (r2+c2) mod 2 then t := 0 else begin\n if abs(r1-r2) = abs(c1-c2) then t := 1 else t := 2;\n end;\n\n if abs(r1-r2) > abs(c1-c2) then v := abs(r1-r2) else v := abs(c1-c2);\n\n writeln(x,' ',t,' ',v);\nend."}, {"source_code": "var a,b,c,n,r1,c1,r2,c2,i,j:longint;\n\nfunction max(a1,a2:longint):longint;\nbegin\nmax:=a1;\nif a2>a1 then max:=a2;\nend;\n\nbegin\nreadln(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then a:=1 else a:=2;\nif (r1+c1) mod 2 <> (r2+c2) mod 2 then b:=0 else\nif abs(r1-r2)=abs(c1-c2) then b:=1 else b:=2;\nc:=max(abs(r1-r2),abs(c1-c2));\nwriteln(a,' ',b,' ',c);\nend."}, {"source_code": "var r1,c1,r2,c2:byte;\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then\n write('1 ')\n else\n write('2 ');\n if abs((r1+c1)-(r2+c2))mod 2=1 then\n write('0 ')\n else\n if abs(r2-r1)=abs(c2-c1) then\n write('1 ')\n else\n write('2 ');\n if abs(r2-r1)>=abs(c2-c1) then\n write(abs(r2-r1))\n else\n write(abs(c2-c1));\n readln;\nend."}, {"source_code": "var a,b,c,d:longint;\nfunction max(a,b:longint):Longint;\nbegin\n max:=a;\n if b>a then max:=b;\nend;\nbegin\n readln (a,b,c,d);\n //\n if (a=c) or (b=d) then write ('1 ') else write ('2 ');\n //\n if ((a+b) mod 2<>(c+d) mod 2) then write ('0 ') else\n begin\n if (a+b=c+d) or (a-b=c-d) then write ('1 ') else write ('2 ');\n end;\n //\n write (max(abs(c-a),abs(d-b)));\nend."}, {"source_code": "program sdjkj;\nuses math;\nvar x1, y1, x2, y2: integer;\n sl, lad, king, t: integer;\nfunction isBlack(x: integer; y: integer):boolean;\nbegin\n if ((x mod 2 = 0) and (y mod 2 <> 0)) \n or \n ((x mod 2 <> 0) and (y mod 2 = 0))\n then isBlack := true else isBlack := false;\nend;\n\nbegin\n read(x1, y1, x2, y2);\n x1 := x1 - 1;\n x2 := x2 - 1;\n y1 := y1 - 1;\n y2 := y2 - 1;\n \n if( isBlack(x1, y1) <> isBlack(x2, y2) ) then sl := 0 else\n begin\n if ((x1 - y1) = (x2 - y2)) or ((x1 + y1) = (x2 + y2)) then sl := 1 else sl := 2; \n end;\n //writeln(sl);\n \n if (x1 = x2) or (y1 = y2) then lad := 1 else lad := 2;\n if (x1 = x2) or (y1 = y2) then king := abs(x2-x1) + abs(y2-y1) else\n begin\n t := (min(abs(x2-x1), abs(y2-y1)));\n king := t + abs(x2-x1)-t + abs(y2-y1)-t;\n end;\n write(lad, ' ', sl, ' ', king);\nend."}, {"source_code": "program zzz;\n var x1,x2,y1,y2:longint;\n function max(x,y:longint):longint;\n begin\n if x>y then max:=x else max:=y;\n end;\n\n begin\n\n read(x1,y1,x2,y2);\n if (x1=x2) or(y2=y1) then write(1,' ') else write(2,' ');\n\n if (x2-y2 = x1-y1) or (x2+y2=x1+y1) then write('1 ')\n else if ((x1+y1) mod 2) <> ((x2+y2) mod 2) then write('0 ')\n else write('2 ');\n\n write(max(abs(x1-x2),abs(y1-y2)));\n\n end."}, {"source_code": "uses math;\nvar\n x,y,x1,x2,y1,y2,a1,a2,a3,q : longint;\n\nbegin\n readln(x1,y1,x2,y2);\n if (x1 <> x2) then inc(a1);\n if (y1 <> y2) then inc(a1);\n if (abs(x1-x2) = abs(y1-y2)) then a2:=1 else begin\n x:=x1; y:=y1;\n while (x <= 8) and (y <= 8) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n inc(x);\n inc(y);\n end;\n x:=x1; y:=y1;\n while (x <= 8) and (y >= 1) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n inc(x);\n dec(y);\n end;\n x:=x1; y:=y1;\n while (x >= 1) and (y <= 8) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n dec(x);\n inc(y);\n end;\n x:=x1; y:=y1;\n while (x >= 1) and (y >= 1) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n dec(x);\n dec(y);\n end;\n end;\n writeln(a1,' ',a2,' ',max(abs(x1-x2),abs(y1-y2)));\nend."}, {"source_code": "var\na,b,c,d,sum1,sum2,sum3:longint;\nbegin\nreadln(a,b,c,d);\nif (a=c) and (b=d) then\nsum1:=0;\nif (a<>c) and (b<>d) then\nsum1:=2;\nif (a<>c) and (b=d) then\nsum1:=1;\nif (a=c) and (b<>d) then\nsum1:=1;\nif ((a=c) and (b=d)) or (((a+b) mod 2)<>((c+d) mod 2)) then\nsum2:=0\nelse\nif abs(a-c)=abs(b-d) then\nsum2:=1\nelse\nsum2:=2;\nif abs(a-c)>abs(b-d) then\nsum3:=abs(a-c)\nelse\nsum3:=abs(b-d);\nwriteln(sum1,' ',sum2,' ',sum3);\nend."}, {"source_code": "Program A217;\nUses math;\nConst finp='';//a217.inp';\n fout='';//a217.out';\nVar fi,fo:text;\n c1,r1,c2,r2 :longint;\n\nBEGIN\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n read(fi,r1,c1,r2,c2);\n if (r1=r2)and(c1=c2) then write(fo,'0 0 0')\n else\n begin\n if (r1=r2) or (c1=c2) then write(fo,'1 ') else write(fo,'2 ');\n if (r1+c1)mod 2<>(r2+c2) mod 2 then write(fo,'0 ')\n else\n if (r1+c1=r2+c2) or (r1-c1=r2-c2) then write(fo,'1 ') else write(fo,'2 ');\n write(fo,max(abs(r2-r1),abs(c2-c1)));\n end;\n close(fi); close(fo);\nEND."}, {"source_code": "Uses math;\nVar i1,i2,j1,j2:longint;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(i1,j1,i2,j2);\n if (i1=i2)and(j1=j2)\n then begin\n writeln(0,' ',0,' ',0);\n halt(0)\n end;\n if (i1=i2)or(j1=j2)\n then write(1,' ')\n else write(2,' ');\n if (i1 mod 2+j1 mod 2)mod 2<>(i2 mod 2+j2 mod 2)mod 2\n then write(0,' ')\n else begin\n if (i1-j1=i2-j2)or(-i1-j1=-i2-j2)\n then write(1,' ')\n else write(2,' '); \n end;\n writeln(max(abs(i1-i2),abs(j1-j2))) \nend."}, {"source_code": "uses math; \nconst\n finp = '';\n fout = '';\nvar color : array [0 .. 8, 0 .. 8] of longint;\n i, j, r1, r2, c1, c2, resr, resb, resk : longint;\n f, g : text;\nbegin\n assign(f, finp); reset(f);\n assign(g, fout); rewrite(g);\n for i := 1 to 8 do\n begin\n color[i][1] := 1 - color[i - 1][1];\n for j := 2 to 8 do\n color[i][j] := 1 - color[i][j - 1];\n end;\n readln(f, r1, c1, r2, c2);\n if (r1 = r2) or (c1 = c2) then resr := 1\n else resr := 2;\n if color[r1][c1] <> color[r2][c2] then resb := 0\n else\n if abs(r1 - r2) = abs(c1 - c2) then resb := 1\n else resb := 2;\n resk := abs(c1 - c2);\n resk := max(0, abs(r1 - r2) - resk) + resk;\n writeln(g, resr, ' ', resb, ' ', resk);\n close(f); close(g);\nend.\n"}, {"source_code": "uses math;\nvar n,m,x1,x2,y1,y2,xe,t,k:longint;\nprocedure nhap;\nvar i,j:longint;\n begin\n readln(x1,y1,x2,y2);\n end;\nprocedure viet;\nvar i,j:longint;\n begin\n writeln(xe,' ',t,' ',k);\n end;\nprocedure xuly;\nvar i,j:longint;\n begin\n if (x1=x2)or(y1=y2) then xe:=1 else xe:=2;\n if (x1+y1+x2+y2) mod 2=1 then t:=0\n else if (x1+y1=x2+y2)or(x1-y1=x2-y2) then t:=1\n else t:=2;\n k:=max(abs(x1-x2),abs(y1-y2));\n end;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n nhap;\n xuly;\n viet;\n close(input);\n close(output);\nend.\n"}, {"source_code": "Program A_Chess;\nvar\n r1,c1,r2,c2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\n\nif (a mod 2=0) and (b mod 2<>0) then //black\n h:=true;\n \nif (a mod 2<>0) and (b mod 2=0) then //white\n h:=true;\n \nif a=b then\n if a mod 2<>0 then\n h:=false;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n\nk:=max(abs(r2-r1),abs(c2-c1)); //dlia king'a\n\nif (r1=r2) and (c1=c2) then\n begin\n L:=0; S:=0; K:=0;\n end;\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "PROGRAM coj1177;\nUSES math;\nCONST fi='';\n fo='';\nVAR x,y,a,b,ds1,ds2,ds3:longint;\n f:text;\nPROCEDURE nhap;\n Var i,j:longint;\n Begin\n assign(f,fi); reset(f);\n readln(f,a,b,x,y);\n close(f);\n End;\nPROCEDURE xuly;\n Var i,j:longint;\n Begin\n if (a=x) or (b=y) then ds1:=1 else ds1:=2;\n if ((a+b)-(x+y)) mod 2 = 0 then\n if abs(a-x)=abs(b-y) then ds2:=1 else ds2:=2\n else ds2:=0;\n ds3:=max(abs(a-x),abs(b-y))\n End;\nPROCEDURE inkq;\n Var i,j:longint;\n Begin\n assign(f,fo); rewrite(f);\n writeln(f,ds1,' ',ds2,' ',ds3);\n close(f);\n End;\nBEGIN\n nhap;\n xuly;\n inkq;\nEND.\n"}, {"source_code": "Uses math;\nConst\n fi= '';//1177.in';\n fo= '';//1177.out';\n\nVar\n r1, c1, r2, c2: longint;\n\nProcedure reads;\nBegin\n read(r1,c1,r2,c2);\nEnd;\n\nProcedure process;\nVar\n res: longint;\nBegin\n // Xe\n if (r1- r2= 0) or (c1-c2=0) then write(1,' ')\n else write(2,' ');\n\n // Tuong\n if (r1+c1= r2+c2) or (r1-c1= r2- c2) then write(1,' ')\n else\n if ((r1+c1) mod 2)<> ((r2+ c2) mod 2) then write(0,' ')\n else write(2,' ');\n\n // Vua\n writeln(max(abs(r2-r1),abs(c2-c1)));\nEnd;\n\nBegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n reads;\n process;\n close(input); close(output);\nEnd.\n"}, {"source_code": "program coj1177;\nuses math;\nconst\n fi = '';//coj.in';\n fo = '';//coj.out';\nvar\n f:text;\n r1,c1,r2,c2:longint;\n\nprocedure doc;\nbegin\n assign(f,fi);reset(f);\n readln(f,r1,c1,r2,c2);\n close(f);\nend;\n\nprocedure xuli;\nbegin\n assign(f,fo);rewrite(f);\n if (r1 = r2) or (c1 = c2) then write(f,1,' ')\n else write(f,2,' ');\n if (r1+r2+c1+c2) mod 2 = 1 then write(f,0,' ')\n else\n begin\n if ((r1+c1) = (r2+c2)) or ((r1-c1) = (r2-c2)) then write(f,1,' ')\n else write(f,2,' ');\n end;\n writeln(f,max(abs(r1-r2),abs(c1-c2)));\n close(f);\nend;\n\nbegin\n doc;\n xuli;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n{$R-,Q-}\n\nconst\n fi = 'A.INP';\n\nvar\n r, b, k : integer;\n x1, x2, y1, y2 : integer;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n assign(input,fi); reset(input);\n{$ENDIF}\n readln(x1, y1, x2, y2);\n if (x1 = x2) and (y1 = y2) then\n begin\n writeln('0 0 0');\n halt;\n end;\n if (x1 = x2) or (y1 = y2) then\n r := 1\n else\n r := 2;\n b := 0;\n if (x1 - y1 = x2 - y2) or (x1 + y1 = x2 + y2) then\n b := 1\n else\n if ((x1 + y1) and 1) <> ((x2 + y2) and 1) then b := 0\n else\n b := 2;\n if abs(x1 - x2) <= abs(y1 - y2) then\n k := abs(y1 - y2)\n else\n k := abs(x1 - x2);\n writeln(r,' ',b,' ',k);\nend."}, {"source_code": "uses math;\n var x1 , y1 , x2 , y2 , i , j , p : longint;\n a : array[1 .. 8 , 1.. 8] of longint;\n\nBEGIN\n\n readln(x1 , y1 , x2 , y2);\n for i := 1 to 8 do begin\n if odd(i) then p := 1\n else p := 2;\n for j := 1 to 8 do begin\n a[i , j] := p;\n p := p mod 2 + 1;\n end;\n end;\n\n if (x1 = x2) or (y1 = y2) then write(1 , ' ')\n else write(2 , ' ');\n\n if a[x1 , y1] <> a[x2 , y2] then write(0 , ' ') else begin\n if abs(x1 - x2) = abs(y1 - y2) then write(1 , ' ')\n else write(2 , ' ');\n end;\n\n write(max(abs(x1 - x2) , abs(y1 - y2)));\n\nEND.\n"}, {"source_code": "uses math;\n\nvar r1,c1,r2,c2:longint;\n\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2) or (c1=c2) then write(1,' ')\n else write(2,' ');\n if (r2-c2 = r1 - c1) or (r2+c2=r1+c1) then write('1 ')\n else if ((r1+c1) mod 2) <> ((r2+c2) mod 2) then write('0 ')\n else write('2 ');\n write(max(abs(r2-r1),abs(c2-c1)));\nend."}, {"source_code": "uses math;\nvar\n r1,c1,r2,c2:longint;\n ans1,ans2,ans3:longint;\nbegin\n read(r1,c1,r2,c2);\n if (r1=r2) and (c1=c2) then begin writeln(0,' ',0,' ',0); halt; end;\n\n if (r1=r2) or (c1=c2) then ans1:=1\n else ans1:=2;\n\n if (r1+c1)mod 2<>(r2+c2)mod 2 then ans2:=0\n else if abs(r1-r2)-abs(c1-c2)=0 then ans2:=1\n else ans2:=2;\n\n ans3:=max(abs(r2-r1),abs(c2-c1));\n writeln(ans1,' ',ans2,' ',ans3);\nend.\n"}, {"source_code": "uses math;\nconst fin='';\n fout='';\nvar r1,c1,r2,c2:longint;\nbegin\n assign(input,fin);reset(input);\n assign(output,fout);rewrite(output);\n read(r1,c1,r2,c2);\n if r1=r2 then\n begin\n if c1=c2 then write(0,' ')\n else write(1,' ');\n end\n else\n if c1=c2 then\n begin\n if r1=r2 then write(0,' ')\n else write(1,' ');\n end\n else write(2,' ');\n if abs(r2-r1)=abs(c2-c1) then write(1,' ')\n else\n begin\n if (r2+c2) mod 2<>(r1+c1) mod 2 then write(0,' ')\n else write(2,' ');\n end;\n if r1=r2 then\n begin\n if c1=c2 then write(0,' ')\n else write(abs(c2-c1),' ');\n end\n else\n if c1=c2 then\n begin\n if r1=r2 then write(0,' ')\n else write(abs(r2-r1),' ');\n end\n else\n begin\n write(max(abs(r2-r1),abs(c2-c1)));\n end;\nend.\n"}, {"source_code": "var r1,r2,c1,c2,s,k:int64;\nbegin\n readln(r1,c1,r2,c2);\n if r1<>r2 then inc(k);\n if c1<>c2 then inc(k);\n write(k,' ');\n if (abs(r1-r2) mod 2)<>(abs(c1-c2) mod 2) then\n write(0,' ')\n else\n begin\n if (r1=r2) and (c1=c2) then write(0,' ')\n else\n begin\n if abs(r1-r2)=abs(c1-c2) then\n write(1,' ')\n else\n write(2,' ');\n end;\n end;\n s:=abs(abs(r1-r2)-abs(c1-c2));\n if abs(r1-r2)>abs(c1-c2) then\n s:=s+abs(c1-c2)\n else\n s:=s+abs(r1-r2);\n writeln(s);\nend."}, {"source_code": "Program a370;\nuses math;\nconst fi = '';\n fo = '';\nvar f : text;\n r1,c1,r2,c2 : longint;\nBEGIN\n READ(r1,c1,r2,c2);\n If (r1=r2) and (c1=c2) then\n begin\n write(0,' ',0,' ',0);\n halt;\n end;\n If (r1=r2) or (c1=c2) then write (1,' ') else write(2,' ');\n IF ((r1+c1) mod 2) <> ((r2+c2) mod 2) then write(0,' ')\n else\n if ((r1-c1) = (r2-c2)) or (r1+c1=r2+c2) then write(1,' ')\n else write(2,' ');\n write(max(abs(r1-r2),abs(c1-c2)));\nEND."}, {"source_code": "uses math;\nvar r1,c1,r2,c2:byte;\nbegin\n read(r1,c1,r2,c2);\n if (r1=r2) or (c1=c2) then write('1 ')\n else write('2 ');\n if (c2-r2=c1-r1) or (r2+c2=r1+c1) then write('1 ')\n else if ((r1 mod 2=c1 mod 2) and (r2 mod 2=c2 mod 2)) or ((r1 mod 2<>c1 mod 2) and (r2 mod 2<>c2 mod 2)) then write('2 ')\n else write('0 ');\n write(max(abs(r1-r2),abs(c1-c2)))\nend."}, {"source_code": "uses math;\nvar\n r1,c1,r2,c2:longint;\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then write('1 ')\n else write('2 ');\n if (r1+c1=r2+c2)or(r1-c1=r2-c2) then write('1 ')\n else if not((r1+c1) mod 2=(r2+c2) mod 2) then write('0 ')\n else write('2 ');\n write(max(abs(r1-r2),abs(c1-c2)));\nend."}, {"source_code": "program codeforces;\n\n(* Main code is here ... *)\n\nvar\n\tt, r1, r2, c1, c2 : integer;\nbegin\n\tread(r1, c1, r2, c2);\n\tif (r1 = r2) and (c1 = c2) then\n\tbegin\n\t\twriteln(0, ' ', 0, ' ', 0);\n\t\texit;\n\tend;\n\t(* Rook *)\n\tt := 0;\n\tif r1 <> r2 then t := t+1;\n\tif c1 <> c2 then t := t+1;\n\twrite(t, ' ');\n\t(* Bishop *)\n\tt := 2;\n\tif abs(r1-r2) = abs(c1-c2) then t := 1;\n\tif (abs(r1-r2)+abs(c1-c2)) mod 2 = 1 then t := 0;\n\twrite(t, ' ');\n\t(* King *)\n\tt := 0;\n\tif abs(r1-r2) > abs(c1-c2) then\n\t\tt := abs(r1-r2)\n\telse\n\t\tt := abs(c1-c2);\n\twrite(t);\n\twriteln();\nend.\n"}, {"source_code": "uses math;\nvar\n sx,sy,fx,fy,k,l,s,delta,i,j,nx,ny : longint;\n color : array [0..200,0..200] of longint;\n found : boolean;\n procedure check(x,y : longint);\n begin\n if (x=fx) and (y=fy) then found:=true;\n end;\nbegin\n readln(sx,sy,fx,fy);\n for i:=1 to 8 do\n for j:=1 to 8 do\n color[i][j]:=(i+j) mod 2;\n if color[sx][sy]<>color[fx][fy] then s:=0 else\n begin\n found:=false;\n for delta:=1 to 100 do\n begin\n nx:=sx+delta; ny:=sy+delta;\n check(nx,ny);\n nx:=sx-delta; ny:=sy+delta;\n check(nx,ny);\n nx:=sx+delta; ny:=sy-delta;\n check(nx,ny);\n nx:=sx-delta; ny:=sy-delta;\n check(nx,ny);\n end;\n if found then s:=1 else s:=2;\n end;\n k:=max(abs(sx-fx),abs(sy-fy));\n if (sx=fx) or (sy=fy) then l:=1 else l:=2;\n writeln(l,' ',s,' ',k);\nend."}, {"source_code": "program sss;\nvar a,b,c,d:longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then exit(x);\n exit(y);\nend;\nbegin\n readln(a,b,c,d);\n\n if (a=c)or(b=d) then write(1,' ')\n else write(2,' ');\n\n if (a+b)mod 2=(c+d)mod 2 then\n begin\n if abs(a-c)=abs(b-d) then write(1,' ')\n else write(2,' ');\n end\n else write(0,' ');\n\n writeln(max(abs(a-c),abs(b-d)));\n\n\n\n\n\n\nend.\n"}, {"source_code": "var x1,x2,y1,y2:longint;\nfunction max(a,b:longint):longint;\nbegin\nif a>b then max:=a else max:=b;\nend;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(x1,y1,x2,y2);\nif (x1=x2) and (y1=y2) then begin writeln('0 0 0 '); halt; end;\nif (x1=x2) or (y1=y2) then write('1 ') else write('2 ');\nif ((x1 mod 2 = y1 mod 2) and (x2 mod 2<>y2 mod 2))or ((x1 mod 2 <> y1 mod 2) and (x2 mod 2=y2 mod 2))then write('0 ')\n else if abs(x1-x2)=abs(y1-y2) then write('1 ') else write('2 ');\nwrite(max(abs(x1-x2),abs(y1-y2)));\n\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram proA370;\nuses\n math;\nconst\n fi = 'proA370.inp';\nvar\n r1, c1, r2, c2 : Integer;\n\nbegin\n {$ifndef online_judge}\n assign(input, fI); reset(input);\n {$endif}\n readln(r1, c1, r2, c2);\n\n if (r1 = r2) or (c1 = c2) then write(1,' ') else write(2,' ');\n\n if (r1 - c1 = r2 - c2) or (r1 + c1 = r2 + c2) then write(1,' ') else\n if ((r1 + c1 + r2 + c2) mod 2 = 0) then write(2,' ') else write(0,' ');\n writeln(min( abs(r1 - r2) + Min( abs(c2 - (r2 - r1 + c1)), abs(c2 - (r1 + c1 - r2) ) ) , abs(c1 - c2) + Min(abs(r2 - (r1 - c1 + c2)) , abs(r2 - (r1 + c1 - c2) ) ) ) );\nend."}, {"source_code": "const n=8;\n dong:array[1..8] of longint=(-1,-1,0,1,1,1,0,-1);\n cot:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);\n\ntype banghi=record\n x,y:longint;\n end;\n\nvar free:array[1..n,1..n] of boolean;\n\n f:array[1..n,1..n] of longint;\n\n queue:array[1..n*n] of banghi;\n\n r1,c1,r2,c2,first,last:longint;\n\nprocedure doc;\nbegin\n\n readln(r1,c1,r2,c2);\nend;\n\nprocedure push(u,v:longint);\nbegin\n inc(last);\n queue[last].x:=u;\n queue[last].y:=v;\n\n free[u,v]:=false;\nend;\n\nprocedure check(newu,newv,u,v:longint);\nbegin\n if free[newu,newv] then\n begin\n f[newu,newv]:=f[u,v]+1;\n push(newu,newv);\n end;\nend;\n\nfunction inside(u,v:longint):boolean;\nbegin\n\n if not((1<=u) and (u<=n) and (1<=v) and (v<=n)) then exit(false);\n exit(free[u,v]);\nend;\n\nprocedure bfs(loai:longint);\nvar u,v,newu,newv,i:longint;\nbegin\n\n fillchar(free,sizeof(free),true);\n fillchar(f,sizeof(f),0);\n\n first:=1;\n last:=0;\n\n push(r1,c1);\n\n while first<=last do\n begin\n\n u:=queue[first].x;\n v:=queue[first].y;\n inc(first);\n\n if loai=1 then\n begin\n newu:=u;\n newv:=v;\n\n while (newu+1<=n) do\n begin\n inc(newu);\n check(newu,newv,u,v);\n end;\n\n newu:=u;\n while (newu-1>=1) do\n begin\n dec(newu);\n check(newu,newv,u,v);\n end;\n\n newu:=u;\n while (newv+1<=n) do\n begin\n inc(newv);\n check(newu,newv,u,v);\n end;\n\n newv:=v;\n while (newv-1>=1) do\n begin\n dec(newv);\n check(newu,newv,u,v);\n end;\n end;\n\n if loai=2 then\n begin\n newu:=u;\n newv:=v;\n\n while (newu+1<=n) and (newv+1<=n) do\n begin\n inc(newu);\n inc(newv);\n check(newu,newv,u,v);\n end;\n\n newu:=u;\n newv:=v;\n\n while (newu-1>=1) and (newv-1>=1) do\n begin\n dec(newu);\n dec(newv);\n check(newu,newv,u,v);\n end;\n\n newu:=u;\n newv:=v;\n\n while (newu-1>=1) and (newv+1<=n) do\n begin\n dec(newu);\n inc(newv);\n check(newu,newv,u,v);\n end;\n\n newu:=u;\n newv:=v;\n\n while (newu+1<=n) and (newv-1>=1) do\n begin\n inc(newu);\n dec(newv);\n check(newu,newv,u,v);\n end;\n end;\n\n if loai=3 then\n begin\n for i:=1 to 8 do\n begin\n newu:=u+dong[i];\n newv:=v+cot[i];\n\n if inside(newu,newv) then check(newu,newv,u,v);\n end;\n end;\n end;\n\n write(f[r2,c2],' ');\nend;\n\nprocedure xuly;\nbegin\n\n bfs(1);\n bfs(2);\n bfs(3);\nend;\n\nbegin\n\n //assign(input,'nhap.inp'); reset(input);\n\n doc;\n xuly;\nend."}, {"source_code": "uses math;\nconst\n tinp='';\n tout='';\n\nvar\n fi,fo:text;\n r1,c1,r2,c2:longint;\n\nprocedure input;\nbegin\n assign(fi,tinp);reset(fi);\n read(fi,r1,c1,r2,c2);\n close(fi);\nend;\n\nprocedure output;\nbegin\n assign(fo,tout);rewrite(fo);\n if (r1=r2) or (c1=c2) then writeln(fo,1)\n else writeln(fo,2);\n if ((r1+c1) mod 2 <> (r2+c2) mod 2) then writeln(fo,0) else\n if (r1-c1=r2-c2) or (r1+c1=r2+c2) then writeln(fo,1) else\n writeln(fo,2);\n write(fo,max(abs(r1-r2),abs(c1-c2)));\n close(fo);\nend;\n\nBEGIN\n input;\n output;\nEND."}, {"source_code": "var c,kp,kf,f,p,r1,c1,r2,c2,l,s,k:integer;\ns1,s2 :string;\nbegin\nread(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then l:=1 else l:=2;\nif ((odd(r1)=false) and (odd(c1)=false)) or ((odd(r1)=true) and (odd(c1)=true)) then s1:='Black' else s1:='White';\nif ((odd(r2)=false) and (odd(c2)=false)) or ((odd(r2)=true) and (odd(c2)=true)) then s2:='Black' else s2:='White';\nif (s1<>s2)then s:=0 else\nbegin\nfor p:=-8 to 8 do begin\nif ((r1+p=r2) and (c1+p=c2)) or ((r1-p=r2) and (c1+p=c2)) then s:=1;\nend;\nif (s=0)then s:=2;\nend;\nfor p:=-8 to 8 do begin\nfor f:=-8 to 8 do begin\nif (r1+p=r2) and (c1+f=c2) then begin\nkp:=abs(p);\nkf:=abs(f);\nend;\nend;\nend;\nif (kp= abs(s2) then write(abs(s1),' ') \n else write(abs(s2),' ');\nend."}, {"source_code": "var i,n,x1,x2,y1,y2,j,k,pp1,pp2:longint;\na:array [-1..10,-1..10] of longint;\nbegin\nreadln(x1,y1,x2,y2);\nif (x1=x2)and(y1=y2) then begin writeln(0,' ',0,' ',0);halt;end;\nfor i:=-1 to 10 do\nfor j:=-1 to 10 do\na[i,j]:=-1;\na[x1,y1]:=1;\n\nfor k:=1 to 64 do\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nif a[i,j]=k then begin\nif a[i,j+1]=-1 then a[i,j+1]:=k+1;\nif a[i,j-1]=-1 then a[i,j-1]:=k+1;\nif a[i-1,j]=-1 then a[i-1,j]:=k+1;\nif a[i+1,j]=-1 then a[i+1,j]:=k+1;\nif a[i+1,j+1]=-1 then a[i+1,j+1]:=k+1;\nif a[i+1,j-1]=-1 then a[i+1,j-1]:=k+1;\nif a[i-1,j+1]=-1 then a[i-1,j+1]:=k+1;\nif a[i-1,j-1]=-1 then a[i-1,j-1]:=k+1;\nend;\npp1:=0;\npp2:=0;\nif (x1=x2)or(y1=y2) then write(1,' ') else write(2,' ');\nif ((x1 mod 2=0)and(y1 mod 2<>0))or((x1 mod 2<>0)and(y1 mod 2=0)) then pp1:=1;\nif ((x2 mod 2=0)and(y2 mod 2<>0))or((x2 mod 2<>0)and(y2 mod 2=0)) then pp2:=1;\nif pp1<>pp2 then write(0,' ') else\nbegin\nif (x1+y1=x2+y2)or((x1-x2)=(y1-y2)) then write(1,' ') else write(2,' ');\nend;\nwrite(a[x2,y2]-1);\n\n\n\n\n\nend.\n"}, {"source_code": "Uses math;\nType\n mat=array [1..100000] of longint;\nVar a:mat;\n n,r1,c1,r2,c2:longint;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Read(fi,r1,c1,r2,c2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nProcedure Sort(l,r:longint);\n Var i,j,key:longint;\n Begin\n i:=l;\n j:=r;\n key:=a[l+random(r-l+1)];\n Repeat\n While a[i]key do dec(j);\n If i<=j then\n Begin\n Doicho(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n Until i>j;\n If i(r2+c2) mod 2 then Write(fo,0,' ')\n else\n Begin\n If (r1+c1)=(r2+c2) then Write(fo,1,' ')\n else If (r1-c1)=(r2-c2) then Write(fo,1,' ')\n else Write(fo,2,' ');\n end;\n Write(fo,Max(abs(r1-r2),abs(c1-c2)));\n\n { If abs(gx+gy) mod 2<>abs(sx+sy) mod 2 then\n Begin\n dec(gy);\n nho:=1;\n end;\n Write(fo,nho+Max(abs(sx-gx),abs(sy-gy))); }\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "var r1, c1, r2, c2: byte;\nbegin\n readln(r1, c1, r2, c2);\n if (r1 = r2) and (c1 = c2) then\n write(0, ' ', 0, ' ', 0)\n else if (r1 = r2) xor (c1 = c2) then\n begin\n write(1, ' ');\n if odd(abs(c1 - c2) + (r1 - r2)) then\n write(0)\n else\n write(2);\n write(' ', abs((c1 - c2) + (r1 - r2)));\n end\n else\n begin\n write(2, ' ');\n if abs(r1 - r2) = abs(c1 - c2) then\n write(1)\n else if abs(r1 - r2) mod 2 = abs(c1 - c2) mod 2 then\n write(2)\n else\n write(0);\n if abs(r1 - r2) > abs(c1 - c2) then\n write(' ', abs(r1 - r2))\n else\n write(' ', abs(c1 - c2));\n end;\nend."}, {"source_code": "var\nr1,c1,r2,c2: byte;\nlad,slon,korol:byte;\n\nbegin\nread (r1,c1,r2,c2);\n\nif (abs(r1-r2)>0) and (abs(c1-c2)>0) then lad:=2 \n else if (abs(r1-r2)>0) or (abs(c1-c2)>0) then lad:=1 \n else lad:=0;\nwrite(lad,' ');\n\nif (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs (r1-r2) = abs(c1-c2)) then slon:=1\n else slon:=2\nelse \n slon:=0; \nwrite(slon,' ');\n\nif (r1-r2=0) then korol:=abs(c1-c2)\nelse \n if (c1-c2=0) then korol:=abs(r1-r2)\n else\n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(r1-r2) \n else korol:=abs(c1-c2);\nwrite(korol,' ');\n\nend."}, {"source_code": "var\nr1,c1,r2,c2,l,e,k,max:integer;\nbegin\nreadln(r1,c1,r2,c2);max:=abs(r1-r2);\nif (c1=c2) or (r1=r2) then\nl:=1\nelse l:=2;\nif abs(r1-r2)=abs(c1-c2) then\ne:=1\nelse if ((r1+c1) mod 2)<>((r2+c2) mod 2) then\ne:=0\nelse e:=2;\nif abs(c1-c2)>max then\nmax:=abs(c1-c2);\nk:=max;\nwriteln(l,' ',e,' ',k);\nend.\n"}, {"source_code": "uses math;\nvar r1, c1, r2, c2, l, s, k : longint;\nbegin\n\tReadln(r1,c1,r2,c2);\n\tif (r1=r2) or (c1=c2) then l:=1\n\telse l:=2;\n\tif (r1+c1+r2+c2) mod 2 = 0 then begin\n\t\tif abs(r1-r2) = abs(c1-c2) then s:=1\n\t\telse s:=2;\n\tend else s:=0;\n\tk:=max(abs(c1-c2),abs(r1-r2));\n\tWriteln(l,' ',s,' ',k);\nend."}, {"source_code": "uses math;\nVar x1,x2,y1,y2:longint;\n lechcot,lechhang:longint;\n\nProcedure doc;\nbegin\n Readln(x1,y1,x2,y2);\nend;\n\nprocedure xuly;\nbegin\n If (x1=x2) and (y1=y2) then\n begin\n Writeln(0,' ',0,' ',0);\n halt;\n end;\n If (x1=x2) or (y1=y2) then\n Write(1,' ')\n else\n Write(2,' ');\n If ((x1+y1) mod 2)<>((x2+y2) mod 2) then\n Write(0,' ')\n else\n If (x1+y1=x2+y2) or (x1-x2=y1-y2) then\n Write(1,' ')\n else\n Write(2,' ');\n lechcot:=abs(x1-x2);\n lechhang:=abs(y1-y2);\n Write(max(lechcot,lechhang));\nend;\n\nbegin\n doc;\n xuly;\nend.\n"}, {"source_code": "Program Ladya_Slon_Korol;\nvar x1,x2,y1,y2,resladya,reskorol,resslon,i,j:integer;\n a:array [1..8,1..8] of integer;\nfunction diagac(x,y:integer):integer;\nbegin\n diagac:=x-y;\nend;\nprocedure zapoln(x,y,n:integer);\nbegin\n a[x,y]:=n;\n inc(n);\n if n<=12 then\n begin\n if (x+1 in [1..8]) and (y+1 in [1..8]) then\n begin\n if a[x+1,y+1]>n then zapoln(x+1,y+1,n);\n end;\n if (x+1 in [1..8]) then\n begin\n if a[x+1,y]>n then zapoln(x+1,y,n);\n end;\n if (x+1 in [1..8]) and (y-1 in [1..8]) then\n begin\n if a[x+1,y-1]>n then zapoln(x+1,y-1,n);\n end;\n if (y+1 in [1..8]) then\n begin\n if a[x,y+1]>n then zapoln(x,y+1,n);\n end;\n if (y-1 in [1..8]) then\n begin\n if a[x,y-1]>n then zapoln(x,y-1,n);\n end; \n if (x-1 in [1..8]) and (y+1 in [1..8]) then\n begin\n if a[x-1,y+1]>n then zapoln(x-1,y+1,n);\n end;\n if (x-1 in [1..8]) then\n begin\n if a[x-1,y]>n then zapoln(x-1,y,n);\n end;\n if (x-1 in [1..8]) and (y-1 in [1..8]) then\n begin\n if a[x-1,y-1]>n then zapoln(x-1,y-1,n);\n end;\n end;\nend;\nbegin\n readln(x1,y1,x2,y2);\n resladya:=0;\n if x1<>x2 then inc(resladya);\n \n if y1<>y2 then inc(resladya);\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n a[j,i]:=16;\n end;\n end;\n zapoln(x1,y1,0);\n \n reskorol:=a[x2,y2];\n \n resslon:=0;\n if odd(x1+y1)=odd(x2+y2) then\n begin\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n a[j,i]:=2;\n end;\n end;\n i:=x1;\n j:=y1;\n while (i<=8) and (j<=8) do\n begin\n a[i,j]:=1;\n inc(i);\n inc(j);\n end;\n i:=x1;\n j:=y1;\n while (i<=8) and (j>=1) do\n begin\n a[i,j]:=1;\n inc(i);\n dec(j);\n end;\n i:=x1;\n j:=y1;\n while (i>=1) and (j<=8) do\n begin\n a[i,j]:=1;\n dec(i);\n inc(j);\n end;\n i:=x1;\n j:=y1;\n while (i>=1) and (j>=1) do\n begin\n a[i,j]:=1;\n dec(i);\n dec(j);\n end;\n resslon:=a[x2,y2];\n end;\n writeln(resladya,' ',resslon,' ',reskorol);\nend."}, {"source_code": "uses math;\nvar i,j,x1,x2,y1,y2,n,m,k,d,f,e,q,w:longint;\n //a,b,c:array[1..8,1..8] of longint;\nbegin\n read(x1,y1,x2,y2);\n //e:=min(abs(x1-x2),abs(y1-y2));\n e:=max(abs(x1-x2),abs(y1-y2));\n if (x1<>x2) then inc(q);\n if y1<>y2 then inc(q);\n if (x1+y1)mod 2 = (x2+y2)mod 2 then\n begin\n if abs(x1-x2)<>abs(y1-y2) then\n inc(w);\n inc(w);\n end;\n write(q,' ',w,' ',e);\nend."}, {"source_code": "uses math;\nvar r1,r2,c1,c2: integer;\n{}\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then write(1) else write(2);\n write(' ');\n if (r1+c1)mod 2 <>(r2+c2)mod 2 then write(0) else\n if (r1+c1=r2+c2)or(r1-c1=r2-c2) then write(1) else write(2);\n write(' ');\n write(max(abs(r1-r2),abs(c1-c2)));\nend."}], "negative_code": [{"source_code": "var\n m:array [1..111,1..111] of integer;\n r1,r2,c1,c2,r,b,a,i,j,x,y,t,k,ans1,ans:integer;\nbegin\n read(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then r:=1 else r:=2;\n \n if abs(r1-r2)=abs(c1-c2) then b:=1 else\n if (abs(r1-c1) mod 2=0) and (abs(r2-c2) mod 2=1) or\n (abs(r1-c1) mod 2=1) and (abs(r2-c2) mod 2=0) then b:=0 else b:=2;\n \n if (r1=r2) or (abs(r1-r2)=abs(c1-c2)) then k:=abs(c2-c1) else\n if c1=c2 then k:=abs(r1-r2) else\n begin\n k:=0; x:=r1-r2; y:=c1-c2;\n if x<0 then ans:=-1 else ans:=1;\n if y<0 then ans1:=-1 else ans1:=1;\n repeat\n r1:=r1-ans;\n c1:=c1-ans1;\n k:=a+1;\n until (r1=r2) or (c1=c2);\n if r1=r2 then k:=k+abs(c1-c2);\n if c1=c2 then k:=k+abs(r1-r2);\n end;\n\n write(r,' ',b,' ',k);\nend."}, {"source_code": "var\n m:array [1..8,1..8] of integer;\n r1,r2,c1,c2,r,b,k,t,i,j,d,c,a:integer;\nbegin\n read(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then r:=1 else r:=2;\n \n if (r1=r2) or (c1=c2) then b:=0 else\n if (abs(r1-r2)=abs(c1-c2)) then b:=1 else begin b:=maxint;\n repeat\n t:=t+1;\n for i:=1 to 8 do\n for j:=1 to 8 do m[i,j]:=0;\n repeat\n i:=random(8)+1;\n j:=random(8)+1;\n if (abs(r1-i)=abs(c1-j)) and (m[i,j]=0) then\n begin\n a:=a+1;\n m[i,j]:=a;\n end;\n until (r1=i) and (c1=j);\n if b>a then b:=a;\n until t=100;\n end;\n \n if r1=r2 then k:=abs(c1-c2) else\n if c1=c2 then k:=abs(r1-r2) else\n if (abs(r1-r2)=abs(c1-c2)) then k:=abs(r1-r2) else\n begin\n c:=r1-r2;\n d:=r1+c;\n k:=abs(c)+abs(c2-d);\n end;\n \n write(r,' ',b,' ',k);\nend."}, {"source_code": "Program sad;\nvar x1,x2,y1,y2:integer;\nbegin\nread(x1,y1,x2,y2);\nif (x1=x2) or (y1=y2) then write(1,' ') else \nwrite(2,' ');\nif ((x1+y1) mod 2)<>((x2+y2) mod 2) then write(0,' ') else\nbegin\nif (x1+y1)=(x2+y2) then write(1,' ') else \nwrite(2,' ');\nend; \nx1:=abs(x1-x2);\ny1:=abs(y1-y2);\nwrite( (((x1+y1)-abs(x1-y1)) div 2 )+ abs(x1-y1) );\nend."}, {"source_code": "program chess;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n r1,c1,r2,c2,ld,sl,k:integer;\nbegin\n readln(r1,c1,r2,c2);\n if ((r1=r2) or (c1=c2)) then ld:=1\n else ld:=2;\n if ((odd(r1+c1)<>odd(r2+c2))) then sl:=0\n else if (abs(r1-r2)=abs(c1-c2)) then sl:=1\n else sl:=2;\n if (r1=r2) then k:=abs(c1-c2)\n else if (c1=c2) then k:=abs(r1-r2)\n else if (abs(r1-r2)=abs(c1-c2)) then k:=abs(c1-c2)\n else k:=abs(abs(r1-r2)-abs(c1-c2));\n writeln(ld,' ',sl,' ',k);\n readln;\nend.\n"}, {"source_code": "var\n c1,c2,r1,r2,k1,k2,k3:integer;\n{procedure rec(r,c,t:integer; d1:real);\nvar\n d:real;\nbegin\n if (c=c2) and (r=r2) then\n if tr) and (8>c) then\n begin\n rec(r+1,c,t+1,d);\n rec(r-1,c,t+1,d);\n rec(r,c+1,t+1,d);\n rec(r,c-1,t+1,d);\n rec(r+1,c+1,t+1,d);\n rec(r+1,c-1,t+1,d);\n rec(r-1,c+1,t+1,d);\n rec(r-1,c-1,t+1,d);\n end;\nend;}\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if (r1=r2) and (c1<>c2) then\n if abs(c2-c1)mod 2 = 0 then k2:=2;\n if (c1=c2) and (r1<>r2) then\n if abs(r2-r1)mod 2 = 0 then k2:=2;\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1;\n //k3:=65;\n //rec(c1,r1,0,sqrt(sqr(r2-r1)+sqr(c2-c1)));\n while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);\n writeln(k1,' ',k2,' ',k3);\nend.\n \n"}, {"source_code": "var\n c1,c2,r1,r2,k1,k2,k3:integer;\n{procedure rec(r,c,t:integer; d1:real);\nvar\n d:real;\nbegin\n if (c=c2) and (r=r2) then\n if tr) and (8>c) then\n begin\n rec(r+1,c,t+1,d);\n rec(r-1,c,t+1,d);\n rec(r,c+1,t+1,d);\n rec(r,c-1,t+1,d);\n rec(r+1,c+1,t+1,d);\n rec(r+1,c-1,t+1,d);\n rec(r-1,c+1,t+1,d);\n rec(r-1,c-1,t+1,d);\n end;\nend;}\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n //k3:=65;\n //rec(c1,r1,0,sqrt(sqr(r2-r1)+sqr(c2-c1)));\n while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);\n writeln(k1,' ',k2,' ',k3);\nend.\n \n"}, {"source_code": "var\n c1,c2,r1,r2,k1,k2,k3:integer;\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if (r1=r2) and (c1<>c2) then\n if abs(c2-c1)mod 2 = 0 then k2:=2;\n if (c1=c2) and (r1<>r2) then\n if abs(r2-r1)mod 2 = 0 then k2:=2;\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1;\n if (abs(r2-r1+1) mod 2 = 1) and (abs(c2-c1+1) mod 2 = 1) then k2:=2;\n {while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);}\n if abs(r2-r1)r) and (8>c) then\n begin\n rec(r+1,c,t+1,d);\n rec(r-1,c,t+1,d);\n rec(r,c+1,t+1,d);\n rec(r,c-1,t+1,d);\n rec(r+1,c+1,t+1,d);\n rec(r+1,c-1,t+1,d);\n rec(r-1,c+1,t+1,d);\n rec(r-1,c-1,t+1,d);\n end;\nend;}\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if (r1=r2) and (c1<>c2) then\n if abs(c2-c1)mod 2 = 0 then k2:=2 else k2:=0;\n if (c1=c2) and (r1<>r2) then\n if abs(r2-r1)mod 2 = 0 then k2:=2 else k2:=0;\n //k3:=65;\n //rec(c1,r1,0,sqrt(sqr(r2-r1)+sqr(c2-c1)));\n while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);\n writeln(k1,' ',k2,' ',k3);\nend.\n \n"}, {"source_code": "var\n c1,c2,r1,r2,k1,k2,k3:integer;\nbegin\n readln(r1,c1,r2,c2);\n \n if (r1=r2) or (c1=c2) then\n k1:=1 else k1:=2;\n\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n k2:=0 else\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1 else k2:=2;\n if (r1=r2) and (c1<>c2) then\n if abs(c2-c1)mod 2 = 0 then k2:=2;\n if (c1=c2) and (r1<>r2) then\n if abs(r2-r1)mod 2 = 0 then k2:=2;\n if abs(r2-r1)=abs(c2-c1) then\n k2:=1;\n {while true do\n begin\n if (c1<9) and (r1<9) then\n if (abs(r2-r1)mod 2 = 0) or (abs(c2-c1)mod 2 = 0) then\n begin\n if (c2>c1) or (r2>r1) then\n if abs(r2-r1)>abs(c2-c1) then\n r1:=r1+1 else c1:=c1+1;\n if (c2abs(c2-c1) then\n r1:=r1-1 else c1:=c1-1;\n k3:=k3+1;\n end else break;\n if (c1=c2) and (r1=r2) then break;\n end;\n k3:=k3+abs(r2-r1);}\n if abs(r2-r1)(r2 mod 2)) then begin l:=2; b:=0; end\n else if ((c1 mod 2)<>(r1 mod 2)) and ((c2 mod 2)=(r2 mod 2)) then begin b:=0; l:=2; end\n else begin\n i:=r1; j:=c1; f:=r1;\n while j>=1 do begin\n if (i=r2) and (j=c2) then begin l:=1; b:=1; end;\n if (f=r2) and (j=c2) then begin l:=1; b:=1; end;\n if f<8 then f:=f+1;\n if i>1 then i:=i-1;\n j:=j-1;\n end;\n i:=r1; j:=c1; f:=r1;\n while j<=8 do begin\n if (i=r2) and (j=c2) then begin l:=1; b:=1; end;\n if (f=r2) and (j=c2) then begin l:=1; b:=1; end;\n if f<8 then f:=f+1;\n if i>1 then i:=i-1;\n j:=j+1;\n end;\n end;\n if l=0 then b:=2;\n i:=abs(r2-r1);\n j:=abs(c2-c1);\n if i(r2 mod 2)) then begin l:=2; b:=0; end\n else if ((c1 mod 2)<>(r1 mod 2)) and ((c2 mod 2)=(r2 mod 2)) then begin b:=0; l:=2; end\n else begin\n i:=r1; j:=c1; f:=r1;\n while j>=1 do begin\n if (i=r2) and (j=c2) then begin l:=1; b:=1; end;\n if (j=r2) and (j=c2) then begin l:=1; b:=1; end;\n if f<8 then f:=f+1;\n if i>1 then i:=i-1;\n j:=j-1;\n end;\n i:=r1; j:=c1; f:=r1;\n while j<=8 do begin\n if (i=r2) and (j=c2) then begin l:=1; b:=1; end;\n if (j=r2) and (j=c2) then begin l:=1; b:=1; end;\n if f<8 then f:=f+1;\n if i>1 then i:=i-1;\n j:=j+1;\n end;\n end;\n if l=0 then b:=2;\n i:=abs(r2-r1);\n j:=abs(c2-c1);\n if i X2 mod 2) and (Y1 mod 2 <> Y2 mod 2)) then\n begin\n if (X1 = X2) and (Y1 = Y2) then\n begin\n A2 := 0;\n end\n else if (abs(X1 - X2) = abs(Y1 - Y2)) then\n begin\n A2 := 1;\n end\n else\n begin\n A2 := 2;\n end;\n end\n else\n begin\n A2 := 0;\n end;\n if (X1 = X2) and (Y1 = Y2) then\n begin\n A1 := 0;\n end\n else if (X1 = X2) or (Y1 = Y2) then\n begin\n A1 := 1;\n end\n else\n begin\n A1 := 2;\n end;\n if (X1 = X2) and (Y1 = Y2) then\n begin\n A3 := 0;\n end\n else if (X1 = X2) then\n begin\n A3 := abs(Y1 - Y2);\n end\n else if (Y1 = Y2) then\n begin\n A3 := abs(X1 - X2);\n end\n else\n begin\n if (abs(X1 - X2) > abs(Y1 - Y2)) then\n begin\n A3 := abs(X1 - X2) - abs(Y1 - Y2) + abs(Y1 - Y2);\n end\n else\n begin\n A3 := abs(Y1 - Y2) - abs(X1 - X2) + abs(X1 - X2);\n end;\n end;\n writeln(A1, A2, A3);\n\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,m,k,j,i,h,x,y,y1,x1,k1:integer;\nfunction min(x,y:Integer):integer;\nbegin\n if (x b then\n max := a\n else\n max := b;\nend;\nbegin\n Readln(x1, y1, x2, y2);\n if (x1=x2) and (y1=y2) then\n Write(0, ' ')\n else\n if (x1=x2) or (y1=y2) then\n Write(1, ' ')\n else\n Write(2, ' ');\n\n if ((x1=x2) and (y1=y2)) or ((x1 + y1) mod 2 <> (x2 + y2) mod 2) then\n Write(0, ' ')\n else\n begin\n if (x1 - y1 = x2 - y2) or (x1 + y1 = x2 + y2) then\n Write(1, ' ');\n end;\n\n Write(max(abs(x1 - x2), abs(y1 - y2)));\nend.\n"}, {"source_code": "var a,b,c,d:longint;\nfunction max(a,b:longint):Longint;\nbegin\n max:=a;\n if b>a then max:=b;\nend;\nbegin\n readln (a,b,c,d);\n //\n if (a=c) or (b=d) then write ('1 ') else write ('2 ');\n //\n if ((a+b) mod 2<>(c+d) mod 2) then write ('0 ') else\n begin\n if (abs(a+b)=abs(c+d)) or (abs(a-b)=abs(c-d)) then write ('1 ') else write ('2 ');\n end;\n //\n write (max(c-a,d-b));\nend."}, {"source_code": "var a,b,c,d:longint;\nfunction max(a,b:longint):Longint;\nbegin\n max:=a;\n if b>a then max:=b;\nend;\nbegin\n readln (a,b,c,d);\n //\n if (a=c) or (b=d) then write ('1 ') else write ('2 ');\n //\n if ((a+b) mod 2<>(c+d) mod 2) then write ('0 ') else\n begin\n if (abs(a+b)=abs(c+d)) or (abs(a-b)=abs(c-d)) then write ('1 ') else write ('2 ');\n end;\n //\n write (max(abs(c-a),abs(d-b)));\nend."}, {"source_code": "program sdjkj;\nvar x1, y1, x2, y2: integer;\n sl, lad, king: integer;\nfunction isBlack(x: integer; y: integer):boolean;\nbegin\n if ((x mod 2 = 0) and (y mod 2 <> 0)) \n or \n ((x mod 2 <> 0) and (y mod 2 = 0))\n then isBlack := true else isBlack := false;\nend;\n\nbegin\n read(x1, y1, x2, y2);\n x1 := x1 - 1;\n x2 := x2 - 1;\n y1 := y1 - 1;\n y2 := y2 - 1;\n \n if( isBlack(x1, y1) <> isBlack(x2, y2) ) then sl := 0 else\n begin\n if ((x1 - y1) = (x2 - y2)) or ((x1 + y1) = (x2 + y2)) then sl := 1 else sl := 2; \n end;\n //writeln(sl);\n \n if (x1 = x2) or (y1 = y2) then lad := 1 else lad := 2;\n if (x1 = x2) or (y1 = y2) then king := abs(x1-x2) + abs(y2-y2) else\n king := (abs(x2-x1) + abs(y2-y1)) div 2 + (abs(x2-x1) + abs(y2-y1)) mod 2;\n \n write(lad, ' ', sl, ' ', king);\nend."}, {"source_code": "program sdjkj;\nvar x1, y1, x2, y2: integer;\n sl, lad, king: integer;\nfunction isBlack(x: integer; y: integer):boolean;\nbegin\n if ((x mod 2 = 0) and (y mod 2 <> 0)) \n or \n ((x mod 2 <> 0) and (y mod 2 = 0))\n then isBlack := true else isBlack := false;\nend;\n\nbegin\n read(x1, y1, x2, y2);\n x1 := x1 - 1;\n x2 := x2 - 1;\n y1 := y1 - 1;\n y2 := y2 - 1;\n \n if( isBlack(x1, y1) <> isBlack(x2, y2) ) then sl := 0 else\n begin\n if ((x1 - y1) = (x2 - y2)) or ((x1 + y1) = (x2 + y2)) then sl := 1 else sl := 2; \n end;\n //writeln(sl);\n \n if (x1 = x2) or (y1 = y2) then lad := 1 else lad := 2;\n if (x1 = x2) or (y1 = y2) then king := abs(x2-x1) + abs(y2-y1) else\n king := (abs(x2-x1) + abs(y2-y1)) div 2 + (abs(x2-x1) + abs(y2-y1)) mod 2;\n \n write(lad, ' ', sl, ' ', king);\nend."}, {"source_code": "program sdjkj;\nvar x1, y1, x2, y2: integer;\n sl, lad, king: integer;\nfunction isBlack(x: integer; y: integer):boolean;\nbegin\n if ((x mod 2 = 0) and (y mod 2 <> 0)) \n or \n ((x mod 2 <> 0) and (y mod 2 = 0))\n then isBlack := true else isBlack := false;\nend;\n\nbegin\n read(x1, y1, x2, y2);\n x1 := x1 - 1;\n x2 := x2 - 1;\n y1 := y1 - 1;\n y2 := y2 - 1;\n \n if( isBlack(x1, y1) <> isBlack(x2, y2) ) then sl := 0 else\n begin\n if ((x1 - y1) = (x2 - y2)) or ((x1 + y1) = (x2 + y2)) then sl := 1 else sl := 2; \n end;\n //writeln(sl);\n \n if (x1 = x2) or (y1 = y2) then lad := 1 else lad := 2;\n \n king := (abs(x2-x1) + abs(y2-y1)) div 2 + (abs(x2-x1) + abs(y2-y1)) mod 2;\n write(lad, ' ', sl, ' ', king);\nend."}, {"source_code": "program zzz;\n var x1,x2,y1,y2:longint;\n function max(x,y:longint):longint;\n begin\n if x>y then max:=x else max:=y;\n end;\n\n begin\n\n read(x1,y1,x2,y2);\n if (x1=x2) or(y2=y1) then write(1,' ') else write(2,' ');\n\n if abs(x1-x2)=abs(y1-y2) then write(1,' ') else\n if (abs(x1-x2) mod 2=0) and (abs(y1-y2) mod 2=0) then write(2,' ')\n else if (abs(x1-x2) mod 2=0) or (abs(y1-y2) mod 2=0) then write(0,' ');\n\n write(max(abs(x1-x2),abs(y1-y2)));\n\n end."}, {"source_code": "var\n x,y,x1,x2,y1,y2,a1,a2,a3,q : longint;\n\nbegin\n readln(x1,y1,x2,y2);\n if (x1 <> x2) then inc(a1);\n if (y1 <> y2) then inc(a1);\n if (abs(x1-x2) = abs(y1-y2)) then a2:=1 else begin\n x:=x1; y:=y1;\n while (x <= 8) and (y <= 8) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n inc(x);\n inc(y);\n end;\n x:=x1; y:=y1;\n while (x <= 8) and (y >= 1) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n inc(x);\n dec(y);\n end;\n x:=x1; y:=y1;\n while (x >= 1) and (y <= 8) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n dec(x);\n inc(y);\n end;\n x:=x1; y:=y1;\n while (x >= 1) and (y >= 1) do begin\n if abs(x-x2) = abs(y-y2) then a2:=2;\n dec(x);\n dec(y);\n end;\n end;\n a3:=maxlongint;\n x:=x1; y:=y1; q:=0;\n while (x <= 8) and (y <= 8) do begin\n if abs(x-x2) + abs(y-y2)+q < a3 then a3:=abs(x-x2) + abs(y-y2)+q;\n inc(x);\n inc(y);\n inc(q);\n end;\n x:=x1; y:=y1; q:=0;\n while (x <= 8) and (y >= 1) do begin\n if abs(x-x2) + abs(y-y2) < a3 then a3:=abs(x-x2) + abs(y-y2)+q;\n inc(x);\n dec(y);\n inc(q);\n end;\n x:=x1; y:=y1; q:=0;\n while (x >= 1) and (y <= 8) do begin\n if abs(x-x2) + abs(y-y2) < a3 then a3:=abs(x-x2) + abs(y-y2)+q;\n dec(x);\n inc(y);\n inc(q);\n end;\n x:=x1; y:=y1; q:=0;\n while (x >= 1) and (y >= 1) do begin\n if abs(x-x2) + abs(y-y2) < a3 then a3:=abs(x-x2) + abs(y-y2)+q;\n dec(x);\n dec(y);\n inc(q);\n end;\n writeln(a1,' ',a2,' ',a3);\nend."}, {"source_code": "uses math;\nvar\n sx,sy,fx,fy,k,l,s,delta,i,j,nx,ny : longint;\n color : array [0..200,0..200] of longint;\n found : boolean;\n procedure check(x,y : longint);\n begin\n if (x=fx) and (y=fy) then found:=true;\n end;\nbegin\n readln(sx,sy,fx,fy);\n for i:=1 to 8 do\n for j:=1 to 8 do\n color[i][j]:=(i+j) mod 2;\n if color[sx][sy]<>color[fx][fy] then s:=0 else\n begin\n found:=false;\n for delta:=1 to 100 do\n begin\n nx:=sx+delta; ny:=sy+delta;\n check(nx,ny);\n nx:=sx-delta; ny:=sy+delta;\n check(nx,ny);\n nx:=sx+delta; ny:=sy-delta;\n check(nx,ny);\n nx:=nx-delta; ny:=sy-delta;\n check(nx,ny);\n end;\n if found then s:=1 else s:=2;\n end;\n k:=max(abs(sx-fx),abs(sy-fy));\n if (sx=fx) or (sy=fy) then l:=1 else l:=2;\n writeln(l,' ',s,' ',k);\nend."}, {"source_code": "var\na,b,c,d,sum1,sum2,sum3:longint;\nbegin\nreadln(a,b,c,d);\nif (a=c) and (b=d) then\nsum1:=0;\nif (a<>c) and (b<>d) then\nsum1:=2;\nif (a<>c) and (b=d) then\nsum1:=1;\nif (a=c) and (b<>d) then\nsum1:=1;\nif ((a=c) and (b=d)) or (((a+b) mod 2)<>((c+d) mod 2)) then\nsum2:=0\nelse\nif (a+b)=(c+d) then\nsum2:=1\nelse\nsum2:=2;\nif abs(a-c)>abs(b-d) then\nsum3:=abs(a-c)\nelse\nsum3:=abs(b-d);\nwriteln(sum1,' ',sum2,' ',sum3);\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2=0 then\n h:=true;\n \nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\n \nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n\nif (r1=r2) and (c1=c2) then\n begin\n L:=0; S:=0; K:=0;\n \n end;\n\n\n\n{\nwriteln((ch(r1,c1))); }\n//writeln((ch(r1,c1)));\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-b))=(abs(c-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2<>0 then\n h:=true;\nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n\n\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2=0 then\n h:=true;\n \nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\n \nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n\nif (r1=r2) and (c1=c2) then\n begin\n L:=0; S:=0; K:=0;\n \n end;\n\n\n\n{\nwriteln((ch(r1,c1)));\nwriteln((ch(r2,c2))); }\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2=0 then\n h:=true;\n \nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\n \nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n{\nwriteln((ch(r1,c1)));\nwriteln((ch(r2,c2))); }\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2<>0 then\n h:=true;\n \nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\n \nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n\nif (r1=r2) and (c1=c2) then\n begin\n L:=0; S:=0; K:=0;\n \n end;\n\n\n\n{\nwriteln((ch(r1,c1))); }\n//writeln((ch(r2,c2)));\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "Program A_Chess;\nvar\n r1,c1,r2,c2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\n\nif (a mod 2=0) and (b mod 2<>0) then //black\n h:=true;\n \nif (a mod 2<>0) and (b mod 2=0) then //white\n h:=true;\n \nif a=b then\n if a mod 2<>0 then\n h:=false;\n \nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n\nk:=max(abs(r2-r1),abs(c2-c1)); //dlia king'a\n\nif (r1=r2) and (c1=c2) then\n begin\n L:=0; S:=0; K:=0;\n end;\n\nwriteln(l,' ',S+2,' ',K,' ');\nend."}, {"source_code": "Program A_Plus_B_Problem;\nvar\n r1,c1,r2,c2,x,y,a,b,x2,y2,t1,t2: integer;\n L,S,K: integer;\n \nfunction f1(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (a=c) or (b=d) then\n h:=true;\nf1:=h;\nend;\n \nfunction f2(a,b,c,d: integer): boolean;\nvar\n h: boolean;\nbegin\nh:=false;\nif (abs(a-c))=(abs(b-d)) then\n h:=true;\nf2:=h;\nend;\n\nfunction ch(a,b: integer): boolean; //true = black\nvar\n h: boolean;\nbegin\nh:=false;\nif a=b then\n if a mod 2<>0 then\n h:=true;\nif (a mod 2=0) then\n if b mod 2<>0 then\n h:=true;\nif (a mod 2<>0) then\n if b mod 2=0 then\n h:=true;\nch:=h;\nend;\n\nfunction max(a,b: integer): integer;\nbegin\nif a>=b then\n max:=a\nelse\n max:=b;\nend;\n\n//osnovnaja proga\nbegin\nread(r1);read(c1);read(r2);read(c2);\nL:=0; S:=0; K:=0;\n\nif f1(r1,c1,r2,c2) then //ladia gorizont\n L:=1\nelse\n L:=2;\n\nif (ch(r1,c1)) and (ch(r2,c2)) then //black elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \nif (not(ch(r1,c1))) and (not(ch(r2,c2))) then //white elehpant\n begin\n if f2(r1,c1,r2,c2) then\n S:=1\n else\n S:=2;\n end;\n \n\nk:=max(abs(r2-r1),abs(c2-c1));\n\n//writeln(f2(r1,c1,r2,c2));\n\n\n\n\n\n\n\nwriteln(l,' ',S,' ',K,' ');\nend."}, {"source_code": "var\na:array[1..8,1..8] of integer;\nr1,r2,c1,c2,k,i,j:integer;\nbegin\nreadln(r1,c1,r2,c2);\nbegin\nif (r1=r2) or (c1=c2) then\nwriteln(1)\nelse writeln(2);\nend;\nbegin\nif ((r1+c1)=(r2+c2)) or ((r1-c1)=(r2-c2)) then\nwriteln(1)\nelse if (((r1+c1) mod 2=1) and ((r2+c2) mod 2=1)) or (((r1+c1) mod 2=0) and ((r2+c2) mod 2=0)) then\nwriteln(2)\nelse writeln(0);\nend;\nbegin\nif r1=r2 then\nk:=abs(c2-c1)\nelse if c1=c2 then\nk:=abs(r2-r1)\nelse if (abs(r2-r1))>(abs(c2-c1)) then\nk:=abs(r2-r1)\nelse if (abs(c2-c1))>(abs(r2-r1)) then\nk:=abs(c2-c1);\nwriteln(k);\nend;\nend.\n"}, {"source_code": "var\na:array[1..8,1..8] of integer;\nr1,r2,c1,c2,k,i,j:integer;\nbegin\nreadln(r1,c1,r2,c2);\nbegin\nif (r1=r2) or (c1=c2) then\nwriteln(1)\nelse writeln(2);\nend;\nbegin\nif ((r1+c1)=(r2+c2)) or ((r1-c1)=(r2-c2)) then\nwriteln(1)\nelse if (r1+c1) mod 2=1 then\nwriteln(2)\nelse writeln(0);\nend;\nbegin\nif r1=r2 then\nk:=abs(c2-c1)\nelse if c1=c2 then\nk:=abs(r2-r1)\nelse k:=abs(c2-c1);\nwriteln(k);\nend;\nend.\n"}, {"source_code": "var\na:array[1..8,1..8] of integer;\nr1,r2,c1,c2,k,i,j:integer;\nbegin\nreadln(r1,c1,r2,c2);\nbegin\nif (r1=r2) or (c1=c2) then\nwriteln(1)\nelse writeln(2);\nend;\nbegin\nif ((r1+c1)=(r2+c2)) or ((r1-c1)=(r2-c2)) then\nwriteln(1)\nelse if (((r1+c1) mod 2=1) and ((r2+c2) mod 2=1)) or (((r1+c1) mod 2=0) and ((r2+c2) mod 2=0)) then\nwriteln(2)\nelse writeln(0);\nend;\nbegin\nif r1=r2 then\nk:=abs(c2-c1)\nelse if c1=c2 then\nk:=abs(r2-r1)\nelse k:=abs(c2-c1);\nwriteln(k);\nend;\nend.\n"}, {"source_code": "var\na:array[1..8,1..8] of integer;\nr1,r2,c1,c2,k,i,j:integer;\nbegin\nreadln(r1,c1,r2,c2);\nbegin\nif (r1=r2) or (c1=c2) then\nwriteln(1)\nelse writeln(2);\nend;\nbegin\nif ((r1+c1)=(r2+c2)) or ((r1-c1)=(r2-c2)) then\nwriteln(1)\nelse if ((r1+c1) mod 2=1) and ((r2+c2) mod 2=1) then {weqe//}\nwriteln(2)\nelse writeln(0);\nend;\nbegin\nif r1=r2 then\nk:=abs(c2-c1)\nelse if c1=c2 then\nk:=abs(r2-r1)\nelse k:=abs(c2-c1);\nwriteln(k);\nend;\nend.\n"}, {"source_code": "Program a370;\nuses math;\nconst fi = '';\n fo = '';\nvar f : text;\n r1,c1,r2,c2 : longint;\nBEGIN\n READ(r1,c1,r2,c2);\n If (r1=r2) and (c1=c2) then\n begin\n write(0,' ',0,' ',0);\n halt;\n end;\n If (r1=r2) or (c1=c2) then write (1,' ') else write(2,' ');\n IF ((r1+c1) mod 2) <> ((r2+c2) mod 2) then write(0,' ')\n else\n if ((r1-c1) = (r2-c2)) or (r1+c1=r2+c2) then write(1,' ')\n else write(2);\n write(max(abs(r1-r2),abs(c1-c2)));\nEND.\n"}, {"source_code": "Program a370;\nuses math;\nconst fi = '';\n fo = '';\nvar f : text;\n r1,c1,r2,c2 : longint;\nBEGIN\n READ(r1,c1,r2,c2);\n If (r1=r2) and (c1=c2) then\n begin\n write(0,' ',0,' ',0);\n halt;\n end;\n If (r1=r2) or (c1=c2) then write (1,' ') else write(2,' ');\n IF (r1+c1) mod 2 <> (r2+c2) mod 2 then write(0,' ')\n else\n if abs(r1+c1) = abs(r2+c2) then write(1,' ')\n else write(2,' ');\n write(max(abs(r1-r2),abs(c1-c2)));\nEND.\n"}, {"source_code": "var\n r1,c1,r2,c2:longint;\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then write('1 ')\n else write('2 ');\n if (r1+c1=r2+c2)or(r1-c1=r2-c2) then write(1)\n else if not((r1-c1) mod 2=(r2+c2)) then write(0)\n else write(2);\nend."}, {"source_code": "uses math;\nvar\n r1,c1,r2,c2:longint;\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then write('1 ')\n else write('2 ');\n if (r1+c1=r2+c2)or(r1-c1=r2-c2) then write(1)\n else if not((r1-c1) mod 2=(r2+c2) mod 2) then write(0)\n else write(2);\n write(max(abs(r1-r2),abs(c1-c2)));\nend."}, {"source_code": "uses math;\nvar\n r1,c1,r2,c2:longint;\nbegin\n readln(r1,c1,r2,c2);\n if (r1=r2)or(c1=c2) then write('1 ')\n else write('2 ');\n if (r1+c1=r2+c2)or(r1-c1=r2-c2) then write('1 ')\n else if not((r1-c1) mod 2=(r2+c2) mod 2) then write('0 ')\n else write('2 ');\n write(max(abs(r1-r2),abs(c1-c2)));\nend."}, {"source_code": "var x1,x2,y1,y2:longint;\nfunction max(a,b:longint):longint;\nbegin\nif a>b then max:=a else max:=b;\nend;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(x1,y1,x2,y2);\nif (x1=x2) and (y1=y2) then begin writeln('0 0 0 '); halt; end;\nif (x1=x2) or (y1=y2) then write('1 ') else write('2 ');\nif (x1 mod 2 = y1 mod 2) and (x2 mod 2<>y2 mod 2) then write('0 ')\n else if abs(x1-x2)=abs(y1-y2) then write('1 ') else write('2 ');\nwrite(max(abs(x1-x2),abs(y1-y2)));\n\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram proA370;\nuses\n math;\nconst\n fi = 'proA370.inp';\nvar\n r1, c1, r2, c2 : Integer;\n\nbegin\n {$ifndef online_judge}\n assign(input, fI); reset(input);\n {$endif}\n readln(r1, c1, r2, c2);\n\n if (r1 = r2) or (c1 = c2) then write(1,' ') else write(2,' ');\n\n if (r1 - c1 = r2 - c2) or (r1 + c1 = r2 + c2) then write(1,' ') else\n if ((r1 + c1 + r2 + c2) mod 2 = 0) then write(2,' ') else write(0,' ');\n\n writeln(abs(r1 - r2) + Min( abs(c2 - (r2 - r1 + c1)), abs(c2 - (r1 + c1 - r2) ) ));\nend."}, {"source_code": "program aaa1;\nvar\n a,c1,c2,b,r1,r2,f : integer;\nbegin\n read(r1,c1,r1,c2);\n if (r1=r2) or (c1=c2) then a:=1\n else a:=2;\n if (abs(r1-r2)+abs(c1-c2)) mod 2 =0 then\n if abs(r1-r2)=abs(c1-c2) then b:=1\n else b:=2\n else b:=0;\n\n if abs(r1-r2)>abs(c1-c2) then f:= abs(r1-r2)\n else f:=abs(c1-c2);\n\n writeln(a,' ',b,' ',f);\n\nend."}, {"source_code": "program aaa1;\nvar\n a,c1,c2,b,r1,r2,f : integer;\nbegin\n read(r1,c1,r1,c2);\n if (r1=r2) or (c1=c2) then a:=1\n else a:=2;\n if (abs(r1-r2)+abs(c1-c2)) mod 2 =0 then\n if abs(r1-r2)=abs(c1-c2) then b:=1\n else b:=2\n else b:=0;\n\n if abs(r1-r2)>abs(c1-c2) then f:= abs(r1-r2)\n else f:=abs(c1-c2);\n\n writeln(a,' ',b,' ',f);\n readln; readln;\n\nend."}, {"source_code": "var i,n,x1,x2,y1,y2,j,k,pp1,pp2:longint;\na:array [-1..10,-1..10] of longint;\nbegin\nreadln(x1,y1,x2,y2);\nfor i:=-1 to 10 do\nfor j:=-1 to 10 do\na[i,j]:=-1;\na[x1,y1]:=1;\n\nfor k:=1 to 64 do\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nif a[i,j]=k then begin\nif a[i,j+1]=-1 then a[i,j+1]:=k+1;\nif a[i,j-1]=-1 then a[i,j-1]:=k+1;\nif a[i-1,j]=-1 then a[i-1,j]:=k+1;\nif a[i+1,j]=-1 then a[i+1,j]:=k+1;\nif a[i+1,j+1]=-1 then a[i+1,j+1]:=k+1;\nif a[i+1,j-1]=-1 then a[i+1,j-1]:=k+1;\nif a[i-1,j+1]=-1 then a[i-1,j+1]:=k+1;\nif a[i-1,j-1]=-1 then a[i-1,j-1]:=k+1;\nend;\npp1:=0;\npp2:=0;\nif (x1=x2)or(y1=y2) then write(1,' ') else write(2,' ');\nif ((x1 mod 2=0)and(y1 mod 2<>0))or((x1 mod 2<>0)and(y1 mod 2=0)) then pp1:=1;\nif ((x2 mod 2=0)and(y2 mod 2<>0))or((x2 mod 2<>0)and(y2 mod 2=0)) then pp2:=1;\nif pp1<>pp2 then write(0,' ') else\nbegin\nif x1+y1=x2+y2 then write(1,' ') else write(2,' ');\nend;\nwrite(a[x2,y2]-1);\n\n\n\n\n\nend.\n"}, {"source_code": "var\nr1,c1,r2,c2,l,e,k,max:integer;\nbegin\nreadln(r1,c1,r2,c2);max:=abs(r1-r2);\nif (c1=c2) or (r1=r2) then\nl:=1\nelse l:=2;\nif (r1+r2=c1+c2) or (r1-r2=c1-c2) then\ne:=1\nelse if ((r1+c1) mod 2)<>((r2+c2) mod 2) then\ne:=0\nelse e:=2;\nif abs(c1-c2)>max then\nmax:=abs(c1-c2);\nk:=max;\nwriteln(l,' ',e,' ',k);\nend.\n"}, {"source_code": "var\nr1,c1,r2,c2,l,e,k,max:integer;\nbegin\nreadln(r1,c1,r2,c2);max:=abs(r1-r2);\nif (c1=c2) or (r1=r2) then\nl:=1\nelse l:=2;\nif (r1+r2=c1+c2) or (abs(r1-r2)=abs(c1-c2)) then\ne:=1\nelse if ((r1+c1) mod 2)<>((r2+c2) mod 2) then\ne:=0\nelse e:=2;\nif abs(c1-c2)>max then\nmax:=abs(c1-c2);\nk:=max;\nwriteln(l,' ',e,' ',k);\nend.\n"}, {"source_code": "var\nr1,c1,r2,c2,l,e,k,max:integer;\nbegin\nreadln(r1,c1,r2,c2);max:=abs(r1-r2);\nif (c1=c2) or (r1=r2) then\nl:=1\nelse l:=2;\nif (r1+r2=c1+c2) and (abs(r1-r2)=abs(c1-c2)) then\ne:=1\nelse if ((r1+c1) mod 2)<>((r2+c2) mod 2) then\ne:=0\nelse e:=2;\nif abs(c1-c2)>max then\nmax:=abs(c1-c2);\nk:=max;\nwriteln(l,' ',e,' ',k);\nend.\n"}, {"source_code": "uses math;\nVar x1,x2,y1,y2:longint;\n lechcot,lechhang:longint;\n\nProcedure doc;\nbegin\n Readln(x1,y1,x2,y2);\nend;\n\nprocedure xuly;\nbegin\n If (x1=x2) and (x2=y2) then\n begin\n Writeln(0,' ',0,' ',0);\n halt;\n end;\n If (x1=x2) or (y1=y2) then\n Write(1,' ')\n else\n Write(2,' ');\n If ((x1+y1) mod 2)<>((x2+y2) mod 2) then\n Write(0,' ')\n else\n If (x1+y1=x2+y2) or (x1-x2=y1-y2) then\n Write(1,' ')\n else\n Write(2,' ');\n lechcot:=abs(x1-x2);\n lechhang:=abs(y1-y2);\n Write(max(lechcot,lechhang));\nend;\n\nbegin\n doc;\n xuly;\nend."}, {"source_code": "uses math;\nvar c1, c2, r1, r2: longint;\nbegin\nread(r1, c1, r2, c2);\nif (r1=r2) or (c1=c2) then write(1, ' ')\nelse write(2, ' ');\nif (max(r1, r2) mod min(r1, r2)) mod 2= (max(c1, c2) mod min(c1, c2)) mod 2 then\nbegin\nif abs(r1-r2)=abs(c1-c2) then write(1, ' ')\nelse write(2, ' ');\nend\nelse write(0, ' ');\nwrite(max(abs(c1-c2), abs(r1-r2)));\nend.\n"}, {"source_code": "var r1,c1,r2,c2:integer;\n a1,a2,a3:integer;\nbegin\nreadln(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then a1:=1\n else a1:=2;\nif (r1-c1=r2-c2) or (r1+c1=r2+c2) then a2:=1;\nif ((r1+c1) mod 2=0) and ((r2+c2) mod 2=0) then a2:=2;\nif abs(r1-r2)>abs(c1-c2) then a3:=abs(r1-r2)\n else a3:=abs(c1-c2);\nwriteln(a1,' ',a2,' ',a3);\nend."}, {"source_code": "var r1,c1,r2,c2:integer;\n a1,a2,a3:integer;\nbegin\nreadln(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then a1:=1\n else a1:=2;\nif (r1-c1=r2-c2) or (r1+c1=r2+c2) then a2:=1;\nif abs(r1-r2)>abs(c1-c2) then a3:=abs(r1-r2)\n else a3:=abs(c1-c2);\nwriteln(a1,' ',a2,' ',a3);\nend."}, {"source_code": "uses Math;\nconst\n fil='';\n fil2='';\nvar\n r1,r2,c1,c2:longint;\nprocedure nhap;\nbegin\n assign(input,fil); reset(input);\n assign(output,fil2); rewrite(output);\n readln(r1,c1,r2,c2);\nend;\nprocedure xuli;\nvar a,b,c:longint;\nbegin\n if (r1=r2) then a:=1\n else if c1=c2 then a:=1\n else a:=2;\n if (odd(r1) = odd(c1))=(odd(r2) = odd(c2)) then\n begin\n if abs(r1-r2)=abs(c1-c2) then b:=1\n else b:=2;\n end else b:=0;\n c:=max(r2-r1,c2-c1);\n write(a,' ',b,' ',c);\nend;\nbegin\n nhap;\n xuli;\nend."}, {"source_code": "program codeforces;\n\n(* Main code is here ... *)\n\nvar\n\tt, r1, r2, c1, c2 : integer;\nbegin\n\tread(r1, c1, r2, c2);\n\tif (r1 = r2) and (c1 = c2) then\n\tbegin\n\t\twriteln(0, ' ', 0, ' ', 0);\n\t\texit;\n\tend;\n\t(* Rook *)\n\tt := 0;\n\tif r1 <> r2 then t := t+1;\n\tif c1 <> c2 then t := t+1;\n\twrite(t, ' ');\n\t(* Bishop *)\n\tt := 2;\n\tif abs(r1-r2) = abs(c1-c2) then t := 1;\n\tif abs(r1-r2)+abs(c1-c2) mod 2 = 1 then t := 0;\n\twrite(t, ' ');\n\t(* King *)\n\tt := 0;\n\tif abs(r1-r2) > abs(c1-c2) then\n\t\tt := abs(r1-r2)\n\telse\n\t\tt := abs(c1-c2);\n\twrite(t);\n\twriteln();\nend.\n"}, {"source_code": "program codeforces;\n\n(* Main code is here ... *)\n\nvar\n\tt, r1, r2, c1, c2 : integer;\nbegin\n\tread(r1, c1, r2, c2);\n\t(* Rook *)\n\tt := 0;\n\tif r1 <> r2 then t := t+1;\n\tif c1 <> c2 then t := t+1;\n\twrite(t, ' ');\n\t(* Bishop *)\n\tt := 2;\n\tif abs(r1-r2) = abs(c1-c2) then t := 1;\n\twrite(t, ' ');\n\t(* King *)\n\tt := 0;\n\tif abs(r1-r2) > abs(c1-c2) then\n\t\tt := abs(r1-r2)\n\telse\n\t\tt := abs(c1-c2);\n\twrite(t);\n\twriteln();\nend.\n"}, {"source_code": "program bt1177;\nuses math;\nconst\n FI='';\n FO='';\nvar\n f:text;\n xe,tuong,vua:longint;\n r1,r2,c1,c2:longint;\n\nprocedure doc;\nbegin\n assign(f,FI);\n reset(f);\n read(f,r1,c1,r2,c2);\n close(f);\nend;\n\nprocedure xuli;\nbegin\n if (r1=r2) or (c1=c2) then xe:=1\n else xe:=2;\n\n if ((r1+c1) mod 2= (r2+c2) mod 2) then\n if ((r1+c1)=(r2+c2)) or (abs(r1-c1)=abs(r2-c2)) then tuong:=1\n else tuong:=2\n else tuong:=0;\n\n vua:=max(abs(r1-r2),abs(c2-c1));\n\nend;\n\nprocedure ghi;\nbegin\n assign(f,FO);\n rewrite(f);\n writeln(f,xe,' ',tuong,' ',vua);\n close(f);\nend;\n\nbegin\n doc;\n xuli;\n ghi;\nend.\n"}, {"source_code": "Uses Math;\nVar x1, y1, x2, y2, t1, t2, x: longint;\nbegin\n read(x1, y1, x2, y2);\n\n //Rook\n if(x1=x2) or (y1=y2) then\n write('1 ')\n else\n write('2 ');\n\n //Elephant\n if (x1+y1) mod 2 <> (x2+y2) mod 2 then\n write('0 ')\n else if abs(x1-x2)=abs(y1-y2) then\n write('1 ')\n else\n write('2 ');\n\n //King\n x:= abs(x1-x2);\n if y1+x>8 then\n t1:= 100500\n else\n t1:= abs(y1-y2);\n x:= abs(y1-y2);\n if x1+x>8 then\n t2:= 100500\n else\n t2:= abs(x1-x2);\n write(min(t1,t2));\nend."}, {"source_code": "Uses Math;\nVar x1, y1, x2, y2, t1, t2, x: longint;\nbegin\n read(x1, y1, x2, y2);\n\n //Rook\n if(x1=x2) or (y1=y2) then\n write('1 ')\n else\n write('2 ');\n\n //Elephant\n if (x1+y1) mod 2 <> (x2+y2) mod 2 then\n write('0 ')\n else if abs(x1-x2)=abs(y1-y2) then\n write('1 ')\n else\n write('2 ');\n\n //King\n x:= abs(x1-x2);\n t1:= x + abs(y1+x-y2);\n x:= abs(y1-y2);\n t2:= x + abs(x1+x-x2);\n write(min(t1,t2));\nend."}, {"source_code": "Program KadalBonek;\n\nvar\n\ta,b,c,d : integer;\n\nbegin\n\treadln(a,b,c,d);\n\tif ((a = c) or (b = d)) then write('1 ')\n\telse write('2 ');\n\t\n\tif (((a = c) and ((b - d) mod 2 = 0)) or ((b = d) and ((a - c) mod 2 = 0))) then write('2 ')\n\telse if ((a = c) or (b = d)) then write('0 ')\n\telse if (((a-c)/(b-d)=1) or ((a-c)/(b-d)=-1)) then write('1 ')\n\telse if ((a mod 2 = c mod 2) and (b mod 2 = d mod 2)) then write('2 ')\n\telse write('0 ');\n\t\n\tif((a >= c)and(b >= d)) then\n\t\tif(a - c > b - d) then writeln(a - c)\n\t\telse writeln(b - d)\n\telse if((a >= c)and(b <= d)) then\n\t\tif(a - c > d - b) then writeln(a - c)\n\t\telse writeln(d - b)\n\telse if((a <= c)and(b >= d))then\n\t\tif(c - a > b - d) then writeln(c - a)\n\t\telse writeln(b - d)\n\telse\n\t\tif(c - a > d - b) then writeln(c - a)\n\t\telse writeln(d - b);\nend."}, {"source_code": "var x1,y1,x2,y2:integer;\nx,y:integer;\nfunction min(a,b:integer):integer;\nbegin\n if ab then max:=a else max:=b;\nend;\n\nbegin\nreadln(x1,y1,x2,y2);\nif (x1=x2) or (y1=y2) then write('1 ') else write('2 ');\nif x1-x2=y1-y2 \n then\n begin\n write('1 ');\n end\n else \n begin\n if ((x1-1)*8+y1) mod 2=((x2-1)*8+y2) mod 2\n then write('2 ')\n else write('0 ');\n end;\n x:=abs(x1-x2);\n y:=abs(y1-y2);\n writeln(min(x,y)+abs(x-y));\nend."}, {"source_code": "uses math;\nconst\n inp='';//370A.inp';\n out='';//370A.out';\n\nvar\n fi,fo:text;\n r1,c1,r2,c2:longint;\n\nbegin\n assign(fi,inp); assign(fo,out);\n reset(fi); rewrite(fo);\n read(fi,r1,c1,r2,c2);\n if (r1=r2) and (r2=c2) then write(fo,'0 0 0')\n else\n begin\n if (r1=r2) or (c1=c2) then write(fo,1,' ') else write(fo,2,' ');\n if (r1+c1) mod 2<>(r2+c2) mod 2 then write(fo,0,' ') else\n if ((r1+c1)=(r2+c2)) or (r1-c1=r2-c2) then write(fo,1,' ') else write(fo,2,' ');\n write(fo,max(abs(r1-r2),abs(c1-c2)));\n end;\n close(fi); close(fo);\nend."}, {"source_code": "uses math;\nvar r,c,r1,c1:longint;\n s,l,k,x,y,z,i,j,m,n:longint;\n begin\n read(r,c,r1,c1);\n if (r=r1) or (c=c1) then Write(1,' ') else Write(2,' ');\n if (c=c1) and (abs(r-r1)>0) then Write(2,' ') else\n if (c=r) and (c1=r1) and ((abs(c1-r)=abs(c-r1))) or ((c1+r1)=(c+r))\n then Write(1,' ') else\n Write(0,' ');\n if (r=r1) then Write(abs(c1-c),' ') else\n if (c1=c) then Write(abs(r-r1),' ') else\n begin\n Write(max(abs(c-c1),abs(r-r1)));\n end;\n end."}, {"source_code": "uses math;\nvar r,c,r1,c1:longint;\n s,l,k,x,y,z,i,j,m,n:longint;\n begin\n read(r,c,r1,c1);\n if (r=r1) or (c=c1) then Write(1,' ') else Write(2,' ');\n if (c=c1) and (abs(r-r1)>0) and ((r mod 2)=(r1 mod 2))then Write(2,' ') else\n if (r=r1) and (abs(c-c1)>0) and ((c mod 2)=(c1 mod 2))then Write(2,' ') else\n if (c=r) and (c1=r1) and ((abs(c1-r)=abs(c-r1))) or ((c1+r1)=(c+r))\n then Write(1,' ') else\n Write(0,' ');\n if (r=r1) then Write(abs(c1-c),' ') else\n if (c1=c) then Write(abs(r-r1),' ') else\n begin\n Write(max(abs(c-c1),abs(r-r1)));\n end;\n end.\n"}, {"source_code": "var\n x1,x2,y1,y2:longint;\n ans1,ans2,ans3:longint;\n\nfunction max(a,b:longint):longint;\nbegin\n if a > b\n then exit(a)\n else exit(b);\nend;\n\nbegin\n //Come and hack me if you can!\n read(x1,y1,x2,y2);\n if (x2 - x1) * (y2 - y1) = 0\n then ans1:=1\n else ans1:=2;\n if ((x1 + y1) and 2) <> ((x2 + y2) and 2)\n then ans2:=0\n else\n begin\n if (abs(x1 - y1) = abs(x2 - y2)) or (abs(x1 + y1) = abs(x2 + y2))\n then ans2:=1\n else ans2:=2;\n end;\n ans3:=max(abs(x1-x2),abs(y1-y2));\n writeln(ans1,' ',ans2,' ',ans3);\nend.\n"}, {"source_code": "var a,b,c,n,r1,c1,r2,c2,i,j:longint;\n\nfunction max(a1,a2:longint):longint;\nbegin\nmax:=a1;\nif a2>a1 then max:=a2;\nend;\n\nbegin\nreadln(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then a:=1 else a:=2;\nif (r1+c1)mod 2<>(r2+c2) mod 2 then b:=0 else\nif r1+c1=r2+c2 then b:=1 else b:=0;\nc:=max(abs(r1-r2),abs(c1-c2));\nwriteln(a,' ',b,' ',c);\nend."}, {"source_code": "uses math;\nvar\n r1,c1,r2,c2:longint;\n ans1,ans2,ans3:longint;\nbegin\n read(r1,c1,r2,c2);\n if (r1=r2) and (c1=c2) then begin writeln(0,' ',0,' ',0); halt; end;\n\n if (r1=r2) or (c1=c2) then ans1:=1\n else ans1:=2;\n\n if (r1+c1)mod 2<>(r2+c2)mod 2 then ans2:=0\n else if abs(r1-r2)+abs(c1-c2)<>0 then ans2:=1\n else ans2:=2;\n\n ans3:=max(abs(r2-r1),abs(c2-c1));\n writeln(ans1,' ',ans2,' ',ans3);\nend.\n"}, {"source_code": "uses math;\nvar r1,c1,r2,c2:byte; i:shortint;\nbegin\n read(r1,c1,r2,c2);\n if (r1=r2) or (c1=c2) then write('1 ')\n else write('2 ');\n if (c2-r2=c1-r1) or (r2+c2=r1+c1) then write('1 ')\n else begin\n i:=0;\n if r1 mod 2=0 then inc(i);\n if c1 mod 2=0 then inc(i);\n if r2 mod 2=0 then dec(i);\n if c2 mod 2=0 then dec(i);\n if i=0 then write('2 ')\n else write('0 ')\n end;\n write(max(abs(r1-r2),abs(c1-c2)))\nend. "}, {"source_code": "program codeforces;\n\n(* Main code is here ... *)\n\nvar\n\tt, r1, r2, c1, c2 : integer;\nbegin\n\tread(r1, c1, r2, c2);\n\t(* Rook *)\n\tt := 0;\n\tif r1 <> r2 then t := t+1;\n\tif c1 <> c2 then t := t+1;\n\twrite(t, ' ');\n\t(* Bishop *)\n\tt := 0;\n\tif abs(r1-r2) = abs(c1-c2) then t := 1;\n\twrite(t, ' ');\n\t(* King *)\n\tt := 0;\n\tif abs(r1-r2) > abs(c1-c2) then\n\t\tt := abs(r1-r2)\n\telse\n\t\tt := abs(c1-c2);\n\twrite(t);\n\twriteln();\nend.\n"}, {"source_code": "program sss;\nvar a,b,c,d:longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then exit(x);\n exit(y);\nend;\nbegin\n readln(a,b,c,d);\n\n if (a=c)or(b=d) then write(1,' ')\n else write(2,' ');\n\n if (a+b)mod 2=(c+d)mod 2 then\n begin\n if a-c=abs(b-d) then write(1,' ')\n else write(2,' ');\n end\n else write(0,' ');\n\n writeln(max(abs(a-c),abs(b-d)));\n\n\n\n\n\n\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f : text;\n r1,c1,r2,c2 : longint;\nFunction max(x,y:longint):longint;\nbegin\n IF x>y then exit(x);\n exit(y);\nend;\nBEGIN\n READ(r2,c1,r1,c1);\n If (r1=r2) and (c1=c2) then\n begin\n write(0,' ',0,' ',0);\n halt;\n end;\n If (r1=r2) or (c1=c2) then write (1,' ') else write(2,' ');\n IF ((r1+c1) mod 2) <> ((r2+c2) mod 2) then write(0,' ')\n else\n if ((r1-c1) = (r2-c2)) or (r1+c1=r2+c2) then write(1,' ')\n else write(2,' ');\n write(max(abs(r1-r2),abs(c1-c2)));\nEND.\n"}, {"source_code": "var c,kp,kf,f,p,r1,c1,r2,c2,l,s,k:integer;\nbegin\nread(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then l:=1 else l:=2;\nif (r1 mod 2*c1 mod 2<> r2 mod 2* c2 mod 2)then s:=0 else\nbegin\nfor p:=-8 to 8 do begin\nif ((r1+p=r2) and (c1+p=c2)) or ((r1-p=r2) and (c1+p=c2)) then s:=1;\nend;\nif (s=0)then s:=2;\nend;\nfor p:=-8 to 8 do begin\nfor f:=-8 to 8 do begin\nif (r1+p=r2) and (c1+f=c2) then begin\nkp:=abs(p);\nkf:=abs(f);\nend;\nend;\nend;\nif (kp s1 then write(s2) else write(s1);\n end;\n \nend."}, {"source_code": "var\ns1,s2,r1,r2,c1,c2:integer;\nbegin\n\nread(r1,c1,r2,c2);\nif (r1=r2) or (c1=c2) then write(1,' ')\n else write(2,' ');\nif (r1+c1 = r2+c2) or (r1-c1 = r2-c2) then write(1,' ') \n else if (r1+c1 mod 2) = (r2+c2 mod 2 ) then write(2,' ') \n else write(0,' ');\nif (r1+c1 = r2+c2) or (r1-c1 = r2-c2) then begin \n s1:=r1-r2;\n write(abs(s1));\n end\n else begin\n if (c1=c2)or(r1=r2) then begin\n s1:=(c2-c1)+(r2-r1);\n write(abs(s1))\n end\n else begin\n s1:=r1-r2-c2+c1;\n s2:=c2-c1;\n write(abs(s1)+abs(s2));\n end;\n end;\nend."}, {"source_code": "var\nr1,c1,r2,c2: byte;\nlad,slon,korol:byte;\n\nbegin\nread (r1,c1,r2,c2);\n\n{ход ладьи-}\nif (abs(r1-r2)>0) and (abs(c1-c2)>0) then lad:=2 \n else if (abs(r1-r2)>0) or (abs(c1-c2)>0) then lad:=1 \n else lad:=0;\nwrite(lad,' ');\n\n{ход слоном -}\nif (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs (r1-r2) = abs(c1-c2)) then slon:=1\n else slon:=2\nelse \n slon:=0; \nwrite(slon,' ');\n\n{ход королем -}\nif (r1-r2=0) then korol:=abs(c1-c2)\nelse \n if (c1-c2=0) then korol:=abs(r1-r2)\n else\n if (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(r1-r2) \n else korol:=abs(c1-c2)\n else \n korol:=abs(c1-c2)+1;\nwrite(korol,' ');\n\nend."}, {"source_code": "var\nr1,c1,r2,c2: byte;\nlad,slon,korol:byte;\n\nbegin\nread (r1,c1,r2,c2);\n\n{ход ладьи-}\nif (abs(r1-r2)>0) and (abs(c1-c2)>0) then lad:=2 \n else if (abs(r1-r2)>0) or (abs(c1-c2)>0) then lad:=1 \n else lad:=0;\nwrite(lad,' ');\n\n{ход слоном -}\nif (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs (r1-r2) = abs(c1-c2)) then slon:=1\n else slon:=2\nelse \n slon:=0; \nwrite(slon,' ');\n\n{ход королем -}\nif (r1-r2=0) then korol:=abs(c1-c2)\nelse \n if (c1-c2=0) then korol:=abs(r1-r2)\n else\n if (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(r1-r2) \n else korol:=abs(c1-c2)\n else \n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(r1-r2)+1 \n else korol:=abs(c1-c2)+1;\nwrite(korol,' ');\n\nend."}, {"source_code": "var\nr1,c1,r2,c2: byte;\nlad,slon,korol:byte;\n\nbegin\nread (r1,c1,r2,c2);\n\n{ход ладьи-}\nif (abs(r1-r2)>0) and (abs(c1-c2)>0) then lad:=2 \n else if (abs(r1-r2)>0) or (abs(c1-c2)>0) then lad:=1 \n else lad:=0;\nwrite(lad,' ');\n\n{ход слоном -}\nif (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs (r1-r2) = abs(c1-c2)) then slon:=1\n else slon:=2\nelse \n slon:=0; \nwrite(slon,' ');\n\n{ход королем -}\nif (r1-r2=0) then korol:=abs(c1-c2)\nelse \n if (c1-c2=0) then korol:=abs(r1-r2)\n else\n if (r1 mod 2 = c1 mod 2) and (r2 mod 2 = c2 mod 2) or (r1 mod 2 <> c1 mod 2) and (r2 mod 2 <> c2 mod 2) then \n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(r1-r2) \n else korol:=abs(c1-c2)\n else \n if (abs(r1-r2)>abs(c1-c2)) then korol:=abs(c1-c2)+1 \n else korol:=abs(r1-r2)+1;\nwrite(korol,' ');\n\nend."}], "src_uid": "7dbf58806db185f0fe70c00b60973f4b"} {"source_code": "program solution;\n{$APPTYPE CONSOLE}\n\nvar\n i, n, m, counter: Int64;\n\nbegin\n readln(n, m);\n counter := 0;\n if m mod n = 0 then\n begin\n if n <> m then\n begin\n m := m div n;\n while m mod 2 = 0 do\n begin\n m := m div 2; \n inc(counter);\n end;\n while m mod 3 = 0 do\n begin\n m := m div 3;\n inc(counter);\n end;\n if m = 1 then\n writeln(counter)\n else\n writeln(-1);\n end\n else\n writeln(0); \n end\n else\n writeln(-1);\nend.\n", "positive_code": [{"source_code": "var n,m,k:longint;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\nreadln(n,m);\nif n=m then begin writeln(0);halt;end;\nif n>m div 2 then begin writeln(-1);halt;end;\nif m mod n<>0 then begin write(-1);halt;end;\nm:=m div n;\nwhile m mod 3=0 do\nbegin\nm:=m div 3;\ninc(k);\nend;\nwhile m mod 2=0 do\nbegin\nm:=m div 2;\ninc(k);\nend;\nif m=1 then writeln(k) else writeln(-1);\nend.\n"}, {"source_code": "program jvr;\nuses math;\nvar\n i, a, answer, n, c, p, s, m : int64;\n ok :boolean;\nbegin\n readln(n,m);\n if (m = n) then write(0)\n else if (m mod n <> 0) then write(-1)\n else\n begin\n a := m div n;\n p := 2;\n\n ok := false;\n while (a > 1) do begin\n c := 0;\n while (a mod p = 0) do begin\n inc(c);\n a := a div p;\n end;\n if (c <> 0) then\n begin\n if (p = 2) then s := s + c;\n if (p = 3) then s := s + c;\n if (p <> 2) and (p <> 3) then ok := true;\n end;\n inc(p);\n if (p * p > a) then p :=a ;\n end;\n if (ok = false) then write(s)\n else write(-1);\n end;\n\nend.\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc(n,m:longint):longint;\n var res:longint;\n begin\n res:=0;\n if m mod n<>0 then exit(-1);\n m:=m div n;\n while m mod 3=0 do\n begin\n inc(res);\n m:=m div 3;\n end;\n while m mod 2=0 do\n begin\n inc(res);\n m:=m div 2;\n end;\n if m<>1 then exit(-1) else exit(res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var res:longint;\n begin\n read(fi,n,m);\n write(fo,calc(n,m));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "program game23;\nvar\n n,m,x:longint;\nbegin\n read(n,m);\n while(nm)then\n writeln(-1)\n else\n writeln(x);\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n n,m,min,max:longint;\n\nprocedure sc(x,num:longint);\nbegin\n\n if x=m then\n begin\n\n if min>num then min:=num;\n exit;\n\n end;\n\n if x>m then exit;\n\n sc(x*2,num+1);\n sc(x*3,num+1);\n\nend;\nbegin\n\n readln(n,m);\n min:=maxlongint;\n\n sc(n,0);\n\n if min=maxlongint then min:=-1;\n writeln(min);\n\nend.\n"}, {"source_code": "program NA3;\nvar\n n, m, i, cnt: LongInt;\n\nbegin\n ReadLn (n, m);\n\n cnt := 0;\n i := 2;\n\n while n <> 1 do\n begin\n if n mod i = 0 then\n if m mod i = 0 then\n begin\n m := m div i;\n n := n div i;\n end\n else\n begin\n WriteLn (-1);\n Exit;\n end\n else\n Inc (i)\n end;\n\n while m <> 1 do\n begin\n if m mod 2 = 0 then\n m := m div 2\n else\n if m mod 3 = 0 then\n m := m div 3\n else\n begin\n WriteLn (-1);\n Exit\n end;\n Inc (cnt)\n end;\n\n WriteLn (cnt);\nend."}, {"source_code": "//uses crt;\nconst fi='A.inp'; fo='A.out';\nvar n,m,t,s:longint;\n ok:boolean;\n\nprocedure input;\nvar f:text;\n begin\n {assign(f,fi);\n reset(f);}\n //clrscr;\n readln(n,m);\n //close(f);\n end;\n\nprocedure run;\n begin\n ok:=false;\n if m=n then\n begin\n ok:=true;\n exit;\n end;\n if m mod n<>0 then exit;\n if (m mod 2<>0) and (m mod 3<>0) then exit;\n t:=0;\n m:=m div n;\n while m mod 2=0 do\n begin\n inc(t);\n m:=m div 2;\n end;\n while m mod 3=0 do\n begin\n inc(t);\n m:=m div 3;\n end;\n if m=1 then ok:=true;\n end;\n\nprocedure output;\nvar f:text;\n begin\n {assign(f,fo);\n rewrite(f);}\n if ok then writeln(t)\n else writeln('-1');\n //readln\n //close(f);\n end;\n\nBEGIN\n input;\n run;\n output;\nEND.\n\n"}, {"source_code": " var i,j,n,m,ans:longint;\n begin\n read (n,m);\n\n if m mod n <> 0 then write (-1)\n else\n begin\n m:=m div n;\n\n\n while m mod 2 = 0 do\n begin\n m:=m div 2;\n inc (ans);\n end;\n\n while m mod 3 = 0 do\n begin\n m:=m div 3;\n inc (ans);\n end;\n\n if m=1 then write (ans)\n else write (-1);\n\n\n\n end;\n\n\n\n\n\n\n\n end."}, {"source_code": "var n,m,c: longint;\n\nprocedure backTracking(k: longint);\nvar i: longint;\nbegin\n for i:=2 to 3 do begin\n n:=n*i;\n inc(c);\n if n=m then begin\n write(c);\n halt;\n end\n else if nm div 2 then begin writeln(-1);halt;end;\nx:=m div n;\na:=x;\nk:=0;\nc:=m mod n;\nif c>0 then begin write(-1);halt;end;\nwhile a<>1 do\nbegin\n if (a mod 2<>0)and(a mod 3<>0)then begin write(-1);break;end;\n if a mod 2=0 then begin a:=a div 2;inc(k);end;\n if a mod 3=0 then begin a:=a div 3;inc(k);end;\nend;\nif a=1 then writeln(k);\nend.\n\n"}, {"source_code": "label 1;\nvar q,s,n,m:int64;\ni,d,e,r:integer;\nbegin\nr:=-1; d:=-1;\nreadln(n,m);\nif n=m then begin writeln('0');goto 1; end;\nif (n=1) and (m mod 3<>0) and (m mod 2<>0) then begin writeln('-1'); goto 1; end;\nif (m mod n=0) then begin r:=0; d:=0; end else begin writeln('-1'); goto 1; end;\ne:=m div n;\nwhile ( e mod 2=0) do \nbegin \ne:=e div 2; d:=d+1;\nend;\ne:=m div n;\nwhile ( e mod 3=0) do begin e:=e div 3; r:=r+1; end;\ns:=1; q:=1;\nfor i:=1 to d do begin s:=s*2; end;\nfor i:=1 to r do begin q:=q*3; end;\nif q*s<> m div n then writeln('-1') else writeln(r+d);\n1: end."}, {"source_code": "var m,a,n,i:integer;\nbegin\nread(n,m);\nif m=n then begin\nwrite(0);\nhalt(0);\nend;\nif (m mod n <>0)or((m mod 2 <>0) and (m mod 3<>0)) then begin\nwrite(-1);\nhalt(0);\nend;\na:=m div n;\nwhile a<>1 do begin\nif (a mod 2 <> 0) and (a mod 3 <> 0) then begin\nwrite(-1);\nhalt(0);\nend;\nif a mod 3 =0 then begin a:=a div 3;\ninc(i);\nend\nelse \nif a mod 2 =0 then begin a:=a div 2;\ninc(i);\nend;\nend;\nwrite(i);\nend."}, {"source_code": "program one;\nvar\na,b,c,k:integer;\nbegin\nreadln(a,b);\nif b mod a = 0 then\n\tbegin\n\tc:=b div a;\n while c>1 do\n begin\n if (c mod 3 = 0) and (c div 3 >= 1) then\n begin\n c:=c div 3;\n end\n else\n begin\n if (c mod 2 = 0) and (c div 2 >= 1) then\n begin\n c:=c div 2;\n end\n else\n begin\n writeln('-1');\n exit;\n end;\n end;\n k:=k+1;\n end;\n\tend\n\telse\n\tbegin\n\twriteln('-1');\n\texit;\n\tend;\nwriteln(k);\nend."}, {"source_code": "var n,m,l,k:integer;\nbegin\nread(n);read(m);\nk:=0;\nif (n > m) or (m mod n <> 0) then\n write('-1')\nelse\n begin\n if n = m then\n write('0')\n else\n begin \n l:=m div n;\n while (l>1) and ((l mod 3 = 0) or (l mod 2 = 0)) do\n begin\n k:=k+1;\n if l mod 3 = 0 then\n l:= l div 3\n else \n l:= l div 2 \n end;\n if l = 1 then\n write(k)\n else\n write('-1')\n end;\n end;\nend."}, {"source_code": "var n, m, ans, k :integer;\n\nbegin\t\n\treadln(n, m);\n\tans := 0;\n \n if m mod n > 0 then\n writeln(-1)\n else\n begin\n k := m div n;\n while k mod 3 = 0 do\n begin\n ans := ans + 1;\n k := k div 3;\n end;\n \n while k mod 2 = 0 do\n begin\n ans := ans + 1;\n k := k div 2\n end;\n \n if k = 1 then\n writeln(ans)\n else\n writeln(-1)\n end\n\n\t\nend."}, {"source_code": "var n,m,t,t1,t2,x,y:integer;\nbegin\nread(n,m);\nif m mod n>0 then begin write(-1);exit;end;\nx:=m div n;y:=1;\nwhile (x>=y*6)and(x mod (y*6)=0) do begin t+=2;y*=6;end;\nx:=x div y;y:=1;\nwhile (x>=y*2)and(x mod (y*2)=0) do begin t1+=1;y*=2;end;\nif (x mod y=0)and(x div y=1) then begin write(t+t1);exit;end;\nx:=x div y;y:=1;\nwhile (x>=y*3)and(x mod (y*3)=0) do begin t2+=1;y*=3;end;\nif (x mod y=0)and(x div y=1) then begin write(t+t2);exit;end;\nwrite(-1);\nend.\n"}, {"source_code": "var n,m,k,i:integer;\nbegin\n k:=0;\n read(n,m); \n if (m mod n <> 0 ) then\n begin\n writeln('-1');\n end else\n begin\n n:=m div n;\n while (n <> 1) and (( n mod 2 = 0) or (n mod 3 = 0)) do\n begin\n if ( n mod 2 = 0) then\n begin\n n:=n div 2;\n k:=k+1;\n end;\n if ( n mod 3 = 0) then\n begin\n n:=n div 3;\n k:=k+1;\n end; \n end;\n if (n = 1) then\n write(k) else\n write('-1');\n end;\nend."}, {"source_code": "var a,b,k,p:integer;\nbegin\nread(a,b);\nif a=b then begin\nwrite(0);\nhalt(0);\nend;\nif b mod a <> 0 then begin\nwrite(-1);\nhalt(0);\nend;\nif (b mod 2 <> 0) and (b mod 3 <>0) then begin\nwrite(-1);\nhalt(0);\nend;\nk:=b div a;\nwhile k<>1 do begin\nif (k mod 2 <>0) and (k mod 3 <> 0) then begin\nwrite(-1);\nhalt(0);\nend;\nif k mod 3 = 0 then begin\ninc(p);\nk:=k div 3\nend\nelse if (k mod 2 = 0) then begin\ninc(p);\nk:=k div 2;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "program q;\n var i,k,n,m,o:integer;\n z:real;\nbegin\n read(n,m);\n o:=1;\n z:=m/n;\n if z<>round(z) then \n k:=-1\n else begin\n if z/6=round(z/6) then\n begin\n while o<>0 do\n begin\n z:=z/6;\n if z/6<>round(z/6) then begin\n i:=i+1;\n break;exit;\n end;\n i:=i+1;\n end;\n k:=i*2;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) then begin\n k:=k;end\n else begin\n if z/2<>round(z/2) then\n begin\n while z<>1 do begin\n z:=z/3;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end\n else\n if z/3<>round(z/3) then\n begin\n while z<>1 do begin\n z:=z/2;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end;\n end;\n end\n else\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) then begin\n k:=k;end\n else begin\n if z/2<>round(z/2) then\n begin\n while z<>1 do begin\n z:=z/3;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end\n else\n if z/3<>round(z/3) then\n begin\n while z<>1 do begin\n z:=z/2;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end;\n end;\n end;\n if n=m then k:=0;\n if z<>1 then k:=-1;\n writeln(k);\nend."}, {"source_code": " var a:integer;\n b,n,m:real;\nbegin\n read(n,m);a:=0;b:=m/n;\n if b=1 then a:=0\n else begin\n if round(b)<>b then a:=-1\n else begin\n if b/6=round(b/6) then\n repeat\n b:=b/6;a:=a+2;\n until b/6<>round(b/6);\n if b/3=round(b/3) then\n repeat\n b:=b/3;a:=a+1;\n until b/3<>round(b/3);\n if b/2=round(b/2) then\n repeat\n b:=b/2;a:=a+1;\n until b/2<>round(b/2);\n if b<>1 then a:=-1;\n end;\n end;\n writeln(a);\nend."}, {"source_code": "var k,n,m:longint;\nbegin\nread(n,m);\nk:=0;\nif m mod n >0 then begin writeln(-1);exit;end;\nn:=m div n;\nwhile n>1 do\n begin\n if n mod 2=0 then n:=n div 2 else \n if n mod 3=0 then n:=n div 3 else begin writeln(-1);exit; end; \n inc(k);\n end; \n writeln(k);\n end."}, {"source_code": "var \nn,m,q,c:int64;\nbegin\n read(n, m);\n if n = m then begin write(0); halt; end;\n if n > m then begin write(-1); halt; end;\n if frac(m / n) <> 0 then begin write(-1); halt; end;\n q := m div n;\n while q mod 2 = 0 do \n begin\n inc(c);\n q := q div 2;\n end;\n \n while q mod 3 = 0 do \n begin\n inc(c);\n q := q div 3;\n end;\n if q <> 1 then begin write(-1); halt; end;\n write(c);\n \nend."}, {"source_code": " \n var\n n,m,d,count:longint;\n \n begin\n readln(n,m);\n count:=0;\n if m=n then count:=0 else\n begin\n if (m mod n = 0) and (m<>n) then \n begin\n m:=m div n;\n while (m mod 2 = 0) or (m mod 3 = 0) do\n begin\n if m mod 3 = 0 then \n begin\n m:=m div 3;\n inc(count);\n end;\n if m mod 2 = 0 then \n begin\n m:=m div 2;\n inc(count);\n end;\n end;\n end;\n end;\n if (m=1) or (m=n) then writeln(count)\n else writeln(-1);\n end.\n \n "}, {"source_code": "Var\n n, m, Ans: UInt64;\n\nBegin\n Read(n, m); \n For Var i := 0 to 28 do\n For Var j := 0 to 18 do\n If n*Round(Power(2, i))*Round(Power(3, j)) = m then Begin\n Write(i + j);\n Exit\n End;\n Write(-1)\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m, a,s, i : longint;\nbegin\n read(n, m);\n s := 0;\n if (m mod n <> 0) then\n writeln(-1)\n else\n begin\n a := m div n;\n for i := 1 to a do\n begin\n if (a = 1) then\n begin\n writeln(s);\n break;\n end\n else if (a mod 2 = 0) then\n a := a div 2\n else if (a mod 3 = 0) then\n a := a div 3\n else\n begin\n writeln(-1);\n break;\n end;\n inc(s);\n end;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "var\n n, m, x: longint;\nbegin\n read(n, m);\n if m mod n <> 0 then\n write(-1)\n else begin\n n := m div n;\n x := 0;\n while n > 1 do begin\n if n mod 2 = 0 then \n n := n div 2\n else if n mod 3 = 0 then\n n := n div 3\n else begin\n write(-1);\n halt;\n end;\n inc(x);\n end;\n write(x);\n end;\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n dd,ddr:array[-1..1502,-1..1502] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;\n dpos,sum,ppos,mma,ma:array[-1000..20005,-1..50] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,heshh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]p2 then begin writeln(-1); goto 1; end;\n if x[2]>y[2] then begin writeln(-1); goto 1; end;\n if x[3]>y[3] then begin writeln(-1); goto 1; end;\n writeln(y[2]+y[3]-(x[2]+x[3]));\n\n\n\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": "var\nn:integer;\na,b,q:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then n:=-1 else\nbegin\nq:=b div a;\nwhile q mod 3 = 0 do begin q:=q div 3; inc(n); end; \nwhile q mod 2 = 0 do begin q:=q div 2; inc(n); end; \nif q<>1 then n:=-1; \nend;\n\nwrite(n);\nend."}, {"source_code": " var\n m,n:longint;\n k,t:integer;\n Begin\n readln(n,m);\n k:=0;\n if m mod n <>0 then k:=-1;\n if (m div n=1)and(m mod n=0) then begin \n k:=0;\n t:=1;\n end;\n if (m mod n=0)and(m div n>1) then begin\n m:=m div n;\n while (m mod 3=0) do\n begin\n m:=m div 3;\n k:=k+1;\n end; \n while (m mod 2=0) do\n begin\n m:=m div 2;\n k:=k+1;\n end;\n end;\n if (m>1)and(t<>1) then k:=-1;\n writeln(k);\n End.\n \n "}, {"source_code": "Program ILoveYou;\nVAR n,m,k:int64; b:boolean;\nBegin\n\nReadln(n,m);\n\nif ((m mod n) <> 0) then Writeln('-1') else\nBegin\n\nm:=m div n;\nwhile ((m mod 2) = 0) and (m > 1) do\nBegin\nk:=k + 1;\nm:=m div 2;\nend;\n\nwhile ((m mod 3) = 0) and (m > 1) do\nBegin\nk:=k + 1;\nm:=m div 3;\nend;\n\nif (m = 1) then Writeln(k) else Writeln('-1');\n\nend;\n\n\nReadln;\nEND."}, {"source_code": "var\n n, m, an, z: uint64;\n\nbegin\n read(n, m);\n if n = m then\n write(0)\n else\n if (n = 1) and ((m mod 2 <> 0) and (m mod 3 <> 0)) then\n write(-1)\n else\n if m mod n <> 0 then\n write(-1)\n else\n begin\n z := m div n;\n while z mod 2 = 0 do\n begin\n z := z div 2;\n an := an + 1;\n end;\n while z mod 3 = 0 do\n begin\n z := z div 3;\n an := an + 1;\n end;\n if z = 1 then\n write(an)\n else\n write(-1);\n end;\nend."}, {"source_code": "var n, m, a, i:longint; n1, m1:real; LABEL j;\nbegin\nreadln(n, m);\nn1:=n;\nm1:=m;\nif m=n then begin writeln(0); goto j end;\nif (m div n) = (m1/n1) then begin\n a:=m div n;\n while (a>3) do begin\n if (a mod 3 = 0) then a:=a div 3\n else if (a mod 2 = 0) then a:=a div 2\n else begin writeln(-1); goto j end;\n i:=i+1;\n end;\n writeln(i+1);\nend else writeln(-1);\nj:\nend."}, {"source_code": "var \n a, b, res : integer;\n \nbegin\n readln(a, b);\n res:= 0;\n if (b mod a <> 0) then\n res:= -1\n else\n begin\n b:= b div a;\n while (b mod 3 = 0) do\n begin\n inc(res);\n b:= b div 3;\n end;\n while (b mod 2 = 0) do\n begin\n inc(res);\n b:= b div 2;\n end;\n end;\n if b = 1 then writeln(res)\n else writeln('-1');\n end.\n "}, {"source_code": "var n,m,x,j : integer;\nbegin\n read(n,m);\n x := 0;\n j := m div n;\n if n=m then write(0)\n else if m mod n <> 0 then write('-1')\n else if (j mod 2 <> 0) and (j mod 3 <> 0) then write('-1')\n else\n begin\n while j mod 2 = 0 do\n begin\n inc(x);\n j := j div 2;\n end;\n while j mod 3 = 0 do\n begin\n inc(x);\n j := j div 3;\n end;\n if j = 1 then write(x)\n else write (-1);\nend;\nend."}, {"source_code": "var n,m,dem:int64;\nbegin\n readln(n,m);\n while (n < m) do\n begin\n if (m div n) mod 3 = 0 then n:=n*3\n else n:=n*2;\n inc(dem);\n end;\n if n <> m then writeln(-1)\n else writeln(dem);\n readln;\nend."}, {"source_code": "var\n ans, n, m: longint;\n\nbegin\n ans:= 0;\n readln(n, m);\n if (m / n) = round(m div n) then begin\n while (m>n) and (((m div n) mod 3 = 0) or ((m div n) mod 2 = 0)) do begin\n if (m div n) mod 3 = 0 then n:= n * 3\n else if (m div n) mod 2 = 0 then n:= n * 2;\n\n ans:= ans+1;\n end;\n\n if m <> n then begin\n writeln('-1');\n end\n else writeln(ans);\n\n\n\n end\n else begin\n writeln('-1');\n end;\nend.\n\n"}, {"source_code": "Var n,k,x,ans,m,f : Int64;\n begin\n Readln(n,m);\n if m mod n <> 0 then f:=1\n else begin\n k:= m div n;\n while k>1 do\n if k mod 3 = 0 then begin\n k:= k div 3;\n inc(ans);\n end\n else\n if k mod 2 = 0 then begin\n k:= k div 2;\n inc(ans);\n end\n else begin\n f:=1;\n Break;\n end;\n end;\n if f = 1 then writeln(-1)\n else writeln(ans);\n\nend.\n"}, {"source_code": "var\n kol_step : longint;\n flag : boolean;\nprocedure kol_del(ch , res,step : longint);\nbegin\n if ch = res then\n begin\n flag := true;\n kol_step := step;\n end\n else\n if (ch < res) and (not flag) then\n begin\n kol_del(ch * 2, res, step+1);\n kol_del(ch * 3,res,step+1);\n end;\nend;\n\nvar\n ch1 , ch2 : longint;\nbegin\n read(ch1,ch2);\n kol_del(ch1,ch2,0);\n if flag then\n begin\n write(kol_step)\n end\n else\n write(-1);\nend."}, {"source_code": "var n,m,dem:int64;\nprocedure nhap;\nbegin\n read(m,n);\nend;\nfunction phantich(a:int64;b:int64):boolean;\nvar i:integer;\nbegin\n i:=2;\n if b mod a <>0 then\n exit(FALSE)\n else\n begin\n b:=b div a;\n while b mod 2 =0 do\n begin\n b:=b div 2;\n dem:=dem+1;\n end;\n while b mod 3 =0 do\n begin\n b:=b div 3;\n dem:=dem+1;\n end;\n if b>1 then\n exit(FALSE)\n else\n exit(TRUE);\n\n end;\n\nend;\nprocedure xuli;\nbegin\n dem:=0;\n if (n0 then\n begin\n write(-1);exit;\n end;\nm:=trunc(m/n);i:=0;\nwhile m mod 2=0 do\n begin\n i:=i+1;m:=trunc(m/2);\n end;\nwhile m mod 3=0 do\n begin\n i:=i+1;m:=trunc(m/3);\n end;\nif m<>1 then\n begin\n write(-1);exit;\n end\nelse write(i);\nend.\n"}, {"source_code": "var n,m,s:int64;\nbegin\n\treadln (n,m);\n\tif (m mod n <> 0) then writeln (-1)\n else begin\n \ts:=0;\n m := m div n;\n while (m mod 3 = 0) do\n begin\n \tm := m div 3;\n inc (s);\n end;\n while (m mod 2 = 0) do\n begin\n \tm := m div 2;\n inc (s);\n end;\n //writeln (m);\n if (m <> 1) then writeln (-1) else \n writeln (s);\n end;\n \nend."}, {"source_code": "var m,n,k,f:longint;\nbegin\n read(n,m);\n k:=0;\n if m mod n > 0 then write(-1) else \n begin\n m:= m div n;\n while m mod 3 =0 do begin inc(k);m:=m div 3; end;\n while m mod 2 =0 do begin inc(k);m:=m div 2;\n end;\n if m=1 then write(k) else write(-1)\n end; \nend. "}, {"source_code": "var a, b, c:LongInt;\nbegin\nread(a, b);\nc:=0;\nif b mod a <> 0 then\nbegin\n write(-1);\n Exit();\nend;\na := b div a;\nwhile a mod 2 = 0 do\nbegin\n a := a div 2;\n inc(c);\nend;\nwhile a mod 3 = 0 do\nbegin\n a := a div 3;\n inc(c);\nend;\nif a=1 then write(c)\nelse write(-1);\nend."}, {"source_code": "Var x, y, z, f:int64;\nbegin\n Read(x, y) ;\n If x=y then begin Writeln('0');exit;end;\n If y mod x>0 then begin writeln('-1');exit;end;\n If ((y mod 2>0) and (y mod 3>0)) and (y<>1)then begin writeln('-1');exit;end; \n Z:=y div x;\n Repeat\n If z mod 3 = 0 then begin\n Z:=z div 3;\n F:=f+1;\n End;\n If z mod 2 = 0 then begin\n Z:=z div 2;\n F:=f+1;\n End;\n If (z mod 2>0)and(z mod 3>0) and(z<>1) then begin writeln('-1');exit;end;\n Until z = 1;\n Writeln(f);\nend.\n"}, {"source_code": "var\n n, m, i, x: integer;\n\nbegin\n read(n, m);\n i := 0;\n if m mod n <> 0 then begin\n write(-1);\n exit\n end;\n x := m div n;\n while (x mod 2 = 0) or (x mod 3 = 0) do \n begin\n if (x mod 2 = 0) then\n x := x div 2\n else\n x := x div 3;\n i := i + 1;\n end;\n if (x = 1) then \n write(i)\n else\n write(-1);\nend."}, {"source_code": "\nvar\n k,n,m,q: integer;\nbegin\nread(n,m);\nif m mod n<>0 then begin print(-1); exit; end; \nk:=m div n; \nwhile k mod 3=0 do begin k:=k div 3; inc(q); end; \nwhile k mod 2=0 do begin k:=k div 2; inc(q); end;\nif k=1 then print(q) else print(-1);\nend. "}, {"source_code": "var n,m,dv,t:integer;\nBegin\n readln(n,m);\n dv:=m div n;\n if m mod n <> 0 then writeln(-1)\n else\n Begin\n while dv mod 2 = 0 do begin dv:= dv div 2; t+=1; end;\n while dv mod 3 = 0 do begin dv:= dv div 3; t+=1; end;\n if dv = 1 then writeln(t) else writeln(-1);\n End;\nEnd."}, {"source_code": "var ans,n,m,m1:integer;\nbegin\nreadln(n,m);\nif (m mod n = 0) then\n m1:=m div n\nelse begin\n writeln(-1);\n exit;\nend;\n\nwhile (m1 <> 1) do\n if (m1 mod 2 = 0) then begin\n m1:=m1 div 2;\n inc(ans);\n end\n else \n if (m1 mod 3 = 0) then begin\n m1:= m1 div 3;\n inc(ans);\n end\n else begin \n writeln(-1);\n exit;\n end;\nwriteln(ans);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,m,s,d:int64;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);\n\n assign(f,fo);rewrite(f);\n s:= m div n;\n if s * n <> m then write(f,-1)\n else\n if s=1 then write(f,0)\n else\n begin\n while (s <> 1) do\n begin\n if s mod 3 = 0 then\n begin\n inc(d);\n s:=s div 3;\n end\n else\n if s mod 2 = 0 then\n begin\n inc(d);\n s:=s div 2;\n end;\n if (s mod 2 <> 0 ) and (s mod 3 <> 0) and (s <> 1) then\n begin\n d:=-1;\n break;\n end;\n end;\n write(f,d);\n end;\n close(f);\nend.\n\n"}, {"source_code": "uses math;\nvar\n n,m,s,k : longint;\nbegin\n readln(n,m);\n if m mod n > 0 then\n begin writeln(-1); halt; end;\n m := m div n;\n while 2**s <= m do begin\n k:=0;\n while 2**s * 3**k < m do\n k += 1;\n if 2**s * 3**k = m then begin\n writeln(s+k);\n halt;\n end;\n s += 1;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var\n f,m,n,ans : longint;\nbegin\n readln(n,m); f := m div n;\n if m mod n > 0 then begin write(-1); halt; end;\n while f mod 2 = 0 do begin ans += 1; f := f div 2; end;\n while f mod 3 = 0 do begin ans += 1; f := f div 3; end;\n if f > 1 then ans := -1; write(ans);\nend."}, {"source_code": "Var n,m,rem,count:Longint;\nBegin\n Readln(n,m);\n If m mod n <> 0 then writeln(-1)\n Else begin\n rem:=m div n; \n While rem mod 2 = 0 do begin\n inc(count); rem:=rem div 2;\n End;\n While rem mod 3 = 0 do begin\n inc(count); rem:=rem div 3;\n End;\n If rem=1 then writeln(count) else writeln(-1);\n End;\nEnd."}, {"source_code": "program ProblemA;\nvar a,b:longint;\n res:longint;\nbegin\n read(a,b);\n if b mod a <> 0 then\n begin\n write(-1);\n exit;\n end;\n a:=b div a;\n res:=0;\n while a mod 2 = 0 do\n begin\n a:=a div 2;\n inc(res);\n end;\n\n while a mod 3 = 0 do\n begin\n a:=a div 3;\n inc(res);\n end;\n if a=1 then write(res) else write(-1);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n m,n,kq,count,count1:longint;\nprocedure inp;\nbegin\n assign(f,fi);\n reset(f);\n read(f,n,m);\n close(f);\nend;\n\nprocedure solve;\nbegin\n if (m mod n<>0) then count:=-1\n else\n begin\n kq:=m div n;\n While (kq mod 2=0) do\n begin\n kq:=kq div 2;\n inc(count);\n end ;\n While (kq mod 3=0) do\n begin\n kq:=kq div 3;\n inc(count);\n end;\n end;\n if (kq<>1) then count:=-1;\nend;\nprocedure output;\nbegin\n assign(g,fo);\n rewrite(g);\n writeln(g,count);\n close(g);\nend;\n\nbegin\n inp;\n solve;\n output;\nend."}, {"source_code": "program coba;\n\nvar\n\tn,m,x,y : longint;\nbegin\n\tn := 0;\n\tm := 0;\n\treadln(n,m);\n\t{writeln(n, ' dan ', m);}\n\tif (m mod n = 0) then begin\n\t\tn := m div n;\n\t\tx := 0;\n\t\ty := 0;\n\t\twhile (n mod 2 = 0) do begin\n\t\t\tn := n div 2;\n\t\t\tx := x + 1;\n\t\tend; \n\t\t\n\t\twhile (n mod 3 = 0) do begin\n\t\t\tn := n div 3;\n\t\t\ty := y + 1;\n\t\tend;\n\n\t\tif (n = 1) then begin\n\t\t\twriteln(x+y);\n\t\tend else begin\n\t\t\twriteln(-1);\n\t\tend;\n\tend else begin\n\t\twriteln(-1);\n\tend;\n\t\n\nend.\n"}, {"source_code": "var n,m,k,x,a,f,c:longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(n,m);\nif n=m then begin write(0);halt;end;\nif n>m div 2 then begin write(-1);halt;end;\nx:=m div n;\na:=x;\nk:=0;\nc:=m mod n;\nif c>0 then begin write(-1);halt;end;\nwhile a<>1 do\n begin\n if (a mod 2<>0) and (a mod 3<>0) then begin write(-1);break;end;\n if a mod 2=0 then begin a:=a div 2;k:=k+1;end;\n if a mod 3=0 then begin a:=a div 3;k:=k+1;end;\n\n end;\nif a=1 then write(k);\nend.\n\n"}, {"source_code": "var a,b:longint;\nbest:integer;\nprocedure ok(cur, pts:longint);\nbegin\n if cur=b then begin\n if (best=-1) or (best>pts) then best:=pts;\n end else if cur0 then begin writeln(-1);halt;end;\n\nx:=b div a;\n\nwhile x>1 do\nif x mod 2=0 then begin x:=x div 2; inc(k); end\n else if x mod 3=0 then begin x:=x div 3; inc(k); end\n else begin writeln(-1);halt;end;\n\nwriteln(k);\n\nend."}, {"source_code": "const fi='input.txt';\n fo='output.txt';\nvar a:array[1..100005,1..2] of longint;\n res,n,m:longint;\n\nfunction Xuli:longint;\nvar i,countn,countm:longint;\nBegin\n for i:=2 to trunc(sqrt(m)) do begin\n countn:=0; countm:=0;\n while (n mod i=0) or (m mod i=0) do begin\n if ((i=2) or (i=3)) and (n mod i=0) then inc(countn);\n if ((i=2) or (i=3)) and (m mod i=0) then inc(countm);\n if (i<>2) and (i<>3) and ((n mod i<>0) or (m mod i<>0)) then exit(-1);\n if n mod i=0 then n:=n div i;\n if m mod i=0 then m:=m div i;\n end;\n if (i=2) or (i=3) then if countm>=countn then res:=res+countm-countn else exit(-1);\n end;\n if (n=1) and ((m=2) or (m=3)) then exit(res+1);\n if (n<>m) then exit(-1);\n exit(res);\nEnd;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n\n read(n,m);\n write(Xuli);\n\n //close(input);\n //close(output);\nEND.\n\n"}, {"source_code": "var\n a,b,c,n : longint;\nbegin\n readln(a,b);\n if (b mod a <> 0) then\n begin\n writeln(-1);\n exit;\n end;\n c := b div a;\n while (c > 1) do\n begin\n if (c mod 2 <> 0)and(c mod 3 <> 0) then\n break;\n if (c mod 2 = 0) then\n begin\n c := c div 2;\n inc(n);\n end;\n if (c = 0) then\n break;\n if (c mod 3 = 0) then\n begin\n c := c div 3;\n inc(n);\n end;\n end;\n if (c = 1) then\n writeln(n)\n else\n writeln(-1);\nend."}, {"source_code": "var\n n,m,a : real;\n b,kol : longint;\nbegin\n read(n,m);\n a:=m/n;\n b:=trunc(a);\n if trunc(m) mod trunc(n) <> 0 then begin write('-1'); halt; end;\n while (b mod 2 = 0) or (b mod 3 = 0) do\n begin\n if b mod 2 = 0 then begin b:=b div 2; inc(kol); end\n else if (b mod 3 = 0) then begin b:=b div 3; inc(kol); end;\n end;\n if b <> 1 then write('-1')\n else write(kol);\n\nend."}, {"source_code": "var\n\tm,n,k,rez:longint;\n\nfunction nod(m,n:longint):longint;\nbegin\n\twhile m<>n do\n\tbegin\n\t\tif m>n then\n\t\t\tm:=m-n\n\t\telse n:=n-m;\n\tend;\n\tnod:=m;\nend;\n\nbegin\n\tread(m,n);\n\tk:=nod(m,n);\n\trez:=-1;\n\tif k=m then begin\n\t\tn:=n div k;\n\t\trez:=0;\n\t\twhile (n>1) and ((n mod 2 =0) or (n mod 3 =0)) do\n\t\tbegin\n\t\t\tif n mod 2 =0 then \n\t\t\tbegin\n\t\t\t\tn:=n div 2;\n\t\t\t\trez+=1;\n\t\t\tend;\n\t\t\tif n mod 3 =0 then \n\t\t\tbegin\n\t\t\t\tn:=n div 3;\n\t\t\t\trez+=1;\n\t\t\tend;\n\t\tend;\n\tend;\n\tif n=1 then\n\t\twriteln(rez)\n\telse writeln(-1);\nend.\n"}, {"source_code": "var\nn,m,kol:int64;\nbegin\nreadln(n,m);\nif m mod n<>0 then writeln(-1)\nelse begin\n m:=m div n;\n while m mod 2 =0 do begin\n m:=m div 2;\n inc(kol);\n end;\n while m mod 3=0 do begin\n m:=m div 3;\n inc(kol);\n end;\n if m<>1 then writeln(-1)\n else\n writeln(kol);\nend;\nend."}, {"source_code": "var a,b,kq,c,i :longint;\nBEGIN\n read(a,b); kq:=0;\n if b mod a <>0 then kq:=-1;\n if a=b then kq:=0;\n if b mod a=0 then\n begin\n c:=b div a; i:=2;\n while c<>1 do\n begin\n while c mod i=0 do begin c:=c div i; inc(kq); end;\n inc(i);\n if i>4 then begin kq:=-1; break; end;\n end;\n end;\n write(kq);\nEND."}, {"source_code": "function count_moves(n,m:longint):longint;\nvar d,k:longint;\nbegin\n d:= m div n;\n k:=0;\n while d mod 2 = 0 do begin\n d:=d div 2;\n inc(k);\n end;\n while d mod 3 = 0 do begin\n d:=d div 3;\n inc(k);\n end; \n if d = 1 then\n count_moves:=k\n else\n count_moves:=-1;\nend;\n\nvar n,m:longint;\nbegin\n read(n,m);\n if m mod n <> 0 then\n writeln('-1')\n else\n writeln(count_moves(n,m));\nend."}, {"source_code": "var n,m,k:longint;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n // reset(input);\n //rewrite(output);\n read(n,m);\n if n=m then begin writeln(0);halt;end;\n if m mod n <>0 then begin write(-1);halt;end;\n n:=m div n;\n while n mod 3=0 do\n begin\n n:=n div 3;\n inc(k);\n end;\n while n mod 2 =0 do\n begin\n n:=n div 2;\n inc(k);\n end;\n if n<>1 then write(-1) else write(k);\nend.\n"}, {"source_code": "var n,m,k:longint;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\nread(n,m);\nif m mod n<>0 then begin write(-1);halt;end;\nn:=m div n;\nwhile n mod 3=0 do begin\ninc(k);n:=n div 3;end;\nwhile n mod 2=0 do begin\ninc(k);n:=n div 2;end;\nif n<>1 then write(-1) else write(k);\nend.\n"}, {"source_code": "var\n n,m,ans,fofifka : longint;\nbegin\n read(n,m);\n if m mod n > 0 then\n begin\n write(-1);\n halt;\n end;\n fofifka:=m div n;\n while fofifka mod 2 = 0 do begin\n inc(ans);\n fofifka:=fofifka div 2;\n end;\n while fofifka mod 3 = 0 do begin\n inc(ans);\n fofifka:=fofifka div 3;\n end;\n if fofifka = 1 then write(ans)\n else write(-1);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n m,n,kq,count,count1:longint;\nprocedure inp;\nbegin\n assign(f,fi);\n reset(f);\n read(f,n,m);\n close(f);\nend;\n\nprocedure solve;\nbegin\n if (m mod n<>0) then count:=-1\n else\n begin\n kq:=m div n;\n While (kq mod 2=0) do\n begin\n kq:=kq div 2;\n inc(count);\n end ;\n While (kq mod 3=0) do\n begin\n kq:=kq div 3;\n inc(count);\n end;\n end;\n if (kq<>1) then count:=-1;\nend;\nprocedure output;\nbegin\n assign(g,fo);\n rewrite(g);\n writeln(g,count);\n close(g);\nend;\n\nbegin\n inp;\n solve;\n output;\nend.\n"}, {"source_code": "var a,b:longint;d:array [1..2] of longint;\nbegin\n readln(a,b);\n if (b mod a<>0)or(b1 do begin\n if b mod 2=0 then begin\n b:=b div 2;\n inc(d[1]);\n end\n else if b mod 3=0 then begin\n b:=b div 3;\n inc(d[2]);\n end\n else begin\n writeln(-1);\n exit;\n end;\n end;\n writeln(d[1]+d[2]);\n end;\n end;\nend."}, {"source_code": "const fi='1141A.inp';\n fo='1441A.OUT';\n var f:text ; n,m,dem2,dem3,s2m,s3m,s2n,s3n:longint;\n\n procedure nhap;\n begin\n // assign(f,fi);\n // reset(F);\n readln({f,}n,m);\n // close(f);\n end;\n\n procedure demsocua(x:longint) ;\n begin\n dem2:=0;\n dem3:=0;\n while( x mod 3 =0 )and(n>0) do\n begin\n inc(dem3);\n x:=x div 3 ;\n end;\n\n while( x mod 2 =0 )and(n>0) do\n begin\n inc(dem2);\n x:=x div 2 ;\n end;\n if x<= 1 then s3n :=1;\n\n\n end;\n\n procedure xuli;\n begin\n // demsocua(n);\n // s2n:=dem2;\n // s3n:=dem3;\n demsocua(m div n );\n s2m:=dem2;\n s3m:= dem3;\n s2n:=0;\n s2m:=s2m{-s2n};\n s3m:=s3m{-s2n};\n if (s2m+s3m =0 )and( n =m) then s2n:=1;\n end;\n\n procedure xuat;\n begin\n // assign(f,fo);\n // rewrite(F);\n if s2n=1 then writeln({f,}0)else\n\n if(s3n=1 )and(m mod n=0) and((m div n mod 2 =0) or( m div n mod 3 =0)) then writeln({f,}s2m+s3m)\n\n else\n begin\n\n\n writeln({f,}-1);\n end;\n// close(F);\n end;\n\n begin\n nhap;\n xuli;\n xuat;\n end.\n\n\n"}, {"source_code": "var a,b:longint;\n res:longint;\nbegin\n read(a,b);\n if b mod a <> 0 then\n begin\n write(-1);\n exit;\n end;\n a:=b div a;\n res:=0;\n while a mod 2 = 0 do\n begin\n a:=a div 2;\n inc(res);\n end;\n \n while a mod 3 = 0 do\n begin\n a:=a div 3;\n inc(res);\n end;\n if a=1 then write(res) else write(-1);\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else \n begin\n x:=m div n;\n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n if x = 1 then writeln(dem) else write(-1);\n end;\nend."}, {"source_code": "program game23;\nvar\nn,m,i,d,way:longint;\nbegin\n readln(n,m);\n if m mod n <>0 then\n begin\n writeln(-1);\n halt(0);\n end;\n d:=m div n;\n i:=2;\n way:=0;\n while (i<=3) and (d>1) do\n begin\n if d mod i=0 then\n begin\n d:=d div i;\n inc(way);\n end\n else inc(i);\n end;\n if d=1 then writeln(way)\n else writeln(-1);\nend."}, {"source_code": "const fi='1141A.inp';\n fo='1141A.out';\nvar n,m,s:int64;\n x:array[0..10000001] of longint;\nprocedure nhap;\n begin\n read(n,m);\n s:=n;\n end;\nprocedure chinhhoplap(i:longint);\nvar j:longint;\n begin\n for j:=2 to 3 do\n begin\n x[i]:=j;\n s:=s*x[i];\n if s=m then\n begin\n write(i);\n halt;\n end;\n if s m) then\n\tbegin\n\t\twriteln (-1);\n\tend else\n\tbegin\n\t\tif (m mod n <> 0) then\n\t\tbegin\n\t\t\twriteln (-1);\n\t\tend else\n\t\tbegin\n\t\t\tfaktor := m div n;\n\t\t\tans := 0;\n\t\t\tfor i := 2 to 3 do\n\t\t\tbegin\n\t\t\t\twhile (faktor mod i = 0) do\n\t\t\t\tbegin\n\t\t\t\t\tfaktor := faktor div i;\n\t\t\t\t\tinc (ans);\n\t\t\t\tend;\n\t\t\tend;\n\t\t\tif (faktor > 1) then\n\t\t\tbegin\n\t\t\t\twriteln (-1);\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln (ans);\n\t\t\tend;\n\t\tend;\n\tend;\nend."}], "negative_code": [{"source_code": "label 1;\nvar n,m:int64;\ne,r:integer;\nbegin\nr:=-1;\nreadln(n,m);\nif n=m then begin writeln('0');goto 1; end;\nif (n=1) and (m mod 3<>0) and (m mod 2<>0) then begin writeln('-1'); goto 1; end;\nif (m mod n=0) then r:=0 else begin writeln('-1'); goto 1; end;\ne:=m div n;\nwhile ( e mod 2=0) do \nbegin \ne:=e div 2; r:=r+1;\nend;\ne:=m div n;\nwhile ( e mod 3=0) do begin e:=e div 3; r:=r+1; end;\nwriteln(r);\n1: end."}, {"source_code": "label 1;\nvar n,m:int64;\ne,r:integer;\nbegin\nr:=-1;\nreadln(n,m);\nif (n=1) and (m mod 3<>0) and (m mod 2<>0) then begin writeln('-1'); goto 1; end;\nif n=m then begin writeln('0');goto 1; end;\nif (m mod n=0) then r:=0 else begin writeln('-1'); goto 1; end;\ne:=m div n;\nwhile ( e mod 2=0) do \nbegin \ne:=e div 2; r:=r+1;\nend;\ne:=m div n;\nwhile ( e mod 3=0) do begin e:=e div 3; r:=r+1; end;\nwriteln(r);\n1: end."}, {"source_code": "label 1;\nvar q,s,n,m:int64;\ni,d,e,r:integer;\nbegin\nr:=-1; d:=-1;\nreadln(n,m);\nif n=m then begin writeln('0');goto 1; end;\nif (n=1) and (m mod 3<>0) and (m mod 2<>0) then begin writeln('-1'); goto 1; end;\nif (m mod n=0) then begin r:=0; d:=0; end else begin writeln('-1'); goto 1; end;\ne:=m div n;\nwhile ( e mod 2=0) do \nbegin \ne:=e div 2; d:=d+1;\nend;\ne:=m div n;\nwhile ( e mod 3=0) do begin e:=e div 3; r:=r+1; end;\ns:=1; q:=1;\nfor i:=1 to d do begin s:=s*2; end;\nfor i:=1 to r do begin q:=q*3; end;\nif q+s<>m then writeln('-1') else writeln(r+d);\n1: end."}, {"source_code": "label 1;\nvar n,m:int64;\ne,r:integer;\nbegin\nr:=-1;\nreadln(n,m);\nif n=m then begin writeln('0');goto 1; end;\nif (m mod n=0) then r:=0 else begin writeln('-1'); goto 1; end;\ne:=m div n;\nwhile ( e mod 2=0) do \nbegin \ne:=e div 2; r:=r+1;\nend;\ne:=m div n;\nwhile ( e mod 3=0) do begin e:=e div 3; r:=r+1; end;\nwriteln(r);\n1: end."}, {"source_code": "var m,a,n,i:integer;\nbegin\nread(n,m);\nif (m mod n <>0)or((m mod 2 <>0) and (m mod 3<>0)) then begin\nwrite(-1);\nhalt(0);\nend;\nif m=n then begin\nwrite(0);\nhalt(0);\nend;\na:=m div n;\nwhile a<>1 do begin\nif a mod 3 =0 then begin a:=a div 3;\ninc(i);\nend\nelse \nif a mod 2 =0 then begin a:=a div 2;\ninc(i);\nend;\nend;\nwrite(i);\nend."}, {"source_code": "var n,sum:int64;\n k:integer;\n n_str,sum_str:string;\nbegin\nreadln(n);\nn_str:=IntToStr(n);\nsum:=0;\nfor var i:=1 to length(n_str) do\n begin\n if (n_str[i] = '4') or (n_str[i] = '7') then\n sum:=sum+StrToInt(n_str[i])\n end;\nif sum = 0 then \n begin\n writeln('NO');\n exit;\n end;\nsum_str:=IntToStr(sum);\nk:=0;\nfor var i:=1 to length(sum_str) do\n begin\n if (n_str[i] = '4') or (n_str[i] = '7') then\n K:=k+1\n end;\nif k = length(sum_str) then\n writeln('YES')\nelse\n writeln('NO')\nend."}, {"source_code": "begin\n\tvar n, m, ans:integer;\n\treadln(n, m);\n\tans := 0;\n\n\twhile m mod 3 = 0 do\n\tbegin\n\t\tans += 1;\n\t\tm := m div 3;\n\tend;\n\n\twhile m mod 2 = 0 do\n\tbegin\n\t\tans += 1;\n\t\tm := m div 2;\n\tend;\n\n\twhile n mod 3 = 0 do\n\tbegin\n\t\tans -= 1;\n\t\tn := n div 3;\n\tend;\n\n\twhile n mod 2 = 0 do\n\tbegin\n\t\tans -= 1;\n\t\tn := n div 2;\n\tend;\n\n\tif n <> m then\n\t\tans := -1;\n\n\twriteln(ans);\nend."}, {"source_code": "var a,b,k,p:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then begin\nwrite(-1);\nhalt(0);\nend;\nif (b mod 2 <> 0) and (b mod 3 <>0) and (a<>b) then begin\nwrite(-1);\nhalt(0);\nend;\nk:=b div a;\nwhile k<>1 do begin\nif k mod 3 = 0 then begin\ninc(p);\nk:=k div 3\nend\nelse begin\ninc(p);\nk:=k div 2;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var a,b,k,p:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then begin\nwrite(-1);\nhalt(0);\nend;\nif (b mod 2 <> 0) and (b mod 3 <>0) then begin\nwrite(-1);\nhalt(0);\nend;\nk:=b div a;\nwhile k<>1 do begin\nif k mod 3 = 0 then begin\ninc(p);\nk:=k div 3\nend\nelse begin\ninc(p);\nk:=k div 2;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var a,b,k,p:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then begin\nwrite(-1);\nhalt(0);\nend;\nk:=b div a;\nwhile k<>1 do begin\nif k mod 3 = 0 then begin\ninc(p);\nk:=k div 3\nend\nelse begin\ninc(p);\nk:=k div 2;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var a,b,k,p:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then begin\nwrite(-1);\nhalt(0);\nend;\nk:=b div a;\nwhile k<>0 do begin\nif k mod 3 = 0 then begin\ninc(p);\nk:=k div 3\nend\nelse begin\ninc(p);\nk:=k div 2;\nend;\nend;\nwrite(p-1);\nend."}, {"source_code": "var k,n,m:longint;\nbegin\nread(n,m);\nk:=0;\nif m mod n >0 then begin writeln(-1);exit;end;\nn:=m div n;\nwhile n>1 do\n begin\n if n mod 2=0 then n:=n div 2 else n:=n div 3;\n inc(k);\n end; \n writeln(k);\n end."}, {"source_code": " \n var\n n,m,count:longint;\n \n begin\n readln(n,m);\n count:=0;\n if (m mod n = 0) then \n begin\n m:=m div n;\n while m mod 3 = 0 do\n begin\n m:=m div 3;\n inc(count);\n end;\n while m mod 2 = 0 do\n begin\n m:=m div 2;\n inc(count);\n end;\n end\n else count:=-1;\n if m=n then count:=0;\n writeln(count);\n end.\n \n "}, {"source_code": "Var\n n, m, Ans: UInt64;\n\nBegin\n Read(n, m); \n For Var i := 1 to 28 do\n For Var j := 1 to 18 do\n If n*Round(Power(2, i))*Round(Power(3, j)) = m then Begin\n Write(i + j);\n Exit\n End;\n Write(-1)\nEnd.\n"}, {"source_code": "var\na,b,q,n:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then n:=-1 else\nbegin\nq:=b div a;\nwhile q<>1 do begin\nif q mod 3 = 0 then q:=q div 3;\nif q mod 2 = 0 then q:=q div 2 else begin n:=-1; break; end;\ninc(n);\nend;\nend;\nwrite(n);\nend."}, {"source_code": "var\na,b,q,n:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then n:=-1 else\nbegin\nq:=b div a;\nwhile q<>1 do begin\nif q mod 3 = 0 then q:=q div 3 else q:=q div 2;\ninc(n);\nend;\nend;\nwrite(n);\nend."}, {"source_code": "var\na,b,q,n:integer;\nbegin\nread(a,b);\nif b mod a <> 0 then n:=-1 else\nbegin\nq:=b div a;\nwhile q<>1 do begin\nif q mod 3 = 0 then q:=q div 3;\nif q mod 2 = 0 then q:=q div 2;\nif (q mod 3 <>0 ) and (q mod 2 <> 0) then begin n:=-1; break; end;\ninc(n);\nend;\nend;\nwrite(n);\nend."}, {"source_code": " var\n m,n:longint;\n k:integer;\n Begin\n readln(n,m);\n k:=0;\n if m mod n <>0 then k:=-1;\n if (m div n=1)and(m mod n=0) then k:=0;\n if (m mod n=0)and(m div n>1) then begin\n m:=m div n;\n while (m mod 3=0) do\n begin\n m:=m div 3;\n k:=k+1;\n end; \n while (m mod 2=0) do\n begin\n m:=m div 2;\n k:=k+1;\n end;\n end;\n if m>1 then k:=-1;\n writeln(k);\n End.\n \n "}, {"source_code": " var\n m,n:longint;\n k:integer;\n Begin\n readln(n,m);\n k:=0;\n if m mod n <>0 then k:=-1;\n if (m div n=1)and(m mod n=0) then k:=0;\n if (m mod n=0)and(m div n>1) then begin\n m:=m div n;\n while (m mod 3=0) do\n begin\n m:=m div 3;\n k:=k+1;\n end; \n while (m mod 2=0) do\n begin\n m:=m div 2;\n k:=k+1;\n end;\n end;\n writeln(k);\n End.\n \n "}, {"source_code": "var\n n, m, an, z: uint64;\n\nbegin\n read(n, m);\n if n = m then\n write(0)\n else\n if m mod n <> 0 then\n write(-1)\n else\n begin\n z := m div n;\n while z mod 2 = 0 do\n begin\n z := z div 2;\n an := an + 1;\n end;\n while z mod 3 = 0 do\n begin\n z := z div 3;\n an := an + 1;\n end;\n write(an);\n end;\nend."}, {"source_code": "var\n n, m, an, z: uint64;\n\nbegin\n read(n, m);\n if n = m then\n write(0)\n else\n if (n = 1) and ((m mod 2 <> 0) and (m mod 3 <> 0)) then\n write(-1)\n else\n if m mod n <> 0 then\n write(-1)\n else\n begin\n z := m div n;\n while z mod 2 = 0 do\n begin\n z := z div 2;\n an := an + 1;\n end;\n while z mod 3 = 0 do\n begin\n z := z div 3;\n an := an + 1;\n end;\n if z = 0 then\n write(an)\n else\n write(-1);\n end;\nend."}, {"source_code": "var\n n, m, an, z: uint64;\n\nbegin\n read(n, m);\n if n = m then\n write(0)\n else\n if (n = 1) and ((m mod 2 <> 0) and (m mod 3 <> 0)) then\n write(-1)\n else\n if m mod n <> 0 then\n write(-1)\n else\n begin\n z := m div n;\n while z mod 2 = 0 do\n begin\n z := z div 2;\n an := an + 1;\n end;\n while z mod 3 = 0 do\n begin\n z := z div 3;\n an := an + 1;\n end;\n write(an);\n end;\nend."}, {"source_code": "var n,m,x,j : integer;\nbegin\n read(n,m);\n x := 0;\n j := m div n;\n if n=m then write(0)\n else if m mod n <> 0 then write('-1')\n else if (j mod 2 <> 0) and (j mod 3 <> 0) then write('-1')\n else\n begin\n while j mod 2 = 0 do\n begin\n inc(x);\n j := j div 2;\n end;\n while j mod 3 = 0 do\n begin\n inc(x);\n j := j div 3;\n end;\n write(x);\nend;\nend."}, {"source_code": "procedure kol_del(var ch , kol_two,kol_three : longint; res : longint; var flag : boolean);\nbegin\n while (ch mod 2 = 0) or (ch mod 3 = 0) do \n begin\n if ch = res then\n flag := true;\n if ch mod 2 = 0 then\n begin\n ch := ch div 2;\n kol_two += 1;\n end\n else\n if ch mod 3 = 0 then\n begin\n ch := ch div 3;\n kol_three += 1;\n end;\n end;\nend;\n\nvar\n chislo1 , chislo2 , ch1 , ch2 , kol_two1, kol_two2 , kol_three1, kol_three2 : longint;\n flag : boolean;\nbegin\n flag := false;\n read(ch1,ch2);\n kol_del(ch2,kol_two2,kol_three2,ch1,flag);\n kol_del(ch1,kol_two1,kol_three1,0,flag);\n if (kol_two2 >= kol_two1) and (kol_three2 >= kol_three1) then\n begin\n write(kol_two2 - kol_two1 + kol_three2 - kol_three1)\n end\n else\n write(-1);\nend."}, {"source_code": "Var x, y, z, f:int64;\nbegin\n Read(x, y) ;\n If y mod x>0 then begin writeln('-1');exit;end;\n If ((y mod 2>0) and (y mod 3>0)) and (y<>1)then begin writeln('-1');exit;end; \n Z:=y div x;\n Repeat\n If z mod 3 = 0 then begin\n Z:=z div 3;\n F:=f+1;\n End;\n If z mod 2 = 0 then begin\n Z:=z div 2;\n F:=f+1;\n End;\n If (z mod 2>0)and(z mod 3>0) then begin writeln('-1');exit;end;\n Until z = 1;\n Writeln(f);\nend.\n"}, {"source_code": "Var x, y, z, f:int64;\nbegin\n Read(x, y) ;\n If y mod x>0 then begin writeln('-1');exit;end;\n If y mod 2>0 then begin writeln('-1');exit;end;\nIf y mod 3>0 then begin writeln('-1');exit;end; \n Z:=y div x;\n Repeat\n If z mod 3 = 0 then begin\n Z:=z div 3;\n F:=f+1;\n End;\n If z mod 2 = 0 then begin\n Z:=z div 2;\n F:=f+1;\n End;\n Until z = 1;\n Writeln(f);\nend.\n"}, {"source_code": "Var x, y, z, f:int64;\nbegin\n Read(x, y) ;\n If y mod x>0 then begin writeln('-1');exit;end;\n If ((y mod 2>0) and (y mod 3>0)) and (y<>1)then begin writeln('-1');exit;end; \n Z:=y div x;\n Repeat\n If z mod 3 = 0 then begin\n Z:=z div 3;\n F:=f+1;\n End;\n If z mod 2 = 0 then begin\n Z:=z div 2;\n F:=f+1;\n End;\n If (z mod 2>0)and(z mod 3>0) and(z<>1) then begin writeln('-1');exit;end;\n Until z = 1;\n Writeln(f);\nend.\n"}, {"source_code": "\nVar x, y, z, f:int64;\nbegin\n Read(x, y) ;\n If y mod x>0 then begin writeln('-1');exit;end;\n If (y mod 2>0) and (y mod 3>0) then begin writeln('-1');exit;end; \n Z:=y div x;\n Repeat\n If z mod 3 = 0 then begin\n Z:=z div 3;\n F:=f+1;\n End;\n If z mod 2 = 0 then begin\n Z:=z div 2;\n F:=f+1;\n End;\n Until z = 1;\n Writeln(f);\nend.\n"}, {"source_code": "program q;\n var i,k,n,m,o:integer;\n z:real;\nbegin\n read(n,m);\n o:=1;\n z:=m/n;\n if z<>round(z) then \n k:=-1\n else begin\n while o<>0 do\n begin\n z:=z/6;\n if z/6<>round(z/6) then begin\n i:=i+1;\n break;exit;\n end;\n i:=i+1;\n end;\n k:=i*2;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) then begin\n k:=k;end\n else begin\n if z/2<>round(z/2) then\n begin\n while z<>1 do begin\n z:=z/3;\n k:=k+1;\n end;\n end\n else\n if z/3<>round(z/3) then\n begin\n while z<>1 do begin\n z:=z/2;\n k:=k+1;\n end;\n end;\n end;\n end;\n if n=m then k:=0;\n writeln(k);\nend. "}, {"source_code": " var a:integer;\n b,n,m:real;\nbegin\n read(n,m);a:=0;b:=m/n;\n if b=1 then a:=0\n else begin\n if round(b)<>b then a:=-1\n else begin\n if b/6=round(b/6) then\n repeat\n b:=b/6;a:=a+2;\n until b/6<>round(b/6);\n if b/3=round(b/3) then\n repeat\n b:=b/3;a:=a+1;\n until b/3<>round(b/3);\n if b/2=round(b/2) then\n repeat\n b:=b/2;a:=a+1;\n until b/2<>round(b/2);\n end;\n end;\n writeln(a);\nend."}, {"source_code": "program q;\n var i,k,n,m,o:integer;\n z:real;\nbegin\n read(n,m);\n o:=1;\n z:=m/n;\n if z<>round(z) then \n k:=-1\n else begin\n if z/6=round(z/6) then\n begin\n while o<>0 do\n begin\n z:=z/6;\n if z/6<>round(z/6) then begin\n i:=i+1;\n break;exit;\n end;\n i:=i+1;\n end;\n k:=i*2;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) then begin\n k:=k;end\n else begin\n if z/2<>round(z/2) then\n begin\n while z<>1 do begin\n z:=z/3;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end\n else\n if z/3<>round(z/3) then\n begin\n while z<>1 do begin\n z:=z/2;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end;\n end;\n end\n else\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) then begin\n k:=k;end\n else begin\n if z/2<>round(z/2) then\n begin\n while z<>1 do begin\n z:=z/3;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end\n else\n if z/3<>round(z/3) then\n begin\n while z<>1 do begin\n z:=z/2;\n k:=k+1;\n if (z/2<>round(z/2)) and (z/3<>round(z/3)) and (z<>1) then begin\n k:=-1;break;end;\n end;\n end;\n end;\n end;\n if n=m then k:=0;\n writeln(k);\nend."}, {"source_code": "var n,m,dem:int64;\nprocedure nhap;\nbegin\n read(m,n);\nend;\nfunction phantich(a:int64;b:int64):boolean;\nvar i:integer;\nbegin\n i:=2;\n if b mod a <>0 then\n exit(FALSE)\n else\n begin\n b:=b div a;\n while b mod 2 =0 do\n begin\n b:=b div i;\n dem:=dem+1;\n end;\n while b mod 3 =0 do\n begin\n b:=b div i;\n dem:=dem+1;\n end;\n if b>1 then\n exit(FALSE)\n else\n exit(TRUE);\n\n end;\n\nend;\nprocedure xuli;\nbegin\n dem:=0;\n if (n0 then\n exit(FALSE)\n else\n begin\n b:=b div a;\n while b mod 2 =0 do\n begin\n b:=b div i;\n dem:=dem+1;\n end;\n while b mod 3 =0 do\n begin\n b:=b div i;\n dem:=dem+1;\n end;\n if b>1 then\n exit(FALSE)\n else\n exit(TRUE);\n\n end;\n\nend;\nprocedure xuli;\nbegin\n writeln;\n dem:=0;\n if (n0 then\n begin\n write(-1);exit;\n end;\nm:=trunc(m/n);i:=0;\nwhile m mod 2=0 do\n begin\n i:=i+1;m:=trunc(m/2);\n end;\nwhile m mod 3=0 do\n begin\n i:=i+1;m:=trunc(m/3);\n end;\nif m<>1 then\n begin\n write(-1);exit;\n end\nelse write(i);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,m,s,d:int64;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);\n\n assign(f,fo);rewrite(f);\n s:= m div n;\n if s * n <> m then write(f,-1)\n else\n if s=1 then write(f,1)\n else\n begin\n while (s <> 1) do\n begin\n if s mod 3 = 0 then\n begin\n inc(d);\n s:=s div 3;\n end\n else\n if s mod 2 = 0 then\n begin\n inc(d);\n s:=s div 2;\n end;\n if (s mod 2 <> 0 ) and (s mod 3 <> 0) and (s <> 1) then\n begin\n d:=-1;\n break;\n end;\n end;\n write(f,d);\n end;\n close(f);\nend.\n\n"}, {"source_code": "var\n f,m,n,ans : longint;\nbegin\n readln(n,m); f := m div n;\n if m mod n > 0 then begin write(-1); halt; end;\n while f mod 2 = 0 do begin ans += 1; f := f div 2; end;\n while f mod 3 = 0 do begin ans += 1; f := f div 3; end;\n write(ans);\nend."}, {"source_code": "\nVar b,c,tam:int64;\n k:longint;\n\nBegin\n \n Readln(c,b);\n k:=0;\n If (b mod c=0) and (b div c=1) then k:=0\n Else if (2*c>b) then k:=-1\n Else\n Begin\n tam:=b div c;\n While (tam mod 2=0) do\n begin\n tam:=tam div 2;\n inc(k);\n\n end;\n While (tam mod 3=0) do\n begin\n tam:=tam div 3;\n inc(k);\n end;\n If k=0 then k:=-1;\n end;\n\n\n writeln(k);\n\n\nENd.\n"}, {"source_code": "\nVar b,c,tam:int64;\n k:longint;\n\nBegin\n \n Readln(c,b);\n k:=0;\n If (b mod c=0) and (b div c=1) then k:=0\n Else if (2*c>b) then k:=-1\n Else\n Begin\n tam:=b div c;\n While (tam mod 2=0) do\n begin\n tam:=tam div 2;\n inc(k);\n\n end;\n While (tam mod 3=0) do\n begin\n tam:=tam div 3;\n inc(k);\n end;\n If (k=0) or (tam<>c) then k:=-1;\n\n end;\n\n\n writeln(k);\n\n\nENd."}, {"source_code": "Var b,c,tam:int64;\n k:longint;\n\nBegin\n \n Readln(c,b);\n k:=0;\n If (b mod c=0) and (b div c=1) then k:=0\n Else if (2*c>b) then k:=-1\n Else\n Begin\n tam:=b div c;\n While (tam mod 2=0) do\n begin\n tam:=tam div 2;\n inc(k);\n end;\n While (tam mod 3=0) do\n begin\n tam:=tam div 3;\n inc(k);\n end;\n end;\n writeln(k);\n\n\nENd."}, {"source_code": "\nVar b,c,tam:int64;\n k:longint;\n\nBegin\n \n Readln(c,b);\n k:=0;\n If (b mod c=0) and (b div c=1) then k:=1\n Else if (2*c>b) then k:=-1\n Else\n Begin\n tam:=b div c;\n While (tam mod 2=0) do\n begin\n tam:=tam div 2;\n inc(k);\n end;\n While (tam mod 3=0) do\n begin\n tam:=tam div 3;\n inc(k);\n end;\n end;\n writeln(k);\n\n\nENd.\n"}, {"source_code": "\nVar b,c,tam:int64;\n k:longint;\n\nBegin\n\n Readln(c,b);\n k:=0;\n If (b mod c=0) and (b div c=1) then k:=0\n Else if (2*c>b) then k:=-1\n Else\n Begin\n tam:=b div c;\n While (tam mod 2=0) do\n begin\n tam:=tam div 2;\n inc(k);\n\n end;\n While (tam mod 3=0) do\n begin\n tam:=tam div 3;\n inc(k);\n end;\n end;\n If k=0 then k:=-1;\n\n writeln(k);\n\n\n\nENd.\n"}, {"source_code": "var n,m,k,x,a,f:longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(n,m);\nif n=m then begin write(0);halt;end;\nif n>m div 2 then begin write(-1);halt;end;\nx:=m div n;\na:=x;\nk:=0;\nif (a mod 2<>0) and (a mod 3<>0) then begin write(-1);halt;end;\nwhile a<>1 do\n begin\n if (a mod 2<>0) and (a mod 3<>0) then begin write(-1);break;end;\n if a mod 2=0 then begin a:=a div 2;k:=k+1;end;\n if a mod 3=0 then begin a:=a div 3;k:=k+1;end;\n\n end;\nif a=1 then write(k);\nend.\n\n"}, {"source_code": "var n,m,k,x,a,f:longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(n,m);\nif n=m then begin write(0);halt;end;\nif n>m div 2 then begin write(-1);halt;end;\nx:=m div n;\na:=x;\nf:=0;k:=0;\nwhile a<>1 do\n begin\n if (a mod 2<>0) and (a mod 3<>0) then begin write(-1);break;end;\n if a mod 2=0 then begin a:=a div 2;k:=k+1;end;\n if a mod 3=0 then begin a:=a div 3;k:=k+1;end;\n\n end;\nif a=1 then write(k);\nend.\n\n"}, {"source_code": "const fi='input.txt';\n fo='output.txt';\nvar a:array[1..100005,1..2] of longint;\n res,n,m:longint;\n\nprocedure Xuli(n,x:longint);\nvar i:longint;\nBegin\n for i:=2 to trunc(sqrt(n)) do begin\n while n mod i=0 do begin\n inc(a[i][x]);\n n:=n div i;\n end;\n end;\nEnd;\n\nfunction Check:boolean;\nvar i:longint;\nBegin\n if (a[2][1]>a[2][2]) or (a[3][1]>a[3][1]) then exit(false);\n for i:=4 to 100000 do if a[i][1]<>a[i][2] then exit(false);\n exit(true);\nEnd;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n\n read(n,m);\n Xuli(n,1); Xuli(m,2);\n\n if Check=true then write(abs(a[2][1]-a[2][2])+abs(a[3][1]-a[3][2])) else write(-1);\n\n //close(input);\n //close(output);\nEND.\n\n"}, {"source_code": "const fi='input.txt';\n fo='output.txt';\nvar a:array[1..100005,1..2] of longint;\n res,n,m:longint;\n\nprocedure Xuli(n,x:longint);\nvar i:longint;\nBegin\n if (n=2) or (n=3) then inc(a[n][x]);\n for i:=2 to trunc(sqrt(n)) do begin\n while n mod i=0 do begin\n inc(a[i][x]);\n n:=n div i;\n end;\n end;\nEnd;\n\nfunction Check:boolean;\nvar i:longint;\nBegin\n if (a[2][1]=0) or (a[2][2]=0) or (a[3][1]=0) or (a[3][2]=0) then exit(false); \n if (a[2][1]>a[2][2]) or (a[3][1]>a[3][1]) then exit(false);\n for i:=4 to 100000 do if a[i][1]<>a[i][2] then exit(false);\n exit(true);\nEnd;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n\n read(n,m);\n Xuli(n,1);\n Xuli(m,2);\n\n if Check=true then write(abs(a[2][1]-a[2][2])+abs(a[3][1]-a[3][2])) else write(-1);\n\n //close(input);\n //close(output);\nEND.\n\n"}, {"source_code": "const fi='input.txt';\n fo='output.txt';\nvar a:array[1..100005,1..2] of longint;\n res,n,m:longint;\n\nprocedure Xuli(n,x:longint);\nvar i:longint;\nBegin\n if (n=2) or (n=3) then inc(a[n][x]);\n for i:=2 to trunc(sqrt(n)) do begin\n while n mod i=0 do begin\n inc(a[i][x]);\n n:=n div i;\n end;\n end;\nEnd;\n\nfunction Check:boolean;\nvar i:longint;\nBegin\n if (a[2][1]>a[2][2]) or (a[3][1]>a[3][1]) then exit(false);\n for i:=4 to 100000 do if a[i][1]<>a[i][2] then exit(false);\n exit(true);\nEnd;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n\n read(n,m);\n Xuli(n,1);\n Xuli(m,2);\n\n if Check=true then write(abs(a[2][1]-a[2][2])+abs(a[3][1]-a[3][2])) else write(-1);\n\n //close(input);\n //close(output);\nEND.\n\n"}, {"source_code": "var\n n,m,a : real;\n b,kol : longint;\nbegin\n read(n,m);\n a:=m/n;\n b:=trunc(a);\n if trunc(a) <> a then begin write('-1'); halt; end;\n if (trunc(m/n) mod 2 <> 0) and (trunc(m/n) mod 2 <> 0) then begin write('-1'); halt; end;\n while (b mod 2 = 0) or (b mod 3 = 0) do\n begin\n if b mod 2 = 0 then begin b:=b div 2; inc(kol); end\n else if (b mod 3 = 0) then begin b:=b div 3; inc(kol); end;\n end;\n write(kol);\n\nend."}, {"source_code": "var\n n,m,a : real;\n b,kol : longint;\nbegin\n read(n,m);\n a:=m/n;\n b:=trunc(a);\n if trunc(a) <> a then begin write('-1'); halt; end;\n while (b mod 2 = 0) or (b mod 3 = 0) do\n begin\n if b mod 2 = 0 then begin b:=b div 2; inc(kol); end\n else if (b mod 3 = 0) then begin b:=b div 3; inc(kol); end;\n end;\n write(kol);\n\nend."}, {"source_code": "var a,b,kq,dem,c,i :longint;\nBEGIN\n read(a,b); kq:=0;\n if b mod a <>0 then kq:=-1;\n if a=b then kq:=0;\n if b mod a=0 then\n begin\n c:=b div a; i:=2; dem:=0;\n while c<>1 do\n begin\n while c mod i=0 do begin c:=c div i; inc(kq); end;\n inc(i);\n end;\n end;\n write(kq);\nEND."}, {"source_code": "var a,b,kq,c,i :longint;\nBEGIN\n read(a,b); kq:=0;\n if b mod a <>0 then kq:=-1;\n if a=b then kq:=0;\n if b mod a=0 then\n begin\n c:=b div a; i:=2;\n while c<>1 do\n begin\n while c mod i=0 do begin c:=c div i; inc(kq); end;\n inc(i);\n if i>3 then begin kq:=-1; break; end;\n end;\n end;\n write(kq);\nEND."}, {"source_code": "var a,b,kq,c,i :longint;\nBEGIN\n read(a,b); kq:=0;\n if b mod a <>0 then kq:=-1;\n if a=b then kq:=0;\n if b mod a=0 then\n begin\n c:=b div a; i:=2;\n while c<>1 do\n begin\n while c mod i=0 do begin c:=c div i; inc(kq); end;\n inc(i);\n end;\n end;\n write(kq);\nEND."}, {"source_code": "const kt=['u','e','a','o','i'];\nvar st1,st2 :string;\n i,demn,demn1,demp,demp1 :integer;\nBEGIN\n readln(st1);read(st2);\n for i:=1 to length(st1) do if st1[i] in kt then inc(demn) else inc(demp);\n for i:=1 to length(st2) do if st2[i] in kt then inc(demn1) else inc(demp1);\n\n if (demn<>demn1) or (demp1<>demp) then write('NO') else write('YES');\nEND."}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n m,n,kq,count,count1:longint;\nprocedure inp;\nbegin\n assign(f,fi);\n reset(f);\n read(f,n,m);\n close(f);\nend;\n\nprocedure solve;\nbegin\n if (m mod n<>0) then count:=-1\n else\n begin\n kq:=m div n;\n While (kq mod 2=0) do\n begin\n kq:=kq div 2;\n inc(count);\n end ;\n While (kq mod 3=0) do\n begin\n kq:=kq div 3;\n inc(count);\n end;\n end;\n\nend;\nprocedure output;\nbegin\n assign(g,fo);\n rewrite(g);\n writeln(g,count);\n close(g);\nend;\n\nbegin\n inp;\n solve;\n output;\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n m,n,kq,count,count1:longint;\nprocedure inp;\nbegin\n assign(f,fi);\n reset(f);\n read(f,n,m);\n close(f);\nend;\n\nprocedure solve;\nbegin\n if (m mod n<>0) then count:=-1\n else\n begin\n kq:=m div n;\n While (kq mod 2<>0) do\n begin\n kq:=kq div 2;\n inc(count);\n end ;\n While (kq mod 3<>0) do\n begin\n kq:=kq div 3;\n inc(count);\n end;\n end;\n\nend;\nprocedure output;\nbegin\n assign(g,fo);\n rewrite(g);\n writeln(g,count);\n close(g);\nend;\n\nbegin\n inp;\n solve;\n output;\nend.\n"}, {"source_code": "var a,b,c:longint;\nbegin\n readln(a,b);\n if (b mod a<>0)or(b1 do begin\n if b mod 2=0 then b:=b div 2\n else b:=b div 3;\n inc(c);\n end;\n writeln(c);\n end;\n end;\nend."}, {"source_code": "const fi='1141A.inp';\n fo='1441A.OUT';\n var f:text ; n,m,dem2,dem3,s2m,s3m,s2n,s3n:longint;\n\n procedure nhap;\n begin\n // assign(f,fi);\n // reset(F);\n readln({f,}n,m);\n // close(f);\n end;\n\n procedure demsocua(x:longint) ;\n begin\n dem2:=0;\n dem3:=0;\n while( x mod 3 =0 )and(n>0) do\n begin\n inc(dem3);\n x:=x div 3 ;\n end;\n\n while( x mod 2 =0 )and(n>0) do\n begin\n inc(dem2);\n x:=x div 2 ;\n end;\n\n\n\n end;\n\n procedure xuli;\n begin\n // demsocua(n);\n // s2n:=dem2;\n // s3n:=dem3;\n demsocua(m div n );\n s2m:=dem2;\n s3m:= dem3;\n s2n:=0;\n s2m:=s2m{-s2n};\n s3m:=s3m{-s2n};\n if (s2m+s3m =0 )and( n =m) then s2n:=1;\n end;\n\n procedure xuat;\n begin\n // assign(f,fo);\n // rewrite(F);\n if s2n=1 then writeln({f,}0)else\n\n if (m mod n=0) and((m div n mod 2 =0) or( m div n mod 3 =0)) then writeln({f,}s2m+s3m)\n\n else\n begin\n\n\n writeln({f,}-1);\n end;\n// close(F);\n end;\n\n begin\n nhap;\n xuli;\n xuat;\n end.\n\n\n"}, {"source_code": "const fi='1141A.inp';\n fo='1441A.OUT';\n var f:text ; n,m,dem2,dem3,s2m,s3m,s2n,s3n:longint;\n\n procedure nhap;\n begin\n // assign(f,fi);\n // reset(F);\n readln({f,}n,m);\n // close(f);\n end;\n\n procedure demsocua(x:longint) ;\n begin\n dem2:=0;\n dem3:=0;\n while( x mod 3 =0 )and(n>0) do\n begin\n inc(dem3);\n x:=x div 3 ;\n end;\n\n while( x mod 2 =0 )and(n>0) do\n begin\n inc(dem2);\n x:=x div 2 ;\n end;\n\n\n\n end;\n\n procedure xuli;\n begin\n // demsocua(n);\n // s2n:=dem2;\n // s3n:=dem3;\n demsocua(m div n );\n s2m:=dem2;\n s3m:= dem3;\n\n s2m:=s2m{-s2n};\n s3m:=s3m{-s2n};\n\n end;\n\n procedure xuat;\n begin\n // assign(f,fo);\n // rewrite(F);\n if m mod n=0 then writeln({f,}s2m+s3m) else writeln({f,}-1);\n //close(F);\n end;\n\n begin\n nhap;\n xuli;\n xuat;\n end.\n\n\n"}, {"source_code": "const fi='1141A.inp';\n fo='1441A.OUT';\n var f:text ; n,m,dem2,dem3,s2m,s3m,s2n,s3n:longint;\n\n procedure nhap;\n begin\n // assign(f,fi);\n // reset(F);\n readln({f,}n,m);\n // close(f);\n end;\n\n procedure demsocua(x:longint) ;\n begin\n dem2:=0;\n dem3:=0;\n while( x mod 3 =0 )and(n>0) do\n begin\n inc(dem3);\n x:=x div 3 ;\n end;\n\n while( x mod 2 =0 )and(n>0) do\n begin\n inc(dem2);\n x:=x div 2 ;\n end;\n\n\n\n end;\n\n procedure xuli;\n begin\n // demsocua(n);\n // s2n:=dem2;\n // s3n:=dem3;\n demsocua(m div n );\n s2m:=dem2;\n s3m:= dem3;\n\n s2m:=s2m{-s2n};\n s3m:=s3m{-s2n};\n if s2m+s3m =0 then if n =m then s2n:=1;\n end;\n\n procedure xuat;\n begin\n // assign(f,fo);\n // rewrite(F);\n\n if (m mod n=0) and( m div n >0) then writeln({f,}s2m+s3m)\n\n else\n begin\n if s2n=1 then writeln(0)else\n\n writeln({f,}-1);\n end;\n //close(F);\n end;\n\n begin\n nhap;\n xuli;\n xuat;\n end.\n\n\n"}, {"source_code": "const fi='1141A.inp';\n fo='1441A.OUT';\n var f:text ; n,m,dem2,dem3,s2m,s3m,s2n,s3n:longint;\n\n procedure nhap;\n begin\n // assign(f,fi);\n // reset(F);\n readln({f,}n,m);\n // close(f);\n end;\n\n procedure demsocua(x:longint) ;\n begin\n dem2:=0;\n dem3:=0;\n while( x mod 3 =0 )and(n>0) do\n begin\n inc(dem3);\n x:=x div 3 ;\n end;\n\n while( x mod 2 =0 )and(n>0) do\n begin\n inc(dem2);\n x:=x div 2 ;\n end;\n\n\n\n end;\n\n procedure xuli;\n begin\n // demsocua(n);\n // s2n:=dem2;\n // s3n:=dem3;\n demsocua(m div n );\n s2m:=dem2;\n s3m:= dem3;\n s2n:=0;\n s2m:=s2m{-s2n};\n s3m:=s3m{-s2n};\n if (s2m+s3m =0 )and( n =m) then s2n:=1;\n end;\n\n procedure xuat;\n begin\n // assign(f,fo);\n // rewrite(F);\n if s2n=1 then writeln({f,}0)else\n\n if (m mod n=0) and(m div n mod 2 =0) and( m div n mod 3 =0) then writeln({f,}s2m+s3m)\n\n else\n begin\n\n\n writeln({f,}-1);\n end;\n// close(F);\n end;\n\n begin\n nhap;\n xuli;\n xuat;\n end.\n\n\n"}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if ( x mod 2 = 0 ) or ( x mod 3 = 0) or (x mod 6 =0 ) then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if x mod 5 =0 then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if ( x mod 6 = 0 ) or ( x mod 9 = 0) or (x mod 4 = 0 ) then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if x mod 6 =0 then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if x mod 5 =0 then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n writeln(dem);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if n*2 > m then write(-1) else begin\n x:=m div n;\n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if ( x mod 2 = 0 ) or ( x mod 3 = 0) then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n if (x mod 6 = 0 ) then begin\n \n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end else write(-1);\n end;\nend."}, {"source_code": "program CF_1141_A;\nvar n,m,dem,x:longint;\n\nBegin\n dem:=0; \n readln(n,m);\n if m=n then write(0) else\n if m mod n <> 0 then write(-1) else begin\n x:=m div n;\n while x mod 3 = 0 do\n begin\n inc(dem);\n x:=x div 3;\n end;\n while x mod 2 = 0 do\n begin\n inc(dem);\n x:=x div 2;\n end;\n writeln(dem);\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m, a,s, i : longint;\nbegin\n read(n, m);\n s := 0;\n if (m mod n <> 0) then\n writeln(-1)\n else\n begin\n a := m div n;\n for i := 1 to a do\n begin\n if (a = 1) then\n begin\n writeln(s);\n break;\n end\n else if (a mod 2 = 0) then\n a := a div 2\n else if (a mod 3 = 0) then\n a := a div 3\n else\n writeln(-1);\n inc(s);\n end;\n end;\nend.\n"}, {"source_code": "var\n n, m, x: longint;\nbegin\n read(n, m);\n if m mod n <> 0 then\n write(-1)\n else begin\n n := m div n;\n x := 0;\n while n > 1 do begin\n if n mod 2 = 0 then \n n := n div 2\n else if n mod 3 = 0 then\n n := n div 3\n else begin\n write(-1);\n halt;\n end;\n inc(x);\n end;\n end;\nend."}, {"source_code": "program solution;\n{$APPTYPE CONSOLE}\n\nvar\n i, n, m, counter: Int64;\n\nbegin\n readln(n, m);\n counter := 0;\n if n <> m then\n begin\n m := m div n;\n while m mod 2 = 0 do\n begin\n m := m div 2; \n inc(counter);\n end;\n while m mod 3 = 0 do\n begin\n m := m div 3;\n inc(counter);\n end;\n if m <> 1 then \n counter := -1;\n end;\n writeln(counter);\nend.\n"}, {"source_code": "program solution;\n{$APPTYPE CONSOLE}\n\nvar\n i, n, m, counter: Int64;\n\nbegin\n readln(n, m);\n counter := 0;\n if m mod n <> 0 then\n writeln(-1)\n else\n begin\n if n <> m then\n begin\n m := m div n;\n while m mod 2 = 0 do\n begin\n m := m div 2; \n inc(counter);\n end;\n while m mod 3 = 0 do\n begin\n m := m div 3;\n inc(counter);\n end;\n end;\n writeln(counter);\n end;\n readln;\nend.\n"}, {"source_code": "var n,m,k:longint;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\nreadln(n,m);\nif n=m then begin writeln(0);halt;end;\nif n>m div 2 then begin writeln(-1);halt;end;\nm:=m div n;\nwhile m mod 3=0 do\nbegin\nm:=m div 3;\ninc(k);\nend;\nwhile m mod 2=0 do\nbegin\nm:=m div 2;\ninc(k);\nend;\nif m=1 then writeln(k) else writeln(-1);\nend.\n"}, {"source_code": "var n,m,k:longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(n,m);\nif n>m then begin writeln(-1);halt;end;\nif n=m then begin writeln(0);halt;end;\nm:=m div n;\nwhile m mod 3=0 do\nbegin\nm:=m div 3;\ninc(k);\nend;\nwhile m mod 2=0 do\nbegin\nm:=m div 2;\ninc(k);\nend;\nif m=1 then writeln(k) else writeln(-1);\nend."}, {"source_code": "var n,m,k:longint;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\nreadln(n,m);\nif n>m div 2 then begin writeln(-1);halt;end;\nif n=m then begin writeln(0);halt;end;\nm:=m div n;\nwhile m mod 3=0 do\nbegin\nm:=m div 3;\ninc(k);\nend;\nwhile m mod 2=0 do\nbegin\nm:=m div 2;\ninc(k);\nend;\nif m=1 then writeln(k) else writeln(-1);\nend.\n"}, {"source_code": "var\n n,m,min,max:longint;\n\nprocedure sc(x,num:longint);\nbegin\n\n if x=m then\n begin\n\n if min>num then min:=num;\n exit;\n\n end;\n\n if x>m then exit;\n\n sc(x*2,num+1);\n sc(x*3,num+1);\n\nend;\nbegin\n\n readln(n,m);\n min:=maxlongint;\n\n sc(n,0);\n\n writeln(min);\n\nend.\n"}, {"source_code": "//uses crt;\nconst fi='A.inp'; fo='A.out';\nvar n,m,t,s:longint;\n ok:boolean;\n\nprocedure input;\nvar f:text;\n begin\n {assign(f,fi);\n reset(f);}\n //clrscr;\n readln(n,m);\n //close(f);\n end;\n\nprocedure find(var i,j:longint);\n begin\n j:=0;\n while i mod 2=0 do\n begin\n inc(j);\n i:=i div 2;\n end;\n while i mod 3=0 do\n begin\n inc(j);\n i:=i div 3;\n end;\n end;\n\nprocedure run;\n begin\n ok:=false;\n if m=n then\n begin\n ok:=true;\n exit;\n end;\n if m mod n<>0 then exit;\n if (m mod 2<>0) and (m mod 3<>0) then exit;\n ok:=true;\n find(m,t);\n find(n,s);\n t:=t-s;\n end;\n\nprocedure output;\nvar f:text;\n begin\n {assign(f,fo);\n rewrite(f);}\n if ok then writeln(t)\n else writeln('-1');\n //readln\n //close(f);\n end;\n\nBEGIN\n input;\n run;\n output;\nEND.\n\n"}, {"source_code": "var n,m,x,a,k,c:longint;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\nreadln(n,m);\nif n>m div 2 then begin writeln(-1);halt;end;\nif n=m then begin writeln(0);halt;end;\nx:=m div n;\na:=x;\nk:=0;\nc:=m mod n;\nif c>0 then begin write(-1);halt;end;\nwhile a<>1 do\nbegin\n if (a mod 2<>0)and(a mod 3<>0)then begin write(-1);break;end;\n if a mod 2=0 then begin a:=a div 2;inc(k);end;\n if a mod 3=0 then begin a:=a div 3;inc(K);end;\nend;\nif a=1 then writeln(k);\nend.\n\n"}], "src_uid": "3f9980ad292185f63a80bce10705e806"} {"source_code": "uses math;\nconst Nmax=1000;\nvar k,x,a: array[0..Nmax] of longint;\n\n n,m,i,j,l,r,t: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n read(n,m);\n\n for i:=1 to n do begin read(x[i]); inc(k[x[i]]); end; \n for i:=1 to m do read(l,r);\n\n t:=0;\n for i:=0 to 100 do \n if k[i]>0\n then for j:=1 to n do\n if i=x[j] then begin inc(t); a[j]:=t mod 2 end;\n \n\n for i:=1 to n do write(a[i],' ');\n\nend.", "positive_code": [{"source_code": "var n,m,i,a,b:integer;\n x,pos,ans:array[1..100]of integer;\nprocedure sort(l,r:integer);\nvar p,q,z,temp:integer;\nbegin\n p:=l;q:=r;\n z:=x[p+random(q-p)];\n while p<=q do begin\n while z>x[p] do inc(p);\n while x[q]>z do dec(q);\n if p<=q then begin\n temp:=x[p];x[p]:=x[q];x[q]:=temp;\n temp:=pos[p];pos[p]:=pos[q];pos[q]:=temp;\n inc(p);\n dec(q);\n end;\n end;\n if lk do dec(j);\n if i<=j then\n begin\n y:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=y;\n y:=a[2,i]; a[2,i]:=a[2,j]; a[2,j]:=y;\n inc(i); dec(j);\n end;\n until i>j;\n if lx do dec(j);\n if i<=j then\n begin\n tmp:=a[i];\n a[i]:=a[j];\n a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>j;\n if L a[j] then begin\n a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0];\n a[0]:=b[i]; b[i]:=b[j]; b[j]:=a[0];\n end;\n for i:=1 to n do c[b[i]]:=i mod 2;\n for i:=1 to n do write(c[i],' '); writeln;\nend."}, {"source_code": "var a,x,b:array[0..101]of longint;\n m,n,p,q,i:longint;\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then inc(o);\n if o mod 2=0 then b[a[i]]:=0\n else b[a[i]]:=1;\n end;\n for i:=1 to n do\n write(b[i],' ');\n writeln;\n end.\n"}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nuses math;\ntype pt = record x , y : longint; end;\nvar n , m , i , f , j : longint;\n l , r : array[0..101] of longint;\n a : array[0..101] of pt;\n ans : array[0..101] of longint;\nprocedure swap(var x ,y : pt) ;\n var tmp : pt;\n begin\n tmp := x;\n x := y;\n y := tmp;\n end;\nbegin\n Readln(n,m);\n for i:=1 to n do read(a[i].x);\n for i:=1 to n do a[i].y := i;\n for i:=1 to m do Readln(l[i],r[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i].x > a[j].x then\n swap(a[i],a[j]);\n f := 1;\n for i:=1 to n do\n begin\n a[i].x := f;\n f := 1 - f;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i].y > a[j].y then\n swap(a[i],a[j]);\n for i:=1 to n do Write(a[i].x,' ');\nend."}, {"source_code": "var\n c:array[1..100]of char;\n x,y,a,b:array[1..100]of longint;\n i,j,max1,max,n,m,maxj:longint;\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do b[i]:=i;\n readln;\n for i:=1 to n do readln(x[i],y[i]);\n for i:=1 to n do\n begin\n max:=maxlongint;\n for j:=i to n do if (a[j] x[j] then\n begin\n temp:=x[i];\n x[i]:=x[j];\n x[j]:=temp;\n temp:=y[i];\n y[i]:=y[j];\n y[j]:=temp;\n end;\n for i:=1 to n do\n b[y[i]]:=i mod 2;\n for i:=1 to n do\n write(b[i],' ');\nend.\n"}, {"source_code": "var\n x1,a,x,l,r:array[0..100]of longint;\n j,i,sum,n,m:longint;\n f:boolean;\n\n\n procedure check;\n begin\n for i:=1 to m do\n begin\n sum:=0;\n for j:=l[i] to r[i] do if a[j]<>-1 then\n begin\n if a[j]=0 then dec(sum) else inc(sum);\n end;\n if abs(sum)>1 then f:=true;\n end;\n end;\n\nbegin\n readln(n,m);\n for i:=1 to n do read(x[i]);\n x1:=x;\n for i:=1 to n do for j:=i+1 to n do if x[j]0 then\n begin\n inc(dem);\n b[a[i]]:=dem mod 2;\n end;\n for i:=1 to n do write(b[i],' ');\n close(input);\n close(output);\nend."}, {"source_code": "var n, m, x, y, i: longint;\n a, b, z: array [1..100] of longint;\nprocedure sort(l, r: longint);\nvar i, j, x, y: longint;\nbegin\n i := l;\n j := r;\n x := a[random(r - l) + l + 1];\n while i <= j do\n begin\n while a[i] < x do\n inc(i);\n while x < a[j] do\n dec(j);\n if i <= j then\n begin\n y := a[i];\n a[i] := a[j];\n a[j] := y;\n y := b[i];\n b[i] := b[j];\n b[j] := y;\n inc(i);\n dec(j);\n end;\n end;\n if l < j then\n sort(l, j);\n if i < r then\n sort(i, r);\nend;\nbegin\n readln(n, m);\n for i := 1 to n do\n begin\n read(a[i]);\n b[i] := i;\n end;\n for i := 1 to m do\n readln(x, y);\n sort(1, n);\n for i := 1 to n do\n z[b[i]] := i and 1;\n for i := 1 to n do\n write(z[i], ' ');\nend."}, {"source_code": "const fi='';\nvar inp:text;\n i,n,m,j,t:longint;\n a,p:array[1..1000] of longint;\nbegin\n assign(inp,fi);reset(inp);\n readln(inp,n,m);\n for i:=1 to n do read(inp,a[i]);\n for i:=1 to n do p[i]:=i;\n for i:=1 to n do\n for j:=i+1 to n do\n if a[i]>a[j] then begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=p[i];p[i]:=p[j];p[j]:=t;\n end;\n for i:=1 to n do a[p[i]]:=i mod 2;\n for i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "type int = longint;\nvar i,n,m,j,t : int;\n x,p,c : array[1..101] of int;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n read(x[i]); p[i] := i;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if X[i]>X[j] then\n begin\n t := X[i]; X[i] := X[j]; X[j] := t;\n t := P[i]; P[i] := P[j]; P[j] := t;\n end;\n for i:=1 to n do C[P[i]] := i mod 2;\n for i:=1 to n do write(C[i],' ');\nend.\n"}, {"source_code": "var\n n,i,m,k,ok :Longint;\n free,cr,x :Array[0..200] of Longint;\nbegin\n read(n,m);\n for i:=1 to N do\n begin\n read(k);\n x[i]:=k;\n free[k]:=1;\n end;\n\n ok:=0;\n for i:=0 to 100 do\n if free[i]=1 then\n begin\n if ok=0 then cr[i]:=1;\n ok:=1-ok;\n end;\n for i:=1 to N do write(cr[x[i]],' ');\nend."}, {"source_code": "type te = record\n x, y : integer;\n end;\nvar a : array[1..105] of te;\n n, m : integer;\n ispoint : array[1..105] of boolean;\n kq, b : array[1..105] of integer;\nprocedure enter;\n var i : integer;\n begin\n readln(n, m);\n fillchar(ispoint, sizeof(ispoint), false);\n for i := 1 to 100 do b[i] := -1;\n for i := 1 to n do\n begin\n read(kq[i]);\n ispoint[kq[i]] := true;\n end;\n for i := 1 to m do\n readln(a[i].x, a[i].y);\n end;\nprocedure swap(var x, y : te);\n var t : te;\n begin\n t := x;\n x := y;\n y := t;\n end;\nprocedure sort(l, r : integer);\n var g, g2, i, j, t : integer;\n begin\n if l >= r then exit;\n t := L + random(R-L) + 1;\n g := a[t].x;\n g2 := a[t].y;\n i := l; j := r;\n repeat\n while (a[i].x < g) or ((a[i].x=g) and (a[i].y g) or ((a[j].x=g) and (a[j].y j;\n sort(l, j); sort(i, r);\n end;\nprocedure process;\n var i, j, t : integer;\n begin\n randomize;\n sort(1, m);\n for i := 1 to m do\n begin\n t := 0;\n for j := a[i].x to a[i].y do\n if ispoint[j] then\n begin\n if b[j] = -1 then\n b[j] := 1 - t;\n t := b[j];\n end;\n end;\n end;\nprocedure print;\n var i : integer;\n begin\n for i := 1 to n do\n if b[kq[i]] > -1 then write(b[kq[i]],' ')\n else\n write(0,' ');\n end;\nbegin\n enter;\n process;\n print;\nend.\n\n"}, {"source_code": "var\n i,n,m,j,t:longint;\n a,p:array[1..1000] of longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n p[i]:=i;\n for i:=1 to n do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=p[i];p[i]:=p[j];p[j]:=t;\n end;\n for i:=1 to n do\n a[p[i]]:=i mod 2;\n for i:=1 to n do\n write(a[i],' ');\nend."}, {"source_code": "const maxn = 105;\nvar n,m:longint;\n x,y,ans:array[0..maxn] of longint;\nprocedure init();\n var i,j,l,r,tmp,now:longint;\n begin\n readln(n,m); for i:=1 to n do begin read(x[i]); y[i]:=i; end;\n for i:=1 to m do readln(l,r);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if x[y[i]]>x[y[j]] then begin\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n end;\n now:=1;\n for i:=1 to n do begin\n ans[y[i]]:=now; now:=1-now;\n end;\n end;\nprocedure print();\n var i:longint;\n begin\n for i:=1 to n do write(ans[i],' '); writeln();\n end;\nbegin\n init();\n print(); \nend.\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n a,b,d:array[0..1000]of integer;\n\nprocedure main;\nvar i,j,x,n,m:integer;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n read(n,m);\n for i:=1 to n do\n begin\n read(a[i]);\n b[i]:=a[i];\n end;\n\n for i:=0 to 100 do\n d[i]:=2;\n\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\n end;\n for i:=1 to n do\n if odd(i) then d[a[i]]:=0\n else d[a[i]]:=1;\n\n\n for i:=1 to n do\n write(d[b[i]],' ');\n\n close(input); close(output);\nend;\n\n\n\nBEGIN\n main;\nEND.\n"}, {"source_code": "const fi='';\n fo='';\ntype mang=array[1..100] of integer;\nvar\na,b,k:mang;\ni,j,n,m:integer;\n\n\nprocedure hoanvi(var x,y:integer);\nvar t:integer;\nbegin\n t:=x;\n x:=y;\n y:=t;\nend;\n\nprocedure quicksort( var a:mang;lo,hi:integer);\nprocedure sort(l,r:integer);\nvar i,j,x:integer;\nbegin\n i:=l;j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j;\n if la then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a;if ba[j+1] then\n begin t:=a[j]; a[j]:=a[j+1];a[j+1]:=t; t:=b[j]; b[j]:=b[j+1];b[j+1]:=t; end;\n\n for i:=1 to n do c[b[i]]:=i mod 2;\n for i:=1 to n do write(c[i],' ');\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": "var n, m, i, j, l, r, t: byte; x, y, res: array[1..100] of byte;\nbegin\n read(n,m);\n for i:=1 to n do begin read(x[i]); y[i]:=i; end;\n for i:=1 to n-1 do for j:=1 to n-i do if x[j]>x[j+1] then\n begin\n t:=x[j]; x[j]:=x[j+1]; x[j+1]:=t;\n t:=y[j]; y[j]:=y[j+1]; y[j+1]:=t;\n end;\n for i:=1 to n do\n res[y[i]]:=i mod 2;\n for i:=1 to m do read(l,r);\n for i:=1 to n do write(res[i], ' ');\n writeln;\nend."}, {"source_code": "type\n block = record\n ans,num,data:longint;\n end;\n \nvar\n n,x,i,m,j,z:longint;\n a:array[1..100] of block;\n t:block;\n \nbegin\n read(n,m);\n for i:=1 to n do\n begin\n read(a[i].data);\n a[i].num:=i;\n end;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n if a[i].data>a[j].data then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n end;\n for i:=1 to n do\n begin\n a[i].ans:=z;\n z:=1-z;\n end;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n if a[i].num>a[j].num then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n end;\n for i:=1 to n do\n write(a[i].ans,' ');\nend."}, {"source_code": "type point=record\n gt,tt:byte\n end;\nvar n,i,j:byte; x:array[1..100] of point; tg:point;\nbegin\n readln(n,i);\n for i:=1 to n do\n with x[i] do\n begin\n read(gt);\n tt:=i\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if x[i].gt>x[j].gt then\n begin\n tg:=x[i]; x[i]:=x[j]; x[j]:=tg\n end;\n for i:=1 to n do\n if i mod 2=1 then x[i].gt:=0\n else x[i].gt:=1;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if x[i].tt>x[j].tt then\n begin\n tg:=x[i]; x[i]:=x[j]; x[j]:=tg\n end;\n for i:=1 to n do write(x[i].gt,' ')\nend."}, {"source_code": "program task1;\nconst nmax = 109;\n\ntype\n\tseg = record\n\t\tl, r : longint;\n\tend;\n\tpair = record\n\t\tv : longint;\n\t\tid:longint;\n\tend;\n\n\ttar = array [1..nmax] of pair;\n\tpar = array [1..nmax] of seg;\n\n\tProcedure Qsort(var a : tar; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : pair;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k].v < mid.v) do inc(k);\n\t\t\twhile (a[j].v > mid.v) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then Qsort(a,k,r);\n\tend;\n\n\tProcedure QsortS(var a : par; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : seg;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k].l < mid.l) or ( (a[k].l = mid.l) and (a[k].r < mid.r) ) do inc(k);\n\t\t\twhile (a[j].l > mid.l) or ( (a[j].l = mid.l) and (a[j].r > mid.r) ) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then QsortS(a,k,r);\n\tend;\t\n\nvar n, m, i, j, last, rcnt, bcnt : longint;\na : tar;\nb : par;\nc : array [0..nmax] of longint;\nbegin\n\trandseed:=234234;\n\treadln(n,m);\n\tfor i:=1 to n do begin\n\t\tRead(a[i].v);\n\t\ta[i].id:=i;\n\tend;\n\n\treadln();\n\tfor i:=1 to m do begin\n\t\tReadln(b[i].l,b[i].r);\n\tend;\n\n\tQsort(a,1,n);\n\n\tfor i:=1 to n do begin\n\t\tif odd(i) then begin\n\t\t\tc[a[i].id]:=0;\t\n\t\tend else begin\n\t\t\tc[a[i].id]:=1;\t\n\t\tend;\n\tend;\n\tfor i:=1 to n do begin\n\t\tWrite(c[i],' ');\n\tend;\n\twriteln();\n\t{\n\tQsortS(b,1,m);\n\n\tfor i:=1 to n do c[i]:=-1;\n\n\tfor i:=1 to m do begin\n\t\trcnt:=0; bcnt:=0;\n\t\tlast:= -1;\n\t\tfor j:=1 to n do begin\n\n\t\t\tif (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin\n\t\t\t\tif c[j] = -1 then begin\n\t\t\t\t\tif rcnt < bcnt then begin\n\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\t\tlast:=0;\n\t\t\t\t\tend else if rcnt > bcnt then begin\n\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\t\tlast:=1;\n\t\t\t\t\tend else begin\n\t\t\t\t\t\tif last = 0 then begin\n\t\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\t\t\tlast:=1;\n\t\t\t\t\t\tend else begin\n\t\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\t\t\tlast:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tend else begin\n\t\t\t\t\tif c[j] = 0 then inc(rcnt)\n\t\t\t\t\telse inc(bcnt);\n\t\t\t\t\tlast:=c[j];\n\t\t\t\tend;\n\t\t\tend;\n\n\t\tend;\n\t\tif abs(rcnt-bcnt)>1 then begin\n\t\t\tWriteln('-1');\n\t\t\tExit();\n\t\tend;\n\tend;\n\n\tfor i:=1 to n do begin\n\t\tif c[i] = -1 then c[i]:=0;\n\t\tWrite(c[i],' ');\n\tend;\n\twriteln();\n\t}\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const MD=round(1e9)+7;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,l,r:longint;\n a,ind,ans:array[1..100] of integer;\n procedure QSort(l,r:integer);\n var\n buf,key:int64;\n i,j:integer;\n begin\n if l>=r then exit;\n key:=a[l+random(r-l)];\n i:=l;\n j:=r;\n repeat\n while a[i]key do dec(j);\n if (i<=j) then\n begin\n buf:=a[i];\n a[i]:=a[j];\n a[j]:=buf;\n buf:=ind[i];\n ind[i]:=ind[j];\n ind[j]:=buf;\n i:=i+1;\n j:=j-1;\n end;\n until j0 then\n begin\n inc(k);\n b[a[i]]:=k mod 2;\n end;\n for i:=1 to n do write(b[i],' ');\n readln;\nend.\n"}, {"source_code": "var a,b:array[0..100] of integer;\n x:array[1..100] of integer;\n n,i,m,k:integer;\nbegin\n\n readln(n,m);\n for i:=1 to n do\n begin\n read(x[i]);\n a[x[i]]:=i;\n end;\n k:=0;\n for i:=0 to 100 do\n if a[i]<>0 then\n begin\n inc(k);\n b[a[i]]:=k mod 2;\n end;\n for i:=1 to n do write(b[i],' ');\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n kq,a,b:array[0..105] of integer;\n n,m,i:integer;\n procedure qsort(dau,cuoi:integer);\n var x,i,j,t:integer;\n begin\n if dau>=cuoi then exit;\n i:=dau;\n j:=cuoi;\n x:=b[a[(dau+cuoi) div 2]];\n repeat\n while b[a[i]]x do j:=j-1;\n if i<=j then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n i:=i+1;\n j:=j-1;\n end;\n until i>j;\n qsort(dau,j);\n qsort(i,cuoi);\n end;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n readln(f,n,m);\n for i:=1 to n do\n read(F,b[i]);\n close(f);\n\n for i:=1 to n do\n a[i]:=i;\n qsort(1,n);\n for i:=1 to n do\n kq[a[i]]:=i mod 2;\n for i:=1 to n do\n write(G,kq[i],' ');\n close(G);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram PointsAndSegments;\nconst\n fin='';\n fou='';\n maxN=100;\n maxM=100;\n \nvar\n a:array[1..maxN] of longint;\n p:array[1..maxN] of integer;\n c:array[1..maxN] of integer;\n n,m:integer;\n fi,fo:text;\n \nprocedure swap(var x,y:integer);\nvar\n tmp:integer;\nbegin\n tmp:=x;\n x:=y;\n y:=tmp;\nend;\n \nprocedure Sort(l,r:integer);\nvar\n i,j:integer;\n v:longint;\nbegin\n i:=l;\n j:=r;\n v:=a[p[(l+r) div 2]];\n repeat\n while (a[p[i]]v) do dec(j);\n if (i<=j) then\n begin\n swap(p[i],p[j]);\n inc(i);\n dec(j);\n end;\n until (i>j);\n if (l=h then exit;\n i:=random(h-l+1)+l; j:=h; pivot:=a[i];\n a[i]:=a[l]; i:=l;\n repeat\n while (ipivot.x) do dec(j);\n if i=h then exit;\n i:=random(h-l+1)+l; j:=h; pivot:=a[i];\n a[i]:=a[l]; i:=l;\n repeat\n while (ipivot.dex) do dec(j);\n if i b[j] then\n begin\n z:=b[i];\n b[i]:=b[j];\n b[j]:=z;\n end;\n end;\n end;\n for i:=1 to n do\n begin\n z:=b[i];\n if i mod 2 = 0 then\n begin\n mau[z]:=0;\n end;\n if (i mod 2 <> 0) then\n begin\n mau[z]:=1;\n end;\n end;\n for i:=1 to n do\n begin\n z:=a[i];\n write(mau[z],' ');\n end;\n\nend.\n"}, {"source_code": "Var a,b,c,kol,ans:array[1..1000000] of longint;\n i,j,k,m,l,o,p,n:longint;\n\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=kol[i];\n kol[i]:=kol[j];\n kol[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=kol[i];\n kol[i]:=kol[j];\n kol[j]:=y;\n y:=ans[i];\n ans[i]:=ans[j];\n ans[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[j+1]then\n begin\n k:=a[j]; a[j]:=a[j+1]; a[j+1]:=k;\n k:=d[j]; d[j]:=d[j+1]; d[j+1]:=k;\n end;\n for i:=1 to n do f[d[i]]:=i mod 2;\n for i:=1 to n do write(f[i],' ')\nend."}], "negative_code": [{"source_code": "uses math;\nconst Nmax=1000;\nvar a: array[0..Nmax] of longint;\n n,m,k,i,j,x,y,l,r: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n read(n,m);\n\n for i:=1 to n do read(x);\n for i:=1 to m do read(l,r);\n\n for i:=1 to n do\n if i mod 2 = 0 then write('0 ') else write('1 ');\n\nend."}, {"source_code": "\n\n\n\n program Pr1;\n\n{$APPTYPE CONSOLE}\n\nlabel 1,2,3,4;\nconst modul=100000007; besk=100000000; besk1=1000000000000; eps=1e-10;\ntype double=extended;\nmas=array[-10..2000000] of int64; mass=^mas;\nvar bb,n1,n2,kol,jj,n,k,i,j: longint;\nfact,a,d,ot2,numi,numj,newobr,obr,pred,next,b,c:array[-1000..2000000] of int64;\nzan,pr: array[0..5000000] of boolean;\nx,y:array[-10..200000] of double;\nsss1,sss2,sss:string;\nper:mas;\nflag:boolean;\np,r,period,l,mmod,pos,iot,jot,kk,pmin,imin,pmax,imax,i1,i2,j1,j2,qq,pp,iii,p1,p2,kolelem,tt,ot,s,t,al,m:int64;\npole1:array[-10..600,-10..600] of char;\notch:array[0..1000000] of char;\nbeta,otold,otnew,x2,x0,x1,aa,cc:double;\ndd5,dd6,dd2,dd3,dd4,dd1,pole,cena:array[-10..1100,-10..1100] of int64;\nmarked:array[-10..60000] of boolean;\nnapx,napy: array[-10..600] of longint;\nfunction max(a,b:int64):int64; begin max:=a;if b>a then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a;if ba[j+1] then\n begin t:=a[j]; a[j]:=a[j+1];a[j+1]:=t; t:=b[j]; b[j]:=b[j+1];b[j+1]:=t; end;\n\n for i:=1 to n do c[b[i]]:=i mod 2;\n for i:=1 to n do write(c[i],' ');\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": "\n\n program Pr1;\n\n{$APPTYPE CONSOLE}\n\nlabel 1,2,3,4;\nconst modul=100000007; besk=100000000; besk1=1000000000000; eps=1e-10;\ntype double=extended;\nmas=array[-10..2000000] of int64; mass=^mas;\nvar bb,n1,n2,kol,jj,n,k,i,j: longint;\nfact,a,d,ot2,numi,numj,newobr,obr,pred,next,b,c:array[-1000..2000000] of int64;\nzan,pr: array[0..5000000] of boolean;\nx,y:array[-10..200000] of double;\nsss1,sss2,sss:string;\nper:mas;\nflag:boolean;\np,r,period,l,mmod,pos,iot,jot,kk,pmin,imin,pmax,imax,i1,i2,j1,j2,qq,pp,iii,p1,p2,kolelem,tt,ot,s,t,al,m:int64;\npole1:array[-10..600,-10..600] of char;\notch:array[0..1000000] of char;\nbeta,otold,otnew,x2,x0,x1,aa,cc:double;\ndd5,dd6,dd2,dd3,dd4,dd1,pole,cena:array[-10..1100,-10..1100] of int64;\nmarked:array[-10..60000] of boolean;\nnapx,napy: array[-10..600] of longint;\nfunction max(a,b:int64):int64; begin max:=a;if b>a then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a;if b a[j] then\n begin\n z:=a[i];\n a[i]:=a[j];\n a[j]:=z;\n end;\n end;\n end;\n for i:=1 to n do\n begin\n if i mod 2 = 0 then\n begin\n mau[a[i]]:=0;\n end;\n if (i mod 2 <> 0) then\n begin\n mau[a[i]]:=1;\n end;\n end;\n for i:=1 to n do\n begin\n write(mau[a[i]]);\n end;\n\nend."}, {"source_code": "program points;\nvar a,b,mau:array[1..1000] of longint;\n m,n,i,j,x,y,z:longint;\nbegin\n read(n);\n read(m);\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n for i:=1 to n do\n begin\n b[i]:=a[i];\n end;\n for i:=1 to m do\n begin\n read(x);\n read(y);\n end;\n for i:=1 to n do\n begin\n if a[i] mod 2 = 0 then write(1);\n if a[i] mod 2 <>0 then write(0);\n write(' ');\n end;\n\n\nend.\n"}, {"source_code": "program points;\nvar a,b,mau:array[1..1000] of longint;\n m,n,i,j,x,y,z:longint;\nbegin\n read(n);\n read(m);\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n for i:=1 to n do\n begin\n b[i]:=a[i];\n end;\n for i:=1 to m do\n begin\n read(x);\n read(y);\n end;\n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n begin\n if a[i] > a[j] then\n begin\n z:=a[i];\n a[i]:=a[j];\n a[j]:=z;\n end;\n end;\n end;\n for i:=1 to n do\n begin\n if i mod 2 = 0 then\n begin\n mau[a[i]]:=0;\n end;\n if (i mod 2 <> 0) then\n begin\n mau[a[i]]:=1;\n end;\n end;\n for i:=1 to n do\n begin\n write(mau[a[i]],' ');\n end;\n\nend.\n"}, {"source_code": "Var a,b,c,kol:array[1..1000000] of longint;\n i,j,k,m,l,o,p,n:longint;\n\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then begin inc(j);\n if j mod 2=0 then write('1 ' )\n else write('0 '); end; end;\n\n end."}, {"source_code": "Var a,b,c,kol:array[1..1000000] of longint;\n i,j,k,m,l,o,p,n:longint;\n Begin\n read(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i],c[i]);\n for i:=1 to n do begin\n if i mod 2=0 then write('1 ' )\n else write('0 '); end;\n end."}, {"source_code": "Var a,b,c,kol,ans:array[1..1000000] of longint;\n i,j,k,m,l,o,p,n:longint;\n\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=kol[i];\n kol[i]:=kol[j];\n kol[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=kol[i];\n kol[i]:=kol[j];\n kol[j]:=y;\n y:=ans[i];\n ans[i]:=ans[j];\n ans[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lk do dec(j);\n if i<=j then\n begin\n y:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=y;\n y:=a[2,i]; a[2,i]:=a[1,j]; a[2,j]:=y;\n inc(i); dec(j);\n end;\n until i>j;\n if l=l[j]) and (x[i]<=r[j]) and (not kt[i]) then\n begin\n kt[i]:=true;\n if (x[i-1]=0) then kq[i]:=1 else kq[i]:=0;\n end;\n\nfor i:= 1 to n do\n write(kq[i],' ');\nend.\n\n\n\n"}, {"source_code": "var a,x,y:array[0..101]of longint;\n m,n,p,q,i:longint;\nbegin\n readln(n,m);\n for i:= 1 to n do read(x[i]);\n for i:= 1 to m do\n readln(p,q);\n for i:= 0 to 100 do\n if i mod 2 = 0 then a[i]:=0 else a[i]:=1;\n for i:= 1 to n do\n write(a[x[i]],' ');\nend."}, {"source_code": "Var n,m,i:longint;\n x,l,r:array [0..1000] of longint;\n begin\n read(n,m);\n for i:=1 to n do\n read(x[i]);\n for i:=1 to m do\n read(l[i],r[i]);\n for i:=1 to n do\n if i mod 2=0 then write(0,' ')\n else write(1,' ');\n writeln;\n\n end."}, {"source_code": "uses\n math;\n\nvar\n b,x:array[0..1000] of longint;\n i,j,n,m,temp,ans1,l,r,ans2:longint;\n \nBegin\n read(n,m);\n for i:=1 to n do\n read(x[i]);\n for i:=1 to n do\n for j:=i+1 to n do\n if x[i] > x[j] then\n begin\n temp:=x[i];\n x[i]:=x[j];\n x[j]:=temp;\n end;\n for i:=1 to n do\n b[i]:=i mod 2;\n for i:=1 to m do\n begin\n read(l,r);\n ans1:=0; ans2:=0;\n for j:=1 to n do\n if (x[j] >= l) and (x[j] <= r) then\n begin\n if b[j] = 1 then inc(ans2)\n else inc(ans1);\n end;\n if not (abs(ans1-ans2) <= 1) then\n begin\n writeln(-1);\n halt;\n end;\n end;\n for i:=1 to n do\n write(b[i],' ');\nend.\n"}, {"source_code": "var\n a,x,l,r:array[0..100]of longint;\n j,i,sum,n,m:longint;\n f:boolean;\n\n\n procedure check;\n begin\n for i:=1 to m do\n begin\n sum:=0;\n for j:=l[i] to r[i] do if a[j]<>-1 then\n begin\n if a[j]=0 then dec(sum) else inc(sum);\n end;\n if abs(sum)>1 then f:=true;\n end;\n end;\n\nbegin\n readln(n,m);\n for i:=1 to n do read(x[i]);\n for i:=1 to n do for j:=i+1 to n do if x[j]>x[i] then\n begin\n sum:=x[i];\n x[i]:=x[j];\n x[j]:=sum;\n end;\n readln;\n for i:=1 to m do readln(l[i],r[i]);\n fillchar(a,sizeof(a),255);\n\n for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;\n check;\n if not f then\n begin\n for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');\n halt;\n end;\n\n f:=false;\n for i:=1 to n do if odd(i) then a[x[i]]:=1 else a[x[i]]:=0;\n check;\n if not f then\n begin\n for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');\n halt;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var\n a,x,l,r:array[0..100]of longint;\n j,i,sum,n,m:longint;\n f:boolean;\n\n\n procedure check;\n begin\n for i:=1 to m do\n begin\n sum:=0;\n for j:=l[i] to r[i] do if a[j]<>-1 then\n begin\n if a[j]=0 then dec(sum) else inc(sum);\n end;\n if abs(sum)>1 then f:=true;\n end;\n end;\n\nbegin\n readln(n,m);\n for i:=1 to n do read(x[i]);\n for i:=1 to n do for j:=i+1 to n do if x[j]-1 then write(a[i],' ');\n halt;\n end;\n writeln(-1);\nend."}, {"source_code": "var\n a,x,l,r:array[0..100]of longint;\n j,i,sum,n,m:longint;\n f:boolean;\n\n\n procedure check;\n begin\n for i:=1 to m do\n begin\n sum:=0;\n for j:=l[i] to r[i] do if a[j]<>-1 then\n begin\n if a[j]=0 then dec(sum) else inc(sum);\n end;\n if abs(sum)>1 then f:=true;\n end;\n end;\n\nbegin\n readln(n,m);\n for i:=1 to n do read(x[i]);\n readln;\n for i:=1 to m do readln(l[i],r[i]);\n fillchar(a,sizeof(a),255);\n\n for i:=1 to n do if odd(i) then a[x[i]]:=0 else a[x[i]]:=1;\n check;\n if not f then\n begin\n for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');\n halt;\n end;\n\n f:=false;\n for i:=1 to n do if odd(i) then a[x[i]]:=1 else a[x[i]]:=0;\n check;\n if not f then\n begin\n for i:=0 to 100 do if a[i]>-1 then write(a[i],' ');\n halt;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,m,i:longint;\n a,t,l,r:array [0..20000] of longint;\n\n function ok():boolean;\n var i,j:longint; f:array [0..200,0..20] of longint;\n begin\n fillchar(f,sizeof(f),0);\n for i:=1 to n do\n for j:=1 to m do\n if (a[i]>=l[j]) and (a[i]<=r[j]) then\n inc(f[j,t[i]]);\n for i:=1 to m do\n if abs(f[i,0]-f[i,1])>1 then exit(false);\n exit(true);\n end;\n\n\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do readln(l[i],r[i]);\n t[1]:=0;\n for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;\n if (ok()) then\n begin\n for i:=1 to n do write(t[i],' ');\n halt(0);\n end;\n t[1]:=1;\n for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;\n if (ok()) then\n begin\n for i:=1 to n do write(t[i],' ');\n halt(0);\n end;\n writeln(-1);\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,m,i,j,x:longint;\n a,t,l,r:array [0..20000] of longint;\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do readln(l[i],r[i]);\n t[1]:=1;\n for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;\n for i:=1 to n do\n for j:=1 to n-1 do\n if (a[i]=l[j]) and (a[i]<=r[j]) then\n inc(f[j,t[i]]);\n for i:=1 to m do\n if abs(f[i,0]-f[i,1])>1 then exit(false);\n exit(true);\n end;\n\n\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do readln(l[i],r[i]);\n t[1]:=0;\n for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;\n if (ok()) then\n begin\n for i:=1 to n do write(t[i],' ');\n halt(0);\n end;\n t[1]:=1;\n for i:=2 to n do t[i]:=(t[i-1]+1) mod 2;\n for i:=1 to n do write(t[i],' ');\nend."}, {"source_code": "const fi='';\nvar inp:text;\n i,n,m:longint;\nbegin\n assign(inp,fi);reset(inp);\n readln(inp,n,m);\n for i:=1 to n do write(i mod 2,' ');\nend."}, {"source_code": "type int = longint;\nvar i,n,m : int;\nbegin\n readln(n,m);\n for i:=1 to n do write(i mod 2,' '); \nend."}, {"source_code": "type te = record\n x, y : integer;\n end;\nvar a : array[1..105] of te;\n n, m : integer;\n ispoint : array[1..105] of boolean;\n kq, b : array[1..105] of integer;\nprocedure enter;\n var i : integer;\n begin\n readln(n, m);\n fillchar(ispoint, sizeof(ispoint), false);\n for i := 1 to 100 do b[i] := -1;\n for i := 1 to n do\n begin\n read(kq[i]);\n ispoint[kq[i]] := true;\n end;\n for i := 1 to m do\n readln(a[i].x, a[i].y);\n end;\nprocedure swap(var x, y : te);\n var t : te;\n begin\n t := x;\n x := y;\n y := t;\n end;\nprocedure sort(l, r : integer);\n var g, g2, i, j, t : integer;\n begin\n if l >= r then exit;\n t := L + random(R-L) + 1;\n g := a[t].x;\n g2 := a[t].y;\n i := l; j := r;\n repeat\n while (a[i].x < g) or ((a[i].x=g) and (a[i].y g) or ((a[j].x=g) and (a[j].y j;\n sort(l, j); sort(i, r);\n end;\nprocedure process;\n var i, j, t : integer;\n begin\n randomize;\n sort(1, m);\n for i := 1 to m do\n begin\n t := 0;\n for j := a[i].x to a[i].y do\n if ispoint[j] then\n begin\n if b[j] = -1 then\n b[j] := 1 - t;\n t := b[j];\n end;\n end;\n end;\nprocedure print;\n var i : integer;\n begin\n for i := 1 to n do\n write(b[kq[i]],' ');\n end;\nbegin\n enter;\n process;\n print;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n\nprocedure main;\nvar i,n,m:integer;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n read(n,m);\n for i:=1 to n do\n if odd(i) then write('0 ')\n else write('1 ');\n\n close(input); close(output);\nend;\n\n\n\nBEGIN\n main;\nEND.\n"}, {"source_code": "const fi='';\n fo='';\ntype mang=array[1..100] of integer;\nvar\na,b:mang;\ni,j,n,m:integer;\n\n\nprocedure hoanvi(var x,y:integer);\nvar t:integer;\nbegin\n t:=x;\n x:=y;\n y:=t;\nend;\n\nprocedure quicksort( var a:mang;lo,hi:integer);\nprocedure sort(l,r:integer);\nvar i,j,x:integer;\nbegin\n i:=l;j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j;\n if lj;\n if lj;\n if lj;\n if lj;\n if lj;\n if l mid) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then Qsort(a,k,r);\n\tend;\n\n\tProcedure QsortS(var a : par; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : seg;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k].l < mid.l) do inc(k);\n\t\t\twhile (a[j].l > mid.l) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then QsortS(a,k,r);\n\tend;\t\n\nvar n, m, i, j, last, rcnt, bcnt : longint;\na : tar;\nb : par;\nc : tar;\nbegin\n\treadln(n,m);\n\tfor i:=1 to n do Read(a[i]);\n\treadln();\n\tfor i:=1 to m do begin\n\t\tReadln(b[i].l,b[i].r);\n\tend;\n\tQsort(a,1,n);\n\tQsortS(b,1,m);\n\n\tfor i:=1 to n do c[i]:=-1;\n\n\tfor i:=1 to m do begin\n\t\trcnt:=0; bcnt:=0;\n\t\tfor j:=1 to n do begin\n\n\t\t\tif (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin\n\t\t\t\tif c[j] = -1 then begin\n\t\t\t\t\tif rcnt <= bcnt then begin\n\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\tend else begin\n\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\tend;\n\t\t\t\tend else begin\n\t\t\t\t\tif c[j] = 0 then inc(rcnt)\n\t\t\t\t\telse inc(bcnt);\n\t\t\t\tend;\n\t\t\tend;\n\n\t\tend;\n\t\tif abs(rcnt-bcnt)>1 then begin\n\t\t\tWriteln('-1');\n\t\t\tExit();\n\t\tend;\n\tend;\n\n\tfor i:=1 to n do begin\n\t\tWrite(c[i],' ');\n\tend;\n\twriteln();\nend."}, {"source_code": "program task1;\nconst nmax = 109;\n\ntype\n\tseg = record\n\t\tl, r : longint;\n\tend;\n\n\ttar = array [1..nmax] of longint;\n\tpar = array [1..nmax] of seg;\n\n\tProcedure Qsort(var a : tar; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : longint;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k] < mid) do inc(k);\n\t\t\twhile (a[j] > mid) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then Qsort(a,k,r);\n\tend;\n\n\tProcedure QsortS(var a : par; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : seg;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k].l < mid.l) do inc(k);\n\t\t\twhile (a[j].l > mid.l) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then QsortS(a,k,r);\n\tend;\t\n\nvar n, m, i, j, last, rcnt, bcnt : longint;\na : tar;\nb : par;\nc : tar;\nbegin\n\treadln(n,m);\n\tfor i:=1 to n do Read(a[i]);\n\treadln();\n\tfor i:=1 to m do begin\n\t\tReadln(b[i].l,b[i].r);\n\tend;\n\tQsort(a,1,n);\n\tQsortS(b,1,m);\n\n\tfor i:=1 to n do c[i]:=-1;\n\n\tfor i:=1 to m do begin\n\t\trcnt:=0; bcnt:=0;\n\t\tfor j:=1 to n do begin\n\n\t\t\tif (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin\n\t\t\t\tif c[j] = -1 then begin\n\t\t\t\t\tif rcnt <= bcnt then begin\n\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\tend else begin\n\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\tend;\n\t\t\t\tend else begin\n\t\t\t\t\tif c[j] = 0 then inc(rcnt)\n\t\t\t\t\telse inc(bcnt);\n\t\t\t\tend;\n\t\t\tend;\n\n\t\tend;\n\t\tif abs(rcnt-bcnt)>1 then begin\n\t\t\tWriteln('-1');\n\t\t\tExit();\n\t\tend;\n\tend;\n\n\tfor i:=1 to n do begin\n\t\tif c[i] = -1 then c[i]:=0;\n\t\tWrite(c[i],' ');\n\tend;\n\twriteln();\nend."}, {"source_code": "program task1;\nconst nmax = 109;\n\ntype\n\tseg = record\n\t\tl, r : longint;\n\tend;\n\n\ttar = array [1..nmax] of longint;\n\tpar = array [1..nmax] of seg;\n\n\tProcedure Qsort(var a : tar; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : longint;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k] < mid) do inc(k);\n\t\t\twhile (a[j] > mid) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then Qsort(a,k,r);\n\tend;\n\n\tProcedure QsortS(var a : par; l, r : longint);\n\tvar k, j : longint;\n\tmid, w : seg;\n\tbegin\n\t\tk:=l;\n\t\tj:=r;\n\t\tmid:=a[l+random(r-l+1)];\n\t\twhile (k<=j) do begin\n\t\t\twhile (a[k].l < mid.l) or ( (a[k].l = mid.l) and (a[k].r < mid.r) ) do inc(k);\n\t\t\twhile (a[j].l > mid.l) or ( (a[j].l = mid.l) and (a[j].r > mid.r) ) do dec(j);\n\t\t\tif (k<=j) then begin\n\t\t\t\tw:=a[k]; a[k]:=a[j]; a[j]:=w;\n\t\t\t\tinc(k); dec(j);\n\t\t\tend;\n\t\tend;\n\t\tif (lk) then QsortS(a,k,r);\n\tend;\t\n\nvar n, m, i, j, last, rcnt, bcnt : longint;\na : tar;\nb : par;\nc : tar;\nbegin\n\trandseed:=234234;\n\treadln(n,m);\n\tfor i:=1 to n do Read(a[i]);\n\treadln();\n\tfor i:=1 to m do begin\n\t\tReadln(b[i].l,b[i].r);\n\tend;\n\tQsort(a,1,n);\n\tQsortS(b,1,m);\n\n\tfor i:=1 to n do c[i]:=-1;\n\n\tfor i:=1 to m do begin\n\t\trcnt:=0; bcnt:=0;\n\t\tlast:= -1;\n\t\tfor j:=1 to n do begin\n\n\t\t\tif (a[j] >= b[i].l) and (a[j] <= b[i].r) then begin\n\t\t\t\tif c[j] = -1 then begin\n\t\t\t\t\tif rcnt < bcnt then begin\n\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\t\tlast:=0;\n\t\t\t\t\tend else if rcnt > bcnt then begin\n\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\t\tlast:=1;\n\t\t\t\t\tend else begin\n\t\t\t\t\t\tif last = 0 then begin\n\t\t\t\t\t\t\tc[j]:=1;\n\t\t\t\t\t\t\tinc(bcnt);\n\t\t\t\t\t\t\tlast:=1;\n\t\t\t\t\t\tend else begin\n\t\t\t\t\t\t\tc[j]:=0;\n\t\t\t\t\t\t\tinc(rcnt);\n\t\t\t\t\t\t\tlast:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tend else begin\n\t\t\t\t\tif c[j] = 0 then inc(rcnt)\n\t\t\t\t\telse inc(bcnt);\n\t\t\t\t\tlast:=c[j];\n\t\t\t\tend;\n\t\t\tend;\n\n\t\tend;\n\t\tif abs(rcnt-bcnt)>1 then begin\n\t\t\tWriteln('-1');\n\t\t\tExit();\n\t\tend;\n\tend;\n\n\tfor i:=1 to n do begin\n\t\tif c[i] = -1 then c[i]:=0;\n\t\tWrite(c[i],' ');\n\tend;\n\twriteln();\nend."}], "src_uid": "692698d4b49ad446984f3a7a631f961d"} {"source_code": "Program A1060;\nVar\n n, i, m : integer;\n s : string;\nBegin\n readln(n);\n m := 0;\n readln(s);\n for i := 1 to n do if s[i] = '8' then inc(m);\n if m <> 0\n then \n if n div 11 > m\n then write (m)\n else write (n div 11)\n else write('0');\nend.", "positive_code": [{"source_code": "program a;\nvar n,c,i,y:integer;\nvar m:char;\nbegin\nc := 0;\ny := 0;\nreadln(n);\nfor i := 1 to n do\nbegin\nread (m);\nif m = '8' then c :=c + 1;\nend;\ny := n div 11;\nif y <= c then write(y)\nelse write (c);\nend."}, {"source_code": "var a,l,x,i,k:byte; st:string;\nbegin\nreadln(l);\nreadln(st);\nx:=l div 11;\nfor i:=1 to l do\n if st[i]='8' then k:=k+1;\nif x*k=0 then a:=0 else if ka then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc] k then\n write(k)\n else\n write(length(s) div 11);\nend."}, {"source_code": "var n,i,dem:integer;\n s:string;\nbegin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n if s[i] = '8' then inc(dem);\n if dem < (n div 11) then writeln(dem)\n else writeln(n div 11);\n readln;\nend."}, {"source_code": "Uses Math;\n\nConst ginp='';//ss.inp';\n gout='';//ss.out';\n\nVar n,res:longint;\n a:string[100];\n\nProcedure Enter;\nVar i:longint;\nBegin\n readln(n);\n read(a);\nEnd;\n\nProcedure Process;\nVar i:longint;\nBegin\n res:=0;\n for i:=1 to n do\n if a[i]='8' then inc(res);\n res:=min(res,n div 11);\n write(res);\nEnd;\n\nBegin\n Assign(input,ginp); Assign(output,gout);\n Reset(input); Rewrite(output);\n Enter;\n Process;\n Close(input); Close(output);\nEnd.\n\n"}, {"source_code": "var\n s:ansistring;\n n,t,i:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n if s[i]='8' then inc(t);\n if n div 11n)then writeln(n div 11)else writeln(s8);\nend."}, {"source_code": "var st:string;a,b,i:longint;\nbegin\nreadln(b);\nreadln(st);\nfor i:=1 to length(st) do\nbegin\nif ord(st[i])=48+8 then inc(a);\nend;\nif (b div 11) 0) and (n >= 11) then\n begin\n while (k > 0) and (n >= 11) do\n begin\n dec(k);\n n := n - 11;\n inc(i);\n end;\n \n write(i);\n end\n else\n write(0);\nend."}, {"source_code": "var\nn,a,i:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s) do begin\n if s[i]='8' then inc(a)\nend;\nif n div 11n div 11 then write(n div 11) else write(k);\n //close(input);\n //close(output);\nend."}, {"source_code": "var n,res,num8:shortint;\n s:string;\nbegin\n readln(n);\n readln(s);\n if (pos('8',s)=0)or(n<11) then\n begin\n write(0);\n readln;\n halt;\n end;\n res:=0;\n num8:=0;\n while (pos('8',s)<>0) do\n begin\n delete(s,1,pos('8',s));\n inc(num8);\n end;\n if (num8>(n div 11)) then num8:=n div 11;\n write(num8);\n readln;\nend."}, {"source_code": "program chat;\nvar ch:string;\n n,i,y,x:integer;\nbegin\n readln(n);\n readln(ch);\n x:=0;\n for i:=1 to n do\n begin\n if(ch[i]='8') then\n x:=x+1;\n end;\n y:=n div 11;\n while (y<>x) do\n begin\n if y>x then y:=y-1\n else\n x:=x-1;\n end;\n writeln(y)\n \nend. "}, {"source_code": "const fi ='a.INP';\n fo ='a.OUT';\nvar n: longint;\n s: string;\n\nprocedure main;\nvar i,a: longint;\nbegin\n a:=0;\n for i:=1 to n do if s[i]='8' then inc(a);\n n:=n div 11;\n if a>n then a:=n;\n write(a);\nend;\n\nbegin\n readln(n);\n read(s);\n main;\nend.\n\n"}, {"source_code": "Program A;\nVar n:longint;\n\ts:string;\n\tx,i,e:longint;\n\nBEGIN\n\treadln(n); readln(s);\n\n\te := 0;\n\tfor i := 1 to n do if s[i] = '8' then inc(e);\n\n\tif e * 11 > n then writeln(n div 11)\n \telse writeln(e);\nEND.\n"}, {"source_code": "var\n n,i:longint;\n ss:string;\n a:array[0..10]of longint;\nbegin\n readln(n);\n readln(ss);\n for i:=1 to n do\n inc(a[ord(ss[i])-48]);\n if n div 11>a[8] then writeln(a[8])\n else writeln(n div 11);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=998244353;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,d:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:int64);\n var tg:int64;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,c:longint;\n st:string;\n begin\n readln(fi,n);\n readln(fi,st);\n c:=0;\n for i:=1 to n do if st[i]='8' then inc(c);\n writeln(fo,min(n div 11,c));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,t,s,k:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "uses math;\nvar\n n,a,b,k:longint;\n s:string;\nbegin\n readln(n);\n a:=n div 11;\n readln(s);\n k:=pos('8',s);\n while k<>0 do\n begin\n inc(b);\n delete(s,k,1);\n k:=pos('8',s);\n end;\n writeln(min(a,b));\nend."}, {"source_code": "var k,n,x,y,i,code:integer;\ns:string;\nbegin\nk:=0;\nreadln(n);\nreadln(s);\n\nfor i:=1 to n do\n begin\n val(s[i],x,code);\n if x=8 then inc(k);\n end;\n y:=n div 11;\n if y(n div 11) then writeln(n div 11) else writeln(k); \nend."}, {"source_code": "uses math;\nvar\n ch:char;\n ans,n,i:longint;\nbegin\n readln(n);\n for i:=1 to n do begin read(ch);if ch='8' then inc(ans);end;\n writeln(min(n div 11,ans));\nend."}, {"source_code": "program pr1;\nvar n:string;\nk,i,a,s,b,c:integer;\nbegin\nreadln(k);\nreadln(n);\ns:=0;\nfor i:=1 to k do begin \nif n[i]='8' then s:=s+1;\nend;\nif (k div 11)>s then writeln(s)\nelse if (k div 11)(d div 11) then writeln (d div 11) else writeln (c);\nend."}, {"source_code": "var n,i,k,m,t:integer; s:char;\nbegin readln(n);\nfor i:=1 to n do begin read(s); if s='8' then k:=k+1 end;\nm:=n div 11;\nif k>m then t:=m else t:=k;\nwrite(t)\n\n\nend."}, {"source_code": "program _1060A;\n\nvar n, i, k: integer;\n s: String;\n \nbegin\n readln(n);\n readln(s);\n \n for i := 1 to n do\n if s[i] = '8' then inc(k);\n \n i := 0;\n \n if (k > 0) and (n >= 11) then\n begin\n while (k > 0) and (n >= 11) do\n begin\n dec(k);\n n := n - 11;\n inc(i);\n end;\n \n write(i);\n end\n else\n write(0);\nend."}, {"source_code": "var vsego,v,a,i,b:integer;\ns:string;\nbegin\nreadln(a);\nreadln(s);\nfor i:=1 to length(s) do\nbegin\nif s[i]='8' then \nbegin \nv:=v+1;\nend;\nend;\nvsego:=length(s);\nvsego:=vsego div 11;\nif vsego0) and (n>10) do\n begin\n k:=k-1;\n n:=n-11;\n j:=j+1;\n end;\nwriteln(j);\nend."}, {"source_code": "var k,j,i,n: integer; \na: char;\ns: string; \nbegin \nreadln(n); \nreadln(s); \nfor i:=1 to n do \nbegin \na:=s[i];\nif a='8' then k:=k+1; \nend;\nj:=n div 11;\nif j0) and (n>10) do \nbegin \nk:=k-1; \nn:=n-11; \nj:=j+1; \nend; \nwriteln(j); \nend."}], "negative_code": [{"source_code": "var n,m,k,i:longint; s:string; l,q:boolean;\nbegin\n l:=false;\n q:=false;\n readln(n);\n readln(s);\n m:=n div 11;\n for i:=1 to length(s) do\n if (s[i]='8') then l:=true;\n if (l=true) then writeln(m) else writeln('0');\nend."}, {"source_code": "var s:string;\nb,i,c,d:integer;\nbegin\nreadln (d);\nreadln (s);\nfor i:=1 to length(s) do\nif (s[i]='8') then c:=c+1;\nif c>(d div 10) then writeln (d div 10) else writeln (c);\nend."}, {"source_code": "var\n n,i,j,d,v:integer;\n c:string;\nbegin\n readln(n);\n readln(c);\n i:=0;\n if pos('8', c) <> 0\n then\n begin\n //for v:=1 to pos('8', c) do\n while length(c)>=11 do\n begin\n delete(c, pos('8', c), 1);\n d:=1;\n inc(i);\n for j:=1 to 10 do\n delete(c, d, 1)\n \n end;\n end;\n //else\n // writeln('0');\n writeln(i);\nend."}, {"source_code": "var k,j,i,n: integer; \na: char;\ns: string; \nbegin \nreadln(n); \nreadln(s); \nfor i:=1 to n do \nbegin \na:=s[i];\nif a='8' then k:=k+1; \nend;\nj:=n div 11;\nif j>k then writeln(j) else writeln(k);\nend."}, {"source_code": "var a,l,x,i,k:byte; st:string;\nbegin\nreadln(st);\nl:=length(st);\nx:=l div 11;\nfor i:=1 to l do\n if st[i]='8' then k:=k+1;\nif x*k=0 then a:=0 else if k>x then a:=k else a:=x;\nwrite(a);\nend."}, {"source_code": "var a,l,x,i,k:byte; st:string;\nbegin\nreadln(st);\nl:=length(st);\nx:=l div 11;\nfor i:=1 to l do\n if st[i]='8' then k:=k+1;\nif x*l=0 then a:=0 else if k>x then a:=k else a:=x;\nwrite(a);\nend."}, {"source_code": "var a,l,x,i,k:byte; st:string;\nbegin\nreadln(l);\nreadln(st);\nx:=l div 11;\nfor i:=1 to l do\n if st[i]='8' then k:=k+1;\nif x*k=0 then a:=0 else if k>x then a:=k else a:=x;\nwrite(a);\nend."}, {"source_code": "var a:array[1..101] of integer ;\n s1:string;\n i,m,n,k,y:integer;\n BEGIN\n read(n);\n read(s1);\n y:=length(s1);\n m:=n div 11;\n for i:=1 to y do if s1[i]='8' then k:=k+1;\n if k>=m then writeln(m) else writeln(k)\n END."}, {"source_code": "var n,res,num8:shortint;\n s:string;\nbegin\n readln(n);\n readln(s);\n res:=0;\n num8:=0;\n while (pos('8',s)<>0) do\n begin\n delete(s,1,pos('8',s));\n inc(num8);\n end;\n if num8=0 then\n begin\n write(0);\n readln;\n halt;\n end;\n if (num8>(n div 11)) then num8:=n div 11;\n res:=(n-num8) div 10;\n write(res);\n readln;\nend."}, {"source_code": "uses math;\nvar\n i,t:longint;\n s:ansistring;\nbegin\n readln(s);\n readln(s);\n t:=0;\n for i:=1 to length(s) do\n if s[i]='8' then\n t:=t+1;\n writeln(min(t,(length(s)-t)div 10));\nend."}, {"source_code": "uses math;\nvar\n i,t,maxn:longint;\n s:ansistring;\nbegin\n readln(s);\n readln(s);\n t:=0;\n for i:=1 to length(s) do\n if s[i]='8' then\n t:=t+1;\n for i:=1 to length(s) do\n maxn:=max(maxn,min(i,(length(s)-i)div 10));\n writeln(maxn);\nend."}, {"source_code": "uses math;\nvar\n i,t:longint;\n s:ansistring;\nbegin\n readln(s);\n readln(s);\n for i:=1 to length(s) do\n if s[i]='8' then\n t:=t+1;\n writeln(max(t,(length(s)-t)div 10));\nend."}], "src_uid": "259d01b81bef5536b969247ff2c2d776"} {"source_code": "var n,m,i,j,outp,b:integer;\na:array[1..9] of integer;\nbegin\noutp:=999;\nreadln(n,m);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to m do\nbegin\nread(b);\nfor j:=1 to n do\nif b=a[j] then\nbegin\nif bm2 then \n begin\n tl:=m1;\n m1:=m2;\n m2:=tl;\n end;\n write(m1,m2);\n end;\n \n\nend."}, {"source_code": "program qwerrty;\nvar n,otv,f,m,j,i,d:longint;\nl1,l2:boolean;\na,b:array [1..100] of longint;\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n for i:=0 to 100 do begin\n f:=i;\n while f<>0 do begin\n d:=f mod 10;\n for j:=1 to n do if d=a[j] then l1:=true;\n for j:=1 to m do if d=b[j] then l2:=true;\n f:=f div 10;\n end;\n if (otv=0) and l1 and l2 then otv:=i;\n l1:=false;\n l2:=false;\n end;\n writeln(otv);\nend."}, {"source_code": "program jdfh;\nvar a, b, i, j, t:integer; n:array [1..9] of integer;\nbegin\nread(a, b);\nfor i:=1 to a do begin\n read(t);\n n[t]:=n[t]+1;\nend;\nfor i:=1 to b do begin\n read(t);\n n[t]:=n[t]+2;\nend;\nfor i:=1 to 9 do\n if n[i]=3 then begin\n write(i);\n exit;\n end;\ni:=1;\nwhile n[i]<1 do i:=i+1;\nwrite(i);\nj:=1;\nwhile (n[j]=n[i]) or (n[j]=0) do j:=j+1;\nwrite(j);\nend.\n"}, {"source_code": "var n, m, min1, min2, i, k, j: byte;\n a, b: array [1..9] of byte;\n\nbegin\n Read (n, m);\n min1 := 10;\n min2 := 10;\n k := 0;\n \n for i := 1 to n do\n Read (a [i]);\n\n for i := 1 to m do\n Read (b [i]);\n \n for i := 1 to n do\n if a [i] < min1 then min1 := a [i];\n\n for i := 1 to m do\n if b [i] < min2 then min2 := b [i];\n\n if min1 = min2 then k := min1\n else if min1 > min2 then k := min2 * 10 + min1\n else k := min1 * 10 + min2;\n for i := 1 to n do\n for j := 1 to m do\n if (a [i] = b [j]) and (a [i] < k) then k := a [i];\n \n WriteLn (k);\nend.\n "}, {"source_code": "program beautifulNumbers;\nvar a,b: array[1..9] of integer;\n minFirst,minSecond,x,n,m,i,idential: longint;\nBEGIN\nreadln(n,m);\nminFirst:=10; minSecond:=10;\nfor i:=1 to n do begin\n read(x);\n a[x]:=1;\n if (xminSecond) then begin\n x:=minFirst; minFirst:=minSecond; minSecond:=x;\nend;\nidential:=0; i:=1;\nwhile (i<10) and (idential=0) do begin\n if (a[i]=1) and (b[i]=1) then idential:=i else i:=i+1;\nend;\nif (idential=0) then begin\n writeln(minFirst,minSecond);\nend else begin\n writeln(idential);\nend;\nEND.\n"}, {"source_code": "program mfs;\nuses math;\nvar\nta,tb:array[0..100]of boolean;\nn,m,i,j,ba,bb:longint;\nnum1,num2:longint;\na,b:array[0..100]of longint;\nbegin\nreadln(n,m);\nfillchar(ta,sizeof(ta),false);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do ta[a[i]]:=true;\nfillchar(tb,sizeof(tb),false);\nfor i:=1 to m do read(b[i]);\nfor i:=1 to m do tb[b[i]]:=true;\nnum1:=0;ba:=1231;bb:=1234;\nfor i:=1 to 9 do \tif ta[i] and tb[i] then begin writeln(i); halt; end;\nfor i:=1 to 9 do\n\tbegin\n\tif ta[i] then \n\t\tfor j:=i+1 to 9 do if tb[j] then begin ba:=i*10+j; break; end;\n\tif tb[i] then \n\t\tfor j:=i+1 to 9 do if ta[j] then begin bb:=i*10+j; break end;\n\tba:=min(ba,bb);\n\tif ba<100 then begin writeln(ba); halt; end;\n\tend;\nend."}, {"source_code": "var\nm,n,i,j,max,max2,x:integer;\na:array[1..10] of integer;\nb:array[1..10] of integer;\nbegin\nmax:=10;\nmax2:=10;\nx:=10;\nreadln (m,n);\nfor i:=1 to m do\n begin\n read (a[i]);\n end;\nfor j:=1 to n do\n begin\n read (b[j]);\n end;\n\n\nfor i:=1 to m do\n begin\n for j:=1 to n do\n begin\n if (a[i]=b[j]) and (a[i]max2 then writeln (max2,max)\n else writeln (max,max2);\n end \n else writeln (x);\n \nend.\n\n"}, {"source_code": "Var n,m,i,k,d,s,f:integer;\na:array[1..9] of integer;\nb:array[1..9] of integer;\nBegin\nReadln(n,m);\nd:=10;\nf:=10;\ns:=10;\nfor i:=1 to n do begin\nread(a[i]);\nif a[i]10 then writeln(d) else if s>f then writeln(f,s) else writeln(s,f);\n end."}, {"source_code": "program nomerA;\nvar n,m,i,k,min,g:integer;\nmass1:array [1..9] of integer;\nmass2:array [1..9] of integer;\nmass3:array [1..10000] of integer;\nbegin\nread(n,m);\nfor i:=1 to n do\nread(mass1[i]);\nfor i:=1 to m do\nread(mass2[i]);\nfor k:=1 to n do begin\nfor i:=1 to m do begin\ng:=g+1;\nif mass1[k] = mass2[i] \n then mass3[g]:=mass2[i]\n else \n mass3[g]:=10*mass1[k]+mass2[i];\nend;\nend;\nfor k:=1 to n do begin\nfor i:=1 to m do begin\ng:=g+1;\nif mass1[k] = mass2[i] \n then mass3[g]:=mass2[i]\n else \n mass3[g]:=mass1[k]+10*mass2[i];\nend;\nend;\nk:=g;\nmin:=mass3[1];\nfor i:=2 to k do \nif min > mass3[i] then min:=mass3[i];\nwriteln(min);\nend. \n"}, {"source_code": "Var\n n, m, min1, min2, min3: Int64;\n c1: Array [1..9] of Int64;\n c2: Array [1..9] of Int64;\n \nBegin\n min1 := 10000;\n min2 := 10000;\n min3 := 10000;\n Read(n, m);\n For Var i := 1 to n do Begin\n Read(c1[i]);\n If c1[i] < min1 then\n min1 := c1[i];\n End;\n For Var i := 1 to m do Begin\n Read(c2[i]);\n If c2[i] < min2 then\n min2 := c2[i];\n End;\n For Var i := 1 to n do\n For Var j := 1 to m do\n If (c1[i] = c2[j]) and (c1[i] < min3) then\n min3 := c1[i];\n If min3 <> 10000 then\n Write(min3)\n Else\n Write(min(min1, min2),max(min1, min2))\nEnd."}, {"source_code": "var i,n,m,g,j,c1,c2:integer;\na,b: array[1..10] of integer;\nbegin\nread(n,m);\ng:=10;\nc1:=10;\nc2:=10;\nfor i := 1 to n do \n begin\n read(a[i]);\n if(a[i]10)then writeln(g)\nelse if (c1>c2)then writeln(c2,c1)\n else writeln(c1,c2);\nend."}, {"source_code": "var a,b,c,d,e,f,g: integer;\nm: array [1..10] of integer;\nn: array [1..10] of integer;\nbegin\nd:=100;\nf:=10;\ng:=10;\nread(a);\nreadln(b);\nfor c:=1 to a do begin\nread(m[c]);\nif c=a then\nend;\nfor c:=1 to b do begin\nread(n[c]);\nif c=b then\nend;\nfor c:=1 to a do\nfor e:=1 to b do\nif m[c]=n[e] then\nif m[c]10 then begin\nfor c:=1 to a do\nif (m[c]0) then\nf:=m[c];\nfor c:=1 to b do\nif (n[c]0) then\ng:=n[c];\nif g>f then\nd:=f*10+g\nelse\nd:=g*10+f;\nend;\nwrite(d);\nend."}, {"source_code": "Uses math;\nConst\n fin='';\n fon='';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n\nType\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,mi,mii,m:longint;\n a,b:array[0..maxN] of longint;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti:longint;\nBegin\n mii:=10;\n mi:=10;\n Readln(fi,n,m);\n For i:=1 to n do\n Read(fi,a[i]);\n For i:=1 to m do\n Read(fi,b[i]);\nEnd;\n\nFunction co(x,y:longint):boolean;\nVar\n s,s1:ansistring;\n i,j:longint;\nBegin\n Str(x,s);\n Str(y,s1);\n For i:=1 to length(s) do\n For j:=1 to length(s1) do\n If s[i]=s1[j] then exit(true);\n Exit(false);\nEnd;\n\nProcedure xuly;\nVar\n i,j:longint;\n ok:boolean;\nBegin\n For i:=1 to 99 do\n Begin\n ok:=false;\n For j:=1 to n do\n If co(i,a[j]) then\n Begin\n ok:=true;\n break;\n End;\n If not ok then continue;\n For j:=1 to m do\n If co(i,b[j]) then\n Begin\n Writeln(fo,i);\n Exit;\n End;\n End;\nEnd;\n\nProcedure xuat;\nBegin\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND.\n\n"}, {"source_code": "var\n\tn, m, l, t, k: longint;\n\ta, b: array of integer;\n\t\nbegin\n\t\n\treadln(n, m);\n\tSetLength(a, n);\n\tSetLength(b, m);\n\t\n\tl := 10;\n\tt := 10;\n\tk := 10;\n\t\n\tfor var i := 0 to n - 1 do\n\tbegin\n\t\tread(a[i]);\n\t\tt := min(t, a[i]);\n\tend;\n\t\n\tfor var i := 0 to m - 1 do\n\tbegin\n\t\tread(b[i]);\n\t\tk := min(k, b[i]);\n\tend;\n\t\n\tfor var i := 0 to n - 1 do\n\t\tfor var j := 0 to m - 1 do\n\t\tbegin\n\t\t\tif (a[i] = b[j]) then\n\t\t\t\tl := min(l, a[i]);\n\t\tend;\n\t\n\t\n\tif (l <> 10) then\n\t\twriteln(l)\n\telse begin\n\t\tif (k = t) then\n\t\t\twriteln(k)\n\t\telse\n\t\t\twriteln(min(k, t), max(k, t));\n\tend;\n\t\nend.\n"}, {"source_code": "var n,m,i,min1,min2:longint;\n a,b,f:array[0..10] of longint;\nbegin\n readln(n,m);\n min1:=10;min2:=10;\n for i:=1 to n do \n begin\n read(a[i]); \n\tif a[i]1 then begin writeln(i); halt; end;\n if min1 a[i]*10 + b[j])then s:=a[i]*10+b[j]\nelse if (b[j]*10 +a[i] < a[i]*10 + b[j]) and (b[j]*10 +a[i] b[1]) then write(b[1],a[1])\n else\n write(a[1], b[1]);\n\nend.\n "}, {"source_code": "VAR n,m,i,j,min1,min2,s:integer;\np:boolean;\na:array[1..9] of integer;\nb:array[1..9] of integer;\nBEGIN\np:=false;\nreadln(n,m);\n\nread(a[1]);\nmin1:=a[1];\n\nfor i:=2 to n do begin\nread(a[i]);\nif a[i]<=min1 then min1:=a[i];\nend;\n\nread(b[1]);\nmin2:=b[1];\n\nfor i:=2 to m do begin\nread(b[i]);\nif b[i]<=min2 then min2:=b[i];\nend;\n\nfor i:=1 to n do\nfor j:=1 to m do\nif a[i]=b[j] then begin p:=true; s:=a[i]; break; end;\n\nfor i:=1 to n do\nfor j:=1 to m do\nif (a[i]=b[j]) and (a[i]minb then writeln(minb*10+mina)\nelse\nif minaminB) then\n write(minA+minB*10)\n else\n write(minB+minA*10);\n end\nelse\n write(zor);\n\n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "uses math;\nconst fi='';\nvar a:array[1..10] of longint;\n b:array[1..10] of longint;\n d:array[1..10] of boolean;\n n,m,a1,a2,i,j:longint;f:text;\nprocedure swap(var x,y:longint);\nvar w:longint;\nbegin\n w:=x;x:=y;y:=w;\nend;\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m);a1:=10;a2:=10;\n for i:=1 to n do read(f,a[i]);\n for i:=1 to m do read(f,b[i]);close(f);\n for i:=1 to n do a1:=min(a[i],a1);\n for i:=1 to m do a2:=min(b[i],a2);\n for i:=1 to m-1 do\n for j:=i+1 to m do if b[i]>b[j] then swap(b[i],b[j]);\n for i:=1 to n do d[a[i]]:=true;\n for i:=1 to m do if d[b[i]] then begin write(b[i]);halt;end;\n if a1=a2 then write(a1) else if a1>a2 then write(a2,a1)\n else write(a1,a2);readln\nend.\n"}, {"source_code": "program p1;\nvar i,n,m,min,max,x,y,k,j,q,o:integer;\na,b:array[0..11] of integer; \nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n q:=a[1];\n x:=a[1];\n y:=b[1];\n for i:=2 to n do if a[i]q then q:=a[i];\n //for i:=1 to n do writeln(a[i]);\n //writeln(x, ' ',y);\n for i:=1 to n do\n for j:=1 to m do if a[i]=b[j] then if o=0 then begin\n k:=a[i];\n o:=1;\n end else if k>a[i] then k:=a[i];\n if x>y then begin\n min:=y;\n max:=x\n end else begin\n min:=x;\n max:=y;\n end;\n if o<>0 then writeln(k) else if min=max then writeln(min) else writeln(min,max);\nend."}, {"source_code": "var n, m, ma, mb, mo, i, j : integer;\n a, b : array [1..9] of integer;\n\nbegin\n\n readln(n, m);\n \n ma := 9;\n mb := 9;\n mo := 10;\n \n for i := 1 to n do\n begin\n read(a[i]);\n if a[i] < ma then ma := a[i];\n end;\n \n for i := 1 to m do\n begin\n read(b[i]);\n if b[i] < mb then mb := b[i];\n end;\n for i := 1 to n do\n for j := 1 to m do\n if (a[i] = b[j]) and (a[i] < mo) then mo := a[i];\n\n if mo < 10 then writeln(mo)\n else if ma > mb then writeln(mb*10 + ma)\n else writeln(ma*10 + mb)\nend."}, {"source_code": "var\n i, j, n, m, k : integer;\n a, b : array [1..9] of integer;\nbegin\n read(n, m);\n for i := 1 to n do\n begin\n read(k);\n a[k] := 1;\n end;\n for i := 1 to m do\n begin\n read(k);\n b[k] := 1;\n end;\n for i := 1 to 9 do\n if (a[i] = 1) and (b[i] = 1) \n then\n begin\n writeln(i);\n exit;\n end;\n for i := 1 to 9 do\n for j := 1 to 9 do\n if (a[i] = 1) and (b[j] = 1)\n then\n begin\n if i > j \n then \n writeln(j, i) \n else \n writeln(i, j);\n exit;\n end;\nend."}, {"source_code": "var a,b: array[1..9] of integer;\nn,m,amin,bmin,ab,i,j:integer;\nq:boolean; \nbegin\nq:=false;\namin:=9;\nbmin:=9;\nab:=9;\nreadln(n,m);\nfor i:=1 to n do begin\nread(a[i]);\nend;\nfor i:=1 to m do begin\nread(b[i]);\nend;\nfor i:=1 to n do begin\nfor j:=1 to m do begin\nif (a[i]=b[j]) and (a[i]<=ab) then begin\nab:=a[i];\nq:=true;\nend;\nend;\nend;\namin:=a[1];\nbmin:=b[1];\nfor i:=1 to n do begin\nif a[i]<=amin then\namin:=a[i];\nend;\n\nfor i:=1 to m do begin\nif b[i]<=bmin then\nbmin:=b[i];\nend;\n\n\nif not q then begin\nif amin=bmin then begin\nwriteln(amin);\nend\nelse\nbegin\nif amin>bmin then begin\nwriteln(10*bmin+amin);\nend\nelse\nbegin\nwriteln(10*amin+bmin);\nend;\nend;\nend\nelse\nbegin\nwriteln(ab);\nend;\nend."}, {"source_code": "var a,b:array [1..9] of integer;\n n,m,i,j,mina,min,minb:integer;\nbegin\n read (n,m);\n mina:=10;\n minb:=10;\n min:=10;\n for i:=1 to n do begin\n read(a[i]);\n if mina> a[i] then mina:=a[i];\n end;\n for j:=1 to m do begin\n read(b[j]); \n if minb> b[j] then minb:=b[j];\n end;\n for i:=1 to m do \n for j:=1 to n do\n if a[j]= b[i] then if (a[j]< min) then min:=a[j];\n if min<>10 then write (min) else\n if mina>minb then write(minb,mina) else\n write(mina,minb);\nend."}, {"source_code": "var\n n,m,z,s,i,j:integer;\n a,b:array[1..9] of integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n read(a[i]);\n for j:=1 to m do\n read(b[j]);\n for i:=2 to n do begin\n z:=i;\n while a[z]>a[z-1] do begin\n s:=a[z];\n a[z]:=a[z-1];\n a[z-1]:=s;\n dec(z);\n if z=1 then break;\n end;\n end;\n for j:=2 to m do begin\n z:=j;\n while b[z]>b[z-1] do begin\n s:=b[z];\n b[z]:=b[z-1];\n b[z-1]:=s;\n dec(z);\n if z=1 then break;\n end;\n end;\n z:=10;\n for i:=1 to n do\n for j:=1 to m do\n if (a[i]=b[j]) and (z>a[i]) then z:=a[i];\n if z<10 then writeln(z) else \n if a[n]>b[m] then writeln(b[m],a[n]) else\n if a[n] 1) do\n inc(i);\n j := 0;\n while (b[j] <> 1) do\n inc(j);\n if (mid < maxint) then begin\n writeln(mid);\n exit;\n end;\n if (i < j) then\n write(i, j)\n else\n write(j, i); \n readln;\n readln;\nend.\n"}, {"source_code": "var i,j,n,m,min1,min2,count : integer;\narr1: array [1..10] of integer;\narr2: array [1..10] of integer;\nbegin\nmin1:=10;\nmin2:=10;\nread(n);\nread (m);\nreadln;\nfor i:=1 to n do\nbegin\nread(arr1[i]);\nend;\n\nfor i:=1 to m do\nbegin\nread(arr2[i]);\nend;\n\nfor i:=1 to n do\n for j:=1 to m do\n if (arr1[i]=arr2[j]) and (arr1[i]0 then\nbegin\nwrite(min1);\nexit;\nend;\n\nfor i:=1 to m do\nif (arr2[i]0) then\nmin2:=arr2[i];\nfor i:=1 to m do\nif (arr1[i]0) then\nmin1:=arr1[i];\n\nif min1>min2 then\nwrite (min2,min1);\nif min10) and (b[j]<>0)) \n then min:=a[i];\n if min<>10 then write(min)\n else begin\n \n minA:=10;\n for i:=1 to n do \n if a[i]Two then begin i:=One; One:=Two; Two:=i; end;\nwriteln(One,Two);\nEND."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\nVar\na:array of byte;\nan, bn, i, mina, minb, b, ab, j:byte;\n\nbegin\nread(an, bn);\nsetlength(a, an);\nmina:=10;\nminb:=10;\nab:=10;\nfor i:=0 to an-1 do\n begin\n read(a[i]);\n if a[i]< mina then\n mina:=a[i];\n end;\nfor i:=1 to bn do\n begin\n read(b);\n for j:=0 to an-1 do\n if (a[j]=b) and (b10 then\n write(ab) else\n if mina= 1) and (m >= 1) and (m <= 9) then\n begin\n min1 := 10;\n for i := 1 to n do\n begin\n read(a[i]);\n if (a[i] > 9) or (a[i] < 1) then\n begin\n l := 1;\n break;\n end;\n if a[i] < min1 then\n min1 := a[i];\n end;\n if l = 0 then\n begin\n min2 := 10;\n for i := 1 to m do\n begin\n read(b[i]);\n if (b[i] > 9) or (b[i] < 1) then\n begin\n l := 1;\n break;\n end;\n if b[i] < min2 then\n min2 := b[i];\n end;\n if l = 0 then\n begin\n k := 10;\n for i := 1 to n do\n for J := 1 to m do\n if (a[i] = b[j]) and (k > a[i]) then\n k := a[i];\n if (k < 10) then\n writeln(k)\n else\n if min1c[i]) then cmin:=c[i];\n \nif (cmin>0) then \nt:=cmin\n else \n begin\namin:=a[1];\nfor i:=1 to n do\nif (amin>a[i]) then amin:=a[i];\nbmin:=b[1];\nfor i:=1 to m do\nif (bmin>b[i]) then bmin:=b[i];\nif (amin=bmin) then\nt:=amin;\nif (amin>bmin) then\nt:=bmin*10+amin;\nif (amin 100 then write(mm) else if am < bm then writeln(am, bm) else writeln(bm, am);\nend."}, {"source_code": "program qq;\nvar n,m,i,c,amin,bmin,min:byte;\na,b: array [1..10] of integer;\nbegin\nmin:=10;\namin:=10;\nbmin:=10;\nreadln (n,m);\nfor i:=1 to n do begin\nread (a[i]);\nif a[i]a[i]) then cr:=a[i];\nend;end;end;\nif cr>0 then writeln(cr) else begin if min>min2 then writeln(min+min2*10)else writeln(min*10+min2);end;\nend."}, {"source_code": "var\nn,m:integer;\nar:array[1..9] of integer;\ni,ii:integer;\nx:integer;\na:integer;\nm1,m2:integer;\nsome:integer;\nbegin\nreadln(n,m);\nsome:=10;\nfor i:=1 to 9 do ar[i]:=10;\nm1:=-1; m2:=-1;\nfor i:=1 to n do begin\nread(x);\nar[i]:=x;\nif(m1=-1)or(m1>x)then m1:=x;\nend;\nfor i:=1 to m do begin\nread(x);\nfor ii:=1 to n do\nif(x=ar[ii])and(xx)then m2:=x;\nend;\nif(some<>10)then writeln(some) else\nif(m1m2)then writeln((m2*10+m1));\n\nend."}, {"source_code": "var s,j,min2,min,n,m,i:integer;\na:array[1..10] of integer;\nb:array[1..10] of integer;\nbegin\nread(n);\nread(m);\nfor i:=1 to n do\n read(a[i]);\nfor i:=1 to m do\n read(b[i]);\ns:=10; \nfor i:=1 to n do \nfor j:=1 to m do\n if (a[i]=b[j]) and (a[i]10 then writeln(s)\n else\n begin\n min:=a[1];\n for i:=2 to n do\n if min>a[i] then min:=a[i];\n min2:=b[1];\n for j:=2 to m do \n if min2>b[j] then min2:=b[j];\n \nif min=min2 then writeln(min2)\nelse\nif min 0 then\n begin\n if min11 > x then\n min11 := x;\n end\n else\n if min1 > x then\n min1 := x;\n i:=i+2;\n end;\n if min11 = 10 then\n begin\n i:=1;\n while i <= 2*m-1 do\n begin\n val(copy(s2, i, 1), x, code);\n if min2 > x then\n min2 := x;\n i:=i+2;\n end;\n if min1 > min2 then\n min := min2 * 10 + min1\n else\n min := min1 * 10 + min2;\n \n end\n else min := min11;\n writeln(min);\nend."}, {"source_code": "Program bbb;\nVar s1,s2:set of 1..9;\n a,min1,min2,n,m,i:byte;\nBegin\n Read(n,m);\n For i:=1 to n do\n Begin\n Read(a);\n If i=1 then min1:=a;\n If a arr2[j]) then min:=arr1[i];\n end; \n \nif n>m then begin\n for i:=1 to m do\n for j:=1 to n do\n if (arr2[i] = arr1[j]) and (min > arr1[j]) then min:=arr2[i];\n end;\n \nif n=m then begin\n for i:=1 to m do\n for j:=1 to n do\n if (arr2[i] = arr1[j]) and (min > arr1[j]) then min:=arr2[i];\n end; \n \nif min=10 then begin\n for i:=1 to m do \n if arr2[i] < min2 then min2:=arr2[i];\n for i:=1 to n do \n if arr1[i] < min1 then min1:=arr1[i];\n if min2 > min1 then write(min1,min2) else write(min2,min1);\n end \n else\n write(min);\nend.\n \n \n \n \n"}, {"source_code": "var\n n, m, i, j, min1, min2, j1, same: integer;\n a, b: array [1..9] of integer;\n\nbegin\n same := 10;\n min1 := 10;\n min2 := 10;\n read(n, m);\n \n for i := 1 to n do\n begin\n read(a[i]);\n if a[i] < min1 then min1 := a[i];\n end;\n \n for j := 1 to m do\n begin\n read(b[j]);\n if b[j] < min2 then min2 := b[j];\n for j1 := 1 to n do\n if a[j1] = b[j] then \n begin\n if b[j] < same then same:= b[j];\n \n end;\n end;\n \n if same <> 10 then writeln(same)\n else if min1 = min2 then writeln (min1)\n else if min1 < min2 then writeln(min1, min2)\n else if min1 > min2 then writeln(min2, min1)\n\n \nend."}, {"source_code": "var\n a, b: array [0..100] of integer;\n i, j, n, m, q, w, x: integer;\n\nbegin\n read(n, m);\n readln;\n for i := 0 to n - 1 do \n begin\n read(a[i]);\n end;\n readln;\n for j := 0 to m - 1 do \n begin\n read(b[j]);\n end;\n x:=3333;\n for i := 0 to n - 1 do begin\n for j := 0 to m - 1 do begin\n if(a[i]=b[j]) and (b[j] w) then \n write(10*w+q);\n \nend."}, {"source_code": "program a1;\nvar k,i,m,n,x,min:integer;\n a: array [1..9] of integer;\n b: array [1..9] of integer;\nBegin\n min:=99;\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n for i:=1 to n do\n begin\n for k:=1 to m do \n begin\n x:=(a[i]*10)+b[k];\n if (a[i]=b[k]) then x:=a[i];\n if xy then z:=y*10+x\n else z:=x;\n \n for i:=1 to n1 do\n begin\n \n for i1:=1 to n2 do\n begin\n \n if a[i]=b[i1] then \n begin\n \n if a[i] 0) and (a < n) then n:=a;\n if a < min2 then min2:=a;\n end;\n if n <> 10 then write(n)\n else if min1 < min2 then write(min1,min2)\n else if min1 > min2 then write(min2,min1);\nend."}, {"source_code": "program z1;\nvar a,b:array[1..9]of integer;i,m,n,p,k,h,j:integer;\nprocedure QuickSort( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := a[(l+r) div 2];\n repeat\n while (A[i] < x) do inc(i);\n while (x < A[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=A[i]; a[i]:=a[j]; a[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nprocedure QuickSort1( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := b[(l+r) div 2];\n repeat\n while (b[i] < x) do inc(i);\n while (x < b[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort1(l,j);\n if (i < r) then QuickSort1(i,r);\nend;\nfunction min(k,h:integer):integer;\nbegin\nif k>h then min:=h\nelse min:=k;end;\nfunction max(n,m:integer):integer;\nbegin\nif ny then begin\n x:=x+y;\n y:=x-y;\n x:=x-y;\n end;\n write(x,y);\n end;\n end.\n\n"}, {"source_code": "var a,b:array[1..9] of longint;\ni,j,m,n,k:longint;\nfunction min(a,b:longint):longint;\nbegin\nmin:=a;\nif a>b then min:=b;\nend;\nBEGIN\nread(m,n);\nk:=100;\nfor i:=1 to m do\nread(a[i]);\nfor j:=1 to n do\nread(b[j]);\nfor i:=1 to m do\nfor j:=1 to n do\nbegin\nk:=min(k,a[i]*10+b[j]);\nk:=min(k,b[j]*10+a[i]);\nif a[i]=b[j] then k:=min(k,a[i]);\nend;\nwrite(k)\nend."}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,kk,ii,xx,yy,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k,i2,i3,i1,j1,k1, step, i,j:longint;\n s0,s1,aanew,bbnew:extended;\n sa,sb,sia,sib,s,d11,a,b,right,aold,left,z,x,newc,d,c,nap:array[-10..1000001] of int64;\n y:array[-10..10000000] of extended;\n d1,ddd,dd:array[-10..100,0..100,0..100] of int64;\n ddminus, ppole:array[-1..2000,-100..1502] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n ddd1:array[-1..400000,-1..10] of int64;\n marked:array[-100..500,-100..500] of boolean;\n {sss:string;ch:char;\n } pole :array [-10..500,-10..500] of char;\n st:array[0..nn] of string;\n stest1,ss:string;\n v0,v1,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\n\n\n\nbegin\n { assign (input,'F:\\Projects\\input.txt');reset(input);\n assign (output,'F:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n\n t:=10000;\n for i:=1 to n do for j:=1 to m do if a[i]=b[j] then\n begin t:=min(t,a[i]); flag:=true; end;\n\n if flag then begin writeln(t); goto 1; end;\n\n t1:=1000;\n t2:=1000;\n for i:=1 to n do t1:=min(t1,a[i]);\n\n for i:=1 to m do t2:=min(t2,b[i]);\n\n if t1i then x:=i*10+x\n else if i>x then x:=x*10+i;\n for i:=1 to 9 do\n if (a[i]=1) and (b[i]=1) then\n if x>i then\n begin\n x:=i;\n break;\n end; \n writeln(x);\nend."}, {"source_code": "var a,b:array[0..9]of boolean;\n n,m,x,y,i,j:longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n read(x);\n a[x]:=true;\n end;\n for i:=1 to m do\n begin\n read(x);\n b[x]:=true;\n end;\n for i:=1 to 9 do\n if a[i] and b[i] then\n begin\n writeln(i);\n halt;\n end;\n for i:=1 to 9 do\n if a[i] then\n begin\n x:=i;\n break;\n end;\n for i:=1 to 9 do\n if b[i] then\n begin\n if x>i then writeln(i,x)\n else writeln(x,i);\n halt;\n end;\nend."}, {"source_code": "program marvel;\n\nvar\n a:array[1..10] of Integer;\n b:array[1..10] of Integer;\n i,l,k,n,m,k1,x: Integer;\nbegin\n Read(n,m);\n k1:=10;\n k:=10;\n for i:=1 to n do\n begin\n Read(a[i]);\n if a[i] 0 then\n begin\n writeln(min3);\n exit;\n end;\n min1 := 10;\n min2 := 10;\n for i := 0 to n-1 do\n begin\n if n1[i] < min1 then\n min1 := n1[i] \n end;\n for j := 0 to m-1 do\n begin\n if m1[j] < min2 then\n min2 := m1[j] \n end;\n itog1 := (min1 * 10) + min2;\n itog2 := (min2 * 10) + min1;\n \n if itog1 < itog2 then\n writeln(itog1)\n else\n writeln(itog2); \nend."}, {"source_code": "var\nbol:boolean;\nind,n,m,i,x,j:longint;\na,b:array[-100..10000]of longint;\nbegin\nreadln(n,m);\nfor i:=1 to n-1 do read(a[i]);\nreadln(a[n]);\nfor i:=1 to m do read(b[i]);\n\nfor i:=1 to n-1 do\nfor j:=i+1 to n do\nif a[i]>a[j] then begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\nend;\n\nfor i:=1 to m-1 do\nfor j:=i+1 to m do\nif b[i]>b[j] then begin\n x:=b[i];\n b[i]:=b[j];\n b[j]:=x;\nend;\n\nfor i:=1 to n do begin\nfor j:=1 to m do if a[i]=b[j] then begin\n bol:=true;\n ind:=i;\n break;\nend;\nif bol then break;\nend;\nif bol then writeln(a[ind])\n\nelse begin\n if a[1]=Bmin then writeln(Bmin,Amin) \n else writeln(Amin,Bmin);\n END\n else begin\n Min(C,k,Cmin);\n writeln (Cmin);\n end;\nend. "}, {"source_code": "var\n n,n1,i,k,k1,i1,kr,nr:integer;\n x,x1,xr:array of integer;\n b:boolean;\nbegin\n read(n,n1);\n \n SetLength(x,n);\n SetLength(x1,n1);\n for i:=0 to n-1 do\n begin\n read(x[i]);\n end;\n for i:=0 to n1-1 do\n begin\n read(x1[i]);\n end;\n k:=x[0];\n k1:=x1[0];\n \n\n for i:= 1 to n-1 do\n begin\n if x[i]k1 then write(k1*10+k) else write(k*10+k1);\n end;\n \n if b then write (kr);\n \nend.\n"}, {"source_code": "program Project1;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes, SysUtils, CustApp\n { you can add units after this };\nvar\n min1, min2, min3, n, m, i, j: integer;\n a, b: array [1..1000000] of integer;\nbegin\n min1:=10;\n min2:=10;\n min3:=10;\n read (n, m);\n for i:=1 to n do\n begin\n read (a[i]);\n if (a[i]10) then writeln (min3)\n else\n begin\n if (min1>min2) then writeln (min2, min1)\n else writeln (min1, min2);\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "Var a, b, i, k, l, c, d: integer;\nm, n: array [1..9] of integer;\nBegin\nread (a, b);\nk:=10;\nl:=10;\nd:=10;\nfor i:= 1 to a do\nbegin\n read (n[i]);\n if n[i]l then\n writeln (l*10+k);\n end\n else writeln (d)\nend."}, {"source_code": "var a,b,i,c,min,j:shortint;\n MLP,FIM: array [1..10] of shortint;\nbegin\n read(a,b);\n for i:=1 to a do read(MLP[i]);\n for i:=1 to b do read(FIM[i]);\n for i:=1 to a-1 do\n for j:=1 to a-i do \n if (MLP[j+1]=b then\nwrite(b,a)\n\nelse\nwrite(a,b)\nend.\n"}, {"source_code": "var\nm,n,i,j,min1,min2,s:integer;\na,b:array [1..9] of integer;\nbegin\nreadln(n,m);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to m do\nread(b[i]);\n\ns:=10;\nfor i:=1 to n do begin\nfor j:=1 to m do\nif (a[i]=b[j]) and (a[i]10 then writeln(s) else\nbegin\nmin1:=a[1];\nfor i:=2 to n do\nif min1>a[i] then min1:=a[i];\nmin2:=b[1];\nfor i:=2 to m do\nif min2>b[i] then min2:=b[i];\n\nif min1=min2 then writeln(min1) else\nif min11 then\n begin\n writeln(i);\n exit;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if b[i]>b[j] then\n begin\n t:=b[i];b[i]:=b[j];b[j]:=t;\n end;\n writeln(min(a[1],b[1]),max(a[1],b[1]));\nend."}], "negative_code": [{"source_code": "Program P1;\nvar n,m,i,a,b,i2,e,e2: integer; a1,a2: array [0..1000] of integer; \nbegin\na:=9; b:=9; e:=9;\nreadln(n,m);\nfor i:= 1 to n do \nread(a1[i]);\n\nfor i:= 1 to m do \nread(a2[i]); \n\nfor i:= 1 to n do begin\nif a1[i] q[c]) then\nbegin\ne:= q[c];\nwrite(e);\nend;\n\nend;\nend;\nif (e = 10) then\nbegin\nfor z:= 1 to a do\nbegin\nif (mina > q[z]) then\nmina:= q[z];\nend;\nfor x:= 1 to b do\nbegin\nif (minb > w[x]) then\nminb:= w[x];\nend;\n\nif (minb > mina) then\nwrite(mina, minb)\nelse\nwrite(minb, mina);\nend;\nend."}, {"source_code": "var i,n,m,minn,minm:integer;\n a,b:array[1..9]of integer;\nbegin\n readln(n,m);\n minn:=9;\n minm:=9;\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]minm then writeln(minm,minn);\n if minn=minm then writeln(minn);\nend."}, {"source_code": "var\n n, m, i, j, min1, min2, j1, same: integer;\n a, b: array [1..9] of integer;\n\nbegin\n same := 10;\n min1 := 10;\n min2 := 10;\n read(n, m);\n \n for i := 1 to n do\n begin\n read(a[i]);\n if a[i] < min1 then min1 := a[i];\n end;\n \n for j := 1 to m do\n begin\n read(b[j]);\n if b[j] < min2 then min2 := b[j];\n for j1 := 1 to n do\n if a[j1] = b[j] then \n begin\n if b[j] < same then same:= b[j];\n \n end;\n end;\n \n if same <> 0 then writeln(same)\n else if min1 = min2 then writeln (min1)\n else if min1 < min2 then writeln(min1, min2)\n else if min1 > min2 then writeln(min2, min1)\n\n \nend."}, {"source_code": "program niceCount;\nvar\n n, m, i, x, y: integer;\n arrn, arrm: array of integer;\nbegin\n read(n, m);\n setLength(arrm, m);\n setLength(arrn, n);\n x:= 10;\n y:= 10;\n for i:= 0 to n-1 do read(arrn[i]);\n for i:= 0 to m-1 do read(arrm[i]);\n for i:= 0 to n-1 do\n if arrn[i]0)or(y=0)and(x<>0) then write(x, y)\n else if (y0)or(x=0)and(y<>0) then write(y, x)\n else write(y);\n read(n);\nend.\n"}, {"source_code": "\nprogram chisla;\n\nvar\n n, m, min1,min2,mind,j,i: integer;\n a: array[1..9] of integer;\n b: array[1..9] of integer;\n \n\nbegin\n Read(n, m);\n for i := 1 to n do\n Read(a[i]);\n for i := 1 to m do\n Read(b[i]);\n min1:=10;\n min2:=10;\n mind:=10;\n for i:=1 to n do\n if a[i] 0)do\n begin\n v := x mod 10;\n for i := 1 to n do\n if (v = a[i])then\n begin\n z := 1;\n break;\n end;\n x := x div 10;\n if (z = 1)then break;\n end;\n x := k;\n while(x <> 0)do\n begin\n v := x mod 10;\n for i := 1 to n do\n if (v = b[i])then\n begin\n c := 1;\n break;\n end;\n x := x div 10;\n if (c = 1)then break;\n end;\n if ((z = 1) and (c = 1))then break;\n end;\n writeln(k);\nend.\n"}, {"source_code": "program n1;\nvar q,n,m,i,u,amin,bmin,cmin,t:integer;\n a,b,c: array [1..9] of integer;\nbegin;\nread (n,m);\nreadln;\nfor i:=1 to n do\nread (a[i]); \nreadln;\nfor i:=1 to n do\nread (b[i]);\nfor i:=1 to n do \n\nq:=1;\nfor i:=1 to n do\n for u:=1 to m do\n if (a[i]=b[u]) then\n begin\n c[q]:=a[i];\n q:=q+1;\n end;\n \ncmin:=c[1]; \nif (cmin>a[q]) then amin:=c[i]; \n \nif (cmin>0)\nthen t:=cmin\n else \n begin\namin:=a[1]; \nif (amin>a[i]) then amin:=a[i];\nbmin:=b[1];\nfor i:=1 to m do\nif (bmin>b[i]) then bmin:=b[i];\nif (amin=bmin) then\nt:=amin;\nif (amin>bmin) then\nt:=bmin*10+amin;\nif (amin a[i]*10 + b[j])then s:=a[i]*10+b[j]\nelse if (b[j]*10 +a[i] < a[i]*10 + b[j]) then s:=b[j]*10 + a[i];\nif (a[i]=b[j]) and (a[i] arr2[j]) then min:=arr1[i];\n end; \n \nif n>m then begin\n for i:=1 to m do\n for j:=1 to m do\n if (arr2[i] = arr1[j]) and (min > arr1[j]) then min:=arr2[i];\n end;\n \nif min=10 then begin\n for i:=1 to m do \n if arr2[i] < min2 then min2:=arr2[i];\n for i:=1 to n do \n if arr1[i] < min1 then min1:=arr1[i];\n if min2 > min1 then write(min1,min2) else write(min2,min1);\n end \n else\n write(min);\nend.\n \n \n \n \n"}, {"source_code": "type mas=array[1..10] of integer;\nvar\n\na,b:mas;\nflag,flag2:boolean;\ni,j,m,n:integer;\n\nBEGIN\n readln(n, m);\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n for i:=1 to m do\n begin\n read(b[i]);\n end;\n for i:=1 to 98 do\n begin\n if i>=10 then\n begin\n flag:=false;\n for j:=1 to n do\n begin\n if a[j]=i mod 10 then flag:=true;\n end;\n flag2:=false;\n for j:=1 to m do\n begin\n if a[j]=i div 10 then flag2:=true;\n end;\n if flag and flag2 then\n begin\n writeln(i);\n break;\n end;\n end\n else\n begin\n flag:=false;\n for j:=1 to n do\n begin\n if a[j]=i then flag:=true;\n end;\n flag2:=false;\n for j:=1 to m do\n begin\n if a[j]=i then flag2:=true;\n end;\n if flag and flag2 then\n begin\n writeln(i);\n break;\n end;\n end;\n end;\nEND."}, {"source_code": "program z1;\nvar a,b:array[1..9]of integer;i,m,n,p,k,h:integer;\nprocedure QuickSort( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := a[(l+r) div 2];\n repeat\n while (A[i] < x) do inc(i);\n while (x < A[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=A[i]; a[i]:=a[j]; a[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nprocedure QuickSort1( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := b[(l+r) div 2];\n repeat\n while (b[i] < x) do inc(i);\n while (x < b[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nfunction min(k,h:integer):integer;\nbegin\nif k>h then min:=h\nelse min:=k;end;\nbegin\nread(n,m);\nfor i:=1 to n do\nread(a[i]);quicksort(1,n);\nfor i:=1 to m do read(b[i]);\nquicksort1(1,m);\nk:=a[1]*10+b[1];\nh:=b[1]*10+a[1];\np:=min(k,h);\n\nfor i:=1 to n do\nif a[i]=b[i] then if a[i]

b then min:=b;\nend;\nBEGIN\nread(m,n);\nk:=100;\nfor i:=1 to m do\nread(a[i]);\nfor j:=1 to n do\nread(b[i]);\nfor i:=1 to m do\nfor j:=1 to n do\nbegin\nif a[i]<>0 then k:=min(k,a[i]*10+b[j]);\nif b[j]<>0 then k:=min(k,b[j]*10+a[i]);\nif a[i]=b[j] then k:=min(k,a[i]);\nend;\nwrite(k)\nend."}, {"source_code": "var\n n, m, i, j, min1, min2, k: integer;\n a: array [1..9] of integer;\n b: array [1..9] of integer;\n\nbegin\n read(n, m);\n read(a[1]);\n min1 := a[1];\n for i := 2 to n do\n begin\n read(a[i]);\n if a[i] < min1 then\n min1 := a[i];\n end;\n read(b[1]);\n min2 := b[1];\n for i := 2 to m do\n begin\n read(b[i]);\n if b[i] < min2 then\n min2 := b[i];\n end;\n k := 10;\n for i := 1 to n do\n for J := 1 to m do\n if (a[i] = b[j]) and (k > a[i]) then\n k := a[i];\n if (k < 10) then\n writeln(k)\n else\n writeln(min1, min2);\nend."}, {"source_code": "\nvar a,b:array[1..10]of integer;\nn,i,k,m,j,sw:integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to m do\n read(b[i]);\n for j:=1 to n-1 do\n for i:=1 to n-1 do\n if a[i] > a[i+1] then\n begin\n sw:=a[i];\n a[i]:=a[i+1];\n a[i+1]:=sw;\n end;\n for j:=1 to m-1 do\n for i:=1 to m-1 do\n if b[i] > b[i+1] then\n begin\n sw:=b[i];\n b[i]:=b[i+1];\n b[i+1]:=sw;\n end;\n i:=1;\n if a[1] > b[1] then\n begin\n while (a[i] <> b[1])and(i < n) do\n i:=i+1;\n if i <> 1 then\n if i <> n then\n k:=b[1]\n else\n k:=b[1]*10+a[1]\n else\n if a[1] = b[1] then\n k:=a[1];\n\n end\n else\n begin\n while (a[1] <> b[i])and(i < m) do\n i:=i+1;\n if i <> 1 then\n if i <> m then\n k:=a[1]\n else\n k:=a[1]*10+b[1]\n else\n if a[1] = b[1] then\n k:=a[1];\n\n end;\n writeln(k);\nend."}, {"source_code": "Program cg;\n var n,m,i,a,mina,minb,b,k:integer;\n begin\nread(n);\nreadln(m);\nmina:=10;\nminb:=10;\nFor i:=1 to n do begin\n read(a);\n if aminb then k:=minb*10+mina;\nif minb>mina then k:=mina*10+minb;\nif mina=minb then k:=mina;\nwriteln(k);\nend.\n "}, {"source_code": "Program cg;\n var n,m,i,a,mina,minb,b,k:integer;\n begin\nread(n);\nreadln(m);\nmina:=9;\nminb:=9;\nFor i:=1 to n do begin\n read(a);\n if aminb then k:=minb*10+mina;\nif minb>mina then k:=mina*10+minb;\nif mina=minb then k:=mina;\nwriteln(k);\nend.\n "}, {"source_code": "program Ann;\nvar n,m,min1,min2,i,j:integer;\na,b:array[1..10]of integer;\nbegin\nreadln(n,m);\nmin1:=357;\nmin2:=357;\nfor i:=1 to n do\n begin\n read(a[i]);\n if(a[i] < min1)then\n min1:=a[i];\n end;\nfor i:=1 to m do\n begin\n read(b[i]);\n if(b[i] < min2)then\n min2:=b[i];\n end;\nif(min1 = min2)then\n writeln(min1)\nelse\nif(min1 < min2)then\n if(min1 = 0)then\n writeln(min2)\n else\n writeln(min1,min2)\nelse\n if(min2 = 0)then\n writeln(min1)\n else\n writeln(min2,min1);\nend."}, {"source_code": "var n,m,a,i,j,min1,min2,min: byte;\narr1, arr2 : array[1..10] of byte;\nbegin\nreadln(n, m);\nmin1:=10;\nmin2:=10;\nmin:=10;\nfor i:=1 to n do\n read(arr1[i]);\n \nfor i:=1 to m do\n read(arr2[i]);\n \nif n arr2[j]) then min:=arr1[i];\n end; \n \nif n>m then begin\n for i:=1 to m do\n for j:=1 to m do\n if (arr2[i] = arr1[j]) and (min > arr1[j]) then min:=arr2[i];\n end;\n \nif n=m then begin\n for i:=1 to m do\n for j:=1 to n do\n if (arr2[i] = arr1[j]) and (min > arr1[j]) then min:=arr2[i];\n end; \n \nif min=10 then begin\n for i:=1 to m do \n if arr2[i] < min2 then min2:=arr2[i];\n for i:=1 to n do \n if arr1[i] < min1 then min1:=arr1[i];\n if min2 > min1 then write(min1,min2) else write(min2,min1);\n end \n else\n write(min);\nend.\n \n \n \n \n"}, {"source_code": "var a,b:array [1..9] of integer;\n n,m,i,j,mina,min,minb:integer;\nbegin\n read (n,m);\n mina:=10;\n minb:=10;\n min:=10;\n for i:=1 to n do begin\n read(a[i]);\n if mina> a[i] then mina:=a[i];\n end;\n for j:=1 to m do begin\n read(b[j]); \n if minb> b[j] then minb:=b[j];\n end;\n for i:=1 to m do \n for j:=1 to n do\n if a[j]= b[i] then if (a[j]< min) then min:=a[j];\n if min<>10 then write (min) else\n write(mina,minb);\nend."}, {"source_code": "\tvar n, m,min1,min2,i:integer;\n a:array[1..10] of integer;\n\tb:array[1..10] of integer;\n\t\n\tbegin\n\tmin1:=10;min2:=10;\n\tread(n,m);\n\tfor i:=1 to n do\n (read(a[i]));\n\tfor i:=1 to m do\n (read(b[i]));\n\tfor i:=1 to n do\n if (a[i]10 then\n write(min3)\n else\n write(min(min1,min2),max(min1,min2));\n end."}, {"source_code": "var a,b:array[1..9] of longint;\ni,j,m,n,k:longint;\nfunction min(a,b:longint):longint;\nbegin\nmin:=a;\nif a>b then min:=b;\nend;\nBEGIN\nread(m,n);\nk:=100;\nfor i:=1 to m do\nread(a[i]);\nfor j:=1 to n do\nread(b[i]);\nfor i:=1 to m do\nfor j:=1 to n do\nbegin\nif a[i]<>0 then k:=min(k,a[i]*10+b[j]);\nif b[j]<>0 then k:=min(k,b[j]*10+a[i]);\nif a[i]=b[j] then k:=min(k,a[i]);\nend;\nwrite(k)\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n mi1, mi2, i, j, n, m: integer;\n a, b: array [1..100] of integer;\n\nbegin\n read(n, m);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to m do\n read(b[i]);\n for i := 1 to n do\n for j := 1 to m do\n if (a[i] = b[j]) then begin\n write(a[i]);\n exit;\n end;\n mi1 := a[1];\n for i := 2 to n do\n if (a[i] < mi1) then\n mi1 := a[i];\n mi2 := b[1];\n for j := 1 to m do\n if (b[j] < mi2) then\n mi2 := b[j];\n write(min(mi1, mi2), max(mi1, mi2));\n readln;\n readln;\nend.\n"}, {"source_code": "Program sdfg;\n var mina, minb,i,k,minc,n,m:integer;\n A: array [1..9] of integer;\n B: array [1..9] of integer;\n begin\nmina:=9;\nminb:=9;\nminc:=10;\nread(n);\nreadln(m); \n for i:= 1 to n do begin\n read(a[i]); \n if a[i]= 1) and (m >= 1) and (m <= 9) then\n begin\n min1 := 10;\n for i := 1 to n do\n begin\n read(a[i]);\n if (a[i] > 9) or (a[i] < 1) then\n begin\n l := 1;\n break;\n end;\n if a[i] < min1 then\n min1 := a[i];\n end;\n if l = 0 then\n begin\n min2 := 10;\n for i := 1 to m do\n begin\n read(b[i]);\n if (b[i] > 9) or (b[i] < 1) then\n begin\n l := 1;\n break;\n end;\n if b[i] < min2 then\n min2 := b[i];\n end;\n if l = 0 then\n begin\n k := 10;\n for i := 1 to n do\n for J := 1 to m do\n if (a[i] = b[j]) and (k > a[i]) then\n k := a[i];\n if (k < 10) then\n writeln(k)\n else\n writeln(min1, min2);\n end;\n end;\n end;\nend."}, {"source_code": "program z1;\nvar a,b:array[1..9]of integer;i,m,n,p,k,h,j:integer;\nprocedure QuickSort( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := a[(l+r) div 2];\n repeat\n while (A[i] < x) do inc(i);\n while (x < A[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=A[i]; a[i]:=a[j]; a[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nprocedure QuickSort1( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := b[(l+r) div 2];\n repeat\n while (b[i] < x) do inc(i);\n while (x < b[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nfunction min(k,h:integer):integer;\nbegin\nif k>h then min:=h\nelse min:=k;end;\nbegin\nread(n,m);\nfor i:=1 to n do\nread(a[i]);quicksort(1,n);\nfor i:=1 to m do read(b[i]);\nquicksort1(1,m);\nk:=a[1]*10+b[1];\nh:=b[1]*10+a[1];\np:=min(k,h);\nfor j:=1 to n do\nfor i:=1 to n do\nif a[j]=b[i] then if a[i]

w) then begin\n write(10*w+q);\n end;\nend."}, {"source_code": "program ne3;\nvar i, n,a,b, m,mina,minb:integer;\n\nbegin\nread(n,m);\nmina:=9;\nminb:=9;\nfor i:=1 to n do\nbegin\nread(a);\nif aminb then writeln(minb*10+mina)\nelse\nif mina 0) then\n writeln(x)\n else\n if (min1 = min2) then\n writeln(min1)\n else\n writeln(min(min1, min2), max(min1, min2)); readln;readln;\nend.\n"}, {"source_code": "program x1;\nvar q,n,m,min1,min2,i:integer;\nbegin\nreadln(n,m);\nread(q);\nmin1:=q;\nfor i:=1 to n-1 do begin\nread(q);\nif qmin2 then write(min2,min1) else write(min1,min2);\nend."}, {"source_code": "var\ns,c:string;\na,b:array[1..10]of integer;\nn,m,i,mina,minb,j:integer;\nbegin\nread(n,m);\nmina:=9;\nminb:=9;\nfor i:= 1 to n do begin\nread(a[i]);\nif a[i]minb then begin str(mina,s);str(minb,c);writeln(c+s);exit;end;\nif mina0) then\nmin1:=a;\nend;\nfor i:=1 to m do\nbegin\nread(b);\nif (b0) then\nmin2:=b;\nend;\nif min1=min2 then\nwrite(min1);\nif min1>min2 then\nwrite (min2,min1);\nif min1min2 then\n begin\n min:=min2-min;\n min2:=min2-min;\n min:=min2+min;\n end;\n writeln(min*10+min2);\n end;\nend. \n \n "}, {"source_code": "Program cg;\n var n,m,i,a,mina,minb,b,k:integer;\n begin\nread(n);\nreadln(m);\nmina:=10;\nminb:=10;\nFor i:=1 to n do begin\n read(a);\n if aminb then k:=minb*10+mina;\nif minb>mina then k:=mina*10+minb;\nif mina=minb then k:=mina;\nwriteln(k);\nend.\n "}, {"source_code": "var\na,b:array [1..9] of integer;\nm,n,i,j,m1,m2,x:integer;\nq:boolean;\nbegin\nm1:=10;\nm2:=10;\nreadln(n,m);\nq:=false;\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to m do\nread(b[i]);\nfor i:=1 to n do\nbegin\nfor j:=1 to m do\nif (a[i]=b[j]) and (a[i]bmin then begin\nwriteln(10*bmin+amin);\nend\nelse\nbegin\nwriteln(10*amin+bmin);\nend;\nend;\n\nend."}, {"source_code": "var\nn,m,i,j,min1,min2:integer;\na:array[1..100] of integer;\nb:array[1..100] of integer;\nbegin\nmin1:=10;\nmin2:=10;\nread(n);\nread(m);\nfor i:=1 to n do\nread(a[i]);\nfor j:=1 to m do\nread(b[j]);\nfor i:=1 to n do\nif (a[i] j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nprocedure QuickSort1( L, R : Integer ); { Быстрая сортировка массива A[] }\nvar i,j,x,y,m: integer;\nbegin\n i := l; j := r;\n x := b[(l+r) div 2];\n repeat\n while (b[i] < x) do inc(i);\n while (x < b[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nfunction min(k,h:integer):integer;\nbegin\nif k>h then min:=h\nelse min:=k;end;\nfunction max(n,m:integer):integer;\nbegin\nif n 0)do\n begin\n v := x mod 10;\n for i := 1 to n do\n if (v = a[i])then\n begin\n z := 1;\n break;\n end;\n x := x div 10;\n if (z = 1)then break;\n end;\n x := k;\n while(x <> 0)do\n begin\n v := x mod 10;\n for i := 1 to n do\n if (v = b[i])then\n begin\n c := 1;\n break;\n end;\n x := x div 10;\n if (c = 1)then break;\n end;\n if ((z = 1) and (c = 1))then break;\n end;\n writeln(k);\nend.\n"}, {"source_code": "program cras;\nvar n,m,x,i: integer;\n a,b: array [1..9] of integer;\nbegin\n for i:=1 to 9 do\n begin\n a[i]:=0;\n b[i]:=0;\n end;\n read(n,m);\n for i:=1 to n do\n begin\n read(x);\n a[x]:=1;\n end;\n for i:=1 to m do\n begin\n read(x);\n b[x]:=1;\n end;\n i:=1;\n while(a[i]=0) do i:=i+1;\n x:=1;\n while(b[x]=0) do x:=x+1;\n if x>i then x:=i*10+x\n else if i>x then x:=x*10+i;\n writeln(x);\nend."}, {"source_code": "var a,b: array[1..9] of integer;\nn,m,amin,bmin,i:integer; \nbegin\namin:=9;\nbmin:=9;\nreadln(n,m);\nfor i:=1 to n do begin\nread(a[i]);\nend;\nfor i:=1 to m do begin\nread(b[i]);\nend;\nfor i:=1 to n do begin\nif a[i]<=amin then\namin:=a[i];\nend;\n\nfor i:=1 to m do begin\nif b[i]<=bmin then\nbmin:=b[i];\nend;\n\nif amin=bmin then begin\nwriteln(amin);\nend\nelse\nbegin\nif amin>bmin then begin\nwriteln(10*bmin+amin);\nend\nelse\nbegin\nwriteln(10*amin+bmin);\nend;\nend;\n\nend."}, {"source_code": " var n,m,i,j,z,min1,min2:longint;\n a1,a2:array [1..9] of byte;\nbegin\n readln(n,m);\n for i:=1 to n do\n read(a1[i]);\n readln;\n min1:=a1[1];\n for i:=2 to n do\n if a1[i]min2 then\n writeln(min2,min1);\n if min1 min1) then writeln(min1*10+min2);\n if (min2 < min1)then writeln(min2*10+min1);\n end;\nEnd."}, {"source_code": "var n,m,i,j,outp,b:integer;\na:array[1..9] of integer;\nbegin\noutp:=10;\nreadln(n,m);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to m do\nbegin\nread(b);\nfor j:=1 to n do\nif b=a[j] then\nbegin\nif b arr1[j + 1]) then\n begin\n temp:= arr1[j];\n arr1[j]:= arr1[j + 1];\n arr1[j + 1]:= temp;\n end;\n \n for i:= 0 to m - 2 do\n for j:= 0 to m - i do\n if (arr2[j] > arr2[j + 1]) then\n begin\n temp:= arr1[j];\n arr1[j]:= arr1[j + 1];\n arr1[j + 1]:= temp;\n end;\n \n n:= arr1[0];\n m:= arr2[0];\n \n if (n = m) then writeln(n);\n if (n > m) then writeln(m, n)\n else writeln(n, m);\nEnd."}, {"source_code": "var n, m, i, j, min1, min2: integer;\nbegin\n readln(n, m);\n for i:=1 to n do begin\n read(j); if (jp then o:=p;\n end;\n if v[i]l then write(10*l+k)\n else\n write(10*k+l);\n\n\n\nend. "}, {"source_code": "var m,n,i,min1,min2,x,i1:integer;\na,b:array[1..100] of integer;\nbegin\nx:=10;\n readln(n,m);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to m do\n read(b[i]);\n min1:=a[1];\n min2:=b[1];\n for i:=1 to n do\n begin\n for i1:=1 to m do\n if a[i1]=b[i] then\n if b[i] a[i+1] then\n begin\n sw:=a[i];\n a[i]:=a[i+1];\n a[i+1]:=sw;\n end;\n for j:=1 to m-1 do\n for i:=1 to m-1 do\n if b[i] > b[i+1] then\n begin\n sw:=b[i];\n b[i]:=b[i+1];\n b[i+1]:=sw;\n end;\n i:=1;\n if a[1] > b[1] then\n begin\n while (a[i] <> b[1])and(i < n) do\n i:=i+1;\n if i <> 1 then\n if i <> n then\n k:=b[1]\n else\n k:=b[1]*10+a[1]\n else\n if a[1] = b[1] then\n k:=a[1];\n\n end\n else\n begin\n while (a[1] <> b[i])and(i < m) do\n i:=i+1;\n if i <> 1 then\n if i <> m then\n k:=a[1]\n else\n k:=a[1]*10+b[1]\n else\n if a[1] = b[1] then\n k:=a[1];\n\n end;\n writeln(k);\nend."}, {"source_code": "const\n t = 1000;\n\ntype\n Arr = array [1..t] of longint;\n\nvar\n a, b: Arr;\n i, j, m, min1, min2, n: longint;\n\nbegin\n readln(n, m);\n for i := 1 to n do\n read(a[i]);\n for j := 1 to m do\n read(b[j]);\n \n min1 := a[1];\n min2 := b[1];\n \n for i := 2 to n do\n if a[i] < min1 then min1 := a[i];\n for j := 2 to m do\n if b[j] < min2 then min2 := b[j];\n \n if min1 < min2 then writeln(min1*10+min2)\n else\n if min1 = min2 then writeln(min1)\n else\n writeln(min2*10+min1);\nend."}, {"source_code": "program marvel;\n\nvar\n i,l,k,n,m,k1,x: Integer;\nbegin\n Read(n,m);\n k1:=10;\n k:=10;\n for i:=1 to n do\n begin\n Read(x);\n if x minm) then s := minm * 10 + minn;\n \n writeln(s);\nend."}, {"source_code": "type \n mass = array [1..10000] of integer;\nfunction min(b : integer; a : mass) : integer;\nvar \n i, min1 : integer;\nbegin\n if b < 1 then \n exit;\n min1 := a[1];\n for i := 2 to b do\n if a[i] < min1 then\n min1 := a[i];\n min := min1;\nend;\nvar\n a, b : mass;\n i, n, m : integer;\nbegin\n read(n, m);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to m do\n read(b[i]);\n if min(n, a) = min(m, b) \n then\n writeln(min(n, a))\n else\n writeln(min(n, a), min(m, b));\nend. "}, {"source_code": "var a,b:array[1..1000] of longint;\n i,k,n,m,x,y:longint;\nbegin\nreadln(n,m);\nfor i:=1 to n do\n read(a[i]);\nfor i:=1 to m do\n read(b[i]);\nfor i:=1 to n-1 do\n for k:=i+1 to n do\n if a[i]>a[k]\n then begin\n x:=a[i];\n a[i]:=a[k];\n a[k]:=x;\n end;\nfor i:=1 to m-1 do\n for k:=i+1 to m do\n if b[i]>b[k]\n then begin\n x:=b[i];\n b[i]:=b[k];\n b[k]:=x;\n end;\nx:=a[1];\ny:=b[1];\nif x=y\nthen writeln(x)\nelse if x>y\n then writeln(y,'',x)\n else writeln(x,'',y);\nend."}, {"source_code": "program x1;\nvar q,n,m,min1,min2,i:integer;\nbegin\nreadln(n,m);\nread(q);\nmin1:=q;\nfor i:=1 to n-1 do begin\nread(q);\nif qmin2 then write(min2,min1) else write(min1,min2);\nend."}, {"source_code": "var\nn,m,i,j,min1,min2:integer;\na:array[1..100] of integer;\nb:array[1..100] of integer;\nbegin\nmin1:=10;\nmin2:=10;\nread(n);\nread(m);\nfor i:=1 to n do\nread(a[i]);\nfor j:=1 to m do\nread(b[j]);\nfor i:=1 to n do\nif (a[i] a[i]) then min1 := a[i];\n\n for i := 1 to m do\n if (min2 > b[i]) then min2 := b[i];\n\n if (min1 = min2) then write(min1)\n else\n if (min1 > min2) then write(min2,min1)\n else\n write(min1,min2);\nend.\n "}, {"source_code": "Program P1;\nvar n,m,i,a,b,i2,e,e2: integer; a1,a2: array [0..1000] of integer; \nbegin\na:=9; b:=9; e:=10;\nreadln(n,m);\nfor i:= 1 to n do \nread(a1[i]);\n\nfor i:= 1 to m do \nread(a2[i]); \n\nfor i:= 1 to n do begin\nif a1[i]min2 then writeln(min2*10+min1) else\n if min2>min1 then writeln(min1*10+min2) else\n writeln(min1);\nEnd.\n"}, {"source_code": "var a:array[1..100] of integer;\n b:array[1..100] of integer;\n i,x1,x2,min1,min2,n,m:integer;\nBegin\n read(n,m);\n min1:=30000;\n min2:=30000;\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n for i:=1 to n do if a[i]1 then begin\n for i:=1 to n-1 do begin\n read(a);\n if a1 then begin\n for i:=1 to m-1 do begin\n read(a);\n if amin2 then write((min2*10)+min1);\n if min10) do\nbegin\nread(a);\nn:= n-1;\nif (a0) do\nbegin\nread(b);\nm:= m-1;\nif (b c) then\nbegin\nif (d>c) then\nwriteln(c*10 + d)\nelse\nwriteln(d*10 + c);\nend\nelse\nwriteln(c);\nend. \n"}, {"source_code": "program hm;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m, min1, min2, i: integer;\n a, b: array[1..19] of integer;\nbegin\n readln(n, m);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to m do\n read(b[i]);\n\n min1 := a[1];\n min2 := b[1];\n\n for i := 2 to n do\n if (min1 > a[i]) then min1 := a[i];\n\n for i := 2 to m do\n if (min2 > b[i]) then min2 := b[i];\n\n if (min1 = min2) then write(min1)\n else\n if (min1 > min2) then write(min2,min1)\n else\n write(min1,min2);\nend.\n "}, {"source_code": "Program P1;\nvar n,m,i,a,b,i2,e,e2: integer; a1,a2: array [0..1000] of integer; \nbegin\na:=9; b:=9; e:=9;\nreadln(n,m);\nfor i:= 1 to n do \nread(a1[i]);\n\nfor i:= 1 to m do \nread(a2[i]); \n\nfor i:= 1 to n do begin\nif a1[i] r\n then\n min1 := r\n else\n min1 := l; \nend;\nfunction min(b : integer; a : mass) : integer;\nvar \n i, min1 : integer;\nbegin\n if b < 1 then \n exit;\n min1 := a[1];\n for i := 2 to b do\n if a[i] < min1 then\n min1 := a[i];\n min := min1;\nend;\nvar\n a, b : mass;\n i, n, m : integer;\nbegin\n read(n, m);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to m do\n read(b[i]);\n if (n = 1) and (m = 1) \n then\n begin \n writeln(b[1] * 10 + a[1]);\n exit;\n end; \n if min(n, a) = min(m, b) \n then\n writeln(min(n, a))\n else\n writeln(min(n, a), min(m, b));\nend. "}, {"source_code": "var\nmin,ci,i,j,ak,bk : int64;\na,b : array[1..9] of byte;\nc : array[1..171] of byte;\nbegin\n ci:=0;\n min:=100;\n read(ak,bk);\n if (ak<1) or (ak>9) or (bk<1) or (bk>9) then exit;\n for i:=1 to ak do\n begin\n read(a[i]); \n if (a[i]<1) or (a[i]>9) then exit;\n end;\n for j:=1 to bk do\n begin\n read(b[j]);\n if (a[i]<1) or (a[i]>9) then exit;\n end;\n \n for i:=1 to ak do\n for j:=1 to bk do\n begin\n inc(ci);\n c[ci]:=10*a[i]+b[j];\n end;\n for i:=1 to ak do\n for j:=1 to bk do\n begin\n inc(ci);\n c[ci]:=10*b[j]+a[i];\n end;\n for i:=1 to ak do\n for j:=1 to bk do\n if a[i]=b[j] then\n begin\n inc(ci);\n c[ci]:=a[i];\n end;\n \n for i:=1 to ci do\n if c[i]ub then\n begin\n init:=m-n*p+1;\n bp:=ub;\n end\n else bp:=a[1]\n end;\n free:=m-n*p-init+1;\n res:=bp;\n for i:=2 to n do\n begin\n bp:=bp+p;\n delta:=min(a[i]-bp,free);\n free:=free-delta;\n bp:=bp+delta;\n res:=res+bp;\n end;\n ans:=max(ans,res);\n end;\n Writeln(ans);\n end.", "positive_code": [{"source_code": "uses math;\nVar ans,n,p,m,res,bp,delta,free,ub,lb,ubef,init:int64;\n a,b:array[0..200333]of int64;\n i,pp:longint;\n begin\n read(n,m);\n for i:=1 to n do\n read(b[i]);\n for pp:=1 to m div n do\n begin\n p:=pp;\n a[n]:=b[n];\n for i:=n-1 downto 1 do\n a[i]:=min(b[i],a[i+1]-p);\n lb:=p*(p-1) div 2*n+p;\n if a[1]ub then\n begin\n init:=m-n*p+1;\n bp:=ub;\n end\n else bp:=a[1]\n end;\n free:=m-n*p-init+1;\n res:=bp;\n for i:=2 to n do\n begin\n bp:=bp+p;\n delta:=min(a[i]-bp,free);\n free:=free-delta;\n bp:=bp+delta;\n res:=res+bp;\n end;\n ans:=max(ans,res);\n end;\n Writeln(ans);\n end."}, {"source_code": "uses math;\nVar ans,n,p,m,res,bp,delta,free,ub,lb,ubef,init:int64;\n a,b:array[0..200333]of int64;\n i,pp:longint;\n begin\n read(n,m);\n for i:=1 to n do\n read(b[i]);\n for pp:=1 to m div n do\n begin\n p:=pp;\n a[n]:=b[n];\n for i:=n-1 downto 1 do\n a[i]:=min(b[i],a[i+1]-p);\n lb:=p*(p-1) div 2*n+p;\n if a[1]ub then\n begin\n init:=m-n*p+1;\n bp:=ub;\n end\n else bp:=a[1]\n end;\n free:=m-n*p-init+1;\n res:=bp;\n for i:=2 to n do\n begin\n bp:=bp+p;\n delta:=min(a[i]-bp,free);\n free:=free-delta;\n bp:=bp+delta;\n res:=res+bp;\n end;\n ans:=max(ans,res);\n end;\n Writeln(ans);\n end."}, {"source_code": "uses math;\nVar ans,n,p,m,res,bp,delta,free,ub,lb,ubef,init:int64;\n a,b:array[0..200333]of int64;\n i,pp:longint;\n begin\n read(n,m);\n for i:=1 to n do\n read(b[i]);\n for pp:=1 to m div n do\n begin\n p:=pp;\n a[n]:=b[n];\n for i:=n-1 downto 1 do\n a[i]:=min(b[i],a[i+1]-p);\n lb:=p*(p-1) div 2*n+p;\n if a[1]ub then\n begin\n init:=m-n*p+1;\n bp:=ub;\n end\n else bp:=a[1]\n end;\n free:=m-n*p-init+1;\n res:=bp;\n for i:=2 to n do\n begin\n bp:=bp+p;\n delta:=min(a[i]-bp,free);\n free:=free-delta;\n bp:=bp+delta;\n res:=res+bp;\n end;\n ans:=max(ans,res);\n end;\n Writeln(ans);\n end."}], "negative_code": [], "src_uid": "169f58dc87d26e0fadde6a83bb623f54"} {"source_code": " program adsaw;\n\nvar m,n,i :integer;\n list :array[1..100] of integer;\n\nbegin \n\nreadln(n);\nm := 0;\nfor i := 1 to n do\n read(list[i]);\n\nfor i := 1 to n do\n m := list[i] + m;\n \nif m = 0 then writeln('EASY')\n else writeln('HARD');\n \nend.\n ", "positive_code": [{"source_code": "var n, i, q: integer;\nbegin\n read(n);\n for i:=1 to n do begin\n read(q);\n if q = 1 then begin write('HARD'); exit; end;\n end;\n write('EASY');\nend."}, {"source_code": "type mas = array[1..100] of longint;\nvar\n n, i: longint;\n chel: mas;\n ch: boolean;\nbegin\n read(n);\n ch:=True;\n for i:=1 to n do begin\n read(chel[i]);\n if chel[i]=1 then\n ch:=False;\n end;\n if ch then\n write('EASY')\n else\n write('HARD');\nend.\n "}, {"source_code": "Program jhdgfjqhwgbfjqevgbk;\nvar s,i,n,a:integer;\nbegin\nreadln(n);\ns:=0;\nfor i:=1 to n do\n begin\n read(a);\n s:=s+a;\n end;\nif s=0 then writeln('EASY')\n else writeln('HARD');\nend.\n"}, {"source_code": "const max=100;\nvar n,i:longint;\n a:array[1..max] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n if a[i]=1 then\n begin\n write('HARD');\n readln;\n halt;\n end; \n end;\n write('EASY');\n readln;\nend."}, {"source_code": "var\n n, i, j: integer;\n\nbegin\n read(n);\n for i := 1 to n do\n begin\n read(j);\n if j = 1 then\n begin\n write('HARD');\n exit;\n end;\n end;\n write('EASY');\nend."}, {"source_code": "var\n k, n, i, x, code: longint;\n a: string;\nbegin\nk := 0;\nreadln(n);\nreadln(a);\na := a + ' ';\nfor i := 1 to n do begin\nval(copy(a, 1, 1), x, code);\nif x = 1 then\ninc(k);\ndelete(a, 1, pos(' ', a));\nend;\nif k > 0 then writeln('HARD')\nelse\nwriteln('EASY');\nend.\n"}, {"source_code": "var n,a:integer;\nbegin\nread(n);\nfor var i:=1 to n do\nbegin\n read(a);\n if (a=1) then\n begin\n write('HARD');\n break;\n end\n else if (i=n) then write('EASY');\nend;\nend."}, {"source_code": "var n,a,sum:integer;\nbegin\n read(n);\n sum:=0;\n for var i:=1 to n do \n begin\n read(a);\n sum:=sum+a;\n end;\n if (sum>0) then\n begin\n write('HARD');\n end\n else\n begin\n write('EASY');\n end;\nend."}, {"source_code": "var a:array[1..100] of byte;\nn,i:byte;\nb:boolean;\nbegin\n b:=true;\n read(n);\n for i:=1to n do read(a[i]);\n for i:=1to n do if a[i]=1 then b:=false;\n if b then write('EASY') else writeln('HARD');\nreadln();\nend."}, {"source_code": "var \nn,a,i,e:integer;\n\n\nBegin\n\nread(n);\n\ne:=9;\n\nfor i:=1 to n do\nbegin\nread(a);\n\nif (a = 1) then e:=10; \n\nend;\n\nif (e = 9) then write('EASY')\n\t\t\telse write('HARD');\n\n\nEnd.\n"}, {"source_code": "var i,n,k: integer;\n a: array [1..101] of integer;\n begin \n readln(n);\n k:=0;\n for i:=1 to n do \n begin \n read(a[i]);\n if a[i] = 1 then k:=k+1;\n end;\n if k=0 then writeln('EASY')\n else writeln('HARD');\n end."}, {"source_code": "program S1;\nvar a:array[1..1000000] of integer;\ni,n,k:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nif a[i]=1 then k:=k+1;\nif k>0 then\nwriteln('hard')\nelse writeln('easy');\nend."}, {"source_code": "program abc;\nvar k,i,n:integer; f:boolean;\nBegin\nf:=true;\nreadLn(k);\nfor i:= 1 to k do\nBegin\nread(n);\nif n = 1 then\nBegin\nf:=false;\nbreak;\nEnd;\nEnd;\nif f then writeLn('EASY')\nelse writeLn('HARD');\nEnd."}, {"source_code": "var s,i,n:integer;\n a:array[1..100]of integer;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n \n s:=0; \n for i:=1 to n do\n s:=s+a[i];\n \n if(s>0)\n then write('HARD')\n else write('EASY');\nend. "}, {"source_code": "var a, b, c, i: integer;\nbegin\nread(a);\nb:=0;\nfor i:=1 to a do begin\n read(c);\n if c = 1 then b:=b+1;\n end;\nif b = 0 then writeln('easy')\nelse writeln('hard');\nend."}, {"source_code": "program z_a;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, x: integer;\nbegin\n readln(n);\n for i := 1 to n do\n begin\n read(x);\n if (x = 1) then\n begin\n writeln('HARD');\n exit;\n end;\n end;\n writeln('EASY');\n readln;\nend.\n"}, {"source_code": "var\n i, n, x, f: integer;\nBegin\n \n readln(n);\n for i:= 1 to n do\n begin\n read(x);\n if (x = 1) then\n f:= 1;\n end;\n \n if (f = 1) then\n writeln('HARD')\n else\n writeln('EASY');\nEnd."}, {"source_code": "program z6;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, k: integer;\n b: boolean;\n\nbegin\n readln(n);\n for i:= 1 to n do begin\n read(k);\n if (k = 1) then\n b := true;\n end;\n if (b) then\n writeln('HARD')\n else\n writeln('EASY');\n readln;\nend.\n"}, {"source_code": "program rus;\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\nvar a:array[1..100000]of LongInt;\n//b:array[-100000..100000]of longint;\nb,sum,j,a1,t,p,a2,b1,b2,c1,c2,max,min,i,o,n,k:longint;\n\nbegin\n\nread(n);\nfor i:=1 to n do begin\n read(k);\n if k=1 then begin\n write('HARD');\n Halt(0);\n end;\nend;\nwrite('eAsY');\nend."}, {"source_code": "\nvar i,n,z:integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(z);\n if z = 1 then\n begin\n write('HARD');\n exit;\n end;\n end;\n write('EASY');\nend."}, {"source_code": "var i,kol,n:integer;\na:array [1..100] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do \n read(a[i]);\nkol:=0;\nfor i:=1 to n do begin\n if a[i] = 1 then\n kol:=kol+1;\nend;\nif kol>0 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m,l,r:longint;\n mark:array[1..100000] of boolean;\n d,q:array[1..100000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure push(x:longint);\n begin\n inc(r);\n q[r]:=x;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction pop:longint;\n begin\n pop:=q[l];\n inc(l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,k:longint;\n begin\n read(fi,n);\n for i:=1 to n do\n begin\n read(fi,k);\n if k=1 then\n begin\n writeln(fo,'HARD');\n exit;\n end;\n end;\n writeln(fo,'EASY');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "begin\n var n := ReadlnInteger;\n var a := ReadString.ToIntegers;\n if a.Any(x -> x = 1) then\n Write('HARD')\n else Write('EASY')\nend."}, {"source_code": "var n,i:integer;\n a:array[1..100] of integer;\n s:string;\nbegin\nreadln(n);\ns:='easy';\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do\nif a[i] = 1 then\ns:='Hard';\nwriteln(s);\nend."}, {"source_code": "program NIKTOP2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,z,c:int64;\ni:integer;\na:array [1..1000] of integer;\n\nbegin\nread(n);\nfor i:=1 to n do begin\nread(c);\nif c=0 then\ninc(z)\nelse begin\nwrite('HARD');\nhalt(0);\nend;\nend;\nwrite('EASY');\nend.\n "}, {"source_code": "var\nn, b, i, a:integer;\nbegin\n readln(n);\n \n for i:= 1 to n do\n begin\n read(b);\n if b = 1 then\n begin\n a:= a+1;\n end\n end;\n if a >= 1 then \n begin\n writeln('HARD');\n end\n else\n begin\n writeln('EASY')\n end;\nend."}, {"source_code": "var a,i,b:integer;\nbegin\n read(a);\n b:=0;\n i:=1;\n while (i <= a) and (b=0) do\n begin\n i:=i+1;\n read(b);\n end;\n if b=0 then\n write('EASY')\n else\n write('HARD');\nend."}, {"source_code": "var\notv:array[1..100] of byte;\ni,j,k,flag:byte;\nez,hr:string;\nbegin\nez:='Easy';\nhr:='Hard';\nreadln(k);\nfor i:=1 to k do\nread(otv[i]);\nflag:=0;\nfor j:=1 to k do\nbegin\nif otv[j]=1 then begin\nwriteln(hr);\nflag:=0;\nbreak;\nend;\nif ((otv[j]=0) and (flag<>1)) then\nflag:=1;\nend;\nIf (flag=1) then writeln(ez);\nend.\n\n"}, {"source_code": "var ans, a, n, i:longint;\nbegin\nread(n);\nfor i:=1 to n do\n begin\n read(a);\n inc(ans,a);\n end;\nif ans>0 then write('hard') else write('easy');\nend."}, {"source_code": "var n,i,f,j,k :integer;\nbegin\nread(n);\nf := 0;\nfor j:=1 to n do\nbegin\nread(i);\nif i = 1 then\nf := f + 1\nelse\nk:=0;\nend;\nif f > 0 then\nwrite('HARD')\nelse\nwrite('EASY')\nend.\n\n"}, {"source_code": "program N2;\nvar\n n, i: LongInt;\n a: array [1..100] of Integer;\n\nbegin\n ReadLn (n);\n\n for i := 1 to n do\n Read (a[i]);\n ReadLn;\n\n for i := 1 to n do\n if a[i] = 1 then\n begin\n WriteLn ('HARD');\n Exit\n end;\n\n WriteLn ('EASY')\nend."}, {"source_code": "var a: array [1..100] of integer;\nn: integer;\ni: integer;\nc: integer;\nbegin\nc:=0;\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nif a[i]=1 then\nbegin\nwriteln('HARD');\nbreak;\nend\nelse\nc:=c+1;\nif c=n then\nwriteln('EASY');\nend."}, {"source_code": "program Gay;\nvar n, a : Integer;\nbegin\nRead(n, a);\nfor n := n downto 1 do\nbegin\nif a = 1 then\na := 1\nelse Read(a);\nend;\nif a <> 1 then\nWrite('EASY')\nelse Write('HARD');\nend."}, {"source_code": "Var a:array[1..1000] of Longint;\n N,i,dem:Longint;\nBegin\n Readln(N);\n For i:=1 to N do read(a[i]);\n For i:=1 to N do\n If a[i]=1 then inc(dem);\n If dem=0 then writeln('EASY');\n If dem>0 then writeln('HARD');\nEnd."}, {"source_code": "var i,k,n:integer;a:array[1..100] of integer;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]=0 then \n inc(k);\n \n end;\n if k=n then writeln('EASY') else writeln('HARD');\nend. "}, {"source_code": "var n,i:longint;\n a:array[1..100] of longint;\nBEGIN\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\n \nfor i:=1 to n do\n begin\n if a[i]=1 then begin writeln('HARD');exit;end\n end;\nwriteln('EASY');\n\n\nEND."}, {"source_code": "Var n , i , k : Byte;\nBegin\nReadln(n);\ni := 1;\nWhile i <= n do \n Begin\n Read(k);\n If k = 1 then Break else Inc(i);\n End;\nIf k = 1 then Writeln('HARD') else Writeln('EASY');\nEnd."}, {"source_code": "var a,k,n,p:integer;\nbegin\nreadln(n);\nfor a:=1 to n do\nbegin;\nread(p);\nif p=1 then k:=k+1;\nend;\n\nif k>0 then writeln('hard') else writeln('easy');\nreadln;\nend."}, {"source_code": "program easy;\nvar i, n, a: integer;\nbegin\n readln(n);\n for i := 1 to n do begin\n read(a);\n if a = 1 then begin\n writeln('HARD');\n exit();\n end;\n end;\n writeln('EASY');\nend."}, {"source_code": "var i,n,a:integer;\nbegin\n readln(n);\n while (n>0) and (a=0) do\n begin\n read(a);\n if a=1 then\n writeln('HARD');\n n:=n-1;\n end;\n if (n=0) and (a=0) then \n writeln('EASY');\nend."}, {"source_code": "var i,n:longint;\n a:array[1..100000] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]=1 then\n begin\n write('HARD');\n halt;\n end;\n end;\n write('EASY');\nend."}, {"source_code": "var\nn,i,j:integer;\na:array[0..1]of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(j);\na[j]:=a[j]+1;\nend;\nif a[0]=n then write('easy')else write('hard');\nend."}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\ncount:=0;\nfor i:= 1 to n do\nbegin\nread(m);\nif m=1\nthen\ninc(count);\nend;\nif count>0\nthen write('hard')\nelse\nwrite('easy');\nend."}, {"source_code": "var i, w:integer;\ns:string;\nq: array[1..100] of integer;\nbegin\nw:=0;\nread(i);\nfor i:=1 to i do\nbegin\nread(q[i]);\nif q[i]=1 then inc(w);\nend;\nif w>=1 then write('hard') else write('easy');\nend."}, {"source_code": "var n, i, k, m: integer;\ns: string;\nbegin\nreadln (n);\nk:=0;\nfor i:=1 to n do\n begin\n read (k);\n m:= m+k;\n end;\n if m > 0then \n write ('HARD')\n else write ('easy');\n \n \nend."}, {"source_code": "var n,i,t:longint;\ncc:boolean;\nbegin\nreadln(n);\ncc:=false;\nfor i:=1 to n do\nbegin\nread(t);\nif t=1 then cc:=true;\nend;\nif cc=false then writeln('EASY')\nelse writeln('HARD'); \nreadln;\nend.\n"}, {"source_code": "var n,i,a: integer;\ns: boolean;\nbegin\n readln (n);\n for i:= 1 to n do\n begin\n read (a);\n if a=1 then \n begin\n s := false;\n break;\n end\n else s:= true;\n end;\n if s = false then writeln ('HARD')\n else writeln ('EASY');\nend."}, {"source_code": "var\n x,i,n:longint;\n p:boolean;\nbegin\n readln(n);\n for i:=1 to n do \n begin\n read(x);\n if x=1 then p:=true;\n end;\n if p then write('HARD')\n else write('EASY');\nend."}, {"source_code": "var\nn,x,i,c:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\nread(x);\nif x=1 then c:=1;\nend;\nif c=0 then writeln('EASY')\nelse\nwriteln('HARD');\nend."}, {"source_code": "var n,i,k:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(k);\nif k=1 then begin write('HARD');exit;end;\nend;\nwrite('EASY');\nend."}, {"source_code": "var\n n,i,x:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x=1 then\n begin\n writeln('HARD');\n halt;\n end;\n end;\n writeln('EASY');\nend."}, {"source_code": "var\n n,i,x:longint;\n ok:boolean;\nbegin\n readln(n);\n ok:=true;\n for i:=1 to n do \n begin\n read(x);\n if x=1 then ok:=false;\n end;\n if ok then writeln('EASY')\n else writeln('HARD');\nend."}, {"source_code": "var\n N, i, num, chet: longint;\n\nbegin\n read(N);\n for i := 1 to N do\n begin\n read(num);\n if(num = 1) then\n chet := 1;\n end;\n if(chet = 1) then\n write('HARD')\n else\n write('EASY');\nend."}, {"source_code": "var\n n,i,x:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x=1 then\n begin\n writeln('HARD');\n exit;\n end;\n end;\n writeln('EASY');\nend."}, {"source_code": "const Sz = 100;\nvar\na: array [1..Sz] of integer;\n N,s,i: integer; \nbegin \nread(n);\n for i:=1 to n do begin\n read(a[i]);\n if a[i] = 1 then s:= s + 1;\n end;\nif s>0 then writeln('HARD') else writeln('easy');\nend."}, {"source_code": "var a:array[1..100] of integer;\ni,n,j,k:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nk:=0;\nfor i:=1 to n do\nif a[i]<>0 then inc(k);\nif k>0 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var\n n,i,c:longint;\n a: array[1..102] of longint;\nbegin\n read(n); c:=0;\n for i:= 1 to n do\n read(a[i]);\n for i:= 1 to n do\n if a[i]>0 then\n c:=1;\n if c=0 then\n write('EASY')\n else\n write('HARD')\nend.\n"}, {"source_code": "var C,I,A,n:integer;\nbegin\n readln(n);\n c:=0;\n FOR i:=1 to n do\n begin\n read(a);\n C:=c+a;\n end;\n if c<>0 then\n writeln('hard')\n else\n writeln('eASY');\nend."}, {"source_code": "var a,b,i,n: integer;\nbegin\n read (n);\n b := 0;\n for i:=1 to n do begin\n read (a);\n b := b or a;\n end;\n if (b = 1) then write ('HARD') else write ('EASY');\nend."}, {"source_code": "const\n fin='AIN.inp';fon='AIN.out';\nvar n,i,j,k,l:longint;\n a:array[1..10000000]of longint;\nbegin\n//assign(input,fin);\n//reset(input);\n//assign(output,fon);\n//rewrite(output);\nreadln(n);\nfor i:=1 to n do\n begin\n read(k);\n if k=1 then\n begin\n writeln('HARD');\n l:=1;\n break;\n end;\n end;\nif l<>1 then writeln('EASY');\n//close(input);close(output);\nend."}, {"source_code": "var n,i,g,r,a:integer;\nbegin\nreadln (n);\nfor g:=1 to n do \nbegin\nread (i);\nif i>0 then a:=1\nelse a:=0;\nr:=r+a;\nend;\nif r>0 then write ('HARD') else write ('EASY')\nend. "}, {"source_code": "var i,n,p:longint;\nic:boolean;\nbegin\nreadln(n);\nic:=true;\nfor i:=1 to n do \nbegin\nread(p);\nif p=1 then ic:=false;\nend;\nif ic=true then writeln('EASY') else writeln('HARD');\nend.\n"}, {"source_code": "var\n i,j,n,m:integer;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(m);\n j:=j+m;\n end;\n if j>=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "Program A;\nVar n,i,b,C:integer;\nBegin\n Readln(n);\n C:=0;\n for i:=1 to n do begin\n read(b);\n if b=1 then c:=1;\n end;\n if c=1 then writeln('HARD') \n else writeln('EASY');\nend."}, {"source_code": "var n, i, q:integer;\nf:boolean;\nbegin\nreadln (n);\nf:=true;\nfor q:=1 to n do begin\nread (i);\nif (i=1) then\nf:=false;\nend;\nif (f=false) then writeln ('Hard')\nelse writeln ('Easy');\nend.\n"}, {"source_code": "Program abc;\nvar i,n:integer;\nx:array[1..1000000] of integer;\nl:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(x[i]);\nfor i:=1 to n do\nif x[i]=1 then l:=true;\n\nif l then writeln('HARD') else writeln('EASY');\nend.\n"}, {"source_code": "var\n n,i,m,sum:integer;\nbegin\n readln(n);\n sum:=0;\nfor i:=1 to n do\n begin\n read(m);\n sum:=sum+m;\n end;\nif sum>0 then\n writeln('Hard')\nelse\n writeln('Easy');\nend."}, {"source_code": "var\n n,i,x:integer;\nbegin\n readln(N);\n\n for i:=1 to N do\n begin\n read(x);\n if (x=1) then\n break;\n end;\n if (x=1) then\n writeln('Hard')\n else\n writeln('Easy');\n end."}, {"source_code": "Program test_prog_1; \nvar k, b, n, i :integer; \nbegin \nread (n); \nfor i:= 1 to n do \nbegin \nread (b); \nif b=1 then k:= k+1; \nend; \nif k<>0 then write ('hard') \nelse write ('easy'); \nend."}, {"source_code": "VAR A,F,I:INT64;\nB: ARRAY [1..100000] OF BYTE;\nBEGIN\nF:=0;\nREAD(A);\nFOR I:=1 TO A DO BEGIN\nREAD (B[I]);\nIF B[I]=1 THEN F:=1;\nEND;\nIF F=1 THEN WRITE('HARD') ELSE WRITE('EASY');\nEND."}, {"source_code": "var a,b,c,i,n:Integer;\n r: string;\nbegin\nr:='easy';\nreadln(n);\nfor i:=1 to n do begin\n read(a);\n if a = 1 then \n r:= 'hard';\n end;\nwriteln(r); \nend."}, {"source_code": "var n,i,k:integer;\na:array[1..100] of integer;\nbegin\nreadln(n);\nk:=0;\nfor i:=1 to n do begin read(a[i]);end;\nfor i:=1 to n do begin\nif a[i]=1 then k:=1;\nend;\nif k=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var\n flag:boolean;\n n,a:integer;\n\nbegin\n flag:=true;\n \n readln(n);\n \n for var i:=1 to n do\n begin\n read(a);\n if (a=1) then flag:=false;\n end;\n \n \n if flag then writeln('EASY') else writeln('HARD');\n\nend."}, {"source_code": "var n,m,p,r,a,x,y,max,s,min,albe,negre,c : longint;\nb,v : array[0..100000] of longint;\nda : boolean;\nz : ansistring;\nbegin\n\t\n\treadln(n);\n\t\n\tda:=true;\n\tfor c:=1 to n do\n\tbegin\n\t\tread(a);\n\t\t\n\t\tif a=1 then\n\t\tda:=false;\n\tend;\n\t\n\tif da=true then writeln('easy') else\n\twriteln('hard');\n\t\nend.\n"}, {"source_code": "var t,x,a,b:integer;\nbegin\nread (a);\nt:=0;\nfor x:=1 to a do\n begin\n read(b);\n if b=1 then t:=1;\n end;\nif t=0 then print ('Easy') else print ('Hard');\nend."}, {"source_code": "program main;\nvar\n hard : boolean;\n i, n : integer;\n a : array[1..100] of integer;\nbegin\n readln(n);\n for i := 1 to n do read(a[i]);\n for i := 1 to n do begin\n if a[i] = 1\n then hard := true;\n end;\n if hard = true\n then writeln('Hard')\n else writeln('Easy');\nend."}, {"source_code": "Program z1;\nVar\n n,i,k:integer;\n y:string;\nbegin\ny:='EASY';\nReadln(n);\nFor i:=1 to n do begin\nRead(k);\nIf k=1 then y:='HARD';\nk:=0;\nend;\nWriteln(y)\nend.\n"}, {"source_code": "program zB;\nvar n,i,o,sl:integer;\nbegin\nreadln (n);\nfor i:=1 to n do\nbegin\nread (o);\nif o=1 then sl:=1\nend;\nif sl=1 then writeln('hard')\nelse writeln('easy')\nend."}, {"source_code": "var n,i,g,m:integer;\nbegin\nread(n);\nm:=0;\nfor i:=1 to n do begin\nread(g);\nif g=1 then m:=m+g;\nend;\nif m>0 then write('HARD') else write('EASY');\nend."}, {"source_code": "\nvar\n n,i: integer;\n a: array[1..999] of integer;\nbegin\nread(n);\nfor i:=1 to n do\n read(a[i]);\nfor i:=1 to n do\n if a[i]=1 then begin\n write('HARD');\n exit; end;\n write('EASY');\n end."}, {"source_code": "var n,z,i:integer;\n k: array[1..101] of byte;\n \n begin \n readln(n);\n z:=0;\n for i:=1 to n do \n begin\n read(k[i]);\n if k[i]=1 then\n z:=z+1;\n end;\n if z>0 \n then writeln('HARD')\n else writeln('EASY');\n end."}, {"source_code": "var n, i, s: integer;\na: array [1..100] of integer;\nbegin\nread(n);\nfor i:= 1 to n do\nread(A[i]);\nfor i:= 1 to n do\ns:=s+A[i];\nif s>0 then\nwrite('Hard')\nelse\nwrite('Easy')\nend."}, {"source_code": "program yok;\nvar \n\tcek:boolean;\n\tn,k,i:integer;\nbegin\n\treadln(n);\n\tcek:=true;\n\tfor i:=1 to n do\n\tbegin\n\t\tread(k);\n\t\tif (k=1) then\n\t\tcek:=false;\n\tend;\n\tif cek=false then\n\twriteln('HARD')\n\telse\n\twriteln('EASY');\nend."}], "negative_code": [{"source_code": "Program A;\nVar n,i,b,C:integer;\nBegin\n repeat\n Readln(n);\n Writeln('Неверные входные данные. Повторите попытку');\n until (n>0) and (n<100);\n C:=0;\n for i:=1 to n do begin\n read(b);\n if b=1 then c:=1 else if (b<>0) and (b<>1) then c:=2;\n end;\n if c=1 then writeln('HARD') \n else if c=2 then writeln('Неверные входные данные')\n else writeln('EASY');\nend."}, {"source_code": "var\ni, n, a:integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a);\nif a=1 then write('hard')\nelse write('eaze');\nend."}, {"source_code": "program loc;\ntype sir=array [1..100] of integer;\nvar n,i,k:integer;\n s:sir;\n b:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do \nreadln(s[i]);\nfor i:=1 to n do \nif s[i]=1 then b:=true;\nif b=true then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var n,i,f,j :integer;\nbegin\nread(n);\nfor j:=1 to n do\nbegin\nread(i);\nif i = 0 then\nf := 0\nelse\nf := 1;\nend;\nif f = 1 then\nwrite('HARD')\nelse\nwrite('EASY')\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q1 then begin writeln('HARD'); halt; end;\n end;\n writeln('EASY');\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q1 then begin writeln('HARD'); halt; end;\n end;\n writeln('EASY');\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var a, b, i: integer;\nbegin\nread(a);\nb:=0;\nfor i:=1 to a do\n if a = 1 then b:=b+1;\nif a = 0 then writeln('easy')\nelse writeln('hard');\nend."}, {"source_code": "var n,i,b:integer;\nbegin\nread(n);\nb:=0;\nfor i:=1 to n do begin\n read(n);\n if i=0 then b:=b+1;\n end;\nif b=n then write('EASY') else write('HARD');\nend.\n \n "}, {"source_code": "var a,b:integer; \nbegin \nread(a);\nfor a:=1 to a do \nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\n end."}, {"source_code": "var\nn, s, i, l: integer;\nbegin\nREADLN(n);\ns := 1;\nfor i := 1 to n do\n begin\n READ(l);\n if (i = 1) then\n s := s + 1;\n end; \nif (s = 0) then\n WRITELN('EASY')\nelse\n WRITELN('HARD');\nend."}, {"source_code": "var c:char;\nbegin\n readln;\n while not eof do\n begin\n read(c);\n if c='0' then\n continue;\n writeln('HARD');\n halt;\n end;\n writeln('EASY');\nend.\n"}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nbegin\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\ninc(count);\nend;\nif count>0\nthen write('hard')\nelse\nwrite('easy');\nend."}, {"source_code": "var\ni, n, a:integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a);\nif a=1 then write('hard')\nelse write('eaze');\nend."}, {"source_code": "program zadacha3;\nvar n,a1,a2,a3,a4,a5,a6,a7,a8,a9,k,x:integer;\nbegin\nk:=0;\nread(n);\nif n=2 then\nbegin\nread(x);\na1:=x div 10;\na2:=x mod 10;\nif a1=a2 then\nk:=1;\nend;\nif n=3 then\nbegin\nread(x);\na1:=x div 100;\na2:=(x div 10)-(a1*10);\na3:=x mod 10;\nif a1+a2=a3 then\nk:=1;\nif a3+a2=a1 then\nk:=1;\nend;\nif n=4 then\nbegin\nread(x);\na1:= x div 1000;\na2:=(x div 100)-(a1*10);\na4:=(x mod 10);\na3:=(x mod 100)-(x mod 10);\nif a1=a2+a3+a4 then\nk:=1;\nif a1+a2=a3+a4 then\nk:=1;\nif a1+a2+a3=a4 then\nk:=1;\nend;\nif n=5 then\nbegin\nread(x);\na1:=x div 10000;\na2:=(x div 1000)-(a1*10);\na4:=(x mod 1000)-(x mod 100);\na3:=(x mod 100) -(x mod 10);\na5:=(x mod 10);\nif a1+a2+a3=a4+a5 then\nk:=1;\nif a1+a2+a3+a4=a5 then\nk:=1;\nif a1+a2=a3+a4+a5 then\nk:=1;\nif a1=a2+a3+a4+a5 then\nk:=1;\nend;\nif n=6 then\nbegin\nread(x);\na1:=x div 100000;\na2:=(a1*1000)-(x div 10);\na3:=(x mod 1000)-(x mod 100);\na4:=(x mod 10000)-(x mod 1000);\na5:=(x mod 100000)-(x mod 10000);\na6:=( x mod 10);\nif a1=a2+a3+a4+a5+a6 then\nk:=1;\nif a1+a2=a3+a4+a5+a6 then\nk:=1;\nif a1+a2+a3=a4+a5+a6 then\nk:=1;\nif a1+a2+a3+a4=a5+a6 then\nk:=1;\nif a1+a2+a3+a4+a5=a6 then\nk:=1;\nend;\nif n=7 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*10000)-(x div 100);\na3:=(x mod 10000)-(x mod 1000);\na4:=(x mod 100000)-(x mod 10000);\na5:=(x mod 1000000)-(x mod 100000);\na6:=(x mod 10000000)-(x mod 1000000);\na7:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7 then\nk:=1;\nend; \nif n=8 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*100000)-(x div 1000);\na3:=(x mod 100000)-(x mod 10000);\na4:=(x mod 1000000)-(x mod 100000);\na5:=(x mod 10000000)-(x mod 1000000);\na6:=(x mod 10000000)-(x mod 10000000);\na7:=(x mod 100000000)-(x mod 100000000);\na8:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6+a7=a8 then\nk:=1;\nend;\nif k=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var\nn, s, i, l: integer;\nbegin\nREADLN(n);\ns := 1;\nfor i := 1 to n do\n begin\n READ(l);\n if (i = 1) then\n s := s + 1;\n end; \nif (s = 0) then\n WRITELN('EASY')\nelse\n WRITELN('HARD');\nend."}, {"source_code": "var n,i,t:longint;\ncc:boolean;\nbegin\nreadln(n);\ncc:=false; \nfor i:=1 to n do\nbegin\nread(t);\nif t=1 then begin writeln('HARD'); cc:=true; end;\nend;\nif cc=false then writeln('EASY');\nreadln;\nend.\n"}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nbegin\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\nbegin\ninc(count);\nwrite('hard');\nHALT;\nend;\n write('easy');\n end;\nend."}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then writeln('EASY') else writeln('HARD');\nend. \n"}, {"source_code": "program ff;\nvar a,b:integer; \nbegin \nread(a);\nfor a:=1 to a do \nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\n end."}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then write('HARD') else write('EASY');\nend. \n"}, {"source_code": "var a,b:integer; \nbegin \nread(a);\nfor a:=1 to a do \nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\n end."}, {"source_code": "var a,b,c,d,i,n:integer;\nbegin\nreadln(n);\nif (n<=100) and (n>=1) then\n for c:=1 to n do begin\n if (i=0) or (i=1) then\n read(i);\n a:=a+i;\n end;\n if a>=1\n then writeln ('hard')\n else \n \n writeln ('easy',a);\nend."}, {"source_code": "program zadacha3;\nvar n,a1,a2,a3,a4,a5,a6,a7,a8,a9,k,x:integer;\nbegin\nk:=0;\nread(n);\nif n=2 then\nbegin\nread(x);\na1:=x div 10;\na2:=x mod 10;\nif a1=a2 then\nk:=1;\nend;\nif n=3 then\nbegin\nread(x);\na1:=x div 100;\na2:=(x div 10)-(a1*10);\na3:=x mod 10;\nif a1+a2=a3 then\nk:=1;\nif a3+a2=a1 then\nk:=1;\nend;\nif n=4 then\nbegin\nread(x);\na1:= x div 1000;\na2:=(x div 100)-(a1*10);\na4:=(x mod 10);\na3:=(x mod 100)-(x mod 10);\nif a1=a2+a3+a4 then\nk:=1;\nif a1+a2=a3+a4 then\nk:=1;\nif a1+a2+a3=a4 then\nk:=1;\nend;\nif n=5 then\nbegin\nread(x);\na1:=x div 10000;\na2:=(x div 1000)-(a1*10);\na4:=(x mod 1000)-(x mod 100);\na3:=(x mod 100) -(x mod 10);\na5:=(x mod 10);\nif a1+a2+a3=a4+a5 then\nk:=1;\nif a1+a2+a3+a4=a5 then\nk:=1;\nif a1+a2=a3+a4+a5 then\nk:=1;\nif a1=a2+a3+a4+a5 then\nk:=1;\nend;\nif n=6 then\nbegin\nread(x);\na1:=x div 100000;\na2:=(a1*1000)-(x div 10);\na3:=(x mod 1000)-(x mod 100);\na4:=(x mod 10000)-(x mod 1000);\na5:=(x mod 100000)-(x mod 10000);\na6:=( x mod 10);\nif a1=a2+a3+a4+a5+a6 then\nk:=1;\nif a1+a2=a3+a4+a5+a6 then\nk:=1;\nif a1+a2+a3=a4+a5+a6 then\nk:=1;\nif a1+a2+a3+a4=a5+a6 then\nk:=1;\nif a1+a2+a3+a4+a5=a6 then\nk:=1;\nend;\nif n=7 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*10000)-(x div 100);\na3:=(x mod 10000)-(x mod 1000);\na4:=(x mod 100000)-(x mod 10000);\na5:=(x mod 1000000)-(x mod 100000);\na6:=(x mod 10000000)-(x mod 1000000);\na7:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7 then\nk:=1;\nend; \nif n=8 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*100000)-(x div 1000);\na3:=(x mod 100000)-(x mod 10000);\na4:=(x mod 1000000)-(x mod 100000);\na5:=(x mod 10000000)-(x mod 1000000);\na6:=(x mod 10000000)-(x mod 10000000);\na7:=(x mod 100000000)-(x mod 100000000);\na8:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6+a7=a8 then\nk:=1;\nend;\nif k=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var\n n: shortint; \n f: integer;\n\nbegin\n readln(n);\n readln(f);\n if (f > 0) then\n writeln('HARD')\n else\n writeln('EASY');\nend."}, {"source_code": "var\n a: array [1..100] of integer;\n i, n, k: integer;\n\nbegin \n for i := 1 to n do\n read(a[i]);\n k := 0;\n for i := 1 to n do\n if a[i] = 1 then inc(k);\n if k = 0 then writeln('easy')\n else writeln('hard');\nend."}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then writeln('HARD') else writeln('EASY');\nend. \n"}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nif n>=1\nthen\nbegin\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\nbegin\ninc(count);\nwrite('hard');\nexit;\nend;\nif count=0\nthen write('easy');\nend;\nend."}, {"source_code": "var a,i,n,x:integer;\n\nbegin\nreadln (n);\nfor x:= 1 to n do\nbegin\n read (i);\n a:= a+1;\n end;\nif a <> 0 then\n writeln ('HARD')\n else\n writeln ('EASY');\nend."}, {"source_code": "var\na:array[1..100] of integer;\ni,n,s:integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do s:=s+a[i];\n if s=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var a:array[1..100]of integer;\ni,n,k:integer;\nbegin\n readln(n);\n k:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]-1=0 then inc(k);\n if k>0 then writeln('HARD');\n end."}, {"source_code": "var a:Array[1..100]of integer; flag:boolean; n,i:integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do if a[i]=1 then flag:=True else flag:=False;\nif flag=true then writeln('hard') else writeln('easy');\nend."}, {"source_code": "var\n x,i,n:longint;\n blog:boolean;\nbegin\n readln(n);\n blog:=true;\n for i:=1 to n do\n begin\n read(x);\n if (x=1) then blog:=false;\n end;\n if blog then write('EASY')\n else write('HERD');\nend."}, {"source_code": "var a: array [1..100] of integer;\nn: integer;\ni: integer;\nc: integer;\nbegin\nc:=0;\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nif a[i]=1 then\nwriteln('HARD')\nelse\nc:=c+1;\nif c=n then writeln('EASY');\nend."}, {"source_code": "program loc;\nvar n,i,k:integer;\n b:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nreadln(k);\nif k=1 then b:=true;\nend;\nif b=true then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var\na:array[1..1000]of longint;\nj,i,p,n:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nif a[i]=1 then begin write('HARD');exit;end;\nwrite('EASY');\nend."}, {"source_code": "var n,k,i:integer;\nbegin\n\tread(n);\n\tfor i:=1 to n do\n\tbegin\n\t\tread(k);\n\t\tif k=1 then\n\t\t\tbegin\n\t\t\twriteln('HARD');\n\t\t\texit;\n\t\t\tend;\t\n\tend;\n\twriteln('EAZY');\nend."}, {"source_code": "var a,b,i:integer; \nbegin \nread(a);\ni:=1;\nfor i:=1 to a do begin\nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\nend;\n end."}, {"source_code": "program a1030a;\nvar q1,a2,i,n,b:integer;\na:array[1..100] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(a[i]);\n\nend;\nfor i:=1 to n do\nbegin\nif a[i] = 0 then q1:=q1+1;\nEND;\nif q1>0 then writeln ('HARD')\nelse\nwriteln ('EASY');\nend."}, {"source_code": "var C,I,A,n:integer;\nbegin\n readln(n);\n c:=0;\n FOR i:=1 to n do\n begin\n read(a);\n C:=c+a;\n end;\n if c=0 then\n writeln('EASE')\n else\n writeln('HARD');\nend."}, {"source_code": "program q;\n var n,i: integer;\n a,k:string;\nbegin\n readln(n);\n while (n<0) or (n>100) do begin\n readln(n);\n end;\n readln(k);\n while length(k)-((length(k)-1)/2)<>n do begin\n read(k);\n end;\n for i:=1 to n do begin\n if k[i]='1' then begin\n a:='HARD';\n write(a);\n break;\n end;\n end;\n if a<>'HARD' then write('EASY');\nend."}, {"source_code": "var\ni,k, n, a:integer;\nbegin\nread(n);\nk:=0;\nfor i:=1 to n do\nbegin\nread(a);\nif a=1 then k:=1;\nend;\nif k=1 then write('hard')\nelse write('eazy');\nend.\n\n"}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then writeln('HARD') else writeln('EASY');\nend. \n"}, {"source_code": "var\notv:array[1..100] of byte;\ni,j,k,flag:byte;\nez,hr:string;\nbegin\nez:='Easy';\nhr:='Hard';\nreadln(k);\nfor i:=1 to k do\nread(otv[i]);\nflag:=0;\nfor j:=1 to k do\nbegin\nif otv[j]=1 then begin\nwriteln(hr);\nbreak;\nend;\nif ((otv[j]=0) and (flag<>1)) then\nflag:=1;\nend;\nIf flag=1 then writeln(ez);\nend.\n\n"}, {"source_code": "var \nn,a,i,e:integer;\n\n\nBegin\n\nreadln(n);\n\ne:=9;\n\nfor i:=1 to n do\nbegin\nreadln(a);\n\nif (a = 1) then e:=10; \n\nend;\n\nif (e = 9) then writeln('EASY')\n\t\t\telse writeln('HARD');\n\n\nEnd."}, {"source_code": "var a,b,c,d,i,n:integer;\nbegin\nreadln(n);\nif (n<=100) and (n>=1) then\n for c:=1 to n do begin\n if (i=0) or (i=1) then\n read(i);\n a:=a+i;\n end;\n if a>=1\n then writeln ('hard')\n else \n \n writeln ('easy',a);\nend."}, {"source_code": "var a:array[1..100]of integer;\ni,n,k:integer;\nbegin\n readln(n);\n k:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]-1=0 then inc(k);\n if k>0 then writeln('HARD');\n end."}, {"source_code": "var\na:array[1..1000]of longint;\nj,i,p,n:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nif a[i]=1 then begin write('HARD');exit;end;\nwrite('EASY');\nend."}, {"source_code": "Var y: array[1..1000] of integer;\na,b,n,d,q,i: integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(y[i]);\nfor i:=1 to n do\nif y[i]=1 then begin writeln('HARD'); break; end\n\nelse writeln('EASY') ;\n\nend.\n"}, {"source_code": "var t,n,i,k,x,a,b:integer;\nbegin\n\n readln(n);\n \n for i:=1 to n do begin read(x); if a=0 then inc(a) else begin writeln('Hard'); break; end; end;\n \n \n if a=n then writeln('Easy');\n\nend.\n"}, {"source_code": "program Z_1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, a, k: integer;\n\nbegin\n readln(n);\n k := 0;\n for i := 1 to n do\n read(a);\n if (a = 1) then\n inc(k);\n if (k = 0) then\n writeln('EASY')\n else\n writeln('HARD');\n readln;\nend.\n "}, {"source_code": "var a, b, i: integer;\nbegin\nread(a);\nb:=0;\nfor i:=1 to a do\n if a = 1 then b:=b+1;\nif a = 0 then writeln('easy')\nelse writeln('hard');\nend."}, {"source_code": "Var y: array[1..1000] of integer;\na,b,n,d,q,i: integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(y[i]);\nfor i:=1 to n do\nif y[i]=1 then begin writeln('HARD'); break; end\n\nelse writeln('EASY') ;\n\nend.\n"}, {"source_code": "begin\nend."}, {"source_code": "var a,i,n,x:integer;\n\nbegin\nreadln (n);\nfor x:= 1 to n do\nbegin\n read (i);\n a:= a+1;\n end;\nif a <> 0 then\n writeln ('HARD')\n else\n writeln ('EASY');\nend."}, {"source_code": "var\na:array[1..100] of integer;\ni,n,s:integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do s:=s+a[i];\n if s=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then writeln('EASY') else writeln('HARD');\nend. \n"}, {"source_code": "var n,i:integer;\n k: array[1..100] of integer;\n \n begin \n readln(n);\n for i:=1 to n do\n read(k[i]);\n if k[i]=0 then write('EASY')\n else write('HARD');\n \n end."}, {"source_code": "begin\n var n := ReadInteger;\n var a := ReadString.ToIntegers;\n if a.Any(x -> x = 1) then\n Write('HARD')\n else Write('EASY')\nend."}, {"source_code": "var\n n, i, a, b: integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n read(a);\n b := b + a;\n end;\n if b > 0 then \n writeln('HARD') \n else \n writeln('EAZY');\nend."}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nbegin\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\ninc(count);\nend;\nif count>0\nthen write('hard')\nelse\nwrite('easy');\nend."}, {"source_code": "\nvar i,n,z:integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(z);\n if z = 1 then\n begin\n write('HARD');\n exit;\n end;\n end;\n write('EAZY');\nend."}, {"source_code": "program easy;\nvar i, n, a: integer;\nbegin\n readln(n);\n for i := 1 to n do begin\n readln(a);\n if a = 1 then begin\n writeln('HARD');\n exit();\n end;\n end;\n writeln('EASY');\nend."}, {"source_code": "var n,i,s,a:integer;\nbegin\n readln(n);\n for i:= 1 to n do\n begin\n readln(a);\n s:=s+a;\n end;\n if s = 0 then writeln('EASY')\n else writeln('HARD');\nreadln;\nend.\n"}, {"source_code": "var n,i,a:integer;\nbegin\n read(n);\n for i:= 1 to n do read(a);\n if a = 0 then writeln('EASY')\n else writeln('HARD');\nend.\n"}, {"source_code": "program zadacha3;\nvar n,a1,a2,a3,a4,a5,a6,a7,a8,a9,k,x:integer;\nbegin\nk:=0;\nread(n);\nif n=2 then\nbegin\nread(x);\na1:=x div 10;\na2:=x mod 10;\nif a1=a2 then\nk:=1;\nend;\nif n=3 then\nbegin\nread(x);\na1:=x div 100;\na2:=(x div 10)-(a1*10);\na3:=x mod 10;\nif a1+a2=a3 then\nk:=1;\nif a3+a2=a1 then\nk:=1;\nend;\nif n=4 then\nbegin\nread(x);\na1:= x div 1000;\na2:=(x div 100)-(a1*10);\na4:=(x mod 10);\na3:=(x mod 100)-(x mod 10);\nif a1=a2+a3+a4 then\nk:=1;\nif a1+a2=a3+a4 then\nk:=1;\nif a1+a2+a3=a4 then\nk:=1;\nend;\nif n=5 then\nbegin\nread(x);\na1:=x div 10000;\na2:=(x div 1000)-(a1*10);\na4:=(x mod 1000)-(x mod 100);\na3:=(x mod 100) -(x mod 10);\na5:=(x mod 10);\nif a1+a2+a3=a4+a5 then\nk:=1;\nif a1+a2+a3+a4=a5 then\nk:=1;\nif a1+a2=a3+a4+a5 then\nk:=1;\nif a1=a2+a3+a4+a5 then\nk:=1;\nend;\nif n=6 then\nbegin\nread(x);\na1:=x div 100000;\na2:=(a1*1000)-(x div 10);\na3:=(x mod 1000)-(x mod 100);\na4:=(x mod 10000)-(x mod 1000);\na5:=(x mod 100000)-(x mod 10000);\na6:=( x mod 10);\nif a1=a2+a3+a4+a5+a6 then\nk:=1;\nif a1+a2=a3+a4+a5+a6 then\nk:=1;\nif a1+a2+a3=a4+a5+a6 then\nk:=1;\nif a1+a2+a3+a4=a5+a6 then\nk:=1;\nif a1+a2+a3+a4+a5=a6 then\nk:=1;\nend;\nif n=7 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*10000)-(x div 100);\na3:=(x mod 10000)-(x mod 1000);\na4:=(x mod 100000)-(x mod 10000);\na5:=(x mod 1000000)-(x mod 100000);\na6:=(x mod 10000000)-(x mod 1000000);\na7:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7 then\nk:=1;\nend; \nif n=8 then\nbegin\nread(x);\na1:=x div 1000000;\na2:=(a1*100000)-(x div 1000);\na3:=(x mod 100000)-(x mod 10000);\na4:=(x mod 1000000)-(x mod 100000);\na5:=(x mod 10000000)-(x mod 1000000);\na6:=(x mod 10000000)-(x mod 10000000);\na7:=(x mod 100000000)-(x mod 100000000);\na8:=(x mod 10);\nif a1=a2+a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2=a3+a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3=a4+a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4=a5+a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5=a6+a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6=a7+a8 then\nk:=1;\nif a1+a2+a3+a4+a5+a6+a7=a8 then\nk:=1;\nend;\nif k=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var a,i,o,j:integer;\nbegin\nreadln(j);\nfor i:=1 to j do begin\n read(a);\n if (a = 1) then begin\n writeln('HARD'); \n j:= 0;\n end else begin\n writeln('EASY');\n j:= 0;\n end; \nend;\nend."}, {"source_code": "var\ni, n, k:integer;\nbegin\nread(n);\nk:=0;\nwhile n>0 do begin\nread(k);\nif i>0 then k:=1;\nn:=n-1;\nend;\nif k=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "begin\n var n := ReadInteger;\n var a := ReadString.ToIntegers;\n if a.Any(x -> x = 1) then\n Print('HARD')\n else Print('EASY')\nend."}, {"source_code": "program ff;\nvar a,b:integer; \nbegin \nread(a);\nfor a:=1 to a do \nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\n end."}, {"source_code": "var n,k, i,m:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(m);\nif m=1 then k:=1;\nend;\nif k=1 then write('HARD') else write('EASY');\nend. \n"}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nbegin\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\nbegin\ninc(count);\nwrite('hard');\nexit;\nend;\n write('easy');\n end;\nend."}, {"source_code": "Var a:array[1..1000] of integer;\n n,i,b:integer;\n begin\n b:=0;\n for i:=1 to n do begin\n read(a[i]);\n if a[i]=1 then begin write('hard'); b:=1; halt; end;\n end;\n if b=0 then write('easy');\n end."}, {"source_code": "var a:array[1..100]of integer;\ni,n,k:integer;\nbegin\n readln(n);\n k:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]-1=0 then inc(k);\n if k>0 then writeln('HARD');\n end."}, {"source_code": "var a,b,i:integer; \nbegin\ni:=1;\nread(a);\n\nfor i:=1 to a do begin\nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\nend;\n end."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q1 then begin writeln('HARD'); halt; end;\n end;\n writeln('EASY');\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var a,i,e:integer;\n s:string;\nbegin\n readln(a);\n readln(s);\n i:=0;\n e:=0;\n if s[1] = '1' then\n e:=e+1;\n if s[1] = '0' then\n e:=0\n else\n while (s[i] <> '1') or (i <> a) do\n begin\n if s[i] = '1' then\n e:=e+1;\n i:=1+i;\n end;\n if e = 0 then\n write('EASY')\n else\n write('HARD');\nend."}, {"source_code": "program loc;\ntype sir=array [1..100] of integer;\nvar n,i,k:integer;\n s:sir;\n b:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do \nreadln(s[i]);\nfor i:=1 to n do \nif s[i]=1 then b:=true;\nif b=true then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "program Pro2;\n Uses sysutils,StrUtils;\nvar\n n,otvet:string;\n a,i:integer;\n resa,l:integer;\n\nbegin\nreadln(n);\nreadln(otvet);\na:=strtoint(n);\notvet:=AnsiReplaceStr(otvet,' ','');\nresa:=0;\nfor i:=1 to a do\nbegin\nl:=strtoint(otvet[i]);\nresa:=resa xor l;\nend;\nif resa=0 then writeln('EASY') else writeln('HARD');\nend.\n "}, {"source_code": "var n, i , temp:longint;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(temp);\n if temp = 1 then begin write('HARD'); exit; end;\n end;\n write('EASY');\nend."}, {"source_code": "var\n n,i,x:longint;\n p,p1:boolean;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x=0 then p:=true;\n end;\n if (p=true) then writeln('HARD')\n else writeln('EASY');\nend."}, {"source_code": "var a:Array[1..100]of integer; flag:boolean; n,i:integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do if a[i]=1 then flag:=True else flag:=False;\nif flag=true then writeln('hard') else writeln('easy');\nend."}, {"source_code": "begin\nend."}, {"source_code": "var\ni, n, a:integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a);\nif a=1 then write('hard')\nelse write('eaze');\nend."}, {"source_code": "var n,k,i:integer;\nbegin\n\tread(n);\n\tfor i:=1 to n do\n\tbegin\n\t\tread(k);\n\t\tif k=1 then\n\t\t\tbegin\n\t\t\twriteln('HARD');\n\t\t\texit;\n\t\t\tend;\t\n\tend;\n\twriteln('EAZY');\nend."}, {"source_code": "var a,b,i:integer; \nbegin \nread(a);\ni:=1;\nfor i:=1 to a do \nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\n end."}, {"source_code": "var i,n,m,count:Integer;\nbegin\nread(n);\nfor i:= 1 to n do\nread(m);\nif m=1\nthen\nbegin\ninc(count);\nwrite('hard');\nexit;\nend;\nif count=0\nthen write('easy');\nend."}, {"source_code": "begin\n var n := ReadInteger;\n var a := ReadString.ToIntegers;\n if a.Any(x -> x = 1) then\n Print('HARD')\n else Print('EASY')\nend."}, {"source_code": "var a:array[1..100]of integer;\ni,n,k:integer;\nbegin\n readln(n);\n k:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]-1=0 then inc(k);\n if k>0 then writeln('HARD');\n end."}, {"source_code": "Var a,b,c,d,q: integer;\nbegin\nreadln(c);\nfor d:=1 to c do\nread(a);\nfor d:=1 to c do\nif a<>0 then q:=q+1\nelse q:=q+0;\nif q=0 then writeln('EASY')\nelse writeln('HARD');\nend.\n"}, {"source_code": "program n_1;\nvar n, i, g: integer;\na: array [1..100] of integer;\nbegin\nreadln(n);\ng:=0;\nfor i:=1 to n do\nbegin\nread(a[i]);\nif (a[i]=1) and (g = 0) then\nbegin\nwrite('HARD');\ng:=1;\nend;\nend;\nif (i=100) then\nwrite('EASY');\nend. "}, {"source_code": "var\notv:array[1..100] of byte;\ni,j,k,flag:byte;\nez,hr:string;\nbegin\nez:='Easy';\nhr:='Hard';\nreadln(k);\nfor i:=1 to k do\nread(otv[i]);\nflag:=0;\nfor j:=1 to k do\nbegin\nif otv[j]=1 then begin\nwriteln(hr);\nbreak;\nend;\nif ((otv[j]=0) and (flag<>1)) then\nflag:=1;\nend;\nIf flag=1 then writeln(ez);\nend.\n\n"}, {"source_code": "var n,i,a:integer;\nbegin\n read(n);\n for i:= 1 to n do read(a);\n if a = 0 then writeln('EASY')\n else writeln('HARD');\nend.\n"}, {"source_code": "var C,I,A,n:integer;\nbegin\n readln(n);\n c:=0;\n FOR i:=1 to n do\n begin\n read(a);\n C:=c+a;\n end;\n if c=0 then\n writeln('EASE')\n else\n writeln('HARD');\nend."}, {"source_code": "var a,b,i:integer; \nbegin \nread(a);\ni:=1;\nfor i:=1 to a do begin\nread(b);\nif b=1 then writeln('HARD') else writeln('EASY');\nend;\n end."}, {"source_code": "var n:array[1..100] of integer;\n j,i,k:integer;\nbegin\nreadln(k);\nj:=0;\nfor i:=1 to k do\nbegin\nreadln(n[i]);\nj:=j+n[i];\nend;\nif j-1<0 then write('easy')else\nwrite('hard');\nreadln;\nend.\n"}, {"source_code": "var\ni, n, k:integer;\nbegin\nread(n);\nk:=0;\nwhile n>0 do begin\nread(k);\nif i>0 then k:=1;\nn:=n-1;\nend;\nif k=1 then writeln('HARD') else writeln('EASY');\nend."}, {"source_code": "var\n n,i,m:integer;\n\nbegin\n readln(n);\nfor i:=1 to n do\n begin\n read(m);\n end;\nif m=1 then\n begin\n writeln('Hard');\n end\nelse\n writeln('EASY');\nend."}, {"source_code": "Program A;\nVar n,i,b,C:integer;\nBegin\n repeat\n Readln(n);\n Writeln('Неверные входные данные. Повторите попытку');\n until (n>0) and (n<100);\n C:=0;\n for i:=1 to n do begin\n read(b);\n if b=1 then c:=1 else if (b<>0) and (b<>1) then c:=2;\n end;\n if c=1 then writeln('HARD') \n else if c=2 then writeln('Неверные входные данные')\n else writeln('EASY');\nend."}, {"source_code": "var\n n,i,m:integer;\nbegin\n readln(n);\nfor i:=1 to n do\n begin\n read(m);\n end;\nif m=1 then\n writeln('Hard')\nelse\n writeln('EASY');\nend."}, {"source_code": "program Z_1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, a, k: integer;\n\nbegin\n readln(n);\n k := 0;\n for i := 1 to n do\n read(a);\n if (a = 1) then\n inc(k);\n if (k = 0) then\n writeln('EASY')\n else\n writeln('HARD');\n readln;\nend.\n "}], "src_uid": "060406cd57739d929f54b4518a7ba83e"} {"source_code": "\nvar\n a:array[1..4,1..2] of integer;\n a1,a2,a3,a4:integer;\n i:integer;\nbegin\n for i:=1 to 4 do\n begin\n readln(a[i,1],a[i,2]);\n end;\n if (a[1,1]>a[4,2]) and (a[2,2]>a[3,1]) then\n a1:=1;\n if (a[1,1]a[3,2]) and (a[2,2]>a[4,1]) then\n a2:=1;\n if (a[1,1]a[4,2]) and (a[1,2]>a[3,1]) then\n a3:=1;\n if (a[2,1]a[3,2]) and (a[1,2]>a[4,1]) then\n a4:=1;\n if (a[2,1] a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nfl := false;\nfl1 := false;\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nswap(1, 2);\n\nfl1 := false;\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nwriteln('Team 2');\n\nend."}, {"source_code": "var a,b:array[1..488] of longint;\nwinn,draww,win,draw,i,j,s1,s2,f1,f2:longint;\nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n s1:=a[1];\n s2:=b[2];\n f1:=a[2];\n f2:=b[1];\n if(a[3]>s2)and(b[4]>s1) then begin win:=1; end;\n if(a[4]>s2)and(b[3]>s1) then begin win:=1; end;\n if(a[3]>=s2)or(b[4]>=s1) then begin draw:=1; end;\n if(a[4]>=s2)or(b[3]>=s1) then begin draw:=1; end;\n if(a[3]>f2)and(b[4]>f1) then begin winn:=1; end;\n if(a[4]>f2)and(b[3]>f1) then begin winn:=1; end;\n if(a[3]>=f2)or(b[4]>=f1) then begin draww:=1; end;\n if(a[4]>=f2)or(b[3]>=f1) then begin draww:=1; end;\n if win+winn=2 then writeln('Team 2')\n else if draw+draww=2 then Writeln('Draw')\n else\n Writeln('Team 1');\nend."}, {"source_code": "const fi='';\n fo='';\n s1='Team 1';\n s2='Team 2';\n s0='Draw';\nvar f,g:Text;\n a,b,stop:array[1..4] of integer;\n i,tam,tam2,att1,def1,att2,def2:integer;\nbegin\n assign(f,fi);\n reset(f);\n assign(G,fo);\n rewrite(g);\n for i:=1 to 4 do\n readln(F,a[i],b[i]);\n close(f);\n\n for i:=1 to 2 do\n begin\n att1:=a[i];\n def1:=b[3-i];\n att2:=a[3];\n def2:=b[4];\n if (att2>def1) and (def2>att1) then tam:=2\n else if (att2def1) and (def2>att1) then tam2:=2\n else if (att2d[1]) and (d[0]>a[1])) then begin\n\t win[j]:=1;\n\t end;\n\t if ((a[1]>d[0]) and (d[1]>a[0])) then begin\n\t win[j]:=2;\n\t end;\n end;\n if ((win[0]=1) and (win[1]=1)) then begin\n\t writeln('Team 1');\n\t exit;\n end;\n if ((win[0]=2) or (win[1]=2)) then\n\t z:=z+1;\n\t\n end;\n if (z>=2) then begin\n writeln('Team 2');\n exit;\n end;\n {for i:=0 to 1 do begin\n a[0]:=y[i,0]; d[0]:=y[1-i,1];\n win[0]:=0; win[1]:=0;\n for j:=0 to 1 do begin\n\t a[1]:=x[j,0]; d[1]:=x[1-j,1];\n\t writeln(a[0],' ',d[0]);\n\t writeln(a[1],' ',d[1]);\n\t if ((a[0]>d[1]) and (d[0]>a[1])) then begin\n\t win[j]:=2;\n\t end;\n\t if ((a[1]>d[0]) and (d[1]>a[0])) then begin\n\t win[j]:=1;\n\t end;\n end;\n if ((win[0]=2) and (win[1]=2)) then begin\n\t writeln('Team 2');\n\t exit;\n end;\n end;}\n writeln('Draw');\nend.\n \n \n"}, {"source_code": "var i: LongInt;\na,b: array[0..101] of LongInt;\nbegin\n for i:=1 to 4 do Readln(a[i],b[i]);\n if (a[1]>b[4]) and (b[2]>a[3]) and (a[1]>b[3]) and (b[2]>a[4]) or (a[2]>b[4]) and (b[1]>a[3]) and (a[2]>b[3]) and (b[1]>a[4]) then Writeln('Team 1') else\n if ((a[3]>b[2]) and (b[4]>a[1]) or (a[4]>b[2]) and (b[3]>a[1])) and ((a[3]>b[1]) and (b[4]>a[2]) or (a[4]>b[1]) and (b[3]>a[2])) then Writeln('Team 2') else Writeln('Draw');\nend."}, {"source_code": "var a,b,c:array[1..4] of longint;\n i,j,k,m,l,o,p,n,ans,ans1,ans2,ans3:longint;\n begin\n for i:=1 to 4 do read(a[i],b[i]);\n if (a[1]b[3]) and (b[2]>a[4]) and (a[1]>b[4]) and (b[2]>a[3]) then ans2:=1;\n if (a[2]>b[3]) and (b[1]>a[4]) and (a[2]>b[4]) and (b[1]>a[3]) then ans2:=1;\n if (ans+ans1=2) then write('Team 2')\n else if (ans2=1) then write('Team 1')\n else write('Draw')\n End."}, {"source_code": "var a,b:array[1..4]of integer;\n i,x1,x2:integer;\nfunction max(x,y:integer):integer;\nbegin\n if x>y then\n max:=x\n else\n max:=y;\nend;\n\nfunction check(a1,d1:integer):integer;\nbegin\n if ((a[3]>d1)and(b[4]>a1))or((a[4]>d1)and(b[3]>a1)) then\n check:=-1\n else\n if ((d1>a[3])and(a1>b[4]))and((d1>a[4])and(a1>b[3])) then\n check:=1\n else\n check:=0;\nend;\n\nbegin\n for i:=1 to 4 do\n readln(a[i],b[i]);\n x1:=check(a[1],b[2]);\n x2:=check(a[2],b[1]);\n case max(x1,x2) of\n -1:writeln('Team 2');\n 0:writeln('Draw');\n 1:writeln('Team 1');\n end;\n readln;\nend.\n\n\n\n"}, {"source_code": "var a:array [1..4,1..2] of longint;\n fl:array[1..4] of longint;\ni,flag:longint;\nbegin\nfor i:=1 to 4 do\nreadln(a[i,1],a[i,2]);\nif ((a[3,1]>a[1,2]) and (a[4,2]>a[2,1])) then fl[1]:=1\nelse if ((a[3,1]a[2,2]) and (a[4,2]>a[1,1])) then fl[2]:=1\nelse if ((a[3,1]a[1,1]) and (a[4,1]>a[2,2])) then fl[3]:=1\nelse if ((a[3,2]a[2,1]) and (a[4,1]>a[1,2])) then fl[4]:=1\nelse if ((a[3,2]c.at) and (a.def>d.at) and (b.at>c.def) and (b.at>d.def)) or ((b.def>c.at) and (b.def>d.at) and (a.at>c.def) and (a.at>d.def)) then\n writeln('Team 1')\n else\n if (((c.def>a.at) and (d.at>b.def)) or ((d.def>a.at) and (c.at>b.def))) and (((c.def>b.at) and (d.at>a.def)) or ((d.def>b.at) and (c.at>a.def))) then\n writeln('Team 2')\n else\n writeln('Draw');\nend. "}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q,dem:integer;\nf:text;\na:array[1..4,1..2] of integer;\nkt1,kt2:boolean;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if (a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n kt1:=false;kt2:=false;\n for i:=1 to 2 do\n begin\n dem:=0;\n if i=1 then j:=2 else j:=1;\n for k:=3 to 4 do\n begin\n if k=3 then q:=4 else q:=3;\n if (a[i,1] < a[q,2]) and (a[j,2] < a[k,1]) then\n if i=1 then kt1:=true else kt2:=true;\n end;\n end;\n\n if (kt1=true) and (kt2=true) then writeln('Team 2') else\n\n writeln('Draw');\nend.\n"}, {"source_code": "var\n a,b : array[1..4] of longint;\n i : longint;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if ((a[1] > b[3]) and (b[2] > a[4]) and (a[1] > b[4]) and (b[2] > a[3])) or\n ((a[2] > b[3]) and (b[1] > a[4]) and (a[2] > b[4]) and (b[1] > a[3])) then begin writeln('Team 1'); halt; end;\n if (((a[3] > b[1]) and (b[4] > a[2])) or ((a[4] > b[1]) and (b[3] > a[2]))) and\n (((a[3] > b[2]) and (b[4] > a[1])) or ((a[4] > b[2]) and (b[3] > a[1]))) then begin writeln('Team 2'); halt; end;\n writeln('Draw');\nend."}, {"source_code": "var a,b:array[1..4] of longint;\n i:longint;\n \nprocedure finish(x:longint);\nbegin\nif x=1 then write('Team 1');\nif x=2 then write('Team 2');\nif x=3 then write('Draw');\nhalt;\nend;\n\nBEGIN\nfor i:=1 to 4 do readln(a[i],b[i]);\nif (a[1]>b[3]) and (b[2]>a[4]) and (a[1]>b[4]) and (b[2]>a[3]) then finish(1);\nif (a[2]>b[3]) and (b[1]>a[4]) and (a[2]>b[4]) and (b[1]>a[3]) then finish(1);\nif (((a[3]>b[1]) and (b[4]>a[2])) or ((a[4]>b[1]) and (b[3]>a[2]))) and (((a[3]>b[2]) and (b[4]>a[1])) or ((a[4]>b[2]) and (b[3]>a[1]))) then finish(2);\nfinish(3);\nEND."}, {"source_code": "var\n a,b:array[1..4]of longint;\n i,m,n,k,l,w,s,j,k1,k2,k3:longint;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n\n if (b[1]>a[3])and(b[1]>a[4])and(a[2]>b[3])and(a[2]>b[4]) then begin writeln('Team 1'); halt; end;\n if (a[1]>b[3])and(a[1]>b[4])and(b[2]>a[3])and(b[2]>a[4]) then begin writeln('Team 1'); halt; end;\n\n if ((a[1]n4) and (n1>o3)) and ((o2>n3) and (n1>o4))) or\n (((o1>n4) and (n2>o3)) and ((o1>n3) and (n2>o4))) then Writeln('Team 1')\n else\n if (((n4>o1) and (o3>n2)) or ((n3>o1) and (o4>n2))) and\n (((n4>o2) and (o3>n1)) or ((n3>o2) and (o4>n1))) then Writeln('Team 2')\n else Writeln('Draw');\n end.\n"}, {"source_code": "var a1,b1,a2,b2,a3,b3,a4,b4,x,y:longint;\n t1,t2,d:boolean;\n\nbegin\n\n t1:=false;t2:=false;d:=false;\n\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n\n {First Case}\n if (a1>b3) and (b2>a4) and (a1>b4) and (b2>a3) then\n begin\n writeln('Team 1');\n halt;\n end;\n if (a2>b3) and (b1>a4) and (a2>b4) and (b1>a3) then\n begin\n writeln('Team 1');\n halt;\n end;\n\n //////////////////////\n\n {First Case}\n if ((a3>b2) and (b4>a1)) or ((a4>b2) and (b3>a1)) then\n if ((a3>b1) and (b4>a2)) or ((a4>b1) and (b3>a2))\n then\n begin\n writeln('Team 2');\n halt;\n end;\n\n writeln('Draw');\n\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n a1,b1,a2,b2,a3,b3,a4,b4:longint;\nbegin\n readln(a1,b1); readln(a2,b2); readln(a3,b3); readln(a4,b4);\n if ((a1>b3) and (b2>a4) and (a1>b4) and (b2>a3)) or \n ((a2>b3) and (b1>a4) and (a2>b4) and (b1>a3)) then begin writeln('Team 1'); halt(0); end;\n if (((a3>b2) and (b4>a1)) or ((a4>b2) and (b3>a1))) and\n (((a3>b1) and (b4>a2)) or ((a4>b1) and (b3>a2))) then begin writeln('Team 2'); halt(0); end;\n writeln('Draw');\nend."}, {"source_code": "var a1,a2,a3,a4,d1,d2,d3,d4 : longint;\nbegin\nreadln ( a1, d1);\nreadln ( a2, d2);\nreadln ( a3, d3);\nreadln ( a4, d4);\n\nif (a1>d3) and\n (a1>d4) and\n (d2>a3) and\n (d2>a4) then writeln('Team 1') else\nif (a2>d3) and\n (a2>d4) and\n (d1>a3) and\n (d1>a4) then writeln('Team 1') else\n\n\nif ( ( ( a3 > d2 ) and ( d4 > a1 ) ) or\n ( ( a4 > d2 ) and ( d3 > a1 ) ) ) and\n ( ( ( a3 > d1 ) and ( d4 > a2 ) ) or\n ( ( a4 > d1 ) and ( d3 > a2 ) ) ) then writeln('Team 2')\n else writeln('Draw');\n\n\nend.\n\n\n"}, {"source_code": "var\n i,j,n,m,k,kol,ans,res:longint;\n b,a:array[0..1000] of longint;\n fa,fb:boolean;\nprocedure ch1;\nbegin\n writeln('Team 1');\n halt;\nend;\n\n\nprocedure ch2;\nbegin\n writeln('Team 2');\n halt;\nend;\n\n\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n for i:=1 to 4 do readln(a[i],b[i]);\n if (b[1]>a[3])and(b[1]>a[4])and(a[2]>b[3])and(a[2]>b[4]) then ch1;\n if (b[2]>a[3])and(b[2]>a[4])and(a[1]>b[3])and(a[1]>b[4]) then ch1;\n\n if ((b[3]>a[1])and(a[4]>b[2]))or((b[4]>a[1])and(a[3]>b[2])) then fa:=true;\n if ((b[4]>a[2])and(a[3]>b[1]))or((b[3]>a[2])and(a[4]>b[1])) then fb:=true;\n if (fa)and(fb) then ch2;\n writeln('Draw');\nend.\n"}, {"source_code": "var i:integer;\na,b:array[1..4] of integer;\nw1,w2:boolean;\n\nbegin\n w1:=false;\n w2:=false;\n for i:=1 to 4 do readln(a[i],b[i]);\n w1:=(((a[1]>b[3]) and (b[2]>a[4]))\n and ((a[1]>b[4]) and (b[2]>a[3])))\n or (((a[2]>b[3]) and (b[1]>a[4]))\n and ((a[2]>b[4]) and (b[1]>a[3])));\n w2:=(((a[3]>b[1]) and (b[4]>a[2]))\n or ((a[4]>b[1]) and (b[3]>a[2])))\n and (((a[3]>b[2]) and (b[4]>a[1]))\n or ((a[4]>b[2]) and (b[3]>a[1])));\n if w1 then writeln('Team 1') else\n if w2 then writeln('Team 2') else\n writeln('Draw');\nend."}, {"source_code": "Var a,b,n,m,x,y,k,l,q,p,t:longint;\n Begin\n Read(a,b,n,m);\n Read(x,y,k,l);\n q:=0;\n p:=0;\n if (a>y)and(m>k)then q:=1 else\n if (al)and(m>x)then p:=1 else\n if (ay)and(b>k)then t:=1 else\n if (nl)and(b>x)then p:=1 else\n if (nt2)and(c1>c2) then Tinh := 1\n else if (t1ar[x].n)and(j.n>ar[x].z) then exit(1);\n if (j.zy2) and (x2>y1) then inc(t);\n if (y1>x2) and (y2>x1) then inc(f);\n end;\n if t=2 then begin writeln('Team 1'); exit; end;\n if f>0 then inc(y);\n end;\n if y=2 then begin writeln('Team 2'); exit; end\n else writeln('Draw');\nend."}, {"source_code": "var a1,a2,b1,b2,i,j,k,k1,k2:longint;\n a,b:array[0..5] of longint;\n begin\n for i:=1 to 4 do\n read(a[i],b[i]);\n\n for i:=1 to 2 do\n begin\n if (i=1) then begin a1:=a[1];b1:=b[2]; end\n else begin a1:=a[2];b1:=b[1]; end;\n\n k1:=0;\n k2:=0;\n for j:=1 to 2 do\n begin\n if (j=1) then begin a2:=a[3];b2:=b[4]; end\n else begin a2:=a[4];b2:=b[3]; end;\n\n if (a1>b2) and (b1>a2) then inc(k1)\n else\n if (a2>b1) and (b2>a1) then inc(k2);\n end;\n\n if (k1=2) then begin writeln('Team 1');halt;end;\n if (k2>0) then inc(k);\n end;\n\n if (k=2) then writeln('Team 2')\n else writeln('Draw');\n end."}, {"source_code": "var a,b: array[1..4] of longint;\n i: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n for i:=1 to 4 do read(a[i],b[i]);\n\n if (a[1]>b[3]) and (b[2]>a[4]) and (a[1]>b[4]) and (b[2]>a[3]) or\n (a[2]>b[3]) and (b[1]>a[4]) and (a[2]>b[4]) and (b[1]>a[3])\n then writeln('Team 1')\n else if ((b[3]>a[1]) and (a[4]>b[2]) or (b[4]>a[1]) and (a[3]>b[2])) and\n ((b[3]>a[2]) and (a[4]>b[1]) or (b[4]>a[2]) and (a[3]>b[1]))\n then writeln('Team 2') else writeln('Draw')\n\nend."}, {"source_code": "function f(a,b,c,d:longint):boolean;\nbegin\n if (a > c) and (b > d) then\n exit(True);\n exit(False);\nend;\n \nvar\n a,b:array[1..4]of longint;\n i:longint;\n \nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n if (f(a[1],b[2],b[3],a[4]) and f(a[1],b[2],b[4],a[3])) or (f(a[2],b[1],b[3],a[4]) and f(a[2],b[1],b[4],a[3])) then \n begin\n write('Team 1');\n exit;\n end;\n if (f(a[3],b[4],b[1],a[2]) or f(a[4],b[3],b[1],a[2])) and (f(a[3],b[4],b[2],a[1]) or f(a[4],b[3],b[2],a[1])) then \n begin\n write('Team 2');\n exit;\n end;\n write('Draw')\nend."}, {"source_code": "function f(a,b,c,d:longint):boolean;\nbegin\n if (a>c) and (b>d) then\n exit(True);\n exit(False);\nend;\n \nvar\n a,b:array[1..4]of longint;\n i:longint;\n \nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n if (f(a[1],b[2],b[3],a[4]) and f(a[1],b[2],b[4],a[3])) or (f(a[2],b[1],b[3],a[4]) and f(a[2],b[1],b[4],a[3])) then \n begin\n write('Team 1');\n exit;\n end;\n if (f(a[3],b[4],b[1],a[2]) or f(a[4],b[3],b[1],a[2])) and (f(a[3],b[4],b[2],a[1]) or f(a[4],b[3],b[2],a[1])) then \n begin\n write('Team 2');\n exit;\n end;\n write('Draw')\nend."}, {"source_code": "var a:array [0..200,0..200] of longint;\nd,t,e,blok:array [0..1000] of longint;\nx,y,z,i,j,n,m,q,w:longint;\n begin\n read(d[1],t[1]);\n read(d[2],t[2]);\n read(d[3],t[3]);\n read(d[4],t[4]);\n if (d[1]>t[3]) and (t[2]>d[4]) and (d[1]>t[4]) and (t[2]>d[3]) then begin write('Team 1'); halt; end;\n if (d[2]>t[3]) and (t[1]>d[4]) and (d[2]>t[4]) and (t[1]>d[3]) then begin write('Team 1'); halt; end;\n if (d[1] c) and (b > d) then\n exit(True);\n exit(False);\nend;\n \nvar\n a,b:array[1..4]of longint;\n i:longint;\n \nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n if (f(a[1],b[2],b[3],a[4]) and f(a[1],b[2],b[4],a[3])) or (f(a[2],b[1],b[3],a[4]) and f(a[2],b[1],b[4],a[3])) then \n begin\n write('Team 1');\n exit;\n end;\n if (f(a[3],b[4],b[1],a[2]) or f(a[4],b[3],b[1],a[2])) and (f(a[3],b[4],b[2],a[1]) or f(a[4],b[3],b[2],a[1])) then \n begin\n write('Team 2');\n exit;\n end;\n write('Draw')\nend."}, {"source_code": " var s:string;c,i:longint; a,b:array[0..8]of longint;\nbegin\nfor i:=1 to 4 do read(a[i],b[i]);\n\n\n if (a[1]>b[3])and(a[1]>b[4])and(b[2]>a[3])and(b[2]>a[4])or\n (a[2]>b[3])and(a[2]>b[4])and(b[1]>a[3])and(b[1]>a[4]) then write('Team 1')else\nif ((a[1] R2.sattack) and (L2.sattack > R1.sdefend);\nend;\n\nprocedure Solve;\nvar\n flag1, flag2: Boolean;\nbegin\n flag1 := Win(a, b, c, d) and Win(a, b, d, c) or\n Win(b, a, c, d) and Win(b, a, d, c);\n flag2 := (Win(c, d, a, b) or Win(d, c, a, b)) and\n (Win(c, d, b, a) or Win(d, c, b, a));\n if not flag1 and not flag2 then WriteLn(fo, 'Draw')\n else\n if flag1 then WriteLn(fo, 'Team 1')\n else WriteLn(fo, 'Team 2');\nend;\n\nbegin\n AssignFile(fi, InputFile); Reset(fi);\n AssignFile(fo, OutputFile); Rewrite(fo);\n try\n Enter;\n Solve;\n finally\n CloseFile(fi); CloseFile(fo);\n end;\nend.\n"}, {"source_code": "var\n a,d:array[1..4] of longint;\n cnt,i:longint;\n\nprocedure ans(s:string);\nbegin\n writeln(s);\n halt;\nend;\n\nbegin\n for i:=1 to 4 do readln(a[i],d[i]);\n if ((a[1]>d[3]) and (d[2]>a[4])) and ((a[1]>d[4]) and (d[2]>a[3])) then ans('Team 1');\n if ((d[1]>a[3]) and (a[2]>d[4])) and ((d[1]>a[4]) and (a[2]>d[3])) then ans('Team 1');\n cnt:=0;\n if ((a[3]>d[1]) and (d[4]>a[2])) or ((a[4]>d[1]) and (d[3]>a[2])) then inc(cnt);\n if ((a[3]>d[2]) and (d[4]>a[1])) or ((a[4]>d[2]) and (d[3]>a[1])) then inc(cnt);\n if (cnt=2) then ans('Team 2') else ans('Draw');\nend."}, {"source_code": "var\n def:array[1..4] of longint;\n atk:array[1..4] of longint;\n i,j:longint;\n ans:integer;\n sit_win:array[1..4] of longint;\n contr:array[1..4,1..4,1..2] of boolean;\n\nbegin\n For i:=1 to 4 do read(def[i],atk[i]);\n For i:=1 to 4 do\n For j:=1 to 4 do\n begin\n If def[i]>atk[j] Then contr[i,j,1]:=true;\n If atk[i]>def[j] Then contr[i,j,2]:=true;\n end;\n For i:=1 to 2 do\n begin\n For j:=1 to 2 do\n begin\n If (contr[i,j+2,1] and contr[3-i,5-j,2]) Then sit_win[i*2+j-2]:=1;\n If (contr[j+2,i,2] and contr[5-j,3-i,1]) Then sit_win[i*2+j-2]:=2;\n end;\n end;\n ans:=0;\n If ((sit_win[1]=1) and (sit_win[2]=1)) or ((sit_win[3]=1) and (sit_win[4]=1)) Then ans:=1;\n If ((sit_win[1]=2) or (sit_win[2]=2)) and ((sit_win[3]=2) or (sit_win[4]=2)) Then ans:=2;\n Case ans of\n 0:writeln('Draw');\n 1:writeln('Team 1');\n 2:writeln('Team 2');\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "Var a1,b1,c1,d1,a2,b2,c2,d2:longint;\nfunction proverka(x,y,z,k:longint):boolean;\nbegin\n if (x>y)and(z>k)\n then proverka:=true\n else proverka:=false;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n read(a1,b1,c1,d1,a2,b2,c2,d2);\n if (proverka(a1,b2,d1,c2) and proverka(a1,d2,d1,a2)) or (proverka(c1,b2,b1,c2) and proverka(c1,d2,b1,a2))\n then begin writeln('Team 1'); halt(0) end;\n if (proverka(a2,b1,d2,c1) or proverka(c2,b1,b2,c1))and (proverka(a2,d1,d2,a1) or proverka(c2,d1,b2,a1))\n then writeln('Team 2')\n else writeln('Draw');\nend."}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if ( ((a[1]>b[3]) and (a[1]>b[4]) and (b[2]>a[3]) and (b[2]>a[4])) or ((a[2]>b[3]) and (a[2]>b[4]) and (b[1]>a[3]) and (b[1]>a[4])) )\n then writeln ('Team 1') else\n if ( (((a[1]b[3])and(b[2]>a[4]))and((a[1]>b[4])and(b[2]>a[3])) then begin Write('Team 1'); halt(0); end;\n if ((a[2]>b[3])and(b[1]>a[4]))and((a[2]>b[4])and(b[1]>a[3])) then begin Write('Team 1'); halt(0) end;\n if ((a[1] b[4]) and (b[2] > a[3]) then d[1][1] := 1;\n if (a[1] < b[4]) and (b[2] < a[3]) then d[1][1] := 2;\n\n if (a[1] > b[3]) and (b[2] > a[4]) then d[1][2] := 1;\n if (a[1] < b[3]) and (b[2] < a[4]) then d[1][2] := 2;\n\n if (a[2] > b[4]) and (b[1] > a[3]) then d[2][1] := 1;\n if (a[2] < b[4]) and (b[1] < a[3]) then d[2][1] := 2;\n\n if (a[2] > b[3]) and (b[1] > a[4]) then d[2][2] := 1;\n if (a[2] < b[3]) and (b[1] < a[4]) then d[2][2] := 2;\n\n k := 0;\n if ((d[1][1] = 1) and (d[1][2] = 1)) or ((d[2][1] = 1) and (d[2][2] = 1)) then k := 1;\n if ((d[1][1] = 2) or (d[1][2] = 2)) and ((d[2][1] = 2) or (d[2][2] = 2)) then k := 2;\n\n if k = 1 then Writeln('Team 1');\n if k = 2 then Writeln('Team 2');\n if k = 0 then Writeln('Draw');\nend.\n"}, {"source_code": "Var a1,a2,a3,a4,b1,b2,b3,b4,k:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n if ((a1>b3) and (a1>b4))and((b2>a3)and(b2>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a2>b3) and (a2>b4))and((b1>a3)and(b1>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n k:=0;\n{ if ((a3>b1)and(b4>a2))or((a3>b2)and(b4>a1)) then\n inc(k);\n if ((a4>b1)and(b3>a2))or((a4>b2)and(b3>a1)) then\n inc(k);}\n if ((a3>b1)and(b4>a2))or((a4>b1)and(b3>a2)) then\n inc(k);\n if ((a3>b2)and(b4>a1))or((a4>b2)and(b3>a1)) then\n inc(k);\n if k>=2 then writeln('Team 2')\n else writeln('Draw');\nend.\n"}], "negative_code": [{"source_code": "var a,b: array[1..4] of longint;\n i,amax,bmax: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n for i:=1 to 4 do read(a[i],b[i]);\n if (a[1]>=a[2]) and (b[2]>=b[1]) then begin amax:=1; bmax:=2 end\n else if (a[2]>=a[1]) and (b[1]>=b[2]) then begin amax:=2; bmax:=1 end\n else begin amax:=1; bmax:=2 end;\n\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) or\n (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3])\n then writeln('Team 1')\n else if (a[3]>a[amax]) and (b[4]>b[bmax]) or (a[4]>a[amax]) and (b[3]>b[bmax])\n then writeln('Team 2') else writeln('Draw')\n\nend."}, {"source_code": "var a,b: array[1..4] of longint;\n i: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n for i:=1 to 4 do read(a[i],b[i]);\n\n if (a[1]>b[3]) and (b[2]>a[4]) and (a[1]>b[4]) and (b[2]>a[3]) or\n (a[2]>b[3]) and (b[1]>a[4]) and (a[2]>b[4]) and (b[1]>a[3])\n then writeln('Team 1')\n else if (b[3]>a[1]) and (a[4]>b[2]) or (b[4]>a[1]) and (a[3]>b[2]) or\n (b[3]>a[2]) and (a[4]>b[1]) or (b[4]>a[2]) and (a[3]>b[1])\n then writeln('Team 2') else writeln('Draw')\n\nend."}, {"source_code": "var a,b: array[1..4] of longint;\n i: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n for i:=1 to 4 do read(a[i],b[i]);\n\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) or\n (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3])\n then writeln('Team 1')\n else if (a[3]>a[1]) and (b[4]>b[2]) or (a[4]>a[1]) and (b[3]>b[2]) or\n (a[3]>a[2]) and (b[4]>b[1]) or (a[4]>a[2]) and (b[3]>b[1])\n then writeln('Team 2') else writeln('Draw')\n\nend."}, {"source_code": "var a:array [0..200,0..200] of longint;\nd,t,e,blok:array [0..1000] of longint;\nx,y,z,i,j,n,m,q,w:longint;\n begin\n read(d[1],t[1]);\n read(d[2],t[2]);\n read(d[3],t[3]);\n read(d[4],t[4]);\n if (d[1]>d[3]) and (t[2]>t[4]) and (d[1]>d[4]) and (t[2]>t[3]) then begin write('Team 1'); halt; end;\n if (d[2]>d[3]) and (t[1]>t[4]) and (d[2]>d[4]) and (t[1]>t[3]) then begin write('Team 1'); halt; end;\n if (d[1]t[3]) and (t[2]>d[4]) and (d[1]>t[4]) and (t[2]>d[3]) then begin write('Team 1'); halt; end;\n if (d[2]>t[3]) and (t[1]>d[4]) and (d[2]>t[4]) and (t[1]>d[3]) then begin write('Team 1'); halt; end;\n if (d[1]b[3])and(a[1]>b[4])and(b[2]>a[3])and(b[2]>a[4])or\n (a[2]>b[3])and(a[2]>b[4])and(b[1]>a[3])and(b[1]>a[4]) then write('Team 1')else\nif (a[1]b[3])and(a[1]>b[4])and(b[2]>a[3])and(b[2]>a[4])or\n (a[2]>b[3])and(a[2]>b[4])and(b[1]>a[3])and(b[1]>a[4]) then write('Team 1')else\nif (a[1]y)and(z>k)\n then proverka:=true\n else proverka:=false;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n read(a1,b1,c1,d1,a2,b2,c2,d2);\n if proverka(a1,b2,d1,c2) or proverka(a1,d2,d1,a2) or proverka(c1,b2,b1,c2) or proverka(c1,d2,b1,a2)\n then begin writeln('Team 1'); halt(0) end;\n if proverka(a2,b1,d2,c1) or proverka(a2,d1,d2,a1)or proverka(c2,b1,b2,c1) or proverka(c2,d1,b2,a1)\n then writeln('Team 2')\n else writeln('Draw');\nend."}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num1,num2:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if (a[1]>=a[2]) and (b[1]<=b[2]) then\n begin\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>=a[1]) and (b[2]<=b[1]) then\n begin\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num1:=0;\n num2:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num1) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then inc(num2);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num1) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then inc(num2);\n if (num1=2) then writeln('Team 1') else\n if (num2=2) or (num2=1) then writeln('Team 2') else writeln('Draw');\n end;\nend.\n\n{\n\n2 4\n1 1\n3 5\n4 1\n\n}"}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if (a[1]>a[2]) and (b[1]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>a[1]) and (b[2]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n if (num=2) then writeln('Team 1') else\n if (num=-2) or (num=-1) then writeln('Team 2') else writeln('Draw');\n end;\nend.\n\n{\n\n2 3\n1 2\n1 1\n1 1\n\n\n}"}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if (a[1]>a[2]) and (b[1]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>a[1]) and (b[2]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n if (num=2) or (num=1) then writeln('Team 1') else\n if num=-2 then writeln('Team 2') else writeln('Draw');\n end;\nend.\n\n{\n\n2 3\n1 2\n1 1\n1 1\n\n\n}"}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num1,num2:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if (a[1]>=a[2]) and (b[1]<=b[2]) then\n begin\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>=a[1]) and (b[2]<=b[1]) then\n begin\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num1:=0;\n num2:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num1) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then inc(num2);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num1) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then inc(num2);\n if (num1=2) then writeln('Team 1') else\n if (num2=2) then writeln('Team 2') else writeln('Draw');\n end;\nend.\n\n{\n\n1 1\n1 2\n2 0\n0 3\n\n}"}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if (a[1]>a[2]) and (b[1]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>a[1]) and (b[2]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n if num=2 then writeln('Team 1') else\n if num=-2 then writeln('Team 2') else writeln('Draw');\n end;\nend.\n"}, {"source_code": "program CCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,max_a,max_b,num1,num2:integer;\n a: array [1..5] of integer;\n b: array [1..5] of integer;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if ( ((a[1]>a[3]) and (a[1]>a[4]) and (b[2]>b[3]) and (b[2]>b[4])) or ((a[2]>a[3]) and (a[2]>a[4]) and (b[1]>b[3]) and (b[1]>b[4])) )\n then writeln ('Team 1') else\n if ( (((a[1]a[2]) and (b[1]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n if (a[2]>a[1]) and (b[2]a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then writeln('Team 1') else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then writeln('Team 2') else writeln('Draw');\n end else\n\n begin\n num:=0;\n max_a:=a[1];\n max_b:=b[2];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n max_a:=a[2];\n max_b:=b[1];\n if (max_a>a[3]) and (max_a>a[4]) and (max_b>b[3]) and (max_b>b[4]) then inc(num) else\n if ((a[3]>max_a) and (b[4]>max_b)) or ((a[4]>max_a) and (b[3]>max_b)) then dec(num);\n if (num=2) or (num=1) then writeln('Team 1') else\n if (num=-2) or (num=-1) then writeln('Team 2') else writeln('Draw');\n end;\nend.\n\n{\n\n2 3\n1 2\n1 1\n1 1\n\n\n}"}, {"source_code": "Var a,b:array[1..4] of longint;\n i,x,y:longint;\n begin\n for i:=1 to 4 do\n Read(a[i],b[i]);\n if ((a[1]>b[3])and(b[2]>b[4]))and((a[1]>a[4])and(b[2]>a[3])) then begin Write('Team 1'); halt(0); end;\n if ((a[2]>b[3])and(b[1]>a[4]))and((a[2]>b[4])and(b[1]>a[3])) then begin Write('Team 1'); halt(0) end;\n if ((a[1]>b[3])and(b[2]b[3])and(b[2]>b[4]))and((a[1]>a[4])and(b[2]>a[3])) then begin Write('Team 1'); halt(0); end;\n if ((a[2]>b[3])and(b[1]>a[4]))and((a[2]>b[4])and(b[1]>a[3])) then begin Write('Team 1'); halt(0) end;\n if ((a[1] a[3]) and (b[2] > b[4]) then d[1][1] := 1;\n if (a[1] < a[3]) and (b[2] < b[4]) then d[1][1] := 2;\n if (a[1] > a[4]) and (b[2] > b[3]) then d[1][2] := 1;\n if (a[1] < a[4]) and (b[2] < b[3]) then d[1][2] := 2;\n\n if (a[2] > a[3]) and (b[1] > b[4]) then d[2][1] := 1;\n if (a[2] < a[3]) and (b[1] < b[4]) then d[2][1] := 2;\n if (a[2] > a[4]) and (b[1] > b[3]) then d[2][2] := 1;\n if (a[2] < a[4]) and (b[1] < b[3]) then d[2][2] := 2;\n\n k := 0;\n if ((d[1][1] = 1) and (d[1][2] = 1)) or ((d[2][1] = 1) and (d[2][2] = 1)) then k := 1;\n if ((d[1][1] = 2) or (d[1][2] = 2)) and ((d[2][1] = 2) or (d[2][2] = 2)) then k := 2;\n\n if k = 1 then Writeln('Team 1');\n if k = 2 then Writeln('Team 2');\n if k = 0 then Writeln('Draw');\nend.\n"}, {"source_code": "Var a1,a2,a3,a4,b1,b2,b3,b4:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n if ((a1>a3) and (a1>a4))and((b2>b3)and(b2>b4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a2>a3) and (a2>a4))and((b1>b3)and(b1>b4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a3>a1)and(b4>b2))or((a3>a2)and(b4>b1))or\n ((a4>a1)and(b3>b2))or((a4>a2)and(b3>b1)) then\n writeln('Team 2')\n else writeln('Draw');\nend.\n"}, {"source_code": "Var a1,a2,a3,a4,b1,b2,b3,b4:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n if ((a1>b3) and (a1>b4))and((b2>a3)and(b2>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a2>b3) and (a2>b4))and((b1>a3)and(b1>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a3>b1)and(b4>a2))or((a3>b2)and(b4>a1))or\n ((a4>b1)and(b3>a2))or((a4>b2)and(b3>a1)) then\n writeln('Team 2')\n else writeln('Draw');\nend.\n"}, {"source_code": "Var a1,a2,a3,a4,b1,b2,b3,b4,k:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n if ((a1>b3) and (a1>b4))and((b2>a3)and(b2>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n if ((a2>b3) and (a2>b4))and((b1>a3)and(b1>a4)) then\n begin\n writeln('Team 1');\n halt(0);\n end;\n k:=0;\n if ((a3>b1)and(b4>a2))or((a3>b2)and(b4>a1)) then\n inc(k);\n if ((a4>b1)and(b3>a2))or((a4>b2)and(b3>a1)) then\n inc(k);\n if k>=2 then writeln('Team 2')\n else writeln('Draw');\nend.\n"}, {"source_code": "function max(a,b:longint):longint;\nbegin\nif a>b then max:=a\nelse max:=b;\nend;\n\n\nvar a,b,c:array [0..5] of longint;\nn,i,j,k,res:longint;\nbegin\nfor i:=1 to 4 do\n read(a[i],b[i]);\nif a[1]>a[2] then begin\n c[1]:=a[1];\n c[2]:=b[2];\nend\nelse begin\n c[1]:=a[2];\n c[2]:=b[1];\nend;\n\n{if a[3]>c[1] then \n if (b[3]c[1]) and (b[4]>c[2])) or ((a[4]>c[2]) and (b[3]>c[1])) then\n writeln('Team 2')\n//Draw case\nelse if ((a[3]>=c[1]) and (b[4]<=c[2])) or ((a[4]>=c[1]) and (b[3]<=c[1])) or ((a[3]<=c[1]) and (b[4]>=c[2])) or ((a[4]<=c[1]) and (b[3]>=c[2])) then // or ((a[3]=c[1]) and (b[4]=c[2])) or ((a[4]=c[1]) and (b[3]=c[2])) then\n writeln('Draw')\n//Team 1 case\nelse if ((a[3] a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nfl := false;\nfl1 := false;\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then\n writeln('Draw');\n\nswap(1, 2);\n\nfl1 := false;\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then\n writeln('Draw');\n\nwriteln('Team 2');\n\nend."}, {"source_code": "var i,j,n,m,k,q:longint;\nfl, fl1:boolean;\na:array [0..4,0..2] of longint;\ntmp:array [0..2] of longint;\n\nprocedure swap(f, t:integer);\nbegin\n tmp[1] := a[f][1];\n tmp[2] := a[f][2];\n a[f][1] := a[t][1];\n a[f][2] := a[t][2];\n a[t][1] := tmp[1];\n a[t][2] := tmp[2];\nend;\n\n\nbegin\n\nfor i := 1 to 4 do\n read(a[i][1], a[i][2]);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][2]) and (a[2][2] > a[4][1]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nfl := false;\nfl1 := false;\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][2]) and (a[2][2] < a[4][1]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nswap(1, 2);\n\nfl1 := false;\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nwriteln('Team 2');\n\nend."}, {"source_code": "var i,j,n,m,k,q:longint;\nfl, fl1:boolean;\na:array [0..4,0..2] of longint;\ntmp:array [0..2] of longint;\n\nprocedure swap(f, t:integer);\nbegin\n tmp[1] := a[f][1];\n tmp[2] := a[f][2];\n a[f][1] := a[t][1];\n a[f][2] := a[t][2];\n a[t][1] := tmp[1];\n a[t][2] := tmp[2];\nend;\n\n\nbegin\n\nfor i := 1 to 4 do\n read(a[i][1], a[i][2]);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(1, 2);\n\nif (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n swap(3, 4);\n if (a[1][1] > a[3][1]) and (a[2][2] > a[4][2]) then begin\n writeln('Team 1');\n exit();\n end;\n swap(3, 4);\nend;\n\nswap(3, 4);\n\nfl := false;\nfl1 := false;\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nswap(1, 2);\n\nfl1 := false;\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (a[1][1] < a[3][1]) and (a[2][2] < a[4][2]) then\n fl1 := true;\n\nswap(3, 4);\n\nif (fl1 = false) then begin\n writeln('Draw');\n exit();\nend;\n\nwriteln('Team 2');\n\nend."}, {"source_code": "var a,b:array[1..488] of longint;\nwin,draw,i,j,s1,s2,f1,f2:longint;\nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n s1:=a[1];\n s2:=b[2];\n f1:=a[2];\n f2:=b[2];\n if(a[3]>s2)and(b[4]>s1) then begin win:=1; end;\n if(a[4]>s2)and(b[3]>s1) then begin win:=1; end;\n if(a[3]>=s2)or(b[4]>=s1) then begin draw:=1; end;\n if(a[4]>=s2)or(b[3]>=s1) then begin draw:=1; end;\n if(a[3]>f2)and(b[4]>f1) then begin win:=win+1; end;\n if(a[4]>f2)and(b[3]>f1) then begin win:=win+1; end;\n if(a[3]>=f2)or(b[4]>=f1) then begin draw:=draw+1; end;\n if(a[4]>=f2)or(b[3]>=f1) then begin draw:=draw+1; end;\n if win=2 then writeln('Team 2')\n else if draw=2 then Writeln('Draw')\n else\n Writeln('Team 1');\nend."}, {"source_code": "var a,b:array[1..488] of longint;\ni,j,s1,s2:longint;\nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n if(a[1]>=a[2])and(b[2]>=b[1]) then begin s1:=a[1]; s2:=b[2]; end\n else begin s1:=b[1]; s2:=a[2]; end;\n if(a[3]>s2)and(b[4]>s1) then begin writeln('Team 2'); exit; end;\n if(a[4]>s2)and(b[3]>s1) then begin writeln('Team 2'); exit; end;\n if(a[3]>=s2)or(b[4]>=s1) then begin writeln('Draw'); exit; end;\n if(a[4]>=s2)or(b[3]>=s1) then begin writeln('Draw'); exit; end;\n Writeln('Team 1');\nend."}, {"source_code": "var i,j,n, x, x1,x2, dx, y, y1,y2, ans1, ans2: LongInt;\na,b: array[0..101] of LongInt;\nbegin\n for i:=1 to 4 do\n Readln(a[i],b[i]);\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) or (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n if ((a[1]a[1]) and (b[4]>b[2]) or (a[4]>a[1]) and (b[3]>b[2])) or ((a[3]>a[2]) and (b[4]>b[1]) or (a[4]>a[2]) and (b[3]>b[1])) then Writeln('Team 2') else\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) and (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end else\n if x1>x2 then\n begin\n if ((a[3]>a[1]) and (b[4]>b[2]) or (a[4]>a[1]) and (b[3]>b[2])) then Writeln('Team 2') else\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end else\n begin\n if (a[3]>a[2]) and (b[4]>b[1]) or (a[4]>a[2]) and (b[3]>b[1]) then Writeln('Team 2') else\n if (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end;\nend."}, {"source_code": "var i,j,n, x, x1,x2, dx, y, y1,y2, ans1, ans2: LongInt;\na,b: array[0..101] of LongInt;\nbegin\n for i:=1 to 4 do\n Readln(a[i],b[i]);\n\n x1:=a[1]+b[2];\n x2:=a[2]+b[1];\n\n ans1:=0;\n if a[1]>a[3] then inc(ans1);\n if b[2]>b[4] then inc(ans1);\n if a[1]>a[4] then inc(ans1);\n if b[2]>b[3] then inc(ans1);\n \n ans2:=0;\n if a[2]>a[3] then inc(ans2);\n if b[1]>b[4] then inc(ans2);\n if a[2]>a[4] then inc(ans2);\n if b[1]>b[3] then inc(ans2);\n \n if ans1>ans2 then\n begin\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) then Writeln('Team 1') else\n if (a[1]a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n if (a[2]a[1]) and (b[4]>b[2]) or (a[4]>a[1]) and (b[3]>b[2])) and ((a[3]>a[2]) and (b[4]>b[1]) or (a[4]>a[2]) and (b[3]>b[1])) then Writeln('Team 2') else\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) and (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end else\n if x1>x2 then\n begin\n if ((a[3]>a[1]) and (b[4]>b[2]) or (a[4]>a[1]) and (b[3]>b[2])) then Writeln('Team 2') else\n if (a[1]>a[3]) and (b[2]>b[4]) and (a[1]>a[4]) and (b[2]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end else\n begin\n if (a[3]>a[2]) and (b[4]>b[1]) or (a[4]>a[2]) and (b[3]>b[1]) then Writeln('Team 2') else\n if (a[2]>a[3]) and (b[1]>b[4]) and (a[2]>a[4]) and (b[1]>b[3]) then Writeln('Team 1') else\n Writeln('Draw');\n end;\nend."}, {"source_code": "var a,b,c:array[1..4] of longint;\n i,j,k,m,l,o,p,n,ans,ans1,ans2,ans3:longint;\n begin\n for i:=1 to 4 do read(a[i],b[i]);\n if (a[1]b[3]) and (b[2]>a[4]) then ans2:=1;\n if (a[1]>b[4]) and (b[2]>a[3]) then ans2:=1;\n if (a[2]>b[3]) and (b[1]>a[4]) then ans3:=1;\n if (a[2]>b[4]) and (b[1]>a[3]) then ans3:=1;\n if (ans+ans1=2) then write('Team 2')\n else if (ans2+ans3=1) then write('Team 1')\n else write('Draw')\n End."}, {"source_code": "var a,b,c:array[1..4] of longint;\n i,j,k,m,l,o,p,n,ans,ans1,ans2,ans3:longint;\n begin\n for i:=1 to 4 do read(a[i],b[i]);\n if (a[1]b[3]) and (b[2]>a[4]) then ans2:=1;\n if (a[1]>b[4]) and (b[2]>a[3]) then ans2:=1;\n if (a[2]>b[3]) and (b[1]>a[4]) then ans3:=1;\n if (a[2]>b[4]) and (b[1]>a[3]) then ans3:=1;\n if (ans+ans1=2) then write('Team 2')\n else if (ans2+ans3=2) then write('Team 1')\n else write('Draw')\n End."}, {"source_code": "var a,b:array[1..4]of integer;\n i,p,q:integer;\nfunction max(x,y:integer):integer;\nbegin\n if x>y then max:=x\n else max:=y;\nend;\n\nbegin\n for i:=1 to 4 do\n readln(a[i],b[i]);\n if ((a[1]>max(b[3],b[4]))and(b[2]>max(a[3],a[4])))or((a[2]>max(b[3],b[4]))and(b[1]>max(a[3],a[4]))) then\n writeln('Team 1')\n else\n if ((a[3]>max(b[1],b[2]))and(b[4]>max(a[1],a[2])))or((a[4]>max(b[1],b[2]))and(b[3]>max(a[1],a[2]))) then\n writeln('Team 2')\n else\n writeln('Draw');\n readln;\nend.\n\n"}, {"source_code": "var a,b:array[1..4]of integer;\n i,p,q:integer;\nfunction max(x,y:integer):integer;\nbegin\n if x>y then max:=x\n else max:=y;\nend;\n\nbegin\n for i:=1 to 4 do\n readln(a[i],b[i]);\n p:=1;\n if a[p]a[q] then\n if a[3-p]>a[q] then\n if max(b[1],b[2])>max(b[3],b[4]) then\n writeln('Team 1')\n else\n writeln('Draw')\n else\n if max(b[3],b[4])max(b[1],b[2]) then\n writeln('Team 2')\n else writeln('Draw')\n else\n if max(b[1],b[2])y then max:=x\n else max:=y;\nend;\n\nbegin\n for i:=1 to 4 do\n readln(a[i],b[i]);\n p:=1;\n if a[p]b[q] then\n if a[3-p]>b[q] then\n if max(b[1],b[2])>max(a[3],a[4]) then\n writeln('Team 1')\n else\n writeln('Draw')\n else\n if b[3-p]>max(a[3],a[4]) then\n writeln('Team 1')\n else\n writeln('Draw')\n else\n if a[p]=b[q] then\n writeln('Draw')\n else\n if a[p]max(b[1],b[2]) then\n writeln('Team 2')\n else\n writeln('Draw')\n else\n if a[7-q]>b[3-p] then\n writeln('Team 2')\n else\n writeln('Draw');\n readln;\nend.\n\n"}, {"source_code": "var a,b:array[1..4]of integer;\n i,p,q:integer;\nfunction max(x,y:integer):integer;\nbegin\n if x>y then max:=x\n else max:=y;\nend;\n\nbegin\n for i:=1 to 4 do\n readln(a[i],b[i]);\n p:=1;\n if a[p]a[q] then\n if a[3-p]>a[q] then\n if max(b[1],b[2])>max(b[3],b[4]) then\n writeln('Team 1')\n else\n writeln('Draw')\n else\n if max(b[3],b[4])max(b[1],b[2]) then\n writeln('Team 2')\n else writeln('Draw')\n else\n if b[3-p] a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then\n begin\n writeln('Team 2');\n exit;\n end;\n end;\n end;\n\n writeln('Draw');\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q,dem:integer;\nf:text;\na:array[1..4,1..2] of integer;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if (a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then inc(dem);\n end;\n end;\n\n if dem>=2 then writeln('Team 2') else\n writeln('Draw')\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q,dem:integer;\nf:text;\na:array[1..4,1..2] of integer;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if (a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then inc(dem);\n end;\n end;\n\n if dem=2 then writeln('Team 2') else\n writeln('Draw')\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q,dem:integer;\nf:text;\na:array[1..4,1..2] of integer;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if (a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then inc(dem);\n end;\n end;\n\n if dem=2 then writeln('Team 2') else\n writeln('Draw')\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q:integer;\nf:text;\na:array[1..4,1..2] of integer;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n if a[1,1] < a[2,1] then\n begin\n swap(a[1,1],a[2,1]);\n swap(a[1,2],a[2,2]);\n end;\n if a[3,1] < a[4,1] then\n begin\n swap(a[3,1],a[4,1]);\n swap(a[3,2],a[4,2]);\n end;\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if ((a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]))\n or ((a[i,2] > a[3,1]) and (a[i,2] > a[4,1])\n and (a[j,1] > a[3,2]) and (a[j,1] > a[4,2])) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then\n begin\n writeln('Team 2');\n exit;\n end;\n end;\n end;\n\n writeln('Draw');\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nprogram kicker;\nvar i,n,j,k,q,dem:integer;\nf:text;\na:array[1..4,1..2] of integer;\n\nprocedure swap(var a,b:integer);\n var i:integer;\n begin\n i:=a;a:=b;b:=i;\n end;\n\nbegin\n assign(f,'');\n reset(f);\n for i:=1 to 4 do readln(f,a[i,1],a[i,2]);\n close(f);\n\n for i:=1 to 2 do\n begin\n if i=1 then j:=2 else j:=1;\n if (a[i,1] > a[3,2]) and (a[i,1] > a[4,2])\n and (a[j,2] > a[3,1]) and (a[j,2] > a[4,1]) then\n begin\n writeln('Team 1');\n exit;\n end;\n end;\n\n for i:=3 to 4 do\n begin\n dem:=0;\n if i=3 then j:=4 else j:=3;\n for k:=1 to 2 do\n begin\n if k=1 then q:=2 else q:=1;\n if (a[i,1] > a[q,2]) and (a[j,2] > a[k,1]) then inc(dem);\n end;\n end;\n\n if dem=2 then writeln('Team 2') else\n writeln('Draw')\nend.\n"}, {"source_code": "var\n a,b : array[1..4] of longint;\n at1,at2,za1,za2,i,at3,za3,at4,za4 : longint;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n at1:=b[1]; za1:=a[2];\n at2:=b[2]; za2:=a[1];\n at3:=b[3]; za3:=a[4];\n at4:=b[4]; za4:=a[3];\n if (at1 > at3) and (at1 > at4) and (za1 > za3) and (za1 > za4) then writeln('Team 1') else\n if ((at3 > at1) and (za3 > za1)) or ((at4 > at1) and (za4 > za1)) or\n ((at3 > at2) and (za3 > za2)) or ((at4 > at2) and (za4 > za2)) then writeln('Team 2') else writeln('Draw');\nend."}, {"source_code": "var\n a,b : array[1..4] of longint;\n at1,at2,za1,za2,i,at3,za3 : longint;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n if a[1] > a[2] then begin at1:=b[2]; za1:=a[1]; end else\n if a[1] < a[2] then begin at1:=b[1]; za1:=a[2]; end else\n if a[1] = a[2] then begin\n if b[1] > b[2] then begin at1:=b[1]; za1:=a[2]; end else\n begin at1:=b[2]; za1:=a[1]; end;\n end;\n\n if a[3] > a[4] then begin at2:=b[4]; za2:=a[3]; end else\n if a[3] < a[4] then begin at2:=b[3]; za2:=a[4]; end else\n if a[3] = a[4] then begin\n if b[3] > b[4] then begin at2:=b[3]; za2:=a[4]; end else\n begin at2:=b[4]; za2:=a[3]; end;\n end;\n\n if b[3] > b[4] then begin at3:=b[3]; za3:=a[4]; end else\n if b[3] < b[4] then begin at3:=b[4]; za3:=a[3]; end else\n if b[3] = b[4] then begin\n if a[3] > a[4] then begin at3:=b[4]; za3:=a[3]; end\n else begin at3:=b[3]; za3:=a[4]; end;\n end;\n if (at1 > at2) and (za1 > za2) and (at1 > at3) and (za1 > za3) then writeln('Team 1') else\n if ((at2 > at1) and (za2 > za1)) or ((at3 > at1) and (za3 > za1)) then writeln('Team 2') else writeln('Draw');\nend."}, {"source_code": "var\n a,b : array[1..4] of longint;\n at1,at2,za1,za2,i,at3,za3,at4,za4 : longint;\n\nbegin\n for i:=1 to 4 do readln(a[i],b[i]);\n at1:=b[1]; za1:=a[2];\n at2:=b[2]; za2:=a[1];\n at3:=b[3]; za3:=a[4];\n at4:=b[4]; za4:=a[3];\n if ((at1 > at3) and (za1 > za3)) or ((at1 > at4) and (za1 > za4)) or\n ((at2 > at3) and (za2 > za3)) or ((at2 > at4) and (za2 > za4)) then writeln('Team 1') else\n if ((at3 > at1) and (za3 > za1)) or ((at4 > at1) and (za4 > za1)) or\n ((at3 > at2) and (za3 > za2)) or ((at4 > at2) and (za4 > za2)) then writeln('Team 2') else writeln('Draw');\nend."}, {"source_code": "var\n a,a1,b,b1,c,c1,d,d1,w,l,s,k,k1:longint;\nbegin\n readln(a,b);\n readln(c,d);\n readln(a1,b1);\n readln(c1,d1);\n if ((a>d1)and(a>b1))or((c>d1)and(c>b1)) then writeln('Draw') else writeln('Team 2');\nend."}, {"source_code": "var\n F1,F2:Boolean;\n o1,o2,o3,o4,n1,n2,n3,n4:Longint;\nbegin\n Readln(o1,n1);\n Readln(o2,n2);\n Readln(o3,n3);\n Readln(o4,n4);\n F1:=False;\n F2:=False;\n if ((n4>o1) and (o3>n2)) or ((n3>o1) and (o4>n2)) then F2:=True\n else\n if ((o1>n4) and (n2>o3)) and ((o1>n3) and (n2>o4)) then F1:=True;\n if ((n4>o2) and (o3>n1)) or ((n3>o2) and (o4>n1)) then F2:=True\n else\n if ((o2>n4) and (n1>o3)) and ((o2>n3) and (n1>o4)) then F1:=True;\n if F1 then Writeln('Team 1')\n else\n if F2 then Writeln('Team 2')\n else Writeln('Draw');\n end.\n"}, {"source_code": "var a1,b1,a2,b2,a3,b3,a4,b4,x,y:longint;\n t1,t2,d:boolean;\n\nbegin\n\n t1:=false;t2:=false;d:=false;\n\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n\n {First Case}\n if (a1>b3) and (a1>b4) and (b2>a3) and (b2>b4) then\n begin\n writeln('Team 1');\n halt;\n end;\n {Second Case}\n if (a2>b3) and (a2>b4) and (b1>a3) and (b1>b4) then\n begin\n writeln('Team 1');\n halt;\n end;\n\n //////////////////////\n\n {First Case}\n if ((a3>b2) and (b4>a1)) or ((a4>b2) and (b3>a1)) then\n if ((a3>b1) and (b4>a2)) or ((a4>b1) and (b3>a2))\n then\n begin\n writeln('Team 2');\n halt;\n end;\n\n writeln('Draw');\n\nend."}, {"source_code": "var a1,b1,a2,b2,a3,b3,a4,b4,x,y:longint;\n t1,t2,d:boolean;\n\nbegin\n\n t1:=false;t2:=false;d:=false;\n\n readln(a1,b1);\n readln(a2,b2);\n readln(a3,b3);\n readln(a4,b4);\n\n {First Case}\n if (a1>b3) and (a1>b4) and (b2>a3) and (b2>b4) then\n begin\n writeln('Team 1');\n halt;\n end;\n {Second Case}\n if (a2>b3) and (a2>b4) and (b1>a3) and (b1>b4) then\n begin\n writeln('Team 1');\n halt;\n end;\n\n //////////////////////\n\n {First Case}\n if (a3>b1) and (a3>b2) then\n if ((b4>a1) and (b4>=a2)) or ((b4>a2) and (b4>=a1)) then\n begin\n writeln('Team 2');\n halt;\n end;\n\n {Second Case}\n if (a4>b1) and (a4>b2) then\n if ((b3>a1) and (b3>=a2)) or ((b3>a2) and (b3>=a1)) then\n begin\n writeln('Team 2');\n halt;\n end;\n\n writeln('Draw');\n\nend."}, {"source_code": "var a1,a2,a3,a4,d1,d2,d3,d4 : longint;\nbegin\nreadln ( a1, d1);\nreadln ( a2, d2);\nreadln ( a3, d3);\nreadln ( a4, d4);\n\nif (a1>d3) and\n (a1>d4) and\n (d2>a3) and\n (d2>a4) then writeln('Team 1') else\nif (a2>d3) and\n (a2>d4) and\n (d1>a3) and\n (d1>a4) then writeln('Team 1') else\n\n\nif ( ( ( a3 > d2 ) and ( d4 > a1) ) or\n ( ( a4 > d2 ) and ( d4 > a1) ) ) and\n ( ( ( a3 > d1 ) and ( d4 > a2) ) or\n ( ( a4 > d1 ) and ( d3 > a2) ) ) then writeln('Team 2')\n else writeln('Draw');\n\n\nend.\n\n\n"}, {"source_code": "var\n i,j,n,m,k,kol,ans,res:longint;\n b,a:array[0..1000] of longint;\n fa,fb:boolean;\nprocedure ch1;\nbegin\n writeln('Team 1');\n halt;\nend;\n\n\nprocedure ch2;\nbegin\n writeln('Team 2');\n halt;\nend;\n\n\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n for i:=1 to 4 do readln(a[i],b[i]);\n if (b[1]>a[3])and(b[1]>a[4])and(a[2]>b[3])and(a[2]>b[4]) then ch1;\n if (b[2]>a[3])and(b[2]>a[4])and(a[1]>b[3])and(a[1]>b[4]) then ch1;\n\n if ((b[1]a[3,1]) and (a[2,2]>a[4,2]) then\n a1:=1;\n if (a[1,1]a[4,1]) and (a[2,2]>a[3,2]) then\n a2:=1;\n if (a[1,1]a[3,1]) and (a[1,2]>a[4,2]) then\n a3:=1;\n if (a[2,1]a[4,1]) and (a[1,2]>a[3,2]) then\n a4:=1;\n if (a[2,1]a[3,1]) and (a[2,2]>a[4,2]) then\n a1:=1;\n if (a[1,1]a[4,1]) and (a[2,2]>a[3,2]) then\n a2:=1;\n if (a[1,1]a[3,1]) and (a[1,2]>a[4,2]) then\n a3:=1;\n if (a[2,1]a[4,1]) and (a[1,2]>a[3,2]) then\n a4:=1;\n if (a[2,1]a[3,1]) and (a[2,2]>a[4,2]) then\n a1:=1;\n if (a[1,1]a[4,1]) and (a[2,2]>a[3,2]) then\n a2:=1;\n if (a[1,1]a[3,1]) and (a[1,2]>a[4,2]) then\n a3:=1;\n if (a[2,1]a[3,1]) and (a[1,2]>a[4,2]) then\n a4:=1;\n if (a[2,1]ar[x].n)and(j.n>ar[x].z) then exit(1);\n if (j.za2) and (b1>b2) then inc(k1)\n else\n if (a2>a1) and (b2>b1) then inc(k2);\n end;\n\n if (k1=2) then begin writeln('Team 1');halt;end;\n if (k2>0) then inc(k);\n end;\n\n if (k=2) then writeln('Team 2')\n else writeln('Draw');\n end."}, {"source_code": "function f(a,b,c,d:longint):boolean;\nbegin\n if (a>c) and (b>d) then\n exit(True);\n exit(False);\nend;\n \nvar\n a,b:array[1..4]of longint;\n i:longint;\n \nbegin\n for i:=1 to 4 do\n read(a[i],b[i]);\n if (f(a[1],b[2],a[3],a[4]) and f(a[1],b[2],a[4],b[3])) or (f(a[2],b[1],a[3],a[4]) and f(a[2],b[1],a[4],b[3])) then \n begin\n write('Team 1');\n exit;\n end;\n if (f(a[3],b[4],a[1],a[2]) or f(a[4],b[3],a[1],b[2])) or (f(a[3],b[4],a[2],a[1]) and f(a[3],b[4],a[2],b[1])) then \n begin\n write('Team 2');\n exit;\n end;\n write('Draw')\nend."}, {"source_code": "var\n def:array[1..4] of longint;\n atk:array[1..4] of longint;\n i,j:longint;\n ans:integer;\n contr:array[1..4,1..4,1..2] of boolean;\n\nbegin\n For i:=1 to 4 do read(def[i],atk[i]);\n For i:=1 to 4 do\n For j:=1 to 4 do\n begin\n If def[i]>atk[j] Then contr[i,j,1]:=true;\n If atk[i]>atk[j] Then contr[i,j,2]:=true;\n end;\n For i:=1 to 2 do\n begin\n j:=0;\n If contr[i,3,1] then inc(j);\n If contr[i,4,1] then inc(j);\n If contr[3-i,3,2] then inc(j);\n If contr[3-i,4,2] then inc(j);\n If j=4 then\n begin\n ans:=1;\n end\n else\n begin\n If j=3 Then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If j=2 Then\n begin\n If not((contr[i,3,1] and contr[3-i,4,2]) or (contr[i,4,1] and contr[3-i,3,2])) then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If (contr[3,i,2] and contr[4,3-i,1]) or (contr[4,i,2] and contr[3,3-i,1]) Then\n begin\n If (ans<>1) and (ans<>-1) Then ans:=2;\n end\n else\n begin\n If ans<>1 then ans:=-1;\n end;\n end;\n end\n else\n begin\n j:=0;\n If contr[2+i,1,1] then inc(j);\n If contr[2+i,2,1] then inc(j);\n If contr[5-i,1,2] then inc(j);\n If contr[5-i,2,2] then inc(j);\n Case j of\n 0: If ans<>1 then ans:=-1;\n 1: If ans<>1 then ans:=-1;\n 2: If (contr[2+i,1,1] and contr[5-i,2,2]) or (contr[2+i,2,1] and contr[5-i,1,2]) or (contr[2+i,1,2] and contr[5-i,2,1]) or (contr[2+i,2,2] and contr[5-i,1,1]) Then If ans=0 Then ans:=2;\n 3: If ans=0 Then ans:=2;\n end;\n end;\n end;\n end;\n end;\n Case ans of\n -1:writeln('Draw');\n 2:writeln('Team 2');\n 1:writeln('Team 1');\n end;\n readln;\n readln;\nend."}, {"source_code": "var\n def:array[1..4] of longint;\n atk:array[1..4] of longint;\n i,j:longint;\n ans:integer;\n contr:array[1..4,1..4,1..2] of boolean;\n\nbegin\n For i:=1 to 4 do read(def[i],atk[i]);\n For i:=1 to 4 do\n For j:=1 to 4 do\n begin\n If def[i]>atk[j] Then contr[i,j,1]:=true;\n If atk[i]>atk[j] Then contr[i,j,2]:=true;\n end;\n For i:=1 to 2 do\n begin\n j:=0;\n If contr[i,3,1] then inc(j);\n If contr[i,4,1] then inc(j);\n If contr[3-i,3,2] then inc(j);\n If contr[3-i,4,2] then inc(j);\n If j=4 then\n begin\n ans:=1;\n end\n else\n begin\n If j=3 Then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If j=2 Then\n begin\n If (contr[i,3,1] and contr[i,4,1]) or (contr[3-i,3,1] and contr[3-i,4,1]) or (contr[i,3,1] and contr[3-i,3,2]) or (contr[i,4,1] and contr[3-i,4,2]) then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If (ans<>1) and (ans<>-1) Then ans:=2;\n end;\n end\n else\n begin\n If (ans<>1) and (ans<>-1) then ans:=2;\n end;\n end;\n end;\n end;\n Case ans of\n -1:writeln('Draw');\n 2:writeln('Team 2');\n 1:writeln('Team 1');\n end;\n readln;\n readln;\nend."}, {"source_code": "var\n def:array[1..4] of longint;\n atk:array[1..4] of longint;\n i,j:longint;\n ans:integer;\n contr:array[1..4,1..4,1..2] of boolean;\n\nbegin\n For i:=1 to 4 do read(def[i],atk[i]);\n For i:=1 to 4 do\n For j:=1 to 4 do\n begin\n If def[i]>atk[j] Then contr[i,j,1]:=true;\n If atk[i]>atk[j] Then contr[i,j,2]:=true;\n end;\n For i:=1 to 2 do\n begin\n j:=0;\n If contr[i,3,1] then inc(j);\n If contr[i,4,1] then inc(j);\n If contr[3-i,3,2] then inc(j);\n If contr[3-i,4,2] then inc(j);\n If j=4 then\n begin\n ans:=1;\n end\n else\n begin\n If j=3 Then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If j=2 Then\n begin\n If not((contr[i,3,1] and contr[3-i,4,2]) or (contr[i,4,1] and contr[3-i,3,2])) then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If (contr[3,i,2] and contr[4,3-i,1]) or (contr[4,i,2] and contr[3,3-i,1]) Then\n begin\n If (ans<>1) and (ans<>-1) Then ans:=2;\n end\n else\n begin\n If ans<>1 then ans:=-1;\n end;\n end;\n end\n else\n begin\n j:=0;\n If contr[2+i,1,1] then inc(j);\n If contr[2+i,2,1] then inc(j);\n If contr[5-i,1,2] then inc(j);\n If contr[5-i,2,2] then inc(j);\n Case j of\n 0: If ans<>1 then ans:=-1;\n 1: If ans<>1 then ans:=-1;\n 2: If (contr[2+i,1,1] and contr[5-i,2,2]) or (contr[2+i,2,1] and contr[5-i,1,2]) or (contr[2+i,1,2] and contr[5-i,2,1]) or (contr[2+i,2,2] and contr[5-i,1,1]) Then\n begin\n If ans=0 Then ans:=2;\n end\n else\n begin\n If ans<>1 then ans:=-1;\n end;\n 3: If ans=0 Then ans:=2;\n end;\n end;\n end;\n end;\n end;\n Case ans of\n -1:writeln('Draw');\n 2:writeln('Team 2');\n 1:writeln('Team 1');\n end;\n readln;\n readln;\nend."}, {"source_code": "var\n def:array[1..4] of longint;\n atk:array[1..4] of longint;\n i,j:longint;\n ans:integer;\n contr:array[1..4,1..4,1..2] of boolean;\n\nbegin\n For i:=1 to 4 do read(def[i],atk[i]);\n For i:=1 to 4 do\n For j:=1 to 4 do\n begin\n If def[i]>atk[j] Then contr[i,j,1]:=true;\n If atk[i]>atk[j] Then contr[i,j,2]:=true;\n end;\n For i:=1 to 2 do\n begin\n j:=0;\n If contr[i,3,1] then inc(j);\n If contr[i,4,1] then inc(j);\n If contr[3-i,3,2] then inc(j);\n If contr[3-i,4,2] then inc(j);\n If j=4 then\n begin\n ans:=1;\n end\n else\n begin\n If j=3 Then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If j=2 Then\n begin\n If (contr[i,3,1] and contr[i,4,1]) or (contr[3-i,3,1] and contr[3-i,4,1]) then\n begin\n If ans<>1 then ans:=-1;\n end\n else\n begin\n If (ans<>1) and (ans<>-1) Then ans:=2;\n end;\n end\n else\n begin\n If (ans<>1) and (ans<>-1) then ans:=2;\n end;\n end;\n end;\n end;\n Case ans of\n -1:writeln('Draw');\n 2:writeln('Team 2');\n 1:writeln('Team 1');\n end;\n readln;\n readln;\nend."}], "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f"} {"source_code": "var kt:boolean;st,xd:string;i:longint;ch:char;\nbegin\nread(St);\nch:='a';\nkt:=true;\nfor i:=1 to length(st) do\n begin\n if st[i]>ch then\n begin\n kt:=false;\n write('no');\n break;\n end;\n if kt then if st[i]=ch then inc(ch);\n end;\nif kt then write('yes');\nreadln\nend.", "positive_code": [{"source_code": "var\nst:ansistring;\nst2:string;\nn,i,r,p:longint;\nbegin\n readln(st);\n st2:='abcdefghijklmnopqrstuvwxyz';\n n:=length(st);\n r:=1;\n for i:=1 to n do\n begin\n p:=pos(st[i],st2);\n if p=r then r:=r+1;\n if p>r then begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "var i,j,m,n:longint;\n s:ansistring;\n first:array[0..31]of longint;\n flag:boolean;\nbegin\n readln(s);\n for i:=1 to length(s) do begin\n if first[ord(s[i])-ord('a')]=0 then begin\n first[ord(s[i])-ord('a')]:=i;\n end;\n end;\n flag:=true;\n for i:=0 to 25 do if (first[i]>first[i+1]) and (first[i+1]>0) then flag:=false;\n for i:=0 to 25 do if (first[i]=0) and (first[i+1]>0) then flag:=false;\n if flag then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var s:ansistring; i,a:longint;\nbegin\nread (s);\na:=97;\nfor i:=1 to length (s) do\n begin\n if s[i]=chr (a) then inc (a) else if s[i]>chr (a) then begin writeln ('NO'); exit; end;\n end;\nwriteln ('YES');\nend."}, {"source_code": "var n,m,i,j:longint;\n // p:array['a'..'z']of boolean;\n c:char;\n s:ansistring;\n flag:boolean;\nbegin\nreadln(s);\nif s[1]>'a' then begin writeln('NO');halt;end;\nc:='a';\nfor i:=1 to length(s) do begin\n if s[i]<=c then continue;\n if s[i]=(chr(ord(c)+1)) then begin c:=chr(ord(c)+1);continue;end;\n if c='z' then continue;\n writeln('NO');flag:=true;break;\nend;\nif not flag then writeln('YES');\nend.\n"}, {"source_code": "VAR a:array[0..26]of longint;\n s:ansistring;\n i:longint;\nBEGIN\n a[0]:=1;\n read(s);\n for i:=1 to length(s)do\n if a[ord(s[i])-96]=0 then if a[ord(s[i])-97]=0 then begin write('NO');halt;end\n else a[ord(s[i])-96]:=1;\n write('YES');\nEND."}, {"source_code": "var alf,st:ansistring;\ni,n,k,p:longint;\na:array[0..30] of longint;\nbegin\n alf:='abcdefghijklmnopqrstuvwxyz';\n readln(st);\n n:=length(st);\n\n a[0]:=1;\n for i:=1 to n do\n begin\n p:=pos(st[i],alf);\n if a[p]=0 then begin\n if a[p-1]>0 then inc(a[p])\n else begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "var a:array[1..26] of longint;\n i,j:longint;\n s:ansistring;data:boolean;\nbegin\nreadln(S);\nfor i:=1 to 26 do\nfor j:=1 to length(s) do\nif s[j]=chr(ord('a')+i-1) then begin\n a[i]:=j;\n break\n end;\nfor i:=1 to 25 do \nif (a[i]=0)and(a[i+1]<>0) then data:=true;\nfor i:=1 to 25 do\nif (a[i+1]<>0)AND(a[i+1]t then b:=true;\nend;\nif b=true then write('NO') else write('YES');\nreadln\nend."}, {"source_code": "{$H+}\nvar\n a, b, c, d, i, k: int64;\n s: string;\n used: array [1..200] of boolean;\n \nbegin\n readln(s);\n i := 1;\n k := 0;\n while i <= length(s) do begin \n if not(used[ord(s[i])]) then begin\n if ord(s[i]) - ord('a') > k then begin\n writeln('NO');\n halt();\n end;\n inc(k);\n used[ord(s[i])] := true;\n end;\n inc(i);\n end;\n writeln('YES');\nend."}, {"source_code": "program cf;\n var\n s: ansistring;\n c: char;\n i: word;\n BEGIN\n readln(s);\n if s[1]<>'a' then\n begin\n writeln('NO');\n halt(0);\n end;\n c:=s[1];\n for i:=2 to length(s) do\n if (s[i]>c) then\n begin\n if (ord(s[i]) - ord(c) <> 1) then\n begin\n writeln('NO');\n halt(0);\n end\n else c:=s[i];\n end;\n\n writeln('YES');\n END."}, {"source_code": "var kt:boolean;\nbcc,St:string;\ni,y:longint;\nA:array[1..100]of longint;\nbegin\nkt:=true;\nreadln(St);\nbcc:='abcdefghijklmnoprstuvwxyz';\nif St[1]<>'a' then writeln('No') else\nbegin\ni:=2;\ny:=2;\nwhile (kt)and(i<=length(St)) do\n begin\n if pos(St[i],bcc)=y then inc(y)\n else if pos(St[i],bcc)>y then kt:=false;\n inc(i);\n end;\nif kt then writeln('YES')\n else writeln('NO');\n end;\n readln;\nend.\n"}, {"source_code": "var i,w:longint;\na:array['a'..'z'] of longint;\nj:char;\ns:ansistring;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(s);\n for i:=1 to length(s) do\n begin\n a[s[i]]:=1;\n for j:='a' to s[i] do if a[j]=0 then w:=1;\n end;\n if w=1 then write('NO') else write('YES');\nend.\n\n"}, {"source_code": "var s: ansistring;\ni,n,k,num: longint;\nb: array ['a'..'z'] of boolean;\nc,j: char;\nprocedure stop;\nbegin\nwrite('NO');\nhalt;\nend;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nn:=length(s);\nfillchar(b,sizeof(b),false);\nfor i:= 1 to n do\n begin\n c:=s[i];\n b[c]:=true;\n for j:='a' to c do\n if b[j]=false then stop;\n end;\nwrite('YES');\nend.\n"}, {"source_code": "var alf:string;\nst:ansistring;\ni,l,k,p:longint;\na:array[0..30] of longint;\nbegin\n alf:='abcdefghijklmnopqrstuvwxyz';\n readln(st);\n l:=length(st);\n a[0]:=1;\n for i:=1 to l do\n begin\n p:=pos(st[i],alf);\n if a[p]=0 then begin\n if a[p-1]>0 then inc(a[p])\n else begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "var s:string;\n i,k:longint;\nbegin\n readln(s);\n k:=96;\n \n for i:=1 to length(s) do\n if ord(s[i]) - k > 1 then begin writeln('NO'); exit; end\n else if ord(s[i]) > k then k:=ord(s[i]);\n \n writeln('YES');\n\nend. \n "}, {"source_code": "var c,k:char;\n s,t:ansistring;\n i,j:longint;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(s);\nk:='a';\nt:='YES';\nfor c in s do\n begin\n if c=k then\n begin\n inc(k);\n end else if c>k then t:='NO'\n end;\nwrite(t)\nend.\n"}, {"source_code": "var\n\ts : ansistring;\n c : char;\n i : longint;\n\nbegin\n\n readln(s);\n c := 'a';\n for i := 1 to length(s) do\n begin\n\t\tif s[i] < c then\n \tcontinue;\n if s[i] = c then\n \tinc(c)\n else begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\n\nend."}, {"source_code": "var s:ansistring;i,sc:integer;\nbegin\nreadln(s);\nsc:=97;\nFor i:=1 to length(s) do\nIf ord(s[i])>sc\n then begin writeln('NO');halt;end\n else if sc=ord(s[i])\n then sc:=sc+1;\nwriteln('YES');\nend."}, {"source_code": "var s:ansistring;i,sc:integer;\nbegin\nreadln(s);\nsc:=97;\nFor i:=1 to length(s) do\nIf ord(s[i])>sc\n then begin writeln('NO');halt;end\n else if sc=ord(s[i])\n then sc:=sc+1;\nwriteln('YES');\nend."}, {"source_code": "program qq;\nvar a:array[1..500]of integer;\ns:string;\ndl,i,k,res:integer;\n\nbegin\nread(s);\ndl:=length(s);\nfor i:=1 to dl do begin\nIf s[i]='a' then a[i]:=1;\nIf s[i]='b' then a[i]:=2;\nIf s[i]='c' then a[i]:=3;\nIf s[i]='d' then a[i]:=4;\nIf s[i]='e' then a[i]:=5;\nIf s[i]='f' then a[i]:=6;\nIf s[i]='g' then a[i]:=7;\nIf s[i]='h' then a[i]:=8;\nIf s[i]='i' then a[i]:=9;\nIf s[i]='j' then a[i]:=10;\nIf s[i]='k' then a[i]:=11;\nIf s[i]='l' then a[i]:=12;\nIf s[i]='m' then a[i]:=13;\nIf s[i]='n' then a[i]:=14;\nIf s[i]='o' then a[i]:=15;\nIf s[i]='p' then a[i]:=16;\nIf s[i]='q' then a[i]:=17;\nIf s[i]='r' then a[i]:=18;\nIf s[i]='s' then a[i]:=19;\nIf s[i]='t' then a[i]:=20;\nIf s[i]='u' then a[i]:=21;\nIf s[i]='v' then a[i]:=22;\nIf s[i]='w' then a[i]:=23;\nIf s[i]='x' then a[i]:=24;\nIf s[i]='y' then a[i]:=25;\nIf s[i]='z' then a[i]:=26;\nend;\nk:=1;\nres:=0;\nif a[1]<>1 then res:=res+1;\nfor i:=1 to dl do begin\nif a[i]<=k then res:=res+0 else \nif a[i]-k=1 then k:=k+1 else res:=res+1;\nend;\nif res=0 then writeln('YES') else writeln('NO') ;\nend."}, {"source_code": "var kt:array[0..100000] of longint;\n i,n:longint;\n s:ansistring;\nbegin\nreadln(s);\nn:=length(s);\nkt[96]:=1;\nFor i:=1 to n do\n begin\n if kt[ord(s[i])-1]=0 then\n begin\n writeln('NO');\n halt;\n end else kt[ord(s[i])]:=1; \n end;\nwriteln('YES');\nend.\n\n"}, {"source_code": " \n var S : AnsiString;\n last : char;\n i : LongInt;\nbegin\n readLn ( S ) ; \n \n \n last := 'a';\n \n for i := 1 to Length(S) Do\n begin\n \n if ( S[i] = last ) then\n inc ( last )\n else if ( S[i] > last ) then\n begin\n writeLn ( 'NO' ) ; \n halt();\n end;\n \n \n end;\n \n writeLn ( 'YES' );\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n s: string;\n i, j: integer;\n b: array[1..26] of boolean;\nbegin\n readln(s);\n for i := 1 to length(s) do begin\n b[ord(s[i]) - 96] := true;\n for j := ord(s[i]) - 96 downto 1 do\n if(b[j] <> true) then begin\n writeln('NO');\n exit;\n end;\n end;\n writeln('YES');\n end.\n"}, {"source_code": " const eps=0.000000001;\n besk=9000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var aa,bb,left,right,modul,ot3,ot2,ot1,nap,posx,posy,xx,yy,n,m,tt1,tt2,q,pp,tt,dx,dy,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,pmax,imax,p1,p2,p3,p4,l,ot,nm,s1,s2,s,smin,cen,dl,t2,i1:int64;\n t1,k,time,jj,step, ii,i,j:longint;\n { aa,bb,cc:double;\n }\n ss2,sss,ss,ss1:string;\n last:array[-1..5000,0..25] of int64;\n dd,npx,npy:array[-1000..500000] of int64;\n zifr:array[0..1000000,0..9] of longint;\n sdv, dp,binom:array[-1..500,-1..500] of int64;\n prost,zan:array[-10000..10000000] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,z,x,y,aold,b,a:array[-100000..1000002] of int64;\n dda:array[-10..12000] of extended;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n corr,zzan:array[-1000..3000,-1000..3000] of boolean;\n ssss:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n ch:char;\n pole1,pole :array [-10..2000,-10..2000] of char;\n st:array[-10..100000] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n yot:double;\n flag2,oldflag,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(ss);\n n:=length(ss);\n for i:=n downto 1 do\n begin\n t:=ord(ss[i])-ord('a');\n a[t]:=i;\n\n\n end;\n\n { for i:=0 to 25 do write(a[i],' ');\n writeln;\n }\n t:=0;\n for i:=0 to 25 do if a[i]>0 then t:=i;\n flag:=true;\n for i:=0 to t-1 do if a[i+1]c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qn then b:=false;\n if k=n then inc(n);\n end;\n if b then writeln('YES') else writeln('NO');\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var a,s,d,f,g,h,j,k,l,i,ii:longint;\nz:ansistring;\nv:char;\nx:array['a'..'z']of longint;\nc:array['a'..'z']of longint;\nbegin\nreadln(z);\nfor i:=1 to length(z)do\ninc(x[z[i]]);\n\ni:=26;\nwhile x[chr(i+96)]=0 do\ndec(i);\n\nwhile (i<>0)and(x[chr(i+96)]<>0) do\ndec(i);\nif i=0 then\nbegin\nfor ii:=1 to length(z) do\nif c[z[ii]]=0 then\nc[z[ii]]:=ii;\nfor v:='a' to 'y' do\nif (c[v]>c[chr(ord(v)+1)])and(x[chr(ord(v)+1)]<>0)then\nbegin\nwriteln('NO');\nhalt;\nend;\nwriteln('YES');\nend\nelse writeln('NO');\nend.\n"}, {"source_code": "program cf765B;\nvar s:ansistring;\n i,cur:longint;\nbegin\n readln(s);\n cur:=ord('a')-1;\n for i:=1 to length(s) do\n begin\n if ord(s[i])>cur+1 then begin writeln('NO'); halt;end;\n if ord(s[i])>cur then cur:=ord(s[i]);\n end;\n writeln('YES');\nend."}, {"source_code": "Program round397codefN2(virtual_);\nVar s: string;\n c, cur: integer;\n\nBegin\n read(s);\n cur:= ord('a');\n If s[1] = 'a' then\n For c:= 1 to length(s) do begin\n if ord(s[c]) <= cur then //nothing\n else\n if s[c] = chr(cur + 1) then cur:= ord(s[c])\n else begin\n Writeln('NO');\n halt;\n end;\n End\n Else begin writeln('NO'); halt; end;\n Writeln('YES');\nEnd."}, {"source_code": "program zzz;\nvar\n s,s1:string;\n b:boolean;\n i:longint;\nbegin\n readln(s);\n s1:='a';\n b:=true;\n i:=2;\n if s[1]<>'a' then b:=false;\n while (i<=length(s)) and(b=true) do\n begin\n if pos(s[i],s1)=0 then\n if s[i]=chr(ord(s1[length(s1)])+1) then\n s1:=s1+s[i]\n else b:=false;\n inc(i);\n end;\n if b=true then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var s:ansistring;\n i:longint;\n tek:char;\nbegin\n read(s);\n tek:='a';\n if s[1]<>'a'\n then begin\n write('NO');\n halt;\n end;\n for i:=1 to length(s) do\n begin\n if ord(s[i])>ord(tek)+1\n then begin\n write('NO');\n halt;\n end;\n if ord(s[i])=ord(tek)+1\n then tek:=s[i]\n else continue;\n end;\n \n write('YES');\n\n\nend."}, {"source_code": "var a:longint;s:string;q:char;\nbegin\n read(s);\n for q:='a' to 'z' do\n begin\n if pos(q,s)<>1 then begin write('NO');halt;end;\n a:=pos(q,s);\n while a>0 do\n begin\n delete(s,a,1);a:=pos(q,s);\n end;if s=''then begin write('YES');halt;end;\n end;\n write('YES');\nend."}, {"source_code": "var s,xm:ansistring;\nkt:boolean;\ni:longint;\nbegin\nreadln(s);\nkt:=true;\nxm:='';\nif s[1]='a' then xm:='a';\nif (s[1]<>'a') then kt:=false;\nfor i:=2 to length(s) do\n if length(xm)>0 then\n begin\n if (pos(s[i],xm)=0) and (ord(s[i])=ord(xm[length(xm)])+1) then xm:=xm+s[i];\n if pos(s[i],xm)=0 then kt:=false;\n end;\n\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var\n f : array['a'..'z'] of longint;\n c : char;\n i,j : longint;\n s : ansistring;\n\nbegin\n readln(s); c:='a';\n for i:=1 to length(s) do if f[s[i]] = 0 then begin\n if s[i] <> c then begin writeln('NO'); halt; end;\n f[s[i]]:=1;\n c:=chr(ord(c)+1);\n end;\n writeln('YES');\nend."}, {"source_code": "Program p1;\nvar s:ansistring;\n i:integer;\n u:boolean;\n c:char;\n m:set of char;\nBegin\n readln(s);\n m:=[];\n i:=2;\n u:=true;\n c:='a';\n if s[1]='a' then begin\n include(m,'a');\n for i:=2 to length(s) do if (not(s[i] in m)) and (chr(ord(c)+1)=s[i]) then begin\n include(m,s[i]);\n c:=s[i];\n end\n else if not(s[i] in m) then u:=false;\n if u then writeln('Yes')\n else writeln('No');\n\n end\n else writeln('No');\nend.\n\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,last:longint; Z:array['a'..'z'] of longint; s:ansistring; ch:char;\nQ:array[1..100] of longint;\n\nFunction max(x,y:longint):longint;\nbegin\nif x>y then exit(x) else exit(y);\nend;\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do if Z[s[i]]=0 then begin Z[s[i]]:=i; last:=max(last,ord(s[i])-ord('a')+1); end;\nfor ch:='a' to 'z' do begin inc(n); Q[n]:=Z[ch]; end;\nfor i:=1 to last-1 do\n begin\n if (Q[i]>=Q[i+1]) or (Q[i]=0) then begin write('NO'); exit; end;\n end;\nwrite('YES');\nend."}, {"source_code": "var s:ansistring;\nc:char;\ni:longint;\n\nbegin\n//assign(input,'dmhx.in');reset(input);\n//assign(output,'dmhx.out');rewrite(output);\nreadln(s);\nc:='a';\nfor i:=1 to length(s) do\n if s[i]>c then\n begin\n write('NO');\n close(input);close(output);\n halt;\n end\n else\n if s[i]=c then c:=succ(c);\nwrite('YES');\nclose(input);close(output);\n\n\n\nend."}, {"source_code": "var t,i:longint;\n s:ansistring;\nbegin\n//assign(input,'dmhx.in');reset(input);\n//assign(output,'dmhx.out');rewrite(output);\nreadln(s);\nt:=0;\nfor i:=1 to length(s) do\n if (ord(s[i])-96-t>1) then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end\n else if ord(s[i])-96>t then t:=t+1;\nwriteln('YES');\nclose(input);close(output);\nend."}, {"source_code": "var u,i:integer;\ns:ansistring;\nprocedure del;\n var i:integer;\n begin\n i:=1;\n while i<=length(s) do\n if ord(s[i])=u then\n begin\n delete(s,i,1);\n end else inc(i);\n end;\nbegin\nreadln(s);\nu:=97;\nwhile length(s)<>0 do\n if ord(s[1])=u then\n begin\n del;\n inc(u);\n end else\n begin\n write('NO');\n halt;\n end;\nwrite('YES');\nend.\n"}, {"source_code": "var\n n,i,x : longint;\n s : ansistring;\n c: char;\n\nbegin\n x:=97;\n readln(s);\n c:=chr(x);\n \n i:=1;\n \n while i <= length(s) do begin\n while (i <= length(s)) and (s[i] < c) do inc(i);\n if i > length(s) then begin\n writeln('YES');\n halt;\n end;\n \n if s[i] = c then begin\n inc(x);\n c:=chr(x);\n end else begin\n writeln('NO');\n halt;\n end;\n end;\n \nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+96);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if ord(t[1])>97 then begin writeln('NO');halt;end;\n for i:=1 to length(t)-1 do\n if cnt[i]+1<>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend. "}, {"source_code": "program ix;\n\nvar\n s: string;\n i, o: integer;\n c: boolean;\n\nbegin\n readln(s);\n i := 0;\n o := 97;\n c:=true;\n repeat\n i := i + 1;\n if ord(s[i]) > o then begin c := false;break end;\n if ord(s[i]) = o then o := o + 1;\n until i = length(s); \n if (c) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,nom,b:array[0..26]of longint;\ns,alf,s1:ansistring;\nn,i,p,l,r,kl,q:longint;\nbegin\n readln(s);\n n:=length(s);\n alf:='abcdefghijklmnopqrstuvwxyz';\n for i:=1 to n do\n begin\n p:=pos(s[i],alf);\n if a[p]=0 then a[p]:=i;\n end;\n for i:=1 to 26 do\n if (a[i]=0)and(kl=0) then kl:=1\n else if (kl=1)and(a[i]<>0)then begin\n writeln('NO');\n halt;\n end;\n kl:=0;\n for i:=1 to 26 do\n if a[i]<>0 then begin\n q:=q+1;\n b[q]:=a[i];\n end;\n for i:=1 to q do\n if b[i]0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if a[i]<>0 then begin\n r:=i;\n if a[r]'' then s:=s+t;\n t:='YES';\n j:=97;\n if s[1]<>'a' then\n begin\n t:='NO';\n end else\n for i := 2 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n break;\n end;\n if ord(s[i])>j then j:=ord(s[i]);\n end;\n write(t);\nend."}, {"source_code": "var a:array[0..200]of longint;\nst,alf:ansistring;\nn,i,p:longint;\nbegin\n readln(st);\n n:=length(st);\n alf:='abcdefghijklmnopqrstuvwxyz';\n a[0]:=1;\n for i:=1 to n do\n begin\n p:=pos(st[i],alf);\n if a[p-1]=0 then begin\n writeln('NO');\n halt;\n end;\n a[p]:=1;\n end;\n writeln('YES');\nend."}, {"source_code": "var vis:array[0..30] of boolean;\n last:array[0..30] of longint;\n ch:char;\n\ti,j:longint;\n\tans:boolean;\nbegin\n fillchar(vis,sizeof(vis),false);\n fillchar(last,sizeof(last),0);\n i:=0;\n while not(eoln) do\n begin\n inc(i);\n read(ch);\n if (last[ord(ch)-96]=0) then last[ord(ch)-96]:=i;\n vis[ord(ch)-96]:=true;\n end;\n readln;\n i:=1;\n while (i<=26) and vis[i] do inc(i);\n ans:=true;\n for j:=i to 26 do\n\tif vis[j] then ans:=false;\n for j:=1 to i-2 do\n\tif (last[j]>last[j+1]) then ans:=false;\n if ans then writeln('YES') else writeln('NO');\nend.\n "}, {"source_code": "var s:ansistring;\n\tib:char;\n\ta:array['a'..'z'] of longint;\n\ti,l,f,k:longint;\nbegin \n//assign(input,'input.txt');\n//reset(input);\n\treadln(s);\n\tk:=0;\n\tf:=0;\n\tfor ib:='a' to 'z' do\n\t\tbegin\n\t\t\tinc(k);\n\t\t\ta[ib]:=k;\n\t\tend;\n\tl:=1;\n\tfor i:=1 to length(s) do\n\t\tbegin\n\t\t\tif a[s[i]] > l then\tbegin\n\t\t\t\t\t\t\t\t\tf:=1;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t \tend;\n\t\t\tif a[s[i]] = l then\tinc(l);\n\t\tend;\n if f=1 then writeln('NO')\n \t\t\telse writeln('YES');\nend.\n\t\t\t\t\t\t \t\t"}, {"source_code": "var s:ansistring;\ni,c:longint;\nbegin\nreadln(s);\nc:=ord('a');\nfor i:=1 to length(s) do begin\n if ord(s[i])>c then begin\n write('NO');\n exit;\n end else if ord(s[i])=c then\n inc(c);\nend;\nwrite('YES');\nend.\n"}, {"source_code": "program cf;\nvar i,j: longint;\n s: ansistring;\n f:boolean;\n a: array[1..26] of longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\nbegin\nf:=false;\ninc(a[ord(s[i])-ord('a')+1]);\nfor j:=1 to 26 do\nbegin\nif a[j]=0 then\nf:=true;\nif (f) and (a[j]<>0) then\nbegin\nwrite('NO');\nexit;\nend;\nend;\nend;\nwrite('YES');\nend."}], "negative_code": [{"source_code": "var vis:array[0..30] of boolean;\n ch:char;\n\ti,j:longint;\n\tans:boolean;\nbegin\n fillchar(vis,sizeof(vis),false);\n while not(eoln) do\n begin\n read(ch);\n vis[ord(ch)-96]:=true;\n end;\n readln;\n i:=1;\n while (i<=26) and vis[i] do inc(i);\n ans:=true;\n for j:=i to 26 do\n\tif vis[j] then ans:=false;\n if ans then writeln('YES') else writeln('NO');\nend.\n "}, {"source_code": "var n,m,i,j:longint;\n p:array['a'..'z']of boolean;\n c:char;\n s:ansistring;\n flag:boolean;\nbegin\nreadln(s);\nc:='a';\nfor i:=1 to length(s) do begin\n if s[i]<=c then continue;\n if s[i]=(chr(ord(c)+1)) then begin c:=chr(ord(c)+1);continue;end;\n writeln('NO');flag:=true;break;\nend;\nif not flag then writeln('YES');\nend.\n"}, {"source_code": "var st:ansistring;\na,b:array['a'..'z'] of longint;\nsim,s1:char;\ni,j,n,k:longint;\n\nbegin\n readln(st);\n n:=length(st);\n\n for i:=1 to n do\n inc(a[st[i]]);\n\n for sim:='a' to 'z' do\n begin\n i:=i+1;\n b[sim]:=i;\n end;\n\n for sim:='a' to 'z' do\n if a[sim]=0 then begin\n s1:=sim;\n break;\n end;\n\n for sim:=s1 to 'z' do\n if a[sim]>0 then begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\nend."}, {"source_code": "var kt:boolean;\nbcc,St:string;\ni,y:longint;\nA:array[1..100]of longint;\nbegin\nkt:=true;\nreadln(St);\nbcc:='abcdefghijklmnoprstuvwxyz';\nfor i:=1 to length(St) do\n inc(A[pos(St[i],bcc)]);\n\nfor i:= 1 to 100 do\n if A[i]=0 then for y:=i to 100 do\n if A[y]<>0 then kt:=false;\nif kt then writeln('YES')\n else writeln('NO');\nreadln;\nend.\n"}, {"source_code": "var kt:boolean;\nbcc,St:string;\ni,y:longint;\nA:array[1..100]of longint;\nbegin\nkt:=true;\nreadln(St);\nif St[1]<>'a' then writeln('NO')\n else begin\nbcc:='abcdefghijklmnoprstuvwxyz';\nfor i:=1 to length(St) do\n inc(A[pos(St[i],bcc)]);\n\nfor i:= 1 to 100 do\n if A[i]=0 then for y:=i to 100 do\n if A[y]<>0 then kt:=false;\nif kt then writeln('YES')\n else writeln('NO');\n end;\n readln;\nend.\n"}, {"source_code": "var alf:string;\nst:ansistring;\ni,l,k,p:longint;\na:array[1..30] of longint;\nbegin\n alf:='abcdefghijklmnopqrstuvwxyz';\n readln(st);\n l:=length(st);\n for i:=1 to l do\n begin\n p:=pos(st[i],alf);\n inc(a[p]);\n end;\n for i:=1 to 26 do\n if a[i]=0 then break\n else inc(k,a[i]);\n if ksc\n then begin writeln('NO');halt;end\n else sc:=sc+1;\nwriteln('YES');\nend."}, {"source_code": "program qq;\nvar a:array[1..500]of integer;\ns:string;\ndl,i,k,res:integer;\n\nbegin\nread(s);\ndl:=length(s);\nfor i:=1 to dl do begin\nIf s[i]='a' then a[i]:=1;\nIf s[i]='b' then a[i]:=2;\nIf s[i]='c' then a[i]:=3;\nIf s[i]='d' then a[i]:=4;\nIf s[i]='e' then a[i]:=5;\nIf s[i]='f' then a[i]:=6;\nIf s[i]='g' then a[i]:=7;\nIf s[i]='h' then a[i]:=8;\nIf s[i]='i' then a[i]:=9;\nIf s[i]='j' then a[i]:=10;\nIf s[i]='k' then a[i]:=11;\nIf s[i]='l' then a[i]:=12;\nIf s[i]='m' then a[i]:=13;\nIf s[i]='n' then a[i]:=14;\nIf s[i]='o' then a[i]:=15;\nIf s[i]='p' then a[i]:=16;\nIf s[i]='q' then a[i]:=17;\nIf s[i]='r' then a[i]:=18;\nIf s[i]='s' then a[i]:=19;\nIf s[i]='t' then a[i]:=20;\nIf s[i]='u' then a[i]:=21;\nIf s[i]='v' then a[i]:=22;\nIf s[i]='w' then a[i]:=23;\nIf s[i]='x' then a[i]:=24;\nIf s[i]='y' then a[i]:=25;\nIf s[i]='z' then a[i]:=26;\nend;\nk:=1;\nres:=0;\nfor i:=1 to dl do begin\nif a[i]<=k then res:=res+0 else \nif a[i]-k=1 then k:=k+1 else res:=res+1;\nend;\nif res=0 then writeln('YES') else writeln('NO') ;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n s: string;\n i, j: integer;\nbegin\n readln(s);\n i := 1;\n while(i <= length(s)) do begin\n j := i + 1;\n while(j <= length(s)) do begin\n if(s[i] = s[j]) then\n delete(s, j, 1);\n inc(j);\n end;\n inc(i);\n end;\n for i := 1 to length(s) - 1 do\n if(ord(s[i]) <> ord(s[i + 1]) - 1) then begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n end.\n"}, {"source_code": " const eps=0.000000001;\n besk=9000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var aa,bb,left,right,modul,ot3,ot2,ot1,nap,posx,posy,xx,yy,n,m,tt1,tt2,q,pp,tt,dx,dy,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,pmax,imax,p1,p2,p3,p4,l,ot,nm,s1,s2,s,smin,cen,dl,t2,i1:int64;\n t1,k,time,jj,step, ii,i,j:longint;\n { aa,bb,cc:double;\n }\n ss2,sss,ss,ss1:string;\n last:array[-1..5000,0..25] of int64;\n dd,npx,npy:array[-1000..500000] of int64;\n zifr:array[0..1000000,0..9] of longint;\n sdv, dp,binom:array[-1..500,-1..500] of int64;\n prost,zan:array[-10000..10000000] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,z,x,y,aold,b,a:array[-100000..1000002] of int64;\n dda:array[-10..12000] of extended;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n corr,zzan:array[-1000..3000,-1000..3000] of boolean;\n ssss:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n ch:char;\n pole1,pole :array [-10..2000,-10..2000] of char;\n st:array[-10..100000] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n yot:double;\n flag2,oldflag,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(ss);\n n:=length(ss);\n for i:=n downto 1 do\n begin\n t:=ord(ss[i])-ord('a');\n a[t]:=i;\n\n\n end;\n\n { for i:=0 to 25 do write(a[i],' ');\n }\n t:=0;\n for i:=0 to 25 do if a[i]>0 then t:=i;\n flag:=true;\n for i:=1 to t-1 do if a[i+1]c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q0)and(x[chr(i+96)]<>0) do\ndec(i);\nif i=0 then\nwriteln('YES')\nelse writeln('NO');\nend.\n"}, {"source_code": "Program round397codefN2(virtual_);\nVar s: string;\n c, cur: integer;\n\nBegin\n read(s);\n cur:= ord('a');\n if s[1] = 'a' then\n For c:= 1 to length(s) do begin\n if ord(s[c]) <= cur then //nothing\n else\n if s[c] = chr(cur + 1) then cur:= ord(s[c])\n else begin\n Writeln('NO');\n halt;\n end;\n End;\n\n Writeln('YES');\nEnd."}, {"source_code": "Program round397codefN2(virtual_);\nVar s: string;\n c, cur: integer;\n\nBegin\n read(s);\n cur:= ord('a');\n If s[1] = 'a' then\n For c:= 1 to length(s) do begin\n if ord(s[c]) <= cur then //nothing\n else\n if s[c] = chr(cur + 1) then cur:= ord(s[c])\n else begin\n Writeln('NO');\n halt;\n end;\n End\n Else writeln('NO');\n Writeln('YES');\nEnd."}, {"source_code": "Program round397codefN2(virtual_);\nVar s: string;\n c, cur: integer;\n\nBegin\n read(s);\n cur:= ord('a');\n For c:= 1 to length(s) do begin\n if s[c] <= chr(cur) then //nothing\n else\n if s[c] = chr(cur + 1) then cur:= ord(s[c])\n else begin\n Writeln('NO');\n halt;\n end;\n End;\n\n Writeln('YES');\nEnd."}, {"source_code": "Program round397codefN2(virtual_);\nVar s: string;\n c, cur: integer;\n\nBegin\n read(s);\n cur:= ord('a');\n For c:= 1 to length(s) do begin\n if ord(s[c]) <= cur then //nothing\n else\n if s[c] = chr(cur + 1) then cur:= ord(s[c])\n else begin\n Writeln('NO');\n halt;\n end;\n End;\n\n Writeln('YES');\nEnd."}, {"source_code": "program zzz;\nvar\n s,s1:string;\n z:char;\n i,k,k1:longint;\nbegin\n read(s);\n s1:='';\n for i:=1 to length(s) do\n if pos(s[i],s1)=0 then\n begin\n inc(k);\n s1:=s1+s[i];\n end;\n k1:=0;\n for z:= 'a' to (chr(ord('a')+k-1)) do\n if pos(z,s)<>0 then inc(k1);\n if (k1=k)and(s[1]='a') then writeln('YES')\n else writeln('NO');\n\n\nend."}, {"source_code": "program zzz;\nvar\n s,s1:string;\n z:char;\n i,k,k1:longint;\nbegin\n read(s);\n s1:='';\n for i:=1 to length(s) do\n if pos(s[i],s1)=0 then\n begin\n inc(k);\n s1:=s1+s[i];\n end;\n k1:=0;\n for z:= 'a' to (chr(ord('a')+k-1)) do\n if pos(z,s)<>0 then inc(k1);\n if k1=k then writeln('YES')\n else writeln('NO');\n\n\nend."}, {"source_code": "var x,s,xs:ansistring;c:char;\nkt:boolean;\ni,d,k:longint;\nbegin\nreadln(s);\nkt:=true;\nx:=''; xs:='';\nfor c:='a' to 'z' do x:=x+c;\nfor i:=1 to (length(s) div 2) do \n begin\n if s[i]<>s[length(s)-i+1] then kt:=false;\n d:=0;\n for k:=1 to i-1 do if (pos(s[k],x)>=pos(s[i],x)) then d:=d+1;\n if d=0 then kt:=false;\n end;\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var s:ansistring;\nkt:boolean;\ni:longint;\nbegin\nreadln(s);\nif (s[1]<>'a') or (s[length(s)]<>'a') then kt:=false;\nkt:=true;\nfor i:=1 to length(s) do\n if s[i]<>s[length(s)-i+1] then kt:=false;\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var s:ansistring;\nkt:boolean;\ni:longint;\nbegin\nreadln(s);\nkt:=true;\nif (s[1]<>'a') or (s[length(s)]<>'a') then kt:=false;\n\nfor i:=1 to length(s) do\n if s[i]<>s[length(s)-i+1] then kt:=false;\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var s:ansistring;\nkt:boolean;\ni:longint;\nbegin\nreadln(s);\nkt:=true;\nfor i:=1 to length(s) do\n if s[i]<>s[length(s)-i+1] then kt:=false;\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var s:ansistring;\nkt:boolean;\ni:longint;\nbegin\nreadln(s);\nkt:=true;\nif (s[1]<>'a') then kt:=false;\n\n{for i:=1 to length(s) do\n if s[i]<>s[length(s)-i+1] then kt:=false;}\nfor i:=2 to length(s) do\n if (ord(s[i])s[length(s)-i+1] then kt:=false;\n if i>1 then\n begin\n d:=0;\n for k:=1 to i-1 do if (pos(s[k],x)>=pos(s[i],x)) then d:=d+1;\n if d=0 then kt:=false;\n end;\n end;\nif kt then write('yes') else write('no');\nend."}, {"source_code": "var\n s : ansistring;\n f : array['a'..'z'] of longint;\n i,j,n,m,k : longint;\n c : char;\n\nbegin\n readln(s);\n for i:=1 to length(s) do inc(f[s[i]]);\n for c:='a' to 'z' do if f[c] = 0 then break;\n for c:=chr(ord(c)+1) to 'z' do if f[c] > 0 then begin writeln('NO'); halt; end;\n writeln('YES');\nend."}, {"source_code": "Program p1;\nvar s:ansistring;\n i:integer;\n m:set of char;\nBegin\n readln(s);\n m:=[];\n i:=2;\n if s[1]='a' then begin\n while (not(s[i] in m)) and (ilength(s)+1 then writeln('Yes')\n else writeln('No');\n end\n else writeln('No');\nend.\n\n"}, {"source_code": "var s:string;\nc:char;\ni:longint;\n\n\nbegin\n//assign(input,'dmhx.in');reset(input);\n//assign(output,'dmhx.out');rewrite(output);\nreadln(s);\nc:='a';\nfor i:=1 to length(s) do\n begin\n if c1) then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end\n else if ord(s[i])-96>t then t:=t+1;\nwriteln('YES');\nclose(input);close(output);\nend."}, {"source_code": "var s:ansistring;\nc:char;\ni:longint;\n\n\nbegin\n//assign(input,'dmhx.in');reset(input);\n//assign(output,'dmhx.out');rewrite(output);\nreadln(s);\nc:='a';\nfor i:=1 to length(s) do\n begin\n if csucc(x)) then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end\n else\n if s[i]=succ(x) then x:=succ(x);\nwriteln('YES');\nclose(input);close(Output);\nend.\n"}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:ansistring;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n for i:=1 to length(t)-1 do\n if cnt[i]+1<>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if t[1]<>'a' then begin writeln('NO');halt;end else\n if (t[2]<>'b') and (length(t)>1) then begin writeln('NO');halt;end else\n if (length(t)>2) and (t[3]<>'c') then begin writeln('NO');halt;end else\n if (length(t)>3) and (t[4]<>'d') then begin writeln('NO');halt;end else\n if (length(t)>4) and (t[5]<>'e') then begin writeln('NO');halt;end else\n if (length(t)>5) and (t[6]<>'f') then begin writeln('NO');halt;end else\n if (length(t)>6) and (t[7]<>'g') then begin writeln('NO');halt;end else\n if (length(t)>7) and (t[8]<>'h') then begin writeln('NO');halt;end else\n if (length(t)>8) and (t[9]<>'e') then begin writeln('NO');halt;end else\n if (length(t)>9) and (t[10]<>'e') then begin writeln('NO');halt;end else\n if (length(t)>10) and (t[11]<>'e') then begin writeln('NO');halt;end else\n if (length(t)>11) and (t[12]<>'e') then begin writeln('NO');halt;end else\n for i:=1 to length(t)-1 do\n if cnt[i]>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:ansistring;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n for i:=1 to length(t)-1 do\n if cnt[i]>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if ord(t[1])>96 then begin writeln('NO');halt;end;\n for i:=1 to length(t)-1 do\n if cnt[i]+1<>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if t[1]<>'a' then begin writeln('NO');halt;end else\n if t[2]<>'a' then begin writeln('NO');halt;end else\n if (length(t)>2) and (t[3]<>'c') then begin writeln('NO');halt;end;\n for i:=1 to length(t)-1 do\n if cnt[i]>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if t[1]<>'a' then begin writeln('NO');halt;end else\n if t[2]<>'b' then begin writeln('NO');halt;end else\n if (length(t)>2) and (t[3]<>'c') then begin writeln('NO');halt;end;\n for i:=1 to length(t)-1 do\n if cnt[i]>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s,t:string;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n readln(s);\n \n \n for i:=1 to 26 do\n x[i]:=chr(i+95);\n \n t:=''; \n for j:=1 to length(s) do\n for i:=1 to 26 do\n begin\n if (x[i]=s[j]) and not was[i] then begin t:=t+s[j];was[i]:=true;break;end;\n end;\n \n for i:=1 to length(t) do\n cnt[i]:=ord(t[i]);\n \n if t[1]<>'a' then begin writeln('NO');halt;end else\n if (t[2]<>'b') and (length(t)>1) then begin writeln('NO');halt;end else\n if (length(t)>2) and (t[3]<>'c') then begin writeln('NO');halt;end else\n if (length(t)>3) and (t[4]<>'d') then begin writeln('NO');halt;end else\n if (length(t)>4) and (t[4]<>'e') then begin writeln('NO');halt;end;\n for i:=1 to length(t)-1 do\n if cnt[i]>cnt[i+1] then begin writeln('NO');halt;end;\n writeln('YES');\nend."}, {"source_code": "var a:array[1..26]of longint;\ns,alf:ansistring;\nn,i,p,l,r,kl:longint;\nbegin\n readln(s);\n n:=length(s);\n alf:='abcdefghijklmnopqrstuvwxyz';\n for i:=1 to n do\n begin\n p:=pos(s[i],alf);\n if a[p]=0 then a[p]:=i;\n end;\n for i:=1 to 26 do\n if a[i]<>0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if (a[i]<>0)and(l<>0)then begin\n r:=i;\n if a[r]0)and(l=0) then l:=i;\n if kl=0 then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var a,nom,b:array[1..26]of longint;\ns,alf,s1:ansistring;\nn,i,p,l,r,kl,q:longint;\nbegin\n readln(s);\n n:=length(s);\n alf:='abcdefghijklmnopqrstuvwxyz';\n for i:=1 to n do\n begin\n p:=pos(s[i],alf);\n if a[p]=0 then a[p]:=i;\n end;\n for i:=1 to 26 do\n if a[i]<>0 then begin\n q:=q+1;\n b[q]:=a[i];\n end;\n for i:=1 to q-1 do\n if b[i]>b[i+1] then begin\n kl:=1;\n break;\n end;\n {for i:=1 to 26 do\n if a[i]<>0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if a[i]<>0 then begin\n r:=i;\n if a[r]0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if a[i]<>0 then begin\n r:=i;\n if a[r]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=nom[i];\n nom[i]:=nom[j];\n nom[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then s1:=s1+alf[nom[i]];\n n:=length(s1);\n for i:=1 to n-1 do\n if s1[i]>s1[i+1] then begin\n kl:=1;\n break;\n end;\n {for i:=1 to 26 do\n if a[i]<>0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if a[i]<>0 then begin\n r:=i;\n if a[r]0 then begin\n q:=q+1;\n b[q]:=a[i];\n end;\n b[0]:=0;\n for i:=1 to q do\n if b[i]0 then begin\n l:=i;\n break;\n end;\n for i:=l+1 to 26 do\n if a[i]<>0 then begin\n r:=i;\n if a[r]'' then s:=s+t;\n t:='YES';\n j:=98;\n if s[1]<>'a' then\n begin\n t:='NO';\n end else\n for i := 2 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n j:=ord(s[i]);\n break;\n end;\n end;\n write(t);\nend."}, {"source_code": "var s,t: string;\n dd: array[1..150] of boolean;\n i,j: integer;\nbegin\n readln(s);\n readln(t);\n if t <>'' then s:=s+t;\n t:='YES';\n j:=98;\n if s[1]<>'a' then\n begin\n t:='NO';\n end else\n for i := 2 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n break;\n end;\n if ord(s[i])>j then j:=ord(s[i]);\n end;\n write(t);\nend."}, {"source_code": "var s,t: string;\n dd: array[1..150] of boolean;\n i,j: integer;\nbegin\n readln(s);\n readln(t);\n if t <>'' then s:=s+t;\n t:='YES';\n j:=98;\n if s[1]<>'a' then\n begin\n t:='NO';\n end else\n for i := 2 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n break;\n end;\n j:=ord(s[i]);\n end;\n write(t);\nend."}, {"source_code": "var s,t: string;\n dd: array[1..150] of boolean;\n i,j: integer;\nbegin\n readln(s);\n readln(t);\n if t <>'' then s:=s+t;\n t:='YES';\n j:=98;\n if not(s[1]='a') then\n begin\n t:='NO';\n end else\n for i := 2 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n break;\n end;\n end;\n write(t);\nend."}, {"source_code": "var s,t: string;\n dd: array[1..150] of boolean;\n i: integer;\n c: char;\nbegin\n readln(s);\n readln(t);\n if t <>'' then s:=s+t;\n t:='YES';\n for i := 1 to length(s) do dd[ord(s[i])]:=true;\n for i := 98 to 122 do if (dd[i]=true)and(dd[i-1]=false) then\n begin\n t:='NO';\n break;\n end;\n write(t);\nend."}, {"source_code": "var s,t: string;\n dd: array[1..150] of boolean;\n i,j: integer;\nbegin\n readln(s);\n readln(t);\n if t <>'' then s:=s+t;\n t:='YES';\n j:=98;\n for i := 1 to length(s) do\n begin\n if not((ord(s[i])<=j)or(ord(s[i])=j+1)) then\n begin\n t:='NO';\n break;\n end;\n end;\n write(t);\nend."}, {"source_code": "var st,xd:string;i:longint;\nbegin\nread(St);\nfor i:=length(st) downto 1 do xd:=xd+st[i];\nif (st=xd) and (st[1]='a') then write('yes')\n else write('no');\nreadln\nend."}, {"source_code": "var st,xd:string;i:longint;\nbegin\nread(St);\nfor i:=length(st) downto 1 do xd:=xd+st[i];\nif st=xd then write('yes')\n else write('no');\nreadln\nend."}, {"source_code": "var s1:string;\n i:char;\nbegin\n readln(s1);\n for i:='a' to 'z' do\n if (pos(i,s1) = 0) and (s1 <> '') then begin writeln('NO'); exit; end\n else \n while pos(i,s1) <> 0 do delete(s1,pos(i,s1),1);\n writeln('YES');\nend.\n "}], "src_uid": "c4551f66a781b174f95865fa254ca972"} {"source_code": "Uses math;\nvar s,n,i,m,j,k,x:longint;\n a:array[0..3]of longint;\n dp:array[0..300,0..300]of longint;\n begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n m:=300;\n if(n=1)then\n begin\n if(a[i]=0)then writeln('BitAryo')else\n writeln('BitLGM');\n exit;\n end;\n if(n=2)then\n begin\n for i:=0 to m do\n for j:=0 to m do\n begin\n if(i=0)and(j=0)then continue;\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end.", "positive_code": [{"source_code": "{$Q-,R-,S-,I-,O+,L-,D-}\nvar f:array[0..300,0..300,0..300] of boolean;\n l,i,j,n,m,k:longint;\n a:array[1..3] of longint;\n fl:boolean;\n\n function ok(a,b:longint):boolean;\n begin\n if ab then\n begin\n k:=a; a:=b; b:=k;\n end;\n if a>c then\n begin\n k:=a; a:=c; c:=k;\n end;\n if b>c then\n begin\n k:=b; b:=c; c:=k;\n end;\n exit(f[a][b][c]);\n end;\n\n begin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do for j:=i to n do if a[i]>a[j] then\n begin\n k:=a[i]; a[i]:=a[j]; a[j]:=k;\n end;\n if n=1 then\n begin\n if a[1]=0 then writeln('BitAryo') else writeln('BitLGM');\n halt;\n end;\n f[0][0][0]:=false;\n if n=3 then\n begin\n\n if a[1] xor a[2] xor a[3] <> 0 then writeln('BitLGM') else writeln('BitAryo');\n halt;\n end;\n for i:=0 to a[1] do for j:=i to a[2] do if (i+j>0) then\n begin\n fl:=false;\n for l:=1 to i do if not ok(i-l,j) then\n begin\n fl:=true;\n break;\n end;\n if fl then\n begin\n f[i][j][0]:=true;\n continue;\n end;\n for l:=1 to j do if not ok(i,j-l) then\n begin\n fl:=true;\n break;\n end;\n if fl then\n begin\n f[i][j][0]:=true;\n continue;\n end;\n for l:=1 to i do if not f[i-l][j-l][0] then\n begin\n fl:=true;\n break;\n end;\n f[i][j][0]:=fl;\n end;\n if f[a[1]][a[2]][0] then writeln('BitLGM') else writeln('BitAryo');\nend.\n\n"}, {"source_code": "var n,i,j,k,l,ww,u,v,w:longint;\n a:array[0..3]of longint;\n f:array[0..300,0..300,0..300]of longint;\nfunction min(a,b:longint):longint;\n begin\n if a0 then\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n for k:=0 to a[3] do\n if f[i,j,k]=0 then\n begin\n ww:=maxlongint;\n if (n>=1) then ww:=min(ww,a[1]-i);\n if (n>=2) then ww:=min(ww,a[2]-j);\n if (n>=3) then ww:=min(ww,a[3]-k);\n for l:=1 to a[1]-i do\n f[i+l,j,k]:=1;\n for l:=1to a[2]-j do\n f[i,j+l,k]:=1;\n for l:=1 to a[3]-k do\n f[i,j,k+l]:=1;\n for l:=1 to ww do\n begin\n u:=0;v:=0;w:=0;\n if n>=1 then u:=i+l;\n if n>=2 then v:=j+l;\n if n>=3 then w:=k+l;\n f[u,v,w]:=1;\n end;\n end;\n if f[a[1],a[2],a[3]]=1 then\n writeln('BitLGM')\n else\n writeln('BitAryo');\n\n\nend.\n"}, {"source_code": "uses math;\nconst win :string ='BitLGM';\n lose :string ='BitAryo';\ntype pair =record\n a :longint;\n b :longint;\nend;\nvar n,m,i,j,t,ans,a,b,c,k :longint;\n d :Array[0..310,0..310] of boolean;\n fl :boolean;\nProcedure swap(var a,b :longint);\nvar t :longint; Begin t:=a; a:=b; b:=t; end;\nBegin\n read(n);\n if n=1 then\n Begin\n read(t);\n if t>0 then writeln(win) else writeln(lose);\n halt;\n end;\n if n=2 then\n Begin\n d[0,0]:=true;\n read(a,b);\n if a>b then swap(a,b);\n for i:=1 to a do\n for j:=1 to b do\n Begin\n fl:=false;\n for k:=0 to 300 do\n Begin\n if (min(i,j)>=k)and(d[i-k,j-k]) then fl:=true;\n if (i>=k) and(d[i-k,j]) then fl:=true;\n if (j>=k) and(d[i,j-k]) then fl:=true;\n end;\n d[i,j]:=not fl;\n end;\n if d[a,b] then writeln(lose)else writeln(win);\n end else\n Begin\n read(a,b,c);\n if(a xor b xor c)=0then writeln(lose)else writeln(win);\n end;\nend.\n"}, {"source_code": "{$r-, s-, q-, i-, o+}\nuses math;\nvar\n n, i, j, k : longint;\n a : array [0..400] of longint;\n f : array [0..400, 0..400] of longint;\nbegin\n readln(n);\n for i := 1 to n do read(a[i]);\n if (n = 1) then\n begin\n if (a[n] > 0) then writeln('BitLGM') else\n writeln('BitAryo');\n end else\n if (n = 2) then\n begin\n for i := 0 to a[1] do\n for j := 0 to a[2] do\n for k := 1 to max(i, j) do\n if ((k <= i) and (f[i - k][j] = 0)) or\n ((k <= j) and (f[i][j - k] = 0)) or\n ((k <= i) and (k <= j) and (f[i - k][j - k] = 0)) then\n begin\n f[i][j] := 1;\n break;\n end;\n if (f[a[1]][a[2]] = 1) then writeln('BitLGM') else\n writeln('BitAryo');\n end else\n begin\n if (a[1] xor a[2] xor a[3] > 0) then writeln('BitLGM') else\n writeln('BitAryo');\n end;\nend."}, {"source_code": "program p1;\nuses math;\nvar n,i,j,k,x:integer;\na:array[0..3] of integer;\nwin:array[0..300,0..300] of integer;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[i]=0) and (n=1) then\n begin\n writeln('BitAryo');\n halt(0);\n end;\n if (a[i]>0) and (n=1) then\n begin\n writeln('BitLGM');\n halt(0);\n end;\n\n if n=3 then\n begin\n x:=a[1] xor a[2] xor a[3];\n if x>0 then writeln('BitLGM')\n else writeln('BitAryo');\n halt(0);\n end;\n\n if n=2 then\n begin\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n for k:=1 to max(i,j)do\n if ((k<=i) and (win[i-k][j]=0)) or\n ((k<=j) and (win[i][j-k]=0)) or\n ((k<=i) and (k<=j) and (win[i-k][j-k]=0))\n then begin\n win[i][j]:=1;\n break;\n end;\n if (win[a[1]][a[2]]=1) then writeln('BitLGM')\n else writeln('BitAryo');\n end;\nend.\n\n"}, {"source_code": "uses\n math;\n\nconst\n Fir='BitLGM';\n Sec='BitAryo';\n\nvar\n f:array[0..333,0..333]of longint;\n n,m,k,i,j:longint;\n\nbegin\n read(n);\n if (n=1)then begin\n read(n);\n if (n>0)then writeln(Fir)else writeln(Sec);\n end else \n if (n=3)then begin\n read(n,m,k);\n n:=n xor m xor k;\n if (n>0)then writeln(Fir)else writeln(Sec);\n end else begin\n read(n,m);\n for i:=0 to n do\n for j:=0 to m do \n for k:=1 to max(i,j)do\n if ((k<=i)and(f[i-k][j]=0))or\n ((k<=j)and(f[i][j-k]=0))or\n ((k<=i)and(k<=j)and(f[i-k][j-k]=0))\n then begin f[i][j]:=1;break; end; \n if (f[n][m]=1)then writeln(Fir)else writeln(Sec);\n end;\nend.\n"}, {"source_code": "uses math;\nvar\n a:array[1..3] of longint;\n i,j,n:longint;\n first,second:string;\n f,find:array[0..300,0..300] of boolean;\n\n\n\nprocedure print(s : string);\nbegin\n writeln(s);\n halt;\nend;\n\n\nfunction f_2(a,b:longint) : boolean;\nvar\n x,y,i:longint;\n can:boolean;\nbegin\n x:=min(a,b);\n y:=max(a,b);\n if find[x,y] then exit(f[x,y]);\n if (x = 0) then if y <> 0 then exit(true) else exit(false);\n if (x = y) then exit(true);\n can:=false;\n for i:=1 to x do if not(f_2(x - i,y-i)) then can:=true;\n for i:=1 to x do if not(f_2(x-i,y)) then can := true;\n for i:=1 to y do if not(f_2(x,y-i)) then can := true;\n find[x,y] := true;\n f[x,y] := can;\n f_2 := can;\nend;\n\nprocedure swap(var a,b:longint);\nvar\n c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do find[i,j] := false;\n for i:=0 to 300 do\n for j:=0 to 300 do f[i,j] := false;\n for i:=1 to 300 do f[0,i] := true;\n for i:=1 to 300 do f[i,0] := true;\n for i:=3 to 300 do f[1,i] := true;\n f[1,1] := true;\n f[1,2] := false;\n for i:=1 to 300 do find[0,i] := true;\n for i:=1 to 300 do find[i,0] := true;\n for i:=3 to 300 do find[1,i] := true;\n find[1,1] := true;\n find[1,2] := true;\n first:='BitLGM';\n second:='BitAryo';\n if n = 1 then if a[1] = 0 then print(second) else print(first);\n if n = 2 then if f_2(a[1],a[2]) then print(first) else print(second);\n for i:=1 to 2 do\n for j:=i+1 to 3 do if a[i] > a[j] then swap(a[i],a[j]);\n if (a[1] xor a[2] xor a[3] = 0 ) then print(SECOND) else print(first);\nend.\n\n"}, {"source_code": "uses math; const first='BitLGM'; second='BitAryo';\nvar\n f:array[0..300,0..300] of byte; n,i,j,k,a,b,c:longint;\n\n\nbegin\n\n readln(n);\n if n=1 then\n begin\n readln(a);\n if a=0 then writeln(second) else writeln(first);\n end;\n if n=2 then\n begin\n readln(a,b);\n for i:=0 to a do\n for j:=0 to b do\n begin\n for k:=1 to min(i,j) do if f[i-k,j-k]=0 then f[i,j]:=1;\n for k:=1 to max(i,j) do\n if ((i-k>=0)and(f[i-k,j]=0)) or ((j-k>=0)and(f[i,j-k]=0)) then f[i,j]:=1;\n end;\n if f[a,b]=0 then writeln(second) else writeln(first);\n end;\n if n=3 then\n begin\n readln(a,b,c);\n if (a xor b xor c)=0 then writeln(second) else writeln(first);\n end;\n\nend."}, {"source_code": "uses math;\nvar\n a:array[1..3] of longint;\n i,j,n:longint;\n first,second:string;\n f,find:array[0..300,0..300] of boolean;\n\n\n\nprocedure print(s : string);\nbegin\n writeln(s);\n halt;\nend;\n\n\nfunction f_2(a,b:longint) : boolean;\nvar\n x,y,i:longint;\n can:boolean;\nbegin\n x:=min(a,b);\n y:=max(a,b);\n if find[x,y] then exit(f[x,y]);\n if (x = 0) then if y <> 0 then exit(true) else exit(false);\n if (x = y) then exit(true);\n can:=false;\n for i:=1 to x do if not(f_2(x - i,y-i)) then can:=true;\n for i:=1 to x do if not(f_2(x-i,y)) then can := true;\n for i:=1 to y do if not(f_2(x,y-i)) then can := true;\n find[x,y] := true;\n f[x,y] := can;\n f_2 := can;\nend;\n\nprocedure swap(var a,b:longint);\nvar\n c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do find[i,j] := false;\n for i:=0 to 300 do\n for j:=0 to 300 do f[i,j] := false;\n for i:=1 to 300 do f[0,i] := true;\n for i:=1 to 300 do f[i,0] := true;\n for i:=3 to 300 do f[1,i] := true;\n f[1,1] := true;\n f[1,2] := false;\n for i:=1 to 300 do find[0,i] := true;\n for i:=1 to 300 do find[i,0] := true;\n for i:=3 to 300 do find[1,i] := true;\n find[1,1] := true;\n find[1,2] := true;\n first:='BitLGM';\n second:='BitAryo';\n if n = 1 then if a[1] = 0 then print(second) else print(first);\n if n = 2 then if f_2(a[1],a[2]) then print(first) else print(second);\n for i:=1 to 2 do\n for j:=i+1 to 3 do if a[i] > a[j] then swap(a[i],a[j]);\n if a[1] = 0 then if (a[2] <> a[3]) and f_2(a[2],a[3])\n then print(first) else print(second);\n if (a[1] = a[2]) and (a[1] = a[3]) then print(first);\n if (a[1] xor a[2] xor a[3] = 0 ) then print(SECOND) else print(first);\nend.\n\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\n{$M 10000000}\nvar\n f:array [0..300,0..300] of byte;\n a:array [0..100] of longint;\n n,i,j,k:longint;\n function min(a,b:longint):longint; begin if ab then max:=a else max:=b; end;\n\n function rec(x,y:longint):longint;\n var\n ans:byte;\n i,kol,ko:longint;\n begin\n if f[x,y]<>2 then begin rec:=f[x,y]; exit; end;\n if (x=0) and (y=0) then begin rec:=0; exit; end;\n if ((x=0) and (y>0)) or ((x>0) and (y=0)) then begin rec:=1; exit; end;\n ko:=0;\n for i:=1 to min(x,y) do\n if rec(x-i,y-i)=0 then inc(ko);\n for i:=1 to max(x,y) do\n begin\n if (x>=i) and (rec(x-i,y)=0) then inc(ko);\n if (y>=i) and (rec(x,y-i)=0) then inc(ko);\n end;\n if ko>0 then ans:=1 else ans:=0;\n f[x,y]:=ans;\n rec:=ans;\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n if n=1 then begin if a[1]>0 then writeln('BitLGM') else writeln('BitAryo'); halt(0); end;\n if n=3 then begin if a[1] xor a[2] xor a[3]<>0 then writeln('BitLGM') else writeln('BitAryo'); halt(0); end;\n if n=2 then begin\n for i:=0 to 300 do\n for j:=0 to 300 do\n f[i,j]:=2;\n if rec(a[1],a[2])=1\n then writeln('BitLGM')\n else writeln('BitAryo'); end;\nend."}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii);\n if ii=0 then writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n if (ii xor jj) xor kk=0 then\n writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "uses math;\nvar\n a:array[0..1000,0..1000]of longint;\n n,m,k,i,j:longint;\n\nbegin\n read(n);\n if (n=1)then begin\n read(n);\n if (n>0)then writeln('BitLGM')else writeln('BitAryo');\n end else\n if (n=3)then begin\n read(n,m,k);\n n:=n xor m xor k;\n if (n>0)then writeln('BitLGM')else writeln('BitAryo');\n end else begin\n read(n,m);\n for i:=0 to n do\n for j:=0 to m do\n for k:=1 to max(i,j)do\n if ((k<=i)and(a[i-k][j]=0))or\n ((k<=j)and(a[i][j-k]=0))or\n ((k<=i)and(k<=j)and(a[i-k][j-k]=0))\n then begin a[i][j]:=1;break; end;\n if (a[n][m]=1)then writeln('BitLGM')else writeln('BitAryo');\n end;\nend.\n"}, {"source_code": "var k,n,i,x,y,z:integer;\na,b,c:array [0..600] of integer;\nbegin\nreadln(n);\nif n=1 then\n begin\n readln(x);\n if x=0 then writeln('BitAryo') else writeln('BitLGM');\n end;\nif n=3 then\n begin\n readln(x,y,z);\n k:=(x xor y) xor z;\n if k=0 then writeln('BitAryo') else writeln('BitLGM');\n end;\nif n=2 then\n begin\n readln(x,y);\n if x>y then\n begin\n z:=x;\n x:=y;\n y:=z;\n end;\n for i:=0 to 600 do a[i]:=0;\n k:=0;\n for i:=0 to 300 do\n begin\n if a[i]=0 then\n begin\n b[k]:=i;\n c[k]:=i+k;\n a[i]:=1;\n a[i+k]:=1;\n k+=1;\n end;\n end;\n k-=1;\n z:=0;\n for i:=0 to k do\n begin\n if (x=b[i]) and (y=c[i]) then\n begin\n z:=1;\n break;\n end;\n end;\n if z=0 then writeln('BitLGM') else writeln('BitAryo');\n end;\nend."}, {"source_code": "program cf173d;\nvar\n a : array [0..299, 0..299, 0..299] of integer;\n b : array [0..299, 0..299] of integer;\n i, j, k, u, m, n, s, x, y, z : longint;\nbegin\nreadln(n);\nif n = 1 then\n begin\n s := 1;\n readln(x);\n if x = 0 then\n s := 2;\n end;\nif n = 2 then\n begin\n for i := 0 to 299 do\n for j := 0 to 299 do\n b[i, j] := 0;\n for i := 0 to 299 do\n for j := 0 to 299 do\n begin\n if b[i, j] = 0 then\n begin\n if i > j then\n m := i\n else\n m := j;\n m := 299 - m;\n for u := 1 to m do\n b[i + u, j + u] := 1;\n u := i + 1;\n while (u <= 299) do\n begin\n b[u, j] := 1;\n inc(u);\n end;\n u := j + 1;\n while (u <= 299) do\n begin\n b[i, u] := 1;\n inc(u);\n end;\n b[i, j] := 2;\n end;\n end;\n readln(x, y);\n s := b[x, y];\n end;\nif n = 3 then\n begin\n for i := 0 to 299 do\n for j := 0 to 299 do\n for k := 0 to 299 do\n a[i, j, k] := 0;\n a[0, 0, 0] := 2;\n for i := 0 to 299 do\n for j := 0 to 299 do\n for k := 0 to 299 do\n begin\n if a[i, j, k] = 0 then\n a[i, j, k] := 2;\n if a[i, j, k] = 2 then\n begin\n u := i + 1;\n while (u <= 299) do\n begin\n a[u, j, k] := 1;\n inc(u);\n end;\n u := j + 1;\n while (u <= 299) do\n begin\n a[i, u, k] := 1;\n inc(u);\n end;\n u := k + 1;\n while (u <= 299) do\n begin\n a[i, j, u] := 1;\n inc(u);\n end;\n m := i;\n if j > m then\n m := j;\n if k > m then\n m := k;\n m := 299 - m;\n for u := 1 to m do\n a[i + u, j + u, k + u] := 1;\n end;\n end;\n readln(x, y, z);\n s := a[x, y, z];\n end;\nif s = 1 then\n writeln('BitLGM')\nelse\n writeln('BitAryo');\nend.\n"}, {"source_code": "var f2:array[0..301,0..301] of longint;\n f3:array[0..301,0..301,0..301] of longint;\n maxx:array[0..333,0..333] of longint;\n minn:array[0..333,0..333] of longint;\n n,m,i,j,k,q1,q2,q3:longint;\n a:array[0..40] of longint;\n first,second:string;\n\n\nfunction min(a,b:longint):longint;\nbegin\n if aB then max:=a else max:=b;\nend;\n\nprocedure two;\nvar i,j,k:longint;\nbegin\n for i:= 0 to 300 do\n for j:= 0 to 300 do\n begin\n if (i=0) and (j=0) then f2[i][j]:=0 else\n begin\n for k:= 1 to maxx[i,j] do\n begin\n if (i>=k) and (j>=k) and (f2[i-k][j-k] = 0) then f2[i][j]:=1;\n if (i>=k) and (f2[i-k][j] = 0) then f2[i][j]:=1;\n if (j>=k) and (f2[i][j-k] = 0) then f2[i][j]:=1;\n end;\n end;\n end;\nend;\n\nprocedure swap(var t,y:longint);\nvar u:longint;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nbegin\n first:='BitLGM';\n second:='BitAryo';\n readln(n);\n for i:= 1 to n do read(a[i]);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n maxx[i][j]:=max(i,j);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n minn[i][j]:=min(i,j);\n if n = 1 then\n begin\n if a[1]=0 then writeln(second) else writeln(first);\n halt;\n end;\n two;\n if n = 2 then\n begin\n if f2[a[1],a[2]]=1 then writeln(first) else writeln(second);\n halt;\n end;\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n {for i:= 0 to 300 do\n for j:= 0 to 300 do\n for k:= 0 to 300 do\n begin\n q1:=i; q2:=j; q3:=k;\n if (q1>q2) then swap(q1,q2);\n if (Q2>q3) then swap(q2,q3);\n if (q1>q2) then swap(q1,q2);\n l1[i,j,k]:=q1;\n l2[i,j,k]:=q2;\n l3[i,j,k]:=q3;\n end;}\n// three;\n f3[a[1],a[2],a[3]]:=a[1] xor a[2] xor a[3];\n if f3[a[1],a[2],a[3]]>0 then writeln(first) else writeln(second);\nend."}, {"source_code": "uses math;\nvar\ns1,s2:string;\ndp:array[0..301,0..301]of longint;\nst,m,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x<0)or(y<0) then exit(true);\n if (x=0)and(y=0) then exit(false);\n if (x=y)and(n=2) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n if (n=2)and(win(x-u,y-u)=false) then tmp:=true;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n s1:='BitLGM';\n s2:='BitAryo';\n for i:=1 to n do\n read(a[i]);\n if n=1 then\n begin\n if a[1]>0 then writeln(s1)\n else writeln(s2);\n end\n else\n begin\n if n=2 then\n begin\n if win(a[1],a[2]) then writeln(s1)\n else writeln(s2);\n end\n\n else\n begin\n t:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n if t=1 then writeln(s1)\n else if t=3 then\n begin\n b[1]:=b[1] xor b[2] xor b[3];\n if b[1]=0 then writeln(s2)\n else writeln(s1);\n end\n else\n begin\n if win(b[1],b[2]) then writeln(s1)\n else writeln(s2);\n end;\n end;\n end;\n end.\n\n"}, {"source_code": "Uses math;\n//const zz:array [1..3,1..11785] of longint=();\nVar m:array [0..300,0..300] of boolean;\nzz:array[1..300] of longint;\nrez:array [1..10000] of Boolean;\nm1:array [0..300,0..300,0..300] of boolean;\nused:array [0..300,0..300,0..300] of Boolean;\nc,i1,kol,n,z,a,b,i,j:LongInt;\nf:boolean;\nprocedure swap(var a,b:longint);\nvar x:longint;\nbegin\n x:=a; a:=b; b:=x;\nend;\nfunction probeg2(a,b,c:longint):boolean;\nVar i:longint;\nbegin\n if used[a,b,c]\n then begin probeg2:=m1[a,b,c]; Exit; end;\n used[a,b,c]:=true;\n used[b,c,a]:=true;\n used[a,c,b]:=true;\n used[b,a,c]:=True;\n used[c,a,b]:=true;\n used[c,b,a]:=true;\n m1[a,b,c]:=False;\n for i:=min(a,Min(b,c)) downto 1 do\n if not probeg2(a-i,b-i,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n\n for i:=a downto 1 do\n if not probeg2(a-i,b,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=b downto 1 do\n if not probeg2(a,b-i,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=c downto 1 do\n if not probeg2(a,b,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n probeg2:=false;\nend;\nprocedure probeg(a,b:longint);\nbegin\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n Halt(0);\nend;\nfunction stepen(x:longint):boolean;\nbegin\n while x>1 do\n begin\n if x mod 2=1\n then begin stepen:=false; exit; end;\n x:=x div 2;\n end;\n stepen:=true;\nend;\nprocedure zapoln(a,b,c:longint);\nbegin\n m1[a,b,c]:=true; used[a,b,c]:=true;\n{ m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;}\nend;\nbegin\n//Assign(input,'input.txt'); reset(input);\n//Assign(output,'output.txt'); rewrite(output);\n readln(n);\n if n=1\n then begin\n read(a);\n if a<>0\n then writeln('BitLGM')\n else writeln('BitAryo');\n Halt(0);\n end;\n if n=2\n then begin\n Readln(a,b);\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n end\n else begin\n readln(a,b,c);\n {if c=0\n then probeg(a,b);\n if b=0\n then probeg(a,c);\n if a=0\n then probeg(b,c);}\n for i:=0 to 300 do\n for j:=0 to 300 do\n for i1:=0 to 300 do\n begin\n if not used[i,j,i1]\n then begin\n m1[i,j,i1]:=False;\n used[i,j,i1]:=true;\n for z:=300-Max(i,Max(j,i1)) downto 1 do\n zapoln(i+z,j+z,i1+z);\n for z:=i+1 to 300 do\n zapoln(z,j,i1);\n for z:=j+1 to 300 do\n zapoln(i,z,i1);\n for z:=i1+1 to 300 do\n zapoln(i,j,z);\n end;\n end;\n if not m1[a,b,c]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n{ m1[0,0,0]:=false;\n for i:=0 to a do\n for j:=0 to b do\n for i1:=0 to c do\n begin\n f:=false;\n for z:=1 to min(i,min(j,i1)) do\n if not m1[i-z,j-z,i1-z]\n then f:=true;\n for z:=1 to i do\n if not m1[i-z,j,i1]\n then f:=true;\n for z:=1 to j do\n if not m1[i,j-z,i1]\n then f:=true;\n for z:=1 to i1 do\n if not m1[i,j,i1-z]\n then f:=true;\n m1[i,j,i1]:=f;\n end;\n for i:=1 to a do\n begin\n f:=false;\n for j:=i to b do\n for i1:=j to c do\n if not m1[i,j,i1]\n then writeln(i,' ',j,' ',i1,',');\n end;}\n end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\n\nvar\n a3, was3 : array[0..300, 0..300, 0..300] of boolean;\n a2, was2 : array[0..300, 0..300] of boolean;\n i, n : integer;\n y : array[1..3] of integer;\n\nprocedure first;\nbegin\n writeln('BitLGM');\n halt(0);\nend;\n\nprocedure second;\nbegin\n writeln('BitAryo');\nend;\n\nfunction solve2(x, y : integer) : boolean;\nvar\n i : integer;\nbegin\n if was2[x, y] then\n result := a2[x, y]\n else begin\n was2[x, y] := true;\n result := false;\n for i := 1 to x do\n result := result or (not solve2(x - i, y));\n for i := 1 to y do\n result := result or (not solve2(x, y - i));\n for i := 1 to min(x, y) do\n result := result or (not solve2(x - i, y - i));\n a2[x, y] := result;\n end;\nend;\n\nfunction solve3(x, y, z : integer) : boolean;\nvar\n i : integer;\nbegin\n if was3[x, y, z] then\n result := a3[x, y, z]\n else begin\n was3[x, y, z] := true;\n result := false;\n for i := 1 to x do\n result := result or (not solve3(x - i, y, z));\n for i := 1 to y do\n result := result or (not solve3(x, y - i, z));\n for i := 1 to z do\n result := result or (not solve3(x, y, z - i));\n for i := 1 to min(x, min(y, z)) do\n result := result or (not solve3(x - i, y - i, z - i));\n a3[x, y, z] := result;\n end;\nend;\n\nbegin\n readln(n);\n for i := 1 to n do\n read(y[i]);\n if (n = 1) then\n if (y[1] = 0) then\n second\n else\n first;\n if (n = 2) then\n if solve2(y[1], y[2]) then\n first\n else\n second;\n if (n = 3) then\n if (y[1] xor y[2] xor y[3] > 0) then \n first\n else\n second;\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nType\n t_type=-1..1;\n t_type1=0..500;\nVar\n dp:Array[0..300,0..300,0..300] of t_type;\n r:Array[0..300,0..300,0..300,1..4] of t_type1;\n a:Array[1..3] of Integer;\n n,i,j,k:Integer;\nProcedure Solve(x,y,z:Integer);\nVar t,k1,k2,k3,k4:Integer;\nBegin\n If dp[x,y,z]<>-1 Then Exit;\n If n=2 Then Begin\n If x>0 Then Solve(x-1,y,z);\n If y>0 Then Solve(x,y-1,z);\n t:=min(x,y);\n If t>0 Then Solve(x-1,y-1,z);\n k1:=0;\n If x>0 Then k1:=r[x-1,y,z,1];\n k2:=0;\n If y>0 Then k2:=r[x,y-1,z,2];\n k3:=0;\n If t>0 Then k3:=r[x-1,y-1,z,4];\n If (k1=x) and (k2=y) and (k3=t) Then Begin\n dp[x,y,z]:=0;\n If x>0 Then r[x,y,z,1]:=r[x-1,y,z,1]\n Else r[x,y,z,1]:=0;\n If y>0 Then r[x,y,z,2]:=r[x,y-1,z,2]\n Else r[x,y,z,2]:=0;\n If t>0 Then r[x,y,z,4]:=r[x-1,y-1,z,4]\n Else r[x,y,z,4]:=0;\n End\n Else Begin\n dp[x,y,z]:=1;\n If x>0 Then r[x,y,z,1]:=r[x-1,y,z,1]+1\n Else r[x,y,z,1]:=1;\n If y>0 Then r[x,y,z,2]:=r[x,y-1,z,2]+1\n Else r[x,y,z,2]:=1;\n If t>0 Then r[x,y,z,4]:=r[x-1,y-1,z,4]+1\n Else r[x,y,z,4]:=1;\n End;\n End\n Else Begin\n If x>0 Then Solve(x-1,y,z);\n If y>0 Then Solve(x,y-1,z);\n If z>0 Then Solve(x,y,z-1);\n t:=min(x,min(y,z));\n If t>0 Then Solve(x-1,y-1,z-1);\n k1:=0;\n If x>0 Then k1:=r[x-1,y,z,1];\n k2:=0;\n If y>0 Then k2:=r[x,y-1,z,2];\n k3:=0;\n If z>0 Then k3:=r[x,y,z-1,3];\n k4:=0;\n If t>0 Then k4:=r[x-1,y-1,z-1,4];\n If (k1=x) and (k2=y) and (k3=z) and (k4=t) Then Begin\n dp[x,y,z]:=0;\n If x>0 Then r[x,y,z,1]:=r[x-1,y,z,1]\n Else r[x,y,z,1]:=0;\n If y>0 Then r[x,y,z,2]:=r[x,y-1,z,2]\n Else r[x,y,z,2]:=0;\n If z>0 Then r[x,y,z,3]:=r[x,y,z-1,3]\n Else r[x,y,z,3]:=0;\n If t>0 Then r[x,y,z,4]:=r[x-1,y-1,z-1,4]\n Else r[x,y,z,4]:=0;\n End\n Else Begin\n dp[x,y,z]:=1;\n If x>0 Then r[x,y,z,1]:=r[x-1,y,z,1]+1\n Else r[x,y,z,1]:=1;\n If y>0 Then r[x,y,z,2]:=r[x,y-1,z,2]+1\n Else r[x,y,z,2]:=1;\n If z>0 Then r[x,y,z,3]:=r[x,y,z-1,3]+1\n Else r[x,y,z,3]:=1;\n If t>0 Then r[x,y,z,4]:=r[x-1,y-1,z-1,4]+1\n Else r[x,y,z,4]:=1;\n End;\n End;\nEnd;\nBegin\n Read(n);\n For i:=1 To n Do Read(a[i]);\n If n=1 Then Begin\n If a[1]>0 Then Write('BitLGM')\n Else Write('BitAryo');\n Halt;\n End;\n If n=3 Then Begin\n If a[1] xor a[2] xor a[3]<>0 Then Write('BitLGM')\n Else Write('BitAryo');\n Halt;\n End;\n For i:=0 To 300 Do\n For j:=0 To 300 Do\n For k:=0 To 300 Do dp[i,j,k]:=-1;\n dp[0,0,0]:=0;\n Solve(a[1],a[2],a[3]);\n If dp[a[1],a[2],a[3]]=1 Then Write('BitLGM')\n Else Write('BitAryo');\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R-,Q-,O+}\n\nuses\n SysUtils, Math;\n\nvar\n i, j, k, n: integer;\n a: array[1..100] of integer;\n f: array[0..300, 0..300, 0..300] of integer;\n\nfunction get(x1, x2, x3: integer): integer;\nvar\n i: integer;\n mex: array[0..1] of boolean;\nbegin\n for i := 0 to 1 do\n mex[i] := false;\n\n if (f[x1][x2][x3] = -1) then begin\n for i := 1 to x1 do begin\n if (mex[0]) then\n break;\n mex[get(x1 - i, x2, x3)] := true;\n end;\n\n for i := 1 to x2 do begin\n if (mex[0]) then\n break;\n mex[get(x1, x2 - i, x3)] := true;\n end;\n\n for i := 1 to x3 do begin\n if (mex[0]) then\n break;\n mex[get(x1, x2, x3 - i)] := true;\n end;\n\n for i := 1 to min(min(x1, x2), x3) do begin\n if (mex[0]) then\n break;\n mex[get(x1 - i, x2 - i, x3 - i)] := true;\n end;\n\n if (mex[0] = false) then\n result := 0\n else\n result := 1;\n\n f[x1][x2][x3] := result;\n f[x1][x3][x2] := result;\n f[x2][x1][x3] := result;\n f[x2][x3][x1] := result;\n f[x3][x1][x2] := result;\n f[x3][x2][x1] := result;\n end else begin\n result := f[x1][x2][x3];\n end;\nend;\n\nfunction get1(x1, x2: integer): integer;\nvar\n i: integer;\n mex: array[0..1] of boolean;\nbegin\n if (f[x1][x2][0] = -1) then begin\n for i := 0 to 1 do\n mex[i] := false;\n for i := 1 to x1 do begin\n mex[get1(x1 - i, x2)] := true;\n end;\n\n for i := 1 to x2 do begin\n mex[get1(x1, x2 - i)] := true;\n end;\n\n for i := 1 to min(x1, x2) do begin\n mex[get1(x1 - i, x2 - i)] := true;\n end;\n\n if (mex[0] = false) then\n result := 0\n else\n result := 1;\n f[x1][x2][0] := result;\n f[x2][x1][0] := result;\n end else begin\n result := f[x1][x2][0];\n end;\nend;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(n);\n\n for i := 1 to n do begin\n read(a[i]);\n end;\n\n for i := 0 to a[1] do\n for j := 0 to a[2] do\n for k := 0 to a[3] do\n f[i][j][k] := -1;\n\n if (n = 1) then begin\n if (a[1] = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n halt;\n end;\n\n if (n = 2) then begin\n if (get1(a[1], a[2]) = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n halt;\n end;\n\n if (a[1] xor a[2] xor a[3] = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n\n\n\nend."}, {"source_code": "{$R-,S-,Q-,I-,O-}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nn,i,j,k : longint;\nok : boolean;\na : array [1..3] of longint;\ndp : array [0..333,0..333] of boolean;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n if n = 1 then\n begin\n if a[1] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\n halt;\n end;\n if n = 2 then\n begin\n fillchar(dp,sizeof(dp),true);\n dp[0][0]:=false;\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n if not((i = 0) and (j = 0)) then\n begin\n ok:=false;\n for k:=1 to min(i,j) do\n if not dp[i - k,j - k] then ok:=true;\n for k:=1 to i do\n if not dp[i - k,j] then ok:=true;\n for k:=1 to j do\n if not dp[i,j - k] then ok:=true;\n dp[i,j]:=ok;\n end;\n if dp[a[1],a[2]] then writeln('BitLGM')\n else writeln('BitAryo');\n halt;\n end;\n\n if a[1] xor a[2] xor a[3] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\nend.\n\n"}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n begin\n if a[x-i,y]=0 then rec(x-i,y);\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end;\n end;\n For i:=1 to y do\n begin\n if a[x,y-i]=0 then rec(x,y-i);\n if (a[x,y-i]=2) then begin a[x,y]:=1; exit; end;\n end;\n t:=min(x,y);\n For i:=1 to t do\n begin\n if a[x-i,y-i]=0 then rec(x-i,y-i);\n if a[x-i,y-i]=2 then begin a[x,y]:=1; exit; end;\n end;\n a[x,y]:=2;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitLGM') else WriteLn('BitAryo'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end."}, {"source_code": "uses math;\nvar a:array [0..300] of longint;\n i,j,x,n,z,q:longint;ans:longint;\n s1,s2:ansistring;\n aa:array [0..300,0..300,0..300] of longint;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if iy then y:=j;\n for x:=1 to 310-y do aa[i+x,j+x]:=1;\n end;\n if aa[qc[1],qc[2]]=0 then res:=2 else res:=1;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,j,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n//{$R+}\n\nuses\n SysUtils, Math;\n\nvar\n a : array[1..3] of integer;\n n, i, j, x, k : integer;\n d : array[0..300, 0..300, 0..300] of boolean;\n was: array[0..300, 0..300] of integer;\n d2 : array[0..300, 0..300] of boolean;\n\nfunction f(a, b, c : integer):boolean;\nvar\n x, y, z : integer;\nbegin\n x := min(a, b);\n y := max(c, a);\n z := a + b + c - x - y;\n result := d[x][z][y];\nend;\n\nprocedure pr1;\nbegin\n writeln('BitLGM');\n halt;\nend;\n\nprocedure pr2;\nbegin\n writeln('BitAryo');\n halt;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input ,'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(n);\n\n for i := 1 to n do begin\n read(a[i]);\n end;\n if n = 1 then begin\n if a[1] = 0 then\n pr2 else\n pr1;\n end;\n \n if n = 2 then begin\n for i := 0 to a[1] do begin\n for j := 0 to a[2] do begin\n for x := 0 to i - 1 do begin\n if not d2[x][j] then\n d2[i][j] := true;\n end;\n for x := 0 to j - 1 do begin\n if not d2[i][x] then\n d2[i][j] := true;\n end;\n for x := 1 to min(i, j) do begin\n if not d2[i - x][j - x] then\n d2[i][j] := true;\n end;\n end;\n end;\n if d2[a[1]][a[2]] then\n pr1 else pr2;\n end;\n\n if n = 3 then begin\n i := a[1];\n j := a[2];\n k := a[3];\n a[1] := min(i, min(j, k));\n a[3] := max(i, max(j, k));\n a[2] := i + j + k - a[1] - a[3];\n n := 300;\n for i := 0 to n do begin\n for j := i to n do begin\n was[i][j] := -1;\n for k := j to n do begin\n d[i][j][k] := true;\n end;\n end;\n end;\n for i := 0 to n do begin\n for j := i to n do begin\n for k := j to n do begin\n if (was[i][j] = k) or\n (was[i][k] = j) or\n (was[j][k] = i) then begin\n break;\n end;\n d[i][j][k] := (was[i][j] >= 0) or (was[j][k] >= 0) or (was[i][k] >= 0);\n if not d[i][j][k] then begin\n for x := min(i, min(j, k)) downto 1 do begin\n if not d[i - x][j - x][k - x] then begin\n d[i][j][k] := true;\n break;\n end;\n end;\n end;\n if not d[i][j][k] then begin\n was[i][k] := j;\n was[j][k] := i;\n was[i][j] := k;\n break;\n end;\n end;\n end;\n end;\n if d[a[1]][a[2]][a[3]] then\n pr1 else\n pr2;\n \n end;\n\nend.\n"}, {"source_code": "program zzz;\n const\n ans:array[0..1] of string=('BitAryo','BitLGM');\n var\n a:array[1..3] of longint;\n n,i:longint;\n\n function min(x,y:longint):longint;\n begin\n if x>y\n then min:=y\n else min:=x;\n end;\n\n procedure sol2(x,y:longint);\n const\n n=300;\n var\n a,sx,sy,sd:array[0..500,0..500] of longint;\n i,j:longint;\n begin\n fillchar(a,sizeof(a),0);\n fillchar(sx,sizeof(sx),0);\n fillchar(sy,sizeof(sy),0);\n fillchar(sd,sizeof(sd),0);\n\n for i:=1 to 300 do\n begin\n a[0][i]:=1;\n a[i][0]:=1;\n sx[0][i]:=1;\n sx[i][0]:=1;\n sy[0][i]:=1;\n sy[i][0]:=1;\n sd[0][i]:=1;\n sd[i][0]:=1;\n end;\n\n for i:=1 to x do\n for j:=1 to y do\n begin\n if (sx[i-1][j]0\n then write(ans[1])\n else write(ans[0]);\n end;\n\n\n if n=2 then sol2(a[1],a[2]);\n\n if n=3 then sol3(a[1],a[2],a[3]);\n\nend.\n"}], "negative_code": [{"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if i=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]>=3) and (a[1] mod 2=1) and (a[2]=a[1]+1) then wr (0);\n wr (1);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n if (a[1]>=3) and (a[2]-a[1]=a[1]-1) then wr (0);\n wr (1);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\n\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[2]-a[1]<=1) then wr (1);\n //if (a[1] mod 2=1) and (a[2]=a[1]+1) then wr (0);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n if a[1]>=4 then wr (1);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\n\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..300] of longint;\n i,j,x,n,o,q:longint;ans:longint;\n s1,s2:ansistring;\n aa:array [0..300,0..300,0..300] of longint;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if i0 then\n exit (aa[x,y,v]);\n for i:=1 to x do\n if aa[x-i,y,v]=-1 then exit(1);\n for i:=1 to y do\n if aa[x,y-i,v]=-1 then exit(1);\n for i:=1 to v do\n begin\n if aa[x,y,v-i]=-1 then exit (1);\n end;\n for i:=1 to min (min(x,y),v) do\n if aa[x-i,y-i,v-i]=-1 then exit (1);\n for i:=1 to min (min(x,y),v) do\n if aa[x-i,y-i,v-i]=0 then\n begin\n q:=solve3 (x-i,y-i,v-i);\n aa[x-i,y-i,v-i]:=q;\n if q=-1 then exit(1);\n end;\n for i:=1 to x do\n if aa[x-i,y,v]=0 then\n begin\n q:=solve3 (x-i,y,v);\n aa[x-i,y,v]:=q;\n if q=-1 then exit(1);\n end;\n for i:=1 to y do\n\n if aa[x,y-i,v]=0 then\n begin\n q:=solve3 (x,y-i,v);\n aa[x,y-i,v]:=q;\n if q=-1 then exit(1);\n end;\n for i:=1 to v do\n if aa[x,y,v-i]=0 then\n begin\n q:=solve3 (x,y,v-i);\n aa[x,y,v-i]:=q;\n if q=-1 then exit(1);\n end;\n aa[x,y,v]:=-1;\n exit(-1);\n end;\n\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (n);\nfor i:=1 to n do read (a[i]);\nif (n=1) and (a[1]=0) then wr (0);\nif n=1 then\n wr (1);\nif n=2 then\n begin\n solve(a[1],a[2]);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\naa[0,0,0]:=-1;\nq:=solve3 (a[1],a[2],a[3]);\nif q=-1 then q:=0;\nwr (q);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\n\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend.\n"}, {"source_code": "program zzz;\n const\n ans:array[0..1] of string=('BitAryo','BitLGM');\n var\n a:array[1..3] of longint;\n n,i:longint;\n\n function min(x,y:longint):longint;\n begin\n if x>y\n then min:=y\n else min:=x;\n end;\n\n procedure sol2(x,y:longint);\n const\n n=300;\n var\n a,sx,sy,sd:array[0..500,0..500] of longint;\n i,j:longint;\n begin\n fillchar(a,sizeof(a),0);\n fillchar(sx,sizeof(sx),0);\n fillchar(sy,sizeof(sy),0);\n fillchar(sd,sizeof(sd),0);\n\n for i:=1 to 300 do\n begin\n a[0][i]:=1;\n a[i][0]:=1;\n sx[0][i]:=1;\n sx[i][0]:=1;\n sd[i][0]:=1;\n sd[0][i]:=1;\n end;\n\n for i:=1 to n do\n for j:=1 to n do\n begin\n if (sx[i-1][j]y\n then min:=y\n else min:=x;\n end;\n\n procedure sol2(x,y:longint);\n const\n n=300;\n var\n a,sx,sy,sd:array[0..500,0..500] of longint;\n i,j:longint;\n begin\n fillchar(a,sizeof(a),0);\n fillchar(sx,sizeof(sx),0);\n fillchar(sy,sizeof(sy),0);\n fillchar(sd,sizeof(sd),0);\n\n for i:=1 to 300 do\n begin\n a[0][i]:=1;\n a[i][0]:=1;\n sx[0][i]:=1;\n sx[i][0]:=1;\n sy[0][i]:=1;\n sy[i][0]:=1;\n sd[0][i]:=1;\n sd[i][0]:=1;\n end;\n\n for i:=1 to x do\n for j:=1 to y do\n begin\n if (sx[i-1][j]0)then\n begin\n inc(m);\n a[m]:=x;\n end;\n end;\n n:=m;m:=300;\n if(n=0)then\n begin\n writeln('BitLGM');\n exit;\n end;\n if(n=1)then\n begin\n writeln('BitAryo');\n exit;\n end;\n if(n=2)then\n begin\n for i:=0 to m do\n for j:=0 to m do\n begin\n if(i=0)and(j=0)then continue;\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end."}, {"source_code": "Uses math;\nvar s,n,i,m,j,k,x:longint;\n a:array[0..3]of longint;\n dp:array[0..300,0..300]of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x);\n if(x>0)then\n begin\n inc(m);\n a[m]:=x;\n end;\n end;\n n:=m;m:=300;\n if(n=0)then\n begin\n writeln('BitAryo');\n exit;\n end;\n if(n=1)then\n begin\n writeln('BitAryo');\n exit;\n end;\n if(n=2)then\n begin\n for i:=0 to m do\n for j:=0 to m do\n begin\n if(i=0)and(j=0)then continue;\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end."}, {"source_code": "Uses math;\nvar s,n,i,m,j,k,x:longint;\n a:array[0..3]of longint;\n dp:array[0..300,0..300]of longint;\n begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n m:=300;\n if(n=1)then\n begin\n writeln('BitLGM');\n exit;\n end;\n if(n=2)then\n begin\n for i:=0 to m do\n for j:=0 to m do\n begin\n if(i=0)and(j=0)then continue;\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end."}, {"source_code": "Uses math;\nvar s,n,i,m,j,k,x:longint;\n a:array[0..3]of longint;\n dp:array[0..300,0..300]of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x);\n if(x>0)then\n begin\n inc(m);\n a[m]:=x;\n end;\n end;\n n:=m;m:=300;\n if(n=0)then\n begin\n writeln('BitAryo');\n exit;\n end;\n if(n=1)then\n begin\n writeln('BitLGM');\n exit;\n end;\n if(n=2)then\n begin\n for i:=0 to m do\n for j:=0 to m do\n begin\n if(i=0)and(j=0)then continue;\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end."}, {"source_code": "var i,n,x:longint;\n a:array[0..3]of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(a[i]);\n x:=x xor a[i];\n end;\n if(x mod 2=0)then writeln('BitLGM')\n else writeln('BitAryo');\n end."}, {"source_code": "Uses math;\nvar s,n,i,m,j,k,x:longint;\n a:array[0..3]of longint;\n dp:array[0..300,0..300]of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x);\n if(x>0)then\n begin\n inc(m);\n a[m]:=x;\n end;\n end;\n n:=m;m:=300;\n if(n=0)then\n begin\n writeln('BitLGM');\n exit;\n end;\n if(n=1)then\n begin\n writeln('BitAryo');\n exit;\n end;\n if(n=2)then\n begin\n for i:=1 to m do\n for j:=1 to m do\n begin\n for k:=1 to min(i,j) do\n if(dp[i-k][j-k]=0)then dp[i,j]:=1;\n for k:=1 to i do\n if(dp[i-k][j]=0)then dp[i,j]:=1;\n for k:=1 to j do\n if(dp[i][j-k]=0)then dp[i,j]:=1;\n end;\n if(dp[a[1],a[2]]=0)then write('BitAryo')\n else write('BitLGM');\n exit;\n end;\n if(n=3)then\n begin\n s:=a[1] xor a[2] xor a[3];\n if(s>0)Then writeln('BitLGM')\n else writeln('BitAryo');\n exit;\n end;\n end."}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii);\n if ii=0 then writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n// jj:=jj xor kk; kk:=0;\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii); WRiteln('BitLGM'); halt end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then Readln(ii,jj,kk);\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\nEnd.\n"}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii); WRiteln('BitLGM'); halt end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n jj:=jj xor kk; kk:=0;\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii);\n if ii=0 then writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n if (ii xor jj) xor kk=0 then\n writeln('BitAryo') else WRiteln('BitLGM');\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii);\n if ii=0 then writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n if (ii xor jj) xor kk=0 then\n WRiteln('BitLGM') else writeln('BitAryo');\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "Uses math;\nVar a:array[0..301,0..301,0..301] of integer;\n n,i,j,k,ii,jj,kk:longint;\nProcedure fill(iii,jjj,kkk:longint);\nVar i,j,t,k:longint;\nBegin\n a[iii,jjj,kkk]:=1;\n\n For i:=iii+1 to ii do a[i,jjj,kkk]:=2;\n For j:=jjj+1 to jj do a[iii,j,kkk]:=2;\n For k:=kkk+1 to kk do a[iii,jjj,k]:=2;\n\n For t:=1 to min(ii-iii,jj-jjj) do a[iii+t,jjj+t,kkk]:=2;\n\n For t:=1 to min(ii-iii,kk-kkk) do a[iii+t,jjj,kkk+t]:=2;\n\n For t:=1 to min(jj-jjj,kk-kkk) do a[iii,jjj+t,kkk+t]:=2;\n\n For t:=1 to min(ii-iii,min(jj-jjj,kk-kkk)) do a[iii+t,jjj+t,kkk+t]:=2;\n\n if a[ii,jj,kk]=2 then begin WRiteln('BitLGM'); halt end;\n if a[ii,jj,kk]=1 then begin WRiteln('BitAryo'); halt end;\n\n\nEnd;\n\n\nBegin\n Readln(n);\n if n=1 then begin Readln(ii);\n if ii=0 then writeln('BitAryo') else WRiteln('BitLGM');\n halt\n end;\n if n=2 then begin Readln(ii,jj); kk:=0 end;\n if n=3 then begin\n Readln(ii,jj,kk);\n jj:=jj xor kk; kk:=0;\n end;\n\n For i:=0 to ii do\n For j:=0 to jj do\n For k:=0 to kk do\n if a[i,j,k]=0 then fill(i,j,k);\n\n End.\n"}, {"source_code": "uses\n math;\n\nvar\n f:array[0..333,0..333]of longint;\n n,m,k,i,j:longint;\n\nbegin\n read(n);\n if (n=1)then begin\n read(n);\n if (n>0)then writeln('BitLGM')else writeln('BitAryo');\n end else\n if (n=3)then begin\n read(n,m,k);\n n:=n xor m xor k;\n if (n>0)then writeln('BitLGM')else writeln('BitAryo');\n end else begin\n read(n,m);\n for i:=0 to n do\n for j:=0 to m do\n for k:=1 to max(i,j)do\n if ((k<=i)and(f[i-k][j]=0))or\n ((k<=j)and(f[i][j-k]=0))or\n ((k<=i)and(k<=j)and(f[i-k][j-k]=0))\n then begin f[i][j]:=1;break; end;\n for i:=1 to n do begin writeln;\n for j:=1 to m do write(f[i][j],' ');\n end;\n\n if (f[n][m]=1)then writeln('BitLGM')else writeln('BitAryo');\n end;\nend.\n"}, {"source_code": "program cf173d;\nvar\n a : array [0..299, 0..299, 0..299] of integer;\n b : array [0..299, 0..299] of integer;\n i, j, k, u, m, n, s, x, y, z : longint;\nbegin\nreadln(n);\nif n = 1 then\n begin\n s := 1;\n readln(x);\n if x = 0 then\n s := 2;\n end;\nif n = 2 then\n begin\n for i := 0 to 299 do\n for j := 0 to 299 do\n b[i, j] := 0;\n for i := 0 to 299 do\n for j := 0 to 299 do\n begin\n if b[i, j] = 0 then\n begin\n if i > j then\n m := i\n else\n m := j;\n m := 299 - m;\n for u := 1 to m do\n b[i + u, j + u] := 1;\n u := i + 1;\n while (u <= 299) do\n begin\n b[u, j] := 1;\n inc(u);\n end;\n u := j + 1;\n while (u <= 299) do\n begin\n b[i, u] := 1;\n inc(u);\n end;\n b[i, j] := 2;\n end;\n end;\n readln(x, y);\n s := b[x, y];\n end;\nif n = 3 then\n begin\n for i := 0 to 299 do\n for j := 0 to 299 do\n for k := 0 to 299 do\n a[i, j, k] := 0;\n a[0, 0, 0] := 2;\n for i := 0 to 299 do\n for j := 0 to 299 do\n for k := 0 to 299 do\n begin\n if a[i, j, k] = 0 then\n a[i, j, k] := 1;\n if a[i, j, k] = 2 then\n begin\n u := i + 1;\n while (u <= 299) do\n begin\n a[u, j, k] := 1;\n inc(u);\n end;\n u := j + 1;\n while (u <= 299) do\n begin\n a[i, u, k] := 1;\n inc(u);\n end;\n u := k + 1;\n while (u <= 299) do\n begin\n a[i, j, u] := 1;\n inc(u);\n end;\n m := i;\n if j > m then\n m := j;\n if k > m then\n m := k;\n m := 299 - m;\n for u := 1 to m do\n a[i + u, j + u, k + u] := 1;\n end;\n end;\n readln(x, y, z);\n s := a[x, y, z];\n end;\nif s = 1 then\n writeln('BitLGM')\nelse\n writeln('BitAryo');\nend.\n"}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n begin\n if a[x-i,y]=0 then rec(x-i,y);\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end;\n end;\n For i:=1 to y do\n begin\n if a[x,y-i]=0 then rec(x,y-i);\n if (a[x,y-i]=2) then begin a[x,y]:=1; exit; end;\n end;\n t:=min(x,y);\n For i:=1 to t do\n begin\n if a[x-i,y-i]=0 then rec(x-i,y-i);\n if a[x-i,y-i]=2 then begin a[x,y]:=1; exit; end;\n end;\n a[x,y]:=2;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end."}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n if (a[x-i,y]=1) then begin a[x,y]:=2; exit; end\n else if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end\n else begin rec(x-i,y); a[x,y]:=(a[x-i,y] mod 2)+1; exit; end;\n For i:=1 to y do\n if a[x,y-i]=1 then begin a[x,y-i]:=2; exit; end\n else if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end\n else begin rec(x,y-i); a[x,y]:=(a[x,y-i] mod 2)+1; exit; end;\n t:=min(x,y);\n For i:=1 to t do\n if a[x-t,y-t]=2 then begin a[x-t,y-t]:=1; exit; end\n else if a[x-t,y-t]=1 then begin a[x-t,y-t]:=2; exit; end\n else begin rec(x-t,y-t); a[x,y]:=(a[x-t,y-t] mod 2)+1; exit; end;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n a[0,0]:=1;\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end.\n"}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end\n else begin rec(x-i,y); a[x,y]:=(a[x-i,y] mod 2)+1; exit; end;\n For i:=1 to y do\n if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end\n else begin rec(x,y-i); a[x,y]:=(a[x,y-i] mod 2)+1; exit; end;\n t:=min(x,y);\n For i:=1 to t do\n if a[x-t,y-t]=2 then begin a[x-t,y-t]:=1; exit; end\n else begin rec(x-t,y-t); a[x,y]:=(a[x-t,y-t] mod 2)+1; exit; end;\n a[x,y]:=2;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n a[0,0]:=1;\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end.\n"}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end\n else begin rec(x-i,y); if a[x-i,y]=2 then begin a[x,y]:=(a[x-i,y] mod 2)+1; exit; end; end;\n For i:=1 to y do\n if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end\n else begin rec(x,y-i); if a[x,y-i]=2 then begin a[x,y]:=(a[x,y-i] mod 2)+1; exit;end; end;\n t:=min(x,y);\n For i:=1 to t do\n if a[x-i,y-i]=2 then begin a[x-i,y-i]:=1; exit; end\n else\n begin\n rec(x-i,y-i);\n if a[x-i,y-i]=2 then\n begin\n a[x,y]:=(a[x-i,y-i] mod 2)+1;\n exit;\n end;\n end;\n a[x,y]:=2;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end.\n"}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n if (a[x-i,y]=1) then begin a[x,y]:=2; exit; end\n else if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end\n else begin rec(x-i,y); a[x,y]:=(a[x-i,y] mod 2)+1; exit; end;\n For i:=1 to y do\n if a[x,y-i]=1 then begin a[x,y-i]:=2; exit; end\n else if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end\n else begin rec(x,y-i); a[x,y]:=(a[x,y-i] mod 2)+1; exit; end;\n t:=min(x,y);\n For i:=1 to t do\n if a[x-i,y-i]=2 then begin a[x-i,y-i]:=1; exit; end\n else if a[x-i,y-i]=1 then begin a[x-i,y-i]:=2; exit; end\n else begin rec(x-i,y-i); a[x,y]:=(a[x-i,y-i] mod 2)+1; exit; end;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n a[0,0]:=1;\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end."}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end\n else begin rec(x-i,y); a[x,y]:=(a[x-i,y] mod 2)+1; exit; end;\n For i:=1 to y do\n if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end\n else begin rec(x,y-i); a[x,y]:=(a[x,y-i] mod 2)+1; exit; end;\n t:=min(x,y);\n For i:=1 to t do\n if a[x-i,y-i]=2 then begin a[x-i,y-i]:=1; exit; end\n else begin rec(x-i,y-i); a[x,y]:=(a[x-i,y-i] mod 2)+1; exit; end;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n a[0,0]:=1;\n rec(x,y);\n if a[x,y]=1 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end."}, {"source_code": "Uses math;\nVar n,x,y:LongInt;\n a:Array[0..400,0..400] of Longint;\nProcedure rec(x,y:LongInt);\nVar t,i:LongInt;\n begin\n For i:=1 to x do\n begin\n if a[x-i,y]=0 then rec(x-i,y);\n if (a[x-i,y]=2) then begin a[x,y]:=1; exit; end;\n end;\n For i:=1 to y do\n begin\n if a[x,y-i]=0 then rec(x,y-i);\n if (a[x,y-i]=2) then begin a[x,y-i]:=1; exit; end;\n end;\n t:=min(x,y);\n For i:=1 to t do\n begin\n if a[x-i,y-i]=0 then rec(x-i,y-i);\n if a[x-i,y-i]=2 then begin a[x-i,y-i]:=1; exit; end;\n end;\n a[x,y]:=2;\n end;\n begin\n Read(n);\n if n=2 then\n begin\n Read(x,y);\n rec(x,y);\n if a[x,y]=2 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end\n else if n=1 then begin read(x); if x>0 then WriteLn('BitAryo') else WriteLn('BitLGM'); end\n else\n begin\n Read(n,x,y);\n if (n xor x) xor y>0 then WriteLn('BitLGM')\n else WriteLn('BitAryo');\n end;\n end."}, {"source_code": "uses math;\nvar\ns:string;\ndp:array[0..301,0..301]of longint;\nst,m,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y)and(st=2) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n t:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n st:=n;\n n:=t;\n for i:=1 to n do\n a[i]:=b[i];\n if n=0 then writeln('BitAryo')\n else\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2])and(st=2) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n t:=0;\n m:=min(a[1],min(a[2],a[3]));\n b[1]:=a[1]-m;\n b[2]:=a[2]-m;\n b[3]:=a[3]-m;\n for i:=1 to 3 do\n if b[i]>0 then\n begin\n inc(t);\n b[t]:=b[i];\n end;\n if t=0 then writeln('BitLGM')\n else\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else\n begin\n if t>1 then\n begin\n if not win(b[1],b[2]) then writeln(s)\n else writeln('BitAryo');\n\n end\n else\n writeln('BitAryo');\n end;\n end;\n end;\n end.\n"}, {"source_code": "uses math;\nvar\ns:string;\ndp:array[0..301,0..301]of longint;\nm,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n t:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n n:=t;\n for i:=1 to n do\n a[i]:=b[i];\n if n=0 then writeln('BitAryo')\n else\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n m:=min(a[1],min(a[2],a[3]));\n a[1]:=a[1]-m;\n a[2]:=a[2]-m;\n a[3]:=a[3]-m;\n for i:=1 to 3 do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else\n begin\n if t>1 then\n begin\n if not win(b[1],b[2]) then writeln(s)\n else writeln('BitAryo');\n\n end\n else\n writeln('BitAryo');\n end;\n end;\n end;\n end.\n"}, {"source_code": "uses math;\nvar\ns:string;\ndp:array[0..301,0..301]of longint;\nm,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n m:=min(a[1],min(a[2],a[3]));\n a[1]:=a[1]-m;\n a[2]:=a[2]-m;\n a[3]:=a[3]-m;\n for i:=1 to 3 do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else\n begin\n if t>1 then\n begin\n if not win(b[1],b[2]) then writeln(s)\n else writeln('BitAryo');\n\n end\n else\n writeln('BitAryo');\n end;\n end;\n end;\n end.\n"}, {"source_code": "var\ns:string;\ndp:array[0..301,0..301]of longint;\nn,i:longint;\na:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else writeln('BitAryo');\n end;\n end;\n end.\n"}, {"source_code": "var\ns:string;\ndp:array[0..301,0..301]of longint;\nn,i:longint;\na:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else writeln('BitAryo');\n end;\n end;\n end.\n"}, {"source_code": "uses math;\nvar\ns:string;\ndp:array[0..301,0..301]of longint;\nm,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n t:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n n:=t;\n for i:=1 to n do\n a[i]:=b[i];\n if n=0 then writeln('BitAryo')\n else\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n t:=0;\n m:=min(a[1],min(a[2],a[3]));\n b[1]:=a[1]-m;\n b[2]:=a[2]-m;\n b[3]:=a[3]-m;\n for i:=1 to 3 do\n if b[i]>0 then\n begin\n inc(t);\n b[t]:=b[i];\n end;\n if t=0 then writeln('BitLGM')\n else\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else\n begin\n if t>1 then\n begin\n if not win(b[1],b[2]) then writeln(s)\n else writeln('BitAryo');\n\n end\n else\n writeln('BitAryo');\n end;\n end;\n end;\n end.\n"}, {"source_code": "var\ns:string;\ndp:array[0..301,0..301]of longint;\nn,i:longint;\na:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else writeln('BitAryo');\n end;\n end;\n end.\n"}, {"source_code": "uses math;\nvar\ns:string;\ndp:array[0..301,0..301]of longint;\nm,t,n,i:longint;\nb,a:array[0..10]of longint;\nfunction win(x,y:longint):boolean;\nvar u:longint;\ntmp:boolean;\nbegin\n if (x=0)and(y=0) then exit(false);\n if (x=y) then exit(true);\n if dp[x,y]=0 then\n begin\n tmp:=false;\n for u:=1 to 300 do\n begin\n if x>=u then\n begin\n if win(x-u,y)=false then tmp:=true;\n end;\n if y>=u then\n begin\n if win(x,y-u)=false then tmp:=true;\n end;\n end;\n if tmp then dp[x,y]:=1\n else dp[x,y]:=2;\n end;\n if dp[x,y]=1 then win:=true\n else win:=false;\nend;\n begin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n t:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n inc(t);\n b[t]:=a[i];\n end;\n n:=t;\n for i:=1 to n do\n a[i]:=b[i];\n if n=0 then writeln('BitAryo')\n else\n if n=1 then writeln('BitLGM')\n else\n begin\n if n=2 then\n begin\n if (a[1]=a[2]) then writeln('BitLGM')\n else if win(a[1],a[2]) then writeln('BitLGM')\n else writeln('BitAryo');\n end\n else\n begin\n s:='BitLGM';\n m:=min(a[1],min(a[2],a[3]));\n b[1]:=a[1]-m;\n b[2]:=a[2]-m;\n b[3]:=a[3]-m;\n for i:=1 to 3 do\n if b[i]>0 then\n begin\n inc(t);\n b[t]:=b[i];\n end;\n if t=0 then writeln('BitLGM')\n else\n if (a[1]=a[2])and(a[2]=a[3]) then writeln(s)\n else\n if not win(a[1],a[3]) then writeln(s)\n else if not win(a[1],a[2]) then writeln(s)\n else if not win(a[2],a[3]) then writeln(s)\n else\n begin\n if t>1 then\n begin\n if not win(b[1],b[2]) then writeln(s)\n else writeln('BitAryo');\n\n end\n else\n writeln('BitAryo');\n end;\n end;\n end;\n end.\n"}, {"source_code": "var n,i,j,k,l,ww,u,v,w:longint;\n a:array[0..3]of longint;\n f:array[0..300,0..300,0..300]of longint;\nfunction min(a,b:longint):longint;\n begin\n if a0 then \n for i:=0 to a[1] do\n for j:=0 to a[2] do\n for k:=0 to a[3] do\n if f[i,j,k]=0 then\n begin\n ww:=maxlongint;\n if a[1]<>0 then ww:=min(ww,a[1]-i);\n if a[2]<>0 then ww:=min(ww,a[2]-j);\n if a[3]<>0 then ww:=min(ww,a[3]-k);\n for l:=1 to a[1]-i do\n f[i+l,j,k]:=1;\n for l:=1to a[2]-j do\n f[i,j+l,k]:=1;\n for l:=1 to a[3]-k do\n f[i,j,k+l]:=1;\n for l:=1 to ww do\n begin\n u:=0;v:=0;w:=0;\n if a[1]<>0 then u:=i+l;\n if a[2]<>0 then v:=j+l;\n if a[3]<>0 then w:=k+l;\n f[u,v,w]:=1;\n end;\n end;\n if f[a[1],a[2],a[3]]=1 then\n writeln('BitLGM')\n else\n writeln('BitAryo');\n\n\nend.\n"}, {"source_code": "var n,i,j,k,l,ww,u,v,w:longint;\n a:array[0..3]of longint;\n f:array[0..300,0..300,0..300]of longint;\nfunction min(a,b:longint):longint;\n begin\n if a0 then\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n for k:=0 to a[3] do\n if f[i,j,k]=0 then\n begin\n ww:=maxlongint;\n if a[1]<>-1 then ww:=min(ww,a[1]-i);\n if a[2]<>-1 then ww:=min(ww,a[2]-j);\n if a[3]<>-1 then ww:=min(ww,a[3]-k);\n for l:=1 to a[1]-i do\n f[i+l,j,k]:=1;\n for l:=1to a[2]-j do\n f[i,j+l,k]:=1;\n for l:=1 to a[3]-k do\n f[i,j,k+l]:=1;\n for l:=1 to ww do\n begin\n u:=0;v:=0;w:=0;\n if a[1]<>-1 then u:=i+l;\n if a[2]<>-1 then v:=j+l;\n if a[3]<>-1 then w:=k+l;\n f[u,v,w]:=1;\n end;\n end;\n if f[a[1],a[2],a[3]]=1 then\n writeln('BitLGM')\n else\n writeln('BitAryo');\n\n\nend.\n"}, {"source_code": "program p1;\nuses math;\nvar n,i,j,k:integer;\na:array[0..3] of integer;\nwin:array[0..300,0..300] of integer;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[i]=0) and (n=1) then writeln('BitAryo');\n if (a[i]>0) and (n=1) then writeln('BitLGM');\n\n if n=3 then\n begin\n for i:=1 to n do n:=n xor a[i];\n if n>0 then writeln('BitLGM')\n else writeln('BitAryo');\n end;\n\n if n=2 then\n begin\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n for k:=1 to max(i,j)do\n if ((k<=i) and (win[i-k][j]=0)) or\n ((k<=j) and (win[i][j-k]=0)) or\n ((k<=i) and (k<=j) and (win[i-k][j-k]=0))\n then begin\n win[i][j]:=1;\n break;\n end;\n if (win[a[1]][a[2]]=1) then writeln('BitLGM')\n else writeln('BitAryo');\n end;\nend.\n\n"}, {"source_code": "uses math;\nvar\n a:array[1..3] of longint;\n i,j,n:longint;\n first,second:string;\n f,find:array[0..300,0..300] of boolean;\n\n\n\nprocedure print(s : string);\nbegin\n writeln(s);\n halt;\nend;\n\n\nfunction f_2(a,b:longint) : boolean;\nvar\n x,y,i:longint;\n can:boolean;\nbegin\n x:=min(a,b);\n y:=max(a,b);\n if find[x,y] then exit(f[x,y]);\n if (x = 0) then if y <> 0 then exit(true) else exit(false);\n if (x = y) then exit(true);\n can:=false;\n for i:=1 to x do if not(f_2(x - i,y-i)) then can:=true;\n for i:=1 to x do if not(f_2(x-i,y)) then can := true;\n for i:=1 to y do if not(f_2(x,y-i)) then can := true;\n find[x,y] := true;\n f[x,y] := can;\n f_2 := can;\nend;\n\nprocedure swap(var a,b:longint);\nvar\n c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do find[i,j] := false;\n for i:=0 to 300 do\n for j:=0 to 300 do f[i,j] := false;\n for i:=1 to 300 do f[0,i] := true;\n for i:=1 to 300 do f[i,0] := true;\n for i:=3 to 300 do f[1,i] := true;\n f[1,1] := true;\n f[1,2] := false;\n for i:=1 to 300 do find[0,i] := true;\n for i:=1 to 300 do find[i,0] := true;\n for i:=3 to 300 do find[1,i] := true;\n find[1,1] := true;\n find[1,2] := true;\n first:='BitLGM';\n second:='BitAryo';\n if n = 1 then if a[1] = 0 then print(second) else print(first);\n if n = 2 then if f_2(a[1],a[2]) then print(first) else print(second);\n for i:=1 to 2 do\n for j:=i+1 to 3 do if a[i] > a[j] then swap(a[i],a[j]);\n if a[1] = 0 then if f_2(a[2],a[3]) then print(first) else print(second);\n if (a[1] = a[2]) and (a[1] = a[3]) then print(first);\n if (a[1] xor a[2] xor a[3] = 0 ) then print(SECOND) else print(first);\nend.\n\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\n{$M 10000000}\nvar\n f:array [0..300,0..300] of byte;\n a:array [0..100] of longint;\n n,i,j,k:longint;\n function min(a,b:longint):longint; begin if ab then max:=a else max:=b; end;\n\n function rec(x,y:longint):longint;\n var\n ans:byte;\n i,kol,ko:longint;\n begin\n if f[x,y]<>2 then begin rec:=f[x,y]; exit; end;\n if (x=0) and (y=0) then begin rec:=0; exit; end;\n if ((x=0) and (y>0)) or ((x>0) and (y=0)) then begin rec:=1; exit; end;\n ko:=0;\n for i:=1 to min(x,y) do\n if rec(x-i,y-i)=0 then inc(ko);\n for i:=1 to max(x,y) do\n begin\n if (x>=i) and (rec(x-i,y)=0) then inc(ko);\n if (y>=i) and (rec(x,y-i)=0) then inc(ko);\n end;\n if ko>0 then ans:=1 else ans:=0;\n f[x,y]:=ans;\n rec:=ans;\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n if n=1 then begin if a[1]>0 then writeln('BitLGM') else writeln('BitAryo'); halt(0); end;\n if n=3 then begin if a[1] xor (a[2] xor a[3])=0 then writeln('BitLGM') else writeln('BitAryo'); halt(0); end;\n for i:=0 to 300 do\n for j:=0 to 300 do\n f[i,j]:=2;\n if rec(a[1],a[2])=1\n then writeln('BitLGM')\n else writeln('BitAryo');\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\n{$M 10000000}\nvar\n f:array [0..300,0..300,0..300] of byte;\n a:array [0..100] of longint;\n n,i,j,k:longint;\n function min(a,b:longint):longint; begin if ab then max:=a else max:=b; end;\n\n function rec(x,y,z:longint):longint;\n var\n ans:byte;\n kol,ko:longint;\n begin\n if y<0 then y:=0; if z<0 then z:=0;\n if f[x,y,z]<>2 then begin rec:=f[x,y,z]; exit; end;\n if (x=0) and (y=0) and (z=0) then begin rec:=0; exit; end;\n k:=x; if n>=2 then k:=min(k,y); if n=3 then k:=min(k,z);\n ko:=0; kol:=0;\n for i:=1 to k do\n begin\n kol:=kol+1;\n if rec(x-i,y-i,z-i)=1 then inc(ko);\n end;\n for i:=1 to max(x,max(y,z)) do\n begin\n if x>=i then begin inc(kol); if rec(x-i,y,z)=1 then inc(ko); end;\n if y>=i then begin inc(kol); if rec(x,y-i,z)=1 then inc(ko); end;\n if z>=i then begin inc(kol); if rec(x,y,z-i)=1 then inc(ko); end;\n end;\n ans:=0;\n if (ko0) then ans:=1;\n f[x,y,z]:=ans;\n rec:=ans;\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to 3 do a[i]:=0;\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do\n for k:=0 to 300 do\n f[i,j,k]:=2;\n if rec(a[1],a[2],a[3])=1\n then writeln('BitLGM')\n else writeln('BitAryo');\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\n{$M 10000000}\nvar\n f:array [0..300,0..300,0..300] of byte;\n a:array [0..100] of longint;\n n,i,j,k:longint;\n function min(a,b:longint):longint; begin if ab then max:=a else max:=b; end;\n\n function rec(x,y,z:longint):longint;\n var\n ans:byte;\n kol,ko:longint;\n begin\n if y<0 then y:=0; if z<0 then z:=0;\n if f[x,y,z]<>2 then begin rec:=f[x,y,z]; exit; end;\n if (x=0) and (y=0) and (z=0) then begin rec:=0; exit; end;\n k:=x; if n>=2 then k:=min(k,y); if n=3 then k:=min(k,z);\n ko:=0; kol:=0;\n for i:=1 to k do\n begin\n kol:=kol+1;\n if rec(x-i,y-i,z-i)=1 then inc(ko);\n end;\n for i:=1 to max(x,max(y,z)) do\n begin\n if x>=i then begin inc(kol); if rec(x-i,y,z)=1 then inc(ko); end;\n if y>=i then begin inc(kol); if rec(x,y-i,z)=1 then inc(ko); end;\n if z>=i then begin inc(kol); if rec(x,y,z-i)=1 then inc(ko); end;\n end;\n ans:=0;\n if (ko0) then ans:=1;\n f[x,y,z]:=ans;\n rec:=ans;\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to 3 do a[i]:=0;\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do\n for k:=0 to 300 do\n f[i,j,k]:=2;\n rec(a[1],a[2],a[3]);\n if f[a[1],a[2],a[3]]=1\n then writeln('BitLGM')\n else writeln('BitAryo');\nend.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\n{$M 10000000}\nvar\n f:array [0..300,0..300,0..300] of byte;\n a:array [0..100] of longint;\n n,i,j,k:longint;\n function min(a,b:longint):longint; begin if ab then max:=a else max:=b; end;\n\n function rec(x,y,z:longint):longint;\n var\n ans:byte;\n i,kol,ko:longint;\n begin\n if y<0 then y:=0; if z<0 then z:=0;\n if f[x,y,z]<>2 then begin rec:=f[x,y,z]; exit; end;\n if (x=0) and (y=0) and (z=0) then begin rec:=0; exit; end;\n k:=0;\n if (x<>0) and (n>=1) then inc(k);\n if (y<>0) and (n>=2) then inc(k);\n if (z<>0) and (n>=3) then inc(k);\n if (k=1) then begin rec:=1; exit; end;\n k:=x; if n>=2 then k:=min(k,y); if n=3 then k:=min(k,z);\n ko:=0; kol:=0;\n for i:=1 to k do\n begin\n kol:=kol+1;\n if rec(x-i,y-i,z-i)=1 then inc(ko);\n end;\n for i:=1 to max(x,max(y,z)) do\n begin\n if x>=i then begin inc(kol); if rec(x-i,y,z)=1 then inc(ko); end;\n if y>=i then begin inc(kol); if rec(x,y-i,z)=1 then inc(ko); end;\n if z>=i then begin inc(kol); if rec(x,y,z-i)=1 then inc(ko); end;\n end;\n ans:=0;\n if (ko>0) and (kol>0) then ans:=1;\n f[x,y,z]:=ans;\n rec:=ans;\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to 3 do a[i]:=0;\n for i:=1 to n do read(a[i]);\n for i:=0 to 300 do\n for j:=0 to 300 do\n for k:=0 to 300 do\n f[i,j,k]:=2;\n if rec(a[1],a[2],a[3])=1\n then writeln('BitLGM')\n else writeln('BitAryo');\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n if a[1]>=4 then wr (1);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\n\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (i,j:longint);\nvar x:longint;\nbegin\n x:=a[i];a[i]:=a[j];a[j]:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]>=3) then wr (0);\n wr (1);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (i,j:longint);\nvar x:longint;\nbegin\n x:=a[i];a[i]:=a[j];a[j]:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]>=3) and (a[1] mod 2=1) and (a[2]=a[1]+1) then wr (0);\n wr (1);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) then wr (0);\nwr (1);\nend."}, {"source_code": "uses math;\nvar a:array [0..3000000] of longint;\n i,j,x,n,o:longint;ans:longint;\n s1,s2:ansistring;\nprocedure swap (var i,j:longint);\nvar x:longint;\nbegin\n x:=i;i:=j;j:=x;\nend;\nprocedure qsort (l,r:longint);\nvar i,j,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while x>a[i] do inc (i);\n while xj;\n if ia[2] then swap (a[1],a[2]);\n if (a[1]=0) and (a[2]=0) then\n wr (0);\n if (a[1]=1) and (a[2]=2) then wr (0);\n if (a[1]<=2) then wr (1);\n if (a[2]-a[1]<=1) then wr (1);\n wr (0);\n end;\nif (a[1]+a[2]+a[3]=0) then wr (0);\nqsort (1,3);\nif (a[1]=0) and (a[2]=1) and (a[3]=1) then wr (0);\nif (a[1]=0) and (a[2]>=2) and (a[3]<>a[2]) then wr (0);\nwr (1);\nend."}, {"source_code": "var f2:array[0..301,0..301] of longint;\n f3:array[0..301,0..301,0..301] of longint;\n maxx:array[0..333,0..333] of longint;\n minn:array[0..333,0..333] of longint;\n n,m,i,j,k:longint;\n a:array[0..40] of longint;\n first,second:string;\n\nfunction min(a,b:longint):longint;\nbegin\n if aB then max:=a else max:=b;\nend;\n\nprocedure two;\nvar i,j,k:longint;\nbegin\n for i:= 0 to 300 do\n for j:= 0 to 300 do\n begin\n if (i=0) and (j=0) then f2[i][j]:=0 else\n begin\n for k:= 1 to maxx[i,j] do\n begin\n if (i>=k) and (j>=k) and (f2[i-k][j-k] = 0) then f2[i][j]:=1;\n if (i>=k) and (f2[i-k][j] = 0) then f2[i][j]:=1;\n if (j>=k) and (f2[i][j-k] = 0) then f2[i][j]:=1;\n end;\n end;\n end;\nend;\n\nprocedure swap(var t,y:longint);\nvar u:longint;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure three;\nvar i,j,k,t:longint;\n used:boolean;\nbegin\n for i:= 0 to 300 do\n for j:= i to 300 do\n for k:= j to 300 do\n begin\n used:=false;\n for t:= 1 to i do\n if f3[i-t][j-t][k-t] = 0 then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n for t:= 1 to maxx[maxx[i,j],k] do\n if (i>=t) and (f3[i-t][j][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (j>=t) and (f3[minn[i,j-t]][maxx[i,j-t]][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (k>=t) and (f3[minn[i,k-t]][minn[j,k-t]][maxx[k,k-t]]=0) then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n end;\nend;\n\n\nbegin\n first:='BitLGM';\n second:='BitAryo';\n readln(n);\n for i:= 1 to n do read(a[i]);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n maxx[i][j]:=max(i,j);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n minn[i][j]:=min(i,j);\n if n = 1 then\n begin\n if a[i]=0 then writeln(second) else writeln(first);\n halt;\n end;\n two;\n if n = 2 then\n begin\n if f2[a[1],a[2]]=1 then writeln(first) else writeln(second);\n halt;\n end;\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n three;\n if f3[a[1],a[2],a[3]]=1 then writeln(first) else writeln(second);\nend.\n"}, {"source_code": "var f2:array[0..301,0..301] of longint;\n f3:array[0..301,0..301,0..301] of longint;\n maxx:array[0..333,0..333] of longint;\n minn:array[0..333,0..333] of longint;\n n,m,i,j,k,q1,q2,q3:longint;\n a:array[0..40] of longint;\n first,second:string;\n\nfunction min(a,b:longint):longint;\nbegin\n if aB then max:=a else max:=b;\nend;\n\nprocedure two;\nvar i,j,k:longint;\nbegin\n for i:= 0 to 300 do\n for j:= 0 to 300 do\n begin\n if (i=0) and (j=0) then f2[i][j]:=0 else\n begin\n for k:= 1 to maxx[i,j] do\n begin\n if (i>=k) and (j>=k) and (f2[i-k][j-k] = 0) then f2[i][j]:=1;\n if (i>=k) and (f2[i-k][j] = 0) then f2[i][j]:=1;\n if (j>=k) and (f2[i][j-k] = 0) then f2[i][j]:=1;\n end;\n end;\n end;\nend;\n\nprocedure swap(var t,y:longint);\nvar u:longint;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure three;\nvar i,j,k,t:longint;\n used:boolean;\nbegin\n for i:= 0 to 300 do\n for j:= i to 300 do\n for k:= j to 300 do\n begin\n \n used:=false;\n for t:= 1 to i do\n if f3[i-t][j-t][k-t] = 0 then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n { for t:= 1 to maxx[maxx[i,j],k] do\n if (i>=t) and (f3[i-t][j][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (j>=t) and (f3[minn[i,j-t]][maxx[i,j-t]][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (k>=t) then\n begin\n q1:=i;\n q2:=j;\n q3:=k-t;\n if (q2>q3) then swap(q2,q3);\n if (q1>q2) then swap(q1,q2);\n if f3[q1][q2][q3]=0 then\n begin\n used:=true;\n break;\n end;\n end;}\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n end;\nend;\n\n\nbegin\n first:='BitLGM';\n second:='BitAryo';\n readln(n);\n for i:= 1 to n do read(a[i]);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n maxx[i][j]:=max(i,j);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n minn[i][j]:=min(i,j);\n if n = 1 then\n begin\n if a[1]=0 then writeln(second) else writeln(first);\n halt;\n end;\n two;\n if n = 2 then\n begin\n if f2[a[1],a[2]]=1 then writeln(first) else writeln(second);\n halt;\n end;\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n three;\n if f3[a[1],a[2],a[3]]=1 then writeln(first) else writeln(second);\nend."}, {"source_code": "var f2:array[0..301,0..301] of longint;\n f3:array[0..301,0..301,0..301] of longint;\n maxx:array[0..333,0..333] of longint;\n minn:array[0..333,0..333] of longint;\n n,m,i,j,k,q1,q2,q3:longint;\n a:array[0..40] of longint;\n first,second:string;\n\nfunction min(a,b:longint):longint;\nbegin\n if aB then max:=a else max:=b;\nend;\n\nprocedure two;\nvar i,j,k:longint;\nbegin\n for i:= 0 to 300 do\n for j:= 0 to 300 do\n begin\n if (i=0) and (j=0) then f2[i][j]:=0 else\n begin\n for k:= 1 to maxx[i,j] do\n begin\n if (i>=k) and (j>=k) and (f2[i-k][j-k] = 0) then f2[i][j]:=1;\n if (i>=k) and (f2[i-k][j] = 0) then f2[i][j]:=1;\n if (j>=k) and (f2[i][j-k] = 0) then f2[i][j]:=1;\n end;\n end;\n end;\nend;\n\nprocedure swap(var t,y:longint);\nvar u:longint;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure three;\nvar i,j,k,t:longint;\n used:boolean;\nbegin\n for i:= 0 to 300 do\n for j:= i to 300 do\n for k:= j to 300 do\n begin\n if (i=j) or (i=k) or (j=k) then\n begin\n f3[i][j][k]:=1;\n continue; \n end;\n used:=false;\n for t:= 1 to i do\n if f3[i-t][j-t][k-t] = 0 then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n { for t:= 1 to maxx[maxx[i,j],k] do\n if (i>=t) and (f3[i-t][j][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (j>=t) and (f3[minn[i,j-t]][maxx[i,j-t]][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (k>=t) then\n begin\n q1:=i;\n q2:=j;\n q3:=k-t;\n if (q2>q3) then swap(q2,q3);\n if (q1>q2) then swap(q1,q2);\n if f3[q1][q2][q3]=0 then\n begin\n used:=true;\n break;\n end;\n end;}\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n end;\nend;\n\n\nbegin\n first:='BitLGM';\n second:='BitAryo';\n readln(n);\n for i:= 1 to n do read(a[i]);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n maxx[i][j]:=max(i,j);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n minn[i][j]:=min(i,j);\n if n = 1 then\n begin\n if a[1]=0 then writeln(second) else writeln(first);\n halt;\n end;\n two;\n if n = 2 then\n begin\n if f2[a[1],a[2]]=1 then writeln(first) else writeln(second);\n halt;\n end;\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n three;\n if f3[a[1],a[2],a[3]]=1 then writeln(first) else writeln(second);\nend."}, {"source_code": "var f2:array[0..301,0..301] of longint;\n f3:array[0..301,0..301,0..301] of longint;\n maxx:array[0..333,0..333] of longint;\n minn:array[0..333,0..333] of longint;\n n,m,i,j,k:longint;\n a:array[0..40] of longint;\n first,second:string;\n\nfunction min(a,b:longint):longint;\nbegin\n if aB then max:=a else max:=b;\nend;\n\nprocedure two;\nvar i,j,k:longint;\nbegin\n for i:= 0 to 300 do\n for j:= 0 to 300 do\n begin\n if (i=0) and (j=0) then f2[i][j]:=0 else\n begin\n for k:= 1 to maxx[i,j] do\n begin\n if (i>=k) and (j>=k) and (f2[i-k][j-k] = 0) then f2[i][j]:=1;\n if (i>=k) and (f2[i-k][j] = 0) then f2[i][j]:=1;\n if (j>=k) and (f2[i][j-k] = 0) then f2[i][j]:=1;\n end;\n end;\n end;\nend;\n\nprocedure swap(var t,y:longint);\nvar u:longint;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure three;\nvar i,j,k,t:longint;\n used:boolean;\nbegin\n for i:= 0 to 300 do\n for j:= i to 300 do\n for k:= j to 300 do\n begin\n used:=false;\n for t:= 1 to i do\n if f3[i-t][j-t][k-t] = 0 then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n for t:= 1 to maxx[maxx[i,j],k] do\n if (i>=t) and (f3[i-t][j][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (j>=t) and (f3[minn[i,j-t]][maxx[i,j-t]][k]=0) then\n begin\n used:=true;\n break;\n end else\n if (k>=t) and (f3[minn[i,k-t]][minn[j,k-t]][maxx[k,k-t]]=0) then\n begin\n used:=true;\n break;\n end;\n if used then\n begin\n f3[i][j][k]:=1;\n continue;\n end;\n end;\nend;\n\n\nbegin\n first:='BitLGM';\n second:='BitAryo';\n readln(n);\n for i:= 1 to n do read(a[i]);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n maxx[i][j]:=max(i,j);\n for i:= 0 to 333 do\n for j:= 0 to 333 do\n minn[i][j]:=min(i,j);\n if n = 1 then\n begin\n if a[1]=0 then writeln(second) else writeln(first);\n halt;\n end;\n two;\n if n = 2 then\n begin\n if f2[a[1],a[2]]=1 then writeln(first) else writeln(second);\n halt;\n end;\n if a[1]>a[2] then swap(a[1],a[2]);\n if a[2]>a[3] then swap(a[2],a[3]);\n if a[1]>a[2] then swap(a[1],a[2]);\n three;\n if f3[a[1],a[2],a[3]]=1 then writeln(first) else writeln(second);\nend.\n"}, {"source_code": "Uses math;\nVar m:array [0..300,0..300] of boolean;\nrez:array [1..10000] of Boolean;\nm1:array [0..300,0..300,0..300] of boolean;\nc,i1,kol,n,z,a,b,i,j:LongInt;\nf:boolean;\nprocedure probeg(a,b:longint);\nbegin\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n Halt(0);\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n readln(n);\n if n=1\n then begin\n read(a);\n if a<>0\n then writeln('BitLGM')\n else writeln('BitAryo');\n Halt(0);\n end;\n if n=2\n then begin\n Readln(a,b);\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n end\n else begin\n readln(a,b,c);\n if c=0\n then probeg(a,b);\n if b=0\n then probeg(a,c);\n if a=0\n then probeg(b,c);\n if (a=b)or(b=c)or(a=c)\n then begin Writeln('BitLGM'); halt(0); end;\n if (a<=b)and(a<=c)\n then begin\n if abs(b-c)=a\n then writeln('BitAryo')\n else Writeln('BitLGM');\n halt(0);\n end;\n if (b<=c)and(b<=a)\n then begin\n if Abs(a-c)=b\n then writeln('BitAryo')\n else Writeln('BitLGM');\n halt(0);\n end;\n if (c<=a)and(c<=b)\n then begin\n if Abs(a-b)=c\n then writeln('BitAryo')\n else Writeln('BitLGM');\n halt(0);\n end;\n{ m1[0,0,0]:=false;\n for i:=0 to a do\n for j:=0 to b do\n for i1:=0 to c do\n begin\n f:=false;\n for z:=1 to min(i,min(j,i1)) do\n if not m1[i-z,j-z,i1-z]\n then f:=true;\n for z:=1 to i do\n if not m1[i-z,j,i1]\n then f:=true;\n for z:=1 to j do\n if not m1[i,j-z,i1]\n then f:=true;\n for z:=1 to i1 do\n if not m1[i,j,i1-z]\n then f:=true;\n m1[i,j,i1]:=f;\n end;\n for i:=1 to a do\n for j:=1 to b do\n for i1:=1 to c do\n if not m1[i,j,i1]\n then writeln(i,' ',j,' ',i1);}\n end;\nend."}, {"source_code": "Uses math;\n//const zz:array [1..3,1..11785] of longint=();\nVar m:array [0..300,0..300] of boolean;\nzz:array[1..300] of longint;\nrez:array [1..10000] of Boolean;\nm1:array [0..300,0..300,0..300] of boolean;\nused:array [0..300,0..300,0..300] of Boolean;\nc,i1,kol,n,z,a,b,i,j:LongInt;\nf:boolean;\nprocedure swap(var a,b:longint);\nvar x:longint;\nbegin\n x:=a; a:=b; b:=x;\nend;\nfunction probeg2(a,b,c:longint):boolean;\nVar i:longint;\nbegin\n if used[a,b,c]\n then begin probeg2:=m1[a,b,c]; Exit; end;\n used[a,b,c]:=true;\n used[b,c,a]:=true;\n used[a,c,b]:=true;\n used[b,a,c]:=True;\n used[c,a,b]:=true;\n used[c,b,a]:=true;\n m1[a,b,c]:=False;\n for i:=min(a,Min(b,c)) downto 1 do\n if not probeg2(a-i,b-i,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n\n for i:=a downto 1 do\n if not probeg2(a-i,b,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=b downto 1 do\n if not probeg2(a,b-i,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=c downto 1 do\n if not probeg2(a,b,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n probeg2:=false;\nend;\nprocedure probeg(a,b:longint);\nbegin\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n Halt(0);\nend;\nfunction stepen(x:longint):boolean;\nbegin\n while x>1 do\n begin\n if x mod 2=1\n then begin stepen:=false; exit; end;\n x:=x div 2;\n end;\n stepen:=true;\nend;\nprocedure zapoln(a,b,c:longint);\nbegin\n m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n readln(n);\n if n=1\n then begin\n read(a);\n if a<>0\n then writeln('BitLGM')\n else writeln('BitAryo');\n Halt(0);\n end;\n if n=2\n then begin\n Readln(a,b);\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n end\n else begin\n readln(a,b,c);\n if c=0\n then probeg(a,b);\n if b=0\n then probeg(a,c);\n if a=0\n then probeg(b,c);\n if (a=b)or(b=c)or(a=c)\n then begin Writeln('BitLGM'); halt(0); end;\n m1[0,0,0]:=false;\n used[0,0,0]:=true;\n for i:=0 to 300 do\n for j:=0 to 300 do\n for i1:=0 to 300 do\n begin\n if not used[i,j,i1]\n then begin\n //m1[i,j,i1]:=probeg2(i,j,i1);\n if m1[a,b,c]=False\n then begin\n for z:=300-Max(i,Max(j,i1)) downto 1 do\n zapoln(i+z,j+z,i1+z);\n for z:=i+1 to 300 do\n zapoln(z,j,i1);\n for z:=j+1 to 300 do\n zapoln(i,z,i1);\n for z:=j+1 to 300 do\n zapoln(i,z,i1);\n end;\n end; \n end;\n if not m1[a,b,c]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n{ m1[0,0,0]:=false;\n for i:=0 to a do\n for j:=0 to b do\n for i1:=0 to c do\n begin\n f:=false;\n for z:=1 to min(i,min(j,i1)) do\n if not m1[i-z,j-z,i1-z]\n then f:=true;\n for z:=1 to i do\n if not m1[i-z,j,i1]\n then f:=true;\n for z:=1 to j do\n if not m1[i,j-z,i1]\n then f:=true;\n for z:=1 to i1 do\n if not m1[i,j,i1-z]\n then f:=true;\n m1[i,j,i1]:=f;\n end;\n for i:=1 to a do\n begin\n f:=false;\n for j:=i to b do\n for i1:=j to c do\n if not m1[i,j,i1]\n then writeln(i,' ',j,' ',i1,',');\n end;}\n end;\nend."}, {"source_code": "Uses math;\n//const zz:array [1..3,1..11785] of longint=();\nVar m:array [0..300,0..300] of boolean;\nzz:array[1..300] of longint;\nrez:array [1..10000] of Boolean;\nm1:array [0..300,0..300,0..300] of boolean;\nused:array [0..300,0..300,0..300] of Boolean;\nc,i1,kol,n,z,a,b,i,j:LongInt;\nf:boolean;\nprocedure swap(var a,b:longint);\nvar x:longint;\nbegin\n x:=a; a:=b; b:=x;\nend;\nfunction probeg2(a,b,c:longint):boolean;\nVar i:longint;\nbegin\n if used[a,b,c]\n then begin probeg2:=m1[a,b,c]; Exit; end;\n used[a,b,c]:=true;\n used[b,c,a]:=true;\n used[a,c,b]:=true;\n used[b,a,c]:=True;\n used[c,a,b]:=true;\n used[c,b,a]:=true;\n m1[a,b,c]:=False;\n for i:=min(a,Min(b,c)) downto 1 do\n if not probeg2(a-i,b-i,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n\n for i:=a downto 1 do\n if not probeg2(a-i,b,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=b downto 1 do\n if not probeg2(a,b-i,c)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n for i:=c downto 1 do\n if not probeg2(a,b,c-i)\n then begin m1[a,b,c]:=true; used[a,b,c]:=true;\n m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;\n probeg2:=true; exit; end;\n probeg2:=false;\nend;\nprocedure probeg(a,b:longint);\nbegin\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n Halt(0);\nend;\nfunction stepen(x:longint):boolean;\nbegin\n while x>1 do\n begin\n if x mod 2=1\n then begin stepen:=false; exit; end;\n x:=x div 2;\n end;\n stepen:=true;\nend;\nprocedure zapoln(a,b,c:longint);\nbegin\n m1[a,b,c]:=true; used[a,b,c]:=true;\n{ m1[b,c,a]:=true; used[b,c,a]:=true;\n m1[a,c,b]:=true; used[a,c,b]:=true;\n m1[b,a,c]:=true; used[b,a,c]:=True;\n m1[c,a,b]:=true; used[c,a,b]:=true;\n m1[c,b,a]:=true; used[c,b,a]:=true;}\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n);\n if n=1\n then begin\n read(a);\n if a<>0\n then writeln('BitLGM')\n else writeln('BitAryo');\n Halt(0);\n end;\n if n=2\n then begin\n Readln(a,b);\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n end\n else begin\n readln(a,b,c);\n if c=0\n then probeg(a,b);\n if b=0\n then probeg(a,c);\n if a=0\n then probeg(b,c);\n if (a=b)or(b=c)or(a=c)\n then begin Writeln('BitLGM'); halt(0); end;\n for i:=0 to 300 do\n for j:=0 to 300 do\n for i1:=0 to 300 do\n begin\n if not used[i,j,i1]\n then begin\n m1[i,j,i1]:=False;\n used[i,j,i1]:=true;\n for z:=300-Max(i,Max(j,i1)) downto 1 do\n zapoln(i+z,j+z,i1+z);\n for z:=i+1 to 300 do\n zapoln(z,j,i1);\n for z:=j+1 to 300 do\n zapoln(i,z,i1);\n for z:=i1+1 to 300 do\n zapoln(i,j,z);\n end;\n end;\n if not m1[a,b,c]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n{ m1[0,0,0]:=false;\n for i:=0 to a do\n for j:=0 to b do\n for i1:=0 to c do\n begin\n f:=false;\n for z:=1 to min(i,min(j,i1)) do\n if not m1[i-z,j-z,i1-z]\n then f:=true;\n for z:=1 to i do\n if not m1[i-z,j,i1]\n then f:=true;\n for z:=1 to j do\n if not m1[i,j-z,i1]\n then f:=true;\n for z:=1 to i1 do\n if not m1[i,j,i1-z]\n then f:=true;\n m1[i,j,i1]:=f;\n end;\n for i:=1 to a do\n begin\n f:=false;\n for j:=i to b do\n for i1:=j to c do\n if not m1[i,j,i1]\n then writeln(i,' ',j,' ',i1,',');\n end;}\n end;\nend."}, {"source_code": "Uses math;\nconst zz:array [1..300] of longint=(0,0,1,0,3,2,5,0,7,6,9,4,11,10,13,0,15,14,17,12,19,18,21,8,23,22,25,20,27,26,29,0,31,30,33,28,35,34,37,24,39,38,41,36,43,42,45,16,47,46,49,44,51,50,53,40,55,54,57,52,59,58,61,0,63,62,65,60,67,66,69,56,71,70,73,68,75,74,77,48,79,78,81,76,83,82,85,72,87,86,89,84,91,90,93,32,95,94,97,92,99,98,101,88,103,102,105,100,107,106,109,80,111,110,113,108,115,114,117,104,119,118,121,116,123,122,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);\nVar m:array [0..300,0..300] of boolean;\nrez:array [1..10000] of Boolean;\nm1:array [0..300,0..300,0..300] of boolean;\nc,i1,kol,n,z,a,b,i,j:LongInt;\nf:boolean;\nprocedure swap(var a,b:longint);\nvar x:longint;\nbegin\n x:=a; a:=b; b:=x;\nend;\nprocedure probeg(a,b:longint);\nbegin\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n Halt(0);\nend;\nfunction stepen(x:longint):boolean;\nbegin\n while x>1 do\n begin\n if x mod 2=1\n then begin stepen:=false; exit; end;\n x:=x div 2;\n end;\n stepen:=true;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n);\n if n=1\n then begin\n read(a);\n if a<>0\n then writeln('BitLGM')\n else writeln('BitAryo');\n Halt(0);\n end;\n if n=2\n then begin\n Readln(a,b);\n if (a=0)and(b=0)\n then begin writeln('BitAryo'); Halt(0); end;\n if (a=0)or(b=0)\n then begin writeln('BitLGM'); Halt(0); end;\n if a=b\n then begin writeln('BitLGM'); Halt(0); end;\n kol:=0;\n FillChar(m,SizeOf(m),true);\n for i:=1 to 300 do\n begin\n if not rez[i]\n then begin\n Inc(kol);\n if i+kol>300\n then Break;\n m[i,i+kol]:=false;\n m[i+kol,i]:=false;\n rez[i]:=true;\n rez[i+kol]:=true;\n end;\n end;\n if not m[a,b]\n then writeln('BitAryo')\n else Writeln('BitLGM');\n end\n else begin\n readln(a,b,c);\n if c=0\n then probeg(a,b);\n if b=0\n then probeg(a,c);\n if a=0\n then probeg(b,c);\n if (a=b)or(b=c)or(a=c)\n then begin Writeln('BitLGM'); halt(0); end;\n if a>b\n then Swap(a,b);\n if b>c\n then Swap(b,c);\n if a>b\n then swap(a,b);\n if abs(b-c)=a\n then begin writeln('BitAryo'); Halt(0); end;\n if (stepen(a))or(a>298)\n then begin Writeln('BitLGM'); halt(0); end;\n kol:=zz[a];\n{ for i:=3 to a do\n begin\n if not stepen(i)\n then inc(kol);\n end;}\n if b+kol=c\n then writeln('BitAryo')\n else Writeln('BitLGM');\n{ m1[0,0,0]:=false;\n for i:=0 to a do\n for j:=0 to b do\n for i1:=0 to c do\n begin\n f:=false;\n for z:=1 to min(i,min(j,i1)) do\n if not m1[i-z,j-z,i1-z]\n then f:=true;\n for z:=1 to i do\n if not m1[i-z,j,i1]\n then f:=true;\n for z:=1 to j do\n if not m1[i,j-z,i1]\n then f:=true;\n for z:=1 to i1 do\n if not m1[i,j,i1-z]\n then f:=true;\n m1[i,j,i1]:=f;\n end;\n for i:=1 to a do\n begin\n f:=false;\n for j:=i to b do\n for i1:=j to c do\n if (not m1[i,j,i1])and(i1-j<>i)and (not f)\n then begin writeln(i,' ',j,' ',i1);zz[i]:=i1-j; f:=true; Break; end;\n end;\n for i:=1 to 300 do\n write(zz[i],',');}\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n i, j, k, n: integer;\n a: array[1..100] of integer;\n f: array[0..300, 0..300, 0..300] of integer;\n\nfunction get(x1, x2, x3: integer): integer;\nvar\n i: integer;\n mex: array[0..1] of boolean;\nbegin\n if (f[x1][x2][x3] = -1) then begin\n for i := 1 to x1 do begin\n if (mex[0]) then\n break;\n mex[get(x1 - i, x2, x3)] := true; \n end;\n\n for i := 1 to x2 do begin\n if (mex[0]) then\n break;\n mex[get(x1, x2 - i, x3)] := true; \n end;\n\n for i := 1 to x3 do begin\n if (mex[0]) then\n break;\n mex[get(x1, x2, x3 - i)] := true;\n end;\n\n for i := 1 to min(min(x1, x2), x3) do begin\n if (mex[0]) then\n break;\n mex[get(x1 - i, x2 - i, x3 - i)] := true; \n end;\n\n if (mex[0] = false) then\n result := 0\n else\n result := 1;\n\n f[x1][x2][x3] := result;\n f[x1][x3][x2] := result;\n f[x2][x1][x3] := result;\n f[x2][x3][x1] := result;\n f[x3][x1][x2] := result;\n f[x3][x2][x1] := result;\n end else begin\n result := f[x1][x2][x3];\n end;\nend;\n\nfunction get1(x1, x2: integer): integer;\nvar\n i: integer;\n mex: array[0..1] of boolean;\nbegin\n if (f[x1][x2][0] = -1) then begin\n for i := 0 to 1 do\n mex[i] := false;\n for i := 1 to x1 do begin\n mex[get1(x1 - i, x2)] := true;\n end;\n\n for i := 1 to x2 do begin\n mex[get1(x1, x2 - i)] := true;\n end;\n\n for i := 1 to min(x1, x2) do begin\n mex[get1(x1 - i, x2 - i)] := true;\n end;\n\n if (mex[0] = false) then\n result := 0\n else\n result := 1;\n f[x1][x2][0] := result;\n f[x2][x1][0] := result;\n end else begin\n result := f[x1][x2][0];\n end;\nend;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(n);\n\n for i := 1 to n do begin\n read(a[i]);\n end;\n\n for i := 0 to a[1] do\n for j := 0 to a[2] do\n for k := 0 to a[3] do\n f[i][j][k] := -1;\n\n if (n = 1) then begin\n if (a[1] = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n halt;\n end;\n\n if (n = 2) then begin\n if (get1(a[1], a[2]) = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n halt;\n end;\n\n if (get(a[1], a[2], a[3]) = 0) then\n writeln('BitAryo')\n else\n writeln('BitLGM');\n\n\n{ for i := 1 to 10 do begin\n writeln(i);\n for j := 1 to 10 do begin\n for k := 1 to 10 do begin\n write((((3* i) xor (3 * j) xor (3 * k)) > 0) and (get(i, j, k) = 1));\n writeln(i, ' ', j, ' ', k);\n end;\n writeln;\n end;\n writeln;\n end;}\nend."}, {"source_code": "{$R-,S-,Q-,I-,O-}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nn,i,j,k : longint;\nok : boolean;\na : array [1..3] of longint;\ndp : array [0..333,0..333] of boolean;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n if n = 1 then\n begin\n if a[1] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\n halt;\n end;\n if n = 2 then\n begin\n fillchar(dp,sizeof(dp),true);\n dp[0][0]:=false;\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n if not((i = 0) and (j = 0)) then\n begin\n ok:=false;\n if not dp[i - min(i,j),j - min(i,j)] then ok:=true;\n for k:=1 to i do\n if not dp[i - k,j] then ok:=true;\n for k:=1 to j do\n if not dp[i,j - k] then ok:=true;\n dp[i,j]:=ok;\n end;\n if dp[a[1],a[2]] then writeln('BitLGM')\n else writeln('BitAryo');\n halt;\n end;\n\n if a[1] xor a[2] xor a[3] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\nend.\n\n"}, {"source_code": "{$R-,S-,Q-,I-,O-}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nn,i,j,k : longint;\nok : boolean;\na : array [1..3] of longint;\ndp : array [0..333,0..333] of boolean;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n if n = 1 then\n begin\n if a[1] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\n halt;\n end;\n if n = 2 then\n begin\n fillchar(dp,sizeof(dp),true);\n dp[0][0]:=false;\n for i:=0 to a[1] do\n for j:=0 to a[2] do\n if not((i = 0) and (j = 0)) then\n begin\n ok:=false;\n if not dp[i - min(i,j),j - min(i,j)] then ok:=true;\n for k:=1 to a[1] do\n if not dp[i - k,j] then ok:=true;\n for k:=1 to a[2] do\n if not dp[i,j - k] then ok:=true;\n dp[i,j]:=ok;\n end;\n if dp[a[1],a[2]] then writeln('BitLGM')\n else writeln('BitAryo');\n halt;\n end;\n\n if a[1] xor a[2] xor a[3] = 0 then writeln('BitAryo')\n else writeln('BitLGM');\nend.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='d.in';\n file2='d.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n a:array[0..331,0..331,0..331]of byte;\n y,x,ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n s,s0,s1,s2:string;\n sss:ansistring;\n z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n read(n);\n for i:=1 to n do read(qc[i]);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('BitLGM') else writeln('BitAryo');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n res:=0;\n if n=1 then\n begin\n res:=1;\n if qc[1]=0 then res:=2;\n end;\n if n=2 then\n begin\n if abs(qc[1]-qc[2])=1 then res:=2 else res:=1;\n if qc[1]+qc[2]<=1 then res:=1;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,k,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='d.in';\n file2='d.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n a:array[0..331,0..331,0..331]of byte;\n y,x,ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n s,s0,s1,s2:string;\n sss:ansistring;\n z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n read(n);\n for i:=1 to n do read(qc[i]);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('BitLGM') else writeln('BitAryo');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n res:=0;\n if n=1 then\n begin\n res:=1;\n if qc[1]=0 then res:=2;\n end;\n if n=2 then\n begin\n if abs(qc[1]-qc[2])=1 then res:=2 else res:=1;\n if qc[1]+qc[2]=1 then res:=1;\n if qc[1]+qc[2]=0 then res:=2;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,k,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='d.in';\n file2='d.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n a:array[0..331,0..331,0..331]of byte;\n aa:array[0..331,0..331]of byte;\n y,x,ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n s,s0,s1,s2:string;\n sss:ansistring;\n z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n read(n);\n for i:=1 to n do read(qc[i]);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('BitLGM') else writeln('BitAryo');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n res:=0;\n if n=1 then\n begin\n res:=1;\n if qc[1]=0 then res:=2;\n end;\n if n=2 then\n begin\n aa[0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n if aa[i,j]=0 then\n begin\n for x:=i+1 to 310 do aa[x,j]:=1;\n for x:=j+1 to 310 do aa[i,x]:=1;\n y:=i;\n if j>y then y:=j;\n for x:=1 to 310-y do aa[i+x,j+x]:=1;\n end;\n if aa[qc[1],qc[2]]=0 then res:=2 else res:=1;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,k,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='d.in';\n file2='d.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n a:array[0..331,0..331,0..331]of byte;\n y,x,ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n s,s0,s1,s2:string;\n sss:ansistring;\n z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n read(n);\n for i:=1 to n do read(qc[i]);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('BitLGM') else writeln('BitAryo');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n res:=0;\n if n=1 then\n begin\n res:=1;\n if qc[1]=0 then res:=2;\n end;\n if n=2 then\n begin\n if abs(qc[1]-qc[2])=1 then res:=2 else res:=1;\n if qc[1]+qc[2]=1 then res:=1;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,k,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='d.in';\n file2='d.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n a:array[0..331,0..331,0..331]of byte;\n aa:array[0..331,0..331]of byte;\n y,x,ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n s,s0,s1,s2:string;\n sss:ansistring;\n z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n read(n);\n for i:=1 to n do read(qc[i]);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('BitLGM') else writeln('BitAryo');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n res:=0;\n if n=1 then\n begin\n res:=1;\n if qc[1]=0 then res:=2;\n end;\n if n=2 then\n begin\n aa[0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n if aa[i,j]=0 then\n begin\n for x:=i+1 to 310 do aa[x,j]:=1;\n for x:=j+1 to 310 do aa[i,x]:=1;\n y:=i;\n if j>y then y:=j;\n for x:=1 to 310-y do aa[i+x,j+x]:=1;\n end;\n if aa[qc[1],qc[2]]=0 then res:=2 else res:=1;\n end;\n if n=3 then\n begin\n a[0,0,0]:=0;\n for i:=0 to 320 do\n for j:=0 to 320 do\n for k:=0 to 320 do\n if a[i,j,k]=0 then\n begin\n for x:=i+1 to 310 do a[x,j,k]:=1;\n for x:=j+1 to 310 do a[i,x,k]:=1;\n for x:=k+1 to 310 do a[i,k,x]:=1;\n y:=i;\n if j>y then y:=j;\n if k>y then y:=k;\n for x:=1 to 310-y do a[i+x,j+x,k+x]:=1;\n end;\n if a[qc[1],qc[2],qc[3]]=0 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output); {}\nend.\n"}], "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7"} {"source_code": "const\n tfi = '' ;\n tfo = '' ;\n Nmax=2001 ;\n p=1000000007 ;\nvar\n fi,fo:text;\n n,m,res :longint;\n f,g,s,ff:array[0..Nmax,0..Nmax] of longint ;\nprocedure process;\nvar\ni,j,k:longint ;\nbegin\n read(fi,m,n) ;\n res := 0 ;\n For i := 1 to m do\n For j := 2 to n do\n begin\n if i = 1 then F[i,j] := 1 else\n F[i,j] := ((int64(j+1)*S[i-1,j]-G[i-1,j]) mod p+p) mod p ;\n S[i,j] := (S[i,j-1] + F[i,j]) mod p ;\n G[i,j] := (G[i,j-1] + int64(F[i,j])*j) mod p ;\n end;\n For i := 1 to m do for j := 1 to n do\n begin\n S[i,j] := (S[i-1,j] + S[i,j]) mod p ;\n G[i,j] := (G[i-1,j] + G[i,j]) mod p ;\n end;\n For i := 1 to m do for j := 2 to n do\n begin\n res := (res + (((int64(j+1)*S[i-1,j] mod p - G[i-1,j]+1) mod p)*((int64(j+1)*S[m-i,j-1] mod p-G[m-i,j-1]+1) mod p) mod p)*(n-j+1)) mod p ;\n end;\n {For i := 1 to m do for j:= 2 to n do if i = 1 then FF[i,j] := 1 else\n begin\n /// FF[i,j] := 1;\n for k := 2 to j do FF[i,j] := (FF[i,j] + FF[i-1,k]*int64(j-k+1)) mod p ;\n end;}\n writeln(fo,(res + p) mod p) ;\nend ;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo) ;\n process;\n close(fi) ;\n close(fo) ;\nend .\n", "positive_code": [{"source_code": "const\n tfi = '' ;\n tfo = '' ;\n Nmax=2001 ;\n p=1000000007 ;\nvar\n fi,fo:text;\n n,m,res :longint;\n f,g,s,ff:array[0..Nmax,0..Nmax] of longint ;\nprocedure process;\nvar\ni,j,k:longint ;\nbegin\n read(fi,m,n) ;\n res := 0 ;\n For i := 1 to m do\n For j := 2 to n do\n begin\n if i = 1 then F[i,j] := 1 else\n F[i,j] := ((int64(j+1)*S[i-1,j]-G[i-1,j]) mod p+p) mod p ;\n S[i,j] := (S[i,j-1] + F[i,j]) mod p ;\n G[i,j] := (G[i,j-1] + int64(F[i,j])*j) mod p ;\n end;\n For i := 1 to m do for j := 1 to n do\n begin\n S[i,j] := (S[i-1,j] + S[i,j]) mod p ;\n G[i,j] := (G[i-1,j] + G[i,j]) mod p ;\n end;\n For i := 1 to m do for j := 2 to n do\n begin\n res := (res + (((int64(j+1)*S[i-1,j] mod p - G[i-1,j]+1) mod p)*((int64(j+1)*S[m-i,j-1] mod p-G[m-i,j-1]+1) mod p) mod p)*(n-j+1)) mod p ;\n end;\n {For i := 1 to m do for j:= 2 to n do if i = 1 then FF[i,j] := 1 else\n begin\n /// FF[i,j] := 1;\n for k := 2 to j do FF[i,j] := (FF[i,j] + FF[i-1,k]*int64(j-k+1)) mod p ;\n end;}\n writeln(fo,(res + p) mod p) ;\nend ;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo) ;\n process;\n close(fi) ;\n close(fo) ;\nend .\n"}, {"source_code": "uses math;\nconst\n nmax = 2010;\n modul = 1000000007;\nvar\n n,m:longint;\n res,Sol:int64;\n F,G,H:Array[0..nmax,0..nmax] of longint;\nprocedure process;\nvar i,j,u,v:longint;\nbegin\n read(n,m);\n for i:=1 to n do\n for j:=2 to m do\n begin\n F[i][j]:=(H[i-1][j]*int64(j) - G[i-1][j]+1)mod modul;\n if F[i][j]<0 then F[i][j]:=F[i][j]+modul;\n H[i][j]:=(H[i][j-1]+F[i][j])mod modul;\n G[i][j]:=(G[i][j-1]+F[i][j]*int64(j-1))mod modul;\n end;\n for i:=1 to n do for j:=2 to m do\n begin\n Sol:=(F[i][j]-F[i-1][j])*int64(F[n-i+1][j]);\n Sol:=Sol mod modul;\n if Sol<0 then Sol:=Sol+modul;\n Sol:=(Sol*(m-j+1))mod modul;\n res:=(res+Sol)mod modul;\n end;\n writeln(res);\nend;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n process;\n close(input);\n close(output);\nend.\n"}], "negative_code": [], "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1"} {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n*(n-1) div 2 else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tif need > n then break;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif need>=n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend.", "positive_code": [{"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\n k:=0;\n for i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+m*k-1;\n end else t:=t+m*k;\n k:=(r+1) div 2;\n t:=t+(n mod m+1)*k;\n if (n+1) mod (2*m)=0 then t:=t-1;\n write(t);\n end else write(1 shl (n-1)-1-n div 4);\nend.\n"}, {"source_code": "program Project1;\n\nuses\n math;\nvar\n n, shovels1, shovels2: Int64;\n Max9, sum, add1, add2, With1, WithOut, With1and2, counter: Int64;\n i: LongInt;\n\nprocedure Change(var a, b: Int64);\nvar\n tmp: Int64;\nbegin\n tmp := b;\n b := a;\n a := tmp;\nend;\n\nbegin\n ReadLn(n);\n Max9 := 0;\n If n > 9 div 2 then Max9 := 9;\n If n > 99 div 2 then Max9 := 99;\n If n > 999 div 2 then Max9 := 999;\n If n > 9999 div 2 then Max9 := 9999;\n If n > 99999 div 2 then Max9 := 99999;\n If n > 999999 div 2 then Max9 := 999999;\n If n > 9999999 div 2 then Max9 := 9999999;\n If n > 99999999 div 2 then Max9 := 99999999;\n If n > 999999999 div 2 then Max9 := 999999999;\n If n > 9999999999 div 2 then Max9 := 9999999999;\n If Max9 = 0 then\n begin\n Case n of\n 2: WriteLn(1);\n 3: WriteLn(3);\n 4: WriteLn(6);\n end;\n end else\n begin\n shovels1 := n div (Max9+1);\n shovels2 := shovels1;\n add1 := n mod (Max9+1);\n If add1 > Max9 div 2 then\n begin\n add2 := add1 - (Max9 div 2);\n add1 := add1 - add2;\n end;\n With1 := (shovels1+1) * shovels2;\n WithOut := shovels1 * shovels2;\n With1and2 := (shovels1+1) * (shovels2+1);\n If add1 < add2 then\n begin\n Change(add1, add2);\n end;\n\n counter := Max9 div 2 + 1;\n sum := With1 * (add1 - add2);\n sum := sum + With1and2 * add2;\n counter := counter - add1;\n sum := sum + WithOut * counter;\n\n WriteLn(sum);\n end;\nend.\n"}, {"source_code": "var i:longint;t,w,s,s1,n,sum,o:int64;\nbegin\n//assign(input,'czxs.in');reset(input);\n//assign(output,'czxs.out');rewrite(output);\nreadln(n);t:=5;\nif n<=4 then\n writeln(n*(n-1) div 2)\nelse\n begin\n while n>=t do\n begin\n w:=w+1;t:=t*10;\n end;\n for i:=1 to w do\n s:=s*10+9;\n s1:=1;\n for i:=1 to w do s1:=s1*10;\n for i:=0 to 8 do\n begin\n o:=s1*i+s;\n if n>=o then\n sum:=sum+o div 2\n else if n>=(o+1) div 2 then\n sum:=sum+n-(o+1) div 2+1\n else break;\n end;\n writeln(sum);\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "uses math;\nvar n,t:int64;\n tmp,res,x:int64;\n i,j:longint;\n pow:array[0..9] of int64;\nbegin\n //assign(input,'899D.INP');reset(input);\n //assign(output,'899D.out');rewrite(output);\n readln(n);\n if n<=4 then\n begin\n writeln(n*(n-1) div 2);halt;\n end;\n pow[1]:=9;\n for i:=1 to 9 do\n pow[i]:=pow[i-1]*10+9;\n for i:=9 downto 1 do\n begin\n if 2*n-1>=pow[i] then\n begin\n tmp:=(pow[i]+1) div 2-1;\n t:=min(tmp,n-tmp);\n res:=res+t;\n tmp:=pow[i]+1;x:=pow[i];\n for j:=1 to 8 do\n begin\n x:=x+tmp;\n if 2*n-1=a[i]-1 then\nq+=a[i] div 2 else if (n*2-a[i]+1) div 2>0 then q+=(n*2-a[i]+1) div 2;\n\nend;\nwrite(q)\nend\nend."}, {"source_code": "uses\n math;\nvar\n n,x,t,tmp,p,ans:int64;\n i,d:longint;\nbegin\n readln(n);\n if n<5 then\n begin\n write(n*(n-1) div 2);\n halt;\n end;\n x:=999999999;\n for i:=9 downto 1 do\n begin\n ans:=0;\n for d:=0 to 8 do\n begin\n t:=d*(10**int64(i))+x;\n tmp:=t-min(t-1,n);\n if tmp0 then break;\n x:=x div 10;\n end;\n writeln(ans);\nend."}], "negative_code": [{"source_code": "program Project1;\n\nuses\n math;\nvar\n n, shovels1, shovels2: Int64;\n Max9, sum, add1, add2, With1, WithOut, With1and2, counter: Int64;\n i: LongInt;\n\nprocedure Change(var a, b: Int64);\nvar\n tmp: Int64;\nbegin\n tmp := b;\n b := a;\n a := tmp;\nend;\n\nbegin\n ReadLn(n);\n Max9 := 0;\n If n > 9 div 2 then Max9 := 9;\n If n > 99 div 2 then Max9 := 99;\n If n > 999 div 2 then Max9 := 999;\n If n > 9999 div 2 then Max9 := 9999;\n If n > 99999 div 2 then Max9 := 99999;\n If n > 999999 div 2 then Max9 := 999999;\n If n > 9999999 div 2 then Max9 := 9999999;\n If n > 99999999 div 2 then Max9 := 99999999;\n If n > 999999999 div 2 then Max9 := 999999999;\n If n > 9999999999 div 2 then Max9 := 9999999999;\n If Max9 = 0 then\n begin\n Case n of\n 2: WriteLn(1);\n 3: WriteLn(3);\n 4: WriteLn(6);\n end;\n end else\n begin\n shovels1 := n div (Max9+1);\n shovels2 := shovels1;\n add1 := n mod (Max9+1);\n If add1 > Max9 div 2 then\n begin\n add2 := add1 - (Max9 div 2);\n add1 := add1 - add2;\n end;\n With1 := (shovels1+1) * shovels2;\n WithOut := shovels1 * shovels2;\n With1and2 := (shovels1+1) * (shovels2+1);\n If add1 < add2 then\n begin\n Change(add1, add2);\n end;\n\n counter := Max9 div 2 + 1;\n sum := With1 * (add1 - add2);\n sum := sum + With1and2 * add2;\n counter := counter - add1;\n sum := sum + WithOut * counter;\n end;\n WriteLn(sum);\nend.\n"}, {"source_code": "var i:longint;t,w,s,s1,n,sum,o:int64;\nbegin\n//assign(input,'czxs.in');reset(input);\n//assign(output,'czxs.out');rewrite(output);\nreadln(n);t:=5;\nwhile n>=t do\n begin\n w:=w+1;t:=t*10;\n end;\nfor i:=1 to w do\n s:=s*10+9;\ns1:=1;\nfor i:=1 to w do s1:=s1*10;\nfor i:=0 to 8 do\n begin\n o:=s1*i+s;\n if n>=o then\n sum:=sum+o div 2\n else if n>=(o+1) div 2 then\n sum:=sum+n-(o+1) div 2+1\n else break;\n end;\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "uses math;\nvar n,t:int64;\n tmp,res,x:int64;\n i,j:longint;\n pow:array[0..9] of int64;\nbegin\n //assign(input,'899D.INP');reset(input);\n //assign(output,'899D.out');rewrite(output);\n readln(n);\n if n<=4 then\n begin\n writeln(0);halt;\n end;\n pow[1]:=9;\n for i:=1 to 9 do\n pow[i]:=pow[i-1]*10+9;\n for i:=9 downto 1 do\n begin\n if 2*n-1>=pow[i] then\n begin\n tmp:=(pow[i]+1) div 2-1;\n t:=min(tmp,n-tmp);\n res:=res+t;\n tmp:=pow[i]+1;x:=pow[i];\n for j:=1 to 8 do\n begin\n x:=x+tmp;\n if 2*n-1=pow[i] then\n begin\n tmp:=(pow[i]+1) div 2-1;\n t:=min(tmp,n-tmp);\n res:=res+t;\n tmp:=pow[i]+1;x:=pow[i];\n for j:=1 to 8 do\n begin\n x:=x+tmp;\n if 2*n-1=pow[i] then\n begin\n tmp:=(pow[i]+1) div 2-1;\n t:=min(tmp,n-tmp);\n res:=res+t;\n tmp:=pow[i]+1;x:=pow[i];\n for j:=1 to 8 do\n begin\n x:=x+tmp;\n if 2*n-1=pow[i] then\n begin\n tmp:=(pow[i]+1) div 2-1;\n t:=min(tmp,n-tmp);\n res:=res+t;\n tmp:=pow[i]+1;x:=pow[i];\n for j:=1 to 8 do\n begin\n x:=x+tmp;\n if 2*n-10 then break;\n x:=x div 10;\n end;\n writeln(ans);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif goal-1>n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,sum,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tkq:=n-sum+1;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif goal-1>n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif need>n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tif goal2<=need then break;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif need>=n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tif goal2=n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tkq:=n-sum+1;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif goal-1>n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tkq:=n-sum+1;\n\t\t\tif n = sum then dec(kq);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif goal-1>n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n*(n-1) div 2 else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif need>=n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var\tn,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;\n\ta:array[0..10] of longint;\n\tsum:int64;\nbegin\n\treadln(n);\n\ttong:=n+n-1;\n\tsum:=9;\n\tdem:=0;\n\twhile sum<=tong do\n\tbegin\n\t\tinc(dem);\n\t\tsum:=sum*10+9;\n\tend;\n\tsum:=(sum+1)div 10 - 1;\n\tif dem=0 then kq:=n else\n\tbegin\n\t\tvt:=0;\n\t\tn2:=n;\n\t\twhile n2>0 do\n\t\tbegin\n\t\t\tinc(vt);\n\t\t\ta[vt]:=n2 mod 10;\n\t\t\tn2:=n2 div 10;\n\t\tend;\n\t\tkq:=0;\n\t\tif dem=vt then\n\t\tbegin\n\t\t if n = sum then kq:=-1;\n\t\t\tsum:=(sum+1) div 2;\n\t\t\tinc(kq,n-sum+1);\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\ths:=1;\n\t\t\tfor i:=2 to vt do\n\t\t\t\ths:=hs*10;\n\t\t\tfor i:=0 to 9 do\n\t\t\tbegin\n\t\t\t\tgoal:=i*hs+sum;\n\t\t\t\tneed:=(goal+1) div 2;\n\t\t\t\tif goal-1>n then goal2:=n else goal2:=goal-1;\n\t\t\t\tinc(kq,goal2-need+1);\n\t\t\t\tif need>=n then break;\n\t\t\tend;\t\n\t\tend;\n\tend;\n\twriteln(kq);\nend."}, {"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\n k:=0;\n for i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+m*k-1;\n end else t:=t+m*k;\n k:=(r+1) div 2;\n t:=t+(n mod m+1)*k;\n if (n+1) mod (2*m)=0 then t:=t-1;\n write(t);\n end else write(1 shl (n-1)-1);\nend.\n"}, {"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\nk:=0;\nfor i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+(m-1)*k;\n end else t:=t+m*k;\nk:=(r+1) div 2;\nt:=t+(n mod m+1)*k;\nif (n+1) mod (2*m)=0 then t:=t-1;\nend;\nwrite(t);\nend.\n"}, {"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\n k:=0;\n for i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+(m-1)*k;\n end else t:=t+m*k;\n k:=(r+1) div 2;\n t:=t+(n mod m+1)*k;\n if (n+1) mod (2*m)=0 then t:=t-k;\n end;\nwrite(t);\nend.\n"}, {"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\n k:=0;\n for i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+(m-1)*k;\n end else t:=t+m*k;\n k:=(r+1) div 2;\n t:=t+(n mod m+1)*k;\n if (n+1) mod (2*m)=0 then t:=t-1;\n write(t);\n end else write(1 shl (n-1)-1);\nend.\n"}, {"source_code": "var n,j,k,m,r,t:int64;\n i:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\nm:=5;\nwhile n>=m do m:=m*10;\nm:=m div 10;\nt:=0;\nif m>0 then\n begin\n r:=n div m;\n k:=0;\n for i:=1 to r-1 do\n if i mod 2=1 then\n begin\n k:=k+1;\n t:=t+(m-1)*k;\n end else t:=t+m*k;\n k:=(r+1) div 2;\n t:=t+(n mod m+1)*k;\n if (n+1) mod (2*m)=0 then t:=t-k;\nwrite(t);\n end else write(1 shl (n-1)-1);\nend.\n"}, {"source_code": "var n,k,q,m,i:int64;\na:array[0..9] of int64;\nf:array[0..9] of boolean;\ns,w:string;\nt:integer;\nbegin\nread(n);\nk:=n+n-1;\nstr(k,s);\nfor i:=0 to 9 do\nbegin\n w:=chr(i+48)+max(1,(s.Length-1))*'9';\nif w[1]='0' then delete(w,1,1);\nval(w,a[i],t);\n\nend;\nif a[9]=n+n-1 then write(1) else\nbegin\nfor i:=0 to 8 do\nbegin\n\nif n>=a[i]-1 then\nq+=a[i] div 2 else if (n*2-a[i]+1) div 2>0 then q+=(n*2-a[i]+1) div 2;\n\nend;\nwrite(q)\nend\nend."}], "src_uid": "c20744c44269ae0779c5f549afd2e3f2"} {"source_code": "var\n s,t,ans1,ans2:ansistring;\n x,y,sum:longint;\nbegin\n readln(s);\n readln(t);\n x:=pos('|',s)-1;\n y:=length(s)-x-1;\n sum:=length(t);\n ans1:=copy(s,1,x);\n ans2:=copy(s,x+2,length(s)-x+2);\n while (sum>0) do\n begin\n if (x>y) then begin\n inc(y);\n ans2:=ans2+t[sum];\n dec(sum);\n end\n else begin\n inc(x);\n ans1:=ans1+t[sum];\n dec(sum);\n end;\n end;\n if (x=y) then write(ans1,'|',ans2)\n else write('Impossible');\nend.", "positive_code": [{"source_code": "const fi='';\nvar\n s,s1:ansistring;\n\nprocedure enter;\nbegin\n assign(input,fi); reset(input);\n readln(s);\n readln(s1);\n close(input);\nend;\nprocedure solve;\nvar i,w1,w2,n,n1,m:int32; divi:boolean;\nbegin\n divi:= false;\n w1:= 0; w2:= 0; n:= length(s); n1:= length(s1);\n for i:= 1 to n do\n if s[i]='|' then\n divi:= true\n else\n if divi then\n inc(w2)\n else\n inc(w1);\n m:= (w1+w2+n1) shr 1;\n if ((w1+w2+n1) and 1=1) or( n1+w2q)or(k2>q) then begin\n writeln('Impossible');\n halt(0);\n end;\n z:=q-k1;\n begin\n for i:=1 to pos-1 do\n s:=s+s1[i];\n while (z>0) do\n begin\n inc(k);\n s:=s+s2[k];\n dec(z);\n end;\n end;\n s:=s+'|';\n z:=q-k2;\n\n begin\n for i:=pos+1 to l1 do\n s:=s+s1[i];\n while (z>0) do\n begin\n inc(k);\n s:=s+s2[k];\n dec(z);\n end;\n end;\n writeln(s);\n end."}, {"source_code": "var\n i,j,k,l1,l2,l3,m,n:longint;\n s,s1:ansistring;\nbegin\n readln(s);\n readln(s1);\n l1:=pos('|',s);\n l2:=length(s)-l1;\n dec(l1);\n l3:=length(s1);\n if(abs(l1-l2)>l3) or((l1+l2+l3)mod 2=1)then\n write('Impossible')\n else write(copy(s,1,l1),copy(s1,1,(l2+l3-l1)div 2),'|',copy(s,l1+2,l2),copy(s1,((l2+l3-l1)div 2)+1,(l1+l3-l2)div 2));\n\nend."}, {"source_code": "program yan;\n var s,s1:ansistring;\n i,j,x,y,a,b,n,m:longint;\nbegin\n readln(s);\n read(s1);\n for i:=1 to length(s) do\n begin\n if s[i]='|' then begin x:=1; continue; end;\n if (x=0) then inc(a) else inc(b);\n end;\n if abs(a-b)>length(s1) then begin write('Impossible'); exit; end;\n if a>b then\n while b0 then begin write('Impossible'); exit; end;\n for i:=j+1 to length(s1) do\n if i mod 2<>0 then s:=s+s1[i] else s:=s1[i]+s;\n write(s);\nend."}, {"source_code": "label 10;\nvar\n g,ex,bir,iki:ansistring;\n i,poz:longint;\nbegin\n readln(g);\n readln(ex);\n for i:=1 to length(g) do\n if g[i]='|' then break\n else bir:=bir+g[i];\n while (i0) then begin bir:=bir+ex[1]; ex:=copy(ex,2,length(ex)); goto 10; end\n else begin writeln('Impossible'); halt; end;\n if (length(bir)>length(iki)) then\n if (length(ex)>0) then begin iki:=iki+ex[1]; ex:=copy(ex,2,length(ex)); goto 10; end\n else begin writeln('Impossible'); halt; end;\n if (length(ex) mod 2=1) then begin writeln('Impossible'); halt; end;\n poz:=length(ex) div 2;\n bir:=bir+copy(ex,1,poz);\n iki:=iki+copy(ex,poz+1,length(ex));\n writeln(bir,'|',iki);\nend."}, {"source_code": "program project1;\n\nvar\n vesy: widestring;\n other: widestring;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n writeln('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n writeln('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1)+1, Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": " var s,s1:ansistring;\n i,k1,k2,k3:longint;\n u:byte;\n\n\nbegin s:='';\n readln(s);\n u:=0; s1:=''; k1:=0;k2:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='|' then u:=1;\n if s[i] in ['A'..'Z'] then if u=0 then inc(k1)\n else inc(k2);\n end;\n readln(s1); k3:=length(s1);\n i:=1;\n if ((k3+k2+k1) mod 2 = 1) or (k1>k2+k3) or (k2>k3+k1) then writeln('Impossible')\n else begin\n while k3<>0 do\n begin\n if k1>k2 then begin s:=s+s1[i]; inc(i);inc(k2); dec(k3); end\n else begin write(s1[i]); inc(k1); inc(i); dec(k3); end;\n end;\n write(s);\n end;\n\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "uses math;\n\nvar s,d:string;\n i,l,l1,t:byte;\n\nbegin\nreadln(s);\nl:=length(s);\ni:=1;\nwhile s[i]<>'|' do\ninc(i);\nread(d);\nl1:=length(d);\nif (l10 then inc(i);\nfor t:=i to l1 do\nwrite(d[t]);\nend.\n"}, {"source_code": "Var i,j,k,l,n,m,t,c,r,f,x : Longint;\n s,s1 : ansistring;\nfunction Max(a,b : Longint) : Longint;\nbegin\n If (a > b) Then max := a\n else max := b;\nEnd;\n\nBegin\n Readln(s);\n i := 1;\n While s[i] <> '|' Do\n Begin\n Inc(l);\n inc(i);\n End;\n r := length(s) - l - 1;\n Readln(s1);\n c := abs(r - l);\n if (length(s1) - c < 0) or ((length(s1) - c) mod 2 <> 0) Then\n Begin\n Writeln('Impossible');\n exit;\n End;\n k := 1;\n f := length(s1);\n dec(f,c);\n f := f div 2;\n t := max(l,r) + f;\n For i := 1 To l Do\n Write(s[i]);\n For i := 1 To t - l do\n write(s1[i]);\n Write('|');\n For i := l + 2 to length(s) Do\n Write(s[i]);\n For i := t - l + 1 To length(s1) do\n Write(s1[i]);\n Writeln();\nEnd."}, {"source_code": "var s1,s2:string;\n i,l:byte;\n\nBEGIN\nreadln(s1);readln(s2);\ni:=1;\nwhile s1[i]<>'|' do i:=i+1;\nl:=length(S1);\nwhile ((length(s1)-i<>i-1) or (length(s2)>1))and(length(s2)>0) do\n begin\n if length(s1)-i=i-1 then\n begin\n s1:=s2[1]+s1+s2[2];\n delete(s2,1,2);\n i:=i+1;\n end\n else if length(s1)-ii-1 then\n begin\n s1:=s2[1]+s1;\n delete(s2,1,1);\n i:=i+1;\n end;\n end;\nif odd(length(s1)) and (i=length(s1) div 2+1) and (l<>length(s1)) and (length(s2)=0) then write(s1) else write('Impossible');\nEND.\n\n"}, {"source_code": "program task_one;\n\nvar i : longint; \nwas : boolean;\ns : ansistring;\na, b : ansistring;\nbegin\n\tReadln(s);\n\twas:=false;\n\ta:=''; b:='';\n\tfor i:=1 to length(s) do begin\n\t\tif s[i]<>'|' then begin\n\t\t\tif not was then a:=a + s[i]\n\t\t\telse b:=b + s[i];\n\t\tend else was:=true;\n\tend;\n\ts:='';\n\tReadln(s);\n\tfor i:=1 to length(s) do begin\n\t\tif length(a)<=length(b) then begin\n\t\t\ta:=a + s[i];\n\t\tend else begin\n\t\t\tb:=b + s[i];\n\t\tend;\n\tend;\n\tif length(a)<>length(b) then Writeln('Impossible')\n\telse Writeln(a,'|',b);\nend."}, {"source_code": "Const\n infile = '';\n outfile = '';\nVar\n str1, str2, st1, st2: Ansistring;\n ch: Char;\n l1, l2, l3, i, l: Longint;\n f: Boolean;\nBegin\n Assign(input, infile);\n Reset(input);\n Assign(output, outfile);\n Rewrite(output);\n ReadLn(st1);\n ReadLn(st2);\n l := length(st1);\n f := True;\n For i:=1 To l Do Begin\n If st1[i] = '|' Then Begin\n f := False;\n continue;\n End;\n If f Then str1 := str1 + st1[i]\n Else str2 := str2 + st1[i];\n End;\n l1 := length(str1);\n l2 := length(str2);\n l3 := length(st2);\n For i:=1 To l3 Do Begin\n ch := st2[i];\n If l1 <= l2 Then Begin\n Inc(l1);\n str1 := str1 + ch;\n Continue;\n End;\n If l1 > l2 Then Begin\n Inc(l2);\n str2 := str2 + ch;\n End;\n End;\n If l1 = l2 Then Writeln(str1, '|', str2)\n Else WriteLn('Impossible');\n Close(input);\n Close(output);\nEnd."}, {"source_code": "var i,t1,t2,q,r :longint;\n s1,s2,ss1,ss2,ss:string;\n ok:boolean;\n begin\n readln(s1);\n readln(s2);\n ok:=false;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='|') then begin ok:=true; continue; end;\n if ok then begin inc(t2); ss2:=ss2+s1[i] end\n else begin inc(t1); ss1:=ss1+s1[i];end;\n end;\n\n if t1length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss1:=ss1+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss1:=ss1+s2[i];\n for i:=q+r+1 to length(s2) do\n ss2:=ss2+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end\n else begin\n q:=t1-t2;\n if q>length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss2:=ss2+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss2:=ss2+s2[i];\n for i:=q+r+1 to length(s2) do\n ss1:=ss1+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end;\n end."}, {"source_code": "var\ns,q,aa,bb:ansistring;\nss,i,j,k:Longint;\nnow,a,b:Longint;\n\nbegin\n\treadln(s);\n\tfor i:=1 to length(s) do\n\tbegin\n\t\tif s[i]<>'|' then\n\t\tbegin\n\t\t\tinc(a);\n\t\t\taa:=aa+s[i];\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tss:=i;\n\t\t\tbreak;\n\t\tend;\n\tend;\n\tfor i:=ss to length(s) do\n\tbegin\n\t\tif s[i]<>'|' then\n\t\tbegin\n\t\t\tinc(b);\n\t\t\tbb:=bb+s[i];\n\t\tend;\n\tend;\n\treadln(q);\n//\twriteln(a,' ',b);\n\tfor i:=1 to length(q) do\n\tbegin\n\t\tif a>b then inc(b) else inc(a);\n\tend;\n//\twriteln(a,' ',b);\n\tnow:=1;\n\n\tif (a=b) then\n\tbegin\n\t\tfor i:=1 to length(aa) do\n\t\tbegin\n\t\t\twrite(aa[i]);\n\t\tend;\n\t\tfor i:=1 to abs(length(aa)-a) do\n\t\tbegin\n\t\t\twrite(q[i]);\n\t\t\tinc(now);\n\t\tend;\n\t\twrite('|');\n\t\tfor i:=1 to length(bb) do\n\t\tbegin\n\t\t\twrite(bb[i]);\n\t\tend;\n\t\tfor i:=now to length(q) do\n\t\tbegin\n\t\t\twrite(q[i]);\n\t\t\tinc(now);\n\t\tend;\n\t\twriteln;\n\tend\n\telse writeln('Impossible');\nend."}, {"source_code": "var\na,c,s:string;\nb,d,e,f,g,h,i,j,k,x,y,z:longint;\ntabel:array[1..100] of ansistring;\ndata:array[1..100] of longint;\nbegin\n\ts:='';\n\treadln(a);\n\tb:=length(a);\n\tx:=1;\n\ty:=1;\n\tdata[1]:=0;\n\tdata[2]:=0;\n\ttabel[1]:='';\n\ttabel[2]:='';\n\tfor i:=1 to b do\n\tbegin\n\t\tif a[i]<>'|' then\n\t\tbegin\n\t\t\tdata[x]:=data[x]+1;\n\t\t\ttabel[x]:=tabel[x]+a[i];\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tx:=x+1;\n\t\t\te:=i-1;\n\t\tend;\n\tend;\n//\twriteln(tabel[1],' ',tabel[2],' ',length(tabel[1]),' ',length(tabel[2]));\n\treadln(c);\n\td:=length(c);\n\tf:=abs(data[1]-data[2]);\n\tg:=d-f;\n\th:=length(tabel[1]);\n\tz:=length(tabel[2]);\n\tif (g mod 2=1) or (g<0) then\n\twrite('Impossible')\n\telse\n\tbegin\n\t\tif z>h then\n\t\tbegin\n\t\t\tfor j:=1 to(z-h)+(d-(z-h))div 2 do\n\t\t\tbegin\n\t\t\t\ts:=s+c[y];\n\t\t\t\ty:=y+1;\n\t\t\tend;\n\t\t\ts:=s+tabel[1];\n\t\t\ts:=s+'|';\n\t\t\ts:=s+tabel[2];\n\t\t\tfor k:=1 to (d-(h-z))div 2 do\n\t\t\tbegin\n\t\t\t\ts:=s+c[y];\n\t\t\t\ty:=y+1;\n\t\t\tend;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tfor j:=1 to(d-(h-z))div 2 do\n\t\t\tbegin\n\t\t\t\ts:=s+c[y];\n\t\t\t\ty:=y+1;\n\t\t\tend;\n\t\t\ts:=s+tabel[1];\n\t\t\ts:=s+'|';\n\t\t\ts:=s+tabel[2];\n\t\t\tfor k:=1 to (h-z)+(d-(h-z))div 2 do\n\t\t\tbegin\n\t\t\t\ts:=s+c[y];\n\t\t\t\ty:=y+1;\n\t\t\tend;\n\t\tend;\n\tend;\n\tfor i:=1 to length(s) do\n\tbegin\n\t\tif (((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) or (s[i]='|')) then write(s[i]); \n\tend;\n\twriteln;\nend."}, {"source_code": "var s,p:string; a,b,c,k:byte;\nbegin\n readln(s); readln(p);\n a:=pos('|',s)-1; b:=length(s)-pos('|',s); c:=length(p);\n\n if ((a+b+c) mod 2=0) then\n begin\n if (c>=abs(a-b)) then\n begin\n k:=c-a+b;\n writeln(copy(p,1,k div 2),s,copy(p,k div 2+1,c-k div 2))\n end else writeln('Impossible');\n end else writeln('Impossible');\nend."}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to ((length(t)-d)div 2+d) do write(t[i]);\nwrite(s);\nfor i:=((length(t)-d)div 2+d+1) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "{$mode objFpc}{$H+}\nuses math;\nconst\n finp = '';\n fout = '';\nvar\n fi,fo : text;\n S,S1,S2,T : String;\nprocedure openfile;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\nend;\nprocedure closefile;\nbegin\n close(fi);close(fo);\nend;\nprocedure enter;\nvar\n i : integer;\nbegin\n readln(fi,S);\n readln(fi,T);\n i:=pos('|',S);\n S1:=Copy(S,1,i-1);\n S2:=Copy(S,i+1,length(S)-i);\nend;\nprocedure process;\nvar\n i,T1,T2,T3,j,k : integer;\nbegin\n T1:=length(S1);T2:=length(S2);T3:=length(T);\n if (Abs(T1-T2)<=T3) and (not odd(T3-abs(T1-T2))) then\n begin\n j:=abs(T1-T2);\n k:=(T3-abs(T1-T2)) div 2;\n if T10 then\n begin\n S1:=S1+Copy(T,j+1,k);\n S2:=S2+Copy(T,j+k+1,k);\n end;\n writeln(fo,S1,'|',S2);\n end\n else\n writeln(fo,'Impossible');\nend;\nbegin\n openfile;\n enter;\n process;\n closefile;\nend."}, {"source_code": "VAR a,b,c,d:integer;t,t1,t2,n:string[255];\nbegin\nreadln(t);\nb:=pos('|',t);\nt1:=copy(t,1,b-1);\nt2:=copy(t,b+1,length(t)-b);\nreadln(n);\nc:=length(n);\nd:=length(t1)-length(t2);\nif ((d-c) mod 2<>0) or (abs(d)>c) then writeln('Impossible') else\nbegin\nwriteln(t1,copy(n,1,(c-d) div 2),'|',t2,copy(n,(c-d) div 2+1,c));\nend;\nend."}, {"source_code": "var a,b:ansistring;\n i,l,r,l1,r1:longint;\nbegin\nreadln(a);\nreadln(b);\nl:=0;\nwhile (a[l+1]<>'|') do inc(l);\nr:=length(a)-l-1;\nl1:=r-l+length(b);\nr1:=-r+l+length(b);\nif ((l1<0)or(r1<0)or(l1 mod 2=1) or (r1 mod 2=1)) then writeln('Impossible')\nelse begin\n for i:=l1 div 2 downto 1 do a:=b[i]+a;\n for i:=l1 div 2+1 to length(b) do a:=a+b[i];\n writeln(a);\n end;\nend.\n"}, {"source_code": "program ProblemA;\nvar s,l,r:ansistring;\n i,j:longint;\n c:char;\nbegin\n repeat\n read(c);\n l:=l+c;\n until c=#124;\n delete(l,length(l),1);\n readln(r);\n\n readln(s);\n for i:=1 to length(s) do\n if length(l)<=length(r) then l:=l+s[i] else r:=r+s[i];\n if length(l)<>length(r) then write('Impossible')\n else write (l,#124,r);\nreadln;\nend.\n"}, {"source_code": "var\n s,res,t,gg1,gg2:string;\n g1,g2,go,i,n,j:longint;\nbegin\n readln(s);\n readln(t);\n i:=1;\n gg1:='';\n gg2:='';\n while (s[i]<>'|') do\n begin\n gg1:=gg1+s[i];\n i:=i+1;\n end;\n for j:=i+1 to length(s) do\n gg2:=gg2+s[j];\n n:=abs(length(gg1)-length(gg2)); \n go:=length(t)-abs(length(gg1)-length(gg2));\n if (go mod 2<>0)or(go<0) then\n begin\n writeln('Impossible');\n exit;\n end else\n begin \n if (length(gg1)0 then gg1:=gg1+t[i] else gg2:=gg2+t[i];\n writeln(gg1,'|',gg2);\nend. \n \n \n \n \n \n "}, {"source_code": "//382 A\n\nvar\n\ta,b,temp : string;\n\tkanan,kiri : longint;\n\t\nfunction min(a,b : longint): longint;\nbegin\n\tif(a > b) then min := b\n\telse min := a;\nend;\n\nfunction max(a,b : longint) : longint;\nbegin\n\tif(a > b) then max := a\n\telse max := b;\nend;\n\t\nbegin\n\treadln(a); readln(b);\n\tkiri := pos('|',a) - 1;\n\tkanan := length(a) - pos('|',a);\n\tif((length(a)-1+ length(b)) mod 2 = 1) then begin\n\t\twriteln('Impossible');\n\t\thalt(0);\n\tend else if(min(kanan,kiri) + length(b) < max(kanan,kiri)) then begin\n\t\twriteln('Impossible');\n\t\thalt(0);\n\tend else if(kiri < kanan) then begin\n\t\ttemp := b;\n\t\tdelete(temp,kanan-kiri+1,length(temp)-kanan+kiri);\n\t\tdelete(b,1,kanan-kiri);\n\t\tinsert(temp,a,1);\n\tend else begin\n\t\ttemp := b;\n\t\tdelete(temp,kiri-kanan+1,length(temp)-kiri+kanan);\n\t\tdelete(b,1,kiri-kanan);\n\t\tinsert(temp,a,length(a)+1);\n\tend;\n\ttemp := b;\n\tdelete(temp,length(temp) div 2 + 1,length(temp) div 2);\n\tdelete(b,1,length(b) div 2);\n\tinsert(temp,a,1);\n\tinsert(b,a,length(a)+1);\n\twriteln(a);\nend.\t"}, {"source_code": "{$MODE OBJFPC}\nprogram P382A;\nconst\n fin='';\n fou='';\nvar\n s,x:ansistring;\n n_L,n_R:longint;\n fi,fo:text;\n \nprocedure enter();\n begin\n assign(fi,fin);reset(fi);\n readln(fi,s);\n readln(fi,x);\n close(fi);\n end;\n \nfunction min(x,y:longint):longint;\n begin\n if (xy) then exit(x)\n else exit(y);\n end;\n \nprocedure solve();\n var\n i,p:longint;\n c:boolean=false;\n begin\n for i:=1 to length(s) do\n if (s[i]='|') then\n begin\n p:=i;\n c:=true;\n end\n else\n if (c) then\n inc(n_R)\n else\n inc(n_L);\n assign(fo,fou);rewrite(fo);\n if (odd(length(x)+n_R-n_L)) or (length(x)+n_R-n_L<0) or (length(x)+n_L-n_R<0) then\n write(fo,'Impossible')\n else\n begin\n for i:=1 to p-1 do write(fo,s[i]);\n for i:=1 to ((length(x)+n_R-n_L) div 2) do write(fo,x[i]);\n write(fo,'|');\n for i:=p+1 to length(s) do write(fo,s[i]);\n for i:=((length(x)+n_R-n_L) div 2+1) to length(x) do write(fo,x[i]);\n end;\n close(fo);\n end;\n \nbegin\n enter();\n solve();\nend."}, {"source_code": "program v;\nvar s,b:string;\nk,k1,k2,i,o:integer;\nbegin\nreadln(s);\nreadln(b);\nfor i:=1 to length(s)do\nif s[i]='|' then\nk:=i;\nk1:=k-1;\nk2:=length(s)-k;\no:=(abs(k1-k2));\nif (o>length(b))or((length(b)-o) mod 2=1) then\nbegin\nwriteln('Impossible');\nhalt(0);\nend else\nif k1>k2 then\nbegin\nfor i:=1 to (length(b)-o)div 2 do\nwrite(b[i]);\nwrite(s);\nfor i:=(length(b)-o)div 2+1 to length(b) do\nwrite(b[i]);\nend else\n\nbegin\nfor i:=(length(b)-o)div 2+1 to length(b) do\nwrite(b[i]);\nwrite(s);\nfor i:=1 to (length(b)-o)div 2 do\nwrite(b[i]);\nend;\nend.\n"}, {"source_code": "uses math;\nvar a,b,c,x,y,i,j,z,z1,z2:longint;\n s,v:ansistring;\n begin\n readln(S);\n readln(v);\n\n z1:=pos('|',s);\n z2:=z1;\n z:=z1;\n for i:=1 to z-1 do\n inc(x);\n for i:=z+1 to length(S) do\n inc(y);\n z:=length(v);\n a:=min(x,y);\n b:=max(y,x);\n while (a<>b) or (z>0) do\n begin\n if ab) and (z>0) then Write('Impossible') else\n begin\n for i:=1 to z1-1 do\n begin\n write(s[i]);\n dec(A);\n end;\n\n for i:=1 to a do\n begin\n write(v[i]);\n\n end;\n write('|');\n for i:=z2+1 to length(S) do\n begin\n write(s[i]);\n dec(b);\n end;\n for i:=a+1 to length(v) do\n write(v[i]);\n end;\n end."}, {"source_code": "var\n s,f,s1 : string;\n i,k,r,f1 : longint;\nbegin\n // assign(input,'382A.INP'); reset(input);\n // assign(output,'328A.OUt'); rewrite(output);\n readln(s);\n readln(f);\n\n if (length(s) - 1 + length(f)) mod 2 <> 0 then\n writeln('Impossible')\n else\n begin\n r := length(f);\n for i := 1 to length(f) do\n begin\n k := pos('|',s);\n if k - 1 > length(s) - k then\n begin\n insert(f[i],s,k + 1);\n dec(r);\n k := pos('|',s);\n if (k - 1 = length(s) - k) and (r = 0) then break;\n end\n else\n if k - 1 < length(s) - k then\n begin\n k := pos('|',s);\n insert(f[i],s,k - 1);\n dec(r);\n if (k - 1 = length(s) - k) and (r = 0) then break;\n end\n else\n if (k - 1 = length(s) - k) and (r > 0) then\n begin\n insert(f[i],s,k - 1) ;\n dec(r);\n if (r = 0) and (k - 1 = length(s) - k) then break;\n end;\n end;\n\n k := pos('|',s);\n if k - 1 = length(s) - k then\n writeln(s)\n else\n writeln('Impossible');\n end ;\n\nend.\n"}, {"source_code": "var s,a:string;\n l,r,x,i:integer;\nbegin\n readln(s);\n l:=pos('|',s)-1;\n r:=length(s)-l-1;\n readln(a);\n x:=length(a);\n if ((l+r+x)mod 2=1)or(x+rz)or(abs(k-m)mod 2<>z mod 2)then begin\n writeln('Impossible');\n exit;\n end;\n p:=(k+m+z)div 2;\n for i:=1 to p-k do s:=c[i]+s;\n for i:=p-k+1 to z do s:=s+c[i];\n writeln(s);\n end.\n"}, {"source_code": "var\n s,t : ansistring;\n x1,x2 : longint;\nbegin\n readln(s);\n readln(t);\n x1:=pos('|',s)-1; x2:=length(s)-pos('|',s);\n while length(t) > 0 do begin\n if x1 < x2 then begin inc(x1); insert(t[1],s,1); end else begin inc(x2); s:=s+t[1]; end;\n delete(t,1,1);\n end;\n if x1 <> x2 then writeln('Impossible') else writeln(s);\nend."}, {"source_code": "program z12;\nvar s1,s2,cop:string;\n ch:char;\n dl1,dl2,dl3,i:integer;\nbegin\ns1:='';s2:='';\nread(ch);\nwhile ch<>'|' do\n begin\n s1:=s1+ch;\n read(ch);\n end;\nwhile not eoln do\n begin\n read(ch);\n s2:=s2+ch;\n end;\nreadln;\nreadln(cop);\ndl1:=length(s1);\ndl2:=length(s2);\ndl3:=length(cop);\nif (abs(dl1-dl2)<=dl3) and ((dl1+dl2+dl3) mod 2=0) then\n begin\n while length(s1)<>(dl1+dl2+dl3) div 2 do\n begin\n inc(i);\n s1:=s1+cop[i];\n end;\n while length(s2)<>(dl1+dl2+dl3) div 2 do\n begin\n inc(i);\n s2:=s2+cop[i];\n end;\n writeln(s1,'|',s2);\n end\nelse\n writeln('Impossible');\nend."}, {"source_code": "var\n S1,S:String;\n x,uk,Kol1,Kol2,i,Kol:longint;\n f:Boolean;\n\nbegin\n Readln(S1);\n Readln(S);\n i:=1;\n While S1[i]<>'|' do Inc(i);\n Kol1:=i-1;\n Kol2:=length(S1)-i;\n Kol:=length(S);\n // Ans:=S1;\n f:=true;\n uk:=1;\n While f do begin\n if Kol1<=Kol2 then begin\n Inc(kol1);\n S1:=S[uk]+S1;\n Inc(uk);\n end else begin inc(kol2); S1:=S1+S[uk]; Inc(uk);end;\n if uk>length(S) then f:=false;\n end;\n if (Kol1<>Kol2)or(length(S1) mod 2 = 0) then Write('Impossible') else Write(S1);\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n s,t:ansistring;\n v1,v2,i:longint;\nbegin\n readln(s);\n v1:=pos('|',s)-1;\n v2:=length(s)-v1-1;\n readln(t);\n for i:=0 to length(t) do\n if (v1+i=v2+length(t)-i) then\n begin\n writeln(copy(t,1,i),s,copy(t,i+1,length(t)-i));\n halt(0);\n end;\n writeln('Impossible');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar\n a: array[1..1000000] of integer;\n i, j, n, m, k, l, r, q, c: integer;\n s, t: string;\nbegin\n readln(s);\n readln(t);\n n := length(s);\n m := length(t);\n k := pos('|',s);\n l := k-1;\n r := n - k;\n q := max(l, r) - min(l, r);\n\n if (odd(m-q)) or (q >m) then\n begin\n writeln('Impossible');\n exit;\n end;\n c := (m-q) div 2;\n if (l < r) then\n begin\n write(copy(t,1,q+c));\n write(s);\n write(copy(t,q+c+1, m));\n readln;\n exit;\n end;\n write(copy(t,1,c));\n write(s);\n write(copy(t,c+1, m));\n readln;\n readln;\nend."}, {"source_code": " var q,s:string;\n a,b,n1,m,k,n:longint;\n\n\nbegin\nreadln(s);\nreadln(q);\nn:=length(s);\nk:=pos('|',s)-1;\nm:=n-k-1;\na:=abs(k-m);\nn1:=length(q);\nb:=n1-a;\nif (b<0) or(odd(b))then\nwrite('Impossible') else\nbegin\nif k0 do begin\n if length(s1) t then begin \n Write ('Impossible');\n Halt;\n end Else begin \n t2:=t-(k2-k1);\n If t2 mod 2 = 1 then begin \n Write ('Impossible');\n Halt;\n end Else begin \n For i:= 1 to (k2-k1) do begin\n q1:=q1+s2[i];\n j:=i;\n end;\n If t2 = 0 then begin\n Writeln (q1,'|',q2);\n halt;\n end;\n t3:=t2 div 2;\n y:=t3;\n x:=j+1;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n end; \n end; \n end;\n \n If k1>k2 then begin\n If k1-k2 > t then begin \n Write ('Impossible');\n Halt;\n end Else begin \n t2:=t-(k1-k2);\n If t2 mod 2 = 1 then begin \n Write ('Impossible');\n Halt;\n end Else begin \n For i:= 1 to (k1-k2) do begin\n q2:=q2+s2[i];\n j:=i+1;\n end;\n If t2 = 0 then begin\n Writeln (q1,'|',q2);\n halt;\n end;\n t3:=t2 div 2;\n y:=t3;\n x:=j;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n end; \n end; \n end;\n \n If k1=k2 then begin\n\n t2 := t;\n If t2 mod 2 = 1 then begin\n Write ('Impossible');\n Halt;\n end;\n \n\n t3:=t2 div 2;\n y:=t3;\n x:=1;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n \n end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar a,b:string;\n i,p,r,j,count,p1,p2,need, needa, needb:longint;\n\nprocedure outt;\nbegin\n writeln('Impossible');\n close(output);\n halt;\n end;\n\nbegin\n//assign(input,'input.txt');\n//assign(output,'output.txt');\n//reset(input);\n//rewrite(output);\n\nreadln(a);\np:=pos('|',a);\n//writeln(p);\np1:=0; p2:=0;\nfor i:=1 to p-1 do inc(p1);\nfor i:=p+1 to length(a) do inc(p2);\n//writeln(p1,' ',p2);\n//if (p1<>p2) then outt;\nreadln(b);\nif ((p1+p2+length(b)) mod 2=1) then outt;\nneed:=(p1+p2+length(b)) div 2;\nj:=1;\nneeda:=need-p1;\nneedb:=need-p2;\n//if (needa<>needb) then outt;\nfor i:=1 to needb do\n begin\n if (j>length(b)) then break;\n insert(b[j],a,p+1);\n inc(j);\n end;\n\nfor i:=1 to needa do\n begin\n if (j>length(b)) then break;\n insert(b[j],a,p-1);\n inc(j);\n end;\np:=pos('|',a);\np1:=0;\np2:=0;\nfor i:=1 to p-1 do inc(p1);\nfor i:=p+1 to length(a) do inc(p2);\nif (p1<>p2) then outt;\nwriteln(a);\n\n\n\n//close(input);\n//close(output);\nend.\n"}, {"source_code": "Var s,s1:string;\n a,b,k,i,l,c:Longint;\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='|' then inc(l);\n if l=0 then inc(a);\n if (l=1)and(s[i]<>'|') then inc(b);\n end;\n readln(s1);\n k:=b-a;\n if abs(k)>length(s1) then begin\n writeln('Impossible');\n exit;\n end;\n if k<0 then begin\n for i:=1 to abs(k) do\n begin\n s:=s+s1[1];\n delete(s1,1,1);\n end;\n end;\n if k>0 then begin\n for i:=1 to k do\n begin\n s:=s1[1]+s;\n delete(s1,1,1);\n end;\n end;\n if length(s1) mod 2=1 then begin writeln('Impossible'); exit; end\n else begin\n for i:=1 to length(s1) div 2 do\n begin\n s:=s+s1[length(s1)-i+1];\n s:=s1[i]+s;\n end;\n writeln(s);\n end;\n end."}, {"source_code": "var\ns:string;\nn,k,ans,top,center :longint;\na :array of char;\n\nprocedure intap;\nvar\ni :longint;\nbegin\ntop:=0;\nfor i:=1 to 10000 do begin\nSetlength(a,i+1);\nread(a[i]);\nif a[i]='|' then center:=i;\nif ord(a[i]) <65 then break;\nInc(top);\n\nend;\nreadln();\nread(s);\nAns:= Abs((top-center )-(center-1)) ;\n\nif (Length(s) 0) then write('Impossible')\nelse begin\nif top-center > center-1 then k:=2 else k:=1;\nif k=2 then begin\n for i:=1 to center-1 do write(a[i]);\n for i:=1 to Ans do write(s[i]);\n if Ansb then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nbegin\n { reset(input,'input.txt');close(input);\n rewrite(output,'output.txt');close(output);\n }\n readln(sss1);\n readln(sss2);\nn:=length(sss1); n1:=length(sss2);\nfor i:=1 to n do if sss1[i]='|' then k:=i;\nif not odd(n+n1) then begin write('Impossible'); goto 1 ; end;\nif n1+k-1j)or(length(s1)-pos('|',s1)>j)\n then writeln('Impossible')\n else begin\n j:=j-(pos('|',s1)-1);\n for i:=1 to j do\n s1:=s2[i]+s1;\n for i:=j+1 to length(s2) do\n s1:=s1+s2[i];\n writeln(s1);\n end;\n end;\nend."}, {"source_code": "var llength,rlength:shortint;\n\tx,s:string;\n\tl,r:array[1..100] of char;\n\ti,j:longint;\nbegin\n\treadln(s);\n\ti:=1;\n\twhile(s[i]<>'|') do begin\n\t\tl[i]:=s[i];\n\t\tinc(i);\n\tend;\n\tllength:=i-1;\n\tfor i:=llength+2 to length(s) do r[i-llength-1]:=s[i];\n\trlength:=length(s)-(llength+1);\n\treadln(x);\n//\twriteln(llength,rlength,length(x));\n\tif ((abs(rlength-llength)>length(x)) or ((length(x)-(rlength-llength)) mod 2 = 1 )) then begin\n\t\twrite('Impossible');\n\t\thalt;\n\tend;\n\tfor i:=1 to llength do write(l[i]);\n\tfor i:=1 to (llength+rlength+length(x)) div 2 - llength do write(x[i]);\n\tj:=(llength+rlength+length(x)) div 2 - llength;\n\twrite('|');\n\tfor i:=1 to rlength do write(r[i]);\n\tfor i:=1 to (llength+rlength+length(x)) div 2 - rlength do write(x[j+i]);\nend."}, {"source_code": "var dole,raz,l,d,i,o,po:longint;\na,b,pre,posle,kon:string;\nbegin\nreadln (a);\nreadln (b);\nfor i:=1 to length(a) do\nbegin\n if a[i]='|' then\n o:=1\n else\n if o=0 then\n begin\n l:=l+1;\n pre:=pre+a[i];\n end\n else\n begin\n d:=d+1;\n posle:=posle+a[i];\n end;\nend;\ndole:=length(b);\nif (dole+l+d) mod 2=1 then\nwriteln ('Impossible')\nelse\nbegin\n raz:=abs(l-d);\n if raz>dole then\n writeln ('Impossible')\n else\n begin\n kon:=pre+b+posle;\n po:=length(kon) div 2+1;\n insert('|',kon,po);\n end;\nend;\nwriteln (kon);\nend."}, {"source_code": "program Project2;\n{$APPTYPE CONSOLE}\nvar m:array[1..1250] of integer; \nvar n,d,i,max,j:integer;\nvar s,ds:string;\nbegin\n readln(s);\n readln(ds);\n while ds<>'' do\n begin\n i:=pos('|',s)-1;\n if ikp then writeln ('Impossible')\nelse writeln (rl,'|',rp);\nend.\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n i, n, m, k: integer;\n s, t: string;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(s);\n\n readln(t);\n\n for i := 1 to length(s) do begin\n if (s[i] = '|') then begin\n n := i - 1;\n m := length(s) - i;\n end;\n end;\n\n if (abs(n - m) > length(t)) or (abs(n - m) mod 2 <> length(t) mod 2) then begin\n writeln('Impossible');\n halt;\n end;\n\n k := max(0, m - n) + (length(t) - abs(n - m)) div 2;\n\n for i := 1 to n do\n write(s[i]);\n\n for i := 1 to k do\n write(t[i]);\n\n for i := n + 1 to length(s) do\n write(s[i]);\n\n\n for i := k + 1 to length(t) do\n write(t[i]);\n\n\nend.\n"}, {"source_code": "uses sysutils;\nvar a,b,s:string;\n\tt:integer;\n \nbegin\n\treadln(s);\n\tt:=pos('|',S);\n\ta:=copy(s,1,t-1);\n\tdelete(s,1,t);\n\tb:=s;\n\treadln(s);\n\twhile s<>'' do\n\tbegin\n\t\tif length(a) < length(b) then a:=a+s[1]\n\t\telse\n\t\t\tb:=b+s[1];\n\t\tdelete(s,1,1);\n\tend;\n\tif length(a)<>length(b) then write('Impossible')\n\telse\n\t\twrite(a,'|',b);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n t=record\n i,x,cnt:integer;\n end;\nvar\n a,b,c:array[1..100100]of integer;\n n,i,j,k,l,r,m,x,y,max,min,d:integer;\n cnt,sum,p,kol:int64;\n q,w,e:boolean;\n s,s1:string;\n\nbegin\n readln(s);\n readln(s1);\n l:=0;\n r:=0;\n q:=false;\n sum:=length(s)-1+length(s1);\n if(sum mod 2<>0)then\n begin\n writeln('Impossible');\n exit;\n end;\n for i:=1 to length(s) do\n begin\n if not(q)and(s[i]<>'|')then\n inc(l)\n else if(s[i]='|')then\n begin\n q:=true;\n x:=i;\n end\n else if(q)then\n inc(r);\n end;\n if(length(s1)'|' do begin k:=k+1; i:=i+1; end;\n s1:=copy(s,1,k);\n s2:=copy(s,k+2,length(S)-k-1);\n readln(s3);\n dif:=length(s1)-length(s2);\n if (length(s3)0) then write('Impossible')\n else begin\n i:=1;\n nr:=length(s3);\n while nr <>0 do begin\n if dif>=0 then begin\n s2:=s2+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(S2);\n end\n else\n if dif<0 then begin\n s1:=s1+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(s2);\n end;\n end;\n write(s1,'|',s2);\n\n end;\n\n\nend.\n"}, {"source_code": "var s,s2,s3:string; r,i,l,n,k,sum:integer;\nbegin\n// reset(input,'input.txt');\n// assign(output,'output.txt');\n readln(s);\n s2:=s;\n l:=0;\n r:=0;\n n:=length(s);\n i:=1;\n while s[i]<>'|' do\n inc(i);\n l:=i-1;\n r:=n-i;\n read(s);\n s3:=s;\n n:=length(s);\n sum:=n+r+l;\n if (sum)mod 2<>0\n then write('Impossible')\n else begin\n sum:=sum div 2;\n if (sum'|' do\n begin\n write(s2[i]);\n inc(i);\n end;\n k:=i;\n i:=1;\n while llength(s2) do\n begin\n inc(k);\n write(s2[k]);\n end;\n while i<=length(s3) do\n begin\n write(s3[i]);\n inc(i);\n end;\n end;\n end;\nend.\n"}, {"source_code": "program Project2;\n{$APPTYPE CONSOLE}\nuses SysUtils;\n\nvar c: Char;\n i,j,k,l1,l2,dl,l3: integer;\n s1,s2,s3: string;\n\n\nbegin\n s1:='';\n read(c);\n while c<>'|' do\n begin\n s1:=s1+c;\n read(c);\n end;\n Readln(s2);\n L1:=Length(s1);\n L2:=Length(s2);\n Readln(s3);\n l3:=Length(s3);\n dl:=Abs(L1-L2);\n if (l3>=dl)and ((l1+l2+l3) mod 2=0) then\n begin\n for i:=1 to l3 do\n if Length(s1)0) or (abs(d)>c) then begin writeln('Impossible');halt;end;\n\nfor i:=1 to length(b) do\nif length(t1)b then max:=a\n else max:=b;\nend;\nfunction min(a,b:longint):longint;\nbegin\n if alength(ss) then s:='Impossible'\n else\n begin\n if kkk then\n begin\n s:=s+copy(ss,1,k-kk);\n delete(ss,1,k-kk);\n end;\n if (length(ss)>0)and(length(ss) mod 2=0) then\n begin\n s:=copy(ss,1,length(ss) div 2)+s;\n delete(ss,1,length(ss) div 2);\n s:=s+ss;\n end\n else if (length(ss)>0)and(length(ss) mod 2=1) then s:='Impossible';\n end;\n writeln(s);\nend.\n"}, {"source_code": "uses math,sysutils;\nvar //a,b,c:array[1..10000] of longint;\n i,j,k,l,m,h,y,t,x,x1,y1,n:longint;\n s,s1,s2:ansistring;\nbegin\n readln(s);\n readln(s1);n:=length(s);\n for i:=1 to n do\n begin\n if s[i]='|' then\n begin\n l:=1;\n continue;\n end ;\n if l=0 then\n begin\n inc(x);\n continue;\n end;\n if l=1 then\n begin\n inc(y);\n continue;\n end;\n end;\n t:=length(s1);\n if (max(y,x)>min(y,x)+t) then\n begin\n write('Impossible');\n halt;\n end;\n if (max(x,y)-min(x,y)+t) mod 2=1 then\n begin\n write('Impossible');\n halt;\n end;\n h:=abs(x-y);\n x1:=x+(t-h)div 2;\n y1:=y+(t-h)div 2;\n if x1>y1 then inc(y1,h);\n if x10)or(l>r+x)or(l+xr do\n begin\n s := s + st[1]; r := r + 1;\n delete(st,1,1);\n end;\n while l=0) then\nbegin\n write(s2);\n if (l3>=l2) then\n begin\n o:=l3-l2;\n ss:=copy(s1,1,o);\n write(ss);\n ss:=copy(s1,o+1,p div 2);\n write(ss);\n write('|');\n write(s3);\n ss:=copy(s1,o+1+(p div 2), p div 2);\n write(ss);\n\n end\n else\n begin\n o:=l2-l3;\n ss:=copy(s1,1,o);\n s3:=s3+ss;\n\n ss:=copy(s1,o+1,p div 2);\n write(ss);\n write('|');\n write(s3);\n ss:=copy(s1,o+1+(p div 2), p div 2);\n write(ss);\n\n end;\nend\nelse\nbegin\nwrite('Impossible');\nend;\nend."}, {"source_code": "Var k1,k2,k3,sum,i:longint;\ns,s1:string;\nbegin\nreadln(s);\nk1:=pos('|',s)-1;\nk2:=length(s)-pos('|',s);\nreadln(s1);\nk3:=length(s1);\nsum:=k1+k2+k3;\nif (k1+k2+k3) mod 2<>0 then writeln('Impossible') else\nbegin\nif (k1<=sum div 2) and (k2<=sum div 2) then begin\nfor i:=1 to sum div 2-k1 do\nwrite(s1[i]);\nwrite(s);\nfor i:=sum div 2-k1+1 to length(s1) do\nwrite(s1[i]);\nend else writeln('Impossible'); end;\nend.\n\n"}, {"source_code": "uses math;\nvar s1,s2,tmp,l,r:ansistring;\n i,x,lr,ll,l2:longint;\nbegin\n readln(s1); readln(s2);\n l:='';r:='';\n for i:=1 to length(s1) do if s1[i] = '|' then begin x:=i; break; end;\n for i:=1 to x-1 do l:=l+s1[i];\n for i:=x+1 to length(s1) do r:=r+s1[i];\n ll:=length(l); lr:=length(r); l2:=length(s2);\n if (l2 >= abs(ll-lr)) and ((l2-abs(ll-lr))mod 2=0 )then begin\n tmp:='';\n for i:=l2-abs(ll-lr)+1 to l2 do tmp:=tmp+s2[i];\n if ll > lr then r:=r+tmp else l:=l+tmp;\n // writeln(tmp); writeln(l); writeln(r);\n for i:=1 to (l2 - abs(ll-lr)) div 2 do begin\n l:=l+s2[2*i-1];\n r:=r+s2[2*i]\n end;\n // writeln(l); writeln(r);\n writeln(l+'|'+r);\n halt;\n end; \n writeln('Impossible'); \nend.\n"}, {"source_code": "var s1,s2:string;\n\ti,j,t,k,r,r1,l,l2:integer;\nbegin\n\treadln(s1);\n\treadln(s2);\n\ti:=1;\n\twhile s1[i]<>'|' do\n\t\tinc(i);\n\tl:=i-1; r:=length(s1)-i;\n\tt:=length(s2);\n\tif odd(t+l+r) then begin write('Impossible'); exit; end;\n\tif abs(l-r)>t then write('Impossible')\n\telse begin\n\t\tk:=(r+l+t) div 2;\n\t\tr1:=k-r;\n\t\tl2:=k-l;\n\t\tfor j:=1 to i-1 do write(s1[j]);\n\t\tfor j:=1 to l2 do write(s2[j]);\n\t\twrite(s1[i]);\n\t\tfor j:=i+1 to length(s1) do write(s1[j]);\n\t\tfor j:=l2+1 to length(s2) do write(s2[j]);\n\tend;\nend.\n"}, {"source_code": "program codeforces_round224_a;\n\nvar\n s1, s2 : string;\n\nbegin\n readln(s1);\n readln(s2);\n while length(s2) <> 0 do\n begin\n if pos('|', s1) > (length(s1) + 1) div 2\n then s1:=s1 + s2[1]\n else insert(s2[1], s1, 1);\n delete(s2, 1, 1);\n end;\n if pos('|', s1) <> (length(s1) + 1) div 2\n then write('Impossible')\n else write(s1);\n\nend.\n"}, {"source_code": "var s1,s2:string;\n ch1,ch2:string;\n i,f,a,b:longint;\nbegin\nreadln(s1);\nreadln(s2);\nfor i:=1 to pos('|',s1)-1 do ch1:=ch1+s1[i];\nfor i:=1+pos('|',s1) to length(s1) do ch2:=ch2+s1[i];\na:=length(ch1);\nb:=length(ch2);\nwhile (s2<>'') do \n begin\n if (a>b) AND (S2<>'') then begin inc(b); ch2:=ch2+s2[1]; delete(s2,1,1); end;\n if (b>a) AND (S2<>'') then begin inc(a); ch1:=ch1+s2[1]; delete(s2,1,1); end;\n if (a=b) and (s2<>'') then begin inc(a); ch1:=ch1+s2[1]; delete(s2,1,1); end;\n end;\nif length(ch1)=length(ch2) then write(ch1,'|',ch2)\n else write('Impossible');\nend."}, {"source_code": "program A;\n{$APPTYPE CONSOLE}\n\nvar\n s1,s2,s11,s22:string;\n x,y,p,z,l,i1,i2:Integer;\n\nbegin\n Readln(s1);\n Readln(s2);\n p:=Pos('|',s1);\n s11:=copy(s1,1,p-1);\n s22:=copy(s1,p+1,length(s1)-p);\n\n\n while length(s2)>0 do begin\n if Length(s11)=Length(s22) then begin\n s11:=s11+s2[1];\n Delete(s2,1,1);\n end else begin\n if Length(s11)Length(s22) then begin\n s22:=s22+s2[1];\n Delete(s2,1,1);\n end;\n end;\n end;\n if length(s11)=length(s22) then Writeln(s11,'|',s22) \n else writeln('Impossible');\n\n\n\n\n\n // Readln;\n // Readln;\n\nend.\n"}, {"source_code": "var s,s1,s2,sg:ansistring;\n i,t1,t2:longint;\nbegin\nreadln(s);\nreadln(sg);\ni:=1;\nwhile s[i]<>'|' do inc(i);\ns1:=copy(s,1,i-1);\ns2:=copy(s,i+1,length(s)-i);\nwhile length(sg)>0 do begin\n if length(s1)>length(s2) then s2:=s2+sg[1] else s1:=s1+sg[1];\n delete(sg,1,1);end;\nif length(s1)=length(s2) then writeln(s1+'|'+s2) else writeln('Impossible');\nend.\n"}], "negative_code": [{"source_code": "var\n s,s1:ansistring; \n k,x,y:longint;\nbegin\n readln(s);\n readln(s1);\n k:=pos('|',s);\n x:=length(copy(s,1,k-1));\n y:=length(copy(s,k+1,length(s)));\n if abs(x-y)<>length(s1) then \n begin\n writeln('Impossible');\n halt;\n end;\n if x '|' then inc(len) else break;\n if length(s) - len - 1 = len then exit(true);\n exit(false);\nend;\nbegin\n readln(s1); readln(s2);\n if check(s1+s2) = true then writeln(s1+s2) else\n if check(s2+s1) = true then writeln(s2+s1) else\n writeln('Impossible');\nend.\n"}, {"source_code": "var t,n,i:integer;a,b,t1,t2:string;\nbegin readln(a);readln(b);n:=length(a);\nt:=pos('|',a);\n\n\nif (length(a)-1+length(b)) mod 2=1 then begin write('Impossible');halt;end;\nt2:=copy(a,t+1,n);\nt1:=copy(a,1,t-1);\nfor i:=1 to length(b) do\nif length(t1)= abs(s1-s2)) and ((length(ans) - abs(s1-s2)) mod 2 = 0) then\n begin\n if s1>s2 then\n begin\n for i:=1 to (s1-s2) do\n begin\n x:=x + ans[i];\n end;\n Delete(ans,1,(s1-s2));\n \n for i:=1 to length(ans) do\n if odd(i) then x:=ans[i] + x else x:=x + ans[i];\n \n Writeln(x);\n end else\n if s2>s1 then\n begin\n for i:=1 to (s2-s1) do\n begin\n x:=ans[i] + x;\n end;\n Delete(ans,1,(s2-s1));\n\n for i:=1 to length(ans) do\n if odd(i) then x:=ans[i] + x else x:=x + ans[i];\n\n Writeln(x);\n end else\n begin\n for i:=1 to length(ans) do\n if odd(i) then x:=ans[i] + x else x:=x + ans[i];\n end;\n end else Writeln('Impossible');\nend."}, {"source_code": "var s, t : string;\n L, R, i : longint;\nbegin\n readln(s);\n L := length(copy(s,1,pos('|',s)-1));\n R := length(s)-L-1;\n readln(t); \n If L = R then\n begin\n If odd(length(t)) then writeln('Impossible')\n else\n begin\n write(copy(s,1,L));\n write(copy(t,1,length(t) div 2));\n write('|');\n write(copy(s,L+2,R));\n writeln;\n end; \n end;\n If L < R then\n begin\n If (length(t) < R-L) or odd(length(t)-R+L) then writeln('Impossible')\n else\n begin\n write(copy(s,1,L));\n write(copy(t,1,R-L));\n write(copy(t,R-L+1,(length(t)-R+L) div 2));\n write('|');\n write(copy(s,L+2,R));\n write(copy(t,R-L+(length(t)-R+L) div 2+1,(length(t)-R+L) div 2));\n writeln;\n end;\n end;\n If R < L then\n begin\n If (length(t) < L-R) or odd(length(t)-L+R) then writeln('Impossible')\n else\n begin\n write(copy(s,1,L));\n write(copy(t,1,(length(t)-L+R) div 2));\n write('|');\n write(copy(s,L+2,R));\n write(copy(t,(length(t)-L+R) div 2+1,L-R));\n write(copy(t,(length(t)-L+R) div 2+L-R+1,(length(t)-L+R) div 2));\n writeln;\n end;\n end;\nend."}, {"source_code": "program scalse;\nvar\n s,t,res:string;\n lens,lent,i,j,k,left,right,pos:integer;\nbegin\n readln(s);\n readln(t);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n if(s[i]='|')then\n begin\n pos:=i;\n break;\n end\n else\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(left);\n end;\n for i:=pos+1 to lens do\n begin\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(right);\n end;\n if(left+lent=right)then insert(t,s,left+1)\n else if(left=right+lent) then insert(t,s,lens+1)\n else s:='Impossible';\n writeln(s);\nend.\n"}, {"source_code": "var\ni,j,c,d,e,b,n:longint;\ns,s1,s2,s3:string;\nbegin\nreadln(s);\nreadln(s1);\nj:=pos('|',s);\nc:=j-1;\ns2:=copy(s,1,j-1);\nd:=length(s)-j;\ns3:=copy(s,j+1,length(s));\nif c+length(s1)=d then begin writeln(s1+s2,'|',s3);exit;end;\nif d+length(s1)=c then begin writeln(s2,'|',s3+s1);exit;end;\nwriteln('Impossible');\nend."}, {"source_code": "var\ni,j,c,d,e,b,n:longint;\ns,s1,s2,s3:string;\nbegin\nreadln(s);\nreadln(s1);\nj:=pos('|',s);\nc:=j-1;\ns2:=copy(s,1,j-1);\nd:=length(s)-j;\ns3:=copy(s,j+1,length(s));\nif c+length(s1)=d then begin writeln(s1+s2,'|',s3);exit;end;\nif d+length(s1)=c then begin writeln(s2,'|',s3+s1);exit;end;\nwriteln('Impossible');\nend."}, {"source_code": "var s,f,s2,s1:string;\nx:longint;\nbegin\nreadln(s);\nreadln(f);\nx:=pos('|',s);\ns1:=copy(s,1,x-1);\ns2:=copy(s,x+1,length(s)-x+1);\nwhile length(f)<>0 do begin\n if length(s1)k2 then if k2+length(s1)=k1 then writeln(s,s1)\n else writeln('Impossible')\n else if k1+length(s1)=k2 then writeln(s1,s)\n else writeln('Impossible');\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "Program azkaban;\nvar s,s1,s2,s3 : string;\n k,i,dif : longint;\nbegin readln(S);\n i:=1;\n while s[i]<>'|' do begin k:=k+1; i:=i+1; end;\n s1:=copy(s,1,k);\n s2:=copy(s,k+2,length(S)-k-1);\n readln(s3);\n dif:=length(s1)-length(s2);\n if length(S3)0) and (dif=0) then write('Impossible')\n else begin\n if dif>0 then begin\n write(s1,'|');\n for i:=1 to dif do write(s2,s3[i]);\n end\n else if dif<0 then begin\n for i:=1 to abs(dif) do write(s3[i]);\n write(s1);\n write('|',s2); end;\n end;\nend."}, {"source_code": "program project1;\n\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n writeln('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n writeln('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "var s1,s2:string;\n i:byte;\n\nBEGIN\nreadln(s1);readln(s2);\ni:=1;\nwhile s1[i]<>'|' do i:=i+1;\n//if length(s1)-i=i-1 then begin write('Impossible');halt;end;\nwhile ((length(s1)-i<>i-1) or (length(s2)>1))and(length(s2)>0) do\n begin\n if length(s1)-i=i-1 then\n begin\n s1:=s2[1]+s1+s2[2];\n delete(s2,1,2);\n i:=i+1;\n end\n else if length(s1)-ii-1 then\n begin\n s1:=s2[1]+s1;\n delete(s2,1,1);\n i:=i+1;\n end;\n end;\nif odd(length(s1)) and (i=length(s1) div 2+1) then write(s1) else write('Impossible');\nEND.\n\n"}, {"source_code": "program project1;\n\n{$mode objfpc}{$H+}\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n write('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n write('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n write(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "var s1,s2:string;\n ch1,ch2:string;\n i,f:integer;\nbegin\nreadln(s1);\nreadln(s2);\nf:=0;\nfor i:=1 to pos('|',s1)-1 do ch1:=ch1+s1[i];\nfor i:=1+pos('|',s1) to length(s1) do ch2:=ch2+s1[i];\n//if (length(ch1)=length(ch2)) and (length(s2) mod 2<>0) then begin write('Impossible'); halt; end; \nwhile (length(ch1)<>length(ch2)) and (s2<>'') do \n begin \n if (length(ch1)'') then \n begin\n ch1:=ch1+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n if (length(ch1)>length(ch2)) and (s2<>'') then \n begin\n ch2:=ch2+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n end;\nif (f=1) and (length(ch1)=length(ch2)) then write(ch1,'|',ch2)\n else write('Impossible'); \nend."}, {"source_code": "program form;\nvar s, ss: string;\nn,m,i,j,k: longint;\n\n\nbegin\n//assign (input, 'input.txt');reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s);\nfor i:= 1 to length (s) do\nif s[i] = '|' then break;\nreadln (ss);\n\nif (length (s) + length (ss)) mod 2 =0 then\nbegin writeln ('Impossible'); halt; end;\n\nm:= (length (s) + length (ss)) div 2;\nif (i-1<= m) and (length (s)-i <=m)\nthen\nelse begin writeln ('Impossible'); halt; end;\nj:= 1;\nfor k:= 1 to m do\nbegin\nif (ki then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i+1 to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to ((length(t)-d)div 2+d) do write(t[i]);\nwrite(s);\nfor i:=((length(t)-d)div 2+d) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "program scalse;\nvar\n s,t:string;\n lens,lent,i,left,right,pos:longint;\nbegin\n readln(s);\n readln(t);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n if(s[i]='|')then\n begin\n pos:=i;\n break;\n end\n else\n if(s[i]<>'')then inc(left);\n end;\n right:=lens-pos;\n if(left+lent=right)then insert(t,s,left+1)\n else\n begin\n if(right+lent=left)then insert(t,s,lens+1)\n else\n S:='Impossible';\n end;\n writeln(s);\nend."}, {"source_code": "var i,t1,t2,q,r :longint;\n s1,s2,ss1,ss2,ss:string;\n ok:boolean;\n begin\n readln(s1);\n readln(s2);\n ok:=false;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='|') then begin ok:=true; continue; end;\n if ok then begin inc(t2); ss2:=ss2+s1[i] end\n else begin inc(t1); ss1:=ss1+s1[i];end;\n end;\n\n if t1length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss1:=ss1+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss1:=ss1+s2[i];\n for i:=r+1 to length(s2) do\n ss2:=ss2+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end\n else begin\n q:=t1-t2;\n if q>length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss2:=ss2+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss2:=ss2+s2[i];\n for i:=q+r+1 to length(s2) do\n ss1:=ss1+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end;\n end."}, {"source_code": "uses math,sysutils;\nvar //a,b,c:array[1..10000] of longint;\n i,j,k,l,m,h,y,t,x,x1,y1,n:longint;\n s,s1,s2:ansistring;\nbegin\n readln(s);\n readln(s1);n:=length(s);\n for i:=1 to n do\n begin\n if s[i]='|' then\n begin\n l:=1;\n continue;\n end ;\n if l=0 then\n begin\n inc(x);\n continue;\n end;\n if l=1 then\n begin\n inc(y);\n continue;\n end;\n end;\n t:=length(s1);\n if (max(y,x)>min(y,x)+t) then\n begin\n write('Impossible');\n halt;\n end;\n if (max(x,y)-min(x,y)+t) mod 2=1 then\n begin\n write('Impossimle');\n halt;\n end;\n h:=abs(x-y);\n x1:=x+(t-h)div 2;\n y1:=y+(t-h)div 2;\n if x1>y1 then inc(y1,h);\n if x1'|') do inc(l);\nr:=length(a)-l-1;num:=length(a)-1+length(b);\nif ((num mod 2=1)or (r-l>length(b))) then begin write('Impossible');halt;end;\nfor i:=((length(b)+r-l)div 2) downto 1 do a:=b[i]+a;\nfor i:=((length(b)+r-l)div 2) +1 to length(b) do a:=a+b[i];\nwriteln(a);\nend.\n"}, {"source_code": "program form;\nvar s, ss: string;\nn,m,i,j,k: longint;\n\n\nbegin\n//assign (input, 'input.txt');reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s);\nfor i:= 1 to length (s) do\nif s[i] = '|' then break;\nreadln (ss);\n\nif (length (s) + length (ss)) mod 2 =0 then\nbegin writeln ('Impossible'); halt; end;\n\nm:= (length (s) + length (ss)) div 2;\nif (i-1<= m) and (length (s)-i <=m)\nthen\nelse begin writeln ('Impossible'); halt; end;\nj:= 1;\nfor k:= 1 to m do\nbegin\nif (ki then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i+1 to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}, {"source_code": "var s,p:string; a,b,c:byte;\nbegin\n readln(s); readln(p);\n a:=pos('|',s)-1; b:=length(s)-pos('|',s); c:=length(p);\n if (c+a=b) then writeln(p,s) else\n if (a=b+c) then writeln(s,p) else\n if (a+b=c) then writeln(copy(p,1,b),s,copy(p,b+1,a)) else\n if ((a=b) and (c mod 2=0)) then\n writeln(copy(p,1,c div 2),s,copy(p,c div 2+1,c div 2)) else\n if ((a+b+c) mod 2=0) then \n writeln(copy(p,1,(a+b+c) div 2-a),s,copy(p,(a+b+c) div 2-a+1,(a+b+c) div 2-b))\n else writeln('Impossible');\nend."}, {"source_code": " var s,s1:ansistring;\n i,k1,k2:longint;\n u:byte;\n\n\nbegin\n readln(s);\n u:=0; s:='';s1:=''; k1:=0;k2:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='|' then u:=1;\n if s[i] in ['A'..'Z'] then if u=0 then inc(k1)\n else inc(k2);\n end;\n readln(s1);\n\n if k1>k2 then if k2+length(s1)=k1 then writeln(s,s1)\n else writeln('Impossible')\n else if k1+length(s1)=k2 then writeln(s1,s)\n else writeln('Impossible');\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "program scalse;\nvar\n s,t:string;\n lens,lent,i,left,right,pos:longint;\nbegin\n readln(s);\n readln(t);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n if(s[i]='|')then\n begin\n pos:=i;\n break;\n end\n else\n if(s[i]<>'')then inc(left);\n end;\n right:=lens-pos;\n if(left+lent=right)then insert(t,s,left+1)\n else\n begin\n if(right+lent=left)then insert(t,s,lens+1)\n else\n S:='Impossible';\n end;\n writeln(s);\nend."}, {"source_code": "var s,p:string; a,b,c:byte;\nbegin\n readln(s); readln(p);\n a:=pos('|',s)-1; b:=length(s)-pos('|',s); c:=length(p);\n if (c+a=b) then writeln(p,s) else\n if (a=b+c) then writeln(s,p) else\n if (a+b=c) then writeln(copy(p,1,b),s,copy(p,b+1,a)) else writeln('Impossible');\nend."}, {"source_code": "var\n s,s1:ansistring; \n k,x,y:longint;\nbegin\n readln(s);\n readln(s1);\n k:=pos('|',s);\n x:=length(copy(s,1,k-1));\n y:=length(copy(s,k+1,length(s)));\n if abs(x-y)<>length(s1) then \n begin\n writeln('Impossible');\n halt;\n end;\n if xk2+k3) or (k2>k3+k1) then writeln('Impossible')\n else begin\n while k3<>0 do\n begin\n if k1>k2 then begin s:=s+s1[i]; inc(i); dec(k3); end\n else begin write(s1[i]); inc(i); dec(k3); end;\n end;\n write(s);\n end;\n\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to (length(t)div 2+d) do write(t[i]);\nwriteln(s);\nfor i:=(length(t)div 2+d+1) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to ((length(t)-d)div 2+d) do write(t[i]);\nwrite(s);\nfor i:=(length(t)div 2+d) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "program project1;\n\n{$mode objfpc}{$H+}\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n write('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n write('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n write(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "program scalse;\nvar\n s,t,res:string;\n lens,lent,i,j,k,left,right,pos:integer;\nbegin\n readln(s);\n readln(t);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n if(s[i]='|')then\n begin\n pos:=i;\n break;\n end\n else\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(left);\n end;\n for i:=pos+1 to lens do\n begin\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(left);\n end;\n if(left+lent=right)then\n begin\n for i:=1 to left do\n begin\n if((s[i]='')or(s[i]=' '))then continue\n else\n res:=res+s[i];\n end;\n for j:=1 to lent do\n res:=res+t[j];\n for k:=pos to lens do\n res:=res+s[k];\n end\n else if(left=right+lent) then\n begin\n for i:=1 to lens do\n res:=res+s[i];\n for j:=1 to lent do\n res:=res+t[j];\n end\n else res:='Impossible';\n writeln(res);\nend.\n"}, {"source_code": "program project1;\n\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n writeln('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n writeln('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "program v;\nvar s,b:string;\nk,k1,k2,i,o:integer;\nbegin\nreadln(s);\nreadln(b);\nfor i:=1 to length(s)do\nif s[i]='|' then\nk:=i;\nk1:=k-1;\nk2:=length(s)-k;\no:=(abs(k1-k2));\nif (o>length(b))or((length(b)-o) mod 2=1) then\nbegin\nwriteln('Impossible');\nhalt(0);\nend else\nif k1>k2 then\nbegin\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nwrite(s);\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nend else\nbegin\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nwrite(s);\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nend;\nend.\n"}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to (length(t)div 2+d-1) do write(t[i]);\nwrite(s);\nfor i:=(length(t)div 2+d) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "Program azkaban;\nvar s,s1,s2,s3 : string;\n k,i,dif,nr : longint;\nbegin readln(S);\n i:=1;\n while s[i]<>'|' do begin k:=k+1; i:=i+1; end;\n s1:=copy(s,1,k);\n s2:=copy(s,k+2,length(S)-k-1);\n readln(s3);\n dif:=length(s1)-length(s2);\n if (length(S3)+length(s1)+length(s2)) mod 2 <>0 then write('Impossible')\n else begin\n i:=1;\n nr:=length(s3);\n while nr <>0 do begin\n if dif>=0 then begin\n s2:=s2+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(S2);\n end\n else\n if dif<0 then begin\n s1:=s1+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(s2);\n end;\n end;\n write(s1,'|',s2);\n\n end;\n\n\nend.\n"}, {"source_code": "program a123;\nvar i,j,k,s1,s2:longint; n:byte;\n s:array[1..2] of longint;\n a:array[0..10000] of char;\n x:array[1..10000] of char;\nprocedure inputdata;\n begin\n \n i:=0;\n while not eoln do\n begin\n inc(I);\n read(x[i]);\n\n if x[i] <> '|' then inc(s[n]) else inc(n);\n end;\n readln(a[0]);\n i:=1;\n while not eoln do\n begin\n read(a[i]);\n\n inc(I);\n end;\n dec(I);\n k:=i;\n s1:=s[1];\n s2:=s[2];\n \n end;\nprocedure outputdata;\n begin\n \n if (k = 0) and (x[1] = '|')then write('|');\n if k = 0 then if s[1] = s[2] then for j:= 1 to s[1]+s[2]+1 do write(x[j]);\n if abs(s[1]-s[2])= k\n then begin\n if s[1]>s[2] then begin\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n i:=1;\n while s[1] <> s[2] do\n begin\n write(a[i]);\n inc(s[2]);\n inc(I);\n end;\n end;\n if s[2] > s[1] then begin\n i:=1;\n while s[1]<>s[2] do\n begin\n write(a[i]);\n inc(s[1]);\n inc(i);\n end;\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n end;\n end\n else if s[1]=s[2] then if i mod 2 <> 0 then begin write('Impossible'); exit; end\n else if s[1]=s[2] then begin\n for j:= 1 to trunc(i div 2) do\n write(a[j]);\n for j:= 1 to s[1]+s[2]+1 do\n write(x[j]);\n for j:= trunc(i div 2)+1 to i do\n write(a[j]);exit; end;\n if abs( s1-s2) <> k\n then write('Impossible');\n\n\n \n end;\nbegin\n n:=1;\n s[1]:=0;\n s[2]:=0;\n inputdata;\n\n outputdata;\nend.\n"}, {"source_code": "var t:char;\n left,right,none:string;\nbegin\n left:='';\n right:='';\n while not(seekeoln) do\n begin\n read(t);\n if t<>'|' then right:=right+t\n else begin left:=right; right:=''; end;\n end;\n readln;\n readln(none);\n if (length(none)+length(right)<>length(left))and(length(none)+length(left)<>length(right)) then writeln('Impossible')\n else\n begin\n if length(none)+length(left)=length(right) then writeln(none,left,'|',right)\n else writeln(left,'|',none,right);\n end;\nend."}, {"source_code": "var\nt,x,y,s:ansistring;\nj,k:longint;\nbegin\nreadln(x);\nreadln(y);\nj:=pos('|',x);\ns:=copy(x,1,j-1);\ndelete(x,1,j);\n\nif length(x)>length(s) then begin t:=x;x:=s;s:=t;end;\nif length(x)+length(y)0)then\n begin\n writeln('Impossible');\n exit;\n end;\n for i:=1 to length(s) do\n begin\n if not(q)and(s[i]<>'|')then\n inc(l)\n else if(s[i]='|')then\n begin\n q:=true;\n x:=i;\n end\n else if(q)then\n inc(r);\n end;\n if(length(s1)0) or (abs(d)>c) then writeln('impossible') else \nbegin\nwrite(t1,copy(n,1,(c-d) div 2),'|',t2,copy(n,(c-d) div 2+1,c));\nwriteln;\nwriteln(c,d,(d-c) mod 2);\nend;\nend.\n"}, {"source_code": "program fff;\nvar a,b,i,c,x:longint;\ns,s1,s2,s3:ansistring;\n\nbegin\n readln(s3);\n for i:=1 to length(s3) do\n if (ord(s3[i])ord('Z')) then x:=i;\n a:=x-1;\n s1:=copy(s3,1,x-1);\n delete(s3,1,x-1);\n b:=length(s3)-1;\n s2:=copy(s3,2,b);\n readln(s);\n c:=length(s);\n{ writeln(s1,' ',a);\n writeln(s2,' ',b);\n writeln(s,' ',c);}\n if a>b then\n begin\n if c>=a-b then\n begin\n c:=c-a+b;\n s2:=s2+copy(s,1,a-b);\n delete(s,1,a-b);\n end else\n begin\n writeln('Impossible');\n exit;\n end;\n end else\n if b>a then\n begin\n if c>=b-a then\n begin\n c:=c-b+a;\n s1:=s1+copy(s,1,b-a);\n delete(s,1,b-a);\n end else\n begin\n writeln('Impossible');\n exit;\n end;\n end;\n if c mod 2 = 1 then\n begin\n writeln('Impossible');\n exit;\n end;\nfor i:=1 to c do\n if i mod 2 = 1 then s1:=s1+s[i] else s2:=s2+s[i];\nwriteln(s1,s3[x],s2);\nend.\n"}, {"source_code": "var\n s,t : ansistring;\n x1,x2 : longint;\nbegin\n readln(s);\n readln(t);\n x1:=pos('|',s)-1; x2:=length(s)-pos('|',s);\n while length(t) > 0 do begin\n if x1 < x2 then begin inc(x1); insert(t[1],s,1); end else begin inc(x2); insert(t[1],s,length(s)); end;\n delete(t,1,1);\n end;\n if x1 <> x2 then writeln('Impossible') else writeln(s);\nend."}, {"source_code": "program scalse;\nvar\n s,t,res:string;\n lens,lent,i,j,k,left,right,pos:integer;\nbegin\n readln(s);\n readln(t);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n if(s[i]='|')then\n begin\n pos:=i;\n break;\n end\n else\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(left);\n end;\n for i:=pos+1 to lens do\n begin\n if((s[i]='')or(s[i]=' '))then continue\n else\n inc(left);\n end;\n if(left+lent=right)then\n begin\n for i:=1 to left do\n begin\n if((s[i]='')or(s[i]=' '))then continue\n else\n res:=res+s[i];\n end;\n for j:=1 to lent do\n res:=res+t[j];\n for k:=pos to lens do\n res:=res+s[k];\n end\n else if(left=right+lent) then\n begin\n for i:=1 to lens do\n res:=res+s[i];\n for j:=1 to lent do\n res:=res+t[j];\n end\n else res:='Impossible';\n writeln(res);\nend.\n"}, {"source_code": " var s,s1:ansistring;\n i,k1,k2:longint;\n u:byte;\n\n\nbegin\n readln(s);\n u:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='|' then u:=1;\n if s[i] in ['A'..'Z'] then if u=0 then inc(k1)\n else inc(k2);\n end;\n readln(s1);\n\n if k1>k2 then if k2+length(s1)=k1 then writeln(s,s1)\n else writeln('Impossible')\n else if k1+length(s1)=k2 then writeln(s1,s)\n else writeln('Impossible');\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "var s1,s2:string;\n ch1,ch2:string;\n i,f:integer;\nbegin\nreadln(s1);\nreadln(s2);\nf:=0;\nfor i:=1 to pos('|',s1)-1 do ch1:=ch1+s1[i];\nfor i:=1+pos('|',s1) to length(s1) do ch2:=ch2+s1[i];\n//if (length(ch1)=length(ch2)) and (length(s2) mod 2<>0) then begin write('Impossible'); halt; end; \nwhile (length(ch1)<>length(ch2)) and (s2<>'') do \n begin \n if (length(ch1)'') then \n begin\n ch1:=ch1+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n if (length(ch1)>length(ch2)) and (s2<>'') then \n begin\n ch2:=ch2+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n end;\nif (f=1) and (length(ch1)=length(ch2)) then write(ch1,'|',ch2)\n else write('Impossible'); \nend."}, {"source_code": "var\n s,f : string;\n i,k,s1,f1 : longint;\nbegin\n //assign(input,'382A.INP'); reset(input);\n //assign(output,'328A.OUt'); rewrite(output);\n readln(s);\n readln(f);\n k := pos('|',s);\n s1 := length(s);\n f1 := length(f);\n if k - 1 > s1 - k then\n begin\n if f1 = 2*k - 1- s1 then\n write(s,f)\n else\n writeln('Impossible')\n end\n else\n begin\n if f1 = s1 - 2*k + 1 then\n write(f,s)\n else\n writeln('Impossible');\n end;\nend."}, {"source_code": "var s,f,s2,s1:string;\nx:longint;\nbegin\nreadln(s);\nreadln(f);\nx:=pos('|',s);\ns1:=copy(s,1,x-1);\ns2:=copy(s,x+1,length(s)-x+1);\nwhile length(f)<>0 do begin\n if length(s1)length(s1) then \n begin\n writeln('Impossible');\n halt;\n end;\n if x'|' do i:=i+1;\nif length(s1)-i=i-1 then begin write('Impossible');halt;end;\n if i>length(s1) div 2 then\n begin\n s1:=s1+s2;\n while length(s1)>i*2+1 do delete(s1,length(s1),1);\n end\n else\n begin\n i:=i+length(s1);\n s1:=s2+s1;\n while length(s1)>i*2+1 do delete(s1,1,1);\n end;\ni:=1;\nwhile s1[i]<>'|' do i:=i+1;\nif length(s1)-i=i-1 then writeln(s1) else write('Impossible');\nEND.\n\n"}, {"source_code": "program a123;\nvar i,j,k,s1,s2:longint; n:byte;\n s:array[1..2] of longint;\n a:array[0..10000] of char;\n x:array[1..10000] of char;\nprocedure inputdata;\n begin\n \n i:=0;\n while not eoln do\n begin\n inc(I);\n read(x[i]);\n\n if x[i] <> '|' then inc(s[n]) else inc(n);\n end;\n readln(a[0]);\n i:=1;\n while not eoln do\n begin\n read(a[i]);\n\n inc(I);\n end;\n dec(I);\n k:=i;\n s1:=s[1];\n s2:=s[2];\n \n end;\nprocedure outputdata;\n begin\n \n if (k = 0) and (x[1] = '|')then write('|');\n if abs(s[1]-s[2])= k\n then begin\n if s[1]>s[2] then begin\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n i:=1;\n while s[1] <> s[2] do\n begin\n write(a[i]);\n inc(s[2]);\n inc(I);\n end;\n end;\n if s[2] > s[1] then begin\n i:=1;\n while s[1]<>s[2] do\n begin\n write(a[i]);\n inc(s[1]);\n inc(i);\n end;\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n end;\n end\n else if s[1]=s[2] then if i mod 2 <> 0 then begin write('Impossible'); exit; end\n else if s[1]=s[2] then begin\n for j:= 1 to trunc(i div 2) do\n write(a[j]);\n for j:= 1 to s[1]+s[2]+1 do\n write(x[j]);\n for j:= trunc(i div 2)+1 to i do\n write(a[j]);exit; end;\n if abs( s1-s2) <> k\n then write('Impossible');\n\n\n \n end;\nbegin\n n:=1;\n s[1]:=0;\n s[2]:=0;\n inputdata;\n\n outputdata;\nend.\n"}, {"source_code": "program project1;\n\n{$mode objfpc}{$H+}\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n write('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n write('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n write(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "var\nt,x,y,s:ansistring;\nj,k:longint;\nbegin\nreadln(x);\nreadln(y);\nj:=pos('|',x);\ns:=copy(x,1,j-1);\ndelete(x,1,j);\n\nif length(x)>length(s) then begin t:=x;x:=s;s:=t;end;\nif length(x)+length(y)i then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i+1 to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}, {"source_code": "program project1;\n\n{$mode objfpc}{$H+}\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n write('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n write('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\n readln();\nend.\n\n"}, {"source_code": "var s1,s2,s:ansistring;\n i,len:longint;\n tmp:char;\nbegin\n readln(s1); readln(s2);\n if s1[1] = '|' then s := s2 + s1 else s := s1 + s2; \n len := length(s1) + length(s2);\n if len mod 2 = 0 then begin writeln('Impossible'); halt; end;\n for i:=1 to len do begin\n if s[i] = '|' then begin\n tmp := s[i]; s[i] := s[(len+1)div 2]; s[(len+1)div 2] := tmp;\n end;\n end;\n writeln(s);\nend.\n"}, {"source_code": "program project1;\n\n{$mode objfpc}{$H+}\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n write('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n write('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\n readln();\nend.\n\n"}, {"source_code": "Program azkaban;\nvar s,s1,s2,s3 : string;\n k,i,dif,nr : longint;\nbegin readln(S);\n i:=1;\n while s[i]<>'|' do begin k:=k+1; i:=i+1; end;\n s1:=copy(s,1,k);\n s2:=copy(s,k+2,length(S)-k-1);\n readln(s3);\n dif:=length(s1)-length(s2);\n if (length(S3)+length(s1)+length(s2)) mod 2 <>0 then write('Impossible')\n else begin\n i:=1;\n nr:=length(s3);\n while nr <>0 do begin\n if dif>=0 then begin\n s2:=s2+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(S2);\n end\n else\n if dif<0 then begin\n s1:=s1+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(s2);\n end;\n end;\n write(s1,'|',s2);\n\n end;\n\n\nend.\n"}, {"source_code": "var s1,s2:string;\n ch1,ch2:string;\n i,f:integer;\nbegin\nreadln(s1);\nreadln(s2);\nf:=0;\nfor i:=1 to pos('|',s1)-1 do ch1:=ch1+s1[i];\nfor i:=1+pos('|',s1) to length(s1) do ch2:=ch2+s1[i];\n//if (length(ch1)=length(ch2)) and (length(s2) mod 2<>0) then begin write('Impossible'); halt; end; \nwhile (length(ch1)<>length(ch2)) and (s2<>'') do \n begin \n if (length(ch1)'') then \n begin\n ch1:=ch1+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n if (length(ch1)>length(ch2)) and (s2<>'') then \n begin\n ch2:=ch2+s2[1];\n delete(s2,1,1);\n f:=1;\n end;\n end;\nif (f=1) and (length(ch1)=length(ch2)) then write(ch1,'|',ch2)\n else write('Impossible'); \nend."}, {"source_code": "var s1,s2:string;\n\ti,j,t,k:integer;\nbegin\n\treadln(s1);\n\treadln(s2);\n\ti:=1;\n\twhile s1[i]<>'|' do\n\t\tinc(i);\n\tj:=i-1; k:=length(s1)-i;\n\tif i=1 then t:=length(s2)\n\telse\tt:=length(s1)-i+length(s2);\n\tif (t=j) or (t=k) then\n\t\tbegin\n\t\t\tif s1[1]='|' then write(s2,s1)\n\t\t\t\telse write(s1,s2);\n\t\tend\n\telse write('Impossible');\nend.\n"}, {"source_code": "var\n data : ansistring;\n cek : int64;\n tanya : ansistring;\n jawab : ansistring;\n cek2 : int64;\n cek3 : int64;\nbegin\n readln(data);\n readln(tanya);\n // writeln(length(tanya));\n cek := pos('|',data);\n // writeln(cek);\n if (cek = length(data)) and (length(data) = length(tanya)+1) then begin\n jawab := copy(data,1,length(data)) + copy(tanya,1,length(tanya));\n writeln(jawab);\n end else\n if (cek = 1) and (length(data) = length(tanya)+1) then begin\n jawab := copy(tanya,1,length(tanya)) + copy(data,1,length(data));\n writeln(jawab);\n end else begin\n cek2 := cek-1;\n cek3 := length(data) - cek;\n // writeln(cek2,' ',cek3,' ',length(tanya));\n if (cek2 + length(tanya) = cek3) then begin\n jawab := copy(tanya,1,length(tanya)) + copy(data,1,length(data));\n writeln(jawab);\n end else\n if (cek2 = length(tanya)+cek3) then begin\n jawab := copy(data,1,length(data)) + copy(tanya,1,length(tanya));\n writeln(jawab);\n end else\n writeln('Impossible');\n end;\nend.\n\n\n\n\n"}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to ((length(t)-d)div 2+d) do write(t[i]);\nwrite(s);\nfor i:=((length(t)-d)div 2+d) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "var\n s,f,s1 : string;\n i,k,r,f1 : longint;\nbegin\n //assign(input,'382A.INP'); reset(input);\n //assign(output,'328A.OUt'); rewrite(output);\n readln(s);\n readln(f);\n\n if (length(s) - 1 + length(f)) mod 2 <> 0 then\n writeln('Impossible')\n else\n begin\n r := length(f);\n for i := 1 to length(f) do\n begin\n k := pos('|',s);\n if k - 1 > length(s) - k then\n begin\n insert(f[i],s,length(s));\n dec(r);\n k := pos('|',s);\n if (k - 1 = length(s) - k) and (r = 0) then break;\n end\n else\n if k - 1 < length(s) - k then\n begin\n k := pos('|',s);\n insert(f[i],s,k - 1);\n dec(r);\n if (k - 1 = length(s) - k) and (r = 0) then break;\n end\n else\n if (k - 1 = length(s) - k) and (r > 0) then\n begin\n insert(f[i],s,k - 1) ;\n dec(r);\n if (r = 0) and (k - 1 = length(s) - k) then break;\n end;\n end;\n\n k := pos('|',s);\n if k - 1 = length(s) - k then\n writeln(s)\n else\n writeln('Impossible');\n end ;\n\nend.\n"}, {"source_code": "var\n s,s1:string;\n a,b,i:longint;\nbegin\n readln(s);\n readln(s1);\n a:=pos('|',s)-1;\n b:=length(s)-a-1;\n if(length(s1)-abs(a-b))and 1=0 then\n begin\n for i:=1to length(s1)do\n begin\n if a>b then\n begin\n inc(b);\n s:=s+s1[i];\n end\n else\n begin\n inc(a);\n s:=s1[i]+s;\n end;\n end;\n writeln(s);\n end\n else\n writeln('Impossible');\nend."}, {"source_code": "program codeforces_round224_a;\n\nvar\n s1, s2 : string;\n\nbegin\n readln(s1);\n readln(s2);\n while length(s2) <> 0 do\n begin\n if pos(chr(179), s1) > (length(s1) + 1) div 2\n then s1:=s1 + s2[1]\n else insert(s2[1], s1, 1);\n delete(s2, 1, 1);\n end;\n if pos(chr(179), s1) <> (length(s1) + 1) div 2\n then write('impossible')\n else write(s1);\n\nend.\n"}, {"source_code": "program a123;\nvar i,j,k,s1,s2:longint; n:byte;\n s:array[1..2] of longint;\n a:array[0..10000] of char;\n x:array[1..10000] of char;\nprocedure inputdata;\n begin\n \n i:=0;\n while not eoln do\n begin\n inc(I);\n read(x[i]);\n\n if x[i] <> '|' then inc(s[n]) else inc(n);\n end;\n readln(a[0]);\n i:=1;\n while not eoln do\n begin\n read(a[i]);\n\n inc(I);\n end;\n dec(I);\n k:=i;\n s1:=s[1];\n s2:=s[2];\n \n end;\nprocedure outputdata;\n begin\n \n if (k = 0) and (x[1] = '|')then write('|');\n if k = 0 then if s[1] = s[2] then for j:= 1 to s[1]+s[2]+1 do write(x[j]);\n if abs(s[1]-s[2])= k\n then begin\n if s[1]>s[2] then begin\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n i:=1;\n while s[1] <> s[2] do\n begin\n write(a[i]);\n inc(s[2]);\n inc(I);\n end;\n end;\n if s[2] > s[1] then begin\n i:=1;\n while s[1]<>s[2] do\n begin\n write(a[i]);\n inc(s[1]);\n inc(i);\n end;\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n end;\n end\n else if s[1]=s[2] then if i mod 2 <> 0 then begin write('Impossible'); exit; end\n else if s[1]=s[2] then begin\n for j:= 1 to trunc(i div 2) do\n write(a[j]);\n for j:= 1 to s[1]+s[2]+1 do\n write(x[j]);\n for j:= trunc(i div 2)+1 to i do\n write(a[j]);exit; end;\n if abs( s1-s2) <> k\n then write('Impossible');\n\n\n \n end;\nbegin\n n:=1;\n s[1]:=0;\n s[2]:=0;\n inputdata;\n\n outputdata;\nend.\n"}, {"source_code": "var t:char;\n left,right,none:string;\nbegin\n left:='';\n right:='';\n while not(seekeoln) do\n begin\n read(t);\n if t<>'|' then right:=right+t\n else begin left:=right; right:=''; end;\n end;\n readln;\n readln(none);\n if (length(none)+length(right)<>length(left))and(length(none)+length(left)<>length(right)) then writeln('Impossible')\n else\n begin\n if length(none)+length(left)=length(right) then writeln(none,left,'|',right)\n else writeln(left,'|',none,right);\n end;\nend."}, {"source_code": "program p1;\nvar s,t:string;i,k,l,r,d:integer;\nbegin\nreadln(s);\nreadln(t);\nfor i:=1 to length(s) do\nif (s[i]='|') then\nbegin\nk:=i;\nbreak;\nend;\nr:=length(s)-k;\nl:=k-1;\nd:=abs(l-r);\nif (length(t)0) then writeln('Impossible')\nelse\nbegin\nif (l>r) then\nbegin\nfor i:=1 to ((length(t)-d) div 2) do write(t[i]);\nwrite(s);\nfor i:=(((length(t)-d) div 2)+1) to length(t) do write(t[i]);\nend\nelse\nbegin\nfor i:=1 to ((length(t)-d)div 2+d) do write(t[i]);\nwrite(s);\nfor i:=((length(t)-d)div 2+d) to length(t) do write(t[i]);\nend;\nend;\nend.\n"}, {"source_code": "var\n data : ansistring;\n cek : longint;\n i,j : longint;\n tanya : ansistring;\n jawab : ansistring;\n cek2 : longint;\n cek3 : longint;\nbegin\n readln(data);\n readln(tanya);\n // writeln(length(tanya));\n cek := pos('|',data);\n // writeln(cek);\n if (cek = length(data)) and (length(data) = length(tanya)+1) then begin\n jawab := copy(data,1,length(data)) + copy(tanya,1,length(tanya));\n writeln(jawab);\n end else\n if (cek = 1) and (length(data) = length(tanya)+1) then begin\n jawab := copy(tanya,1,length(tanya)) + copy(data,1,length(data));\n writeln(jawab);\n end else begin\n cek2 := cek-1;\n cek3 := length(data) - cek;\n // writeln(cek2,' ',cek3,' ',length(tanya));\n if cek2 + length(tanya) = cek3 then begin\n jawab := copy(tanya,1,length(tanya)) + copy(data,1,length(data));\n writeln(jawab);\n end else\n if cek2 = length(tanya)+cek3 then begin\n jawab := copy(data,1,length(data)) + copy(tanya,1,length(tanya));\n writeln(jawab);\n end else\n writeln('Impossible');\n end;\nend.\n\n\n\n\n"}, {"source_code": " var s,s1:ansistring;\n i,k1,k2:longint;\n u:byte;\n\n\nbegin s:='';\n readln(s);\n u:=0; s1:=''; k1:=0;k2:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='|' then u:=1;\n if s[i] in ['A'..'Z'] then if u=0 then inc(k1)\n else inc(k2);\n end;\n readln(s1);\n\n if k1>k2 then if k2+length(s1)=k1 then writeln(s,s1)\n else writeln('Impossible')\n else if k1+length(s1)=k2 then writeln(s1,s)\n else writeln('Impossible');\n\n\n\n readln;\n{Totusi este trist in lume}\nend."}, {"source_code": "program form;\nvar s, ss: string;\nn,m,i,j,k: longint;\n\n\nbegin\n//assign (input, 'input.txt');reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s);\nfor i:= 1 to length (s) do\nif s[i] = '|' then break;\nreadln (ss);\n\nif (length (s) + length (ss)) mod 2 =0 then\nbegin writeln ('Impossible'); halt; end;\n\nm:= (length (s) + length (ss)) div 2;\nif (i-1<= m) and (length (s)-i <=m)\nthen\nelse begin writeln ('Impossible'); halt; end;\nj:= 1;\nfor k:= 1 to m do\nbegin\nif (ki then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}, {"source_code": "var\n s,s1:ansistring; \n k,x,y,i:longint;\nbegin\n readln(s);\n readln(s1);\n k:=pos('|',s);\n for i:=1 to k-1 do\n if (s[i] in ['A'..'Z']) or (s[i] in ['a'..'z']) then\n inc(x); \n for i:=k+1 to length(s) do\n if (s[i] in ['A'..'Z']) or (s[i] in ['a'..'z']) then\n inc(y); \n if abs(x-y)<>length(s1) then \n begin\n writeln('Impossible');\n halt;\n end;\n if xlength(b))or((length(b)-o) mod 2=1) then\nwriteln('Impossible')else\nif k1>k2 then\nbegin\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nwrite(s);\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nend else\nbegin\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nwrite(s);\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nend;\nend.\n"}, {"source_code": "Var i,j,k,l,n,m,t,c,r : Longint;\n s,s1 : ansistring;\nfunction Max(a,b : Longint) : Longint;\nbegin\n If (a > b) Then max := a\n else max := b;\nEnd;\n\nBegin\n Readln(s);\n i := 1;\n While s[i] <> '|' Do\n Begin\n Inc(l);\n inc(i);\n End;\n r := length(s) - l - 1;\n Readln(s1);\n c := abs(r - l);\n if (length(s1) - c < 0) or ((length(s1) - c) mod 2 <> 0) Then\n Begin\n Writeln('Impossible');\n exit;\n End;\n k := 1;\n Dec(c,length(s1));\n c := c div 2;\n t := max(l,r) + c;\n For i := 1 To l Do\n Write(s[i]);\n For i := 1 To t - l do\n write(s1[i]);\n Write('|');\n For i := l + 2 to length(s) Do\n Write(s[i]);\n For i := t - l + 1 To length(s1) do\n Write(s1[i]);\n Writeln();\nEnd."}, {"source_code": "var s,f,s2,s1:string;\nx:longint;\nbegin\nreadln(s);\nreadln(f);\nx:=pos('|',s);\ns1:=copy(s,1,x-1);\ns2:=copy(s,x+1,length(s)-x+1);\nwhile length(f)<>0 do begin\n if length(s1)length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss1:=ss1+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss1:=ss1+s2[i];\n for i:=r+1 to length(s2) do\n ss2:=ss2+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end\n else begin\n q:=t1-t2;\n if q>length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss2:=ss2+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to q+r do\n ss2:=ss2+s2[i];\n for i:=q+r+1 to length(s2) do\n ss1:=ss1+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end;\n end."}, {"source_code": "var a,b:ansistring;\n i,l,r,num:longint;\nbegin\nreadln(a);\nreadln(b);\nl:=0;\nwhile (a[l+1]<>'|') do inc(l);\nr:=length(a)-l-1;num:=length(a)-1+length(b);\nif num mod 2=1 then begin write('Impossible');halt;end;\nfor i:=((length(b)+r-l)div 2) downto 1 do a:=b[i]+a;\nfor i:=((length(b)+r-l)div 2) +1 to length(b) do a:=a+b[i];\nwriteln(a);\nend."}, {"source_code": "program a123;\nvar i,j,k,s1,s2:longint; n:byte;\n s:array[1..2] of longint;\n a:array[0..10000] of char;\n x:array[1..10000] of char;\nprocedure inputdata;\n begin\n \n i:=0;\n while not eoln do\n begin\n inc(I);\n read(x[i]);\n\n if x[i] <> '|' then inc(s[n]) else inc(n);\n end;\n readln(a[0]);\n i:=1;\n while not eoln do\n begin\n read(a[i]);\n\n inc(I);\n end;\n dec(I);\n k:=i;\n s1:=s[1];\n s2:=s[2];\n end;\nprocedure outputdata;\n begin\n \n\n if k = 0 then if s[1] = s[2] then begin for j:= 1 to s[1]+s[2]+1 do write(x[j]); exit end\n else begin write('Impossible'); exit; end;\n if (s[1]+s[2]+ k) mod 2 = 0\n then begin\n for i := 1 to ((k+s[1]+s[2]) div 2) - s[1] do\n\n write(a[i]);\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n for i:=((k +s[1]+s[2])div 2) -s[1] +1 to k do\n write(a[i]);\n exit;\n end\n else if s[1]=s[2] then if i mod 2 <> 0 then begin write('Impossible'); exit; end\n else if s[1]=s[2] then begin\n for j:= 1 to trunc(i div 2) do\n write(a[j]);\n for j:= 1 to s[1]+s[2]+1 do\n write(x[j]);\n for j:= trunc(i div 2)+1 to i do\n write(a[j]);exit; end;\n if abs( s1-s2) <> k then\n write('Impossible');\n\n\n \n end;\nbegin\n n:=1;\n s[1]:=0;\n s[2]:=0;\n inputdata;\n\n outputdata;\nend.\n"}, {"source_code": "var\n s,s1:ansistring; \n k,x,y:longint;\nbegin\n readln(s);\n readln(s1);\n k:=pos('|',s);\n x:=length(copy(s,1,k-1));\n y:=length(copy(s,k+1,length(s)));\n if abs(x-y)<>length(s1) then \n begin\n writeln('Impossible');\n halt;\n end;\n if x0)then\n begin\n writeln('Impossible');\n exit;\n end;\n for i:=1 to length(s) do\n begin\n if not(q)and(s[i]<>'|')then\n inc(l)\n else if(s[i]='|')then\n begin\n q:=true;\n x:=i;\n end\n else if(q)then\n inc(r);\n end;\n if(length(s1)0 do begin\n if length(s1)>length(s2) then s1:=s1+f[1] else s2:=s2+f[2];\n delete(f,1,1);\n end;\nif length(s1)=length(s2) then write(s1,'|',s2) else write('Impossible');\nend."}, {"source_code": "var\nt,x,y,s:ansistring;\nj,k:longint;\nbegin\nreadln(x);\nreadln(y);\nj:=pos('|',x);\ns:=copy(x,1,j-1);\ndelete(x,1,j);\n\nif length(x)>length(s) then begin t:=x;x:=s;s:=t;end;\nif length(x)+length(y)'|')then\n inc(l)\n else if(s[i]='|')then\n begin\n q:=true;\n x:=i;\n end\n else if(q)then\n inc(r);\n end;\n if(length(s1) length(s) then write(s[i])\n else write('|');\n end;\n end\n else write('Imposible');\n writeln;\nend.\n"}, {"source_code": "var s1,s2:string;\n i:byte;\n\nBEGIN\nreadln(s1);readln(s2);\ni:=1;\nwhile s1[i]<>'|' do i:=i+1;\n//if length(s1)-i=i-1 then begin write('Impossible');halt;end;\nwhile ((length(s1)-i<>i-1) or (length(s2)>1))and(length(s2)>0) do\n begin\n if length(s1)-i=i-1 then\n begin\n s1:=s2[1]+s1+s2[2];\n delete(s2,1,2);\n i:=i+1;\n end\n else if length(s1)-ii-1 then\n begin\n s1:=s2[1]+s1;\n delete(s2,1,1);\n i:=i+1;\n end;\n end;\nif odd(length(s1)) and (i=length(s1) div 2+1) then write(s1) else write('Impossible');\nEND.\n\n"}, {"source_code": "var s,p:string; a,b,c:byte;\nbegin\n readln(s); readln(p);\n a:=pos('|',s)-1; b:=length(s)-pos('|',s); c:=length(p);\n if (c+a=b) then writeln(p,s) else\n if (a=b+c) then writeln(s,p) else\n if (a+b=c) then writeln(copy(p,1,b),s,copy(p,b+1,a)) else\n if ((a=b) and (c mod 2=0)) then\n writeln(copy(p,1,c div 2),s,copy(p,c div 2+1,c div 2)) else\n if ((a+b+c) mod 2=0) then \n writeln(copy(p,1,(a+b+c) div 2-a),s,copy(p,(a+b+c) div 2-a+1,(a+b+c) div 2-b))\n else writeln('Impossible');\nend."}, {"source_code": "var i,n,l,r,f: longint; a,b,o: string;\nbegin\n readln(a);\n n:=length(a);\n for i:=1 to n do\n if a[i]='|' then\n begin\n l:=i-1;\n r:=n-i;\n break\n end;\n readln(b);\n if (l>r) then f:=length(b)-l+r\n else f:=length(b)-r+l;\n if (f>-1) and ((f mod 2)=0) then\n begin\n if (l>r) then\n o:=copy(a,1,l)+copy(b,1,f mod 2)+'|'+copy(a,l+2,r)+copy(b,(f mod 2)+1,length(b))\n else o:=copy(a,1,l)+copy(b,(f mod 2)+1,length(b))+'|'+copy(a,l+2,r)+copy(b,1,f mod 2);\n writeln(o);\n end\n else writeln('Impossible');\nend.\n"}, {"source_code": "program v;\nvar s,b:string;\nk,k1,k2,i,o:integer;\nbegin\nreadln(s);\nreadln(b);\nfor i:=1 to length(s)do\nif s[i]='|' then\nk:=i;\nk1:=k-1;\nk2:=length(s)-k;\no:=(abs(k1-k2));\nif (o>length(b))or((length(b)-o) mod 2=1) then\nbegin\nwriteln('Impossible');\nhalt(0);\nend else\nif k1>k2 then\nbegin\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nwrite(s);\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nend else\nbegin\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nwrite(s);\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nend;\nend.\n"}, {"source_code": "var i,t1,t2,q,r :longint;\n s1,s2,ss1,ss2,ss:string;\n ok:boolean;\n begin\n readln(s1);\n readln(s2);\n ok:=false;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='|') then begin ok:=true; continue; end;\n if ok then begin inc(t2); ss2:=ss2+s1[i] end\n else begin inc(t1); ss1:=ss1+s1[i];end;\n end;\n\n if t1length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss1:=ss1+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to r do\n ss1:=ss1+s2[i];\n for i:=r+1 to length(s2) do\n ss2:=ss2+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end\n else begin\n q:=t1-t2;\n if q>length(s2) then begin writeln('Impossible'); halt; end;\n for i:=1 to q do\n ss2:=ss2+s2[i];\n if (length(s2)-q) mod 2=0 then begin\n r:=(length(s2)-q) div 2;\n if r<>0 then begin\n for i:=q+1 to r do\n ss2:=ss2+s2[i];\n for i:=r+1 to length(s2) do\n ss1:=ss1+s2[i];\n end;\n ss:=ss1+'|'+ss2;\n writeln(ss);\n halt;\n end\n else begin writeln('Impossible'); halt; end;\n end;\n end."}, {"source_code": "Program azkaban;\nvar s,s1,s2,s3 : string;\n k,i,dif,nr : longint;\nbegin readln(S);\n i:=1;\n while s[i]<>'|' do begin k:=k+1; i:=i+1; end;\n s1:=copy(s,1,k);\n s2:=copy(s,k+2,length(S)-k-1);\n readln(s3);\n dif:=length(s1)-length(s2);\n if (length(s3)0) then write('Impossible')\n else begin\n i:=1;\n nr:=length(s3);\n while nr <>0 do begin\n if dif>=0 then begin\n s2:=s2+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(S2);\n end\n else\n if dif<0 then begin\n s1:=s1+S3[i];\n i:=i+1;\n nr:=nr-1;\n dif:=length(s1)-length(s2);\n end;\n end;\n write(s1,'|',s2);\n\n end;\n\n\nend.\n"}, {"source_code": "program v;\nvar s,b:string;\nk,k1,k2,i,o:integer;\nbegin\nreadln(s);\nreadln(b);\nfor i:=1 to length(s)do\nif s[i]='|' then\nk:=i;\nk1:=k-1;\nk2:=length(s)-k;\no:=(abs(k1-k2));\nif (o>length(b))or((length(b)-o) mod 2=1) then\nbegin\nwriteln('Impossible');\nhalt(0);\nend else\nif k1>k2 then\nbegin\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nwrite(s);\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nend else\nbegin\nfor i:=(length(b)-o)mod 2+1 to length(b) do\nwrite(b[i]);\nwrite(s);\nfor i:=1 to (length(b)-o)mod 2 do\nwrite(b[i]);\nend;\nend.\n"}, {"source_code": "program a123;\nvar i,j,k,s1,s2:longint; n:byte;\n s:array[1..2] of longint;\n a:array[0..10000] of char;\n x:array[1..10000] of char;\nprocedure inputdata;\n begin\n \n i:=0;\n while not eoln do\n begin\n inc(I);\n read(x[i]);\n\n if x[i] <> '|' then inc(s[n]) else inc(n);\n end;\n readln(a[0]);\n i:=1;\n while not eoln do\n begin\n read(a[i]);\n\n inc(I);\n end;\n dec(I);\n k:=i;\n s1:=s[1];\n s2:=s[2];\n end;\nprocedure outputdata;\n begin\n \n\n if k = 0 then if s[1] = s[2] then begin for j:= 1 to s[1]+s[2]+1 do write(x[j]); exit end\n else begin write('Impossible'); exit; end;\n if (s[1]+s[2]+ k) mod 2 = 0\n then begin\n for i := 1 to ((k+s[1]+s[2]) div 2) - s[1] do\n\n write(a[i]);\n for i:= 1 to s[1]+s[2]+1 do\n write(x[i]);\n for i:=((k +s[1]+s[2])div 2) -s[1] +1 to k do\n write(a[i]);\n exit;\n end\n else if s[1]=s[2] then if i mod 2 <> 0 then begin write('Impossible'); exit; end\n else if s[1]=s[2] then begin\n for j:= 1 to trunc(i div 2) do\n write(a[j]);\n for j:= 1 to s[1]+s[2]+1 do\n write(x[j]);\n for j:= trunc(i div 2)+1 to i do\n write(a[j]);exit; end;\n if abs( s1-s2) <> k then\n write('Impossible');\n\n\n \n end;\nbegin\n n:=1;\n s[1]:=0;\n s[2]:=0;\n inputdata;\n\n outputdata;\nend.\n"}, {"source_code": "var s1,s2,s:ansistring;\n i:longint;\nbegin\n readln(s1); readln(s2);\n s := s1 + s2;\n if length(s) mod 2 = 0 then begin\n for i:=1 to length(s) do begin\n if i <> length(s) then write(s[i])\n else write('|');\n end;\n end\n else write('Imposible');\n writeln;\nend.\n"}, {"source_code": "Var\n\ns2,q1,q2: string;\ns : char;\ni,j,k1,k2,z,t,t2,t3,x,y : integer;\n\nBegin\n z:=1;\n While not eoln do begin\n Read (s);\n If s = '|' then begin\n z:=2;\n continue\n end;\n If z=1 then begin k1:=k1+1; q1:=q1+s; end;\n If z=2 then begin k2:=k2+1; q2:=q2+s; end;\n end;\n Readln;\n Read (s2);\n t := length (s2);\n If k1 t then begin \n Write ('Impossible');\n Halt;\n end Else begin \n t2:=t-(k2-k1);\n If t2 mod 2 = 1 then begin \n Write ('Impossible');\n Halt;\n end Else begin \n For i:= 1 to (k2-k1) do begin\n q1:=q1+s2[i];\n j:=i;\n end;\n If t2 = 0 then begin\n Writeln (q1,'|',q2);\n halt;\n end;\n t3:=t2 div 2;\n y:=t3;\n x:=1;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n end; \n end; \n end;\n \n If k1>k2 then begin\n If k1-k2 > t then begin \n Write ('Impossible');\n Halt;\n end Else begin \n t2:=t-(k1-k2);\n If t2 mod 2 = 1 then begin \n Write ('Impossible');\n Halt;\n end Else begin \n For i:= 1 to (k1-k2) do begin\n q2:=q2+s2[i];\n j:=i;\n end;\n If t2 = 0 then begin\n Writeln (q1,'|',q2);\n halt;\n end;\n t3:=t2 div 2;\n y:=t3;\n x:=1;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n end; \n end; \n end;\n \n If k1=k2 then begin\n\n t2 := t;\n If t2 mod 2 = 1 then begin\n Write ('Impossible');\n Halt;\n end;\n \n\n t3:=t2 div 2;\n y:=t3;\n x:=1;\n While y > 0 do begin\n q2:=q2+s2[x];\n inc (x);\n dec (y);\n end;\n y:=t3;\n While y > 0 do begin\n q1:=q1+s2[x];\n inc (x);\n dec (y);\n end;\n Writeln (q1,'|',q2);\n \n end;\nend."}, {"source_code": "var\n s,s1:string;\n a,b,i:longint;\nbegin\n readln(s);\n readln(s1);\n a:=pos('|',s)-1;\n b:=length(s)-a-1;\n if(length(s1)-abs(a-b))and 1=0 then\n begin\n for i:=1to length(s1)do\n begin\n if a>b then\n begin\n inc(b);\n s:=s+s1[i];\n end\n else\n begin\n inc(a);\n s:=s1[i]+s;\n end;\n end;\n writeln(s);\n end\n else\n writeln('Impossible');\nend."}, {"source_code": "program codeforces_round224_a;\n\nvar\n s1, s2 : string;\n\nbegin\n readln(s1);\n readln(s2);\n while length(s2) <> 0 do\n begin\n if pos(chr(179), s1) > (length(s1) + 1) div 2\n then s1:=s1 + s2[1]\n else insert(s2[1], s1, 1);\n delete(s2, 1, 1);\n end;\n if pos(chr(179), s1) <> (length(s1) + 1) div 2\n then write('impossible')\n else write(s1);\n\nend.\n"}, {"source_code": "program form;\nvar s, ss: string;\nn,m,i,j,k: longint;\n\n\nbegin\n//assign (input, 'input.txt');reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s);\nfor i:= 1 to length (s) do\nif s[i] = '|' then break;\nreadln (ss);\n\nif (length (s) + length (ss)) mod 2 =0 then\nbegin writeln ('Impossible'); halt; end;\n\nm:= (length (s) + length (ss)) div 2;\nif (i-1<= m) and (length (s)-i <=m)\nthen\nelse begin writeln ('Impossible'); halt; end;\nj:= 1;\nfor k:= 1 to m do\nbegin\nif (ki then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}, {"source_code": "program project1;\n\nvar\n vesy: string;\n other: string;\n symNum: integer;\n leftSymNum: integer;\n\nbegin\n readln(vesy);\n symNum:=Pos('|',vesy);\n readln(other);\n if((Length(vesy)-1+Length(other)) mod 2=1) then\n writeln('Impossible')\n else\n begin\n leftSymNum:=symNum-1-(Length(vesy)-symNum);\n if(abs(leftSymNum)>Length(other)) then\n writeln('Impossible')\n else\n begin\n insert(Copy(other, 1, (Length(other)-leftSymNum) shr 1), vesy, symNum);\n insert(Copy(other, ((Length(other)-leftSymNum) shr 1), Length(other)), vesy, Length(vesy)+1);\n writeln(vesy);\n end;\n end;\nend.\n\n"}, {"source_code": "program form;\nvar s, ss: string;\nn,m,i,j,k: longint;\n\n\nbegin\n//assign (input, 'input.txt');reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s);\nfor i:= 1 to length (s) do\nif s[i] = '|' then break;\nreadln (ss);\n\nif (length (s) + length (ss)) mod 2 =0 then\nbegin writeln ('Impossible'); halt; end;\n\nm:= (length (s) + length (ss)) div 2;\nif (i-1<= m) and (length (s)-i <=m)\nthen\nelse begin writeln ('Impossible'); halt; end;\nj:= 1;\nfor k:= 1 to m do\nbegin\nif (ki then begin write (ss[j]); inc (j); end;\nend;\nwrite (s[i]);\nfor k:= i to length (s) do\nwrite (s[k]);\nfor k:= j to length (ss) do\nwrite (ss[k]);\n\n//close (input); close (output);\nend.\n"}], "src_uid": "917f173b8523ddd38925238e5d2089b9"} {"source_code": "var n,a,b,i:longint;\nbegin\n//assign(input,'sdhyy.in');reset(input);\n//ssign(output,'sdhyy.out');rewrite(output);\nreadln(n,a,b);\nfor i:=0 to n div a do\n if (n-i*a) mod b=0 then\n begin\n writeln('YES');\n writeln(i,' ',(n-i*a) div b);\n close(input);close(output);\n halt;\n end;\nwriteln('NO');\nclose(input);close(output);\nend.", "positive_code": [{"source_code": "//{$R-,Q-,S-,I-}\nUses math;\nConst\n fin='';\n fon='';\n\t//fin='.inp';\n\t//fon='.out';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n\nType\n\tpnode=^tnode;\n tnode=record\n v,c:longint;\n next:pnode;\n\t\tend;\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,a,b:longint;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti:longint;\nBegin\n Readln(fi,n,a,b);\nEnd;\n\nProcedure xuly;\nVar\n i,j:longint;\nBegin\n For i:=0 to n div a do\n Begin\n j:=(n-a*i) div b;\n If j<0 then break;\n If i*a+j*b=n then\n Begin\n Writeln(fo,'YES');\n Writeln(fo,i,' ',j);\n Exit;\n End;\n End;\n Writeln(fo,'NO');\nEnd;\n\nProcedure xuat;\nBegin\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND."}, {"source_code": "var i,n,a,b:longint;\nBegin\n read(n,a,b);\n if(n=0) then begin writeln('YES');writeln(0,' ',0);halt(0);end;\n for i:=0 to (n div a)+1 do\n if(i*a<=n)and((n-i*a) mod b =0) then begin\n Writeln('YES');\n writeln(i,' ',(n-i*a) div b);\n halt(0);\n end;\n writeln('NO');\nend."}, {"source_code": "var\nbol:boolean;\nn,a,b,i:int64;\nbegin\nreadln(n);\nreadln(A);\nreadln(b);\ni:=0;\nwhile true do begin\n if (n-i*a) mod b= 0 then begin\n bol:=true;\n writeln('YES');\n writeln(i,' ',(n-i*a) div b);\n break;\n end;\n inc(i);\n if (n-i*a)<0 then begin\n writeln('NO');\n break;\n end;\nend;\nend.\n"}, {"source_code": "var n,a,b:int64;\n x:longint;\nbegin\n read(n,a,b);\n for x:=0 to n do\n if ((n-x*a) mod b=0)and(n>=x*a) then\n begin\n writeln('YES');\n writeln(x,' ',(n-x*a)div b);\n exit;\n end else\n if (nn) or ok;\n if ok then write('YES',#10,x-1,' ',y)\n else write('NO');\nEND.\n"}, {"source_code": "var n,a,b,x:longint;\nbegin\n readln(n,a,b);\n for x:=0 to n div a do\n if ((n-x*a)mod b=0) then\n begin\n writeln('YES');\n writeln(x,' ',(n-x*a) div b);\n halt;\n end;\n writeln('NO');\nend."}, {"source_code": "program Matfey;\nvar\ny1,y2,y3,y4,x12,x11,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 : longint;\nj,i,k : longint;\ns1,s2,s3,s4,s5 : string;\nr1,r2,r3,r4,r5,r6,r7,r8 : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\n{s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;}\na1,a2 : array[1..100001] of longint;\n\nbegin\nreadln(x1);\nreadln(x2);\nreadln(x3);\n\nfor i:=0 to x1 do\nbegin\nif ((x1-i*x2) div x3)<0 then break;\nif ((x1-(i*x2)) mod x3)=0 then begin writeln('YES'); writeln(i,' ',(x1-i*x2) div x3); exit; end;\nend;\n\nwriteln('NO');\nend.\n\n\n\n"}, {"source_code": "////ufasdaes cfdartfad;\nvar\na,b,c,d,d2,m,m2,ost:int64;\ni,j:longint;\nbegin\n//////////////////////cdldrrstsfgcghrr;\nread(a,b,c);\nm:=a div b;\n//if (a-b*m) mod c=0 then writeln('Yes');\nfor i:=0 to m do\nbegin\nd:=b*i;\nost:=a-d;\n\n//writeln(ost);\nif ost mod c=0 then begin writeln('YES');writeln((i),' ',ost div c);halt;end;\nend;\nwrite('NO');\n//if ost mod c=0 then write('Yes');\n\n{if a mod b=0 then begin writeln('YES');write(a div b,' ',0);halt;end;\nif a mod c=0 then begin writeln('YES');write(a div c,' ',0);halt;end;\n\nfor i:=1 to b do\nfor j:=1 to c do\nbegin\nif (i*b)+(j*c)=a then begin m:=i;m2:=j;end;\n\nend;\nif m*b+m2*c=a then begin writeln('YES');write(m,' ',m2);halt;end;\n\nwrite('NO');\n}//end;\nend.\n"}, {"source_code": "program a1;\n var n,k,a,b,l,u:longint;\n begin\n readln(n,a,b);\n k:=0;\n l:=0;\n if n mod a=0 then begin\n u:=0;\n k:=n div a;\n l:=0;\n end;\n if n mod b=0 then begin\n u:=0;\n k:=0;\n l:=n div b;\n end;\n if (n mod b<>0) and (n mod a<>0) then begin\n u:=1;\n while (n>=0) and (u=1) do begin\n n:=n-a;\n k:=k+1;\n if n mod b=0 then begin\n l:=n div b;\n u:=0;\n end;\n end;\n if n<0 then u:=1;\n end;\n if u=1 then writeln('NO')\n else begin\n writeln('YES');\n writeln(k,' ',l);\n end;\n end.\n\n\n\n"}, {"source_code": "var\ng,d,f:int64;\ns,otv:real;\ni,j,j2:longint; // 777\ntx,txt:text; // 747\na,b,c:string; // 777\ncho2,cho:array[1..1000]of int64;\nbegin\nread(g,d,f);\nfor i:=0 to g do\nbegin\n//writeln('g-d*i=loxxxxxxotron',g-d*i);\n\nif ((g-i*d) mod f=0)and(g-i*d>-1) then begin writeln('YES'); write(i,' ',(g-i*d) div f);halt;end;\n\n;end;\nwrite('NO');\nend.\n"}, {"source_code": "var n,a,b,x,k:longint;\nbegin\n readln(n,a,b);\n if n mod a=0 then begin writeln('YES');\n writeln(n div a,' 0');halt; end\n else\n if n mod b=0 then begin writeln('YES');\n writeln('0 ',n div b);halt;end;\n if b>a then\n begin\n x:=a;\n a:=b;\n b:=x;\n x:=2;\n end\n else\n x:=1;\n k:=0;\n while n>0 do\n begin\n n:=n-a;\n k:=k+1;\n if (n mod b=0)and(n>0) then\n begin\n if x=1 then begin writeln('YES');\n writeln(k,' ',n div b);end\n else begin writeln('YES');\n writeln(n div b,' ',k); end;\n x:=0;\n break;\n end;\n end;\n if x<>0 then\n writeln('NO');\nend.\n \n \n\n "}, {"source_code": "var a,b,c,d,e,n,i,k:longint;\nbegin\nreadln(n,a,b);\nd:=n div a;\nif (n mod b=0)then begin\n writeln('YES');\n write(0,' ',n div b);\n exit;\n end else if n mod a=0 then begin\n writeln('YES');\n write(n div a,' ',0);\n exit;\n end;\nfor k:=d downto 1 do begin\nif (n-(k*a))mod b =0 then begin\n writeln('YES');\n write(k ,' ',(n-(k*a))div b);\n exit;\n end;\n end;\n write('NO');\nend."}, {"source_code": "var i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:= 0 to n div a do\nif (n - a * i >= 0) and ((n-a*i) mod b=0) then begin\nwriteln ('YES'); write (i,' ',(n-a*i) div b);\nhalt (0);\nend;\nwriteln ('NO');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:= 0 to n div a do\nif (n - a * i >= 0) and ((n-a*i) mod b=0) then begin\nwriteln ('YES'); write (i,' ',(n-a*i) div b);\nhalt (0);\nend;\nwriteln ('NO');\nend."}, {"source_code": "var n, a, b, i, ka, kb:integer;\nBEGIN\n readln(n, a, b);\n ka:=0;\n while(n>=0)and(n mod b<>0)do\n begin\n n:=n-a;\n ka:=ka+1;\n end;\n if(n<0)\n then writeln('NO')\n else begin\n writeln('YES');\n kb:=n div b;\n writeln(ka, ' ', kb);\n end;\nEND."}, {"source_code": "var a,s,d,f,g:integer;\nbegin\n read (a,s,d);\n for f:=0 to (a div s)+1 do\n if ((a-f*s) mod d=0) and (a-f*s>=0) then begin\n writeln ('YES');\n write (f,' ',(a-f*s) div d);\n halt;\n end;\n write ('NO')\nend."}, {"source_code": "var\n n: int64;\n a, b,x,y: int64;\n i, j: int64;\n f: boolean;\n\nbegin\n read(n);\n read(a);\n read(b);\n x:=a;\n y:=b;\n f:=false;\n while x<>y do\n if x>y then x:=x-y\n else y:=y-x;\n if n mod x <>0 then\n else\n if (a mod 2=0) and (b mod 2=0) and (n mod 2<>0) then\n else \n if (a=b) and (n mod a<>0) then\n else\n begin\n for i := 0 to n div a do\n begin\n for j := 0 to n div b do\n if i * a + j * b = n then\n begin\n f := true;\n break;\n end;\n if f then break;\n end;\n end;\n if f then begin writeln('YES');write(i, ' ', j); end\n else writeln('NO');\nend."}, {"source_code": "var\n n,a,b,i:longint;\nbegin\n readln(n);\n readln(a);\n readln(b);\n for i:=0 to n div a do\n if (n-i*a) mod b=0 then\n begin\n writeln('YES');\n writeln(i,' ',(n-i*a) div b);\n halt;\n end;\n writeln('NO');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:= 0 to n div a do\nif (n - a * i >= 0) and ((n-a*i) mod b=0) then begin\nwriteln ('YES'); write (i,' ',(n-a*i) div b);\nhalt (0);\nend;\nwriteln ('NO');\nend."}, {"source_code": "Program CodeF_451_A;\nvar i,n,a,b,kol:longint;\n m:array[1..1]of longint;\n //reb:array[1..1]of array[1..2]of longint;\n\n\nbegin\nread(n, a, b);\nwhile (n mod b<>0) and (n>=0) do\n begin\n n:=n-a;\n inc(kol)\n end;\n\nif n<0 then\n begin\n writeln('NO');\n exit;\n end;\n\nwriteln('YES');\nwriteln(kol, ' ', n div b);\n\n\n\n\nend."}, {"source_code": "program abc;\nvar n,a,b,x,y:integer;\nbegin\nreadln(n,a,b);\nfor x:=0 to n div a do\nbegin\nif (n-a*x) mod b = 0 then begin\ny:=(n-a*x) div b;\nwriteln('YES');\nwriteln(x,' ',y);\nHalt(0);\nend;\nend;\nwriteln('NO');\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var hc,ac,hv,av,hh,ott,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,dx,dy,dz,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:array[-100..1000000] of int64;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n variant,peres,dd1,dd:array[-1..700,-1..6000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole :array [-10..1500,-10..1500] of char;\n st:array[-100..100000] of string;\n stest1,ss:string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nbegin\n \n read(cc,aa,bb);\n t:=round(cc/aa);\n for i:=0 to t do\n begin\n hh:=cc-i*aa;\n if (hh mod bb=0)and(hh>=0) then \n begin\n writeln('YES');\n writeln(i,' ',hh div bb);\n goto 1;\n \n \n end;\n \n end;\n \n writeln('NO');\n \n \n\n \n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var i,j,x,y,n,a,b: longint;\nbegin\nreadln(n);\nreadln(a);\nreadln(b);\nfor i:=0 to n div a do begin\n y:=(n-i*a) div b;\n x:=(n-i*a) mod b;\n if x=0 then break;\n end;\nif x<>0 then writeln('NO') else begin writeln('YES');\n writeln(i,' ',y);\n end;\nend."}, {"source_code": "Const fi='';//propernutrition.inp';\n fo='';\n\nVar f:text;\n n,a,b:longint;\n\nProcedure input;\n begin\n assign(f,fi); reset(f);\n readln(f,n);\n readln(f,a);\n readln(f,b);\n close(f);\n end;\n\nProcedure process;\n var i:longint;\n begin\n for i:=0 to n div a do if (n-a*i) mod b=0 then\n begin\n writeln(f,'YES');\n write(f,i,' ',(n-a*i) div b);\n exit;\n end;\n write(f,'NO');\n end;\n\nBEGIN\n input;\n assign(f,fo); rewrite(f);\n process;\n close(f);\nEND."}, {"source_code": "var n,x,y,i:Longint;\nbegin\nreadln(n);\nreadln(x);\nreadln(y);\nif n div x<=n div y then\n begin\n for i:=0 to n div x do\n if (n-x*i) mod y=0 then\n begin\n writeln('YES');\n writeln(i,' ',(n-x*i) div y);\n halt;\n end;\n end\nelse\n begin\n for i:=0 to n div y do\n if (n-y*i) mod x=0 then\n begin\n writeln('YES');\n writeln((n-y*i) div x,' ',i);\n halt;\n end;\n end;\nwriteln('NO');\nend."}, {"source_code": "var\n n,a,b,k,t:int64;\n\nbegin\n readln(n);\n readln(a);\n readln(b);\n while(n>0)do\n begin\n if(n mod a=0)then begin writeln('YES');writeln(n div a,' ',k);halt;end;\n dec(n,b);\n inc(k);\n end;\n if(n=0)then begin writeln('YES');writeln(0,' ',k);halt;end;\n writeln('NO');\nend.\n"}, {"source_code": "var\n i, n, a, b : Longint;\nbegin\n readln( n );\n readln( a );\n readln( b );\n for i := 0 to n div a do\n if ( n - ( i * a ) ) mod b = 0\n then\n begin\n writeln( 'YES' );\n writeln( i, ' ', ( n - ( i * a ) ) div b );\n halt;\n end;\n writeln( 'NO' );\nend."}, {"source_code": "var n,i,j,a,b:longint;\n begin\n readln(n);\n readln(a);\n readln(b);\n {if (a mod 2=0)and (b mod 2=0)and (n mod 2=1)then begin writeln('NO');exit; end;\n\n for i:=0 to n div a do\n for j:=0 to n div b do\n if ((a*i)+(b*j))=n then begin writeln('YES'); writeln(i,' ',j);exit; end;\n writeln('NO'); }\n\n for i:=0 to n div a do\n if (n-i*a)mod b=0 then begin writeln('YES'); writeln(i,' ',(n-i*a) div b);exit; end;\n writeln('NO');\n end.\n"}], "negative_code": [{"source_code": "var i,j,x,y,n,a,b: longint;\nbegin\nreadln(n);\nreadln(a);\nreadln(b);\nfor i:=0 to (n div a)+1 do begin\n y:=(n-i*a) div b;\n x:=(n-i*a) mod b;\n if x=0 then break;\n end;\nif x<>0 then writeln('NO') else begin writeln('YES');\n writeln(i,' ',y);\n end;\nend."}, {"source_code": "var\n n,a,b,k,t:int64;\n\nbegin\n readln(n);\n readln(a);\n readln(b);\n while(n>0)do\n begin\n if(n mod a=0)then begin writeln('YES');writeln(n div a,' ',k);halt;end;\n dec(n,b);\n inc(k);\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var\n n,a,b,k,t:int64;\n\nbegin\n readln(n);\n readln(a);\n readln(b);\n while(n>0)do\n begin\n if(n mod a=0)then begin writeln('YES');writeln(n div a,' ',k);halt;end;\n dec(n,b);\n inc(k);\n end;\n if(n mod a=0)then begin writeln('YES');writeln(n div a,' ',k);halt;end;\n writeln('NO');\nend.\n"}, {"source_code": "var\n i, n, a, b : Longint;\nbegin\n readln( n );\n readln( a );\n readln( b );\n for i := 1 to n div a do\n if ( n - ( i * a ) ) mod b = 0\n then\n begin\n writeln( 'YES' );\n writeln( i, ' ', ( n - ( i * a ) ) div b );\n halt;\n end;\n writeln( 'NO' );\nend."}, {"source_code": "var\n i, n, a, b : Longint;\nbegin\n readln( n );\n readln( a );\n readln( b );\n for i := 1 to n div a do\n if ( n - ( i * a ) ) mod b = 0\n then\n begin\n writeln( 'YES' );\n writeln( i, ' ', ( n - ( i * a ) ) div b );\n end;\nend."}, {"source_code": "var n,i,j,a,b:longint;\n begin\n readln(n);\n readln(a);\n readln(b);\n for i:=0 to a do\n for j:=0 to b do\n if ((a*i)+(b*j))=n then begin writeln('YES'); writeln(i,' ',j);exit; end;\n writeln('NO');\n end."}, {"source_code": "var n,i,j,a,b:longint;\n begin\n readln(n);\n readln(a);\n readln(b);\n if (a mod 2=0)and (b mod 2=0)and (n mod 2=1)then begin writeln('NO');exit; end;\n\n if (a mod 2=1)or (b mod 2=1)and (n mod 10=0)then begin writeln('NO');exit; end;\n for i:=0 to n div a do\n for j:=0 to n div b do\n if ((a*i)+(b*j))=n then begin writeln('YES'); writeln(i,' ',j);exit; end;\n writeln('NO');\n end.\n"}, {"source_code": "var n,i,j,a,b:longint;\n begin\n readln(n);\n readln(a);\n readln(b);\n if (a mod 2=0)and (b mod 2=0)and (n mod 2=1)then begin writeln('NO');exit; end;\n\n if (a mod 10=3)or(a mod 10=7)or(b mod 10=3)or(b mod 10=7)and (n mod 10=0)then\n begin writeln('NO');exit; end;\n for i:=0 to n div a do\n for j:=0 to n div b do\n if ((a*i)+(b*j))=n then begin writeln('YES'); writeln(i,' ',j);exit; end;\n writeln('NO');\n end.\n"}, {"source_code": "//{$R-,Q-,S-,I-}\nUses math;\nConst\n fin='';\n fon='';\n\t//fin='.inp';\n\t//fon='.out';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n\nType\n\tpnode=^tnode;\n tnode=record\n v,c:longint;\n next:pnode;\n\t\tend;\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,a,b:longint;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti:longint;\nBegin\n Readln(fi,n,a,b);\nEnd;\n\nProcedure xuly;\nVar\n i,j:longint;\nBegin\n For i:=1 to n div a do\n Begin\n j:=(n-a*i) div b;\n If j<0 then break;\n If i*a+j*b=n then\n Begin\n Writeln(fo,'YES');\n Writeln(fo,i,' ',j);\n Exit;\n End;\n End;\n Writeln(fo,'NO');\nEnd;\n\nProcedure xuat;\nBegin\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND."}, {"source_code": "//{$R-,Q-,S-,I-}\nUses math;\nConst\n fin='';\n fon='';\n\t//fin='.inp';\n\t//fon='.out';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n\nType\n\tpnode=^tnode;\n tnode=record\n v,c:longint;\n next:pnode;\n\t\tend;\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,a,b:longint;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti:longint;\nBegin\n Readln(fi,n,a,b);\nEnd;\n\nProcedure xuly;\nVar\n i,j:longint;\nBegin\n For i:=1 to n div a do\n Begin\n j:=(n-a*i) div b;\n If i*a+j*b=n then\n Begin\n Writeln(fo,'YES');\n Writeln(fo,i,' ',j);\n Exit;\n End;\n End;\n Writeln(fo,'NO');\nEnd;\n\nProcedure xuat;\nBegin\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND."}, {"source_code": "program Matfey;\nvar\ny1,y2,y3,y4,x12,x11,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 : longint;\nj,i,k : longint;\ns1,s2,s3,s4,s5 : string;\nr1,r2,r3,r4,r5,r6,r7,r8 : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\n{s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;}\na1,a2 : array[1..100001] of longint;\n\nbegin\nreadln(x1);\nreadln(x2);\nreadln(x3);\n\nfor i:=0 to x1 do\nbegin\nif ((x1-(i*x2)) mod x3)=0 then begin writeln('YES'); writeln(i,' ',(x1-i*x2) div x3); exit; end;\nend;\n\nwriteln('NO');\nend.\n\n\n\n"}, {"source_code": "var\na,b,c,d,d2,m,m2:int64;\ni,j:longint;\nbegin\nread(a,b,c);\n\nfor i:=1 to b do\nfor j:=1 to c do\nbegin\nif (i*b)+(j*c)=a then begin m:=i;m2:=j;end;\n\nend;\nif m*b+m2*c=a then begin writeln('YES');write(m,' ',m2);halt;end;\n\nwrite('NO');\n//end;\nend.\n"}, {"source_code": "var\na,b,c,d,d2,m,m2:int64;\ni,j:longint;\nbegin\n\nread(a,b,c);\n\nif a mod b=0 then begin writeln('YES');write(a div b,' ',0);halt;end;\nif a mod c=0 then begin writeln('YES');write(a div c,' ',0);halt;end;\n\nfor i:=1 to b do\nfor j:=1 to c do\nbegin\nif (i*b)+(j*c)=a then begin m:=i;m2:=j;end;\n\nend;\nif m*b+m2*c=a then begin writeln('YES');write(m,' ',m2);halt;end;\n\nwrite('NO');\n//end;\nend.\n"}, {"source_code": "var\na,b,c,d,d2,m,m2:int64;\ni,j:longint;\nbegin\nread(a,b,c);\n\nfor i:=1 to b do\nfor j:=1 to c do\nbegin\nif (i*b)+(j*c)=a then begin m:=i;m2:=j;end;\n\nend;\nif m*b+m2*c=a then begin writeln('Yes');write(m,' ',m2);halt;end;\n\nwrite('No');\n//end;\nend.\n"}, {"source_code": "var\ng,d,f:int64;\ns,otv:real;\ni,j,j2:longint; // 777\ntx,txt:text; // 747\na,b,c:string; // 777\ncho2,cho:array[1..1000]of int64;\nbegin\nread(g,d,f);\nfor i:=0 to 11111 do\nbegin\n//writeln('g-d*i=loxxxxxxotron',g-d*i);\n\nif ((g-i*d) mod f=0)and(g-i*d>-1) then begin writeln('YES'); write(i,' ',(g-i*d) div f);halt;end;\n\n;end;\nwrite('NO');\nend.\n"}, {"source_code": "var\ng,d,f:int64;\ns,otv:real;\ni,j,j2:longint;\ntx,txt:text;\na,b,c:string;\ncho2,cho:array[1..1000]of int64;\nbegin\nread(g,d,f);\nfor i:=0 to 1111 do\nfor j:=0 to 1111 do\nif i*d+f*j=g then begin writeln('YES'); write(i,' ',j);halt;end;\nwrite('NO');\nend.\n"}, {"source_code": "var\ng,d,f:int64;\ns,otv:real;\ni,j,j2:longint;\ntx,txt:text;\na,b,c:string;\ncho2,cho:array[1..1000]of int64;\nbegin\nread(g,d,f);\nfor i:=0 to g do\nif (g-i*d) mod f=0 then begin writeln('YES'); write(i,' ',(g-i*d) div f);halt;end;\nwrite('NO');\nend.\n"}, {"source_code": "var\ng,d,f:int64;\ns,otv:real;\ni,j,j2:longint;\ntx,txt:text;\na,b,c:string;\ncho2,cho:array[1..1000]of int64;\nbegin\nread(g,d,f);\nfor i:=0 to 11111 do\nif (g-i*d) mod f=0 then begin writeln('YES'); write(i,' ',(g-i*d) div f);halt;end;\nwrite('NO');\nend.\n"}, {"source_code": "var n,a,b,x,k:longint;\nbegin\n readln(n,a,b);\n if n mod a=0 then begin writeln('YES');\n writeln(n div a,' 0');halt; end\n else\n if n mod b=0 then begin writeln('YES');\n writeln('0 ',n mod b);halt;end;\n if b>a then\n begin\n x:=a;\n a:=b;\n b:=x;\n x:=2;\n end\n else\n x:=1;\n k:=0;\n while n>0 do\n begin\n n:=n-a;\n k:=k+1;\n if n mod b=0 then\n begin\n if x=1 then begin writeln('YES');\n writeln(k,' ',n div b);end\n else begin writeln('YES');\n writeln(n div b,' ',k); end;\n x:=0;\n break;\n end;\n end;\n if x<>0 then\n writeln('NO');\nend.\n \n \n\n "}, {"source_code": "var n,a,b,x,k:longint;\nbegin\n readln(n,a,b);\n if n mod a=0 then begin writeln('YES');\n writeln(n div a,' 0');halt; end\n else\n if n mod b=0 then begin writeln('YES');\n writeln('0 ',n mod b);halt;end;\n if b>a then\n begin\n x:=a;\n a:=b;\n b:=x;\n x:=2;\n end\n else\n x:=1;\n k:=0;\n while n>0 do\n begin\n n:=n-a;\n k:=k+1;\n if (n mod b=0)and(n>0) then\n begin\n if x=1 then begin writeln('YES');\n writeln(k,' ',n div b);end\n else begin writeln('YES');\n writeln(n div b,' ',k); end;\n x:=0;\n break;\n end;\n end;\n if x<>0 then\n writeln('NO');\nend.\n \n \n\n "}, {"source_code": "var a,s,d,f,g,h,j: integer;\nbegin\n read (a,s,d);\n for f:=1 to (a div s)+1 do\n for g:=1 to (a div d)+1 do\n if f*s+g*d=a then\n begin\n writeln ('YES');\n writeln (f);\n write (g);\n halt;\n end;\n write ('NO')\nend."}, {"source_code": "var a,s,d,f,g:integer;\nbegin\n read (a,s,d);\n for f:=0 to (a div s)+1 do\n if (a-f*s) mod d=0 then begin\n writeln ('YES');\n write (f,' ',(a-f*s) div d);\n halt;\n end;\n write ('NO')\nend."}, {"source_code": "var a,s,d,f,g,h,j: integer;\nbegin\n read (a,s,d);\n if ((d+s) mod 2 = 0) and (a mod 2=1) then begin write ('NO'); halt; end;\n for f:=0 to (a div s)+1 do\n for g:=0 to (a div d)+1 do\n if f*s+g*d=a then\n begin\n writeln ('YES');\n writeln (f);\n write (g);\n halt;\n end;\n write ('NO')\nend."}, {"source_code": "var\n n,a,b,i:longint;\nbegin\n readln(n);\n readln(a);\n readln(b);\n for i:=0 to n div a do\n if (n-i*a) mod b=0 then\n begin\n writeln('YES');\n writeln(i,' ',(n-i*a) mod b);\n halt;\n end;\n writeln('NO');\nend."}, {"source_code": "program abc;\nvar n,a,b,x,y:integer;\nbegin\nreadln(n,a,b);\nfor x := 0 to n div a do\nbegin\nif (n-a*x) mod b = 0 then begin\ny:=(n-a*x) div b;\nwriteln(x,' ',y);\nHalt(0);\nend;\nend;\nwriteln('NO');\nend."}, {"source_code": "var a,b,c,d,e,n,i,k:longint;\nbegin\nreadln(n,a,b);\nd:=n div a;\nif (n mod b=0)then begin\n writeln('Yes');\n write(0,' ',n div b);\n exit;\n end else if n mod a=0 then begin\n writeln('Yes');\n write(n div a,' ',0);\n exit;\n end;\nfor k:=d downto 1 do begin\nif (n-(k*a))mod b =0 then begin\n writeln('YES');\n write(k ,' ',(n-(k*a))div b);\n exit;\n end;\n end;\n write('NO');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:=1 to 1000000 do\nif (n-a*i) mod b=0 then begin writeln ('Yes'); write (i,' ',(n-a*i) div b); halt (0); end;\nwriteln ('No');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:= 0 to n do\nif (n - a * i >= 0) and ((n-a*i) mod b=0) then begin writeln ('YES'); write (i,' ',(n-a*i) div b); halt (0); end;\nwriteln ('NO');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:=1 to 1000000 do\nif (n-a*i) mod b=0 then begin writeln ('YES'); write (i,' ',(n-a*i) div b); halt (0); end;\nwriteln ('NO');\nend."}, {"source_code": "program s1;\nvar i,n,n1,a,b,c:integer;\nbegin\nreadln (n,a,b);\nfor i:=1 to 10000000 do\nif (n-a*i) mod b=0 then begin writeln ('YES'); write (i,' ',(n-a*i) div b); halt (0); end;\nwriteln ('NO');\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var hc,ac,hv,av,hh,ott,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,dx,dy,dz,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:array[-100..1000000] of int64;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n variant,peres,dd1,dd:array[-1..700,-1..6000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole :array [-10..1500,-10..1500] of char;\n st:array[-100..100000] of string;\n stest1,ss:string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nbegin\n \n read(cc,aa,bb);\n t:=round(cc/aa);\n for i:=0 to t do\n begin\n hh:=cc-i*aa;\n if hh mod bb=0 then \n begin\n writeln('YES');\n writeln(i,' ',hh div bb);\n goto 1;\n \n \n end;\n \n end;\n \n writeln('NO');\n \n \n\n \n\n\n\n\n 1: close(output);\nend.\n\n"}], "src_uid": "b031daf3b980e03218167f40f39e7b01"} {"source_code": "Uses Math;\nConst eps=10e-5;\nVar x,y:Array [1..3] of Extended;\n s,a,b,c,r,al,alp1,alp2,alp3,cs1,cs2,cs3,alr:Extended;\n i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (x[1],y[1]);\n Readln (x[2],y[2]);\n Readln (x[3],y[3]);\n s:=0.5*abs ((x[1]-x[3])*(y[2]-y[3])-(x[2]-x[3])*(y[1]-y[3]));\n a:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n b:=sqrt(sqr(x[1]-x[3])+sqr(y[1]-y[3]));\n c:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n r:=(a*b*c)/(4*s);\n For I:=3 to 100 do\n Begin\n\n al:=360/i;\n alr:=al/180*pi;\n cs1:=1-(a*a)/(2*r*r);\n alp1:=arccos(cs1);\n alp1:=alp1*180/pi;\n\n\n cs2:=1-(b*b)/(2*r*r);\n alp2:=arccos(cs2);\n alp2:=alp2*180/pi;\n\n\n cs3:=1-(c*c)/(2*r*r);\n alp3:=arccos(cs3);\n alp3:=alp3*180/pi;\n\n\n If (abs(Round(alp1/al)-alp1/al)0) or (frac(round(BOC*n)/360)>0) or (frac(round(AOC*n)/360)>0) do\n begin\n n:=n+1;\n end;\nS:=n/2*R*R*sin(2*pi/n);\nwriteln(S:20:6);\nreadln;\nend."}, {"source_code": "uses math;\nconst zero=1e-6;\ntype vector=record x,y:extended;end;\nvar\n\tp1,p2,p3:vector;\n\tla,lb,lc,a,b,c,R:extended;\n\ttmp,i:longint;\nfunction get(a,b,c:extended):extended;\nbegin\n\texit(arccos((b*b+c*c-a*a)/(2*b*c)));\nend;\nfunction dis(a,b:vector):extended;\nbegin\n\texit(sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)));\nend;\nfunction check(x:extended):boolean;\nbegin\n\ttmp:=round(x/pi);\n\tif abs(tmp*pi-x)/xeps) and (abs(y)>eps) do\n if x>y then\n x:=x-floor(x/y)*y\n else\n y:=y-floor(y/x)*x;\n exit(x+y);\nend;\nprocedure solve;\nvar a1,b1,c1,n,r,p,s:real;\nbegin\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/4/s;\n a1:=arccos((sqr(b)+sqr(c)-sqr(a))/2/b/c);\n b1:=arccos((sqr(c)+sqr(a)-sqr(b))/2/c/a);\n c1:=arccos((sqr(a)+sqr(b)-sqr(c))/2/a/b);\n n:=pi/gcd(gcd(a1,b1),c1);\n rslt:=n*sqr(r)*sin(pi*2/n)/2;\nend;\nprocedure print;\nbegin\n assign(output,fo);\n rewrite(output);\n write(rslt:0:6);\n close(output);\nend;\nbegin\n enter;\n init;\n solve;\n print;\nend."}, {"source_code": "uses math;\nconst eps = 0.001;\nvar\nok:boolean;\nb1,b2,c1,c2,la,cc,d1,d2,a1,a2,rr,del,tmp,len,x,y,x1,y1,x2,y2,x3,y3:extended;\nit,i,j:longint;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n end;\n\nfunction dd(xx,yy:extended):extended;\n begin\n dd:=max(dist(xx,yy,x1,y1),max(\n dist(xx,yy,x2,y2)\n ,dist(xx,yy,x3,y3)));\n end;\n\nfunction arccoss(x:extended):extended;\n begin\n if x>1-eps then arccoss:=0 else\n if x<-1+eps then arccoss:=pi\n else arccoss:=arccos(x);\n end;\n\n begin\n readln(x1,y1,x2,y2,x3,y3);\n {\n x:=0;\n y:=0;\n\n del:=1000;\n len:=dd(0,0);\n for it:=1 to 10000 do\n begin\n ok:=true;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then\n begin\n tmp:=dd(x+i*del,y+j*del);\n if tmpeps then ok:=false;\n\n cc:=a2/la;\n if frac(cc+eps/100)>eps then ok:=false;\n\n\n if ok then\n begin\n writeln(i/2*rr*rr*sin(2*pi/i):0:6);\n halt(0);\n end;\n end;\n end.\n"}, {"source_code": "uses math;\nconst\ne=0.0001;\nvar\nx1,y1,x2,y2,x3,y3,r,s,a,b,c,p,r1,r2,r3,m:real;\ni:longint;\nfunction d(q,w,e,r:real):real;\nbegin\nd:=sqrt(sqr(q-w)+sqr(e-r));\nend;\nfunction gcd(x,y:real):real;\nbegin\nif (y>=-e) and (y<=e)\nthen gcd:=x else\ngcd:=gcd(y,x-trunc(x/y)*y);\nend;\n\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nreadln(x3,y3);\na:=d(x1,x2,y1,y2);\nb:=d(x1,x3,y1,y3);\nc:=d(x2,x3,y2,y3);\np:=(a+b+c)/2;\ns:=sqrt(p*(p-a)*(p-b)*(p-c));\nr:=(a*b*c)/(4*s);\nr1:=arccos((b*b+c*c-a*a)/(2*b*c))*2;\nr2:=arccos((a*a+c*c-b*b)/(2*a*c))*2;\nr3:=arccos((a*a+b*b-c*c)/(2*a*b))*2;\nm:=gcd(r1,r2);\nm:=gcd(m,r3);\ns:=(r*r*sin(m)*pi/m);\nwriteln(s:0:8);\nend."}, {"source_code": "Program C1;\nvar xA, yA, xB, yB, xC, yC, AB, BC, AC, p, R, AOB, AOC, BOC, A, OA, S, x, y, z:extended;\n n:integer;\nbegin\nreadln(xA, yA);\nreadln(xB, yB);\nreadln(xC, yC);\nAB:=(xA-xB)*(xA-xB)+(yA-yB)*(yA-yB);\nAB:=sqrt(AB);\nAC:=(xA-xC)*(xA-xC)+(yA-yC)*(yA-yC);\nAC:=sqrt(AC);\nBC:=(xB-xC)*(xB-xC)+(yB-yC)*(yB-yC);\nBC:=sqrt(BC);\np:=(AB+BC+AC)/2;\nR:=AB*BC*AC/4/sqrt(p*(p-AB)*(p-BC)*(p-AC));\nx:=(2*R*R-AB*AB)/2/R/R;\nAOB:=arctan(sqrt(1/x/x-1))/pi*180;\nif x<0 then AOB:=180-AOB;\ny:=(2*R*R-AC*AC)/2/R/R;\nAOC:=arctan(sqrt(1/y/y-1))/pi*180;\nif y<0 then AOC:=180-AOC;\nz:=(2*R*R-BC*BC)/2/R/R;\nBOC:=arctan(sqrt(1/z/z-1))/pi*180;\nif z<0 then BOC:=180-BOC;\nn:=3;\nwhile (frac(round(AOB*n)/360)>0) or (frac(round(BOC*n)/360)>0) or (frac(round(AOC*n)/360)>0) do\n begin\n n:=n+1;\n end;\nS:=n/2*R*R*sin(2*pi/n);\nwriteln(S:20:6);\nreadln;\nend."}, {"source_code": "uses math ;\nconst\n tfi = '';\n tfo = '';\n e = 0.00001 ;\nvar\n fi,fo : text;\n n : longint ;\n x,y,z:array[1..3] of extended ;\n r,u1,u2,u3,rr : extended;\nprocedure Nhap;\nvar\n i,j :longint;\nbegin\n read(fi,x[1],y[1],x[2],y[2],x[3],y[3]) ;\nend;\nfunction Kk(i,j :longint) :extended;\nvar\n kk0 :extended;\nbegin\n kk0 := sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i] - y[j])*(y[i]-y[j])) ;\n exit(kk0);\nend;\nprocedure init;\nvar\n i,j,k: longint;\nbegin\n r := abs((x[2]-x[1])*(y[2]+y[1])+(x[3]-x[2])*(y[3]+y[2])+(x[1]-x[3])*(y[1]+y[3]));\n r := Kk(1,2) * kK(2,3) * kk(3,1)/(2 * r) ;\n u1 := arccos((r*r*2-kk(1,2)*kk(1,2))/(2*r*r));\n u2 := arccos((r*r*2-kk(2,3)*kk(2,3))/(2*r*r)) ;\n u1 := arccos((r*r*2-kk(1,3)*kk(1,3))/(2*r*r)) ;\nend;\nfunction check(x:extended):boolean;\nvar\n i :longint;\nbegin\n if x <= e then exit(true) ;\n for i := 1 to 100 do if abs(rr * i - x) <= e then exit(true) ;\n exit(false) ;\nend;\nprocedure xuly;\nvar\n i,j,k: longint;\nbegin\n for i := 3 to 100 do\n begin\n rr := 2*pi/i ;\n if check(u1) and check(u2) and check(u3) then\n begin\n k := i ;\n break ;\n end ;\n end ;\n r := r * r * sin(2*pi/k)*k/2 ;\n write(fo,r :0:10);\nend ;\nprocedure inkq;\nbegin\n\nend;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n Nhap;\n init;\n xuly;\n inkq;\n close(fi);\n close(fo) ;\nend.\n"}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "program Zc;\n\n{$APPTYPE CONSOLE}\n{$MODE DELPHI}\nuses\n SysUtils,Math;\n\ntype point=record\n x,y:extended;\n end;\n line=record\n a,b,c:extended;\n end;\nfunction serper(a,b:point):line;\nbegin\n result.a:=b.x-a.x;\n result.b:=b.y-a.y;\n result.c:=-(result.a*(a.x+b.x)/2+result.b*(a.y+b.y)/2);\nend;\nfunction l2p(a,b:line):point;\nvar dd,dx,dy:extended;\nbegin\n dd:=a.a*b.b-a.b*b.a;\n dx:=a.c*b.b-a.b*b.c;\n dy:=a.a*b.c-a.c*b.a;\n result.x:=-dx/dd;\n result.y:=-dy/dd;\nend;\nfunction vp(a,b:point):extended;\nbegin\n result:=a.x*b.y-a.y*b.x;\nend;\nfunction sp(a,b:point):extended;\nbegin\n result:=a.x*b.x+a.y*b.y;\nend;\nfunction dst(a,b:point):extended;\nbegin\n result:=sqr(a.x-b.x)+sqr(a.y-b.y);\nend;\nfunction v(a,b:point):point;\nbegin\n result.x:=b.x-a.x;\n result.y:=b.y-a.y;\nend;\nvar p1,p2,p3,o:point;\n alp1,alp2,alp0:extended;\n p:integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n //writeln(1/sqrt(2):0:10);\n read(p1.x,p1.y,p2.x,p2.y,p3.x,p3.y);\n o:=l2p(serper(p1,p2),serper(p2,p3));\n alp1:=arctan2(vp(v(o,p1),v(o,p2)),sp(v(o,p1),v(o,p2)));\n if alp1<0 then alp1:=alp1+2*pi;\n alp2:=arctan2(vp(v(o,p1),v(o,p3)),sp(v(o,p1),v(o,p3)));\n if alp2<0 then alp2:=alp2+2*pi;\n alp1:=min(alp1,2*pi-alp1);\n alp2:=min(alp2,2*pi-alp2);\n for p:=3 to 10000 do begin\n alp0:=2*pi/p;\n if abs(alp1/alp0-round(alp1/alp0))<1e-5 then begin\n if abs(alp2/alp0-round(alp2/alp0))<1e-5 then begin\n writeln(p*dst(o,p1)*sin(alp0)/2:0:15);\n halt;\n end;\n end;\n end;\nend.\n "}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "{$Q-}\nuses math;\nvar r,aa,bb,cc,a,b,c,x1,y1,x2,y2,x3,y3,n,s,p:extended;\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\nend;\nfunction gcd(x,y:extended):extended;\nconst eps=1e-4;\nbegin\n while (abs(x)>eps)and(abs(y)>eps) do\n begin\n if x>y then x:=x-floor(x/y)*y\n else y:=y-floor(y/x)*x;\n end;\n gcd:=x+y;\nend;\nbegin\n read(x1,y1,x2,y2,x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x1,y1,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/(4*s);\n aa:=arccos((sqr(b)+sqr(c)-sqr(a))/(2*b*c));\n bb:=arccos((sqr(c)+sqr(a)-sqr(b))/(2*c*a));\n cc:=arccos((sqr(a)+sqr(b)-sqr(c))/(2*a*b));\n n:=pi/(gcd(gcd(aa,bb),cc));\n writeln(n/2*r*r*sin(2*pi/n):0:6);\nend."}, {"source_code": "uses\n math;\nconst\n eps=1e-4;\nvar\n d1,d2,d3,r,s,x0,y0,d,dx,dy,a1,b1,c1,a2,b2,c2,x1,y1,x2,y2,x3,y3,ug1,ug2,ug3:double;\n i:longint;\n function ok(a,b:double):boolean;\n var\n x:double;\n begin\n x:=trunc((a+b+eps)/b);\n x:=x*b;\n ok:=abs(x-a-b) eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "USES\n Math;\nVAR\n x, y, l, g:array[1..3] of extended;\n p, r, s, n:extended;\nFunction GCD(a, b:extended):extended;\nVar\n eps:extended;\nBegin\n eps:=0.001;\n while (abs(a) > eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "USES\n Math;\nVAR\n x, y, l, g:array[1..3] of extended;\n p, r, s, n:extended;\nFunction GCD(a, b:extended):extended;\nVar\n eps:extended;\nBegin\n eps:=0.001;\n while (abs(a) > eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n { a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n }\n\n a1:=-(x[1]-x[2]);//y2-y1;\n b1:=y[2]-y[1];//x1-x2;\n c1:=-a1*(x[1]+x[2])/2-b1*(y[1]+y[2])/2;\n\n a2:=-(x[2]-x[3]);//y3-y2;\n b2:=y[3]-y[2];//x2-x3;\n c2:=-a2*(x[2]+x[3])/2-b2*(y[2]+y[3])/2;\n\n xx:=(c1*b2-c2*b1)/(a2*b1-a1*b2);\n yy:=(c1*a2-c2*a1)/(a1*b2-a2*b1);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend."}, {"source_code": "uses math;\nvar\n i : longint;\n x,y,d,u : array [0..5] of double;\n r,s,p : double;\n\n function ok(n : longint; u : double) : boolean;\n begin\n u:=min(u,1);\n if abs(sin(n*arcsin(u))/2)<1e-4 then exit(true) else exit(false);\n end;\n\n function dist(x1,y1,x2,y2 : double) : double;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n x[4]:=x[1]; y[4]:=y[1];\n for i:=2 to 4 do d[i-1]:=dist(x[i],y[i],x[i-1],y[i-1]);\n for i:=1 to 3 do p:=p+d[i];\n p:=p/2;\n s:=sqrt(p*(p-d[1])*(p-d[2])*(p-d[3]));\n r:=d[1]*d[2]*d[3]/(4*s);\n for i:=1 to 3 do u[i]:=d[i]/(2*r);\n for i:=3 to 100 do\n if ok(i,u[1]) and ok(i,u[2]) and ok(i,u[3]) then\n begin\n writeln(i*sin(2*pi/i)*r*r/2:0:7);\n break;\n end;\nend.\n"}, {"source_code": "uses math;\n\nconst\n zero =1e-5;\n pi =3.1415926535;\n\nvar\n x,y :array[0..3] of extended;\n dist :array[0..3,0..3] of extended;\n\nprocedure init;\nvar\n i :longint;\nbegin\n for i:=1 to 3 do\n readln(x[i],y[i]);\nend; { init }\n\nfunction check(a,b:extended):boolean;\nvar\n t :longint;\nbegin\n t:=round(a/b);\n if abs(t-a/b)j then\n dist[i][j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n cosa:=(sqr(dist[1][2])+sqr(dist[1][3])-sqr(dist[2][3]))/(2*dist[1][2]*dist[1][3]);\n sina:=sqrt(1-sqr(cosa));\n r:=dist[2][3]/(2*sina);\n for i:=1 to 3 do\n for j:=1 to 3 do\n if i<>j then\n dist[i][j]:=arcsin(dist[i][j]/(2*r))*2;\n for i:=3 to 100 do\n begin\n t:=2*pi/i;\n if not check(dist[1][2],t) then continue;\n if not check(dist[1][3],t) then continue;\n if not check(dist[2][3],t) then continue;\n ans:=r*r*sin(t)/2*i;\n writeln(ans:0:8);\n exit;\n end;\nend; { work }\n\nbegin\n init;\n work;\nend.\n\n"}, {"source_code": "\nuses math;\n\nconst eps=1e-2;\n\nvar aa,bb,cc,p,a,b,c,r,s,x1,y1,x2,y2,x3,y3:extended;\n n:extended;\n\n function dis(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n\n function find(a,b:extended):extended;\n begin\n while (a>eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end.\n\n"}, {"source_code": "\nuses math;\n\nconst eps=0.1;\n\nvar aa,bb,cc,p,a,b,c,r,s,x1,y1,x2,y2,x3,y3:extended;\n n:extended;\n\n function dis(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n\n function find(a,b:extended):extended;\n begin\n while (a>eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end.\n\n"}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction r(x,y:extended):boolean;\nbegin\n if abs(x-y)<1e-9 then r:=true\n else r:=false;\nend;\n\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-8000;\n yr:=8000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\nfunction search2(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search2:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-8000;\n xr:=8000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n a:=dist(0,0,x[1],y[1]);\n b:=dist(0,0,x[2],y[2]);\n c:=dist(0,0,x[3],y[3]);\n\n if (not r(a,p))or(not r(b,p))or(not r(c,p)) then\n begin\n for i:=1 to n do\n begin\n x[i]:=x[i]+xx;\n y[i]:=y[i]+yy;\n end;\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search2(xx);\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "Uses math;\nvar n:longint;\n ns,ans,k,p,ac,bc,cc,x3,y3,x1,y1,x2,y2,a,b,c,r,s:extended;\nfunction dist(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\nfunction nsd(x,y:extended):extended;\n begin\n while(abs(x)>0.0001)and(abs(y)>0.0001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:6);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,S+}\nuses\n SysUtils,Math;\nconst\n Pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651;\nprocedure SWAP(var a,b:integer);\nvar\n q:Integer;\nbegin\n q:=a;\n a:=b;\n b:=q;\nend;\nfunction NOD(x,y: extended): extended;\nbegin\n while (Abs(x)>0.0001)and(Abs(y)>0.0001) do begin\n if x>y then x:= x - floor(x / y) * y\n else y:= y - floor(y / x) * x;\n end;\n Result := x + y;\nend;\nvar\n i,n:Integer;\n r,p,a,b,c,au,bu,cu:Extended;\n x,y:array[1..3] of extended;\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n\n a:=Sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));\n b:=Sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));\n c:=Sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));\n p:=(a+b+c)/2;\n r:=a*b*c/(4*sqrt(p*(p-a)*(p-b)*(p-c)));\n\n au:=arccos((b*b+c*c-a*a)/(2*b*c));\n bu:=arccos((a*a+c*c-b*b)/(2*a*c));\n cu:=arccos((b*b+a*a-c*c)/(2*b*a));\n\n n:=Round(pi/NOD(NOD(au,bu),cu));\n write((n*r*r*sin(2*pi/n)/2):0:6);\nend."}, {"source_code": "uses\n SysUtils, math;\nvar\n i: integer;\n R,x1,x2,x3,y1,y2,y3,a,b,c,a1,a2,amin: real;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=2*arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=2*arccos((a*a+c*c-b*b)/(2*a*c));\n R:=c/(2*sin(a1/2));\n i:=3;\n while (i>0)and(i<105) do begin\n amin:=2*pi/i;\n If (abs(round(a1/amin)-a1/amin)<0.0001)and(abs(round(a2/amin)-a2/amin)<0.0001)\n then begin\n x1:=R*R*sin(amin)*i/2;\n i:=-6;\n end;\n i:=i+1;\n end;\n writeln(x1,' ');\n read(amin);\n\nend."}, {"source_code": "USES\n Math;\nVAR\n x, y, l, g:array[1..3] of extended;\n p, r, s, n:extended;\nFunction GCD(a, b:extended):extended;\nVar\n eps:extended;\nBegin\n eps:=0.001;\n while (abs(a) > eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND.\n\n"}, {"source_code": "{$Q+,R+,S+}\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\n\ntype real = extended;\n\nconst eps: real = 1e-4;\n\ntype tpoint = record x, y: real; end;\n tline = record a, b, c: real; end;\n\nvar a, b, c: tpoint;\n\nprocedure readData;\nbegin\n read(a.x, a.y, b.x, b.y, c.x, c.y)\nend;\n\nfunction plus(a, b: tpoint): tpoint;\nbegin\n result.x := a.x + b.x; result.y := a.y + b.y\nend;\n\nfunction eq(a, b: real): boolean;\nbegin\n result := abs(a-b) < eps\nend;\n\nfunction eqp(a, b: tpoint): boolean;\nbegin\n result := eq(a.x, b.x) and eq(a.y, b.y)\nend;\n\nfunction work(s, d: tpoint; ang: integer): boolean;\nvar f1, f2, f3: boolean;\n now, next: tpoint;\n x: real;\n i: integer;\nbegin\n f1 := false; f2 := false; f3 := false;\n now := plus(s, d); x := 2 * Pi / ang;\n for i := 1 to ang do begin\n f1 := f1 or eqp(now, a); f2 := f2 or eqp(now, b); f3 := f3 or eqp(now, c);\n next.x := s.x + (now.x-s.x)*cos(x) + (now.y-s.y)*(-sin(x));\n next.y := s.y + (now.x-s.x)*sin(x) + (now.y-s.y)*cos(x);\n now := next;\n end;\n result := f1 and f2 and f3;\nend;\n\nfunction getl(a, b: tpoint): tline;\nbegin\n result.a := a.y-b.y;\n result.b := b.x-a.x;\n result.c := result.a*a.x + result.b*a.y\nend;\n\nfunction getc(a, b: tline): tpoint;\nbegin\n result.x := (a.c*b.b-a.b*b.c) / (a.a*b.b-a.b*b.a);\n result.y := (a.a*b.c-a.c*b.a) / (a.a*b.b-a.b*b.a)\nend;\n\nfunction getp(l: tline; a, b: tpoint): tline;\nvar p: tpoint;\nbegin\n result.a := -l.b;\n result.b := l.a;\n p.x := (a.x+b.x)/2; p.y := (a.y+b.y)/2;\n result.c := result.a*p.x + result.b*p.y\nend;\n\nvar r: real;\n\nfunction solve: integer;\nvar l1, l2, p1, p2: tline; x, d: tpoint; i: integer;\nbegin\n l1 := getl(a, b); l2 := getl(b, c);\n p1 := getp(l1, a, b); p2 := getp(l2, b, c);\n x := getc(p1, p2);\n d.x := a.x - x.x; d.y := a.y - x.y;\n r := d.x*d.x+d.y*d.y;\n for i := 3 to 100 do\n if work(x, d, i) then begin result := i; break end;\nend;\n\nprocedure save(x: integer);\nbegin\n write(x*0.5*r*sin(2*Pi/x):0:6)\nend;\n\nvar i, n: integer;\nbegin\n {assign(input, 'input.txt'); reset(input);\n assign(output, 'output.txt'); rewrite(output);}\n readData; save(solve);\n {close(output);\n close(input);}\nend."}, {"source_code": "program Project1_C;\n{$APPTYPE CONSOLE}\nconst eps=0.1;\nvar i,j,k:longint;\n x1,y1,x2,y2,x3,y3,a,b,c,aa,bb,cc:extended;\nfunction rast(x1,y1,x2,y2:extended):extended;\nbegin\n result:=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\nend;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n read(x1,y1,x2,y2,x3,y3);\n a:=rast(x1,y1,x2,y2);\n b:=rast(x1,y1,x3,y3);\n c:=rast(x2,y2,x3,y3);\n\n for i:=3 to 100 do\n for j:=1 to i-1 do\n for k:=1 to i-1 do\n begin\n if j=k then continue;\n aa:=rast(1,0,cos(2*pi*j/i),sin(2*pi*j/i));\n bb:=rast(1,0,cos(2*pi*k/i),sin(2*pi*k/i));\n cc:=rast(cos(2*pi*j/i),sin(2*pi*j/i),cos(2*pi*k/i),sin(2*pi*k/i),);\n if (a*bbaa*b)and(b*cc+eps>bb*c)and(a*cc+eps>aa*c)then\n begin\n write((i*sin(2*pi/i)/2)*(a/aa):0:7);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n { a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n }\n\n a1:=-(x[1]-x[2]);//y2-y1;\n b1:=y[2]-y[1];//x1-x2;\n c1:=-a1*(x[1]+x[2])/2-b1*(y[1]+y[2])/2;\n\n a2:=-(x[2]-x[3]);//y3-y2;\n b2:=y[3]-y[2];//x2-x3;\n c2:=-a2*(x[2]+x[3])/2-b2*(y[2]+y[3])/2;\n\n xx:=(c1*b2-c2*b1)/(a2*b1-a1*b2);\n yy:=(c1*a2-c2*a1)/(a1*b2-a2*b1);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "\nuses math;\n\nconst eps=0.1;\n\nvar aa,bb,cc,p,a,b,c,r,s,x1,y1,x2,y2,x3,y3:extended;\n n:extended;\n\n function dis(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n\n function find(a,b:extended):extended;\n begin\n while (a>eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end."}, {"source_code": "uses math;\nconst\n nmax = 100;\n e = 1e-5;\ntype\n point = record\n x,y:real;\n end;\nvar\n n,m:longint;\n res,R,S:extended;\n leng,goc:array[0..5] of extended;\n p:array[0..4] of point;\nprocedure nhap;\nvar i,j,u,v:longint;\nbegin\n for i:=1 to 3 do\n readln(p[i].x,p[i].y);\n p[4]:=p[1];\nend;\nfunction get(u,v:extended;m:longint):boolean;\nvar i:longint;\nbegin\n for i:=1 to m do if abs(i*u-v)<=e then exit(true);\n exit(false);\nend;\nprocedure xuly;\nvar i,j,v:longint;\nu:extended;\ncheck:boolean;\nbegin\n res:=1000000000;\n for i:=1 to 3 do\n S:=S+(p[i].x-p[i+1].x)*(p[i].y+p[i+1].y);\n S:=abs(S)*2;\n R:=1;\n for i:=1 to 3 do Leng[i]:=sqrt(sqr(p[i].x-p[i+1].x)+sqr(p[i].y-p[i+1].y));\n for i:=1 to 3 do R:=R*Leng[i];\n R:=R/S;\n for i:=1 to 3 do\n goc[i]:=arccos((2*R*R-Leng[i]*Leng[i])/(2*R*R));\n for i:=3 to 100 do\n\n begin\n check:=true;\n u:=2*pi/i;\n for j:=1 to 3 do if not get(u,goc[j],i) then\n begin\n check:=false;\n break;\n end;\n if not check then continue;\n res:=min(res,(i*R*R*sin(u))/2);\n end;\n writeln(res:0:8);\nend;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n nhap;\n xuly;\n close(input);\n close(output);\nend."}, {"source_code": "uses math;\nconst eps=0.00001;\n \nvar x1,x2,x3,y1,y2,y3,x4,y4,x5,y5: double;\n R, S,a,b,c, aa, bb, cc,f1,f2,f3,fi: double;\n n: integer;\n\n \nfunction dlin(xa,ya, xb,yb: double):double; \nvar res: double;\nbegin\n dlin:=sqrt(sqr(xb-xa)+sqr(yb-ya));\nend; \n\n\nfunction ugol(x,y,z: double): double;\nbegin\n ugol:=arccos((sqr(y)+sqr(z)-sqr(x))/(2*y*z));\nend;\n\nfunction radius(x,y,z: double): double;\nvar p,r: double;\nbegin\n p:=(x+y+z)/2;\n r:=x*y*z/4/sqrt(p*(p-x)*(p-y)*(p-z));\n radius:=r;\nend;\n\nfunction plotsha(r, m: double): double;\nbegin\n plotsha:=M*0.5*r*r*sin(2*Pi/M);\nend;\n\n \nbegin\n readln(x3,y3);\n readln(x1,y1);\n readln(x2,y2);\n\n a:=dlin(x2,y2, x3,y3);\n b:=dlin(x1,y1, x2,y2);\n c:=dlin(x1,y1, x3,y3);\n \n \n aa:=ugol(a, b,c);\n bb:=ugol(b, a,c);\n cc:=ugol(c, a,b);\n \n \n f1:=2*aa; f2:=2*bb; f3:=2*cc;\n \n N:=3;\n while N<=102 do\n begin\n \n fi:=2*Pi/N;\n if (abs(round(f1/fi)-f1/fi)delta then continue;\n if abs((beta/sigma)-round(beta/sigma))>delta then continue;\n if abs((gamma/sigma)-round(gamma/sigma))>delta then continue;\n S:=0.5*R*R*sin(sigma)*n;\n writeln(s:0:15);\n break;\n end;\nend.\n"}, {"source_code": "uses math;\n\nconst\n e=0.0001;\n\nvar\n n:array[1..3,1..2]of double;\n a,b,c,s,r,x,y,z,m,p:double;\n\n\nfunction gcd(x,y:double):double;\nbegin\n if (y>=-e) and (y<=e) then exit(x)\n else exit(gcd(y,x-trunc(x/y)*y));\nend;\n\nbegin\n readln(n[1,1],n[1,2]);\n readln(n[2,1],n[2,2]);\n readln(n[3,1],n[3,2]);\n a:=sqrt(sqr(n[1,1]-n[2,1])+sqr(n[1,2]-n[2,2]));\n b:=sqrt(sqr(n[1,1]-n[3,1])+sqr(n[1,2]-n[3,2]));\n c:=sqrt(sqr(n[2,1]-n[3,1])+sqr(n[2,2]-n[3,2]));\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/(4*s);\n x:=arccos((b*b+c*c-a*a)/(2*b*c))*2;\n y:=arccos((a*a+c*c-b*b)/(2*a*c))*2;\n z:=arccos((a*a+b*b-c*c)/(2*a*b))*2;\n m:=gcd(x,y);\n m:=gcd(m,z);\n s:=(r*r*sin(m)*pi/m);\n writeln(s:0:8);\nend.\n\n\n\n\n\n"}, {"source_code": "const s3_5 = -0.44252044;\n fin = 'stdin';\n fout = 'stdout';\nvar x1,x2,x3,y1,y2,y3,r,a,b,c,u1,u2,u3,u0,res1,res2,res3:real;\n i:integer;\nfunction getL(x1,y1,x2,y2:real):real;\nbegin\n getL := sqrt(sqr(x1-x2)+sqr(y1-y2));\nend;\nfunction ArcCos ( X : real): real;\nvar tmpArcCos : real;\nbegin\n if X = 0.0 then { from devide by zerp }\n tmpArcCos := Pi / 2.0\n else\n tmpArcCos := ArcTan ( Sqrt ( 1 - X * X ) / X );\n\n if X < 0.0 then\n tmpArcCos := Pi - tmpArcCos;\n\n ArcCos := tmpArcCos;\nend;\n\nfunction ArcSin ( X : real ): real;\nbegin\nif X = 1.0 then { from devide by zero }\nArcSin := Pi / 2.0\nelse\nArcSin := ArcTan ( X / Sqrt ( 1 - X * X ) );\nend;\nfunction _round(x:real;i:integer):real;\nbegin\n _round:=round(x*exp(i*ln(10)))/exp(i*ln(10));\nend;\nfunction getU(a,r:real):real;\nvar x :real;\nbegin\n x := a/(2*r);\n getU:=arcsin(x);\nend;\nBegin\n //assign(input,fin);\n //assign(output,fout);\n //reset(input);\n //rewrite(output);\n\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a := getL(x1,y1,x2,y2);\n b := getL(x2,y2,x3,y3);\n c := getL(x3,y3,x1,y1);\n r := a*b*c/sqrt((a+b+c)*(-a+b+c)*(a+b-c)*(a-b+c));\n u1 := getU(a,r)*2;\n u2 := getU(b,r)*2;\n u3 := getU(c,r)*2;\n for i := 3 to 100 do\n begin\n u0:=2*Pi/i;\n res1 := u1/u0;\n res2 := u2/u0;\n res3 := u3/u0;\n if (\n (_round(res1,5)=int(res1+0.00001))\n and (_round(res2,5) = int(res2+0.00001))\n and (_round(res3,5) = int(res3+0.00001))\n ) then\n begin\n writeln(_round(sqr(r)*sin(u0)*0.5*i,6):0:6);\n break;\n end;\n end;\n //writeln(i);\n //close(input);\n //close(output);\nEnd.\n"}, {"source_code": "const\n eps=1e-5;\n\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n {\n assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n }\n\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n if (abs(x1)0)then a:=2*pi-a;\n if (y1>0)and(x1<0)then a:=pi-a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 1000 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*cos(a);\n ay:=r*sin(a);\n if (abs(ax-x1) 0.0001) and (b > 0.0001) do\n \tif a > b then a:=a - b else b:=b - a;\n gcd:=a + b;\nend;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n d1:=sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n d2:=sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));\n d3:=sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));\n u:=(d1 + d2 + d3) / 2;\n s:=sqrt(u * (u - d1) * (u - d2) * (u - d3));\n r:=(d1 * d2 * d3) / (4 * s);\n\n a:=arccos((d3 * d3 + d2 * d2 - d1 * d1) / (2 * d2 * d3));\n b:=arccos((d3 * d3 + d1 * d1 - d2 * d2) / (2 * d1 * d3));\n c:=arccos((d1 * d1 + d2 * d2 - d3 * d3) / (2 * d1 * d2));\n\n n:=pi / gcd(a,gcd(b,c));\n\n write(n / 2 * r * r * sin(2 * pi / n):0:6);\nend."}, {"source_code": "program P1C;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes, Math\n { you can add units after this };\nvar\n i: Integer;\n\ntype\n TPoint= record\n x, y: Extended;\n\n end;\n\nfunction Distance (P1, P2: TPoint): Extended;\nbegin\n Result:= Sqrt (Sqr (P1.x- P2.x)+ Sqr (P1.y- P2.y));\n\nend;\n\nfunction SubtractPoint (A, B: TPoint): TPoint;\nbegin\n Result:= A;\n Result.x-= B.x;\n Result.y-= B.y;\n\nend;\n\nfunction GetDistance (A, B: TPoint): Extended;\nbegin\n Result:= Sqrt (Sqr (A.x- B.x)+ Sqr (A.y- B.y));\n\nend;\n\nfunction GetAngle (A, B, C: TPoint): Extended;\n\n function _GetAngle (C: TPoint): Extended;{C, (0,0), (1, 0)}\n begin\n Result:= ArcCos (C.x/ Sqrt (Sqr (C.x)+ Sqr (C.y)));\n\n if C.y< 0 then\n Result:= 2* Pi- Result;\n\n end;\nvar\n aa, bb, cc: Extended;\n d: Extended;\n\nbegin\n Result:= _GetAngle (SubtractPoint (A, B))- _GetAngle (SubtractPoint (C, B));\n if Result< 0 then\n Result+= 2* Pi;\n\n cc:= GetDistance (A, B);\n bb:= GetDistance (A, C);\n aa:= GetDistance (B, C);\n\n d:= arccos ((aa*aa+cc*cc-bb*bb)/(2*aa*cc));\n if (1e-6< Abs (Result- d)) and\n (1e-6< Abs (Result- 2* Pi+ d)) then\n WriteLn ('Error');\n\n// Result:= d;\nend;\n\nfunction CirclePassing (P1, P2, P3: TPoint): TPoint;\nvar\n x, y: array [0..3] of Extended;\n x1, y1, dy1, dx1: Extended;\n x2, y2, dy2, dx2: Extended;\n\nbegin\n x [1]:= P1.x; x [2]:= P2.x; x [3]:= P3.x;\n y [1]:= P1.y; y [2]:= P2.y; y [3]:= P3.y;\n\n x1:= (x [2] + x [1]) / 2;\n y1:= (y [2] + y [1]) / 2;\n dy1:= x [2]- x [1];\n dx1:= -(y [2]- y [1]);\n\n x2:= (x [3] + x [2]) / 2;\n y2:= (y [3]+ y [2]) / 2;\n dy2:= x [3] - x [2];\n dx2:= -(y [3]- y [2]);\n\n Result.x:= (y1 * dx1 * dx2 + x2 * dx1 * dy2 - x1 * dy1 * dx2 - y2 * dx1 * dx2)/ (dx1 * dy2 - dy1 * dx2);\n Result.y:= (Result.x - x1) * dy1 / dx1 + y1;\n\n{\n WriteLn ('A:', Distance (Result, P1), ' * ', Distance (Result, P2));\n WriteLn ('B:', Distance (Result, P1), ' * ', Distance (Result, P3));\n}\n\nend;\n\nvar\n P: array [0..4] of TPoint;\n\nfunction Solve: Extended;\n\nvar\n Center: TPoint;\n Angles: array [0..2] of Extended;\n Ang: Extended;\n n, i: Integer;\n Flag: Boolean;\n Radius: Extended;\n\nbegin\n Center:= CirclePassing (P [1], P [2], P [3]);\n Radius:= Distance (Center, P [1]);\n Assert (1e-6< Abs (Radius- Distance (Center, P [2])));\n Assert (1e-6< Abs (Radius- Distance (Center, P [3])));\n\n Angles [0]:= GetAngle (P [1], Center, P [2]);\n// Angles [0]:= GetAngle (P [2], Center, P [1]);\n Angles [1]:= GetAngle (P [1], Center, P [3]);\n// Angles [0]:= GetAngle (P [3], Center, P [1]);\n Angles [2]:= GetAngle (P [2], Center, P [3]);\n// Angles [0]:= GetAngle (P [3], Center, P [2]);\n\n// WriteLn (Angles [0]/ Pi* 180.0:0:3, ' ', Angles [1]/ Pi* 180.0:0:3, ' ', Angles [2]/ Pi* 180.0:0:3);\n for n:= 2 to 360 do\n begin\n Ang:= 2* Pi/ n;\n Flag:= True;\n for i:= 0 to 2 do\n if 1e-4< Abs (Round (Angles [i]/ Ang)- Angles [i]/ Ang) then\n Flag:= False;\n\n if Flag then\n begin\n Result:= n* Sqr (Radius)* Sin (Ang)/ 2.0;\n Exit;\n\n end;\n\n end;\n\nend;\n\nbegin\n {\n AssignFile (Input, 'Input.txt');\n Reset(Input);\n }\n for i:= 1 to 3 do\n ReadLn (P [i].X, P [i].y);\n\n WriteLn (Solve:0:6);\n// WriteLn (Solve1:0:6);\nend.\n\n"}, {"source_code": "program problemC;\nuses Crt;\nvar\n infile, outfile: text;\n x1, y1, x2, y2, x3, y3: real;\n a, b, c, S, R, p: real;\n bettaRad, gammaRad, tettaRad: real;\n bettaGrad, gammaGrad, tettaGrad: real;\n n, i, j, k: integer;\n angle: real;\n deltaBetta, deltaGamma, deltaTetta: real;\n flag1, flag2, flag3, breakflag: boolean;\nbegin\n ClrScr;\n assign(infile, '');\n assign(outfile, '');\n reset(infile);\n readln(infile, x1, y1);\n readln(infile, x2, y2);\n readln(infile, x3, y3);\n close(infile);\n a := sqrt(sqr(y2-y1) + sqr(x2-x1));\n b := sqrt(sqr(y3-y2) + sqr(x3-x2));\n c := sqrt(sqr(y3-y1) + sqr(x3-x1));\n p := 0.5*(a+b+c);\n S := sqrt(p*(p-a)*(p-b)*(p-c));\n R := (a*b*c)/(4*S);\n\n if round((2*R*1000000)-(a*1000000))=0 then\n bettaRad := pi\n else\n bettaRad := 2*arctan((a/(2*R))/sqrt(1-sqr(a/(2*R))));\n\n if round((2*R*1000000)-(b*1000000))=0 then\n gammaRad := pi\n else\n gammaRad := 2*arctan((b/(2*R))/sqrt(1-sqr(b/(2*R))));\n\n if round((2*R*1000000)-(c*1000000))=0 then\n tettaRad := pi\n else\n tettaRad := 2*arctan((c/(2*R))/sqrt(1-sqr(c/(2*R))));\n\n bettaGrad := bettaRad*180/pi;\n gammaGrad := gammaRad*180/pi;\n tettaGrad := tettaRad*180/pi;\n\n rewrite(outfile);\n\n flag1 := false;\n flag2 := false;\n flag3 := false;\n breakflag := false;\n k := 3;\n for i := 0 to 97 do\n begin\n angle := 360/k;\n for j := 1 to 50 do\n begin\n deltaBetta := angle * j - bettaGrad;\n deltaGamma := angle * j - gammaGrad;\n deltaTetta := angle * j - tettaGrad;\n if (abs(deltaBetta)>=0) and (abs(deltaBetta)<0.001) then\n begin\n flag1 := true;\n end;\n if (abs(deltaGamma)>=0) and (abs(deltaGamma)<0.001) then\n begin\n flag2 := true;\n end;\n if (abs(deltaTetta)>=0) and (abs(deltaTetta)<0.001) then\n begin\n flag3 := true;\n end;\n if (flag1=true) and (flag2=true) and (flag3=true) then\n begin\n n := k;\n breakflag := true;\n break;\n end;\n end;\n if breakflag = true then break;\n k := k + 1;\n end;\n\n S := n/2*sqr(R)*sin(2*pi/n);\n writeln(outfile, S:0:6);\n\n close(outfile);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses Math;\n\nType\n point = record\n x, y: extended;\n end;\nvar\n n, i, j, k: integer;\n a, b, c, s, r, p, alpha1, alpha2, alpha3, alpha: extended;\n a1, a2, a3: point;\n\nfunction Dist(a, b: point): extended;\nbegin\n Result := sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));\nend;\n\nfunction check(a, b: extended): boolean;\nbegin\n Result := abs(a / b - round(a/b)) <= 1e-5;\nend;\n\nbegin\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt'); }\n\n read(a1.x, a1.y, a2.x, a2.y, a3.x, a3.y);\n\n a := dist(a1, a2);\n b := dist(a2, a3);\n c := dist(a3, a1);\n\n p := (a + b + c) / 2;\n\n s := sqrt(p * (p - a) * (p - b) * (p - c));\n\n r := a * b * c / (4 * s);\n\n alpha1 := arccos((2 * r * r - a * a) / (2 * r * r));\n alpha2 := arccos((2 * r * r - b * b) / (2 * r * r));\n alpha3 := arccos((2 * r * r - c * c) / (2 * r * r));\n\n for i := 3 to 1000 do\n begin\n alpha := 2 * pi / i;\n\n if check(alpha1, alpha) and check(alpha2, alpha) and check(alpha3, alpha) then\n begin\n a := r * cos(alpha / 2);\n b := r * sin(alpha / 2);\n s := a * b * i;\n write(s:0:6);\n Halt(0);\n end;\n end;\nend.\n"}, {"source_code": "uses math;\nconst eps:double=1e-5;\ntype pixel=record\n x,y:double;\n end;\nvar i:byte;\n ans, r,dw,ac,bc:double;\n a:array of pixel;\n d:array of double;\nfunction len(p1,p2:pixel):double;\nbegin\n result:=sqrt(sqr(p1.x-p2.x)+sqr(p1.y-p2.y))\nend;\nfunction arc(a,b,c:double):double;\nbegin\n result:=arccos((a*a+b*b-c*c)/(2*a*b))*2\nend;\nfunction AbsEps(a,b,ep:double):boolean;\nbegin\n result:= abs(round(a/b)-a/b)0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n { a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n }\n\n a1:=-(x[1]-x[2]);//y2-y1;\n b1:=y[2]-y[1];//x1-x2;\n c1:=-a1*(x[1]+x[2])/2-b1*(y[1]+y[2])/2;\n\n a2:=-(x[2]-x[3]);//y3-y2;\n b2:=y[3]-y[2];//x2-x3;\n c2:=-a2*(x[2]+x[3])/2-b2*(y[2]+y[3])/2;\n\n xx:=(c1*b2-c2*b1)/(a2*b1-a1*b2);\n yy:=(c1*a2-c2*a1)/(a1*b2-a2*b1);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend."}, {"source_code": "{xn times I don't solove this task}\nconst fo='';\n fi='';\nvar a,b,c,d,e,f,n,m,alpha,beta,r,c1,c2,c3,n_o: real;\n f1,f2: text;\nprocedure doc;\n begin\n assign(f1,fo); reset(f1);\n assign(f2,fi); rewrite(f2);\n readln(f1,a,b);readln(f1,c,d); readln(f1,e,f);\n close(f1);\n end;\nfunction dt(x,y,z,t: real): real;\n begin\n dt:=x*t-y*z;\n end;\nprocedure findcI;\n var dx,dy,dz: real;\n begin\n dz:=dt(e-a,f-b,e-c,f-d);\n dx:=dt((e-a)*(a+e)/2+(f-b)*(b+f)/2,f-b,(e-c)*(c+e)/2+(f-d)*(d+f)/2,f-d);\n dy:=dt(e-a,(e-a)*(a+e)/2+(f-b)*(b+f)/2,e-c,(e-c)*(c+e)/2+(f-d)*(d+f)/2);\n if (dz<>0) then\n begin\n n:=dx/dz;\n m:=dy/dz;\n end;\n end;\nfunction lengthc(x,y,z,t: real): real;\n begin\n lengthc:=sqrt(sqr(x-z)+sqr(y-t));\n end;\nprocedure tinhcanh;\n begin\n c1:=lengthc(a,b,c,d);\n c2:=lengthc(a,b,e,f);\n c3:=lengthc(c,d,e,f);\n r:= lengthc(n,m,a,b);\n end;\nprocedure tinhgoc;\nvar sinalpha,sinbeta,x,y,cosalpha,cosbeta: real;\n begin\n if (c1>=c2) and (c1>=c3) then\n begin\n x:=c2; y:=c3;\n end\n else if (c2>=c1) and (c2>=c3) then\n begin\n x:=c1; y:=c3;\n end\n else if (c3>=c1) and (c3>=c2) then\n begin\n x:=c1; y:=c2;\n end;\n cosalpha:=1-(x*x)/(2*r*r);\n cosbeta:=1-(y*y)/(2*r*r);\n sinalpha:=sqrt(1-sqr(cosalpha));\n sinbeta:=sqrt(1-sqr(cosbeta));\n alpha:=arctan(sinalpha/cosalpha);\n beta:=arctan(sinbeta/cosbeta);\n while alpha<0 do alpha:=alpha+pi;\n while beta<0 do beta:=beta+pi;\n end;\nprocedure load;\n var i,j: word;\n re: real;\n begin\n re:=alpha;\n if alphaeps then\n ff:=false;\n if ff then\n begin\n writeln(i*sin(2*pi/i)*sqr(rr)/2:0:6);\n halt;\n end;\n end;\nend.\n"}, {"source_code": "uses math;\nconst\n st = 100000;\ntype\n cord = record\n x:extended;\n y:extended;\n end;\nvar\naa,bb,cc,ac,bc,r,ug:extended;\nnv,j:longint;\na,b,c:cord;\nfunction dist(a,b:cord):extended;\n begin\n exit(sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)));\n end;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(a.x,a.y,b.x,b.y,c.x,c.y);\naa:=dist(a,b);\nbb:=dist(b,c);\ncc:=dist(c,a);\nac:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\nbc:=arccos((bb*bb+cc*cc-aa*aa)/(2*bb*cc))*2;\nr:=cc/(2*sin(ac/2));\nj:=3;\nwhile j<=102 do\n begin\n ug:=2*pi/j;\n if (abs(round(ac/ug)-ac/ug)<0.0001) and (abs(round(bc/ug)-bc/ug)<0.0001) then\n begin\n writeln(r*r*sin(ug)/2*j:0:6);\n halt;\n end;\n inc(j);\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "uses math; const eps=0.001;\nvar\n x,y:array[0..3] of extended; ras:extended; may:boolean; i:longint;\n\n\nprocedure findcenter;\nvar a1,b1,c1,a2,b2,c2,a,b,c,x1,y1,x2,y2:extended;\nbegin\n a:=y[1]-y[2]; b:=x[2]-x[1]; c:=x[1]*y[2]-x[2]*y[1];\n x1:=(x[1]+x[2])/2; y1:=(y[1]+y[2])/2;\n a1:=-b; b1:=a;\n x2:=b1+x1;\n y2:=y1-a1;\n c1:=x1*y2-x2*y1;\n a:=y[2]-y[3]; b:=x[3]-x[2]; c:=x[2]*y[3]-x[3]*y[2];\n x1:=(x[2]+x[3])/2; y1:=(y[2]+y[3])/2;\n a2:=-b; b2:=a;\n x2:=b2+x1;\n y2:=y1-a2;\n c2:=x1*y2-x2*y1;\n x[0]:=(b1*c2-b2*c1)/(a1*b2-a2*b1);\n y[0]:=-(a1*c2-a2*c1)/(a1*b2-a2*b1);\nend;\n\n\nfunction check(i,j,n:longint):boolean;\nvar u1,u2:extended;\nbegin\n u1:=arctan2(x[i]-x[0],y[i]-y[0]);\n u2:=arctan2(x[j]-x[0],y[j]-y[0]);\n if abs(sin(n*(u1-u2)/2))<=eps then check:=true else check:=false;\nend;\n\n\nbegin\n readln(x[1],y[1]); readln(x[2],y[2]); readln(x[3],y[3]);\n findcenter;\n ras:=sqrt(sqr(x[1]-x[0])+sqr(y[1]-y[0]));\n for i:=3 to 100 do\n begin\n may:=check(1,2,i) and check(1,3,i) and check(2,3,i);\n if may=true then\n begin\n writeln(i/2*ras*ras*sin(2*pi/i):0:6);\n break;\n end;\n end;\nend.\n"}, {"source_code": "program problem3;\nconst eps = 1.0e-3;\n\ntype point = record\n x, y: real;\n end;\n\nfunction arcSin( sin: real ): real;\nbegin\n if ( abs(sin-1.0) < sqr(eps) ) then\n arcSin := pi / 2\n else\n arcSin := arcTan( sin / Sqrt( 1 - sqr(sin) ) );\nend;\n\nvar A, B, C: point;\n r, k, AB, AC, BC, p, AOB, AOC, BOC, S: real;\n n: longWord;\n\nbegin\n readln( A.x, A.y, B.x, B.y, C.x, C.y );\n\n AB := sqrt( sqr( A.x - B.x ) + sqr( A.y - B.y ) );\n AC := sqrt( sqr( A.x - C.x ) + sqr( A.y - C.y ) );\n BC := sqrt( sqr( C.x - B.x ) + sqr( C.y - B.y ) );\n\n p := ( AB + AC + BC ) / 2;\n r := ( AB * AC * BC ) / ( 4 * sqrt( p*(p-AB)*(p-AC)*(p-BC) ) );\n\n AOC := 2 * arcSin( AC / (2*r) );\n AOB := 2 * arcSin( AB / (2*r) );\n BOC := 2 * arcSin( BC / (2*r) );\n\n for n := 3 to 100 do\n begin\n k := 2 * pi / n;\n\n if ( ( frac( AOC / k ) < eps ) or ( (1-frac( AOC / k )) < eps ) ) and\n ( ( frac( AOB / k ) < eps ) or ( (1-frac( AOB / k )) < eps ) ) and\n ( ( frac( BOC / k ) < eps ) or ( (1-frac( BOC / k )) < eps ) ) then\n begin\n S := r * cos(k/2) * n * r * sin(k/2);\n writeln( S:0:12 );\n halt;\n end;\n end;\nend.\n"}, {"source_code": "type\n dato=record\n x,y:extended;\n end;\nvar\n p:array[1..3] of dato;\n i,b1,b2,k,n:longint;\n d,a:extended;\n c,v,aux:dato;\nbegin\n for i:=1 to 3 do\n readln(p[i].x,p[i].y);\n d:=2*(p[1].x*(p[2].y-p[3].y)+p[2].x*(p[3].y-p[1].y)+p[3].x*(p[1].y-p[2].y));\n c.x:=((p[1].x*p[1].x+p[1].y*p[1].y)*(p[2].y-p[3].y)+\n (p[2].x*p[2].x+p[2].y*p[2].y)*(p[3].y-p[1].y)+\n (p[3].x*p[3].x+p[3].y*p[3].y)*(p[1].y-p[2].y))/d;\n c.y:=((p[1].x*p[1].x+p[1].y*p[1].y)*(p[3].x-p[2].x)+\n (p[2].x*p[2].x+p[2].y*p[2].y)*(p[1].x-p[3].x)+\n (p[3].x*p[3].x+p[3].y*p[3].y)*(p[2].x-p[1].x))/d;\n d:=0;\n for i:=1 to 2 do\n d:=d+p[i].x*p[i+1].y-p[i].y*p[i+1].x;\n d:=d+p[3].x*p[1].y-p[3].y*p[1].x;\n if d<0 then\n begin\n aux:=p[1];\n p[1]:=p[3];\n p[3]:=aux;\n end;\n v.x:=p[1].x-c.x;\n v.y:=p[1].y-c.y;\n d:=v.x*v.x+v.y*v.y;\n for n:=3 to 100 do\n begin\n a:=2*Pi/n;\n b1:=0;\n b2:=0;\n for k:=1 to n-1 do\n begin\n aux.x:=v.x*cos(k*a)-v.y*sin(k*a)+c.x;\n aux.y:=v.x*sin(k*a)+v.y*cos(k*a)+c.y;\n if (abs(aux.x-p[2].x)<0.00001) AND (abs(aux.y-p[2].y)<0.00001) then\n begin\n b1:=k;\n break;\n end;\n end;\n if b1>0 then\n begin\n for k:=b1+1 to n-1 do\n begin\n aux.x:=v.x*cos(k*a)-v.y*sin(k*a)+c.x;\n aux.y:=v.x*sin(k*a)+v.y*cos(k*a)+c.y;\n if (abs(aux.x-p[3].x)<0.00001) AND (abs(aux.y-p[3].y)<0.00001) then\n begin\n b2:=k;\n break;\n end;\n end;\n end;\n if (b1>0) and (b2>0) then\n begin\n d:=n*d*sin(a)/2;\n writeln(d:0:6);\n break;\n end;\n end;\nend.\n"}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "Uses math;\nConst\n Tfi = '';\n Tfo = '';\nVar\n fi,fo : Text;\n x1,x2,x3,y1,y2,y3 : Real;\nProcedure Lam;\n Var\n S,a,b,c,R,aa,bb,cc,n,res,min1 : real;\n i : Integer;\n Begin\n a := sqrt(sqr(x2-x1) + sqr(y2-y1));\n b := sqrt(sqr(x2-x3) + sqr(y2-y3));\n c := sqrt(sqr(x3-x1) + sqr(y3-y1));\n bb := arccos((sqr(a) + sqr(c) - sqr(b))/(2*a*c))*2;\n cc := arccos((sqr(b) + sqr(a) - sqr(c))/(2*b*a))*2;\n r := c/(2*sin(cc/2));\n i := 3;\n while (i>0) and (i<105) do\n Begin\n min1 := 2*pi/i;\n If (abs(round(cc/min1) - cc/min1)<0.0001) and (abs(round(bb/min1)-bb/min1)<0.0001) then\n Begin\n res := r*r*sin(min1)*(i/2);\n i := -6;\n End;\n Inc(i);\n End;\n Writeln(fo,res:6:6);\n End;\nBegin\n Assign(fi,tfi); Reset(fi);\n Assign(fo,tfo); Rewrite(fo);\n Readln(fi,x1,y1);\n Readln(fi,x2,y2);\n Readln(fi,x3,y3);\n Lam;\n Close(fi);\n Close(fo);\nEnd.\n"}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "USES MATH;\nCONST\n fin='';\n fon='';\nVAR\n n: LONGINT;\n x1,x2,x3,y1,y2,y3: EXTENDED;\n a,b,c,nuaP,S,r: EXTENDED;\n CosA,CosB,CosC: EXTENDED;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nPROCEDURE NHAP;\n BEGIN\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n END;\nFUNCTION TINH_TOAN(a,b: EXTENDED): EXTENDED;\n BEGIN\n while (ABS(a)>0.0001) and (ABS(b)>0.0001) do\n begin\n if(a>b)then a:=a-TRUNC(a/b)*b\n else b:=b-TRUNC(b/a)*a;\n end;\n EXIT(a+b);\n END;\nPROCEDURE XU_LI_1;\n BEGIN\n a:=SQRT(SQR(x2-x1)+SQR(y2-y1));\n b:=SQRT(SQR(x3-x2)+SQR(y3-y2));\n c:=SQRT(SQR(x1-x3)+SQR(y1-y3));\n END;\nPROCEDURE XU_LI_2;\n BEGIN\n nuaP:=(a+b+c)/2;\n S:=SQRT(nuaP*(nuaP-a)*(nuaP-b)*(nuaP-c));\n r:=(a*b*c)/(S*4);\n END;\nPROCEDURE XU_LI_3;\n BEGIN\n CosA:=ARCCOS((b*b+c*c-a*a)/(2*b*c));\n CosB:=ARCCOS((a*a+c*c-b*b)/(2*a*c));\n CosC:=ARCCOS((a*a+b*b-c*c)/(2*a*b));\n END;\nPROCEDURE XU_LI_CHINH;\n VAR tam1,tam2,heso,kq: EXTENDED;\n BEGIN\n tam1:=TINH_TOAN(CosB,CosC);\n tam2:=TINH_TOAN(CosA,tam1);\n heso:=pi/tam2;\n kq:=heso/2*r*r*sin(2*pi/heso);\n writeln(kq:0:6);\n END;\nPROCEDURE CHUONG_TRINH;\n BEGIN\n NHAP;\n XU_LI_1;\n XU_LI_2;\n XU_LI_3;\n XU_LI_CHINH;\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n CHUONG_TRINH;\n KET_THUC;\nEND."}, {"source_code": "program cf1c;\nuses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend.\n\n"}, {"source_code": "program p1C;\nuses math;\nconst eps:double=1e-5;\ntype pixel=record\n x,y:double;\n end;\nvar i:byte;\n ans, r,dw,ac,bc:double;\n a:array of pixel;\n d:array of double;\nfunction len(p1,p2:pixel):double;\nbegin\n result:=sqrt(sqr(p1.x-p2.x)+sqr(p1.y-p2.y))\nend;\nfunction arc(a,b,c:double):double;\nbegin\n result:=arccos((a*a+b*b-c*c)/(2*a*b))*2\nend;\nfunction AbsEps(a,b,ep:double):boolean;\nbegin\n result:= abs(round(a/b)-a/b)=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:double):double;\nvar\np1,p2,p3,p4:double;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n\n\n\nbegin\n\npi:=3.141592653589793238462643383279502;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n\n if abs(a/p1-round(a/p1))<0.00001 then\n if abs(b/p1-round(b/p1))<0.00001 then\n if abs(c/p1-round(c/p1))<0.00001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "uses math;\ntype dot=record x,y:double; end;\nvar\n a,b,c:dot;\n i:longint;\n r,dw,ans,af,bt,aa,bb,cc:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nbegin\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n aa:=dis(b,c); bb:=dis(a,c); cc:=dis(a,b);\n af:=arccos((aa*aa+bb*bb-cc*cc)/(2*aa*bb))*2;\n bt:=arccos((aa*aa+cc*cc-bb*bb)/(2*aa*cc))*2;\n\n r:=cc*0.5/(sin(af*0.5));\n\n for i:=1 to 101 do begin\n dw:=2*pi/i;\n if abs(round(af/dw)-af/dw)<1e-4 then\n if abs(round(bt/dw)-bt/dw)<1e-4 then begin\n ans:=r*r*sin(dw)*i/2;\n writeln(ans:0:12);\n halt;\n end;\n end;\nend."}, {"source_code": "var\nx1,y1,x2,y2,x3,y3,x4,y4:double;\nx5,x6,x7,x8,y5,y6,y7,y8:double;\na,b,c,ab,ac,bc,r:double;\ns1,s2,s3:longint;\np1,p2,p3,p4,pi:double;\n\n\nfunction vectorProizvedenie(ax,ay,bx,by:double):double;\n\nbegin\nvectorProizvedenie:=ax*by-ay*bx;\nend;\n\n\nfunction rast(x1,y1,x2,y2:double):double; \nbegin\nrast:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend; \n{��������� �� ����� �� �����}\n\nfunction ploshad(x1,y1,x2,y2,x3,y3:double):double;\nvar\np1,a,b,c:double;\nbegin\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x2,y2);\nc:=rast(x1,y1,x3,y3);\np1:=(a+b+c)/2;\nploshad:=sqrt(p1*(p1-a)*(p1-b)*(p1-c));\nend; \n\n\nfunction ugol(x1,y1,x2,y2,x3,y3,x4,y4:double):double; \nvar\nax,bx,by,ay,a,b:double;\nbegin\nax:=x2-x1;\nay:=y2-y1;\nbx:=x4-x3;\nby:=y4-y3;\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x4,y4);\nugol:=arcsin((ax*by-ay*bx)/a/b);\n\nend;\n{���� �� ������� ����� ��������� ������ ������ �� ������� ������ ������� ������� (-pi..+pi) }\n\nfunction peresechenie(x1,y1,x2,y2,x3,y3,x4,y4:double):double;\nvar\np1,p2,p3,p4:double;\nbegin\np1:=ugol(x1,y1,x3,y3,x3,y3,x2,y2);\np2:=ugol(x3,y3,x2,y2,x2,y2,x4,y4);\np3:=ugol(x2,y2,x4,y4,x4,y4,x1,y1);\np4:=ugol(x4,y4,x1,y1,x1,y1,x3,y3);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:double):double;\nvar\np1,p2,p3,p4:double;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643383279502;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n {Writeln(s1);\n p2:=a/p1-round(a/p1);\n Writeln(p2);\n p2:=b/p1-round(b/p1);\n Writeln(p2);\n p2:=c/p1-round(c/p1);\n Writeln(p2);\n Writeln();}\n if abs(a/p1-round(a/p1))<0.00001 then\n if abs(b/p1-round(b/p1))<0.00001 then\n if abs(c/p1-round(c/p1))<0.00001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar\n i: integer;\n R,x1,x2,x3,y1,y2,y3,a,b,c,a1,a2,amin: real;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=2*arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=2*arccos((a*a+c*c-b*b)/(2*a*c));\n R:=c/(2*sin(a1/2));\n i:=3;\n while (i>0)and(i<105) do begin\n amin:=2*pi/i;\n If (abs(round(a1/amin)-a1/amin)<0.0001)and(abs(round(a2/amin)-a2/amin)<0.0001)\n then begin\n x1:=R*R*sin(amin)*i/2;\n i:=-6;\n end;\n i:=i+1;\n end;\n writeln(x1,' ');\n read(amin);\n\nend."}, {"source_code": " {$APPTYPE CONSOLE}\n uses\n SysUtils,math;\n var\n i: integer;\n R,x1,x2,x3,y1,y2,y3,a,b,c,a1,a2,amin: real;\n begin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=2*arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=2*arccos((a*a+c*c-b*b)/(2*a*c));\n R:=c/(2*sin(a1/2));\n i:=3;\n while (i>0)and(i<105) do begin\n amin:=2*pi/i;\n If (abs(round(a1/amin)-a1/amin)<0.0001)and(abs(round(a2/amin)-a2/amin)<0.0001)\n then begin\n x1:=R*R*sin(amin)*i/2;\n i:=-6;\n end;\n i:=i+1;\n end;\n writeln(x1,' ');\n read(amin);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\ntype point = record\n x, y: real;\nend;\n\ntype vector = record\n x, y: real;\nend;\n\nconst eps = 0.00001;\n\nfunction eq(a, b: real): boolean;\nbegin\n result := abs(a - b) < eps;\nend;\n\nfunction p2v(a, b: point): vector;\nbegin\n result.x := b.x - a.x;\n result.y := b.y - a.y;\nend;\n\nfunction scal_proizv(a, b: vector): real;\nbegin\n result := a.x * b.x + a.y * b.y;\nend;\n\nfunction vect_proizv(a, b: vector): real;\nbegin\n result := a.x * b.y - a.y * b.x;\nend;\n\nfunction find_ug(v1, v2: vector): real;\nbegin\n result := arctan2(vect_proizv(v1, v2), scal_proizv(v1, v2));\nend;\n\nfunction dist(a, b: point): real;\nbegin\n result := sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));\nend;\n\nvar a, b, c: point;\n r, d1, d2, curr, t1, t2, ans: real;\n i, tmp1, tmp2: longint;\n\nbegin\n//reset(input, 'input.txt');rewrite(output, 'output.txt');\n read(a.x, a.y, b.x, b.y, c.x, c.y);\n d1 := 2 * find_ug(p2v(a, b), p2v(a, c));\n d2 := 2 * find_ug(p2v(c, a), p2v(c, b));\n r := dist(a, b) / (sin(d2 / 2) * 2);\n for i := 3 to 100 do\n begin\n t1 := i;\n curr := 2 * pi / t1;\n t1 := d1 / curr;\n t2 := d2 / curr;\n tmp1 := round(t1);\n tmp2 := round(t2);\n if eq(tmp1, t1)and(eq(tmp2, t2))then\n begin\n ans := i;\n break;\n end;\n end;\n ans := sqr(r) * sin(curr) * ans / 2;\n writeln(ans: 0: 7)\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\ntype point = record\n x, y : extended;\nend;\nvar i, points : longint;\n p1, p2, p3 : point;\n A1, B1, C1, A2, B2, C2, Anew, Bnew, Cnew, x_center, y_center, angle, angle1, angle2, angle3, angle12, angle13, angle23, answer, a : extended;\n ok : boolean;\n//\nfunction div_ok(x, y : extended) : boolean;\nbegin\nif (abs(round(x/y)-x/y)<1e-5) then result := true else result := false;\nend;\n//\nbegin\n//assign(input, 'input.txt'); reset(input);\nReadln(p1.x, p1.y);\nReadln(p2.x, p2.y);\nReadln(p3.x, p3.y);\n//\nA1 := p1.y - p2.y;\nB1 := p2.x - p1.x;\nC1 := p2.y*(-B1)+p2.x*(A1);\nAnew := B1;\nBnew := -A1;\nCnew := -(Anew*(p1.x+p2.x)/2+Bnew*(p1.y+p2.y)/2);\nA1 := Anew;\nB1 := Bnew;\nC1 := Cnew;\n//\nA2 := p1.y - p3.y;\nB2 := p3.x - p1.x;\nC2 := p3.y*(-B2)+p3.x*(A2);\nAnew := B2;\nBnew := -A2;\nCnew := -(Anew*(p1.x+p3.x)/2+Bnew*(p1.y+p3.y)/2);\nA2 := Anew;\nB2 := Bnew;\nC2 := Cnew;\n//\nx_center := (-C1*B2 + C2*B1)/(A1*B2 - B1*A2);\ny_center := (-C1*A2 + C2*A1)/(B1*A2 - b2*A1);\n//\npoints := 2;\nangle1 := ArcTan2(p1.y-y_center, p1.x-x_center); if (angle1<0) then angle1 := angle1 + 2*PI;\nangle2 := ArcTan2(p2.y-y_center, p2.x-x_center); if (angle2<0) then angle2 := angle2 + 2*PI;\nangle3 := ArcTan2(p3.y-y_center, p3.x-x_center); if (angle3<0) then angle3 := angle3 + 2*PI;\nangle12 := abs(angle1-angle2);\nangle13 := abs(angle1-angle3);\nangle23 := abs(angle3-angle2);\nok :=false;\nwhile (not ok) do begin\n inc(points);\n angle := 2*PI/points;\n if ((div_ok(angle12, angle)) and (div_ok(angle13, angle)) and (div_ok(angle23, angle)))\n then ok := true;\nend;\n//\na := sqrt((p1.x-x_center)*(p1.x-x_center)+(p1.y-y_center)*(p1.y-y_center));\nanswer:=0.5*points*a*a*sin(angle);\n//\nWriteln(answer:0:6);\n//\n//close(input);\nend.\n"}, {"source_code": "{uses crt;}\nlabel 1,2;\nconst nn=200; eps=1e-5;\ntype mas=array[-10..nn] of real;\n var s1,s2,ii,jj,l,r,p,oo,dmin,ymin,j,n1:longint;\n i,tt,k,m,n:longint;\n\n vx,vy,x,y,co,co1:mas; l1,l2,x1,y1,x2,y2,ch,zn,s,ss:real;\n prov,flag,otv,per:boolean;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'output.txt'); rewrite (output);}\n for i:=1 to 3 do read(x[i],y[i]);\n for i:=1 to 3 do begin x[3+i]:=x[i];y[3+i]:=y[i]; end;\n for i:=1 to 3 do begin x[-3+i]:=x[i];y[-3+i]:=y[i]; end;\n\n for i:=1 to 3 do\n begin\n x1:=x[i]-x[i-1];y1:=y[i]-y[i-1]; x2:=x[i]-x[i+1];y2:=y[i]-y[i+1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co[i]:=ch/zn;\n { writeln(co[i]:0:2); }\n end;\n\n\n for n:=3 to 100 do\n\nbegin\n for i:=1 to n do begin vx[i]:=cos(2*pi*i/n); vy[i]:=sin(2*pi*i/n); end;\n { for i:=1 to n do writeln(vx[i]:0:2,' ',vy[i]:0:2); writeln; }\nprov:=false;\n for i:=2 to n do for j:=2 to n do if j<>i then\n begin\n x1:=vx[i]-vx[1];y1:=vy[i]-vy[1]; x2:=vx[j]-vx[1];y2:=vy[j]-vy[1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[1]:=ch/zn;\n\n x1:=vx[i]-vx[j];y1:=vy[i]-vy[j]; x2:=vx[1]-vx[j];y2:=vy[1]-vy[j];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[2]:=ch/zn;\n\n { writeln(n,' ',co1[1]:0:2,' ',co1[2]:0:2);\n } if (abs(co1[1]-co[1])0\n then y:=(-c2-a2*x)/b2\n else y:=(-c1-a1*x)/b1;\n r:=Sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));\n a:=Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=Sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n c:=Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));\n for i:=3 to 1000 do\n begin\n z:=360/i;\n z1:=arccos((r*r+r*r-a*a)/(2*r*r))*180/pi;\n if (Frac(z1/z)>abc)and(Frac(z1/z)<1-abc)\n then Continue;\n z1:=arccos((r*r+r*r-b*b)/(2*r*r))*180/pi;\n if (Frac(z1/z)>abc)and(Frac(z1/z)<1-abc)\n then Continue;\n z1:=arccos((r*r+r*r-c*c)/(2*r*r))*180/pi;\n if (Frac(z1/z)>abc)and(Frac(z1/z)<1-abc)\n then Continue;\n Writeln(0.5*r*r*i*sin(360*pi/(180*i)):0:6);\n break\n end;\nend."}, {"source_code": "program C1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n math;\n\nvar\n i:integer;\n x1,x2,x3,y1,y2,y3,min,a1,a2,r,a,b,c:real;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=2*arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=2*arccos((a*a+c*c-b*b)/(2*a*c));\n r:=c/(2*sin(a1/2));\n i:=3;\n while (i>0) and (i<105) do begin\n min:=2*pi/i;\n if (abs(round(a1/min)-a1/min)<0.0001)and(abs(round(a2/min)-a2/min)<0.0001) then begin\n x1:=r*r*sin(min)*(i/2);\n i:=-6;\n end;\n inc(i);\n end;\n writeln(x1,' ');\n read(min);\n\nend.\n "}], "negative_code": [{"source_code": "var\nx1,y1,x2,y2,x3,y3,x4,y4:real;\nx5,x6,x7,x8,y5,y6,y7,y8:real;\na,b,c,ab,ac,bc,r:real;\ns1,s2,s3:longint;\np1,p2,p3,p4,pi:real;\n\n\nfunction vectorProizvedenie(ax,ay,bx,by:real):real;\n\nbegin\nvectorProizvedenie:=ax*by-ay*bx;\nend;\n\n\nfunction rast(x1,y1,x2,y2:real):real; \nbegin\nrast:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend; \n{��������� �� ����� �� �����}\n\nfunction ploshad(x1,y1,x2,y2,x3,y3:real):real;\nvar\np1,a,b,c:real;\nbegin\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x2,y2);\nc:=rast(x1,y1,x3,y3);\np1:=(a+b+c)/2;\nploshad:=sqrt(p1*(p1-a)*(p1-b)*(p1-c));\nend; \n\n\nfunction ugol(x1,y1,x2,y2,x3,y3,x4,y4:real):real; \nvar\nax,bx,by,ay,a,b:real;\nbegin\nax:=x2-x1;\nay:=y2-y1;\nbx:=x4-x3;\nby:=y4-y3;\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x4,y4);\nugol:=arcsin((ax*by-ay*bx)/a/b);\n\nend;\n{���� �� ������� ����� ��������� ������ ������ �� ������� ������ ������� ������� (-pi..+pi) }\n\nfunction peresechenie(x1,y1,x2,y2,x3,y3,x4,y4:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x3,y3,x3,y3,x2,y2);\np2:=ugol(x3,y3,x2,y2,x2,y2,x4,y4);\np3:=ugol(x2,y2,x4,y4,x4,y4,x1,y1);\np4:=ugol(x4,y4,x1,y1,x1,y1,x3,y3);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643383279502;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n\n if abs(a/p1-round(a/p1))<0.00000001 then\n if abs(b/p1-round(b/p1))<0.00000001 then\n if abs(c/p1-round(c/p1))<0.00000001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "uses\n math;\nconst\n eps=1e-6;\nvar\n d1,d2,d3,r,s,x0,y0,d,dx,dy,a1,b1,c1,a2,b2,c2,x1,y1,x2,y2,x3,y3,ug1,ug2,ug3:double;\n i:longint;\n function ok(a,b:double):boolean;\n var\n x:double;\n begin\n a:=a+pi+pi;\n x:=trunc(a/b);\n ok:=abs(x*b-a)0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end.\n\n"}, {"source_code": "Uses math;\nConst abc=1e-9;\nVar z1,z,r,a1,a2,b1,b2,c1,c2,x,y,l1,l,l2,s,p,h1,a,b,c,x1,x2,x3,y1,y2,y3:extended;\ni:longint;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n Readln(x1,y1,x2,y2,x3,y3);\n a:=y2-y3;\n b:=(x3-x2);\n c:=-a*x3-b*y3;\n x:=(x2+x3)/2;\n y:=(y2+y3)/2;\n a1:=b;\n b1:=-a;\n c1:=-a1*x-b1*y;\n\n a:=y3-y1;\n b:=(x1-x3);\n c:=-a*x1-b*y1;\n x:=(x1+x3)/2;\n y:=(y1+y3)/2;\n a2:=b;\n b2:=-a;\n c2:=-x*a2-y*b2;\n\n x:=(c1*b2-b1*c2)/(a2*b1-a1*b2);\n if b2<>0\n then y:=(-c2-a2*x)/b2\n else y:=(-c1-a1*x)/b1;\n r:=Sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));\n a:=Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=Sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n c:=Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));\n for i:=3 to 1000 do\n begin\n z:=360/i;\n z1:=arccos((r*r+r*r-a*a)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-b*b)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-c*c)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n Writeln(0.5*r*r*i*sin(360*pi/(180*i)));\n Halt(0);\n end;\nend."}, {"source_code": "{uses crt; }\nlabel 1,2;\nconst nn=200; eps=1e-8;\ntype mas=array[-10..nn] of real;\n var s1,s2,ii,jj,l,r,p,oo,dmin,ymin,j,n1:longint;\n i,tt,k,m,n:longint;\n\n vx,vy,x,y,co,co1:mas; l1,l2,x1,y1,x2,y2,ch,zn,s,ss:real;\n prov,flag,otv,per:boolean;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'output.txt'); rewrite (output);}\n for i:=1 to 3 do read(x[i],y[i]);\n for i:=1 to 3 do begin x[3+i]:=x[i];y[3+i]:=y[i]; end;\n for i:=1 to 3 do begin x[-3+i]:=x[i];y[-3+i]:=y[i]; end;\n\n for i:=1 to 3 do\n begin\n x1:=x[i]-x[i-1];y1:=y[i]-y[i-1]; x2:=x[i]-x[i+1];y2:=y[i]-y[i+1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co[i]:=ch/zn;\n { writeln(co[i]:0:2); }\n end;\n\n\n for n:=3 to 6 do\n\nbegin\n for i:=1 to n do begin vx[i]:=cos(2*pi*i/n); vy[i]:=sin(2*pi*i/n); end;\n { for i:=1 to n do writeln(vx[i]:0:2,' ',vy[i]:0:2); writeln; }\nprov:=false;\n for i:=2 to n do for j:=2 to n do if j<>i then\n begin\n x1:=vx[i]-vx[1];y1:=vy[i]-vy[1]; x2:=vx[j]-vx[1];y2:=vy[j]-vy[1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[1]:=ch/zn;\n\n x1:=vx[i]-vx[j];y1:=vy[i]-vy[j]; x2:=vx[1]-vx[j];y2:=vy[1]-vy[j];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[2]:=ch/zn;\n\n { writeln(n,' ',co1[1]:0:2,' ',co1[2]:0:2);\n } if (abs(co1[1]-co[1])1-eps then arccoss:=0 else\n if x<-1+eps then arccoss:=pi\n else arccoss:=arccos(x);\n end;\n\n begin\n readln(x1,y1,x2,y2,x3,y3);\n\n x:=0;\n y:=0;\n\n del:=1000;\n len:=dd(0,0);\n for it:=1 to 10000 do\n begin\n ok:=true;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then\n begin\n tmp:=dd(x+i*del,y+j*del);\n if tmpeps then ok:=false;\n\n cc:=a2/la;\n if frac(cc+eps/100)>eps then ok:=false;\n\n\n if ok then\n begin\n writeln(i/2*rr*rr*sin(2*pi/i):0:6);\n halt(0);\n end;\n end;\n end."}, {"source_code": "var\nx1,y1,x2,y2,x3,y3,x4,y4:real;\nx5,x6,x7,x8,y5,y6,y7,y8:real;\na,b,c,ab,ac,bc,r:real;\ns1,s2,s3:longint;\np1,p2,p3,p4,pi:real;\n\n\nfunction vectorProizvedenie(ax,ay,bx,by:real):real;\n\nbegin\nvectorProizvedenie:=ax*by-ay*bx;\nend;\n\n\nfunction rast(x1,y1,x2,y2:real):real; \nbegin\nrast:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend; \n{��������� �� ����� �� �����}\n\nfunction ploshad(x1,y1,x2,y2,x3,y3:real):real;\nvar\np1,a,b,c:real;\nbegin\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x2,y2);\nc:=rast(x1,y1,x3,y3);\np1:=(a+b+c)/2;\nploshad:=sqrt(p1*(p1-a)*(p1-b)*(p1-c));\nend; \n\n\nfunction ugol(x1,y1,x2,y2,x3,y3,x4,y4:real):real; \nvar\nax,bx,by,ay,a,b:real;\nbegin\nax:=x2-x1;\nay:=y2-y1;\nbx:=x4-x3;\nby:=y4-y3;\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x4,y4);\nugol:=arcsin((ax*by-ay*bx)/a/b);\n\nend;\n{���� �� ������� ����� ��������� ������ ������ �� ������� ������ ������� ������� (-pi..+pi) }\n\nfunction peresechenie(x1,y1,x2,y2,x3,y3,x4,y4:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x3,y3,x3,y3,x2,y2);\np2:=ugol(x3,y3,x2,y2,x2,y2,x4,y4);\np3:=ugol(x2,y2,x4,y4,x4,y4,x1,y1);\np4:=ugol(x4,y4,x1,y1,x1,y1,x3,y3);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643383279502;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n\n if abs(a/p1-round(a/p1))<0.0000000001 then\n if abs(b/p1-round(b/p1))<0.0000000001 then\n if abs(c/p1-round(c/p1))<0.0000000001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "const fo='';\n fi='';\nvar a,b,c,d,e,f,n,m,alpha,beta,r,c1,c2,c3,n_o: real;\n f1,f2: text;\nprocedure doc;\n begin\n assign(f1,fo); reset(f1);\n assign(f2,fi); rewrite(f2);\n readln(f1,a,b);readln(f1,c,d); readln(f1,e,f);\n close(f1);\n end;\nfunction dt(x,y,z,t: real): real;\n begin\n dt:=x*t-y*z;\n end;\nprocedure findcI;\n var dx,dy,dz: real;\n begin\n dz:=dt(e-a,f-b,e-c,f-d);\n dx:=dt((e-a)*(a+e)/2+(f-b)*(b+f)/2,f-b,(e-c)*(c+e)/2+(f-d)*(d+f)/2,f-d);\n dy:=dt(e-a,(e-a)*(a+e)/2+(f-b)*(b+f)/2,e-c,(e-c)*(c+e)/2+(f-d)*(d+f)/2);\n if (dz<>0) then\n begin\n n:=dx/dz;\n m:=dy/dz;\n end;\n end;\nfunction lengthc(x,y,z,t: real): real;\n begin\n lengthc:=sqrt(sqr(x-z)+sqr(y-t));\n end;\nprocedure tinhcanh;\n begin\n c1:=lengthc(a,b,c,d);\n c2:=lengthc(a,b,e,f);\n c3:=lengthc(c,d,e,f);\n r:= lengthc(n,m,a,b);\n end;\nprocedure tinhgoc;\nvar sinalpha,sinbeta,x,y,cosalpha,cosbeta: real;\n begin\n if (c1>=c2) and (c1>=c3) then\n begin\n x:=c2; y:=c3;\n end\n else if (c2>=c1) and (c2>=c3) then\n begin\n x:=c1; y:=c3;\n end\n else if (c3>=c1) and (c3>=c2) then\n begin\n x:=c1; y:=c2;\n end;\n cosalpha:=1-(x*x)/(2*r*r);\n cosbeta:=1-(y*y)/(2*r*r);\n sinalpha:=sqrt(1-sqr(cosalpha));\n sinbeta:=sqrt(1-sqr(cosbeta));\n alpha:=arctan(sinalpha/cosalpha);\n beta:=arctan(sinbeta/cosbeta);\n while alpha<0 do alpha:=alpha+pi;\n while beta<0 do beta:=beta+pi;\n end;\nprocedure load;\n var i,j: word;\n re: real;\n begin\n re:=alpha;\n if alpha0 then\n arccos:=arctan(si/co)\n else arccos:=pi+arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n// writeln(o.x,' ',o.y);\n r:=dis(b,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n if af<0 then af:=-af;\n bt:=arccos(bt);\n if bt<0 then bt:=-bt;\n // writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 10000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n if trunc(2*pi*r)=114 then writeln('1034.70898496')\n else\n if trunc(r*pi*r)=5674 then writeln('5669.99444283')\n else\n if trunc(r*pi*r)=26244 then writeln('26277.47891823')\n else\n writeln(r*pi*r:0:12);\nend.\n\n\n\n\n\n\n\n"}, {"source_code": "program cf1c;\nconst eps=1e-10;\ntype\n dot=record\n x,y:double;\n end;\nvar\n n,i,j:longint;\n af,dw,ans,bt,r,pi:double;\n o,a,b,c:dot;\nfunction dj(a,b,c,d:dot):double;\nbegin\n dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);\nend;\n\nfunction cj(a,b,c,d:dot):double;\nbegin\n cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y)\nend;\n\nfunction jiao_dian(a,b,c,d:dot):dot;\nvar\n s1,s2:double;\nbegin\n s1:=cj(a,c,a,b);\n s2:=cj(a,b,a,d);\n jiao_dian.x:=(c.x*s2+d.x*s1)/(s1+s2);\n jiao_dian.y:=(c.y*s2+d.y*s1)/(s1+s2);\nend;\n\nfunction quzhong(a,b:dot):dot;\nbegin\n quzhong.x:=(a.x+b.x)/2;\n quzhong.y:=(a.y+b.y)/2;\nend;\n\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nfunction make_o(a,b,c:dot):dot;\nvar\n aa,bb,cc:double;\n e,f,d,g:dot;\nbegin\n {aa:=dis(b,c);\n bb:=dis(a,c);\n cc:=dis(a,b);\n if aa*aa+bb*bb0 then\n arccos:=arctan(si/co)\n else arccos:=pi+arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n// writeln(o.x,' ',o.y);\n r:=dis(b,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n if af<0 then af:=-af;\n bt:=arccos(bt);\n if bt<0 then bt:=-bt;\n // writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 10000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n if trunc(2*pi*r)=114 then writeln('1034.70898496')\n else\n if trunc(r*pi*r)=5674 then writeln('5669.99444283')\n else\n if trunc(r*pi*r)=26244 then writeln('26277.47891823')\n else\n writeln(r*pi*r:0:12);\nend.\n\n\n\n\n\n\n\n"}, {"source_code": "uses math;\nconst eps=0.0000001;\nvar x1,x2,x3,y1,y2,y3,x4,y4,x5,y5: real;\n R, S,a,b,c, aa, bb, cc,f1,f2,f3,fi: real;\n n: integer;\n\n \nfunction dlin(xa,ya, xb,yb: real):real; \nvar res: real;\nbegin\n dlin:=sqrt(sqr(xb-xa)+sqr(yb-ya));\nend; \n\n\nfunction ugol(x,y,z: real): real;\nbegin\n ugol:=arccos((sqr(y)+sqr(z)-sqr(x))/(2*y*z));\nend;\n\nfunction radius(x,y,z: real): real;\nvar p,r: real;\nbegin\n p:=(x+y+z)/2;\n r:=x*y*z/4/sqrt(p*(p-x)*(p-y)*(p-z));\n radius:=r;\nend;\n\nfunction plotsha(r, m: real): real;\nbegin\n plotsha:=M*0.5*r*r*sin(2*Pi/M);\nend;\n\n \nbegin\n readln(x3,y3);\n readln(x1,y1);\n readln(x2,y2);\n\n a:=dlin(x2,y2, x3,y3);\n b:=dlin(x1,y1, x2,y2);\n c:=dlin(x1,y1, x3,y3);\n \n \n aa:=ugol(a, b,c);\n bb:=ugol(b, a,c);\n cc:=ugol(c, a,b);\n \n \n f1:=2*aa; f2:=2*bb; f3:=2*cc;\n \n N:=3;\n while N<=100 do\n begin\n { if (abs(sin(f1*N))0 then\n arccos:=arctan(si/co)\n else arccos:=pi+arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n// writeln(o.x,' ',o.y);\n r:=dis(b,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n if af<0 then af:=-af;\n bt:=arccos(bt);\n if bt<0 then bt:=-bt;\n // writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 10000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n if trunc(2*pi*r)=114 then writeln('1034.70898496')\n else writeln(2*pi*r:0:12);\nend.\n"}, {"source_code": "program cf1c;\ntype\n dot=record\n x,y:double;\n end;\nvar\n n,i,j:longint;\n af,dw,ans,bt,r,pi:double;\n o,a,b,c:dot;\nfunction dj(a,b,c,d:dot):double;\nbegin\n dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);\nend;\n\nfunction cj(a,b,c,d:dot):double;\nbegin\n cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y)\nend;\n\nfunction jiao_dian(a,b,c,d:dot):dot;\nvar\n s1,s2:double;\nbegin\n s1:=cj(a,c,a,b);\n s2:=cj(a,b,a,d);\n jiao_dian.x:=(c.x*s2+d.x*s1)/(s1+s2);\n jiao_dian.y:=(c.y*s2+d.y*s1)/(s1+s2);\nend;\n\nfunction quzhong(a,b:dot):dot;\nbegin\n quzhong.x:=(a.x+b.x)/2;\n quzhong.y:=(a.y+b.y)/2;\nend;\n\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nfunction make_o(a,b,c:dot):dot;\nvar\n aa,bb,cc:double;\n e,f,d,g:dot;\nbegin\n {aa:=dis(b,c);\n bb:=dis(a,c);\n cc:=dis(a,b);\n if aa*aa+bb*bb0 then\n arccos:=arctan(si/co)\n else arccos:=pi-arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n //writeln(o.x,' ',o.y);\n r:=dis(a,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n bt:=arccos(bt);\n //writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 1000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n writeln(2*pi*r:0:12);\nend.\n\n\n\n\n\n\n\n"}, {"source_code": "program problemC;\nuses Crt;\nvar\n infile, outfile: text;\n x1, y1, x2, y2, x3, y3: real;\n a, b, c, S, R, p, minside: real;\n bettaRad: real;\n bettaGrad: integer;\n n1: real;\n n, i, j: integer;\n arrAngle: array[0..97] of real;\n arrSide: array[0..97] of integer;\nbegin\n ClrScr;\n assign(infile, '');\n assign(outfile, '');\n reset(infile);\n readln(infile, x1, y1);\n readln(infile, x2, y2);\n readln(infile, x3, y3);\n close(infile);\n a := sqrt(sqr(y2-y1) + sqr(x2-x1));\n b := sqrt(sqr(y3-y2) + sqr(x3-x2));\n c := sqrt(sqr(y3-y1) + sqr(x3-x1));\n minside := a;\n if minside>b then minside := b;\n if minside>c then minside := c;\n p := 0.5*(a+b+c);\n S := sqrt(p*(p-a)*(p-b)*(p-c));\n R := (a*b*c)/(4*S);\n bettaRad := 2*arctan((minside/(2*R))/sqrt(1-sqr(minside/(2*R))));\n bettaGrad := round(bettaRad*180/pi);\n\n rewrite(outfile);\n for i := low(arrSide) to high(arrSide) do\n begin\n arrSide[i] := 3+i;\n end;\n\n j := 0;\n for i := 3 to 100 do\n begin\n arrAngle[j] := 360/i;\n j := j + 1;\n end;\n\n for i := low(arrAngle) to high(arrAngle) do\n begin\n n1 := bettaGrad/arrAngle[i];\n if frac(n1) = 0 then\n begin\n n := round(n1*360/bettaGrad);\n S := n/2*sqr(R)*sin(2*pi/n);\n writeln(outfile, S:0:6);\n break;\n end;\n end;\n close(outfile);\nend.\n"}, {"source_code": "uses math;\n\nconst\n zero =1e-6;\n pi =3.1415926535;\n\nvar\n x,y :array[0..3] of extended;\n dist :array[0..3,0..3] of extended;\n\nprocedure init;\nvar\n i :longint;\nbegin\n for i:=1 to 3 do\n readln(x[i],y[i]);\nend; { init }\n\nfunction check(a,b:extended):boolean;\nvar\n t :longint;\nbegin\n t:=round(a/b);\n if abs(t-a/b)j then\n dist[i][j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n cosa:=(sqr(dist[1][2])+sqr(dist[1][3])-sqr(dist[2][3]))/(2*dist[1][2]*dist[1][3]);\n sina:=sqrt(1-sqr(cosa));\n r:=dist[2][3]/(2*sina);\n for i:=1 to 3 do\n for j:=1 to 3 do\n if i<>j then\n dist[i][j]:=arcsin(dist[i][j]/(2*r))*2;\n for i:=3 to 100 do\n begin\n t:=2*pi/i;\n if not check(dist[1][2],t) then continue;\n if not check(dist[1][3],t) then continue;\n if not check(dist[2][3],t) then continue;\n ans:=r*r*sin(t)/2*i;\n writeln(ans:0:8);\n exit;\n end;\nend; { work }\n\nbegin\n init;\n work;\nend.\n\n"}, {"source_code": "program Project1_C;\n{$APPTYPE CONSOLE}\nvar i,j,k:longint;\n x1,y1,x2,y2,x3,y3,a,b,c,aa,bb,cc:extended;\nfunction rast(x1,y1,x2,y2:extended):extended;\nbegin\n result:=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\nend;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n read(x1,y1,x2,y2,x3,y3);\n a:=rast(x1,y1,x2,y2);\n b:=rast(x1,y1,x3,y3);\n c:=rast(x2,y2,x3,y3);\n\n for i:=3 to 100 do\n for j:=1 to i-1 do\n for k:=1 to i-1 do\n begin\n if j=k then continue;\n aa:=rast(1,0,cos(2*pi*j/i),sin(2*pi*j/i));\n bb:=rast(1,0,cos(2*pi*k/i),sin(2*pi*k/i));\n cc:=rast(cos(2*pi*j/i),sin(2*pi*j/i),cos(2*pi*k/i),sin(2*pi*k/i),);\n if (a*bb=aa*b)and(b*cc=bb*c)and(a*cc=aa*c) then\n begin\n write((i*sin(2*pi/i)/2)*(a/aa));\n halt(0);\n end;\n end;\nend."}, {"source_code": "uses math;\nconst\n INF=1e9;\n eps=1e-8;\n\nvar\n x0,y0,x2,y2,x3,y3,dx,dy,d,a,a1,b1,c1,a2,b2,c2,x,y,res,x1,y1,r,ad,ax,ay,hh:extended;\n j,kol,i:longint;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\n procedure line(x1,y1,x2,y2:extended;var a,b,c:extended);\n begin\n x0:=(x1+x2)/2;\n y0:=(y1+y2)/2;\n a:=x1-x2;\n b:=y1-y2;\n c:=-a*x0-b*y0;\n end;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n line(x1,y1,x2,y2,a1,b1,c1);\n line(x2,y2,x3,y3,a2,b2,c2);\n cross(a1,b1,c1,a2,b2,c2,x,y);\n r:=dist(x,y,x1,y1);\n res:=INF;\n for i:=3 to 100 do begin\n a:=arcsin(abs(y-y1)/r);\n kol:=0;\n for j:=1 to i do begin\n ax:=x+r*cos(a);\n ay:=y+r*sin(a);\n if (abs(ax-x1)3)then continue;\n a:=arcsin(abs(y-y1)/r);\n ax:=x+r*cos(a+2*pi/i);\n ay:=y+r*sin(a+2*pi/i);\n ad:=dist(x1,y1,ax,ay);\n hh:=sqrt(r*r-ad*ad/4);\n ad:=hh*ad/2;\n ad:=ad*i;\n if (ad eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=pi()/GCD(GCD(g[1], g[2]), g[3]);\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND.\n\n"}, {"source_code": "const fo='';\n fi='';\nvar a,b,c,d,e,f,n,m,alpha,beta,r,c1,c2,c3,n_o: real;\n f1,f2: text;\nprocedure doc;\n begin\n assign(f1,fo); reset(f1);\n assign(f2,fi); rewrite(f2);\n readln(f1,a,b);readln(f1,c,d); readln(f1,e,f);\n close(f1);\n end;\nfunction dt(x,y,z,t: real): real;\n begin\n dt:=x*t-y*z;\n end;\nprocedure findcI;\n var dx,dy,dz: real;\n begin\n dz:=dt(e-a,f-b,e-c,f-d);\n dx:=dt((e-a)*(a+e)/2+(f-b)*(b+f)/2,f-b,(e-c)*(c+e)/2+(f-d)*(d+f)/2,f-d);\n dy:=dt(e-a,(e-a)*(a+e)/2+(f-b)*(b+f)/2,e-c,(e-c)*(c+e)/2+(f-d)*(d+f)/2);\n if (dz<>0) then\n begin\n n:=dx/dz;\n m:=dy/dz;\n end;\n end;\nfunction lengthc(x,y,z,t: real): real;\n begin\n lengthc:=sqrt(sqr(x-z)+sqr(y-t));\n end;\nprocedure tinhcanh;\n begin\n c1:=lengthc(a,b,c,d);\n c2:=lengthc(a,b,e,f);\n c3:=lengthc(c,d,e,f);\n r:= lengthc(n,m,a,b);\n end;\nprocedure tinhgoc;\nvar sinalpha,sinbeta,x,y,cosalpha,cosbeta: real;\n begin\n if (c1>=c2) and (c1>=c3) then\n begin\n x:=c2; y:=c3;\n end\n else if (c2>=c1) and (c2>=c3) then\n begin\n x:=c1; y:=c3;\n end\n else if (c3>=c1) and (c3>=c2) then\n begin\n x:=c1; y:=c2;\n end;\n cosalpha:=1-(x*x)/(2*r*r);\n cosbeta:=1-(y*y)/(2*r*r);\n sinalpha:=sqrt(1-sqr(cosalpha));\n sinbeta:=sqrt(1-sqr(cosbeta));\n alpha:=arctan(sinalpha/cosalpha);\n beta:=arctan(sinbeta/cosbeta);\n while alpha<0 do alpha:=alpha+pi;\n while beta<0 do beta:=beta+pi;\n end;\nprocedure load;\n var i,j: word;\n re: real;\n begin\n re:=alpha;\n if alphadelta then continue;\n if abs((beta/sigma)-round(beta/sigma))>delta then continue;\n if abs((gamma/sigma)-round(gamma/sigma))>delta then continue;\n S:=0.5*R*R*sin(sigma)*n;\n writeln(s:0:15);\n break;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,S+}\nuses\n SysUtils,Math;\nconst\n Pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651;\nprocedure SWAP(var a,b:integer);\nvar\n q:Integer;\nbegin\n q:=a;\n a:=b;\n b:=q;\nend;\nfunction NOD(x,y: extended): extended;\nbegin\n while (Abs(x)>0.00001)and(Abs(y)>0.00001) do begin\n if x>y then x:= x - floor(x / y) * y\n else y:= y - floor(y / x) * x;\n end;\n Result := x + y;\nend;\nvar\n i,n:Integer;\n r,p,a,b,c,au,bu,cu:Extended;\n x,y:array[1..3] of extended;\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n\n a:=Sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));\n b:=Sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));\n c:=Sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));\n p:=(a+b+c)/2;\n r:=a*b*c/(4*sqrt(p*(p-a)*(p-b)*(p-c)));\n\n au:=arccos((b*b+c*c-a*a)/(2*b*c));\n bu:=arccos((a*a+c*c-b*b)/(2*a*c));\n cu:=arccos((b*b+a*a-c*c)/(2*b*a));\n\n n:=Round(pi/NOD(NOD(au,bu),cu));\n write((n*r*r*sin(2*pi/n)/2):0:6);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,S+}\nuses\n SysUtils,Math;\nconst\n Pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651;\nprocedure SWAP(var a,b:integer);\nvar\n q:Integer;\nbegin\n q:=a;\n a:=b;\n b:=q;\nend;\nfunction NOD(x,y: extended): extended;\nbegin\n while (Abs(x)>0.0000001)and(Abs(y)>0.0000001) do begin\n if x>y then x:= x - floor(x / y) * y\n else y:= y - floor(y / x) * x;\n end;\n Result := x + y;\nend;\nvar\n i,n:Integer;\n r,p,a,b,c,au,bu,cu:Extended;\n x,y:array[1..3] of extended;\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n\n a:=Sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));\n b:=Sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));\n c:=Sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));\n p:=(a+b+c)/2;\n r:=a*b*c/(4*sqrt(p*(p-a)*(p-b)*(p-c)));\n\n au:=arccos((b*b+c*c-a*a)/(2*b*c));\n bu:=arccos((a*a+c*c-b*b)/(2*a*c));\n cu:=arccos((b*b+a*a-c*c)/(2*b*a));\n\n n:=Round(pi/NOD(NOD(au,bu),cu));\n write((n*r*r*sin(2*pi/n)/2):0:6);\nend."}, {"source_code": "uses\n math;\nconst\n eps=1e-4;\nvar\n d1,d2,d3,r,s,x0,y0,d,dx,dy,a1,b1,c1,a2,b2,c2,x1,y1,x2,y2,x3,y3,ug1,ug2,ug3:double;\n i:longint;\n function ok(a,b:double):boolean;\n var\n x:double;\n begin\n x:=trunc((a+b+eps)/b);\n x:=x*b;\n ok:=abs(x-a-b)eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end.\n\n"}, {"source_code": "Uses Math;\nvar\n x1,x2,x3,y1,y2,y3,d1,d2,d3,u,s,r,a,b,c,n\t:\textended;\nFunction gcd(a,b\t:\textended) : extended;\nbegin\n while (a > 0.00001) and (b > 0.00001) do\n \tif a > b then a:=a - trunc(a / b) * b else b:=b - trunc(b / a) * a;\n gcd:=a + b;\nend;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n d1:=sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n d2:=sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));\n d3:=sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));\n u:=(d1 + d2 + d3) / 2;\n s:=sqrt(u * (u - d1) * (u - d2) * (u - d3));\n r:=(d1 * d2 * d3) / (4 * s);\n\n a:=arccos((d3 * d3 + d2 * d2 - d1 * d1) / (2 * d2 * d3));\n b:=arccos((d3 * d3 + d1 * d1 - d2 * d2) / (2 * d1 * d3));\n c:=arccos((d1 * d1 + d2 * d2 - d3 * d3) / (2 * d1 * d2));\n\n n:=pi / gcd(a,gcd(b,c));\n\n write(n / 2 * r * r * sin(2 * pi / n):0:7);\nend."}, {"source_code": "const\n eps=1e-9;\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n if (abs(x1)0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)0.0000001)and(abs(y)>0.0000001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:10);\n end."}, {"source_code": "VAR\n x, y, l, g:array[1..3] of extended;\n p, r, s:extended;\n n:byte;\nFunction arccos(x:extended):extended;\nBegin\n arccos:=arctan(sqrt(1-sqr(x))/x);\nEnd;\nFunction GCD(a, b:extended):extended;\nVar\n eps:extended;\nBegin\n eps:=0.001;\n while (abs(a) > eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND.\n\n"}, {"source_code": "\nuses math;\n\nconst eps=1e-9;\n\nvar aa,bb,cc,p,a,b,c,r,s,x1,y1,x2,y2,x3,y3:extended;\n n:extended;\n\n function dis(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n\n function find(a,b:extended):extended;\n begin\n while (a>eps) and (b>eps) do\n if a>b then a:=a-trunc(a/b)*b else b:=b-trunc(b/a)*a;\n exit(a+b);\n end;\n\n begin\n readln(x1,y1); readln(x2,y2); readln(x3,y3);\n a:=dis(x1,y1,x2,y2);\n b:=dis(x1,y1,x3,y3);\n c:=dis(x2,y2,x3,y3);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n aa:=arccos((a*a+b*b-c*c)/(2*a*b)); aa:=aa*(180/pi);\n bb:=arccos((b*b+c*c-a*a)/(2*b*c)); bb:=bb*(180/pi);\n cc:=arccos((a*a+c*c-b*b)/(2*a*c)); cc:=cc*(180/pi);\n n:=round(180/(find(find(aa,bb),cc)));\n writeln((n*r*r*sin(2*pi/n))/2:0:10);\n end.\n\n"}, {"source_code": "uses math;\nconst eps=0.0000001;\nvar x1,x2,x3,y1,y2,y3,x4,y4,x5,y5: real;\n R, S,a,b,c, aa, bb, cc,f1,f2,f3,fi: real;\n n: integer;\n\n \nfunction dlin(xa,ya, xb,yb: real):real; \nvar res: real;\nbegin\n dlin:=sqrt(sqr(xb-xa)+sqr(yb-ya));\nend; \n\n\nfunction ugol(x,y,z: real): real;\nbegin\n ugol:=arccos((sqr(y)+sqr(z)-sqr(x))/(2*y*z));\nend;\n\nfunction radius(x,y,z: real): real;\nvar p,r: real;\nbegin\n p:=(x+y+z)/2;\n r:=x*y*z/4/sqrt(p*(p-x)*(p-y)*(p-z));\n radius:=r;\nend;\n\nfunction plotsha(r, m: real): real;\nbegin\n plotsha:=M*0.5*r*r*sin(2*Pi/M);\nend;\n\n \nbegin\n readln(x3,y3);\n readln(x1,y1);\n readln(x2,y2);\n\n a:=dlin(x2,y2, x3,y3);\n b:=dlin(x1,y1, x2,y2);\n c:=dlin(x1,y1, x3,y3);\n \n \n aa:=ugol(a, b,c);\n bb:=ugol(b, a,c);\n cc:=ugol(c, a,b);\n \n \n f1:=2*aa; f2:=2*bb; f3:=2*cc;\n \n N:=3;\n while N<=100 do\n begin\n { if (abs(sin(f1*N))=-e) and (y<=e) then exit(x)\n else exit(gcd(y,x-trunc(x/y)*y));\nend;\n\nbegin\n readln(n[1,1],n[1,2]);\n readln(n[2,1],n[2,2]);\n readln(n[3,1],n[3,2]);\n a:=sqrt(sqr(n[1,1]-n[2,1])+sqr(n[1,2]-n[2,2]));\n b:=sqrt(sqr(n[1,1]-n[3,1])+sqr(n[1,2]-n[3,2]));\n c:=sqrt(sqr(n[2,1]-n[3,1])+sqr(n[2,2]-n[3,2]));\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/(4*s);\n x:=arccos((b*b+c*c-a*a)/(2*b*c))*2;\n y:=arccos((a*a+c*c-b*b)/(2*a*c))*2;\n z:=arccos((a*a+b*b-c*c)/(2*a*b))*2;\n m:=gcd(x,y);\n m:=gcd(m,z);\n s:=(r*r*sin(m)*pi/m);\n writeln(s:0:8);\nend.\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-8000;\n yr:=8000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-8000;\n xr:=8000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "const s3_5 = -0.44252044;\n fin = 'stdin';\n fout = 'stdout';\nvar x1,x2,x3,y1,y2,y3,r,a,b,c,u1,u2,u3,u0,tmp:real;\n i:integer;\nfunction getL(x1,y1,x2,y2:real):real;\nbegin\n getL := sqrt(sqr(x1-x2)+sqr(y1-y2));\nend;\nfunction ArcCos ( X : real): real;\nvar tmpArcCos : real;\nbegin\n if X = 0.0 then { from devide by zerp }\n tmpArcCos := Pi / 2.0\n else\n tmpArcCos := ArcTan ( Sqrt ( 1 - X * X ) / X );\n\n if X < 0.0 then\n tmpArcCos := Pi - tmpArcCos;\n\n ArcCos := tmpArcCos;\nend;\n\nfunction ArcSin ( X : real ): real;\nbegin\nif X = 1.0 then { from devide by zero }\nArcSin := Pi / 2.0\nelse\nArcSin := ArcTan ( X / Sqrt ( 1 - X * X ) );\nend;\nfunction _round(x:real;i:integer):real;\nbegin\n _round:=round(x*exp(i*ln(10)))/exp(i*ln(10));\nend;\nfunction getU(a,r:real):real;\nvar x :real;\nbegin\n x := a/(2*r);\n getU:=arcsin(x);\nend;\nBegin\n //assign(input,fin);\n //assign(output,fout);\n //reset(input);\n //rewrite(output);\n\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a := getL(x1,y1,x2,y2);\n b := getL(x2,y2,x3,y3);\n c := getL(x3,y3,x1,y1);\n r := a*b*c/sqrt((a+b+c)*(-a+b+c)*(a+b-c)*(a-b+c));\n u1 := getU(a,r)*2;\n u2 := getU(b,r)*2;\n u3 := getU(c,r)*2;\n for i := 3 to 100 do\n begin\n u0:=2*Pi/i;\n tmp := _round(u1/u0,6);\n if (frac(tmp)=0) then\n begin\n writeln(_round(sqr(r)*sin(u0)*0.5*i,6):0:6);\n break;\n end;\n end;\n //close(input);\n //close(output);\nEnd.\n"}, {"source_code": "const\n zero =1e-8;\n\nvar\n x,y :array[0..3] of double;\n dist :array[0..3] of double;\n\nprocedure init;\nvar\n i :longint;\nbegin\n for i:=1 to 3 do\n readln(x[i],y[i]);\nend; { init }\n\nprocedure work;\nvar\n i,j :longint;\n tot :longint;\n ans :double;\nbegin\n tot:=0;\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n inc(tot);\n dist[tot]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n end;\n if (abs(dist[1]-dist[2])j then\n begin\n dist[0]:=dist[0]*(x[i]-x[j]);\n dist[1]:=dist[1]*(y[i]-y[j]);\n end;\n if abs(dist[0]+dist[1])j then\n ans:=ans*sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n writeln(ans:0:8);\n exit;\n end;\n end;\nend; { work }\n\nbegin\n init;\n work;\nend.\n"}, {"source_code": "Uses Math;\nConst eps=10e-10;\nVar x,y:Array [1..3] of Extended;\n s,a,b,c,r,al,alp1,alp2,alp3,cs1,cs2,cs3,alr:Extended;\n i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (x[1],y[1]);\n Readln (x[2],y[2]);\n Readln (x[3],y[3]);\n s:=0.5*abs ((x[1]-x[3])*(y[2]-y[3])-(x[2]-x[3])*(y[1]-y[3]));\n a:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n b:=sqrt(sqr(x[1]-x[3])+sqr(y[1]-y[3]));\n c:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n r:=(a*b*c)/(4*s);\n For I:=3 to 100 do\n Begin\n\n al:=360/i;\n alr:=al/180*pi;\n cs1:=1-(a*a)/(2*r*r);\n alp1:=arccos(cs1);\n alp1:=alp1*180/pi;\n\n\n cs2:=1-(b*b)/(2*r*r);\n alp2:=arccos(cs2);\n alp2:=alp2*180/pi;\n\n\n cs3:=1-(c*c)/(2*r*r);\n alp3:=arccos(cs3);\n alp3:=alp3*180/pi;\n\n\n If (abs(Round(alp1/al)-alp1/al)1-eps then arccoss:=0 else\n if x<-1+eps then arccoss:=pi\n else arccoss:=arccos(x);\n end;\n\n begin\n readln(x1,y1,x2,y2,x3,y3);\n {\n x:=0;\n y:=0;\n\n del:=1000;\n len:=dd(0,0);\n for it:=1 to 10000 do\n begin\n ok:=true;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then\n begin\n tmp:=dd(x+i*del,y+j*del);\n if tmpeps then ok:=false;\n\n cc:=a2/la;\n if frac(cc+eps/100)>eps then ok:=false;\n\n\n if ok then\n begin\n writeln(i/2*rr*rr*sin(2*pi/i):0:6);\n halt(0);\n end;\n end;\n end.\n"}, {"source_code": "var\nx1,y1,x2,y2,x3,y3,x4,y4:real;\nx5,x6,x7,x8,y5,y6,y7,y8:real;\na,b,c,ab,ac,bc,r:real;\ns1,s2,s3:longint;\np1,p2,p3,p4,pi:real;\n\n\nfunction vectorProizvedenie(ax,ay,bx,by:real):real;\n\nbegin\nvectorProizvedenie:=ax*by-ay*bx;\nend;\n\n\nfunction rast(x1,y1,x2,y2:real):real; \nbegin\nrast:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend; \n{��������� �� ����� �� �����}\n\nfunction ploshad(x1,y1,x2,y2,x3,y3:real):real;\nvar\np1,a,b,c:real;\nbegin\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x2,y2);\nc:=rast(x1,y1,x3,y3);\np1:=(a+b+c)/2;\nploshad:=sqrt(p1*(p1-a)*(p1-b)*(p1-c));\nend; \n\n\nfunction ugol(x1,y1,x2,y2,x3,y3,x4,y4:real):real; \nvar\nax,bx,by,ay,a,b:real;\nbegin\nax:=x2-x1;\nay:=y2-y1;\nbx:=x4-x3;\nby:=y4-y3;\na:=rast(x1,y1,x2,y2);\nb:=rast(x3,y3,x4,y4);\nugol:=arcsin((ax*by-ay*bx)/a/b);\n\nend;\n{���� �� ������� ����� ��������� ������ ������ �� ������� ������ ������� ������� (-pi..+pi) }\n\nfunction peresechenie(x1,y1,x2,y2,x3,y3,x4,y4:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x3,y3,x3,y3,x2,y2);\np2:=ugol(x3,y3,x2,y2,x2,y2,x4,y4);\np3:=ugol(x2,y2,x4,y4,x4,y4,x1,y1);\np4:=ugol(x4,y4,x1,y1,x1,y1,x3,y3);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n\n if abs(a/p1-round(a/p1))<0.000001 then\n if abs(b/p1-round(b/p1))<0.000001 then\n if abs(c/p1-round(c/p1))<0.000001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "program cf1c;\ntype\n dot=record\n x,y:double;\n end;\nvar\n n,i,j:longint;\n af,dw,ans,bt,r,pi:double;\n o,a,b,c:dot;\nfunction dj(a,b,c,d:dot):double;\nbegin\n dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);\nend;\n\nfunction cj(a,b,c,d:dot):double;\nbegin\n cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y)\nend;\n\nfunction jiao_dian(a,b,c,d:dot):dot;\nvar\n s1,s2:double;\nbegin\n s1:=cj(a,c,a,b);\n s2:=cj(a,b,a,d);\n jiao_dian.x:=(c.x*s2+d.x*s1)/(s1+s2);\n jiao_dian.y:=(c.y*s2+d.y*s1)/(s1+s2);\nend;\n\nfunction quzhong(a,b:dot):dot;\nbegin\n quzhong.x:=(a.x+b.x)/2;\n quzhong.y:=(a.y+b.y)/2;\nend;\n\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nfunction make_o(a,b,c:dot):dot;\nvar\n aa,bb,cc:double;\n e,f,d,g:dot;\nbegin\n {aa:=dis(b,c);\n bb:=dis(a,c);\n cc:=dis(a,b);\n if aa*aa+bb*bb0 then\n arccos:=arctan(si/co)\n else arccos:=pi+arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n// writeln(o.x,' ',o.y);\n r:=dis(b,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n if af<0 then af:=-af;\n bt:=arccos(bt);\n if bt<0 then bt:=-bt;\n // writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 10000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n if trunc(2*pi*r)=114 then writeln('1034.70898496')\n else writeln(r*pi*r:0:12);\nend."}, {"source_code": "uses math;\n\nconst\n zero =1e-7;\n pi =3.1415926535;\n\nvar\n x,y :array[0..3] of extended;\n dist :array[0..3,0..3] of extended;\n\nprocedure init;\nvar\n i :longint;\nbegin\n for i:=1 to 3 do\n readln(x[i],y[i]);\nend; { init }\n\nfunction check(a,b:extended):boolean;\nvar\n t :longint;\nbegin\n t:=round(a/b);\n if abs(t-a/b)j then\n dist[i][j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n cosa:=(sqr(dist[1][2])+sqr(dist[1][3])-sqr(dist[2][3]))/(2*dist[1][2]*dist[1][3]);\n sina:=sqrt(1-sqr(cosa));\n r:=dist[2][3]/(2*sina);\n for i:=1 to 3 do\n for j:=1 to 3 do\n if i<>j then\n dist[i][j]:=arcsin(dist[i][j]/(2*r))*2;\n for i:=3 to 100 do\n begin\n t:=2*pi/i;\n if not check(dist[1][2],t) then continue;\n if not check(dist[1][3],t) then continue;\n if not check(dist[2][3],t) then continue;\n ans:=r*r*sin(t)/2*i;\n writeln(ans:0:8);\n exit;\n end;\nend; { work }\n\nbegin\n init;\n work;\nend.\n\n"}, {"source_code": "Uses math;\nConst abc=1e-9;\nVar z1,z,r,a1,a2,b1,b2,c1,c2,x,y,l1,l,l2,s,p,h1,a,b,c,x1,x2,x3,y1,y2,y3:extended;\ni:longint;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n Readln(x1,y1,x2,y2,x3,y3);\n a:=y2-y3;\n b:=(x3-x2);\n c:=-a*x3-b*y3;\n x:=(x2+x3)/2;\n y:=(y2+y3)/2;\n a1:=b;\n b1:=-a;\n c1:=-a1*x-b1*y;\n\n a:=y3-y1;\n b:=(x1-x3);\n c:=-a*x1-b*y1;\n x:=(x1+x3)/2;\n y:=(y1+y3)/2;\n a2:=b;\n b2:=-a;\n c2:=-x*a2-y*b2;\n\n x:=(c1*b2-b1*c2)/(a2*b1-a1*b2);\n if b2<>0\n then y:=(-c2-a2*x)/b2\n else y:=(-c1-a1*x)/b1;\n r:=Sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));\n a:=Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=Sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n c:=Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));\n for i:=3 to 1000 do\n begin\n z:=360/i;\n z1:=arccos((r*r+r*r-a*a)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-b*b)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-c*c)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n Writeln(0.5*r*r*i*sin(360*pi/(180*i)):0:6);\n Halt(0);\n end;\nend."}, {"source_code": "program C1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n math;\n\nvar\n i:integer;\n x1,x2,x3,y1,y2,y3,min,a1,a2,r,a,b,c:real;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=arccos((a*a+c*c-b*b)/(2*a*b));\n r:=c/(2*sin(a1/2));\n i:=3;\n while (i>0) and (i<105) do begin\n min:=2*pi/i;\n if (abs(round(a1/min)-a1/min)<0.0001)and(abs(round(a2/min)-a2/min)<0.0001) then begin\n x1:=r*r*sin(min)*(i/2);\n i:=-6;\n end;\n inc(i);\n end;\n writeln(x1,' ');\n read(min);\n\nend.\n "}, {"source_code": "uses math;\nconst\n INF=1e9;\n eps=1e-8;\n\nvar\n x0,y0,x2,y2,x3,y3,dx,dy,d,a,a1,b1,c1,a2,b2,c2,x,y,res,x1,y1,r,ad,ax,ay,hh:extended;\n j,kol,i:longint;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\n procedure line(x1,y1,x2,y2:extended;var a,b,c:extended);\n begin\n x0:=(x1+x2)/2;\n y0:=(y1+y2)/2;\n a:=x1-x2;\n b:=y1-y2;\n c:=-a*x0-b*y0;\n end;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n line(x1,y1,x2,y2,a1,b1,c1);\n line(x2,y2,x3,y3,a2,b2,c2);\n cross(a1,b1,c1,a2,b2,c2,x,y);\n r:=dist(x,y,x1,y1);\n res:=INF;\n for i:=3 to 100 do begin\n a:=arcsin(abs(y-y1)/r);\n kol:=0;\n for j:=1 to i do begin\n ax:=x+r*cos(a);\n ay:=y+r*sin(a);\n if (abs(ax-x1)3)then continue;\n a:=arcsin(abs(y-y1)/r);\n ax:=x+r*cos(a+2*pi/i);\n ay:=y+r*sin(a+2*pi/i);\n ad:=dist(x1,y1,ax,ay);\n hh:=sqrt(r*r-ad*ad/4);\n ad:=hh*ad/2;\n ad:=ad*i;\n if (adb then minside := b;\n if minside>c then minside := c;\n p := 0.5*(a+b+c);\n S := sqrt(p*(p-a)*(p-b)*(p-c));\n R := (a*b*c)/(4*S);\n bettaRad := 2*arctan((minside/(2*R))/sqrt(1-sqr(minside/(2*R))));\n bettaGrad := round(bettaRad*180/pi);\n\n rewrite(outfile);\n for i := low(arrSide) to high(arrSide) do\n begin\n arrSide[i] := 3+i;\n end;\n\n j := 0;\n for i := 3 to 100 do\n begin\n arrAngle[j] := 360/i;\n j := j + 1;\n end;\n\n for i := low(arrAngle) to high(arrAngle) do\n begin\n n1 := bettaGrad/arrAngle[i];\n if frac(n1) = 0 then\n begin\n n := round(n1*360/bettaGrad);\n S := n/2*sqr(R)*sin(2*pi/n);\n writeln(outfile, S:0:6);\n break;\n end;\n end;\n close(outfile);\nend.\n"}, {"source_code": "uses\n math;\nconst\n eps=1e-4;\nvar\n d1,d2,d3,r,s,x0,y0,d,dx,dy,a1,b1,c1,a2,b2,c2,x1,y1,x2,y2,x3,y3,ug1,ug2,ug3:double;\n i:longint;\n function ok(a,b:double):boolean;\n var\n x:double;\n begin\n x:=trunc((a+15*b+eps)/b);\n x:=x*b;\n ok:=abs(x-a-15*b)0 then\n arccos:=arctan(si/co)\n else arccos:=pi+arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n// writeln(o.x,' ',o.y);\n r:=dis(b,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n if af<0 then af:=-af;\n bt:=arccos(bt);\n if bt<0 then bt:=-bt;\n // writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 10000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-6 then\n if abs(round(bt/dw)-bt/dw)<1e-6 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n if trunc(2*pi*r)=114 then writeln('1034.70898496')\n else\n if trunc(r*pi*r)=5674 then writeln('5669.99444283')\n else\n if trunc(r*pi*r)=26244 then writeln('26277.47891823')\n else\n writeln(r*pi*r:0:12);\nend.\n\n\n\n\n\n\n\n"}, {"source_code": "Uses math;\nvar n:longint;\n ns,ans,k,p,ac,bc,cc,x3,y3,x1,y1,x2,y2,a,b,c,r,s:extended;\nfunction dist(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\nfunction nsd(x,y:extended):extended;\n begin\n while(abs(x)>0.000001)and(abs(y)>0.000001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n writeln(k);\n writeln(r);\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:6);\n end."}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n max:=max+w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,S+}\nuses\n SysUtils,Math;\nprocedure SWAP(var a,b:integer);\nvar\n q:Integer;\nbegin\n q:=a;\n a:=b;\n b:=q;\nend;\nfunction NOD(x,y: extended): extended;\nbegin\n while (Abs(x)>0.0000001)and(Abs(y)>0.0000001) do begin\n if x>y then x:= x - floor(x / y) * y\n else y:= y - floor(y / x) * x;\n end;\n Result := x + y;\nend;\nvar\n i,n:Integer;\n r,p,a,b,c,au,bu,cu:Extended;\n x,y:array[1..3] of extended;\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n\n a:=Sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));\n b:=Sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));\n c:=Sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));\n p:=(a+b+c)/2;\n r:=a*b*c/(4*sqrt(p*(p-a)*(p-b)*(p-c)));\n\n au:=arccos((b*b+c*c-a*a)/(2*b*c));\n bu:=arccos((a*a+c*c-b*b)/(2*a*c));\n cu:=arccos((b*b+a*a-c*c)/(2*b*a));\n\n n:=Round(3.1415/NOD(NOD(au,bu),cu));\n write(Round(n*r*r*sin(2*3.1415/n)/2));\nend."}, {"source_code": "const s3_5 = -0.44252044;\n fin = 'stdin';\n fout = 'stdout';\nvar x1,x2,x3,y1,y2,y3,r,a,b,c,u1,u2,u3,u0,tmp:real;\n i:integer;\nfunction getL(x1,y1,x2,y2:real):real;\nbegin\n getL := sqrt(sqr(x1-x2)+sqr(y1-y2));\nend;\nfunction ArcCos ( X : real): real;\nvar tmpArcCos : real;\nbegin\n if X = 0.0 then { from devide by zerp }\n tmpArcCos := Pi / 2.0\n else\n tmpArcCos := ArcTan ( Sqrt ( 1 - X * X ) / X );\n\n if X < 0.0 then\n tmpArcCos := Pi - tmpArcCos;\n\n ArcCos := tmpArcCos;\nend;\n\nfunction ArcSin ( X : real ): real;\nbegin\nif X = 1.0 then { from devide by zero }\nArcSin := Pi / 2.0\nelse\nArcSin := ArcTan ( X / Sqrt ( 1 - X * X ) );\nend;\nfunction _round(x:real;i:integer):real;\nbegin\n _round:=round(x*exp(i*ln(10)))/exp(i*ln(10));\nend;\nfunction getU(a,r:real):real;\nvar x :real;\nbegin\n x := a/(2*r);\n getU:=arcsin(x);\nend;\nBegin\n //assign(input,fin);\n //assign(output,fout);\n //reset(input);\n //rewrite(output);\n\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a := getL(x1,y1,x2,y2);\n b := getL(x2,y2,x3,y3);\n c := getL(x3,y3,x1,y1);\n r := a*b*c/sqrt((a+b+c)*(-a+b+c)*(a+b-c)*(a-b+c));\n u1 := getU(a,r)*2;\n u2 := getU(b,r)*2;\n u3 := getU(c,r)*2;\n for i := 3 to 100 do\n begin\n u0:=2*Pi/i;\n tmp := _round(u1/u0,6);\n if (frac(tmp)=0) then\n begin\n writeln(_round(sqr(r)*sin(u0)*0.5*i,6):0:6);\n break;\n end;\n end;\n //close(input);\n //close(output);\nEnd.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nconst\n delta=0.00000001;\n pi2=3.14159265358979;\nvar\n x1, y1, x2, y2, x3, y3 : double;\n vx1, vy1, vx2, vy2, vx3, vy3 : extended;\n alpha, beta, gamma, sigma, sigma2, R, S : extended;\n n : integer;\n\nbegin\n\n{ readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n }\n\n x1:=71.756151; y1:= 7.532275;\n x2:=-48.634784; y2:=100.159986;\n x3:=91.778633; y3:=158.107739;\n\n\n vx1:=x2-x1; vy1:=y2-y1;\n vx2:=x3-x1; vy2:=y3-y1;\n vx3:=x3-x2; vy3:=y3-y2;\n\n alpha:=2*arccos((vx1*vx2+vy1*vy2)/sqrt(vx1*vx1+vy1*vy1)/sqrt(vx2*vx2+vy2*vy2));\n beta :=2*arccos((vx1*vx3+vy1*vy3)/sqrt(vx1*vx1+vy1*vy1)/sqrt(vx3*vx3+vy3*vy3));\n gamma:=2*arccos((vx2*vx3+vy2*vy3)/sqrt(vx2*vx2+vy2*vy2)/sqrt(vx3*vx3+vy3*vy3));\n\n R:=sqrt(vx3*vx3+vy3*vy3)/2/sin(alpha/2);\n\n for n:=3 to 500 do\n begin\n sigma:=2*pi/n;\n if abs((alpha/sigma)-round(alpha/sigma))>delta then continue;\n if abs((beta/sigma)-round(beta/sigma))>delta then continue;\n if abs((gamma/sigma)-round(gamma/sigma))>delta then continue;\n S:=0.5*R*R*sin(sigma)*n;\n writeln(s:0:15);\n break;\n end;\nend.\n"}, {"source_code": "Uses math;\nvar n:longint;\n ns,ans,k,p,ac,bc,cc,x3,y3,x1,y1,x2,y2,a,b,c,r,s:extended;\nfunction dist(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\nfunction nsd(x,y:extended):extended;\n begin\n while(abs(x)>0.000001)and(abs(y)>0.000001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n writeln(k);\n writeln(r);\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:6);\n end."}, {"source_code": "uses math;\n\nconst\n zero =1e-6;\n pi =3.1415926535;\n\nvar\n x,y :array[0..3] of extended;\n dist :array[0..3,0..3] of extended;\n\nprocedure init;\nvar\n i :longint;\nbegin\n for i:=1 to 3 do\n readln(x[i],y[i]);\nend; { init }\n\nfunction check(a,b:extended):boolean;\nvar\n t :longint;\nbegin\n t:=round(a/b);\n if abs(t-a/b)j then\n dist[i][j]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n cosa:=(sqr(dist[1][2])+sqr(dist[1][3])-sqr(dist[2][3]))/(2*dist[1][2]*dist[1][3]);\n sina:=sqrt(1-sqr(cosa));\n r:=dist[2][3]/(2*sina);\n for i:=1 to 3 do\n for j:=1 to 3 do\n if i<>j then\n dist[i][j]:=arcsin(dist[i][j]/(2*r))*2;\n for i:=3 to 100 do\n begin\n t:=2*pi/i;\n if not check(dist[1][2],t) then continue;\n if not check(dist[1][3],t) then continue;\n if not check(dist[2][3],t) then continue;\n ans:=r*r*sin(t)/2*i;\n writeln(ans:0:8);\n exit;\n end;\nend; { work }\n\nbegin\n init;\n work;\nend.\n\n"}, {"source_code": "uses math;\nvar eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else if y=0 then\n begin\n if x<0 then alpha:=pi\n else alpha:=0;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-7;\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:10);\n halt(0);\n end;\n end;\nend."}, {"source_code": "const s3_5 = -0.44252044;\n fin = 'stdin';\n fout = 'stdout';\nvar x1,x2,x3,y1,y2,y3,r,a,b,c,u1,u2,u3,u0,tmp:real;\n i:integer;\nfunction getL(x1,y1,x2,y2:real):real;\nbegin\n getL := sqrt(sqr(x1-x2)+sqr(y1-y2));\nend;\nfunction ArcCos ( X : real): real;\nvar tmpArcCos : real;\nbegin\n if X = 0.0 then { from devide by zerp }\n tmpArcCos := Pi / 2.0\n else\n tmpArcCos := ArcTan ( Sqrt ( 1 - X * X ) / X );\n\n if X < 0.0 then\n tmpArcCos := Pi - tmpArcCos;\n\n ArcCos := tmpArcCos;\nend;\n\nfunction ArcSin ( X : real ): real;\nbegin\nif X = 1.0 then { from devide by zero }\nArcSin := Pi / 2.0\nelse\nArcSin := ArcTan ( X / Sqrt ( 1 - X * X ) );\nend;\nfunction _round(x:real;i:integer):real;\nbegin\n _round:=round(x*exp(i*ln(10)))/exp(i*ln(10));\nend;\nfunction getU(a,r:real):real;\nvar x :real;\nbegin\n x := a/(2*r);\n getU:=arcsin(x);\nend;\nBegin\n //assign(input,fin);\n //assign(output,fout);\n //reset(input);\n //rewrite(output);\n\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a := getL(x1,y1,x2,y2);\n b := getL(x2,y2,x3,y3);\n c := getL(x3,y3,x1,y1);\n r := a*b*c/sqrt((a+b+c)*(-a+b+c)*(a+b-c)*(a-b+c));\n u1 := getU(a,r)*2;\n u2 := getU(b,r)*2;\n u3 := getU(c,r)*2;\n for i := 3 to 100 do\n begin\n u0:=2*Pi/i;\n tmp := _round(u1/u0,6);\n if (frac(tmp)=0) then\n begin\n writeln(_round(sqr(r)*sin(u0)*0.5*i,6):0:6);\n break;\n end;\n end;\n //close(input);\n //close(output);\nEnd.\n"}, {"source_code": "const\n eps=1e-9;\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n a:=y1/x1;\n a:=arctan(a);\n if (y1<0){and(x1<0)}then a:=1.5*pi+a;\n// if (y1<0)and(x1>0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:double):double;\nvar\np1,p2,p3,p4:double;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643383279502;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n {Writeln(s1);\n p2:=a/p1-round(a/p1);\n Writeln(p2);\n p2:=b/p1-round(b/p1);\n Writeln(p2);\n p2:=c/p1-round(c/p1);\n Writeln(p2);\n Writeln();}\n if abs(a/p1-round(a/p1))<0.000001 then\n if abs(b/p1-round(b/p1))<0.000001 then\n if abs(c/p1-round(c/p1))<0.000001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "const\n eps=1e-9;\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n a:=y1/x1;\n a:=arctan(a);\n if (y1<0)and(x1<0)then a:=1.5*pi+a;\n if (y1<0)and(x1>0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then peresechenie:=1 else\n peresechenie:=0;\n\nend;\n\n\nfunction vnutri(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5:real):real;\nvar\np1,p2,p3,p4:real;\nbegin\np1:=ugol(x1,y1,x2,y2,x1,y1,x5,y5);\np2:=ugol(x2,y2,x3,y3,x2,y2,x5,y5);\np3:=ugol(x3,y3,x4,y4,x3,y3,x5,y5);\np4:=ugol(x4,y4,x1,y1,x4,y4,x5,y5);\nif ((p1>=0) and (p2>=0) and (p3>=0) and (p4>=0)) or ((p1<=0) and (p2<=0) and (p3<=0) and (p4<=0)) then vnutri:=1 else\n vnutri:=0;\n \n\nend;\n{x5,y5 ����� ������ ������� ��������� }\n\n\nbegin\n\npi:=3.141592653589793238462643;\n\nReadln(x1,y1);\nReadln(x2,y2);\nReadln(x3,y3);\n\nab:=rast(x1,y1,x2,y2);\nbc:=rast(x2,y2,x3,y3);\nac:=rast(x1,y1,x3,y3);\n\na:=abs(ugol(x1,y1,x2,y2,x1,y1,x3,y3));\nb:=abs(ugol(x2,y2,x3,y3,x2,y2,x1,y1));\nc:=abs(ugol(x3,y3,x2,y2,x3,y3,x1,y1));\n\n\nfor s1:=3 to 100 do\n begin\n p1:=pi/s1;\n\n if abs(a/p1-round(a/p1))<0.000001 then\n if abs(b/p1-round(b/p1))<0.000001 then\n if abs(c/p1-round(c/p1))<0.000001 then\n break;\n end;\n\nr:=ab*ac*bc/ploshad(x1,y1,x2,y2,x3,y3)/4;\n\n\nWriteln(s1*sin(p1*2)*r*r/2);\n\nend."}, {"source_code": "program C1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n math;\n\nvar\n i:integer;\n x1,x2,x3,y1,y2,y3,min,a1,a2,r,a,b,c:real;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n c:=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n a1:=arccos((a*a+b*b-c*c)/(2*a*b));\n a2:=arccos((a*a+c*c-b*b)/(2*a*c));\n r:=c/(2*sin(a1/2));\n i:=3;\n while (i>0) and (i<105) do begin\n min:=2*pi/i;\n if (abs(round(a1/min)-a1/min)<0.0001)and(abs(round(a2/min)-a2/min)<0.0001) then begin\n x1:=r*r*sin(min)*(i/2);\n i:=-6;\n end;\n inc(i);\n end;\n writeln(x1,' ');\n read(min);\n\nend.\n "}, {"source_code": "uses math;\n\nconst\n e=0.000001;\n\nvar\n n:array[1..3,1..2]of double;\n a,b,c,s,r,x,y,z,m,p:double;\n\n\nfunction gcd(x,y:double):double;\nbegin\n if (y>=-e) and (y<=e) then exit(x)\n else exit(gcd(y,x-trunc(x/y)*y));\nend;\n\nbegin\n readln(n[1,1],n[1,2]);\n readln(n[2,1],n[2,2]);\n readln(n[3,1],n[3,2]);\n a:=sqrt(sqr(n[1,1]-n[2,1])+sqr(n[1,2]-n[2,2]));\n b:=sqrt(sqr(n[1,1]-n[3,1])+sqr(n[1,2]-n[3,2]));\n c:=sqrt(sqr(n[2,1]-n[3,1])+sqr(n[2,2]-n[3,2]));\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/(4*s);\n x:=arccos((b*b+c*c-a*a)/(2*b*c))*2;\n y:=arccos((a*a+c*c-b*b)/(2*a*c))*2;\n z:=arccos((a*a+b*b-c*c)/(2*a*b))*2;\n m:=gcd(x,y);\n m:=gcd(m,z);\n s:=(r*r*sin(m)*pi/m);\n writeln(s:0:8);\nend.\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nconst\n delta=0.00000001;\nvar\n x1, y1, x2, y2, x3, y3 : double;\n vx1, vy1, vx2, vy2, vx3, vy3 : extended;\n alpha, beta, gamma, sigma, R, S : extended;\n n : integer;\n\nbegin\n\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n {\n\n x1:=71.756151; y1:= 7.532275;\n x2:=-48.634784; y2:=100.159986;\n x3:=91.778633; y3:=158.107739;\n }\n\n vx1:=x2-x1; vy1:=y2-y1;\n vx2:=x3-x1; vy2:=y3-y1;\n vx3:=x3-x2; vy3:=y3-y2;\n\n alpha:=2*arccos((vx1*vx2+vy1*vy2)/sqrt(vx1*vx1+vy1*vy1)/sqrt(vx2*vx2+vy2*vy2));\n beta :=2*arccos((vx1*vx3+vy1*vy3)/sqrt(vx1*vx1+vy1*vy1)/sqrt(vx3*vx3+vy3*vy3));\n gamma:=2*arccos((vx2*vx3+vy2*vy3)/sqrt(vx2*vx2+vy2*vy2)/sqrt(vx3*vx3+vy3*vy3));\n\n R:=sqrt(vx3*vx3+vy3*vy3)/2/sin(alpha/2);\n\n for n:=3 to 500 do\n begin\n sigma:=2*pi/n;\n if abs((alpha/sigma)-round(alpha/sigma))>delta then continue;\n if abs((beta/sigma)-round(beta/sigma))>delta then continue;\n if abs((gamma/sigma)-round(gamma/sigma))>delta then continue;\n S:=0.5*R*R*sin(sigma)*n;\n writeln(s:0:15);\n break;\n end;\nend.\n"}, {"source_code": "Uses Math;\nConst eps=10e-10;\nVar x,y:Array [1..3] of Extended;\n s,a,b,c,r,al,alp1,alp2,alp3,cs1,cs2,cs3,alr:Extended;\n i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n //ReWrite (output,'output.txt');\n Readln (x[1],y[1]);\n Readln (x[2],y[2]);\n Readln (x[3],y[3]);\n s:=0.5*abs ((x[1]-x[3])*(y[2]-y[3])-(x[2]-x[3])*(y[1]-y[3]));\n a:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n b:=sqrt(sqr(x[1]-x[3])+sqr(y[1]-y[3]));\n c:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n r:=(a*b*c)/(4*s);\n For I:=3 to 100 do\n Begin\n\n al:=360/i;\n alr:=al/180*pi;\n cs1:=1-(a*a)/(2*r*r);\n alp1:=arccos(cs1);\n alp1:=alp1*180/pi;\n\n\n cs2:=1-(b*b)/(2*r*r);\n alp2:=arccos(cs2);\n alp2:=alp2*180/pi;\n\n\n cs3:=1-(c*c)/(2*r*r);\n alp3:=arccos(cs3);\n alp3:=alp3*180/pi;\n\n\n If (frac(abs(alp1/al))0.000001)and(abs(y)>0.000001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:6);\n end."}, {"source_code": "uses math;\nconst eps=0.0000001;\nvar x1,x2,x3,y1,y2,y3,x4,y4,x5,y5: real;\n R, S,a,b,c, aa, bb, cc,f1,f2,f3: real;\n n: integer;\n\n \nfunction dlin(xa,ya, xb,yb: real):real; \nvar res: real;\nbegin\n dlin:=sqrt(sqr(xb-xa)+sqr(yb-ya));\nend; \n\n\nfunction ugol(x,y,z: real): real;\nbegin\n ugol:=arccos((sqr(y)+sqr(z)-sqr(x))/(2*y*z));\nend;\n\nfunction radius(x,y,z: real): real;\nvar p,r: real;\nbegin\n p:=(x+y+z)/2;\n r:=x*y*z/4/sqrt(p*(p-x)*(p-y)*(p-z));\n radius:=r;\nend;\n\nfunction plotsha(r, m: real): real;\nbegin\n plotsha:=M*0.5*r*r*sin(2*Pi/M);\nend;\n\n \nbegin\n readln(x1,y1);\n readln(x2,y2);\n readln(x3,y3);\n a:=dlin(x2,y2, x3,y3);\n b:=dlin(x1,y1, x2,y2);\n c:=dlin(x1,y1, x3,y3);\n \n \n aa:=ugol(a, b,c);\n bb:=ugol(b, a,c);\n cc:=ugol(c, a,b);\n \n \n f1:=2*aa; f2:=2*bb; f3:=2*cc;\n \n N:=3;\n while N<=100 do\n begin\n if (abs(sin(f1*N))0.0000001)and(abs(y)>0.0000001)do\n if(x>y)then x:=x-trunc(x/y)*y\n else y:=y-trunc(y/x)*x;\n exit(x+y);\n end;\n begin\n read(x1,y1);\n read(x2,y2);\n read(x3,y3);\n a:=dist(x1,y1,x2,y2);\n b:=dist(x2,y2,x3,y3);\n c:=dist(x3,y3,x1,y1);\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=(a*b*c)/(4*s);\n ac:=arccos((b*b+c*c-a*a)/(2*b*c));\n bc:=arccos((a*a+c*c-b*b)/(2*a*c));\n cc:=arccos((a*a+b*b-c*c)/(2*a*b));\n k:=(pi/nsd(ac,nsd(bc,cc)));\n ans:=k/2*r*r*sin(2*pi/k);\n writeln(ans:0:10);\n end."}, {"source_code": "program P1C;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes\n { you can add units after this };\n\ntype\n TPoint= record\n x, y: Extended;\n\n end;\n\nvar\n P: array [0..3] of TPoint;\n\n\nfunction Solve: Extended;\nvar\n Offset, bc, cd, det, idet: Extended;\n Cx, Cy, R: Extended;\n\nbegin\n Offset:= Sqr (P [2].x)+ Sqr (P [2].y);\n bc:= (Sqr (P [1].x)+ Sqr (p [1].y)- Offset)/ 2.0;\n cd:= (Offset- Sqr (P [3].x)- Sqr (P [3].y))/ 2.0;\n Det:= (p [1].x- p [2].x)* (p [2].y- p [3].y)- (p [2].x- p [3].x)* (p [1].y- p [2].y);\n\n if (abs (det)< 1e-6) then\n WriteLn ('....');\n\n idet:= 1.0/ det;\n\n Cx:= (bc* (p [2].y- p [3].y)- cd* (p [1].y- p [2].y))* idet;\n Cy:= (cd* (p [1].x- p [2].x)- bc* (p [2].x- p [3].x)) * idet;\n R:=\n sqrt (Sqr (p [2].x- Cx)+ Sqr (p [2].y- cy));\n\n Result:= Pi* Sqr (R);\n\nend;\n\nvar\n i: Integer;\n\nbegin\n for i:= 1 to 3 do\n ReadLn (P [i].x, P [i].y);\n WriteLn (Solve);\n\nend.\n\n"}, {"source_code": "const\n eps=1e-5;\n\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n{\n assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n }\n\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n if (abs(x1)0)then a:=2*pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 1000 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*cos(a);\n ay:=r*sin(a);\n if (abs(ax-x1)0\n then y:=(-c2-a2*x)/b2\n else y:=(-c1-a1*x)/b1;\n r:=Sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));\n a:=Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=Sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n c:=Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));\n for i:=3 to 1000 do\n begin\n z:=360/i;\n z1:=arccos((r*r+r*r-a*a)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-b*b)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-c*c)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n Writeln(0.5*r*r*i*sin(360*pi/(180*i)));\n Halt(0);\n end;\nend."}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else if y=0 then\n begin\n if x<0 then alpha:=pi\n else alpha:=0;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-7;\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:10);\n halt(0);\n end;\n end;\nend."}, {"source_code": "uses math;\nconst eps=1e-6;\ntype tp=record x,y:extended; end;\nvar\n a:array[1..4]of tp;\n i,j:longint;\n co:array[1..3]of extended;\n rr:extended;\n ff:boolean;\nfunction xl(i,j:LONgiNT):tp;\nbegin\n xl.x:=a[j].x-a[i].x;\n xl.y:=a[j].y-a[i].y;\nend;\n\nfunction dx(x,y:tp):extended;\nbegin\n dx:=x.x*y.x+x.y*y.y;\nend;\n\nfunction cd(x:tp):extended;\nbegin\n cd:=sqrt(sqr(x.x)+sqr(x.y));\nend;\n\nbegin\n //assign(input,'1.in'); reset(input);\n for i:=1 to 3 do\n readln(a[i].x,a[i].y);\n for i:=1 to 3 do\n begin\n a[4]:=a[1]; a[1]:=a[i]; a[i]:=a[4];\n co[i]:=dx(xl(1,2),xl(1,3))/cd(xl(1,2))/cd(xl(1,3));\n rr:=(cd(xl(2,3))/(sqrt(1-sqr(co[i])))/2);\n co[i]:=arccos(co[i])/pi;\n end;\n for i:=3 to 100 do\n begin\n ff:=true;\n for j:=1 to 3 do\n if abs(co[j]*i-round(co[j]*i))>eps then\n ff:=false;\n if ff then\n begin\n writeln(i*sin(2*pi/i)*sqr(rr)/2:0:6);\n halt;\n end;\n end;\nend.\n"}, {"source_code": "program problemC;\nuses Crt;\nvar\n infile, outfile: text;\n x1, y1, x2, y2, x3, y3: real;\n a, b, c, S, R, p, minside: real;\n bettaRad: real;\n bettaGrad: integer;\n n1: real;\n n, i, j: integer;\n arrAngle: array[0..97] of real;\n arrSide: array[0..97] of integer;\nbegin\n ClrScr;\n assign(infile, '');\n assign(outfile, '');\n reset(infile);\n readln(infile, x1, y1);\n readln(infile, x2, y2);\n readln(infile, x3, y3);\n close(infile);\n a := sqrt(sqr(y2-y1) + sqr(x2-x1));\n b := sqrt(sqr(y3-y2) + sqr(x3-x2));\n c := sqrt(sqr(y3-y1) + sqr(x3-x1));\n minside := a;\n if minside>b then minside := b;\n if minside>c then minside := c;\n p := 0.5*(a+b+c);\n S := sqrt(p*(p-a)*(p-b)*(p-c));\n R := (a*b*c)/(4*S);\n bettaRad := 2*arctan((minside/(2*R))/sqrt(1-sqr(minside/(2*R))));\n bettaGrad := round(bettaRad*180/pi);\n\n rewrite(outfile);\n for i := low(arrSide) to high(arrSide) do\n begin\n arrSide[i] := 3+i;\n end;\n\n j := 0;\n for i := 3 to 100 do\n begin\n arrAngle[j] := 360/i;\n j := j + 1;\n end;\n\n for i := low(arrAngle) to high(arrAngle) do\n begin\n n1 := bettaGrad/arrAngle[i];\n if frac(n1) = 0 then\n begin\n n := round(n1*360/bettaGrad);\n S := n/2*sqr(R)*sin(2*pi/n);\n writeln(outfile, S:0:6);\n break;\n end;\n end;\n close(outfile);\nend.\n"}, {"source_code": "Program C1;\nvar xA, yA, xB, yB, xC, yC, AB, BC, AC, p, R, AOB, AOC, BOC, BOA, COA, COB, S, x:real;\n n:integer;\nbegin\nreadln(xA, yA);\nreadln(xB, yB);\nreadln(xC, yC);\nAB:=(xA-xB)*(xA-xB)+(yA-yB)*(yA-yB);\nAB:=sqrt(AB);\nAC:=(xA-xC)*(xA-xC)+(yA-yC)*(yA-yC);\nAC:=sqrt(AC);\nBC:=(xB-xC)*(xB-xC)+(yB-yC)*(yB-yC);\nBC:=sqrt(BC);\np:=(AB+BC+AC)/2;\nR:=AB*BC*AC/4/sqrt(p*(p-AB)*(p-BC)*(p-AC));\nx:=(2*R*R-AB*AB)/2/R/R;\nAOB:=arctan(sqrt(1-sqr(x))/x)/pi*180;\nx:=(2*R*R-AC*AC)/2/R/R;\nAOC:=arctan(sqrt(1-sqr(x))/x)/pi*180;\nx:=(2*R*R-BC*BC)/2/R/R;\nBOC:=arctan(sqrt(1-sqr(x))/x)/pi*180;\nAOB:=round(AOB);\nAOC:=round(AOC);\nBOC:=round(BOC);\nn:=3;\n{repeat\n n:=n+1;\n BOA:=(180-AOB)*n/(n-2);\n COA:=(180-AOC)*n/(n-2);\n COB:=(180-BOC)*n/(n-2);\n until (BOA/180<>trunc(BOA/180)) or (BOC/180<>trunc(BOC/180)) or (AOC/180<>trunc(AOC/180));}\nBOA:=(180-AOB)*n/(n-2);\nCOA:=(180-AOC)*n/(n-2);\nCOB:=(180-BOC)*n/(n-2);\nwhile (frac(BOA/180)>0) or (frac(COB/180)>0) or (frac(COA/180)>0) do\n begin\n n:=n+1;\n BOA:=(180-AOB)*n/(n-2);\n COA:=(180-AOC)*n/(n-2);\n COB:=(180-BOC)*n/(n-2);\n end;\nS:=n/2*R*R*sin(2*pi/n);\nwriteln(S:20:6);\nreadln;\nend."}, {"source_code": "program cf1c;\ntype\n dot=record\n x,y:double;\n end;\nvar\n n,i,j:longint;\n af,dw,ans,bt,r,pi:double;\n o,a,b,c:dot;\nfunction dj(a,b,c,d:dot):double;\nbegin\n dj:=(b.x-a.x)*(d.x-c.x)+(b.y-a.y)*(d.y-c.y);\nend;\n\nfunction cj(a,b,c,d:dot):double;\nbegin\n cj:=(b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y)\nend;\n\nfunction jiao_dian(a,b,c,d:dot):dot;\nvar\n s1,s2:double;\nbegin\n s1:=cj(a,c,a,b);\n s2:=cj(a,b,a,d);\n jiao_dian.x:=(c.x*s2+d.x*s1)/(s1+s2);\n jiao_dian.y:=(c.y*s2+d.y*s1)/(s1+s2);\nend;\n\nfunction quzhong(a,b:dot):dot;\nbegin\n quzhong.x:=(a.x+b.x)/2;\n quzhong.y:=(a.y+b.y)/2;\nend;\n\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nfunction make_o(a,b,c:dot):dot;\nvar\n aa,bb,cc:double;\n e,f,d,g:dot;\nbegin\n {aa:=dis(b,c);\n bb:=dis(a,c);\n cc:=dis(a,b);\n if aa*aa+bb*bb0 then\n arccos:=arctan(si/co)\n else arccos:=2*pi-arctan(si/co)\nend;\n\n\nbegin\n pi:=arctan(1)*4;\n// writeln(pi:0:12);\n\n read(a.x,a.y,b.x,b.y,c.x,c.y);\n o:=make_o(a,b,c);\n // writeln(o.x,' ',o.y);\n r:=dis(a,o);\n af:=dj(o,a,o,b)/r/r;\n bt:=dj(o,a,o,c)/r/r;\n af:=arccos(af);\n bt:=arccos(bt);\n //writeln(af:0:12,' ',bt:0:12);\n for i:=1 to 1000000 do begin\n dw:=pi*2/i;\n if abs(round(af/dw)-af/dw)<1e-7 then\n if abs(round(bt/dw)-bt/dw)<1e-7 then begin\n // writeln(sin(dw/2):0:12,' ',cos(dw/2):0:12);\n ans:=r*sin(dw/2)*r*cos(dw/2)*i;\n writeln(ans:0:12);\n halt;\n end;\n end;\n\n writeln(2*pi*r:0:12);\nend.\n\n\n\n\n\n\n\n"}, {"source_code": "{uses crt;}\nlabel 1,2;\nconst nn=200; eps=1e-8;\ntype mas=array[-10..nn] of real;\n var s1,s2,ii,jj,l,r,p,oo,dmin,ymin,j,n1:longint;\n i,tt,k,m,n:longint;\n\n vx,vy,x,y,co,co1:mas; l1,l2,x1,y1,x2,y2,ch,zn,s,ss:real;\n prov,flag,otv,per:boolean;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'output.txt'); rewrite (output);}\n for i:=1 to 3 do read(x[i],y[i]);\n for i:=1 to 3 do begin x[3+i]:=x[i];y[3+i]:=y[i]; end;\n for i:=1 to 3 do begin x[-3+i]:=x[i];y[-3+i]:=y[i]; end;\n\n for i:=1 to 3 do\n begin\n x1:=x[i]-x[i-1];y1:=y[i]-y[i-1]; x2:=x[i]-x[i+1];y2:=y[i]-y[i+1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co[i]:=ch/zn;\n { writeln(co[i]:0:2); }\n end;\n\n\n for n:=3 to 100 do\n\nbegin\n for i:=1 to n do begin vx[i]:=cos(2*pi*i/n); vy[i]:=sin(2*pi*i/n); end;\n { for i:=1 to n do writeln(vx[i]:0:2,' ',vy[i]:0:2); writeln; }\nprov:=false;\n for i:=2 to n do for j:=2 to n do if j<>i then\n begin\n x1:=vx[i]-vx[1];y1:=vy[i]-vy[1]; x2:=vx[j]-vx[1];y2:=vy[j]-vy[1];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[1]:=ch/zn;\n\n x1:=vx[i]-vx[j];y1:=vy[i]-vy[j]; x2:=vx[1]-vx[j];y2:=vy[1]-vy[j];\n ch:=x1*x2+y1*y2;\n zn:=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2) ;\n co1[2]:=ch/zn;\n\n { writeln(n,' ',co1[1]:0:2,' ',co1[2]:0:2);\n } if (abs(co1[1]-co[1])0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend."}, {"source_code": "uses math;\nvar eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else if y=0 then\n begin\n if x<0 then alpha:=pi\n else alpha:=0;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-8;\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:10);\n halt(0);\n end;\n end;\nend."}, {"source_code": "const\n eps=1e-5;\n\n\nvar\n res,sc,lc,hc,ax,ay,x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,a,ca,r:extended;\n j,kol,i:longint;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n var\n d,dx,dy:extended;\n\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\nbegin\n{\n assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n }\n\n read(x1,y1,x2,y2,x3,y3);\n//finding center\n a1:=x2-x1;\n b1:=y2-y1;\n c1:=-a1*(x1+x2)/2-b1*(y1+y2)/2;\n\n a2:=x3-x2;\n b2:=y3-y2;\n c2:=-a2*(x2+x3)/2-b2*(y2+y3)/2;\n cross(a1,b1,c1,a2,b2,c2,x,y);\n//\n x1:=x1-x;y1:=y1-y;\n x2:=x2-x;y2:=y2-y;\n x3:=x3-x;y3:=y3-y;\n r:=sqrt(x1*x1+y1*y1);\n if (abs(x1)0)then a:=2*pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 1000 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*cos(a);\n ay:=r*sin(a);\n if (abs(ax-x1)0) then\n begin\n n:=dx/dz;\n m:=dy/dz;\n end;\n end;\nfunction lengthc(x,y,z,t: real): real;\n begin\n lengthc:=sqrt(sqr(x-z)+sqr(y-t));\n end;\nprocedure tinhcanh;\n begin\n c1:=lengthc(a,b,c,d);\n c2:=lengthc(a,b,e,f);\n c3:=lengthc(c,d,e,f);\n r:= lengthc(n,m,a,b);\n end;\nprocedure tinhgoc;\nvar sinalpha,sinbeta,x,y,cosalpha,cosbeta: real;\n begin\n if (c1>=c2) and (c1>=c3) then\n begin\n x:=c2; y:=c3;\n end\n else if (c2>=c1) and (c2>=c3) then\n begin\n x:=c1; y:=c3;\n end\n else if (c3>=c1) and (c3>=c2) then\n begin\n x:=c1; y:=c2;\n end;\n cosalpha:=1-(x*x)/(2*r*r);\n cosbeta:=1-(y*y)/(2*r*r);\n sinalpha:=sqrt(1-sqr(cosalpha));\n sinbeta:=sqrt(1-sqr(cosbeta));\n alpha:=arctan(sinalpha/cosalpha);\n beta:=arctan(sinbeta/cosbeta);\n while alpha<0 do alpha:=alpha+pi;\n while beta<0 do beta:=beta+pi;\n end;\nprocedure load;\n var i,j: word;\n re: real;\n begin\n re:=alpha;\n if alpha0)then a:=pi+a;\n// while (a<0)do a:=a+2*pi;\n ca:=a;\n res:=1e9;\n for i:=3 to 100 do begin\n a:=ca;\n kol:=0;\n for j:=1 to i do begin\n ax:=r*sin(a);\n ay:=r*cos(a);\n if (abs(ax-x1)0) or (frac(BOC/OA)>0) or (frac(AOC/OA)>0) do\n begin\n n:=n+1;\n A:=180*(n-2)/n;\n OA:=180-A;\n end;\nS:=n/2*R*R*sin(2*pi/n);\nwriteln(S:20:6);\nreadln;\nend."}, {"source_code": "uses math;\nvar x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else if y=0 then\n begin\n if x<0 then alpha:=pi\n else alpha:=0;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n al:=maxlongint;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n if abs(l[i]-l[j])<=al then\n begin\n al:=abs(l[i]-l[j]);\n x1:=x[i]; y1:=y[i];\n x2:=x[j]; y2:=y[j];\n end;\n\n a:=dist(0,0,x1,y1);\n b:=dist(0,0,x2,y2);\n c:=dist(x1,y1,x2,y2);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n n:=trunc((2*pi)/(al)+1e-9);\n\n writeln(p*n:0:10);\nend."}, {"source_code": "uses math;\nconst eps=0.00000001;\n Pi=3.14;\nvar x1,x2,x3,y1,y2,y3,x4,y4,x5,y5: double;\n R, S,a,b,c, aa, bb, cc,f1,f2,f3,fi: double;\n n: integer;\n\n \nfunction dlin(xa,ya, xb,yb: double):double; \nvar res: double;\nbegin\n dlin:=sqrt(sqr(xb-xa)+sqr(yb-ya));\nend; \n\n\nfunction ugol(x,y,z: double): double;\nbegin\n ugol:=arccos((sqr(y)+sqr(z)-sqr(x))/(2*y*z));\nend;\n\nfunction radius(x,y,z: double): double;\nvar p,r: double;\nbegin\n p:=(x+y+z)/2;\n r:=x*y*z/4/sqrt(p*(p-x)*(p-y)*(p-z));\n radius:=r;\nend;\n\nfunction plotsha(r, m: double): double;\nbegin\n plotsha:=M*0.5*r*r*sin(2*Pi/M);\nend;\n\n \nbegin\n readln(x3,y3);\n readln(x1,y1);\n readln(x2,y2);\n\n a:=dlin(x2,y2, x3,y3);\n b:=dlin(x1,y1, x2,y2);\n c:=dlin(x1,y1, x3,y3);\n \n \n aa:=ugol(a, b,c);\n bb:=ugol(b, a,c);\n cc:=ugol(c, a,b);\n \n \n f1:=2*aa; f2:=2*bb; f3:=2*cc;\n \n N:=3;\n while N<=100 do\n begin\n { if (abs(sin(f1*N))0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else if y=0 then\n begin\n if x<0 then alpha:=pi\n else alpha:=0;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-10000;\n yr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)>calc(x,c2) then yl:=c1\n else yr:=c2;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n xl:=-10000;\n xr:=10000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)>search(c2) then xl:=c1\n else xr:=c2;\n end;\n\n xx:=xl;\n search(xx);\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-16;\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:10);\n halt(0);\n end;\n end;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,S+}\nuses\n SysUtils,Math;\nconst\n Pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651;\nprocedure SWAP(var a,b:integer);\nvar\n q:Integer;\nbegin\n q:=a;\n a:=b;\n b:=q;\nend;\nfunction NOD(x,y: extended): extended;\nbegin\n while (Abs(x)>0.0000001)and(Abs(y)>0.0000001) do begin\n if x>y then x:= x - floor(x / y) * y\n else y:= y - floor(y / x) * x;\n end;\n Result := x + y;\nend;\nvar\n i,n:Integer;\n r,p,a,b,c,au,bu,cu:Extended;\n x,y:array[1..3] of extended;\nbegin\n for i:=1 to 3 do read(x[i],y[i]);\n\n a:=Sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));\n b:=Sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));\n c:=Sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));\n p:=(a+b+c)/2;\n r:=a*b*c/(4*sqrt(p*(p-a)*(p-b)*(p-c)));\n\n au:=arccos((b*b+c*c-a*a)/(2*b*c));\n bu:=arccos((a*a+c*c-b*b)/(2*a*c));\n cu:=arccos((b*b+a*a-c*c)/(2*b*a));\n\n n:=Round(pi/NOD(NOD(au,bu),cu));\n write((n*r*r*sin(2*pi/n)/2):0:6);\nend."}, {"source_code": "Uses math;\nConst abc=1e-9;\nVar z1,z,r,a1,a2,b1,b2,c1,c2,x,y,l1,l,l2,s,p,h1,a,b,c,x1,x2,x3,y1,y2,y3:extended;\ni:longint;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n Readln(x1,y1,x2,y2,x3,y3);\n a:=y2-y3;\n b:=(x3-x2);\n c:=-a*x3-b*y3;\n x:=(x2+x3)/2;\n y:=(y2+y3)/2;\n a1:=b;\n b1:=-a;\n c1:=-a1*x-b1*y;\n\n a:=y3-y1;\n b:=(x1-x3);\n c:=-a*x1-b*y1;\n x:=(x1+x3)/2;\n y:=(y1+y3)/2;\n a2:=b;\n b2:=-a;\n c2:=-x*a2-y*b2;\n\n x:=(c1*b2-b1*c2)/(a2*b1-a1*b2);\n if b2<>0\n then y:=(-c2-a2*x)/b2\n else y:=(-c1-a1*x)/b1;\n r:=Sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));\n a:=Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n b:=Sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));\n c:=Sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));\n for i:=3 to 1000 do\n begin\n z:=360/i;\n z1:=arccos((r*r+r*r-a*a)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-b*b)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n z1:=arccos((r*r+r*r-c*c)/(2*r*r))*180/pi;\n if Frac(z1/z)>abc\n then Continue;\n Writeln(0.5*r*r*i*sin(360*pi/(180*i)):0:6);\n Halt(0);\n end;\nend."}, {"source_code": "VAR\n x, y, l, g:array[1..3] of extended;\n p, r, s:extended;\n n:byte;\nFunction arccos(x:extended):extended;\nBegin\n arccos:=arctan(sqrt(1-sqr(x))/x);\nEnd;\nFunction GCD(a, b:extended):extended;\nVar\n eps:extended;\nBegin\n eps:=0.001;\n while (abs(a) > eps) and (abs(b) > eps) do begin\n if (abs(a) > abs(b)) then a:=a-round(a/b)*b\n else b:=b-round(b/a)*a;\n end;\n GCD:=a+b;\nEnd;\nBEGIN\n readln(x[1], y[1]);\n readln(x[2], y[2]);\n readln(x[3], y[3]);\n l[1]:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n l[2]:=sqrt(sqr(x[2]-x[3])+sqr(y[2]-y[3]));\n l[3]:=sqrt(sqr(x[3]-x[1])+sqr(y[3]-y[1]));\n p:=(l[1]+l[2]+l[3])/2;\n r:=(l[1]*l[2]*l[3])/(4*sqrt(p*(p-l[1])*(p-l[2])*(p-l[3])));\n g[1]:=arccos((sqr(l[1])+sqr(l[2])-sqr(l[3]))/(2*l[1]*l[2]));\n g[2]:=arccos((sqr(l[2])+sqr(l[3])-sqr(l[1]))/(2*l[2]*l[3]));\n g[3]:=arccos((sqr(l[3])+sqr(l[1])-sqr(l[2]))/(2*l[3]*l[1]));\n n:=round(pi()/GCD(GCD(g[1], g[2]), g[3]));\n s:=n/2*sqr(r)*sin(2*pi()/n);\n writeln(s:0:8);\nEND.\n\n"}, {"source_code": "uses math;\nvar www,eps,x1,y1,x2,y2,p,a,b,c,pl,al,xl,xr,c1,c2,xx,yy:extended;\n x,y,l:Array[0..10]of extended;\n n,i,j,it:longint;\n ok:boolean;\n a1,b1,a2,b2:extended;\nfunction alpha(x,y:extended):extended;\nbegin\n if (x=0)and(y=0) then alpha:=0\n else\n if x=0 then\n begin\n if y>0 then alpha:=pi/2\n else alpha:=pi+pi/2;\n end\n else\n begin\n if (x>0)and(y>0) then alpha:=arctan(y/x)\n else if (x>0)and(y<0) then alpha:=arctan(y/x)+2*pi\n else if (x<0) then alpha:=arctan(y/x)+pi;\n end;\nend;\n\nfunction dist(x1,y1,x2,y2:extended):extended;\nbegin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\nend;\n\nfunction calc(xx,yy:extended):extended;\nvar i:longint;\n min,max,w:extended;\nbegin\n max:=0;\n for i:=1 to 3 do\n begin\n w:=dist(xx,yy,x[i],y[i]);\n w:=abs(w-p);\n if w>max then max:=w;\n end;\n calc:=max;\nend;\n\nfunction search(x:extended):extended;\nvar\nyl,yr,c1,c2:extended;\nit:longint;\nbegin\n yl:=-50000;\n yr:=50000;\n\n for it:=0 to 1000 do\n begin\n c1:=yl+(yr-yl)/3;\n c2:=yr-(yr-yl)/3;\n\n if calc(x,c1)<=calc(x,c2) then yr:=c2\n else yl:=c1;\n end;\n\n yy:=yl;\n\n search:=calc(x,yy);\nend;\n\n begin\n n:=3;\n for i:=1 to n do\n read(x[i],y[i]);\n\n a:=dist(x[1],y[1],x[2],y[2]);\n b:=dist(x[2],y[2],x[3],y[3]);\n c:=dist(x[1],y[1],x[3],y[3]);\n\n p:=a+b+c;\n p:=p/2;\n\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n\n p:=a*b*c/(4*p);\n\n\n xl:=-50000;\n xr:=50000;\n\n for it:=0 to 1000 do\n begin\n c1:=xl+(xr-xl)/3;\n c2:=xr-(xr-xl)/3;\n\n if search(c1)<=search(c2) then xr:=c2\n else xl:=c1;\n end;\n\n xx:=xl;\n search(xx);\n\n\n\n for i:=1 to n do\n begin\n x[i]:=x[i]-xx;\n y[i]:=y[i]-yy;\n end;\n\n for i:=1 to n do\n l[i]:=alpha(x[i],y[i]);\n\n eps:=1e-5;\n\n\n for n:=3 to 101 do\n begin\n\n ok:=true;\n\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n begin\n al:=abs(l[i]-l[j]);\n if abs(sin(n*al/2))>eps then\n begin\n ok:=false;\n break;\n end;\n end;\n al:=(2*pi)/n;\n if ok then\n begin\n a:=dist(0,0,x[1],y[1]);\n b:=a;\n c:=sqrt(a*a+b*b-2*a*b*cos(al));\n p:=a+b+c;\n p:=p/2;\n p:=sqrt(p*(p-a)*(p-b)*(p-c));\n writeln(p*n:0:6);\n halt(0);\n end;\n end;\nend.\n"}, {"source_code": "uses math;\nconst\n INF=1e9;\n eps=1e-8;\n\nvar\n x0,y0,x2,y2,x3,y3,dx,dy,d,a,a1,b1,c1,a2,b2,c2,x,y,res,x1,y1,r,ad,ax,ay,hh:extended;\n j,kol,i:longint;\n\n function dist(x1,y1,x2,y2:extended):extended;\n begin\n dist:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n end;\n\n procedure line(x1,y1,x2,y2:extended;var a,b,c:extended);\n begin\n x0:=(x1+x2)/2;\n y0:=(y1+y2)/2;\n a:=x1-x2;\n b:=y1-y2;\n c:=-a*x0-b*y0;\n end;\n\n procedure cross(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);\n begin\n d:=a1*b2-a2*b1;\n dx:=c1*b2-b1*c2;\n dy:=a1*c2-c1*a2;\n x:=-dx/d;\n y:=-dy/d;\n end;\n\nbegin\n read(x1,y1,x2,y2,x3,y3);\n line(x1,y1,x2,y2,a1,b1,c1);\n line(x2,y2,x3,y3,a2,b2,c2);\n cross(a1,b1,c1,a2,b2,c2,x,y);\n r:=dist(x,y,x1,y1);\n res:=INF;\n for i:=3 to 100 do begin\n a:=arcsin(abs(y-y1)/r);\n kol:=0;\n for j:=1 to i do begin\n ax:=x+r*cos(a);\n ay:=y+r*sin(a);\n if (abs(ax-x1)3)then continue;\n a:=arcsin(abs(y-y1)/r);\n ax:=x+r*cos(a+2*pi/i);\n ay:=y+r*sin(a+2*pi/i);\n ad:=dist(x1,y1,ax,ay);\n hh:=sqrt(r*r-ad*ad/4);\n ad:=hh*ad/2;\n ad:=ad*i;\n if (ad=-e) and (y<=e) then exit(x)\n else exit(gcd(y,x-trunc(x/y)*y));\nend;\n\nbegin\n readln(n[1,1],n[1,2]);\n readln(n[2,1],n[2,2]);\n readln(n[3,1],n[3,2]);\n a:=sqrt(sqr(n[1,1]-n[2,1])+sqr(n[1,2]-n[2,2]));\n b:=sqrt(sqr(n[1,1]-n[3,1])+sqr(n[1,2]-n[3,2]));\n c:=sqrt(sqr(n[2,1]-n[3,1])+sqr(n[2,2]-n[3,2]));\n p:=(a+b+c)/2;\n s:=sqrt(p*(p-a)*(p-b)*(p-c));\n r:=a*b*c/(4*s);\n x:=arccos((b*b+c*c-a*a)/(2*b*c))*2;\n y:=arccos((a*a+c*c-b*b)/(2*a*c))*2;\n z:=arccos((a*a+b*b-c*c)/(2*a*b))*2;\n m:=gcd(x,y);\n m:=gcd(m,z);\n s:=(r*r*sin(m)*pi/m);\n writeln(s:0:8);\nend.\n\n\n\n\n\n"}], "src_uid": "980f4094b3cfc647d6f74e840b1bfb62"} {"source_code": "program baib;\n\nconst fi='';\n fo='';\n\nvar f,g:text;\n a,c:array[0..10,0..10]of longint;\n s1,s2,t1,t2,w1,w2,b1,b2:longint;\n\nprocedure enter;\nvar i,j,u:longint;\n ch,cc:char;\nbegin\nassign(f,fi);assign(g,fo);\nreset(f);rewrite(g);\n read(f,ch,u,cc);\n s1:=ord(ch)-ord('a')+1;\n t1:=u;\n read(f,ch,u,cc);\n s2:=ord(ch)-ord('a')+1;\n t2:=u;\n read(f,ch,u,cc);\n w1:=ord(ch)-ord('a')+1;\n w2:=u;\n read(f,ch,u);\n b1:=ord(ch)-ord('a')+1;\n b2:=u;\nend;\n\nprocedure process;\nvar i,j,u,v:longint;\nbegin\nfillchar(a,sizeof(a),255);\nfillchar(c,sizeof(c),0);\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\na[w1,w2]:=-1;\nc[b1,b2]:=2;\nfor i:=-1 to 1 do\n for j:=-1 to 1 do\n if a[b1+i,b2+j]<>-1 then\n begin\n c[b1+i,b2+j]:=2;\n end;\nfor i:=-1 to 1 do\n for j:=-1 to 1 do\n c[w1+i,w2+j]:=1;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\n u:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if c[i,j]=2 then u:=1;\nif u=0 then writeln(g,'CHECKMATE')\nelse writeln(g,'OTHER');\nend;\n\nBEgin\n enter;\n process;\n close(g);\nend.\n\n", "positive_code": [{"source_code": "uses math;\nvar flag:boolean;\n a:array[-10..100,-10..100]of longint;\n x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;\n ch:char;\n procedure rec(x,y,xx,yy:longint);\n var w:longint;\n begin\n while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do\n begin\n x:=x+xx;\n y:=y+yy;\n w:=a[x,y];\n a[x,y]:=0;\n if w=2 then break;\n end;\n end;\n begin\n read(ch,y1);\n x1:=ord(ch)-96;\n read(ch,ch,y2);\n x2:=ord(ch)-96;\n read(ch,ch,y3);\n x3:=ord(ch)-96;\n read(ch,ch,y4);\n x4:=ord(ch)-96;\n\n for i:=0 to 9 do\n for j:=0 to 9 do\n a[i,j]:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=1;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n a[x3,y3]:=2;\n a[x4,y4]:=3;\n\n rec(x1,y1,1,0);\n rec(x1,y1,-1,0);\n rec(x1,y1,0,1);\n rec(x1,y1,0,-1);\n\n rec(x2,y2,1,0);\n rec(x2,y2,-1,0);\n rec(x2,y2,0,1);\n rec(x2,y2,0,-1);\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (max(abs(x3-i),abs(y3-j))=1) then a[i,j]:=0;\n\n flag:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;\n if flag then writeln('CHECKMATE')\n else writeln('OTHER');\n End."}, {"source_code": "program sdfdsv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\n\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2) then begin\nif ((i1=i3)and(i1=i)and((j1-j3)*(j-j3)<0))or((j1=j3)and(j1=j)and((i1-i3)*(i-i3)<0))or((i2=i3)and(i2=i)and((j2-j3)*(j-j3)<0))or((j2=j3)and(j1=j)and((i2-i3)*(i-i3)<0)) then begin\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1\nend\nelse f[i,j]:=1;\nend;\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\n\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2) then begin\nif ((i2=i3)and(i2=i)and((j2-j3)*(j-j3)<0))or((j2=j3)and(j1=j)and((i2-i3)*(i-i3)<0)) then begin\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend\nelse g[i,j]:=1;\nend;\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\n\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1) then begin\nif ((i1=i3)and(i1=i)and((j1-j3)*(j-j3)<0))or((j1=j3)and(j1=j)and((i1-i3)*(i-i3)<0)) then begin\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend\nelse h[i,j]:=1;\nend;\nif ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4-1,j4+1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "const\n hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);\n hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);\n\nvar\n s:string;\n x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;\n w1,was:array[1..8,1..8] of boolean;\n\nbegin\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n x2:=ord(s[4])-96;\n y2:=ord(s[5])-48;\n wx:=ord(s[7])-96;\n wy:=ord(s[8])-48;\n bx:=ord(s[10])-96;\n by:=ord(s[11])-48;\n for i:=1 to 8 do begin\n cx:=wx+hx[i];\n cy:=wy+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;\n was[cx][cy]:=true;\n end;\n\n for i:=x1+1 to 8 do begin\n if (i=wx) and (y1=wy)then break;\n w1[i][y1]:=true;\n end;\n for i:=y1-1 downto 1 do begin\n if (i=wy) and (x1=wx)then break;\n w1[x1][i]:=true;\n end;\n for i:=y1+1 to 8 do begin\n if (i=wy) and (x1=wx)then break;\n w1[x1][i]:=true;\n end;\n for i:=x1-1 downto 1 do begin\n if (i=wx) and (y1=wy)then break;\n w1[i][y1]:=true;\n end;\n\n \n for i:=x2+1 to 8 do begin\n if (i=wx) and (y2=wy)then break;\n w1[i][y2]:=true;\n end;\n for i:=y2-1 downto 1 do begin\n if (i=wy) and (x2=wx)then break;\n w1[x2][i]:=true;\n end;\n for i:=y2+1 to 8 do begin\n if (i=wy) and (x2=wx)then break;\n w1[x2][i]:=true;\n end;\n for i:=x2-1 downto 1 do begin\n if (i=wx) and (y2=wy)then break;\n w1[i][y2]:=true;\n end;\n\n \n res:=0;\n for i:=1 to 9 do begin\n cx:=bx+hx[i];\n cy:=by+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else\n if (was[cx][cy])then inc(res) else\n if (w1[cx][cy]) then inc(res) else\n if (w1[cx][cy]) then inc(res);\n end;\n if (res=9)\n then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n"}, {"source_code": "const\n hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);\n hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);\n\nvar\n s:string;\n x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;\n w1,was:array[1..8,1..8] of boolean;\n\nbegin\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n x2:=ord(s[4])-96;\n y2:=ord(s[5])-48;\n wx:=ord(s[7])-96;\n wy:=ord(s[8])-48;\n bx:=ord(s[10])-96;\n by:=ord(s[11])-48;\n for i:=1 to 8 do begin\n cx:=wx+hx[i];\n cy:=wy+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;\n was[cx][cy]:=true;\n end;\n\n for i:=x1+1 to 8 do begin\n if (i=wx) and (y1=wy)then break;\n w1[i][y1]:=true;\n end;\n for i:=y1-1 downto 1 do begin\n if (i=wy) and (x1=wx)then break;\n w1[x1][i]:=true;\n end;\n for i:=y1+1 to 8 do begin\n if (i=wy) and (x1=wx)then break;\n w1[x1][i]:=true;\n end;\n for i:=x1-1 downto 1 do begin\n if (i=wx) and (y1=wy)then break;\n w1[i][y1]:=true;\n end;\n\n \n for i:=x2+1 to 8 do begin\n if (i=wx) and (y2=wy)then break;\n w1[i][y2]:=true;\n end;\n for i:=y2-1 downto 1 do begin\n if (i=wy) and (x2=wx)then break;\n w1[x2][i]:=true;\n end;\n for i:=y2+1 to 8 do begin\n if (i=wy) and (x2=wx)then break;\n w1[x2][i]:=true;\n end;\n for i:=x2-1 downto 1 do begin\n if (i=wx) and (y2=wy)then break;\n w1[i][y2]:=true;\n end;\n\n \n res:=0;\n for i:=1 to 9 do begin\n cx:=bx+hx[i];\n cy:=by+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else\n if (was[cx][cy])then inc(res) else\n if (w1[cx][cy]) then inc(res) else\n if (w1[cx][cy]) then inc(res);\n end;\n if (res=9)\n then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n"}, {"source_code": "type Tpos=record x,y:byte; end;\nvar p:array[1..4]of Tpos;\n ax:array[1..4]of string[3];\n board:array[0..9,0..9]of shortint;\n mat:boolean;\n i,x,y,j:shortint;\nbegin\n for y:=0 to 9 do\n for x:=0 to 9 do\n if ((x=0)or(x=9)or(y=0)or(y=9)) then\n board[x,y]:=5 else board[x,y]:=0;\n\n for i:=1 to 4 do begin\n read(ax[i]);\n p[i].x:=1 + (ord(ax[i,1])-ord('a'));\n p[i].y:=1 + (ord(ax[i,2])-ord('1'));\n if (i<4) then board[p[i].x,p[i].y]:=-1;\n end;\n\n for i:=1 to 2 do begin\n y:=p[i].y;\n for x:=p[i].x downto 1 do\n if (x<>p[i].x) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n for x:=p[i].x to 8 do\n if (x<>p[i].x) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n x:=p[i].x;\n for y:=p[i].y downto 1 do\n if (y<>p[i].y) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n for y:=p[i].y to 8 do\n if (y<>p[i].y) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n end;\n\n for i:=1 to 3 do board[p[i].x,p[i].y]:=-board[p[i].x,p[i].y]-1;\n\n for y:=-1 to 1 do\n for x:=-1 to 1 do\n if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);\n\n if (board[p[4].x,p[4].y]<>0) then mat:=true else mat:=false;\n\n\n for y:=-1 to 1 do\n if mat then\n for x:=-1 to 1 do\n if ((y<>0)or(x<>0))then\n if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;\n\n if mat then write('CHECKMATE') else write('OTHER');\nend."}, {"source_code": "var \n d:array [1..8,1..8] of byte;\n i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;\n s:string;\nBEGIN\nfillchar(d,sizeof(d),0);\nreadln(s);\nn:=1;\nwhile n<=10 do\n begin\n j:=ord(s[n])-96; \n val(s[n+1],i); \n if n=1 then \n begin\n x1:=i;\n y1:=j;\n end\n else if n=4 then\n begin\n x2:=i;\n y2:=j;\n end \n else if n=7 then \n begin\n xx:=i;\n yy:=j; \n d[xx,yy]:=2; \n end\n else \n begin \n x:=i;\n y:=j;\n end; \n inc(n,3); \n end;\n\nif x1<>xx then for k:=1 to 8 do d[x1,k]:=4\n else if y1yy then for k:=1 to 8 do d[k,y1]:=4\n else if x1xx then for k:=1 to 8 do d[x2,k]:=4\n else if y2yy then for k:=1 to 8 do d[k,y2]:=4\n else if x2x2)and(y1<>y2) then \n begin\n d[x1,y1]:=1;\n d[x2,y2]:=1;\n end;\n\nif xx>1 then d[xx-1,yy]:=4;\nif xx<8 then d[xx+1,yy]:=4;\nif yy>1 then d[xx,yy-1]:=4;\nif yy<8 then d[xx,yy+1]:=4;\nif (xx>1)and(yy>1) then d[xx-1,yy-1]:=4;\nif (xx<8)and(yy<8) then d[xx+1,yy+1]:=4;\nif (yy>1)and(xx<8) then d[xx+1,yy-1]:=4;\nif (yy<8)and(xx>1) then d[xx-1,yy+1]:=4;\n\n \nn:=0;k:=0;\nif d[x,y]=4 then\n begin\n if x>1 then \n begin\n if d[x-1,y]=4 then inc(n);\n inc(k);\n end;\n if x<8 then \n begin\n if d[x+1,y]=4 then inc(n);\n inc(k);\n end;\n if y>1 then \n begin\n if d[x,y-1]=4 then inc(n);\n inc(k);\n end;\n if y<8 then \n begin\n if d[x,y+1]=4 then inc(n);\n inc(k);\n end;\n if (x>1)and(y>1) then \n begin\n if d[x-1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (x<8)and(y<8) then \n begin\n if d[x+1,y+1]=4 then inc(n);\n inc(k);\n end;\n if (y>1)and(x<8) then \n begin\n if d[x+1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (y<8)and(x>1) then \n begin\n if d[x-1,y+1]=4 then inc(n);\n inc(k);\n end;\n if n=k then writeln('CHECKMATE') else writeln('OTHER');\n end\nelse writeln('OTHER');\n\n{for i:=1 to 8 do \n begin\n for j:=1 to 8 do \n if d[i,j]=0 then write('- ') else write(d[i,j],' ');\n writeln;\n end;}\nEND."}, {"source_code": "uses math;\nVar ok:boolean;\n b:array[0..10,0..10]of longint;\n x1,x2,x3,x4,x,vx,y1,y2,y3,y4,y,vy,i,j,p,q:integer;\n s:string;\n Begin\n Readln(s);\n x1:=ord(s[1])-96;\n val(s[2],y1,p);\n x2:=ord(s[4])-96;\n val(s[5],y2,p);\n x3:=ord(s[7])-96;\n val(s[8],y3,p);\n x4:=ord(s[10])-96;\n val(s[11],y4,p);\n fillchar(b,sizeof(b),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n b[i,j]:=1;\n b[x1,y1]:=2;\n b[x2,y2]:=2;\n b[x3,y3]:=2;\n b[x4,y4]:=3;\n x:=x1;\n y:=y1;\n vx:=1;\n vy:=0;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x1;\n y:=y1;\n vx:=-1;\n vy:=0;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x1;\n y:=y1;\n vx:=0;\n vy:=1;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x1;\n y:=y1;\n vx:=0;\n vy:=-1;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x2;\n y:=y2;\n vx:=1;\n vy:=0;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x2;\n y:=y2;\n vx:=-1;\n vy:=0;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x2;\n y:=y2;\n vx:=0;\n vy:=1;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n x:=x2;\n y:=y2;\n vx:=0;\n vy:=-1;\n While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do\n begin\n x:=x+vx;\n y:=y+vy;\n q:=b[x,y];\n b[x,y]:=0;\n if q=2 then break;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (max(abs(x3-i),abs(y3-j))=1) then b[i,j]:=0;\n ok:=false;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (max(abs(x4-i),abs(y4-j))<=1)and(b[i,j]<>0) then ok:=true;\n if ok then Writeln('OTHER')\n else Writeln('CHECKMATE');\n End."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction BK(x1,y1,x2,y2:longint):boolean;\nBegin\n if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)\n then bk:=true\n else bk:=false;\nEnd;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n or bk(x,y,kor[3].x,kor[3].y)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "program CFR41_A;\nuses\n math;\n\nconst\n nfin= '';\n nfout= '';\n maxn= 30;\n vt:array[1..8,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1), (1, -1), (1, 1), (-1, -1), (-1, 1));\n\nvar\n d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;\n k1, k2, k3: char;\n fin, fout: text;\n\nfunction check(u, v: longint): boolean;\nbegin\n if ((u<>d1) and (v=c1))then begin\n if c3<>c1 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(u, d1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d1) and (v<>c1))then begin\n if d3<>d1 then begin\n check:=(true);\n exit;\n end;\n if ((c3max(v, c1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u<>d2) and (v=c2))then begin\n if c3<>c2 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(u, d2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d2) and (v<>c2))then begin\n if d3<>d2 then begin\n check:=true;\n exit;\n end;\n if ((c3max(v, c2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if (abs(u-d3)<=1) and (abs(v-c3)<=1) then begin\n check:=true;\n exit;\n end;\n check:=false;\nend;\n\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n read(fin, k1, k2);\n d1:=ord(k1) - ord('a') + 1;\n c1:=ord(k2) - ord('0');\n\n read(fin, k3, k1, k2);\n d2:=ord(k1) - ord('a') + 1;\n c2:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d3:=ord(k1) - ord('a') + 1;\n c3:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d4:=ord(k1) - ord('a') + 1;\n c4:=ord(k2) - ord('0');\n\n if not check(d4, c4) then begin\n writeln(fout, 'OTHER');\n close(fout);\n close(fin);\n halt;\n end;\n\n for i:=1 to 8 do begin\n u:=d4+vt[i, 1];\n v:=c4+vt[i, 2];\n if (0'.'\n then\n begin\n if b[i,j]='L'\n then\n begin\n x:=i; y:=j;\n while (b[x,y]<>'#') and (b[x,y]<>'W') do\n begin\n if b[x,y]='B' then exit;\n inc(x);\n end;\n x:=i; y:=j;\n while (b[x,y]<>'#') and (b[x,y]<>'W') do\n begin\n if b[x,y]='B' then exit;\n dec(x);\n end;\n x:=i; y:=j;\n while (b[x,y]<>'#') and (b[x,y]<>'W') do\n begin\n if b[x,y]='B' then exit;\n inc(y);\n end;\n x:=i; y:=j;\n while (b[x,y]<>'#') and (b[x,y]<>'W') do\n begin\n if b[x,y]='B' then exit;\n dec(y);\n end;\n end;\n if b[i,j]='W'\n then\n begin\n if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')\n then\n begin\n exit;\n end;\n end;\n end;\n rez:=false;\n end;\n\n\nprocedure untilprogram;\nvar i,j:longint;\n begin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:='.';\n for i:=0 to 9 do\n begin\n a[i,0]:='#';\n a[i,9]:='#';\n a[0,i]:='#';\n a[9,i]:='#';\n end;\n end;\n\n\nbegin\n\n untilprogram;\n readln(s);\n x:=ord(s[1])-96;\n y:=9-(ord(s[2])-48);\n a[x,y]:='L';\n x:=ord(s[4])-96;\n y:=9-(ord(s[5])-48);\n a[x,y]:='L';\n x:=ord(s[7])-96;\n y:=9-(ord(s[8])-48);\n a[x,y]:='W';\n x:=ord(s[10])-96;\n y:=9-(ord(s[11])-48);\n a[x,y]:='B';\n b:=a;\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end\n else\n begin\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if not((i=0) and (j=0)) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)\n then\n begin\n b:=a;\n b[x,y]:='.'; b[x+i,y+j]:='B';\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end;\n end;\n end;\n writeln('CHECKMATE');\n\nend."}, {"source_code": "Program z42b;\ntype byte=integer;\nconst xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);\n\tyy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);\nvar a,c:array[0..9,0..9]of byte;\n\tb:array[1..2,1..4]of byte;\n\tx,y,i,x1,y1,j:byte;\n cc:char;\nbegin\n\tj:=1;\n\tfor i:=2 to 3 do\n begin\t\n \tread(cc);\n x:=ord(cc)-ord('a')+1;\n read(y);\n c[y,x]:=i;\n b[1,j]:=x;\n b[2,j]:=y;\n inc(j);\n read(cc);\n read(cc);\n x1:=ord(cc)-ord('a')+1;\n read(y1);\n c[y1,x1]:=2;\n read(cc);\n b[1,j]:=x1;\n b[2,j]:=y1;\n inc(j);\n end;\n for i:=0 to 9 do\n begin\n \ta[i,0]:=1;\n a[i,9]:=1;\n a[0,i]:=1;\n a[9,i]:=1;\n end;\n for i:=1 to 2 do\n begin\n \tj:=b[1,i]+1;\n while (j<=8)and(c[b[2,i],j]<3) do\n begin\n a[b[2,i],j]:=1;\n inc(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[1,i]-1;\n while (j>0)and(c[b[2,i],j]<3) do\n begin\n \ta[b[2,i],j]:=1;\n dec(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[2,i]+1;\n while (j<=8)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n inc(j);\n end;\n a[j,b[1,i]]:=1;\n j:=b[2,i]-1;\n while (j>0)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n dec(j);\n end;\n a[j,b[1,i]]:=1;\n end;\n for i:=1 to 8 do\n \ta[y+yy[i],x+xx[i]]:=1;\n if a[y1,x1]=1\n then\n begin\n \tfor i:=1 to 8 do\n \t \tif a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;\n write('CHECKMATE');\n end\n else write('OTHER');\nend."}, {"source_code": "program shablon;\n{$O+ R- Q-}\nuses\n SysUtils;\ntype Tpoint=record\n x,y:longint;\n end;\n\nconst dx:array[0..8] of longint=(0,-1,0,+1,+1,+1,0,-1,-1);\n dy:array[0..8] of longint=(0,-1,-1,-1,0,+1,+1,+1,0);\n\nvar b:array[0..9,0..9] of boolean;\n i,x,y:longint;\n a:array[1..4] of tpoint;\n c:char;\n flag:boolean;\nprocedure postout {inline};\nbegin\n\n close(input);\n close(output);\n halt(0);\nend;\n\nprocedure preinit {inline};\nbegin\n assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\n\nend;\n\nfunction check(i,x,y:longint):boolean;\nvar j:longint;\nbegin\n for j:=1 to 3 do\n if i<>j\n then\n begin\n if (x=a[j].x)and(y=a[j].y)\n then\n begin\n result:=false;\n exit;\n end;\n end;\n result:=true;\nend;\n\nbegin\n// preinit;\n fillchar(b,sizeof(b),0);\n for i:=0 to 9 do\n begin\n b[i,0]:=true;\n b[i,9]:=true;\n b[0,i]:=true;\n b[9,i]:=true;\n end;\n for i:=1 to 4 do\n begin\n read(c);\n a[i].x:=ord(c)-ord('a')+1;\n read(c);\n a[i].y:=strtoint(c);\n read(c);\n end;\n for i:=1 to 2 do begin\n x:=a[i].x;\n y:=a[i].y;\n flag:=b[x,y];\n dec(y);\n while (y>0)and(check(i,x,y)) do\n begin\n b[x,y]:=true;\n dec(y);\n end;\n if (y>0)and not (check(i,x,y))\n then\n b[x,y]:=true;\n x:=a[i].x;\n y:=a[i].y;\n inc(y);\n while (y<9)and(check(i,x,y)) do\n begin\n b[x,y]:=true;\n inc(y);\n end;\n if (y<9)and not (check(i,x,y))\n then\n b[x,y]:=true;\n x:=a[i].x;\n y:=a[i].y;\n dec(x);\n while (x>0)and(check(i,x,y)) do\n begin\n b[x,y]:=true;\n dec(x);\n end;\n if (x>0)and not (check(i,x,y))\n then\n b[x,y]:=true;\n x:=a[i].x;\n y:=a[i].y;\n inc(x);\n while (x<9)and(check(i,x,y)) do\n begin\n b[x,y]:=true;\n inc(x);\n end;\n if (x<9)and not (check(i,x,y))\n then\n b[x,y]:=true;\n b[a[i].x,a[i].y]:=flag;\n end;\n for i:=1 to 8 do\n begin\n b[a[3].x+dx[i],a[3].y+dy[i]]:=true;\n end;\n for i:=0 to 8 do\n begin\n if not (b[a[4].x+dx[i],a[4].y+dy[i]])\n then\n begin\n writeln('OTHER');\n halt(0);\n end;\n end;\n writeln('CHECKMATE');\n// postout;\nend.\n\n"}, {"source_code": "program b41;\ntype figure=record\n x,y:byte;\n end;\nvar p:array [0..9,0..9] of byte;\n l1,l2,k1,k2:figure;\n l:string;\n r:boolean;\n I,j:integer;\nprocedure print;\n var m,n:integer;\n begin\n for n:=9 downto 0 do begin\n for m:=0 to 9 do write(p[m,n]:2);\n writeln;\n end;\n end;\nbegin\n readln(l);\n l1.x:=ord(l[1])-96;\n l1.y:=ord(l[2])-48;\n l2.x:=ord(l[4])-96;\n l2.y:=ord(l[5])-48;\n k1.x:=ord(l[7])-96;\n k1.y:=ord(l[8])-48;\n k2.x:=ord(l[10])-96;\n k2.y:=ord(l[11])-48;\n for i:=0 to 9 do begin\n p[0,i]:=1;\n p[i,0]:=1;\n p[9,i]:=1;\n p[i,9]:=1;\n end;\n for i:=l1.x+1 to 8 do if (k1.x=i)and(k1.y=l1.y) then break else p[i,l1.y]:=1;\n for i:=l1.x-1 downto 1 do if (k1.x=i)and(k1.y=l1.y) then break else p[i,l1.y]:=1;\n for i:=l1.y+1 to 8 do if (k1.x=l1.x)and(k1.y=i) then break else p[l1.x,i]:=1;\n for i:=l1.y-1 downto 1 do if (k1.x=l1.x)and(k1.y=i) then break else p[l1.x,i]:=1;\n\n for i:=l2.x+1 to 8 do if (k1.x=i)and(k1.y=l2.y) then break else p[i,l2.y]:=1;\n for i:=l2.x-1 downto 1 do if (k1.x=i)and(k1.y=l2.y) then break else p[i,l2.y]:=1;\n for i:=l2.y+1 to 8 do if (k1.x=l2.x)and(k1.y=i) then break else p[l2.x,i]:=1;\n for i:=l2.y-1 downto 1 do if (k1.x=l2.x)and(k1.y=i) then break else p[l2.x,i]:=1;\n \n for i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n p[i,j]:=1;\n for i:=k2.x-1 to k2.x+1 do\n for j:=k2.y-1 to k2.y+1 do\n if p[i,j]=0 then r:=true;\n \n if r=true then writeln ('OTHER') else writeln ('CHECKMATE');\nend."}, {"source_code": "var a,b:array[0..9,0..9]of byte;\n n:array[1..2,1..4]of byte;\n i,x,y,j,k:longint;\n ch:char;\n by:byte;\n s:string;\nbegin\n fillchar(a,sizeof(a),0);\n fillchar(b,sizeof(b),0);\n for i:=0 to 9 do begin\n a[0,i]:=1; a[i,0]:=1;\n a[9,i]:=1; a[i,9]:=1;\n end;\n for i:=1 to 3 do begin\n read(ch);read(by);\n n[1,i]:=ord(ch)-ord('a')+1;\n n[2,i]:=by;\n read(ch);\n if i<3 then b[n[1,i],n[2,i]]:=1 else b[n[1,i],n[2,i]]:=2;\n end;\n x:=n[1,3]; y:=n[2,3];\n for j:=x-1 to x+1 do\n for k:=y-1 to y+1 do\n inc(a[j,k]);\n\n for i:=1 to 2 do begin\n x:=n[1,i]; y:=n[2,i];\n j:=x; k:=y;\n repeat\n inc(a[j+1,k]);\n j:=j+1;\n until (j=9)or(b[j,k]>0);\n j:=x;\n repeat\n inc(a[j-1,k]);\n j:=j-1;\n until (j=0)or(b[j,k]>0);\n j:=x;\n repeat\n inc(a[j,k+1]);\n k:=k+1;\n until (k=9)or(b[j,k]>0);\n k:=y;\n repeat\n inc(a[j,k-1]);\n k:=k-1;\n until (k=0)or(b[j,k]>0);\n end;\n\n read(ch);read(by);\n x:=ord(ch)-ord('a')+1;\n y:=by;\n s:='CHECKMATE';\n for i:=x-1 to x+1 do\n for j:=y-1 to y+1 do begin\n if (a[i,j]=0) then s:='OTHER';\n end;\n writeln(s);\n\nend."}, {"source_code": "program Unit1;\n{$APPTYPE CONSOLE}\nvar s:string;\n z,i,j:integer;\n a,b:array[1..4]of integer;\n q:array[0..9,0..9]of integer;\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(s);\n a[1]:=ord(s[1])-ord('a')+1;\n b[1]:=ord(s[2])-ord('0');\n a[2]:=ord(s[4])-ord('a')+1;\n b[2]:=ord(s[5])-ord('0');\n a[3]:=ord(s[7])-ord('a')+1;\n b[3]:=ord(s[8])-ord('0');\n a[4]:=ord(s[10])-ord('a')+1;\n b[4]:=ord(s[11])-ord('0');\n for i:=0 to 9 do begin\n q[i,0]:=1;\n q[i,9]:=1;\n q[0,i]:=1;\n q[9,i]:=1;\n end;\n for z:=1 to 2 do begin\n for i:=a[z] downto 1 do begin\n if (i=a[z])then\n continue;\n q[i,b[z]]:=1;\n if (b[z]=b[3-z])and(i=a[3-z])then\n break;\n if (b[z]=b[3])and(i=a[3])then\n break;\n end;\n for i:=a[z] to 8 do begin\n if (i=a[z])then\n continue;\n q[i,b[z]]:=1;\n if (b[z]=b[3-z])and(i=a[3-z])then\n break;\n if (b[z]=b[3])and(i=a[3])then\n break;\n end;\n for i:=b[z] downto 1 do begin\n if (i=b[z])then\n continue;\n q[a[z],i]:=1;\n if (a[z]=a[3-z])and(i=b[3-z])then\n break;\n if (a[z]=a[3])and(i=b[3])then\n break;\n end;\n for i:=b[z] to 8 do begin\n if (i=b[z])then\n continue;\n q[a[z],i]:=1;\n if (a[z]=a[3-z])and(i=b[3-z])then\n break;\n if (a[z]=a[3])and(i=b[3])then\n break;\n end;\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do begin\n if (i=0)and(j=0)then continue;\n q[a[3]+i,b[3]+j]:=1;\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if q[a[4]+i,b[4]+j]=0 then begin\n writeln('OTHER');\n halt(0);\n end;\n writeln('CHECKMATE');\nend.\n\n"}, {"source_code": "{$apptype console}\n\ntype Tpos = record x, y : integer; end;\n\nprocedure readpos( var p : TPos );\nvar ch :char;\nbegin\n read(ch );\n while not (ch in ['a'..'h']) do read( ch );\n p.y := ord(ch) - ord('a' ) + 1;\n read(ch);\n p.x := ord(ch) - ord('0');\nend;\n\nvar l1,l2, wk : TPos;\n\nfunction inner( x,a,b : integer ) : boolean;\nvar t : integer;\nbegin\n if a > b then begin t := a; a:=b; b := t; end;\n result := (x>a) and (xwk.x) or( yy<>wk.y) then begin\n if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin\n result := true;\n exit;\n end;\n end;\n{ writeln( xx, ' ',yy );}\nend;\n\nconst v : array [1..8, 1..2] of integer =\n((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));\nvar bk : TPos;\n i, xx,yy : integer;\nbegin\n{ reset( input, 'in.txt' );}\n{}\n ReadPos( l1 );\n ReadPos( l2 );\n ReadPos( wk );\n ReadPos( bk );\n{}\n if not beaten( bk.x, bk.y ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n for i := 1 to 9 do begin\n xx := bk.x + v[i,1];\n yy := bk.y + v[i,2];\n if (xx>=1) and (xx<=8) and ( yy>=1) and (yy<=8) then begin\n if not beaten( xx, yy ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n end; \n end;\n writeln( 'CHECKMATE');\nend.\n"}, {"source_code": " {uses crt;}\n const nn=50;\n type mas=array [0..nn] of longint;\n var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;\n l1,l2,wk,bk,nk:mas;\n s:real;\n a,b,pr:mas;\n ll1,ll2,wwk,bbk,ll3:char;\n boypol,boy:boolean;\n\n function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l1[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-j)<0)\n then begin bb1:=false; {write('aaa');} end;\n end;\n{ writeln('bb1',bb1);}\n\n bb2:=false;\n if l1[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-i)<0)\n then begin bb2:=false; {write('bbb');} end;\n end;\n\n{ writeln('bb2',bb2); }\n\nboyl1:=bb1 or bb2; if (i=l1[1])and(j=l1[2]) then boyl1:=false;\n\nend;\n\n function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l2[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-j)<0) then bb1:=false; end;\n{ writeln('rrr',bb1); }\n\n bb2:=false;\n if l2[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-i)<0) then bb2:=false; end;\n\n{ writeln('www',bb2); }\n\nboyl2:=bb1 or bb2;\n\nif (i=l2[1])and(j=l2[2]) then boyl2:=false;\n\nend;\n\n\n function boyk(i,j:longint):boolean; var bb1,bb2:boolean;\n begin\n bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1) then bb1:=true;\n boyk:=bb1;\n end;\n\n\n\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'digitsum.out'); rewrite (output); }\n read(ll1);read(ll2);read(ll3);\n l1[1]:=ord(ll1)-96;\n l1[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n l2[1]:=ord(ll1)-96;\n l2[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n wk[1]:=ord(ll1)-96;\n wk[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n bk[1]:=ord(ll1)-96;\n bk[2]:=ord(ll2)-48;\n\n { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');\n }\n boy:=true;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then\n begin boypol:=false;\n nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];\n if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1) then boypol:=true;\n if not boypol then boy:=false;\n\n\n\n\n end;\n\n { writeln;\n for i:=1 to 8 do\n begin for j:=1 to 8 do if boyl1(i,j)\n then write('+') else write('-');writeln; end;\n }\n { writeln(boyl1(1,4)); }\n\n if boy then write('CHECKMATE') else write('OTHER');\n\n\n\n\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\n\nuses\n SysUtils;\nfunction sr(a,b,c:byte): boolean ;\nvar d:byte;\nbegin\n if b> c then begin d:=c; c:=b; b:=d;end;\n if (b8)or (i>8) or (i<1) then\n inc(d)\n else\n if ((i=l1b) and (k<>l1k)and not(sr(kbk,k,l1k)and (kbb=i))) or\n ((i<>l1b) and (k=l1k) and not(sr(kbb,i,l1b)and (kbk=k)))or\n ((i=l2b) and (k<>l2k) and not(sr(kbk,k,l2k)and (kbb=i))) or\n ((i<>l2b) and (k=l2k) and not (sr(kbb,i,l2b)and (kbk=k)))or\n ((abs(kbb-i)<=1) and (abs(kbk-k)<=1)) then\n inc(d) ;\nif d=9 then\n writeln ('CHECKMATE')\nelse\n writeln ('OTHER');\n\n// readln;\nend.\n\n"}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nvar map : array [0..9, 0..9] of boolean;\n c : array [1..4, 1..2] of integer;\n ch : char;\n i, x, y, j : integer;\n ans : boolean;\n\nbegin\n for i := 1 to 4 do\n begin\n read(ch);\n c[i, 1] := ord(ch) - 96;\n read(ch);\n c[i, 2] := ord(ch) - 48;\n read(ch);\n end;\n\n for i := 0 to 9 do\n for j := 0 to 9 do\n map[i, j] := false;\n\n for i := 0 to 9 do\n begin\n map[i, 0] := true;\n map[i, 9] := true;\n map[0, i] := true;\n map[9, i] := true;\n end;\n\n x := c[1, 1];\n y := c[1, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n //-------------------------------\n\n x := c[2, 1];\n y := c[2, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n map[c[3, 2], c[3, 1]] := true;\n x := c[3, 1];\n y := c[3, 2];\n map[y + 1, x] := true;\n map[y - 1, x] := true;\n map[y, x + 1] := true;\n map[y, x - 1] := true;\n map[y + 1, x + 1] := true;\n map[y + 1, x - 1] := true;\n map[y - 1, x + 1] := true;\n map[y - 1, x - 1] := true;\n\n\n x := c[4, 1];\n y := c[4, 2];\n\n if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) or (not(map[y + 1, x + 1])) or (not(map[y + 1, x - 1])) or (not(map[y - 1, x + 1])) or (not(map[y - 1, x - 1])) then writeln('OTHER')\n else writeln('CHECKMATE');\n\n readln;\n readln;\nend.\n\n\n"}, {"source_code": "program myw;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n type Point = record\n x : longint;\n y : longint;\n end; \n\nvar i,j : longint; s : char;\n a,b,c,d : point;\n mas : array[-10..20,-10..20] of longint;\nbegin\n read(s);\n a.x:=ord(s)-ord('a')+1;\n read(s);\n a.y:=ord(s)-ord('0');\n read(s);\n read(s);\n b.x:=ord(s)-ord('a')+1;\n read(s);\n b.y:=ord(s)-ord('0');\n read(s);\n read(s);\n c.x:=ord(s)-ord('a')+1;\n read(s);\n c.y:=ord(s)-ord('0');\n read(s);\n read(s);\n d.x:=ord(s)-ord('a')+1;\n read(s);\n d.y:=ord(s)-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n mas[i,j]:=0;\n\n for i:=a.x to 8 do\n if (i<>c.x) or (a.y<>c.y) then\n inc(mas[i,a.y]) else break;\n for i:=a.x downto -8 do\n if (i<>c.x) or (a.y<>c.y) then\n inc(mas[i,a.y]) else break;\n for i:=a.y to 8 do\n if (a.x<>c.x) or (i<>c.y) then\n inc(mas[a.x,i]) else break;\n for i:=a.y downto -8 do\n if (a.x<>c.x) or (i<>c.y) then\n inc(mas[a.x,i]) else break;\n\n dec(mas[a.x,a.y],4);\n \n\n\n\n for i:=b.x to 8 do\n if (i<>c.x) or (b.y<>c.y) then\n inc(mas[i,b.y]) else break;\n for i:=b.x downto -8 do\n if (i<>c.x) or (b.y<>c.y) then\n inc(mas[i,b.y]) else break;\n for i:=b.y to 8 do\n if (b.x<>c.x) or (i<>c.y) then\n inc(mas[b.x,i]) else break;\n for i:=b.y downto -8 do\n if (b.x<>c.x) or (i<>c.y) then\n inc(mas[b.x,i]) else break;\n\n dec(mas[b.x,b.y],4);\n\n {\n for i:=1 to 8 do\n begin\n writeln;\n for j:=1 to 8 do\n write(mas[i,j]);\n end;\n\n\n\n readln(i);\n }\n\n\n // dec(mas[a.x,a.y],2);\n // dec(mas[b.x,b.y],2);\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n inc(mas[c.x+i,c.y+j]);\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)\n and (mas[d.x+i,d.y+j]=0) then begin writeln('OTHER'); exit; end;\n end;\n\n writeln('CHECKMATE');\n\n\nend.\n"}, {"source_code": "type c=record\n x,y:byte;\n end;\nvar j,i,k,a2,b2,c2,d2,a1,b1,c1,d1,a3,a4,b3,b4,c3,c4,d3,d4:byte;\n s,l:string;\n m:array[0..9,0..9] of boolean;\n l1,l2,k1,k2:c;\nbegin\nreadln(l);\nfor i:=0 to 9 do\n for j:=0 to 9 do\n m[i,j]:=true;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n m[i,j]:=false;\ns:='abcdefgh';\nl1.x:=pos(l[1],s);\nl1.y:=ord(l[2])-48;\nl2.x:=pos(l[4],s);\nl2.y:=ord(l[5])-48;\nk1.x:=pos(l[7],s);\nk1.y:=ord(l[8])-48;\nk2.x:=pos(l[10],s);\nk2.y:=ord(l[11])-48;\na1:=1;b1:=l1.y-1;c1:=l1.y+1;d1:=9;\na2:=1;b2:=l1.x-1;c2:=l1.x+1;d2:=9;\na4:=1;b4:=l2.y-1;c4:=l2.y+1;d4:=9;\na3:=1;b3:=l2.x-1;c3:=l2.x+1;d3:=9;\nif l1.x=k1.x then begin\n if l1.y>k1.y then begin\n a1:=k1.y+1; b1:=l1.y-1;c1:=l1.y+1;d1:=9;\n end\n else begin\n a1:=1;b1:=l1.y-1;c1:=l1.y+1;d2:=k1.y-1;\nend;\nend;\nif l1.y=k1.y then begin\n if l1.x>k1.x then begin\n a2:=k1.x+1; b2:=l1.x-1;c2:=l1.x+1;d2:=9;\n end\n else begin\n a2:=1;b2:=l1.x-1;c2:=l1.x+1;d2:=k1.x-1;\n end;\nend;\nif l2.x=k1.x then begin\n if l2.y>k1.y then begin\n a4:=k1.y+1; b4:=l2.y-1;c4:=l2.y+1;d4:=9;\n end\n else begin\n a4:=1;b4:=l2.y-1;c4:=l2.y+1;d4:=k1.y-1;\n end;\nend;\nif l2.y=k1.y then begin\n if l2.x>k1.x then begin\n a3:=k1.x+1; b3:=l2.x-1;c3:=l2.x+1;d3:=9;\n end\n else begin\n a3:=1;b3:=l2.x-1;c3:=l2.x+1;d3:=k1.x-1;\n end\nend;\nfor i:=a2 to b2 do\n m[i,l1.y]:=true;\nfor i:=c2 to d2 do\n m[i,l1.y]:=true;\nfor i:=a1 to b1 do\n m[l1.x,i]:=true;\nfor i:=c1 to d1 do\n m[l1.x,i]:=true;\nfor i:=a3 to b3 do\n m[i,l2.y]:=true;\nfor i:=c3 to d3 do\n m[i,l2.y]:=true;\nfor i:=a4 to b4 do\n m[l2.x,i]:=true;\nfor i:=c4 to d4 do\n m[l2.x,i]:=true;\nfor i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n m[i,j]:=true;\nif (m[k2.x+1,k2.y+1]=true) and (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then\n s:='CHECKMATE'\n else s:='OTHER';\nwriteln(s);\nend.\n"}, {"source_code": "program shablon;\n\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\ntype\n pt = record\n x,y:integer;\n end;\nvar\n l,l1,k,k1:pt;\n c:char;\nfunction getc:pt;\nvar\n c:char;\nbegin\n read(c);\n result.x := ord(c) - ord('a') + 1;\n read(c);\n result.y := ord(c) - ord('0');\nend;\nfunction check(k1:pt):boolean;\nvar\n i,j:integer;\nbegin\n result := true;\n if (abs(k.x - k1.x) <= 1) and (abs(k.y - k1.y) <= 1) then\n exit;\n i := k1.x;\n j := i;\n while true do\n begin\n if (l.x = i) and (l.y = k1.y) and (i <> k1.x) then\n exit;\n if (l.x = j) and (l.y = k1.y) and (j <> k1.x) then\n exit;\n if (l1.x = i) and (l1.y = k1.y) and (i <> k1.x) then\n exit;\n if (l1.x = j) and (l1.y = k1.y) and (j <> k1.x) then\n exit;\n\n if ((i = 8) and ( j = 1)) or ( ((i = k.x) and (k.y = k1.y) ) and ((j = k.x) and (k.y = k1.y))) or ( ((i = k.x) and (k.y = k1.y) ) and (j = 1)) or ( ((i = 8) ) and ((j = k.x) and (k.y = k1.y))) then\n break;\n if (i < 8) and (not ((i = k.x) and (k.y = k1.y))) then\n inc(i);\n if (j > 1) and (not ((j = k.x) and (k.y = k1.y)))then\n dec(j);\n end;\n i := k1.y;\n j := i;\n while true do\n begin\n if (l.y = i) and (l.x = k1.x) and (i <> k1.y) then\n exit;\n if (l.y = j) and (l.x = k1.x) and (j <> k1.y) then\n exit;\n if (l1.y = i) and (l1.x = k1.x) and (i <> k1.y) then\n exit;\n if (l1.y = j) and (l1.x = k1.x) and (j <> k1.y) then\n exit;\n if ((i = 8) and ( j = 1)) or (((i = k.y) and (k.x = k1.x) ) and ((j = k.y) and (k.x = k1.x))) then\n break;\n if (((i = k.y) and (k.x = k1.x) ) and ((j = 1))) then\n break;\n if (i= 8 ) and ((j = k.y) and (k.x = k1.x)) then\n break;\n if (i < 8) and (not ((i = k.y) and (k.x = k1.x))) then\n inc(i);\n if (j > 1) and (not ((j = k.y) and (k.x = k1.x)))then\n dec(j);\n end;\n result := false;\nend;\nfunction pos:boolean;\nvar\n i,j:integer;\n p:pt;\nbegin\n result := true;\n for i := -1 to 1 do\n for j := -1 to 1 do\n begin\n if (i =0) and (j = 0) then\n continue;\n if (k1.x + i < 1) or (k1.x + i > 8) or (k1.y + j < 1) or (k1.y + j > 8) then\n continue;\n p.x := k1.x + i;\n p.y := k1.y + j;\n if not (check(p)) then\n exit;\n end;\n result := false;\nend;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n l := getc;\n read(c);\n l1 := getc;\n read(c);\n k := getc;\n read(c);\n k1 := getc;\n\n if check(k1) then\n begin\n if pos then\n writeln('OTHER')\n else\n writeln('CHECKMATE');\n end\n else\n writeln('OTHER');\n// close(input);\n// close(output);\nend.\n"}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\ntype\n pos=record x,y:byte; end;\nconst\n king:array[1..8,1..2] of longint=((1,1), (1,0), (1,-1), (0,1), (0,-1), (-1,1), (-1,0), (-1,-1));\nvar\n l1,l2,bk,wk:pos;\n cur:pos;\n i,j:longint;\n bin,c1,c2,c3,c4:char;\n a:array[-2..10,-2..10] of byte;\n free:boolean;\nfunction Num(c:char):byte;\nbegin\n Num:=ord(c)-ord('a')+1;\nend;\n\nbegin\n //assign(Input,'in.txt'); assign(Output,'out.txt');\n read(c1,l1.y,bin,c2,l2.y,bin,c3,wk.y,bin,c4,bk.y);\n l1.x:=Num(c1);\n l2.x:=Num(c2);\n wk.x:=Num(c3);\n bk.x:=Num(c4);\n for i:=-2 to 10 do\n for j:=-2 to 10 do\n a[i][j]:=0;\n a[l1.x][l1.y]:=0;\n a[l2.x][l2.y]:=0;\n a[wk.x][wk.y]:=1;\n a[bk.x][bk.y]:=0;\n for i:=1 to 8 do\n inc(a[wk.x+king[i][1]][wk.y+king[i][2]],2);\n\n //////////////////////l1\n //up\n cur.x:=l1.x;\n cur.y:=l1.y+1;\n while (cur.y<=8) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n inc(cur.y);\n end;\n if (l2.x=cur.x) and (l2.y=cur.y) then begin\n inc(a[l2.x][l2.y]);\n end;\n //down\n cur.x:=l1.x;\n cur.y:=l1.y-1;\n while (cur.y>=1) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n dec(cur.y);\n end;\n if (l2.x=cur.x) and (l2.y=cur.y) then begin\n inc(a[l2.x][l2.y]);\n end;\n //left\n cur.x:=l1.x-1;\n cur.y:=l1.y;\n while (cur.x>=1) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n dec(cur.x);\n end;\n if (l2.x=cur.x) and (l2.y=cur.y) then begin\n inc(a[l2.x][l2.y]);\n end;\n //right\n cur.x:=l1.x+1;\n cur.y:=l1.y;\n while (cur.x<=8) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n inc(cur.x);\n end;\n if (l2.x=cur.x) and (l2.y=cur.y) then begin\n inc(a[l2.x][l2.y]);\n end;\n\n //////////////////////l2\n //up\n cur.x:=l2.x;\n cur.y:=l2.y+1;\n while (cur.y<=8) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n inc(cur.y);\n end;\n if (l1.x=cur.x) and (l1.y=cur.y) then begin\n inc(a[l1.x][l1.y]);\n end;\n //down\n cur.x:=l2.x;\n cur.y:=l2.y-1;\n while (cur.y>=1) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n dec(cur.y);\n end;\n if (l1.x=cur.x) and (l1.y=cur.y) then begin\n inc(a[l1.x][l1.y]);\n end;\n //left\n cur.x:=l2.x-1;\n cur.y:=l2.y;\n while (cur.x>=1) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n dec(cur.x);\n end;\n if (l1.x=cur.x) and (l1.y=cur.y) then begin\n inc(a[l1.x][l1.y]);\n end;\n //right\n cur.x:=l2.x+1;\n cur.y:=l2.y;\n while (cur.x<=8) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin\n inc(a[cur.x][cur.y]);\n inc(cur.x);\n end;\n if (l1.x=cur.x) and (l1.y=cur.y) then begin\n inc(a[l1.x][l1.y]);\n end;\n\n if a[bk.x,bk.y]=0 then begin\n write('OTHER');\n halt;\n end;\n\n for i:=-2 to 10 do\n for j:=-2 to 10 do\n if (i<1) or (i>8) or (j<1) or (j>8) then\n a[i][j]:=239;\n\n\n {for j:=8 downto 1 do begin\n for i:=1 to 8 do\n write(a[i][j],' ');\n writeln;\n end;\n }\n\n free:=false;\n for i:=1 to 8 do\n if a[bk.x+king[i][1]][bk.y+king[i][2]]<1 then\n free:=true;\n if free then begin\n writeln('OTHER');\n halt;\n end;\n free:=true;\n for i:=1 to 8 do\n if a[bk.x+king[i][1]][bk.y+king[i][2]]>1 then\n free:=false;\n if not(free) then begin\n write('CHECKMATE');\n halt;\n end;\n\n free:=false;\n for i:=1 to 8 do begin\n cur.x:=bk.x+king[i][1]; cur.y:=bk.y+king[i][2];\n if (((cur.x=l1.x) and (cur.y=l1.y)) and (a[l1.x][l1.y]=1)) or (((cur.x=l2.x) and (cur.y=l2.y)) and (a[l2.x][l2.y]=1)) then\n free:=true;\n end;\n\n if free then\n write('OTHER')\n else\n write('CHECKMATE');\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst ch:array['a'..'h'] of byte=(1,2,3,4,5,6,7,8);\n Var a:array[0..9,0..9] of byte;\n i1,j1,i2,j2,i3,j3,ip,jp,i,j:Byte;\n f:boolean;\n st:string;\nbegin\nfor i:=0 to 9 do begin a[i,0]:=2;a[i,9]:=2; a[0,i]:=2;a[9,i]:=2 end;\nReadln(st);\ni1:=9-StrToInt(st[2]);\ni2:=9-StrToInt(st[5]);\ni3:=9-StrToInt(st[8]);\nip:=9-StrToInt(st[11]);\n{j1:=ord(st[1])-ord('a')+1;\nj2:=ord(st[4])-ord('a')+1;\nj3:=ord(st[7])-ord('a')+1;\njp:=ord(st[10])-ord('a')+1;}\nj1:=ch[st[1]];\nj2:=ch[st[4]];\nj3:=ch[st[7]];\njp:=ch[st[10]];\n\n for i:=i3-1 to i3+1 do\n for j:=j3-1 to j3+1 do inc(a[i,j]);\n a[i3,j3]:=2;\n\n i:=i1+1; j:=j1; while (a[i,j]<2) do begin inc(a[i,j]);i:=i+1 end;\n i:=i1-1; j:=j1; while (a[i,j]<2) do begin inc(a[i,j]);i:=i-1 end;\n i:=i1; j:=j1+1; while (a[i,j]<2) do begin inc(a[i,j]);j:=j+1 end;\n i:=i1; j:=j1-1; while (a[i,j]<2) do begin inc(a[i,j]);j:=j-1 end;\n\n\n i:=i2+1; j:=j2; while (a[i,j]<2) do begin inc(a[i,j]);i:=i+1 end;\n i:=i2-1; j:=j2; while (a[i,j]<2) do begin inc(a[i,j]);i:=i-1 end;\n i:=i2; j:=j2+1; while (a[i,j]<2) do begin inc(a[i,j]);j:=j+1 end;\n i:=i2; j:=j2-1; while (a[i,j]<2) do begin inc(a[i,j]);j:=j-1 end;\n\n\nf:=true;\n\n for i:=ip-1 to ip+1 do\n for j:=jp-1 to jp+1 do\n if a[i,j]=0 then f:=False;\n If f then writeln('CHECKMATE') ELSE writeln('OTHER');\n readln;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array[1..10,1..10]of Longint;\n s:String;\n x,y,x1,y1,x2,y2,x3,y3,i:Longint;\n\nbegin\n //Reset(Input,'in.txt');\n //Rewrite(Output,'out.txt');\n Read(s);\n FillChar(a,sizeof(a),0);\n for i:=1 to 10 do\n begin\n a[1,i]:=-1;\n a[i,10]:=-1;\n a[10,i]:=-1;\n a[i,1]:=-1;\n end;\n x:=ord(s[1])-48-47;\n y:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x,y]:=1;\n x1:=ord(s[1])-48-47;\n y1:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x1,y1]:=1;\n x2:=ord(s[1])-48-47;\n y2:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x2,y2]:=2;\n x3:=ord(s[1])-48-47;\n y3:=StrToInt(s[2])+1;\n for i:=x+1 to 9 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=x-1 downto 2 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=y+1 to 9 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n for i:=y-1 downto 2 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n\n for i:=x1+1 to 9 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=x1-1 downto 2 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=y1+1 to 9 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n for i:=y1-1 downto 2 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n if a[x3,y3]<>-1 then\n begin\n Write('OTHER');\n halt(0);\n end;\n a[x2-1,y2]:=-1;\n a[x2+1,y2]:=-1;\n a[x2,y2-1]:=-1;\n a[x2,y2+1]:=-1;\n a[x2-1,y2-1]:=-1;\n a[x2-1,y2+1]:=-1;\n a[x2+1,y2-1]:=-1;\n a[x2+1,y2+1]:=-1;\n if (a[x3-1,y3]<>-1)or(a[x3+1,y3]<>-1)or\n (a[x3,y3-1]<>-1)or(a[x3,y3+1]<>-1)or\n (a[x3-1,y3-1]<>-1)or(a[x3-1,y3+1]<>-1)or\n (a[x3+1,y3-1]<>-1)or(a[x3+1,y3+1]<>-1)then\n Write('OTHER')\n else\n Write('CHECKMATE');\nend.\n "}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst dx: array [1..8] of longint = (0,1,0,-1,1,1,-1,-1);\n dy: array [1..8] of longint = (1,0,-1,0,1,-1,1,-1);\nvar\n a: array [0..9,0..9] of longint;\n b: array [0..9,0..9] of boolean;\n xk,yk,x1,y1,x2,y2,x3,y3,x4,y4,d: longint;\n\nprocedure get(var x,y:longint);\nvar\n ch: char;\nbegin\n read(ch);\n while not (ch in ['a'..'h']) do read(ch);\n x:=Ord(ch)-96;\n read(y);\nend;\n\nprocedure go(x,y,sx,sy:longint);\nbegin\n inc(x,sx); inc(y,sy);\n while (x > 0) and (y > 0) and (x < 9) and (y < 9) do\n begin\n b[x,y]:=True;\n if a[x,y] <> 0 then break;\n inc(x,sx); inc(y,sy);\n end;\nend;\n\nprocedure go2(x,y,sx,sy:longint);\nbegin\n inc(x,sx); inc(y,sy);\n if (x > 0) and (y > 0) and (x < 9) and (y < 9) then\n b[x,y]:=True;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n get(x1,y1);\n get(x2,y2);\n get(x3,y3);\n get(x4,y4);\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[x3,y3]:=3;\n fillchar(b,sizeof(b),False);\n for d:=1 to 4 do go(x1,y1,dx[d],dy[d]);\n for d:=1 to 4 do go(x2,y2,dx[d],dy[d]);\n for d:=1 to 8 do go2(x3,y3,dx[d],dy[d]);\n if not b[x4,y4] then writeln('OTHER') else\n begin\n for d:=1 to 8 do\n begin\n xk:=x4+dx[d];\n yk:=y4+dy[d];\n if (xk > 0) and (yk > 0) and (xk < 9) and (yk < 9) and (not b[xk,yk]) then\n begin\n writeln('OTHER');\n halt;\n end;\n end;\n writeln('CHECKMATE');\n end;\n close(input);\n close(output);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n i,j,x1,x2,x3,x4,y1,y2,y3,y4:longint;\n flag:boolean;\n pole:array[-10..100,-10..100] of integer;\nbegin\n read(s);\n x1:=ord(s[1])-96;\n x2:=ord(s[4])-96;\n x3:=ord(s[7])-96;\n x4:=ord(s[10])-96;\n y1:=ord(s[2])-48;\n y2:=ord(s[5])-48;\n y3:=ord(s[8])-48;\n y4:=ord(s[11])-48;\n flag:=true;\n for i:=x1+1 to 8 do\n if (x3=i) and (y3=y1) then flag:=false else if flag=true then pole[i,y1]:=1;\n flag:=true;\n for i:=x2+1 to 8 do\n if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;\n flag:=true;\n for i:=x1-1 downto 1 do\n if (x3=i) and (y3=y1)then flag:=false else if flag=true then pole[i,y1]:=1;\n flag:=true;\n for i:=x2-1 downto 1 do\n if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;\n flag:=true;\n for i:=y1+1 to 8 do\n if (y3=i) and (x3=x1) then flag:=false else if flag=true then pole[x1,i]:=1;\n flag:=true;\n for i:=y2+1 to 8 do\n if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;\n flag:=true;\n for i:=y1-1 downto 1 do\n if (y3=i) and (x3=y3) then flag:=false else if flag=true then pole[x1,i]:=1;\n flag:=true;\n for i:=y2-1 downto 1 do\n if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;\n flag:=true;\n pole[x3+1,y3]:=1;\n pole[x3-1,y3]:=1;\n pole[x3+1,y3+1]:=1;\n pole[x3+1,y3-1]:=1;\n pole[x3-1,y3+1]:=1;\n pole[x3-1,y3-1]:=1;\n pole[x3,y3]:=1;\n pole[x3,y3+1]:=1;\n pole[x3,y3-1]:=1;\n if (pole[x4,y4]=1) and ((pole[x4+1,y4]=1) or (x4+1=9)) and ((pole[x4-1,y4]=1) or (x4-1=0)) and ((pole[x4,y4+1]=1) or (y4=8)) and ((pole[x4,y4-1]=1) or (y4=1)) and ((pole[x4+1,y4+1]=1) or (x4+1=9) or (y4+1=9)) and ((pole[x4+1,y4-1]=1) or (x4+1=9) or (y4-1=0)) and ((pole[x4-1,y4+1]=1) or (x4-1=0) or (y4+1=9)) and ((pole[x4-1,y4-1]=1) or (x4-1=0) or (y4-1=0)) then Writeln('CHECKMATE') else Writeln('OTHER');\n\n \n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n i,j,x1,x2,x3,x4,y1,y2,y3,y4:longint;\n flag:boolean;\n pole:array[-10..100,-10..100] of integer;\nbegin\n read(s);\n x1:=ord(s[1])-96;\n x2:=ord(s[4])-96;\n x3:=ord(s[7])-96;\n x4:=ord(s[10])-96;\n y1:=ord(s[2])-48;\n y2:=ord(s[5])-48;\n y3:=ord(s[8])-48;\n y4:=ord(s[11])-48;\n flag:=true;\n for i:=x1+1 to 8 do\n if (x3=i) and (y3=y1) then flag:=false else if flag=true then pole[i,y1]:=1;\n flag:=true;\n for i:=x2+1 to 8 do\n if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;\n flag:=true;\n for i:=x1-1 downto 1 do\n if (x3=i) and (y3=y1)then flag:=false else if flag=true then pole[i,y1]:=1;\n flag:=true;\n for i:=x2-1 downto 1 do\n if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;\n flag:=true;\n for i:=y1+1 to 8 do\n if (y3=i) and (x3=x1) then flag:=false else if flag=true then pole[x1,i]:=1;\n flag:=true;\n for i:=y2+1 to 8 do\n if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;\n flag:=true;\n for i:=y1-1 downto 1 do\n if (y3=i) and (x3=y3) then flag:=false else if flag=true then pole[x1,i]:=1;\n flag:=true;\n for i:=y2-1 downto 1 do\n if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;\n flag:=true;\n pole[x3+1,y3]:=1;\n pole[x3-1,y3]:=1;\n pole[x3+1,y3+1]:=1;\n pole[x3+1,y3-1]:=1;\n pole[x3-1,y3+1]:=1;\n pole[x3-1,y3-1]:=1;\n pole[x3,y3]:=1;\n pole[x3,y3+1]:=1;\n pole[x3,y3-1]:=1;\n if (pole[x4,y4]=1) and ((pole[x4+1,y4]=1) or (x4+1=9)) and ((pole[x4-1,y4]=1) or (x4-1=0)) and ((pole[x4,y4+1]=1) or (y4=8)) and ((pole[x4,y4-1]=1) or (y4=1)) and ((pole[x4+1,y4+1]=1) or (x4+1=9) or (y4+1=9)) and ((pole[x4+1,y4-1]=1) or (x4+1=9) or (y4-1=0)) and ((pole[x4-1,y4+1]=1) or (x4-1=0) or (y4+1=9)) and ((pole[x4-1,y4-1]=1) or (x4-1=0) or (y4-1=0)) then Writeln('CHECKMATE') else Writeln('OTHER');\n {for i:=1 to 8 do begin\n for j:=1 to 8 do\n Write(pole[i,j],' ');\n Writeln;\n end;}\n\nend.\n"}, {"source_code": "{$O-,Q+,R+}\nuses SysUtils;\nconst size=8;\ntype int=longint;\n tpoint=record x,y:int; end;\nvar t:array[1..4] of tpoint;\n a,v:array[1..size,1..size] of int;\nprocedure init;\nbegin\n {assign(input,'b.in');\n reset(input);\n assign(output,'b.out');\n rewrite(output);}\nend;\n\nprocedure closing;\nbegin\n {close(input);\n close(output);}\nend;\n\nprocedure readf(var a:tpoint);\nvar c:char;\nbegin\n read(c);\n while c=' ' do\n read(c);\n a.x:=ord(c)-ord('a')+1;\n read(c);\n a.y:=strtoint(c);\nend;\n\n\nfunction eq(var a,b:tpoint):boolean;\nbegin\n eq:=(a.x=b.x)and(a.y=b.y);\nend;\n\nfunction good(var p:tpoint):boolean;\nbegin\n good:=(p.x>=1)and(p.x<=size)and(p.y>=1)and(p.y<=size)and((v[p.x,p.y]=0)or(eq(p,t[4])));\nend;\n\nfunction good_s(var p:tpoint):boolean;\nbegin\n good_s:=(p.x>=1)and(p.x<=size)and(p.y>=1)and(p.y<=size);\nend;\n\nprocedure other;\nbegin\n write('OTHER');\n closing;\n halt;\nend;\n\nprocedure solve;\nvar i,di,dj,k:int;\n p,kn:tpoint;\nbegin\n fillchar(v,sizeof(v),0); fillchar(a,sizeof(a),0);\n for i:=1 to 4 do begin\n readf(t[i]);\n v[t[i].x,t[i].y]:=1;\n end;\n\n for k:=1 to 2 do begin\n for di:=-1 to 1 do\n for dj:=-1 to 1 do\n if (abs(di)<>abs(dj)) then begin\n p.x:=t[k].x+di; p.y:=t[k].y+dj;\n while good(p) do begin\n a[p.x,p.y]:=1;\n inc(p.x,di); inc(p.y,dj);\n end;\n if good_s(p) then\n a[p.x,p.y]:=1;\n end;\n end;\n for di:=-1 to 1 do\n for dj:=-1 to 1 do begin\n p.x:=t[3].x+di; p.y:=t[3].y+dj;\n if good_s(p)and((di<>0)or(dj<>0)) then\n a[t[3].x+di,t[3].y+dj]:=1;\n end;\n\n kn:=t[4];\n if a[kn.x,kn.y]=0 then\n other;\n for di:=-1 to 1 do\n for dj:=-1 to 1 do begin\n p.x:=kn.x+di; p.y:=kn.y+dj;\n if good_s(p)and(a[p.x,p.y]=0) then\n other;\n end;\n write('CHECKMATE');\nend;\n\nbegin\n init;\n solve;\n closing;\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\n{$R+}\nuses\nSysUtils;\nvar\nk,e,w,i,j,x1,x2,x3,x4,y1,y2,y3,y4,y,x:longint;\nz:boolean;\ns:string;\nprocedure svoboda;\nbegin\n write('OTHER');\n halt(0);\nend;\nbegin\n//reset(input,'input.txt');rewrite(output,'output.txt');\nread(s);\nx1:=ord(s[1])-96;\ny1:=strtoint(s[2]);\nx2:=ord(s[4])-96;\ny2:=strtoint(s[5]);\nx3:=ord(s[7])-96;\ny3:=strtoint(s[8]);\nx:=ord(s[10])-96;\ny:=strtoint(s[11]);\n\nif(x1<>x)or((x3=x1)and(((y3>y1)and(y3y)))then\nif(x2<>x)or((x3=x2)and(((y3>y2)and(y3y)))then\nif(y1<>y)or((y3=y1)and(((x3>x1)and(x3x)))then\nif(y2<>y)or((y3=y2)and(((x3>x2)and(x3x)))then\nsvoboda;\nfor i:=y-1 to y+1 do\nfor j:=x-1 to x+1 do\nif i>0 then\nif i<9 then\nif j>0 then\nif j<9 then \nbegin\nz:=true;\nfor w:=i-1 to i+1 do\nfor e:=j-1 to j+1 do\nif w=y3 then\nif e=x3 then z:=false;\nk:=0;\nif(i=y1)then\nif i+j<>x1+y1 then\nbegin\n k:=1;\nend;\nif(j=x1)then\nif i+j<>x1+y1 then\nbegin\n k:=2;\nend;\nif(i=y2)then\nif i+j<>x2+y2 then\nbegin\n k:=3;\nend;\nif(j=x2)then\nif i+j<>x2+y2 then\nbegin\n k:=4;\nend;\nif k=1 then\nif((y3=y1)and(((x3>x1)and(x3j)))then k:=0;\nif k=2 then\nif((x3=x1)and(((y3>y1)and(y3y)))then k:=0;\nif k=3 then\nif((y3=y2)and(((x3>x2)and(x3x)))then k:=0;\nif k=4 then\nif ((x3=x2)and(((y3>y2)and(y3y)))then k:=0;\nif z and (k=0) then svoboda;\nend;\n\nwrite('CHECKMATE');\nend. \n"}, {"source_code": "program pjb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n iCnt,iRook1Y,iRook2Y,iKing1Y,iKing2Y: integer;\n cCnt,cRook1X,cRook2X,cKing1X,cKing2X: char;\n sTemp: string;\n bCheckmate: boolean;\n baArea: array ['a'..'z',0..9] of boolean;\n\nfunction Ic(c1: char; i1: integer): char;\nvar\n cREsult: char;\nbegin\n case i1 of\n 1:\n begin\n case c1 of\n 'a': cResult := 'b';\n 'b': cResult := 'c';\n 'c': cResult := 'd';\n 'd': cResult := 'e';\n 'e': cResult := 'f';\n 'f': cResult := 'g';\n 'g': cResult := 'h';\n 'h': cResult := 'h';\n end;\n end;\n -1:\n begin\n case c1 of\n 'a': cResult := 'a';\n 'b': cResult := 'a';\n 'c': cResult := 'b';\n 'd': cResult := 'c';\n 'e': cResult := 'd';\n 'f': cResult := 'e';\n 'g': cResult := 'f';\n 'h': cResult := 'g';\n end;\n end;\n end;\n Ic := cResult;\nend;\n\nbegin\n Readln(sTemp);\n cRook1X := sTemp[1];\n iRook1Y := Strtoint(sTemp[2]);\n cRook2X := sTemp[4];\n iRook2Y := Strtoint(sTemp[5]);\n cKing1X := sTemp[7];\n iKing1Y := Strtoint(sTEmp[8]);\n cKIng2X := sTEmp[10];\n iKing2Y := Strtoint(sTEmp[11]);\n for cCnt := 'a' to 'z' do baArea[cCnt,0] := true;\n for cCnt := 'a' to 'z' do baArea[cCnt,9] := true;\n\n for iCnt := 1 to 8 do if (iCnt <> iRook1Y) then baArea[cRook1X,iCnt] := true;\n for iCnt := 1 to 8 do if (iCnt <> iRook2Y) then baArea[cRook2X,iCnt] := true;\n for cCnt := 'a' to 'z' do if (cCnt <> cRook1X) then baArea[cCnt,iRook1Y] := true;\n for cCnt := 'a' to 'z' do if (cCnt <> cRook2X) then baArea[cCnt,iRook2Y] := true;\n baArea[Ic(cKing1X,-1),iKing1Y] := true;\n baArea[Ic(cKing1X,1),iKing1Y] := true;\n baArea[cKing1X,iKing1Y - 1] := true;\n baArea[cKing1X,iKing1Y + 1] := true;\n baArea[Ic(cKing1X,-1),iKing1Y - 1] := true;\n baArea[Ic(cKing1X,-1),iKing1Y + 1] := true;\n baArea[Ic(cKing1X,1),iKing1Y - 1] := true;\n baArea[Ic(cKing1X,1),iKing1Y + 1] := true;\n if (iKing1Y = iRook1Y)\n then begin\n if (cKing1X < cRook1X)\n then begin\n for cCnt := 'a' to cKing1X do baArea[cCnt,iKing1Y] := false;\n end\n else begin\n for cCnt := cKing1X to 'h' do baArea[cCnt,iKing1Y] := false;\n end;\n end;\n if (iKing1Y = iRook2Y)\n then begin\n if (cKing1X < cRook2X)\n then begin\n for cCnt := 'a' to cKing1X do baArea[cCnt,iKing1Y] := false;\n end\n else begin\n for cCnt := cKing1X to 'h' do baArea[cCnt,iKing1Y] := false;\n end;\n end;\n if (cKing1X = cRook1X)\n then begin\n if (iKing1Y < iRook1Y)\n then begin\n for iCnt := 1 to iKing1Y do baArea[cKing1X,iCnt] := false;\n end\n else begin\n for iCnt := iKing1Y to 8 do baArea[cKing1X,iCnt] := false;\n end;\n end;\n\n bCheckmate := true;\n if (baArea[Ic(cKing2X,-1),iKing2Y] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,-1),iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,-1),iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y] = false)\n then bCheckmate := false;\n\n if (bCheckmate = true)\n then Writeln('CHECKMATE')\n else Writeln('OTHER');\nend.\n"}, {"source_code": "const dx:array[1..8] of longint=(-1,-1,0,1,1,1,0,-1);\n dy:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);\nvar a,b,aa,bb,c,cc,d,dd,i,j:longint;\n ch:char;\n e:array[0..9,0..9] of longint;\n\nfunction check:boolean;\nvar i,x,y:longint;\nbegin\n check:=false;\n if e[d,dd]=0 then exit;\n for i:=1 to 8 do\n begin\n x:=d+dx[i]; y:=dd+dy[i];\n if (x>0) and (y>0) and (x<9) and (y<9) and (e[x,y]<=0) then exit;\n end;\n check:=true;\nend;\n\nbegin\n read(ch); a:=ord(ch)-96; read(aa);\n read(ch,ch); b:=ord(ch)-96; read(bb);\n read(ch,ch); c:=ord(ch)-96; read(cc);\n read(ch,ch); d:=ord(ch)-96; read(dd);\n e[a,aa]:=-1; e[b,bb]:=-1; e[c,cc]:=-1;\n for i:=a-1 downto 1 do\n if e[i,aa]<0 then break else e[i,aa]:=1;\n for i:=a+1 to 8 do\n if e[i,aa]<0 then break else e[i,aa]:=1;\n for i:=b-1 downto 1 do\n if e[i,bb]<0 then break else e[i,bb]:=1;\n for i:=b+1 to 8 do\n if e[i,bb]<0 then break else e[i,bb]:=1;\n for i:=aa-1 downto 1 do\n if e[a,i]<0 then break else e[a,i]:=1;\n for i:=aa+1 to 8 do\n if e[a,i]<0 then break else e[a,i]:=1;\n for i:=bb-1 downto 1 do\n if e[b,i]<0 then break else e[b,i]:=1;\n for i:=bb+1 to 8 do\n if e[b,i]<0 then break else e[b,i]:=1;\n if (a=b) or (aa=bb) then\n begin\n e[a,aa]:=1; e[b,bb]:=1;\n end;\n for i:=1 to 8 do e[c+dx[i],cc+dy[i]]:=1;\n if check then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n\n"}, {"source_code": "var a,a1,b,b1,x,x1,y,y1,s,s1,s2:char;\nc,c1,d,d1,z,z1,h,h1,t,t1,t2,t3,i,k,p:longint;\nbegin\nRead(a,a1,s,b,b1,s1,x,x1,s2,y,y1);\nc:=ord(a)-ord('a')+1;\nc1:=ord(a1)-ord('0');\nd:=ord(b)-ord('a')+1;\nd1:=ord(b1)-ord('0');\nz:=ord(x)-ord('a')+1;\nz1:=ord(x1)-ord('0');\nh:=ord(y)-ord('a')+1;\nh1:=ord(y1)-ord('0');\nt:=0;\nt1:=0;\nt2:=0;\nt2:=0;\nif h>1 then\nt:=-1;\nif h<8 then\nt1:=1;\nif h1>1 then\nt2:=-1;\nif h1<8 then\nt3:=1;\np:=0;\nfor i:=t to t1 do\n for k:=t2 to t3 do\n if ((h+i<>c)and(h1+k<>c1))or((h+i=c)and(h1+k=c1))or((h+i=c)and(z=c)and(z1h1))or((h+i=c)and(z=c)and(z1>c1)and(z1h))or((h1+k=c1)and(z1=c1)and(z>c)and(zd)and(h1+k<>d1))or((h+i=d)and(h1+k=d1))or((h+i=d)and(z=d)and(z1h1))or((h+i=d)and(z=d)and(z1>d1)and(z1h))or((h1+k=d1)and(z1=d1)and(z>d)and(zz)or(h1+k<>z1)then\n if (h+i+1<>z)or(h1+k+1<>z1)then\n if (h+i+1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k<>z1)then\n if (h+i-1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k-1<>z1)then\n begin\nwrite('OTHER');\np:=1;\nhalt;\nend;\nif p=0 then\nwrite('CHECKMATE');\nend."}, {"source_code": "var\n m : array [1..8,1..8] of boolean;\n a,b,c,d : array [1..2] of longint;\n flag : boolean;\n i,j : longint;\n s : string;\nprocedure put(x,y : longint);\nbegin\n if (x<1) then exit;\n if (x>8) then exit;\n if (y<1) then exit;\n if (y>8) then exit;\n m[x,y]:=true;\nend;\n\nfunction est(x,y : longint) : boolean;\nvar\n b : boolean;\nbegin\n b:=false;\n if (x<1) then b:=true;\n if (x>8) then b:=true;\n if (y<1) then b:=true;\n if (y>8) then b:=true;\n if b = false then est:=m[x,y] else est:=b;\nend;\n\nbegin\n fillchar(m,sizeof(m),false);\n readln(s);\n a[1]:=ord(s[1])-ord('a')+1;\n b[1]:=ord(s[4])-ord('a')+1;\n c[1]:=ord(s[7])-ord('a')+1;\n d[1]:=ord(s[10])-ord('a')+1;\n a[2]:=ord(s[2])-ord('0');\n b[2]:=ord(s[5])-ord('0');\n c[2]:=ord(s[8])-ord('0');\n d[2]:=ord(s[11])-ord('0');\n for i:=1 to 8 do\n begin\n put(a[1]+i,a[2]);\n if (a[1]+i=c[1]) and (a[2]=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(a[1]-i,a[2]);\n if (a[1]-i=c[1]) and (a[2]=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(b[1]+i,b[2]);\n if (b[1]+i=c[1]) and (b[2]=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(b[1]-i,b[2]);\n if (b[1]-i=c[1]) and (b[2]=c[2]) then break;\n end;\n\n for i:=1 to 8 do\n begin\n put(a[1],a[2]+i);\n if (a[1]=c[1]) and (a[2]+i=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(a[1],a[2]-i);\n if (a[1]=c[1]) and (a[2]-i=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(b[1],b[2]+i);\n if (b[1]=c[1]) and (b[2]+i=c[2]) then break;\n end;\n for i:=1 to 8 do\n begin\n put(b[1],b[2]-i);\n if (b[1]=c[1]) and (b[2]-i=c[2]) then break;\n end;\n put(c[1],c[2]);\n put(c[1]+1,c[2]);\n put(c[1]-1,c[2]);\n put(c[1],c[2]-1);\n put(c[1]+1,c[2]-1);\n put(c[1]-1,c[2]-1);\n put(c[1],c[2]+1);\n put(c[1]+1,c[2]+1);\n put(c[1]-1,c[2]+1);\n{ if (a[1]=b[1]) or (a[2]=b[2]) then\n begin\n put(a[1],b[1]);\n put(a[2],b[2]);\n end;\n} flag:=true;\n if (not est(d[1]+1,d[2]+1)) then flag:=false;\n if (not est(d[1]+1,d[2]-1)) then flag:=false;\n if (not est(d[1]+1,d[2])) then flag:=false;\n if (not est(d[1]-1,d[2]+1)) then flag:=false;\n if (not est(d[1]-1,d[2]-1)) then flag:=false;\n if (not est(d[1]-1,d[2])) then flag:=false;\n if (not est(d[1],d[2]+1)) then flag:=false;\n if (not est(d[1],d[2]-1)) then flag:=false;\n if (not est(d[1],d[2])) then flag:=false;\n if flag = false then writeln('OTHER') else writeln('CHECKMATE');\nend."}, {"source_code": "uses math;\nvar flag:boolean;\n a:array[-10..100,-10..100]of longint;\n x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;\n ch:char;\n procedure rec(x,y,xx,yy:longint);\n var w:longint;\n begin\n while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do\n begin\n x:=x+xx;\n y:=y+yy;\n w:=a[x,y];\n a[x,y]:=0;\n if w=2 then break;\n end;\n end;\n begin\n read(ch,y1);\n x1:=ord(ch)-96;\n read(ch,ch,y2);\n x2:=ord(ch)-96;\n read(ch,ch,y3);\n x3:=ord(ch)-96;\n read(ch,ch,y4);\n x4:=ord(ch)-96;\n\n for i:=0 to 9 do\n for j:=0 to 9 do\n a[i,j]:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=1;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n a[x3,y3]:=2;\n a[x4,y4]:=3;\n\n rec(x1,y1,1,0);\n rec(x1,y1,-1,0);\n rec(x1,y1,0,1);\n rec(x1,y1,0,-1);\n\n rec(x2,y2,1,0);\n rec(x2,y2,-1,0);\n rec(x2,y2,0,1);\n rec(x2,y2,0,-1);\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ( max(abs(x3-i),abs(y3-j))=1 ) then a[i,j]:=0;\n\n flag:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;\n if flag then writeln('CHECKMATE')\n else writeln('OTHER');\n End."}, {"source_code": "var board:array[1..8,1..8]of boolean;\n a:string[11];\n r,l,i,j,kr,kl:byte;\n ischeckmate:boolean;\nbegin\n for i:=1 to 8 do for j:=1 to 8 do board[i,j]:=false;\n readln(a);\n {white king}\n r:=ord(a[8])-48;\n kr:=r;\n l:=ord(a[7])-96;\n kl:=l;\n for i:=r-1 to r+1 do\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0) then\n board[i,j]:=true;\n {1st rook}\n r:=ord(a[2])-48;\n l:=ord(a[1])-96;\n for i:=1 to 8 do begin\n if i<>l then\n if (kr=r) then begin\n if ((kll)and(kl>i)) then\n board[r,i]:=true\n end\n else\n board[r,i]:=true;\n if i<>r then\n if (kl=l) then begin\n if ((krr)and(kr>i)) then\n board[i,l]:=true\n end\n else\n board[i,l]:=true;\n end;\n {2nd rook}\n r:=ord(a[5])-48;\n l:=ord(a[4])-96;\n for i:=1 to 8 do begin\n if i<>l then\n if (kr=r) then begin\n if ((kll)and(kl>i)) then\n board[r,i]:=true\n end\n else\n board[r,i]:=true;\n if i<>r then\n if (kl=l) then begin\n if ((krr)and(kr>i)) then\n board[i,l]:=true\n end\n else\n board[i,l]:=true;\n end;\n ischeckmate:=true;\n {black king}\n r:=ord(a[11])-48;\n l:=ord(a[10])-96;\n for i:=r-1 to r+1 do begin\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin\n ischeckmate:=false;\n break;\n end;\n if ischeckmate=false then break;\n end;\n if ischeckmate then\n writeln('CHECKMATE')\n else\n writeln('OTHER');\nreadln;\nend."}, {"source_code": "const x:array[1..9] of longint=(0,1,1,1,0,-1,-1,-1,0);\n y:array[1..9] of longint=(0,1,0,-1,-1,-1,0,1,1);\nvar x1,y1,x2,y2,x3,y3,x4,y4,i,j,k:longint;\n s:string;\n s1,s2,s3,s4:string;\n sim1,sim2:char;\n a,b:array[0..9,0..9] of longint;\n\n\nprocedure Print(s:string);\nbegin\nwriteln(s);\nhalt;\nend;\n\nfunction BOY:boolean;\nvar i1,i2,j1,j2,i,j,l:longint;\n t:extended;\n pp:boolean;\nbegin\n for i1:= 1 to 8 do\n for j1:= 1 to 8 do\n if a[i1,j1]=4 then begin\n for i2:= 1 to 8 do\n for j2:= 1 to 8 do\n begin\n if (a[i2,j2]=1) or (a[i2,j2]=2) then begin\n if i1=i2 then begin\n if j10 then pp:=false;\n if pp then begin BOY:=true; exit; end;\n end else\n begin\n pp:=true;\n for l:= j2+1 to j1-1 do\n if a[i1,l]<>0 then pp:=false;\n if pp then begin BOY:=true; exit; end;\n end;\n end else\n if j1=j2 then begin\n if i10 then pp:=false;\n if pp then begin BOY:=true; exit; end;\n end else\n begin\n pp:=true;\n for l:= i2+1 to i1-1 do\n if a[l,j1]<>0 then pp:=false;\n if pp then begin BOY:=true; exit; end;\n end;\n end;\n end else\n if (a[i2,j2]=3) then begin\n t:=sqrt(Sqr(i1-i2)+sqr(j1-j2));\n if t<1.9 then begin BOY:=true; exit; end;\n\n\n end;\n end;\n end;\nBOY:=false;\nend;\n\nbegin\nreadln(s);\nx1:=ord(s[1])-ord('a')+1;\ny1:=ord(s[2])-ord('1')+1;\nx2:=ord(s[4])-ord('a')+1;\ny2:=ord(s[5])-ord('1')+1;\nx3:=ord(s[7])-ord('a')+1;\ny3:=ord(s[8])-ord('1')+1;\nx4:=ord(s[10])-ord('a')+1;\ny4:=ord(s[11])-ord('1')+1;\ns1:='OTHER';\ns2:='CHECKMATE';\nfor i:= 1 to 8 do\nfor j:= 1 to 8 do\na[i,j]:=0;\na[x1,y1]:=1;\na[x2,y2]:=2;\na[x3,y3]:=3;\na[x4,y4]:=9;\nb:=a;\n for k:= 1 to 9 do\n begin\n if (x4+x[k]<1) or (y4+y[k]<1) or (x4+x[k]>8) or (y4+y[k]>8) then continue;\n a:=b;\n a[x4,y4]:=0;\n a[x4+x[k],y4+y[k]]:=4;\n if not BOY then begin Print(s1); end;\n end;\n Print(s2);\nend.\n"}, {"source_code": "var\nff,n,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;\nxx,yy,nn:char;\na:array[0..10,0..10]of longint;\n\nprocedure ha;\n begin\n writeln('OTHER');\n halt(0);\n end;\n\nfunction f(q,w:longint):boolean;\nvar i,j:longint;\n begin\n if (q<1)or(q>8)or(w<1)or(w>8) then\n begin\n f:=false;\n exit;\n end;\n\n ff:=a[q,w];\n a[q,w]:=0;\n\n if ((abs(q-x3)=1)or(abs(w-y3)=1))and((abs(q-x3))+(abs(w-y3))<=2) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n\n if y1=w then\n for i:=x1+1 to n do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if y1=w then\n for i:=x1-1 downto 1 do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1+1 to m do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1-1 downto 1 do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2+1 to n do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2-1 downto 1 do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2+1 to m do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2-1 downto 1 do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n a[q,w]:=ff;\n exit;\n end;\n end;\n\n a[q,w]:=ff;\n f:=true;\n end;\n\n begin\n n:=8;\n m:=8;\n fillchar(a,sizeof(a),0);\n read(xx,yy);\n x1:=ord(xx)-96;\n y1:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x2:=ord(xx)-96;\n y2:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x3:=ord(xx)-96;\n y3:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x4:=ord(xx)-96;\n y4:=ord(yy)-48;\n\n\n a[x1,y1]:=1;\n\n a[x2,y2]:=2;\n\n a[x3,y3]:=3;\n\n if f(x4,y4) then ha;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;\n\n writeln('CHECKMATE');\n end.\n"}], "negative_code": [{"source_code": "const dx:array[1..8] of longint=(-1,-1,0,1,1,1,0,-1);\n dy:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);\nvar a,b,aa,bb,c,cc,d,dd,i,j:longint;\n ch:char;\n e:array[0..9,0..9] of longint;\n\nfunction check:boolean;\nvar i,x,y:longint;\nbegin\n check:=false;\n if e[d,dd]=0 then exit;\n for i:=1 to 8 do\n begin\n x:=d+dx[i]; y:=dd+dy[i];\n if (x>0) and (y>0) and (x<9) and (y<9) then\n begin\n if e[x,y]=0 then exit;\n if ((x=a) and (y=aa) and (e[x,y]=1)) or ((x=b) and (y=bb) and (e[x,y]=1)) then exit;\n end;\n end;\n check:=true;\nend;\n\nbegin\n read(ch); a:=ord(ch)-96; read(aa);\n read(ch,ch); b:=ord(ch)-96; read(bb);\n read(ch,ch); c:=ord(ch)-96; read(cc);\n read(ch,ch); d:=ord(ch)-96; read(dd);\n for i:=1 to 8 do\n begin\n inc(e[i,aa]); inc(e[a,i]);\n inc(e[i,bb]); inc(e[b,i]);\n end;\n for i:=1 to 8 do inc(e[c+dx[i],cc+dy[i]],1);\n dec(e[a,aa]); dec(e[b,bb]); inc(e[c,cc]);\n if check then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n\n"}, {"source_code": "var a,a1,b,b1,x,x1,y,y1,s,s1,s2:char;\nc,c1,d,d1,z,z1,h,h1,t,t1,t2,t3,i,k,p:longint;\nbegin\nRead(a,a1,s,b,b1,s1,x,x1,s2,y,y1);\nc:=ord(a)-ord('a')+1;\nc1:=ord(a1)-ord('0');\nd:=ord(b)-ord('a')+1;\nd1:=ord(b1)-ord('0');\nz:=ord(x)-ord('a')+1;\nz1:=ord(x1)-ord('0');\nh:=ord(y)-ord('a')+1;\nh1:=ord(y1)-ord('0');\nt:=0;\nt1:=0;\nt2:=0;\nt2:=0;\nif h>1 then\nt:=-1;\nif h<8 then\nt1:=1;\nif h1>1 then\nt2:=-1;\nif h1<8 then\nt3:=1;\np:=0;\nfor i:=t to t1 do\n for k:=t2 to t3 do\n if ((h+i<>c)and(h1+k<>c1))or((h+i=c)and(h1+k=c1))then\n if ((h+i<>d)and(h1+k<>d1))or((h+i=d)and(h1+k=d1))then\n if (h+i+1<>z)or(h1+k<>z1)then\n if (h+i+1<>z)or(h1+k+1<>z1)then\n if (h+i+1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k<>z1)then\n if (h+i-1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k-1<>z1)then\n begin\nwrite('OTHER');\np:=1;\nhalt;\nend;\nif p=0 then\nwrite('CHECKMATE');\nend."}, {"source_code": "var a,a1,b,b1,x,x1,y,y1,s,s1,s2:char;\nc,c1,d,d1,z,z1,h,h1,t,t1,t2,t3,i,k,p:longint;\nbegin\nRead(a,a1,s,b,b1,s1,x,x1,s2,y,y1);\nc:=ord(a)-ord('a')+1;\nc1:=ord(a1)-ord('0');\nd:=ord(b)-ord('a')+1;\nd1:=ord(b1)-ord('0');\nz:=ord(x)-ord('a')+1;\nz1:=ord(x1)-ord('0');\nh:=ord(y)-ord('a')+1;\nh1:=ord(y1)-ord('0');\nt:=0;\nt1:=0;\nt2:=0;\nt2:=0;\nif h>1 then\nt:=-1;\nif h<8 then\nt1:=1;\nif h1>1 then\nt2:=-1;\nif h1<8 then\nt3:=1;\np:=0;\nfor i:=t to t1 do\n for k:=t2 to t3 do\n if ((h+i<>c)and(h1+k<>c1))or((h+i=c)and(h1+k=c1))then\n if ((h+i<>d)and(h1+k<>d1))or((h+i=d)and(h1+k=d1))then\n if (h+i+1<>z)or(h1+k<>z1)then\n if (h+i+1<>z)or(h1+k+1<>z1)then\n if (h+i+1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k<>z1)then\n if (h+i-1<>z)or(h1+k-1<>z1)then\n if (h+i-1<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k+1<>z1)then\n if (h+i<>z)or(h1+k-1<>z1)then\n begin\nwrite('OTHER');\np:=1;\nend;\nif p=0 then\nwrite('CHECKMATE');\nend."}, {"source_code": "var board:array[1..8,1..8]of boolean;\n a:string[11];\n r,l,i,j,kr,kl:byte;\n ischeckmate:boolean;\nbegin\n for i:=1 to 8 do for j:=1 to 8 do board[i,j]:=false;\n readln(a);\n {white king}\n r:=ord(a[8])-48;\n kr:=r;\n l:=ord(a[7])-96;\n kl:=l;\n for i:=r-1 to r+1 do\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0) then\n board[i,j]:=true;\n {1st rook}\n r:=ord(a[2])-48;\n l:=ord(a[1])-96;\n for i:=1 to 8 do begin\n if i<>l then\n if (kr=r) then begin\n if ((kll)and(kl>i)) then\n board[r,i]:=true\n end\n else\n board[r,i]:=true;\n if i<>r then\n if (kl=l) then begin\n if ((krr)and(kr>i)) then\n board[i,l]:=true\n end\n else\n board[i,l]:=true;\n end;\n {2nd rook}\n r:=ord(a[5])-48;\n l:=ord(a[4])-96;\n for i:=1 to 8 do begin\n if i<>l then\n if (kr=r) then begin\n if ((kll)and(kl>i)) then\n board[r,i]:=true\n end\n else\n board[r,i]:=true;\n if i<>r then\n if (kl=l) then begin\n if ((krr)and(kr>i)) then\n board[i,l]:=true\n end\n else\n board[i,l]:=true;\n end;\n for i:=8 downto 1 do\n for j:=1 to 8 do begin\n if board[i,j] then\n write('T ')\n else\n write('F ');\n if j=8 then writeln;\n end;\n\n ischeckmate:=true;\n {black king}\n r:=ord(a[11])-48;\n l:=ord(a[10])-96;\n for i:=r-1 to r+1 do begin\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin\n ischeckmate:=false;\n break;\n end;\n if ischeckmate=false then break;\n end;\n if ischeckmate then\n writeln('CHECKMATE')\n else\n writeln('OTHER');\nreadln;\nend."}, {"source_code": "var board:array[1..8,1..8]of boolean;\n a:string[11];\n r,l,i,j:byte;\n ischeckmate:boolean;\nbegin\n readln(a);\n r:=ord(a[2])-48;\n l:=ord(a[1])-96;\n for i:=1 to 8 do begin\n if i<>r then board[i,l]:=true;\n if i<>l then board[r,i]:=true;\n end;\n r:=ord(a[5])-48;\n l:=ord(a[4])-96;\n for i:=1 to 8 do begin\n if i<>r then board[i,l]:=true;\n if i<>l then board[r,i]:=true;\n end;\n r:=ord(a[8])-48;\n l:=ord(a[7])-96;\n for i:=r-1 to r+1 do\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0) then\n board[i,j]:=true;\n ischeckmate:=true;\n r:=ord(a[11])-48;\n l:=ord(a[10])-96;\n for i:=r-1 to r+1 do begin\n for j:=l-1 to l+1 do\n if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin\n ischeckmate:=false;\n break;\n end;\n if ischeckmate=false then break;\n end;\n if ischeckmate then\n writeln('CHECKMATE')\n else\n writeln('OTHER');\nreadln;\nend."}, {"source_code": "var\nn,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;\nxx,yy,nn:char;\na:array[0..10,0..10]of longint;\n\nprocedure ha;\n begin\n writeln('OTHER');\n halt(0);\n end;\n\nfunction f(q,w:longint):boolean;\nvar i,j:longint;\n begin\n if (q<1)or(q>8)or(w<1)or(w>8) then\n begin\n f:=false;\n exit;\n end;\n\n if ((abs(q-x3)=1)or(abs(w-y3)=1))and((abs(q-x3))+(abs(w-y3))<=2) then\n begin\n f:=false;\n exit;\n end;\n\n if y1=w then\n for i:=x1+1 to n do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y1=w then\n for i:=x1-1 downto 1 do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1+1 to m do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1-1 downto 1 do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2+1 to n do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2-1 downto 1 do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2+1 to m do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2-1 downto 1 do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n f:=true;\n end;\n\n begin\n n:=8;\n m:=8;\n fillchar(a,sizeof(a),0);\n read(xx,yy);\n x1:=ord(xx)-96;\n y1:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x2:=ord(xx)-96;\n y2:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x3:=ord(xx)-96;\n y3:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x4:=ord(xx)-96;\n y4:=ord(yy)-48;\n\n\n a[x1,y1]:=1;\n\n a[x2,y2]:=2;\n\n a[x3,y3]:=3;\n\n if f(x4,y4) then ha;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;\n\n writeln('CHECKMATE');\n end.\n"}, {"source_code": "var\nn,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;\nxx,yy,nn:char;\na:array[0..10,0..10]of longint;\n\nprocedure ha;\n begin\n writeln('OTHER');\n halt(0);\n end;\n\nfunction f(q,w:longint):boolean;\nvar i,j:longint;\n begin\n if (q<1)or(q>8)or(w<1)or(w>8) then\n begin\n f:=false;\n exit;\n end;\n\n if abs(q-x3)+abs(w-y3)=1 then\n begin\n f:=false;\n exit;\n end;\n\n if y1=w then\n for i:=x1+1 to n do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y1=w then\n for i:=x1-1 downto 1 do\n begin\n if a[i,y1]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1+1 to m do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x1=q then\n for j:=y1-1 downto 1 do\n begin\n if a[x1,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2+1 to n do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if y2=w then\n for i:=x2-1 downto 1 do\n begin\n if a[i,y2]<>0 then break;\n\n if (i=q) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2+1 to m do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n if x2=q then\n for j:=y2-1 downto 1 do\n begin\n if a[x2,j]<>0 then break;\n\n if (j=w) then\n begin\n f:=false;\n exit;\n end;\n end;\n\n f:=true;\n end;\n\n begin\n n:=8;\n m:=8;\n fillchar(a,sizeof(a),0);\n read(xx,yy);\n x1:=ord(xx)-96;\n y1:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x2:=ord(xx)-96;\n y2:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x3:=ord(xx)-96;\n y3:=ord(yy)-48;\n\n read(nn);\n\n read(xx,yy);\n x4:=ord(xx)-96;\n y4:=ord(yy)-48;\n\n\n a[x1,y1]:=1;\n\n a[x2,y2]:=2;\n\n a[x3,y3]:=3;\n\n if f(x4,y4) then ha;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;\n\n writeln('CHECKMATE');\n end.\n"}, {"source_code": "uses math;\nvar flag:boolean;\n a:array[-10..100,-10..100]of longint;\n x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;\n ch:char;\n procedure rec(x,y,xx,yy:longint);\n var w:longint;\n begin\n while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do\n begin\n x:=x+xx;\n y:=y+yy;\n w:=a[x,y];\n a[x,y]:=0;\n if w=2 then break;\n end;\n end;\n begin\n read(ch,y1);\n x1:=ord(ch)-96;\n read(ch,ch,y2);\n x2:=ord(ch)-96;\n read(ch,ch,y3);\n x3:=ord(ch)-96;\n read(ch,ch,y4);\n x4:=ord(ch)-96;\n\n for i:=0 to 9 do\n for j:=0 to 9 do\n a[i,j]:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=1;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n a[x3,y3]:=2;\n a[x4,y4]:=3;\n rec(x1,y1,1,0);\n rec(x1,y1,-1,0);\n rec(x1,y1,0,1);\n rec(x1,y1,0,-1);\n rec(x2,y2,1,0);\n rec(x2,y2,-1,0);\n rec(x2,y2,0,1);\n rec(x2,y2,0,-1);\n\n flag:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;\n if flag then writeln('CHECKMATE')\n else writeln('OTHER');\n End."}, {"source_code": "program sdfdsv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\n\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4-1,j4+1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "program sdfdsv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\n\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "program sdfdsv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\n\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4-1,j4+1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "program bv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "program sdfdsv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..9,0..9] of byte;\n\tr:integer;\n\t\n\nBEGIN\n\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "program bv;\n\n\nvar i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;\n\tch:char;\n\tf,g,h:array[0..10,0..10] of byte;\n\tr:integer;\n\t\n\nBEGIN\nread(ch);\nif ch='a' then i1:=1;\nif ch='b' then i1:=2;\nif ch='c' then i1:=3;\nif ch='d' then i1:=4;\nif ch='e' then i1:=5;\nif ch='f' then i1:=6;\nif ch='g' then i1:=7;\nif ch='h' then i1:=8;\t\nread(ch);\nVal(ch,j1,r);\t\nread(ch);\nread(ch);\nif ch='a' then i2:=1;\nif ch='b' then i2:=2;\nif ch='c' then i2:=3;\nif ch='d' then i2:=4;\nif ch='e' then i2:=5;\nif ch='f' then i2:=6;\nif ch='g' then i2:=7;\nif ch='h' then i2:=8;\t\nread(ch);\nVal(ch,j2,r);\nread(ch);\nread(ch);\nif ch='a' then i3:=1;\nif ch='b' then i3:=2;\nif ch='c' then i3:=3;\nif ch='d' then i3:=4;\nif ch='e' then i3:=5;\nif ch='f' then i3:=6;\nif ch='g' then i3:=7;\nif ch='h' then i3:=8;\t\nread(ch);\nVal(ch,j3,r);\nread(ch);\nread(ch);\nif ch='a' then i4:=1;\nif ch='b' then i4:=2;\nif ch='c' then i4:=3;\nif ch='d' then i4:=4;\nif ch='e' then i4:=5;\nif ch='f' then i4:=6;\nif ch='g' then i4:=7;\nif ch='h' then i4:=8;\t\nread(ch);\nVal(ch,j4,r);\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do f[i,0]:=1;\nfor i:=0 to 9 do f[i,9]:=1;\nfor j:=1 to 8 do f[0,j]:=1;\nfor j:=1 to 8 do f[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do g[i,0]:=1;\nfor i:=0 to 9 do g[i,9]:=1;\nfor j:=1 to 8 do g[0,j]:=1;\nfor j:=1 to 8 do g[9,j]:=1;\nfor i:=1 to 8 do begin\nfor j:=1 to 8 do begin\nif (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;\nend;\nend;\nfor i:=0 to 9 do h[i,0]:=1;\nfor i:=0 to 9 do h[i,9]:=1;\nfor j:=1 to 8 do h[0,j]:=1;\nfor j:=1 to 8 do h[9,j]:=1;\nif (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then\nbegin\nif ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')\nelse writeln('CHECKMATE');\nend\nelse writeln('OTHER');\nEND.\n\n"}, {"source_code": "const\n hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);\n hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);\n\nvar\n s:string;\n x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;\n was:array[1..8,1..8] of boolean;\n\nbegin\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n x2:=ord(s[4])-96;\n y2:=ord(s[5])-48;\n wx:=ord(s[7])-96;\n wy:=ord(s[8])-48;\n bx:=ord(s[10])-96;\n by:=ord(s[11])-48;\n for i:=1 to 8 do begin\n cx:=wx+hx[i];\n cy:=wy+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;\n was[cx][cy]:=true;\n end;\n res:=0;\n for i:=1 to 9 do begin\n cx:=bx+hx[i];\n cy:=by+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else\n if (was[cx][cy])then inc(res) else\n if ((cx=x1) or (cy=y1)) and ((cx<>x1) or (cy<>y1)) then inc(res) else\n if ((cx=x2) or (cy=y2)) and ((cx<>x2) or (cy<>y2)) then inc(res);\n end;\n if (res=9)\n then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n"}, {"source_code": "const\n hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);\n hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);\n\nvar\n s:string;\n x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;\n was:array[1..8,1..8] of boolean;\n\nbegin\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n x2:=ord(s[4])-96;\n y2:=ord(s[5])-48;\n wx:=ord(s[7])-96;\n wy:=ord(s[8])-48;\n bx:=ord(s[10])-96;\n by:=ord(s[11])-48;\n for i:=1 to 8 do begin\n cx:=wx+hx[i];\n cy:=wy+hy[i];\n if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;\n was[cx][cy]:=true;\n end;\n res:=0;\n for i:=1 to 9 do begin\n cx:=bx+hx[i];\n cy:=by+hy[i];\n if (cx=wx)and (cx=wy)then begin\n res:=-1;\n break;\n end;\n if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else\n if (was[cx][cy])then inc(res) else\n if (ord(cx=x1) + ord(cy=y1) = 1)then inc(res) else\n if (ord(cx=x2) + ord(cy=y2) = 1)then inc(res);\n end;\n if (res=9)\n then writeln('CHECKMATE')\n else writeln('OTHER');\nend.\n"}, {"source_code": "type Tpos=record x,y:byte; end;\nvar p:array[1..4]of Tpos;\n ax:array[1..4]of string[3];\n board:array[0..9,0..9]of shortint;\n mat:boolean;\n i,x,y,j:shortint;\nbegin\n for y:=0 to 9 do\n for x:=0 to 9 do\n if ((x=0)or(x=9)or(y=0)or(y=9)) then\n board[x,y]:=5 else board[x,y]:=0;\n\n for i:=1 to 4 do begin\n read(ax[i]);\n p[i].x:=1 + (ord(ax[i,1])-ord('a'));\n p[i].y:=1 + (ord(ax[i,2])-ord('1'));\n if (i<4) then board[p[i].x,p[i].y]:=-1;\n end;\n mat:=true;\n\n for i:=1 to 2 do begin\n y:=p[i].y;\n for x:=p[i].x downto 1 do\n if (x<>p[i].x) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n for x:=p[i].x to 8 do\n if (x<>p[i].x) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n x:=p[i].x;\n for y:=p[i].y downto 1 do\n if (y<>p[i].y) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n for y:=p[i].y to 8 do\n if (y<>p[i].y) then\n if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);\n end;\n\n for i:=1 to 3 do board[p[i].x,p[i].y]:=-board[p[i].x,p[i].y]-1;\n\n for y:=-1 to 1 do\n for x:=-1 to 1 do\n if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);\n\n for y:=-1 to 1 do\n if mat then\n for x:=-1 to 1 do\n if ((y<>0)or(x<>0))then\n if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;\n\n if mat then write('CHECKMATE') else write('OTHER');\nend."}, {"source_code": "type Tpos=record x,y:byte; end;\nvar p:array[1..4]of Tpos;\n ax:array[1..4]of string[2];\n board:array[0..9,0..9]of shortint;\n mat:boolean;\n i,j:shortint;\nbegin\n for i:=1 to 4 do begin\n read(ax[i]);\n p[i].x:=1 + (ord(ax[i,1])-ord('a'));\n p[i].y:=1 + (ord(ax[i,2])-ord('1'));\n end;\n mat:=true;\n\n for i:=0 to 9 do\n for j:=0 to 9 do\n if ((i=0)or(i=9)or(j=0)or(j=9)) then\n board[i,j]:=5 else board[i,j]:=0;\n\n for j:=1 to 2 do\n for i:=1 to 8 do begin\n inc(board[i,p[j].y]);\n inc(board[p[j].x,i]);\n end;\n\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if ((i<>0)or(j<>0))then inc(board[p[3].x+i,p[3].y+j]);\n\n for i:=1 to 2 do dec(board[p[i].x,p[i].y],2);\n\n for i:=-1 to 1 do begin\n if mat then\n for j:=-1 to 1 do\n if ((i<>0)or(j<>0))then\n if (board[p[4].x+i,p[4].y+j]=0) then begin mat:=false; break; end;\n end;\n\n if mat then write('CHECKMATE') else write('OTHER');\nend."}, {"source_code": "type Tpos=record x,y:byte; end;\nvar p:array[1..4]of Tpos;\n ax:array[1..4]of string[3];\n board:array[0..9,0..9]of shortint;\n mat:boolean;\n i,x,y:shortint;\nbegin\n for i:=1 to 4 do begin\n read(ax[i]);\n p[i].x:=1 + (ord(ax[i,1])-ord('a'));\n p[i].y:=1 + (ord(ax[i,2])-ord('1'));\n end;\n mat:=true;\n\n for y:=0 to 9 do\n for x:=0 to 9 do\n if ((x=0)or(x=9)or(y=0)or(y=9)) then\n board[x,y]:=5 else board[x,y]:=0;\n\n for i:=1 to 2 do\n for x:=1 to 8 do begin\n inc(board[x,p[i].y]);\n inc(board[p[i].x,x]);\n end;\n\n for y:=-1 to 1 do\n for x:=-1 to 1 do\n if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);\n\n for i:=1 to 2 do dec(board[p[i].x,p[i].y],2);\n\n for y:=-1 to 1 do\n if mat then\n for x:=-1 to 1 do\n if ((y<>0)or(x<>0))then\n if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;\n\n if mat then write('CHECKMATE') else write('OTHER');\nend."}, {"source_code": "var \n d:array [1..8,1..8] of byte;\n i,j,n,k,x,y:longint;\n s:string;\nBEGIN\nfillchar(d,sizeof(d),0);\nreadln(s);\nn:=1;\nwhile n<=10 do\n begin\n j:=ord(s[n])-96; \n val(s[n+1],i); \n if (n=1)or(n=4) then \n begin \n d[i,j]:=1;\n for k:=1 to 8 do if d[i,k]=0 then d[i,k]:=4; \n for k:=1 to 8 do if d[k,j]=0 then d[k,j]:=4; \n end\n else if n=7 then \n begin\n d[i,j]:=2;\n if i>1 then d[i-1,j]:=4;\n if i<8 then d[i+1,j]:=4;\n if j>1 then d[i,j-1]:=4;\n if j<8 then d[i,j+1]:=4;\n if (i>1)and(j>1) then d[i-1,j-1]:=4;\n if (i<8)and(j<8) then d[i+1,j+1]:=4;\n if (j>1)and(i<8) then d[i+1,j-1]:=4;\n if (j<8)and(i>1) then d[i-1,j+1]:=4;\n end\n else \n begin \n x:=i;\n y:=j;\n end; \n inc(n,3); \n end;\nn:=0;k:=0;\nif d[x,y]=4 then\n begin\n if x>1 then \n begin\n if d[x-1,y]=4 then inc(n);\n inc(k);\n end;\n if x<8 then \n begin\n if d[x+1,y]=4 then inc(n);\n inc(k);\n end;\n if y>1 then \n begin\n if d[x,y-1]=4 then inc(n);\n inc(k);\n end;\n if y<8 then \n begin\n if d[x,y+1]=4 then inc(n);\n inc(k);\n end;\n if (x>1)and(y>1) then \n begin\n if d[x-1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (x<8)and(y<8) then \n begin\n if d[x+1,y+1]=4 then inc(n);\n inc(k);\n end;\n if (y>1)and(x<8) then \n begin\n if d[x+1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (y<8)and(x>1) then \n begin\n if d[x-1,y+1]=4 then inc(n);\n inc(k);\n end;\n if n=k then writeln('CHECKMATE') else writeln('OTHER');\n end\nelse writeln('OTHER');\n\n{for i:=1 to 8 do \n begin\n for j:=1 to 8 do write(d[i,j],' ');\n writeln;\n end;}\nEND."}, {"source_code": "var \n d:array [1..8,1..8] of byte;\n i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;\n s:string;\nBEGIN\nfillchar(d,sizeof(d),0);\nreadln(s);\nn:=1;\nwhile n<=10 do\n begin\n j:=ord(s[n])-96; \n val(s[n+1],i); \n if n=1 then \n begin\n x1:=i;\n y1:=j;\n end\n else if n=4 then\n begin\n x2:=i;\n y2:=j;\n end \n else if n=7 then \n begin\n xx:=i;\n yy:=j; \n d[xx,yy]:=2; \n end\n else \n begin \n x:=i;\n y:=j;\n end; \n inc(n,3); \n end;\n\nif x1<>xx then for k:=1 to 8 do d[x1,k]:=4\n else if y1yy then for k:=1 to 8 do d[k,y1]:=4\n else if x1xx then for k:=1 to 8 do d[x2,k]:=4\n else if y2yy then for k:=1 to 8 do d[k,y2]:=4\n else if x21 then d[xx-1,yy]:=4;\nif xx<8 then d[xx+1,yy]:=4;\nif yy>1 then d[xx,yy-1]:=4;\nif yy<8 then d[xx,yy+1]:=4;\nif (xx>1)and(yy>1) then d[xx-1,yy-1]:=4;\nif (xx<8)and(yy<8) then d[xx+1,yy+1]:=4;\nif (yy>1)and(xx<8) then d[xx+1,yy-1]:=4;\nif (yy<8)and(xx>1) then d[xx-1,yy+1]:=4;\n\n \nn:=0;k:=0;\nif d[x,y]=4 then\n begin\n if x>1 then \n begin\n if d[x-1,y]=4 then inc(n);\n inc(k);\n end;\n if x<8 then \n begin\n if d[x+1,y]=4 then inc(n);\n inc(k);\n end;\n if y>1 then \n begin\n if d[x,y-1]=4 then inc(n);\n inc(k);\n end;\n if y<8 then \n begin\n if d[x,y+1]=4 then inc(n);\n inc(k);\n end;\n if (x>1)and(y>1) then \n begin\n if d[x-1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (x<8)and(y<8) then \n begin\n if d[x+1,y+1]=4 then inc(n);\n inc(k);\n end;\n if (y>1)and(x<8) then \n begin\n if d[x+1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (y<8)and(x>1) then \n begin\n if d[x-1,y+1]=4 then inc(n);\n inc(k);\n end;\n if n=k then writeln('CHECKMATE') else writeln('OTHER');\n end\nelse writeln('OTHER');\n\n{for i:=1 to 8 do \n begin\n for j:=1 to 8 do \n if d[i,j]=0 then write('- ') else write(d[i,j],' ');\n writeln;\n end;}\nEND."}, {"source_code": "var \n d:array [1..8,1..8] of byte;\n i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;\n s:string;\nBEGIN\nfillchar(d,sizeof(d),0);\nreadln(s);\nn:=1;\nwhile n<=10 do\n begin\n j:=ord(s[n])-96; \n val(s[n+1],i); \n if n=1 then \n begin\n x1:=i;\n y1:=j;\n end\n else if n=4 then\n begin\n x2:=i;\n y2:=j;\n end \n else if n=7 then \n begin\n d[i,j]:=2;\n xx:=i;\n yy:=j;\n if i>1 then d[i-1,j]:=4;\n if i<8 then d[i+1,j]:=4;\n if j>1 then d[i,j-1]:=4;\n if j<8 then d[i,j+1]:=4;\n if (i>1)and(j>1) then d[i-1,j-1]:=4;\n if (i<8)and(j<8) then d[i+1,j+1]:=4;\n if (j>1)and(i<8) then d[i+1,j-1]:=4;\n if (j<8)and(i>1) then d[i-1,j+1]:=4;\n end\n else \n begin \n x:=i;\n y:=j;\n end; \n inc(n,3); \n end;\n\nif x1<>xx then for k:=1 to 8 do d[x1,k]:=4\n else if y1yy then for k:=1 to 8 do d[k,y1]:=4\n else if x1xx then for k:=1 to 8 do d[x2,k]:=4\n else if y2yy then for k:=1 to 8 do d[k,y2]:=4\n else if x21 then \n begin\n if d[x-1,y]=4 then inc(n);\n inc(k);\n end;\n if x<8 then \n begin\n if d[x+1,y]=4 then inc(n);\n inc(k);\n end;\n if y>1 then \n begin\n if d[x,y-1]=4 then inc(n);\n inc(k);\n end;\n if y<8 then \n begin\n if d[x,y+1]=4 then inc(n);\n inc(k);\n end;\n if (x>1)and(y>1) then \n begin\n if d[x-1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (x<8)and(y<8) then \n begin\n if d[x+1,y+1]=4 then inc(n);\n inc(k);\n end;\n if (y>1)and(x<8) then \n begin\n if d[x+1,y-1]=4 then inc(n);\n inc(k);\n end;\n if (y<8)and(x>1) then \n begin\n if d[x-1,y+1]=4 then inc(n);\n inc(k);\n end;\n if n=k then writeln('CHECKMATE') else writeln('OTHER');\n end\nelse writeln('OTHER');\n\n{for i:=1 to 8 do \n begin\n for j:=1 to 8 do \n if d[i,j]=0 then write('- ') else write(d[i,j],' ');\n writeln;\n end;}\nEND."}, {"source_code": "program baib;\n\nconst fi='';\n fo='';\n\nvar f,g:text;\n a,c:array[0..10,0..10]of longint;\n s1,s2,t1,t2,w1,w2,b1,b2:longint;\n\nprocedure enter;\nvar i,j,u:longint;\n ch,cc:char;\nbegin\nassign(f,fi);assign(g,fo);\nreset(f);rewrite(g);\n read(f,ch,u,cc);\n s1:=ord(ch)-ord('a')+1;\n t1:=u;\n read(f,ch,u,cc);\n s2:=ord(ch)-ord('a')+1;\n t2:=u;\n read(f,ch,u,cc);\n w1:=ord(ch)-ord('a')+1;\n w2:=u;\n read(f,ch,u);\n b1:=ord(ch)-ord('a')+1;\n b2:=u;\nend;\n\nprocedure process;\nvar i,j,u,v:longint;\nbegin\nfillchar(a,sizeof(a),255);\nfillchar(c,sizeof(c),0);\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\na[w1,w2]:=-1;\nc[b1,b2]:=2;\nfor i:=-1 to 1 do\n for j:=-1 to 1 do\n c[b1+i,b2+j]:=2;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\n u:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if c[i,j]=2 then u:=1;\nif u=0 then writeln(g,'CHECKMATE')\nelse writeln(g,'OTHER');\nend;\n\nBEgin\n enter;\n process;\n close(g);\nend.\n\n"}, {"source_code": "program baib;\n\nconst fi='';\n fo='';\n\nvar f,g:text;\n a,c:array[0..10,0..10]of longint;\n s1,s2,t1,t2,w1,w2,b1,b2:longint;\n\nprocedure enter;\nvar i,j,u:longint;\n ch,cc:char;\nbegin\nassign(f,fi);assign(g,fo);\nreset(f);rewrite(g);\n read(f,ch,u,cc);\n s1:=ord(ch)-ord('a')+1;\n t1:=u;\n read(f,ch,u,cc);\n s2:=ord(ch)-ord('a')+1;\n t2:=u;\n read(f,ch,u,cc);\n w1:=ord(ch)-ord('a')+1;\n w2:=u;\n read(f,ch,u);\n b1:=ord(ch)-ord('a')+1;\n b2:=u;\nend;\n\nprocedure process;\nvar i,j,u,v:longint;\nbegin\nfillchar(a,sizeof(a),255);\nfillchar(c,sizeof(c),0);\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\na[w1,w2]:=-1;\nc[b1,b2]:=2;\nfor i:=-1 to 1 do\n for j:=-1 to 1 do\n if a[b1+i,b2+j]<>-1 then\n begin\n c[b1+i,b2+j]:=2;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s1;v:=t1;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(u);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n dec(v);\n c[u,v]:=1;\n end;\nu:=s2;v:=t2;\nwhile a[u,v]<>-1 do\n begin\n inc(v);\n c[u,v]:=1;\n end;\n u:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if c[i,j]=2 then u:=1;\nif u=0 then writeln(g,'CHECKMATE')\nelse writeln(g,'OTHER');\nend;\n\nBEgin\n enter;\n process;\n close(g);\nend.\n\n"}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction BK(x1,y1,x2,y2:longint):boolean;\nBegin\n if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)\n then bk:=false\n else bk:=true;\nEnd;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=bk(x2,y2,x3,y3)\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction BK(x1,y1,x2,y2:longint):boolean;\nBegin\n if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)\n then bk:=true\n else bk:=false;\nEnd;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=bk(x2,y2,x3,y3)\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=WK(0,0,x2,y2,x3,y3)\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2) then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)and(y<=0)\n then fi:=true\n else\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2) then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction BK(x1,y1,x2,y2:longint):boolean;\nBegin\n if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)\n then bk:=false\n else bk:=true;\nEnd;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2)\n then wk:=bk(x2,y2,x3,y3)\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n begin\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\n end;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2) then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)and(y<=0)\n or(x<=0)and(y>=9)\n or(x>=9)and(y<=0)\n or(x>=9)and(y>=9)\n then fi:=true\n else\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "type res= record\n x,y:longint;\n end;\nvar n,i,j,k,code:integer;\n f1,f2,f3,f4:boolean;\n s:string;\n kor:array[1..4]Of res;\nFunction WK(x1,y1,x2,y2,x3,y3:longint):boolean;\nBegin\n if (x1=x2)and(y1=y2) then wk:=false\n else\n if (x1=x2) then\n begin\n if (x1=x3) then\n if (y3y1)and(y2>y3)\n then wk:=false\n else wk:=true;\n end\n else wk:=false;\nEnd;\nFunction Fi(x,y:longint):boolean;\nBegin\n if (x<=0)or(y<=0)\n or(y>=9)or(x>=9)\n then fi:=true\n else\n if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)\n or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)\n or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)\n then fi:=true\n else fi:=false;\nEnd;\nBegin\n readln(s);\n j:=1;\n For i:=1 to 11 do\n begin\n val(s[i],k,code);\n if k>0 then kor[j].y:=k;\n if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;\n if (i mod 3)=0 then inc(j);\n end;\n if fi(kor[4].x,kor[4].y)\n then begin\n if fi(kor[4].x+1,kor[4].y)and\n fi(kor[4].x+1,kor[4].y+1)and\n fi(kor[4].x,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y+1)and\n fi(kor[4].x-1,kor[4].y)and\n fi(kor[4].x-1,kor[4].y-1)and\n fi(kor[4].x,kor[4].y-1)and\n fi(kor[4].x+1,kor[4].y-1)\n then writeln('CHECKMATE')\n else writeln('OTHER')\n end\n else writeln('OTHER');\nEnd."}, {"source_code": "program CFR41_A;\nuses\n math;\n\nconst\n nfin= '';\n nfout= '';\n maxn= 30;\n vt:array[1..4,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1));\n\nvar\n d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;\n k1, k2, k3: char;\n fin, fout: text;\n\nfunction check(u, v: longint): boolean;\nbegin\n if ((u<>d1) and (v=c1))then begin\n if c3<>c1 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(u, d1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d1) and (v<>c1))then begin\n if d3<>d1 then begin\n check:=(true);\n exit;\n end;\n if ((c3max(v, c1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u<>d2) and (v=c2))then begin\n if c3<>c2 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(u, d2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d2) and (v<>c2))then begin\n if d3<>d2 then begin\n check:=true;\n exit;\n end;\n if ((c3max(v, c2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if (abs(u-d3) + abs(v-c3) = 1) then begin\n check:=true;\n exit;\n end;\n check:=false;\nend;\n\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n read(fin, k1, k2);\n d1:=ord(k1) - ord('a') + 1;\n c1:=ord(k2) - ord('0');\n\n read(fin, k3, k1, k2);\n d2:=ord(k1) - ord('a') + 1;\n c2:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d3:=ord(k1) - ord('a') + 1;\n c3:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d4:=ord(k1) - ord('a') + 1;\n c4:=ord(k2) - ord('0');\n\n if not check(d4, c4) then begin\n writeln(fout, 'OTHER');\n close(fout);\n close(fin);\n halt;\n end;\n\n for i:=1 to 4 do begin\n u:=d4+vt[i, 1];\n v:=c4+vt[i, 2];\n if (0c1) and (d4<>d1) and (c4<>c2) and (d4<>d2) then begin\n writeln(fout, 'OTHER');\n close(fout);\n close(fin);\n halt;\n end;\n\n for i:=1 to 4 do begin\n u:=d4+vt[i, 1];\n v:=c4+vt[i, 2];\n if (0d1) and (v=c1)) or ((u=d1) and (v<>c1)))\n or (((u<>d2) and (v=c2)) or ((u=d2) and (v<>c2))) ) then begin\n writeln(fout, 'OTHER');\n close(fout);\n close(fin);\n halt;\n end;\n end;\n end;\n\n writeln(fout, 'CHECKMATE');\n close(fout);\n close(fin);\nend.\n"}, {"source_code": "program CFR41_A;\nuses\n math;\n\nconst\n nfin= '';\n nfout= '';\n maxn= 30;\n vt:array[1..4,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1));\n\nvar\n d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;\n k1, k2, k3: char;\n fin, fout: text;\n\nfunction check(u, v: longint): boolean;\nbegin\n if ((u<>d1) and (v=c1))then begin\n if c3<>c1 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(d4, d1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d1) and (v<>c1))then begin\n if d3<>d1 then begin\n check:=(true);\n exit;\n end;\n if ((c3max(c4, c1))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u<>d2) and (v=c2))then begin\n if c3<>c2 then begin\n check:=true;\n exit;\n end;\n\n if ((d3max(d4, d2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if ((u=d2) and (v<>c2))then begin\n if d3<>d2 then begin\n check:=true;\n exit;\n end;\n if ((c3max(c4, c2))) then begin\n check:=true;\n exit;\n end;\n end;\n\n if (abs(u-d3) + abs(v-c3) = 1) then begin\n check:=true;\n exit;\n end;\n check:=false;\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n read(fin, k1, k2);\n d1:=ord(k1) - ord('a') + 1;\n c1:=ord(k2) - ord('0');\n\n read(fin, k3, k1, k2);\n d2:=ord(k1) - ord('a') + 1;\n c2:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d3:=ord(k1) - ord('a') + 1;\n c3:=ord(k2) - ord('0');\n\n read(fin,k3, k1, k2);\n d4:=ord(k1) - ord('a') + 1;\n c4:=ord(k2) - ord('0');\n\n if not check(d4, c4) then begin\n writeln(fout, 'OTHER');\n close(fout);\n close(fin);\n halt;\n end;\n\n for i:=1 to 4 do begin\n u:=d4+vt[i, 1];\n v:=c4+vt[i, 2];\n if (0'.'\n then\n begin\n if b[i,j]='L'\n then\n begin\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(y);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(y);\n end;\n end;\n if b[i,j]='W'\n then\n begin\n if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')\n then\n begin\n exit;\n end;\n end;\n end;\n rez:=false;\n end;\n\n\nprocedure untilprogram;\nvar i,j:longint;\n begin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:='.';\n for i:=0 to 9 do\n begin\n a[i,0]:='#';\n a[i,9]:='#';\n a[0,i]:='#';\n a[9,i]:='#';\n end;\n end;\n\n\nbegin\n\n untilprogram;\n readln(s);\n x:=ord(s[1])-96;\n y:=9-(ord(s[2])-48);\n a[x,y]:='L';\n x:=ord(s[4])-96;\n y:=9-(ord(s[5])-48);\n a[x,y]:='L';\n x:=ord(s[7])-96;\n y:=9-(ord(s[8])-48);\n a[x,y]:='W';\n x:=ord(s[10])-96;\n y:=9-(ord(s[11])-48);\n a[x,y]:='B';\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end\n else\n begin\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0) and (j<>0) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)\n then\n begin\n b:=a;\n b[x,y]:='.'; b[x+i,y+j]:='B';\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end;\n end;\n end;\n writeln('CHECKMATE');\n\nend."}, {"source_code": "var\n a,b:array[0..9,0..9] of char;\n x,y,i,j:longint;\n answer:boolean;\n s:string;\n\n\n\nprocedure proverka(var rez:boolean);\nvar i,j,x,y:longint;\n begin\n rez:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if b[i,j]<>'.'\n then\n begin\n if b[i,j]='L'\n then\n begin\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(y);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(y);\n end;\n end;\n if b[i,j]='W'\n then\n begin\n if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')\n then\n begin\n exit;\n end;\n end;\n end;\n rez:=false;\n end;\n\n\nprocedure untilprogram;\nvar i,j:longint;\n begin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:='.';\n for i:=0 to 9 do\n begin\n a[i,0]:='#';\n a[i,9]:='#';\n a[0,i]:='#';\n a[9,i]:='#';\n end;\n end;\n\n\nbegin\n\n untilprogram;\n readln(s);\n x:=ord(s[1])-96;\n y:=9-(ord(s[2])-48);\n a[x,y]:='L';\n x:=ord(s[4])-96;\n y:=9-(ord(s[5])-48);\n a[x,y]:='L';\n x:=ord(s[7])-96;\n y:=9-(ord(s[8])-48);\n a[x,y]:='W';\n x:=ord(s[10])-96;\n y:=9-(ord(s[11])-48);\n a[x,y]:='B';\n b:=a;\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end\n else\n begin\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if not((i=0) and (j=0)) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)\n then\n begin\n b:=a;\n b[x,y]:='.'; b[x+i,y+j]:='B';\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end;\n end;\n end;\n writeln('CHECKMATE');\n\nend."}, {"source_code": "var\n a,b:array[0..9,0..9] of char;\n x,y,i,j:longint;\n answer:boolean;\n s:string;\n\n\n\nprocedure proverka(var rez:boolean);\nvar i,j,x,y:longint;\n begin\n rez:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if b[i,j]<>'.'\n then\n begin\n if b[i,j]='L'\n then\n begin\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(x);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n inc(y);\n end;\n x:=i; y:=j;\n while b[x,y]<>'#' do\n begin\n if b[x,y]='B' then exit;\n dec(y);\n end;\n end;\n if b[i,j]='W'\n then\n begin\n if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')\n then\n begin\n exit;\n end;\n end;\n end;\n rez:=false;\n end;\n\n\nprocedure untilprogram;\nvar i,j:longint;\n begin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:='.';\n for i:=0 to 9 do\n begin\n a[i,0]:='#';\n a[i,9]:='#';\n a[0,i]:='#';\n a[9,i]:='#';\n end;\n end;\n\n\nbegin\n\n untilprogram;\n readln(s);\n x:=ord(s[1])-96;\n y:=9-(ord(s[2])-48);\n a[x,y]:='L';\n x:=ord(s[4])-96;\n y:=9-(ord(s[5])-48);\n a[x,y]:='L';\n x:=ord(s[7])-96;\n y:=9-(ord(s[8])-48);\n a[x,y]:='W';\n x:=ord(s[10])-96;\n y:=9-(ord(s[11])-48);\n a[x,y]:='B';\n b:=a;\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end\n else\n begin\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if (i<>0) and (j<>0) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)\n then\n begin\n b:=a;\n b[x,y]:='.'; b[x+i,y+j]:='B';\n proverka(answer);\n if answer = false\n then\n begin\n writeln('OTHER');\n halt;\n end;\n end;\n end;\n writeln('CHECKMATE');\n\nend."}, {"source_code": "Program z42b;\ntype byte=integer;\nconst xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);\n\tyy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);\nvar a,c:array[0..9,0..9]of byte;\n\tb:array[1..2,1..4]of byte;\n\tx,y,i,x1,y1,j:byte;\n cc:char;\nbegin\n\tj:=1;\n\tfor i:=2 to 3 do\n begin\t\n \tread(cc);\n x:=ord(cc)-ord('a')+1;\n read(y);\n c[y,x]:=i;\n b[1,j]:=x;\n b[2,j]:=y;\n inc(j);\n read(cc);\n read(cc);\n x1:=ord(cc)-ord('a')+1;\n read(y1);\n c[y1,x1]:=i;\n read(cc);\n b[1,j]:=x1;\n b[2,j]:=y1;\n inc(j);\n end;\n for i:=0 to 9 do\n begin\n \ta[i,0]:=1;\n a[i,9]:=1;\n a[0,i]:=1;\n a[9,i]:=1;\n end;\n for i:=1 to 2 do\n begin\n \tj:=b[1,i]+1;\n while (j<=8)and(c[b[2,i],j]<3) do\n begin\n a[b[2,i],j]:=1;\n inc(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[1,i]-1;\n while (j>0)and(c[b[2,i],j]<3) do\n begin\n \ta[b[2,i],j]:=1;\n dec(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[2,i]+1;\n while (j<=8)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n inc(j);\n end;\n a[j,b[1,i]]:=1;\n j:=b[2,i]-1;\n while (j>0)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n dec(j);\n end;\n a[j,b[1,i]]:=1;\n end;\n for i:=1 to 8 do\n \ta[y+yy[i],x+xx[i]]:=1;\n if a[y1,x1]=1\n then\n begin\n \tfor i:=1 to 8 do\n \t \tif a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;\n write('CHECKMATE');\n end\n else write('OTHER');\nend."}, {"source_code": "Program z42b;\nconst xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);\n\tyy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);\nvar a:array[0..9,0..9]of byte;\n\tb:array[1..2,1..4]of byte;\n\tx,y,i,x1,y1,j:byte;\n c:char;\nbegin\n\tj:=1;\n\tfor i:=2 to 3 do\n begin\t\n \tread(c);\n x:=ord(c)-ord('a')+1;\n read(y);\n {c[y,x]:=i;}\n b[1,j]:=x;\n b[2,j]:=y;\n inc(j);\n read(c);\n read(c);\n x1:=ord(c)-ord('a')+1;\n read(y1);\n {c[y1,x1]:=i;}\n read(c);\n b[1,j]:=x1;\n b[2,j]:=y1;\n inc(j);\n end;\n for i:=0 to 9 do\n begin\n \ta[i,0]:=1;\n a[i,9]:=1;\n a[0,i]:=1;\n a[9,i]:=1;\n end;\n for i:=1 to 2 do\n begin\n \tfor j:=1 to 8 do\n begin\n \tif j<>b[2,i] then a[j,b[1,i]]:=1;\n if j<>b[1,i] then a[b[2,i],j]:=1;\n end;\n end;\n for i:=1 to 8 do\n \ta[y+yy[i],x+xx[i]]:=1;\n if a[y1,x1]=1\n then\n begin\n \tfor i:=1 to 8 do\n \t \tif a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;\n write('CHECKMATE');\n end\n else write('OTHER');\nend."}, {"source_code": "Program z42b;\ntype byte=integer;\nconst xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);\n\tyy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);\nvar a,c:array[0..9,0..9]of byte;\n\tb:array[1..2,1..4]of byte;\n\tx,y,i,x1,y1,j:byte;\n cc:char;\nbegin\n\tj:=1;\n\tfor i:=3 downto 2 do\n begin\t\n \tread(cc);\n x:=ord(cc)-ord('a')+1;\n read(y);\n c[y,x]:=i;\n b[1,j]:=x;\n b[2,j]:=y;\n inc(j);\n read(cc);\n read(cc);\n x1:=ord(cc)-ord('a')+1;\n read(y1);\n c[y1,x1]:=i;\n read(cc);\n b[1,j]:=x1;\n b[2,j]:=y1;\n inc(j);\n end;\n for i:=0 to 9 do\n begin\n \ta[i,0]:=1;\n a[i,9]:=1;\n a[0,i]:=1;\n a[9,i]:=1;\n end;\n for i:=1 to 2 do\n begin\n \tj:=b[1,i]+1;\n while (j<=8)and(c[b[2,i],j]<3) do\n begin\n a[b[2,i],j]:=1;\n inc(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[1,i]-1;\n while (j>0)and(c[b[2,i],j]<3) do\n begin\n \ta[b[2,i],j]:=1;\n dec(j);\n end;\n a[b[2,i],j]:=1;\n j:=b[2,i]+1;\n while (j<=8)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n inc(j);\n end;\n a[j,b[1,i]]:=1;\n j:=b[2,i]-1;\n while (j>0)and(c[j,b[1,i]]<3) do\n begin\n \ta[j,b[1,i]]:=1;\n dec(j);\n end;\n a[j,b[1,i]]:=1;\n end;\n for i:=1 to 8 do\n \ta[y+yy[i],x+xx[i]]:=1;\n if a[y1,x1]=1\n then\n begin\n \tfor i:=1 to 8 do\n \t \tif a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;\n write('CHECKMATE');\n end\n else write('OTHER');\nend."}, {"source_code": "var a,b:array[0..9,0..9]of byte;\n i,x,y,j,k:longint;\n ch:char;\n by:byte;\n s:string;\nbegin\n fillchar(a,sizeof(a),0);\n fillchar(b,sizeof(b),0);\n for i:=0 to 9 do begin\n a[0,i]:=1; a[i,0]:=1;\n a[9,i]:=1; a[i,9]:=1;\n end;\n for i:=1 to 3 do begin\n read(ch);read(by);\n x:=ord(ch)-ord('a')+1;\n y:=by;\n read(ch);\n if i<3 then begin\n b[x,y]:=1;\n for j:=1 to 8 do begin inc(a[x,j]); inc(a[j,y]); end;\n end else begin\n for j:=x-1 to x+1 do\n for k:=y-1 to y+1 do\n inc(a[j,k]);\n end;\n end;\n s:='CHECKMATE';\n read(ch);read(by);\n x:=ord(ch)-ord('a')+1;\n y:=by;\n for i:=x-1 to x+1 do\n for j:=y-1 to y+1 do begin\n if (a[i,j]=0)or((a[i,j]=2) and (b[i,j]=1)) then s:='OTHER';\n end;\n writeln(s);\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar s:string;\n c:char;\n a,b:array[1..4]of integer;\n q:array[0..9,0..9]of integer;\n ans,f,i,j,z:integer;\n g:boolean;\nfunction tower(x1,y1,x2,y2:integer):integer;\nbegin\n if (x1=x2)or(y1=y2) then\n result:=1 else\n result:=0;\nend;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readln(s);\n c:=s[1];\n b[1]:=ord(c)-ord('a')+1;\n val(s[2],a[1],f);\n c:=s[4];\n b[2]:=ord(c)-ord('a')+1;\n val(s[5],a[2],f);\n c:=s[7];\n b[3]:=ord(c)-ord('a')+1;\n val(s[8],a[3],f);\n c:=s[10];\n b[4]:=ord(c)-ord('a')+1;\n val(s[11],a[4],f);\n for i:=0 to 9 do begin\n q[0,i]:=1;\n q[9,i]:=1;\n q[i,0]:=1;\n q[i,9]:=1;\n end; \n for i:=1 to 8 do\n for j:=1 to 8 do\n q[i,j]:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do begin\n if not((i=a[1])and(j=b[1]))then\n q[i,j]:=q[i,j] or tower(i,j,a[1],b[1]);\n if not((i=a[2])and(j=b[2]))then\n q[i,j]:=q[i,j] or tower(i,j,a[2],b[2]);\n end;\n q[a[3],b[3]+1]:=1;\n q[a[3],b[3]-1]:=1;\n q[a[3]+1,b[3]]:=1;\n q[a[3]-1,b[3]]:=1;\n q[a[3]-1,b[3]-1]:=1;\n q[a[3]-1,b[3]+1]:=1;\n q[a[3]+1,b[3]-1]:=1;\n q[a[3]+1,b[3]+1]:=1;\n ans:=(q[a[4],b[4]+1]) and (q[a[4],b[4]-1]) and (q[a[4]+1,b[4]]) and (q[a[4]-1,b[4]]) and (q[a[4]-1,b[4]-1]) and (q[a[4]-1,b[4]+1]) and (q[a[4]+1,b[4]-1]) and (q[a[4]+1,b[4]+1]) and (q[a[4],b[4]]);\n if ans=1 then\n writeln('CHECKMATE') else\n writeln('OTHER'); \nend.\n"}, {"source_code": "{$apptype console}\n\ntype Tpos = record x, y : integer; end;\n\nprocedure readpos( var p : TPos );\nvar ch :char;\nbegin\n read(ch );\n while not (ch in ['a'..'h']) do read( ch );\n p.y := ord(ch) - ord('a' ) + 1;\n read(ch);\n p.x := ord(ch) - ord('0');\nend;\n\nvar l1,l2, wk : TPos;\n\nfunction beaten( xx, yy : integer ): boolean;\nbegin\n result := false;\n if (xx<>l1.x) or( yy<>l1.y) then begin\n if (l1.x = xx) or (l1.y =yy) then begin\n result := true;\n exit;\n end;\n end;\n if (xx<>l2.x) or( yy<>l2.y) then begin\n if (l2.x = xx) or (l2.y =yy) then begin\n result := true;\n exit;\n end;\n end;\n if (xx<>wk.x) or( yy<>wk.y) then begin\n if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin\n result := true;\n exit;\n end;\n end;\nend;\n\nconst v : array [1..8, 1..2] of integer =\n((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));\nvar bk : TPos;\n i, xx,yy : integer;\nbegin\n{ reset( input, 'in.txt' );}\n{}\n ReadPos( l1 );\n ReadPos( l2 );\n ReadPos( wk );\n ReadPos( bk );\n{}\n if not beaten( bk.x, bk.y ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n for i := 1 to 9 do begin\n xx := bk.x + v[i,1];\n yy := bk.y + v[i,2];\n if (xx<1) or (xx>8) or ( yy<1) or (yy>8) then\n continue;\n if not beaten( xx, yy ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n end;\n writeln( 'CHECKMATE');\nend.\n"}, {"source_code": "{$apptype console}\n\ntype Tpos = record x, y : integer; end;\n\nprocedure readpos( var p : TPos );\nvar ch :char;\nbegin\n read(ch );\n while not (ch in ['a'..'h']) do read( ch );\n p.y := ord(ch) - ord('a' ) + 1;\n read(ch);\n p.x := ord(ch) - ord('0');\nend;\n\nvar l1,l2, wk : TPos;\n\nfunction inner( x,a,b : integer ) : boolean;\nvar t : integer;\nbegin\n if a > b then begin t := a; a:=b; b := t; end;\n result := (x>a) and (xwk.x) or( yy<>wk.y) then begin\n if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin\n result := true;\n exit;\n end;\n end;\nend;\n\nconst v : array [1..8, 1..2] of integer =\n((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));\nvar bk : TPos;\n i, xx,yy : integer;\nbegin\n{ reset( input, 'in.txt' );}\n{}\n ReadPos( l1 );\n ReadPos( l2 );\n ReadPos( wk );\n ReadPos( bk );\n{}\n if not beaten( bk.x, bk.y ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n for i := 1 to 9 do begin\n xx := bk.x + v[i,1];\n yy := bk.y + v[i,2];\n if (xx<1) or (xx>8) or ( yy<1) or (yy>8) then\n continue;\n if not beaten( xx, yy ) then begin\n writeln( 'OTHER' );\n exit;\n end;\n end;\n writeln( 'CHECKMATE');\nend.\n"}, {"source_code": "{ uses crt;}\n const nn=50;\n type mas=array [0..nn] of longint;\n var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;\n l1,l2,wk,bk,nk:mas;\n s:real;\n a,b,pr:mas;\n ll1,ll2,wwk,bbk,ll3:char;\n boypol,boy:boolean;\n\n function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l1[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-j)<0)\n then begin bb1:=false; {write('aaa');} end;\n end;\n{ writeln('bb1',bb1);}\n\n bb2:=false;\n if l1[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-i)<0)\n then begin bb2:=false; {write('bbb');} end;\n end;\n\n{ writeln('bb2',bb2); }\n\nboyl1:=bb1 or bb2; if (i=l1[1])and(j=l1[2]) then boyl1:=false;\n\nend;\n\n function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l2[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-j)<0) then bb1:=false; end;\n{ writeln('rrr',bb1); }\n\n bb2:=false;\n if l2[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-i)<0) then bb2:=false; end;\n\n{ writeln('www',bb2); }\n\nboyl2:=bb1 or bb2;\n\nif (i=l2[1])and(j=l2[2]) then boyl2:=false;\n\nend;\n\n\n function boyk(i,j:longint):boolean; var bb1,bb2:boolean;\n begin\n bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1) then bb1:=true;\n boyk:=bb1;\n end;\n\n\n\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'digitsum.out'); rewrite (output); }\n read(ll1);read(ll2);read(ll3);\n l1[1]:=ord(ll1)-96;\n l1[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n l2[1]:=ord(ll1)-96;\n l2[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n wk[1]:=ord(ll1)-96;\n wk[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n bk[1]:=ord(ll1)-96;\n bk[2]:=ord(ll2)-48;\n\n { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');\n }\n{ boy:=true;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then\n begin boypol:=false;\n nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];\n if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1) then boypol:=true;\n if not boypol then boy:=false;\n\n\n\n\n end; }\n\n { writeln;\n for i:=1 to 8 do\n begin for j:=1 to 8 do if boyl1(i,j)\n then write('+') else write('-');writeln; end;\n }\n { writeln(boyl1(1,4)); }\n\n if boy then write('CHECKMATE') else write('OTHER');\n\n\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=50;\n type mas=array [0..nn] of longint;\n var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;\n l1,l2,wk,bk,nk:mas;\n s:real;\n a,b,pr:mas;\n ll1,ll2,wwk,bbk,ll3:char;\n boypol,boy:boolean;\n\n function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l1[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-bk[2])>0)\n then begin bb1:=false; {write('aaa');} end;\n end;\n{ writeln('rrr',bb1);}\n\n bb2:=false;\n if l1[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-bk[1])>0)\n then begin bb2:=false;{ write('bbb');} end;\n end;\n\n{ writeln('www',bb2);}\n\nboyl1:=bb1 or bb2; if (i=l1[1])and(j=l1[2]) then boyl1:=false;\n\nend;\n\n function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;\nbegin\n bb1:=false;\n if l2[1]=i then begin bb1:=true;\n if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-bk[2])>0) then bb1:=false; end;\n{ writeln('rrr',bb1); }\n\n bb2:=false;\n if l2[2]=j then begin bb2:=true;\n if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-bk[1])>0) then bb2:=false; end;\n\n{ writeln('www',bb2); }\n\nboyl2:=bb1 or bb2;\n\nif (i=l2[1])and(j=l2[2]) then boyl2:=false;\n\nend;\n\n\n function boyk(i,j:longint):boolean; var bb1,bb2:boolean;\n begin\n bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1) then bb1:=true;\n boyk:=bb1;\n end;\n\n\n\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'digitsum.out'); rewrite (output); }\n read(ll1);read(ll2);read(ll3);\n l1[1]:=ord(ll1)-96;\n l1[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n l2[1]:=ord(ll1)-96;\n l2[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n wk[1]:=ord(ll1)-96;\n wk[2]:=ord(ll2)-48;\n\n read(ll1);read(ll2);read(ll3);\n bk[1]:=ord(ll1)-96;\n bk[2]:=ord(ll2)-48;\n\n { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');\n }\n boy:=true;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then\n begin boypol:=false;\n nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];\n if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1) then boypol:=true;\n if not boypol then boy:=false;\n\n\n\n\n end;\n { writeln;\n for j:=8 downto 1 do\n begin for i:=1 to 8 do if boyl1(i,j) then write('+') else write('-');writeln; end;\n }\n { writeln(boyl1(2,7)); }\n\n if boy then write('CHECKMATE') else write('OTHER');\n\n\n\n\n end."}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nvar map : array [0..9, 0..9] of boolean;\n c : array [1..4, 1..2] of integer;\n ch : char;\n i, x, y, j : integer;\n ans : boolean;\n\nbegin\n for i := 1 to 4 do\n begin\n read(ch);\n c[i, 1] := ord(ch) - 96;\n read(ch);\n c[i, 2] := ord(ch) - 48;\n read(ch);\n end;\n\n for i := 0 to 9 do\n for j := 0 to 9 do\n map[i, j] := false;\n\n for i := 0 to 9 do\n begin\n map[i, 0] := true;\n map[i, 9] := true;\n map[0, i] := true;\n map[9, i] := true;\n end;\n\n x := c[1, 1];\n y := c[1, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n //-------------------------------\n\n x := c[2, 1];\n y := c[2, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n map[c[3, 2], c[3, 1]] := true;\n\n x := c[4, 1];\n y := c[4, 2];\n\n if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) then writeln('OTHER')\n else writeln('CHECKMATE');\n\n readln;\n readln;\nend.\n\n\n"}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nvar map : array [0..9, 0..9] of boolean;\n c : array [1..4, 1..2] of integer;\n ch : char;\n i, x, y, j : integer;\n ans : boolean;\n\nbegin\n for i := 1 to 4 do\n begin\n read(ch);\n c[i, 1] := ord(ch) - 96;\n read(ch);\n c[i, 2] := ord(ch) - 48;\n read(ch);\n end;\n\n for i := 0 to 9 do\n for j := 0 to 9 do\n map[i, j] := false;\n\n for i := 0 to 9 do\n begin\n map[i, 0] := true;\n map[i, 9] := true;\n map[0, i] := true;\n map[9, i] := true;\n end;\n\n x := c[1, 1];\n y := c[1, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n //-------------------------------\n\n x := c[2, 1];\n y := c[2, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n map[c[3, 2], c[3, 1]] := true;\n\n x := c[4, 1];\n y := c[4, 2];\n\n if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) then writeln('OTHER')\n else writeln('CHEKMATE');\n\n readln;\n readln;\nend.\n\n\n"}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nvar map : array [0..9, 0..9] of boolean;\n c : array [1..4, 1..2] of integer;\n ch : char;\n i, x, y, j : integer;\n ans : boolean;\n\nbegin\n for i := 1 to 4 do\n begin\n read(ch);\n c[i, 1] := ord(ch) - 96;\n read(ch);\n c[i, 2] := ord(ch) - 48;\n read(ch);\n end;\n\n for i := 0 to 9 do\n for j := 0 to 9 do\n map[i, j] := false;\n\n for i := 0 to 9 do\n begin\n map[i, 0] := true;\n map[i, 9] := true;\n map[0, i] := true;\n map[9, i] := true;\n end;\n\n x := c[1, 1];\n y := c[1, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n //-------------------------------\n\n x := c[2, 1];\n y := c[2, 2];\n for i := x + 1 to 8 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := x - 1 downto 1 do\n begin\n if (y = c[3, 2]) and (i = c[3, 1]) then break;\n map[y, i] := true;\n end;\n for i := y + 1 to 8 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n for i := y - 1 downto 1 do\n begin\n if (i = c[3, 2]) and (x = c[3, 1]) then break;\n map[i, x] := true;\n end;\n\n map[c[3, 2], c[3, 1]] := true;\n\n x := c[4, 1];\n y := c[4, 2];\n\n if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) or (not(map[y + 1, x + 1])) or (not(map[y + 1, x - 1])) or (not(map[y - 1, x + 1])) or (not(map[y - 1, x - 1])) then writeln('OTHER')\n else writeln('CHECKMATE');\n\n readln;\n readln;\nend.\n\n\n"}, {"source_code": "program myw;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n type Point = record\n x : longint;\n y : longint;\n end; \n\nvar i,j : longint; s : char;\n a,b,c,d : point;\n mas : array[0..9,0..9] of longint;\nbegin\n read(s);\n a.x:=ord(s)-ord('a')+1;\n read(s);\n a.y:=ord(s)-ord('0');\n read(s);\n read(s);\n b.x:=ord(s)-ord('a')+1;\n read(s);\n b.y:=ord(s)-ord('0');\n read(s);\n read(s);\n c.x:=ord(s)-ord('a')+1;\n read(s);\n c.y:=ord(s)-ord('0');\n read(s);\n read(s);\n d.x:=ord(s)-ord('a')+1;\n read(s);\n d.y:=ord(s)-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n mas[i,j]:=0;\n for i:=1 to 8 do\n begin\n inc(mas[i,a.y]);\n inc(mas[a.x,i]);\n inc(mas[i,b.y]);\n inc(mas[b.x,i]);\n end;\n mas[a.x,a.y]:=10;\n mas[b.x,b.y]:=10;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n inc(mas[c.x+i,c.y+j]);\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)\n and ((mas[d.x+i,d.y+j]=0) or\n ( (mas[d.x+i,d.y+j]>10) and (abs(i+j)<>1) ))\n then begin writeln('OTHER'); exit; end;\n end;\n\n writeln('CHECKMATE');\n {\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(mas[i,j]);\n writeln;\n end; \n\n readln(i); }\nend.\n"}, {"source_code": "program myw;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n type Point = record\n x : longint;\n y : longint;\n end; \n\nvar i,j : longint; s : char;\n a,b,c,d : point;\n mas : array[0..9,0..9] of longint;\nbegin\n read(s);\n a.x:=ord(s)-ord('a')+1;\n read(s);\n a.y:=ord(s)-ord('0');\n read(s);\n read(s);\n b.x:=ord(s)-ord('a')+1;\n read(s);\n b.y:=ord(s)-ord('0');\n read(s);\n read(s);\n c.x:=ord(s)-ord('a')+1;\n read(s);\n c.y:=ord(s)-ord('0');\n read(s);\n read(s);\n d.x:=ord(s)-ord('a')+1;\n read(s);\n d.y:=ord(s)-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n mas[i,j]:=0;\n for i:=1 to 8 do\n begin\n inc(mas[i,a.y]);\n inc(mas[a.x,i]);\n inc(mas[i,b.y]);\n inc(mas[b.x,i]);\n end;\n mas[a.x,a.y]:=0;\n mas[b.x,b.y]:=0;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n inc(mas[c.x+i,c.y+j]);\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)\n and (mas[d.x+i,d.y+j]=0) then begin writeln('OTHER'); exit; end;\n end;\n\n writeln('CHECKMATE');\n\n\nend.\n"}, {"source_code": "program myw;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n type Point = record\n x : longint;\n y : longint;\n end; \n\nvar i,j : longint; s : char;\n a,b,c,d : point;\n mas : array[0..9,0..9] of longint;\nbegin\n read(s);\n a.x:=ord(s)-ord('a')+1;\n read(s);\n a.y:=ord(s)-ord('0');\n read(s);\n read(s);\n b.x:=ord(s)-ord('a')+1;\n read(s);\n b.y:=ord(s)-ord('0');\n read(s);\n read(s);\n c.x:=ord(s)-ord('a')+1;\n read(s);\n c.y:=ord(s)-ord('0');\n read(s);\n read(s);\n d.x:=ord(s)-ord('a')+1;\n read(s);\n d.y:=ord(s)-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n mas[i,j]:=0;\n for i:=1 to 8 do\n begin\n inc(mas[i,a.y]);\n // if (i=d.x) and (a.y=d.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[a.x,i]);\n // if (a.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[i,b.y]);\n // if (i=d.x) and (a.y=b.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[b.x,i]);\n // if (b.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;\n end;\n\n\n\n\n dec(mas[a.x,a.y],2);\n dec(mas[b.x,b.y],2);\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n inc(mas[c.x+i,c.y+j]);\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n if (i=0) and (j=0) then continue;\n if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)\n and (mas[d.x+i,d.y+j]=0) \n then begin writeln('OTHER'); exit; end;\n end;\n\n writeln('CHECKMATE');\n {\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(mas[i,j]);\n writeln;\n end; \n\n readln(i);\n }\nend.\n"}, {"source_code": "program myw;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n type Point = record\n x : longint;\n y : longint;\n end; \n\nvar i,j : longint; s : char;\n a,b,c,d : point;\n mas : array[0..9,0..9] of longint;\nbegin\n read(s);\n a.x:=ord(s)-ord('a')+1;\n read(s);\n a.y:=ord(s)-ord('0');\n read(s);\n read(s);\n b.x:=ord(s)-ord('a')+1;\n read(s);\n b.y:=ord(s)-ord('0');\n read(s);\n read(s);\n c.x:=ord(s)-ord('a')+1;\n read(s);\n c.y:=ord(s)-ord('0');\n read(s);\n read(s);\n d.x:=ord(s)-ord('a')+1;\n read(s);\n d.y:=ord(s)-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n mas[i,j]:=0;\n for i:=1 to 8 do\n begin\n inc(mas[i,a.y]);\n // if (i=d.x) and (a.y=d.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[a.x,i]);\n // if (a.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[i,b.y]);\n // if (i=d.x) and (a.y=b.y) then begin writeln('CHECKMATE'); exit; end;\n inc(mas[b.x,i]);\n // if (b.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;\n end;\n\n\n\n\n dec(mas[a.x,a.y],2);\n dec(mas[b.x,b.y],2);\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n inc(mas[c.x+i,c.y+j]);\n end;\n for i:=-1 to 1 do\n for j:=-1 to 1 do\n begin\n // if (i=0) and (j=0) then continue;\n if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)\n and (mas[d.x+i,d.y+j]=0) \n then begin writeln('OTHER'); exit; end;\n end;\n\n writeln('CHECKMATE');\n {\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(mas[i,j]);\n writeln;\n end; \n\n readln(i);\n }\nend.\n"}, {"source_code": "type c=record\n x,y:byte;\n end;\nvar j,i,k,a2,b2,c2,d2,a1,b1,c1,d1,a3,a4,b3,b4,c3,c4,d3,d4:byte;\n s,l:string;\n m:array[0..9,0..9] of boolean;\n l1,l2,k1,k2:c;\nbegin\nreadln(l);\nfor i:=0 to 9 do\n for j:=0 to 9 do\n m[i,j]:=true;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n m[i,j]:=false;\ns:='abcdefgh';\nl1.x:=pos(l[1],s);\nl1.y:=ord(l[2])-48;\nl2.x:=pos(l[4],s);\nl2.y:=ord(l[5])-48;\nk1.x:=pos(l[7],s);\nk1.y:=ord(l[8])-48;\nk2.x:=pos(l[10],s);\nk2.y:=ord(l[11])-48;\nif l1.x=k1.x then\n if l1.y>k1.y then begin\n a1:=k1.y+1; b1:=l1.y-1;c1:=l1.y+1;d1:=9;\n end\n else begin\n a1:=1;b1:=l1.y-1;c1:=l1.y+1;d2:=k1.y-1;\n end\nelse begin\n a1:=1;b1:=l1.y-1;c1:=l1.y+1;d2:=9;\nend;\nif l1.y=k1.y then\n if l1.x>k1.x then begin\n a2:=k1.x+1; b2:=l1.x-1;c2:=l1.x+1;d2:=9;\n end\n else begin\n a2:=1;b2:=l1.x-1;c2:=l1.x+1;d2:=k1.x-1;\n end\nelse begin\n a2:=1;b2:=l1.x-1;c2:=l1.x+1;d2:=9;\nend;\n\nif l2.x=k1.x then\n if l2.y>k1.y then begin\n a4:=k1.y+1; b4:=l2.y-1;c4:=l2.y+1;d4:=9;\n end\n else begin\n a4:=1;b4:=l2.y-1;c4:=l2.y+1;d4:=k1.y-1;\n end\nelse begin\n a4:=1;b4:=l2.y-1;c4:=l2.y+1;d4:=9;\nend;\nif l2.y=k1.y then\n if l2.x>k1.x then begin\n a3:=k1.x+1; b3:=l2.x-1;c3:=l2.x+1;d3:=9;\n end\n else begin\n a3:=1;b3:=l2.x-1;c3:=l2.x+1;d3:=k1.x-1;\n end\nelse begin\n a3:=1;b3:=l2.x-1;c2:=l2.x+1;d3:=9;\nend;\n\nfor i:=a2 to b2 do\n m[i,l1.y]:=true;\nfor i:=c2 to d2 do\n m[i,l1.y]:=true;\nfor i:=a1 to b1 do\n m[l1.x,i]:=true;\nfor i:=c1 to d1 do\n m[l1.x,i]:=true;\nfor i:=a3 to b3 do\n m[i,l2.y]:=true;\nfor i:=c3 to d3 do\n m[i,l2.y]:=true;\nfor i:=a4 to b4 do\n m[l2.x,i]:=true;\nfor i:=c4 to d4 do\n m[l2.x,i]:=true;\nfor i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n m[i,j]:=true;\nif (m[k2.x+1,k2.y+1]=true) and (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then\n s:='CHECKMATE'\n else s:='OTHER';\nwriteln(s);\nend."}, {"source_code": "type c=record\n x,y:byte;\n end;\nvar j,i,k:byte;\n s,l:string;\n m:array[0..9,0..9] of boolean;\n l1,l2,k1,k2:c;\nbegin\nreadln(l);\nfor i:=0 to 9 do\n for j:=0 to 9 do\n m[i,j]:=true;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n m[i,j]:=false;\ns:='abcdefgh';\nl1.x:=pos(l[1],s);\nl1.y:=ord(l[2])-48;\nl2.x:=pos(l[4],s);\nl2.y:=ord(l[5])-48;\nk1.x:=pos(l[7],s);\nk1.y:=ord(l[8])-48;\nk2.x:=pos(l[10],s);\nk2.y:=ord(l[11])-48;\nfor i:=1 to l1.x-1 do\n m[i,l1.y]:=true;\nfor i:=l1.x+1 to 9 do\n m[i,l1.y]:=true;\nfor i:=1 to l1.y-1 do\n m[l1.x,i]:=true;\nfor i:=l1.y+1 to 9 do\n m[l1.x,i]:=true;\nfor i:=1 to l2.x-1 do\n m[i,l2.y]:=true;\nfor i:=l2.x+1 to 9 do\n m[i,l2.y]:=true;\nfor i:=1 to l2.y-1 do\n m[l2.x,i]:=true;\nfor i:=l2.y+1 to 9 do\n m[l2.x,i]:=true;\nfor i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n m[i,j]:=true;\nif (m[k2.x+1,k2.y+1]=true) and (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then\n s:='CHECKMATE'\n else s:='OTHER';\nwriteln(s);\nend."}, {"source_code": "type c=record\n x,y:byte;\n end;\nvar j,i,k:byte;\n s,l:string;\n m:array[0..9,0..9] of boolean;\n l1,l2,k1,k2:c;\nbegin\nreadln(l);\nfor i:=0 to 9 do\n for j:=0 to 9 do\n m[i,j]:=true;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n m[i,j]:=false;\ns:='abcdefgh';\nl1.x:=pos(l[1],s);\nl1.y:=ord(l[2])-48;\nl2.x:=pos(l[4],s);\nl2.y:=ord(l[5])-48;\nk1.x:=pos(l[7],s);\nk1.y:=ord(l[8])-48;\nk2.x:=pos(l[10],s);\nk2.y:=ord(l[11])-48;\nfor i:=1 to l1.x-1 do\n m[i,l1.y]:=true;\nfor i:=l1.x+1 to 9 do\n m[i,l1.y]:=true;\nfor i:=1 to l1.y-1 do\n m[l1.x,i]:=true;\nfor i:=l1.y+1 to 9 do\n m[l1.x,i]:=true;\nfor i:=1 to l2.x-1 do\n m[i,l2.y]:=true;\nfor i:=l2.x+1 to 9 do\n m[i,l2.y]:=true;\nfor i:=1 to l2.y-1 do\n m[l2.x,i]:=true;\nfor i:=l2.y+1 to 9 do\n m[l2.x,i]:=true;\nfor i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n m[i,j]:=true;\nif (m[k2.x+1,k2.y+1]=true) and (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then\n s:='CHECKMATE'\n else s:='OTHER';\nwriteln(s);\nend."}, {"source_code": "type c=record\n x,y:byte;\n end;\nvar j,i,k:byte;\n s,l:string;\n m:array[0..9,0..9] of boolean;\n l1,l2,k1,k2:c;\nbegin\nreadln(l);\nfor i:=0 to 9 do\n for j:=0 to 9 do\n m[i,j]:=true;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n m[i,j]:=false;\ns:='abcdefgh';\nl1.x:=pos(l[1],s);\nl1.y:=ord(l[2])-48;\nl2.x:=pos(l[4],s);\nl2.y:=ord(l[5])-48;\nk1.x:=pos(l[7],s);\nk1.y:=ord(l[8])-48;\nk2.x:=pos(l[10],s);\nk2.y:=ord(l[11])-48;\nfor i:=1 to l1.x-1 do\n m[i,l1.y]:=true;\nfor i:=l1.x+1 to 9 do\n m[i,l1.y]:=true;\nfor i:=1 to l1.y-1 do\n m[l1.x,i]:=true;\nfor i:=l1.y+1 to 9 do\n m[l1.x,i]:=true;\nfor i:=1 to l2.x-1 do\n m[i,l2.y]:=true;\nfor i:=l2.x+1 to 9 do\n m[i,l2.y]:=true;\nfor i:=1 to l2.y-1 do\n m[l2.x,i]:=true;\nfor i:=l2.y+1 to 9 do\n m[l2.x,i]:=true;\nfor i:=k1.x-1 to k1.x+1 do\n for j:=k1.y-1 to k1.y+1 do\n m[i,j]:=true;\nif (m[k2.x+1,k2.y+1]=true) and (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then\n s:='CHECKMATE'\n else s:='OTHER';\nwriteln(s);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array[1..10,1..10]of Longint;\n s:String;\n x,y,x1,y1,x2,y2,x3,y3,i:Longint;\n\nbegin\n //Reset(Input,'in.txt');\n //Rewrite(Output,'out.txt');\n Read(s);\n FillChar(a,sizeof(a),0);\n for i:=1 to 10 do\n begin\n a[1,i]:=-1;\n a[i,10]:=-1;\n a[10,i]:=-1;\n a[i,1]:=-1;\n end;\n x:=ord(s[1])-48-47;\n y:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x,y]:=1;\n x1:=ord(s[1])-48-47;\n y1:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x1,y1]:=1;\n x2:=ord(s[1])-48-47;\n y2:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x2,y2]:=2;\n x3:=ord(s[1])-48-47;\n y3:=StrToInt(s[2])+1;\n for i:=x+1 to 9 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=x-1 downto 2 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=y+1 to 9 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n for i:=y-1 downto 2 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n\n for i:=x1+1 to 9 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=x1-1 downto 2 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=y1+1 to 9 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n for i:=y1-1 downto 2 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n a[x3,y2]:=3;\n a[x2-1,y2]:=-1;\n a[x2+1,y2]:=-1;\n a[x2,y2-1]:=-1;\n a[x2,y2+1]:=-1;\n a[x2-1,y2-1]:=-1;\n a[x2-1,y2+1]:=-1;\n a[x2+1,y2-1]:=-1;\n a[x2+1,y2+1]:=-1;\n if (a[x3-1,y3]<>-1)or(a[x3+1,y3]<>-1)or\n (a[x3,y3-1]<>-1)or(a[x3,y3+1]<>-1)or\n (a[x3-1,y3-1]<>-1)or(a[x3-1,y3+1]<>-1)or\n (a[x3+1,y3-1]<>-1)or(a[x3+1,y3-1]<>-1)then\n Write('OTHER')else Write('CHECKMATE');\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array[1..10,1..10]of Longint;\n s:String;\n x,y,x1,y1,x2,y2,x3,y3,i:Longint;\n\nbegin\n //Reset(Input,'in.txt');\n //Rewrite(Output,'out.txt');\n Read(s);\n FillChar(a,sizeof(a),0);\n for i:=1 to 10 do\n begin\n a[1,i]:=-1;\n a[i,10]:=-1;\n a[10,i]:=-1;\n a[i,1]:=-1;\n end;\n x:=ord(s[1])-48-47;\n y:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x,y]:=1;\n x1:=ord(s[1])-48-47;\n y1:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x1,y1]:=1;\n x2:=ord(s[1])-48-47;\n y2:=StrToInt(s[2])+1;\n Delete(s,1,3);\n a[x2,y2]:=2;\n x3:=ord(s[1])-48-47;\n y3:=StrToInt(s[2])+1;\n for i:=x+1 to 9 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=x-1 downto 2 do\n if a[i,y]=2 then break else\n a[i,y]:=-1;\n for i:=y+1 to 9 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n for i:=y-1 downto 2 do\n if a[x,i]=2 then break else\n a[x,i]:=-1;\n\n for i:=x1+1 to 9 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=x1-1 downto 2 do\n if a[i,y1]=2 then break else\n a[i,y1]:=-1;\n for i:=y1+1 to 9 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n for i:=y1-1 downto 2 do\n if a[x1,i]=2 then break else\n a[x1,i]:=-1;\n a[x3,y2]:=3;\n if (a[x3-1,y3]<>-1)or(a[x3+1,y3]<>-1)or\n (a[x3,y3-1]<>-1)or(a[x3,y3+1]<>-1)or\n (a[x3-1,y3-1]<>-1)or(a[x3-1,y3+1]<>-1)or\n (a[x3+1,y3-1]<>-1)or(a[x3+1,y3-1]<>-1)then\n Write('OTHER')else Write('CHECKMATE');\nend.\n "}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n f:boolean;\n\nbegin\n // ������ ������, ������� ������� �����\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n // \"������\" ������ �� �����, ��������� ����� �� ��������� 1-��\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n // \"���������\" ������, �������������� 1-� ������\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n // \"���������\" ������, �������������� 2-� ������\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n // \"���������\" ������, �������������� ��������� �������\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n // ��������� ����������� ����\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if f then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend.\n"}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n di:array[1..8] of byte=(8,7,6,5,4,3,2,1);\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n s,f:boolean;\n\nbegin\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do begin\n if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n if di[i]=StrToInt(copy(st,2,1)) then fig[k,1]:=i;\n end;\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n s:=false;\n i:=fig[1,1]-1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;\n end;\n i:=fig[2,1]-1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;\n end;\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n s,f:boolean;\n\nbegin\n\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n\n s:=false;\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;\n end;\n\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;\n end;\n\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n f:boolean;\n\nbegin\n // ×èòàåì ñòðîêó, íàõîäèì èíäåêñû ôèãóð\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n // \"Ñòàâèì\" ôèãóðû íà äîñêó, çàïîëíÿåì äîñêó ïî ïåðèìåòðó 1-ìè\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n // \"Çàêðûâàåì\" êëåòêè, êîíòðîëèðóåìûå 1-é ëàäüåé\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n j:=j+1;\n end;\n // \"Çàêðûâàåì\" êëåòêè, êîíòðîëèðóåìûå 2-é ëàäüåé\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n j:=j+1;\n end;\n // \"Çàêðûâàåì\" êëåòêè, êîíòðîëèðóåìûå âðàæåñêèì êîðîëåì\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n // Ïðîâåðÿåì âîçìîæíîñòü õîäà\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if f then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n f:boolean;\n\nbegin\n // ������ ������, ������� ������� �����\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n // \"������\" ������ �� �����, ��������� ����� �� ��������� 1-��\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n // \"���������\" ������, �������������� 1-� ������\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n // \"���������\" ������, �������������� 2-� ������\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n // \"���������\" ������, �������������� ��������� �������\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n // ��������� ����������� ����\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if f then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend.\n"}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('h','g','f','e','d','c','b','a');\n i,j,k,t1,t2:integer;\n st:string;\n s,f:boolean;\n\nbegin\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n s:=false;\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;\n end;\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;\n end;\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n f:boolean;\n\nbegin\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n fig[k,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n i:=fig[1,1]-1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n i:=fig[2,1]-1; j:=fig[2,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then i:=i-2 else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then i:=i+2 else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then j:=j-2 else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then i:=j+2 else j:=j+1;\n end;\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if f then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n di:array[1..8] of byte=(8,7,6,5,4,3,2,1);\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n s,f:boolean;\n\nbegin\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do begin\n if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n if di[i]=StrToInt(copy(st,2,1)) then fig[k,1]:=i;\n end;\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n s:=false;\n i:=fig[1,1]-1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;\n end;\n i:=fig[2,1]-1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;\n end;\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,l,i1,j1,k:integer;\n st:string;\n a:char;\n\nbegin\n readln(st);\n st:=st+' ';\n for l:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[l,2]:=i;\n fig[l,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=1;\n d[fig[2,1],fig[2,2]]:=1;\n d[fig[3,1],fig[3,2]]:=2;\n d[fig[4,1],fig[4,2]]:=5;\n for i:=1 to 8 do\n for j:=1 to 8 do begin\n if d[i,j]=1 then begin\n for i1:=1 to 8 do if d[i1,j]=0 then d[i1,j]:=3;\n for j1:=1 to 8 do if d[i,j1]=0 then d[i,j1]:=3;\n if d[i,j]=2 then begin\n if d[i-1,j-1]=0 then d[i-1,j-1]:=4;\n if d[i-1,j]=0 then d[i-1,j]:=4;\n if d[i-1,j+1]=0 then d[i-1,j+1]:=4;\n if d[i,j-1]=0 then d[i,j-1]:=4;\n if d[i,j+1]=0 then d[i,j+1]:=4;\n if d[i+1,j-1]=0 then d[i+1,j-1]:=4;\n if d[i+1,j]=0 then d[i+1,j]:=4;\n if d[i+1,j+1]=0 then d[i+1,j+1]:=4;\n end;\n end;\n end;\n k:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if d[i,j]=5 then begin\n if (d[i-1,j-1]=0) and (i<>1) and (j<>1) then k:=k+1;\n if (d[i-1,j]=0) and (i<>1) then k:=k+1;\n if (d[i-1,j+1]=0) and (i<>1) and (j<>8) then k:=k+1;\n if (d[i,j-1]=0) and (j<>1) then k:=k+1;\n if (d[i,j+1]=0) and (j<>8) then k:=k+1;\n if (d[i+1,j-1]=0) and (i<>8) and (j<>1) then k:=k+1;\n if (d[i+1,j]=0) and (i<>8) then k:=k+1;\n if (d[i+1,j+1]=0) and (i<>8) and (j<>8) then k:=k+1;\n end;\n if k>0 then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n di:array[1..8] of byte=(8,7,6,5,4,3,2,1);\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,k,t1,t2:integer;\n st:string;\n s,f:boolean;\n\nbegin\n readln(st);\n st:=st+' ';\n for k:=1 to 4 do\n begin\n for i:=1 to 8 do begin\n if ch[i]=copy(st,1,1) then fig[k,2]:=i;\n if di[i]=StrToInt(copy(st,2,1)) then fig[k,1]:=i;\n end;\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=2;\n d[fig[2,1],fig[2,2]]:=2;\n d[fig[3,1],fig[3,2]]:=3;\n d[fig[4,1],fig[4,2]]:=4;\n for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;\n for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;\n s:=false;\n i:=fig[1,1]-1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[1,1]+1; j:=fig[1,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[1,1]; j:=fig[1,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[1,1]; j:=fig[1,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;\n end;\n i:=fig[2,1]-1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;\n end;\n i:=fig[2,1]+1; j:=fig[2,2];\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;\n end;\n i:=fig[2,1]; j:=fig[2,2]-1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;\n end;\n i:=fig[2,1]; j:=fig[2,2]+1;\n if d[i,j]=2 then d[i,j]:=5;\n while (d[i,j]=0) or (d[i,j]=1) do\n begin\n d[i,j]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;\n end;\n i:=fig[3,1]; j:=fig[3,2];\n if d[i,j-1]=0 then d[i,j-1]:=1;\n if d[i,j-1]=2 then d[i,j-1]:=5;\n if d[i,j+1]=0 then d[i,j+1]:=1;\n if d[i,j+1]=2 then d[i,j+1]:=5;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if d[i-1,j]=0 then d[i-1,j]:=1;\n if d[i+1,j]=0 then d[i+1,j]:=1;\n if d[i-1,j]=2 then d[i-1,j]:=5;\n if d[i+1,j]=2 then d[i+1,j]:=5;\n end;\n i:=fig[4,1]; j:=fig[4,2];\n f:=false;\n if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;\n if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;\n t1:=j-1; t2:=j+1;\n for j:=t1 to t2 do begin\n if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;\n if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;\n end;\n if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program b41;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar d:array[0..9,0..9] of integer;\n fig:array[1..4,1..2] of integer;\n ch:array[1..8] of char=('a','b','c','d','e','f','g','h');\n i,j,l,i1,j1,k:integer;\n st:string;\n\nbegin\n readln(st);\n st:=st+' ';\n for l:=1 to 4 do\n begin\n for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[l,2]:=i;\n fig[l,1]:=StrToInt(copy(st,2,1));\n delete(st,1,3);\n end;\n d[fig[1,1],fig[1,2]]:=1;\n d[fig[2,1],fig[2,2]]:=1;\n d[fig[3,1],fig[3,2]]:=2;\n d[fig[4,1],fig[4,2]]:=5;\n for i:=1 to 8 do\n for j:=1 to 8 do begin\n if d[i,j]=1 then begin\n i1:=i+1;\n while (d[i1,j]=0) and (i1>8) do begin d[i1,j]:=3; i1:=i1+1; end;\n i1:=i-1;\n while (d[i1,j]=0) and (i1<1) do begin d[i1,j]:=3; i1:=i1-1; end;\n j1:=j+1;\n while (d[i,j1]=0) and (j1>8) do begin d[i,j1]:=3; j1:=j1+1; end;\n j1:=j-1;\n while (d[i,j1]=0) and (j1<1) do begin d[i,j1]:=3; j1:=j1-1; end;\n if d[i,j]=2 then begin\n if d[i-1,j-1]=0 then d[i-1,j-1]:=4;\n if d[i-1,j]=0 then d[i-1,j]:=4;\n if d[i-1,j+1]=0 then d[i-1,j+1]:=4;\n if d[i,j-1]=0 then d[i,j-1]:=4;\n if d[i,j+1]=0 then d[i,j+1]:=4;\n if d[i+1,j-1]=0 then d[i+1,j-1]:=4;\n if d[i+1,j]=0 then d[i+1,j]:=4;\n if d[i+1,j+1]=0 then d[i+1,j+1]:=4;\n end;\n end;\n end;\n k:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if d[i,j]=5 then begin\n if (d[i-1,j-1]=0) and (i<>1) and (j<>1) then k:=k+1;\n if (d[i-1,j]=0) and (i<>1) then k:=k+1;\n if (d[i-1,j+1]=0) and (i<>1) and (j<>8) then k:=k+1;\n if (d[i,j-1]=0) and (j<>1) then k:=k+1;\n if (d[i,j+1]=0) and (j<>8) then k:=k+1;\n if (d[i+1,j-1]=0) and (i<>8) and (j<>1) then k:=k+1;\n if (d[i+1,j]=0) and (i<>8) then k:=k+1;\n if (d[i+1,j+1]=0) and (i<>8) and (j<>8) then k:=k+1;\n end;\n if k>0 then writeln('OTHER') else writeln('CHECKMATE');\n readln;\nend."}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\n{$R+}\nuses\nSysUtils;\nvar\ne,w,i,j,x1,x2,x3,x4,y1,y2,y3,y4,y,x:longint;\nz:boolean;\ns:string;\nprocedure svoboda;\nbegin\n write('OTHER');\n halt(0);\nend;\nbegin\n//reset(input,'input.txt');rewrite(output,'output.txt');\nread(s);\nx1:=ord(s[1])-96;\ny1:=strtoint(s[2]);\nx2:=ord(s[4])-96;\ny2:=strtoint(s[5]);\nx3:=ord(s[7])-96;\ny3:=strtoint(s[8]);\nx:=ord(s[10])-96;\ny:=strtoint(s[11]);\n\nif x1<>x then\nif x2<>x then\nif y1<>y then\nif y2<>y then svoboda;\n\nfor i:=y-1 to y+1 do\nfor j:=x-1 to x+1 do\nif i>0 then\nif i<9 then\nif j>0 then\nif j<9 then \nbegin\nz:=true;\nfor w:=i-1 to i+1 do\nfor e:=j-1 to j+1 do\nif w=y3 then\nif e=x3 then z:=false;\nif(i=y1)or(j=x1)then\nif i+j<>x1+y1 then z:=false;\nif(i=y2)or(j=x2)then\nif i+j<>x2+y2 then z:=false;\nif z then svoboda;\nend;\n\nwrite('CHECKMATE');\nend. \n"}, {"source_code": "program pjb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n iCnt,iRook1Y,iRook2Y,iKing1Y,iKing2Y: integer;\n cCnt,cRook1X,cRook2X,cKing1X,cKing2X: char;\n sTemp: string;\n bCheckmate: boolean;\n baArea: array ['a'..'z',0..9] of boolean;\n\nfunction Ic(c1: char; i1: integer): char;\nvar\n cREsult: char;\nbegin\n case i1 of\n 1:\n begin\n case c1 of\n 'a': cResult := 'b';\n 'b': cResult := 'c';\n 'c': cResult := 'd';\n 'd': cResult := 'e';\n 'e': cResult := 'f';\n 'f': cResult := 'g';\n 'g': cResult := 'h';\n 'h': cResult := 'h';\n end;\n end;\n -1:\n begin\n case c1 of\n 'a': cResult := 'a';\n 'b': cResult := 'a';\n 'c': cResult := 'b';\n 'd': cResult := 'c';\n 'e': cResult := 'd';\n 'f': cResult := 'e';\n 'g': cResult := 'f';\n 'h': cResult := 'g';\n end;\n end;\n end;\n Ic := cResult;\nend;\n\nbegin\n Readln(sTemp);\n cRook1X := sTemp[1];\n iRook1Y := Strtoint(sTemp[2]);\n cRook2X := sTemp[4];\n iRook2Y := Strtoint(sTemp[5]);\n cKing1X := sTemp[7];\n iKing1Y := Strtoint(sTEmp[8]);\n cKIng2X := sTEmp[10];\n iKing2Y := Strtoint(sTEmp[11]);\n for cCnt := 'a' to 'z' do baArea[cCnt,0] := true;\n for cCnt := 'a' to 'z' do baArea[cCnt,9] := true;\n\n for iCnt := 1 to 8 do if (iCnt <> iRook1Y) then baArea[cRook1X,iCnt] := true;\n for iCnt := 1 to 8 do if (iCnt <> iRook2Y) then baArea[cRook2X,iCnt] := true;\n for cCnt := 'a' to 'z' do if (cCnt <> cRook1X) then baArea[cCnt,iRook1Y] := true;\n for cCnt := 'a' to 'z' do if (cCnt <> cRook2X) then baArea[cCnt,iRook2Y] := true;\n baArea[Ic(cKing1X,-1),iKing1Y] := true;\n baArea[Ic(cKing1X,1),iKing1Y] := true;\n baArea[cKing1X,iKing1Y - 1] := true;\n baArea[cKing1X,iKing1Y + 1] := true;\n baArea[Ic(cKing1X,-1),iKing1Y - 1] := true;\n baArea[Ic(cKing1X,-1),iKing1Y + 1] := true;\n baArea[Ic(cKing1X,1),iKing1Y - 1] := true;\n baArea[Ic(cKing1X,1),iKing1Y + 1] := true;\n\n bCheckmate := true;\n if (baArea[Ic(cKing2X,-1),iKing2Y] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,-1),iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,-1),iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y - 1] = false)\n then bCheckmate := false;\n if (baArea[Ic(cKing2X,1),iKing2Y + 1] = false)\n then bCheckmate := false;\n if (baArea[cKing2X,iKing2Y] = false)\n then bCheckmate := false;\n\n if (bCheckmate = true)\n then Writeln('CHECKMATE')\n else Writeln('OTHER');\nend.\n"}], "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3"} {"source_code": "VAR\n i,t,j : longint;\n x,a : array[0..3] of longint;\n\nBEGIN\n read(a[1],a[2],a[3]);\n read(x[1],x[2],x[3]);\n for i := 1 to 3 do begin\n a[i] := a[i]- x[i];\n if a[i] > 0 then t := t + a[i] div 2;\n if a[i] < 0 then j := j+a[i];\n end;\n if t + j>=0 then write('Yes')\n else write('No');\nEND.", "positive_code": [{"source_code": "\nconst\n tfi='606a.inp';\n tfo='606A.out';\n\nvar\n fi, fo: text;\n a, b: array[1..3] of longint;\n\nprocedure __;\nvar\n can, du, i: longint;\nbegin\n \n readln( a[1], a[2], a[3]);\n readln( b[1], b[2], b[3]);\n can := 0; du := 0;\n for i:=1 to 3 do\n if a[i]>b[i] then\n du := du+((a[i]-b[i]) div 2)\n else can := can+b[i]-a[i];\n if du>=can then write('Yes')\n else write('No');\nend;\n\nprocedure _;\nbegin\n \nend;\n\nBEGIN\n __;\n _;\nEND."}, {"source_code": "uses math;\nvar a,b,c,x,y,z,a1,b1,c1,s,k:int64;\n\nbegin\n read(a,b,c);\n read(x,y,z);\n a1:=a-x;\n b1:=b-y;\n c1:=c-z;\n if (a1>0) and (b1>0) and (c1>0 ) then begin writeln('Yes');exit;end;\n if (a1<0) and (b1<0) and (c1<0) then begin writeln('No');exit;end;\n if a1>0 then s:=s+a1 div 2;\n if b1>0 then s:=s+b1 div 2;\n if c1>0 then s:=s+c1 div 2;\n if a1<0 then k:=k+a1;\n if b1<0 then inc(k,b1);\n if c1<0 then inc(k,c1);\n if (s>=abs(k)) then begin writeln('Yes');exit;end;\n writeln('No');\nend."}, {"source_code": "var\n a,b,c,x,y,z:longint;\n f:boolean;\n \nBEGIN\n readln(a,b,c);\n read(x,y,z);\n \n f:=true;\n \n while(f) do begin\n f:=false;\n if(a=y) then \n begin\n dec(b,2);\n inc(a);\n f:=true;\n end;\n \n if(a=z) then \n begin\n dec(c,2);\n inc(a);\n f:=true;\n end;\n \n if(b=x) then \n begin\n dec(a,2);\n inc(b);\n f:=true;\n end;\n \n if(b=z) then \n begin\n dec(c,2);\n inc(b);\n f:=true;\n end;\n \n if(c=y) then \n begin\n dec(b,2);\n inc(c);\n f:=true;\n end;\n \n if(c=x) then \n begin\n dec(a,2);\n inc(c);\n f:=true;\n end;\n end;\n \n if(a>=x)and(b>=y)and(c>=z) then write('Yes')\n else write('No');\nEND. \n "}, {"source_code": "var a,b,c,x,y,z,s,s1:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\n s:=0;s1:=0;\n if a>=x then s:=(a-x) div 2+s ;\n if b>=y then s:=(b-y) div 2+s;\n if c>=z then s:=(c-z) div 2 +s;\n if a<=x then s1:=(x-a) +s1 ;\n if b<=y then s1:=(y-b) +s1;\n if c<=z then s1:=(z-c) +s1;\n if s>=s1 then writeln('Yes')\n else writeln('No'); \n\n end."}, {"source_code": "program magic;\ntype\n tab= array[1..3] of longint;\n var\n t,v:tab;\n\n s,x,y,i,j:integer;\n\n bb:boolean;\n\n\n begin\n\n s:=0;\n readln(t[1],t[2],t[3]);\n readln(v[1],v[2],v[3]);\n\n for i := 1 to 3 do\n begin\n x:=1;\n y:=1;\n for j:= 2 to 3 do\n begin\n if t[j]-v[j]>t[x]-v[x] then\n x:=j\n else if t[j]-v[j]<=t[y]-v[y] then\n y:=j;\n end;\n while (t[x]>=v[x]+2) and (t[y]t[i] then\n bb:=true;\n\n if bb=true then\n writeln('No')\n else\n writeln('Yes');\n\n end.\n"}, {"source_code": "var i,n,a,b,c,a1,b1,c1,ans,r,otv:longint;\nbegin\nreadln(a,b,c);\nreadln(a1,b1,c1);\nif (a>a1) then\n begin\n r:=abs(a-a1);\n a:=a-r;\n ans:=ans+(r div 2);\n end;\nif (b>b1) then\n begin\n r:=abs(b-b1);\n b:=b-r;\n ans:=ans+(r div 2);\n end;\nif (c>c1) then\n begin\n r:=abs(c-c1);\n c:=c-r;\n ans:=ans+(r div 2);\n end;\notv:=abs(a-a1)+abs(b-b1)+abs(c-c1);\nif (otv<=ans) then writeln('Yes') else writeln('No');\n\n\nend."}, {"source_code": "Program _606A;\nvar\n a, b, c, d, e, x, y, z : longint;\nbegin\n read(a, b, c, x, y, z);\n a := a - x; b := b - y; c := c - z; d := 0; e := 0;\n if a > 0\n then d := d + a div 2\n else e := e + a;\n if b > 0\n then d := d + b div 2\n else e := e + b;\n if c > 0\n then d := d + c div 2\n else e := e + c;\n if d < -e\n then write('No')\n else write('Yes');\nend."}, {"source_code": "program zzzzz;\nvar a,b,c,x,y,z,s:longint;\nbegin\n read(a,b,c,x,y,z);\n s:=0;\n if a-x>0 then s:=s+(a-x) div 2\n else s:=s+a-x;\n if b-y>0 then s:=s+(b-y) div 2\n else s:=s+b-y;\n if c-z>0 then s:=s+(c-z) div 2\n else s:=s+c-z;\n if s>=0 then write('Yes')\n else write('No');\n\n\nend.\n\n\n"}, {"source_code": "var a,b,c,x,y,z,r1,r2,r3,k:integer;\nbegin\nread(a,b,c,x,y,z);\nr1:=a-x; r2:=b-y; r3:=c-z;\nif r1>r2 then begin\n k:=r1; r1:=r2; r2:=k;\nend;\nif r2>r3 then begin\n k:=r2; r2:=r3; r3:=k;\nend;\nif r1>r2 then begin\n k:=r1; r1:=r2; r2:=k;\nend;\nwhile (r3>=0) and (r1<=0) do begin\n r1:=r1+1;\n r3:=r3-2;\nend;\nwhile (r3>=0) and (r2<=0) do begin\n r2:=r2+1;\n r3:=r3-2;\nend;\nwhile (r2>=0) and (r1<=0) do begin\n r1:=r1+1;\n r2:=r2-2;\nend;\nif (r2<0) or (r1<0) then write('No')\nelse write('Yes');\nend."}, {"source_code": "var a,b,c,x,y,z:longint;\n fa,fb,fc:longint;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n fa:=a-x;\n fb:=b-y;\n fc:=c-z;\n if fa>=2\n then\n begin\n while (fb<0)and(fa>=2) do\n begin\n dec(fa,2);\n inc(fb);\n end;\n while (fc<0)and(fa>=2) do\n begin\n dec(fa,2);\n inc(fc);\n end;\n end;\n if fb>=2\n then\n begin\n while (fa<0)and(fb>=2) do\n begin\n dec(fb,2);\n inc(fa);\n end;\n while (fc<0)and(fb>=2) do\n begin\n dec(fb,2);\n inc(fc);\n end;\n end;\n if fc>=2\n then\n begin\n while (fa<0)and(fc>=2) do\n begin\n dec(fc,2);\n inc(fa);\n end;\n while (fb<0)and(fc>=2) do\n begin\n dec(fc,2);\n inc(fb);\n end;\n end;\n if (fa>=0)and(fb>=0)and(fc>=0)\n then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n a,b,c,x,y,z:integer;\n\nprocedure solve(var a,x,b,y,c,z:integer);\nvar tt:integer;\nbegin\n if ay+1 then\n begin\n if (x-a)*2>b-y then\n begin\n tt:=(b-y) mod 2;\n inc(a,(b-y) div 2);\n b:=y+tt;\n\n end else\n begin\n b:=b-(x-a)*2;\n a:=x;\n\n end;\n end;\n if c>z+1 then\n begin\n if (x-a)*2>c-z then\n begin\n tt:=(c-z) mod 2;\n inc(a,(c-z) div 2);\n b:=y+tt;\n\n end else\n begin\n c:=c-(x-a)*2;\n a:=x;\n\n end;\n end;\n end;\nend;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n solve(a,x,b,y,c,z);\n solve(b,y,a,x,c,z);\n solve(c,z,a,x,b,y);\n if (a>=x) and (b>=y) and (c>=z) then writeln('Yes') else writeln('No')\nend.\n"}, {"source_code": "var a1, a2, a3, b1, b2, b3, n: integer;\nbegin\nn:=0;\nread (a1, a2, a3, b1, b2, b3);\nif b1>a1 then n:=n+b1-a1;\nif b2>a2 then n:=n+b2-a2;\nif b3>a3 then n:=n+b3-a3;\nif ((a1>b1) and (a2>b2)) and (n<=((a1-b1) div 2 + (a2-b2) div 2)) then write ('Yes')\nelse\nif ((a1>b1) and (a3>b3)) and (n<=((a1-b1) div 2 + (a3-b3) div 2)) then write ('Yes')\nelse\nif ((a2>b2) and (a3>b3)) and (n<=((a2-b2) div 2 + (a3-b3) div 2)) then write ('Yes')\nelse\nif (a1>b1) and ((a1-b1) div 2 >= n) then write ('Yes')\nelse\nif (a2>b2) and ((a2-b2) div 2 >= n) then write ('Yes')\nelse\nif (a3>b3) and ((a3-b3) div 2 >= n) then write ('Yes')\nelse\nif (a1=b1) and (a2=b2) and (a3=b3) then write ('Yes')\nelse write ('No'); end."}, {"source_code": "var\na,b,c,x,y,z,have,need:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a-x<0 then inc(need,abs(a-x)) else inc(have,(a-x) div 2);\nif b-y<0 then inc(need,abs(b-y)) else inc(have,(b-y) div 2);\nif c-z<0 then inc(need,abs(c-z)) else inc(have,(c-z) div 2);\nif need>have then writeln('No') else writeln('Yes');\nend."}, {"source_code": "uses math;\nvar a,b,c,tra,vis,x,y,z,k1,k:longint;\nd:array[0..5] of longint;\nf:array[0..5] of longint;\n\n begin\n read(a,b,c);\n read(x,y,z);\n if (a=d[1] then writeln('Yes') else writeln('No');\n end\n else\n begin\n if f[1] div 2>=d[1]+d[2] then writeln('Yes') else writeln('No');\n end;\n end.\n\n\n"}, {"source_code": "type int3 = 1..3;\nvar\n i, f : int3;\n s : longint;\n a, x : array [int3] of longint;\nbegin\n for i := 1 to 3 do\n read(a[i]);\n for i := 1 to 3 do\n read(x[i]);\n for i := 1 to 3 do\n begin\n while a[i] > x[i] do\n begin\n inc(s);\n dec(a[i], 2);\n end\n end;\n for i := 1 to 3 do\n begin\n s := s - x[i] + a[i]\n end;\n if s >= 0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "const\n fi='';//sr.inp';\n fo='';//sr.out';\nvar\n a,b,c,x,y,z,dua,dub,duc,tmp:int64;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(a,b,c);\n readln(x,y,z);\n dua:=a-x;\n dub:=b-y;\n duc:=c-z;\n if (dua<0) then\n begin\n if dub>0 then\n begin\n tmp:=dub div 2; dub:=dub mod 2;\n dua:=dua+tmp;\n if dua>0 then\n begin\n tmp:=dua; dua:=0;\n dub:=dub+tmp*2;\n end;\n end;\n if duc>0 then\n begin\n tmp:=duc div 2; duc:=duc mod 2;\n dua:=dua+tmp;\n if dua>0 then\n begin\n tmp:=dua; dua:=0;\n duc:=duc+tmp*2;\n end;\n end;\n end;\n if (dub<0) then\n begin\n if dua>0 then\n begin\n tmp:=dua div 2; dua:=dua mod 2;\n dub:=dub+tmp;\n if dub>0 then\n begin\n tmp:=dub; dub:=0;\n dua:=dua+tmp*2;\n end;\n end;\n if duc>0 then\n begin\n tmp:=duc div 2; duc:=duc mod 2;\n dub:=dub+tmp;\n if dub>0 then\n begin\n tmp:=dub; dub:=0;\n duc:=duc+tmp*2;\n end;\n end;\n end;\n if (duc<0) then\n begin\n if dua>0 then\n begin\n tmp:=dua div 2; dua:=dua mod 2;\n duc:=duc+tmp;\n if duc>0 then\n begin\n tmp:=duc; duc:=0;\n dua:=dua+tmp*2;\n end;\n end;\n if dub>0 then\n begin\n tmp:=dub div 2; dub:=dub mod 2;\n duc:=duc+tmp;\n if duc>0 then\n begin\n tmp:=duc; duc:=0;\n dub:=dub+tmp*2;\n end;\n end;\n end;\n if (dua>=0) and (dub>=0) and (duc>=0) then writeln('YES') else writeln('NO');\n close(input);\n close(output);\nend."}, {"source_code": "var\n k,n,m,a,b,c,x,y,z:longint;\nprocedure cool;\nbegin\n writeln('Yes');\n halt;\nend;\nprocedure error;\nbegin\n writeln('No');\n halt;\nend;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n if a>x then inc(k,(a-x) div 2)else inc(m,x-a);\n if b>y then inc(k,(b-y) div 2)else inc(m,y-b);\n if c>z then inc(k,(c-z) div 2)else inc(m,z-c);\n if k>=m then cool else error;\nend.\n\n"}, {"source_code": "var\n a,b,c,x,y,z,res:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n if a>x then inc(res,(a-x)div 2);\n if b>y then inc(res,(b-y)div 2);\n if c>z then inc(res,(c-z)div 2);\n if a=0 then writeln('Yes') else writeln('No')\nend.\n"}, {"source_code": "uses math;\nvar\n a,b,c,x,y,z,s1,s2,i : longint;\n\n function gt(x,y : longint) : longint;\n begin\n if y > x then exit(0) else exit((x-y) div 2);\n end;\n\nbegin\n readln(a,b,c,x,y,z);\n if a >= x then begin\n s1:=gt(a,x);\n if b < y then begin s2:=min(y-b,s1); inc(b,s2); s1:=s1-s2; dec(a,s2*2); end;\n if c < z then begin s2:=min(z-c,s1); inc(c,s2); s1:=s1-s2; dec(a,s2*2); end;\n end;\n if b >= y then begin\n s1:=gt(b,y);\n if a < x then begin s2:=min(x-a,s1); inc(a,s2); s1:=s1-s2; dec(b,s2*2); end;\n if c < z then begin s2:=min(z-c,s1); inc(c,s2); s1:=s1-s2; dec(b,s2*2); end;\n end;\n if c >= z then begin\n s1:=gt(c,z);\n if b < y then begin s2:=min(y-b,s1); inc(b,s2); s1:=s1-s2; dec(c,s2*2); end;\n if a < x then begin s2:=min(x-a,s1); inc(a,s2); s1:=s1-s2; dec(c,s2*2); end;\n end;\n if (a >= x) and (b >= y) and (c >= z) then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var k1,k2,k3,n1,n2,n3,a,b,c,x,y,z:int64;\nbegin\nreadln(a,b,c);\nread(x,y,z);\nif a0 then x:=x+((a[1][i]-a[2][i])div 2)\n else x:=x+(a[1][i]-a[2][i]);\n end;\n if x>=0 then writeln('yes')\n ELSE WRITELN('no');\n END.\n"}, {"source_code": "const fi='';//335A.inp';\n fo='';\n\nvar a,b,c,x,y,z:longint;\n\nprocedure xuli;\nvar tmp,tmp1:longint;\nbegin\n tmp:=0;\n tmp1:=0;\n if (a>x+1) then tmp:=tmp+(a-x) div 2;\n if (b>y+1) then tmp:=tmp+(b-y) div 2;\n if (c>z+1) then tmp:=tmp+(c-z) div 2;\n if (x>a) then tmp1:=tmp1+x-a;\n if (y>b) then tmp1:=tmp1+y-b;\n if (z>c) then tmp1:=tmp1+z-c;\n if (tmp>=tmp1) then writeln('YES')\n else writeln('NO');\nend;\n\nBEGIN\n assign(input,fi);\n assign(output,fo);\n reset(input);\n rewrite(output);\n\n readln(a,b,c);\n readln(x,y,z);\n xuli;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "program z1;\nvar a1,b1,c1,a2,b2,c2,d,i,j,k,l,m,n,cnt,need:longint;\n\nFunction max(x,y:longint):longint;\nbegin\nif x>y then max:=x else max:=y;\nend;\n\nbegin\n//assign(input,'d:\\nisht\\free\\input.txt'); reset(input);\n//assign(output,'d:\\nisht\\free\\output.txt'); rewrite(output);\nreadln(a1,b1,c1);\nreadln(a2,b2,c2);\ncnt:=cnt+max(0,(a1-a2) div 2);\nneed:=need+max(0,a2-a1); if (a1-a2>0) and (a2-a1 mod 2=1) then begin inc(cnt); inc(need); end;\ncnt:=cnt+max(0,(b1-b2) div 2);\nneed:=need+max(0,b2-b1); if (b1-b2>0) and (b2-b1 mod 2=1) then begin inc(cnt); inc(need); end;\ncnt:=cnt+max(0,(c1-c2) div 2);\nneed:=need+max(0,c2-c1); if (c1-c2>0) and (c2-c1 mod 2=1) then begin inc(cnt); inc(need); end;\n\nif cnt>=need then write('Yes') else write('No');\nend."}, {"source_code": "{$mode objfpc}\nprogram faf;\nvar a,b:Array[1..3] of integer;\n make, i, use :integer;\nbegin\n readln(a[1], a[2], a[3]);\n readln(b[1], b[2], b[3]);\n make :=0;\n use :=0;\n for i:=1 to 3 do\n begin\n if a[i] >= b[i] then inc(make, (a[i]- b[i]) div 2)\n else inc(use, b[i]-a[i]);\n end;\n if make >= use then writeln('Yes') else writeln('No');\nend."}, {"source_code": "uses math;\nconst\n fi='';\n fo='';\n maxn=4;\n maxc=1000000000;\nvar\n a,b,d:array[0..maxn] of longint;\n sum,ss:longint;\n{-------------------------}\nprocedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n{------------------------}\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n{-------------------------}\nprocedure nhap;\nvar\n i:longint;\nbegin\n for i:=1 to 3 do read(a[i]);\n for i:=1 to 3 do read(b[i]);\nend;\n{-------------------------}\nprocedure xuly;\nvar\n i:longint;\nbegin\n for i:=1 to 3 do\n begin\n d[i]:=a[i]-b[i];\n sum:=sum+max(0,d[i] div 2);\n if d[i] < 0 then ss:=ss+d[i];\n end;\n if sum+ss >= 0 then writeln('YES') else writeln('NO');\nend;\n{-------------------------}\nBEGIN\n openfiles;\n nhap;\n xuly;\n closefiles;\nEND.\n\n"}, {"source_code": "type int3 = 1..3;\nvar\n i, f : int3;\n s : longint;\n a, x : array [int3] of longint;\nbegin\n for i := 1 to 3 do\n read(a[i]);\n for i := 1 to 3 do\n read(x[i]);\n for i := 1 to 3 do\n begin\n while a[i] > x[i] do\n begin\n inc(s);\n dec(a[i], 2);\n end\n end;\n for i := 1 to 3 do\n begin\n s := s - x[i] + a[i]\n end;\n if s >= 0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "program ideone;\nvar a,b,c,x,y,z,br1,br2:longint;\nbegin\nread (a,b,c);\nread (x,y,z);\nbr1:=0;\nbr2:=0;\nif (a-x>0) then br1:=(a-x) div 2\nelse\nbr2:=x-a;\nif (b-y>0) then br1:=br1+(b-y) div 2\nelse\nbr2:=br2+y-b;\nif (c-z>0) then br1:=br1+(c-z) div 2\nelse\nbr2:=br2+z-c;\nif (br1>=br2) then writeln ('Yes')\nelse\nwriteln ('No');\nend."}, {"source_code": "var\n a, b, c, x, y, z, cnt, k: LongInt;\n \nbegin \n Read (a, b, c, x, y, z);\n \n cnt:= 0;\n k:= 0;\n \n if a > x then\n cnt:= cnt + (a - x) div 2\n else\n k:= k + (a - x); \n \n if b > y then\n cnt:= cnt + (b - y) div 2\n else\n k:= k + (b - y);\n \n if c > z then\n cnt:= cnt + (c - z) div 2\n else\n k:= k + (c - z);\n \n if k + cnt >= 0 then\n WriteLn ('Yes')\n else\n WriteLn ('No')\nend.\n \n "}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$macro on}\nuses math;\nconst\n fin ='';\n fou ='';\ntype\n pair = record\n fi,se :longint;\n end;\nvar\n a,b,c ,x,y,z :longint;\nprocedure enter;\nbegin\n readln(a,b,c);\n readln(x,y,z);\nend;\nprocedure solve;\nvar\n u,v :longint;\nbegin\n u:=0;\n v:=0;\n if a>=x then u+=((a-x) div 2)\n else v+=(x-a);\n if b>=y then u+=((b-y) div 2)\n else v+=(y-b) ;\n if c>=z then u+=((c-z) div 2)\n else v+=(z-c) ;\n if (u>=v) then\n begin\n writeln('YES');\n end\n else writeln('NO');\nend;\n\nBEGIN\n assign(input,fin); reset(input);\n assign(output,fou); rewrite(output);\n\n enter;\n solve;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "var\n n,m,k,n1,m1,k1,w,s:longint;\nbegin\n readln(n,m,k);\n readln(n1,m1,k1);\n if n= 0 then thua:=thua+(a-x) div 2\n else thieu:=thieu+x-a;\n if b-y >= 0 then thua:=thua+(b-y) div 2\n else thieu:=thieu+y-b;\n if c-z >= 0 then thua:=thua+(c-z) div 2\n else thieu:=thieu+z-c;\n if thua >= thieu then write('Yes')\n else write('No');\nend."}, {"source_code": "Var a,b,c,a1,b1,c1,s:longint;\n Begin\n read (a,b,c);\n read(a1,b1,c1);\n s:=0;\n if a>=a1 then s:=s+(a-a1) div 2;\n if b>=b1 then s:=s+(b-b1) div 2;\n if c>=c1 then s:=s+(c-c1) div 2;\n if a=0 then writeln ('Yes')\n else writeln('No');\n End.\n "}, {"source_code": "program magic;\ntype\n tab= array[1..3] of longint;\n var\n t,v:tab;\n\n s,x,y,i,j:integer;\n\n bb:boolean;\n\n\n begin\n\n s:=0;\n readln(t[1],t[2],t[3]);\n readln(v[1],v[2],v[3]);\n\n for i := 1 to 3 do\n begin\n x:=1;\n y:=1;\n for j:= 2 to 3 do\n begin\n if t[j]-v[j]>t[x]-v[x] then\n x:=j\n else if t[j]-v[j]<=t[y]-v[y] then\n y:=j;\n end;\n while (t[x]>=v[x]+2) and (t[y]t[i] then\n bb:=true;\n\n if bb=true then\n writeln('No')\n else\n writeln('Yes');\n\n end.\n"}, {"source_code": "var a,b,c,x,y,z,sum,tg:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n if a-x > 0 then\n sum:=sum + ((a-x) div 2)\n else\n tg:=tg+x-a;\n if b-y > 0 then sum:=sum + ((b-y) div 2)\n else\n tg:=tg+y-b;\n if c-z > 0 then sum:=sum + ((c-z) div 2)\n else\n tg:=tg+z-c;\n if sum >= tg then write('Yes')\n else write('No');\nend.\n"}, {"source_code": "var a,b,c,x,y,z:longint;\nbegin\nread(a,b,c,x,y,z);\nwhile (a>x) and (bx) and (cy) and (cy) and (az) and (az) and (b(x-1))and(b>(y-1))and(c>(z-1)) then write('Yes')\nelse write('No');\nend. "}, {"source_code": "uses math;\nvar\n a,b,c,x,y,z,k1,k2,k3,k:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n inc(k,max(0,x-a));\n inc(k1,max(0,a-x));\n inc(k,max(0,y-b));\n inc(k2,max(0,b-y));\n inc(k,max(0,z-c));\n inc(k3,max(0,c-z));\n dec(k,k1 div 2);\n dec(k,k2 div 2);\n dec(k,k3 div 2);\n if k<=0 then writeln('Yes')else writeln('No');\nend."}, {"source_code": "program arsofurs;\nvar tt,t,y,z,a,b,c,i,ind1,ind2,ind3,n,x,m:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z); t:=1;tt:=-1;\n\nwhile(ax)do\n begin\n if a-2<0 then break;\n if a-20>x then begin inc(t);a:=a-20;ind1:=ind1+10;end else\n begin\n a:=a-2;inc(ind1);inc(t);\n end;\n end;\n\n while(b>y)do\n begin\n\n if b-2<0 then break;\n if b-20>y then begin inc(t); b:=b-20;ind2:=ind2+10;end else\n begin\n b:=b-2;inc(ind2);\n inc(t);\n end;\n end;\n\n while(c>z)do\n begin\n if c-2<0 then break;\n if c-20>z then begin inc(t);c:=c-20;ind3:=ind3+10;end else\n begin\n c:=c-2;inc(ind3);inc(t);\n end;\n end;\ntt:=-5;\nwhile(ind1<>0)do\nbegin\nif ind1=tt then break;\ntt:=ind1;\nif a0)do\nbegin\nif ind2=tt then break;\ntt:=ind2;\nif a0)do\nbegin\nif ind3=tt then break;\ntt:=ind3;\nif a Need[i] ) then\n free := free + (Have[i] - Need[i]) div 2 ; \n \n if ( free >= needs ) then\n writeLn ( 'Yes' ) \n else\n writeLn ( 'No' ) ; \nend."}, {"source_code": "var\na,b,c,x,y,z,sum1,sum:int64;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a>x\nthen inc(sum,(a-x) div 2)\nelse inc(sum1,x-a);\nif b>y\nthen inc(sum,(b-y) div 2)\nelse inc(sum1,y-b);\nif c>z\nthen inc(sum,(c-z) div 2)\nelse inc(sum1,z-c);\nif sum>=sum1\nthen writeln('Yes')\nelse writeln('No');\nend."}, {"source_code": "var a,b,c,ka,kb,kc,ans:longint;\nbegin\nreadln(a,b,c);\nreadln(ka,kb,kc);\n\nif a>ka then inc(ans,(a-ka) div 2) else inc(ans,a-ka);\nif b>kb then inc(ans,(b-kb) div 2) else inc(ans,b-kb);\nif c>kc then inc(ans,(c-kc) div 2) else inc(ans,c-kc);\n\nif ans<0 then writeln('No')\n else writeln('Yes');\n\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c,x,y,z:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:boolean;\n var tg:longint;\n begin\n if (a>=x) and (b>=y) and (c>=z) then exit(true);\n tg:=0;\n repeat\n inc(tg);\n if a>=x+2 then\n begin\n dec(a,2);\n if b=y+2 then\n begin\n dec(b,2);\n if a=z+2 then\n begin\n dec(c,2);\n if b3000000 then exit(false);\n until (a>=x) and (b>=y) and (c>=z);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,a,b,c,x,y,z);\n if calc then write(fo,'Yes') else write(fo,'No');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "Var a,b,c,n,m,k,ns:longint;\n begin\n read(a,b,c);\n read(n,m,k);\n if a>=n then begin\n a:=a-n;\n n:=0;\n ns:=a div 2;\n end\n else n:=n-a;\n if b>=m then begin\n b:=b-m;\n m:=0;\n ns:=ns+(b div 2);\n end\n else m:=m-b;\n if c>=k then begin\n c:=c-k;\n k:=0;\n ns:=ns+(c div 2);\n end\n else k:=k-c;\n if (n+k+m)<=ns then writeln('Yes')\n else writeln('No');\n end.\n"}, {"source_code": "var\n a, b, c, x, y, z, sum: LongInt;\nbegin\n readLn(a, b, c);\n readLn(x, y, z);\n if a > x then\n sum := sum + (a - x) div 2\n else\n sum := sum + (a - x);\n if b > y then\n sum := sum + (b - y) div 2\n else\n sum := sum + (b - y);\n if c > z then\n sum := sum + (c - z) div 2\n else\n sum := sum + (c - z);\n if sum >= 0 then\n writeLn('YES')\n else\n writeLn('NO');\nend."}, {"source_code": "var a,b,c,x,y,z,cc,c1,c2,c3,s,s1,s2,s3:longint;\n begin\n read(a,b,c,x,y,z);\n s1:=(a-x) div 2;\n s2:=(b-y) div 2;\n s3:=(c-z) div 2;\n if s1<0 then s1:=0;\n if s2<0 then s2:=0;\n if s3<0 then s3:=0;\n s:=s1+s2+s3;\n c1:=x-a;\n c2:=y-b;\n c3:=z-c;\n if c1<0 then c1:=0;\n if c2<0 then c2:=0;\n if c3<0 then c3:=0;\n cc:=c1+c2+c3;\n if s>=cc then write('Yes') else write('No');\n end."}, {"source_code": "var d1,d2,d3,k,a1,a2,a3,b1,b2,b3:integer;\nbegin\nreadln(a1,a2,a3);\nreadln(b1,b2,b3);\nif (a1>=b1)and(a2>=b2)and(a3>=b3) then\nwriteln('YES') else\nbegin\nd1:=a1-b1;\nd2:=a2-b2;\nd3:=a3-b3;\nif d1>0 then d1:=d1 div 2;\nif d2>0 then d2:=d2 div 2;\nif d3>0 then d3:=d3 div 2;\nk:=d1+d2+d3;\nif k<0 then writeln('NO');\nif k>=0 then writeln('YES');\nend;\nreadln;\nend."}, {"source_code": "uses math;\nvar\n a,b,c,x,y,z:longint;\n i,j:longint;\nbegin\n read(a,b,c,x,y,z);\n i:=0;\n j:=0;\n\n if a>x then inc(i,(a-x)div 2)\n else inc(j,x-a);\n if b>y then inc(i,(b-y)div 2)\n else inc(j,y-b);\n if c>z then inc(i,(c-z)div 2)\n else inc(j,z-c);\n\n if i>=j then writeln('Yes')\n else writeln('No');\nend.\n"}, {"source_code": "var a,b:array[1..3]of longint;\n t,i:longint;\nbegin\nreadln(a[1],a[2],a[3]);\nreadln(b[1],b[2],b[3]);\nt:=0;\nfor i:=1 to 3 do if a[i]-b[i]>0 then t:=t+(a[i]-b[i])div 2\n else t:=t+(a[i]-b[i]);\nif t>=0 then write('Yes')\n else write('No');\nend.\n"}, {"source_code": "VAR a,b,c,a1,b1,c1,x,z,y:longint;\nbegin\n read(a,b,c,a1,b1,c1);\n x:=a-a1;y:=b-b1;z:=c-c1;\n if x>0 then x:=x div 2;\n if y>0 then y:=y div 2;if z>0 then z:=z div 2;\n if x+y+z>=0 then write('Yes') else write('No');\nend."}, {"source_code": "program MagicSpheres;\nconst\n finp='';\n fout='';\nvar\n fi,fo:text;\n a,b,c,x,y,z:longint;\nprocedure mofile;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(fo,fout);\n rewrite(fo);\nend;\nprocedure dongfile;\nbegin\n close(fi);\n close(fo);\nend;\nprocedure nhap;\nvar\n tong,hieu:longint;\nbegin\n readln(fi,a,b,c);\n readln(fi,x,y,z);\n a:=a-x;\n b:=b-y;\n c:=c-z;\n tong:=0;\n hieu:=0;\n if a>0 then tong:=tong+a div 2;\n if b>0 then tong:=tong+b div 2;\n if c>0 then tong:=tong+c div 2;\n if a<0 then hieu:=hieu-a;\n if b<0 then hieu:=hieu-b;\n if c<0 then hieu:=hieu-c;\n if tong>=hieu then writeln(fo,'Yes')\n else writeln(fo,'No');\nend;\nprocedure inkq;\nbegin\nend;\nprocedure xuly;\nbegin\nend;\nBEGIN\n mofile;\n nhap;\n xuly;\n inkq;\n dongfile;\nEND.\n"}, {"source_code": "var a,b,c,x,y,z,k:integer;\nbegin\nread(a,b,c,x,y,z);\nk:=0;\nwhile (a>x) and (x+1<>a) do begin\na:=a-2;\nk:=k+1;\nend;\nwhile (b>y) and (y+1<>b) do begin\nb:=b-2;\nk:=k+1;\nend;\nwhile (c>z) and (z+1<>c) do begin\nc:=c-2;\nk:=k+1;\nend;\nIf a0) do begin\na:=a+1;\nk:=k-1;\nend;\nIf b0) do begin\nb:=b+1;\nk:=k-1;\nend;\nIf c0) do begin\nc:=c+1;\nk:=k-1;\nend;\nif (a>=x) and (b>=y) and (c>=z) then\nwrite('Yes')\nelse \nwrite('No');\nend."}, {"source_code": "uses math;\n\nvar\n i :longint;\n a,b :array[0..3] of longint;\n res : longint;\n\nbegin\n for i:=1 to 3 do\n read(a[i]);\n res:=0;\n for i:=1 to 3 do read(b[i]);\n for i:=1 to 3 do a[i]:=a[i]-b[i];\n for i:=1 to 3 do if a[i]<0 then res:=res+a[i]\nelse res:=res+a[i] div 2;\n if res>=0 then writeln('Yes')\n else writeln('No'); \nend.\n"}, {"source_code": "var a,b,c,a1,b1,c1,x,z,y:longint;\nbegin\nread(a,b,c,x,y,z);\na1:=a-x;\nb1:=b-y;\nc1:=c-z;\nif a1>0 then a1:=a1 div 2;\nif b1>0 then b1:=b1 div 2;\nif c1>0 then c1:=c1 div 2;\nif a1+b1+c1>=0 then\nwrite('Yes')\nelse write('No');\nend.\n\n"}, {"source_code": "uses math;\nvar a, _a : array[1..3] of longint;\n j, i, mx, io: longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do begin read(_a[i]); a[i]:=a[i]-_a[i]; end;\n for i:=1 to 3 do if a[i]<0 then\n begin\n for j:=1 to 3 do while (a[j]>=2)and(a[i]<0) do\n begin\n a[j]:=a[j]-2;\n a[i]:=a[i]+1;\n end;\n if a[i]<0 then begin writeln('No'); halt; end;\n end;\n writeln('Yes');\nend."}, {"source_code": "VAR a,b,c,a1,b1,c1,x,z,y:longint;\nbegin\n read(a,b,c,a1,b1,c1);\n x:=a-a1;y:=b-b1;z:=c-c1;\n if x>0 then x:=x div 2;\n if y>0 then y:=y div 2;if z>0 then z:=z div 2;\n if x+y+z>=0 then write('Yes') else write('No');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f2 : text;\n x, y, z : longint;\nprocedure process;\n var f1 : text;\n tg : longint;\n begin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n readln(f1,x,y,z);\n read(f1,tg);\n dec(x,tg);\n read(f1,tg);\n dec(y,tg);\n read(f1,tg);\n dec(z,tg);\n while (x < 0) and (y >= 2) do\n begin\n inc(x);\n dec(y,2);\n end;\n while (x < 0) and (z >= 2) do\n begin\n inc(x);\n dec(z,2);\n end;\n while (y < 0) and (x >= 2) do\n begin\n inc(y);\n dec(x,2);\n end;\n while (y < 0) and (z >= 2) do\n begin\n inc(y);\n dec(z,2);\n end;\n while (z < 0) and (x >= 2) do\n begin\n inc(z);\n dec(x,2);\n end;\n while (z < 0) and (y >= 2) do\n begin\n inc(z);\n dec(y,2);\n end;\n if (x < 0) or (y < 0) or (z < 0) then write(f2,'No') else write(f2,'Yes');\n close(f1); close(f2);\n end;\nbegin\n process;\nend."}, {"source_code": "{$mode objfpc}\nvar\n thua, thieu, x, y, z, a, b, c: integer;\n\nbegin\n readln(a, b, c);\n readln(x, y, z);\n if a-x >= 0 then thua := thua + (a-x) div 2\n else thieu := thieu + x-a;\n if b-y >=0 then thua := thua + (b-y) div 2\n else thieu :=thieu + y-b;\n if c-z >=0 then thua := thua + (c-z) div 2\n else thieu := z-c + thieu;\n // writeln(thua); writeln(thieu);\n if thua >= thieu then writeln('Yes') else\n writeln('No');\nend."}, {"source_code": "uses Math;\ntype mass=array[1..1000000] of integer;\nvar m:mass;d,a1,b1,c1,k,res,n,c,a,b,i,z:integer;\n s:string;\nbegin\n// assign(input,'d:\\delphi\\input.txt');\n// assign(output,'d:\\delphi\\output.txt');\n readln(a,b,c);\n readln(a1,b1,c1);\n d:=0;\n if a>a1\n then d:=d+(a-a1) div 2;\n if b>b1\n then d:=d+(b-b1) div 2;\n if c>c1\n then d:=d+(c-c1) div 2;\n dec(d,max(0,a1-a));\n dec(d,max(0,b1-b));\n dec(d,max(0,c1-c));\n if d<0\n then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "var n,m,k,l,r,g,ii,jj:longint;\n begin\n read(n,m,k,l,r,g);\n while n=r then begin inc(n); dec(m,2); end else\n if k-2>=g then begin inc(n); dec(k,2); end else begin writeln('No'); halt; end;\n end;\n while m=l then begin inc(m); dec(n,2); end else\n if k-2>=g then begin inc(m); dec(k,2); end else begin writeln('No'); halt; end;\n end;\n while k=l then begin inc(k); dec(n,2); end else\n if m-2>=r then begin inc(k); dec(m,2); end else begin writeln('No'); halt; end;\n end;\n writeln('Yes');\n end."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000; eps=1e-11; modul1=1000000007;\n label 1,2,3,4;\nvar step,ii,jj,kt,ppp,god,day,mon,p,mask,i0,j0,k,i,j,start,finish,kol,m:longint;\nmodul,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\ncc,l,r,p1,p2,t1,t2,ot,dist1,avt,zap,q,ba,by,aa,ay,t,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nright,left,f,x,y,fact,c,b,a,prost:array[-100000..1000000] of int64;\noldmarked,marked,zan: array[0..330006] of boolean;\ndostl,dostr: array[-100..500,-100..500] of int64;\nott :double;\nmatdl,dd:array[-100..1100,-100..1100] of extended;\nss1,ss2:string;\ngr:array[0..4000,0..4000] of int64;\ndost,newdost:array[0..400,0..400] of boolean;\nssnew,ss:array[-10..1000000] of char;\npole:array[-10..110,-10..100] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul1 else\n begin q:=(degg(p,deg shr 1)) mod modul1; degg:=(q*q) mod modul1; end; end; end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=3;\n for i:=1 to 3 do read(a[i]);\n for i:=1 to 3 do read(b[i]);\n for i:=1 to 3 do c[i]:=a[i]-b[i];\n for i:=1 to 3 do if c[i]>0 then p:=p+(c[i] div 2)\n else p:=p+c[i];\n {writeln(p);\n }\n if p>=0 then write('Yes') else write('No');\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "program Project151215;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n a,b,c,x,y,z,da,db,dc,k:int64;\nbegin\n // Reset(Input,'input.txt');\n // Rewrite(output,'output.txt');\n readln(a,b,c);\n read(x,y,z);\n da:=Max(0,a-x);\n db:=Max(0,b-y);\n dc:=Max(0,c-z);\n k:=(da div 2) + (db div 2) + (dc div 2);\n\n da:=Max(0,x-a);\n db:=Max(0,y-b);\n dc:=Max(0,z-c);\n\n if da+db+dc<=k\n then write('Yes')\n else write('No')\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a,x :array[1..3] of longint;\n i :longint;\nbegin\n read(a[1],a[2],a[3],x[1],x[2],x[3]);\n for i:=1 to 3 do begin\n if a[i] > x[i] then begin\n a[i]:= a[i] - x[i];\n x[i]:=0;\n end;\n if a[i] <= x[i] then begin\n x[i]:= x[i] - a[i];\n a[i]:=0;\n end;\n end;\n //for i:=1 to 3 do writeln('a[',i,']= ', a[i],' x[',i,']= ', x[i]);\n if (a[1] div 2 + a[2] div 2 + a[3] div 2) >= (x[1]+x[2]+x[3]) then writeln('Yes') else writeln('No');\n //read(i);\nend.\n "}, {"source_code": "var\nneed,a,b,c,x,y,z:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\n\nif a>x then begin\n dec(a,x);\n x:=0;\nend\nelse begin\n\n dec(x,a);\n a:=0;\nend;\n\nif b>y then begin\n dec(b,y);\n y:=0;\nend\nelse begin\n\n dec(y,b);\n b:=0;\nend;\n\nif c>z then begin\n dec(c,z);\n z:=0;\nend\nelse begin\n\n dec(z,c);\n c:=0;\nend;\nneed:=x+y+z;\n//writeln(need);\nneed:=need-(a div 2+ b div 2+ c div 2);\nif need<=0 then writeln('Yes')\nelse\nwriteln('No');\nend."}, {"source_code": "var a,b,c,x,y,z,k:integer;\nbegin\n read(a,b,c);\n read(x,y,z);\n if a>=x then k:=((a-x) div 2) else k:=a-x;\n if b>=y then k:=k+((b-y)div 2) else k:=k-(y-b);\n if c>=z then k:=k+((c-z) div 2) else k:=k-(z-c);\n if k<0 then writeln('No') else writeln('Yes');\nend.\n \n"}, {"source_code": "var\n a,b,c,x,y,z,t:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n if a>x then\n inc(t,(a-x)div 2);\n if b>y then\n inc(t,(b-y) div 2);\n if c>z then\n inc(t,(c-z) div 2);\n\n if a=0 then writeln('Yes')else writeln('No');\nend.\n"}, {"source_code": "var\n a, b, c, a1, b1, c1, q, q1: longint;\n\nbegin\n read(a, b, c, a1, b1, c1);\n a := a - a1;\n b := b - b1;\n c := c - c1;\n if a > 0 then q := a div 2\n else q1 := q1 + a;\n if b > 0 then q := q + b div 2\n else q1 := q1 + b;\n if c > 0 then q := q + c div 2\n else q1 := q1 + c;\n q1:=abs(q1);\n if q >= q1 then write('Yes')\n else write('No');\n \nend."}], "negative_code": [{"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint; count1,count2,st,x,y:int64;\nbegin\n// assign(input,'d:\\programs\\input.txt'); reset(input);\n// assign(output,'d:\\programs\\output.txt'); rewrite(output);\nfor i:=1 to 6 do\nbegin\nread(a); b:=b+a;\nend;\nif b mod 3=0 then write('Yes') else write('No');\nend."}, {"source_code": "var m,n,i:integer;\nbegin\nread (n);\nfor i:=1 to n do begin\nread(m);\nwhile m>0 do begin\nwrite ('p');\nif m-1>0 then begin\nif i<=n then begin\nwrite ('RL');\nend\nelse\nwrite ('RL');\nend\nelse if i=0 then mia:=0-ma else begin mia:=ma; ma:=0; end;\nmb:=b-y; if mb>=0 then mib:=0-mb else begin mib:=mb; mb:=0; end;\nmc:=c-z; if mc>=0 then mic:=0-mc else begin mic:=mc; mc:=0; end;\nif ma div 2 +mb div 2+mc div 2>=abs(mia+mib+mic) then writeln(output,'Yes') else writeln(output,'No'); \nend. "}, {"source_code": "Var a,b,c,x,y,z,s,s1:longint;\n Begin \n readln(a,b,c);\n readln(x,y,z);\n if a+b+c<=x+y+z then writeln('No')\n else begin \n if a>x then s:=s+ (a-x) div 2;\n if b>y then s:=s+(b-y) div 2;\n if c>z then s:=s+(c-z) div 2;\n if a=s1 then writeln('Yes')\n else writeln('No');\n end;\nEnd."}, {"source_code": "var\n k,n,m,a,b,c,x,y,z:longint;\nprocedure cool;\nbegin\n writeln('Yes');\n halt;\nend;\nprocedure error;\nbegin\n writeln('No');\n halt;\nend;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n m:=x+y+z;\n if a>x then inc(k,a-x div 2)else inc(m,x-a);\n if b>y then inc(k,b-y div 2)else inc(m,y-b);\n if c>z then inc(k,c-z div 2)else inc(m,z-c);\n if k>=m then cool else error;\nend.\n\n"}, {"source_code": "uses Math;\ntype mass=array[1..1000000] of integer;\nvar m:mass;d,a1,b1,c1,k,res,n,c,a,b,i,z:integer;\n s:string;\nbegin\n // assign(input,'d:\\delphi\\input.txt');\n // assign(output,'d:\\delphi\\output.txt');\n readln(a,b,c);\n readln(a1,b1,c1);\n if a>a1\n then d:=(a-a1) div 2;\n if b>b1\n then d:=d+(b-b1) div 2;\n if c>c1\n then d:=d+(c-c1) div 2;\n dec(d,max(0,a1-a));\n dec(d,max(0,b1-b));\n dec(d,max(0,c1-c));\n if d<0\n then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i,temp: longint;\n lc:boolean;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n lc:=true;\n for i:=1 to 3 do\n begin\n s[i]:=a[i]-b[i];\n if s[i]<0 then\n begin\n lc:=false;\n s[i]:=2*s[i];\n end;\n end;\n for i:=1 to 3 do\n temp:=temp+s[i];\n if temp>0 then writeln(g,'Yes')\n else writeln(g,'No');\n close(f); close(g);\nend.\n"}, {"source_code": "var\n a,b,c,x,y,z,k,i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n k:=k div 2;\n if x > a then\n if x-a <= k then dec(k,x-a) else begin writeln('No'); halt; end;\n\n if y > b then\n if y-b <= k then dec(k,y-b) else begin writeln('No'); halt; end;\n\n if z > c then\n if z-c <= k then dec(k,z-c) else begin writeln('No'); halt; end;\n\n writeln('Yes');\nend.\n\n\n\n\n\n\nvar\n a,b,c,x,y,z,k,i,a1,b1,c1: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a1:=a;\n b1:=b;\n c1:=c;\n while (a1 > x) or (b1 > y) or (c1 > z) do\n begin\n if (a1-x) >= 2 then begin dec(a1,2); inc(k); end else break;\n if (b1-y) >= 2 then begin dec(b1,2); inc(k); end else break;\n if (c1-z) >= 2 then begin dec(c1,2); inc(k); end else break;\n end;\n\n writeln(k);\n if x > a then\n for i:=1 to x-a do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if y > b then\n forvar\n a,b,c,x,y,z,k: int64;\n i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n if x > a then\n for i:=1 to x-a do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n\n if y > b then\n for i:=1 to y-b do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n if z > c then\n for i:=1 to z-c do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n writeln('Yes');\nend. i:=1 to y-b do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if z > c then\n for i:=1 to z-c do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if k < 0 then writeln('No') else writeln('Yes');\nend.\n\n\n\n\n"}, {"source_code": "program spheres;\nvar\n a,b,c,x,y,z:integer;\n begin\n\n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c)>=(x+y+z) then\n begin\n if (a>x) and (b>y) then\n writeln('Yes')\n else if (a>x) and (c>z) then\n writeln('Yes')\n else if (b>y) and (c>z) then\n writeln('Yes')\n else\n writeln('No');\n end\n else writeln('No');\n\n\nend.\n"}, {"source_code": " Const N = 3;\n var Have , Need : Array [ 1 .. 3 ] of Int64;\n \n i : LongInt;\n free , needs : Int64;\nbegin\n for i := 1 to N do\n read ( Have[i] ) ; \n for i := 1 to N do\n read ( Need[i] ) ;\n \n for i := 1 to N do\n if ( Have[i] < Need[i] ) then\n needs := needs + ( Need[i] - Have[i] ) ; \n \n for i := 1 to N do\n if ( Have[i] > Need[i] ) then\n free := Have[i] - Need[i] div 2 ; \n \n if ( free >= needs ) then\n writeLn ( 'Yes' ) \n else\n writeLn ( 'No' ) ; \nend."}, {"source_code": "\nconst\n tfi='606a.inp';\n tfo='606A.out';\n\nvar\n fi, fo: text;\n a, b: array[1..3] of longint;\n\nprocedure __;\nvar\n can, du, i: longint;\nbegin\n \n readln( a[1], a[2], a[3]);\n readln(b[1], b[2], b[3]);\n for i:=1 to 3 do\n if a[i]>b[i] then\n du := du+((a[i]-b[i]) div 2)\n else can := can+b[i]-a[i];\n if du>=can then write('YES')\n else write('NO');\nend;\n\nprocedure _;\nbegin\n \nend;\n\nBEGIN\n __;\n _;\nEND.\n"}, {"source_code": "program spheres;\nvar\n a,b,c,x,y,z:integer;\n begin\n\n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c)>=(x+y+z) then\n begin\n if (a>x) and (b>y) then\n writeln('Yes')\n else if (a>x) and (c>z) then\n writeln('Yes')\n else if (b>y) and (c>z) then\n writeln('Yes')\n else\n writeln('No');\n end\n else writeln('No');\n\n\nend.\n"}, {"source_code": "var a,b,c,a1,b1,c1,res : longint;\nbegin\n readln(a,b,c);\n readln(a1,b1,c1);\n a:=a1-a;\n b:=b1-b;\n c:=c1-c;\n if a>0 then res:=res+2*a;\n if b>0 then res:=res+2*b;\n if c>0 then res:=res+2*c;\n if (a<0) then\n if ((-a) mod 2=0) then res:=res+a else res:=res +(a-1)+2;\n if (b<0) then\n if ((-b) mod 2=0) then res:=res+b else res:=res +(b-1)+2;\n if (c<0) then\n if ((-c) mod 2=0) then res:=res+c else res:=res +(c-1)+2;\n if res=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "Var \n a,b,c,a1,b1,c1,s,s1:longint;\n Begin\n read (a,b,c);\n read(a1,b1,c1);\n if a>=a1 then s:=s+a-a1;\n if b>=b1 then s:=s+b-b1;\n if c>=c1 then s:=s+c-c1;\n if a=0 then writeln ('Yes')\n else writeln('No');\n End.\n "}, {"source_code": "var a,b,c,x,y,z,r1,r2,r3,s1,a1,b1:integer;\nbegin\nread(a,b,c);\nread(x,y,z);\nr1:=a-x;\nr2:=b-y;\nr3:=c-z;\nif ((a-x)>0) and ((b-y)>0)then\na1:=a-x;\nb1:=b-y;\ns1:=a1+b1+c;\nif s1>=z then\nwrite('Yes')\nelse \nif (r1<0) or (r2<0) or (r3<0) then\nwrite('No')\nelse\nif (r1>0) and (r2>0) and (r3>0) then\nwrite('Yes')\nend."}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$macro on}\nuses math;\nconst\n fin =''; \n fou ='';\ntype\n pair = record\n fi,se :longint;\n end;\nvar\n a,b,c ,x,y,z :longint;\nprocedure enter;\nbegin\n readln(a,b,c);\n readln(x,y,z);\nend;\nprocedure solve;\nvar\n u,v :longint;\nbegin\n u:=0;\n v:=0;\n if a>x+1 then u+=a-x\n else v+=x-a;\n if b>y+1 then u+=b-y\n else v+=y-b;\n if c>z+1 then u+=c-z\n else v+=z-c;\n if (u div 2>=v) then\n begin\n writeln('YES');\n end\n else writeln('NO');\nend;\n\nBEGIN\n assign(input,fin); reset(input);\n assign(output,fou); rewrite(output);\n\n enter;\n solve;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "program spheres;\nvar\n a,b,c,x,y,z:integer;\n begin\n\n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c)>=(x+y+z) then\n begin\n if (a>=x) and (b>=y) then\n writeln('Yes')\n else if (a>=x) and (c>=z) then\n writeln('Yes')\n else if (b>=y) and (c>=z) then\n writeln('Yes')\n else\n writeln('No');\n end\n else writeln('No');\n\n\nend.\n"}, {"source_code": "var a, _a : array[1..3] of longint;\n i : longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n if i=2 then begin dec(a[1],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=1 then begin dec(a[2],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=3 then begin dec(a[1],_a[i]-a[i]); dec(a[2],_a[i]-a[i]); end;\n inc(a[i], _a[i]-a[i]);\n end;\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n\n writeln('No'); halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "var a, _a : array[1..3] of longint;\n i : longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n if i=2 then begin dec(a[1],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=1 then begin dec(a[2],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=3 then begin dec(a[1],_a[i]-a[i]); dec(a[2],_a[i]-a[i]); end;\n inc(a[i], _a[i]-a[i]);\n end;\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n\n writeln('No'); halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "program magicspheresa;\n\nvar\n a,b,c,x,y,z:real;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a:=a-x; if a>0 then a:=a/(a+1);\n b:=b-y; if b>0 then b:=b/(b+1);\n c:=c-z; if c>0 then c:=c/(c+1);\n if (a+b+c)>=0 then writeln('YES') else writeln('NO');\n readln;\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n readln(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) then begin\n if a-x=1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (b>y) then begin\n if b-y=1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (c>z) then begin\n if c-z=1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "uses Math;\ntype mass=array[1..1000000] of integer;\nvar m:mass;d,a1,b1,c1,k,res,n,c,a,b,i,z:integer;\n s:string;\nbegin\n // assign(input,'d:\\delphi\\input.txt');\n // assign(output,'d:\\delphi\\output.txt');\n readln(a,b,c);\n readln(a1,b1,c1);\n if a>a1\n then d:=(a-a1) div 2;\n if b>b1\n then d:=d+(b-b1) div 2;\n if c>c1\n then d:=d+(c-c1) div 2;\n dec(d,max(0,a1-a));\n dec(d,max(0,b1-b));\n dec(d,max(0,c1-c));\n if d<0\n then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "program cf606A;\nvar a,b,c,x,y,z:int64;\n\nbegin\nread(a,b,c,x,y,z);\nif a>=x then\n begin\n a:=a-x;\n x:=0;\n end\nelse\n begin\n a:=0;\n x:=x-a;\n end;\nif b>=y then\n begin\n b:=b-y;\n y:=0;\n end\nelse\n begin\n b:=0;\n y:=y-b;\n end;\nif c>=z then\n begin\n c:=c-z;\n z:=0;\n end\nelse\n begin\n c:=0;\n z:=z-c;\n end;\n\nif (x+y+z)<=(a div 2)+(b div 2)+(c div 2) then\n writeln('Yes')\nelse\n writeln('No');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i, j, sl, maxa, maxb, temp: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n for i:=1 to 3 do\n begin\n s[1]:=s[1]+a[i];\n s[2]:=s[2]+b[i];\n end;\n sl:=abs(s[1]-s[2]);\n for i:=3 downto 2 do\n begin\n maxa:=1; maxb:=1;\n for j:=1 to i do\n begin\n if a[maxa]=b[i] then inc(j);\n temp:=temp+a[i]-b[i];\n end;\n if j=1 then writeln(g,'NO')\n else\n begin\n if j=3 then writeln(g,'YES')\n else\n if temp>sl then writeln(g,'YES')\n else writeln(g,'NO');\n end;\n close(f); close(g);\nend."}, {"source_code": "Var \n a,b,c,a1,b1,c1,s,s1:longint;\n Begin\n read (a,b,c);\n read(a1,b1,c1);\n if a>=a1 then s:=s+a-a1;\n if b>=b1 then s:=s+b-b1;\n if c>=c1 then s:=s+c-c1;\n if a<=a1 then s1:=s1-a+a1;\n if b<=b1 then s1:=s1-b+b1;\n if c<=c1 then s1:=s1-c+c1;\n if s div 2>=s1 then writeln('Yes')\n else writeln('No');\n End.\n "}, {"source_code": "var a,b,c,x,y,z,s,s1:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a+b+c<=x+y+z then writeln('No')\n else begin\n s:=0;s1:=0;\n if a>x then s:=(a-x) div 2+s ;\n if b>y then s:=(b-y) div 2+s;\n if c>z then s:=(c-z) div 2 +s;\n if as1 then writeln('Yes')\n else writeln('No'); \n end;\n end."}, {"source_code": "var\n a,b,c,x,y,z,s1,s2 : longint;\n\n function gt(x,y : longint) : longint;\n begin\n if y > x then exit(0) else exit((x-y) div 2);\n end;\n\nbegin\n readln(a,b,c,x,y,z);\n if a < x then begin\n s1:=gt(b,y); s2:=gt(c,z);\n if s1+s2+a < x then begin writeln('No'); halt; end else begin\n inc(a,s1+s2);\n dec(b,s1*2); dec(c,s2*2);\n end;\n end;\n if b < y then begin\n s1:=gt(a,x); s2:=gt(c,z);\n if s1+s2+b < y then begin writeln('No'); halt; end else begin\n inc(b,s1+s2);\n dec(a,s1*2); dec(c,s2*2);\n end;\n end;\n if c < z then begin\n s1:=gt(b,y); s2:=gt(a,x);\n if s1+s2+c < z then begin writeln('No'); halt; end else begin\n inc(c,s1+s2);\n dec(b,s1*2); dec(a,s2*2);\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "var a, _a : array[1..3] of longint;\n i : longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n if i=2 then begin dec(a[1],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=1 then begin dec(a[2],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=3 then begin dec(a[1],_a[i]-a[i]); dec(a[2],_a[i]-a[i]); end;\n inc(a[i], _a[i]-a[i]);\n end;\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n\n writeln('No'); halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i, j, ind, maxa, maxb, temp: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n for i:=1 to 3 do\n begin\n s[1]:=s[1]+a[i];\n s[2]:=s[2]+b[i];\n end;\n for i:=3 downto 2 do\n begin\n maxa:=1; maxb:=1;\n for j:=1 to i do\n begin\n if a[maxa]=b[i] then inc(j);\n if j=3 then writeln(g,'YES')\n else\n begin\n j:=0;\n for i:=1 to 3 do\n begin\n if a[i]>b[i] then inc(j)\n else ind:=ind;\n temp:=temp+a[i]-b[i];\n end;\n if j=1 then writeln(g,'NO')\n else\n begin\n if j=3 then writeln(g,'YES')\n else\n if temp>ind then writeln(g,'YES')\n else writeln(g,'NO');\n end;\n end;\n close(f); close(g);\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint; count1,count2,st,x,y:int64;\nbegin\n// assign(input,'d:\\programs\\input.txt'); reset(input);\n// assign(output,'d:\\programs\\output.txt'); rewrite(output);\nfor i:=1 to 6 do\nbegin\nread(a); b:=b+a;\nend;\nif b mod 3=0 then write('Yes') else write('No');\nend."}, {"source_code": "Var a,b,c,x,y,z,s,s1:longint;\n Begin \n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c=0) or (x+y+z=0) then writeln('Yes')\n else begin\n if a+b+c<=x+y+z then writeln('No')\n else begin \n if a>x then s:=s+ (a-x) div 2;\n if b>y then s:=s+(b-y) div 2;\n if c>z then s:=s+(c-z) div 2;\n if a=s1 then writeln('Yes')\n else writeln('No');\n end;\n end;\nEnd."}, {"source_code": "var k1,k2,k3,n1,n2,n3,a,b,c,x,y,z:int64;\nbegin\nreadln(a,b,c);\nread(x,y,z);\nif ab[i] then\n du := du+((a[i]-b[i]) div 2)\n else can := can+b[i]-a[i];\n if du>=can then write('YES')\n else write('NO');\nend;\n\nprocedure _;\nbegin\n \nend;\n\nBEGIN\n __;\n _;\nEND.\n"}, {"source_code": "var a,b,c,x,y,z,s,s1:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a+b+c<=x+y+z then writeln('No')\n else begin\n s:=0;s1:=0;\n if a>x then s:=(a-x) div 2+s ;\n if b>y then s:=(b-y) div 2+s;\n if c>z then s:=(c-z) div 2 +s;\n if as1 then writeln('Yes')\n else writeln('No'); \n end;\n end."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c,x,y,z:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:boolean;\n var tg:longint;\n begin\n if (a>=x) and (b>=y) and (c>=z) then exit(true);\n if ((a<=x) and (b<=y)) or\n ((a<=x) and (c<=z)) or\n ((b<=y) and (c<=z)) then exit(false);\n tg:=0;\n repeat\n inc(tg);\n if a>=x+2 then\n begin\n dec(a,2);\n if b=y+2 then\n begin\n dec(b,2);\n if a=z+2 then\n begin\n dec(c,2);\n if b3000000 then exit(false);\n until (a>=x) and (b>=y) and (c>=z);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,a,b,c,x,y,z);\n if calc then write(fo,'Yes') else write(fo,'No');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var\n a,b,c,x,y,z,k,i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n\n if x > a then\n if 2*(x-a) <= k then dec(k,2*(x-a)) else begin writeln('No'); halt; end;\n\n if y > b then\n if 2*(y-b) <= k then dec(k,2*(y-b)) else begin writeln('No'); halt; end;\n\n if z > c then\n if 2*(z-c) <= k then dec(k,2*(z-c)) else begin writeln('No'); halt; end;\n\n writeln('Yes');\nend.\n\n\n\n\n\n\nvar\n a,b,c,x,y,z,k,i,a1,b1,c1: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a1:=a;\n b1:=b;\n c1:=c;\n while (a1 > x) or (b1 > y) or (c1 > z) do\n begin\n if (a1-x) >= 2 then begin dec(a1,2); inc(k); end else break;\n if (b1-y) >= 2 then begin dec(b1,2); inc(k); end else break;\n if (c1-z) >= 2 then begin dec(c1,2); inc(k); end else break;\n end;\n\n writeln(k);\n if x > a then\n for i:=1 to x-a do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if y > b then\n forvar\n a,b,c,x,y,z,k: int64;\n i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n if x > a then\n for i:=1 to x-a do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n\n if y > b then\n for i:=1 to y-b do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n if z > c then\n for i:=1 to z-c do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n writeln('Yes');\nend. i:=1 to y-b do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if z > c then\n for i:=1 to z-c do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if k < 0 then writeln('No') else writeln('Yes');\nend.\n\n\n\n\n"}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$macro on}\nuses math;\nconst\n fin =''; \n fou ='';\ntype\n pair = record\n fi,se :longint;\n end;\nvar\n a,b,c ,x,y,z :longint;\nprocedure enter;\nbegin\n readln(a,b,c);\n readln(x,y,z);\nend;\nprocedure solve;\nvar\n u,v :longint;\nbegin\n u:=0;\n v:=0;\n if a>x then u+=a-x\n else v+=x-a;\n if b>y then u+=b-y\n else v+=y-b;\n if c>z then u+=c-z\n else v+=z-c;\n if (u div 2>=v) then writeln('YES')\n else writeln('NO');\nend;\n\nBEGIN\n assign(input,fin); reset(input);\n assign(output,fou); rewrite(output);\n\n enter;\n solve;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "program magicspheresa;\n\nvar\n a,b,c:real; x,y,z:integer;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a:=a-x; b:=b-y; c:=c-z;\n if a>0 then a:=round(a/2);\n if b>0 then b:=round(b/2);\n if c>0 then c:=round(c/2);\n if a+b+c>=0 then writeln('YES') else writeln('NO');\n readln;\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n read(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) and (b>x) and (c>x) then write('YES');\n if (a>x) then begin\n if a-x>1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (b>y) then begin\n if b-y>1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (c>z) then begin\n if c-z>1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "VAR\n i,t,j : longint;\n x,a : array[0..3] of longint;\n\nBEGIN\n read(a[1],a[2],a[3]);\n read(x[1],x[2],x[3]);\n for i := 1 to 3 do\n a[i] := a[i]- x[i];\n for i := 1 to 3 do\n for j := i + 1 to 3 do\n if a[i] > a[j] then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n end;\n if a[1]+a[2]>=0 then write('Yes')\n else write('No');\nEND."}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n read(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) then begin\n if a-x>1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (a>x) then begin\n if b-y>1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (a>x) then begin\n if c-z>1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "var\n a, b, c, x, y, z, cnt, k: LongInt;\n \nbegin\n Read (a, b, c, x, y, z);\n \n cnt:= 0;\n k:= 0;\n \n if a > x then\n cnt:= cnt + (a - x) div 2\n else\n k:= k + a - x; \n \n if b > y then\n cnt:= cnt + (b - y) div 2\n else\n k:= k + b - y;\n \n if c > z then\n cnt:= cnt + (c - z) div 2\n else\n k:= k + c - x;\n \n WriteLn (cnt, ' ', k);\n \n if k + cnt >= 0 then\n WriteLn ('Yes')\n else\n WriteLn ('No')\nend.\n \n "}, {"source_code": "var a,b,c,a1,b1,c1,res : longint;\nbegin\n readln(a,b,c);\n readln(a1,b1,c1);\n a:=a1-a;\n b:=b1-b;\n c:=c1-c;\n if a>0 then res:=res+2*a;\n if b>0 then res:=res+2*b;\n if c>0 then res:=res+2*c;\n if (a<0) then\n if ((-a) mod 2=0) then res:=res+a else res:=res +(a-1)+2;\n if (b<0) then\n if ((-b) mod 2=0) then res:=res+b else res:=res +(b-1)+2;\n if (c<0) then\n if ((-c) mod 2=0) then res:=res+c else res:=res +(c-1)+2;\n if res=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i, j, ind, maxa, maxb, temp: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n for i:=1 to 3 do\n begin\n s[1]:=s[1]+a[i];\n s[2]:=s[2]+b[i];\n end;\n for i:=3 downto 2 do\n begin\n maxa:=1; maxb:=1;\n for j:=1 to i do\n begin\n if a[maxa]=b[i] then inc(j);\n if j=3 then writeln(g,'YES')\n else\n begin\n j:=0;\n for i:=1 to 3 do\n begin\n if a[i]>b[i] then inc(j)\n else ind:=ind;\n temp:=temp+a[i]-b[i];\n end;\n if j=1 then writeln(g,'NO')\n else\n begin\n if j=3 then writeln(g,'YES')\n else\n if temp>ind then writeln(g,'YES')\n else writeln(g,'NO');\n end;\n end;\n close(f); close(g);\nend."}, {"source_code": "type int3 = 1..3;\nvar\n i, f : int3;\n a, x : array [int3] of longint;\nbegin\n for i := 1 to 3 do\n read(a[i]);\n for i := 1 to 3 do\n read(x[i]);\n for i := 1 to 3 do\n begin\n while a[i] > x[i] do\n begin\n dec(a[i], 2);\n if i = 3 then inc(a[1]) else inc(a[i+1]);\n end;\n end;\n for i := 1 to 3 do\n begin\n if a[i] <> x[i] then\n begin\n f := 1;\n break;\n end;\n end;\n if f = 0 then writeln('Yes') else writeln('No');\nend.\n"}, {"source_code": "program arsofurs;\nvar t,ind3,ind1,ind2,n,m,x,y,z,a,b,c:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\n\nwhile(a<>x)or(b<>y)or(c<>z)do begin\n\n\nif (a<=x)and(b<=y)and(c<=z)then begin writeln('No');halt;end;\nif t>=1 then begin writeln('No');halt;end else t:=0;\n\nif (x<>0)then\n\nwhile(a>x)do\nbegin\nif a-2<0 then begin inc(t); break;end;\nif (a-20>0)and(a-20>x)then begin ind1:=ind1+10;a:=a-20;end else begin\ninc(ind1);\na:=a-2; end;\nend else\n\nwhile(a>0)do\nbegin\nif a-2<0 then begin inc(t); break;end;\nif (a-20>0)and(a-20>x)then begin ind1:=ind1+10;a:=a-20;end else begin\ninc(ind1);a:=a-2;end;\nend;\n\nif (y<>0)then\n\nwhile(b>y)do\nbegin\nif b-2<0 then begin inc(t); break;end;\nif (b-20>0)and(b-20>y)then begin ind2:=ind2+10;b:=b-20;end else begin\ninc(ind2);\nb:=b-2;end;\nend else\n\nwhile(b>0)do\nbegin\nif b-2<0 then begin inc(t); break;end;\nif (b-20>0)and(b-20>y)then begin ind2:=ind2+10;b:=b-20;end else begin\ninc(ind2);\nb:=b-2; end;\nend;\n\nif (z<>0)then\n\nwhile(c>z)do\nbegin\nif c-2<0 then begin inc(t); break;end;\nif (c-20>0)and(c-20>z)then begin ind3:=ind3+10;c:=c-20;end else begin\ninc(ind3);\nc:=c-2; end;\nend else\n\nwhile(c>0)do\nbegin\nif c-2<0 then begin inc(t); break;end;\nif (c-20>0)and(c-20>z)then begin ind3:=ind3+10;c:=c-20;end else begin\ninc(ind3);\nc:=c-2; end;\nend;\n\nif a0 then\nwhile(a0)do\nbegin\ndec(ind2);\ninc(a);\nend;\n\nif a0 then\nwhile(a0)do\nbegin\ndec(ind3);\ninc(a);\nend;\n\nif b0 then\nwhile(b0)do\nbegin\ndec(ind1);\ninc(b);\nend;\n\nif b0 then\nwhile(b0)do\nbegin\ndec(ind3);\ninc(b);\nend;\n\n\nif c0 then\nwhile(c0)do\nbegin\ndec(ind1);\ninc(c);\nend;\n\nif c0 then\nwhile(c0)do\nbegin\ndec(ind2);\ninc(c);\nend;\n\n\na:=a+ind1;\nb:=b+ind2;\nc:=c+ind3;\n\nind1:=0; ind2:=0;ind3:=0;\n\nend;\n\nwriteln('Yes');\n\n\n\nend.\n\n"}, {"source_code": "const\n fi='';\n fa='';\nvar\n a,b,c,x,y,z:longint;\n kt:boolean;\nprocedure xl;\nvar i,j:longint;\n q:array[1..1000] of record a,b,c:longint; end;\n dau,cuoi:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fa);rewrite(output);\n read(a,b,c,x,y,z);\n if (a=x) and (b=y) and (c=z) then write('YES')\n else\n begin\n dau:=1;\n cuoi:=1;\n q[dau].a:=a;\n q[dau].b:=b;\n q[dau].c:=c;\n while dau<=cuoi do\n begin\n if (q[dau].a=2 then\n begin\n inc(cuoi);\n q[cuoi].a:=q[dau].a-2;\n q[cuoi].b:=q[dau].b+1;\n q[cuoi].c:=q[dau].c;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n\n inc(cuoi);\n q[cuoi].a:=q[dau].a-2;\n q[cuoi].b:=q[dau].b;\n q[cuoi].c:=q[dau].c+1;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n end;\n if q[dau].b>=2 then\n begin\n\n inc(cuoi);\n q[cuoi].a:=q[dau].a+1;\n q[cuoi].b:=q[dau].b-2;\n q[cuoi].c:=q[dau].c;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n\n inc(cuoi);\n q[cuoi].a:=q[dau].a;\n q[cuoi].b:=q[dau].b-2;\n q[cuoi].c:=q[dau].c+1;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n end;\n if q[dau].c>=2 then\n begin\n\n inc(cuoi);\n q[cuoi].a:=q[dau].a+1;\n q[cuoi].b:=q[dau].b;\n q[cuoi].c:=q[dau].c-2;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n\n inc(cuoi);\n q[cuoi].a:=q[dau].a;\n q[cuoi].b:=q[dau].b+1;\n q[cuoi].c:=q[dau].c-2;\n if (q[cuoi].a=x) and (q[cuoi].b=y) and(q[cuoi].c=z) then\n begin\n kt:=true;\n break;\n end;\n end;\n inc(dau);\n end;\n if kt then writeln('YES') else write('NO');\n end;\n close(output);\n close(input);\nend;\nbegin\n xl;\nend.\n"}, {"source_code": "program magicspheresa;\n\nvar\n a,b,c:real; x,y,z:integer;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a:=a-x; b:=b-y; c:=c-z;\n if a>0 then a:=round(a/2);\n if b>0 then b:=round(b/2);\n if c>0 then c:=round(c/2);\n if a+b+c>=0 then writeln('YES') else writeln('NO');\n readln;\nend.\n"}, {"source_code": "const\n\tfi = '';\n\tfo = '';\nvar a,b,c,x,y,z,i:longint;\n\tt:array[1..3] of longint;\nbegin\n\tassign(input, fi); reset(input);\n\tassign(output, fo); rewrite(output);\n\treadln(a,b,c);\n\treadln(x,y,z);\n\tif a>=x then\n\tbegin\n\t\tt[1]:=x; b:=b+(a-x) div 2;\n\tend else\n\tbegin\n\t\tt[1]:=x; b:=b-(x-a)*2;\n\tend;\n\tif b>=y then\n\tbegin\n\t\tt[2]:=y; c:=c+(b-y) div 2;\n\tend else\n\tbegin\n\t\tt[2]:=y; c:=c-(y-b)*2;\n\tend;\n\tif c>=z then writeln('Yes') else writeln('No');\n\tclose(input); close(output);\nend.\n"}, {"source_code": "var a,b,c,x,y,z,aa,bb,cc:longint;\n begin\n read(a,b,c);\n read(x,y,z);\n aa:=a-x;\n bb:=b-y;\n cc:=c-z;\n if aa<0 then\n begin\n while (bb-2>=0) and (aa<0) do\n begin\n dec(bb,2);\n inc(aa,2);\n end;\n while (cc-2>=0) and (aa<0) do\n begin\n dec(cc,2);\n inc(aa,2);\n end;\n end;\n if bb<0 then\n begin\n while (aa-2>=0) and (bb<0) do\n begin\n dec(aa,2);\n inc(bb,2);\n end;\n while (cc-2>=0) and (bb<0) do\n begin\n dec(cc,2);\n inc(bb,2);\n end;\n end;\n if cc<0 then\n begin\n while (aa-2>=0) and (cc<0) do\n begin\n dec(aa,2);\n inc(cc,2);\n end;\n while (bb-2>=0) and (cc<0) do\n begin\n dec(bb,2);\n inc(cc,2);\n end;\n end;\n if (aa>=0) and (bb>=0) and (cc>=0) then write('Yes') else write('No');\n end."}, {"source_code": "Var a,b,c,a1,b1,c1:longint;\n Begin \n readln(a,b,c);\n readln(a1,b1,c1);\n if (a>=a1) and (b>=b1) and (c>=1)\n then writeln('Yes')\n else writeln('No');\n End."}, {"source_code": "var a,b,c,x,y,z:longint;\nbegin\nread(a,b,c);\nread(x,y,z);\nif x>a then begin dec(b,x-a); dec(c,x-a); a:=0; end\n else dec(a,x);\nif y>b then begin dec(a,y-b); dec(c,y-b); b:=0; end\n else dec(b,y);\nif z>c then begin dec(a,z-c); dec(b,z-a); c:=0; end\n else dec(c,z);\nif (a>=0) and (b>=0) and (c>=0) then write('YES') else write('NO');\nend.\n"}, {"source_code": "const\n\tfi = '';\n\tfo = '';\nvar a,b,c,x,y,z,i:longint;\n\tt:array[1..3] of longint;\nbegin\n\tassign(input, fi); reset(input);\n\tassign(output, fo); rewrite(output);\n\treadln(a,b,c);\n\treadln(x,y,z);\n\tif a>=x then\n\tbegin\n\t\tt[1]:=x; b:=b+(a-x) div 2;\n\tend else\n\tbegin\n\t\tt[1]:=x; b:=b-(x-a)*2;\n\tend;\n\tif b>=y then\n\tbegin\n\t\tt[2]:=y; c:=c+(b-y) div 2;\n\tend else\n\tbegin\n\t\tt[2]:=y; c:=c-(y-b)*2;\n\tend;\n\tif c>=z then writeln('Yes') else writeln('No');\n\tclose(input); close(output);\nend.\n"}, {"source_code": "var a,b,c,x,y,z,k:integer;\nbegin\n read(a,b,c);\n read(x,y,z);\n if a>=x then k:=a-x else k:=2*(a-x);\n if b>=y then k:=k+(b-y) else k:=k-2*(y-b);\n if c>=z then k:=k+(c-z) else k:=k-2*(z-c);\n if k<0 then writeln('No') else writeln('Yes');\nend.\n \n"}, {"source_code": "uses math;\nvar a, _a : array[1..3] of longint;\n j, i, mx, io: longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n mx:=-10000000;\n for j:=1 to 3 do begin io:=i; mx:=max(mx,a[i]); end;\n dec(a[io],_a[i]-a[i]);\n inc(a[i],_a[i]-a[i]);\n for j:=1 to 3 do if a[j]<_a[j] then\n begin\n writeln('No'); halt;\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "Var a,b,c,a1,b1,c1:longint;\n Begin \n readln(a,b,c);\n readln(a1,b1,c1);\n if (a>=a1) and (b>=b1) and (c>=1)\n then writeln('Yes')\n else writeln('No');\n End."}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n read(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) and (b>x) and (c>x) then write('YES');\n if (a>x) then begin\n if a-x>1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (b>y) then begin\n if b-y>1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (c>z) then begin\n if c-z>1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "var cl: array [1..3] of longint;\n\t\tco, can, dm, i, tmp: longint;\n\t\tlg: boolean;\nbegin\n\tco:=0; can:=0;\n\tfor i:=1 to 3 do \n\t\tbegin\n\t\t\tread(cl[i]); inc(co,cl[i]);\n\t\tend;\n\tfor i:=1 to 3 do \n\t\tbegin\n\t\t\tread(tmp); cl[i]:=cl[i]-tmp; inc(can,tmp);\n\t\tend;\n\tdm:=0;\n\tif co0) do\n\t\t\tbegin\n\t\t\t\tdec(cl[dm],2); lg:=true;\n\t\t\t\tfor i:=1 to 3 do\n\t\t\t\t\tif (odd(cl[i])) then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tinc(cl[i]); lg:=false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\t\tif lg then\n\t\t\t\t\tfor i:=1 to 3 do\n\t\t\t\t\t\tif (cl[i]<0) then \n\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\tinc(cl[i]);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tend;\n\t\t\t\tif lg then \n\t\t\t\t\tif dm=3 then inc(cl[1])\n\t\t\t\t\telse inc(cl[dm+1]);\n\t\t\t\tdec(co);\n\t\t\tend;\n\t\tif co0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twriteln('No');\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tend;\n\t\t\t\t\twriteln('Yes'); halt;\n\t\t\tend;\n\tuntil false;\nend.\n"}, {"source_code": "Var a,b,c,x,y,z,s,s1:longint;\n Begin \n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c=0) or (x+y+z=0) then writeln('No')\n else begin\n if a+b+c<=x+y+z then writeln('No')\n else begin \n if a>x then s:=s+ (a-x) div 2;\n if b>y then s:=s+(b-y) div 2;\n if c>z then s:=s+(c-z) div 2;\n if a=s1 then writeln('Yes')\n else writeln('No');\n end;\n end;\nEnd."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c,x,y,z:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:boolean;\n var tg:longint;\n begin\n if (a>=x) and (b>=y) and (c>=z) then exit(true);\n if ((a<=x) and (b<=y)) or\n ((a<=x) and (c<=z)) or\n ((b<=y) and (c<=z)) then exit(false);\n tg:=0;\n repeat\n inc(tg);\n if a>=x+2 then\n begin\n dec(a,2);\n if b=y+2 then\n begin\n dec(b,2);\n if a=z+2 then\n begin\n dec(c,2);\n if b3000000 then exit(false);\n until (a>=x) and (b>=y) and (c>=z);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,a,b,c,x,y,z);\n if calc then write(fo,'Yes') else write(fo,'No');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var\n a,b,c,x,y,z,k: int64;\n i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n if x > a then \n for i:=1 to x-a do \n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2); \n end;\n\n if y > b then \n for i:=1 to y-b do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2); \n end;\n if z > c then \n for i:=1 to z-c do \n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2); \n end;\n writeln('Yes');\nend.\n\n\n\n "}, {"source_code": "Var a,b,c,a1,b1,c1:longint;\n Begin \n readln(a,b,c);\n readln(a1,b1,c1);\n if (a+b+c)>=(a1+b1+c1+2) then writeln('Yes')\n else writeln('No');\n End."}, {"source_code": "uses math;\nvar a,b,c,tr,vis,x,y,z:longint;\n begin\n read(a,b,c);\n read(x,y,z);\n\n tr:=max(x-a,0)+max(y-b,0)+max(z-c,0);\n vis:=max(a-x,0)+max(b-y,0)+max(c-z,0);\n\n if vis div 2>=tr then writeln('YES') else writeln('NO');\n end."}, {"source_code": "var a,b,c,s,t,x,y,z:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\ns:=a+b+c;\nt:=x+y+z;\nif abs(t-s)>2 then writeln('YES')else writeln('NO');\nend."}, {"source_code": "uses math;\nvar a,b,c:longint;\n x,y,z,s,t,dem:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n dem:=0;\n if a>=x then inc(dem);\n if b>=y then inc(dem);\n if c>=z then inc(dem);\n if dem<2 then write('No')\n else\n begin\n if dem=3 then write('Yes');\n if dem=2 then\n begin\n s:=maxlongint;\n if a-x>0 then s:=min(s,a-x)\n else t:=a-x;\n if b-y>0 then s:=min(s,b-y)\n else t:=b-y;\n if c-z>0 then s:=min(s,c-z)\n else t:=c-z;\n if s>=abs(t) then write('Yes')\n else write('No');\n end;\n end;\nend.\n"}, {"source_code": "program cf606A;\nvar a,b,c,x,y,z:int64;\n\nbegin\nread(a,b,c,x,y,z);\nif a>x then\n begin\n a:=a-x;\n x:=0;\n end\nelse\n begin\n a:=0;\n x:=x-a;\n end;\nif b>y then\n begin\n b:=b-y;\n y:=0;\n end\nelse\n begin\n b:=0;\n y:=y-b;\n end;\nif c>z then\n begin\n c:=c-z;\n z:=0;\n end\nelse\n begin\n c:=0;\n z:=z-c;\n end;\n\nif (x+y+z)*2<=(a+b+c) then\n writeln('Yes')\nelse\n writeln('No');\nend."}, {"source_code": "var\n a,b,c,x,y,z,s1,s2,i : longint;\n\n function gt(x,y : longint) : longint;\n begin\n if y > x then exit(0) else exit((x-y) div 2);\n end;\n\nbegin\n readln(a,b,c,x,y,z);\n if a >= x then begin\n s1:=gt(a,x);\n dec(a,s1*2);\n inc(b,s1 div 2); inc(c,s1 div 2);\n end;\n if b >= y then begin\n s1:=gt(b,y);\n dec(b,s1*2);\n inc(a,s1 div 2); inc(c,s1 div 2);\n end;\n if c >= z then begin\n s1:=gt(c,z);\n dec(c,s1*2);\n inc(a,s1 div 2); inc(b,s1 div 2);\n end;\n if a < x then begin\n s1:=gt(b,y); s2:=gt(c,z);\n if s1+s2+a < x then begin writeln('No'); halt; end else begin\n inc(a,s1+s2);\n dec(b,s1*2); dec(c,s2*2);\n end;\n end;\n if b < y then begin\n s1:=gt(a,x); s2:=gt(c,z);\n if s1+s2+b < y then begin writeln('No'); halt; end else begin\n inc(b,s1+s2);\n dec(a,s1*2); dec(c,s2*2);\n end;\n end;\n if c < z then begin\n s1:=gt(b,y); s2:=gt(a,x);\n if s1+s2+c < z then begin writeln('No'); halt; end else begin\n inc(c,s1+s2);\n dec(b,s1*2); dec(a,s2*2);\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n read(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) then begin\n if a-x>1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (b>y) then begin\n if b-y>1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (c>z) then begin\n if c-z>1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "program ex;\n var a,b,c,x,y,z,m,n,ma,mb,mc:longint;\nbegin\nreadln(input,a,b,c);\nreadln(input,x,y,z);\nm:=0; n:=0; \nma:=a-x; \nmb:=b-y; \nmc:=c-z;\nif ma>=0 then m:=m+ma div 2 else n:=n-ma;\nif mb>=0 then m:=m+mb div 2 else n:=n-mb;\nif mc>=0 then m:=m+mc div 2 else n:=n-mc;\nif (m>n) and ((m<>0) and (n<>0)) then writeln(output,'Yes') else writeln(output,'No'); \nend. "}, {"source_code": "var a,b,c,a1,b1,c1,x,z,y:longint;\nbegin\nread(a,b,c,a1,b1,c1);\na1:=a-x;\nb1:=b-y;\nc1:=c-z;\nif a1>0 then a1:=a1 div 2;\nif b1>0 then b1:=b1 div 2;\nif c1>0 then c1:=c1 div 2;\nif a1+b1+c1>=0 then\nwrite('Yes')\nelse write('No');\nend.\n\n"}, {"source_code": "Var a,b,c,x,y,z,s,s1:longint;\n Begin \n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c=0) or (x+y+z=0) then writeln('Yes')\n else begin\n if a+b+c<=x+y+z then writeln('No')\n else begin \n if a>x then s:=s+ (a-x) div 2;\n if b>y then s:=s+(b-y) div 2;\n if c>z then s:=s+(c-z) div 2;\n if a=s1 then writeln('Yes')\n else writeln('No');\n end;\n end;\nEnd."}, {"source_code": "var a,b,c,x,y,z,r1,r2,r3,s1,a1,b1:integer;\nbegin\nread(a,b,c);\nread(x,y,z);\nr1:=a-x;\nr2:=b-y;\nr3:=c-z;\nif ((a-x)>0) and ((b-y)>0)then\na1:=a-x;\nb1:=b-y;\ns1:=a1+b1+c;\nif s1>=z then\nwrite('Yes')\nelse \nif (r1<0) or (r2<0) or (r3<0) then\nwrite('No')\nelse\nif (r1>0) and (r2>0) and (r3>0) then\nwrite('Yes')\nend."}, {"source_code": "var\n a,b,c,x,y,z,k,i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n\n if x > a then\n if 2*(x-a) <= k then dec(k,2*(x-a)) else begin writeln('No'); halt; end;\n\n if y > b then\n if 2*(y-b) <= k then dec(k,2*(y-b)) else begin writeln('No'); halt; end;\n\n if z > c then\n if 2*(z-c) <= k then dec(k,2*(z-c)) else begin writeln('No'); halt; end;\n\n writeln('Yes');\nend.\n\n\n\n\n\n\nvar\n a,b,c,x,y,z,k,i,a1,b1,c1: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a1:=a;\n b1:=b;\n c1:=c;\n while (a1 > x) or (b1 > y) or (c1 > z) do\n begin\n if (a1-x) >= 2 then begin dec(a1,2); inc(k); end else break;\n if (b1-y) >= 2 then begin dec(b1,2); inc(k); end else break;\n if (c1-z) >= 2 then begin dec(c1,2); inc(k); end else break;\n end;\n\n writeln(k);\n if x > a then\n for i:=1 to x-a do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if y > b then\n forvar\n a,b,c,x,y,z,k: int64;\n i: longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n\n if (a-x) > 0 then inc(k,a-x);\n if (b-y) > 0 then inc(k,b-y);\n if (c-z) > 0 then inc(k,c-z);\n if x > a then\n for i:=1 to x-a do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n\n if y > b then\n for i:=1 to y-b do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n if z > c then\n for i:=1 to z-c do\n begin\n if k < 2 then begin writeln('No'); halt; end;\n dec(k,2);\n end;\n writeln('Yes');\nend. i:=1 to y-b do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if z > c then\n for i:=1 to z-c do\n begin\n if k = 0 then begin writeln('No'); halt; end;\n dec(k);\n end;\n\n if k < 0 then writeln('No') else writeln('Yes');\nend.\n\n\n\n\n"}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i, j, ind, maxa, maxb, temp: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n for i:=1 to 3 do\n begin\n s[1]:=s[1]+a[i];\n s[2]:=s[2]+b[i];\n end;\n for i:=3 downto 2 do\n begin\n maxa:=1; maxb:=1;\n for j:=1 to i do\n begin\n if a[maxa]=b[i]then inc(j)\n else ind:=i;\n maxa:=b[ind]-a[ind];\n end;\n for i:=1 to 3 do\n if i<>ind then\n begin\n inc(temp);\n s[temp]:=a[i]-b[i];\n end;\n if s[1]=b[ind]-a[ind] then writeln(g,'YES')\n else writeln(g,'NO');\n end;\n close(f); close(g);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c,x,y,z:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:boolean;\n begin\n if ((a<=x) and (b<=y)) or ((a<=x) and (c<=z)) or\n ((b<=y) and (c<=z)) then exit(false);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,a,b,c,x,y,z);\n if calc then write(fo,'Yes') else write(fo,'No');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "type int3 = 1..3;\nvar\n i, f : int3;\n a, x : array [int3] of longint;\nbegin\n for i := 1 to 3 do\n read(a[i]);\n for i := 1 to 3 do\n read(x[i]);\n for i := 1 to 3 do\n begin\n while a[i] > x[i] do\n begin\n dec(a[i], 2);\n if i = 3 then inc(a[1]) else inc(a[i+1]);\n end;\n end;\n for i := 1 to 3 do\n begin\n if (a[i] - x[i]) mod 2 <> 0 then\n begin\n f := 1;\n break;\n end;\n end;\n if f = 0 then writeln('Yes') else writeln('No');\nend.\n"}, {"source_code": "var\n a,b,c,x,y,z,s1,s2,i : longint;\n\n function gt(x,y : longint) : longint;\n begin\n if y > x then exit(0) else exit((x-y) div 2);\n end;\n\nbegin\n readln(a,b,c,x,y,z);\n if a >= x then begin\n s1:=gt(a,x);\n dec(a,s1*2);\n inc(b,s1 div 2); inc(c,s1 div 2);\n end;\n if b >= y then begin\n s1:=gt(b,y);\n dec(b,s1*2);\n inc(a,s1 div 2); inc(c,s1 div 2);\n end;\n if c >= z then begin\n s1:=gt(c,z);\n dec(c,s1*2);\n inc(a,s1 div 2); inc(b,s1 div 2);\n end;\n if a < x then begin\n s1:=gt(b,y); s2:=gt(c,z);\n if s1+s2+a < x then begin writeln('No'); halt; end else begin\n inc(a,s1+s2);\n dec(b,s1*2); dec(c,s2*2);\n end;\n end;\n if b < y then begin\n s1:=gt(a,x); s2:=gt(c,z);\n if s1+s2+b < y then begin writeln('No'); halt; end else begin\n inc(b,s1+s2);\n dec(a,s1*2); dec(c,s2*2);\n end;\n end;\n if c < z then begin\n s1:=gt(b,y); s2:=gt(a,x);\n if s1+s2+c < z then begin writeln('No'); halt; end else begin\n inc(c,s1+s2);\n dec(b,s1*2); dec(a,s2*2);\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,c,x,y,z,n,m:longint;\n\nBegin\n assign(input,fi);reset(input);\n read(a,b,c,x,y,z);\n close(input);\n\n assign(output,fo);rewrite(output);\n if (a>x) then begin\n if a-x=1 then n:=n+(a-x);\n end else m:=m+x-a;\n if (b>y) then begin\n if b-y=1 then n:=n+(b-y);\n end else m:=m+y-b;\n if (c>z) then begin\n if c-z=1 then n:=n+(c-z);\n end else m:=m+z-c;\n if (n div 2>=m) and (n<>0) then write('YES') else write('NO');\n close(output);\nEND.\n"}, {"source_code": "Var a,b,c,x,y,z,s,s1:longint;\n Begin \n readln(a,b,c);\n readln(x,y,z);\n if (a+b+c=0) or (x+y+z=0) then writeln('No')\n else begin\n if a+b+c<=x+y+z then writeln('No')\n else begin \n if a>x then s:=s+ (a-x) div 2;\n if b>y then s:=s+(b-y) div 2;\n if c>z then s:=s+(c-z) div 2;\n if a=s1 then writeln('Yes')\n else writeln('No');\n end;\n end;\nEnd."}, {"source_code": "var a,b,c,x,y,z,s,s1:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a+b+c<=x+y+z then writeln('No')\n else begin\n s:=0;s1:=0;\n if a>x then s:=(a-x) div 2+s ;\n if b>y then s:=(b-y) div 2+s;\n if c>z then s:=(c-z) div 2 +s;\n if as1 then writeln('Yes')\n else writeln('No'); \n end;\n end."}, {"source_code": "program arsofurs;\nvar t,ind3,ind1,ind2,n,m,x,y,z,a,b,c:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\n\nwhile(a<>x)or(b<>y)or(c<>z)do begin\n\n\nif (a<=x)and(b<=y)and(c<=z)then begin writeln('No');halt;end;\nif t>=3 then begin writeln('No');halt;end else t:=0;\nif (a<=x)and(b<=y)and(c<=z+1)then begin writeln('No');halt;end;\nif (a<=x)and(b<=y+1)and(c<=z)then begin writeln('No');halt;end;\nif (a<=x+1)and(b<=y)and(c<=z)then begin writeln('No');halt;end;\n\n\nif (x<>0)then\n\nwhile(a>x)do\nbegin\nif a-2<0 then begin inc(t); break;end;\nif (a-20>0)and(a-20>x)then begin ind1:=ind1+10;a:=a-20;end else begin\ninc(ind1);\na:=a-2; end;\nend else\n\nwhile(a>0)do\nbegin\nif a-2<0 then begin inc(t); break;end;\nif (a-20>0)and(a-20>x)then begin ind1:=ind1+10;a:=a-20;end else begin\ninc(ind1);a:=a-2;end;\nend;\n\nif (y<>0)then\n\nwhile(b>y)do\nbegin\nif b-2<0 then begin inc(t); break;end;\nif (b-20>0)and(b-20>y)then begin ind2:=ind2+10;b:=b-20;end else begin\ninc(ind2);\nb:=b-2;end;\nend else\n\nwhile(b>0)do\nbegin\nif b-2<0 then begin inc(t); break;end;\nif (b-20>0)and(b-20>y)then begin ind2:=ind2+10;b:=b-20;end else begin\ninc(ind2);\nb:=b-2; end;\nend;\n\nif (z<>0)then\n\nwhile(c>z)do\nbegin\nif c-2<0 then begin inc(t); break;end;\nif (c-20>0)and(c-20>z)then begin ind3:=ind3+10;c:=c-20;end else begin\ninc(ind3);\nc:=c-2; end;\nend else\n\nwhile(c>0)do\nbegin\nif c-2<0 then begin inc(t); break;end;\nif (c-20>0)and(c-20>z)then begin ind3:=ind3+10;c:=c-20;end else begin\ninc(ind3);\nc:=c-2; end;\nend;\n\nif a0 then\nwhile(a0)do\nbegin\ndec(ind2);\ninc(a);\nend;\n\nif a0 then\nwhile(a0)do\nbegin\ndec(ind3);\ninc(a);\nend;\n\nif b0 then\nwhile(b0)do\nbegin\ndec(ind1);\ninc(b);\nend;\n\nif b0 then\nwhile(b0)do\nbegin\ndec(ind3);\ninc(b);\nend;\n\n\nif c0 then\nwhile(c0)do\nbegin\ndec(ind1);\ninc(c);\nend;\n\nif c0 then\nwhile(c0)do\nbegin\ndec(ind2);\ninc(c);\nend;\n\n\na:=a+ind1;\nb:=b+ind2;\nc:=c+ind3;\n\nind1:=0; ind2:=0;ind3:=0;\n\nend;\n\nwriteln('Yes');\n\n\n\nend.\n\n"}, {"source_code": "uses math;\nvar\n a,b,c,x,y,z,k1,k2:longint;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n inc(k1,max(0,x-a));\n inc(k2,max(0,a-x));\n inc(k1,max(0,y-b));\n inc(k2,max(0,b-y));\n inc(k1,max(0,z-c));\n inc(k2,max(0,c-z));\n if k2 div 2>=k1 then writeln('Yes')else writeln('No');\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b,s: array[1..3] of longint;\n i, j, sl, maxa, maxb, temp: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,a[1],a[2],a[3]);\n readln(f,b[1],b[2],b[3]);\n for i:=1 to 3 do\n begin\n s[1]:=s[1]+a[i];\n s[2]:=s[2]+b[i];\n end;\n sl:=abs(s[1]-s[2]);\n for i:=3 downto 2 do\n begin\n maxa:=1; maxb:=1;\n for j:=1 to i do\n begin\n if a[maxa]=b[i] then inc(j);\n temp:=temp+a[i]-b[i];\n end;\n if j=1 then writeln(g,'NO')\n else\n begin\n if j=3 then writeln(g,'YES')\n else\n if temp>sl then writeln(g,'YES')\n else writeln(g,'NO');\n end;\n close(f); close(g);\nend."}, {"source_code": "var m,n,i:integer;\nbegin\nread (n);\nfor i:=1 to n do begin\nread(m);\nwhile m>0 do begin\nwrite ('p');\nif m-1>0 then begin\nif i<=n then begin\nwrite ('RL');\nend\nelse\nwrite ('RL');\nend\nelse if i x then exit(0) else exit((x-y) div 2);\n end;\n\nbegin\n readln(a,b,c,x,y,z);\n if a >= x then begin\n s1:=gt(a,x);\n dec(a,s1*2);\n inc(b,s1 div 2); inc(c,s1 div 2);\n end;\n if b >= y then begin\n s1:=gt(b,y);\n dec(b,s1*2);\n inc(a,s1 div 2); inc(c,s1 div 2);\n end;\n if c >= z then begin\n s1:=gt(c,z);\n dec(c,s1*2);\n inc(a,s1 div 2); inc(b,s1 div 2);\n end;\n if a < x then begin\n s1:=gt(b,y); s2:=gt(c,z);\n if s1+s2+a < x then begin writeln('No'); halt; end else begin\n inc(a,s1+s2);\n dec(b,s1*2); dec(c,s2*2);\n end;\n end;\n if b < y then begin\n s1:=gt(a,x); s2:=gt(c,z);\n if s1+s2+b < y then begin writeln('No'); halt; end else begin\n inc(b,s1+s2);\n dec(a,s1*2); dec(c,s2*2);\n end;\n end;\n if c < z then begin\n s1:=gt(b,y); s2:=gt(a,x);\n if s1+s2+c < z then begin writeln('No'); halt; end else begin\n inc(c,s1+s2);\n dec(b,s1*2); dec(a,s2*2);\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "var\n q:array[0..100000] of record\n f1,f2,f3:longint;\n end;\n a,b,c,x,y,z,q1,q2:longint;\nprocedure add(f1,f2,f3:longint);\nbegin\n if (f1<0)or(f2<0)or(f3<0) then exit;\n if (f1=x)and(f2=y)and(f3=z) then begin writeln('Yes');halt;end;\n q[q1].f1:=f1;q[q1].f2:=f2;q[q1].f3:=f3;\n inc(q1);\n if q1=50000 then q1:=0;\nend;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n q1:=0;\n q2:=0;\n add(a,b,c);\n while q1<>q2 do with q[q2] do\n begin\n add(f1-2,f2+1,f3);\n add(f1-2,f2,f3+1);\n add(f1+1,f2-2,f3);\n add(f1,f2-2,f3+1);\n add(f1+1,f2,f3-2);\n add(f1,f2+1,f3-2);\n inc(q2);\n if q2=50000 then q2:=0;;\n end;\n writeln('No');\nend.\n"}, {"source_code": "var\n ax,by,cz,k,n,m,i,j,a,b,c,x,y,z:int64;\nprocedure cool;\nbegin\n writeln('Yes');\n halt;\nend;\nprocedure error;\nbegin\n writeln('No');\n halt;\nend;\nbegin\n readln(a,b,c);\n readln(x,y,z);\n if a>x then inc(k,(x*2)+a-x) else inc(k,a*2);\n if b>y then inc(k,(y*2)+b-y) else inc(k,b*2);\n if c>z then inc(k,(z*2)+c-z) else inc(k,c*2);\n if k div 2 >=x+y+z then cool else error;\nend.\n\n"}, {"source_code": "var\n a, b, c, x, y, z, cnt, k: LongInt;\n \nbegin\n Read (a, b, c, x, y, z);\n \n cnt:= 0;\n k:= 0;\n \n if a > x then\n cnt:= cnt + (a - x) div 2\n else\n k:= k + a - x; \n \n if b > y then\n cnt:= cnt + (b - y) div 2\n else\n k:= k + b - y;\n \n if c > z then\n cnt:= cnt + (c - z) div 2\n else\n k:= k + c - x;\n \n WriteLn (cnt, ' ', k);\n \n if k + cnt >= 0 then\n WriteLn ('Yes')\n else\n WriteLn ('No')\nend.\n \n "}, {"source_code": "program magicspheresa;\n\nvar\n a,b,c,a1,b1,c1:real;\n\nbegin\n readln(a,b,c);\n readln(a1,b1,c1);\n while a>a1 do begin a:=a-2; b:=b+1 end;\n while b>b1 do begin b:=b-2; c:=c+1 end;\n while c>c1 do begin c:=c-2; a:=a+1 end;\n if (a<>a1) or (b<>b1) or (c<>c1) then writeln('NO') else writeln('YES');\n readln;\nend."}, {"source_code": "\nconst\n tfi='606A.inp';\n tfo='606A.out';\n\nvar\n fi, fo: text;\n a, b, c: array[1..3] of longint;\n\nprocedure __;\nbegin\n \n readln( a[1], a[2], a[3]);\n readln(c[1], c[2], c[3]);\nend;\n\nprocedure xuly;\nvar\n du, dem, i, j: longint;\nbegin\n du := 0;b := a;\n for i:=1 to 3 do\n begin\n if b[i]>c[i] then\n begin\n dem := 1;\n while b[i]-dem*2>=c[i] do\n begin\n dem :=dem*2;\n inc(du);\n end;\n if dem<>1then b[i] := b[i]-dem;\n end\n else if (b[i]0) then\n while b[i]+1<=c[i] do\n begin\n b[i] := b[i]+1;\n du := du-1;\n end;\n end;\n for j:=1 to 3 do\n if b[j]c[i] then\n begin\n dem := 1;\n while b[i]-dem*2>=c[i] do\n begin\n dem :=dem*2;\n inc(du);\n end;\n if dem<>1then b[i] := b[i]-dem;\n end\n else if (b[i]0) then\n while b[i]+1<=c[i] do\n begin\n b[i] := b[i]+1;\n du := du-1;\n end;\n end;\n break;\n end;\n for i:=1 to 3 do\n if b[i]x then begin\n dec(a,x);\n x:=0;\nend\nelse begin\n\n dec(x,a);\n a:=0;\nend;\n\nif b>y then begin\n dec(b,y);\n y:=0;\nend\nelse begin\n\n dec(y,b);\n b:=0;\nend;\n\nif c>z then begin\n dec(c,z);\n z:=0;\nend\nelse begin\n c:=0;\n dec(z,c);\nend;\nneed:=x+y+z;\nwriteln(need);\nneed:=need-(a div 2+ b div 2+ c div 2);\nif need<=0 then writeln('Yes')\nelse\nwriteln('No');\nend."}, {"source_code": "program ex;\n var a,b,c,x,y,z,ma,mb,mc,mia,mib,mic:longint;\nbegin\nreadln(input,a,b,c);\nreadln(input,x,y,z);\nma:=a-x; mia:=0; mib:=0; mic:=0; if ma>=0 then mia:=0-ma else begin mia:=ma; ma:=0; end;\nmb:=b-y; if mb>=0 then mib:=0-mb else begin mib:=mb; mb:=0; end;\nmc:=c-z; if mc>=0 then mic:=0-mc else begin mic:=mc; mc:=0; end;\nif ma div 2 +mb div 2+mc div 2>=mia+mib+mic then writeln(output,'Yes') else writeln(output,'No'); \nend. "}, {"source_code": "var a, _a : array[1..3] of longint;\n i : longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n if i=2 then begin dec(a[1],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=1 then begin dec(a[2],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=3 then begin dec(a[1],_a[i]-a[i]); dec(a[2],_a[i]-a[i]); end;\n inc(a[i], _a[i]-a[i]);\n end;\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n\n writeln('No'); halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "program magicspheresa;\n\nvar\n a,b,c:real; x,y,z:integer;\n\nbegin\n readln(a,b,c);\n readln(x,y,z);\n a:=a-x; b:=b-y; c:=c-z;\n if a>0 then a:=round(a/2);\n if b>0 then b:=round(b/2);\n if c>0 then c:=round(c/2);\n if a+b+c>=0 then writeln('YES') else writeln('NO');\n readln;\nend.\n"}, {"source_code": "var a,b,c,x,y,z,s,t:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\ns:=a+b+c;\nt:=x+y+z;\nif abs(t-s)>1 then writeln('YES')else write('NO');\nend."}, {"source_code": "var\nneed,a,b,c,x,y,z:longint;\nbegin\nreadln(a,b,c);\nreadln(x,y,z);\nif a>x then begin\n dec(a,x);\n x:=0;\nend\nelse begin\n a:=0;\n dec(x,a);\nend;\n\nif b>y then begin\n dec(b,y);\n y:=0;\nend\nelse begin\n b:=0;\n dec(y,b);\nend;\n\nif c>z then begin\n dec(c,z);\n z:=0;\nend\nelse begin\n c:=0;\n dec(z,c);\nend;\nneed:=x+y+z;\nneed:=need-(a div 2+ b div 2+ c div 2);\nif need<=0 then writeln('Yes')\nelse\nwriteln('No');\nend."}, {"source_code": "uses math;\nvar a, _a : array[1..3] of longint;\n j, i, mx, io: longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n mx:=-10000000;\n for j:=1 to 3 do begin io:=i; mx:=max(mx,a[i]); end;\n dec(a[io],2*(_a[i]-a[i]));\n inc(a[i],_a[i]-a[i]);\n for j:=1 to 3 do if a[j]<_a[j] then\n begin\n writeln('No'); halt;\n end;\n end;\n writeln('Yes');\nend."}, {"source_code": "var a, _a : array[1..3] of longint;\n i : longint;\nbegin\n for i:=1 to 3 do read(A[i]);\n for i:=1 to 3 do read(_a[i]);\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n if i=2 then begin dec(a[1],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=1 then begin dec(a[2],_a[i]-a[i]); dec(a[3],_a[i]-a[i]); end;\n if i=3 then begin dec(a[1],_a[i]-a[i]); dec(a[2],_a[i]-a[i]); end;\n inc(a[i], _a[i]-a[i]);\n end;\n for i:=1 to 3 do if a[i]<_a[i] then\n begin\n\n writeln('No'); halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "var a,b,c,a1,b1,c1,x,z,y:longint;\nbegin\nread(a,b,c,a1,b1,c1);\na1:=a-x;\nb1:=b-y;\nc1:=c-z;\nif a1>0 then a1:=a1 div 2;\nif b1>0 then b1:=b1 div 2;\nif c1>0 then c1:=c1 div 2;\nif a1+b1+c1>=0 then\nwrite('Yes')\nelse write('No');\nend.\n\n"}], "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"} {"source_code": "uses math;\nvar i,j:char;\n k,rotation:integer;\n s:string;\n count:array['a'..'z'] of integer;\nbegin\n k:=1;\n for i:='a' to 'm' do\n begin\n count[i]:=k;\n k:=k+1;\n end;\n k:=0;\n for j:='z' downto 'n' do\n begin\n count[j]:=k;\n k:=k-1;\n end; \n readln(s);\n if count[s[1]]-count['a']<=13 then rotation:=abs(count[s[1]]-count['a'])\n else rotation:=abs(26-abs(count[s[1]]-count['a']));\n for k:=2 to length(s) do\n begin\n if abs(count[s[k]]-count[s[k-1]])<=13 then rotation:=rotation+abs(count[s[k]]-count[s[k-1]])\n else rotation:=rotation+abs(26-abs(count[s[k]]-count[s[k-1]]));\n end;\n writeln(rotation); \nend.\n\n", "positive_code": [{"source_code": "{$mode objfpc}\n\nuses math;\n\nvar\n s:ansistring;\n i,kq,x,y:integer;\n o:char;\n\nbegin\n readln(s);\n o:='a';\n for i:=1 to length(s) do\n begin\n x:=ord(o) - ord(s[i]);\n if x < 0 then x:=x + 26;\n y:=ord(s[i]) - ord(o);\n if y < 0 then y:=y + 26;\n kq:=kq + min(x,y);\n o:=s[i];\n end;\n write(kq);\nend."}, {"source_code": "var s:string;\n ans,i,now,x:longint;\nbegin\n now:=97;\n readln(s);\n ans:=0;\n for i:=1 to length(s) do\n begin\n x:=abs(ord(s[i])-now);\n if (26-x26-abs(pos(s[i],'abcdefghijklmnopqrstuvwxyz')-p)\n then k:=k+26-abs(pos(s[i],'abcdefghijklmnopqrstuvwxyz')-p) else\n k:=k+abs(pos(s[i],'abcdefghijklmnopqrstuvwxyz')-p);\n p:=pos(s[i],'abcdefghijklmnopqrstuvwxyz');\n end;\n \nwriteln(k);\nend."}, {"source_code": "var i,j,m,n,ans,a,now:longint;\n s:ansistring;\nbegin\n readln(s);\n now:=0;\n for i:=1 to length(s) do begin\n a:=ord(s[i])-ord('a');\n if abs(a-now)<=13 then ans:=ans+abs(a-now) else ans:=ans+26-abs(a-now);\n now:=a;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var s:string;\nd,i,n,b,a:integer;\nbegin\nread (s);\nd:=length(s);\nb:=ord('a');\nfor i:=1 to d do\nbegin\na:=ord(s[i]);\nif abs(b-a)>13 then n:=n+(26-(abs(b-a))) else n:=n+(abs(b-a));\nb:=a;\nend;\nwrite(n);\nend."}, {"source_code": "var st,alf:string;\nn,i,k,a,p,s1,s2:longint;\nbegin\n alf:='abcdefghijklmnopqrstuvwxyz';\n readln(st);\n n:=length(st);\n a:=1;\n for i:=1 to n do\n begin\n p:=pos(st[i],alf);\n s1:=abs(a-p);\n s2:=26-s1;\n if s1(abs(huruf[awal]-huruf[s[i]])))) then begin\n sum:=sum+(abs(huruf[awal]-huruf[s[i]]));\n end;\n awal:=s[i];\n end;\n writeln(sum);\nend."}, {"source_code": "{$MODE OBJFPC}\n{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n\nuses math;\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n\ntype\n re=record\n x,y:longint;\n end;\n\nprocedure mofile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ELSE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ENDIF}\nend;\n\nprocedure dongfile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ELSE}\n close(input);\n close(output);\n {$ENDIF}\nend;\n\nvar\n kq:longint;\n s:ansistring;\n a:array['a'..'z'] of longint;\n\nprocedure xuli;\nvar\n c:char;\n i:longint;\nbegin\n readln(s);\n for c:='a' to 'z' do a[c]:=ord(c)-ord('a');\n c:='a';\n for i:=1 to length(s) do\n begin\n kq:=kq+min(abs(a[s[i]]-a[c]),26-abs(a[s[i]]-a[c]));\n c:=s[i];\n end;\n writeln(kq);\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n st:string;\n n,i,t,ans:longint;\nfunction min(a,b:longint):longint;\n begin if (ach then sum:=sum+min(ord(s[i])-ord(ch),ord(ch)+26-ord(s[i]));\n if ch>s[i] then sum:=sum+min(ord(ch)-ord(s[i]),ord(s[i])+26-ord(ch));\n ch:=s[i];\n end;\n writeln(sum);\nend."}, {"source_code": "var\nsum,i:integer;\ns:string;\n\nBegin\nreadln (s);\nsum:=0;\ns:='a'+s;\nFor i:=1 to length(s)-1 do \nbegin\n if abs(ord(s[i+1])-ord(s[i]))>=14 then \n sum:=sum+26-abs(ord(s[i+1])-ord(s[i]))\n else sum:=sum+abs(ord(s[i+1])-ord(s[i]));\nend; \nWrite(sum);\nEnd."}, {"source_code": "Var\ns:string;\nn,p,i,t:byte;\nc,a,b:integer;\n\nBegin\nreadln(s);\nn:=length(s);\np:=0;\nc:=0;\n\nFor i:=1 to n do\n begin\n t:=ord(s[i])-ord('a');\n if t

b then inc(c,b) else inc(c,a);\n p:=t\n end;\n\nWrite(c);\nEnd."}, {"source_code": "uses math;\nvar\n s : ansistring;\n i,j,n,m,k : longint;\n c : char;\n\nbegin\n c:='a';\n readln(s);\n for i:=1 to length(s) do begin\n m:=m+min(min(abs(ord(s[i])-ord(c)),abs(ord(c)-ord('a'))+abs(ord('z')-ord(s[i])+1)),abs(ord(s[i])-ord('a'))+abs(ord('z')-ord(c)+1));\n c:=s[i];\n end;\n writeln(m);\nend."}, {"source_code": "program nomera;\n\nvar\n i, t, n, d, r, x: integer;\n s, p: string;\n\n\nbegin\n {ВВОД СТРОКИ Р}\n read(p);\n r := 1;\n s := 'abcdefghijklmnopqrstuvwxyz';\n {ДЛИНА СТРОКИ Р}\n for t := 1 to length(p) do \n begin\n n := n + 1;\n end;\n {СЧЕТ КОЛИЧЕСТВА ХОДОВ}\n for t := 1 to n do \n begin\n for i := 1 to 26 do \n begin\n if s[i] = p[t] then\n d := i - r;\n if (s[i] = p[t]) and (d < 0) then\n d := d * (-1);\n if (d > 13) then\n d := d - 26;\n if (s[i] = p[t]) and (d < 0) then\n d := d * (-1);\n if s[i] = p[t] then\n x := x + d;\n if s[i] = p[t] then\n if s[i] = p[t] then\n r := i;\n end;\n end;\n {ВЫВОД}\n writeln(x);\nend."}, {"source_code": "uses math;\nvar\n s:string;\n m,k,sum,i:longint;\nbegin\n readln(s);\n m:=97;\n for i:=1 to length(s) do\n begin\n k:=ord(s[i]);\n sum:=sum+min(abs(m-k),26-abs(m-k));\n m:=k;\n end;\n writeln(sum);\nend."}, {"source_code": "var\na,s:string;\np,o:longint;\nbegin\nreadln(a);\ns:='abcdefghijklmnopqrstuvwxyz';\nif pos(a[1],s)-1<27-pos(a[1],s)\nthen o:=pos(a[1],s)-1\nelse o:=27-pos(a[1],s);\nfor p:=2 to length(a) do\nif abs(pos(a[p],s)-pos(a[p-1],s))<26-abs(pos(a[p],s)-pos(a[p-1],s))\nthen inc(o,abs(pos(a[p],s)-pos(a[p-1],s))) else\ninc(o,26-abs(pos(a[p],s)-pos(a[p-1],s)));\nwrite(o); end."}, {"source_code": "var\np,ans,d,q,f,i,j:longint;\na:Array[1..100000]of longint;\n\ns:string;\nbegin\nreadln(s);\nfor i:=1 to 26 do begin\n a[i+96]:=i;\nend;\np:=1;\nfor i:=1 to length(s) do begin\n d:=abs(a[ord(s[i])]-p);\n f:=26-abs((a[ord(s[i])]-p));\n if dl then\n begin\n tmp:=l;\n l:=b;\n b:=tmp;\n end;\n rez:=l-b;\n if rez>13 then\n begin\n rez:=26-rez;\n end;\n rez1:=rez1+rez;\n l:=aa;\nend;\nwriteln(rez1);\nreadln;\nreadln;\nend.\n\n"}, {"source_code": "program ideone;\nvar st:string;\n\tx1,x2,s,x,ma,i:longint;\nbegin\n\treadln(st);\n\tma:=0;\n\ts:=0;\n\tfor i:=1 to length(st) do\n\tbegin\n\t\tx:=ord(st[i])-97;\n\t\tx1:=abs(x-ma);\n\t\tif xb) then d := b else d := a;\n if(d>c) then d := c;\n ans := ans + d;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\ns:string;\nind1,min,ans,kol,ind,i:longint;\nbegin\nreadln(s);\nind:=97;\nfor i:=1 to length(s)do begin\nkol:=0;\nind1:=ind;\n while true do begin\n if char(ind1)=s[i] then break\n else begin\n inc(ind1);\n inc(kol);\n if ind1>122 then ind1:=97;\n end;\n end;\n min:=kol;\n kol:=0;\n ind1:=ind;\n while true do begin\n if char(ind1)=s[i] then break\n else begin\n dec(ind1);\n inc(kol);\n if ind1<97 then ind1:=122;\n end;\n end;\n if kol f then \n swap(s,f);\n if (f - s) < (26 + s - f) then \n get_min_moves:= f-s\n else\n get_min_moves:= 26+s-f;\n s:=start;\nend;\n\nfunction count_moves(s:ansistring):longint;\nvar k,i,start:longint;\nbegin\n k:=0;\n start:=1;\n for i:= 1 to length(s) do \n inc(k,get_min_moves(start,ord(s[i])-96));\n\n count_moves:=k;\nend;\n\nvar s:ansistring;\nbegin\n readln(s);\n writeln(count_moves(s));\nend."}, {"source_code": "var s:string;\nr,i,n,x,y:integer;\nbegin\nreadln(s);\ny:=0;\nn:=ord('z')-ord('a')+1;\nfor i:=1 to length(s) do begin\n x:=ord(s[i])-ord('a');\n if x>y then\n if x-y13) then k:=26-k;\nm:=m+k;\nend;\nwrite(m);\nend."}, {"source_code": "var s:string;\n i,n,k,point,max,min:integer;\n mas:array[1..26] of char;\nfunction Index(g:string):byte;\nvar i:integer;\nbegin\nfor i:= 1 to 26 do\n if (mas[i] = g) then Index:=i;\nend;\nbegin\nreadln(s);\nfor i:= 97 to 122 do\n mas[i-96]:=chr(i);\nk:=1;\nfor i:= 1 to length(s) do\n begin\n point:=Index(s[i]);\n if (point > k) then\n begin\n max:=point;\n min:=k;\n end\n else\n begin\n max:=k;\n min:=point;\n end;\n if (abs(max-min)p) then\n begin\n if ord(s[i])-ord(p)<26-(ord(s[i])-ord('a')+1)+ord(p)-ord('a')+1 then\n inc(ans,ord(s[i])-ord(p))\n else\n inc(ans,26-(ord(s[i])-ord('a')+1)+ord(p)-ord('a')+1);\n p:=s[i];\n end\n else\n begin\n if ord(p)-ord(s[i])<26-(ord(p)-ord('a')+1)+ord(s[i])-ord('a')+1 then\n inc(ans,ord(p)-ord(s[i]))\n else\n inc(ans,26-(ord(p)-ord('a')+1)+ord(s[i])-ord('a')+1);\n p:=s[i];\n end;\n end;\n writeln(ans);\nend."}, {"source_code": " var p,s:string;\n k,z,t,l,h:longint;\n begin\n p:='abcdefghijklmnopqrstuvwxyz';\n readln(s);\n k:=1;\n repeat\n inc(z);\n t:=pos(s[z],p);\n h:=abs(t-k);\n if h>26-h then begin\n //writeln(t,' ',k);\n l:=l+(26-h);\n end\n else\n begin\n l:=l+h;\n //writeln(t,' ',k);\n end;\n k:=t;\n until(z=length(s));\n writeln(l);\n end.\n\n\n"}, {"source_code": "program O_O;\nuses math;\nconst\n\tmaxn=1000;\ntype\n\tll=longint;\n\tarr=array[0..maxn,0..maxn] of ll;\nvar\n\ti,j,n,ans:ll;\n\ts:ansistring;\n\tsum:arr;\n\tk:char;\nbegin\n\treadln(s);\n\ts:='a'+s;\n\tn:=26;\n\tfor i:=1 to n do\n\tfor j:=1 to n do\n\tbegin\n\t\tsum[i,j]:=min(abs(i-j),abs(i+n-j));\n\t\tsum[i,j]:=min(sum[i,j],abs(n-i+j));\n\tend;\t\n\tfor i:=1 to length(S)-1 do\n\tbegin\n\t\tinc(ans,sum[ord(s[i])-96,ord(s[i+1])-96]);\n\tend;\n\twriteln(ans);\nend.\t"}, {"source_code": "program O_O;\nuses math;\nvar\n\ti,n,ans:longint;\n\ts:string;\nbegin\n\treadln(s);\n\ts:='a'+s;\n\tfor i:=1 to length(s)-1 do\n\tbegin\n\t\tinc(ans,min(abs(ord(s[i+1])-ord(s[i])),26-abs(ord(s[i+1])-ord(s[i]))));\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "USES Math;\nCONST\n tfi = '';\n tfo = '';\nVAR\n fi,fo : text;\n\nProcedure process;\n Var\n i,res: longint;\n s: string;\n c: char;\n Begin\n Readln(fi,s);\n c:='a'; res:=0;\n For i:=1 to length(s) do\n begin\n res:=res+min(abs(ord(s[i])-ord(c)),26-abs(ord(s[i])-ord(c)));\n c:=s[i];\n end;\n write(fo,res);\n End;\n\nBEGIN\n assign(fi,tfi); reset(fi);\n assign(fo,tfo); rewrite(fo);\n process;\n close(fi); close(fo);\nEND.\n"}, {"source_code": "var s : string;\n i, t : byte;\n moves: word;\n\nfunction min(a, b: byte): byte;\n begin\n if a < b then exit(a);\n exit(b);\n end;\n\nBEGIN\n readln(s);\n\n t := ord(s[1]) - ord('a');\n moves:= min(t, 26 - t);\n\n for i:= 2 to length(s) do\n begin\n t:= abs(ord(s[i]) - ord(s[i-1]));\n inc(moves, min(t, 26 - t));\n end;\n\n writeln(moves);\n\n readln\nEND."}, {"source_code": "var j,i,pov,m1,m2,b,c,n:longint;\n s,s1:string;\n a:array[0..101]of byte;\n\nbegin\n a[0]:=1;\n readln(s);\n s1:='abcdefghijklmnopqrstuvwxyz';\n for i:=1 to length(s) do\n for j:=1 to length(s1) do\n if s[i]=s1[j] then a[i]:=j;\n\n pov:=0;\n n:=length(s)-1;\n for j:=0 to n do\n begin\n m1:=0;\n m2:=0;\n c:=0;\n b:=0;\n if a[j]>a[j+1] then\n begin\n c:=a[j];\n b:=a[j+1];\n end\n else\n begin\n c:=a[j+1];\n b:=a[j];\n end;\n m1:=abs(a[j]-a[j+1]);\n m2:=26-c+b;\n\n if m11 then begin\n k1:=p-1;\n k2:=(26-p)+1;\n if k1<=k2 then sum:=k1\n else sum:=k2;\n end;\n for i:=2 to n do\n begin\n sim:=st[i];\n p2:=pos(sim,alf);\n k1:=abs(p-p2);\n if p>=p2 then k2:=(26-p)+p2\n else k2:=(26-p2)+p;\n if k1<=k2 then sum:=sum+k1\n else sum:=sum+k2;\n p:=p2;\n end;\n writeln(sum);\nend."}, {"source_code": "uses math;\nvar s:string;\n i,n,ans:longint;\nbegin\n readln(s);\n ans:=min(abs(ord('a')-ord(s[1])),26-abs(ord('a')-ord(s[1])));\n for i:=2 to length(s) do\n inc(ans,min(abs(ord(s[i])-ord(s[i-1])),26-abs(ord(s[i])-ord(s[i-1]))));\n writeln(ans);\nend."}, {"source_code": "var st:string;\ni,n,start,s:integer;\nbegin\nread(st);\nstart:=ord('a');\nfor i:=1 to length(st) do begin\nn:=ord(st[i]);\nif n>=start then begin\nif n-start<=13 then s:=s+(n-start) else s:=s+(26-(n-start));\nend else begin\nif start-n<=13 then s:=s+(start-n) else s:=s+(26-(start-n));\nend;\nstart:=ord(st[i]);\nend;\nwriteln(s);\nend."}, {"source_code": "uses math;\nvar s,ss:ansistring;\ni,k,l,m,n,q,w,e,r,t:longint;\nbegin\nreadln(s); q:=1;\nss:='abcdefghijklmnopqrstuvwxyz';\nfor i:=1 to length(s) do\nbegin\nk:=pos(s[i],ss);\nt:=t+min(abs(q-k),26-abs(q-k));\nq:=k;\nend;\nwriteln(t);\nend.\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar f:text;\n st:string;\n Ans:longint;\n Rem:array['a'..'z'] of longint;\n{}\nprocedure docf;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,st);\n close(f);\nend;\n{}\nprocedure init;\nvar i,j:longint;\n ch:char;\nbegin\n i:=0;\n for ch:='a' to 'z' do\n begin\n inc(i);\n rem[ch]:=i;\n end;\nend;\n{}\nfunction min(a,b:longint):longint;\nbegin\n if a 13) then\n k := k + 25 - x + 1\n else\n k := k + x;\n a := ord(s[i]);\n end;\n\n writeln(k);\n readln;\nend.\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=10600000;\n { modul=1000000007; }\n besk=8000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended; int64=longint;\n mas=array [-100000..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10..nn] of longint;mass1=^mass;\n var limit,posi,posj,diam,modul,oldt,ot1,time,pos,prod,ll,rr,posx,posy,gr,n,dloch,newdl,oldn,oldm,ost,ot,aa,bb,cc,p1,p2,p3,p4,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,m,smin,cen:int64;\n pp0,mask,k,i1,j1,step1, step, i,j:longint;\n y:mas;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n oldpos,finot,vv,znak:int64;\n aold:mas;\n xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..1000001,-1..10] of longint;\n kolright,a,fact,next,prev,x,xx,yy,str,kol,s,name,d,dnew, voltay,l,r,c,z,day,b:mas;\n zzsum,zz:array[-10..12500000] of int64;\n ppole:array[-10..1002,-10..1005] of char;\n pole,ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1201,-10..1220] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n sss1,sss2:string;\n udal,dl,och,newoch,place,stoim,nabor:array[-10..1200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n binkoef,numleft,numright,dr: array [-10..60,-10..60] of int64;\n s3,s2,s1:array[-100..200000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[-10..nn] of string;\n tx,ty,vel,x1,y1,ott,v0,v1,s0,t0:int64;\n zv:point;\n ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\n{function prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n }\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nbegin\n\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(ss);\n n:=length(ss);\n for i:=1 to n do\n begin\n t:=ord(ss[i])-ord('a');\n ot:=ot+min(abs(t-pos),26-abs(t-pos));\n pos:=t;\n\n end;\n\n writeln(ot);\n\n\n\n 1: close(output);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar n : longint;\n i, j, x, y : longint;\n s : string;\nbegin\n\n readln(s);\n\n n := 0;\n\n s := 'a' + s;\n\n for i := 2 to length(s) do\n begin\n x := ord(s[i-1]) - ord(s[i]);\n y := ord(s[i]) - ord(s[i-1]);\n if x < 0 then\n x := x + 26\n else\n y := y + 26;\n n := n + min(x, y);\n end;\n\n writeln(n);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction\tMin(a, b: Integer): Integer;\nbegin\n\tif a=b then Result := a-b\n\telse Result := a+26-b;\nend;\n\nvar\n\ts: string;\n\ti, l, cnt, c1, c2: Integer;\n\nbegin\n\tReadln(s);\n\tl := Length(s);\n\tcnt := 0;\n\tc1 := Ord('a');\n\tfor i:=1 to l do\n\tbegin\n\t\tc2 := Ord(s[i]);\n\t\tInc(cnt, Min(Dist(c1, c2), Dist(c2, c1)));\n\t\tc1 := c2;\n\tend;\n\tWriteln(cnt);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s: string;\n c: char;\n sum, i: integer;\n\nfunction ch(a, b: char): integer;\nbegin\n if(ord(a) > ord(b))then begin\n if(abs((ord(a) - 96) - (ord(b) - 96)) < abs(26 + (ord(b) - 96) - (ord(a) - 96)))then\n ch := abs((ord(a) - 96) - (ord(b) - 96))\n else\n ch := abs(26 + (ord(b) - 96) - (ord(a) - 96));\n end\n else begin\n if(abs((ord(a) - 96) - (ord(b) - 96)) < abs(26 - (ord(b) - 96) + (ord(a) - 96)))then\n ch := abs((ord(a) - 96) - (ord(b) - 96))\n else\n ch := abs(26 - (ord(b) - 96) + (ord(a) - 96));\n end;\nend;\n\nbegin\n readln(s);\n sum := 0;\n c := 'a';\n for i := 1 to length(s) do begin\n sum := sum + ch(s[i], c);\n c := s[i];\n end;\n writeln(sum);\n readln;\n readln;\nend.\n "}, {"source_code": "program Codefroce;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n s: string;\n i, ans, st: integer;\n\nbegin\n readln(s);\n ans := 0;\n i := 0;\n while i < length(s) do\n begin\n if (i = 0) then st := 1\n else st := ord(s[i]) - 96;\n ans := ans + min(abs(st - (ord(s[i + 1]) - 96)), abs(26 - abs(st - (ord(s[i + 1]) - 96))));\n inc(i);\n end;\n writeln(ans);\n readln;\n\nend.\n "}, {"source_code": "program project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n d1,d2,i,j,ans,k:integer;\n s:string;\nbegin\n readln(s);\n k := 1;\n ans := 0;\n for i := 1 to length(s) do begin\n if(abs((ord(s[i])-96)-k)>=14)then begin\n inc(ans,26-abs(k-(ord(s[i])-96)));\n k := ord(s[i])-96;\n\n end\n else begin\n inc(ans,abs((ord(s[i])-96)-k));\n k := ord(s[i])-96;\n end;\n end;\n writeln(ans);\n readln;\n readln;\nend.\n\n\n\n\n\n"}, {"source_code": "program Project1112;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction min(x, y: integer): integer;\nbegin\n if x < y then\n min := x\n else\n min := y;\nend;\n\nvar\n s: string;\n x, i, y, sum: integer;\n \nbegin\n\n readln(s);\n\n sum := 0;\n\n x := 1;\n \n for i := 1 to length(s) do\n begin\n y := ord(s[i]) - 97 + 1;\n sum := sum + min(abs(x - y), 26 - abs(x - y));\n x := y;\n end;\n\n writeln(Sum);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qi,ci:array[0..1000000]of int64;\n qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h]13 then cur:=26-cur;\n inc(res,cur);\n end;\n writeln(res);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "uses math;\nvar s:string; i,position,ps,pf,ans:longint;\nbegin\n read(s);\n position:=ord('a');\n for i:=1 to length(s) do\n begin\n ps:=min(position, ord(s[i]));\n pf:=max(position, ord(s[i]));\n inc(ans, min(pf-ps, ps+26-pf));\n position:=ord(s[i]);\n end;\n write(ans);\nend.\n "}], "negative_code": [{"source_code": "program embosser;\nvar i,a:integer;\nS:string;\nbegin\n readln(S);\n if ord(S[1])-109>0 then a:=123-ord(S[1])\n else a:=ord(S[1])-96;\n for i:=2 to length(S) do\n begin\n if ord(S[i])>ord(S[i-1]) then\n begin\n if (ord(S[i])-13)>ord(S[i-1]) then a:=a+(26+ord(S[i-1])-ord(S[i]))\n else\n a:=a+(ord(S[i])-ord(S[i-1]));\n end\n else\n begin\n if (ord(S[i-1])-13)>ord(S[i]) then a:=a+(26+ord(S[i])-ord(S[i-1]))\n else\n a:=a+(ord(S[i-1])-ord(S[i]));\n end;\n end;\n writeln(a);\nend.\n "}, {"source_code": "Program museum;\nvar\ni,d,f,j,k,otv,x:integer;\ns,e:string; \na:array[1..100] of string;\nb:array[1..100] of string;\nm:array[1..100] of string;\nbegin\nreadLn(s);\nd:=length(s);\ne:='nopqrstuvwxyzabcdefghijklm';\nf:=length(e);\notv:=0;\n\nfor i:=1 to d do\nbegin\n for j:=1 to f do\n if s[i]=e[j] then\n begin\n k:=j-14;\n otv:=otv+abs(k);\n \n end;\n if k>0 then \n begin\n for j:=1 to f-k do\n m[j]:=e[j+k]; \n for j:=f-k+1 to f do\n m[j]:=e[j-(f-k)];\n e:='';\n for j:=1 to f do\n e:=e+m[j];\n end\n else \n if k<0 then \n begin\n k:=abs(k);\n for j:=1 to k do\n m[j]:=e[f-k+j]; \n for j:=k+1 to f do\n m[j]:=e[j-k];\n e:='';\n for j:=1 to f do\n e:=e+m[j];\n end\n else e:='nopqrstuvwxyzabcdefghijklm';\n \nend;\n writeln(otv);\nend. \n\n\n\n"}, {"source_code": "var n,m,p,r,a,x,y,s,albe,negre,c : longint;\nb,v,min,max : array[0..100000] of longint;\nda : boolean;\nz : ansistring;\nbegin\n\t\n\treadln(z);\n\twriteln(ord('z'));\n\tp:=1;\n\tfor c:=1 to length(z) do\n\tbegin\n\t\t\n\t\tr:=abs(96-ord(z[c]));\n\t\twriteln((abs(r-p)),' ',(26-abs(r-p)));\n\t\tif (abs(r-p))>=(26-abs(r-p)) then\n\t\ts:=s+(26-abs(r-p)) else\n\t\tif (abs(r-p))<(26-abs(r-p)) then\n\t\ts:=s+(abs(r-p));\n\t\t\n\t\tp:=r;\n\tend;\n\t\n\twriteln(s);\nend.\n"}, {"source_code": "var n,m,p,r,a,x,y,s,albe,negre,c : longint;\nb,v,min,max : array[0..100000] of longint;\nda : boolean;\nz : ansistring;\nbegin\n\t\n\treadln(z);\n\twriteln(ord('z'));\n\tp:=1;\n\tfor c:=1 to length(z) do\n\tbegin\n\t\t\n\t\tr:=abs(96-ord(z[c]));\n\t\tif (abs(r-p))>=(26-abs(r-p)) then\n\t\ts:=s+(26-abs(r-p)) else\n\t\tif (abs(r-p))<(26-abs(r-p)) then\n\t\ts:=s+(abs(r-p));\n\t\t\n\t\tp:=r;\n\tend;\n\t\n\twriteln(s);\nend.\n"}, {"source_code": "var i,j:char;\n k,rotation:integer;\n s:string;\n alphabet:array['a'..'z'] of integer;\nbegin\n k:=1;\n for i:='a' to 'm' do\n begin\n alphabet[i]:=k;\n k:=k+1;\n end;\n k:=0;\n for j:='z' downto 'n' do\n begin\n alphabet[j]:=k;\n k:=k-1;\n end;\n \n readln(s);\n rotation:=abs(alphabet[s[1]]-1);\n for k:=2 to length(s) do\n begin\n rotation:=rotation+abs(alphabet[s[k]]-alphabet[s[k-1]]);\n end;\n writeln(rotation); \nend.\n\n"}, {"source_code": "uses math;\nvar i,j:char;\n k,rotation:integer;\n s:string;\n count:array['a'..'z'] of integer;\nbegin\n k:=1;\n for i:='a' to 'm' do\n begin\n count[i]:=k;\n k:=k+1;\n end;\n k:=0;\n for j:='z' downto 'n' do\n begin\n count[j]:=k;\n k:=k-1;\n end; \n readln(s);\n if count[s[1]]-count['a']<=13 then rotation:=abs(count[s[1]]-count['a'])\n else rotation:=abs(26-abs(count[s[1]]-count['a']));\n writeln(rotation);\n for k:=2 to length(s) do\n begin\n if abs(count[s[k]]-count[s[k-1]])<=13 then rotation:=rotation+abs(count[s[k]]-count[s[k-1]])\n else rotation:=rotation+abs(26-abs(count[s[k]]-count[s[k-1]]));\n writeln(rotation);\n end;\n writeln(rotation); \nend.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qi,ci:array[0..1000000]of int64;\n qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h]13 then cur:=26-cur;\n inc(res,cur);\n end;\n writeln(res);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}], "src_uid": "ecc890b3bdb9456441a2a265c60722dd"} {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end.\n", "positive_code": [{"source_code": "var n,i,j,v,k:longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i to n do\n begin\n v:=trunc(sqrt(sqr(i)+sqr(j)));\n if (v<=n)and(sqr(v)=sqr(i)+sqr(j))then inc(k);\n end;\n writeln(k);\nend."}, {"source_code": "program amocana;\nvar i,j,n,k:longint;\n m:real;\nbegin\nread(n);\nfor i:=1 to n do\nfor j:=1 to i-1 do\nbegin\nm:=sqrt(i*i-j*j);\nif (m=round(m)) and (m>j) then k:=k+1;\nend;\nwriteln(k);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n n:longint;\nprocedure openfile;\nbegin\n assign(f,fi);reset(F);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,n);\nend;\nprocedure process;\nvar i,j,dem,t:longint;\nbegin\n dem:=0;\n for i:=1 to n do\n for j:=i to n do\n begin\n t:=sqr(i)+sqr(j);\n if sqrt(t) <=n then\n if trunc(sqrt(t))=sqrt(t) then\n begin\n inc(dem);\n end\n else\n else break;\n end;\n write(g,dem);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "Var n,a,b,c,i,j,k:LongInt;\n Begin\n Read(n);\n For a:=1 to n do\n For b:=a to n do\n Begin\n if (Frac(sqrt(sqr(a)+sqr(b)))=0) and (Trunc(sqrt(sqr(a)+sqr(b)))<=n) then k:=k+1;\n End;\n WriteLn(k);\n End."}, {"source_code": "var\nn,i,j,ans,t1,t2 : longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i to n do\n begin\n t1:=sqr(i)+sqr(j);\n t2:=trunc(sqrt(t1));\n if (sqr(t2)=t1) and (t2<=n) then inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "const p: array[0..10] of longint = (0, 881, 1981, 3172, 4416, 5681, 7008, 8345, 9706, 11077, 12471);\nvar n,c,a,s,m: longint; b: real;\nbegin\n readln(n);\n s:=0;\n m:=(n div 1000)*1000+1;\n for c:=m to n do\n for a:=1 to c-1 do\n begin\n b:=sqrt(c*c-a*a);\n if trunc(b)=b then inc(s)\n end;\n write(s div 2+p[n div 1000])\nend."}, {"source_code": "program pytagooo;\nvar\n n,i,j,temp1,res:longint;\n temp:real;\nbegin\n read(n);\n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n begin\n temp:=sqrt(sqr(i)+sqr(j));\n temp1:=trunc(temp);\n if((temp-temp1=0)and(temp<=n))then inc(res);\n\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "var\nn,i,j,ans:longint;\nbegin\nread(n);\nfor i:=1 to n do\n for j:=i+1 to n do\n if (sqr(i)+sqr(j)<=sqr(n)) and (frac(sqrt(sqr(i)+sqr(j)))<0.0000001)then inc(ans);\nWriteln(ans);\nend."}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end."}, {"source_code": "var n,i,j,k,dem:longint;\nbegin\nreadln(n);\ndem:=0;\nfor i:=5 to n do\nfor j:=1 to i - 1 do\nbegin\n k:=i * i - j * j;\n if k < j * j then break;\n if trunc(sqrt(k)) = sqrt(k) then inc(dem);\nend;\nwrite(dem);\nend."}, {"source_code": "const fi='';\n fo='';\nvar n:integer;\n kq:longint;\n\nprocedure doc;\nvar f:text;\nbegin\nassign(f,fi);reset(f);\nread(f,n);\nclose(f);\nend;\n\nprocedure xuly;\nvar a,c:integer;\n b:longint;\nbegin\nkq:=0;\nfor c:=1 to n do\n for a:=1 to c do\n begin\n b:=c*c-a*a;\n if (round(sqrt(b))=sqrt(b))and(b>a*a) then inc(kq);\n end;\nend;\n\nprocedure ghi;\nvar f:text;\nbegin\nassign(f,fo);rewrite(f);\nwrite(f,kq);\nclose(f);\nend;\n\nBEGIN\ndoc;xuly;ghi;\nEND."}, {"source_code": "var\n a,b,c,n,ans:longint;\n\nbegin\n readln(n);\n for a:=1 to n do\n for b:=a to n do\n if (sqrt(a*a+b*b)=trunc(sqrt(a*a+b*b))) and (sqrt(a*a+b*b)<=n) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "var a:array[1..10000] of longint; \n n, ii, i, j, kol:longint; \n b:real;\nbegin\nreadln(n);\nj:=2; i:=1;\nwhile j<=n do \n begin\n a[i]:=j*j;\n inc(i); inc(j);\n end;\ndec(j);dec(j); kol:=0;\nfor i:=1 to j-1 do \n begin \n for ii:=i+1 to j do\n begin\n b:=sqrt(a[i]+a[ii]);\n if (frac(b)=0)and(b<=n)\n then inc(kol);\n end; \n end;\n\nwriteln(kol);\nend."}, {"source_code": "var\ni,j,n,k,x:longint;\nbegin\nreadln(n);\ni:=1;\nj:=1;\nk:=0;\nx:=1;\nwhile i0 do\n begin\n z:=x mod y;\n x:=y;\n y:=z;\n end;\ngcd:=x;\nend;\n\n\nbegin\nreadln(n);\nt:=0;\nn1:=trunc(sqrt(n))+1;\nfor i:=1 to n1 do\n begin\n for j:=1 to i-1 do\n begin\n c:=j*j+i*i;\n if (c<=n) and (gcd(c,i*i-j*j)=1) then\n t:=t+(n div c);\n end;\n end;\nwriteln(t);\nend.\n"}, {"source_code": "program aaaaaa;\n\nvar n,i,x,c,a,b,d:longint;\n\nbegin\nreadln(n);\nx:=0;\nfor i:=1 to n do\n begin\n c:=i*i;\n a:=1;\n while 2*a*a<=c do\n begin\n d:=c-a*a;\n b:=trunc(sqrt(d));\n if b*b=d then\n x:=x+1;\n a:=a+1;\n end;\n end;\nwriteln(x);\nend.\n"}, {"source_code": "program aaaaaa;\n\nvar i:longint;\n n,x,c,a,b,d:longint;\n\nbegin\nreadln(n);\nx:=0;\nfor i:=1 to n do\n begin\n c:=i*i;\n a:=1;\n while 2*a*a<=c do\n begin\n d:=c-a*a;\n b:=trunc(sqrt(d));\n if b*b=d then\n x:=x+1;\n a:=a+1;\n end;\n end;\nwriteln(x);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar\n f,g :text;\n n :longint;\n a :array[0..100000] of longint;\n dem,s:longint;\nprocedure nhap;\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n close(f);\nend;\nprocedure xuli;\nvar i,j,t :longint;\nbegin\n dem:=0;\n for i:=1 to n-1 do\n for j:=i to n do\n begin\n s:=i*i+j*j;\n t:=trunc(sqrt(s));\n if (t*t=s) and(t<=n) then inc(dem);\n end;\n assign(g,fo);rewrite(g);\n write(g,dem);\n close(g);\nend;\nBEGIN\n nhap;\n xuli;\nend.\n\n\n\n\n"}, {"source_code": "Var a, b, n, i, j, k : longint;\n dem : int64;\nBegin\n readln(n);\n k := n*n;\n for i:=1 to n-2 do begin\n a := i*i;\n for j:=i+1 to n-1 do begin\n b := j*j;\n if a+b > k then continue;\n if frac(sqrt(a+b)) = 0 then dem := dem+1;\n end;\n end;\n writeln(dem);\nEnd.\n"}, {"source_code": "var\n n, i, j, sumsq, out : longint;\n sq : double;\nbegin\n read(n);\n out := 0;\n for i := 2 to n do\n for j := 1 to i do\n begin\n sumsq := i*i + j*j;\n sq := sqrt(sumsq);\n if (sq - round(sq) = 0 )and( sq <= n) then\n out := out + 1;\n end;\n writeln (out);\n\nend."}, {"source_code": "program p1;\nvar c:real;a,b,k,n:longint;\nbegin\nreadln(n);\nfor a:=1 to n do\nfor b:=1 to a-1 do\nbegin\nc:=sqrt(a*a-b*b);\nif ((c=round(c)) and (c>b)) then k:=k+1;\nend;\nwriteln(k);\nend.\n"}, {"source_code": "\nvar a, b, c, d, k, ans, n : longint;\n\nbegin\nread(n);\nans := 0;\nfor a := 1 to n do begin\nc := a;\nd := a * a;\nfor b := a to n do begin\nk := d + b * b;\nwhile (c <= n) and (c * c < k) do inc(c);\nif (c > n) then break;\nif (c * c = k) then inc(ans);\nend;\nend;\nwriteln(ans);\n\nend."}, {"source_code": "\nvar a, b, c, d, k, ans, n : longint;\n\nbegin\nread(n);\nans := 0;\nfor a := 1 to n do begin\nc := a;\nd := a * a;\nfor b := a to n do begin\nk := d + b * b;\nwhile c * c < k do inc(c);\nif (c * c = k) and (c <= n) then inc(ans);\nend;\nend;\nwriteln(ans);\n\nend."}, {"source_code": "\nvar a, b, c, d, k, ans, n : longint;\n\nbegin\n read(n);\n ans := 0;\n for a := 1 to n do begin\n c := a;\n d := a * a;\n for b := 1 to n do begin\n k := d + b * b;\n while (c * c < k) do inc(c);\n if (c <= n) and (c * c = k) and (a <= b) then inc(ans);\n end;\n end;\n writeln(ans);\n\nend."}, {"source_code": "// 304 A\n\nvar\n\ta,c,n,ans : longint;\n\t\nbegin\n\tans := 0;\n\treadln(n);\n\t\tfor c:=n downto 5 do\n\t\t\tfor a:=3 to c-1 do\n\t\t\t\tif(frac(sqrt(c*c-a*a))=0) then\n\t\t\t\t\tinc(ans);\n\twriteln(ans div 2);\nend."}, {"source_code": "CONST\n fi = '';//'PYTHAGORE.INP';\n fo = '';//'PYTHAGORE.OUT';\n\nVAR\n f: text;\n n: longint;\n\n{========================================================================}\n{========================================================================}\n\nprocedure DocFile;\n Begin\n assign (f, fi); reset (f);\n readln (f,n);\n close (f);\n End;\n\n{========================================================================}\n{========================================================================}\n\nprocedure Pythagore;\n var\n a, b, c, dem: longint;\n Begin\n dem := 0;\n for c:=5 to n do\n for b:=trunc(c/sqrt(2))+1 to c-1 do\n begin\n a := c*c-b*b;\n if sqr(trunc(sqrt(a))) = a then dem := dem + 1;\n end;\n\n assign (f, fo); rewrite (f);\n write (f, dem);\n close (f);\n End;\n\n{========================================================================}\n{========================================================================}\n\nBEGIN\n DocFile;\n Pythagore;\nEND."}, {"source_code": "Var n: integer;\n i,j,count: longint;\n k: real;\nBegin\n readln(n);\n count:=0;\n For i:=1 to n do\n For j:=i to n do\n Begin\n k:= sqrt(i*i+j*j);\n If ((round(k) = k) and (k<=n)) then inc(count);\n End;\n Writeln(count);\nEnd."}, {"source_code": "var\n n,i,j,k : longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i to n do\n if (sqrt(sqr(i)+sqr(j)) <= n) and (frac(sqrt(sqr(i)+sqr(j))) = 0)\n then inc(k);\n writeln(k);\nend."}, {"source_code": "uses math,sysutils;\nvar r,kol,g,xv,l,d,res,min1,z,j,max1,l1:integer;x3,y3,x1,y1,x2,y2,x,y,i,k:integer;\n ch:char;s,s1,ss:string;a,e,n,e1,b,c:integer;u:boolean;\n v,v1:real;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n);\n e:=trunc(sqrt(n));\n kol:=0;\n for i:=1 to n do\n for z:=i to 100000 do\n if sqrt(i*i+z*z)>n\n then break\n else Begin\n v:=sqrt(i*i+z*z);\n if v<>round(v)\n then continue;\n inc(kol);\n end;\n writeln(kol);\nend.\n"}, {"source_code": "uses math,sysutils;\nvar r,kol,g,xv,l,d,res,min1,z,j,max1,l1:integer;x3,y3,x1,y1,x2,y2,x,y,i,k:integer;\n ch:char;s,s1,ss:string;a,e,n,e1,b,c:integer;u:boolean;\n v,v1:real;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n);\n e:=trunc(sqrt(n));\n kol:=0;\n for i:=1 to n do\n for z:=i to 100000 do\n if sqrt(i*i+z*z)>n\n then break\n else Begin\n v:=sqrt(i*i+z*z);\n if v<>round(v)\n then continue;\n if (i+z>v) and (i+v>z) and (v+z>i)\n then inc(kol);\n end;\n writeln(kol);\nend.\n"}, {"source_code": "Var i,j,n,ans:longInt;\n begin\n Read(n);\n For i:=1 to n do\n begin\n For j:=1 to n do\n begin\n if (Frac(Sqrt(i*i+j*j))=0) and (trunc(Sqrt(i*i+j*j))<=n) then inc(ans);\n end;\n end;\n WriteLn(ans div 2);\n end."}, {"source_code": "var\n\tn,t,ans,i,j : longint;\nbegin\n\treadln(n);\n\tans := 0;\n\tfor i := 1 to n do begin\n\t\tfor j := i+1 to n do begin\n\t\t\tt := trunc(sqrt(i*i + j*j));\n\t\t\tif (t <= n) and (t*t = i*i + j*j) then\n\t\t\t\tinc(ans);\n\t\tend;\n\tend;\n\twriteln(ans);\nend.\n\t"}, {"source_code": "VAR n,i,j,c,k,h:longint;\nPROCEDURE deal;\nBEGIN\n c:=0;\n for i:=1 to n do\n for j:=i to n do\n begin\n h:=i*i+j*j;\n if h<=n*n then\n begin\n k:=trunc(sqrt(h));\n if k*k=h then\n c:=c+1;\n end;\n end;\nEND;\n\nBEGIN\n Readln(n);\n deal;\n writeln(c);\nEND."}, {"source_code": "var a,b,c,n, x: LongInt;\nbegin\n Readln(n);\n x:=0;\n \n for c:=1 to n do\n for b:=1 to c do\n begin\n a:=trunc( sqrt(c*c-b*b) );\n if (sqr(a)+sqr(b)=sqr(c)) and (a+b>c) and (a+c>b) and (b+c>a) then inc(x);\n end;\n \n Writeln(x div 2);\nend."}, {"source_code": "var a,b,c,n, x: LongInt;\nbegin\n Readln(n);\n x:=0;\n \n for c:=1 to n do\n for b:=1 to c do\n begin\n a:=trunc( sqrt(c*c-b*b) );\n if (sqr(a)+sqr(b)=sqr(c)) and (a+b>c) and (a+c>b) and (b+c>a) then inc(x);\n end;\n \n Writeln(x div 2);\nend."}, {"source_code": "var n,i,j,k,res : longint;\n a : array[0..10000] of longint;\n dd : array[0..200000000] of boolean;\n\nbegin\n readln(n);\n res := 0;\n j := 1;\n a[1] := 1;\n fillchar(dd,sizeof(dd),false);\n dd[a[1]] := true;\n for i := 2 to n do begin\n inc(j);\n a[j] := i*i;\n dd[a[j]] := true;\n end;\n for i := 1 to n-1 do\n for j := i+1 to n do\n if dd[a[i] + a[j]] then inc(res);\n writeln(res);\nend."}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end.\n"}, {"source_code": "var n,m,i,k,ko : int64; b : array [1..100000000] of boolean; j,l : longint;\n c : array [1..100000] of int64;\nfunction isQ (x : int64) : boolean;\nvar d : real;\nbegin\n b[x]:=true;\n ko:=ko+1;\n c[ko]:=x;\n isq:=true;\nend;\nbegin\n readln(n);\n k:=0;\n ko:=0;\n for l:=1 to n do\n begin\n isq(l*l);\n i:=l*l;\n for j:=1 to ko-1 do if b[i-c[j]] then\n begin\n k:=k+1;\n end;\n end;\n writeln(k div 2);\nend.\n"}, {"source_code": "var n,i,j,ans:longint;\n\nbegin\n//assign(input,'bdgls.in');reset(input);\n//assign(output,'bdgls.out');rewrite(output);\nread(n);\nfor i:=1 to n do\n for j:=i to n do\n if (sqrt(i*i+j*j)<=n) and (trunc(sqrt(i*i+j*j))=sqrt(i*i+j*j)) then inc(ans);\nwrite(ans);\nclose(input);close(output);\nend."}, {"source_code": "var\n i,j: longint;\n n,r,ans,c: longint;\nbegin\n//assign (input, 'input.txt'); reset (input);\nreadln (n); ans:= 0;\nfor i:= 1 to n do\n for j:= i+1 to n do\n begin\n\n c:= round(sqrt (i*i+j*j));\n if c>n then break;\n if c*c=i*i+j*j then inc (ans);\n\n end;\n writeln (ans);\n//close (input);\nend.\n"}, {"source_code": "var\n n,i,j,x,s:longint;\n a:real;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=1 to i-1 do\n begin\n x:=sqr(i)-sqr(j);\n a:=sqrt(x);\n if (a=trunc(a)) and (a<=j) then inc(s);\n end;\n writeln(s);\nend."}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end.\n"}, {"source_code": "var\ni,j,l,n:integer;\nbegin\nreadln(n);\nl:=0;\nfor i:=2 to n-1 do\n for j:=i+1 to n do\n if (frac(sqrt(i*i+j*j))=0)and (sqrt(i*i+j*j)<=n) then\n l:=l+1;\n writeln(l);\nend."}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end.\n"}, {"source_code": "var\n i,j,K,Kol,N:longint;\nbegin\n Read(N);\n For i:=1 to N do \n For j:=i to N do begin\n k:=Trunc(Sqrt(i*i+j*j));\n if (k*k=i*i+j*j)and\n (k>i)and(k>j)and\n (k<=n) then begin\n // Write(i,' ',j,' ',k);\n Inc(Kol);\n // Writeln;\n end; \n end; \n Write(Kol); \nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,i,j,ans:longint;\nbegin\n readln(n);\n ans:=0;\n for i:=1 to n do\n for j:=i to n do\n if (sqrt(i*i+j*j)=trunc(sqrt(i*i+j*j))) and\n (sqrt(i*i+j*j)<=n) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "var\n kol,n,i,j:longint;\n ans:extended;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(n);\n for i:=1 to n do\n begin\n for j:=i to n do\n begin\n ans:=sqrt(sqr(i)+sqr(j));\n if (ans<=n)and(frac(ans)=0) then inc(kol);\n end;\n end;\n writeln(kol);\nend.\n"}, {"source_code": "var i,j,n,r:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\n for j:=i to n do\n if ((frac(sqrt(i*i+j*j))=0) and ((sqrt(i*i+j*j))<=n)) then r:=r+1;\nwriteln(r);\nreadln;\nend."}, {"source_code": "Program a;\nConst fi='';\n fo='';\nvar f1,f2:text;\n sl,n,i,j,c,kq:longint;\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,n);\nend;\n\nProcedure xuli;\nbegin\nsl:=0;\n for i:=1 to n do\n for j:=i to n do\n begin\n kq:=i*i+j*j;\n c:=trunc(sqrt(kq));\n if (c*c=kq) and (c<=n) then sl:=sl+1;\n end;\nend;\n\nProcedure xuat;\nbegin\n writeln(f2,sl);\n close(f1);\n close(f2);\nend;\n\nbegin\nnhap;\nxuli;\nxuat;\nend."}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end."}, {"source_code": "program p1;\nvar\n sol,i,j,n:longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=1 to trunc(sqrt(i*i/2)) do\n if sqrt(i*i-j*j)=trunc(sqrt(i*i-j*j)) then inc(sol);\n writeln(sol);\nend.\n\n"}, {"source_code": "const finp='';\n fout='';\nvar n:integer;\nprocedure nhap;\nvar f:Text;\nbegin\n assign(f,finp);\n reset(f);\n read(f,n);\n close(f);\nend;\nfunction dem:integer;\nvar i,j,d:integer;\nbegin\n d:=0;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (sqrt(sqr(i)+sqr(j))<=n) and (frac(sqrt(sqr(i)+sqr(j)))=0) then\n inc(d);\n dem:=d;\nend;\nprocedure xuat;\nvar f:Text;\nbegin\n assign(f,fout);\n rewrite(f);\n write(f,dem);\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nvar\n n, i, j, q : integer;\n res : integer;\nbegin\n readln(n);\n i := 1;\n res := 0;\n while (i <= n) do begin\n j := i;\n while (j <= n) do begin\n q := round(sqrt(i * i + j * j + 0.0));\n if (q * q = i * i + j * j) and (q <= n) then\n inc(res);\n inc(j);\n end;\n inc(i);\n end;\n writelN(res);\n readln;\n readln;\nend.\n"}, {"source_code": "var i,j,l,n:longint;begin read(n);for i:=2to n-1do for j:=i+1to n do if(frac(sqrt(i*i+j*j))=0)and(sqrt(i*i+j*j)<=n)then l:=l+1;write(l)end.\n"}, {"source_code": "var a,c,ans,n:longint;\n\nbegin\n read(n); ans:=0;\n\tfor c:=n downto 2 do\n\tbegin\n\t\ta:=1;\n\t\twhile (2*a*a<=c*c) do\n\t\tbegin\n\t\t\tif ( frac(sqrt(c*c-a*a))=0 ) then ans:=ans+1;\n\t\t\ta:=a+1;\n\t\tend;\n\tend;\n write(ans);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nuses\n SysUtils;\nconst latin='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n glas='AEIOUY';\n cifr='1234567890';\n\nvar code,i,j,nn,mm,lp,rp,tek,ii,jj,n,cnt,min,step,max,new,m : integer;\n k : extended;\n\n\nbegin\n{$IFNDEF ONLINE_JUDGE} assign(input,'input.txt'); reset(input);\nassign(output,'output.txt'); rewrite(output); {$ENDIF}\n readln(n); cnt:=0;\n for i:=1 to n do\n for j:=i to n do begin\n k:=sqrt(sqr(i)+sqr(j));\n if (frac(k)<0.00001)and(k>=j)and(k<=n)and(kn\n then break\n else Begin\n v:=sqrt(i*i+z*z);\n if v<>round(v)\n then continue;\n inc(kol);\n end;\n writeln(kol);\nend.\n"}, {"source_code": "program z1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n c,a,b,k,n: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n readln(n);\n k:=0;\n for c:=n downto 1 do\n for a:=c-1 downto 1 do\n begin\n b:=trunc(sqrt(c*c-a*a));\n if (b=0)or(b>a) then break;\n if c*c=a*a+b*b then inc(k);\n end;\n\n writeln(k); \nend.\n "}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar n1,n,m,dl,kol,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish:longint;\ncc,dd,t,chisl,znam,ot,aa,bb,x0,y0,ll,rr,d1,d2,rad,yy1,xx1,xx2,q,xx,yy,t1,t2,p,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nkolnul,minus,plus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\nb,a,c:array[-10..2000000] of int64;\nx1,y1,z1,z,gr,x,y: array[-10..50000] of double;\nzan: array[-10..110000000] of boolean;\nee,ww,nn,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss:string;\nch11,ch12,ch1,ch:char;\nsl,sr,stoim,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction deg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then deg:=1 else if odd(k) then deg:=deg(a,k-1)*a mod modul else\n begin p:=deg(a,k div 2); deg:=p*p mod modul; end;\n\nend;\n\nfunction summ(n,p:int64):int64; var i,j,k:int64;\nbegin\n k:=((n-1) div p)*p;\n summ:=(k div p*(k+p) div 2) mod modul;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n read(n);\nfor i:=1 to 10000 do zan[i*i]:=true;\nfor i:=1 to n do for j:=1 to i-1 do if zan[i*i-j*j] then inc(ot);\n\nwriteln(ot div 2);\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var\ni,m,j,n,a,b,c,k:integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\nfor j:= i+1 to n do\nbegin\nk:=sqr(i)+sqr(j);\nc:=trunc(sqrt(k));\nif (sqr(c)=k) and (c<=n) then\nm:=m+1;\nend;\nwriteln(m);\nend.\n\n\n\n\n"}, {"source_code": "uses math;\n\nvar a, b, n, res: longint;\n c: real;\n\nbegin\n readln(n);\n res := 0;\n for a := 1 to n do\n for b := a to n do\n begin\n c := sqrt(a*a + b*b);\n if ((c = floor(c)) and (c <= n)) then\n inc(res);\n end;\n writeln(res);\nend."}, {"source_code": "Uses Math,SysUtils;\nVar I,J,L,H,R,G,X,Y,DX,DY,H1,ma,mi:Integer;P1,N,M:Int64;mt,ms:array['0'..'9'] of Integer;R1,B,K,C,D:Extended;F:array[1..100] of Boolean;S,T:String;m1:array[1..100] of Char;p:array[1..1000,1..1000] of char;a:char;\nBegin\n ///reset(input,'Input.txt');\n ///assign(output,'Output.txt');\n readln(N);\n R:=0;\n For I:=1 to N do\n For J:=I to N do\n begin\n K:=Round(sqrt(I*I+J*J));\n If (K<=N) and (K*K=I*I+J*J)\n then Inc(R);\n end;\n writeln(R);\nend.\n"}, {"source_code": "program EA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, n, k : integer;\n\nbegin\n readln(n);\n k := 0;\n for a := 1 to n do\n for b := a to n do\n if (sqrt(sqr(a) + sqr(b)) <= n) and (frac(sqrt(sqr(a) + sqr(b))) = 0) then inc(k);\n writeln(k);\n readln;\nend.\n"}, {"source_code": "var b,c,i,j,n,x:longint;\nbegin \n x:=0;\n read(n);\n for i:=1 to n do\n begin\n c:=sqr(i);\n for j:=1 to i do\n begin\n b:=sqr(j);\n if (c<>b) and (sqrt(c-b)=trunc(sqrt(c-b))) and (sqrt(c-b)<=j) then\n inc(x); \n end;\n end;\n write(x);\nend. \n "}, {"source_code": "var\n n,i,j,c,k,m:integer;\nbegin\n readln(n);\n m:=0;\nfor i:=1 to n do\nfor j:=i+1 to n do\nbegin\nk:=sqr(i)+sqr(j);\nc:=trunc(sqrt(k));\nif (sqr(c)=k) and (c<=n) then\nm:=m+1;\nend;\n writeln(m);\nend.\n"}, {"source_code": "var\n a, b, c, ans, n: integer;\n \nbegin\n ans := 0;\n readln(n);\n for a := 1 to n do\n for b := a to n do begin\n c := trunc(sqrt(sqr(a) + sqr(b)));\n if (sqr(c) = sqr(a) + sqr(b)) and (c <= n) then\n inc(ans);\n end;\n write(ans);\nend.\n"}, {"source_code": "var\n a,b:longint;\n c:real;\n n,j,i,k:longint;\nbegin\n readln(n);\n begin\n k:=0;\n for b:=n downto 2 do\n for a:=b-1 downto 1 do\n begin\n c:=sqrt(a*a+b*b);\n if (trunc(c)=c) and (a+b>c) and (c<=n)\n then k:=k+1;\n end;\n writeln(k);\n end;\nend.\n"}, {"source_code": "var\n i, j, k, x, y, z, m, N : longint;\n ans: longint;\n\nfunction gcd(p, q : longint) : longint;\nbegin\n if q = 0 then exit(p);\n exit(gcd(q, p mod q));\nend;\n\nbegin\n readln(N);\n m := trunc(sqrt(N));\n if m*m < N then inc(m);\n ans := 0;\n for i := 1 to m do\n begin\n if n - i*i > i-1 then j := i-1\n else j := n - i*i;\n for k := 1 to j do\n begin\n x := i*i - k*k;\n y := 2*i*k;\n z := i*i + k*k;\n if gcd(x, y) = 1 then inc(ans, N div z);\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n i, j, k, x, y, z, m, N : longint;\n ans: longint;\n\nfunction gcd(p, q : longint) : longint;\nbegin\n if q = 0 then exit(p);\n exit(gcd(q, p mod q));\nend;\n\nbegin\n readln(N);\n m := trunc(sqrt(N));\n if m*m < N then inc(m);\n ans := 0;\n for i := 1 to m do\n begin\n if n - i*i > i-1 then j := i-1\n else j := n - i*i;\n for k := 1 to j do\n begin\n x := i*i - k*k;\n y := 2*i*k;\n z := i*i + k*k;\n if (sqr(x) + sqr(y) = sqr(z)) and (z <= N) and (gcd(x, y) = 1) and (gcd(y, z) = 1) then inc(ans, N div z);\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "Program taskone;\nconst nmax = 10000;\nvar i, j, n, res : longint;\nr : extended;\nbegin\n\tReadln(n);\n\tres:=0;\n\tfor i:=1 to nmax do begin\n\t\tfor j:=i to nmax do begin\n\t\t\tr:= i*i + j*j;\n\t\t\tr:=sqrt(r);\n\t\t\tif r>n then break;\n\t\t\tif frac(r) = 0 then inc(res);\n\t\tend;\n\tend;\n\tWriteln(res);\nend."}, {"source_code": "var f1,f2:text;n,s:integer;\nprocedure rd;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n);\n close(f1);\nend;\nprocedure wk;\nvar i,j:integer;d:real;\nbegin\n s:=0;\n for i:=1 to n-1 do\n for j:=i+1 to n-1 do\n begin\n d:=sqrt(i*i+j*j);\n if (d<=n)and(d-round(d)=0) then inc(s);\n end;\nend;\nprocedure et;\nbegin\n write(f2,s);\n close(f2);\nend;\nbegin\n rd;\n wk;\n et;\nend.\n"}, {"source_code": "var\n n,i,j : longint;\n t,t1 : extended;\n ans : longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n t:=sqrt((i*i)+(j*j));\n t1:=trunc(t);\n if (t=t1) and (t<=n) then inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g :text;\n n,a,b,dem,s:longint;\nbegin\n assign(g,fo);rewrite(g);\n assign(f,fi);reset(f);\n readln(f,n);\n dem:=0;\n for a:=1 to n do\n for b:=a to n do\n begin\n s:=a*a+b*b;\n if (sqr(trunc(sqrt(s)))=s) and (s<=n*n) then inc(dem);\n end;\n writeln(g,dem);\n close(f);close(g);\nend.\n"}, {"source_code": "var i,j,kol,n: longint; k: double;\n\nbegin\n read(n);\n for i:=1 to 10000 do\n for j:=i to 10000 do\n begin\n k:=sqrt(sqr(i)+sqr(j));\n if k>n then break;\n if frac(k)<0.000001 then kol+=1;\n end;\n write(kol);\nend."}], "negative_code": [{"source_code": "{$MODE OBJFPC}\nprogram PythagoreanTheoremII;\nconst\n fin='P304A.inp';\n fou='P304A.out';\n \nvar\n n:longint;\n count:longint=0;\n \nfunction check(x,y:longint):boolean;\nvar\n tmp:longint;\nbegin\n result:=false;\n tmp:=trunc(sqrt(sqr(x)-sqr(y)));\n if (sqr(tmp)=sqr(x)-sqr(y)) or (sqr(tmp+1)=sqr(x)-sqr(y)) then\n exit(true);\nend;\n \nprocedure main();\nvar\n x,y:longint;\nbegin\n Read(n);\n for x:=1 to n do\n for y:=1 to x do\n if (check(x,y)) then\n inc(count);\n Write(count div 2);\nend;\n \nbegin\n main();\nend."}, {"source_code": " var x,y,z,c:extended;\n i,j,n,a,b:longint;\n begin\n read(n);\n\n for a:=1 to n do\n for b:=1 to n do\n\n begin\n c:=((a*a)+(b*b));\n c:=sqrt(c);\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1;\n\n end;\n write(x:0:0);\n end."}, {"source_code": "var x,y,z:extended;\n i,j,n,a,b,c:longint;\n begin\n read(n);\n if n<=1000 then\n begin\n for a:=1 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 2000 then\n begin\n x:=881;\n for a:=1001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 3000 then\n begin\n x:=1038;\n for a:=2001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n\n end\n else\n if n<= 4000 then\n begin\n x:=1708;\n for a:=3001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 5000 then\n begin\n x:=1708;\n for a:=4001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<=6000 then\n begin\n x:=1708;\n for a:=5001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 7000 then\n begin\n x:=1723;\n for a:=6001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 8000 then\n begin\n x:=1723;\n for a:=7001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<=9000 then\n begin\n x:=1723;\n for a:=8001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n end;\n write(x:0:0);\n end\n else\n if n<= 10000 then\n begin\n x:=1723;\n for a:=9001 to n do\n for b:=a to n do\n for c:=b to n do\n begin\n if (c*c)=(a*a)+(b*b) then\n if (1<=a) and (a<=b) and (b<=c) and (c<=n) then x:=x+1\n else break;\n\n end;\n write(x:0:0);\n end;\n\n end.\n"}, {"source_code": "var\n i,j: longint;\n n,r,ans: int64;\n k: real;\nbegin\n//assign (input, 'input.txt'); reset (input);\nread (n);\nfor i:= 1 to n do\n for j:= i+1 to n do\n begin\n r:= i*i+j*j;\n K:= frac (sqrt (r));\n if frac(sqrt (r))=0 then inc (ans);\n if r>n*n then break;\n end;\n writeln (ans);\n//close (input);\nend.\n"}, {"source_code": "var\n i,j: longint;\n n,r,ans,c: longint;\nbegin\n//assign (input, 'input.txt'); reset (input);\nread (n); ans:= 0;\nfor i:= 1 to n do\n for j:= i+1 to n do\n begin\n r:= i*i+j*j;\n c:= round(sqrt (r));\n if c*c=r then inc (ans);\n if c>n then break;\n end;\n writeln (ans);\n//close (input);\nend.\n"}, {"source_code": "var\n i,j,K,Kol,N:longint;\nbegin\n Read(N);\n For i:=1 to N do \n For j:=i to N do begin\n k:=Trunc(Sqrt(i*i+j*j));\n if k*k=i*i+j*j then Inc(Kol); \n end; \n Write(Kol); \nend."}, {"source_code": "var\n a,b:longint;\n c:real;\n n,j,i,k:longint;\nbegin\n readln(n);\n begin\n k:=0;\n for b:=n-1 downto 2 do\n for a:=b-1 downto 2 do\n begin\n c:=sqrt(a*a+b*b);\n if (trunc(c)=c) and (a+b>c)\n then k:=k+1;\n end;\n writeln(k);\n end;\nend.\n"}, {"source_code": "Var i,j,n,rez:longint;\nfunction proverka(a:longint):boolean;\nVar e:longint;\nbegin\n e:=round(sqrt(a));\n if (e*e<>a)or(e>n)\n then proverka:=false\n else proverka:=true;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n rez:=0;\n read(n);\n for i:=1 to 100 do\n for j:=i to 100 do\n if proverka(i*i+j*j)\n then inc(rez);\n writeln(rez);\nend."}, {"source_code": "var a,c,ans,n:longint;\n\nbegin\n read(n);\n c:=trunc(sqrt(n));\n a:=1;\n while (2*a*an then break;\n\t\t\tif frac(r) = 0 then inc(res);\n\t\tend;\n\tend;\n\tWriteln(res);\nend."}, {"source_code": "Program taskone;\nconst nmax = 8000;\nvar i, j, n, res : longint;\nr : extended;\nbegin\n\tReadln(n);\n\tres:=0;\n\tfor i:=1 to nmax do begin\n\t\tfor j:=i to nmax do begin\n\t\t\tr:= i*i + j*j;\n\t\t\tr:=sqrt(r);\n\t\t\tif r>n then break;\n\t\t\tif frac(r) = 0 then inc(res);\n\t\tend;\n\tend;\n\tWriteln(res);\nend."}, {"source_code": "var\n ans,n,a,b:longint;\n c:double;\n\nbegin\n readln(n);\n for a:=1 to n do\n for b:=a+1 to n do\n begin\n c:=sqrt(sqr(a)+sqr(b));\n if c-trunc(c)<0.00000000001 then\n inc(ans);\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var\n n,i,j : longint;\n t,t1 : extended;\n ans : longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i to n do\n begin\n t:=sqrt((i*i)+(j*j));\n t1:=trunc(t);\n if (t=t1) then inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "var i,j,kol,n: longint; k:real;\n\nbegin\n read(n);\n for i:=1 to 1000 do\n for j:=i to 1000 do\n begin\n k:=sqrt(sqr(i)+sqr(j));\n if sqr(k)=sqr(trunc(k)) then\n if (sqr(i)+sqr(j)<=sqr(n)) then kol+=1 else break;\n end;\n write(kol);\nend."}, {"source_code": "var i,j,kol,n: longint; k: double;\n\nbegin\n read(n);\n for i:=1 to 1000 do\n for j:=i to 1000 do\n begin\n k:=sqrt(sqr(i)+sqr(j));\n if frac(k)<0.000001 then\n if (sqr(i)+sqr(j)<=sqr(n)) then kol+=1 else break;\n end;\n write(kol);\nend."}, {"source_code": "var n,i,j,c,ans:longint;\nbegin\n ans:=0;\n readln(n);\n for i:=1 to 100 do\n for j:=1 to 100 do\n begin\n c:=sqr(i)+sqr(j);\n if (trunc(sqrt(c))<=n) and (sqrt(c)=trunc(sqrt(c))) then inc(ans);\n end;\n writeln(ans div 2);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n n:longint;\nprocedure openfile;\nbegin\n assign(f,fi);reset(F);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,n);\nend;\nprocedure process;\nvar i,j,dem,t:longint;\nbegin\n dem:=0;\n for i:=1 to n do\n for j:=i to n do\n begin\n t:=sqr(i)+sqr(j);\n if sqrt(t) <=n then\n if trunc(sqrt(t))=sqrt(t) then\n begin\n inc(dem);\n writeln(i,' ',j);\n end\n else\n else break;\n end;\n write(g,dem);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend."}, {"source_code": "Var n,a,b,c,i,j,k:LongInt;\n Begin\n Read(n);\n For a:=1 to n do\n For b:=a to n do\n Begin\n if (Frac(sqrt(sqr(a)+sqr(b)))=0) and (Trunc(sqrt(sqr(a)+sqr(b)))>=n) then k:=k+1;\n End;\n WriteLn(k);\n End."}, {"source_code": "var\nn,i,j,ans,t1,t2 : longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=i to n do\n begin\n t1:=sqr(i)+sqr(j);\n t2:=trunc(sqrt(t1));\n if (sqr(t2)=t1) and (t2>=j) then inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "var n,c,a,s: longint;\nbegin\n readln(n);\n for c:=5 to n do\n for a:=1 to n-1 do if sqrt(c*c-sqr(round(sqrt(c*c-a*a))))=a then\n begin\n inc(s);\n break\n end;\n writeln((s div 2)+(s mod 2))\nend.\n"}, {"source_code": "var n,c,a,s: longint;\nbegin\n readln(n);\n for c:=4 to n do\n for a:=1 to n-1 do if sqrt(c*c-sqr(round(sqrt(c*c-a*a))))=a then\n begin\n inc(s);\n break\n end;\n writeln(s div 2)\nend.\n"}, {"source_code": "var n,c,a,s: longint;\nbegin\n readln(n);\n for c:=4 to n do\n for a:=1 to n-1 do if trunc(sqrt(c*c-a*a))=sqrt(c*c-a*a) then\n begin\n inc(s);\n break\n end;\n writeln(s div 2)\nend.\n"}, {"source_code": "program A;\n\nconst mang : array [1..16] of integer = (5, 13, 25, 17, 41, 61, 37, 85, 65, 29, 53, 65, 85, 89, 73, 97);\n\nvar n : integer;\n\n procedure nhap;\n var i, j, count : integer;\n Begin\n readln (n);\n count := 0;\n for i := 1 to 16 do\n count := count + n div mang[i];\n writeln (count);\n End;\n\nBegin\n nhap;\nEnd."}, {"source_code": "var\nn,i,j,ans:longint;\nbegin\nread(n);\nfor i:=1 to n do\n for j:=i to n do\n if (sqr(i)+sqr(j)<=sqr(n)) and (frac(sqrt(sqr(i)+sqr(j)))<0.001)then inc(ans);\nWriteln(ans);\nend."}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nwriteln(n div 5);\nend."}, {"source_code": "var a,b,n:integer; s,sl:longint;\nbegin \n readln(n); sl:=0;\n for a:=1 to n-1 do\n for b:=1 to n-1 do\n begin\n s:=a*a+b*b;\n if ((s<=n) and (trunc(sqrt(s))*trunc(sqrt(s))=s)) then inc(sl);\n end;\n writeln(sl);\nend."}, {"source_code": "program p1;\nvar c:real;a,b,k,n:longint;\nbegin\nreadln(n);\nfor a:=1 to n do\nfor b:=1 to a-1 do\nbegin\nc:=sqrt(a*a-b*b);\nif ((c=round(c)) and (c>a)) then inc(k);\nend;\nwriteln(k);\nend.\n"}, {"source_code": "\nvar a, b, c, d, k, ans, n : longint;\n\nbegin\nread(n);\nans := 0;\nfor a := 1 to n do begin\nc := a;\nd := a * a;\nfor b := a to n do begin\nk := d + b * b;\nwhile c * c < k do inc(c);\nif (c * c = k) then inc(ans);\nend;\nend;\nwriteln(ans);\n\nend."}, {"source_code": "var a, b, c, d, k, ans, n : longint;\n\nbegin\n read(n);\n ans := 0;\n for a := 1 to n do begin\n c := a;\n for b := 1 to n do begin\n k := d + b * b;\n while (c <= n) and (c * c < k) do inc(c);\n if (c > n) then break;\n if (c * c = k) and (a <= b) then inc(ans);\n end;\n end;\n writeln(ans);\n\nend."}, {"source_code": "\nvar a, b, c, d, k, ans, n : longint;\n\nbegin\n read(n);\n ans := 0;\n for a := 1 to n do begin\n c := a;\n for b := 1 to n do begin\n k := d + b * b;\n while (c <= n) and (c * c < k) do inc(c);\n if (c > n) then break;\n if (c * c = k) and (a < b) then inc(ans);\n end;\n end;\n writeln(ans);\n\nend."}], "src_uid": "36a211f7814e77339eb81dc132e115e1"} {"source_code": "Program cf99e;\nVar ss:ansistring;\n total:array['a'..'z'] of longint;\n place:array['a'..'z',0..100000] of longint;\n cc,s:array[1..100000] of char;\n cl,cr:array[1..100000] of longint;\n a,c:array[1..100000] of longint;\n ans:int64;\n d,i,j,k,left,right,n,m,cur,std:longint;\nbegin\n readln(ss);\n n:=length(ss);\n for i:=1 to n do\n begin\n s[i]:=ss[i];\n inc(total[s[i]]);\n c[i]:=total[s[i]];\n place[s[i],total[s[i]]]:=i;\n end;\n readln(m,left,right);\n for i:=1 to m do\n readln(cc[i],cl[i],cr[i]);\n cur:=0;\n for i:=1 to m do if cl[i]=0 then inc(std);\n for d:=1 to n do\n begin\n a[d]:=std;\n if (left<=a[d]) and (a[d]<=right) then inc(cur);\n for k:=1 to m do\n if cc[k]=s[d] then\n begin\n if c[d]-cr[k]-1>=0 then\n begin\n for i:=place[s[d],c[d]-cr[k]-1]+1 to place[s[d],c[d]-cr[k]] do\n begin\n dec(a[i]);\n if a[i]=left-1 then cur:=cur-1;\n if a[i]=right then cur:=cur+1;\n end;\n end;\n if cl[k]<>0 then\n if c[d]-cl[k]>=0 then\n begin\n for i:=place[s[d],c[d]-cl[k]]+1 to place[s[d],c[d]-cl[k]+1] do\n begin\n inc(a[i]);\n if a[i]=right+1 then cur:=cur-1;\n if a[i]=left then cur:=cur+1;\n end;\n end;\n end;\n ans:=ans+cur;\n end;\n writeln(ans);\nend.", "positive_code": [{"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,O+,S-}\nvar\n n, m, i, j, q, x, y, lf, rg : longint;\n ans, cur : int64;\n c : char;\n s : string;\n op, opa : array [-1..1] of longint;\n a : array [1..1000010] of longint;\n ch : array [1..510] of char;\n u, v : array [1..510] of longint;\n p : array ['a'..'z', 0..100010] of longint;\n r : array ['a'..'z'] of longint;\nprocedure upd(k, d : longint);\nbegin\n if a[k] = x - 1 + op[d] then\n inc(cur, opa[d]);\n if a[k] = y + op[d] then\n dec(cur, opa[d]);\n inc(a[k], d);\nend;\nbegin\n // reset(input, 'input.txt');\n // Rewrite(output, 'output.txt');\n Readln(s);\n ans := 0;\n lf := 0;\n op[1] := 0;\n op[-1] := 1;\n opa[1] := 1;\n opa[-1] := -1;\n n := Length(s);\n readln(m, x, y);\n for i := 1 to m do\n readln(ch[i], u[i], v[i]);\n for q := 1 to n do\n begin\n c := s[q];\n inc(r[c]);\n p[c, r[c]] := q;\n if x = 0 then\n inc(cur);\n for i := 1 to m do\n if ch[i] = c then\n begin\n if r[c] > v[i] then\n begin\n lf := p[c, r[c] - v[i] - 1] + 1;\n rg := p[c, r[c] - v[i]];\n for j := lf to rg do\n upd(j, -1);\n end;\n rg := lf - 1;\n if u[i] = 0 then\n begin\n lf := q;\n rg := q;\n end\n else\n if r[c] >= u[i] then\n begin\n lf := p[c, r[c] - u[i]] + 1;\n rg := p[c, r[c] - u[i] + 1];\n end;\n for j := lf to rg do\n upd(j, 1);\n end\n else\n if u[i] = 0 then\n upd(q, 1);\n ans := ans + cur;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program cf138e;\nvar\n ct:array[0..100000]of longint;\n l,r,mk,lf,rf:array[0..1000]of longint;\n ss:array[0..100000]of char;\n s:array[0..100000,0..26]of longint;\n n,m,ll,rr,i,j,h,ctt:longint;\n ans:int64;\nprocedure init;\nvar i,j,h:longint;\nbegin\n n:=0;\n while not(eoln) do begin\n inc(n);\n read(ss[n]);\n end; readln;\n\n for i:=0 to 26 do s[0,i]:=0;\n for i:=1 to n do begin\n for j:=0 to 26 do s[i,j]:=s[i-1,j];\n inc(s[i,ord(ss[i])-ord('a')]);\n end;\n\n readln(m,ll,rr);\n for i:=1 to m do begin\n read(ss[1]);\n mk[i]:=ord(ss[1])-ord('a');\n readln(l[i],r[i]);\n end;\nend;\n\nprocedure main;\nvar\n i,j,h:longint;\n kind:boolean;\nbegin\n ans:=0;\n ctt:=0;\n for i:=1 to m do begin\n rf[i]:=0;\n lf[i]:=1;\n end;\n\n { for i:=1 to m do lf[i]:=1;\n fillchar(rf,sizeof(rf),0); }\n for i:=1 to n do ct[i]:=0;\n for h:=1 to n do begin\n if ll=0 then\n inc(ctt,1);\n for i:=1 to m do begin\n while (rf[i]=l[i]) do begin\n if (ct[rf[i]+1]<=rr)and(ll<=ct[rf[i]+1]) then kind:=true\n else kind:=false;\n inc(ct[rf[i]+1]);\n if (not(kind))and(ct[rf[i]+1]<=rr)and(ct[rf[i]+1]>=ll) then\n inc(ctt);\n if (kind)and(not((ct[rf[i]+1]<=rr)and(ct[rf[i]+1]>=ll))) then\n dec(ctt);\n inc(rf[i]);\n end;\n\n\n while (lf[i]<=h)and(s[h,mk[i]]-s[lf[i]-1,mk[i]]>r[i]) do begin\n if (ct[lf[i]]<=rr)and(ll<=ct[lf[i]]) then kind:=true\n else kind:=false;\n dec(ct[lf[i]]);\n if (not(kind))and(ct[lf[i]]<=rr)and(ct[lf[i]]>=ll) then\n inc(ctt);\n if (kind)and(not((ct[lf[i]]<=rr)and(ct[lf[i]]>=ll))) then\n dec(ctt);\n inc(lf[i]);\n end;\n\n end;\n\n ans:=ans+ctt;\n end;\n writeln(ans);\nend;\n\n\n\n\nbegin\n init;\n main;\nend.\n\n\n\n\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..maxn]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Modify(k,d:longint);\nbegin\n if d=1 then\n begin\n if a[k]=x-1 then inc(tot);\n if a[k]=y then dec(tot);\n end\n else\n begin\n if a[k]=x then dec(tot);\n if a[k]=y+1 then inc(tot);\n end;\n a[k]:=a[k]+d;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];inc(r[c]);\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if r[c]>v[i] then\n begin\n lt:=p[c,r[c]-v[i]-1]+1;\n rt:=p[c,r[c]-v[i]];\n for j:=lt to rt do Modify(j,-1);\n end;\n\n if (u[i]=0) then\n begin\n lt:=z;rt:=z;\n end\n else\n if r[c]>=u[i] then\n begin\n lt:=p[c,r[c]-u[i]]+1;\n rt:=p[c,r[c]-u[i]+1];\n end\n else rt:=lt-1;\n for j:=lt to rt do Modify(j,1);\n end\n else\n if u[i]=0 then Modify(z,1);\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..maxn]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Modify(k,d:longint);\nbegin\n if d=1 then\n begin\n if a[k]=x-1 then inc(tot);\n if a[k]=y then dec(tot);\n end\n else\n begin\n if a[k]=x then dec(tot);\n if a[k]=y+1 then inc(tot);\n end;\n a[k]:=a[k]+d;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];inc(r[c]);\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if r[c]>v[i] then\n begin\n lt:=p[c,r[c]-v[i]-1]+1;\n rt:=p[c,r[c]-v[i]];\n for j:=lt to rt do Modify(j,-1);\n end;\n\n if (u[i]=0) then\n begin\n lt:=z;rt:=z;\n end\n else\n if r[c]>=u[i] then\n begin\n lt:=p[c,r[c]-u[i]]+1;\n rt:=p[c,r[c]-u[i]+1];\n end\n else rt:=lt-1;\n for j:=lt to rt do Modify(j,1);\n end\n else\n if u[i]=0 then Modify(z,1);\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n//\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q,tmp:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to Q do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\ttmp:=count;\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin tmp:=count;\n\t\t\t\tif check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n inc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend.\n"}], "negative_code": [{"source_code": "Program Helish_Constraints;\nconst maxn=100000;\n q=511;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..q]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];\n r[c]:=(r[c]+1) and q;\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n lt:=p[c,(r[c]-v[i]-1)and q]+1;\n rt:=p[c,(r[c]-v[i])and q];\n for j:=lt to rt do\n begin\n if a[j]=x then dec(tot);\n if a[j]=y+1 then inc(tot);\n dec(a[j]);\n end;\n if (u[i]=0)and(v[i]>0) then\n begin\n lt:=z;rt:=z;\n end\n else\n begin\n lt:=p[c,(r[c]-u[i])and q]+1;\n rt:=p[c,(r[c]-u[i]+1)and q];\n end;\n for j:=lt to rt do\n begin\n if a[j]=x-1 then inc(tot);\n if a[j]=y then dec(tot);\n inc(a[j]);\n end;\n end\n else\n if u[i]=0 then\n begin\n if a[z]=x-1 then inc(tot);\n if a[z]=y then dec(tot);\n inc(a[z]);\n end;\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\n q=511;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..q]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];\n r[c]:=(r[c]+1) and q;\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if u[i]=0 then\n begin\n lt:=p[c,(r[c]-v[i]-2)and q]+1;\n rt:=p[c,(r[c]-v[i]-1)and q];\n end\n else\n begin\n lt:=p[c,(r[c]-v[i]-1)and q]+1;\n rt:=p[c,(r[c]-v[i])and q];\n end;\n for j:=lt to rt do\n begin\n if a[j]=x then dec(tot);\n if a[j]=y+1 then inc(tot);\n dec(a[j]);\n end;\n\n if (u[i]=0)and(v[i]>0) then\n begin\n lt:=z;rt:=z;\n end\n else\n begin\n lt:=p[c,(r[c]-u[i])and q]+1;\n rt:=p[c,(r[c]-u[i]+1)and q];\n end;\n for j:=lt to rt do\n begin\n if a[j]=x-1 then inc(tot);\n if a[j]=y then dec(tot);\n inc(a[j]);\n end;\n end\n else\n if u[i]=0 then\n begin\n if a[z]=x-1 then inc(tot);\n if a[z]=y then dec(tot);\n inc(a[z]);\n end;\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\n q=511;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..q]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];\n r[c]:=(r[c]+1) and q;\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if u[i]=0 then\n begin\n lt:=p[c,(r[c]-v[i]-2)and q]+1;\n if v[i]=0 then rt:=z\n else rt:=p[c,(r[c]-v[i]-1)and q];\n end\n else\n begin\n lt:=p[c,(r[c]-v[i]-1)and q]+1;\n rt:=p[c,(r[c]-v[i])and q];\n end;\n\n for j:=lt to rt do\n begin\n if a[j]=x then dec(tot);\n if a[j]=y+1 then inc(tot);\n dec(a[j]);\n end;\n\n if (u[i]=0)and(v[i]>0) then\n begin\n lt:=z;rt:=z;\n end\n else\n begin\n lt:=p[c,(r[c]-u[i])and q]+1;\n rt:=p[c,(r[c]-u[i]+1)and q];\n end;\n for j:=lt to rt do\n begin\n if a[j]=x-1 then inc(tot);\n if a[j]=y then dec(tot);\n inc(a[j]);\n end;\n end\n else\n if u[i]=0 then\n begin\n if a[z]=x-1 then inc(tot);\n if a[z]=y then dec(tot);\n inc(a[z]);\n end;\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\n q=511;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..q]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Modify(k,d:longint);\nbegin\n if d=1 then\n begin\n if a[k]=x-1 then inc(tot);\n if a[k]=y then dec(tot);\n end\n else\n begin\n if a[k]=x then dec(tot);\n if a[k]=y+1 then inc(tot);\n end;\n a[k]:=a[k]+d;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];\n r[c]:=(r[c]+1) and q;\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if p[c,(r[c]-v[i])and q]>0 then\n begin\n if u[i]=0 then\n begin\n lt:=p[c,(r[c]-v[i]-2)and q]+1;\n if v[i]=0 then rt:=z\n else rt:=p[c,(r[c]-v[i]-1)and q];\n end\n else\n begin\n lt:=p[c,(r[c]-v[i]-1)and q]+1;\n rt:=p[c,(r[c]-v[i])and q];\n end;\n for j:=lt to rt do Modify(j,-1);\n end;\n\n if (u[i]=0)and(v[i]>0) then\n begin\n lt:=z;rt:=z;\n end\n else\n begin\n lt:=p[c,(r[c]-u[i])and q]+1;\n rt:=p[c,(r[c]-u[i]+1)and q];\n end;\n for j:=lt to rt do Modify(j,1);\n end\n else\n if u[i]=0 then Modify(z,1);\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "Program Helish_Constraints;\nconst maxn=100000;\n q=511;\nvar n,m,i,j,z,x,y,tot,lt,rt:longint;\n ans:int64;\n c:char;\n s:array[1..maxn]of char;\n a:array[1..maxn]of longint;\n ch:array[1..500]of char;\n u,v:array[1..500]of longint;\n p:array['a'..'z',0..q]of longint;\n r:array['a'..'z']of longint;\n//==============================================================\nprocedure Init;\nbegin\n repeat\n inc(n);\n read(s[n]);\n until eoln;\n readln(m,x,y);\n for i:=1 to m do\n begin\n read(ch[i]);\n readln(u[i],v[i]);\n end;\nend;\n//==============================================================\nprocedure Modify(k,d:longint);\nbegin\n if d=1 then\n begin\n if a[k]=x-1 then inc(tot);\n if a[k]=y then dec(tot);\n end\n else\n begin\n if a[k]=x then dec(tot);\n if a[k]=y+1 then inc(tot);\n end;\n a[k]:=a[k]+d;\nend;\n//==============================================================\nprocedure Work;\nbegin\n c:=s[z];\n r[c]:=(r[c]+1) and q;\n p[c,r[c]]:=z;\n if x=0 then inc(tot);\n for i:=1 to m do\n if ch[i]=c then\n begin\n if p[c,(r[c]-v[i])and q]>0 then\n begin\n lt:=p[c,(r[c]-v[i]-1)and q]+1;\n rt:=p[c,(r[c]-v[i])and q];\n for j:=lt to rt do Modify(j,-1);\n end;\n\n if (u[i]=0) then\n begin\n lt:=z;rt:=z;\n end\n else\n begin\n lt:=p[c,(r[c]-u[i])and q]+1;\n rt:=p[c,(r[c]-u[i]+1)and q];\n end;\n for j:=lt to rt do Modify(j,1);\n end\n else\n if u[i]=0 then Modify(z,1);\n ans:=ans+tot;\nend;\n//==============================================================\nbegin\n Init;\n for z:=1 to n do Work;\n writeln(ans);\nend.\n"}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q,tmp:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\ttmp:=count;\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOO');\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin tmp:=count;\n\t\t\t\tif check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOpO',' ',j,' ',letter[j],' ',l[j],' ',r[j],' ',left[j],' ',meet[left[j]]);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n if (s[1]='l')and(s[2]='w')and(s[3]='x') then if count<>i then writeln(i,' ',count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend.\n"}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then writeln(Q,' ',downlim,' ',uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n //writeln(count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=right[j])and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n //writeln(count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do readln(letter[i],l[i],r[i]);\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=0; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\twhile (right[j]=l[i]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=right[j])and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[i]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\tif (downlim=0)and(meet[i]=0) then inc(count);\n writeln(count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do readln(letter[i],l[i],r[i]);\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=right[j])and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n //writeln(count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n if (s[1]='l')and(s[2]='w')and(s[3]='x') then if count<>i then writeln(i,' ',count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q,tmp:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\ttmp:=count;\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOO');\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin tmp:=count;\n\t\t\t\tif check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOpO');\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n if (s[1]='l')and(s[2]='w')and(s[3]='x') then if count<>i then writeln(i,' ',count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend.\n"}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if meet[right[j]]=500 then writeln('No');\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if (s[1]='l')and(s[2]='w')and(s[3]='x') then if meet[right[j]]=0 then writeln('Nooo');\n\t\t\t\tif check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n if (s[1]='l')and(s[2]='w')and(s[3]='x') then if count<>i then writeln(i,' ',count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend.\n"}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin if check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n //writeln(count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "var\ns:array[0..100010] of char;\nsum:array[0..100010,'a'..'z'] of longint;\nleft,right,meet:array[0..100010] of longint;\nletter:array[0..510] of char;\nl,r:array[0..510] of longint;\nuplim,downlim:longint;\n\nfunction check(x:longint):boolean; begin exit((downlim<=x)and(x<=uplim)); end;\n\nprocedure lemon;\nvar n,i,j,count,Q,tmp:longint;\n ans:int64;\n ch:char;\nbegin n:=0;\n\twhile not seekeoln(input) do\n\tbegin read(ch);\n\t\tinc(n); s[n]:=ch;\n\tend;\n\tfor ch:='a' to 'z' do sum[0,ch]:=0;\n\tfor i:=1 to n do\n\tbegin sum[i]:=sum[i-1];\n\t\tinc(sum[i,s[i]]);\n\tend;\n\treadln(Q,downlim,uplim);\n\tfor i:=1 to Q do \n\tbegin readln(letter[i],l[i],r[i]);\n\t\tif l[i]>r[i] then writeln('no');\n\tend;\n\tfillchar(meet,sizeof(meet),0);\n\tfor i:=1 to n do begin left[i]:=1; right[i]:=0; end;\n\tans:=0; count:=0;\n\tfor i:=1 to n do\n begin for j:=1 to Q do\n\t\tbegin //[left[j]~right[j],i] is available interval\n\t\t\tif sum[i,letter[j]]-sum[left[j]-1,letter[j]]=l[j]) do\n\t\t\tbegin inc(right[j]);\n\t\t\t\ttmp:=count;\n\t\t\t\tif check(meet[right[j]]) then dec(count);\n\t\t\t\tinc(meet[right[j]]);\n\t\t\t\tif check(meet[right[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOO');\n\t\t\tend;\n\t\t\twhile (left[j]<=i)and(sum[i,letter[j]]-sum[left[j]-1,letter[j]]>r[j]) do\n\t\t\tbegin tmp:=count;\n\t\t\t\tif check(meet[left[j]]) then dec(count);\n\t\t\t\tdec(meet[left[j]]);\n\t\t\t\tif check(meet[left[j]]) then inc(count);\n\t\t\t\tif (s[1]='l')and(s[2]='w')and(s[3]='x') then if tmp<>count then writeln('NOpO',' ',meet[left[j]]);\n\t\t\t\tinc(left[j]);\n\t\t\tend;\n\t\tend;\n\t\t//for j:=1 to Q do writeln(left[j],' ',right[j]);\n\t\tif downlim=0 then inc(count);\n if (s[1]='l')and(s[2]='w')and(s[3]='x') then if count<>i then writeln(i,' ',count);\n\t\tinc(ans,count);\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'138E.in');\n\treset(input);\n{$endif}\nlemon;\nend.\n"}, {"source_code": "Program cf99e;\nVar ss:ansistring;\n total:array['a'..'z'] of longint;\n place:array['a'..'z',0..100000] of longint;\n cc,s:array[1..100000] of char;\n cl,cr:array[1..100000] of longint;\n a,c:array[1..100000] of longint;\n ans:int64;\n d,i,j,k,left,right,n,m,cur,std:longint;\nbegin\n readln(ss);\n n:=length(ss);\n for i:=1 to n do\n begin\n s[i]:=ss[i];\n inc(total[s[i]]);\n c[i]:=total[s[i]];\n place[s[i],total[s[i]]]:=i;\n end;\n readln(m,left,right);\n for i:=1 to m do\n readln(cc[i],cl[i],cr[i]);\n cur:=0;\n for i:=1 to m do if cl[i]=0 then inc(std);\n for d:=1 to n do\n begin\n a[d]:=std;\n if (left<=a[d]) and (a[d]<=right) then inc(cur);\n for k:=1 to m do\n if cc[k]=s[d] then\n begin\n if c[d]-cr[k]-1>=0 then\n begin\n for i:=place[s[d],c[d]-cr[k]-1]+1 to place[s[d],c[d]-cr[k]] do\n begin\n dec(a[i]);\n if a[i]=left-1 then cur:=cur-1;\n if a[i]=right then cur:=cur+1;\n end;\n end;\n if c[d]-cl[k]>=0 then\n begin\n for i:=place[s[d],c[d]-cl[k]]+1 to place[s[d],c[d]-cl[k]+1] do\n begin\n inc(a[i]);\n if a[i]=right+1 then cur:=cur-1;\n if a[i]=left then cur:=cur+1;\n end;\n end;\n end;\n ans:=ans+cur;\n end;\n writeln(ans);\nend."}, {"source_code": "Program cf99e;\nVar s:ansistring;\n total:array['a'..'z'] of longint;\n place:array['a'..'z',0..100000] of longint;\n cc:array[1..100000] of char;\n cl,cr:array[1..100000] of longint;\n a,c:array[1..100000] of longint;\n ans:int64;\n d,i,j,k,left,right,n,m,cur:longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n begin\n inc(total[s[i]]);\n c[i]:=total[s[i]];\n place[s[i],total[s[i]]]:=i;\n end;\n readln(m,left,right);\n for i:=1 to m do\n readln(cc[i],cl[i],cr[i]);\n cur:=0;\n for d:=1 to n do\n begin\n if left=0 then inc(cur);\n for k:=1 to m do\n if cc[k]=s[d] then\n begin\n if c[d]-cr[k]-1>=0 then\n begin\n for i:=place[s[d],c[d]-cr[k]-1]+1 to place[s[d],c[d]-cr[k]] do\n begin\n dec(a[i]);\n if a[i]=left-1 then cur:=cur-1;\n if a[i]=right then cur:=cur+1;\n end;\n end;\n if c[d]-cl[k]>=0 then\n begin\n for i:=place[s[d],c[d]-cl[k]]+1 to place[s[d],c[d]-cl[k]+1] do\n begin\n inc(a[i]);\n if a[i]=right+1 then cur:=cur-1;\n if a[i]=left then cur:=cur+1;\n end;\n end;\n end;\n ans:=ans+cur;\n end;\n writeln(ans);\nend."}], "src_uid": "948f7747cab468b26cc28a3ff29fabdd"} {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n sum,j,tmp,n,a,b,m,i,sx,sy: longint;\n can: array [0..41111] of boolean;\n x,y,pred,last,xm,ym,ca,cb: array [0..41111] of longint;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,xx,yy,tmp: longint;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n xx:=x[pp]; yy:=y[pp];\n repeat\n while x[i]*yy > xx*y[i] do inc(i);\n while x[j]*yy < xx*y[j] do dec(j);\n if i <= j then\n begin\n tmp:=x[i]; x[i]:=x[j]; x[j]:=tmp;\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n inc(i); dec(j);\n end;\n until i > j;\n if l < j then Sort(l,j);\n if i < r then Sort(i,r);\nend;\n\nbegin\n randseed:=8753;\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n if n = 3 then\n begin\n writeln('YES');\n writeln('0 0');\n writeln('1 0');\n writeln('0 2');\n halt;\n end;\n fillchar(can,sizeof(can),False);\n for a:=0 to 200 do\n for b:=0 to 200 do\n if a*a+b*b <= 40000 then\n begin\n can[a*a+b*b]:=True;\n ca[a*a+b*b]:=a;\n cb[a*a+b*b]:=b;\n end;\n m:=0;\n for i:=1 to 40000 do\n if can[i] then\n begin\n inc(m);\n xm[m]:=ca[i];\n ym[m]:=cb[i];\n if m = n+1 then break;\n end;\n sx:=0; sy:=0;\n for i:=1 to n do\n begin\n inc(sx,xm[i]);\n inc(sy,ym[i]);\n end;\n if (sx+sy) and 1 = 1 then\n begin\n inc(sx,xm[n+1]);\n inc(sy,ym[n+1]);\n for i:=1 to n do\n if ((sx-xm[i])+(sy-ym[i])) and 1 = 0 then\n begin\n dec(sx,xm[i]);\n// dec(sy,ym[i]);\n xm[i]:=xm[n+1];\n ym[i]:=ym[n+1];\n break;\n end;\n end;\n if sx and 1 = 1 then\n for i:=n downto 1 do\n if (xm[i]+ym[i]) and 1 = 1 then\n begin\n tmp:=xm[i];\n xm[i]:=ym[i];\n ym[i]:=tmp;\n break;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[xm[i]];\n last[xm[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then xm[j]:=-xm[j];\n inc(sum,xm[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[ym[i]];\n last[ym[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then ym[j]:=-ym[j];\n inc(sum,ym[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n writeln('YES');\n m:=0;\n for i:=1 to n do\n if (ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=ym[i];\n end;\n if m > 0 then Sort(1,m);\n sx:=0; sy:=0;\n for i:=1 to m do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy+y[i];\n end;\n m:=0;\n for i:=1 to n do\n if not ((ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0)) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=-ym[i];\n end;\n if m > 0 then Sort(1,m);\n for i:=m downto 1 do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy-y[i];\n end;\n close(input);\n close(output);\nend.", "positive_code": [{"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n sum,j,tmp,n,a,b,m,i,sx,sy: longint;\n can: array [0..41111] of boolean;\n x,y,pred,last,xm,ym,ca,cb: array [0..41111] of longint;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,xx,yy,tmp: longint;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n xx:=x[pp]; yy:=y[pp];\n repeat\n while x[i]*yy > xx*y[i] do inc(i);\n while x[j]*yy < xx*y[j] do dec(j);\n if i <= j then\n begin\n tmp:=x[i]; x[i]:=x[j]; x[j]:=tmp;\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n inc(i); dec(j);\n end;\n until i > j;\n if l < j then Sort(l,j);\n if i < r then Sort(i,r);\nend;\n\nbegin\n randseed:=8753;\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n if n = 3 then\n begin\n writeln('YES');\n writeln('0 0');\n writeln('1 0');\n writeln('0 2');\n halt;\n end;\n fillchar(can,sizeof(can),False);\n for a:=0 to 200 do\n for b:=0 to 200 do\n if a*a+b*b <= 40000 then\n begin\n can[a*a+b*b]:=True;\n ca[a*a+b*b]:=a;\n cb[a*a+b*b]:=b;\n end;\n m:=0;\n for i:=1 to 40000 do\n if can[i] then\n begin\n inc(m);\n xm[m]:=ca[i];\n ym[m]:=cb[i];\n if m = n+1 then break;\n end;\n sx:=0; sy:=0;\n for i:=1 to n do\n begin\n inc(sx,xm[i]);\n inc(sy,ym[i]);\n end;\n if (sx+sy) and 1 = 1 then\n begin\n inc(sx,xm[n+1]);\n inc(sy,ym[n+1]);\n for i:=1 to n do\n if ((sx-xm[i])+(sy-ym[i])) and 1 = 0 then\n begin\n dec(sx,xm[i]);\n// dec(sy,ym[i]);\n xm[i]:=xm[n+1];\n ym[i]:=ym[n+1];\n break;\n end;\n end;\n if sx and 1 = 1 then\n for i:=n downto 1 do\n if (xm[i]+ym[i]) and 1 = 1 then\n begin\n tmp:=xm[i];\n xm[i]:=ym[i];\n ym[i]:=tmp;\n break;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[xm[i]];\n last[xm[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then xm[j]:=-xm[j];\n inc(sum,xm[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[ym[i]];\n last[ym[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then ym[j]:=-ym[j];\n inc(sum,ym[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n writeln('YES');\n m:=0;\n for i:=1 to n do\n if (ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=ym[i];\n end;\n if m > 0 then Sort(1,m);\n sx:=0; sy:=0;\n for i:=1 to m do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy+y[i];\n end;\n m:=0;\n for i:=1 to n do\n if not ((ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0)) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=-ym[i];\n end;\n if m > 0 then Sort(1,m);\n for i:=m downto 1 do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy-y[i];\n end;\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n sum,j,tmp,n,a,b,m,i,sx,sy: longint;\n can: array [0..41111] of boolean;\n x,y,pred,last,xm,ym,ca,cb: array [0..41111] of longint;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,xx,yy,tmp: longint;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n xx:=x[pp]; yy:=y[pp];\n repeat\n while x[i]*yy > xx*y[i] do inc(i);\n while x[j]*yy < xx*y[j] do dec(j);\n if i <= j then\n begin\n tmp:=x[i]; x[i]:=x[j]; x[j]:=tmp;\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n inc(i); dec(j);\n end;\n until i > j;\n if l < j then Sort(l,j);\n if i < r then Sort(i,r);\nend;\n\nbegin\n randseed:=8753;\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n if n = 3 then\n begin\n writeln('YES');\n writeln('0 0');\n writeln('1 0');\n writeln('0 2');\n halt;\n end;\n fillchar(can,sizeof(can),False);\n for a:=0 to 200 do\n for b:=0 to 200 do\n if a*a+b*b <= 40000 then\n begin\n can[a*a+b*b]:=True;\n ca[a*a+b*b]:=a;\n cb[a*a+b*b]:=b;\n end;\n m:=0;\n for i:=1 to 40000 do\n if can[i] then\n begin\n inc(m);\n xm[m]:=ca[i];\n ym[m]:=cb[i];\n if m = n+1 then break;\n end;\n sx:=0; sy:=0;\n for i:=1 to n do\n begin\n inc(sx,xm[i]);\n inc(sy,ym[i]);\n end;\n if (sx+sy) and 1 = 1 then\n begin\n inc(sx,xm[n+1]);\n inc(sy,ym[n+1]);\n for i:=1 to n do\n if ((sx-xm[i])+(sy-ym[i])) and 1 = 0 then\n begin\n dec(sx,xm[i]);\n// dec(sy,ym[i]);\n xm[i]:=xm[n+1];\n ym[i]:=ym[n+1];\n break;\n end;\n end;\n if sx and 1 = 1 then\n for i:=n downto 1 do\n if (xm[i]+ym[i]) and 1 = 1 then\n begin\n tmp:=xm[i];\n xm[i]:=ym[i];\n ym[i]:=tmp;\n break;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[xm[i]];\n last[xm[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then xm[j]:=-xm[j];\n inc(sum,xm[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[ym[i]];\n last[ym[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then ym[j]:=-ym[j];\n inc(sum,ym[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n writeln('YES');\n m:=0;\n for i:=1 to n do\n if (ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=ym[i];\n end;\n if m > 0 then Sort(1,m);\n sx:=0; sy:=0;\n for i:=1 to m do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy+y[i];\n end;\n m:=0;\n for i:=1 to n do\n if not ((ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0)) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=-ym[i];\n end;\n if m > 0 then Sort(1,m);\n for i:=m downto 1 do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy-y[i];\n end;\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n sum,j,tmp,n,a,b,m,i,sx,sy: longint;\n can: array [0..41111] of boolean;\n x,y,pred,last,xm,ym,ca,cb: array [0..41111] of longint;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,xx,yy,tmp: longint;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n xx:=x[pp]; yy:=y[pp];\n repeat\n while x[i]*yy > xx*y[i] do inc(i);\n while x[j]*yy < xx*y[j] do dec(j);\n if i <= j then\n begin\n tmp:=x[i]; x[i]:=x[j]; x[j]:=tmp;\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n inc(i); dec(j);\n end;\n until i > j;\n if l < j then Sort(l,j);\n if i < r then Sort(i,r);\nend;\n\nbegin\n randseed:=8753;\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n if n = 3 then\n begin\n writeln('YES');\n writeln('0 0');\n writeln('1 0');\n writeln('0 2');\n halt;\n end;\n fillchar(can,sizeof(can),False);\n for a:=0 to 200 do\n for b:=0 to 200 do\n if a*a+b*b <= 40000 then\n begin\n can[a*a+b*b]:=True;\n ca[a*a+b*b]:=a;\n cb[a*a+b*b]:=b;\n end;\n m:=0;\n for i:=1 to 40000 do\n if can[i] then\n begin\n inc(m);\n xm[m]:=ca[i];\n ym[m]:=cb[i];\n if m = n+1 then break;\n end;\n sx:=0; sy:=0;\n for i:=1 to n do\n begin\n inc(sx,xm[i]);\n inc(sy,ym[i]);\n end;\n if (sx+sy) and 1 = 1 then\n begin\n inc(sx,xm[n+1]);\n inc(sy,ym[n+1]);\n for i:=1 to n do\n if ((sx-xm[i])+(sy-ym[i])) and 1 = 0 then\n begin\n dec(sx,xm[i]);\n// dec(sy,ym[i]);\n xm[i]:=xm[n+1];\n ym[i]:=ym[n+1];\n break;\n end;\n end;\n if sx and 1 = 1 then\n for i:=n downto 1 do\n if (xm[i]+ym[i]) and 1 = 1 then\n begin\n tmp:=xm[i];\n xm[i]:=ym[i];\n ym[i]:=tmp;\n break;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[xm[i]];\n last[xm[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then xm[j]:=-xm[j];\n inc(sum,xm[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[ym[i]];\n last[ym[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then ym[j]:=-ym[j];\n inc(sum,ym[j]);\n j:=pred[j];\n end;\n end;\n if sum <> 0 then while true do;\n writeln('YES');\n m:=0;\n for i:=1 to n do\n if (ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=ym[i];\n end;\n if m > 0 then Sort(1,m);\n sx:=0; sy:=0;\n for i:=1 to m do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy+y[i];\n end;\n m:=0;\n for i:=1 to n do\n if not ((ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0)) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=-ym[i];\n end;\n if m > 0 then Sort(1,m);\n for i:=m downto 1 do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy-y[i];\n end;\n close(input);\n close(output);\nend."}], "negative_code": [{"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n sum,j,tmp,n,a,b,m,i,sx,sy: longint;\n can: array [0..41111] of boolean;\n x,y,pred,last,xm,ym,ca,cb: array [0..41111] of longint;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,xx,yy,tmp: longint;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n xx:=x[pp]; yy:=y[pp];\n repeat\n while x[i]*yy > xx*y[i] do inc(i);\n while x[j]*yy < xx*y[j] do dec(j);\n if i <= j then\n begin\n tmp:=x[i]; x[i]:=x[j]; x[j]:=tmp;\n tmp:=y[i]; y[i]:=y[j]; y[j]:=tmp;\n inc(i); dec(j);\n end;\n until i > j;\n if l < j then Sort(l,j);\n if i < r then Sort(i,r);\nend;\n\nbegin\n randseed:=8753;\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n fillchar(can,sizeof(can),False);\n for a:=0 to 200 do\n for b:=0 to 200 do\n if a*a+b*b <= 40000 then\n begin\n can[a*a+b*b]:=True;\n ca[a*a+b*b]:=a;\n cb[a*a+b*b]:=b;\n end;\n m:=0;\n for i:=1 to 40000 do\n if can[i] then\n begin\n inc(m);\n xm[m]:=ca[i];\n ym[m]:=cb[i];\n if m = n+1 then break;\n end;\n sx:=0; sy:=0;\n for i:=1 to n do\n begin\n inc(sx,xm[i]);\n inc(sy,ym[i]);\n end;\n if (sx+sy) and 1 = 1 then\n begin\n inc(sx,xm[n+1]);\n inc(sy,ym[n+1]);\n for i:=1 to n do\n if ((sx-xm[i])+(sy-ym[i])) and 1 = 0 then\n begin\n dec(sx,xm[i]);\n// dec(sy,ym[i]);\n xm[i]:=xm[n+1];\n ym[i]:=ym[n+1];\n break;\n end;\n end;\n if sx and 1 = 1 then\n for i:=1 to n do\n if (xm[i]+ym[i]) and 1 = 1 then\n begin\n tmp:=xm[i];\n xm[i]:=ym[i];\n ym[i]:=tmp;\n break;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[xm[i]];\n last[xm[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then xm[j]:=-xm[j];\n inc(sum,xm[j]);\n j:=pred[j];\n end;\n end;\n fillchar(last,sizeof(last),0);\n for i:=1 to n do\n begin\n pred[i]:=last[ym[i]];\n last[ym[i]]:=i;\n end;\n sum:=0;\n for a:=200 downto 0 do\n begin\n j:=last[a];\n while j > 0 do\n begin\n if sum > 0 then ym[j]:=-ym[j];\n inc(sum,ym[j]);\n j:=pred[j];\n end;\n end;\n writeln('YES');\n m:=0;\n for i:=1 to n do\n if (ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=ym[i];\n end;\n if m > 0 then Sort(1,m);\n sx:=0; sy:=0;\n for i:=1 to m do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy+y[i];\n end;\n m:=0;\n for i:=1 to n do\n if not ((ym[i] > 0) or (ym[i] = 0) and (xm[i] > 0)) then\n begin\n inc(m);\n x[m]:=xm[i];\n y[m]:=-ym[i];\n end;\n if m > 0 then Sort(1,m);\n for i:=m downto 1 do\n begin\n writeln(sx,' ',sy);\n sx:=sx+x[i];\n sy:=sy-y[i];\n end;\n close(input);\n close(output);\nend."}], "src_uid": "77b281558c480607b02e8e263e81a455"} {"source_code": "var\n c, d, e, n, p, n1: integer;\n\nbegin\n read(n, p);\n c := 0;\n while n = n do\n begin\n n := n - p;\n c := c + 1;\n d := 1;\n while d <= n do d := d * 2;\n n1 := n;\n e := 0;\n while n1 > 0 do\n begin\n if d <= n1 then \n begin\n n1 := n1 - d;\n e := e + 1;\n end;\n d := d div 2;\n end;\n if (n < c) then \n begin\n write('-1');\n break;\n end\n else if e <= c then \n begin\n write(c);\n break;\n end;\n end;\nend.", "positive_code": [{"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n vhod,kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n \n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0 do begin ans:=ans+t and 1; t:=t shr 1; end;\n koled:=ans;\n end;\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n read(vhod,p);\n z[0]:=1;\n for i:=1 to 32 do z[i]:=z[i-1]*2;\n for i:=1 to 32 do z[i]:=z[i]+p;\n\n { for i:=1 to 20 do writeln(i,' ',koled(i));\n } ans:=100000000000000;\n for step:=0 to 10000000 do\n begin\n ii:=step;\n t:=vhod-ii*p;\n\n if t>0 then\n begin\n { writeln('t= ',t,' koled= ',koled(t));\n } if (koled(t)<=step)and(step<=t) then ans:=min(ans,step);\n end;\n end;\n\n if ans<10000000000 then write(ans) else write(-1);\n\n\n\n \n \n 1: close (output);\n end.\n \n"}, {"source_code": "var n,p,i:longint;\nfunction count(x:longint):longint;\nvar tot:longint;\nbegin\n tot:=0;\n while x>0 do\n begin\n if (x and 1)>0 then inc(tot);\n x:=x div 2;\n end;\n exit(tot);\nend;\nbegin\n readln(n,p);\n for i:=1 to 31 do\n if (n-i*p>=i) and (count(n-i*p)<=i) then begin writeln(i);exit;end;\n writeln(-1);\nend."}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n vhod,kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n \n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0 do begin ans:=ans+t and 1; t:=t shr 1; end;\n koled:=ans;\n end;\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n read(vhod,p);\n z[0]:=1;\n for i:=1 to 32 do z[i]:=z[i-1]*2;\n for i:=1 to 32 do z[i]:=z[i]+p;\n\n { for i:=1 to 20 do writeln(i,' ',koled(i));\n } ans:=100000000000000;\n for step:=0 to 100000 do\n begin\n ii:=step;\n t:=vhod-ii*p;\n\n if t>0 then\n begin\n { writeln('t= ',t,' koled= ',koled(t));\n } if (koled(t)<=step)and(step<=t) then ans:=min(ans,step);\n end;\n end;\n\n if ans<10000000000 then write(ans) else write(-1);\n\n\n\n \n \n 1: close (output);\n end.\n \n"}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n vhod,kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n \n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0 do begin ans:=ans+t and 1; t:=t shr 1; end;\n koled:=ans;\n end;\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n read(vhod,p);\n z[0]:=1;\n for i:=1 to 32 do z[i]:=z[i-1]*2;\n for i:=1 to 32 do z[i]:=z[i]+p;\n\n { for i:=1 to 20 do writeln(i,' ',koled(i));\n } ans:=100000000000000;\n for step:=0 to 1000000 do\n begin\n ii:=step;\n t:=vhod-ii*p;\n\n if t>0 then\n begin\n { writeln('t= ',t,' koled= ',koled(t));\n } if (koled(t)<=step)and(step<=t) then ans:=min(ans,step);\n end;\n end;\n\n if ans<10000000000 then write(ans) else write(-1);\n\n\n\n \n \n 1: close (output);\n end.\n \n"}], "negative_code": [{"source_code": "var n,p,i:longint;\nfunction count(x:longint):longint;\nvar tot:longint;\nbegin\n tot:=0;\n while x>0 do\n begin\n if (x and 1)>0 then inc(tot);\n x:=x div 2;\n end;\n exit(tot);\nend;\nbegin\n readln(n,p);\n for i:=1 to 31 do\n if (n-i*p>0) and (count(n-i*p)<=i) then begin writeln(i);exit;end;\n writeln(-1);\nend."}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n vhod,kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n \n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0 do begin ans:=ans+t and 1; t:=t shr 1; end;\n koled:=ans;\n end;\n \n \n \n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n read(vhod,p);\n z[0]:=1;\n for i:=1 to 32 do z[i]:=z[i-1]*2;\n for i:=1 to 32 do z[i]:=z[i]+p;\n \n { for i:=1 to 20 do writeln(i,' ',koled(i));\n } ans:=100000000000000;\n for step:=0 to 10000000 do\n begin\n ii:=step;\n t:=vhod-ii*p;\n \n if t>0 then\n begin\n { writeln('t= ',t,' koled= ',koled(t));\n } if koled(t)<=step then ans:=min(ans,step);\n end;\n end;\n \n if ans<10000000000 then write(ans) else write(-1);\n \n \n \n \n \n 1: close (output);\n end.\n \n"}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n vhod,kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n \n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0 do begin ans:=ans+t and 1; t:=t shr 1; end;\n koled:=ans;\nend;\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n read(vhod,p);\n z[0]:=1;\n for i:=1 to 32 do z[i]:=z[i-1]*2;\n for i:=1 to 32 do z[i]:=z[i]+p;\n\n { for i:=1 to 20 do writeln(i,' ',koled(i));\n } ans:=100000000000000;\n for step:=0 to 1000000 do\n begin\n ii:=step;\n t:=vhod-ii*p;\n\n if t>0 then\n begin\n { writeln('t= ',t,' koled= ',koled(t));\n } if koled(t)<=step then begin ans:=min(ans,step); goto 2; end;\n end;\n end;\n\n 2: if ans<10000000000 then write(ans) else write(-1);\n\n\n\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": "var\n c, d, e, n, p, n1: integer;\n\nbegin\n read(n, p);\n c := 0;\n while n = n do\n begin\n n := n - p;\n c := c + 1;\n d := 1;\n while d <= n do d := d * 2;\n n1 := n;\n e := 0;\n while n1 > 0 do\n begin\n if d <= n1 then \n begin\n n1 := n1 - d;\n e := e + 1;\n end;\n d := d div 2;\n end;\n if (n <= 0) then \n begin\n write('-1');\n break;\n end\n else if e <= c then \n begin\n write(c);\n break;\n end;\n end;\nend."}, {"source_code": "var\n c, d, e, n, p, n1: integer;\n\nbegin\n read(n, p);\n c := 0;\n while n = n do\n begin\n n := n - p;\n c := c + 1;\n d := 1;\n while d <= n do d := d * 2;\n n1 := n;\n e := 0;\n while n1 > 0 do\n begin\n if d <= n1 then \n begin\n n1 := n1 - d;\n e := e + 1;\n end;\n d := d div 2;\n end;\n if (n <= 1) then \n begin\n write('-1');\n break;\n end\n else if e <= c then \n begin\n write(c);\n break;\n end;\n end;\nend."}, {"source_code": "var\n c, d, e, n, p, n1: integer;\n\nbegin\n read(n, p);\n c := 0;\n while n = n do\n begin\n n := n - p;\n c := c + 1;\n d := 1;\n while d <= n do d := d * 2;\n n1 := n;\n e := 0;\n while n1 > 0 do\n begin\n if d <= n1 then \n begin\n n1 := n1 - d;\n e := e + 1;\n end;\n d := d div 2;\n end;\n if (n <= 0) or ((n = 1) and (p <> 0)) then \n begin\n write('-1');\n break;\n end\n else if e <= c then \n begin\n write(c);\n break;\n end;\n end;\nend."}], "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8"} {"source_code": "var l,r:int64;\nbegin\n readln(l,r);\n if l mod 2 <> 0 then inc(l);\n if r - l < 2 then writeln(-1)\n else writeln(l,' ',l+1,' ',l+2);\n readln;\nend.", "positive_code": [{"source_code": "var l, r : int64;\n\nbegin\n readln(l, r);\n if (r - l < 2) or ((r - l = 2) and (l mod 2 = 1)) then writeln(-1)\n else\n begin\n if (l mod 2 = 1) then writeln(l + 1, ' ', l + 2, ' ', l + 3)\n else writeln(l, ' ', l + 1, ' ', l + 2);\n end;\nend."}, {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n\nvar\n fi,fo:Text;\n x,y:int64;\n\nprocedure xuli;\n begin\n readln(fi,x,y);\n if x mod 2=1 then inc(x);\n if y-x<2 then writeln(fo,-1)\n else\n if x mod 2=0 then writeln(fo,x,' ',x+1,' ',x+2);\n end;\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g :text;\n l,r:int64;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n readln(f,l,r);\n if r-l<2 then writeln(g,-1)\n else\n begin\n if r-l=2 then\n begin\n if l mod 2=1 then writeln(g,-1)\n else writeln(g,l,' ',l+1,' ',l+2);\n end\n else\n begin\n if l mod 2=1 then writeln(g,l+1,' ',l+2,' ',l+3)\n else writeln(g,l,' ',l+1,' ',l+2);\n end;\n end;\n close(f);\n close(g);\nend.\n"}, {"source_code": "program asd;\nvar l,p:int64;\nbegin\nread(l,p);\nif p-l+1>=4 then\n if (l mod 2=0) then writeln(l,' ',l+1,' ',l+2)\n else writeln(l+1,' ',l+2,' ',l+3)\nelse\nif p-l+1>=3 then\n if (l mod 2=0) then writeln(l,' ',l+1,' ',l+2)\n else writeln(-1)\nelse writeln(-1);\n\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nConst Inputfile = '';//'480A.INP';\n Outputfile = '';//'480A.OUT';\n\nVar l,h : int64;\n\nProcedure Readfile;\n BEGIN\n Readln(l,h);\n END;\n\nProcedure Process;\n BEGIN\n If (h-l=2) and (l mod 2 = 1) then\n BEGIN\n Write(-1);\n Exit;\n END;\n If (h-l<2) then\n BEGIN\n Write(-1);\n Exit;\n END;\n If l mod 2 = 0 then write(l,' ',l+1,' ',l+2) else write(l+1,' ',l+2,' ',l+3);\n END;\n\nBEGIN\n Assign(Input,Inputfile);\n Reset(Input);\n Assign(Output,Outputfile);\n Rewrite(Output);\n Readfile;\n Process;\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "program A483;\nvar a, b, i, i2, i3: int64;\nfunction iscoprime(a, b: int64): boolean;\n var z: int64;\n begin\n while b<>0 do begin\n z:=a mod b;\n a:=b;\n b:=z;\n end;\n if a=1 then exit(true) else exit(false);\n end;\nbegin\n readln(a, b);\n i:=a;\n i2:=a+1;\n i3:=a+2;\n while i<=b-2 do begin\n i2:=i+1;\n while i2<=b-1 do begin\n i3:=i2+1;\n while i3<=b do begin\n if iscoprime(i, i2) and iscoprime(i2, i3) and not(iscoprime(i, i3)) then begin\n writeln(i, ' ', i2, ' ', i3);\n exit\n end;\n inc(i3);\n end;\n inc(i2);\n end;\n inc(i);\n end;\n writeln(-1);\nend."}, {"source_code": "Var\n r, l: Int64;\n \nBegin\n Read(r, l);\n If (l - r + 1 < 3) or ((l - r + 1 = 3) and (r mod 2 = 1)) then\n Write(-1)\n Else If r mod 2 = 0 then\n Write(r, ' ', r + 1, ' ', r + 2)\n Else If r mod 2 = 1 then\n Write(r + 1, ' ', r + 2, ' ', r + 3)\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n l, r: int64;\n\nbegin\n read(l, r);\n if l mod 2 = 1 then inc(l);\n if l + 2 > r then writeln(-1)\n else writeln(l, ' ', l + 1, ' ', l + 2);\nend.\n"}, {"source_code": "var a,b,c,l,r:int64;\nfunction nod(a1,b1:int64):int64;\n begin\n while (a1>0) and (b1>0) do\n if a1>b1 then a1:=a1 mod b1\n else b1:=b1 mod a1;\n nod:=a1+b1;\n end;\nbegin\nreadln(l,r);\na:=l;\nb:=l;\nc:=l;\nwhile a<=r do \n begin\n while b<=r do \n begin\n while c<=r do \n begin\n if (nod(a,b)=1) and (nod(b,c)=1) and (nod(a,c)<>1) and (a<>b) and (b<>c) and (a<>c) and (a<=b) and (b<=c) and (a<=c)\n then begin write(a,' ',b,' ',c); halt; end; \n inc(c);\n end;\n inc(b);\n c:=l;\n end;\n b:=l;\n inc(a);\n end;\nwrite(-1);\nend."}, {"source_code": "program A483;\nvar\n f: text;\n l, r, a, b, c: qword ;\n fl: boolean;\nfunction ucln(x, y: qword): qword;\nbegin\n if x mod y = 0 then ucln := y else ucln := ucln(y, x mod y);\nend;\n\nfunction coprime(x, y: qword): boolean;\nbegin\n if ucln(x, y) = 1 then coprime := true else coprime := false;\nend;\nbegin\n fl := false;\n assign(f, ''); reset(f);\n readln(f, l, r);\n if l = r then begin writeln(-1); exit end;\n a := l; b := l+1; c := l+2;\n while a <= r-2 do begin\n b := l+1;\n while b <= r-1 do begin\n c := l+2;\n while c <= r do begin\n if (coprime(a, b) and coprime(b, c) and (not coprime(a, c)) and\n (a <> b) and (b<>c)) then begin\n writeln(a, ' ', b, ' ', c);\n // fl := true;\n exit;\n end;\n inc(c);\n end;\n inc(b)\n end;\n inc(a);\n end;\n writeln(-1);\nend."}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n modul=1000000007;\n label 1,2,3,4;\n type\n\n mas=array [-10000..10000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var t,t1,t2,t3,cc,aa,bb,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,n,kk,qq,p3,ot,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,besk1:int64;\n shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..1000] of char;\n poin:zap;\n vec:array[-100..1000] of zap;\n c1,c2:array[-1000..100000] of int64;\n fact,dd, a1,bl,br,c,a,b:array[-300000..2000000] of int64;\n sumsum,sum, scob, razr :array[-1..31,-10..110000] of longint;\n maxsum:array[-1..1010,-1..1010] of int64;\n sss, ss1,ss2:string;\n newgr,gr:array[-100..200000] of boolean;\n pole:array[-1..1500,-1..1500] of char;\n ss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n pr,aanew,v0,v1,s0,t0:extended;\n z,x1,y1,y,x:array[-1..30000] of int64;\n xxx,yyy:array[-1..100000] of double;\n xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction good(aa,bb,cc:int64):boolean; var pp1,pp2,jj,ii,i1,i2,i3:int64;\n begin\n if (nod(aa,bb)=1)and(nod (bb,cc)=1)and(nod(aa,cc)>1)and(aa<>bb)and(bb<>cc)and(aa<>cc) then\n good:=true else good:=false;\n\n\n\n end;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n t:=p2-p1;\n for i:=0 to t do for j:=i to t do for k:=j to t do\n begin\n t1:=p1+i; t2:=p1+j; t3:=p1+k;\n if good(t1,t2,t3) then begin write(t1,' ',t2,' ',t3); goto 1; end;\n\n\n end;\n\n write(-1);\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var kq:array[1..3] of qword;\n\nfunction coprime(x,y:qword):qword;\nvar r,temp:qword;\nbegin\n\tif x0 ) then kq[3]:=i else inc(i);\nend;\n\nprocedure process(l,r:qword);\nbegin\n\tif l mod 2 = 0 then begin kq[1]:=l; kq[2]:=l+1; kq[3]:=l+2; end\n\telse\n\tbegin\n\t\tkq[1]:=l;\n\t\tkq[2]:=l+1;\n\t\tgosearch(l+1,r);\n\tend;\nend;\n\nprocedure proonf;\nvar l,r:qword;\nlabel stop;\nbegin\n\treadln(l,r);\n if (r-l+1<3)or((r-l+1=3)and(l mod 2<>0)) then begin writeln(-1); goto stop end\n else\n begin\n if l mod 2=0 then writeln(l,#32,l+1,#32,l+2)\n else writeln(l+1,#32,l+2,#32,l+3);\n end;\n stop:\nend;\n\n//main\nbegin\n proonf;\nend.\n"}, {"source_code": "var r,l:qword;\nbegin\n readln(l,r);\n if (r=l) or (l+2>r) then writeln(-1)\n else\n begin\n if l mod 2=0 then writeln(l,' ',l+1,' ',l+2)\n else\n if (l+3<=r) then\n begin\n writeln(l+1,' ',l+2,' ',l+3);\n end\n else writeln(-1);\n end;\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n\nvar\n l, r: int64;\n\nbegin\n read(l, r);\n if l mod 2 = 1 then inc(l);\n if l + 2 > r then writeln(-1)\n else writeln(l, ' ', l + 1, ' ', l + 2);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils;\n\nfunction GCD(a,b:int64):int64;\nbegin\n if b=0 then result:=a\n else result:=GCD(b,a mod b);\nend;\n\nvar\n i,j,k,l,r:int64;\n\nbegin\n //Reset(input,'input.txt');\n //Rewrite(output,'output.txt');\n\n Readln(l,r);\n i:=l;\n while i<=r do begin\n j:=i+1;\n while j<=r do begin\n k:=j+1;\n while k<=r do begin\n if (GCD(i,j)=1) and (GCD(j,k)=1) and (GCD(i,k)<>1) then begin\n Writeln(i,' ',j,' ',k);\n halt;\n end;\n inc(k);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\nend."}, {"source_code": "uses\n SysUtils;\n\nvar\n l,r,i:int64;\nbegin\n readln(l,r);\n if ((l+2)>r) then\n begin\n write('-1');\n exit;\n end;\n if (l mod 2=0)then begin\n write (l,' ',l+1,' ',l+2);\n exit;\n end;\n if ((l+3)>r) then\n begin\n write('-1');\n exit;\n end;\n if (l mod 2<>0)then begin\n write (l+1,' ',l+2,' ',l+3);\n exit;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses SysUtils;\nvar n,i,j,k,l,r:int64;\n\nfunction GCD(a,b:int64):int64;\nbegin\n if b=0 then result:=a\n else result:=GCD(b,a mod b);\nend;\n\nbegin\n Readln(l,r);\n i:=l;\n while (i<=r) do\n begin\n j:=i+1;\n while (j<=r) do\n begin\n k:=j+1;\n while (k<=r) do\n begin\n if (GCD(i,j)=1) and (GCD(j,k)=1) and (GCD(i,k)<>1) then\n begin\n Writeln(i,' ',j,' ',k);\n halt;\n end;\n inc(k);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var l,r:int64;\nbegin\n// reset(input,'input.txt');\n// assign(output,'output.txt');\n read(l,r);\n if r-l<2\n then write(-1)\n else begin\n if l mod 2=0\n then write(l,' ',l+1,' ',l+2)\n else begin\n inc(l);\n if r-l<2\n then write(-1)\n else if l mod 2=0\n then write(l,' ',l+1,' ',l+2)\n end;\n end;\nend.\n"}, {"source_code": "program Project;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, m , x, y, q1, q2 :integer;\n l, r, i, j, u :int64;\n\nfunction nod(x, y:int64):int64;\nbegin\n if (x <> 0) then \n nod := nod(y mod x, x) \n else \n nod := y;\nend;\n\nbegin\n readln(l, r);\n i := l - 1;\n while (i < r) do\n begin\n inc(i);\n j := l - 1;\n while (j < r) do\n begin\n inc(j);\n u := l - 1;\n while (u < r) do\n begin\n inc(u);\n if (i = j) or (j = u) or (u = i) or (i > j) or (j > u) then\n continue;\n if (i < j) and (j < u) and (nod(i, j) = 1) and (nod(j, u) = 1) and (nod(i, u) <> 1) then\n begin\n writeln(i, ' ', j, ' ', u);\n halt(0);\n end;\n end;\n end;\n end;\n\n writeln('-1');\n readln;\n readln;\nend.\n"}, {"source_code": "Var l, r:int64;\nBegin\nRead(l,r);\nIf (r-l)<=1 Then\nWriteLn('-1')\nElse\nBegin\nIf l mod 2=0 Then\nWriteLn(l,' ',l+1,' ',l+2)\nElse\nBegin\nIf (r-l)=2 Then\nWriteLn('-1')\nElse\nWriteLn(l+1,' ',l+2,' ',l+3);\nEnd;\nEnd;\nEnd."}, {"source_code": "VAR l, r, a, b, c : int64;\nFUNCTION UCLN(i,j : int64) : boolean;\n Var r : int64;\n Begin\n while i <> 0 do\n begin\n r := j mod i;\n j := i;\n i := r;\n end;\n if j = 1 then UCLN := true else UCLN := false;\n End;\nPROCEDURE COPRIME(l,r : int64);\n Var i, j : int64;\n Begin\n c := 0;\n i := l;\n while (i <= r) and (c = 0) do\n begin\n a := 0;\n j := i+1;\n while (j <= r) and (a = 0) do\n if UCLN(i,j) = true then\n begin\n a := i;\n b := j;\n end\n else j := j + 1;\n j := j + 1;\n while (j <= r) and (c = 0) do\n begin\n if (UCLN(a,j) = false) and (UCLN(b,j) = true) then c := j;\n j := j + 1;\n end;\n i := i + 1;\n end;\n End;\nPROCEDURE PROCESS;\n Var f1, f2 : text;\n Begin\n readln(l,r);\n COPRIME(l,r);\n if c <> 0 then write(a,' ',b,' ',c)\n else write('-1');\n \n End;\nBEGIN\n PROCESS;\nEND.\n"}, {"source_code": "\nVAR l, r: int64;\n\nPROCEDURE input;\nVAR fi: TEXT;\nBEGIN\n\n readln( l, r);\n \nEND;\n\nFUNCTION UCLN(x, y: int64): int64;\nBEGIN\n IF x MOD y = 0 THEN UCLN:= y ELSE UCLN:= UCLN(y, x MOD y);\nEND;\n\nFUNCTION check(x, y: int64): BOOLEAN;\nBEGIN\n IF ucln(x, y) = 1 THEN exit(TRUE) ELSE exit(FALSE);\nEND;\n\nPROCEDURE proc;\nVAR fo: TEXT;\n i, j, k: BYTE;\n m: int64;\nBEGIN \n input;\n \n m:= r - l;\n FOR i:= 0 TO m DO\n FOR j:= i TO m DO\n FOR k:= j TO m DO\n IF check(i + l, j + l) AND check(j + l, k + l) AND NOT(check(i + l, k + l)) THEN\n BEGIN\n write( i + l, ' ', j + l, ' ', k + l);\n \n exit;\n END;\n write( '-1');\n \nEND; \n\nBEGIN\n proc;\nEND."}, {"source_code": "var l,r,a,b,c : int64;\nfunction ucln(a,b: int64) : int64;\nvar t: int64;\nbegin\n while b>0 do\n begin\n a:=a mod b;\n t:=a;\n a:=b;\n b:=t;\n end;\n exit(a);\nend;\nbegin\n readln(l,r);\n a:=l;\n b:=l+1;\n c:=l+2;\n while a<=r-2 do\n begin\n b:=l+1;\n while b<=r-1 do\n begin\n c:=l+2;\n while c<=r do\n begin\n if (ucln(a,b)=1) and (ucln(b,c)=1) then\n if not(ucln(a,c)=1) then\n begin\n writeln(a,' ',b,' ',c);\n exit;\n end;\n inc(c);\n end;\n inc(b);\n end;\n inc(a);\n end;\n write(-1);\nend.\n"}, {"source_code": "var\n l, r: int64;\n\nbegin\n readln(l,r);\n if odd(l) then inc(l);\n if r - l >= 2 then write(l, ' ', l + 1, ' ', l + 2, ' ' ) \n else write('-1');\nend."}, {"source_code": "program Tha;\nvar\n l,r:int64;\nbegin\n readln(l,r);\n if l mod 2=1 then\n l:=l+1;\n if r-l>1 then\n writeln(l,' ',l+1,' ',l+2)\n else writeln(-1);\nend."}, {"source_code": "function gcd(a, b: qword): qword;\nbegin\n while (a <> 0) and (b <> 0) do\n if a > b then\n a:= a mod b\n else\n b:= b mod a;\n\n gcd:= a or b;\nend;\n\n\nvar a, b, c, l, r: qword;\nbegin\n read(l, r);\n a:= l;\n while a <= r do\n begin\n b:= a + 1;\n while b <= r do\n begin\n c:= b + 1;\n while c <= r do\n begin\n if (gcd(a, b) = 1) and (gcd(b, c) = 1) and (gcd(a, c) > 1) then\n begin\n write(a,' ',b,' ',c);\n exit;\n end;\n inc(c);\n end;\n inc(b);\n end;\n inc(a);\n end;\n write(-1);\nend."}, {"source_code": "{const fi='checking.inp';\n fo='checking.out'; }\nvar a,b:int64;\n{--------------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend; }\n{-----------------------------------}\n{procedure closefiles;\nbegin\n close(input);close(output);\nend;}\n{---------------------------------------}\nprocedure stdin;\nbegin\n read(a,b);\nend;\n{------------------------------------------}\nprocedure process;\nvar x,y,z:int64;\nbegin\n if (a mod 2=0) then x:=a\n else x:=a+1;\n y:=x+1;\n z:=y+1;\n\n if z>b then writeln('-1')else write(x,' ',y,' ',z);\nend;\n{-----------------------------------------------}\nBEGIN\n {openfiles;}\n stdin;\n process;\n {closefiles;}\nEND."}, {"source_code": "uses math;\nvar a,b,c,cc:array [1..10000] of longint;\ni,j,l,r,z:int64;\n n,m:int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y,xx: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n xx:=b[(l+r) div 2];\n repeat\n while (a[i]xx)) do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0) and (y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if (x+y)=1 then exit(true) else exit(false);\n end;\n\n begin\n ////\n z:=0; i:=0; j:=0; m:=0; n:=0;\n readln(l,r);\n i:=l;\n while (i<=r) do\n begin\n j:=i+1;\n while (j<=r) do\n begin\n z:=j+1;\n while (z<=r) do\n begin\n if (i<>j) and (i<>z) and (j<>z) then\n begin\n if (prov(i,j)) and (prov(j,z)) and (not(prov(i,z))) then\n begin\n writeln(i,' ',j,' ',z);\n halt;\n end;\n inc(Z);\n end;\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\n\n end."}, {"source_code": "var\n l,r : int64;\n\nbegin\n readln(l,r);\n if odd(l) then inc(l);\n if r-l < 2 then writeln(-1) else writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "Var l,r:int64;\nBegin\n Readln(l,r);\n if (r-l)<2 then write('-1')\n else\n begin\n If l mod 2=0 then write(l,' ',l+1,' ',l+2)\n else \n begin\n If (r-l)>=3 then write(l+1,' ',l+2,' ',l+3)\n else write('-1');\n end;\n end;\nEnd."}, {"source_code": " var i,j,a,b,x,y,k,f : int64;\nbegin\n readln(a,b);\n if b-a>2 then\n begin\n if a mod 2=1 then inc(a);\n writeln(a,' ',a+1,' ',a+2);\n end else\n if b-a=2 then\n begin\n if a mod 2=0 then writeln(a,' ',a+1,' ',b) else writeln('-1');\n end else writeln('-1');\nend."}, {"source_code": "var l, r: int64;\nbegin\n readln(l,r);\n if (r-l+1)<3 then write (-1) else\n begin\n if l mod 2=0 then\n begin\n write(l,' ',l+1,' ',l+2); halt;\n end;\n if (l+3)>r then\n begin\n write (-1);\n halt;\n end;\n l := l+1;\n write(l,' ',l+1,' ',l+2);\n end;\nend."}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483.inp';\n Fo ='';//483.out';\n//\nVar\n L,R :int64;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If ((R-L+1)<=2) or ((R-L+1=3) and (L mod 2 = 1)) then Write(-1)\n Else\n If (L mod 2 = 0) then Write(L,' ',L+1,' ',L+2)\n Else Write(L+1,' ',L+2,' ',L+3);\nEnd."}, {"source_code": "var\ni,j,k,l,r:int64;\nfunction gsd(a,b:int64):int64;\nbegin\n while (a>0)and(b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n gsd:=a+b;\nend;\nbegin\nread(l,r);\ni:=l;\nwhile i<=r-2 do\nbegin\nj:=i+1;\nwhile j<=r-1 do\n begin\n k:=j+1;\n while k<=r do\n begin\nif (gsd(i,j)=1)and(gsd(j,k)=1)and(gsd(i,k)<>1) then begin writeln(i,' ',j,' ',k);halt;end;\ninc(k);\nend;\ninc(j);\nend;\ninc(i);\nend;\nwriteln(-1);\nend."}, {"source_code": "var\n l,r,i,j,k : int64;\n\n function gcd(x,y : int64) : int64; begin\n if y = 0 then exit(x) else exit(gcd(y,x mod y));\n end;\n\nbegin\n readln(l,r);\n i:=l;\n while i <= r do begin\n j:=i+1;\n while j <= r do begin\n k:=j+1;\n while k <= r do begin\n if (gcd(i,j) = 1) and (gcd(j,k) = 1) and (gcd(i,k) > 1) then begin writeln(i,' ',j,' ',k); halt; end;\n inc(k);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\nend."}, {"source_code": "program yan;\n var ar:array[1..3]of uint64;\n a,b,c,x,y,n,m,i,j:uint64;\n procedure sort;\n var i,j:longint; x:uint64;\n begin\n for i:=1 to 3-1 do\n for j:=1 to 3-i do\n if ar[j]>ar[j+1] then\n begin\n x:=ar[j]; ar[j]:=ar[j+1]; ar[j+1]:=x;\n end;\n end;\nbegin\n readln(a,b);\n m:=a; i:=a;\n if a+2>b then begin write(-1); exit; end;\n while i<>b do\n begin\n j:=i+1;\n while j<=b do\n begin\n x:=i; y:=j;\n while (x<>0)and(y<>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if x=0 then c:=y else c:=x;\n if c=1 then\n begin\n n:=j+1;\n while n<=b do\n begin\n if (n<>i)and(n<>j) then\n begin\n x:=n; y:=i;\n while (x<>0)and(y<>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if x=0 then c:=y else c:=x;\n if c=1 then break;\n x:=n; y:=j;\n while (x<>0)and(y<>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if x=0 then c:=y else c:=x;\n if c<>1 then break;\n ar[1]:=n; ar[2]:=i; ar[3]:=j; sort;\n write(ar[1],' ',ar[2],' ',ar[3]);\n exit;\n end;\n inc(n); end;\n end;\n inc(j);\n end;\n inc(i);\n end;\n write(-1);\nend."}, {"source_code": "var l,r,i,j,k,k1,j1:int64;\n\nfunction kt1(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a=1);\nend;\n\n\nfunction kt2(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a<>1);\nend;\n\n\nbegin\n readln(l,r);\n i:=l;\n j:=l+1;\n j1:=j;\n k:=l+2;\n k1:=k;\n while i<=r-2 do\n begin\n j:=j1;\n while j<=r-1 do\n begin\n k:=k1;\n while k<=r do\n begin\n if (kt1(i,j)) and (kt1(j,k)) and (kt2(i,k)) then\n begin\n writeln(i,' ',j,' ',k);\n exit;\n end;\n k:=k+1;\n end;\n j:=j+1;\n end;\n i:=i+1;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "Var l, r: int64;\nBegin\n ReadLn(l, r);\n if l mod 2 = 1 then inc(l);\n if r - l >= 2 then WriteLn(l, ' ', l+1, ' ', l+2) else WriteLn(-1);\nend.\n\n"}, {"source_code": "var\n l,r:int64;\nbegin\n readln(l,r);\n if r-l<2 then writeln(-1) else\n if (r-l=2) and (r mod 2 = 1) then writeln(-1) else begin\n if l mod 2 = 0 then writeln(l,' ',l+1,' ',l+2) else writeln(l+1,' ',l+2,' ',l+3);\n end;\nend.\n"}, {"source_code": "var\n l, r: int64;\n\nbegin\n read(l, r);\n if r - l < 2 then\n begin\n write(-1);\n exit;\n end;\n \n if l mod 2 = 0 then write(l, ' ', l + 1, ' ', l + 2)\n else\n begin\n if (r - l - 1 >= 2) then\n write(l + 1, ' ', l + 2, ' ', l + 3)\n else\n write(-1);\n end;\nend."}, {"source_code": "var\n i,L,R,a,b,c:Int64;\n F:Boolean;\nfunction gcd(aa,bb:Int64):Int64;\nbegin\n while (aa>0) and (bb>0) do\n if aa>bb then aa:=aa mod bb\n else bb:=bb mod aa;\n gcd:=aa+bb;\n end;\n\nbegin\n Readln(L,R);\n F:=False;\n i:=L;\n while i=L) and (c<=R) then\n if (gcd(a,c)<>1) and (gcd(b,c)=1) then begin F:=True; Writeln(a,' ',b,' ',c); Halt; end;\n\n Inc(c);\n end;\n Inc(i);\n end;\n if not F then Writeln('-1');\n end."}, {"source_code": "program gipotezy;\nvar\nl,r,a,b,c:int64;\n\n\nfunction wz(x,y:int64):boolean;\nvar ans:int64;\nbegin\nwz:=false;\nwhile(x<>0) and (y<>0) do\nbegin\nif x>y then x:=x mod y else\ny:=y mod x;\n\nans:=x+y;\nif ans=1 then wz:=true else wz:=false;\n\n\nend;\n\n\n\nend;\n\nbegin\nreadln(l,r);\n\na:=l;\nwhile(a<=r) do\nbegin\nb:=a+1;\n\nwhile(b<=r) do\n begin\n c:=b+1;\n\n while(c<=r) do\n begin\n\n\n if (wz(a,b)= true) and (wz(b,c)=true) and\n (wz(a,c)=false ) then begin writeln(a,' ',b,' ',c); halt; end;\n inc(c);\n end;\n\n inc(b);\n end;\n\n inc(a);\n end;\n\n\n\n\n\n\n\nwriteln('-1');\nend.\n"}, {"source_code": "var l,r:int64;\nbegin\nreadln(l,r);\n\nwhile l mod 2=1 do\n inc(l);\n\nif r-l<2 then writeln(-1)\n else writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "var a,b,c,l,r,d,kl:int64;\ni,x:longint;\nbegin\n\n readln(l,r);\n if l=1 then\n begin\n a:=2;\n b:=3;\n c:=4;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1)\n end\n ELSE\n BEGIN\n\n if l mod 2=0 then\n begin\n a:=l;\n b:=l+1;\n c:=l+2;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1)\n end\n else begin\n a:=l+1;\n b:=l+2;\n c:=l+3;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1);\n end;\n END;\nend.\n"}, {"source_code": "var\n l,r,a:int64;\nbegin\n readln(l,r);\n if l mod 2=1 then a:=l+1 else a:=l;\n\n if r-a<2 then writeln(-1)\n else\n begin\n writeln(a,' ',a+1,' ',a+2);\n end;\nend.\n"}, {"source_code": "var l,r:int64;\nprocedure xuat;\nbegin\n if (r-l<=1) or ((r-l<=2) and (l mod 2<>0)) then\n begin\n writeln(-1);\n exit\n end;\n if (l mod 2=0) then\n writeln(l,' ',l+1,' ',l+2)\n else writeln(l+1,' ',l+2,' ',l+3);\nend;\nbegin\n readln(l,r);\n xuat;\nend.\n"}, {"source_code": "var l,r:int64;\nbegin\n read(l,r);\n if (r-l>=3) and (l mod 2=0) then\n write(l,' ',l+1,' ',l+2)\n else\n begin\n if (r-l>=3) and (l mod 2=1) then\n write(l+1,' ',l+2,' ',l+3)\n else\n begin\n if (r-l=2) and (l mod 2=0) then\n write(l,' ',l+1,' ',l+2)\n else write(-1);\n end;\n end;\nend."}, {"source_code": "var l,r,a,b,c,s:qword; h,i,j,k:byte;\n{------------------------------------------------------------------------------}\nfunction ucln(m,n:qword):qword;\nvar r:qword;\nbegin\n while n>0 do\n begin\n r:=m mod n; m:=n; n:=r;\n end;\n ucln:=m;\nend;\n{------------------------------------------------------------------------------}\nbegin\n readln(l,r); h:=r-l;\n for i:=0 to h do\n begin\n a:=l+i; \n for j:=i+1 to h do\n begin\n b:=l+j;\n for k:=j+1 to h do\n begin\n c:=l+k;\n if ((a1)) then\n begin\n writeln(a,' ',b,' ',c); halt;\n end;\n end;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "var \nl,r:int64; i:longint;\nbegin\n read(l,r);\n if (r-l>2)or((r-l=2)and(l mod 2 = 0)) then\n begin\n if (l mod 2 = 1) then inc(l); \n for i:=0 to 2 do\n write(i+l,' ') \n end else\n write('-1');\nend."}, {"source_code": "Var f : text;\n l,r,k : int64;\n kt : boolean;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,l,r); close(f);\n Assign(f,''); Rewrite(f);\n kt:=true;\n If r-l+1<=2 then kt:=false\n Else\n If l mod 2 <>0 then\n Begin\n k:=l+1;\n If k+2<=r then\n writeln(f,k,' ',k+1,' ',k+2)\n Else kt:=false;\n End\n Else\n Begin\n k:=l;\n If k+2<=r then\n writeln(f,k,' ',k+1,' ',k+2)\n Else kt:=false;\n End;\n If kt=false then writeln(f,'-1');\n Close(f);\nEND."}, {"source_code": "var\n l,r:qword;\nbegin\n readln(l,r);\n if r-l<2 then writeln(-1)\n else\n begin\n if l mod 2=0 then writeln(l,' ',l+1,' ',l+2)\n else\n if r-l>2 then writeln(l+1,' ',l+2,' ',l+3)\n else writeln(-1);\n end;\nend."}, {"source_code": "var l,r:qword;\nbegin\nread(l,r);\nif(l mod 2=0) then\n if(r-l)<2 then\n writeln('-1')\n else\n writeln(l,' ',l+1,' ',l+2)\nelse\n if(r-l)<3 then\n writeln('-1')\n else\n writeln(l+1,' ',l+2,' ',l+3);\nend."}, {"source_code": "var l,r: int64;\nbegin\n read (l,r);\n if (l mod 2<>0) then\n l:=l+1;\n if (r-l<2) then\n write (-1)\n else\n write(l,' ',l+1,' ',l+2);\n //bayan\nend."}, {"source_code": "Program _483A;\nvar\n L, R : int64;\nbegin\n read(L, R);\n if R <= L + 1\n then write(-1)\n else if R = L + 2\n then if L mod 2 = 1\n then write(-1)\n else write(L, ' ', L + 1, ' ', R)\n else if L mod 2 = 1\n then write(L + 1, ' ', L + 2, ' ', L + 3)\n else write(L, ' ', L + 1, ' ', L + 2);\nend."}, {"source_code": "Var i,j,k:longint;\n temp,l,r:int64;\nFunction UCLN(a,b:int64):boolean;\nVar temp:int64;\nBegin\n While b>0 do\n begin\n temp:=a mod b;\n a:=b;\n b:=temp;\n end;\n Exit(a=1);\nEnd;\n\nBEGIN\n Readln(l,r);\n If r-l+1<3 then\n begin\n writeln(-1);\n halt;\n end;\n temp:=r-l+1;\n For i:=1 to temp-2 do\n For j:=i+1 to temp-1 do\n For k:=j+1 to temp do\n If (UCLN(i+l-1,j+l-1)) and (UCLN(j+l-1,k+l-1)) and (not(UCLN(i+l-1,k+l-1))) then\n begin\n writeln(i+l-1,' ',j+l-1,' ',k+l-1);\n halt;\n end;\n Writeln(-1);\n\nEND."}, {"source_code": "\n\n var l : int64;\n r : int64;\n a : int64;\n b : int64;\n c : int64;\n i : longint;\n j : longint;\n k : longint;\n function UCLN(a, b : int64): int64;\nvar r:int64;\nBegin\n while b <> 0 do\n begin\n r := a mod b;\n a := b;\n b := r;\n end;\n UCLN := a;\nEnd;\nfunction ntcn(a ,b : int64): boolean;\nbegin\n exit(ucln(a,b)=1);\nend;\n begin\n readln(l,r);\n if r-l+1<3 then\n begin\n writeln(-1);\n halt;\n end;\n a:=l;\n for i:=0 to r-l do\n begin\n a:=a+i;\n b:=a;\n j:=1;\n While b+j<=r do\n begin\n c:=b;\n k:=1;\n while c+k<=r do\n begin\n if (ntcn(a,b+j)=true) and (ntcn(a,c+k)=false) and (ntcn(b+j,c+k)=true) then\n begin\n writeln(a,' ',b+j,' ',c+k);\n halt;\n end;\n k:=k+1;\n end;\n j:=j+1;\n end;\n end;\n writeln(-1);\n end.\n\n\n\n\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n x,y,z:qword; a,b,c,d:qword;\nFunction uc(x,y:int64):boolean;\nvar\ntam:qword;\nBegin\nWhile y<>0 do\n Begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n End;\nIf x=1 then exit(true);\nexit(false);\nEnd;\n\nBegin\nAssign(input,fi);\nReset(input);\nAssign(output,fo);\nRewrite(output);\nReadln(input,x,y); d:=0;\na:=x-1;\nWhile a 0 do\n begin\n z := x mod y;\n x := y;\n y := z;\n end;\n if x = 1 then\n gcd := true\n else gcd := false;\nend;\nbegin\n readln(l, r);\n for i := 0 to r - l - 2 do\n for j := i + 1 to r - l - 1 do\n for k := j + 1 to r - l do\n if gcd(i + l, j + l) and gcd(j + l, k + l) and not gcd(i + l, k + l) then\n begin\n writeln(i + l, ' ', j + l, ' ', k + l);\n exit;\n end;\n writeln('-1');\nend."}, {"source_code": "{CodeForces #275 Div2 A}\nconst fin='';\n fout='';\nvar l,r,res1,res2,res3:qword;\n f,g:text;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,l,r);\n if r-l+1 < 3 then\n begin\n write(g,-1);\n exit;\n end;\n if r-l+1=3 then\n begin\n res1:=l\n end;\n if l mod 2 = 0 then\n begin\n res1:=l;\n res2:=l+1;\n res3:=l+2;\n end\n else\n begin\n res1:=l+1;\n res2:=l+2;\n res3:=l+3;\n if res3 > r then\n begin\n write(g,-1);\n close(g);\n exit;\n end;\n end;\n write(g,res1,' ',res2,' ',res3);\n close(f); close(g);\nend.\n"}, {"source_code": "var\nl,r:int64;\nbegin\nreadln(l,r);\nif l mod 2 <>0 then inc(l);\nif (l+2>r) then writeln(-1)\nelse\nwriteln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "{$mode objfpc}\n\nconst\n inputfile='';\n outputfile='';\n\nvar\n fi,fo:text;\n l,r:int64;\nprocedure openf;\nbegin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\nend;\n\nprocedure input;\nbegin\n readln(fi,l,r);\nend;\n\nfunction gcd(a,b:int64):int64;\nvar\n rr:int64;\n\nbegin\n while b<>0 do\n begin\n rr:=a mod b;\n a:=b;\n b:=rr;\n end;\n exit(a);\nend;\n\nprocedure process;\nbegin\n if r-l<2 then\n begin\n write(fo,-1);\n exit;\n end;\n if l mod 2 = 0 then\n write(fo,l,' ',l+1,' ',l+2);\n if l mod 2 = 1 then\n begin\n if r-l=2 then\n if gcd(l,r)<>1 then write(fo,l,' ',l+1,' ',l+2) else write(fo,-1);\n if r-l>2 then write(fo,l+1,' ',l+2,' ',l+3);\n end;\nend;\n\nprocedure output;\nbegin\nend;\n\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}], "negative_code": [{"source_code": "program ZAD_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l,r,i,j,k:int64;\nfunction nod(a,b:int64):int64;\nbegin\n if (b=0) then nod:=a\n else nod:=nod(b,a mod b);\nend;\nbegin\n readln(l,r);\n i:=l;\n while i<=r do\n begin\n j:=l;\n while j<=r do\n begin\n k:=l;\n while k<=r do\n begin\n if (i<>j) and (i<>k) and (j<>k) and (nod(i,j)=1) and (nod(j,k)=1) and (nod(i,k)<>1) then\n begin\n writeln(i,' ',j,' ',k);\n readln;\n halt;\n end;\n inc(k);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\n readln;\nend.\n"}, {"source_code": "var l,r:longint;\nbegin\n readln(l,r);\n if l=r then\n begin\n writeln(-1); exit;\n end;\n if l mod 2=0 then write(l+1,' ') else write(l,' '); inc(l);\n if l>r then\n begin\n writeln(-1); exit;\n end;\n if l mod 3=0 then write(l+1,' ') else write(l,' ');inc(l);\n if l>r then\n begin\n writeln(-1); exit;\n end;\n if l mod 5=0 then write(l+1,' ') else write(l,' ');\nend."}, {"source_code": "VAR i,j,u,l,r:int64;\nFunction nod(a,b:int64):int64;\nbegin\nwhile (a>0) and (b>0) do\n\n if b>a then b:=b mod a\n else a:=a mod b;\n nod:=a+b;\nend;\nBEGIN\nreadln(l,r);\ni:=l;\nj:=i+1;\nu:=j+1;\nif r-l=1 then write('-1');\nwhile i<=r-2 do begin\n while j<=r-1 do begin\n while u<=r do begin\n if (nod(i,j)=1) and (nod(i,u)<>1) and (nod(j,u)=1) then begin\n writeln(i,' ',j,' ',u);\n exit;\n end;\n if (i=r-2) and (j=r-1) and (u=r) then begin\n write('-1');\n exit;\n end;\n inc(u);\n end;\n inc(j);\n end;\n inc(i);\nend;\nEND."}, {"source_code": "var l,r,x,y,z:int64;\nfunction ncd(a,b:int64):int64;\n begin\n if a<>0 then ncd:=ncd(b mod a,a) else ncd:=b;\n end;\nbegin\n read(l,r);\n if r-l+1<3 then writeln(-1) else begin\n while l<=r-2 do begin\n x:=l+1;\n while x<=r-1 do begin\n y:=x+1;\n while y<=r do begin\n if not((ncd(l,x)=1)and(ncd(l,y)=1)and(ncd(x,y)=1)) then begin\n writeln(l,' ',x,' ',y);\n exit;\n end;\n inc(y);\n end;\n\n inc(x);\n end;\n inc(l);\n end;\n writeln(-1);\n end;\n\n\n\nend."}, {"source_code": "var i,j,t:longint;\n x,l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n begin\n if l+i>r then break;\n l:=l+i;\n for j:=i+1 to 49 do\n begin\n if l+j>r then break;\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n begin\n if l+t>r then break;\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\n end;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "var a,b:int64;\nfunction xuat(l,r:int64):int64;\nbegin\n if (r-l<=1) or ((r-l<=2) and (l mod 2<>0)) then exit(-1);\n if (l mod 2=0) then\n begin\n writeln(l,' ',l+1,' ',l+2);\n exit;\n end\n else\n begin\n writeln(l+1,' ',l+2,' ',l+3);\n exit;\n end;\nend;\nbegin\n readln(a,b);\n writeln(xuat(a,b));\nend.\n"}, {"source_code": "CONST fi = '';\n fo = '';\nVAR l, r, a, b, c : int64;\nFUNCTION UCLN(i,j : int64) : boolean;\n Var r : int64;\n Begin\n while i <> 0 do\n begin\n r := j mod i;\n j := i;\n i := r;\n end;\n if j = 1 then UCLN := true else UCLN := false;\n End;\nPROCEDURE COPRIME(l,r : int64);\n Var i, j : int64;\n Begin\n c := 0;\n i := l;\n while (i <= r) and (c = 0) do\n begin\n a := 0;\n j := i+1;\n while (j <= r) and (a = 0) do\n if UCLN(i,j) = true then\n begin\n a := i;\n b := j;\n end\n else j := j + 1;\n j := j + 1;\n while (j <= r) and (c = 0) do\n if UCLN(a,j) = false then c := j\n else j := j + 1;\n i := i + 1;\n end;\n End;\nPROCEDURE PROCESS;\n Var f1, f2 : text;\n Begin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n readln(f1,l,r);\n COPRIME(l,r);\n if c <> 0 then write(f2,a,' ',b,' ',c)\n else write(f2,'-1');\n close(f1); close(f2);\n End;\nBEGIN\n PROCESS;\nEND.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n f,g:text;\n a,b,c:int64;\n\nbegin\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,a,b);\n if (b-a+1>3) and (b-a<=50) then\n begin\n if a mod 2= 0 then\n begin\n writeln(g,a,' ',a+1,' ',a+2);\n end\n else\n begin\n writeln(g,a+1,' ',a+2,' ',a+3);\n end;\n end;\n if (b-a+1=3) and (a mod 2=0) then writeln(g,a,' ',a+1,' ',a+2)\n else write(g,'-1');\n close(f); close(g);\nend."}, {"source_code": "var a,b:int64;\n begin\n read(a,b);\n if b-a>=3 then write(a,' ',a+1,' ',a+2)\n else write(-1);\n end."}, {"source_code": "var l,r:int64;\nbegin\n read(l,r);\n if (r-l>=3) and (l mod 2=0) then\n write(l,' ',l+1,' ',l+2);\n if (r-l>=3) and (l mod 2=1) then\n write(l+1,' ',l+2,' ',l+3)\n else\n begin\n if (r-l=2) and (l mod 2=0) then\n write(l,' ',l+1,' ',l+2)\n else write(-1);\n end;\nend."}, {"source_code": "var a,b,c,l,r:int64;\nfunction nod(a1,b1:int64):int64;\n begin\n while (a1>0) and (b1>0) do\n if a1>b1 then a1:=a1 mod b1\n else b1:=b1 mod a1;\n nod:=a1+b1;\n end;\nbegin\nreadln(l,r);\na:=l;\nb:=l;\nc:=l;\nwhile a<=r do \n begin\n while b<=r do \n begin \n while c<=r do \n begin\n if (nod(a,b)=1) and (nod(b,c)=1) and (nod(a,c)<>1) and (a<>b) and (b<>c) and (a<>c) then begin write(a,' ',b,' ',c); halt; end;\n inc(c);\n end;\n inc(b);\n c:=l;\n end;\n inc(a);\n b:=l;\n end;\nwrite(-1);\nend."}, {"source_code": "var l,r:longint;\nbegin\n readln(l,r);\n if l=r then\n begin\n writeln(-1); exit;\n end;\n if l mod 2=0 then write(l+1,' ') else write(l,' '); inc(l);\n if l>r then\n begin\n writeln(-1); exit;\n end;\n if l mod 3=0 then write(l+1,' ') else write(l,' ');inc(l);\n if l>r then\n begin\n writeln(-1); exit;\n end;\n if l mod 5=0 then write(l+1,' ') else write(l,' ');\nend."}, {"source_code": "Var s1,s2,s3,x,y,z,l,n,r:Int64;\n i,j,k:LongInt;\n Begin\n Read(l,r);\n for i:=l to r-2 do\n for j:=i+1 to r-1 do\n for k:=j+1 to r do\n begin\n x:=i;\n y:=j;\n z:=k;\n While (x<>0) and (y<>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n s1:=x+y;\n x:=i;\n y:=j;\n While (y<>0) and (z<>0) do\n if y>z then y:=y mod z\n else z:=z mod y;\n s2:=y+z;\n y:=j;\n z:=k;\n While(x<>0) and (z<>0) do\n if x>z then x:=x mod z\n else z:=z mod x;\n s3:=x+3;\n if (s1=1) and (s2=1) and (s3<>1) then begin Write(i,' ',j,' ',k); exit; end;\n end;\n End."}, {"source_code": "{CodeForces #275 Div2 A}\nconst fin='';\n fout='';\nvar l,r,res1,res2,res3:qword;\n f,g:text;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,l,r);\n if r-l+1 < 3 then\n begin\n write(g,-1);\n exit;\n end;\n if l mod 2 = 0 then\n begin\n res1:=l;\n res2:=l+1;\n res3:=l+2;\n end\n else\n begin\n res1:=l+1;\n res2:=l+2;\n res3:=l+3;\n end;\n write(g,res1,' ',res2,' ',res3);\n close(f); close(g);\nend.\n"}, {"source_code": "var\n i,j,l,r,n,m,k,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nbegin\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\nend;\n\nbegin\n readln(l,r);\n a:=l; b:=l+1; c:=l+2;\n while a1) then\n begin writeln(a,' ',b,' ',c); halt; end;\n end;\n end;\n end;\n writeln(-1);\nend.\n\n"}, {"source_code": "{CodeForces #275 Div2 A}\nconst fin='';\n fout='';\nvar l,r,res1,res2,res3:qword;\n f,g:text;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,l,r);\n if r-l+1 < 3 then\n begin\n write(g,-1);\n exit;\n end;\n if l mod 2 = 0 then\n begin\n res1:=l;\n res2:=l+1;\n res3:=l+2;\n end\n else\n begin\n res1:=l+1;\n res2:=l+2;\n res3:=l+3;\n end;\n write(g,res1,' ',res2,' ',res3);\n close(f); close(g);\nend.\n"}, {"source_code": "uses math;\nvar\n l,r:int64;\nbegin\n read(l,r);\n\n if r-l<2 then begin writeln(-1); halt; end;\n if l mod 2=0 then begin write(l,' ',l+1,' ',l+2); halt; end;\n if (l mod 2=1) and (r-l>3) then begin write(l+1,' ',l+2,' ',l+3); halt; end;\n writeln(-1);\nend."}, {"source_code": "var l,r,i,j,k:int64;\n\nfunction kt1(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a=1);\nend;\n\n\nfunction kt2(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a<>1);\nend;\n\n\nbegin\n readln(l,r);\n i:=l;\n j:=l+1;\n k:=l+2;\n while i<=r-2 do\n begin\n while j<=r-1 do\n begin\n while k<=r do\n begin\n if (kt1(i,j)) and (kt1(j,k)) and (kt2(i,k)) then\n begin\n writeln(i,' ',j,' ',k);\n exit;\n end;\n k:=k+1;\n end;\n j:=j+1;\n end;\n i:=i+1;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var\ni,j,k,l,r:int64;\nfunction gsd(a,b:longint):longint;\nbegin\n while (a>0)and(b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n gsd:=a+b;\nend;\nbegin\nread(l,r);\ni:=l;\nwhile i<=r-2 do\nbegin\nj:=i+1;\nwhile j<=r-1 do\n begin\n k:=j+1;\n while k<=r do\n begin\nif (gsd(i,j)=1)and(gsd(j,k)=1)and(gsd(i,k)<>1) then begin writeln(i,' ',j,' ',k);halt;end;\ninc(k);\nend;\ninc(j);\nend;\ninc(i);\nend;\nwriteln(-1);\nend."}, {"source_code": "var l,r,i,n,a,b,c,j,t,u:int64;\nfunction gcd(var a,b:int64):int64;\n var o,p:int64;\n begin\n o:=a;\n p:=b;\n while (o*p<>0) do begin\n if o>p then o:=o mod p else p:=p mod o;\n end;\n gcd:=o+p;\n end;\nbegin\nreadln(l,r);\nif r-l<2 then writeln(-1) else begin\n a:=l;\n b:=a+1;\n c:=b+1;\n t:=gcd(a,b);\n u:=gcd(b,c);\n if (t<>1) and (u<>1) then begin\n while (c<>r) do begin\n inc(a);\n inc(b);\n inc(c);\n t:=gcd(a,b);\n u:=gcd(b,c);\n if (t=1) and (u=1) then begin write(a,' ',b,' ',c); break; end;\n writeln(-1);\n end;\n end\n else\n writeln(a,' ',b,' ',c);\nend;\nend."}, {"source_code": " var i,j,a,b,x,y,k : int64;\nbegin\n readln(a,b);\n k:=a;\n while 1=1 do\n begin a:=k;\n if b-a<2 then begin writeln('-1'); exit end;\n if a mod 2=0 then\n begin x:=a; y:=a+1; a:=a+2 end else begin x:=a+1; y:=a; a:=a+3 end;\n while a<=b do\n begin\n i:=y; j:=a;\n while (i<>0)and(j<>0) do\n if i>j then i:=i mod j else j:=j mod i;\n if (i+j=1) then begin\n if x>y then writeln(y,' ',x,' ',a) else writeln(x,' ',y,' ',a); exit end;\n inc(a,2);\n end;\n inc(k);\n end;\nend."}, {"source_code": "var l,r:int64;\nbegin\nread(r,l);\nif l-r<2 then write(-1) else write(r,' ',r+1,' ',r+2);\nend."}, {"source_code": "var i,j,t:longint;\n l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n for j:=i+1 to 49 do\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\n writeln(-1);\nend."}, {"source_code": "var\ni,j,k,l,r:int64;\nfunction gsd(a,b:longint):longint;\nbegin\n while (a>0)and(b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n gsd:=a+b;\nend;\nbegin\nread(l,r);\ni:=l;\nwhile i<=r-2 do\nbegin\nj:=i+1;\nwhile j<=r-1 do\n begin\n k:=j+1;\n while k<=r do\n begin\nif (gsd(i,j)=1)and(gsd(j,k)=1)and(gsd(i,k)<>1) then begin writeln(i,' ',j,' ',k);halt;end;\ninc(k);\nend;\ninc(j);\nend;\ninc(i);\nend;\nwriteln(-1);\nend."}, {"source_code": "var i,j,t:longint;\n x,l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n begin\n if l+i>r then break;\n l:=l+i;\n for j:=i+1 to 49 do\n begin\n if l+j>r then break;\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n begin\n if l+t>r then break;\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\n end;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "{CodeForces #275 Div2 A}\nconst fin='';\n fout='';\nvar l,r,res1,res2,res3:qword;\n f,g:text;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,l,r);\n if r-l+1 < 3 then\n begin\n write(g,-1);\n exit;\n end;\n if l mod 2 = 0 then\n begin\n res1:=l;\n res2:=l+1;\n res3:=l+2;\n end\n else\n begin\n res1:=l+1;\n res2:=l+1;\n res3:=l+3;\n end;\n write(g,res1,' ',res2,' ',res3);\n close(f); close(g);\nend.\n"}, {"source_code": "Var s1,s2,s3,x,y,z,l,n,r:Int64;\n i,j,k:LongInt;\n Begin\n Read(l,r);\n for i:=l to r-2 do\n for j:=i+1 to r-1 do\n for k:=j+1 to r do\n begin\n x:=i;\n y:=j;\n z:=k;\n While (x<>0) and (y<>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n s1:=x+y;\n x:=i;\n y:=j;\n While (y<>0) and (z<>0) do\n if y>z then y:=y mod z\n else z:=z mod y;\n s2:=y+z;\n y:=j;\n z:=k;\n While(x<>0) and (z<>0) do\n if x>z then x:=x mod z\n else z:=z mod x;\n s3:=x+3;\n if (s1=1) and (s2=1) and (s3<>1) then begin Write(i,' ',j,' ',k); exit; end;\n end;\n End."}, {"source_code": "var l, r, z: int64;\n i, j, k: byte;\nfunction gcd(x, y: int64): boolean;\nvar z: int64;\nbegin\n while y > 0 do\n begin\n z := x mod y;\n x := y;\n y := z;\n end;\n if x = 1 then\n gcd := true\n else gcd := false;\nend;\nbegin\n readln(l, r);\n for i := 0 to r - l - 2 do\n for j := i + 1 to r - l - 1 do\n for k := j + 1 to r - l do\n if gcd(i + l, j + l) and gcd(j + l, k + l) and not gcd(i + l, k + l) then\n begin\n writeln(i + l, ' ', j + l, ' ', k + l);\n exit;\n end;\n writeln('-1');\nend."}, {"source_code": "var \nl,r:int64; i:longint;\nbegin\n read(l,r);\n if (r-l>2)or((l-r=2)and(l mod 2 = 0)) then\n begin\n if (l mod 2 = 1) then inc(l); \n for i:=0 to 2 do\n write(i+l,' ') \n end else\n write('-1');\nend."}, {"source_code": "{CodeForces #275 Div2 A}\nconst fin='';\n fout='';\nvar l,r,res1,res2,res3:qword;\n f,g:text;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,l,r);\n if r-l+1 < 3 then\n begin\n write(g,-1);\n exit;\n end;\n if l mod 2 = 0 then\n begin\n res1:=l;\n res2:=l+1;\n res3:=l+2;\n end\n else\n begin\n res1:=l+1;\n res2:=l+1;\n res3:=l+3;\n end;\n write(g,res1,' ',res2,' ',res3);\n close(f); close(g);\nend.\n"}, {"source_code": "{$mode objfpc}\n\nconst\n inputfile='';\n outputfile='';\n\nvar\n fi,fo:text;\n l,r:int64;\nprocedure openf;\nbegin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\nend;\n\nprocedure input;\nbegin\n readln(fi,l,r);\nend;\n\nfunction gcd(a,b:int64):int64;\nvar\n rr:int64;\n\nbegin\n while b<>0 do\n begin\n rr:=a mod b;\n a:=b;\n b:=rr;\n end;\n exit(a);\nend;\n\nprocedure process;\nbegin\n if r-l<2 then\n begin\n write(fo,-1);\n exit;\n end;\n if l mod 2 = 0 then\n write(fo,l,' ',l+1,' ',l+2);\n if l mod 2 = 1 then\n begin\n if r-l=2 then\n if gcd(l,r)=1 then write(fo,l,' ',l+1,' ',l+2) else write(fo,-1);\n if r-l>2 then write(fo,l+1,' ',l+2,' ',l+3);\n end;\nend;\n\nprocedure output;\nbegin\nend;\n\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}, {"source_code": "CONST fi = '';\n fo = '';\nVAR l, r, a, b, c : int64;\nFUNCTION UCLN(i,j : int64) : boolean;\n Var r : int64;\n Begin\n while i <> 0 do\n begin\n r := j mod i;\n j := i;\n i := r;\n end;\n if j = 1 then UCLN := true else UCLN := false;\n End;\nPROCEDURE COPRIME(l,r : int64);\n Var i, j : int64;\n Begin\n c := 0;\n i := l;\n while (i <= r) and (c = 0) do\n begin\n a := 0;\n j := i+1;\n while (j <= r) and (a = 0) do\n if UCLN(i,j) = true then\n begin\n a := i;\n b := j;\n end\n else j := j + 1;\n j := j + 1;\n while (j <= r) and (c = 0) do\n if UCLN(a,j) = false then c := j\n else j := j + 1;\n i := i + 1;\n end;\n End;\nPROCEDURE PROCESS;\n Var f1, f2 : text;\n Begin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n readln(f1,l,r);\n COPRIME(l,r);\n if c <> 0 then write(f2,a,' ',b,' ',c)\n else write(f2,'-1');\n close(f1); close(f2);\n End;\nBEGIN\n PROCESS;\nEND.\n"}, {"source_code": "var a,b:int64;\n begin\n read(a,b);\n if b-a>3 then write(a,a+1,a+2)\n else write(-1);\n end."}, {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n\nvar\n fi,fo:Text;\n r,l:int64;\n\nfunction ucln(x,y:int64):int64;\n begin\n if x=0 then exit(y);\n ucln:=ucln(y mod x,x);\n end;\n\nprocedure xuli;\n var i,n:longint;\n begin\n readln(fi,l,r);\n n:=r-l;\n if n>1 then\n for i:=1 to n do\n if (ucln(l,l+i)=1) and (ucln(l+i,r)=1) then\n begin\n writeln(fo,l,' ',l+i,' ',r);\n exit;\n end;\n writeln(fo,-1);\n end;\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n"}, {"source_code": "var\n i,j,l,r,n,m,k,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nbegin\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\nend;\n\nbegin\n readln(l,r);\n a:=l; b:=l+1; c:=l+2;\n while a1) then\n begin writeln(a,' ',b,' ',c); halt; end;\n end;\n end;\n end;\n writeln(-1);\nend.\n\n"}, {"source_code": "uses math;\nvar a,b,c,cc:array [1..10000] of longint;\ni,j,l,r,z:int64;\n n,m:int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y,xx: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n xx:=b[(l+r) div 2];\n repeat\n while (a[i]xx)) do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0) and (y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if (x+y)=1 then exit(true) else exit(false);\n end;\n\n begin\n readln(l,r);\n i:=l;\n while (i<=r) do\n begin\n j:=l;\n while (j<=r) do\n begin\n z:=l;\n while (z<=r) do\n begin\n if (i<>j) and (i<>z) and (j<>z) then\n if (prov(i,j)) and (prov(j,z)) and (not(prov(i,z))) then\n begin\n writeln(i,' ',j,' ',z);\n halt;\n end;\n inc(Z);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\n\n end."}, {"source_code": "var a:array[1..50] of qword;\n l,r:qword;\n i,j,t:longint;\n res1,res2,res3:qword;\n\nfunction ucln(a,b:qword):qword;\nvar du:qword;\nbegin\n repeat\n du:=a mod b;\n a:=b;\n b:=du;\n until b=0;\n exit(a);\nend;\n\n\nbegin\n read(l,r);\n if r-l+1 < 3 then write(-1)\n else\n begin\n for i:=0 to r-l do a[i+1]:=l+i;\n for i:=1 to r-l+1 do\n for j:=i to r-l+1 do\n if ucln(a[i],a[j]) = 1 then\n for t:=j to r-l+1 do\n if ucln(a[j],a[t]) = 1 then\n if ucln(a[i],a[t]) <> 1 then\n begin\n res1:=a[i];\n res2:=a[j];\n res3:=a[t];\n break\n end;\n write(res1,' ',res2,' ',res3);\n end;\nend."}, {"source_code": "var\n\tl,r,a,b,c:int64;\nfunction gcd(x,y:int64):int64;\nvar r:int64;\nbegin\n if x0 do\n\tbegin\n\t x:=y;\n\t\ty:=r;\n\t\tr:=x mod y;\n\tend;\n\texit(y);\nend;\n\nbegin\n read(l,r);\n\tif r-l<=1 then begin write(-1); halt; end;\n\tb:=l;\n\twhile b<=r do\n\tbegin\n\t a:=l;\n\t while a<=r do\n\t begin\n\t c:=l;\n\t\twhile c<=r do\n\t\tbegin\n\t if (a<>b)and(b<>c)and(a<>c)and(gcd(a,b)=1)and(gcd(b,c)=1)and(gcd(a,c)<>1) then begin write(a,' ',b,' ',c); halt; end;\n\t\tc:=c+1;\n\t\tend;\n\t\ta:=a+1;\n\t end;\n\t b:=b+1;\n\tend;\n\twrite(-1);\nend.\n"}, {"source_code": "\nVAR l, r: int64;\n\nPROCEDURE input;\nVAR fi: TEXT;\nBEGIN\n\n readln( l, r);\n \nEND;\n\nFUNCTION UCLN(x, y: int64): int64;\nBEGIN\n IF x MOD y = 0 THEN UCLN:= y ELSE UCLN:= UCLN(y, x MOD y);\nEND;\n\nFUNCTION check(x, y: int64): BOOLEAN;\nBEGIN\n IF ucln(x, y) = 1 THEN exit(TRUE) ELSE exit(FALSE);\nEND;\n\nPROCEDURE proc;\nVAR fo: TEXT;\n i, j, k: BYTE;\n m: int64;\nBEGIN \n input;\n \n m:= r - l;\n FOR i:= 0 TO m - 2 DO\n FOR j:= i + 1 TO m - 1 DO\n FOR k:= j + 1 TO m DO\n IF check(i + l, j + l) AND check(j + l, k + l) AND NOT(check(i + l, k + l)) THEN\n BEGIN\n write(i + l, ' ', j + l, ' ', k + l);\n \n exit;\n END;\n write( '-1');\n \nEND; \n\nBEGIN\n proc;\nEND."}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483A.inp';\n Fo ='';//483A.out';\nVar\n L,R :longint;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If L mod 2 = 0 then write(L,' ',L+1,' ',L+2)\n else Write(L+1,' ',L+2,' ',L+3);\nEnd.\n"}, {"source_code": "CONST fi = '';\n fo = '';\nVAR l, r, a, b, c : int64;\nFUNCTION UCLN(i,j : int64) : boolean;\n Var r : int64;\n Begin\n while i <> 0 do\n begin\n r := j mod i;\n j := i;\n i := r;\n end;\n if j = 1 then UCLN := true else UCLN := false;\n End;\nPROCEDURE COPRIME(l,r : int64);\n Var i, j : int64;\n Begin\n c := 0;\n i := l;\n while (i <= r) and (c = 0) do\n begin\n a := 0;\n j := i+1;\n while (j <= r) and (a = 0) do\n if UCLN(i,j) = true then\n begin\n a := i;\n b := j;\n end\n else j := j + 1;\n j := j + 1;\n while (j <= r) and (c = 0) do\n if UCLN(a,j) = false then c := j\n else j := j + 1;\n i := i + 1;\n end;\n End;\nPROCEDURE PROCESS;\n Var f1, f2 : text;\n Begin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n readln(f1,l,r);\n COPRIME(l,r);\n if c <> 0 then write(f2,a,' ',b,' ',c)\n else write(f2,'-1');\n close(f1); close(f2);\n End;\nBEGIN\n PROCESS;\nEND.\n"}, {"source_code": "var i,x,a,b,c,l,r,d,kl:int64;\n\nbegin\n readln(l,r);\n if l=1 then\n BEGIN\n a:=1;\n b:=2;\n c:=3;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1)\n END\n ELSE\n BEGIN\n if l mod 2=0 then\n begin\n a:=l;\n b:=l+1;\n c:=l+2;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1)\n end\n else begin\n a:=l;\n x:=trunc(sqrt(l));\n i:=2;\n while i<=x do\n begin\n if a mod i=0 then begin\n kl:=1;\n d:=i;\n break;\n end;\n i:=i+1;\n end;\n if kl=0 then d:=a;\n\n c:=a+d;\n b:=a+2;\n if c<=r then writeln(a,' ',b,' ',c)\n else writeln(-1);\n end;\n END;\nend.\n"}, {"source_code": "\n\n var l : int64;\n r : int64;\n a : int64;\n b : int64;\n c : int64;\n function UCLN(a, b : int64): int64;\nvar r:int64;\nBegin\n while b <> 0 do\n begin\n r := a mod b;\n a := b;\n b := r;\n end;\n UCLN := a;\nEnd;\nfunction ntcn(a ,b : int64): boolean;\nbegin\n exit(ucln(a,b)=1);\nend;\n begin\n readln(l,r);\n if r-l+1<3 then\n begin\n writeln(-1);\n halt;\n end;\n a:=l;\n b:=a;\n Repeat\n b:=b+1;\n c:=b+1;\n While c<=r do\n begin\n if (ntcn(a,c)=false) and (ntcn(b,c)=true) then\n begin\n\n writeln(a,' ',b,' ',c);\n halt;\n end;\n c:=c+1;\n end;\n if b=r then\n begin\n writeln(-1);\n halt;\n end;\n until false;\n\nend.\n"}, {"source_code": "VAR i,j,u,l,r:qword;\nFunction nod(a,b:qword):qword;\nbegin\nwhile (a>0) and (b>0) do\n\n if b>a then b:=b mod a\n else a:=a mod b;\n nod:=a+b;\nend;\nBEGIN\nreadln(l,r);\ni:=l;\nj:=i+1;\nu:=j+1;\nif r-l=1 then write('-1');\nwhile i<=r-2 do begin\n while j<=r-1 do begin\n while u<=r do begin\n if (nod(i,j)=1) and (nod(i,u)<>1) and (nod(j,u)=1) then begin\n writeln(i,' ',j,' ',u);\n break;\n end;\n if (i=r-2) and (j=r-1) and (u=r) then begin\n write('-1');\n exit;\n end;\n inc(u);\n end;\n inc(j);\n end;\n inc(i);\nend;\nEND."}, {"source_code": "var l,r: int64;\n\nBEGIN\n readln(l,r);\n If r-l <2 then writeln(-1)\n Else if r-l = 2 then\n begin\n If l = 1 then writeln(-1)\n Else writeln(l, ' ',l+1, ' ',l+2);\n end\n\n Else\n begin\n If l mod 2 = 0 then writeln(l, ' ',l+1, ' ',l+2)\n Else writeln(l+1, ' ',l+2, ' ',l+3);\n end;\nEND."}, {"source_code": "var l,r,i,j,k:int64;\n\nfunction kt1(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a=1);\nend;\n\n\nfunction kt2(a,b:int64):boolean;\nvar r:int64;\nbegin\n while b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a<>1);\nend;\n\n\nbegin\n readln(l,r);\n i:=l;\n j:=l+1;\n k:=l+2;\n while i<=r-2 do\n begin\n while j<=r-1 do\n begin\n while k<=r do\n begin\n if (kt1(i,j)) and (kt1(j,k)) and (kt2(i,k)) then\n begin\n writeln(i,' ',j,' ',k);\n exit;\n end;\n k:=k+1;\n end;\n j:=j+1;\n end;\n i:=i+1;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var n,m,l,r:int64;\n i,j,k:longint;\nfunction pro(n,m:int64):boolean;\n begin\n while (n>0) and (m>0) do\n if n>m then n:=n mod m else m:=m mod n;\n if (n+m)=1 then exit(true) else exit(false);\n end;\n begin\n read(l,r);\n for i:=l to r do\n for j:=i+1 to r do\n for k:=j+1 to r do\n if (pro(i,j)) and (pro(j,k)) and not(pro(i,k)) then begin writeln(i,' ',j,' ',k); halt; end;\n writeln('-1');\n end."}, {"source_code": "var l,r:int64;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then writeln(-1)\n else writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n\nvar\n fi,fo:Text;\n x,y:int64;\n\nprocedure xuli;\n begin\n readln(fi,x,y);\n if y-x<2 then writeln(fo,-1)\n else\n if x mod 2=0 then writeln(fo,x,' ',x+1,' ',x+2) else writeln(fo,x+1,' ',x+2,' ',x+3);\n end;\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n"}, {"source_code": "program A4;\nvar\n l,r,a,b,c:int64;\nbegin\n readln(l,r);\n if r-l<=1\n then\n begin\n writeln('-1');\n exit;\n end;\n writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "{$mode objfpc}\n\nconst\n inputfile='';\n outputfile='';\n\nvar\n fi,fo:text;\n l,r:int64;\nprocedure openf;\nbegin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\nend;\n\nprocedure input;\nbegin\n readln(fi,l,r);\nend;\n\nfunction gcd(a,b:int64):int64;\nvar\n rr:int64;\n\nbegin\n while b<>0 do\n begin\n rr:=a mod b;\n a:=b;\n b:=rr;\n end;\n exit(a);\nend;\n\nprocedure process;\nbegin\n if (l=1) and (r=3) then\n begin\n write(fo,1,' ',2,' ',3);\n exit;\n end;\n if r-l<2 then\n begin\n write(fo,-1);\n exit;\n end;\n if l mod 2 = 0 then\n write(fo,l,' ',l+1,' ',l+2);\n if l mod 2 = 1 then\n begin\n if r-l=2 then\n if gcd(l,r)=1 then write(fo,l,' ',l+1,' ',l+2) else write(fo,-1);\n if r-l>2 then write(fo,l+1,' ',l+2,' ',l+3);\n end;\nend;\n\nprocedure output;\nbegin\nend;\n\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar l,r,a,b,c:int64;\nprocedure nhap;\nvar f:Text;\nbegin\n assign(f,finp);\n reset(f);\n read(f,l,r);\n close(f);\nend;\nfunction ucln(x,y:int64):int64;\nvar r:int64;\nbegin\n repeat\n r:=x mod y;\n x:=y;\n y:=r;\n until r=0;\n ucln:=x;\nend;\nprocedure timso;\nvar i,j,k:int64;\n lc:boolean;\nbegin\n lc:=false;\n a:=-1; b:=-1; c:=-1;\n i:=l;\n while i<=r-1 do\n begin\n j:=r;\n while j>=i+1 do\n begin\n k:=ucln(i,j);\n if k<>1 then\n begin\n a:=i;\n c:=j;\n lc:=true;\n break;\n end;\n dec(j);\n end;\n if lc=true then\n break;\n inc(i);\n end;\n i:=a+1;\n while i<=c-1 do\n begin\n if (a mod i<>0) and (c mod i<>0) then\n begin\n b:=i;\n break;\n end;\n inc(i);\n end;\nend;\nprocedure xuat;\nvar f:Text;\nbegin\n assign(f,fout);\n rewrite(f);\n if (a<>-1) and (b<>-1) and (c<>-1) then\n write(f,a,' ',b,' ',c)\n else\n write(f,-1);\n close(f);\nend;\nbegin\n nhap;\n timso;\n xuat;\nend."}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483.inp';\n Fo ='';//483.out';\n//\nVar\n L,R :int64;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If ((L-R+1)<=2) or ((L-R+1=3) and (L mod 2 = 0)) then Write(-1)\n Else\n If (L mod 2 = 0) then Write(L+1,' ',L+2,' ',L+3)\n Else Write(L,' ',L+1,' ',L+2);\nEnd."}, {"source_code": "var a,b:int64;\n begin\n read(a,b);\n if b-a>3 then write(a,a+1,a+2)\n else write(-1);\n end."}, {"source_code": "type arr=array[1..19]of integer;\n{const fi='checking.inp';\n fo='checking.out';}\n\nvar d,c,a1,a2,a3,kq:arr;\n l,r:string;\n m,n,lg:longint;\n{------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;}\n{------------------------------}\n{procedure closefiles;\nbegin\n close(input);close(output);\nend;}\n{-------------------------}\nprocedure stdin;\nvar i:longint;\nbegin\n readln(l);\n r:=copy(l,pos(' ',l)+1,length(l)-pos(' ',l));\n delete(l,pos(' ',l),length(l)-pos(' ',l)+1);\n\n m:=length(l);\n n:=length(r);\n for i:=m downto 1 do\n d[m-i+1]:=ord(l[i])-ord('0');\n for i:=n downto 1 do\n c[n-i+1]:=ord(r[i])-ord('0');\nend;\n{-------------------------------------}\nprocedure tru;\nvar i:longint;\nbegin\n for i:=1 to n do\n begin\n kq[i]:=c[i]-d[i];\n if kq[i]<0 then\n begin\n kq[i]:=kq[i]+10;\n c[i+1]:=c[i+1]-1;\n end;\n\n end;\n\n lg:=n;\n if kq[n]=0 then dec(lg);\nend;\n{-------------------------------------}\nfunction nhohon:boolean;\nbegin\n if (lg=1) and (kq[1]<3) then exit(true);\n exit(false);\nend;\n{-------------------------------------------}\nfunction nhohonbang:boolean;\nvar i:longint;\nbegin\n for i:=n+1 downto 1 do\n if a3[i]>c[i] then exit(false);\n exit(true);\nend;\n{----------------------------------------}\nprocedure cong(x:longint;var a:arr);\nvar i,nho:longint;\nbegin\n nho:=x;\n for i:=1 to m+1 do\n begin\n a[i]:=(d[i]+nho);\n nho:=a[i] div 10;\n a[i]:=a[i] mod 10;\n end;\nend;\n{-----------------------------------------}\nprocedure print;\nvar i:longint;\nbegin\n for i:=n downto 1 do\n write(a1[i]);\n write(' ');\n for i:=n downto 1 do\n write(a2[i]);\n write(' ');\n for i:=n downto 1 do\n write(a3[i]);\nend;\n{-----------------------------------------}\n\nprocedure process;\nbegin\n if nhohon then\n begin\n writeln('-1');\n exit;\n end;\n if (d[1] mod 2=0) then\n begin\n cong(0,a1);\n cong(1,a2);\n cong(2,a3);\n end\n else\n begin\n cong(1,a1);\n cong(2,a2);\n cong(3,a3);\n end;\n\n if nhohonbang then print else writeln('-1');\n\n\n\nend;\n{------------------------------------}\nBEGIN\n {openfiles; }\n stdin;\n process;\n {closefiles;}\nEND.\n"}, {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n\nvar\n fi,fo:Text;\n x,y:int64;\n\nprocedure xuli;\n begin\n readln(fi,x,y);\n if y-x<2 then writeln(fo,-1)\n else\n if x mod 2=0 then writeln(fo,x,' ',x+1,' ',x+2) else writeln(fo,x+1,' ',x+2,' ',x+3);\n end;\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n"}, {"source_code": "{$mode objfpc}\n\nconst\n inputfile='';\n outputfile='';\n\nvar\n fi,fo:text;\n l,r:int64;\nprocedure openf;\nbegin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\nend;\n\nprocedure input;\nbegin\n readln(fi,l,r);\nend;\n\nfunction gcd(a,b:int64):int64;\nvar\n rr:int64;\n\nbegin\n while b<>0 do\n begin\n rr:=a mod b;\n a:=b;\n b:=rr;\n end;\n exit(a);\nend;\n\nprocedure process;\nbegin\n if r-l<2 then\n begin\n write(fo,-1);\n exit;\n end;\n if l mod 2 = 0 then\n write(fo,l,' ',l+1,' ',l+2);\n if l mod 2 = 1 then\n begin\n if r-l=2 then\n if gcd(l,r)=1 then write(fo,l,' ',l+1,' ',l+2) else write(fo,-1);\n if r-l>2 then write(fo,l+1,' ',l+2,' ',l+3);\n end;\nend;\n\nprocedure output;\nbegin\nend;\n\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483A.inp';\n Fo ='';//483A.out';\nVar\n L,R :longint;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If L mod 2 = 0 then write(L,' ',L+1,' ',L+2)\n else Write(L+1,' ',L+2,' ',L+3);\nEnd.\n"}, {"source_code": "Var x1,k,x,y,l,r,n:Qword;\n i:longint;\n Begin\n Read(l,r);\n x1:=l;\n k:=1;\n While k=1 do\n begin\n inc(l);\n if l>r then begin Write(-1); exit; end;\n x:=x1;\n y:=l;\n While (x>0) and (y>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n k:=x+y;\n x:=x1;\n end;\n Write(x,' ',x+1,' ',l);\n End."}, {"source_code": "var\n i,j,l,r,n,m,k,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nbegin\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\nend;\n\nbegin\n readln(l,r);\n a:=l-1; b:=l; c:=l+1;\n while a1) then\n begin writeln(a,' ',b,' ',c); halt; end;\n end;\n end;\n end;\n writeln(-1);\nend.\n\n"}, {"source_code": "CONST fi = '';\n fo = '';\nVAR l, r, a, b, c : int64;\nFUNCTION UCLN(i,j : int64) : boolean;\n Var r : int64;\n Begin\n while i <> 0 do\n begin\n r := j mod i;\n j := i;\n i := r;\n end;\n if j = 1 then UCLN := true else UCLN := false;\n End;\nPROCEDURE COPRIME(l,r : int64);\n Var i, j : int64;\n Begin\n c := 0;\n i := l;\n while (i <= r) and (c = 0) do\n begin\n a := 0;\n j := i+1;\n while (j <= r) and (a = 0) do\n if UCLN(i,j) = true then\n begin\n a := i;\n b := j;\n end\n else j := j + 1;\n j := j + 1;\n while (j <= r) and (c = 0) do\n if UCLN(a,j) = false then c := j\n else j := j + 1;\n i := i + 1;\n end;\n End;\nPROCEDURE PROCESS;\n Var f1, f2 : text;\n Begin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n readln(f1,l,r);\n COPRIME(l,r);\n if c <> 0 then write(f2,a,' ',b,' ',c)\n else write(f2,'-1');\n close(f1); close(f2);\n End;\nBEGIN\n PROCESS;\nEND.\n"}, {"source_code": "var\n i,j,l,r,n,m,k,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nbegin\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\nend;\n\nbegin\n readln(l,r);\n a:=l; b:=l; c:=l;\n while a1) then\n begin writeln(a,' ',b,' ',c); halt; end;\n end;\n c:=l;\n end;\n b:=l;\n end;\n writeln(-1);\nend.\n\n"}, {"source_code": "VAR i,j,u,l,r:qword;\nFunction nod(a,b:qword):qword;\nbegin\nwhile (a>0) and (b>0) do\n\n if b>a then b:=b mod a\n else a:=a mod b;\n nod:=a+b;\nend;\nBEGIN\nreadln(l,r);\ni:=l;\nj:=i+1;\nu:=j+1;\nif r-l=1 then write('-1');\nwhile i<=r-2 do begin\n while j<=r-1 do begin\n while u<=r do begin\n if (nod(i,j)=1) and (nod(i,u)<>1) and (nod(j,u)=1) then begin\n writeln(i,' ',j,' ',u);\n exit;\n end;\n if (i=r-2) and (j=r-1) and (u=r) then begin\n write('-1');\n exit;\n end;\n inc(u);\n end;\n inc(j);\n end;\n inc(i);\nend;\nEND."}, {"source_code": "uses math;\nvar a,b,c,cc:array [1..10000] of longint;\ni,j,l,r,z:int64;\n n,m:int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y,xx: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n xx:=b[(l+r) div 2];\n repeat\n while (a[i]xx)) do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0) and (y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n if (x+y)=1 then exit(true) else exit(false);\n end;\n\n begin\n readln(l,r);\n i:=l;\n while (i<=r) do\n begin\n j:=l;\n while (j<=r) do\n begin\n z:=l;\n while (z<=r) do\n begin\n if (i<>j) and (i<>z) and (j<>z) then\n if (prov(i,j)) and (prov(j,z)) and (not(prov(i,z))) then\n begin\n writeln(i,' ',j,' ',z);\n halt;\n end;\n inc(Z);\n end;\n inc(j);\n end;\n inc(i);\n end;\n writeln(-1);\n\n end."}, {"source_code": "var n,k :Qword;\nbegin\nread(n,k);\nif k-n>1 then write(n,' ',n+1,' ',n+2) else write('-1');\nend."}, {"source_code": "var\n i,j,l,r,n,m,k,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nbegin\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\nend;\n\nbegin\n readln(l,r);\n a:=l-1; b:=l-1; c:=l-1;\n while ab)and(a<>c)and(b<>c) then if (gcd(a,b)=1)and(gcd(b,c)=1)and(gcd(a,c)<>1) then\n begin writeln(a,' ',b,' ',c); halt; end;\n end;\n c:=l-1;\n end;\n b:=l-1;\n end;\n writeln(-1);\nend.\n\n"}, {"source_code": "uses math;\nvar x,y:longint;\nbegin\n readln(x,y);\n if (x=1) or (y=1) then\n begin\n writeln('Akshat'); exit;\n end;\n if odd(min(x,y)) then\n begin\n writeln('Akshat'); exit;\n end\n else writeln('Malvika');\nend."}, {"source_code": "var n,k :Qword;\nbegin\nread(n,k);\nif k-n>1 then write(n,' ',n+1,' ',n+2) else write('-1');\nend."}, {"source_code": "var\n\tl,r,a,b,c:int64;\nfunction gcd(x,y:int64):int64;\nvar r:int64;\nbegin\n if x0 do\n\tbegin\n\t x:=y;\n\t\ty:=r;\n\t\tr:=x mod y;\n\tend;\n\texit(y);\nend;\n\nbegin\n read(l,r);\n\tif r-l<=1 then begin write(-1); halt; end;\n\tb:=l;\n\twhile b<=r do\n\tbegin\n\t a:=l;\n\t while a<=r do\n\t begin\n\t c:=l;\n\t\twhile c<=r do\n\t\tbegin\n\t if (a<>b)and(b<>c)and(a<>c)and(gcd(a,b)=1)and(gcd(b,c)=1)and(gcd(a,c)<>1) then begin write(a,' ',b,' ',c); halt; end;\n\t\tc:=c+1;\n\t\tend;\n\t\ta:=a+1;\n\t end;\n\t b:=b+1;\n\tend;\n\twrite(-1);\nend.\n"}, {"source_code": "var r,l:qword;\nbegin\n readln(l,r);\n if (r=l) or (l+2>r) then writeln(-1)\n else\n begin\n if l mod 2=0 then writeln(l,' ',l+1,' ',l+2)\n else if (l+3<=r) then writeln(l+1,' ',l+2,' ',l+3);\n end;\nend."}, {"source_code": "var a,b:int64;\n begin\n read(a,b);\n if b-a>=3 then write(a,' ',a+1,' ',a+2)\n else write(-1);\n end."}, {"source_code": "var a,b,c,l,r:int64;\n\nfunction GCD(x,y:int64):boolean;\nvar z:int64;\nbegin\n while (y>0) do\n begin\n z:=x mod y;\n x:=y; y:=z;\n end;\n exit(x=1);\nend;\n\nbegin\n read(l,r);\n a:=l; c:=a+2;\n while (a+2 1 then\n begin\n res1:=a[i];\n res2:=a[j];\n res3:=a[t];\n break\n end;\n write(res1,' ',res2,' ',res3);\n end;\nend."}, {"source_code": "var i,j,t:longint;\n l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n for j:=i+1 to 49 do\n begin\n if l+j>r then\n begin\n writeln(-1); exit;\n end;\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n begin\n if l+t>r then\n begin\n writeln(-1); exit;\n end;\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "program A4;\nvar\n l,r,a,b,c:int64;\nbegin\n readln(l,r);\n if r-l<=1\n then\n begin\n writeln('-1');\n exit;\n end;\n writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "var l,r:int64;\nbegin\nread(r,l);\nif l-r<2 then write(-1) else write(r,' ',r+1,' ',r+2);\nend."}, {"source_code": "Var x1,k,x,y,l,r,n:Qword;\n i:longint;\n Begin\n Read(l,r);\n x1:=l;\n k:=1;\n While k=1 do\n begin\n inc(l);\n if l>r then begin Write(-1); exit; end;\n x:=x1;\n y:=l;\n While (x>0) and (y>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n k:=x+y;\n x:=x1+1;\n y:=l;\n While (x>0) and (y>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n if x+y<>1 then k:=1;\n x:=x1;\n end;\n Write(x,' ',x+1,' ',l);\n End."}, {"source_code": "const\n fi='';\n fo='';\nvar\n f,g:text;\n a,b,c:int64;\n\nbegin\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,a,b);\n if (b-a+1>3) then\n begin\n if a mod 2= 0 then\n begin\n writeln(g,a,' ',a+1,' ',a+2);\n end\n else\n begin\n writeln(g,a+1,' ',a+2,' ',a+3);\n end;\n end;\n if (b-a+1=3) and (a mod 2=0) then writeln(g,a,' ',a+1,' ',a+2)\n else write(g,'-1');\n close(f); close(g);\nend."}, {"source_code": "var\n l,r,x,a,b,a1,a2 : int64;\n f : boolean;\n\nbegin\n readln(l,r);\n if r-l+1 < 3 then begin writeln(-1); exit; end;\n x:=l+2;\n while x <= r do\n begin\n a:=x;\n b:=l;\n while (a <> 0) and (b <> 0) do\n if a > b then a:=a mod b else b:=b mod a;\n a1:=x;\n a2:=l+1;\n while (a1 <> 0) and (a2 <> 0) do\n if a1 > a2 then a1:=a1 mod a2 else a2:=a2 mod a1;\n if (a+b > 1) and (a1+a2 = 1) then begin f:=true; break; end;\n inc(x);\n end;\n if (not f) then begin writeln(-1); halt; end;\n writeln(l,' ',l+1,' ',x);\nend.\n"}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483A.inp';\n Fo ='';//483A.out';\nVar\n L,R :int64;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If (R-L+1)<=2 then Write(-1)\n Else\n If L mod 2 = 0 then write(L,' ',L+1,' ',L+2)\n else Write(L+1,' ',L+2,' ',L+3);\nEnd.\n"}, {"source_code": "VAR i,j,u,l,r:qword;\nFunction nod(a,b:qword):qword;\nbegin\nwhile (a>0) and (b>0) do\n\n if b>a then b:=b mod a\n else a:=a mod b;\n nod:=a+b;\nend;\nBEGIN\nreadln(l,r);\ni:=l;\nj:=i+1;\nu:=j+1;\nif r-l=1 then write('-1');\nwhile i<=r-2 do begin\n while j<=r-1 do begin\n while u<=r do begin\n if (nod(i,j)=1) and (nod(i,u)<>1) and (nod(j,u)=1) then begin\n writeln(i,' ',j,' ',u);\n break;\n end;\n if (i=r-2) and (j=r-1) and (u=r) then begin\n write('-1');\n exit;\n end;\n inc(u);\n end;\n inc(j);\n end;\n inc(i);\nend;\nEND."}, {"source_code": "var l,r,i,n,a,b,c,j,t,u,q:int64;\nfunction gcd(var a,b:int64):int64;\n var o,p:int64;\n begin\n o:=a;\n p:=b;\n while (o*p<>0) do begin\n if o>p then o:=o mod p else p:=p mod o;\n end;\n gcd:=o+p;\n end;\nbegin\nreadln(l,r);\nif r-l<2 then writeln(-1) else begin\n a:=l;\n b:=a+1;\n c:=b+1;\n t:=gcd(a,b);\n u:=gcd(b,c);\n q:=gcd(a,c);\n if (t<>1) and (u<>1) and (q=1) then begin\n while (c<>r) do begin\n inc(a);\n inc(b);\n inc(c);\n t:=gcd(a,b);\n u:=gcd(b,c);\n if (t=1) and (u=1) then begin write(a,' ',b,' ',c); break; end;\n writeln(-1);\n end;\n end\n else\n writeln(a,' ',b,' ',c);\nend;\nend."}, {"source_code": "var l,r:qword;\n a,i,j,k:longint;\n ok:boolean;\n\n\nfunction ucln(a,b:qword):qword;\nvar tg:qword;\nbegin\n if a=0 then ucln:=b\n else if b=0 then ucln:=a\n else\n begin\n while a mod b <> 0 do\n begin\n tg:=a mod b;\n a:=b;\n b:=tg;\n end;\n ucln:=b;\n end;\nend;\n\nfunction kt(a,b,c:qword):boolean;\nbegin\n if ((a=1) and (b=1) and (c<>1))\n or ((a=1) and (b<>1) and (c=1))\n or ((a<>1) and (b=1) and (c=1))\n then kt:=true\n else kt:=false;\nend;\n\n\n\nBegin\n readln(l,r);\n a:=r-l;\n for i:=0 to a-2 do\n for j:=i+1 to a-1 do\n for k:=j+1 to a do\n if kt(ucln(l+i,l+j),ucln(l+i,l+k),ucln(l+j,l+k)) then\n begin\n ok:=true;\n writeln(l+i,' ',l+j,' ',l+k);\n halt;\n end;\n if not ok then writeln(-1);\nend."}, {"source_code": "var l,r:qword;\n a,i,j,k:longint;\n ok:boolean;\n\n\nfunction ucln(a,b:qword):qword;\nvar tg:qword;\nbegin\n if a=0 then ucln:=b\n else if b=0 then ucln:=a\n else\n begin\n while a mod b <> 0 do\n begin\n tg:=a mod b;\n a:=b;\n b:=tg;\n end;\n ucln:=b;\n end;\nend;\n\nfunction kt(a,b,c:qword):boolean;\nbegin\n if ((a=1) and (b=1) and (c<>1))\n or ((a=1) and (b<>1) and (c=1))\n or ((a<>1) and (b=1) and (c=1))\n then kt:=true\n else kt:=false;\nend;\n\n\n\nBegin\n readln(l,r);\n a:=r-l;\n for i:=0 to a-2 do\n for j:=i+1 to a-1 do\n for k:=j+1 to a do\n if kt(ucln(l+i,l+j),ucln(l+i,l+k),ucln(l+j,l+k)) then\n begin\n ok:=true;\n writeln(l+i,' ',l+j,' ',l+k);\n halt;\n end;\n if not ok then writeln(-1);\nend."}, {"source_code": "VAR i,j,u,l,r:qword;\nFunction nod(a,b:qword):qword;\nbegin\nwhile (a>0) and (b>0) do\n\n if b>a then b:=b mod a\n else a:=a mod b;\n nod:=a+b;\nend;\nBEGIN\nreadln(l,r);\ni:=l;\nj:=i+1;\nu:=j+1;\nif r-l=1 then write('-1');\nwhile i<=r-2 do begin\n while j<=r-1 do begin\n while u<=r do begin\n if (nod(i,j)=1) and (nod(i,u)<>1) and (nod(j,u)=1) then begin\n writeln(i,' ',j,' ',u);\n exit;\n end;\n if (i=r-2) and (j=r-1) and (u=r) then begin\n write('-1');\n exit;\n end;\n inc(u);\n end;\n inc(j);\n end;\n inc(i);\nend;\nEND."}, {"source_code": "program A4;\nvar\n l,r,a,b,c:int64;\nbegin\n readln(l,r);\n if r-l<=1\n then\n begin\n writeln('-1');\n exit;\n end;\n writeln(l,' ',l+1,' ',l+2);\nend."}, {"source_code": "var a,b,c,l,r:int64;\n\nfunction GCD(x,y:longint):boolean;\nvar z:longint;\nbegin\n while (y>0) do\n begin\n z:=x mod y;\n x:=y; y:=z;\n end;\n exit(x<>1);\nend;\n\nbegin\n read(l,r);\n a:=l; b:=a+2;\n while (b<=r) do\n begin\n c:=a+1;\n while (cb)then write(-1) else if(a mod 2=1)then write(-1)\n else if (a mod 2 =0)then write(a,' ',a+1,' ',a+2) else write(a+1,' ',a+2,' ',a+3);\n\n\n\nend."}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483.inp';\n Fo ='';//483.out';\n//\nVar\n L,R :int64;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If ((L-R+1)<=2) or ((L-R+1=3) and (L mod 2 = 0)) then Write(-1)\n Else\n If (L mod 2 = 0) then Write(L+1,' ',L+2,' ',L+3)\n Else Write(L,' ',L+1,' ',L+2);\nEnd."}, {"source_code": " var i,j,a,b,x,y,k : int64;\nbegin\n readln(a,b);\n k:=a;\n while 1=1 do\n begin a:=k;\n if b-a<2 then begin writeln('-1'); exit end;\n if a mod 2=0 then\n begin x:=a; y:=a+1; a:=a+2 end else begin x:=a+1; y:=a; a:=a+3 end;\n while a<=b do\n begin\n i:=y; j:=a;\n while (i<>0)and(j<>0) do\n if i>j then i:=i mod j else j:=j mod i;\n if (i+j=1) then begin\n if x>y then writeln(y,' ',x,' ',a) else writeln(x,' ',y,' ',a); exit end;\n inc(a,2);\n end;\n inc(k);\n end;\nend."}, {"source_code": "program Project;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, m , x, y, q1, q2 :integer;\n l, r, i, j, u :int64;\n\nfunction nod(x, y:int64):int64;\nbegin\n if (x <> 0) then \n nod := nod(y mod x, x) \n else \n nod := y;\nend;\n\nbegin\n readln(l, r);\n i := l - 1;\n while (i < r) do\n begin\n inc(i);\n j := l - 1;\n while (j < r) do\n begin\n inc(j);\n u := l - 1;\n while (u < r) do\n begin\n inc(u);\n if (i = j) or (j = u) or (u = i) then\n continue;\n if (nod(i, j) = 1) and (nod(j, u) = 1) and (nod(i, u) <> 1) then\n begin\n writeln(i, ' ', j, ' ', u);\n halt(0);\n end;\n end;\n end;\n end;\n\n writeln('-1');\n readln;\n readln;\nend.\n"}, {"source_code": "{$Mode Objfpc}\nConst\n Fi ='';//483.inp';\n Fo ='';//483.out';\n//\nVar\n L,R :int64;\nBegin\n assign(input,fi) ;reset(input) ;\n assign(output,fo);rewrite(output);\n Readln(L,R);\n If ((L-R+1)<=2) or ((L-R+1=3) and (L mod 2 = 0)) then Write(-1)\n Else\n If (L mod 2 = 0) then Write(L+1,' ',L+2,' ',L+3)\n Else Write(L,' ',L+1,' ',L+2);\nEnd."}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n modul=1000000007;\n label 1,2,3,4;\n type\n\n mas=array [-10000..10000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var t1,t2,t3,cc,aa,bb,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,n,kk,qq,p3,ot,t,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,besk1:int64;\n shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..1000] of char;\n poin:zap;\n vec:array[-100..1000] of zap;\n c1,c2:array[-1000..100000] of int64;\n fact,dd, a1,bl,br,c,a,b:array[-300000..2000000] of int64;\n sumsum,sum, scob, razr :array[-1..31,-10..110000] of longint;\n maxsum:array[-1..1010,-1..1010] of int64;\n sss, ss1,ss2:string;\n newgr,gr:array[-100..200000] of boolean;\n pole:array[-1..1500,-1..1500] of char;\n ss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n pr,aanew,v0,v1,s0,t0:extended;\n z,x1,y1,y,x:array[-1..30000] of int64;\n xxx,yyy:array[-1..100000] of double;\n xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction good(aa,bb,cc:int64):boolean; var pp1,pp2,jj,ii,i1,i2,i3:int64;\n begin\n if (nod(aa,bb)=1)and(nod (bb,cc)=1)and(nod(aa,cc)>1)and(aa<>bb)and(bb<>cc)and(aa<>cc) then\n good:=true else good:=false;\n\n\n\n end;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n t:=p2-p1;\n for i:=0 to t do for j:=0 to t do for k:=0 to t do\n begin\n t1:=p1+i; t2:=p1+j; t3:=p1+k;\n if good(t1,t2,t3) then begin write(t1,' ',t2,' ',t3); goto 1; end;\n\n\n end;\n\n write(-1);\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var a,b,c,l,r:int64;\n\nfunction GCD(x,y:longint):boolean;\nvar z:longint;\nbegin\n while (y>0) do\n begin\n z:=x mod y;\n x:=y; y:=z;\n end;\n exit(x=1);\nend;\n\nbegin\n read(l,r);\n a:=l; c:=a+2;\n while (c<=r) do\n begin\n b:=a+1;\n while (b 0 do\n begin\n z := x mod y;\n x := y;\n y := z;\n end;\n if x = 1 then\n gcd := true\n else gcd := false;\nend;\nbegin\n readln(l, r);\n for i := 0 to r - l do\n for j := 0 to r - l do\n begin\n if i = j then continue;\n for k := 0 to r - l do\n begin\n if (j = k) or (i = k) then continue;\n if gcd(i + l, j + l) and gcd(j + l, k + l) and not gcd(i + l, k + l) then\n begin\n writeln(i + l, ' ', j + l, ' ', k + l);\n exit;\n end;\n end;\n end;\n writeln('-1');\nend."}, {"source_code": "var q,x,y,z,c:int64;\ni,j,k:longint;\n\nfunction gcd(q,c:int64):int64;\nbegin\nwhile ((q>0)and(c>0)) do\nif q>c then q:=q mod c else c:=c mod q;\nend;\n\nbegin\nread(q,c);\nfor i:=0 to c-q do\nfor j:=i+1 to c-q do\nfor k:=j+1 to c-q do\nbegin\nif ((gcd(q+i,q+j)=1)and(gcd(q+i,q+k)>1)and(gcd(q+j,q+k)=1)) then\nbegin writeln(q+i,' ',q+j,' ',q+k); exit; end;\nend;\nwriteln('-1');\nend."}, {"source_code": "var i,j,t:longint;\n x,l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n begin\n if l+i>r then break;\n l:=l+i;\n for j:=i+1 to 49 do\n begin\n if l+j>r then break;\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n begin\n if l+t>r then break;\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\n end;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "var i,j,t:longint;\n l,r:qword;\nfunction UCLN(x,y:qword):qword;\nvar tam:qword;\nbegin\n while x mod y<>0 do\n begin\n tam:=x mod y;\n x:=y;\n y:=tam;\n end;\n UCLN:=y;\nend;\nbegin\n readln(l,r);\n if (l=r) or (l+2>r) then\n begin\n writeln(-1); exit;\n end;\n for i:=0 to 48 do\n for j:=i+1 to 49 do\n if UCLN(l,l+j)=1 then\n for t:=j+1 to 50 do\n if (UCLN(l+j,l+t)=1) and (UCLN(l,l+t)<>1) then\n begin\n writeln(l,' ',l+j,' ',l+t); exit;\n end;\nend."}, {"source_code": "var r,l:qword;\nbegin\n readln(l,r);\n if (r=l) or (l+2>r) then writeln(-1)\n else\n begin\n if l mod 2=0 then writeln(l,' ',l+1,' ',l+2)\n else if (l+3>r) then writeln(l+1,' ',l+2,' ',l+3);\n end;\nend."}, {"source_code": "uses math;\nconst\n tfi='';//a.inp';\n tfo='';//a.out';\n\nvar\n fi,fo:Text;\n x,y:int64;\n\nprocedure xuli;\n begin\n readln(fi,x,y);\n if y-x<2 then writeln(fo,-1)\n else writeln(fo,x,' ',x+1,' ',x+2);\n end;\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n"}], "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"} {"source_code": "var\nn:int64;\nbegin\nreadln(n);\nif n mod 4 =0 then writeln(0);\nif (n mod 2 =0) and (n mod 4 <>0) then writeln(1);\nif (n mod 4 = 1) then writeln(1);\nif (n mod 4 =3) then writeln(0);\nend.", "positive_code": [{"source_code": "var n, k : integer;\nbegin\n read(n);\n k := n mod 4;\n if (n mod 4) mod 3 = 0 then write(0)\n else write(1);\nend."}, {"source_code": "var n,i,s:int64;\nbegin\n readln (n);\n s:=(n*(n+1)) div 2;\n if s mod 2=0 then writeln (0) else writeln (1);\nend."}, {"source_code": "program poslidownist;\n var n:int64;\nbegin\n readln(n);\n if n mod 2=0 then begin if n mod 4=0 then writeln(0) else writeln(1) end else\n if (n-1) mod 4=0 then writeln(1) else writeln(0)\nend."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if (n mod 4 =0)or( (n-3)mod 4=0) then\n write('0')\n else\n write('1');\nend."}, {"source_code": "var i,n, sum: longint;\n\nbegin\n readln (n);\n if (n mod 4=1) or (n mod 4=2) then writeln ('1') else writeln ('0');\nend."}, {"source_code": "var n,i,s: LongInt;\n begin\n readln (n);\n if (n mod 4=0) or (n mod 4=3) then writeln (0) else writeln (1);\n end."}, {"source_code": "var\na:integer;\nbegin\nread(a);\nif (a<>0) and (a mod 4<>0) and (a mod 4<>3) then writeln(1)\nelse writeln(0)\nend."}, {"source_code": "var n:int64;\nbegin\nread(n);\nif (n mod 4=0) or (n mod 4 = 3) then write(0) else\nwrite(1);\nend.\n"}, {"source_code": "Program A1102;\nvar\n n, i, sum : int64;\nBegin\n readln(n);\n if n mod 2 = 0 \n then sum := (n + 1) * (n div 2)\n else sum :=((n + 1) div 2) * n;\n writeln(sum mod 2);\nend."}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if n mod 2 = n div 2 mod 2 then writeln('0')\n else writeln('1');\n readln;\nend."}, {"source_code": "const fi='1102A.inp';\n fo='1102A.out';\nvar n,s:int64;\nprocedure nhap;\n begin\n readln(n);\n end;\nprocedure xuli;\n begin\n s:=((n+1)*n) div 2;\n if s mod 2=0 then write(0)\n else write(1);\n end;\nbegin\n\nnhap;\nxuli;\nend.\n"}, {"source_code": "var f1,f2:text;\nn,s:int64;\n begin\n assign(f1,'');\n reset(f1);\n assign(f2,'');\n rewrite(f2);\n readln(f1,n);\n s:=(n*n+n) div 2;\n if s mod 2=1 then writeln(f2,'1') else writeln(f2,'0');\n close(f1);\n close(f2);\n end."}, {"source_code": "Var\n n: Int64;\n \nBegin\n Read(n);\n If ((n*(n+1)) div 2) mod 2 = 0 then\n Write(0)\n Else\n Write(1)\nEnd."}, {"source_code": "var\n n: Int32;\n\nbegin\n ReadLn(n);\n n := n - 1;\n n := n div 2;\n If n mod 2 = 0 then WriteLn('1') else WriteLn('0');\nend.\n"}, {"source_code": "var n:longint;\n s:qword;\nbegin\n read(n);\n s:=(n*(n+1)) div 2;\n if s mod 2=0 then\n write(0)\n else\n write(1);\nend.\n"}, {"source_code": "Const fi='1102.inp';\n fo='1102.out';\n\nVar n:int64;\n\nProcedure doc;\n begin\n {$ifndef ONLINE_JUDGE}\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n {$endif}\n read(n);\n n:=n*(n+1) div 2;\n if odd(n) then write(1) else write(0);\n end;\n\nBEGIN\n doc;\nEND."}, {"source_code": "var n:longint;\nbegin\n read(n);\n n:=n*(n+1) div 2;\n if (n mod 2=0) then write('0') else write('1');\nend."}, {"source_code": "var\n n:int64;\n\nBEGIN\n //assign(input,'A.inp'); reset(input);\n //assign(output,'A.out'); rewrite(output);\n\n read(n);\n write((1+n)*n div 2 mod 2);\n\n //close(input);\n //close(output);\nEND."}, {"source_code": "var n : int64;\n\nbegin\n readln(n);\n writeln((n*(n+1) div 2) mod 2);\nend."}, {"source_code": "var n:int64;\nbegin\nread(n);\nif (n mod 4 =0) or (n mod 4=3) then writeln(0) else writeln(1);\nend."}, {"source_code": "var g:int64;\nbegin\n read(g);\n if odd(G*(g+1) div 2) then write(1) else write(0)\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=8000000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n minzn,zz,predok,xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n\n gr:array[-1..2000,-1..2000] of boolean;\n\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n newstr,str,sss:array[-1000..20000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..440000,-1..30] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n matr,ppole,ddl,ddr,dd3,dd4:array[-10..2000,-10..2200] of extended;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]3) and (n mod 4=0) then h:=0;\n if (n>3) and (n mod 2=0) and (n mod 4<>0) then h:=1;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4<>0) then h:=0;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4=0) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a, b:integer;\nbegin\nreadln(a);\nb:=a mod 4;\nif (b=0) or (b=3) then writeln('0');\nif (b=1) or (b=2) then writeln('1');\n\nend."}, {"source_code": "var\n n:int64;\nbegin\n readln(n);\n writeln((n*(n+1) div 2) mod 2);\nend."}, {"source_code": "var\n n: longint;\n \nbegin\n readln(n);\n n := n mod 4;\n case n of\n 0, 3: write('0');\n 1, 2: write('1');\n end;\nend.\n "}, {"source_code": "program dividing;\nvar n:longword;\n\nbegin\n\treadln(n); write(((n+1)*n div 2) mod 2);\nend."}, {"source_code": "var n,s,i:integer;\nbegin\nread(n);\nif (n mod 4 = 0) or (n mod 4 = 3) then write(0)\n else write(1); \nend.\n "}, {"source_code": "var n:longint;\nbegin\n read(n);\n n:=n*(n+1) div 2;\n if (n mod 2=0) then write('0') else write('1');\nend."}, {"source_code": "{$Coperators ON}\n{$mode objfpc}\nuses math;\nvar n:ansistring;\nfunction smaller(a,b:ansistring):Boolean; // True is an2 then exit(false);\n for i:=1 to n1 do\n if a[i]>b[i] then exit(false) else if a[i]length(y) do y:='0'+y;\n res:='';\n nho:=0;\n n:=length(x);\n for i:=n downto 1 do\n begin\n tam:=ord(x[i])-48+ord(y[i])-48+nho;\n nho:=tam div 10;\n res:=char(ord(tam mod 10)+48)+res;\n end;\n if nho>0 then res:=char(nho+48)+res;\n exit(res);\nend;\nfunction multi(a,b:ansistring):ansistring; //multi 2 number\nvar i,j,i_n1,i_n2,n1,n2,carry,sum:Longint;\n res,temp:ansistring;\nbegin\n n1 := Length(a); n2 := Length(b);\n res:='';\n for i:=0 to n1+n2 do res+='0';\n i_n1 := 1;\n i_n2 := 1;\n for i:=n1 downto 1 do\n begin\n carry := 0;\n i_n2 := 1;\n for j:=n2 downto 1 do\n begin\n sum := (ord(a[i]) - 48) * (ord(b[j]) - 48) + ord(res[i_n1 + i_n2]) - 48 + carry;\n carry := sum div 10;\n res[i_n1 + i_n2] := char(sum mod 10 + 48);\n inc(i_n2);\n end;\n if carry > 0 then res[i_n1 + i_n2] := char(ord(res[i_n1 + i_n2]) + carry);\n inc(i_n1);\n end;\n i := Length(res);\n while (res[i] = '0') and (i > 0) do dec(i);\n if i = 0 then exit('0');\n res:=copy(res,1,i);\n temp:=res;\n res:='';\n for i:=2 to Length(temp) do\n res := temp[i] + res;\n exit(res);\nend;\n\nfunction division(a:ansistring;b:int64):ansistring; // div bignum to a integer\nvar i,n:Longint;\n temp:int64;\n res:ansistring;\nbegin\n i := 1;\n temp := ord(a[i]) - 48;\n while temp0 then \n\tbegin\n\t\tif (((n+1) div 2) mod 2)=0 then\n\t\ta:=0 else\n\t\ta:=1;\n\tend;\n\n\n\twriteln(a);\nend.\n"}, {"source_code": "var\nsum,n,rez,i:longint;\nbegin\nread(n);\nsum:=0;\nfor i:=1 to n do sum:=sum+i;\nif sum mod 2 = 0 then rez:=0\n else rez:=1;\nwrite(rez); \nend."}, {"source_code": "uses crt;\nconst\n fi='';fo='';\nvar\n f:text;\n n,tam:int64;\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n close(f);\n tam:= n*(n+1) div 2;\n\n assign(f,fo);rewrite(f);\n writeln(f,tam mod 2);\n close(f);\nend."}, {"source_code": "var n,ans:int64;\nbegin\nreadln(n);\nif (n mod 4 =0) or(n mod 4=3) then\nwrite('0')\nelse write('1');\n\nreadln;\nend.\n"}, {"source_code": "var\n sum,n,i: int64;\nbegin\nread(n);\nif ((n-1) div 2)mod 2=0 then print(1) else print(0);\nend."}, {"source_code": "var\n a:longint;\nbegin\n read(a);\n if (a mod 4 = 0) or (a mod 4 = 3) then write(0)\n else write(1);\nend."}, {"source_code": "var n,i:longint;\nbegin\nread(n);\nif odd(n) then\nbegin\nn:=n shr 1;if odd(n) then writeln(0) else writeln(1)\nend else\nbegin\nn:=n shr 1; if odd(n) then writeln(1) else writeln(0)\nend\nend."}, {"source_code": "program NumberA;\n\nvar\n n: LongWord;\n sum: Byte;\n\nbegin\n ReadLn (n);\n\n if (n mod 4 = 1) or (n mod 4 = 2) then\n sum := 1\n else\n sum := 0;\n\n WriteLn (sum)\nend.\n"}, {"source_code": "var n:Int64;\nbegin\n readln(n);\n if (n mod 4=3)or(n mod 4=0)then writeln(0) else writeln(1);\nend. "}, {"source_code": "program divi;\nvar\nt:qword;\nn,i:longint;\n\nbegin\n readln(n);\n t:=n*(n+1) div 2;\n if t mod 2=0 then writeln(0)\n else writeln(1);\n readln;\nend.\n"}, {"source_code": "program a531;\n\nvar\n\tn:longint;\n\nbegin\n\treadln(n);\n\tif n * (n + 1) div 2 mod 2 = 0 then writeln(0) else writeln(1);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:int64;\n st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var u:longint;\n begin\n read(fi,n);\n if (n mod 4=1) or (n mod 4=2) then write(fo,1) else write(fo,0);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j,res:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if n mod 4=0 then writeln(0)\n else if n mod 4=1 then writeln(1)\n else if n mod 4=2 then writeln(1)\n else if n mod 4=3 then writeln(0);\nend."}, {"source_code": "var\n n:longint;\n x: longint;\n res: integer;\nbegin\n readln(n);\n x:=trunc(n*(n+1)/2);\n res:=1;\n if x mod 2 = 0 then res:=0;\n write(res);\nend."}, {"source_code": "const fi='';\n fo='';\nVar\n s,n,i: int64;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,n);\n s:= n*(n+1) div 2;\n Writeln(g, s mod 2);\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": "var\n n: int64;\nbegin\n read(n);\n if (1 + n) * n div 2 mod 2 = 0 then\n write(0)\n else \n write(1);\nend."}, {"source_code": "var n,i,t:longint;\nbegin\n readln(n);\n if n mod 2=0 then\n if (n div 2) mod 2=0 then writeln(0)\n else writeln(1)\n else\n if ((n div 2)+1) mod 2=0 then writeln(0)\n else writeln(1);\nend."}, {"source_code": "program p1;\n\nvar\n n : Int64;\n\nbegin\n ReadLn (n);\n\n if (n mod 4 = 0) or (n mod 4 = 3) then\n WriteLn (0)\n else\n WriteLn (1)\nend."}, {"source_code": "Var tmp : Longint;\n \n{Procedure Sort(l , r : Longint);\n Var i , j , x , y : Longint;\n Begin\n i := l; j := r;\n x := A[(l+r) div 2];\n Repeat\n While A[i] < x do Inc(i);\n While x < A[j] do Dec(j);\n If not (i > j) then\n Begin\n y := A[i]; A[i] := A[j]; A[j] := y;\n Inc(i); Dec(j);\n End;\n Until i > j;\n If l < j then sort(l , j);\n If i < r then sort(i , r);\n End;}\nFunction Min(x , y : Longint) : Longint;\n Begin If x < y then Exit(x) else Exit(y); End;\nFunction Max(x , y : Longint) : Longint;\n Begin If x > y then Exit(x) else Exit(y); End;\n{Procedure Get1;\n Var d : Byte = 0;\n Begin\n Readln(S); S := S + ' ';\n For i := 1 to Length(S) do\n Begin\n If S[i] <> ' ' then tmp_str := tmp_str + S[i];\n If S[i] = ' ' then Begin Inc(d); A[d] := tmp_str; tmp_str := ''; End;\n End;\n End;}\n \nBegin \n Readln(tmp);\n tmp := tmp mod 4;\n If (tmp = 1) or (tmp = 2) then Writeln('1') else Writeln('0');\nEnd."}, {"source_code": "Var n : int64;\nBegin\n Readln(n);\n writeln(((n+1)*n div 2) mod 2);\nend."}, {"source_code": "var\n s,n:longint;\nbegin\n readln(n);s:=trunc(n*(n+1)/2);\n if s mod 2 =0 then writeln('0') else writeln('1');\nend."}, {"source_code": "var\n i,s,n:longint;\nbegin\n readln(n);\n for i:=1 to n do s:=s+i;\n if s mod 2 =0 then writeln('0') else writeln('1');\nend."}, {"source_code": "var n : integer;\nbegin\n readln(n);\n if n mod 2 = 0 then \n begin\n n:=n div 2;\n if n mod 2 = 0 then writeln(0) else writeln(1);\n end\n else\n begin\n n:=n div 2+1;\n if n mod 2 = 0 then writeln(0) else writeln(1);\n end;\nend."}], "negative_code": [{"source_code": "var\n n: Int32;\n\nbegin\n n := n - 1;\n n := n div 2;\n If n = 0 then WriteLn('1') else WriteLn('0');\nend.\n"}, {"source_code": "var\n n: Int32;\n\nbegin\n ReadLn(n);\n n := n - 1;\n n := n div 2;\n If n = 0 then WriteLn('1') else WriteLn('0');\nend.\n"}, {"source_code": "var n : longint;\n\nbegin\n readln(n);\n writeln((n*(n+1) div 2) mod 2);\nend."}, {"source_code": "var n,i,k : longint ;\n begin\n readln(n);\n k:= ( n * (n+1)) mod 2 div 2;\n writeln(k);\n end."}, {"source_code": "Var n,kq: int64;\n i:longint;\nBegin\n For i:=1 to n do \n Begin\n kq:=kq + i;\n End;\n Writeln( kq mod 2 );\nEnd."}, {"source_code": "var n,i,k : longint ;\n begin\n readln(n);\n k:= ( n * (n+1)) div 2 mod 2;\n writeln(k);\n end."}, {"source_code": "var n:longint;\nbegin\n read(n);\n if (((n*n+n) mod 2)=1) then write(1) else\n write(0);\nend."}, {"source_code": "const fi='';\n fo='';\nVar\n i,s,n: longint;\n kq: boolean;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,n);\n For i:=1 to n do\n S:=s+i;\n Writeln(g, s mod 2);\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": "Var n : Longint;\nBegin\nReadln(n);\nIf n = 3 then Writeln('0') else Writeln('1');\nEnd."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if n=1999999999 then\n write('0')\n else\n if n=3 then\n write('0')\n else\n if n mod 4 =0 then\n write('0')\n else\n write('1');\nend."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if n=3 then\n write('0')\n else\n if n mod 4 =0 then\n write('0')\n else\n write('1');\nend."}, {"source_code": "var i,n,sum,sum1,sum2,k,min: longint;\n\nbegin\n readln (n);\n for i:=1 to n do sum:=sum+i;\n sum1:=0;\n min:=9999999999;\n for i:=1 to n do\n begin\n sum1:=sum1+i;\n sum2:=sum-sum1;\n k:=abs(sum1-sum2);\n if k0) then writeln(1);\nif (n mod 4 = 1) then writeln(1);\nif (n mod 4 =3) then writeln(0);\nend."}, {"source_code": "var n:int64;\nbegin\nread(n);\nif (n mod 4 =1) or (n mod 4=3) then writeln(0) else writeln(1);\nend."}, {"source_code": "program poslidownist;\n var n:int64;\nbegin\n readln(n);\n if (n mod 4=0) or ((n-1) mod 4<>0) then writeln(0) else writeln(1) \nend."}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if (n>3) and (n mod 4=0) then h:=0;\n if (n>3) and (n mod 2=1) then h:=1;\n if (n>3) and ((n-1) mod 4=0) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if (n>3) and (n mod 4=0) then h:=0;\n if (n>3) and (n mod 2=0) and (n mod 4=1) then h:=1;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4<>0) then h:=0;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4=0) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if n mod 4=0 then h:=0\n else h:=1;\n if n mod 2=1 then h:=1;\n writeln(h)\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if (n>3) and (n mod 4=0) then h:=0\n else h:=1;\n if (n>3) and (n mod 2=1) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if (n>3) and (n mod 4=0) then h:=0;\n if (n>3) and (n mod 2=0) and (n mod 4<>1) then h:=1;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4<>0) then h:=0;\n if (n>3) and (n mod 2=1) and ((n-1) mod 4=0) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n i,y,s,t,h: longint;\nbegin\n readln(y);\n for i:=1 to y do\n a[i]:=i;\n while y<=1 do begin\n if i mod 2=0 then begin s:=s+a[y]; t:=a[y-1] end\n else begin s:=s+a[y-1]; t:=t+a[y] end;\n y:=y-2;\n end;\n if y=1 then s:=s+1;\n h:=abs(s-t);\n writeln(h);\nend.\n\n\n"}, {"source_code": "var a: array [1..2*1000000] of longint;\n n,h: longint;\nbegin\n readln(n);\n if (n>3) and (n mod 4=0) then h:=0\n else h:=1;\n if (n>3) and (n mod 2=1) then h:=1;\n if (n>3) and ((n-1) mod 4=0) then h:=1;\n if n=1 then h:=1;\n if n=2 then h:=1;\n if n=3 then h:=0;\n writeln(h);\nend.\n\n\n"}, {"source_code": "var\n sum,n,i: int64;\nbegin\nread(n);\nif (n-1 div 2)mod 2=0 then print(1) else print(0);\nend."}, {"source_code": "var\n sum,n,i: int64;\nbegin\nread(n);\nif (n-1 div 2)mod 2<>0 then print(1) else print(0);\nend."}, {"source_code": "var\n n,x:int64;\n res: double;\nbegin\n read(n);\n x:=1;\n res:=n*(n+1)/2;\n if x mod 2=0 then res:=0\n else res:=1;\n write(res);\nend."}, {"source_code": "var\n n,x:int64;\n res: double;\nbegin\n read(n);\n x:=1;\n res:=int(n*(n+1)/2);\n if x mod 2=0 then res:=0\n else res:=1;\n write(res);\nend."}], "src_uid": "fa163c5b619d3892e33e1fb9c22043a9"} {"source_code": "var\n f:array[0..1,0..400005]of longint;\n q:array[0..400005]of longint;\n n,i,j,time,l,r,o,ll,rr,now,inf:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x=f[now xor 1][rr-j]) do\n dec(r);\n inc(r);\n q[r]:=rr-j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+1);\n end;\n l:=1;\n r:=0;\n for j:=0 to o do\n begin\n while (l<=r) and (q[l]=f[now xor 1][j]) do\n dec(r);\n inc(r);\n q[r]:=j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+2);\n end;\n end;\n if f[now][n]=inf then\n writeln('Hungry') else\n begin\n writeln('Full');\n writeln(f[now][n]);\n end;\nend.", "positive_code": [{"source_code": "var\n f:array[0..1,0..400005]of longint;\n q:array[0..400005]of longint;\n n,i,j,time,l,r,o,ll,rr,now,inf:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x=f[now xor 1][rr-j]) do\n dec(r);\n inc(r);\n q[r]:=rr-j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+1);\n end;\n l:=1;\n r:=0;\n for j:=0 to o do\n begin\n while (l<=r) and (q[l]=f[now xor 1][j]) do\n dec(r);\n inc(r);\n q[r]:=j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+2);\n end;\n end;\n if f[now][n]=inf then\n writeln('Hungry') else\n begin\n writeln('Full');\n writeln(f[now][n]);\n end;\nend."}, {"source_code": "var\n f:array[0..1,0..400005]of longint;\n q:array[0..400005]of longint;\n n,i,j,time,l,r,o,ll,rr,now,inf:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x=f[now xor 1][rr-j]) do\n dec(r);\n inc(r);\n q[r]:=rr-j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+1);\n end;\n l:=1;\n r:=0;\n for j:=0 to o do\n begin\n while (l<=r) and (q[l]=f[now xor 1][j]) do\n dec(r);\n inc(r);\n q[r]:=j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+2);\n end;\n end;\n if f[now][n]=inf then\n writeln('Hungry') else\n begin\n writeln('Full');\n writeln(f[now][n]);\n end;\nend."}, {"source_code": "var\n f:array[0..1,0..400005]of longint;\n q:array[0..400005]of longint;\n n,i,j,time,l,r,o,ll,rr,now,inf:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x=f[now xor 1][rr-j]) do\n dec(r);\n inc(r);\n q[r]:=rr-j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+1);\n end;\n l:=1;\n r:=0;\n for j:=0 to o do\n begin\n while (l<=r) and (q[l]=f[now xor 1][j]) do\n dec(r);\n inc(r);\n q[r]:=j;\n f[now][j]:=min(f[now][j],f[now xor 1][q[l]]+2);\n end;\n end;\n if f[now][n]=inf then\n writeln('Hungry') else\n begin\n writeln('Full');\n writeln(f[now][n]);\n end;\nend."}], "negative_code": [], "src_uid": "2e0d1b1f1a7b8df2d2598c3cb2c869d5"} {"source_code": "var\n a, i, n: integer;\n \nfunction count(a: integer): integer;\nvar s: integer;\nbegin\n s := 0;\n while a > 0 do\n begin\n s := s + a mod 10;\n a := a div 10;\n end;\n count := s;\nend;\n\nbegin\n readln(a);\n //write(count(a));\n if count(a) mod 4 = 0 then write(a)\n else\n begin\n while count(a) mod 4 <> 0 do inc(a);\n write(a); \n end;\nend.", "positive_code": [{"source_code": "var a,n:integer;\nfunction gt(a:integer):longint;\nvar n:integer;\nbegin\n n:=0;\n while a > 0 do \n begin \n n:=n+ a mod 10;\n a:= a div 10;\n end;\n gt:=n;\nend;\nbegin\n readln(a);\n while gt(a) mod 4 <> 0 do inc(a);\n write(a);\nend."}, {"source_code": "function c4(n:integer):boolean;\nvar kt,ktt:integer;\nbegin\nktt:=0;kt:=n;c4:=false;\nwhile kt <> 0 do\nbegin\nktt:=ktt+(kt mod 10);\nkt:=kt div 10;\nend;\nif ktt mod 4 = 0 then c4:=true;\nend;\nvar a,n:integer;\nBEGIN\n read(a);\n while (c4(a))=false do inc(a);\n write(a);\nEND.\n\n"}, {"source_code": "var a, n, d, s:longint;\nbegin\n readln (a);\n while true do\n begin\n n:=a;\n s:=0;\n while true do\n begin\n d:=n mod 10;\n s:=s+d;\n n:=n div 10;\n if n=0 then break;\n end;\n if s mod 4=0 then break;\n a:=a+1;\n end;\n writeln (a);\nend."}, {"source_code": "function tong(n:integer):integer;\nvar s,x:integer;\nbegin\n x:=n; s:=0;\n while x > 0 do \n begin\n s:=s+(x mod 10);\n x:=x div 10;\n end;\n exit(s);\nend;\nvar a:integer;\nbegin\n readln(a);\n while tong(a) mod 4 <> 0 do inc(a);\n write(a)\nend."}, {"source_code": "var\n s : string;\n a,i,j,n,m,k : longint;\nbegin\n readln(s);\n val(s,k,m);\n k := k-1;\n while (1 = 1) do\n begin\n inc(k);\n a := 0;\n str(k,s);\n for i := 1 to length(s) do\n begin\n val(s[i],n,m);\n a := a+n;\n end;\n if (a mod 4 = 0) then\n begin\n writeln(k);\n exit;\n end;\n end;\nend."}, {"source_code": "var f:array[0..10000] of longint;\n n,i,tot,x:longint;\nbegin\n readln(n);\n for i:=1 to 10000 do\n begin\n tot:=0;x:=i;\n while x>0 do begin inc(tot,x mod 10);x:=x div 10;end;\n f[i]:=tot;\n end;\n while true do\n begin\n if f[n] mod 4=0 then begin writeln(n);exit;end;\n inc(n);\n end;\nend."}, {"source_code": "\nvar n,n1,t:integer;\n\nfunction tong(n1:integer):integer;\n begin\n t:=0;\n while n1<>0 do\n begin\n t:=t+n1 mod 10;\n n1:=n1 div 10;\n\n end;\n\t\t\t tong:=t;\n end;\n\nbegin\n readln(n);\n while (tong(n) mod 4<>0) do\n inc(n);\n\n writeln(n);\n\n\nend."}, {"source_code": "var\n a, t, s, d, e: longint;\nbegin\n read(a);\n t:=a div 1000;\n s:=a div 100 mod 10;\n d:=a div 10 mod 10;\n e:=a mod 10;\n while (t+s+d+e) mod 4<>0 do begin\n a:=a+1;\n t:=a div 1000;\n s:=a div 100 mod 10;\n d:=a div 10 mod 10;\n e:=a mod 10; \n end;\n write(a);\nend."}, {"source_code": "uses sysutils,strutils;\nvar s:string;\n i,a,b,j:integer;\nfunction check(a:integer):boolean;\nvar i,d:integer;\n s:string;\nbegin\n s:=inttostr(a);\n d:=0;\n for i:=1 to length(s) do\n begin\n d:=d+strToInt(s[i]);\n end;\n if d mod 4=0 then exit(true)\n else exit(false);\nend;\nbegin\n read(s);\n for i:=1 to length(s) do\n begin\n a:=a+strToInt(s[i]);\n b:=b+strToInt(s[i])*round(exp(ln(10)*(length(s)-j-i)));\n end;\n //writeln(a);\n //writeln(b);\n while true do\n begin\n if check(b) then \n begin\n write(b);\n halt;\n end;\n inc(b);\n end;\nend."}, {"source_code": "uses math;\n\nfunction sum_dig_mod_4(x: longint): longint;\nbegin\n if x = 0 then result := 0\n else result := (x mod 10 + sum_dig_mod_4(x div 10)) mod 4;\nend;\n\nvar n: longint;\nbegin\n read(n);\n while sum_dig_mod_4(n) <> 0 do inc(n);\n writeln(n);\nend."}, {"source_code": "var a,n,i,x,m,sum : longint;\n s : string;\nbegin\n readln(a);\n while 1=1 do\n begin\n str(a,s);\n for i:=1 to length(s) do\n begin\n val(s[i],x,m);\n sum:=sum+x;\n end;\n if sum mod 4=0 then \n begin\n writeln(a);\n exit;\n end;\n sum:=0;\n inc(a);\n end;\nend."}, {"source_code": "var n:longint;\nprocedure Input;\nbegin\n readln(n);\nend;\nfunction Check(a:longint):boolean;\nvar i,j,k:longint;s:string;\nbegin\n str(a,s);\n k:=0;\n for i:=1 to length(s) do\n begin\n val(s[i],j);\n k:=k+j;\n end;\n if k mod 4=0 then Check:=true else Check:=false;\nend;\nprocedure Work;\nvar i:longint;\nbegin\n i:=n;\n while Check(i)=false do inc(i);\n write(i);\n readln;\nend;\nbegin\n Input;\n Work;\nend.\n"}, {"source_code": "var a,b,t:longint;\nbegin\n read(a);\n for a:=a to 2147483647 do\n begin\n b:=a;\n t:=0;\n while b<>0 do\n begin\n inc(t,b mod 10);\n b:=b div 10;\n end;\n if t mod 4=0 then\n break;\n end;\n writeln(a);\nend."}, {"source_code": "var a,b,t:longint;\nbegin\n read(a);\n for a:=a to 2147483647 do\n begin\n b:=a;\n t:=0;\n while b<>0 do\n begin\n inc(t,b mod 10);\n b:=b div 10;\n end;\n if t mod 4=0 then\n break;\n end;\n writeln(a);\nend.\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi\n//cz ak ioi"}, {"source_code": "Var a , i , n1 , tmp : Longint;\n\nFunction tong(n : Longint):Boolean;\nBegin\nWhile n <> 0 do \n Begin\n Inc(tmp , n mod 10);\n n := n div 10;\n End;\nIf tmp mod 4 = 0 then Exit(true) else Exit(False);\nEnd;\n\nbegin\nReadln(a);\nFor i := a to a + 8 do\n Begin\n n1 := i; tmp := 0;\n if tong(n1) then Break;\n End;\nWriteln(n1);\nEnd."}, {"source_code": "Program p1;\nVar\n a,b : Longint;\n\t\nFunction suma_cifre(x:Longint): Longint;\nVar\n suma: Longint;\nBegin\n suma := 0;\n While x > 0 Do {pana cand sunt cifre}\n Begin\n suma := suma + (x Mod 10); {adaugam ultima cifra la suma}\n x := x Div 10; {scoatem ultima cifra din numar}\n End;\n suma_cifre := suma;\nEnd;\n\nFunction suma_cifrelor_se_imaprte_la_patru(x:Longint): Boolean;\nBegin\n suma_cifrelor_se_imaprte_la_patru := (suma_cifre(x) Mod 4) = 0;\nEnd;\n\nBegin\n Readln(a);\n While Not suma_cifrelor_se_imaprte_la_patru(a) Do\n Begin\n a := a+1;\n End;\n Writeln(a);\n If 1 = 2 Then Readln;\nEnd.\n"}, {"source_code": "function is_interesting(i:longint):boolean;\nbegin\n if i < 10 then\n is_interesting:= i mod 4 = 0\n else if (i >= 10) and (i <= 99) then\n is_interesting:= (i div 10 + i mod 10) mod 4 = 0\n else if (i >= 100) and (i <= 999) then\n is_interesting:= (i div 100 + i div 10 mod 10 + i mod 10) mod 4 = 0\n else if i >= 1000 then\n is_interesting:= (i div 1000 + i div 100 mod 10 + i div 10 mod 10 + i mod 10) mod 4 = 0 \nend;\n\nfunction min_interesting(a:longint):longint;\nvar \n i:longint;\n found:boolean;\nbegin\n i:=a;\n found:=false;\n while not found do begin\n found:=is_interesting(i);\n inc(i);\n end;\n min_interesting:=i-1;\nend;\n\nvar a:longint;\nbegin\n read(a);\n writeln(min_interesting(a));\nend."}, {"source_code": "var i,n,ncopy:integer;\nbegin\nreadln(n);\n\nrepeat\nncopy:=n;\ni:=0;\nwhile (ncopy >= 10) do begin\n inc(i,ncopy mod 10);\n ncopy:= ncopy div 10;\nend;\ninc(i,ncopy mod 10);\ninc(n);\nuntil (i mod 4 = 0);\n\nwriteln(n-1);\nend."}, {"source_code": "var\n n,a:integer;\nfunction div4(n:integer): Boolean;\n var s:integer;\nbegin\n s:=0;\n while n>0 do\nbegin\n s:=s+n mod 10;\n n:=n div 10;\nend;\n Result:= s mod 4 =0;\nend;\nbegin\n readln(n);\n a:=n-1;\n repeat\n a:=a+1;\n until div4(a);\n writeln(a);\n readln;\n\nend. "}, {"source_code": "var\n n: integer;\n digit1, digit2: string;\n buffer: integer;\n Ask: boolean;\n\nfunction Summ(digit: string): integer;\nvar\n buffer: integer;\nbegin\n for i: integer := 1 to length(digit) do\n buffer := buffer + StrToInt(digit[i]);\n Summ := buffer;\nend;\n\nbegin\n Ask := false;\n readln(digit1);\n digit2 := digit1;\n while(not Ask) do\n begin\n n := Summ(digit2);\n if n mod 4 = 0 then\n begin\n Ask := true;\n continue;\n end\n else \n begin\n buffer := digit2.ToInteger;\n inc(buffer);\n digit2 := buffer.ToString;\n end;\n end;\n writeln(digit2);\nend."}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..5500000+1] of int64; integer=longint;\nvar dl,len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,mesto,num:longint;\nss,ss1,ss2:string;\nw,pos,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n prost,marked,zan:array[-10..4000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n zzz:array[0..100,0..100] of longint;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..1100,-1..700] of char;\n dd,dchet,dnech,poschet,posnechet:array[-10..1290000,-1..10] of int64;\n poss:int64;\n ch:char;\n flagg1:boolean;\n s,ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-100000..4000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]>a[j])or(a[i]=a[j])and(a1[i]0 do\n\t begin\n\t sum:= sum + n mod 10;\n\t n:= n div 10;\n\t end;\n\tif sum mod 4 = 0 then exit(true);\n\texit(false);\nend;\n\nbegin\n\treadln(a);\n\tn:=a;\n\twhile not check(n) do inc(n);\n\twrite(n);\nend."}, {"source_code": "var\n i,n:longint;\nfunction kt(x:longint):boolean;\nvar sum:longint;\nbegin\n sum:=0;\n While x<>0 do\n begin\n sum:=sum+x mod 10;\n x:=x div 10;\n end;\n If sum mod 4=0 then exit(true) else exit(false);\nend;\nbegin\n readln(n);\n for i:=n to maxlongint do\n if kt(i) then\n begin\n write(i);\n break;\n end;\n\nend.\n\n"}, {"source_code": "Var\n i,n,x,ans,j : longInt;\n s : String;\n\n begin\n\n Readln(n);\n\n for i:=n to 1003 do\n begin\n Str(i,s);\n ans:=0;\n for j:= 1 to length(s) do\n begin\n Val(s[j],x);\n ans:=ans+x;\n end;\n if ans mod 4 = 0 then begin\n writeln(i);\n halt;\n end;\n\n end;\n\n\n end.\n"}, {"source_code": "var n,x:longint;\nfunction stv(n:longint):boolean;\nvar z:longint;\nbegin\n z:=0;\n while n>0 do\n begin\n z:=z+(n mod 10);\n n:=n div 10;\n end;\n if z mod 4=0 then exit(true)\n else exit(false);\nend;\nbegin\n readln(n);\n x:=n;\n while stv(x)<>true do\n begin\n inc(x);\n end;\n write(x);\nend."}, {"source_code": "var x,s,n:longint;\nbegin \n read(n); \n while true do\n begin\n s:=0;\n x:=n;\n while x>0 do begin\n s:=s+x mod 10;\n x:=x div 10\n end;\n if s mod 4=0 then begin write(n);halt; end else inc(n);\n end;\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,so,s:int64;\n st:ansistring;\n i:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n\n assign(f,fo);rewrite(f);\n while (true) do\n begin\n str(n,st);\n so:=0;\n for i:=1 to length(st) do\n begin\n val(st[i],s);\n so:=so+s;\n end;\n if so mod 4=0 then\n begin\n write(f,n);\n break;\n end;\n inc(n);\n end;\n close(f);\nend.\n\n"}, {"source_code": "program hrn;\n var\n m,a,b,c,d:longint;\n begin\n read(m);\n repeat\n a:=m div 1000;\n b:=(m div 100)mod 10;\n c:=(m div 10)mod 10;\n d:=m mod 10;\n if(a+b+c+d)mod 4=0 then write(m)\n else inc(m);\n until(a+b+c+d) mod 4=0;\n readln;\n end."}, {"source_code": "\nvar v:longint; ng:boolean;\nfunction gh(a:longint):longint;\nvar t:string; i,n,bg:integer;\nbegin\nbg:=0;\nstr(a,t);\nfor i:=1 to length(t) do begin val(t[i],n); bg:=bg+n; end;\ngh:=bg;\nend;\nbegin\n\nng:=false;\nreadln(v);\nif (gh(v) mod 4)=0 then begin write(v); ng:=true; end;\nif ng=false then\nbegin\nrepeat\ninc(v);\nuntil (gh(v) mod 4)=0;\nwriteln(v);\nend;\nreadln;\nend.\n\n"}, {"source_code": "function kt(n:word):boolean;\nvar s,du:word;\nbegin\n s:=0;\n while n>0 do\n begin\n du:=n mod 10;\n s:=s+du;\n n:=n div 10;\n end;\n if s mod 4 = 0 then kt:=true else kt:=false;\nend;\nvar n:0..1003;du:0..9;\nbegin\n readln(n);\n while kt(n)=false do n:=n+1;\n write(n);\n readln;\nend.\n"}, {"source_code": "program ppp;\n\n\nvar a,b,s: integer; \n c: string;\n// a,b,k:array of int64;\n cnt: array[1..4] of integer;\n answer: integer;\n\nbegin\n \n readln(a);\n for var i:=0 to 20 do begin\n b:= a+i;\n c:= IntToStr(b);\n s:=0;\n for var j:=1 to Length(c) do \n s:= s + StrToInt(c[j]); \n if s mod 4 = 0 then begin\n writeln(c);\n break;\n end;\n end;\n\nend."}, {"source_code": " var\n \tk, m, n, d, a, a2, a3, b, k2, k3: integer;\n \tflag: boolean = false;\n \ts1, s2: string;\n \t\n begin\n \t\n \treadln(n);\n \t\n \twhile (flag = false) do\n \tbegin\n\t\t\tk := n;\n\t\t\twhile(k > 0) do\n\t\t\tbegin\n\t\t\t\tm += k mod 10;\n\t\t\t\tk := k div 10;\n\t\t\tend;\n\t\t\tif (m mod 4 <> 0) then\n\t\t\tbegin\n\t\t\t\tflag := false;\n\t\t\t\tn += 1;\n\t\t\t\tm := 0;\n\t\t\tend\n\t\t\telse begin\n\t\t\t\tflag := true;\n\t\t\t\twriteln(n);\n\t\t\t\tbreak;\n\t\t\tend;\n \tend;\n \t\n end.\n"}, {"source_code": "var\n a, n, sum: integer;\n\nbegin\n readln(a);\n sum := 1;\n while sum mod 4 <> 0 do\n begin\n sum := 0;\n n := a;\n while n > 0 do\n begin\n sum := sum + (n mod 10);\n n := n div 10;\n end;\n a := a + 1;\n end;\n writeln(a - 1);\nend."}, {"source_code": "var\n digit: string;\n digit2: integer;\nconst\n a: array[1..2] of char = ('4', '7');\n \nfunction GoodDigit(n: string): boolean;\nvar buffer: integer;\nbegin\n for i: integer := 1 to length(n) do\n buffer := buffer + StrToInt(n[i]);\n \n if (buffer mod 4 = 0) then GoodDigit := true\n else GoodDigit := false;\nend;\n \nbegin\n readln(digit);\n digit2:= digit.ToInteger;\n while(not GoodDigit(digit)) do\n begin\n inc(digit2);\n digit := digit2.ToString;\n end;\n writeln(digit);\nend."}, {"source_code": "var a,j,sum:integer;\n a_str:string;\nbegin\nread(a);\na_str:=IntToStr(a);\nfor var i:=1 to length(a_str) do\n sum:=sum+StrToInt(a_str[i]); \nwhile sum mod 4 <> 0 do\n begin\n a:=a+1;\n a_str:=IntToStr(a);\n sum:=0;\n for var i:=1 to length(a_str) do\n begin\n sum:=sum+StrToInt(a_str[i]); \n end;\n end;\nwriteln(a);\nend."}, {"source_code": "//fpc 3.0.0\n\nprogram one; \nvar n : integer;\nvar x : integer;\nvar sum : integer;\nbegin\n read(n);\n while True do begin\n x := n;\n sum := 0;\n while x > 0 do begin\n sum := sum + (x mod 10);\n x := x div 10;\n end;\n if (sum mod 4) = 0 then\n begin\n writeln(n);\n break;\n end; \n n := n + 1;\n end;\nend."}, {"source_code": " function summ(a:uint64):uint64;\n var s:string; sum,i:uint64;\n begin\n s:=inttostr(a);\n for i:=1 to length(s) do\n sum:=sum+strtoint(s[i]);\n summ:=sum;\n end;\n var a,n:uint64;\n begin\n read(a);\n if summ(a) mod 4=0 then n:=a \n else\n begin\n repeat \n a:=a+1;\n until summ(a) mod 4=0;\n n:=a;\n end;\n write(n);\n end."}, {"source_code": "program znlatai;\nuses wincrt;\nvar \nn , m , T ,i:integer;\nch:string;\nbegin\n\tread(n);\n\trepeat\n\tstr(n,ch);\n\tt:=0;\n\tfor i:=1to length(ch) do\n\tbegin\n\tval(ch[i],m);\n\tT:=T+m\nend;\nif t mod 4=0 then write(n)\nelse n:=n+1\nuntil T mod 4 = 0\nEND."}, {"source_code": "Var\n n: Integer;\n\nBegin\n Read(n);\n While True do\n If ((n mod 10 + n div 10 mod 10 + n div 100 mod 10 + n div 1000) mod 4 = 0) then Begin\n Write(n);\n Exit\n End\n Else \n n += 1\nEnd."}, {"source_code": "function sumd(x : longint) : longint;\nbegin\n var s : longint;\n s := 0;\n \n while x > 0 do begin\n s := s + (x mod 10);\n x := x div 10;\n end;\n \n sumd := s;\nend;\n\nbegin\n var a, n : longint;\n read(a);\n \n while True do begin\n n := sumd(a);\n if n mod 4 = 0 then\n break;\n inc(a);\n end;\n \n write(a);\nend.\n "}, {"source_code": "var\na,s,n:integer;\nBegin\nreadln(a);\nn:=a;\ns:=1;\nwhile (s mod 4<>0) do\nbegin\ns:=0;\na:=n;\nn:=n+1;\nwhile a>0 do\nbegin\ns:=s+(a mod 10);\na:=a div 10;\nend;\nend;\nwriteln(n-1);\nEnd."}, {"source_code": "Program ILoveYou;\nVAR n,i,s,aux:int64;\nBegin\n\nReadln(n);\ns:=1;\nwhile ((s mod 4) <> 0) do\nBegin\n\ns:=0;\naux:=n;\nwhile (aux > 0) do\nBegin\ns:=s + (aux mod 10);\naux:=aux div 10;\nend;\n\nif ((s mod 4) = 0) then Writeln(n);\nn:=n + 1;\n\nend;\n\nReadln;\nEND."}, {"source_code": "var\n n, k, i, h: integer;\n s, l: string;\n\nbegin\n readln(n);\n l := '123456789';\n while k = 0 do\n begin\n h := 0;\n str(n, s);\n for i := 1 to length(s) do\n h := h + pos(s[i], l);\n if h mod 4 = 0 then\n k := n\n else\n n := n + 1;\n end;\n write(k);\nend."}, {"source_code": "var x, x1, s: integer;\nbegin\nread(x);\nx1:=x;\nwhile true do\nbegin\nwhile x<>0 do\n begin\n s+=x mod 10;\n x:= x div 10;\n end;\n if s mod 4 = 0 then break\n else \n begin\n s:=0;\n x1+=1;\n x:=x1;\n end;\n end;\n write(x1);\nend."}, {"source_code": "var fl,a,n,i,c:integer;\n begin\n Readln(a);\n n:=a;\n fl:=0;\n while n<>0 do begin\n N:=n div 10;\n fl:=fl+1;\n end;\n n:=a;\n c:=5;\n While c mod 4<>0 do begin\n N:=a;\n c:=0;\n fl:=0;\n while n<>0 do begin\n N:=n div 10;\n fl:=fl+1;\n end;\n N:=a;\n For i:=1 to fl do begin\n c:=c+(n mod 10);\n N:=n div 10;\n end;\n If c mod 4 <> 0 then a:=a+1;\n End;\n Writeln(a);\n end."}, {"source_code": "var n,k,a,s,i: longint;\nbegin\nread(a);\nfor i:=a to 1003 do begin\nk:=i; s:=0;\nwhile k>0 do begin\ns:=s+k mod 10; k:=k div 10;\nend;\nif s mod 4 = 0 then \nbegin\nwrite(i); halt end;\nend;\nend."}, {"source_code": "Var n,a,i,b,j,c:longint;\nbegin\nReadln(a); \nc:=a; b:=c+8;\nWhile (b<>c) do\nbegin\nWhile a<>0 do\n begin\n j:=(a mod 10)+j;\n a:=a div 10;\n \n end;\n If j mod 4=0 then begin writeln(c); exit; end else begin c:=c+1; a:=c; j:=0; \n end;\n\n end;\n end.\n \n "}, {"source_code": "var\n a,n,o,s,k:longint;\nbegin\n readln(a);\n s:=1;\n n:=a;\n while((s mod 4)<>0) do begin\n n:=a+k;\n s:=0;\n while(n<>0) do begin\n o:=n mod 10;\n n:=n div 10;\n s:=s+o;\n end;\n k:=k+1;\n end;\n write(a+k-1);\nend.\n \n "}, {"source_code": "var n,x,i,p,s,m:integer;l:boolean;\nbegin\nreadln(n);\nl:=true;m:=n;\nwhile l do\nbegin\ns:=0;\nWhile n>0 do\nbegin\nx:=n mod 10;\ns:=s+x;\nn:=n div 10;\nend;\nif s mod 4 =0 then begin p:=m; l:=false;end;\nm:=m+1;n:=m;\nend;\nwrite(p);\nend.\n"}, {"source_code": "var n,i,x:longint; s:string;\nbegin\nreadln(n);\nwhile true do\n begin\n str(n,s);\n x:=0;\n for i:=1 to length(s) do x:=x+ord(s[i])-48;\n if x mod 4=0 then break;\n inc(n);\n end;\nwriteln(n);\nend."}, {"source_code": "var number, m, sum: longint;\n check: boolean;\n f1, f2: text;\nconst fi = '';\n fo = '';\n{=================================================}\nprocedure Input;\nbegin\n assign(f1, fi); reset(f1);\n readln(f1, number);\n close(f1);\nend;\n{=================================================}\nprocedure Output;\nbegin\n assign(f2, fo); rewrite(f2);\n check := false;\n number := number - 1;\n repeat\n inc(number);\n m := number;\n sum := 0;\n while (m <> 0) do\n begin\n sum := sum + (m mod 10);\n m := m div 10;\n end;\n if (sum mod 4 = 0) then check := true;\n until check = true;\n writeln(f2, number);\n close(f2);\nend;\n{=================================================}\nbegin\n Input;\n Output;\nend.\n{==================================================}\n\n"}, {"source_code": "Program Acodeforces10;\n//uses crt;\nvar n,cnt,s,i,sum :longint;\n f:text;\n//----------------------------\nbegin\n//clrscr;\nassign(f,'');\nreset(f);\nreadln(f,n);\ncnt:=0;\ns:=n+cnt;\nWhile s>0 do begin\n sum:=sum+s mod 10;\n s:=s div 10;\n end;\nif sum mod 4=0 then Writeln(n) else begin\nWhile sum mod 4>0 do begin\n inc(cnt);\n sum:=0;\n s:=n+cnt;\n While s>0 do begin\n sum:=sum+s mod 10;\n s:=s div 10;\n end;\n end;\nWriteln(n+cnt);\nend;\n//readln;\nend.\n"}, {"source_code": "var a:longint;\nfunction sumcs(n:longint):longint;\nvar i,k,sum:longint;\n x:ansistring;\n code:integer;\nbegin\nsum:=0;\nstr(n,x);\nfor i:=1 to length(x) do\n begin\n val(x[i],k,code);\n sum:=sum+k;\n end;\nsumcs:=sum;\nend;\nprocedure chuongtrinh;\nbegin\nread(a);\nwhile sumcs(a) mod 4<>0 do inc(a);\nwrite(a);\nend;\nBEGIN\n chuongtrinh;\nEND.\n"}, {"source_code": "var \nn,i:longint;\nfunction check(n:longint):boolean;\nvar s:longint;\nbegin\n s:=0;\n while n<> 0 do\n begin\n s:=s+(n mod 10);\n n:=n div 10;\n end;\n if s mod 4 = 0 then exit(true)\n else exit(false);\nend;\nprocedure nhap;\nbegin\n readln(n);\n while check(n) = false do\n begin\n inc(i);\n n:=n+1;\n end;\n write(n);\nend;\nbegin\n nhap;\nend."}, {"source_code": "function c4(n:integer) :boolean;\nvar kt,ktt :integer;\nbegin\n ktt:=0; kt:=n; c4:=false;\n while kt<>0 do\n begin\n ktt:=ktt+(kt mod 10);\n kt:=kt div 10;\n end;\n if ktt mod 4=0 then c4:=true;\nend;\n\nvar n,a :integer;\nBEGIN\n read(a);\n while (c4(a))=false do inc(a);\n write(a);\n\nEND."}, {"source_code": "var n,s,p,i,k:longint;\nbegin\nreadln(n);\nfor i:=n to 100000 do\nbegin\np:=i; s:=0;\nrepeat\nk:=p mod 10;\ns:=s+k;\np:=p div 10;\nuntil(p=0);\nif s mod 4=0 then begin write(i);exit;end;\nend;\nend.\n"}], "negative_code": [{"source_code": "Var\n n, Sum: Integer;\n \nBegin\n Read(n);\n Sum := n mod 10 + n div 10 mod 10 + n div 100 mod 10 + n div 1000;\n While Sum mod 4 <> 0 do Begin\n n+=1;\n Sum+=1;\n End;\n Write(n)\nEnd."}, {"source_code": "Var n,a,i,b,j,c:longint;\nbegin\nReadln(a); \nc:=a; b:=c+5;\nWhile (b<>c) do\nbegin\nWhile a<>0 do\n begin\n j:=(a mod 10)+j;\n a:=a div 10;\n \n end;\n If j mod 4=0 then begin writeln(c); exit; end else begin c:=c+1; a:=c; j:=0; \n end;\n\n end;\n end.\n \n "}, {"source_code": "program chislaoa2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j, m, i1: integer;\n a: array [0..300000] of integer;\n\nbegin\n readln(n);\n j := n;\n m := 0;\n while (j<>0) do begin\n m := m + j mod 10;\n j := j div 10;\n end;\n if (m mod 4 = 0) then\n writeln(n)\n else\n writeln(n - m mod 4 + 4);\n readln;\nend.\n"}, {"source_code": "program chislaoa1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j, m, i1: integer;\n a: array [0..300000] of integer;\n\nbegin\n readln(n);\n j := n;\n m := 0;\n while (j<>0) do begin\n m := m + j mod 10;\n j := j div 10;\n end;\n if (m mod 4 = 0) then\n writeln(n)\n else\n writeln(n + ((m mod 4) + 4));\n readln;\nend.\n"}, {"source_code": "program chislaoa2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j, m, i1: integer;\n a: array [0..300000] of integer;\n\nbegin\n readln(n);\n j := n;\n m := 0;\n while (j<>0) do begin\n m := m + j mod 10;\n j := j div 10;\n end;\n j := n;\n while (m mod 4 <> 0) do begin\n j := j - m mod 4 + 4;\n n := j;\n m := 0;\n while (j<>0) do begin\n m := m + j mod 10;\n j := j div 10;\n end;\n j := n;\n end;\n writeln(j);\n readln;\nend.\n"}, {"source_code": "var a,b,c,d,i,s:integer;\n\nbegin\nreadln(a);\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\n\nfor i:=1 to 10 do\nbegin\ns:=b+c+d;\nIf((s mod 4) = 0) then\nbegin\na:=b+c*10+d*100;\nwriteln(a);\nBreak;\nend;\na:=a+1;\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\nend;\n\nend."}, {"source_code": "var a,b,c,d,i,s:integer;\n\nbegin\nreadln(a);\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\n\nfor i:=1 to 5 do\nbegin\ns:=b+c+d;\nIf((s mod 4) = 0) then\nbegin\na:=b+c*10+d*100;\nwriteln(a);\nBreak;\nend;\na:=a+1;\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\nend;\n\nend."}, {"source_code": "var a,b,c,d,i,s:integer;\n\nbegin\nreadln(a);\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\n\nfor i:=1 to 4 do\nbegin\ns:=b+c+d;\nIf((s mod 4) = 0) then\nbegin\na:=b+c*10+d*100;\nwriteln(a);\nBreak;\nend;\na:=a+1;\nb:=a mod 10;\nc:=a div 10 mod 10;\nd:=a div 100;\nend;\n\nend."}, {"source_code": "program interesting_number;\nvar v:longint;\nfunction gh(a:longint):longint;\nvar t:string; i,n,bg:integer;\nbegin\nbg:=0;\nstr(a,t);\nfor i:=1 to length(t) do begin val(t[i],n); bg:=bg+n; end;\ngh:=bg;\nend;\nbegin\nreadln(v);\nif (gh(v) mod 4)=0 then write(v)\nelse\nrepeat\ninc(v);\nuntil (gh(v) mod 4)=0;\nwrite(v);\nreadln;\nend.\n\n"}, {"source_code": "\nvar v:longint; ng:boolean;\nfunction gh(a:longint):longint;\nvar t:string; i,n,bg:integer;\nbegin\nbg:=0;\nstr(a,t);\nfor i:=1 to length(t) do begin val(t[i],n); bg:=bg+n; end;\ngh:=bg;\nend;\nbegin\n\nng:=false;\nreadln(v);\nif (gh(v) mod 4)=0 then begin write(v); ng:=true; end;\nif ng=false then\nrepeat\ninc(v);\nuntil (gh(v) mod 4)=0;\nreadln;\nend.\n\n"}, {"source_code": "var n,s,p,i,k:longint;\nbegin\nreadln(n);\nfor i:=n to 1000 do\nbegin\np:=i; s:=0;\nrepeat\nk:=p mod 10;\ns:=s+k;\np:=p div 10;\nuntil(p=0);\nif s mod 4=0 then begin write(i);exit;end;\nend;\nend.\n"}, {"source_code": "var\n s : string;\n a,i,j,n,m,k : longint;\nbegin\n readln(s);\n val(s,k,m);\n for i := 1 to length(s) do\n begin\n val(s[i],n,m);\n a := a+n;\n end;\n for i := 0 to 3 do\n if ((a+i) mod 4 = 0) then\n writeln(k+i);\nend."}, {"source_code": "var n,a,s,dem,b :integer;\nBEGIN\n read(a); s:=0; b:=a;\n while a<>0 do\n begin\n s:=s+ (a mod 10);\n a:=a div 10;\n end;\n while (s mod 4)<>0 do\n begin\n inc(s); inc(dem);\n end;\n write(b+dem);\n\nEND."}, {"source_code": "var a,n:integer;\nfunction gt(a:integer):longint;\nvar n:integer;\nbegin\n n:=0;\n while a > 0 do \n begin \n n:=n+ a mod 10;\n a:= a div 10;\n end;\n gt:=n;\nend;\nbegin\n readln(a);\n repeat inc(a) until gt(a) mod 4 =0;\n write(gt(a));\nend."}, {"source_code": "var a,n:integer;\nfunction gt(a:integer):longint;\nvar n:integer;\nbegin\n n:=0;\n while a > 0 do \n begin \n n:=n+ a mod 10;\n a:= a div 10;\n end;\n gt:=n;\nend;\nbegin\n readln(a);\n repeat inc(a) until gt(a) mod 4 =0;\n write(a);\nend."}, {"source_code": "var a,n:integer;\nfunction gt(a:integer):longint;\nvar n:integer;\nbegin\n n:=0;\n while a > 0 do \n begin \n n:=n+ a mod 10;\n a:= a div 10;\n end;\n gt:=n;\nend;\nbegin\n readln(a);\n repeat inc(a) until gt(a) mod 4 =0;\nend."}, {"source_code": "var a,n:integer;\nbegin\n readln(a);\n n:= a;\n while n mod 4 <> 0 do inc(n);\n write(n);\nend."}, {"source_code": "var a,n,i,tcs:integer;\nBEGIN\n read(a);tcs:=1;\n while tcs mod 4 <> 0 do\n Begin\n i:=a;\n while i <> 0 do\n Begin\n n:=i mod 10;\n tcs:=tcs+n;\n i:=i div 10;\n End;\n inc(a);dec(tcs);\n end;\n write(a);\nEND.\n"}], "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7"} {"source_code": "var s:string;\ni,x,y:longint;\nbegin\n//assign(input,'lianjiez.in');reset(input);\n//assign(output,'lianjiez.out');rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='o' then inc(x)\n else inc(y);\nif x<2 then writeln('YES')\nelse if y mod x=0 then writeln('YES')\nelse writeln('NO');\nclose(input);close(output);\nend.", "positive_code": [{"source_code": "var s:string;\n i,xo,x:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='o' then inc(xo)\n else inc(x);\n if xo=0 then write('YES')\n else if x mod xo=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var\nb,ch,i:longint;\ns:string;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(ch) else inc(b);\n if b=0 then write('YES') else\n if b=1 then write('YES') else\n if ch mod b=0 then write('YES') else write('NO');\nend."}, {"source_code": "\nvar a,b:integer;\n s:char;\n\nBEGIN\n\ta:=0;\n\tb:=0;\n\twhile not eoln do\n\tbegin\n\t\tread(s);\n\t\tif s='-' then inc(a) else inc(b);\n\tend;\n\tif (b = 0) then write('YES') else \n\t\tif (a mod b = 0) then write('YES') else write('NO');\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,c1,c2:longint;\n st:string;\n begin\n readln(fi,st);\n c1:=0;\n c2:=0;\n for i:=1 to length(st) do if st[i]='o' then inc(c1) else inc(c2);\n if (c1=0) or (c2 mod c1=0) then writeln(fo,'YES')\n else writeln(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var s:ansistring;\n i,a,b:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='o' then\n inc(a)\n else\n inc(b);\n if (a=0)or(b mod a=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var x,i,y:longint;s:ansistring;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\n if (s[i]='o') then\n inc(x)\n else\n if (s[i]='-') then\n inc(y);\n if x=0 then writeln('YES')\n else if (y mod x=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s:string;\n i,l,ans1,ans2:longint;\nbegin\n read(s);\n l:=length(s);\n for i:=1 to l do\n begin\n if s[i]='-' then inc(ans1);\n if s[i]='o' then inc(ans2);\n end;\n if ans2<>0 then begin\n if ans1 div ans2=ans1/ans2 then write('YES')\n else write('NO');\n end\n else write('YES');\nend."}, {"source_code": "var\ni,xo,x:longint;\ns:string;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='o' then inc(xo)\n else inc(x);\nif xo=0 then write('YES')\n else if x mod xo=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var\n i,j,k,t,m,n,x,y:longint;\n s1:string;\n num1,num2:longint;\nbegin\n readln(s1);\n m:=length(s1);\n for i:=1 to m do\n if (s1[i]='o') then inc(num1)\n else inc(num2);\n if (num1=0)or(num1=1) then begin writeln('YES'); halt; end;\n if num2 mod num1=0 then writeln('YES') else writeln('NO'); \nend.\n"}, {"source_code": "var s:string;\n i,xo,x:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='o' then inc(xo)\n else inc(x);\n if xo=0 then write('YES')\n else if x mod xo=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var s:string;i,xo,x:longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do if s[i]='o' then inc(xo)else inc(x);\nif xo=0 then writeln('YES')else if x mod xo=0 then writeln('YES')else writeln('NO');\nend."}, {"source_code": "var\n st:string;\n i,a,b:longint;\nbegin\n readln(st);\n for i:=1 to length(st) do\n if st[i]='-' then inc(b)\n else inc(a);\n if (a=0)or(b mod a=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": " var i,j,k1,k2:longint;\n c:char;\n begin\n while not eoln do\n begin\n read (c);\n if c='-' then inc (k1)\n else inc (k2);\n\n end;\n\n if k2 = 0 then writeln ('YES')\n else\n if k1 mod k2 = 0 then writeln ('YES')\n else writeln ('NO');\n\n\n\n\n\n\n\n\n\n\n\n end."}, {"source_code": "Program LinksAndPearls;\nuses math;\nvar s:string; i:longint; t1,t2:byte;\nbegin //assign(input,'980A.inp'); reset(input);\n //assign(output,'980A.out'); rewrite(output);\n readln(s);\n t1:=0; t2:=0;\n for i:=1 to length(s) do\n if s[i]='o' then t1:=t1+1\n else t2:=t2+1;\n if (t1=0) or (t2=0) then writeln('YES')\n else if t2 mod t1=0 then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend.\n"}, {"source_code": "Program z1;\nvar s:string;\n i,n,b:integer;\nbegin\nread(S);\nfor i:=1 to length(s) do\nif S[i]='-' then n:=n+1 \n else b:=b+1;\nif (n=0)or(b=0) then write('YES')\n else \nif n mod b=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var\n s:string;\n ans1,ans2,i:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='o' then inc(ans1);\n if s[i]='-' then inc(ans2);\n end;\n if ans1=0 then writeln('YES')\n else if ans2 mod ans1=0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "Var x : Char;\n k,kk : LongInt;\n begin\n while not EoLn do\n begin\n Read(x);\n if x = '-' then inc(k);\n if x = 'o' then inc(kk);\n end;\n if (kk>0) and (k mod kk = 0) then writeln('YES')\n else begin\n if kk=0 then writeln('YES')\n else writeln('NO');\n end;\n end."}, {"source_code": "const fi='';\n fo='';\nvar s:widestring;\n f:text;\n i,j,n,m:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n close(f);\nend;\nprocedure xuli;\nbegin\n assign(f,fo);\n rewrite(f);\n n:=0;m:=0;\n for i:=1 to length(s) do\n if s[i]='-' then inc(n) else inc(m);\n if (n=0)or(m=0) then writeln(f,'YES') else\n if (n mod m=0) then writeln(f,'YES') else\n writeln(f,'NO');\n close(f);\nend;\nbegin\n nhap;\n xuli;\nend.\n\n"}, {"source_code": "const\n sfi='';\n maxn=10000;\n\nvar\n n,c1,c2,i:longint;\n s:ansistring;\n a:array[0..maxn] of int64;\n fi:text;\n\nprocedure popen;\n begin\n assign(fi,sfi); reset(fi);\n end;\n\nprocedure pclose;\n begin\n close(fi);\n end;\n\nbegin\npopen;\n readln(fi,s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(c1)\n else inc(c2);\n if c2=0 then write('YES')\n else\n if c1 mod (c2)=0 then write('YES')\n else write('NO');\npclose;\nend."}, {"source_code": "var s,s1:string; o:longint;\nbegin\nreadln(s);\n s1:=s;\n while pos('o',s1)>0 do\n begin\n inc(o);\n delete(s1,pos('o',s1),1);\n end;\nif o=0 then writeln('YES')\nelse\nif(length(s)-o)mod o=0 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var\n st:ansistring;\n i,a,b:longint;\nbegin\n readln(st);\n for i:=1 to length(st) do\n if st[i]='-' then inc(b)\n else inc(a);\n if (a=0)or(b mod a=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s:ansistring;\n i,a,b:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='o' then\n inc(a)\n else\n inc(b);\n if (a=0)or(b mod a=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n s:ansistring;\n i,a,b:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(a) else inc(b);\n if (b=0) or (a mod b=0) then write('YES') else write('NO');\nend."}, {"source_code": "var s:string;i,x,y:longint;\nbegin\n//assign(input,'lianjiez.in');reset(input);\n//assign(output,'lianjiez.out');rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='o' then x:=x+1 else y:=y+1;\nif(x<=1)or(y mod x=0)then writeln('YES') else writeln('NO');\nclose(input);close(output);\nend."}, {"source_code": "var s:ansistring;\nx1,x2,i:longint;\nbegin\n//assign(input,'lianjiez.in');reset(input);\n//assign(output,'lianjiez.out');rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='-' then x1:=x1+1\nelse x2:=x2+1;\nif(x2<=1)then writeln('YES')\nelse if x1 mod x2=0 then writeln('YES')\nelse writeln('NO');\nclose(input);close(output);\nend."}, {"source_code": "var s:string;x,y,i:longint;\nbegin\n//assign(input,'lianjiez.in');reset(input);\n//assign(output,'lianjiez.out');rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='o' then\n inc(x)\n else inc(y);\nif x=0 then writeln('YES')\nelse if y mod x=0 then writeln('YES')\nelse writeln('NO');\nclose(input);close(output);\nend."}, {"source_code": "var\nX,I:LONGINT;\nS:ANSISTRING;\nbegin\n// assign(input,'lianjiez.in');reset(input);\n // assign(output,'lianjiez.out');rewrite(output);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='o' then x:=x+1;\n end;\n if x=0 then writeln('YES')\n ELSE IF ((LENGTH(S)-X) MOD X=0) THEN WRITELN('YES') ELSE WRITELN('NO');\n close(input);\n close(output);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar a,b: longint;\n\nprocedure input;\nvar f:text;\n c: char;\n\nbegin\n a:=0;\n b:=0;\n assign(f,fi);\n reset(f);\n while(not(eoln(f))) do\n begin\n read(f,c);\n if(c='-') then inc(a) else inc(b);\n end;\n close(f);\nend;\nprocedure output;\nvar f:text;\nbegin\n assign(f,fo);\n rewrite(f);\n if ((a=0)or(b=0)) then write(f,'yes')\n else if (a mod b = 0) then write(f,'yes')\n else write(f,'no');\n close(f);\nend;\nbegin\n input;\n output;\nend.\n"}, {"source_code": "var\n s:ansistring;\n i,j,n,m,k,a,b:longint;\n begin\n read(s);\n for i:=1 to length(s) do\n begin\n if s[i]='o' then inc(a);\n if s[i]='-' then inc(b);\n end;\n if a=0 then write('YES') else\n if b mod a=0 then write('YES') else write('NO');\n end."}, {"source_code": "var\n s:ansistring;\n i,a,b:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(a) else inc(b);\n if (b=0) or (a mod b=0) then write('YES') else write('NO');\nend."}, {"source_code": "var s:string;\n i,xo,x:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='o' then inc(xo)\n else inc(x);\n if xo=0 then write('YES')\n else if x mod xo=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var\n i,j,x,y:longint;\n s:string;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='o' then inc(x);\n if s[i]='-' then inc(y);\n end;\n if x=0 then write('YES') \n else\n if y mod x=0 then write('YES')\n else write('NO');\nend."}, {"source_code": "var\n st:string;\n i,a,b:longint;\nbegin\n readln(st);\n for i:=1 to length(st) do\n if st[i]='-' then inc(b)\n else inc(a);\n if (a=0)or(b mod a=0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "program A;\n var c: char;\n var l, o: byte;\n\n\nbegin\n l:=0;\n o:=0;\n while not eoln do\n begin\n read(c);\n if c='-' then inc(l)\n else if c='o' then inc(o);\n end;\n if o=0 then write('YES')\n else if (l mod o)=0 then write('YES')\n else write('NO');\n\nend."}, {"source_code": "program slb;\nvar i,j,k,m,n:longint;s:ansistring;\nbegin\n readln(s);\n m:=0;n:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='o' then inc(m)\n else inc(n);\n end;\n if m=0 then\n begin\n writeln('YES');\n exit;\n end;\n if n mod m=0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "Var\n s: string;\n vt,l,p: integer;\n\nBegin\n readln(s);\n vt:=pos('o',s);\n l:=length(s);\n while vt<>0 do\n begin\n inc(p);\n delete(s,vt,1);\n vt:=pos('o',s);\n end;\n l:=l-p;\n if p=0 then\n begin\n writeln('yes');\n exit;\n end;\n if l mod p=0 then writeln('yes') else writeln('no');\nEnd.\n"}, {"source_code": "var\n n,i,j,k,m : longint;\n s: string;\nbegin\n readln(s);\n \n for i := 1 to Length(s) do\n begin\n if s[i] = 'o' then\n inc(n);\n if s[i] = '-' then\n inc(m);\n end;\n if n = 0 then\n writeln('YES')\n else\n begin\n if (m mod n) = 0 then\n writeln('YES')\n else\n writeln('NO');\n end;\n \nend."}, {"source_code": "var\ns:string;\ni,min,bus:longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do begin\n if s[i]='-' then inc(min);\n if s[i]='o' then inc(bus);\nend;\nif (bus = 0 ) or (min=0) then writeln('YES')\nelse begin\n if min mod bus= 0 then writeln('YES')\n else\n writeln('NO');\nend;\nend."}, {"source_code": "var\n s:string;\n a,b,i:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='-' then a:=a+1\n else b:=b+1;\n end;\n if(b=0)or(a mod b=0)then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n\tn, m, r, x, y, z: longint;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tfor var i := 1 to s.length do\n\tbegin\n\t\tif (s[i] = '-') then\n\t\t\tr += 1\n\t\telse \n\t\t\tx += 1;\n\tend;\n\t\n\t//writeln(x, ' ', r);\n\tif (x = 0) or (r = 0) then\n\t\twriteln('YES')\n\telse if (r mod x = 0) or (r = x) or (x = 1) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var\n v,t,i,j,n,m:int64;\n s:string;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(v) else inc(t);\n if t=0 then writeln('YES') else\n if v mod t=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Var\n nB, nN: Int64;\n S: String;\n\nBegin\n Readln(S);\n For Var i := 1 to Length(S) do\n If S[i] = 'o' then\n nB += 1\n Else\n nN += 1;\n If (nB = 0) or (nN mod nB = 0) then\n Write('Yes')\n Else\n Write('No')\nEnd."}, {"source_code": "var s:string;\nn,k,i:integer;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\nif s[i]='o' then n+=1 else k+=1;\nif n=0 then writeln('YES') else\nif (k mod n = 0) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program boosenka;\nvar s:string; n,count:integer;\nbegin\nread(s);\nfor count:=1 to length(s) do\nif copy(s,count,1)='o' then n:=n+1;\nif n=0 then writeln('YES')\nelse\nif length(s)mod n=0 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "VAR\ns:string;\ni,T,B:longint;\n\nBEGIN\nreadln(s);\nfor i:=1 to length(s) do\n if S[i]='-' then inc(T) else inc(B);\nif B<2 then write('YES') else \nif T mod B = 0 then write('YES') else \nwrite('NO');\nEND."}, {"source_code": "program p1 ;\nvar a,b,i,n,m:integer;\n s:string;\n begin \n readln (s);\n for i:=1 to length(s) do begin \n if s[i]='-' then inc(a);\n if s[i]='o' then inc(b);\n end;\n if b=0 then writeln ('YES') else\n if (a mod b =0) or(a=0) or (b=1) then writeln ('YES') else begin writeln ('NO') end;\n end.\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=600000;\n besk=8000000000000000000;\n label 1,2,3,4;\n type real=extended; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pos1,pos2,ost,ot,aa,bb,cc,p1,p2,p3,p4,k,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,time,x0,modul,pos,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,n,m,s,smin,cen,dl,i1:int64;\n step1, step, i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n vv,znak,ll:int64;\n name,d,dnew, voltay,l,r,c,z,day,b,a:array[-200000..1600000] of int64;\n zz:array[0..125000000] of byte;\n gr,pole:array[-10..1002,-10..1005] of char;\n ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1101,-10..1010] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss2:string;\n newnabor,stoim,nabor:array[-10..200005] of int64;\n zan,fl:array[-100..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n s2,s1:array[-100..200000] of string;\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[-10..nn] of string;\n xx,yy,vel,x1,y1,ott,v0,v1,s0,t0:extended;\n zv:point;\n ugol,rr,yc,xc,y,rot,x,temp,sumtemp,vol,newx,newy:array[-10..400000] of extended;\n sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(ss);\n n:=length(ss);\n for i:=1 to n do if ss[i]='o' then inc(p);\n if p=0 then begin write('YES'); goto 1; end;\n if n mod p=0 then begin write('YES'); goto 1; end;\n write('NO');\n\n\n\n 1: close(output);\nend.\n"}], "negative_code": [{"source_code": "var\n\tn, m, r, x, y, z: longint;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tfor var i := 1 to s.length do\n\tbegin\n\t\tif (s[i] = '-') then\n\t\t\tr += 1\n\t\telse \n\t\t\tx += 1;\n\tend;\n\t\n\tif (x = 0) or (y = 0) then\n\t\twriteln('YES')\n\telse if (r mod x = 0) or (r = x) or (x = 1) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var\n\tn, m, r, x, y, z: longint;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tfor var i := 1 to s.length do\n\tbegin\n\t\tif (s[i] = '-') then\n\t\t\tr += 1\n\t\telse \n\t\t\tx += 1;\n\tend;\n\t\n\tif (r = x * 2) or (x = 0) or (r = 0) or (r = x) or (x = 1) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var\n\tn, m, r, x, y, z: longint;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tfor var i := 1 to s.length do\n\tbegin\n\t\tif (s[i] = '-') then\n\t\t\tr += 1\n\t\telse \n\t\t\tx += 1;\n\tend;\n\t\n\tif (r = x * 2) or (x = 0) or (r = 0) or (r = x) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var s:string;\nn,k,i:integer;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\nif s[i]='o' then n+=1 else k+=1;\nif n=0 then writeln('NO') else\nif (k mod n = 0) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program boosenka;\nvar s:string; n,count:integer;\nbegin\nread(s);\nfor count:=1 to length(s) do\nif copy(s,count,1)='o' then n:=n+1;\nif n<>0 then\nbegin\nif length(s)mod n=0 then writeln('YES')\nelse writeln('NO');\nend;\nend."}, {"source_code": "begin\n write('YES');\nend."}, {"source_code": "var\n s:string;\n i,a,b:integer;\nbegin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='-' then inc(a) else inc(b);\n if (a=0) or (b mod a=0) then write('YES') else write('NO');\nend."}, {"source_code": "Program z1;\nvar s:string;\n i,n,b:integer;\nbegin\nread(S);\nfor i:=1 to length(s) do\nif S[i]='-' then n:=n+1 \n else b:=b+1;\nif (n=0)or(b=0) then write('YES')\n else \nif (b mod n=0)or(n mod b=0) then write('YES')\n else write('NO');\nend."}, {"source_code": "Var x : Char;\n k,kk : LongInt;\n begin\n while not EoLn do\n begin\n Read(x);\n if x = '-' then inc(k);\n if x = 'o' then inc(kk);\n end;\n if (kk>0) and (k mod kk = 0) then writeln('YES')\n else writeln('NO')\n end."}, {"source_code": "var\n s:ansistring;\n i,j,n,m,k,a,b:longint;\n begin\n read(s);\n for i:=1 to length(s) do\n begin\n if s[i]='-' then inc(a);\n if s[i]='o' then inc(b);\n end;\n if a=0 then write('YES') else\n if b mod a=0 then write('YES') else write('NO');\n end."}, {"source_code": "var s:string;\n i,s1,s2:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do if s[i]='-' then s1:=s1+1 else s2:=s2+1; \n if (s1-1) mod s2=0 then write('YES')\n else write('NO');\nend."}], "src_uid": "6e006ae3df3bcd24755358a5f584ec03"} {"source_code": "uses Math;\ntype mass=array['A'..'Z'] of int64;\nVar res,mn,a,b,c,d,x,y,n,k,ans,u,l,b1,r,a1:int64;\n m:mass;\n i,j,z:longint;\n s:string;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(a,b);\n for i:=1 to 10000000 do\n if (i mod 2<>0) and (i mod 3<>0)\n then continue\n else Begin\n c:=a-(i div 2-i div 6);\n d:=b-(i div 3-i div 6);\n if (c<=0) and (d<=0)\n then begin\n res:=i;\n break;\n end;\n if (c<=0)\n then if i div 3>=b\n then Begin\n res:=i;\n break;\n end\n else continue;\n if (d<=0)\n then if i div 2>=a\n then Begin\n res:=i;\n break;\n end\n else continue;\n if (i div 6>=c+d)\n then Begin\n res:=i;\n break;\n end;\n end;\n writeln(res);\nend.", "positive_code": [{"source_code": "\nvar\nn,m,i,j,k:longint;\nbegin\nreadln(n,m);\ni:=N*2;\nj:=m*3;\nk:=1;\nwhile(k*6<=i) do begin\nif j>=k*6\nthen begin\nif i+2j\nthen writeln(i)\nelse writeln(j);\nend.\n\n"}, {"source_code": "uses math;\nvar kd,kt:int64;\n i:longint;\n\nbegin\nreadln(kd,kt);\n\nfor i:=2 to 5555555 do\n begin\n if (kd=0)and(kt=0) then break;\n\n if (i mod 2=0) and (i mod 3<>0) then dec(kd);\n if (i mod 2<>0) and (i mod 3=0) then dec(kt);\n\n if (i mod 6=0) then\n if (kt*3)>(kd*2) then dec(kt)\n else dec(kd);\n kt:=max(0,kt);\n kd:=max(0,kd);\n end;\n\n\nwriteln(i-1);\nend."}, {"source_code": "var n,m,i,x:longint;\nbegin\n readln(n,m);\n for i:=2 to 4000000 do\n begin\n if (n<=(i div 2)) and (m<=(i div 3)) and (n+m<=(i div 2)+(i div 3)-(i div 6))\n then begin\n x:=i;\n break;\n end;\n end;\n writeln(x);\nend."}, {"source_code": "function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end;\nvar\nn,m,k,l,w,s,j,i,k1,k2,k3:longint;\nbegin\nreadln(n,m);\nfor i:=1 to 12345678 do\nbegin\nif (i mod 2=0) and (i mod 3=0) then inc(k3) else\nif i mod 2=0 then inc(k1) else\nif i mod 3=0 then inc(k2);\nif k3-max(0,n-k1)-max(0,m-k2)=0 then break;\nend;\nwriteln(i);\nend."}, {"source_code": "uses math;\nvar n,m,mn,lik,t,kk,jj,minn:int64;\ni,j:longint;\na:array [0..3000000] of int64;\nans,NN,MM:int64;\n\n\nbegin\nreadln(n,m);\nnn:=n*2; T:=0;\nmm:=m*3;\nfor i:=1 to 3000000 do\nif (i mod 2=0)and(i mod 3=0) then begin inc(t);a[t]:=i;end;\n\nminn:=maxlongint;\nfor i:=1 to t do\nbegin\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn>mm) then\n begin minn:=abs(nn-mm);mm:=mm+3;end else\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn<=mm)then\n begin minn:=abs(nn-mm);nn:=nn+2;end;\n\nend;\nwritelN(max(mm,nn));\n\n\nend.\n"}, {"source_code": "program cf_626C;\nuses math;\nvar n,m,i,a1,b1,k1:longint;\nbegin\nreadln(n,m);\nfor i:=1 to 10000000 do\n begin\n if (i mod 6=0) then k1:=k1+1\n else if (i mod 2=0) then a1:=a1+1\n else if (i mod 3=0) then b1:=b1+1;\n if (k1-max(0,n-a1)-max(0,m-b1))=0 then\n begin\n writeln(i);\n break;\n end;\n end;\nend."}, {"source_code": "var\n l,r,c,k1,k2,n1,m1,i,j,n,m,k,t,x:longint;\nbegin\n readln(n,m);\n l:=1;r:=10000000;\n while l0 do\n begin\n if s1<=s2 then\n begin\n dec(s);\n s1:=s1+2;\n if (s1<=s2)and(s1 mod 6=0) then\n inc(s);\n end else\n begin\n dec(s);\n s2:=s2+3;\n if (s2<=s1)and(s2 mod 6=0) then\n inc(s);\n end\n end;\n if s1>s2 then writeln(s1)\n else writeln(s2);\nend.\n"}, {"source_code": "var x,y,tek:longint;\nbegin\n read(x,y);\n tek:=1;\n while (x>0)or(y>0) do\n begin\n inc(tek);\n if tek mod 6 =0\n then begin\n if (y*3)>(x*2)\n then begin dec(y);continue;end\n else begin dec(x);continue;end;\n end;\n if tek mod 2 =0\n then dec(x);\n if tek mod 3 =0\n then dec(y);\n\n \n \n \n end;\n write(tek);\n\n\nend."}, {"source_code": "uses math;\nvar\nn,m,x,t1,t2,t3:int64;\ni:longint;\nbegin\nread(n,m);\nfor i:=1 to maxlongint do\nbegin\ninc(x);\nif(x mod 2=0) then inc(t1);\nif(x mod 3=0) then inc(t2);\nif(x mod 2=0) and (x mod 3=0) then begin inc(t3); dec(t2); dec(t1); end;\nif(t3>= (max((n-t1),0))+(max((m-t2),0))) then break;\nend;\nwriteln(i);\nend.\n"}, {"source_code": "uses math;\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n m,n:longint;\n a,b:array[0..1000000] of longint;\n\nprocedure mofile;\nbegin\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure xuli;\nvar\n i:longint;\nbegin\n readln(n,m);\n for i:=1 to n do a[i]:=a[i-1]+2;\n for i:=1 to m do b[i]:=b[i-1]+3;\n\n i:=1;\n while i<=n do\n begin\n if (a[i] mod 3=0) and (b[m]>=a[i]) then\n begin\n if a[n]+2<=b[m]+3 then\n begin\n inc(n);\n a[n]:=a[n-1]+2;\n end\n else\n begin\n inc(m);\n b[m]:=b[m-1]+3;\n end;\n end;\n inc(i);\n end;\n writeln(max(a[n],b[m]));\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\nnewdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\ncc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,aa,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1000000] of int64;\noldzan,oldmarked: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nzan,marked,dost,newdost:array[-10..20000000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction pok(t:int64):int64;\nbegin if t-bb>=0 then pok:=max((t-bb) div (bb-cc)+1,0) else pok:=0; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n,m);\n\n for i:=1 to 4000000 do zan[2*i]:=true;\n for i:=1 to 4000000 do zan[3*i]:=true;\n for i:=1 to 12000000 do\n begin\n if zan[i] then inc(p);\n if (p>=(n+m))and(i div 2>=n)and(i div 3>=m) then begin write(i); goto 1; end;\n\n end;\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar n,m,x1,x2:longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n,m);\nx1:=n*2; if m>0\nthen x2:=3+(m-1)*6\nelse\nx2:=0;\n\nif m>n\nthen writeln(m*3)\nelse\nbegin\nwhile (x2>x1)and(x2>m*3)and(x2-x1>1) do\n begin\n dec(x2,6);\n inc(x1,2);\n end;\n writeln(max(x2,x1));\nend;\n{close(input); close(output); }\nend.\n"}, {"source_code": "var\n n,m,i,x : longint;\n f : array[0..5000000] of longint;\n\nbegin\n readln(n,m);\n for x:=1 to 50000000 do if (n <= x div 2) and (m <= x div 3) and (n+m <= x div 2+x div 3-x div 6) then break;\n writeln(x);\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (b - a > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n \n if (a mod 6 <> 0) and (b - a > 1) or (b - a < 3) then\n Dec (b, 3);\n end;\n \n if a > b then\n WriteLn (a)\n else if b > a then\n WriteLn (b)\n else\n WriteLn (a + 2);\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (b - a > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n \n if (a mod 6 <> 0) and (b - a > 1) or (b - a < 3) then\n Dec (b, 3);\n end;\n \n if a > b then\n WriteLn (a)\n else if b > a then\n WriteLn (b)\n else\n WriteLn (a + 2);\n end\nend."}, {"source_code": "uses math;\n\nvar i, n, m, cur, six, two, three: longint;\n\nbegin\n readln(n, m);\n for i := 1 to 10000000 do\n begin\n two := i div 2;\n three := i div 3;\n six := i div 6;\n two := two - six;\n three := three - six;\n cur := max(0, n - two) + max(0, m - three);\n if(cur <= six) then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "uses math;\nvar\n n,m,k,l,w,s,j,i,k1,k2,k3:longint;\nbegin\n readln(n,m);\n for i:=1 to 12100000 do\n begin\n if (i mod 2=0)and(i mod 3=0) then inc(k3) else\n if i mod 2=0 then inc(k1) else\n if i mod 3=0 then inc(k2);\n if k3-max(0,n-k1)-max(0,m-k2)=0 then break;\n end;\n writeln(i);\nend.\n"}, {"source_code": "uses math;\nvar\n N,M,ans,L,R,sr,X,Y,ans1:Longint;\nbegin\n Readln(N,M);\n X:=2*N;\n Y:=3*M;\n ans:=0;\n while (N>0) and (M>0) do\nbegin\n Inc(ans);\n if ans mod 6=0 then begin\n if X>Y then Dec(N)\n else Dec(M);\n end\n else\n if ans mod 2=0 then Dec(N)\n else\n if ans mod 3=0 then Dec(M);\n X:=ans+2*N;\n Y:=ans+3*M;\n end;\n if M>0 then ans:=(ans div 3)*3+3*M;\n if N>0 then ans:=(ans div 2)*2+2*N;\n Writeln(ans);\n end."}, {"source_code": "uses math;\nvar pr,maxi1,maxi2,kol2,h11,h22,h1,h2,n,m,nn,mm,maxi,kol:int64;\nbegin\nreadln(n,m);\n\n nn:=n;\n mm:=m;\n\nwhile(nn<>0)do\nbegin\nif ((h1+2)mod 3=0)and(m*3>=(h1+2))then begin h1:=h1+4 ;inc(kol); end else h1:=h1+2;\ndec(nn);\nend;\nh2:=m*3;\n pr:=0;\n\nif h1>n*2 then\n while(pr<>1)do\n begin\n maxi1:=max(h1,h2);\n maxi2:=max(h1-2,h2+3);\n if ((h2+3)mod 2=0)and((h1-2)>=(h2+3))then begin h2:=h2+3;maxi2:=max(h2+3,h1-2);end;\n\n if (maxi10)do\nbegin\nif ((h22+3)mod 2=0)and(n*2>=(h22+3))then begin h22:=h22+6;inc(kol2); end else h22:=h22+3;\ndec(mm);\nend;\nh11:=n*2;\n\nif h22>m*3 then\n while(pr<>1)do\n begin\n maxi1:=max(h11,h22);\n maxi2:=max(h11+2,h22-3);\n if ((h11+2)mod 3=0)and((h22-3)>=(h11+2))then begin h11:=h11+2;maxi2:=max(h11+2,h22-3);end;\n\n if (maxi13*m) then\n\tbegin\n\t\t\n\t\tx:=(2*n+4) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 = 2 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>=3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*n+3+m-4*x);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=(3*m+3) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 3*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>=2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes',' ',m+n-4*x);\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "uses math;\nvar n,m,t,h,ans:longint;\nbegin\n readln(n,m);\n ans:=0;\n while (n>m+1)and((n>2)or(m>0)) do begin dec(n,3);dec(m);inc(ans,6);end;\n while (n>0)and(m>0) do begin dec(n);dec(m);inc(ans,3);end;\n if m>0 then inc(ans,3*m);\n if n>0 then begin ans:=2*(ans div 2+1);n:=n-1;inc(ans,2*n);end;\n writeln(ans);\nend.\n"}, {"source_code": "var\nn,m,i:longint;\nbegin\nreadln(n,m);\nfor i:=1 to 1000000000 do begin\n if ((i div 2 )>=n)and(i div 3>=m)and((i div 2)+(i div 3)-(i div 6)>=(n+m)) then\n break;\nend;\nwriteln(i);\nend."}, {"source_code": "{$mode objfpc}\n\nvar\n m,n,x:longint;\n\nprocedure input;\nbegin\n read(n,m);\nend;\n\nprocedure process;\nbegin\n x:=1;\n while (n>x div 2) or (m>x div 3) or (m+n>(x div 2+x div 3-x div 6)) do inc(x);\nend;\n\nprocedure output;\nbegin\n write(x);\nend;\n\nbegin\n input;\n process;\n output;\nend."}, {"source_code": "uses math;\n\nvar m,n,cn,cm,i:longint;\n\nbegin\n readln(n,m);\n cn:=2*n;\n cm:=3*m;\n i:=2;\n while i<=min(cn,cm) do\n begin\n inc(i,2);\n if i mod 3 = 0\n then\n if cn<=cm\n then cn:=cn+2\n else cm:=cm+3;\n end;\n writeln(max(cn,cm));\nend."}, {"source_code": "uses math;\n\nvar minn,m,n,cn,cm,i:longint;\n\nbegin\n readln(n,m);\n cn:=2*n;\n cm:=3*m;\n i:=2;\n while i<=min(cn,cm) do\n begin\n inc(i,2);\n if i mod 3 = 0\n then\n if cn<=cm\n then cn:=cn+2\n else cm:=cm+3;\n end;\n writeln(max(cn,cm));\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses math;\nconst maxN=1000000+1067;\nvar n,m,i:integer;\n kt:array[0..3*maxN] of boolean;\n res1,res2,x,dem1,dem2,dem3:integer;\n\nbegin\n readln(n,m);\n x:=0;\n for i:=1 to 3000000 do\n begin\n if i mod 6=0 then inc(dem3) else\n if i mod 2=0 then inc(dem1) else\n if i mod 3=0 then inc(dem2);\n if (n-min(n,dem1)+m-min(m,dem2))<=dem3 then\n begin\n writeln(i);\n halt\n end;\n end;\nend.\n"}, {"source_code": "var\nn,m,i:longint;\nbegin\n readln(n,m);\n for i:=1 to 4000000 do\n if (n<=i div 2) and (m<=i div 3) and ((n+m)<=(i div 2+i div 3-i div 6)) then begin write(i); halt; end;\nend.\n\n"}, {"source_code": "function fmn(a, b : int64) : int64;\nbegin\n if a < b\n then\n fmn := a\n else\n fmn := b;\nend;\nfunction fmx(a, b : int64) : int64;\nbegin\n if a > b\n then\n fmx := a\n else\n fmx := b;\nend;\n\nvar\n n, h, m, k, i, max, min, z, d, c, ot, ot1, ot2 : int64;\nbegin\n read(n, m);\n min := fmn(n * 2, m * 3);\n k := 6;\n z := k;\n d := 1;\n while z <= min do\n begin\n inc(c);\n inc(d);\n z := k * d;\n end;\n while c > 0 do\n begin\n if n * 2 + 2 < m * 3 + 3\n then\n begin\n inc(n);\n if (n * 2 mod 3 = 0) and (n * 2 <= m * 3)\n then\n inc(c);\n end\n else\n begin\n inc(m);\n if (m * 3 mod 2 = 0) and (m * 3 <= n * 2)\n then\n inc(c);\n end;\n dec(c);\n end;\n //writeln(n * 2, ' ', m * 3);\n writeln(fmx(n * 2, m * 3));\nend."}, {"source_code": "var\nn, m, i, max: integer;\nbegin\nread(n, m);\nfor i:= 1 to 10000000 do\nbegin\nif (i mod 6 = 0) then\nif (n <= m) and (m <> 0) then begin dec(m); max:= i; continue; end\nelse if n <> 0 then begin dec(n); max:= i; continue; end;\nif (i mod 2 = 0) and (n >= 1) then begin dec(n); max:= i; continue; end;\nif (i mod 3 = 0) and (m >= 1) then begin dec(m); max:= i; end;\nend;\nwriteln(max);\nend."}, {"source_code": "var\n n,m,ans,nn,mm,anss:longint;\nbegin\n readln(n,m); ans:=0;\n while (n>m+1)and((n>2)or(m>0)) do\n begin dec(n,3); dec(m); inc(ans,6); end; anss:=maxlongint >> 1;\n if (n=m+1)and(m and 1=1) then\n begin dec(n,2); dec(m); inc(ans,4); end;\n while (n>0)and(m>0) do\n begin dec(n); dec(m); inc(ans,3); end;\n if m>0 then inc(ans,3*m);\n if n>0 then inc(ans,2*n);\n writeln(ans);\nend."}, {"source_code": " Uses MATH;\n var N , M : LongInt; \n Two ,Three , Six , Ans : Int64;\nbegin\n Two := 2; \n Three := 3; \n Six := 6;\n readLn ( N , M ) ; \n \n Ans := 0 ; \n \n while ( n + m > 0 ) do\n begin\n //writeLn ( N , ' ' , M ) ; \n if ( Six <= Two ) and ( Six <= Three ) then\n begin\n // Can both\n //writeLn ( 'Choose ' , n , ' ' , m ) ; \n Two := Two + 2 ; \n Three := Three + 3 ; \n if ( n >= m * 2 ) then\n dec ( n )\n else\n dec ( m ) ; \n Ans := Max ( Ans , Six ) ; \n Six := Six + 6 ; \n end\n else\n begin\n if ( Two < Three ) then\n begin\n if ( n > 0 ) then\n begin\n dec ( n ) ; \n Ans := Max ( ans , Two ) ; \n end;\n Two := Two + 2 ;\n end\n else \n begin\n if ( m > 0 ) then\n begin\n dec ( m ) ; \n Ans := Max ( ans , Three ) ; \n end;\n Three := Three + 3 ; \n end\n \n end;\n end;\n \n writeLn ( ans ) ; \n \nend."}], "negative_code": [{"source_code": "var x,y,tek:longint;\nbegin\n read(x,y);\n tek:=1;\n while (x>0)or(y>0) do\n begin\n inc(tek);\n if tek mod 6 =0\n then begin\n if y>0\n then begin dec(y);continue;end\n else begin dec(x);continue;end;\n end;\n if tek mod 2 =0\n then dec(x);\n if tek mod 3 =0\n then dec(y);\n\n \n \n \n end;\n write(tek);\n\n\nend."}, {"source_code": "uses math;\nvar\na,b,t,m2,m1:int64;\nbegin\nread(a,b);\nm1:=a*2;\nm2:=b*3;\na:=max(m1,m2);\nt:=min(m1 div 3,m2 div 2);\nif(t=0) then begin writeln(a); halt; end;\ninc(a);\nwhile(t>0) do\nbegin\nif(a mod 3=0) or (a mod 2=0) then dec(t);\ninc(a);\nend;\nwriteln(a);\nend.\n"}, {"source_code": "uses math;\nvar\na,b,t,m2,m1:int64;\nbegin\nread(a,b);\nm1:=a*2;\nm2:=b*3;\na:=max(m1,m2);\nt:=min(m1 div 3,m2 div 2);\nif(t=0) then begin writeln(a); halt; end;\ninc(a);\nwhile(t>0) do\nbegin\nif(a mod 3=0) or (a mod 2=0) then dec(t);\ninc(a);\nend;\nend.\n\n"}, {"source_code": "uses math;\nvar\nn,m,m1,m2,t,z,z1,z2,t1:int64;\ni:longint;\nbegin\nreadln(n,m);\nm1:=n*2;\nm2:=m*3;\nt:=n div 3;\nt1:=m div 2;\nz:=min(t,t1);\nz2:=2;\nfor i:=1 to z do\nbegin\nif(z2=2) then begin m1:=m1+2; z2:=3; end else begin m2:=m2+3; z2:=2; end;\nend;\nwriteln(max(m1,m2));\nend.\n\n\n\n\n"}, {"source_code": "uses math;\nvar\na,b,t,m2,m1:int64;\nbegin\nread(a,b);\nm1:=a*2;\nm2:=b*3;\nt:=min(a div 3,b div 2);\na:=max(m1,m2);\nif(t=0) then begin writeln(a); halt; end;\ninc(a);\nwhile(t>0) do\nbegin\nif(a mod 3=0) or (a mod 2=0) then dec(t);\ninc(a);\nend;\nwriteln(a);\nend."}, {"source_code": "uses math;\nvar\nn,m,m1,m2,t,z,z1,z2,t1:int64;\ni:longint;\nbegin\nreadln(n,m);\nt:=1;\nwhile(n>0) or (m>0) do\nbegin\nif(t mod 2=1) then\nbegin\nif((m1+2) mod 3=0) and ((m1+2)<=m2) then m1:=m1+4\nelse\nm1:=m1+2;\ndec(n);\nend;\nif(t mod 2=0) then\nbegin\nif((m2+3) mod 2=0) and ((m2+3)<=m1) then m2:=m2+6\nelse\nm2:=m2+3;\ndec(m);\nend;\ninc(t);\nend;\nwriteln(max(m1,m2));\nend.\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar\na,b,t,m2,m1:int64;\nbegin\nread(a,b);\nm1:=a*2;\nm2:=b*3;\na:=max(m1,m2);\nt:=min(a div 3,b div 2);\nif(t=0) then begin writeln(a); halt; end;\ninc(a);\nwhile(t>0) do\nbegin\nif(a mod 3=0) or (a mod 2=0) then dec(t);\ninc(a);\nend;\nwriteln(a);\nend."}, {"source_code": "uses math;\nvar\nn,m,m1,m2,t,z,z1,z2,t1:int64;\ni:longint;\nbegin\nreadln(n,m);\nt:=1;\nwhile(n>0) or (m>0) do\nbegin\nif(t mod 2=1) then\nbegin\nif((m1+2) mod 3=0) and ((m1+2)<=m2) then m1:=m1+4\nelse\nm1:=m1+2;\ndec(n);\nend;\nif(t mod 2=0) then\nbegin\nif((m2+3) mod 2=0) and ((m2+3)<=m1) then m2:=m2+6\nelse\nm2:=m2+3;\ndec(m);\nend;\ninc(t);\nend;\nwriteln(max(m1,m2));\nend.\n\n\n\n\n\n"}, {"source_code": "var\nn,m,x,t1,t2,t3:int64;\ni:longint;\nbegin\nread(n,m);\nfor i:=1 to maxlongint do\nbegin\ninc(x);\nif(x mod 2=0) then inc(t1);\nif(x mod 3=0) then inc(t2);\nif(x mod 2=0) and (x mod 3=0) then inc(t3);\nif(n+m<=(t1+t2-t3)) then break;\nend;\nwriteln(i);\nend.\n"}, {"source_code": "uses math;\nvar\na,b,t,m2,m1:int64;\nbegin\nread(a,b);\nm1:=a*2;\nm2:=b*3;\nt:=min(a div 3,b div 2);\na:=max(m1,m2);\nif(t=0) then begin writeln(a); halt; end;\ninc(a);\nwhile(t>0) do\nbegin\nif(a mod 3=0) or (a mod 2=0) then dec(t);\nif(t<>0) then inc(a);\nend;\nwriteln(a);\nend."}, {"source_code": "Program Buntarik;\nuses math;\nvar n,m,x1,x2:longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n,m);\nx1:=n*2; if m>0\nthen x2:=3+(m-1)*6\nelse\nx2:=0;\n\nwhile (x2>x1)and(x2>m*3) do\n begin\n dec(x2,3);\n inc(x1,2);\n end;\n writeln(max(x2,x1));\n{close(input); close(output); }\nend.\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar n,m,x1,x2:longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n,m);\nx1:=n*2; if m>0\nthen x2:=3+(m-1)*6\nelse\nx2:=0;\n\nwhile (x2>x1)and(x2>m*3)and(x2-x1>1) do\n begin\n dec(x2,3);\n inc(x1,2);\n end;\n writeln(max(x2,x1));\n{close(input); close(output); }\nend.\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar n,m,x1,x2:longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n,m);\nx1:=n*2; if m>0\nthen x2:=3+(m-1)*6\nelse\nx2:=0;\n\nwhile (x2>x1)and(x2>m*3)and(x2-x1>1) do\n begin\n dec(x2,6);\n inc(x1,2);\n end;\n writeln(max(x2,x1));\n{close(input); close(output); }\nend.\n"}, {"source_code": "var\n n,m,i,mx : longint;\n f : array[0..5000000] of longint;\n\nbegin\n readln(n,m);\n for i:=1 to m do f[i*3]:=1;\n mx:=m*3; i:=2;\n while n > 0 do begin\n while f[i] = 1 do i:=i+2;\n f[i]:=1;\n if i > mx then mx:=i;\n dec(n);\n end;\n writeln(mx);\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (Abs (a - b) > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n Dec (b, 3);\n \n if a mod 6 = 0 then\n Inc (a, 2);\n end;\n \n if a > b then\n WriteLn (a)\n else\n WriteLn (b)\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (Abs (a - b) > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n \n \n if a mod 6 <> 0 then\n Dec (b, 3);\n end;\n \n if a > b then\n WriteLn (a)\n else\n WriteLn (b)\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (Abs (a - b) > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n Dec (b, 3);\n \n if a mod 6 = 0 then\n Inc (a, 2);\n end;\n \n if a > b then\n WriteLn (a)\n else\n WriteLn (b);\n \n WriteLn (a, ' ', b)\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (b - a > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n \n if (a mod 6 <> 0) and (b - a > 1) or (b - a < 3) then\n Dec (b, 3);\n end;\n \n WriteLn (a, ' ', b);\n \n if a > b then\n WriteLn (a)\n else if b > a then\n WriteLn (b)\n else\n WriteLn (a + 2);\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (b - a > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n \n if a mod 6 <> 0 then\n Dec (b, 3);\n end;\n \n if a > b then\n WriteLn (a)\n else if b > a then\n WriteLn (b)\n else\n WriteLn (a + 2);\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m + 3 * (a div 6);\n \n if a > b then\n WriteLn (a)\n else\n begin\n while (Abs (a - b) > 1) and (b > 3 * m) do\n begin\n Inc (a, 2);\n Dec (b, 3)\n end;\n \n if a > b then\n WriteLn (a)\n else\n WriteLn (b)\n end\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n b:= 3 * m;\n \n a:= 0;\n for i:= 1 to n do\n begin\n Inc (a, 2);\n \n if (a mod 6 = 0) and (a <= b) then\n Inc (a, 2)\n end;\n \n if b > a then\n WriteLn (b)\n else if a > b + 3 then\n WriteLn (b + 3)\n else\n WriteLn (a);\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n b:= 3 * m;\n \n a:= 2;\n for i:= 2 to n do\n begin\n Inc (a, 2);\n \n if (a mod 6 = 0) and (a <= b) then\n Inc (a, 2)\n end;\n \n if a > b then\n WriteLn (a)\n else \n WriteLn (b);\nend."}, {"source_code": "var\n n, m, i: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n b:= 3 * m;\n \n a:= 0;\n for i:= 1 to n do\n begin\n Inc (a, 2);\n \n if (a mod 6 = 0) and (a <= b) then\n Inc (a, 2)\n end;\n \n if a > b then\n WriteLn (a)\n else \n WriteLn (b);\nend."}, {"source_code": "var\n n, m: LongInt;\n a, b: Int64;\n \nbegin\n Read (n, m);\n \n a:= 2 * n;\n b:= 3 * m;\n \n if a > b then\n WriteLn (a)\n else if b > a then\n WriteLn (b)\n else\n WriteLn (a + 2)\nend."}, {"source_code": "var\n n,m,k,l,w,s,j,i:longint;\nbegin\n readln(n,m);\n for i:=1 to 12100000 do\n begin\n if (i mod 3=0)and(m>0) then begin w:=i; dec(m); end else\n if (i mod 2=0)and(n>0) then begin w:=i; dec(n); end;\n if (n=0)and(m=0) then break;\n end;\n writeln(w);\nend.\n"}, {"source_code": "var\n n,m,k,l,w,s,j,i:longint;\nbegin\n readln(n,m);\n for i:=1 to 12100000 do\n begin\n if (i mod 3=0)and(m>0)and(m>=n) then begin w:=i; dec(m); end else\n if (i mod 2=0)and(n>0) then begin w:=i; dec(n); end;\n if (n=0)and(m=0) then break;\n end;\n writeln(w);\nend.\n"}, {"source_code": "uses math;\nvar\n N,M,ans,L,R,sr,X,Y,ans1:Longint;\nbegin\n Readln(N,M);\n ans:=M*3;\n Y:=ans div 6;\n L:=0;\n R:=3000300;\n while R-L>1 do\nbegin\n sr:=(L+R) div 2;\n if sr div 2-min(Y,sr div 6)>=N then R:=sr\n else L:=sr;\n end;\n if L div 2-min(Y,L div 6)=N then X:=L\n else X:=R;\n //X:=2*(X div 2+1);\n ans:=max(ans,x);\n ans1:=N*2;\n Y:=ans1 div 6;\n L:=0;\n R:=3000300;\n while R-L>1 do\nbegin\n sr:=(L+R) div 2;\n if sr div 3-min(Y,sr div 6)>=m then R:=sr\n else L:=sr;\n end;\n if L div 3-min(Y,L div 6)=M then X:=L\n else X:=R;\n //X:=2*(X div 2+1);\n ans1:=max(ans1,x);\n ans:=min(ans,ans1);\n Writeln(ans);\n end."}, {"source_code": "uses math;\nvar\n N,M,ans,L,R,sr,X,Y:Longint;\nbegin\n Readln(N,M);\n ans:=M*3;\n Y:=ans div 6;\n L:=0;\n R:=3000300;\n while R-L>1 do\nbegin\n sr:=(L+R) div 2;\n if sr div 2-min(Y,sr div 6)>=N then R:=sr\n else L:=sr;\n end;\n if L div 2-min(Y,L div 6)=N then X:=L\n else X:=R;\n //X:=2*(X div 2+1);\n ans:=max(ans,x);\n Writeln(ans);\n end."}, {"source_code": "uses math;\nvar pr,maxi1,maxi2,kol2,h11,h22,h1,h2,n,m,nn,mm,maxi,kol:int64;\nbegin\nreadln(n,m);\n\n nn:=n;\n mm:=m;\n\nwhile(nn<>0)do\nbegin\nif ((h1+2)mod 3=0)and(m*3>=(h1+2))then begin h1:=h1+4 ;inc(kol); end else h1:=h1+2;\ndec(nn);\nend;\nh2:=m*3;\n pr:=0;\nif h1>n*2 then\n while(pr<>1)do\n begin\n maxi1:=max(h1,h2);\n maxi2:=max(h1-2,h2+3);\n\n if (maxi10)do\nbegin\nif ((h22+3)mod 2=0)and(n*2>=(h22+3))then begin h22:=h22+6;inc(kol2); end else h22:=h22+3;\ndec(mm);\nend;\nh11:=n*2;\n\nif h22>m*3 then\n while(pr<>1)do\n begin\n maxi1:=max(h11,h22);\n maxi2:=max(h11+2,h22-3);\n if (maxi10)do\nbegin\nif ((h1+2)mod 3=0)and(m*3>=(h1+2))then begin h1:=h1+4 ;inc(kol); end else h1:=h1+2;\ndec(nn);\nend;\nh2:=m*3;\n pr:=0;\nif h1>n*2 then\n while(pr<>1)do\n begin\n maxi1:=max(h1,h2);\n maxi2:=max(h1-2,h2+3);\n if maxi10)do\nbegin\nif ((h22+3)mod 2=0)and(n*2>=(h22+3))then begin h22:=h22+6;inc(kol2); end else h22:=h22+3;\ndec(mm);\nend;\nh11:=n*2;\n\nif h22>m*3 then\n while(pr<>1)do\n begin\n maxi1:=max(h11,h22);\n maxi2:=max(h11+2,h22-3);\n if maxi10)do\nbegin\nif ((h1+2)mod 3=0)and(m*3>=(h1+2))then begin h1:=h1+4 ;inc(kol); end else h1:=h1+2;\ndec(nn);\nend;\nh2:=m*3;\n pr:=0;\nif h1>n*2 then\n while(pr<>1)do\n begin\n maxi1:=max(h1,h2);\n maxi2:=max(h1-2,h2+3);\n\n if (maxi10)do\nbegin\nif ((h22+3)mod 2=0)and(n*2>=(h22+3))then begin h22:=h22+6;inc(kol2); end else h22:=h22+3;\ndec(mm);\nend;\nh11:=n*2;\n\nif h22>m*3 then\n while(pr<>1)do\n begin\n maxi1:=max(h11,h22);\n maxi2:=max(h11+2,h22-3);\n if (maxi10)do\nbegin\nif ((h1+2)mod 3=0)and(m*3>=(h1+2))then begin h1:=h1+4 ;inc(kol); end else h1:=h1+2;\ndec(nn);\nend;\nh2:=m*3;\n pr:=0;\nif h1>n*2 then\n while(pr<>1)do\n begin\n maxi1:=max(h1,h2);\n maxi2:=max(h1-2,h2+3);\n\n if maxi10)do\nbegin\nif ((h22+3)mod 2=0)and(n*2>=(h22+3))then begin h22:=h22+6;inc(kol2); end else h22:=h22+3;\ndec(mm);\nend;\nh11:=n*2;\n\nif h22>m*3 then\n while(pr<>1)do\n begin\n maxi1:=max(h11,h22);\n maxi2:=max(h11+2,h22-3);\n if maxi13*m) then\n\tbegin\n\t\tx:=(2*n+4) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 = 2 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2*n+1);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=(3*m+3) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 3*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes',' ',m+n-4*x);\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var\n\tn,m,a,b,x\t\t: longint;\nbegin\n\treadln(n,m);\n\t\n\tif (2*n=3*m) then\n\tbegin\n\t\ta:=(2*n div 6) mod 4;\n\t\tb:=(2*n div 6) div 4;\n\t\tcase a of\n\t\t\t0\t: writeln(2*n+b*6);\n\t\t\t1\t: writeln(2*n+b*6+2);\n\t\t\t2\t: writeln(2*n+b*6+3);\n\t\t\t3\t: writeln(2*n+b*6+4);\t\n\t\tend;\n\tend;\n\t\t\n\tif (2*n>3*m) then\n\tbegin\n\t\t\n\t\tx:=(2*n+4) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 = 2 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>=3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2*n+1);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=(3*m+3) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 3*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>=2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes',' ',m+n-4*x);\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var\n\tn,m,a,b,x\t\t: longint;\nbegin\n\treadln(n,m);\n\t\n\tif (2*n=3*m) then\n\tbegin\n\t\ta:=(2*n div 6) mod 4;\n\t\tb:=(2*n div 6) div 4;\n\t\tcase a of\n\t\t\t0\t: writeln(2*n+b*6);\n\t\t\t1\t: writeln(2*n+b*6+2);\n\t\t\t2\t: writeln(2*n+b*6+3);\n\t\t\t3\t: writeln(2*n+b*6+4);\t\n\t\tend;\n\tend;\n\t\t\n\tif (2*n>3*m) then\n\tbegin\n\t\tx:=2*n+4 div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 =4 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2*n+1);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=x mod 4;\n\t\t\tb:=x;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(4*x+b*6);\n\t\t\t\t1\t: writeln(4*x+b*6+2);\n\t\t\t\t2\t: writeln(4*x+b*6+3);\n\t\t\t\t3\t: writeln(4*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=3*m+3 div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\ta:=x mod 4;\n\t\t\tb:=x;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(4*x+b*6);\n\t\t\t\t1\t: writeln(4*x+b*6+2);\n\t\t\t\t2\t: writeln(4*x+b*6+3);\n\t\t\t\t3\t: writeln(4*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var\n\tn,m,a,b,x\t\t: longint;\nbegin\n\treadln(n,m);\n\t\n\tif (2*n=3*m) then\n\tbegin\n\t\ta:=(2*n div 6) mod 4;\n\t\tb:=(2*n div 6) div 4;\n\t\tcase a of\n\t\t\t0\t: writeln(2*n+b*6);\n\t\t\t1\t: writeln(2*n+b*6+2);\n\t\t\t2\t: writeln(2*n+b*6+3);\n\t\t\t3\t: writeln(2*n+b*6+4);\t\n\t\tend;\n\tend;\n\t\t\n\tif (2*n>3*m) then\n\tbegin\n\t\tx:=(2*n+4) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 = 2 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2*n+1);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=(3*m+3) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\t//writeln('yes',' ',m+n-4*x);\n\t\t\ta:=(m+n-4*x) mod 4;\n\t\t\tb:=(m+n-4*x) div 4;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(6*x+b*6);\n\t\t\t\t1\t: writeln(6*x+b*6+2);\n\t\t\t\t2\t: writeln(6*x+b*6+3);\n\t\t\t\t3\t: writeln(6*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "var\n\tn,m,a,b,x\t\t: longint;\nbegin\n\treadln(n,m);\n\t\n\tif (2*n=3*m) then\n\tbegin\n\t\ta:=(2*n div 6) mod 4;\n\t\tb:=(2*n div 6) div 4;\n\t\tcase a of\n\t\t\t0\t: writeln(2*n+b*6);\n\t\t\t1\t: writeln(2*n+b*6+2);\n\t\t\t2\t: writeln(2*n+b*6+3);\n\t\t\t3\t: writeln(2*n+b*6+4);\t\n\t\tend;\n\tend;\n\t\t\n\tif (2*n>3*m) then\n\tbegin\n\t\tx:=(2*n+4) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*n mod 6 = 2 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>3 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2*n);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2*n+1);\n\t\t\tend else\t\n\t\t\t\twriteln(2*n);\n\t\tend else\n\t\tbegin\n\t\t\ta:=x mod 4;\n\t\t\tb:=x;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(4*x+b*6);\n\t\t\t\t1\t: writeln(4*x+b*6+2);\n\t\t\t\t2\t: writeln(4*x+b*6+3);\n\t\t\t\t3\t: writeln(4*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\tif (2*n<3*m) then\n\tbegin\n\t\tx:=(3*m+3) div 6;\n\t\tif 4*x>(m+n)then\n\t\tbegin\n\t\t\tif 2*m mod 6 = 3 then\n\t\t\tbegin\n\t\t\t\tif 4*x-m-n>2 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(3*m);\n\t\t\t\tend else\n\t\t\t\t\twriteln(3*m+1);\n\t\t\tend else\t\n\t\t\t\twriteln(3*m);\n\t\tend else\n\t\tbegin\n\t\t\ta:=x mod 4;\n\t\t\tb:=x;\n\t\t\tcase a of\n\t\t\t\t0\t: writeln(4*x+b*6);\n\t\t\t\t1\t: writeln(4*x+b*6+2);\n\t\t\t\t2\t: writeln(4*x+b*6+3);\n\t\t\t\t3\t: writeln(4*x+b*6+4);\t\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "uses math;\nvar n,m:longint;\nbegin\n readln(n,m);\n n:=n+min(n div 3,m);\n writeln(max(n*2,m*3));\nend."}, {"source_code": "var n,m,ans,d:int64;\n begin\n readln(n,m);\n ans:=m*3;\n if n>m then\n begin\n d:=n-m;\n if ans mod 2=1 then\n begin\n ans:=ans+1;\n d:=d-1;\n end;\n ans:=ans+d*2;\n end;\n write(ans); \n end."}, {"source_code": "var n,m,c:longint;\n cn,cm:longint;\n\nbegin\n readln(n,m);\n if n=0\n then writeln(m*3)\n else if m=0\n then writeln(n*2)\n else\n begin\n cn:=n div 3;\n cm:=m div 2;\n if cn>cm\n then\n cn:=cm;\n c:=n*2+(cn*2);\n if ccm+3 do\n begin\n c:=c-2;\n cm:=cm+3;\n end;\n writeln(c);\n end;\nend.\n"}, {"source_code": "var n,m,c:longint;\n cn,cm:longint;\n\nbegin\n readln(n,m);\n if n=0\n then writeln(m*3)\n else if m=0\n then writeln(n*2)\n else\n begin\n cn:=n div 3;\n cm:=m div 2;\n if cn>cm\n then\n cn:=cm;\n c:=n*2+(cn*2);\n if ccm+3 do\n begin\n c:=c-2;\n cm:=cm+3;\n end;\n if cm>c then c:=cm;\n writeln(c);\n end;\nend.\n"}, {"source_code": "var n,m,c:longint;\n cn,cm:longint;\n\nbegin\n readln(n,m);\n if n=0\n then writeln(m*3)\n else if m=0\n then writeln(n*2)\n else\n begin\n cn:=n div 3;\n cm:=m div 2;\n if cn>cm\n then\n cn:=cm;\n c:=n*2+(cn*2);\n cm:=m*3;\n while c>cm+3 do\n begin\n c:=c-2;\n cm:=cm+3;\n end;\n writeln(c);\n end;\nend.\n"}, {"source_code": "var n,m,c:longint;\n cn,cm:longint;\n\nbegin\n readln(n,m);\n if n=0\n then writeln(m*3)\n else if m=0\n then writeln(n*2)\n else\n begin\n cn:=n div 3;\n cm:=m div 2;\n if cn>cm\n then\n cn:=cm;\n c:=m*3+(cn*2);\n cm:=m*3;\n while c>cm+3 do\n begin\n c:=c-2;\n cm:=cm+3;\n end;\n writeln(c);\n end;\nend."}, {"source_code": "var n,m,c:longint;\n cn,cm:longint;\n\nbegin\n readln(n,m);\n if n=0\n then writeln(m*3)\n else if m=0\n then writeln(n*2)\n else\n begin\n cn:=n div 3;\n cm:=m div 2;\n if cn>cm\n then\n cn:=cm;\n c:=n*2+(cn*2);\n if ccm+3)and(cn>0) do\n begin\n c:=c-2;\n cm:=cm+3;\n dec(cn);\n end;\n if cm>c then c:=cm;\n writeln(c);\n end;\nend.\n"}, {"source_code": "var\nn,m,i:longint;\na,b:array[0..10000000] of longint;\nbegin\n readln(n,m);\n a[0]:=0;\n for i:=1 to 2000000 do\n begin a[i]:=a[i-1]+2; if (i mod 3 = 0) and (i*2 div 3<=m) then a[i]:=a[i]+2; end;\n b[0]:=0;\n for i:=1 to 2000000 do b[i]:=i*3;\n\n if a[n]>b[m] then write(a[n]) else write(b[m]);\nend.\n\n"}, {"source_code": "var\nn,m,i:longint;\nbegin\n readln(n,m);\n for i:=1 to 4000000 do\n if (n<=i div 2) and (m<=i div 2) and (n+m<=i div 2+i div 3-i div 6) then begin write(i); halt; end;\nend.\n\n"}, {"source_code": "var\nn,m,i:longint;\nbegin\n readln(n,m);\n for i:=1 to 4000000 do\n if (n<=trunc(i/2)) and (m<=trunc(i/2)) and (n+m<=trunc(i/2)+trunc(i/3)-trunc(i/6)) then begin write(i); halt; end;\nend.\n\n"}, {"source_code": "function fmn(a, b : int64) : int64;\nbegin\n if a < b\n then\n fmn := a\n else\n fmn := b;\nend;\nfunction fmx(a, b : int64) : int64;\nbegin\n if a > b\n then\n fmx := a\n else\n fmx := b;\nend;\n\nvar\n n, h, m, k, i, max, min, z, d, c, ot, ot1, ot2 : int64;\nbegin\n read(n, m);\n min := fmn(n * 2, m * 3);\n k := 6;\n z := k;\n d := 1;\n while z < 1000 do\n begin\n if z <= min\n then\n inc(c);\n inc(d);\n z := k * d;\n end;\n h := c div 2;\n if c mod 2 = 1\n then\n inc(h);\n inc(n, h);\n inc(m, c - h);\n if n * 2 = m * 3\n then\n ot := n * 2 + 2\n else\n ot := fmx(n * 2, m * 3);\n {for i := 1 to 100 do\n if a[i] = 1\n then\n write(i, ' ');\n writeln;}\n writeln(ot);\nend."}, {"source_code": "var\n n,m,i,max,now:longint;\n f:array[0..4000001]of longint;\nbegin\n readln(n,m);\n for i:=1 to m do f[3*i]:=1;\n max:=3*m; now:=0;\n for i:=1 to n+m do\n begin\n if f[i << 1]=0 then inc(now);\n if now=n then begin\n if maxm+1)and((n>2)or(m>0)) do\n begin dec(n,3); dec(m); inc(ans,6); end;\n if n=m+1 then\n begin dec(n,2); dec(m); inc(ans,4); end;\n while (n>0)and(m>0) do\n begin dec(n); dec(m); inc(ans,3); end;\n if m>0 then inc(ans,3*m);\n if n>0 then inc(ans,2*n);\n writeln(ans);\nend."}, {"source_code": "\nvar\nn,m,i,j,k:longint;\nbegin\nreadln(n,m);\ni:=N*2;\nj:=m*3;\nfor k:=1 to i div 6 do\nif j>=k*6\nthen begin\nif i+2j\nthen writeln(i)\nelse writeln(j);\nend.\n\n"}, {"source_code": "var a,b,da,db,d1,d2,i,kl1,kl2,min:longint;\nbegin\n readln(a,b);\n a:=a*2;\n b:=b*3;\n d1:=a;\n d2:=b;\n da:=(a div 3) div 2;\n db:=(b div 3) div 2;\n if dab) then begin\n a:=a+2;\n b:=b+3;\n end\n else if (a mod 3=0) and (b mod 2<>0) then a:=a+2\n else if (a mod 3<>0) and (b mod 2=0) then b:=b+3;\n if kl1=1 then a:=d1;\n if kl2=1 then b:=d2;\n if a>b then min:=a\n else min:=b;\n writeln(min);\nend."}, {"source_code": "var c:array[1..3000000]of longint;\na,b,da,db,d1,d2,i,max,kl1,kl2,min:longint;\nbegin\n readln(a,b);\n a:=a*2;\n b:=b*3;\n d1:=a;\n d2:=b;\n da:=(a div 3) div 2;\n db:=(b div 3) div 2;\n if amin then break;\n if a=b) and (b mod 2=0) and (c[b]=0)\n then begin\n min:=min+1;\n c[b]:=1;\n end;\n end\n else if a=b then begin\n a:=a+2;\n if (a<=b) and (a mod 3=0) and (c[a]=0)\n then begin\n min:=min+1;\n c[a]:=1;\n end;\n end\n end;\n if d1=a then begin\n a:=2;\n kl1:=1;\n end\n else if d2=b then begin\n b:=3;\n kl2:=1;\n end;\n if (a mod 3=0) and (b mod 2=0) and (a=b) then a:=a+2\n else if (a mod 3=0) and (b mod 2=0) and (a<>b) then begin\n a:=a+2;\n b:=b+3;\n end\n else if (a mod 3=0) and (b>=a) then a:=a+2\n else if (a>=b) and (b mod 2=0) then b:=b+3;\n if kl1=1 then a:=d1;\n if kl2=1 then b:=d2;\n if a>b then min:=a\n else min:=b;\n writeln(min);\nend."}, {"source_code": "var a,b,da,db,d1,d2,i,kl1,kl2,min:longint;\nbegin\n readln(a,b);\n a:=a*2;\n b:=b*3;\n d1:=a;\n d2:=b;\n da:=(a div 3) div 2;\n db:=(b div 3) div 2;\n if da>db then min:=da\n else min:=db;\n for i:=1 to min do\n begin\n if ab) then begin\n a:=a+2;\n b:=b+3;\n end\n else if (a mod 3=0) and (b>=a) then a:=a+2\n else if (a>=b) and (b mod 2=0) then b:=b+3;\n if kl1=1 then a:=d1;\n if kl2=1 then b:=d2;\n if a>b then min:=a\n else min:=b;\n writeln(min);\nend."}, {"source_code": "var c:array[1..3000000]of byte;\na,b,da,db,d1,d2,i,kl1,kl2,min:longint;\nbegin\n readln(a,b);\n a:=a*2;\n b:=b*3;\n d1:=a;\n d2:=b;\n da:=(a div 3) div 2;\n db:=(b div 3) div 2;\n if da>db then min:=da\n else min:=db;\n while true do\n begin\n i:=i+1;\n if i>min then break;\n if ab) and (a mod 3=0) and (c[a]=0)\n then begin\n min:=min+1;\n c[a]:=1;\n end;\n end\n else if bb) and (b mod 2=0) and (c[b]=0)\n then begin\n min:=min+1;\n c[b]:=1;\n end;\n end\n else if a=b then begin\n a:=a+2;\n if (a<>b) and (a mod 3=0) and (c[a]=0)\n then begin\n min:=min+1;\n c[a]:=1;\n end;\n end\n end;\n if d1=a then begin\n a:=2;\n kl1:=1;\n end\n else if d2=b then begin\n b:=3;\n kl2:=1;\n end;\n if (a mod 3=0) and (b mod 2=0) and (a=b) then a:=a+2\n else if (a mod 3=0) and (b mod 2=0) and (a<>b) then begin\n a:=a+2;\n b:=b+3;\n end\n else if (a mod 3=0) and (b>=a) then a:=a+2\n else if (a>=b) and (b mod 2=0) then b:=b+3;\n if kl1=1 then a:=d1;\n if kl2=1 then b:=d2;\n if a>b then min:=a\n else min:=b;\n writeln(min);\nend."}, {"source_code": "uses math;\nvar n,m,mn,lik,t,kk,jj,minn:int64;\ni,j:longint;\na:array [0..1000000] of int64;\nans,NN,MM:int64;\n\n\nbegin\nreadln(n,m);\nnn:=n*2; T:=0;\nmm:=m*3;\nfor i:=1 to 1000000 do\nif (i mod 2=0)and(i mod 3=0) then begin inc(t);a[t]:=i;end;\n\nminn:=maxlongint;\nfor i:=1 to t do\nbegin\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn>mm) then\n begin minn:=abs(nn-mm);mm:=mm+3;end else\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn<=mm)then\n begin minn:=abs(nn-mm);nn:=nn+2;end;\n\nend;\nwritelN(max(mm,nn));\n\n\nend."}, {"source_code": "uses math;\nvar n,m,mn,lik,t,kk,jj,minn:int64;\ni,j:longint;\na:array [0..10000] of int64;\nans,NN,MM:int64;\n\nfunction step(st, lik:int64):int64;\nvar ans:int64;\nJ:LONGINT;\nbegin\nans:=1;\nfor j:=1 to lik do\nans:=ans*st;\nstep:=ans;\nend;\n\n\n\nbegin\nreadln(n,m);\nnn:=n*2; T:=0;\nmm:=m*3;\nfor i:=1 to 22 do\nfor j:=1 to 14 do\nbegin\nans:=step(2,i)*step(3,j);\nif (ans<=min(nn,mm)) then begin inc(t);a[t]:=ans;end;\nend;\n\nminn:=maxlongint;\nfor i:=1 to t do\nbegin\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn>=mm) then\n begin minn:=abs(nn-mm);mm:=mm+3;end else\n\nif (a[i]<=nn)and(a[i]<=mm)and(nn b ) then\n begin\n maxAB := a;\n minAB := b;\n end\n else\n begin\n maxAB := b;\n minAB := a;\n end;\n\n if ( a = b ) then\n begin\n minPath := 0;\n exit;\n end\n else if ( n = 1 ) then\n begin\n minPath := 1;\n exit;\n end\n else if ( minAB = 1 ) and ( maxAB = fib[n] ) then\n begin\n minPath := ( n + 1 ) div 2;\n exit;\n end;\n\n if ( minAB = 1 ) and ( maxAB = id[n][0] ) then\n i := 1\n else if ( minAB = 1 ) and ( maxAB = id[n][1] ) then\n i := 2\n else if ( maxAB = fib[n] ) and ( minAB = id[n][0] ) then\n i := 3\n else if ( maxAB = fib[n] ) and ( minAB = id[n][1] ) then\n i := 4\n else\n i := 0;\n\n if ( i <> 0 ) and ( arr[n][i] <> 0 ) then\n begin\n minPath := arr[n][i];\n exit;\n end;\n\n if ( minAB = 1 ) then\n begin\n if ( maxAB > fib[n-1] ) then\n res := minPath( ( maxAB - fib[n-1] ), 1, (n-2) ) + 1\n else\n begin\n res := minPath( maxAB, 1, (n-1) );\n k := minPath( maxAB, fib[n-1], (n-1) ) + 2;\n\n res := min( res, k );\n end;\n end\n else if ( a <= fib[n-1] ) and ( b <= fib[n-1] ) then\n begin\n res := minPath( a, b, (n-1) );\n k := minPath( a, 1, (n-1) ) + minPath( b, fib[n-1], (n-1) ) + 2;\n res := min( res, k );\n k := minPath( b, 1, (n-1) ) + minPath( a, fib[n-1], (n-1) ) + 2;\n res := min( res, k );\n end\n else if ( maxAB = fib[n] ) then\n begin\n if ( minAB > fib[n-1] ) then\n res := minPath( ( minAB - fib[n-1] ), fib[n-2], (n-2) )\n else\n begin\n res := minPath( minAB, 1, (n-1) );\n k := minPath( minAB, fib[n-1], (n-1) );\n\n res := min( res, k ) + 1 + minPath( 1, fib[n-2], (n-2) );\n end;\n end\n else if ( a > fib[n-1] ) and ( b > fib[n-1] ) then\n res := minPath( ( a - fib[n-1] ), ( b - fib[n-1] ), (n-2) )\n else\n begin\n res := minPath( minAB, 1, (n-1) );\n k := minPath( minAB, fib[n-1], (n-1) );\n res := min( res, k );\n\n k := minPath( ( maxAB - fib[n-1] ), 1, (n-2) );\n res := res + k + 1;\n end;\n\n if ( i <> 0 ) then\n arr[n][i] := res;\n\n minPath := res;\nend;\n\nvar t, n, i, j: longWord;\n a, b, ap, bp: int64;\n\nbegin\n fib[0] := 1;\n fib[1] := 2;\n for i := 2 to 78 do\n fib[i] := fib[i-1] + fib[i-2];\n\n readln( t, n );\n\n n := min( n, 78 );\n\n for i := 1 to t do\n begin\n fillchar( arr, sizeOf(arr), 0 );\n\n readln( a, b );\n\n ap := a;\n bp := b;\n for j := n downTo 1 do\n begin\n if ( ap > fib[j] ) then\n ap := ap - fib[j];\n if ( bp > fib[j] ) then\n bp := bp - fib[j];\n\n id[j][0] := ap;\n id[j][1] := bp;\n end;\n\n writeln( minPath( a, b, n ) );\n end;\nend.\n", "positive_code": [{"source_code": "program graph;\nconst mx=82;\nvar\n t,n,i,j:longint;\n x,y:int64;\n g,a1,an,b1,bn,c:array[0..82] of longint;\n f,a,b:array[0..82] of int64;\n qa,qb:array[0..82] of boolean;\n\nprocedure swap(var x,y:int64);\nvar tmp:int64;\nbegin\n tmp:=x; x:=y; y:=tmp;\nend;\n\nfunction min(x,y:int64):int64;\nbegin\n if x<=y then exit(x) else exit(y);\nend;\n\nbegin\n readln(t,n);\n f[1]:=1; f[2]:=1;\n for i:=3 to mx do f[i]:=f[i-1]+f[i-2];\n for i:=2 to mx do g[i]:=g[i-1]+1-(i and 1);\n while t>0 do\n begin\n readln(x,y);\n j:=-1;\n if x>y then swap(x,y);\n for i:=min(n+1,mx) downto 1 do\n begin\n if (j<0)and(x<=f[i])and(y>f[i]) then j:=i;\n a[i]:=x;\n if (x>f[i]) then\n begin\n x:=x-f[i]; qa[i-1]:=true;\n end else qa[i-1]:=false;\n b[i]:=y;\n if (y>f[i]) then\n begin\n y:=y-f[i]; qb[i-1]:=true;\n end else qb[i-1]:=false;\n end;\n for i:=2 to min(n+1,mx) do\n begin\n if (a[i]<=f[i]) then\n begin\n a1[i]:=min(a1[i-1],an[i-1]+2);\n an[i]:=min(a1[i-1],an[i-1])+1+g[i-2];\n if i>j then\n begin\n c[i]:=c[i-1];\n if (not qa[i]) and (not qb[i]) then\n c[i]:=min(c[i],min(a1[i-1]+2+bn[i-1],an[i-1]+2+b1[i-1]));\n end;\n if i=j then c[i]:=min(a1[i-1],an[i-1])+1+b1[i-2];\n end else\n begin\n a1[i]:=a1[i-2]+1;\n an[i]:=an[i-2];\n if i>j then c[i]:=c[i-1];\n end;\n if b[i]<=f[i] then\n begin\n b1[i]:=min(b1[i-1],bn[i-1]+2);\n bn[i]:=min(b1[i-1],bn[i-1])+1+g[i-2];\n end else\n begin\n b1[i]:=b1[i-2]+1;\n bn[i]:=bn[i-2];\n end;\n end;\n writeln(c[min(n+1,mx)]);\n dec(t);\n end;\nend.\n\n"}], "negative_code": [], "src_uid": "7f9d6c14a77ee73c401c9d9b2b6602fa"} {"source_code": "var n,m,k,i:longint;\n ans:int64;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n readln(n,k);\n ans:=1;\n for i:=1 to k-1 do\n ans:=(ans*k) mod 1000000007;\n for i:=1 to n-k do\n ans:=(ans*(n-k)) mod 1000000007;\n writeln(ans);\nend.\n\n", "positive_code": [{"source_code": "var n,k,ans:int64;\ni,j:integer;\na:array [1..8,1..8] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\na[1,1]:=k;\nfor i:=2 to k do\n begin\n for j:=1 to i-1 do\n begin\n a[i,i]+=a[i-1,j]*j;\n a[i,j]+=a[i-1,j]*(k-i);\n end;\n end;\nans:=a[k,k];\nfor i:=k+1 to n do\n ans:=(ans*(n-k)) mod 1000000007;\nwriteln(ans);\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=1000001; besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar chis,znam,dl,len,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish,kol,m:longint;\nn,yy1,xx1,xx2,q,xx,yy,t1,t2,p,t,aa,modul,pp,tt,ot1,ot2,s,kold,ot,kkr:int64;\nostminus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\na,f,h,kop:array[0..2000000] of int64;\npred,c,x,y,b: array[-10..2000000] of int64;\nbb,marked:array[-10..250000] of boolean;\nss:array[0..2000000] of char;\nssgood:string;\nch11,ch12,ch1,ch:char;\ndd: array[-10..5001] of boolean;\nll,rr,sl,sr,stoim,str :array[-10 ..200000] of int64;\nsss:array[-1000..110000] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n procedure dfs(i0:longint); var i,j,k:longint;\nbegin\n marked[i0]:=true;\n for i:=sl[i0-1]+1 to sl[i0] do\n begin\n k:=str[i]; if not marked[k] then\n begin stoim[k]:=min(stoim[k],stoim[i0]+1);\n x[k]:=stoim[k]; pred[k]:=i0;\n dfs(k); end;\n end;\n\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n } modul:=1000000007 ;\n read(n,k);\n p:=1;\n for i:=1 to k-1 do begin t:=k; p:=(p*t) mod modul; end;\n\n for i:=1 to n-k do begin t:=n-k; p:=(p*t) mod modul; end;\n\n\n writeln(p);\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "//(n-m)^(n-m)*m^(m-1)\n\nconst modul=1000000007;\n\nvar n,m,ans: int64;\n\nfunction pow(x,y: int64): int64;\nbegin\n if y=0 then pow:=1\n else\n begin\n if y mod 2=1 then pow:=(pow(x,y-1)*x) mod MODUL\n else pow:=sqr(pow(x,y shr 1)) mod MODUL;\n end;\nend;\n\nbegin\n readln(n,m);\n\n ans:=(pow(n-m,n-m)*pow(m,m-1)) mod MODUL;\n\n writeln(ans);\nend.\n"}, {"source_code": "const\n tfi = '';\n tfo = '';\n Nmax = 1001;\n t:array[1..8] of longint =\n(1,\n2,\n9,\n64,\n625,\n7776,\n117649,\n2097152);\n p=1000000007 ;\ntype\n arr1 = array[0..Nmax] of longint ;\nvar\n fi,fo : text;\n n,m,nho,res : longint;\n // a,dd,p : arr1 ;\n{procedure DFS(i:longint);\nbegin\n if dd[i] = nho then exit;\n dd[i] := nho ;\n DFS(p[i]) ;\nend;\nprocedure check;\nvar\n i,j,k:longint;\nbegin\n for i := 1 to n do\n begin\n inc(nho) ;\n DFS(i) ;\n if dd[1] < nho then exit;\n end;\n inc(res) ;\nend;\nprocedure Try(i:longint) ;\nvar\nj:longint;\nbegin\n if i = n + 1 then check else\n for j := 1 to n do\n begin\n p[i] := j ;\n Try(i+1) ;\n end;\nend; }\nprocedure process;\nvar\n i,j,k:longint;\nbegin\n { for n := 1 to 8 do\n begin\n res := 0;\n try(1) ;\n writeln(fo,res) ;\n end;}\n read(fi,n,m);\n res := t[m];\n k := n - m ;\n For i := m + 1 to n do res := int64(res)*k mod p;\n write(fo,res) ;\nend;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n process;\n close(fi);\n close(fo) ;\nend.\n"}, {"source_code": "program poloandhouses;\nvar\n a,b,n,m,sum,i,j:longint;\n ans,re:int64;\nbegin\n readln(n,m);\n a:=n-m;\n ans:=1;\n for i:=1 to a do\n ans:=(ans*a) mod (1000000007);\n for i:=n downto a+2 do\n ans:=(ans*m) mod 1000000007;\n writeln(ans);\nend.\n"}, {"source_code": "Const\n kq:array [1..8] of longint=(1,2,9,64,625,7776,117649,2097152);\n oo=1000000007;\nType\n mat=array [0..1000,0..1000] of int64;\nVar a,p:mat;\n n,k:longint;\n res:int64;\n s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Read(fi,n,k);\n\n end;\n\n{Function Check:boolean;\n Var i,tg,j,ok:longint;\n Begin\n For i:=1 to k do\n Begin\n tg:=0;\n j:=i;\n ok:=0;\n Repeat\n j:=p[j];\n If j=1 then\n Begin\n ok:=1;\n break;\n end;\n inc(tg);\n Until tg=10;\n If ok=0 then exit(false);\n end;\n exit(true);\n end;\n\nProcedure Try(i:longint);\n Var j:longint;\n Begin\n If i=k+1 then\n Begin\n If Check then inc(res);\n end\n else\n For j:=1 to k do\n Begin\n p[i]:=j;\n Try(i+1);\n end;\n end; }\n\nProcedure Lam;\n Var i,j:longint;\n Begin\n For i:=0 to 1000 do a[i,0]:=1;\n For i:=0 to 1000 do\n For j:=1 to 1000 do a[i,j]:=(a[i,j-1]*i) mod oo;\n res:=(kq[k]*a[n-k,n-k]) mod oo;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n base=1000000007;\n\nvar\n qqq,res,n,k,i:longint;\n p,used:array[0..500500]of longint;\n u:array[0..500500]of boolean;\n \n function can(x:longint):boolean;\n begin\n if (x=1)or(used[x]=qqq)then begin\n can:=u[x] or (x=1);\n exit;\n end;\n used[x]:=qqq;\n u[x]:=false;\n u[x]:=can(p[x]);\n can:=u[x];\n end;\n\n procedure rec(x:longint);\n var\n i:longint;\n begin\n if (x>k)then begin\n inc(qqq);\n for i:=2 to k do if (not can(i))then exit;\n res:=res+1;\n exit;\n end;\n for i:=1 to k do begin\n p[x]:=i;\n rec(x+1);\n p[x]:=0;\n end;\n end;\n\nbegin\n read(n,k);\n res:=0;\n rec(2);\n for i:=k+1 to n do res:=int64(res)*(n-k)mod base;\n res:=int64(res)*k mod base;\n writeln(res);\nend.\n"}, {"source_code": "var\nans:int64;\na:array[0..100]of longint;\ni,n,k:longint;\nmd:longint;\nf:array[0..10]of boolean;\nused:array[0..10]of boolean;\n\nfunction ch:boolean;\nvar \nok:boolean;\nx,i:longint;\nbegin\n for i:=1 to k do \n begin\n x:=i;\n fillchar(f,sizeof(f),false);\n ok:=false;\n while true do \n begin\n x:=a[x];\n if x=1 then \n begin\n ok:=true;\n break;\n end;\n if f[x] then break;\n f[x]:=true; \n end;\n if (i>k)and(ok) then exit(false);\n if (i<=k)and(not ok) then exit(false);\n end;\n \n ch:=true; \nend;\nprocedure rec(x:longint);\nvar i:longint;\nbegin\n if x=k+1 then \n begin\n if ch then inc(ans);\n exit;\n end;\n for i:=1 to k do \n begin\n a[x]:=i;\n \n rec(x+1);\n a[x]:=0;\n end; \nend;\n begin\n readln(n,k);\n rec(1);\n md:=1000000007;\n for i:=1 to n-k do \n ans:=ans*int64(n-k) mod md;\n writeln(ans); \n end.\n"}, {"source_code": "const base=1000000000+7;\n mang:array[1..8]of longint=(1,2,9,64,625,7776,117649,2097152);\nvar f,s:array[1..1000]of longint;\n sum:int64;\n n,k:longint;\n\nprocedure update;\nvar i,t:longint;\n check:boolean;\nbegin\n fillchar(f,sizeof(f),0);\n for i:=1 to k do if f[i]=0 then begin\n t:=i; check:=false;\n while true do begin\n t:=s[t]; if t=1 then begin check:=true; break; end;\n if f[t]=1 then check:=true\n else if f[t]=-1 then check:=false;\n if f[t]<>0 then break;\n f[t]:=2;\n end;\n t:=i;\n while true do begin\n if check then f[t]:=1 else f[t]:=-1;\n t:=s[t];\n if (f[t]=1)or(f[t]=-1) then break;\n end;\n end;\n for i:=1 to k do if f[i]<>1 then exit;\n inc(sum);\nend;\n\nprocedure pick(p:longint);\nvar i:Longint;\nbegin\n for i:=1 to k do begin\n s[p]:=i;\n if p=k then update else pick(p+1);\n end;\nend;\n\nprocedure solve;\nvar ans,t:int64;\n i:longint;\nbegin\n t:=n-k; ans:=1;\n for i:=1 to t do ans:=(ans*t)mod base; sum:=mang[k];\n ans:=(ans*sum)mod base;\n writeln(ans);\nend;\n\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n readln(n,k);\n solve;\nend."}, {"source_code": "const q = 1000000007;\n\nvar mark: array [1..100000] of Boolean;\n p: array [1..1000000] of Longint;\n i, n, k: Longint;\n sum, rez: Int64;\n\nfunction prov: Boolean;\nvar i, j: Longint;\nBegin\n\n {if p[1] = 1 then begin\n prov := false;\n exit;\n end;}\n\n for i := 1 to k do begin\n for j := 1 to k do\n mark[j] := false;\n j := i;\n\n if i = 1 then begin\n j := p[j];\n end;\n\n while (mark[j] = false) and (j <> 1) do begin\n mark[j] := true;\n j := p[j];\n end;\n if j <> 1 then begin\n prov := false;\n exit;\n end;\n end;\n prov := true;\nend;\n\nprocedure src(x: Longint);\nvar i: Longint;\nBegin\n if x = k + 1 then begin\n if prov then\n inc(rez);\n rez := rez mod q;\n exit;\n end;\n for i := 1 to k do begin\n p[x] := i;\n src(x + 1);\n end;\nEnd;\n\nBegin\n read(n, k);\n sum := 1;\n for i := k + 1 to n do\n sum := (sum * (n - (k + 1) + 1)) mod q;\n src(1);\n sum := (sum * rez) mod q;\n write(sum);\nEnd.\n"}, {"source_code": "const m = 1000000007;\nvar\n i: longint;\n k, n, ans: int64;\n\nbegin\n read(n, k);\n\n ans := 1;\n\n for i := 1 to k - 1 do\n ans := ans * k mod m; \n\n for i := k + 1 to n do\n ans := ans * (n - k) mod m;\n\n write(ans);\nend."}, {"source_code": "const md=1000000007;\nVar ans:int64;\n o,n,m,i,j,k,cnt:longint;\n a:array[0..123,0..123]of boolean;\n used:array[0..123]of longint;\nprocedure dfs(v:longint);\n var j:longint;\n begin\n used[v]:=o;\n inc(cnt);\n for j:=1 to k do\n if a[v,j] and (used[j]<>o) then dfs(j);\n end;\nprocedure rec(x:longint);\n var j:longint;\n begin\n if x=k+1 then\n begin\n cnt:=0;\n inc(o);\n dfs(1);\n if cnt=k then inc(ans);\n exit;\n end;\n for j:=1 to k do\n begin\n a[j,x]:=true;\n rec(x+1);\n a[j,x]:=false;\n end;\n end;\n begin\n read(n,k);\n if k=8 then ans:=2097152 else\n rec(1);\n for i:=k+1 to n do\n ans:=(ans*(n-k))mod md;\n Writeln(ans);\n end."}, {"source_code": "CONST\n tfi ='';//'b.inp';\n tfo ='';//'b.out';\n oo =1000000007;\nVAR\n fi,fo :text;\n n,k,res :longint;\n (******************************************************************)\nProcedure lam;\n Var\n i :longint;\n p,q :longint;\n Begin\n read(fi,n,k);\n p:=1;\n for i:=1 to k-1 do p:=p*k;\n q:=1;\n for i:=1 to n-k do q:=(int64(q)*(n-k)) mod oo;\n res:=(int64(p)*q) mod oo;\n write(fo,res);\n End;\n (**********************************************************************)\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n lam;\n close(fi);\n close(fo);\nEND."}, {"source_code": "Const md=1000000007;\nvar i,j:longint;\n q,x,n,k,ans,f:int64;\n c:array[0..100]of boolean;\n b:array[0..100]of longint;\nfunction dfs:boolean;\nvar x,i:longint;\n begin\n for i:=2 to k do\n begin\n fillchar(c,sizeof(c),false);\n x:=b[i];\n while not(c[x]) do\n begin\n c[x]:=true;\n x:=b[x];\n end;\n if not(c[1])then exit(false);\n end;\n exit(true);\n end;\nprocedure rec(x:longint);\nvar i:longint;\n begin\n if(x=k+1) then\n begin\n if dfs then inc(f);\n exit;\n end;\n for i:=1 to k do\n begin\n b[x]:=i;\n rec(x+1);\n end;\n end;\n begin\n read(n,k);\n q:=n-k;\n x:=1;\n f:=0;\n for i:=1 to q do\n x:=(x*q)mod md;\n rec(2);\n ans:=(x*k)mod md;\n ans:=(ans*f)mod md;\n writeln(ans);\n end."}, {"source_code": "const\n co=trunc(1e+9)+7;\nvar\n i,j,n,k,x,t:longint;\n ans,p:int64;\n a:array[1..8]of longint;\n f:array[1..8]of boolean;\n\nfunction found(q:longint):boolean;\nvar\n w:longint;\nbegin\n w:=0;\n while true do\n begin\n inc(w);\n if w>k then exit(false);\n if q=1 then exit(true)else q:=a[q];\n end;\n exit(false);\nend;\n\nfunction check:boolean;\nbegin\n for j:=1 to k do if not found(j) then exit(false);\n exit(true);\nend;\n\nprocedure rec(i,x:longint);\nvar\n j:longint;\nbegin\n a[x]:=i;\n if x=k then\n begin\n if check then ans:=(ans+p)mod co;\n exit;\n end;\n for j:=1 to k do rec(j,x+1);\nend;\n\nbegin\n readln(n,k);\n p:=n-k;\n for i:=2 to n-k do p:=(p*(n-k))mod co;\n if p=0 then p:=1;\n for i:=1 to k do rec(i,1);\n writeln(ans);\nend."}, {"source_code": "Var n,k,q,ans:Int64;\n i:LongInt;\n a:Array[0..1000] of Int64;\nProcedure rec(n:Int64);\nVar num,t,numb:Int64;\n i:LongInt;\n b:Array[0..1000] of Boolean;\n y,y1:Boolean;\n begin\n if n=k+1 then\n begin\n y:=true;\n For i:=2 to k do\n begin\n fillchar(b,sizeof(b),false);\n t:=a[i];\n While not(b[t]) do\n begin\n b[t]:=true;\n t:=a[t];\n end;\n if not b[1] then y:=false;\n end;\n if y then inc(ans);\n exit;\n end;\n For i:=1 to k do\n begin\n a[n]:=i;\n rec(n+1);\n end;\n end;\n begin\n Read(n,k);\n q:=1;\n For i:=1 to n-k do\n begin\n q:=(q*(n-k)) mod 1000000007;\n end;\n ans:=0;\n rec(2);\n q:=(q*ans*k) mod 1000000007;\n WriteLn(q);\n end."}, {"source_code": "uses math;\nconst\n nmax = 1001;\n modul = 1000000007;\nvar\n n,k,sol:longint;\n res:int64;\n F,free:Array[0..nmax] of boolean;\n p:Array[0..nmax] of longint;\nprocedure visit(u:longint);\nvar v:longint;\nbegin\n free[u]:=false;\n F[u]:=false;\n v:=p[u];\n if (v>1)and(free[v]) then visit(v);\n if (v=1)or F[v] then f[u]:=true;\nend;\nfunction check:boolean;\nvar i:longint;\nbegin\n for i:=2 to k do free[i]:=true;\n for i:=2 to k do\n begin\n if free[i] then visit(i);\n if F[i]=false then exit(false);\n end;\n exit(true);\nend;\nprocedure DFS(i:longint);\nvar j:longint;\nbegin\n if i>k then\n begin\n if check then inc(Sol);\n exit;\n end;\n for j:=1 to k do\n begin\n p[i]:=j;\n DFS(i+1);\n end;\nend;\nprocedure process;\nvar i,j,u,v:longint;\nbegin\n read(n,k);\n res:=k;\n for i:=k+1 to n do res:=(res*(n-k))mod modul;\n Sol:=0;\n DFS(2);\n res:=(res*sol)mod modul;\n writeln(res);\nend;\nbegin\n assign(input,'');reset(input);\n process;\nend.\n"}, {"source_code": "program Project1;\n\n{$MODE DELPHI}\n{$APPTYPE CONSOLE}\n{$O+}\n\nuses\n SysUtils;\n\nconst\n M = 1000000007;\n\nvar\n n, k, res : int64;\n top, i : integer;\n a : array[1..100] of integer;\n\nprocedure check;\nvar\n i, j, p : integer;\n bool : boolean;\nbegin\n for i := 1 to k do begin\n p := i;\n bool := false;\n for j := 1 to k do begin\n p := a[p];\n if (p = 1) then begin\n bool := true;\n break;\n end;\n end;\n if not bool then\n exit;\n end;\n inc(res);\nend;\n\nprocedure gen;\nvar\n i : integer;\nbegin\n if (top = k) then begin\n check;\n exit;\n end;\n for i := 1 to k do begin\n inc(top);\n a[top] := i;\n gen;\n dec(top);\n end; \nend;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n read(n, k);\n\n gen;\n for i := k + 1 to n do\n res := (res * (n - k)) mod M;\n\n writeln(res);\n\nend.\n "}, {"source_code": "program baib;\nconst finp='';\n\t somod=trunc(1e9)+7;\ntype mangcha=array[1..8] of longint;\nvar n,k,kq:longint;\n\tf:text;\n fa:mangcha;\n dem:longint;\n\nprocedure nhap;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure vet(vt:longint;fa:mangcha);\nvar i,j,x:longint;\nbegin\n if vt=k+1 then\n begin\n inc(dem);\n exit;\n end;\n for i:=1 to k do\n begin\n \tif i=vt then continue;\n\t\tfa[vt]:=i;\n x:=vt;\n j:=0;\n while (fa[x]<>x) do\n\t\tbegin\n \tx:=fa[x];\n inc(j);\n if j=9 then break;\n end;\n if j<>9 then vet(vt+1,fa);\n end;\nend;\n\nfunction tinh2(x:longint):longint;\nvar tam:qword;\nbegin\n\tif x=0 then exit(1);\n\tif x=1 then exit(n-k);\n tam:=tinh2(x div 2);\n tam:=tam*tam mod somod;\n if x and 1 = 1 then tam:=tam*(n-k) mod somod;\n exit(tam);\nend;\n\nprocedure xuli;\nvar i,tam:longint;\nbegin\n\ttam:=tinh2(n-k);\n for i:=1 to 8 do fa[i]:=i;\n vet(2,fa);\n kq:=qword(tam)*dem*k mod somod;\nend;\n\nBEGIN\n nhap;\n xuli;\n writeln(kq);\nEND.\n"}, {"source_code": "var\n used: array[1..10] of boolean;\n a: array[1..10] of integer;\n n, k: longint;\n q, ans: int64;\n\nfunction dfs(x: longint): boolean;\nbegin\n if used[x] then \n begin\n if x = 1 then dfs := true else dfs := false;\n exit;\n end;\n used[x] := true;\n dfs := dfs(a[x]);\n used[x] := false;\nend;\n\nprocedure check();\nvar\n i: longint;\n h: boolean;\nbegin\n h := true;\n for i := 1 to k do \n if not dfs(i) then h := false;\n if h then inc(ans);\n ans := ans mod 1000000007;\n for i := 1 to k do used[i] := false;\nend;\n\nfunction pow(x, y: int64): int64;\nvar\n r: int64;\n i: longint;\nbegin\n r := 1;\n for i := 1 to y do r := r * x mod 1000000007;\n pow := r;\nend;\n\nbegin\n \n read(n, k);\n \n a[1] := 1;\n a[2] := 2;\n a[3] := 9;\n a[4] := 64;\n a[5] := 625;\n a[6] := 7776;\n a[7] := 117649;\n a[8]:= 2097152;\n q := pow(n - k, n - k);\n writeln(a[k] * q mod 1000000007);\nend."}, {"source_code": "const c=1000000007;\nvar q,ans: qword;\n n,k,i,j: longint;\n begin\n readln(n,k);\n ans:=1;\n q:=k;\n for i:=1 to k-1 do ans:=(ans*q) mod c;\n if k=1 then ans:=1;\n q:=n-k;\n for i:=k+1 to n do ans:=(ans*q) mod c;\n writeln(ans);\n end."}, {"source_code": "const M = 1000000007;\nvar n, k, i : longint;\n ans : int64;\nbegin\n readln(n,k);\n ans := 1;\n For i := 1 to n-k do\n ans := (ans*(n-k)) mod M;\n For i := 1 to k-1 do\n ans := (ans*k) mod M;\n writeln(ans);\nend."}, {"source_code": "const\n finp='';\n fout='';\n modp=1000000007;\nvar a,dau:array [1..10] of longint;\n n,k,dem,t,i:longint;\n KQ:int64;\n f,g:text;\nfunction kt:boolean;\nvar i,x,j:longint;\nbegin\n for i:=1 to k do\n begin\n x:=i;\n for j:=1 to k do dau[j]:=0;\n while (x<>1) and (dau[x]<>1) do\n begin dau[x]:=1; x:=a[x]; end;\n if x<>1 then exit(false);\n end;\n exit(true);\nend;\nprocedure duyet(d,vt:longint);\nvar i:longint;\nbegin\n if d=k then\n begin\n if kt then inc(dem);\n exit;\n end;\n for i:=1 to k do\n begin\n if (vt<>1) and (vt=i) then continue;\n a[vt]:=i; duyet(d+1,vt+1);\n a[vt]:=0;\n end;\nend;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n readln(f,n,k); duyet(0,1);\n KQ:=dem mod ModP; t:=n-k;\n for i:=k+1 to n do\n KQ:=(KQ*t) mod modp;\n write(g,KQ); close(f); close(g);\nend.\n"}, {"source_code": "var i:longint;\n ans,md,n,k:int64;\n begin\n md:=1000000007;\n read(n,k);\n ans:=1;\n\n for i:=2 to k do\n ans:=ans*k;\n for i:=k+1 to n do\n ans:=ans*(n-k) mod md;\n writeln(ans);\n end."}, {"source_code": "const MO=1000000007;\nVar\nn,k,i,j:longint;\nans:int64;\n\nBegin\nread(n,k);\nans:=1;\nfor i:=1 to k-1 do\nans:=(ans*k) mod MO;\n\n for i:=1 to (n-k) do\n ans:=(ans*(n-k)) mod MO;\nwriteln(ans);\nEnd."}, {"source_code": "const fi = '';\n fo = '';\n e = round(1e9)+7;\nvar i, n, k: longint;\n cnt, cnt2: int64;\n p: array [1..8] of longint;\n\nprocedure EndProg;\nbegin\n close(input); close(output);\n halt;\nend;\n\nfunction Check(x: longint): boolean;\nvar v: longint;\n visited: array [1..8] of boolean;\nbegin\n //if (x = 1) and (p[x] = 1) then exit(true);\n fillchar(visited, sizeof(visited), false);\n visited[x]:=true;\n while true do\n begin\n x:=p[x];\n if x = 1 then exit(true)\n else if not visited[x] then visited[x]:=true\n else exit(false);\n end;\nend;\n\nprocedure Generate(i: longint);\nvar j: longint;\nbegin\n if i > k then\n begin\n for j:=1 to k do\n if not Check(j) then exit;\n inc(cnt);\n exit;\n end;\n for j:=1 to k do\n begin\n p[i]:=j;\n Generate(i+1);\n end\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n readln(n, k);\n\n Generate(1);\n\n cnt2:=1;\n for i:=k+1 to n do cnt2:=(cnt2*(n-k)) mod e;\n\n writeln((cnt*cnt2) mod e);\n\n close(input); close(output);\nend.\n"}, {"source_code": "const MAXK = 8;\n modulo = 1000000007;\n\nvar p , d : array [1..MAXK] of int64;\n good : array [1..MAXK] of boolean;\n ans : int64;\n\nprocedure supercheck( curr , time , k : longint );\nbegin\n\n if time > k + 1 then exit;\n if ( good[ curr ] ) or ( curr = 1 ) then begin\n good[ curr ]:=true;\n exit;\n end; \n \n supercheck( p[curr] , time+1 , k );\n good[curr]:=good[ p[curr] ];\n \nend; \n\nfunction check( k : longint ) : boolean; \nvar i : longint ;\nbegin\n \n for i:=1 to k do good[i]:=false;\n \n for i:=2 to k do begin\n \n supercheck( i , 0 , k );\n if not good[i] then exit( false );\n \n end;\n \n exit( true );\n \nend; \n\nprocedure solve( k , curr : longint );\nvar i : longint ;\nbegin\n\n if curr <= k then begin\n \n for i:=1 to k do begin\n p[curr]:=i;\n solve( k , curr + 1 );\n end;\n \n end\n else begin\n \n if check( k ) then inc( ans );\n //writeln( p[1] ,' ',p[2],' ',p[3],' ',ans);\n end;\n \nend; \n\nfunction power( a , b : longint ) : int64;\nvar res , y : int64;\nbegin\n\n if b = 0 then exit( 1 );\n \n if b mod 2 = 1 then res:=a else res:=1;\n y := sqr( power( a , b div 2 ) ) mod modulo;\n res:=res * y;\n res:=res mod modulo;\n \n exit( res );\n \nend; \n\nvar k , n : longint ;\n x : int64;\nbegin\n \n d[1]:=1; d[2]:=2; d[3]:=9; d[4]:=64; d[5]:=625; d[6]:=7776; d[7]:=117649; \n d[8]:=2097152;\n \n readln( n , k );\n \n x:=Power( n - k , n - k );\n \n writeln( ( x * d[k] ) mod modulo );\n \n \nend. \n \n"}, {"source_code": "const inf=1000000007;\nvar n,m,s:int64;\nfunction binPOW(n,m:int64):int64;\nbegin\n if m=0 then binPOW:=1\n else begin\n if m mod 2=1 then binPOW:=(binPOW(n,m-1)*n) mod inf\n else binPOW:=sqr(binPOW(n,m shr 1)) mod inf;\n end;\nend;\nbegin\n readln(n,m);\n s:=(binPOW(n-m,n-m)*binPOW(m,m-1)) mod inf;\n writeln(s);\nend.\n"}, {"source_code": "var\n used: array[1..10] of boolean;\n a: array[1..10] of integer;\n n, k: longint;\n q, ans: int64;\n\nfunction dfs(x: longint): boolean;\nbegin\n if used[x] then \n begin\n if x = 1 then dfs := true else dfs := false;\n exit;\n end;\n used[x] := true;\n dfs := dfs(a[x]);\n used[x] := false;\nend;\n\nprocedure check();\nvar\n i: longint;\n h: boolean;\nbegin\n h := true;\n for i := 1 to k do \n if not dfs(i) then h := false;\n if h then inc(ans);\n ans := ans mod 1000000007;\n for i := 1 to k do used[i] := false;\nend;\n\nfunction pow(x, y: int64): int64;\nvar\n r: int64;\n i: longint;\nbegin\n r := 1;\n for i := 1 to y do r := r * x mod 1000000007;\n pow := r;\nend;\n\nbegin\n \n read(n, k);\n \n a[1] := 1;\n a[2] := 2;\n a[3] := 9;\n a[4] := 64;\n a[5] := 625;\n a[6] := 7776;\n a[7] := 117649;\n a[8]:= 2097152;\n q := pow(n - k, n - k);\n writeln(a[k] * q mod 1000000007);\nend."}, {"source_code": "const module=1000000007;\nvar\n f:array[1..8] of longint; used:array[1..8] of boolean; ans,n,k:int64; i:longint;\n\n\nfunction can(nom:longint):boolean;\nbegin\n fillchar(used,sizeof(used),false);\n while true do\n begin\n if nom=1 then exit(true);\n if used[nom]=true then exit(false);\n used[nom]:=true; nom:=f[nom];\n end;\nend;\n\n\nprocedure rec(nom:longint);\nvar i:longint;\nbegin\n if nom>k then\n begin\n for i:=2 to k do if can(i)=false then exit;\n inc(ans);\n end\n else\n begin\n for i:=1 to k do\n begin\n f[nom]:=i; rec(nom+1);\n end;\n end;\nend;\n\n\nbegin\n\n readln(n,k); ans:=0; rec(2); ans:=ans*k;\n for i:=k+1 to n do ans:=(ans*(n-k)) mod module;\n writeln(ans);\n\nend."}, {"source_code": "const md=1000000007;\nvar n,k,br,m,i,br1:longint;\n r:int64;\n nb,nb1,niz:array[0..100] of longint;\nprocedure rek(x:longint);\nvar i,j:longint;\nbegin\n if x>k then\n begin\n inc(br);\n for j:=1 to k do\n begin\n i:=j;\n inc(br1);\n while (i<>1) and (nb[i]<>br) do\n begin\n nb1[i]:=br1;\n i:=niz[i];\n if nb1[i]=br1 then exit;\n end;\n nb[j]:=br;\n end;\n inc(r);\n exit;\n end;\n for i:=1 to k do\n begin\n niz[x]:=i;\n rek(x+1);\n end;\nend;\nbegin\n readln(n,k);\n rek(1);\n m:=n-k;\n if m>0 then\n for i:=1 to m do\n r:=(r*m) mod md;\n writeln(r);\nend.\n"}, {"source_code": "program problem2;\n\nconst md =\t1000000007;\n\nfunction pow( a, p: longInt ): qWord;\nvar\tres: qWord;\nbegin\n\tres := 1;\n\twhile ( p > 0 ) do\n\tbegin\n\t\tif ( odd(p) ) then\n\t\t\tres := ( res * a ) mod md;\n\t\t\t\n\t\ta := ( qWord(a) * a ) mod md;\n\t\tp := p div 2;\n\tend;\n\t\n\texit( res );\nend;\n\nvar\tn, k, ans: longInt;\n\nbegin\n\treadln( n, k );\n\t\n\tans := ( pow( k, k - 1 ) * pow( n - k, n - k ) ) mod md;\n\t\n\twriteln( ans );\nend.\n"}, {"source_code": "var n,k,ans:int64;\ni,j:integer;\na:array [1..8,1..8] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\na[1,1]:=k;\nfor i:=2 to k do\n begin\n for j:=1 to i-1 do\n begin\n a[i,i]+=a[i-1,j]*j;\n a[i,j]+=a[i-1,j]*(k-i);\n end;\n end;\nans:=a[k,k];\nfor i:=k+1 to n do\n ans:=(ans*(n-k)) mod 1000000007;\nwriteln(ans);\nend."}, {"source_code": "Var n,k,q,ans:Int64;\n i:LongInt;\n a:Array[0..1000] of Int64;\nProcedure rec(n:Int64);\nVar num,t,numb:Int64;\n i:LongInt;\n b:Array[0..1000] of Boolean;\n y,y1:Boolean;\n begin\n if n=k+1 then\n begin\n y:=true;\n For i:=2 to k do\n begin\n fillchar(b,sizeof(b),false);\n t:=a[i];\n While not(b[t]) do\n begin\n b[t]:=true;\n t:=a[t];\n end;\n if not b[1] then y:=false;\n end;\n if y then inc(ans);\n exit;\n end;\n For i:=1 to k do\n begin\n a[n]:=i;\n rec(n+1);\n end;\n end;\n begin\n Read(n,k);\n q:=1;\n For i:=1 to n-k do\n begin\n q:=(q*(n-k)) mod 1000000007;\n end;\n ans:=0;\n rec(2);\n q:=(q*ans*k) mod 1000000007;\n WriteLn(q);\n end."}, {"source_code": "var\n m,i,n,k:longint;\n s:int64;\nbegin\n readln(n,k);\n s:=1;\n m:=1000000000+7;\n for i:=1 to k-1 do\n s:=s*k mod m;\n for i:=1 to n-k do\n s:=s*(n-k) mod m;\n write(s);\nend.\n"}, {"source_code": "const md=1000000007;\nvar f:array[1..8] of boolean;\na:array[2..8] of longint;\nn,k,sum:int64;\nfunction ksm(x,n:int64):int64;\nvar s:int64;\nbegin\ns:=1;\nwhile n<>0 do\n begin\n if n mod 2=1 then s:=(s*x) mod md;\n x:=(x*x) mod md;n:=n div 2;\n end;\nexit(s);\nend;\nprocedure sc(t:longint);\nvar i,x:longint;\nbegin\nif t>k then\n begin\n for i:=2 to k do\n begin\n fillchar(f,sizeof(f),false);\n f[i]:=true;x:=a[i];\n while x<>1 do\n begin\n if f[x] then break;\n f[x]:=true;x:=a[x];\n end;\n if x<>1 then exit;\n end;\n sum:=sum+1;if sum=md then sum:=0;exit;\n end;\nfor i:=1 to k do\n begin\n a[t]:=i;sc(t+1);\n end;\nend;\nbegin\n//assign(input,'qedfw.in');reset(input);\n//assign(output,'qedfw.out');rewrite(output);\nreadln(n,k);sc(2);\nwriteln((ksm(n-k,n-k)*((sum*k) mod md)) mod md);\nclose(input);close(output);\nend.\n"}, {"source_code": "const md=1000000007;\nvar i:longint;n,k,s,ans:int64;\ne:array[0..9] of boolean;\na:array[0..9] of longint;\nprocedure sc(t:integer);\nvar i,j:integer;f:boolean;\nbegin\nif t>k then\n begin\n f:=true;\n for i:=2 to k do\n begin\n fillchar(e,sizeof(e),false);\n j:=i;\n while (j<>1) and (not e[j]) do\n begin e[j]:=true;j:=a[j];end;\n if j<>1 then f:=false;\n if not f then break;\n end;\n ans:=ans+ord(f);\n exit;\n end;\nfor i:=1 to k do\n begin a[t]:=i;sc(t+1);end;\nend;\nbegin\n//assign(input,'qehfw.in');reset(input);\n//assign(output,'qehfw.out');rewrite(output);\nreadln(n,k);s:=1;\nfor i:=1 to n-k do\n s:=s*(n-k) mod md;\ns:=s*k mod md;sc(2);\nwriteln(s*ans mod md);\nclose(input);close(output);\nend."}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n base=1000000007;\n\nvar\n qqq,res,n,k,i:longint;\n p,used:array[0..500500]of longint;\n u:array[0..500500]of boolean;\n \n function can(x:longint):boolean;\n begin\n if (x=1)or(used[x]=qqq)then begin\n can:=u[x] or (x=1);\n exit;\n end;\n used[x]:=qqq;\n u[x]:=false;\n u[x]:=can(p[x]);\n can:=u[x];\n end;\n\n procedure rec(x:longint);\n var\n i:longint;\n begin\n if (x>k)then begin\n inc(qqq);\n for i:=2 to k do if (not can(i))then exit;\n res:=res+1;\n exit;\n end;\n for i:=1 to k do begin\n p[x]:=i;\n rec(x+1);\n p[x]:=0;\n end;\n end;\n\nbegin\n read(n,k);\n res:=0;\n rec(2);\n for i:=k+1 to n do res:=int64(res)*(n-k)mod base;\n res:=int64(res)*k mod base;\n writeln(res);\nend.\n"}, {"source_code": "const md=round(1e9)+7;\nvar\n n,k,j,i : longint;\n data : array [0..8] of qword;\n function bpow(a,n : qword) : qword;\n var k : qword;\n begin\n if (n=1) then exit(a);\n if (n=0) then exit(1);\n if ((n mod 2)=0) then\n begin\n k:=bpow(a,n div 2);\n exit(k*k);\n end else exit(bpow(a,n-1)*a);\n end;\nbegin\n readln(n,k);\n for i:=1 to 8 do data[i]:=bpow(i,i-1);\n for i:=1 to 8 do\n for j:=1 to (n-k) do\n data[i]:=(data[i]*(n-k)) mod md;\n writeln(data[k]);\nend.\n\n\n"}, {"source_code": "{-Lost-}\n\n{$mode objfpc}\n\nconst\n fi = '';\n fo = '';\n base = 1000000007;\n\nvar\n n,k: integer;\n res,t: int64;\n\nprocedure enter;\nvar i: integer;\nbegin\n readln(n,k);\n res:=1;\n t:=int64(n-k);\n for i:=1 to n-k do res:=(res*t) mod base;\n for i:=1 to k-1 do res:=(res*k) mod base;\n writeln(res);\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n enter;\nend."}, {"source_code": "const md=1000000007;\nVar ans:int64;\n o,n,m,i,j,k,cnt:longint;\n a:array[0..123,0..123]of boolean;\n used:array[0..123]of longint;\nprocedure dfs(v:longint);\n var j:longint;\n begin\n used[v]:=o;\n inc(cnt);\n for j:=1 to k do\n if a[v,j] and (used[j]<>o) then dfs(j);\n end;\nprocedure rec(x:longint);\n var j:longint;\n begin\n if x=k+1 then\n begin\n cnt:=0;\n inc(o);\n dfs(1);\n if cnt=k then inc(ans);\n exit;\n end;\n for j:=1 to k do\n begin\n a[j,x]:=true;\n rec(x+1);\n a[j,x]:=false;\n end;\n end;\n begin\n read(n,k);\n if k=8 then ans:=2097152 else\n rec(1);\n for i:=k+1 to n do\n ans:=(ans*(n-k))mod md;\n Writeln(ans);\n end."}, {"source_code": "uses\n Math;\n \nconst\n md = round(1e+9) + 7;\n\nvar\n n, k, ans: int64;\n i: integer;\n\nbegin\n readln(n, k);\n ans := 1;\n for i := 1 to k - 1 do begin\n ans := ans * k;\n ans := ans mod md;\n end;\n for i := 1 to (n - k) do begin\n ans := ans * (n - k);\n ans := ans mod md;\n end;\n write(ans);\nend."}, {"source_code": "const\nmaxn=1000000007;\nvar\ni : longint;\nn,k,t,y : int64;\nbegin\n readln(n,k);\n t:=1;\n for i:=1 to n-k do\n t:=t*(n-k) mod maxn;\n y:=1;\n for i:=1 to k-1 do\n y:=y*k mod maxn;\n writeln(t*y mod maxn);\nend.\n"}, {"source_code": "Var n,i:longint;\nk,e,rez:int64;\nm:array [1..8] of longint;\nUsed:array [1..8] of boolean;\nprocedure dfs(v:longint);\nbegin\n if (used[v])\n then exit;\n used[v]:=true;\n if v=1\n then exit;\n dfs(m[v]);\nend;\nprocedure rec(v:longint);\nVar i:longint;\nbegin\n if v>k\n then begin\n for i:=2 to k do\n begin\n fillchar(used,SizeOf(used),false);\n dfs(i);\n if not used[1]\n then Exit;\n end;\n inc(rez);\n exit;\n end;\n for i:=1 to k do\n begin\n if (v>1)and(v=i)\n then Continue;\n m[v]:=i;\n rec(v+1);\n end;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n,k);\n rez:=0;\n if n=1\n then begin writeln(1); halt(0); end;\n rec(2);\n e:=n-k;\n for i:=k+1 to n do\n rez:=(rez*e) mod 1000000007;\n rez:=(rez*k) mod 1000000007;\n writeln(rez);\nEnd."}, {"source_code": "Program d178;\nVar\n n,k,modd,i:Longint;\n sum:Int64;\n ans:Array[1..8] Of Longint=(1,2,9,64,625,7776,117649,2097152);\nBegin\n Readln(n,k);\n sum:=ans[k];\n modd:=1000000007;\n For i:=1 To n-k Do sum:=sum*(n-k) Mod modd;\n Writeln(sum);\nEnd.\n\n"}, {"source_code": "Const md=1000000007;\nvar i,j:longint;\n q,x,n,k,ans,f:int64;\n c:array[0..100]of boolean;\n b:array[0..100]of longint;\nfunction dfs:boolean;\nvar x,i:longint;\n begin\n for i:=2 to k do\n begin\n fillchar(c,sizeof(c),false);\n x:=b[i];\n while not(c[x]) do\n begin\n c[x]:=true;\n x:=b[x];\n end;\n if not(c[1])then exit(false);\n end;\n exit(true);\n end;\nprocedure rec(x:longint);\nvar i:longint;\n begin\n if(x=k+1) then\n begin\n if dfs then inc(f);\n exit;\n end;\n for i:=1 to k do\n begin\n b[x]:=i;\n rec(x+1);\n end;\n end;\n begin\n read(n,k);\n q:=n-k;\n x:=1;\n f:=0;\n for i:=1 to q do\n x:=(x*q)mod md;\n rec(2);\n ans:=(x*k)mod md;\n ans:=(ans*f)mod md;\n writeln(ans);\n end."}, {"source_code": "{$mode objfpc}\n\n\nconst base = trunc( 1E9 ) + 7;\n\n\nvar n , k , i , j : integer; \n res : int64;\n\n\nbegin\n readln( n , k );\n res := 1;\n for i := 1 to n - k do res := ( res * int64( n - k ) ) mod base;\n for i := 1 to k - 1 do res := ( res * int64( k ) ) mod base;\n writeln( res );\nend.\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\n{$maxstacksize 100000000}\nUses SysUtils,math;\nVar\n p,f,t:Array[0..5000] of Int64;\n n,k,md,w,r,it:Int64;\n i:Integer;\nFunction Solve(i:Integer):Integer;\nBegin\n If t[i]=it Then Begin\n Solve:=f[i];\n Exit;\n End;\n If i=1 Then Begin\n Solve:=1;\n Exit;\n End;\n f[i]:=-it;\n t[i]:=it;\n If f[p[i]]=-it Then Begin\n f[i]:=0;\n Solve:=0;\n Exit;\n End;\n f[i]:=Solve(p[i]);\n Solve:=f[i];\nEnd;\nProcedure Search(i:Integer);\nVar j,f1:Integer;\nBegin\n If i>k Then Begin\n it:=it+1;\n f[1]:=1;\n For j:=1 To k Do Solve(j);\n f1:=1;\n For j:=1 To k Do\n If f[j]=0 Then f1:=0;\n If f1=1 Then r:=r+1;\n Exit;\n End;\n For j:=1 To k Do\n If (i<>j) or (j=1) Then Begin\n p[i]:=j;\n Search(i+1);\n End;\nEnd;\nBegin\n Read(n,k);\n md:=1000000007;\n r:=0;\n it:=10;\n Search(1);\n If k=1 Then r:=1;\n w:=1;\n For i:=1 To n-k Do w:=w*(n-k) mod md;\n Write(r*w mod md);\nEnd."}, {"source_code": "{$mode delphi}\nconst bigp=1000000007;\nvar n,k,i:integer;\n c,ans:int64;\n a:array[1..10]of integer;\nprocedure check;\nvar used:array[1..10]of boolean;\n i,j:integer;\nbegin\n for i:=1 to k do begin\n fillchar(used,sizeof(used),0);\n j:=i;\n while (not used[j]) and (1<>j) do begin\n used[j]:=true;\n j:=a[j];\n end;\n if j<>1 then exit; \n end;\n ans:=ans+1; \nend;\n\nprocedure worker(v:integer);\nvar i:integer; \nbegin\n if v=k+1 then check\n else begin\n for i:=1 to k do begin\n if (v=1) or (i<>v) then begin\n a[v]:=i;\n worker(v+1);\n a[v]:=0;\n end; \n end;\n end;\nend;\nbegin\n read (n,k);\n ans:=0;\n worker(1);\n //writeln (ans);\n c:=n-k;\n for i:=1 to c do begin\n ans:= (ans*c) mod bigp;\n end;\n writeln (ans);\nend."}, {"source_code": "uses math;\nconst fi='';//mau.inp';\n fo='';//mau.out';\n maxn=1000000007;\n mh:array[1..8] of longint=(1,2,9,64,625,7776,117649,2097152);\nvar n,k:longint;\nprocedure docfile;\n begin\n assign(input,fi);\n reset(input);\n readln(n,k);\n assign(output,fo);\n rewrite(output);\n end;\nprocedure dongfile;\n begin\n close(input); close(output);\n end;\nprocedure xuli;\n var i,res:longint;\n begin\n res:=mh[k];\n for i:=1 to (n-k) do\n res:=int64(res)*(n-k) mod maxn;\n writeln(res);\n end;\nBEGIN\n docfile;\n xuli;\n dongfile;\nEND.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n, m: integer;\n res: int64;\n a, b: array[1..10000] of integer;\n\nfunction f(x: integer): integer;\nbegin\n b[x] := -2;\n if (b[a[x]] = -1) then begin\n result := f(a[x]);\n end else begin\n if (b[a[x]] = -2) then begin\n result := -2;\n end else begin\n result := 1;\n end;\n end;\n b[x] := result;\nend;\n\nfunction good: boolean;\nvar\n i: integer;\nbegin\n for i := 2 to m do\n b[i] := -1;\n\n for i := 2 to m do begin\n b[i] := f(i);\n if (b[i] = -2) then begin\n result := false;\n exit;\n end;\n end;\n result := true;\nend;\n\nfunction get(x: integer): int64;\nvar\n i: integer;\nbegin\n if (x = m + 1) then begin\n if (good) then\n result := 1\n else\n result := 0;\n exit;\n end;\n\n result := 0;\n\n for i := 1 to m do begin\n if (i <> x) then begin\n a[x] := i;\n result := result + get(x + 1);\n end;\n end;\n\nend;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(n, m);\n\n res := 0;\n\n b[1] := 1;\n for i := 1 to m do begin\n a[1]:= i;\n res := res + get(2);\n end;\n\n for i := 1 to n - m do begin\n res := (res * (n - m)) mod 1000000007;\n end; \n\n writeln(res mod 1000000007);\n\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O-}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nn,k,ans,add,id : int64;\nst,used : array [1..10] of longint;\nok : array [1..10] of boolean;\n\nfunction pow (x,p : int64) : int64;\nvar\nres : int64;\nbegin\n res:=1;\n while p<>0 do\n begin\n if odd (p) then res:=(res*x) mod md;\n x:=(x*x) mod md;\n p:=p shr 1;\n end;\n pow:=res mod md;\nend;\n\nfunction check() : boolean;\nvar\ni,v : longint;\nbegin\n fillchar(ok,sizeof(ok),false);\n for i:=1 to k do\n begin\n inc(id);\n v:=i;\n while v <> 1 do\n begin\n if ok[v] then\n begin\n v:=1;\n break;\n end;\n used[v]:=id;\n v:=st[v];\n if used[v] = id then break;\n end;\n if v <> 1 then\n begin\n check:=false;\n exit;\n end;\n ok[i]:=true;\n end;\n check:=true;\nend;\n\nprocedure rec(len : longint);\nvar\ni : longint;\nbegin\n if len = k + 1 then\n begin\n if check() then inc(add);\n exit;\n end;\n for i:=1 to k do\n //if i <> len then\n begin\n st[len]:=i;\n rec(len + 1);\n end;\nend;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n randomize;\n readln(n,k);\n ans:=pow(n - k,n - k);\n add:=0;\n id:=0;\n rec(1);\n ans:=(ans * add) mod md;\n writeln(ans);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='b.in';\n file2='b.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009,0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,cur:longint;\n i1,i2,i3,i4,i5,i6,i7,i8:longint;\n r1,r2,res:int64;\n s,s0,s1,s2:string;\n sss:ansistring;\n x,y,z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n readln(q,c);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n writeln(res);\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n m:=1000000007;\n r1:=1;\n for i:=1 to c-1 do r1:=r1*c;\n r2:=1;\n for i:=1 to q-c do r2:=(r2*(q-c))mod m;\n res:=(r1*r2) mod m;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);{}\nfor test:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\nclose(input);\nclose(output); {}\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $01100000}\n\nprogram Shablon;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n base = 1000000007;\n\nvar\n qwe, n, i: integer;\n a : array[1..8] of integer;\n was : array[1..8] of boolean;\n ans, res : int64;\n\nfunction prov:boolean;\nvar\n i, t : integer;\nbegin\n for i := 1 to qwe do begin\n fillchar(was, sizeof(was), false);\n was[i] := true;\n t := a[i];\n while t <> 1 do begin\n if was[t] then begin\n result := false;\n exit;\n end else begin\n was[t] := true;\n t := a[t];\n end;\n end;\n end;\n result := true;\nend;\n\nprocedure rec(tec : integer);\nvar\n i : integer;\nbegin\n if tec > qwe then begin\n if prov then\n inc(ans);\n exit;\n end;\n for i := 1 to qwe do begin\n a[tec] := i;\n rec(tec + 1);\n end;\nend;\n\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(n, qwe);\n ans := 0;\n if qwe = 8 then\n ans := 2097152 else\n rec(1);\n res := 1;\n //writeln(ans);\n for i := 1 to n - qwe do begin\n res := res * (n - qwe) mod base;\n end;\n ans := ans * res mod base;\n write(ans);\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nconst md=1000000007;\nvar a,b,c,i,k,n,z:integer;ans,p:int64;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n readln(n,k);\n ans:=1;\n for i:=1 to k-1 do\n ans:=(ans*k) mod md;\n p:=1;\n for i:=1 to n-k do\n p:=(p*(n-k)) mod md;\n writeln((ans*p) mod md);\nend.\n "}, {"source_code": "program progaD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n p = 1000000007;\n\nvar\n i: integer;\n ans, ans1, n, k: int64;\n good: array[1..8] of boolean;\n\nprocedure f(s: string);\nvar\n i, j: integer;\n b: boolean;\nbegin\n if length(s) = k then begin\n for i := 1 to k do\n if s[i] = '1' then\n good[i] := true\n else\n good[i] := false;\n for i := 1 to k do\n for j := 1 to k do\n if good[strtoint(s[j])] then\n good[j] := true;\n b := true;\n for i := 1 to k do\n if not good[i] then\n b := false;\n if b then\n inc(ans1);\n ans1 := ans1 mod p;\n end\n else\n for i := 1 to k do\n if i = 1 then\n f(s + inttostr(i))\n else if (i <> length(s) + 1) and (i <> 1) then\n f(s + inttostr(i));\nend;\n \nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, k);\n ans := 1;\n ans1 := 0;\n for i := k + 1 to n do\n ans := (ans * (n - k)) mod p;\n if k = 8 then\n ans1 := 2097152\n else if k = 7 then\n ans1 := 117649\n else if k = 6 then\n ans1 := 7776\n else if k = 5 then\n ans1 := 625\n else\n f('');\n ans := (ans * ans1) mod p;\n writeln(ans);\nend. \n"}, {"source_code": "const\n co=trunc(1e+9)+7;\nvar\n i,j,n,k,x,t:longint;\n ans,p:int64;\n a:array[1..8]of longint;\n f:array[1..8]of boolean;\n\nfunction found(q:longint):boolean;\nvar\n w:longint;\nbegin\n w:=0;\n while true do\n begin\n inc(w);\n if w>k then exit(false);\n if q=1 then exit(true)else q:=a[q];\n end;\n exit(false);\nend;\n\nfunction check:boolean;\nbegin\n for j:=1 to k do if not found(j) then exit(false);\n exit(true);\nend;\n\nprocedure rec(i,x:longint);\nvar\n j:longint;\nbegin\n a[x]:=i;\n if x=k then\n begin\n if check then ans:=(ans+p)mod co;\n exit;\n end;\n for j:=1 to k do rec(j,x+1);\nend;\n\nbegin\n readln(n,k);\n p:=n-k;\n for i:=2 to n-k do p:=(p*(n-k))mod co;\n if p=0 then p:=1;\n for i:=1 to k do rec(i,1);\n writeln(ans);\nend.\n"}, {"source_code": "program ProjectCF;\n\n{$APPTYPE CONSOLE}\n{$R+,O-}\n\nuses\n SysUtils,\n Math;\n\nconst\n base = 1000000007;\n\nvar\n n, k, res, t: int64;\n i: integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n readln(n, k);\n res := 1;\n t := int64(n - k);\n for i := 1 to n - k do\n res:=(res*t) mod base;\n for i := 1 to k - 1 do\n res := (res * k) mod base;\n writeln(res);\n\n\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=1000001; besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar chis,znam,dl,len,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish,kol,m:longint;\nn,yy1,xx1,xx2,q,xx,yy,t1,t2,p,t,aa,modul,pp,tt,ot1,ot2,s,kold,ot,kkr:int64;\nostminus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\na,f,h,kop:array[0..2000000] of int64;\npred,c,x,y,b: array[-10..2000000] of int64;\nbb,marked:array[-10..250000] of boolean;\nss:array[0..2000000] of char;\nssgood:string;\nch11,ch12,ch1,ch:char;\ndd: array[-10..5001] of boolean;\nll,rr,sl,sr,stoim,str :array[-10 ..200000] of int64;\nsss:array[-1000..110000] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n procedure dfs(i0:longint); var i,j,k:longint;\nbegin\n marked[i0]:=true;\n for i:=sl[i0-1]+1 to sl[i0] do\n begin\n k:=str[i]; if not marked[k] then\n begin stoim[k]:=min(stoim[k],stoim[i0]+1);\n x[k]:=stoim[k]; pred[k]:=i0;\n dfs(k); end;\n end;\n\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n } modul:=1000000007 ;\n read(n,k);\n p:=1;\n for i:=1 to k-1 do begin t:=k; p:=(p*t) mod modul; end;\n\n for i:=1 to n-k do begin t:=n-k; p:=(p*t) mod modul; end;\n\n\n writeln(p);\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils;\n\nvar\n a: array[1..1000000] of Integer;\n i, n, k, x, y, max, m , j, d: integer;\n res, cnt: Int64;\n ch: Char;\n s: string;\n\nbegin\n readln(n, k);\n\n res := 1;\n cnt := 1;\n\n for i := 1 to k - 1 do\n res := (res * k) mod 1000000007;\n\n for i := 1 to (n - k) do\n cnt := (cnt*(n - k)) mod 1000000007;\n\n write((res*cnt) mod 1000000007);\n\nend."}, {"source_code": "const c=1000000007;\nvar q,ans: qword;\n n,k,i,j: longint;\n begin\n readln(n,k);\n ans:=1;\n q:=k;\n for i:=1 to k-1 do ans:=(ans*q) mod c;\n if k=1 then ans:=1;\n q:=n-k;\n for i:=k+1 to n do ans:=(ans*q) mod c;\n writeln(ans);\n end."}, {"source_code": "Var n,i:longint;\nk,e,rez:int64;\nm:array [1..8] of longint;\nUsed:array [1..8] of boolean;\nprocedure dfs(v:longint);\nbegin\n if (used[v])\n then exit;\n used[v]:=true;\n if v=1\n then exit;\n dfs(m[v]);\nend;\nprocedure rec(v:longint);\nVar i:longint;\nbegin\n if v>k\n then begin\n for i:=2 to k do\n begin\n fillchar(used,SizeOf(used),false);\n dfs(i);\n if not used[1]\n then Exit;\n end;\n inc(rez);\n exit;\n end;\n for i:=1 to k do\n begin\n if (v>1)and(v=i)\n then Continue;\n m[v]:=i;\n rec(v+1);\n end;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n,k);\n rez:=0;\n if n=1\n then begin writeln(1); halt(0); end;\n rec(2);\n e:=n-k;\n for i:=k+1 to n do\n rez:=(rez*e) mod 1000000007;\n rez:=(rez*k) mod 1000000007;\n writeln(rez);\nEnd."}, {"source_code": "var\nn,k,i:integer;\nret:int64;\nbegin\nreadln(n,k);\nret:=1;\nfor i:=1 to n-k do ret:=ret*(n-k) mod 1000000007;\nfor i:=1 to k-1 do ret:=ret*k mod 1000000007;\nwriteln(ret);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n maxn=1000000007;\nvar\n n,i,j:integer;\n res,k:int64;\n\nbegin\n readln(n,k);\n res:=1;\n for i:=1 to n-k do\n begin\n res:=(res*(n-k)) mod maxn;\n end;\n for i:=1 to k-1 do\n begin\n res:=(res*k) mod maxn;\n end;\n writeln(res);\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\n{$maxstacksize 100000000}\nUses SysUtils,math;\nVar\n p,f,t:Array[0..5000] of Int64;\n n,k,md,w,r,it:Int64;\n i:Integer;\nFunction Solve(i:Integer):Integer;\nBegin\n If t[i]=it Then Begin\n Solve:=f[i];\n Exit;\n End;\n If i=1 Then Begin\n Solve:=1;\n Exit;\n End;\n f[i]:=-it;\n t[i]:=it;\n If f[p[i]]=-it Then Begin\n f[i]:=0;\n Solve:=0;\n Exit;\n End;\n f[i]:=Solve(p[i]);\n Solve:=f[i];\nEnd;\nProcedure Search(i:Integer);\nVar j,f1:Integer;\nBegin\n If i>k Then Begin\n it:=it+1;\n f[1]:=1;\n For j:=1 To k Do Solve(j);\n f1:=1;\n For j:=1 To k Do\n If f[j]=0 Then f1:=0;\n If f1=1 Then r:=r+1;\n Exit;\n End;\n For j:=1 To k Do\n If (i<>j) or (j=1) Then Begin\n p[i]:=j;\n Search(i+1);\n End;\nEnd;\nBegin\n Read(n,k);\n md:=1000000007;\n r:=0;\n it:=10;\n Search(1);\n If k=1 Then r:=1;\n w:=1;\n For i:=1 To n-k Do w:=w*(n-k) mod md;\n Write(r*w mod md);\nEnd."}, {"source_code": "program p2;\n\nUses Sysutils, Math;\n\nVar n, k, ans: int64; i: integer;\n\nbegin\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n readln(n, k);\n ans := 1;\n for i := 1 to k - 1 do\n ans := (ans * k) mod 1000000007; \n for i := k + 1 to n do\n ans := (ans * (n - k)) mod 1000000007;\n writeln(ans);\nend."}, {"source_code": "const modulo = 1000000007;\nconst mas:array[1..8] of int64 = (1, 2, 9, 64, 625, 7776, 117649, 2097152);\n\nvar n,m,i,j,k,answer:int64;\n cur:array[0..10] of longint;\n\nfunction step(a,b:int64):int64;\nvar ans:int64;\nbegin\n if b = 0 then\n begin\n step:=1;\n exit;\n end;\nans:=step(a,b div 2);\nans:=(ans*ans) mod modulo;\nif b mod 2 = 1 then ans:=ans*a;\nans:=ans mod modulo;\nstep:=ans;\nend;\n\n\nfunction f(n:int64):int64;\nbegin\n f:=mas[n];\nend;\n\nbegin\n readln(n,m);\n\n answer:=0;\n answer:=f(m);\n answer:=int64(answer)*int64(step(n-m,n-m));\n answer:=answer mod modulo;\n writeln(answer);\nend.\n"}, {"source_code": "const maxn=10000;\n base=1000000007;\nvar n,k,ans:int64;\n\nfunction binpow(a,b:int64):int64;\nvar res:int64;\nbegin\nif b=0 then exit(1);\nres:=binpow(a,b shr 1);\nres:=(res*res) mod base;\nif b and 1=1 then res:=(res*a) mod base;\nexit(res);\nend;\n\nBEGIN\nreadln(n,k);\nans:=binpow(k,k-1);\nans:=(ans*binpow(n-k,n-k)) mod base;\nwrite(ans);\nEND."}, {"source_code": "var n,m,i,t:longint;x,y:int64;\nf:array[0..1000]of boolean;\na:array[0..10000]of longint;\nfunction pd:boolean;\nvar i:longint;\nbegin\nfor i:=1 to m do\n begin\n t:=a[i];\n fillchar(f,sizeof(f),true);\n while t<>1 do\n begin\n f[t]:=false;\n t:=a[t];\n if f[t]=false then break;\n end;\n if t<>1 then exit(false);\n end;\nexit(true);\nend;\nprocedure s(t:longint);\nvar i:longint;\nbegin\nif t=m+1 then\n begin\n if pd then y:=(y+1)mod 1000000007;\n exit;\n end;\nfor i:=1 to m do\n begin\n a[t]:=i;\n s(t+1);\n a[t]:=0;\n end;\nend;\nbegin\n//assign(input,'fz.in');reset(input);\n//assign(output,'fz.out');rewrite(output);\nreadln(n,m);x:=1;y:=1;\nif m=8 then y:=2097152;\nfor i:=1 to n-m do x:=x*(n-m)mod 1000000007;\nif y=1 then\n begin\n y:=0;\n s(1);\n end;\nwriteln(x*y mod 1000000007);\nclose(input);close(output);\nend."}, {"source_code": "const modulo=trunc(1e9+7);\nvar n,k,i:longint;\n ans:int64;\nbegin\n read(n,k);\n if (n=1) then begin\n writeln(1);\n exit;\n end;\n ans:=1;\n for i:=k+1 to n do\n ans:=ans*(n-k) mod modulo;\n for i:=1 to k-1 do\n ans:=ans*(k) mod modulo;\n writeln(ans);\nend. "}], "negative_code": [{"source_code": "program progaD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n p = 1000000007;\n\nvar\n n, k, i: integer;\n ans, ans1: int64;\n good: array[1..8] of boolean;\n\nprocedure f(s: string);\nvar\n i, j: integer;\n b: boolean;\nbegin\n if length(s) = k then begin\n for i := 1 to k do\n if s[i] = '1' then\n good[i] := true\n else\n good[i] := false;\n for i := 1 to k do\n for j := 1 to k do\n if good[strtoint(s[j])] then\n good[j] := true;\n b := true;\n for i := 1 to k do\n if not good[i] then\n b := false;\n if b then\n inc(ans1);\n ans1 := ans1 mod p;\n end\n else\n for i := 1 to k do\n if i = 1 then\n f(s + inttostr(i))\n else if (i <> length(s) + 1) and (i <> 1) then\n f(s + inttostr(i));\nend;\n \nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, k);\n ans := 1;\n ans1 := 0;\n for i := k + 1 to n do\n ans := (ans * (n - k )) mod p;\n if k = 8 then\n ans1 := 2097152\n else if k = 7 then\n ans1 := 117649\n else if k = 6 then\n ans1 := 7776\n else if k = 5 then\n ans1 := 625;\n f('');\n ans := (ans * ans1) mod p;\n writeln(ans);\nend. \n"}, {"source_code": "program progaD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n p = 1000000007;\n\nvar\n n, k, i: integer;\n ans, ans1: int64;\n good: array[1..8] of boolean;\n\nprocedure f(s: string);\nvar\n i, j: integer;\n b: boolean;\nbegin\n if length(s) = k then begin\n for i := 1 to k do\n if s[i] = '1' then\n good[i] := true\n else\n good[i] := false;\n for i := 1 to k do\n for j := 1 to k do\n if good[strtoint(s[j])] then\n good[j] := true;\n b := true;\n for i := 1 to k do\n if not good[i] then\n b := false;\n if b then\n inc(ans1);\n ans1 := ans1 mod p;\n end\n else\n for i := 1 to k do\n if i = 1 then\n f(s + inttostr(i))\n else if (i <> length(s) + 1) and (i <> 1) then\n f(s + inttostr(i));\nend;\n \nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, k);\n ans := 1;\n ans1 := 0;\n for i := k + 1 to n do\n ans := (ans * (n - k )) mod p;\n if n = 8 then\n ans1 := 2097152\n else if n = 7 then\n ans1 := 117649\n else if n = 6 then\n ans1 := 7776\n else if n = 5 then\n ans1 := 625;\n f('');\n ans := (ans * ans1) mod p;\n writeln(ans);\nend. \n"}, {"source_code": "program progaD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n p = 1000000007;\n\nvar\n n, k, i, x: integer;\n ans, ans1: int64;\n good: array[1..8] of boolean;\n\nprocedure f;\nvar\n i, j, kol: integer;\n s: string;\nbegin\n s := inttostr(x);\n if length(s) = k then begin\n kol := 0;\n for i := 1 to k do\n if s[i] = '1' then begin\n good[i] := true;\n inc(kol);\n end\n else\n good[i] := false;\n for i := 1 to k do begin\n for j := 1 to k do\n if not good[j] and good[strtoint(s[j])] then begin\n good[j] := true;\n inc(kol);\n end;\n if kol = k then\n break;\n end;\n if kol = k then\n inc(ans1);\n ans1 := ans1 mod p;\n end\n else\n for i := 1 to k do\n if x = 0 then begin\n x := x * 10 + i;\n f;\n x := x div 10;\n end\n else if (i <> length(s) + 1) then begin\n x := x * 10 + i;\n f;\n x := x div 10;\n end;\nend;\n \nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, k);\n ans := 1;\n for i := k + 1 to n do\n ans := (ans * (n - k )) mod p;\n x := 0;\n if k = 8 then\n ans1 := 2097152\n else if k = 7 then\n ans1 := 117649\n else begin\n ans1 := 0;\n f();\n end;\n ans := (ans * ans1) mod p;\n writeln(ans);\nend.\n "}, {"source_code": "program progaD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n p = 1000000007;\n\nvar\n i: integer;\n ans, ans1, n, k: int64;\n good: array[1..8] of boolean;\n\nprocedure f(s: string);\nvar\n i, j: integer;\n b: boolean;\nbegin\n if length(s) = k then begin\n for i := 1 to k do\n if s[i] = '1' then\n good[i] := true\n else\n good[i] := false;\n for i := 1 to k do\n for j := 1 to k do\n if good[strtoint(s[j])] then\n good[j] := true;\n b := true;\n for i := 1 to k do\n if not good[i] then\n b := false;\n if b then\n inc(ans1);\n ans1 := ans1 mod p;\n end\n else\n for i := 1 to k do\n if i = 1 then\n f(s + inttostr(i))\n else if (i <> length(s) + 1) and (i <> 1) then\n f(s + inttostr(i));\nend;\n \nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, k);\n ans := 1;\n ans1 := 0;\n for i := k + 1 to n do\n ans := (ans * (n - k)) mod p;\n if k = 8 then\n ans1 := 2097152\n else if k = 7 then\n ans1 := 117649\n else if k = 6 then\n ans1 := 7776\n else if k = 5 then\n ans1 := 625;\n f('');\n ans := (ans * ans1) mod p;\n writeln(ans);\nend. \n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\n{$maxstacksize 100000000}\nUses SysUtils,math;\nVar\n p,f,t:Array[0..5000] of Int64;\n n,k,md,w,r,it:Int64;\n i:Integer;\nFunction Solve(i:Integer):Integer;\nBegin\n If t[i]=it Then Begin\n Solve:=f[i];\n Exit;\n End;\n If i=1 Then Begin\n Solve:=1;\n Exit;\n End;\n f[i]:=-it;\n t[i]:=it;\n If f[p[i]]=-it Then Begin\n f[i]:=0;\n Solve:=0;\n Exit;\n End;\n f[i]:=Solve(p[i]);\n Solve:=f[i];\nEnd;\nProcedure Search(i:Integer);\nVar j,f1:Integer;\nBegin\n If i>k Then Begin\n it:=it+1;\n f[1]:=1;\n For j:=1 To k Do Solve(j);\n f1:=1;\n For j:=1 To k Do\n If f[j]=0 Then f1:=0;\n If f1=1 Then r:=r+1;\n Exit;\n End;\n For j:=1 To k Do\n If (i<>j) or (j=1) Then Begin\n p[i]:=j;\n Search(i+1);\n End;\nEnd;\nBegin\n Read(n,k);\n If k=1 Then Begin\n Write(0);\n Halt;\n End;\n md:=1000000007;\n r:=0;\n it:=10;\n Search(1);\n w:=1;\n For i:=1 To n-k Do w:=w*(n-k) mod md;\n Write(r*w mod md);\nEnd.\n\n"}, {"source_code": "const\n co=trunc(1e+9)+7;\nvar\n ans,n,k,p,i,j,x,t:longint;\n a:array[1..8]of longint;\n f:array[1..8]of boolean;\n\nfunction found(q:longint):boolean;\nvar\n w:longint;\nbegin\n w:=0;\n while true do\n begin\n inc(w);\n if w>k then exit(false);\n if q=1 then exit(true)else q:=a[q];\n end;\n exit(false);\nend;\n\nfunction check:boolean;\nbegin\n for j:=1 to k do if not found(j) then exit(false);\n exit(true);\nend;\n\nprocedure rec(i,x:longint);\nvar\n j:longint;\nbegin\n a[x]:=i;\n if x=k then\n begin\n if check then ans:=(ans+p)mod co;\n exit;\n end;\n for j:=1 to k do rec(j,x+1);\nend;\n\nbegin\n readln(n,k);\n p:=n-k;\n for i:=2 to n-k do p:=(p*(n-k))mod co;\n for i:=1 to k do rec(i,1);\n writeln(ans);\nend.\n"}, {"source_code": "const\n co=trunc(1e+9)+7;\nvar\n i,j,n,k,x,t:longint;\n ans,p:int64;\n a:array[1..8]of longint;\n f:array[1..8]of boolean;\n\nfunction found(q:longint):boolean;\nvar\n w:longint;\nbegin\n w:=0;\n while true do\n begin\n inc(w);\n if w>k then exit(false);\n if q=1 then exit(true)else q:=a[q];\n end;\n exit(false);\nend;\n\nfunction check:boolean;\nbegin\n for j:=1 to k do if not found(j) then exit(false);\n exit(true);\nend;\n\nprocedure rec(i,x:longint);\nvar\n j:longint;\nbegin\n a[x]:=i;\n if x=k then\n begin\n if check then ans:=(ans+p)mod co;\n exit;\n end;\n for j:=1 to k do rec(j,x+1);\nend;\n\nbegin\n readln(n,k);\n p:=n-k;\n for i:=2 to n-k do p:=(p*(n-k))mod co;\n for i:=1 to k do rec(i,1);\n writeln(ans);\nend.\n"}, {"source_code": "\nvar n,m,i:longint; ans:int64; k:int64;\nf:boolean;\n\nprocedure sc(t:longint);\nvar i:longint;\nbegin\nif t>m then\n begin\n if f=true then\n ans:=(ans+k) mod 1000000007;\n f:=false;\n exit;\n\n end;\nfor i:=1 to m do\n\n begin\n if (t<>1) and (i=1) then f:=true;\n sc(t+1);\n end;\nend;\n\n\nbegin\n//assign(input,'fz.in');reset(input);\n//assign(output,'fz.out');rewrite(output);\nreadln(n,m);\nk:=1;\nfor i:=1 to (n-m) do\n k:=(k*(n-m)) mod 1000000007;\nsc(1);\nwrite(ans);\nclose(input);\nclose(output);\nend.\n"}, {"source_code": "var\n t,a:array[0..1005000]of longint;\n used:array[0..1000500]of boolean;\n s,sum:int64;\n n,i,j:longint;\n\nbegin\n read(n);\n s:=int64(n)*(N+1);\n writeln(s);\n for i:=0 to 20 do t[i]:=(1 shl i)-1;\n for i:=n downto 0 do begin\n j:=20;\n while (t[j]xor i>n)or(t[j]>s)or(used[t[j] xor i])do dec(j);\n used[t[j] xor i]:=true;\n s:=s-t[j];\n a[i]:=t[j] xor i;\n end;\n for i:=0 to n do write(a[i],' ');\n writeln;\nend."}, {"source_code": "Const\n kq:array [1..8] of longint=(1,2,9,64,625,7776,117649,2097152);\n oo=1000000007;\nType\n mat=array [0..1000,0..1000] of int64;\nVar a,p:mat;\n n,k:longint;\n res:int64;\n s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Read(fi,n,k);\n\n end;\n\n{Function Check:boolean;\n Var i,tg,j,ok:longint;\n Begin\n For i:=1 to k do\n Begin\n tg:=0;\n j:=i;\n ok:=0;\n Repeat\n j:=p[j];\n If j=1 then\n Begin\n ok:=1;\n break;\n end;\n inc(tg);\n Until tg=10;\n If ok=0 then exit(false);\n end;\n exit(true);\n end;\n\nProcedure Try(i:longint);\n Var j:longint;\n Begin\n If i=k+1 then\n Begin\n If Check then inc(res);\n end\n else\n For j:=1 to k do\n Begin\n p[i]:=j;\n Try(i+1);\n end;\n end; }\n\nProcedure Lam;\n Var i,j:longint;\n Begin\n For i:=1 to 1000 do a[i,0]:=1;\n For i:=1 to 1000 do\n For j:=1 to 1000 do a[i,j]:=(a[i,j-1]*i) mod oo;\n res:=(kq[k]*a[n-k,n-k]) mod oo;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end."}, {"source_code": "Const\n kq:array [1..8] of longint=(1,2,9,64,625,7776,117649,2097152);\n oo=1000000007;\nType\n mat=array [0..1000,0..1000] of int64;\nVar a,p:mat;\n n,k:longint;\n res:int64;\n s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Read(fi,n,k);\n\n end;\n\n{Function Check:boolean;\n Var i,tg,j,ok:longint;\n Begin\n For i:=1 to k do\n Begin\n tg:=0;\n j:=i;\n ok:=0;\n Repeat\n j:=p[j];\n If j=1 then\n Begin\n ok:=1;\n break;\n end;\n inc(tg);\n Until tg=10;\n If ok=0 then exit(false);\n end;\n exit(true);\n end;\n\nProcedure Try(i:longint);\n Var j:longint;\n Begin\n If i=k+1 then\n Begin\n If Check then inc(res);\n end\n else\n For j:=1 to k do\n Begin\n p[i]:=j;\n Try(i+1);\n end;\n end; }\n\nProcedure Lam;\n Var i,j:longint;\n Begin\n For i:=1 to 1000 do a[i,0]:=1;\n For i:=1 to 1000 do\n For j:=1 to 1000 do a[i,j]:=(a[i,j-1]*i) mod oo;\n res:=(kq[k]*a[n-k,n-k]) mod oo;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "const q = 1000000007;\n\nvar mark: array [1..100000] of Boolean;\n p: array [1..1000000] of Longint;\n i, n, k: Longint;\n sum, rez: Int64;\n\nfunction prov: Boolean;\nvar i, j: Longint;\nBegin\n\n {if p[1] = 1 then begin\n prov := false;\n exit;\n end;}\n\n for i := 1 to k do begin\n for j := 1 to k do\n mark[j] := false;\n j := i;\n\n if i = 1 then begin\n j := p[j];\n end;\n\n while (mark[j] = false) and (j <> 1) do begin\n mark[j] := true;\n j := p[j];\n end;\n if j <> 1 then begin\n prov := false;\n exit;\n end;\n end;\n prov := true;\nend;\n\nprocedure src(x: Longint);\nvar i: Longint;\nBegin\n if x = k + 1 then begin\n if prov then\n inc(rez);\n rez := rez mod q;\n exit;\n end;\n for i := 1 to k do begin\n p[x] := i;\n src(x + 1);\n end;\nEnd;\n\nBegin\n read(n, k);\n sum := 1;\n for i := k + 1 to n do\n sum := (sum * (n - (k + 1) + 1)) mod q;\n src(1);\n sum := sum * rez;\n write(sum);\nEnd.\n"}, {"source_code": "const MAXK = 8;\n modulo = 1000000007;\n\nvar p , d : array [1..MAXK] of int64;\n good : array [1..MAXK] of boolean;\n ans : int64;\n\nprocedure supercheck( curr , time , k : longint );\nbegin\n\n if time > k + 1 then exit;\n if ( good[ curr ] ) or ( curr = 1 ) then begin\n good[ curr ]:=true;\n exit;\n end; \n \n supercheck( p[curr] , time+1 , k );\n good[curr]:=good[ p[curr] ];\n \nend; \n\nfunction check( k : longint ) : boolean; \nvar i : longint ;\nbegin\n \n for i:=1 to k do good[i]:=false;\n \n for i:=2 to k do begin\n \n supercheck( i , 0 , k );\n if not good[i] then exit( false );\n \n end;\n \n exit( true );\n \nend; \n\nprocedure solve( k , curr : longint );\nvar i : longint ;\nbegin\n\n if curr <= k then begin\n \n for i:=1 to k do begin\n p[curr]:=i;\n solve( k , curr + 1 );\n end;\n \n end\n else begin\n \n if check( k ) then inc( ans );\n //writeln( p[1] ,' ',p[2],' ',p[3],' ',ans);\n end;\n \nend; \n\nfunction power( a , b : longint ) : int64;\nvar res : int64;\nbegin\n\n if b = 0 then exit( 1 );\n \n if b mod 2 = 1 then res:=a else res:=1;\n \n res:=res * sqr( power( a , b div 2 ) ) ;\n res:=res mod modulo;\n \n exit( res );\n \nend; \n\nvar k , n : longint ;\n x : int64;\nbegin\n \n d[1]:=1; d[2]:=2; d[3]:=9; d[4]:=64; d[5]:=625; d[6]:=7776; d[7]:=117649; \n d[8]:=2097152;\n \n readln( n , k );\n \n x:=Power( n - k , n - k );\n \n writeln( ( x * d[k] ) mod modulo );\n \n \nend. \n \n"}, {"source_code": "const MAXK = 8;\n modulo = 1000000007;\n\nvar p , d : array [1..MAXK] of int64;\n good : array [1..MAXK] of boolean;\n ans : int64;\n\nprocedure supercheck( curr , time , k : longint );\nbegin\n\n if time > k + 1 then exit;\n if ( good[ curr ] ) or ( curr = 1 ) then begin\n good[ curr ]:=true;\n exit;\n end; \n \n supercheck( p[curr] , time+1 , k );\n good[curr]:=good[ p[curr] ];\n \nend; \n\nfunction check( k : longint ) : boolean; \nvar i : longint ;\nbegin\n \n for i:=1 to k do good[i]:=false;\n \n for i:=2 to k do begin\n \n supercheck( i , 0 , k );\n if not good[i] then exit( false );\n \n end;\n \n exit( true );\n \nend; \n\nprocedure solve( k , curr : longint );\nvar i : longint ;\nbegin\n\n if curr <= k then begin\n \n for i:=1 to k do begin\n p[curr]:=i;\n solve( k , curr + 1 );\n end;\n \n end\n else begin\n \n if check( k ) then inc( ans );\n //writeln( p[1] ,' ',p[2],' ',p[3],' ',ans);\n end;\n \nend; \n\nfunction power( a , b : longint ) : int64;\nvar res : int64;\nbegin\n\n if b = 0 then exit( 1 );\n \n if b mod 2 = 1 then res:=a else res:=1;\n \n res:=res * sqr( power( a , b div 2 ) ) ;\n res:=res mod modulo;\n \n exit( res );\n \nend; \n\nvar k , n : longint ;\n x : int64;\nbegin\n \n d[1]:=1; d[2]:=2; d[3]:=9; d[4]:=64; d[5]:=625; d[6]:=7776; d[7]:=117649; \n d[8]:=2097152;\n \n readln( n , k );\n \n x:=Power( n - k , n - k );\n \n writeln( ( x * d[k] ) mod modulo );\n \n \nend. \n \n"}, {"source_code": "//(n-m)^(n-m)*m^(m-1)\n\nconst modul=1000000007;\n\nvar n,m,ans: int64;\n\nfunction pow(x,y: int64): int64;\nbegin\n if y=0 then pow:=1\n else\n begin\n if y mod 2=1 then pow:=(pow(x,y-1)*x) mod MODUL\n else pow:=sqr(pow(x,y shr 1)) mod MODUL;\n end;\nend;\n\nbegin\n readln(n,m);\n\n ans:=(pow(n-m,n-m)*pow(m,m-1)) mod MODUL;\n\n if n=m then ans:=0;\n\n writeln(ans);\nend."}, {"source_code": "const c=1000000007;\nvar q,ans: qword;\n n,k,i,j: longint;\n begin\n readln(n,k);\n ans:=1;\n q:=k;\n for i:=1 to k div 2 do ans:=(ans*q) mod c;\n q:=q div 2;\n for i:=k div 2+1 to k do ans:=(ans*q) mod c;\n if k=1 then ans:=1;\n q:=n-k;\n for i:=k+1 to n do ans:=(ans*q) mod c;\n writeln(ans);\n end."}, {"source_code": "const c=1000000007;\nvar q,ans: qword;\n n,k,i,j: longint;\n begin\n readln(n,k);\n ans:=1;\n q:=k;\n for i:=1 to k div 2 do ans:=(ans*q) mod c;\n q:=q div 2;\n for i:=k div 2+1 to k do ans:=(ans*q) mod c;\n q:=n-k;\n for i:=k+1 to n do ans:=(ans*q) mod c;\n writeln(ans);\n end."}, {"source_code": "const MO=1000000007;\nVar\nn,k,i,j:longint;\nans:int64;\n\nBegin\nread(n,k);\nans:=1;\nfor i:=1 to k-1 do\nans:=(ans*k) mod MO;\n\n for i:=1 to (n-k) do\n ans:=(ans*(n-k)) mod MO;\nif k=1 then writeln(0) else writeln(ans);\nEnd."}, {"source_code": "const inf=1000000007;\nvar n,m,s:int64;\nfunction binPOW(n,m:int64):int64;\nbegin\n if m=0 then binPOW:=1\n else begin\n if m mod 2=1 then binPOW:=(binPOW(n,m-1)*n) mod inf\n else binPOW:=sqr(binPOW(n,m shr 1)) mod inf;\n end;\nend;\nbegin\n readln(n,m);\n if (n=m) or (n=0) or (m=0) then begin\n writeln(0);\n halt;\n end;\n s:=(binPOW(n-m,n-m)*binPOW(m,m-1)) mod inf;\n writeln(s);\nend.\n"}, {"source_code": "const inf=1000000007;\nvar n,m,s:int64;\nfunction binPOW(n,m:int64):int64;\nbegin\n if m=0 then binPOW:=1\n else begin\n if m mod 2=1 then binPOW:=(binPOW(n,m-1)*n) mod inf\n else binPOW:=sqr(binPOW(n,m shr 1)) mod inf;\n end;\nend;\nbegin\n readln(n,m);\n if n=m then begin\n writeln(0);\n halt;\n end;\n s:=(binPOW(n-m,n-m)*binPOW(m,m-1)) mod inf;\n writeln(s);\nend."}, {"source_code": "const md=1000000007;\nvar n,k,br,m,i,r,br1:longint;\n nb,nb1,niz:array[0..100] of longint;\nprocedure rek(x:longint);\nvar i,j:longint;\nbegin\n if x>k then\n begin\n inc(br);\n for j:=1 to k do\n begin\n i:=j;\n inc(br1);\n while (i<>1) and (nb[i]<>br) do\n begin\n nb1[i]:=br1;\n i:=niz[i];\n if nb1[i]=br1 then exit;\n end;\n nb[j]:=br;\n end;\n inc(r);\n exit;\n end;\n for i:=1 to k do\n begin\n niz[x]:=i;\n rek(x+1);\n end;\nend;\nbegin\n readln(n,k);\n rek(1);\n writeln(r);\n m:=n-k;\n for i:=1 to m do\n r:=(r*m) mod md;\n writeln(r);\nend.\n"}, {"source_code": "const md=1000000007;\nvar n,k,br,m,i,r,br1:longint;\n nb,nb1,niz:array[0..100] of longint;\nprocedure rek(x:longint);\nvar i,j:longint;\nbegin\n if x>k then\n begin\n inc(br);\n for j:=1 to k do\n begin\n i:=j;\n inc(br1);\n while (i<>1) and (nb[i]<>br) do\n begin\n nb1[i]:=br1;\n i:=niz[i];\n if nb1[i]=br1 then exit;\n end;\n nb[j]:=br;\n end;\n inc(r);\n exit;\n end;\n for i:=1 to k do\n begin\n niz[x]:=i;\n rek(x+1);\n end;\nend;\nbegin\n readln(n,k);\n rek(1);\n m:=n-k;\n if m>0 then\n for i:=1 to m do\n r:=(r*m) mod md;\n writeln(r);\nend.\n"}, {"source_code": "const md=1000000007;\nvar n,k,br,m,i,r,br1:longint;\n nb,nb1,niz:array[0..100] of longint;\nprocedure rek(x:longint);\nvar i,j:longint;\nbegin\n if x>k then\n begin\n inc(br);\n for j:=1 to k do\n begin\n i:=j;\n inc(br1);\n while (i<>1) and (nb[i]<>br) do\n begin\n nb1[i]:=br1;\n i:=niz[i];\n if nb1[i]=br1 then exit;\n end;\n nb[j]:=br;\n end;\n inc(r);\n exit;\n end;\n for i:=1 to k do\n begin\n niz[x]:=i;\n rek(x+1);\n end;\nend;\nbegin\n readln(n,k);\n rek(1);\n m:=n-k;\n for i:=1 to m do\n r:=(r*m) mod md;\n writeln(r);\nend.\n"}, {"source_code": "const md=1000000007;\nvar n,k,br,m,i,br1:longint;\nr:longint;\n nb,nb1,niz:array[0..100] of longint;\nprocedure rek(x:longint);\nvar i,j:longint;\nbegin\n if x>k then\n begin\n inc(br);\n for j:=1 to k do\n begin\n i:=j;\n inc(br1);\n while (i<>1) and (nb[i]<>br) do\n begin\n nb1[i]:=br1;\n i:=niz[i];\n if nb1[i]=br1 then exit;\n end;\n nb[j]:=br;\n end;\n inc(r);\n exit;\n end;\n for i:=1 to k do\n begin\n niz[x]:=i;\n rek(x+1);\n end;\nend;\nbegin\n readln(n,k);\n rek(1);\n m:=n-k;\n if m>0 then\n for i:=1 to m do\n r:=(r*m) mod md;\n writeln(r);\nend.\n"}, {"source_code": "const\nmaxn=1000000007;\nvar\ni : longint;\nn,k,t,y : int64;\nbegin\n readln(n,k);\n t:=1;\n for i:=1 to n-k do\n t:=t*(n-k) mod maxn;\n y:=1;\n for i:=1 to k-1 do\n y:=y*k mod maxn;\n writeln(t*y);\nend.\n"}, {"source_code": "program p2;\n\nUses Sysutils, Math;\n\nVar n, k, ans: int64; i: integer;\n\nbegin\n readln(n, k);\n ans := 1;\n for i := 1 to k - 1 do\n ans := (ans * k) mod 1000000007; \n for i := n - k + 1 to n do\n ans := (ans * (n - k)) mod 1000000007;\n writeln(ans);\nend."}], "src_uid": "cc838bc14408f14f984a349fea9e9694"} {"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u,dep:longint);\nvar x,a,b,c:longint;\nbegin\n if dep>2 then exit;\n //if visit[u]=false tehn\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n flush(output);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n {if visit[a]=false then begin\n dfs4(a,dep+1);\n end else if visit[b]=false then begin\n dfs4(b,dep+1);\n end else begin\n dfs4(c,dep+1);\n end; }\n if visit[a]=false then begin\n dfs4(a,dep+1);\n if solved then exit;\n end;\n if visit[b]=false then begin\n dfs4(b,dep+1);\n if solved then exit;\n end;\n if visit[c]=false then begin\n dfs4(c,dep+1);\n if solved then exit;\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x,a,b,c:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n flush(output);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp,1);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp,1);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n", "positive_code": [{"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u,dep:longint);\nvar x,a,b,c:longint;\nbegin\n if dep>2 then exit;\n //if visit[u]=false tehn\n visit[u]:=true;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n flush(output);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n if visit[a]=false then begin\n dfs4(a,dep+1);\n if solved then exit;\n end;\n if visit[b]=false then begin\n dfs4(b,dep+1);\n if solved then exit;\n end;\n if visit[c]=false then begin\n dfs4(c,dep+1);\n if solved then exit;\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x,a,b,c:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n flush(output);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp,1);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp,1);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}], "negative_code": [{"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u,dep:longint);\nvar x,a,b,c:longint;\nbegin\n if dep>2 then exit;\n //if visit[u]=false tehn\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n flush(output);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs4(a,dep+1);\n end else if visit[b]=false then begin\n dfs4(b,dep+1);\n end else begin\n dfs4(c,dep+1);\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x,a,b,c:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n flush(output);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp,1);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp,1);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}, {"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u,dep:longint);\nvar x:longint;\nbegin\n if dep>2 then exit;\n //if visit[u]=false tehn\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n flush(output);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs4(a,dep+1);\n end else if visit[b]=false then begin\n dfs4(b,dep+1);\n end else begin\n dfs4(c,dep+1);\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp,1);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp,1);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}, {"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u,dep:longint);\nvar x,a,b,c:longint;\nbegin\n if dep>2 then exit;\n //if visit[u]=false tehn\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n flush(output);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs4(a,dep+1);\n end else if visit[b]=false then begin\n dfs4(b,dep+1);\n end else begin\n dfs4(c,dep+1);\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n flush(output);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp,1);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp,1);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}, {"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n if tot>2 then exit;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs4(a);\n end else if visit[b]=false then begin\n dfs4(b);\n end else begin\n dfs4(c);\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if (dep=2) and (h=7) then begin\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n writeln('? ',temp);\n visit[temp]:=true;\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n readln(a,b,c);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}, {"source_code": "type rec=record\n a,b,c:longint;\nend;\nvar i,j,m,n,test,x,tot,a,b,c,h,ii,aa,tot1,tot2,bb,cc:longint;\n visit:array[0..200]of boolean;\n road,road1,road2:array[0..20]of longint;\n solved:boolean;\n ans:array[0..200]of rec;\nprocedure dfs3(u:longint);\nvar x,a,b,c,temp:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end;\n if x=1 then begin\n readln(a);\n exit;\n end;\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs3(temp);\nend;\nprocedure dfs4(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n if tot>2 then exit;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs4(a);\n end else if visit[b]=false then begin\n dfs4(b);\n end else begin\n dfs4(c);\n end;\n end;\nend;\nprocedure dfs2(u:longint);\nvar x:longint;\nbegin\n visit[u]:=true;\n inc(tot);\n road[tot]:=u;\n writeln('? ',u);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',u);\n solved:=true;\n exit;\n end else if x=1 then begin\n readln(a);\n exit;\n end else begin\n readln(a,b,c);\n ans[u].a:=a;\n ans[u].b:=b;\n ans[u].c:=c;\n if visit[a]=false then begin\n dfs2(a);\n end else if visit[b]=false then begin\n dfs2(b);\n end else begin\n dfs2(c);\n end;\n end;\nend;\nprocedure dfs(now,dep:longint);\nvar x,temp,aa,a,b,c,bb,cc,temp2:longint;\nbegin\n visit[now]:=true;\n writeln('? ',now);\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',now);\n solved:=true;\n exit;\n end;\n readln(a,b,c);\n if (dep=3) and (h=7) then begin\n tot:=0;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n dfs4(temp);\n if solved then exit;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n //dfs4(temp);\n writeln('? ',temp);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp);\n flush(output);\n solved:=true;\n\n end else begin\n readln(a,b,c);\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n visit[temp2]:=true;\n writeln('? ',temp2);\n flush(output);\n readln(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end else begin\n if visit[a]=false then temp2:=a else if visit[b]=false then temp2:=b else temp2:=c;\n readln(aa,bb,cc);\n writeln('! ',temp2);\n flush(output);\n solved:=true;\n exit;\n end;\n end;\n exit;\n end;\n if visit[a]=false then temp:=a else if visit[b]=false then temp:=b else temp:=c;\n if visit[temp]=false then begin\n tot:=0;\n dfs2(temp);\n if solved then exit;\n if tot=h-dep then begin\n if visit[a]=false then dfs(a,dep-1) else if visit[b]=false then dfs(b,dep-1) else dfs(c,dep-1);\n end else begin\n cc:=(tot-h+dep)>>1;\n aa:=road[(tot-h+dep)>>1];\n //dfs(road[aa],dep-aa);\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,dep-cc-1);\n end;\n end;\n\nend;\nbegin\n readln(test);\n for ii:=1 to test do begin\n //ans:=0;\n solved:=false;\n dec(test);\n readln(h);\n fillchar(visit,sizeof(visit),false);\n writeln('? ',1);\n visit[1]:=true;\n flush(output);\n read(x);\n if x=2 then begin\n readln(a,b);\n writeln('! ',1);\n flush(output);\n continue;\n end else if x=1 then begin\n readln(a);\n dfs(a,h-1);\n end else begin\n readln(a,b,c);\n tot:=0;\n dfs3(a);\n if solved then continue;\n tot1:=tot;\n for i:=1 to tot do road1[i]:=road[i];\n tot:=0;\n dfs3(b);\n if solved then continue;\n tot2:=tot;\n for i:=1 to tot do road2[i]:=road[i];\n if tot1=tot2 then begin\n dfs(c,h-tot1-1);\n end else begin\n if tot1>1];\n\n //dfs(road2[aa],h-(tot1+tot2)>>1);\n end else begin\n aa:=road1[(tot1-tot2)>>1];\n //dfs(road1[aa],h-(tot1+tot2)>>1);\n end;\n if visit[ans[aa].a]=false then bb:=ans[aa].a else if visit[ans[aa].b]=false then bb:=ans[aa].b else bb:=ans[aa].c;\n dfs(bb,h-(tot1+tot2)>>1-1);\n end;\n end;\n end;\nend.\n"}], "src_uid": "5c0db518fa326b1e405479313216426a"} {"source_code": "var\n x, y, z, a, b, c: integer;\n k: byte;\n\nbegin\n read(x, y, z, a, b, c);\n k := 0;\n if a < x then\n k := 1\n else\n a := a - x;\n if k <> 1 then\n begin\n if y > a then\n begin\n y := y - a;\n a := 0;\n if y > b then\n k := 1\n else\n b := b - y;\n end\n else\n if y = a then\n a := 0\n else\n a := a - y;\n end\n else\n k := 1;\n if k <> 1 then\n if a + b + c < z then\n k := 1;\n if k <> 1 then\n write('YES')\n else\n write('NO');\nend.", "positive_code": [{"source_code": "var x,y,z,a,b,c:int64;\nbegin\nread(x,y,z,a,b,c);\nif (x<=a) and (y<=(a-x)+b) and (z<=(a+b+c)-x-y) then write('YES') else write('NO')\nend."}, {"source_code": "var\n x, z, y, g, p, b, v, no: integer;\n s1: string;\n s2: string;\n\nbegin\n readln(x, y, z);\n readln(g, p, b);\n \n if g >= x then\n v := g - x\n else\n no := 1;\n \n if p+v >= y then\n v := p+v - y\n else\n no := 1;\n \n if b+v < z then no := 1;\n \n if no = 1 then\n writeln('NO')\n else \n writeln('YES');\nend.\n"}, {"source_code": "begin\n var a,b,c,x,y,z:integer;\n readln(x,y,z);\n readln(a,b,c);\n z:=z-c;\n if x<=a then\n begin\n a:=a-x; \n end\n else\n begin\n println('NO');\n exit();\n end;\n if y<=a+b then\n begin\n a:=a-y;\n b:=b+a;\n end\n else\n begin\n println('NO');\n exit();\n end;\n if z<=b then\n println('YES')\n else\n println('NO');\nend."}, {"source_code": "var a,b,c,x,z,y,q:longint;\nbegin\n read(x,y,z,a,b,c);\n if a=x then dec(a,x) else begin writeln('NO');exit;end;\n if a>=y then dec(a,y)\n else if a+b>=y then begin dec(y,a);a:=0;dec(b,y);end\n else begin writeln('NO');exit;end;\n if a+b+c>=z then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Var x,y,z,a,b,c,sum:Longint;\nBegin\n Readln(x,y,z); Readln(a,b,c);\n sum:=a+b+c;\n If x<=a then begin\n Dec(a,x);\n Dec(sum,x);\n End\n Else begin\n Writeln('NO');\n Halt;\n End;\n If y<=a+b then Dec(sum,y)\n Else begin\n Writeln('No');\n Halt;\n End;\n If z<=sum then writeln('YES')\n Else writeln('NO');\nEnd."}, {"source_code": "program ProblemA;\nvar a,b,c,x,y,z:longint;\nbegin\n readln(x,y,z);\n readln(a,b,c);\n if a>=x then a:=a-x else\n begin\n write('NO');\n exit;\n end;\n\n b:=a+b;\n if b>=y then b:=b-y else\n begin\n write('NO');\n exit;\n end;\n c:=c+b;\n if c>=z then write('YES') else write('NO');\nend."}, {"source_code": "Program VINOGRAD2;\nvar x,y,z,a,b,c:integer;\nBegin\nreadln(x,y,z,a,b,c);\nif (x<=a) and (y<=a+b-x) and (z<=a+b+c-x-y) then\nwriteln('Yes')\nelse\nwriteln('No');\nEnd."}, {"source_code": "Program Vinograd;\nvar x,y,z,a,b,c,sum: longint;\n\nBegin\nreadln(x,y,z,a,b,c);\nif x<=a then\n begin\n a:= a-x;\n if y<=a+b then\n begin\n sum:=a+b-y;\n if z<= sum+c then\n writeln('Yes')\n else\n writeln('NO');\n end\n else\n begin\n writeln('NO');\n end;\n end\nelse\n begin\n writeln('NO');\n end;\n\nEnd."}, {"source_code": "\n Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If ( (a>=x) and (b>=y) and (c>=z) ) then writeln('YES')\n else\n begin\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n b:=b+kq;\n If (ba\n then write('NO')\n else if (a-x)+b= y then Begin\n If min(a, y) = a then Begin\n b -= y;\n b += a;\n a -= min(a, y);\n End\n Else\n a -= min(a, y);\n If a + b + c >= z then\n Write('YES')\n Else\n Write('NO')\n End\n Else Write('NO')\n End\n Else\n Write('NO')\nEnd."}, {"source_code": "var\n z,x,y,a,b,c,s:longint;\nbegin\nreadln(x,y,z);\nreadln(a,b,c);\nif x>a then begin writeln('NO'); halt; end else\na:=a-x;\nif a+b= x then a -= x\n else\n begin\n Writeln('NO');\n exit;\n end;\n summ := b + a;\n if summ >= y then summ -= y\n else\n begin\n Writeln('NO');\n exit;\n end;\n summ += c;\n if summ >= z then \n begin\n summ -= z;\n Writeln('YES');\n end\n else\n Writeln('NO');\n end."}, {"source_code": "var a,b,c,y,x,z:integer;\nbegin\nread(x,y,z,a,b,c);\nreadln;\nif (x<=a)and(a-x+b>=y)and(a-x+b-y+c>=z)\nthen writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var\n d,n,p,i,i2,i4:longint;\n a,b,c,z,x,y:extended;\n s:string;\nBegin\n\n readln(x,y,z);\n readln(a,b,c);\n \n if a=0 then begin\n itog:=true;\n a:=a-x;\n if a+b-y>=0 then begin\n sum:=a+b+c-y;\n if sum-z<0 then itog:=false;\n end\n else itog:=false; \n end\n else itog:=false; \nif itog then write('YES')\n else write('NO');\nend."}, {"source_code": "var n,m,k,green,purple,black,sum:longint;\nprocedure die;\nbegin\n write('NO');\n halt;\nend;\n\nbegin\n readln(n,m,k);\n read(green,purple,black);\n if green=x then dec(a,x) else\n begin\n write('NO');\n exit;\n end;\n if a+b>=y then b:=b-y+a else\n begin\n write('NO');\n exit;\n end;\n if b+c>=z then write('YES') else write('NO');\n readln;\nend."}, {"source_code": "program Grape;\nvar\n x, y, z: LongInt;\n a, b, c: LongInt;\n\nbegin\n ReadLn (x, y, z);\n ReadLn (a, b, c);\n\n a := a - x;\n\n if b > y then\n b := b - y\n else\n if b + a >= y then\n begin\n y := y - b;\n b := 0;\n a := a - y\n end\n else\n begin\n a := -1;\n end;\n\n if (a >= 0) and (b >= 0) and (a + b + c >= z) then\n WriteLn ('YES')\n else\n WriteLn ('NO');\nend."}, {"source_code": "var a,b,c,i,x,y,z,d:integer;\nbegin\n //x-Андрей(Только зеленый) y-Дмитрий(Не любит черный(Расист)) z-Михаил(ВСЕ)\n readln(x,y,z);\n //a-зленый b-фиолетовый c-черный\n readln(a,b,c);\n if (a - x >= 0) then\n begin\n a:= a-x;\n if (a + b - y >= 0) then\n begin\n d:= a + b - y;\n if (d + c - z >= 0) then\n begin\n d:= d + c - z;\n writeln('YES');\n end\n else writeln('NO');\n end\n else writeln('NO');\n end\n else writeln('NO');\nend."}, {"source_code": "Var x , y , z , a , b , c : Longint;\nBegin\nReadln(x,y,z);\nReadln(a,b,c);\nIf x > a then Writeln('NO') else\n Begin\n Dec(a,x);\n If a + b < y then Writeln('NO') else \n Begin\n Inc(c,a+b-y);\n If c < z then Writeln('NO') else Writeln('YES');\n End;\n End;\nEnd."}, {"source_code": "var x,y,z,i,s:integer;\n a:array [0..2] of integer;\n \nbegin\n readln(x,y,z);\n readln(a[0],a[1],a[2]);\n \n s:=a[0];\n \n if(x <= s) then\n begin\n s:=s-x;\n s:=s+a[1];\n if(y <= s) then\n begin\n s:=s-y;\n s:=s+a[2];\n if(z <= s) then writeln('YES')\n else writeln('NO');\n end\n else writeln('NO');\n end\n else writeln('NO');\nend."}, {"source_code": "program rusik;\n\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\n\nvar x,y,z,a,b,c,l,r,n,k,i:longint;\n\nbegin\n\nread(x,y,z);\nread(a,b,c);\nif x>a then begin\nwrite('NO');\nhalt(0);\nend;\nif y>a+b-x then begin\nwrite('NO');\nhalt(0);\nend;\nif z>a+b+c-x-y then begin\nwrite('NO');\nhalt(0);\nend;\nwrite('YES');\nend.\n"}, {"source_code": "var\n x, y, z, a, b, c, i: longint;\nbegin\n readln(x, y, z); \n read(a, b, c); \n if (a >= x) and ((a-x)+b >= y) and ((a-x)+(b-y)+c >= z) then write('YES') else write('NO');\nend."}, {"source_code": "var x,y,z,a,b,c,tam:longint;\nbegin\n readln(x,y,z);\n readln(a,b,c);\n if x > a then writeln('NO')\n else\n begin\n dec(a,x);\n tam:=a+b;\n if y > tam then writeln('NO')\n else\n begin\n dec(tam,y);\n tam:=tam+c;\n if z > tam then writeln('NO')\n else writeln('YES')\n end;\n end;\n readln;\nend.\n"}, {"source_code": "Program Grapes;\nuses math;\nvar a,b,c,x,y,z:longint;\nProcedure Likegrapes;\nbegin if (x>=a) and (x+y-a>=b) and (x+y+z-a-b>=c) then writeln('YES')\n else writeln('NO');\nend;\nbegin readln(a,b,c); readln(x,y,z);\n Likegrapes;\nend.\n"}, {"source_code": "var x,y,z,a,b,c:longint;\n t1,t2:longint;\n k:boolean;\n d:array[1..1000] of longint;\n\n{type day=array[1..100000] of longint;\n\nprocedure sort(var a:day;l,r: longint);\nvar i,j,x,y: longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=a) and (x+y-a>=b) and (x+y+z-a-b>=c) then writeln('YES')\n else writeln('NO');\nend;\nbegin //assign(input,'grape.inp'); reset(input);\n // assign(output,'grape.out'); rewrite(output);\n readln(a,b,c); readln(x,y,z);\n Likegrapes;\n //close(input); close(output);\nend.\n"}, {"source_code": "VAr i,e,t,k,l,m,u:int64;\nBegin\n //Assign(input,'Grapes.inp');reset(input);\n //Assign(output,'Grapes.out');rewrite(output);\n Readln(i,e,t);\n Readln(k,l,m);\n u:=k+l+m;\n If u<(i+e+t) then Write('NO') else\n Begin\n If t>m then u:=u-t else u:=k+l;\n If u<(i+e) then Write('NO') else\n Begin\n If (e+t)>(k+l+m) then u:=k+l+m-e-t else u:=k;\n If uz then begin writeln('NO'); halt; end;\nz:=z-a;\nif (z+f)=a then l:=l+1;\nz:=z-a;\ncol:=z+f;\nif col>=d then l:=l+1;\ncol:=col-d;\nch:=ch+col;\nif ch>=m then l:=l+1;\nif l=3 then write('Yes')\n else write('No');\n end.\n\n"}, {"source_code": "var \n x,y,z,a,b,c: integer;\nbegin\nreadln(x,y,z);\nreadln(a,b,c);\nif(a>=x)then a:=a-x else begin write('no'); exit; end;\nif a+b>=y then begin \n if y>=a then begin \n y:=y-a; a:=0; b:=b-y; end\n else a:=a-y; end else begin write('no'); exit; end; \nif a+b+c>=z then write('yes') else write('no');\nend."}, {"source_code": "var x,y,z:integer;\n ze,ph,ch:integer;\nBegin\n readln(x,y,z);\n readln(ze,ph,ch);\n if (ze < x) then begin\n writeln('NO');\n Exit;\n end;\n if (ze-x+ph < y) then begin\n writeln('NO');\n Exit;\n end;\n if (ze-x + ch-y + ph < z) then begin\n writeln('NO');\n Exit;\n end;\n writeln('YES');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=59999 then writeln('AAA');111\nif (a>=x) and(b+a>=y+x)and(a+b+c>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(200)=0 then writeln('AAA');\nend."}, {"source_code": "var x,y,z,a,b,c:longint;\nbegin \nread(x,y,z,a,b,c);\nif x>a then begin write('NO');halt;end;\nb:=b+a-x;\nif y>b then begin write('NO');halt;end;\nc:=c+b-y;\nif z>c then begin write('NO');halt;end;\nwrite('YES');\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=8000000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var centr,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,xx,yy,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n kolizm,minzn,zz,predok,xold,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n\n gr:array[-1..2000,-1..2000] of boolean;\n\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n newstr,str,sss:array[-1000..20000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4,-1..1300000] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n matr,ppole,ddl,ddr,dd3,dd4:array[-10..2000,-10..2200] of extended;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]y[i] then flag:=false;\n if flag then write('YES') else write('NO');\n\n\n\n\n\n\n\n1: close(output);\nend.\n"}, {"source_code": "var\n\ta, b, c, x, y, z: integer;\n\t\nbegin\n\t{$string_nullbased+}\n\t\n\treadln(x, y, z);\n\treadln(a, b, c);\n\t\n\tif (x > a) then writeln('NO')\n\telse if (y > a - x + b) then writeln ('NO')\n\telse if (z > a + b + c - y - x) then writeln ('NO')\n\telse writeln ('YES')\n\t\n\t\n\t\n\t\n\t\n\t\n\t\nend.\n"}, {"source_code": "var a,b,c,x,y,z: longint;\n\nbegin\n readln (x,y,z);\n readln (a,b,c);\n a:=a-x;\n if (a>=0) and ((a+b)>=y) and (a+b+c>=y+z) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var x,y,z,a,b,c:longint;\nBEGIN\nreadln(x,y,z);\nreadln(a,b,c);\n//if x+y+z>a+b+c then begin writeln('NO');exit;end;\n//fast NO\nif x>a then begin writeln('NO');exit;end;\nif y>a+b-x then begin writeln('NO');exit;end;\nif z>a+b+c - (x+y) then begin writeln('NO');exit;end;\nwriteln('YES');\nEND."}], "negative_code": [{"source_code": "begin\n var a,b,c,x,y,z:integer;\n readln(x,y,z);\n readln(a,b,c);\n z:=z-c;\n if x<=a then\n begin\n a:=a-x; \n end\n else\n begin\n println('NO');\n exit();\n end;\n if y<=c+b then\n begin\n a:=a-y;\n b:=b+a;\n end\n else\n begin\n println('NO');\n exit();\n end;\n if z<=c+b then\n println('YES')\n else\n println('NO');\nend."}, {"source_code": "begin\n var a,b,c,x,y,z:integer;\n readln(x,y,z);\n readln(a,b,c);\n z:=z-c;\n if x<=a then\n begin\n a:=a-x; \n end\n else\n begin\n println('NO');\n exit();\n end;\n if y<=c+b then\n begin\n a:=a-y;\n b:=b+a;\n end\n else\n begin\n println('NO');\n exit();\n end;\n if z<=b then\n println('YES')\n else\n println('NO');\nend."}, {"source_code": "Program VINOGRAD2;\nvar x,y,z,a,b,c:integer;\nBegin\nreadln(x,y,z,a,b,c);\nif (x<=a) and (y<=a+b-x) and (c<=a+b+c-x-y) then\nwriteln('Yes')\nelse\nwriteln('No');\nEnd."}, {"source_code": "Program Vinograd;\nvar x,y,z,a,b,c,sum: longint;\n\nBegin\nreadln(x,y,z,a,b,c);\nif x<=a then\n begin\n a:= a-x;\n if y<=a+b then\n begin\n sum:=a+b-y;\n if y <> 0 then\n b:=b-y;\n if z<= a+sum then\n writeln('Yes')\n else\n writeln('NO');\n end\n else\n begin\n writeln('NO');\n end;\n end\nelse\n begin\n writeln('NO');\n end;\n\nEnd."}, {"source_code": "Program VINOGRAD2;\nvar x,y,z,a,b,c:integer;\nBegin\nreadln(x,y,z,a,b,c);\nif (x<=a) and (y<=a+b-a) and (c<=a+b+c-a-y) then\nwriteln('Yes')\nelse\nwriteln('No');\nEnd."}, {"source_code": "Program Vinograd;\nvar x,y,z,a,b,c: integer;\n\nBegin\nreadln(x,y,z,a,b,c);\nif x<=a then\n begin\n a:= a-x;\n if y<=a+b then\n begin\n while a>0 do\n begin\n a:=a-1;\n if y <> 0 then\n y:=y-1\n else\n break;\n end;\n if y <> 0 then\n b:=b-y;\n if z<= a+b+c then\n writeln('Yes');\n end\n else\n begin\n writeln('NO');\n end;\n end\nelse\n begin\n writeln('NO');\n end;\n\nEnd."}, {"source_code": "Program Vinograd;\nvar x,y,z,a,b,c: longint;\n\nBegin\nreadln(x,y,z,a,b,c);\nif x<=a then\n begin\n a:= a-x;\n if y<=a+b then\n begin\n while a>0 do\n begin\n a:=a-1;\n if y <> 0 then\n y:=y-1\n else\n break;\n end;\n if y <> 0 then\n b:=b-y;\n if z<= a+b+c then\n writeln('Yes')\n else\n writeln('NO');\n end\n else\n begin\n writeln('NO');\n end;\n end\nelse\n begin\n writeln('NO');\n end;\n\nEnd."}, {"source_code": "program one;\nvar\nx,y,z,a,b,c:integer;\nbegin\nreadln(x,y,z);\nreadln(a,b,c);\nif x<=a then \n begin\n a:=a-x;\n x:=0;\n end;\nif y<=a then\n begin\n a:=a-y;\n y:=0;\n end\n else\n begin\n a:=0;\n y:=y-a;\n if y<=b then\n begin\n b:=b-y;\n y:=0;\n end;\n end;\nif z<=a then\n begin\n z:=0;\n end\n else\n begin\n if z<=b then\n begin\n b:=b-z;\n z:=0;\n end\n else\n begin\n b:=0;\n z:=z-b;\n if z<=c then\n begin\n c:=c-z;\n z:=0;\n end;\n end;\n end;\nif (x=0) and (y=0) and (z=0) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "program one;\nvar\nx,y,z,a,b,c:integer;\nbegin\nreadln(x,y,z);\nreadln(a,b,c);\nif x<=a then \n begin\n a:=a-x;\n x:=0;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\nif y<=a then\n begin\n a:=a-y;\n y:=0;\n end\n else\n begin\n a:=0;\n y:=y-a;\n if y<=b then\n begin\n b:=b-y;\n y:=0;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end;\nif z<=a then\n begin\n z:=0;\n end\n else\n begin\n if z<=b then\n begin\n b:=b-z;\n z:=0;\n end\n else\n begin\n b:=0;\n z:=z-b;\n if z<=c then\n begin\n c:=c-z;\n z:=0;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end;\n end;\nwriteln('YES');\nend.\n"}, {"source_code": "program one;\nvar\nx,y,z,a,b,c:integer;\nbegin\nread(x,y,z);\nread(a,b,c);\nif x<=a then\n begin\n a:=a-x;\n x:=0;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\nwriteln('a: ',a);\nwriteln('x: ',x);\nreadln;\nif y<=a then \n begin\n a:=a-y;\n y:=0;\n end\n else\n begin\n y:=y-a;\n a:=0;\n if y<=b then\n begin\n b:=b-y;\n y:=0;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end;\nif z<=a then\n begin\n writeln('YES');\n end\n else\n begin\n z:=z-a;\n a:=0;\n if z<=b then\n begin\n writeln('YES');\n end\n else\n begin\n z:=z-b;\n b:=0;\n if z<=c then \n begin\n writeln('YES');\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end;\n end;\nend."}, {"source_code": "program one;\nvar\nx,y,z,a,b,c:integer;\nbegin\nreadln(x,y,z);\nreadln(a,b,c);\nif x<=a then \n begin\n a:=a-x;\n x:=0;\n end;\nif y<=a then\n begin\n a:=a-y;\n y:=0;\n end\n else\n begin\n a:=0;\n y:=y-a;\n if y<=b then\n begin\n b:=b-y;\n y:=0;\n end;\n end;\nif z<=a then\n begin\n a:=a-z;\n z:=0;\n end\n else\n begin\n if z<=b then\n begin\n b:=b-z;\n z:=0;\n end\n else\n begin\n b:=0;\n z:=z-b;\n if z<=c then\n begin\n c:=c-z;\n z:=0;\n end;\n end;\n end;\nif (x=0) and (y=0) and (z=0) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var x,y,z,a,b,c:int64;\nbegin\nread(x,y,z,a,b,c);\nif (x<=a) and (y<=(x-a)+b) and (z<=(a+b+c)-x-y) then write('YES') else write('NO')\nend."}, {"source_code": "Var\n x, y, z, a, b, c: Int64;\n \nBegin\n Read(x, y, z);\n Read(a, b, c);\n If x <= a then Begin\n a -= x;\n If a + b <= y then Begin\n b -= y;\n a -= x;\n If a + b + c <= z then\n Write('YES')\n Else\n Write('NO')\n End\n Else Write('NO')\n End\n Else\n Write('NO')\nEnd."}, {"source_code": "Var\n x, y, z, a, b, c: Int64;\n \nBegin\n Read(x, y, z);\n Read(a, b, c);\n If x <= a then Begin\n a -= x;\n If a + b <= y then Begin\n b -= (x + y);\n If a + b + c <= z then\n Write('YES')\n Else\n Write('NO')\n End\n Else Write('NO')\n End\n Else\n Write('NO')\nEnd."}, {"source_code": "\nvar x,y,z:integer;\n a,b,c:integer;\n\n\nbegin\nx:=5;\ny:=1;\nz:=1;\na:=5;\nb:=3;\nc:=2;\n read(x,y,z);\n read(a,b,c);\n if a=y) then if ((a-x)+(a-x+b-y+c))>=z then write('Yes')\n else write('No');\n \nend.\n"}, {"source_code": "\nvar x,y,z:integer;\n a,b,c:integer;\n\n\nbegin\nx:=5;\ny:=1;\nz:=1;\na:=5;\nb:=3;\nc:=2;\n read(x,y,z);\n read(a,b,c);\n if a=y) then if ((a-x)+((b-y-(a-x))+c))>=z then write('Yes')\n else write('No');\n \nend.\n"}, {"source_code": "\nvar x,y,z:integer;\n a,b,c:integer;\n\n\nbegin\nx:=5;\ny:=1;\nz:=1;\na:=5;\nb:=3;\nc:=2;\n read(x,y,z);\n read(a,b,c);\n if a=y) then if ((a-x)+(a-x+b-y))>=z then write('Yes')\n else write('No');\n \nend.\n"}, {"source_code": "var\n x, y, z, a, b, c: integer;\n k: byte;\n\nbegin\n read(x, y, z, a, b, c);\n k:=0;\n if a > x then\n k := 1\n else\n a := a - x;\n write(k);\n if k <> 1 then\n begin\n if y > a then\n begin\n y := y - a;\n if y > b then\n k := 1\n else\n b := b - y;\n end\n else\n if y = a then\n a := 0\n else\n a := a - y;\n end\n else\n k := 1;\n write(k);\n if k <> 1 then\n if a + b + c < z then\n k := 1;\n write(k);\n if k <> 1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "var\n x, y, z, a, b, c: integer;\n k: byte;\n\nbegin\n read(x, y, z, a, b, c);\n k := 0;\n if a < x then\n k := 1\n else\n a := a - x;\n if k <> 1 then\n begin\n if y > a then\n begin\n y := y - a;\n if y > b then\n k := 1\n else\n b := b - y;\n end\n else\n if y = a then\n a := 0\n else\n a := a - y;\n end\n else\n k := 1;\n if k <> 1 then\n if a + b + c < z then\n k := 1;\n if k <> 1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+a>=y)and(a+b+c>=z) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+c>=y)and(x+y+z>=z) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+a>=y-x)and(a+b+c+1>=z-y-x) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+a>=y)and(a+b+c+1>=z) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=59999 then writeln('AAA');\nif (a>=x) and(b+a>=y+x)and(a+b+c>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(20)=0 then writeln('AAA');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+c>=y)and(x+y+z+1>=c) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=59999 then writeln('AAA');\nif (a>=x) and(b+a>=y+x)and(a+b+c>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(200)=0 then writeln('AAA');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n///if x+y+z+a+b+c=59999 then writeln('AAA');\nif (a>=x) and(b+a>=y+x)and(a+b+c>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(20)=0 then writeln('AAA');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+a>=y+x)and(a+b+c+1>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(20)=0 then writeln('AAA');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=59999 then writeln('AAA');\nif (a>=x) and(b+a>=y+x)and(a+b+c>=z+y+x) then writeln('YES') else writeln('NO');\nrandomize;\nif random(200)=0 then writeln('AAA');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+c>=y)and(x+y+z>=c) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\nif x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+c>=y)and(x+y+z+1>=z) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,c,x,y,z:int64;\nbegin\nreadln(x,y,z,a,b,c);\n//if x+y+z+a+b+c=600000 then writeln('AAA');\nif (a>=x) and(b+a>=y-x)and(a+b+c>=z-y-x) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n z:=z+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:integer;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n z:=z+b+kq;\n end\n else\n begin\n b:=b+kq;\n z:=z+(b-y);\n end;\n If (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If ( (a>=x) and (b>=y) and (c>=z) ) then writeln('YES')\n else\n begin\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n c:=c+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:integer;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n If (a>=x) then kq:=a-x;\n If (b>=y) then kq1:=b-y\n else b:=b+kq;\n If (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:integer;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then b:=b-y\n else b:=b+kq;\n If (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If ( (a>=x) and (b>=y) and (c>=z) ) then writeln('YES')\n else\n begin\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n c:=c+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n end;\n end;\n end;\n Close(input);\n Close(output);\nENd.\n"}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If ( (a>=x) and (b>=y) and (c>=z) ) then writeln('YES')\n else\n begin\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n c:=c+b+kq;\n end\n else\n begin\n b:=b+kq;\n end;\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n end;\n end;\n\n\n Close(input);\n Close(output);\nENd.\n"}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n c:=c+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:integer;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n z:=z+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n c:=c+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "Var a,b,c,x,y,z,kq,kq1:longint;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Read(x,y,z);\n readln;\n Read(a,b,c);\n If (x>a) then writeln('NO')\n else\n begin\n\n kq:=a-x;\n If (b>=y) then\n begin\n b:=b-y;\n z:=z+b+kq;\n end\n else\n begin\n b:=b+kq;\n\n if (b=z) then writeln('YES')\n else writeln('NO');\n end;\n Close(input);\n Close(output);\nENd."}, {"source_code": "var r,y,x,z,d,e,f,j,jj:integer;\n\nbegin\nread (y,x,z);\nread (d,e,f);\nj:=d+e+f;\njj:=d+e;\nif (d-y>-1) then jj:=jj-y else r:=1;\nif (jj-x>-1) then j:=j-x else r:=1;\nif (j-f<0) then e:=1;\nif (r=0) then write ('YES') else write ('NO');\nend."}, {"source_code": "var\n d,n,p,i,i2,i4:longint;\n a,b,c,z,x,y:extended;\n s:string;\nBegin\n\n readln(x,y,z);\n readln(a,b,c);\n \n if a0 then g:=g-m\n else if p-m>0 then p:=p-m\n else g:=g+p-m;\n if g+b=0 then g:=g-m\n else if p-m>=0 then p:=p-m\n else g:=g+p-m;\n if g+b y then\n b := b - y\n else\n if b + a <= y then\n begin\n y := y - b;\n b := 0;\n a := a - y\n end\n else\n begin\n a := -1;\n end;\n\n if (a >= 0) and (b >= 0) and (a + b + c >= z) then\n WriteLn ('YES')\n else\n WriteLn ('NO');\nend."}, {"source_code": "Var x , y , z , a , b , c : Longint;\nBegin\nReadln(x,y,z);\nReadln(a,b,c);\nIf x > a then Writeln('NO') else\n Begin\n Dec(a,x);\n If a + b < y then Writeln('NO') else Writeln('YES');\n End;\nEnd."}, {"source_code": "var\n x, y, z, a, b, c, i: longint;\n s: string;\n \nbegin\n readln(x, y, z); \n read(a, b, c); \n s := 'YES';\n a := a-x;\n if (a < 0) then begin s := 'NO'; write(s); exit; end;\n b := (a+b)-y;\n if (b < 0) then begin s := 'NO'; write(s); exit; end;\n c := (c+b+a)-z;\n if (c < 0) then begin s := 'NO'; write(s); exit; end;\n write(s);\nend."}, {"source_code": "var a,b,r,z,f,c,s:longint;\nbegin\nread(a,b,r);\nread(z,f,c);\nif a>c then begin writeln('NO'); halt; end;\nz:=z-a;\nif (z+f)=a then l:=l+1;\nz:=z-a;\ncol:=z+f;\nif col>=d then l:=l+1;\ncol:=col-d;\nif ch>=a+col then l:=l+1;\nif l=3 then write('Yes')\n else write('No');\n end.\n\n"}, {"source_code": "var a,b,q,w,e,r,t,y,u,i,o,p,l,k,j,hg,f,d,s,z,x,c,v,n,m,g,ch,col:integer;\nbegin\nread(a,d,m);\nread(z,f,ch);\nif z>=a then l:=l+1;\nz:=z-a;\ncol:=z+f;\nif col>=d then l:=l+1;\ncol:=col-d;\nif ch>=m+col then l:=l+1;\nif l=3 then write('Yes')\n else write('No');\n end.\n\n"}, {"source_code": "var x,y,z:integer;\n ze,ph,ch:integer;\nBegin\n readln(x,y,z);\n readln(ze,ph,ch);\n if (ze < x) then begin\n writeln('NO');\n Exit;\n end;\n if (ph+ch < y) then begin\n writeln('NO');\n Exit;\n end;\n if (ze-x + ph+ch-y < z) then begin\n writeln('NO');\n Exit;\n end;\n writeln('YES');\nend."}, {"source_code": "var x,y,z:integer;\n ze,ph,ch:integer;\nBegin\n readln(x,y,z);\n readln(ze,ph,ch);\n if (ze < x) then begin\n writeln('NO');\n Exit;\n end;\n if (ze-x+ch < y) then begin\n writeln('NO');\n Exit;\n end;\n if (ze-x + ch-y + ph < z) then begin\n writeln('NO');\n Exit;\n end;\n writeln('YES');\nend."}, {"source_code": "var x,y,z,i:integer;\n a:array [0..2] of integer;\n \nbegin\n readln(x,y,z);\n readln(a[0],a[1],a[2]);\n \n if(x <= a[0]) then\n begin\n a[0]:=a[0]-x;\n if(y <= (a[0]+a[1])) then\n begin\n if(a[0] >= y) then a[0]:=a[0]-y\n else \n begin\n y:=y-a[0];\n a[0]:=0;\n end;\n a[1]:=a[1]-y;\n if(z <= (a[0] + a[1] + a[2])) then writeln('YES')\n else writeln('NO');\n end\n else writeln('NO');\n end\n else writeln('NO');\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=8000000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var centr,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,xx,yy,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n kolizm,minzn,zz,predok,xold,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n\n gr:array[-1..2000,-1..2000] of boolean;\n\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n newstr,str,sss:array[-1000..20000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4,-1..1300000] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n matr,ppole,ddl,ddr,dd3,dd4:array[-10..2000,-10..2200] of extended;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]y then begin\nwrite('NO');\nhalt(0);\nend;\nif y>a+b-x then begin\nwrite('NO');\nhalt(0);\nend;\nif z>a+b+c-x-y then begin\nwrite('NO');\nhalt(0);\nend;\nwrite('YES');\nend.\n"}], "src_uid": "d54201591f7284da5e9ce18984439f4e"} {"source_code": "var N, i2, i3, Dem: int64;\r\n T, i: longint;\r\n\r\nprocedure Nhap;\r\n begin\r\n readln(N);\r\n end;\r\n\r\nprocedure Xuli;\r\nvar i: int64;\r\n begin\r\n Dem := 1;\r\n i2 := 2;\r\n i3 := 2;\r\n while (i2*i2 <= N) do begin\r\n inc(Dem);\r\n inc(i2);\r\n end;\r\n while(i3*i3*i3 <= N) do begin\r\n if trunc(sqrt(i3*i3*i3)) * trunc(sqrt(i3*i3*i3)) <> i3*i3*i3 then inc(Dem);\r\n inc(i3);\r\n end;\r\n writeln(Dem);\r\n end;\r\n\r\nbegin\r\n readln(T);\r\n for i := 1 to T do begin\r\n Nhap;\r\n Xuli;\r\n end;\r\nend.\r\n", "positive_code": [{"source_code": "var t:integer;\r\nn,s:longint;\r\na,b,c:set of integer;\r\nbegin\r\n readln(t);\r\n for var i:=0 to t-1 do begin\r\n readln(n);\r\n s:=0;\r\n a:=[];\r\n b:=[];\r\n c:=[];\r\n for var j:=1 to n do if j*j<=n then include(a,j*j) else break;\r\n for var j:=1 to n do if j*j*j<=n then include(b,j*j*j) else break;\r\n c:=(a-b)+b;\r\n foreach x: integer in c do s:=s+1;\r\n writeln(s);\r\n end; \r\nend."}, {"source_code": "uses\r\n Math;\r\n\r\nvar\r\n t, step, n, ans: longint;\r\n i, m: extended;\r\n \r\nbegin\r\n read(t);\r\n for step := 1 to t do begin\r\n read(n);\r\n i := 1;\r\n ans := 0;\r\n m := floor(sqrt(n));\r\n while i <= m do begin\r\n inc(ans, 2);\r\n if (i * i * i > n) or (frac(sqrt(i * i * i)) = 0) then\r\n dec(ans);\r\n i := i + 1;\r\n end;\r\n writeln(ans);\r\n end;\r\nend."}, {"source_code": "{$Ifdef Home}\r\nunit Task_B;\r\ninterface\r\nimplementation\r\n{$Else}\r\nprogram Task_;\r\n{$EndIf}\r\n\r\n{$APPTYPE CONSOLE}\r\n{$T+}\r\n\r\n//todo -c adsads -oPPP: asdsada\r\n\r\nuses\r\n SysUtils,\r\n Types,\r\n Math,\r\n Classes;\r\n\r\n\r\n\r\nconst\r\n{$Ifdef Home}\r\n Home=true;\r\n{$Else}\r\n Home=false;\r\n{$EndIf}\r\n\r\n\r\nvar\r\n GCD_PassCnt: int64=0;\r\n\r\n Test: boolean=false;\r\n Check: boolean=false;\r\n Hack: boolean=false;\r\n Echo: boolean=false;\r\n Data: array of string;\r\n TestFile: textFile;\r\n\r\n\r\n\r\nprocedure Stop;\r\nbegin\r\n\r\nend;\r\n\r\nprocedure SetData(S: array of string);\r\n var\r\n i: integer;\r\n begin\r\n SetLength(Data, Length(S));\r\n for i:=0 to High(S) do\r\n Data[i]:=S[i];\r\n end;\r\n\r\n\r\nprocedure Swap(var A, B: int64); overload;\r\n var\r\n C: int64;\r\n begin\r\n C:=A;\r\n A:=B;\r\n B:=C;\r\n end;\r\n\r\nprocedure FillStrRnd(var S: string; C: array of char);\r\n var\r\n n: integer;\r\n i: integer;\r\n begin\r\n N:=Length(C);\r\n for i:=1 to Length(S) do\r\n S[i]:=C[random(N)];\r\n\r\n end; // FillStrRnd\r\n\r\n//==============================================================================\r\n\r\n\r\nprocedure FillRnd(A: TInt64DynArray; Min, Max: int64);\r\n var\r\n i: integer;\r\n begin\r\n for i:=0 to High(A) do\r\n A[i]:=Min+random(Max-Min+1);\r\n\r\n end; // FillStrRnd\r\n\r\n//==============================================================================\r\n\r\nprocedure ReadPrepare(FileName: string);\r\n begin\r\n if not FileExists(FileName) then\r\n begin\r\n WriteLn(format('TestFile \"%s\" not found', [FileName]));\r\n WriteLn('Press to terminate');\r\n System.ReadLn;\r\n halt(1);\r\n end;\r\n\r\n AssignFile(TestFile, FileName);\r\n Reset(TestFile);\r\n end;\r\n\r\n\r\nprocedure Read_(var X: int64); overload;\r\n begin\r\n if Test then System.Read(TestFile, X)\r\n else System.Read(X);\r\n end;\r\n\r\nprocedure Read_(var X: double); overload;\r\n begin\r\n if Test then System.Read(TestFile, X)\r\n else System.Read(X);\r\n end;\r\n\r\n\r\nprocedure Read_Ln(var X: int64); overload;\r\n begin\r\n if Test then System.ReadLn(TestFile, X)\r\n else System.ReadLn(X);\r\n end;\r\n\r\nprocedure Read_Ln(var X: double); overload;\r\n begin\r\n if Test then System.ReadLn(TestFile, X)\r\n else System.ReadLn(X);\r\n end;\r\n\r\nprocedure Read_Ln(var Str: string); overload;\r\n begin\r\n if Test then System.Readln(TestFile, Str)\r\n else System.Readln(Str);\r\n end;\r\n\r\n//------------------------------------------------------------------------------\r\n\r\n\r\n// ������ � Delphi. �����: A, B: int64;\r\n// 1) ������ ���� ������� ��������� (var X: array of int64) � �������� ([A, B])\r\n//\r\n// 2) ���� � �������������� �����������\r\n// ���� ������� (X: array of pInteger) � (X: array of pInt64), ��\r\n// ���������� ��������������� ��� ������ ([@A, @B])\r\n// 3) ���� ���� ������ ReadLn(X: array of pInt64),\r\n// �� ��� ������ ReadLn([@A, @B]) ������ Ordinal type req...\r\n// ������ ����������� �� ����������� ��������\r\n// ������� ������� ����� ��� ������� �������� ���� Task_C.\r\n\r\n\r\nprocedure Read_Ln(X: array of pInt64); overload;\r\n var\r\n i, h: integer;\r\n begin\r\n h:=High(X);\r\n for i:=0 to h-1 do\r\n Read_(X[i]^);\r\n\r\n Read_Ln(X[h]^)\r\n end;\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nprocedure Read_LnD(X: array of pdouble); overload;\r\n var\r\n i, h: integer;\r\n begin\r\n h:=High(X);\r\n for i:=0 to h-1 do\r\n Read_(X[i]^);\r\n\r\n Read_Ln(X[h]^)\r\n end;\r\n\r\n//------------------------------------------------------------------------------\r\n\r\n\r\nprocedure Read_Ln(X: TInt64DynArray); overload;\r\n var\r\n i, h: integer;\r\n begin\r\n h:=High(X);\r\n for i:=0 to h-1 do\r\n Read_(X[i]);\r\n\r\n Read_Ln(X[h])\r\n end;\r\n\r\n\r\nprocedure Write_Ln(X: TInt64DynArray);\r\n var\r\n i: integer;\r\n begin\r\n if Length(X)=0 then\r\n WriteLn('')\r\n else\r\n begin\r\n for i:=0 to High(X)-1 do\r\n Write(X[i], ' ');\r\n WriteLn(X[High(X)]);\r\n end;\r\n\r\n end;\r\n\r\ntype\r\n\r\n TInt64Array=array [0..$7FFFFFF] of int64;\r\n PInt64Array=^TInt64Array;\r\n\r\n TIteratorAxisCustom=class\r\n// Common: TIntegerDynArray;\r\n // ExtraA, ExtraB, ExtraB: TIntegerDynArray;\r\n\r\n AxisCnt: integer;\r\n AxisIdx: integer;\r\n AxisVal: TIntegerDynArray;\r\n\r\n function StateStr: string; virtual;\r\n function NextAxisVal: boolean; virtual; abstract;\r\n function Next: boolean; virtual;\r\n procedure UpdateAxisVal(Axis, ValNew: integer); virtual;\r\n procedure Init(AxisCnt: integer); virtual;\r\n procedure AddAxis(AxisVal: integer);\r\n procedure Reset; virtual;\r\n end;\r\n//------------------------------------------------------------------------------\r\n\r\n TIteratorAxis=class(TIteratorAxisCustom)\r\n AxisValHi: TIntegerDynArray;\r\n\r\n function NextAxisVal: boolean; override;\r\n procedure AddAxisHi(AxisVal, AxisValHi: integer);\r\n end;\r\n\r\n//==============================================================================\r\n// {$T+} Usage:\r\n// A: TInt64DynArray;\r\n// QuickIntSort_(pInt64Array(@A[0]), nil, 0, n-1);\r\n\r\nprocedure QuickSort(Value, Order: PInt64Array; iLo, iHi: Integer; OrderSign: integer=0);\r\n var\r\n Lo, Hi: Int64;\r\n MidVal, MidOrd: int64;\r\n Tmp: int64;\r\n UseOrder: boolean;\r\n begin\r\n Lo:=iLo;\r\n Hi:=iHi;\r\n if Hi0) and Assigned(Order);\r\n if UseOrder then\r\n OrderSign:=OrderSign div abs(OrderSign)\r\n else\r\n OrderSign:=0;\r\n\r\n MidVal:=Value[(Lo + Hi) div 2];\r\n if UseOrder then\r\n MidOrd:=OrderSign*Order[(Lo + Hi) div 2]\r\n else\r\n MidOrd:=0;\r\n repeat\r\n //while Value[Lo]Mid do Dec(Hi);\r\n {while (Value[Lo]MidVal) or (UseOrder and (Value[Hi]=MidVal) and (OrderSign*Order[Hi]>MidOrd)) do\r\n Dec(Hi);{}\r\n\r\n if UseOrder then\r\n begin\r\n while (Value[Lo]MidVal) or\r\n ((Value[Hi]=MidVal) and (OrderSign*Order[Hi]>MidOrd)) do\r\n Dec(Hi);\r\n end\r\n else\r\n begin\r\n while Value[Lo]MidVal do Dec(Hi);\r\n end;\r\n\r\n if Lo<=Hi then\r\n begin\r\n Tmp:=Value[Lo];\r\n Value[Lo]:=Value[Hi];\r\n Value[Hi]:=Tmp;\r\n\r\n if Assigned(Order) then\r\n begin\r\n Tmp:=Order[Lo];\r\n Order[Lo]:=Order[Hi];\r\n Order[Hi]:=Tmp;\r\n end;\r\n\r\n Inc(Lo);\r\n Dec(Hi);\r\n end;\r\n until Lo > Hi;\r\n if Hi>iLo then QuickSort(Value, Order, iLo, Hi, OrderSign);\r\n if Lo0) do\r\n begin\r\n if test then\r\n inc(Cmp_PC);\r\n\r\n Dec(Hi);\r\n end;\r\n\r\n if Lo<=Hi then\r\n begin\r\n Tmp:=Value[Lo];\r\n Value[Lo]:=Value[Hi];\r\n Value[Hi]:=Tmp;\r\n\r\n if Assigned(Order) then\r\n begin\r\n Tmp:=Order[Lo];\r\n Order[Lo]:=Order[Hi];\r\n Order[Hi]:=Tmp;\r\n end;\r\n\r\n Inc(Lo);\r\n Dec(Hi);\r\n end;\r\n until Lo > Hi;\r\n \r\n if Hi>iLo then QuickSortCmp(Value0, Order0, Cmp, iLo, Hi);\r\n if Lo0 then\r\n begin\r\n WriteLn('Sort error on pass: ', PassCnt);\r\n inc(ErrCnt);\r\n end;\r\n end;\r\n end;\r\n end;\r\n\r\n if ErrCnt=0 then\r\n WriteLn('Sort Test passed')\r\n else\r\n WriteLn('Sort Test failed');\r\n end; // TEST_QuickSortCmpInt64\r\n\r\n//==============================================================================\r\n\r\nprocedure TIteratorAxisCustom.AddAxis(AxisVal: integer);\r\n begin\r\n SetLength(Self.AxisVal, AxisCnt+1);\r\n\r\n inc(AxisCnt);\r\n UpdateAxisVal(AxisCnt-1, AxisVal);\r\n\r\n end; // AddAxis\r\n\r\n//==============================================================================\r\n\r\nprocedure TIteratorAxis.AddAxisHi(AxisVal, AxisValHi: integer);\r\n begin\r\n SetLength(Self.AxisValHi, AxisCnt+1);\r\n\r\n Self.AxisValHi[AxisCnt]:=AxisValHi;\r\n\r\n AddAxis(AxisVal);\r\n end; // AddAxis\r\n\r\n//==============================================================================\r\n\r\nprocedure TIteratorAxisCustom.Init(AxisCnt: integer);\r\n var\r\n a: integer;\r\n begin\r\n Self.AxisCnt:=AxisCnt;\r\n AxisIdx:=0;\r\n SetLength(AxisVal, AxisCnt);\r\n for a:=0 to AxisCnt-1 do\r\n begin\r\n AxisVal[a]:=0;\r\n end;\r\n end; // Init\r\n\r\n//==============================================================================\r\n\r\nfunction TIteratorAxis.NextAxisVal: boolean;\r\n begin\r\n Result:=AxisVal[AxisIdx]AxisIdx0 then\r\n begin\r\n //for a:=0 to AxisIdx-1 do\r\n // UpdateAxisVal(a, 0);\r\n AxisIdx:=0;\r\n end;\r\n end\r\n else\r\n begin\r\n// PrevAxisVal;\r\n if AxisIdx0 then\r\n Result:=gcd(y, x mod y)\r\n else\r\n Result:=x;\r\n end; // gcd\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nfunction LCM(x, y: int64): int64;\r\n begin\r\n Result:=(x div gcd(x, y))*y;\r\n end;\r\n\r\n//------------------------------------------------------------------------------\r\n\r\n// Greatest Common Divider\r\nfunction GCDold(a, b: int64): int64;\r\n var\r\n t: int64;\r\n a_, b_: int64;\r\n begin\r\n inc(GCD_PassCnt);\r\n if GCD_PassCnt=4362 then\r\n Stop;\r\n\r\n a_:=abs(a);\r\n b_:=abs(b);\r\n\r\n while (b_<>0) do\r\n begin\r\n t:=b_;\r\n b_:=a_ mod b_;\r\n a_:=t;\r\n end;\r\n result:=a_;\r\n end; // GCD\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nprocedure TestGCD;\r\n var\r\n x, y: int64;\r\n xy, xyold: int64;\r\n ErrCnt: int64;\r\n begin\r\n ErrCnt:=0;\r\n repeat\r\n x:=random(1000);\r\n y:=random(1000);\r\n\r\n xy:=gcd(x, y);\r\n xyold:=gcdold(x, y);\r\n\r\n if xy<>xyOld then\r\n begin\r\n inc(ErrCnt);\r\n Stop;\r\n end;\r\n until false;\r\n end; // TestGCD\r\n\r\n//==============================================================================\r\nvar\r\n PrimeList: TIntegerDynArray;\r\n\r\nfunction PrimeCntList(X: int64): integer;\r\n var\r\n p, Cnt, i: integer;\r\n Y: int64;\r\n begin\r\n Result:=0;\r\n if X<=1 then\r\n Exit;\r\n\r\n Cnt:=Length(PrimeList);\r\n Y:=X;\r\n for i:=0 to Cnt-1 do\r\n begin\r\n p:=PrimeList[i];\r\n if p=0 then\r\n Stop;\r\n while Y mod p=0 do\r\n begin\r\n Y:=Y div p;\r\n inc(Result);\r\n end;\r\n\r\n if sqr(p)>Y then\r\n Break;\r\n end;\r\n\r\n if Y>1 then\r\n inc(Result);\r\n end;\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nfunction PrimeCnt(X: int64): integer;\r\n var\r\n p, y: integer;\r\n pp: int64;\r\n begin\r\n Result:=0;\r\n if X<=1 then\r\n Exit;\r\n \r\n y:=x;\r\n p:=2;\r\n while (y mod p)=0 do\r\n begin\r\n y:=y div p;\r\n inc(Result);\r\n end;\r\n\r\n inc(p);\r\n\r\n while (sqr(p)<=y) do\r\n begin\r\n while y mod p=0 do\r\n begin\r\n y:=y div p;\r\n inc(Result);\r\n end;\r\n inc(p, 2);\r\n end;{}\r\n\r\n if y>1 then\r\n inc(Result);\r\n end; // PrimeCnt\r\n\r\n//==============================================================================\r\n\r\nprocedure PrimeCntPrepare(Xmax: int64);\r\n var\r\n h: int64;\r\n p: integer;\r\n Y: int64;\r\n Count, Capacity: integer;\r\n\r\n procedure Add(p: integer);\r\n begin\r\n if Count=Capacity then\r\n begin\r\n Capacity:=Max(2*Capacity, 4);\r\n SetLength(PrimeList, Capacity);\r\n end;\r\n\r\n PrimeList[Count]:=p;\r\n inc(Count);\r\n end;\r\n\r\n begin\r\n// Result\r\n h:=round(sqrt(1.0*Xmax));\r\n while (h*h)0 then Res:=max(Res, LevelVal[Level, NodeIdx])\r\n else Res:=min(Res, LevelVal[Level, NodeIdx]);\r\n end;\r\n\r\n procedure TValTree.LevelRange(Level: integer; L, R: integer; var Res: int64);\r\n var\r\n Step, i: integer;\r\n L_, R_: integer;\r\n Val: int64;\r\n NodeL, NodeR: integer;\r\n NodeL_, NodeR_: integer;\r\n Prefix: string;\r\n begin\r\n inc(OpCnt);\r\n Step:=1 shl (LevelH-Level);\r\n\r\n if Echo then\r\n begin\r\n Prefix:=StringOfChar(' ', 3*Level);\r\n WriteLn(format('%s %2d %2d %2d %2d', [Prefix, Level, Step, L, R]));\r\n if Level>=4 then\r\n Stop;\r\n end;\r\n\r\n if Step=1 then\r\n begin\r\n for i:=L to R do\r\n begin\r\n NodeOp(Level, i, Res);\r\n if Echo then\r\n WriteLn(Prefix, '+');\r\n end;\r\n end\r\n else\r\n begin\r\n NodeL:=(L) div Step;\r\n NodeR:=(R) div Step;\r\n L_:=NodeL*Step;\r\n R_:=(NodeR+1)*Step-1;\r\n if NodeL=NodeR then\r\n begin\r\n if (L=L_) and (R=R_) then\r\n begin\r\n inc(OpCnt);\r\n NodeOp(Level, NodeL, Res);\r\n if Echo then\r\n WriteLn(Prefix, '+', Step);\r\n end\r\n else\r\n LevelRange(Level+1, L, R, Res)\r\n end\r\n else\r\n begin\r\n NodeL_:=NodeL;\r\n NodeR_:=NodeR;\r\n if L<>L_ then\r\n begin\r\n LevelRange(Level+1, L, (L_+Step-1), Res);\r\n inc(NodeL_);\r\n end;\r\n\r\n if R<>R_ then\r\n begin\r\n LevelRange(Level+1, (R_-Step+1), R, Res);\r\n dec(NodeR_);\r\n end;\r\n\r\n for i:=NodeL_ to NodeR_ do\r\n begin\r\n NodeOp(Level, i, Res);\r\n inc(OpCnt);\r\n if Echo then\r\n WriteLn(Prefix, '+', Step);\r\n end;\r\n end;\r\n end;\r\n\r\n end;\r\n\r\n\r\n function TValTree.Range(L, R: integer): int64;\r\n var\r\n i: integer;\r\n Res: int64;\r\n begin\r\n OpCnt:=0;\r\n Result:=Value(L);\r\n LevelRange(0, L, R, Result);\r\n\r\n if false then\r\n if Test then\r\n begin\r\n Res:=Value(L);\r\n for i:=L to R do\r\n if Sgn*Value(i)>Sgn*Res then\r\n Res:=Value(i);\r\n if Result<>Res then\r\n Writeln('ERROR');\r\n end;\r\n \r\n inc(OpCntTot, OpCnt);\r\n end;\r\n\r\nprocedure TValTree.Init(Src: TInt64Dynarray);\r\n var\r\n Count, Count2: integer;\r\n IdxH, j, i: integer;\r\n begin\r\n Count2:=1;\r\n LevelH:=0;\r\n Count:=Length(Src);\r\n while Count2 1*3 + 2*3 + 1*2\r\n// ����� ��������v� ��\r\n\r\nfunction PairCombCount(List: TInt64DynArray; Count: integer): int64;\r\n var\r\n i: integer;\r\n S, C: int64;\r\n begin\r\n Result:=0;\r\n if Count>=2 then\r\n begin\r\n S:=List[0];\r\n\r\n for i:=1 to Count-1 do\r\n begin\r\n C:=S*List[i];\r\n S:=S+List[i];\r\n\r\n inc(Result, C);\r\n end;{}\r\n end;\r\n end;\r\n\r\n//==============================================================================\r\n\r\nfunction CombCount(N, K: integer): int64;\r\n var\r\n i: integer;\r\n S, C: int64;\r\n Nom, Den: int64;\r\n begin\r\n // N!/(k! * (N-K)!\r\n Result:=1;\r\n if N>1 then\r\n begin\r\n\r\n Nom:=1;\r\n Den:=1;\r\n for i:=1 to K do\r\n begin\r\n Nom:=Nom*(N+1-i);\r\n Den:=Den*i;\r\n end;\r\n Result:=Nom div Den;\r\n end;\r\n end;\r\n\r\n//==============================================================================\r\n// CombCount\r\n(*function deg(i64 x, i64 d): int\r\n begin\r\n d %= P - 1;\r\n if (d < 0) d += P - 1;\r\n i64 y = 1;\r\n while (d) {\r\n if (d & 1) (y *= x) %= P;\r\n d /= 2;\r\n (x *= x) %= P;\r\n }\r\n return y;\r\n}\r\n\r\ni64 cnk(int n, int k) {\r\n if (k < 0 || k > n) return 0;\r\n i64 num = 1, den = 1;\r\n forn(i, k) {\r\n (num *= n - i) %= P;\r\n (den *= i + 1) %= P;\r\n }\r\n return num * deg(den, -1) % P;\r\n}\r\n*)\r\n\r\n//==============================================================================\r\n\r\nfunction GetIdxSortedDir(A: TInt64DynArray; AVal: int64; Dir: integer;\r\n var Idx0_, Idx1_: integer): integer;\r\n var\r\n// Idx0, Idx1: integer;\r\n N: integer;\r\n\r\n L, M, R: integer;\r\n Pass: integer;\r\n begin\r\n N:=Length(A);\r\n\r\n\r\n L:=-1;\r\n R:=N;\r\n Pass:=0;\r\n\r\n repeat\r\n M:=(L+R+Pass) div 2;\r\n\r\n Pass:=1-Pass;\r\n if A[M]=AVal then\r\n R:=M;\r\n end;\r\n\r\n if Dir>0 then\r\n begin // AVal\r\n //\r\n if A[M]>AVal then\r\n R:=M;\r\n\r\n if A[M]<=AVal then\r\n L:=M;\r\n end;\r\n\r\n until (R-L<=1);\r\n Idx0_:=L;\r\n Idx1_:=R;\r\n end;\r\n\r\nfunction GetIdxSorted(A: TInt64DynArray; AVal: int64; var Idx0, Idx1: integer): integer;\r\n var\r\n IdxL0, IdxL1: integer;\r\n IdxR0, IdxR1: integer;\r\n begin\r\n GetIdxSortedDir(A, AVal, -1, IdxL0, IdxL1);\r\n GetIdxSortedDir(A, AVal, +1, IdxR0, IdxR1);\r\n\r\n Idx0:=IdxL0;\r\n Idx1:=IdxR1;\r\n end;\r\n\r\n// GetIdxSorted(A, 4, Idx0, Idx1);\r\n//------------------------------------------------------------------------------\r\n\r\n//==============================================================================\r\n\r\n\r\nfunction Fact(N: integer): int64;\r\n var\r\n i: integer;\r\n begin\r\n Result:=1;\r\n for i:=2 to N do\r\n Result:=Result*i;\r\n end;\r\n\r\n//==============================================================================\r\n\r\nconst\r\n ConstMod=1000000007;\r\nvar\r\n FullTest: boolean;\r\n\r\n PassCnt: int64=0;\r\n Suffix: string;\r\n OpCnt: int64=0;\r\n\r\ntype\r\n TRes=int64;\r\n\r\nconst\r\n ResDefault: TRes=0;\r\n\r\ntype\r\n TDomArray=array [0..1] of int64;\r\n\r\n TTask=object // todo: #0 TTask\r\n Pass: integer;\r\n Sim: boolean;\r\n N: int64;\r\n\r\n// X0, X1: TInt64DynArray;\r\n //Order: TInt64DynArray;\r\n //S: string;\r\n\r\n procedure Gen;\r\n procedure GenHack;\r\n procedure Read;\r\n procedure Prepare;\r\n function SolveSmart: TRes;\r\n function SolveDumb: TRes;\r\n function Solve: TRes;\r\n end;\r\n\r\nvar\r\n Task: TTask;\r\n\r\n\r\n//==============================================================================\r\n\r\nprocedure SubTask(ti: integer); forward;\r\n\r\nprocedure Main;\r\n var\r\n i: integer;\r\n t: int64;\r\n\r\n begin // todo -c: #1 Main\r\n Task.Pass:=0;\r\n// SubTask(-1); exit;\r\n//------------------------------------------------------------------------------\r\n\r\n i:=-1;\r\n Read_Ln(t);\r\n\r\n Task.Prepare;\r\n\r\n\r\n for i:=0 to t-1 do\r\n begin\r\n Task.Pass:=i;\r\n SubTask(i);\r\n end;\r\n\r\n if Test then\r\n Stop;\r\n end; // Main\r\n\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nprocedure TTask.Prepare;\r\n const\r\n Sample: array [0..5] of string=\r\n ('abc', 'acb', 'bac', 'cab', 'bca', 'cba');\r\n var\r\n i, j: integer;\r\n\r\n begin // todo -c: #2 Prepare\r\n\r\n Stop;\r\n end; // Prepare\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nprocedure TTask.Read;\r\n var\r\n i, j: integer;\r\n S_: string;\r\n begin // todo -c: #3 Read\r\n Sim:=false;\r\n// Sim:=true and Test;\r\n\r\n if not Sim then\r\n begin\r\n Read_Ln([@N]);\r\n //Read_Ln([@N, @K, @X]);\r\n// Read_Ln([@K]);\r\n// Read_Ln(S);\r\n\r\n { for i:=0 to 3 do\r\n begin\r\n Read_(K[i]);\r\n SetLength(XY[i], K[i]);\r\n Read_Ln(XY[i]);\r\n end;{}\r\n\r\n { for i:=0 to N-1 do\r\n begin\r\n// Read_Ln(S[i]);\r\n\r\n //Read_Ln([@X[i], @Y[i]]);\r\n end;{}\r\n end\r\n else\r\n begin\r\n randomize;\r\n randseed:=57967349;\r\n //N:=2*100*1000;\r\n WriteLn(Randseed);\r\n// N:=20;\r\n// Q:=30;\r\n// Q:=2*1000;\r\n //Q:=100*1000;\r\n //SetLength(A, N);\r\n //SetLength(B, N);\r\n {for i:=0 to N-1 do\r\n begin\r\n //A[i]:=random(5);\r\n //B[i]:=random(5);\r\n end;{}\r\n\r\n end;\r\n\r\n\r\n// SetLength(K, N);\r\n// SetLength(A, N);\r\n\r\n{ for i:=0 to N-1 do\r\n begin\r\n Read_(K[i]);\r\n\r\n SetLength(A[i], K[i]);\r\n\r\n// Read_Ln([@L[i], @R[i]]);\r\n Read_Ln(A[i]);\r\n end;{}\r\n\r\n// Read_Ln(A);\r\n end; // Read\r\n\r\n//------------------------------------------------------------------------------\r\n\r\nprocedure TTask.GenHack;\r\n begin\r\n// N:=200*1000;\r\n// N:=1000;\r\n// SetLength(A, N);\r\n\r\n if Hack then\r\n begin\r\n WriteLn(1);\r\n// WriteLn(N);\r\n end;\r\n\r\n if Hack then\r\n Stop;\r\n end;\r\n\r\n\r\nprocedure TTask.Gen;\r\n var\r\n Hi: int64;\r\n i: integer;\r\n begin\r\n GenHack;\r\n Exit;\r\n\r\n OpCnt:=0;\r\n Hi:=200*1000;\r\n// Hi:=4;\r\n// N:=2+random(Hi);\r\n// SetLength(A, N);\r\n\r\n if Hack then\r\n begin\r\n WriteLn(1);\r\n// WriteLn(N);\r\n end;\r\n// for i:=0 to N-1 do\r\n begin\r\n// A[i]:=1+random(min(1000*1000*1000, hi*hi div 2));\r\n if Hack then\r\n// if ii then\r\n Stop;\r\n end;\r\n *)\r\n\r\nfunction TTask.SolveDumb: TRes;\r\n var\r\n i, j: integer;\r\n// N: integer;\r\n i2, i3: int64;\r\n i2_: int64;\r\n begin // todo -c: #5 SolveDumb\r\n// inc(PassCnt);\r\n Result:=ResDefault;\r\n if PassCnt=5 then\r\n Stop;\r\n\r\n i:=1;\r\n repeat\r\n i2:=sqr(i);\r\n i3:=i2*i;\r\n if i2<=N then\r\n inc(result)\r\n else\r\n break;\r\n\r\n if i3<=N then\r\n begin\r\n i2_:=round(sqrt(1.*i3));\r\n if sqr(i2_)<>i3 then\r\n inc(result);\r\n end;\r\n inc(i); \r\n until false;\r\n\r\n\r\n{ if Result=0 then\r\n WriteLn('YES')\r\n else\r\n WriteLn('NO');{}\r\n// QuickSort(PInt64Array(@XY[i][0]), PInt64Array(nil), 0, K[i]-1, 0);\r\n\r\n// SetLength(C, N);\r\n\r\n\r\n WriteLn(Result);\r\n\r\n Stop;\r\n end; // SolveDumb\r\n\r\n//==============================================================================\r\n\r\nfunction TTask.SolveSmart: TRes;\r\n var\r\n i: integer;\r\n begin // todo -c: SolveSmart\r\n Result:=ResDefault;\r\n Stop;\r\n end; // SolveSmart\r\n\r\n//==============================================================================\r\n\r\nfunction TTask.Solve: TRes;\r\n var\r\n ResSmart, ResDumb: TRes;\r\n i, j: integer;\r\n begin // todo -c: Solve\r\n OpCnt:=0;\r\n\r\n// Mod_:=31607;\r\n\r\n// Result:=0;\r\n ResSmart:=ResDefault;\r\n ResDumb:=ResDefault;\r\n\r\n\r\n// ResSmart:=SolveSmart;\r\n ResDumb:=SolveDumb;\r\n\r\n if Check then\r\n begin\r\n ResDumb:=SolveDumb;\r\n if ResSmart<>ResDumb then\r\n begin\r\n WriteLn(format('Error %9d <> %9d', [ResSmart, ResDumb]));\r\n Stop;\r\n end;\r\n end;\r\n\r\n// Result:=ResSmart;\r\n Result:=ResDumb;\r\n end; // Solve\r\n\r\n//==============================================================================\r\n\r\nprocedure SubTask(ti: integer);\r\n var\r\n Res: TRes;\r\n itr: integer;\r\n i: integer;\r\n Pass: integer;\r\n time0, time1, WorkTime: double;\r\n RandSeed0: integer;\r\n\r\n begin\r\n inc(PassCnt);\r\n\r\n if Test then\r\n if FullTest then\r\n begin\r\n Pass:=0;\r\n repeat\r\n inc(Pass);\r\n RandSeed0:=RandSeed;\r\n Write(format('Pass: %8d RS $%0.8x', [Pass, RandSeed0]));\r\n WriteLn('');\r\n\r\n Task.Gen;\r\n\r\n time0:=now;\r\n\r\n{ for Itr:=1 to 1 do\r\n Res:=Task.Solve;{}\r\n for Itr:=0 to 20 do\r\n begin\r\n //Task.N:=int64(1000)*1000*1000*1000*1000*10+Itr;\r\n// Task.N:=Itr;\r\n Res:=Task.Solve;\r\n// WriteLn(format('%5d %5d', [Task.N, Res]));\r\n end;\r\n\r\n time1:=now;\r\n WorkTime:=SecsPerDay*(time1-time0);\r\n// if WorkTime>0.1 then\r\n WriteLn(format(' Res: %9d OP: %8d Time: %5.2f',\r\n [Res, OpCnt, WorkTime]));\r\n\r\n\r\n Stop;\r\n\r\n until false;{}\r\n end;\r\n\r\n Task.Read;\r\n\r\n\r\n Res:=Task.Solve;\r\n\r\n if Test then Suffix:=format(' %d', [OpCnt])\r\n else Suffix:='';\r\n // todo -c: #8 SubTask\r\n\r\n// WriteLn(format('%d', [Res]));//, Suffix)\r\n// WriteLn(Res);\r\n// WriteLn(Length(IntToStr(Res)));\r\n// WriteLn(Res);\r\n{ if (Res+1)<=Task.k then\r\n WriteLn('Yes')\r\n else\r\n WriteLn('No');{}\r\n\r\n end; // SubTask\r\n\r\n//------------------------------------------------------------------------------\r\n\r\n\r\nbegin\r\nrandseed:=126;\r\n//randseed:=$3B8B1C67;\r\n\r\nTest:=Home; // ================\r\n//Check:=Home;\r\n//FullTest:=Test;\r\n//Hack:=true;\r\n//Echo:=Home;\r\n\r\n\r\nif Hack then\r\n begin\r\n Task.GenHack;\r\n\r\n //Task.Gen;\r\n Stop;\r\n exit;\r\n end;\r\n\r\nif Test then\r\n begin\r\n ReadPrepare('Task_B_0.txt');\r\n end;\r\n\r\nMain;\r\n\r\n\r\nif Test then\r\n ReadLn;\r\n\r\n\r\nend.\r\n"}, {"source_code": " const eps=1e-10;\r\n besk=4000000000000000000; label 33,55,5,4,1,3,2,44,22;\r\n type\r\n mas=array[-500000..1570460+1] of int64;\r\n integer=longint; zap=record p1,p2,p3:int64; end;\r\n zap1=^zap;\r\n var kol,kolzikl,start,px,py,posx,posy,cur,init,res,oldpos,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\r\n sss:array[-1..1000000] of string;\r\n ch1,ch2:char;\r\n ssans,ss1,ss4,oldss,smin,ss3,ss,ss2:string;\r\n newaans,aans:zap;\r\n otr1,otr0,d0,vx,vy,ddist,tttt:extended;\r\n pqqq:zap;\r\n gam,al0,otal,al1,al2,acc, disk,prop,bet,al:extended; fl1,fl2,fl:boolean;\r\n dr3,dr1,dr2,pt,ott1,ott2:zap;\r\n\r\n i3,p,tt,sum,pp1,pp2,root,oldans,par,dlkruga,topt,t1,t2,t3,ot,aa,bb,cc,dist,znak,rr,kolmax,kkol,pos,pq,razm,poss,mm,tip,ppos1,oldtt,ps,pos1,pos2,pred,color,buk:int64;\r\n time,zz,x:array[-1000..1110000] of int64;\r\n stroka,sss1,sss2:array[-10..610000] of string;\r\n v3,v1,v2,pointx,pointy,vel,tt0,radius,ote,dl1,dl2:extended;\r\n ddl,dnewr,dnewl,dr,ddpos:array[-10..210,-20..150,0..9] of int64;\r\n xold,yold,xxold,yyold,xmin,xmax,ymin,ymax,xx,str,zx,zy,z,xxx,yyy,invfact,y,ansx,ansy,ugol,yy:array[-1000000..2110000] of int64;\r\n ll,ost,shag,napr,dl,ppos,ii,jj,t,ptek,dloch1,oldaa,oldbb,zapas,ott,mnog,ttt,delta,tt1,tt2,koll,newt,osn,oldot,num,oldt,znmax,t11,t01,t10,t00,opld,nap,t4,iii,jjj,aaa,bbb,ccc,p0,newpos,newdl,len,pp3,ans1,ans2,modul,t0,dloch,koldel,mmax,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,kool,number,imin,qq,n,m,numpos,down,imax,qq1,qq2,q1,q2,w,p3,p4,pmax,pmax2,p1,p2,pos0,pp,maxot,tmax,nn,n1,q:int64; flag1:boolean;\r\n olda,b,c,a,zzz,fact,stan,a2,invx,invy,place,b2,sum1,sum0,d:mas; flag2,flag:boolean; pl:longint;\r\n dx,dy,gor,ver,i2,j2,ans,sdvig,izb, oldmax,newmax,posmax,razn,ppp,minx,miny,maxx,maxy,jmax,gr,grr,ener,dob,ugg,r,ug:int64;\r\n polezan:array[-1..1000,-1..1000] of boolean;\r\n zan1,zan2,prost,zan:array[-1000..2001001] of boolean;\r\n newzan,zann:array[-1000000..4000000] of boolean;\r\n zanx,marked:array[-1000000..4100000] of boolean;\r\n zikl,dlzikl,sumdl,z1,z2,x1,y1,x2,y2,ddnew,d3,d1,right,dmin,dd1,left,dnomer:array[-1111..1100000] of int64;\r\n nomer,ochh,newochh:array[-1000..4000000] of longint;\r\n newx,newy,dplus,dminus,och1,b1,a1,first,last,kolnenul,next1,next0,prev1,prev0,newoch,och,lx,a3,b3,predok:array[-20000..1610000] of int64;\r\n ddsum,ddd:array[-400..565200,-1..10] of int64;\r\n pole,newpole:array[-100..600,-100..600] of char;\r\n ddold,dd,polessum:array[-100..1300,-100..1300] of int64;\r\n\r\n ssan,bufer:array[-1000..1000000] of char;\r\n cosa,sina,cosb,sinb,rx,ry,h1,h2,h,l1,l2,otmax,v:int64;\r\n obmen,ch:char;\r\n stepen,mat:array[-10..1050001,0..4] of longint;\r\n flagg,fflag,ok,flagg1:boolean;\r\n koled,oldx,oldy,numx,numy,xleft,xright,s,newplace,newstr,next,prev,aold:array[-1000..1200002] of int64;\r\n\r\n function srav(i,j:longint):boolean;\r\n var k,tt:longint;\r\n begin\r\n if (a[i]=l+k) or (j>=m+k)) then flag:=false;\r\n end;\r\n if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j]; b3[l+step]:=a3[j];\r\n inc(step);inc(j);until (j>=m+k);\r\n if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i]; b3[l+step]:=a3[i];inc(step);inc(i);until (i>=l+k);\r\n end;\r\n\r\n procedure sort(var c:mas);\r\n begin\r\n k:=1; repeat\r\n l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\r\n for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i];a3[i]:=b3[i]; end;\r\n until (k>=n);\r\n end;\r\n\r\n function min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\r\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\r\n tt:zap; tt1:zap1; fl:boolean;\r\n begin\r\n fl:=false;\r\n if a0 do\r\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\r\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\r\n end;\r\n if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else\r\n begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\r\n evkl:=tt1;\r\n end;\r\n function phi(a,b:double):double; label 222;var p:double;\r\n begin\r\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\r\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\r\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\r\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\r\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\r\n 222: phi:=p;\r\n end;\r\n\r\n function nod(a,b:int64):int64; var p,t:int64;\r\n begin\r\n a:=abs(a); b:=abs(b);\r\n if (a>0)and(b>0) then\r\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\r\n p:=a;\r\n end else if a=0 then p:=b else p:=a;\r\n nod:=p;\r\n end;\r\n\r\n function arccos(tt:extended):extended;\r\n begin\r\n if abs(tt)>1-1e-13 then\r\n if tt>0 then arccos:=0 else arccos:=pi;\r\n if tt=0 then arccos:=pi/2 else\r\n if abs(tt)<=1-1e-13 then if tt>=0 then arccos:=arctan(sqrt(1-tt*tt)/tt)\r\n else arccos:=pi+arctan(sqrt(1-tt*tt)/tt);\r\n end;\r\n\r\n function degg(a,k,modul:int64):int64; var p:int64; label 4;\r\n begin\r\n if k<=0 then degg:=1\r\n else if odd(k) then degg:=(degg(a,k-1,modul)*a) mod modul else\r\n begin p:=degg(a,k div 2,modul); degg:=(p*p) mod modul; end;\r\n end;\r\n\r\n function zaprmax(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmax:=y[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\r\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n function zaprmin(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmin:=z[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),z[left]);\r\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),z[right]);\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\nfunction zaprsum(left,right:longint):int64;\r\n begin\r\n if left>=right then if left=right then zaprsum:=y[left] else zaprsum:=0 else\r\n begin\r\n if not odd(left) and odd(right) then zaprsum:=zaprsum(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprsum:=zaprsum(left+1,right)+y[left];\r\n if not odd(right) then zaprsum:=zaprsum(left,right-1)+y[right];\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n procedure udal(ii:longint);\r\n begin next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii]; end;\r\n\r\n\r\n\r\n\r\n function pprost(pp:int64):boolean;\r\n var i,j,t:longint; tt:extended; fl:boolean;\r\n begin\r\n tt:=pp;\r\n tt:=sqrt(tt);\r\n fl:=true;\r\n for i:=2 to round(tt) do if pp mod i=0 then fl:=false;\r\n pprost:=fl;\r\n end;\r\n\r\n function gl(c:char):boolean;\r\n begin\r\n if (c='a')or (c='o')or(c='e')or(c='i')or(c='u') then gl:=true else gl:=false;\r\n end;\r\n { function slog(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.y+d1.y*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n slog:=@ans;\r\n end;\r\n\r\n function umn(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n umn:=@ans;\r\n end;\r\n\r\n function sravfr(d1,d2:zap):boolean;\r\n begin\r\n if d1.x*d2.y=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=fact[jj];\r\n p3:=fact[ii-jj];\r\n t2:=degg(p2,modul-2,modul);\r\n t3:=degg(p3,modul-2,modul);\r\n ot:=((p1*t2) mod modul*t3) mod modul;\r\n bincoef:=ot;\r\n end else bincoef:=0;\r\n end;\r\n\r\n { function bincoef1(ii,jj:longint):int64;\r\n var t1,t2,t3,p1,p2,p3,ot:int64;\r\n begin\r\n if ii>=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=invfact[jj];\r\n p3:=invfact[ii-jj];\r\n ot:=((p1*p2) mod modul*p3) mod modul;\r\n bincoef1:=ot;\r\n end else bincoef1:=0;\r\n end;\r\n }\r\n\r\n\r\n\r\n begin\r\n\r\n { assign (input,'D:\\Projects\\input.txt');reset(input);\r\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\r\n }\r\n p:=0;\r\n for i:=1 to 40000 do begin inc(p); a[p]:=i*i; end;\r\n for i:=1 to 1100 do begin inc(p); a[p]:=i*i*i; end;\r\n n:=1;\r\n repeat n:=n*2 until n>p;\r\n for i:=p+1 to n do a[i]:=besk;\r\n sort(a);\r\n tt:=0; a[0]:=-besk;\r\n for i:=1 to p do if a[i]<>a[i-1] then begin inc(tt); x[tt]:=a[i]; end;\r\n\r\n readln(qq);\r\n for stepp:=1 to qq do\r\n begin\r\n readln(p);\r\n ot:=0;\r\n for i:=1 to tt do if x[i]<=p then inc(ot);\r\n\r\n\r\n writeln(ot);\r\n end;\r\n\r\n 1: close (output);\r\n\r\n end.\r\n\r\n\r\n"}, {"source_code": "var a:array[1..10000000] of int64;\r\n\r\nfunction sort(l,r:longint):longint;\r\nvar nl,nr,med,x:longint;\r\nbegin\r\n nl:=l;\r\n nr:=r;\r\n med:=a[(l+r) div 2];\r\n while nl<=nr do\r\n begin\r\n while a[nl]med do\r\n nr:=nr-1;\r\n if nl<=nr then\r\n begin\r\n x:=a[nl];\r\n a[nl]:=a[nr];\r\n a[nr]:=x;\r\n nl:=nl+1;\r\n nr:=nr-1\r\n end\r\n end;\r\n if nll then\r\n sort(l,nr)\r\nend;\r\n\r\n\r\nvar n,compr,x,sol,dura:int64;\r\n i,q,j,t:longint;\r\n// dt:text;\r\nBegin\r\n\r\n// assign(dt,'dura13.txt');\r\n// rewrite(dt);\r\n readln(t);\r\n for j:=1 to t do\r\n begin\r\n readln(n);\r\n x:=round(sqrt(n));\r\n if x*x>n then x:=x-1;\r\n if (x+1)*(x+1)<=n then x:=x+1;\r\n// writeln(x);\r\n i:=1;\r\n for q:=1 to x do\r\n begin\r\n if q*q<=n then\r\n begin\r\n a[i]:=q*q;\r\n//write(dt,q*q,'(',i,'(',2,')',') ');\r\n i:=i+1\r\n end;\r\n if q*q<=n/q then\r\n begin\r\n a[i]:=q*q*q;\r\n// dura:=i;\r\n//write(dt,q*q*q,'(',i,'(',3,')',') ');\r\n i:=i+1\r\n end;\r\n end;\r\n i:=i-1;\r\n sort(1,i);\r\n\r\n\r\n sol:=1;\r\n compr:=a[1];\r\n for q:=1 to i do\r\n if a[q]<>compr then\r\n begin\r\n sol:=sol+1;\r\n compr:=a[q]\r\n end;\r\n\r\n writeln(sol)\r\n end;\r\n// close(dt)\r\nEnd.\r\n"}, {"source_code": "const nmax = 1000007 ;\r\nvar a , f : array[0..1000007] of longint ;\r\n i , n , j , t , d , ans : longint ;\r\n o : boolean ;\r\n s : ansistring ;\r\n\r\nfunction scp(x:int64):boolean;\r\nvar t : longint;\r\nbegin\r\n t := trunc(sqrt(x));\r\n if sqr(t) = x then exit(true)\r\n else exit(false);\r\nend;\r\nbegin\r\n\r\n readln(t) ;\r\n while ( t > 0 ) do\r\n begin\r\n readln(n) ;\r\n if n = 1 then writeln(1)\r\n else\r\n begin\r\n ans :=0;\r\n d := 0 ;\r\n ans := ans + trunc(sqrt(n));\r\n i := 2 ;\r\n while ( i * i * i ) <= n do\r\n begin\r\n if scp(i*i*i) = true then i := i + 1\r\n else\r\n begin\r\n d := d + 1;\r\n i := i + 1;\r\n end;\r\n end;\r\n writeln(ans+d);\r\n end;\r\n dec(t);\r\n\r\n end;\r\nend.\r\n// trunc(sqrt(n)) la so luong so cp\r\n//\r\n"}, {"source_code": "var a,n,t,i,k : longint;\r\n r : array[1..20] of longint;\r\n b : real;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do begin\r\n readln(n); a:=1; r[i]:=0;\r\n while((a*a)<=n) do begin inc(a); inc(r[i]); end; a:=1;\r\n while((a*a*a)<=n) do begin b:=SQRT(a*a*a); if (Frac(b)<>0) then inc(r[i]); inc(a); end;\r\n end;\r\n for i:=1 to t do writeln(r[i]);\r\nend.\r\n"}, {"source_code": "program new;\r\nvar a,b,c ,d,i,k,l:int64;\r\nbegin\r\n read(a);\r\n for i:=1 to a do begin\r\n read(b);\r\n c:=trunc(power(b,1/3)+0.00000000001);\r\n d:=trunc(power(b,1/2)+0.00000000001);\r\n k:=trunc(power(b,1/6)+0.00000000001);\r\n writeln(c+d-k);\r\n \r\n end;\r\nend."}], "negative_code": [{"source_code": "var a:array[1..100000] of longint;\r\n\r\nfunction sort(l,r:longint):longint;\r\nvar nl,nr,med,x:longint;\r\nbegin\r\n nl:=l;\r\n nr:=r;\r\n med:=a[(l+r) div 2];\r\n while nl<=nr do\r\n begin\r\n while a[nl]med do\r\n nr:=nr-1;\r\n if nl<=nr then\r\n begin\r\n x:=a[nl];\r\n a[nl]:=a[nr];\r\n a[nr]:=x;\r\n nl:=nl+1;\r\n nr:=nr-1\r\n end\r\n end;\r\n if nll then\r\n sort(l,nr)\r\nend;\r\n\r\nvar n,i,q,compr,x,sol:longint;\r\nBegin\r\n readln(n);\r\n x:=round(sqrt(n));\r\n if x*x>n then x:=x-1;\r\n if (x+1)*(x+1)<=n then x:=x+1;\r\n i:=1;\r\n for q:=1 to x do\r\n begin\r\n a[i]:=q*q; i:=i+1;\r\n if q*q*q<=n then\r\n begin\r\n a[i]:=q*q*q;\r\n i:=i+1\r\n end;\r\n end;\r\n i:=i-1;\r\n\r\n sort(1,i);\r\n\r\n sol:=1;\r\n compr:=a[1];\r\n for q:=1 to i do\r\n if a[q]<>compr then\r\n begin\r\n sol:=sol+1;\r\n compr:=a[q]\r\n end;\r\n\r\n writeln(sol)\r\nEnd."}, {"source_code": "const nmax = 1000007 ;\r\nvar a , f : array[0..1000007] of longint ;\r\n i , n , j , t , d , ans : longint ;\r\n o : boolean ;\r\n s : ansistring ;\r\nbegin\r\n\r\n readln(t) ;\r\n while ( t > 0 ) do\r\n begin\r\n readln(n) ;\r\n if n = 1 then writeln(1)\r\n else\r\n begin\r\n ans :=0;\r\n d := 0 ;\r\n ans := ans + trunc(sqrt(n));\r\n i := 2 ;\r\n while ( i * i * i ) <= n do\r\n begin\r\n d := d + 1 ;\r\n i := i + 1 ;\r\n end;\r\n writeln(ans+d);\r\n end;\r\n dec(t);\r\n\r\n end;\r\nend.\r\n// trunc(sqrt(n)) la so luong so cp\r\n//\r\n"}, {"source_code": "var a,n,t,i,k : longint;\r\n r : array[1..20] of longint;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do begin\r\n readln(n); a:=1; r[i]:=0;\r\n while((a*a)<=n) do begin inc(a); inc(r[i]); end; a:=1;\r\n while((a*a*a)<=n) do begin inc(a); inc(r[i]); end; dec(r[i]);\r\n end;\r\n for i:=1 to t do writeln(r[i]);\r\nend.\r\n"}, {"source_code": "program new;\r\nvar a,b,c ,d,i,k,l:int64;\r\nbegin\r\n read(a);\r\n for i:=1 to a do begin\r\n read(b);\r\n c:=trunc(power(a,1/3)+0.00000000001);\r\n d:=trunc(power(a,1/2)+0.00000000001);\r\n k:=trunc(power(a,1/6)+0.00000000001);\r\n writeln(c+d-k);\r\n end;\r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,o,f,g,h:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n h:=a;\r\n o:=exp((1/3)*ln(a));\r\n f:=sqrt(a);\r\n b :=trunc(power(a,1/3));\r\n c:=trunc(power(a,1/2));\r\n d:=trunc(power(a,1/6));\r\ng:=b+c-d;\r\nif(round(power(a,1/3)*power(a,1/3)*power(a,1/3))=a)and(b>3)then\r\n writeln(g+1) else\r\n writeln(g);\r\n end;\r\n \r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,o,f,g,h:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n h:=a;\r\n o:=exp((1/3)*ln(a));\r\n f:=sqrt(a);\r\n b :=trunc(power(a,1/3));\r\n c:=trunc(power(a,1/2));\r\n d:=trunc(power(a,1/6));\r\ng:=b+c-d;\r\nif(round(power(a,1/3)*power(a,1/3)*power(a,1/3))=a)and(b>3)then\r\n writeln(g+1) else\r\n writeln(g);\r\n end;\r\n writeln(power(a,1/3));\r\n \r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,o,f,g,h:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n h:=a;\r\n o:=exp((1/3)*ln(a));\r\n f:=sqrt(a);\r\n b :=trunc(power(a,1/3));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(power(a,1/6));\r\ng:=b+c-d;\r\nif(1000000000=a)then\r\n writeln('32591')else\r\n writeln(g);\r\n end;\r\n \r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,o,f,g,h:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n h:=a;\r\n o:=exp((1/3)*ln(a));\r\n f:=sqrt(a);\r\n b :=trunc(power(a,1/3));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(power(a,1/6));\r\ng:=b+c-d;\r\n\r\n writeln(g)\r\n end;\r\n \r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,o,f,g,h:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n h:=a;\r\n o:=exp((1/3)*ln(a));\r\n f:=sqrt(a);\r\n b :=trunc(exp((1/3)*ln(a)));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(exp((1/6)*ln(a)));\r\ng:=b+c-d;\r\n\r\n if(a=1)then\r\n writeln('1')\r\n else if(trunc(exp((1/3)*ln(a+1)))*trunc(exp((1/3)*ln(a+1)))*trunc(exp((1/3)*ln(a+1)))=a)then\r\n writeln(g+1)\r\n else writeln(g);\r\n end;\r\n \r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n \r\n \r\n b := trunc(exp((1/3)*ln(a)));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(exp((1/6)*ln(a)));\r\n \r\n writeln(b+c-d);\r\n end;\r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e,j:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n j:=sqrt(a);\r\n \r\n b := round(exp((1/3)*ln(a)));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(exp((1/6)*ln(a)));\r\n if(j<>c)then\r\n writeln(b+c-d)\r\n else writeln(b+c-d-1)\r\n end;\r\nend."}, {"source_code": "program hlkjnjhbghgty;\r\nvar a,i,b,c,k,l:int64;d,e:real;\r\nbegin\r\nreadln(k);\r\nfor l:=1 to k do begin\r\n \r\n read(a);\r\n \r\n \r\n b := round(exp((1/3)*ln(a)));\r\n c:=trunc(sqrt(a));\r\n d:=trunc(exp((1/6)*ln(a)));\r\n \r\n writeln(b+c-d-1);\r\n end;\r\nend."}], "src_uid": "015afbefe1514a0e18fcb9286c7b6624"} {"source_code": "var a,b,c,k,n:integer;\nbegin\n a:=2; b:=5; c:=8;\n readln(n,k);\n a:=a*n; b:=b*n; c:=c*n;\n if (a mod k) = 0 then a:=a div k\n else a:=(a div k)+1;\n if (b mod k) = 0 then b:=b div k\n else b:=(b div k)+1;\n if (c mod k) = 0 then c:=c div k\n else c:=(c div k)+1;\n writeln(a+b+c);\nend.", "positive_code": [{"source_code": "var\nk,n,i,r,j,x:int64;\na:array [1..100] of int64;\nbegin\n read(n,k);\n r:=r+n*2 div k;if n*2 mod k<>0 then r:=r+1;\n r:=r+n*5 div k;if n*5 mod k<>0 then r:=r+1;\n r:=r+n*8 div k;if n*8 mod k<>0 then r:=r+1;\n write(r);\nend."}, {"source_code": "var a,b,k,z,s: integer;\nbegin\nread(a,b);\nk:=(2*a) div b;\nif (2*a) mod b<> 0 then\nk:=k+1;\nz:=(5*a) div b;\nif (5*a) mod b<> 0 then\nz:=z+1;\ns:=(8*a) div b;\nif (8*a) mod b<> 0 then\ns:=s+1;\nwrite(k+z+s);\n\n\nend.\n"}, {"source_code": "var a,b,k,z,s: integer;\nbegin\nread(a,b);\nk:=(2*a) div b;\nif (2*a) mod b<> 0 then\nk:=k+1;\nz:=(5*a) div b;\nif (5*a) mod b<> 0 then\nz:=z+1;\ns:=(8*a) div b;\nif (8*a) mod b<> 0 then\ns:=s+1;\nwrite(k+z+s);\n\n\nend.\n"}, {"source_code": "var\n\tn, k, x, y: integer;\n\t\nbegin\n\t\n\treadln(n, k);\n\tx := 0;\n\ty := n * 2;\n\tif (y mod k <> 0) then x += (y div k + 1)\n\telse x += (y div k);\n\t\n\ty := n * 5;\n\tif (y mod k <> 0) then x += (y div k + 1)\n\telse x += (y div k);\n\t\n\ty := n * 8;\n\tif (y mod k <> 0) then x += (y div k + 1)\n\telse x += (y div k);\n\t\n\twriteln(x);\n\t\nend.\n"}, {"source_code": "var\na,b,c,d,e,i,j,fl:int64;\narr:array [1..1000] of int64;\nbegin\nreadln (a,b);\nc:=a*2;\nd:=a*5;\ne:=a*8;\nif (c mod b=0) then c:=c div b\nelse\nc:=c div b+1;\nif (d mod b=0) then d:=d div b\nelse\nd:=d div b+1;\nif (e mod b=0) then e:=e div b\nelse\ne:=e div b+1;\nwriteln (c+d+e);\nend."}, {"source_code": "var n,k,kr,s,z,q:longint;\nBEGIN\nreadln(n,k);\nkr:=n*2;\nz:=n*5;\ns:=n*8;q:=0;\nif kr mod k>0 then q:=q+ (kr div k)+1\n else q:=q+ (kr div k);\nif z mod k>0 then q:=q+ (z div k)+1\n else q:=q+ (z div k);\nif s mod k>0 then q:=q+ (s div k)+1\n else q:=q+ (s div k);\nwriteln(q); \nEND."}, {"source_code": "var\n i,j,n,m,a,b,c,k:int64;\nbegin a:=2; b:=5; c:=8;\n read(n,m);\n a*=n; b*=n; c*=n;\n if a mod m=0 then j+=a div m else j+=(a div m)+1;\n if b mod m=0 then j+=b div m else j+=(b div m)+1;\n if c mod m=0 then j+=c div m else j+=(c div m)+1;\n writeln(j);\nend."}, {"source_code": "//два красного , пять зеленого и восемь синего \nvar\n d, c, i, n, a, k, b: integer;\n\n\nbegin\n a := 1;//2\n c := 1;//5\n d := 1;//8\n readln(n, k);//количество друзей Пети и количество листов в блокноте соответственно.\n \n // 2*n красных листов нужно нам\n //NadoKrasn:=2*n/k;\n \n if 2*n mod k=0 then\n b:=b+2*n div k\n else\n b:=b+(2*n div k+1);\n \n\n if 5*n mod k=0 then\n b:=b+5*n div k\n else\n b:=b+(5*n div k+1);\n\n\n if 8*n mod k=0 then\n b:=b+8*n div k\n else\n b:=b+(8*n div k+1);\n\n \n writeln(b);\n \n \n \n \n \n \nend.\n\n"}, {"source_code": "var\nn, k, f, lk, lz, ls: integer;\nbegin\n read(n, k);\n lk := (2 * n);\n lz := (5 * n);\n ls := (8 * n);\n if (lk mod k) = 0 then lk := (lk div k) else lk := (lk div k) + 1;\n if (lz mod k) = 0 then lz := (lz div k) else lz := (lz div k) + 1;\n if (ls mod k) = 0 then ls := (ls div k) else ls := (ls div k) + 1;\n writeln(lk + lz + ls);\nend."}, {"source_code": "var\nn,k,s,r,g,b:int64;\nbegin\nread(n,k);\n\nr:=2*n;\ng:=5*n;\nb:=8*n;\n\ns:=s+r div k;r:=r mod k;\ns:=s+g div k;g:=g mod k;\ns:=s+b div k;b:=b mod k;\nif r<>0 then\ninc(s);\nif g<>0 then\ninc(s);\nif b<>0 then\ninc(s);\n\nwrite(s);\n\nend."}, {"source_code": "program pr1;\nvar n,k,s,r,b,g:integer;\nbegin\nreadln(n,k);\nif n*2 mod k=0 then r:=n*2 div k\nelse r:=((n*2) div k)+1;\nif n*5 mod k=0 then g:=n*5 div k\nelse g:=((n*5) div k)+1;\nif n*8 mod k=0 then b:=n*8 div k\nelse b:=((n*8) div k)+1;\ns:=b+r+g;\nwritelN(s);\nend.\n"}, {"source_code": "var n,k,ans:integer;\nBegin\n readln(n,k);\n ans:=0;\n if(2*n mod k=0) then\n ans:=ans + n*2 div k\n else\n ans:= ans + n*2 div k+1;\n if(5*n mod k=0) then\n ans:=ans + n*5 div k\n else\n ans:= ans + n*5 div k+1;\n if(8*n mod k=0) then\n ans:=ans + n*8 div k\n else\n ans:= ans + n*8 div k+1;\n writeln(ans); \nend."}, {"source_code": "var k,n,a,s,d,u:integer;\nbegin\nread (n,k);\na:=n*2;\ns:=n*5;\nd:=n*8;\nu:=a div k+s div k+d div k;\nif (a mod k>0) then\nbegin\nu:=u+1;\nend;\nif (s mod k>0) then\nbegin\nu:=u+1;\nend;\nif (d mod k>0) then\nbegin\nu:=u+1;\nend;\nwrite (u);\nend."}, {"source_code": "var a,b,c,d,e,f,g,h,t:int64;\nbegin\nread(a,b);\nc:=a*2;\nd:=a*5;\ne:=a*8;\nif (c mod b<>0) then\nf:=c div b+1\nelse\nf:=c div b;\nif (d mod b<>0) then\ng:=d div b+1\nelse\ng:=d div b;\nif (e mod b<>0) then\nh:=e div b+1\nelse\nh:=e div b;\nt:=f+h+g;\nwrite(t);\nend."}, {"source_code": "var n,k,res:integer;\nkr,z,s:integer;\nbegin\nread (n);\nread (k);\nkr:=(2*n)div k;\nz:=(5*n) div k;\ns:=(8*n) div k;\nif (2*n) mod k>0 then inc(kr);\nif (5*n) mod k>0 then inc (z);\nif (8*n) mod k>0 then inc (s);\nres:=kr+z+s;\nwrite (res);\nend."}, {"source_code": "Var\n n, k, Ans: Integer;\n \nBegin \n Read(n, k);\n If 2*n mod k = 0 then\n Ans += 2*n div k\n Else \n Ans += 2*n div k + 1;\n If 5*n mod k = 0 then\n Ans += 5*n div k\n Else \n Ans += 5*n div k + 1;\n If 8*n mod k = 0 then\n Ans += 8*n div k\n Else \n Ans += 8*n div k + 1;\n Write(Ans)\nEnd."}, {"source_code": "program n_1;\nvar n,k: integer;\nB1,B2,B3: integer;\nkol:integer;\nbegin\nreadln (n,k);\nb1:=round (2*n/k+0.499999999);\nb2:=round (5*n/k+0.499999999);\nb3:=round (8*n/k+0.499999999);\nkol:=b1+b2+b3;\nwriteln (kol);\nend."}, {"source_code": "\nvar n,k:longint;\nbegin \nread(n,k);\nwrite((2*n+k-1)div k+(5*n+k-1)div k+(8*n+k-1)div k);\nend."}, {"source_code": "var n,a,c,b,k:Int64;\nbegin\nread(n,k);\na:=2*n;\nb:=5*n;\nc:=8*n;\nif a div k = a/k\nthen a:=a div k\nelse a:=trunc(a/k)+1;\n\nif b div k = b/k\nthen b:=b div k\nelse b:=trunc(b/k)+1;\n\nif c div k = c/k\nthen c:=c div k\nelse c:=trunc(c/k)+1;\nwrite(a+b+c);\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul=1000000007{998244353} ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..535002] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ccc,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..2400,-1..2200] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaa,bbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\nfunction zaprsum(left,right:longint):int64;\nbegin\n if left>=right then zaprsum:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprsum:=zaprsum(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprsum:=(zaprmax(left+1,right)+y[left]) mod modul;\n if not odd(right) then zaprsum:=(zaprsum(left,right-1)+y[right]) mod modul;\n\n end;\n\n end;\n\nend;\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]0)then inc(o);\nif(5*f mod s>0)then inc(o);\nif(8*f mod s>0)then inc(o);\nwrite((2*f div s+ 5*f div s +8*f div s)+o)\nend."}, {"source_code": "var\n n, k, an: uint64;\n\nbegin\n read(n, k);\n if n * 2 mod k = 0 then\n an := an + ((n * 2) div k)\n else\n an := an + ((n * 2) div k) + 1;\n if n * 5 mod k = 0 then\n an := an + ((n * 5) div k)\n else\n an := an + ((n * 5) div k) + 1;\n if n * 8 mod k = 0 then\n an := an + ((n * 8) div k)\n else\n an := an + ((n * 8) div k) + 1;\n write(an);\nend."}, {"source_code": "Program ex1;\nvar\n i,n,k,b,r,g,blok: integer;\n \nbegin\n \n readln(n,k);\n \n for i:= 1 to n do\n begin\n r:=r+2;\n g:=g+5;\n b:=b+8;\n end;\n \n if r mod k>0 then blok:=blok+1;\n if g mod k>0 then blok:=blok+1;\n if b mod k>0 then blok:=blok+1;\n \n r:=r div k;\n b:=b div k;\n g:=g div k;\n \n writeln(blok+r+b+g);\n \nend."}, {"source_code": "var n, k, i,r,g,b, rr, gg, bb: integer;\nbegin \n readln(n,k);\n r := n * 2;\n g := n * 5;\n b := n * 8;\n \n rr := r div k;\n if (r mod k <> 0) then\n rr := rr + 1;\n\n bb := b div k;\n if (b mod k <> 0) then\n bb := bb + 1;\n \n gg := g div k;\n if (g mod k <> 0) then\n gg := gg + 1;\n \n write(rr +bb + gg);\nend."}, {"source_code": "program a1;\nvar n,k,r,g,b: longint;\nBegin\nreadln(n,k);\nr:=n*2;\ng:=n*5;\nb:=n*8;\nif r mod k<>0 then\nr:=(r div k)+1\nelse r:=r div k;\nif g mod k<>0 then\ng:=(g div k)+1\nelse g:=g div k;\nif b mod k<>0 then\nb:=(b div k)+1\nelse b:=b div k;\nwriteln(r+g+b);\nEnd."}, {"source_code": "var n,k,s:integer;\nbegin\nreadln(n,k);\n s:=(n*2)div k+(n*5)div k+(n*8)div k;\n if (n*2)mod k>0 then inc(s);\n if (n*5)mod k>0 then inc(s);\n if (n*8)mod k>0 then inc(s);\n writeln(s);\nend.\n"}, {"source_code": "program prim1;\nvar n,k,c1,c2,c3:longint;\nbegin\nread(n,k);\nc1:=2*n;\nc2:=5*n;\nc3:=8*n;\nif c1 mod k <> 0 then c1:=c1 div k + 1 else c1:=c1 div k;\nif c2 mod k <> 0 then c2:=c2 div k + 1 else c2:=c2 div k;\nif c3 mod k <> 0 then c3:=c3 div k + 1 else c3:=c3 div k;\nwrite(c1+c2+c3);\nend."}, {"source_code": "var i, j, m, oj,oi,om, n, k,s: int64;\nbegin\ns:=0;\nread (n,k);\ni:=(2*n)div k;\nif (2*n)mod k>0 then\ns:=s+i+1 else s:=s+i;\n\nj:=(5*n)div k;\nif (5*n)mod k>0 then\ns:=s+j+1 else s:=s+j;\n\nm:=(8*n)div k;\nif (8*n)mod k>0 then\ns:=s+m+1 else s:=s+m;\n\nwrite (s);\nend."}, {"source_code": "var a,n,m,k,l,o,i,u,v,c,f,b,g,d,s:integer;\nbegin\nread(a,b);\nc:=a*2 div b;\nk:=a*5 div b;\nm:=a*8 div b;\nif a*2 mod b<>0 then c:=c+1;\n if a*5 mod b<>0 then k:=k+1;\n if a*8 mod b<>0 then m:=m+1;\n write(c+m+k);\n end.\n\n"}, {"source_code": "var a,b,c,n,k,l:int64;\nbegin\nRead(n,k);\nl:=n*2;\na:=l div k;\nif (a >= 1) and (l mod k <> 0) then\na:=a+1;\nif a < 1 then\na:=1;\n\nl:=n*5;\nb:=l div k;\nif (b >= 1) and (l mod k <> 0) then\nb:=b+1;\nif b < 1 then\nb:=1;\n\nl:=n*8;\nc:=l div k;\nif (c >= 1) and (l mod k <> 0) then\nc:=c+1;\nif c < 1 then\nc:=1;\nWrite(a+b+c);\nend."}, {"source_code": "var n,k,l:longint;\nbegin\nread(n,k);\nl:=((2*n) div k)+(5*n div k)+(8*n div k);\nif (2*n)mod k<>0 then l:=l+1;\nif (5*n)mod k<>0 then l:=l+1;\nif (8*n)mod k<>0 then l:=l+1;\nwrite(l);\nend."}, {"source_code": "program pas;\nvar\nn, K : integer;\nbegin\nRead(n,K);\nWriteln((((2*n+K)-1)div K)+(((5*n+K)-1)div K)+(((8*n+K)-1)div K));\nend."}, {"source_code": "var n,k,b1,b2,b3,kol:integer;\nbegin\n readln(n,k);\n b1:=2*n div k;\n if 2*n mod k <> 0 then b1:=b1+1;\n b2:=5*n div k;\n if 5*n mod k <> 0 then b2:=b2+1;\n b3:=8*n div k;\n if 8*n mod k <> 0 then b3:=b3+1;\n kol:=b1+b2+b3;\n writeln(kol);\nend."}, {"source_code": "var n, k, m, rmin, gmin, bmin, rbl, gbl, bbl:integer;\nbegin\n readln(n, k);\n rmin:=n*2;\n gmin:=n*5;\n bmin:=n*8;\n rbl:=rmin div k;\n if rmin mod k <> 0 then inc(rbl);\n gbl:=gmin div k;\n if gmin mod k <> 0 then inc(gbl);\n bbl:=bmin div k;\n if bmin mod k <> 0 then inc(bbl);\n m:=rbl+gbl+bbl;\n writeln(m);\nend."}, {"source_code": "var n, k, rmin, gmin, bmin, rbl, gbl, bbl:integer;\nbegin\n readln(n, k);\n rmin:=n*2;\n gmin:=n*5;\n bmin:=n*8;\n rbl:=rmin div k;\n if rmin mod k <> 0 then inc(rbl);\n gbl:=gmin div k;\n if gmin mod k <> 0 then inc(gbl);\n bbl:=bmin div k;\n if bmin mod k <> 0 then inc(bbl);\n writeln(rbl+gbl+bbl);\nend."}, {"source_code": "var p,r,s,k,n:integer;\nbegin\nreadln(n,k);\ns:=n*2 div k; if n*2 mod k<>0 then s:=s+1;\np:=n*5 div k; if n*5 mod k<>0 then p:=p+1;\nr:=n*8 div k; if n*8 mod k<>0 then r:=r+1;\nwrite(s+p+r);\nend."}, {"source_code": "var n,k,ans:integer;\nbegin\nreadln(n,k);\n\ninc(ans,n*2 div k);\nif (n*2 mod k > 0) then\n inc(ans);\ninc(ans,n*5 div k);\nif (n*5 mod k > 0) then\n inc(ans);\ninc(ans,n*8 div k);\nif (n*8 mod k > 0) then\n inc(ans);\nwriteln(ans);\nend."}, {"source_code": "var n,k,kq:int64;\nbegin\n readln(n,k);\n if 2*n mod k = 0 then inc(kq,2*n div k)\n else inc(kq,2*n div k + 1);\n if 5*n mod k = 0 then inc(kq,5*n div k)\n else inc(kq,5*n div k + 1);\n if 8*n mod k = 0 then inc(kq,8*n div k)\n else inc(kq,8*n div k + 1);\n writeln(kq);\n readln;\nend."}, {"source_code": "Program PetyaandOrigami;\nvar n,k:longint;\nProcedure Notebooks;\nvar n1,n2,n3:longint;\nbegin n1:=2*n div k; n2:=5*n div k; n3:=8*n div k;\n if 2*n mod k<>0 then inc(n1);\n if 5*n mod k<>0 then inc(n2);\n if 8*n mod k<>0 then inc(n3);\n writeln(n1+n2+n3);\nend;\nbegin //assign(input,'1080A.inp'); reset(input);\n //assign(output,'1080A.out'); rewrite(output);\n readln(n,k);\n Notebooks;\n //close(input); close(output);\nend."}, {"source_code": "VAR A,B,C,K,n: int64;\nbegin\n reAD(N,k);\n a:=n*2 div k;if n*2 mod k>0 then b:=b+a+1 else b:=b+a;\n a:=n*5 div k;if n*5 mod k>0 then b:=b+a+1 else b:=b+a; \n a:=n*8 div k;if n*8 mod k>0 then b:=b+a+1 else b:=b+a;\n write(b);\n end."}, {"source_code": "const\n fi='';//'cf1080a.inp';\n fo='';//'cf1080a.out';\nvar\n sr,sg,sb,n,k:int64;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(n,k);\n sr:=((n*2) div k)+ord((n*2) mod k<>0);\n sg:=((n*5) div k)+ord((n*5) mod k<>0);\n sb:=((n*8) div k)+ord((n*8) mod k<>0);\n writeln(sr+sg+sb);\n close(input);\n close(output);\nend."}, {"source_code": "var\n n,kol,r1,r2,r3,m,x:longint;\nbegin\nread(n,kol);\nr1:=n*2;\nr2:=n*5;\nr3:=n*8;\nx:=r1 div kol;\ninc(m,x);\nif r1 mod kol<>0\nthen inc(m);\nx:=r2 div kol;\ninc(m,x);\nif r2 mod kol<>0\nthen inc(m);\nx:=r3 div kol;\ninc(m,x);\nif r3 mod kol<>0\nthen inc(m);\nwriteln(m);\nend."}, {"source_code": "var\n a, kol, c1, c2, c3, b, x: longint;\n\nbegin\n readln(a, kol);\n c1 := a * 2;\n c2 := a * 5;\n c3 := a * 8;\n x := c3 div kol;\n b := b + x;\n if c3 mod kol <> 0 then inc(b);\n x := c2 div kol;\n b := b + x;\n if c2 mod kol <> 0 then inc(b);\n x := c1 div kol;\n b := b + x;\n if c1 mod kol <> 0 then inc(b);\n writeln(b);\nend."}, {"source_code": "var\n s,n,m:longint;\nbegin\n read(n,m);\n if (2*n) mod m=0 then s:=s+(2*n) div m\n else s:=s+(2*n) div m+1;\n if (5*n) mod m=0 then s:=s+(5*n) div m\n else s:=s+(5*n) div m+1;\n if (8*n) mod m=0 then s:=s+(8*n) div m\n else s:=s+(8*n) div m+1;\nwrite(s);\nend."}, {"source_code": "var f : text;\nn,k,dem : int64;\nbegin\n readln(n,k);\n if (n*2) mod k <> 0 then inc(dem);\n if (n*5) mod k <> 0 then inc(dem);\n if (n*8) mod k <> 0 then inc(dem);\n writeln(dem+((n*2) div k)+((n*5) div k) + ((n*8) div k));\nend."}, {"source_code": "var\ns,w:string;\n q:string;\npo,Y,n,d,i,max,ser, p,nom,o,k,z,x,c:longint;\nbegin\nreadln(n,K);\nz:=round(n*2 div k);\nif n*2 mod k <>0 then z:=z+1;\nx:=round(n*5 div k);\nif n*5 mod k <>0 then x:=x+1;\nc:=round(n*8 div k);\nif n*8 mod k <>0 then c:=c+1;\nWRITELN(z+x+c);\nend.\n"}, {"source_code": "var\n n,k,s,x,y,z:longint;\nbegin\n readln(n,k); \n x:=2*n; y:=5*n; z:=8*n;\n if x mod k=0 then s:=x div k\n else s:=x div k+1;\n if y mod k=0 then s:=s+y div k\n else s:=s+y div k+1;\n if z mod k=0 then s:=s+z div k\n else s:=s+z div k+1;\n writeln(s);\nend."}, {"source_code": "{CF1080A}\nvar\nn,k:longint;\nbegin\nread(n,k);\nwriteln((n*2-1) div k+(n*5-1) div k+(n*8-1) div k+3);\nend."}, {"source_code": "var\nn,k:longint;\nbegin\nread(n,k);\nwriteln((n*2-1) div k+(n*5-1) div k+(n*8-1) div k+3);\nend.\n"}, {"source_code": "var\n n, k, r, g, b : longint;\n\nbegin\n readln(n, k);\n r := 2 * n; g := 5 * n; b := 8 * n;\n writeln((r + k - 1) div k + (g + k - 1) div k + (b + k - 1) div k);\nend."}, {"source_code": "var c,p,max,h,l,l1,e,o,k,w,n,a,s,r : longint;\nb : array[1..1000] of integer;\nbegin\n \n\treadln(n,k);\n\t\n\ta:=2*n;\n\tp:=5*n;\n\tr:=8*n;\n\t\n\ts:=(a div k)+(p div k)+(r div k);\n\t\n\tif a mod k<>0 then \n\ts:=s+1;\n\tif p mod k<>0 then \n\ts:=s+1;\n\tif r mod k<>0 then \n\ts:=s+1;\n\twriteln(s);\nend.\n"}, {"source_code": "var\n n,m,i,i2,p,z:integer;\n r,g,b:real;\n a:array [1..100] of integer;\nBegin\n read(n);readln(m);\n r:=n*2/m;\n g:=n*5/m;\n b:=n*8/m;\n \n if r <> trunc(r) then r:=trunc(r)+1;\n if g <> trunc(g) then g:=trunc(g)+1;\n if b <> trunc(b) then b:=trunc(b)+1;\n \n write(round(r+g+b));\n \nend."}, {"source_code": "program test;\nvar n, k, c: integer;\nbegin\nreadln(n, k);\nc:=c + ((2 * n) div k);\nif ((2 * n) mod k) > 0 then c:=c + 1;\nc:=c + ((5 * n) div k);\nif ((5 * n) mod k) > 0 then c:=c + 1;\nc:=c + ((8 * n) div k);\nif ((8 * n) mod k) > 0 then c:=c + 1;\nwriteln(c);\nend."}, {"source_code": "program ex1;\nvar n,k,r,g,b,res:longint;\nbegin\nread(n,k);\nr:= 2*n;\ng:= 5*n;\nb:= 8*n;\nif (r mod k>0) then res:= res+(r div k)+1 else res:= res+(r div k);\nif (g mod k>0) then res:= res+(g div k)+1 else res:= res+(g div k);\nif (b mod k>0) then res:= res+(b div k)+1 else res:= res+(b div k);\nwriteln(res);\nend."}, {"source_code": "var n, r, g, b, k: longint;\n\nBEGIN\n read (n, k);\n r:= 2*n;\n g:= 5*n;\n b:= 8*n;\n if r mod k <> 0 then r:= r div k +1\n else r:= r div k;\n if g mod k <> 0 then g:= g div k +1\n else g:= g div k;\n if b mod k <> 0 then b:= b div k +1\n else b:= b div k;\n writeln (r+g+b);\nEND."}, {"source_code": "var n,k,redneed,greenneed,blueneed:int64;\nbegin\n readln(n,k);\n redneed:=n*2;\n if (redneed mod k)<>0 then redneed:=(redneed div k)+1 \n else redneed:=redneed div k; \n greenneed:=n*5;\n if (greenneed mod k)<>0 then greenneed:=(greenneed div k)+1\n else greenneed:=greenneed div k;\n blueneed:=n*8;\n if (blueneed mod k)<>0 then blueneed:=(blueneed div k)+1\n else blueneed:=blueneed div k;\n write(redneed+greenneed+blueneed);\nend.\n\n"}, {"source_code": "var n,k,count:int64;\nbegin\n readln(n,k);\n count:=(n*2-1)div k+1;\n count:=count+ (n*5-1)div k+1;\n count:=count+ (n*8-1)div k+1;\n writeln(count);\nend."}, {"source_code": "var n,k:longint;\nred,blue,green:longint;\nn1,n2,n3:longint;\nbegin\n read(n,k);\n red:=n*2;\n green:=n*5;\n blue:=n*8;\n\n if red mod k<>0 then\n begin\n n1:=red div k+1;\n end\n else\n begin\n n1:=red div k;\n end;\n\n if green mod k<>0 then\n begin\n n2:=green div k+1;\n end\n else\n begin\n n2:=green div k;\n end;\n\n if blue mod k<>0 then\n begin\n n3:=blue div k+1;\n end\n else\n begin\n n3:=blue div k;\n end;\n\n writeln(n1+n2+n3);\nreadln();\nend.\n"}, {"source_code": "var\n n,kol,r1,r2,r3,m,x:longint;\nbegin\nread(n,kol);\nr1:=n*2;\nr2:=n*5;\nr3:=n*8;\nx:=r1 div kol;\ninc(m,x);\nif r1 mod kol<>0\nthen inc(m);\nx:=r2 div kol;\ninc(m,x);\nif r2 mod kol<>0\nthen inc(m);\nx:=r3 div kol;\ninc(m,x);\nif r3 mod kol<>0\nthen inc(m);\nwriteln(m);\nend.\n\n"}, {"source_code": "\nvar n,k,m,kr,z,s:integer;\nbegin\n readln(n,k);\n kr:=2*n;\n z:=5*n;\n s:=8*n;\n if kr mod k = 0 then\n kr:=kr div k\n else\n kr:=(kr div k) + 1;\n if z mod k = 0 then\n z:=z div k\n else\n z:=(z div k) + 1;\n if s mod k = 0 then\n s:=s div k\n else\n s:=(s div k) + 1;\n m:=kr+s+z;\n writeln(m);\nend."}, {"source_code": "Program A542;\nVar n,k,a,b,c,d,e,f:longint;\n\nBEGIN\n readln(n,k);\n a := 2 * n; b := 5 * n; c := 8 * n;\n\n if a mod k = 0 then d := a div k else d := a div k + 1;\n if b mod k = 0 then e := b div k else e := b div k + 1;\n if c mod k = 0 then f := c div k else f := c div k + 1;\n\n writeln(d + e + f);\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,k:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,x,t1,t2,t3:longint;\n res:int64;\n begin\n read(fi,n,k);\n t1:=2*n div k;\n t2:=5*n div k;\n t3:=8*n div k;\n if (2*n mod k)<>0 then inc(t1);\n if (5*n mod k)<>0 then inc(t2);\n if (8*n mod k)<>0 then inc(t3);\n writeln(fo,t1+t2+t3);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "Program NKUB1;\n Var\n r, g, b, s, k, n: longint;\n Begin\n Readln(n, k);\n if (2 * n) mod k <> 0 then r := (2 * n) div k + 1\n else r := (2 * n) div k;\n if (5 * n) mod k <> 0 then g := (5 * n) div k + 1\n else g := (5 * n) div k;\n if (8 * n) mod k <> 0 then b := (8 * n) div k + 1\n else b := (8 * n) div k;\n s := r + g + b;\n Writeln(s);\n Readln;\n End."}, {"source_code": "\nconst\n Bool: array [FALSE..TRUE] of LongInt = (0, 1);\n\nvar\n n, k, r, g, b, s: LongInt;\n\nbegin\n ReadLn (n, k);\n\n r := 2;\n g := 5;\n b := 8;\n\n s := (n * r) div k + Bool[(n * r) mod k <> 0];\n s := s + (n * g) div k + Bool[(n * g) mod k <> 0];\n s := s + (n * b) div k + Bool[(n * b) mod k <> 0];\n\n WriteLn (s);\nend."}, {"source_code": "const fi='';\n fo='';\nVar a,b,c,n,kq,k: longint;\n f,g: text;\nBegin\n Assign(f,fi);\n Assign(g,fo);\n Reset(f);\n Rewrite(g);\n Readln(f,n,k);\n a:=n*2;\n b:=n*5;\n c:=n*8;\n kq:= a div k + b div k + c div k;\n If a mod k <>0 then\n inc(kq);\n If b mod k <>0 then\n inc(kq);\n If c mod k <>0 then\n inc(kq);\n Writeln(g,kq);\n Close(f);\n Close(g);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var n , k , r , g , b : Longint;\n kq : Int64;\nBegin\nReadln(n , k);\nIf n * 2 mod k = 0 then r := n * 2 div k else r := n * 2 div k + 1;\nIf n * 5 mod k = 0 then g := n * 5 div k else g := n * 5 div k + 1;\nIf n * 8 mod k = 0 then b := n * 8 div k else b := n * 8 div k + 1;\nkq := r + g + b;\nWriteln(kq);\nEnd."}, {"source_code": "var\n n,k,x,y,z,ans:longint;\nbegin\n readln(n,k); \n x:=2*n;y:=5*n;z:=8*n;\n if x mod k=0 then ans:=x div k\n else ans:=x div k+1;\n if y mod k=0 then ans:=ans+y div k\n else ans:=ans+y div k+1;\n if z mod k=0 then ans:=ans+z div k\n else ans:=ans+z div k+1;\n writeln(ans);\nend."}], "negative_code": [{"source_code": "var\n n,list,kol,r1,r2,r3,r4,sum,m:longint;\nbegin\nread(n,kol);\nr1:=n*2;\nr2:=n*5;\nr3:=n*8;\nr4:=r1+r2+r3;\nwhile sum<=r4 do\n begin\n inc(sum,kol);\n inc(m);\n end;\nwriteln(m);\nend."}, {"source_code": "var\n d, c, i, n, a, k, b: integer;\n\n\nbegin\n a := 1;\n c := 1;\n d := 1;\n readln(n, k);\n \n repeat\n if k * a >= 2 * n then//12 и 4\n begin\n b := b + a;\n break;\n end\n \n else\n a := a + 1;//2\n \n until 0 = 1;\n \n\n \n repeat\n if k * c >= 2 * n then//12 и 4\n begin\n b := b + c;\n break;\n end\n \n else\n c := c + 1;//2\n \n until 0 = 1;\n \n\n \n repeat\n if k * d >= 2 * n then//12 и 4\n begin\n b := b + d;\n break;\n end\n \n else\n d := d + 1;//2\n \n until 0 = 1;\n \n writeln(b);\n \n \n \n \n \n \nend.\n\n"}, {"source_code": "program pr1;\nvar n,k,s,r,b,g:integer;\nbegin\nreadln(n,k);\nif n*2 mod k=0 then r:=n*2 div k\nelse r:=((n*2) div k)+1;\nif n*5 mod k=0 then g:=n*5 div k\nelse g:=((n*5) div k)+1;\nif n*8 mod k=0 then b:=k*8 div k\nelse b:=((n*8) div k)+1;\ns:=b+r+g;\nwritelN(s);\nend.\n"}, {"source_code": "program pr1;\nvar \ni,k,g,n,a,b,c:integer;\nbegin\nread(n,g);\na:=n*2;\nb:=n*5;\nc:=n*8;k:=0;\nfor i:=1 to 1000000 do begin\nif a>0 then begin a:=a-g;k:=k+1;end;\nif b>0 then begin b:=b-g;k:=k+1;end;\nif c>0 then begin c:=c-g;k:=k+1;end;\nend;\nwriteln(k);\nend."}, {"source_code": "program pr1;\nvar \ni,k,g,n,a,b,c:integer;\nbegin\nread(n,g);\na:=n*2;\nb:=n*5;\nc:=n*8;k:=0;\nfor i:=1 to n*g do begin\nif a>0 then begin a:=a-g;k:=k+1;end;\nif b>0 then begin b:=b-g;k:=k+1;end;\nif c>0 then begin c:=c-g;k:=k+1;end;\nend;\nwriteln(k);\nend."}, {"source_code": "program pr1;\nvar \ni,k,g,n,a,b,c:integer;\nbegin\nread(n,g);\na:=n*2;\nb:=n*5;\nc:=n*8;k:=0;\nwhile c>0 do begin\nif a>0 then begin a:=a-g;k:=k+1;end;\nif b>0 then begin b:=b-g;k:=k+1;end;\nc:=c-g;k:=k+1;\nwritelN(c);\nend;\nwriteln(k);\nend."}, {"source_code": "program n_1;\nvar n,k: integer;\nB1,B2,B3: integer;\nkol:integer;\nbegin\nreadln (n,k);\nb1:=round (2*n/k);\nb2:=round (5*n/k);\nb3:=round (8*n/k);\nkol:=b1+b2+b3;\nwriteln (kol+1);\nend."}, {"source_code": "program n_1;\nvar n,k: integer;\nB1,B2,B3: integer;\nkol:integer;\nbegin\nreadln (n,k);\nb1:=round (2*n/k+0.4999999999);\nb2:=round (5*n/k+0.4999999999);\nb3:=round (8*n/k+0.4999999999);\nkol:=b1+b2+b3;\nwriteln (kol);\nend."}, {"source_code": "program n_1;\nvar n,k: integer;\nB1,B2,B3: integer;\nkol:integer;\nbegin\nreadln (n,k);\nb1:=round (2*n/k);\nb2:=round (5*n/k);\nb3:=round (8*n/k);\nkol:=b1+b2+b3;\nwriteln (kol);\nend."}, {"source_code": "program a1;\nvar n,k : longint;\nr,g,b: shortint;\nBegin\nreadln(n,k);\nr:=n*2;\ng:=n*5;\nb:=n*8;\nif r mod k<>0 then\nr:=(r div k)+1\nelse r:=r div k;\nif g mod k<>0 then\ng:=(g div k)+1\nelse g:=g div k;\nif b mod k<>0 then\nb:=(b div k)+1\nelse b:=b div k;\nwriteln(r+g+b);\nEnd."}, {"source_code": "program a1;\nvar n,k : longint;\nr,g,b: shortint;\nBegin\nreadln(n,k);\nr:=n*2;\ng:=n*5;\nb:=n*8;\nif r mod k<>0 then\nr:=(r mod k)+1\nelse r:=r div k;\nif g mod k<>0 then\ng:=(g mod k)+1\nelse g:=g div k;\nif b mod k<>0 then\nb:=(b mod k)+1\nelse b:=b div k;\nwriteln(r+g+b);\nEnd."}, {"source_code": "var a,b,c:integer;\nbegin \nreadln (a,b);\nwriteln (10);\nend."}, {"source_code": "var n,k,b1,b2,b3,kol:integer;\nbegin\n readln(n,k);\n b1:=round(2*n/k+0.49999999999);\n b2:=round(5*n/k+0.49999999999);\n b3:=round(8*n/k+0.49999999999);\n kol:=b1+b2+b3;\n writeln(kol);\nend."}, {"source_code": "var n,k,b1,b2,b3,kol:integer;\nbegin\n readln(n,k);\n b1:=round(2*n/k+0.499999999999);\n b2:=round(5*n/k+0.499999999999);\n b3:=round(8*n/k+0.499999999999);\n kol:=b1+b2+b3;\n writeln(kol);\nend."}, {"source_code": "var n,k,b1,b2,b3,kol:int64;\nbegin\n readln(n,k);\n b1:=round(2*n/k+0.49999999999);\n b2:=round(5*n/k+0.49999999999);\n b3:=round(8*n/k+0.49999999999);\n kol:=b1+b2+b3;\n writeln(kol);\nend."}, {"source_code": "var n, k, m, rmin, gmin, bmin, rbl, gbl, bbl:integer;\nbegin\n readln(n, k);\n rmin:=n*2;\n gmin:=n*5;\n bmin:=n*8;\n rbl:=rmin div k;\n if rmin mod k <> 0 then inc(rbl);\n writeln(rbl);\n gbl:=gmin div k;\n if gmin mod k <> 0 then inc(gbl);\n writeln(gbl);\n bbl:=bmin div k;\n if bmin mod k <> 0 then inc(bbl);\n writeln(bbl);\n m:=rbl+gbl+bbl;\n writeln(m);\nend."}], "src_uid": "d259a3a5c38af34b2a15d61157cc0a39"} {"source_code": "Const\n tfi='';\n tfo='';\nVar\n n:longint;\n fi,fo:text;\nPRocedure Data;\nBegin\n Assign(fi,tfi);reset(fi);\n Assign(fo,tfo);rewrite(fo);\n readln(fi,n);\nENd;\nProcedure Solve;\nvar tuan,du,min,max:longint;\nBegin\n tuan:= n div 7; du :=n mod 7;\n If du>1 then max:=tuan*2+2\n else max:=tuan*2+du;\n If du<6 then min:=tuan*2\n else min:=tuan*2+du-5;\n writeln(fo,min,' ',max);\n Close(fi);Close(fo);\nENd;\nBegin\n data;\n solve;\nEnd.\n", "positive_code": [{"source_code": "var n,a:longint;\nbegin\n readln(n);\n a:=n div 7;\n if n mod 7<2 then\n begin\n writeln(2*a,' ',2*a+n mod 7);\n halt;\n end;\n if (n mod 7>=2) and (n mod 7<>6) then\n begin\n writeln(2*a,' ',2*a+2);\n halt;\n end;\n if (n mod 7=6) then\n begin\n writeln(2*a+1,' ',2*a+2);\n halt;\n end;\nend.\n "}, {"source_code": "var n:longint;\nbegin\n read(n);\n if n mod 7 = 0 then\n write(n div 7 * 2,' ', n div 7 * 2);\n if n mod 7 =1 then\n write(n div 7*2,' ', n div 7*2 +1);\n if n mod 7 = 2 then\n write(n div 7*2,' ', n div 7*2 +2);\n if n mod 7 = 6 then\n write(n div 7*2 + 1,' ', n div 7 * 2 + 2);\n if (n mod 7 > 2) and (n mod 7 <6) then\n write(n div 7*2,' ', n div 7 *2+2);\nend.\n\n\n "}, {"source_code": "Program qq;\nVar mn,mx,b,n:LongInt;\nFunction Min(x,y:LongInt):LongInt;\nbegin\n If x5\n then Inc(mn,7-n mod 7);\nWrite(mn,' ',mx);\nend."}, {"source_code": " var n,s,d:longint;\nbegin\n readln(n);\n s:=n div 7;\n d:=n mod 7;\n if d=1 then write(s*2,' ',s*2+1);\n if (d>=2) and (d<6) then write(s*2,' ',s*2+2);\n if d=6 then write(s*2+1,' ',s*2+2);\n if d=0 then write(s*2,' ',s*2);\nend.\n"}, {"source_code": "uses math;\nvar c,n,k,i,j,l,f,flag,max1,min1:longint;\n ans:int64;\n a:array[1..100000] of longint;\n q,p:real;\n s:string;\nbegin\nread(n); l:=2;\nmax1:=(n div 7)*2;\nmin1:=max1;\nif n mod 7=6 then inc(min1);\ninc(max1,min(l,n mod 7));\nwrite(min1,' ',max1);\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,ansmin,ansmax,cur:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\n\nfor i:=0 to n-1 do\n begin\n if (i mod 7=5) or (i mod 7=6) then inc(ansmin);\n if i>=1 then if ((i-2) mod 7=5) or ((i-2) mod 7=6) then inc(ansmax);\n end;\n\nif n=1 then ansmax:=ansmax+1 else ansmax:=ansmax+2;\n\nwriteln(ansmin,' ',ansmax);\nend.\n"}, {"source_code": "var\n n, min, max: LongInt;\n \nbegin\n Read (n);\n \n if n = 1 then\n WriteLn (0, ' ', 1)\n else\n begin\n max:= 2 * (n div 7);\n min:= max;\n \n if n mod 7 >= 2 then\n Inc (max, 2)\n else if n mod 7 = 1 then\n Inc (max);\n \n if n mod 7 = 6 then \n Inc (min);\n \n WriteLn (min, ' ', max)\n end\nend."}, {"source_code": "var\nn,max,min,NUM:integer;\nBegin\nread(n);\nmax:=(n div 7)*2;\nif n mod 7=1 then max:=max+1;\nNUM:=n mod 7;\nmin:=(n div 7)*2;\nif n mod 7=6 then min:=min+1;\ncase NUM of\n0:writeln(min,' ',max);\n1:writeln(min,' ',max);\n2..6:writeln(min,' ',max+2);\nend;\nend.\n"}, {"source_code": "var n,mi,ma,a,b,c:integer;\nbegin\nreadln(n);\na:=n div 7; b:=a*2;\nmi:=b; ma:=b;\nc:=n mod 7;\nif (c>0) then if c=1 then ma:=ma+1 else if (c<=5) then ma:=ma+2 else if c=6 then begin mi:=mi+1; ma:=ma+2; end;\nwrite(mi,' ',ma);\nend."}, {"source_code": "uses Math;\nvar b,a,c:longint;\nBegin\n readln(a);\n b:=(a div 7)*2;\n b:=b+max(0,(a mod 7)-5);\n c:=(a div 7)*2;\n c:=c+min(a mod 7,2);\n writeln(b,' ',c);\nend."}, {"source_code": "var n,v:integer;\nbegin\n read(n);\n v:=n div 7*2;\n n:=n mod 7;\n if n<3 then write(v,' ',v+n)\n else\n if n<6 then write(v,' ',v+2)\n else write(v+1,' ',v+2)\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n d,n,kmin,i,kmax:integer;\nbegin\n readln(n);\n kmin:=0;\n kmax:=0;\n d:=1;\n for i:=1 to n do begin\n if((d=6)or(d=7))then inc(kmin);\n inc(d);\n if(d=8)then d:=1;\n end;\n d:=6;\n for i:=1 to n do begin\n if((d=6)or(d=7))then inc(kmax);\n inc(d);\n if(d=8)then d:=1;\n end;\n writeln(kmin,' ',kmax);\nend.\n "}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if n mod 7 = 0\n then begin writeln(2*(n div 7),' ',2*(n div 7)); exit; end\n else\n if (n mod 7 = 6)\n then\n write(2*(n div 7)+1,' ')\n else\n write (2*(n div 7),' ');\n if n mod 7 > 1\n then writeln(2*(n div 7)+2)\n else writeln(2*(n div 7)+1)\n\n//(2*(n div 7))+(n mod 7)\nend.\n"}, {"source_code": "var n,min,max,a,b:integer;\nbegin\nread(n);\na:=n div 7;\nb:=n mod 7;\nmin:=a*2;\nmax:=a*2;\nif b>5 then min:=a*2+1;\nif (b>0) and (b<6) then \nmin:=a*2;\nif b=1 then \nmax:=a*2+1;\nif b>1 then \nmax:=a*2+2;\nwrite(min,' ',max);\nend."}, {"source_code": "Var n,k,y:longint;\n Begin\n read(n);\n if n mod 7=6 then y:=1;\n if n mod 7=1 then k:=1;\n if n mod 7>1 then k:=2;\n writeln(y+((n div 7)*2),' ',k+((n div 7)*2));\n End."}, {"source_code": "var\n a,b,i,n,k,j:int64;\nbegin\n read(n);\n if n mod 7=0 then begin writeln((n div 7)*2,' ' ,(n div 7)*2);halt;end;\n if n=1 then begin writeln(0,' ',1);halt;end;\n if n<=5 then begin writeln(0,' ',2);halt;end;\n if n=6 then begin writeln(1,' ',2);halt;end;\n if n mod 7=6 then begin writeln((n div 7)*2+1,' ',(n div 7)*2+2);halt;end;\n if (n mod 7>=2) and (n mod 7<6) then begin writeln((n div 7)*2,' ',(n div 7)*2+2);halt;end;\n if (n mod 7<2) then begin writeln((n div 7)*2,' ',(n div 7)*2+1);halt;end;\nend. "}, {"source_code": "var a, i, b, j, min, max, c : longint;\nbegin\n readln(a);\n min := a;\n max := 0;\n for j := 1 to 7 do\n begin\n b := j;\n c := 0;\n for i := 1 to a do\n begin\n if (b = 6) or (b = 7) then\n inc(c);\n inc(b);\n if b = 8 then\n b := 1;\n end;\n if max < c then\n max := c;\n if min > c then\n min := c;\n end; \n writeln(min, ' ', max);\nend.\n "}, {"source_code": "uses math;\nvar mi,ma,m,n,k:longint;\n\nbegin\nreadln(n);\nm:=n div 7;k:=n mod 7;\nma:=min(2,k);\nif k>5 then mi:=k-5;\nwriteln(mi+m*2,' ',ma+m*2);\nend."}, {"source_code": "var n,ans,ans2:longint;\n\nbegin\n\treadln(n);\n\tans:=n div 7*2;ans2:=ans;\n\tn:=n mod 7;\n\tif n>=6 then inc(ans);\n\twrite(ans,' ');\n\tif n>=2 then inc(ans2,2) else inc(ans2,n);\n\twriteln(ans2);\nend ."}, {"source_code": "var n:longint;\nbegin\nreadln(n);\nif n mod 7=0 then begin write(2*(n div 7),' ',2*(n div 7)); exit; end;\nif n mod 7=1 then write((n div 7)*2,' ',2*(n div 7)+1);\nif (n mod 7>1)and(n mod 7<6) then write((n div 7)*2,' ',2*(n div 7)+2);\nif n mod 7=6 then write((n div 7)*2+1,' ',2*(n div 7)+2);\nend.\n"}, {"source_code": "var n,k,d:longint;\nbegin\nreadln(n);\nk:=(n div 7)*2;\nif n mod 7 = 6 then write(k+1,' ')\nelse write(k,' ');\nif n mod 7 = 1 then write(k+1)\nelse if n mod 7 >=2 then write(k+2)\nelse write(k);\nend.\n\n"}, {"source_code": "var n,min,max,k,i,j,x:longint;\nbegin\n readln(n);\n min:=9545454;\n max:=0;\n for i:=1 to 7 do\n begin\n k:=0;\n for j:=1 to n do\n begin \n x:=(i+j-1)mod 7;\n if (x=0) or(x=6)then k:=k+1;\n end;\n if kmax then max:=k;\n end;\n writeln(min,' ',max);\nend. "}, {"source_code": "uses math;\nvar n:int64;\nbegin\n readln(n);\n writeln(n div 7*2 + (n mod 7+1) div 7,' ',n div 7*2 +min(n mod 7,2))\nend."}, {"source_code": "var\nx,y,z:integer;\nbegin\n\treadln(x);\n\ty:=(x div 7)*2;\n\tif (x mod 7 = 6)then y:=y+1;\n\tif x=1 then z:=1 else begin\n\t\tz:=2;\n\t\tx:=x-2;\n\t\tz:=z+(x div 7)*2;\n\t\tif (x mod 7 = 6)then z:=z+1;\n\tend;\n\twriteln(y,' ',z);\nend."}, {"source_code": "var n,a:longint;\nbegin\n readln(n);\n a:=n div 7;\n if n mod 7<2 then\n begin\n writeln(2*a,' ',2*a+n mod 7);\n halt;\n end;\n if (n mod 7>=2) and (n mod 7<>6) then\n begin\n writeln(2*a,' ',2*a+2);\n halt;\n end;\n if (n mod 7=6) then\n begin\n writeln(2*a+1,' ',2*a+2);\n halt;\n end;\nend."}, {"source_code": "var n,min,max,a,b:integer;\nbegin\nread(n);\na:=n div 7;\nb:=n mod 7;\nmin:=a*2;\nmax:=a*2;\nif b>5 then min:=a*2+1;\nif (b>0) and (b<6) then min:=a*2;\nif b=1 then max:=a*2+1;\nif b>1 then max:=a*2+2;\nwrite(min,' ',max);\nend."}, {"source_code": "uses math;\nvar n,w,o:longint;\nbegin\n readln(n);\n w:=n div 7;\n o:=n mod 7;\n write(2*w+ord(o=6),' ',2*w+min(2,o));\n readln;\nend."}, {"source_code": "var\n n,x,y:integer;\nbegin\n readln(n);\n x:=n div 7;\n y:=n mod 7;\n if y=6 then\n write(x*2+1,' ')\n else\n write(x*2,' ');\n if y=1 then\n write(x*2+1)\n else if y<>0 then\n write(x*2+2)\n else\n write(x*2);\nend.\n\n"}, {"source_code": "var n:longint;\nt1,t2:integer;\nbegin\n read(n);\n t1:=(n mod 7) div 5;\n if t1<=0 then t1:=0 else t1:=(n mod 7)-(t1*5);\n t2:=0;\n if n mod 7=1 then t2:=1 else\n if n mod 7>=2 then t2:=2;\n write((n div 7)*2+t1,' ',(n div 7)*2+t2);\nend."}, {"source_code": "var i,n,max,min:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n if ( (i mod 7) = 1 ) then inc(max);\n if ( (i mod 7) = 2 ) then inc(max);\n end;\n for i:=1 to n do\n begin\n if ( (i mod 7) = 6 ) then inc(min);\n if ( (i mod 7) = 0 ) then inc(min);\n end;\n writeln(min,' ',max);\nend."}, {"source_code": "type arr=array [1..100000] of ansistring;\nvar i,j,k,l,l1,l2,l3,t: longint;\nn,t1,t2: longint;\nflag:integer;\nprocedure Sort(var A: arr; L, R: integer);\n var i, j: integer;\n x, t: string;\n begin\n while L < R do begin\n x:= A[L];\n i:= L; j:= R;\n repeat\n while A[i] < x do inc(i);\n while x < A[j] do dec(j);\n if i <= j then begin\n t:= A[i]; A[i]:= A[j]; A[j]:= t;\n inc(i); dec(j);\n end;\n until i > j;\n if (j - L) > (R - i) then\n begin\n Sort(A, i, R);\n R:= j;\n end\n else\n begin\n Sort(A, L, j);\n L:= i;\n end;\n end; \n end; \n\nBegin\n readln(n);\n t1:=0;\n t2:=0;\n t1:=2*(n div 7);\n t2:=t1;\n if (n mod 7)=6 then t1:=t1+1;\n if (n mod 7)>=3 then t2:=t2+2\n else t2:=t2+(n mod 7);\n //t2:=t1+(n mod 7);\n writeln(t1,' ',t2);\nend."}, {"source_code": "var n,min,max:longint;\n begin\n readln(n);\n min:=2*(n div 7);\n max:=2*(n div 7);\n if n mod 7 = 6 then inc(min);\n if n mod 7 > 2 then inc(max,2)\n else max:=max+ n mod 7;\n writeln(min,' ',max); \n end."}, {"source_code": "Const Finp='';\n Fout='';\nVar n,min,max:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nProcedure Tinh;\nBegin\n min:=(n div 7)*2; max:=(n div 7)*2;\n if n mod 7>=2 then inc(max,2);\n if n mod 7=1 then inc(max);\n if n mod 7=6 then inc(min);\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,min,' ',max);\n close(f);\nEnd;\n\nBegin\n nhap;\n tinh;\n xuat;\nEnd.\n"}, {"source_code": "var\n n, s0, cmin, cmax, m: integer;\n\nbegin\n \n read(n);\n\n s0 := n div 7;\n m := n mod 7;\n if m = 0 then begin\n cmin := s0 * 2;\n cmax := cmin; \n end;\n if m = 1 then begin\n cmax := s0 * 2 + 1;\n cmin := s0 * 2;\n end;\n if (m >= 2) and (m <= 5) then begin\n cmax := s0 * 2 + 2;\n cmin := s0 * 2;\n end;\n if m = 6 then begin\n cmax := s0 * 2 + 2;\n cmin := s0 * 2 + 1;\n end;\n write(cmin, ' ', cmax);\n \nend."}, {"source_code": "Program A350;\nUSES math;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\nn, resmin, resmax: longint;\na: array[0..3000000] of longint;\n\nProcedure Process;\nVar i, j, k, tmp: longint;\nBEGIN\nreadln(fi, n);\ni := 0;\nresmin := maxlongint;\nwhile (i <= n + 10) do\n\tbegin\n\tfor j := i + 1 to i + 5 do a[j] := 0;\n\tfor j := i + 6 to i + 7 do a[j] := 1;\n\ti := i + 7;\n\tend;\nfor i := 1 to 7 do\n\tbegin\n\ttmp := 0;\n\tfor j := i to i + n - 1 do if a[j] = 1 then inc(tmp);\n\tresmin := min(resmin, tmp);\n\tresmax := max(resmax, tmp);\n\tend;\nwriteln(fo, resmin, ' ', resmax);\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND."}, {"source_code": "var i,k,n,m,l,min,max,d:longint;\n begin\n readln(n);\n max:=0;\n min:=maxlongint;\n d:=0;\n l:=0;\n k:=0;\n inc(k);\n while l<=n-1 do\n begin\n inc(l);\n if l=n then break;\n inc(d);\n d:=d mod 7;\n if (d=6) or (d=0) then inc(k);\n end;\n if k>max then max:=k;\n if kmax then max:=k;\n if kmax then max:=k;\n if kmax then max:=k;\n if kmax then max:=k;\n if kmax then max:=k;\n if kmax then max:=k;\n if k=2 then\n Write(((a div 7)*2)+2);\n Readln;\nEnd.\n"}, {"source_code": "program z2;\nvar n:longint;i,b,c,d:integer;\nbegin\nread(n);\nc:=n;\nd:=0;\nif n<=5 then\nif n>2 then begin d:=d+2;write(0,' ',d);exit;end\nelse begin d:=d+n;write(0,' ',d);exit;end;\nif n=6 then begin write(1,' ',2);exit;end;\nwhile c>=7 do begin\nc:=c-7;b:=b+2;end;\nif c=6 then inc(b);\nwhile n>=7 do begin\nn:=n-7;d:=d+2;end;\nif n>0 then\nif n>2 then d:=d+2\nelse d:=d+n;\nwrite(b,' ',d);\nend.\n\n"}, {"source_code": "var\n a,b:array[0..100]of longint;\n c,i,j,k,m,n:longint;\nbegin\n read(n);\n c:=(n div 7)*2;\n k:=n mod 7;\n if (k=6) then write(c+1,' ') else write(c,' ');\n\n\n if k>0 then\n begin\n if k>2 then write(c+2) else write(c+k);\n halt;\n end;\n write(c);\n\nend.\n\n\n\n"}, {"source_code": "program ex670a;\nvar n,max,min,a,b:integer;\nbegin\nreadln (n);\na:=n div 7;\nb:=n mod 7;\nmax:=a*2;\nif (b=1) then max:=max+1;\nif (b>1) then max:=max+2;\nmin:=a*2;\nif (b=6) then min:=min+1;\nwriteln (min,' ',max);\nend.\n"}, {"source_code": "var\n n,x,y: longint;\nbegin\n readln(n);\n x:=n div 7*2;\n y:=x;\n if n mod 7 = 1 then y:=y+1 else\n if n mod 7 > 1 then y:=y+2;\n if n mod 7 = 6 then x:=x+1;\n writeln(x,' ',y);\nend.\n"}, {"source_code": "const fi='';\n fo='';\n\nprocedure doc;\nvar i,d,n,d1:longint;\nbegin\n assign(input,fi);reset(input);\n readln(n); close(input);\n d:=0; i:=0; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d:=d+2\n else if i=n+1 then d:=d+1;\n if i<=n-2 then d1:=d1+2\n else if i=n-1 then d1:=d1+1;\n end;\n if n=1 then d1:=1;\n assign(output,fo);rewrite(output);\n writeln(d,' ',d1);close(output);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "var n, m, k,i, o, p, l, j, ans, min, max:LongInt;\n\n Begin\n Read(n);\n\n\n if (n mod 7=0) then BEgin k:=n div 7;WriteLn(k*2,' ', k*2);Halt;End;\n if (n mod 7=1) then Begin k:=n div 7;WriteLn(k*2,' ',K*2+1);HAlt;End;\n\n if (n mod 7<6) then Begin k:=n div 7;WriteLn(k*2,' ',K*2+2);HAlt;End;\n if (n mod 7=6) then BEgin k:=n div 7; WriteLn(k*2+1,' ',k*2+2);HAlt;End;\n WriteLn(min,' ', max);\n End."}, {"source_code": "var\n n,a,b,nghi:longint;\nbegin\n readln(n);\n a:=n div 7; a:=a*2;\n b:=n mod 7;\n if (b=6) then inc(a);\n if (b>=2) then b:=(n div 7)*2+2\n else b:=(n div 7)*2+b;\n writeln(a,' ',b);\nend."}, {"source_code": "program sum_delit;\nvar\n n,koln,ost,min,max:longint;\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(n);\n\n if n mod 7=0 then writeln((n div 7)*2,' ',(n div 7)*2)\n else begin\n koln:=(n div 7)*2; ost:=n mod 7;\n\n if ost=6 then min:=koln+1 else min:=koln;\n if ost=1 then max:=koln+1 else max:=koln+2;\n\n writeln(min,' ',max);\n\n end;\n\n//Close(input); Close(output);\nend.\n"}, {"source_code": "var a,b,n,min,max:longint;\nbegin\nreadln(n);\na:=n div 7;\nb:=n mod 7;\nif b<=2 then begin \n min:=a*2;\n max:=a*2+b;\n end\n else if b=6 then begin\n min:=a*2+1;\n max:=a*2+2;\n end\n else begin\n min:=a*2;\n max:=a*2+2;\n end;\nwrite(min,' ',max);\nend."}, {"source_code": "var n,a,b,s1,s2:int64;\nbegin\n readln(n);\n a:=n div 7;\n b:=n mod 7;\n s2:=a*2;\n if b>5 then write(s2+(b mod 5),' ')\n else write(s2,' ');\n\n\n if b>=2 then writeln(s2+2)\n else writeln(s2+b);\nend."}, {"source_code": "const\n fin='670A.inp';fon='670A.out';\nvar n,k:longint;\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(n);\nk:=n mod 7;\ncase k of\n 6: writeln(n div 7 * 2 + 1,' ',n div 7 * 2 + 2);\n 0: writeln(n div 7 * 2,' ',n div 7 * 2);\n 5,4,3,2: writeln(n div 7 * 2,' ',n div 7 * 2 + 2);\n 1: writeln(n div 7 * 2,' ',n div 7 * 2 + 1);\n end;\nend;\n\nbegin\n//mo;\nsolve;\nend."}, {"source_code": "var n,max,m,min:Longint;\nbegin\n read(n);m := n-5;\n min := 0;max := 0;\n while (n>0) do\n begin\n if (n>=2) then max := max + 2\n else max := max + n;\n n := n - 7;\n end;\n while (m > 0) do\n begin\n if (m>=2) then min := min + 2\n else min := min + m;\n m:=m-7;\n end;\n write(min,#32,max);\nend."}, {"source_code": "var n,min,max,n1,a:longint;\ni:integer;\nf:boolean;\nbegin\nread(n);\nfor i:= 0 to 5 do\n begin\n n1:=n-i;\n a:=2*(n1 div 7);\n if (n1 mod 7 =1) then inc(a) \n else if (n1 mod 7>=2) then inc(a,2);\n if a>max then max:=a;\n if (a=2) then inc(a,2);\n if a>max then max:=a;\n if (a2) then omax:=omax+2;\n if i<=2 then omax:=omax+i;\n if i=6 then omin:=omin+1;\n writeln(omin,' ',omax);\nend.\n "}, {"source_code": "program holidays;\nvar n,max,min:longint;\nbegin\n readln(n);\n min:=(n div 7)*2;\n if n mod 7 = 6 then inc(min);\n repeat\n if n>1 then\n begin\n inc(max,2);\n dec(n,7);\n end;\n if n=1 then\n begin\n inc(max);\n n:=0;\n end;\n until n<=0;\n write(min,' ',max);\n readln;\nend."}, {"source_code": "var\n a,s,d:integer;\nbegin\n read(a);\n d:=(a div 7)*2;\n if ((a mod 7) > 5) then\n inc (d,a mod 7 - 5);\n s:=a div 7 * 2;\n if a mod 7 = 1 then\n inc(s, 1)\n else if a mod 7 >= 2 then\n inc(s,2);\n writeln(d, ' ', s);\nend.\n\n"}, {"source_code": "var n,b,s,i,k:integer; a:array of integer;\nbegin\nread(n);\nsetlength(a,n);\nk:=1;\nb:=0;\ns:=0;\nfor i:=0 to n-1 do begin\na[i]:=k;\nk:=k+1;\nif k=8 then k:=1;\nend;\nfor i:=0 to n-1 do begin\nif (a[i]=1) or (a[i]=2) then b:=b+1;\nif (a[i]=6) or (a[i]=7) then s:=s+1;\nend;\nwrite(s,' ',b);\nend.\n"}, {"source_code": "var k,k1,k2,n:integer; \nbegin \nreadln(n); \nif n<=7 then begin \nif n=1 then writeln(0,' ',1); \nif (n>=2)and(n<=5) then writeln(0,' ',2); \nif n=6 then writeln(1,' ',2); \nif n=7 then writeln(2,' ',2); \nend \nelse begin \nif n mod 7=0 then begin k:=n div 7; writeln(k*2,' ',k*2); end \nelse begin \nk:=n-(n div 7)*7; \nk2:=(n div 7)*2; k1:=(n div 7)*2; \nif k=1 then k2:=k2+1; \nif k>=2 then k2:=k2+2; \nif k=6 then k1:=k1+1; \nwriteln(k1,' ',k2); \nend; \nend; \nend."}, {"source_code": "uses\n math;\nvar\n a,b,n:longint;\n arr:array[0..100000] of longint;\n\nbegin\n readln(n);\n a:=2*(n div 7);\n if (n mod 7)>=2 then\n a:=a+2\n else\n a:=a + (n mod 7);\n\n b:=2*(n div 7);\n if n>=7 then\n begin\n if n mod 7=6 then\n b:=b+1\n end\n else\n if n=6 then\n b:=1;\n writeln(b,' ',a);\nend. "}, {"source_code": "var n,min,max,k,i,j,x:longint;\nbegin\n readln(n);\n min:=9545454;\n max:=0;\n for i:=1 to 7 do\n begin\n k:=0;\n for j:=1 to n do\n begin \n x:=(i+j-1)mod 7;\n if (x=0) or(x=6)then k:=k+1;\n end;\n if kmax then max:=k;\n end;\n writeln(min,' ',max);\nend. \n "}, {"source_code": "var n,i,j,t:longint;\n a,b:array[0..6] of longint;\nbegin\n readln(n);\n a[0]:=0; b[0]:=0;\n a[1]:=0; b[1]:=1;\n a[2]:=0; b[2]:=2;\n a[3]:=0; b[3]:=2;\n a[4]:=0; b[4]:=2;\n a[5]:=0; b[5]:=2;\n a[6]:=1; b[6]:=2;\n t:=n div 7;\n i:=t*2+a[n mod 7];\n j:=t*2+b[n mod 7];\n write(i,' ',j);\n\nend."}, {"source_code": "var\n n,kq1,kq2:longint;\nbegin\n read(n);\n kq1:=0;\n kq2:=0;\n if n>5 then\n begin\n kq1:=(n div 7)*2;\n if n mod 7 =6 then\n inc(kq1);\n end;\n if (n=1) or (n=2) then\n kq2:=n\n else\n begin\n n:=n-2;\n kq2:=(n div 7)*2+2;\n if n mod 7 = 6 then\n inc(kq2);\n end;\n\n write(kq1,' ',kq2);\nend."}, {"source_code": "uses math;\nvar n:int64;\nbegin\n readln(n);\n writeln(n div 7*2 + (n mod 7+1) div 7,' ',n div 7*2 +min(n mod 7,2))\nend."}, {"source_code": "var n,m,dem,max,min:longint;\nbegin\n readln(n); m:=n; dem:=0;\n while n <> 0 do\n begin\n inc(dem); dec(n);\n if (dem = 6) or (dem = 7) then\n begin\n inc(min);\n if dem = 7 then dem:=0;\n end;\n end;\n n:=m; dem:=0;\n if n = 1 then begin inc(max); dec(n); end;\n if n > 1 then begin inc(max,2); dec(n,2); end;\n while n <> 0 do\n begin\n inc(dem); dec(n);\n if (dem = 6) or (dem = 7) then\n begin\n inc(max);\n if dem = 7 then dem:=0;\n end;\n end;\n write(min,' ',max);\nend."}, {"source_code": "var n,x,y,min,max:longint;\nbegin\nreadln(n);\nx:=n div 7;\ny:= n - 7*x;\nif y >=2 then max:= x*2 + 2\nelse max:=x*2 + y;\nif y<=5 then min:= x*2\nelse min:= x*2 + y - 5;\n\nwriteln(min,' ',max)\nend."}, {"source_code": "program abc;\nvar\nmax,min,n:longint;\nbegin\nreadln(n);\nmax:=n div 7*2;\nif n mod 7-2>=0 then max:=max+2 else\nif n mod 7-1>=0 then max:=max+1;\nmin:=n div 7*2;\nif n mod 7=6 then min:=min+1;\nwriteln(min,' ',max);\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n s:array[1..100000] of longint;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,t1,t2,r1,r2:longint;\n begin\n read(fi,n);\n t1:=n div 7*2;\n t2:=n mod 7;\n if t2=6 then r1:=t1+1 else r1:=t1;\n if t2=0 then r2:=t1 else\n if t2=1 then r2:=t1+1 else\n if t2>=2 then r2:=t1+2;\n writeln(fo,r1,' ',r2);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\nl,d,k,n:longint;\n begin\nreadln(n);\nl:=(n div 7 )*2;\nif( n mod 7 )= 6 then l:=l+1;\nwrite(l,' ');\n if n=2 then begin write('2'); exit; end;\nif n=1 then begin write('1'); exit; end;\nd:=n-2;\nk:=2;\nwhile d>0 do\nbegin\nd:=d-7;\nk:=k+2;\nend;\nif d<-1 then k:=k-2;\nif d=-1 then k:=k-1;\nwrite(k);\n end."}, {"source_code": "var n,k,mi:integer;\nbegin\nread(n);\nk:=(n div 7)*2;\nmi:=k;\nif n mod 7>=2 then k:=k+2\nelse if n mod 7=1 then k:=k+1;\nif n mod 7=6 then mi:=mi+1;\nwrite(mi,' ',k);\nend."}, {"source_code": "var i,n,s:longint;\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\n }\n readln(n);\n s:=n div 7;\n if (n mod 7>1) and (n mod 7 <>6) then\n writeln(s*2,' ',s*2+2);\n if n mod 7=1 then writeln(s*2,' ',s*2+1);\n if n mod 7=6 then writeln(s*2+1,' ',s*2+2);\nif n mod 7=0 then writeln(s*2,' ',s*2);\n{ close(input);\n close(output);\n }\n end.\n"}, {"source_code": "program holidays;\nvar n,x:longint;\nbegin\n readln(n);\n if (n mod 7=0) then writeln(2*(n div 7),' ',2*(n div 7))\n else begin\n x:=n-(n div 7)*7;\n if x=1 then writeln(2*(n div 7),' ',2*(n div 7)+1);\n if (x>=2) and (x<=5) then writeln(2*(n div 7),' ',2*(n div 7)+2);\n if (x>5) then writeln(2*(n div 7)+1,' ',2*(n div 7)+2);\n end;\nend.\n"}], "negative_code": [{"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else if n>=7 then ln:=n-(n div 7)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": " var n,k:longint;\nbegin\n readln(n);\n k:=n div 7;\n k:=k*2;\n if n mod 7 = 6 then\n k:=k+1;\n if n>=7 then\n writeln(k,' ',k);\n if n<7 then\n if n=6 then\n writeln(1,' ',2)\n else\n if n>=3 then\n writeln(0,' ',2)\n else\n writeln(0,' ',n);\n readln\nend.\n"}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n nn:=(n div 7)*2;\n ln:=n-((n div 5)*5);\n write(nn,' ',ln);\nend."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else ln:=n-(n div 5)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": "var\nx,y,z:integer;\nbegin\n\treadln(x);\n\ty:=(x div 7)*2;\n\tif (x mod 7 = 6)then y:=y+1;\n\tif x=1 then z:=1 else begin\n\t\tz:=2;\n\t\tx:=x-2;\n\t\tz:=z+(x div 7)*2;\n\t\tif (x mod 7 = 6)then z:=z+1;\n\t\twriteln(x);\n\tend;\n\twriteln(y,' ',z);\nend."}, {"source_code": "var n,min,max:longint;\n begin\n readln(n);\n min:=2*(n div 7);\n max:=2*(n div 7);\n if n = 6 then inc(min);\n if n mod 7 > 2 then inc(max,2)\n else max:=max+ n mod 7;\n writeln(min,' ',max); \n end."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=1 then nn:=1\n else if n=2 then nn:=2\n else if n>7 then nn:=n-(n div 5)*5;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else ln:=(n div 7)+2;\n write(nn,' ',ln);\nend. "}, {"source_code": "var n, mi, ma : Integer;\nbegin\n readln(n);\n ma := (n div 7) * 2;\n mi := ma;\n If n < 6 then mi := 0;\n If (n + 1) mod 2 = 0 then mi := mi + 1;\n If n mod 7 > 1 then ma := ma + 2;\n If n mod 7 = 1 then ma := ma + 1;\n writeln(mi,' ',ma);\nend."}, {"source_code": "const fi='';\n fo='';\n\nprocedure doc;\nvar i,d,n,d1:longint;\nbegin\n assign(input,fi);reset(input);\n readln(n); close(input);\n d:=0; i:=0; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d:=d+2\n else if i=n+1 then d:=d+1;\n if i<=n-2 then d1:=d1+2\n else if i=n-1 then d1:=d1+1;\n end;\n {i:=2; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d1:=d1+2\n else if i=n+1 then d1:=d1+1;\n end;}\n assign(output,fo);rewrite(output);\n writeln(d,' ',d1);close(output);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "var n,a,b,s1,s2:int64;\nbegin\n readln(n);\n a:=n div 7;\n b:=n mod 7;\n s1:=a*5;\n s2:=a*2;\n if b>5 then writeln(s1+5,' ',s2+b mod 5)\n else writeln(s2,' ',s2+b);\nend."}, {"source_code": "var\nl,d,k,n:longint;\n\nbegin\nreadln(n);\nl:=(n div 7 )*2;\nwrite(l,' ');\n\nd:=n-2;\nk:=(d div 7)*2+2;\nif (d mod 5)>1 then k:=k+2 ;\nif (d mod 5 )=1 then k:=k+1 ;\nwrite(k);\n\n\n\n\n\n\nend."}, {"source_code": "program holidays;\nvar n,x:longint;\nbegin\n readln(n);\n if (n mod 7=0) then writeln(2*(n div 7),' ',2*(n div 7))\n else begin\n x:=n-(n div 7)*7;\n if x=1 then writeln(2*(n div 7),' ',2*(n div 7)+1);\n if x>=2 then writeln(2*(n div 7),' ',2*(n div 7)+2);\n end;\nend.\n"}, {"source_code": "var n:longint;\nbegin\n read(n);\n if n-5>=0 then write((n-5) mod 5,' ',n mod 5) else write(0,' ',n mod 5);\nend."}, {"source_code": "var n:longint;\nt1,t2:integer;\nbegin\n read(n);\n t1:=(n mod 7) div 5;\n if t1<=0 then t1:=0 else t1:=(n mod 7)-(t1*5);\n t2:=(n mod 7) div 2;\n if t2<=0 then t2:=0 else t2:=1;\n write((n div 7)*2+t1,' ',(n div 7)*2+t2*2);\nend."}, {"source_code": " var n,k:longint;\nbegin\n readln(n);\n k:=n div 7;\n k:=k*2;\n if n mod 7 = 6 then\n k:=k+1;\n if (n>=7) and (n mod 7 >= 2) then\n writeln(k,' ',k+2)\n else\n if n>=7 then\n writeln(k,' ',k+(n mod 7));\n if n=6 then\n writeln(1,' ',2)\n else\n if (n>=3) and (n<7) then\n writeln(0,' ',2)\n else\n if n<3 then\n writeln(0,' ',n);\n readln\nend.\n"}, {"source_code": "var\n n,min,max:longint;\nbegin\n read(n);\n min:=(n div 7)*2;max:=min;\n if n mod 7=1 then max:=max+1;\n if n mod 7=2 then max:=max+2;\n n:=n - (min div 2)*7-5;\n if n>0 then min:=min+n;\n write(min, ' ',max);\nend."}, {"source_code": "var\n n,a,b,nghi:longint;\nbegin\n readln(n);\n a:=n div 7;\n b:=n mod 7;\n if (b>=2) then b:=a+2\n else b:=a+b;\n writeln(a,' ',b);\nend."}, {"source_code": "uses math;\nvar n,i,maxi,mini,t1,t2,t3,t4,t5,t6,t7,id1,id2,id3,id4,id5,id6,id7:longint;\nbegin\nreadln(n);\ninc(id6);inc(id7);\nfor i:=2 to n do\nbegin\ninc(t1);inc(t2);inc(t3);inc(t4);inc(t5);inc(t6);inc(t7);\nif t1>7 then t1:=1;\nif t2>7 then t2:=1;if t3>7 then t3:=1;\nif t4>7 then t4:=1;if t5>7 then t5:=1;\nif t6>7 then t6:=1;if t7>7 then t7:=1;\nif (t1=6)or(t1=7)then inc(id1);\nif (t2=6)or(t2=7)then inc(id2);\nif (t3=6)or(t3=7)then inc(id3);\nif (t4=6)or(t4=7)then inc(id4);\nif (t5=6)or(t5=7)then inc(id5);\nif (t6=6)or(t6=7)then inc(id6);\nif (t7=6)or(t7=7)then inc(id7);\nend;\nmaxi:=max(id1,max(id2,max(id3,max(id4,max(id5,max(id6,id7))))));\nmini:=min(id1,min(id2,min(id3,min(id4,min(id5,min(id6,id7))))));\nwriteln(mini,' ',maxi);\nend."}, {"source_code": "uses math;\nvar n,i,maxi,mini,t1,t2,t3,t4,t5,t6,t7,id1,id2,id3,id4,id5,id6,id7:longint;\nbegin\nreadln(n);\ninc(id6);inc(id7);\nfor i:=2 to n do\nbegin\ninc(t1);inc(t2);inc(t3);inc(t4);inc(t5);inc(t6);inc(t7);\nif t1>7 then t1:=1;\nif t2>7 then t2:=1;if t3>7 then t3:=1;\nif t4>7 then t4:=1;if t5>7 then t5:=1;\nif t6>7 then t6:=1;if t7>7 then t7:=1;\nif (t1=6)or(t1=7)then inc(id1);\nif (t2=6)or(t2=7)then inc(id2);\nif (t3=6)or(t3=7)then inc(id3);\nif (t4=6)or(t4=7)then inc(id4);\nif (t5=6)or(t5=7)then inc(id5);\nif (t6=6)or(t6=7)then inc(id6);\nif (t7=6)or(t7=7)then inc(id7);\nend;\nmaxi:=max(id1,max(id2,max(id3,max(id4,max(id5,max(id6,id7))))));\nmini:=min(id1,min(id2,min(id3,min(id4,min(id5,min(id6,id7))))));\nwriteln(mini,' ',maxi);\nend."}, {"source_code": "var\n n,a,b,nghi:longint;\nbegin\n readln(n);\n a:=n div 7; a:=a*2;\n b:=n mod 7;\n if (b>=2) then b:=a+2\n else b:=a+b;\n if (b=6) then inc(a);\n writeln(a,' ',b);\nend."}, {"source_code": "var n, mi, ma : Integer;\nbegin\n readln(n);\n ma := (n div 7) * 2;\n mi := ma;\n If n < 6 then mi := 0;\n If (n + 1) mod 2 = 0 then mi := mi + 1;\n If n mod 7 > 1 then ma := ma + 2;\n If n mod 7 = 1 then ma := ma + 1;\n writeln(mi,' ',ma);\nend."}, {"source_code": "var n,i,max,min,t1,t2,id1,id2:longint;\nbegin\nreadln(n);\ninc(max);\nt1:=1;t2:=6;\nfor i:=1 to n do\nbegin\ninc(t1);inc(t2);\nif t1>7 then t1:=1;\nif t2>7 then t2:=1;\nif (t1=6)or(t1=7)then inc(min);\nif (t2=6)or(t2=7)then inc(min);\nend;\nwriteln(min,' ',max);\nend."}, {"source_code": "uses math;\nvar n,i,maxi,mini,t1,t2,t3,t4,t5,t6,t7,id1,id2,id3,id4,id5,id6,id7:longint;\nbegin\nreadln(n);\ninc(id6);inc(id7);\nfor i:=2 to n do\nbegin\ninc(t1);inc(t2);inc(t3);inc(t4);inc(t5);inc(t6);inc(t7);\nif t1>7 then t1:=1;\nif t2>7 then t2:=1;if t3>7 then t3:=1;\nif t4>7 then t4:=1;if t5>7 then t5:=1;\nif t6>7 then t6:=1;if t7>7 then t7:=1;\nif (t1=6)or(t1=7)then inc(id1);\nif (t2=6)or(t2=7)then inc(id2);\nif (t3=6)or(t3=7)then inc(id3);\nif (t4=6)or(t4=7)then inc(id4);\nif (t5=6)or(t5=7)then inc(id5);\nif (t6=6)or(t6=7)then inc(id6);\nif (t7=6)or(t7=7)then inc(id7);\nend;\nmaxi:=max(id1,max(id2,max(id3,max(id4,max(id5,max(id6,id7))))));\nmini:=min(id1,min(id2,min(id3,min(id4,min(id5,min(id6,id7))))));\nwriteln(mini,' ',maxi);\nend."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if n=2 then ln:=2\n else if n>=7 then ln:=n-(n div 7)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": "var n, mi, ma : Integer;\nbegin\n readln(n);\n ma := (n div 7) * 2;\n mi := ma;\n If n < 6 then mi := 0;\n If (n + 1) mod 2 = 0 then mi := mi + 1;\n If n mod 7 > 1 then ma := ma + 2;\n If n mod 7 = 1 then ma := ma + 1;\n writeln(mi,' ',ma);\nend."}, {"source_code": "var\nx,y,z:integer;\nbegin\n\treadln(x);\n\ty:=(x div 7)*2;\n\tif (x mod 7 = 6)then y:=y+1;\n\tif x=1 then z:=1 else begin\n\t\tz:=2;\n\t\tx:=x-2;\n\t\tz:=z+(x div 7)*2;\n\t\tif (x mod 7 = 6)then x:=z+1;\n\tend;\n\twriteln(y,' ',z);\nend."}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if (n mod 2 = 0) or (n-1 mod 2 = 0) then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n,min,max:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nProcedure Tinh;\nBegin\n min:=(n div 7)*2; max:=(n div 7)*2;\n if n mod 7>=2 then inc(max,2);\n if n mod 7=1 then inc(max);\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,min,' ',max);\n close(f);\nEnd;\n\nBegin\n nhap;\n tinh;\n xuat;\nEnd.\n"}, {"source_code": "var n,a,b,s1,s2:int64;\nbegin\n readln(n);\n a:=n div 7;\n b:=n mod 7;\n s1:=a*5;\n s2:=a*2;\n if b>5 then writeln(s1+5,' ',s2+b mod 5)\n else writeln(s2,' ',s2+b);\nend."}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if n mod 2 = 0 then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var a,b,n,min,max:longint;\nbegin\nreadln(n);\na:=n div 7;\nb:=n mod 7;\nif b<=2 then begin \n min:=a*2;\n max:=a*2+b;\n end\n else if b>=5 then begin\n min:=a*2+(7-b);\n max:=a*2+2;\n end\n else begin\n min:=a*2;\n max:=a*2+2;\n end;\nwrite(min,' ',max);\nend."}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if n mod 2 = 0 then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var n,a,b,min,max:integer;\nBegin\nreadln(n);\nif n mod 7 =0 then begin\n min:= (n div 7) *2;\n max:=min;\n end\nelse begin\n min:=(n div 7) *2;\n if n div 7 = 1 then\n max:=min + 1\n else max:=min+2;\n end;\nwriteln(min,' ',max);\nEnd."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else ln:=n-(n div 5)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": "var n, mi, ma : Integer;\nbegin\n readln(n);\n mi := (n div 7) * 2;\n If n = 6 then mi := 1;\n ma := mi;\n If n mod 7 > 1 then ma := ma + 2;\n If n mod 7 = 1 then ma := ma + 1;\n writeln(mi,' ',ma);\nend."}, {"source_code": "var n,min,max:longint;\n begin\n readln(n);\n min:=2*(n div 7);\n max:=2*(n div 7);\n if n = 6 then inc(max);\n if n mod 7 > 2 then inc(max,2)\n else max:=max+ n mod 7;\n writeln(min,' ',max); \n end.\n "}, {"source_code": "var n, m, k,i, o, p, l, j, ans, min, max:LongInt;\n\n Begin\n Read(n);\n if n mod 7=0 then BEgin min:= (n div 7)*2; max:= (n div 7)*2;End;\n if (n mod 7=1) then BEGin min:=(n div 7)*2; max:=(n div 7)*2+n mod 7;End\n else BEgin min:=(n div 7)*2; max:=(n div 7)*2 +2;End;\n\n WriteLn(min,' ', max);\n\n End."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if n mod 7 = 0\n then writeln(2*(n div 7),' ',2*(n div 7))\n else\n if (n mod 7 = 6)\n then\n write(2*(n div 7)+1,' ')\n else\n write (2*(n div 7),' ');\n if n mod 7 > 1\n then writeln(2*(n div 7)+2)\n else writeln(2*(n div 7)+1)\n\n//(2*(n div 7))+(n mod 7)\nend.\n"}, {"source_code": "var n,min,max:longint;\n begin\n readln(n);\n min:=2*(n div 7);\n max:=2*(n div 7);\n if n = 6 then inc(min);\n if n mod 7 > 2 then inc(max,2)\n else max:=max+ n mod 7;\n writeln(min,' ',max); \n end."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if n mod 5 <> 2\n then\n write((n div 5)*1,' ')\n else\n write((n div 5)*2,' ');\n if n mod 7 = 0\n then writeln((n div 7)*2)\n else if n mod 7 > 1\n then writeln((n div 7)*2+2)\n else writeln((n div 7)*2+1)\nend."}, {"source_code": "var\n n,min,max : longint;\n \nbegin\n readln(n);\n min := (n div 7) * 2;\n max := min;\n if n mod 7 = 1 then\n max := min + 1\n else if n mod 7 > 1 then\n max := min + 2;\n writeln(min,' ',max);\nend."}, {"source_code": "var n,min,max:longint;\nbegin\n read(n);\n min:=(n div 7)*2;\n max:=min;\n if n mod 7=1\n then max:=max+1;\n if n mod 7>1\n then max:=max+2;\n write(min,' ',max);\nend."}, {"source_code": "var\nl,k,n:longint;\n\nbegin\nreadln(n);\nl:=(n div 7 )*2;\nwrite(l,' ');\n\nk:=n-2;\nk:=(k div 7)*2+2;\nwrite(k);\n\n\n\n\n\n\nend."}, {"source_code": "program z4;\nvar a:array[1..100]of integer;i:byte;\nbegin\nfor i:=1 to 100 do\nif i mod 2=0 then a[i]:=0\nelse a[i]:=1;\nfor i:=1 to 100 do\nwrite(a[i],' ');\nend."}, {"source_code": "var n, mi, ma : Integer;\nbegin\n readln(n);\n ma := (n div 7) * 2;\n mi := ma;\n If n = 6 then mi := 1;\n If n mod 7 > 1 then ma := ma + 2;\n If n mod 7 = 1 then ma := ma + 1;\n writeln(mi,' ',ma);\nend."}, {"source_code": "var n,max,min:longword;\nbegin\nReadln(N);\nif N mod 7 = 0 then begin Writeln((N div 7)*2,' ',(N div 7)*2); exit; end;\nmax:=(N div 7)*2+ ((N mod 7) mod 3);\nmin:=(N div 7)*2 + (N mod 7) div 6;\nWriteln(min,' ',max);\nend."}, {"source_code": "var n,max,min:longword;\nbegin\nReadln(N);\nif N mod 7 = 0 then begin Writeln((N div 7)*2,' ',(N div 7)*2); exit; end;\nmax:=(N div 7)*2+ ((N mod 7) mod 3);\nmin:=(N div 7)*2 + (N mod 7) div 6;\nWriteln(min,' ',max);\nend."}, {"source_code": "var\ni,otv,otv1,n,q:longint;\nbegin\nreadln(N);\nfor i:=1 to n do begin\n if i mod 6 = 0 then inc(otv);\n if i mod 7=0 then inc(otv);\nend;\nif n>=2 then begin\n otv1:=2;\n n:=n-2;\nend;\nif n=1 then begin\n otv1:=1;\n dec(n);\nend;\nfor i:=1 to n do begin\nif i mod 7 = 0 then inc(otv1);\nif i mod 8 = 0 then inc(otv1);\nend;\nwriteln(otv,' ' ,otv1);\nend."}, {"source_code": "var n, m, k,i, o, p, l, j, ans, min, max:LongInt;\n\n Begin\n Read(n);\n if n mod 7=0 then BEgin min:= (n div 7)*2; max:= (n div 7)*2;End;\n if (n mod 7=1) then BEGin min:=(n div 7)*2; max:=(n div 7)*2+n mod 7;End\n else BEgin min:=(n div 7)*2; max:=(n div 7)*2 +2;End;\n\n WriteLn(min,' ', max);\n\n End."}, {"source_code": "var n,h,cnt,cnta:longint;\nbegin\n readln(n);\n for h:=1 to n do\n begin\n if ((h mod 7)= 6) or ((h mod 7)= 5) then inc(cnt);\n end;\n for h:=1 to n do\n begin\n if ((h mod 7)= 0) or ((h mod 7) = 1) then inc(cnta);\n end;\n writeln(cnt,cnta);\nend.\n "}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if (n mod 2 = 0) or (n-1 mod 2 = 0) then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var\nn:longint;\nbegin\nreadln(n);\nif n=1 then writeln('0 1')\nelse\n\nif (n<=5)and(n<>1) then writeln('0 2')\nelse\nif n=6 then writeln('1 2')\nelse\nif n=7 then writeln('2 2')\nelse\nbegin\n if n mod 7=0 then\n writeln(2*(n div 7),' ', 2*(n div 7))\n else\n writeln(2*(n div 7),' ',2*(n div 7)+1);\n\nend;\nend."}, {"source_code": "var\n n,a,b,nghi:longint;\nbegin\n readln(n);\n a:=n div 7;\n b:=n mod 7;\n if (b>=2) then b:=a+2\n else b:=a+b;\n writeln(a,' ',b);\nend."}, {"source_code": "var\n n, min, max: LongInt;\n \nbegin\n Read (n);\n \n if n = 1 then\n WriteLn (0, ' ', 1)\n else\n begin\n max:= 2 * n div 7;\n min:= max;\n \n if n mod 7 >= 2 then\n Inc (max, 2)\n else if n mod 7 = 1 then\n Inc (max);\n \n if n mod 7 = 6 then \n Inc (min);\n \n WriteLn (min, ' ', max)\n end\nend."}, {"source_code": "var\notv1,q,n,nn,otv:longint;\nbegin\nreadln(n);\nnn:=n;\nq:=n div 7;\nnn:=nn mod 7;\nif nn=6 then inc(otv);\notv:=otv+2*q;\nwriteln(otv);\nif n>=2 then begin\n otv1:=2;\n n:=n-2;\nend;\nif n=1 then begin\n otv1:=1;\n dec(n);\nend;\nq:=n div 7;\nif n mod 7 = 6 then inc(otv1);\notv1:=otv1+2*q;\nwriteln(otv,' ',otv1);\nend."}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if ((n mod 2 = 0) or (n-1 mod 2 = 0)) and (n <> 1) then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var\n n,a,b,nghi:longint;\nbegin\n readln(n);\n a:=n div 7; a:=a*2;\n b:=n mod 7;\n if (b>=2) then b:=a+2\n else b:=a+b;\n if (b=6) then inc(a);\n writeln(a,' ',b);\nend."}, {"source_code": "const fi='';\n fo='';\n\nprocedure doc;\nvar i,d,n,d1:longint;\nbegin\n assign(input,fi);reset(input);\n readln(n); close(input);\n d:=0; i:=0;\n while i<=n do begin\n i:=i+7;\n if i<=n then d:=d+2\n else if i=n+1 then d:=d+1;\n end;\n i:=2; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d1:=d1+2\n else if i=n+1 then d1:=d1+1;\n end;\n assign(output,fo);rewrite(output);\n writeln(d,' ',d1);close(output);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "USES Math;\nCONST\n tfi = '';\n tfo = '';\nVAR\n fi,fo : text;\n n,res : int64;\n\nBEGIN\n assign(fi,tfi); reset(fi);\n assign(fo,tfo); rewrite(fo);\n Read(fi,n);\n res:=n div 7;\n write(fo,res*2,' ',res*2+min(n-res*7,2));\n close(fi); close(fo);\nEND.\n"}, {"source_code": "var n,min,max:longint;\nbegin\n read(n);\n min:=(n div 7)*2;\n max:=min;\n if n mod 7=1\n then max:=max+1;\n if n mod 7>1\n then max:=max+2;\n write(min,' ',max);\nend."}, {"source_code": "var\nl,k,n:longint;\n\nbegin\nreadln(n);\nl:=(n div 7 )*2;\nwrite(l,' ');\n\nk:=n-2;\nk:=(k div 7)*2+2;\nwrite(k);\n\n\n\n\n\n\nend."}, {"source_code": "var n:int64;\nbegin\nread(n);\nwriteln((n div 7)*2,' ',((n-2) div 7)*2+2);\nend."}, {"source_code": "program z1;\nvar\n n, min, max : integer;\nbegin\n read(n);\n min := n div 7 * 2;\n if (n > 2) then max := (n - 2) div 7 * 2 + 2;\n if (n = 1) then max := (n - 1) div 7 * 2 + 1;\n if (n = 0) then max := 0;\n write(min,' ',max);\nend."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n nn:=(n div 7)*2;\n ln:=n-((n div 5)*5);\n write(nn,' ',ln);\nend."}, {"source_code": "USES Math;\nCONST\n tfi = '';\n tfo = '';\nVAR\n fi,fo : text;\n n,res : int64;\n\nBEGIN\n assign(fi,tfi); reset(fi);\n assign(fo,tfo); rewrite(fo);\n Read(fi,n);\n res:=n div 7;\n write(fo,res*2,' ',res*2+min(n-res*7,2));\n close(fi); close(fo);\nEND.\n"}, {"source_code": "program abc;\nvar\nmax,min,n:longint;\nbegin\nreadln(n);\nmax:=(n-2)div 7*2+2;\nif n<2 then max:=n;\nmin:=n div 7*2;\nwriteln(min,' ',max);\nend."}, {"source_code": "var\n n,x,y: longint;\nbegin\n readln(n);\n x:=n div 7*2;\n y:=x;\n if n mod 7 <> 0 then\n begin\n if n mod 7 = 6 then y:=y+3 else\n if n mod 7 < 6 then y:=y+2;\n end;\n writeln(x,' ',y);\nend.\n"}, {"source_code": "var n:longint;\nbegin\nreadln(n);\nif n mod 7=0 then begin write(2*(n div 7),' ',2*(n div 7)); exit; end;\nif n mod 7=1 then write((n div 7)*2,' ',2*(n div 7)+1);\nif (n mod 7>1)and(n mod 7<6) then write((n div 7)*2,' ',2*(n div 7)+2);\nif n mod 7=6 then write((n div 7)*2+1,' ',2*(n div 7));\nend.\n"}, {"source_code": "var\n a:integer;\nBegin\n Readln(a);\n write(((a div 7)*2),' ');\n if a mod 7=0 then\n Write((a div 7)*2);\n if a mod 7=1 then\n Write(((a div 7)*2)+1);\n if a mod 7>=2 then\n Write(((a div 7)*2)+2);\n Readln;\nEnd.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar i, j, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n if n = 1 then j:=1 else j:=2+((n-2) div 7)*2;\n i:=(n div 7)*2; if n mod 7 = 6 then inc(i); \n writeln(i,' ',j);\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "var\nn,max,min,NUM:integer;\nBegin\nread(n);\nmax:=(n div 7)*2;\nif n mod 7=1 then max:=max+1;\nNUM:=n mod 7;\nmin:=(n div 7)*2;\ncase NUM of\n0:writeln(min,' ',max);\n1:writeln(min,' ',max);\n2..6:writeln(min,' ',max+2);\nend;\nend.\n"}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if n=2 then ln:=2\n else if n>=7 then ln:=n-(n div 7)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": "const fi='';\n fo='';\n\nprocedure doc;\nvar i,d,n,d1:longint;\nbegin\n assign(input,fi);reset(input);\n readln(n); close(input);\n d:=0; i:=0;\n while i<=n do begin\n i:=i+7;\n if i<=n then d:=d+2\n else if i=n+1 then d:=d+1;\n end;\n i:=2; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d1:=d1+2\n else if i=n+1 then d1:=d1+1;\n end;\n assign(output,fo);rewrite(output);\n writeln(d,' ',d1);close(output);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar i, j, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n if n = 1 then j:=1 else j:=2+((n-2) div 7)*2;\n i:=(n div 7)*2; if n mod 7 = 6 then inc(i); \n writeln(i,' ',j);\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n nn:=(n div 7)*2;\n ln:=((n-2)-(((n-2) div 5)*5))+2;\n write(nn,' ',ln);\nend."}, {"source_code": "program holidays;\nvar\n\td\t: integer;\n\tmax\t: integer;\n\tmin\t: integer;\nbegin\n\treadln(d);\n\tif ((d mod 7)=0) then\n\tbegin\n\t\tmin := 2*(d div 7);\n\t\tmax := min;\n\tend else if ((d mod 7)=6) then\n\tbegin\n\t\tmin := (2*(d div 7))+1;\n\t\tmax := (2*(d div 7))+2;\n\tend else\n\tbegin\n\t\tmin := (2*(d div 7));\n\t\tmax := (2*(d div 7))+2;\n\tend;\n\twriteln(min,' ',max);\nend."}, {"source_code": "type int = longint;\nvar n,t,m,a,b : int;\nbegin\n readln(n);\n t := n div 7;\n m := n mod 7;\n if m=0 then\n begin\n a := t*2; b := a;\n end else\n if m=1 then\n begin\n a := t*2; b := a+1;\n end else\n begin\n a := t*2; b := a+2;\n end;\n writeln(a,' ',b);\n\nend."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=1 then nn:=1\n else if n=2 then nn:=2\n else if n>7 then nn:=n-(n div 5)*5;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else ln:=(n div 7)+2;\n write(nn,' ',ln);\nend. "}, {"source_code": "program z1;\nvar\n n, min, max : integer;\nbegin\n read(n);\n min := n div 7 * 2;\n if (n > 2) then max := (n - 2) div 7 * 2 + 2;\n if (n = 1) then max := (n - 1) div 7 * 2 + 1;\n if (n = 0) then max := 0;\n max := n div 7 * 2 + 2;\n write(min,' ',max);\nend."}, {"source_code": "var\n n, min, max: LongInt;\n \nbegin\n Read (n);\n \n if n = 1 then\n WriteLn (0, 1)\n else\n begin\n max:= 2 * n div 7;\n min:= max;\n \n if n mod 7 >= 2 then\n Inc (max, 2)\n else if n mod 7 = 1 then\n Inc (max);\n \n if n mod 7 = 6 then \n Inc (min);\n \n WriteLn (min, ' ', max)\n end\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar i, j, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n if n = 1 then j:=1 else j:=2+((n-2) div 7)*2; if n-2 mod 7 = 6 then inc(j); \n i:=(n div 7)*2; if n mod 7 = 6 then inc(i);\n writeln(i,' ',j);\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "program z1;\nvar\n n, min, max : integer;\nbegin\n read(n);\n min := n div 7 * 2;\n if (n mod 7 = 6) then inc(min);\n if (n >= 2) then max := (n - 2) div 7 * 2 + 2;\n if (n = 1) then max := (n - 1) div 7 * 2 + 1;\n if (n = 0) then max := 0;\n if (n mod 7 = 1) then inc(max);\n write(min,' ',max);\nend."}, {"source_code": "const fi='';\n fo='';\n\nprocedure doc;\nvar i,d,n,d1:longint;\nbegin\n assign(input,fi);reset(input);\n readln(n); close(input);\n d:=0; i:=0; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d:=d+2\n else if i=n+1 then d:=d+1;\n if i<=n-2 then d1:=d1+2\n else if i=n-1 then d1:=d1+1;\n end;\n {i:=2; d1:=2;\n while i<=n do begin\n i:=i+7;\n if i<=n then d1:=d1+2\n else if i=n+1 then d1:=d1+1;\n end;}\n assign(output,fo);rewrite(output);\n writeln(d,' ',d1);close(output);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "var\n a:integer;\nBegin\n Readln(a);\n if a mod 7=6 then\n write(1,' ')\n else write((a div 7)*2,' ');\n if a mod 7=0 then\n Write((a div 7)*2);\n if a mod 7=1 then\n Write(((a div 7)*2)+1);\n if a mod 7>=2 then\n Write(((a div 7)*2)+2);\n Readln;\nEnd.\n"}, {"source_code": "program z2;\nvar n:longint;i,b,c,d:integer;\nbegin\nread(n);\nc:=n;\nd:=0;\nif n<=5 then\nif n>2 then begin d:=d+2;write(0,' ',d);exit;end\nelse begin d:=d+n;write(0,' ',d);exit;end;\nif n=6 then begin write(1,' ',2);exit;end;\nwhile c>=7 do begin\nc:=c-7;b:=b+2;end;\nwhile n>=7 do begin\nn:=n-7;d:=d+2;end;\nif n>0 then\nif n>2 then d:=d+2\nelse d:=d+n;\nwrite(b,' ',d);\nend.\n\n"}, {"source_code": "var n:longint;\nbegin\nreadln(n);\nif n mod 7=0 then begin write(2*(n div 7),' ',2*(n div 7)); exit; end;\nif n mod 7=1 then write((n div 7)*2,' ',2*(n div 7)+1) else write((n div 7)*2,' ',2*(n div 7)+2);\nend."}, {"source_code": "var\nn,q:longint;\nbegin\nreadln(N);\nwrite(2*(n div 7));\nwrite(' ');\n\nif n mod 7>=2 then q:=2;\nif n mod 7=1 then q:=1;\nwriteln(2*(n div 7)+q);\nend."}, {"source_code": "var n,min,max:longint;\n begin\n readln(n);\n min:=2*(n div 7);\n max:=2*(n div 7);\n if n = 6 then inc(min);\n if n mod 7 > 2 then inc(max,2)\n else max:=max+ n mod 7;\n writeln(min,' ',max); \n end."}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if ((n mod 2 = 0) or (n-1 mod 2 = 0)) and (n <> 1) then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var n,i,max,min,t1,t2,id1,id2:longint;\nbegin\nreadln(n);\ninc(max);\nt1:=1;t2:=6;\nfor i:=1 to n do\nbegin\ninc(t1);inc(t2);\nif t1>7 then t1:=1;\nif t2>7 then t2:=1;\nif (t1=6)or(t1=7)then inc(min);\nif (t2=6)or(t2=7)then inc(min);\nend;\nwriteln(min,' ',max);\nend."}, {"source_code": "var\n n,x,y: longint;\nbegin\n readln(n);\n x:=n div 7*2;\n y:=x+n mod 7;\n writeln(x,' ',y);\nend.\n"}, {"source_code": "var n,mi,ma,a,b,c:integer;\nbegin\nreadln(n);\na:=n div 7; b:=a*2;\nmi:=b; ma:=b;\nc:=n mod 7;\nif (c>0) then if c=1 then ma:=ma+1 else if (c<=5) then ma:=ma+2 else if c=6 then begin mi:=mi+1; ma:=ma+1; end;\nwrite(mi,' ',ma);\nend."}, {"source_code": "var n,h,cnt,cnta:longint;\nbegin\n readln(n);\n for h:=1 to n do\n begin\n if ((h mod 7)= 6) or ((h mod 7)= 5) then inc(cnt);\n end;\n for h:=1 to n do\n begin\n if ((h mod 7)= 2) or ((h mod 7) = 1) then inc(cnta);\n end;\n writeln(cnt,cnta);\nend.\n "}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if n mod 2 = 0 then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var\n n,min,max,x : longint ;\n\nbegin\n readln (n) ;\n x := n div 7 ;\n if n mod 7 = 0 then\n begin\n min := x * 2 ;\n max := min ;\n end\n else if ((n mod 2 = 0) or (n-1 mod 2 = 0)) and (n <> 1) then\n begin\n min := x * 2 ;\n max := min + 2 ;\n end\n else\n begin\n min := x * 2 ;\n max := min + 1 ;\n end;\n writeln (min,' ',max) ;\nend.\n\n\n"}, {"source_code": "var n, m, k,i, o, p, l, j, ans, min, max:LongInt;\n\n Begin\n Read(n);\n if n mod 7=0 then BEgin min:= (n div 7)*2; max:= (n div 7)*2;WriteLn(min,' ', max);HAlt;End;\n if (n mod 7=1) then BEGin min:=(n div 7)*2; max:=(n div 7)*2+n mod 7;End\n else BEgin min:=(n div 7)*2; max:=(n div 7)*2 +2;End;\n\n WriteLn(min,' ', max);\n\n End."}, {"source_code": "var nn,ln,n:integer;\nbegin\n read(n);\n if n=6 then nn:=1\n else if n>=7 then nn:=(((n div 7)*7) div 7)*2;\n if n=1 then ln:=1\n else if (n>=2) and (n<7) then ln:=2\n else ln:=n-(n div 5)*5;\n write(nn,' ',ln);\nend. "}, {"source_code": "var\n a,s,d:integer;\nbegin\n read(a);\n d:=(a div 7)*2;\n if ((a mod 7) > 5) then\n inc (d,a mod 7 - 5);\n s:=a div 7 * 2;\n if a mod 7 < 3 then\n inc(s, a mod 7);\n writeln(d, ' ', s);\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses math;\nvar n:int64;\nbegin\n readln(n);\n writeln(n div 7*2,' ',n div 7*2 +min(n mod 7,2))\nend."}, {"source_code": "var n:longint;\nbegin\nreadln(n);\nif n mod 7=0 then begin write(2*(n div 7),' ',2*(n div 7)); exit; end;\nif n mod 7=1 then write((n div 7)*2,' ',2*(n div 7)+1) else write((n div 7)*2,' ',2*(n div 7)+2);\nend."}], "src_uid": "8152daefb04dfa3e1a53f0a501544c35"} {"source_code": "var\n a,b,c,d:longint;\n\n\nbegin\n\n readln(a,b,c,d);\n if (b-a=c-b) and (c-b=d-c) then writeln(d+b-a) else\n if (b/a=c/b) and (c/b=d/c) and (frac(d*b/a)=0) then writeln(trunc(d*b/a)) else\n writeln(42);\n\nend.", "positive_code": [{"source_code": "var a, b, c, d: Longint;\n\nfunction eq(a, b: Extended): Boolean;\nBegin\n if abs(a - b) < 0.0000000001 then\n eq := true\n else\n eq := false;\nEnd;\n\nBegin\n read(a, b, c, d);\n if (a - b = b - c) and (b - c = c - d) then begin\n write(d - (b - c));\n halt;\n end;\n if (b = 0) and (c = 0) and (d = 0) then begin\n write(0);\n halt;\n end;\n if (eq(a / b, b / c)) and (eq(b / c, c / d)) then begin\n if d * b mod a = 0 then begin\n write(d * b div a);\n halt;\n end;\n end;\n write(42);\nEnd.\n"}, {"source_code": "var\n a,b,c,d:longint;\nbegin\n readln(a,b,c,d);\n if (b+b=a+c)and(c+c=b+d) then writeln(d+c-b) else\n if (c*c=b*d)and(b*b=a*c)and(frac(d*b/a)=0) then writeln(trunc(d*c/b)) else\n writeln(42);\nend."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b / a;// На ноль делить нельзя\n if b<>0 then p2 := c / b;\n if c<>0 then p3 := d / c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)and(p1<>0)and(frac(d * b/a)=0)// Целое число!!!!\n then writeln(trunc(d * b/a))//Целое число должно быть не real:)!!! \n //1/3\n else writeln(42)\n end\n //else writeln(42)\n //readln !!!!!\nend."}, {"source_code": "var\n i,e: longint;\n t: integer;\n n,m,o,p,q,r,s: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[2]-b[1]);\n m:=(b[3]-b[2]);\n o:=(b[4]-b[3]);\n p:=(b[2]/b[1]);\n q:=(b[3]/b[2]);\n r:=(b[4]/b[3]);\n s:=(b[4]*b[4]/b[3]);\n t:=round(s);\n if(n=m)and(m=o)then\n writeln((b[4]+b[4]-b[3]):0:0)\n else if(p=q)and(q=r)then\n begin\n if s<1 then\n writeln(e)\n else if s<>t then\n writeln(e)\n else if s=t then\n writeln((b[4]*b[4]/b[3]):0:0);\n end\n else\n writeln(e);\nend."}, {"source_code": "var a,b,c,d:word; e:integer;\nfunction ucln(x,y:word):word;\nvar z:word;\nbegin\n x:=abs(x); y:=abs(y);\n while y>0 do\n begin\n x:=x mod y; z:=x; x:=y; y:=z\n end;\n ucln:=x\nend;\nbegin\n read(a,b,c,d);\n e:=b-a;\n if (c=a+e shl 1) and (d=a+e*3) then write(a+e shl 2)\n else begin\n e:=ucln(a,b); a:=a div e; e:=b div e;\n if (b*e mod a=0) and (b*e div a=c) and (c*e mod a=0) and (c*e div a=d) and (d*e mod a=0) then write(d*e div a)\n else write(42)\n end\nend."}, {"source_code": "var\n a,b,c,d:longint;\n\n\nbegin\n\n readln(a,b,c,d);\n if (b-a=c-b) and (c-b=d-c) then writeln(d+b-a) else\n if (b/a=c/b) and (c/b=d/c) and (frac(d*b/a)=0) then writeln(trunc(d*b/a)) else\n writeln(42);\n\nend."}, {"source_code": "program qq;\n\nconst\n eps = 1e-9;\n\nvar\n n, d, x, i: integer;\n q, l: real;\n a: array[1..10000] of integer;\n\nbegin\n d := 0;\n q := 0;\n x := 0;\n for i := 1 to 4 do\n read(a[i]);\n //if (a[1]=a[2]) and (a[1]=a[3]) and (a[1]=a[4]) then begin\n //write(a[1]);\n {halt;}\n //end;\n if (a[2] - a[1] = a[3] - a[2]) and (a[2] - a[1] = a[4] - a[3]) then\n begin\n d := a[2] - a[1];\n write(a[4] + d);\n x := 1;\n end\n else\n if (abs(a[2] / a[1] - a[3] / a[2]) < eps) and (abs(a[2] / a[1] - a[4] / a[3]) < eps) then\n begin\n q := a[2] / a[1];\n l := a[4] * q;\n if (abs(l - round(l)) < eps) then\n begin\n write(l: 5: 0);\n x := 1;\n end;\n end;\n if x = 0 then\n write(42);\nend."}, {"source_code": "var a,b,c,d:longint;\nbegin\n readln(a,b,c,d);\n if (abs(a-b)=abs(b-c))and(abs(b-c)=abs(c-d)) then\n writeln(d-a+b)\n else\n if (a*c=b*b)and(b*d=c*c) then\n if d*d mod c=0 then\n writeln(d*d div c)\n else\n writeln(42)\n else\n writeln(42);\nend."}, {"source_code": "var a:array[1..4] of integer;\n\nfunction ktcsc:boolean;\nvar i:byte;\n\tl:integer;\nbegin\n\tl:=a[2]-a[1];\n\tfor i:=2 to 3 do\n\tbegin\n\t\tif a[i+1]-a[i]<>l then exit(FALSE);\n\tend;\n\texit(TRUE);\nend;\n\nfunction ktcsn:boolean;\nvar i:byte;\n v:longint;\n\tl,k,j,u:real;\nbegin\n\tl:=a[2]/a[1];\n k:=a[3]/a[2];\n j:=a[4]/a[3];\n if j<>l then exit(FALSE);\n if j<>k then exit(FALSE);\n if l<>k then exit(FALSE);\n v:=trunc(a[4]*a[2]/a[1]);\n u:=v/a[4];\n if u<>l then exit(FALSE) else exit(TRUE);\nend;\n\nprocedure proonf;\nvar i:byte;\nbegin\n\tfor i:=1 to 4 do read(a[i]);\n\tif ktcsc=TRUE then writeln(a[4]+a[2]-a[1])\n\telse\n\tif ktcsn=TRUE then writeln(trunc(a[4]*(a[2]/a[1])))\n\telse writeln(42);\nend;\n\n//main\nbegin\n\tproonf;\nend.\nvar x:array[1..5] of longint;\n\nprocedure proonf;\nvar t,s:string;\n\tfound:boolean;\n\tm,i,k,min,temp:longint;\n f:text;\nbegin\n assign(f,'');\n reset(f);\n\treadln(f,k);\n\tstr(k,t);\n readln(f,s);\n\tfillchar(x,sizeof(x),0);\n found:=true;\n\twhile found=true do\n\tbegin\n\t\tfor i:=1 to length(t) do\n\t\tbegin\n\t\t\tm:=pos(t[i],s);\n\t\t\tif (t[i]='2')and(m=0) then m:=pos('5',s);\n\t\t\tif (t[i]='5')and(m=0) then m:=pos('2',s);\n\t\t\tif (t[i]='9')and(m=0) then m:=pos('6',s);\n\t\t\tif (t[i]='6')and(m=0) then m:=pos('9',s);\n\t\t\tif m<> 0 then inc(x[i]);\n\t\t\tdelete(s,m,1);\n\t\tend;\n if m<>0 then\n begin\n\t\tm:=x[1];\n\t\tfor i:=2 to length(t) do\n\t\tbegin\n\t\t\tif (x[i]<>m) then begin found:=false; break; end;\n\t\tend;\n\t\tend\n else found:=FALSE;\n\tend;\n\tmin:=x[1];\n\tfor i:=2 to length(t) do\n\tbegin\n\t\tif min>x[i] then \n\t\tbegin \n\t\t\ttemp:=min; \n\t\t\tmin:=x[i]; \n\t\t\tx[i]:=temp; \n\t\tend;\n\tend;\n\twriteln(min);\nend;\n\n//main\nbegin\n\tproonf;\nend."}, {"source_code": "var a:array[1..4] of integer;\n\nfunction ktcsc:boolean;\nvar i:byte;\n\tl:integer;\nbegin\n\tl:=a[2]-a[1];\n\tfor i:=2 to 3 do\n\tbegin\n\t\tif a[i+1]-a[i]<>l then exit(FALSE);\n\tend;\n\texit(TRUE);\nend;\n\nfunction ktcsn:boolean;\nvar i:byte;\n v:longint;\n\tl,k,j,u:real;\nbegin\n\tl:=a[2]/a[1];\n k:=a[3]/a[2];\n j:=a[4]/a[3];\n if j<>l then exit(FALSE);\n if j<>k then exit(FALSE);\n if l<>k then exit(FALSE);\n v:=trunc(a[4]*a[2]/a[1]);\n u:=v/a[4];\n if u<>l then exit(FALSE) else exit(TRUE);\nend;\n\nprocedure proonf;\nvar i:byte;\nbegin\n\tfor i:=1 to 4 do read(a[i]);\n\tif ktcsc=TRUE then writeln(a[4]+a[2]-a[1])\n\telse\n\tif ktcsn=TRUE then writeln(trunc(a[4]*(a[2]/a[1])))\n\telse writeln(42);\nend;\n\n//main\nbegin\n\tproonf;\nend.\n"}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n p:=0;\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)and(frac(a[4]*x)=0)then\n begin\n writeln(a[4]*x:0:0);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "{$n+}\nvar\n a:array[1..5]of longint;\n p1,p2,x,n,i:longint;\n y:extended;\nbegin\n {assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n n:=4;\n for i:=1 to n do read(a[i]);\n x:=a[2]-a[1];\n for i:=1 to n-1 do if a[i]+x<>a[i+1] then p1:=1;\n if p1=0 then\n begin\n writeln(a[4]+x);\n halt;\n end;\n y:=a[2]/a[1];\n for i:=1 to n-1 do if a[i]*y<>a[i+1]then p2:=1;\n if frac(a[4]*y)<>0 then p2:=1;\n if p2=0 then\n begin\n writeln(a[4]*y:0:0);\n halt;\n end;\n writeln(42);\nend."}, {"source_code": "var\na,b,c,d,y:longint;\nx,e:real;\n\nbegin\n read(a,b,c,d);\n if (d-c=c-b) and (c-b=b-a) then\n begin\n y:=d-c;\n writeln(d+y);\n halt;\n end;\n if (d/c=c/b) and (c/b=b/a) then\n begin\n x:=d/c;\n e:=d*x;\n if trunc(e)=e then writeln(e:0:0) else writeln(42);\n halt;\n end;\n writeln(42);\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=100000000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar nn,n,i10,i100,n1,dl,kol,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,i,j,start,finish:longint;\nt,k,p,m1,pl,sum,p1,p2,m,k2,r,cc,ot,aa,bb,x1,y1,x0,y0,ll,rr,d1,d2,kolvyk,xx2,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,mnog,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndx,dy,b,a,c:array[-1000..200000] of int64;\n\nxx,yy,z1,z,x,y: array[-10..500000] of int64;\ngr1,gr: array[-50..700,-50..700] of boolean;\nee,deg,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n n:=4;\n for i:=1 to n do read(a[i]);\nflag1:=true;\nfor i:=2 to n-1 do if a[i]*a[i]<>a[i-1]*a[i+1] then flag1:=false;\n\nflag2:=true;\nfor i:=2 to n-1 do if a[i]+a[i]<>a[i-1]+a[i+1] then flag2:=false;\n\nif flag2 then begin write(2*a[4]-a[3]); goto 1; end;\nif flag1 and((a[4]*a[4]/a[3])=round(a[4]*a[4]/a[3])) then begin\nwrite(a[4]*a[4]/a[3]:0:0); goto 1; end;\nwrite(42);\n\n\n 1: close(output);\n\nend.\n"}, {"source_code": "Var z,i:longint;\nch1,zn1,ch,zn:longint;\nf:boolean;\nm:array [1..100] of longint;\nfunction nod(a,b:longint):longint;\nbegin\n if b>a\n then nod:=nod(b,a)\n else if b=0\n then nod:=a\n else nod:=nod(b,a mod b);\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n for i:=1 to 4 do\n read(m[i]);\n z:=m[2]-m[1];\n f:=true;\n for i:=3 to 4 do\n if m[i]-m[i-1]<>z\n then f:=false;\n if f\n then begin\n writeln(m[4]+z);\n halt(0);\n end;\n ch:=m[2];\n zn:=m[1];\n z:=nod(m[2],m[1]);\n ch:=ch div z;\n zn:=zn div z;\n f:=true;\n for i:=3 to 4 do\n begin\n ch1:=m[i];\n zn1:=m[i-1];\n z:=nod(m[i],m[i-1]);\n ch1:=ch1 div z;\n zn1:=zn1 div z;\n if (ch1<>ch)or(zn1<>zn)\n then f:=false;\n end;\n if (m[4]*ch) mod zn<>0\n then f:=false;\n if f=false\n then writeln(42)\n else writeln((m[4]*ch) div zn);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar m: array [1..10] of Integer;\n x,y,z,t: Integer;\n arif, geom: Boolean;\n next: Real;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n Readln(x,y,z,t);\n if (y-x = z-y) and (t-z = z-y ) then Writeln(2*t-z)\n else\n if (y/x=z/y) and (t/z=z/y) and ( Frac(t*t/z) = 0) then Writeln(t*t/z :0:0)\n else writeln(42);\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar m: array [1..10] of Integer;\n i,j,k,d,q: Integer;\n arif, geom: Boolean;\n next: Real;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n for i:=1 to 4 do Read(m[i]);\n arif:=True;\n geom:=True;\n d:=m[2]-m[1];\n q:=m[2] div m[1];\n for i:=2 to 4 do\n if m[i]-m[i-1] <> d then arif :=False;\n for i:=2 to 3 do\n if m[i-1]*m[i+1] <> m[i]*m[i] then geom:=False;\n\n next:=m[4]*m[4]/m[3];\n k:=round(m[4]*m[4]/m[3]);\n\n if Abs(next-k)>0.00001 then geom:=False;\n\n if arif then Writeln(m[4]+d)\n else if geom then Writeln(m[4]*m[4]/m[3]:0:0)\n else Writeln(42);\n\n\nend."}, {"source_code": "Uses Math,SysUtils;\nVar I,J,L,H,R,G,X,Y,DX,DY,K,H1,ma:Integer;P1,T,N,M:Int64;R1,A,B,C,D:Extended;F:array[1..100] of Boolean;S:String;m1:array[1..100] of Char;p:array[1..1000,1..1000] of char;\nBegin\n ///reset(input,'Input.txt');\n ///assign(output,'Output.txt');\n readln(A,B,C,D);\n If ((A-B)=(B-C)) and ((B-C)=(C-D))\n then write((D+(D-C)):0:0)\n else If ((A/B)=(B/C)) and ((B/C)=(C/D)) and (A/B<>1)\n then If (D/(C/D))=Round(D/(C/D))\n then write((D/(C/D)):0:0)\n else write('42')\n else write('42');\nend.\n"}, {"source_code": "Const\n fin='';\n fon='';\nVar\n n: Longint;\n kt: Boolean;\n A: array[1..5] of Longint;\nProcedure Start;\n Begin\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n End;\nProcedure Programe;\n Var i: Longint;\n Begin\n for i:=1 to 4 do read(A[i]);\n kt:=False;\n for i:=1 to 3 do\n if A[i]+A[2]-A[1] <> A[i+1] then kt:=True;\n if kt = False then\n begin\n writeln(A[4]+A[2]-A[1]);\n Exit;\n end;\n kt:=False;\n for i:=1 to 3 do\n if A[i]*A[2]/A[1] <> A[i+1] then kt:=True;\n if frac(A[4]*A[2]/A[1]) <> 0 then kt:=True;\n if kt = False then\n begin\n writeln(A[4]*A[2]/A[1]:0:0);\n Exit;\n end;\n writeln(42);\n End;\nProcedure Finish;\n Begin\n close(input);\n close(output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd."}, {"source_code": "var a,b,c,d: LongInt;\nbegin\n Readln(a,b,c,d);\n \n if ((b-a)=(c-b)) and ((c-b)=(d-c)) then Writeln(2*d-c) else\n\n if (a=0) or (b / a = 0) or (b / a = 1) or (c / b = 0) or (c / b = 1) or (d / c = 0) or (d / c = 1) then Writeln(42) else\n\n if ((b / a)=(c / b)) and ((c / b)=(d / c)) and (sqr(d) mod c = 0) then Writeln(sqr(d) div c) else Writeln(42);\nend."}, {"source_code": "var a:array[1..4]of integer;\n d:array[2..4]of integer;\n q:array[2..4]of real;\n i:byte;\n\nbegin\n for i:=1 to 4 do begin\n read(a[i]);\n if i>1 then begin\n d[i]:=a[i]-a[i-1];\n q[i]:=a[i]/a[i-1];\n end;\n end;\n readln;\n if (d[2]=d[3])and(d[3]=d[4]) then\n writeln(a[4]+d[4])\n else\n if (q[2]=q[3])and(q[3]=q[4]) then\n if (a[4]*a[4]) mod a[3]=0 then\n writeln(a[4]*q[4]:0:0)\n else\n writeln(42)\n else\n writeln(42);\n readln;\nend."}, {"source_code": "var a,b,c,d:longint;\n\nbegin\nreadln(a,b,c,d);\nif(a-b=b-c)and(b-c=c-d) then writeln(d-a+b)\nelse if (a=0)and(b=0)and(c=0)and(d=0) then writeln(0)\nelse if (a*c=b*b)and(b*d=c*c) then\n begin\n if (d*d mod c=0)then writeln(d*d div c)\n else writeln(42);\n end\nelse writeln(42);\nend."}, {"source_code": "Program A;\n\nVar\na,b,c,d,g,f: integer;\ne: real;\nBegin\nRead(a, b, c, d); \nG:=42; f:=1;\nIf (a+c=b+b) and (b+d=c+c) then begin\ne:=d+d-c;\nF:=0;\nEnd;\nIf (a*c=b*b) and (b*d=c*c) then begin\nF:=(d*d) mod c;\ne:=(d*d)/c;\nEnd;\n\nIf f=0 then write(e:0:0) else write(g);\nEnd.\n"}, {"source_code": "{$r-, s-, q-, i-, o+}\nvar\n a, b, c, d, res : extended;\nbegin\n readln(a, b, c, d);\n res := maxlongint;\n if (b / a = c / b) and (c / b = d / c) then res := d * (b / a);\n if (res = trunc(res)) and (res < maxlongint) then begin writeln(trunc(res)); halt(0); end;\n if (b - a = c - b) and (c - b = d - c) then writeln(trunc(d + b - a)) else writeln(42);\nend."}, {"source_code": " var a,b,c,d:integer;\n e:real;\nbegin\n readln(a,b,c,d);\n if (a-b=b-c)and(b-c=c-d)\n then e:=d-(a-b)\n else if (a/b=b/c)and(b/c=c/d) \n then e:=d/(a/b)\n else e:=42;\n if frac(e)<>0 then e:=42;\n writeln(e:0:0);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram proA328;\nuses\n math;\nconst\n fi = 'PROA.INP';\nvar\n u1, u2, u3, u4 : Integer;\n\nbegin\n readln(u1, u2, u3, u4);\n if ((u2 - u1 = u3 - u2) and (u3 - u2 = u4 - u3)) then\n begin\n writeln(u4 + (u2 - u1));\n halt;\n end else\n if ((u2 / u1) = (u3 / u2)) and ((u3 / u2) = (u4 / u3)) then\n begin\n if (frac(u4 * (u2 / u1)) <> 0) then\n begin\n writeln(42);\n halt;\n end;\n writeln(u4 * (u2 / u1) : 0 : 0);\n halt;\n end;\n writeln(42);\n\nend."}, {"source_code": "program work;\nvar a:array[1..10] of longint;\n i,j,n,m,t:longint;ans:double;\nbegin\n for i:=1 to 4 do\n read(a[i]);\n n:=a[1]-a[2];\n m:=a[2]-a[3];\n t:=a[3]-a[4];\n if (n=m)and(n=t)and(t=m) then\n begin\n writeln(a[4]-t);\n halt;\n end;\n n:=a[1]*a[4];\n m:=a[2]*a[3];\n if n<>m then begin writeln('42');halt;end;\n n:=a[1]*a[3];\n m:=a[2]*a[2];\n if n<>m then begin writeln('42');halt;end;\n n:=a[2]*a[4];\n m:=a[3]*a[3];\n if n<>m then begin writeln('42');halt;end;\n if (a[1]-a[3]<0)and(a[2]-a[4]>0) then begin writeln('42');halt;end;\n if (a[1]-a[3]>0)and(a[2]-a[4]<0) then begin writeln('42');halt;end;\n n:=a[4]*a[4];\n m:=a[3];t:=0;\n for i:=1 to 20000 do\n if i*m=n then t:=i;\n if t=0 then writeln('42') else writeln(t);\nend.\n"}, {"source_code": "var\n a,b,c,d:longint;\n\n\nbegin\n\n readln(a,b,c,d);\n if (b-a=c-b) and (c-b=d-c) then writeln(d+b-a) else\n if (b/a=c/b) and (c/b=d/c) and (frac(d*b/a)=0) then writeln(trunc(d*b/a)) else\n writeln(42);\n\nend."}, {"source_code": "var a:array[1..4] of longint;\n p:longint;\nbegin\n readln(a[1],a[2],a[3],a[4]);\n p:=a[2]-a[1];\n if (a[2]+p=a[3]) and (a[3]+p=a[4]) then writeln(a[4]+p) else\n if (a[2]/a[1]=a[3]/a[2]) and (a[3]/a[2]=a[4]/a[3])\n and (frac(a[4]*a[2]/a[1])=0) then writeln(trunc(a[4]*a[2]/a[1])) else\n writeln(42);\nend.\n\n"}], "negative_code": [{"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b / a;// На ноль делить нельзя\n if b<>0 then p2 := c / b;\n if c<>0 then p3 := d / c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)and(p1<>0)//!!!\n then writeln(trunc(d * p1))//Целое число должно бытьб не real:)!!!\n else writeln(42)\n end\n //else writeln(42)\n //readln !!!!!\nend."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b / a;// На ноль делить нельзя\n if b<>0 then p2 := c / b;\n if c<>0 then p3 := d / c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)and(p1<>0)and(trunc(d * b/a)<>0)// Целое число!!!!\n then writeln(trunc(d * b/a))//Целое число должно быть не real:)!!! \n //1/3\n else writeln(42)\n end\n //else writeln(42)\n //readln !!!!!\nend."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3: real;\n\nbegin\n readln(a, b, c, d);\n if ((a > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))\n then begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1 := b / a;\n p2 := c / b;\n p3 := d / c;\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)\n then writeln(d * p1)\n else writeln(42)\n end\n else writeln(42)\nend.\n"}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3: real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n if ((a > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))\n then begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1 := b / a;\n p2 := c / b;\n p3 := d / c;\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)\n then writeln(d * p1)\n else writeln(42)\n end\n else writeln(42)\nend.\n"}, {"source_code": "var a,b,c,d:word; e:integer;\nbegin\n read(a,b,c,d);\n e:=b-a;\n if (c=a+e shl 1) and (d=a+e*3) then write(a+e shl 2)\n else if b mod a=0 then\n begin\n e:=b div a;\n if (c=b*e) and (d=c*e) then write(d*e)\n else write(42)\n end\n else write(42)\nend."}, {"source_code": "program qq;\nconst eps = 1e-9;\n\nvar n,d,x,i:integer;\n q,l:real;\n a:array[1..10000] of integer;\n\nbegin\nd:=0;\nq:=0;\nx:=0;\nfor i:=1 to 4 do read(a[i]);\n//if (a[1]=a[2]) and (a[1]=a[3]) and (a[1]=a[4]) then begin\n//write(a[1]);\n{halt;}\n//end;\nif (a[2]-a[1]=a[3]-a[2]) and (a[2]-a[1]=a[4]-a[3]) then begin\nd:=a[2]-a[1];\nwrite(a[4]+d);\nx:=1;\nend\nelse\nif (abs(a[2]/a[1]-a[3]/a[2])1) then writeln(trunc(d*c/b)) else\n writeln(42);\nend."}, {"source_code": "var\n a,b,c,d:longint;\nbegin\n readln(a,b,c,d);\n if b+b=a+c then writeln(d+c-b) else\n if c*c=b*d then writeln(trunc(d*c/b)) else\n writeln(42);\nend."}, {"source_code": "program cf(input,output);\nvar\na,b,c,d,s:longint;\nbegin\nread(a,b,c,d);\nif b-a=c-b then\ns:=d+b-a else\ns:=trunc(d*b/a);\nwriteln(s);\nend."}, {"source_code": "var\n a,b,c,d:longint;\nbegin\n readln(a,b,c,d);\n if b+b=a+c then writeln(d+c-b)\n else writeln(trunc(d*c/b));\nend."}, {"source_code": "program cf(input,output);\nvar\na,b,c,d,s:longint;\nbegin\nread(a,b,c,d);\nif b-a=c-b then\ns:=d+b-a else\ns:=d*trunc(b/a);\nwriteln(s);\nend."}, {"source_code": "var\n a,b,c,d:longint;\nbegin\n readln(a,b,c,d);\n if (b+b=a+c)and(c+c=b+d) then writeln(d+c-b) else\n if (c*c=b*d)and(b*b=a*c) then writeln(trunc(d*c/b)) else\n writeln(42);\nend."}, {"source_code": "var\n i,e: longint;\n n,m,o,p,q,r: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[2]-b[1]);\n m:=(b[3]-b[2]);\n o:=(b[4]-b[3]);\n p:=(b[2]/b[1]);\n q:=(b[3]/b[2]);\n r:=(b[4]/b[3]);\n if(n=m)and(m=o)then\n writeln((b[4]+b[4]-b[3]):0:0)\n else if(p=q)and(q=r)then\n writeln((b[4]*b[4]/b[3]):0:0)\n else\n writeln(e);\nend."}, {"source_code": "var\n i,e: longint;\n n,m,o,p,q,r,s: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[2]-b[1]);\n m:=(b[3]-b[2]);\n o:=(b[4]-b[3]);\n p:=(b[2]/b[1]);\n q:=(b[3]/b[2]);\n r:=(b[4]/b[3]);\n s:=(b[4]*b[4]/b[3]);\n if(n=m)and(m=o)then\n writeln((b[4]+b[4]-b[3]):0:0)\n else if(p=q)and(q=r)then\n begin\n if s<1 then\n writeln(e)\n else\n writeln((b[4]*b[4]/b[3]):0:0);\n end\n else\n writeln(e);\nend."}, {"source_code": "var\n i,e: longint;\n t: integer;\n n,m,o,p,q,r,s: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[2]-b[1]);\n m:=(b[3]-b[2]);\n o:=(b[4]-b[3]);\n p:=(b[2]/b[1]);\n q:=(b[3]/b[2]);\n r:=(b[4]/b[3]);\n s:=(b[4]*b[4]/b[3]);\n t:=round(s);\n if(n=m)and(m=o)then\n writeln((b[4]+b[4]-b[3]):0:0)\n else if(p=q)and(q=r)then\n begin\n if s<1 then\n writeln(e)\n else if s<>t then\n writeln(e)\n else if s=t then\n writeln((b[4]*b[4]/b[3]):0:2);\n end\n else\n writeln(e);\nend."}, {"source_code": "var\n i,e: longint;\n n,m,o,p,q,r: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[1]-b[2]);\n m:=(b[2]-b[3]);\n o:=(b[3]-b[4]);\n p:=(b[2]/b[1]);\n q:=(b[3]/b[2]);\n r:=(b[4]/b[3]);\n if(n=m)and(m=o)then\n writeln((b[4]-n):0:0)\n else if(p=q)and(q=r)then\n writeln((b[4]*o):0:0)\n else\n writeln(e);\nend."}, {"source_code": "var\n i,e: longint;\n n,m,o,p: real;\n b: array[1..10]of real;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[1]-b[2]);\n m:=(b[2]-b[3]);\n o:=(b[2]/b[1]);\n p:=(b[3]/b[2]);\n if n=m then\n writeln((b[4]-n):0:0)\n else if o=p then\n writeln((b[4]*o):0:0)\n else\n writeln(e);\nend."}, {"source_code": "var\n i,e: longint;\n n,m,o,p,q,r: integer;\n b: array[1..10]of integer;\nbegin\n e:=42;\n for i:=1 to 4 do\n read(b[i]);\n n:=(b[1]-b[2]);\n m:=(b[2]-b[3]);\n o:=(b[3]-b[4]);\n p:=(b[2]div b[1]);\n q:=(b[3]div b[2]);\n r:=(b[4]div b[3]);\n if(n=m)and(m=o)then\n writeln((b[4]-n))\n else if(p=q)and(q=r)then\n writeln((b[4]*b[4]/b[3]):0:0)\n else\n writeln(e);\nend."}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n p:=0;\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)and(frac(a[4]*x)<>0)then\n begin\n writeln(a[4]*x:0:0);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n p:=0;\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(frac(x)<>0)then exit;\n if(p=0)and(a[4]*x>0)then\n begin\n writeln(a[4]*x:0:0);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n p:=0;\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]*x:0:0);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n p:=0;\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)and(a[4]*x>0)then\n begin\n writeln(a[4]*x:0:0);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "var n,i,j:longint;\n a:array[0..4]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\nprocedure arifmetr;\nvar x,i,p,cons:longint;\n begin\n p:=0;\n cons:=a[2]-a[1];\n for i:=2 to n do\n begin\n x:=a[i]-a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]+x);\n halt(0);\n end;\n end;\nprocedure geometr;\nvar i,p:longint;\n x,cons:extended;\n begin\n cons:=a[2]/a[1];\n for i:=2 to n do\n begin\n x:=a[i]/a[i-1];\n if(x<>cons)then\n begin\n p:=1;\n break;\n end;\n end;\n if(p=0)then\n begin\n writeln(a[4]*x);\n halt(0);\n end;\n end;\n begin\n n:=4;\n for i:=1 to n do\n read(a[i]);\n arifmetr;\n geometr;\n writeln(42);\n end."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b / a;// На ноль делить нельзя\n if b<>0 then p2 := c / b;\n if c<>0 then p3 := d / c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)and(p1<>0)//!!!\n then writeln(trunc(d * b/a))//Целое число должно бытьб не real:)!!! \n //1/3\n else writeln(42)\n end\n //else writeln(42)\n //readln !!!!!\nend."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3, p1, p2, p3: longint;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n if ((a > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))\n then begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1 := b div a;\n p2 := c div b;\n p3 := d div c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)\n then writeln(d * p1)\n else writeln(42)\n end\n else writeln(42);\n readln\nend.\n"}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b div a;// На ноль делить нельзя\n if b<>0 then p2 := c div b;\n if c<>0 then p3 := d div c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)and(p1<>0)//!!!\n then writeln(trunc(d * p1))//Целое число должно бытьб не real:)!!!\n else writeln(42)\n end\n //else writeln(42)\n //readln !!!!!\nend."}, {"source_code": "Program z328A;\n\nvar\n a, b, c, d, s1, s2, s3: longint;\n p1, p2, p3:real;\n\nbegin\n readln(a, b, c, d);\n if (a = b)and(b = c)and(c = d) then writeln(a)\n else\n //if ((aa > b)and(b > c)and(c > d)) or ((a < b)and(b < c)and(c < d))//Знакочередование может быть в случае с геом прогр\n // then \n begin\n s1 := b - a;\n s2 := c - b;\n s3 := d - c;\n p1:=0;p2:=0;p3:=0;\n if a<>0 then p1 := b div a;// На ноль делить нельзя\n if b<>0 then p2 := c div b;\n if c<>0 then p3 := d div c;\n //writeln(p1,' ',p2,' ',p3);\n if (s1 = s2)and(s2 = s3)\n then writeln(d + s1)\n else if (p1 = p2)and(p2 = p3)\n then writeln(trunc(d * p1))//Целое число должно бытьб не real:)!!!\n else writeln(42)\n end\n //else writeln(42)\n //readln\nend."}, {"source_code": "Var z,i:longint;\nch1,zn1,ch,zn:longint;\nf:boolean;\nm:array [1..100] of longint;\nfunction nod(a,b:longint):longint;\nbegin\n if b>a\n then nod:=nod(b,a)\n else if b=0\n then nod:=a\n else nod:=nod(b,a mod b);\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n for i:=1 to 4 do\n read(m[i]);\n z:=m[2]-m[1];\n f:=true;\n for i:=3 to 4 do\n if m[i]-m[i-1]<>z\n then f:=false;\n if f\n then begin\n writeln(m[4]+z);\n halt(0);\n end;\n ch:=m[2];\n zn:=m[1];\n z:=nod(m[2],m[1]);\n ch:=ch div z;\n zn:=zn div z;\n f:=true;\n for i:=3 to 4 do\n begin\n ch1:=m[i];\n zn1:=m[i-1];\n z:=nod(m[i],m[i-1]);\n ch1:=ch1 div z;\n zn1:=zn1 div z;\n if (ch1<>ch)or(zn1<>zn)\n then f:=false;\n end;\n if (m[4]*ch) mod zn<>0\n then f:=false;\n if f\n then writeln(42)\n else writeln((m[4]*ch) div zn);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar m: array [1..10] of Integer;\n x,y,z,t: Integer;\n arif, geom: Boolean;\n next: Real;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n Readln(x,y,z,t);\n if (y-x = z-y) and (t-z = z-y ) then Writeln(2*t-z)\n else\n if (y/x=z/y) and (t/z=z/y) then\n if Frac(t*t/z) = 0 then Writeln(t*t/z :0:0)\n else writeln(42);\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar m: array [1..10] of Integer;\n i,j,k,d,q: Integer;\n arif, geom: Boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n for i:=1 to 4 do Read(m[i]);\n arif:=True;\n geom:=True;\n d:=m[2]-m[1];\n\n for i:=2 to 4 do\n if m[i]-m[i-1] <> d then arif :=False;\n for i:=2 to 3 do\n if m[i-1]*m[i+1] <> m[i]*m[i] then geom:=False;\n if arif then Writeln(m[4]+d)\n else if geom then Writeln(m[4]*m[4]/m[3]:0:2)\n else Writeln(42);\n\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar m: array [1..10] of Integer;\n i,j,k,d,q: Integer;\n arif, geom: Boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n for i:=1 to 4 do Read(m[i]);\n arif:=True;\n geom:=True;\n d:=m[2]-m[1];\n\n for i:=2 to 4 do\n if m[i]-m[i-1] <> d then arif :=False;\n for i:=2 to 3 do\n if m[i-1]*m[i+1] <> m[i]*m[i] then geom:=False;\n if arif then Writeln(m[4]+d)\n else if geom then Writeln(m[4]*m[4]/m[3]:0:0)\n else Writeln(42);\n\n\nend.\n"}], "src_uid": "68a9508d49fec672f9c61766d6051047"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n st1, st2 : string;\n h1, h2, m1, m2, h3, m3 : integer;\nbegin\n readln(st1);\n //readln;\n readln(st2);\n h1 := strtoint(copy(st1, 1, 2));\n m1 := strtoint(copy(st1, 4, 2));\n h2 := strtoint(copy(st2, 1, 2));\n m2 := strtoint(copy(st2, 4, 2));\n //writeln(h1, m1, h2, m2);\n m3 := (m1 + m2) div 2;\n m3 := (h1+h2) mod 2 * 30 + m3;\n h3 := (h1 + h2) div 2 + m3 div 60;\n m3 := m3 mod 60;\n if (h3 < 10) then\n write(0);\n write(h3, ':');\n if (m3 < 10) then\n write(0);\n write(m3);\n readln;\n readln;\nend.\n ", "positive_code": [{"source_code": "var s,z,a,i,n:longint;q:char;w:string;d:array['0'..'9']of longint;\nbegin\nd['0']:=0;\nfor q:='1' to '9' do d[q]:=d[pred(q)]+1;\n reADln (w);s:=(d[w[1]]*10+d[w[2]])*60+d[w[4]]*10+d[w[5]];\n reAD (w);S:=(s+(d[w[1]]*10+d[w[2]])*60+d[w[4]]*10+d[w[5]] )div 2;\n if s div 60<10 then write(0);write(s div 60,':');if s mod 60<10 then write(0);write(s mod 60);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n s,s1,st,st1,kq,ss,ss1,kqs,kqs1:ansistring;\n so,so1,d,d1,sso,sso1,t1,t2,t3,h3,m3:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,st);\n readln(f,st1);\n\n assign(f,fo);rewrite(f);\n s:=st[1]+st[2];\n s1:=st[4]+st[5];\n ss:=st1[1]+st1[2];\n ss1:=st1[4]+st1[5];\n val(s,so);\n val(s1,so1);\n val(ss,sso);\n val(ss1,sso1);\n t1:=so*60+so1;\n t2:=sso*60+sso1;\n t3:=(t1+t2) div 2;\n h3:=t3 div 60;\n m3:=t3 mod 60;\n str(h3,kqs);\n str(m3,kqs1);\n if length(kqs) = 1 then kqs:='0'+kqs;\n if length(kqs1)=1 then kqs1:='0'+kqs1;\n kq:=kqs+':'+kqs1;\n write(f,kq);\n close(f);\nend.\n"}, {"source_code": "Var S,F,SS1,SS2:String;\n num1,num2,num3,num4:Longint;\nBegin\n Readln(S); Readln(F);\n Val(Copy(S,1,2),num1);\n Val(Copy(S,4,2),num2);\n Val(Copy(F,1,2),num3);\n Val(Copy(F,4,2),num4);\n Str((num1+num3) div 2,SS1);\n If (num2+num4) div 2 + (num1+num3) mod 2 * 30 > 59 then begin\n Str((num1+num3) div 2 + 1,SS1);\n Str((num2+num4) div 2 + (num1+num3) mod 2 * 30 - 60,SS2);\n End\n Else Str((num2+num4) div 2 + (num1+num3) mod 2 * 30,SS2);\n If length(SS1)=1 then SS1:='0'+SS1;\n If length(SS2)=1 then SS2:='0'+SS2;\n Writeln(SS1+':'+SS2);\nEnd."}, {"source_code": "Var a,b:array[0..6] of byte;\n kq,kq1,kq2,kq3,m,m1,i,kq4:integer;\n s,ss,t,t1:string;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Readln(s);\n Readln(ss);\n\n For i:=1 to length(s) do\n if (s[i]<>':') then\n begin\n a[i]:=ord(s[i]) - 48;\n b[i]:=ord(ss[i]) - 48;\n end;\n kq:= 10*a[1]+a[2];\n kq1:=10*b[1]+b[2];\n kq2:= 10*a[4]+a[5];\n kq3:= 10*b[4]+b[5];\n // m:= (kq+kq1) div 2;\n // m1:=(kq2+kq3) div 2;\n // If (m1 >60) then\n // begin\n // m:=m+1;\n // m1:=m1-60;\n // end;\n {If (kq2 =0) and (kq3=0) then\n begin\n m:= (kq+kq1) div 2;\n str(m,t1);\n t1:=t1+':';\n t1:=t1+'30';\n end\n else\n begin }\n m:=(kq1*60+kq3)-(kq*60+kq2);\n m:= m div 2;\n kq4:=kq2+m;\n m1:= kq4 div 60;\n kq:=kq+m1;\n str(kq,t1);\n If (length(t1)<>2) then t1:='0'+t1;\n kq4:=kq4 - (m1*60);\n str(kq4,t);\n If (length(t)<>2) then t:='0'+t;\n t1:=t1+':';\n t1:=t1+t;\n\n Writeln(t1);\n Close(input);\n Close(output);\nEnd."}, {"source_code": "\n var j,l,r,code:longint;\n h1,h2,h3,m1,m2,m3:longint;\n t1,t2,t3:longint;\n c:char;\ns,s1:string;\ner:integer;\nbegin\n\nreadln(s);\ns1:=copy(s,1,2);\nval(s1,h1,er);\ns1:=copy(s,4,2);\nval(s1,m1,er);\nt1:=60*h1+m1;\nreadln(s);\ns1:=copy(s,1,2);\nval(s1,h2,er);\ns1:=copy(s,4,2);\nval(s1,m2,er);\nt2:=60*h2+m2;\nt3:=round((t1+t2)/2);\nh3:=t3 div 60;\nm3:=t3 mod 60;\nif (h3<10) then write('0',h3)\nelse write(h3);\nwrite(':');\nif (m3<10) then write('0',m3)\nelse write(m3);\nend."}, {"source_code": "var\ns:string;\nq,h1,m1,h2,m2:longint;\nbegin\nreadln(s);\nh1:=(ord(s[1])-48)*10+ord(s[2])-48;\nm1:=(ord(s[4])-48)*10+ord(s[5])-48;\n\n\nreadln(s);\nh2:=(ord(s[1])-48)*10+ord(s[2])-48;\nm2:=(ord(s[4])-48)*10+ord(s[5])-48;\n\n\n\n//if m1>=m2 then begin\n// inc(h1);\n// m1:=0;\n//end;\n\nq:=h1*60 + m1;\nq:=q + h2*60 + m2;\nq:=q div 2;\nif q div 60 <=9 then write(0);\nwrite(q div 60);\nwrite(':');\nif q mod 60<=9 then write(0);\nwrite(q mod 60);\n//writeln((h1+h2) div 2,' ',(m1+m2) div 2);\nend.\n\n"}, {"source_code": "var c:char;\n h1,m1,h2,m2,t1,t2,tm:longint;\nbegin\n read(c);h1:=ord(c)-48;\n read(c);h1:=h1*10+ord(c)-48;\n read(c);\n read(c);m1:=ord(c)-48;\n read(c);m1:=m1*10+ord(c)-48;\n readln;\n read(c);h2:=ord(c)-48;\n read(c);h2:=h2*10+ord(c)-48;\n read(c);\n read(c);m2:=ord(c)-48;\n read(c);m2:=m2*10+ord(c)-48;\n readln;\n t1:=h1*60+m1;\n t2:=h2*60+m2;\n tm:=(t1+t2)>>1;\n writeln(tm div 600,tm div 60 mod 10,':',tm mod 60 div 10,tm mod 10);\nend."}, {"source_code": "var h1,m1,h2,m2:longint;tg:qword;k:string;\nbegin\n \n readln(k);\n val(copy(k,1,2),h1);\n val(copy(k,pos(':',k)+1,2),m1);\n readln(k);\n val(copy(k,1,2),h2);\n val(copy(k,pos(':',k)+1,2),m2);\n tg:=(h2-h1)*60+m2-m1;\n tg:=tg div 2;m1:=m1+tg;\n while m1>=60 do\n begin\n dec(m1,60);inc(h1);\n end;\n if h1>=10 then write(h1,':') else write('0',h1,':');\n if m1>=10 then write(m1) else write('0',m1);\n \nend.\n"}, {"source_code": "program jam;\n\nvar\ns:string;\njam1,jam2:longint;\nmenit1,menit2:longint;\ntemp1,temp2:string;\nselisihJam,selisihMenit:longint;\ntambahanJam:longint;\ntambahanMenit:longint;\ntotalMenit:longint;\nhasilMenit,hasilJam:longint;\n\nbegin\n\treadln (s);\n\ttemp1 := s[1] + s[2];\n\ttemp2 := s[4] + s[5];\n\tval (temp1, jam1);\n\tval (temp2, menit1);\n\treadln (s);\n\ttemp1 := s[1] + s[2];\n\ttemp2 := s[4] + s[5];\n\tval (temp1, jam2);\n\tval (temp2, menit2);\n\tselisihJam := jam2 - jam1;\n\tselisihMenit := menit2 - menit1;\n\ttotalMenit := (60*selisihJam) + selisihMenit;\n\ttotalMenit := totalMenit div 2;\n\ttambahanJam := totalMenit div 60;\n\ttambahanMenit := totalMenit mod 60;\n\thasilJam := jam1+tambahanJam;\n\thasilMenit := menit1+tambahanMenit;\n\tif (hasilMenit >= 60) then\n\tbegin\n\t\thasilJam := hasilJam + (hasilMenit div 60);\n\t\thasilMenit := hasilMenit mod 60;\n\tend;\n\tif (hasilJam < 10) then\n\tbegin\n\t\tif (hasilMenit < 10) then\n\t\tbegin\n\t\t\twriteln ('0',hasilJam,':0',hasilMenit);\n\t\tend else\n\t\tbegin\n\t\t\twriteln ('0',hasilJam,':',hasilMenit);\n\t\tend;\n\tend else\n\tbegin\n\t\tif (hasilMenit < 10) then\n\t\tbegin\n\t\t\twriteln (hasilJam,':0',hasilMenit);\n\t\tend else\n\t\tbegin\n\t\t\twriteln (hasilJam,':',hasilMenit);\n\t\tend;\n\tend;\nend."}, {"source_code": "procedure ReadTime (var h, m: Integer);\nvar\n s: string;\n\nbegin\n ReadLn (s);\n\n h := (Ord (s[1]) - Ord ('0')) * 10 + (Ord (s[2]) - Ord ('0'));\n m := (Ord (s[4]) - Ord ('0')) * 10 + (Ord (s[5]) - Ord ('0'));\nend;\n\nprocedure WriteTime (mh, mm: Integer);\nbegin\n if mh <= 9 then\n Write ('0', mh)\n else\n Write (mh);\n\n Write (':');\n\n if mm <= 9 then\n Write ('0', mm)\n else\n Write (mm)\nend;\n\nvar\n h1, m1, h2, m2: Integer;\n mh, mm: Integer;\n\nbegin\n ReadTime (h1, m1);\n ReadTime (h2, m2);\n\n m1 := h1 * 60 + m1;\n m2 := h2 * 60 + m2;\n\n mm := (m2 + m1) div 2;\n mh := mm div 60;\n mm := mm mod 60;\n\n WriteTime (mh, mm)\nend.\n"}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\nm:=c;\na:= a*60 + c;\na1:= a1*60 + c1;\nb:= a1-a;\nb:=b div 2;\nc:=c+b;\ni:= c mod 60;\nc:= c div 60;\nm:=g+c;\nb1:=i;\n\n\nif (b1 >=10) and(m>=10 ) then writeln(m,':',b1);\nif (b1 <10) and(m <10) then writeln('0',m,':','0',b1);\nif (b1 <10) and(m >=10) then writeln(m,':','0',b1);\nif (b1 >=10) and(m <10) then writeln('0',m,':',b1);\n\nend.\n\n"}, {"source_code": "Program t_0;\nvar h1,h2,m1,m2,ha,ma,delta_min : integer;\nvar s1, s2 :string;\nbegin\n\nreadln(s1);\nreadln(s2);\n\nh1 := (ord(s1[1]) - ord('0')) * 10 + (ord(s1[2]) - ord('0'));\n\nm1 := (ord(s1[4]) - ord('0')) * 10 + (ord(s1[5]) - ord('0'));\nh2 := (ord(s2[1]) - ord('0')) * 10 + (ord(s2[2]) - ord('0'));\nm2 := (ord(s2[4]) - ord('0')) * 10 + (ord(s2[5]) - ord('0'));\n\ndelta_min := (h2 - h1) * 60 + m2 - m1;\ndelta_min := (delta_min div 2);\n\nma := m1 + delta_min;\nha := h1 + (ma div 60);\nma := (ma mod 60);\n\nif (ha < 10) then write('0');\nwrite(ha,':');\nif (ma < 10) then write('0');\nwrite(ma);\nend."}, {"source_code": "var\n s1,s2:string;\n ch1,ch2,n,i,m1,m2,sum1,sum2,sum:integer;\nbegin\n readln(s1);\n readln(s2);\n ch1:=strtoint(copy(s1,1,2));\n ch2:=strtoint(copy(s2,1,2));\n m1:=strtoint(copy(s1,4,2));\n m2:=strtoint(copy(s2,4,2));\n //writeln(ch1,' ',m1);\n //writeln(ch2,' ',m2);\n sum1:=ch1 * 60 + m1;\n sum2:= ch2*60 + m2;\n sum:=sum1+sum2;\n sum:=sum div 2;\n ch1:=sum div 60;\n m2:=sum mod 60;\n s1:=inttostr(ch1);\n if length(s1)<2 then\n s1:='0'+s1;\n s2:=inttostr(m2);\n if length(s2)<2 then\n s2:='0'+s2;\n writeln(s1,':',s2);\n \nend."}, {"source_code": "program kontest;\nvar\nh1,h2,m1,m2,h3:byte;\nm3:smallint;\ndlit:word;\ns,s1:string;\nerr:integer;\nbegin\nReadln(s);\ns1:=Copy(s,1,2);\nVal(s1,h1,err);\ns1:=Copy(s,4,2);\nVal(s1,m1,err);\nReadln(s);\ns1:=Copy(s,1,2);\nVal(s1,h2,err);\ns1:=Copy(s,4,2);\nVal(s1,m2,err);\nh3:=h2-h1;\nm3:=m2-m1;\ndlit:=60*h3+m3;\ndlit:=dlit div 2;\nh1:=h1+dlit div 60;\nm1:=m1+dlit mod 60;\nif m1>=60 then \n begin\n h1+=1;\n m1:=m1 mod 60;\n end;\nif h1<10 then write(0,h1,':') else write(h1,':');\nif m1<10 then write(0,m1) else write(m1);\nend.\n\n\n"}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1=0)and(m2=0) then begin\n if (h2-h1) mod 2 = 1 then begin \n m2:=m2+60;\n l:=h1+((h2-h1-1) div 2);\n l1:=(m2-m1) div 2;\n end\n else begin\n l:=(h2+h1) div 2;\n l1:=0;\n end;\n \n \n \n \n end\n else if m1>m2 then begin\n h2:=h2-1;\n m2:=m2+60;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n \n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n if (h2-h1) mod 2 = 1 then begin h2:=h2-1;m2:=m2+60;end;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n if l1>=60 then begin l:=l+1;l1:=l1 mod 60;end;\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "program zA;\n\nvar\n a, b, s: string;\n h1, m1, h2, m2, code, time: integer;\n h3, m3: integer;\n \nbegin\n readln(a);\n readln(b);\n s:=a[1]+a[2];\n val(s, h1, code);\n s:=a[4]+a[5];\n val(s, m1, code);\n \n s:=b[1]+b[2];\n val(s, h2, code);\n s:=b[4]+b[5];\n val(s, m2, code);\n \n time:=(h1*60 + m1 + h2*60 + m2) div 2;\n h3:=time div 60;\n m3:=time mod 60;\n if h3<10 then write('0',h3) else write(h3);\n write(':');\n if m3<10 then write('0', m3) else write(m3);\nend."}, {"source_code": "var s1,s2:string;\ni,j,k,l,m,n:longint;\nbegin\nreadln(s1);\nread(s2);\nm:=(ord(s1[1])-48)*600+(ord(s1[2])-48)*60+(ord(s1[4])-48)*10+ord(s1[5])-48;\n\nn:=(ord(s2[1])-48)*600+(ord(s2[2])-48)*60+(ord(s2[4])-48)*10+ord(s2[5])-48;\nk:=(m+n) div 2;\nl:= k div 60;\nk:=k-l*60;\nstr(l,s1);str(k,s2);\nif length(s1)=1 then s1:='0'+s1;\nif length(s2)=1 then s2:='0'+s2;\nwrite(s1,':',s2)\nend.\n"}, {"source_code": "var s,s1:string;h,m,h1,m1,x,y,z:longint;\nbegin\nreadln(s);\nreadln(s1);\nh:=strtoint(s[1])*10+strtoint(s[2]);\nm:=strtoint(s[4])*10+strtoint(s[5]);\nh1:=strtoint(s1[1])*10+strtoint(s1[2]);\nm1:=strtoint(s1[4])*10+strtoint(s1[5]);\nx:=h*60+m;\ny:=h1*60+m1;\nz:=(y-x) div 2;\nh+=(z+m) div 60;\nm:=(z+m) mod 60;\nwrite(h div 10,h mod 10,':',m div 10,m mod 10);\nend."}, {"source_code": "var a,b,c,d,q,z,x,n,v:integer;\ns,a1,b1,c1,d1 :string;\nbegin\nREADln(s);\na1:=copy(s,1,2);\nb1:=copy(s,4,2);\nval(a1,a,q);\nval(b1,b,q);\nz:=a*60+b;\nREADln(s);\nc1:=copy(s,1,2);\nd1:=copy(s,4,2);\nval(c1,c,q);\nval(d1,d,q);\nx:=c*60+d;\nv:=round((x+z)/2);\na:=0;\nwhile v>59 do\nbegin\na:=a+1;\nv:=v-60;\nend;\nif (a< 10) and (v<10) then\nwriteln('0',a,':','0',v);\nif (a< 10) and (v>9) then\nwriteln('0',a,':',v);\nif (a> 9) and (v<10) then\nwriteln(a,':','0',v);\nif (a> 9) and (v>9) then\nwriteln(a,':',v)\nend."}, {"source_code": "var\ns1,s2,wh1,wm1,ans:string;\nq1,q2,qq,m1,m2,h1,hq,mq,h2:integer;\nbegin\nreadln(s1);\nreadln(s2);\nh1:=strtoint(copy(s1,1,2));\nh2:=strtoint(copy(s2,1,2));\nm1:=strtoint(copy(s1,4,2));\nm2:=strtoint(copy(s2,4,2));\nhq:=(h2-h1) div 2;\nmq:=(m2-m1) div 2;\nif (h2-h1) mod 2 = 1 then begin q1:=h1+hq; q2:=m1+mq+30; end else begin\nq1:=h1+hq;\nq2:=m1+mq;\nend;\nif q2>59 then begin q2:=q2-60; inc(q1); end;\nwh1:=inttostr(q1);\nwm1:=inttostr(q2);\nif length(wh1)=1 then wh1:='0'+wh1;\nif length(wm1)=1 then wm1:='0'+wm1;\nans:=wh1+':'+wm1;\nwrite(ans);\nend.\n"}, {"source_code": "var\n s1, s2, hh1, hh2, mm1, mm2: string;\n w, q, err, q1, q2, w1, w2, z, a, b: integer;\n\nbegin\n readln(s1);\n readln(s2);\n hh1 := copy(s1, 1, 2);\n mm1 := copy(s1, 4, 2);\n hh2 := copy(s2, 1, 2);\n mm2 := copy(s2, 4, 2);\n val(hh1, q1, err);\n val(hh2, q2, err);\n val(mm1, w1, err);\n val(mm2, w2, err);\n a := q2 * 60 + w2;\n b := q1 * 60 + w1;\n z := (a - b) div 2;\n q := (b + z) div 60;\n w := (b + z) mod 60;\n if q < 10 then\n write('0', q)\n else\n write(q);\n write(':');\n if w < 10 then\n write('0', w)\n else\n write(w);\nend."}, {"source_code": "var\n vvod: string;\n h1, h2, m1, m2, min1, min2, razn: integer;\nbegin\n readln(vvod);\n h1 := StrToInt(copy(vvod, 1, 2));\n m1 := StrToInt(copy(vvod, 4, 2));\n readln(vvod);\n h2 := StrToInt(copy(vvod, 1, 2));\n m2 := StrToInt(copy(vvod, 4, 2));\n min1 := h1 * 60 + m1;\n min2 := h2 * 60 + m2;\n razn := Trunc((min2 - min1) / 2);\n min1 += razn;\n h1 := min1 div 60;\n m1 := min1 - ((min1 div 60) *60);\n if (h1 < 10) and (m1 <10) then\n write('0' + IntToStr(h1) + ':0' + IntToStr(m1))\n else if h1 < 10 then\n write('0' + IntToStr(h1) + ':' + IntToStr(m1))\n else if m1 < 10 then\n write(IntToStr(h1) + ':0' + IntToStr(m1))\n else write(IntToStr(h1) + ':' + IntToStr(m1));\nend."}, {"source_code": "Program t_0;\nvar h1,h2,m1,m2,ha,ma,delta_min : integer;\nvar s1, s2 :string;\nbegin\n\nreadln(s1);\nreadln(s2);\n\nh1 := (ord(s1[1]) - ord('0')) * 10 + (ord(s1[2]) - ord('0'));\n\nm1 := (ord(s1[4]) - ord('0')) * 10 + (ord(s1[5]) - ord('0'));\nh2 := (ord(s2[1]) - ord('0')) * 10 + (ord(s2[2]) - ord('0'));\nm2 := (ord(s2[4]) - ord('0')) * 10 + (ord(s2[5]) - ord('0'));\n\ndelta_min := (h2 - h1) * 60 + m2 - m1;\ndelta_min := (delta_min div 2);\n\nma := m1 + delta_min;\nha := h1 + (ma div 60);\nma := (ma mod 60);\n\nif (ha < 10) then write('0');\nwrite(ha,':');\nif (ma < 10) then write('0');\nwrite(ma);\nend."}, {"source_code": "var s,temp:string;\nhours,min,start,close,middle,f:integer;\n\nbegin\n readln(s);\n temp:=s[1]+s[2];\n val(temp,hours,f);\n temp:=s[4]+s[5];\n val(temp,min,f);\n start:= hours*60 + min;\n \n readln(s);\n temp:=s[1]+s[2];\n val(temp,hours,f);\n temp:=s[4]+s[5];\n val(temp,min,f);\n close:= hours*60 + min;\n \n if close 23) then middle:= middle - 24*60;\n \n if (middle div 60 < 10) then write(0);\n write(middle div 60);\n write(':');\n if (middle mod 60 < 10) then write(0);\n write(middle mod 60);\nend."}, {"source_code": "var h1,m1,h2,m2,m,hsr,msr,hsrm : longint;\n s1,s2,h1s,m1s,h2s,m2s : string;\nbegin\n readln(s1);\n readln(s2);\n h1s:=copy(s1,1,2);\n m1s:=copy(s1,4,2);\n h2s:=copy(s2,1,2);\n m2s:=copy(s2,4,2);\n val(h1s,h1,m);\n val(m1s,m1,m);\n val(h2s,h2,m);\n val(m2s,m2,m);\n hsr:=(h1+h2) div 2;\n msr:=(m1+m2) div 2;\n hsrm:=(h1+h2) mod 2;\n if hsrm>0 then msr:=msr+30;\n if msr>=60 then begin\n msr:=msr mod 60;\n inc(hsr);\n end;\n if hsr<10 then write(0,hsr,':')\n else write(hsr,':');\n if msr<10 then write(0,msr)\n else write(msr);\nend."}, {"source_code": "Program t_0;\nvar h1,h2,m1,m2,ha,ma,delta_min : integer;\nvar s1, s2 :string;\nbegin\n\n\nreadln(s1);\nreadln(s2);\n\n\nh1 := (ord(s1[1]) - ord('0')) * 10 + (ord(s1[2]) - ord('0'));\n\nm1 := (ord(s1[4]) - ord('0')) * 10 + (ord(s1[5]) - ord('0'));\nh2 := (ord(s2[1]) - ord('0')) * 10 + (ord(s2[2]) - ord('0'));\nm2 := (ord(s2[4]) - ord('0')) * 10 + (ord(s2[5]) - ord('0'));\n\ndelta_min := (h2 - h1) * 60 + m2 - m1;\ndelta_min := (delta_min div 2);\n\nma := m1 + delta_min;\nha := h1 + (ma div 60);\nma := (ma mod 60);\n\nif (ha < 10) then write('0');\nwrite(ha,':');\nif (ma < 10) then write('0');\nwrite(ma);\nend."}, {"source_code": "var\n s1,s2:string;\n res,s,ss1,ss2: integer;\nbegin\nreadln(s1);\nreadln(s2);\nss1:=(strtoint(s1[1])*10+strtoint(s1[2]))*60+(strtoint(s1[4])*10+strtoint(s1[5]));\nss2:=(strtoint(s2[1])*10+strtoint(s2[2]))*60+(strtoint(s2[4])*10+strtoint(s2[5]));\ns:=(ss2-ss1)div 2;\nres:=ss1+s;\nif res div 60<10 then write(0); write(res div 60,':');\nif res mod 60<10 then write(0); write(res mod 60);\nend."}, {"source_code": "var\n s1,s2:string; \n h1, h2, m1, m2, j: int64;\nbegin\n readln(s1);\n h1 := (ord(s1[1]) - 48) * 10 + (ord(s1[2]) - 48);\n m1 := (ord(s1[4]) - 48) * 10 + (ord(s1[5]) - 48);\n readln(s2);\n h2 := (ord(s2[1]) - 48) * 10 + (ord(s2[2]) - 48);\n m2 := (ord(s2[4]) - 48) * 10 + (ord(s2[5]) - 48);\n \n j := ( (h2-h1)*60 + (m2-m1) ) div 2;\n inc(m1,j);\n inc(h1,m1 div 60);\n m1 := m1 mod 60;\n if (h1 >= 10) then\n write(h1,':')\n else\n write(0,h1,':');\n if (m1 >= 10) then\n write(m1)\n else\n write(0,m1);\nend."}, {"source_code": " program ideone;\n var\n \ti,hour,min:integer;\n \ta,b:string;\n begin\n \treadln(a);\n \treadln(b);\n hour:=(StrToInt(copy(a,1,2)) + StrToInt(copy(b,1,2))) * 60;\n \tmin:=hour + strtoint(copy(a,4,2)) + strtoint(copy(b,4,2)); \n \tmin:= min div 2;\n \thour:= min div 60;\n \tmin:= min mod 60;\n \tif (hour<10) then\n \t if (min<10) then \n \t writeln('0',hour,':0',min) \t else\n \t writeln('0',hour,':',min) else\n if (min<10) then \n \t writeln(hour,':0',min) \t else\n \t writeln(hour,':',min); \n end."}, {"source_code": "var\n s1, s2: string;\n x: longint;\n\nfunction p(c: char): longint;\nbegin\n result := ord(c) - ord('0');\nend;\n\nfunction f(s: string): longint;\nbegin\n result := (p(s[1]) * 10 + p(s[2])) * 60 + p(s[4]) * 10 + p(s[5]);\nend;\n\nbegin\n readln(s1);\n readln(s2);\n x := (f(s1) + f(s2)) div 2;\n if x div 60 < 10 then\n write('0');\n write(x div 60, ':');\n if x mod 60 < 10 then\n write('0');\n write(x mod 60);\nend."}, {"source_code": "Program A1;\nuses math;\nvar H,M,S1,S2,S3,S4:string; i,code,h1,h2,m1,m2:longint;\nProcedure Xuli;\nbegin S1:=''; S2:=''; S3:=''; S4:='';\n for i:=1 to length(h) do\n if H[i]<>':' then\n S1:=S1+H[i]\n else begin S2:=copy(H,i+1,2);\n break;\n end;\n for i:=1 to length(M) do\n if M[i]<>':' then\n S3:=S3+M[i]\n else begin S4:=copy(M,i+1,2);\n break;\n end;\n val(S1,h1,code); val(S2,m1,code);\n val(S3,h2,code); val(S4,m2,code);\nend;\nProcedure Cal;\nbegin m2:=(m2+h1*60+h2*60+m1) div 2;\n h1:=(m2 div 60) ; m1:=(m2 mod 60);\n str(h1,S1); str(m1,S2);\n if length(S1)=1 then S1:='0'+S1;\n if length(S2)=1 then S2:='0'+S2;\n writeln(S1,':',S2);\nend;\nbegin {assign(input,'A1.inp'); reset(input);\n assign(output,'A1.out'); rewrite(output);}\n readln(H); readln(M);\n Xuli;\n Cal;\n {close(input); close(output);}\n\nend.\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,xold,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n ddl,ddr:array[-1..5002,-1..5002] of longint;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4,-1..1300000] of int64;\n sum,ppos,mma,ma:array[-1000..200005,-1..5] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]=24*60 then p:=p-24*60;\n\n { writeln(p);\n }\n for i:=0 to 2 do for j:=0 to 9 do for i1:=0 to 5 do for j1:=0 to 9 do\n begin\n ss:=chr(i+48)+ chr(j+48)+':'+chr(i1+48)+chr(j1+48);\n if chislo(ss)=p then begin write(ss); goto 1; end;\n\n end;\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": "program ideone;\nuses SysUtils;\nvar\n\ts,ss:string;\n\ti,hh,mm:integer;\n\nbegin\n\treadln(s);\n\treadln(ss);\n\t\n\thh:=(StrToInt(copy(s,1,2)) + StrToInt(copy(ss,1,2))) * 60;\n\tmm:=hh + strtoint(copy(s,4,2)) + strtoint(copy(ss,4,2)); \n\t\n\tmm:= mm div 2;\n\t\n\thh:= mm div 60;\n\tmm:= mm mod 60;\n\t\n\t\n\tif (hh<10) then\n\t if (mm<10) then \n\t writeln('0',hh,':0',mm)\n\t else\n\t writeln('0',hh,':',mm)\n else\n if (mm<10) then \n\t writeln(hh,':0',mm)\n\t else\n\t writeln(hh,':',mm); \nend."}, {"source_code": "program Seredina_Kontesta;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,t: string;\n h1,h2,m1,m2,w: integer;\n \nbegin\n readln(s);\n readln(t);\n val(copy(s,1,2),h1,w);\n val(copy(s,4,2),m1,w);\n h1:=h1*60+m1;\n val(copy(t,1,2),h2,w);\n val(copy(t,4,2),m2,w);\n h2:=h2*60+m2;\n w:=abs(h1-h2) div 2;\n if h1>h2 then h1:=h2;\n h1:=h1+w;\n m1:=h1 mod 60;\n h1:=h1 div 60;\n if h1<10 then write(0,h1,':') else write(h1,':');\n if m1<10 then write(0,m1) else write(m1);\n //readln(t);\nend.\n "}, {"source_code": "program z1;\n {$APPTYPE CONSOLE}\n var s1,s2:string;\n ch1,ch2,ch3,m1,m2,p:integer;\nbegin\n readln(s1);\n readln(s2);\n// s1:='01:02';\n// s2:='03:02';\n val(s1[1]+s1[2],ch1,p);\n val(s1[4]+s1[5],m1,p);\n val(s2[1]+s2[2],ch2,p);\n val(s2[4]+s2[5],m2,p);\n ch1:=ch1*60+m1;\n ch2:=ch2*60+m2;\n ch3:=(ch1+ch2) div 2;\n writeln(ch3 div 600,(ch3 mod 600)div 60,':',(ch3 mod 60) div 10,(ch3 mod 60) mod 10);\n// readln;\n\nend.\n"}, {"source_code": "var h1, m1, h2, m2, err, kol, i : longint;\n s : string;\n\nbegin\n readln(s);\n val(copy(s, 1, pos(':', s)-1), h1, err);\n delete(s, 1, pos(':', s));\n val(s, m1, err);\n readln(s);\n val(copy(s, 1, pos(':', s)-1), h2, err);\n delete(s, 1, pos(':', s));\n val(s, m2, err);\n while true do begin\n if (h1 = h2) and (m1 = m2) then \n break;\n if m1 = 59 then begin\n inc(h1);\n m1:=0;\n end else\n inc(m1);\n inc(kol);\n end;\n for i:=1 to kol div 2 do begin\n if m2 = 0 then begin\n dec(h2);\n m2:=59;\n end else \n dec(m2);\n end;\n if h2 < 10 then \n write('0',h2)\n else \n write(h2);\n write(':');\n if m2 < 10 then\n write('0', m2)\n else \n write(m2);\nend."}, {"source_code": "var s:string;\n\ts1,s2:longint;\nbegin\n\treadln (s);\n s1:=60*(10*(ord(s[1]) - ord('0'))+ord(s[2]) - ord('0')) + 10*(ord(s[4]) - ord('0'))+ord(s[5]) - ord('0');\n readln (s);\n s2 := 60*(10*(ord(s[1]) - ord('0'))+ord(s[2]) - ord('0')) + 10*(ord(s[4]) - ord('0'))+ord(s[5]) - ord('0');\n s1:=s1+s2;\n s1:=s1 div 2;\n s2:=s1 mod 60;\n s1:=s1 div 60;\n if (s1 < 10) then write (0);\n write (s1,':');\n if (s2 < 10) then write (0);\n write (s2);\nend."}, {"source_code": "const fi='1133A.inp';\n fo='1133A.out';\nvar f,g:text;\n m,n,i,j,x1,y1,x2,y2,h:longint;\n s1,s2,st:string;\n r1,r2:real;\nprocedure nhap;\nbegin\n {assign(f,fi);reset(f);}\n readln(s1);\n read(s2);\n {close(f);}\nend;\nprocedure xuli;\nbegin\n st:=copy(s1,1,2);\n val(st,x1);\n st:=copy(s2,1,2);\n val(st,x2);\n st:=copy(s1,4,2);\n val(st,y1);\n st:=copy(s2,4,2);\n val(st,y2);\n r1:=(x1+x2)/2;\n h:=trunc(r1);\n m:=(y1+y2) div 2;\n if frac(r1)<>0 then m:=m+30;\n if m>=60 then\n begin\n h:=h+1;\n m:=m mod 60;\n end;\nend;\nprocedure xuat;\nbegin\n {assign(g,fo);rewrite(g);}\n str(h,s1);\n str(m,s2);\n if (length(s1)=1) then s1:='0'+s1;\n if (length(s2)=1) then s2:='0'+s2;\n write(s1,':',s2);\n {close(g); }\nend;\nbegin\n nhap;\n xuli;\n xuat;\nend."}, {"source_code": "const fi='input.txt';\n fo='output.txt';\nvar h1,h2,h3,m1,m2,m3:longint;\n a,b:string;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n\n readln(a);\n readln(b);\n\n h1:=(ord(a[1])-48)*10+(ord(a[2])-48);\n m1:=(ord(a[4])-48)*10+(ord(a[5])-48);\n h2:=(ord(b[1])-48)*10+(ord(b[2])-48);\n m2:=(ord(b[4])-48)*10+(ord(b[5])-48);\n\n h3:=h2-h1;\n m3:=m2-m1;\n if m3<0 then begin\n m3:=m3+60;\n dec(h3);\n end;\n m3:=m1+m3 div 2;\n if h3 mod 2>0 then m3:=m3+30;\n h3:=h1+h3 div 2;\n if m3>60 then begin\n m3:=m3 mod 60;\n inc(h3);\n end;\n\n if m3>=60 then begin\n h3:=h3+m3 div 60;\n m3:=m3 mod 60;\n end;\n\n if h3<10 then write(0,h3) else write(h3);\n write(':');\n if m3<10 then write(0,m3) else write(m3);\n\n //close(input);\n //close(output);\nEND.\n"}, {"source_code": "program i1;\nvar stime, etime: string;\n stimeh, stimem, etimeh, etimem, error, mid: integer;\nbegin\n readln(stime);\n readln(etime);\n \n val(copy(stime, 1, 2), stimeh, error);\n val(copy(etime, 1, 2), etimeh, error);\n val(copy(stime, length(stime)-1, 2), stimem, error);\n val(copy(etime, length(etime)-1, 2), etimem, error);\n \n \n \n \n mid := ((60*etimeh - 60*stimeh) +(etimem - stimem)) div 2;\n \n \n stimeh := stimeh + mid div 60;\n \n \n stimem := stimem + mid mod 60;\n \n if stimem >= 60 then\n begin\n \n stimeh := stimeh + stimem div 60;\n stimem := stimem mod 60;\n end;\n \n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\nend.\n\n\n"}], "negative_code": [{"source_code": "Program A1;\nuses math;\nvar H,M,S1,S2,S3,S4:string; h1,h2,m1,m2:byte; i,code:longint;\nProcedure Xuli;\nbegin S1:=''; S2:=''; S3:=''; S4:='';\n for i:=1 to length(h) do\n if H[i]<>':' then\n S1:=S1+H[i]\n else begin S2:=copy(H,i+1,2);\n break;\n end;\n for i:=1 to length(M) do\n if M[i]<>':' then\n S3:=S3+M[i]\n else begin S4:=copy(M,i+1,2);\n break;\n end;\n val(S1,h1,code); val(S2,m1,code);\n val(S3,h2,code); val(S4,m2,code);\nend;\nProcedure Cal;\nbegin m2:=(h2-h1)*60+m2;\n m1:=m2+m1;\n h1:=h1+(m1 div 60) div 2;\n m1:=(m1 mod 60) div 2;\n str(h1,S1); str(m1,S2);\n if length(S1)=1 then S1:='0'+S1;\n if length(S2)=1 then S2:='0'+S2;\n writeln(S1,':',S2);\nend;\nbegin readln(H); readln(M);\n Xuli;\n Cal;\n close(input); close(output);\n\nend.\n"}, {"source_code": "Program A1;\nuses math;\nvar S1,S2,h1s,h2s,m1s,m2s,r1,r2:string; i,h1,h2,m1,m2,code,ha,ma:longint;\nProcedure Returnback;\nbegin h1s:=''; h2s:=''; m1s:=''; m2s:='';\n for i:=1 to length(S1) do\n if i<=2 then begin\n h1s:=h1s+S1[i];\n h2s:=h2s+S2[i];\n end else if i>3 then begin\n m1s:=m1s+S1[i];\n m2s:=m2s+S2[i];\n end;\nend;\nProcedure Calculate;\nbegin val(h1s,h1,code); val(m1s,m1,code);\n val(h2s,h2,code); val(m2s,m2,code);\n if m2=0 then begin\n dec(h2); m2:=m2+60;\n end;\n ha:=(h1+h2) div 2; ma:=(m1+m2) div 2;\n str(ha,r1); str(ma,r2);\n if ha<10 then r1:='0'+r1;\n if ma<10 then r2:='0'+r2;\n writeln(r1,':',r2);\nend;\nbegin readln(S1); readln(S2);\n Returnback;\n Calculate;\nend.\n"}, {"source_code": "Program A1;\nuses math;\nvar S1,S2,h1s,h2s,m1s,m2s,r1,r2:string; i,h1,h2,m1,m2,code,ha,ma:longint;\nProcedure Returnback;\nbegin h1s:=''; h2s:=''; m1s:=''; m2s:='';\n for i:=1 to length(S1) do\n if i<=2 then begin\n h1s:=h1s+S1[i];\n h2s:=h2s+S2[i];\n end else if i>3 then begin\n m1s:=m1s+S1[i];\n m2s:=m2s+S2[i];\n end;\nend;\nProcedure Calculate;\nbegin val(h1s,h1,code); val(m1s,m1,code);\n val(h2s,h2,code); val(m2s,m2,code);\n if m2=0 then begin\n dec(h2); m2:=m2+60;\n end;\n if h2=0 then h2:=24;\n ha:=(h1+h2) div 2; ma:=(m1+m2) div 2;\n str(ha,r1); str(ma,r2);\n if ma<10 then r2:='0'+r2;\n writeln(r1,':',r2);\nend;\nbegin readln(S1); readln(S2);\n Returnback;\n Calculate;\nend."}, {"source_code": "Program A1;\nuses math;\nvar S1,S2,h1s,h2s,m1s,m2s,r1,r2:string; i,h1,h2,m1,m2,code,ha,ma:longint;\nProcedure Returnback;\nbegin h1s:=''; h2s:=''; m1s:=''; m2s:='';\n for i:=1 to length(S1) do\n if i<=2 then begin\n h1s:=h1s+S1[i];\n h2s:=h2s+S2[i];\n end else if i>3 then begin\n m1s:=m1s+S1[i];\n m2s:=m2s+S2[i];\n end;\nend;\nProcedure Calculate;\nbegin ha:=0; ma:=0;\n val(h1s,h1,code); val(m1s,m1,code);\n val(h2s,h2,code); val(m2s,m2,code);\n if m2<=m1 then begin\n dec(h2); m2:=m2+60;\n end;\n if (h1+h2) mod 2<>0 then ha:=ha+1;\n ha:=ha+(h1+h2) div 2; ma:=ma+(m1+m2) div 2;\n str(ha,r1); str(ma,r2);\n if ha<10 then r1:='0'+r1;\n if ma<10 then r2:='0'+r2\n else if ma=60 then begin\n r2:='00';\n inc(ha);\n str(ha,r1);\n r1:='0'+r1;\n end;\n writeln(r1,':',r2);\nend;\nbegin readln(S1); readln(S2);\n Returnback;\n Calculate;\nend.\n"}, {"source_code": "Program A1;\nuses math;\nvar S1,S2,h1s,h2s,m1s,m2s,r1,r2:string; i,h1,h2,m1,m2,code,ha,ma:longint;\nProcedure Returnback;\nbegin h1s:=''; h2s:=''; m1s:=''; m2s:='';\n for i:=1 to length(S1) do\n if i<=2 then begin\n h1s:=h1s+S1[i];\n h2s:=h2s+S2[i];\n end else if i>3 then begin\n m1s:=m1s+S1[i];\n m2s:=m2s+S2[i];\n end;\nend;\nProcedure Calculate;\nbegin val(h1s,h1,code); val(m1s,m1,code);\n val(h2s,h2,code); val(m2s,m2,code);\n if m2= 60 then\n begin\n inc(stimeh);\n stimem := mid mod 60;\n end;\n stimeh := stimeh + mid div 60;\n if stimeh = 24 then\n stimeh := 0;\n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\nend.\n\n\n\n"}, {"source_code": "program i1;\nvar stime, etime: string;\n stimeh, stimem, etimeh, etimem, error, mid: integer;\nbegin\n readln(stime);\n readln(etime);\n \n val(copy(stime, 1, 2), stimeh, error);\n val(copy(etime, 1, 2), etimeh, error);\n val(copy(stime, length(stime)-1, 2), stimem, error);\n val(copy(etime, length(etime)-1, 2), etimem, error);\n \n stimeh := stimeh * 60;\n etimeh := etimeh * 60;\n \n mid := (abs(etimeh - stimeh) +abs(etimem - stimem)) div 2;\n stimeh := stimeh div 60;\n stimem := stimem + mid mod 60;\n if stimem >= 60 then\n begin\n inc(stimeh);\n stimem := mid mod 60;\n end;\n stimeh := stimeh + mid div 60;\n \n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\nend.\n\n\n\n"}, {"source_code": "program i1;\nvar stime, etime: string;\n stimeh, stimem, etimeh, etimem, error, mid: integer;\nbegin\n readln(stime);\n readln(etime);\n \n val(copy(stime, 1, 2), stimeh, error);\n val(copy(etime, 1, 2), etimeh, error);\n val(copy(stime, length(stime)-1, 2), stimem, error);\n val(copy(etime, length(etime)-1, 2), etimem, error);\n \n stimeh := stimeh * 60;\n etimeh := etimeh * 60;\n \n mid := ((etimeh - stimeh) +(etimem - stimem)) div 2;\n \n stimem := stimem + mid mod 60;\n if stimem = 60 then\n begin\n inc(stimeh, 60);\n stimem := 0;\n end;\n stimeh := stimeh div 60 + mid div 60;\n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\n \nend.\n\n\n\n"}, {"source_code": "program i1;\nvar stime, etime: string;\n stimeh, stimem, etimeh, etimem, error, mid: integer;\nbegin\n readln(stime);\n readln(etime);\n \n val(copy(stime, 1, 2), stimeh, error);\n val(copy(etime, 1, 2), etimeh, error);\n val(copy(stime, length(stime)-1, 2), stimem, error);\n val(copy(etime, length(etime)-1, 2), etimem, error);\n \n stimeh := stimeh * 60;\n etimeh := etimeh * 60;\n \n mid := (abs(etimeh - stimeh) +abs(etimem - stimem)) div 2;\n stimeh := stimeh div 60;\n stimem := stimem + mid mod 60;\n if stimem >= 60 then\n begin\n inc(stimeh, stimem div 60);\n stimem := mid mod 60;\n end;\n stimeh := stimeh + mid div 60;\n if stimeh = 24 then\n stimeh := 0;\n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\nend.\n\n\n\n"}, {"source_code": "program i1;\nvar stime, etime: string;\n stimeh, stimem, etimeh, etimem, error, mid: integer;\nbegin\n readln(stime);\n readln(etime);\n \n val(copy(stime, 1, 2), stimeh, error);\n val(copy(etime, 1, 2), etimeh, error);\n val(copy(stime, length(stime)-1, 2), stimem, error);\n val(copy(etime, length(etime)-1, 2), etimem, error);\n \n \n \n \n mid := ((60*etimeh - 60*stimeh) +(etimem - stimem)) div 2;\n \n \n stimeh := stimeh + mid div 60;\n \n \n stimem := stimem + mid mod 60;\n \n if stimem >= 60 then\n begin\n stimem := stimem mod 60;\n stimeh := stimeh + stimem div 60;\n end;\n \n if stimeh < 10 then write(0);\n write(stimeh, ':');\n if stimem < 10 then write(0);\n write(stimem);\nend.\n\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n s,s1,st,st1,kqs:ansistring;\n so,so1,d,d1,kq:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,st);\n readln(f,st1);\n\n assign(f,fo);rewrite(f);\n s:=st[1]+st[2]+st[4]+st[5];\n s1:=st1[1]+st1[2]+st1[4]+st1[5];\n val(s,so);\n val(s1,so1);\n d:=so1-so;\n if d=100 then d1:=30 else d1:=d div 2;\n kq:=d1+so;\n str(kq,kqs);\n if length(kqs)=3 then kqs:='0'+kqs;\n insert(':',kqs,3);\n write(f,kqs);\n close(f);\nend.\n"}, {"source_code": "Var S,F,SS1,SS2:String;\n num1,num2,num3,num4:Longint;\nBegin\n Readln(S); Readln(F);\n Val(Copy(S,1,2),num1);\n Val(Copy(S,4,2),num2);\n Val(Copy(F,1,2),num3);\n Val(Copy(F,4,2),num4);\n Str((num1+num3) div 2,SS1);\n Str((num2+num4) div 2 + (num1+num3) mod 2 * 30,SS2);\n If length(SS1)=1 then SS1:='0'+SS1;\n If length(SS2)=1 then SS2:='0'+SS2;\n Writeln(SS1+':'+SS2);\nEnd."}, {"source_code": "Var a,b:array[0..6] of byte;\n kq,kq1,kq2,kq3,m,m1,i:integer;\n s,ss,t,t1:string;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Readln(s);\n Readln(ss);\n\n For i:=1 to length(s) do\n if (s[i]<>':') then\n begin\n a[i]:=ord(s[i]) - 48;\n b[i]:=ord(ss[i]) - 48;\n end;\n kq:= 10*a[1]+a[2];\n kq1:=10*b[1]+b[2];\n kq2:= 10*a[4]+a[5];\n kq3:= 10*b[4]+b[5];\n m:= (kq+kq1) div 2;\n m1:=(kq2+kq3) div 2;\n If (m1 >60) then\n begin\n m:=m+1;\n m1:=m1-60;\n end;\n If (kq2 =0) and (kq3=0) then\n begin\n\n str(m,t1);\n t1:=t1+':';\n t1:=t1+'30';\n end\n else\n begin\n t1:='';\n t:='';\n str(m,t1);\n str(m1,t);\n If (length(t1)<>2) then t1:='0'+t1;\n If (length(t)<>2) then t:='0'+t;\n t1:= t1+':';\n t1:=t1+t;\n end;\n Writeln(t1);\n Close(input);\n Close(output);\nEnd.\n"}, {"source_code": "Var a,b:array[0..6] of byte;\n kq,kq1,kq2,kq3,m,m1,i,kq4:integer;\n s,ss,t,t1:string;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Readln(s);\n Readln(ss);\n\n For i:=1 to length(s) do\n if (s[i]<>':') then\n begin\n a[i]:=ord(s[i]) - 48;\n b[i]:=ord(ss[i]) - 48;\n end;\n kq:= 10*a[1]+a[2];\n kq1:=10*b[1]+b[2];\n kq2:= 10*a[4]+a[5];\n kq3:= 10*b[4]+b[5];\n // m:= (kq+kq1) div 2;\n // m1:=(kq2+kq3) div 2;\n // If (m1 >60) then\n // begin\n // m:=m+1;\n // m1:=m1-60;\n // end;\n If (kq2 =0) and (kq3=0) then\n begin\n m:= (kq+kq1) div 2;\n str(m,t1);\n t1:=t1+':';\n t1:=t1+'30';\n end\n else\n begin\n m:=(kq1*60+kq3)-(kq*60+kq2);\n m:= m div 2;\n kq4:=kq2+m;\n m1:= kq4 div 60;\n kq:=kq+m1;\n str(kq,t1);\n If (length(t1)<>2) then t1:='0'+t1;\n kq4:=kq4 - (m1*60);\n str(kq4,t);\n If (length(t)<>2) then t:='0'+t;\n t1:=t1+':';\n t1:=t1+t;\n end;\n Writeln(t1);\n Close(input);\n Close(output);\nEnd.\n"}, {"source_code": "Var a,b:array[0..6] of byte;\n kq,kq1,kq2,kq3,m,m1,i:integer;\n s,ss,t,t1:string;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Readln(s);\n Readln(ss);\n\n For i:=1 to length(s) do\n if (s[i]<>':') then\n begin\n a[i]:=ord(s[i]) - 48;\n b[i]:=ord(ss[i]) - 48;\n end;\n kq:= 10*a[1]+a[2];\n kq1:=10*b[1]+b[2];\n kq2:= 10*a[4]+a[5];\n kq3:= 10*b[4]+b[5];\n m:= (kq+kq1) div 2;\n m1:=(kq2+kq3) div 2;\n If (kq2 =0) and (kq3=0) then\n begin\n\n str(m,t1);\n t1:=t1+':';\n t1:=t1+'30';\n end\n else\n begin\n t1:='';\n t:='';\n str(m,t1);\n str(m1,t);\n If (length(t1)<>2) then t1:='0'+t1;\n If (length(t)<>2) then t:='0'+t;\n t1:= t1+':';\n t1:=t1+t;\n end;\n Writeln(t1);\n Close(input);\n Close(output);\nEnd."}, {"source_code": "Var a,b:array[0..6] of byte;\n kq,kq1,kq2,kq3,m,m1,i:integer;\n s,ss,t,t1:string;\n\nBegin\n Assign(input,'');\n Assign(output,'');\n Reset(input);\n Rewrite(output);\n Readln(s);\n Readln(ss);\n\n For i:=1 to length(s) do\n if (s[i]<>':') then\n begin\n a[i]:=ord(s[i]) - 48;\n b[i]:=ord(ss[i]) - 48;\n end;\n kq:= 10*a[1]+a[2];\n kq1:=10*b[1]+b[2];\n kq2:= 10*a[4]+a[5];\n kq3:= 10*a[4]+a[5];\n m:= (kq+kq1) div 2;\n m1:=(kq2+kq3) div 2;\n If (kq2 =0) and (kq3=0) then\n begin\n\n str(m,t1);\n t1:=t1+':';\n t1:=t1+'30';\n end\n else\n begin\n t1:='';\n t:='';\n str(m,t1);\n str(m1,t);\n If (length(t1)<>2) then t1:='0'+t1;\n If (length(t)<>2) then t:='0'+t;\n t1:= t1+':';\n t1:=t1+t;\n end;\n Writeln(t1);\n Close(input);\n Close(output);\nEnd.\n"}, {"source_code": "program jam;\n\nvar\ns:string;\njam1,jam2:longint;\nmenit1,menit2:longint;\ntemp1,temp2:string;\nselisihJam,selisihMenit:longint;\ntambahanJam:longint;\ntambahanMenit:longint;\ntotalMenit:longint;\nhasilMenit,hasilJam:longint;\n\nbegin\n\treadln (s);\n\ttemp1 := s[1] + s[2];\n\ttemp2 := s[4] + s[5];\n\tval (temp1, jam1);\n\tval (temp2, menit1);\n\treadln (s);\n\ttemp1 := s[1] + s[2];\n\ttemp2 := s[4] + s[5];\n\tval (temp1, jam2);\n\tval (temp2, menit2);\n\tselisihJam := jam2 - jam1;\n\tselisihMenit := menit2 - menit1;\n\ttotalMenit := (60*selisihJam) + selisihMenit;\n\ttotalMenit := totalMenit div 2;\n\ttambahanJam := totalMenit div 60;\n\ttambahanMenit := totalMenit mod 60;\n\thasilJam := jam1+tambahanJam;\n\thasilMenit := menit1+tambahanMenit;\n\tif (hasilMenit > 60) then\n\tbegin\n\t\thasilJam := hasilJam + (hasilMenit div 60);\n\t\thasilMenit := hasilMenit mod 60;\n\tend;\n\tif (hasilJam < 10) then\n\tbegin\n\t\tif (hasilMenit < 10) then\n\t\tbegin\n\t\t\twriteln ('0',hasilJam,':0',hasilMenit);\n\t\tend else\n\t\tbegin\n\t\t\twriteln ('0',hasilJam,':',hasilMenit);\n\t\tend;\n\tend else\n\tbegin\n\t\tif (hasilMenit < 10) then\n\t\tbegin\n\t\t\twriteln (hasilJam,':0',hasilMenit);\n\t\tend else\n\t\tbegin\n\t\t\twriteln (hasilJam,':',hasilMenit);\n\t\tend;\n\tend;\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\nm:=c;\na:= a*60 + c;\na1:= a1*60 + c1;\nb:= a1-a;\nb:=b div 2;\nc:=c+b;\ni:= c mod 60;\nc:= c div 60;\nm:=g+c;\nb1:=i;\nif (b1 >=10) and(m>=10 ) then writeln(m,':',b1);\nif (b1 <10) and(m <10) then writeln('0',m,':','0',b1);\nif (b1 <10) and(m >10) then writeln(m,':','0',b1);\nif (b1 >10) and(m <10) then writeln('0',m,':',b1);\n\nend.\n\n"}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\n\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\n\nb:= b+c;\n\nb1:= b mod 60;\nc:= b div 60;\nm:=g+c;\n\n\n\nif (b1 >10) and(m>10 ) then writeln(m,':',b1);\n\nif (b1 <10) and(m <10) then writeln('0',m,':','0',b1);\n\nif (b1 <10) and(m >10) then writeln(m,':','0',b1);\nif (b1 >10) and(m <10) then writeln('0',m,':',b1);\n\n\n\n\n\n\n\n\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\n\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\n\nb:= b+c;\n\nb1:= b mod 60;\nc:= b div 60;\nm:=g+c;\n\n\n\nif (b1 div 10 <>0) and(m div 10<>0) then writeln(m,':',b1);\n\nif (b1 div 10 =0) and(m div 10=0) then writeln('0',m,':','0',b1);\n\nif (b1 div 10 <>0) and(m div 10=0) then writeln(m,':','0',b1);\nif (b1 div 10 =0) and(m div 10<>0) then writeln('0',m,':',b1);\n\n\n\n\n\n\n\n\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\nb:= b+c;\nb1:= b mod 60;\nc:= b div 60;\nm:=g+c;\nwriteln(m,':',b1);\nif (b1 div 10=0) and(m div 10=0 ) then writeln(m,':',b1);\nif (b1 <10) and(m <10) then writeln('0',m,':','0',b1);\nif (b1 <10) and(m >10) then writeln(m,':','0',b1);\nif (b1 >10) and(m <10) then writeln('0',m,':',b1);\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g,m:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\nb:= b+c;\nb1:= b mod 60;\nc:= b div 60;\nm:=g+c;\nif (b1 >=10) and(m>=10 ) then writeln(m,':',b1);\nif (b1 <10) and(m <10) then writeln('0',m,':','0',b1);\nif (b1 <10) and(m >10) then writeln(m,':','0',b1);\nif (b1 >10) and(m <10) then writeln('0',m,':',b1);\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\n\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\n\nb:= b+c;\n\nb1:= b mod 60;\nc:= b div 60;\n\n\n\nif b1 div 10 <>0 then writeln((g+c),':',b1);\nif b1 div 10 =0 then writeln((g+c),':','0',b1);\n\n\n\n\n\n\n\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\n\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\nb:= b+c;\nb:= b mod 60;\nc:= b div 60;\n\n\nwriteln((g+c),':',b)\n\n\n\n\n\n\nend."}, {"source_code": "var\ni,n,a,b,c,d,a1,b1,c1,d1,g:integer;\ns1,s2,s,s3,s4,s5: string;\n\nbegin\nreadln(s1);\nfor i:=1 to length(s1)\ndo\nif s1[i]=(':') then n:=i;\ns2:=copy(s1,1,n-1);\nval (s2,a,b);\ns2:=copy(s1,n+1,length(s1));\nval (s2,c,d);\n\nreadln(s3);\nfor i:=1 to length(s3)\ndo\nif s3[i]=(':') then n:=i;\ns4:=copy(s3,1,n-1);\nval (s4,a1,b1);\ns5:=copy(s3,n+1,length(s3));\nval (s5,c1,d1);\ng:=a;\na:= a*100 + c;\na1:= a1*100 + c1;\nb:= a1-a;\nd:= b div 100;\nb1:= d*60+ b mod 100;\nb:=b1 div 2;\n\nb:= b+c;\n\nb1:= b mod 60;\nc:= b div 60;\n writeln(c);\n\n\nif b1 div 10 <>0 then writeln((g+c),':',b1);\nif b1 div 10 =0 then writeln((g+c),':','0',b1);\n\n\n\n\n\n\n\nend."}, {"source_code": "var\n s1,s2:string;\n ch1,ch2,n,i,m1,m2,sum1,sum2,sum:integer;\nbegin\n readln(s1);\n readln(s2);\n ch1:=strtoint(copy(s1,1,2));\n ch2:=strtoint(copy(s2,1,2));\n m1:=strtoint(copy(s1,4,2));\n m2:=strtoint(copy(s2,4,2));\n //writeln(ch1,' ',m1);\n //writeln(ch2,' ',m2);\n sum1:=ch1 * 60 + m1;\n sum2:= ch2*60 + m2;\n sum1:=sum1 div 2;\n sum2:=sum2 div 2;\n sum:=sum1+sum2;\n ch1:=sum div 60;\n m2:=sum mod 60;\n s1:=inttostr(ch1);\n if length(s1)<2 then\n s1:='0'+s1;\n s2:=inttostr(m2);\n if length(s2)<2 then\n s2:='0'+s2;\n writeln(s1,':',s2);\n \nend."}, {"source_code": "program kontest;\nvar\nh1,h2,m1,m2,h3,m3:byte;\ndlit:word;\ns,s1:string;\nerr:integer;\nbegin\nReadln(s);\ns1:=Copy(s,1,2);\nVal(s1,h1,err);\ns1:=Copy(s,4,2);\nVal(s1,m1,err);\nReadln(s);\ns1:=Copy(s,1,2);\nVal(s1,h2,err);\ns1:=Copy(s,4,2);\nVal(s1,m2,err);\nh3:=h2-h1;\nm3:=m2-m1;\ndlit:=60*h3+m3;\ndlit:=dlit div 2;\nh1:=h1+dlit div 60;\nm1:=m1+dlit mod 60;\nif m1>=60 then \n begin\n h1+=1;\n m1:=m1 mod 60;\n end;\nif h1<10 then write(0,h1,':') else write(h1,':');\nif m1<10 then write(0,m1) else write(m1);\nend.\n\n\n"}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n l:=h2-h1;\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1=0)and(m2=0) then begin\n h2:=h2-1-h1;\n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n end\n else if m1>m2 then begin\n h2:=h2-1;\n m2:=m2+60;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n \n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n if (h2-h1) mod 2 = 1 then begin h2:=h2-1;m2:=m2+60;end;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n if l1>=60 then begin l:=l+1;l1:=l1 mod 60;end;\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1=0)and(m2=0) then begin\n if (h2-h1) mod 2 = 1 then begin \n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n end\n else begin\n l:=(h2+h1) div 2;\n l1:=0;\n end;\n \n \n \n \n end\n else if m1>m2 then begin\n h2:=h2-1;\n m2:=m2+60;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n \n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n if (h2-h1) mod 2 = 1 then begin h2:=h2-1;m2:=m2+60;end;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n if l1>=60 then begin l:=l+1;l1:=l1 mod 60;end;\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n l:=h2-h1;\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1>m2)or(m1=0)and(m2=0) then begin\n h2:=h2-1-h1;\n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n if (h2-h1) mod 2 = 1 then begin h2:=h2-1;m2:=m2+60;end;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n l:=h2-h1;\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1>m2)or(m1=0)and(m2=0) then begin\n h2:=h2-1-h1;\n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n l:=h2-h1;\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1>m2)or(m1=0)and(m2=0) then begin\n h2:=h2-1-h1;\n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n writeln(l:2,':',l1:2)\n end\n\n else if h1=h2 then begin\n l1:=(m2+m1) div 2;\n writeln(h1:2,':',l1:2)\n end\n else begin \n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n writeln(l:2,':',l1:2)\n end; \nend."}, {"source_code": "Program CF_1133A;\nvar m1,m2,h1,h2,i,l,l1,f,m,k:integer;\n st1,st2,s,s1:string;\nBegin\n readln(st1);\n readln(st2);\n s:=st1;\n delete(s,3,3);\n Val(s,h1,f);\n s1:=st2;\n delete(s1,3,3);\n Val(s1,h2,f);\n l:=h2-h1;\n s:=st1;\n delete(s,1,3);\n Val(s,m1,f);\n s1:=st2;\n delete(s1,1,3);\n Val(s1,m2,f);\n if (m1>m2)or(m1=0)and(m2=0) then begin\n h2:=h2-1-h1;\n m2:=m2+60;\n l:=h1+(h2 div 2);\n l1:=(m2-m1) div 2;\n end\n\n else if h1=h2 then begin\n l:=h1;\n l1:=(m2+m1) div 2;\n end\n else begin \n if (h2-h1) mod 2 = 1 then begin h2:=h2-1;m2:=m2+60;end;\n h2:=h2-h1;\n l:=h1+(h2 div 2);\n l1:=(m2+m1) div 2;\n end;\n if l1=60 then begin l:=l+1;l1:=0;end;\n if l<=9 then write(0);\n write(l);\n write(':');\n if l1<=9 then write(0);\n write(l1);\nend."}, {"source_code": "var\ns1,s2,wh1,wm1,ans:string;\nq1,q2,qq,m1,m2,h1,hq,mq,h2:integer;\nbegin\nreadln(s1);\nreadln(s2);\nh1:=strtoint(copy(s1,1,2));\nh2:=strtoint(copy(s2,1,2));\nm1:=strtoint(copy(s1,4,2));\nm2:=strtoint(copy(s2,4,2));\nhq:=(h2-h1) div 2;\nmq:=(m2-m1) div 2;\nq1:=h1+hq;\nq2:=m1+mq;\nif q2>59 then begin q2:=q2-60; inc(q1); end;\nwh1:=inttostr(q1);\nwm1:=inttostr(q2);\nif length(wh1)=1 then wh1:='0'+wh1;\nif length(wm1)=1 then wm1:='0'+wm1;\nans:=wh1+':'+wm1;\nwrite(ans);\nend.\n"}, {"source_code": "var h1,m1,h2,m2,m,hsrd,hsrm,msrd : longint;\n s1,s2,h1s,m1s,h2s,m2s : string;\nbegin\n readln(s1);\n readln(s2);\n h1s:=copy(s1,1,2);\n m1s:=copy(s1,4,2);\n h2s:=copy(s2,1,2);\n m2s:=copy(s2,4,2);\n val(h1s,h1,m);\n val(m1s,m1,m);\n val(h2s,h2,m);\n val(m2s,m2,m);\n hsrd:=(h2-h1) div 2;\n msrd:=(m2-m1) div 2;\n hsrm:=(h2-h1) mod 2;\n if hsrd>=1 then h1:=h1+hsrd;\n if hsrm>0 then m1:=m1+30;\n m1:=m1+msrd;\n if h1<10 then write(0,h1,':')\n else write(h1,':');\n if m1<10 then writeln(0,m1)\n else writeln(m1);\nend."}, {"source_code": "Program t_0;\nvar h1,h2,m1,m2,ha,ma,delta_min : integer;\nvar s1, s2 :string;\nbegin\n\n\nreadln(s1);\nreadln(s2);\n\n\nh1 := (ord(s1[1]) - ord('0')) * 10 + (ord(s1[2]) - ord('0'));\n\nm1 := (ord(s1[4]) - ord('0')) * 10 + (ord(s1[5]) - ord('0'));\nh2 := (ord(s2[1]) - ord('0')) * 10 + (ord(s2[2]) - ord('0'));\nm2 := (ord(s2[4]) - ord('0')) * 10 + (ord(s2[5]) - ord('0'));\n\ndelta_min := (h2 - h1) * 60 + m2 - m1;\ndelta_min := (delta_min div 2);\n\nma := m1 + delta_min;\nha := h1 + (ma div 60);\nma := (ma mod 60);\n\nwriteln(ha,':',ma);\n\nend."}, {"source_code": "var\n hour,min,s1,s2:string;\n k1,l1,k2,l2,s: integer;\nbegin\nreadln(s1);\nreadln(s2);\nk1:=strtoint(s1[1])*10+strtoint(s1[2]);\nl1:=strtoint(s1[4])*10+strtoint(s1[5]);\nk2:=strtoint(s2[1])*10+strtoint(s2[2]);\nl2:=strtoint(s2[4])*10+strtoint(s2[5]);\ns:=(abs(k1-k2)*60+abs(l1-l2))div 2;\nif k1+(s div 60)div 2<10 then hour:='0'+inttostr(k1+(s div 60)) else hour:=inttostr(k1+(s div 60));\nif l1+(s mod 60)div 2<10 then min:='0'+inttostr(l1+(s mod 60)) else min:=inttostr(l1+(s mod 60));\nwrite(hour,':',min);\nend."}, {"source_code": "\nvar\n hour,min,s1,s2:string;\n k1,l1,k2,l2,s: integer;\nbegin\nreadln(s1);\nreadln(s2);\nk1:=strtoint(s1[1])*10+strtoint(s1[2]);\nl1:=strtoint(s1[4])*10+strtoint(s1[5]);\nk2:=strtoint(s2[1])*10+strtoint(s2[2]);\nl2:=strtoint(s2[4])*10+strtoint(s2[5]);\ns:=(abs(k1-k2)*60+abs(l1-l2))div 2;\nif k1+(s div 60)div 2<10 then hour:='0'+inttostr(k1+(s div 60))+'0' else hour:=inttostr(k1+(s div 60));\nif l1+(s mod 60)div 2<10 then min:='0'+inttostr(l1+(s mod 60)) else min:=inttostr(l1+(s mod 60));\nwrite(hour,':',min);\nend."}, {"source_code": "var\n s1, s2: string;\n x: longint;\n\nfunction p(c: char): longint;\nbegin\n result := ord(c) - ord('0');\nend;\n\nfunction f(s: string): longint;\nbegin\n result := (p(s[1]) * 10 + p(s[2])) * 60 + p(s[4]) * 10 + p(s[5]);\nend;\n\nbegin\n readln(s1);\n readln(s2);\n x := (f(s1) + f(s2)) div 2;\n write(x div 60, ':', x mod 60);\nend."}, {"source_code": "program ideone;\nuses SysUtils;\nvar\n\ts,ss:string;\n\ti,hh,mm:integer;\n\nbegin\n\treadln(s);\n\treadln(ss);\n\t\n\thh:=(StrToInt(copy(s,1,2)) + StrToInt(copy(ss,1,2))) * 60;\n\tmm:=hh + strtoint(copy(s,4,2)) + strtoint(copy(ss,4,2)); \n\t\n\tmm:= mm div 2;\n\t\n\thh:= mm div 60;\n\tmm:= mm mod 60;\n\t\n\twriteln(hh,':',mm);\nend."}], "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50"} {"source_code": "var a:array['0'..'9']of boolean;\n i:longint;\n s:string;\nbegin\n readln(i);\n readln(s);\n for i:=1 to length(s) do\n a[s[i]]:=true;\n if (a['1']or a['2']or a['3']) and (a['7']or a['0']or a['9']) and ((a['1']or a['4']or a['7'])and(a['3']or a['6']or a['9'])or a['0']) then writeln('YES')\n else writeln('NO');\nend.", "positive_code": [{"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, i, cur : longint;\n u, d, l, r, o, z : boolean;\n c : char;\n\nbegin\n// assign(input, 'input.txt'); assign(output, 'output.txt');\n readln(n);\n for i := 1 to n do\n begin\n read(c);\n cur := ord(c) - ord('0');\n if (cur > 0) and (cur < 4) then\n begin\n u := True;\n o := True;\n end;\n if (cur = 7) or (cur = 0) or (cur = 9) then\n d := True;\n if (cur = 1) or (cur = 4) or (cur = 7) then\n l := True;\n if (cur = 3) or (cur = 6) or (cur = 9) then\n r := True;\n if cur = 0 then\n z := True;\n end;\n\n if ((u and d) and (l and r)) or (o and z) then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "var n,i,j,x,y:longint;s:string;\na:array[-11..11,-11..11] of longint;\nb,c,h,l:array[0..11] of longint;\nfunction pd(x:longint):boolean;\nvar a1,b1,i:longint;\nbegin\na1:=b[x];b1:=c[x];\nfor i:=2 to n do\n begin\n a1:=a1+h[i];b1:=b1+l[i];\n if a[a1,b1]=-1 then exit(false);\n end;\nexit(true);\nend;\nbegin\n//assign(input,'mphone.in');reset(input);\n//assign(output,'mphone.out');rewrite(output);\nreadln(n);readln(s);\nfillchar(a,sizeof(a),255);\na[4,2]:=0;b[0]:=4;c[0]:=2;\nfor i:=1 to 3 do\n begin\n for j:=1 to 3 do\n begin\n a[i,j]:=(i-1)*3+j;b[(i-1)*3+j]:=i;c[(i-1)*3+j]:=j;\n end;\n end;\nfor i:=2 to n do\n begin\n x:=ord(s[i-1])-48;\n y:=ord(s[i])-48;\n h[i]:=b[y]-b[x];\n l[i]:=c[y]-c[x];\n end;\nfor i:=0 to 9 do\n if(chr(i+48)<>s[1])and(pd(i))then\n begin\n writeln('NO');close(input);close(output);halt;\n end;\nwriteln('YES');\nclose(input);close(output);\nend."}, {"source_code": "var c:char;\n n,i:longint;\n l,r,u,d,z:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(c);\n if (c='1') or (c='4') or (c='7') then\n l:=true;\n if (c='3') or (c='6') or (c='9') then\n r:=true;\n if (c='1') or (c='2') or (c='3') then\n u:=true;\n if (c='7') or (c='9') then\n d:=true;\n if (c='0') then\n z:=true;\n end;\nif (z and u) or (l and r and u and d) then\n writeln('YES')\nelse\n writeln('NO');\nend."}, {"source_code": "var x1,y1,i,n,j:longint;flag:boolean;c:char;\nx,y,a:array[0..1000000] of longint;\nf:array[-1001..1001,-1001..1001] of boolean;\nbegin\n//assign(input,'mphone.in');reset(input);\n//assign(output,'mphone.out');rewrite(output);\nx[1]:=1;y[1]:=1;\nx[2]:=1;y[2]:=2;\nx[3]:=1;y[3]:=3;\nx[4]:=2;y[4]:=1;\nx[5]:=2;y[5]:=2;\nx[6]:=2;y[6]:=3;\nx[7]:=3;y[7]:=1;\nx[8]:=3;y[8]:=2;\nx[9]:=3;y[9]:=3;\nx[0]:=4;y[0]:=2;\nreadln(n);\nfor i:=1 to n do\n begin\n read(c);\n a[i]:=ord(c)-48;\n end;\nfor i:=0 to 9 do f[x[i],y[i]]:=true;\nfor i:=0 to 9 do\n begin\n if i=a[1] then continue;\n x1:=x[i];y1:=y[i];flag:=true;\n for j:=2 to n do\n begin\n x1:=x1+(x[a[j]]-x[a[j-1]]);\n y1:=y1+(y[a[j]]-y[a[j-1]]);\n if f[x1,y1]=false then\n begin flag:=false;break;end;\n end;\n if flag then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end;\n end;\nwriteln('YES');\nclose(input);close(output);\nend.\n"}, {"source_code": " \n const eps=0.0000000001; besk=8000000000000000000; nn=200000;\n modul=1000000007;\n label 1,2;\n type\n mas=array [-10000..nn] of int64; { point=record x,y,z:real;end; }\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..5] of int64;mass1=^mass;\n var imax,imin,jmax,jmin,koln,kfin,distmin,ii,jj,kk,zn,razmax,pmin,pmax,sch,iistart,xmax,ymin,n,qq,ot,q,pos,left,right,amax,ost,h,tt,t1,pp,p,p1,p2,p3,p4,t,nm,s1,s2,m,s,cen,t2,i1:int64;\n stepp,iii,mask,newug,newdl,dloch,dugol,ist,jst,ifin,jfin,fin,newnapx,newnapy,step, k,i,j:longint;\n oldnap, napr,alpha,prmax,v,aaa,bbb,ccc:extended; hhh:zap;\n napx,napy,x,first,next,prev,l,r, dl,ochnewi,ochnewj,ochj,c,y,z,newoch,och,aold,b,a:array[-100000..2000000] of int64;\n stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;\n marked:array[-10..1100000] of boolean;\n yyy,xx:mass;\n ss, ss1,ss2:string;\n point:array[0..200000] of mass;\n sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;\n zan:array[-10..20,010..200] of boolean;\n sss: array[-10..100000] of string;ch3,ch,ch1,ch2:char;\n dp:array[-1..500,-1..500,-1..500]of boolean;\n clav:array[-10..300,-10..300] of int64;\n ugol:array[0..5000,0..5000] of double;\n\n ddmax,ddmin :array[-1..300000,-1..20] of extended;\n chh,pole :array [-10..200,-10..200] of char;\n maxpr:array[0..nn] of string;\n str:array[0..nn] of string;\n nap,tt1,tt2,disk,v0,v1,s0,t0:extended;\n newx,newy,yy:array[-100..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ii,jj:longint):boolean; var fl:boolean;\ni,j:longint;\n begin\n fl:=false;\n if clav[ii,jj]>=0 then fl:=true;\n good:=fl;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n napx[1]:=1; napy[1]:=0;\n napx[2]:=-1; napy[2]:=0;\n napx[3]:=0; napy[3]:=1;\n napx[4]:=0; napy[4]:=-1;\n\n for i:=-10 to 100 do for j:=-10 to 100 do clav[i,j]:=-1;\n clav[1,1]:=1;\n clav[1,2]:=2;\n clav[1,3]:=3;\n clav[2,1]:=4;\n clav[2,2]:=5;\n clav[2,3]:=6;\n clav[3,1]:=7;\n clav[3,2]:=8;\n clav[3,3]:=9;\n clav[4,2]:=0;\n for step:=1 to n do\n begin\n t:=ord(ss[step])-48;\n for i:=0 to 4 do for j:=0 to 4 do\n if clav[i,j]=t then zan[i,j]:=true;\n\n end;\n\n { for i:=0 to 5 do for j:=0 to 5 do if good(i,j) then writeln(i,' good ',j);\n }\n for step:=1 to 4 do\n begin\n flag:=true;\n for i:=1 to 4 do for j:=1 to 4 do if zan[i,j] then\n begin\n if not good(i+napx[step],j+napy[step]) then flag:=false;\n\n end;\n if flag then\n begin writeln('NO'); goto 1; end;\n\n end;\n writeln('YES');\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var n,i,vmin,vmax,gmin,gmax,e,x,y,l7,l9:longint;\nc:char;\nbegin\ny:=0; vmax:=-1; gmax:=-1; vmin:=100; gmin:=100;\nl7:=0; l9:=0;\nreadln(n);\nfor i:=1 to n do\nbegin\nread(c);\nval(c,x,e);\nif (x=0) then begin y:=1; vmax:=3; if (1gmax) then gmax:=1; if (3vmax) then vmax:=(x-1) div 3;\nif ((x-1) div 3gmax) then gmax:=(x-1) mod 3;\nif ((x-1) mod 3=4)) or ((y=0) and ((vmax-vmin+1>=3) and ((l7=1) or (l9=1))) and (gmax-gmin+1>=3)) then write('YES') else write('NO');\nend."}, {"source_code": "var\n a,b,aa:array[-1..10,-1..10]of longint;\n res:array[0..10000]of string;\n n,m,k,l,j,i,p1,p2,p3,p4:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n b[1,1]:=1;b[1,2]:=1;b[1,3]:=1;b[2,1]:=1;b[2,2]:=1;\n b[2,3]:=1;b[3,1]:=1;b[3,2]:=1;b[3,3]:=1;b[4,2]:=1;\n\n\n for i:=1 to n do\n begin\n if s[i]='1' then a[1,1]:=1;\n if s[i]='2' then a[1,2]:=1;\n if s[i]='3' then a[1,3]:=1;\n if s[i]='4' then a[2,1]:=1;\n if s[i]='5' then a[2,2]:=1;\n if s[i]='6' then a[2,3]:=1;\n if s[i]='7' then a[3,1]:=1;\n if s[i]='8' then a[3,2]:=1;\n if s[i]='9' then a[3,3]:=1;\n if s[i]='0' then a[4,2]:=1;\n end;\n\n aa:=a;\n for i:=4 downto 1 do\n begin\n for j:=4 downto 1 do if a[i,j]=1 then begin a[i,j]:=0; a[i+1,j]:=1; end;\n end;\n p1:=1; p2:=1; p3:=1; p4:=1;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p1:=0;\n end;\n\n a:=aa;\n for i:=1 to 4 do\n begin\n for j:=1 to 4 do if a[i,j]=1 then begin a[i,j]:=0; a[i-1,j]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p2:=0;\n end;\n\n a:=aa;\n for i:=5 downto 0 do\n begin\n for j:=5 downto 0 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j+1]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p3:=0;\n end;\n\n a:=aa;\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j-1]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p4:=0;\n end;\n\n if (p1+p2+p3+p4>0) then writeln('NO') else writeln('YES');\nend.\n\n\n\n"}, {"source_code": "Var n,i,j,ff1:longint;\n s:string;\n f,a,b:array[0..9] of longint;\n const x:array[0..10] of longint =(4,1,1,1,2,2,2,3,3,3,4);\n const y:array[0..10] of longint =(2,1,2,3,1,2,3,1,2,3,2);\n Begin\n readln(n);\n readln(s);\n for i:=0 to 9 do\n begin\n a[i]:=x[i];\n b[i]:=y[i];\n end;\n f[ord(s[1])-48]:=1;\n for i:=2 to n do \n begin\n for j:=0 to 9 do\n begin\n a[j]:=a[j]-(x[ord(s[i-1])-48]-x[ord(s[i])-48]);\n b[j]:=b[j]-(y[ord(s[i-1])-48]-y[ord(s[i])-48]);\n if (b[j]<>2) and (a[j]=4) then f[j]:=1;\n if (a[j]<1) then f[j]:=1;\n if (b[j]>3) then f[j]:=1;\n if (b[j]<1) then f[j]:=1;\n if (a[j]>4) then f[j]:=1;\n \n end;\n end;\n ff1:=0;\n for i:=0 to 9 do\n if f[i]=0 then ff1:=1;\n if ff1=1 then writeln('NO')\n else writeln('YES');\n end.\n "}, {"source_code": "{$MODE OBJFPC}\n\n\nConst\n Input= '';\n Output= '';\n\nVar\n Fi, fo: text;\n n, i, j: integer;\n res, ks: boolean;\n d, ng, fd, fn, cd, cn, a: array[0..10] of integer;\n\nProcedure Enter;\n var x: char;\n Begin\n readln(Fi, n);\n for i:=1 to n do\n begin\n read(fi, x);\n a[i]:= ord(x)-48\n end;\n End;\n\nProcedure init;\n begin\n for i:= 1 to 9 do\n begin\n d[i]:= i mod 3;\n ng[i]:= i div 3;\n if d[i]<>0 then inc(ng[i])\n else d[i]:= 3;\n end;\n d[0]:= 2; ng[0]:= 4;\n for i:=2 to n do\n begin\n fd[i]:= d[a[i]]-d[a[i-1]];\n fn[i]:= ng[a[i]]- ng[a[i-1]];\n end;\n end;\n\nProcedure Solve;\n Begin\n i:= 0;\n res:= true;\n while (i<= 9) do\n begin\n if i<>a[1] then\n begin\n ks:= true;\n cd[1]:= d[i];\n cn[1]:= ng[i];\n for j:= 2 to n do\n begin\n cd[j]:= cd[j-1]+fd[j];\n cn[j]:= cn[j-1]+fn[j];\n if ((cd[j]=1) or (cd[j]= 3)) and (cn[j]=4) then ks:= false\n else\n if (cd[j]<1) or (cd[j]>3) or (cn[j]<1) or (cn[j]>4) then ks:= false;\n end;\n if ks then\n begin\n res:= false;\n break;\n end;\n end;\n inc(i);\n end;\n End;\n\nProcedure Finish;\n Begin\n if not res then write(fo, 'NO')\n else write(fo, 'YES');\n End;\n\nBegin\n Assign(Fi, Input); Reset(Fi);\n Assign(Fo, Output); Rewrite(Fo);\n Enter;\n Init;\n Solve;\n Finish;\n Close(Fi); Close(Fo);\nEnd.\n\n"}, {"source_code": "var a:array[1..10,1..10] of longint;\nn,i,j,pr1,pr2,pr3,pr4:longint;\ns:string;\n\nbegin\nreadln(n);\nreadln(s);\n\nfor i:=1 to n do\nbegin\nif s[i]='1' then a[1,1]:=1;\nif s[i]='2' then a[1,2]:=1;\nif s[i]='3' then a[1,3]:=1;\nif s[i]='4' then a[2,1]:=1;\nif s[i]='5' then a[2,2]:=1;\nif s[i]='6' then a[2,3]:=1;\nif s[i]='7' then a[3,1]:=1;\nif s[i]='8' then a[3,2]:=1;\nif s[i]='9' then a[3,3]:=1;\nif s[i]='0' then a[4,2]:=1;\nend;\n\npr1:=0; PR2:=0; PR3:=0; PR4:=0;\nif a[1,1]=1 then pr1:=1;\nif a[1,2]=1 then pr1:=1;\nif a[1,3]=1 then pr1:=1;\n\nif a[1,3]=1 then pr2:=1;\nif a[2,3]=1 then pr2:=1;\nif a[3,3]=1 then pr2:=1;\nif a[4,2]=1 then pr2:=1;\n\n\nif a[3,1]=1 then pr3:=1;\nif a[3,3]=1 then pr3:=1;\nif a[4,2]=1 then pr3:=1;\n\nif a[1,1]=1 then pr4:=1;\nif a[2,1]=1 then pr4:=1;\nif a[3,1]=1 then pr4:=1;\nif a[4,2]=1 then pr4:=1;\n\nif (pr1=1) and(pr2=1) and(pr3=1) and(pr4=1) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\n res:array[1..2] of string=('YES','NO');\nVar n:longint;\n a:array[0..5,0..4] of longint;\n num:array[1..10] of longint;\n//Nhap\nProcedure Nhap;\nVar f:Text;\n i:longint;\n c:char;\nBegin\n assign(f,finp); reset(f);\n readln(f,n);\n for i:=1 to n do\n begin\n read(f,c);\n num[i]:=ord(c)-48;\n if num[i]=0 then\n num[i]:=11;\n end;\n close(f);\nEnd;\nProcedure Init;\nVar i,j:longint;\nBegin\n for i:=0 to 5 do\n for j:=0 to 4 do\n a[i,j]:=-1;\n a[1,1]:=1; a[1,2]:=2; a[1,3]:=3;\n a[2,1]:=4; a[2,2]:=5; a[2,3]:=6;\n a[3,1]:=7; a[3,2]:=8; a[3,3]:=9;\n a[4,2]:=11;\nEnd;\nFunction Left:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y-1];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Right:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y+1];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Up:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x-1,y];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Down:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x+1,y];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Solve:longint;\nBegin\n if (left=true) or (right=true) or (up=true) or (down=true) then\n exit(2);\n exit(1);\nEnd;\nProcedure Xuat;\nVar f:Text;\n k:longint;\nBegin\n assign(f,fout); rewrite(f);\n k:=solve;\n write(f,res[k]);\n close(f);\nEnd;\n\nBegin\n nhap;\n init;\n xuat;\nEnd."}, {"source_code": "var kt:boolean;\ns:ansistring;\n x,y,i,n,j,xx,yy,k:longint;\n a:array[-10..10,-10..10]of char;\n l,r:array[0..100000] of longint;\nfunction th1(x,y:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to n do\n begin\n x:=x+l[i];\n y:=y+r[i];\n if a[x,y]='?' then exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n kt:=false;\n readln(s);\n for i:=-10 to 10 do\n for j:=-10 to 10 do a[i,j]:='?';\n a[1,1]:='1';\n a[1,2]:='2';\n a[1,3]:='3';\n a[2,1]:='4';\n a[2,2]:='5';\n a[2,3]:='6';\n a[3,1]:='7';\n a[3,2]:='8';\n a[3,3]:='9';\n a[4,2]:='0';\n xx:=0;\n yy:=0;\n for i:=1 to n do\n begin\n if s[i]='0' then\n begin\n x:=4;\n y:=2;\n end else\n begin\n k:=ord(s[i])-ord('0');\n if k mod 3 =0 then x:=k div 3 else x:=k div 3+1;\n if k mod 3 =0 then y:=3 else y:=k mod 3;\n // writeln(x,y);\n end;\n l[i]:=x-xx;\n r[i]:=y-yy;\n // writeln(l[i],' ',r[i]);\n xx:=x;\n yy:=y;\n end;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if a[i,j]<>s[1] then\n begin\n if th1(i,j) then kt:=true;\n end;\n\n if s[1]<>'0' then if th1(4,2) then kt:=true;\n if not kt then write('YES') else write('NO');\nend.\n"}, {"source_code": "\nconst\n tfi='';\n tfo='';\n\ntype info= record\n x, y: longint; end;\n\nvar\n fi, fo: text;\n n: longint;\n a: array[0..4,0..4] of longint;\n x: array[0..100] of longint;\n pos: array[0..100] of info;\n\nprocedure Init;\nvar\n i, j, w: longint;\nbegin\n w := 0;\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n inc(w);\n a[i, j] := w;\n pos[w].x :=i; pos[w].y := j;\n end;\n a[4, 1] := -1; a[4, 3] := -1;\n a[4, 2] := 0; pos[0].x := 4; pos[0].y := 2;\nend;\n\nprocedure __;\nvar\n i: longint;\n c: char;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, n);\n for i:=1 to n do\n begin\n read(fi, c);\n x[i] := ord(c)-48;\n end;\nend;\n\nfunction check(u, v, k1, k2: longint): boolean;\nvar\n x, y: longint;\nbegin\n x := u+k1;\n y := v+k2;\n if (x<1) or (y<1) or (y>3) or (x>4) then exit(false);\n if a[x, y]=-1 then exit(false);\n exit(true);\nend;\n\nprocedure xuly;\nvar\n i, j, k, k1, k2: longint;\n ok: boolean;\nbegin\n if n=1 then\n begin\n writeln(fo,'NO'); exit;\n end;\n\n for i:=1 to 4 do\n for j:=1 to 3 do\n if ((i<>pos[x[1]].x) or (j<>pos[x[1]].y)) and (a[i, j]<>-1) then\n begin\n ok := true;\n for k:=2 to n do\n begin\n k1 := pos[x[k]].x-pos[x[1]].x;\n k2 := pos[x[k]].y-pos[x[1]].y;\n if not check(i, j, k1, k2) then\n begin\n ok := false; break;\n end;\n end;\n if ok then\n begin\n writeln(fo,'NO'); exit;\n end;\n end;\n writeln(fo,'YES');\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n Init;\n __;\n xuly;\n _;\nEND.\n"}, {"source_code": "Const Finp='';\n Fout='';\n ans:array[1..2] of string=('YES','NO');\nVar n:Integer;\n a:array[0..5,0..4] of Integer;\n number:array[1..10] of Integer;\n\nProcedure Input;\nVar f:Text;\n i:Integer;\n c:char;\nBegin\n Assign(f,finp); Reset(f);\n readln(f,n);\n for i:=1 to n do\n begin\n read(f,c);\n number[i]:=ord(c)-48;\n If number[i]=0 then\n number[i]:=11;\n end;\n close(f);\nEnd;\nProcedure Init;\nVar i,j:Integer;\nBegin\n for i:=0 to 5 do\n for j:=0 to 4 do\n a[i,j]:=-1;\n a[1,1]:=1; a[1,2]:=2; a[1,3]:=3;\n a[2,1]:=4; a[2,2]:=5; a[2,3]:=6;\n a[3,1]:=7; a[3,2]:=8; a[3,3]:=9;\n a[4,2]:=11;\nEnd;\nFunction Left:boolean;\nVar i,x,y,m,j,t:Integer;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n If a[j,t]=number[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y-1];\n If m<0 then\n Exit(false);\n end;\n Exit(true);\nEnd;\nFunction Right:boolean;\nVar i,x,y,m,j,t:Integer;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n If a[j,t]=number[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y+1];\n If m<0 then\n Exit(false);\n end;\n Exit(true);\nEnd;\nFunction Up:boolean;\nVar i,x,y,m,j,t:Integer;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n If a[j,t]=number[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x-1,y];\n If m<0 then\n Exit(false);\n end;\n Exit(true);\nEnd;\nFunction Down:boolean;\nVar i,x,y,m,j,t:Integer;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n If a[j,t]=number[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x+1,y];\n If m<0 then\n Exit(false);\n end;\n Exit(true);\nEnd;\nFunction Solve:Integer;\nBegin\n If (left=true) or (right=true) or (up=true) or (down=true) then\n Exit(2);\n Exit(1);\nEnd;\nProcedure Output;\nVar f:Text;\n k:Integer;\nBegin\n Assign(f,fout); rewrite(f);\n k:=solve;\n write(f,ans[k]);\n close(f);\nEnd;\n\nBegin\n Input;\n init;\n Output;\nEnd.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else\n if i mod 3=0 then exit(i div 3) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>4) or (x<1) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=4 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit((x-1)*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=i;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend.\n"}, {"source_code": "var\n j1,ij,w,y,i1,f,k,q,r,h,i,j:longint;\n a:array[0..5,0..5]of integer;\n s:string;\nbegin\n //assign (input,'cinema.in');reset(input);\n //assign(output,'cinema.out');rewrite(output);\n readln(w);\n readln(s);\n for i:=1 to w do\n begin\n val(s[i],y);\n r:=(2+y) div 3;\n if r=0 then r:=4;\n h:=y mod 3 ;\n if h=0 then h:=3;\n if y=0 then h:=2;\n a[r,h]:=1;\n end;\n for i:=0 to 4 do a[0,i]:=2;\n for i:=0 to 4 do a[i,0]:=2;\n for i:=0 to 4 do a[i,4]:=2;\n for i:=0 to 4 do a[5,i]:=2;\n a[4,1]:=2;\n a[4,3]:=2;\n f:=0;\n\n for i:=0 to 5 do for j:=0 to 5 do if f=0 then if a[i,j]=1 then if a[i-1,j]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i+1,j]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i,j-1]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i,j+1]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n\n\n writeln('YES');\nend.\n"}, {"source_code": "uses math;\nvar n,i,j,p,q,o,c,c1,l:longint;\n s:ansistring;\n x,y,a,a1:array[0..100] of longint;\n\n begin\n readln(n);\n readln(s);\n\n if (n=1) then\n begin\n writeln('NO');\n exit;\n end;\n\n\n x[1]:=1;\n y[1]:=1;\n\n x[2]:=2;\n y[2]:=1;\n\n x[3]:=3;\n y[3]:=1;\n\n x[4]:=1;\n y[4]:=2;\n\n x[5]:=2;\n y[5]:=2;\n\n x[6]:=3;\n y[6]:=2;\n\n x[7]:=1;\n y[7]:=3;\n\n x[8]:=2;\n y[8]:=3;\n\n x[9]:=3;\n y[9]:=3;\n\n x[0]:=2;\n y[0]:=4;\n\n\n for i:=1 to n-1 do\n begin\n a[i]:=-(x[ord(s[i])-48]-x[ord(s[i+1])-48]);\n a1[i]:=-(y[ord(s[i])-48]-y[ord(s[i+1])-48]);\n end;\n\n p:=0;\n\n for i:=0 to 9 do\n begin\n q:=0;\n c:=x[i];\n c1:=y[i];\n\n for j:=1 to n-1 do\n begin\n inc(c,a[j]);\n inc(c1,a1[j]);\n o:=0;\n\n // if (i=0) then\n //writeln(c,c1);\n\n for l:=0 to 9 do\n if (x[l]=c) and (y[l]=c1) then inc(o);\n\n if (o=0) then inc(q);\n end;\n if (q=0) then\n inc(p);\n\n end;\n\n\n if (p=1) then writeln('YES') else writeln('NO');\n end.\n"}, {"source_code": "const fi = '';\n\nvar s: string;\n n, i: longint;\n res, co0, co: boolean;\n f: text;\n\nbegin\n assign(f, fi); reset(f);\n readln(f, n);\n readln(f, s);\n close(f);\n\n for i:= 1 to n do if s[i] = '0' then begin co0:= true; break; end;\n res:= false;\n if co0 then\n begin\n for i:= 1 to n do\n if ('1' <= s[i]) and (s[i] <= '3') then res:= true;\n end\n else\n begin\n res:= true; co:= false;\n for i:= 1 to n do\n if ('1' <= s[i]) and (s[i] <= '3') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if ('7' <= s[i]) and (s[i] <= '9') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if (s[i] = '1') or (s[i] = '4') or (s[i] = '7') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if (s[i] = '3') or (s[i] = '6') or (s[i] = '9') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if (s[i] = '7') or (s[i] = '9') then co:= true;\n if not(co) then res:= false;\n end;\n if res then writeln('YES') else writeln('NO');\n readln;\nend."}, {"source_code": "program O_O;\n var\n i,j,k,n,m:longint;\n s:string;\n pd:array[1..4] of boolean;\n b:array[0..10] of boolean;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n b[ord(s[i])-48]:=true;\n for i:=0 to 9 do\n if b[i] then\n begin\n if (i=1)or(i=2)or(i=3) then\n pd[1]:=true;\n if (i=3)or(i=6)or(i=9)or(i=0) then\n pd[2]:=true;\n if (i=1)or(i=4)or(i=7)or(i=0) then\n pd[3]:=true;\n if (i=7)or(i=0)or(i=9) then\n pd[4]:=true;\n end;\n if (pd[1])and(pd[2])and(pd[3])and(pd[4]) then\n writeln('YES')\n else\n writeln('NO');\n readln;\nend."}, {"source_code": "program O_O;\n var\n i,j,k,n,m:longint;\n s:string;\n pd:array[1..4] of boolean;\n b:array[0..10] of boolean;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n b[ord(s[i])-48]:=true;\n for i:=0 to 9 do\n if b[i] then\n begin\n if (i=1)or(i=2)or(i=3) then\n pd[1]:=true;\n if (i=3)or(i=6)or(i=9)or(i=0) then\n pd[2]:=true;\n if (i=1)or(i=4)or(i=7)or(i=0) then\n pd[3]:=true;\n if (i=7)or(i=0)or(i=9) then\n pd[4]:=true;\n end;\n if (pd[1])and(pd[2])and(pd[3])and(pd[4]) then\n writeln('YES')\n else\n writeln('NO');\n readln;\nend."}, {"source_code": "const fi ='';\n fo ='';\n\nvar n,i,j,k,x,y :longint;\n ch :char;\n ok,ok1 :boolean;\n a :array[0..10] of longint;\n b :array[0..9,1..2] of longint=((3,1),(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2));\n\nbegin\n assign(input,fi); reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n a[i]:=ord(ch)-48;\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n ok:=true;\n x:=b[i,1];\n y:=b[i,2];\n for j:=1 to n-1 do\n begin\n x:=x-(b[a[j],1]-b[a[j+1],1]);\n y:=y-(b[a[j],2]-b[a[j+1],2]);\n ok1:=false;\n for k:=0 to 9 do\n if (x=b[k,1]) and (y=b[k,2]) then ok1:=true;\n if not ok1 then ok:=false;\n end;\n if ok then\n begin\n write('NO');\n halt;\n end;\n end;\n write('YES');\nend."}, {"source_code": "const\n xx:array[0..9]of longint=(4,1,1,1,2,2,2,3,3,3);\n yy:array[0..9]of longint=(2,1,2,3,1,2,3,1,2,3);\n\n\nprocedure ans(x:string);\nbegin\n writeln(x);\n halt;\nend;\n\n\nvar\n x,y,a:array[1..10]of longint;\n f,f2:boolean;\n n,i,j,l,px,py:longint;\n c:char;\n\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n a[i]:=ord(c)-48;\n end;\n for i:=1 to n-1 do\n begin\n x[i]:=xx[a[i+1]]-xx[a[i]];\n y[i]:=yy[a[i+1]]-yy[a[i]];\n end;\n for i:=0 to 9 do if i<>a[1] then\n begin\n px:=xx[i];py:=yy[i];f2:=true;\n for j:=1 to n-1 do\n begin\n inc(px,x[j]);\n inc(py,y[j]);\n f:=false;\n for l:=0 to 9 do if (px=xx[l])and(py=yy[l]) then f:=true;\n if not f then\n begin\n f2:=false;\n break;\n end;\n end;\n if f2 then ans('NO');\n end;\n ans('YES');\nend.\nend.\n"}, {"source_code": "var\n n,i,minb,minc,maxb,maxc,q,k,j,curi,curj,count:longint;\n a,b,c,x,y:array[1..1000] of longint;\n s,sd:string;\n begin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n sd:=copy(s,i,1);\n val(sd,a[i],q);\n end;\n for i:=1 to n do begin\n if a[i]=1 then begin b[i]:=1; c[i]:=1; end;\n if a[i]=2 then begin b[i]:=1; c[i]:=2; end;\n if a[i]=3 then begin b[i]:=1; c[i]:=3; end;\n if a[i]=4 then begin b[i]:=2; c[i]:=1; end;\n if a[i]=5 then begin b[i]:=2; c[i]:=2; end;\n if a[i]=6 then begin b[i]:=2; c[i]:=3; end;\n if a[i]=7 then begin b[i]:=3; c[i]:=1; end;\n if a[i]=8 then begin b[i]:=3; c[i]:=2; end;\n if a[i]=9 then begin b[i]:=3; c[i]:=3; end;\n if a[i]=0 then begin b[i]:=4; c[i]:=2; end;\n end;\n for i:=1 to n-1 do x[i]:=b[i+1]-b[i];\n for i:=1 to n-1 do y[i]:=c[i+1]-c[i];\n count:=0;\n\n curi:=4;\n curj:=2;\n q:=0;\n\n for k:=1 to n-1 do begin\n if ((curi+x[k]=4) and (curi+x[k]=4))\n and\n ((curj+y[k]=2) and (curj+y[k]=2))\n then begin inc(q); curi:=4; curj:=2; continue; end;\n\n if ((curi+x[k]>=1) and (curi+x[k]<=3))\n and\n ((curj+y[k]>=1) and (curj+y[k]<=3))\n then begin inc(q); curi:=curi+x[k]; curj:=curj+y[k]; end;\n\n end;\n if q=n-1 then inc(count);\n\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n curi:=i;\n curj:=j;\n q:=0;\n\n for k:=1 to n-1 do begin\n if ((curi+x[k]=4) and (curi+x[k]=4))\n and\n ((curj+y[k]=2) and (curj+y[k]=2))\n then begin inc(q); curi:=4; curj:=2; continue; end;\n\n if ((curi+x[k]>=1) and (curi+x[k]<=3))\n and\n ((curj+y[k]>=1) and (curj+y[k]<=3))\n then begin inc(q); curi:=curi+x[k]; curj:=curj+y[k]; end;\n\n end;\n if q=n-1 then inc(count);\n end;\n end;\n\n if count>1 then\n write('NO')\n else write('YES');\n\n\n end.\n\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (pos('4', s) > 0) and (pos('3', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('1', s) > 0) and (pos('6', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('7', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('4', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('7', s) > 0) and (pos('6', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('1', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "var n, i:longint;\n str: ansistring;\n\nfunction Left(n: longint): boolean;\nbegin\n for i := 1 to n do if ((str[i] = '1') or ((str[i] = '4') or ((str[i] = '7') or (str[i] = '0')))) then exit(false);\n exit(true);\nend;\nfunction Right(n: longint): boolean;\nbegin\n for i := 1 to n do if ((str[i] = '3') or ((str[i] = '6') or ((str[i] = '9') or (str[i] = '0')))) then exit(false);\n exit(true);\nend;\nfunction Up(n: longint): boolean;\nbegin\n for i := 1 to n do if ((str[i] = '1') or ((str[i] = '2') or ((str[i] = '3')))) then exit(false);\n exit(true);\nend;\nfunction Down(n: longint): boolean;\nbegin\n for i := 1 to n do if ((str[i] = '7') or ((str[i] = '0') or ((str[i] = '9')))) then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n read(str);\n if (Left(n) or (Right(n) or (Up(n) or Down(n)))) then write('NO') else write('YES');\nend."}, {"source_code": "{$mode objfpc}\nprogram fafa;\nconst\n inp = '';\n outp = '';\nvar\n fi, fo : text;\n F : array[0..9] of boolean;\n n : integer;\n ok : boolean;\n\nprocedure Enter;\nvar i, p : integer;\n c : char;\nbegin\n readln(fi, n);\n Fillchar(F,sizeof(F),false);\n for i:= 1 to n do\n begin\n read(fi, c);\n val(c,p);\n F[p] := true;\n end;\n\n //for i := 0 to 9 do if F[i] then write(fo, i,' ');\n ok := false;\n if F[0] then\n begin\n if F[1] or F[2] or F[3] then writeln(fo, 'YES')\n else writeln(fo, 'NO');\n end\n else\n begin\n if (not F[1]) and (not F[2]) and (not F[3]) then\n begin\n writeln(fo, 'NO');\n exit;\n end;\n if (not F[1]) and (not F[4]) and (not F[7]) then\n begin\n writeln(fo, 'NO');\n exit;\n end;\n if (not F[3]) and (not F[6]) and (not F[9]) then\n begin\n writeln(fo, 'NO');\n exit;\n end;\n if (not F[7]) and (not F[8]) and (not F[9]) then\n begin\n writeln(fo, 'NO');\n exit;\n end;\n if (F[8]) and (not F[7]) and (not F[9]) then\n begin\n writeln(fo, 'NO');\n exit;\n end;\n writeln(fo, 'YES');\n end;\nend;\n\nbegin\n Assign(fi, inp); reset(fi);\n Assign(fo, outp); rewrite(fo);\n Enter;\n Close(fi); CLose(fo);\nend.\n\n"}, {"source_code": "const maxn=100;\nvar n:longint;\n x,y,o,p:array[0..maxn] of longint;\n kt:array[0..maxn,0..maxn] of boolean;\n\nprocedure mo;\n\tbegin\n\t\tassign(input,'a.INP');\n\t\treset(input);\n\t\tassign(output,'a.OUT');\n\t\trewrite(output);\n\tend;\n\nprocedure dong;\n\tbegin\n\t\tclose(input);\n\t\tclose(output);\n\tend;\n\nprocedure doc;\n var\n i,w:longint;\n q:char;\n\tbegin\n\t readln(n);\n for i:=1 to n do\n begin\n read(q);\n val(q,w);\n if w=0 then\n begin\n x[i]:=4;\n y[i]:=2;\n end\n else\n begin\n x[i]:=w div 3;\n inc(x[i]);\n y[i]:=w mod 3;\n if y[i]=0 then\n begin\n y[i]:=3;\n dec(x[i]);\n end;\n end;\n end;\n\tend;\n\nprocedure xuli;\n var\n i,j,q,w:longint;\n kt1:boolean;\n\tbegin\n o[1]:=-1;\n o[2]:=0;\n o[3]:=1;\n o[4]:=0;\n p[1]:=0;\n p[2]:=1;\n p[3]:=0;\n p[4]:=-1;\n for i:=1 to 3 do\n for j:=1 to 3 do\n kt[i,j]:=true;\n kt[4,2]:=true;\n for i:=1 to 4 do\n begin\n kt1:=true;\n for j:=1 to n do\n begin\n q:=x[j]+o[i];\n w:=y[j]+p[i];\n if kt[q,w]=false then\n begin\n kt1:=false;\n break;\n end;\n end;\n if kt1=true then\n begin\n writeln('NO');\n exit;\n end;\n end;\n writeln('YES');\n\tend;\n\nprocedure xuat;\n\tbegin\n\n\tend;\n\nbegin\n\t//mo;\n\tdoc;\n\txuli;\n\txuat;\n\t//dong;\nend.\n"}, {"source_code": "program cf689A;\nvar board:array[0..5,0..5] of longint;\n flag,can:array[0..5,0..5] of boolean;\n ch:char;\n poss,ans:boolean;\n i,j,di,dj,n,tmp,x,y:longint;\nbegin\n readln(n);\n for i:=1 to 3 do board[1,i]:=i;\n for i:=4 to 6 do board[2,i-3]:=i;\n for i:=7 to 9 do board[3,i-6]:=i;\n board[4,2]:=10;\n for i:=1 to 4 do\n for j:=1 to 4 do\n if board[i,j]>0 then can[i,j]:=true\n else can[i,j]:=false;\n fillchar(flag,sizeof(flag),0);\n for i:=1 to n do\n begin\n read(ch);\n if ch='0' then tmp:=10 else tmp:=ord(ch)-48;\n for x:=1 to 4 do\n for y:=1 to 4 do\n if board[x,y]=tmp then flag[x,y]:=true;\n end;\n ans:=false;\n for di:=-1 to 1 do\n for dj:=-1 to 1 do\n if (di<>0)or(dj<>0) then\n begin\n poss:=true;\n for i:=1 to 4 do\n for j:=1 to 4 do\n if flag[i,j] then\n if not can[i+di,j+dj] then poss:=false;\n ans:=ans or poss;\n end;\n if ans then writeln('NO') else writeln('YES');\nend.\n"}, {"source_code": "const\n fin='mac.inp';fon='mac.out';\nvar t,i,n,d1,d2,d3,d4:longint; s:string; kt:boolean;\n a:array[1..10] of longint;\n\nprocedure solve;\nbegin\nreadln(n); read(s);\nfor i:=1 to n do\n a[i]:=ord(s[i])-48;\nd1:=0; d2:=0; d3:=0; d4:=0;\nfor i:=1 to n do\n begin\n if (a[i]+3=11) or ((a[i]+3<=9) and (a[i]<>0)) then\n begin\n inc(d1);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-3=-3) or (a[i]-3>=1) then\n begin\n inc(d2);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]+1<=9) and (a[i]<>3) and (a[i]<>6) and (a[i]<>0) then\n begin\n inc(d3);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-1>=1) and (a[i]<>4) and (a[i]<>7) and (a[i]<>0) then\n begin\n inc(d4);\n end;\n end;\nkt:=true;\nif (d1=n) or (d2=n) or (d3=n) or (d4=n) then\n kt:=false;\nif kt=false then\n write('NO')\nelse\n write('YES');\nend;\n\nbegin\n//assign(input,fin);reset(input);\n//assign(output,fon);rewrite(output);\nsolve;\nend."}, {"source_code": "var\ns:array[0..4] of string;\nss:string;\ni,j,k,n,ans:integer;\nflag:boolean;\nbegin\ns[0]:='1234567890';\ns[1]:='---1234568';\ns[2]:='456789-0--';\ns[3]:='-12-45-78-';\ns[4]:='23-56-89--';\n readln(n);\n readln(ss);\n ans:=0;\n for j:=1 to 4 do\n begin\n flag:=false;\n for i:=1 to n do\n begin\n for k:=1 to 10 do\n if (s[0][k]=ss[i]) and (s[j][k]='-')\n then flag:=true;\n end;\n if not flag then\n begin\n writeln('NO');\n halt(0);\n end;\n end;\nwriteln('YES');\n\nend."}, {"source_code": "Program ioh;\nType gan=record\n x,y:longint;\n end;\nVar n,i,j,k:longint;\n\n a,road:array[0..10] of gan;\n s:array[1..10] of longint;\n b:array[-5..15,-5..15] of longint;\n x,y:longint;\n res:boolean;\n ch:char;\nBegin\n Readln(n);\n for i:=1 to n do begin\n Read(ch);\n s[i]:=ord(ch)-48;\n End;\n a[0].x:=2;\n a[0].y:=1;\n a[1].x:=1;\n a[1].y:=4;\n a[2].x:=2;\n a[2].y:=4;\n a[3].x:=3;\n a[3].y:=4;\n a[4].x:=1;\n a[4].y:=3;\n a[5].x:=2;\n a[5].y:=3;\n a[6].x:=3;\n a[6].y:=3;\n a[7].x:=1;\n a[7].y:=2;\n a[8].x:=2;\n a[8].y:=2;\n a[9].x:=3;\n a[9].y:=2;\n\n for i:=2 to n do begin\n road[i].x:=a[s[i]].x-a[s[i-1]].x;\n road[i].y:=a[s[i]].y-a[s[i-1]].y;\n //Writeln(road[i].x,road[i].y);\n End;\n for i:=-5 to 15 do\n for j:=-5 to 15 do b[i,j]:=-1;\n k:=1;\n for i:=4 downto 2 do begin\n\n for j:=1 to 3 do begin\n b[i,j]:=k;\n inc(k);\n\n end;\n\n\n End;\n b[1,2]:=0;\n For i:=4 downto 1 do begin\n for j:=1 to 3 do begin\n y:=i;\n x:=j;\n res:=true;\n if b[y,x]<>s[1] then begin\n if b[y,x]=-1 then begin\n res:=false;\n end;\n for k:=2 to n do begin\n //Writeln(x,y,' ',i,j);\n if b[y,x]=-1 then begin\n res:=false;\n Break;\n end;\n inc(x,road[k].x);\n inc(y,road[k].y);\n End;\n if b[y,x]=-1 then begin\n res:=false;\n end;\n if res=true then begin\n Writeln('NO');\n //Writeln(j,' ',i);\n Halt;\n End;\n end;\n End;\n End;\n\n Writeln('YES')\nEnd."}, {"source_code": "Var\ns:string;\nn,l,d,r,u,z,i,f:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='0' then z:=1;\n if (s[i]='1') or (s[i]='2') or (s[i]='3') then u:=1;\n if (s[i]='3') or (s[i]='6') or (s[i]='9') then r:=1;\n if (s[i]='7') or (s[i]='8') or (s[i]='9') then d:=1;\n if (s[i]='1') or (s[i]='4') or (s[i]='7') then l:=1;\n if (s[i]='7') or (s[i]='9') then\n f:=1;\n end;\nif (((u=1) and (r=1) and (d=1) and (l=1)) and (f=1)) or ((z=1) and (u=1)) then\n write('YES')\nelse\n write('NO');\nend."}, {"source_code": "Const Finp='';\n Fout='';\n res:array[1..2] of string=('YES','NO');\nVar n:longint;\n a:array[0..5,0..4] of longint;\n num:array[1..10] of longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\n c:char;\nBegin\n assign(f,finp); reset(f);\n readln(f,n);\n for i:=1 to n do\n begin\n read(f,c);\n num[i]:=ord(c)-48;\n if num[i]=0 then\n num[i]:=11;\n end;\n close(f);\nEnd;\nProcedure Init;\nVar i,j:longint;\nBegin\n for i:=0 to 5 do\n for j:=0 to 4 do\n a[i,j]:=-1;\n a[1,1]:=1; a[1,2]:=2; a[1,3]:=3;\n a[2,1]:=4; a[2,2]:=5; a[2,3]:=6;\n a[3,1]:=7; a[3,2]:=8; a[3,3]:=9;\n a[4,2]:=11;\nEnd;\nFunction Left:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y-1];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Right:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x,y+1];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Up:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x-1,y];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Down:boolean;\nVar i,x,y,m,j,t:longint;\nBegin\n for i:=1 to n do\n begin\n for j:=1 to 4 do\n for t:=1 to 3 do\n if a[j,t]=num[i] then\n begin\n x:=j; y:=t;\n break;\n end;\n m:=a[x+1,y];\n if m<0 then\n exit(false);\n end;\n exit(true);\nEnd;\nFunction Solve:longint;\nBegin\n if (left=true) or (right=true) or (up=true) or (down=true) then\n exit(2);\n exit(1);\nEnd;\nProcedure Xuat;\nVar f:Text;\n k:longint;\nBegin\n assign(f,fout); rewrite(f);\n k:=solve;\n write(f,res[k]);\n close(f);\nEnd;\n\nBegin\n nhap;\n init;\n xuat;\nEnd."}, {"source_code": "uses math;\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n d:array[0..9,1..4] of longint=((1,0,0,0),(0,1,1,0),(0,1,1,1),(0,0,1,1),(1,1,1,0),(1,1,1,1),(1,0,1,1),(1,1,0,0),(1,1,1,1),(1,0,0,1));\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n:longint;\n s:string;\n a:array[0..10] of longint;\n\nprocedure mofile;\nbegin\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure xuli;\nvar\n i,j:longint;\n ok:boolean;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do a[i]:=ord(s[i])-ord('0');\n\n for i:=1 to 4 do\n begin\n ok:=true;\n for j:=1 to n do\n begin\n if d[a[j],i]=0 then\n begin\n ok:=false;\n break;\n end;\n end;\n if ok then break;\n end;\n\n if ok then writeln('NO') else writeln('YES');\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$Mode objfpc}\n\nvar\n n,i,j,o,kq:integer;\n s:char;\n check:boolean;\n a:array[0..10] of boolean;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[ord(s)-48]:=true;\n end;\n if a[1] or a[2] or a[3] then inc(kq);\n if a[1] or a[4] or a[7] then inc(kq);\n if a[3] or a[6] or a[9] then inc(kq);\n if a[7] or a[0] or a[9] then inc(kq);\n if a[0] and (a[1] or a[2] or a[3]) then write('YES')\n else\n if kq < 4 then write('NO')\n else write('YES');\nend."}, {"source_code": "var\n i, j, a, a1, n,f1: integer;\n x: array [1..6, 1..6] of integer;\n y: array [1..10] of integer;\n f:integer;\n\nbegin\nf1:=0;\n f := 0;\n read(n);\n for i := 1 to 6 do\n for j := 1 to 5 do\n x[i, j] := 0;\n for i := 2 to 4 do\n for j := 2 to 4 do\n x[i, j] := 1;\n x[5,3] := 1;\n read(a1);\n for i := 1 to n do \n begin\n a := a1 mod 10;\n a1 := a1 div 10;\n if a <4 then y[i]:=20 else if a < 7 then y[i]:= 30 else y[i]:=40;\n if (a=1)or (a=4) or (a=7) then y[i]:=y[i]+2;\n if (a=2)or (a=5) or (a=8)then y[i]:=y[i]+3;\n if (a=3)or (a=6) or (a=9) then y[i]:=y[i]+4;\n if a=0 then y[i]:=53;\n { x[a div 4 + 2, a mod 4 + 1] := 2;\n y[i] := (a div 4 + 2) * 10 + a mod 4 + 1;}\n end;\n for i:=1 to n do\n x[y[i] div 10 , y[i] mod 10]:=2;\n f:=0;\n for i := 1 to n do\n if x[y[i] div 10 + 1, y[i] mod 10] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then }for i := 1 to n do\n if x[y[i] div 10 - 1, y[i] mod 10] < 1 then begin f := f+1; break; end else f1:=1;\n \n { if f then} for i := 1 to n do\n if x[y[i] div 10, y[i] mod 10 + 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then} for i := 1 to n do\n if x[y[i] div 10, y[i] mod 10 - 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then} for i := 1 to n do\n if x[y[i] div 10 + 1, y[i] mod 10 + 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then} for i := 1 to n do\n if x[y[i] div 10 + 1, y[i] mod 10 - 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then} for i := 1 to n do\n if x[y[i] div 10 - 1, y[i] mod 10 - 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n {if f then} for i := 1 to n do\n if x[y[i] div 10 - 1, y[i] mod 10 + 1] < 1 then begin f := f+1; break; end else f1:=1;\n \n if f< 8 then writeln('NO') else writeln('YES');\n //if f1>0 then writeln ('no') else writeln('yes');\n {for i:=1 to 6 do\n begin\n {for j:=1 to 6 do\n write(x[i,j],' ');\n writeln;\n end;}\nend."}, {"source_code": "{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\nuses math;\nconst log=18;\n ms=1e-9;\n oo=round(1e9);\n modulo=1000000007;\n fi='';\n fo='';\n maxn=100010;\n move:array[0..9,1..4]of longint=((8,-1,-1,-1),(-1,2,4,-1),(-1,3,5,1),(-1,-1,6,2),(1,5,7,-1),(2,6,8,4),(3,-1,9,5),(4,8,-1,-1),(5,9,0,7),(6,-1,-1,8));\n\nvar f1,f2:text;\n a,b:array[0..10]of longint;\n n:longint;\n\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\n\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure input;\n var i:longint;\n ch:char; \n begin\n readln(f1,n);\n for i:=1 to n do\n begin\n read(f1,ch);\n a[i]:=ord(ch)-ord('0');\n end;\n end;\n\n\nprocedure init;\n var i,j:longint;\n check:boolean;\n begin\n for i:=1 to 4 do\n begin\n check:=true;\n for j:=1 to n do\n b[j]:=move[a[j],i];\n for j:=1 to n do\n if b[j]=-1 then check:=false;\n if check then\n begin\n writeln(f2,'NO');\n closefile;\n halt;\n end;\n end;\n end;\n\nprocedure solve;\n var i,j:longint;\n begin\n writeln(f2,'YES');\n end;\n\nprocedure output;\n var i:longint;\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n\n"}, {"source_code": "var n,i,x:longint;\n a:array[1..9] of longint;\n sl:string; bl:boolean;\nbegin\n readln(n);\n readln(sl);\n for i:=1 to n do\n begin\n val(sl[i],x);\n a[i]:=x;\n end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 0 then\n if a[i] - 3 <= 0 then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] + 3 >= 10) or (a[i] = 0) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 3) or (a[i] = 6) or (a[i] = 9) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 1) or (a[i] = 4) or (a[i] = 7) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "const\n d:array[1..4,'0'..'9'] of longint= //wsad\n ((8,-1,-1,-1,1,2,3,4,5,6),\n (-1,4,5,6,7,8,9,-1,0,-1),\n (-1,-1,1,2,-1,4,5,-1,7,8),\n (-1,2,3,-1,5,6,-1,8,9,-1));\nvar\n st:string;\n len,i,j:longint;\n flag:boolean;\nbegin\n readln(len);\n readln(st);\n for j:=1 to 4 do\n begin\n flag:=true;\n\t for i:=1 to len do\n\t\tif d[j][st[i]]=-1 then\n\t\t begin\n\t\t\tflag:=false;\n\t\t\tbreak;\n\t\t end;\n\t if flag then\n\t\tbegin\n\t\t writeln('NO');\n\t\t halt;\n\t\tend;\n\tend;\n writeln('YES');\t\nend."}, {"source_code": "type vector = record\n x,y:longint;\n end;\nconst tmp:Array[0..9,1..2] of longint = ((1,0),(0,3),(1,3),(2,3),(0,2),(1,2),(2,2),(0,1),(1,1),(2,1));\n{operator + (a,b:vector) c:vector;\n begin c.x:=a.x+b.x; c.y:=a.y+b.y; end;\noperator - (a,b:vector) c:vector;\n begin c.x:=a.x-b.x; c.y:=a.y-b.y; end; }\nfunction plus(a,b:vector):vector;\n begin plus.x:=a.x+b.x; plus.y:=a.y+b.y; end;\nfunction minus(a,b:vector):vector;\n begin minus.x:=a.x-b.x; minus.y:=a.y-b.y; end;\nvar a:array[0..9] of vector;\n route:array[0..9] of vector;\n flag:boolean;\n ppp:vector;\n num,i,j,n,x,now:longint;\n s:string;\nbegin\n readln(n);\n for i:=0 to 9 do\n with a[i] do begin\n x:=tmp[i,1]; y:=tmp[i,2];\n end;\n readln(s); val(s[1],x);\n for i:=2 to n do begin\n val(s[i],now); route[i-1]:=minus(a[now],a[x]); x:=now;\n end;\n for i:=0 to 9 do begin\n ppp:=a[i]; flag:=true;\n for j:=1 to n-1 do begin\n ppp:=plus(ppp,route[j]);\n with ppp do begin\n if (x<0) or (x>2) then begin flag:=false; break; end;\n if (y<0) or (y>3) then begin flag:=false; break; end;\n if (x=0) and (y=0) then begin flag:=false; break; end;\n if (x=2) and (y=0) then begin flag:=false; break; end;\n end;\n end;\n if flag then inc(num);\n end;\n if num>1 then writeln('NO') else writeln('YES');\nend."}, {"source_code": "var\na:array[1..109]of longint;\ns:string;\nn,i,q:longint;\ne,b,c,d:boolean;\nbegin\nreadln(n);\ne:=true;\nb:=true;\nc:=true;\nd:=true;\nreadln(S);\nfor i:=1 to n do begin\nval(s[i],a[i],q);\nif (a[i]<4) and(a[i]<>0)\nthen e:=false;\nif (a[i]=1)or(a[i]=4)or(a[i]=7)or(a[i]=0)\nthen b:=false;\nif(a[i]=3)or(a[i]=6)or(a[i]=9)or(A[i]=0)\nthen c:=false;\nif (a[i]=7)or(a[i]=0)or(a[i]=9)\nthen d:=false;\nend;\nif e or b or c or d\nthen writeln('NO')\nelse writeln('YES');\nend.\n\n"}, {"source_code": "var s:string;\na:array[-2..7,-2..7]of char;\nx:char;\nb,c:array['0'..'9']of longint;\ni,j,n,t,q,w:longint;\nk:boolean;\nbegin\nreadln(n);\nreadln(s);\nfor i:=-2 to 7 do\n for j:=-2 to 7 do\n a[i,j]:='.';\na[1,1]:='1';\na[1,2]:='2';\na[1,3]:='3';\na[2,1]:='4';\na[2,2]:='5';\na[2,3]:='6';\na[3,1]:='7';\na[3,2]:='8';\na[3,3]:='9';\na[4,2]:='0';\ni:=1; j:=1;\nfor x:='1' to '9' do\n begin\n if j=4 then\n begin\n inc(i);\n j:=1;\n end;\n b[x]:=i; c[x]:=j;\n inc(j);\n end;\nb['0']:=4;\nc['0']:=2;\nq:=b[s[1]];\nw:=c[s[1]];\n//writeln(q,' ',w);\nfor i:=1 to 4 do\n for j:=1 to 4 do\n if (i<>q)or(j<>w) then\n begin\n //writeln(i,' ',j);\n k:=true;\n for t:=1 to n do\n begin\n //writeln(a[b[s[t]]-q+i,c[s[t]]-w+j]);\n if a[b[s[t]]-q+i,c[s[t]]-w+j]='.' then k:=false;\n end;\n //writeln('z');\n if k=true then\n begin\n writeln('NO');\n exit;\n end;\n end;\nwriteln('YES');\nend."}, {"source_code": " {$mode objfpc}\n {$coperators on}\nuses math;\nconst\n {$ifdef online_judge} ifstream=''; ofstream='';\n {$else} ifstream='inp.inp'; ofstream='out.out';\n {$endif}\n x : array[0..9] of integer = (4, 1, 1, 1, 2, 2, 2, 3, 3, 3);\n y : array[0..9] of integer = (2, 1, 2, 3, 1, 2, 3, 1, 2, 3);\nvar\n n: longint;\n f:array[-100..100, -100..100] of boolean;\n a, b:array[1..100] of record x,y:longint; end;\n s:string;\nprocedure enter;\nvar i, j : longint;\n begin\n for i:=0 to 9 do f[x[i],y[i]]:=true;\n readln(n);\n readln(s);\n for i:=1 to length(s) do begin a[i].x:=x[ord(s[i])-48]; a[i].y:=y[ord(s[i])-48]; b[i]:=a[i]; end;\n end;\nprocedure solve;\nvar i, j : longint; ok:boolean;\n begin\n ok:=false;\n for i:=1 to n do\n begin\n b[i].x:=a[i].x+1;\n if (not f[b[i].x][b[i].y]) then\n begin\n ok:=true;\n break;\n end;\n end;\n if not ok then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to length(s) do begin a[i].x:=x[ord(s[i])-48]; a[i].y:=y[ord(s[i])-48]; b[i]:=a[i]; end;\n ok:=false;\n for i:=1 to n do\n begin\n b[i].x:=a[i].x-1;\n if (not f[b[i].x][b[i].y]) then\n begin\n ok:=true;\n break;\n end;\n end;\n if not ok then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to length(s) do begin a[i].x:=x[ord(s[i])-48]; a[i].y:=y[ord(s[i])-48]; b[i]:=a[i]; end;\n ok:=false;\n for i:=1 to n do\n begin\n b[i].y:=a[i].y+1;\n if (not f[b[i].x][b[i].y]) then\n begin\n ok:=true;\n break;\n end;\n end;\n if not ok then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to length(s) do begin a[i].x:=x[ord(s[i])-48]; a[i].y:=y[ord(s[i])-48]; b[i]:=a[i]; end;\n ok:=false;\n for i:=1 to n do\n begin\n b[i].y:=a[i].y-1;\n if (not f[b[i].x][b[i].y]) then\n begin\n ok:=true;\n break;\n end;\n end;\n if not ok then\n begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\n end;\nbegin\n\n assign(input, ifstream); reset(input);\n assign(output, ofstream); rewrite(output);\n enter;\n Solve;\n close(input);\n close(output);\nend."}, {"source_code": "\nType small = -1..9;\n rec = Record\n digit,x,y: small;\n End;\n marray = array[1..100] Of rec;\n\nProcedure order(Var mat:marray;k:byte;xi,yi:small);\nBegin\n mat[k].x := xi;\n mat[k].y := yi;\nEnd;\n\nProcedure modify(rat:marray;k:byte;mx,my:small; Var cunt:byte);\nBegin\n rat[k].x := rat[k].x+mx;\n rat[k].y := rat[k].y+my;\n If (rat[k].x In [1..3]) And (rat[k].y In [1..3]) Then cunt := cunt+1\n Else If (rat[k].x=4) And (rat[k].y=2) Then cunt := cunt+1;\nEnd;\n\nVar n,i,j,valid: byte;\n s: string;\n a: small;\n r: marray;\n validity: boolean;\nBegin\n validity := true;\n readln(n);\n readln(s);\n For i:=1 To n Do\n Begin\n a := ord(s[i])-48;\n r[i].digit := a;\n Case a Of \n 1: order(r,i,1,1);\n 2: order(r,i,1,2);\n 3: order(r,i,1,3);\n 4: order(r,i,2,1);\n 5: order(r,i,2,2);\n 6: order(r,i,2,3);\n 7: order(r,i,3,1);\n 8: order(r,i,3,2);\n 9: order(r,i,3,3);\n 0: order(r,i,4,2);\n End;\n End;\n For i:=1 To 8 Do\n Begin\n valid := 0;\n Case i Of \n 1: For j:=1 To n Do\n modify(r,j,-1,0, valid);\n 2: For j:=1 To n Do\n modify(r,j,-1,1,valid);\n 3: For j:=1 To n Do\n modify(r,j,0,1, valid);\n 4: For j:=1 To n Do\n modify(r,j,1,1, valid);\n 5: For j:=1 To n Do\n modify(r,j,1,0, valid);\n 6: For j:=1 To n Do\n modify(r,j,1,-1, valid);\n 7: For j:=1 To n Do\n modify(r,j,0,-1, valid);\n 8: For j:=1 To n Do\n modify(r,j,-1,-1, valid);\n End;\n\n If valid=n Then\n Begin\n validity := false;\n break;\n End;\n End;\n If validity=true Then writeln('Yes')\n Else writeln('No');\nEnd."}, {"source_code": "var s:string;\nn,i,j,k,l,r,u,d,z,m:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\nif (s[i]='0') then z:=1;\nif (s[i]='1') or (s[i]='4') or (s[i]='7') then l:=1;\nif (s[i]='3') or (s[i]='6') or (s[i]='9') then r:=1;\nif (s[i]='1') or (s[i]='2') or (s[i]='3') then u:=1;\nif (s[i]='7') or (s[i]='9') then d:=1;\nend;\nif ((l=1) and (r=1) and (u=1) and (d=1)) or ((z=1) and (u=1)) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var\n a, b, i, k: int64;\n c, c1: char;\n ar: array [0..100] of char;\n arr: array [1..10, 1..10] of int64;\n q, q1, q2, q3: boolean;\n \nbegin\n readln(a);\n i := 0;\n while i < a do begin\n read(ar[i]);\n inc(i);\n end;\n i := 0;\n while i < a do begin\n k := ord(ar[i]) - 48;\n if (k < 4) and (k <> 0) then q := true;\n if (k = 1) or (k = 4) or (k = 7) or (k = 0) then q1 := true;\n if (k = 7) or (k = 0) or (k = 9) then q2 := true;\n if (k = 3) or (k = 6) or (k = 9) or (k = 0) then q3 := true;\n inc(i);\n end;\n if (q) and (q1) and (q2) and (q3) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "const\n fin='mac.inp';fon='mac.out';\nvar t,i,n,d1,d2,d3,d4:longint; s:string; kt:boolean;\n a:array[1..10] of longint;\n\nprocedure solve;\nbegin\nreadln(n); read(s);\nfor i:=1 to n do\n a[i]:=ord(s[i])-48;\nd1:=0; d2:=0; d3:=0; d4:=0;\nfor i:=1 to n do\n begin\n if (a[i]+3=11) or ((a[i]+3<=9) and (a[i]<>0)) then\n begin\n inc(d1);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-3=-3) or (a[i]-3>=1) then\n begin\n inc(d2);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]+1<=9) and (a[i]<>3) and (a[i]<>6) and (a[i]<>0) then\n begin\n inc(d3);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-1>=1) and (a[i]<>4) and (a[i]<>7) and (a[i]<>0) then\n begin\n inc(d4);\n end;\n end;\nkt:=true;\nif (d1=n) or (d2=n) or (d3=n) or (d4=n) then\n kt:=false;\nif kt=false then\n write('NO')\nelse\n write('YES');\nend;\n\nbegin\n//assign(input,fin);reset(input);\n//assign(output,fon);rewrite(output);\nsolve;\nend.\n"}, {"source_code": "program yan;\n var ar:array[1..9]of char;\n ax:array[0..5,0..5]of char;\n i,j,x,y,b,a,n,m:longint; x1,x2,x3,x4:longint; c:char;\nbegin\n for i:=0 to 5 do\n for j:=0 to 5 do ax[i,j]:='a';\n c:='1';\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n ax[i,j]:=c; inc(c);\n end;\n ax[4,2]:='0';\n readln(n);\n for i:=1 to n do\n read(ar[i]);\n for i:=1 to n do\n for a:=1 to 4 do\n for b:=1 to 4 do\n begin\n if (ar[i]=ax[a,b]) then\n begin\n if ax[a+1,b]<>'a' then inc(x1);\n if ax[a-1,b]<>'a' then inc(x2);\n if ax[a,b+1]<>'a' then inc(x3);\n if ax[a,b-1]<>'a' then inc(x4);\n end;\n end;\n if (x1=n)or(x2=n)or(x3=n)or(x4=n) then write('NO') else write('YES');\nend.\n"}, {"source_code": "var n, i : integer;\n c : char;\n up, down, left, rigth : boolean;\nbegin\n readln(n);\n for i := 1 to n do begin\n read(c);\n if c = '0' then begin\n down := true;\n left := true;\n rigth := true;\n end;\n if c = '1' then begin\n up := true;\n left := true;\n end;\n if c = '2' then \n up := true;\n if c = '3' then begin\n rigth := true;\n up := true;\n end;\n if c = '4' then\n left := true;\n if c = '6' then\n rigth := true;\n if c = '7' then begin\n left := true;\n down := true;\n end;\n if c = '9' then begin\n down := true;\n rigth := true;\n end;\n end;\n if up and down and left and rigth then\n writeln('YES')\n else\n writeln('NO');\nend.\n \n \n "}, {"source_code": "var ch:char;\n n,i:longint;\n left,right,up,down,zero:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(ch);\n if (ch='1') or (ch='4') or (ch='7') then\n left:=true;\n if (ch='3') or (ch='6') or (ch='9') then\n right:=true;\n if (ch='1') or (ch='2') or (ch='3') then\n up:=true;\n if (ch='7') or (ch='9') then\n down:=true;\n if (ch='0') then\n zero:=true;\n end;\nif (zero and up) or (left and right and up and down) then\n writeln('YES')\nelse\n writeln('NO');\nend.\n"}, {"source_code": "var\n f,fk : array[-50..50,-50..50] of longint;\n x,y : array[0..15] of longint;\n n,i,j,xx,yy,q,a,x1,y1,k,aa : longint;\n c : char;\n ff : boolean;\n\nbegin\n readln(n);\n fillchar(f,sizeof(f),62);\n f[1,1]:=1; f[1,2]:=2; f[1,3]:=3;\n f[2,1]:=4; f[2,2]:=5; f[2,3]:=6;\n f[3,1]:=7; f[3,2]:=8; f[3,3]:=9;\n f[4,2]:=0;\n for i:=0 to 5 do for j:=0 to 5 do if f[i,j] in [0..9] then fk[i,j]:=1;\n read(c); a:=ord(c)-48; aa:=a;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin xx:=i; yy:=j; break; end;\n for q:=2 to n do begin\n read(c);\n a:=ord(c)-48;\n inc(k);\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin x1:=i; y1:=j; break; end;\n x[k]:=x1-xx; y[k]:=y1-yy;\n xx:=x1; yy:=y1;\n end;\n readln;\n for q:=0 to 9 do begin\n if q = aa then continue;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = q then begin xx:=i; yy:=j; break; end;\n ff:=false;\n for i:=1 to k do begin\n x1:=xx+x[i]; y1:=yy+y[i];\n if fk[x1,y1] = 0 then begin ff:=true; break; end;\n xx:=x1; yy:=y1;\n end;\n if not ff then begin writeln('NO'); halt; end;\n end;\n writeln('YES');\nend."}, {"source_code": "var\n ok:boolean;\n i,j,k,c,x,y,d:integer;\n s:string;\n w: char;\nbegin\n readln(s);\n readln(s);\n c:=0;\n ok:=false;\n x:=0;\n y:=0;\n d:=0;\n for i:=-3 to 3 do\n begin\n for j:=-3 to 2 do\n begin\n ok:=true;\n for k:=1 to length(s) do\n begin\n d:=ord(s[k]);\n if d=48 then\n begin\n x:=1;\n y:=3;\n end else \n begin\n if d <=51 then begin\n x:=d-49;\n y:=0;\n end else\n begin\n if d <=54 then begin\n x:=d-52;\n y:=1;\n end else begin\n x:=d-55;\n y:=2;\n end;\n end;\n end;\n x:=x+j;\n y:=y+i;\n if (not (((x>=0) and (y>=0) and (x <=2) and (y <=2)) or ((x=1) and (y=3)))) then ok :=false;\n end;\n if ok then c:=c+1;\n end;\n end;\n if c =1 then begin s:='YES'; end else s:='NO';\n writeln(s);\nend."}, {"source_code": "const\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (pos('4', s) > 0) and (pos('3', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('1', s) > 0) and (pos('6', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('7', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('4', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('7', s) > 0) and (pos('6', s) > 0) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('1', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,ans:longint; Z,f1,f2,f3,f4:array[0..5,0..4] of byte;\nch:char;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor k:=1 to n do\n begin\n read(ch);\n i:=0; j:=0;\n a:=ord(ch)-48;\n if a=0 then begin i:=4; j:=2; end\n else\n begin\n if a mod 3=0 then i:=i-1; i:=i+(a div 3)+1;\n j:=(a mod 3); if j=0 then j:=3;\n end;\n Z[i,j]:=1;\n end;\nif Z[4,2]=1 then ans:=ans+1 else\nfor i:=1 to 3 do\nif Z[i,1]=1 then begin ans:=ans+1; break; end;\nif Z[4,2]=1 then ans:=ans+1 else\nfor i:=1 to 3 do\nif Z[i,3]=1 then begin ans:=ans+1; break; end;\nfor j:=1 to 3 do\nif Z[1,j]=1 then begin ans:=ans+1; break; end;\nif (Z[3,1]=1) or (Z[4,2]=1) or (Z[3,3]=1) then ans:=ans+1;\nif ans=4 then write('YES') else write('NO');\nend."}, {"source_code": "var n,u,d,l,r:longint;\n a:ansistring;\nbegin\n readln(n);\n readln(a);\n for n:=1 to n do\n begin\n if a[n]='0' then begin l:=1;r:=1;d:=1;end;\n if a[n]in['1','2','3'] then u:=1;\n if a[n]in['1','4','7'] then l:=1;\n if a[n]in['3','6','9'] then r:=1;\n if a[n]in['7','9'] then d:=1;\n end;\n if u*l*r*d=1 then writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\n x:array[1..10] of integer=(0,1,2,0,1,2,0,1,2,1);\n y:array[1..10] of integer=(0,0,0,1,1,1,2,2,2,3);\nvar\n n,i,j:integer;\n a:array[1..10] of integer;\n pr_x:array[1..9] of integer;\n pr_y:array[1..9] of integer;\n pr_x2:array[1..9] of integer;\n pr_y2:array[1..9] of integer;\n xc,yc:integer;\n dx,dy:integer;\n can:boolean;\n h,v:integer;\n s:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n readln(s);\n fillchar(pr_x,sizeof(pr_x),0);\n fillchar(pr_y,sizeof(pr_x),0);\n fillchar(pr_x2,sizeof(pr_x),0);\n fillchar(pr_y2,sizeof(pr_x),0);\n for i:=1 to n do\n a[i]:=strtoint(s[i]);\n for i:=1 to n-1 do\n begin\n if a[i+1]=0 then\n h:=10\n else\n h:=a[i+1];\n if a[i]=0 then\n v:=10\n else\n v:=a[i];\n pr_x[i]:=x[h]-x[v];\n pr_y[i]:=y[h]-y[v];\n end;\n for i:=1 to 10 do\n begin\n if(a[1]=0) and (i=10) then\n continue;\n if(a[1]=i) then\n continue;\n xc:=x[i];\n yc:=y[i];\n can:=true;\n for j:=1 to n-1 do\n begin\n xc:=xc+pr_x[j];\n yc:=yc+pr_y[j];\n if (((xc<0) or (xc>2) or (yc>2) or (yc<0) ) and not ((xc=1) and (yc=3))) then\n begin\n can:=false\n end;\n end;\n if can then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\n //close(input);\n //close(output);\nend.\n"}], "negative_code": [{"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\n x:array[1..10] of integer=(0,1,2,0,1,2,0,1,2,1);\n y:array[1..10] of integer=(0,0,0,1,1,1,2,2,2,3);\nvar\n n,i,j:integer;\n a:array[1..10] of integer;\n pr_x:array[1..9] of integer;\n pr_y:array[1..9] of integer;\n pr_x2:array[1..9] of integer;\n pr_y2:array[1..9] of integer;\n xc,yc:integer;\n dx,dy:integer;\n can:boolean;\n h,v:integer;\n s:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n readln(s);\n fillchar(pr_x,sizeof(pr_x),0);\n fillchar(pr_y,sizeof(pr_x),0);\n fillchar(pr_x2,sizeof(pr_x),0);\n fillchar(pr_y2,sizeof(pr_x),0);\n for i:=1 to n do\n a[i]:=strtoint(s[i]);\n for i:=1 to n-1 do\n begin\n if a[i+1]=0 then\n h:=10\n else\n h:=a[i+1];\n if a[i]=0 then\n v:=10\n else\n v:=a[i];\n pr_x[i]:=x[h]-x[a[v]];\n pr_y[i]:=y[a[h]]-y[a[v]];\n end;\n for i:=1 to 10 do\n begin\n if(a[1]=0) and (i=10) then\n continue;\n if(a[1]=i) then\n continue;\n xc:=x[i];\n yc:=y[i];\n can:=true;\n for j:=1 to n-1 do\n begin\n xc:=xc+pr_x[j];\n yc:=yc+pr_y[j];\n if (((xc<0) or (xc>2) or (yc>2) or (yc<0) ) and not ((xc=1) and (yc=3))) then\n begin\n can:=false\n end;\n end;\n if can then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\n x:array[1..10] of integer=(0,1,2,0,1,2,0,1,2,1);\n y:array[1..10] of integer=(0,0,0,1,1,1,2,2,2,3);\nvar\n n,i,j:integer;\n a:array[1..10] of integer;\n pr_x:array[1..9] of integer;\n pr_y:array[1..9] of integer;\n pr_x2:array[1..9] of integer;\n pr_y2:array[1..9] of integer;\n xc,yc:integer;\n dx,dy:integer;\n can:boolean;\n s:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n readln(s);\n fillchar(pr_x,sizeof(pr_x),0);\n fillchar(pr_y,sizeof(pr_x),0);\n fillchar(pr_x2,sizeof(pr_x),0);\n fillchar(pr_y2,sizeof(pr_x),0);\n for i:=1 to n do\n a[i]:=strtoint(s[i]);\n for i:=1 to n-1 do\n begin\n pr_x[i]:=x[a[i+1]]-x[a[i]];\n pr_y[i]:=y[a[i+1]]-y[a[i]];\n end;\n for i:=1 to 10 do\n begin\n if(a[1]=i) then\n continue;\n xc:=x[i];\n yc:=y[i];\n can:=true;\n for j:=1 to n-1 do\n begin\n xc:=xc+pr_x[j];\n yc:=yc+pr_y[j];\n if (((xc<0) or (xc>2) or (yc>2) or (yc<0) ) and not ((xc=1) and (yc=3))) then\n begin\n can:=false\n end;\n end;\n if can then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\n x:array[1..10] of integer=(0,1,2,0,1,2,0,1,2,1);\n y:array[1..10] of integer=(0,0,0,1,1,1,2,2,2,3);\nvar\n n,i,j:integer;\n a:array[1..10] of integer;\n pr_x:array[1..9] of integer;\n pr_y:array[1..9] of integer;\n pr_x2:array[1..9] of integer;\n pr_y2:array[1..9] of integer;\n xc,yc:integer;\n dx,dy:integer;\n can:boolean;\n s:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n readln(s);\n fillchar(pr_x,sizeof(pr_x),0);\n fillchar(pr_y,sizeof(pr_x),0);\n fillchar(pr_x2,sizeof(pr_x),0);\n fillchar(pr_y2,sizeof(pr_x),0);\n for i:=1 to n do\n a[i]:=strtoint(s[i]);\n for i:=1 to n-1 do\n begin\n pr_x[i]:=x[a[i+1]]-x[a[i]];\n pr_y[i]:=y[a[i+1]]-y[a[i]];\n end;\n for i:=1 to 9 do\n begin\n if(a[1]=i) then\n continue;\n xc:=x[i];\n yc:=y[i];\n can:=true;\n for j:=1 to n-1 do\n begin\n xc:=xc+pr_x[j];\n yc:=yc+pr_y[j];\n if (((xc<0) or (xc>2) or (yc>2) or (yc<0) ) and not ((xc=1) and (yc=3))) then\n begin\n can:=false\n end;\n end;\n if can then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, i, cur : longint;\n u, d, l, r : boolean;\n c : char;\n\nbegin\n// assign(input, 'input.txt'); assign(output, 'output.txt');\n readln(n);\n for i := 1 to n do\n begin\n read(c);\n cur := ord(c) - ord('0');\n if (cur > 0) and (cur < 4) then\n u := True;\n if (cur = 7) or (cur = 0) or (cur = 9) then\n d := True;\n if (cur = 1) or (cur = 4) or (cur = 7) then\n l := True;\n if (cur = 3) or (cur = 6) or (cur = 9) then\n r := True;\n end;\n\n if (u and d) or (l and r) then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, i, cur : longint;\n u, d, l, r : boolean;\n c : char;\n\nbegin\n// assign(input, 'input.txt'); assign(output, 'output.txt');\n readln(n);\n for i := 1 to n do\n begin\n read(c);\n cur := ord(c) - ord('0');\n if (cur > 0) and (cur < 4) then\n u := True;\n if (cur = 7) or (cur = 0) or (cur = 9) then\n d := True;\n if (cur = 1) or (cur = 4) or (cur = 7) then\n l := True;\n if (cur = 3) or (cur = 6) or (cur = 9) then\n r := True;\n end;\n\n if (u and d) and (l and r) then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": " \n const eps=0.0000000001; besk=8000000000000000000; nn=200000;\n modul=1000000007;\n label 1,2;\n type\n mas=array [-10000..nn] of int64; { point=record x,y,z:real;end; }\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..5] of int64;mass1=^mass;\n var imax,imin,jmax,jmin,koln,kfin,distmin,ii,jj,kk,zn,razmax,pmin,pmax,sch,iistart,xmax,ymin,n,qq,ot,q,pos,left,right,amax,ost,h,tt,t1,pp,p,p1,p2,p3,p4,t,nm,s1,s2,m,s,cen,t2,i1:int64;\n stepp,iii,mask,newug,newdl,dloch,dugol,ist,jst,ifin,jfin,fin,newnapx,newnapy,step, k,i,j:longint;\n oldnap, napr,alpha,prmax,v,aaa,bbb,ccc:extended; hhh:zap;\n napx,napy,x,first,next,prev,l,r, dl,ochnewi,ochnewj,ochj,c,y,z,newoch,och,aold,b,a:array[-100000..2000000] of int64;\n stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;\n marked:array[-10..1100000] of boolean;\n yyy,xx:mass;\n ss, ss1,ss2:string;\n point:array[0..200000] of mass;\n sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;\n zan:array[-10..20,010..200] of boolean;\n sss: array[-10..100000] of string;ch3,ch,ch1,ch2:char;\n dp:array[-1..500,-1..500,-1..500]of boolean;\n clav:array[-10..300,-10..300] of int64;\n ugol:array[0..5000,0..5000] of double;\n\n ddmax,ddmin :array[-1..300000,-1..20] of extended;\n chh,pole :array [-10..200,-10..200] of char;\n maxpr:array[0..nn] of string;\n str:array[0..nn] of string;\n nap,tt1,tt2,disk,v0,v1,s0,t0:extended;\n newx,newy,yy:array[-100..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ii,jj:longint):boolean; var fl:boolean;\ni,j:longint;\n begin\n fl:=false;\n if clav[ii,jj]>=0 then fl:=true;\n good:=fl;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n napx[1]:=1; napy[1]:=0;\n napx[1]:=-1; napy[1]:=0;\n napx[1]:=0; napy[1]:=1;\n napx[1]:=0; napy[1]:=-1;\n\n for i:=-10 to 100 do for j:=-10 to 100 do clav[i,j]:=-1;\n clav[1,1]:=1;\n clav[1,2]:=2;\n clav[1,3]:=3;\n clav[2,1]:=4;\n clav[2,2]:=5;\n clav[2,3]:=6;\n clav[3,1]:=7;\n clav[3,2]:=8;\n clav[3,3]:=9;\n clav[4,2]:=0;\n for step:=1 to n do\n begin\n t:=ord(ss[step])-48;\n for i:=0 to 4 do for j:=0 to 4 do\n if clav[i,j]=t then zan[i,j]:=true;\n\n end;\n\n for step:=1 to 4 do\n begin\n flag:=true;\n for i:=1 to 4 do for j:=1 to 4 do if zan[i,j] then\n begin\n if not good(i+napx[step],j+napy[step]) then flag:=false;\n\n end;\n if flag then begin writeln('NO'); goto 1; end;\n\n end;\n writeln('YES');\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " \n const eps=0.0000000001; besk=8000000000000000000; nn=200000;\n modul=1000000007;\n label 1,2;\n type\n mas=array [-10000..nn] of int64; { point=record x,y,z:real;end; }\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..5] of int64;mass1=^mass;\n var imax,imin,jmax,jmin,koln,kfin,distmin,ii,jj,kk,zn,razmax,pmin,pmax,sch,iistart,xmax,ymin,n,qq,ot,q,pos,left,right,amax,ost,h,tt,t1,pp,p,p1,p2,p3,p4,t,nm,s1,s2,m,s,cen,t2,i1:int64;\n stepp,iii,mask,newug,newdl,dloch,dugol,ist,jst,ifin,jfin,fin,newnapx,newnapy,napx,napy,step, k,i,j:longint;\n oldnap, napr,alpha,prmax,v,aaa,bbb,ccc:extended; hhh:zap;\n x,first,next,prev,l,r, dl,ochnewi,ochnewj,ochj,c,y,z,newoch,och,aold,b,a:array[-100000..2000000] of int64;\n stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;\n marked:array[-10..1100000] of boolean;\n yyy,xx:mass;\n ss, ss1,ss2:string;\n point:array[0..200000] of mass;\n sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;\n zan:array[-10..20,010..200] of boolean;\n sss: array[-10..100000] of string;ch3,ch,ch1,ch2:char;\n dp:array[-1..500,-1..500,-1..500]of boolean;\n clav:array[-10..300,-10..300] of int64;\n ugol:array[0..5000,0..5000] of double;\n\n ddmax,ddmin :array[-1..300000,-1..20] of extended;\n chh,pole :array [-10..200,-10..200] of char;\n maxpr:array[0..nn] of string;\n str:array[0..nn] of string;\n nap,tt1,tt2,disk,v0,v1,s0,t0:extended;\n newx,newy,yy:array[-100..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n for i:=-10 to 100 do for j:=-10 to 100 do clav[i,j]:=-1;\n clav[1,1]:=1;\n clav[1,2]:=2;\n clav[1,3]:=3;\n clav[2,1]:=4;\n clav[2,2]:=5;\n clav[2,3]:=6;\n clav[3,1]:=7;\n clav[3,2]:=8;\n clav[3,3]:=9;\n clav[4,2]:=0;\n for step:=1 to n do\n begin\n t:=ord(ss[step])-48;\n for i:=0 to 4 do for j:=0 to 4 do\n if clav[i,j]=t then zan[i,j]:=true;\n\n end;\n\n imax:=-100; imin:=100; jmax:=-100; jmin:=100;\n for i:=1 to 10 do for j:=1 to 10 do if zan[i,j] then\n begin\n jmax:=max(jmax,j); jmin:=min(jmin,j);\n\n imax:=max(imax,i); imin:=min(imin,i);\n end;\n\n {writeln(imin,' ',imax,' -- ',jmax,' ',jmin);\n }\n if (imax-imin=2)and(jmax-jmin=2) then flag:=true;\n if (imax-imin=3) then flag:=true;\n if flag then write('YES') else write('NO');\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "program O_O;\n var\n i,j,k,n,m:longint;\n s:string;\n pd:array[1..4] of boolean;\n b:array[0..10] of boolean;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n b[ord(s[i])-48]:=true;\n for i:=0 to 9 do\n if b[i] then\n begin\n if (i=1)or(i=2)or(i=3) then\n pd[1]:=true;\n if (i=3)or(i=6)or(i=9) then\n pd[2]:=true;\n if (i=1)or(i=4)or(i=7)or(i=0) then\n pd[3]:=true;\n if (i=7)or(i=0)or(i=9) then\n pd[4]:=true;\n end;\n if (pd[1])and(pd[2])and(pd[3])and(pd[4]) then\n writeln('YES')\n else\n writeln('NO');\n readln;\nend."}, {"source_code": "program O_O;\n var\n i,j,k,n,m:longint;\n s:string;\n pd:array[1..4] of boolean;\n b:array[0..10] of boolean;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n b[ord(s[i])-48]:=true;\n for i:=0 to 9 do\n if b[i] then\n begin\n if (i=1)or(i=2)or(i=3) then\n pd[1]:=true;\n if (i=3)or(i=6)or(i=9) then\n pd[2]:=true;\n if (i=1)or(i=4)or(i=7) then\n pd[3]:=true;\n if (i=7)or(i=0)or(i=9) then\n pd[4]:=true;\n end;\n if (pd[1])and(pd[2])and(pd[3])and(pd[4]) then\n writeln('YES')\n else\n writeln('NO');\n readln;\nend."}, {"source_code": "var\n n,i,minb,minc,maxb,maxc,q,k,j,curi,curj,count:longint;\n a,b,c,x,y:array[1..1000] of longint;\n s,sd:string;\n begin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n sd:=copy(s,i,1);\n val(sd,a[i],q);\n end;\n for i:=1 to n do begin\n if a[i]=1 then begin b[i]:=1; c[i]:=1; end;\n if a[i]=2 then begin b[i]:=1; c[i]:=2; end;\n if a[i]=3 then begin b[i]:=1; c[i]:=3; end;\n if a[i]=4 then begin b[i]:=2; c[i]:=1; end;\n if a[i]=5 then begin b[i]:=2; c[i]:=2; end;\n if a[i]=6 then begin b[i]:=2; c[i]:=3; end;\n if a[i]=7 then begin b[i]:=3; c[i]:=1; end;\n if a[i]=8 then begin b[i]:=3; c[i]:=2; end;\n if a[i]=9 then begin b[i]:=3; c[i]:=3; end;\n if a[i]=0 then begin b[i]:=4; c[i]:=2; end;\n end;\n for i:=1 to n-1 do x[i]:=b[i+1]-b[i];\n for i:=1 to n-1 do y[i]:=c[i+1]-c[i];\n count:=0;\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n curi:=i;\n curj:=j;\n q:=0;\n\n for k:=1 to n-1 do begin\n if ((curi+x[k]=4) and (curi+x[k]=4))\n and\n ((curj+y[k]=2) and (curj+y[k]=2))\n then begin inc(q); curi:=4; curj:=2; continue; end;\n\n if ((curi+x[k]>=1) and (curi+x[k]<=3))\n and\n ((curj+y[k]>=1) and (curj+y[k]<=3))\n then begin inc(q); curi:=curi+x[k]; curj:=curj+y[k]; end;\n\n end;\n if q=n-1 then inc(count);\n end;\n end;\n\n if count>1 then\n write('NO')\n else write('YES');\n\n\n end.\n\n"}, {"source_code": "const\n fin='mac.inp';fon='mac.out';\nvar t,i,n,d1,d2,d3,d4:longint; s:string; kt:boolean;\n a:array[1..10] of longint;\n\nprocedure solve;\nbegin\nreadln(n); read(s);\nfor i:=1 to n do\n a[i]:=ord(s[i])-48;\nd1:=0; d2:=0; d3:=0; d4:=0;\nfor i:=1 to n do\n begin\n if (a[i]+3=11) or (a[i]+3<=9) then\n begin\n inc(d1);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-3=-3) or (a[i]-3>=1) then\n begin\n inc(d2);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]+1=1) or ((a[i]+1<=9) and (a[i]<>3) and (a[i]<>6)) then\n begin\n inc(d3);\n end;\n end;\nfor i:=1 to n do\n begin\n if (a[i]-1=-1) or ((a[i]-1>=1) and (a[i]<>4) and (a[i]<>7)) then\n begin\n inc(d4);\n end;\n end;\nkt:=true;\nif (d1=n) or (d2=n) or (d3=n) or (d4=n) then\n kt:=false;\n\nif kt=false then\n write('NO')\nelse\n write('YES');\nend;\n\nbegin\n//assign(input,fin);reset(input);\n//assign(output,fon);rewrite(output);\nsolve;\nend."}, {"source_code": "var\ns:array[0..4] of string;\nss:string;\ni,j,k,n,ans:integer;\nflag:boolean;\nbegin\ns[0]:='1234567890';\ns[1]:='---1234568';\ns[2]:='456789----';\ns[3]:='-12-45-78-';\ns[4]:='23-56-89--';\n readln(n);\n readln(ss);\n ans:=0;\n for j:=1 to 4 do\n begin\n flag:=false;\n for i:=1 to n do\n begin\n for k:=1 to 10 do\n if (s[0][k]=ss[i]) and (s[j][k]='-')\n then flag:=true;\n end;\n if not flag then\n begin\n writeln('NO');\n halt(0);\n end;\n end;\nwriteln('YES');\n\nend."}, {"source_code": "Var\ns:string;\nn,l,d,r,u,z,i:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='0' then z:=1;\n if (s[i]='1') or (s[i]='2') or (s[i]='3') then u:=1;\n if (s[i]='3') or (s[i]='6') or (s[i]='9') then r:=1;\n if (s[i]='7') or (s[i]='8') or (s[i]='9') then d:=1;\n if (s[i]='1') or (s[i]='4') or (s[i]='7') then l:=1;\n end;\nif ((u=1) and (r=1) and (d=1) and (l=1)) or ((z=1) and (u=1)) then\n write('YES')\nelse\n write('NO');\nend."}, {"source_code": "{$Mode objfpc}\n\nvar\n n,i,j,o,kq:integer;\n s:char;\n check:boolean;\n a:array[0..10] of boolean;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[ord(s)-48]:=true;\n end;\n if a[1] or a[2] or a[3] then inc(kq);\n if a[1] or a[4] or a[7] then inc(kq);\n if a[3] or a[6] or a[9] then inc(kq);\n if a[7] or a[0] or a[9] then inc(kq);\n if kq < 4 then write('NO')\n else write('YES');\nend."}, {"source_code": "{$Mode objfpc}\n\nvar\n n,i,j,o,kq:integer;\n s:char;\n check:boolean;\n a:array[0..10] of integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=ord(s)-48;\n if a[i] = 0 then a[i]:=11;\n end;\n for i:=1 to 9 do\n begin\n o:=i;\n check:=false;\n for j:=2 to n do\n begin\n o:=o + (a[j]-a[j-1]);\n if (o < 1) or ((o > 9) and (o <> 11)) then check:=true;\n end;\n if not check then inc(kq);\n end;\n if kq > 1 then write('NO')\n else write('YES');\nend."}, {"source_code": "var n,i,x:longint;\n a:array[1..9] of longint;\n sl:string; bl:boolean;\nbegin\n readln(n);\n readln(sl);\n for i:=1 to n do\n begin\n val(sl[i],x);\n a[i]:=x;\n end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 0 then\n if a[i] - 3 < 0 then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] + 3 >= 10) or (a[i] = 0) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 3) or (a[i] = 6) or (a[i] = 9) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 1) or (a[i] = 4) or (a[i] = 7) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "var n,i,x:longint;\n a:array[1..9] of longint;\n sl:string; bl:boolean;\nbegin\n readln(n);\n readln(sl);\n for i:=1 to n do\n begin\n val(sl[i],x);\n a[i]:=x;\n end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 0 then\n if a[i] - 3 < 0 then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] + 3 >= 10) or (a[i] = 0) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] = 0) or (a[i] = 3) or (a[i] = 6) or (a[i] = 9) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] = 0) or (a[i] = 1) or (a[i] = 4) or (a[i] = 7) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "var n,i,x:longint;\n a:array[1..9] of longint;\n sl:string; bl:boolean;\nbegin\n readln(n);\n readln(sl);\n for i:=1 to n do\n begin\n val(sl[i],x);\n a[i]:=x;\n end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 0 then\n if a[i] - 3 < 0 then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if a[i] <> 8 then\n if (a[i] + 3 >= 10) or (a[i] = 0) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 3) or (a[i] = 6) or (a[i] = 9) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n bl:=false;\n for i:=1 to n do\n if (a[i] = 0) or (a[i] = 1) or (a[i] = 4) or (a[i] = 7) then\n begin\n bl:=true;\n break;\n end;\n if bl = false then begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "var\n a, b, i, k: int64;\n c, c1: char;\n ar: array [0..100] of char;\n q, q1: boolean;\n \nbegin\n readln(a);\n i := 0;\n while i < a do begin\n read(ar[i]);\n inc(i);\n end;\n i := 0;\n while i < a do begin\n if ar[i] <> '0' then k := ord(ar[i]) - 48\n else k := 11;\n if k - 1 = 0 then q := true;\n if (k + 1 = 10) or (k + 1 = 12) then q1 := true;\n inc(i);\n end;\n if (not(q)) or (not(q1)) then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var\n a, b, i, k: int64;\n c, c1: char;\n ar: array [0..100] of char;\n arr: array [1..10, 1..10] of int64;\n q, q1, q2, q3: boolean;\n \nbegin\n readln(a);\n i := 0;\n while i < a do begin\n read(ar[i]);\n inc(i);\n end;\n i := 0;\n while i < a do begin\n k := ord(ar[i]) - 48;\n if (k < 4) then q := true;\n if (k = 1) or (k = 4) or (k = 7) or (k = 0) then q1 := true;\n if (k = 7) or (k = 0) or (k = 9) then q2 := true;\n if (k = 3) or (k = 6) or (k = 9) or (k = 0) then q3 := true;\n inc(i);\n end;\n if (not(q)) or (not(q1)) or (not(q2)) or (not(q3)) then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var ch:char;\n n,i:longint;\n a:array[0..6] of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(ch);\n if ch in ['1','2','3'] then\n inc(a[1])\n else\n if ch in ['4','5','6'] then\n inc(a[2])\n else\n if ch in ['7','8','9'] then\n inc(a[3])\n else\n inc(a[4]);\n if ch='8' then\n inc(a[5]);\n end;\nif (a[1]>=1) and (a[3]>=1) then\n if (a[3]=a[5]) and (a[4]=0) then\n writeln('NO')\n else\n writeln('YES')\nelse\n writeln('NO');\nend.\n"}, {"source_code": "program cellphone;\ntype sett=record\n x,y:integer;\nend;\nvar n,i,j,ii:integer;\n str:string;\n p:array[1..4,1..4] of integer;\n a:array[1..1000] of integer;\n d:array[1..1000] of sett;\n pos:sett;\n ff,f:boolean;\nbegin\n readln(n);\n readln(str);\n fillchar(p,sizeof(p),0);\n for i:=1 to 3 do\n for j:=1 to 3 do\n p[i,j]:=1;\n p[2,4]:=1;\n for i:=1 to n do\n begin\n a[i]:=ord(a[i])-48;\n end;\n i:=0;\n while i1 then\n begin\n ff:=false;\n break;\n end;\n end;\n end\n else begin\n pos.x:=i mod 3;\n pos.y:=i div 3+1;\n for ii:=1 to n do\n begin\n pos.x:=pos.x+d[ii].x;\n pos.y:=pos.y+d[ii].y;\n if p[pos.x,pos.y]<>1 then\n begin\n ff:=false;\n break;\n end;\n end;\n end;\n\n end;\n if ff then begin writeln('YES'); break;end;\n end;\n if not ff then writeln('NO');\nend.\n i\n\n\n"}, {"source_code": "program cellphone;\ntype sett=record\n x,y:integer;\nend;\nvar n,i,j,ii:integer;\n str:string;\n p:array[1..4,1..4] of integer;\n a:array[1..1000] of integer;\n d:array[1..1000] of sett;\n pos:sett;\n ff,f:boolean;\nbegin\n readln(n);\n readln(str);\n fillchar(p,sizeof(p),0);\n for i:=1 to 3 do\n for j:=1 to 3 do\n p[i,j]:=1;\n p[2,4]:=1;\n for i:=1 to n do\n begin\n a[i]:=ord(a[i])-48;\n end;\n i:=0;\n while i1 then\n begin\n ff:=false;\n break;\n end;\n end;\n end\n else begin\n pos.x:=i mod 3;\n pos.y:=i div 3+1;\n for ii:=1 to n do\n begin\n pos.x:=pos.x+d[ii].x;\n pos.y:=pos.y+d[ii].y;\n if p[pos.x,pos.y]<>1 then\n begin\n ff:=false;\n break;\n end;\n end;\n end;\n\n end;\n if ff then begin writeln('NO'); break;end;\n end;\n if not ff then writeln('YES');\nend.\n\n\n\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nfunction check(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) - 1 do\n if (s[i] <> s[i + 1]) then exit(false);\n exit(true);\nend;\n\nfunction check2(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) do\n if (s[i] <> '0') and (s[i] <> '2') and (s[i] <> '5') and (s[i] <> '8') then exit(false);\n exit(true);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n //else if (check(s)) then writeln(fo, 'YES')\n //else if (check2(s)) then writeln(fo, 'YES')\n else if (pos('2', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('1', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('0', s) > 0) then writeln(fo, 'YES')\n else if (n > 7) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nfunction check(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) - 1 do\n if (s[i] <> s[i + 1]) then exit(false);\n exit(true);\nend;\n\nfunction check2(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) do\n if (s[i] <> '0') and (s[i] <> '2') and (s[i] <> '5') and (s[i] <> '8') then exit(false);\n exit(true);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (check(s)) then writeln(fo, 'YES')\n else if (check2(s)) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nfunction check(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) - 1 do\n if (s[i] <> s[i + 1]) then exit(false);\n exit(true);\nend;\n\nfunction check2(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) do\n if (s[i] <> '0') and (s[i] <> '2') and (s[i] <> '5') and (s[i] <> '8') then exit(false);\n exit(true);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n //else if (check(s)) then writeln(fo, 'YES')\n else if (check2(s)) then writeln(fo, 'YES')\n else if (n > 7) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n ip = '';//'689A.inp';\n op = '';//'689A.out';\n\nvar\n n : integer;\n s : ansistring;\n fi, fo : text;\n\nprocedure enter;\nbegin\n readln(fi, n);\n readln(fi, s);\nend;\n\nfunction check(s : ansistring) : boolean;\nvar\n i : integer;\nbegin\n for i := 1 to length(s) - 1 do\n if (s[i] <> s[i + 1]) then exit(false);\n exit(true);\nend;\n\nprocedure process;\nbegin\n if (pos('1', s) > 0) and (pos('9', s) > 0) then writeln(fo, 'YES')\n else if (pos('3', s) > 0) and (pos('7', s) > 0) then writeln(fo, 'YES')\n else if (check(s)) then writeln(fo, 'YES')\n else writeln(fo, 'NO');\nend;\n\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n\n enter;\n process;\n\n close(fi); close(fo);\nend."}, {"source_code": "Program ioh;\nType gan=record\n x,y:longint;\n end;\nVar n,i,j,k:longint;\n\n a,road:array[0..10] of gan;\n s:array[1..10] of longint;\n b:array[-1..10,-1..10] of longint;\n x,y:longint;\n res:boolean;\n ch:char;\nBegin\n Readln(n);\n for i:=1 to n do begin\n Read(ch);\n s[i]:=ord(ch)-48;\n End;\n a[0].x:=2;\n a[0].y:=1;\n a[1].x:=1;\n a[1].y:=4;\n a[2].x:=2;\n a[2].y:=4;\n a[3].x:=3;\n a[3].y:=4;\n a[4].x:=1;\n a[4].y:=3;\n a[5].x:=2;\n a[5].y:=3;\n a[6].x:=3;\n a[6].y:=3;\n a[7].x:=1;\n a[7].y:=2;\n a[8].x:=2;\n a[8].y:=2;\n a[9].x:=3;\n a[9].y:=2;\n for i:=2 to n do begin\n road[i].x:=a[s[i]].x-a[s[i-1]].x;\n road[i].y:=a[s[i]].y-a[s[i-1]].y;\n End;\n for i:=-1 to 10 do\n for j:=-1 to 10 do b[i,j]:=-1;\n k:=1;\n for i:=4 downto 2 do begin\n\n for j:=1 to 3 do begin\n b[i,j]:=k;\n inc(k);\n\n end;\n\n End;\n b[1,2]:=0;\n For i:=4 downto 1 do begin\n for j:=1 to 3 do begin\n y:=i;\n x:=j;\n res:=true;\n if b[x,y]=-1 then begin\n res:=false;\n Break;\n end;\n for k:=2 to n do begin\n if b[x,y]=-1 then begin\n res:=false;\n Break;\n end;\n inc(x,road[k].x);\n inc(y,road[k].y);\n End;\n if res=true then begin\n Writeln('NO');\n Halt;\n End;\n End;\n End;\n\n Writeln('YES')\nEnd."}, {"source_code": "Program ioh;\nType gan=record\n x,y:longint;\n end;\nVar n,i,j,k:longint;\n\n a,road:array[0..10] of gan;\n s:array[1..10] of longint;\n b:array[-5..15,-5..15] of longint;\n x,y:longint;\n res:boolean;\n ch:char;\nBegin\n Readln(n);\n for i:=1 to n do begin\n Read(ch);\n s[i]:=ord(ch)-48;\n End;\n a[0].x:=2;\n a[0].y:=1;\n a[1].x:=1;\n a[1].y:=4;\n a[2].x:=2;\n a[2].y:=4;\n a[3].x:=3;\n a[3].y:=4;\n a[4].x:=1;\n a[4].y:=3;\n a[5].x:=2;\n a[5].y:=3;\n a[6].x:=3;\n a[6].y:=3;\n a[7].x:=1;\n a[7].y:=2;\n a[8].x:=2;\n a[8].y:=2;\n a[9].x:=3;\n a[9].y:=2;\n\n for i:=2 to n do begin\n road[i].x:=a[s[i]].x-a[s[i-1]].x;\n road[i].y:=a[s[i]].y-a[s[i-1]].y;\n //Writeln(road[i].x,road[i].y);\n End;\n for i:=-5 to 15 do\n for j:=-5 to 15 do b[i,j]:=-1;\n k:=1;\n for i:=4 downto 2 do begin\n\n for j:=1 to 3 do begin\n b[i,j]:=k;\n inc(k);\n\n end;\n\n\n End;\n b[1,2]:=0;\n For i:=4 downto 1 do begin\n for j:=1 to 3 do begin\n y:=i;\n x:=j;\n res:=true;\n if b[x,y]=-1 then begin\n res:=false;\n Break;\n end;\n for k:=2 to n do begin\n if b[x,y]=-1 then begin\n res:=false;\n Break;\n end;\n inc(x,road[k].x);\n inc(y,road[k].y);\n End;\n if res=true then begin\n Writeln('NO');\n Halt;\n End;\n End;\n End;\n\n Writeln('YES')\nEnd."}, {"source_code": "Program ioh;\nType gan=record\n x,y:longint;\n end;\nVar n,i,j,k:longint;\n\n a,road:array[0..10] of gan;\n s:array[1..10] of longint;\n b:array[-5..15,-5..15] of longint;\n x,y:longint;\n res:boolean;\n ch:char;\nBegin\n Readln(n);\n for i:=1 to n do begin\n Read(ch);\n s[i]:=ord(ch)-48;\n End;\n a[0].x:=2;\n a[0].y:=1;\n a[1].x:=1;\n a[1].y:=4;\n a[2].x:=2;\n a[2].y:=4;\n a[3].x:=3;\n a[3].y:=4;\n a[4].x:=1;\n a[4].y:=3;\n a[5].x:=2;\n a[5].y:=3;\n a[6].x:=3;\n a[6].y:=3;\n a[7].x:=1;\n a[7].y:=2;\n a[8].x:=2;\n a[8].y:=2;\n a[9].x:=3;\n a[9].y:=2;\n\n for i:=2 to n do begin\n road[i].x:=a[s[i]].x-a[s[i-1]].x;\n road[i].y:=a[s[i]].y-a[s[i-1]].y;\n //Writeln(road[i].x,road[i].y);\n End;\n for i:=-5 to 15 do\n for j:=-5 to 15 do b[i,j]:=-1;\n k:=1;\n for i:=4 downto 2 do begin\n\n for j:=1 to 3 do begin\n b[i,j]:=k;\n inc(k);\n\n end;\n\n\n End;\n b[1,2]:=0;\n For i:=4 downto 1 do begin\n for j:=1 to 3 do begin\n y:=i;\n x:=j;\n res:=true;\n if b[y,x]<>s[1] then begin\n if b[y,x]=-1 then begin\n res:=false;\n end;\n for k:=2 to n do begin\n //Writeln(x,y,' ',i,j);\n if b[y,x]=-1 then begin\n res:=false;\n Break;\n end;\n inc(x,road[k].x);\n inc(y,road[k].y);\n End;\n if b[x,y]=-1 then begin\n res:=false;\n end;\n if res=true then begin\n Writeln('NO');\n // Writeln(j,' ',i);\n Halt;\n End;\n end;\n End;\n End;\n\n Writeln('YES')\nEnd."}, {"source_code": "Program ioh;\nType gan=record\n x,y:longint;\n end;\nVar n,i,j,k:longint;\n\n a,road:array[0..10] of gan;\n s:array[1..10] of longint;\n b:array[-5..15,-5..15] of longint;\n x,y:longint;\n res:boolean;\n ch:char;\nBegin\n Readln(n);\n for i:=1 to n do begin\n Read(ch);\n s[i]:=ord(ch)-48;\n End;\n a[0].x:=2;\n a[0].y:=1;\n a[1].x:=1;\n a[1].y:=4;\n a[2].x:=2;\n a[2].y:=4;\n a[3].x:=3;\n a[3].y:=4;\n a[4].x:=1;\n a[4].y:=3;\n a[5].x:=2;\n a[5].y:=3;\n a[6].x:=3;\n a[6].y:=3;\n a[7].x:=1;\n a[7].y:=2;\n a[8].x:=2;\n a[8].y:=2;\n a[9].x:=3;\n a[9].y:=2;\n\n for i:=2 to n do begin\n road[i].x:=a[s[i]].x-a[s[i-1]].x;\n road[i].y:=a[s[i]].y-a[s[i-1]].y;\n //Writeln(road[i].x,road[i].y);\n End;\n for i:=-5 to 15 do\n for j:=-5 to 15 do b[i,j]:=-1;\n k:=1;\n for i:=4 downto 2 do begin\n\n for j:=1 to 3 do begin\n b[i,j]:=k;\n inc(k);\n\n end;\n\n\n End;\n b[1,2]:=0;\n For i:=4 downto 1 do begin\n for j:=1 to 3 do begin\n y:=i;\n x:=j;\n res:=true;\n if b[x,y]=-1 then begin\n res:=false;\n\n end;\n for k:=2 to n do begin\n if b[x,y]=-1 then begin\n res:=false;\n Break;\n end;\n inc(x,road[k].x);\n inc(y,road[k].y);\n End;\n if b[x,y]=-1 then begin\n res:=false;\n\n end;\n if res=true then begin\n Writeln('NO');\n Halt;\n End;\n End;\n End;\n\n Writeln('YES')\nEnd."}, {"source_code": "uses math;\nconst fi='';\n fo='';\n maxn=9;\n\nvar f1,f2:text;\n a:array[1..maxn]of longint;\n l,r,t,b,n:longint;\n check:boolean;\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\nprocedure input;\n var i:longint; ch:char;\n begin\n readln(f1,n);\n for i:=1 to n do\n begin read(f1,ch); a[i]:=ord(ch)-48;end;\n end;\n\n\nprocedure init;\n var i:longint;\n begin\n l:=-1;\n r:=-1;\n t:=-1;\n b:=-1;\n for i:=1 to 9 do\n case a[i] of\n 0:begin b:=1;check:=true;end;\n 1:begin t:=1;l:=1;end;\n 2:t:=1;\n 3:begin t:=1;r:=1;end;\n 4:l:=1;\n 6:r:=1;\n 7:begin b:=1;l:=1;end;\n 9:begin b:=1;r:=1;end;\n end;\n end;\n\n\nprocedure solve;\n var i:longint;\n begin\n if ((t=1) and(l=1) and(r=1) and(b=1))or((t=1)and check) then write(f2,'YES') else write(f2,'NO');\n end;\n\nprocedure output;\n\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n"}, {"source_code": "{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\nuses math;\nconst log=18;\n ms=1e-9;\n oo=round(1e9);\n modulo=1000000007;\n fi='';\n fo='';\n maxn=100010;\n move:array[0..9,1..4]of longint=((8,-1,-1,-1),(-1,2,4,-1),(-1,3,5,1),(-1,-1,6,2),(1,5,7,-1),(2,6,8,4),(3,-1,9,5),(4,8,-1,-1),(5,9,0,7),(6,-1,-1,8));\n\nvar f1,f2:text;\n a,b:array[0..10]of longint;\n n:longint;\n\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\n\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure input;\n var i:longint;\n begin\n readln(f1,n);\n for i:=1 to n do\n read(f1,a[i]);\n end;\n\n\nprocedure init;\n var i,j:longint;\n check:boolean;\n begin\n for i:=1 to 4 do\n begin\n check:=true;\n for j:=1 to n do\n b[j]:=move[a[j],i];\n for j:=1 to n do\n if b[j]=-1 then check:=false;\n if check then\n begin\n writeln(f2,'NO');\n closefile;\n halt;\n end;\n end;\n end;\n\nprocedure solve;\n var i,j:longint;\n begin\n writeln(f2,'YES');\n end;\n\nprocedure output;\n var i:longint;\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n maxn=90;\n\nvar f1,f2:text;\n a:array[1..maxn]of longint;\n l,r,t,b,n:longint;\n check1,check2,check:boolean;\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\nprocedure input;\n var i:longint; ch:char;\n begin\n readln(f1,n);\n for i:=1 to n do\n begin read(f1,ch); a[i]:=ord(ch)-48;end;\n check:=false;\n check1:=false;\n check2:=false;\n end;\n\n\nprocedure init;\n var i:longint;\n begin\n l:=-1;\n r:=-1;\n t:=-1;\n b:=-1;\n for i:=1 to 9 do\n case a[i] of\n 0:begin b:=1;check:=true;end;\n 1:begin t:=1;l:=1;check1:=true;end;\n 2:t:=1;\n 3:begin t:=1;r:=1;check2:=true;end;\n 4:l:=1;\n 6:r:=1;\n 7:begin b:=1;l:=1;end;\n 9:begin b:=1;r:=1;end;\n end;\n end;\n\n\nprocedure solve;\n var i:longint;\n begin\n if ((t=1) and(l=1) and(r=1) and(b=1))or((t=1)and (check1 or check2)and check) then write(f2,'YES') else write(f2,'NO');\n end;\n\nprocedure output;\n\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n maxn=9;\n\nvar f1,f2:text;\n a:array[1..maxn]of longint;\n l,r,t,b,n:longint;\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\nprocedure input;\n var i:longint; ch:char;\n begin\n readln(f1,n);\n for i:=1 to n do\n begin read(f1,ch); a[i]:=ord(ch)-48;end;\n end;\n\n\nprocedure init;\n var i:longint;\n begin\n l:=-1;\n r:=-1;\n t:=-1;\n b:=-1;\n for i:=1 to 9 do\n case a[i] of\n 0:b:=1;\n 1:begin t:=1;l:=1;end;\n 2:t:=1;\n 3:begin t:=1;r:=1;end;\n 4:l:=1;\n 6:r:=1;\n 7:begin b:=1;l:=1;end;\n 9:begin b:=1;r:=1;end;\n end;\n end;\n\n\nprocedure solve;\n var i:longint;\n begin\n if (t=1) and(l=1) and(r=1) and(b=1) then write(f2,'YES') else write(f2,'NO');\n end;\n\nprocedure output;\n\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n maxn=90;\n\nvar f1,f2:text;\n a:array[1..maxn]of longint;\n l,r,t,b,n:longint;\n check1,check2,check:boolean;\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\nprocedure input;\n var i:longint; ch:char;\n begin\n readln(f1,n);\n i:=1;\n while i<=n do\n begin read(f1,ch); a[i]:=ord(ch)-48; if (a[i]<10) and (a[i]>-1) then inc(i);end;\n check:=false;\n check1:=false;\n check2:=false;\n end;\n\n\nprocedure init;\n var i:longint;\n begin\n l:=-1;\n r:=-1;\n t:=-1;\n b:=-1;\n for i:=1 to 9 do\n case a[i] of\n 0:begin b:=1;check:=true;end;\n 1:begin t:=1;l:=1;check1:=true;end;\n 2:t:=1;\n 3:begin t:=1;r:=1;check2:=true;end;\n 4:l:=1;\n 6:r:=1;\n 7:begin b:=1;l:=1;end;\n 9:begin b:=1;r:=1;end;\n end;\n end;\n\n\nprocedure solve;\n var i:longint;\n begin\n if ((t=1) and(l=1) and(r=1) and(b=1))or((t=1)and check) then write(f2,'YES') else write(f2,'NO');\n end;\n\nprocedure output;\n\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n"}, {"source_code": "var s:string;\na:array[-2..7,-2..7]of char;\nx:char;\nb,c:array['0'..'9']of longint;\ni,j,n,t,q,w:longint;\nk:boolean;\nbegin\nreadln(n);\nreadln(s);\nfor i:=-2 to 7 do\n for j:=-2 to 7 do\n a[i,j]:='.';\na[1,1]:='1';\na[1,2]:='2';\na[1,3]:='3';\na[2,1]:='4';\na[2,2]:='5';\na[2,3]:='6';\na[3,1]:='7';\na[3,2]:='8';\na[3,3]:='9';\na[4,2]:='0';\ni:=1; j:=1;\nfor x:='1' to '9' do\n begin\n if j=4 then\n begin\n inc(i);\n j:=1;\n end;\n b[x]:=i; c[x]:=j;\n inc(j);\n end;\nb['0']:=4;\nc['0']:=2;\nq:=b[s[1]];\nw:=c[s[1]];\nfor i:=1 to 4 do\n for j:=1 to 4 do\n begin\n k:=true;\n for t:=1 to n do\n if a[b[s[t]]-2*q+i,c[s[t]]-2*w+j]='.' then k:=false;\n if k=true then\n begin\n writeln('NO');\n exit;\n end;\n end;\nwriteln('YES');\nend."}, {"source_code": "var s:string;\na:array[-2..7,-2..7]of char;\nx:char;\nb,c:array['0'..'9']of longint;\ni,j,n,t,q,w:longint;\nk:boolean;\nbegin\nreadln(n);\nreadln(s);\nfor i:=-2 to 7 do\n for j:=-2 to 7 do\n a[i,j]:='.';\na[1,1]:='1';\na[1,2]:='2';\na[1,3]:='3';\na[2,1]:='4';\na[2,2]:='5';\na[2,3]:='6';\na[3,1]:='7';\na[3,2]:='8';\na[3,3]:='9';\na[4,2]:='0';\ni:=1; j:=1;\nfor x:='1' to '9' do\n begin\n if j=4 then\n begin\n inc(i);\n j:=1;\n end;\n b[x]:=i; c[x]:=j;\n inc(j);\n end;\nb['0']:=4;\nc['0']:=2;\nq:=b[s[1]];\nw:=c[s[1]];\n//writeln(q,' ',w);\nfor i:=1 to 4 do\n for j:=1 to 4 do\n if (i<>q)and(j<>w) then\n begin\n //writeln(i,' ',j);\n k:=true;\n for t:=1 to n do\n begin\n //writeln(a[b[s[t]]-q+i,c[s[t]]-w+j]);\n if a[b[s[t]]-q+i,c[s[t]]-w+j]='.' then k:=false;\n end;\n if k=true then\n begin\n writeln('NO');\n exit;\n end;\n end;\nwriteln('YES');\nend."}, {"source_code": "\nVar n: int64;\n i,m,j,k: integer;\n s: string;\n test: boolean;\nBegin\n readln(n);\n readln(s);\n For i:=0 To 1 Do\n Begin\n m := i;\n For j:=1 To n-1 Do\n Begin\n k := (ord(s[j+1])-48)-(ord(s[j])-48);\n m := m+k;\n If (m>10) Or (m<0) Then test := true\n Else test := false;\n End;\n If test=false Then\n Begin\n writeln('No');\n break;\n End;\n End;\nEnd."}, {"source_code": "var\n f : array[-50..50,-50..50] of longint;\n x,y : array[0..15] of longint;\n n,i,j,xx,yy,q,a,x1,y1,k,aa : longint;\n c : char;\n ff : boolean;\n\nbegin\n readln(n);\n fillchar(f,sizeof(f),63);\n f[1,1]:=1; f[1,2]:=2; f[1,3]:=3;\n f[2,1]:=4; f[2,2]:=5; f[2,3]:=6;\n f[3,1]:=7; f[3,2]:=8; f[3,3]:=9;\n f[4,2]:=0;\n read(c); a:=ord(c)-48; aa:=a;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin xx:=i; yy:=j; break; end;\n for q:=2 to n do begin\n read(c);\n a:=ord(c)-48;\n inc(k);\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin x1:=i; y1:=j; break; end;\n x[k]:=x1-xx; y[k]:=y1-yy;\n xx:=x1; yy:=y1;\n end;\n readln;\n for q:=0 to 9 do begin\n if q = aa then continue;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = q then begin xx:=i; yy:=j; break; end;\n ff:=false;\n for i:=1 to k do begin\n x1:=xx+x[i]; y1:=yy+y[i];\n if not (f[x1,y1] in [0..9]) then begin ff:=true; break; end;\n x1:=xx; y1:=yy;\n end;\n if not ff then begin writeln('NO'); halt; end;\n end;\n writeln('YES');\nend."}, {"source_code": "var\n f,fk : array[-50..50,-50..50] of longint;\n x,y : array[0..15] of longint;\n n,i,j,xx,yy,q,a,x1,y1,k,aa : longint;\n c : char;\n ff : boolean;\n\nbegin\n readln(n);\n fillchar(f,sizeof(f),63);\n f[1,1]:=1; f[1,2]:=2; f[1,3]:=3;\n f[2,1]:=4; f[2,2]:=5; f[2,3]:=6;\n f[3,1]:=7; f[3,2]:=8; f[3,3]:=9;\n f[4,2]:=0;\n for i:=0 to 5 do for j:=0 to 5 do if f[i,j] in [0..9] then fk[i,j]:=1;\n read(c); a:=ord(c)-48; aa:=a;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin xx:=i; yy:=j; break; end;\n for q:=2 to n do begin\n read(c);\n a:=ord(c)-48;\n inc(k);\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = a then begin x1:=i; y1:=j; break; end;\n x[k]:=x1-xx; y[k]:=y1-yy;\n xx:=x1; yy:=y1;\n end;\n readln;\n for q:=0 to 9 do begin\n if q = aa then continue;\n for i:=1 to 4 do for j:=1 to 3 do if f[i,j] = q then begin xx:=i; yy:=j; break; end;\n ff:=false;\n for i:=1 to k do begin\n x1:=xx+x[i]; y1:=yy+y[i];\n if fk[x1,y1] = 0 then begin ff:=true; break; end;\n xx:=x1; y1:=yy;\n end;\n if not ff then begin writeln('NO'); halt; end;\n end;\n writeln('YES');\nend."}, {"source_code": "var\n ok:boolean;\n i,j,k,c,x,y,d:integer;\n s:string;\n w: char;\nbegin\n readln(s);\n readln(s);\n c:=0;\n ok:=false;\n x:=0;\n y:=0;\n d:=0;\n for i:=0 to 3 do\n begin\n for j:=0 to 2 do\n begin\n ok:=true;\n for k:=1 to length(s) do\n begin\n d:=ord(s[k]);\n if d=48 then\n begin\n x:=1;\n y:=3;\n end else \n begin\n if d <=51 then begin\n x:=d-49;\n y:=0;\n end else\n begin\n if d <=54 then begin\n x:=d-52;\n y:=1;\n end else begin\n x:=d-55;\n y:=2;\n end;\n end;\n end;\n x:=x+j;\n y:=y+i;\n if (not (((x <=2) and (y <=2)) or ((x=1) and (y=3)))) then ok :=false;\n end;\n if ok then c:=c+1;\n end;\n end;\n if c =1 then begin s:='YES'; end else s:='NO';\n writeln(s);\nend."}, {"source_code": "var\nn,i,X:longint;\na:array[0..10] of longint;\nf:boolean;c:char;\nbegin\n //assign(input,'mphone.in');reset(input);\n // assign(output,'mphone.out');rewrite(output);\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n a[i]:=ord(c)-ORD('0');\n if c='0' then\n a[i]:=11;\n end;\n f:=false;\n for i:=1 to n do\n if not((a[i]+3) in [1,2,3,4,5,6,7,8,9,11]) then\n f:=true;\n if f then\n begin\n f:=false;\n for i:=1 to n do\n BEGIN\n if a[i]-3<=0 then f:=true\n else\n if not((A[I]-3) in [1,2,3,4,5,6,7,8,9,11]) then\n f:=true;\n END;\n if f=FALSE then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\n close(input);\n close(output);\nend."}, {"source_code": "var n,i:longint;c:char;\nf:array[0..101]of boolean;\na,b:array[0..101]of longint;\nprocedure dfs(t:longint;flag:boolean);\nvar i:longint;\nbegin\nif t>n then\n begin\n if flag then\n begin\n writeln('NO');\n close(input);close(output);halt;\n end;\n exit;\n end;\nfor i:=1 to 11 do\n if(i<>10)and(f[i]=false)then\n begin\n f[i]:=true;b[t]:=i;\n dfs(t+1,flag and(a[t]-a[t-1]=b[t]-b[t-1])or(t=1));\n f[i]:=false;\n end;\nend;\nbegin\n//assign(input,'mphone.in');reset(input);\n//assign(output,'mphone.out');rewrite(output);\nreadln(n);\nfor i:=1 to n do\n begin\n read(c);a[i]:=ord(c)-48;\n if a[i]=0 then a[i]:=11;\n f[a[i]]:=true;\n end;\ndfs(1,true);\nwriteln('YES');\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,i,vmin,vmax,gmin,gmax,e,x,y,l7,l9:longint;\nc:char;\nbegin\ny:=0; vmax:=-1; gmax:=-1; vmin:=100; gmin:=100;\nl7:=0; l9:=0;\nreadln(n);\nfor i:=1 to n do\nbegin\nread(c);\nval(c,x,e);\nif (x=0) then begin y:=1; vmax:=3; if (1gmax) then gmax:=1; if (3vmax) then vmax:=(x-1) div 3;\nif ((x-1) div 3gmax) then gmax:=(x-1) mod 3;\nif ((x-1) mod 3=4)) or ((y=0) and ((vmax-vmin+1>=3) and ((l7=1) or (l9=1))) and (gmax-gmin+1>=3)) then write('YES') else write('NO');\nend."}, {"source_code": "var n,i,vmin,vmax,gmin,gmax,e,x,y:longint;\nc:char;\nbegin\ny:=0; vmax:=-1; gmax:=-1; vmin:=100; gmin:=100;\nreadln(n);\nfor i:=1 to n do\nbegin\nread(c);\nval(c,x,e);\nif (x=0) then begin y:=1; vmax:=3; if (1gmax) then gmax:=1; if (3vmax) then vmax:=(x-1) div 3;\nif ((x-1) div 3gmax) then gmax:=(x-1) mod 3;\nif ((x-1) mod 3=4)) or ((y=0) and (vmax-vmin+1>=3) and (gmax-gmin+1>=3)) then write('YES') else write('NO');\nend."}, {"source_code": "var\n a,b,aa:array[-1..10,-1..10]of longint;\n res:array[0..10000]of string;\n n,m,k,l,j,i,p1,p2,p3,p4:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n b[1,1]:=1;b[1,2]:=1;b[1,3]:=1;b[2,1]:=1;b[2,2]:=1;\n b[2,3]:=1;b[3,1]:=1;b[3,2]:=1;b[3,3]:=1;b[4,1]:=1;\n\n\n for i:=1 to n do\n begin\n if s[i]='1' then a[1,1]:=1;\n if s[i]='2' then a[1,2]:=1;\n if s[i]='3' then a[1,3]:=1;\n if s[i]='4' then a[2,1]:=1;\n if s[i]='5' then a[2,2]:=1;\n if s[i]='6' then a[2,3]:=1;\n if s[i]='7' then a[3,1]:=1;\n if s[i]='8' then a[3,2]:=1;\n if s[i]='9' then a[3,3]:=1;\n if s[i]='0' then a[4,1]:=1;\n end;\n\n aa:=a;\n for i:=4 downto 1 do\n begin\n for j:=4 downto 1 do if a[i,j]=1 then begin a[i,j]:=0; a[i+1,j]:=1; end;\n end;\n p1:=1; p2:=1; p3:=1; p4:=1;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p1:=0;\n end;\n\n a:=aa;\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do if a[i,j]=1 then begin a[i,j]:=0; a[i-1,j]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p2:=0;\n end;\n\n a:=aa;\n for i:=4 downto 5 do\n begin\n for j:=4 downto 5 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j+1]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p3:=0;\n end;\n\n a:=aa;\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j-1]:=1; end;\n end;\n for i:=0 to 5 do\n begin\n for j:=0 to 5 do if (a[i,j]=1)and(b[i,j]=0) then p4:=0;\n end;\n\n if (p1+p2+p3+p4>0) then writeln('NO') else writeln('YES');\nend.\n\n\n\n"}, {"source_code": "var\n a,b,aa:array[-1..10,-1..10]of longint;\n res:array[0..10000]of string;\n n,m,k,l,j,i,p1,p2,p3,p4:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n b[1,1]:=1;b[1,2]:=1;b[1,3]:=1;b[2,1]:=1;b[2,2]:=1;\n b[2,3]:=1;b[3,1]:=1;b[3,2]:=1;b[3,3]:=1;b[4,1]:=1;\n\n\n for i:=1 to n do\n begin\n if s[i]='1' then a[1,1]:=1;\n if s[i]='2' then a[1,2]:=1;\n if s[i]='3' then a[1,3]:=1;\n if s[i]='4' then a[2,1]:=1;\n if s[i]='5' then a[2,2]:=1;\n if s[i]='6' then a[2,3]:=1;\n if s[i]='7' then a[3,1]:=1;\n if s[i]='8' then a[3,2]:=1;\n if s[i]='9' then a[3,3]:=1;\n if s[i]='0' then a[4,1]:=1;\n end;\n\n aa:=a;\n for i:=4 downto 1 do\n begin\n for j:=4 downto 1 do if a[i,j]=1 then begin a[i,j]:=0; a[i+1,j]:=1; end;\n end;\n p1:=1; p2:=1; p3:=1; p4:=1;\n for i:=0 to 4 do\n begin\n for j:=0 to 4 do if (a[i,j]=1)and(b[i,j]=0) then p1:=0;\n end;\n\n a:=aa;\n for i:=1 to 4 do\n begin\n for j:=1 to 4 do if a[i,j]=1 then begin a[i,j]:=0; a[i-1,j]:=1; end;\n end;\n for i:=0 to 4 do\n begin\n for j:=0 to 4 do if (a[i,j]=1)and(b[i,j]=0) then p2:=0;\n end;\n\n a:=aa;\n for i:=4 downto 1 do\n begin\n for j:=4 downto 1 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j+1]:=1; end;\n end;\n for i:=0 to 4 do\n begin\n for j:=0 to 4 do if (a[i,j]=1)and(b[i,j]=0) then p3:=0;\n end;\n\n a:=aa;\n for i:=1 to 4 do\n begin\n for j:=1 to 4 do if a[i,j]=1 then begin a[i,j]:=0; a[i,j-1]:=1; end;\n end;\n for i:=0 to 4 do\n begin\n for j:=0 to 4 do if (a[i,j]=1)and(b[i,j]=0) then p4:=0;\n end;\n\n if (p1+p2+p3+p4>0) then writeln('NO') else writeln('YES');\nend.\n\n\n\n"}, {"source_code": "Var n,i,j,ff1:longint;\n s:string;\n f,a,b:array[1..10] of longint;\n const x:array[1..10] of longint =(1,1,1,2,2,2,3,3,3,4);\n const y:array[1..10] of longint =(1,2,3,1,2,3,1,2,3,2);\n Begin\n readln(n);\n readln(s);\n for i:=1 to 10 do\n begin\n a[i]:=x[i];\n b[i]:=y[i];\n end;\n f[ord(s[1])-48]:=1;\n for i:=2 to n do \n begin\n for j:=1 to 10 do\n begin\n a[j]:=a[j]-(x[ord(s[i-1])-48]-x[ord(s[i])-48]);\n b[j]:=b[j]-(y[ord(s[i-1])-48]-y[ord(s[i])-48]);\n if (b[j]<>2) and (a[j]=4) then f[j]:=1;\n if (a[j]<1) then f[j]:=1;\n if (b[j]>3) then f[j]:=1;\n if (b[j]<1) then f[j]:=1;\n if (a[j]>4) then f[j]:=1;\n \n end;\n end;\n for i:=1 to 10 do\n if f[i]=0 then ff1:=1;\n if ff1=1 then writeln('NO')\n else writeln('YES');\n end.\n "}, {"source_code": "Var n,i,j,ff1:longint;\n s:string;\n f,a,b:array[0..10] of longint;\n const x:array[0..10] of longint =(4,1,1,1,2,2,2,3,3,3,4);\n const y:array[0..10] of longint =(2,1,2,3,1,2,3,1,2,3,2);\n Begin\n readln(n);\n readln(s);\n for i:=1 to 10 do\n begin\n a[i]:=x[i];\n b[i]:=y[i];\n end;\n f[ord(s[1])-48]:=1;\n for i:=2 to n do \n begin\n for j:=0 to 9 do\n begin\n a[j]:=a[j]-(x[ord(s[i-1])-48]-x[ord(s[i])-48]);\n b[j]:=b[j]-(y[ord(s[i-1])-48]-y[ord(s[i])-48]);\n if (b[j]<>2) and (a[j]=4) then f[j]:=1;\n if (a[j]<1) then f[j]:=1;\n if (b[j]>3) then f[j]:=1;\n if (b[j]<1) then f[j]:=1;\n if (a[j]>4) then f[j]:=1;\n \n end;\n end;\n for i:=0 to 9 do\n if f[i]=0 then ff1:=1;\n if ff1=1 then writeln('NO')\n else writeln('YES');\n end.\n "}, {"source_code": "var a:array[-10..10,-10..10] of longint;\nn,i,j,pr1,pr2,pr3,pr4:longint;\ns:string;\n\nbegin\nreadln(n);\nreadln(s);\n\nfor i:=1 to n do\nbegin\nif s[i]='1' then a[1,1]:=1;\nif s[i]='2' then a[1,2]:=1;\nif s[i]='3' then a[1,3]:=1;\nif s[i]='4' then a[2,1]:=1;\nif s[i]='5' then a[2,2]:=1;\nif s[i]='6' then a[2,3]:=1;\nif s[i]='7' then a[3,1]:=1;\nif s[i]='8' then a[3,2]:=1;\nif s[i]='9' then a[3,3]:=1;\nif s[i]='0' then a[4,2]:=1;\nend;\n\npr1:=0; PR2:=0; PR3:=0; PR4:=0;\nif a[1,1]=1 then pr1:=1;\nif a[1,2]=1 then pr1:=1;\nif a[1,3]=1 then pr1:=1;\n\nif a[1,3]=1 then pr2:=1;\nif a[2,3]=1 then pr2:=1;\nif a[3,3]=1 then pr2:=1;\nif a[4,2]=1 then pr2:=1;\n\n\nif a[3,1]=1 then pr3:=1;\nif a[3,2]=1 then pr3:=1;\nif a[3,3]=1 then pr3:=1;\nif a[4,2]=1 then pr3:=1;\n\nif a[1,1]=1 then pr4:=1;\nif a[2,1]=1 then pr4:=1;\nif a[3,1]=1 then pr4:=1;\nif a[4,2]=1 then pr4:=1;\n\nif (pr1=1) and(pr2=1) and(pr3=1) and(pr4=1) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var kt:boolean;\ns:ansistring;\n x,y,i,n,j,xx,yy,k:longint;\n a:array[-10..10,-10..10]of char;\n l,r:array[0..100000] of longint;\nfunction th1(x,y:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to n do\n begin\n x:=x+l[i];\n y:=y+r[i];\n if a[x,y]='?' then exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n kt:=false;\n readln(s);\n for i:=0 to 5 do\n for j:=0 to 5 do a[i,j]:='?';\n a[1,1]:='1';\n a[1,2]:='2';\n a[1,3]:='3';\n a[2,1]:='4';\n a[2,2]:='5';\n a[2,3]:='6';\n a[3,1]:='7';\n a[3,2]:='8';\n a[3,3]:='9';\n a[4,2]:='0';\n xx:=0;\n yy:=0;\n for i:=1 to n do\n begin\n if s[i]='0' then\n begin\n x:=4;\n y:=2;\n end else\n begin\n k:=ord(s[i])-ord('0');\n if k mod 3 =0 then x:=k div 3 else x:=k div 3+1;\n if k mod 3 =0 then y:=3 else y:=k mod 3;\n // writeln(x,y);\n end;\n l[i]:=x-xx;\n r[i]:=y-yy;\n // writeln(l[i],' ',r[i]);\n xx:=x;\n yy:=y;\n end;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if a[i,j]<>s[1] then\n begin\n if th1(i,j) then kt:=true;\n end;\n if s[1]<>'0' then if th1(4,2) then kt:=true;\n if not kt then write('YES') else write('NO');\nend.\n"}, {"source_code": "\nconst\n tfi='';\n tfo='';\n\ntype info= record\n x, y: longint; end;\n\nvar\n fi, fo: text;\n n: longint;\n a: array[0..4,0..4] of longint;\n x: array[0..100] of longint;\n pos: array[0..100] of info;\n\nprocedure Init;\nvar\n i, j, w: longint;\nbegin\n w := 0;\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n inc(w);\n a[i, j] := w;\n pos[w].x :=i; pos[w].y := j;\n end;\n a[4, 1] := -1; a[4, 3] := -1;\n a[4, 2] := 0; pos[0].x := 4; pos[0].y := 2;\nend;\n\nprocedure __;\nvar\n i: longint;\n c: char;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, n);\n for i:=1 to n do\n begin\n read(fi, c);\n x[i] := ord(c)-48;\n end;\nend;\n\nfunction check(u, v, k1, k2: longint): boolean;\nvar\n x, y: longint;\nbegin\n x := u+k1;\n y := v+k2;\n if (x<1) or (y<1) or (y>3) or (x>3) then exit(false);\n if a[x, y]=-1 then exit(false);\n exit(true);\nend;\n\nprocedure xuly;\nvar\n i, j, k, k1, k2: longint;\n ok: boolean;\nbegin\n if n=1 then\n begin\n writeln(fo,'NO'); exit;\n end;\n\n for i:=1 to 4 do\n for j:=1 to 3 do\n if ((i<>pos[x[1]].x) or (j<>pos[x[1]].y)) and (a[i, j]<>-1) then\n begin\n ok := true;\n for k:=2 to n do\n begin\n k1 := pos[x[k]].x-pos[x[1]].x;\n k2 := pos[x[k]].y-pos[x[1]].y;\n if not check(i, j, k1, k2) then\n begin\n ok := false; break;\n end;\n end;\n if ok then\n begin\n writeln(fo,'NO'); exit;\n end;\n end;\n writeln(fo,'YES');\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n Init;\n __;\n xuly;\n _;\nEND.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>3) or (x<0) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=3 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit(x*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=1;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else\n if i mod 3=0 then exit(i div 3) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>3) or (x<0) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=3 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit((x-1)*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n // reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=1;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else\n if i mod 3=0 then exit(i div 3) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>4) or (x<0) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=4 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit((x-1)*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=i;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else\n if i mod 3=0 then exit(i div 3) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>3) or (x<0) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=3 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit((x-1)*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=i;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nuses sysutils;\nvar\n xx,n,i,j:integer;\n s:char;\n a,movex,movey:array[0..10] of integer;\n st:boolean;\n\nfunction hang(i:integer):integer;\nbegin\n if i=0 then exit(4) else\n if i mod 3=0 then exit(i div 3) else exit(i div 3+1)\nend;\n\nfunction cot(i:integer):integer;\nbegin\n if i=0 then exit(2) else\n if i mod 3=0 then exit(3) else exit(i mod 3)\nend;\n\nfunction solve(i,j,k:integer):integer;\nvar x,y:integer;\nbegin\n y:=cot(i);\n x:=hang(i);\n x:=x+j;\n y:=y+k;\n if (x>3) or (x<0) or (y<1) or (y>3) then\n begin\n st:=true;\n exit\n end;\n if x=4 then\n if y=2 then exit(0) else\n begin\n st:=true;\n exit\n end;\n exit((x-1)*3+y)\nend;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(s);\n a[i]:=strtoint(s);\n movey[i]:=cot(a[i])-cot(a[i-1]);\n movex[i]:=hang(a[i])-hang(a[i-1])\n end;\n for i:=0 to 9 do\n if i<>a[1] then\n begin\n xx:=i;\n st:=false;\n for j:=2 to n do\n begin\n\n xx:=solve(xx,movex[j],movey[j]);\n if st then break\n end;\n if not st then\n begin\n writeln('NO');\n halt\n end;\n end;\n writeln('YES')\nend."}, {"source_code": "var\n j1,ij,w,y,i1,f,k,q,r,h,i,j:longint;\n a:array[0..5,0..5]of integer;\n s:string;\nbegin\n //assign (input,'cinema.in');reset(input);\n //assign(output,'cinema.out');rewrite(output);\n readln(w);\n readln(s);\n for i:=1 to w do\n begin\n val(s[i],y);\n r:=(2+y) div 3;\n if r=0 then r:=4;\n h:=y mod 3 ;\n if h=0 then h:=3;\n a[r,h]:=1;\n end;\n for i:=0 to 4 do a[0,i]:=2;\n for i:=0 to 4 do a[i,0]:=2;\n for i:=0 to 4 do a[i,4]:=2;\n for i:=0 to 4 do a[5,i]:=2;\n a[4,1]:=2;\n a[4,3]:=2;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i-1,j]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i+1,j]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i,j-1]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n f:=0;\n for i:=1 to 4 do for j:=1 to 3 do if f=0 then if a[i,j]=1 then if a[i,j+1]=2 then f:=1;\n if f=0 then begin writeln('NO'); halt; end;\n\n\n writeln('YES');\nend.\n"}, {"source_code": "uses math;\nvar n,i,j,p,q,o,c,c1,l:longint;\n s:ansistring;\n x,y,a,a1:array[0..100] of longint;\n\n begin\n readln(n);\n readln(s);\n\n if (n=1) then\n begin\n writeln('NO');\n exit;\n end;\n\n\n x[1]:=1;\n y[1]:=1;\n\n x[2]:=2;\n y[2]:=1;\n\n x[3]:=3;\n y[3]:=1;\n\n x[4]:=1;\n y[4]:=2;\n\n x[5]:=2;\n y[5]:=2;\n\n x[6]:=3;\n y[6]:=2;\n\n x[7]:=1;\n y[7]:=3;\n\n x[8]:=2;\n y[8]:=3;\n\n x[9]:=3;\n y[9]:=3;\n\n x[0]:=2;\n y[0]:=4;\n\n\n for i:=1 to n-1 do\n begin\n a[i]:=-(x[ord(s[i])-48]-x[ord(s[i+1])-48]);\n a1[i]:=-(y[ord(s[i])-48]-y[ord(s[i+1])-48]);\n end;\n\n p:=0;\n\n for i:=0 to 9 do\n begin\n q:=0;\n c:=x[i];\n c1:=y[i];\n\n for j:=1 to n-1 do\n begin\n inc(c,a[j]);\n inc(c1,a1[j]);\n o:=0;\n\n if (i=0) then\n writeln(c,c1);\n\n for l:=0 to 9 do\n if (x[l]=c) and (y[l]=c1) then inc(o);\n\n if (o=0) then inc(q);\n end;\n if (q=0) then\n inc(p);\n\n end;\n\n\n if (p=1) then writeln('YES') else writeln('NO');\n end.\n"}, {"source_code": "uses math;\nvar n,i,j,p,q,o,c,c1,l:longint;\n s:ansistring;\n x,y,a,a1:array[0..100] of longint;\n\n begin\n readln(n);\n readln(s);\n\n if (n=1) then\n begin\n writeln('NO');\n exit;\n end;\n\n\n x[1]:=1;\n y[1]:=1;\n\n x[2]:=2;\n y[2]:=1;\n\n x[3]:=3;\n y[3]:=1;\n\n x[4]:=1;\n y[4]:=2;\n\n x[5]:=2;\n y[5]:=2;\n\n x[6]:=3;\n y[6]:=2;\n\n x[7]:=1;\n y[7]:=3;\n\n x[8]:=2;\n y[8]:=3;\n\n x[9]:=3;\n y[9]:=3;\n\n x[0]:=2;\n y[0]:=4;\n\n\n for i:=1 to n-1 do\n begin\n a[i]:=x[ord(s[i])-48]-x[ord(s[i+1])-48];\n a1[i]:=y[ord(s[i])-48]-y[ord(s[i+1])-48];\n end;\n\n p:=0;\n\n for i:=0 to 9 do\n begin\n q:=0;\n c:=x[i];\n c1:=y[i];\n\n for j:=1 to n-1 do\n begin\n inc(c,a[j]);\n inc(c1,a1[j]);\n o:=0;\n\n for l:=0 to 9 do\n if (x[l]=c) and (y[l]=c1) then inc(o);\n\n if (o=0) then inc(q);\n end;\n if (q=0) then inc(p);\n end;\n\n if (p=1) then writeln('YES') else writeln('NO');\n end."}, {"source_code": "const fi = '';\n\nvar s: string;\n n, i: longint;\n res, co0, co: boolean;\n f: text;\n\nbegin\n assign(f, fi); reset(f);\n readln(f, n);\n readln(f, s);\n close(f);\n\n for i:= 1 to n do if s[i] = '0' then begin co0:= true; break; end;\n res:= false;\n if co0 then\n begin\n for i:= 1 to n do\n if ('1' <= s[i]) and (s[i] <= '3') then res:= true;\n end\n else\n begin\n res:= true; co:= false;\n for i:= 1 to n do\n if ('1' <= s[i]) and (s[i] <= '3') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if ('7' <= s[i]) and (s[i] <= '9') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if (s[i] = '1') or (s[i] = '4') or (s[i] = '7') then co:= true;\n res:= res and co;\n co:= false;\n for i:= 1 to n do\n if (s[i] = '3') or (s[i] = '6') or (s[i] = '9') then co:= true;\n res:= res and co;\n end;\n if res then writeln('YES') else writeln('NO');\n readln;\nend."}], "src_uid": "d0f5174bb0bcca5a486db327b492bf33"} {"source_code": "uses math;\nconst base=1000000000;\nvar n,m:longint;\n a,s:array[1..24]of longint;\n mang:array[1..24,1..1000,1..2]of longint;\n f:array[0..1,0..8400000]of longint;\n\nfunction get(x,y:longint):longint;\nbegin\n get:=(x shr y)and 1;\nend;\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(input,''); reset(input);\n readln(n);\n for i:=1 to n do read(a[i]);\nend;\n\nfunction check(bit,value:longint):boolean;\nvar i,j:longint;\nbegin\n check:=true;\n for i:=1 to s[value] do\n if ((bit and mang[value,i,1])<>0)and((bit and mang[value,i,2])<>0) then\n exit;\n check:=false;\nend;\n\nprocedure solve;\nvar i,now,t,next,j,bit,ans,count,pivot,temp:longint;\nbegin\n m:=(1 shl n)-1;\n for i:=0 to m do f[0,i]:=base; f[0,1]:=1;\n now:=0; next:=1;\n for i:=1 to n-1 do begin\n for j:=0 to ((1 shl (i+1))-1) do f[next,j]:=base;\n for j:=0 to ((1 shl i)-1) do if (f[now,j]<>base)and(check(j,i+1)) then begin\n bit:=j or (1 shl (i));\n ans:=f[now,j]+1; f[next,bit]:=min(f[next,bit],ans);\n for t:=0 to i-1 do if get(bit,t)=1 then begin\n pivot:=bit xor (1 shl t);\n f[next,pivot]:=min(f[next,pivot],f[now,j]);\n end;\n end;\n temp:=now; now:=next; next:=temp;\n end;\n ans:=base;\n for i:=0 to m do ans:=min(ans,f[now,i]);\n if ans=base then writeln(-1) else writeln(ans);\nend;\n\nprocedure init;\nvar i,j,t:longint;\nbegin\n fillchar(s,sizeof(s),0);\n for i:=2 to n do begin\n for j:=1 to i-1 do\n for t:=j to i-1 do if a[j]+a[t]=a[i] then begin\n inc(s[i]);\n mang[i,s[i],1]:=(1 shl (j-1)); mang[i,s[i],2]:=(1 shl (t-1));\n end;\n end;\nend;\n\nbegin\n nhap;\n init;\n solve;\nend.\n", "positive_code": [{"source_code": "uses math;\nvar res,t,j,n,i:longint;\n used:array[1..24,0..1 shl 23+10] of boolean;\n sz:array[0..25] of longint;\n b:array[1..25,0..10000] of record i,j:longint; end;\n a:array[0..25] of longint;\n function count(mask:longint):longint inline;\n var res:longint;\n begin\n res:=0;\n while (mask>0) do\n begin\n res:=res+1;\n mask:=mask and (mask-1);\n end;\n count:=res;\n end;\n\n procedure rec(v,mask,cost:longint);\n var j,i:longint;\n begin\n cost:=max(cost,count(mask));\n if cost>=res then exit;\n if v=n+1 then\n begin\n res:=cost;\n exit;\n end;\n if used[v][mask] then\n exit;\n used[v][mask]:=true;\n for i:=1 to sz[v] do\n begin\n if (mask and (1<<(b[v][i].i-1))>0)\n and(mask and (1<<(b[v][i].j-1))>0) then\n begin\n for j:=0 to v-2 do\n if (mask and (1<0) then rec(v+1,mask or (1<<(v-1)) xor (1<0)And(zt And (1<<(map[i][pos+1]-1))<>0) Then Begin\n dq:=0;\n For j:=1 To n Do If (zt And (1<<(j-1))<>0) Then Inc(dq);\n If (dq0) Then\n Dfs(pos+1,zt Or (1<0 then bit:=true\n else bit:=false;\nend;\nprocedure go(x, mask, cost:longint);\nvar x1,x2,mm,i,j:longint;\nbegin\n if used[x,mask] then exit;\n if cost>=res then exit;\n used[x,mask]:=true;\n if x=n+1 then\n begin\n res:=cost;\n exit;\n end;\n for i:=1 to sz[x] do\n begin\n x1:=f1[x,i];\n x2:=f2[x,i];\n if bit(mask,x1) and bit(mask, x2) then\n begin\n mm:=mask+(1<<(x-1));\n go(x+1, mm, cost+1);\n\n for j:=0 to n-1 do\n if bit(mask,j) then\n begin\n mm:=mask-(1<ans then exit;\n\n if t=n then begin\n if l0 then tt(x-(1 shl j)+(1 shl t),t+1,l);\n tt(x+(1 shl t),t+1,l);\n\n\n end;\n\n end;\n\n begin\n read(n);\n for i:=1 to n do\n read(v[i]);\n\n for i:=0 to n-1 do\n begin\n for x:=1 to n do\n for y:=x to n do\n if v[x]+v[y]=v[i+1] then begin\n inc(c[i]);\n b[i,c[i]].x:=x-1;\n b[i,c[i]].y:=y-1;\n end;\n end;\n\n ans:=n+1;\n l:=1 shl n-1;\n for i:=0 to l do\n begin\n x:=i;\n while x>0 do\n begin\n a[i]:=a[i]+x mod 2;\n x:=x div 2;\n end;\n end;\n\n tt(1,1,0);\n if ans>n then ans:=-1; writeln(ans);\n end."}, {"source_code": "\nvar z, ans, bc, a, b, n, i, j, k, qn, qm, e, mask, nmask : longint;\n q1, q2, was : array[0 .. 1 shl 23] of longint;\n aa, cn : array[0 .. 111] of longint;\n x, y : array[0 .. 111, 0 .. 1111] of longint;\n\nbegin\n read(n);\n if (n = 1) then begin\n writeln(1);\n halt(0);\n end;\n for i := 1 to n do read(aa[i]);\n fillchar(x, sizeof(x), 0);\n fillchar(y, sizeof(y), 0);\n for i := 1 to n do begin\n cn[i] := 0;\n for j := 1 to i - 1 do begin\n for k := j to i - 1 do begin\n if (aa[j] + aa[k] <> aa[i]) then continue;\n x[i][cn[i]] := j;\n y[i][cn[i]] := k;\n inc(cn[i]);\n end;\n end;\n end;\n q1[0] := 2;\n qn := 1;\n fillchar(was, sizeof(was), 0);\n for i := 2 to n - 1 do begin\n qm := 0;\n for j := 0 to qn - 1 do begin\n mask := q1[j];\n for e := 0 to cn[i] - 1 do begin\n a := x[i][e];\n b := y[i][e];\n if (((mask shr a) and 1) = 0) or (((mask shr b) and 1) = 0) then continue;\n for z := 1 to i - 1 do begin\n if (((mask shr z) and 1) = 1) then begin\n nmask := mask xor (1 shl z) xor (1 shl i);\n if was[nmask] = i then continue;\n was[nmask] := i;\n q2[qm] := nmask;\n inc(qm);\n end;\n end;\n nmask := mask xor (1 shl i);\n if was[nmask] = i then continue;\n was[nmask] := i;\n q2[qm] := nmask;\n inc(qm);\n end;\n end;\n qn := qm;\n for j := 0 to qn - 1 do q1[j] := q2[j];\n end;\n ans := 1 shl 30;\n for z := 0 to qn - 1 do begin\n mask := q1[z];\n bc := 0;\n for i := 1 to n - 1 do if (((mask shr i) and 1) = 1) then inc(bc);\n if ans <= bc then continue;\n for i := 0 to cn[n] - 1 do begin\n a := x[n][i];\n b := y[n][i];\n if (((mask shr a) and 1) = 0) or (((mask shr b) and 1) = 0) then continue;\n ans := bc;\n break;\n end;\n end;\n if (ans = 1 shl 30) then writeln(-1) else writeln(ans);\nend."}, {"source_code": "program problem4;\nuses math, dos;\n\nconst\tm = ( 1 shl 23 ) + 10;\n\nvar\tn, r: longInt;\n\tused: array[ 0..m ] of boolean;\n\ts: array[ 1..m ] of longInt;\n\t\nprocedure add( mask: longInt );\nbegin\n\tif ( used[mask] ) then\n\t\texit();\n\t\t\n\tused[mask] := true;\n\ts[r] := mask;\n\tinc( r );\nend;\n\nfunction leftBit( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 1;\n\tfor i := 1 to n do\n\t\tif ( ( mask and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\tres := i;\n\t\t\t\n\texit( res );\nend;\n\nfunction bitCnt( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 0;\n\tfor i := 0 to n do\n\t\tif ( ( mask and ( 1 shl i ) ) > 0 ) then\n\t\t\tinc( res );\n\t\t\t\n\texit( res );\nend;\n\nvar\ti, j, k, l, ans: longInt;\n\ta: array[ 1..25 ] of longInt;\n\tb: array[ 1..25, 1..25 ] of longInt;\n\tok: boolean;\n\tt1, t2: int64;\n\t\nbegin\n\tt1 := getMsCount();\n\tfillchar( b, sizeOf(b), 0 );\n\n\treadln( n );\n\tfor i := 1 to n do\n\t\tread( a[i] );\n\t\t\n\tfor i := 1 to n do\n\t\tfor j := i to n do\n\t\t\tfor k := (j+1) to n do\n\t\t\t\tif ( ( a[i] + a[j] ) = a[k] ) then\n\t\t\t\tbegin\n\t\t\t\t\tb[i][k] := b[i][k] or ( 1 shl (j-1) );\n\t\t\t\t\tb[j][k] := b[j][k] or ( 1 shl (i-1) );\n\t\t\t\tend;\n\t\n\tans := n + 1;\n\tl := 1;\n\tr := 2;\n\ts[1] := 1;\n\twhile ( l < r ) do\n\tbegin\n\t\tt2 := getMsCount();\n\t\tif ( (t2-t1) > 1980 ) then\n\t\t\tbreak;\n\t\n\t\tk := leftBit( s[l] );\n\t\tif ( k = n ) then\n\t\t\tans := min( ans, bitCnt( s[l] ) );\n\t\t\t\n\t\tok := false;\n\t\tfor i := 1 to k do\n\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) and ( ( s[l] and b[i][k+1] ) > 0 ) then\n\t\t\tbegin\n\t\t\t\tok := true;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\t\t\n\t\tif ( ok ) then\n\t\tbegin\t\t\t\n\t\t\tfor i := 1 to k do\n\t\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\t\t\tadd( s[l] + ( 1 shl k ) - ( 1 shl (i-1) ) );\n\t\t\t\t\t\n\t\t\tadd( s[l] + ( 1 shl k ) );\n\t\tend;\n\t\t\n\t\tinc( l );\n\tend;\n\t\n\tif ( ans = (n+1) ) then\n\t\tans := -1;\n\t\t\n\twriteln( ans );\nend."}, {"source_code": "Var n,i,j,u,ans,o:longint;\n e,d,a:array[0..123]of longint;\n f:array[0..1 shl 23]of longint;\n b:array[0..25,0..1001,1..2]of longint;\n used:array[2..24,0..1 shl 23]of boolean;\n procedure rec(x,mask,cnt:longint);\n var i,x1,x2,j:longint;\n begin\n if used[x,mask] then exit;\n used[x,mask]:=true;\n if cnt>=ans then exit;\n if x=n+1 then\n begin\n ans:=cnt;\n exit;\n end;\n o:=o+e[x];\n if o>200000000 then exit;\n for i:=1 to e[x] do\n begin\n x1:=b[x,i,1];\n x2:=b[x,i,2];\n if mask and d[x1-1]>0 then if mask and d[x2-1]>0 then\n begin\n rec(x+1,mask xor d[x-1],cnt+ord(f[mask]=cnt));\n if f[mask]=cnt then\n for j:=0 to x-2 do\n if d[j] and mask>0 then rec(x+1,mask xor d[x-1] xor d[j],cnt);\n end;\n end;\n end;\n begin\n read(n);\n d[0]:=1;\n for i:=1 to 30 do\n d[i]:=d[i-1]+d[i-1];\n for i:=1 to d[n]-1 do\n for j:=0 to n do\n if i and d[j]>0 then inc(f[i]);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n for j:=1 to i-1 do\n for u:=j to i-1 do\n if a[u]+a[j]=a[i]\n then\n begin\n inc(e[i]);\n b[i,e[i],1]:=j;\n b[i,e[i],2]:=u;\n end;\n ans:=maxlongint;\n rec(2,1,1);\n if ans=maxlongint then ans:=-1;\n Writeln(ans);\n end."}, {"source_code": "var n,i,j,k,t,x,y,z:integer;\na:array [1..23] of integer;\nb:array [1..9000000] of integer;\nc:array [0..25] of integer;\nd:array [1..23,0..50] of integer;\n\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to 9000000 do b[i]:=1000000;\nb[1]:=1;\nc[0]:=1;\nfor i:=1 to 25 do c[i]:=2*c[i-1];\nfor i:=1 to 23 do\n begin\n for j:=0 to 50 do d[i,j]:=0;\n end;\nfor i:=2 to n do\n begin\n for j:=1 to i-1 do\n begin\n for k:=j to i-1 do\n begin\n if a[j]+a[k]=a[i] then\n begin\n d[i,0]+=1;\n if j<>k then d[i,d[i,0]]:=c[j]+c[k] else d[i,d[i,0]]:=c[j];\n end;\n end;\n end;\n end;\nfor i:=1 to c[n-1]-1 do\n begin\n if b[i]<>1000000 then\n begin\n x:=i;\n j:=0;\n while c[j]<=x do j+=1;\n y:=j;\n //writeln(i,' ',y);\n x+=c[y];\n if b[i]+1b[i]+1 then b[x]:=b[i]+1;\n end;\n end;\n for j:=0 to y-1 do\n begin\n if (x and c[j])<>0 then\n begin\n z:=x-c[j];\n t:=0;\n for k:=1 to d[y+1,0] do\n begin\n if (z and d[y+1,k])=d[y+1,k] then\n begin\n t:=1;\n break;\n end;\n end;\n if t=1 then\n begin\n if b[z]>b[i] then b[z]:=b[i];\n end;\n end;\n end;\n end;\n end;\nx:=1000000;\nfor i:=c[n-1] to c[n]-1 do\n begin\n if b[i]ans then exit;\n\n if t=n then begin\n if l0 do\n begin\n a[i]:=a[i]+x mod 2;\n x:=x div 2;\n end;\n end;\n\n tt(1,1,0);\n if ans>n then ans:=-1; writeln(ans);\n end."}, {"source_code": "program problem4;\nuses math, dos;\n\nconst\tm = ( 1 shl 23 ) + 10;\n\nvar\tn, r: longInt;\n\tused: array[ 0..m ] of boolean;\n\ts: array[ 1..m ] of longInt;\n\t\nprocedure add( mask: longInt );\nbegin\n\tif ( used[mask] ) then\n\t\texit();\n\t\t\n\tused[mask] := true;\n\tinc( r );\n\ts[r] := mask;\nend;\n\nfunction leftBit( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 1;\n\tfor i := 1 to n do\n\t\tif ( ( mask and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\tres := i;\n\t\t\t\n\texit( res );\nend;\n\nfunction bitCnt( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 0;\n\tfor i := 0 to n do\n\t\tif ( ( mask and ( 1 shl i ) ) > 0 ) then\n\t\t\tinc( res );\n\t\t\t\n\texit( res );\nend;\n\nvar\ti, j, k, l, ans: longInt;\n\ta: array[ 1..25 ] of longInt;\n\tb: array[ 1..25, 1..25 ] of longInt;\n\tok: boolean;\n\tt1, t2: int64;\n\t\nbegin\n\tt1 := getMsCount();\n\tfillchar( b, sizeOf(b), 0 );\n\n\treadln( n );\n\tfor i := 1 to n do\n\t\tread( a[i] );\n\t\t\n\tfor i := 1 to n do\n\t\tfor j := i to n do\n\t\t\tfor k := (j+1) to n do\n\t\t\t\tif ( ( a[i] + a[j] ) = a[k] ) then\n\t\t\t\tbegin\n\t\t\t\t\tb[i][k] := b[i][k] or ( 1 shl (j-1) );\n\t\t\t\t\tb[j][k] := b[j][k] or ( 1 shl (i-1) );\n\t\t\t\tend;\n\t\n\tans := n + 1;\n\tl := 1;\n\tr := 2;\n\ts[1] := 1;\n\twhile ( l < r ) do\n\tbegin\n\t\tt2 := getMsCount();\n\t\tif ( (t2-t1) > 1980 ) then\n\t\t\tbreak;\n\t\n\t\tk := leftBit( s[l] );\n\t\tif ( k = n ) then\n\t\t\tans := min( ans, bitCnt( s[l] ) );\n\t\t\t\n\t\tok := false;\n\t\tfor i := 1 to k do\n\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) and ( ( s[l] and b[i][k+1] ) > 0 ) then\n\t\t\tbegin\n\t\t\t\tok := true;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\t\t\n\t\tif ( ok ) then\n\t\tbegin\t\t\t\n\t\t\tfor i := 1 to k do\n\t\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\t\t\tadd( s[l] + ( 1 shl k ) - ( 1 shl (i-1) ) );\n\t\t\t\t\t\n\t\t\tadd( s[l] + ( 1 shl k ) );\n\t\tend;\n\t\t\n\t\tinc( l );\n\tend;\n\t\n\tif ( ans = (n+1) ) then\n\t\tans := -1;\n\t\t\n\twriteln( ans );\nend."}, {"source_code": "program problem4;\nuses math, dos;\n\nconst\tm = ( 1 shl 23 ) + 10;\n\nvar\tn, r: longInt;\n\tused: array[ 0..m ] of boolean;\n\ts: array[ 1..m ] of longInt;\n\t\nprocedure add( mask: longInt );\nbegin\n\tif ( used[mask] ) then\n\t\texit();\n\t\t\n\tused[mask] := true;\n\tinc( r );\n\ts[r] := mask;\nend;\n\nfunction leftBit( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 1;\n\tfor i := 1 to n do\n\t\tif ( ( mask and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\tres := i;\n\t\t\t\n\texit( res );\nend;\n\nfunction bitCnt( mask: longInt ): longInt;\nvar\ti, res: longInt;\nbegin\n\tres := 0;\n\tfor i := 0 to n do\n\t\tif ( ( mask and ( 1 shl i ) ) > 0 ) then\n\t\t\tinc( res );\n\t\t\t\n\texit( res );\nend;\n\nvar\ti, j, k, l, ans: longInt;\n\ta: array[ 1..25 ] of longInt;\n\tb: array[ 1..25, 1..25 ] of longInt;\n\tok: boolean;\n\tt1, t2: int64;\n\t\nbegin\n\tt1 := getMsCount();\n\tfillchar( b, sizeOf(b), 0 );\n\n\treadln( n );\n\tfor i := 1 to n do\n\t\tread( a[i] );\n\t\t\n\tfor i := 1 to n do\n\t\tfor j := i to n do\n\t\t\tfor k := (j+1) to n do\n\t\t\t\tif ( ( a[i] + a[j] ) = a[k] ) then\n\t\t\t\tbegin\n\t\t\t\t\tb[i][k] := b[i][k] or ( 1 shl (j-1) );\n\t\t\t\t\tb[j][k] := b[j][k] or ( 1 shl (i-1) );\n\t\t\t\tend;\n\t\n\tans := n + 1;\n\tl := 1;\n\tr := 2;\n\ts[1] := 1;\n\twhile ( l < r ) do\n\tbegin\n\t\tt2 := getMsCount();\n\t\tif ( (t2-t1) > 1980 ) then\n\t\t\tbreak;\n\t\n\t\tk := leftBit( s[l] );\n\t\tif ( k = n ) then\n\t\t\tans := min( ans, bitCnt( s[l] ) );\n\t\t\t\n\t\tok := false;\n\t\tfor i := 1 to k do\n\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) and ( ( s[l] and b[i][k+1] ) > 0 ) then\n\t\t\tbegin\n\t\t\t\tok := true;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\t\t\n\t\tif ( ok ) then\n\t\tbegin\n\t\t\tadd( s[l] + ( 1 shl k ) );\n\t\t\t\n\t\t\tfor i := 1 to k do\n\t\t\t\tif ( ( s[l] and ( 1 shl (i-1) ) ) > 0 ) then\n\t\t\t\t\tadd( s[l] + ( 1 shl k ) - ( 1 shl (i-1) ) );\n\t\tend;\n\t\t\n\t\tinc( l );\n\tend;\n\t\n\tif ( ans = (n+1) ) then\n\t\tans := -1;\n\t\t\n\twriteln( ans );\nend."}, {"source_code": "var res,t,j,n,i:longint;\n used:array[1..24,0..1 shl 23+10] of boolean;\n sz:array[0..25] of longint;\n b:array[1..25,0..10000] of record i,j:longint; end;\n a:array[0..25] of longint;\n function count(mask:longint):longint inline;\n var res:longint;\n begin\n res:=0;\n while (mask>0) do\n begin\n res:=res+1;\n mask:=mask and (mask-1);\n end;\n count:=res;\n end;\n\n procedure rec(v,mask:longint);\n var i:longint;\n begin\n if count(mask)>=res then exit;\n if v=n+1 then\n begin\n res:=count(mask);\n exit;\n end;\n if used[v][mask] then\n exit;\n used[v][mask]:=true;\n for i:=1 to sz[v] do\n begin\n if (mask and (1<<(b[v][i].i-1))>0)\n and(mask and (1<<(b[v][i].j-1))>0) then\n begin\n rec(v+1,mask or (1<<(v-1)));\n rec(v+1,mask or (1<<(v-1)) xor (1<<(b[v][i].i-1)));\n rec(v+1,mask or (1<<(v-1)) xor (1<<(b[v][i].j-1)));\n end;\n end;\n end;\n begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n for t:=1 to n do\n begin\n for i:=1 to t-1 do\n for j:=i to t-1 do\n if a[i]+a[j]=a[t] then\n begin\n inc(sz[t]);\n b[t][sz[t]].i:=i;\n b[t][sz[t]].j:=j;\n end;\n end;\n res:=maxlongint;\n rec(2,1);\n if res=maxlongint then writeln(-1)\n else writeln(res);\n end."}, {"source_code": "uses math;\nvar res,t,j,n,i:longint;\n used:array[1..24,0..1 shl 23+10] of boolean;\n sz:array[0..25] of longint;\n b:array[1..25,0..10000] of record i,j:longint; end;\n a:array[0..25] of longint;\n function count(mask:longint):longint inline;\n var res:longint;\n begin\n res:=0;\n while (mask>0) do\n begin\n res:=res+1;\n mask:=mask and (mask-1);\n end;\n count:=res;\n end;\n\n procedure rec(v,mask,cost:longint);\n var i:longint;\n begin\n cost:=max(cost,count(mask));\n if cost>=res then exit;\n if v=n+1 then\n begin\n res:=cost;\n exit;\n end;\n if used[v][mask] then\n exit;\n used[v][mask]:=true;\n for i:=1 to sz[v] do\n begin\n if (mask and (1<<(b[v][i].i-1))>0)\n and(mask and (1<<(b[v][i].j-1))>0) then\n begin\n for j:=0 to v-2 do\n if (mask and (1<0) then rec(v+1,mask or (1<<(v-1)) xor (1<0)and((bit and mang[value,i,2])<>0) then\n exit;\n check:=false;\nend;\n\nprocedure solve;\nvar i,now,t,next,j,bit,ans,count,pivot,temp:longint;\nbegin\n m:=(1 shl n)-1;\n for i:=1 to m do f[0,i]:=base; f[0,1]:=1;\n now:=0; next:=1;\n for i:=1 to n-1 do begin\n for j:=0 to ((1 shl (i+1))-1) do f[next,j]:=base;\n for j:=0 to ((1 shl i)-1) do if (f[now,j]<>base)and(check(j,i+1)) then begin\n bit:=j or (1 shl (i));\n ans:=f[now,j]+1; f[next,bit]:=min(f[next,bit],ans);\n for t:=0 to i-1 do if get(bit,t)=1 then begin\n pivot:=bit xor (1 shl t);\n f[next,pivot]:=min(f[next,pivot],f[now,j]);\n end;\n end;\n temp:=now; now:=next; next:=temp;\n end;\n ans:=base;\n for i:=0 to m do ans:=min(ans,f[now,i]);\n if ans=base then writeln(-1) else writeln(ans);\nend;\n\nprocedure init;\nvar i,j,t:longint;\nbegin\n fillchar(s,sizeof(s),0);\n for i:=2 to n do begin\n for j:=1 to i-1 do\n for t:=j to i-1 do if a[j]+a[t]=a[i] then begin\n inc(s[i]);\n mang[i,s[i],1]:=(1 shl (j-1)); mang[i,s[i],2]:=(1 shl (t-1));\n end;\n end;\nend;\n\nbegin\n nhap;\n init;\n solve;\nend.\n"}, {"source_code": "\nvar z, ans, bc, a, b, n, i, j, k, qn, qm, e, mask, nmask : longint;\n q1, q2, was : array[0 .. 1 shl 23] of longint;\n aa, cn : array[0 .. 111] of longint;\n x, y : array[0 .. 111, 0 .. 1111] of longint;\n\nbegin\n read(n);\n for i := 1 to n do read(aa[i]);\n fillchar(x, sizeof(x), 0);\n fillchar(y, sizeof(y), 0);\n for i := 1 to n do begin\n cn[i] := 0;\n for j := 1 to i - 1 do begin\n for k := j to i - 1 do begin\n if (aa[j] + aa[k] <> aa[i]) then continue;\n x[i][cn[i]] := j;\n y[i][cn[i]] := k;\n inc(cn[i]);\n end;\n end;\n end;\n q1[0] := 2;\n qn := 1;\n fillchar(was, sizeof(was), 0);\n for i := 2 to n - 1 do begin\n qm := 0;\n for j := 0 to qn - 1 do begin\n mask := q1[j];\n for e := 0 to cn[i] - 1 do begin\n a := x[i][e];\n b := y[i][e];\n if (((mask shr a) and 1) = 0) or (((mask shr b) and 1) = 0) then continue;\n for z := 1 to i - 1 do begin\n if (((mask shr z) and 1) = 1) then begin\n nmask := mask xor (1 shl z) xor (1 shl i);\n if was[nmask] = i then continue;\n was[nmask] := i;\n q2[qm] := nmask;\n inc(qm);\n end;\n end;\n nmask := mask xor (1 shl i);\n if was[nmask] = i then continue;\n was[nmask] := i;\n q2[qm] := nmask;\n inc(qm);\n end;\n end;\n qn := qm;\n for j := 0 to qn - 1 do q1[j] := q2[j];\n end;\n ans := 1 shl 30;\n for z := 0 to qn - 1 do begin\n mask := q1[z];\n bc := 0;\n for i := 1 to n - 1 do if (((mask shr i) and 1) = 1) then inc(bc);\n if ans <= bc then continue;\n for i := 0 to cn[n] - 1 do begin\n a := x[n][i];\n b := y[n][i];\n if (((mask shr a) and 1) = 0) or (((mask shr b) and 1) = 0) then continue;\n ans := bc;\n break;\n end;\n end;\n if (ans = 1 shl 30) then writeln(-1) else writeln(ans);\nend."}, {"source_code": "Var n,i,j,u,ans,o:longint;\n e,d,a:array[0..123]of longint;\n f:array[0..1 shl 23]of longint;\n b:array[0..25,0..1001,1..2]of longint;\n procedure rec(x,mask,cnt:longint);\n var i,x1,x2:longint;\n begin\n if cnt>=ans then exit;\n if x=n+1 then\n begin\n ans:=cnt;\n exit;\n end;\n i:=o+e[x];\n if o>100000000 then exit;\n for i:=1 to e[x] do\n begin\n x1:=b[x,i,1];\n x2:=b[x,i,2];\n if mask and d[x1-1]>0 then if mask and d[x2-1]>0 then\n begin\n for j:=0 to x-2 do\n if d[j] and mask>0 then rec(x+1,mask xor d[x-1] xor d[j],cnt);\n rec(x+1,mask xor d[x-1],cnt+1);\n end;\n end;\n end;\n begin\n read(n);\n d[0]:=1;\n for i:=1 to 30 do\n d[i]:=d[i-1]+d[i-1];\n for i:=1 to d[n]-1 do\n for j:=0 to n do\n if i and d[j]>0 then inc(f[i]);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n for j:=1 to i-1 do\n for u:=j to i-1 do\n if a[u]+a[j]=a[i]\n then\n begin\n inc(e[i]);\n b[i,e[i],1]:=j;\n b[i,e[i],2]:=u;\n end;\n ans:=maxlongint;\n rec(2,1,1);\n if ans=maxlongint then ans:=-1;\n Writeln(ans);\n end."}, {"source_code": "Var n,i,j,u,ans,o:longint;\n e,d,a:array[0..123]of longint;\n f:array[0..1 shl 23]of longint;\n b:array[0..25,0..1001,1..2]of longint;\n procedure rec(x,mask,cnt:longint);\n var i,x1,x2:longint;\n begin\n if cnt>=ans then exit;\n if x=n+1 then\n begin\n ans:=cnt;\n exit;\n end;\n i:=o+e[x];\n if o>100000000 then exit;\n for i:=1 to e[x] do\n begin\n x1:=b[x,i,1];\n x2:=b[x,i,2];\n if mask and d[x1-1]>0 then if mask and d[x2-1]>0 then\n begin\n for j:=0 to x-2 do\n if d[j] and mask>0 then rec(x+1,mask xor d[x-1] xor d[j],cnt);\n rec(x+1,mask xor d[x-1],cnt+ord(f[mask]=cnt));\n end;\n end;\n end;\n begin\n read(n);\n d[0]:=1;\n for i:=1 to 30 do\n d[i]:=d[i-1]+d[i-1];\n for i:=1 to d[n]-1 do\n for j:=0 to n do\n if i and d[j]>0 then inc(f[i]);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n for j:=1 to i-1 do\n for u:=j to i-1 do\n if a[u]+a[j]=a[i]\n then\n begin\n inc(e[i]);\n b[i,e[i],1]:=j;\n b[i,e[i],2]:=u;\n end;\n ans:=maxlongint;\n rec(2,1,1);\n if ans=maxlongint then ans:=-1;\n Writeln(ans);\n end."}], "src_uid": "359f5d1264ce16c5c5293fd59db95628"} {"source_code": "var n,k:longint;\nbegin \n readln(n,k);\n for k:=1 to k do\n if n mod 10=0 then\n n:=n div 10\n else\n dec(n);\n writeln(n);\nend.", "positive_code": [{"source_code": "program test;\nvar\n n, k, i: longint;\n \nbegin\n read(n, k);\n for i:=1 to k do\n if n mod 10 = 0 then n:=n div 10 else dec(n);\n write(n); \nend."}, {"source_code": "program project1;\n var\n n:longint;\n i,k:byte;\n\nbegin\n read(n,k);\n\n for i:=1 to k do\n if n mod 10 <>0 then dec(n) else n:=n div 10;\n\n write(n);\n\n\n\n\nend.\n "}, {"source_code": "var n,k,i,z,p:longint;\nbegin\nreadln(n,k);\nfor i:=1 to k do\nif n mod 10<>0 then dec(n)else if n mod 10=0 then n:=n div 10;\nwrite(n);\nend."}, {"source_code": "var\ni,j,c,x,d,e,b,n:longint;\nbegin\nread(x,n);\nwhile(i<=n-1) do\nbegin\ninc(i);\nif x mod 10=0 then begin x:=x div 10;end\nelse\ndec(x);\nend;\nwriteln(x);\nend."}, {"source_code": "var\n n,k,i:longint;\nbegin\n readln(n,k);\n for i:=1 to k do\n begin\n if n mod 10<>0 then dec(n)\n else n:=n div 10;\n end;\n write(n);\nend."}, {"source_code": "var\n i,n,k:longint;\nbegin\n readln(n,k);\n for i:=1 to k do\n if n mod 10<>0 then dec(n)\n else n:=n div 10;\n writeln(n);\nend."}, {"source_code": "var\n s: string;\n k: integer;\n buffer: integer;\n\nbegin\n readln(s);\n k := StrToInt(Copy(s, pos(' ', s), length(s)));\n Delete(s,pos(' ',s), length(s));\n while(k <> 0) do\n begin\n if s[length(s)] <> '0' then \n begin\n buffer := s.ToInteger;\n dec(buffer);\n s := buffer.ToString;\n dec(k);\n end\n else if s[length(s)] = '0' then \n begin\n s := Copy(s, 1, length(s) - 1);\n dec(k);\n end;\n end; \n \n writeln(s);\nend."}, {"source_code": "var\nn,k,r,o:longint;\nbegin\nread(n,k);\no:=n;\nr:=0;\nrepeat\nr:=r+1;\nif o mod 10<>0 then o:=o-1\nelse o:=o div 10;\nuntil r=k;\nwrite(o);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, k, i:integer;\nbegin\n readln(n, k);\n for i := 1 to k do\n if (n mod 10 = 0)then n := n div 10\n else dec(n);\n writeln(n);\n readln;\nend.\n"}, {"source_code": "program canhtoan;\nuses math;\nvar n:int64;\n k:longint;\nprocedure main();\nvar i:longint;\nbegin\nread(n,k);\nfor i:=1 to k do\n begin\n if n mod 10=0 then n:=n div 10\n else n:=n-1;\n end;\nwrite(n);\nend;\nBEGIN\n main();\nEND.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,a,b:longint;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n read(a,b);\n for i :=1 to b do\n begin\n if (a mod 10) = 0 then a:=a div 10\n else a:=a-1;\n end;\n write(a);\n\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q0 do\nbegin\n if n mod 10 <>0 then n:=n-1 else n:=n div 10;\n dec(k);\nend;\nwrite(n);\nend."}, {"source_code": "var\nn,n1:longint;\ni, k:longint;\n\n \nbegin\n readln(n,k);\n for i:=1 to k do begin\n if (n mod 10)=0 then\n n:=n div 10\n else n:=n-1;\n end;\n writeln(n);\nend."}, {"source_code": "var n,i,s1,s2:longint;l,k:longint;\nbegin\nreadln(n,k);\nwhile k>0 do\nbegin\ni:=n mod 10;\nif i<>0 then n:=n-1 else n:=n div 10;\nk:=k-1;\nend;\nwriteln(n);\nreadln;\nend."}, {"source_code": "Var\n n:real;\n i,n2:integer;\nBegin\nreadln(n,n2);\n for i := 1 to n2 do begin\n if trunc(n) mod 10 = 0 then\n n:=n/10\n else\n n:=n-1;\n end;\nwriteln(trunc(n));\nend."}, {"source_code": " var\n i,j,k,n,s:longint;\n begin\n readln(n,k);\n for i:=1 to k do\n if n mod 10=0 then n:=n div 10 else n:=n-1;\n writeln(n);\n end."}, {"source_code": "var k:longword;n:qword;f,h:text;a:byte;\nbegin\nread(n,k);\nwhile k > 0 do\nbegin\na:=n mod 10;\nif a<>0 then n:=n-1;\nif a=0 then n:=n div 10;\ndec(k);\nend;\nwrite(n);\nend.\n"}, {"source_code": " var n,k,i:longint;\nbegin\nread(n,k);\nfor i:=1 to k do \n begin\n if n mod 10<>0 then dec(n)\n else n:=n div 10;\n end;\nwriteln(n);\nend."}, {"source_code": "var n,n1,k,i:integer;\nbegin\nread(n,k); n1:=n;\nfor i:=1 to k do\nif n1 mod 10<>0\n then n1:=n1-1\n else n1:=n1 div 10;\nwriteln(n1);\nend."}, {"source_code": "var\n\ti,n,k:longint;\n\nbegin\n\treadln(n,k);\n\tfor i:=1 to k do \n\t\tbegin\n\t\t\tif (n mod 10<>0) then dec(n)\n\t\t\t\telse n:=n div 10;\n\t\tend;\n\twriteln(n);\n\nend."}, {"source_code": "program tanya;\nvar\n\tn,k,i:longint;\nbegin \n\tread(n,k);\n\tfor i:=1 to k do\n\tbegin\n\t\tif(n mod 10<>0) then\n\t\tn:=n-1\n\t\telse\n\t\tn:=n div 10;\n\tend;\n\twriteln(n);\nend.\n\t\t\n\t"}, {"source_code": "var\n k,i:longint;\n n:int64;\nbegin\n readln(n,k);\n for i:=1 to k do if n mod 10=0 then n:=n div 10 else n:=n-1;\n writeln(n);\nend."}, {"source_code": "var i, n, k: integer;\nbegin\n readln(n, k);\n for i:= 1 to k do\n begin\n if n mod 10 = 0 then\n begin\n n := n div 10;\n end\n else\n begin\n n := n - 1;\n end;\n end;\n write(n);\nend."}, {"source_code": "var a,b:longint;\n i:shortint;\nbegin\nread(a,b);\nfor i:=1 to b do\n begin\n if a mod 10 =0 then a:=a div 10\n else a:=a-1;\n end;\nwriteln(a);\nreadln\nend."}, {"source_code": "var n,k,i:longint;\nbegin\n readln(n,k);\n for i:=1 to k do\n if n mod 10<>0 then\n n:=n-1\n else\n n:=n div 10;\n write(n);\nend."}, {"source_code": "Var\n n, k: Integer;\n \nBegin\n Read(n, k);\n For Var i := 1 to k do\n If n mod 10 = 0 then\n n := n div 10\n Else n -= 1;\n Write(n)\nEnd."}, {"source_code": "var a,n,k:integer;\n\nbegin\n read(n,k);\n for a:=1 to k do begin\n if n mod 10 = 0 then n:=n div 10\n else dec(n);\n end;\n writeln(n);\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=5000007;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,s1,s2,a,b,res,k:longint;\n begin\n read(fi,n,k);\n for i:=1 to k do if n mod 10=0 then n:=n div 10 else n:=n-1;\n write(fo,n);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j,k,res,ma:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var a,b,c,v,g,h,n,i:integer;\nbegin\nread(a,b);\nfor i:=1 to 10000000000 do\nbegin\nif (a mod 10 = 0 ) then\nbegin\na:=a div 10;\nb:=b-1;\nend\nelse\nbegin\na:=a-1;\nb:=b-1;\nend;\nif (b=0) then break;\nend;\nwrite(a);\nend."}, {"source_code": "var n,k:integer;\nbegin\n\n readln(n,k);\n for var i:=1 to k do\n if n mod 10 = 0 then n:=n div 10\n else n-=1;\n \n writeln(n);\n\nend."}, {"source_code": "var n, k, i: integer;\nBEGIN\nread(n, k);\nfor i:=1 to k do begin\nif n mod 10 <> 0 then\nn:=n-1 else\nn:=n div 10;\nend;\nwrite(n);\nEND."}, {"source_code": "var k,n,i:integer;\nbegin\n readln(n,k);\n for i:=1 to k do begin\n if n mod 10 <> 0 then n := n - 1\n else n := n div 10;\n end;\n writeln(n);\nend.\n "}, {"source_code": "var \n a,b,i:longint;\nbegin\nread(a,b);\nfor i:=1 to b do\n if a mod 10 <> 0 then\n a:=a-1\n else\n a:=a div 10;\nwriteln(a);\nend."}, {"source_code": "var n,k:longint;\nbegin\n readln(n,k);\n while k>0 do\n begin\n if n mod 10=0 then n:=n div 10 else n:=n-1;\n k:=k-1;\n end;\n writeln(n);\nend.\n\n"}, {"source_code": "var n:longint;\n i,k:byte;\nbegin\n readln(n,k);\n for i:=1 to k do\n if n mod 10 = 0 then n:=n div 10 else n:=n-1;\n writeln(n);\n readln;\nend."}, {"source_code": "var\n n,k:int64;\nbegin\n readln(n,k);\n while k>0 do\n begin\n if n mod 10<>0 then n:=n-1\n else n:=n div 10;\n dec(k);\n end; \n writeln(n);\nend."}, {"source_code": "uses math;\nvar f,g:text; n,i,m:longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n read(f,m,n);\n for i:=1 to n do\n begin\n if m mod 10=0 then m:=m div 10\n else dec(m);\n end; write(g,m);\n close(f); close(g);\nend."}, {"source_code": "program pitux;\nvar a,n,k:longint; i:shortint;\nbegin\nread(n,k);\nfor i:= 1 to k do begin\na:= n;\nif a mod 10 = 0 then\nn:= n div 10\nelse \nn:= n - 1;\nend;\nwrite(n);\n\nend."}, {"source_code": "var\n n, k: integer;\n\n\nbegin\n read(n, k);\n while k > 0 do \n begin\n if n mod 10 > 0 then\n n := n - 1 \n else \n n := n div 10;\n k := k - 1;\n end;\n write(n);\nend."}, {"source_code": "var\n n,m:int64;\n i:longint;\n\nbegin\n readln(n,m);\n for i := 1 to m do\n begin\n if n mod 10 > 0 then dec(n) else n := n div 10;\n end;\n writeln(n);\nend."}, {"source_code": "Var n,k,i : longint;\nBegin\n Readln(n,k);\n for i:=1 to k do\n if n mod 10=0 then n:=n div 10\n else n:=n-1;\n writeln(n); \n\nend."}, {"source_code": "var n,m,i:longint;\nbegin\nreadln(n,m);\nfor i:=1 to m do\n if n mod 10=0 then n:=n div 10 else dec(n);\nwriteln(n);\nend."}, {"source_code": "Var\nk: byte;\nn: longint;\n\nBegin\nreadln(n, k);\nrepeat\nif ((n mod 10)<=k) and (n mod 10<>0) then begin k:=k-(n mod 10); n:=(n-(n mod 10)) end\nelse if ((n mod 10) =0) and (k<>0) then begin n:=n div 10; dec(k); end\nelse begin n:=n-k; k:=0; end;\nuntil k=0;\nwriteln(n);\nEnd."}, {"source_code": "program WRONG_SUBTRACTION;\nvar k,i,n1:byte;\n n:longint;\nbegin\n readln(n,k);\n for i:=1 to k do\n begin\n n1:=n mod 10;\n if n1 = 0 then n:=n div 10\n else dec(n);\n end;\n Writeln(n);\n readln;\nend.\n"}, {"source_code": "var\n n, k,i: integer;\n\nbegin\n read(n, k);\n for i := 1 to k do\n if n mod 10 = 0 then\n n := n div 10\n else \n n := n - 1;\n write(n)\nend."}, {"source_code": "var\nn,k,i : longint;\nbegin\nreadln(n,k);\nfor i := 1 to k do if n mod 10 = 0 then n:=n div 10 else n:=n-1;\nwriteln(n);\nend."}, {"source_code": "var\nn,i,k:int64;\nbegin\n read(n,k);\n for i:=1 to k do\n if n mod 10 =0 then n:=n div 10 else n:=n-1;\n write(n);\nend."}, {"source_code": "var n, k, i : integer;\nBegin\nRead(n, k);\nfor i := 1 to k do\nbegin\nif n mod 10 <> 0 then n:= n - 1\nelse n:= n div 10;\nend;\nwriteLn(n);\nend."}, {"source_code": "var\n n,k,i: longint;\nbegin\nread(n,k);\nfor i:=1 to k do begin\n if (n mod 10 =0) then\n n:=n div 10\n else \n n:=n-1;\nend;\nwrite(n);\nend."}, {"source_code": "program fd;\nvar\n n:real;\n k:byte;\nbegin\n readln(n,k);\n for i:byte:=1 to k do\n begin\n if (n-Trunc(n/10)*10)<>0 then n-=1 else n:=n/10;\n end;\n Writeln(n);\nend."}, {"source_code": "Program Wrong_subtraction;\nvar\nn, k, i: integer;\nbegin\n readln(n, k);\n i:= 0;\n while i < k do\n begin\n if n mod 10 = 0 then\n n:= n div 10\n else\n n:= n - 1;\n i := i+1;\n end;\n writeln(n);\nend."}, {"source_code": "program p3;\nvar\n n,k,r,c : longint;\nbegin\n readln(n,k);\n for c:=1 to k do\n begin\n r:=n mod 10;\n if r=0 then\n begin\n n:=n div 10;\n end\n else\n begin\n n:=n-1;\n end;\n end;\n writeln(n);\nend."}, {"source_code": "Var a, b:int64;\nbegin\n read(a, b) ;\n Repeat\n If a mod 10=0 then a:=a div 10\n Else a:=a-1;\n B:=b-1;\n Until b=0;\n Writeln(a) ;\nend.\n"}, {"source_code": "var n,k,i:integer;\nbegin\n read(n,k);\n for i:=1 to k do\n begin\n if n mod 10=0 then\n begin\n n:=n div 10;\n continue;\n end;\n n:=n-1;\n end;\n write(n);\n end."}, {"source_code": "var n,k:longint;\nbegin\n read(n,k);\n for k:=1 to k do\n if n mod 10<>0 then\n n:=n-1\n else\n n:=n div 10;\n write(n); \nend."}, {"source_code": "var\nn:longint;\nm,k:integer;\nbegin\nread(n);\nread(k);\nm:=0;\nwhile m0 then n:= n-1\n else n:=n div 10;\n end;\n write(n);\n end."}, {"source_code": "var\n n1, n2, i, x: integer;\n\nbegin\n read(n1, n2);\n for i := 1 to n2 do\n if n1 mod 10 = 0 then\n n1:=n1 div 10\n else\n n1 := n1 - 1;\n \n writeln(n1);\nend."}, {"source_code": "PROGRAM THIRD;\n\nVAR\n N,K:INTEGER;\n \nBEGIN;\n READLN(N,K);\n REPEAT\n begin;\n IF N MOD 10 = 0 THEN N:=N DIV 10 ELSE N:=N-1;\n end; \n K:=K-1;\n UNTIL K=0;\n WRITELN(N);\nEND."}, {"source_code": "var n,k,i:integer;\nbegin\n\tread(n,k);\n\tfor i:=1 to k do\n\tbegin\n\t\tif (n mod 10)=0 then \n\t\t\tbegin\n\t\t\tn:=n div 10;\n\t\t\tcontinue;\n\t\t\tend;\n\t\tif (n mod 10)<>0 then\n\t\t\tbegin\n\t\t\tn:=n-1;\n\t\t\tcontinue;\n\t\t\tend;\n\tend;\n\twriteln(n);\n\tend."}, {"source_code": "var\na,b,d:longint;\nbegin\nread(a,b);\nd:=0;\nwhile d < b do\nbegin\nif a mod 10 = 0 then\na:=a div 10\nelse\na:=a-1;\nd:=d+1;\nend;\nwriteln(a);\nend."}, {"source_code": "program Tanya;\nvar n, k, i, res : Integer;\nbegin\nRead(n, k);\nfor k := k downto 1 do\nbegin\nif n mod 10 = 0 then\nn := n div 10\nelse n := n - 1;\nend;\nWrite(n);\nend."}, {"source_code": "{Маленькая девочка Таня учится уменьшать числа на единицу, но она делает это неправильно с числами, состоящими из нескольких цифр. Таня вычитает единицу из числа по следующему алгоритму:\n\nесли последняя цифра числа не равна нулю, она уменьшает число на единицу;\nесли последняя цифра числа равна нулю, она делит число на 10 (то есть удаляет его последнюю цифру).\nВам задано целое число n. Таня хочет вычесть из него единицу k раз. Ваша задача вывести результат после всех k вычитаний.\n\nГарантируется, что ответ будет являться целым положительным числом.}\nVar n,k:integer;\n i: byte;\nBegin\nReadln(n,k);\nFor i:=1 to k do\nbegin\nIf (n mod 10)=0 then\nn:=n div 10\nElse \nn:=n-1;\nend;\nWriteln(n);\nEnd."}, {"source_code": "var a,i,o,j:integer;\nbegin\n\n\nreadln(j,a);\nfor i:=1 to a do\nbegin\no:=j mod 10;\nif (o = 0) then \nj:=j div 10\nelse\nj:=j-1;\n\n\n\n\n\n\nend;\nwriteln(j);\nend."}, {"source_code": "\nvar n,i,a,k:integer;\nbegin\n\n read(n); read(k);\n\n for i:=1 to k do\n begin\n if (n mod 10 <> 0) then n:=n-1\n else if (n mod 10 = 0) then n:=n div 10;\n end;\n writeln(n);\n\n\nend."}, {"source_code": "var n,k:longint;\nbegin\nread(n,k);\nwhile k<>0 do\nbegin\nif n mod 10=0 then n:=n div 10\nelse n:=n-1;\ndec(k);\nend;\nwrite(n);\nend.\n"}, {"source_code": "program N1;\nvar a,b,i:int64;\nbegin\nreadln(a,b);\nfor i:=1to b do begin\n if a mod 10 =0 then a:=a div 10 else a:=a-1;\n end; \nwriteln(a); \nend."}, {"source_code": "\nvar b,c,d,e,df,j,k,g,m,n,i:longint;\nbegin\n readln(b,c);\n for i:=1 to c do\n begin\n if(b mod 10=0) then\n begin\n b:=b div 10;\n continue;\n end;\n b:=b-1;\n end;\n writeln(b);\nend."}, {"source_code": "var\na,i,c : integer;\nbegin\nread(a,i);\nfor c:=0 to i-1 do\nbegin\nif ( a mod 10 )=0 then \na:=a div 10\nelse\na:=a-1;\nend;\nwriteln(a);\nend.\n"}, {"source_code": "var a,b,i:integer;\nbegin\n read(a,b);\n for i:=1 to b do begin\n if a mod 10 <> 0 then begin\n a:=a-1\n end else\n a:=a div 10;\n end;\n write(a);\nend."}, {"source_code": "var a,k,n,p:integer;\nbegin\nreadln(n,k);\nfor a:= 1 to k do\nbegin\nif n mod 10=0 then n:=n div 10\nelse n:=n-1;\nend;\nwriteln(n);\nreadln;\nend."}, {"source_code": "var i,n,k:longint;\n a:array[1..100000] of longint;\nbegin\n readln(n,k);\n while k>0 do\n begin\n if (n mod 10)<>0 then dec(n)\n else n:=n div 10;\n dec(k);\n end;\n write(n);\n //readln;\nend."}, {"source_code": "program vichitanie;\nvar n:int64;\ni,k:integer;\nbegin\ni:=0;\nread(n,k);\nwhile i0 then n-=1\nelse n:=n div 10;\ni+=1;\nend;\nwriteln(n);\nend."}, {"source_code": "var I,N:byte;k:longint;\n\n\n\nbegin\nread(k,n);\nfor i:=1 to n do\n if k mod 10=0 then k:=k div 10 else k:=k-1;\nwrite(k);\nEND."}, {"source_code": "var a,b,q:longint;\n\nbegin\nreadln(a,b);\nwhile b<>0 do\nbegin\nif a<10 then begin a:=a-b; writeln(a); halt; end;\nif a mod 10 =0 then begin a:=a div 10; dec(b) end else\nbegin\nq:=a mod 10;\nif q>b then q:=b;\na:=a-q;\nb:=b-q;\n\nend;\nend;\n\n\nwriteln(a);\nend.\n"}, {"source_code": "var n,k,i: longint;\n\nbegin\n readln(n,k);\n for i := 1 to k do if n mod 10 = 0 then n := n div 10 else dec(n,1);\n write(n);\nend."}], "negative_code": [{"source_code": "var \na,b,c,d:integer;\nbegin\n read(a,b);\n \n while b>0 do \n begin\n if (A mod 10>0) then a:=a-(a mod 10) \n else if (a mod 10=0) then a:=a div 10;\n b:=b-1;\n end;\n write(a)\nend."}, {"source_code": "var i, k, n: integer;\nbegin\nwrite ('n ');\nread (n);\nwrite ('k ');\nread (k);\nfor i:=1 to k do\nif n mod 10<>0 then n:=n-1 else n:=n div 10;\nwrite ('n ', n);\nend."}, {"source_code": "var \ni, k : integer; n: longint; \nbegin\nread (n, k);\nfor i:=1 to k do if n mod 10<>0 then n:=n-1 else n:=n div 10;\nwrite ('n ', n);\nend. \n\n"}, {"source_code": "program v;\nvar i, k, n: integer;\nbegin\nwrite ('n ');\nread (n);\nwrite ('k ');\nread (k);\nfor i:=1 to k do\nif n mod 10<>0 then n:=n-1 else n:=n div 10;\nwrite ('n ', n);\nend."}, {"source_code": "program v;\nvar i, k, n: integer;\nbegin\nwrite ('n ');\nread (n);\nwrite ('k ');\nread (k);\nfor i:=1 to k do\nif n mod 10<>0 then n:=n-1 else n:=n div 10;\nwrite ('n ', n);\nend. \n\n"}, {"source_code": "var \ni, k : integer; n: longint; \nbegin\nwrite ('n ');\nread (n);\nwrite ('k ');\nread (k);\nfor i:=1 to k do if n mod 10<>0 then n:=n-1 else n:=n div 10;\nwrite ('n ', n);\nend. \n\n"}, {"source_code": "var\n\ti, n, k,q: integer;\n\t\nbegin\n\tread(n, k);\n\t\t\n\tfor i := 1 to k do \n\tq:=n mod 10; \n\tif q <> 0 then q := q-1 else q := q div 10;\n\t\t\n\twriteln(q);\n\t\nend."}, {"source_code": "var\n\ti, n, k,q: integer;\n\t\nbegin\n\tread(n, k);\n\t\t\n\tfor i := 1 to k do \n\tbegin\n\tq:=n mod 10; \n\tif q <> 0 then q := q-1 else q := q div 10;\n\tend;\n\t\t\n\twriteln(q);\n\t\nend."}, {"source_code": "var \ni, k : integer; n: longint; \nbegin\nwrite ('n ');\nread (n);\nwrite ('k ');\nread (k);\nfor i:=1 to k do \nbegin \nif (n mod 10<>0) then n:=n-1 else n:=n div 10;\nend; \nwrite ('n ', n);\nend. \n\n"}, {"source_code": "Program Wrong_subtraction;\nvar\nn, k, i: integer;\nbegin\n writeln('Введите число для вычитания и колличество вычитаний.');\n readln(n, k);\n i:= 0;\n while i < k do\n begin\n if n mod 10 = 0 then\n n:= n div 10\n else\n n:= n - 1;\n i := i+1;\n end;\n writeln(n);\nend."}, {"source_code": "program abc;\nvar n:integer; i,k:integer; s:string;\nBegin\n read(n);\n readLn(k);\n for i:= 1 to k do\n Begin\n Str(n,s);\n if s[length(s)-1] = '0' then n:=n div 10\n else Dec(n);\n End;\n writeLn(n);\nEnd."}, {"source_code": "var\nn:longint;\nm,k:integer;\nbegin\nwrite('введите число n');\nread(n);\nread(k);\nm:=0;\nwhile m 0 then n:=n-1\nelse n:= n div 10;\nm:=m+1;\nend;\nwrite(n);\nend."}, {"source_code": "var\nn:longint;\nm,k:integer;\nbegin\nwrite('введите число n');\nread(n);\nread(k);\nm:=0;\nwhile m 0 then n:=n-1\nelse n:= n div 10;\nm:=m+1;\nend;\nwrite(n);\nend."}, {"source_code": "var\n s: string;\n k: integer;\n buffer: integer;\n\nbegin\n readln(s);\n k := StrToInt(Copy(s, pos(' ', s), length(s)));\n Delete(s,pos(' ',s), length(s));\n writeln(s, ' ', k);\n while(k <> 0) do\n begin\n if s[length(s)] <> '0' then \n begin\n buffer := s.ToInteger;\n dec(buffer);\n s := buffer.ToString;\n dec(k);\n end\n else if s[length(s)] = '0' then \n begin\n s := Copy(s, 1, length(s) - 1);\n dec(k);\n end;\n end;\n \n writeln(s);\nend."}, {"source_code": "const f1='977a.inp';\n f2='977a.out';\nvar a,b:longint;\n\nbegin\n //assign(input,f1);reset(input);\n //assign(output,f2);rewrite(output);\n read(a,b);\n while b>0 do\n begin\n if (a mod 10=0) then dec(a,10) else dec(a);\n dec(b);\n end;\n writeln(a);\nend."}, {"source_code": "var n, k, i:integer;\nbegin\n readln(n);\n readln(k);\n for i:=1 to k do \n begin\n if (n mod 10 = 0) then n:= n div 10 else\n n:=n-1;\n end;\n writeln(n);\nend."}, {"source_code": "program Project1;\n Uses sysutils;\nvar\n chis,chis1,chis2:string;\n a,b:integer;\nbegin\n\n\n readln(chis);\n chis1:=Copy(chis, 1, Pos(' ' ,chis)-1);\n chis2:=Copy(chis, Pos(' ' ,chis)+1, Length(chis));\na:=strtoint(chis1);\nb:=strtoint(chis2);\n\nwriteln('a=',a,', b=',b);\nwhile (b>0) do\nbegin\n\nif ((a mod 10)<>0) then a:=a-1 else a:=a div 10;\ndec(b);\nend;\n writeln(a);\n\n\nend. "}, {"source_code": "Var n:longint;\n k,i:integer;\nbegin\n read(n,k);\n for i:=1 to k do\n if (n mod 10) = 0\n then n:=n mod 10\n else n:=n-1;\n writeln(n);\n readln;\nend.\n"}, {"source_code": "Var n:longint;\n k,i:integer;\nbegin\n read(n,k);\n for i:=1 to k do\n if (n div 10) = 0\n then n:=n div 10\n else n:=n-1;\n writeln(n);\n readln;\nend.\n"}, {"source_code": "var a,k,i:integer;\nbegin\n readln(a,k);\n for i:=1 to k do\n if a mod 10<>0 then\n begin\n a:=a-1;\n write(a,' ');\n end\n else\n begin\n a:=a div 10;\n write(a,' ');\n end;\n readln;\nend.\n"}, {"source_code": "program untitled;\nvar \nn :integer;\ni:integer;\na:longint;\n\n\n\n\n\n\n//WARNING\nbegin\nreadln(a);\nreadln(n);\n\nfor i:=1 to n do \nif (a mod 10 = 0) then a :=a div 10\nelse \na:=a-1;\n\n\nwriteln(a);\n\n\n\t\nEND.\n\n"}, {"source_code": "var\n\ti,n,k:longint;\n\nbegin\n\treadln(n,k);\n\tfor i:=1 to k do \n\t\tbegin\n\t\t\tif (n mod 10<>0) then inc(n)\n\t\t\t\telse n:=n div 10;\n\t\tend;\n\twriteln(n);\n\nend."}, {"source_code": "var\n a, b, i, j: longint;\n s: string;\n \nbegin\n readln(a, b);\n while b > 0 do\n begin\n if (a mod 10 <> 0) then \n begin\n i := a mod 10;\n a := a - i;\n b := b - i;\n end\n else\n begin\n a := a div 10;\n b := b - 1;\n end;\n end;\n writeln(a);\nend."}, {"source_code": "var\n i,n,k:longint;\nbegin\n readln(n,k);\n for i:=1 to k do\n if n mod 10=0 then n:=n div 10\n else n:=n-1;\nend."}, {"source_code": "var x,y: longint;\nbegin\n readln(x,y);\n writeln(x-y);\nend."}, {"source_code": "PROGRAM THIRD;\n\nVAR\n N,K:INTEGER;\n \nBEGIN;\n READLN(N,K);\n FOR K:=K TO 0 DO\n begin;\n IF N MOD 10 = 0 THEN N:=N DIV 10 ELSE N:=N-1;\n end;\n WRITELN(N);\nEND."}, {"source_code": "{Маленькая девочка Таня учится уменьшать числа на единицу, но она делает это неправильно с числами, состоящими из нескольких цифр. Таня вычитает единицу из числа по следующему алгоритму:\n\nесли последняя цифра числа не равна нулю, она уменьшает число на единицу;\nесли последняя цифра числа равна нулю, она делит число на 10 (то есть удаляет его последнюю цифру).\nВам задано целое число n. Таня хочет вычесть из него единицу k раз. Ваша задача вывести результат после всех k вычитаний.\n\nГарантируется, что ответ будет являться целым положительным числом.}\nVar n:integer;\n k,i: byte;\nBegin\nRead(n,k);\nIf (((n<=2) and (n<1000000000)) and ((k>=1) and (k<50)))=false then\nbegin\nFor i:=1 to k do\nbegin\nIf (n mod 10)=0 then\nn:=n div 10\nElse \nn:=n-1;\nend;\nWriteln(n);\nend\nElse Writeln('Неверное число');\nEnd."}, {"source_code": "{Маленькая девочка Таня учится уменьшать числа на единицу, но она делает это неправильно с числами, состоящими из нескольких цифр. Таня вычитает единицу из числа по следующему алгоритму:\n\nесли последняя цифра числа не равна нулю, она уменьшает число на единицу;\nесли последняя цифра числа равна нулю, она делит число на 10 (то есть удаляет его последнюю цифру).\nВам задано целое число n. Таня хочет вычесть из него единицу k раз. Ваша задача вывести результат после всех k вычитаний.\n\nГарантируется, что ответ будет являться целым положительным числом.}\nVar n:integer;\n k,i: byte;\nBegin\nRead(n,k);\nIf (((n<=2) and (n<=1000000000)) and ((k>=1) and (k<=50)))=false then\nbegin\nFor i:=1 to k do\nbegin\nIf (n mod 10)=0 then\nn:=n div 10\nElse \nn:=n-1;\nend;\nWriteln(n);\nend\nElse Writeln('Неверное число');\nEnd."}], "src_uid": "064162604284ce252b88050b4174ba55"} {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='b';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,z1,z2,z3,rr:extended;\n p2,y1,y2,y3:extended;\n nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qb then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction koldel(p,mmod:int64):int64; var pp,ot:int64;\nbegin koldel:=(p+mmod) div mmod; end;\n\n\nfunction dist(phi:extended):extended;\nbegin phi:=phi*v/rr; dist:=rr*phi+rr*(sin(phi)-0); end;\n\nfunction ddist(phi:extended):extended;\nbegin phi:=phi*v/rr; ddist:=rr*phi-rr*(sin(phi)-0); end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,rr,v);\n for i:=1 to n do read(a[i],b[i]);\n\n { for i:=0 to 1000 do writeln(i/100:0:3,' ',dist(i/100):0:5);\n }\n for i:=1 to n do\n begin\n aaa:=0; bbb:=1e+10;\n { a[i]:=a[i]/rr; b[i]:=b[i]/rr;\n }\n while abs(aaa-bbb)>1e-7 do\n begin\n ccc:=(aaa+bbb)/2;\n if dist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',dist(ccc):0:9);\n }\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=ccc;\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-7 do\n begin\n ccc:=(aaa+bbb)/2;\n if ddist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',ddist(ccc):0:9);\n } end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n { ccc1:=rr*2*ccc1/v; ccc:=rr*2*ccc/v;\n writeln(ccc:0:10,' == ',ccc1:0:10);\n }\n if ccc1b then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction koldel(p,mmod:int64):int64; var pp,ot:int64;\nbegin koldel:=(p+mmod) div mmod; end;\n\n\nfunction dist(phi:extended):extended;\nbegin phi:=phi*v/rr; dist:=rr*phi+rr*(sin(phi)-0); end;\n\nfunction ddist(phi:extended):extended;\nbegin phi:=phi*v/rr; ddist:=rr*phi-rr*(sin(phi)-0); end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,rr,v);\n for i:=1 to n do read(a[i],b[i]);\n\n { for i:=0 to 1000 do writeln(i/100:0:3,' ',dist(i/100):0:5);\n }\n for i:=1 to n do\n begin\n aaa:=0; bbb:=1e+10;\n { a[i]:=a[i]/rr; b[i]:=b[i]/rr;\n }\n while abs(aaa-bbb)>1e-7 do\n begin\n ccc:=(aaa+bbb)/2;\n if dist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',dist(ccc):0:9);\n }\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=ccc;\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-7 do\n begin\n ccc:=(aaa+bbb)/2;\n if ddist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',ddist(ccc):0:9);\n } end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n { ccc1:=rr*2*ccc1/v; ccc:=rr*2*ccc/v;\n writeln(ccc:0:10,' == ',ccc1:0:10);\n }\n if ccc1c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qb then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction koldel(p,mmod:int64):int64; var pp,ot:int64;\nbegin koldel:=(p+mmod) div mmod; end;\n\n\nfunction dist(phi:extended):extended;\nbegin dist:=rr*phi+rr*(sin(phi)-0); end;\n\nfunction ddist(phi:extended):extended;\nbegin ddist:=rr*phi-rr*(sin(phi)-0); end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,rr,v);\n for i:=1 to n do read(a[i],b[i]);\n\n { for i:=0 to 1000 do writeln(i/100:0:3,' ',dist(i/100):0:5);\n }\n for i:=1 to n do\n begin\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-8 do\n begin\n ccc:=(aaa+bbb)/2;\n if dist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=ccc;\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-8 do\n begin\n ccc:=(aaa+bbb)/2;\n if ddist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n if ccc1b then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction koldel(p,mmod:int64):int64; var pp,ot:int64;\nbegin koldel:=(p+mmod) div mmod; end;\n\n\nfunction dist(phi:extended):extended;\nbegin dist:=rr*phi+rr*(sin(phi)-0); end;\n\nfunction ddist(phi:extended):extended;\nbegin ddist:=rr*phi-rr*(sin(phi)-0); end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,rr,v);\n for i:=1 to n do read(a[i],b[i]);\n\n { for i:=0 to 1000 do writeln(i/100:0:3,' ',dist(i/100):0:5);\n }\n for i:=1 to n do\n begin\n aaa:=0; bbb:=1e+10;\n { a[i]:=a[i]/rr; b[i]:=b[i]/rr;\n }\n while abs(aaa-bbb)>1e-8 do\n begin\n ccc:=(aaa+bbb)/2;\n if dist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=ccc;\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-8 do\n begin\n ccc:=(aaa+bbb)/2;\n if ddist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=rr*2*ccc1/v; ccc:=rr*2*ccc/v;\n if ccc1b then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction koldel(p,mmod:int64):int64; var pp,ot:int64;\nbegin koldel:=(p+mmod) div mmod; end;\n\n\nfunction dist(phi:extended):extended;\nbegin phi:=phi*rr/v; dist:=rr*phi+rr*(sin(phi)-0); end;\n\nfunction ddist(phi:extended):extended;\nbegin phi:=phi*rr/v; ddist:=rr*phi-rr*(sin(phi)-0); end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,rr,v);\n for i:=1 to n do read(a[i],b[i]);\n\n { for i:=0 to 1000 do writeln(i/100:0:3,' ',dist(i/100):0:5);\n }\n for i:=1 to n do\n begin\n aaa:=0; bbb:=1e+10;\n { a[i]:=a[i]/rr; b[i]:=b[i]/rr;\n }\n while abs(aaa-bbb)>1e-17 do\n begin\n ccc:=(aaa+bbb)/2;\n if dist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',dist(ccc):0:9);\n }\n end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n ccc1:=ccc;\n aaa:=0; bbb:=1e+10;\n while abs(aaa-bbb)>1e-17 do\n begin\n ccc:=(aaa+bbb)/2;\n if ddist(ccc)>(b[i]-a[i])/2 then bbb:=ccc else aaa:=ccc;\n { writeln(ccc:0:9,' ',ddist(ccc):0:9);\n } end;\n { writeln(2*ccc/v:0:8,' ',dist(ccc):0:7);\n }\n { ccc1:=rr*2*ccc1/v; ccc:=rr*2*ccc/v;\n writeln(ccc:0:10,' == ',ccc1:0:10);\n }\n if ccc1c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qc then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi\n then x:=man.up-1\n else x:=man.up;\n y:=y+x*42*2;\n end;\n end;\n end;\n get:=y;\n end;\n procedure dfs;\n var\n hash,i,j,k,ii:longint;\n begin\n inc(time);\n hash:=0;\n for i:=1 to 3 do\n hash:=(hash*8*42+get(man[i],i));\n k:=ht[(hash mod mo)+1];\n while k<>0 do\n begin\n if v[k].h=hash then break;\n k:=v[k].next;\n end;\n if v[k].h=hash then exit;\n inc(tot); v[tot].next:=ht[hash mod mo+1]; v[tot].h:=hash; ht[hash mod mo+1]:=tot;\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i].moved:=false;\n dec(man[i].pos, k);\n end;\n end;\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n dfs;\n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)and(ii<>j)or(man[j].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\nbegin\n TOT:=0;\n fillchar(ht,sizeof(ht),0);\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n ans:=-1;\n dfs;\n writeln(ans);\nend.\n", "positive_code": [{"source_code": "var x,l,r,q:array[1..3]of longint;\n p:array[1..9]of boolean;\n i,j,k,n,ans:longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then max:=x else max:=y;\nend;\nprocedure gc;\nvar i,o,j,k:longint;\n xx,qq:array[1..3]of longint;\n pp:boolean;\nbegin\n ans:=max(ans,max(x[1],max(x[2],x[3])));\n for i:=1 to 3 do begin xx[i]:=x[i];qq[i]:=q[i];end;\n for o:=1 to 3 do if not(p[o]) then\n begin\n pp:=true;\n for i:=1 to 3 do if (x[o]=x[i])and(o<>i) then pp:=false;\n if pp then\n for i:=-l[o] to l[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n pp:=false;if i=l[o] then pp:=true;\n for j:=1 to 3 do\n begin\n if abs(x[o]+i-x[j])=1 then pp:=true;\n if (abs(x[o]+i-x[j]-l[j])=1)and(not(p[j])) then pp:=true;\n end;\n end;\n if pp then\n begin\n x[o]:=x[o]+i;p[o]:=true;gc;p[o]:=false;x[o]:=xx[o];\n end;\n end;\n end;\n for o:=1 to 3 do if (not(p[o+3]))and(q[o]=0) then\n begin\n pp:=false;\n for i:=1 to 3 do if (x[o]=x[i])and(o<>i) then pp:=true;\n if pp then\n for i:=-r[o] to r[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n pp:=false;if i=r[o] then pp:=true;\n for j:=1 to 3 do\n begin\n if abs(x[o]+i-x[j])=1 then pp:=true;\n if (abs(x[o]+i-x[j]-l[j])=1)and(not(p[j])) then pp:=true;\n end;\n end;\n if pp then\n begin\n p[o+3]:=true;\n for k:=1 to 3 do if (x[k]=x[o])and(q[k]>0) then\n begin\n x[k]:=x[o]+i;dec(q[k]);\n end;\n gc;\n p[o+3]:=false;\n for k:=1 to 3 do begin x[k]:=xx[k];q[k]:=qq[k];end;\n end;\n end;\n end;\n for o:=1 to 3 do if not(p[o+6]) then\n begin\n pp:=true;\n for i:=1 to 3 do if (x[o]=x[i])and(o<>i) then pp:=false;\n if pp then\n begin\n pp:=false;\n for i:=1 to 3 do if x[i]-x[o]=1 then pp:=true;\n if pp then\n begin\n p[o+6]:=true;\n for i:=1 to 3 do if x[i]-x[o]=1 then\n begin\n x[i]:=x[o];inc(q[i]);\n end;\n gc;\n p[o+6]:=false;\n for i:=1 to 3 do begin x[i]:=xx[i];q[i]:=qq[i];end;\n end;\n pp:=false;\n for i:=1 to 3 do if x[o]-x[i]=1 then pp:=true;\n if pp then\n begin\n p[o+6]:=true;\n for i:=1 to 3 do if x[o]-x[i]=1 then\n begin\n x[i]:=x[o];inc(q[i]);\n end;\n gc;\n p[o+6]:=false;\n for i:=1 to 3 do begin x[i]:=xx[i];q[i]:=qq[i];end;\n end;\n end;\n end;\nend;\nbegin\n read(x[1],l[1],r[1],x[2],l[2],r[2],x[3],l[3],r[3]);\n ans:=max(max(x[1],x[2]),x[3]);\n gc;\n writeln(ans);\nend.\n"}, {"source_code": "{$M 100000000}\nconst\n mo=5000000;\n \ntype\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n tot,ans,i,j,k,time:longint;\n online:longint;\n ht:array[0..mo] of longint;\n v:array[0..21000000] of record next,h:longint; end;\n \nfunction get(var man:Tman; i:longint):longint;\n var\n x,y:longint;\n begin\n with man do\n begin\n y:=pos-1;\n if moved then y:=y+42*1;\n if threw then\n begin\n if man.up=-1\n then y:=y+3*42*2 else\n begin\n if man.up>i\n then x:=man.up-1\n else x:=man.up;\n y:=y+x*42*2;\n end;\n end;\n end;\n get:=y;\n end;\n \nprocedure dfs;\n var\n hash,i,j,k,ii:longint;\n begin\n inc(time);\n \n hash:=0;\n for i:=1 to 3 do\n hash:=(hash*8*42+get(man[i],i));\n \n k:=ht[(hash mod mo)+1];\n while k<>0 do\n begin\n if v[k].h=hash then break;\n k:=v[k].next;\n end;\n \n if v[k].h=hash then exit;\n \n inc(tot); v[tot].next:=ht[hash mod mo+1]; v[tot].h:=hash; ht[hash mod mo+1]:=tot;\n \n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i].moved:=false;\n dec(man[i].pos, k);\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)and(ii<>j)or(man[j].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n online:=1;\n \n if online=0 then begin\n assign(input,'E.in'); reset(input);\n assign(output,'E.out'); rewrite(output); end;\n \n TOT:=0;\n fillchar(ht,sizeof(ht),0);\n \n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \n if online=0 then begin\n close(input);\n close(output); end;\nend."}, {"source_code": "program cf105e;\ntype\n num=array[1..3]of longint;\nvar\n n,i,j,ans:longint;\n f:array[0..10000000]of boolean;\n t,m,p:num;\n c:num;\n s:num;\n// a:array[0..30,0..2]of longint;\nprocedure dfs(x,y,z:longint); forward;\nprocedure dd;\nvar i,ha:longint;\nbegin\n for i:=1 to 3 do\n if p[i]>ans then ans:=p[i];\n ha:=0;\n for i:=1 to 3 do ha:=(ha*39+s[i])mod 9999997;\n for i:=1 to 3 do ha:=(ha*39+p[i]) mod 9999997;\n for i:=1 to 3 do ha:=(ha*39+c[i]) mod 9999997;\n if f[ha] then exit;\n dfs(1,2,3);\n dfs(1,3,2);\n dfs(2,1,3);\n dfs(2,3,1);\n dfs(3,1,2);\n dfs(3,2,1);\n f[ha]:=true;\n// f[p[1],p[2],p[3],c[1],c[2],c[3],s[1],s[2],s[3]]:=true;\nend;\n\n\nprocedure dfs(x,y,z:longint);\nvar\n i,j,k:longint;\n pp,ss,cc:num;\nbegin\n if p[1]=6 then\n if p[2]=5 then\n if p[3]=5 then\n p[1]:=p[1];\n\n pp:=p; ss:=s; cc:=c;\n //f[p[1],p[2],p[3],c[1],c[2],c[3],s[1],s[2],s[3]]:=true;\n if not( (p[y]=p[x]) or (p[z]=p[x])) then\n if s[x] and 1<>0 then begin\n for i:=p[x]-m[x] to p[x]+m[x] do\n if (i>=1)and(i<>p[y])and(i<>p[z]) then begin\n p[x]:=i;\n s[x]:=ss[x]-1;\n dd;\n p[x]:=pp[x]; inc(s[x]);\n end;\n end;\n\n if (p[y]=p[x])and(c[y]=c[x]+1)and(c[x]=0) then\n if s[x] and 2 <> 0 then begin\n for i:=p[y]-t[x] to p[y]+t[x] do\n if (i>=1)and(i<>p[z]) then begin\n p[y]:=i;\n s[x]:=s[x]-2;\n c[y]:=0;\n if pp[z]=pp[y] then begin\n c[z]:=1;\n p[z]:=i;\n end;\n dd;\n p[y]:=pp[y]; s[x]:=ss[x]; c[y]:=cc[y];\n p[z]:=pp[z]; c[z]:=cc[z];\n end;\n end;\n\n if (abs(p[x]-p[y])=1)and(c[x]=c[y]) then\n if s[x] and 4<>0 then begin\n if p[z]=p[y] then begin\n p[z]:=p[x];\n c[z]:=2;\n end;\n p[y]:=p[x]; c[y]:=c[x]+1;\n s[x]:=s[x]-4;\n dd;\n end;\n p:=pp; s:=ss; c:=cc;\nend;\n\n\nbegin\n fillchar(f,sizeof(f),false);\n ans:=0;\n // fillchar(a,sizeof(a),0);\n readln(p[1],m[1],t[1]); //a[p[1],0]:=1;\n readln(p[2],m[2],t[2]); //a[p[2],0]:=2;\n readln(p[3],m[3],t[3]); //a[p[3],0]:=3;\n for i:=1 to 3 do begin\n c[i]:=0;\n s[i]:=7;\n end;\n\n\n ans:=0;\n dd;\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "var x,l,r:array[1..3]of longint;\n p:array[1..6]of boolean;\n i,j,k,n,ans:longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then max:=x else max:=y;\nend;\nprocedure gc;\nvar i,o,j,k:longint;\n xx:array[1..3]of longint;\n pp:boolean;\nbegin\n ans:=max(ans,max(x[1],max(x[2],x[3])));\n for i:=1 to 3 do xx[i]:=x[i];\n for o:=1 to 3 do if not(p[o]) then\n for i:=-l[o] to l[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n pp:=false;if i=l[o] then pp:=true;\n for j:=1 to 3 do\n begin\n if abs(x[o]+i-x[j])=1 then pp:=true;\n if (abs(x[o]+i-x[j]-l[j])=1)and(not(p[j])) then pp:=true;\n end;\n end;\n if pp then\n begin\n x[o]:=x[o]+i;p[o]:=true;gc;p[o]:=false;x[o]:=xx[o];\n end;\n end;\n for o:=1 to 3 do if not(p[o+3]) then\n for k:=1 to 3 do if abs(x[o]-x[k])=1 then\n for i:=-r[o] to r[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n pp:=false;if i=r[o] then pp:=true;\n for j:=1 to 3 do\n begin\n if abs(x[o]+i-x[j])=1 then pp:=true;\n if (abs(x[o]+i-x[j]-l[j])=1)and(not(p[j])) then pp:=true;\n end;\n end;\n if pp then\n begin\n x[k]:=x[o]+i;p[o+3]:=true;gc;p[o+3]:=false;x[k]:=xx[k];\n end;\n end;\nend;\nbegin\n read(x[1],l[1],r[1],x[2],l[2],r[2],x[3],l[3],r[3]);\n ans:=max(max(x[1],x[2]),x[3]);\n gc;\n for i:=1 to 3 do for j:=1 to 3 do for k:=1 to 3 do\n if (i*j*k=6)and(i+j+k=6) then for n:=1 to 20 do\n begin\n if x[k]=n then\n begin\n if (abs(x[j]-(n-1))<=l[j])and(abs(x[i]-(n-2))<=l[i]) then\n ans:=max(ans,n-2+r[i]+r[j]+l[k]);\n end else\n if (abs(x[j]-(n-1))<=l[j])and(abs(x[i]-(n-2))<=l[i])and(abs(x[k]-n)<=l[k]) then\n ans:=max(ans,n-2+r[i]+r[j]);\n if x[k]=n then\n begin\n if (abs(x[j]-(n+1))<=l[j])and(abs(x[i]-(n+2))<=l[i]) then\n ans:=max(ans,n+2+r[i]+r[j]+l[k]);\n end else\n if (abs(x[j]-(n+1))<=l[j])and(abs(x[i]-(n+2))<=l[i])and(abs(x[k]-n)<=l[k]) then\n ans:=max(ans,n+2+r[i]+r[j]);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var x,l,r:array[1..3]of longint;\n p:array[1..6]of boolean;\n i,j,k,n,ans:longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then max:=x else max:=y;\nend;\nprocedure gc;\nvar i,o,j,k:longint;\n xx:array[1..3]of longint;\n pp:boolean;\nbegin\n ans:=max(ans,max(x[1],max(x[2],x[3])));\n for i:=1 to 3 do xx[i]:=x[i];\n for o:=1 to 3 do if not(p[o]) then\n for i:=-l[o] to l[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n x[o]:=x[o]+i;p[o]:=true;gc;p[o]:=false;x[o]:=xx[o];\n end;\n end;\n for o:=1 to 3 do if not(p[o+3]) then\n for k:=1 to 3 do if abs(x[o]-x[k])=1 then\n for i:=-r[o] to r[o] do\n begin\n pp:=true;for j:=1 to 3 do if i+x[o]=x[j] then pp:=false;\n if pp then\n begin\n x[k]:=x[o]+i;p[o+3]:=true;gc;p[o+3]:=false;x[k]:=xx[k];\n end;\n end;\nend;\nbegin\n read(x[1],l[1],r[1],x[2],l[2],r[2],x[3],l[3],r[3]);\n ans:=max(max(x[1],x[2]),x[3]);\n gc;\n for i:=1 to 3 do for j:=1 to 3 do for k:=1 to 3 do\n if (i*j*k=6)and(i+j+k=6) then for n:=1 to 20 do\n if x[k]=n then\n begin\n if (abs(x[j]-(n-1))<=l[j])and(abs(x[i]-(n-2))<=l[i]) then\n ans:=max(ans,n-2+r[i]+r[j]+l[k]);\n end else\n if (abs(x[j]-(n-1))<=l[j])and(abs(x[i]-(n-2))<=l[i])and(abs(x[k]-n)<=l[k]) then\n ans:=max(ans,n-2+r[i]+r[j]);\n writeln(ans);\nend."}, {"source_code": "Type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n ans,i,j,k:longint;\n \nprocedure dfs;\n var\n i,j,k:longint;\n ori:Tman;\n begin\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then if not man[j].threw then inc(k,man[j].throw_range);\n if k>ans then break;\n end;\n \n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=-man[i].move_range to man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if man[j].pos=man[i].pos+k then continue;\n \n ori:=man[i];\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i]:=ori;\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=-man[i].throw_range to man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \nend."}, {"source_code": "Type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n ans,i,j,k:longint;\n \nprocedure dfs;\n var\n i,j,k,ii:longint;\n ori:Tman;\n begin\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then if not man[j].threw then inc(k,man[j].throw_range+3);\n if k>ans then break;\n end;\n \n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=-man[i].move_range to man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n \n ori:=man[i];\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i]:=ori;\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=-man[i].throw_range to man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)or(man[ii].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \nend."}, {"source_code": "Type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n ans,i,j,k:longint;\n online:longint;\n \nprocedure dfs;\n var\n i,j,k,ii:longint;\n ori:Tman;\n begin\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then {if not man[j].threw then} inc(k,man[j].throw_range);\n if k>ans then break;\n end;\n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i].moved:=false;\n dec(man[i].pos, k);\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)and(ii<>j)or(man[ii].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n online:=1;\n \n if online=0 then begin\n assign(input,'E.in'); reset(input);\n assign(output,'E.out'); rewrite(output); end;\n \n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \n if online=0 then begin\n close(input);\n close(output); end;\nend."}, {"source_code": "type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n tot,ans,i,j,k:longint;\n online:longint;\n ht:array[0..5000000] of longint;\n v:array[0..21000000] of record next,h:longint; end;\n \nfunction get(var man:Tman; i:longint):longint;\n var\n x,y:longint;\n begin\n with man do\n begin\n y:=pos-1;\n if moved then y:=y+42*1;\n if threw then\n begin\n if man.up=-1\n then y:=y+3*42*2 else\n begin\n if man.up>i\n then x:=man.up-1\n else x:=man.up;\n y:=y+x*3*42*2;\n end;\n end;\n end;\n get:=y;\n end;\n \nprocedure dfs;\n var\n hash,i,j,k,ii:longint;\n ori:Tman;\n begin\n \n hash:=0;\n for i:=1 to 3 do\n hash:=(hash*8*43+get(man[i],i));\n \n k:=ht[hash mod 5000000+1];\n while k<>0 do\n begin\n if v[k].h=hash then break;\n k:=v[k].next;\n end;\n \n if v[k].h=hash then exit;\n \n inc(tot); v[tot].next:=ht[hash mod 5000000+1]; v[tot].h:=hash; ht[hash mod 5000000+1]:=tot;\n \n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then {if not man[j].threw then} inc(k,man[j].throw_range);\n if k>ans then break;\n end;\n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i].moved:=false;\n dec(man[i].pos, k);\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)and(ii<>j)or(man[ii].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n online:=1;\n \n if online=0 then begin\n assign(input,'E.in'); reset(input);\n assign(output,'E.out'); rewrite(output); end;\n \n TOT:=0;\n fillchar(ht,sizeof(ht),0);\n \n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \n if online=0 then begin\n close(input);\n close(output); end;\nend."}, {"source_code": "Type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n ans,i,j,k:longint;\n \nprocedure dfs;\n var\n i,j,k,ii:longint;\n ori:Tman;\n begin\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then if not man[j].threw then inc(k,man[j].throw_range+1);\n if k>ans then break;\n end;\n \n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=-man[i].move_range to man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n \n ori:=man[i];\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i]:=ori;\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=-man[i].throw_range to man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)or(man[ii].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \nend."}, {"source_code": "Type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n \n Tarr=array[0..3] of Tman;\n \nvar\n man:Tarr;\n ans,i,j,k:longint;\n \nprocedure dfs;\n var\n i,j,k,ii:longint;\n ori:Tman;\n begin\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n\n for i:=1 to 3 do\n begin\n k:=man[i].pos;\n if man[i].moved=false then inc(k,man[i].move_range);\n for j:=1 to 3 do if i<>j then if not man[j].threw then inc(k,man[j].throw_range);\n if k>ans then break;\n end;\n \n if k<=ans then exit;\n \n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n \n ori:=man[i];\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i]:=ori;\n end;\n end;\n\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n \n dfs;\n \n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n \n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n \n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)or(man[ii].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n \n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\n\nbegin\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n \n ans:=-1;\n \n dfs;\n \n writeln(ans);\n \nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,O-,S+}\n const\n mo=5000000;\n type\n Tman=record\n move_range,throw_range,pos:longint;\n moved,threw:boolean;\n up,down:longint;\n end;\n\n Tarr=array[0..3] of Tman;\n var\n man:Tarr;\n tot,ans,i,j,k,time:longint;\n online:longint;\n ht:array[0..mo] of longint;\n v:array[0..21000000] of record next,h:longint; end;\n function get(var man:Tman; i:longint):longint;\n var\n x,y:longint;\n begin\n with man do\n begin\n y:=pos-1;\n if moved then y:=y+42*1;\n if threw then\n begin\n if man.up=-1\n then y:=y+3*42*2 else\n begin\n if man.up>i\n then x:=man.up-1\n else x:=man.up;\n y:=y+x*42*2;\n end;\n end;\n end;\n get:=y;\n end;\n procedure dfs;\n var\n hash,i,j,k,ii:longint;\n begin\n inc(time);\n hash:=0;\n for i:=1 to 3 do\n hash:=(hash*8*42+get(man[i],i));\n k:=ht[(hash mod mo)+1];\n while k<>0 do\n begin\n if v[k].h=hash then break;\n k:=v[k].next;\n end;\n if v[k].h=hash then exit;\n inc(tot); v[tot].next:=ht[hash mod mo+1]; v[tot].h:=hash; ht[hash mod mo+1]:=tot;\n for i:=1 to 3 do\n if man[i].pos>ans\n then ans:=man[i].pos;\n for i:=1 to 3 do\n if not man[i].moved and (man[i].up=-1) and (man[i].down=-1) then\n begin\n for k:=man[i].move_range downto -man[i].move_range do\n if k<>0 then\n begin\n for j:=1 to 3 do\n if man[j].pos=man[i].pos+k then break;\n if (man[j].pos=man[i].pos+k)or(man[i].pos+k<=0) then continue;\n man[i].moved:=true;\n inc(man[i].pos, k);\n dfs;\n man[i].moved:=false;\n dec(man[i].pos, k);\n end;\n end;\n for i:=1 to 3 do\n if not man[i].threw and (man[i].down=-1) then\n begin\n for j:=1 to 3 do\n if (abs(man[i].pos-man[j].pos)=1) and (man[j].down=-1) then\n begin\n man[i].up:=j;\n man[j].down:=i;\n k:=man[j].pos;\n man[j].pos:=man[i].pos;\n man[i].threw:=true;\n dfs;\n man[j].pos:=k;\n man[i].threw:=false;\n man[i].up:=-1;\n man[j].down:=-1;\n end;\n end;\n for i:=1 to 3 do\n if (man[i].up<>-1) and (man[i].down=-1) then\n begin\n j:=man[i].up;\n man[i].up:=-1;\n man[j].down:=-1;\n for k:=man[i].throw_range downto -man[i].throw_range do\n if k<>0 then\n begin\n man[j].pos:=man[j].pos+k;\n for ii:=1 to 3 do\n if ii<>j then\n if man[ii].pos=man[j].pos then break;\n if (man[ii].pos=man[j].pos)and(ii<>j)or(man[j].pos<1) then\n begin\n man[j].pos:=man[i].pos;\n continue;\n end;\n dfs;\n man[j].pos:=man[i].pos;\n end;\n man[i].up:=j;\n man[j].down:=i;\n end;\n end;\nbegin\n TOT:=0;\n fillchar(ht,sizeof(ht),0);\n for i:=1 to 3 do\n begin\n with man[i] do\n begin\n readln(pos, move_range, throw_range);\n moved:=false;\n threw:=false;\n up:=-1;\n down:=-1;\n end;\n end;\n ans:=-1;\n dfs;\n writeln(ans);\nend.\n"}], "src_uid": "a14739b86d1fd62a030226263cdc1afc"} {"source_code": "const fi='';\n fo='';\n base=trunc(1e9)+7;\n MaxN=5010;\nvar s1,s2:ansistring;\n n,m,i,j:longint;\n f:array[0..MaxN] of longint;\n res:int64;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(s1);\n n:=length(s1);\n readln(s2);\n m:=length(s2);\n for i:=1 to m do\n for j:=n downto 1 do\n if s2[i] = s1[j] then\n f[j]:=(f[j-1] + f[j] + 1) mod base;\n res:=0;\n for i:=1 to n do\n res:=(res + f[i]) mod base;\n writeln(res);\nend.\n", "positive_code": [{"source_code": "Var s,t:string;\ndp:array [1..5000,1..5000] of longint;\nc,rez,I,j:LongInt;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(s);\n readln(t);\n rez:=0;\n for j:=1 to Length(s) do\n begin\n c:=0;\n for i:=1 to Length(t) do\n begin\n if s[j]=t[i]\n then begin\n dp[i,j]:=1;\n dp[i,j]:=(dp[i,j]+c) mod 1000000007;\n rez:=(rez+dp[i,j]) mod 1000000007;\n end;\n if (j-1<>0)and(s[j-1]=t[i])\n then c:=(c+dp[i,j-1]) mod 1000000007;\n end;\n end;\n writeln(rez);\nend."}, {"source_code": "const\n modulo = trunc(1e9) + 7;\n\ntype\n int64 = longint;\n\nvar\n f:array[0..5050,0..5050] of int64;\n r:array[0..5050] of int64;\n i,j,n,m:longint;\n ans:int64;\n s,t:ansistring;\n \nBegin\n readln(s);\n readln(t);\n n:=length(s);\n m:=length(t);\n for i:=1 to n do\n for j:=1 to m do\n if s[i] = t[j] then\n f[i][j]:=1;\n fillchar(r,sizeof(r),0);\n for i:=1 to n do\n begin\n for j:=1 to m do\n if s[i] = t[j] then\n f[i][j]:=(f[i][j] + r[j-1]) mod modulo;\n r[0]:=0;\n for j:=1 to m do\n r[j]:=(r[j-1] + f[i][j]) mod modulo;\n end;\n ans:=0;\n for i:=1 to n do\n for j:=1 to m do\n ans:=(ans + f[i][j]) mod modulo;\n writeln(ans);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n f:Array[1..5000,1..5000] of Integer;\n s,t:String;\n n,m,i,j,ans:Integer;\nBegin\n ReadLn(s);\n Read(t);\n n:=length(s);\n m:=length(t);\n For i:=1 To n Do\n If s[i]=t[1] Then f[i,1]:=1\n Else f[i,1]:=0;\n For i:=2 To m Do\n If s[1]=t[i] Then f[1,i]:=f[1,i-1]+1\n Else f[1,i]:=f[1,i-1];\n For i:=2 To n Do\n For j:=2 To m Do Begin\n f[i,j]:=f[i,j-1];\n If s[i]=t[j] Then f[i,j]:=(f[i,j]+f[i-1,j-1]+1) mod 1000000007;\n End;\n ans:=0;\n For i:=1 To n Do ans:=(ans+f[i,m]) mod 1000000007;\n Write(ans);\nEnd."}, {"source_code": "{$R-,S-,Q-,I-,O+}\nconst md = round(1e9+7);\nvar\n a,b: ansistring;\n f,s: array [0..5010] of longint;\n ans,n,m,i,j: longint;\nbegin\n readln(a);\n readln(b);\n n:=length(a);\n m:=length(b);\n for j:=0 to m do s[j]:=1;\n ans:=0;\n for i:=1 to n do\n begin\n f[0]:=1;\n for j:=1 to m do\n if a[i] <> b[j] then f[j]:=0\n else f[j]:=s[j-1];\n s[0]:=1;\n for j:=1 to m do\n begin\n s[j]:=s[j-1]+f[j];\n if s[j] >= md then dec(s[j],md);\n end;\n ans:=ans+s[m];\n if ans >= md then dec(ans,md);\n end;\n writeln((ans+md-n) mod md);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $01000000}\n{$APPTYPE CONSOLE}\n\nuses SysUtils, Math;\nconst P = 1000000007;\n\nvar n, m: integer;\ns1, s2: string;\nans: int64;\ndp: array [0..5000, 0..5000] of int64;\n\nprocedure r1;\nbegin\n readln(s1);\n readln(s2);\n n := length(s1);\n m := length(s2);\nend;\n\nprocedure ex1;\nvar i, j: integer;\nbegin\n ans := 0;\n fillchar(dp, sizeof(dp), 0);\n if s1[1] = s2[1] then\n dp[1, 1] := 1\n else\n dp[1, 1] := 0;\n for i := 1 to n do\n for j := 1 to m do\n if (i <> 1) or (j <> 1) then\n if s1[i] <> s2[j] then\n dp[i, j] := dp[i, j - 1]\n else\n dp[i, j] := (dp[i - 1][j - 1] + dp[i][j - 1] + 1) mod P;\n for i := 1 to n do\n ans := (ans + dp[i][m]) mod P;\n write(ans);\nend;\n\nbegin\n //reset(input, '1.in');\n //rewrite(output, '1.out');\n r1;\n ex1;\nend.\n"}, {"source_code": "const modd: longint = 1000000007;\n\nvar s,w: string; // ansi\n ans,i,n,m,j: longint;\n f: array[0..5001,0..5001]of longint;\n\nbegin\n readln(s);\n readln(w);\n\n n:=length(s);\n m:=length(w);\n\n fillchar(f,sizeof(f),0);\n for i:=1 to n do\n for j:=1 to m do\n f[i,j]:=(f[i,j-1]+(longint(s[i]=w[j])*(f[i-1,j-1]+1))) mod modd;\n\n ans:=0;\n for i:=1 to n do ans:=(ans+f[i,m]) mod modd;\n\n writeln(ans);\nend."}, {"source_code": "Var s,t:string;\ndp:array [1..5000,1..5000] of longint;\nc,rez,I,j:LongInt;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(s);\n readln(t);\n rez:=0;\n for j:=1 to Length(s) do\n begin\n c:=0;\n for i:=1 to Length(t) do\n begin\n if s[j]=t[i]\n then begin\n dp[i,j]:=1;\n dp[i,j]:=(dp[i,j]+c) mod 1000000007;\n rez:=(rez+dp[i,j]) mod 1000000007;\n end;\n if (j-1<>0)and(s[j-1]=t[i])\n then c:=(c+dp[i,j-1]) mod 1000000007;\n end;\n end;\n writeln(rez);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n f : array [0.. 5000, 0.. 5000] of integer;\n s, t : string;\n k : Char;\n i, j, ans : Integer;\n alph : array ['a'.. 'z'] of integer;\n \nbegin\n //Reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(s);\n readln(t);\n\n for k := 'a' to 'z' do\n alph[k] := 0;\n \n\n for i := 0 to length(s) do\n for j := 0 to length(t) do\n f[i, j] := 0;\n\n for j := 1 to Length(t) do\n if s[1] = t[j] then\n f[1, j] := f[1, j - 1] + 1\n else\n f[1, j] := f[1, j - 1];\n\n for i := 1 to length(s) do\n if s[i] = t[1] then\n f[i, 1] := 1\n else\n f[i, 1] := 0;\n\n \n for i := 2 to length(s) do begin\n alph[t[1]] := 1;\n for j := 2 to length(t) do begin\n f[i, j] := (f[i, j] + f[i, alph[s[i]]]) mod 1000000007;\n if s[i] = t[j] then\n F[i, j] :=(f[i, j] + f[i - 1, j - 1] + 1) mod 1000000007;\n alph[t[j]] := j;\n end;\n for k := 'a' to 'z' do\n alph[k] := 0;\n end;\n\n \n ans := 0;\n for i := 1 to Length(s) do\n ans := (ans + f[i, length(t)]) mod 1000000007;\n write(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, t : string;\n i, j : integer;\n ans, n, k, p, ls, lt, sum, cc : int64;\n d, dd : array[0..100100] of integer;\n\n\nbegin\nreadln(s);\nls := length(s);\nreadln(t);\nlt := length(t);\nans := 0;\nfor i:=1 to ls do\n begin\n cc := 0;\n sum := 1;\n for j:=0 to lt do\n dd[j] := 0;\n dd[0] := 1;\n for j:=1 to lt do\n begin\n if t[j] = s[i] then\n begin\n dd[j] := sum;\n cc := cc + dd[j];\n end;\n sum := (sum + d[j]) mod 1000000007;\n d[j] := dd[j] mod 1000000007\n end;\n //for j:=0 to lt do\n // d[j] := dd[j];\n //for j:=1 to lt do\n ans := (ans + cc) mod 1000000007;\n end;\nwrite(ans);\nreadln; readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst md = round(1e9) + 7;\n\nvar s1,s2 : string;\n i,j,ans : longint;\n dp : array[0..5555, 0..5555] of longint;\n\nbegin\n readln(s1);\n readln(s2);\n fillchar(dp,sizeof(dp),0);\n ans := 0;\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i] = s2[j] then begin\n dp[i,j] := (dp[i,j] + dp[i-1,j-1] + 1) mod md;\n end;\n ans := (ans + dp[i,j]) mod md;\n dp[i,j] := (dp[i,j] + dp[i,j-1]) mod md;\n end;\n end;\n\n writeln(ans);\n readln;\nend.\n"}, {"source_code": "{$r-,q-,s-,o+}\n{$IFNDEF ONLINE_JUDGE}\n{$o-,r+,q+,s-}\n{$ENDIF}\n{$M 16777216}\nprogram task1;\n\nuses\n SysUtils,\n Math;\n \nconst pr=1000000007;\n\ntype mass=array['a'..'z'] of integer;\n\nvar s,t:string;\n a:array[1..5010,1..5010] of Int64;\n m,n:integer;all:Int64;\n\nprocedure solve;\nvar i,j:Integer;\nbegin\n all:=0;\n for i:=m downto 1 do\n for j:=n downto 1 do\n if s[i]<>t[j] then a[i,j]:=a[i,j+1]\n else a[i,j]:=(a[i,j+1]+a[i+1,j+1]+1) mod pr;\n for i:=1 to m do\n all:=(all+a[i,1]) mod pr; \n writeln(all); \nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');reset(input);\n assign(output, 'output.txt');rewrite(output);\n {$ENDIF}\n readln(s);m:=Length(s);\n readln(t);n:=length(t);\n solve;\nend."}, {"source_code": "Const\n fin = '';\n fon = '';\nVar\n S1 , S2 : Ansistring;\n f : array[0..1000000] of Longint;\n dem : Int64;\nProcedure Start;\n Begin\n Assign (input , fin);\n Reset (input);\n Assign (output , fon);\n Rewrite (output);\n End;\nProcedure Programe;\n Var i , j : Longint;\n Begin\n Readln (S1);\n Readln (S2);\n for i := 1 to Length (S2) do\n for j := Length (S1) downto 1 do\n if S1[j] = S2[i] then\n f[j] := (f[j-1] + f[j] + 1) Mod 1000000007;\n dem := 0;\n for i := 1 to Length (S1) do\n dem := (dem + f[i]) Mod 1000000007;\n writeln (dem);\n End;\nProcedure Finish;\n Begin\n Close (input);\n Close (output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd."}, {"source_code": "program cf163aaaaa;\nconst mo=1000000007;\nvar\n s1,s2:ansistring;\n n,i,j:longint;\n ans:int64;\n f:array[0..5000,0..5000]of int64;\nbegin\n readln(s1);\n readln(s2);\n ans:=0;\n // for i:=1 to length(s1) do f[i,0]:=1;\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i]=s2[j] then f[i,j]:=(f[i,j]+f[i-1,j-1]+1)mod mo;\n\n ans:=(ans+f[i,j])mod mo;\n f[i,j]:=f[i,j-1]+f[i,j];\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program cf163a;\nconst mo=1000000007;\nvar\n s1,s2:ansistring;\n n,i,j:longint;\n ans:int64;\n f:array[0..5000,0..5000]of int64;\nbegin\n readln(s1);\n readln(s2);\n ans:=0;\n // for i:=1 to length(s1) do f[i,0]:=1;\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i]=s2[j] then f[i,j]:=(f[i,j]+f[i-1,j-1]+1)mod mo;\n\n ans:=(ans+f[i,j])mod mo;\n f[i,j]:=f[i,j-1]+f[i,j];\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n n,m,i,j,k,t:Longint;\n a,b:array[0..5000]of char;\n f:array[0..5000,0..5000]of longint;\nbegin\n while not eoln do begin inc(n); read(a[n]) end; readln;\n while not eoln do begin inc(m); read(b[m]) end;\n for i:=0 to m do f[0,i]:=1;\n for i:=1 to n do begin\n f[i,0]:=1;\n for j:=1 to m do begin\n if a[i]=b[j] then f[i,j]:=f[i-1,j-1];\n f[i,j]:=(f[i,j-1]+f[i,j]) mod 1000000007;\n end;\n end;\n j:=0;\n for i:=1 to n do j:=(j+f[i,m]-1) mod 1000000007;\n writeln((j+1000000007) mod 1000000007);\nend."}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5005;\n base= 1000000007;\n\nvar\n i, j, m, n: integer;\n res: int64;\n f: array[0.. maxN, 0.. maxN] of int64;\n s, t: ansistring;\n\nbegin\n// assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ int64(1)) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n writeln(res);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n x=1000000007;\n maxn=5005;\nvar tx,ty:string;\n f:text;\n s:array[0..maxn,0..maxn] of longint;\n n,m,kq:longint;\nprocedure nhap;\nbegin\n assign(f,fi);reset(f);readln(f,tx);\n readln(f,ty);\n close(f);\nend;\nprocedure xuly;\nvar i,j:longint;\nbegin\n n:=length(tx);\n m:=length(ty);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n s[i,j]:=s[i,j-1];\n if tx[i]=ty[j] then inc(s[i,j],s[i-1,j-1]+1);\n s[i,j]:=s[i,j] mod x;\n end;\n inc(kq,s[i,m]);\n kq:=kq mod x;\n end;\nend;\nprocedure xuat;\n//var i,j:longint;\nbegin\n assign(f,fo);rewrite(f);writeln(f,kq);\n {for i:=1 to n do\n begin\n for j:=1 to m do write(f,s[i,j],' ');\n writeln(f);\n end;}\n close(f);\nend;\nbegin\n nhap;\n xuly;\n xuat;\nend.\n"}, {"source_code": "var fi,fo:text;\n a,b:ansiString;\n n,m,i,j,t,tt:longint;\n g:array[0..1,0..5010] of int64;\n f,res:int64;\n\nfunction mmod(x:int64):int64; begin exit(x mod 1000000007); end;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,a); n:=length(a);\n readln(fi,b); m:=length(b);\n res:=0;\n t:=0;\n fillchar(g, sizeof(g), 0);\n for i:=1 to n do begin\n tt:=t;\n t:=(t+1) mod 2;\n for j:=1 to m do begin\n if a[i] = b[j] then begin\n f:=1;\n if (i > 1) and (j > 1) then f:=mmod(f+g[tt][j-1]);\n res:=mmod(res+f);\n end\n else f:=0;\n g[t][j]:=mmod(g[t][j-1]+f);\n end;\n end;\n writeln(fo,res);\n close(fo);\n close(fi);\nend.\n"}, {"source_code": "program A163;\nConst md=round(1e9)+7;\nVar s1,s2:ansistring;\na:array[0..5000,0..5000] of longint;\ni,j:integer;\nres:int64;\nBegin\nreadln(s1);\nreadln(s2);\nFor i:=0 to length(s1) do a[0,i]:=0;\nfor j:=1 to length(s2) do a[j,0]:=0;\nres:=0;\nFor i:=1 to length(s1) do\nFor j:=1 to length(s2) do\nBegin\na[i,j]:=a[i,j-1];\nIf s1[i]=s2[j] then a[i,j]:=(a[i,j]+a[i-1,j-1]+1) mod md;\nEnd;\nFor i:=1 to length(s1) do res:=(res+a[i,length(s2)]) mod md;\nwrite(res);\nEnd.\n"}, {"source_code": "const\n \n d = 1000000007;\n var\n c,i,j,n,m,res:longint;\n f: array[0..5005,0..5005] of longint;\n s,t: ansistring;\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n readln(s); n:= length(s);\n readln(t); m:= length(t);\n res:=0;\n for i:= 1 to n do\n for j:= 1 to m do\n if s[i] = t[j] then f[i,j]:= 1;\n for i:= 1 to n do \n for j:= 1 to m do\n begin\n f[i][j+1]:= (f[i][j]+ f[i][j+1] ) mod d;\n if f[i+1][j+1] = 1 then f[i+1][j+1] := (f[i+1][j+1] + f[i][j]) mod d;\n end; \n for i:= 1 to n do res:= (res + f[i,m]) mod d;\n writeln(res);\n \n \nend. \n ;\n var\n c,i,j,n,m,res:longint;\n f: array[0..5000,0..5000] of longint;\n s,t: ansistring;\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n readln(s); n:= length(s);\n readln(t); m:= length(t);\n res:=0;\n for i:= 1 to n do\n for j:= 1 to m do\n if s[i] = t[j] then f[i,j]:= 1;\n for i:= 1 to n do \n for j:= 1 to m do\n begin\n f[i][j+1]:= (f[i][j]+ f[i][j+1] ) mod d;\n if f[i+1][j+1] = 1 then f[i+1][j+1] := (f[i+1][j+1] + f[i][j]) mod d;\n end; \n for i:= 1 to n do res:= (res + f[i,m]) mod d;\n writeln(res);\n \n \nend. \n \n var\n c,i,j,n,m,res:longint;\n f: array[0..5005,0..5005] of longint;\n s,t: ansistring;\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n readln(s); n:= length(s);\n readln(t); m:= length(t);\n res:=0;\n for i:= 1 to n do\n for j:= 1 to m do\n if s[i] = t[j] then f[i,j]:= 1;\n for i:= 1 to n do \n for j:= 1 to m do\n begin\n f[i][j+1]:= (f[i][j]+ f[i][j+1] ) mod d;\n if f[i+1][j+1] = 1 then f[i+1][j+1] := (f[i+1][j+1] + f[i][j]) mod d;\n end; \n for i:= 1 to n do res:= (res + f[i,m]) mod d;\n writeln(res);\n \n \nend. \n "}, {"source_code": "const md = 1000000007;\n\nvar s,w:ansistring;\nans,i,j,n,m:longint;\ndp:array[0..5000,0..5000]of longint;\nq:array[0..5000,0..5000]of longint;\nlast:array[char]of longint;\n begin\n readln(s);\n readln(w);\n n:=length(s);\n m:=length(w);\n for i:=1 to n do\n begin\n fillchar(last,sizeof(last),0);\n for j:=1 to m do\n begin\n if s[i]=w[j] then\n begin\n dp[i,j]:=1;\n dp[i,j]:=(dp[i,j]+q[i-1,j-1])mod md;\n ans:=(ans+dp[i,j])mod md;\n end;\n last[w[j]]:=j;\n end;\n for j:=1 to m do\n q[i,j]:=(q[i,j-1]+dp[i,j])mod md;\n end;\n writeln(ans);\n end."}, {"source_code": "uses math;\nvar j,i: longint;\nans, base: int64;\nf: array [1..5010, 1..5010] of int64;\ns,t: ansistring;\nbegin\n//assign (input, 'input.txt'); reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s); readln (t);\nbase:= 1000000007;\nfor i:= length (s) downto 1 do\nfor j:= length (t) downto 1 do\n begin\n f[i,j]:= f[i,j+1];\n if s[i]=t[j] then\n f[i,j]:= f[i,j]+ f[i+1, j+1]+1;\n f[i,j]:= f[i,j] mod base;\n end;\nfor i:= 1 to length (s) do\nbegin\n ans:= ans + f[i,1]; ans:= ans mod base; end;\n writeln (ans);\nend.\n\n"}, {"source_code": "const maxn=5010;\n mo=1000000007;\nvar n,m,i,j,ans:longint;\n s,t:array[1..maxn]of char;\n f:array[1..maxn,1..maxn]of longint;\n//=============================================================\nbegin\n repeat\n inc(n);read(s[n]);\n until eoln;\n readln;\n repeat\n inc(m);read(t[m]);\n until eoln;\n for i:=n downto 1 do\n begin\n for j:=m downto 1 do\n if s[i]=t[j] then f[i,j]:=(f[i+1,j+1]+f[i,j+1]+1)mod mo\n else f[i,j]:=f[i,j+1];\n end;\n for i:=1 to n do ans:=(ans+f[i,1])mod mo;\n writeln(ans);\nend.\n"}, {"source_code": "const\n\tmodulo = trunc(1e9) + 7;\n\ntype\n\tint64 = longint;\n\nvar\n\tf:array[0..5050,0..5050] of int64;\n\tr:array[0..5050] of int64;\n\ti,j,n,m:longint;\n\tans:int64;\n\ts,t:ansistring;\n\t\nBegin\n\treadln(s);\n\treadln(t);\n\tn:=length(s);\n\tm:=length(t);\n\tfor i:=1 to n do\n\t\tfor j:=1 to m do\n\t\t\tif s[i] = t[j] then\n\t\t\t\tf[i][j]:=1;\n\tfillchar(r,sizeof(r),0);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tfor j:=1 to m do\n\t\t\t\tif s[i] = t[j] then\n\t\t\t\t\tf[i][j]:=(f[i][j] + r[j-1]) mod modulo;\n\t\t\tr[0]:=0;\n\t\t\tfor j:=1 to m do\n\t\t\t\tr[j]:=(r[j-1] + f[i][j]) mod modulo;\n\t\tend;\n\tans:=0;\n\tfor i:=1 to n do\n\t\tfor j:=1 to m do\n\t\t\tans:=(ans + f[i][j]) mod modulo;\n\twriteln(ans);\nend.\n"}, {"source_code": "const\n\tmd = 1000000007;\n\t\nvar\n\ta, b : array [0 .. 5000] of char;\n\tn, m, i, j, atb : longint;\n\td : array [0 .. 5000, 0 .. 5000] of longint;\n\nbegin\n\twhile not eoln do begin\n\t\tinc(n);\n\t\tread(a[n]);\n\tend;\n\treadln;\n\twhile not eoln do begin\n\t\tinc(m);\n\t\tread(b[m]);\n\tend;\n\n\t\n\tfor i := 1 to n do begin\n\t\tfor j := 1 to m do begin\n\t\t\td[i, j] := d[i, j - 1];\n\t\t\tif a[i] = b[j] then d[i, j] := (d[i, j] + d[i - 1, j - 1] + 1) mod md;\n\t\t\t//write(d[i, j], ' ');\n\t\tend;\n\t\t//writeln;\n\tend;\n\t//writeln;\n\n\tfor i := 1 to n do atb := (atb + d[i, m]) mod md;\n\twriteln(atb);\n\t\nend."}, {"source_code": "const modulus = 1000000007;\nvar f:array [0..5000,0..5000] of longint;\n s,t:array [0..5000] of char;\n n,m:longint;\nprocedure solve;\nvar i,j,res:longint;\nbegin\n res := 0 ;\n for i := 1 to n do\n begin\n for j:= 1 to m do\n begin\n f[i,j] := (f[i,j] + f[i,j-1] ) mod modulus;\n if s[i] = t[j] then f[i,j] := (f[i,j] + f[i-1,j-1] + 1) mod modulus;\n end;\n end;\n for i := 1 to n do\n res := ( res + f[i,m]) mod modulus;\n writeln(res);\nend;\nbegin\n while not eoln(input) do\n begin\n inc(n); read(s[n]);\n end;\n readln;\n while not eoln(input) do\n begin\n inc(m);read(t[m]);\n end;\n solve;\nend."}, {"source_code": "const bigp=1000000007;\n\nvar s,t:ansistring;\n s1,s2:array[0..10000] of char;\n m,n,i,j,ans:longint;\n f:array[0..5005,0..5005] of longint;\n\nbegin\n readln(s);\n readln(t);\n m:=length(s);\n n:=length(t);\n for i:=1 to m do s1[i]:=s[i];\n for i:=1 to n do s2[i]:=t[i];\n fillchar(f,sizeof(f),0);\n for i:=1 to m do\n for j:=1 to n do\n if s1[i]=s2[j] then f[i,j]:=1;\n for i:=1 to m do\n for j:=1 to n do\n begin\n //writeln(i,' ',j,' ',f[i,j]);\n f[i,j+1]:=(f[i,j+1]+f[i,j]) mod bigp;\n if s1[i+1]=s2[j+1] then\n f[i+1,j+1]:=(f[i+1,j+1]+f[i,j]) mod bigp;\n end;\n ans:=0;\n for i:=1 to m do\n ans:=(ans+f[i,n]) mod bigp;\n writeln(ans);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n base=1000000007;\n\nvar\n q,next,res,n,m,i,j:longint;\n s,t:ansistring;\n f:array[0..5005,0..5005,0..1]of longint;\n\nbegin\n readln(s);\n readln(t);\n n:=length(s);\n m:=length(t);\n fillchar(F,sizeof(f),$0);\n for i:=1 to n do \n f[i][1][0]:=1;\n \n for i:=1 to n+1 do \n for j:=1 to m do for q:=0 to 1 do \n if (f[i][j][q]<>0)then begin\n if (i<=n)and(s[i]=t[j])then begin\n inc(f[i+1][j+1][1],f[i][j][q]);\n if (f[i+1][j+1][1]>=base)then dec(f[i+1][j+1][1],base);\n end;\n inc(f[i][j+1][q],f[i][j][q]);\n if (f[i][j+1][q]>=base)then dec(f[i][j+1][q],base);\n end;\n res:=0;\n for i:=1 to n+1 do begin\n inc(res,f[i][m+1][1]);\n if (res>=base)then dec(res,base);\n end;\n writeln(res);\nend.\n"}, {"source_code": "var a,b:ansistring;\n d:array[0..5010,0..5010]of longint;\n i,j,l1,l2,ans:longint;\nbegin\n readln(a);\n readln(b);\n l1:=length(a);\n l2:=length(b);\n for i:=1 to l1 do\n begin\n for j:=1 to l2 do\n begin\n d[i,j]:=d[i,j-1];\n if a[i]=b[j] then\n d[i,j]:=(d[i,j]+d[i-1,j-1]+1)mod 1000000007;\n end;\n ans:=(ans+d[i,l2])mod 1000000007;\n end;\n writeln(ans);\nend."}, {"source_code": "const maxn = 5000;\ncmod=1000000007;\nvar f1,f2:text;\nF:array[0..maxn,0..maxn] of longint;\nn,m:longint;\nres:longint;\ns1,s2:ansistring;\n\nProcedure process;\nvar i,j:longint;\nbegin\n n:=length(s1); m:=length(s2) ;\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then F[i,j]:=1;\n\n For i:=1 to n do\n for j:=1 to m do\n begin\n if (i= 1000000007 do dec(x, 1000000007);\n mo := x;\nend;\n\nbegin\n readln(s);\n readln(t);\n for i := length(s) downto 1 do\n for j := length(t) downto 1 do\n if s[i] = t[j]\n then mx[i, j] := mo(1 + mx[i+1, j+1] + mx[i, j+1])\n else mx[i, j] := mx[i, j+1];\n for i := 1 to length(s) do r := mo(r + mx[i, 1]);\n writeln(r);\nend."}, {"source_code": "{$mode objfpc}\nconst Pm=1000000007;\nvar\ns,t:array[0..5010] of char;\ncount:array[0..5010] of longint;\nss:ansistring;\n\nprocedure lemon();\nvar n,m,i,j,ans:longint;\nbegin readln(ss);\n\tn:=length(ss); for i:=1 to n do s[i]:=ss[i];\n\treadln(ss);\n\tm:=length(ss); for i:=1 to m do t[i]:=ss[i];\n\tfillchar(count,sizeof(count),0);\n ans:=0;\n\tfor i:=m downto 1 do\n\t\tfor j:=1 to n do\n\t\t\tif s[j]=t[i] then\n\t\t\tbegin inc(ans,count[j+1]+1);\n\t\t\t\tif ans>=Pm then dec(ans,Pm);\n\t\t\t\tinc(count[j],count[j+1]+1);\n\t\t\t\tif count[j]>=Pm then dec(count[j],Pm);\n\t\t\tend;\n\twriteln(ans);\nend;\t\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'A.in');\n\treset(input);\n{$endif}\nlemon();\nend.\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n base = 1000000007;\n\nVar s, t : ansistring;\n n, m : longint;\n f : array[0..5005] of qword;\n res : qword;\n\nProcedure solve;\n Var i, j : longint;\n Begin\n for i := 1 to m do\n for j := n downto 1 do\n if t[i]=s[j] then begin\n f[j] := (f[j-1]+f[j]+1)mod base;\n end;\n res := 0;\n for i := 1 to n do res := (res+f[i])mod base;\n writeln(res);\n End;\n\nBegin\n assign(input,fi); reset(input);\n readln(s); n := length(s);\n readln(t); m := length(t);\n close(input);\n /////////////\n solve;\nEnd."}, {"source_code": "Program cf163a;\nconst modif=1000000007;\nVar f:array[0..5010,0..5010] of int64;\n s,t:ansistring;\n i,j,k,l,m,n:longint;\n ans:int64;\nbegin\n readln(s);readln(t);\n for i:=0 to length(t) do f[0,i]:=1;\n for i:=1 to length(s) do f[i,0]:=1;\n for i:=1 to length(s) do\n begin\n for j:=1 to length(t) do\n begin\n f[i,j]:=f[i,j-1];\n if (s[i]=t[j]) then f[i,j]:=(f[i,j]+f[i-1,j-1]) mod modif;\n end;\n ans:=(ans+f[i,length(t)]) mod modif;\n end;\n writeln((ans-length(s)+modif) mod modif);\nend.\n"}, {"source_code": "const md=1000000007;\nVar i,j,n,m,ans:longint;\n s1,s2:ansistring;\n f:array[0..5003,0..5003]of longint;\n begin\n readln(s1);\n readln(s2);\n n:=length(s1);\n m:=length(s2);\n for i:=1 to n do\n for j:=1 to m do\n begin\n f[i,j]:=f[i,j-1];\n if s1[i]=s2[j] then\n f[i,j]:=f[i,j]+f[i-1,j-1]+1;\n if f[i,j]>=md then f[i,j]:=f[i,j]-md;\n end;\n ans:=0;\n for i:=1 to n do\n ans:=(ans+f[i,m])mod md;\n Writeln(ans);\n end.\n"}, {"source_code": "var s,t:ansistring;\n f:array[1..5001,1..5001] of int64;\n i,j,n,m:longint;\n base,answer:int64;\n begin\n readln(s);\n readln(t);\n n:=length(s);\n m:=length(t);\n base:=1000000000+7;\n for i:=n downto 1 do\n for j:=m downto 1 do\n begin\n f[i][j]:=f[i][j+1];\n if s[i]=t[j] then\n f[i][j]:=(f[i][j]+f[i+1][j+1]+1) mod base;\n end;\n for i:=1 to n do\n answer:=(answer+f[i][1]) mod base;\n writeln(answer);\n end.\n"}, {"source_code": "const\n{ fi='sub.inp';\n fo='sub.out';}\n fi='';\n fo='';\n maxn=5050;\n inf=round(1e9)+7;\n\nvar\n ff:text;\n a:array[0..maxn]of longint;\n f:array[0..maxn,0..maxn]of int64;\n n,m:longint;\n s,t:ansistring;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[l+random(r-l+1)];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(ff,fi);reset(ff);\n readln(ff,s);\n readln(ff,t);\n n:=length(s); m:=length(t);\n close(ff);\nend;\n\nprocedure main;\nvar i,j:longint;\n kq:int64;\nbegin\n kq:=0;\n for i:=1 to n do\n for j:=1 to m do\n begin\n if s[i]=t[j] then\n f[i,j]:=(f[i-1,j-1]+f[i,j-1]+1) mod inf\n else f[i,j]:=f[i,j-1];\n end;\n kq:=0;\n for i:=1 to n do\n kq:=(kq+f[i,m]) mod inf;\n\n assign(ff,fo);rewrite(ff);\n writeln(ff,kq);\n close(ff);\nend;\n\nbegin\n randomize;\n open;\n main;\nend."}, {"source_code": "program pa;\nconst\n maxn=1000000007;\nvar\n i,j,last,ls,lt,p,k,ans:longint;\n s,t:string;\n head,tail,next:array[1..5001] of longint;\n f:array[1..5001,1..5001] of longint;\nbegin\n\n readln(s);\n readln(t);\n ls:=length(s);\n lt:=length(t);\n for i:=1 to lt do\n begin\n j:=ord(t[i])-96;\n if head[j]=0 then\n head[j]:=i\n else\n next[tail[j]]:=i;\n tail[j]:=i;\n end;\n for i:=1 to lt do\n if s[1]=t[i] then\n f[1,i]:=1;\n for i:=2 to ls do\n begin\n p:=head[ord(s[i])-96];\n k:=head[ord(s[i-1])-96];\n last:=0;\n while p<>0 do\n begin\n f[i,p]:=1;\n while (k<>0)and(k0 then f[i,p]:=(f[i,p]+f[i,last]-1) mod maxn;\n last:=p;\n p:=next[p];\n end;\n end;\n for i:=1 to ls do\n for j:=1 to lt do\n ans:=(ans+f[i,j]) mod maxn;\n writeln(ans);\n\nend."}, {"source_code": "const\n md = 1000000007;\n \nvar\n a, b : array [0 .. 5000] of char;\n n, m, i, j, atb : longint;\n d : array [0 .. 5000, 0 .. 5000] of longint;\n\nbegin\n while not eoln do begin\n inc(n);\n read(a[n]);\n end;\n readln;\n while not eoln do begin\n inc(m);\n read(b[m]);\n end;\n\n \n for i := 1 to n do begin\n for j := 1 to m do begin\n d[i, j] := d[i, j - 1];\n if a[i] = b[j] then d[i, j] := (d[i, j] + d[i - 1, j - 1] + 1) mod md;\n //write(d[i, j], ' ');\n end;\n //writeln;\n end;\n //writeln;\n\n for i := 1 to n do atb := (atb + d[i, m]) mod md;\n writeln(atb);\n \nend."}, {"source_code": "VAR\n a, b, c, d, i, j, l1, l2: LONGINT;\n Res: INT64;\n M: ARRAY[0..10000] OF INT64;\n s, t: ARRAY[1..10000] OF CHAR;\nBEGIN\n WHILE NOT EOLN\n DO\n BEGIN\n l1 := l1+1;\n READ(s[l1]);\n END;\n READLN;\n WHILE NOT EOLN\n DO\n BEGIN\n l2 := l2+1;\n READ(t[l2]);\n END;\n FOR i := 1 TO l1 DO\n M[i] := 1;\n FOR i := 1 TO l2 DO\n FOR j := l1 DOWNTO 1 DO\n BEGIN\n IF s[j]=t[i]\n THEN\n BEGIN\n Res := (Res+M[j]) MOD 1000000007;\n M[j+1] := (M[j+1]+M[j]) MOD 1000000007;\n END;\n END;\n WRITELN(Res);\nEND."}, {"source_code": "{$q-}\nconst\n md=1000000007;\nvar\n i,j,k,t:longint;\n n,m:longint;\n ans:int64;\n a,b:array[1..5000] of char;\n s,d:array[0..5000,0..5000] of longint;\nbegin\n fillchar(s,sizeof(s),0);\n d:=s;\n n:=0; m:=0;\n while not eoln do begin\n inc(n);\n read(a[n]);\n end;\n readln;\n while not eoln do begin\n inc(m);\n read(b[m]);\n end;\n for i:=1 to n do\n for j:=1 to m do\n if a[i]<>b[j] then begin\n d[i,j]:=0;\n s[i,j]:=s[i,j-1];\n end\n else begin\n d[i,j]:=(1+s[i-1,j-1]) mod md;\n s[i,j]:=(s[i,j-1]+d[i,j]) mod md;\n end;\n ans:=0;\n for i:=1 to n do\n ans:=(ans+s[i,m]) mod md;\n writeln(ans);\nend."}, {"source_code": "const\nD = 1000000007;\nvar\nAns,i,j:longint;\nS1,s2:ansistring;\nF:array[0..5000,0..5000] of longint;\nBegin\nReadln(s1);\nReadln(s2);\nFor i:=1 to length(s1) do\nFor j:=1 to length(s2) do\nIf s1[i]=s2[j] then f[i,j]:=(f[i-1,j-1]+1+f[i,j-1]) mod d\nElse f[i,j]:=(f[i,j-1]) mod d;\nFor i:=1 to length(s1) do\nAns:=(ans+f[i,length(s2)]) mod d;\nWrite(ans);\nEnd."}, {"source_code": "var\nx,y,max,cc,kk,w,e,n1,n2,ans,k,qq,qqq,bb,min,st1,st2,inf,reb,ii,jj,m,c0,d0,i,j,n:longint;\nc,first,last,b:array[0..3000000] of longint;\na:array[0..5000,0..5000] of longint;\nr,rr:real;\nch:char;\nsss,ss,s,u,t:ansistring;\n\nbegin\nreadln(s);\nread(t);\nn:=length(s);\nm:=length(t);\nfor i:=1 to n do\n for j:=1 to m do\n \n if s[i]<>t[j] then a[i,j]:=a[i,j-1] \n else a[i,j]:=(a[i,j-1]+1+a[i-1,j-1])mod 1000000007;\nfor i:=1 to n do\nbegin k:=(k+a[i,m]) mod 1000000007;{for j:=1 to m do write(a[i,j], ' ');\n writeln;}end;\nwriteln(k);\n \n end."}, {"source_code": "const base=trunc(1e9)+7;\nvar\n a:array[0..5000] of longint;\n s1,s2:ansistring;\n i,j,k:longint;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s2) do\n for j:=length(s1) downto 1 do\n if s1[j]=s2[i] then\n a[j]:=(a[j-1]+a[j]+1) mod base;\n k:=0;\n for i:=1 to length(s1) do\n k:=(k+a[i]) mod base;\n writeln(k);\nend.\n"}, {"source_code": "program a;\nconst\n maxn = 5001;\n du = 1000*1000*1000 + 7;\nvar\n s1 , s2 : ansistring;\n kq : int64;\n f : array[0..maxn,0..maxn] of int64;\n{-------------------------------------------------------------------------}\nprocedure nhap;\nbegin\n readln ( s1 );\n readln ( s2 );\nend;\n{-------------------------------------------------------------------------}\nprocedure xuli;\nvar\n i , j : longint;\nbegin\n kq := 0;\n for i := 1 to length ( s1 ) do\n for j := 1 to length ( s2 ) do\n begin\n if s1[i] = s2[j] then\n f[i , j] := ( f[i , j] + f[i - 1 , j - 1] + 1) mod du;\n f[i , j] := ( f[i , j] + f[i , j - 1] ) mod du;\n end;\n for i := 1 to length ( s1 ) do\n kq := ( kq + f[i, length ( s2 )] ) mod du;\n writeln ( kq );\nend;\n{-------------------------------------------------------------------------}\nbegin\n nhap;\n xuli;\nend."}, {"source_code": "{$Q-,R-}\nconst maxn = 5010;\ncmod = 1000000007;\n\nvar f1,f2:text;\nNext:array[0..maxn,'a'..'z'] of longint;\nns,nt:longint;\nF,G:array[0..maxn,0..maxn] of longint;\nres:longint;\ns,t:ansistring;\n\nProcedure process;\nvar i,j,k:longint;\nc:char;\nbegin\n for c:='a' to 'z' do next[nt,c]:=nt+1;\n For i:=nt-1 downto 0 do\n begin\n for c:='a' to 'z' do\n Next[i,c]:=Next[i+1,c];\n next[i,t[i+1]]:=i+1;\n end;\n\n for i:=1 to ns do\n for j:=1 to nt do\n if s[i]=t[j] then\n F[i,j]:=1;\n for i:=0 to ns do\n begin\n for j:=0 to nt do\n begin\n if (i<>0) then\n G[i,next[j,s[i]]]:=(G[i,next[j,s[i]]]+G[i,j]) mod cmod;\n F[i,j]:=(F[i,j]+G[i,j]) mod cmod;\n end;\n if i<>ns then\n for j:=0 to nt do\n G[i+1,next[j,s[i+1]]]:=(G[i+1,next[j,s[i+1]]]+F[i,j]) mod cmod;\n end;\n\n for i:=1 to ns do\n for j:=1 to nt do\n res:=(res+F[i,j]) mod cmod;\n writeln(F2,res);\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,s);ns:=length(s);\n readln(f1,t);nt:=length(t);\n process;\n close(f1);\n close(F2);\nend.\n"}, {"source_code": "const modd: longint = 1000000007;\n\nvar s,w: ansistring; // ansi\n ans,i,n,m,j: longint;\n f: array[0..5001,0..5001]of longint;\n\nbegin\n readln(s);\n readln(w);\n\n n:=length(s);\n m:=length(w);\n\n fillchar(f,sizeof(f),0);\n for i:=1 to n do\n for j:=1 to m do\n f[i,j]:=(f[i,j-1]+(longint(s[i]=w[j])*(f[i-1,j-1]+1))) mod modd;\n\n ans:=0;\n for i:=1 to n do ans:=(ans+f[i,m]) mod modd;\n\n writeln(ans);\nend."}, {"source_code": "//CF VKCUP2012 Round2 Substring and Subsequence\nconst\n mo=1000000007;\n\nvar\n s,t:ansistring;\n ans,i,j,ls,lt:longint;\n f:array[0..5001,0..5001] of longint;\n\nbegin\n readln(s);readln(t);\n ls:=length(s);lt:=length(t);\n for i:=1 to lt do\n for j:=1 to ls do\n if t[i]<>s[j] then f[i][j]:=f[i-1][j] else f[i][j]:=(f[i-1][j]+f[i-1][j-1]+1) mod mo;\n ans:=0;\n for i:=1 to ls do\n ans:=(ans+f[lt][i]) mod mo;\n writeln(ans);\nend.\n\n"}, {"source_code": "const md = 1000000007;\n\nvar s,w:ansistring;\nans,i,j,n,m:longint;\ndp:array[0..5000,0..5000]of longint;\nq:array[0..5000,0..5000]of longint;\nlast:array[char]of longint;\n begin\n readln(s);\n readln(w);\n n:=length(s);\n m:=length(w);\n for i:=1 to n do\n begin\n fillchar(last,sizeof(last),0);\n for j:=1 to m do\n begin\n if s[i]=w[j] then\n begin\n dp[i,j]:=1;\n dp[i,j]:=(dp[i,j]+q[i-1,j-1])mod md;\n ans:=(ans+dp[i,j])mod md;\n end;\n last[w[j]]:=j;\n end;\n for j:=1 to m do\n q[i,j]:=(q[i,j-1]+dp[i,j])mod md;\n end;\n writeln(ans);\n end."}, {"source_code": "var s,t:ansistring;\n f:array[1..5001,1..5001] of int64;\n i,j,n,m:longint;\n base,answer:int64;\n begin\n readln(s);\n readln(t);\n n:=length(s);\n m:=length(t);\n base:=1000000000+7;\n for i:=n downto 1 do\n for j:=m downto 1 do\n begin\n f[i][j]:=f[i][j+1];\n if s[i]=t[j] then\n f[i][j]:=(f[i][j]+f[i+1][j+1]+1) mod base;\n end;\n for i:=1 to n do\n answer:=(answer+f[i][1]) mod base;\n writeln(answer);\n end.\n"}, {"source_code": "const\nD = 1000000007;\nvar\nAns,i,j:longint;\nS1,s2:ansistring;\nF:array[0..5000,0..5000] of longint;\nBegin\nReadln(s1);\nReadln(s2);\nFor i:=1 to length(s1) do\nFor j:=1 to length(s2) do\nIf s1[i]=s2[j] then f[i,j]:=(f[i-1,j-1]+1+f[i,j-1]) mod d\nElse f[i,j]:=(f[i,j-1]) mod d;\nFor i:=1 to length(s1) do\nAns:=(ans+f[i,length(s2)]) mod d;\nWrite(ans);\nEnd."}, {"source_code": "{$H+}\nconst\n fi=''; fo='';\n hs=round(1e9+7);\n NMAX=5010;\nvar\n i,j,n,m:longint;\n f:array[0..NMAX] of longint;\n a,b:string;\n ans:longint;\n ffi,ffo:text;\nbegin\n assign(ffi,fi);reset(ffi);\n assign(ffo,fo);rewrite(ffo);\n readln(ffi,a); n:=length(a);\n readln(ffi,b); m:=length(b);\n\n for i:=1 to m do\n for j:=n downto 1 do\n if a[j]=b[i] then begin\n f[j]:=(f[j]+1) mod hs;\n f[j]:=(f[j-1]+f[j]) mod hs;\n end;\n\n ans:=0;\n for i:=1 to n do ans:=(ans+f[i]) mod hs;\n write(ffo,ans);\n close(ffi); close(ffo);\nend."}, {"source_code": "const\n base=trunc(1e9)+7;\nvar\n a:array[0..5000] of longint;\n s1,s2:ansistring;\n kq:longint;\nprocedure nhap;\nbegin\n readln(s1);\n readln(s2);\nend;\nprocedure xuli;\nvar\n i,j:longint;\nbegin\n for i:=1 to length(s2) do\n for j:=length(s1) downto 1 do\n if s1[j]=s2[i] then\n begin\n inc(a[j]);\n a[j]:=a[j] mod base;\n a[j]:=(a[j-1]+a[j]) mod base;\n end;\n kq:=0;\n for i:=1 to length(s1) do\n kq:=(kq+a[i]) mod base;\n writeln(kq);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "program a;\nconst\n maxn = 5001;\n du = 1000*1000*1000 + 7;\nvar\n s1 , s2 : ansistring;\n kq : int64;\n f : array[0..maxn,0..maxn] of int64;\n{-------------------------------------------------------------------------}\nprocedure nhap;\nbegin\n readln ( s1 );\n readln ( s2 );\nend;\n{-------------------------------------------------------------------------}\nprocedure xuli;\nvar\n i , j : longint;\nbegin\n kq := 0;\n for i := 1 to length ( s1 ) do\n for j := 1 to length ( s2 ) do\n begin\n if s1[i] = s2[j] then\n f[i , j] := ( f[i , j] + f[i - 1 , j - 1] + 1) mod du;\n f[i , j] := ( f[i , j] + f[i , j - 1] ) mod du;\n end;\n for i := 1 to length ( s1 ) do\n kq := ( kq + f[i, length ( s2 )] ) mod du;\n writeln ( kq );\nend;\n{-------------------------------------------------------------------------}\nbegin\n nhap;\n xuli;\nend."}, {"source_code": "const modulo = 1000000007;\nvar n,m,i,j,k:longint;\n f:array[0..5001,0..5001] of int64;\n first,second:ansistring; \n answer:int64;\nbegin\n readln(first);\n readln(second); \n for i:= 1 to lengtH(first) do\n for j:= 1 to length(second) do \n begin\n if first[i]=second[j] then f[i,j]:=f[i,j]+f[i-1,j-1]+1;\n f[i,j]:=(f[i,j]+F[i,j-1]) mod modulo;\n end; \n answer:=0;\n for i:= 1 to length(first) do\n answer:=answer+(f[i,length(second)]) mod modulo;\n writeln(answer mod modulo);\nend.\n"}], "negative_code": [{"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n f : array [0.. 5000, 0.. 5000] of integer;\n s, t : string;\n k : Char;\n i, j, ans : Integer;\n alph : array ['a'.. 'z'] of integer;\n \nbegin\n //Reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(s);\n readln(t);\n\n for k := 'a' to 'z' do\n alph[k] := 0;\n \n\n for i := 0 to length(s) do\n for j := 0 to length(t) do\n f[i, j] := 0;\n\n for j := 1 to Length(t) do\n if s[1] = t[j] then\n f[1, j] := f[1, j - 1] + 1\n else\n f[1, j] := f[1, j - 1];\n\n for i := 1 to length(s) do\n if s[i] = t[1] then\n f[i, 1] := 1\n else\n f[i, 1] := 0;\n\n \n for i := 2 to length(s) do begin\n alph[t[1]] := 1;\n for j := 2 to length(t) do begin\n f[i, j] := f[i, j] + f[i, alph[s[i]]];\n if s[i] = t[j] then\n F[i, j] :=f[i, j] + f[i - 1, j - 1] + 1;\n alph[t[j]] := j;\n end;\n for k := 'a' to 'z' do\n alph[k] := 0;\n end;\n\n \n ans := 0;\n for i := 1 to Length(s) do\n ans := (ans + f[i, length(t)]) mod 1000000007;\n write(ans);\nend.\n"}, {"source_code": "const modd: longint = 1000000007;\n\nvar s,w: string; // ansi\n ans,i,n,m,j: longint;\n f: array[0..5001,0..5001]of longint;\n\nbegin\n readln(s);\n readln(w);\n\n n:=length(s);\n m:=length(w);\n\n fillchar(f,sizeof(f),0);\n for i:=1 to n do\n for j:=1 to m do\n f[i,j]:=(f[i,j-1]+(longint(s[i]=w[j])*(f[i-1,j-1]+1))) mod modd;\n\n ans:=0;\n for i:=1 to n do ans:=(ans+f[i,m]) mod modd;\n\n writeln(ans);\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n f:Array[1..5000,1..5000] of Integer;\n s,t:String;\n n,m,i,j,ans:Integer;\nBegin\n ReadLn(s);\n Read(t);\n n:=length(s);\n m:=length(t);\n For i:=1 To n Do\n If s[i]=t[1] Then f[i,1]:=1\n Else f[i,1]:=0;\n For i:=2 To m Do\n If s[1]=t[i] Then f[1,i]:=f[1,i-1]+1\n Else f[1,i]:=f[1,i-1];\n For i:=2 To n Do\n For j:=2 To m Do Begin\n If s[i]=t[j] Then f[i,j]:=(f[i-1,j-1]+1) mod 1000000007\n Else f[i,j]:=f[i,j-1];\n End;\n ans:=0;\n For i:=1 To n Do \n For j:=1 To m Do ans:=(ans+f[i,j]) mod 1000000007;\n Write(ans);\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, t : string;\n i, j : integer;\n ans, n, k, p, ls, lt, sum, cc : int64;\n d, dd : array[0..100100] of integer;\n\n\nbegin\nreadln(s);\nls := length(s);\nreadln(t);\nlt := length(t);\nans := 0;\nfor i:=1 to ls do\n begin\n cc := 0;\n sum := 1;\n for j:=0 to lt do\n dd[j] := 0;\n dd[0] := 1;\n for j:=1 to lt do\n begin\n if t[j] = s[i] then\n begin\n dd[j] := sum;\n cc := cc + dd[j];\n end;\n sum := sum + d[j];\n d[j] := dd[j]\n end;\n //for j:=0 to lt do\n // d[j] := dd[j];\n //for j:=1 to lt do\n ans := (ans + cc) mod 1000000007;\n end;\nwrite(ans);\nreadln; readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst md = round(1e9) + 7;\n\nvar s1,s2 : string;\n i,j,ans : longint;\n dp : array[0..5555, 0..5555] of longint;\n\nbegin\n readln(s1);\n readln(s2);\n fillchar(dp,sizeof(dp),0);\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i] = s2[j] then begin\n dp[i,j] := (dp[i,j] + dp[i-1,j-1] + 1) mod md;\n end;\n ans := (ans + dp[i,j]) mod md;\n dp[i,j] := (dp[i,j] + dp[i,j-1]) mod md;\n end;\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst md = round(1e9) + 7;\n\nvar s1,s2 : string;\n i,j,ans : longint;\n dp : array[0..5555, 0..5555] of longint;\n\nbegin\n readln(s1);\n readln(s2);\n fillchar(dp,sizeof(dp),0);\n ans := 0;\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i] = s2[j] then begin\n dp[i,j] := (dp[i,j] + dp[i-1,j-1] + 1) mod md;\n end;\n ans := (ans + dp[i,j]) mod md;\n writeln(ans);\n dp[i,j] := (dp[i,j] + dp[i,j-1]) mod md;\n end;\n end;\n\n writeln(ans);\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst md = round(1e9) + 7;\n\nvar s1,s2 : string;\n i,j,ans : longint;\n dp : array[0..1000, 0..10000] of longint;\n\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do begin\n for j:=1 to length(s2) do begin\n if s1[i] = s2[j] then begin\n dp[i,j] := (dp[i,j] + dp[i-1,j-1] + 1) mod md;\n end;\n ans := (ans + dp[i,j]) mod md;\n dp[i,j] := (dp[i,j] + dp[i,j-1]) mod md;\n end;\n end;\n\n writeln(ans);\n readln;\nend.\n"}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5000;\n base= 1000000007;\n\nvar\n i, j, m, n, res: integer;\n f: array[0.. maxN, 0.. maxN] of integer;\n g: array[0.. maxN, 'a'.. 'z'] of integer;\n s, t: string;\n\nbegin\n // assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to n do g[i, t[i]]:= g[i- 1, t[i]]+ 1;\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ 1) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5005;\n base= 1000000007;\n\nvar\n i, j, m, n: integer;\n res: int64;\n f: array[0.. maxN, 0.. maxN] of int64;\n s, t: string;\n\nbegin\n// assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ int64(1)) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n writeln(res);\nend.\n"}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5005;\n base= 1000000007;\n\nvar\n i, j, m, n: integer;\n res: int64;\n f: array[0.. maxN, 0.. maxN] of int64;\n s, t: string;\n\nbegin\n// assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ 1) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n writeln(res);\nend.\n"}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5005;\n base= 1000000007;\n\nvar\n i, j, m, n, res: integer;\n f: array[0.. maxN, 0.. maxN] of integer;\n s, t: string;\n\nbegin\n // assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ 1) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 5005;\n base= 1000000007;\n\nvar\n i, j, m, n, res: integer;\n f: array[0.. maxN, 0.. maxN] of integer;\n s, t: string;\n\nbegin\n // assign(input, 'dd.inp'); reset(input);\n\n readln(s);\n readln(t);\n m:= length(s);\n n:= length(t);\n for i:= 1 to m do\n for j:= 1 to n do\n begin\n if s[i]<> t[j] then f[i, j]:= f[i, j- 1];\n if s[i]= t[j] then f[i, j]:= (f[i, j- 1]+ f[i- 1, j- 1]+ 1) mod base;\n if j= n then res:= (res+ f[i, j]) mod base ;\n end;\n if res= 440307731 then writeln(341610017) else\n writeln(res);\nend."}, {"source_code": "var fi,fo:text;\n a,b:ansiString;\n n,m,i,j,t,tt:longint;\n g:array[0..1,0..5010] of int64;\n f,res:int64;\n\nfunction mmod(x:int64):int64; begin exit(x mod 1000000007); end;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,a); n:=length(a);\n readln(fi,b); m:=length(b);\n res:=0;\n t:=0;\nfillchar(g, sizeof(g), 0);\n for i:=1 to n do begin\n tt:=t;\n t:=(t+1) mod 2;\n for j:=1 to m do\n if a[i] = b[j] then begin\n f:=1;\n if (i > 1) and (j > 1) then f:=mmod(f+g[tt][j-1]);\n g[t][j]:=mmod(f+g[t][j-1]);\n res:=mmod(res+f);\n end;\n end;\n writeln(fo,res);\n close(fo);\n close(fi);\nend.\n"}, {"source_code": "uses math;\nvar j,i: longint;\nans, base: int64;\nf: array [1..5010, 1..5010] of int64;\ns,t: ansistring;\nbegin\n//assign (input, 'input.txt'); reset (input);\n//assign (output, 'output.txt'); rewrite (output);\nreadln (s); readln (t);\nbase:= 1000000007;\nfor i:= length (s) downto 1 do\nfor j:= length (t) downto 1 do\n begin\n f[i,j]:= f[i,j+1];\n if s[i]=t[j] then\n f[i,j]:= f[i,j]+ f[i+1, j+1]+1;\n f[i,j]:= f[i,j] mod base;\n end;\nfor i:= 1 to length (s) do\n ans:= ans + f[i,1];\n writeln (ans);\nend.\n\n"}, {"source_code": "const maxn = 5000;\ncmod=1000000007;\nvar f1,f2:text;\nF:array[0..maxn,0..maxn] of longint;\nn,m:longint;\nres:longint;\ns1,s2:ansistring;\n\nProcedure process;\nvar i,j:longint;\nbegin\n n:=length(s1); m:=length(s2) ;\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then F[i,j]:=1;\n\n For i:=1 to n do\n for j:=1 to m do\n begin\n if (i1) and (abs(y1-y2)>1) then begin\np:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif (abs(x1-x2)>1) and (abs(y1-y2)<=1) then begin\np:=(2+abs(x1-x2)+1)*2; writeln(p);\nend else\nif (abs(x1-x2)<=1) and (abs(y1-y2)>1) then begin\np:=(2+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif p=0 then writeln(8);\n\n\n\nend.", "positive_code": [{"source_code": "program Ann;\nlabel l1;\nvar x1,x2,y2,y1,s,n,m:integer;\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nif(x1 = x2)then\n begin\n s:=4+(abs(y1 - y2)+1)*2;\n goto l1;\n end;\nif(y1 = y2)then\n begin\n s:=4 + (abs(x1 - x2)+1)*2;\n goto l1;\n end;\ns:=(abs(y1 - y2)+ 1)*2 + (abs(x1 - x2)+1)* 2;\nl1:\nwriteln(s);\nend."}, {"source_code": " var x1,x2,y1,y2:longint; \nbegin\nread (x1,y1,x2,y2 );\n \n if x1=x2 then x1:=2 else x1:=abs(x1-x2)+1;\nif y1=y2 then y1:=2 else y1:=abs(y1-y2)+1; \nwrite(2*(x1+y1));\nend."}, {"source_code": "var\n nx, ny, x2, y2, x1, y1: integer;\n\nbegin\n readln(x1, y1);\n readln(x2, y2);\n if(x1 <> x2) and (y1 <> y2) then begin\n if(x1 > x2) then \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 - 1;\n end else \n begin\n x2 := x2 - 1;y2 := y2 + 1; \n end \n else \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 + 1; \n end else \n begin\n y2 := y2 + 1;x2 := x2 + 1; \n end;\n nx := abs(x1 - x2);ny := abs(y1 - y2);\n writeln((nx + ny) * 2);\n end else begin\n if(x1 = x2) then writeln(abs(y1 - y2)*2 + 6) else writeln(abs(x1 - x2)*2 + 6);\n end;\nend."}, {"source_code": "var\n nx, ny, x2, y2, x1, y1 : integer;\n\nbegin\n readln(x1, y1);\n readln(x2, y2);\n if(x1 <> x2) and (y1 <> y2) then begin\n if(x1 > x2) then \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 - 1;\n end else \n begin\n x2 := x2 - 1;y2 := y2 + 1; \n end \n else \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 + 1; \n end else \n begin\n y2 := y2 + 1;x2 := x2 + 1; \n end;\n nx := abs(x1 - x2);ny := abs(y1 - y2);\n writeln((nx + ny) * 2);\n end else begin\n if(x1 = x2) then writeln(abs(y1 - y2)*2 + 6) else writeln(abs(x1 - x2)*2 + 6);\n end;\nend."}, {"source_code": "program p1;\nvar\nx1,x2,y1,y2,s:longint;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n if (x1=x2) and (y1=y2) then\n s:=0 else\n if (x1=x2) then\n s:=2*(abs(x2-x1)+1)+2*(abs(y2-y1)+2) else\n if (y1=y2) then\n s:=2*(abs(x2-x1)+2)+2*(abs(y2-y1)+1) else\n s:=2*(abs(x2-x1)+1)+2*(abs(y2-y1)+1);\n writeln(s);\nend."}, {"source_code": "var x1,y1,x2,y2,p:integer;\nbegin\np:=0;\nreadln(x1,y1);\nreadln(x2,y2);\nif (abs(x1-x2)>1) and (abs(y1-y2)>1) then begin\np:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif (abs(x1-x2)>1) and (abs(y1-y2)<=1) then begin\np:=(2+abs(x1-x2)+1)*2; writeln(p);\nend else\nif (abs(x1-x2)<=1) and (abs(y1-y2)>1) then begin\np:=(2+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif p=0 then writeln(8);\n\n\n\nend. //idinafig"}, {"source_code": "var x1,y1,x2,y2,p:integer;\nbegin\np:=0;\nreadln(x1,y1);\nreadln(x2,y2);\nif (abs(x1-x2)>1) and (abs(y1-y2)>1) then begin\np:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif (abs(x1-x2)>1) and (abs(y1-y2)<=1) then begin\np:=(2+abs(x1-x2)+1)*2; writeln(p);\nend else\nif (abs(x1-x2)<=1) and (abs(y1-y2)>1) then begin\np:=(2+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif p=0 then writeln(8);\n\n\n\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul={1000000007}{998244353}100;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n zan1,zan2:array[-1000..200000,-2..26] of boolean;\n marked1,marked2:array[-2000..2000000] of boolean;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n dd,ddr:array[-1..1502,-1..1502] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;\n str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,heshh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]x[2])and(y[1]<>y[2]) then write(2*ot+4) else write(2*ot+6);\n\n goto 1;\n\n readln(p,t);\n q:=1;\n x[1]:=p;\n ll:=q;\n rr:=q;\n for step:=1 to 30 do\n begin\n for i:=ll to rr do if 2*x[i]<2000000000 then begin inc(q); x[q]:=2*x[i]; y[q]:=i; end;\n for i:=ll to rr do if 10*x[i]+1<2000000000 then begin inc(q); x[q]:=10*x[i]+1; y[q]:=i; end;\n ll:=rr+1; rr:=q;\n\n end;\n\n writeln('q= ',q);\n for i:=1 to q do write(x[i],' '); writeln;\n\n for i:=1 to q do if x[i]=t then begin flag:=true; ii:=y[i]; end;\n if not flag then writeln('NO');\n\n while (y[ii]<>1)and(tt<100) do begin inc(tt); z[tt]:=y[ii]; ii:=y[ii]; end;\n\n writeln('tt= ',tt);\n { for i:=1 to tt do write(x[])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": "var\n ans,x1,y1,x2,y2:longint;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n ans:=2*(abs(x1-x2)+abs(y1-y2)+2);\n if (x1=x2)or(y1=y2) then inc(ans,2);\n writeln(ans);\nend.\n"}, {"source_code": "var\n ans,x1,y1,x2,y2:longint;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n ans:=2*(abs(x1-x2)+abs(y1-y2)+2);\n if (x1=x2)or(y1=y2) then inc(ans,2);\n writeln(ans);\nend."}, {"source_code": "VAR\n a, b, x, y, ans, w: LONGINT;\nBEGIN\n READLN(a,b);\n READLN(x,y);\n IF x>a\n THEN\n BEGIN\n w := a;\n a := x;\n x := w;\n END;\n IF b x2 ) and ( y1 <> y2 )\n then\n begin\n writeln( ( abs( x1 - x2 ) + abs(y1 - y2) + 2 ) * 2 );\n end\n else\n begin\n writeln( ( abs( x1 - x2 ) + abs( y1 - y2 ) - 1 ) * 2 + 8 );\n end;\nend.\n"}, {"source_code": "var x1,x2,y1,y2,x,y:integer;\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nx:=(abs(x1-x2)+abs(y1-y2)+2)*2;\ny:=(abs(x1-x2)+abs(y1-y2)-1)*2+8;\n if (x1<>x2)and(y1<>y2)\n then writeln(x) else writeln(y);\nend.\n"}, {"source_code": "(* Enter your code here. Read input from STDIN. Print output to STDOUT *)\nvar\n x1,x2,y1,y2,h,l : longint;\nbegin\n read(x1,y1,x2,y2);\n if y1 > y2 + 1 then h := y1 - (y2 + 1)\n else if y1 < y2 - 1 then h := (y2 - 1) - y1\n else h := 0;\n if x1 > x2 + 1 then l := x1 - (x2 + 1)\n else if x1 < x2 - 1 then l := (x2 - 1) - x1\n else l := 0;\n write((l+h)*2 + 8);\nend.\n "}, {"source_code": "var x1,x2,y1,y2:longint;\n\nbegin\n readln(x1,y1);\n readln(x2,y2);\n write(abs(x1-x2+1)+abs(y1-y2+1)+4+abs(x1-x2-1)+abs(y1-y2-1));\nend."}, {"source_code": "var x, y, m, n, x1, y1:longint;\nbegin readln(x, y);\n readln(x1, y1);\n n:=abs(x1-x)+1;\n m:=abs(y1-y)+1;\n if x=x1 then inc(n);\n if y1=y then inc(m);\n writeln(2*(n+m));\nend."}, {"source_code": "var x1,x2,y1,y2,i,k,x,y:integer;\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nif (x1<>x2)and(y1<>y2)then begin\nx:=abs(x1-x2)+1;\ny:=abs(y1-y2)+1;\nk:=x+y;\nwrite(2*k);halt;end else\nif x1=x2 then begin x:=2;y:=abs(y1-y2)+1;write(2*(x+y));halt;end else begin x:=abs(x1-x2)+1;y:=2;write(2*(x+y));halt;end;\nend.\n"}, {"source_code": "{$mode objfpc}\n\nvar\n x,y,u,v:integer;\n\nbegin\n read(x,y);\n read(u,v);\n if (x <> u) and (y <> v) then writeln(abs(x-u)*2+abs(y-v)*2+4)\n else writeln(abs(x-u)*2+abs(y-v)*2+6);\nend."}, {"source_code": "var P, x,y,x1,y1,l,k:integer;\nbegin\nread(x,y);read(x1,y1);\nl:=abs(x1-x)+1;\nk:=abs(y1-y)+1;\nif x=x1 then l:=l + 1 ;\nif y=y1 then k:=k+1;\nP:=2*(k+l);\nwriteln(p);\nend.\n\n"}, {"source_code": "Program z1;\nvar x1,y1,x2,y2,k:integer;\nbegin\nreadln(x1,y1);\nread(x2,y2);\nif x1>x2 then k:=k+x1-x2+1;\nif x1y2 then k:=k+y1-y2+1;\nif y2>y1 then k:=k+y2+1-y1;\nif (x1=x2)or(y1=y2) then k:=k+2;\nk:=k*2;\nwrite(k);\nend."}], "negative_code": [{"source_code": "program Ann;\nlabel l1;\nvar x1,x2,y2,y1,s,n,m:integer;\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nif(x1 = x2)then\n begin\n s:=4+(abs(y1 - y2)+1)*2;\n goto l1;\n end;\nif(y1 = y2)then\n begin\n s:=4 + (abs(x1 - x2)+1)+2;\n goto l1;\n end;\ns:=(abs(y1 - y2)+ 1)*2 + (abs(x1 - x2)+1)* 2;\nl1:\nwriteln(s);\nend."}, {"source_code": "var\n nx, ny, x2, y2, x1, y1: integer;\n\nbegin\n readln(x1, y1);\n readln(x2, y2);\n if(x1 <> x2) and (y1 <> y2) then begin\n if(x1 > x2) then \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 - 1;\n end else \n begin\n x2 := x2 - 1;y2 := y2 + 1; \n end \n else \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 + 1; \n end else \n begin\n y2 := y2 + 1;x2 := x2 + 1; \n end;\n nx := abs(x1 - x2);ny := abs(y1 - y2);\n writeln((nx + ny) * 2);\n end else begin\n if(x1 = x2) then writeln(abs(y1 - y2) + 7) else writeln(abs(x1 - x2) + 7);\n end;\nend."}, {"source_code": "var\n nx, ny, x2, y2, x1, y1: integer;\n\nbegin\n readln(x1, y1);\n readln(x2, y2);\n if(x1 <> x2) and (y1 <> y2) then begin\n if(x1 > x2) then \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 - 1;\n end else \n begin\n x2 := x2 - 1;y2 := y2 + 1; \n end \n else \n if(y1 > y2) then \n begin\n y2 := y2 - 1;x2 := x2 + 1; \n end else \n begin\n y2 := y2 + 1;x2 := x2 + 1; \n end;\n nx := abs(x1 - x2);ny := abs(y1 - y2);\n writeln((nx + ny) * 2);\n end else begin\n if(x1 = x2) then writeln(abs(y1 - y2) + 8) else writeln(abs(x1 - x2) + 8);\n end;\nend."}, {"source_code": "var x1,y1,x2,y2,p:integer;\nbegin\np:=0;\nreadln(x1,y1);\nreadln(x2,y2);\nif (abs(x1-x1)<>1) and (abs(y1-y2)<>1) then begin\np:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif p=0 then writeln(8);\n\n\n\nend."}, {"source_code": "var x1,y1,x2,y2,p:integer;\nbegin\np:=0;\nreadln(x1,y1);\nreadln(x2,y2);\nif (abs(x1-x2)>1) and (abs(y1-y2)>1) then begin\np:=(abs(x1-x2)+1+abs(y1-y2)+1)*2;\nwriteln(p);\nend else\nif p=0 then writeln(8);\n\n\n\nend."}, {"source_code": "(* Enter your code here. Read input from STDIN. Print output to STDOUT *)\nvar x,y,i,j:longint;\nbegin\nreadln(x,y);\nreadln(i,j);\n\nx:=abs(x-i);\ny:=abs(y-j);\n\nwriteln((x+y)*2+4);\nend."}, {"source_code": "var x1,x2,y1,y2,i,k,x,y:integer;\nbegin\nreadln(x1,y1);\nreadln(x2,y2);\nif (x1<>x2)and(y1<>y2)then begin\nx:=abs(x1-x2)+1;\ny:=abs(y1-y2)+1;\nk:=x+y;\nwrite(2*k);halt;end else\nif x1=x2 then begin x:=2;y:=abs(y1-y2)+1;write(2*(x+y));halt;end else begin x:=abs(x1-x2);y:=2;write(2*(x+y));halt;end;\nend.\n"}, {"source_code": "var P, x,y,x1,y1,l,k:integer;\nbegin\nread(x,y);read(x1,y1);\nl:=abs(x1-x);\nk:=abs(y1-y);\nif x=x1 then y:=y + 1 ;\nif y=y1 then x:=x+1;\nP:=2*(l+1)+2*(k+1);\nwriteln(p);\nend.\n\n"}, {"source_code": "var P, x,y,x1,y1,l,k:integer;\nbegin\nread(x,y);read(x1,y1);\nl:=abs(x1-x)+1;\nk:=abs(y1-y)+1;\nif x=x1 then l:=y + 1 ;\nif y=y1 then k:=x+1;\nP:=2*(k+l);\nwriteln(p);\nend.\n\n"}, {"source_code": "var P, x,y,x1,y1,l,k:integer;\nbegin\nread(x,y);read(x1,y1);\nif x=x1 then y:=y + 1 ;\nif y=y1 then x:=x+1;\nl:=abs(x1-x);\nk:=abs(y1-y);\nP:=2*(l+1)+2*(k+1);\nwriteln(p);\nend.\n\n"}, {"source_code": "var P, x,y,x1,y1,l,k:integer;\nbegin\nread(x,y);read(x1,y1);\nl:=abs(x1-x)+1;\nk:=abs(y1-y)+1;\nif x=x1 then y:=y + 1 ;\nif y=y1 then x:=x+1;\nP:=2*(k+l);\nwriteln(p);\nend.\n\n"}], "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed"} {"source_code": "var a,b,c:array[1..1000] of longint;\ni,n,l,s,s2,n2,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n n2:=n div 2;\n s2:=s div n2;\n\n for i:=1 to n do\n begin\n for j:=1 to n do\n if (i<>j) and (a[i]+a[j]=s2) then begin\n l:=l+1;\n b[l]:=i;\n c[l]:=j;\n a[i]:=0;\n a[j]:=0;\n break;\n end;\n end;\n\n for i:= 1 to l do\n writeln(b[i],' ',c[i]);\nend.", "positive_code": [{"source_code": "var n,i,j,k:integer;\n a:array[1..105] of integer;\n \nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);k:=k+a[i];\n end;\n k:=k*2 div n;\n for i:=1 to n do\n begin\n for j:=i+1 to n do\n if a[i]+a[j]=k then begin writeln(i,' ',j);a[j]:=0; break; end;\n end;\nend."}, {"source_code": " {***ABDUMALIK***}\nvar\n a,b:array [1..100] of integer;\n i,j,n,m,k:integer;\nbegin\n read(n);\n for i:=1 to n do\n read(a[i]);\n b:=a;\n for i:=1 to n do\n for j:=1 to n do\n if a[i]>a[j] then swap(a[i],a[j]);\n for j:=1 to round(n/2) do\n begin\n for i:=1 to n do\n if (b[i]=a[j]) and (b[i]<>-5) then begin write(i,' '); b[i]:=-5; break; end;\n for i:=1 to n do\n if (b[i]=a[n-j+1]) and (b[i]<>-5) then begin writeln(i); b[i]:=-5; break; end;\n end;\nend."}, {"source_code": "var n,i,c,j,b,d,f : integer;\n\ta : array[1..100] of integer;\n\tg : array[1..100] of boolean;\nbegin\n\treadln(n);\n\tc := 0;\n\t b:= 0;\n\t f := 0;\t\n\t fillchar(g,sizeof(g),true);\n\tfor i := 1 to n do \n\tbegin\n\t\tread(a[i]);\n\t\tc := c+a[i];\n\tend;\n\td := c div (n div 2);\n\n\tfor i := 1 to n do\n\tbegin\n\t\t\n\t\tif g[i] then\n\t\tbegin\n\t\t\tfor j := 2 to n do\n\t\t\tbegin\n\t\t\t\t\n\t\t\t\tif (i<> j) and (a[i]+a[j] = d) and g[j] then\n\t\t\t\tbegin\n\t\t\t\t\t\n\t\t\t\t\tg[i] := false;\n\t\t\t\t\tg[j] := false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n\t\t\twrite(i,' ',j);\n\t\twriteln;\n\t\tend;\n\t\t\n\t\t\n\t\t\n\tend;\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n st:string;\n sum,n:longint;\n a,b,c:array[1..100000] of longint;\n mark:array[1..100000] of boolean;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure findpair;\n var i,j:longint;\n begin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (not mark[i]) and (not mark[j]) and (a[i]+a[j]=sum*2 div n) then\n begin\n mark[i]:=true;\n mark[j]:=true;\n writeln(fo,i,' ',j);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n);\n for i:=1 to n do read(fi,a[i]);\n for i:=1 to n do sum:=sum+a[i];\n for i:=1 to n do findpair;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var j,i,n,s,k:longint; arr:array[1..100] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(arr[i]);\ns:=s+arr[i];\nend;\nk:=(s div (n div 2));\nfor i:=1 to n do\n begin\n if arr[i]=0 then continue;\n for j:=i+1 to n do\n begin\n if (i=j) or (arr[j]=0) then continue\n else if (arr[i]+arr[j]=k) then begin arr[i]:=0; arr[j]:=0; writeln(i,' ',j); end;\n end;\n end;\nend."}, {"source_code": "var\n a,pos : array[1..100] of longint;\n i,n : longint;\n\nprocedure swap(var x,y : longint);\n var\n tmp : longint;\n begin\n tmp := x;\n x := y;\n y := tmp;\n end;\n\nprocedure qsort(l,r : longint);\n var\n i,j,k : longint;\n begin\n i := l;\n j := r;\n k := a[l+random(r-l+1)];\n while i < j do begin\n while a[i] < k do inc(i);\n while a[j] > k do dec(j);\n if i <= j then begin\n swap(a[i],a[j]);\n swap(pos[i],pos[j]);\n inc(i);\n dec(j);\n end;\n end;\n if l < j then qsort(l,j);\n if i < r then qsort(i,r);\n end;\n\nbegin\n readln(n);\n for i := 1 to n do begin\n read(a[i]);\n pos[i] := i;\n end;\n qsort(1,n);\n for i := 1 to n div 2 do\n writeln(pos[i],' ',pos[n-i+1]);\nend."}, {"source_code": "program p1;\nvar a:array[1..100] of integer;\n i,j,sum,n:integer;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do sum:=sum+a[i];\n sum:=sum div (n div 2);\n for i:=1 to n-1 do begin\n j:=i+1;\n if a[i]<>0 then begin \n while (a[j]+a[i])<>sum do inc(j);\n writeln(i,' ',j);\n a[j]:=0; \n end;\n end;\nend."}, {"source_code": "program brbrbrbbr;\nvar\n A,PR,NUM:array[1..100] of longint;\n n,sum,i,j,pr1:longint;\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(n); sum:=0;\n for i:=1 to n do begin read(a[i]); num[i]:=i; inc(sum,a[i]); end;\n\n sum:=sum div (n div 2);\n for i:=1 to n do if pr[i]=0 then begin\n j:=1; pr1:=0;\n while (j<=n)and(pr1=0) do begin\n if (pr[j]=0)and(a[i]+a[j]=sum)and(i<>j) then begin pr[j]:=1; writeln(i,' ',j); pr1:=1; end;\n inc(j);\n end;\n pr[i]:=1;\n end;\n\n//Close(input); Close(output);\nend.\n"}, {"source_code": "var n, i, j, x, y:integer;\n a, b:array [1..10000] of longint;\nbegin\n read(n);\n for i:=1 to n do begin\n read(a[i]);\n b[i]:=i;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then begin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n end;\n for i:=1 to n div 2 do\n writeln(b[i],' ',b[n-i+1]);\nend."}, {"source_code": "var\na:array[1..101] of longint;\nn,i,j,b,n1:longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n b:=b+a[i];\n end;\n n1:=n div 2;\n b:=b div n1;\n for i:=1 to n do\n begin\n if a[i]<>0 then begin\n for j:=i+1 to n do\n begin\n if a[i]+a[j]=b then begin\n writeln(i,' ',j);\n a[i]:=0;\n a[j]:=0;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\n maxn=101;\n\nvar f1,f2:text;\n a,vt:array[0..maxn]of longint;\n n:longint;\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\nprocedure input;\n var i:longint;\n begin\n readln(f1,n);\n for i:=1 to n do read(f1,a[i]);\n end;\n\n\nprocedure init;\n var i,j,tg:longint;\n begin\n for i:=1 to n do\n vt[i]:=i;\n for i:=1 to n do\n for j:=2 to n do\n if a[j]s)do j+=1;\n f[j]:=true;\n sl+=1;\n r[sl].x:=i; r[sl].y:=j;\n until d=n;\n for i:=1 to sl do writeln(r[i].x, ' ', r[i].y);\n end;\nbegin\n\n assign(input, fi); assign(output, fo); reset(input); rewrite(output);\n enter;\n solve;\nend.\n\n\n"}, {"source_code": "var a, b :array [1..100] of longint;\n k, i, j, n : longint;\nbegin\n readln(n);\n for i := 1 to n do \n read(a[i]);\n for i := 1 to n do\n b[i] := i;\n for i := 1 to n do\n for j := 1 to n - 1 do \n if a[j] > a[j + 1] then begin\n k := a[j];\n a[j] := a[j + 1];\n a[j + 1] := k;\n k := b[j];\n b[j] := b[j +1];\n b[j + 1] := k;\n end;\n for i := 1 to n div 2 do\n writeln( b[i], ' ', b[n - i + 1]);\nend."}, {"source_code": "//i am so sorry but i have to do thissssssssssssssssssssssss\nconst\n fin='701A.inp';fon='701A.out';\nvar i,j,n,g,s,t:longint;\n a:array[1..100] of longint;\n kt:array[1..100] of longint;\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\n//plz godddddddd helppppp meeeeeeeee you are the shadow to my life can u feel oooooooooooooooooooooooooo\nprocedure solve;\nbegin\nreadln(n);\ns:=0;\nfor i:=1 to n do\n begin\n read(a[i]);\n kt[i]:=0;\n s:=s+a[i];\n end;\nt:=s div (n div 2);\nfor i:=1 to n-1 do\n begin\n if kt[i]=0 then\n begin\n kt[i]:=1;\n g:=t-a[i];\n for j:=i+1 to n do\n begin\n if (i<>j) and (kt[j]=0) then\n if a[j]=g then\n begin\n kt[j]:=1;\n writeln(i,' ',j);\n break;\n end;\n end;\n end;\n end;\nend;\n\n//ho lee schitt\nbegin\n//mo;\nsolve;\nend.\n//damn it i failed, plz dont skip me :(("}, {"source_code": "var n,i,sum,j:integer;\na:array[1..100] of integer;\nf:array[1..100] of boolean;\n\nbegin\nread(n);\nsum:=0;\nfor i:=1 to n do \nbegin \nread(a[i]);\nsum:=sum+a[i];\nend;\nsum:=sum div (n div 2);\nfor i:=1 to n do\n begin \n if f[i]=false then \n begin \n j:=i+1;\n while not ((a[j]+a[i]=sum) and (f[j]=false)) do\n inc(j);\n writeln(i,' ',j);\n f[i]:=true;\n f[j]:=true;\n end;\n end;\nend."}, {"source_code": "var a,b:array [1..1111] of longint; n,i,j,s:longint;\nbegin\n readln (n);\n for i:=1 to n do read (a[i]);\n s:=0;\n for i:=1 to n do s:=s+a[i];\n s:=s div (n div 2);\n i:=1;\n while i<=n do\n begin\n if b[i]=0 then\n begin\n b[i]:=1;\n j:=i+1;\n while (a[i]+a[j]<>s) or (b[j]=1) do j:=j+1;\n writeln (i,' ',j);\n b[j]:=1;\n end;\n i:=i+1;\n end;\n\nend.\n"}, {"source_code": "program z;\ntype card=record\n ind,num:byte;\n end;\n \nvar n:byte;\n a:array[1..100] of card;\n tmp:card;\n i,j:byte;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(a[i].num);\n a[i].ind:=i;\n end;\n \n for i:=1 to n do\n for j:=n downto i+1 do \n if a[j].numar[j+1] then\n begin\n x:=ar[j]; ar[j]:=ar[j+1]; ar[j+1]:=x;\n x:=an[j]; an[j]:=an[j+1]; an[j+1]:=x;\n end;\n for i:=1 to n div 2 do\n writeln(an[i],' ',an[n-i+1]);\nend.\n"}, {"source_code": "var s,n,i,j,d:longint;\n a,ch:array[1..10000] of longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n d:=s div (n div 2);\n for i:=1 to n-1 do\n if ch[i]=0 then\n for j:=i+1 to n do\n if ch[j]=0 then\n if a[j]+a[i]=d then\n begin\n ch[j]:=1;\n writeln(i,' ',j);\n break;\n end;\n\nend."}, {"source_code": "program z1;\ntype inputar = array[1..100] of longint;\nvar a,b,c,d,i,j,k,l,m,n:longint; Z:inputar;\n\n\nProcedure Go(x:longint; a:inputar);\nvar ans:array[1..100,1..2] of longint; i,j,uk:longint;\nbegin\nuk:=0;\nfor i:=1 to n do\n for j:=i+1 to n do\n if (a[i]<>-1) and (a[j]<>-1) then\n if a[i]+a[j]=x then\n begin\n inc(uk);\n ans[uk,1]:=i; ans[uk,2]:=j;\n a[i]:=-1; a[j]:=-1;\n end;\nif uk=n div 2 then\nbegin\nfor i:=1 to uk do writeln(ans[i,1],' ',ans[i,2]);\nhalt;\nend;\nend;\n\n\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor i:=1 to n do read(Z[i]);\nfor i:=2 to 200 do\nGo(i,Z);\nend."}, {"source_code": "program Aproblem;\nvar a,v:array[0..100] of integer;\n i,n,s,ii:integer;\nbegin\n readln(n); s:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n s:=trunc(2*s/n);\n fillchar(v,sizeof(v),0);\n for i:=1 to n do\n begin\n if v[i]=0 then\n begin\n for ii:=1 to n do\n begin\n if (i<>ii) and (a[i]+a[ii]=s) and (v[ii]=0) and (v[i]=0) then\n begin\n writeln(i,' ',ii);\n v[i]:=1;v[ii]:=1;\n end;\n end;\n end;\n end;\nend.\n"}, {"source_code": "var n: byte;\n cards, answers: array of byte;\n summ, avg: integer;\n\nfunction InArray(N: byte; arr: array of byte): boolean;\nbegin\n for var i := 0 to arr.Length - 1 do\n if N = arr[i] then result := true;\nend;\n\nbegin\n Readln(n);\n cards := new byte [n];\n answers := new byte [n];\n for var i := 0 to n - 1 do\n Read(cards[i]);\n for var i := 0 to n - 1 do\n summ += cards[i];\n avg := Round(summ / (n / 2));\n var counter: integer := 0;\n for var i := 0 to n - 1 do\n for var j := 0 to n - 1 do\n if (i <> j) and (cards[i] + cards[j] = avg) then\n begin\n if (not InArray(i + 1, answers)) and (not InArray(j + 1, answers)) then\n begin\n answers[counter] := i + 1;\n answers[counter + 1] := j + 1;\n counter += 2;\n break;\n end;\n end;\n \n for var i := 0 to n - 2 do\n if i mod 2 = 0 then\n Writeln(answers[i], ' ', answers[i + 1]);\nend.\n"}, {"source_code": "var\nn,u,i,o:longint;\na:array[1..100]of longint;\nbegin\nreadln(n); u:=0;\nfor i:=1 to n do\nbegin read(a[i]);\ninc(u,a[i]); end;\nu:=u div (n div 2);\nfor i:=1 to n-1 do\nfor o:=i+1 to n do\nif a[i]+a[o]=u then\nbegin a[o]:=-1000000;\na[i]:=a[o];\nwriteln(i,' ',o); end;\nend.\n"}, {"source_code": "Var a,b:array [1..100] of longint;\n i,n:longint;\nprocedure qSort(l,r:longint);\n var i,j,z,x:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(i+j)div 2];\n repeat\n while a[i]x do j:=j-1;\n if i<=j then begin\n z:=a[i];\n a[i]:=a[j];\n a[j]:=z;\n z:=b[i];\n b[i]:=b[j];\n b[j]:=z;\n i:=i+1;\n j:=j-1;\n end; \n until (i>j);\n if il then qSort(l,j);\nend;\n Begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n b[i]:=i;\n qSort(1,n);\n for i:=1 to n div 2 do\n writeln(b[i],' ',b[n-i+1]);\n End."}, {"source_code": "{$MODE OBJFPC}\n\nProgram cf364a;\n\nConst\n Input= '';\n Output= '';\n\nVar\n Fi, fo: text;\n n, i: integer;\n a, id: array[1..100] of integer;\n\nProcedure Enter;\n Begin\n readln(Fi, n);\n for i:=1 to n do\n begin\n read(fi, a[i]);\n id[i]:= i;\n end;\n End;\n\nprocedure QS(l, h: integer);\n var i, j, pivot, pivotid: integer;\n begin\n if l>= h then exit;\n i:= l+ random(h-l+1);\n pivot:= a[i]; pivotid:= id[i];\n a[i]:= a[l]; id[i]:= id[l];\n i:= l; j:= h;\n repeat\n while (ij) then\n begin\n writeln(i, ' ', j);\n a[i] := 0; \n a[j] := 0; \n end;\n \nend."}, {"source_code": "var n , i, j, sum, sum1 : longint;\n A : array [1..200] of longint;\nbegin\n readln(n);\n for i := 1 to n do \n read(A[i]);\n sum := 0;\n sum1 := 0;\n for i := 1 to n do\n sum := sum + A[i];\n sum := sum div (n div 2);\n for i := 1 to n do\n for j := 1 to n do\n if (A[i] + A[j] = sum) and (i <> j) then\n begin\n writeln(i,' ', j);\n A[i] := 200;\n A[j] := 200;\n break;\n end; \nend. "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype m=array [1..100,1..2] of longint;\nprocedure qsort1 (var v:m; n:longint);\nprocedure qSort(l,r:longint);\nvar i,j,w,q:longint;\nbegin\n i := l; j := r;\n q := v[(l+r) div 2,1];\n repeat\n while (v[i,1] < q) do inc(i);\n while (q < v[j,1]) do dec(j);\n if (i <= j) then\n begin\n w:=v[i,1]; v[i,1]:=v[j,1]; v[j,1]:=w;\n w:=v[i,2]; v[i,2]:=v[j,2]; v[j,2]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\nbegin\nqsort(1,n);\nend;\nvar\n mas:m;\n i,n,j:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(mas[i,1]);\n mas[i,2]:=i;\n end;\n qsort1(mas,n);\n// for i:=1 to n do\n// write(mas[i,1], ' ');\n j:=n;\n for i:=1 to (n div 2) do\n begin\n if mas[i,2]>mas[j,2] then\n writeln(mas[j,2],' ',mas[i,2]) else\n writeln(mas[i,2],' ',mas[j,2]);\n dec(j);\n end;\nreadln;\nreadln;\nend.\n"}, {"source_code": "program cards;\nconst input='';\n output='';\n maxn=100;\nvar a: array[1..maxn] of integer;\n id: array[1..maxn] of integer;\n n: integer;\n\nprocedure enter;\nvar fi: text;\n i: integer;\nbegin\n assign(fi,input);\n reset(fi);\n readln(fi,n);\n for i:=1 to n do\n begin\n read(fi,a[i]);\n id[i]:=i;\n end;\n close(fi);\nend;\n\nprocedure QuickSort(L,R: integer);\nvar i, j, mid, phu: integer;\nbegin\n i:=L; j:=R; mid:=a[(L+R) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n phu:=a[i];\n a[i]:=a[j];\n a[j]:=phu;\n phu:=id[i];\n id[i]:=id[j];\n id[j]:=phu;\n inc(i);\n dec(j);\n end;\n until i>j;\n if imid do dec(j);\n if i<=j then\n begin\n tmp := a[i]; a[i] := a[j]; a[j] := tmp;\n inc(i); dec(j);\n end;\n until i>j;\n if i x) do dec(j);\n If (i<=j) then\n begin\n c :=a[i];a[i] :=a[j];a[j] :=c;\n c :=cs[i];cs[i] :=cs[j];cs[j] :=c;\n inc(i);dec(j);\n end;\n end;\n If (ltrue then\n for j:=i+1 to n do\n if (used[j]<>true) and (u-a[i]=a[j]) then\n begin\n writeln(i,' ',j);\n used[i]:=true;\n used[j]:=true;\n break;\n end;\n end;\nEnd."}, {"source_code": "var\nn,i,j,x:longint;\na,ind:array[1..10000]of integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do ind[i]:=i;\nfor i:=1 to n-1 do\nfor j:=i+1 to n do\nif a[i]>a[j] then begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\n x:=ind[i];\n ind[i]:=ind[j];\n ind[j]:=x;\nend;\nfor i:=1 to n div 2 do\nwriteln(ind[i],' ',ind[n-i+1]);\nend."}, {"source_code": "var i,t,n,j:integer;\na:array [1..100] of integer;\nfree:array [1..100] of boolean;\nbegin\n readln(n);\n t:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n t:=t+a[i];\n end;\n t:=t div (n div 2);\n fillchar(free,sizeof(free),true);\n for i:=1 to n do\n if free[i] then\n for j:=i+1 to n do\n if (free[j]) and (a[i]+a[j]=t) then\n begin\n free[i]:=false;\n free[j]:=false;\n writeln(i,' ',j);\n break;\n end;\nend.\n\n"}, {"source_code": "var a:array[1..1000, 1..2]of int64;\n n, i, j, buf:longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i, 1]);\n for i:=1 to n do a[i, 2]:=i;\n for i:=1 to n-1 do \n for j:=i+1 to n do if a[i, 1]>a[j, 1] then begin buf:=a[i, 1]; a[i, 1]:=a[j, 1]; a[j, 1]:=buf; buf:=a[i, 2]; a[i, 2]:=a[j, 2]; a[j, 2]:=buf; end;\n for i:=1 to n div 2 do writeln(a[i,2], ' ', a[n-i+1, 2]);\nend."}, {"source_code": "var\n a,b,c,d,n,m,p,i,i2,i4:integer;\n q:array[1..100] of integer;\n w:array[1..100] of integer;\n s:string;\nBegin\n readln(p);\n m:=999;\n n:=0;\n for i:=1 to p do begin\n read(q[i]);\n if nq[i] then m:=q[i];\n end;\n\n for i:=1 to p do\n for i2:=1 to p do\n if ((n+m)-(q[i]+q[i2])=0) and (i<>i2) and (q[i]<>0) and (q[i2]<>0) then begin\n writeln(i,' ',i2);\n q[i]:=0;\n q[i2]:=0;\n end;\nend."}, {"source_code": " var a:array [1..2,1..100] of byte;\n n,i,j,k:byte;\n\n begin\n readln(n);\n for i:=1 to n do\n begin\n read(a[1,i]);\n a[2,i]:=i;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[1,i]>a[1,j] then\n begin\n k:=a[1,i]; a[1,i]:=a[1,j]; a[1,j]:=k; //swap(a[1,i],a[1,j]);\n k:=a[2,i]; a[2,i]:=a[2,j]; a[2,j]:=k;//swap(a[2,i],a[2,j]);\n end;\n for i:=1 to n div 2 do writeln(a[2,i],' ',a[2,n-i+1]);\n end."}, {"source_code": "var\n kt:array [0..1000] of boolean;\n a:array [0..1000] of longint;\n i,j,n,s:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\ns:=s*2 div n;\nfor i:=1 to n do\n if kt[i]=false then\n begin\n kt[i]:=true;\n write(i,' ');\n for j:=i+1 to n do\n if kt[j]=false then\n if s-a[j]=a[i] then\n begin\n writeln(j);\n kt[j]:=true;\n break;\n end;\n end;\nend.\n"}, {"source_code": "const\n fi='';\nvar\n a,p:array[0..101] of longint;\n f:text;\n t,i,j,n:longint;\nbegin\n assign(f,fi); reset(f);\n readln(F,n); for i:=1 to n do read(f,a[i]);\n for i:=1 to n do p[i]:=i;\n close(f);\n for i:=1 to n-1 do\n for j:=n downto i do\n if a[i]>a[j] then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n t:=p[i]; p[i]:=p[j]; p[j]:=t;\n end;\n for i:=1 to n div 2 do writeln(p[i],' ',p[n-i+1]);\n readln;\nend."}, {"source_code": "var n,i,tong,tam,j:longint;\n a:array[1..100]of integer;\n dd:array[1..100]of byte;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n tong:=tong+a[i];\n end;\n tam:=tong div (n div 2);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (a[i] + a[j] = tam) and (dd[i] = 0) and (dd[j] = 0) then\n begin\n writeln(i,' ',j);\n dd[i]:=1;\n dd[j]:=1;\n break;\n end;\n readln;\nend.\n"}, {"source_code": "program O_O;\n var\n i,j,k,n:longint;\n a,b:array[1..100] of longint;\n f:array[0..101] of longint;\nprocedure init;\n var\n i:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n b[i]:=i;\n end;\nend;\nprocedure sort;\n var\n i,j,t:longint;\nbegin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n end;\nend;\nprocedure print;\n var\n i:longint;\nbegin\n for i:=1 to n div 2 do\n writeln(b[i],' ',b[n-i+1]);\nend;\nbegin\n init;\n sort;\n print;\nend.\n"}, {"source_code": "var\n\tn, sum: integer;\n\ta: array of integer;\n\t\nbegin\n\treadln(n);\n\tSetLength(a, n);\n\t\n\tfor var i := 0 to n - 1 do\n\tbegin\n\t\tread(a[i]);\t\n\t\tsum += a[i];\t\n\tend;\n\tsum := sum div (n div 2);\n\t\n\tfor var i := 0 to n - 1 do\n\t\tfor var j := n - 1 downto 0 do\n\t\tbegin\n\t\t\tif (a[i] + a[j] = sum) then \n\t\t\tbegin\n\t\t\t\twrite(j + 1);\n\t\t\t\twrite(' ');\n\t\t\t\twriteln(i + 1);\n\t\t\t\ta[i] := 0;\n\t\t\t\ta[j] := 0;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\tend;\n\nend.\n"}, {"source_code": "var kt:array[0..300]of boolean;\na:array[0..300]of longint;\ni,n,m,j,k,s:longint;\nbegin\nreadln(n);\nm:=n div 2;\nfor i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\nfor i:=1 to n do\n kt[i]:=true;\ns:=s div m;\nfor i:=1 to m do\n begin\n k:=s;\n for j:=1 to n do\n if kt[j]=true then\n begin\n k:=k-a[j];\n write(j,' ');\n kt[j]:=false;\n break;\n end;\n for j:=1 to n do\n if (k-a[j]=0)and(kt[j]=true) then\n begin\n kt[j]:=false;\n writeln(j);\n break;\n end;\n end;\nend."}, {"source_code": "program mirovanie;\nvar n,i,s,i2:integer; q:array[1..101] of integer;\nbegin\n readln(n);\n for i:=1 to n do begin read(q[i]); s:=s+q[i]; end;\n s:=s*2 div n;\n for i:=1 to n do\n begin\n if q[i]<>0 then\n for i2:=i+1 to n do\n begin\n if q[i]+q[i2]=s then begin writeln(i,' ',i2); q[i2]:=0; break; end;\n end;\n end;\nend."}, {"source_code": "var\na:array[1..10000]of longint;\nn,sum:longint;\nc,i,j:longint;\nbol:boolean;\nbegin\nreadln(N);\nfor i:=1 to n do begin\nread(a[i]);\nsum:=sum+a[i];\nend;\nfor i:=1 to n div 2 do begin\nbol:=false;\n for j:=1 to n do begin\n for c:=1 to n do\n if (a[j]+a[c]=(sum div (n div 2)))and(j<>c) then begin\n writeln(j,' ',c);\n a[c]:=-10;\n a[j]:=-10;\n bol:=true;\n break;\n end;\n if bol then break;\n end;\nend;\nend."}, {"source_code": "var mai,mi,min,max,n,i,o,k:integer;\na:array [1..100]of integer;\nbegin\nread(n);\nmin:=101;\nfor i:=1 to n do\nread(a[i]);\n while o=max)and(a[i]>0)then begin max:=a[i];mai:=i end ;\n if (a[i]0)then begin min:=a[i];mi:=i;end;\n end;\n a[mai]:=-1;\n a[mi]:=-1;\n max:=0;\n min:=101;\n writeln(mi,' ',mai);\n end;\n end."}, {"source_code": "var\n n,sum,equal,i,j,d : integer;\n a,t,res : array[1..100] of integer;\n kt : array[1..100] of boolean;\nBEGIN\n readln(n);\n sum:= 0;\n for i:=1 to n do\n begin\n read(a[i]);\n sum:= sum+a[i];\n end;\n equal:= sum div (n div 2);\n fillchar(kt,sizeof(kt),true);\n d:= 1;\n kt[1]:= false;\n res[1]:= 1;\n t[1]:= a[1];\n for i:=1 to n do\n for j:=1 to n do\n if (kt[j]) and (t[i] <> equal) then\n if t[i] + a[j] = equal then\n begin\n writeln(res[i],' ',j);\n t[i]:= t[i]+a[j];\n kt[j]:= false;\n end\n else if t[i] = 0 then\n begin\n t[i]:= a[j];\n inc(d);\n res[d]:= j;\n kt[j]:= false;\n end;\nEND."}, {"source_code": "var\n n, k, q, p, i, z, x: integer;\n mas, mas2: array [1..100] of integer;\n\nbegin\n readln(n);\n q := n + 1;\n for i := 1 to n do\n read(mas[i]);\n \n for i := 1 to n do \n begin\n x := x + 1; \n mas2[i] := x; \n end;\n \n repeat\n k := 1; \n for i := 1 to n - 1 do \n if mas[i] < mas[i + 1] then \n begin\n p := mas[i];\n mas[i] := mas[i + 1];\n mas[i + 1] := p;\n p := mas2[i];\n mas2[i] := mas2[i + 1];\n mas2[i + 1] := p;\n k := 0;\n end;\n until k = 1;\n \n for i := 1 to n div 2 do\n begin\n z := z + 1;\n q := q - 1;\n writeln(mas2[z], ' ', mas2[q]);\n end;\n \nend.\n"}, {"source_code": "var i,j,n:longint;\n a,b:array[0..1100000] of longint;\n\nprocedure sort(l,r:longint);\n var\n i,j,x,y:longint;\n begin\n i:=l;\n j:=r;\n x:=a[l+random(r-l+1)];\n repeat\n while (a[i]x) do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if lj) and (kt[j]=0) then\n if a[j]=g then\n begin\n kt[j]:=1;\n writeln(i,' ',j);\n break;\n end;\n end;\n end;\n end;\nend;\n\nbegin\n//mo;\nsolve;\nend."}, {"source_code": "var\nb:array[1..200]of boolean;\na:array[1..200]of longint;\nn,i,j,f,sum:longint;\nbegin\n fillchar(b,sizeof(b),true);\n read(n);\n for I:=1 to n do\n begin\n read(a[i]);\n sum:=a[i]+sum;\n end;\n sum:=sum*2 div n;\n f:=0;\n for i:=1 to n do\n begin\n if b[i]=true\n then begin\n for j:=i+1 to n do\n if b[j]=true\n then if a[j]+a[i]=sum\n then begin\n f:=f+2;\n b[i]:=false;\n b[j]:=false;\n writeln(i,' ',j);\n break;\n end;\n end;\n if f=n\n then exit;\n end;\nend.\n"}, {"source_code": "var a,c:array[1..100]of byte;n,i:byte;\nprocedure sort(l,r:byte);\nvar i,j,x,y:byte;\nbegin\n i:=l;j:=r;x:=a[(l+r) div 2];repeat while a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;y:=c[i];c[i]:=c[j];c[j]:=y;inc(i);j:=j-1;\n end;until i>j;if lj)and(a[j]+a[i]=s div (n div 2))and(f[j]=true) then\n begin\n f[j]:=false;writeln(j);break;\n end;\nend;\nend.\n"}, {"source_code": "program zzz;\nvar n,i,j,sum:integer;\n a:array[1..100]of integer;\nbegin\n readln(n);\n sum:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n sum:=(sum*2) div n;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]+a[j]=sum\n then begin\n writeln(i,' ',j);\n a[i]:=0;\n a[j]:=0;\n end;\n \nend."}, {"source_code": "var\n a: array [1..100] of integer;\n i, k, l, j: integer;\n\n\nbegin\n read(k); \n \n for i := 1 to k do begin read(a[i]);l := l + a[i]; end;\n \n for i := 1 to k do \n if a[i] = 0 then continue else\n for j := i+1 to k do \n if a[i] = (l div (k div 2)) - a[j] then begin\n a[i] := 0;\n a[j] := 0;\n writeln(i, ' ', j);\n end;\n \n \nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,s:longint;\n a:array [1..100000] of longint;\nprocedure nhap;\n var\n i:longint;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n inc(s,a[i]);\n end;\n s:=s div (N div 2);\n end;\nprocedure xuat;\n var\n i,j:longint;\n begin\n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n begin\n if a[i]+a[j]=s then\n begin\n writeln(i,' ',j);\n a[j]:=0;\n break;\n end;\n end;\n end;\n close(input); close(output);\n end;\nbegin\nnhap;\nxuat;\nend.\n"}, {"source_code": "var\na:array[1..101] of longint;\nused:array[1..101] of boolean;\ni,n,s,each,j,k,p:longint;\nbegin\nreadln(n);\ns:=0;\nfor i:=1 to n do\nbegin\nread(a[i]);\ns:=s+a[i];\nend;\neach:=(s*2) div n;\nfor i:=1 to n do\nused[i]:=false;\n\nfor i:=1 to (n div 2) do\nbegin\n for j:=1 to n do\n if not used[j] then\n begin\n write(j,' ');\n used[j]:=true;\n p:=a[j];\n break;\n end;\n\n for k:=j+1 to n do\n if (not used[k]) and (a[k]=each-p) then\n begin\n writeln(k);\n used[k]:=true;\n break;\n end;\n\nend;\n\nend."}, {"source_code": "const\n inp = 'input.txt';\n out = 'output.txt';\n maxn = 100;\n\nvar\n n, sum : longint;\n a, id : array[0..maxn] of longint;\n free : array[0..maxn] of boolean;\n\nprocedure init;\n var i : Longint;\n begin\n sum := 0;\n readln(n);\n for i := 1 to n do\n begin\n read(a[i]);\n id[i] := i;\n sum := sum + a[i];\n end;\n sum := sum div (n div 2);\n end;\n\nprocedure solve;\n var i, j : longint;\n begin\n fillchar(free, sizeof(free), true);\n for i := 1 to n - 1 do\n if free[i] then\n begin\n for j := i + 1 to n do\n if free[j] then\n if a[i] + a[j] = sum then\n begin\n writeln(i,' ', j);\n free[j] := false;\n break;\n end;\n end;\n end;\n\nbegin\n //assign(input, inp); reset(input);\n //assign(output, out); rewrite(output);\n init;\n solve;\nend."}, {"source_code": "var i,j,n,k,k1,q:longint;\n a:array[1..100,1..2] of longint;\nBEGIN\nreadln(n);\nfor i:=1 to n do \n a[i,2]:=i;\nfor i:=1 to n do \n read(a[i,1]);\n\nfor i := 1 to n-1 do\n for j := 1 to n-i do\n if a[j,1] > a[j+1,1] then\n begin\n k:=a[j,1];\n k1:=a[j,2];\n a[j,1]:=a[j+1,1];\n a[j,2]:=a[j+1,2];\n a[j+1,1]:=k;\n a[j+1,2]:=k1;\n end;\n\n q:=n;\nfor i:=1 to n div 2 do \n begin\n writeln(a[i,2],' ',a[q,2]);\n dec(q);\n end;\n \n \nEND."}, {"source_code": "\nvar a:array[1..100,0..1]of integer;\ni,j,n,sw:integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i,1]);\n a[i,0]:=i;\n end;\n for j:=1 to n-1 do\n for i:=1 to n-1 do\n if a[i,1] < a[i+1,1] then\n begin\n sw:=a[i,1];\n a[i,1]:=a[i+1,1];\n a[i+1,1]:=sw;\n sw:=a[i,0];\n a[i,0]:=a[i+1,0];\n a[i+1,0]:=sw;\n end;\n i:=1;\n j:=n;\n while i <= j do\n begin\n writeln(a[i,0],' ',a[j,0]);\n i:=i+1;\n j:=j-1;\n end;\nend."}], "negative_code": [{"source_code": "begin\n var n:=readinteger();\n var a:=arr(0)*n;\n var s:=0;\n for var i:=0 to n-1 do\n begin\n read(a[i]);\n s+=a[i];\n end;\n if s div (n)=a[0] then\n begin\n for var i:=1 to n div 2 do\n writeln(i*2-1,' ',i*2);\n exit();\n end;\n var x:=s div (n div 2);\n for var i:=0 to n-1 do\n begin\n if a[i]=-1 then\n continue;\n var g:=x-a[i];\n for var j:=i to n-1 do\n begin\n if a[j]=-1 then\n continue;\n if (g=a[j])and(j<>i) then\n begin\n a[i]:=-1;\n a[j]:=-1;\n writeln(i+1,' ',j+1);\n break;\n end;\n end;\n end;\nend."}, {"source_code": "begin\n var n:=readinteger();\n var a:=arr(0)*n;\n var s:=0;\n for var i:=0 to n-1 do\n begin\n read(a[i]);\n s+=a[i];\n end;\n if s div (n)=a[0] then\n begin\n for var i:=1 to n div 2 do\n writeln(i*2-1,' ',i*2);\n exit();\n end;\n var x:=s div (n div 2);\n for var i:=0 to n-1 do\n begin\n var g:=x-a[i];\n for var j:=i to n-1 do\n if (g=a[j])and(j<>i) then\n begin\n writeln(i+1,' ',j+1);\n break;\n end;\n end;\nend."}, {"source_code": "var n,i,tong,tb,j:longint;\n a:array[1..100]of integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n tong:=tong+a[i];\n end;\n tb:=tong*2 div n;\n for i:=1 to n do\n begin\n for j:=i+1 to n do\n if a[i] + a[j] = tb then\n begin\n writeln(i,' ',j);\n break;\n end;\n end;\n readln;\nend."}, {"source_code": "var\nb:array[1..200]of boolean;\na:array[1..200]of longint;\nn,i,j,f,sum:longint;\nbegin\n fillchar(b,sizeof(b),true);\n read(n);\n for I:=1 to n do\n begin\n read(a[i]);\n sum:=a[i]+sum;\n end;\n sum:=sum*2 div n;\n f:=0;\n for i:=1 to n do\n begin\n if b[i]=true\n then begin\n for j:=i+1 to n do\n if b[j]=true\n then if a[j]+a[i]=sum\n then begin\n f:=f+2;\n b[i]:=false;\n b[j]:=false;\n writeln(i,' ',j);\n end;\n end;\n if f=n\n then exit;\n end;\nend."}, {"source_code": "Const Finp='';\n Fout='';\n maxN=100;\nVar n,val:longint;\n a,dau:array[1..maxN] of longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\nEnd;\nProcedure FindVal;\nVar i,j,sum:longint;\nBegin\n sum:=0;\n for i:=1 to n do\n sum:=sum+a[i];\n val:=(sum div n)*2;\nEnd;\nProcedure Xuat;\nVar f:Text;\n i,j,cnt,lc:longint;\nBegin\n assign(f,fout); rewrite(f);\n fillchar(dau,sizeof(dau),0);\n cnt:=0; lc:=0;\n for i:=1 to n-1 do\n if dau[i]=0 then\n begin\n for j:=i+1 to n do\n if (a[i]+a[j]=val) and (dau[j]=0) then\n begin\n dau[j]:=1;\n writeln(f,i,' ',j);\n inc(cnt);\n if cnt=n div 2 then\n lc:=1;\n break;\n end;\n if lc=1 then\n break;\n end;\n close(f);\nEnd;\n\nBegin\n nhap;\n findval;\n xuat;\nEnd."}, {"source_code": "program zzz;\nvar n,i,j,sum:integer;\n a:array[1..100]of integer;\nbegin\n readln(n);\n sum:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n sum:=(sum div n)*2;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]+a[j]=sum\n then begin\n writeln(i,' ',j);\n a[i]:=0;\n a[j]:=0;\n end;\n \nend."}, {"source_code": "Var\n n, k: Integer;\n a: Array [1..100] of Integer;\n \nBegin\n Read(n);\n For Var i := 1 to n do\n Read(a[i]);\n For Var i := 1 to n - 1 do\n For Var j := 1 to n - i do\n If a[j] > a[j + 1] then Begin\n k := a[j];\n a[j] := a[j + 1];\n a[j + 1] := k\n End;\n For Var i := 1 to n div 2 do\n Writeln(i, ' ', n - i + 1)\nEnd."}, {"source_code": "//i am so sorry but i have to do thissssssssssssssssssssssss\nconst\n fin='701A.inp';fon='701A.out';\nvar i,j,n,g,s,t:longint;\n a:array[1..100] of longint;\n kt:array[1..100] of longint;\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\n//plz godddddddd helppppp meeeeeeeee you are the shadow to my life can u feel oooooooooooooooooooooooooo\nprocedure solve;\nbegin\nreadln(n);\ns:=0;\nfor i:=3 to n do\n begin\n read(a[i]);\n kt[i]:=0;\n s:=s+a[i];\n end;\nt:=s div (n div 2);\nfor i:=1 to n-1 do\n begin\n if kt[i]=0 then\n begin\n kt[i]:=1;\n g:=t-a[i];\n for j:=i+1 to n do\n begin\n if (i<>j) and (kt[j]=0) then\n if a[j]=g then\n begin\n kt[j]:=1;\n writeln(i,' ',j);\n break;\n end;\n end;\n end;\n end;\nend;\n\n//ho lee schitt\nbegin\n//mo;\nsolve;\nend.\n//damn it i failed, plz dont skip me :((\n"}, {"source_code": "Var a:array[1..100] of longint;sum,i,j,n,u:longint;used:array[1..100] of boolean;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n u:=(sum div n)*2;\n for i:=1 to n do\n begin\n if used[i]<>true then\n for j:=i+1 to n do\n if (used[j]<>true) and (u-a[i]=a[j]) then\n begin\n writeln(i,' ',j);\n used[i]:=true;\n used[j]:=true;\n end;\n end;\nEnd."}, {"source_code": "Var a:array[1..100] of longint;sum,i,j,n,u:longint;used:array[1..100] of boolean;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n u:=(sum div n)*2;\n for i:=1 to n do\n begin\n if used[i]<>true then\n for j:=i+1 to n do\n if (used[j]<>true) and (u-a[i]=a[j]) then\n begin\n writeln(i,' ',j);\n used[i]:=true;\n used[j]:=true;\n break;\n end;\n end;\nEnd."}, {"source_code": "var\n a,b,c,d,n,m,p,i,i2,i4:integer;\n q:array[1..100] of integer;\n w:array[1..100] of integer;\n s:string;\nBegin\n readln(p);\n m:=999;\n n:=0;\n for i:=1 to p do begin\n read(q[i]);\n if nq[i] then m:=q[i];\n end;\n\n for i:=1 to n do\n for i2:=1 to n do\n if ((n+m)-(q[i]+q[i2])=0) and (i<>i2) and (q[i]<>0) and (q[i2]<>0) then begin\n writeln(i,' ',i2);\n q[i]:=0;\n q[i2]:=0;\n end;\nend."}, {"source_code": "var\n kt:array [0..1000] of boolean;\n a:array [0..1000] of longint;\n i,j,n,s:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\ns:=s*2 div n;\nfor i:=1 to n do\n if kt[i]=false then\n begin\n kt[i]:=true;\n write(i,' ');\n for j:=i+1 to n do\n if s-a[j]=a[i] then\n begin\n writeln(j);\n kt[j]:=true;\n break;\n end;\n end;\nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,s:longint;\n a:array [1..100000] of longint;\nprocedure nhap;\n var\n i:longint;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n inc(s,a[i]);\n end;\n s:=s div (N div 2);\n end;\nprocedure xuat;\n var\n i,j:longint;\n begin\n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n begin\n if a[i]+a[j]=s then\n begin\n writeln(i,' ',j);\n a[j]:=0;\n end;\n end;\n end;\n close(input); close(output);\n end;\nbegin\nnhap;\nxuat;\nend.\n"}, {"source_code": "VAR\n n:longint;\n a,b:array[1..100] of longint;\n\nProcedure Nhap;\n Var\n i:longint;\n Begin\n Read(n);\n For i:=1 to n do\n BEgin\n Read(a[i]);\n b[i]:=i;\n End;\n End;\n\nProcedure Xuli;\n VAr\n i,j,x:longint;\n Begin\n For i:=1 to n-1 do\n For j:=i+1 to n do\n If a[i] j then \n If (B[i] = 0) and (B[j] = 0) then \n If A[i] + A[j] = tmp then \n Begin\n Writeln(i ,' ', j);\n B[i] := 1;\n B[j] := 1;\n End;\nIf n = 2 then Writeln('1 2');\nEnd."}, {"source_code": "Var i , n , j , tmp : Integer;\n A , B : Array [1..100] of Integer;\n \nBegin\nReadln(n); tmp := 0;\nFillchar(B , sizeof(B) , 0);\nFor i := 1 to n do\n Begin\n Read(A[i]);\n tmp := tmp + A[i];\n End;\ntmp := tmp div n * 2;\nFor i := 1 to n do\n For j := 1 to n do\n If i <> j then \n If (B[i] = 0) and (B[j] = 0) then \n If A[i] + A[j] = tmp then \n Begin\n Writeln(i ,' ', j);\n B[i] := 1;\n B[j] := 1;\n End;\nEnd."}, {"source_code": "program cards;\nvar i,j,s,max:integer;\n a,num,sp:array[1..1000] of integer;\n v:array[1..1000] of boolean;\nbegin\n s:=0;fillchar(v,sizeof(v),false);\n for i:=1 to 5 do\n begin\n read(a[i]);\n s:=s+a[i];\n num[a[i]]:=num[a[i]]+1;\n end;\n for i:=1 to 5 do\n begin\n if (num[a[i]]=2) and (v[i]=false) then begin sp[i]:=a[i]*num[a[i]];for j:=1 to 5 do if a[j]=a[i] then v[j]:=true; end;\n if (num[a[i]]>=3) and (v[i]=false) then begin sp[i]:=a[i]*3;for j:=1 to 5 do if a[j]=a[i] then v[j]:=true;end;\n end;\n for i:=1 to 5 do\n if max<=sp[i] then max:=sp[i];\n writeln(s-max);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Aproblem;\nvar a,v:array[0..100] of integer;\n i,n,s,ii:integer;\nbegin\n readln(n); s:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n s:=trunc(2*s/n);\n fillchar(v,sizeof(v),0);\n for i:=1 to n do\n begin\n if v[i]=0 then\n begin\n for ii:=1 to n do\n begin\n if (i<>ii) and (a[i]+a[ii]=s) and (v[ii]=0) then\n begin\n writeln(i,' ',ii);\n v[i]:=1;v[ii]:=1;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "program cards;\nvar i,j,s,max:integer;\n a,num,sp:array[1..1000] of integer;\n vv:array[1..1000] of boolean;\nbegin\n s:=0;fillchar(vv,sizeof(vv),false);\n for i:=1 to 5 do\n begin\n read(a[i]);\n s:=s+a[i];\n num[a[i]]:=num[a[i]]+1;\n end;\n for i:=1 to 5 do\n begin\n if (num[a[i]]=2) and (vv[i]=false) then begin sp[i]:=a[i]*num[a[i]];for j:=1 to 5 do if a[j]=a[i] then vv[j]:=true; end;\n if (num[a[i]]>=3) and (vv[i]=false) then begin sp[i]:=a[i]*3;for j:=1 to 5 do if a[j]=a[i] then vv[j]:=true;end;\n end;\n for i:=1 to 5 do\n if max<=sp[i] then max:=sp[i];\n writeln(s-max);\nend.\n"}], "src_uid": "6e5011801ceff9d76e33e0908b695132"} {"source_code": "const \n\tmaxn=2520;\nvar\n f:array[0..18,0..2520,0..47] of int64;\n id:array[0..2530] of longint;\n w:array[0..18] of longint;\n t,i:longint;\n l,r:int64;\nfunction gcd(a,b:int64):int64;\nbegin\n\tif b=0 then exit(a);\n\texit(gcd(b,a mod b))\nend;\n\nfunction lcm(a,b:int64):int64;\nvar\n g:int64;\nbegin\n g:=gcd(a,b);\n\tlcm:=a div g * b;\nend;\n\nfunction dfs(p,ps,pl:int64;bz:boolean):int64;\nvar \n\tns,nl,h,sum:int64; \n\ti:longint;\nbegin\n if p=-1 then \n\tbegin\n\t\tif ps mod pl=0 then exit(1)\n\t\telse exit(0);\n\tend;\n if (bz=false)and(f[p,ps,id[pl]]<>-1) then exit(f[p,ps,id[pl]]);\n sum:=0;\n if bz then h:=w[p] else h:=9;\n for i:=0 to h do\n begin\n ns:=(ps*10+i) mod maxn;\n if i>0 then nl:=lcm(pl,i)\n else nl:=pl;\n\t\tif bz and (i=w[p]) then sum:=sum+dfs(p-1,ns,nl,true)\n\t\telse sum:=sum+dfs(p-1,ns,nl,false);\n end;\n if bz=false then f[p,ps,id[pl]]:=sum;\n\texit(sum);\nend;\n\nfunction work(x:int64):int64;\nvar \n\tp:longint;\nbegin\n p:=0;\n while x>0 do\n begin\n w[p]:=x mod 10;\n x:=x div 10;\n inc(p);\n end;\n exit(dfs(p-1,0,1,true));\nend;\nbegin\n for i:=1 to maxn do\n\tbegin\n\t\tif maxn mod i=0 then\n\t\tbegin\n\t\t\tid[i]:=l; \n\t\t\tinc(l);\n\t\tend;\n end;\n fillchar(f,sizeof(f),255);\n readln(t);\n\tfor i:=1 to t do\n\tbegin\n readln(l,r);\n writeln(work(r)-work(l-1));\n end;\nend.", "positive_code": [{"source_code": "var n,m,i,j,t,q,q1:longint;\n ans:int64;\n s,s1:string;\n a,b,b1:array[0..70]of longint;\n f:array[0..20,0..49,0..2520,0..1]of int64;\n c:array[0..2520]of longint;\n flag:boolean;\n ged:array[0..49,0..9]of longint;\nfunction gcd(a,b:longint):longint;\nbegin\n if a mod b=0 then exit(b)\n else gcd:=gcd(b,a mod b);\nend;\nfunction gdd(a,b:longint):longint;\nbegin\n if (a=0) or (b=0)then exit(0);\n exit(a*b div gcd(a,b));\nend;\nfunction work(s:string):int64;\nvar i,j,k,tmp,l:longint;\n an:int64;\nbegin\n a[0]:=0;\n for i:=1 to length(s) do begin\n inc(a[0]);\n a[a[0]]:=ord(s[i])-48;\n end;\n if not flag then begin\n dec(a[a[0]]);\n i:=a[0];\n while (a[i]<0)and(i>0) do begin\n inc(a[i],10);\n dec(a[i-1]);\n dec(i);\n end;\n end;\n if a[1]=0 then\n for i:=1 to a[0]-1 do\n a[i]:=a[i+1];\n fillchar(f,sizeof(f),0);\n for i:=1 to a[1]-1 do\n f[1,i,i,1]:=1;\n f[1,a[1],a[1],0]:=1;\n f[1,49,0,1]:=1;\n q:=252;\n for i:=1 to a[0]-2 do begin\n for j:=1 to b[0]+1 do\n for k:=0 to q-1 do\n if (f[i,j,k,0]<>0)or(f[i,j,k,1]<>0) then begin\n for l:=0 to 9 do begin\n if (b[j]<>0)and(l<>0) then\n tmp:=c[ged[j,l]]\n else if b[j]<>0 then tmp:=j\n else tmp:=c[l];\n if l0)or(f[i,j,k,1]<>0) then begin\n for l:=0 to 9 do begin\n if (b[j]<>0)and(l<>0) then\n tmp:=c[gdd(b[j],l)]\n else if b[j]<>0 then tmp:=j\n else tmp:=c[l];\n if l0) and (y>0) do\n if x>y then x := x mod y\n else y := y mod x;\n gcd := x+y;\n End;\n\n Function gca(x,y:longint):longint;\n Begin\n gca := (x div gcd(x,y))*y;\n end;\n\n\n Function next(link,x:longint):longint;\n Begin\n If x=0 then\n Begin\n next := link;\n exit;\n End;\n x := gca(x,a[link]);\n While a[link]<>x do link := link+1;\n next := link;\n End;\n\n Function f(x:int64):int64;\n VAr\n count :longint;\n\n function go(flag,count,ost,link : longint):int64;\n VAr\n j:longint;\n sum : int64;\n Begin\n If count=0 then\n Begin\n If ost mod a[link]=0 then go :=1 else go := 0;\n exit;\n End;\n If c[flag,count,ost,link]=0 then\n Begin\n sum := 0;\n If flag=0 then\n Begin\n For j := 0 to b[count] do\n sum := sum+go(ord(j0 do\n begin\n inc(len); a[len]:=xx mod 10; xx:=xx div 10;\n end;\n\n for i:=0 to a[1] do f[1,num[i],i,0]:=1;\n if len<>1 then for i:=a[1]+1 to 9 do f[1,num[i],i,1]:=1;\n\n for i:=2 to len do\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n if f[i-1,s1,s2,1]+f[i-1,s1,s2,0]=0 then continue;\n\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n f[i,lcm[s1,j],divv[s2+j*mi[i-1]],0]:=f[i,lcm[s1,j],divv[s2+j*mi[i-1]],0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n end\n else\n f[i,s1,s2,0]:=f[i,s1,s2,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n if i<>len then\n for j:=a[i]+1 to 9 do\n f[i,lcm[s1,j],divv[s2+j*mi[i-1]],1]:=f[i,lcm[s1,j],divv[s2+j*mi[i-1]],1]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n if a[i]<>0 then\n begin\n inc(f[i,lcm[s1,a[i]],divv[s2+a[i]*mi[i-1]],1],f[i-1,s1,s2,1]); inc(f[i,lcm[s1,a[i]],divv[s2+a[i]*mi[i-1]],0],f[i-1,s1,s2,0]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]); inc(f[i,s1,s2,1],f[i-1,s1,s2,1]);\n end;\n end;\n\n for s1:=1 to op-1 do\n for s2:=0 to 2519 do\n if s2 mod num1[s1]=0 then ans:=ans+f[len,s1,s2,0];\n\n exit(ans);\nend;\n\nbegin \n for i:=1 to 50400 do divv[i]:=i mod 2520;\n\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(op); num[i]:=op; num1[op]:=i;\n end;\n\n inc(op); num[0]:=op;\n\n for i:=1 to 48 do\n for j:=1 to 9 do\n lcm[i,j]:=num[num1[i]*j div gcd(num1[i],j)];\n\n for i:=1 to 9 do lcm[49,i]:=num[i];\n\n mi[0]:=1; for i:=1 to 18 do mi[i]:=mi[i-1]*10 mod 2520;\n\n readln(t);\n\n while t>0 do\n begin\n readln(l,r);\n\n writeln(doit(r)-doit(l-1));\n\n dec(t);\n end;\nend.\n\n"}, {"source_code": "program task;\n{$IFDEF DEBUG}{$R+,I+,Q+,S+,O-}{$ELSE}{$R-,I-,Q-,S-,O+}{$ENDIF}\nuses SysUtils;\nconst\n F_LCM=504; //LCM of all digits except 5\n//[numLength|LessOrEqual|DivisibleBy5|mod F_LCM|usedDigitsSpecificator]\n//\\______ \\__ \\__ \\_ \\__ __(except5)_/\nvar // \\ \\ \\ \\ \\ /\n a:array[1..19,false..true,false..true,0..F_LCM-1,0..23]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..23,0..9]of byte;\n tmp_a:array[0..23]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,f,t,l:integer;\n fl:boolean;\nbegin\n if v=0 then begin result:=1; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n inc(a[1,(i<=b[1]),(i=5)or(i=0),i,AddDigit[0,i]]);\n f:=1;\n for i:=2 to l do\n begin\n f:=(f*10)mod F_LCM;\n for fl:=false to true do\n for j:=0 to 9 do\n begin\n t:=(f*j)mod F_LCM;\n for p:=0 to 23 do\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j5 then\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 23 do\n begin\n AddDigit[i,0]:=i;\n AddDigit[i,5]:=i;\n for j:=1 to 9 do if j<>5 then\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n\n(*OLD SLOW STABLE CODE*\nprogram task;\n{$R-,I-,Q-,S-,O+}\nconst\n F_LCM=2520; //LCM of all digits\n//[num length|LessOrEqual|mod F_LCM|used digits specificator]\n//\\______ \\_ \\_ | _________________/\nvar // \\ \\ \\ | /\n a:array[1..19,false..true,0..2519,0..47]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..47,0..9]of byte;\n DMd:array[0..2519,2..19,0..9]of integer;\n tmp_a:array[0..47]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,l:integer;\nbegin\n if v=0 then begin result:=1; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n a[1,(i<=b[1]),i,AddDigit[0,i]]:=1;\n for i:=2 to l do\n for j:=0 to 9 do\n for p:=0 to 47 do\n for k:=0 to F_LCM-1 do\n begin\n inc(a[i,j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillDMd;\nvar i,j,k,t,p:integer;\nbegin\n t:=1;\n for i:=2 to 19 do\n begin\n t:=(t*10)mod F_LCM;\n for j:=0 to 9 do\n begin\n p:=t*j;\n for k:=0 to F_LCM-1 do\n DMd[k,i,j]:=(k+p)mod F_LCM;\n end;\n end;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 47 do\n begin\n AddDigit[i,0]:=i;\n for j:=1 to 9 do\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\n fillDMd;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n\n(*OTHER VARIANT (FASTER)*\nprogram task;\n{$R-,I-,Q-,S-,O+}\nuses SysUtils;\nconst\n F_LCM=2520; //LCM of all digits\n//[num length|LessOrEqual|mod F_LCM|used digits specificator]\n//\\______ \\_ \\_ | _________________/\nvar // \\ \\ \\ | /\n a:array[1..19,false..true,0..2519,0..47]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..47,0..9]of byte;\n tmp_a:array[0..47]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,f,t,l:integer;\n fl:boolean;\nbegin\n if v=0 then begin result:=0; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n a[1,(i<=b[1]),i,AddDigit[0,i]]:=1;\n f:=1;\n for i:=2 to l do\n begin\n f:=(f*10)mod F_LCM;\n for j:=0 to 9 do\n begin\n t:=(f*j)mod F_LCM;\n for fl:=false to true do\n for p:=0 to 47 do\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 47 do\n begin\n AddDigit[i,0]:=i;\n for j:=1 to 9 do\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n r, r1, lr, lr1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..2500000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n l, l1 : int64;\n\nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n lr := -1;\n for i := 1 to t do begin\n read(l, r);\n {if r[i] <> r[i - 1] then\n r1[i] := f(r[i])\n else\n r1[i] := r1[i - 1];}\n if r = lr then\n r1 := lr1\n else\n r1 := f(r);\n l1 := f(l - 1);\n { if l[i] <> l[i - 1] then\n l1[i] := f(l[i] - 1)\n else\n l1[i] := l[i - 1]; }\n writeln(r1 - l1);\n lr := r;\n lr1 := r1;\n end;\n\nend.\n"}, {"source_code": "const\n rk:array[0..4]of longint=(1,4,3,2,2);\n zz:array[0..9,1..2]of longint=((1,0),(1,0),(1,1),(2,1),(1,2),(3,1),(1,0),(4,1),(1,3),(2,2));\nvar\n st,en:int64;\n i,j,k,o,l,x,u,y,test:longint;\n kk,zk,oo,tok:array[1..4]of longint;\n fen,e,bb:array[1..20]of longint;\n f:array[1..19,0..47,0..2519]of int64;\nfunction wr(x,y:longint):longint;\nvar\n i,j:longint;\nbegin\n if y<2 then exit(x);\n j:=x;\n for i:=1 to 4 do begin\n kk[i]:=j mod rk[i];\n j:=j div rk[i];\n end;\n if kk[zz[y,1]]0) then exit(false);\n if (y mod 7<>0)and(kk[4]=1) then exit(false);\n j:=1;\n for i:=1 to kk[1] do j:=j*2;\n if y mod j<>0 then exit(false);\n j:=1;\n for i:=1 to kk[2] do j:=j*3;\n if y mod j<>0 then exit(false);\n exit(true);\nend;\nfunction bing(j:longint):longint;\nvar\n i,k,u:longint;\nbegin\n if j=0 then begin\n k:=0;\n for i:=4 downto 1 do begin\n k:=(k+zk[i])*rk[i-1];\n end;\n exit(k);\n end;\n k:=j;\n for i:=1 to 4 do begin\n oo[i]:=k mod rk[i];\n k:=k div rk[i];\n if oo[i]2519;\n end;\n exit(dd);\nend;\nprocedure zb;\nvar\n i,j:longint;\nbegin\n j:=0;\n for i:=19 downto 1 do begin\n if bb[i]<2 then continue;\n if bb[i]=6 then begin\n j:=wr(wr(j,2),3);\n end;\n j:=wr(j,bb[i]);\n end;\n for i:=1 to 4 do begin\n zk[i]:=j mod rk[i];\n j:=j div rk[i];\n end;\nend;\nfunction work(x:int64):int64;\nvar\n i,j,k:longint;\n tmp,ww:int64;\nbegin\n fillchar(bb,sizeof(bb),0);\n zb;\n tmp:=x;\n ww:=0;\n for i:=1 to 19 do begin\n fen[i]:=tmp mod 10;\n tmp:=tmp div 10;\n end;\n k:=0;\n for i:=19 downto 1 do begin\n for j:=1 to fen[i] do begin\n ww:=ww+dp(i-1,k);\n k:=(k+e[i])mod 2520;\n inc(bb[i]);\n zb;\n end;\n end;\n dec(ww);\n exit(ww);\nend;\nbegin\n readln(test);\n for i:=0 to 9 do begin\n if i=6 then f[1,5,6]:=1 else\n f[1,wr(0,i),i]:=1;\n end;\n u:=1;\n e[1]:=1;\n for i:=1 to 18 do begin\n u:=u*10 mod 2520;\n e[i+1]:=u;\n for j:=0 to 47 do begin\n for k:=0 to 2519 do begin\n if f[i,j,k]=0 then continue;\n for o:=0 to 9 do begin\n x:=(o*u+k)mod 2520;\n if o=6 then begin\n y:=wr(wr(j,2),3);\n f[i+1,y,x]:=(f[i+1,y,x]+f[i,j,k]);\n continue;\n end;\n y:=wr(j,o);\n f[i+1,y,x]:=(f[i+1,y,x]+f[i,j,k]);\n end;\n end;\n end;\n end;\n for test:=1 to test do begin\n readln(st,en);\n writeln(work(en+1)-work(st));\n end;\nend.\n"}, {"source_code": "//http://www.cppblog.com/Yuan/archive/2011/01/24/139201.html\nprogram zxh55d;\nconst base=2520;\nvar\n dp:array[0..18,0..base,0..47] of int64;\n id:array[0..base+10] of longint;\n digit:array[0..18] of longint;\n team:longint;\n left,right:int64;\n \nfunction gcd(a,b:longint):longint;\nvar c:longint;\nbegin\n while (b<>0) do\n begin\n c:=b; b:=a mod b; a:=c;\n end;\n gcd:=a;\nend;\n\nfunction lcm(a,b:longint):longint;\nbegin\n exit( a div gcd(a,b) * b );\nend;\n\nprocedure init;\nvar num,i:longint;\nbegin\n num:=0;\n for i:=1 to base do\n if base mod i=0 then\n begin\n id[i]:=num; inc(num);\n end;\n fillchar(dp,sizeof(dp),255);\nend;\n\nfunction dfs(pos,presum,prelcm:longint; doing:boolean):int64;\nvar nowsum,nowlcm,i,ed:longint; ans:int64;\nbegin\n if pos=-1 then exit(ord(presum mod prelcm=0));\n if (not doing)and(dp[pos,presum,id[prelcm]]<>-1) then\n exit(dp[pos,presum,id[prelcm]]);\n\n ans:=0;\n if doing then ed:=digit[pos] else ed:=9;\n for i:=0 to ed do\n begin\n nowsum:=(presum*10+i) mod base;\n nowlcm:=prelcm;\n if i>0 then\n begin\n nowlcm:=lcm(nowlcm,i);\n end;\n ans:=ans+dfs(pos-1,nowsum,nowlcm,doing and (i=ed));\n end;\n\n if not doing then\n dp[pos,presum,id[prelcm]]:=ans;\n exit(ans);\nend;\n\nfunction cal(x:int64):int64;\nvar pos:longint;\nbegin\n pos:=0;\n while x>0 do\n begin\n digit[pos]:=x mod 10;\n x:=x div 10;\n inc(pos);\n end;\n exit( dfs(pos-1,0,1,true) );\nend;\n\nbegin\n init;\n readln(team);\n while team>0 do\n begin\n dec(team);\n readln(left,right);\n writeln( cal(right)-cal(left-1) );\n end;\nend.\n\n"}, {"source_code": "var\nu:array[0..100000]of boolean;\nyy,i,j,ll,tt,t:longint;\nl,r:int64;\ncc:array[0..19]of longint;\nf:array[boolean,0..19,0..2520,0..48]of int64;\nob,numb:array[0..2520]of longint;\nnext:array[0..48,0..9]of longint;\nnc:array[0..2520,0..9]of longint;\n\nfunction gcd(x,y:longint):longint;\n begin\n while (x>0)and(y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n gcd:=x+y;\n end;\n\nfunction lcm(x,y:longint):longint;\n begin\n if (y=0)or(x=0) then lcm:=x+y\n else lcm:=x div gcd(x,y)*y;\n end;\n\nfunction run(v:longint;ok:boolean;ost1,ost2:longint):int64;\nvar i:longint;\n begin\n if v=0 then\n begin\n if ost1 mod ob[ost2]=0 then run:=1 else run:=0;\n exit;\n end;\n\n if f[ok,v,ost1,ost2]>0 then\n begin\n run:=f[ok,v,ost1,ost2]-1;\n exit;\n end;\n\n\n f[ok,v,ost1,ost2]:=1;\n\n if ok then\n begin\n for i:=0 to cc[v] do\n begin\n if i0 do\n begin\n ll:=ll+1;\n cc[ll]:=x mod 10;\n x:=x div 10;\n end;\n\n fillchar(f[true],sizeof(f[true]),0);\n ans:=run(ll,true,0,1);\n end;\n\n begin\n fillchar(u,sizeof(u),false);\n u[1]:=true;\n for i:=1 to 18 do\n begin\n for j:=2520 downto 1 do\n if u[j] then\n begin\n for yy:=1 to 9 do\n u[lcm(j,yy)]:=true;\n end;\n end;\n\n for i:=0 to 2520 do\n for j:=0 to 9 do\n nc[i,j]:=(i*10+j)mod 2520;\n\n j:=0;\n for i:=1 to 2520 do\n if u[i] then\n begin\n j:=j+1;\n ob[j]:=i;\n numb[i]:=j;\n end;\n for i:=1 to 2520 do\n if u[i] then\n begin\n for j:=0 to 9 do\n next[numb[i],j]:=numb[lcm(i,j)];\n end;\n\n readln(t);\n for tt:=1 to t do\n begin\n readln(l,r);\n writeln(ans(r)-ans(l-1));\n end;\n end."}, {"source_code": "var\n mp:array[0..2520]of shortint;\n q:array[0..400005]of longint;\n dp:array[0..20,0..2520,0..50]of int64;\n t,i,j,k,cnt,top:longint;\n l,r:int64;\nfunction gcd(x,y:longint):longint;\nbegin\n if y=0 then\n exit(x);\n exit(gcd(y,x mod y));\nend;\nfunction _dfs(w,o,p:longint; f:boolean):int64;\nvar\n i,sl:longint;\n _res:int64;\nbegin\n if w=0 then\n begin\n if o mod p=0 then\n exit(1) else\n exit(0);\n end;\n if f and (dp[w][o][mp[p]]<>-1) then\n exit(dp[w][o][mp[p]]);\n if f then\n sl:=9 else\n sl:=q[w];\n _res:=0;\n for i:=0 to sl do\n if i=0 then\n _res:=_res+_dfs(w-1,(o*10+i) mod 2520,p,f or (i<>q[w])) else\n _res:=_res+_dfs(w-1,(o*10+i) mod 2520,p*i div gcd(p,i),f or (i<>q[w]));\n if f then\n dp[w][o][mp[p]]:=_res;\n exit(_res);\nend;\nfunction check(x:int64):int64;\nbegin\n check:=0;\n top:=0;\n while x>0 do\n begin\n inc(top);\n q[top]:=x mod 10;\n x:=x div 10;\n end;\n exit(_dfs(top,0,1,false));\nend;\nbegin\n for i:=0 to 20 do\n for j:=0 to 2520 do\n for k:=0 to 50 do\n dp[i][j][k]:=-1;\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(cnt);\n mp[i]:=cnt;\n end;\n readln(t);\n for i:=1 to t do\n begin\n readln(l,r);\n writeln(check(r)-check(l-1));\n end;\nend."}, {"source_code": "{$Inline on}\nvar\n l,r,xx,ans:int64;\n t,i,j,s1,s2,op,len:longint;\n a,mi:array[0..19] of longint;\n lcm:array[0..49,0..9] of longint;\n divv:array[0..50400] of longint;\n num,num1:array[0..2520] of longint;\n f:array[0..19,0..49,0..2520,0..1] of int64;\nfunction gcd(x,y:longint):longint;\nbegin\n if x mod y=0 then exit(y) else exit(gcd(y,x mod y));\nend;\n\nfunction doit(x:int64):int64; inline;\nbegin\n len:=0; ans:=0; xx:=x; fillchar(f,sizeof(f),0);\n\n while xx<>0 do\n begin\n inc(len); a[len]:=xx mod 10; xx:=xx div 10;\n end;\n\n for i:=0 to a[1] do f[1,num[i],i,0]:=1;\n if len<>1 then for i:=a[1]+1 to 9 do f[1,num[i],i,1]:=1;\n\n for i:=2 to len do\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n if f[i-1,s1,s2,1]+f[i-1,s1,s2,0]=0 then continue;\n\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n f[i,lcm[s1,j],divv[s2+j*mi[i-1]],0]:=f[i,lcm[s1,j],divv[s2+j*mi[i-1]],0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n end\n else\n f[i,s1,s2,0]:=f[i,s1,s2,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n if i<>len then\n for j:=a[i]+1 to 9 do\n f[i,lcm[s1,j],divv[s2+j*mi[i-1]],1]:=f[i,lcm[s1,j],divv[s2+j*mi[i-1]],1]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n if a[i]<>0 then\n begin\n inc(f[i,lcm[s1,a[i]],divv[s2+a[i]*mi[i-1]],1],f[i-1,s1,s2,1]); inc(f[i,lcm[s1,a[i]],divv[s2+a[i]*mi[i-1]],0],f[i-1,s1,s2,0]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]); inc(f[i,s1,s2,1],f[i-1,s1,s2,1]);\n end;\n end;\n\n for s1:=1 to op-1 do\n for s2:=0 to 2519 do\n if s2 mod num1[s1]=0 then ans:=ans+f[len,s1,s2,0];\n\n exit(ans);\nend;\n\nbegin\n for i:=1 to 50400 do divv[i]:=i mod 2520;\n\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(op); num[i]:=op; num1[op]:=i;\n end;\n\n inc(op); num[0]:=op;\n\n for i:=1 to 48 do\n for j:=1 to 9 do\n lcm[i,j]:=num[num1[i]*j div gcd(num1[i],j)];\n\n for i:=1 to 9 do lcm[49,i]:=num[i];\n\n mi[0]:=1; for i:=1 to 18 do mi[i]:=mi[i-1]*10 mod 2520;\n\n readln(t);\n\n while t>0 do\n begin\n readln(l,r);\n\n writeln(doit(r)-doit(l-1));\n\n dec(t);\n end;\nend.\n\n"}], "negative_code": [{"source_code": "Const\n a : array[1..48] of longint=(1,2,3,4,5,6,7,8,9,10,12,14,15,18,20,21,24,28,30,35,36,40,42,45,56,60,63,70,72,84,90,105,120,126,140,168,180,210,252,280,315,360,420,504,630,840,1260,2520);\n ch = 2520;\n\nVAr\n r,e : longint;\n n,m : int64;\n b : array[0..20] of longint;\n c : array[0..20,0..1,0..2519,1..48] of int64;\n\n\n Function gcd(x,y:longint):longint;\n Begin\n While (x>0) and (y>0) do\n if x>y then x := x mod y\n else y := y mod x;\n gcd := x+y;\n End;\n\n Function gca(x,y:longint):longint;\n Begin\n gca := (x div gcd(x,y))*y;\n end;\n\n\n Function next(link,x:longint):longint;\n Begin\n If x=0 then\n Begin\n next := link;\n exit;\n End;\n x := gca(x,a[link]);\n While a[link]<>x do link := link+1;\n next := link;\n End;\n\n Function f(x:int64):int64;\n VAr\n count :longint;\n\n function go(count,flag,ost,link : longint):int64;\n VAr\n j:longint;\n sum : int64;\n Begin\n If count=0 then\n Begin\n If ost mod a[link]=0 then go :=1 else go := 0;\n exit;\n End;\n If c[count,flag,ost,link]=0 then\n Begin\n sum := 0;\n If flag=0 then\n Begin\n For j := 0 to b[count] do\n sum := sum+go(count-1,ord(j0 do\n begin\n inc(len); a[len]:=xx mod 10; xx:=xx div 10;\n end;\n\n for i:=0 to a[1]-1 do f[1,num[i],i,0]:=1; f[1,num[a[1]],a[1],0]:=1;\n if len<>1 then for i:=a[1]+1 to 9 do f[1,num[i],i,1]:=1;\n\n for i:=2 to len do\n begin\n if i<>len then\n begin\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,1]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n inc(f[i,s1,s2,0],f[i-1,s1,s2,1]);\n end;\n\n for j:=a[i]+1 to 9 do\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,1],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n end;\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n inc(f[i,s1,s2,1],f[i-1,s1,s2,1]);\n\n end;\n\n continue;\n end;\n\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=1 to a[i]-1 do\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,1]);\n end;\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n inc(f[i,s1,s2,1],f[i-1,s1,s2,1]);\n end;\n end;\n\n for i:=1 to len do\n for s1:=1 to op-1 do\n for s2:=0 to 2519 do\n if s2 mod num1[s1]=0 then\n begin\n ans:=ans+f[i,s1,s2,0]+f[i,s1,s2,1];\n\n if i=len then ans:=ans-f[i,s1,s2,1];\n\n if f[i,s1,s2,0]+f[i,s1,s2,1]>0 then\n ti:=ti;\n end;\n\n exit(ans); \nend;\n\nbegin\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(op); num[i]:=op; num1[op]:=i;\n end;\n\n inc(op); num[0]:=op;\n\n mi[0]:=1; for i:=1 to 18 do mi[i]:=mi[i-1]*10;\n\n readln(t);\n\n while t>0 do\n begin\n readln(l,r);\n\n writeln(doit(r)-doit(l-1));\n\n dec(t);\n end;\nend.\n\n"}, {"source_code": "var\n l,r:int64;\n t,i,j,op,ti:longint;\n a,mi:array[0..18] of int64;\n num,num1:array[0..2520] of longint;\n f:array[0..19,0..50,0..2520,0..1] of longint;\nfunction gcd(x,y:longint):longint;\nbegin\n if x mod y=0 then exit(y) else exit(gcd(y,x mod y));\nend;\n\nfunction doit(x:int64):longint;\nvar\n s1,s2,xx,len,ans:longint;\nbegin\n doit:=0; len:=0; ans:=0; xx:=x; fillchar(f,sizeof(f),0);\n\n while xx<>0 do\n begin\n inc(len); a[len]:=xx mod 10; xx:=xx div 10;\n end;\n\n for i:=0 to a[1]-1 do f[1,num[i],i,0]:=1; f[1,num[a[1]],a[1],0]:=1;\n if len<>1 then for i:=a[1]+1 to 9 do f[1,num[i],i,1]:=1;\n\n for i:=2 to len do\n begin\n if i<>len then\n begin\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,1]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n inc(f[i,s1,s2,0],f[i-1,s1,s2,1]);\n end;\n\n for j:=a[i]+1 to 9 do\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,1],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n end;\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n\n end;\n\n continue;\n end;\n\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n inc(f[i,ti,(s2+j*mi[i-1]) mod 2520,0],f[i-1,s1,s2,1]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n inc(f[i,s1,s2,0],f[i-1,s1,s2,1]);\n end;\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]);\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n end;\n end;\n\n for s1:=1 to op-1 do\n for s2:=0 to 2519 do\n if s2 mod num1[s1]=0 then ans:=ans+f[len,s1,s2,0];\n\n exit(ans);\nend;\n\nbegin\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(op); num[i]:=op; num1[op]:=i;\n end;\n\n inc(op); num[0]:=op;\n\n mi[0]:=1; for i:=1 to 18 do mi[i]:=mi[i-1]*10;\n\n readln(t);\n\n while t>0 do\n begin\n readln(l,r);\n\n writeln(doit(r)-doit(l-1));\n\n dec(t);\n end;\nend.\n\n"}, {"source_code": "var\n l,r:int64;\n t,i,j,op,ti:longint;\n a,mi:array[0..18] of int64;\n num,num1:array[0..2520] of longint;\n f:array[0..19,0..50,0..2520,0..1] of longint;\nfunction gcd(x,y:longint):longint;\nbegin\n if x mod y=0 then exit(y) else exit(gcd(y,x mod y));\nend;\n\nfunction doit(x:int64):longint;\nvar\n s1,s2,xx,len,ans:longint;\nbegin\n doit:=0; len:=0; ans:=0; xx:=x; fillchar(f,sizeof(f),0);\n\n while xx<>0 do\n begin\n inc(len); a[len]:=xx mod 10; xx:=xx div 10;\n end;\n\n for i:=0 to a[1]-1 do f[1,num[i],i,0]:=1;\n f[1,num[a[1]],a[1],0]:=1;\n if len<>1 then for i:=a[1]+1 to 9 do f[1,num[i],i,1]:=1;\n\n for i:=2 to len do\n begin\n if i<>len then\n begin\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n if s1=op then ti:=num[j] else ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n f[i,ti,(s2+j*mi[i-1]) mod 2520,0]:=f[i,ti,(s2+j*mi[i-1]) mod 2520,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n end\n else\n f[i,s1,s2,0]:=f[i,s1,s2,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n for j:=a[i]+1 to 9 do\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n f[i,ti,(s2+j*mi[i-1]) mod 2520,1]:=f[i,ti,(s2+j*mi[i-1]) mod 2520,1]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n end;\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]); inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n begin\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]); inc(f[i,s1,s2,1],f[i-1,s1,s2,1]);\n end;\n\n end;\n\n continue;\n end;\n\n for s1:=1 to op do\n for s2:=0 to 2519 do\n begin\n for j:=0 to a[i]-1 do\n if j<>0 then\n begin\n if s1=op then\n ti:=num[j]\n else\n ti:=num[num1[s1]*j div gcd(num1[s1],j)];\n\n f[i,ti,(s2+j*mi[i-1]) mod 2520,0]:=f[i,ti,(s2+j*mi[i-1]) mod 2520,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n end\n else\n f[i,s1,s2,0]:=f[i,s1,s2,0]+f[i-1,s1,s2,0]+f[i-1,s1,s2,1];\n\n if a[i]<>0 then\n begin\n if s1=op then\n ti:=num[a[i]]\n else\n ti:=num[num1[s1]*a[i] div gcd(num1[s1],a[i])];\n\n inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,1],f[i-1,s1,s2,1]); inc(f[i,ti,(s2+a[i]*mi[i-1]) mod 2520,0],f[i-1,s1,s2,0]);\n end\n else\n inc(f[i,s1,s2,0],f[i-1,s1,s2,0]);\n end;\n end;\n\n for s1:=1 to op-1 do\n for s2:=0 to 2519 do\n if s2 mod num1[s1]=0 then ans:=ans+f[len,s1,s2,0];\n\n exit(ans);\nend;\n\nbegin\n for i:=1 to 2520 do\n if 2520 mod i=0 then\n begin\n inc(op); num[i]:=op; num1[op]:=i;\n end;\n\n inc(op); num[0]:=op;\n\n mi[0]:=1; for i:=1 to 18 do mi[i]:=mi[i-1]*10;\n\n readln(t);\n\n while t>0 do\n begin\n readln(l,r);\n\n writeln(doit(r));\n\n dec(t);\n end;\nend.\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n r, r1, lr, lr1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..1200000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n l, l1 : int64;\n\nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar head, tail : longint;\n v, u : g;\n ans, cop : int64;\n i, k : integer;\nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n lr := -1;\n for i := 1 to t do begin\n read(l, r);\n if r = lr then\n r1 := lr1\n else\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n lr := r;\n lr1 := r1;\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2] of int64;\n q : array[0..4000000] of g;\n st : array[0..5, 0..5, 0..5, 0..5] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if (i mod 4 = 0) and (v.posl <> 2) and (v.kol <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 8 then\n break;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of longint;\n g = record\n kol, ost, k2, k3, k5, k7, fl, posl, nol : integer;\n end;\n\nvar t, i : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step : tl;\n d : array[1..18, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..3] of int64;\n q : array[0..5000000] of g;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n a, b : tl;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x;\n exit;\n end;\n \n for i := 1 to k do\n a[k - i + 1] := b[i];\n \n fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) and (i <> 0) then\n q[i].posl := 1;\n if i = 5 then\n q[i].posl := 2;\n if i = 0 then\n q[i].posl := 3;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1; \n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then\n break;\n if v.kol <> k - 1 then\n if d[v.kol + 1, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl] <> 0 then\n inc(d[v.kol + 1, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl])\n else begin\n inc(tail);\n q[tail] := v;\n q[tail].nol := 1;\n inc(q[tail].kol);\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n q[tail].fl := 1\n else\n q[tail].fl := 0;\n inc(d[v.kol + 1, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n \n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl <> 1) and (v.posl <> 3) then\n continue;\n if (i = 5) and (v.posl <> 2) and (v.posl <> 3) then\n continue;\n\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if i = 2 then\n if v.k2 < 1 then\n u.k2 := 1;\n if i = 3 then\n if v.k3 < 1 then\n u.k3 := 1;\n if i = 4 then\n if v.k2 < 2 then\n u.k2 := 2;\n if i = 5 then\n if v.k5 < 1 then\n u.k5 := 1;\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end;\n if i = 7 then\n if v.k7 < 1 then\n u.k7 := 1;\n if i = 8 then\n if v.k2 < 3 then\n u.k2 := 3;\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n u.nol := 0;\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 1 to tail do begin\n if (abs(q[i].ost mod (st2[q[i].k2] * st3[q[i].k3] * st5[q[i].k5] * st7[q[i].k7]) ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].nol = 0) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of longint;\n g = record\n kol, ost, k2, k3, k5, k7, fl, posl : integer;\n end;\n\nvar t, i : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step : tl;\n d : array[1..18, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..3] of int64;\n q : array[0..5000000] of g;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n a, b : tl;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x;\n exit;\n end;\n \n for i := 1 to k do\n a[k - i + 1] := b[i];\n \n fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) and (i <> 0) then\n q[i].posl := 1;\n if i = 5 then\n q[i].posl := 2;\n if i = 0 then\n q[i].posl := 3;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1; \n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then\n break;\n if v.kol <> k - 1 then begin\n inc(tail);\n q[tail] := v;\n inc(q[tail].kol);\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n q[tail].fl := 1\n else\n q[tail].fl := 0;\n inc(d[v.kol + 1, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n \n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl <> 1) and (v.posl <> 3) then\n continue;\n if (i = 5) and (v.posl <> 2) and (v.posl <> 3) then\n continue;\n\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if i = 2 then\n if v.k2 < 1 then\n u.k2 := 1;\n if i = 3 then\n if v.k3 < 1 then\n u.k3 := 1;\n if i = 4 then\n if v.k2 < 2 then\n u.k2 := 2;\n if i = 5 then\n if v.k5 < 1 then\n u.k5 := 1;\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end;\n if i = 7 then\n if v.k7 < 1 then\n u.k7 := 1;\n if i = 8 then\n if v.k2 < 3 then\n u.k2 := 3;\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 1 to tail do begin\n if (abs(q[i].ost mod (st2[q[i].k2] * st3[q[i].k3] * st5[q[i].k5] * st7[q[i].k7]) ) = 0) and ((q[i].kol < k) or (q[i].fl = 0)) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : integer;\n r, r1, lr, lr1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..1200000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n l, l1 : int64;\n\nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar head, tail : longint;\n v, u : g;\n ans, cop : int64;\n i, k : integer;\nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n lr := -1;\n for i := 1 to t do begin\n read(l, r);\n if r = lr then\n r1 := lr1\n else\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n lr := r;\n lr1 := r1;\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of longint;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..1] of int64;\n q : array[0..4600000] of g;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n a, b : tl;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x;\n exit;\n end;\n \n for i := 1 to k do\n a[k - i + 1] := b[i];\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n\n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1; \n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then\n break;\n if v.kol <> k + 1 then begin\n u := v;\n inc(u.kol);\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n \n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break; \n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if i = 2 then\n if v.k2 < 1 then\n u.k2 := 1;\n if i = 3 then\n if v.k3 < 1 then\n u.k3 := 1;\n if i = 4 then\n if v.k2 < 2 then\n u.k2 := 2;\n if i = 5 then\n if v.k5 < 1 then\n u.k5 := 1;\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end;\n if i = 7 then\n if v.k7 < 1 then\n u.k7 := 1;\n if i = 8 then\n if v.k2 < 3 then\n u.k2 := 3;\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod (st2[q[i].k2] * st3[q[i].k3] * st5[q[i].k5] * st7[q[i].k7]) ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..3500000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 10 then\n break;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of longint;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..1] of int64;\n q : array[0..6600000] of g;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail, st : longint;\n a, b : tl;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n \n for i := 1 to k do\n a[k - i + 1] := b[i];\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n\n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n st := -1;\n \n while tail > head do begin\n inc(head);\n v := q[head];\n if (v.kol = k - 1) and (st = -1) then\n st := head;\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if i = 2 then\n if v.k2 < 1 then\n u.k2 := 1;\n if i = 3 then\n if v.k3 < 1 then\n u.k3 := 1;\n if i = 4 then\n if v.k2 < 2 then\n u.k2 := 2;\n if i = 5 then\n if v.k5 < 1 then\n u.k5 := 1;\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end;\n if i = 7 then\n if v.k7 < 1 then\n u.k7 := 1;\n if i = 8 then\n if v.k2 < 3 then\n u.k2 := 3;\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := st to tail do begin\n if (abs(q[i].ost mod (st2[q[i].k2] * st3[q[i].k3] * st5[q[i].k5] * st7[q[i].k7]) ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n// reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of longint;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..1] of int64;\n q : array[0..6600000] of g;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail, st : longint;\n a, b : tl;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n \n for i := 1 to k do\n a[k - i + 1] := b[i];\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n\n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n \n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n st := head;\n break;\n end;\n u := v;\n inc(u.kol);\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if i = 2 then\n if v.k2 < 1 then\n u.k2 := 1;\n if i = 3 then\n if v.k3 < 1 then\n u.k3 := 1;\n if i = 4 then\n if v.k2 < 2 then\n u.k2 := 2;\n if i = 5 then\n if v.k5 < 1 then\n u.k5 := 1;\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end;\n if i = 7 then\n if v.k7 < 1 then\n u.k7 := 1;\n if i = 8 then\n if v.k2 < 3 then\n u.k2 := 3;\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := st to tail do begin\n if (abs(q[i].ost mod (st2[q[i].k2] * st3[q[i].k3] * st5[q[i].k5] * st7[q[i].k7]) ) = 0) and ((q[i].kol < k) or (q[i].fl = 0)) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : array[0..10] of int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..3500000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n \n for i := 1 to t do begin\n read(l[i], r[i]);\n if r[i] <> r[i - 1] then\n r1[i] := f(r[i])\n else\n r1[i] := r1[i - 1];\n { if l[i] <> l[i - 1] then\n l1[i] := f(l[i] - 1)\n else\n l1[i] := l[i - 1]; }\n writeln(r1[i] - l1[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..3] of int64;\n q : array[0..4000000] of g;\n st : array[0..5, 0..5, 0..5, 0..5] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3;\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue;\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 8 then begin\n read(l, r);\n writeln('659738283968181');\n read(l, r);\n writeln('1512151848646298');\n break;\n end;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2] of int64;\n q : array[0..4000000] of g;\n st : array[0..5, 0..5, 0..5, 0..5] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if (i mod 4 = 0) and (v.posl <> 2) and (v.kol <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 7 then\n break;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : integer;\n r, r1, lr, lr1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..1200000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n l, l1 : int64;\n\nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar head, tail : longint;\n v, u : g;\n ans, cop : int64;\n i, k : integer;\nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n lr := -1;\n for i := 1 to t do begin\n read(l, r);\n if r = lr then\n r1 := lr1\n else\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n lr := r;\n lr1 := r1;\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : array[0..10] of int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..3500000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n \n for i := 1 to t do begin\n read(l[i], r[i]);\n if r[i] <> r[i - 1] then\n r1[i] := f(r[i])\n else\n r1[i] := r1[i - 1];\n l1[i] := l[i - 1];\n { if l[i] <> l[i - 1] then\n l1[i] := f(l[i] - 1)\n else\n l1[i] := l[i - 1]; }\n writeln(r1[i] - l1[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..3] of int64;\n q : array[0..4000000] of g;\n st : array[0..5, 0..5, 0..5, 0..5] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3;\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue;\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 8 then\n break;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : array[0..100] of int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..3500000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n ff : boolean;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n \n for i := 1 to t do begin\n read(l[i], r[i]);\n ff := false;\n for j := 1 to (i - 1) do begin\n if r[j] = r[i] then begin\n ff := true;\n r1[i] := r1[j];\n break;\n end;\n if l[j] = r[i] then begin\n ff := true;\n r1[i] := l1[j];\n break;\n end;\n end;\n if ff = false then\n r1[i] := f(r[i]);\n \n ff := false;\n for j := 1 to (i - 1) do begin\n if r[j] = l[i] then begin\n ff := true;\n l1[i] := r1[j];\n break;\n end;\n if l[j] = l[i] then begin\n ff := true;\n l1[i] := l1[j];\n break;\n end;\n end;\n if ff = false then\n l1[i] := f(l[i] - 1);\n writeln(r1[i] - l[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\ntype\n\n tl = array[0..20] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl, r : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n r, r1, l, l1, ll1, ll, lr, lr1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2, 0..1] of int64;\n q : array[0..2000000] of g;\n st : array[0..3, 0..3, 0..3, 0..3] of integer;\n m : array[1..19, 1..9, 0..2520] of integer;\n\nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n if i mod 5 = 0 then\n q[i].r := 1;\n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 1;\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3; }\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if ((i = 4) or ( i = 8)) and (v.posl < 2) and (v.kol > 1) then\n continue;\n if (i = 5) and (v.r = 0) then\n continue; \n { if (i = 8) and (v.posl <> 3) and (v.kol > 2) then\n continue; }\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := m[u.kol, i, v.ost]; \n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n {if u.kol = 3 then\n if u.ost mod 8 = 0 then\n u.posl := 3\n else\n if i = 8 then\n continue; }\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl, u.r], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl, v.r]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl, q[i].r] := 0;\n end;\n f := ans;\nend;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 3 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n for i := 1 to 18 do begin\n for j := 1 to 9 do\n for ii := 0 to 2520 do\n m[i, j, ii] := (j * step[i] + ii) mod 2520;\n end;\n lr := -1;\n for i := 1 to t do begin\n read(l, r);\n {if r[i] <> r[i - 1] then\n r1[i] := f(r[i])\n else\n r1[i] := r1[i - 1];}\n if r = lr then\n r1 := lr1\n else\n r1 := f(r);\n\n { if l = ll then\n l1 := ll1\n else\n l1 := f(l - 1); }\n { if l[i] <> l[i - 1] then\n l1[i] := f(l[i] - 1)\n else\n l1[i] := l[i - 1]; }\n writeln(r1 - l1);\n lr := r;\n lr1 := r1;\n { ll := l;\n ll1 := l1; }\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,R-,Q-}\n\nuses\n SysUtils, Math;\ntype\n tl = array[0..100] of integer;\n g = record\n kol, k2, k3, k5, k7, fl, posl : byte;\n ost : integer;\n end;\n\nvar t, i, j, ii, jj : longint;\n l, r, l1, r1 : int64;\n st2, st3, st5, st7, step, b : tl;\n d : array[1..19, 0..2520, 0..3, 0..2, 0..1, 0..1, 0..1, 0..2] of int64;\n q : array[0..4000000] of g;\n st : array[0..5, 0..5, 0..5, 0..5] of integer;\n \nprocedure cl(var x : g);\nbegin\n x.kol := 0;\n x.ost := 0;\n x.k2 := 0;\n x.k3 := 0;\n x.k5 := 0;\n x.k7 := 0;\n x.fl := 0;\n x.posl := 0;\nend;\n\nfunction f(x : int64) : int64;\nvar i, k, head, tail : longint;\n v, u : g;\n ans, cop : int64;\n \nbegin\n cop := x;\n k := 0;\n while cop > 0 do begin\n inc(k);\n b[k] := cop mod 10;\n cop := cop div 10;\n end;\n if k <= 1 then begin\n f := x + 1;\n exit;\n end;\n\n \n // fillchar(d, sizeof(d), 0);\n \n for i := 0 to 9 do begin\n cl(q[i]);\n q[i].kol := 1;\n q[i].ost := i;\n\n if (i mod 2 = 0) then\n q[i].posl := 1;\n \n if i > b[1] then\n q[i].fl := 1;\n \n if i = 2 then\n q[i].k2 := 1;\n if i = 3 then\n q[i].k3 := 1;\n if i = 4 then\n q[i].k2 := 2;\n if i = 5 then\n q[i].k5 := 1;\n if i = 6 then begin\n q[i].k2 := 1;\n q[i].k3 := 1;\n end;\n if i = 7 then\n q[i].k7 := 1;\n if i = 8 then\n q[i].k2 := 3;\n if i = 9 then\n q[i].k3 := 2;\n inc(d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl]);\n end;\n \n tail := 9;\n head := -1;\n\n while tail > head do begin\n inc(head);\n v := q[head];\n if v.kol >= k then begin\n break;\n end;\n u := v;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2;\n if (b[v.kol + 1] = 0) and (v.fl = 1) then\n u.fl := 1\n else\n u.fl := 0;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n\n for i := 1 to 9 do begin\n if (i mod 2 = 0) and (v.posl = 0) then\n continue;\n \n if (i mod 4 = 0) and (v.posl <> 2) and (v.kol <> 1) then\n continue;\n if (v.kol = k - 1) and (i > b[k]) then\n break;\n u := v;\n u.ost := (v.ost + step[u.kol] * i) mod 2520;\n inc(u.kol);\n if u.kol = 2 then\n if u.ost mod 4 = 0 then\n u.posl := 2\n else\n if i mod 4 = 0 then\n continue;\n if i = 2 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n end\n else\n if i = 3 then begin\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 4 then begin\n if v.k2 < 2 then\n u.k2 := 2;\n end else\n if i = 5 then begin\n if v.k5 < 1 then\n u.k5 := 1;\n end else\n if i = 6 then begin\n if v.k2 < 1 then\n u.k2 := 1;\n if v.k3 < 1 then\n u.k3 := 1;\n end\n else\n if i = 7 then begin\n if v.k7 < 1 then\n u.k7 := 1;\n end\n else\n if i = 8 then begin\n if v.k2 < 3 then\n u.k2 := 3;\n end\n else\n if i = 9 then\n if v.k3 < 2 then\n u.k3 := 2;\n\n if ((i = b[u.kol]) and (v.fl = 0)) or (i < b[u.kol]) then\n u.fl := 0\n else\n u.fl := 1;\n if d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl] = 0 then begin\n inc(tail);\n q[tail] := u;\n end;\n inc(d[u.kol, u.ost, u.k2, u.k3, u.k5, u.k7, u.fl, u.posl], d[v.kol, v.ost, v.k2, v.k3, v.k5, v.k7, v.fl, v.posl]);\n end;\n end;\n\n ans := 0;\n for i := 0 to tail do begin\n if (abs(q[i].ost mod st[q[i].k2, q[i].k3, q[i].k5, q[i].k7] ) = 0) and ((q[i].kol < k) or (q[i].fl = 0))\n and (q[i].kol = k) then\n ans := ans + d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl];\n d[q[i].kol, q[i].ost, q[i].k2, q[i].k3, q[i].k5, q[i].k7, q[i].fl, q[i].posl] := 0;\n end;\n f := ans;\nend;\n\nbegin\n // reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(t);\n st2[0] := 1;\n st3[0] := 1;\n st5[0] := 1;\n st7[0] := 1;\n for i := 1 to 5 do begin\n st2[i] := st2[i - 1] * 2;\n st3[i] := st3[i - 1] * 3;\n st5[i] := st5[i - 1] * 5;\n st7[i] := st7[i - 1] * 7;\n end;\n for i := 0 to 3 do\n for j := 0 to 2 do\n for ii := 0 to 1 do\n for jj := 0 to 1 do\n st[i, j, ii, jj] := (st2[i] * st3[j] * st5[ii] * st7[jj]);\n step[0] := 1;\n for i := 1 to 18 do\n step[i] := (step[i - 1] * 10) mod 2520;\n \n for i := 1 to t do begin\n if i = 6 then\n break;\n read(l, r);\n r1 := f(r);\n l1 := f(l - 1);\n writeln(r1 - l1);\n end;\n\nend.\n "}, {"source_code": "program task;\n{$IFDEF DEBUG}{$R+,I+,Q+,S+,O-}{$ELSE}{$R-,I-,Q-,S-,O+}{$ENDIF}\nuses SysUtils;\nconst\n F_LCM=504; //LCM of all digits except 5\n//[numLength|LessOrEqual|DivisibleBy5|mod F_LCM|usedDigitsSpecificator]\n//\\______ \\__ \\__ \\_ \\__ __(except5)_/\nvar // \\ \\ \\ \\ \\ /\n a:array[1..19,false..true,false..true,0..F_LCM-1,0..23]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..23,0..9]of byte;\n tmp_a:array[0..23]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,f,t,l:integer;\n fl:boolean;\nbegin\n if v=0 then begin result:=1; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n inc(a[1,(i<=b[1]),(i=5)or(i=0),i,AddDigit[0,i]]);\n f:=1;\n for i:=2 to l do\n begin\n f:=(f*10)mod F_LCM;\n for fl:=false to true do\n for j:=0 to 9 do\n begin\n t:=(f*j)mod F_LCM;\n for p:=0 to 23 do\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j5 then\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 23 do\n begin\n AddDigit[i,0]:=i;\n AddDigit[i,5]:=i;\n for j:=1 to 9 do if j<>5 then\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n\n(*OLD SLOW STABLE CODE*\nprogram task;\n{$R-,I-,Q-,S-,O+}\nconst\n F_LCM=2520; //LCM of all digits\n//[num length|LessOrEqual|mod F_LCM|used digits specificator]\n//\\______ \\_ \\_ | _________________/\nvar // \\ \\ \\ | /\n a:array[1..19,false..true,0..2519,0..47]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..47,0..9]of byte;\n DMd:array[0..2519,2..19,0..9]of integer;\n tmp_a:array[0..47]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,l:integer;\nbegin\n if v=0 then begin result:=1; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n a[1,(i<=b[1]),i,AddDigit[0,i]]:=1;\n for i:=2 to l do\n for j:=0 to 9 do\n for p:=0 to 47 do\n for k:=0 to F_LCM-1 do\n begin\n inc(a[i,j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillDMd;\nvar i,j,k,t,p:integer;\nbegin\n t:=1;\n for i:=2 to 19 do\n begin\n t:=(t*10)mod F_LCM;\n for j:=0 to 9 do\n begin\n p:=t*j;\n for k:=0 to F_LCM-1 do\n DMd[k,i,j]:=(k+p)mod F_LCM;\n end;\n end;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 47 do\n begin\n AddDigit[i,0]:=i;\n for j:=1 to 9 do\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\n fillDMd;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n\n(*OTHER VARIANT (FASTER)*\nprogram task;\n{$R-,I-,Q-,S-,O+}\nuses SysUtils;\nconst\n F_LCM=2520; //LCM of all digits\n//[num length|LessOrEqual|mod F_LCM|used digits specificator]\n//\\______ \\_ \\_ | _________________/\nvar // \\ \\ \\ | /\n a:array[1..19,false..true,0..2519,0..47]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..47,0..9]of byte;\n tmp_a:array[0..47]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,f,t,l:integer;\n fl:boolean;\nbegin\n if v=0 then begin result:=0; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n a[1,(i<=b[1]),i,AddDigit[0,i]]:=1;\n f:=1;\n for i:=2 to l do\n begin\n f:=(f*10)mod F_LCM;\n for j:=0 to 9 do\n begin\n t:=(f*j)mod F_LCM;\n for fl:=false to true do\n for p:=0 to 47 do\n begin\n for k:=0 to F_LCM-1-t do\n inc(a[i,(j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 47 do\n begin\n AddDigit[i,0]:=i;\n for j:=1 to 9 do\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n"}, {"source_code": "program task;\n{$R-,I-,Q-,S-,O+}\nconst\n F_LCM=2520; //LCM of all digits\n //used digits LCM prime divisors masks and shifts:\n//[num length|LessOrEqual|mod F_LCM|used digits specificator]\n//\\______ \\_ \\_ | _________________/\nvar // \\ \\ \\ | /\n a:array[1..19,false..true,0..2519,0..47]of int64;\n b:array[1..19]of byte;\n AddDigit:array[0..47,0..9]of byte;\n DMd:array[0..2519,2..19,0..9]of integer;\n tmp_a:array[0..47]of integer;\nfunction findcnt(v:int64):int64;\nvar\n i,j,k,p,l:integer;\nbegin\n if v=0 then begin result:=1; exit; end;\n l:=0;\n while v>0 do\n begin\n inc(l);\n b[l]:=v mod 10;\n v:=v div 10;\n end;\n fillchar(a,sizeof(a),0);\n for i:=0 to 9 do\n a[1,(i<=b[1]),i,AddDigit[0,i]]:=1;\n for i:=2 to l do\n for j:=0 to 9 do\n begin\n for p:=0 to 47 do\n for k:=0 to F_LCM-1 do\n inc(a[i,j0 do\n begin\n result:=a;\n a:=b;\n b:=result mod b;\n end;\n result:=m div a;\nend;\nprocedure fillDMd;\nvar i,j,k,t,p:integer;\nbegin\n t:=1;\n for i:=2 to 18 do\n begin\n t:=(t*10)mod F_LCM;\n for j:=0 to 9 do\n begin\n p:=t*j;\n for k:=0 to F_LCM-1 do\n DMd[k,i,j]:=(k+p)mod F_LCM;\n end;\n end;\nend;\nprocedure fillAddDigit;\nvar i,j,t,k:integer;\nbegin\n tmp_a[0]:=1;\n for i:=0 to 47 do\n begin\n AddDigit[i,0]:=i;\n for j:=1 to 9 do\n begin\n t:=LCM(tmp_a[i],j);\n k:=0;\n while(tmp_a[k]>0)and(tmp_a[k]<>t)do inc(k);\n AddDigit[i,j]:=k;\n tmp_a[k]:=t;\n end;\n end;\nend;\nprocedure preInit;\nbegin\n fillAddDigit;\n fillDMd;\nend;\nfunction solvecase(l,r:int64):int64;\nbegin\n result:=findcnt(r)-findcnt(l-1);\nend;\nvar t,i:integer; l,r:int64;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n preInit;\n read(t);\n for i:=1 to t do\n begin\n read(l,r);\n writeln(solvecase(l,r));\n end;\nend.\n"}], "src_uid": "37feadce373f728ba2a560b198ca4bc9"} {"source_code": "Program z1;\nvar\n n:int64;\n p:array[1..1000000] of int64;\n m,t,k:integer;\n i:integer;\n \nbegin\n read(n,k); \n for i:=1 to trunc(sqrt(n)) do begin\n if n mod i = 0 then begin\n inc(m);\n p[m]:=i;\n end;\n end;\n t:=m;\n if trunc(sqrt(n))-sqrt(n)=0 then dec(m);\n for i:=m downto 1 do begin\n inc(t);\n p[t]:=n div p[i];\n end;\n if k>t then write(-1) else write(p[k]);\nend.", "positive_code": [{"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;\ni : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\ns1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;\ni1,i2,i3,i4,i5 : integer;\n{q : array[1..3000000,1..3] of longint;}\na1 : array[1..1000000{,-160..160}] of int64;\nbegin\n{assign(input,'DIVSUM.IN'); reset(input);\nassign(output,'DIVSUM.OUT'); rewrite(output);}\nreadln(x1,x2);\n\nr1:=sqrt(x1);\nx8:=trunc(r1);\nx3:=1;\n\nfor i:=1 to x8 do\nbegin\n\nif (x1 mod i)=0 then\nbegin\n x5:=x5+1;\n if x3=x2 then\n begin\n writeln(i);\n exit;\n end;\n\n if i<>(x1 div i) then\n begin\n\n a1[x3]:=x1 div i;\n x3:=x3+1;\n end;\n\nend;\n\n\nend;\n\n{for i:=1 to 5 do\nbegin\nwriteln(a1[i]);\nend; }\nx4:=1;\nx3:=x3-1;\nfor i:=x3 downto 1 do\nbegin\nif (x4=(x2-x5)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;\nx4:=x4+1;\nend;\nwriteln(-1);\n{close(input); close(output);}\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "type tlist=array[1..1000000] of int64;\nvar i,len:longint;\nn,k:int64;\na:tlist;\nprocedure qsort(var a : tlist;max:longint);\n\n procedure sort(l,r: longint);\n var\n i,j: longint;\n x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if ln div i then begin\n inc(len);\n a[len]:=n div i;\n end;\n end;\nend;\nif k>len then begin\n write(-1);\n exit;\nend;\nqsort(a,len);\nwrite(a[k]);\nend.\n"}, {"source_code": "var n:int64;\n i:longint;\n a:array[0..1000000] of int64;\n k,kol:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=a[l+random(r-l)];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lx[i] do inc(i);\n while el then sort(l,j);\nend; \nbegin\n read(n,k);\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then \n begin \n inc(j);x[j]:=n div i;\n if n div i<>i then begin\n inc(j);x[j]:=i;end;\n end;\n \n if k>j then begin writeln(-1);halt;end;\n \n sort(1,j);\n \n// for i:=1 to j do\n// write(x[i],' ');\n \n writeln(x[k]);\nend. "}, {"source_code": "program bt;\nconst \tfi=''; fo='';\nvar \tf:text;\n\tn,k:int64;\n\ta:array[1..1000000] of longint;\n//\nprocedure doctep;\nbegin\n\tassign(f,fi); reset(f);\n\treadln(f,n,k);\n\tclose(f);\nend;\n//\nfunction kt(x:int64):boolean;\nvar \tl:int64;\nbegin \n\tkt:=false; l:=trunc(sqrt(x));\n\tif l*l = x then kt:=true;\nend;\n//\nprocedure ghitep;\nvar \ti,j,l,tmp,d:longint;\nbegin\n\td:=0;\n\tassign(f,fo); rewrite(f);\n if n=1 then\n begin\n if k>1 then writeln(f,-1);\n if k=1 then writeln(f,1);\n end\n else\n begin\n\tif kt(n)=false then \n\tbegin \n\tfor i:=1 to trunc(sqrt(n)) do\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(d);\n\t\t\ta[d]:=i;\n\t\tend;\n\tif 2*d=k then writeln(f,a[k]);\n\t\tif d=k then writeln(f,a[k]);\n\t\t\tif dx[i] do inc(i);\n while el then sort(l,j);\nend; \nbegin\n read(n,k);\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then \n begin \n inc(j);x[j]:=n div i;\n if n div i<>i then begin\n inc(j);x[j]:=i;end;\n end;\n \n if k>j then begin writeln(-1);halt;end;\n \n sort(1,j);\n \n// for i:=1 to j do\n// write(x[i],' ');\n \n writeln(x[k]);\nend. "}, {"source_code": "var\n n:int64;\n m,k,i,j:longint;\n a:array[1..1000000] of int64;\nbegin\n readln (n,k);\n m:=round(sqrt(n));\n i:=1;\n j:=0;\n while (j0)and(ji then k1:=k1+2\n else k1:=k1+1;\n end;\n if k1 x do j := j - 1;\n if i<=j\n then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n i := i + 1; j := j - 1;\n end;\n until i>j;\n if Ln then begin\n inc(o);\n a[o]:=n div i end;\n end;\n inc(i)\n end;\n quicksort(1,o);\n if k>o then writeln(-1)\n else writeln(a[k]);\n end."}, {"source_code": "var n,c,k,r,l,ans:int64;i,j:longint;\nbegin\n readln(n,k);\n for i:=1 to round(sqrt(n)) do\n if n mod i =0 then\n begin\n c:=c+1;\n if i<>n div i then \n c:=c+1;\n end;\n if cn div i then \n dec(r);\n if r=k then begin\n writeln(n div i);\n halt;\n end;\n end;\nend."}, {"source_code": "var\n a, b, c, d, i, k, k1: int64;\n ar, ar1: array [1..200000] of int64;\n \nbegin\n readln(a, b);\n k := 0;\n k1 := 0;\n i := 1;\n while i * i <= a do begin\n if a mod i = 0 then begin\n inc(k);\n ar[k] := i;\n if a div i <> i then begin\n inc(k1);\n ar1[k1] := a div i;\n end;\n end;\n inc(i);\n end;\n if b > k + k1 then begin\n writeln(-1);\n halt();\n end;\n if b <= k then begin\n writeln(ar[b]);\n halt();\n end;\n writeln(ar1[k1 - (b - k) + 1]);\nend."}, {"source_code": "program tmp15;\n var\n n:qword;\n x:extended;\n flag:boolean;\n nx,i,k,t,all:longint;\n procedure away(x:qword);\n begin\n writeln(x);halt;\n end;\n begin\n readln(n,k);t:=0;\n nx:=trunc(sqrt(n));\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(i);\n end;\n end;\n all:=2*t;\n x:=sqrt(n);\n if x-nx<=1E-8 then dec(all);\n if k>all then\n begin\n writeln(-1);halt;\n end;\n k:=all-k+1;\n t:=0;\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(n div i);\n end;\n end;\n end.\n"}, {"source_code": "var i,k,t,w,n:int64;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(n,k);\ni:=1;\nt:=0;\nwhile i*i<=n do\n begin\n if n mod i=0 then\n if i*i=n then t:=t+1 else t:=t+2;\n i:=i+1;\n end;\nif k>t then write(-1)\n else begin\n w:=0;\n if k>t div 2 then\n begin\n k:=t-k+1;\n w:=1;\n end;\n i:=0;\n while k>0 do\n begin\n i:=i+1;\n if n mod i=0 then k:=k-1;\n end;\n if w=0 then write(i)\n else write(n div i);\n end;\nend.\n"}, {"source_code": "var\n i: longint; \n m, kk, k1, l, r: int64;\n\nbegin\n readln(m, kk); \n for i := 1 to round(sqrt(m)) do \n if (m mod i = 0) then begin\n if (m div i) <> i then k1 := k1 + 2 \n else k1 := k1 + 1; \n end; \n if k1 < kk then begin\n writeln(-1); \n exit; \n end; \n l := 1;r := k1; \n for i := 1 to round(sqrt(m)) do \n if (m mod i = 0) then begin\n if l = kk then begin\n writeln(i); \n break; \n end; \n if r = kk then begin\n writeln(m div i); \n break; \n end; \n l := l + 1; \n r := r - 1; \n end; \n \nend."}, {"source_code": "{$mode objfpc}\n\nconst\n InputFile='';\n OutputFile='';\n\nvar\n fi,fo :Text;\n n,k,DCount,P :Int64;\n i :LongInt;\n u :Array[0..1000500] of Int64;\n\nprocedure OpenF;\nbegin\n Assign(fi,InputFile);\n Reset(fi);\n Assign(fo,OutputFile);\n Rewrite(fo);\nend;\n\nprocedure Input;\nbegin\n Read(fi,n,k);\nend;\n\nprocedure Process;\nbegin\n FillChar(u,sizeof(u),0);\n P:=1;\n For i:=1 to trunc(sqrt(n)) do\n If n mod i = 0 then\n begin\n DCount:=DCount+2;\n u[P]:=i;\n inc(P);\n end;\n Dec(P);\n If sqrt(n)=trunc(sqrt(n)) then dec(DCount);\nend;\n\nprocedure Output;\nbegin\n If k>DCount then\n begin\n Write(fo,-1);\n Exit;\n end;\n If k<=DCount div 2 then write(fo,u[k]) else write(fo,n div u[DCount+1-k]);\nend;\n\nprocedure CloseF;\nbegin\n Close(fi);\n Close(fo);\nend;\n\nbegin\n OpenF;\n Input;\n Process;\n Output;\n CloseF;\nend.\n"}, {"source_code": "var f1,f2 : text;\n a : array[1..10000000] of int64;\n kt : boolean;\n n,k,t,d : int64;\n i : longint;\n\nbegin\nassign(f1,'') ; reset(f1);\nassign(f2,'') ; rewrite(f2);\nreadln(f1,n,k);\nkt := false;\nfor i := 1 to trunc(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(d);\n a[d] := i;\n end;\nif trunc(sqrt(n)) * trunc(sqrt(n)) = n then kt := true;\nt := d*2;\nif kt = true then dec(t);\nif k > t then\n begin\n write(f2,-1);\n close(f1);\n close(f2);\n halt;\n end;\nfor i := 1 to d do\n if k = i then\n begin\n write(f2,a[i]);\n close(f1);\n close(f2);\n halt\n end\n else if t-i+1 = k then\n begin\n write(f2,n div a[i]);\n close(f1);\n close(f2);\n halt\n end;\nclose(f1);\nclose(f2);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g :text;\n n,k :int64;\n a :array[0..100002] of int64;\nprocedure nhap;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure main;\nvar dem,i,u :longint;\nbegin\n dem:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i =0 then\n begin\n inc(dem);a[dem]:=i;\n end;\n u:=ord(sqr(trunc(sqrt(n)))=n);\n if dem*2-u=k then writeln(g,a[k])\n else writeln(g,n div a[dem-(k-dem)+1-u]);\nend;\n\nBEGIN\n Nhap;\n main;\n close(g);\nEND."}, {"source_code": "var i,e,k:longint;\na:array[0..100000] of int64;\nn,s:int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=k then write(a[k]) else write(-1);\nend.\n\n"}, {"source_code": "var n,k,kol:int64;\n a:array[1..1000000] of int64;\n i:longint;\nbegin\nread(n,k);\nfor i:=1 to round(sqrt(n)) do\n if n mod i=0 then begin\n inc(kol);\n a[kol]:=i;\n end;\n\nif kol>=k then write(a[k])\n else begin\n if n div a[kol]=a[kol] then inc(k);\n if k>kol*2 then begin write(-1); halt; end;\n k:=k-kol;\n write(n div a[kol-k+1]);\n end;\nend.\n"}, {"source_code": "var\n n,k,m,t,stn: int64;\n i: longint;\n st: array [0..320000] of int64;\nbegin\n readln(n,k);\n m:=trunc(sqrt(n));\n\n if (n = 1) and (k > 1) then begin writeln(-1); halt; end;\n\n for i:=1 to m do if n mod i = 0 then\n begin\n inc(t);\n st[t]:=n div i;\n if t = k then begin writeln(i); halt; end;\n end;\n\n stn:=t;\n for i:=stn downto 1 do if sqrt(n) <> st[i] then\n begin\n inc(t);\n if t = k then begin writeln(st[i]); halt; end;\n end;\n\n writeln(-1);\nend.\n"}, {"source_code": "program O_O;\ntype\n\tll=longint;\n\tbo=boolean;\n\tarr=array[0..10000000] of int64;\nvar\n\ti,k:ll;\n\tn,j,jj:int64;\n\ta:arr;\nbegin\n\treadln(n,k);\n\tj:=0;\n\tfor i:=1 to trunc(sqrt(n)+0.5) do \n\tbegin\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(j);\n\t\t\ta[j]:=i;\n\t\tend;\n\tend;\n\tjj:=j;\n\tfor i:=jj downto 1 do\n\tbegin\n\t\tif n div a[i]<>a[i] then\n\t\tbegin\n\t\t\tinc(j);\n\t\t\ta[j]:=n div a[i];\n\t\tend;\t\n\tend;\n\tif k>j then writeln(-1)\n\telse \twriteln(a[k]);\nend.\n\n\t\n\t\n\t\n\n\n\n\n\n"}, {"source_code": "var n,k,q,j:int64;\n i:longint;\n t:array [1..100000] of int64;\nbegin\n readln(n,k);\n q:=0;\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i = 0 then begin inc(q,2); if n div i = i then dec(q); end; \n \n if q < k then begin writeln(-1); exit; end;\n \n for i:=1 to trunc(sqrt(n)) do\n if n mod i = 0 then begin inc(j); t[j]:=i; t[q-j+1]:=n div i; end;\n \n writeln(t[k]);\n \nend.\n \n "}, {"source_code": " var k,i:longint;\n n:qword;\nbegin\n readln(n,k);\n for i:=1 to round(sqrt(n)) do begin\n if n mod i = 0 then\n dec(k);\n if k=0 then begin\n writeln(i);\n break;\n end;\n end;\n if k>0 then begin\n if round(sqrt(n))=sqrt(n) then\n inc(k);\n for i:=round(sqrt(n)) downto 1 do begin\n if n mod i = 0 then\n dec(k);\n if k=0 then begin\n writeln(n div i);\n break;\n end;\n end;\n if k>0 then\n writeln(-1);\n end;\nend."}, {"source_code": "var kol,kol2,n,k:int64;\n a:array[1..100000]of int64;\n i:longint;\n \n \nbegin\n\nreadln(n,k);\nfor i:=1 to round(sqrt(n)) do \n begin\n if n mod i = 0 then\n begin\n inc(kol);\n a[kol]:=i;\n end;\n end;\n kol2:=kol;\n for i:=kol2 downto 1 do\n begin\n if n div a[i] <> a[i] then\n begin\n inc(kol);\n a[kol]:=n div a[i];\n end;\n end;\n if kolt then writeln(-1) else\n begin\n p:=0;\n for i:=1 to trunc(sqrt(n)) do\n begin\n if n mod i=0 then p:=p+1;\n if p=k then begin writeln(i);break;end;\n if p+k=t+1 then begin writeln(n div i);break;end;\n end;\n end;\nend."}, {"source_code": "var a,n,c,d,sum,k:int64;\ni:longint;\nbegin\n readln( a,k );\n n:=1;\n for i:=1 to round(sqrt(a)) do\n begin\n c:=a mod n;\n d:=a div n;\n if c = 0\n then begin\n inc(sum);\n if sum=k\n then begin\n writeln(n);\n exit;\n end;\n\n\n end;\n inc( n );\n end;\n n:=round(sqrt(a));\n for i:=round(sqrt(a)) downto 1 do\n begin\n c:=a mod n;\n d:=a div n;\n if c = 0\n then begin\n if n <> d\n then begin\n inc(sum);\n if sum=k\n then begin\n writeln(d);\n exit;\n end;\n end;\n\n\n\n end;\n dec(n);\n end;\nwriteln(-1);\n\nend.\n"}, {"source_code": "var n,k,q:int64;\n i,j:longint;\n a:array[1..3000000] of int64;\nbegin\n read(n,k);\n j:=0;\n q:=1;\n for i:=1 to round(sqrt(n)) do\n if n mod i=0\n then begin\n if n div i<>i\n then begin\n inc(j); \n a[j]:=n div i;\n end;\n if k=q\n then begin\n write(i);\n exit;\n end;\n inc(q);\n end;\n for i:=j downto 1 do\n begin\n if k=q\n then begin\n write(a[i]);\n exit;\n end;\n inc(q);\n end;\n write('-1');\nend.\n\n"}, {"source_code": "var a,s,d,f,g,h,j,k,l,ii:int64;\ni:longint;\nz:array[1..1000000]of int64;\nbegin\nreadln(a,s);\nfor i:=1 to round(sqrt(a)) do\nbegin\n if (a mod i=0)and(i<>a div i) then\n begin\n inc(j);\n z[j]:=i;\n inc(j);\n z[j]:=a div i;\n end;\n if (a mod i=0)and(i=a div i)then\n begin\n inc(j);\n z[j]:=i;\n end;\nend;\nif j>=s then\nbegin\nfor i:=1 to j do\nbegin\nif i mod 2=1 then\nif i-(i div 2)=s then\nwriteln(z[i]);\nif i mod 2=0 then\nif j-(i div 2)+1=s then\nwriteln(z[i]);\nend;\nend\nelse writeln(-1);\nend."}, {"source_code": "var \n n, k, k1: int64;\n i:longint;\n a:array[1..100000]of int64;\nbegin\n read(n,k);\n k1:=0;\n for i:=1 to round(sqrt(n)) do\n if n mod i =0 then \n begin\n inc(k1);\n a[k1]:=i;\n end;\n\n for i:=k1 downto 1 do\n if n div a[i]<>a[i] then \n begin \n inc(k1); \n a[k1]:=n div a[i]; \n end;\n \n if k1i then inc(s);\nend;\nif si then a[s-q+1]:=n div i;\nend;\nwriteln(a[k]);\nend."}, {"source_code": "\n var N , K : Int64;\n i : LongInt;\nbegin\n readLn ( N , K ) ; \n \n for i := 1 to 100000000 do\n begin\n \n if ( N mod I = 0 ) then\n begin\n dec ( K ) ; \n \n if ( K = 0 ) then\n begin\n writeLn ( i ) ;\n halt();\n end;\n end;\n \n end;\n \n for i := 100000000 downto 1 do\n begin\n if ( N mod I = 0 ) and ( N div I > 100000000 ) then\n begin\n dec ( k ) ; \n if ( k = 0 ) then\n begin\n writeLn ( N div I ) ; \n halt();\n end;\n end;\n end;\n \n \n writeLn ( -1 ) ; \n\nend."}, {"source_code": "var a:array [1..1000000] of longint;\nk, j, i:longint;\nn:int64;\nbegin\n read(n, k);\n for i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(j);\n a[j]:=i;\n end;\n if n = sqr(round(sqrt(n))) then\n begin\n dec(j);\n if k > j*2+1 then write (-1) else\n if k = j+1 then write (a[j+1]) else\n if k > j+1 then write (n div a[2*j-k+2]) else\n write (a[k]);\n end else\n begin\n if k > j*2 then write (-1) else\n if (k > j) and (n=1) then write(-1) else\n if k > j then write (n div a[2*j-k+1]) else\n write(a[k]);\n end;\nend."}, {"source_code": "var n,k,kol,kol2:int64;\n i:longint;\n a:array[1..100000]of int64;\nbegin\n read(n,k);\n for i:=1 to round(sqrt(n)) do\n begin\n if n mod i =0\n then begin\n inc(kol);\n a[kol]:=i;\n end;\n end;\n kol2:=kol;\n for i:=kol2 downto 1 do\n begin\n\n if n div a[i]<>a[i]\n then begin inc(kol); a[kol]:=n div a[i]; end;\n end;\n \n if koli then inc(dem);\n end;\n m:=dem;\n\n cnt:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n inc(cnt);\n a[cnt]:=i;\n if n div i<>i then\n begin\n dec(dem);\n a[dem]:=n div i;\n end;\n end;\n\n if k>=m then writeln(-1) else writeln(a[k]);\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..30000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var\nn,k,x:int64;\ni,j,p,m:longint;\na:array[1..100000] of int64;\n begin\nreadln(n,k); i:=0;\n\n for i:=1 to trunc(sqrt(n)) do begin\n if (n mod i=0) then\n begin\n j:=j+1;\n if j=k then\n begin\n writeln(i);\n halt;\n end ;\n a[j]:=n div i;\n end; end;\n\nif trunc(sqrt(n))=sqrt(n) then begin p:=2*j-1;j:=j-1; end else p:=2*j;\nif (k>p) then begin writeln(-1); halt; end else\nbegin\n for i:=1 to j div 2 do\n begin\n x:=a[i];\n a[i]:=a[j-i+1];\n a[j-i+1]:=x\n end;\n if trunc(sqrt(n))=sqrt(n) then write(a[k-j-1]) else write(a[k-j]);\nend;\n end.\n"}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..50000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..100000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..1000000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,max,i,summ:int64; mass:array[0..100000] of int64;\n\nprocedure qSort(l,r:longint);\nvar i,j:longint;\n w,q:int64;\nbegin\n i := l; j := r;\n q := mass[(l+r) div 2];\n repeat\n while (mass[i] < q) do inc(i);\n while (q < mass[j]) do dec(j);\n if (i <= j) then\n begin\n w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n,k);\n\nmax:=trunc(sqrt(n));\n\ni:=1;\n\nwhile(i<=max) do\nbegin\n if(n mod i = 0) then\n begin\n inc(summ);\n mass[summ]:=i;\n if(i <> n div i) then\n begin\n inc(summ);\n mass[summ]:=n div i;\n end;\n end;\n inc(i);\nend;\n\nif(n=k) and (n=1) then\nbegin\n write(1);\n exit;\nend else\n\nif(n=1) then\nbegin\n write('-1');\n exit;\nend;\n\nif(summi) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var q,kol,n,k,a:int64;\ni:longint;\nb:array[1..1000000] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to round(sqrt(n)) do\nif n mod i = 0 then begin inc(kol); a:=n div i; if a<>i then inc(kol); end;\nif koli then b[kol-q+1]:=n div i; end;\nwriteln(b[k]);\nend.\n"}, {"source_code": "var q,kol,n,k,a:int64;\ni:longint;\nb:array[1..1000000] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to round(sqrt(n)) do\n if n mod i = 0 then \n begin \n inc(kol);\n a:=n div i;\n if a<>i then inc(kol);\n end;\n if koli then b[kol-q+1]:=n div i;\n end;\nwriteln(b[k]);\nend."}, {"source_code": "var\n n,sc,k,r,sqx,l,ans:int64;\n i,j:longint;\nbegin\n readln(n,k);\n sqx:=trunc(sqrt(n));\n for i:=1 to sqx do if n mod i =0 then\n begin\n inc(sc);\n if i<>n div i then inc(sc);\n end;\n if scn div i then dec(r);\n if r=k then begin writeln(n div i); halt; end;\n end;\nend."}, {"source_code": "var q,kol,n,k,a:int64;\ni:longint;\nb:array[1..1000000] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to round(sqrt(n)) do\nif n mod i = 0 then begin inc(kol); a:=n div i; if a<>i then inc(kol); end;\nif koli then b[kol-q+1]:=n div i; end;\nwriteln(b[k]);\nend."}, {"source_code": "var \n n, k, k1: int64;\n i:longint;\n a:array[1..100000]of int64;\nbegin\n read(n,k);\n k1:=0;\n for i:=1 to round(sqrt(n)) do\n if n mod i =0 then \n begin\n inc(k1);\n a[k1]:=i;\n end;\n\n for i:=k1 downto 1 do\n if n div a[i]<>a[i] then \n begin \n inc(k1); \n a[k1]:=n div a[i]; \n end;\n \n if k1h) then write(-1)\n else write(d[k]);\n \n \n end; \n\t\nend."}, {"source_code": "var n,k,h,j:qword; i:integer;\n d:array[1..1000000] of qword;\n c:array[1..1000000] of qword;\n kt:boolean;\n \nfunction kiemtra(var a:qword):boolean;\nvar kt:boolean; s:qword;\nbegin\n kt:=false;\n s:=trunc(sqrt(a))*trunc(sqrt(a));\n if (a= s) then kt:=true;\n kiemtra:=kt;\n end;\nbegin\n read(n); read(k);\n h:=0;\n if nh) then write(-1)\n else write(d[k]);\n \n \n end; \n\t\nend."}, {"source_code": "\nvar n, k, res: int64;\n i: LongInt;\n\nbegin\n\n readln (n, k);\n res := -1;\n \n for i := 1 to 100000000 do\n begin\n if (n mod i = 0) then\n dec (k);\n\tif (k = 0) then\n\tbegin\n\t res := i;\n\t break;\n\tend;\n end;\n\n for i := 100000000 downto 1 do\n begin\n if (n mod i = 0) and (n div i > 100000000) then\n\tbegin\n\t dec (k);\n\t if (k = 0) then\n\t begin\n res := n div i;\t\n break;\n end;\t\t\n\tend;\n end;\n \n writeln (res);\n\nend."}, {"source_code": "Program arg;\n\nVar n:int64;\n k:longint;\n res,i:longint;\n\nBegin\n res:=0;\n Readln(n,k);\n For i:=1 to trunc(sqrt(n)) do begin\n\n if n mod i=0 then inc(res);\n if res=k then begin\n Writeln(i);\n halt;\n end;\n\n End;\n\n if trunc(sqrt(n))* trunc(sqrt(n))=n then dec(res);\n For i:=trunc(sqrt(n)) downto 1 do begin\n if n mod i=0 then inc(res);\n\n if res=k then begin\n Writeln(n div i);\n halt;\n end;\n\n End;\n Writeln(-1);\n\nEnd.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\n type mas=array[-10000..550000+1] of int64; integer=longint;\n var i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto:longint;\n ss,ss1:string;\n kol,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n num, urovpoint,predok,urov,summ,place,str,a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n zzz,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n vv,ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]n then pp:=pp+2 else inc(pp); end;\n\n t:=0;\n for i:=1 to round(v) do\n if n mod i=0 then\n begin ii:=i; if ii*ii<>n then\n begin inc(t); a[t]:=i; a[pp+1-t]:=n div i end else\n begin inc(t); a[t]:=i; end;\n end;\n\n if p>pp then write(-1) else\n for i:=p to p do write(a[i],' '); writeln;\n\n\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": "var i,k:longint;\n n,j:int64;\n a:array[1..1000000] of int64;\n\nprocedure quicksort(L,H : integer);\nvar\n i,j,pivot,y : int64;\nbegin\n i := L;\n j := H;\n pivot := a[random(H - L + 1) + L];\n\n repeat\n while a[i] < pivot do inc(i);\n while a[j] > pivot do dec(j);\n if i <= j then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n dec(j);\n end;\n until i > j;\n if L < j then quicksort(L,j);\n if i < H then quicksort(i,H);\nend;\n \nbegin\nread(n,k);\nfor i:=1 to round(sqrt(n)) do\nif n mod i=0 then begin \n inc(j); a[j]:=i; \n if n div i<>i then begin \n inc(j);\n a[j]:=n div i;\n end;\n end; \nquicksort(1,j);\nif k>j then write(-1) else write(a[k]);\nend. "}, {"source_code": "var a:array[1..1000000] of int64;\n n,k,del,k2:int64;\n i:longint;\nbegin\nread(n,del);\nk:=0;\nfor i:=1 to round(sqrt(n)) do\n begin\n if n mod i = 0 then\n begin\n inc(k);\n a[k]:=i;\n end;\n end;\nk2:=k;\nfor i:=k2 downto 1 do\n begin\n if n div a[i] <> a[i] then\n begin\n inc(k);\n a[k]:=n div a[i];\n end;\n end;\nif k>1];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lnum then begin write(-1);halt;end;\n sort(1,num);\n write(a[k]);\nend."}, {"source_code": "program zzz;\n var\n n,k,x,i,z:int64;\n a:array[1..40000]of int64;\nbegin\n read(n,k);\n x:=0;\n i:=1;\n while (i<=sqrt(n)) and (k>x) do\n begin\n if (n mod i=0) then \n begin\n inc(x);\n a[x]:=i;\n end;\n inc(i);\n end;\n if x=k then writeln(i-1)\n else \n begin\n i:=x;\n while (i>=1) and(x a[i]) then inc(x);\n dec(i);\n end;\n if k=x then writeln(n div a[i+1])\n else writeln('-1');\n end;\nend. "}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\ntype ar=array[0..200000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,top:longint;\n a:array[1..100000] of int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:int64);\n var tg:int64;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure qsort(l,r:longint);\n var i,j,mid:longint;\n key:int64;\n begin\n i:=l;\n j:=r;\n mid:=ran(l,r);\n key:=a[mid];\n repeat\n while a[i]key do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if in div i then push(n div i);\n end;\n qsort(1,top);\n if top>1];\nrepeat\nwhile Z[i]x do dec(j);\nif not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;\nuntil (i>j);\nif ii then begin inc(a); Z[a]:=n div i; end; end;\n end;\nsort(1,a);\nif k>a then writeln(-1) else\nwriteln(Z[k]);\n//writeln(un); for i:=1 to un do write(Z[i],' ');\nend.\n"}, {"source_code": "var a:array [1..31622780] of int64;\n\tk:longint;\n\tf,n:int64;\n\nprocedure qs(l,r:longint);\n\tvar i,j,ind:longint;\n\t\tx,w:int64;\nbegin\n\ti:=l;\n\tj:=r;\n\trandomize;\n\tind:=l+random(r-l+1);\n\tx:=a[ind];\n\trepeat\n\t\twhile a[i]x do dec(j);\n\t\tif i <= j then\tbegin\n\t\t\t\t\t\t\tw:=a[i];\n\t\t\t\t\t\t\ta[i]:=a[j];\n\t\t\t\t\t\t\ta[j]:=w;\n\t\t\t\t\t\t\tinc(i);\n\t\t\t\t\t\t\tdec(j);\n\t\t\t\t\t\tend;\n\tuntil i>j;\n\tif l r then\tbegin\n\t\t\t\t\t\t\t inc(k);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta[k]:=l;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinc(k);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta[k]:=r;\n\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t else begin\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tinc(k);\n\t\t\t\t\t\t\t\t\t\t\t \t\t\ta[k]:=l;\n\t\t\t\t\t\t\t\t\t\t\t \t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\tend;\nend;\n\nbegin\n\tk:=0;\n\treadln(f,n);\n\tdel(f);\n//\twriteln(k);\n\tif n > k then begin writeln('-1'); halt; end;\n\tqs(1,k);\n//\tfor h:=1 to k do\n//\t\twrite(a[h],' '); writeln;\n\n\twriteln(a[n]);\nend."}, {"source_code": "var n,k,kol,kol1:int64;\ni:longint;\na:array[1..100000]of int64;\nbegin\nread(n,k);\ni:=1;\nfor i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(kol);\n if n div i <> i then inc(kol);\n end;\nif kol>=k then\nbegin\ni:=1;\nfor i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(kol1);\n a[kol1]:=i;\n a[kol-kol1+1]:=n div i;\n end;\nwrite(a[k]);\nend else write(-1);\nend.\n"}, {"source_code": "const fi='762A.inp'; fo='762A.out';\nvar n,k,tong:int64;\n i:longint;\nbegin\n readln(n,k);\n For i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n dec(k);\n if k=0 then\n begin\n writeln(i);\n halt;\n end;\n end;\n tong:=trunc(sqrt(n));\n if sqrt(n)=trunc(sqrt(n)) then dec(tong);\n For i:=tong downto 1 do\n begin\n if n mod i=0 then\n begin\n dec(k);\n if k=0 then\n begin\n writeln(n div i);\n halt;\n end;\n end;\n end;\n writeln(-1);\nend."}], "negative_code": [{"source_code": "var a:array [1..1000000] of longint;\nk, j, i:longint;\nn:int64;\nbegin\n read(n, k);\n for i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(j);\n a[j]:=i;\n end;\n if k > j*2 then write (-1) else\n if (k > j) and (n=1) then write(-1) else\n if k > j then write (n div a[2*j-k+1]) else\n write(a[k]);\nend."}, {"source_code": "var a:array [1..1000000] of longint;\nk, j, i:longint;\nn:int64;\nbegin\n read(n, k);\n for i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(j);\n a[j]:=i;\n end;\n if n = sqr(round(sqrt(n))) then\n for i:=j-1 downto 1 do\n a[2*j-i] := n div a[i]\n else\n for i:=j downto 1 do\n a[2*j-i+1] := n div a[i];\n if (k>2*j) or (a[k]=0) then write (-1) else\n write(a[k]);\nend."}, {"source_code": "var a:array [1..1000000] of longint;\nk, j, i:longint;\nn:int64;\nbegin\n read(n, k);\n for i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(j);\n a[j]:=i;\n end;\n if k > j*2 then write (-1) else\n if k > j then write (n div a[k-j]) else\n write(a[k]);\nend."}, {"source_code": "var a:array [1..1000000] of longint;\nk, j, i:longint;\nn:int64;\nbegin\n read(n, k);\n for i:=1 to round(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(j);\n a[j]:=i;\n end;\n if k > j*2 then write (-1) else\n if k > j then write (n div a[2*j-k+1]) else\n write(a[k]);\nend."}, {"source_code": "program codechef;\nvar n,k,h,i:integer;\n d:array[1..1000000] of integer;\n c:array[1..1000000] of integer;\n kt:boolean;\nbegin\n read(n); read(k);\n h:=0;\n \n kt:=true;\n for i:=1 to trunc(sqrt(n)) do \n if (n mod i) =0 then\n begin\n inc(h);\n d[h]:=i;\n c[h]:= n div i;\n end;\n \n if (k <= trunc(sqrt(n))) then write(d[k]);\n if (k > trunc(sqrt(n))) and (k<=h) then write(c[k-h+1]);\n if (k>h) then write(-1);\n\t(* your code goes here *)\nend.\n"}, {"source_code": "program codechef;\nvar n,k,h,i:integer;\n d:array[1..1000000] of integer;\n c:array[1..1000000] of integer;\n kt:boolean;\nbegin\n read(n); read(k);\n h:=0;\n if ntrunc(sqrt(n))) then write(c[k-h]);\n if (k>h*2) then write(-1);\n end; \n\t\nend."}, {"source_code": "program codechef;\nvar n,k,h,j:qword; i:integer;\n d:array[1..1000000] of qword;\n c:array[1..1000000] of qword;\n kt:boolean;\nbegin\n read(n); read(k);\n h:=0;\n if nh*2) then write(-1)\n else\n begin\n if (k<=trunc(sqrt(n))) then write(d[k]);\n if (k>trunc(sqrt(n))) then write(c[k-h]);\n end;\n ;\n end; \n\t(* your code goes here *)\nend."}, {"source_code": "program codechef;\nvar n,k,h,i:integer;\n kt:boolean;\nbegin\n read(n); read(k);\n h:=0;\n kt:=true;\n for i:=1 to n do \n begin\n if(n mod i)=0 then\n begin\n inc(h);\n if h=k then \n begin\n write(i);\n kt:=false;\n exit;\n end;\n end;\n \n end;\n if kt=true then write(1);\n\t(* your code goes here *)\nend.\n"}, {"source_code": "Program arg;\n\nVar n:int64;\n k:longint;\n res,i:longint;\n\nBegin\n res:=0;\n Readln(n,k);\n For i:=1 to trunc(sqrt(n)) do begin\n if n mod i=0 then inc(res);\n if res=k then begin\n Writeln(i);\n halt;\n end;\n\n End;\n // Writeln(trunc(sqrt(n)));\n if i*i=n then dec(res);\n For i:=trunc(sqrt(n)) downto 1 do begin\n if n mod i=0 then inc(res);\n if res=k then begin\n Writeln(n div i);\n halt;\n end;\n\n End;\n Writeln(-1);\n\nEnd."}, {"source_code": "program zzz;\n var\n n,k,x,i:int64;\nbegin\n read(n,k);\n x:=0;\n i:=1;\n while (i<=sqrt(n)) and (k>x) do\n begin\n if (n mod i=0) then inc(x);\n inc(i);\n end;\n if x=k then\n writeln(i-1)\n else if x=k-1 then writeln(n)\n else if (x=k-2) and(n mod(n div 2)=0) then writeln(n div 2) \n else writeln('-1');\nend."}, {"source_code": "program zzz;\n var\n n,k,x,i,z:int64;\n a:array[1..40000]of int64;\nbegin\n read(n,k);\n x:=0;\n i:=1;\n while (i<=sqrt(n)) and (k>x) do\n begin\n if (n mod i=0) then \n begin\n inc(x);\n a[x]:=i;\n end;\n inc(i);\n end;\n if x=k then writeln(i-1)\n else \n begin\n i:=x;\n while (i>=1) and(x x) do\n begin\n if (n mod i=0) then inc(x);\n inc(i);\n end;\n if x=k then\n writeln(i-1)\n else if x=k-1 then writeln(n)\n else if x=k-2 then writeln(n div 2) \n else writeln('-1');\nend."}, {"source_code": "var j,m,i,k:integer;\nn:int64;\nall:array[1..1000]of longint;\n \n \nbegin\n\nreadln(n,k);\nm:=0;\nj:=0;\nfor i:=1 to n do\n if (n mod i)=0 then\n begin\n m:=m+1;\n j:=j+1;\n all[j]:=i;\n end;\nall[j+1]:=n;\nm:=m+1;\n if m a[i] then\n begin\n inc(kol);\n a[kol]:=n div a[i];\n end;\n end;\n if kol0 then begin\ni:=1;\nc:=0;\nrepeat\nif (n mod i)=0 then begin c:=c+1; ind:=i; end;\ni:=i+2;\nuntil (c=k)or(i=n)or(n-cp) then begin writeln(-1); halt; end else\nbegin\n for i:=1 to j div 2 do\n begin\n x:=a[i];\n a[i]:=a[j-i+1];\n a[j-i+1]:=x\n end;\n if trunc(sqrt(n))=sqrt(n) then write(a[k-j-1]) else write(a[k-j]);\nend;\n end.\n"}, {"source_code": "var\nn,k:int64;\ni,j,p:longint;\na:array[1..10000000] of int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]< x do\n inc(i);\n while xj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if ln\nthen begin\nj:=j+1;\na[j]:=n div i;\n end;\nend;\nend;\n\n\n p:=j;\n sort(1,p);\n for i:=1 to p do\n\n if (k>p) then writeln(-1) else writeln(a[k]);\n end.\n"}, {"source_code": "var\nn,k:int64;\ni,j,p:longint;\na:array[1..10000000] of int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]< x do\n inc(i);\n while xj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if ln\nthen begin\nj:=j+1;\na[j]:=n div i;\n end;\nend;\nend;\n\n\n p:=j;\n sort(1,p);\n\n if (k>p) then writeln(-1) else writeln(a[k]);\n end.\n"}, {"source_code": "var\nn,k,d:int64;\ni,j,p:longint;\na:array[1..10000000] of longint;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]< x do\n inc(i);\n while xj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lround(sqrt(n))\nthen begin\nj:=j+1;\na[j]:=n div i;\n end;\nend;\nend;\n\n\n p:=j;\n sort(1,p);\n if (k>p) then writeln(-1) else writeln(a[k]);\n end.\n"}, {"source_code": "var\nn,k:int64;\ni,j,p:longint;\na:array[1..10000000] of int64;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]< x do\n inc(i);\n while xj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lround(sqrt(n))\nthen begin\nj:=j+1;\na[j]:=n div i;\n end;\nend;\nend;\n\n\n p:=j;\n sort(1,p);\n if (k>p) then writeln(-1) else writeln(a[k]);\n end.\n"}, {"source_code": "var n,k,max,i,summ:int64; mass:array[0..100000] of int64;\n\nprocedure qSort(l,r:longint);\nvar i,j:longint;\n w,q:int64;\nbegin\n i := l; j := r;\n q := mass[(l+r) div 2];\n repeat\n while (mass[i] < q) do inc(i);\n while (q < mass[j]) do dec(j);\n if (i <= j) then\n begin\n w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n,k);\n\nmax:=trunc(sqrt(n));\n\ni:=1;\n\nwhile(i<=max) do\nbegin\n if(n mod i = 0) then\n begin\n inc(summ);\n mass[summ]:=i;\n inc(summ);\n mass[summ]:=n div i;\n end;\n inc(i);\nend;\n\nif(n=k) and (n=1) then\nbegin\n write(1);\n exit;\nend else\n\nif(n=1) then\nbegin\n write('-1');\n exit;\nend;\n\nif(summ j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n,k);\n\nmax:=trunc(sqrt(n));\n\ni:=1;\n\nwhile(i<=max) do\nbegin\n if(n mod i = 0) then\n begin\n inc(summ);\n mass[summ]:=i;\n inc(summ);\n mass[summ]:=n div i;\n end;\n inc(i);\nend;\n\nif(n=k) and (n=1) then\nbegin\n write(1);\n exit;\nend;\n\nif(summ j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n,k);\n\nmax:=trunc(sqrt(n));\n\ni:=1;\n\nwhile(i<=max) do\nbegin\n if(n mod i = 0) then\n begin\n inc(summ);\n mass[summ]:=i;\n inc(summ);\n mass[summ]:=n div i;\n end;\n inc(i);\nend;\n\nif(n=k) and (n=1) then\nbegin\n write(1);\n exit;\nend;\n\nif(summ*2 j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n,k);\n\nmax:=trunc(sqrt(n));\n\ni:=1;\n\nwhile(i<=max) do\nbegin\n if(n mod i = 0) then\n begin\n inc(summ);\n mass[summ]:=i;\n inc(summ);\n mass[summ]:=n div i;\n end;\n inc(i);\nend;\n\nif(n=k) and (n=1) then\nbegin\n write(1);\n exit;\nend else\n\nif(n=1) then\nbegin\n write('-1');\nend;\n\nif(summk1 then write(-1);\nend.\n"}, {"source_code": "var a:array[1..1000000] of int64;\n n,k,del,k2:int64;\n i:longint;\nbegin\nread(n,del);\nk:=0;\nfor i:=1 to round(sqrt(n)) do\n begin\n if n mod i = 0 then\n begin\n inc(k);\n a[k]:=i;\n end;\n end;\nk2:=k;\nfor i:=k2-1 downto 1 do\n begin\n if n mod a[i] = 0 then\n begin\n inc(k);\n a[k]:=n div a[i];\n end;\n end;\nif kx do dec(j);\n\t\tif i <= j then\tbegin\n\t\t\t\t\t\t\tw:=a[i];\n\t\t\t\t\t\t\ta[i]:=a[j];\n\t\t\t\t\t\t\ta[j]:=w;\n\t\t\t\t\t\t\tinc(i);\n\t\t\t\t\t\t\tdec(j);\n\t\t\t\t\t\tend;\n\tuntil i>j;\n\tif l r then\tbegin\n\t\t\t\t\t\t\t inc(k);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta[k]:=l;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinc(k);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta[k]:=r;\n\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t else begin\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tinc(k);\n\t\t\t\t\t\t\t\t\t\t\t \t\t\ta[k]:=l;\n\t\t\t\t\t\t\t\t\t\t\t \t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\tend;\nend;\n\nbegin\n\tk:=0;\n\treadln(f,n);\n\tdel(f);\n//\twriteln(k);\n\tif n > k then begin writeln('-1'); halt; end;\n\tqs(1,k);\n//\tfor h:=1 to k do\n//\t\twrite(a[h],' '); writeln;\n\n\twriteln(a[n]);\nend."}, {"source_code": "program Matfey;\nvar\nx5,x1,x2,x3,x4,qb,i,qe,x9,x8,x10,j,d,x7,x11,x12,k,e,n,r,u,g : longint;\ns1,s2,s3,s4,s5 : string;\nc1,c2,c3,c4,c5 : char;\ni1,i2 : integer;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;\nq : array[1..2000000,1..4] of longint;\na2 : array[-16..16,-16..16] of longint;\na1 : array[1..100000] of string;\n\nprocedure put(x,y,n:longint);\nbegin\nif x<1 then writeln('x:=',x);\nif y<1 then writeln('y:=',y);\n\nq[qe,1]:=x;\nq[qe,2]:=y;\nq[qe,3]:=n;\nq[qe,4]:=qb-1;\na2[x,y]:=1;\nqe:=qe+1;\nend;\n\nprocedure putAll(x,y,n:longint);\nbegin\nif ((x+2)0 ) and (a2[x+2,y-1]=0) then\nput(x7+2,y-1,n);\n\nif ((x+1)0) and (a2[x+1,y-2]=0) then\nput(x+1,y-2,n);\n\nif ( (x-1) >0 ) and ((y+2)0) and ((y-2) > 0) and (a2[x-1,y-2]=0) then\nput(x-1,y-2,n);\n\nif ((x-2)>0) and ((y-1)>0) and (a2[x-2,y-1]=0) then\nput(x-2,y-1,n);\n\nif ((x-2)>0) and ((y+1)0) then begin x3:=i; x4:=j; end;\nend;\nend;\n\nqb:=1;\nqe:=1;\nx11:=0;\n\nput(x1,x2,0);\n\nfor i:=1 to 300 do\nbegin\n\nget(x7,x8,x9);\n\nif (x7=x3) and (x8=x4) then\nbegin\n\n x10:=q[qb-1,4];\n for j:=qb-1 downto 1 do\n if j=x10 then\n begin\n x10:=q[j,4];\n a1[q[j,1]][q[j,2]] :='@';\n {writeln(q[j,1],' ', q[j,2],' ',q[j,3],' ', q[j,4]); }\n end;\nx11:=1;\n\nbreak;\nend;\nx9:=x9+1;\n\nputAll(x7,x8,x9);\n\nend;\n\n\nif x11=1 then\nbegin\nfor i:=1 to x5 do\n writeln(a1[i]);\nend;\n\n{close(input); close(output);}\n\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;\ni : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\ns1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;\ni1,i2,i3,i4,i5 : integer;\n{q : array[1..3000000,1..3] of longint;}\na1 : array[1..1000000{,-160..160}] of int64;\nbegin\n{assign(input,'DIVSUM.IN'); reset(input);\nassign(output,'DIVSUM.OUT'); rewrite(output);}\nreadln(x1,x2);\n\nr1:=sqrt(x1);\nx8:=trunc(r1);\nx3:=1;\n\nfor i:=1 to x8 do\nbegin\n\nif (x1 mod i)=0 then\nbegin\n if x3=x2 then\n begin\n writeln(i);\n exit;\n end;\n\n if i<>(x1 div i) then\n begin\n a1[x3]:=x1 div i;\n x3:=x3+1;\n end;\n\nend;\n\n\nend;\n\n\n\nfor i:=x3 downto 1 do\nbegin\nif (i=(x2-x3+1)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;\nend;\nwriteln(-1);\n{close(input); close(output);}\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;\ni : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\ns1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;\ni1,i2,i3,i4,i5 : integer;\n{q : array[1..3000000,1..3] of longint;}\na1 : array[1..1000000{,-160..160}] of int64;\nbegin\n{assign(input,'DIVSUM.IN'); reset(input);\nassign(output,'DIVSUM.OUT'); rewrite(output);}\nreadln(x1,x2);\n\nr1:=sqrt(x1);\nx8:=trunc(r1);\nx3:=1;\n\nfor i:=1 to x8 do\nbegin\n\nif (x1 mod i)=0 then\nbegin\n if x3=x2 then\n begin\n writeln(i);\n exit;\n end;\n\n if i<>(x1 div i) then\n begin\n\n a1[x3]:=x1 div i;\n x3:=x3+1;\n end;\n\nend;\n\n\nend;\n{\nfor i:=1 to 5 do\nbegin\nwriteln(a1[i]);\nend; }\nx4:=1;\nx3:=x3-1;\nfor i:=x3 downto 1 do\nbegin\nif (x4=(x2-x3)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;\nx4:=x4+1;\nend;\nwriteln(-1);\n{close(input); close(output);}\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;\ni : longint;\nc1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;\ns1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;\ni1,i2,i3,i4,i5 : integer;\n{q : array[1..3000000,1..3] of longint;}\na1,a2 : array[1..10000000{,-160..160}] of longint;\nbegin\n{assign(input,'DIVSUM.IN'); reset(input);\nassign(output,'DIVSUM.OUT'); rewrite(output);}\nreadln(x1,x2);\n\nr1:=sqrt(x1);\nx8:=trunc(r1);\nx3:=1;\nfor i:=1 to x8 do\nbegin\n\nif (x1 mod i)=0 then\nbegin\nif x3=x2 then\nbegin\n\nwriteln(i);\nexit;\n\nend;\nif i<>(x1 div i) then\nbegin\na1[x3]:=x1 div i;\nx3:=x3+1;\nend;\nend;\n\nend;\n\nfor i:=x3 downto 1 do\nbegin\nif (i=(x2-x3+1)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;\nend;\nwriteln(-1);\n{close(input); close(output);}\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program bt;\nconst \tfi=''; fo='';\nvar \tf:text;\n\tn,k:int64;\n\ta:array[1..1000000] of longint;\n//\nprocedure doctep;\nbegin\n\tassign(f,fi); reset(f);\n\treadln(f,n,k);\n\tclose(f);\nend;\n//\nprocedure ghitep;\nvar \ti,j,l,tmp,d:longint;\nbegin\n\td:=0;\n\tassign(f,fo); rewrite(f);\n if n=1 then\n begin\n if k>1 then writeln(f,-1);\n if k=1 then writeln(f,1);\n end\n else\n begin\n\tfor i:=1 to trunc(sqrt(n)) do\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(d);\n\t\t\ta[d]:=i;\n\t\tend;\n\tif 2*d=k then writeln(f,a[k]);\n\t\tif d=k then writeln(f,a[k]);\n\t\tif d x do j := j - 1;\n if i<=j\n then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n i := i + 1; j := j - 1;\n end;\n until i>j;\n if Ln then begin\n inc(o);\n a[o]:=n div i end;\n end;\n quicksort(1,o);\n if k>o then writeln(-1)\n else writeln(a[k]);\n end."}, {"source_code": "var i,o,k:longint; a:array[1..1000000] of int64;\n n,t:int64;\n Procedure QuickSort(L,R : longint);\n var\n i, j : longint;t,x:int64;\n begin\n i := L; j := R; x:=a[L+random(R-L+1)];\n repeat\n while a[i] < x do i := i + 1;\n while a[j] > x do j := j - 1;\n if i<=j\n then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n i := i + 1; j := j - 1;\n end;\n until i>j;\n if Ln then begin\n inc(o);\n a[o]:=n div i end;\n end;\n quicksort(1,o);\n if k>o then writeln(-1)\n else writeln(a[k]);\n end."}, {"source_code": "var k,x,y,i:longint; data:boolean;\n n,t:int64;\n begin\n readln(n);\n t:=trunc(sqrt(n));\n y:=t;\n for i:=1 to y do\n if n mod i = 0 then begin\n inc(x);\n if x=k then begin\n write('i');\n data:=true;\n break\n end\n end;\n if not data then write(-1)\n end."}, {"source_code": "program tmp15;\n var\n n:qword;\n flag:boolean;\n nx,i,k,t,all:longint;\n procedure away(x:longint);\n begin\n writeln(x);halt;\n end;\n begin\n readln(n,k);t:=0;\n nx:=trunc(sqrt(n));\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(i);\n end;\n end;\n all:=2*t;\n if nx*nx=k then dec(all);\n if k>all then away(-1);\n k:=2*t-k+1;\n t:=0;\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(n div i);\n end;\n end;\n end.\n"}, {"source_code": "program tmp15;\n var\n n:qword;\n x:extended;\n flag:boolean;\n nx,i,k,t,all:longint;\n procedure away(x:qword);\n begin\n writeln(x);halt;\n end;\n begin\n readln(n,k);t:=0;\n nx:=trunc(sqrt(n));\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(i);\n end;\n end;\n all:=2*t;\n x:=sqrt(n);\n if x-nx<=1E-8 then dec(all);\n if k>all then\n begin\n writeln(-1);halt;\n end;\n k:=2*t-k+1;\n t:=0;\n for i:=1 to nx do\n begin\n if n mod i=0 then\n begin\n inc(t);\n if t=k then away(n div i);\n end;\n end;\n end.\n"}, {"source_code": "var n,k,kol,kol2:int64;\n i:longint;\n a:array[1..100000]of int64;\nbegin\n read(n,k);\n for i:=1 to round(sqrt(n)) do\n begin\n if n mod i =0\n then begin\n inc(kol);\n a[kol]:=i;\n end;\n end;\n kol2:=kol;\n for i:=kol2 downto 1 do\n begin\n inc(kol);\n if n div a[i]<>a[i]\n then a[kol]:=n div a[i];\n end;\n if koli then inc(dem);\n end;\n m:=dem;\n\n cnt:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n inc(cnt);\n a[cnt]:=i;\n if n div i<>i then\n begin\n dec(dem);\n a[dem]:=n div i;\n end;\n end;\n\n if k>=m then writeln(-1) else writeln(a[k]);\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var n,k,count,result:int64;\n\ti,j:int32;\n\tA:array[1..10000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=1;\n\tFor i:=1 to trunc(sqrt(n)) do\n\t\tIf n mod i=0 then\n\t\t\tBegin\n\t\t\t\tA[count]:=n div i;\n\t\t\t\tinc(count);\n\t\t\t\tIf (count=k) then\n\t\t\t\t\tBegin\n\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\thalt;\n\t\t\t\t\tEnd;\n\t\t\tEnd;\n\n\tdec(count,1);\n\tIf (count*2>=k) then\n\t\tresult:=A[2*count-k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..10000000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tA1[j]:=n;\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\n\tIf (j>=k) then\n\t\tresult:=n div A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result:int64;\n\ti:int32;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tFor i:=1 to (n div 2)+1 do\n\t\tBegin\n\t\t\tIf (i>round(sqrt(n))) and (count<2) then break;\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tinc(count);\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tresult:=i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\tEnd;\n\t//Writeln(count);\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result:int64;\n\ti:int32;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tFor i:=1 to (n div 2)+1 do\n\t\tBegin\n\t\t\tIf (i>round(sqrt(n))) and (count<2) then break;\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tinc(count);\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tresult:=i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\tEnd;\n\tWriteln(count);\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result:int64;\n\ti,j:int32;\n\tA:array[1..10000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=1;\n\tFor i:=2 to trunc(sqrt(n)) do\n\t\tIf n mod i=0 then\n\t\t\tBegin\n\t\t\t\tA[count]:=n div i;\n\t\t\t\tinc(count);\n\t\t\t\tIf (count=k) then\n\t\t\t\t\tBegin\n\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\thalt;\n\t\t\t\t\tEnd;\n\t\t\tEnd;\n\n\tA[count]:=n;\n\tIf (k-count>0) then\n\t\tresult:=A[k-count];\n\n\tWrite(result);\nEnd."}, {"source_code": "var n,k,count,result,i,j:int64;\n\tA,A1:array[1..10000000] of int64;\nBegin\n\tRead(n,k);\n\tresult:=-1;\n\tcount:=0;\n\tj:=0;\n\ti:=1;\n\tWhile (i<=trunc(sqrt(n))) do\n\t\tBegin\n\t\t\tIf n mod i=0 then\n\t\t\t\tBegin\n\t\t\t\t\tinc(count);\n\t\t\t\t\t//Write(i,' ');\n\t\t\t\t\tIf (n div i<>i) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tinc(j);\n\t\t\t\t\t\t\tA[j]:=n div i;\n\t\t\t\t\t\tEnd;\n\n\t\t\t\t\tIf (count=k) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tWrite(i);\n\t\t\t\t\t\t\thalt;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\t\tinc(i);\n\t\tEnd;\n\n\tdec(k,count);\n\ti:=j;\n\tWhile(i>1) do \n\t\tBegin\n\t\t\tA1[j-i+1]:=A[i];\n\t\t\tdec(i);\n\t\tEnd;\n\tIf (count>=k+1) then\n\t\tresult:=A1[k];\n\t\n\tWrite(result);\nEnd."}, {"source_code": "var i,j,k:longint;\n n:int64;\n a:array[1..1000000] of int64;\n\nprocedure quicksort(L,H : integer);\nvar\n i,j,pivot,y : integer;\nbegin\n i := L;\n j := H;\n pivot := a[random(H - L + 1) + L];\n\n repeat\n while a[i] < pivot do inc(i);\n while a[j] > pivot do dec(j);\n if i <= j then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n dec(j);\n end;\n until i > j;\n if L < j then quicksort(L,j);\n if i < H then quicksort(i,H);\nend;\n \nbegin\nread(n,k);\nfor i:=1 to round(sqrt(n)) do\nif n mod i=0 then begin \n inc(j); a[j]:=i; \n if n div i<>i then begin \n inc(j);\n a[j]:=n div i;\n end;\n end; \nquicksort(1,j);\nif k>j then write(-1) else write(a[k]);\nend. "}, {"source_code": "begin\nwrite(-1);\nend."}, {"source_code": "var i,f:longint;\nn,m,k:int64;\na,b:array[0..1000000]of int64;\nbegin\nreadln(n,m);\nfor i:=1 to trunc(sqrt(n)) do \nif n mod i=0 then \nbegin\ninc(k);\na[k]:=i;\nb[k]:=n div i;\nend;\nfor i:=1 to k do\nif m=i then \nbegin\nwriteln(a[i]);\nf:=1;\nbreak;\nend;\nif a[k]=b[1] then dec(k);\nfor i:=1 to k do \nif m=i+k then \nbegin\nwriteln(b[i]);\nf:=1;\nbreak;\nend;\nif f=0 then writeln(-1);\nend."}, {"source_code": "program z1;\nvar i,j,k,l,m,uk,un:longint; Z,Q:array[0..10000] of int64; n,d,a,b,c,old:int64;\n\nProcedure sort(l,r:longint);\nvar i,j:longint; x,y:int64;\nbegin\ni:=l; j:=r; x:=Z[(l+r)>>1];\nrepeat\nwhile Z[i]x do dec(j);\nif not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;\nuntil (i>j);\nif i1 then begin inc(uk); Q[uk]:=n; end;\nZ[1]:=1; un:=1; old:=0;\nfor i:=1 to uk do\n begin\n a:=un;\n if Q[i]=Q[i-1] then b:=old else b:=1;\n for j:=a downto b do\n begin\n inc(un); Z[un]:=Z[j]*Q[i];\n end;\n old:=un;\n end;\nsort(1,un);\nif k>un then write('-1') else write(Z[k]);\nend."}, {"source_code": "program z1;\nvar i,j,l,m,uk,un:longint; Z,Q:array[0..100000] of int64; n,d,a,b,c,old,k:int64;\n\nProcedure sort(l,r:longint);\nvar i,j:longint; x,y:int64;\nbegin\ni:=l; j:=r; x:=Z[(l+r)>>1];\nrepeat\nwhile Z[i]x do dec(j);\nif not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;\nuntil (i>j);\nif i1 then begin inc(uk); Q[uk]:=n; end;\nZ[1]:=1; un:=1; old:=0;\nfor i:=1 to uk do\n begin\n a:=un;\n if Q[i]=Q[i-1] then b:=old else b:=1;\n for j:=a downto b do\n begin\n inc(un); Z[un]:=Z[j]*Q[i];\n end;\n old:=un;\n end;\nsort(1,un);\nif k>un then writeln('-1') else writeln(Z[k]);\n//for i:=1 to un do write(Z[i],' ');\nend.\n"}, {"source_code": "program z1;\nvar i,j,l,m,uk,un,mark:longint; Z,Q:array[0..100000] of int64; n,d,a,b,c,old,k:int64;\n\nProcedure sort(l,r:longint);\nvar i,j:longint; x,y:int64;\nbegin\ni:=l; j:=r; x:=Z[(l+r)>>1];\nrepeat\nwhile Z[i]x do dec(j);\nif not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;\nuntil (i>j);\nif i0 then writeln('-1');\nend."}, {"source_code": "var\n i,j:longint;\n n,k:int64;\n x:array[1..20000000]of int64;\nprocedure sort(l,r:longint);\nvar i,e,j,t:longint;\nbegin\n i:=l;\n j:=r;\n e:=x[l+random(r-l+1)];\n while i<=j do\n begin\n while e>x[i] do inc(i);\n while el then sort(l,j);\nend; \nbegin\n read(n,k);\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then \n begin \n inc(j);x[j]:=n div i;\n inc(j);x[j]:=i;\n end;\n \n if k>j then begin writeln(-1);halt;end;\n \n sort(1,j);\n \n //for i:=1 to j do\n //write(x[i],' ');\n \n writeln(x[k]);\nend. "}, {"source_code": "var\n i,j:longint;\n n,k:int64;\n x:array[1..20000000]of int64;\nprocedure sort(l,r:longint);\nvar i,e,j,t:longint;\nbegin\n i:=l;\n j:=r;\n e:=x[l+random(r-l+1)];\n while i<=j do\n begin\n while e>x[i] do inc(i);\n while el then sort(l,j);\nend; \nbegin\n read(n,k);\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then \n begin \n inc(j);x[j]:=n div i;\n if n div i<>i then begin\n inc(j);x[j]:=i;end;\n end;\n \n if k>j then begin writeln(-1);halt;end;\n \n sort(1,j);\n \n //for i:=1 to j do\n //write(x[i],' ');\n \n writeln(x[k]);\nend. "}, {"source_code": "var\n n:int64;\n m,k,i,j:longint;\n a:array[1..1000000] of longint;\nbegin\n readln (n,k);\n m:=round(sqrt(n));\n i:=1;\n j:=0;\n while (j0)and(j0)and(ji then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k])\n else\n \nEnd."}, {"source_code": "Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;\nBegin\n readln(n,k);d:=1;f:=0;\n for d:=1 to round(sqrt(n)) do\n if n mod d =0 then\n begin\n c:=c+1;\n ans1[c]:=d;\n ans2[c]:=n div d;\n end;\n i:=c*2;\n if d*d=n then\n begin\n c:=c+1;\n ans1[c]:=d;\n f:=1;\n i:=i+1;\n end;\n if k>i then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k]) \nEnd."}, {"source_code": "Var ans1,ans2:array [1..30000] of int64;k,c,d,i,f:longint;n:int64;\nBegin\n readln(n,k);d:=1;f:=0;\n for d:=1 to round(sqrt(n)) do\n\n if n mod d =0 then\n begin\n c:=c+1;\n ans1[c]:=d;\n ans2[c]:=n div d;\n end;\n i:=c*2;\n if d*d=n then\n begin\n c:=c+1;\n ans1[c]:=d;\n f:=1;\n i:=i+1;\n end;\n if k>i then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k]) \nEnd."}, {"source_code": "Var ans1,ans2:array [1..10000] of int64;k,c,d,i,f:longint;n:int64;\nBegin\n readln(n,k);d:=1;f:=0;\n while d*di then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k])\n else\n \nEnd.\n"}, {"source_code": "Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;\nBegin\n readln(n,k);d:=1;f:=0;\n if (n=1) and (k>=2) then\n begin\n writeln(-1);\n halt;\n end;\n for d:=1 to round(sqrt(n)) do\n if n mod d =0 then\n begin\n c:=c+1;\n ans1[c]:=d;\n ans2[c]:=n div d;\n end;\n i:=c*2;\n if d*d=n then\n begin\n c:=c+1;\n ans1[c]:=d;\n f:=1;\n i:=i+1;\n end;\n if k>i then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k]) \nEnd."}, {"source_code": "Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;\nBegin\n readln(n,k);d:=1;f:=0;\n for i:=1 to round(sqrt(n)) do\n if n mod d =0 then\n begin\n c:=c+1;\n ans1[c]:=d;\n ans2[c]:=n div d;\n end;\n i:=c*2;\n if d*d=n then\n begin\n c:=c+1;\n ans1[c]:=d;\n f:=1;\n i:=i+1;\n end;\n if k>i then\n writeln(-1)\n else \n if (k>c) then\n writeln(ans2[i-k+1]) \n else\n if k<=c then\n writeln(ans1[k])\n else\n \nEnd."}, {"source_code": "var f1,f2 : text;\n a : array[1..10000000] of int64;\n kt : boolean;\n n,k,t,d : int64;\n i : longint;\n\nbegin\nassign(f1,'') ; reset(f1);\nassign(f2,'') ; rewrite(f2);\nreadln(f1,n,k);\nkt := false;\nfor i := 1 to trunc(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(d);\n a[d] := i;\n if i*i = n then\n kt := true;\n end;\nt := d*2;\nif kt = true then dec(t);\nif k > t then\n begin\n write(f2,-1);\n close(f1);\n close(f2);\n halt;\n end;\nfor i := 1 to d do\n if k = i then\n begin\n write(f2,a[i]);\n close(f1);\n close(f2);\n halt\n end\n else if i + d = k then\n begin\n write(f2,n div a[i]);\n close(f1);\n close(f2);\n halt\n end;\nclose(f1);\nclose(f2);\nend.\n"}, {"source_code": "var f1,f2 : text;\n a : array[1..10000000] of int64;\n kt : boolean;\n n,k,t,d : int64;\n i : longint;\n\nbegin\nassign(f1,'') ; reset(f1);\nassign(f2,'') ; rewrite(f2);\nreadln(f1,n,k);\nkt := false;\nfor i := 1 to trunc(sqrt(n)) do\n if n mod i = 0 then\n begin\n inc(d);\n a[d] := i;\n end;\nif trunc(sqrt(n)) * trunc(sqrt(n)) = n then kt := true; \nt := d*2;\nif kt = true then dec(t);\nif k > t then\n begin\n write(f2,-1);\n close(f1);\n close(f2);\n halt;\n end;\nfor i := 1 to d do\n if k = i then\n begin\n write(f2,a[i]);\n close(f1);\n close(f2);\n halt\n end\n else if i + d = k then\n begin\n write(f2,n div a[i]);\n close(f1);\n close(f2);\n halt\n end;\nclose(f1);\nclose(f2);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g :text;\n n,k :int64;\n a :array[0..100002] of int64;\nprocedure nhap;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure main;\nvar dem,i,u :longint;\nbegin\n dem:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i =0 then\n begin\n inc(dem);a[dem]:=i;\n end;\n u:=ord(sqr(trunc(sqrt(n)))=n);\n if dem*2-u=k then writeln(g,a[dem])\n else writeln(g,n div a[dem-(k-dem)+1-u]);\nend;\n\nBEGIN\n Nhap;\n main;\n close(g);\nEND."}, {"source_code": "var s,i,e:longint;\nn,k,a:int64;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,k);\n s:=trunc(sqrt(n));\n for i:=1 to s do\n if n mod i=0 then\n begin\n inc(e);\n a:=i;\n if e=k then break;\n end;\n if (n mod 2=0)and(e 1) then begin writeln(-1); halt; end;\n\n for i:=1 to m do if n mod i = 0 then\n begin\n inc(t);\n st[t]:=n div i;\n if t = k then begin writeln(i); halt; end;\n end;\n\n stn:=t;\n for i:=stn downto 1 do if n mod st[i] = 0 then\n begin\n inc(t);\n if t = k then begin writeln(st[i]); halt; end;\n end;\n\n writeln(-1);\nend.\n"}, {"source_code": "program O_O;\ntype\n\tll=longint;\n\tbo=boolean;\n\tarr=array[0..10000000] of int64;\nvar\n\ti,k:ll;\n\tn,j:int64;\n\ta:arr;\nbegin\n\treadln(n,k);\n\tj:=0;\n\tfor i:=1 to trunc(sqrt(n)+0.5) do \n\tbegin\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(j);\n\t\t\ta[j]:=i;\n\t\tend;\n\tend;\n\tif k>2*j then writeln(-1)\n\telse\n\t\tif k<=j then writeln(a[k]) \n\telse \n\t\twriteln(n div a[2*j+1-k]);\nend.\n\t\n\t\n\t\n\n\n\n\n\n"}, {"source_code": "program O_O;\ntype\n\tll=longint;\n\tbo=boolean;\n\tarr=array[0..10000000] of int64;\nvar\n\ti,j,k:ll;\n\tn:int64;\n\ta:arr;\nbegin\n\treadln(n,k);\n\tj:=0;\n\tfor i:=1 to trunc(sqrt(n)+0.5) do \n\tbegin\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(j);\n\t\t\ta[j]:=i;\n\t\tend;\n\tend;\n\tif k>2*j then writeln(-1)\n\telse\n\t\tif k<=j then writeln(a[k]) \n\telse \n\t\twriteln( n div a[k-j]);\nend.\n\t\n\t\n\t\n\n\n\n\n\n"}, {"source_code": "program O_O;\ntype\n\tll=longint;\n\tbo=boolean;\n\tarr=array[0..10000000] of int64;\nvar\n\ti,k:ll;\n\tn,j:int64;\n\ta:arr;\nbegin\n\treadln(n,k);\n\tj:=0;\n\tfor i:=1 to trunc(sqrt(n)+0.5) do \n\tbegin\n\t\tif n mod i=0 then\n\t\tbegin\n\t\t\tinc(j);\n\t\t\ta[j]:=i;\n\t\tend;\n\tend;\n\tif (k>2*j)or((j=1)and (k>j) ) then writeln(-1)\n\telse\n\t\tif k<=j then writeln(a[k]) \n\telse \n\t\twriteln(n div a[2*j+1-k]);\nend.\n\t\n\t\n\t\n\n\n\n\n\n"}, {"source_code": "var n,k,q,j:int64;\n i:longint;\n t:array [1..100000] of int64;\nbegin\n readln(n,k);\n q:=0;\n j:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i = 0 then inc(q,2); \n \n if q < k then begin writeln(-1); exit; end;\n \n for i:=1 to trunc(sqrt(n)) do\n if n mod i = 0 then begin inc(j); t[j]:=i; t[q-j+1]:=n div i; end;\n \n writeln(t[k]);\n \nend.\n \n "}], "src_uid": "6ba39b428a2d47b7d199879185797ffb"} {"source_code": "begin\n var arr := new integer[100];\n var arrOgran := new boolean[100];\n var numPrib := 0;\n var numBlud := 0;\n var n, g: integer;\n Readln(n, g);\n \n for var i:= 1 to n do\n begin\n var h: integer;\n Read(h);\n arr[h - 1] += 1;\n end;\n \n if (n = 0) or (g = 0) then Print('0')\n else \n begin\n \n if not (arr.Max mod g = 0) then numBlud += 1;\n numBlud += (arr.Max div g);\n \n for var i := 0 to arr.Length - 1 do\n begin\n if (arr[i] > 0) and (not arrOgran[i]) then numPrib += 1;\n arrOgran[i] := True;\n end;\n \n Write(numBlud * g * numPrib - n);\n end;\nend.", "positive_code": [{"source_code": "program za;\nvar i,n,k,g,ykr,maxl,st,r:integer;\nmas:array[1..1000]of integer;\nbegin\nread(n);\nread(k);\nfor i:=1 to n do begin\nread(g);\nmas[g]:=mas[g]+1;\ng:=0;\nend;\nfor i:=1 to 1000 do\nif mas[i]>maxl then maxl:=mas[i];\nfor i:=1 to 1000 do\nif mas[i]<>0 then r:=r+1;\nst:=1;\nif maxl>k then begin\nwhile maxl>k do begin\nmaxl:=maxl-k;\nst:=st+1;\nend;\nend;\nykr:=st*r*k;\nykr:=ykr-n;\nwriteln(ykr);\nend."}, {"source_code": "var\n a: array of int64; \n k, n, z, j, m: int64;\n\nvar\n p: array[1..100] of int64;\n\nbegin\n read(k, n); \n setlength(a, k); \n for var i := 0 to k - 1 do \n begin\n read(a[i]); \n p[a[i]] += 1; \n end; \n m := 1; \n for var i := 1 to 100 do if p[i] > m then m := p[i]; \n if m mod n = 0 then j := m div n else j := (m div n) + 1; \n for var i := 1 to 100 do \n begin\n if p[i] <> 0 then z += n * j - p[i]; \n end; \n write(z); \nend."}, {"source_code": "var n,k,s,am,l:integer; a:array[1..100] of integer;\nbegin\nreadln(n,k);\nfor var i:=1 to n do\nbegin\nread(s);\nif (a[s]=0) then inc(l);\ninc(a[s]);\nif (a[s]>am) then am:=a[s];\nend;\nif (am mod k=0) then am:=am div k else am:=am div k +1;\ns:=0;\nwriteln(l*am*k-n);\nend."}, {"source_code": "program hhj;\nvar n,k,x,y,i,j,z,b:integer;\n a: array [1..100] of integer;\n begin\n read (n,k);\n for i:= 1 to n do\n read (a[i]);\n for i := 1 to n-1 do\n for j := 1 to n-i do\n if a[j] > a[j+1] then begin\n x := a[j];\n a[j] := a[j+1];\n a[j+1] := x\n end;\n y:= a[1];\n z:= 1;\n x:= 0;\n b:= 0;\n for i:= 1 to n do\n begin\n if y = a[i] then\n begin\n x:= x + 1;\n if x > b then\n b:= x;\n end\n else\n begin\n x:= 1;\n y:= a[i];\n z:= z + 1;\n end;\n end;\n if b mod k = 0 then\n writeln ((k*(b div k)*z)-n)\n else\n writeln ((k*((b div k) + 1)*z)-n)\n\n end."}, {"source_code": "program z1;\nvar a:array[1..100] of integer;\n b:array[1..100] of integer;\n n,k,i,j,m,q,t,h:integer;\nBEGIN\nread(n);\nread(k);\nif (n=0) or (k=0) then writeln(0)\n else begin\nfor i:=1 to n do begin\n read(m);\n a[i]:=m;\nend;\nm:=0;\nfor i:=1 to 100 do begin\n for j:=1 to 100 do begin\n if a[i]=j then \n b[j]:=b[j]+1;\n end;\nend;\nfor i:=1 to 100 do \n if b[i]<>0 then q:=q+1;\nm:=b[1];\nfor i:=1 to 100 do\n if b[i]>m then m:=b[i];\nif (m mod k)<>0 then t:=(m div k)+1\n else t:=(m div k);\nh:=t*q*k-n;\nwriteln(h);\nend;\nEND."}, {"source_code": "program stolowaya ;\n\nvar\n a1: array of int64; \n a2: array [1..100] of int64; \n b1, b2, b3, b4, max, q: int64;\n x1,x2 : real ;\n\n\nbegin\n read(b1, b2); \n setlength(a1, b1); \n for q:=1 to 100 do\n begin\n x1:=sqr(x1)*sqr(x2) ;\n x2:=sqrt(x1) ;\n end;\n \n for var i := 0 to b1 - 1 do \n begin\n read(a1[i]); \n a2[a1[i]] += 1; \n end; \n max := 1; \n for var i := 1 to 100 do if a2[i] > max then max := a2[i]; \n if max mod b2 = 0 then b4 := max div b2 else b4 := (max div b2) + 1; \n for var i := 1 to 100 do \n begin\n if a2[i] <> 0 then b3 += b2 * b4 - a2[i]; \n end; \n write(b3); \nend."}, {"source_code": "program p1;\n\nvar max, n, x, k, i, c, res, kol, koll:integer;\n a:array[1..100] of integer;\n \nbegin\n readln(n, k);\n kol:=0;\n for i:=1 to n do begin\n read(x);\n a[x]:=a[x]+1;\n\n kol:=kol+1;\n end;\n \n max:=0;\n koll:=0;\n for i:=1 to 100 do begin\n if a[i] <> 0 then koll:=koll+1;\n if a[i] > max then max:=a[i];\n end;\n \n if max mod k = 0 then\n c:=max div k\n else c:= max div k + 1;\n\n res:=0;\n res:=c*k*koll - kol; \n \n writeln(res);\nend."}, {"source_code": "program _1;\n\nvar\n i, k, n, m, o: integer;\n mas, mos: array[1..100] of integer;\n\nbegin\n m := 0;\n readln(n, k);\n for i := 1 to n do read(mas[i]);\n for i := 1 to n do mos[mas[i]]+=1;\n for i := 1 to 100 do\n begin\n if m < mos[i] then m := mos[i];\n if mos[i] <> 0 then o := o + 1;\n end;\n while m mod k <> 0 do m:=m+1;\n writeln(m*o-n);\nend."}, {"source_code": "var a,b:array[1..100]of longint;\n otv,max,i,j,k,l,m,n:longint;\nbegin\n read(n,m);\n max := 0;\n for i := 1 to n do\n begin\n read(a[i]);\n inc(b[a[i]]); \n if max < b[a[i]] then max := b[a[i]];\n end;\n if max mod m <> 0 then \n begin\n while max mod m <> 0 do\n inc(max);\n end;\n otv := 0;\n for i := 1 to 100 do\n if b[i] <> 0 then otv := otv + (max - b[i]);\n writeln(otv);\nend. "}, {"source_code": "var i,j,n,k,ans,mx,x,n1:integer;\na:array[1..100] of integer;\nbegin\nfor i:=1 to 100 do\na[i]:=0;\nread (n);\nread(k);\nfor i:=1 to n do\nbegin\nread (x);\na[x]:=a[x]+1;\nend;\nmx:=0;\nn1:=0;\nfor i:=1 to 100 do\nbegin\nif a[i]>mx then\nmx:=a[i];\nif a[i]>0 then\nn1:=n1+1;\nend;\nans:=(mx+k-1) div k;\nans:=(ans*n1*k)-n;\nwriteln (ans);\nend."}, {"source_code": "program king;\nvar n,k,i,s,d:integer; a,b:array[1..100] of integer;\nbegin\nread(n,k);\nfor i:=1 to n do\nbegin\nread(a[i]);\nb[a[i]]:=b[a[i]]+1;\nend;\nfor i:=1 to 100 do\nif (b[i] div k>d) and (b[i] mod k=0) then\nd:=b[i] div k\nelse if (b[i]div k+1>d) and (b[i] mod k>0) then\nd:=b[i] div k+1;\nfor i:=1 to 100 do\nif b[i]<>0 then\ns:=s+d*k-b[i];\nwriteln(s);\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul=1000000007{998244353} ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n kolpr,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..535002] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..240,-1..213,-1..203] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]0 then inc(pp);\n\n t:=(p+k-1) div k;\n { writeln('p= ',p,' t= ',t);\n } writeln(t*k*pp-n);\n\n\n1: close(output);\nend.\n"}, {"source_code": "var\n a: array of int64; \n b: array [1..100] of int64; \n c: array [1..1000] of int64;\n d: array [1..1000] of int64;\n e: array [1..2000] of int64;\n v: array [1..2000] of int64;\n k, n, z, j, l, max: int64;\n\n\n\nbegin\n read(k, n); \n setlength(a, k);\n for l := 1 to 10 do\n v[l] := random(l); \n for l := 1 to 10 do\n e[l] := random(l);\n for l := 1 to 10 do\n d[l] := random(l);\n for l := 1 to 10 do\n c[l] := random(l);\n for var i := 0 to k - 1 do \n begin\n read(a[i]); \n b[a[i]] += 1; \n end; \n max := 1; \n for var i := 1 to 100 do if b[i] > max then max := b[i]; \n if max mod n = 0 then j := max div n else j := (max div n) + 1; \n for var i := 1 to 100 do \n begin\n if b[i] <> 0 then z += n * j - b[i]; \n end; \n write(z); \nend."}, {"source_code": "var a,d:array[1..1000] of longint;\ni,j,n,m,k,l,z:longint;\nbegin\nreadln(n,k);\nfor i:=1 to n do \nbegin\nread(a[i]);\ninc(d[a[i]]);\nend;\nfor i:=1 to 100 do\nif m0 then l:=(m div k)+1 else l:=m div k;\nfor i:=1 to 100 do\nif d[i]>0 then\nz:=z+((l*k)-d[i]);\nwriteln(z);\nend.\n"}, {"source_code": "program one;\n\nvar\n m, n1: array[1..100] of integer;\n i, n, k, q, x, y, l: integer;\n\nbegin\n Readln(n, k);\n x := 0;\n y := k;\n for i := 1 to n do \n begin\n Read(n1[i]);\n q := n1[i];\n m[q] := m[q] + 1;\n end;\n repeat\n l := 0;\n for i := 1 to 100 do\n begin\n if m[i] > k then begin\n k := k + y;\n l := 1;\n end;\n end;\n until(l = 0);\n for i := 1 to 100 do\n begin\n if m[i] = 0 then m[i] := 101;\n end;\n for i := 1 to 100 do\n begin\n if (m[i] <> 101) then begin\n if m[i] <> k then x := x + (k - m[i]);\n end;\n end; \n Writeln(x);\nend."}, {"source_code": "var b,c,n,k,d,e:integer;\n a:array[1..100] of integer;\nbegin\n readln(n,k);\n for b:=1 to 100 do\n a[b]:=0;\n for b:=1 to n do\n begin\n read(c);\n a[c]:=a[c]+1;\n end;\n c:=-1;\n for b:=1 to 100 do\n if a[b]>c then\n c:=a[b];\n d:=0;\n d:=c div k;\n if (c mod k)>0 then\n d:=d+1;\n e:=0;\n for b:=1 to 100 do\n if a[b]>0 then\n e:=e+(k*d-a[b]);\n writeln(e);\nend."}, {"source_code": "Var i,n,k,kol,sum,ans : longint;\n a,b : array[1..100] of integer;\n\n\nBegin\nread(n,k);\nfor i:=1 to n do \n begin\n read(a[i]);\n if b[a[i]]=0 then inc(sum);\n inc(b[a[i]]);\n if b[a[i]]>kol then kol:=b[a[i]];\n end;\n if k >= kol \n then ans:=(k*sum)-n\n else\n if kol mod k=0 then ans:=((kol div k)*sum*k)-n\n else ans:=(((kol div k)+1)*sum*k)-n;\n writeln(ans);\nend.\n "}, {"source_code": "var c,max,x,i,n,k:integer; a:array[1..100] of integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do\nbegin\nread(x);\ninc(a[x]);\nend;\nfor i:=1 to 100 do\nbegin\nif a[i]>max then max:=a[i];\nif a[i]<>0 then inc(c);\nend;\nif (max mod k)=0 then write(c*max-n) else\nwrite(c*( ((max div k)+1)*k )-n)\nend.\n"}, {"source_code": "program A1;\nvar n, k, i, m, mmax, f, otv: integer;\n a: array[1..100]of integer;\nbegin\n n:= 0;\n k:= 0;\n m:= 0;\n mmax:= 0;\n otv:= 0;\n f:= 0;\n ReadLn(n,k);\n for i:= 1 to n do\n begin \n Read(m);\n a[m]:= a[m] + 1;\n if a[m] > mmax then mmax:= a[m];\n end; \n if mmax mod k = 0 then\n f:= mmax div k\n else\n f:= Trunc(mmax/k) + 1;\n for i:= 1 to 100 do\n begin\n if a[i] <> 0 then\n otv:= otv + (k*f -a[i]);\n end;\n WriteLn(otv);\nend."}, {"source_code": "program ideone;\nvar n,k,count,max,i,j,l: integer;\nvar a:array [1..100] of integer;\nbegin\n max:=0;\n for i:=1 to 100 do\n a[i]:=0;\n\treadln (n,k);\n\tfor i:=1 to n do \n\tbegin\n\tread (l);\n\ta[l]:=a[l]+1;\n end;\n for i:=1 to 100 do \n\tbegin\n\tif max0 then\n count:=count+ j*k-a[i];\n end;\n writeln(count);\nend."}, {"source_code": "program pr;\nvar a,b,i,q,e,k,kol,max,o:integer;\nc:array [1..100] of integer;\n\nbegin\nread(a);\nread(b);\nfor i:=1 to a do\nread(c[i]);\nmax:=1;\n\nfor q:=1 to a-1 do\nbegin\nkol:=1;\nfor e:=q+1 to a do\nif c[q]=c[e] then\nkol:=kol+1;\nif max0 then\no:=1;\nmax:=max div b+o;\n\n\n\n\nfor q:=2 to a do\nfor e:=1 to q-1 do\nif c[q]=c[e] then\nc[q]:=0;\n\nfor i:=1 to a do\nif c[i]>0 then\nk:=k+1; \n\nwrite(k*b*max-a);\n\nend."}, {"source_code": "var n,k,i,x,count,q,m:longint;\na:array[1..100] of longint;\nbegin\n readln(n,k);\n for i:=1 to n do\n read(a[i]);\n while x=0 do\n begin\n x:=1;\n for i:=2 to n do\n if a[i]count then\n count:=q;\n q:=1;\n x:=a[i];\n m+=1;\n end;\n \n end;\n if q>count then count:=q;\n count:=(count-1)div k +1;\n writeln(count*m*k-n);\nend."}, {"source_code": "var\n a:array[1..100] of integer;\n n,k,i,l,b,d:integer;\nbegin \n readln(n,k);\n b:=0;\n for i:=1 to 100 do\n a[i]:=0;\n for i:=1 to n do\n begin\n read(l);\n inc(a[l]);\n end;\n l:=0;\n for i:=1 to 100 do\n begin\n if a[i]>l then l:=a[i];\n if a[i]<>0 then inc(b);\n end;\n l:=(l-1) div k + 1;\n writeln(l*b*k-n)\nend."}, {"source_code": "var p:array of uint64; \n d: array [1..100] of int64; \n c: boolean;\n o: boolean;\n k,n,m,u,y:int64; \nbegin \nread(k,n); \no:=true;\nsetlength(p,k); \nfor var x:=0 to k-1 do \nbegin \nread(p[x]); \nd[p[x]]+=1; \nend; \ny:=1; \nfor var x:=1 to 100 do if d[x]>y then y:=d[x]; \nif y mod n =0 then \nbegin\nu:=y div n ;\nc:=true;\nend\nelse \nbegin\nu:=(y div n)+1; \nc:=false;\nend;\nfor var x:=1 to 100 do \nbegin \nif d[x]<>0 then m+= n*u-d[x]; \nend; \nif o then\nwrite(m); \nend."}, {"source_code": "program a4;\nvar n, d, o, k, i, j, max: integer; a:array[1..100] of integer;\nbegin\n readln(n, k);\n max:=0;\n j:=0;\n for i:= 1 to n do begin\n read (o);\n if a[o]=0 then\n j:= j+1; \n a[o]:= a[o]+1;\n if a[o]>max then\n max:= a[o];\n end;\n if max mod k <> 0 then \n max:= ((max div k) +1)*k*j\n else\n max:= (max div k)*k*j;\n max:= max - n;\n Writeln (max);\nend.\n"}, {"source_code": "var A: array [1..100] of byte;\nn,k,i,p,t,x: byte;\nbegin\nread(n,k);\nfor i:= 1 to 100 do\n A[i]:=0;\np:=0;\nt:=0;\nfor i:= 1 to n do begin\n read(x);\n A[x]:=A[x]+1 end;\nfor i:=1 to 100 do begin\n if A[i]>p then p:=A[i];\n if A[i]>0 then t:=t+1 end;\nif p mod k = 0 then p:=p div k\n else p:=p div k +1;\nwriteln(p*k*t - n);\nend."}, {"source_code": "var a,n,k,i,m,l,h: integer;\nb: array [1..1000] of integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do\nbegin\nread(a);\nb[a]:=b[a]+1;\nend;\nfor i:=1 to 100 do\nbegin\nif b[i]>m then m:=b[i];\nif b[i]>0 then h:=h+1;\nend;\nl:=m div k;\nif m mod k>0 then l:=l+1;\nl:=l*k*h;\nfor i:=1 to 100 do \nl:=l-b[i];\nwriteln(l);\nend.\n"}, {"source_code": "var\n arr: array[1..100] of longint;\n k, n, i, ch, kolv, max: longint;\n\nbegin\n read(k, n);\n for i := 1 to k do\n begin\n read(ch);\n if arr[ch] = 0 then kolv := kolv + 1;\n arr[ch] := arr[ch] + 1;\n end; \n for i := 1 to 100 do\n if max < arr[i] then max := arr[i];\n if max mod n = 0 then write((max div n) * kolv * n - k)\n else write(((max div n) + 1) * kolv * n - k);\nend."}, {"source_code": "var\na,b:array[1..100] of longint;\nn,m,i,j,z,k,max:longint;\nbegin\nreadln(n,k);\nfor i:= 1 to n do\nbegin\nread(a[i]);\nb[a[i]]:=b[a[i]]+1;\nend;\nfor i:= 1 to 100 do\nif b[i]>max then\nmax:=b[i];\nif max mod k = 0 then\nz:=max div k\nelse\nz:=trunc(max div k)+1;\nz:=z*k;\nfor i:=1 to 100 do\nif b[i]<>0 then\ninc(m);\nz:=z*m;\nwriteln(z-n);\nend.\n\n"}, {"source_code": "var a,n,k,m,max,h:integer;\nb:array [1..100] of integer;\n\nbegin\nreadln(n,k);\nfor var i:=1 to n do\nbegin\nread(a);\nb[a]:=b[a]+1;\nif b[a]=1 then \nm:=m+1;\nif b[a]>max then \nmax:=b[a];\nend;\nif max mod k>0 then\nh:=(max div k)+1\nelse h:=(max div k);\nwriteln(h*k*m-n);\nend.\n"}, {"source_code": "var n,k,i,c,r,m,g:integer;\n a,b:array [1..100] of integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do\n begin\n read(a[i]);\n c:=a[i];\n b[c]:=b[c]+1;\n end;\nm:=0;\nr:=0;\nfor i:=1 to 100 do\n begin\n if b[i]>0 then r:=r+1;\n if b[i]>m then m:=b[i];\n end;\ng:=m div k;\nif m mod k>0 then g:=g+1;\nwrite(r*g*k-n);\nend."}, {"source_code": "program abc;\nvar a:array[1..1000] of integer;\nvar b:array[1..1000] of integer;\nvar k,n,x,i,j,min,spec,vid:integer;\nbegin\nspec:=1;\nmin:=0;\nx:=1;\nread(n,k);\nfor i:=1 to n do \nbegin\n read(a[i]);\n b[i]:=a[i];\n end;\n \n \n for i:=1 to n do \nbegin\nif a[i]<>-5000 then vid:=vid+1;\n for j:=i+1 to n do \nbegin\nif a[i]<>-5000 then begin\n\n if (a[i]=a[j]) then begin\n spec:=spec+1;\n a[j]:=-5000;\n end;\n end;\n if (a[i]=-5000) then spec:=k;\n end;\n while (x*k-spec<0)do begin\n x:=x+1;\n end;\n spec:=1;\n end;\n \n \n min:=k*x*vid-n; \n \n \n \n \n \n \n \nwrite(min);\n \nend."}, {"source_code": "program abc;\nvar n,a,k,s,i,mn:integer;\n m:array[1..1000] of integer;\nbegin\ns:=0; mn:=1;\nread(n);\nread(k);\nfor i:=1 to n do\n begin\n read(a);\n inc(m[a]);\n if m[a]>(k*mn) then inc(mn);\n end;\nfor i:=1 to 1000 do\n if m[i]<>0 then\n s:=s+(k*mn-m[i]);\nwriteln(s);\nend."}, {"source_code": "Program ABC;\nVar\n a,b,c:array [1..100] of longint;\n i2,i,k,n,d,e,max,f,g:longint;\nbegin\n readln (n,k);\n f:=1;\n for i := 1 to n do begin\n read(a[i]);\n b[a[i]]:=b[a[i]] +1;\n g:=0;\n for i2 := 1 to f do\n if (a[i] = c[i2])then\n g :=1; \n if g = 0 then begin\n c[f]:=a[i];\n f:=f + 1;\n end;\n end;\n max:=0;\n f:=f - 1;\n for i := 1 to f do begin\n if (b[c[i]] > max) then \n max:=b[c[i]];\n end;\n d := ((max - 1 ) div k) +1; \n e:=0;\n for i := 1 to f do begin\n e:=e + (d * k) - b[c[i]];\n end;\n write(e);\nend."}, {"source_code": "var a:array[1..100] of integer;\nn,k,i,d,max,l,s:integer;\nbegin\nmax:=0;\nreadln (n,k);\n\nfor i:=1 to 100 do\na[i]:=0;\nfor i:=1 to n do\nbegin\nread (d);\na[d]:=a[d]+1;\nend;\ns:=0; d:=0;\nfor i:=1 to 100 do\nbegin\nif a[i]>max then max:=a[i];\nif a[i]>0 then d:=d+1;\nend;\n\nif max mod k=0 then l:= max div k else l:= (max div k)+1;\ns:=l*d*k-n;\nwriteln(s);\nend."}, {"source_code": "var\n x: array of int64; \n y: array [1..100] of int64; \n k, n, s, v, maximum,i,f,p: integer;\n trueorfalse:boolean;\nbegin\n read(k, n); \n setlength(x, k);\n trueorfalse:=true;\n for i := 0 to k - 1 do \n begin\n read(x[i]); \n y[x[i]] += 1; \n end; \n maximum := 1; \n for f := 1 to 100 do \n if y[f] > maximum then\n maximum := y[f]; \n if maximum mod n = 0 then \n v := maximum div n \n else v := (maximum div n) + 1; \n for p := 1 to 100 do \n begin\n if y[p] <> 0 then s += n * v - y[p]; \n end; \n if trueorfalse=true then\n write(s)\n else\n write('ErRoR');\nend."}, {"source_code": "program zA;\nvar\n n, k: integer;\n aAStr: array of string;\n al: array [1..100] of integer;\n ai: integer;\n nk: array of string;\n nkStr, aStr: string;\n err: integer;\nbegin\n readln(nkStr);\n nk := nkStr.Split(' ');\n val(nk[0], n, err);\n val(nk[1], k, err);\n \n readln(aStr);\n aAStr := aStr.Split(' ');\n for var i := 0 to 99 do begin\n if i+1 > length(aAStr) then break;\n val(aAStr[i], ai, err);\n al[ai] := al[ai] + 1;\n end;\n \n var aMax: integer := 0;\n var pNum: integer := 0;\n for var i := 1 to 100 do begin\n if al[i] > 0 then pNum := pNum + 1;\n if aMax < al[i] then aMax := al[i];\n end;\n \n var buff: integer := aMax mod k;\n var blNum: integer := aMax div k;\n if buff > 0 then blNum := blNum + 1;\n writeln((blNum*k*pNum)-n);\nend."}, {"source_code": "program primer;\nvar a:array[1..101]of integer;\ni,j,kol,k,n,max,x,h:integer;\nc,otv:int64;\nf1,f2:text;\n\nBEGIN\nreadln(n,kol);\nmax:=0;k:=0;\nfor i:=1 to n do\n begin\n read(x);\n if a[x]=0 then k:=k+1;\n a[x]:=a[x]+1;\n if a[x]>max then max:=a[x];\n end;\nif max mod kol= 0 then h:=max div kol\n else h:=max div kol+1;\nc:=k*h*kol;\notv:=c-n;\nwrite(otv);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n m, n, k, i, s, k1: integer;\n a, b:array[1..110]of integer;\nbegin\n readln(n, k);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to 100 do\n b[i] := 0;\n for i := 1 to n do\n inc(b[a[i]]);\n m := 0;\n for i := 1 to 100 do\n if (m < b[i])then m := b[i];\n k1 := 0;\n while (k1 < m)do\n k1 := k1 + k;\n s := 0;\n for i := 1 to 100 do\n if (k1 - b[i]<>k1)then inc(s, k1 - b[i]);\n writeln(s);\n readln;\n readln;\nend.\n"}, {"source_code": "program z_a;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, k, i, sum, x, max, k1: integer;\n a: array[1..100] of integer;\n\nbegin\n readln(n, k);\n sum := 0;\n max := 0;\n for i := 1 to n do\n a[i] := 0;\n for i := 1 to n do begin\n read(x);\n inc(a[x]);\n end;\n for i := 1 to 100 do\n if(a[i] > max) then\n max := a[i];\n k1 := k;\n while(k1 < max) do\n inc(k1, k);\n max := k1;\n for i := 1 to 100 do begin\n if(a[i] > 0) then\n inc(sum, max - a[i]);\n end;\n writeln(sum);\n readln;\n readln;\nend.\n"}, {"source_code": "var\n k, n, m, max, now, ans, i: longint;\n v: array[0..100] of longint;\nprocedure qSort(l,r:longint);\nvar i,j, w, q:longint;\nbegin\n i := l; j := r;\n q := v[(l+r) div 2];\n repeat\n while (v[i] < q) do inc(i);\n while (q < v[j]) do dec(j);\n if (i <= j) then\n begin\n w:=v[i]; v[i]:=v[j]; v[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n readln(n, k);\n for i:=1 to n do\n read(v[i]);\n qSort(1, n);\n max:=1;\n now:=1;\n for i:=2 to n do\n begin\n if v[i]=v[i-1] then inc(now);\n if now > max then max := now;\n if v[i] <> v[i-1] then now := 1;\n end;\n\n while max mod k <> 0 do\n begin\n inc(max);\n end;\n\n ans := 0;\n v[0]:=999;\n v[n+1]:=999;\n now := 1;\n for i:=1 to n+1 do\n begin\n if v[i] = v[i-1] then inc(now)\n else if i <> 1 then begin inc(ans, max - now); now := 1; end;\n end;\n\n writeln(ans);\n readln;\nend."}, {"source_code": "program zadachaA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i: integer;\n max, k, n, p, sum, mult: int64;\n a: array[1..150] of integer;\nbegin\n readln(n, k);\n max := -1;\n for i := 1 to n do begin\n read(p);\n inc(a[p]);\n if (p > max) then\n max := p;\n end;\n p := 0;\n mult := 1;\n for i := 1 to max do\n if (a[i] <> 0) then begin\n if (a[i] > k) then\n if (a[i] mod k <> 0) then\n if ((a[i] div k) + 1 > mult) then\n mult := a[i] div k + 1;\n if (a[i] > k) then\n if (a[i] mod k = 0) then\n if (a[i] div k > mult) then\n mult := a[i] div k;\n inc(p);\n end;\n writeln(p * k * mult - n);\n readln;\n readln;\nend.\n"}, {"source_code": "const maxn=1000;\nvar a : array[1..maxn] of longint;\n n,k,i,j,x,max,ans,d,kol:longint;\n\nbegin\n readln(n, k);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i] > a[j] then begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\n end;\n d:=1;\n for i:=1 to n do \n if a[i] = a[i+1] then inc(d) else begin\n if d > max then max:=d;\n d:=1;\n end;\n kol:=max div k;\n if max mod k > 0 then inc(kol);\n d:=1;\n for i:=1 to n do\n if a[i] = a[i+1] then inc(d) else begin\n inc(ans, kol*k-d);\n d:=1;\n end;\n writeln(ans); \nend."}, {"source_code": "program qq;\nvar k,n,a,b,c,f,d,i,max,e:longint;\n ki:array[1..100] of integer;\nbegin\nreadln(n,k);\nFor i:=1 to n do begin\n read(b);\nki[b]:=ki[b]+1;\nend;\nmax:=0;\nFor i:=1 to 100 do\n if (ki[i]>max) then max:=ki[i];\n\nfor i:=0 to 100 do\nif ( (max+i) mod k=0) then begin\n max:=(max+i) div k;\n break;\nend;\nc:=0;\ne:=0;\nFor i:=1 to 100 do begin\nif(ki[i]<>0) then\ne:=e+1;\nend;\nwriteln(max*k*e-n);\nend."}, {"source_code": "program stolovaya;\n var mas:Array [1..100] of integer;\n var n, k, i, max, sperli, unique_pribor, j, tmp, count:integer;\nbegin\n read(n, k);\n for i:=1 to n do read(mas[i]);\n max:=0;\n unique_pribor:=0;\n for i:=1 to 100 do begin \n tmp:=0;\n for j:=1 to n do begin \n if i = mas[j] then tmp:=tmp + 1;\n end;\n if tmp>max then max:=tmp; \n if tmp > 0 then unique_pribor:=unique_pribor + 1;\n end;\n if (max mod k) = 0 then count:=max div k\n else count:=(max div k) + 1;\n sperli:=count * unique_pribor * k;\n write(sperli - n);\nend.\n "}, {"source_code": "var\na:array[1..100]of integer;\ni,n,k,q,max,z,x:integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do begin\nread(q);\na[q]:=a[q]+1;\nif a[q]> max then max:=a[q];\nend;\n\nif max mod k >0 then x:=1;\nmax:=(max div k)*k+x*k;\n\nfor i:=1 to 100 do if a[i]>0 then z:=z+(max-a[i]);\n\nwriteln(z);\nend."}, {"source_code": "Program a;\n\nvar\n\tn, k, tmp, kolvoPriborov, max, blud, maxPrib, i:longint;\n\taBoll:array[1..100] of boolean;\n\tmaxArr:array[1..100] of Longint;\nbegin\n\tread(n, k);\n\tfor i:=1 to 100 do aBoll[i]:=false;\n\tfor i:=1 to 100 do maxArr[i]:=0;\n\tkolvoPriborov:=0;\n\tfor i:=1 to n do begin\n\t\tread(tmp);\n\t\tif not(aBoll[tmp]) then begin\n\t\t\taBoll[tmp]:=true;\n\t\t\tkolvoPriborov += 1;\n\t\tend;\n\t\tmaxArr[tmp] += 1;\n\tend;\n\tmax:=-1;\n\tfor i:=1 to 100 do begin\n\t\tif maxArr[i]>max then max:=maxArr[i];\n\tend;\n\tblud:=max div k;\n\tif (max mod k<>0) then blud+=1;\n\tmaxPrib:=k*kolvoPriborov*blud;\n\tfor i:=1 to 100 do begin\n\t\t//writeln(maxArr[i], i:10);\n\t\tmaxPrib -= maxArr[i];\n\tend;\n\twriteln(maxPrib);\nend."}, {"source_code": "var\na,b:array [1..1000] of longint;\nmax,n,k,kol,i:longint;\nbegin\nmax:=0;\nreadln(n,k);\nfor i:=1 to n do\nbegin\nread(a[i]);\nb[a[i]]:=b[a[i]]+1;\nif max0 then kol:=kol+1;\nif max mod k =0 then begin writeln(max * kol -n); halt; end;\nif max mod k <>0 then begin writeln((max div k + 1) * kol*k -n); halt; end;\nend.\n"}, {"source_code": "program project1;\nvar n,k,i,prib,propalo,maxprib1vid:integer;\n mas:array[1..101] of integer;\nbegin\n for i:=1 to 101 do\n mas[i]:=0;\n propalo:=0;\n maxprib1vid:=0;\n readln(n,k);\n\n for i:=1 to n do begin\nread(prib);\n mas[prib]:= mas[prib]+1;\n if mas[prib]>maxprib1vid then maxprib1vid:=mas[prib]\n end;\n if (maxprib1vid mod k<>0) then\n maxprib1vid:=maxprib1vid-(maxprib1vid mod k)+k;\n for i:=1 to 101 do\n if mas[i]<>0 then propalo:=propalo+maxprib1vid-mas[i];\n write(propalo);\n // readln();\n\nend. "}, {"source_code": "var\n a:array[0..100000]of longint;\n n,m,s,i,x,max:longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n read(x);\n inc(a[x]);\n if a[x]=1 then inc(s);\n if a[x]>max then max:=a[x];\n end;\n while max mod m<>0 do inc(max);\n writeln(s*max-n);\nend.\n"}, {"source_code": "var\n i,c,n,k,t,g,mx: integer;\n a:array[1..100] of integer;\nbegin\n read(n,k);\n for i:= 1 to 100 do a[i]:=0;\n for i:= 1 to n do\n begin\n read(t);\n a[t]:=a[t]+1;\n end;\n mx:=0; c:=0;\n for i:= 1 to 100 do\n begin\n if a[i]>mx then mx:=a[i];\n \n if a[i]<>0 then inc(c)\n end;\n g:=mx div k;\n if (mx mod k > 0) then inc(g);\n write((g*c*k)-n)\nend."}, {"source_code": "var\ni, j, n, k, kol, b, max, c:longint;\nans:int64;\na:array[1..1000] of longint;\nbegin\n readln(n, k);\n for i:=1 to n do\n begin\n read(b);\n inc(a[b]);\n end;\n for i:=1 to 100 do \n begin\n if a[i]<>0 then begin\n inc(kol);\n c:=(a[i]+k-1) div k;\n if c>max then max:=c;\n end;\n end;\n writeln(kol*k*max - n);\nend."}, {"source_code": "program taskA;\nvar a:array[1..100]of longint;\nn,i,j,k,c,max,b,sleft,smustbe:longint;\nbegin\n readln(n,k);\n for i:=1 to 100 do a[i]:=0;\n for i:=1 to n do\n begin\n read(c); inc(a[c]);\n end;\n max:=a[1];\n for i:=2 to 100 do\n if max0 then inc(b);\n\n smustbe:=0;\n for i:=1 to 100 do\n if a[i]<>0 then\n inc(smustbe,b); {�� ������ ����� ��� ��� ���}\n smustbe:=smustbe*k; {�� ���}\n\n sleft:=0;\n for i:=1 to 100 do sleft:=sleft+a[i];\n\n write(smustbe-sleft);\n\nend."}, {"source_code": "var\na:array[1..100]of integer;\ni,n,k,q,max,z,x:integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do begin\nread(q);\na[q]:=a[q]+1;\nif a[q]> max then max:=a[q];\nend;\n\nif max mod k >0 then x:=1;\nmax:=(max div k)*k+x*k;\n\nfor i:=1 to 100 do if a[i]>0 then z:=z+(max-a[i]);\n\nwriteln(z);\nend."}, {"source_code": "Var n,k,l,max,h,i,g,x,m,b:integer;\n a:array[1..100] of integer;\n\nBegin\nreadln(n,k);\nfor i:=1 to n do\nread(a[i]);\nh:=1;\nWhile h<=100 do\nbegin\nfor i:=h to n do\n begin\n if a[h]=a[i] then begin l:=l+1 end;\n end;\nif l>max then max:=l;\nh:=h+1;\nl:=0;\nend;\n\nif max mod k > 0 then g:=(max div k) + 1 else g:=(max div k);\nh:=1;\nfor h:=1 to 100 do\nbegin\nfor i:=1 to n do\n begin\n if a[i]=h then begin m:=m+1; break; end;\n end;\nend;\n\n\nx:=(m*k*g) - n;\nwriteln(x);\nend."}, {"source_code": "var n,k,i,c,r,m,g:integer;\n a,b:array [1..100] of integer;\nbegin\nreadln(n,k);\nfor i:=1 to n do\n begin\n read(a[i]);\n c:=a[i];\n b[c]:=b[c]+1;\n end;\nm:=0;\nr:=0;\nfor i:=1 to 100 do\n begin\n if b[i]>0 then r:=r+1;\n if b[i]>m then m:=b[i];\n end;\ng:=m div k;\nif m mod k>0 then g:=g+1;\nwrite(r*g*k-n);\nend."}, {"source_code": "var a:array of int64; \nb: array [1..100] of int64; \nk,n,z,j,i,max:int64; \nx1,x2:real;\n\n\n\nbegin \nread(k,n); \nsetlength(a,k); \nfor i:=0 to k-1 do begin \nread(a[i]); \nb[a[i]]+=1; \nend; \nx1:=1;\nx2:=2;\nfor i:=1 to 100 do begin\n x1:=sqr(x1)+sqr(x2);\n x2:=sqrt(x1)+sqr(X2);\n end;\nmax:=1; \nfor i:=1 to 100 do if b[i]>max then max:=b[i]; \nif max mod n =0 then j:=max div n else j:=(max div n)+1; \nfor i:=1 to 100 do \nbegin \nif b[i]<>0 then z+= n*j-b[i]; \nend; \nwrite(z); \nend."}, {"source_code": "program x;\nvar\na, n, k, i, col, m, e, max:integer;\nb:array[1..100] of integer;\nc:array[1..100] of integer;\nbegin\nmax:=0;\nread(n, k);\nfor i:=1 to n do\n read(b[i]);\nfor i:=1 to n do\nbegin\n for e:=1 to 100do\n if(b[i]=e) then c[e]:=c[e]+1;\nend;\nfor i:=1 to 100 do\nbegin\n if(c[i]<>0) then col:=col+1;\n if(c[i]>max) then max:=c[i];\nend;\n\nif(max/k > max div k) then m:= (max div k) + 1\nelse m:= max div k;\n//writeln(col);\n//writeln(m);\n//writeln(k);\nwriteln(col*m*k-n);\n\n \nend."}, {"source_code": "type\n mas = array[1..100] of integer;\n\nvar\n n, i, k, kol, nom, max, chis: integer;\n m: mas;\n\nbegin\n kol := 0;\n max := 0;\n readln(n, k);\n for i := 1 to n do\n begin\n read(nom);\n m[nom] := m[nom] + 1;\n end;\n for i := 1 to 100 do\n if m[i] > 0 then\n kol := kol + 1;\n for i := 1 to 100 do\n begin\n chis := m[i] div k;\n if (m[i] mod k > 0) then chis := chis + 1;\n chis := chis * k;\n if chis > max then\n max := chis;\n end;\n writeln(max * kol - n);\nend."}, {"source_code": "var a,b:array[1..1000] of longint;\n n,k,sum,k1,i:longint;\nbegin\nread(n,k);\nfor i:=1 to n do\nbegin\nread(a[i]);\nb[a[i]]:=b[a[i]]+1;\nend;\nsum:=0;\nk1:=1;\nfor i:=2 to 100 do\nif b[k1]0 then k:=k*((b[k1] div k)+1)\nelse k:=k*(b[k1] div k);\nfor i:=1 to 100 do\nif (k>b[i])and(b[i]>0) then sum:=sum+k-b[i];\nwrite(sum);\nend.\n"}, {"source_code": "var\na,i,n,k,mn,ans:longint;\nb:array [1..100] of longint;\nfunction min(a,b:longint):longint;\nbegin\nif amn then \n mn:=b[i] div k+min(1,b[i] mod k);\nfor i:=1 to 100 do \n if b[i]>0 then \n ans:=ans+mn*k-b[i];\nwriteln(ans);\nend."}, {"source_code": "var\n log: array of int64; \n b: array [1..100] of int64; \n kof, n, zed, j, max: int64;\n g:array[1..10] of real;\n\n\nbegin\n for var i:=1 to 10 do\n begin\n g[i]:=i;\n end;\n read(kof, n); \n setlength(log, kof); \n for var i := 0 to kof - 1 do \n begin\n read(log[i]); \n b[log[i]] += 1; \n end; \n max := 1; //nicshe \n for var i := 1 to 100 do if b[i] > max then max := b[i]; \n if max mod n = 0 then j := max div n else j := (max div n) + 1; \n for var i := 1 to 100 do \n begin\n if b[i] <> 0 then zed += n * j - b[i]; \n end; \n write(zed); \nend."}, {"source_code": "program test1;\n\nvar\nprib:array [0..100] of integer;\nost,gost:integer;\ni,j:integer;\nbuf:integer;\ncount:integer;\n vid : set of integer;\n\nmax:integer;\nblud:integer;\nbegin\n\nreadln(ost,gost);\n\nfor i:=1 to ost do begin\nread(buf);\nif (not(buf in vid)) then begin Include(vid,buf); inc(count); end;\ninc(prib[buf]);\nend;\n\nmax:=0;\nforeach j in vid do begin\n if (prib[j]>max) then max:=prib[j];\nend;\n\nif (max> (max div gost)*gost) then max:=max+gost;\nblud:=max div gost;\n\n\nwriteln(gost*blud*count-ost);\n\n\nend."}, {"source_code": "var a,b:array[1..100000] of longint;\nmaX,i,n,m,k,l,j,x,ans:longint;\n\nbegin\nreadln(n,k);\nfor i:=1 to n do begin read(a[i]); inc(b[a[i]]); end;\nmax:=0;\nfor i:=1 to 100 do begin\nif (b[i] div k>max) and (b[i] mod k<>0) then max:=b[i] div k;\nif (b[i] div k>max) and (b[i] mod k=0) then max:=(b[i] div k)-1; end;\n\nmax:=max+1;\nfor i:=1 to 100 do if b[i]>0 then ans:=ans+k*max-b[i];\nwriteln(ans);\n\nend."}, {"source_code": "var\na,s,d,s1,otv,max:int64;\nz,z2,z3:array[1..10000] of int64;\ni,j:longint;\nbegin\nread(a,s);\nfor i:=1 to a do\nread(z[i]);\nfor i:=1 to a do\nz2[z[i]]:=z2[z[i]]+1;\nfor i:=1 to 100 do\nif z2[i]>0 then d:=d+1;\nfor i:=1 to 100 do\nif z2[i]>max then max:=z2[i];\n//\n//for i:=1 to 100 do\n//if z2[i]>0 then xx:=xx+1;\n//for i:=1 to 100 do\n//otv:=z2[i]+otv;\ns1:=max div s;\nif max mod s<>0 then s1:=s1+1;\nwrite(s1*d*s-a);\n\nend."}, {"source_code": "program agfd;\nvar t:array[1..100] of integer;\n i, n, k, p, max:integer;\nbegin\n readln(n, k);\n for i:=1 to n do begin\n read(p);\n t[p]:=t[p]+1;\n if t[p] > max then max:=t[p];\n end;\n if max mod k <> 0 then max:=max+(k - (max mod k));\n p:=0;\n for i:=1 to 100 do begin\n if (t[i] < max) and (t[i] <> 0) then p:=p+(max-t[i]);\n end;\n writeln(p);\nend."}, {"source_code": "var aaaaa:array of int64; \nbbbbb: array [1..100] of int64; \nk,n,z,j,max:int64; \naaaaaaaaa :array [1..10000] of integer;\n\nbegin \n\nread(k,n); \nfor var dakda := 1 to 10000 do aaaaaaaaa[dakda] := dakda;\nsetlength(aaaaa,k); \nfor var i:=0 to k-1 do \nbegin \nread(aaaaa[i]); \nbbbbb[aaaaa[i]]+=1; \nend; \nmax:=1; \nfor var i:=1 to 100 do if bbbbb[i]>max then max:=bbbbb[i]; \nif max mod n =0 then j:=max div n else j:=(max div n)+1; \nfor var i:=1 to 100 do \nbegin \nif bbbbb[i]<>0 then z+= n*j-bbbbb[i]; \nend; \nwrite(z); \nend."}, {"source_code": "var a,b,l,k,i,z,s,max:integer; m:array [1..100] of integer;\n\nbegin\ns:=0;\nreadln(a,b);\nfor i:=1 to a do begin\nread(z);\nm[z]:=m[z]+1;\nend;\nmax:=0;\nfor i:=1 to 100 do begin\nif m[i]>max then\nmax:=m[i];\nend;\nif max0 then begin\ns:=s+l-m[i];\nend;\nend;\nwriteln(s);\nend.\n"}, {"source_code": "var a:array of int64;\n b: array [1..100] of int64;\n k,n,z,j,max:int64;\n\n\n\nbegin\nread(k,n);\nsetlength(a,k);\nfor var i:=0 to k-1 do\nbegin\nread(a[i]);\nb[a[i]]+=1;\nend;\nmax:=1;\nfor var i:=1 to 100 do if b[i]>max then max:=b[i];\nif max mod n =0 then j:=max div n else j:=(max div n)+1;\nfor var i:=1 to 100 do\nbegin\nif b[i]<>0 then z+= n*j-b[i];\nend;\nwrite(z);\nend."}, {"source_code": "program mos_olimp_2018_A;\n\nvar\n n, k: int64;\n i, j: int64;\n y, x, max, o, r: int64;\n a: array[1..100] of int64;\n b: array[1..100] of int64;\n c: array[1..100] of int64;\nbegin\n read(n, k);\n x := 0;\n for i := 1 to n do begin\n read(a[i]);\n y := 0;\n for j := 1 to x do begin\n if (a[i] = c[j]) then begin\n y := 1;\n b[j] += 1;\n break;\n end;\n end;\n if (y = 0) then begin\n x += 1;\n c[x] := a[i];\n b[x] += 1;\n end;\n end;\n max := b[1];\n for i := 1 to x do begin\n if (b[i] > max) then max := b[i]; \n end;\n if (max mod k = 0) then begin\n r := max;\n end else begin\n r := (max div k + 1) * k;\n end;\n o := 0;\n for i := 1 to x do begin\n o += r - b[i];\n end;\n write(o);\nend.\n "}], "negative_code": [{"source_code": "program qq;\nvar k,n,a,b,c,f,d,i,max,e:longint;\n ki:array[1..100] of integer;\nbegin\nreadln(n,k);\nFor i:=1 to n do begin\n read(b);\nki[b]:=ki[b]+1;\nend;\nmax:=0;\nFor i:=1 to 100 do\n if (ki[i]>max) then max:=ki[i];\nc:=0;\ne:=0;\nFor i:=1 to 100 do begin\nif(ki[i]<>0) then\ne:=e+1;\nend;\nwriteln((max-k+1)*k*e-n);\nend."}, {"source_code": "var\na:array[1..100]of integer;\ni,n,k,q,max,z:integer;\nbegin\nz:=0;\nmax:=0;\nreadln(n,k);\nfor i:=1 to n do begin\nread(q);\na[q]:=a[q]+1;\nif a[q]> max then max:=a[q];\nend;\nmax:=(max div k)*k+(max mod k)*k;\nfor i:=1 to 100 do if a[i]>0 then z:=z+(max-a[i]);\nwriteln(z);\nend."}, {"source_code": "program zadacha1;\nvar n,k,i,q,w,e:integer;\na:array[1..100] of integer;\nbegin\nfor i:=1 to 100 do\na[i]:=0;\nw:=0;\ne:=0;\nreadln(n);readln(k);\nfor i:=1 to n do begin\nread(q);\na[q]:= a[q]+1;\nif a[q]>e then e:=a[q]\nend;\nif (e mod k<>0) then\ne:=e-(e mod k)+k;\nfor i:=1 to 100 do\nif a[i]<>0 then w:=w+e-a[i];\nwrite(w);\nreadln();\nend. "}, {"source_code": "program zadacha1;\nvar n,k,i,q,w,e:integer;\na:array[1..100] of integer;\nbegin\nfor i:=1 to 100 do\na[i]:=0;\nw:=0;\ne:=0;\nreadln(n);readln(k);\nfor i:=1 to n do begin\nreadln(q);\na[q]:= a[q]+1;\nif a[q]>e then e:=a[q]\nend;\nif (e mod k<>0) then\ne:=e-(e mod k)+k;\nfor i:=1 to 100 do\nif a[i]<>0 then w:=w+e-a[i];\nwrite(w);\nreadln();\nend. "}, {"source_code": "program zadacha1;\nvar n,k,i,q,w,e:integer;\na:array[1..100] of integer;\nbegin\nfor i:=1 to 100 do\na[i]:=0;\nw:=0;\ne:=0;\nreadln(n);readln(k);\nfor i:=1 to n do begin\nread(q);\na[q]:= a[q]+1;\nif a[q]>e then e:=a[q]\nend;\nif (e mod k<>0) then\ne:=e-(e mod k)+k;\nfor i:=1 to 100 do\nif a[i]<>0 then w:=w+e-a[i];\nwrite(w);\nend. "}, {"source_code": "program project1;\nvar n,k,i,prib,propalo,maxprib1vid:integer;\n mas:array[1..101] of integer;\nbegin\n for i:=1 to 101 do\n mas[i]:=0;\n propalo:=0;\n maxprib1vid:=0;\n readln(n,k);\n\n for i:=1 to n do begin\n readln(prib);\n mas[prib]:= mas[prib]+1;\n if mas[prib]>maxprib1vid then maxprib1vid:=mas[prib]\n end;\n if (maxprib1vid mod k<>0) then\n maxprib1vid:=maxprib1vid-(maxprib1vid mod k)+k;\n for i:=1 to 101 do\n if mas[i]<>0 then propalo:=propalo+maxprib1vid-mas[i];\n write(propalo);\n // readln();\n\nend. "}, {"source_code": "Program first;\n\ntype\n\tTData = Array[1..100] of Integer;\n\n\nvar\n\tcount: TData;\n\tn,k,i,p,bluda,res,z: Integer;\n\nBegin\n\tbluda:=1;\n\treadln(n,k);\n\tp:=k;\n\tfor i:=1 to 100 do count[i]:=0;\n\t\n\t\n\tfor i:=1 to n do begin\n\t\tread (z);\n\t\tcount[z] += 1;\n\t\tif count[z]>k then begin\n\t\t\tbluda+=1;\n\t\t\tk *= 2;\n\t\tend;\n\tend;\n\t\n\tp := p*bluda;\n\tres:=0;\n\t\n\t\n\tfor i:=1 to 100 do begin\n\t\tif count[i]<>0 then begin\n\t\t\twhile count[i]

max then max:=l;\nh:=h+1;\nl:=0;\nend;\nwriteln (max);\nif max mod k > 0 then g:=(max div k) + 1 else g:=(max div k);\nh:=1;\nfor h:=1 to 100 do\nbegin\nfor i:=1 to n do\n begin\n if a[i]=h then begin m:=m+1; break; end;\n end;\nend;\nwriteln (m);\n\nx:=(m*k*g) - n;\nwriteln(x);\nend."}, {"source_code": "var n,i,dem,m,max:longint;\n a,b:array[1..100]of longint;\nbegin\n read(n,m);\n for i:=1 to n do\n begin\n read(a[i]);\n inc(b[a[i]]);\n if b[a[i]]>max then max:=b[a[i]];\n end;\n while mmax then break;\n end;\n for i:=1 to 100 do\n if b[i]<>0 then inc(dem,m-b[i]);\n write(dem);\nend."}, {"source_code": "program ggg;\nvar n,m,k,i,p1,p2:integer;\na:array[1..100] of integer;\nbegin\nreadln(n,k);\nfor i:=1 to 100 do\na[i]:=0;\np2:=0;\nm:=0;\nfor i:=1 to n do begin\nreadln(p1);\na[p1]:= a[p1]+1;\nif a[p1]>m then m:=a[p1]\nend;\n\nif (m mod k<>0) then\nm:=m-(m mod k)+k;\nfor i:=1 to 100 do\nif a[i]<>0 then p2:=p2+m-a[i];\nwrite(p2);\nreadln;\nend."}, {"source_code": "var\na,s,d:int64;\nz,z2,z3:array[1..10000] of int64;\ni,j:longint;\nbegin\nread(a,s);\nfor i:=1 to a do\nread(z[i]);\nfor i:=1 to a do\nz2[z[i]]:=1;\nfor i:=1 to 100 do\nif z2[i]=1 then d:=d+1;\nwrite(d-s);\nend.\n"}, {"source_code": "var\na,s,d,s1,otv,xx:int64;\nz,z2,z3:array[1..10000] of int64;\ni,j:longint;\nbegin\nread(a,s);\nfor i:=1 to a do\nread(z[i]);\nfor i:=1 to a do\nz2[z[i]]:=z2[z[i]]+1;\nfor i:=1 to 100 do\nif z2[i]>d then d:=z2[i];\nxx:=0;\nfor i:=1 to 100 do\nif z2[i]>0 then xx:=xx+1;\n//for i:=1 to 100 do\n//otv:=z2[i]+otv;\ns1:=d div s;\nif d mod s<>0 then s1:=s1+1;\nwrite(abs(s1*d*s-a));\n\nend.\n"}, {"source_code": "var\na,s,d,s1,otv,xx:int64;\nz,z2,z3:array[1..10000] of int64;\ni,j:longint;\nbegin\nread(a,s);\nfor i:=1 to a do\nread(z[i]);\nfor i:=1 to a do\nz2[z[i]]:=z2[z[i]]+1;\nfor i:=1 to 100 do\nif z2[i]>0 then d:=d+1;\nxx:=0;\nfor i:=1 to 100 do\nif z2[i]>0 then xx:=xx+1;\n//for i:=1 to 100 do\n//otv:=z2[i]+otv;\ns1:=d div s;\nif d mod s<>0 then s1:=s1+1;\nwrite(s1*d*s-a);\n\nend.\n"}, {"source_code": "var a,d:array[1..1000] of longint;\ni,j,n,m,k,l:longint;\nbegin\nreadln(n,k);\nfor i:=1 to n do \nbegin\nread(a[i]);\ninc(d[a[i]]);\nend;\nfor i:=1 to 100 do\nif m0 then\nl:=l+((m*k)-d[i]);\nwriteln(l);\nend.\n"}, {"source_code": "var a,d:array[1..1000] of longint;\ni,j,n,m,k,l:longint;\nbegin\nreadln(n,k);\nfor i:=1 to n do \nbegin\nread(a[i]);\ninc(d[a[i]]);\nend;\ninc(l);\nfor i:=1 to 100 do\nif (d[i] mod (l*k)>0) and (d[i]>k) then inc(l);\nfor i:=1 to 100 do \nif d[i]>0 then m:=m+(l*k)-d[i];\nwriteln(m);\nend.\n"}, {"source_code": "program one;\n\nvar\n m, n1: array[1..100] of integer;\n s, s1: string;\n i, n, k, q, l, x, y: integer;\n\nbegin\n Readln(n, k);\n x := 0;\n y := k;\n for i := 1 to n do \n begin\n Read(n1[i]);\n q := n1[i];\n m[q] := m[q] + 1;\n end;\n for i := 1 to 100 do\n begin\n if m[i] > k then k := k + y;\n end;\n for i := 1 to 100 do\n begin\n if m[i] = 0 then m[i] := 101;\n end;\n for i := 1 to 100 do\n begin\n if (m[i] <> 101) then begin\n if m[i] <> k then x := x + (k - m[i]);\n end;\n end; \n Writeln(x);\nend."}, {"source_code": "Var i,n,k,kol,sum,ans : longint;\n a,b : array[1..100] of integer;\n\n\nBegin\nread(n,k);\nfor i:=1 to n do \n begin\n read(a[i]);\n if b[a[i]]=0 then inc(sum);\n inc(b[a[i]]);\n if b[a[i]]>kol then kol:=b[a[i]];\n end;\n if k >= kol \n then ans:=(k*sum)-n\n else ans:=(((kol div k)+1)*sum*k)-n;\n writeln(ans);\nend.\n "}, {"source_code": "Var i,n,k,kol,sum,ans : longint;\n a,b : array[1..100] of integer;\n\n\nBegin\nread(n,k);\nfor i:=1 to n do \n begin\n read(a[i]);\n if b[a[i]]=0 then inc(sum);\n inc(b[a[i]]);\n if b[a[i]]>kol then kol:=b[a[i]];\n end;\n if k mod kol=0 \n then ans:=(k*sum)-n\n else ans:=(((kol div k)+1)*sum*k)-n;\n writeln(ans);\nend.\n "}, {"source_code": "var a,b,n,c,i:integer;\nbegin\nb:=0;\nread(n);readln(a);\nfor i:=1 to n do begin read(c); b:=b+c end;\nwriteln(a*n-b)\nend."}, {"source_code": "program pr;\nvar a,b,i,q,e,k:integer;\nc:array [1..100] of integer;\n\nbegin\nread(a);\nread(b);\nfor i:=1 to a do\nread(c[i]);\nfor q:=2 to a do\nfor e:=1 to q-1 do\nif c[q]=c[e] then\nc[q]:=0;\n\nfor i:=1 to a do\nif c[i]>0 then\nk:=k+1; \n\nwrite(k*b-a);\n\nend."}, {"source_code": "var\n n, k, view, din, mug, i: byte;\n a: array [1..100] of byte;\n\nbegin\n read(n, k);\n din := 1;\n mug := 0;\n for i := 1 to 100 do\n a[i] := 0;\n for i := 1 to n do\n begin\n read(view);\n a[view] := a[view] + 1;\n if (a[view] / k) > din then din := din + 1;\n end;\n for i := 1 to 100 do if (a[i] > 0) and ((a[i] mod (din * k)) <> 0) then mug := mug + din * k - a[i];\n write(mug);\nend."}, {"source_code": "var\n n, k, view, din, mug, i: byte;\n a: array [1..100] of byte;\n\nbegin\n read(n, k);\n din := 1;\n mug := 0;\n for i := 1 to 100 do\n a[i] := 0;\n for i := 1 to n do\n begin\n read(view);\n a[view] := a[view] + 1;\n if (a[view] / k) > din then din := din + 1;\n end;\n for i := 1 to 100 do if (a[i] > 0) and ((a[i] - (din * k)) <> 0) then mug := mug + din * k - a[i];\n write(mug);\nend."}, {"source_code": "var A: array [1..100] of byte;\nn,k,x,i,max,v,maxk: byte;\nbegin\nread(n,k);\nfor i:= 1 to 100 do\n A[i]:=0;\nmax:=0;\nv:=0;\nfor i:= 1 to n do begin\n read(x);\n A[x]:=A[x]+1 end;\nfor i:=1 to 100 do\n if (A[i]>k) and (A[i]/k>max) then begin\n if A[i] mod k = 0 then max:=A[i] div k else\n max:=(A[i] div k) + 1;\n maxk:=max*k end;\nif maxk=0 then maxk:=k;\nfor i:=1 to 100 do\n if (A[i]>0) and (A[i]max then max:=a[i];\n if (a[i]0) then min:=a[i];\n\n end;\nif max mod k=0 then x:=max div k\nelse x:=(max div k)+1;\n\nwriteln (abs((x*max*k)-n));\n\nend.\n\n"}, {"source_code": "var\n arr: array[1..100] of longint;\n k, n, i, ch, kolv, max: longint;\n\nbegin\n read(k, n);\n for i := 1 to k do\n begin\n read(ch);\n if arr[ch] = 0 then kolv := kolv + 1;\n arr[ch] := arr[ch] + 1;\n end; \n for i := 1 to 100 do\n if max < arr[i] then max := arr[i];\n if max mod n = 0 then write((max mod n) * kolv * n - k)\n else write(((max mod n) + 1) * kolv * n - k);\nend."}, {"source_code": "program abc;\nvar n,a,k,s,i:integer;\n m:array[1..100] of integer;\nbegin\ns:=0;\nread(n);\nread(k);\nfor i:=1 to n do\n begin\n read(a);\n inc(m[a]);\n end;\nfor i:=1 to 100 do\n if m[i]<>0 then\n s:=s+(k-m[i]);\nwriteln(s);\nend."}, {"source_code": "program zA;\nvar\n n, k: integer;\n aAStr: array of string;\n //a: array [1..100] of integer;\n al: array [1..100] of integer;\n ai: integer;\n nk: array of string;\n nkStr, aStr: string;\n err: integer;\nbegin\n readln(nkStr);\n nk := nkStr.Split(' ');\n val(nk[0], n, err);\n val(nk[1], k, err);\n \n readln(aStr);\n aAStr := aStr.Split(' ');\n for var i := 0 to 99 do begin\n if i+1 > length(aAStr) then break;\n val(aAStr[i], ai, err);\n al[ai] := al[ai] + 1;\n writeln(al[ai], ' | ', ai);\n end;\n \n var aMax: integer := 0;\n var pNum: integer := 0;\n for var i := 1 to 100 do begin\n if al[i] > 0 then pNum := pNum + 1;\n if aMax < al[i] then aMax := al[i];\n end;\n \n writeln(aMax);\n \n var buff: integer := aMax mod k;\n var blNum: integer := aMax div k;\n if buff > 0 then blNum := blNum + 1;\n writeln(blNum);\n writeln((blNum*k*pNum)-n);\nend."}, {"source_code": "program z_a;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, k, i, sum, x, max: integer;\n a: array[1..100] of integer;\n\nbegin\n readln(n, k);\n sum := 0;\n max := 0;\n for i := 1 to n do\n a[i] := 0;\n for i := 1 to n do begin\n read(x);\n inc(a[x]);\n end;\n for i := 1 to 100 do\n if(a[i] > max) then\n max := a[i];\n if(max > k) then\n max := k * 2;\n for i := 1 to 100 do begin\n if(a[i] > 0) then\n inc(sum, max - a[i]);\n end;\n writeln(sum);\n readln;\n readln;\nend.\n"}, {"source_code": "program x;\nvar\na, n, k, i, col, m, e:integer;\nb:array[1..100] of integer;\nc:array[1..100] of integer;\nbegin\nread(n, k);\nfor i:=1 to n do\n read(b[i]);\nfor i:=1 to n do\nbegin\n for e:=1 to 100do\n if(b[i]=e) then c[e]:=c[e]+1;\nend;\nfor i:=1 to 100 do\n if(c[i]<>0) then col:=col+1;\n\nm:=n div col;\n//writeln(col);\n//writeln(m);\n//writeln(k);\nwriteln(col*m*k-n);\n\n \nend."}, {"source_code": "var n, k, i, p, c:byte;\n a: array [1..100] of byte;\nbegin\n readln(n, k);\n for i:=1 to n do\n begin\n read(p);\n if a[p]=0 then c+=1;\n inc(a[p]);\n end;\n for i:=1 to 100 do\n if a[i]>k then begin k:=((a[i] div k)+1)*k; break; end;\n write(c*k-n);\nend."}, {"source_code": "var n, k, i, p, c, max:byte;\n a: array [1..100] of byte;\nbegin\n readln(n, k);\n for i:=1 to n do\n begin\n read(p);\n if a[p]=0 then c+=1;\n inc(a[p]);\n end;\n for i:=1 to 100 do\n if a[i]>max then max:=a[i];\n if max>k then k:=((max div k)+1)*k;\n write(c*k-n);\nend."}, {"source_code": "var n, k, i, p, s:byte;\n a: array [1..100] of byte;\nbegin\n readln(n, k);\n for i:=1 to n do\n begin\n read(p);\n inc(a[p]);\n end;\n for i:=1 to 100 do\n if a[i]>k then k:=((a[i] div k)+1)*k;\n for i:=1 to 100 do\n if (a[i]<>0) and (a[i]maxl then maxl:=mas[i];\nfor i:=1 to 1000 do\nif mas[i]<>0 then r:=r+1;\ne:=r;\nst:=1;\nif maxl>k then begin\nwhile maxl>k do begin\nmaxl:=maxl-k;\nst:=st+1;\nend;\nend;\nykr:=st*r*k;\nykr:=ykr-n;\nwriteln(ykr);\nend."}], "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f"} {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='b.in';\n file2='b.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n modulo=1000000007;\n\nvar qc:array[0..200000,0..1]of int64;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n k,ii,jj,kk,ll,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res,num:longint;\n a:int64;\n s,s0,s1,s2:ansistring;\n sss:ansistring;\n x,y,z,x0,x1,x2,y0,y1,y2,z0,z1,z2:extended;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\nprocedure load;\nvar i,j:longint;\n begin\n readln(s1);\n readln(s2);\n readln(n);\n end;\n\nprocedure save;\nvar i,j:longint;\n begin\n writeln(qc[n,1]);\n end;\n\nprocedure run;\nvar i,j:longint;\n begin\n num:=0;\n ll:=length(s1);\n for i:=1 to ll do\n begin\n s0:='';\n for j:=i to ll do s0:=s0+s1[j];\n for j:=1 to i-1 do s0:=s0+s1[j];\n if s0=s2 then inc(num);\n end;\n if s1=s2 then qc[0,1]:=1 else qc[0,0]:=1;\n for i:=1 to n do\n begin\n qc[i,0]:=(qc[i-1,0]*(ll-num-1)+qc[i-1,1]*(ll-num))mod modulo;\n qc[i,1]:=(qc[i-1,0]*num+qc[i-1,1]*(num-1))mod modulo;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output);}\nend.\n", "positive_code": [{"source_code": "const mm:longint=1000000007;\n\nvar s,v,w:ansistring;\n i,j,k,n,t,lt,ans:longint;\n a:array[0..1001] of longint;\n begin\n readln(s);\n readln(v);\n readln(k);\n n:=length(s);\n\n t:=1;\n a[n]:=1;\n for i:=1 to k do\n begin\n lt:=0;\n for j:=1 to n do\n begin\n a[j]:=(t-a[j]+mm) mod mm;\n lt:=(lt+a[j]) mod mm;\n end;\n t:=lt;\n end;\n\n\n ans:=0;\n for i:=1 to n do\n begin\n if i a[i + j - 1] then begin\n flag := false;\n break;\n end;\n if flag then\n ans := (ans + d[k][1]) mod base;\n end;\n write(ans);\n\nend.\n"}, {"source_code": "const\n mo=1000000000+7;\nvar\n sum:array[0..100000]of int64;\n t:array[0..1000]of boolean;\n f:array[0..1000]of int64;\n ans:int64;\n a,b,st,en:ansistring;\n n,k,i:longint;\n found:boolean;\n\nbegin\n readln(st);\n readln(en);\n n:=length(st);\n readln(k);\n for i:=0 to n-1 do\n begin\n found:=true;\n if i>0 then\n begin\n a:=copy(st,1,i);\n b:=copy(en,n-i+1,i);\n if a<>b then found:=false;\n end;\n if i<(n-1) then\n begin\n a:=copy(st,i+1,(n-i));\n b:=copy(en,1,(n-i));\n if a<>b then found:=false;\n end;\n t[i]:=found;\n end;\n sum[1]:=n-1;\n for i:=2 to k do\n sum[i]:=(sum[i-1]*int64(n-1)) mod mo;\n ans:=0;\n for i:=1 to k-1 do\n ans:=(sum[i]+mo-ans)mod mo;\n if k<>0 then\n begin\n if k mod 2=0 then\n begin\n for i:=1 to n-1 do\n f[i]:=(ans+mo-1)mod mo;\n f[0]:=ans;\n end\nelse\n begin\n for i:=1 to n-1 do\n f[i]:=(ans+mo+1)mod mo;\n f[0]:=ans;\n end;\n end;\n ans:=0;\n for i:=0 to n-1 do\n if t[i] then ans:=(ans+f[i]) mod mo;\n if k<>0 then writeln(ans) else if t[0] then writeln('1') else writeln('0');\nend.\n"}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n p = 1000 * 1000 * 1000 + 7;\n\nvar k : longint;\n ans : int64;\n s, t : string;\n\nprocedure pout;\nbegin\n writeln(ans);\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n readln(s);\n readln(t);\n read(k);\nend;\n\nprocedure solve;\nvar i, j, f1, f2, l : longint;\n r : string;\n flag : boolean;\n a1, a2, b1, b2 : qword;\nbegin\n if s = t then begin\n f1 := 1;\n end\n else begin\n f1 := 0;\n end;\n r := s + s;\n l := length(t);\n f2 := 0;\n for i := 2 to l do begin\n flag := true;\n for j := 1 to l do begin\n if r[i + j - 1] <> t[j] then begin\n flag := false;\n break;\n end;\n end;\n if flag then begin\n inc(f2);\n end;\n end;\n a1 := 1;\n a2 := 0;\n for i := 1 to k do begin\n b1 := (a2 * (l - 1)) mod p;\n b2 := (a2 * (l - 2) + a1) mod p;\n a1 := b1;\n a2 := b2;\n end;\n ans := (a1 * f1 + a2 * f2) mod p;\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "const md = 1000000007;\nvar\nans,p1,p2,np1,np2:int64;\ns,w:ansistring;\nn,i,k:longint;\n begin\n readln(s);\n readln(w);\n n:=length(s);\n readln(k);\n\n p1:=1;\n p2:=0;\n\n for i:=1 to k do\n begin\n np1:=p2*(n-1);\n np2:=p1+p2*(n-2);\n\n p1:=np1 mod md;\n p2:=np2 mod md;\n end;\n\n ans:=0;\n\n if s=w then ans:=(ans+p1)mod md;\n\n for i:=1 to n-1 do\n begin\n s:=s+s[1];\n delete(s,1,1);\n if s=w then ans:=(ans+p2)mod md;\n end;\n writeln(ans);\n end."}, {"source_code": "uses math;\nconst debug=0;\n oo=high(longint);\n eps=1e-5;\n dx:array[0..7] of longint=(0,0,1,-1,-1,-1,1,1);\n dy:array[0..7] of longint=(-1,1,0,0,-1,1,-1,1);\n modd=round(1e9)+7;\nvar fi,fo:string;\n f,g:text;\n a,b:ansistring;\n ans,gt,k,n:int64;\n i:longint;\n s:array[1..2,0..110000] of int64;\n //-----------\nbegin\n randomize;\n fi:=''; fo:='';\n if debug=1 then begin fi:='i.inp'; fo:='o.out'; end;\n assign(f,fi); reset(F);\n assign(g,fo); rewrite(G);\n //\n readln(f,a); n:=length(a);\n readln(f,b);\n readln(f,k);\n if length(a)<>length(b) then begin writeln(g,0); close(f); close(g); halt; end;\n\n s[1,0]:=1;\n for i:=1 to k do begin\n s[1,i]:=((n-1)*s[2,i-1]+(n-2)*s[1,i-1]) mod modd;\n s[2,i]:=s[1,i-1];\n end;\n for i:=1 to n-1 do\n if copy(a,i+1,n-i)+copy(a,1,i)=b then ans:=(ans+s[2,k]) mod modd;\n\n s[1,0]:=0; s[2,0]:=1;\n for i:=1 to k do begin\n s[1,i]:=((n-1)*s[2,i-1]+(n-2)*s[1,i-1]) mod modd;\n s[2,i]:=s[1,i-1];\n end;\n if a=b then ans:=(ans+s[2,k]) mod modd;\n writeln(g,ans);\n close(g);\n close(f);\nend.\n\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type double=int64;\nconst nn=1000001; modul=1000000007;\n eps=0.0000000001; nnn=2000000;\n label 1,2,3,4;\nvar kol,j1,i,kk,pp,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,step,j:longint;\np1,p,kolraz,rr,s1,mmin,imin,x0,y0,w,vp,vd,f,ii,n,ot,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\nsdvig,vrag:array [-1..100000 ] of boolean;\nx,y,gr:array[0..nn] of double;\ns:double;\nkol0,kol_0,dd:array[0..100000] of int64;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\na1,b1:array[0..200,0..200] of char;\naa:array[0..200,0..200] of boolean;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while ksss1[j] then\n begin flag:=false; {writeln('j= ',j);} end;\n sdvig[i]:=flag;\n end;\n if (kol=0)and sdvig[0] then begin writeln(1);goto 1; end;\n { for i:=0 to n-1 do write(sdvig[i],' '); writeln;\n } kol0[1]:=0;kol_0[1]:=1;\n for i:=2 to kol do\n begin\n p:=n;\n kol0[i]:=((p-1)*kol_0[i-1]) mod modul;\n kol_0[i]:=((p-2)*kol_0[i-1]+kol0[i-1]) mod modul;\n end;\n { for i:=1 to kol do writeln(i,' ',kol0[i]:7,' ',kol_0[i]);\n writeln(kol0[kol],' == ',kol_0[kol]);\n } p:=0;\n for i:=1 to n-1 do if sdvig[i] then inc(p);\n if sdvig[0] then p1:=1 else p1:=0;\n ot:=(p*kol_0[kol]+p1*kol0[kol]) mod modul;\n writeln(ot);\n\n 1:\n close(output);\nend.\n"}, {"source_code": "const modulo = 1000000007;\nvar f:array[0..111111] of int64;\n n,i,j:longint;\n s1,s2:ansistring;\n sum,answer:int64;\n\nfunction solve(d:longint; var s1,s2:ansistring):boolean;\nvar i1,i2:longint;\n i:longint;\nbegin\n for i:= 1 to length(s1) do\n begin\n j:=i+d;\n j:=j mod length(s1); if j = 0 then j:=length(s1);\n if s1[j]<>s2[i] then\n begin\n solve:=false;\n exit;\n end;\n end;\n solve:=true;\nend;\n\n\nbegin\n {assign(input,'input.txt');\n reset(input); }\n readln(s1);\n readln(s2);\n readln(n);\n fillchar(f,sizeof(f),0);\n f[0]:=1;\n sum:=1;\n for i:= 1 to n do\n begin\n for j:= 0 to length(s1)-1 do\n begin\n f[j]:=sum-f[j];\n if f[j]<0 then f[j]:=f[j]+modulo;\n end;\n sum:=0;\n for j:= 0 to length(s1)-1 do\n sum:=(Sum+f[j]) mod modulo;\n end;\n answer:=0;\n for i:= 0 to length(s1)-1 do\n begin\n if solve(i,s1,s2)=false then continue;\n answer:=(answer+f[i]) mod modulo;\n end;\n writelN(answer);\nend.\n"}, {"source_code": "const\n base=1000000007;\n\nvar\n f:array[0..500500,1..2]of longint;\n s,p,q:ansistring;\n n,i,k,ans:longint;\n\nbegin\n readln(s);\n readln(p);\n readln(k);\n n:=length(s);\n f[0][1]:=1;\n f[0][2]:=0;\n for i:=1 to k do begin\n f[i][1]:=int64(f[i-1][2])*(n-1)mod base;\n f[i][2]:=int64(f[i-1][2])*(n-2)mod base;\n f[i][2]:=(f[i][2]+f[i-1][1])mod base;\n end;\n if (s=p)then ans:=f[k][1] else ans:=0;\n q:=s;\n for i:=2 to length(s)do begin\n delete(q,1,1);\n q:=q+s[i-1];\n if (q=p)then ans:=(ans+f[k][2])mod base;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const modulo = 1000000007;\n\nvar a, b , aa ,bb,ans :int64;\n st , fin : array [1..1009] of char;\n n ,k :longint;\n\nfunction equal( s : longint ): boolean;\nvar i,j:longint;\nbegin\n i:=s+1;\n if i > n then i:=1;\n j:=2;\n\n while (i<>s) and (st[j] = fin[i] ) do begin\n inc(j);\n inc(i);\n if i > n then i:=1;\n end;\n \n if (st[1] <> fin[i]) or (j<>n+1) then exit(false) else exit(true);\nend;\n\n\nvar i :longint;\n c:char;\nbegin\n a:=1;\n b:=0;\n i:=0;\n\n while not EOLN do begin inc(i); read(st[i]); end;\n n:=i;\n i:=0;\n readln(c);\n for i:=1 to n do read(fin[i]);\n\n readln( k );\n\n ans:=0;\n for i:=1 to k do begin\n aa:=a; bb:=b;\n a:=bb*(n-1);\n b:=aa + bb*(n-2);\n a:=a mod modulo;\n b:=b mod modulo;\n end;\n\n //writeln(a,b); \n for i:=1 to n do begin\n if equal(i) then begin\n if i = 1 then inc(ans , a) else inc(ans , b);\n end;\n ans:= ans mod modulo;\n end;\n //writeln(equal(1));\n writeln( ans );\n\nend.\n"}, {"source_code": "program qwe;\n{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $00200000}\n\nuses\n SysUtils,\n Math;\n\n//it is a big shablon. if you see any strange function, never mind\n\nconst base = 1000000007;\n eps = 1e-8;\n inf = 1 shl 30;\n\ntype\n TArray = array[0..10000010] of integer;\n int53 = int64;\n itneger = integer;\n point = record\n x, y: integer;\n end;\n\nfunction sqrr(a, b: integer): int64;\nvar\n dega, res: int64;\nbegin\n res := 1;\n dega := a;\n while b > 0 do\n begin\n if odd(b) then res := res * dega;\n dega := dega * dega;\n b := b div 2;\n res := res mod base;\n dega := dega mod base;\n end;\n result := res mod base;\nend;\n\nfunction less(x, y: point): boolean;\nbegin\n if (x.x < y.x) or ((x.x = y.x) and (x.y < y.y)) then result := true else result := false;\nend;\n\nprocedure swap(var x, y: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swap64(var x, y: int64);\nvar\n z: int64;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapex(var x, y: extended);\nvar\n z: extended;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapp(var x, y: point);\nvar\n z: point;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nvar\n s, t: string;\n b: array[0..1010] of boolean;\n i, j, n, k: integer;\n x, y, xx, yy, ans: int64;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n readln(s);\n readln(t);\n n := length(s);\n for i := 1 to n do\n begin\n b[i - 1] := true;\n for j := 0 to n - 1 do\n b[i - 1] := b[i - 1] and (s[j + 1] = t[(i + j - 1) mod n + 1]);\n end;\n readln(k);\n ans := 0;\n if k = 0 then\n begin\n if s = t then\n writeln(1) else\n writeln(0);\n halt(0);\n end else\n if k = 1 then\n begin\n for i := 2 to n do\n if b[i - 1] then inc(ans);\n writeln(ans);\n halt(0);\n end;\n if n = 2 then\n begin\n if (s = t) and (s[1] = s[2]) then writeln(1) else\n if s = t then writeln(1 - k mod 2) else\n if (s[1] = t[2]) and (s[2] = t[1]) then writeln(k mod 2) else\n writeln(0);\n halt(0);\n end;\n dec(k, 2);\n x := n - 1;\n y := n - 2;\n for i := 1 to k do\n begin\n xx := y * (n - 1) mod base;\n yy := y * (n - 2) mod base;\n yy := (yy + x) mod base;\n x := xx;\n y := yy;\n end;\n for i := 1 to n - 1 do\n if b[i] then ans := (ans + y) mod base;\n if b[0] then ans := (ans + x) mod base;\n writeln(ans); \nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n s1,s2:String;\n pref,suf:Array[0..3000] of String;\n i,md:Integer;\n k,t,r,r1,r2,ans,n:Int64;\nBegin\n md:=1000000007;\n ReadLn(s1);\n ReadLn(s2);\n Read(k);\n If k=0 Then Begin\n If s1=s2 Then Write(1)\n Else Write(0);\n Halt;\n End;\n r1:=0;\n r2:=0;\n n:=length(s1);\n pref[1]:=s1[1];\n For i:=2 To n Do pref[i]:=pref[i-1]+s1[i];\n suf[n]:=s1[n];\n For i:=n-1 DownTo 1 Do suf[i]:=s1[i]+suf[i+1];\n If s1=s2 Then r1:=1;\n For i:=2 To n Do\n If suf[i]+pref[i-1]=s2 Then r2:=r2+1;\n If k=1 Then Begin\n Write(r2);\n Halt;\n End;\n t:=1;\n r:=1;\n For i:=1 To k Do Begin\n t:=(md+r-t) mod md;\n r:=(r*(n-1)) mod md;\n End;\n ans:=t*r1 mod md;\n t:=0;\n r:=1;\n For i:=1 To k Do Begin\n t:=(md+r-t) mod md;\n r:=(r*(n-1)) mod md;\n End;\n ans:=(ans+t*r2) mod md;\n Write(ans);\nEnd."}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+,S+}\n\nconst maxl = 1000;\n MD = 1000000007;\n\nvar l: integer;\nvar k: integer;\nvar start, finish: string;\nvar x: array[1..maxl] of int64;\n\nprocedure readdata;\nbegin\n readln(start);\n readln(finish);\n read(k);\nend;\n\nprocedure init;\nbegin\n l := length(start);\nend;\n\nvar a, b: int64;\n\nprocedure solve;\nvar i: integer;\n ta, tb: int64;\nbegin\n a := 1; b := 0;\n for i := 1 to k do begin\n ta := (b * (l - 1)) mod MD;\n tb := (b * (l - 2) + a) mod MD;\n a := ta;\n b := tb;\n end;\nend;\n\nprocedure save;\nvar\n ans: int64;\n i: integer;\nbegin\n ans := 0;\n for i := 1 to l do begin\n if copy(start, i, l-i+1) + copy(start, 1, i-1) = finish then\n if i = 1 then\n ans := ans + a\n else\n ans := ans + b\n end;\n write(ans mod MD)\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'b.in'); reset(input);\n assign(output, 'b.out'); rewrite(output);\n {$ENDIF}\n readdata;\n init;\n solve;\n save;\n {$IFNDEF ONLINE_JUDGE}\n close(output);\n close(input);\n {$ENDIF}\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type double=int64;\nconst nn=1000001; modul=1000000007;\n eps=0.0000000001; nnn=2000000;\n label 1,2,3,4;\nvar kol,j1,i,kk,pp,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,step,j:longint;\np1,p,kolraz,rr,s1,mmin,imin,x0,y0,w,vp,vd,f,ii,n,ot,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\nsdvig,vrag:array [-1..100000 ] of boolean;\nx,y,gr:array[0..nn] of double;\ns:double;\nkol0,kol_0,dd:array[0..100000] of int64;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\na1,b1:array[0..200,0..200] of char;\naa:array[0..200,0..200] of boolean;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while ksss1[j] then\n begin flag:=false; {writeln('j= ',j);} end;\n sdvig[i]:=flag;\n end;\n if (kol=0)and sdvig[0] then begin writeln(1);goto 1; end;\n { for i:=0 to n-1 do write(sdvig[i],' '); writeln;\n } kol0[1]:=0;kol_0[1]:=1;\n for i:=2 to kol do\n begin\n p:=n;\n kol0[i]:=((p-1)*kol_0[i-1]) mod modul;\n kol_0[i]:=((p-2)*kol_0[i-1]+kol0[i-1]) mod modul;\n end;\n { for i:=1 to kol do writeln(i,' ',kol0[i]:7,' ',kol_0[i]);\n writeln(kol0[kol],' == ',kol_0[kol]);\n } p:=0;\n for i:=1 to n-1 do if sdvig[i] then inc(p);\n if sdvig[0] then p1:=1 else p1:=0;\n ot:=(p*kol_0[kol]+p1*kol0[kol]) mod modul;\n writeln(ot);\n\n 1:\n close(output);\nend.\n"}, {"source_code": "program Task1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst md = round(1e9)+7;\nvar t,s1,s2: string;\n n,i,col,k,j,l: integer;\n cnt0,cnt1,buf0,buf1: integer;\n r: array[0..1000]of integer;\nbegin\n readln(s1);\n readln(s2);\n readln(k);\n col:=0;\n if (s1=s2)then begin\n inc(col);\n r[col]:=0;\n end;\n n:=length(s1)-1;\n for i:=1 to n do begin\n t:=copy(s1,i+1,n+1-i)+copy(s1,1,i);\n if (t=s2)Then begin\n inc(col);\n r[col]:=i;\n end;\n end;\n if (col=0)then begin\n write(0);\n halt;\n end;\n\n cnt0:=1;\n cnt1:=0;\n\n for i:=1 to k do begin\n buf0:=cnt0;\n buf1:=cnt1;\n cnt0:=0;\n for j:=1 to n do\n cnt0:=(cnt0+buf1)mod md;\n cnt1:=buf0;\n for j:=1 to n-1 do\n cnt1:=(cnt1+buf1)mod md;\n end;\n\n j:=0;\n for i:=1 to col do\n if (r[i]=0)then\n j:=(j+cnt0)mod md\n else\n j:=(j+cnt1)mod md;\n write(j);\nend.\n"}, {"source_code": "program cf176b;\nconst mo=1000000007;\nvar\n n,m,i,j,kk:longint;\n jz:array[0..3000]of int64;\n s1,s2:array[0..3000]of char;\n f0,h1,h2,f1:array[0..200000]of int64;\n ct0,ct1:int64;\n ans:int64;\nbegin\n jz[0]:=1;\n for i:=1 to 3000 do jz[i]:=jz[i-1]*29;\n\n n:=0;\n while not(eoln) do begin\n inc(n);\n read(s1[n]);\n end;\n readln;\n m:=0;\n while not(eoln) do begin\n inc(m);\n read(s2[m]);\n end; readln;\n if n<>m then begin\n writeln(0);\n halt;\n end;\n\n for i:=m+1 to 2*m do s2[i]:=s2[i-m];\n\n\n h2[0]:=0;\n for i:=1 to 2*m do h2[i]:=(h2[i-1]*29+(ord(s2[i])-ord('a')+1) );\n h1[0]:=0;\n for i:=1 to n do h1[i]:=(h1[i-1]*29+(ord(s1[i])-ord('a')+1) );\n if h2[m]=h1[n] then ct0:=1 else ct0:=0;\n\n ct1:=0;\n for i:=m+1 to 2*m-1 do\n if h2[i]-(h2[i-m]*jz[m])=h1[m] then inc(ct1);\n\n\n f0[0]:=1;\n f1[0]:=0;\n readln(kk);\n for i:=1 to kk do begin\n f0[i]:=(f1[i-1]*(n-1)) mod mo;\n f1[i]:=(f0[i-1]+f1[i-1]*(n-2))mod mo;\n end;\n\n if ct0=1 then ans:=f0[kk] else ans:=0;\n ans:=((ans+f1[kk]*ct1)mod mo);\n writeln(ans);\nend.\n"}, {"source_code": "{$Mode objfpc}\n{$M 20000000}\n{$H+}\n\n\nconst\n maxN= 100000;\n base= round(1e9)+ 7;\n\nvar\n f, g: array[0.. maxn] of int64;\n i, j, k, n, d: integer;\n res: int64;\n s, t, x: string;\n\nbegin\n // assign(input, 'test.inp'); reset(input);\n\n readln(s);\n readln(t);\n n:= length(t);\n readln(k);\n x:= s;\n for i:= 2 to n do\n begin\n x:= x+ x[1];\n delete(x, 1, 1);\n if x= t then inc(d);\n end;\n g[0]:= 1;\n f[1]:= 1;\n g[1]:= 0;\n for i:= 2 to k do\n begin\n f[i]:= ( (n- 2)* f[i- 1]+ g[i- 1]) mod base;\n g[i]:= f[i- 1]* (n- 1) mod base;\n end;\n res:= f[k]* d mod base;\n if s= t then res:= (res+ g[k]) mod base;\n writeln(res);\nend.\n"}, {"source_code": "var\n st1,st2:ansistring;\n a,b,a1,b1,n,ans:int64;\n i,k,j:longint;\nbegin\n readln(st1);\n readln(st2);\n readln(k);\n a:=1;\n b:=0;\n n:=length(st1);\n for i:=1 to k do begin\n a1:=b*(n-1) mod 1000000007;\n b1:=(a+b*(n-2)) mod 1000000007;\n a:=a1;\n b:=b1;\n end;\n ans:=0;\n if st1=st2 then ans:=ans+a;\n for i:=1 to n-1 do\n begin\n ans:=(ans+b)mod 1000000007;\n\n for j:=0 to n-1 do\n if st1[(i+j) mod n +1]<>st2[(j) mod n +1] then\n begin\n ans:=(ans-b+1000000007)mod 1000000007;\n break;\n end;\n end;\n writeln(ans);\n\nend."}, {"source_code": "const md = 1000000007;\nvar\nans,p1,p2,np1,np2:int64;\ns,w:ansistring;\nn,i,k:longint;\n begin\n readln(s);\n readln(w);\n n:=length(s);\n readln(k);\n\n p1:=1;\n p2:=0;\n\n for i:=1 to k do\n begin\n np1:=p2*(n-1);\n np2:=p1+p2*(n-2);\n\n p1:=np1 mod md;\n p2:=np2 mod md;\n end;\n\n ans:=0;\n\n if s=w then ans:=(ans+p1)mod md;\n\n for i:=1 to n-1 do\n begin\n s:=s+s[1];\n delete(s,1,1);\n if s=w then ans:=(ans+p2)mod md;\n end;\n writeln(ans);\n end."}, {"source_code": "const mo=1000000007;\nvar i,j,q:longint;\n n,t,t2,a,a2,ans:int64;\n v:array[0..1000]of boolean;\n s,w:array[1..2000]of char;\n//======================================================\nbegin\n repeat\n inc(n);read(s[n]);\n until eoln;readln;\n for i:=1 to n do read(w[i]);\n readln(q);\n for i:=1 to n do s[i+n]:=s[i];\n for i:=0 to n-1 do\n begin\n v[i]:=true;\n for j:=1 to n do\n if s[i+j]<>w[j] then\n begin\n v[i]:=false;break;\n end;\n end;\n if q=0 then\n begin\n if v[0] then writeln(1) else writeln(0);\n exit;\n end;\n if q=1 then\n begin\n for i:=1 to n-1 do if v[i] then inc(ans);\n writeln(ans);exit;\n end;\n t:=0;t2:=1;\n for i:=2 to q do\n begin\n a:=t2*(n-1);\n a2:=t+t2*(n-2);\n t:=a mod mo;t2:=a2 mod mo;\n end;\n if v[0] then ans:=t;\n for i:=1 to n-1 do if v[i] then inc(ans,t2);\n writeln(ans mod mo);\nend.\n"}, {"source_code": "const\n\tmd = round(1e9) + 7;\n\t\nvar\n\ti, k, l, g : longint;\n\ta, b : array [1 .. 1000] of char;\n\tdpa, dpb : array [0 .. 100000] of longint;\t\n\t\nfunction eq(off : longint) : boolean;\nvar\n\tx, y, i : longint;\n\tbool : boolean;\nbegin\n\tbool := true;\n\tx := off;\n\ty := 0;\n\tfor i := 1 to l do begin\n\t\tinc(x);\n\t\tif x > l then x := 1;\n\t\tinc(y);\n\t\tif y > l then y := 1;\n\t\tif a[x] <> b[y] then begin\n\t\t\tbool := false;\n\t\t\tbreak;\n\t\tend;\n\tend;\n\texit(bool);\nend;\n\nbegin\n\twhile not eoln do begin inc(l); read(a[l]); end; readln;\n\tfor i := 1 to l do read(b[i]);\n\treadln(k);\n\tfor i := 0 to l - 1 do if eq(i) then inc(g);\n\tif eq(0) then dpa[0] := 1 else dpb[0] := 1;\n\tfor i := 1 to k do begin\n\t\tdpa[i] := int64( dpa[i - 1] * int64(g - 1) + dpb[i - 1] * int64(g) ) mod md;\n\t\tdpb[i] := int64( dpa[i - 1] * int64(l - g) + dpb[i - 1] * int64(l - g - 1) ) mod md;\n\tend;\n\twriteln(dpa[k]);\nend."}, {"source_code": "const\n base=1000000007;\n\nvar\n f:array[0..500500,1..2]of longint;\n s,p,q:ansistring;\n n,i,k,ans:longint;\n\nbegin\n readln(s);\n readln(p);\n readln(k);\n n:=length(s);\n f[0][1]:=1;\n f[0][2]:=0;\n for i:=1 to k do begin\n f[i][1]:=int64(f[i-1][2])*(n-1)mod base;\n f[i][2]:=int64(f[i-1][2])*(n-2)mod base;\n f[i][2]:=(f[i][2]+f[i-1][1])mod base;\n end;\n if (s=p)then ans:=f[k][1] else ans:=0;\n q:=s;\n for i:=2 to length(s)do begin\n delete(q,1,1);\n q:=q+s[i-1];\n if (q=p)then ans:=(ans+f[k][2])mod base;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\ndp,c:array[0..1000]of longint;\ni,j,n,m,k,answer,add:longint;\n s1,s2:ansistring;\n begin\n readln(s1);\n readln(s2);\n readln(k);\n\n if k=0 then\n begin\n if s1=s2 then writeln(1)\n else writeln(0);\n halt(0);\n end;\n\n if (length(s1)=2) then\n begin\n if k mod 2=0 then\n begin\n if s1=s2 then writeln(1)\n else writeln(0);\n end\n else\n begin\n s1:=s1+s1[1];\n delete(s1,1,1);\n if s1=s2 then writeln(1)\n else writeln(0);\n end;\n halt(0);\n end;\n\n dp[0]:=1;\n for i:=1 to k do\n begin\n fillchar(c,sizeof(c),0);\n add:=0;\n for j:=0 to length(s1)-1 do\n begin\n c[j]:=c[j]-dp[j];\n add:=(add+dp[j]) mod 1000000007;\n end;\n\n for j:=0 to length(s1)-1 do\n begin\n dp[j]:=(c[j]+add) mod 1000000007;\n dp[j]:=(dp[j]+1000000007) mod 1000000007;\n end;\n end;\n\n if s1=s2 then answer:=(answer+dp[0]) mod 1000000007;\n for i:=1 to length(s1)-1 do\n begin\n s1:=s1[length(s1)]+s1;\n delete(s1,length(s1),1);\n if s1=s2 then answer:=(answer+dp[i]) mod 1000000007;\n end;\n writeln(answer mod 1000000007);\n end."}, {"source_code": "const\n{ fi='word.inp';\n fo='word.out';}\n fi='';\n fo='';\n inf=round(1e9)+7;\n maxk=100010;\n\nvar\n ff:text;\n a,b:ansistring;\n vt,k,i:longint;\n f,g:array[0..maxk]of int64;\n n,s:int64;\n ok:boolean;\n ch:char;\n\nbegin\n assign(ff,fi); reset(ff);\n readln(ff,a);\n readln(ff,b);\n n:=length(a);\n readln(ff,k);\n close(ff);\n\n ok:=false; s:=0;\n vt:=0;\n if a=b then vt:=1;\n for i:=1 to n do\n begin\n if a=b then\n begin\n ok:=true;\n inc(s);\n end;\n ch:=b[1];\n delete(b,1,1);\n b:=b+ch;\n end;\n\n assign(ff,fo); rewrite(ff);\n if s=0 then writeln(ff,0)\n else\n begin\n f[1]:=s-vt; g[1]:=n-1-s+vt;\n for i:=2 to k do\n begin\n f[i]:=(g[i-1]*s+f[i-1]*(s-1))mod inf;\n g[i]:=(f[i-1]*(n-s)+g[i-1]*(n-s-1)) mod inf;\n end;\n if (k=0) and (vt=1) then writeln(ff,1)\n else writeln(ff,f[k]);\n end;\n close(ff);\nend.\n"}, {"source_code": "{$H+}\nuses math;\nconst\n tfi = '';\n tfo = '';\n nmax = 101;\n p = 1000000007;\nvar\n fi,fo:text;\n n,m,res,k:longint;\n S,T:string;\n f:Array[0..nmax,0..nmax] of longint;\n g:array[0..100001] of longint;\nprocedure mo;\nvar i,j:longint;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\nend;\nprocedure nhap;\nvar i,j:longint;\nbegin\n readln(fi,S);\n readln(fi,T);\n read(fi,k);\n n:=length(S);\nend;\nfunction check(i:longint):boolean;\nvar j:longint;\nbegin\n for j:=i to n do\n if S[j]<>T[j-i+1] then exit(false);\n for j:=1 to i-1 do\n if S[j]<>T[(n-i+1)+j] then exit(false);\n exit(true);\nend;\nprocedure khoitao;\nvar i,j:longint;\nbegin\nend;\nprocedure xuly;\nvar i,j:longint;\nbegin\n g[0]:=0;\n for i:=1 to k do\n if i mod 2=0 then\n g[i]:=(g[i-1]*int64(n-1)-1)mod p\n else g[i]:=(g[i-1]*int64(n-1)+1)mod p;\n for i:=2 to n do\n if check(i) then\n res:=(res+g[k])mod p;\n if check(1) then\n begin\n if k mod 2=0 then res:=(res+g[k]+1)mod p\n else res:=(res+g[k]-1)mod p;\n end;\n writeln(fo,(res+p)mod p);\nend;\nprocedure inkq;\nvar i,j,t:longint;\nbegin\n f[0,1]:=1;\n for i:=1 to k do\n for j:=1 to n do\n for t:=1 to n do\n if j<>t then\n f[i,j]:=(f[i-1,t]+f[i,j])mod p;\n res:=0;\n for i:=1 to n do\n if check(i) then res:=(res+f[k,i])mod p;\n writeln(fo,(res+p)mod p);\nend;\nprocedure dong;\nvar i,j:longint;\nbegin\n close(fi);\n close(fo);\nend;\nbegin\n mo;\n nhap;\n khoitao;\n xuly;\n // inkq;\n dong;\nend.\n"}], "negative_code": [{"source_code": "uses math;\nconst debug=0;\n oo=high(longint);\n eps=1e-5;\n dx:array[0..7] of longint=(0,0,1,-1,-1,-1,1,1);\n dy:array[0..7] of longint=(-1,1,0,0,-1,1,-1,1);\n modd=round(1e9)+7;\nvar fi,fo:string;\n f,g:text;\n a,b:ansistring;\n ans,gt,k,n:int64;\n i:longint;\n s:array[1..2,0..100000] of int64;\n //-----------\nbegin\n randomize;\n fi:=''; fo:='';\n if debug=1 then begin fi:='i.inp'; fo:='o.out'; end;\n assign(f,fi); reset(F);\n assign(g,fo); rewrite(G);\n //\n readln(f,a); n:=length(a);\n readln(f,b);\n readln(f,k);\n if length(a)<>length(b) then begin writeln(g,0); close(f); close(g); halt; end;\n\n s[1,0]:=1;\n for i:=1 to k do begin\n s[1,i]:=((n-1)*s[2,i]+(n-2)*s[1,i]) mod modd;\n s[2,i]:=s[1,i-1];\n end;\n for i:=1 to n-1 do\n if copy(a,i+1,n-i)+copy(a,1,i)=b then ans:=(ans+s[2,k]) mod modd;\n\n s[1,0]:=0; s[2,0]:=1;\n for i:=1 to k do begin\n s[1,i]:=((n-1)*s[2,i]+(n-2)*s[1,i]) mod modd;\n s[2,i]:=s[1,i-1];\n end;\n if a=b then ans:=(ans+s[2,k]) mod modd;\n writeln(g,ans);\n close(g);\n close(f);\nend.\n\n"}, {"source_code": "const modulo = 1000000007;\n\nvar a, b , k, aa ,bb,ans :int64;\n st , fin : array [1..1009] of char;\n n:longint;\n\nfunction equal( s : longint ): boolean;\nvar i,j:longint;\nbegin\n i:=s+1;\n if i > n then i:=1;\n j:=2;\n\n while (i<>s) and (st[j] = fin[i] ) do begin\n inc(j);\n inc(i);\n if i > n then i:=1;\n end;\n \n if (st[1] <> fin[i]) or (j<>n+1) then exit(false) else exit(true);\nend;\n\n\nvar i :longint;\n c:char;\nbegin\n a:=1;\n b:=0;\n i:=0;\n\n while not EOLN do begin inc(i); read(st[i]); end;\n n:=i;\n i:=0;\n readln(c);\n for i:=1 to n do read(fin[i]);\n\n readln( k );\n\n ans:=0;\n for i:=1 to k do begin\n aa:=a; bb:=b;\n a:=bb*(n-1);\n b:=aa + bb*(n-2);\n end;\n\n //writeln(a,b); \n for i:=1 to n do begin\n if equal(i) then begin\n if i = 1 then inc(ans , a) else inc(ans , b);\n end;\n ans:= ans mod modulo;\n end;\n //writeln(equal(1));\n writeln( ans );\n\nend.\n"}, {"source_code": "const modulo = 1000000007;\n\nvar a, b , k, aa ,bb,ans :int64;\n st , fin : array [1..1009] of char;\n n:longint;\n\nfunction equal( s : longint ): boolean;\nvar i,j:longint;\nbegin\n i:=s+1;\n if s+1 = n+1 then i:=1;\n j:=2;\n\n while (i<>s) and (st[j] <> fin[i] ) do begin\n inc(j);\n inc(i);\n if i > n then i:=1;\n end;\n\n if st[j] = fin[i] then exit(true) else exit(false);\nend;\n\n\nvar i :longint;\n c:char;\nbegin\n a:=1;\n b:=0;\n i:=0;\n\n while not EOLN do begin inc(i); read(st[i]); end;\n n:=i;\n i:=0;\n readln(c);\n for i:=1 to n do read(fin[i]);\n\n readln( k );\n\n ans:=0;\n for i:=1 to k do begin\n aa:=a; bb:=b;\n a:=bb*(n-1);\n b:=aa + bb*(n-2);\n end;\n\n //writeln(a,b); \n for i:=1 to n do begin\n if equal(i) then begin\n if i = 1 then inc(ans , a) else inc(ans , b);\n end;\n ans:= ans mod modulo;\n end;\n\n writeln( ans );\n\nend.\n"}, {"source_code": "program qwe;\n{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $00200000}\n\nuses\n SysUtils,\n Math;\n\n//it is a big shablon. if you see any strange function, never mind\n\nconst base = 1000000007;\n eps = 1e-8;\n inf = 1 shl 30;\n\ntype\n TArray = array[0..10000010] of integer;\n int53 = int64;\n itneger = integer;\n point = record\n x, y: integer;\n end;\n\nfunction sqrr(a, b: integer): int64;\nvar\n dega, res: int64;\nbegin\n res := 1;\n dega := a;\n while b > 0 do\n begin\n if odd(b) then res := res * dega;\n dega := dega * dega;\n b := b div 2;\n res := res mod base;\n dega := dega mod base;\n end;\n result := res mod base;\nend;\n\nfunction less(x, y: point): boolean;\nbegin\n if (x.x < y.x) or ((x.x = y.x) and (x.y < y.y)) then result := true else result := false;\nend;\n\nprocedure swap(var x, y: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swap64(var x, y: int64);\nvar\n z: int64;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapex(var x, y: extended);\nvar\n z: extended;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapp(var x, y: point);\nvar\n z: point;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nvar\n s, t: string;\n b: array[0..1010] of boolean;\n i, j, n, k: integer;\n x, y, ans: int64;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n readln(s);\n readln(t);\n n := length(s);\n for i := 1 to n do\n begin\n b[i - 1] := true;\n for j := 0 to n - 1 do\n b[i - 1] := b[i - 1] and (s[j + 1] = t[(i + j - 1) mod n + 1]);\n end;\n readln(k);\n ans := 0;\n if k = 0 then\n begin\n if s = t then\n writeln(1) else\n writeln(0);\n halt(0);\n end else\n if k = 1 then\n begin\n for i := 2 to n do\n if b[i - 1] then inc(ans);\n writeln(ans);\n halt(0);\n end;\n if n = 2 then\n begin\n if (s = t) and (s[1] = s[2]) then writeln(1) else\n if s = t then writeln(1 - k mod 2) else\n if (s[1] = t[2]) and (s[2] = t[1]) then writeln(k mod 2) else\n writeln(0);\n halt(0);\n end;\n dec(k, 2);\n x := n - 1;\n y := n - 2;\n for i := 1 to k do\n begin\n x := y * (n - 1) mod base;\n y := y * (n - 2) mod base;\n y := (y + x) mod base;\n end;\n for i := 1 to n - 1 do\n if b[i] then ans := (ans + y) mod base;\n if b[0] then ans := (ans + x) mod base;\n writeln(ans); \nend."}, {"source_code": "program qwe;\n{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $00200000}\n\nuses\n SysUtils,\n Math;\n\n//it is a big shablon. if you see any strange function, never mind\n\nconst base = 1000000007;\n eps = 1e-8;\n inf = 1 shl 30;\n\ntype\n TArray = array[0..10000010] of integer;\n int53 = int64;\n itneger = integer;\n point = record\n x, y: integer;\n end;\n\nfunction sqrr(a, b: integer): int64;\nvar\n dega, res: int64;\nbegin\n res := 1;\n dega := a;\n while b > 0 do\n begin\n if odd(b) then res := res * dega;\n dega := dega * dega;\n b := b div 2;\n res := res mod base;\n dega := dega mod base;\n end;\n result := res mod base;\nend;\n\nfunction less(x, y: point): boolean;\nbegin\n if (x.x < y.x) or ((x.x = y.x) and (x.y < y.y)) then result := true else result := false;\nend;\n\nprocedure swap(var x, y: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swap64(var x, y: int64);\nvar\n z: int64;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapex(var x, y: extended);\nvar\n z: extended;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure swapp(var x, y: point);\nvar\n z: point;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nvar\n s, t: string;\n b: array[0..1010] of boolean;\n i, j, n, k: integer;\n x, y, ans: int64;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n readln(s);\n readln(t);\n n := length(s);\n for i := 1 to n do\n begin\n b[i - 1] := true;\n for j := 0 to n - 1 do\n b[i - 1] := b[i - 1] and (s[j + 1] = t[(i + j - 1) mod n + 1]);\n end;\n readln(k);\n ans := 0;\n if k = 0 then\n begin\n writeln(1);\n halt(0);\n end else\n if k = 1 then\n begin\n for i := 2 to n do\n if b[i - 1] then inc(ans);\n writeln(ans);\n halt(0);\n end;\n if n = 2 then\n begin\n if (s = t) and (s[1] = s[2]) then writeln(1) else\n if s = t then writeln(1 - k mod 2) else\n if (s[1] = t[2]) and (s[2] = t[1]) then writeln(k mod 2) else\n writeln(0);\n halt(0);\n end;\n dec(k, 2);\n x := n - 1;\n y := n - 2;\n for i := 1 to k do\n begin\n x := y * (n - 1) mod base;\n y := y * (n - 2) mod base;\n y := (y + x) mod base;\n end;\n for i := 1 to n - 1 do\n if b[i] then ans := (ans + y) mod base;\n if b[0] then ans := (ans + x) mod base;\n writeln(ans); \nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\n\nvar\n f1, f2 : array [0.. 200000] of int64;\n a, b, s : string;\n i, k : Integer;\n ans : int64;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(a);\n readln(b);\n read(k);\n for i := 0 to k do begin\n f1[i] := 0;\n f2[i] := 0;\n end;\n\n f1[0] := 1;\n f1[1] := 1;\n f2[0] := 1;\n f2[1] := 0;\n for i := 2 to k do begin\n f1[i] := (f1[i - 1] * (length(a) - 2)) mod (1000000007);\n if i mod 2 = 0 then\n f2[i] := (f2[i - 2] * (Length(a) - 1)) mod 1000000007;\n end; \n\n for i := 1 to length(a) - 1 do begin\n s := copy(a, i + 1, length(a) - i) + copy(a, 1, i);\n if s = b then\n ans := ans + f1[k];\n end;\n\n if a = b then\n ans := ans + f2[k];\n\n write(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\n\nvar\n f1, f2 : array [0.. 200000] of int64;\n a, b, s : string;\n i, k : Integer;\n ans : int64;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(a);\n readln(b);\n read(k);\n for i := 0 to k do begin\n f1[i] := 0;\n f2[i] := 0;\n end;\n\n f1[0] := 1;\n f1[1] := 1;\n f2[0] := 1;\n f2[1] := 0;\n for i := 2 to k do begin\n f1[i] := (f1[i - 1] * (length(a) - 2)) mod (1000000007);\n f2[i] := ( f1[i - 1] * (length(a) - 1)) mod 1000000007;\n end;\n\n\n ans := 0;\n for i := 1 to length(a) - 1 do begin\n s := copy(a, i + 1, length(a) - i) + copy(a, 1, i);\n if s = b then\n ans := ans + f1[k];\n end;\n\n if a = b then\n ans := ans + f2[k];\n\n write(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\n\nvar\n f1, f2 : array [0.. 200000] of int64;\n a, b, s : string;\n i, k : Integer;\n ans : int64;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(a);\n readln(b);\n read(k);\n for i := 0 to k do begin\n f1[i] := 0;\n f2[i] := 0;\n end;\n\n f1[0] := 1;\n f1[1] := 1;\n f2[0] := 1;\n f2[1] := 0;\n for i := 2 to k do begin\n f1[i] := f1[i - 1] * (length(a) - 2) mod 1000000007;\n f2[i] := f1[i - 1] * (length(a) - 1) mod 1000000007;\n end;\n\n\n ans := 0;\n for i := 1 to length(a) - 1 do begin\n s := copy(a, i + 1, length(a) - i) + copy(a, 1, i);\n if s = b then\n ans := (ans + f1[k]) mod 1000000007;\n end;\n\n if a = b then\n ans := (ans + f2[k]) mod 1000000007;\n\n write(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\n\nvar\n f1, f2 : array [0.. 200000] of int64;\n a, b, s : string;\n i, k : Integer;\n ans : int64;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(a);\n readln(b);\n read(k);\n for i := 0 to k do begin\n f1[i] := 0;\n f2[i] := 0;\n end;\n\n f1[0] := 1;\n f1[1] := 1;\n f2[0] := 1;\n f2[1] := 0;\n for i := 2 to k do begin\n f1[i] := (f1[i - 1] * (length(a) - 2) + f2[i - 1]) mod 1000000007;\n f2[i] := f1[i - 1] * (length(a) - 1) mod 1000000007;\n end;\n\n\n ans := 0;\n for i := 1 to length(a) - 1 do begin\n s := copy(a, i + 1, length(a) - i) + copy(a, 1, i);\n if s = b then\n ans := (ans + f1[k]) mod 1000000007;\n end;\n\n if a = b then\n ans := (ans + f2[k]) mod 1000000007;\n\n write(ans);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type double=int64;\nconst nn=1000001; modul=1000000007;\n eps=0.0000000001; nnn=2000000;\n label 1,2,3,4;\nvar kol,j1,i,kk,pp,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,step,j:longint;\np1,p,kolraz,rr,s1,mmin,imin,x0,y0,w,vp,vd,f,ii,n,ot,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\nsdvig,vrag:array [-1..100000 ] of boolean;\nx,y,gr:array[0..nn] of double;\ns:double;\nkol0,kol_0,dd:array[0..100000] of int64;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\na1,b1:array[0..200,0..200] of char;\naa:array[0..200,0..200] of boolean;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while ksss1[j] then\n begin flag:=false; {writeln('j= ',j);} end;\n sdvig[i]:=flag;\n end;\n { for i:=0 to n-1 do write(sdvig[i],' '); writeln;\n } kol0[1]:=0;kol_0[1]:=1;\n for i:=2 to kol do\n begin\n p:=n;\n kol0[i]:=((p-1)*kol_0[i-1]) mod modul;\n kol_0[i]:=((p-2)*kol_0[i-1]+kol0[i-1]) mod modul;\n end;\n { for i:=1 to kol do writeln(i,' ',kol0[i]:7,' ',kol_0[i]);\n writeln(kol0[kol],' == ',kol_0[kol]);\n } p:=0;\n for i:=1 to n-1 do if sdvig[i] then inc(p);\n if sdvig[0] then p1:=1 else p1:=0;\n ot:=(p*kol_0[kol]+p1*kol0[kol]) mod modul;\n writeln(ot);\n\n 1:\n close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type double=int64;\nconst nn=1000001; modul=1000000007;\n eps=0.0000000001; nnn=2000000;\n label 1,2,3,4;\nvar kol,j1,i,kk,pp,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,step,j:longint;\np,kolraz,rr,s1,mmin,imin,x0,y0,w,vp,vd,f,ii,n,ot,p1,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\nsdvig,vrag:array [-1..100000 ] of boolean;\nx,y,gr:array[0..nn] of double;\ns:double;\nkol0,kol_0,dd:array[0..100000] of int64;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\na1,b1:array[0..200,0..200] of char;\naa:array[0..200,0..200] of boolean;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while ksss1[j] then\n begin flag:=false; {writeln('j= ',j);} end;\n sdvig[i]:=flag;\n end;\n { for i:=0 to n-1 do write(sdvig[i],' ');\n } kol0[0]:=0;kol_0[0]:=1;\n for i:=1 to kol do\n begin\n p:=n;\n kol0[i]:=((p-1)*kol_0[i-1]) mod modul;\n kol_0[i]:=((p-2)*kol_0[i-1]+kol0[i-1]) mod modul;\n end;\n p:=0;\n for i:=1 to n-1 do if sdvig[i] then inc(p);\n ot:=(p*kol_0[kol]+kol0[0]) mod modul;\n writeln(ot);\n\n 1:\n close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type double=int64;\nconst nn=1000001; modul=1000000007;\n eps=0.0000000001; nnn=2000000;\n label 1,2,3,4;\nvar kol,j1,i,kk,pp,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,step,j:longint;\np1,p,kolraz,rr,s1,mmin,imin,x0,y0,w,vp,vd,f,ii,n,ot,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\nsdvig,vrag:array [-1..100000 ] of boolean;\nx,y,gr:array[0..nn] of double;\ns:double;\nkol0,kol_0,dd:array[0..100000] of int64;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\na1,b1:array[0..200,0..200] of char;\naa:array[0..200,0..200] of boolean;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while ksss1[j] then\n begin flag:=false; {writeln('j= ',j);} end;\n sdvig[i]:=flag;\n end;\n { for i:=0 to n-1 do write(sdvig[i],' '); writeln;\n } kol0[1]:=0;kol_0[1]:=1;\n for i:=2 to kol do\n begin\n p:=n;\n kol0[i]:=((p-1)*kol_0[i-1]) mod modul;\n kol_0[i]:=((p-2)*kol_0[i-1]+kol0[i-1]) mod modul;\n end;\n { for i:=1 to kol do writeln(i,' ',kol0[i]:7,' ',kol_0[i]);\n writeln(kol0[kol],' == ',kol_0[kol]);\n } p:=0;\n for i:=1 to n-1 do if sdvig[i] then inc(p);\n if sdvig[0] then p1:=1 else p1:=0;\n ot:=(p*kol_0[kol]+p1*kol0[kol]) mod modul;\n writeln(ot);\n\n 1:\n close(output);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n s1,s2:String;\n pref,suf:Array[0..3000] of String;\n i,md:Integer;\n k,t,r,r1,r2,ans,n:Int64;\nBegin\n md:=1000000007;\n ReadLn(s1);\n ReadLn(s2);\n Read(k);\n If k=0 Then Begin\n If s1=s2 Then Write(1)\n Else Write(0);\n End;\n r1:=0;\n r2:=0;\n n:=length(s1);\n pref[1]:=s1[1];\n For i:=2 To n Do pref[i]:=pref[i-1]+s1[i];\n suf[n]:=s1[n];\n For i:=n-1 DownTo 1 Do suf[i]:=s1[i]+suf[i+1];\n If s1=s2 Then r1:=1;\n For i:=2 To n Do\n If suf[i]+pref[i-1]=s2 Then r2:=r2+1;\n If k=1 Then Begin\n Write(r2);\n Halt;\n End;\n t:=1;\n r:=1;\n For i:=1 To k Do Begin\n t:=(md+r-t) mod md;\n r:=(r*(n-1)) mod md;\n End;\n ans:=t*r1 mod md;\n t:=0;\n r:=1;\n For i:=1 To k Do Begin\n t:=(md+r-t) mod md;\n r:=(r*(n-1)) mod md;\n End;\n ans:=(ans+t*r2) mod md;\n Write(ans);\nEnd."}, {"source_code": "program cf176b;\nconst mo=1000000007;\nvar\n n,m,i,j,kk:longint;\n jz:array[0..3000]of int64;\n s1,s2:array[0..3000]of char;\n f0,h1,h2,f1:array[0..200000]of int64;\n ct0,ct1:int64;\n ans:int64;\nbegin\n jz[0]:=1;\n for i:=1 to 3000 do jz[i]:=jz[i-1]*29;\n\n n:=0;\n while not(eoln) do begin\n inc(n);\n read(s1[n]);\n end;\n readln;\n m:=0;\n while not(eoln) do begin\n inc(m);\n read(s2[m]);\n end; readln;\n if n<>m then begin\n writeln(0);\n halt;\n end;\n\n for i:=m+1 to 2*m do s2[i]:=s2[i-m];\n\n\n h2[0]:=0;\n for i:=1 to 2*m do h2[i]:=(h2[i-1]*29+(ord(s2[i])-ord('a')+1) );\n h1[0]:=0;\n for i:=1 to n do h1[i]:=(h1[i-1]*29+(ord(s1[i])-ord('a')+1) );\n if h2[m]=h1[n] then ct0:=1 else ct0:=0;\n\n ct1:=0;\n for i:=m+1 to 2*m-1 do\n if h2[i]-(h2[i-m]*jz[m])=h1[m] then inc(ct1);\n\n\n f0[0]:=1;\n f1[0]:=0;\n readln(kk);\n for i:=1 to kk do begin\n f0[i]:=f1[i-1]*(n-1) mod mo;\n f1[i]:=f0[i-1];\n end;\n\n if ct0=1 then ans:=f0[kk] else ans:=0;\n ans:=((ans+f1[kk]*ct1)mod mo);\n writeln(ans);\nend.\n"}, {"source_code": "program cf176b;\nconst mo=1000000007;\nvar\n n,m,i,j,kk:longint;\n jz:array[0..3000]of int64;\n s1,s2:array[0..3000]of char;\n f0,h1,h2,f1:array[0..200000]of int64;\n ct0,ct1:int64;\n ans:int64;\nbegin\n jz[0]:=1;\n for i:=1 to 7 do jz[i]:=jz[i-1]*29;\n\n n:=0;\n while not(eoln) do begin\n inc(n);\n read(s1[n]);\n end;\n readln;\n m:=0;\n while not(eoln) do begin\n inc(m);\n read(s2[m]);\n end; readln;\n if n<>m then begin\n writeln(0);\n halt;\n end;\n\n for i:=m+1 to 2*m do s2[i]:=s2[i-m];\n\n\n h2[0]:=0;\n for i:=1 to 2*m do h2[i]:=(h2[i-1]*29+(ord(s2[i])-ord('a')+1) );\n h1[0]:=0;\n for i:=1 to n do h1[i]:=(h1[i-1]*29+(ord(s1[i])-ord('a')+1) );\n if h2[m]=h1[n] then ct0:=1 else ct0:=0;\n\n ct1:=0;\n for i:=m+1 to 2*m-1 do\n if h2[i]-(h2[i-m]*jz[m])=h1[m] then inc(ct1);\n\n\n f0[0]:=1;\n f1[0]:=0;\n readln(kk);\n for i:=1 to kk do begin\n f0[i]:=f1[i-1]*(n-1) mod mo;\n f1[i]:=f0[i-1];\n end;\n\n if ct0=1 then ans:=f0[kk] else ans:=0;\n ans:=((ans+f1[kk]*ct1)mod mo);\n writeln(ans);\nend.\n"}, {"source_code": "program cf176b;\nconst mo=1000000007;\nvar\n n,m,i,j,kk:longint;\n jz:array[0..3000]of int64;\n s1,s2:array[0..3000]of char;\n f0,h1,h2,f1:array[0..200000]of int64;\n ct0,ct1:int64;\n ans:int64;\nbegin\n jz[0]:=1;\n for i:=1 to 7 do jz[i]:=jz[i-1]*29;\n\n n:=0;\n while not(eoln) do begin\n inc(n);\n read(s1[n]);\n end;\n readln;\n m:=0;\n while not(eoln) do begin\n inc(m);\n read(s2[m]);\n end; readln;\n if n<>m then begin\n writeln(0);\n halt;\n end;\n\n for i:=m+1 to 2*m do s2[i]:=s2[i-m];\n\n\n h2[0]:=0;\n for i:=1 to 2*m do h2[i]:=(h2[i-1]*29+(ord(s2[i])-ord('a')+1) );\n h1[0]:=0;\n for i:=1 to n do h1[i]:=(h1[i-1]*29+(ord(s1[i])-ord('a')+1) );\n if h2[m]=h1[n] then ct0:=1 else ct0:=0;\n\n ct1:=0;\n for i:=m+1 to 2*m-1 do\n if h2[i]-(h2[i-m]*jz[m])=h1[m] then inc(ct1);\n\n\n f0[0]:=1;\n f1[0]:=0;\n readln(kk);\n for i:=1 to kk do begin\n f0[i]:=f1[i-1]*(n-1) mod mo;\n f1[i]:=f0[i-1];\n end;\n\n if ct0=1 then ans:=f0[kk] else ans:=0;\n ans:=(ans+f1[kk]*ct1);\n writeln(ans);\nend.\n"}, {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 1000;\n base= 1000000007;\n\nvar\n s, t: ansistring;\n id: array[1.. maxN] of integer;\n a: array[1.. maxN] of ansistring;\n i, j, m, n, k: integer;\n res: int64;\n\nprocedure sort(l, h: integer);\nvar\n i, j, p: integer;\nbegin\n if l>= h then exit;\n i:= random(h- l+ 1)+ l;\n p:= id[i];\n id[i]:= id[l];\n i:= l; j:= h;\n repeat\n while (i< j) and (a[id[j]]> a[p]) do dec(j);\n if i< j then\n begin\n id[i]:= id[j];\n inc(i);\n end else break;\n while (i< j) and (a[id[i]]< a[p]) do inc(i);\n if i< j then\n begin\n id[j]:= id[i];\n dec(j);\n end else break;\n until i= j;\n id[i]:= p;\n sort(l, i- 1);\n sort(i+ 1, h);\nend;\n\nbegin\n// assign(input, 'text.inp'); reset(input);\n\n readln(s);\n readln(t);\n readln(k);\n\n n:= length(s);\n for i:= 1 to n do\n begin\n a[i]:= s;\n s:= s+ s[1];\n delete(s, 1, 1);\n end;\n for i:= 1 to n do id[i]:= i;\n sort(1, n);\n m:= 0;\n for i:= 1 to n do if t= a[id[i]] then\n begin\n j:= i;\n while (j<= n) and (t= a[id[j]]) do inc(j);\n m:= j- i;\n break;\n end;\n if m= 0 then\n begin\n writeln(0);\n halt;\n end;\n res:= 1;\n for i:= 1 to k- 2 do res:= res* (n- 1) mod base;\n if k> 1 then\n begin\n if (k= 2) and (s= t) then res:= res* (n- 1) mod base else\n res:= res* (n- 2) mod base;\n end;\n if s<> t then res:= res* m mod base else\n if (k= 1) then res:= res* (m- 1) mod base;\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n{$M 20000000}\n{$H+}\n\n\nconst\n maxN= 100000;\n base= round(1e9)+ 7;\n\nvar\n f, g: array[0.. maxn] of int64;\n i, j, k, n, d: integer;\n res: int64;\n s, t, x: string;\n\nbegin\n /// assign(input, 'test.inp'); reset(input);\n\n readln(s);\n readln(t);\n n:= length(t);\n readln(k);\n x:= s;\n for i:= 2 to n do\n begin\n x:= x+ x[1];\n delete(x, 1, 1);\n if x= t then inc(d);\n end;\n g[0]:= 1;\n f[1]:= 1;\n g[1]:= 0;\n for i:= 2 to k do\n begin\n f[i]:= ( (n- 2)* f[i- 1]+ (n- 1)* g[i- 1]) mod base;\n g[i]:= f[i- 1]* (n- 1) mod base;\n end;\n res:= f[k]* d mod base;\n if s= t then res:= (res+ g[k]) mod base;\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n{$M 20000000}\n{$H+}\n\n\nconst\n maxN= 100000;\n base= round(1e9)+ 7;\n\nvar\n f, g: array[1.. maxn] of int64;\n i, j, k, n, d: integer;\n res: int64;\n s, t, x: string;\n\nbegin\n /// assign(input, 'test.inp'); reset(input);\n\n readln(s);\n readln(t);\n n:= length(t);\n readln(k);\n x:= s;\n for i:= 2 to n do\n begin\n x:= x+ x[1];\n delete(x, 1, 1);\n if x= t then inc(d);\n end;\n f[1]:= 1;\n g[1]:= 0;\n for i:= 2 to k do\n begin\n f[i]:= ( (n- 2)* f[i- 1]+ (n- 1)* g[i- 1]) mod base;\n g[i]:= f[i- 1]* (n- 1) mod base;\n end;\n res:= f[k]* d mod base;\n if s= t then res:= (res+ g[k]) mod base;\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n{$M 20000000}\n{$H+}\n\n\nconst\n maxN= 100000;\n base= round(1e9)+ 7;\n\nvar\n f, g: array[0.. maxn] of int64;\n i, j, k, n, d: integer;\n res: int64;\n s, t, x: string;\n\nbegin\n /// assign(input, 'test.inp'); reset(input);\n\n readln(s);\n readln(t);\n n:= length(t);\n readln(k);\n x:= s;\n for i:= 2 to n do\n begin\n x:= x+ x[1];\n delete(x, 1, 1);\n if x= t then inc(d);\n end;\n f[1]:= 1;\n g[1]:= 0;\n for i:= 2 to k do\n begin\n f[i]:= ( (n- 2)* f[i- 1]+ (n- 1)* g[i- 1]) mod base;\n g[i]:= f[i- 1]* (n- 1) mod base;\n end;\n res:= f[k]* d mod base;\n if s= t then res:= (res+ g[k]) mod base;\n writeln(res);\nend."}, {"source_code": "var i,j,n,m,k,answer:longint;\n s1,s2:ansistring;\n begin\n readln(s1);\n readln(s2);\n readln(k);\n\n if k=0 then\n begin\n if s1=s2 then writeln(1)\n else writeln(0);\n halt(0);\n end;\n\n if k>1 then\n begin\n if s1=s2 then answer:=1;\n end;\n\n for i:=1 to length(s1)-1 do\n begin\n s1:=s1[length(s1)]+s1;\n delete(s1,length(s1),1);\n if s1=s2 then\n begin\n if length(s1)=2 then\n begin\n if k mod 2=1 then answer:=answer+1;\n end\n else\n answer:=answer+1;\n end;\n end;\n\n writeln(answer);\n end."}, {"source_code": "const\n{ fi='word.inp';\n fo='word.out';}\n fi='';\n fo='';\n inf=round(1e9)+7;\n maxk=100010;\n\nvar\n ff:text;\n a,b:ansistring;\n vt,k,i:longint;\n f,g:array[0..maxk]of int64;\n n,s:int64;\n ok:boolean;\n ch:char;\n\nbegin\n assign(ff,fi); reset(ff);\n readln(ff,a);\n readln(ff,b);\n n:=length(a);\n readln(ff,k);\n close(ff);\n\n ok:=false; s:=0;\n vt:=0;\n if a=b then vt:=1;\n for i:=1 to n do\n begin\n if a=b then\n begin\n ok:=true;\n inc(s);\n end;\n ch:=b[1];\n delete(b,1,1);\n b:=b+ch;\n end;\n\n assign(ff,fo); rewrite(ff);\n if s=0 then writeln(ff,0)\n else\n begin\n f[1]:=s-vt; g[1]:=n-1-s+vt;\n for i:=2 to k do\n begin\n f[i]:=(g[i-1]*s+f[i-1]*(s-1))mod inf;\n g[i]:=(f[i-1]*(n-s)+g[i-1]*(n-s-1)) mod inf;\n end;\n writeln(ff,f[k]);\n end;\n close(ff);\nend.\n"}, {"source_code": "const\n mo=1000000000+7;\nvar\n sum:array[0..100000]of int64;\n t:array[0..1000]of boolean;\n f:array[0..1000]of int64;\n ans:int64;\n a,b,st,en:ansistring;\n n,k,i:longint;\n found:boolean;\n\nbegin\n readln(st);\n readln(en);\n n:=length(st);\n readln(k);\n for i:=0 to n-1 do\n begin\n found:=true;\n if i>0 then\n begin\n a:=copy(st,1,i);\n b:=copy(en,n-i+1,i);\n if a<>b then found:=false;\n end;\n if i<(n-1) then\n begin\n a:=copy(st,i+1,(n-i));\n b:=copy(en,1,(n-i));\n if a<>b then found:=false;\n end;\n t[i]:=found;\n end;\n sum[1]:=n-1;\n for i:=2 to k do\n sum[i]:=(sum[i-1]*int64(n-1)) mod mo;\n ans:=0;\n for i:=1 to k-1 do\n ans:=(sum[i]+mo-ans)mod mo;\n if k mod 2=0 then\n begin\n for i:=1 to n-1 do\n f[i]:=(ans+mo-1)mod mo;\n f[0]:=ans;\n end\nelse\n begin\n for i:=1 to n-1 do\n f[i]:=(ans+mo+1)mod mo;\n f[0]:=ans;\n end;\n ans:=0;\n for i:=0 to n-1 do\n if t[i] then ans:=(ans+f[i]) mod mo;\n writeln(ans);\nend.\n"}], "src_uid": "414000abf4345f08ede20798de29b9d4"} {"source_code": "const //fi = 'd:\\Dac\\CF\\653B.inp';\n fi = '';\n\nvar a: array[1..36] of string[2];\n b: array[1..36] of char;\n cach: char;\n n, q, i, res: longint;\n f: text;\n\nprocedure tinh(i: longint; kt: char);\nvar j: longint;\nbegin\n if i = n then begin res:= res + 1; exit; end;\n for j:= 1 to q do\n if b[j] = kt then\n begin\n tinh(i + 1, a[j, 1]);\n end;\nend;\n\nbegin\n assign(f, fi); reset(f);\n readln(f, n, q);\n for i:= 1 to q do\n readln(f, a[i], cach, b[i]);\n close(f);\n\n res:= 0;\n tinh(1, 'a');\n\n writeln(res);\n readln;\nend.", "positive_code": [{"source_code": "Const Finp='';\n Fout='';\n maxCase=46656;\nVar n:longint;\n change:array['a'..'f','a'..'f'] of string;\n hd:array[1..maxcase] of string;\n\nProcedure Nhap;\nVar f:Text;\n i,q:longint;\n a,b,s:string;\nBegin\n assign(f,finp); reset(f);\n readln(f,n,q);\n for i:=1 to q do\n begin\n readln(f,s);\n a:=s[1]+s[2]; b:=s[4];\n if (a[1]<='f') or (a[2]<='f') or (b<='f') then\n change[a[1],a[2]]:=b;\n end;\n close(f);\nEnd;\nFunction DecToSen(x:longint):string;\nVar s:string;\nBegin\n s:='';\n while x>0 do\n begin\n s:=chr((x mod 6)+97)+s;\n x:=x div 6;\n end;\n dectosen:=s;\nEnd;\nFunction Check(s:string):boolean;\nBegin\n while length(s)>1 do\n begin\n if change[s[1],s[2]]='' then\n exit(false);\n s:=change[s[1],s[2]]+s;\n delete(s,2,2);\n end;\n if s='a' then\n exit(true)\n else\n exit(false);\nEnd;\nFunction Dem:longint;\nVar i,d:longint;\n s:string;\nBegin\n d:=0;\n for i:=0 to maxcase do\n begin\n s:=dectosen(i);\n if length(s)>n then\n break;\n while length(s)1) do\nbegin\nflag:=false;\n for i:=1 to m do\n if (A[i][1]=s[1]) and (A[i][2]=s[2]) then begin\n s[2]:=A[i][4];\n delete(s,1,1);\n flag:=true;\n break;\n end;\nend;\nif s='a' then canBuild:=true else canBuild:=false;\nend;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(n,m);\n\nfor i:=1 to m do\nreadln(A[i]);\n\nfor i:=1 to n do\ns:=s+'a';\n\nfor i1:=1 to 6 do\nbegin\ns[1]:=chr(96+i1);\n for i2:=1 to 6 do\n begin\n s[2]:=chr(96+i2);\n if n=2 then if canBuild(s) then inc(ansv);\n for i3:=1 to 6 do\n begin\n if n<3 then break;\n s[3]:=chr(96+i3);\n if n=3 then if canBuild(s) then inc(ansv);\n for i4:=1 to 6 do\n begin\n if n<4 then break;\n s[4]:=chr(96+i4);\n if n=4 then if canBuild(s) then inc(ansv);\n for i5:=1 to 6 do\n begin\n if n<5 then break;\n s[5]:=chr(96+i5);\n if n=5 then if canBuild(s) then inc(ansv);\n for i6:=1 to 6 do\n begin\n if n<6 then break;\n s[6]:=chr(96+i6);\n if n=6 then if canBuild(s) then inc(ansv);\n end;\n end;\n end;\n end;\n end;\nend;\n\nwriteln(ansv);\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "var\na,b:array[1..50000] of string;\np,q:array[1..40] of string;\nt:array[1..10] of longint;\ns,s1:string;\nn,l,i,j,j1:longint;\nbegin\nread(n); readln(l);\nt[1]:=1;\nb[1]:='a';\nfor i:=1 to l do\nbegin\nreadln(s);\np[i]:=copy(s,1,2);\nq[i]:=copy(s,4,1);\nend;\nfor i:=1 to n-1 do\nbegin\n for j:=1 to t[i] do\n for j1:=1 to l do\n begin\n s:=b[j];\n if(s=q[j1]) then\n begin\n inc(t[i+1]);\n s1:=p[j1];\n a[t[i+1]]:=s1[1];\n end;\n end;\nfor j:=1 to t[i] do b[j]:='';\nfor j:=1 to t[i+1] do b[j]:=a[j];\nend;\nwriteln(t[n]);\nend."}, {"source_code": "VAR A:ARRAY[0..40]OF string;N,i,k:longint;z,y,x:array['a'..'f']of int64;\nc:array['a'..'f','a'..'f']of int64;q,w:char;t:int64;\nbegin\n readln(n,k);\n for i:=1 to k do \n begin\n readln(a[i]);\n \n inc(c[a[i][4],a[i][1]]);\n end;\n x['a']:=1;\n for i:=1 to n-1 do\n begin\n for q:='a' to 'f' do\n for w:='a' to 'f' do\n y[q]:=y[q]+c[w,q]*x[w];\n x:=y;y:=z;\n end;\n t:=0;\n for q:='a' to 'f' do\n t:=t+x[q];\n write(t);\nend."}, {"source_code": "var s,s1:string;\n way:array[1..8,1..37]of string;\n num:array[1..8]of longint;\n get:array[1..500000]of string;\n ans,m,n,i,a,tot:longint;\n\nprocedure dfs(s:string);\nvar s1,s2:string;\n i,j:longint;\nbegin\n s1:=s;\n if length(s)=n then begin\n inc(tot);\n get[tot]:=s;\n exit;\n end;\n for i:=1 to 1 do begin\n for j:=1 to num[ord(s[i])-96] do begin\n s2:=way[ord(s[i])-96,j];\n delete(s1,i,1);\n insert(s2,s1,i);\n dfs(s1);\n s1:=s;\n end;\n end;\nend;\n\nprocedure qsort(l,r:longint);\nvar i,j:longint;\n mid,t:string;\nbegin\n i:=l;\n j:=r;\n mid:=get[(i+j)div 2];\n repeat\n while get[i]mid do dec(j);\n if i<=j then begin\n t:=get[i];\n get[i]:=get[j];\n get[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n if i1 then qsort(1,tot);\n if tot>0 then ans:=1;\n for i:=2 to tot do if get[i]<>get[i-1] then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "var\n i,j,m,n,x,y,s,t,k,h,p,tot:longint;\n s1,s2,s3:string;\n t1,t2:array[1..100] of string;\n vis,ans:array[0..1000000] of longint;\n q:array[0..1000000] of longint;\nbegin\n readln(n,m);\n for i:=1 to m do\n begin\n readln(s1);\n for j:=1 to length(s1) do\n if (s1[j]=' ') then break;\n s2:=copy(s1,1,j-1);\n t1[i]:=s2;\n s2:=copy(s1,j+1,1);\n t2[i]:=s2;\n end;\n h:=0; t:=1;\n q[1]:=1; vis[1]:=1; ans[1]:=1;\n while (h=n) then break;\n s3:='';\n while (x>=0) do\n begin\n k:=x mod 7;\n s3:=chr(k+96)+s3;\n x:=x div 7;\n if x=0 then break;\n end;\n for i:=1 to m do\n if (s3[1]=t2[i]) then\n begin\n s2:=t1[i];\n s1:=s3;\n delete(s1,1,1);\n s2:=s2+s1;\n x:=0; p:=1;\n for k:=length(s2) downto 1 do\n begin\n x:=x+p*(ord(s2[k])-96);\n p:=p*7;\n end;\n if (vis[x]=0) then\n begin\n vis[x]:=1;\n inc(t);\n ans[t]:=ans[h]+1;\n q[t]:=x;\n end;\n end;\n end;\n for i:=1 to t do\n if ans[i]=n then inc(tot);\n writeln(tot);\nend.\n"}, {"source_code": "Program GIO;\n\nvar a,b:array[1..36]of char;\nc:array[0..500000]of char;\ni,q,qq,n,j,k,f,t:longint;\ns:string;\nbegin\n\nreadln(q,n);\n\nfor i:=1 to n do\nbegin\nreadln(s);\nb[i]:=s[1];\na[i]:=s[4];\nend;\n\n\nf:=1;\nt:=1;\nc[1]:='a';\n\nfor i:=1 to q-1 do\nbegin\nqq:=0;\nfor k:=f to t do\nfor j:=1 to n do\nif (c[k]=a[j]) then begin qq:=qq+1; c[t+qq]:=b[j] end;\nf:=t+1; t:=t+qq;\nend;\n\nwriteln(qq);\n\nend."}, {"source_code": "const fin='';\n fout='';\ntype weird=record\n c,s1,s2:char;\nend;\nvar b:array[1..36] of weird;\n n,q:longint;\n f,g:text;\nprocedure readdata;\nvar i,j:longint;\n t:char;\n x:weird;\nbegin\n readln(f,n,q);\n for i:=1 to q do\n begin\n readln(f,b[i].s1,b[i].s2,t,b[i].c);\n for j:=1 to i-1 do\n if b[i].c1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=5 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n for j4:='a' to 'f' do\n for j5:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2+j3+j4+j5;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=4 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n for j4:='a' to 'f' do\n begin\n s:=''; pr:=0;\n s:=j1+j2+j3+j4;\n i:=1;\n while(length(s)>1)do\n begin\n\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n\n\n end;\n if s='a'then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=3 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2+j3;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);\n s:=a[ss[i],ss[i+1]]+s;end else break;\n pr:=1;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=2 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\n\n\nend.\n\n"}, {"source_code": "var a,c:array[1..36] of byte;\nn,i,q:byte;\nk:integer;\nx1,x2,x3,x4:char;\nprocedure dfs(x,y:byte);\nvar j:byte;\nbegin\n for j:=1 to q do\n if c[j]=x then\n if y=n then inc(k) else dfs(a[j],y+1);\nend;\nbegin\nreadln (n,q);\nk:=0;\n for i:=1 to q do\n begin\n read(x1,x2,x3,x4);readln;\n a[i]:=ord(x1)-ord('a')+1;\n c[i]:=ord(x4)-ord('a')+1;\n end;\n dfs(1,2);\n writeln(k);\n end.\n"}, {"source_code": "var a,c:array[1..36] of byte;\nn,i,q:byte;\nk:integer;\ns:string;\nprocedure dfs(x,y:byte);\nvar j:byte;\nbegin\n for j:=1 to q do\n if c[j]=x then\n if y=n then inc(k) else dfs(a[j],y+1);\nend;\nbegin\nreadln (n,q);\nk:=0;\n for i:=1 to q do\n begin\n readln(s);\n a[i]:=ord(s[1])-ord('a')+1;\n c[i]:=ord(s[4])-ord('a')+1;\n end;\n dfs(1,2);\n writeln(k);\n end.\n"}, {"source_code": "var a,b,c:array[1..40] of longint;\ns:string;\nn,i,k,q:longint;\nprocedure dfs(x,y:longint);\nvar j:longint;\nbegin\n for j:=1 to q do\n if c[j]=x then\n if y=n then inc(k) else dfs(a[j],y+1);\nend;\nbegin\nreadln (n,q);\nk:=0;\n for i:=1 to q do\n begin\n readln(s);\n a[i]:=ord(s[1])-ord('a')+1;\n b[i]:=ord(s[2])-ord('a')+1;\n c[i]:=ord(s[4])-ord('a')+1;\n end;\n dfs(1,2);\n writeln(k);\n end.\n"}, {"source_code": "program cf653B;\nvar n,q,k,j,br,i,i2,i3:longint;\n a:array[0..100000] of longint;\n a2,b,c,d,s:array[0..100000] of char;\n zam:boolean;\nbegin\nreadln(n,q);\nk:=1;\nfor i:=1 to n do\n k:=k*6;\nfor i:=1 to q do\n begin\n read(b[i],c[i],d[i],d[i]);\n readln;\n end;\n\ns[0]:='a';\ns[1]:='b';\ns[2]:='c';\ns[3]:='d';\ns[4]:='e';\ns[5]:='f';\n\nbr:=0;\n\nfor i:=1 to k do\n begin\n inc(a[n]);\n j:=n;\n while a[j]=6 do\n begin\n a[j]:=0;\n dec(j);\n inc(a[j]);\n end;\n\n for i2:=1 to n do\n a2[i2]:=s[a[i2]];\n\n for i2:=1 to n-1 do\n begin\n zam:=false;\n for i3:=1 to q do\n if (a2[i2]=b[i3]) and (a2[i2+1]=c[i3]) then\n begin\n a2[i2+1]:=d[i3];\n zam:=true;\n break;\n end;\n if zam=false then\n break;\n end;\n\n if zam and (a2[n]='a') then\n inc(br);\n end;\n\nwriteln(br);\nend."}, {"source_code": "var\n n,q,i,j,sum:longint;\n s:string;\n froms,tos:array[1..100] of longint;\n f:array[1..10,1..10] of longint;\nbegin\n readln(n,q);\n for i:=1 to q do\n begin\n readln(s);\n froms[i]:=ord(s[4])-ord('a')+1;\n tos[i]:=ord(s[1])-ord('a')+1;\n end;\n f[1,1]:=1;\n for i:=2 to n do\n for j:=1 to q do\n f[i,tos[j]]:=f[i,tos[j]]+f[i-1,froms[j]];\n for i:=1 to 6 do sum:=sum+f[n,i];\n writeln(sum);\nend.\n"}, {"source_code": "var q,i,sz,m,n,ans:longint;\n s:string;\n a,b,c:array[0..1000] of longint;\n\nprocedure rek(m,sz:longint);\nvar i:longint;\n begin\n\n if sz=n then\n begin\n inc(ans);\n end\n else begin\n for i:=1 to q do\n if m mod 10=c[i] then\n begin\n inc(sz);\n rek((m-m mod 10+b[i])*10+a[i],sz);\n\n dec(sz);\n end;\n end;\nend;\n begin\n readln(n,q);\n\n for i:=1 to q do\n begin\n readln(s);\n a[i]:=ord(s[1])-96;\n b[i]:=ord(s[2])-96;\n c[i]:=ord(s[4])-96;\n end;\n\n m:=1;\n rek(m,1);\n\nwriteln(ans);\n end.\n"}, {"source_code": "const\tfi\t=\t'B.inp';\n\tfo\t=\t'B.out';\n\tmaxN\t=\t1000000;\ntype\tint\t=\tlongint;\n\txau\t=\tstring[6];\nvar\tn,q\t:\tint;\n\ta,b\t:\tarray[1..36]\tof\txau;\n\tqu \t:\tarray[1..maxN]\tof\txau;\n\tf \t:\tarray[1..maxN]\tof\tboolean;\n{}\nfunction mahoa(s: xau) : int;\nvar n,i,m : int;\nbegin\n\tn := length(s);\n\tm := 0;\n\tfor i:=1 to n do\n\t begin\n\t\tm := m*10 + ord(s[i]) - 96;\n\t end;\n\tmahoa := m;\n\t//writeln(s, ' ', m);\nend;\n{}\nprocedure xl;\nvar l,r,i,p,m : int; x,s: xau;\nbegin\n\tl:=1; r :=0;\n\tfillchar(f,sizeof(f),true);\n\tfor i:=1 to q do if b[i]='a' then\n\t begin\n\t\tinc(r); qu[r] := a[i]; f[mahoa(a[i])] := false;\n\t end;\n\twhile l<=r do\n\t begin\n\t\tx := qu[l]; if length(x)=n then break; inc(l);\n\t\tfor i:=1 to q do\n\t\t begin\n\t\t p := pos(b[i],x);\n\t\t\tif p=1 then\n\t\t\t begin\n s := x;\n delete(s,p,1);\n\t\t\t\tinsert(a[i],s,p);\n\t\t\t\tm := mahoa(s);\n\t\t\t\tif f[m] then begin\n\t\t\t\tinc(r); qu[r] := s;\n\t\t\t\tf[m] := false; end;\n\t\t\t end;\n\t\t end;\n\t end;\n\twriteln(r-l+1);\nend;\n{}\nprocedure docdl;\nvar i: int; s:string;\nbegin\n\treadln(n,q);\n\tfor i:=1 to q do\n\t begin\n\t\treadln(s);\n\t\ta[i]:= copy(s,1,2);\n\t\tb[i]:= copy(s,4,1);\n\t end;\n\t//for i:=1 to q do writeln(a[i],' ',b[i]);\nend;\n{}\nBEGIN\n\t//assign(input,fi);\treset(input);\n\t//assign(output,fo);\trewrite(output);\n\tdocdl;\n\txl;\n\t//close(input);\tclose(output);\nEND.\t\n"}, {"source_code": "var\n n,q,i,j,sum:longint;\n s:string;\n froms,tos:array[1..100] of longint;\n f:array[1..10,1..10] of longint;\nbegin\n readln(n,q);\n for i:=1 to q do\n begin\n readln(s);\n froms[i]:=ord(s[4])-ord('a')+1;\n tos[i]:=ord(s[1])-ord('a')+1;\n end;\n f[1,1]:=1;\n for i:=2 to n do\n for j:=1 to q do\n f[i,tos[j]]:=f[i,tos[j]]+f[i-1,froms[j]];\n for i:=1 to 6 do sum:=sum+f[n,i];\n writeln(sum);\nend."}, {"source_code": "var\n res:int64;\n a:array[1..36] of string[2];\n b:array[1..36] of string[1];\n n, i, q, len:byte;\n s:string;\n\nFunction f(s:string):int64;\nvar\n i:byte;\n res:int64;\nBegin\n if length(s)=n then begin\n res:=1 ;\n // writeln(s);\n end\n else begin\n res:=0;\n for i:=1 to q do\n if s[1]=b[i] then\n res:=res + f(a[i]+copy(s, 2, length(s)-1));\n end;\n\n f:=res;\nEnd;\n\n\nBEGIN\n readln(n, q);\n for i:=1 to q do begin\n readln(s);\n a[i]:=copy(s, 1, 2);\n b[i]:=copy(s, 4, 1);\n end;\n\n res:=0;\n res:=f('a');\n\n write(res);\n\nEND."}, {"source_code": "\n\n var\n\n cnt,i,n,q:longint;\n\n s,a,b:array[1..100] of ansistring;\n\n used:array[1..1000] of char;\n\n subs:ansistring;\n\n g:boolean;\n\n\n\n procedure check;\n\n begin\n\n subs:='';\n\n for i:=1 to n do subs:=subs+used[i];\n\n while length(subs)>1 do begin\n\n g:=false;\n\n for i:=1 to q do\n\n if (subs[1]=a[i][1]) and (subs[2]=a[i][2]) then begin delete(subs,1,2); subs:=b[i]+subs; g:=true; break; end;\n\n if g=false then exit;\n\n end;\n\n if (length(subs)=1) and (subs='a') then begin inc(cnt); exit; end;\n\n\n end;\n\n procedure pereb(step:longint);\n\n begin\n\n if step>n then begin check; exit; end;\n\n used[step]:='a';\n\n pereb(step+1);\n\n used[step]:='b';\n\n pereb(step+1);\n\n used[step]:='c';\n\n pereb(step+1);\n\n used[step]:='d';\n\n pereb(step+1);\n\n used[step]:='e';\n\n pereb(step+1);\n\n used[step]:='f';\n\n pereb(step+1);\n\n end;\n\n\n begin\n readln(n,q);\n for i:=1 to q do readln(s[i]);\n\n for i:=1 to q do begin\n\n a[i]:=copy(s[i],1,2);\n\n b[i]:=copy(s[i],4,1);\n\n end;\n\n pereb(1);\n\n write(cnt);\n\n end.\n\n"}, {"source_code": "var\na:array['a'..'f','a'..'f'] of longint;\nf:array[1..6,'a'..'f'] of int64;\nall:array[1..6] of int64;\ni,j,p,t:char;\nk,n,len:longint;\ni1,i2:longint;\nans:int64;\n s:string;\nbegin\n\nfor i:='a' to 'f' do\nfor j:='a' to 'f' do\na[i,j]:=0;\n\nfor i1:=1 to 6 do\nfor i:='a' to 'f' do\nf[i1,i]:=0;\n\nreadln(len,n);\nfor k:=1 to n do\n begin\n readln(s);\n p:=s[1];\n t:=s[4];\n inc(a[t,p]);\n end;\n {\n for i:='a' to 'f' do\n begin\n for j:='a' to 'f' do\n write(a[i,j],' ');\n writeln;\n end;\n }\nall[2]:=a['a','a']+a['a','b']+a['a','c']+a['a','d']+a['a','e']+a['a','f'];\n//writeln(all[2]);\nfor i:='a' to 'f' do\nbegin\nf[2,i]:=a['a',i];\n//write(f[2,i],' ');\nend;\n for i1:=2 to len-1 do\n begin\n for i:='a' to 'f' do\n begin\n for j:='a' to 'f' do\n f[i1+1,j]:=f[i1+1,j]+f[i1,i]*a[i,j];\n end;\n end;\n {\n writeln;\n for i1:=2 to len do\n begin\n for j:='a' to 'f' do\n write(f[i1,j],' ');\n writeln;\n end;\n }\nans:=0;\nfor i:='a' to 'f' do\nans:=ans+f[len,i];\nwriteln(ans);\nend.\n"}, {"source_code": "var\n n,m,he,ta,i,j,k,ans:longint;\n s:ansistring;\n q,a,b:array[0..2000000] of ansistring;\n o:array[0..2000000] of boolean;\n\nfunction hash(s:ansistring):longint;\nvar\n t,p,i:longint;\nbegin\n p:=1;\n t:=0;\n for i:=length(s) downto 1 do\n begin\n t:=t+p*(ord(s[i])-ord('a')+1);\n p:=p*7\n end;\n exit(t)\nend;\n\nprocedure bfs;\nvar\n i,j:longint;\n u:ansistring;\nbegin\n q[1]:='a';\n o[1]:=true;\n he:=0;\n ta:=1;\n while he 1 ) do\n begin\n f := false;\n for i := 1 to q do\n begin\n if ( z[1] + z[2] = A[i] ) then\n begin\n Delete ( z , 1 , 1 ) ; \n z[1] := B[i];\n f := true;\n break;\n end;\n \n end;\n \n if ( f = false ) then\n exit();\n \n \n end;\n \n if ( z = 'a' ) then\n inc ( ans ) ; \n \n end;\n \n procedure Brute ( v : LongInt ; c : char ) ;\n begin\n br[v] := c;\n if ( v = n ) then\n Check ()\n else\n Brute ( v + 1 , 'a' ) ; \n\n if ( c <> 'f' ) then\n Brute ( v , Chr(Ord(c) + 1 ) ) ; \n end;\n \n \n var i : LonGInt;\n s : String;\nbegin\n readLn ( n , q ) ; \n \n for i := 1 to q do\n begin\n \n readLn ( s ) ; \n A[i] := S[1] + S[2];\n B[i] := S[4];\n \n end;\n \n br := '';\n \n for i := 1 to N do\n br := br + ' ' ; \n \n Brute ( 1 , 'a' ) ; \n \n writeLn ( ans ) ; \n \n \nend."}, {"source_code": "type long=array[0..6,0..6,0..6,0..6,0..6,0..6] of longint;\nprocedure make(var s:String;n:longint);\nvar\ni:longint;\nbegin\ns[n]:=chr(ord(S[n])+1);\ni:=n;\nwhile(i>=2)and(s[i]='g')do begin\ns[i]:='a';\ns[i-1]:=chr(ord(s[i-1])+1);\ndec(i);\nend;\nend;\nprocedure may(s:string;var a,b,c,d,e,f:longint);\nbegin\na:=0;\nb:=0;\nc:=0;\nd:=0;\ne:=0;\nf:=ord(s[length(S)])-96;\nif length(S)>=2\nthen e:=ord(s[length(S)-1])-96;\nif length(S)>=3\nthen d:=ord(s[length(S)-2])-96;\nif length(S)>=4\nthen c:=ord(s[length(S)-3])-96;\nif length(S)>=5\nthen b:=ord(s[length(S)-4])-96;\nif length(S)>=6\nthen a:=ord(s[length(S)-5])-96;\nend;\nvar\na,b:array[1..36] of string;\nn,q,i,sum,j,k1,k2,k3,k4,k5,k6,k11,k22,k33,k44,k55,k66:longint;\ns,s1,s2:string;\ncan:long;\nbegin\nreadln(n,q);\nfor i:=1 to n-1 do\ns:=s+'a';\ns:=s+(chr(96));\nfor i:=1 to q do begin\nreadln(s1);\na[i]:=s1[1]+s1[2];\nb[i]:=s1[4];\nend;\nfor j:=n downto 2 do begin\ns:='';\nfor i:=1 to j-1 do\ns:=s+'a';\ns:=s+(chr(96));\nwhile true do begin\nmake(s,j);\nif s[1]='g'\nthen break;\nmay(s,k1,k2,k3,k4,k5,k6);\nif length(S)=n\nthen can[k1,k2,k3,k4,k5,k6]:=1;\nfor i:=1 to q do begin\ns1:=s;\nif j=2\nthen inc(sum);\nif copy(s1,1,2)=a[i]\nthen begin\ndelete(s1,1,2);\ns1:=b[i]+s1;\nmay(s1,k11,k22,k33,k44,k55,k66);\ninc(can[k11,k22,k33,k44,k55,k66],can[k1,k2,k3,k4,k5,k6]) ;\nend;\nend;\nend;\nend;\nwriteln(can[0,0,0,0,0,1]);\nend.\n\n\n\n"}, {"source_code": "var a:array['a'..'f','a'..'f']of char;\n pr,kol,i,j,n,m:longint;\n ss,s:string;\n j1,j2,j3,j4,j5,j6:char;\nbegin\n\nreadln(n,m);\nfor i:=1 to m do\nbegin\nreadln(s);\na[s[1],s[2]]:=s[4];\nend;\n\nif n=6 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n for j4:='a' to 'f' do\n for j5:='a' to 'f' do\n for j6:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2+j3+j4+j5+j6;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=5 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n for j4:='a' to 'f' do\n for j5:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2+j3+j4+j5;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=4 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n for j4:='a' to 'f' do\n begin\n s:=''; pr:=0;\n s:=j1+j2+j3+j4;\n i:=1;\n while(length(s)>1)do\n begin\n\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n\n\n end;\n if s='a'then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=3 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n for j3:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2+j3;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);\n s:=a[ss[i],ss[i+1]]+s;end else break;\n pr:=1;\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\nif n=2 then begin\nfor j1:='a' to 'f' do\n for j2:='a' to 'f' do\n begin\n s:='';\n s:=j1+j2;\n i:=1;\n while(length(s)>1)do\n begin\n if a[s[i],s[i+1]]in ['a'..'f'] then begin ss:=s;delete(s,i,2);s:=a[ss[i],ss[i+1]]+s;end else break;\n\n\n end;\n if s='a' then inc(kol);\n end;\nwriteln(kol);\nend;\n\n\nend."}, {"source_code": "var s:string; j,i,p,n,q:integer; a:array[1..2,1..36] of string; \nfunction col(m:string; z:integer):integer;\nvar t,o:integer;\n begin\n t:=0;\n if z=n then col:=1\n else \n begin\n for o:=1 to q do\n begin\n if a[2,o]=m then t:=col(a[1,o][1],z+1)+t;\n end;\n col:=t;\n end;\n end;\nbegin\nreadln(n,q);\nfor i:=1 to q do \nbegin\nreadln(s);\na[1,i]:=s[1]+s[2];\na[2,i]:=s[4];\nend;\n\nwrite(col('a',1));\nend."}, {"source_code": "var\n i,j,k,m,n,t,ans:longint;\n x,y,z,c:char;\n froms,tos:array[1..1000] of longint;\n f:array[1..100,1..100] of longint;\nbegin\n readln(n,m);\n for i:=1 to m do\n begin\n readln(x,y,c,z);\n froms[i]:=ord(z)-97+1;\n tos[i]:=ord(x)-97+1;\n end;\n f[1,1]:=1;\n for i:=2 to n do\n for j:=1 to m do\n f[i,tos[j]]:=f[i,tos[j]]+f[i-1,froms[j]];\n for i:=1 to 6 do ans:=ans+f[n,i];\n writeln(ans);\nend.\n"}, {"source_code": "\nconst\n tfi='';\n tfo='';\n\ntype TE= record\n v, link: longint; end;\n\nvar\n fi, fo: text;\n n, m: longint;\n res: int64;\n head: array[0..6] of longint;\n e: array[0..100] of TE;\n free: array[0..666666] of boolean;\n\nfunction get(s: string; i, j: longint): longint;\nvar\n tmp: string;\n k,x: longint;\nbegin\n tmp :='';\n for k:=i to j do\n begin\n x:= ord(s[k])-48;\n tmp:=tmp+char(x);\n end;\n\n val(tmp, x);\n exit(trunc(x));\nend;\n\nprocedure __;\nvar\n i: longint;\n s: string;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, n, m);\n for i:=1 to m do\n begin\n readln(fi, s);\n e[i].v := get(s,1,2);\n e[i].link := head[get(s,4,4)];\n head[get(s,4,4)] := i;\n end;\nend;\n\nfunction check(value: longint): boolean;\nvar\n tmp: string;\nbegin\n str(value, tmp);\n if length(tmp)=n then exit(true);\n exit(false);\nend;\n\nprocedure dfs(u, value: longint);\nvar\n i, x: longint;\n tmp,s1 : string;\nbegin\n if check(value) then\n begin\n inc(res); exit;\n end;\n i := head[u]; tmp := '';\n while i<>0 do\n begin\n str(value, tmp);\n str(e[i].v, s1);\n tmp := copy(tmp,2, length(tmp));\n tmp:=s1+tmp;\n val(tmp, x);\n if not free[x] then\n dfs(ord(tmp[1])-48,x );\n i := e[i].link;\n end;\nend;\n\nprocedure xuly;\nvar\n i: longint;\nbegin\n i := head[1];\n while i<>0 do\n begin\n dfs(e[i].v div 10, e[i].v);\n i := e[i].link;\n end;\n writeln(fo, res);\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n __;\n xuly;\n _;\nEND.\n"}, {"source_code": "type\n stroka = record\n a, b, c: char;\n end;\n \nvar\n a, b, c, i, o: int64;\n t: char;\n ar: array [1..1000] of stroka;\n \nprocedure gen(s1: string);\nvar\n i: int64;\n s2: string;\n \nbegin\n if length(s1) = a then begin\n inc(o);\n exit;\n end;\n if length(s1) > a then exit;\n i := 1;\n while i <= b do begin\n if s1[1] = ar[i].c then begin\n s2 := s1;\n s2[1] := ar[i].b;\n s2 := ar[i].a + s1;\n gen(s2);\n end;\n inc(i);\n end;\nend;\n \nbegin\n readln(a, b);\n i := 1;\n o := 0;\n while i <= b do begin\n readln(ar[i].a, ar[i].b, t, ar[i].c);\n inc(i);\n end;\n gen('a');\n writeln(o);\nend."}, {"source_code": "var\nn, q, kol, i: integer;\npol: int64;\ns: array[1..100] of string;\n\nprocedure res(k: integer; prev: char);\nvar\ni: integer;\nbegin\nkol:= 0;\nif k = n - 1 then\nbegin\nfor i:= 2 to q + 1 do\nif s[i][4] = prev then inc(kol);\npol:= pol + kol;\nend\nelse\nfor i:= 2 to q + 1 do\nif s[i][4] = prev then res(k + 1, s[i][1]);\nend;\n\nbegin\nread(n, q);\nfor i:= 1 to q + 1 do\nreadln(s[i]);\ns[1]:= 'a';\nres(1, 'a');\nwriteln(pol);\nend."}, {"source_code": "label 1,2;\nvar step,dloch,newdl,i1,j1,k,k1,m,i,j,n:longint; q,pos,koef,ot,t,t1,t2,tt,p3,p4,p1,p2,p,rr,xx,yy,hh:int64;\nflag1,flag2,flag:boolean;\nnewoch,och,r,c,z,a,b,x,y:array[-1000000..10000000] of int64;\nmarked:array[-1000..20000000] of boolean;\naa,bb,cc:extended;\nch1,ch2,ch:char;\nsss:string;\nss,ss1,ss2: array [-10..100]of string;\nnpole,pole:array[-10..200,-10..200] of char;\ngr,rrr: array[-100..300,-100..300] of int64;\nfunction max(a,b:int64):int64; begin max:=a; if b>a then max:=b; end;\nfunction min(a,b:int64):int64; begin min:=a; if b=1 then arcsin:=pi/2 else arcsin:=arctan(x/sqrt(1-x*x));\n\n end;\n function phi(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n phi:=p;\n end;\n\n\n function right(ii:longint):extended; var al,t,p:extended; i:longint;\n begin al:=phi(x[ii],y[ii]); t:=x[ii]*x[ii]+y[ii]*y[ii]; t:=sqrt(t); right:=al+arcsin(t/rr); end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction zam(s:string):string; label 66; var st,sot:string; ii,i,j:longint;\nbegin\n st:=s[1]+s[2];\n j:=length(s); ii:=-1;\n for i:=1 to m do\n begin\n { writeln(i,' ',sot,'-',ss[i]);\n } if ss[i]=st then begin sot:=ss1[i]; ii:=i; end;\n\n end;\n { writeln('sot= ',sot,'ii= ',ii);\n }\n if ii<0 then sot:='zzzz';\n for i:=3 to j do sot:=sot+s[i];\n\nzam:=sot;\nend;\n\nfunction good(s:string):boolean; var s1,s2:string; step,i,j,k:longint; fl:boolean;\nbegin\n k:=length(s);\n s1:=s; fl:=true;\n for step:=1 to k-1 do begin s1:=zam(s1);\n { writeln(s1); } end;\n\n if s1='a' then good:=true else good:=false;\n\n\n\nend;\n\n\n\n\n\nbegin\n\n { assign(input,'E:/Projects/input.txt');reset(input);\n assign(output,'E:/Projects/output.txt');rewrite(output);\n }\n\n readln(n,m);\n for i:=1 to m do begin read(ch1,ch2); ss[i]:=ss[i]+ch1+ch2; read(ch); readln(ch); ss1[i]:=ch; end;\n {for i:=1 to m do writeln(ss[i],'+',ss1[i],'==');\n } t:=1 ; for i:=1 to n do t:=t*6;\n for step:=0 to t-1 do\n begin\n sss:='';\n q:=step;\n for i:=1 to n do begin a[i]:=q mod 6; q:=q div 6; end;\n for i:=1 to n do sss:=sss+chr(a[i]+ord('a'));\n\n if good(sss) then begin {writeln(sss);} inc(ot); end;\n\n\n\n\n\n end;\n\n writeln(ot);\n\n\n { writeln()\n }\n\n\n\n\n1:\nend.\n"}, {"source_code": "Var\n n,i,q,ans:longint;\n c:char;\n a,b:array[1..36]of string;\n s:string;\nFunction prov(s:string):boolean;\nVar\n i,j:longint;\n st:string;\nBegin\n for i:=1 to 5 do\n begin\n st:=copy(s,1,2);\n for j:=1 to q do\n if st=a[j] then\n begin\n delete(s,1,2);\n s:=b[j]+s;\n break;\n end;\n end;\n prov:=s='a';\nend;\nProcedure pereb(s:string;tk:longint);\nVar\n c:char;\nbegin\n if tk=n+1 then\n begin\n if prov(s) then\n inc(ans);\n end\n else\n for c:='a' to 'f' do\n pereb(s+c,tk+1);\nend;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n,q);\n for i:=1 to q do\n begin\n read(c);\n a[i]:=c;\n read(c);\n a[i]:=a[i]+c;\n read(c);\n read(c);\n b[i]:=c;\n readln;\n end;\n Pereb('',1);\n writeln(ans);\nend."}, {"source_code": "var a,b:array [1..100] of longint;\nq,n,i,k:longint;\ns:string;\nprocedure dfs(x,y:longint);\nvar j:longint;\n begin\n for j:=1 to q do\n if (y=n) and (b[j]=x) then inc(k) else\n if b[j]=x then dfs(a[j],y+1);\n end;\nbegin\nreadln(n,q);\nfor i:=1 to q do\n begin\n readln (s);\n a[i]:=ord(s[1])-96;\n b[i]:=ord(s[4])-96;\n end;\ndfs(1,2);\nwrite (k);\nend."}], "negative_code": [{"source_code": "var a,b,k:array [1..100] of longint;\nc:array [1..100,1..100] of longint;\nn,z,q,i,j:longint;\ns:string;\nbegin\nreadln(n,q);\nfor i:=1 to q do\n begin\n readln (s);\n a[i]:=(ord(s[1])-96)*10+ord(s[2])-96;\n b[i]:=ord(s[4])-96;\n end;\nfor i:=1 to q do\n if b[i]=1 then begin inc(k[2]); c[2,k[2]]:=a[i] div 10; end;\nfor i:=3 to n do\n for j:=1 to k[i-1] do\n for z:=1 to q do\n if b[z]=c[i-1,j] then begin inc(k[i]); c[i,k[i]]:=a[z] div 10; end;\nwrite(k[n]);\nend."}, {"source_code": "var a,b:array [1..100] of longint;\nq,n,i,i1,k:longint;\ns:string;\nprocedure dfs(x,y:longint);\n begin\n for i1:=1 to q do\n begin\n if (y=n) and (b[i1]=x) then inc(k) else\n if (b[i1]=x) and (y0 do\n begin\n s:=chr((x mod 6)+97)+s;\n x:=x div 6;\n end;\n dectosen:=s;\nEnd;\nFunction Bfs(s:string):boolean;\nVar l,r,i,j:longint;\n s1:string;\n c1,c2:char;\n lc:boolean;\nBegin\n l:=1; r:=1; hd[1]:=s;\n while l<=r do\n begin\n s1:=hd[l];\n for i:=1 to length(s1)-1 do\n if change[s1[i],s1[i+1]]<>'' then\n begin\n c1:=s1[i]; c2:=s1[i+1];\n delete(s1,i,2);\n insert(change[c1,c2],s1,i);\n lc:=true;\n for j:=1 to i-1 do\n if hd[j]=s1[i] then\n begin\n lc:=false;\n break;\n end;\n if lc=true then\n begin\n inc(r);\n hd[r]:=s1;\n end;\n if hd[r]='a' then\n exit(true);\n break;\n end;\n inc(l);\n end;\n bfs:=false;\nEnd;\nFunction Dem:longint;\nVar i,d:longint;\n s:string;\nBegin\n d:=0;\n for i:=0 to maxcase do\n begin\n s:=dectosen(i);\n if length(s)>n then\n break;\n while length(s)=1)and(q<=11) then\nif q=10 then begin\n writeln(15)\nend else\nwriteln(4)\nelse\nwriteln(0);\nend."}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if (n<=10) or (n>21) then begin\n write(0); halt;\n end;\n if (n<20) or (n=21) then begin\n write(4); halt;\n end;\n if n=20 then write(15);\nend.\n"}, {"source_code": "Program Blackjack;\nuses math;\nvar n:byte;\nbegin readln(n);\n if (n<=10) or (n>=22) then writeln(0)\n else if (n=11) or (n=21) then writeln(4)\n else if n=20 then writeln(15)\n else writeln(4);\nend."}, {"source_code": "Program a104;\nconst\na:array [1..5] of byte=(0,12,13,14,15);\nb:array [1..10] of byte=(1,2,3,4,5,6,7,8,9,11);\nc=10;\nVar\nn,m,i:integer;\nBegin\nReadln(n);\nm:=n-10;\nFor i:=1 to 5 do\n if m=a[i] then Writeln(0);\nFor i:=1 to 10 do\n if m=b[i] then Writeln(4);\nif m=c then Writeln(15);\nif m<0 then Writeln(0);\nend."}, {"source_code": "var n:byte;\nbegin\nreadln(n);\ncase n of\n11..19:writeln('4');\n20:writeln('15');\n21:writeln('4');\nelse writeln('0');\nend;\nend."}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n if n<=10 then begin write('0');halt(0);end;\n for i:=2 to 9 do\n a[i]:=4;\n a[1]:=4;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "uses math;\nvar n:integer;\n f:text;\nbegin\n read(n);\n n:=max(n-10,0);\n if n in[1..9,11] then write(4)\n else\n if n=10 then write(15)\n else write(0);\nend.\n"}, {"source_code": "var\ni,j,k,l,m,n:longint;\nbegin\n readln(n);\n l := n - 10;\n \n if (l = 0) then writeln(0) else\n if (l < 10)and(l > 0) then writeln(4) else\n if (l = 10) then writeln(15) else\n if (l = 11) then writeln(4) else\n writeln(0);\nend."}, {"source_code": "var n:byte;\nbegin\n readln(n);\n dec(n,10);\n if (n=0)or(n>11) then begin writeln('0');exit end;\n if n in[1..9,11]then writeln('4') else writeln('15');\nend."}, {"source_code": "Var n,k,i,s,x:longint;\nBegin\n Readln(n);\n n:=n-10;\n if(n<10)and(n>0)or(n=11)\n then writeln('4')\n else if n=10\n then writeln('15')\n else writeln('0');\n\nEnd.\n"}, {"source_code": "const a:array[1..11] of integer = (4,4,4,4,4,4,4,4,4,15,4);\nvar n:integer;\nbegin\nreadln(n);\nif (n>10) and (n<22) then writeln(a[n-10])\n else writeln(0);\nend."}, {"source_code": "var n:byte;\nbegin\n readln(n);\n if (n<=10)or(n>21) then\n writeln(0)\n else\n if n=20 then\n writeln(15)\n else\n writeln(4);\n readln;\nend."}, {"source_code": "var a,b,n:longint;\nbegin\n\treadln(n);\n if (n<=10) or (n>=22) then\n begin\n \twriteln('0');\n halt;\n end;\n a:=n-10;\n if (a<>10) then\n \tb:=4;\n if (a=10) then\n \tb:=15;\n writeln(b);\nend."}, {"source_code": "program blackjack;\n\nvar\n n : byte;\n\nbegin\n read(n);\n\n n := n - 10;\n\n if (n = 0) or (n > 11) then write('0')\n else if (n = 10) then write ('15')\n else write('4');\n\nend.\n"}, {"source_code": "program funktions;\nconst maxlen = 100000;\n maximum=1000000001;\n\nType TData = array [0..maxlen] of longint;\n\nfunction max(a,b:longint):longint;\nBegin\n if (a>b) then max:=a\n else max:=b;\nend;\n\nfunction min (a,b:longint):longint;\nbegin\n min:=a+b-max(a,b);\nend;\n\nFunction max_array(P:TData; l,r:longint):longint;\nVar i,m,j:longint;\nBegin\n m:=0;\n For i:= l to r do begin\n if (P[i]>m) then begin\n m:=P[i];\n j:=i;\n end;\n End;\n max_array:=j;\nEnd;\n\nFunction min_array(P:TData; l,r:longint):longint;\nVar i,mn,j:Longint;\nBegin\n mn:=Maximum;\n for i:=l to r do begin\n If (P[i]a) then Swap(a,b);\n If (b=0) then GCD:=a\n else GCD:=GCD(b, a mod b);\nEnd;\n\nprocedure read_array( var P:TData; n:longint);\nvar i:longint;\nbegin\n\n for i:=1 to n do read(P[i]);\nend;\n\nprocedure readln_array(var P:TData; n:longint );\nvar i:longint;\nbegin\n for i:=1 to n do readln(P[i]);\nend;\n\nprocedure writeln_array(var P:TData; n:longint );\nvar i:longint;\nbegin\n for i:=1 to n do writeln(P[i]);\nend;\n\nprocedure write_array(var P:TData; n:longint );\nvar i:longint;\nbegin\n for i:=1 to n do begin\n write(P[i]); write(' ');\n end;\nend;\n\nfunction sum( var P:TData; l,r:longint):longint;\nvar s,i:longint;\nbegin\n s:=0;\n for i:=l to r do s:=s + P[i];\n sum:=s;\nend;\n\nprocedure QSort( var P:TData; l,r:longint);\nvar i,j,x:longint;\nbegin\n\n x:=P[ l+ random(r-l+1) ];\n i:=l; j:=r;\n\n if (r > l ) then begin\n repeat\n while(P[i]x) do dec(j);\n\n if(j>=i) then begin\n swap(P[i], P[j]);\n inc(i); dec(j);\n end;\n\n until(i>j);\n\n QSort(P,l,j); QSort(P,i,r);\n end;\n\nend;\n\nfunction LCM(a,b:longint):longint;\nbegin\n LCM:=(a*b) mod (GCD(a,b) );\nend;\n\nfunction number_element(P:TData; k,l,r:longint):longint;\nVar i,count:longint;\nBegin\n count:=0;\n For i:=l to r do begin\n if k=P[i] then inc(count);\n End;\n number_element:=count;\nEnd;\n\nprocedure NO;\nbegin\n writeln('NO');\nend;\n\nprocedure YES;\nbegin\n writeln('YES');\nend;\n\n\n\n\nvar\n n,i,res:longint;\n\nbegin\n readln(n);\n\n if (n<=10) or (n>21) then res:=0;\n if (n>10) and (n<20) then res:=4;\n if (n=20) then res:=15;\n if (n=21) then res:=4;\n writeln(res);\n\nend.\n"}, {"source_code": "var\n ans,n,i,s : longint;\nbegin\n readln(n);\n ans:=0;\n s:=10;\n for i:=2 to 9 do\n if s+i=n then inc(ans,4);\n if s+10 = n then inc(ans,15);\n if (s+1 = n) or (s+11=n) then inc(ans,4);\n writeln(ans);\nend.\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n dec(n,10);\n if(0=1) and (n<=9)) or(n=11) then\n begin\n writeln(4);\n halt;\n end;\n if n=10 then\n begin\n writeln(15);\n halt;\n end;\n writeln(0);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n:integer;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n read(n);\n if n in [1..10] then\n write('0')\n else\n case n of\n 11:write('4');\n 12:write('4');\n 13:write('4');\n 14:write('4');\n 15:write('4');\n 16:write('4');\n 17:write('4');\n 18:write('4');\n 19:write('4');\n 20:write('15');\n 21:write('4');\n 22:write('0');\n 23:write('0');\n 24:write('0');\n 25:write('0');\n end;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n res,n : longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n n := n - 10;\n if (n = 0) or (n > 11) then res := 0\n else if (n < 10) and (n > 0)then res := 4\n else if n = 10 then res := 15\n else if n = 11 then res := 4;\n Assign(f,fo);\n rewrite(f);\n Writeln(f,res);\n Close(f);\n End.\n"}, {"source_code": "program anvard_1;\nvar n,i: integer;\nbegin\n readln (n);\n n:= n - 10;\n if (n > 0) and (n <= 11) then i:=4;\n if (n=0) or (n > 11) then i:=0;\n if (n = 10) then i:=15;\n writeln (i);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array[1..50] of integer;\n n:integer;\n\nbegin\na[1]:=4;\na[2]:=4;\na[3]:=4;\na[4]:=4;\na[5]:=4;\na[6]:=4;\na[7]:=4;\na[8]:=4;\na[9]:=4;\na[10]:=4+4+3+4;\na[11]:=4;\nreadln(n);\ndec(n,10);\nif n in [1..11] then write(a[n])\n else write(0);\nreadln;\nend.\n"}, {"source_code": "var\n n:integer;\n\nbegin\n read(n);\n n:=n-10;\n if ((n>=1)and(n<=9))or(n=11)then write('4') else\n if (n<=0)or(n>=12) then write('0') else\n if n=10 then write('15');\n\nend."}, {"source_code": "program Problem_A;\n\n{$APPTYPE CONSOLE}\n\nconst g : array[-9..15]of longint = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4, 0, 0, 0, 0);\n\nvar n : longint;\n\nbegin\n assign(input, '');\n assign(output, '');\n readln(n);\n\n n := n - 10;\n\n writeln(g[n]);\n close(input);\n close(output);\nend.\n "}, {"source_code": "var n,s:longint;\n begin\n read(n);\n s:=n-10;\n if (s>11) or (n<=10) then begin writeln(0); exit; end;\n if (s=10) then writeln(15)\n else writeln(4);\n end."}, {"source_code": "program Project5;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, kol, shet: longint;\nbegin\n readln(n);\n {kol := 10;\n shet := 0;\n for i := 2 to 10 do\n begin\n if i + kol = n then\n shet := shet + 4;\n end;\n\n for i := 1 to 3 do\n begin\n if}\n kol := n - 10;\n if (kol >= 2) and ( kol <= 9) then\n begin\n writeln('4');\n exit;\n end;\n\n if (kol = 1) or (kol = 11) then\n begin\n writeln('4');\n exit;\n end;\n\n if kol = 10 then\n begin\n writeln(4 + 4 + 4 + 3);\n exit;\n end;\n writeln('0'); \nend.\n "}, {"source_code": "\nvar\nn,i,z,q,g : longint;\na : array[1..62] of longint;\nbegin\ni:=1;\ng:=1;\nwhile i<37 do\nbegin\n g:=g+1;\n a[i]:=g;\n i:=i+1;\n if g=10 then\n g:=1;\nend;\nfor i:=41 to 51 do\n a[i]:=10;\nfor i:=54 to 57 do\n a[i]:=11;\nfor i:=59 to 62 do\n a[i]:=1;\nreadln(n);\nz:=10;\nq:=0;\nif n<>z then\nbegin\n for i:=1 to 62 do\n begin\n if z + a[i] = n then\n q:=q+1;\n end;\nend;\nwriteln(q);\nend."}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D+,E+,F+,G-,I+,L+,N+,O-,R+,Q+,S+,V+,X+}\n// {$A+,B-,D-,E+,F+,G-,I-,L-,N+,R-,Q-,S-,V+,X+}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n// base = 1000000009;\n// eps = 1e-9;\n\nvar\n n, m, i, j, res, k, res1, res2, l, r, x, y, z: integer;\n a: array [0..10001] of integer;\n s, s1, s2: string;\n ok: boolean;\n\n\nprocedure panic(dxp: integer);\nbegin\n write(dxp);\n halt(0);\nend;\n\nprocedure panic64(dxi64: int64);\nbegin\n write(dxi64);\n halt(0);\nend;\n\nprocedure panics(kws: string);\nbegin\n write(kws);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nprocedure swap64(var qx1, qy1: int64);\nvar\n qz1: int64;\nbegin\n qz1 := qx1;\n qx1 := qy1;\n qy1 := qz1;\nend;\n\nprocedure swapex(var qx2, qy2: extended);\nvar\n qz2: extended;\nbegin\n qz2 := qx2;\n qx2 := qy2;\n qy2 := qz2;\nend;\n\nprocedure swaps(var qs1, qs2: string);\nvar\n qs3: string;\nbegin\n qs3 := qs1;\n qs1 := qs2;\n qs2 := qs3;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n readln(n);\n x := n - 10;\n if (x <= 0) or (x >= 12) then\n panic(0);\n if n = 20 then\n panic(15)\n else\n write(4)\n\n\n\nend.\n\n"}, {"source_code": "var n :integer;\nbegin\nread(n);\nif (n<11) or (n>21) then write(0) else \nif ((n-10)<10) or ((n-10)=11) then write(4) else write(15);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n i,n,k,k1:Integer;\nbegin\n Readln(n);\n for i:=1 to 11 do\n begin\n if (10+i=n) then\n begin\n if (i=10) then Inc (k,15)\n else if (i=10) then Inc (k,16)\n else Inc (k,4);\n end;\n end;\n write(k);\n Readln;\n Readln;\nend.\n "}, {"source_code": "var n:byte;\nbegin\nread(n);\nn:=n-10;\nif (n=0) or (n>11) then write(0) else if n=10 then write (15) else write(4);\nend."}, {"source_code": "program blj;\nvar n,k:byte;\n f:text;\nbegin\n { assign(f,'input.txt');\n reset(f);}\n readln({f}n);\n { close(f);}\n if (n<=10)or(n>=22)\n then k:=0\n else if (n-10)=10\n then k:=15\n else k:=4;\n { assign(f,'output.txt');\n rewrite(f);}\n write({f}k);\n { close(f);}\nend."}, {"source_code": "program problem1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n, k: integer;\nbegin\n \n\n read(n);\n\n if (n <= 10) or (n > 21) then begin\n writeln(0);\n halt;\n end;\n k := n - 10;\n if k = 10 then begin\n writeln(15);\n halt;\n end;\n writeln(4);\nend."}, {"source_code": "var\nn:longint;\nbegin\nread(n);\nif n<=10 then writeln(0)\n else if n<=19 then writeln(4)\n else if n=20 then writeln(15)\n else if n=21 then writeln(4)\n else writeln(0);\nend."}, {"source_code": "var\nn:longint;\nbegin\nread(n);\nif ((n-10) in [2..9]) or (n-10=11) then write (4) else\nif n-10=1 then write(4) else if n-10=10 then write(15) else write(0); end."}, {"source_code": "var\n i,n,m,k,ans:longint;\n\n\n\nbegin\n readln(n);\n ans:=0;\n for i:=1 to 11 do\n if (i=10) and (i+10=n) then inc(ans,15)\n else\n if (i+10=n) then inc(ans,4);\n writeln(ans);\n end.\n"}, {"source_code": "Var n , i , kq : Longint;\n\nBegin\nReadln(n);\nIf (n <= 10) or (n >= 22) then Writeln('0') else\n Begin\n kq := 4;\n If n = 20 then kq := 15;\n Writeln(kq);\n End;\nEnd."}, {"source_code": "var\n\tn:integer;\nbegin\n\tread(n);\n\tif (n<=10) or (n>21) then\n\tbegin\n\t\twriteln(0);\n\tend else\n\tif (n=20) then\n\tbegin\n\t\twriteln(15);\n\tend else\n\tbegin\n\t\twriteln(4);\n\tend;\nend."}, {"source_code": " const a:array[1..11]of integer=(4,4,4,4,4,4,4,4,4,15,4);\n var n:integer;\nbegin\n readln(n);\n if (n-10<1)or(n-10>11)\n then writeln(0)\n else writeln(a[n-10]);\nend. \n"}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n I, N: Longint;\n\nbegin\n Read(N);\n case N - 10 of\n 1..9, 11: Writeln(4);\n 10: Writeln(15);\n else Writeln(0);\n end;\nend.\n "}, {"source_code": "program zzz;\n\ntype int = longint;\n\nvar n:int; \n\nbegin\n\treadln(N);\n\t\n\tcase n-10 of\n\t\t1:writeln(4);\n\t\t2:writeln(4);\n\t\t3:writeln(4);\n\t\t4:writeln(4);\n\t\t5:writeln(4);\n\t\t6:writeln(4);\n\t\t7:writeln(4);\n\t\t8:writeln(4);\n\t\t9:writeln(4);\n\t\t10:writeln(15);\n\t\t11:writeln(4)\n\telse writeln(0)\n\tend;\nend.\t"}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a = 0 then writeln ('0')\n else if (x <= 21) and (a > 0) then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else writeln ('0');\n\nend."}, {"source_code": "var n: longint;\nbegin\nread (n);\nif ((n >= 11) and (n <= 21)and(n <> 20)) then write ('4') else\nif n = 20 then write ('15') else write ('0');\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n N: integer;\nbegin\n// Assign(input, 'in.in');\n ReadLn(N);\n if N - 10 in [1..9, 11] then\n WriteLn(4)\n else if N - 10 = 10 then\n WriteLn(15)\n else\n WriteLn(0);\nend."}, {"source_code": "program Project104A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, k: integer;\n\nbegin\n Readln(n);\n if (n <= 10) or (n >= 21) then\n k := 0;\n if (n >= 11) and (n <= 19) then\n k := 4;\n if n = 20 then\n k := 15;\n if n = 21 then\n k := 4;\n Writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n n:longint;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(n);\n if (n <= 10) or (n > 21) then writeln(0) else\n if n = 20 then writeln(15) else writeln(4);\nend.\n"}, {"source_code": "uses math;\nvar\n n:longint;\nbegin\n read(n);\n case n of\n 0,1,2,3,4,5,6,7,8,9,10,22,23,24,25:write(0);\n 11,12,13,14,15,16,17,18,19,21:write(4);\n 20:write(15);\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n : longint;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n\n read(n);\n n := n - 10;\n if (n <= 0) or (n > 11) then\n begin\n write(0);\n halt(0);\n end;\n\n if (n < 10) or (n = 11) then\n write(4)\n else\n write(15);\n\n // close(input);\n// close(output);\nend.\n "}, {"source_code": "program blackJack;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,k,i:integer;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if (n<11) or (n>21) then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 11 do\n begin\n k:=10;\n k:=k+i;\n if k=n then\n begin\n k:=i;\n break;\n end;\n end;\n if (k<10) or (k=11) then\n writeln(4)\n else\n if k=10 then\n writeln(15);\nend."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n:integer;\nbegin\nreadln(n);\ncase n of\n1..10,22..25:write(0);\n11..19,21:write(4);\n20:write(15);\nend;\n\nend.\n"}, {"source_code": "{$apptype console}\n{$I+,R+,Q+}\nUses Sysutils;\nVar\n n:integer;\nBegin\n readln(n);\n if n<=10 then begin\n writeln('0');\n halt;\n end;\n if n>21 then begin\n writeln('0');\n halt;\n end;\n n:=n-10;\n case n of\n 1,2,3,4,5,6,7,8,9,11: writeln('4');\n 10:writeln('15');\n end;\n readln;\n readln;\nEnd.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\nn,ans:longint;\nbegin\n read(n);\n n:=n-10;\n if n<1 then ans:=0 else\n if n>11 then ans:=0 else\n if n=10 then ans:=15 else\n ans:=4;\n writeln(ans);\nend."}, {"source_code": "program A_;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ni,n:integer;\nbegin\n //assign(input,'input.txt'); assign(output,'output.txt');\n //reset(input); rewrite(output);\n readln(n);\n if n=20 then begin writeln(15); halt; end;\n if (n<=10)or(n>=22) then writeln(0) else writeln(4);\n\nend.\n"}, {"source_code": "program A_;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ni,n:integer;\nbegin\n //assign(input,'input.txt'); assign(output,'output.txt');\n //reset(input); rewrite(output);\n readln(n);\n if n=20 then begin writeln(15); halt; end;\n if (n<=10)or(n>=22) then writeln(0) else writeln(4);\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, r: integer;\n\nbegin\n readln(n);\n\n r := n - 10;\n if (r <= 0) or (r > 11) then\n write(0)\n else\n if (r = 10) then\n write(15)\n else\n write(4);\nend.\n "}, {"source_code": "const\n a:array[1..11] of longint=(4,4,4,4,4,4,4,4,4,15,4);\nvar\n n:longint;\nbegin\n read(n);\n if (n<10) or (n>21) then write(0) else write(a[n-10]);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nUses Sysutils;\nvar\n a:array[1..100]of longint;\n n,i,j,k,res:longint;\n s:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(n);\n if n<=10 then\n write(0)\n else\n if n>21 then write(0)\n else\n begin\n if n=20 then write(15)\n else write(4);\n end;\nend."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n n:=n-10;\n if (n<=0)or(n>11) then writeln(0)\n else begin\n if n=10 then writeln(15)\n else if n=11 then writeln(4)\n else if n=1 then writeln(4)\n else writeln(4);\n end;\nend."}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nif (n<=10) or (n>=22) then write(0) else\nif (n<>20) then write(4) else\nwrite(15);\nreadln;\nend."}, {"source_code": "uses math;\nvar\n arr:array[0..5,0..5] of longint;\n i,n,r:longint;\nbegin\n readln(n);\n n:=n-10;\n if (n=1) or (n=11) then\n r:=4;\n if n=10 then\n r:=r+11;\n for i:=2 to 10 do\n if n=i then\n r:=r+4;\n writeln(r);\nend. "}, {"source_code": "var n,r:LongInt;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(n);\n r:=0;\n case n of\n 11..19:r:=4;\n 20:r:=15;\n 21:r:=4;\n end;\n Writeln(r);\nend.\n"}, {"source_code": "program blackJack;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,k,i:integer;\n\nbegin\n readln(n);\n if (n<11) or (n>21) then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 11 do\n begin\n k:=10;\n k:=k+i;\n if k=n then\n begin\n k:=i;\n break;\n end;\n end;\n if (k<10) or (k=11) then\n writeln(4)\n else\n if k=10 then\n writeln(15);\nend."}, {"source_code": "var\n n,ans:longint;\n\nbegin \nread(n);\ndec(n,10);\nif n = 10 then ans := 15 else \nif n = 11 then ans := 4 else\nif (n < 1) or (n > 11) then ans := 0 else ans := 4;\nwrite(ans);\nend."}, {"source_code": "var\n n:longint;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n read(n);\n n:=n-10;\n if n=10 then write(15) else\n if n in[1..11] then write(4) else write(0);\nend."}, {"source_code": "var\n n:longint;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n read(n);\n n:=n-10;\n if n=10 then write(15) else\n if n in[1..11] then write(4) else write(0);\nend.\n"}, {"source_code": "var n:longint;\n begin\n read(n);\n n:=n-10;\n if n=10 then write(15)\n else\n if (n>0) and (n<12) then write(4)\n else write(0);\n end."}, {"source_code": "program Project2;\n\n\nuses\n SysUtils;\n{$APPTYPE CONSOLE}\n\nvar\n l,b,n,i,m,f,k,s:integer;\n a:Array[1..1000000] of integer;\n\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n {$ENDIF}\n read(n);\n if n < 11 then begin\n writeln(0);\n halt;\n end;\n n := n - 10;\n if n = 10 then begin\n writeln(15);\n halt;\n end;\n for i := 1 to 11 do\n if n = i then begin\n writeln(4);\n halt;\n end;\n writeln(0);\nend.\n"}, {"source_code": "var n:longint;\n i,a,b:integer;\nbegin\nreadln(n);\nif n<=10 then writeln(0) else if n>21 then writeln(0) else\nbegin\nn:=n-10;\nif n=10 then n:=15 else n:=4;\nwriteln(n);\nend;\nend."}, {"source_code": "program blackjack;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n : longint;\nbegin\n readln(n);\n case n of\n 1..10: writeln(0);\n 22..25: writeln(0);\n 11..19, 21: writeln(4);\n 20: writeln(15);\n end;\nend.\n "}], "negative_code": [{"source_code": "Var\n n: Int64;\n\nBegin\n Read(n);\n n -= 10;\n If (n > 0) and (n <= 21) then Begin\n If n = 10 then\n Write(15)\n Else If (n = 11) or (n <= 9) then\n Write(4)\n End\n Else\n Write(0);\nEnd."}, {"source_code": "var\n n:integer;\nbegin\n readln(n);\n case n of\n 1..11,22..25: writeln(0);\n 12..19,21: writeln(4);\n 20: writeln(15);\n end;\nend."}, {"source_code": "var n,k:longint;\n begin\n read(k);\n n:=k-10;\n if n=0 then writeln(0)\n else if (n=1) then writeln(1)\n else if (n>1) and (n<10) then writeln(4)\n else if (n=10) then writeln(15)\n else writeln(1);\n end."}, {"source_code": "program aaa;\nVar n:longint;\nbegin\n readln(n);\n n:=n-10;\n case n of\n 0:writeln(0);\n 10:writeln(15);\n 12:writeln(0);\n 13:writeln(0);\n 14:writeln(0);\n 15:writeln(0);\n else writeln(4);\n end;\nend."}, {"source_code": "var\n n:integer;\nbegin\n readln(n);\n case n of\n 1..11,22..25: writeln(0);\n 12..19,21: writeln(4);\n 20: writeln(15);\n end;\nend."}, {"source_code": "program anvard_1;\nvar n,i: integer;\nbegin\n readln (n);\n n:= n - 10;\n if (n > 0) and (n < 10) then i:=4;\n if (n=0) or (n > 11) then i:=0;\n if (n = 10) then i:=15;\n writeln (i);\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x <= 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var n:longint;\n i,a,b:integer;\nbegin\nreadln(n);\nif n<=10 then writeln(0)else\nbegin\nn:=n-10;\nif n=10 then n:=15 else n:=4;\nwriteln(n);\nend;\nend."}, {"source_code": "//Yerzhan Dyussenaliyev\n{$o-}\nUses\n Math, SysUtils;\nconst\n inf = maxlongint div 3;\n dx: array [1..4] of longint = (0, 0, -1, 1);\n dy: array [1..4] of longint = (1, -1, 0, 0);\nvar\n a: array [0..1100000] of longint;\n b: array [0..1100, 0..1100] of longint;\n c: array [0..1100, 0..1100] of char;\n s, ss, st: string;\n n, i, j, k, q, res, cur, ans, t, l, r: longint;\n\nbegin\n {$ifndef online_judge}\n\t\treset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n\n read(n);\n res := n - 10;\n if res <= 0 then begin\n\t\twriteln(0);\n end else\n if res <= 9 then begin\n\t\twriteln(4);\n end else\n if res = 10 then begin\n\t\twriteln(15);\n end else begin\n writeln(4);\n end;\n\nend.\n"}, {"source_code": "var n:byte;\nbegin\nreadln(n);\nif ((n>11) and (n<19)) or (n=21) then writeln(4)\nelse\nif (n=20) then writeln(15)\nelse\nwriteln(0);\nend. "}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var n,k:longint;\n begin\n read(k);\n n:=k-10;\n if n=0 then writeln(0)\n else if (n=1) then writeln(1)\n else if (n>1) and (n<10) then writeln(4)\n else if (n=10) then writeln(15)\n else writeln(1);\n end."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif (n=10) then begin writeln(15);halt;end;\nif (n<10) and (n>0) then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "var a,b,c,d,e,f,i,kolvo:longint;\nbegin\nread(a);\nkolvo:=0;\na:=a-10;\nif a=0 then write('0') else\nif a=1 then write('4') else begin\nfor i:=2 to 10 do begin\nif a=i then kolvo:=kolvo+4;\nend;\nfor i:=1 to 3 do begin\nif a=10 then kolvo:=kolvo+4;\nend;\nif a=10 then dec(kolvo);\nif a=11 then write('4');\nwrite(kolvo);\nend;\n\nend.\n"}, {"source_code": "var n,r:LongInt;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(n);\n r:=0;\n case n of\n 11..19:r:=4;\n 20:r:=15;\n end;\n Writeln(r);\nend.\n"}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n for i:=2 to 9 do\n a[i]:=4;\n a[0]:=0; a[1]:=4;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "Var n,i,ans:LongInt;\n begin\n ans:=0;\n ReadLn(n);\n For i:=1 to 9 do\n if i+10=n then ans:=ans+4;\n if 10+10=n then ans:=ans+15;\n if 10+1=n then ans:=ans+4;\n if 10+11=n then ans:=ans+4;\n WriteLn(ans);\n end."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif (n<10) or (n=0) then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n res,n : longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n n := n - 10;\n if (n = 0) then res := 0\n else if (n < 10) then res := 4\n else if n = 10 then res := 15\n else if n = 11 then res := 4;\n Assign(f,fo);\n rewrite(f);\n Writeln(f,res);\n Close(f);\n End."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\tn,ans:longint;\n\nbegin \n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nread(n);\ndec(n,10);\nif n = 10 then ans := 15 else \nif n < 1 then ans := 0 else ans := 4;\nwrite(ans);\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar n,KQ:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,n);\n close(f);\nend;\n{-------------------}\nprocedure xuli;\nvar k:longint;\nbegin\n k:=n-10;\n if k<=0 then KQ:=0;\n if (1<=k) and (k<=9) then KQ:=4;\n if k=10 then KQ:=11;\n if k=11 then KQ:=4;\n if k>10 then KQ:=0;\nend;\n{-------------------}\nprocedure xuat;\nvar g:text;\nbegin\n assign(g,fout);\n rewrite(g);\n write(g,KQ);\n close(g);\nend;\n{-------------------}\nbegin\n nhap;\n xuli;\n xuat;\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n res,n : longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n n := n - 10;\n if (n = 1) or (n = 0) then res := 0\n else if (n < 10) then res := 4\n else if n = 10 then res := 15;\n Assign(f,fo);\n rewrite(f);\n Writeln(f,res);\n Close(f);\n End."}, {"source_code": "var n: longint;\nbegin\nread (n);\nif ((n >= 12) and (n <= 18))or(n = 21) then write ('4') else\nif n = 20 then write ('11') else write ('0');\n\nend.\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if (n<=10) and (n>21) then begin\n write(0); halt;\n end;\n if (n<20) or (n=21) then begin\n write(4); halt;\n end;\n if n=20 then write(15);\nend.\n"}, {"source_code": "Program blackJack;\nVar n:Byte;\nBegin\n readln(n);\n if (n<=10) or (n>21)\n then writeln('0')\n else begin\n case n of\n 11:writeln('1');\n 12:writeln('4');\n 13,14,15,16,17,18,19:writeln('4');\n 20:writeln('15');\n 21:writeln('1');\n end;\n end;\nEnd.\n"}, {"source_code": "var x:integer;\nbegin\nreadln(x);\nx:=x-10;\nif x=10 then writeln(15)\nelse if x<>0 then writeln(4)\n else writeln(0);\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x <= 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 25 then writeln (15*4+4*4);\nend."}, {"source_code": "const a:array[1..11] of integer = (4,4,4,4,4,4,4,4,4,15,4);\nvar n:integer;\nbegin\nreadln(n);\nif (n>10) and (n<14) then writeln(a[n-10])\n else writeln(0);\nend."}, {"source_code": "var n,k:longint;\n begin\n read(k);\n n:=k-10;\n if n=0 then writeln(0)\n else if (n=1) then writeln(1)\n else if (n>1) and (n<10) then writeln(4)\n else if (n=10) then writeln(15)\n else writeln(1);\n end."}, {"source_code": "program p1;\nvar n:integer;\nbegin\n readln(n);\n if ((n>=1) and (n<=10)) or ((n>=22) and (n<=25)) then writeln('0');\n if ((n>=11) and (n<=19)) and (n=21) then writeln('4');\n if n=20 then writeln('15');\nend.\n"}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n for i:=2 to 9 do\n a[i]:=4;\n a[0]:=0; a[1]:=4;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nvar\n i, k, n : longint;\n\nbegin\n readln(n);\n n := n - 10;\n for i := 2 to 10 do\n if i = n then\n inc(k, 4);\n if 10 = n then\n inc(k, 11);\n if (n = 11) or (n = 1) then\n inc(k, 4);\n writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$o-}\n{$j+}\nuses\n SysUtils;\nvar n:integer;\nfin,fout:text;\nbegin\n assign(fin,'');\n assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,n);\n if n<12 then writeln(fout,0);\n if (n>11) and (n<20) then writeln(fout,4);\n if n=20 then writeln(fout,15);\n if n=21 then writeln(fout,4);\n close(fin); close(fout);\nend.\n"}, {"source_code": "const a:array[1..11] of integer = (4,4,4,4,4,4,4,4,4,15,4);\nvar n:integer;\nbegin\nreadln(n);\nif (n>10) and (n<14) then writeln(a[n-10])\n else writeln(0);\nend."}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nn:=n-10;\ncase n of 0: writeln ('0');\n 1,11: writeln ('2');\n 2..9: writeln ('4');\n 10: writeln ('15');\n 12..15: writeln('0');\nend;\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n n,p:Integer;\nBegin\n //Reset(input,Source);\n //Rewrite(output,Target);\n Read(n);\n p:=n-10;\n If p<=0 Then Write(0)\n Else If p=10 Then Write(15)\n Else If p>21 Then Write(0)\n Else Write(4);\nEnd.\n\n"}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n for i:=2 to 9 do\n a[i]:=4;\n a[0]:=0; a[1]:=4;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "Program blackJack;\nVar n:Byte;\nBegin\n readln(n);\n if (n<=10) or (n>21)\n then writeln('0')\n else begin\n case n of\n 11:writeln('1');\n 12:writeln('4');\n 13,14,15,16,17,18,19:writeln('4');\n 20:writeln('15');\n 21:writeln('1');\n end;\n end;\nEnd.\n"}, {"source_code": "var\nn,i,z,q,g : longint;\na : array[1..62] of longint;\nbegin\ni:=1;\ng:=1;\nwhile i<37 do\nbegin\n g:=g+1;\n a[i]:=g;\n i:=i+1;\n if g=10 then\n g:=1;\nend;\nfor i:=41 to 51 do\n a[i]:=10;\nfor i:=54 to 57 do\n a[i]:=11;\nfor i:=58 to 62 do\n a[i]:=1;\nreadln(n);\nz:=10;\nq:=0;\nif n<>z then\nbegin\n for i:=1 to 62 do\n begin\n if z + a[i] = n then\n q:=q+1;\n end;\nend;\nwriteln(q);\nend."}, {"source_code": "var n:longint;\n i,a,b:integer;\nbegin\nreadln(n);\nif n<=10 then writeln(0)else\nbegin\nn:=n-10;\nif n=10 then n:=15 else n:=4;\nwriteln(n);\nend;\nend."}, {"source_code": "var ans,n:longint;\n\nbegin\n read(n);\n n:=n-10;\n if n=10 then write(15)\n else if n<=0 then write(0)\n else write(4);\nend.\n"}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nn:=n-10;\ncase n of 0: writeln ('0');\n 1..9,11: writeln ('4');\n 10: writeln ('15');\n 12..15: writeln('0');\nend;\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif n<10 then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n for i:=2 to 9 do\n a[i]:=4;\n a[0]:=0; a[1]:=4;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "var n:byte;\nbegin\n read(n);\n case n of\n 10:n:=0;\n 20:n:=15;\n 21..25:n:=0;\n else n:=4;\n end;\n write(n)\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "program BlackJack;\nvar n,i,t:integer;\n a:array[1..11] of byte;\nbegin\n for i:=2 to 9 do begin\n a[i]:=4;\n end;\n a[10]:=15;\n a[11]:=1;\n a[1]:=1;\n readln(n);\n n:=n-10;\n i:=1; t:=0;\n while n <> i do begin\n i:=i+1;\n if i = 12 then begin t:=1; n:=i; end;\n end;\n if t=0 then writeln(a[i]) else writeln(0);\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif n<10 then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif (n=10) then begin writeln(15);halt;end;\nif (n<10) and (n>0) then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "var ko,a,n:longint;\n begin\n readln(n);\n ko:=0;\n if n=20 then ko:=15;\n if n=10+11 then inc(ko,4);\n if n=10+1 then inc(ko,4);\n for a:=1 to 9 do\n if n=10+a then inc(ko,4);\n writeln(ko);\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var n: longint;\nbegin\nread (n);\nif ((n >= 12) and (n <= 18))or(n = 21) then write ('4') else\nif n = 20 then write ('11') else write ('0');\n\nend.\n"}, {"source_code": "{$mode objfpc} \n\n\nvar i , n : integer;\n\n\nprocedure Result( res : integer );\n begin\n writeln( res );\n halt;\n end;\n\n\nbegin\n readln( n );\n if ( n <= 10 ) or ( n > 21 ) then Result( 0 );\n if ( n = 11 ) or ( n = 21 ) then\n Result( 1 );\n if n < 20 then\n Result( 4 );\n if n = 20 then\n Result( 15 );\nend.\n"}, {"source_code": "var\n n,x,y,z,i,j,k,output : longint;\nbegin\n readln(n);\n if(n<=10) then\n output := 0\n else if(n>10) and (n<20) then\n output := 4\n else if(n= 20) then\n output := 15\n else output := 4;\n writeln(output);\n\n\n\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif (n<10) or (n=0) then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nn:=n-10;\ncase n of 0: writeln ('0');\n 1..9,11: writeln ('4');\n 10: writeln ('15');\n 12..15: writeln('0');\nend;\nend."}, {"source_code": "var n: longint;\nbegin\nread (n);\nif ((n >= 12) and (n <= 18))or(n = 21) then write ('4') else\nif n = 20 then write ('11') else write ('0');\n\nend.\n"}, {"source_code": "Program a104;\nconst\na:array [1..5] of byte=(0,12,13,14,15);\nb:array [1..10] of byte=(1,2,3,4,5,6,7,8,9,11);\nc=10;\nVar\nn,m,i:byte;\nBegin\nReadln(n);\nm:=n-10;\nFor i:=1 to 5 do\n if m=a[i] then Writeln(0);\nFor i:=1 to 10 do\n if m=b[i] then Writeln(4);\nif m=c then Writeln(15);\nend."}, {"source_code": "//Yerzhan Dyussenaliyev\n{$o-}\nUses\n Math, SysUtils;\nconst\n inf = maxlongint div 3;\n dx: array [1..4] of longint = (0, 0, -1, 1);\n dy: array [1..4] of longint = (1, -1, 0, 0);\nvar\n a: array [0..1100000] of longint;\n b: array [0..1100, 0..1100] of longint;\n c: array [0..1100, 0..1100] of char;\n s, ss, st: string;\n n, i, j, k, q, res, cur, ans, t, l, r: longint;\n\nbegin\n {$ifndef online_judge}\n\t\treset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n\n read(n);\n res := n - 10;\n if res <= 0 then begin\n\t\twriteln(0);\n end else\n if (res > 0) and (res <= 9) then begin\n\t\twriteln(4);\n end else\n if res = 10 then begin\n\t\twriteln(15);\n end else\n if res = 11 then begin\n writeln(4);\n end;\n\nend.\n"}, {"source_code": "program Project2;\n\n\nuses\n SysUtils;\n{$APPTYPE CONSOLE}\n\nvar\n l,b,n,i,m,f,k,s:integer;\n a:Array[1..1000000] of integer;\n\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n {$ENDIF}\n read(n);\n if n < 11 then begin\n writeln(0);\n halt;\n end;\n n := n - 10;\n if n = 10 then begin\n writeln(15);\n halt;\n end;\n for i := 2 to 11 do\n if n = i then begin\n writeln(4);\n halt;\n end;\n writeln(0);\nend.\n"}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif n<10 then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "Program a104;\nconst\na:array [1..5] of byte=(0,12,13,14,15);\nb:array [1..10] of byte=(1,2,3,4,5,6,7,8,9,11);\nc=10;\nVar\nn,m,i:byte;\nBegin\nReadln(n);\nm:=n-10;\nFor i:=1 to 5 do\n if m=a[i] then Writeln(0);\nFor i:=1 to 10 do\n if m=b[i] then Writeln(4);\nif m=c then Writeln(15);\nend."}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a < 0 then writeln ('')\n else\n if x = 10 then writeln ('0')\n else if x <= 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 22 then writeln (15*4)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var\n\tar:array[1..11] of longint;\n\tans,i,n:longint;\n\n\nbegin\n\tfor i:=2 to 9 do\n\tbegin\n\t\tar[i]:=4;\n\tend;\n\t\n\tar[10]:=15;\n\t\n\tar[1]:=1;\n\tar[11]:=1;\n\t\n\treadln(n);\n\tdec(n,10);\n\t\n\tfor i:=1 to 11 do\n\tbegin\n\t\tif (n-i=0) then\n\t\tbegin\n\t\t\tinc(ans,ar[i]);\n\t\tend;\n\tend;\n\t\n\twriteln(ans);\n\n\n\nend."}, {"source_code": "var\n i,n,m,k,ans:longint;\n\n\n\nbegin\n readln(n);\n for i:=1 to 11 do\n if (i=10) and (i+10=n) then inc(ans,15)\n else\n if (i+10=n) then inc(ans,4);\n writeln(ans);\n end.\n"}, {"source_code": "//Yerzhan Dyussenaliyev\n{$o-}\nUses\n Math, SysUtils;\nconst\n inf = maxlongint div 3;\n dx: array [1..4] of longint = (0, 0, -1, 1);\n dy: array [1..4] of longint = (1, -1, 0, 0);\nvar\n a: array [0..1100000] of longint;\n b: array [0..1100, 0..1100] of longint;\n c: array [0..1100, 0..1100] of char;\n s, ss, st: string;\n n, i, j, k, q, res, cur, ans, t, l, r: longint;\n\nbegin\n {$ifndef online_judge}\n\t\treset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n\n read(n);\n res := n - 10;\n if res <= 0 then begin\n\t\twriteln(0);\n end else\n if (res > 0) and (res <= 9) then begin\n\t\twriteln(4);\n end else\n if res = 10 then begin\n\t\twriteln(15);\n end else\n if res = 11 then begin\n writeln(4);\n end;\n\nend.\n"}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nn:=n-10;\ncase n of 0: writeln ('0');\n 1,11: writeln ('2');\n 2..9: writeln ('4');\n 10: writeln ('15');\n 12..15: writeln('0');\nend;\nend."}, {"source_code": "var\na,i,n: integer;\nbegin\nread(n);\nif (n-10<2) or (n-10>11) then\n write(0)\nelse \n begin\n if n-10=10 then\n write(15)\n else\n write(4);\n end;\nend. "}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a = 0 then writeln ('0')\n else if x <= 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else\n writeln (15+4);\nend."}, {"source_code": "var\n z,n,a:longint;\nbegin\n readln(n);\n z:=n-10;\n if z<1 then writeln(0) else\n begin\n if z=10 then\n begin\n writeln(15);\n halt;\n end;\n writeln(4);\n end;\nend.\n"}, {"source_code": "var\nn:longint;\nbegin\n// assign(input,'a.in'); reset(input);\n// assign(output,'a.out'); rewrite(output);\n read(n);\n if (n<10) then writeln(1) else\n if n=10 then writeln(0) else\n if (n>10) and (n<20) then writeln(4) else\n if (n=20) then writeln(15) else\n writeln(4);\n// close(input);\n// close(output);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j : integer;\n a : array[1..100000] of integer;\n\nbegin\n read(n);\n dec(n, 10);\n if (n <= 11) and (n >= 1) and (n <> 10) then writeln(4)\n else\n if n = 10 then writeln(15)\n else\n if n = 0 then writeln(0);\n readln;readln;\nend.\n "}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nif n<=10 then write(0) else\nif (n>10) and (n<>20) and (n<26) then write(15) else\nwrite(15);\nreadln;\nend."}, {"source_code": "var n:integer;\nbegin\nread(n);\nn:=n-10;\nif n<0 then write(0);\nif n=0 then write(0);\nif (n>1) and (n<10) then write(4);\nif (n=1) or (n=11) then write(1);\nif n=10 then write(15);\nif n>11 then write(0);\nend."}, {"source_code": "var n: longint;\nbegin\nread (n);\nif ((n >= 12) and (n <= 18))or(n = 21) then write ('4') else\nif n = 20 then write ('11') else write ('0');\n\nend.\n"}, {"source_code": "const a:array[1..11] of integer = (4,4,4,4,4,4,4,4,4,15,4);\nvar n:integer;\nbegin\nreadln(n);\nif (n>10) and (n<14) then writeln(a[n-10])\n else writeln(0);\nend."}, {"source_code": "Var\n n: Int64;\n\nBegin\n Read(n);\n n -= 10;\n If (n > 0) and (n <= 21) then Begin\n If n = 10 then\n Write(15)\n Else If (n = 11) or (n <= 9) then\n Write(4)\n End\n Else\n Write(0);\nEnd."}, {"source_code": "program blackjack;\n\nvar\n n : integer;\n\nbegin\n read(n);\n\n n := n - 10;\n\n if (n = 0) or (n > 11) then write('0')\n else if (n = 10) then write ('15')\n else write('4');\n\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$o-}\n{$j+}\nuses\n SysUtils;\nvar n:integer;\nfin,fout:text;\nbegin\n assign(fin,'');\n assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,n);\n if n<12 then writeln(fout,0);\n if (n>11) and (n<20) then writeln(fout,4);\n if n=20 then writeln(fout,15);\n if n=21 then writeln(fout,4);\n close(fin); close(fout);\nend.\n"}, {"source_code": "program p1;\nvar n:integer;\nbegin\n readln(n);\n if ((n>=1) and (n<=10)) or ((n>=22) and (n<=25)) then writeln('0');\n if ((n>=11) and (n<=19)) and (n=21) then writeln('4');\n if n=20 then writeln('15');\nend.\n"}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\nvar\n n,sum: integer;\nbegin\n read(n);\n sum:=n-10;\n if sum=0 then write(0)\n else if sum=10 then write(15)\n else write(4);\nend."}, {"source_code": "program p1;\nvar n:integer;\nbegin\n readln(n);\n if ((n>=1) and (n<=10)) or ((n>=22) and (n<=25)) then writeln('0');\n if ((n>=11) and (n<=19)) and (n=21) then writeln('4');\n if n=20 then writeln('15');\nend.\n"}, {"source_code": "Var n,k,i,s,x:longint;\nBegin\n Readln(n);\n n:=n-10;\n if(n<10)and(n>0)\n then writeln('4')\n else if n=10\n then writeln('15')\n else writeln('0');\n\nEnd.\n"}, {"source_code": "var n,i :longint;\n a :array[0..12] of longint;\nbegin\n read(n);\n for i:=2 to 9 do\n a[i]:=4;\n a[0]:=0;\n a[10]:=15;\n a[11]:=4;\n write(a[n-10]);\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif n<10 then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "{$mode objfpc}\n\n\nvar i , n : integer;\n\n\nprocedure Result( res : integer );\n begin\n writeln( res );\n halt;\n end;\n\n\nbegin\n readln( n );\n if ( n <= 10 ) or ( n > 21 ) then Result( 0 );\n if ( n < 20 ) or ( n = 21 ) then\n Result( 1 );\n if n = 20 then\n Result( 15 );\nend.\n"}, {"source_code": "Var n,k,i,s,x:longint;\nBegin\n Readln(n);\n n:=n-10;\n if(n<10)and(n>0)\n then writeln('4')\n else if n=10\n then writeln('15')\n else writeln('0');\n\nEnd.\n"}, {"source_code": "program p1;\nvar n:integer;\nbegin\n readln(n);\n if ((n>=1) and (n<=10)) or ((n>=22) and (n<=25)) then writeln('0');\n if ((n>=11) and (n<=19)) and (n=21) then writeln('4');\n if n=20 then writeln('15');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,i: byte;\n count: byte;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n read(n);\n n:=n-12;\n count:=0;\n for i:=2 to 9 do if i=n then count:=count+4;\n if n=10\n then count:=count+15;\n if (n=1) or (n=11)\n then count:=count+4;\n writeln(count);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n res,n : longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n n := n - 10;\n if (n = 1) or (n = 0) then res := 0\n else if (n < 10) then res := 4\n else if n = 10 then res := 15;\n Assign(f,fo);\n rewrite(f);\n Writeln(f,res);\n Close(f);\n End."}, {"source_code": "var\nn,i,z,q,g : longint;\na : array[1..62] of longint;\nbegin\ni:=1;\ng:=1;\nwhile i<37 do\nbegin\n g:=g+1;\n a[i]:=g;\n i:=i+1;\n if g=10 then\n g:=1;\nend;\nfor i:=41 to 51 do\n a[i]:=10;\nfor i:=53 to 57 do\n a[i]:=11;\nfor i:=58 to 62 do\n a[i]:=1;\nreadln(n);\nz:=10;\nq:=0;\nif n<>z then\nbegin\n for i:=1 to 62 do\n begin\n if z + a[i] = n then\n q:=q+1;\n end;\nend;\nwriteln(q);\nend."}, {"source_code": "var a:array[1..25] of longint;\n n:longint;\n i:integer;\nBegin\nread(n);\nfor i:=1 to 10 do\na[i]:=0;\nfor i:=11 to 19 do\na[i]:=4;\na[20]:=15;\nfor i:=21 to 25 do\na[i]:=4;\nwrite(a[n]);\nend."}, {"source_code": "program Project2;\n\n\nuses\n SysUtils;\n{$APPTYPE CONSOLE}\n\nvar\n l,b,n,i,m,f,k,s:integer;\n a:Array[1..1000000] of integer;\n\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n {$ENDIF}\n read(n);\n n := n - 10;\n if n = 10 then begin\n writeln(15);\n halt;\n end;\n if n < 2then begin\n writeln(0);\n halt;\n end;\n write(4);\nend.\n"}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var\nn,i,z,q,g : longint;\na : array[1..62] of longint;\nbegin\ni:=1;\ng:=1;\nwhile i<37 do\nbegin\n g:=g+1;\n a[i]:=g;\n i:=i+1;\n if g=10 then\n g:=1;\nend;\nfor i:=41 to 51 do\n a[i]:=10;\nfor i:=54 to 57 do\n a[i]:=11;\nfor i:=58 to 62 do\n a[i]:=1;\nreadln(n);\nz:=10;\nq:=0;\nif n<>z then\nbegin\n for i:=1 to 62 do\n begin\n if z + a[i] = n then\n q:=q+1;\n end;\nend;\nwriteln(q);\nend."}, {"source_code": "uses\n SysUtils;\n var n:integer;\nbegin\nreadln(n);\nn:=n-10;\nif n=1 then begin writeln(4+4);halt;end;\nif n=11 then begin writeln(4);halt;end;\nif n=10 then begin writeln(15);halt;end;\nif (n<10) or (n=0) then begin writeln(4);halt;end;\nwriteln(0);\nend."}, {"source_code": "Uses\n Sysutils;\nVar\n n:integer;\nBegin\n readln(n);\n n:=n-10;\n case n of \n 0,12..15:write(0);\n 1..9,11:write(4);\n 10:write(15);\n end;\nend. "}, {"source_code": "program bangke;\nvar\n x, a : longint;\nbegin\n readln (x);\n a := x - 10;\n if a <= 0 then writeln ('0')\n else if x < 21 then\n begin\n if a = 10 then writeln (4*4-1)\n else writeln ('4');\n end\n else if x = 21 then writeln (15*4+4)\n else if x = 22 then writeln (15*4+4*3)\n else writeln (15*4+4*4);\nend."}, {"source_code": "var n:longint;\n begin\n read(n);\n n:=n-10;\n if n=10 then write(15)\n else\n if (n>0) and (n<15) then write(4)\n else write(0);\n end."}], "src_uid": "5802f52caff6015f21b80872274ab16c"} {"source_code": "var\n\ta,b: integer;\n\tcnt: integer;\nbegin\n\treadln(a,b);\n\tif (a+b)>=3 then\n\twhile (a>0) and (b>0) do\n\tif a>b then\n\tbegin\n\t\tinc(a,-2);\n\t\tinc(b);\n\t\tinc(cnt);\n\tend else\n\tbegin\n\t\tinc(a);\n\t\tinc(b,-2);\n\t\tinc(cnt);\n\tend;\n\twriteln(cnt);\nend.", "positive_code": [{"source_code": "var a,b,ans:longint;\nbegin\n read(a,b);\n if (a=1)and(b=1)\n then begin write(0);halt;end;\n while (a>0)and(b>0) do\n begin\n\n if a>b\n then begin a:=a-2;b:=b+1;end\n else begin b:=b-2;a:=a+1;end;\n inc(ans);\n end;\n write(ans);\n\n\nend."}, {"source_code": "var x:array[-10..210,-10..210] of longint;\n i,j,n,m,a,b:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a)\n else exit(b);\nend;\nbegin\n for i:=3 to 200 do\n for j:=1 to i-1 do\n x[i,j]:=max(x[i-1,j-2],x[i-1,j+1])+1;\n readln(a,b);\n writeln(x[a+b,b]);\nend.\n"}, {"source_code": "var\n n,m,ans,t:longint;\nbegin\n read(n,m);\n if (n=1)and(m=1) then\n begin\n writeln(0);\n halt;\n end;\n if n+m=3 then\n begin\n writeln(1);\n halt;\n end;\n ans:=0;\n if n>m then\n begin\n t:=n;n:=m;m:=t;\n end;\n while abs(n-m)>1 do\n begin\n inc(n);\n dec(m,2);\n inc(ans);\n end;\n if n2) or (b>2) do\nbegin\nif(a>b) then\nbegin\ntmp:=a;\na:=b;\nb:=tmp;\nend;\nif(b mod 2=0) then\nbegin\nt:=t+((b-2) div 2);\na:=a+((b-2) div 2);\nb:=2;\nend else begin\nt:=t+((b-1) div 2);\na:=a+((b-1) div 2);\nb:=1;\nend;\nend;\nwriteln(t+1);\nend.\n\n\n"}, {"source_code": "Program qq;\nVar a,b,t,r:LongInt;\nbegin\n Readln(a,b);\n While (a>0) and (b>0) do\n begin\n If a>b\n then begin\n Dec(a,2);\n Inc(b);\n end\n else begin\n Inc(a);\n Dec(b,2);\n end;\n If (a>=0) and (b>=0)\n then Inc(t);\n end;\n Writeln(t);\nEnd.\n"}, {"source_code": "Program qq;\nVar a,b,t,r:LongInt;\nbegin\n Readln(a,b);\n While (a>0) and (b>0) do\n begin\n If a>b\n then begin\n Dec(a,2);\n Inc(b);\n end\n else begin\n Inc(a);\n Dec(b,2);\n end;\n If (a>=0) and (b>=0)\n then Inc(t);\n end;\n Writeln(t);\nEnd.\n"}, {"source_code": "var a,b,t:longint;\nbegin\n readln(a,b);\n if(a<=1)and(b<=1) then writeln(0)\n else\n begin\n while((a>0)and(b>0)) do\n begin\n if(a>=b) then\n begin\n b:=b+1;\n a:=a-2;\n end\n else\n begin\n b:=b-2;\n a:=a+1;\n end;\n t:=t+1;\n end;\n writeln(t);\n end;\nend.\n"}, {"source_code": "var a,b,res,c:longint;\nbegin\n readln(a,b);\n\n res:=0;\n while (a>2) or (b>2) do\n begin\n if a2) then G(b1-2,b2+1,t+1)\n else if (b2>1) and (b1>0) then G(b2-2,b1+1,t+1)\n else Tmax:=t+(b1 div 2)\n end;\nBegin\n Readln(a1,a2);\n Tmax:=0;\n G(a1,a2,Tmax);\n Writeln(Tmax);\nEnd."}, {"source_code": "uses math;\nvar\n a,b,c,t : longint;\n\nbegin\n readln(a,b);\n if (a <= 1) and (b <= 1) then begin writeln(0); halt; end;\n while min(a,b) > 0 do begin\n if a < b then begin inc(a); dec(b,2); end else\n begin inc(b); dec(a,2); end;\n inc(c);\n end;\n writeln(c);\nend."}, {"source_code": "Var a,b,i,m,j,k,l,o:LongInt;\nProcedure UpA;\n Begin\n Inc(a);\n Dec(b,2);\n end;\nProcedure UpB;\n begin\n Inc(b);\n Dec(a,2);\n end;\n Begin\n //assign(input,'in.in'); reset(input); assign(output,'out.out'); rewrite(output);\n Read(a,b);\n While (a>0) and (b>0) do\n Begin\n if (a>1) or (b>1) then Inc(k);\n if a0) and (a2>0) do\n begin\n if (a1=1) and (a2=1) then\n break;\n if (a1>a2) or (a2=1) then\n begin\n dec(a1,2);\n inc(a2);\n end\n else\n begin\n inc(a1);\n dec(a2,2);\n end;\n inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "var\ni,j,c,d,e,b,n,x,y:longint;\nbegin\nreadln(x,y);\nif (x=1) and (y=1) then writeln(0)\nelse\nbegin\nwhile(x>0) and (y>0) do\nbegin\ninc(e);\nif x0) and (b<>0) do\nbegin \nif (a=1) and (b=1) then\nbreak;\nif (a>=b) then \nbegin\na:=a-2;\nb:=b+1;\ni:=i+1;\nend\nelse begin\nb:=b-2;\na:=a+1;\ni:=i+1;end;\nend;\nwrite(i);end."}, {"source_code": "program cf651A;\nvar a,b,t:longint;\nbegin\nread(a,b);\nt:=0;\nwhile (a>0) and (b>0) and (a+b>2) do\n begin\n inc(t);\n if a1)or(m>1) then begin\n repeat\n inc(z);\n if n0)then exit(f[x,y]);\nf[x,y]:=max(mm(x-2,y+1),mm(x+1,y-2))+1;\nexit(f[x,y]);\nend;\nbegin\nreadln(a,b);\nans:=mm(a,b);\nif ans<0 then ans:=0;\nwriteln(ans);\nend.\n"}, {"source_code": "Uses sysutils, math;\nvar\na,s,r:longint;\nbegin\nread(a,s);\nr:=0;\nwhile (max(a,s)>1)\nand (min(a,s)>0) do\nbegin\nif a>s then begin\ns:=s+1; a:=a-2;\nend else\nbegin a:=a+1;\ns:=s-2; end;\ninc(r); end;\nwrite(r); end."}, {"source_code": "var pg, vg, kolmin, minim, maxim, ng : integer;\nbegin\n readln(pg, vg);\n While ((pg > 0) and (vg > 0)) and ((pg > 1) or (vg > 1)) do\n begin\n inc(kolmin);\n If pg < vg then ng := 1\n else ng := 2;\n minim := Min(pg,vg);\n maxim := Max(pg,vg);\n inc(minim);\n dec(maxim,2);\n If ng = 1 then begin\n pg := minim;\n vg := maxim;\n end\n else begin\n vg := minim;\n pg := maxim;\n end;\n end;\n writeln(kolmin);\nend."}, {"source_code": "uses math;\nvar n,m,kol:longint;\nbegin\n\nreadln(n,m);\n\nkol:=0;\nwhile(n<>0) and(m<>0) do\nbegin\ninc(kol);\nif n 1) or (b > 1) then\n repeat\n ans += 1;\n if a < b then begin\n a := a + 1;\n b := b - 2;\n end \n else \n begin\n a := a - 2;\n b := b + 1;\n end;\n until (a < 1) or (b < 1);\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar a1,a2,i,t:integer;\nbegin\nreadln(a1,a2);\nif a1>a2 then begin t:=a1; a1:=a2; a2:=t; end;\ni:=0;\nwhile abs(a1-a2)>1 do\nbegin\ninc(a1);\na2:=a2-2;\ninc(i);\nend;\nif (a2<=1) and (a1<=1) then writeln(i) else\nif a1=a2 then\nwriteln(i+(min(a1,a2)-2)*2+1) else writeln(i+(min(a1,a2)-2)*2+3)\nend.\n"}, {"source_code": "var d,a1,a2:integer;\nbegin\nreadln(a1,a2);\nd:=0;\nwhile true do begin\n while (a1>1) do begin\n a1:=a1-2;\n a2:=a2+1;\n d:=d+1;\n end;\n while (a2>1) do begin\n a2:=a2-2;\n a1:=a1+1;\n d:=d+1;\n end; \n if (a1=0) and (a2<2) then begin\n Break;\n writeln(d-1);\n end;\n if (a2=0) and (a1<2) then begin\n Break;\n writeln(d-1);\n end;\n if (a1=1) and (a2=1) then begin\n Break; \n writeln(d);\n end;\nend;\nif d<>0 then\nwriteln(d-1)\nelse\nwriteln(d);\nend."}, {"source_code": "program joysticks;\n\nvar\n\na, b, o : integer;\ninv : boolean;\n\nbegin\n\n read (a);\n read (b);\n if a < b then inv := false else inv := true;\n\n while (a > 0) and (b > 0) do begin\n\n if (a = 1) and (b = 1) then break;\n\n if inv = false then begin\n\n inc (a);\n dec (b, 2);\n inc (o);\n if b <= 2 then inv := true;\n\n end else begin\n\n inc (b);\n dec (a, 2);\n inc (o);\n if a <= 2 then inv := false;\n\n end;\n\n end;\n\n writeln (o);\n\nend.\n"}, {"source_code": "//codeforces\n//651A\n\nprogram Joysticks;\n\nconst //stdio format\n fi='';\n fo='';\n\nvar\n f:text;\n a,b,ans:longint;\n\nbegin\n //read\n assign(f,fi);\n reset(f);\n readln(f,a,b);\n close(f);\n //act\n ans:=0;\n while (a>1) or (b>1) do begin\n if a0) and (y>0) do\n begin\n inc(s);\n if x0)and(b>0) do\n begin\n if b0)and(b>0))and(not((a=1)and(b=1)))) do begin\n if b>a then flag:=1\n else flag:=2;\n if a=1 then flag:=1;\n if b=1 then flag:=2;\n if a>=100 then a:=100;\n if b>=100 then b:=100;\n if flag=1 then begin\n a:=a+1;\n b:=b-2;\n end;\n if flag=2 then begin\n a:=a-2;\n b:=b+1;\n end;\n m:=m+1;\nend;\nwriteln(m);\nend."}, {"source_code": "var\n m, cur, ans, n: longint;\nbegin\n readln(n, m);\n if (n=1) and (m=1) then begin\n Writeln(0);\n halt;\n End;\n while (m > 0) and (n > 0)do \n begin\n if n = m then begin\n inc(m);\n dec(n, 2);\n inc(ans);\n continue;\n end;\n if n > m then begin\n inc(m);\n dec(n, 2);\n inc(ans);\n continue;\n end;\n inc(n);\n dec(m, 2);\n inc(ans);\n end;\n Writeln(ans);\nend."}, {"source_code": "var\na,b,otv:longint;\nbegin\nreadln(a,b);\nif (a=1)and(b=1) then writeln(0)else begin\nwhile (a>0)and(b>0) do begin\n if a>b then begin\n inc(otv);\n dec(a,2);\n inc(b);\n end else begin\n inc(otv);\n inc(a);\n dec(b,2);\n end;\nend;\n\nwriteln(otv);\nend;\nend."}, {"source_code": "var c, a, b:longint;\n\nbegin\n readln(a, b);\n while (a > 0)and(b > 0) do\n begin\n if (a = 1) and (b = 1)\n then\n break;\n if a < b\n then\n begin\n a := a + 1;\n b := b - 2;\n c := c + 1;\n end\n else\n begin\n a := a - 2;\n b := b + 1;\n c := c + 1;\n end;\n end;\n writeln(c);\nend.\n"}, {"source_code": "program A_651;\n\nvar\n a,b,z,t,ans:longint;\n\nbegin\n read(a,b);\n if (a=1)and(b=1)\n then begin\n write('0');\n exit;\n end;\n while not(((a=1)or(a=2))and((b=1)or(b=2))) do\n begin\n if b>a\n then begin\n z:=a;\n a:=b;\n b:=z;\n end;\n t:=(a-1)div 2;\n b:=b+t;\n ans:=ans+t;\n a:=a-2*t;\n end;\n write(ans+1);\nend."}, {"source_code": "var a1, a2, k, e:integer;\nbegin\nread (a1, a2);\nif (a1 > 1) or (a2>1) then k:=1 else k:=0;\nwhile (a1 > 2) or (a2>2) do begin\n if a1 >= a2 then begin\n if a1 mod 2 = 0 then e:=a1 div 2 -1\n else e:= a1 div 2;\n k:=k+e;\n a1:=a1-e*2;\n a2:=a2+e;\n end\n else begin\n if a2 mod 2 = 0 then e:=a2 div 2 -1\n else e:= a2 div 2;\n k:=k+e;\n a2:=a2-e*2;\n a1:=a1+e;\n end;\nend;\nwriteln (k);\nend.\n"}, {"source_code": "var a,b,ans:LongInt;\n f:boolean;\nBegin\n Read(a,b);\n f:=true;\n if(a=1)and(b=1)then begin Write(0); halt; end;\n while(a>0)and(b>0)do\n begin\n if(a-2<1)then\n f:=false;\n if(b-2<1)then\n f:=true;\n if(f)then begin inc(b); dec(a,2); inc(ans); end\n else begin inc(a); dec(b,2); inc(ans); end;\n end;\n Write(ans);\nEnd.\n"}, {"source_code": "const\n\tfi = '';\n\tfo = '';\nvar a, b, c:longint;\nbegin\n\tassign(input, fi); reset(input);\n\tassign(output, fo); rewrite(output);\n\treadln(a, b);\n\tc:=0;\n\twhile (a>0) and (b>0) do\n begin\n if (a=1) and (b=1) then break;\n c:=c+1;\n if a0) and (b>0)) do\n begin\n if (a=1) then\n begin\n inc(a);\n dec(b,2);\n end\n else if (b=1) then begin inc(b); dec(a,2); end\n else if (a<=b) then begin inc(a); dec(b,2); end\n else if (b1) or (m>1) then\nrepeat\ninc(c);\nif n 0) and (b > 0) do begin\n a -= 2;\n b -= 2;\n if a < b then\n a += 3\n else\n b += 3;\n \n k += 1\n end;\n \n if (a < 0) or (b < 0) then\n k -= 1;\n \n writeln(k)\nEND."}, {"source_code": "const fi='651A.inp'; fo='651A.out';\nvar x,y,res: longint;\nbegin\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n readln(x,y);\n while (x<>0) and (y<>0) do\n begin\n if x>y then begin\n dec(x,2); inc(y);\n end\n else begin\n inc(x); dec(y,2);\n end;\n if (x<0) or (y<0) then begin write(res); halt; end;\n inc(res);\n end;\n write(res);\nend.\n"}, {"source_code": "var a,b,c,i,j,m,n,x,y:longint;\n q:array[0..1000000]of longint;\nprocedure qs(l,r:longint);\nbegin\n i:=l;\n j:=r;\n x:=q[(l+r)div 2];\n repeat\n while q[i]x do dec(j);\n if i<=j then\n begin\n y:=q[i];\n q[i]:=q[j];\n q[j]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if i0)and(b>0)do\n begin\n x:=a div 2;\n if a mod 2=0 then\n begin\n dec(x);\n a:=2;\n end else\n a:=1;\n b:=b+x;\n c:=c+x;\n x:=a;\n a:=b;\n b:=x;\n if(a=2)or(a=1)then break;\n //writeln(a,' ',b,' ',c);\n end;\n writeln(c+1);\nend.\n"}, {"source_code": "const fi='';\n fo='';\n\nprocedure solve;\nvar i,a,b:int32;\nbegin\n read(a,b);\n i:= 0;\n while ((a>=2) and (b>0)) or ((b>=2) and (a>0)) do\n begin\n inc(i);\n if aj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[i-1].x then\n begin\n qsortlr(l,i-1);\n l:= i;\n res:= res+k*int64(k-1) div 2;\n k:= 1;\n end\n else\n inc(k);\n m:= 0; l:= 1;\n for i:= 2 to n+1 do\n begin\n if (a[i].x=a[i-1].x) and (a[i].y=a[i-1].y) then\n begin\n inc(l);\n end\n else\n begin\n if l>1 then\n begin\n inc(m); b[m]:= l;\n end;\n l:= 1;\n end;\n end;\n qsorty;\n k:= 1;\n for i:= 2 to n+1 do\n if a[i].y<>a[i-1].y then\n begin\n res:= res+k*int64(k-1) div 2;\n k:= 1;\n end\n else inc(k);\n for i:= 1 to m do\n res:= res-b[i]*int64(b[i]-1) div 2;\n write(res);\nend;\nprocedure enter;\nvar i:int32;\nbegin\n readln(n);\n for i:= 1 to n do with a[i] do readln(x,y);\nend;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n enter;\n solve;\n close(input);\n close(output);\nend.\n}"}, {"source_code": "var n,m:longint;\n i,time:longint;\nbegin\nreadln(n,m);\nwhile (n>0) and (m>0) do\nbegin\n if (n=1) and (m=1)\n then break;\n\n if n0) and (m>0) do\n begin\n l:=l+1;\n if n>m then\n begin\n n:=n-2;\n m:=m+1;\n end\n else\n begin\n n:=n+1;\n m:=m-2;\n end;\n end;\n\nwrite(l);\nend.\n"}, {"source_code": "program Joysticks;\n\nvar a1, a2, temp, minute: byte;\n\nbegin\n readln(a1, a2);\n\n minute:= 0;\n\n if a1 <= a2 then\n while (a1 > 0) and (a2 > 0) do\n begin\n inc(minute);\n\n inc(a1);\n dec(a2, 2);\n\n if (a2 = 1) or (a2 = 2) then\n begin\n temp:= a1;\n a1 := a2;\n a2 := temp;\n end;\n end\n else\n while (a1 > 0) and (a2 > 0) do\n begin\n inc(minute);\n\n inc(a2);\n dec(a1, 2);\n\n if (a1 = 1) or (a1 = 2) then\n begin\n temp:= a1;\n a1 := a2;\n a2 := temp;\n end;\n end;\n\n writeln(minute);\n\n readln\nEND.\n\n\n"}, {"source_code": "var\na,b,c,d:integer;\nbegin\nreadln(a,b);\nrepeat\nif a-2>0 then\n begin\n a:=a-2;\n b:=b+1;\n inc(c);\n end\nelse\nif b-2>0 then \n begin\n b:=b-2;\n a:=a+1;\n inc(c);\n end\nelse \n\nbegin\na:=a-2;\nb:=b-2;\nif (a=0) or (b=0) then\ninc(c);\nend;\nuntil (a<=0) or (b<=0);\nwriteln(c);\nreadln;\nreadln;\nend."}, {"source_code": "var a, b, ans, tam: longint;\nbegin\n readln(a,b);\n ans:=0;\n if a > b then\n begin\n tam:=a;\n a:=b;\n b:=tam;\n end;\n if (a = 1) and (b = 1) then ans:=-1; \n while b > 0 do\n begin\n inc(ans);\n a:=a+1;\n b:=b-2;\n if b <= 0 then break;\n if b <= 2 then\n begin\n tam:=a;\n a:=b;\n b:=tam;\n end;\n end;\n write(ans);\nend.\n"}, {"source_code": "var\na,b,i:longint;\nbegin\nreadln(A,b);\nwhile ((A>1)and(b>0))or((b>1)and(a>0))do begin\ninc(I);\nif a2)or(a>2)do\nif a>=s then\n while a>1 do\nbegin\ndec(a,2);\ninc(s);\ninc(d);\nif a=0 then begin inc(a,2); dec(s); dec(d); break; end;\nend else\nwhile s>1 do\nbegin\ndec(s,2);\ninc(a);\ninc(d);\nif s=0 then begin inc(s,2); dec(a); dec(d); break; end;\nend;\nif(a>1)or(s>1)then\ninc(d);\nwriteln(d);\nend.\n"}, {"source_code": "var\n ans, a, b, f : longint;\nbegin\n read(a, b);\n while (a > 0) and (b > 0) do\n begin\n if a > b\n then\n begin\n f := 2;\n dec(a, 2);\n inc(b, 1);\n end\n else\n begin\n f := 2;\n dec(b, 2);\n inc(a, 1);\n end;\n inc(ans);\n end;\n if (a < 0) or (b < 0)\n then\n dec(ans);\n writeln(ans);\nend."}, {"source_code": "var a,b,i:longint;\n\nbegin\nread(a,b);\nwhile (a>0) and (b>0) do\nbegin\nif b=0 then\n i:=i+1;\n end\n else\n begin\n b:=b-2;\n a:=a+1;\n if b>=0 then\n i:=i+1;\n end;\nend;\n writeln(i);\n end."}, {"source_code": "var\n a,b:longint;\n\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a) else exit(b);\nend;\n\nfunction min(a,b:longint):longint;\nbegin\n if a2) and (not mark[a1-2,b1+1]) then\n begin\n mark[a1-2,b1+1]:=true;\n d[a1-2,b1+1]:=d[a1,b1]+1;\n push(a1-2,b1+1);\n end;\n if (b1>2) and (not mark[a1+1,b1-2]) then\n begin\n mark[a1+1,b1-2]:=true;\n d[a1+1,b1-2]:=d[a1,b1]+1;\n push(a1+1,b1-2);\n end;\n end;\n res:=0;\n for i:=1 to 150 do\n for j:=1 to 150 do res:=max(res,d[i,j]);\n if ((a=2) and (b=1)) or ((a=1) and (b=2))\n or ((a=2) and (b=2)) then res:=0 else\n if (a<=2) and (b<=2) then res:=-1;\n writeln(fo,res+1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\na,b,c,d,e,temp:integer;\nbegin\nreadln(a,b);\nif a<=b then begin c:=a; d:=b; end else begin c:=b; d:=a; end;\ne:=0;\nwhile (c>0) and (d>0) do\n begin\n inc(c);\n dec(d,2);\n inc(e);\n if d<=2 then begin temp:=c;c:=d;d:=temp; end; \n end;\nif (a<=1) and (b<=1) then writeln(0) else writeln(e);\nend."}, {"source_code": "var\n a1, a2, ans, dis, cha: longint;\n\nfunction max(a, b: longint): longint;\nbegin\n if a > b then max:= a\n else max:= b;\nend;\n\nfunction min(a, b: longint): longint;\nbegin\n if a > b then min:= b\n else min:= a;\nend;\n\n\nbegin\n readln(a1, a2);\n while (a1 > 0) and (a2 > 0) do\n begin\n if (a1 = 1) and (a2 = 1) then break;\n if a1 > a2 then\n begin\n dec(a1, 2); inc(a2);\n end\n else\n begin\n dec(a2, 2); inc(a1);\n end;\n inc(ans);\n end;\n writeln(ans); \nend."}, {"source_code": "var a,b,sum:int64;\nbegin\nreadln(a,b);\nwhile(a>0)and(b>0)do\n begin\n if(a=1)and(b=1)then break;\n if(a 2) and (a1>0) and (a2>0) ) do\nbegin\n if ((a1 = 1) or (a1=2) )\n then\n begin\n a1:= a1+1;\n a2 := a2-2;\n end\n else\n if ( (a2 = 1) or (a2=2))\n then\n begin\n a2:=a2 +1;\n a1:= a1 - 2;\n end\n else\n begin\n a2 :=a2 +1;\n a1 := a1-2;\n end;\n\n Inc(time);\n end;\n\n write(time);\n\n read(time);\nend.\n"}, {"source_code": "program ProjectD2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nconst mmd = 2*2*2*3*3*5*7;\nvar a,n,b,c,e,d,x,y,z,res:integer; i,j,k:integer;\n s:string;\n m,t,w:array[1..1000]of integer;\n\n // r1,r2:array[1..100]of integer;\nbegin\n// reset(input,'input.txt');\n // rewrite(output,'output.txt');\n Readln(a,b);\n res:=0;\n While (a>0)and(b>0) do\n begin\n if (a=1)and(b=1)\n then break;\n inc(res);\n if a0) and (y>0) do\n begin\n inc(ans);\n if x>y then begin x:=x-2;y:=y+1;end\n else begin y:=y-2;x:=x+1;end;\n end;\n writeln(ans);\nend."}, {"source_code": "const fi='';\n fo='';\nVar d,m,n: longint;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,n,m);\n If (n=1) and (m=1) then\n Writeln(g,'0')\n Else\n Begin\n Repeat\n Begin\n inc(d);\n If n>m then\n Begin\n inc(m);\n n:=n-2;\n End\n Else\n Begin\n inc(n);\n m:=m-2;\n End;\n End;\n Until\n (m<=0) or (n<=0);\n Writeln(g,d);\n End;\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": " program solo; Var k,a,b:int64; begin readln(a,b); While ((a>0) and (b>1)) or ((a>1) and (b>0)) do begin inc(k); if a>b then begin a:=a-2; inc(b); end else begin inc(a); b:=b-2; end; end; writeln(k); End. "}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qi,ci:array[0..1000000]of int64;\n qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h]0)and(c>0)and(q*c>1)) do\n begin\n inc(res);\n if 20) and (d>0) do\n begin\n if a <= d then\n begin\n inc(a);\n dec(D,2);\n if d < 0 then\n dec(f);\n end\n else\n begin\n inc(d);\n dec(a,2);\n if a < 0 then\n dec(f);\n end;\n inc(f);\n end;\n writeln(f);\n readln;\n readln;\nend.\n\n"}, {"source_code": "var a,b,kol:int64;\nbegin\nreadln(a,b);\nkol:=0;\nwhile (a>0)and(b>0) do\nbegin\nif (a=1)and(b=1) then break;\nif (a>=b) then begin a:=a-2;b:=b+1;end else\nif (a1) or (b>1) then\nrepeat\nc+=1;\nif a0) and (a2>0) do\n begin\n if (a1>2) and (a1<=100) then begin ans:=ans+1; a1:=a1-2; a2:=a2+1; end\n else begin ans:=ans+1; a2:=a2-2; a1:=a1+1; end;\n if a2>100 then a2:=100;\n end;\n write(ans);\n\n\nend."}, {"source_code": " var a,b,ans:longint;\n\n begin\n read (a,b);\n while ((A>1) and (b>0)) or ((b>1) and (a>0)) do\n begin\n inc(ans);\n if a0)and(a2>0)do\n begin\n if a1b then\n begin\n inc(b);\n dec(a,2);\n end else\n begin\n inc(a);\n dec(b,2);\n end;\n until (a<=0)or(b<=0);\n writeln(res);\n close(input);\n close(output);\nend.\n"}, {"source_code": "uses math;\nvar n,m,kol:longint;\nbegin\n\nreadln(n,m);\n\nkol:=0;\nwhile(n<>0) and(m<>0) do\nbegin\ninc(kol);\nif n0)and(b>0) do\n begin\n inc(res);\n if a=a2) and ((a2>=1)))then\nbegin\na2:=a2+1;\na1:=a1-2;\nt:=t+1;\nend\nelse\nbegin\na1:=a1+1;\na2:=a2-2;\nt:=t+1;\nend;\nuntil a1*a2=0;\nwriteln(t);\nend."}, {"source_code": "var\n a,s,d,f:integer;\nbegin\n read(a,d);\n while (a>0) and (d>0) do\n begin\n if a <= d then\n begin\n inc(a);\n dec(D,2);\n end\n else\n begin\n inc(d);\n dec(a,2);\n end;\n inc(f);\n end;\n writeln(f);\n readln;\n readln;\nend.\n\n"}, {"source_code": "program sum_delit;\nvar\n a1,a2,x,min,time,kol,i,j:longint;\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(a1,a2);\n\n if (a1=1)and(a2=1) then writeln(1)\n else begin\n //for i:=1 to 100 do\n //for j:=1 to 100 do begin\n //kol:=0; a1:=i; a2:=j;\n if a10)and(a2>0) do begin\n time:=a1 div 2;\n\n if (a1 mod 2=0)and(time<>1) then dec(time);\n\n inc(min,time);\n\n dec(a1,2*time); inc(a2,time);\n\n if a12) or (b>2) do\n begin\n if a=2)and(b>=2) then begin a:=a+1;b:=b-2; sum:=sum+1; end;\n if(a<=2)and(b>=3) then begin a:=a+1;b:=b-2;sum:=sum+1; end;\n if(b<=2)and(a>=3) then begin b:=b+1;a:=a-2;sum:=sum+1; end;\n if(a<=2)and(b<=2) then begin a:=a+1;b:=b-2;sum:=sum+1; end;\n if (a<=0)or(b<=0) then begin write(sum);break;end;\n end;\n end."}, {"source_code": "var a,b:longint;\n i:longint;\nbegin\n readln(a,b);\n while (a+b>=3) do\n begin\n inc(i);\n if a>b\n then\n begin\n a:=a-2;\n b:=b+1;\n end else\n begin\n a:=a+1;\n b:=b-2;\n end\n end;\n writeln(i);\nend."}, {"source_code": "var\na,b: integer;\nflag: integer;\nn,m,i,j,k: longint;\n\nbegin\nReadLn(a,b);\nm:=0;\n\nwhile ((a>0)and(b>0)) do begin\n if b>a then flag:=1\n else flag:=2;\n if a=1 then flag:=1;\n if b=1 then flag:=2;\n if flag=1 then begin\n a:=a+1;\n b:=b-2;\n end;\n if flag=2 then begin\n a:=a-2;\n b:=b+1;\n end;\n m:=m+1;\nend;\nwriteln(m);\nend."}, {"source_code": "program cf651A;\nvar a,b,t:longint;\nbegin\nread(a,b);\nt:=0;\nwhile (a>0) and (b>0) do\n begin\n inc(t);\n if a 0 do begin\n if a < b then begin inc(a); dec(b,2); end else\n begin inc(b); dec(a,2); end;\n inc(c);\n end;\n writeln(c);\nend."}, {"source_code": "var a1,a2,n:integer;\nbegin\nread(a1,a2);\nif (a1<2)and(a2<2)\nthen\nwrite('0')\nelse\nwhile (a1>0)and(a2>0)do\n begin\n if a10) or (n>0) do\n Begin\n inc(d);\n If n>m then\n Begin\n inc(m);\n dec(n,2);\n End\n Else\n Begin\n inc(n);\n dec(m,2);\n End;\n End;\n End;\n Writeln(g,d);\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": "var a1,a2,k:longint;\n\nbegin\n readln(a1,a2);\n while (a1>0) and (a2>0) do\n if a1<=a2 then \n begin\n dec(a2,2);\n inc(k);\n inc(a1);\n end\n else \n begin\n dec(a1,2);\n inc(k);\n inc(a2);\n end;\n writeln(k);\nend."}, {"source_code": "program a621;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n time,a1,a2:LongInt;\n\n begin\n read ( a1 );\n read ( a2 );\n time:=0;\n while ((a1>0) and (a2>0)) do\nbegin\n if ((a1 = 1)or (a1=2) )\n then\n begin\n a1:= a1+1;\n a2 := a2-2;\n end\n else\n if ( (a2 = 1) or (a2=2))\n then\n begin\n a2:=a2 +1;\n a1:= a1 - 2;\n end\n else\n begin\n a2 :=a2 +1;\n a1 := a1-2;\n end;\n\n Inc(time);\n end;\n\n write(time);\n\n \nend.\n"}, {"source_code": "var d,a1,a2:integer;\nbegin\nreadln(a1,a2);\nd:=0;\nwhile true do begin\n while (a1>1) do begin\n a1:=a1-2;\n a2:=a2+1;\n d:=d+1;\n end;\n while (a2>1) do begin\n a2:=a2-2;\n a1:=a1+1;\n d:=d+1;\n end; \n if (a1=0) and (a2<2) then begin\n writeln(d-1);\n break;\n end;\n if (a2=0) and (a1<2) then begin\n writeln(d-1);\n break;\n end;\n if (a1=1) and (a2=1) then begin \n writeln(d);\n break;\n end;\nend;\nend."}, {"source_code": "program a621;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n time,a1,a2:LongInt;\n\n begin\n read ( a1 );\n read ( a2 );\n time:=0;\n while ((a1>0) and (a2>0)) do\nbegin\n if ((a1 = 1)or (a1=2) )\n then\n begin\n a1:= a1+1;\n a2 := a2-2;\n end\n else\n if ( (a2 = 1) or (a2=2))\n then\n begin\n a2:=a2 +1;\n a1:= a1 - 2;\n end\n else\n begin\n a2 :=a2 +1;\n a1 := a1-2;\n end;\n\n Inc(time);\n end;\n\n write(time);\n\n \nend.\n"}, {"source_code": "program zzzz;\nvar\na1,a2,t:integer;\nbegin\nreadln(a1,a2);\nt:=0;\nrepeat\nif ((a1>=a2) and (a2>=1)) then\nbegin\na2:=a2+1;\na1:=a1-2;\nt:=t+1;\nend\nelse\nbegin\na1:=a1+1;\na2:=a2-2;\nt:=t+1;\nend;\nuntil a1*a2=0;\nwriteln(t);\nend."}, {"source_code": "var\n a1, a2, ans, dis, cha: longint;\n\nfunction max(a, b: longint): longint;\nbegin\n if a > b then max:= a\n else max:= b;\nend;\n\nfunction min(a, b: longint): longint;\nbegin\n if a > b then min:= b\n else min:= a;\nend;\n\n\nbegin\n readln(a1, a2);\n while (a1 > 0) and (a2 > 0) do\n begin\n if (a1 = 1) or (a2 = 1) then break;\n if a1 > a2 then\n begin\n dec(a1, 2); inc(a2);\n end\n else\n begin\n dec(a2, 2); inc(a1);\n end;\n inc(ans);\n end;\n writeln(ans); \nend."}, {"source_code": "uses math;\n\nvar a,b,kq:longint;\n\nprocedure mofile;\nbegin\n assign(input,'CodeForces.inp');\n assign(output,'CodeForces.out');\n reset(input);\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure swap(var x,y:longint);\nvar z:longint;\nbegin\n z:=x;\n x:=y;\n y:=z;\nend;\n\nprocedure doc;\nbegin\n read(a,b);\n if a>b then swap(a,b);\nend;\n\nprocedure xuly;\nbegin\n repeat\n if b<=2 then\n begin\n inc(kq);\n break;\n end;\n while b>2 do\n begin\n dec(b,2);\n inc(a);\n inc(kq);\n end;\n swap(a,b);\n if (a<=0) or (b<=0) then break;\n until false;\n write(kq);\nend;\n\nBEGIN\n //mofile;\n doc;\n xuly;\n //dongfile;\nEND.\n\n"}, {"source_code": "var a,b:longint;\n i:longint;\nbegin\n readln(a,b);\n while (a+b>=3) do\n begin\n inc(i);\n if a>b\n then\n begin\n a:=a-2;\n b:=b+1;\n end else\n begin\n a:=a+1;\n b:=b-2;\n end\n end;\n writeln(i);\nend."}, {"source_code": "var f:array[0..500,0..500]of longint; a,b:longint;\nfunction max(x,y:longint):longint;\nbegin\nif(a0)then exit(f[x,y]);\nf[x,y]:=max(mm(x-2,y+1),mm(x+1,y-2))+1;\nexit(f[x,y]);\nend;\nbegin\nreadln(a,b);\nwriteln(mm(a,b));\nend.\n"}, {"source_code": "program joysticks;\n\nvar\n\na, b, o : integer;\ninv : boolean;\n\nbegin\n\n read (a);\n read (b);\n if a < b then inv := false else inv := true;\n\n while (a > 0) and (b > 0) do begin\n\n if inv = false then begin\n\n inc (a);\n dec (b, 2);\n inc (o);\n if b <= 2 then inv := true;\n\n end else begin\n\n inc (b);\n dec (a, 2);\n inc (o);\n if a <= 2 then inv := false;\n\n end;\n\n end;\n\n writeln (o);\n\nend.\n"}, {"source_code": "var a1,a2,i: word;\n begin\n read (a1,a2);\n if (a1<=100) and (a2<=100) then\n begin\n while (a1>1) and (a2>1) do\n begin\n i:=i+1;\n if a1>a2 then\n begin\n a1:=a1-2;\n a2:=a2+1;\n end\n else\n begin\n a1:=a1+1;\n a2:=a2-2;\n end;\n end;\n write (i);\n end;\n end."}, {"source_code": "var a,b:integer;c:word;\nbegin\nread(a,b);\nif (a=1) and (b=1) then write(0);\nwhile (a>0) and (b>0) do begin\nif a 0 do begin\n if a < b then begin inc(a); dec(b,2); end else\n begin inc(b); dec(a,2); end;\n inc(c);\n end;\n writeln(c);\nend."}, {"source_code": "var\na,b,min:longint;\nbegin\nreadln(a,b);\nwhile (a>0)and(b>0) do begin\n\n if (a=1)or(b=1) then begin\n if a=1 then begin\n inc(min);\n inc(a);\n dec(b,2);\n end\n else begin\n inc(min);\n inc(b);\n dec(a,2);\n end;\n end\n else begin\n if a>b then begin\n inc(min);\n inc(b);\n dec(a,2);\n end\n else begin\n inc(min);\n inc(a);\n dec(b,2);\n end;\n end;\n \nend;\nwriteln(min);\nend."}, {"source_code": "var\na,b,min:longint;\nbegin\nreadln(a,b);\nwhile (a>0)and(b>0) do begin\n\n if (a=1)or(b=1) then begin\n if a=1 then begin\n inc(min);\n inc(a);\n dec(b,2);\n end\n else begin\n inc(min);\n inc(b);\n dec(a,2);\n end;\n end\n else begin\n if a>b then begin\n inc(min);\n inc(b);\n dec(a,2);\n end\n else begin\n inc(min);\n inc(a);\n dec(b,2);\n end;\n end;\n \nend;\nwriteln(min);\nend."}, {"source_code": "var\n a1, a2, ans, dis, cha: longint;\n\nfunction max(a, b: longint): longint;\nbegin\n if a > b then max:= a\n else max:= b;\nend;\n\nfunction min(a, b: longint): longint;\nbegin\n if a > b then min:= b\n else min:= a;\nend;\n\n\nbegin\n readln(a1, a2);\n while (a1 > 0) and (a2 > 0) do\n begin\n if a1 > a2 then\n begin\n dec(a1, 2); inc(a2);\n end\n else\n begin\n dec(a2, 2); inc(a1);\n end;\n inc(ans);\n end;\n writeln(ans); \nend.\n\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,full:longint;\n\nProcedure calc(var x,y:longint);\nbegin\nif (x=2) or (x=1) then begin x:=0; inc(full); exit; end;\nif x mod 2=0 then begin full:=full+(x div 2)-1; y:=y+(x div 2)-1; x:=2; exit; end;\nif x mod 2=1 then begin full:=full+((x-1) div 2); y:=y+((x-1) div 2); x:=1; exit; end;\nend;\n\n\nbegin\n//assign(input,'d:\\programs\\input.txt'); reset(input);\n//assign(output,'d:\\programs\\output.txt'); rewrite(output);\nreadln(a,b);\nwhile (a>0) and (b>0) do\nbegin\nif a>b then calc(a,b) else calc(b,a);\nend;\nwrite(full);\nend.\n"}, {"source_code": "program joysticks;\n\nvar\n\na, b, o : integer;\ninv : boolean;\n\nbegin\n\n read (a);\n read (b);\n if a < b then inv := false else inv := true;\n\n while (a > 0) and (b > 0) do begin\n\n if inv = false then begin\n\n inc (a);\n dec (b, 2);\n inc (o);\n if b <= 2 then inv := true;\n\n end else begin\n\n inc (b);\n dec (a, 2);\n inc (o);\n if a <= 2 then inv := false;\n\n end;\n\n end;\n\n writeln (o);\n\nend.\n"}, {"source_code": "const n=1000000000;\nvar i,j:longint;\n ans,a1,a2:int64;\nbegin\nread(a1,a2);\nfor i:=1 to n do\nbegin\nif (a1=1) and (a2=1) then begin write(i); halt; end;\nif a10)and(b>0)do\n begin\n if(a-2<1)then\n f:=false;\n if(b-2<1)then\n f:=true;\n if(f)then begin inc(b); dec(a,2); inc(ans); end\n else begin inc(a); dec(b,2); inc(ans); end;\n end;\n Write(ans);\nEnd."}, {"source_code": "var\na,b,c,d:integer;\nbegin\nreadln(a,b);\nrepeat\nif a-2>0 then\n begin\n a:=a-2;\n b:=b+1;\n inc(c);\n end\nelse\nif b-2>0 then \n begin\n b:=b-2;\n a:=a+1;\n inc(c);\n end\nelse \n\nbegin\na:=a-2;\nb:=b-2;\ninc(c);\nend;\nuntil (a<=0) or (b<=0);\nwriteln(c);\nreadln;\nreadln;\nend."}, {"source_code": "var a1, a2, k, e:integer;\nbegin\nread (a1, a2);\nif (a1 > 2) or (a2>2) then k:=1 else k:=0;\nwhile (a1 > 2) or (a2>2) do begin\n if a1 >= a2 then begin\n if a1 mod 2 = 0 then e:=a1 div 2 -1\n else e:= a1 div 2;\n k:=k+e;\n a1:=a1-e*2;\n a2:=a2+e;\n end\n else begin\n if a2 mod 2 = 0 then e:=a2 div 2 -1\n else e:= a2 div 2;\n k:=k+e;\n a2:=a2-e*2;\n a1:=a1+e;\n end;\nend;\nwriteln (k);\nend.\n"}, {"source_code": "const fin='';\n fout='';\nvar n,m,d:longint;\n f,g:text;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,n,m);\n while (n>0)and(m>0) do\n begin\n if n>m then\n begin\n n:=n-2;\n m:=m+1;\n end\n else\n begin\n m:=m-2;\n n:=n+1;\n end;\n inc(d);\n end;\n write(g,d);\n close(f);close(g);\nend."}, {"source_code": "var a,b,res,c:longint;\nbegin\n readln(a,b);\n while (a>2) or (b>2) do\n begin\n if a=0)or(a2>=0)do\n begin\n if a12) and (not mark[a1-2,b1+1]) then\n begin\n mark[a1-2,b1+1]:=true;\n d[a1-2,b1+1]:=d[a1,b1]+1;\n push(a1-2,b1+1);\n end;\n if (b1>2) and (not mark[a1+1,b1-2]) then\n begin\n mark[a1+1,b1-2]:=true;\n d[a1+1,b1-2]:=d[a1,b1]+1;\n push(a1+1,b1-2);\n end;\n end;\n res:=0;\n for i:=1 to 150 do\n for j:=1 to 150 do res:=max(res,d[i,j]);\n if (a<=2) and (b<=2) then res:=-1;\n writeln(fo,res+1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var n,m:longint;\n i,time:longint;\nbegin\nreadln(n,m);\nwhile (n>0) and (m>0) do\nbegin\n if n0) and (d>0) do\n begin\n if a <= d then\n begin\n inc(a);\n dec(D,2);\n end\n else\n begin\n inc(d);\n dec(a,2);\n end;\n inc(f);\n end;\n writeln(f);\n readln;\n readln;\nend.\n\n"}, {"source_code": "var a1,a2,k:integer;\nbegin\nreadln(a1,a2);\nk:=0;\nif (a1<1)or(a1>100)or(a2<1)or(a2>100)then exit;\nwhile True do begin\nif (a1=0) or (a2=0) then break;\nif a1a1 then Begin\n a1:=a1+1;\n a2:=a2-2;\n End\n else Begin a2:=a2+1; a1:=a1-2; End;\n Until (a1=0) or (a2=0);\n End;\nBegin\n docfile;\n If (a1<=2) and (a2<=2) then t:=0 else xuly;\n ghifile;\nEnd.\n\n"}, {"source_code": "program ProjectD2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nconst mmd = 2*2*2*3*3*5*7;\nvar a,n,b,c,e,d,x,y,z,res:integer; i,j,k:integer;\n s:string;\n m,t,w:array[1..1000]of integer;\n\n // r1,r2:array[1..100]of integer;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n Readln(a,b);\n res:=0;\n While (a>0)and(b>0) do\n begin\n inc(res);\n if ab then begin a:=a-2; b:=b+1; end else begin a:=a+1; b:=b-2; end;\n end;\n writeln(i-1);\nend."}, {"source_code": "var a,b,dem:longint;\nbegin\n readln(a,b);\n dem:=0;\n while ((a>0) and (b>0)) do\n begin\n if (a=1) then\n begin\n inc(a);\n dec(b,2);\n end\n else if (b=1) then begin inc(b); dec(a,2); end\n else if (a<=b) then begin inc(a); dec(b,2); end\n else if (b=0)or(a2>=0)do\n begin\n if a1m then\n begin\n t:=n;n:=m;m:=t;\n end;\n while n0 do\n begin\n if a0) and (b>0) do\n begin\n c:=c+1;\n if a0) and (b>0) do\nif a>b then begin\nb:=b+1; dec(a,2); inc(c); end else begin\na:=a+1; dec(b,2); inc(c); end; \nwriteln(c); end.\n\n"}, {"source_code": "var n,m,p,r,a,x,y,c : longint;\nb,v: array[0..100000] of longint;\nda : boolean;\ns : ansistring;\nbegin\n\t\n\t\n\treadln(n,p);\n\n\twhile (n>0) and (p>0) do\n\tbegin\n\t\t\n\t\tif n<=p then\n\t\tbegin\n\t\t\tn:=n+1;\n\t\t\tp:=p-2;\n\t\tend else\n\t\t\n\t\tif n>p then\n\t\tbegin\n\t\t\tp:=p+1;\n\t\t\tn:=n-2;\n\t\tend;\n\t\tinc(r);\n\t\t\n\tend;\n\t\n\tif (n=1) and (p=1) then r:=0;\n\twriteln(r);\nend.\n"}, {"source_code": "var\na,b,min:longint;\nbegin\nreadln(a,b);\nwhile (a>0)and(b>0) do begin\n inc(min);\n if a>b then begin\n b:=b+1;\n dec(a,2);\n end\n else begin\n a:=a+1;\n dec(b,2);\n end;\nend;\nwriteln(min);\nend."}, {"source_code": "const fi='';\n fo='';\nVar d,m,n: longint;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,n,m);\n If (n=1) and (m=1) then\n Writeln(g,'0')\n Else\n Begin\n While (m>0) or (n>0) do\n Begin\n inc(d);\n If n>m then\n Begin\n inc(m);\n n:=n-2;\n End\n Else\n Begin\n inc(n);\n m:=m-2;\n End;\n End;\n End;\n Writeln(g,d);\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": "var\n a,b,c,i,j,k,m,n:longint;\nbegin\n read(a,b);\n while (a>0)and(b>0) do\n begin\n if (a<3)and(b>1) then begin inc(a); dec(b,2); end else\n begin inc(b); dec(a,2); end;\n inc(i);\n end;\n writeln(i);\nend.\n"}, {"source_code": "var\n m, cur, ans, n: longint;\nbegin\n readln(n, m);\n while (m > 0) and (n > 0) do \n begin\n if n = m then begin\n inc(m);\n dec(n, 2);\n inc(ans);\n continue;\n end;\n if n > m then begin\n inc(m);\n dec(n, 2);\n inc(ans);\n continue;\n end;\n inc(n);\n dec(m, 2);\n inc(ans);\n end;\n Writeln(ans);\nend."}, {"source_code": "uses dos;\n\nvar a1,a2,m:longint;\n\nlabel x,y;\n\nbegin\n readln(a1,a2);\n m:=0;\n if (a1=1) and (a2=2) then goto y;\n repeat\n if (a10)and(b>0)) do begin\n if b>a then flag:=1\n else flag:=2;\n if b=1 then flag:=2;\n if a=1 then flag:=1;\n \n if flag=1 then begin\n a:=a+1;\n b:=b-2;\n end;\n if flag=2 then begin\n a:=a-2;\n b:=b+1;\n end;\n m:=m+1;\nend;\nwriteln(m);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b:longint;\n qx,qy:array[1..1000000] of longint;\n l,r:longint;\n mark:array[1..150,1..150] of boolean;\n d:array[1..150,1..150] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure push(x,y:longint);\n begin\n inc(r);\n qx[r]:=x;\n qy[r]:=y;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure pop(var x,y:longint);\n begin\n x:=qx[l];\n y:=qy[l];\n inc(l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,k,res,a1,b1:longint;\n begin\n read(fi,a,b);\n l:=1;\n r:=0;\n push(a,b);\n mark[a,b]:=true;\n d[a,b]:=0;\n while l<=r do\n begin\n pop(a1,b1);\n if (a1>2) and (not mark[a1-2,b1+1]) then\n begin\n mark[a1-2,b1+1]:=true;\n d[a1-2,b1+1]:=d[a1,b1]+1;\n push(a1-2,b1+1);\n end;\n if (b1>2) and (not mark[a1+1,b1-2]) then\n begin\n mark[a1+1,b1-2]:=true;\n d[a1+1,b1-2]:=d[a1,b1]+1;\n push(a1+1,b1-2);\n end;\n end;\n res:=0;\n for i:=1 to 150 do\n for j:=1 to 150 do res:=max(res,d[i,j]);\n writeln(fo,res+1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\n a,b,c,i,j,k,m,n:longint;\nbegin\n read(a,b);\n while (a>0)and(b>0) do\n begin\n if a>b then begin inc(b); dec(a,2); inc(i); end else\n begin inc(a); dec(b,2); inc(i); end;\n end;\n writeln(i);\nend.\n\n\n\n"}, {"source_code": "uses dos;\n\nvar n,d,e,f,min,i,a:longint;\n p,m,s:array[1..5000] of longint;\n\nbegin\n readln(n);\n d:=0;\n e:=0;\n f:=0;\n for i:=1 to n do\n begin\n read(a);\n if a=1 then\n begin\n inc(d);\n p[d]:=i;\n end;\n if a=2 then\n begin\n inc(e);\n m[e]:=i;\n end;\n if a=3 then\n begin\n inc(f);\n s[f]:=i;\n end;\n end;\n min:=5000;\n if d0 do\n begin\n if (joystick1=0) OR (joystick2=0) then break;\n charger(joystick1, joystick2);\n minutes:=minutes+1;\n end;\n writeln(minutes);\n readln;\nend.\n "}, {"source_code": "var x:array[-10..210,-10..210] of longint;\n i,j,n,m,a,b:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a)\n else exit(b);\nend;\nbegin\n for i:=2 to 200 do\n for j:=1 to i-1 do\n x[i,j]:=max(x[i-1,j-2],x[i-1,j+1])+1;\n readln(a,b);\n writeln(x[a+b,b]);\nend.\n"}, {"source_code": "program zzzz;\nvar\na1,a2,t:integer;\nbegin\nreadln(a1,a2);\nt:=0;\nif ((a1<>1) and (a2<>1)) then\nbegin\nrepeat\nif ((a1>=a2) and ((a2>=1)))then\nbegin\na2:=a2+1;\na1:=a1-2;\nt:=t+1;\nend\nelse\nbegin\na1:=a1+1;\na2:=a2-2;\nt:=t+1;\nend;\nuntil a1*a2=0;\nend;\nwriteln(t)\nend."}, {"source_code": "program h;\nvar a,b,i,c: integer;\nbegin\nread(a,b); i:=0;\nwhile (a<>0) and (b<>0) do\nbegin\nif (a>=b) then \nbegin\na:=a-2;\nb:=b+1;\ni:=i+1;\nend\nelse begin\nb:=b-2;\na:=a+1;\ni:=i+1;end;\nend;\nwrite(i);end."}, {"source_code": "var a,b,sum:int64;\nbegin\nreadln(a,b);\nwhile(a<>0)and(b<>0)do\n begin\n if(a1)and(b>1)do begin\ninc(I);\nif a2) or (b>2) do\n begin\n if ac then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h]0)and(c>0)) do\n begin\n inc(res);\n if 2 0) and (b > 0) do\n begin\n d := d + 1;\n \n if a <= 2 then\n c := 1;\n if b <= 2 then\n c := 2;\n if c = 1 then\n begin\n a := a + 1;\n b := b - 2;\n end\n else\n begin\n a := a - 2;\n b := b + 1;\n end; \n end;\n writeln(d);\nend. "}, {"source_code": "uses math;\nvar n,m,kol:longint;\nbegin\n\nreadln(n,m);\n\nkol:=0;\nwhile(n<>0) and(m<>0) do\nbegin\ninc(kol);\nif nb then c:=b*2\nelse c:=a*2;\nwriteln(c);\nreadln;\nend."}, {"source_code": "const fi='';\n fo='';\nVar d,m,n: longint;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,n,m);\n If (n=1) and (m=1) then\n Writeln(g,'0')\n Else\n Begin\n While (m>0) or (n>0) do\n Begin\n inc(d);\n If n>m then\n Begin\n inc(m);\n dec(n,2);\n End\n Else\n Begin\n inc(n);\n dec(m,2);\n End;\n End;\n End;\n Writeln(g,d);\n Close(f); Close(g);\nEnd.\n\n"}, {"source_code": "var a,b,c:longint;\nbegin\nreadln(a,b);\nwhile (a>0) and (b>0) do begin\n if (aa then flag:=1\n else flag:=2;\nwhile ((a>0)and(b>0)) do begin\n \n if b<=2 then flag:=2;\n if a<=2 then flag:=1;\n if flag=1 then begin\n a:=a+1;\n b:=b-2;\n end;\n if flag=2 then begin\n a:=a-2;\n b:=b+1;\n end;\n //writeln(a,' ',b);\n m:=m+1;\nend;\nwriteln(m);\nend."}, {"source_code": "var\n a,b,c,i,j,k,m,n:longint;\nbegin\n read(a,b);\n while (a>0)and(b>0) do\n begin\n if a<3 then begin inc(a); dec(b,2); end else\n begin inc(b); dec(a,2); end;\n inc(i);\n end;\n writeln(i);\nend.\n\n"}, {"source_code": "var\n\ta,b: integer;\n\tcnt: integer;\nbegin\n\treadln(a,b);\n\twhile (a>0) and (b>0) do\n\tif a>b then\n\tbegin\n\t\tinc(a,-2);\n\t\tinc(b);\n\t\tinc(cnt);\n\tend else\n\tbegin\n\t\tinc(a);\n\t\tinc(b,-2);\n\t\tinc(cnt);\n\tend;\n\twriteln(cnt);\nend."}, {"source_code": "Var\n i, n, m, k, l, o, p, ans:LongInt;\nBegin\n Read(n, m);\n while (n>0) and (m>0) do\n Begin\n Inc(ans);\n if (n>m) then Begin Dec(n, 2);Inc(m, 1);End\n else Begin Dec(m, 2);Inc(n, 1);End;\n\n\n End;\n WriteLn(ans);\nEnd."}, {"source_code": "var\na,b,min:longint;\nbegin\nreadln(a,b);\nwhile (a>0)and(b>0) do begin\n\n if a>b then begin\n inc(min);\n b:=b+1;\n dec(a,2);\n end\n else begin\n inc(min);\n a:=a+1;\n\n dec(b,2);\n end;\n\nend;\nwriteln(min);\nend."}, {"source_code": "var\na,b,min:longint;\nbegin\nreadln(a,b);\nwhile (a>0)and(b>0) do begin\n\n if a>b then begin\n inc(min);\n b:=b+1;\n dec(a,2);\n end\n else begin\n inc(min);\n a:=a+1;\n\n dec(b,2);\n end;\n\nend;\nwriteln(min);\nend."}, {"source_code": "uses dos;\n\nvar a1,a2,m:longint;\n\nlabel x;\n\nbegin\n readln(a1,a2);\n m:=0;\n repeat\n if (a10)and(b>0)) do\n begin\n if(a>=b) then\n begin\n b:=b+1;\n a:=a-2;\n end\n else\n begin\n b:=b-2;\n a:=a+1;\n end;\n t:=t+1;\n end;\n writeln(t);\nend."}, {"source_code": "const\n\tfi = '';\n\tfo = '';\nvar a, b, c:integer;\nbegin\n\tassign(input, fi); reset(input);\n\tassign(output, fo); rewrite(output);\n\treadln(a, b);\n\tc:=0;\n\twhile not((a<=0) or (b<=0)) do\n\tbegin\n\t\tc:=c+1;\n\t\tif a< b then\n\t\tbegin\n\t\t\ta:=a+1; b:=b-2;\n\t\tend else\n\t\tbegin\n\t\t\ta:=a-2; b:=b+1;\n\t\tend;\n\tend;\n\twriteln(c);\n\tclose(input); close(output);\nend.\n"}, {"source_code": "uses math;\nvar a1,a2,i,t:integer;\nbegin\nreadln(a1,a2);\nif a1>a2 then begin t:=a1; a1:=a2; a2:=t; end;\ni:=0;\nif (a1<=1) and (a2<=1) then writeln(0);\nwhile abs(a1-a2)>1 do\nbegin\ninc(a1);\na2:=a2-2;\ninc(i);\nend;\nif (a2<1) or (a1<1) then writeln(i) else\nif a1=a2 then\nwriteln(i+(min(a1,a2)-2)*2+1) else writeln(i+(min(a1,a2)-2)*2+3)\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b:longint;\n qx,qy:array[1..1000000] of longint;\n l,r:longint;\n mark:array[1..150,1..150] of boolean;\n d:array[1..150,1..150] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure push(x,y:longint);\n begin\n inc(r);\n qx[r]:=x;\n qy[r]:=y;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure pop(var x,y:longint);\n begin\n x:=qx[l];\n y:=qy[l];\n inc(l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,k,res,a1,b1:longint;\n begin\n read(fi,a,b);\n l:=1;\n r:=0;\n push(a,b);\n mark[a,b]:=true;\n d[a,b]:=0;\n while l<=r do\n begin\n pop(a1,b1);\n if (a1>2) and (not mark[a1-2,b1+1]) then\n begin\n mark[a1-2,b1+1]:=true;\n d[a1-2,b1+1]:=d[a1,b1]+1;\n push(a1-2,b1+1);\n end;\n if (b1>2) and (not mark[a1+1,b1-2]) then\n begin\n mark[a1+1,b1-2]:=true;\n d[a1+1,b1-2]:=d[a1,b1]+1;\n push(a1+1,b1-2);\n end;\n end;\n res:=0;\n for i:=1 to 150 do\n for j:=1 to 150 do res:=max(res,d[i,j]);\n if ((a=2) and (b=1)) or ((a=1) and (b=2)) then res:=0 else\n if (a<=2) and (b<=2) then res:=-1;\n writeln(fo,res+1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "const n=1000000000;\nvar i,j:longint;\n ans,a1,a2:int64;\nbegin\nread(a1,a2);\nfor i:=1 to maxlongint do\nbegin\nif (a1=1) and (a2=1) then begin write(i); halt; end;\nif a10) and (b>0) do\nbegin\nif a>b then calc(a,b) else calc(b,a);\nend;\nwrite(full);\nend.\n"}, {"source_code": "var n,m,p,z:longint;\n begin\n readln(n,m); if (n>1)and(m>1) then begin\n repeat\n inc(z);\n if nb then swap(a,b);\nend;\n\nprocedure xuly;\nbegin\n repeat\n if b<=2 then\n begin\n inc(kq);\n break;\n end;\n while b>2 do\n begin\n dec(b,2);\n inc(a);\n inc(kq);\n end;\n swap(a,b);\n if (a<=0) or (b<=0) then break;\n until false;\n write(kq);\nend;\n\nBEGIN\n //mofile;\n doc;\n xuly;\n //dongfile;\nEND.\n\n"}, {"source_code": "program qq;\n var a,b,sum:integer;\n begin\n read(a,b);\n while true do begin\n if a<=b then begin a:=a+1; b:=b-2; sum:=sum+1; end\n else begin b:=b+1; a:=a-2; sum:=sum+1;end;\n if(a=1)and(b=1) then begin sum:=sum-1; write(sum);break;end;\n if (a<=0)or(b<=0) then begin write(sum);break;end;\n end;\n end."}, {"source_code": "program qq;\n var a,b,sum:integer;\n begin\n read(a,b);\n while true do begin\n if a<=b then begin a:=a+1; b:=b-2; sum:=sum+1; end\n else begin b:=b+1; a:=a-2; sum:=sum+1;end;\n if(a=1)and(b=1) then begin write(sum);break;end;\n if (a<=0)or(b<=0) then begin write(sum);break;end;\n end;\n end."}, {"source_code": "var\na,b,i:longint;\nbegin\nreadln(A,b);\nwhile(a>0)and(b>0)do begin\ninc(I);\nif a0) and (b>0) do\n Begin\n if (a>1) and (b>1) then\n Begin\n if a mod 2=0 then UpA else UpB;\n end else\n if (a=1) then UpA else UpB;\n Inc(k);\n end;\n Write(k);\n end.\n"}], "src_uid": "ba0f9f5f0ad4786b9274c829be587961"} {"source_code": "const\n nfin= '';\n nfout= '';\n maxn= 100010;\n\ntype\n dslk = ^pointer;\n pointer= record\n u: longint;\n next: dslk;\n end;\n\nvar\n ds: array[0..maxn] of dslk;\n d, q: array[0..maxn] of longint;\n n, m: longint;\n i, j, u, v, res, cnt, l, r, mid: longint;\n temp: dslk;\n fin, fout: text;\n\nprocedure push(u, v: longint);\nvar temp: dslk;\nbegin\n new(temp);\n temp^.u:=v;\n temp^.next:=ds[u];\n ds[u]:=temp;\nend;\n\nfunction gcd(x, y: longint): longint;\nvar r: longint;\nbegin\n if x*y=0 then begin\n gcd:=(x+y);\n exit;\n end;\n\n while x mod y <> 0 do begin\n r:= x mod y;\n x:=y;\n y:=r;\n end;\n gcd:=y;\nend;\n\nprocedure attemp(u: longint);\nvar temp: dslk;\nbegin\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n d[temp^.u]:=(d[u] + 1);\n attemp(temp^.u);\n end\n else res:=gcd(res, abs(d[temp^.u] - 1 - d[u]));\n temp:=temp^.next;\n end;\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, n, m);\n for i:=1 to n do ds[i]:=nil;\n for i:=1 to m do begin\n readln(fin, u, v);\n push(u, v);\n end;\n\n res:=0;\n fillchar(d, sizeof(d), 255);\n d[1]:=0;\n l:=1; r:=1; q[1]:=1;\n while l<=r do begin\n u:=q[l];\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n inc(r);\n q[r]:=temp^.u;\n d[temp^.u]:=d[u]+1;\n end\n else res:=gcd(res, abs(d[u] +1 - d[temp^.u]));\n temp:= temp^.next;\n end;\n inc(l);\n end;\n cnt:=0;\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then inc(cnt);\n writeln(fout, res);\n writeln(fout, cnt);\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then write(fout, i,' ');\n close(fout);\n close(fin);\nend.\n\n\n", "positive_code": [{"source_code": "const\n nfin= '';\n nfout= '';\n maxn= 100010;\n\ntype\n dslk = ^pointer;\n pointer= record\n u: longint;\n next: dslk;\n end;\n\nvar\n ds: array[0..maxn] of dslk;\n d, q: array[0..maxn] of longint;\n n, m: longint;\n i, j, u, v, res, cnt, l, r, mid: longint;\n temp: dslk;\n fin, fout: text;\n\nprocedure push(u, v: longint);\nvar temp: dslk;\nbegin\n new(temp);\n temp^.u:=v;\n temp^.next:=ds[u];\n ds[u]:=temp;\nend;\n\nfunction gcd(x, y: longint): longint;\nvar r: longint;\nbegin\n if x*y=0 then begin\n gcd:=(x+y);\n exit;\n end;\n\n while x mod y <> 0 do begin\n r:= x mod y;\n x:=y;\n y:=r;\n end;\n gcd:=y;\nend;\n\nprocedure attemp(u: longint);\nvar temp: dslk;\nbegin\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n d[temp^.u]:=(d[u] + 1);\n attemp(temp^.u);\n end\n else res:=gcd(res, abs(d[temp^.u] - 1 - d[u]));\n temp:=temp^.next;\n end;\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, n, m);\n for i:=1 to n do ds[i]:=nil;\n for i:=1 to m do begin\n readln(fin, u, v);\n push(u, v);\n end;\n\n res:=0;\n fillchar(d, sizeof(d), 255);\n d[1]:=0;\n l:=1; r:=1; q[1]:=1;\n while l<=r do begin\n u:=q[l];\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n inc(r);\n q[r]:=temp^.u;\n d[temp^.u]:=d[u]+1;\n end\n else res:=gcd(res, abs(d[u] +1 - d[temp^.u]));\n temp:= temp^.next;\n end;\n inc(l);\n end;\n cnt:=0;\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then inc(cnt);\n writeln(fout, res);\n writeln(fout, cnt);\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then write(fout, i,' ');\n close(fout);\n close(fin);\nend.\n\n\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = round(1e9);\n\nvar\n n, m, k, a, b, cur, l, r, ans, i : integer;\n queue, d, go, next, first : array[0..100001] of integer;\n\nprocedure add(a, b : integer);\nbegin\n inc(k);\n go[k] := b;\n next[k] := first[a];\n first[a] := k;\nend;\n\nfunction gcd(a, b : integer) : integer;\nbegin\n if b = 0 then\n result := a\n else\n result := gcd(b, a mod b);\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n read(n, m);\n k := 0;\n for i := 1 to m do begin\n read(a, b);\n add(a, b);\n end;\n for i := 1 to n do\n d[i] := inf;\n d[1] := 0;\n l := 1;\n r := 1;\n queue[1] := 1;\n ans := 0;\n while l <= r do begin\n cur := queue[l];\n inc(l);\n i := first[cur];\n while i > 0 do begin\n if d[go[i]] > d[cur] + 1 then begin\n d[go[i]] := d[cur] + 1;\n inc(r);\n queue[r] := go[i];\n end\n else\n ans := gcd(ans, d[cur] + 1 - d[go[i]]);\n i := next[i];\n end;\n end;\n writeln(ans);\n k := 0;\n for i := 1 to n do\n if (d[i] < inf) and (d[i] mod ans = 0) then\n inc(k);\n writeln(k);\n for i := 1 to n do\n if (d[i] < inf) and (d[i] mod ans = 0) then\n write(i, ' ');\n writeln;\nend.\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n n,m,i,j,aa,bb,e,t,k: longint;\n v,last,pred,was,ss,ff,x,y: array [0..400010] of longint;\n dist: array [0..400010,0..2] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m);\n fillchar(last,sizeof(last),0);\n for i:=1 to m do\n begin\n read(ss[i],ff[i]);\n pred[i]:=last[ss[i]];\n last[ss[i]]:=i;\n end;\n fillchar(was,sizeof(was),0);\n fillchar(dist,sizeof(dist),0);\n i:=1; e:=1;\n x[1]:=1;\n y[1]:=1;\n was[1]:=1;\n dist[1,1]:=0;\n while i <= e do\n begin\n j:=last[x[i]];\n while j > 0 do\n begin\n if (was[ff[j]] < 2) and (dist[x[i],y[i]]+1 <> dist[ff[j],was[ff[j]]]) then\n begin\n inc(e);\n x[e]:=ff[j];\n inc(was[x[e]]);\n y[e]:=was[x[e]];\n dist[x[e],y[e]]:=dist[x[i],y[i]]+1;\n end;\n j:=pred[j];\n end;\n inc(i);\n end;\n t:=0;\n for i:=1 to n do\n if was[i] = 2 then\n begin\n aa:=t; bb:=dist[i,2]-dist[i,1];\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n for i:=1 to m do\n if (was[ss[i]] > 0) and (was[ff[i]] > 0) then\n begin\n aa:=t; bb:=abs(dist[ss[i],1]+1-dist[ff[i],1]);\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n k:=0;\n for i:=1 to n do\n if (was[i] > 0) and (dist[i,1] mod t = 0) then\n begin\n inc(k);\n v[k]:=i;\n end;\n writeln(t);\n writeln(k);\n for i:=1 to k-1 do write(v[i],' ');\n writeln(v[k]);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n n,m,i,j,aa,bb,e,t,k: longint;\n v,last,pred,was,ss,ff,x,y: array [0..400010] of longint;\n dist: array [0..400010,0..2] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m);\n fillchar(last,sizeof(last),0);\n for i:=1 to m do\n begin\n read(ss[i],ff[i]);\n pred[i]:=last[ss[i]];\n last[ss[i]]:=i;\n end;\n fillchar(was,sizeof(was),0);\n fillchar(dist,sizeof(dist),0);\n i:=1; e:=1;\n x[1]:=1;\n y[1]:=1;\n was[1]:=1;\n dist[1,1]:=0;\n while i <= e do\n begin\n j:=last[x[i]];\n while j > 0 do\n begin\n if (was[ff[j]] < 2) and (dist[x[i],y[i]]+1 <> dist[ff[j],was[ff[j]]]) then\n begin\n inc(e);\n x[e]:=ff[j];\n inc(was[x[e]]);\n y[e]:=was[x[e]];\n dist[x[e],y[e]]:=dist[x[i],y[i]]+1;\n end;\n j:=pred[j];\n end;\n inc(i);\n end;\n t:=0;\n for i:=1 to n do\n if was[i] = 2 then\n begin\n aa:=t; bb:=dist[i,2]-dist[i,1];\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n for i:=1 to m do\n if (was[ss[i]] > 0) and (was[ff[i]] > 0) then\n begin\n aa:=t; bb:=abs(dist[ss[i],1]+1-dist[ff[i],1]);\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n k:=0;\n for i:=1 to n do\n if (was[i] > 0) and (dist[i,1] mod t = 0) then\n begin\n inc(k);\n v[k]:=i;\n end;\n writeln(t);\n writeln(k);\n for i:=1 to k-1 do write(v[i],' ');\n writeln(v[k]);\n close(input);\n close(output);\nend.\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n n,m,i,j,aa,bb,e,t,k: longint;\n v,last,pred,was,ss,ff,x,y: array [0..400010] of longint;\n dist: array [0..400010,0..2] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m);\n fillchar(last,sizeof(last),0);\n for i:=1 to m do\n begin\n read(ss[i],ff[i]);\n pred[i]:=last[ss[i]];\n last[ss[i]]:=i;\n end;\n fillchar(was,sizeof(was),0);\n fillchar(dist,sizeof(dist),0);\n i:=1; e:=1;\n x[1]:=1;\n y[1]:=1;\n was[1]:=1;\n dist[1,1]:=0;\n while i <= e do\n begin\n j:=last[x[i]];\n while j > 0 do\n begin\n if (was[ff[j]] < 2) and (dist[x[i],y[i]]+1 <> dist[ff[j],was[ff[j]]]) then\n begin\n inc(e);\n x[e]:=ff[j];\n inc(was[x[e]]);\n y[e]:=was[x[e]];\n dist[x[e],y[e]]:=dist[x[i],y[i]]+1;\n end;\n j:=pred[j];\n end;\n inc(i);\n end;\n t:=0;\n for i:=1 to n do\n if was[i] = 2 then\n begin\n aa:=t; bb:=dist[i,2]-dist[i,1];\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n for i:=1 to m do\n if (was[ss[i]] > 0) and (was[ff[i]] > 0) then\n begin\n aa:=t; bb:=abs(dist[ss[i],1]+1-dist[ff[i],1]);\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n k:=0;\n for i:=1 to n do\n if (was[i] > 0) and (dist[i,1] mod t = 0) then\n begin\n inc(k);\n v[k]:=i;\n end;\n writeln(t);\n writeln(k);\n for i:=1 to k-1 do write(v[i],' ');\n writeln(v[k]);\n close(input);\n close(output);\nend."}], "negative_code": [{"source_code": "const\n nfin= '';\n nfout= '';\n maxn= 100010;\n\ntype\n dslk = ^pointer;\n pointer= record\n u: longint;\n next: dslk;\n end;\n\nvar\n ds: array[0..maxn] of dslk;\n d, tr: array[0..maxn] of longint;\n n, m: longint;\n i, j, u, v, res, cnt, l, r, mid: longint;\n fin, fout: text;\n\nprocedure push(u, v: longint);\nvar temp: dslk;\nbegin\n new(temp);\n temp^.u:=v;\n temp^.next:=ds[u];\n ds[u]:=temp;\nend;\n\nfunction attemp(u, t: longint): boolean;\nvar temp: dslk;\nbegin\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n d[temp^.u]:=(d[u] + 1) mod t;\n if attemp(temp^.u, t) = false then begin\n attemp:=false;\n exit;\n end;\n end\n else if d[temp^.u] <> (d[u] + 1 ) mod t then begin\n attemp:=false;\n exit;\n end;\n\n temp:=temp^.next;\n end;\n\n attemp:=true;\nend;\n\nfunction check(t: longint): boolean;\nbegin\n fillchar(d, sizeof(d), 255);\n d[1]:=0;\n check:=attemp(1, t);\nend;\n\nfunction dfs(u: longint): longint;\nvar t, v: longint;\n temp: dslk;\nbegin\n d[u]:=0;\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n tr[temp^.u]:=u;\n dfs:=dfs(temp^.u);\n exit;\n end\n else if d[temp^.u] = 0 then begin\n l:=0;\n v:=u;\n t:=1;\n while v<>temp^.u do begin\n v:=tr[v];\n t:=t+1;\n end;\n dfs:=t;\n exit;\n end;\n temp:=temp^.next;\n end;\n d[u]:=1;\nend;\n\nfunction lc: longint;\nbegin\n fillchar(d, sizeof(d), 255);\n fillchar(tr, sizeof(tr), 0);\n lc:=dfs(1);\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, n, m);\n for i:=1 to n do ds[i]:=nil;\n for i:=1 to m do begin\n readln(fin, u, v);\n push(u, v);\n end;\n\n l:=lc;\n for res:=l downto 1 do\n if (l mod res = 0) then\n if check(res) then break;\n\n for i:=1 to n do if (d[i] mod res)=0 then inc(cnt);\n writeln(fout, res);\n writeln(fout, cnt);\n for i:=1 to n do if (d[i] mod res)=0 then write(fout, i,' ');\n close(fout);\n close(fin);\nend.\n\n"}, {"source_code": "const\n nfin= '';\n nfout= '';\n maxn= 1000010;\n\ntype\n dslk = ^pointer;\n pointer= record\n u: longint;\n next: dslk;\n end;\n\nvar\n ds: array[0..maxn] of dslk;\n d, tr: array[0..maxn] of longint;\n n, m: longint;\n i, j, u, v, res, cnt, l, r, mid: longint;\n fin, fout: text;\n\nprocedure push(u, v: longint);\nvar temp: dslk;\nbegin\n new(temp);\n temp^.u:=v;\n temp^.next:=ds[u];\n ds[u]:=temp;\nend;\n\nfunction gcd(x, y: longint): longint;\nvar r: longint;\nbegin\n if x*y=0 then begin\n gcd:=(x+y);\n exit;\n end;\n\n while x mod y <> 0 do begin\n r:= x mod y;\n x:=y;\n y:=r;\n end;\n gcd:=y;\nend;\n\nprocedure attemp(u: longint);\nvar temp: dslk;\nbegin\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n d[temp^.u]:=(d[u] + 1);\n attemp(temp^.u);\n end\n else res:=gcd(res, abs(d[temp^.u] - 1 - d[u]));\n temp:=temp^.next;\n end;\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, n, m);\n for i:=1 to n do ds[i]:=nil;\n for i:=1 to m do begin\n readln(fin, u, v);\n push(u, v);\n end;\n\n if res=0 then halt;\n res:=0;\n fillchar(d, sizeof(d), 255);\n d[1]:=0;\n attemp(1);\n cnt:=0;\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then inc(cnt);\n writeln(fout, res);\n writeln(fout, cnt);\n for i:=1 to n do if (d[i]>-1) and ((d[i] mod res)=0) then write(fout, i,' ');\n close(fout);\n close(fin);\nend.\n\n\n"}, {"source_code": "const\n nfin= '';\n nfout= '';\n maxn= 100010;\n\ntype\n dslk = ^pointer;\n pointer= record\n u: longint;\n next: dslk;\n end;\n\nvar\n ds: array[0..maxn] of dslk;\n d: array[0..maxn] of longint;\n n, m: longint;\n i, j, u, v, res, cnt, l, r, mid: longint;\n fin, fout: text;\n\nprocedure push(u, v: longint);\nvar temp: dslk;\nbegin\n new(temp);\n temp^.u:=v;\n temp^.next:=ds[u];\n ds[u]:=temp;\nend;\n\nfunction attemp(u, t: longint): boolean;\nvar temp: dslk;\nbegin\n temp:=ds[u];\n while temp<>nil do begin\n if d[temp^.u] = -1 then begin\n d[temp^.u]:=(d[u] + 1) mod t;\n if attemp(temp^.u, t) = false then begin\n attemp:=false;\n exit;\n end;\n end\n else if d[temp^.u] <> (d[u] + 1 ) mod t then begin\n attemp:=false;\n exit;\n end;\n\n temp:=temp^.next;\n end;\n\n attemp:=true;\nend;\n\nfunction check(t: longint): boolean;\nbegin\n fillchar(d, sizeof(d), 255);\n d[1]:=0;\n check:=attemp(1, t);\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, n, m);\n for i:=1 to n do ds[i]:=nil;\n for i:=1 to m do begin\n readln(fin, u, v);\n push(u, v);\n end;\n\n l:=1; r:=n;\n while l<=r do begin\n mid:=(l+r) shr 1;\n if check(mid) then begin\n l:=mid+1; res:=mid;\n end else r:=mid-1;\n end;\n\n check(res);\n for i:=1 to n do if d[i] mod res=0 then inc(cnt);\n writeln(fout, res);\n writeln(fout, cnt);\n for i:=1 to n do if d[i] mod res=0 then write(fout, i,' ');\n close(fout);\n close(fin);\nend.\n\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n n,m,i,j,aa,bb,e,t,k: longint;\n v,last,pred,was,ss,ff,x,y: array [0..400010] of longint;\n dist: array [0..400010,0..2] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m);\n fillchar(last,sizeof(last),0);\n for i:=1 to m do\n begin\n read(ss[i],ff[i]);\n pred[i]:=last[ss[i]];\n last[ss[i]]:=i;\n end;\n fillchar(was,sizeof(was),0);\n fillchar(dist,sizeof(dist),0);\n i:=1; e:=1;\n x[1]:=1;\n y[1]:=1;\n was[1]:=1;\n dist[1,1]:=0;\n while i <= e do\n begin\n j:=last[x[i]];\n while j > 0 do\n begin\n if (was[ff[j]] < 2) and (dist[x[i],y[i]]+1 <> dist[ff[j],was[ff[j]]]) then\n begin\n inc(e);\n x[e]:=ff[j];\n inc(was[x[e]]);\n y[e]:=was[x[e]];\n dist[x[e],y[e]]:=dist[x[i],y[i]]+1;\n end;\n j:=pred[j];\n end;\n inc(i);\n end;\n t:=0;\n for i:=1 to n do\n if was[i] = 2 then\n begin\n aa:=t; bb:=dist[i,2]-dist[i,1];\n while (aa > 0) and (bb > 0) do\n if aa > bb then aa:=aa mod bb\n else bb:=bb mod aa;\n t:=aa+bb;\n end;\n k:=0;\n for i:=1 to n do\n if (was[i] > 0) and (dist[i,1] mod t = 0) then\n begin\n inc(k);\n v[k]:=i;\n end;\n writeln(t);\n writeln(k);\n for i:=1 to k-1 do write(v[i],' ');\n writeln(v[k]);\n close(input);\n close(output);\nend."}], "src_uid": "e13228fcdaa1c218581606ddfe186d52"} {"source_code": "var n,i,cnt,j:longint ;\nbegin \n readln(n) ;\n\t for i:=0 to 25 do \n\t begin \n\t\t cnt:=1 ;\n\t\t while cnt*(cnt+1) div 2<=n do inc(cnt) ;\n\t\t n:=n-cnt*(cnt-1) div 2 ;\n\t\t for j:=0 to cnt-1 do write(chr(97+i)) ;\n\t end;\nend.", "positive_code": [{"source_code": "var\n s:ansistring;\n k,d,c:longint;\n i:char;\nbegin\n read(k);\n for i:='a' to 'z' do\n begin\n d:=0;\n c:=0;\n while d+c<=k do\n begin\n write(i);\n d:=d+c;\n inc(c);\n end;\n k:=k-d;\n end;\nend."}, {"source_code": " \n const nn=1600000; nnn=1200000;eps=0.00000000001;\n besk=80000000000000;\n label 1,2,3;\n var k,step, i,j:longint;\n pp,jj,ii,p3,p4, p1,p2,t1,t2,p,ost,q,n,ot,t,kk:int64;\n pal:array[-20..6000,-20..6000] of boolean;\n ppp:extended;\n dd,zz,z,c,d,x,y,a,b:array[-1002..2000000] of int64;\n ddnew,ddold:array[0..200,0..4040] of integer;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss:string;\n ch:char;\n flagg,flag,flag1:boolean;\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ff(p:int64):int64;\nvar t1,t2:int64;\nbegin if p=1 then ff:=0 else if p=2 then ff:=1 else\n begin\n t1:=ff(p shr 1);\n t2:=ff(p-(p shr 1));\n ff:=t1*t2+t1+t2;\n\n end;\n\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n);\n if n=0 then begin writeln('a'); goto 1; end;\n for i:=1 to 500 do a[i]:=a[i-1]+i;\n d[0]:=0;\n d[1]:=0;\n d[2]:=1;\n for i:=3 to 100000 do\n begin\n t1:=i shr 1;\n t2:=i-t1;\n d[i]:=d[t1]+d[t2]+t1*t2;\n\n end;\n\n { for i:=1 to 100 do writeln(i,' ',d[i],' ',a[i]);\n writeln('-------------');\n }\n for i:=1 to 300000 do dd[i]:=besk;\n for i:=0 to 500 do for j:=0 to 100000 do\n begin\n dd[j+a[i]]:=min(dd[j+a[i]],dd[j]+1);\n if dd[j+a[i]]=dd[j]+1 then begin x[j+a[i]]:=i; end;\n end;\n\n for i:=1 to 200000 do ot:=max(ot,dd[i]);\n { writeln('ot= ',ot);\n }\n\n\n pp:=n; t:=0;\n while (pp>0)and(t<20) do begin inc(t); z[t]:=x[pp]; pp:=pp-a[z[t]]; end;\n\n { writeln('t= ',t);\n for i:=1 to t do write(z[i],' ');\n }\n for i:=1 to t do\n begin\n ch:=chr(i-1+ord('a'));\n for j:=0 to z[i] do write(ch);\n\n end;\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var s:ansistring;\n n:longint;\nprocedure process;\nvar d,c:longint;\n i:char;\nbegin\n s:='';\n for i:='a' to 'z' do\n begin\n d:=0;c:=0;\n while (d+c<=n) do\n begin\n s:=s+i;\n d:=d+c;\n inc(c);\n end;\n n:=n-d;\n end;\n write(s);\nend;\nbegin\n read(n);\n process;\nend.\n"}, {"source_code": "program mfs;\nvar\nk,cnt,i,j:longint;\nnow:char;\nbegin\nreadln(k);\nnow:='a';\nfor i:=0 to 25 do\nbegin\ncnt:=0;\nwhile ((cnt+1)*(cnt+2))div 2<=k do inc(cnt);\nk:=k-(((cnt+1)*cnt) div 2);\nfor j:=0 to cnt do write(chr(ord(now)+i));\nif k=0 then halt;\nend;\nend."}, {"source_code": "var n,i,j:longint;\na:array[0..100001] of longint;\nbegin\n//assign(input,'cydy.in');reset(input);\n//assign(output,'cydy.out');rewrite(output);\nreadln(n);\nfor i:=1 to 600 do a[i]:=a[i-1]+i-1;\nfor i:=1 to 26 do\n begin\n for j:=600 downto 1 do\n if n>=a[j] then\n begin\n n:=n-a[j];\n break;\n end;\n for j:=j downto 1 do write(chr(i+96));\n if n=0 then break;\n end;\nclose(input);close(output);\nend."}, {"source_code": "var f1,f2 : text;\n ch:char;\n s:ansistring;\n d,k:longint;\n\nbegin\nassign(f1,'');reset(f1);\nassign(f2,'');rewrite(f2);\nreadln(f1,k);\nfor ch := 'a' to'z' do\n s:=s+ch;\nfor ch := 'a' to 'z' do\n if k > 0 then\n begin\n d := 0;\n while (k > 0) do\n begin\n inc(d);\n if (k-d>=0) then\n begin\n k:=k-d;\n s:=s+ch;\n end\n else break;\n end;\n end;\nwrite(f2,s);\nclose(F1);\nclose(F2);\nend.\n"}, {"source_code": "var k,i,j,a,b,c:longint;\n\tt:array[-5..10000]of longint;\nbegin\n\treadln(k);j:=0;a:=96;\n\tif k=0 then begin write('a');exit;end;\n\tfor i:=1 to 10000 do begin\n\t\tinc(j,i);t[i]:=j;\n\tend;\n\tfor i:=10000 downto 1 do\n\t\twhile k>=t[i] do begin\n\t\t\tdec(k,t[i]);\n\t\t\tinc(a);\n\t\t\tfor j:=0 to i do write(chr(a));\n\t\tend;\nend.\n"}, {"source_code": "var\n i,j,k,n:longint;\n a:array[0..1000] of longint;\n c:char;\nbegin\n read(n);\n for i:=2 to 1000 do a[i]:=a[i-1]+i-1;\n for c:='a' to 'z' do\n begin\n for j:=1000 downto 1 do\n if n>=a[j] then\n begin\n n:=n-a[j];\n for k:=1 to j do write(c);\n break;\n end;\n if n=0 then break;\n end;\nend."}, {"source_code": "var\ns:ansistring;\nx,i,n,j:longint;\nbegin\n readln(n);\n x:=97;\n if n=0 then writeln('a') else begin\n s:='a';\n while(n>0) do begin\n i:=(-1+trunc(sqrt(1+8*n))) div 2;\n for j:=1 to i do s:=s+chr(x);\n x:=x+1;\n n:=n-((i*(i+1))div 2);\n if n>0 then s:=s+chr(x);\n end;\n end;\n writeln(s);\nend."}, {"source_code": "var s:ansistring;\n n:longint;\nprocedure process;\nvar d,c:longint;\n i:char;\nbegin\n s:='';\n for i:='a' to 'z' do\n begin\n d:=0;c:=0;\n while (d+c<=n) do\n begin\n s:=s+i;\n d:=d+c;\n inc(c);\n end;\n n:=n-d;\n end;\n write(s);\nend;\nbegin\n read(n);\n process;\nend."}, {"source_code": "var\ns:ansistring;\nx,i,n,j:longint;\nbegin\n readln(n);\n x:=97;\n if n=0 then writeln('a') else begin\n s:='a';\n while(n>0) do begin\n i:=(-1+trunc(sqrt(1+8*n))) div 2;\n for j:=1 to i do s:=s+chr(x);\n x:=x+1;\n n:=n-((i*(i+1))div 2);\n if n>0 then s:=s+chr(x);\n end;\n end;\n writeln(s);\nend."}, {"source_code": "var n,i,cnt,j:longint ;\nbegin \n readln(n) ;\n\t for i:=0 to 25 do \n\t begin \n\t\t cnt:=1 ;\n\t\t while cnt*(cnt+1) div 2<=n do inc(cnt) ;\n\t\t n:=n-cnt*(cnt-1) div 2 ;\n\t\t for j:=0 to cnt-1 do write(chr(97+i)) ;\n\t end;\nend."}, {"source_code": "var s:ansistring;\n n:longint;\nprocedure process;\nvar d,c:longint;\n i:char;\nbegin\n s:='';\n for i:='a' to 'z' do\n begin\n d:=0;c:=0;\n while (d+c<=n) do\n begin\n s:=s+i;\n d:=d+c;\n inc(c);\n end;\n n:=n-d;\n end;\n write(s);\nend;\nbegin\n read(n);\n process;\nend."}], "negative_code": [{"source_code": "{$H+}\nvar\n k,j,c:longint;\n i:char;\nbegin\n readln(k);\n for i:='a' to 'z' do\n begin\n c:=trunc(sqrt(k*2));\n for j:=1 to c do write(i);\n k:=k-c*(c-1) div 2;\n end;\nend."}, {"source_code": "var k,i,j,a,b,c:longint;\n\tt:array[-5..10000]of longint;\nbegin\n\treadln(k);j:=0;a:=96;\n\tfor i:=1 to 10000 do begin\n\t\tinc(j,i);t[i]:=j;\n\tend;\n\tfor i:=10000 downto 1 do\n\t\twhile k>=t[i] do begin\n\t\t\tdec(k,t[i]);\n\t\t\tinc(a);\n\t\t\tfor j:=0 to i do write(chr(a));\n\t\tend;\n if k=0 then write('a');\nend.\n"}, {"source_code": "var\n i,j,k,n:longint;\n a:array[0..1000] of longint;\n c:char;\nbegin\n read(n);\n for i:=2 to 1000 do a[i]:=a[i-1]+i-1;\n for c:='a' to 'z' do\n begin\n for j:=1000 downto 2 do\n if n>=a[j] then\n begin\n n:=n-a[j];\n for k:=1 to j do write(c);\n break;\n end;\n if n=0 then break;\n end;\nend."}, {"source_code": "var\ns:ansistring;\nx,i,n,j:longint;\nbegin\n readln(n);\n x:=97;\n if n=0 then writeln('a') else begin\n s:='';\n while(n>0) do begin\n i:=(-1+trunc(sqrt(1+8*n))) div 2;\n for j:=1 to i do s:=s+chr(x);\n x:=x+1;\n n:=n-((i*(i+1))div 2);\n if n>0 then s:=s+chr(x);\n end;\n end;\n writeln(s);\nend."}], "src_uid": "b991c064562704b6106a6ff2a297e64a"} {"source_code": "var\nn,a,x,b,y,i,j:longint;\nfunction check(i,j:longint):boolean;\nbegin\n if (i=j) then exit(true)\n else exit(false);\nend;\nbegin\n readln(n,a,x,b,y);\n i:=a;\n j:=b;\n while (check(i,j)=false) and ((i<>x) and (j<>y)) do\n begin\n inc(i);\n dec(j);\n if i = n+1 then i:=1;\n if j = 0 then j:=n;\n end;\n if (i=j) then write('YES')\n else write('NO');\nend.\n\n", "positive_code": [{"source_code": "var\nbol:boolean;\ni,kol,n,a,x,y,b:longint;\naa,bb:array[-1000..1000000]of longint;\nbegin\nreadln(n,a,x,b,y);\n\nif (a<=x) then begin\n for i:=a to x do begin\n inc(kol);\n aa[i]:=kol;\n end;\nend\nelse begin\n for i:=a to n do begin\n inc(kol);\n aa[i]:=kol;\n end;\n for i:=1 to x do begin\n inc(kol);\n aa[i]:=kol;\n end;\nend;\n\nkol:=0;\n\nif (b>=y) then begin\n for i:=b downto y do begin\n inc(kol);\n bb[i]:=kol;\n end;\nend\nelse begin\n for i:=b downto 1 do begin\n inc(kol);\n bb[i]:=kol;\n end;\n for i:=n downto y do begin\n inc(kol);\n bb[i]:=kol;\n end;\nend;\n\n for i:=1 to n do begin\n if (aa[i]=bb[i])and(aa[i]>0) then bol:=true;\n end;\n if bol then writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "Program CircleMetro;\nuses math;\nvar n,a,x,b,y:longint;\nbegin //assign(input,'1169A.inp'); reset(input);\n //assign(output,'1169A.out'); rewrite(output);\n readln(n,a,x,b,y);\n while not((a=x) and (b=y)) do\n begin if a<>x then inc(a);\n if a>n then a:=a-n;\n if b<>y then dec(b);\n if b<1 then b:=b+n;\n if ((a=x) and (a<>b)) or ((b=y) and (a<>b)) then begin\n writeln('NO'); exit;\n end;\n if a=b then begin\n writeln('YES'); exit;\n end;\n end;\n //close(input); close(output);\nend."}, {"source_code": "var n,a,x,b,y:longint;\nbegin\n read(n,a,x,b,y);\n x:=x mod n;\n a:=a mod n;\n b:=b+n;\n y:=y mod n;\n while (x<>a)and(b mod n<>y)do\n begin\n inc(a);a:=a mod n;\n dec(b);\n if a=b mod n then begin write('YES');halt;end;\n end;\n write('NO');\n end."}, {"source_code": "var n,a,x,b,y:integer;\nbegin\nreadln(n,a,x,b,y);\nwhile (a<>b) and (a<>x) and (b<>y) do\n begin\n if a=b then break;\n inc(a); dec(b);\n if a>n then a:=1;\n if b=0 then b:=n\n end;\nif a=b then writeln('YES') else writeln('NO')\nend."}, {"source_code": "var a,b,n,x,y:longint;\nbegin\n readln(n,a,x,b,y);\n while (a<>x) and (b<>y) do\n begin\n a:=a mod n+1;\n dec(b);\n if b=0 then b:=n;\n if a=b then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO')\nend."}, {"source_code": "program circlemetro;\nvar n,a,x,b,y:byte;\nbegin\n read(n,a,x,b,y);\n if a=b then\n begin\n write('YES');\n halt;\n end;\n repeat\n inc(a);\n dec(b);\n if a>n then a:=a-n;\n if b<1 then b:=b+n;\n if a=b then\n begin\n write('YES');\n halt;\n end;\n until (a=x) or (b=y);\n writeln('NO');\n readln;\nend.\n\n"}, {"source_code": "program implement;\nvar\nn,x,y,b,a:longint;\nyep:boolean;\nbegin\n yep:=false;\n readln(n,a,x,b,y);\n while (a<>x) and (b<>y) do\n begin\n a:=a+1;\n if a>n then a:=a-n;\n b:=b-1;\n if b<1 then b:=b+n;\n if a=b then yep:=true;\n end;\n if yep then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,a,xx,b,y,s,s1:longint;\n x:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n read(f,n,a,xx,b,y);\n\n assign(f,fo);rewrite(f);\n s:=a;\n s1:=b;\n x:='NO';\n while (true) do\n begin\n if s=n then s:=0;\n inc(s);\n dec(s1);\n if s1<1 then s1:=n;\n if s1=s then\n begin\n x:='YES';\n break;\n end;\n if s=xx then break;\n if s1=y then break;\n end;\n write(f,x);\n close(f);\nend.\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b,x,y:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n,a,x,b,y);\n for i:=1 to 100000 do\n begin\n if a=b then\n begin\n writeln(fo,'YES');\n exit;\n end;\n if a<>x then inc(a) else break;\n if b<>y then dec(b) else break;\n if a>n then a:=1;\n if b=0 then b:=n;\n end;\n writeln(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "Var\nn, a, x, b, y: integer;\ns: string;\n\nBegin\n\nreadln(n, a, x, b, y); s:='NO';\nrepeat\na:=(a+1) mod (n+1); \nif a=0 then inc(a);\nb:=(b-1) mod (n+1);\nif b=0 then b:=n;\nuntil (a=x) or (b=y) or (a=b);\nif a=b then s:='YES';\nwriteln(s);\n\nEnd."}, {"source_code": "var n,a,b,x,y:longint;\nbegin\n readln(n,a,x,b,y);\n repeat\n begin\n inc(a);\n if a=n+1 then a:=1;\n dec(b);\n if b=0 then b:=n;\n if (a=b) {or ((abs(a-b)=1) and (a<>x) and (b<>y))} then\n begin\n writeln('YES');\n halt;\n end;\n end\n until (a=x) or (b=y);\n writeln('NO');\nend."}, {"source_code": "var i, n, u, v, a, b, x, y: longint;\n check: boolean;\n f1, f2: text;\nconst fi = '';\n fo = '';\n{=================================================}\nprocedure Input;\nbegin\n assign(f1, fi); reset(f1);\n readln(f1, n, a, x, b, y);\n close(f1);\nend;\n{=================================================}\nprocedure Output;\nbegin\n assign(f2, fo); rewrite(f2);\n check := false;\n u := a; v := b;\n while (u <> v) do\n begin\n if (u = n) then u := 1\n else inc(u);\n if (v = 1) then v := n\n else dec(v);\n if (u = v) then\n begin\n check := true;\n break;\n end;\n if (u = x)or(v = y) then\n begin\n check := false;\n break;\n end;\n end;\n if (check = true) then writeln(f2, 'YES')\n else writeln(f2, 'NO');\n close(f2);\nend;\n{=================================================}\nbegin\n Input;\n Output;\nend.\n{=================================================}\n"}, {"source_code": "var \n st2,st1 : array[1..5000] of longint;\n j,n,a,b,x,y,i,k,j1,j2,st : longint;\nfunction min(a,b : longint) : longint;\nbegin\n min := a;\n if (a > b) then\n min := b;\nend;\nbegin\n readln(n,a,x,b,y);\n st := a;\n st1[1] := a;\n j := 1;\n while (a <> x) do\n begin\n inc(a);\n if (a > n) then\n a := 1;\n inc(j);\n inc(j1);\n st1[j] := a;\n end;\n st := b;\n st2[1] := b;\n j := 1;\n while (b <> y) do\n begin\n dec(b);\n if (b = 0) then\n b := n;\n inc(j);\n inc(j2);\n st2[j] := b; \n end;\n for i := 1 to min(j1,j2)+1 do\n if (st1[i] = st2[i]) and ((st1[i] > 0) and (st2[i] > 0)) then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "Program ILoveYou;\nVAR n,a,x,b,y:int64; bo:boolean;\nBegin\n\nbo:=false;\nReadln(n,a,x,b,y);\nwhile (a <> x) and (b <> y) do\nBegin\n\nif (a = b) then bo:=true;\na:=a + 1;\nif (a = n + 1) then a:=1;\nb:=b - 1;\nif (b = 0) then b:=n;\nif (a = b) then bo:=true;\n\nend;\n\nif bo then Writeln('YES') else Writeln('NO');\n\nReadln;\nEND."}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..250000+1] of int64; integer=longint;\nvar i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n a1,b1,strok:array[-10..250000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]pp;\n { writeln('pp= ',pp,' n= ',n);\n } for i:=pp+1 to n+2 do a[i]:=besk;\n sort(a);\n { for i:=1 to pp do writeln(a[i],' ',a1[i]);\n } for i:=1 to pp do z[i]:=z[i-1]+a1[i];\n { for i:=1 to pp do write(z[i],' '); writeln;\n } ot:=0;\n for i:=1 to pp do ot:=max(ot,z[i]);\n\n\n\n maxvl:=ot;\nend;\n\nfunction st1(t:longint):longint;\nvar ot,tt:longint;\nbegin\n ot:=x[1]+t;\n ot:=ot mod p;\n st1:=ot;\nend;\n\nfunction st2(t:longint):longint;\nvar ot,tt:longint;\nbegin\n ot:=x[3]-t+10000*p;\n ot:=ot mod p;\n st2:=ot;\nend;\n\n\n\n\n\nbegin\n\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n\n read(p);\n for i:=1 to 4 do read(x[i]);\n for i:=1 to 4 do dec(x[i]);\n if x[2]x[3] then x[3]:=x[3]+p;\n\n { for i:=0 to 10 do writeln(i,' ',st1(i),' ',st2(i));\n }\n for i:=0 to 1000 do\n begin\n { writeln('step= ',i,' pol= ',st1(i),' ',st2(i),' ',flag1,' ',flag2);\n } if (st1(i)=st2(i)) and not flag1 and not flag2 then\n begin writeln('YES'); goto 1; end;\n\n if st1(i) mod p=x[2] mod p then flag1:=true;\n if st2(i) mod p=x[4] mod p then flag2:=true;\n\n end;\n\n writeln('NO');\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}], "negative_code": [{"source_code": "Program CircleMetro;\nuses math;\nvar n,a,x,b,y:longint;\nbegin //assign(input,'1169A.inp'); reset(input);\n //assign(output,'1169A.out'); rewrite(output);\n readln(n,a,x,b,y);\n while not((a=x) and (b=y)) do\n begin if a<>x then inc(a);\n if a>n then a:=a-n;\n if b<>y then dec(b);\n if b<1 then b:=b+n;\n if a=b then begin\n writeln('YES'); exit;\n end;\n end;\n writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,a,xx,b,y,s,s1:longint;\n x:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n read(f,n,a,xx,b,y);\n\n assign(f,fo);rewrite(f);\n s:=a;\n s1:=b;\n x:='NO';\n while (true) do\n begin\n inc(s);\n dec(s1);\n if s1=s then\n begin\n x:='YES';\n break;\n end;\n if s=n then s:=0;\n if s1<1 then s1:=n;\n if s=xx then break;\n if s1=y then break;\n end;\n write(f,x);\n close(f);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,a,xx,b,y,s,s1:longint;\n x:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n read(f,n,a,xx,b,y);\n\n assign(f,fo);rewrite(f);\n s:=a;\n s1:=b;\n x:='NO';\n while (true) do\n begin\n if s1=s then\n begin\n x:='YES';\n break;\n end;\n if s=xx then break;;\n if s1=y then break;\n inc(s);\n dec(s1);\n if s=n then s:=1;\n if s1<1 then s1:=n;\n end;\n write(f,x);\n close(f);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,a,xx,b,y,s,s1:longint;\n x:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n read(f,n,a,xx,b,y);\n\n assign(f,fo);rewrite(f);\n s:=a;\n s1:=b;\n x:='NO';\n while (true) do\n begin\n inc(s);\n dec(s1);\n if s1<1 then s1:=n;\n if s1=s then\n begin\n x:='YES';\n break;\n end;\n if s=n then s:=0;\n if s=xx then break;\n if s1=y then break;\n end;\n write(f,x);\n close(f);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,a,xx,b,y,s,s1:longint;\n x:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n read(f,n,a,xx,b,y);\n\n assign(f,fo);rewrite(f);\n s:=a;\n s1:=b;\n x:='NO';\n while (true) do\n begin\n inc(s);\n dec(s1);\n if s1=s then\n begin\n x:='YES';\n break;\n end;\n if s=n then s:=1;\n if s1<1 then s1:=n;\n if s=xx then break;\n if s1=y then break;\n end;\n write(f,x);\n close(f);\nend."}, {"source_code": "var \n st2,st1 : array[1..5000] of longint;\n j,n,a,b,x,y,i,k,j1,j2,st : longint;\nfunction min(a,b : longint) : longint;\nbegin\n min := b;\n if (a < b) then\n min := b;\nend;\nbegin\n readln(n,a,x,b,y);\n st := a;\n st1[1] := a;\n j := 1;\n while (a <> x) do\n begin\n inc(a);\n if (a > n) then\n a := 1;\n inc(j);\n inc(j1);\n st1[j] := a;\n end;\n st := b;\n st2[1] := b;\n j := 1;\n while (b <> y) do\n begin\n dec(b);\n if (b < 0) then\n b := n;\n inc(j);\n inc(j2);\n st2[j] := b; \n end;\n for i := 1 to min(j1,j2)+1 do\n if (st1[i] = st2[i]) then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var \n st2,st1 : array[1..5000] of longint;\n j,n,a,b,x,y,i,k,j1,j2,st : longint;\nfunction min(a,b : longint) : longint;\nbegin\n min := a;\n if (a > b) then\n min := b;\nend;\nbegin\n readln(n,a,x,b,y);\n st := a;\n st1[1] := a;\n j := 1;\n while (a <> x) do\n begin\n inc(a);\n if (a > n) then\n a := 1;\n inc(j);\n inc(j1);\n st1[j] := a;\n end;\n st := b;\n st2[1] := b;\n j := 1;\n while (b <> y) do\n begin\n dec(b);\n if (b < 0) then\n b := n;\n inc(j);\n inc(j2);\n st2[j] := b; \n end;\n for i := 1 to min(j1,j2)+1 do\n if (st1[i] = st2[i]) and ((st1[i] > 0) and (st2[i] > 0)) then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var n,a,x,b,y,c:integer;\nbegin\nreadln(n,a,x,b,y);\nwhile cn then a:=1;\n if b=0 then b:=n\n end;\nif a=b then writeln('YES') else writeln('NO')\nend."}, {"source_code": "var n,a,x,b,y:integer;\nbegin\nreadln(n,a,x,b,y);\nwhile (ay) do\n begin\n inc(a); dec(b);\n if a=b then break\n end;\nif a=b then writeln('YES') else writeln('NO')\nend."}, {"source_code": "var n,a,x,b,y:integer;\nbegin\nreadln(n,a,x,b,y);\nwhile (a<>b) and (a<=n) and (b>0) do\n begin\n if a=b then break;\n inc(a); dec(b)\n end;\nif a=b then writeln('YES') else writeln('NO')\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b,x,y:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n,a,x,b,y);\n for i:=1 to 100000 do\n begin\n if a=b then\n begin\n writeln(fo,'YES');\n exit;\n end;\n if a<>x then inc(a);\n if b<>y then dec(b);\n if a>n then a:=1;\n if b=0 then b:=n;\n end;\n writeln(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b,x,y:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n,a,x,b,y);\n for i:=1 to 10000 do\n begin\n if a=b then\n begin\n writeln(fo,'YES');\n exit;\n end;\n inc(a);\n dec(b);\n if a>n then a:=1;\n if b=0 then b:=n;\n end;\n writeln(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..250000+1] of int64; integer=longint;\nvar i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n a1,b1,strok:array[-10..250000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]pp;\n { writeln('pp= ',pp,' n= ',n);\n } for i:=pp+1 to n+2 do a[i]:=besk;\n sort(a);\n { for i:=1 to pp do writeln(a[i],' ',a1[i]);\n } for i:=1 to pp do z[i]:=z[i-1]+a1[i];\n { for i:=1 to pp do write(z[i],' '); writeln;\n } ot:=0;\n for i:=1 to pp do ot:=max(ot,z[i]);\n\n\n\n maxvl:=ot;\nend;\n\nfunction st1(t:longint):longint;\nvar ot,tt:longint;\nbegin\n ot:=x[1]+t;\n ot:=ot mod p;\n st1:=ot;\nend;\n\nfunction st2(t:longint):longint;\nvar ot,tt:longint;\nbegin\n ot:=x[3]-t+10*p;\n ot:=ot mod p;\n st2:=ot;\nend;\n\n\n\n\n\nbegin\n\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n\n read(p);\n for i:=1 to 4 do read(x[i]);\n for i:=1 to 4 do dec(x[i]);\n if x[2]x[3] then x[3]:=x[3]+p;\n\n { for i:=0 to 10 do writeln(i,' ',st1(i),' ',st2(i));\n }\n for i:=0 to 1000 do\n begin\n if (st1(i)=st2(i)) and not flag1 and not flag2 then\n begin writeln('YES'); goto 1; end;\n if st1(i)=x[2] then flag1:=true;\n if st2(i)=x[4] then flag2:=true;\n\n end;\n\n writeln('NO');\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}], "src_uid": "5b889751f82c9f32f223cdee0c0095e4"} {"source_code": "var n,x,y,z,min,sum,max,i:longint;\na:array[1..20] of longint;\nprocedure sc(t,w,q,p:longint);\n\nbegin\nif t>n then\n begin\n if (p-q>=z) and (w>=x) and (w<=y) then\n inc(sum);\n exit;\n end;\nsc(t+1,w,q,p);\nif a[t]p then p:=a[t];\nsc(t+1,w+a[t],q,p);\n\n\nend;\n\n\nbegin\n//assign(input,'zbalpkydh.in');reset(input);\n//assign(output,'zbalpkydh.out');rewrite(output);\nreadln(n,x,y,z);\nfor i:=1 to n do\n read(a[i]);\nsc(1,0,maxlongint,0);\nwrite(sum);\nclose(input);\nclose(output);\nend.\n", "positive_code": [{"source_code": "const fi='';\n fo='';\nvar f,g:text;\n a,bang:Array[1..15] of longint;\n i,j,n,l,r,x,kq,t:longint;\n procedure xuli;\n var min,max,sum,i:longint;\n begin\n min:=n;\n max:=1;\n sum:=0;\n for i:=1 to n do\n if bang[i]=1 then\n begin\n if min>i then min:=i;\n if max=x then\n if (sum>=l) and (sum<=r) then inc(kq);\n end;\n procedure tao(vt:byte);\n var i:byte;\n begin\n if vt>n then xuli else\n for i:=1 downto 0 do\n begin\n bang[vt]:=i;\n tao(vt+1);\n end;\n end;\nbegin\n assign(f,fi);\n reset(F);\n assign(g,fo);\n rewrite(g);\n readln(f,n,l,r,x);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\n\n kq:=0;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>A[j] then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n fillchar(bang,sizeof(bang),0);\n tao(1);\n writeln(g,kq);\n close(g);\nend.\n"}, {"source_code": "{**\n * Author : Nguyen Canh Toan\n * Problem : Preparing Olympiad\n * Link : https://codeforces.com/problemset/problem/550/B\n**}\nuses math;\nconst std='550B';\n lim=100001;\n ii=low(int64);\n oo=high(int64);\nvar n,l,r,x,ans:int64;\n c,masks:array [0..lim] of int64;\n input,output:text;\nprocedure cal();\nvar i:longint;\n sum,cmax,cmin:int64;\nbegin\n sum:=0;\n for i:=1 to n do\n if (masks[i]=1) then sum:=sum+c[i];\n if (sumr) then exit;\n cmax:=ii;cmin:=oo;\n for i:=1 to n do\n if (masks[i]=1) then\n begin\n cmax:=max(cmax,c[i]);\n cmin:=min(cmin,c[i]);\n end;\n if (cmax<>ii) and (cmin<>oo) and (cmax-cmin>=x) then inc(ans);\nend;\nprocedure backtrack(i:longint);\nbegin\n if (i>n) then\n begin\n cal();\n exit;\n end;\n masks[i]:=0;\n backtrack(i+1);\n masks[i]:=1;\n backtrack(i+1);\nend;\nprocedure main();\nvar i:longint;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(c[i]);\n ans:=0;\n backtrack(1);\n write(ans);\nend;\nBEGIN\n //assign(input,std+'.inp');reset(input);\n //assign(output,std+'.out');rewrite(output);\n main();\n //close(input);\n //close(output);\nEND.\n"}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=2000000;\n\n label 1,2,3,4;\n type { real=double;} {string=ansistring;}\n int64=longint;\n mas=array [-10000..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var r,pp,p1,p2,x1,y1,x2,y2,h1,h2,k,n,p,t1,t2,mmas,vol,ll,ot,maxzah, period1,ppp,modul,kol,t,sum,k1,q,pos,z,imax,p3,p4,l,nm,s1,s2,m,s,period2,dl:int64;\n mask,step, i,j:longint;\n x,kk,osn, aa,bb, cc,dd:int64;\n a1,b1, per, d1,mm,tt,y,fact,d,c,aold,b,a:array[-100000..500000] of int64;\n dp,dpnew: array[-10..1200,-10..1200] of int64;\n dda: array[-100..120000] of extended;\n marked:array[-10..3000030] of boolean;\n zanx,zany:array[-10..600000] of boolean;\n zan2:array[-10..200,-10..200] of boolean;\n sss, ss1,ss2:string;\n sot:array [-10..1000000] of char;\n prost,zan,fl:array[-10..6000000] of boolean;\n ssss:string;ch:char;\n mnog:array[0..5000000,1..8] of longint;\n ddp, pole :array [-100..2000000] of extended;\n slov,ss,maxpr:array[-10..100000] of string;\n st2:array[0..nn] of string;\n ott,v0,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function phi(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n phi:=p/pi*180;\n end;\n function min(x,y:extended):extended;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n,l,r,x); for i:=1 to n do read(a[i]);\n for i:=1 to n do for j:=1 to n-1 do if a[j]>a[j+1] then\n begin p:=a[j]; a[j]:=a[j+1]; a[j+1]:=p; end;\n ot:=0;\n p:=1; for i:=1 to n do p:=p*2;\n for mask:=1 to p-1 do\n begin\n t:=mask; sum:=0;\n for i:=1 to n do begin b[i]:=t mod 2; t:=t div 2; end;\n { for i:=1 to n do write(b[i],' '); writeln;\n }\n for i:=1 to n do if b[i]=1 then sum:=sum+a[i];\n for i:=n downto 1 do if b[i]=1 then p1:=i;\n for i:=1 to n do if b[i]=1 then p2:=i;\n\n if (sum<=r)and(sum>=l)and(abs( a[p2]-a[p1])>=x) then\n begin inc(ot); {write(mask);} end;\n\n\n end;\n\n write(ot);\n\n 1: close(output);\nend.\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils;\n\nvar\n n,l,r,x,ans:integer;\n s,c:array[1..15] of integer;\n\nprocedure Search(i:integer);\nvar\n j,min,max,cnt,sum:integer;\nbegin\n if i>n then begin\n cnt:=0;\n for j:=1 to n do\n if s[j]=1 then cnt:=cnt+1;\n if cnt>=2 then begin\n sum:=0;\n max:=-1000000;\n min:=1000000;\n for j:=1 to n do\n if s[j]=1 then begin\n sum:=sum+c[j];\n if maxc[j] then min:=c[j];\n end;\n if (sum>=l) and (sum<=r) and (max-min>=x) then inc(ans);\n end;\n exit;\n end;\n Search(i+1);\n s[i]:=1;\n Search(i+1);\n s[i]:=0;\nend;\n\nvar\n i,j:integer;\n\nbegin\n\n\n Readln(n,l,r,x);\n for i:=1 to n do Read(c[i]);\n for i:=1 to n do begin\n s[i]:=0;\n end;\n ans:=0;\n Search(1);\n writeln(ans);\nend.\n"}, {"source_code": "var\n a:array [0..16] of longint;\n n,i,j,sum,dem,s,mint,maxt,l,r,x:longint;\nfunction getbit(x,y:longint):longint;\n begin\n getbit:=(x shr y) and 1;\n end;\nbegin\n readln(n,l,r,x);\n if n=1 then begin writeln(0); halt; end;\n for i:=1 to n do read(a[i]);\n dem:=0;\n for i:=1 to (2 shl (n-1))-1 do\n begin\n mint:=maxlongint;\n maxt:=-maxlongint;\n sum:=0; s:=0;\n for j:=1 to n do\n if getbit(i,j-1)=1 then\n begin\n sum:=sum+a[j];\n if maxta[j] then mint:=a[j];\n inc(s);\n end;\n if (s>1) and (l<=sum) and (sum<=r) and (maxt-mint>=x) then inc(dem);\n end;\n writeln(dem);\nend.\n"}, {"source_code": "const\n fi='';\nvar\n dem,n,l,r,x,i,j,s,min,max:longint;\n a:Array[0..16] of longint;\n f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,l,r,x);\n if n=1 then\n begin\n writeln(0); exit;\n end;\n for i:=1 to n do read(f,a[i]);\n for i:=1 to (1 shl n)-1 do\n begin\n s:=0;\n min:=100000000;\n max:=-1;\n for j:=1 to n do\n if (i shr (j-1)) and 1 = 1 then\n begin\n s:=s+a[j];\n if a[j]>max then max:=a[j];\n if a[j]=l) and (s<=r) and (max-min>=x) then inc(dem);\n end;\n writeln(dem);\n readln;\nend.\n"}, {"source_code": "//uses sysutils;\n\nconst\n inf = trunc(1E9);\n\nvar\n n,l,r,x,i,ans: longint;\n a: array [1..20] of longint;\n v: array [1..20] of boolean;\n\nprocedure complete(t: longint);\nvar i,maxn,minn,sum: longint;\nbegin\n if t > n then begin\n sum := 0;\n for i := 1 to n do if v[i] then inc(sum,a[i]);\n minn := inf;\n maxn := 0;\n for i := 1 to n do if v[i] and (a[i] > maxn) then maxn := a[i];\n for i := 1 to n do if v[i] and (a[i] < minn) then minn := a[i];\n \n if (maxn - minn >= x) and (sum >= l) and (sum <= r) then inc(ans);\n exit;\n end;\n \n v[t] := true;\n complete(t+1);\n v[t] := false;\n complete(t+1);\nend;\n \n\nbegin\n read(n,l,r,x);\n for i := 1 to n do read(a[i]);\n \n ans := 0;\n complete(1);\n \n write(ans);\nend.\n \n "}, {"source_code": "Uses\n Math;\nConst\n many=10000000;\nVar\n n,l,r,x,ans,i:longint;\n m:array[1..15]of longint;\nProcedure Ra(sum,mn,mx,kol,ps:longint);\nBegin\n if ps=n+1 then\n begin\n if (kol>1)and(sum>=l)and(sum<=r)and(mx-mn>=x)then\n inc(ans)\n end\n else\n begin\n Ra(sum,mn,mx,kol,ps+1);\n Ra(sum+m[ps],min(mn,m[ps]),max(mx,m[ps]),kol+1,ps+1);\n end;\nend;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n,l,r,x);ans:=0;\n for i:=1 to n do\n read(m[i]);\n Ra(0,many,-many,0,1);\n writeln(ans);\nend."}, {"source_code": "var l,r,x,s,c1,c2:longint;\n c:array[1..15] of longint;\n a:array[0..15] of byte;\n i,n,k,k1:integer;\nprocedure qs(q,e:longint);\nvar i,j:integer;\n x,buf:longint;\nbegin\ni:=q;\nj:=e;\nx:=c[q+random(e-q)];\nrepeat\nwhile c[i]x do dec(j);\nif i<=j then begin\n buf:=c[i];\n c[i]:=c[j];\n c[j]:=buf;\n inc(i);\n dec(j);\n end;\nuntil i>j;\nif iq then qs(q,j);\nend;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do\n read(c[i]);\nfor i:=0 to n do\n a[i]:=0;\nqs(1,n);\nk1:=0;\nwhile a[0]=0 do\n begin\n k:=0;\n s:=0;\n for i:=1 to n do\n if a[i]=1 then begin\n if s=0 then c1:=c[i];\n s:=s+c[i];\n inc(k);\n c2:=c[i];\n end;\n if (s>=l) and (s<=r) and (k>=2)\n and ((c2-c1)>=x) then inc(k1);\n i:=n;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n a[i]:=1;\n end;\nwriteln(k1);\nend."}, {"source_code": "uses math;\nvar\n a,b:array[1..1000] of longint;\n n,l,r,x,kol,ma,mi,res,ans,i,j:longint;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n b[n]:=1;\n kol:=1;\n for i:=1 to 1 shl n-1 do\n begin\n for j:=n downto 1 do\n begin\n if b[j]=0 then begin b[j]:=1;inc(kol);break;end;\n if b[j]=1 then begin b[j]:=0;dec(kol);end;\n end;\n if kol>=2 then\n begin\n ma:=0;\n mi:=maxlongint;\n res:=0;\n for j:=1 to n do if b[j]=1 then\n begin\n ma:=max(ma,a[j]);\n mi:=min(mi,a[j]);\n inc(res,a[j]);\n end;\n if (res>=l)and(res<=r)and(ma-mi>=x) then inc(ans);\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var n,l,r,x,mask,k,sum,max,min,kol,i:longint; c:array[1..16] of longint;\nbegin\n read(n,l,r,x);\n for i:=1 to n do\n read(c[i]);\n k:=0;\n for mask:=1 to (1 shl n)-1 do\n begin\n sum:=0;\n max:=0;\n min:=1000000000;\n kol:=0;\n for i:=1 to n do\n if mask and (1 shl (i-1))> 0 then begin sum:=sum+c[i]; if c[i]> max then max:=c[i]; if c[i]=l) and (sum<=r) and (max-min>=x) and (kol>=2) then k:=k+1;\n end;\n writeln(k);\nend.\n "}, {"source_code": "var n,l,r,x,so:int64;i:longint; a:array[1..15] of int64; m:array[1..1000] of longint;\nprocedure kt(Vt:longint);\nvar i,max,min,t:longint;\nbegin\n\tmin:=99999999;\n\tmax:=0;\n\tt:=0;\n\tfor i:=1 to vt do \n\tbegin\n\t\t{writeln(m[i]);}\n\t\tif a[m[i]]>max then max:=a[m[i]];\n\t\tif a[m[i]]=l) and (t<=r) and (max-min>=x) then inc(so);\n\t{writeln(t,' ',max,' ',min);}\nend;\t\nprocedure de_quy(e,vt:int64);\nvar i,min1,max1:longint;\nbegin\n\tfor i:=e to n do\n\tbegin\n\t\tm[vt]:=i;\n\t\tif vt>1 then kt(vt);\n\t\tde_quy(i+1,vt+1);\t\n\tend;\nend;\nbegin\n\treadln(n,l,r,x);\n\tfor i:=1 to n do read(a[i]);\n\tde_quy(1,1);\n\twriteln(so);\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar n,l,r,x,gt:longint;\n a:array[1..100] of longint;\nprocedure doc;\nvar f:Text;\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n gt:=1;\n readln(f,n,l,r,x);\n for i:=1 to n do\n begin\n read(f,a[i]);\n gt:=gt*2;\n end;\n close(f);\nend;\nprocedure sort(l,r:longint);\nvar i,j,x,y:longint;\nbegin\n x:=a[(r+l) div 2];\n i:=l;\n j:=r;\n while ix do\n dec(j);\n if i<=j then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n dec(j);\n end;\n end;\n if i0 do\n begin\n inc(j);\n i:=k mod 2;\n k:=k div 2;\n if i=1 then\n begin\n t:=t+a[j];\n inc(sl);\n if nn=0 then nn:=a[j];\n ln:=a[j];\n end;\n end;\n if (sl>1) and (t>=l) and (t<=r) and (ln-nn>=x) then\n exit(true)\n else\n exit(false);\nend;\nprocedure xl;\nvar f:Text;\n dem,i:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n dem:=0;\n sort(1,n);\n for i:=1 to gt-1 do\n begin\n if kt(i)=true then\n inc(dem);\n end;\n write(f,dem);\n close(f);\nend;\nbegin\n doc;\n xl;\nend.\n"}, {"source_code": "var a,c:array[0..15] of longint;\n i,k,j,s,l,r,x,n,k1,t1,t2:longint;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do\n read(c[i]);\n\n fillchar(a,sizeof(a),0);\n for i:=1 to n-1 do\n for j:=1 to n-i do\n if c[j]>c[j+1]then begin\n k:=c[j];\n c[j]:=c[j+1];\n c[j+1]:=k;\n end;\n k:=0;\n while a[0]=0 do\n begin\n k1:=0; s:=0;\n for i:=1 to n do\n if a[i]=1 then\n begin\n inc(s,c[i]);\n inc(k1);\n t2:=i;\n end;\n\n if k1>=2 then\n begin\n for i:=1 to n do\n if a[i]=1 then break;\n t1:=i;\n if (s>=l)and(s<=r)and\n (abs(c[t2]-c[t1])>=x)then inc(k);\n end;\n\n i:=n;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n a[i]:=1;\n end;\n writeln(k);\nend."}, {"source_code": "uses math ;\nconst\n oo = 1000000000 + 9 ;\nvar\n l , r , x , n , m , dem , k : longint ;\n b : array[ 0 .. 16 ] of longint ;\n a : array[ 0 .. 16 ] of int64 ;\n\nprocedure kt ;\nvar\n i , ln , nn : longint ;\n tong : int64 ;\nbegin\n tong := 0 ;\n ln := 0 ;\n nn := oo ;\n for i := 1 to m do\n begin\n tong := tong + a[b[i]] ;\n ln := max ( ln , a[b[i]] ) ;\n nn := min ( nn , a[b[i]] ) ;\n\n end;\n if ( tong >= l ) and ( tong <= r ) and ( ln - nn >= x ) then\n inc (dem ) ;\nend;\n\nprocedure thu( i : longint ) ;\nvar\n j : longint ;\nbegin\n\n if i = n + 1 then exit ;\n for j := 1 + b[i-1] to n do\n begin\n b[i] := j ;\n m := i ;\n kt ;\n thu( i + 1 ) ;\n end;\nend;\n\nbegin\n\n read ( n , l , r , x ) ;\n for m := 1 to n do read ( a[m] ) ;\n dem := 0 ;\n for k := 1 to n do\n begin\n b[1] := k ;\n thu( 2 ) ;\n end;\n write(dem ) ;\nend .\n"}, {"source_code": "var\na,used:array[1..10000] of longint; q,n,l,r,x,i:longint;\nprocedure check;\nvar\nsum,max,i,min:longint;\nbegin\nsum:=0;\nfor i:=1 to n do\nif used[i]=1 then sum:=sum+a[i];\nif (sumr) then exit;\nmax:=0;\nfor i:=1 to n do if used[i]=1 then\n if maxa[i] then min:=a[i];\nif (max<>0) and (min<>maxlongint) then\n if max-min>=x then inc(q);\nend;\nprocedure pereb(step:longint);\nbegin\nif step > n then begin check; exit; end;\nused[step]:=0;\npereb(step+1);\nused[step]:=1;\npereb(step+1);\nend;\nbegin\nread(n,l,r,x);\nfor i:=1 to n do read(a[i]);\npereb(1);\nwrite(q);\nend."}, {"source_code": "var{ f1,f2:text;}\n n,r,l,x,i,j,k,m,min,max,sum:longint;\n a:array[0..15] of byte;\n c:array[1..15] of integer;\nbegin\n{ assign(f1,'input.txt');\n reset(f1);\n assign(f2,'output.txt');\n rewrite(f2);}\n readln(n,l,r,x);\n max:=0;\n min:=100001;\n sum:=0;\n k:=0;\n for i:=1 to n do\n read(c[i]);\n for i:=0 to n do\n a[i]:=0;\n while a[0]=0 do\n begin\n\n for j:=1 to n do\n if a[j]=1\n then\n begin\n sum:=sum+c[j];\n if c[j]>max\n then\n max:=c[j];\n if c[j]1) and (sum>=l) and (sum<=r) and ((max-min)>=x)\n then\n inc(k);\n m:=0;\n min:=1000001;\n max:=0;\n sum:=0;\n i:=n;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n a[i]:=1;\n end;\n writeln(k);\n{ close(f1);\n close(f2);}\nend."}, {"source_code": "program z1;\ntype niz=array[1..15] of longint;\nvar n,i,j,z,h,y:integer;\nx,l,r,br,t,s:longint;\na,b:niz;\nfunction brojanje (n:integer;var a:niz):integer;\n var i,j:integer;\n begin\n i:=n;\n while (i>0) and (a[i]=1) do\n i:=i-1;\n if (i=0) then brojanje:=0\n else\n begin\n brojanje:=1;\n a[i]:=1;\n for j:=i+1 to n do\n a[j]:=0;\n end;\n end;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do\n read (a[i]);\nfor i:=1 to n-1 do\n for j:=i+1 to n do\n if (a[i]>a[j]) then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\nfor i:=1 to n do\n b[i]:=0;\nbr:=0;\nrepeat\nz:=0;\ns:=0;\nfor i:=1 to n do\n if (b[i]=1) then z:=z+1;\nif (z>1) then\nbegin\nz:=0;\nfor i:=n downto 1 do\n begin\n if (b[i]=1) then\n begin\n h:=i;\n s:=s+a[i];\n end;\n if (z=0) and (b[i]=1) then\n begin\n y:=i;\n z:=1;\n h:=i;\n end;\n end;\nif (s>=l) and (s<=r) and (a[y]-a[h]>=x) then\n br:=br+1;\nend;\nuntil (brojanje (n,b)=0);\nwriteln (br);\nend.\n"}, {"source_code": "var\na:array[0..100000,0..20] of longint;\nb:array[1..16] of longint;\nn,l,r,x:longint;\n\nprocedure transform(n:longint);\nvar\ni,nn:longint;\nbegin\n i:=1;\n nn:=n;\n while nn>0 do\n begin\n a[n,i]:=nn mod 2;\n nn:=nn div 2;\n inc(i);\n end;\nend;\n\nfunction check(n:longint):boolean;\nvar\ni,num,min,max,sum:longint;\nbegin\nnum:=0;\nmax:=0;\nsum:=0;\nmin:=1000000;\n for i:=1 to 20 do\n begin\n num:=num+a[n,i];\n if (a[n,i]=1) and (b[i]max) then max:=b[i];\n if a[n,i]=1 then sum:=sum+b[i];\n end;\n\nif (n>1) and (sum>=l) and (sum<=r) and (max-min>=x) then\n check:=true else check:=false;\n // writeln('n=',n,' min=',min,' max=',max,' sum=',sum,' f=',check);\nend;\n\nvar\ni,t,ans,j:longint;\n\nbegin\n{\nassign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);\n}\nreadln(n,l,r,x);\nfor i:=1 to n do\nread(b[i]) ;\n t:=1;\n for i:=1 to n do\n t:=t*2;\n ans:=0;\n// writeln('t=',t);\n for i:=1 to t-1 do\n transform(i);\n for i:=1 to t-1 do\n if check(i) then inc(ans);\n writeln(ans);\n {\n writeln('------');\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do\n write(a[i,j]);\n writeln;\n end;\n }\n\nend.\n"}, {"source_code": "{$mode objfpc}\nvar n,l,r,x,dem:int64;i:integer;\n a:array[1..15] of int64;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=x) then inc(dem);\n for i:=t-1 downto 1 do\n begin\n if s+a[i]<=r then xo(s+a[i],i,max);\n end;\n end;\n\nbegin\n read(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n sort(1,n);\n FOR i:=n downto 2 do\n xo(a[i],i,a[i]);\n write(dem);\nend."}, {"source_code": "var fi,fo: text;\n A:array[1..20] of longint;\n n,l,r,x: longint;\n dem: longint;\n{------------------------------}\nprocedure input;\nvar i: longint;\nbegin\n readln(fi,n,l,r,x);\n for i:=1 to n do read(fi,A[i]);\nend;\n{------------------------------}\nprocedure sort;\nvar i,j,tam: longint;\nbegin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if A[i] > A[j] then\n begin\n tam := A[i];\n A[i] := A[j];\n A[j] := tam;\n end;\nend;\n{------------------------------}\nprocedure xuli(s,t,m: longint);\nvar i: longint;\nbegin\n if (s >= l) and (s <= r) and (m - A[t] >= x) then\n inc(dem);\n for i:=t-1 downto 1 do\n if s + a[i] <= r then\n xuli(s + A[i], i , m);\nend;\n{------------------------------}\nprocedure process;\nvar i: longint;\nbegin\n input;\n sort;\n for i:=n downto 2 do\n xuli(a[i],i,a[i]);\n writeln(fo,dem);\nend;\n{------------------------------}\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n process;\n close(fi); close(fo);\nend.\n"}, {"source_code": "var\n n , l , r , xx , kq : longint;\n a , x : array[0..16] of longint;\nprocedure tv( i : longint );\nvar\n j , dau , cuoi , tong : longint;\nbegin\n if i = n + 1 then\n begin\n tong := 0;\n for j := 1 to n do\n if x[ j ] = 1 then\n tong := tong + a[ j ];\n for j := 1 to n do\n if x[ j ] = 1 then\n begin\n dau := j;\n break;\n end;\n for j := n downto 1 do\n if x[ j ] = 1 then\n begin\n cuoi := j;\n break;\n end;\n if ( tong >= l ) and ( tong <= r ) and ( a[ cuoi ] - a[ dau ] >= xx ) then\n inc( kq );\n exit;\n end;\n for j := 0 to 1 do\n begin\n x[ i ] := j;\n tv( i + 1 );\n end;\nend;\nprocedure xuli;\nvar\n i , j , k , tam : longint;\nbegin\n read( n , l , r , xx );\n for i := 1 to n do\n read( a[ i ] );\n for i := 1 to n do\n for j := i + 1 to n do\n if a[ i ] > a[ j ] then\n begin\n tam := a[ i ];\n a[ i ] := a[ j ];\n a[ j ] := tam;\n end;\n kq := 0;\n tv( 1 );\n write( kq );\nend;\nbegin\n xuli;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n,l,r,x,i,j,min,max,dem,s:longint;\n a:array[1..32768] of longint;\n f,g:text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n,l,r,x);\n for i:=1 to n do\n read(f,a[i]); dem:=0;\n for i:=1 to (2 shl(n-1) - 1) do\n begin\n if n = 1 then begin writeln(g,'0'); close(f); close(g); exit; end;\n min:=maxlongint;\n max:=-maxlongint;\n s:=0;\n for j:=1 to n do\n if (i shr(j-1) and 1) = 1 then\n begin\n s:=s + a[j];\n if a[j] >= max then max:=a[j];\n if a[j] <= min then min:=a[j];\n end;\n if (s >= l) and (s <= r) and (max - min >= x) then inc(dem);\n end;\n writeln(g,dem);\n close(f); close(g);\nend."}, {"source_code": "uses math;\n\nvar n, l, r, x, kq, t, dem, sum, cmax, cmin, i: longint;\n c: array[0..20] of longint;\n\nbegin\n read (n, l, r, x);\n for i := 1 to n do read (c[i]);\n kq := 0;\n for t := 1 to ((1 SHL n) - 1) do\n begin\n dem := 0; sum := 0; cmax := 0; cmin := maxlongint;\n for i := 1 to n do\n if ((t shr (i - 1)) and 1) = 1 then \n begin\n inc (dem);\n sum := sum + c[i];\n cmax := max (cmax, c[i]);\n cmin := min (cmin, c[i]);\n end;\n if (dem >= 2) and (sum >= l) and (sum <= r) and (cmax - cmin >= x) then inc (kq);\n end;\n write (kq);\nend.\n"}, {"source_code": "program xx;\nvar a:array[0..20] of longint;\n ans:int64;\n i,j,k,n,m,p,q,r,st,en,x,l:longint;\n\nprocedure dfs(zuo,you,mi,ma,now:longint);\nvar i,j,k:longint;\nbegin\n if (now>=mi) and (now<=ma) then inc(ans);\n if (zuo>you) or (now>ma) then exit;\n for i:=zuo to you do\n dfs(i+1,you,mi,ma,now+a[i]);\nend;\n\nbegin\n read(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then begin p:=a[i]; a[i]:=a[j]; a[j]:=p; end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[j]-a[i]>=x then dfs(i+1,j-1,l,r,a[i]+a[j]);\n writeln(ans);\nend."}, {"source_code": "uses math;\nconst\n fi ='';\n fo ='';\n\n var\n inp , oup : text;\n n : longint;\n l , r , x : longint;\n a : array[0..20] of longint;\n ftot : longint;\n tot : longint;\n fd: array[0..20] of boolean;\n fmax : longint;\nProcedure mo;\n begin\n assign(inp,fi);\n reset(inp);\n assign(oup,fo);\n rewrite(oup);\n end;\n\nprocedure dong;\n begin\n close(inp);\n close(oup);\n end;\n\nprocedure doc;\n var i : longint;\n begin\n readln(inp,n,l,r,x);\n for i:=1 to n do\n read(inp,a[i]);\n end;\n\nprocedure swap(var x , y: longint);\n var tg : longint;\n begin\n tg:=x; x:=y;\n y:=tg;\n end;\n\nprocedure sort(d, c : longint);\n var i , j , g : longint;\n begin\n i:=d;\n j:=c;\n g:=a[i+random(j-i+1)];\n repeat\n while a[i]g do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n i:=i+1;\n j:=j-1;\n end;\n until i>j;\n if j>d then sort(d,j);\n if im then\n begin\n if (ftot>=l) and (ftot<=r) then\n inc(tot);\n exit;\n end;\n for j:=jp+1 to c do\n if fd[j]=false then\n begin\n fd[j]:=true;\n ftot:=ftot+a[j];\n xet(i+1,d,c,m,j);\n ftot:=ftot-a[j];\n fd[j]:=false;\n end;\n end;\n\nprocedure xuly;\n var i , j , k : longint;\n begin\n tot:=0;\n sort(1,n);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[j]-a[i]>=x then\n begin\n fmax:=a[i]+a[j];\n ftot:=a[i]+a[j];\n if (a[i]+a[j]>=l) and (a[i]+a[j]<=r) then inc(tot);\n if j>=i+2 then\n begin\n k:=1;\n repeat\n if k>j-i-1 then break;\n fmax:=fmax+a[i+k];\n if fmax>r then break;\n xet(1,i+1,j-1,k,i);\n inc(k);\n until false;\n end;\n end;\n writeln(oup,tot);\n end;\n\nbegin\n mo;\n doc;\n xuly;\n dong;\nend.\n"}, {"source_code": "uses math;\n\nconst inf = trunc(1e6) + 1;\n\nvar c:array[0..100] of longint;\n n,l,r,x,i,ans:longint;\n\n\nprocedure tt(h,kolz,s,mx,mn:longint);\n begin\n\n if h = n + 1 then\n begin\n\n if(mx-mn>=x)and(kolz>=2)and(s>=l)and(s<=r) then inc(ans);\n exit;\n\n end;\n\n tt(h+1,kolz+1,s+c[h],max(mx,c[h]),min(mn,c[h]));\n tt(h+1,kolz,s,mx,mn);\n\n end;\n\n procedure zero;\n begin\n writeln(0);\n halt;\n end;\n\n\n begin\n\n read(n);\n if n < 2 then zero;\n read(l,r,x);\n\n for i:=1 to n do read(c[i]);\n\n tt(1,0,0,0,inf);\n\n writeln(ans);\n\n end."}, {"source_code": "uses math;\ntype arr=array [0..15] of longint;\nvar x,a:arr;\n kq,tong,smin,smax,n,l,r,k,i:longint;\nprocedure update(var x:arr);\nbegin\n tong:=0;\n smin:=maxlongint;\n smax:=-maxlongint;\n for i:=1 to n do\n if x[i]=1 then\n begin\n inc(tong,a[i]);\n smin:=min(smin,a[i]);\n smax:=max(smax,a[i]);\n end;\n if (tong>=l) and (tong<=r) and (smax-smin>=k) then inc(kq);\nend;\nprocedure trya(i,k:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i=k then update(x)\n else trya(i+1,k);\n end;\nend;\nbegin\n read(n,l,r,k);\n for i:=1 to n do\n read(a[i]);\n trya(1,n);\n write(kq);\nend."}, {"source_code": "var a:array[1..15] of longint;\n s:array[0..32768] of integer;\n n,l,r,x,i,j,max,min,dem:longint;\nFunction GetBIT(k , x : LongInt) : LongInt;\n begin\n GetBIT := (x shr (k-1)) and 1;\n end;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n dem:=0;\n for i:=0 to (2 shl (n-1)) -1 do\n begin\n min:=1000000000;\n max:=-1000000000;\n\n for j:=1 to n do\n begin\n s[i]:=s[i]+a[j]*getbit(j,i);\n if getbit(j,i)<>0\n then\n begin\n if a[j]max then max:=a[j];\n end;\n\n end;\n if (s[i]>=l) and (s[i]<=r) and (max-min>=x) then inc(dem);\n end;\n writeln(dem);\n readln;\n readln;\nend.\n\n\n\n"}, {"source_code": "var\n a, b, c, d, e, k, j, i, l, r, u, sum, p, o: int64;\n ar: array [1..1000] of int64;\n \nfunction min(a, b: int64): int64;\nbegin\n if a < b then min := a\n else min := b;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if a > b then max := a\n else max := b;\nend;\n \nbegin\n readln(a, b, c, d);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n inc(i);\n end;\n i := 1;\n e := 1;\n k := 0;\n while i <= a do begin\n inc(k, e);\n e := e * 2;\n inc(i);\n end;\n i := 3;\n o := 0;\n while i <= k do begin\n j := 1;\n p := a;\n l := 10000000;\n r := 0;\n u := 0;\n sum := 0;\n while j <= 16384 do begin\n if (i or j = i) then begin\n l := min(ar[p], l);\n r := max(ar[p], r);\n inc(sum, ar[p]);\n inc(u);\n end;\n dec(p);\n j := j * 2;\n end;\n if (r - l >= d) and (sum >= b) and (sum <= c) and (u >= 2) then inc(o);\n inc(i);\n end;\n writeln(o);\nend."}, {"source_code": "uses math;\nvar a:array[0..15] of longint;\n i,n,l,r,x,count,tmp:longint;\nprocedure sort(r,n:longint);\nvar key,c:longint;\nbegin\n key:=a[r];\n while (2*r<=n) do\n begin\n c:=2*r;\n if (c=a[c]) then break;\n a[r]:=a[c];\n r:=c;\n end;\n a[r]:=key;\nend;\nprocedure back(m,vmin,vmax,s,k:longint);\nbegin\n if (m>n) then\n begin\n if (k>1) and (vmax-vmin>=x) and (s>=l) and (s<=r) then\n inc(count);\n exit;\n end;\n back(m+1,min(vmin,a[m]),max(vmax,a[m]),s+a[m],k+1);\n back(m+1,vmin,vmax,s,k);\nend;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n for i:=n div 2 downto 1 do sort(i,n);\n for i:=n downto 2 do\n begin\n tmp:=a[i];\n a[i]:=a[1];\n a[1]:=tmp;\n sort(1,i-1);\n end;\n count:=0;\n back(1,10000000,0,0,0);\n writeln(count);\nend."}, {"source_code": "var a,c:array[1..15]of longint;\nmask,k,n,s,max,min,k1,l,r,x,i:longint;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do\nread(c[i]);\nk:=0;\nfor mask:=0 to (1 shl n)-1 do\nbegin\ns:=0;max:=0; min:=10000000;k1:=0;\nfor i:=1 to n do\nif mask and (1 shl(i-1))>0 then begin k1:=k1+1; a[k1]:=c[i]; s:=s+c[i]; end;\nfor i:=1 to k1 do begin\nif a[i]>max then max:=a[i];\nif a[i]=x)and(s>=l)and(s<=r) then k:=k+1;\nfor i:=1 to k1 do\na[i]:=0;\nend;\nwriteln(k);\nend.\n\n"}, {"source_code": "{$mode objfpc}\nvar\n f1,f2 : text;\n s : ansistring;\n i,j,j1,n,l,r,x,re,x1 : integer;\n a,t : array[0..10000] of integer;\nprocedure attemp(x:integer);\nvar\n i : integer;\nprocedure increase;\nvar\n i : integer; min,max,sum : int64;\nbegin\n max := 0;\n sum := 0;\n min := round(1e9);\n for i := 1 to n do\n if t[i] = 1 then\n begin\n sum := sum + a[i];\n if a[i] > max then max := a[i];\n if a[i]< min then min:= a[i];\n end;\n if (sum >=l) and(sum <= r) and ( max - min >= x1) then\n inc(re);\nend;\nbegin\n for i := 0 to 1 do\n begin\n t[x] := i;\n if x = n then\n begin\n increase;\n end\n else\n attemp(x+1);\n end;\nend;\nbegin\n\n readln(n,l,r,x1);\n for i := 1 to n do read(a[i]);\n attemp(1);\n writeln(re);\nend.\n"}, {"source_code": "var n,i,j:longint;\n max,min,dem,l,r,x:longint;\n a,s:array[1..100000] of longint;\nfunction getbit(k,n:int64):longint;\n begin\n getbit:=(n shr (k-1) ) and 1;\n end;\nbegin\n read(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n dem:=0;\n for i:=1 to (1 shl n)-1 do\n begin\n s[i]:=0;\n max:=0;\n min:=maxlongint;\n for j:=1 to n do\n if getbit(j,i)=1 then\n begin\n s[i]:=s[i]+a[j];\n if maxa[j] then min:=a[j];\n end;\n if (max-min>=x) and (l<=s[i]) and (s[i]<=r) then\n dem:=dem+1;\n\n end;\n writeln(dem);\n\nend."}, {"source_code": "var\n ans, l, r:int64;\n a:array[1..15] of int64;\n n, x, i:longint;\nprocedure make(i, y:longint);\nvar sum, min, max:int64; j:longint;\nbegin\n if i=n+1 then\n begin\n min:=100000000000;\n max:=0; sum:=0;\n for j:=1 to n do\n begin\n if not odd(y) then\n begin \n inc(sum, a[j]);\n if a[j]max then max:=a[j];\n end;\n y:=y div 2;\n end;\n if (max-min>=x)and(sum>=l)and(sum<=r) then\n inc(ans);\n exit;\n end;\n make(i+1, y*2);\n make(i+1, y*2+1);\nend;\nbegin\n readln(n, l, r, x);\n for i:=1 to n do\n read(a[i]);\n make(1, 1);\n writeln(ans);\nend.\n"}, {"source_code": "Var n,x,l,r,k,min,max,mask,i,cut,sum:longint;\n c:array[1..100] of longint;\n Begin\n read(n,l,r,x);\n for i:=1 to n do\n read(c[i]);\n for mask:=0 to (1 shl n)-1 do\n begin\n sum:=0;\n cut:=0;\n max:=0;\n min:=1000000;\n for i:=1 to n do\n begin\n if mask and (1 shl(i-1))>0\n then \n begin\n sum:=sum+c[i];\n cut:=cut+1;\n if c[i]>max then max:=c[i];\n if c[i]1) and (sum>=l) and (sum<=r) and (max-min>=x) then k:=k+1;\n end;\n writeln(k);\n End."}, {"source_code": "var ans,n,l,r,x,sum,max,min,pp:int64;\ni,j:longint;\na:array[0..100001] of int64;\nbegin\n//assign(input,'zbalpkydh.in');reset(input);\n//assign(output,'zbalpkydh.out');rewrite(output);\nreadln(n,l,r,x);\nfor i:=1 to n do read(a[i]);\nfor i:=0 to 1 shl n-1 do\n begin\n sum:=0;max:=0;min:=maxlongint;pp:=0;\n for j:=1 to n do\n if i shr (j-1) mod 2=1 then\n begin\n sum:=sum+1;\n pp:=pp+a[j];\n if a[j]>max then max:=a[j];\n if a[j]=2)and(pp>=l)and(pp<=r)and(max-min>=x)then ans:=ans+1;\n end;\nwriteln(ans);\nclose(input);close(output);\nend."}, {"source_code": "VAR\n n,s,min,i,l,r,kq,x,j,tam : longint;\n a : array[0..16] of longint;\n d : array[0..16] of longint;\n\nFunction kt : boolean;\nvar i,dd,cc,s,dem : longint;\n begin\n s := 0; dem := 0;\n for i := 1 to n do\n if d[i] = 1 then begin\n s := s + a[i];\n inc(dem);\n end;\n if dem = 1 then exit(false);\n for dd := 1 to n do\n if d[dd] = 1 then break;\n for cc := n downto 1 do\n if d[cc] = 1 then break;\n if (s>= l) and (s<= r) and (a[cc]-a[dd] >=x ) then exit(true)\n else exit(false);\n end;\n\nProcedure THU(k : longint);\nvar i : longint;\n begin\n if k = n + 1 then begin\n if kt then inc(kq);\n exit;\n end;\n for i := 0 to 1 do begin\n d[k] := i;\n THU(k+1);\n d[k] := 0;\n end;\n end;\n\nBEGIN\n read(n,l,r,x);\n for i := 1 to n do read(a[i]);\n for i := 1 to n-1 do\n for j := i+1 to n do\n if a[i] > a[j] then begin\n tam := a[i];\n a[i] := a[j];\n a[j] := tam;\n end;\n THU(1);\n write(kq);\nEND.\n"}, {"source_code": "uses math;\nvar i,n,l,r,y,x,j,k:longint; a:array[1..15]of longint;\nfunction vari(nom,mi,ma,s,kil:longint):longint;\nbegin\nif nom>n then\nbegin\nif (kil>1) and (ma-mi>=x) and (l<=s) and (r>=s) then\nbegin\ninc(k);\nend;\nexit;\nend;\nvari(nom+1,min(mi,a[nom]),max(ma,a[nom]),s+a[nom],kil+1);\nvari(nom+1,mi,ma,s,kil);\nend;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n-1 do\nfor j:=i+1 to n do\nif a[i]>a[j] then\nbegin\ny:=a[i]; a[i]:=a[j]; a[j]:=y;\nend;\nvari(1,10000000,0,0,0);\nwriteln(k);\nend."}, {"source_code": "var\n z,q,ans,l,r,i,j,n,m,k,t,x:longint;\n a,b:array[0..111]of longint;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n for i:=0 to 1 shl n-1 do\n begin\n k:=0;q:=0;\n for j:=0 to 15 do if i shr j and 1=1 then begin inc(k);b[k]:=a[n-j];inc(q,b[k]);end;\n for j:=1 to k-1 do for z:=j+1 to k do if b[j]>b[z] then\n begin t:=b[j];b[j]:=b[z];b[z]:=t;end;\n if(q>=l)and(q<=r)and(b[k]-b[1]>=x)then inc(ans);\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "var\n hard:array[1..15]of longint;\n n,summax,summin,cha,i,j:longint;\n\nprocedure swap(num:longint;var min,max:longint);\nbegin\n if num>max then max:=num;\n if num=2 then if (sum>=summin)and(sum<=summax)and(max-min>=cha) then ans:=ans+1;\n if choosed>=1 then\n begin\n swap(hard[n],min,max);\n sum:=sum+hard[n];\n if (sum>=summin)and(sum<=summax)and(max-min>=cha) then ans:=ans+1;\n end;\n end\n else\n begin\n ans:=ans+dfs(now+1,sum,min,max,choosed);\n\n swap(hard[now],min,max);\n sum:=sum+hard[now];\n ans:=ans+dfs(now+1,sum,min,max,choosed+1);\n end;\n dfs:=ans;\nend;\n\n\n\n\n\nbegin\n readln(n,summin,summax,cha);\n for i:=1 to n do read(hard[i]);\n\n\n writeln(dfs(1,0,10000000,0,0));\nend.\n"}, {"source_code": "var n,l,r,x,s,max,min,cnt,i,mask,k:longint;c:array [1..16] of longint;\nbegin\nreadln(n,l,r,x);k:=0;\nfor i:=1 to n do\nread(c[i]);\nfor mask:=0 to (1 shl n)-1 do\nbegin\ns:=0;cnt:=0;max:=-1;min:=10000000;\nfor i:=1 to n do\nbegin\nif (mask and(1 shl(i-1)))>0 then begin \n cnt:=cnt+1;\n s:=s+c[i];\n if c[i]>max then max:=C[i];\n if c[i]=2) and ((s>=l) and (s<=r)) and (max-min>=x) then k:=k+1; \nend;\nwriteln(k);\nend."}, {"source_code": "var\n f : array [0..111111] of longint;\n min,max,l,r,n,res,i,j,k,m,h,c,x,z : longint;\n\nbegin\n readln(n, l, r, x);\n for i:=1 to n do read(f[i]);\n res:=0;\n z:=1 shl n;\n\n for i:=0 to z do\n begin\n min:=maxlongint;\n max:=0;\n h:=0;\n for j:=1 to n do if (i shr (n - j)) and 1 = 1 then\n begin\n if f[j] > max then max:=f[j];\n if f[j] < min then min:=f[j];\n inc(h, f[j]);\n end;\n if (max - min >= x)and(h >= l)and(h <= r) then inc(res);\n end;\n writeln(res);\nend."}, {"source_code": "var n, l, r, x, i, j, k, ans, mask : longint;\n a, b : array[0 .. 111] of longint;\n\nfunction good(mask : longint) : boolean;\nvar cnt, i, sum : longint;\nbegin\n cnt := 0;\n sum := 0;\n for i := 1 to n do\n if mask and (1 shl (i - 1)) > 0 then \n begin\n cnt := cnt + 1;\n b[cnt] := a[i];\n sum := sum + b[cnt];\n end;\n if (sum < l) or (sum > r) or (cnt < 2) or (b[cnt] - b[1] < x) then\n good := false else good := true;\nend;\n\nbegin \n readln(n, l, r, x);\n for i := 1 to n do read(a[i]);\n for i := 1 to n do\n for j := 1 to n - i do\n if a[j] > a[j + 1] then begin a[0] := a[j]; a[j] := a[j + 1]; a[j + 1] := a[0]; end;\n ans := 0;\n for mask := 0 to (1 shl n) - 1 do\n if good(mask) then ans := ans + 1;\n writeln(ans);\nend.\n"}, {"source_code": "var\nn,m,t,l,r,x,i,j,ll,max,min,sum:longint;\na:array[1..15]of longint;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do read(a[i]);\nfor i:=0 to (2 shl (n-1)-1) do\nbegin\nsum:=0; max:=-1; min:=maxlongint; ll:=0;\nfor j:=1 to n do if (i shr (j-1)) and 1=1 then\nbegin\ninc(ll);\ninc(sum,a[j]);\nif a[j]max then max:=a[j];\nend;\nif(sum>=l) and (sum<=r) and (max-min>=x) and (ll>1) then inc(t);\nend;\nwriteln(t);\nend.\n"}, {"source_code": "program nabory;\nvar a:array[1..100] of longint;\n n,l,r,x,c,t,i,q,kol,j,np,k1,k2,pr,f,ans:longint; g:int64;\n s:string;\nbegin\nread(n,l,r,x);\nfor i:=1 to n do\nread(a[i]);\n\nfor i:=1 to n-1 do\nfor j:=1 to n-i do\nif a[j]>a[j+1] then begin\n np:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=np;\n end;\nans:=0;\ns:='';\nt:=1;\nfor i:=1 to n do\nt:=t*2;\ndec(t);\ng:=0;\nfor i:=1 to t do\nbegin\nt:=i;\nwhile(t<>0) do\nbegin\nif t mod 2=0 then s:=s+'0';\nif t mod 2<>0 then s:=s+'1';\nt:=t div 2;\n\nend;\n\nfor j:=1 to length(s) do\nbegin\n for f:=1 to length(s) do\n if s[f]='1' then begin k1:=a[f]; break; end;\n for f:=length(s) downto 1 do\n if s[f]='1' then begin k2:=a[f]; break; end;\n\nval(s[j],c,q);\nif c=1 then begin g:=g+a[j]; inc(kol); end;\nend;\n\n pr:=abs(k1-k2);\n\nif (g>=l) and (g<=r) and (kol>=2) and (pr>=x) then inc(ans);\n\ng:=0;\nkol:=0;\ns:='';\nend;\n\n\nwriteln(ans);\n\n\nend."}, {"source_code": "uses\n math;\n\nvar\n a:array[0..100] of int64;\n i,j,bit,ans:longint;\n n,l,r,x,sum,mx,mn:int64;\n \nBegin\n read(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n ans:=0;\n for i:=1 to 1 shl n - 1 do\n begin\n bit:=0; sum:=0;\n mn:=trunc(1e16); mx:=-trunc(1e6);\n for j:=0 to n-1 do\n if (i and (1 shl j) > 0) then\n begin\n inc(bit);\n inc(sum,a[j+1]);\n mx:=max(mx,a[j+1]);\n mn:=min(mn,a[j+1]);\n end;\n if (bit > 1) and (sum >= l) and (sum <= r) and (mx - mn >= x)then\n inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\nvar c: array[0..20] of longint;\n n,l,x,r,i,kq,t,dem,s,cmax,cmin:longint;\nbegin\n //assign(input,'Olympiad.inp');\n //reset(input);\n readln(n,l,r,x);\n for i:=1 to n do read(c[i]);\n kq:=0;\n For t:=1 to ((1 SHL n)-1) do\n begin\n dem:=0;\n s:=0;\n cmax:=0;\n cmin:=maxlongint;\n for i:= 1 to n do\n if ((t shr (i-1)) and 1) = 1 then\n begin\n inc(dem);\n s:=s+c[i];\n cmax:=max(cmax,c[i]);\n cmin:=min(cmin,c[i]);\n end;\n if (dem>=2) and (s>=l) and (s<=r) and (cmax-cmin>=x) then inc(kq);\n end;\n Writeln(kq);\nend.\n\n"}, {"source_code": "program Quick_Sort; \n var A:array[1..100000] of int64; \n N,i,L,R,x,e : longint;\n count,mask,k,t,hard,min,max:int64; \n \nprocedure QSort(L,R:longint); \n var i,j:longint;\n X,Y:int64;\nbegin \n X:=A[random(r+1-l)+l]; \n i:=L; j:=R; \n while i<=j do \n begin \n while A[i]X do j:=j-1; \n if i<=j then \n begin \n y:=A[i]; A[i]:=A[j]; A[j]:=y; \n i:=i+1; j:=j-1; \n end; \n end; \n if L0) then begin Hard:=Hard+A[N-i];inc(e);end;\n if(t and 1<>0)and(max0)and(min>A[N-i]) then min:=A[N-i];\n end;\n \n if(Hard>=l)and(Hard<=r)and(max-min>=x)and(e>1) then inc(count);\n inc(k);\n end; \n write(count);\nend. "}, {"source_code": "var a,c:array[1..15]of longint;\nmask,k,n,s,max,min,k1,l,r,x,i:longint;\nbegin\nreadln(n,l,r,x);\nfor i:=1 to n do\nread(c[i]);\nk:=0;\nfor mask:=0 to (1 shl n)-1 do\nbegin\ns:=0;max:=0; min:=10000000;k1:=0;\nfor i:=1 to n do\nif mask and (1 shl(i-1))>0 then begin k1:=k1+1; a[k1]:=c[i]; s:=s+c[i]; end;\nfor i:=1 to k1 do begin\nif a[i]>max then max:=a[i];\nif a[i]=x)and(s>=l)and(s<=r) then k:=k+1;\nfor i:=1 to k1 do\na[i]:=0;\nend;\nwriteln(k);\nend."}, {"source_code": "Program GIO;\n\nvar bit:array[0..15]of boolean;\n num:array[1..15]of longint;\nt,ct:int64;\nn,max,min,dif:longint;\n////////////////////////\nprocedure wr;\nvar tt,i:longint;\nbegin\n\nbit[0]:=false;\n\ninc(t);\ntt:=t;\n\nif (t=ct) then bit[0]:=true else\n\nfor i:=1 to n do\nbegin\nbit[i]:=tt mod 2=1;\ntt:=tt div 2\nend;\n\nend;\n/////////////////////////\n\n//////////////////////////\nfunction first:longint;\nvar i:longint;\nbegin\n\nfor i:=1 to 15 do\nif bit[i] then begin first:=num[i]; exit end;\n\nend;\n/////////////////////////\n\n/////////////////////////\nfunction last:longint;\nvar i:longint;\nbegin\n\nfor i:=15 downto 1 do\nif bit[i] then begin last:=num[i]; exit end;\n\nend;\n////////////////////////\n\nfunction sum:longint;\nvar i,s:longint;\nbegin\n\ns:=0;\n\nfor i:=1 to 15 do\nif bit[i] then s:=s+num[i];\n\nsum:=s;\n\nend;\n///////////////////////\n\n///////////////////////\nfunction check:longint;\nvar s:longint;\nbegin\n\ns:=sum;\n\nif bit[0] or (last-firstmax) or (snum[j]) then\n begin num[j]:=num[j]+num[i]; num[i]:=num[j]-num[i]; num[j]:=num[j]-num[i] end;\n\nnn:=1;\n\nfor i:=1 to n do\nnn:=nn*2;\n\nt:=2;\nct:=4;\n\nfor i:=1 to nn do\nbegin\nwr;\nans:=ans+check;\nend;\n\nwriteln(ans);\n\nend.\n"}, {"source_code": "const\n maxm=10000000;\nvar\n n,l,x,y,r,t,i,j:longint;\n a:array[1..15]of longint;\nprocedure dfs(dep,min,maxn,sum:longint);\n var\n k:longint;\n begin\n if dep=n+1 then\n begin\n if (maxn>=x)and(sum>=l)and(sum<=r) then inc(t);\n exit;\n end;\n dfs(dep+1,min,maxn,sum);\n if min>a[dep] then\n begin\n k:=min;\n min:=a[dep];\n dfs(dep+1,min,maxn,a[dep]);\n min:=k;\n end\n else\n begin\n if sum+a[dep]>r then exit;\n k:=maxn;\n maxn:=a[dep]-min;\n dfs(dep+1,min,maxn,sum+a[dep]);\n maxn:=k;\n end;\n end;\n\nbegin\n readln(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n y:=a[i]; a[i]:=a[j]; a[j]:=y;\n end;\n t:=0;\n dfs(1,maxm,0,0);\n writeln(t);\nend."}, {"source_code": "uses math;\nvar a:array[0..15] of longint;\n i,n,l,r,x,count,tmp:longint;\nprocedure sort(r,n:longint);\nvar key,c:longint;\nbegin\n key:=a[r];\n while (2*r<=n) do\n begin\n c:=2*r;\n if (c=a[c]) then break;\n a[r]:=a[c];\n r:=c;\n end;\n a[r]:=key;\nend;\nprocedure back(m,vmin,vmax,s,k:longint);\nbegin\n if (m>n) then\n begin\n if (k>1) and (vmax-vmin>=x) and (s>=l) and (s<=r) then\n inc(count);\n exit;\n end;\n back(m+1,min(vmin,a[m]),max(vmax,a[m]),s+a[m],k+1);\n back(m+1,vmin,vmax,s,k);\nend;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n for i:=n div 2 downto 1 do sort(i,n);\n for i:=n downto 2 do\n begin\n tmp:=a[i];\n a[i]:=a[1];\n a[1]:=tmp;\n sort(1,i-1);\n end;\n count:=0;\n back(1,10000000,0,0,0);\n writeln(count);\nend."}, {"source_code": "var n,l,r,x,i,j,min,max,d:longint;\nt:int64;\na:array[1..15] of longint;\nprocedure xl(i:longint);\nvar h,k:longint;\n begin\n if i=n+1 then\n begin\n if (l<=t) and (t<=r) and (max-min>=x) then inc(d);\n end\n else\n begin\n h:=min;k:=max;\n xl(i+1);\n t:=t+a[i];\n if a[i]>max then max:=a[i];\n if a[i]max) and(a[l1]*b[l1]>0) then\nmax:=a[l1]*b[l1];\nif (a[l1]*b[l1]0) then\nmin:=a[l1]*b[l1];\n\n\nif a[l1]*b[l1]<>0 then\nsum:=a[l1]*b[l1]+sum;\nkoli:=koli+1;\nend;\nif (sum>=z) and (sum<=l) and(max-min>=x)and (koli>=2) then\nbegin\nkol:=kol+1;\n\nend;\ni:=n;\n\n\n {���� � ���� ���ᨢ� }\nwhile a[i]=k-1 do\t{���� ����� ࠢ�� ��᫥���� ��� k-�筮� ��⥬� }\nbegin\na[i]:=0; \t{����塞 ����� ���ᨢ� }\ndec(i);\t\t{㬥��蠥�i }\nend;\ninc(a[i]);\n\nend;\nwrite(kol);\n\nend.\n"}, {"source_code": "uses math;\n\nconst inf = trunc(1e6) + 1;\n\nvar c:array[0..100] of longint;\n n,l,r,x,i,ans:longint;\n\n\nprocedure tt(h,kolz,s,mx,mn:longint);\n begin\n\n if h = n + 1 then\n begin\n\n if(mx-mn>=x)and(kolz>=2)and(s>=l)and(s<=r) then inc(ans);\n exit;\n\n end;\n\n tt(h+1,kolz+1,s+c[h],max(mx,c[h]),min(mn,c[h]));\n tt(h+1,kolz,s,mx,mn);\n\n end;\n\n procedure zero;\n begin\n writeln(0);\n halt;\n end;\n\n\n begin\n\n read(n);\n if n < 2 then zero;\n read(l,r,x);\n\n for i:=1 to n do read(c[i]);\n\n tt(1,0,0,0,inf);\n\n writeln(ans);\n\n end."}, {"source_code": "var n,l,r,x,m,i:longint;\na:array[0..101] of longint;\nfunction max(x,y:longint):longint;\nbegin\nif x>y then exit(x);exit(y);\nend;\nfunction min(x,y:longint):longint;\nbegin\nif xr then exit;\nif t>n then\n begin\n if(h>=l)and(x1-y1>=x)and(rs>1)then m:=m+1;exit;\n end;\nsc(t+1,h,x1,y1,rs);\nsc(t+1,h+a[t],max(x1,a[t]),min(y1,a[t]),rs+1);\nend;\nbegin\n//assign(input,'zbalpkydh.in');reset(input);\n//assign(output,'zbalpkydh.out');rewrite(output);\nreadln(n,l,r,x);\nfor i:=1 to n do read(a[i]);\nsc(1,0,-maxlongint,maxlongint,0);\nwriteln(m);\nclose(input);close(output);\nend.\n"}, {"source_code": "var\n otv,i,n,l,r,x,kol,min,sum,max:longint;\n a:array[1..100000]of longint;\nprocedure check(mask:longint);\nvar i:longint;\nbegin\n max:=-(maxlongint shr 1);\n min:=maxlongint shr 1;\n sum:=0;\n kol:=0;\n for i:=1 to n do\n if (1 shl (i-1))and mask>0 then\n begin\n inc(sum,a[i]);\n inc(kol);\n if maxa[i]then min:=a[i];\n end;\n if (max-min>=x)and(sum>=l)and(sum<=r)and(kol>=2)then inc(otv);\nend;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n for i:=0 to (1 shl n)-1 do\n check(i);\n writeln(otv);\nend."}, {"source_code": "var n,l,r,x1,i,sum:longint;\na:array[0..100001]of longint;\nfunction max(x,y:longint):longint;\nbegin\nif x>y then exit(x);\nexit(y);\nend;\nfunction min(x,y:longint):longint;\nbegin\nif xn then\n begin\n if(s>=2)and(abs(x-y)>=x1)and(z>=l)and(z<=r)then inc(sum);\n exit;\n end;\ndfs(t+1,s,x,y,z);\ndfs(t+1,s+1,max(x,a[t]),min(y,a[t]),z+a[t]);\nend;\nbegin\n//assign(input,'zbalpkydh.in');reset(input);\n//assign(output,'zbalpkydh.out');rewrite(output);\nreadln(n,l,r,x1);\nfor i:=1 to n do read(a[i]);\ndfs(1,0,0,maxlongint,0);\nwriteln(sum);\nclose(input);close(output);\nend."}, {"source_code": "{$mode objfpc}\nvar n,l,r,x,count : int64;\n i : integer;\n a : array[1..15] of int64;\n\nprocedure enter;\n begin\n read(n,l,r,x);\n for i:=1 to n do\n read(a[i]);\n end;\n\nprocedure print;\n begin\n writeln(count);\n end;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=x) then inc(count);\n for i:=last-1 downto 1 do\n begin\n if sum+a[i]<=r then work(sum+a[i],i,max);\n end;\n end;\n\nprocedure main;\n begin\n sort(1,n);\n for i:=n downto 2 do\n work(a[i],i,a[i]);\n end;\n\nbegin\n enter;\n main;\n print;\nend.\n"}, {"source_code": "var f1:text;n,l,r,x,i,j,k,t:longint;res1,s:int64;\na,x1:array[1..15]of longint;\nprocedure adj(rt,en:longint);\nvar k,c:longint;\nbegin\n k:=a[rt];\n while rt*2<=en do\n begin\n c:=rt*2;\n if (c=l)and(s<=r)and(a[x1[k]]-a[x1[1]]>=x) then inc(res1);\n while (i>0)and(x1[i]=n-k+i) do dec(i);\n if i>0 then\n begin inc(x1[i]);for j:=i+1 to k do x1[j]:=x1[j-1]+1;end;\n until i=0;\n end;\n write(res1);\nend.\n"}, {"source_code": "var cnt,st,n,l,r,x,ans,i,j,sum,tmin,tmax,o:longint;\na:array[0..100]of longint;\nfunction max(x,y:longint):longint;\nbegin if x>y then exit(x);exit(Y);end;\nfunction min(x,y:longint):longint;\nbegin if x0 do\n begin\n inc(o);\n if j mod 2=1 then\n begin\n inc(cnt);\n tmax:=max(tmax,a[o]);\n tmin:=min(tmin,a[o]);\n sum:=sum+a[o];\n end;\n j:=j div 2;\n end;\n if(cnt>=2)and(sum>=l)and(sum<=r)and(tmax-tmin>=x)then inc(ans);\n end;\nwriteln(ans);\nclose(input);close(output);\nend.\n"}], "negative_code": [{"source_code": "uses math;\nvar n,l,r,k,t,smin,smax,res:int64;\n i:longint;\n check,a:array [0..1000000] of int64;\nbegin\n read(n,l,r,k);\n smin:=1000000000;\n for i:=1 to n do\n begin\n read(t);\n inc(check[t]);\n smin:=min(t,smin);\n smax:=max(t,smax);\n end;\n for i:=smin to max(smax,r-smin) do\n a[i]:=a[i-1]+check[i];\n\n for i:=smin to smax do\n if (check[i]<>0) and (r-i>=i) then\n if i+k<=r-i then\n inc(res,check[i]*min(a[max(0,r-i)]-a[i+k-1],a[max(0,r-i)]-a[max(i-1,l-i-1)]));\n write(res);\nend.\n"}, {"source_code": "uses math;\nvar n,l,r,k,t,smin,smax,res:int64;\n i:longint;\n check,a:array [0..1000000] of int64;\nbegin\n read(n,l,r,k);\n smin:=1000000000;\n for i:=1 to n do\n begin\n read(t);\n inc(check[t]);\n smin:=min(t,smin);\n smax:=max(t,smax);\n end;\n for i:=smin to max(smax,r-smin) do\n a[i]:=a[i-1]+check[i];\n\n for i:=smin to smax do\n if (check[i]<>0) and (r-i>=i) then\n if i+k<=r-i then\n inc(res,check[i]*min(a[max(0,r-i)]-a[i+k-1],a[max(0,r-i)]-a[max(i-1,l-i-1)]))\n else\n inc(res,check[i]*max(0,(a[max(0,r-i)]-a[max(i-1,l-i-1)])));\n write(res);\nend."}, {"source_code": "var\n a:array[0..16] of longint;\n b:array[1..16] of longint;\n i,min,max,n,k,s,l,r,x,k1:longint;\n begin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,l,r,x);\n k:=0;\n\n for i:=0 to n do\n a[i]:=0;\n\n for i:=1 to n do\n read(b[i]);\n if (n=4) and (l=15) and (r=60) and (x=10)\n then\n begin\n writeln('6');\n close(output);\n halt;\n end;\n while a[0]=0 do\n Begin\n min:=b[1];\n max:=0;\n s:=0;\n k1:=0;\n for i:=1 to n do\n begin\n s:= s+b[i]*a[i];\n if a[i]=1 then\n begin\n inc(k1);\n if b[i]>max then max:=b[i];\n if b[i]=l) and (s<=r) and (k1>1) then\n if (max-min)>=x then\n begin\n inc(k);\n {writeln(s,' ',max-min); }\n end;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n End;\n\n writeln(k);\n {close(input);\n close(output);}\nend.\n"}, {"source_code": "var\n a:array[0..16] of longint;\n b:array[1..16] of longint;\n i,min,max,n,k,s,l,r,x:longint;\n begin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,l,r,x);\n k:=0;\n\n for i:=0 to n do\n a[i]:=0;\n\n for i:=1 to n do\n read(b[i]);\n\n while a[0]=0 do\n Begin\n max:=b[1];\n min:=b[2];\n s:=0;\n for i:=1 to n do\n begin\n s:= s+b[i]*a[i];\n if a[i]=1 then\n begin\n if b[i]>max then max:=b[i];\n if b[i]=l) and (s<=r) then\n if max-min>=x then\n inc(k);\n\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n End;\n\n writeln(k);\n{ close(input);\n close(output);}\nend.\n"}, {"source_code": "var\n a:array[0..16] of longint;\n b:array[1..16] of longint;\n i,min,max,n,k,s,l,r,x,k1:longint;\n begin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n read(n,l,r,x);\n k:=0;\n\n for i:=0 to n do\n a[i]:=0;\n\n for i:=1 to n do\n read(b[i]);\n if (n=4) and (l=15) and (r=60) and (x=10)\n then\n begin\n writeln('6');\n close(output);\n halt;\n end;\n while a[0]=0 do\n Begin\n min:=maxlongint;\n max:=0;\n s:=0;\n k1:=0;\n for i:=1 to n do\n begin\n\n s:= s+b[i]*a[i];\n if a[i]=1 then\n begin\n inc(k1);\n if b[i]>max then max:=b[i];\n if b[i]=l) and (s<=r) and (k1>1) then\n if (max-min)>=x then\n begin\n inc(k);\n writeln(s,' ',max-min);\n end;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n End;\n\n writeln(k);\n{close(input);\n close(output);}\nend.\n"}, {"source_code": "var\n a:array[0..16] of longint;\n b:array[1..16] of longint;\n i,min,max,n,k,s,l,r,x,k1:longint;\n begin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,l,r,x);\n k:=0;\n\n for i:=0 to n do\n a[i]:=0;\n\n for i:=1 to n do\n read(b[i]);\n if (n=4) and (l=15) and (r=60) and (x=10)\n then\n begin\n writeln('6');\n close(output);\n halt;\n end;\n while a[0]=0 do\n Begin\n min:=b[1];\n max:=0;\n s:=0;\n k1:=0;\n for i:=1 to n do\n begin\n s:= s+b[i]*a[i];\n if a[i]=1 then\n begin\n inc(k1);\n if b[i]>max then max:=b[i];\n if b[i]=l) and (s<=r) and (k1>1) then\n if (max-min)>=x then\n begin\n inc(k);\n {writeln(s,' ',max-min); }\n end;\n while a[i]=1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n End;\n\n writeln(k);\n{close(input);\n close(output); }\nend.\n"}, {"source_code": "var\n n , l , r , xx , kq , k : longint;\n a , x : array[0..16] of longint;\nprocedure tv( i : longint );\nvar\n j , dau , cuoi , tong : longint;\nbegin\n if i = n + 1 then\n begin\n tong := 0;\n for j := 1 to n do\n if x[ j ] = 1 then\n tong := tong + a[ j ];\n for j := 1 to n do\n if x[ j ] = 1 then\n begin\n dau := j;\n break;\n end;\n for j := n downto 1 do\n if x[ j ] = 1 then\n begin\n cuoi := j;\n break;\n end;\n if ( tong >= l ) and ( tong <= r ) and ( a[ cuoi ] - a[ dau ] >= xx ) then\n inc( kq );\n exit;\n end;\n for j := 0 to 1 do\n begin\n x [ i ] := j;\n tv( i + 1 );\n end;\nend;\nbegin\n read( n , l , r , xx );\n for k := 1 to n do\n read( a[ k ] );\n kq := 0;\n tv( 1 );\n write( kq );\nend.\n"}, {"source_code": "var\n s , t : ansistring;\n u , v , uu , vv : longint;\nbegin\n read( s );\n t := '';\n for u := length( s ) downto 1 do\n t := t + s[ u ];\n u := pos( 'AB' , s );\n v := pos( 'AB' , t );\n uu := pos( 'BA' , s );\n vv := pos( 'BA' , t );\n if ( u <> 0 ) and ( v <> 0 ) then\n begin\n v := length( s ) - v;\n if ( u + 1 <> v ) and ( v + 1 <> u ) and ( v <> 0 ) then\n begin\n write( 'YES' );\n halt;\n end;\n end;\n if ( uu <> 0 ) and ( vv <> 0 ) then\n begin\n vv := length( s ) - vv;\n if ( uu + 1 <> vv ) and ( vv + 1 <> uu ) and ( vv <> 0 ) then\n begin\n write( 'YES' );\n halt;\n end;\n end;\n write( 'NO' );\nend.\n"}, {"source_code": "const\n fi='';\nvar\n dem,n,l,r,x,i,j,s,min,max:longint;\n a:Array[0..16] of longint;\n f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,l,r,x);\n if n=1 then\n begin\n writeln(0); exit;\n end;\n for i:=1 to n do read(f,a[i]);\n for i:=1 to (1 shl n)-1 do\n begin\n s:=0;\n min:=100000000;\n max:=-1;\n for j:=1 to n do\n if (i shr (j-1)) = 1 then\n begin\n s:=s+a[j];\n if a[j]>max then max:=a[j];\n if a[j]=l) and (s<=r) and (max-min>=x) then inc(dem);\n end;\n writeln(dem);\n readln;\nend.\n"}, {"source_code": "var a:array[1..15] of longint;\n s:array[0..32768] of integer;\n n,l,r,x,i,j,max,min,dem:longint;\nFunction GetBIT(k , x : LongInt) : LongInt;\n begin\n GetBIT := (x shr (k-1)) and 1;\n end;\nbegin\n readln(n,l,r,x);\n for i:=1 to n do read(a[i]);\n dem:=0;\n for i:=0 to (2 shl (n-1)) -1 do\n begin\n min:=1000000000;\n max:=-1000000000;\n\n for j:=1 to n do\n begin\n s[i]:=s[i]+a[j]*getbit(j,i);\n if getbit(j,i)<>0\n then\n begin\n if a[i]max then max:=a[i];\n end;\n\n end;\n if (s[i]>=l) and (s[i]<=r) and (max-min>=x) then inc(dem);\n end;\n writeln(dem);\n readln;\nend.\n\n\n\n"}, {"source_code": "var\n a, b, c, d, o, i: int64;\n ar, ar1: array [1..1000] of int64;\n \nfunction min(a, b: int64): int64;\nbegin\n if a < b then min := a\n else min := b;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if a > b then max := a\n else max := b;\nend;\n\nprocedure perebor(k, l, r, s, t: int64);\nvar\n l1, r1: int64;\n i: int64;\n \nbegin\n if (k > 2) and (r - l < d) then exit;\n if (k > 2) and (s >= b) and (s <= c) and (r - l >= d) then inc(o);\n if s > c then exit;\n if k > a then exit;\n i := t + 1;\n while i <= a do begin\n ar1[k] := ar[i];\n perebor(k + 1, min(l, ar1[k]), max(ar1[k], r), s + ar1[k], i);\n inc(i);\n end;\nend;\n\nbegin\n readln(a, b, c, d);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n inc(i);\n end;\n o := 0;\n perebor(1, 10000000000, 0, 0, 0);\n writeln(o);\nend."}, {"source_code": "var\n a, b, c, d, o, i: int64;\n ar, ar1: array [1..1000] of int64;\n \nfunction min(a, b: int64): int64;\nbegin\n if a < b then min := a\n else min := b;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if a > b then max := a\n else max := b;\nend;\n\nprocedure perebor(k, l, r, s, t: int64);\nvar\n l1, r1: int64;\n i: int64;\n \nbegin\n if (k > 2) and (r - l < d) then exit;\n if (k > 2) and (s >= b) and (s <= c) and (r - l >= d) then inc(o);\n if s > c then exit;\n if k > a then exit;\n i := t + 1;\n while i <= a do begin\n ar1[k] := ar[i];\n perebor(k + 1, min(l, ar1[k]), max(ar1[k], r), s + ar1[k], i);\n inc(i);\n end;\nend;\n\nbegin\n readln(a, b, c, d);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n inc(i);\n end;\n o := 0;\n perebor(1, 10000000, 0, 0, 0);\n writeln(o);\nend."}, {"source_code": "var\n a, b, c, d, o, i: int64;\n ar, ar1: array [1..1000] of int64;\n used: array [1..1000] of boolean;\n \nfunction min(a, b: int64): int64;\nbegin\n if a < b then min := a\n else min := b;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if a > b then max := a\n else max := b;\nend;\n\nprocedure perebor(k, l, r, s, t: int64);\nvar\n l1, r1: int64;\n i: int64;\n \nbegin\n if (k > 2) and (r - l < d) then exit;\n if (k > 2) and (s >= b) and (s <= c) and (r - l >= d) then inc(o);\n if s > c then exit;\n if k > a then exit;\n i := t + 1;\n while i <= a do begin\n if not(used[i]) then begin\n used[i] := true;\n ar1[k] := ar[i];\n perebor(k + 1, min(l, ar1[k]), max(ar1[k], r), s + ar1[k], i);\n used[i] := false;\n end;\n inc(i);\n end;\nend;\n\nbegin\n readln(a, b, c, d);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n inc(i);\n end;\n o := 0;\n perebor(1, 10000000, 0, 0, 0);\n writeln(o);\nend."}, {"source_code": "var a:array[0..15] of byte;\n b:array[0..15] of longint;\n i,s,l,r,n,x,max,min,k,k1:longint;\nbegin\nreadln(n,l,r,x);\ns:=0;\nfor i:=1 to n do\n begin\n read(b[i]);\n inc(s,x);\n end;\nif (n=3) and (l=5) and (r=6) and (x=1) and (a[1]=1) and (a[2]=2) and (a[3]=3) then begin\n writeln(2);\n halt;\n end;\n\nif smax) then max:=b[i];\n end;\n if (s<=r) and (s>=l) and (max-min>=x) then inc(k1);\n i:=n;\n while a[i]=k-1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n end;\n\nwrite(k1);\n\nend.\n"}, {"source_code": "var a:array[0..15] of byte;\n b:array[0..15] of longint;\n i,s,l,r,n,x,max,min,k,k1:longint;\nbegin\nreadln(n,l,r,x);\ns:=0;\nfor i:=1 to n do\n begin\n read(b[i]);\n inc(s,x);\n end;\nif smax) then max:=b[i];\n end;\n if (s<=r) and (s>=l) and (max-min>=x) then inc(k1);\n i:=n;\n while a[i]=k-1 do\n begin\n a[i]:=0;\n dec(i);\n end;\n inc(a[i]);\n end;\n\nwrite(k1);\n\nclose(output);\nend.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n inStr: string;\n n, i, ii, MaxCombinations: Byte;\n m, k, p, TotalWeigth, MinWeigth, MaxWeigth, PacksCount: Integer;\n Goods: array of Integer;\n TempGoods:array of Integer;\n\nfunction ExtractNextNum(s: string):string;\nbegin\n Result := Copy(inStr,1,Pos(' ', inStr)-1);\n Delete(inStr,1,Pos(' ', inStr));\nend;\n\nbegin\n Readln(inStr);\n inStr := inStr + ' ';\n n := StrToInt(ExtractNextNum(inStr));\n m := StrToInt(ExtractNextNum(inStr));\n k := StrToInt(ExtractNextNum(inStr));\n p := StrToInt(ExtractNextNum(inStr));\n\n Readln(inStr);\n inStr := inStr + ' ';\n SetLength(Goods, n);\n for i:=0 to n-1 do\n begin\n Goods[i]:= StrToInt(ExtractNextNum(inStr));\n end;\n\n PacksCount:=0;\n\n MaxCombinations := Trunc(Power(2, n)) - 1; //всего вариантов получить различные наборы товаров\n\n for i:=1 to MaxCombinations do //\n begin\n SetLength(TempGoods,0);\n //заполняем массив следующей комбинацией товаров\n //используем i как двоичную маску отбора элементов в массиве товаров\n for ii:=0 to n-1 do\n begin\n if ( (i and Trunc(Power(2,ii))) = (Trunc(Power(2,ii))) ) then\n begin\n SetLength(TempGoods,Length(TempGoods)+1);\n TempGoods[Length(TempGoods)-1]:=Goods[ii];\n end;\n end;\n\n // if Length(TempGoods)<2 then Continue;//набор из 1 товара сразу нет\n\n TotalWeigth := 0;\n MinWeigth:=TempGoods[0];\n MaxWeigth:=TempGoods[0];\n \n for ii:=0 to Length(TempGoods)-1 do\n begin\n TotalWeigth:=TotalWeigth + TempGoods[ii];\n if MinWeigth > TempGoods[ii] then MinWeigth:= TempGoods[ii];\n if MaxWeigth < TempGoods[ii] then MaxWeigth:= TempGoods[ii];\n end;\n\n if ((TotalWeigth < m) or (TotalWeigth > k)) then Continue; //условие суммарного веса\n if ((MaxWeigth - MinWeigth) < p) then Continue; //условие разницы крайних весов\n\n Inc(PacksCount);//условия подошли - берем как вариант пачки товаров\n\n end;\n\n Writeln(inttostr(PacksCount));\n // readln;\n\nend.\n "}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n inStr: string;\n n, i, ii, MaxCombinations: Byte;\n m, k, p, TotalWeigth, MinWeigth, MaxWeigth, PacksCount: Integer;\n Goods: array of Integer;\n TempGoods:array of Integer;\n\nfunction ExtractNextNum(s: string):string;\nbegin\n Result := Copy(inStr,1,Pos(' ', inStr)-1);\n Delete(inStr,1,Pos(' ', inStr));\nend;\n\nbegin\n Readln(inStr);\n inStr := inStr + ' ';\n n := StrToInt(ExtractNextNum(inStr));\n m := StrToInt(ExtractNextNum(inStr));\n k := StrToInt(ExtractNextNum(inStr));\n p := StrToInt(ExtractNextNum(inStr));\n\n Readln(inStr);\n inStr := inStr + ' ';\n SetLength(Goods, n);\n for i:=0 to n-1 do\n begin\n Goods[i]:= StrToInt(ExtractNextNum(inStr));\n end;\n\n PacksCount:=0;\n\n MaxCombinations := Trunc(Power(2, n)) - 1; //всего вариантов получить различные наборы товаров\n\n for i:=3 to MaxCombinations do //\n begin\n SetLength(TempGoods,0);\n //заполняем массив следующей комбинацией товаров\n //используем i как двоичную маску отбора элементов в массиве товаров\n for ii:=0 to n-1 do\n begin\n if ( (i and Trunc(Power(2,ii))) = (Trunc(Power(2,ii))) ) then\n begin\n SetLength(TempGoods,Length(TempGoods)+1);\n TempGoods[Length(TempGoods)-1]:=Goods[ii];\n end;\n end;\n\n if Length(TempGoods)<2 then Continue;//набор из 1 товара сразу нет\n\n TotalWeigth := 0;\n MinWeigth:=TempGoods[0];\n MaxWeigth:=TempGoods[0];\n \n for ii:=0 to Length(TempGoods)-1 do\n begin\n TotalWeigth:=TotalWeigth + TempGoods[ii];\n if MinWeigth > TempGoods[ii] then MinWeigth:= TempGoods[ii];\n if MaxWeigth < TempGoods[ii] then MaxWeigth:= TempGoods[ii];\n end;\n\n if ((TotalWeigth < m) or (TotalWeigth > k)) then Continue; //условие суммарного веса\n if ((MaxWeigth - MinWeigth) < p) then Continue; //условие разницы крайних весов\n\n Inc(PacksCount);//условия подошли - берем как вариант пачки товаров\n\n end;\n\n Writeln(inttostr(PacksCount));\n // readln;\n\nend.\n "}, {"source_code": "var i,n,s1,r,min1,max1,min,max,k,k1:longint;\n a,a1:array[0..100] of integer;\nbegin\n\nreadln(n,min,max,r);\nfor i:=1 to n do\n read(a1[i]);\nfor i:=0 to n do\n a[i]:=0;\nk:=0;\nwhile a[0]=0 do\n begin\n min1:=19999;\n for i:=1 to n do\n if a[i]=1\n then\n begin\n if min1>a1[i]\n then\n min1:=a1[i];\n if max1=min) and (s1<=max) and (k1>1) and ((max1-min1)>=r)\n then\n k:=k+1;\n s1:=0;\n k1:=0;\n max1:=0;\n i:=n;\n while a[i]=1 do\n begin\n a[i]:=0;\n i:=i-1;\n end;\n a[i]:=1;\n end;\nwriteln(k);\n\nend."}, {"source_code": "program t2;\nvar\n n,l,r,x,i,j,t,e,b:longint;\n y:int64;\n a:array[0..15]of longint;\nprocedure he(c,d,s:int64);\nvar\n k:integer;\n begin\n if(s>l)and(sa[i+1] then\n begin\n t:=a[i];\n a[i]:=a[i+1];\n a[i+1]:=t;\n end;\n end;\n {for i:=(n-1)downto 0do\n if a[i]+a[0]<=r then break;\n e:=i;\n for i:=0to(n-1)do\n if a[e]-a[i]<=x then break;\n b:=i-1;}\n for i:=(n-1) downto 1 do\n begin\n for j:=0 to(i-1)do\n if a[i]-a[j]>=x then he(j,i,a[i]+a[j])\n end;\n writeln(y);\nend."}], "src_uid": "0d43104a0de924cdcf8e4aced5aa825d"} {"source_code": "var\n\ti,c:integer;\n\tp,q:string;\n\ta:array[1..2,1..100] of boolean;\nbegin\n\treadln(p);\n\treadln(q);\n\tfillchar(a,sizeof(a),true);\n\tc:=0;\n\tfor i:=1 to length(p) do\n\tbegin\n\t\tif p[i]='X' then a[1,i]:=false;\n\t\tif q[i]='X' then a[2,i]:=false;\n\tend;\n\tfor i:=1 to length(p)-1 do\n\tbegin\n\t\tif a[1,i] and a[2,i] and a[1,i+1] then\n\t\tbegin\n\t\t\ta[1,i]:=false;\n\t\t\ta[2,i]:=false;\n\t\t\ta[1,i+1]:=false;\n\t\t\tinc(c);\n\t\tend;\n\t\tif a[1,i] and a[2,i] and a[2,i+1] then\n\t\tbegin\n\t\t\ta[1,i]:=false;\n\t\t\ta[2,i]:=false;\n\t\t\ta[2,i+1]:=false;\n\t\t\tinc(c);\n\t\tend;\n\t\tif a[1,i] and a[1,i+1] and a[2,i+1] then\n\t\tbegin\n\t\t\ta[1,i]:=false;\n\t\t\ta[1,i+1]:=false;\n\t\t\ta[2,i+1]:=false;\n\t\t\tinc(c);\n\t\tend;\n\t\tif a[2,i] and a[1,i+1] and a[2,i+1] then\n\t\tbegin\n\t\t\ta[2,i]:=false;\n\t\t\ta[1,i+1]:=false;\n\t\t\ta[2,i+1]:=false;\n\t\t\tinc(c);\n\t\tend;\n\tend;\n\twrite(c);\nend.", "positive_code": [{"source_code": "type ta = array[1..2,1..100] of char;\nvar a:ta;\n i,u,m,k,j:integer;\n s:string;\nfunction recurs(a:ta;u:integer):integer;\nvar k:integer;\nbegin\nk:=0;\nif (a[1,u]='0') then \nk:=k+1;\nif (a[1,u+1]='0') then \nk:=k+1;\nif (a[2,u]='0') then \nk:=k+1;\nif (a[2,u+1]='0') then \nk:=k+1;\nrecurs:=k;\nend;\nbegin\nreadln(s);\nm:=length(s);\nfor i:=1 to m do\na[1,i]:=s[i];\nreadln(s);\nfor i:=1 to m do\na[2,i]:=s[i];\nu:=1;\nk:=0;\nj:=0;\nwhile u0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:extended):extended;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction sum(koef:extended):extended;\nvar i,j:longint; ot,pp:extended; flag:boolean;\nbegin\n flag:=true; pp:=1e+20; ot:=0;\n for i:=1 to n do pp:=min(pp,y[i]-koef*x[i]);\n for i:=1 to n do ot:=ot+y[i]-(koef*x[i]+pp);\n\n\n if flag then sum:=ot else ot:=1e+20;\nend;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n for i:=1 to 2 do readln(sss[i]);\n n:=length(sss[1]);\n for i:=1 to n do if sss[1][i]='X' then zan[i,1]:=true;\n for i:=1 to n do if sss[2][i]='X' then zan[i,2]:=true;\n zan[n+1,1]:=true;\n zan[n+1,2]:=true;\n\n\n for i:=1 to n do\n begin\n if not zan[i,1] and not zan[i+1,1] and not zan[i,2] then\n begin zan[i,1]:=true; zan[i+1,1]:=true; zan[i,2]:=true; inc(ot); goto 2; end;\n\n if not zan[i,1] and not zan[i+1,2] and not zan[i,2] then\n begin zan[i,1]:=true; zan[i+1,2]:=true; zan[i,2]:=true; inc(ot); goto 2; end;\n\n if not zan[i,1] and not zan[i+1,2] and not zan[i+1,1] then\n begin zan[i,1]:=true; zan[i+1,2]:=true; zan[i+1,1]:=true; inc(ot); goto 2; end;\n\n if not zan[i,2] and not zan[i+1,2] and not zan[i+1,1] then\n begin zan[i,2]:=true; zan[i+1,2]:=true; zan[i+1,1]:=true; inc(ot); goto 2; end;\n\n\n\n 2:\n { writeln('i= ',i);\n for k:=1 to 2 do begin for j:=1 to n do if zan[j,k] then write('X') else write('.'); writeln; end;\n }\n end;\n\n writeln(ot);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var a:array [1..2] of string;\nsum,i:longint;\nbegin\n//assign(input,'bswk.in');reset(input);\n//assign(output,'bswk.out');rewrite(Output);\nreadln(a[1]);\nreadln(a[2]);\na[1]:='X'+a[1]+'X';a[2]:='X'+a[2]+'X';\nfor i:=2 to length(a[1])-1 do\n if (a[1,i]='0') and (a[2,i]='0') and ((a[1,i-1]='0') or (a[1,i+1]='0') or (a[2,i-1]='0') or (a[2,i+1]='0')) then\n begin\n a[1,i]:='X';a[2,i]:='X';\n if a[1,i-1]='0' then a[1,i-1]:='X'\n else if a[2,i-1]='0' then a[2,i-1]:='X'\n else if a[1,i+1]='0' then a[1,i+1]:='X'\n else a[2,i+1]:='X';\n inc(sum);\n end;\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "var s1,s2:string;i,s:longint;\nbegin\n//assign(input,'bswk.in');reset(input);\n//assign(output,'bswk.out');rewrite(output);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s1) do\n if s1[i]+s2[i]='00' then\n begin\n if (i<>1) and (s1[i-1]='0') then\n begin\n s1[i-1]:='X';s1[i]:='X';s2[i]:='X';s:=s+1;\n end\n else if (i<>1) and (s2[i-1]='0') then\n begin\n s2[i-1]:='X';s1[i]:='X';s2[i]:='X';s:=s+1;\n end\n else if (i<>length(s1)) and (s1[i+1]='0') then\n begin\n s1[i+1]:='X';s1[i]:='X';s2[i]:='X';s:=s+1;\n end\n else if (i<>length(s1)) and (s2[i+1]='0') then\n begin\n s2[i+1]:='X';s1[i]:='X';s2[i]:='X';s:=s+1;\n end;\n end;\nwriteln(s);\nclose(input);close(output);\nend."}, {"source_code": "var\n c : array[1..2 , 1..100] of char ;\n ch : char ;\n ans , len , i : integer ; \n flag : boolean ; \nbegin\n len := 0 ;\n flag := true ;\n while flag do\n begin\n read( ch ) ;\n if ( ch <> '0' ) and ( ch <> 'X' ) then flag := false \n else\n begin\n len := len + 1 ;\n c[1 , len] := ch ;\n end ;\n end ;\n readln ;\n for i := 1 to len do \n read( c[2 , i] ) ;\n ans := 0 ;\n for i := 2 to len do\n begin\n flag := false ;\n if ( c[1 , i - 1] = '0' ) and ( c[2 , i - 1] = '0' ) then\n begin\n if c[1 , i] = '0' then\n begin\n flag := true ;\n c[1 , i - 1] := 'X' ;\n c[2 , i - 1] := 'X' ;\n c[1 , i] := 'X' ;\n end \n else\n if c[2 , i] = '0' then\n begin\n flag := true ;\n c[1 , i - 1] := 'X' ;\n c[2 , i - 1] := 'X' ;\n c[2 , i] := 'X' ;\n end ;\n end ;\n if ( c[1 , i] = '0' ) and ( c[2 , i] = '0' ) and ( flag = false ) then \n begin\n if c[1 , i - 1] = '0' then\n begin\n flag := true ;\n c[1 , i - 1] := 'X' ;\n c[1 , i] := 'X' ;\n c[2 , i] := 'X' ; \n end \n else\n if c[2 , i - 1] = '0' then\n begin \n flag := true ;\n c[2 , i - 1] := 'X' ;\n c[1 , i] := 'X' ;\n c[2 , i] := 'X' ;\n end ;\n end ;\n if flag = true then ans := ans + 1 ;\n end ;\n writeln( ans ) ;\nend."}, {"source_code": "var a , b : ansistring ;\n c , d , e , f , n , flag , ans : longint ;\n begin\n // assign ( input , 'a.in' ) ; reset ( input ) ;\n // assign ( output , 'a.out' ) ; rewrite ( output ) ;\n readln ( a ) ;\n readln ( b ) ;\n c := length ( a ) ;\n d := 0 ;\n while d < c do\n begin\n e := 1 ; d := d + 1 ;\n while ( a [ d ] = '0' ) and ( b [ d ] = '0' ) do\n begin\n inc ( d ) ;\n inc ( e ) ;\n end ; e := e - 1 ;\n if flag = 1 then if e > 0 then\n begin\n e := e - 1 ;\n ans := ans + 1 ;\n end ;\n ans := ans + e div 3 * 2 ;\n e := e mod 3 ; flag := 0 ;\n if e mod 3 = 0 then\n begin\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n flag := 1 ;\n end ;\n if e mod 3 = 1 then\n begin\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n ans := ans + 1 ;\n end ;\n if e mod 3 = 2 then\n begin\n ans := ans + 1 ;\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n flag := 1 ;\n end ;\n end ;\n write ( ans ) ; //close ( input ) ; close ( output ) ;\n end .\n\n\n"}, {"source_code": "var i,j,n,k : longint;\na: array [1..2,1..100] of longint;\ns: string;\n\nbegin\n for i:=1 to 2 do\n begin\n readln(s);\n n:=length(s);\n for j:=1 to n do\n if s[j]='0' then a[i,j]:=0\n else a[i,j]:=1;\n end;\n k:=0;\n for j:=1 to n-1 do\n begin\n if (a[1,j]=0) and (a[2,j]=0) and (a[1,j+1]=0) then\n begin\n k:=k+1;\n a[1,j]:=1; a[2,j]:=1; a[1,j+1]:=1;\n end;\n if (a[1,j]=0) and (a[2,j]=0) and (a[2,j+1]=0) then\n begin\n k:=k+1;\n a[1,j]:=1; a[2,j]:=1; a[2,j+1]:=1;\n end;\n if (a[1,j+1]=0) and (a[2,j+1]=0) and (a[1,j]=0) then\n begin\n k:=k+1;\n a[1,j+1]:=1; a[2,j+1]:=1; a[1,j]:=1;\n end;\n if (a[1,j+1]=0) and (a[2,j+1]=0) and (a[2,j]=0) then\n begin\n k:=k+1;\n a[1,j+1]:=1; a[2,j+1]:=1; a[2,j]:=1;\n end;\n end;\n writeln(k);\nend.\n"}, {"source_code": "var s1,s2 : string;\nvar slon ,i ,n ,k,pos : integer;\nbegin\nreadln(s1);\nreadln(s2);\ni := 1;\nn := s1.Length;\ns1 +='XXX';\ns2 +='XXX';\nk := 0;\nwhile (i < n) do\nbegin\n if (s1[i] = '0') and (s1[i+1] = '0') and (s1[i+2] = '0') and (s2[i] = '0') and (s2[i+1] = '0') and (s2[i+2] = '0') then begin i := i + 3; inc(k);inc(k) end else\n if (s1[i] = '0') and (s1[i+1] = '0') and (s2[i] = '0') or\n (s2[i] = '0') and (s2[i+1] = '0') and (s1[i] = '0') or\n (s1[i] = '0') and (s1[i+1] = '0') and (s2[i+1] = '0') or\n (s2[i] = '0') and (s2[i+1] = '0') and (s1[i+1] = '0') then begin i := i + 2; inc(k); end else i := i + 1;\nend;\nwriteln(k);\nend."}], "negative_code": [{"source_code": "var i,j,fa,o:longint;\na:array[0..2]of string;\nbegin\n//assign(input,'bswk.in');reset(input);\n//assign(output,'bswk.out');rewrite(output);\nreadln(a[1]);\nreadln(a[2]);\nfa:=length(a[2]);\nfor J:=1 to fa do\n for I:=1 to 2 do\n if a[i,j]='0'then\n begin\n if(j>1)and(i=1)then\n if(a[i,j-1]='0')and(a[i+1,j]='0')then\n begin\n inc(o);\n a[i,j]:='X';\n a[i,j-1]:='X';\n a[i+1,j]:='X';\n end;\n if a[i,j]<>'0'then continue;\n if(j>1)and(i>1)then\n if(a[i,j-1]='0')and(a[i-1,j]='0')then\n begin\n inc(o);\n a[i,j]:='X';\n a[i,j-1]:='X';\n a[i-1,j]:='X';\n end;\n if a[i,j]<>'0'then continue;\n if(j+1<=fa)and(i=1)then\n if(a[i,j+1]='0')and(a[i+1,j]='0')then\n begin\n inc(o);\n a[i,j]:='X';\n a[i,j+1]:='X';\n a[i+1,j]:='X';\n end;\n if a[i,j]<>'0'then continue;\n if(j+1<=fa)and(i=2)then\n if(a[i,j+1]='0')and(a[i-1,j]='0')then\n begin\n inc(o);\n a[i,j]:='X';\n a[i-1,j]:='X';\n a[i,j+1]:='X';\n end;\n end;\nwrite(o);\nclose(input);close(output);\nend."}, {"source_code": "var a:array[0..101,0..101] of char;\n i,j,n,k:longint;\n c:char;\nbegin\n//assign(input,'bswk.in');reset(input);\n//assign(output,'bswk.out');rewrite(output);\nwhile not eoln do\n begin\n read(c);\n j:=j+1;\n a[1,j]:=c;\n end;\nn:=j;\nreadln;\nfor i:=1 to n do\n read(a[2,i]);\nreadln;\nfor i:=1 to 2 do\n for j:=1 to n do\n begin\n if (a[i,j]='0') and (a[i-1,j]='0') and (a[i-1,j+1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i-1,j]:='X';\n a[i-1,j+1]:='X';\n end;\n if (a[i,j]='0') and (a[i-1,j]='0') and (a[i-1,j-1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i-1,j]:='X';\n a[i-1,j-1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j+1]='0') and (a[i-1,j+1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j+1]:='X';\n a[i-1,j+1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j+1]='0') and (a[i+1,j+1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j+1]:='X';\n a[i+1,j+1]:='X';\n end;\n if (a[i,j]='0') and (a[i+1,j]='0') and (a[i+1,j-1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i+1,j]:='X';\n a[i+1,j-1]:='X';\n end;\n if (a[i,j]='0') and (a[i+1,j]='0') and (a[i+1,j+1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i+1,j]:='X';\n a[i+1,j+1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j-1]='0') and (a[i-1,j-1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j-1]:='X';\n a[i-1,j-1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j-1]='0') and (a[i+1,j-1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j-1]:='X';\n a[i+1,j-1]:='X';\n end;\n if (a[i,j]='0') and (a[i-1,j]='0') and (a[i,j+1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i-1,j]:='X';\n a[i,j+1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j+1]='0') and (a[i+1,j]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j+1]:='X';\n a[i+1,j]:='X';\n end;\n if (a[i,j]='0') and (a[i+1,j]='0') and (a[i,j-1]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i+1,j]:='X';\n a[i,j-1]:='X';\n end;\n if (a[i,j]='0') and (a[i,j-1]='0') and (a[i-1,j]='0') then\n begin\n k:=k+1;\n a[i,j]:='X';\n a[i,j-1]:='X';\n a[i-1,j]:='X';\n end;\n end;\nwriteln(k);\nclose(input);close(output);\nend.\n"}, {"source_code": "var a , b : ansistring ;\n c , d , e , f , n , flag , ans : longint ;\n begin\n // assign ( input , 'a.in' ) ; reset ( input ) ;\n // assign ( output , 'a.out' ) ; rewrite ( output ) ;\n readln ( a ) ;\n readln ( b ) ;\n c := length ( a ) ;\n d := 0 ;\n while d < c do\n begin\n e := 1 ; d := d + 1 ;\n while ( a [ d ] = '0' ) and ( b [ d ] = '0' ) do\n begin\n inc ( d ) ;\n inc ( e ) ;\n end ; e := e - 1 ;\n if flag = 1 then if e > 0 then\n begin\n e := e - 1 ;\n ans := ans + 1 ;\n end ;\n ans := ans + e div 3 ;\n e := e mod 3 ; flag := 0 ;\n if e mod 3 = 0 then\n begin\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n flag := 1 ;\n end ;\n if e mod 3 = 1 then\n begin\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n ans := ans + 1 ;\n end ;\n if e mod 3 = 2 then\n begin\n ans := ans + 1 ;\n if ( a [ d ] = '0' ) or ( b [ d ] = '0' ) then\n flag := 1 ;\n end ;\n end ;\n write ( ans ) ; close ( input ) ; close ( output ) ;\n end .\n\n\n"}, {"source_code": "type ta = array[1..2,1..100] of char;\nvar a:ta;\n i,u,m,k:integer;\n s:string;\nfunction recurs(a:ta;u:integer):integer;\nvar k:integer;\nbegin\nk:=0;\nif (a[1,u]='0') then \nk:=k+1;\nif (a[1,u+1]='0') then \nk:=k+1;\nif (a[2,u]='0') then \nk:=k+1;\nif (a[2,u+1]='0') then \nk:=k+1;\nif k>2 then recurs:=1;\nend;\nbegin\nreadln(s);\nm:=length(s);\nfor i:=1 to m do\na[1,i]:=s[i];\nreadln(s);\nfor i:=1 to m do\na[2,i]:=s[i];\nu:=1;\nk:=0;\nwhile u2 then\nbegin\nrecurs:=k;\nend;\nend;\nbegin\nreadln(s);\nm:=length(s);\nfor i:=1 to m do\na[1,i]:=s[i];\nreadln(s);\nfor i:=1 to m do\na[2,i]:=s[i];\nu:=1;\nk:=0;\nj:=0;\nwhile u= 1) and (t <= 16) then\r\n begin\r\n while (t<>0) do\r\n begin\r\n\r\n read(a);\r\n readln(b);\r\n read(c);\r\n readln(d);\r\n if (a=0) and (b=0) and (c=0) and (d=0) then Ar[count]:=0\r\n else if (a=1) and (b=1) and (c=1) and (d=1) then Ar[count]:=2\r\n else Ar[count]:=1;\r\n count:=count+1;\r\n t:=t-1;\r\n end;\r\n for t:= 1 to count-1 do writeln(Ar[t]);\r\n end;\r\n end.\r\n", "positive_code": [{"source_code": "var i,t,a,b,c,d,dem:longint;\r\n kq:array[1..16] of longint;\r\nbegin \r\n readln(t);\r\n for i := 1 to t do \r\n begin \r\n dem := 0;\r\n readln(a,b);\r\n readln(c,d);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if c=1 then inc(dem);\r\n if d=1 then inc(dem);\r\n if dem = 0 then kq[i]:=0 else \r\n if (dem = 1) or (dem =2) or (dem=3) then kq[i]:=1 else kq[i]:=2;\r\n end;\r\n for i:=1 to t do writeln(kq[i]);\r\nend.\r\n \r\n"}, {"source_code": "var ans,t,i,j,u,v:longint;\r\nbegin\r\n { assign(input,'1701a.inp');reset(input);\r\n assign(output,'1701a.out');rewrite(output);}\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n ans:=0;\r\n for j:= 1 to 2 do\r\n begin\r\n readln(u,v);\r\n ans:=ans + u + v;\r\n end;\r\n if ans = 1 then writeln(1) else writeln(ans div 2);\r\n end;\r\n readln;\r\nend."}, {"source_code": "{*\r\n Educational Codeforces Round 131 (Div.2)\r\n*}\r\nprogram Grass_Field;\r\nvar t:integer;\r\n\r\nprocedure solve;\r\nvar i,x,sum:integer;\r\nbegin\r\n sum:=0; i:=0;\r\n while i<4 do\r\n begin\r\n read(x); sum:=sum+x; inc(i);\r\n end;\r\n if sum=0 then writeln('0')\r\n else if sum=4 then writeln('2')\r\n else writeln('1');\r\nend;\r\n\r\nbegin\r\n read(t);\r\n while t>0 do\r\n begin\r\n solve; dec(t);\r\n end;\r\nend."}, {"source_code": "\r\nprogram vd;\r\nvar a,b,c,d,dem,t,i:longword;\r\nbegin\r\n\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n dem:=0;\r\n readln(a,b);\r\n readln(c,d);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if c=1 then inc(dem);\r\n if d=1 then inc(dem);\r\n if dem=0 then writeln('0') else\r\n if (dem=1) or (dem=2) or (dem=3) then writeln('1') else\r\n if dem=4 then writeln('2') else\r\n\r\n\r\n\r\n end;\r\nreadln;\r\nend.\r\n"}, {"source_code": "program Grass_Field;\r\nvar\r\n ntc: int8;\r\n a1, a2, s: int8;\r\n\r\nbegin\r\n readln(ntc);\r\n repeat\r\n s := 0;\r\n\r\n readln(a1, a2);\r\n inc(s, a1+a2);\r\n readln(a1, a2);\r\n inc(s, a1+a2);\r\n\r\n if s = 0 then\r\n writeln(0)\r\n else if s = 4 then\r\n writeln(2)\r\n else\r\n writeln(1);\r\n\r\n dec(ntc);\r\n until ntc = 0;\r\nend.\r\n"}, {"source_code": "var n,i,j,d,t,h:longint;a:array[1..2,1..2] of byte;\r\nbegin\r\n readln(t);\r\n for h:=1 to t do\r\n begin\r\n d:=0;\r\n for i:=1 to 2 do\r\n for j:=1 to 2 do read(a[i,j]);\r\n for i:=1 to 2 do\r\n for j:=1 to 2 do if a[i,j]=1 then inc(d);\r\n if d=0 then writeln('0')\r\n else if d<4 then writeln('1')\r\n else writeln('2');\r\n end;\r\n readln\r\nend."}, {"source_code": "begin\r\n var t, n, m, b, v, x: integer;\r\n read(t);\r\n for var i:=0 to t-1 do\r\n begin\r\n read(n, m, b, v);\r\n if (n=0)and(m=0)and(b=0)and(v=0) then writeln(0)\r\n else \r\n begin\r\n if (n=1)and(m=1)and(b=1)and(v=1) then writeln(2)\r\n else writeln(1)\r\n end;\r\n end;\r\nend."}, {"source_code": " const eps=1e-10;\r\n besk=1800000000000000000; label 33,55,5,4,1,3,2,44,22;\r\n type\r\n mas=array[-250000..1570460+1] of int64;\r\n integer=longint; zap=record p1,p2,p3:int64; end;\r\n zap1=^zap;\r\n var dlina,newnap,nnap,nap,m,pos,kolshagov,kk,hh,koled,px,py,posx,posy,cur,init,res,oldpos,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\r\n sss:array[-1..1000000] of string;\r\n ch1,ch2:char;\r\n ss,ssans,ss1,ss4,oldss,smin,ss3,ss2:string;\r\n newaans,aans:zap;\r\n fx,fy,koef,dfy,dfx,coef,mc,xxc,yyc,zzc,otr1,otr0,vx,vy,ddist,tttt:extended;\r\n pqqq:zap;\r\n time,dx,dy,mexx,diff,jmin,summax,summin,znach,sum,start,start1,kol1,raz,raz1:int64;\r\n xp,yp,almax,almin,gam,al0,otal,al1,al2,acc, disk,prop,bet,al:extended; fl1,fl2,fl:boolean;\r\n dr3,dr1,dr2,pt,ott1,ott2:zap;\r\n dans,sumyy,sumxx,sumxy:array[-10..500000] of extended;\r\n p1,p2,ans,tt,ii,pp,ymax,ymin,xmax,xmin,sumx,sumy,w,pov,sumost,gr,oldsum,amin,amax,ansmax,kolgor,kolver,oldcc,finish,p3,p4,stoimost,kolodin,maxsum,i3,p,pp1,pp2,root,par,dlkruga,topt,t3,ot,cc,znak,rr,kolmax,kkol,pq,razm,mm,tip,ppos1,oldtt,ps,pos1,pos2,pred,color,buk:int64;\r\n nomer,napx,napy,kol,z,stepen1,stepen,xnewoch,ynewoch,xoch,yoch,strx,stry,ppole,y,dold,d,poryadok,num,zz:array[-200000..1110000] of int64;\r\n stroka,sss1,sss2:array[-10..1610000] of string;\r\n xc,yc,zc,v3,v1,v2,pointx,pointy,vel,tt0,radius,ote,dl1,dl2:extended;\r\n dist,ddsum,dd,dnewr,dnewl,dr,ddpos:array[-1..50002,-2..500] of int64;\r\n nomermax,left,right,poss,zzz,x,d0,d1,str,zx,zy,xxx,yyy,invfact,ansx,ansy,ugol:array[-300000..1111000] of int64;\r\n t1,t2,tx,ty,delit,dl,ll,ost,shag,ppos,jj,t,ptek,dloch1,oldaa,oldbb,zapas,ott,mnog,ttt,delta,tt1,tt2,koll,newt,osn,oldot,oldt,znmax,opld,t4,iii,jjj,aaa,bbb,ccc,p0,newpos,newdl,len,pp3,ans1,ans2,modul,t0,dloch,koldel,mmax,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,kool,number,imin,qq,n,numpos,down,imax,qq1,qq2,q1,q2,pmax,pmax2,pos0,maxot,tmax,nn,n1,q:int64; flag1:boolean;\r\n xx,yy,olda,b,c,a,fact,stan,a2,invx,invy,place,b2,sum1,sum0:mas; flag2,flag:boolean;\r\n aa,bb,pleft,pright,kol2,kolminus,pos3,gor,ver,i2,j2,sdvig,izb, nextp,razn,ppp,minx,miny,maxx,maxy,jmax,grr,ener,dob:int64;\r\n zan1,zan2,prost,zan:array[-1000..20001001] of boolean;\r\n zzan,newzan,zann:array[-1000000..4000000] of boolean;\r\n zanx,marked:array[-1000000..4100000] of boolean;\r\n s1,s2:array[-1..1000000] of char;\r\n est,nado,z1,z2,x1,y1,x2,y2,ddnew,d3,dmin,dnomer:array[-211100..1100000] of int64;\r\n ochh,newochh:array[-1000..1000000] of longint;\r\n ba1,ba2,next0,next1,newx,newy,dplus,dminus,och1,b1,a1,first,last,newoch,och,lx,a3,b3,predok:array[-20000..1610000] of int64;\r\n ddd:array[-1..200001,0..1] of longint;\r\n dinleft,din,nextt,polenext,pole,newpole:array[-1..1300,-1..1305] of int64;\r\n ddmax,ddmin,dd2:array[-100..1300,-100..1300] of int64;\r\n dd3:array[-10..130,-10..130,-10..130] of int64;\r\n ssan,bufer:array[-1000..2000000] of char;\r\n cosa,sina,cosb,sinb,rx,ry,h1,h2,h,l1,l2,otmax,v:int64;\r\n obmen,ch:char;\r\n flagg,fflag,ok,flagg1:boolean;\r\n oldx,oldy,numx,numy,xleft,xright,s,newplace,newstr,next,prev,aold:array[-1000..220002] of int64;\r\n function srav(i,j:longint):boolean;\r\n var k,tt:longint;\r\n begin\r\n if (a[i]=l+k) or (j>=m+k)) then flag:=false;\r\n end;\r\n if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j]; b3[l+step]:=a3[j];\r\n inc(step);inc(j);until (j>=m+k);\r\n if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i]; b3[l+step]:=a3[i];inc(step);inc(i);until (i>=l+k);\r\n end;\r\n\r\n procedure sort(var c:mas);\r\n begin\r\n k:=1; repeat\r\n l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\r\n for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i];a3[i]:=b3[i]; end;\r\n until (k>=n);\r\n end;\r\n\r\n function min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\r\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\r\n tt:zap; tt1:zap1; fl:boolean;\r\n begin\r\n fl:=false;\r\n if a0 do\r\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\r\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\r\n end;\r\n if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else\r\n begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\r\n evkl:=tt1;\r\n end;\r\n function phi(a,b:double):double; label 222;var p:double;\r\n begin\r\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\r\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\r\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\r\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\r\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\r\n 222: phi:=p;\r\n end;\r\n\r\n function nod(a,b:int64):int64; var p,t:int64;\r\n begin\r\n a:=abs(a); b:=abs(b);\r\n if (a>0)and(b>0) then\r\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\r\n p:=a;\r\n end else if a=0 then p:=b else p:=a;\r\n nod:=p;\r\n end;\r\n\r\nfunction nok(aa,bb:int64):int64;\r\nvar tt:int64;\r\nbegin tt:=nod(aa,bb); ot:=(aa*bb) div tt; nok:=ot; end;\r\n\r\n function arccos(tt:extended):extended;\r\n begin\r\n if abs(tt)>1-1e-13 then\r\n if tt>0 then arccos:=0 else arccos:=pi;\r\n if tt=0 then arccos:=pi/2 else\r\n if abs(tt)<=1-1e-13 then if tt>=0 then arccos:=arctan(sqrt(1-tt*tt)/tt)\r\n else arccos:=pi+arctan(sqrt(1-tt*tt)/tt);\r\n end;\r\n\r\n function degg(a,k,modul:int64):int64; var p:int64; label 4;\r\n begin\r\n if k<=0 then degg:=1\r\n else if odd(k) then degg:=(degg(a,k-1,modul)*a) mod modul else\r\n begin p:=degg(a,k div 2,modul); degg:=(p*p) mod modul; end;\r\n end;\r\n\r\n{ function zaprmax(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmax:=y[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\r\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\r\n end;\r\n end;\r\n end; }\r\n\r\n\r\n function zaprmin(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmin:=z[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),z[left]);\r\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),z[right]);\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n function zaprsum(left,right:longint):int64;\r\n begin\r\n if left>=right then if left=right then zaprsum:=y[left] else zaprsum:=0 else\r\n begin\r\n if not odd(left) and odd(right) then zaprsum:=zaprsum(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprsum:=zaprsum(left+1,right)+y[left];\r\n if not odd(right) then zaprsum:=zaprsum(left,right-1)+y[right];\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n function zaprsum1(left,right:longint):int64;\r\n begin\r\n if left>=right then if left=right then zaprsum1:=yy[left] else zaprsum1:=0 else\r\n begin\r\n if not odd(left) and odd(right) then zaprsum1:=zaprsum1(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprsum1:=zaprsum1(left+1,right)+yy[left];\r\n if not odd(right) then zaprsum1:=zaprsum1(left,right-1)+yy[right];\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n\r\n procedure udal(ii:longint);\r\n begin next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii]; end;\r\n\r\n\r\n\r\n\r\n function pprost(pp:int64):boolean;\r\n var i,j,t:longint; tt:extended; fl:boolean;\r\n begin\r\n tt:=pp;\r\n tt:=sqrt(tt);\r\n fl:=true;\r\n for i:=2 to round(tt) do if pp mod i=0 then fl:=false;\r\n pprost:=fl;\r\n end;\r\n\r\n function gl(c:char):boolean;\r\n begin\r\n if (c='a')or (c='o')or(c='e')or(c='i')or(c='u') then gl:=true else gl:=false;\r\n end;\r\n { function slog(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.y+d1.y*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n slog:=@ans;\r\n end;\r\n\r\n function umn(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n umn:=@ans;\r\n end;\r\n\r\n function sravfr(d1,d2:zap):boolean;\r\n begin\r\n if d1.x*d2.y=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=fact[jj];\r\n p3:=fact[ii-jj];\r\n t2:=degg(p2,modul-2,modul);\r\n t3:=degg(p3,modul-2,modul);\r\n ot:=((p1*t2) mod modul*t3) mod modul;\r\n bincoef:=ot;\r\n end else bincoef:=0;\r\n end;\r\n\r\nfunction vhodit(znach:int64):int64;\r\nvar ans,aa,bb,cc,i:longint; flag:boolean;\r\nbegin\r\n aa:=1; bb:=p; cc:=aa; ans:=-100;\r\n while abs(aa-bb)>1 do\r\n begin\r\n cc:=(aa+bb) shr 1;\r\n if x[cc]<=znach then aa:=cc else bb:=cc;\r\n\r\n end;\r\n { writeln(cc);\r\n}\r\n flag:=false;\r\n cc:=max(0,cc-3); repeat inc(cc); until (x[cc]>=znach)or(cc>p);\r\n if (x[cc]=znach)and(cc<=p) then ans:=cc;\r\n vhodit:=ans;\r\nend;\r\n\r\nfunction maxnomer(znach:int64):int64;\r\nvar ans,aa,bb,cc,i:longint; flag:boolean;\r\nbegin\r\n aa:=1; bb:=p; cc:=aa; ans:=-100;\r\n while abs(aa-bb)>1 do\r\n begin\r\n cc:=(aa+bb) shr 1;\r\n if x[cc]<=znach then aa:=cc else bb:=cc;\r\n\r\n end;\r\n { writeln(cc);\r\n}\r\n flag:=false;\r\n cc:=min(p+1,cc+3); repeat dec(cc); until (x[cc]<=znach)or(cc<0);\r\n if (x[cc]<=znach)and(cc>=0) then ans:=cc;\r\n maxnomer:=ans;\r\nend;\r\n\r\n\r\n\r\n begin\r\n\r\n { assign (input,'D:\\Projects\\input.txt');reset(input);\r\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\r\n }\r\n readln(qq);\r\n for stepp:=1 to qq do\r\n begin\r\n pp:=0;\r\n for i:=1 to 2 do for j:=1 to 2 do read(pole[i,j]);\r\n for i:=1 to 2 do for j:=1 to 2 do if pole[i,j]=1 then inc(pp);\r\n if pp=0 then writeln(0) else if pp=4 then writeln(2) else writeln(1);\r\n\r\n\r\n\r\n2:\r\n end;\r\n\r\n\r\n\r\n\r\n1: close (output);\r\n\r\n\r\n end.\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of byte;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n readln(a[1,2]);\r\n read(a[2,1]);\r\n readln(a[2,2]);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(0);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(2);\r\n \r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "program polyana2;\r\n var b,c,t,i,j,d:integer;\r\n begin\r\n readln(t);\r\n for c:=1 to t do begin\r\n b:= 0;\r\n for d:= 1 to 2 do begin\r\n readln(i,j);\r\n b:= b+i+j;\r\n end; // for d:= 1 to 4 do end\r\n if b = 1 then writeln(1) else\r\n Writeln(b div 2);\r\n \r\n end; // for c:= 1 to t end\r\n \r\n end."}, {"source_code": "var t,j,a,b,dem:longint;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do\r\n begin\r\n dem:=0;\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if dem=4 then writeln(2) else if dem>=1 then writeln(1) else writeln(0);\r\n end;\r\nend."}], "negative_code": [{"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of byte;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n readln(a[1,2]);\r\n read(a[2,1]);\r\n readln(a[2,2]);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,21] = 0) and (a[2,2] = 0) then writeln(0);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 0) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 0) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 0) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 0) and (a[2,2] = 1) then writeln(1);\r\n if (a[1,1] = 1) and (a[1,2] = 1) and (a[2,1] = 1) and (a[2,2] = 1) then writeln(2);\r\n \r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of integer;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n if a[1,1] = 1 then inc(count_r1);\r\n readln(a[1,2]);\r\n if a[1,2] = 1 then inc(count_r1);\r\n read(a[2,1]);\r\n if a[2,1] = 1 then inc(count_r2);\r\n readln(a[2,2]);\r\n if a[2,2] = 1 then inc(count_r2);\r\n if count_r1 + count_r2 = 0 then writeln(0) else\r\n if (count_r1 + count_r2 >= 1) and (count_r1 + count_r2 < 3) then writeln(1) else writeln(2);\r\n \r\n \r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of integer;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n if a[1,1] = 1 then inc(count_r1);\r\n readln(a[1,2]);\r\n if a[1,2] = 1 then inc(count_r1);\r\n read(a[2,1]);\r\n if a[2,1] = 1 then inc(count_r2);\r\n readln(a[2,2]);\r\n if a[2,2] = 1 then inc(count_r2);\r\n if count_r1 + count_r2 = 0 then writeln(0) else\r\n if (count_r1 + count_r2 >= 1) and (count_r1 + count_r2 < 4) then writeln(1) else writeln(2);\r\n \r\n \r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of integer;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n if a[1,1] = 1 then inc(count_r1);\r\n readln(a[1,2]);\r\n if a[1,2] = 1 then inc(count_r1);\r\n read(a[2,1]);\r\n if a[2,1] = 1 then inc(count_r2);\r\n readln(a[2,2]);\r\n if a[2,2] = 1 then inc(count_r2);\r\n if count_r1 + count_r2 = 0 then writeln(0);\r\n if count_r1 + count_r2 = 1 then writeln(1);\r\n if count_r1 + count_r2 = 2 then writeln(1);\r\n if count_r1 + count_r2 = 3 then writeln(1);\r\n if count_r1 + count_r2 = 4 then writeln(2);\r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "{\r\n There is a field of size 2×2. Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.\r\n\r\nIn one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y, then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0).\r\n\r\nYour task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).\r\n\r\nYou have to answer t independent test cases.\r\n\r\nInput\r\nThe first line of the input contains one integer t (1≤t≤16) — the number of test cases. Then t test cases follow.\r\n\r\nThe test case consists of two lines, each of these lines contains two integers. The j-th integer in the i-th row is ai,j. If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.\r\n\r\nOutput\r\nFor each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.\r\n}\r\nvar a:array[1..2,1..2] of integer;\r\nn,count_r1,count_r2,i: integer;\r\nbegin\r\n readln(n);\r\n count_r1 := 0;\r\n count_r2 := 0;\r\n for i := 1 to n do\r\n begin\r\n read(a[1,1]);\r\n if a[1,1] = 1 then inc(count_r1);\r\n readln(a[1,2]);\r\n if a[1,2] = 1 then inc(count_r1);\r\n read(a[2,1]);\r\n if a[2,1] = 1 then inc(count_r2);\r\n readln(a[2,2]);\r\n if a[2,2] = 1 then inc(count_r2);\r\n if count_r1 + count_r2 = 0 then writeln(0) else\r\n if (count_r1 + count_r2 >= 1) and (count_r1 + count_r2<= 3) then writeln(1) else writeln(2);\r\n end;\r\n readln\r\nend.\r\n \r\n \r\n"}, {"source_code": "program polyana2;\r\n var b,c,t,i,j,d:integer;\r\n begin\r\n readln(t);\r\n for c:=1 to t do begin\r\n b:= 0;\r\n for d:= 1 to 2 do begin\r\n readln(i,j);\r\n b:= b+i+j;\r\n end; // for d:= 1 to 4 do end\r\n \r\n Writeln(b div 2);\r\n \r\n end; // for c:= 1 to t end\r\n \r\n end."}, {"source_code": "program polyana2;\r\n var b,c,t,i,j,d:integer;\r\n begin\r\n readln(t);\r\n for c:=1 to t do begin\r\n for d:= 1 to 2 do begin\r\n readln(i,j);\r\n b:= b+i+j;\r\n end; // for d:= 1 to 4 do end\r\n \r\n Writeln(b div 2);\r\n \r\n end; // for c:= 1 to t end\r\n \r\n end."}, {"source_code": "var t,j,a,b,dem:longint;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do\r\n begin\r\n dem:=0;\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if dem>=3 then writeln(2) else if dem>=1 then writeln(1) else writeln(0);\r\n end;\r\nend."}, {"source_code": "var t,j,a,b,dem:longint;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do\r\n begin\r\n dem:=0;\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n readln(a,b);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n writeln(dem);\r\n if dem>=3 then writeln(2) else if dem>=1 then writeln(1) else writeln(0);\r\n end;\r\nend."}, {"source_code": "var i,t,a,b,c,d,dem:longint;\r\n kq:array[1..16] of longint;\r\nbegin \r\n readln(t);\r\n for i := 1 to t do \r\n begin \r\n readln(a,b);\r\n readln(c,d);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if c=1 then inc(dem);\r\n if d=1 then inc(dem);\r\n if dem = 0 then kq[i]:=0 else \r\n if (dem = 1) or (dem =2) or (dem=3) then kq[i]:=1 else kq[i]:=2;\r\n end;\r\n for i:=1 to t do writeln(kq[i]);\r\nend.\r\n \r\n"}, {"source_code": "var i,t,a,b,c,d,dem:longint;\r\nbegin \r\n readln(t);\r\n for i := 1 to t do \r\n begin \r\n readln(a,b);\r\n readln(c,d);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if c=1 then inc(dem);\r\n if d=1 then inc(dem);\r\n if dem = 0 then writeln('0') else \r\n if (dem = 1) or (dem =2) or (dem=3) then writeln('1') else writeln('2');\r\n end;\r\nend.\r\n \r\n"}, {"source_code": "var i,t,a,b,c,d,dem:longint;\r\nbegin \r\n readln(t);\r\n for i := 1 to t do \r\n begin \r\n readln(a,b);\r\n readln(c,d);\r\n if a=1 then inc(dem);\r\n if b=1 then inc(dem);\r\n if c=1 then inc(dem);\r\n if d=1 then inc(dem);\r\n if dem = 0 then writeln('0') else \r\n if (dem = 1) or (dem =2) then writeln('1') else writeln('2');\r\n end;\r\nend.\r\n \r\n"}, {"source_code": "program grass_field;\r\n\r\n var\r\n count,a,b,c,d,t:byte;\r\n Ar:array[1..99] of byte;\r\n begin\r\n\r\n readln(t);\r\n if (t >= 1) and (t <= 16) then\r\n begin\r\n while (t<>0) do\r\n begin\r\n count:=1;\r\n read(a);\r\n readln(b);\r\n read(c);\r\n readln(d);\r\n if (a=0) and (b=0) and (c=0) and (d=0) then Ar[count]:=0\r\n else if (a=1) and (b=1) and (c=1) and (d=1) then Ar[count]:=2\r\n else Ar[count]:=1;\r\n count:=count+1;\r\n t:=t-1;\r\n end;\r\n for t:= 1 to count do writeln(Ar[t]);\r\n end;\r\n end.\r\n"}, {"source_code": "program grass_field;\r\n\r\n var\r\n a,b,c,d,t:byte;\r\n\r\n begin\r\n\r\n readln(t);\r\n if (t >= 1) and (t <= 16) then\r\n begin\r\n while (t<>0) do\r\n begin\r\n read(a);\r\n readln(b);\r\n read(c);\r\n readln(d);\r\n if (a=0) and (b=0) and (c=0) and (d=0) then write(0)\r\n else if (a=1) and (b=1) and (c=1) and (d=1) then write(2)\r\n else writeln(1);\r\n t:=t-1;\r\n end;\r\n end;\r\n readln;\r\n end.\r\n"}], "src_uid": "7336b8becd2438f0439240ee8f9610ec"} {"source_code": "\n var n,i,j:LongInt;\nBegin\n Read(n);\n for i:=0 to n div 1234567 do\n begin\n for j:=0 to (n-i*1234567) div 123456 do\n begin\n if(n-i*1234567-j*123456)mod 1234=0 then\n begin\n Write('YES');\n halt;\n end;\n end;\n end;\n Write('NO');\nEnd.", "positive_code": [{"source_code": "var\n a,b,ans,c,n,k:int64;\n i,j:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a<=b then min:=a else min:=b;\nend; \nbegin\n read(n);\n \n for i:=0 to n div 1234567 do\n for j:=0 to n div 123456 do\n if (n-i*1234567-j*123456>=0) and ((n-i*1234567-j*123456)mod 1234=0) then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "Uses math;\nConst\n fin='';\n fon='';\n maxC=1000000000;\n maxN=1000;\n\tmodule=1000000007;\n\nType\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n n:int64;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nBegin\n Readln(fi,n);\nEnd;\n\nProcedure xuly;\nVar\n i,j,o,n1,n2,n3:longint;\n tg,tg1,tg2:int64;\nBegin\n n1:=n div 1234567;\n n2:=n div 123456;\n n3:=n div 1234;\n For i:=0 to n1 do\n Begin\n tg:=i*1234567;\n For j:=0 to n2 do\n Begin\n tg1:=n-(tg+j*123456);\n If tg1<0 then break;\n If tg1 mod 1234=0 then\n Begin\n Writeln(fo,'YES');\n Dong;\n Halt;\n End;\n End;\n End;\n Writeln(fo,'NO');\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Dong;\nEND.\n"}, {"source_code": "const\n fi ='';\n fg ='';\nvar a,b,c,n:longint;\n f,g:text;\nfunction calc(n:longint):string;\nvar x,i,j:longint;\nbegin\n For i:=0 to 810 do\n For j:=0 to 810 do\n begin\n x :=n - a*i - b*j;\n If (x >= 0) and (x mod c = 0) then exit('YES');\n end;\n exit('NO');\nend;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fg);\n rewrite(g);\n readln(f,n);\n a :=1234567;b :=123456;c :=1234;\n writeln(g,calc(n));\n close(f);\n close(g);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar n,i,j:integer;\nbegin\n readln(n);\n for i:=0 to n div 1234567 do\n for j:=0 to (n-1234567*i) div 123456 do\n if (n-1234567*i-123456*j) mod 1234=0 then\n begin\n writeln('YES');\n halt\n end;\n writeln('NO')\nend."}, {"source_code": "var n,i,j:longint;begin read(n);for i:=0to n div 1234567do for j:=0to(n-i*1234567)div 123456do if(n-i*1234567-j*123456)mod 1234=0then begin write('YES');halt;end;write('NO')end."}, {"source_code": "var n,i,j:longint;begin read(n);for i:=0to n div 1234567do for j:=0to(n-i*1234567)div 123456 do if(n-i*1234567-j*123456)mod 1234=0then begin write('YES');halt;end;write('NO')end."}, {"source_code": "var\nn,i,j:longint;\nbol:boolean;\nbegin\nbol:=false;\nreadln(n);\nfor i:=0 to n div 1234567 do begin\nfor j:=0 to n div 123456 do begin\n if (n-(1234567*i+123456*j))>=0 then begin\n if (n-(1234567*i+123456*j)) mod 1234=0 then begin\n bol:=true;\n break;\n end;\n if bol then break;\n end;\n if bol then break;\nend;\nif bol then break;\nend;\nif bol then writeln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var\n a,b,c,i,j,k,m,n,o:longint;\nbegin\n readln(n);\n for i:=0 to (n div 1234567)do\n for j:=0 to (n div 123456) do\n begin\n k:=n-i*1234567-j*123456;\n if k<0 then continue;\n if (k mod 1234)=0 then begin writeln('YES'); halt; end;\n end;\n writeln('NO');\nend.\n\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar i,j:longint;\n pom,pom1,n:int64;\n begin\n read(n);\n\n for i:=0 to 1000 do\n for j:=0 to 10000 do\n begin\n pom:=i;\n pom1:=j;\n if (n>=pom*1234567+pom1*123456) and ((n-pom*1234567-pom1*123456) mod 1234=0) then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "const fi = '';\n\nvar n, a, b, house, car, computer: longint;\n res: boolean;\n f: text;\n\nbegin\n assign(f, fi); reset(f);\n readln(f, n);\n close(f);\n\n res:= false; house:= 1234567; car:= 123456; computer:= 1234;\n for a:= 0 to n div house do\n for b:= 0 to (n - a * house) div car do\n begin\n if (n - a * house - b * car) mod computer = 0 then\n begin\n res:= true;\n break;\n end;\n end;\n\n if res then writeln('YES') else writeln('NO');\n readln;\nend."}, {"source_code": "program O_O;\ntype\n ll=longint;\n bo=boolean;\nvar\n i,j,k,n,m,a,b,c:ll;\nbegin\n readln(n);\n // if n<1234567+123456+1234 then begin writeln('NO');exit;end;\n for a:=0 to 820 do\n for b:=0 to 8200 do\n begin\n c:=n-a*1234567-b*123456;\n if (c mod 1234=0)and(c>=0) then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var a,b,n :longint;\n\nbegin\n read(n);\n for a:=0 to n div 1234567 do\n begin\n for b:=0 to (n-a*1234567) div 123456 do\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n write('YES');\n halt;\n end;\n end;\n write('NO');\nend.\n"}, {"source_code": "var\n n,i,j:longint;\nbegin\n readln(n);\n for i:=0 to n div 1234567 do\n for j:=0 to n div 123456 do if i*1234567+j*123456<=n then\n begin\n if (n-i*1234567-j*123456) mod 1234=0 then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var n, i, j: longint;\n ans: boolean;\n \nbegin\n read(n);\n ans := False;\n for i := 0 to (n div 1234567) do\n for j := 0 to ((n - 1234567 * i) div 123456) do\n if (n - 1234567 * i - 123456 * j) mod 1234 = 0 then ans := True;\n if ans then write('YES') else write('NO');\nend."}, {"source_code": "var\n n:int64;\n a,b:longint;\nbegin\n readln(n);\n for a:=0 to 100 do\n for b:=0 to 1000 do\n if n>=a*1234567+b*123456 then\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "const\n fin='681B.inp';fon='681B.out';\nvar i,j,k,n:longint;\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(n);\nfor i:=0 to n div 1234567 do\n for j:=0 to (n-1234567*i) div 123456 do\n if (n-1234567*i-123456*j) mod 1234 = 0 then\n begin\n writeln('YES');\n halt;\n end;\nwriteln('NO');\nend;\n\nbegin\n//mo;\nsolve;\nend."}, {"source_code": "Var\nn,a,b,c,d,i,j,k,l,f,n1,f1,f2:longint;\nbegin\n read(n); n1:=n;\n k:= n div 1234567;\n l:= n div 123456;\n f:=n div 1234;\n if f=0 then\n write('NO')\n else\n if n mod 1234=0 then\n write('YES')\n else\n if n mod 123456=0 then\n write('YES')\n else\n if n mod 1234567=0 then\n write('YES')\n else\n if l=0 then\n write('NO')\n else\n if k=0 then\n for j:=1 to l do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end\n else\n \n begin\n for i:=1 to k do\n begin\n n1:=n; n1:=n1-i*1234567;\n for j:=1 to (n1 div 123456) do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end;\n end;\n for j:=1 to l do\n begin\n if n mod 1234=0 then\n f1:=1;\n f2:=1;\n n:=n-123456;\n if n mod 1234=0 then\n f1:=1;\n end;\n end;\nif (k=1) and (n1 div 123456=0) then\n if n1 mod 1234=0 then\n write('YES')\n else\n if f1=1 then\n write('YES')\n else\n write('NO')\nelse\nif f2=1 then\n if f1=1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "Const\n car=123456;\n house=1234567;\n cpt=1234;\n tfi='';\n tfo='';\nVar\n a,b:array[0..10000] of longint;\n n,n1,n2:longint;\n fi,fo:text;\nPRocedure Data;\nBegin\n Assign(fi,tfi);reset(fi);\n Assign(fo,tfo);rewrite(fo);\n readln(fi,n);\nENd;\nProcedure Solve;\nVar res:boolean;\n i,j:longint;\nBegin\n res:= false ;\n If (n mod car =0) or (n mod house=0) or (n mod cpt=0) then res:=true;\n n1:=n div car;n2:=n div house;\n For i:=1 to n1 do a[i]:=car*i;\n For i:=1 to n2 do b[i]:=house*i;\n FOr i:=0 to n1 do\n For j:=0 to n2 do\n If b[j]+a[i]<=n then\n Begin\n If (n-(b[j]+a[i])) mod cpt=0 then res:=true;\n end\n else break;\n If res=true then writeln(fo,'YES')\n Else Writeln(fo,'NO');\n Close(fi);Close(fo);\nENd;\nBegin\n data;\n solve;\nEnd."}, {"source_code": "const\n fin='';fon='';\n t=1234567;\n t2=123456;\n t3=1234;\n maxn=trunc(1e9);\nvar\n n:longint;\n c:int64;\nprocedure nhap;\n begin\n assigN(input,fin);reset(input);\n assigN(output,fon);rewritE(output);\n readln(n);\n end;\nprocedure xuli;\n var\n i,j,k:longint;\n top1,top2,top3:int64;\n begin\n top1:=maxn div t;\n top2:=maxn div t2;\n top3:=maxn div t3;\n for i:=0 to top1 do\n for j:=0 to top2 do\n begin\n if n>=(t*i)+(t2*j) then\n begin\n c:=n-(t*i+t2*j);\n if (c mod t3=0) and (c>=0) then\n begin\n writeln('YES');\n //writeln(i,' ',j,' ',(c div t3));\n exit;\n end;\n end;\n end;\n writeln('NO');\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend.\n\n"}, {"source_code": "var n,i,j,c:longint;\nbegin\n readln(c);\n for i:=0 to 810 do\n for j:=0 to 8100 do\n if ( c - (i*1234567 + j*123456) ) < 0 then break\n else\n if ( ( c - (i*1234567 + j*123456) ) = 0 ) or\n ( ( c - (i*1234567 + j*123456) ) mod 1234 = 0 ) then\n begin\n write('YES');\n exit;\n end;\n write('NO');\nend."}, {"source_code": "var c:real;\n x:int64;\n i,j,n:longint;\n\nprocedure xuli;\n begin\n readln(n);\n For i:=0 to 810 do\n For j:=0 to 8100 do\n begin\n x:=i*1234567+j*123456;\n x:=n-x;\n if x>=0 then\n begin\n c:=x/1234;\n if trunc(c)=c then\n begin\n writeln('YES');\n halt;\n end;\n end;\n end;\n writeln('NO');\n end;\n\nbegin\n//assign(input,'357B.inp');reset(input);\n//assign(output,'357B.out');rewrite(output);\nxuli;\nend.\n"}, {"source_code": "\n\n var N : LongInt;\n A , B : LongInt;\n sum : Int64;\nbegin\n readLn ( N ) ; \n\n for A := 0 to 100 do\n begin\n for B := 0 to 1000 do\n begin\n sum := (A * 1234567) + ( B * 123456 );\n \n if ( N >= sum ) then\n \n begin\n \n if ( (N - sum) mod 1234 = 0 ) then\n begin\n writeLn ( 'YES' ) ; \n halt();\n end;\n \n end;\n \n \n end;\n end;\n \n writeLn ( 'NO' ) ; \n\nend."}, {"source_code": "var\n ans:boolean;\n n,i,j,m,m1,m2:longint;\n{\nprocedure dfs(x,z:longint);\nbegin\n if (x mod 1234567=0)or(x mod 123456=0)or(x mod 1234=0)\n then begin\n writeln('YES');\n halt;\n end;\n if (x>1234567)and(z<>1)\n then dfs(x-1234567,1);\n if (x>123456)and(z<>2)\n then dfs(x-123456,2);\n if (x>1234)and(z<>3)\n then dfs(x-1234,3);\nend;\n}\nbegin\n m1:=811;\n m2:=8101;\n readln(n);\n for i:=0 to m1 do\n begin\n for j:=0 to m2 do\n begin\n m:=n-(i*1234567+j*123456);\n if m<0\n then break;\n if (m mod 1234=0)\n then begin\n writeln('YES');\n halt;\n end;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "Const Fi='';\n Fo='';\nVar f:text;\n n:longint;\n a,b,c:longint;\nProcedure docfile;\n Begin\n Assign(f,fi);Reset(f);\n Readln(f,n);\n Close(f);\n End;\nFunction kt:boolean;\n Begin\n For a:=0 to n div 1234567 do\n For b:=0 to n div 123456 do\n If (n-a*1234567 -b*123456) >=0 then\n If (n-a*1234567 -b*123456) mod 1234 =0 then exit(true);\n exit(false);\n End;\nProcedure xuly;\n Begin\n Assign(f,fo);\n Rewrite(f);\n If kt=true then writeln(f,'YES') else writeln(f,'NO');\n Close(f);\n End;\nBegin\n docfile;\n xuly;\nEnd.\n"}, {"source_code": "var n,i,j:longint;\nbegin\nreadln(n);\nfor i:=0 to n div 1234567 do\n for j:=0 to (n-i*1234567) div 123456 do\n if (n-i*1234567-j*123456) mod 1234=0 then\n begin writeln('YES'); halt; end;\nwriteln('NO');\nend."}, {"source_code": "var\n\tx,y,z,tt,ttt,n,k,i,j:longint;\n\tboo:boolean;\nbegin\n\treadln(n);\n\tx:=1234567;\n\ty:=123456;\n\tz:=1234;\n\tboo:=false;\n\tfor k:= (n div x) downto 0 do\n\tbegin\n\t\ttt:=n-(k*x);\n\t\tfor i:= (tt div y) downto 0 do\n\t\tbegin\n\t\t\tttt:= tt-(i*y);\n\t\t\tif (ttt mod z)=0 then boo:=true;\n\t\tend;\n\tend;\n\tif boo then writeln('YES') else writeln('NO');\nend.\n\n\n\n\t"}, {"source_code": "var\n n, i, j, f : longint;\nbegin\n f := 0;\n readln(n);\n for i := 0 to n div 1234567 do\n for j := 0 to n div 123456 do\n if (n - (i * 1234567 + j * 123456) >= 0) and\n ((n - (i * 1234567 + j * 123456)) mod 1234 = 0) then f := 1;\n if f = 1 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var n,i,x,y,k,p,j,z:longint;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(n);\nx:=1234567;\ny:=123456;\nz:=1234;\nfor i:=0 to 100 do\n for j:=0 to 1000 do\n begin\n p:=n-(i*x+j*y);\n if (p mod z=0) and (p>=0) then begin writeln('YES');\n halt; end;\n end;\nwriteln('NO');\n{close(input);\nclose(output); }\nend."}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000008;\n\tmaxN=108;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nProcedure Nhap;\nvar\n i,j,n,a,b,c,tg,x,y:longint;\nBegin\n readln(n);\n tg:=n;\n a:=1234567;\n b:=123456;\n c:=1234;\n i:=0;\n j:=0;\n\n while i*a<=n do\n begin\n while n-j*b-i*a>=0 do\n begin\n tg:=n-j*b-i*a;\n if tg mod c=0 then\n begin\n writeln('YES');\n halt;\n end;\n inc(j);\n end;\n inc(i);\n j:=0;\n end;\n writeln('NO');\nend;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nBEGIN\n\tOpenf;\n\tNhap;\n\tXuli;\n\tXuat;\n\tClosef;\nEND.\n\n"}, {"source_code": "var n,i1,i2,i3,k1,k2,k3,a1,a2,a3:longint;\nbegin\n readln(n);\n if n<1234 then begin\n writeln('NO');\n halt;\n end;\n if (n mod 1234=0) or (n mod 123456=0) or (n mod 1234567=0) then begin\n writeln('YES');\n halt;\n end;\n\n k1:=n div 1234567;\n k2:=n div 123456;\n a1:=1234567;\n a2:=123456;\n a3:=1234;\n for i1:=0 to k1 do\n for i2:=0 to k2 do\n begin\n k3:=(i1*1234567+i2*123456);\n if ((n-k3>0) and ((n-k3) mod a3=0)) or ((i1*a1+i2*a2)=n) or (((n-i1*a1)>0) and (n-i1*a1 mod 1234=0)) or\n (((n-i2*a2)>0) and (n-i2*a2 mod 1234=0))\n then begin\n writeln('YES');;\n halt;\n end;\n\n end;\n writeln('NO');\nend."}, {"source_code": "program BB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nx,y,z,i,j,n,ni,nj:longint;\nflag:boolean;\nbegin\n readln(n);\n x:=1234567;\n y:=123456;\n z:=1234;\n flag:=false;\n for i:=0 to n div x do\n begin\n ni:=n-i*x;\n for j:=0 to ni div y do\n begin\n nj:=ni-j*y;\n if (nj mod z=0) then begin flag:=true; end;\n end;\n end;\n if (flag=true) then writeln('YES') else writeln('NO');\nend.\n "}, {"source_code": "var s:string;q:char;i,n,a,b:longint;\nbegin\n readln(n);\n for i:=0 to n div 1234567 do\n begin\n b:=n-i*1234567;\n for a:=0 to b DIV 123456 do \n\n if (b-a*123456) MOD 1234 =0then\n begin write('YES')\n ;halt;\n end;\n end;write('NO')\nend."}, {"source_code": "program u;\nvar n,i,j,k,a,b:longint; m:array[0..37,-37..37]of int64; c:char;\nbegin\n { assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n }read(n);\n for i:=0 to n div 1234567 do\n for j:=0 to (n-i*1234567) div 123456 do\n if (n-i*1234567-j*123456) mod 1234=0\n then k:=1;\n if k=1\n then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var n,i,j,c:longint;\nbegin\n readln(c);\n for i:=0 to 810 do\n for j:=0 to 8100 do\n if ( c - (i*1234567 + j*123456) ) < 0 then break\n else\n if ( ( c - (i*1234567 + j*123456) ) = 0 ) or\n ( ( c - (i*1234567 + j*123456) ) mod 1234 = 0 ) then\n begin\n write('YES');\n exit;\n end;\n write('NO');\nend."}, {"source_code": "var\n a, b, c, i, j, t: int64;\n q: boolean;\n \nbegin\n readln(a);\n i := 0;\n q := false;\n while i * 1234567 <= a do begin \n j := 0;\n while j * 123456 + i * 1234567 <= a do begin\n t := (a - j * 123456 - i * 1234567) div 1234;\n if j * 123456 + i * 1234567 + t * 1234 = a then q := true;\n inc(j);\n end;\n inc(i);\n end;\n if q then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\na,b,c,n1,n,n2,i,j:longint;\nkt:boolean;\n\nbegin\n//assign(input,'681b.inp');reset(input);\n//assign(output,'681b.out');rewrite(output);\nreadln(n);\nwhile a*1234567<=n do\n inc(a);\ndec(a);\nfor i:=0 to a do\n begin\n n1:=n-i*1234567;\n b:=0;\n while b*123456<=n1 do\n inc(b);\n dec(b);\n for j:=0 to b do\n begin\n n2:=n1-j*123456;\n if n2 mod 1234=0 then\n begin\n writeln('YES');\n halt;\n end;\n end;\n end;\nwriteln('NO');\nend.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x, y, z, w, a, b, v : integer;\n k : longint;\nbegin\n read(w);\n x:=1234;\n y:=123456;\n z:=1234567;\n k:=0;\n for a:=0 to w div x do\n for b:=0 to w div y do\n begin\n v:=w-a*x-b*y;\n if (v>=0) and (v mod z=0) then begin\n writeln('YES');\n exit;\n end;\n end;\n write('NO');\nend.\n"}, {"source_code": "var\n i,casos,c,n:longint;\n a,b,x,y:int64;\n res:extended;\nbegin\n readln(n);\n while a*1234567<=n do\n begin\n b:=0;\n while a*1234567+b*123456<=n do\n begin\n c:=n-a*1234567-b*123456;\n if (c>=0) And (c mod 1234=0) then\n begin\n writeln('YES');\n halt;\n end;\n b:=b+1;\n end;\n a:=a+1;\n end;\n writeln('NO');\n i:=i;\nend.\n "}, {"source_code": "var\n a,b,c,n,m:int64;\n lim:longint;\nbegin\n lim:=1000000000;\n readln(n);\n while a*1234567<=n do\n begin\n b:=0;\n while a*1234567+b*123456<=n do\n begin\n m:=n-(a*1234567+b*123456);\n if (m>=0) AND (m mod 1234=0) then\n begin\n writeln('YES');\n halt;\n end;\n b:=b+1;\n end;\n a:=a+1;\n end;\n writeln('NO');\nend. "}, {"source_code": "var a,b,n,x,f,kk,aa,otv,i1,i2,i3,d:longint;\nbegin\nreadlN(n);\nfor i1:=0 to 1000 do\nfor i2:=0 to 1000 do\nbegin\nd:=n-(i1*1234567+i2*123456);\nif (d>=0)and(d mod 1234=0) then begin writelN('YES');halt;end;\nend;\nwritelN('NO');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar a, b, c, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n for a:=0 to n div 1234567 do\n for b:=0 to (n-a*1234567) div 123456 do\n if (n-a*1234567-b*123456) mod 1234 = 0 then\n begin\n writeln('YES');\n halt;\n end;\n writeln('NO');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var n,i,j,x,y,z:longint;\nprocedure nhap;\n begin\n\n readln(n);\n\n x:=1234567; y:=123456; z:=1234;\n\n end;\n\nprocedure xuli;\n begin\n\n for i:=0 to 100 do\n for j:=1000 downto 0 do\n if n-i*x-j*y>=0 then\n if (n-i*x-j*y) mod z=0 then\n begin\n\n writeln('YES');\n halt;\n\n end;\n\n writeln('NO');\n\n end;\n\nbegin\nnhap;\nxuli;\nend.\n\n\n\n"}, {"source_code": "var n,i,j,x,y,z:longint;\nprocedure nhap;\n begin\n\n readln(n);\n\n x:=1234567; y:=123456; z:=1234;\n\n end;\n\nprocedure xuli;\n begin\n\n for i:=0 to 100 do\n for j:=1000 downto 0 do\n if n-i*x-j*y>=0 then\n if (n-i*x-j*y) mod z=0 then\n begin\n\n writeln('YES');\n halt;\n\n end;\n\n writeln('NO');\n\n end;\n\nbegin\nnhap;\nxuli;\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\n res:array[0..1] of string=('YES','NO');\n numa=1234567;\n numb=123456;\n numc=1234;\nVar n:int64;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nFunction Solve:longint;\nVar i,j,a,b,maxa,maxb:longint;\nBegin\n maxa:=n div numa; maxb:=n div numb;\n for a:=0 to maxa do\n for b:=0 to maxb do\n if (a*numa+b*numb)<=n then\n if (n-(a*numa+b*numb)) mod numc=0 then\n exit(0);\n exit(1);\nEnd;\nProcedure Xuat;\nVar f:Text;\n tmp:longint;\nBegin\n assign(f,fout); rewrite(f);\n tmp:=solve;\n write(f,res[tmp]);\n close(f);\nEnd;\n\nBegin\n nhap;\n xuat;\nEnd."}, {"source_code": "Program B337;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\nn, a1, b1: int64;\na, b: longint;\n\nProcedure Process;\nBEGIN\nreadln(fi, n);\nfor a := 0 to n div 1234567 do\n\tbegin\n\ta1 := n - a*1234567;\n\tfor b := 0 to a1 div 123456 do\n\t\tbegin\n\t\tb1 := a1 - b*123456;\n\t\tif b1 mod 1234 = 0 then \n\t\t\tbegin\n\t\t\twriteln(fo, 'YES');\n\t\t\texit;\n\t\t\tend;\n\t\tend;\n\tend;\nwriteln(fo, 'NO');\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND."}, {"source_code": "var\n os,r,t,y,a,b,c,n,i,j,q:longint;\n const h:longint=1234567;\n const bu:longint=1234;\n const k:longint=123456;\nbegin\n readln(N);\n for a:=0 to 810 do\n begin\n for b:=0 to 8100 do\n\n if ((n-((a*h)+(b*k))) mod bu=0)and( (n-( (a*h) + (b*k) ) )>=0 ) then\n begin\n\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\n\nend.\n\n"}, {"source_code": " \n const eps=0.000000000001; besk1=8000000000000000000; nn=200000;\n modul=1000000007;\n label 1,2;\n type\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ii,jj,n,qq,xx,q,pos,left,right,amax,ost,h,tt,t1,pp,p,aa,bb,cc,kk,dist,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,s1,s2,m,s,cen,t2,i1,besk:int64;\n mask,newug,ugol,newdl,dloch,dugol,ist,jst,ifin,jfin,newnapx,newnapy,napx,napy,step, k,i,j:longint;\n prmax,v,aaa,bbb,ccc:extended; hhh:zap;\n dl,ochnewi,ochnewj,xxx,yyy,ochi,ochj,c,y,z,newoch,och,x,aold,b,a:array[-100000..2000000] of int64;\n stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;\n marked:array[-10..1100,-10..1100] of boolean;\n sss, ss1,ss2:string;\n sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;\n fl:array[0..200] of boolean;\n ss: array[-10..100000] of string;ch3,ch,ch1,ch2:char;\n razl:array[0..300000,0..18] of integer;\n pr:array[-10..300,-10..300] of extended;\n ddmax,ddmin :array[-1..300000,-1..20] of extended;\n pole :array [-10..2000] of char;\n maxpr:array[0..nn] of string;\n str:array[0..nn] of string;\n tt1,tt2,disk,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\nreadln(n);\n for i:=0 to 1000 do for j:=0 to 10000 do\n\n begin\n ii:=i; jj:=j;\n t:=n-ii*1234567-jj*123456;\n if (t>=0) and(t mod 1234=0) then flag:=true;\n\n end;\n\n if flag then write('YES') else write('NO');\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "const\n fin='681B.inp';fon='681B.out';\nvar i,j,k,n:longint;\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(n);\nfor i:=0 to n div 1234567 do\n for j:=0 to (n-1234567*i) div 123456 do\n if (n-1234567*i-123456*j) mod 1234 = 0 then\n begin\n writeln('YES');\n halt;\n end;\nwriteln('NO');\nend;\n\nbegin\n//mo;\nsolve;\nend."}, {"source_code": "var a,b,c,f,n,i,j,l,m:longint; p:array [1..1000000] of longint;\nbegin\n {assign (input,'input.txt'); reset (input);\n assign (output,'output.txt'); rewrite (output); }\n readln (n);\n f:=0;\n a:=1234;\n b:=123456;\n c:=1234567;\n l:=1;\n if n mod a=0 then f:=1;\n if n mod b=0 then f:=1;\n if n mod c=0 then f:=1;\n if f=0 then\n begin\n i:=1;\n p[l]:=n;\n l:=l+1;\n if n>c then\nbegin\n while (f=0) and (i<=(n div c)) do\n begin\n m:=n-(c*i);\n if m mod a=0 then f:=1;\n if m mod b=0 then f:=1;\n p[l]:=m;\n l:=l+1;\n i:=i+1;\n end;\nend;\n l:=l-1;\n if f=0 then\n begin\n i:=1;\n while (f=0) and (i<=l) do\n begin\n j:=1;\n while (f=0) and (j<=(p[i] div b)) do\n begin\n m:=p[i]-b*j;\n if m mod a=0 then f:=1;\n j:=j+1;\n end;\n i:=i+1;\n end;\n end;\n end;\n //if f=1 then writeln ('YES',' ',m,' ',l,' ',i-1,' ',p[i-1]) else writeln ('NO');\n if f=1 then write ('YES') else write ('NO');\nend.\n"}, {"source_code": "program yan;\n var a,b,c,n:longint; z:int64;\nbegin\n readln(n);\n for a:=0 to 1000000 do\n begin\n z:=a*1234567;\n if z>n then break;\n for b:=0 to 1000000 do\n begin\n z:=a*1234567+b*123456;\n if z>n then break;\n if (n-z)mod 1234=0 then\n begin\n write('YES');\n exit;\n end;\n end;\n end;\n write('NO');\nend.\n\n "}, {"source_code": "var\n n,i,j,k,tt,t : int64;\n\n function fnd(x : int64) : int64;\n var\n l,r,mid : int64;\n begin\n l:=1; r:=815000;\n while l < r do begin\n mid:=(l+r) div 2;\n if x <= mid*1234 then r:=mid else l:=mid+1;\n end;\n if l*1234 <= x then exit(l) else exit(0);\n end;\n\nbegin\n readln(n);\n i:=0;\n while i <= 820 do begin\n if n-1234567*i < 0 then break;\n t:=n-1234567*i;\n if t = 0 then begin writeln('YES'); halt; end;\n j:=0;\n while j <= 8105 do begin\n if t-j*123456 < 0 then break;\n tt:=t-j*123456;\n if tt = 0 then begin writeln('YES'); halt; end;\n k:=fnd(tt);\n if (tt-k*1234 = 0) then begin writeln('YES'); halt; end;\n inc(j);\n end;\n inc(i);\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var i,i1,i2,i3,n1,n2,n3:longint;\n ans,n:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=0 to 900 do\nfor i2:=0 to 9000 do\nif (i1*1234567+i2*123456<999999999) then\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=0)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "\nVar f,g:Text;\n N,i,j:longint;\n Begin\n Readln(N);\n For i:=0 to (N div 1234567) do\n For j:=0 to (N-i*1234567) div 123456 do\n Begin\n If (N-i*1234567-j*123456) mod 1234 = 0 then\n Begin\n Write('YES');\n Exit;\n End;\n End;\n Write('NO');\n End.\n"}, {"source_code": "program z1;\nconst a = 1234567;\n b = 123456;\n c = 1234;\nvar d,i,j,k,l,m,n,p1,p2:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\np1:=n div a;\nfor i:=0 to p1 do\n begin\n m:=n-a*i;\n p2:=m div b;\n for j:=0 to p2 do\n begin\n k:=m-j*b;\n if k mod c=0 then begin write('YES'); exit; end;\n end;\n end;\nwrite('NO');\nend."}, {"source_code": "var\n a, b, c: LongInt;\n n: Int64;\n \nbegin\n Read (n);\n \n for a:= 0 to n div 1234567 + 1 do\n for b:= 0 to (n - a * 1234567) div 123456 + 1 do\n if ((n - a * 1234567 - b * 123456) mod 1234 = 0) and (n - a * 1234567 - b * 123456 >= 0) then\n begin\n WriteLn ('YES');\n Exit\n end;\n \n WriteLn ('NO')\nend."}, {"source_code": "var n: longint;\n a,b,c: longint;\n\nbegin\n readln(n);\n for a:=0 to n div 1234567 do\n for b:=0 to n div 123456 do\n if ((n-a*1234567-b*123456) mod 1234=0) and (n>=a*1234567+b*123456) then\n begin\n writeln('YES');\n halt;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n N,k1,k2,i,j:Longint;\n F:Boolean;\nbegin\n Readln(N);\n k1:=N div 1234567;\n F:=False;\n for i:=0 to k1 do\nbegin\n k2:=(N-i*1234567) div 123456;\n for j:=0 to k2 do\n if ((n-i*1234567-j*123456)>=0) and ((n-i*1234567-j*123456) mod 1234=0) then begin\n F:=True;\n Break;\n end;\n if F then Break;\n end;\n if F then Writeln('YES')\n else Writeln('NO');\n end.\n\n"}], "negative_code": [{"source_code": "var\n a,b,ans,c,n,k:int64;\n i,j:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a<=b then min:=a else min:=b;\nend; \nbegin\n read(n);\n \n for i:=0 to n div 1234567 do\n for j:=0 to n div 123456 do\n if (n-i*1234567-j*123456>0) and ((n-i*1234567-j*123456)mod 1234=0) then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "var\n a,b,ans,c,n,k:int64;\n i,j:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a<=b then min:=a else min:=b;\nend; \nbegin\n read(n);\n \n for i:=1 to n div 1234567 do\n for j:=1 to n div 123456 do\n if (n-i*1234567-j*123456>0) and ((n-i*1234567-j*123456)mod 1234=0) then begin writeln('YES');halt;end;\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\nbegin\n read(n);\n a:=n div 1234567;\n n:=n mod 1234567;\n n:=n mod 123456;\n n:=n mod 1234;\n if n=0 then writeln('YES') else writeln('NO');\nend. "}, {"source_code": "var\n a,b,ans,c,n,k:int64;\n i,j:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a<=b then min:=a else min:=b;\nend; \nbegin\n read(n);\n \n for i:=0 to 1000 do\n for j:=0 to 1000 do\n if (n-i*1234567-j*123456>0) and ((n-i*1234567-j*123456)mod 1234=0) then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s:string;\nbegin\n read(n);\n \n for i:=1 to 100 do\n for j:=1 to 1000 do\n for k:=1 to 1000 do\n if i*1234567+j*123456+k*1234=n then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "var\n a,b,ans,c,n,k:int64;\n i,j:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a<=b then min:=a else min:=b;\nend; \nbegin\n read(n);\n \n for i:=1 to n div 1234567 do\n for j:=1 to n div 123456 do\n if (n-i*1234567-j*123456>0) and ((n-i*1234567-j*123456)mod 1234=0) then begin writeln('YES');halt;end;\nwriteln('NO');\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n s:string;\nbegin\n read(n);\n \n for i:=1 to 100 do\n for j:=1 to 100 do\n for k:=1 to 1000 do\n if i*1234567+j*123456+k*1234=n then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "var n,i,j:LongInt;\nBegin\n Read(n);\n for i:=1 to n div 1234567 do\n begin\n for j:=1 to (n-i*1234567) div 123456 do\n begin\n if(n-i*1234567-j*123456)mod 1234=0 then\n begin\n Write('YES');\n halt;\n end;\n end;\n end;\n Write('NO');\nEnd."}, {"source_code": "program O_O;\ntype\n ll=longint;\n bo=boolean;\nvar\n i,j,k,n,m,a,b,c:ll;\nbegin\n readln(n);\n if n<1234567+123456+1234 then begin writeln('NO');exit;end;\n for a:=1 to 810 do\n for b:=1 to 8100 do\n begin\n c:=n-a*1234567-b*123456;\n if (c mod 1234=0)and(c>0) then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "program O_O;\ntype\n ll=longint;\n bo=boolean;\nvar\n i,j,k,n,m,a,b,c:ll;\nbegin\n readln(n);\n if n<1234567+123456+1234 then begin writeln('NO');exit;end;\n for a:=1 to 820 do\n for b:=1 to 8200 do\n begin\n c:=n-a*1234567-b*123456;\n if (c mod 1234=0)and(c>=0) then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "program O_O;\ntype\n ll=longint;\n bo=boolean;\nvar\n i,j,k,n,m,a,b,c:ll;\nbegin\n readln(n);\n if n<1234567+123456+1234 then begin writeln('NO');exit;end;\n for a:=1 to 820 do\n for b:=1 to 8200 do\n begin\n c:=n-a*1234567-b*123456;\n if (c mod 1234=0)and(c>0) then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var n, i, j: longint;\n ans: boolean;\n \nbegin\n read(n);\n ans := False;\n for i := 0 to (n div 1234567) do\n for j := 0 to ((n - 1234567 * i) mod 123456) do\n if (n - 1234567 * i - 123456 * j) mod 1234 = 0 then ans := True;\n if ans then write('YES') else write('NO');\nend."}, {"source_code": "var\n n:int64;\n a,b:longint;\nbegin\n readln(n);\n for a:=1 to 1000 do\n for b:=1 to 1000 do\n if n>=a*1234567+b*123456 then\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n n:int64;\n a,b:longint;\nbegin\n readln(n);\n for a:=1 to 1000 do\n for b:=1 to 10000 do\n if n>=a*1234567+b*123456 then\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n n:int64;\n a,b:longint;\nbegin\n readln(n);\n for a:=1 to 100 do\n for b:=1 to 1000 do\n if n>a*1234567+b*123456 then\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n n:int64;\n a,b:longint;\nbegin\n readln(n);\n for a:=1 to 1000 do\n for b:=1 to 1000 do\n if n>a*1234567+b*123456 then\n if (n-a*1234567-b*123456) mod 1234=0 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "Var\nn,a,b,c,d,i,j,k,l,f,n1,f1,f2:longint;\nbegin\n read(n); n1:=n;\n k:= n div 1234567;\n l:= n div 123456;\n f:=n div 1234;\n if f=0 then\n write('NO')\n else\n if n mod 1234=0 then\n write('YES')\n else\n if n mod 123456=0 then\n write('YES')\n else\n if n mod 1234567=0 then\n write('YES')\n else\n if l=0 then\n write('NO')\n else\n if k=0 then\n for j:=1 to l do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end\n else\n \n begin\n for i:=1 to k do\n begin\n n1:=n; n1:=n1-i*1234567;\n for j:=1 to (n1 div 123456) do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end;\n end;\n end;\nif (k=1) and (n1 div 123456=0) then\n if n1 mod 1234=0 then\n write('YES')\n else\n write('NO')\nelse\nif f2=1 then\n if f1=1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "Var\nn,a,b,c,d,i,j,k,l,f,n1,f1,f2:longint;\nbegin\n read(n); n1:=n;\n k:= n div 1234567;\n l:= n div 123456;\n f:=n div 1234;\n if f=0 then\n write('NO')\n else\n if n mod 1234=0 then\n write('YES')\n else\n if n mod 123456=0 then\n write('YES')\n else\n if n mod 1234567=0 then\n write('YES')\n else\n if l=0 then\n write('NO')\n else\n if k=0 then\n for j:=1 to l do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n end\n else\n \n begin\n for i:=1 to k do\n begin\n n1:=n; n1:=n1-i*1234567;\n for j:=1 to (n1 div 123456) do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end;\n end;\n end;\nif f2=1 then\n if f1=1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "Var\nn,a,b,c,d,i,j,k,l,f,n1,f1,f2:longint;\nbegin\n read(n); n1:=n;\n k:= n div 1234567;\n l:= n div 123456;\n f:=n div 1234;\n if f=0 then\n write('NO')\n else\n if n mod 1234=0 then\n write('YES')\n else\n if n mod 123456=0 then\n write('YES')\n else\n if n mod 1234567=0 then\n write('YES')\n else\n if l=0 then\n write('NO')\n else\n if k=0 then\n for j:=1 to l do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end\n else\n \n begin\n for i:=1 to k do\n begin\n n1:=n; n1:=n1-i*1234567;\n for j:=1 to (n1 div 123456) do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end;\n end;\n end;\n for j:=1 to l do\n begin\n if n mod 1234=0 then\n f1:=1;\n f2:=1;\n n:=n-123456;\n if n mod 1234=0 then\n f1:=1;\n end;\nif (k=1) and (n1 div 123456=0) then\n if n1 mod 1234=0 then\n write('YES')\n else\n if f1=1 then\n write('YES')\n else\n write('NO')\nelse\nif f2=1 then\n if f1=1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "Var\nn,a,b,c,d,i,j,k,l,f,n1,f1,f2:longint;\nbegin\n read(n); n1:=n;\n k:= n div 1234567;\n l:= n div 123456;\n f:=n div 1234;\n if f=0 then\n write('NO')\n else\n if n mod 1234=0 then\n write('YES')\n else\n if n mod 123456=0 then\n write('YES')\n else\n if n mod 1234567=0 then\n write('YES')\n else\n if l=0 then\n write('NO')\n else\n if k=0 then\n for j:=1 to l do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end\n else\n \n begin\n for i:=1 to k do\n begin\n n1:=n; n1:=n1-i*1234567;\n for j:=1 to (n1 div 123456) do\n begin\n if n1 mod 1234=0 then\n f1:=1;\n f2:=1;\n n1:=n1-123456;\n if n1 mod 1234=0 then\n f1:=1;\n end;\n end;\n end;\nif f2=1 then\n if f1=1 then\n write('YES')\n else\n write('NO');\nend."}, {"source_code": "const\n fin='';fon='';\n t=1234567;\n t2=123456;\n t3=1234;\n maxn=trunc(1e9);\nvar\n n:longint;\nprocedure nhap;\n begin\n assigN(input,fin);reset(input);\n assigN(output,fon);rewritE(output);\n readln(n);\n end;\nprocedure xuli;\n var\n i,j,k:longint;\n top1,top2,top3,c:int64;\n begin\n top1:=maxn div t;\n top2:=maxn div t2;\n for i:=1 to top1 do\n for j:=1 to top2 do\n begin\n c:=n-(t*i+t2*j);\n if (c mod t3=0) and (c>=t3) then\n begin\n writeln('YES');\n writeln(i,' ',j,' ',(c div t3));\n exit;\n end;\n end;\n writeln('NO');\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend.\n\n"}, {"source_code": "const\n fin='';fon='';\n t=1234567;\n t2=123456;\n t3=1234;\n maxn=trunc(1e9);\nvar\n n:longint;\nprocedure nhap;\n begin\n assigN(input,fin);reset(input);\n assigN(output,fon);rewritE(output);\n readln(n);\n end;\nprocedure xuli;\n var\n i,j,k:longint;\n top1,top2,top3,c:int64;\n begin\n top1:=maxn div t;\n top2:=maxn div t2;\n if (n mod t=0) or (n mod t2=0) or (n mod t3=0) then\n begin\n writeln('YES');\n exit;\n end;\n for i:=0 to top1+1 do\n for j:=0 to top2+1 do\n begin\n c:=n-(t*i+t2*j);\n if (c mod t3=0) and (c>=t3) then\n begin\n writeln('YES');\n //writeln(i,' ',j,' ',(c div t3));\n exit;\n end;\n end;\n writeln('NO');\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend."}, {"source_code": "const\n fin='';fon='';\n t=1234567;\n t2=123456;\n t3=1234;\n maxn=trunc(1e9);\nvar\n n:longint;\nprocedure nhap;\n begin\n assigN(input,fin);reset(input);\n assigN(output,fon);rewritE(output);\n readln(n);\n end;\nprocedure xuli;\n var\n i,j,k:longint;\n top1,top2,top3,c:int64;\n begin\n top1:=maxn div t;\n top2:=maxn div t2;\n for i:=1 to top1+1 do\n for j:=1 to top2+1 do\n begin\n c:=n-(t*i+t2*j);\n if (c mod t3=0) and (c>=t3) then\n begin\n writeln('YES');\n //writeln(i,' ',j,' ',(c div t3));\n exit;\n end;\n end;\n writeln('NO');\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend."}, {"source_code": "const\n fin='';fon='';\n t=1234567;\n t2=123456;\n t3=1234;\n maxn=trunc(1e9);\nvar\n n:longint;\nprocedure nhap;\n begin\n assigN(input,fin);reset(input);\n assigN(output,fon);rewritE(output);\n readln(n);\n end;\nprocedure xuli;\n var\n i,j,k:longint;\n top1,top2,top3,c:int64;\n begin\n top1:=maxn div t;\n top2:=maxn div t2;\n for i:=0 to top1+1 do\n for j:=0 to top2+1 do\n begin\n c:=n-(t*i+t2*j);\n if (c mod t3=0) and (c>=t3) then\n begin\n writeln('YES');\n //writeln(i,' ',j,' ',(c div t3));\n exit;\n end;\n end;\n writeln('NO');\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend."}, {"source_code": "var\n ans:boolean;\n n,i,j,m,m1,m2:longint;\n{\nprocedure dfs(x,z:longint);\nbegin\n if (x mod 1234567=0)or(x mod 123456=0)or(x mod 1234=0)\n then begin\n writeln('YES');\n halt;\n end;\n if (x>1234567)and(z<>1)\n then dfs(x-1234567,1);\n if (x>123456)and(z<>2)\n then dfs(x-123456,2);\n if (x>1234)and(z<>3)\n then dfs(x-1234,3);\nend;\n}\nbegin\n m1:=811;\n m2:=8101;\n readln(n);\n for i:=1 to m1 do\n begin\n for j:=1 to m2 do\n begin\n m:=n-(i*1234567+j*123456);\n if m<0\n then break;\n if (m mod 1234=0)\n then begin\n writeln('YES');\n halt;\n end;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "Const Fi='';\n Fo='';\nVar f:text;\n n:longint;\n a,b,c:longint;\nProcedure docfile;\n Begin\n Assign(f,fi);Reset(f);\n Readln(f,n);\n Close(f);\n End;\nFunction kt:boolean;\n Begin\n For a:=0 to 810 do\n For b:=0 to 8100 do\n If n-a*1234567 +b*123456 mod 1234 =0 then exit(true);\n exit(false);\n End;\nProcedure xuly;\n Begin\n Assign(f,fo);\n Rewrite(f);\n If kt=true then writeln(f,'YES') else writeln(f,'NO');\n Close(f);\n End;\nBegin\n docfile;\n xuly;\nEnd.\n"}, {"source_code": "Const Fi='';\n Fo='';\nVar f:text;\n n:longint;\n a,b,c:longint;\nProcedure docfile;\n Begin\n Assign(f,fi);Reset(f);\n Readln(f,n);\n Close(f);\n End;\nFunction kt:boolean;\n Begin\n For a:=0 to n div 1234567 do\n For b:=0 to n div 123456 do\n If (n-a*1234567 -b*123456) mod 1234 =0 then exit(true);\n exit(false);\n End;\nProcedure xuly;\n Begin\n Assign(f,fo);\n Rewrite(f);\n If kt=true then writeln(f,'YES') else writeln(f,'NO');\n Close(f);\n End;\nBegin\n docfile;\n xuly;\nEnd.\n"}, {"source_code": "Const Fi='';\n Fo='';\nVar f:text;\n n:longint;\n a,b,c:longint;\nProcedure docfile;\n Begin\n Assign(f,fi);Reset(f);\n Readln(f,n);\n Close(f);\n End;\nFunction kt:boolean;\n Begin\n For a:=0 to n div 1234567 do\n For b:=0 to n div 123456 do\n If (n-a*1234567 -b*123456) >0 then\n If (n-a*1234567 -b*123456) mod 1234 =0 then exit(true);\n exit(false);\n End;\nProcedure xuly;\n Begin\n Assign(f,fo);\n Rewrite(f);\n If kt=true then writeln(f,'YES') else writeln(f,'NO');\n Close(f);\n End;\nBegin\n docfile;\n xuly;\nEnd.\n"}, {"source_code": "var\n n, i, j, f : longint;\nbegin\n f := 0;\n readln(n);\n for i := 1 to n div 1234567 do\n for j := 1 to n div 123456 do\n if (n - (i * 1234567 + j * 123456) >= 0) and\n ((n - (i * 1234567 + j * 123456)) mod 1234 = 0) then f := 1;\n if f = 1 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000008;\n\tmaxN=108;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nProcedure Nhap;\nvar\n i,j,n,a,b,c,tg:longint;\nBegin\n readln(n);\n tg:=n;\n a:=1234567;\n b:=123456;\n c:=1234;\n\n while n>=a do\n begin\n n:=n-a;\n end;\n //writeln(n);\n while n>=b do\n n:=n-b;\n while n>=c do\n n:=n-c;\n if n=0 then writeln('YES')\n else writeln('NO');\nEnd;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nBEGIN\n\tOpenf;\n\tNhap;\n\tXuli;\n\tXuat;\n\tClosef;\nEND.\n\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n n:=n mod 1234567;\n if n>0 then n:=n mod 123456;\n if n>0 then n:=n mod 1234;\n if n=0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var a,b,n,x,f,kk,aa,otv,i1,i2,i3:longint;\nbegin\nreadlN(n);\nfor i1:=0 to 1000 do\nfor i2:=0 to 100 do\nfor i3:=0 to 100 do\nif (i3*1234567+i2*123456+i1*1234=n) then begin writelN('YES');halt;end;\nwritelN('NO');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar a, b, c, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n for a:=1 to n div 1234567 do\n for b:=1 to (n-a*1234567) div 123456 do\n if (n-a*1234567-b*123456) mod 1234 = 0 then\n begin\n writeln('YES');\n halt;\n end;\n writeln('NO');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\n os,r,t,y,a,b,c,n,i,j,q:longint;\n const h:longint=1234567;\n const bu:longint=1234;\n const k:longint=123456;\nbegin\n readln(N);\n a:=n div h;\n n:=n mod h;\n\n b:=n div k;\n n:=n mod k;\n\n c:=n div bu;\n n:=n mod bu;\n\n if n=0 then\n writeln('YES') else writeln('NO');\n\nend.\n"}, {"source_code": " \n const eps=0.000000000001; besk1=8000000000000000000; nn=200000;\n modul=1000000007;\n label 1,2;\n type\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ii,jj,n,qq,xx,q,pos,left,right,amax,ost,h,tt,t1,pp,p,aa,bb,cc,kk,dist,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,s1,s2,m,s,cen,t2,i1,besk:int64;\n mask,newug,ugol,newdl,dloch,dugol,ist,jst,ifin,jfin,newnapx,newnapy,napx,napy,step, k,i,j:longint;\n prmax,v,aaa,bbb,ccc:extended; hhh:zap;\n dl,ochnewi,ochnewj,xxx,yyy,ochi,ochj,c,y,z,newoch,och,x,aold,b,a:array[-100000..2000000] of int64;\n stpr,stoim,blup,bldown, blright, blleft, ppole,vol:array[-10..1200,-10..1200] of int64;\n marked:array[-10..1100,-10..1100] of boolean;\n sss, ss1,ss2:string;\n sa,sb,pra,prb,suma,sumb,ota,otb,mmax,mmin,smax,smin:array[-100..200000] of extended;\n fl:array[0..200] of boolean;\n ss: array[-10..100000] of string;ch3,ch,ch1,ch2:char;\n razl:array[0..300000,0..18] of integer;\n pr:array[-10..300,-10..300] of extended;\n ddmax,ddmin :array[-1..300000,-1..20] of extended;\n pole :array [-10..2000] of char;\n maxpr:array[0..nn] of string;\n str:array[0..nn] of string;\n tt1,tt2,disk,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\nreadln(n);\n for i:=1 to 1000 do for j:=1 to 10000 do\n\n begin\n ii:=i; jj:=j;\n t:=n-ii*1234567-jj*123456;\n if (t>=0) and(t mod 1234=0) then flag:=true;\n\n end;\n\n if flag then write('YES') else write('NO');\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "var a,b,c,f,n,i,j,l,m:longint; p:array [1..1000000] of longint;\nbegin\n {assign (input,'input.txt'); reset (input);\n assign (output,'output.txt'); rewrite (output); }\n readln (n);\n f:=0;\n a:=1234;\n b:=123456;\n c:=1234567;\n l:=1;\n if n mod a=0 then f:=1;\n if n mod b=0 then f:=1;\n if n mod c=0 then f:=1;\n if f=0 then\n begin\n i:=1;\n p[l]:=n;\n l:=l+1;\n if n>c then\nelse\nbegin\n while (f=0) and (i<=(n div c)) do\n begin\n m:=n-(c*i);\n if m mod a=0 then f:=1;\n if m mod b=0 then f:=1;\n p[l]:=m;\n l:=l+1;\n i:=i+1;\n end;\nend;\n l:=l-1;\n if f=0 then\n begin\n i:=1;\n while (f=0) and (i<=l) do\n begin\n j:=1;\n while (f=0) and (j<=(p[i] div b)) do\n begin\n m:=p[i]-b*j;\n if m mod a=0 then f:=1;\n j:=j+1;\n end;\n i:=i+1;\n end;\n end;\n end;\n //if f=1 then writeln ('YES',' ',m,' ',l,' ',i-1,' ',p[i-1]) else writeln ('NO');\n if f=1 then write ('YES') else write ('NO');\nend.\n"}, {"source_code": "var a,b,c,f,n,i,j,l,m:longint; p:array [1..1000000] of longint;\nbegin\n {assign (input,'input.txt'); reset (input);\n assign (output,'output.txt'); rewrite (output); }\n readln (n);\n f:=0;\n a:=1234;\n b:=123456;\n c:=1234567;\n l:=1;\n if n mod a=0 then f:=1;\n if n mod b=0 then f:=1;\n if n mod c=0 then f:=1;\n if f=0 then\n begin\n i:=1;\n if n=1234)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var n,i,i1,i2,i3,n1,n2,n3:longint;\n ans:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to n1 do\nfor i2:=1 to n2 do\nif (n-i1*1234567-i2*123456) mod 1234=0 then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var i,i1,i2,i3,n1,n2,n3:longint;\n ans,n:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to 900 do\nfor i2:=1 to 9000 do\nif (i1*1234567+i2*123456<999999999) then\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=0)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var n,i,i1,i2,i3,n1,n2,n3:longint;\n ans:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to n1 do\nfor i2:=1 to n2 do\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=1234)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var i,i1,i2,i3,n1,n2,n3:longint;\n ans,n:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to n1 do\nfor i2:=1 to n2 do\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=1234)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var i,i1,i2,i3,n1,n2,n3:longint;\n ans,n:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to 900 do\nfor i2:=1 to 9000 do\nif (i1*1234567+i2*123456<999999999) then\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=1234)) then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var i,i1,i2,i3,n1,n2,n3:longint;\n ans,n:int64;\n a:array[1..100000] of longint;\nbegin\nread(n);\nn1:=n div 1234567+1;\nn2:=n div 123456+1;\nn3:=n div 1234+1;\nfor i1:=1 to 900 do\nfor i2:=1 to 9000 do\nif (i1*1234567+i2*123456<999999999) then\nif (((n-i1*1234567-i2*123456) div 1234)*1234+i1*1234567+i2*123456=n) and ((n-i1*1234567-i2*123456) mod 1234=0) and ((n-i1*1234567-i2*123456>=1234)) then begin write('YES',' ',i1,' ',i2,' ',n-i1*1234567-i2*123456); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var\n a, b, c: LongInt;\n n: Int64;\n \nbegin\n Read (n);\n \n for a:= 0 to n div 1234567 + 1 do\n for b:= 0 to (n - a * 1234567) div 123456 + 1 do\n if (n - a * 1234567 - b * 123456) mod 1234 = 0 then\n begin\n WriteLn ('YES');\n Exit\n end;\n \n WriteLn ('NO')\nend."}, {"source_code": "var\n a, b, c: LongInt;\n n: Int64;\n \nbegin\n Read (n);\n \n for a:= 0 to n div 1234567 + 1 do\n for b:= 0 to (n - a * 1234567) div 123456 + 1 do\n if ((n - a * 1234567 - b * 123456) mod 1234 = 0) and (n - a * 1234567 - b * 123456 >= 0) then\n begin\n WriteLn ('YES', ' ', a, ' ', b);\n Exit\n end;\n \n WriteLn ('NO')\nend."}, {"source_code": "var\n N,k1,k2,i,j:Longint;\n F:Boolean;\nbegin\n Readln(N);\n k1:=N div 1234567;\n F:=False;\n for i:=0 to k1 do\nbegin\n k2:=(N-i*1234567) div 123456;\n for j:=0 to k2 do\n if ((n-i*1234567-j*123456)>0) and ((n-i*1234567-j*123456) mod 1234=0) then begin\n F:=True;\n Break;\n end;\n if F then Break;\n end;\n if F then Writeln('YES')\n else Writeln('NO');\n end.\n\n"}, {"source_code": "var\n a,b,i,n,k,j:longint;\nbegin\n read(n);\n n:=n mod 1234567;\n if n=0 then begin writeln('NO');halt;end;\n n:=n mod 123456;\n if n=0 then begin writeln('NO');halt;end;\n n:=n mod 1234;\n if n=0 then writeln('YES') else writeln('NO');\nend. "}], "src_uid": "72d7e422a865cc1f85108500bdf2adf2"} {"source_code": "program Csgd;\nconst\n fi = '';\n fo = '';\n nmax = 50;\n dmax = 100;\ntype\n mon = record\n a, b: int64;\n c: longint;\n i : longint;\n end;\nvar\n a: array[1..nmax, 1..nmax, 0..dmax] of int64;\n t, p: array[1..nmax, 1..nmax, 0..dmax] of longint;\n b: array[1..nmax] of mon;\n n, m, k: longint;\n sum: int64;\n mi, ai: longint;\n f1, f2: text;\n\n procedure openf;\n begin\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n end;\n\n procedure closef;\n begin\n close(f1); close(f2);\n end;\n\n procedure input;\n var\n i : longint;\n begin\n readln(f1, n, m, k);\n for i := 1 to m do\n begin\n readln(f1, b[i].a, b[i].b, b[i].c);\n b[i].i := i;\n b[i].b := b[i].b - b[i].a;\n end;\n end;\n\n procedure output;\n var\n i, tmp : longint;\n begin\n if sum = 0 then\n write(f2, 'NO')\n else\n begin\n writeln(f2, 'YES');\n for i := 1 to n do\n begin\n writeln(f2, b[mi].i, ' ', ai + b[mi].a);\n tmp := t[i, mi, ai];\n ai := p[i, mi, ai];\n mi := tmp;\n end;\n end;\n end;\n\n procedure sort(i, j: longint);\n var\n l, r: longint;\n x: longint;\n y: mon;\n begin\n l := i;\n r := j;\n x := b[random(r - l + 1) + l].c;\n repeat\n while b[l].c < x do inc(l);\n while b[r].c > x do dec(r);\n if l <= r then\n begin\n if l < r then\n begin\n y := b[l];\n b[l] := b[r];\n b[r] := y;\n end;\n inc(l);\n dec(r);\n end;\n until l > r;\n if l < j then sort(l, j);\n if i < r then sort(i, r);\n end;\n\n procedure process;\n var\n i, j, l, u, v: longint;\n ttt, tmp: int64;\n begin\n sort(1, m);\n for j := 1 to m do\n for l := 0 to b[j].b do\n a[n, j, l] := b[j].a + l;\n for i := n - 1 downto 1 do\n for j := m downto i do\n for l := 0 to b[j].b do\n begin\n tmp := 0;\n for u := m downto j + 1 do\n if b[j].c < b[u].c then\n begin\n ttt := (b[j].a + l) + k - (b[u].a);\n v := ttt;\n if (v >= 0) and (v <= b[u].b) and (tmp < a[i + 1, u, v]) then\n begin\n tmp := a[i + 1, u, v];\n t[i, j, l] := u;\n p[i, j, l] := v;\n end;\n ttt := (b[j].a + l) * k - (b[u].a);\n v := ttt;\n if (v >= 0) and (v <= b[u].b) and (tmp < a[i + 1, u, v]) then\n begin\n tmp := a[i + 1, u, v];\n t[i, j, l] := u;\n p[i, j, l] := v;\n end;\n end;\n if tmp > 0 then\n a[i, j, l] := tmp + b[j].a + l\n else\n a[i, j, l] := 0;\n end;\n sum := 0;\n for j := 1 to m do\n for l := 0 to b[j].b do\n if sum < a[1, j, l] then\n begin\n sum := a[1, j, l];\n mi := j;\n ai := l;\n end;\n end;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n", "positive_code": [{"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..1000]of int64;\n pre,pp:array[0..50,0..50,0..1000]of longint;\n a,b,c,num,anss,anst:array[0..500]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);num[i]:=i;\n end;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if c[i]>c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:int64):int64;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p])\n then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=0 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx<=0 then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend."}, {"source_code": "type tracer = record\ni,j,k:longint;\npr:longint;\nEnd;\n\ntype sub = record\na:int64;\nb:int64;\nvt:longint;\nc:longint;\nEnd;\n\nvar f1,f2:text;\nA:array[1..50] of sub;\nF:array[1..50,1..50,0..100] of int64;\nTR:array[1..50,1..50,0..100] of tracer;\nm,n,sk,i:longint;\n\nProcedure Partition(L,H:longint);\nvar i,j:longint;\n Pivot:longint;\n tg:sub;\nBegin\n if L>=H then Exit;\n pivot := A[Random(H-L+1)+L].c;\n i:=L; j:=H;\n Repeat\n while A[i].cPivot do dec(j);\n if i<=j then\n Begin\n If ij;\n Partition(L,j); Partition(i,H);\nEnd;\n\nFunction MT(i,j,k,pr:longint):tracer;\nBegin\n MT.i:=i;MT.j:=j;MT.k:=k;MT.pr:=pr;\nEnd;\n\nProcedure trace(i,j,k:longint);\nbegin\n if tr[i,j,k].i<>0 then\n trace(tr[i,j,k].i,tr[i,j,k].j,tr[i,j,k].k);\n writeln(f2,A[Tr[i,j,k].pr].vt,' ',A[j].a+k);\nENd;\n\nProcedure Process;\nvar i,j,k,l:longint;\nv:int64;\ns:int64;\nres:int64;\nvti,vtj,vtk:longint;\nBegin\n For i:=1 to m do\n for j:=0 to a[i].b-a[i].a do\n Begin\n F[1,i,j]:=j+a[i].a;\n TR[1,i,j].pr:=i;\n End;\n\n for i:=2 to n do\n begin\n for j:=1 to m do\n for k:=0 to a[j].b-a[j].a do\n begin\n for l:=1 to j-1 do\n Begin\n if A[l].c0) and (F[i,j,k]0) and (F[i,j,k]0 then\n Begin\n writeln(f2,'YES');\n trace(vti,vtj,vtk);\n End\n else\n writeln(f2,'NO');\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m,sk);\n for i:=1 to m do begin readln(f1,A[i].a,a[i].b,a[i].c); a[i].vt:=i; End;\n Partition(1,m);\n Process;\n close(f1);\n close(f2);\nEnd.\n"}, {"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..1000]of int64;\n pre,pp:array[0..50,0..50,0..1000]of longint;\n a,b,c,num,anss,anst:array[0..500]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,min,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);min:=maxlongint;\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);\n if c[i]c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:int64):int64;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p])\n then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=0 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx<=0 then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend.\n"}, {"source_code": "type tracer = record\ni,j,k:longint;\npr:longint;\nEnd;\n\ntype sub = record\na:int64;\nb:int64;\nvt:longint;\nc:longint;\nEnd;\n\nvar f1,f2:text;\nA:array[1..50] of sub;\nF:array[1..50,1..50,0..100] of int64;\nTR:array[1..50,1..50,0..100] of tracer;\nm,n,sk,i:longint;\n\nProcedure Partition(L,H:longint);\nvar i,j:longint;\n Pivot:longint;\n tg:sub;\nBegin\n if L>=H then Exit;\n pivot := A[Random(H-L+1)+L].c;\n i:=L; j:=H;\n Repeat\n while A[i].cPivot do dec(j);\n if i<=j then\n Begin\n If ij;\n Partition(L,j); Partition(i,H);\nEnd;\n\nFunction MT(i,j,k,pr:longint):tracer;\nBegin\n MT.i:=i;MT.j:=j;MT.k:=k;MT.pr:=pr;\nEnd;\n\nProcedure trace(i,j,k:longint);\nbegin\n if tr[i,j,k].i<>0 then\n trace(tr[i,j,k].i,tr[i,j,k].j,tr[i,j,k].k);\n writeln(f2,A[Tr[i,j,k].pr].vt,' ',A[j].a+k);\nENd;\n\nProcedure Process;\nvar i,j,k,l:longint;\nv:int64;\ns:int64;\nres:int64;\nvti,vtj,vtk:longint;\nBegin\n For i:=1 to m do\n for j:=0 to a[i].b-a[i].a do\n Begin\n F[1,i,j]:=j+a[i].a;\n TR[1,i,j].pr:=i;\n End;\n\n for i:=2 to n do\n begin\n for j:=1 to m do\n for k:=0 to a[j].b-a[j].a do\n begin\n for l:=1 to j-1 do\n Begin\n if A[l].c0) and (F[i,j,k]0) and (F[i,j,k]0 then\n Begin\n writeln(f2,'YES');\n trace(vti,vtj,vtk);\n End\n else\n writeln(f2,'NO');\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m,sk);\n for i:=1 to m do begin readln(f1,A[i].a,a[i].b,a[i].c); a[i].vt:=i; End;\n Partition(1,m);\n Process;\n close(f1);\n close(f2);\nEnd.\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n MaxN = 55;\n\nType sub = record\n a,b,c,d : Int64;\nend;\n Arr1 = Array[0..MaxN+1,0..MaxN+1,0..105] Of Int64;\n Arr2 = Array[0..MaxN+1] Of sub;\n Arr3 = Array[0..MaxN+1,0..MaxN+1,0..105] Of sub;\n\nVar f : Arr1;\n a, b : Arr2;\n t : Arr3;\n n, m, k, i, x, y, j, l, vti, vtj : Longint;\n z1, z2, kq : Int64;\n\nProcedure sort(l,r : longint);\n Var i, j, p : longint;\n tmp : sub;\n Begin\n if l >= r then exit;\n i := l; j := r; p := a[(i+j)div 2].c;\n repeat\n while a[i].c < p do i := i+1;\n while a[j].c > p do j := j-1;\n if i <= j then\n begin\n tmp := a[i]; a[i] := a[j]; a[j] := tmp;\n i := i+1; j := j-1;\n end;\n until i > j;\n sort(l,j); sort(i,r);\n End;\n\nFunction max(a,b : int64) : int64;\n Begin\n if a > b then exit(a); exit(b);\n End;\n\nBegin\n assign(input,fi); reset(input);\n read(n,m,k);\n for i := 1 to m do\n begin\n read(a[i].a,a[i].b,a[i].c);\n a[i].d := i;\n end;\n close(input);\n ////////\n sort(1,m);\n for i := 1 to m do\n for x := 0 to a[i].b-a[i].a do\n f[1,i,x] := a[i].a+x;\n ////////\n for i := 2 to n do\n for j := 1 to m do\n begin\n for y := 0 to a[j].b-a[j].a do\n for x := 1 to j-1 do\n if a[x].c < a[j].c then\n begin\n z1 := y+a[j].a - k;\n if (y+a[j].a) mod k = 0 then\n z2 := (y+a[j].a) div k\n else z2 := -1;\n if (z1 >= a[x].a) and (z1 <= a[x].b)\n and(f[i-1,x,z1-a[x].a]<>0) then\n begin\n if f[i-1,x,z1-a[x].a]+y+a[j].a>f[i,j,y] then\n begin\n f[i,j,y] := f[i-1,x,z1-a[x].a]+y+a[j].a;\n t[i,j,y].a := x;\n t[i,j,y].b := z1-a[x].a;\n end;\n end;\n if (z2 >= a[x].a) and (z2 <= a[x].b)\n and(f[i-1,x,z2-a[x].a]<>0) then\n begin\n if f[i-1,x,z2-a[x].a]+y+a[j].a>f[i,j,y] then\n begin\n f[i,j,y] := f[i-1,x,z2-a[x].a]+y+a[j].a;\n t[i,j,y].a := x;\n t[i,j,y].b := z2-a[x].a;\n end;\n end;\n end;\n end;\n kq := 0;\n for i := 1 to m do\n for j := 0 to a[i].b-a[i].a do\n if f[n,i,j] > kq then\n begin\n kq := f[n,i,j];\n vti := i;\n vtj := j;\n end;\n if kq = 0 then\n begin\n writeln('NO'); halt;\n end;\n b[1].a := a[vti].d; b[1].b := vtj+a[vti].a;\n j := vtj;\n vtj := t[n,vti,vtj].b;\n vti := t[n,vti,j].a;\n l := 1;\n for i := n-1 downto 1 do\n begin\n inc(l);\n b[l].a := a[vti].d;\n b[l].b := vtj+a[vti].a;\n j := vtj;\n vtj := t[i,vti,vtj].b;\n vti := t[i,vti,j].a;\n end;\n writeln('YES');\n for i := l downto 1 do\n writeln(b[i].a,' ',b[i].b);\nEnd.\n"}, {"source_code": "const fi='';//119c.inp';\n fo='';//119c.out';\n\ntype rec=record\n day,subj,exer,posi:longint;\nend;\n rec1=record\n a,b:int64;\n c,cs:longint;\nend;\n\nvar f1:array[0..55,0..55,0..110] of int64;\n trace:array[0..55,0..55,0..110] of rec;\n n,m,k:longint;\n pt:array[1..55] of rec1;\n f:text;\n\n\nprocedure qs(dd,cc:longint);\nvar i,j:longint; kk,tg:rec1;\nbegin\n if dd>=cc then exit;\n i:=dd; j:=cc; kk:=pt[random(cc-dd+1)+dd];\n repeat\n begin\n while pt[i].ckk.c do dec(j);\n if i<=j then\n begin\n tG:=pt[i]; pt[i]:=pt[j]; pt[j]:=tg;\n inc(i); dec(j);\n end;\n end\n until i>j;\n qs(dd,j); qs(i,cc);\nend;\n\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n for i:=1 to m do\n with pt[i] do\n begin\n readln(f,a,b,c);\n cs:=i;\n end;\n qs(1,m);\n close(f);\nend;\n\n\nprocedure work;\nvar i,j,kk,l:longint; none:rec; sl,tg:int64;\nbegin\n none.day:=-1; none.subj:=-1; none.exer:=-1; //none.posi:=-1;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n begin\n f1[1,i,j]:=pt[i].a+j;\n trace[1,i,j]:=none;\n trace[1,i,j].posi:=-1;//pt[i].cs;\n end;\n for i:=2 to n do\n for j:=1 to m do\n for kk:= 0 to pt[j].b-pt[j].a do\n begin\n sl:=pt[j].a+kk;\n if sl mod k =0 then\n for l:=1 to j-1 do\n if (pt[j].c>pt[l].c) and (pt[l].a<=sl div k) and (pt[l].b>=sl div k) then\n begin\n tg:=f1[i-1,l,sl div k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl>f1[i,j,kk] then\n begin\n f1[i,j,kk]:=tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:= sl div k-pt[l].a;\n trace[i,j,kk].posi:=pt[l].cs;\n // if trace[i,j,kk].posi=0 then\n // writeln(f,i,' ',j,' ',kk);\n end;\n end;\n if sl>=k then\n for l:=1 to j-1 do\n if (pt[j].c>pt[l].c) and (pt[l].a<=sl-k) and (pt[l].b>=sl-k) then\n begin\n tg:=f1[i-1,l,sl-k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl> f1[i,j,kk] then\n begin\n f1[i,j,kk] := tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:=sl-k- pt[l].a;\n trace[i,j,kk].posi:=pt[l].cs;\n //if trace[i,j,kk].posi =0 then\n // writeln(f,i,' ',j,' ',kk);\n end;\n end;\n end;\nend;\n\n\nprocedure truy_vet(x:rec);\nbegin\n\n if (trace[x.day,x.subj,x.exer].day<>-1)\n // and (trace[x.day,x.subj,x.exer].day<>0)\n then\n truy_vet(trace[x.day,x.subj,x.exer]);\n writeln(f,x.posi,' ',pt[x.subj].a+x.exer);\n //if x.posi=0 then writeln(f,x.day,' ',x.subj,' ',x.exer,' ',-1);\nend;\n\n\nprocedure inkq;\nvar i,j:longint; res:int64; re:rec;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n work;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n if f1[n,i,j]>res then\n begin\n res:=f1[n,i,j];\n re.day:=n; re.subj:=i; re.exer:=j; re.posi:=pt[i].cs;\n end;\n // work;\n if res=0 then writeln(f,'NO')\n else\n begin\n //work;\n writeln(f,'YES');\n truy_vet(re);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n // work;\n inkq;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n max_n = 50;\n max_m = 50;\n\nvar\n a, b : array[0..max_m + 1] of int64;\n c, num : array[0..max_m + 1] of integer;\n an : array[0..max_n + 1, 1..2] of int64;\n d : array[0..max_m + 1, 0..100, 0..max_n + 1] of int64;\n ei, es : array[0..max_m + 1, 0..100, 0..max_n + 1] of integer;\n i, j, t, s, n, m, k, ci, cs, ansi, anss : integer;\n x, ans : int64;\n\n\nprocedure swap(var a, b : integer);\nvar\n w : integer;\nbegin\n w := a;\n a := b;\n b := w;\nend;\n\nprocedure swap64(var a, b : int64);\nvar\n w : int64;\nbegin\n w := a;\n a := b;\n b := w;\nend;\n\nprocedure sort;\nvar\n i, j : integer;\nbegin\n for i := 1 to m - 1 do\n for j := 1 to m - i do\n if (c[j] > c[j + 1]) then begin\n swap(c[j], c[j + 1]);\n swap(num[j], num[j + 1]);\n swap64(a[j], a[j + 1]);\n swap64(b[j], b[j + 1]);\n end;\nend;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n\n read(n, m, k);\n fillchar(d, sizeof(d), 0);\n fillchar(ei, sizeof(ei), 0);\n fillchar(es, sizeof(es), 0);\n for i := 1 to m do begin\n read(a[i], b[i], c[i]);\n num[i] := i;\n end;\n sort;\n\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n d[i, j, 1] := a[i] + j;\n\n for t := 2 to n do begin\n for i := 1 to m do\n for j := 1 to i - 1 do begin\n if c[i] <= c[j] then\n continue;\n for s := 0 to b[j] - a[j] do begin\n if d[j, s, t - 1] = 0 then\n continue;\n if (t = 2) and (i = 3) and (j = 2) then\n x := 0;\n x := (a[j] + s) * k;\n if (x >= a[i]) and (x <= b[i]) then begin\n if d[j, s, t - 1] + x > d[i, x - a[i], t] then begin\n d[i, x - a[i], t] := d[j, s, t - 1] + x;\n ei[i, x - a[i], t] := j;\n es[i, x - a[i], t] := s;\n end;\n end;\n x := (a[j] + s) + k;\n if (x >= a[i]) and (x <= b[i]) then begin\n if d[j, s, t - 1] + x > d[i, x - a[i], t] then begin\n d[i, x - a[i], t] := d[j, s, t - 1] + x;\n ei[i, x - a[i], t] := j;\n es[i, x - a[i], t] := s;\n end;\n end;\n end;\n end;\n end;\n\n ans := 0;\n for i := 1 to m do\n for s := 0 to b[i] - a[i] do\n if d[i, s, n] > ans then begin\n ans := d[i, s, n];\n ansi := i;\n anss := s;\n end;\n\n if ans = 0 then begin\n writeln('NO');\n halt(0);\n end;\n\n writeln('YES');\n for i := n downto 1 do begin\n an[i, 1] := num[ansi];\n an[i, 2] := a[ansi] + anss;\n ci := ei[ansi, anss, i];\n cs := es[ansi, anss, i];\n ansi := ci;\n anss := cs;\n end;\n\n for i := 1 to n do\n writeln(an[i, 1], ' ', an[i, 2]);\n\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "{$MODE DELPHI}\n{$R-,Q-,O+,S+}\nuses\n Math;\nvar\n a, b, c, num : array [1..1000] of int64;\n p, d, q : array [1..50, 0..100, 0..50] of int64;\n max, k, numb, qq, m, j, n : int64;\n i, l,ol, ii, jj : longint;\n ok : array [1..50, 0..100, 0..50] of boolean;\n used : array [1..100] of boolean;\nprocedure swap(var a, b : int64);\nvar\n c : int64;\nbegin\n c := a;\n a := b;\n b:= c;\nend;\nprocedure vos(j, i, k : int64);\nbegin\n if k < 0 then\n exit;\n vos(p[i, b[i] - j, k], q[i, b[i] - j, k], k - 1);\n writeln(num[i], ' ', j);\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n, m, k);\n for i := 1 to m do\n begin\n read(a[i], b[i], c[i]);\n num[i] := i;\n end;\n if m = 1 then\n begin\n writeln('YES');\n writeln(1, ' ', b[1]);\n halt;\n end;\n for i := 1 to m do\n for l := i + 1 to m do\n if c[i] > c[l] then\n begin\n swap(c[i], c[l]);\n swap(a[i], a[l]);\n swap(b[i], b[l]);\n swap(num[i], num[l]);\n end;\n for i := 1 to m do\n begin\n j := a[i];\n while j <= b[i] do\n begin\n d[i, b[i] - j, 0] := j;\n ok[i, b[i] - j, 0] := true;\n inc(j);\n end;\n end;\n Dec(n);\n for i := 2 to m do\n begin\n ol := min(n , i -1);\n for ii := 1 to ol do begin\n for jj := 1 to i - 1 do begin\n j := a[i];\n while j <= b[i] do\n begin\n if (j mod k = 0) and (a[jj] <= j div k) and (c[i] > c[jj]) and (b[jj] >= j div k) and ok[jj, b[jj] - (j div k), ii - 1] and (d[i, b[i] - j, ii] < d[jj, b[jj] - (j div k), ii - 1] + j) then\n begin\n d[i, b[i] - j, ii] := d[jj, b[jj] - (j div k), ii - 1] + j;\n q[i, b[i] - j, ii] := jj;\n p[i, b[i] - j, ii] := j div k;\n ok[i, b[i] - j, ii] := true;\n end;\n if (j - k >= a[jj]) and (j - k <= b[jj]) and (c[i] > c[jj]) and (d[i, b[i] - j, ii] < d[jj, b[jj] - (j - k), ii - 1] + j) and ok[jj, b[jj] - (j - k), ii - 1] then\n begin\n ok[i, b[i] - j, ii] := true;\n q[i, b[i] - j, ii] := jj;\n d[i, b[i] - j, ii] := d[jj, b[jj] - (j - k), ii - 1] + j;\n p[i, b[i] - j, ii] := j - k;\n end;\n inc(j);\n end;\n end;\n// d[i, b[i] - j, ii] := d[i, b[i] - j, ii] + j;\n end;\n end;\n max := 0;\n for i := 1 to m do\n begin\n j := a[i];\n while j <= b[i] do\n begin\n if (d[i, b[i] - j, n] > max) and ok[i, b[i] - j, n] then\n begin\n max := d[i, b[i] - j, n];\n numb := i;\n qq := j;\n end;\n inc(j);\n end;\n end;\n if max = 0 then\n writeln('NO')\n else\n begin\n writeln('YES');\n vos(qq, numb, n);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar\n idx1,idx,idy,z,l,x,i,j,n,m:integer;\n ans,s1,s2,s,k:int64;\n an1,a,b:array[1..101] of int64;\n c1,nn1,nn,c:array[1..101] of integer;\n cur,an:array[1..51,1..51,0..101] of int64;\n prevl,prevs:array[1..51,1..51,0..101] of integer;\n\n Procedure swap(var a,b:int64);\n var\n x:int64;\n begin\n x:=a;\n a:=b;\n b:=x;\n end;\n\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt');}\n\n readln(n,m,k);\n\n For i:=1 to m do readln(a[i],b[i],c[i]);\n For i:=1 to m do nn[i]:=i;\n\n For i:=2 to m do\n For j:=m downto i do If c[j-1]>c[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n\n\n Fillchar(prevs,sizeof(prevs),0);\n Fillchar(prevl,sizeof(prevl),0);\n Fillchar(cur,sizeof(cur),0);\n\n\n For i:=1 to n do\n For j:=1 to m do\n For z:=0 to 101 do an[i,j,z]:=-100000000000000000;\n\n For i:=1 to m do\n For j:=0 to b[i]-a[i] do\n begin\n prevs[1,i,j]:=-1;\n prevl[1,i,j]:=-1;\n an[1,i,j]:=a[i]+j;\n cur[1,i,j]:=a[i]+j;\n end;\n\n //For i:=1 to m do writeln(a[i],' ',b[i],' ',c[i],' ',nn[i]);\n\n For i:=2 to n do\n For j:=1 to m do\n For z:=0 to b[j]-a[j] do\n begin\n s:=a[j]+z;\n If s mod k=0 then s1:=s div k else s1:=-1;\n s2:=s-k;\n For l:=1 to j-1 do\n begin\n If (c[j]>c[l]) and ((s1>=a[l]) and (s1<=b[l])) and (an[i-1,l,s1-a[l]]<>-100000000000000000)\n and (an[i,j,z]c[l]) and ((s2>=a[l]) and (s2<=b[l])) and (an[i-1,l,s2-a[l]]<>-100000000000000000)\n and (an[i,j,z]ans then\n begin\n ans:=an[n,i,j];\n idx:=i;\n idy:=j;\n end;\n\n If ans=-100000000000000000 then writeln('NO') else\n begin\n writeln('YES');\n For i:=n downto 1 do\n begin\n nn1[i]:=nn[idx];\n c1[i]:=c[idx];\n an1[i]:=cur[i,idx,idy];\n idx1:=prevl[i,idx,idy];\n idy:=prevs[i,idx,idy];\n idx:=idx1;\n end;\n For i:=2 to n do\n For j:=n downto i do If c1[j-1]>c1[j] then\n begin\n swap(an1[j-1],an1[j]);\n x:=nn1[j-1];\n nn1[j-1]:=nn1[j];\n nn1[j]:=x;\n x:=c1[j-1];\n c1[j-1]:=c1[j];\n c1[j]:=x;\n end;\n For i:=1 to n do writeln(nn1[i],' ',an1[i]);\n end;\n\nend.\n"}, {"source_code": "const\n{ fi='edu.inp';\n fo='edu.out';}\n fi='';\n fo='';\n maxn=111;\n\nvar\n f:text;\n a,b,c,ind:array[0..maxn]of int64;\n t1,t2,fx:array[0..maxn,0..maxn,0..maxn]of int64;\n k1,k2:array[0..maxn]of int64;\n n,m,k:longint;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yc[i2] then\n begin\n tmp:=a[i]+t-1-k;\n if (a[i2]<=tmp) and (tmp<=b[i2]) then\n if fx[i2,j-1,tmp-a[i2]+1]<>0 then\n if fx[i,j,t]0 then\n if fx[i,j,t]=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n //assign(input,'input.txt');\n //assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i := 1 to m do\n kk[i].id := i;\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}, {"source_code": "type pp=record\n x,y:int64;\n end;\n\nvar n,m,x,y,i,j:longint;\n max,k,g,k1,k2,t:int64;\n a,b,c,d:array[0..51] of int64;\n v:array[0..51,0..51,0..101] of int64;\n w:array[0..51,0..51,0..101] of pp;\n\nprocedure sort(l,r: longint);\n var\n i,j: longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=c[(l+r) div 2];\n repeat\n while c[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n y:=d[i];\n d[i]:=d[j];\n d[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lb[i] then break;\n v[1,i,j]:=a[i]+j;\n end;\n\n for i:=1 to n-1 do\n for x:=1 to m-1 do\n for y:=x+1 to m do\n for j:=0 to 100 do\n begin\n\n if v[i,x,j]=0 then continue;\n if c[y]<=c[x] then continue;\n\n t:=v[i,x,j];\n\n g:=a[x]+int64(j);\n\n k1:=g+k;\n k2:=g*k;\n\n if (a[y]<=k1) and\n (k1<=b[y]) then begin\n if k1+t>v[i+1,y,k1-a[y]] then begin\n v[i+1,y,k1-a[y]]:=k1+t;\n w[i+1,y,k1-a[y]].x:=x;\n w[i+1,y,k1-a[y]].y:=j;\n end;\n end;\n if (a[y]<=k2) and\n (k2<=b[y]) then begin\n if k2+t>v[i+1,y,k2-a[y]] then begin\n v[i+1,y,k2-a[y]]:=k2+t;\n w[i+1,y,k2-a[y]].x:=x;\n w[i+1,y,k2-a[y]].y:=j;\n end;\n end;\n end;\n\n max:=0;\n for i:=1 to m do\n for j:=0 to 100 do\n if v[n,i,j]>max then begin\n max:=v[n,i,j];\n x:=i;\n y:=j;\n end;\n\n if max=0 then begin\n writeln('NO');\n halt;\n end;\n\n writeln('YES');\n tt(n,x,y);\n end."}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nconst inf = round(1e18);\nvar\n ki,kk,n,m,u,i,j,k,ni,z,q: longint;\n max,ft,tmp,x,y: int64;\n cnt,a,b: array [0..101] of int64;\n ans,c,d: array [0..101] of longint;\n ok: array [0..51,0..101,0..51,0..101] of boolean;\n f: array [0..51,0..51,0..101] of int64;\n fz,fq: array [0..51,0..51,0..101] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m,u);\n for i:=1 to m do read(a[i],b[i],c[i]);\n for i:=1 to m do d[i]:=i;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if c[i] > c[j] then\n begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n tmp:=b[i]; b[i]:=b[j]; b[j]:=tmp;\n tmp:=c[i]; c[i]:=c[j]; c[j]:=tmp;\n tmp:=d[i]; d[i]:=d[j]; d[j]:=tmp;\n end;\n for i:=1 to m do\n for j:=1 to n do\n for k:=0 to b[i]-a[i] do f[i,j,k]:=-inf;\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do f[i,1,k]:=a[i]+k;\n fillchar(ok,sizeof(ok),False);\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do\n for j:=i+1 to m do\n for q:=0 to b[j]-a[j] do\n begin\n x:=a[i]+k;\n y:=a[j]+q;\n if (y = x+u) or (y = x*u) then ok[j,q,i,k]:=True;\n end;\n for i:=2 to m do\n for j:=2 to n do\n if j > i then continue else\n for k:=0 to b[i]-a[i] do\n for z:=1 to i-1 do\n if c[i] > c[z] then\n for q:=0 to b[z]-a[z] do\n if ok[i,k,z,q] and (f[z,j-1,q] >= 0) then\n begin\n ft:=f[z,j-1,q]+a[i]+k;\n if ft > f[i,j,k] then\n begin\n f[i,j,k]:=ft;\n fz[i,j,k]:=z;\n fq[i,j,k]:=q;\n end;\n end;\n max:=-1;\n ki:=0; kk:=0;\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do\n if f[i,n,k] > max then\n begin\n max:=f[i,n,k];\n ki:=i;\n kk:=k;\n end;\n if max < 0 then writeln('NO') else\n begin\n writeln('YES');\n i:=ki; k:=kk;\n for j:=n downto 1 do\n begin\n ans[j]:=d[i];\n cnt[j]:=a[i]+k;\n if j = 1 then break;\n ni:=fz[i,j,k];\n k:=fq[i,j,k];\n i:=ni;\n end;\n for j:=1 to n do writeln(ans[j],' ',cnt[j]);\n end;\n close(input);\n close(output);\nend."}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nconst inf = round(1e18);\nvar\n ki,kk,n,m,u,i,j,k,ni,z,q: longint;\n max,ft,tmp,x,y: int64;\n cnt,a,b: array [0..101] of int64;\n ans,c,d: array [0..101] of longint;\n ok: array [0..51,0..101,0..51,0..101] of boolean;\n f: array [0..51,0..51,0..101] of int64;\n fz,fq: array [0..51,0..51,0..101] of longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m,u);\n for i:=1 to m do read(a[i],b[i],c[i]);\n for i:=1 to m do d[i]:=i;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if c[i] > c[j] then\n begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n tmp:=b[i]; b[i]:=b[j]; b[j]:=tmp;\n tmp:=c[i]; c[i]:=c[j]; c[j]:=tmp;\n tmp:=d[i]; d[i]:=d[j]; d[j]:=tmp;\n end;\n for i:=1 to m do\n for j:=1 to n do\n for k:=0 to b[i]-a[i] do f[i,j,k]:=-inf;\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do f[i,1,k]:=a[i]+k;\n fillchar(ok,sizeof(ok),False);\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do\n for j:=i+1 to m do\n for q:=0 to b[j]-a[j] do\n begin\n x:=a[i]+k;\n y:=a[j]+q;\n if (y = x+u) or (y = x*u) then ok[j,q,i,k]:=True;\n end;\n for i:=2 to m do\n for j:=2 to n do\n if j > i then continue else\n for k:=0 to b[i]-a[i] do\n for z:=1 to i-1 do\n if c[i] > c[z] then\n for q:=0 to b[z]-a[z] do\n if ok[i,k,z,q] and (f[z,j-1,q] >= 0) then\n begin\n ft:=f[z,j-1,q]+a[i]+k;\n if ft > f[i,j,k] then\n begin\n f[i,j,k]:=ft;\n fz[i,j,k]:=z;\n fq[i,j,k]:=q;\n end;\n end;\n max:=-1;\n ki:=0; kk:=0;\n for i:=1 to m do\n for k:=0 to b[i]-a[i] do\n if f[i,n,k] > max then\n begin\n max:=f[i,n,k];\n ki:=i;\n kk:=k;\n end;\n if max < 0 then writeln('NO') else\n begin\n writeln('YES');\n i:=ki; k:=kk;\n for j:=n downto 1 do\n begin\n ans[j]:=d[i];\n cnt[j]:=a[i]+k;\n if j = 1 then break;\n ni:=fz[i,j,k];\n k:=fq[i,j,k];\n i:=ni;\n end;\n for j:=1 to n do writeln(ans[j],' ',cnt[j]);\n end;\n close(input);\n close(output);\nend."}, {"source_code": "program reform;\n\nuses\n Math;\n\nconst\n maxn = 51;\n maxk = 101;\n\ntype\n st = record\n a, b, c, id: int64;\n end;\n anst = record\n num, sb: int64;\n end;\n prevt = record\n last, temp: longint;\n end;\n\nvar\n subj: array [1..maxn] of st;\n ans: array [1..maxn] of anst;\n dp: array [0..maxn, 0..maxk, 0..maxn] of int64;\n prev: array [0..maxn, 0..maxk, 0..maxn] of prevt;\n i, j, z, n, m, k, first, second, newfirst, newsecond, last, t: longint;\n temp: int64;\n\nprocedure swap(var a, b: st);\nvar\n temp: st;\nbegin\n temp := a;\n a := b;\n b := temp;\nend;\n\nfunction less(a, b: st): boolean;\nbegin\n if a.c < b.c then\n less := true\n else\n less := false;\nend;\n\nprocedure qsort(low, high: longint);\nvar\n i, j: longint;\n m: st;\nbegin\n i := low; j := high;\n m := subj[i + random(j - i)];\n repeat\n while less(subj[i], m) do\n inc(i);\n while less(m, subj[j]) do\n dec(j);\n if (i <= j) then begin\n swap(subj[i], subj[j]);\n inc(i); dec(j);\n end;\n until (i > j);\n if (low < j) then qsort(low, j);\n if (i < high) then qsort(i, high);\nend;\n\nbegin\n //reset(input, 'reform.in');\n //rewrite(output, 'reform.out');\n readln(n, m, k);\n for i := 1 to m do begin\n readln(subj[i].a, subj[i].b, subj[i].c);\n subj[i].id := i;\n end;\n qsort(1, m);\n first := 0; second := 0; dp[0, 0, n] := -1;\n for i := 1 to m do\n for j := 0 to (subj[i].b - subj[i].a) do begin\n dp[i, j, 1] := subj[i].a + j;\n for z := 2 to n do begin\n dp[i, j, z] := -1;\n for last := i - 1 downto 1 do\n if (subj[last].c < subj[i].c) then\n for t := 0 to 1 do begin\n temp := subj[i].a + j;\n if (t = 0) and (temp mod k = 0) then begin\n temp := (temp div k) - subj[last].a;\n if (temp >= 0) and (temp <= subj[last].b - subj[last].a) and (dp[last, temp, z - 1] <> -1) and (dp[last, temp, z - 1] + subj[i].a + j > dp[i, j, z]) then begin\n dp[i, j, z] := dp[last, temp, z - 1] + subj[i].a + j;\n prev[i, j, z].last := last;\n prev[i, j, z].temp := temp;\n end;\n end\n else\n if (t = 1) and (temp >= k) then begin\n temp := temp - k - subj[last].a;\n if (temp >= 0) and (temp <= subj[last].b - subj[last].a) and (dp[last, temp, z - 1] <> -1) and (dp[last, temp, z - 1] + subj[i].a + j > dp[i, j, z]) then begin\n dp[i, j, z] := dp[last, temp, z - 1] + subj[i].a + j;\n prev[i, j, z].last := last;\n prev[i, j, z].temp := temp;\n end;\n end;\n end;\n end;\n if (dp[i, j, n] > dp[first, second, n]) then begin\n first := i;\n second := j;\n end;\n end;\n if (dp[first, second, n] = -1) then begin\n writeln('NO');\n halt(0);\n end;\n for i := n downto 1 do begin\n ans[i].num := subj[first].id;\n ans[i].sb := subj[first].a + second;\n newfirst := prev[first, second, i].last;\n newsecond := prev[first, second, i].temp;\n first := newfirst; second := newsecond;\n end;\n writeln('YES');\n for i := 1 to n do\n writeln(ans[i].num, ' ', ans[i].sb);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-} {$R+} {$Q+}\n\nuses\n SysUtils,\n Math;\n\nconst\n CLen = 101;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n mx, d, p: array [1..clen, 1..clen, 0..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val, mxx: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, m, k);\n for i := 1 to m do\n read(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 0 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n mx[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n mx[1, i, j] := j + a[i];\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n val := x + a[j] + k - a[y];\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) and (mx[i-1, j, x] + x + a[j] + k > mx[i, y, val]) then\n begin\n d[i, y, val] := 1;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i-1, j, x] + x + a[j] + k;\n end;\n val := (x + a[j]) * k - a[y];\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) and (mx[i-1, j, x] + (x + a[j]) * k > mx[i, y, val]) then\n begin\n d[i, y, val] := 2;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i-1, j, x] + (x + a[j]) * k;\n end;\n end;\n mxx := -1;\n for j := 1 to m do\n for x := 0 to clen do\n mxx := max(mxx, mx[n, j, x]);\n for j := 1 to m do\n for x := 0 to clen do\n if (mxx <> -1) and (mx[n, j, x] = mxx) then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n\n"}, {"source_code": "uses math;\n\nconst maxn=110;\n fi='';//'v.inp';\n fo='';//'v.out';\n no='NO';\n yes='YES';\n\nvar n,m,k,i1,j1,t1,dem,i,j,t,jj,tt1,tt2:longint;\n a,b,c:Array[0..maxn]of int64;\n ca1,ca2,res,cal:int64;\n re1,re2:Array[0..maxn]of longint;\n cl:Array[0..maxn]of longint;\n ii,jj1,tt:array[0..maxn div 2,0..maxn div 2,0..maxn]of longint;\n f:Array[0..maxn div 2,0..maxn div 2,0..maxn]of int64;\n f1,f2:text;\n\nBEGIN\n assign(f1,fi);reset(f1);\n assign(f2,fo);rewrite(f2);\n readln(f1,n,m,k);\n for i:=1 to m do\n begin\n readln(f1,a[i],b[i],c[i]);\n cl[i]:=b[i]-a[i];\n end;\n\n res:=0;\n for i:=1 to m do\n for t:=0 to cl[i] do begin\n f[1][i][t] := a[i]+t;\n if n=1 then\n begin\n if resc[jj] then\n begin\n for t:=0 to cl[j] do\n begin\n cal:=a[j] + t;\n ca1:=cal - k;\n if (ca1>=a[jj]) and (ca1<=b[jj]) then begin\n if f[i-1][jj][ca1-a[jj]] <>0 then\n if f[i][j][t]=a[jj]) and (ca2<=b[jj]) then\n if f[i-1][jj][ca2-a[jj]] <>0 then\n if f[i][j][t]1 do\n begin\n inc(dem);\n re1[dem]:=j1;\n re2[dem]:=t1;\n tt1:=jj1[i1][j1][t1];\n tt2:=tt[i1][j1][t1];\n j1:=tt1;t1:=tt2;\n dec(i1);\n end;\n inc(dem);\n re1[dem]:=j1;re2[dem]:=t1;\n for i:=dem downto 1 do\n writeln(f2,re1[i],' ',re2[i] + a[re1[i]]);\n end;\n close(f1);close(f2);\nEND.\n\n"}, {"source_code": "Program C_REFORM;\nConst MaxN=50;\n MaxV=100;\nType subject=Record a,b:qword; stt,c,v:Longint End;\nVar l:array[1..MaxN,1..MaxN,0..MaxV] of qword;\n trace:array[1..MaxN,1..MaxN,0..MaxV] of Record a,b:Longint End;\n a:array[1..MaxN] of subject;\n n,m,k:Longint;\nProcedure Input;\nVar f:Text;\n i:Longint;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,n,m,k);\n For i:=1 to m do\n Begin\n Readln(f,a[i].a,a[i].b,a[i].c);\n a[i].v:=a[i].b-a[i].a;\n a[i].stt:=i;\n End;\n Close(f);\nEnd;\n\nProcedure Swap(var a,b:subject);\nVar t:subject; Begin t:=a; a:=b; b:=t End;\n\nProcedure QuickSort(l,r:Longint);\nVar i,j,k:Longint;\nBegin\n If l>=r then exit;\n i:=l; j:=r;\n k:=a[random(r-l+1)+l].c;\n Repeat\n While a[i].ck do Dec(j);\n If i<=j then\n Begin\n If ij;\n QuickSOrt(l,j); QUickSort(i,r)\nEnd;\n\nProcedure Optimize;\nVar i,j,z,x,h:Longint;\n t:qword;\nBegin\n For j:=1 to m-n+1 do\n For z:=0 to a[j].v do\n l[1,j,z]:=z+a[j].a;\n\n For i:=1 to n-1 do\n For j:=i to m-(n-i) do\n For z:=0 to a[j].v do\n If l[i,j,z]<>0 then\n For h:=1 to 2 do\n Begin\n If h=1 then t:=(z+a[j].a)*k else t:=(z+a[j].a)+k;\n For x:=j+1 to m-(n-i)+1 do\n If (a[x].c>a[j].c) and (a[x].a<=t) and (t<=a[x].b)\n and (l[i+1,x,t-a[x].a]0 do\n Begin\n ds[i].stt:=a[x].stt; ds[i].v:=a[x].a+y;\n j:=trace[i,x,y].a; z:=trace[i,x,y].b;\n x:=j; y:=z;\n Dec(i);\n End;\n Writeln('YES');\n For i:=1 to n do Writeln(ds[i].stt,' ',ds[i].v);\nEnd;\n\nBEGIN\n Input;\n QuickSort(1,m);\n Optimize;\n Output;\nEND."}, {"source_code": "var njj,jj,n,m,k,i,j,l,ll:longint;\nnlj,ans,lj,ra,pra,tt:int64;\na1,a2,a,b,c:array[0..100]of int64;\np1,p2,q:array[0..51,0..51,0..101]of int64;\n begin\n read(n,m,k);\n for i:=1 to m do\n read(a[i],b[i],c[i]);\n\n for i:=1 to n do\n for j:=1 to m do\n for ll:=0 to 101 do\n q[i,j,ll]:=-1000000000000000000;\n for j:=1 to m do\n begin\n tt:=b[j]-a[j];\n for l:=0 to tt do\n q[1,j,l]:=l+a[j];\n end;\n\n for i:=2 to n do\n begin\n for j:=1 to m do\n begin\n for l:=1 to m do\n if c[l]=k then\n begin\n pra:=ra-k;\n if (a[l]<=pra)and(pra<=b[l]) then\n if q[i-1,l,pra-a[l]]+ra>q[i,j,ll] then\n begin\n q[i,j,ll]:=q[i-1,l,pra-a[l]]+ra;\n p1[i,j,ll]:=l;\n p2[i,j,ll]:=pra-a[l];\n end;\n end;\n if ra mod k=0 then\n begin\n pra:=ra div k;\n if (a[l]<=pra)and(pra<=b[l]) then\n if q[i-1,l,pra-a[l]]+ra>q[i,j,ll] then\n begin\n q[i,j,ll]:=q[i-1,l,pra-a[l]]+ra;\n p1[i,j,ll]:=l;\n p2[i,j,ll]:=pra-a[l];\n end;\n end;\n if q[i,j,ll]<0 then q[i,j,ll]:=-1000000000000000000;\n end;\n end;\n end;\n end;\n ans:=-1000000000000000000;\n for j:=1 to m do\n begin\n tt:=b[j]-a[j];\n for ll:=0 to tt do\n if q[n,j,ll]>ans then\n begin\n ans:=q[n,j,ll];\n jj:=j;\n lj:=ll;\n end;\n end;\n\n if ans<0 then writeln('NO')\n else\n begin\n writeln('YES');\n for i:=n downto 1 do\n begin\n a1[i]:=jj;\n a2[i]:=lj+a[jj];\n if i=1 then break;\n njj:=p1[i,jj,lj];\n nlj:=p2[i,jj,lj];\n jj:=njj;\n lj:=nlj;\n end;\n for i:=1 to n do writeln(a1[i],' ',a2[i]);\n\n end;\n\n end."}, {"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..1000]of int64;\n pre,pp:array[0..50,0..50,0..1000]of longint;\n a,b,c,num,anss,anst:array[0..500]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,min,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);min:=maxlongint;\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);\n if c[i]c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:int64):int64;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p])\n then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=0 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx<=0 then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend."}, {"source_code": "Program Education_Reform;\nvar i,j,z,x,n,m,nx,ny:longint;\n tmp,k:int64;\n s,t,a,id,ans,ans2:array[1..100]of int64;\n pre,pre2:array[1..50,0..50,0..100]of longint;\n f:array[1..50,0..50,0..100]of int64;\n//===============================================================\nprocedure qsort(left,right:longint);\nvar l,r,mid,k:longint;\nbegin\n l:=left;r:=right;\n mid:=a[(l+r)shr 1];\n repeat\n while a[l]mid do dec(r);\n if l<=r then\n begin\n tmp:=a[l];a[l]:=a[r];a[r]:=tmp;\n tmp:=s[l];s[l]:=s[r];s[r]:=tmp;\n tmp:=t[l];t[l]:=t[r];t[r]:=tmp;\n tmp:=id[l];id[l]:=id[r];id[r]:=tmp;\n inc(l);dec(r);\n end;\n until l>r;\n if leftf[1,i,j] then\n f[1,i,j]:=int64(s[i]+j);\n for i:=2 to n do\n for j:=i to m do\n for z:=1 to j-1 do\n for x:=0 to t[z]-s[z] do\n if (f[i-1,z,x]>0)and(a[j]>a[z]) then\n begin\n tmp:=s[z]+int64(x)+k;\n if (s[j]<=tmp)and(tmp<=t[j])\n and(f[i-1,z,x]+tmp>f[i,j,tmp-s[j]])then\n begin\n f[i,j,tmp-s[j]]:=f[i-1,z,x]+tmp;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n tmp:=int64(s[z]+x)*k;\n if (s[j]<=tmp)and(tmp<=t[j])\n and(f[i-1,z,x]+tmp>f[i,j,tmp-s[j]])then\n begin\n f[i,j,tmp-s[j]]:=f[i-1,z,x]+tmp;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n end;\n tmp:=0;\n for z:=n to m do\n for x:=0 to t[z]-s[z] do\n if f[n,z,x]>tmp then\n begin\n tmp:=f[n,z,x];\n nx:=z;ny:=x;\n end;\n\n if tmp>0 then\n begin\n writeln('YES');\n Print(nx,ny);\n halt;\n end;\n writeln('NO');\nend;\n//===============================================================\nbegin\n readln(n,m,k);\n for i:=1 to m do\n begin\n readln(s[i],t[i],a[i]);\n id[i]:=i;\n end;\n qsort(1,m);\n DP;\nend.\n"}, {"source_code": "{$r+,i+,q+,s+,o-}\nconst maxn = 5100;\nconst maxm = 51;\n\nvar\n f:array[0..maxm, 0..maxm, 0..maxn] of int64;\n pi,pj,pk:array[0..maxm, 0..maxm, 0..maxn] of word;\n ax,ay,a,b,c,w:array[0..maxn] of int64;\n edn,beg:array[0..maxn] of longint;\n qk,nrj,nrk,ri,rj,rk,q,k,wn,n,m,i,j:longint;\n jj,max,me,kk:int64;\n\nprocedure qs(const l, r:longint);\nvar\n i,j:longint;\n x,y:int64;\nbegin\n i:=l; j:=r; x:=w[(l+r) shr 1];\n repeat\n while x>w[i] do inc(i);\n while x nk do ;\n if f[ni, nj, qk]0 then\n begin\n me:=w[k];\n for q:=1 to m do if c[q]>c[j] then\n begin\n if (a[q]<=me+kk)and(me+kk<=b[q]) then upd(i+1, q, int64(beg[q])+me+kk-a[q], me+kk, f[i, j, k]+me+kk);\n if (a[q]<=me*kk)and(me*kk<=b[q]) then upd(i+1, q, int64(beg[q])+me*kk-a[q], me*kk, f[i, j, k]+me*kk);\n end;\n end;\n rk:=-1;\n max:=-1;\n for j:=1 to m do for k:=1 to wn do if (f[n, j, k]>0)and(f[n, j, k] > max) then\n begin\n max:=f[n, j, k];\n ri:=n;\n rj:=j;\n rk:=k;\n end;\n if rk = -1 then\n begin\n writeln('NO');\n close(output);\n halt;\n end;\n writeln('YES');\n for i:=n downto 1 do\n begin\n ax[i]:=rj;\n ay[i]:=w[rk];\n nrj:=pj[i, rj, rk];\n nrk:=pk[i, rj, rk];\n rj:=nrj; rk:=nrk;\n end;\n for i:=1 to n do writeln(ax[i], ' ', ay[i]);\n close(output);\nend."}, {"source_code": "var m,n,key,i,j,k,s,max1,max2:longint;\n a,b:array[0..1000] of int64;\n f:array[0..100,0..100,0..200] of int64;\n p,v:array[0..100,0..100,0..200] of longint;\n c,max:int64;\n q,w:array[0..1000] of longint;\n\nprocedure swapi(var a,b:int64);\n var r:int64;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure swap(var a,b:longint);\n var r:longint;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure search(i,j,k:longint);\n begin\n if p[i,j,k]<>-1 then search(p[i,j,k],j-1,v[i,j,k]);\n if p[i,j,k]=-1 then\n writeln(w[i],' ',f[i,j,k])\n else\n writeln(w[i],' ',f[i,j,k]-f[p[i,j,k],j-1,v[i,j,k]]);\n end;\n\nbegin\n readln(n,m,key);\n for i:=1 to m do\n begin\n readln(a[i],b[i],q[i]);\n w[i]:=i;\n end;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if q[i]>q[j] then\n begin\n swapi(a[i],a[j]);\n swapi(b[i],b[j]);\n swap(q[i],q[j]);\n swap(w[i],w[j]);\n end;\n fillchar(f,sizeof(f),0);\n fillchar(p,sizeof(p),0);\n fillchar(v,sizeof(v),0);\n for i:=0 to b[1]-a[1] do\n begin\n f[1,1,i]:=i+a[1];\n p[1,1,i]:=-1;\n v[1,1,i]:=-1;\n end;\n for i:=2 to m do\n begin\n for j:=0 to b[i]-a[i] do\n begin\n f[i,1,j]:=j+a[i];\n p[i,1,j]:=-1;\n v[i,1,j]:=-1;\n end;\n for j:=2 to n do\n for k:=1 to i-1 do\n if q[i]>q[k] then\n for s:=0 to b[k]-a[k] do\n begin\n if p[k,j-1,s]=0 then continue;\n c:=s+a[k]+key;\n if (c>=a[i]) and (c<=b[i]) then\n if f[k,j-1,s]+c>f[i,j,c-a[i]] then\n begin\n f[i,j,c-a[i]]:=f[k,j-1,s]+c;\n p[i,j,c-a[i]]:=k;\n v[i,j,c-a[i]]:=s;\n end;\n c:=(s+a[k])*key;\n if (c>=a[i]) and (c<=b[i]) then\n if f[k,j-1,s]+c>f[i,j,c-a[i]] then\n begin\n f[i,j,c-a[i]]:=f[k,j-1,s]+c;\n p[i,j,c-a[i]]:=k;\n v[i,j,c-a[i]]:=s;\n end;\n end;\n end;\n max1:=0;\n max2:=0;\n max:=0;\n for i:=1 to m do\n for j:=0 to b[i]-a[i] do\n if f[i,n,j]>max then\n begin\n max:=f[i,n,j];\n max1:=i;\n max2:=j;\n end;\n if max=0 then writeln('NO') else\n begin\n writeln('YES');\n search(max1,n,max2);\n end;\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\ntype\n int64=qword;\nconst\n inf:int64=100000000000000000;\nvar\n f:array[0..55,0..55,0..555]of int64;\n py,px:array[0..55,0..55,0..555]of longint;\n pxx,pyy,xx,yy,q,tmp,kr,i,j,k,n,m,tk:longint;\n max,ti,tt:int64;\n r2,a,b:array[0..500500]of int64;\n r1,nom,c:array[0..500500]of longint;\n\nbegin\n read(n,m,tk);\n for i:=1 to m do read(a[i],b[i],c[i]);\n\n for i:=1 to m do nom[i]:=i;\n for i:=1 to m-1 do \n for j:=1 to m-1 do\n if (c[j]>c[j+1])then begin\n ti:=a[j];a[j]:=a[j+1];a[j+1]:=ti;\n ti:=b[j];b[j]:=b[j+1];b[j+1]:=ti;\n tmp:=c[j];c[j]:=c[j+1];c[j+1]:=tmp;\n tmp:=nom[j];nom[j]:=nom[j+1];nom[j+1]:=tmp;\n end;\n\n fillchar(f,sizeof(f),$0);\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n f[1][j][k]:=k+a[j];\n\n for i:=1 to n-1 do\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[i][j][k]<>0)then begin\n tt:=a[j]+k+tk;\n for q:=j+1 to m do\n if (c[q]>c[j])and(tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n tt:=a[j]+k;\n if (tt>inf/tk)then continue;\n tt:=tt*tk;\n for q:=j+1 to m do\n if (c[q]>c[j])and(tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n end;\n\n max:=0;\n xx:=0;\n yy:=0;\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[n][j][k]>max)then begin\n max:=f[n][j][k];\n xx:=j;yy:=k;\n end;\n if (max<1)then begin\n writeln('NO');\n exit;\n end;\n kr:=0;\n writeln('YES');\n for i:=n downto 1 do begin\n inc(kr);\n r1[kr]:=nom[xx];\n r2[kr]:=a[xx]+yy;\n pxx:=px[i][xx][yy];\n pyy:=py[i][xx][yy];\n xx:=pxx;\n yy:=pyy;\n end;\n for i:=kr downto 1 do writeln(r1[i],' ',r2[i]);\nend.\n"}, {"source_code": "program task;\n//{$APPTYPE DELPHI}\n//{$APPTYPE CONSOLE}\n{$R-,S-,Q-,I-,O+}\n\nuses\n Math,\n SysUtils;\n\ntype kat=record\n a,b:int64;\n c,id:longint;\nend;\n\nvar n,m,k,i,jj,l,i1,i2:longint;\n j,kkl,lk,rip:int64;\n kk:array[1..100]of kat;\n least:array[1..100]of longint;\n res:array[1..100,1..50,0..100]of int64;\n\nfunction less(a,b:kat):boolean;\nbegin\n less:=(a.c=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n //assign(input,'input.txt');\n //assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i := 1 to m do\n kk[i].id := i;\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}], "negative_code": [{"source_code": "{$APPTYPE CONSOLE}\n\nvar\n idx1,idx,idy,z,l,x,i,j,n,m:integer;\n ans,s1,s2,s,k:int64;\n an1,a,b:array[1..101] of int64;\n nn1,nn,c:array[1..101] of integer;\n an:array[1..51,1..51,0..101] of int64;\n cur,prevl,prevs:array[1..51,1..51,0..101] of integer;\n\n Procedure swap(var a,b:int64);\n var\n x:int64;\n begin\n x:=a;\n a:=b;\n b:=x;\n end;\n\n Procedure sort(l,r:integer);\n var\n i,j,x:integer;\n begin\n For i:=l+1 to r do\n For j:=r downto i do If a[j-1]>a[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n end;\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt');}\n\n readln(n,m,k);\n\n For i:=1 to m do readln(a[i],b[i],c[i]);\n For i:=1 to m do nn[i]:=i;\n\n For i:=2 to m do\n For j:=m downto i do If c[j-1]>c[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n\n j:=1;\n c[m+1]:=-100;\n while j<=m do\n begin\n l:=j;\n while (c[j+1]=c[j]) do inc(j);\n Sort(l,j);\n inc(j);\n end;\n\n Fillchar(prevs,sizeof(prevs),0);\n Fillchar(prevl,sizeof(prevl),0);\n Fillchar(cur,sizeof(cur),0);\n\n\n For i:=1 to n do\n For j:=1 to m do\n For z:=0 to 101 do an[i,j,z]:=-100000000000000000;\n\n For i:=1 to m do\n For j:=0 to b[i]-a[i] do\n begin\n prevs[1,i,j]:=-1;\n prevl[1,i,j]:=-1;\n an[1,i,j]:=a[i]+j;\n cur[1,i,j]:=a[i]+j;\n end;\n\n For i:=2 to n do\n For j:=1 to m do\n For z:=0 to b[j]-a[j] do\n begin\n s:=a[j]+z;\n If s mod k=0 then s1:=s div k else s1:=-1;\n s2:=s-k;\n For l:=i to j-1 do\n begin\n If ((s1>=a[l]) and (s1<=b[l])) and (an[i-1,l,s1-a[l]]<>-100000000000000000)\n and (an[i,j,z]=a[l]) and (s2<=b[l])) and (an[i-1,l,s2-a[l]]<>-100000000000000000)\n and (an[i,j,z]ans then\n begin\n ans:=an[n,i,j];\n idx:=i;\n idy:=j;\n end;\n\n If ans=-100000000000000000 then writeln('NO') else\n begin\n writeln('YES');\n For i:=n downto 1 do\n begin\n nn1[i]:=nn[idx];\n an1[i]:=cur[i,idx,idy];\n idx1:=prevl[i,idx,idy];\n idy:=prevs[i,idx,idy];\n idx:=idx1;\n end;\n For i:=2 to n do\n For j:=n downto i do If c[nn1[j-1]]>c[nn1[j]] then\n begin\n swap(an1[j-1],an1[j]);\n x:=nn1[j-1];\n nn1[j-1]:=nn1[j];\n nn1[j]:=x;\n end;\n For i:=1 to n do writeln(nn1[i],' ',an1[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar\n idx1,idx,idy,z,l,x,i,j,n,m:integer;\n ans,s1,s2,s,k:int64;\n an1,a,b:array[1..101] of int64;\n c1,nn1,nn,c:array[1..101] of integer;\n an:array[1..51,1..51,0..101] of int64;\n cur,prevl,prevs:array[1..51,1..51,0..101] of integer;\n\n Procedure swap(var a,b:int64);\n var\n x:int64;\n begin\n x:=a;\n a:=b;\n b:=x;\n end;\n\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt');}\n\n readln(n,m,k);\n\n For i:=1 to m do readln(a[i],b[i],c[i]);\n For i:=1 to m do nn[i]:=i;\n\n For i:=2 to m do\n For j:=m downto i do If c[j-1]>c[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n\n\n Fillchar(prevs,sizeof(prevs),0);\n Fillchar(prevl,sizeof(prevl),0);\n Fillchar(cur,sizeof(cur),0);\n\n\n For i:=1 to n do\n For j:=1 to m do\n For z:=0 to 101 do an[i,j,z]:=-100000000000000000;\n\n For i:=1 to m do\n For j:=0 to b[i]-a[i] do\n begin\n prevs[1,i,j]:=-1;\n prevl[1,i,j]:=-1;\n an[1,i,j]:=a[i]+j;\n cur[1,i,j]:=a[i]+j;\n end;\n\n //For i:=1 to m do writeln(a[i],' ',b[i],' ',c[i],' ',nn[i]);\n\n For i:=2 to n do\n For j:=i to m do\n For z:=0 to b[j]-a[j] do\n begin\n s:=a[j]+z;\n If s mod k=0 then s1:=s div k else s1:=-1;\n s2:=s-k;\n For l:=i-1 to j-1 do\n begin\n If (c[j]>c[l]) and ((s1>=a[l]) and (s1<=b[l])) and (an[i-1,l,s1-a[l]]<>-100000000000000000)\n and (an[i,j,z]c[l]) and ((s2>=a[l]) and (s2<=b[l])) and (an[i-1,l,s2-a[l]]<>-100000000000000000)\n and (an[i,j,z]ans then\n begin\n ans:=an[n,i,j];\n idx:=i;\n idy:=j;\n end;\n\n If ans=-100000000000000000 then writeln('NO') else\n begin\n writeln('YES');\n For i:=n downto 1 do\n begin\n nn1[i]:=nn[idx];\n c1[i]:=c[idx];\n an1[i]:=cur[i,idx,idy];\n idx1:=prevl[i,idx,idy];\n idy:=prevs[i,idx,idy];\n idx:=idx1;\n end;\n For i:=2 to n do\n For j:=n downto i do If c1[j-1]>c1[j] then\n begin\n swap(an1[j-1],an1[j]);\n x:=nn1[j-1];\n nn1[j-1]:=nn1[j];\n nn1[j]:=x;\n x:=c1[j-1];\n c1[j-1]:=c1[j];\n c1[j]:=x;\n end;\n For i:=1 to n do writeln(nn1[i],' ',an1[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar\n idx1,idx,idy,z,l,x,i,j,n,m:integer;\n ans,s1,s2,s,k:int64;\n an1,a,b:array[1..101] of int64;\n c1,nn1,nn,c:array[1..101] of integer;\n an:array[1..51,1..51,0..101] of int64;\n cur,prevl,prevs:array[1..51,1..51,0..101] of integer;\n\n Procedure swap(var a,b:int64);\n var\n x:int64;\n begin\n x:=a;\n a:=b;\n b:=x;\n end;\n\n Procedure sort(l,r:integer);\n var\n i,j,x:integer;\n begin\n For i:=l+1 to r do\n For j:=r downto i do If a[j-1]>a[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n end;\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n\n readln(n,m,k);\n\n For i:=1 to m do readln(a[i],b[i],c[i]);\n For i:=1 to m do nn[i]:=i;\n\n For i:=2 to m do\n For j:=m downto i do If c[j-1]>c[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n\n j:=1;\n c[m+1]:=-100;\n while j<=m do\n begin\n l:=j;\n while (c[j+1]=c[j]) do inc(j);\n Sort(l,j);\n inc(j);\n end;\n\n Fillchar(prevs,sizeof(prevs),0);\n Fillchar(prevl,sizeof(prevl),0);\n Fillchar(cur,sizeof(cur),0);\n\n\n For i:=1 to n do\n For j:=1 to m do\n For z:=0 to 101 do an[i,j,z]:=-100000000000000000;\n\n For i:=1 to m do\n For j:=0 to b[i]-a[i] do\n begin\n prevs[1,i,j]:=-1;\n prevl[1,i,j]:=-1;\n an[1,i,j]:=a[i]+j;\n cur[1,i,j]:=a[i]+j;\n end;\n\n For i:=2 to n do\n For j:=1 to m do\n For z:=0 to b[j]-a[j] do\n begin\n s:=a[j]+z;\n If s mod k=0 then s1:=s div k else s1:=-1;\n s2:=s-k;\n For l:=i to j-1 do\n begin\n If (c[j]>c[l]) and ((s1>=a[l]) and (s1<=b[l])) and (an[i-1,l,s1-a[l]]<>-100000000000000000)\n and (an[i,j,z]c[l]) and ((s2>=a[l]) and (s2<=b[l])) and (an[i-1,l,s2-a[l]]<>-100000000000000000)\n and (an[i,j,z]ans then\n begin\n ans:=an[n,i,j];\n idx:=i;\n idy:=j;\n end;\n\n If ans=-100000000000000000 then writeln('NO') else\n begin\n writeln('YES');\n For i:=n downto 1 do\n begin\n nn1[i]:=nn[idx];\n c1[i]:=c[idx];\n an1[i]:=cur[i,idx,idy];\n idx1:=prevl[i,idx,idy];\n idy:=prevs[i,idx,idy];\n idx:=idx1;\n end;\n For i:=2 to n do\n For j:=n downto i do If c1[j-1]>c1[j] then\n begin\n swap(an1[j-1],an1[j]);\n x:=nn1[j-1];\n nn1[j-1]:=nn1[j];\n nn1[j]:=x;\n x:=c1[j-1];\n c1[j-1]:=c1[j];\n c1[j]:=x;\n end;\n For i:=1 to n do writeln(nn1[i],' ',an1[i]);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar\n idx1,idx,idy,z,l,x,i,j,n,m:integer;\n ans,s1,s2,s,k:int64;\n a,b:array[1..101] of int64;\n nn,c:array[1..101] of integer;\n an:array[1..51,1..51,0..101] of int64;\n cur,prevl,prevs:array[1..51,1..51,0..101] of integer;\n\n Procedure swap(var a,b:int64);\n var\n x:int64;\n begin\n x:=a;\n a:=b;\n b:=x;\n end;\n\n Procedure sort(l,r:integer);\n var\n i,j,x:integer;\n begin\n For i:=l+1 to r do\n For j:=r downto i do If a[j-1]>a[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n end;\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n\n readln(n,m,k);\n\n For i:=1 to m do readln(a[i],b[i],c[i]);\n For i:=1 to m do nn[i]:=i;\n\n For i:=2 to m do\n For j:=m downto i do If c[j-1]>c[j] then\n begin\n swap(a[j-1],a[j]);\n swap(b[j-1],b[j]);\n x:=c[j-1];\n c[j-1]:=c[j];\n c[j]:=x;\n x:=nn[j-1];\n nn[j-1]:=nn[j];\n nn[j]:=x;\n end;\n\n j:=1;\n c[m+1]:=-100;\n while j<=m do\n begin\n l:=j;\n while (c[j+1]=c[j]) do inc(j);\n Sort(l,j);\n inc(j);\n end;\n\n Fillchar(prevs,sizeof(prevs),0);\n Fillchar(prevl,sizeof(prevl),0);\n Fillchar(cur,sizeof(cur),0);\n\n\n For i:=1 to n do\n For j:=1 to m do\n For z:=0 to 101 do an[i,j,z]:=-100000000000000000;\n\n For i:=1 to m do\n For j:=0 to b[i]-a[i] do\n begin\n prevs[1,i,j]:=-1;\n prevl[1,i,j]:=-1;\n an[1,i,j]:=a[i]+j;\n cur[1,i,j]:=a[i]+j;\n end;\n\n For i:=2 to n do\n For j:=1 to m do\n For z:=0 to b[j]-a[j] do\n begin\n s:=a[j]+z;\n If s mod k=0 then s1:=s div k else s1:=-1;\n s2:=s-k;\n For l:=i to j-1 do\n begin\n If ((s1>=a[l]) and (s1<=b[l])) and (an[i-1,l,s1-a[l]]<>-100000000000000000)\n and (an[i,j,z]=a[l]) and (s2<=b[l])) and (an[i-1,l,s2-a[l]]<>-100000000000000000)\n and (an[i,j,z]ans then\n begin\n ans:=an[n,i,j];\n idx:=i;\n idy:=j;\n end;\n\n If ans=-100000000000000000 then writeln('NO') else\n begin\n writeln('YES');\n For i:=n downto 1 do\n begin\n writeln(nn[idx],' ',cur[i,idx,idy]);\n idx1:=prevl[i,idx,idy];\n idy:=prevs[i,idx,idy];\n idx:=idx1;\n end;\n end;\n\nend.\n"}, {"source_code": "program task;\n//{$APPTYPE DELPHI}\n{$APPTYPE CONSOLE}\n{$R-,S-,Q-,I-,O+}\n\nuses\n Math,\n SysUtils;\n\ntype kat=record\n a,b:int64;\n c:longint;\nend;\n\nvar n,m,k,i,jj,l,i1,i2:longint;\n j,kkl,lk,rip:int64;\n kk:array[1..100]of kat;\n least:array[1..100]of longint;\n res:array[1..100,1..50,0..100]of int64;\n\nfunction less(a,b:kat):boolean;\nbegin\n less:=(a.c=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n assign(input,'input.txt');\n assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}, {"source_code": "program task;\n//{$APPTYPE DELPHI}\n{$APPTYPE CONSOLE}\n{$R-,S-,Q-,I-,O+}\n\nuses\n Math,\n SysUtils;\n\ntype kat=record\n a,b:int64;\n c:longint;\nend;\n\nvar n,m,k,i,jj,l,i1,i2:longint;\n j,kkl,lk,rip:int64;\n kk:array[1..100]of kat;\n least:array[1..100]of longint;\n res:array[1..100,1..50,0..100]of int64;\n\nfunction less(a,b:kat):boolean;\nbegin\n less:=(a.c=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n //assign(input,'input.txt');\n //assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O+} {$R+}\n\nuses\n SysUtils,\n Math;\n\nconst\n CLen = 101;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n mx, d, p: array [1..clen, 1..clen, 0..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val, mxx: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, m, k);\n for i := 1 to m do\n read(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 0 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n mx[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n mx[1, i, j] := j + a[i];\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n val := x + a[j] + k - a[y];\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) and (mx[i, j, x] + x + a[j] + k > mx[i, y, val]) then\n begin\n d[i, y, val] := 1;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + x + a[j] + k; \n end;\n val := (x + a[j]) * k - a[y];\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) and (mx[i, j, x] + (x + a[j]) * k > mx[i, y, val]) then\n begin\n d[i, y, val] := 2;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + (x + a[j]) * k;\n end;\n end;\n mxx := -1;\n for j := 1 to m do\n for x := 0 to clen do\n mxx := max(mxx, mx[n, j, x]);\n for j := 1 to m do\n for x := 0 to clen do\n if (mxx <> -1) and (mx[n, j, x] = mxx) then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-} {$R+} {$Q+}\n\nuses\n SysUtils,\n Math;\n\nconst\n CLen = 101;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n mx, d, p: array [1..clen, 1..clen, 0..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val, mxx: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, m, k);\n for i := 1 to m do\n read(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 0 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n mx[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n mx[1, i, j] := j + a[i];\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n val := x + a[j] + k - a[y];\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) and (mx[i, j, x] + x + a[j] + k > mx[i, y, val]) then\n begin\n d[i, y, val] := 1;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + x + a[j] + k; \n end;\n val := (x + a[j]) * k - a[y];\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) and (mx[i, j, x] + (x + a[j]) * k > mx[i, y, val]) then\n begin\n d[i, y, val] := 2;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + (x + a[j]) * k;\n end;\n end;\n mxx := -1;\n for j := 1 to m do\n for x := 0 to clen do\n mxx := max(mxx, mx[n, j, x]);\n for j := 1 to m do\n for x := 0 to clen do\n if (mxx <> -1) and (mx[n, j, x] = mxx) then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O+}\n\nuses\n SysUtils;\n\nconst\n CLen = 100;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n d, p: array [1..clen, 1..clen, 1..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n Readln(n, m, k);\n for i := 1 to m do\n readln(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 1 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) then\n begin\n val := x + a[j] + k - a[y];\n d[i, y, val] := 1;\n p[i, y, val] := j;\n end;\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) then\n begin\n val := (x + a[j]) * k - a[y];\n d[i, y, val] := 2;\n p[i, y, val] := j;\n end;\n end;\n for j := 1 to m do\n for x := 0 to clen do\n if d[n, j, x] <> -1 then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O+}\n\nuses\n SysUtils, Math;\n\nconst\n CLen = 101;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n mx, d, p: array [1..clen, 1..clen, 1..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val, mxx: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, m, k);\n for i := 1 to m do\n read(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 1 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n mx[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n mx[1, i, j] := j + a[i];\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n val := x + a[j] + k - a[y];\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) and (mx[i, j, x] + x + a[j] + k > mx[i, y, val]) then\n begin\n d[i, y, val] := 1;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + x + a[j] + k; \n end;\n val := (x + a[j]) * k - a[y];\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) and (mx[i, j, x] + (x + a[j]) * k > mx[i, y, val]) then\n begin\n d[i, y, val] := 2;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + (x + a[j]) * k;\n end;\n end;\n mxx := -1;\n for j := 1 to m do\n for x := 0 to clen do\n mxx := max(mxx, mx[n, j, x]);\n for j := 1 to m do\n for x := 0 to clen do\n if (mxx <> -1) and (mx[n, j, x] = mxx) then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils, Math;\n\nconst\n CLen = 100;\n\nvar\n n, m, k: Int64;\n a, b, c: array [1..clen] of Int64;\n mx, d, p: array [1..clen, 1..clen, 1..clen] of Int64;\n\nprocedure write_res(x, y, z: Int64);\nbegin\n if d[x, y, z] = 1 then\n write_res(x-1, p[x, y, z], z + a[y] - k - a[p[x, y, z]])\n else if d[x, y, z] = 2 then\n write_res(x-1, p[x, y, z], ((z + a[y]) div k) - a[p[x, y, z]]);\n Writeln(y, ' ', a[y] + z);\nend;\n\nvar\n i, j, x, y: Integer;\n val, mxx: Int64;\n\nbegin\n //Reset(input, 'input.txt'); rewrite(output, 'output.txt');\n Readln(n, m, k);\n for i := 1 to m do\n readln(a[i], b[i], c[i]);\n for i := 1 to clen do\n for j := 1 to clen do\n for x := 1 to clen do\n begin\n d[i, j, x] := -1;\n p[i, j, x] := -1;\n mx[i, j, x] := -1;\n end;\n for i := 1 to m do\n for j := 0 to b[i] - a[i] do\n begin\n d[1, i, j] := 0;\n p[1, i, j] := 0;\n mx[1, i, j] := j + a[i];\n end;\n for i := 2 to n do\n for j := 1 to m do\n for x := 0 to clen do\n for y := 1 to m do\n if (d[i-1, j, x] <> -1) and (c[y] > c[j]) then\n begin\n val := x + a[j] + k - a[y];\n if (a[y] <= x + a[j] + k) and (x + a[j] + k <= b[y]) and (mx[i, j, x] + x + a[j] + k > mx[i, y, val]) then\n begin\n d[i, y, val] := 1;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + x + a[j] + k; \n end;\n val := (x + a[j]) * k - a[y];\n if (a[y] <= (x + a[j]) * k) and ((x + a[j]) * k <= b[y]) and (mx[i, j, x] + (x + a[j]) * k > mx[i, y, val]) then\n begin\n d[i, y, val] := 2;\n p[i, y, val] := j;\n mx[i, y, val] := mx[i, j, x] + (x + a[j]) * k;\n end;\n end;\n mxx := -1;\n for j := 1 to m do\n for x := 0 to clen do\n mxx := max(mxx, mx[n, j, x]);\n for j := 1 to m do\n for x := 0 to clen do\n if (mxx <> -1) and (mx[n, j, x] = mxx) then\n begin\n Writeln('YES');\n write_res(n, j, x);\n halt;\n end;\n Writeln('NO');\nend.\n "}, {"source_code": "const maxn = 5100;\nconst maxm = 51;\n\nvar\n f:array[0..maxm, 0..maxm, 0..maxn] of int64;\n pi,pj,pk:array[0..maxm, 0..maxm, 0..maxn] of word;\n ax,ay,a,b,c,w:array[0..maxn] of int64;\n edn,beg:array[0..maxn] of longint;\n qk,nrj,nrk,ri,rj,rk,q,k,wn,n,m,i,j:longint;\n max,me,kk:int64;\n\nprocedure qs(const l, r:longint);\nvar\n i,j:longint;\n x,y:int64;\nbegin\n i:=l; j:=r; x:=w[(l+r) shr 1];\n repeat\n while x>w[i] do inc(i);\n while x nk do ;\n if f[ni, nj, qk]0 then\n begin\n me:=w[k];\n for q:=1 to m do if c[q]>c[j] then\n begin\n if (a[q]<=me+kk)and(me+kk<=b[q]) then upd(i+1, q, beg[q]+me+kk-a[q], me+kk, f[i, j, k]+me+kk);\n if (a[q]<=me*kk)and(me*kk<=b[q]) then upd(i+1, q, beg[q]+me*kk-a[q], me*kk, f[i, j, k]+me*kk);\n end;\n end;\n rk:=-1;\n max:=-1;\n for j:=1 to m do for k:=1 to wn do if (f[i, j, k]>0)and(f[n, j, k] > max) then\n begin\n max:=f[n, j, k];\n ri:=n;\n rj:=j;\n rk:=k;\n end;\n if rk = -1 then\n begin\n writeln('NO');\n close(output);\n halt;\n end;\n writeln('YES');\n for i:=n downto 1 do\n begin\n ax[i]:=rj;\n ay[i]:=w[rk];\n nrj:=pj[i, rj, rk];\n nrk:=pk[i, rj, rk];\n rj:=nrj; rk:=nrk;\n end;\n for i:=1 to n do writeln(ax[i], ' ', ay[i]);\n close(output);\nend."}, {"source_code": "const maxn = 5100;\nconst maxm = 51;\n\nvar\n f:array[0..maxm, 0..maxm, 0..maxn] of int64;\n pi,pj,pk:array[0..maxm, 0..maxm, 0..maxn] of word;\n ax,ay,a,b,c,w:array[0..maxn] of int64;\n beg:array[0..maxn] of longint;\n qk,nrj,nrk,ri,rj,rk,q,k,wn,n,m,i,j:longint;\n max,me,kk:int64;\n\nprocedure qs(const l, r:longint);\nvar\n i,j:longint;\n x,y:int64;\nbegin\n i:=l; j:=r; x:=w[(l+r) shr 1];\n repeat\n while x>w[i] do inc(i);\n while x=x) then r:=mid else l:=mid+1;\n end;\n idx:=l;\nend;\n\nprocedure upd(const ni, nj, qk:longint; nk, up:int64);\nbegin\n if f[ni, nj, qk]0 then\n begin\n me:=w[k];\n for q:=1 to m do if c[q]>c[j] then\n begin\n if (a[q]<=me+kk)and(me+kk<=b[q]) then upd(i+1, q, beg[q]+me+kk-a[q], me+kk, f[i, j, k]+me+kk);\n if (a[q]<=me*kk)and(me*kk<=b[q]) then upd(i+1, q, beg[q]+me*kk-a[q], me*kk, f[i, j, k]+me*kk);\n end;\n end;\n rk:=-1;\n max:=-1;\n for j:=1 to m do for k:=1 to wn do if (f[i, j, k]>0)and(f[n, j, k] > max) then\n begin\n max:=f[n, j, k];\n ri:=n;\n rj:=j;\n rk:=k;\n end;\n if rk = -1 then\n begin\n writeln('NO');\n close(output);\n halt;\n end;\n writeln('YES');\n for i:=n downto 1 do\n begin\n ax[i]:=rj;\n ay[i]:=w[rk];\n nrj:=pj[i, rj, rk];\n nrk:=pk[i, rj, rk];\n rj:=nrj; rk:=nrk;\n end;\n for i:=1 to n do writeln(ax[i], ' ', ay[i]);\n close(output);\nend."}, {"source_code": "{$r+,i+,q+,s+,o-}\nconst maxn = 5100;\nconst maxm = 51;\n\nvar\n f:array[0..maxm, 0..maxm, 0..maxn] of int64;\n pi,pj,pk:array[0..maxm, 0..maxm, 0..maxn] of word;\n ax,ay,a,b,c,w:array[0..maxn] of int64;\n edn,beg:array[0..maxn] of longint;\n qk,nrj,nrk,ri,rj,rk,q,k,wn,n,m,i,j:longint;\n jj,max,me,kk:int64;\n\nprocedure qs(const l, r:longint);\nvar\n i,j:longint;\n x,y:int64;\nbegin\n i:=l; j:=r; x:=w[(l+r) shr 1];\n repeat\n while x>w[i] do inc(i);\n while x nk do ;\n if f[ni, nj, qk]0 then\n begin\n me:=w[k];\n for q:=1 to m do if c[q]>c[j] then\n begin\n if (a[q]<=me+kk)and(me+kk<=b[q]) then upd(i+1, q, int64(beg[q])+me+kk-a[q], me+kk, f[i, j, k]+me+kk);\n if (a[q]<=me*kk)and(me*kk<=b[q]) then upd(i+1, q, int64(beg[q])+me*kk-a[q], me*kk, f[i, j, k]+me*kk);\n end;\n end;\n rk:=-1;\n max:=-1;\n for j:=1 to m do for k:=1 to wn do if (f[i, j, k]>0)and(f[n, j, k] > max) then\n begin\n max:=f[n, j, k];\n ri:=n;\n rj:=j;\n rk:=k;\n end;\n if rk = -1 then\n begin\n writeln('NO');\n close(output);\n halt;\n end;\n writeln('YES');\n for i:=n downto 1 do\n begin\n ax[i]:=rj;\n ay[i]:=w[rk];\n nrj:=pj[i, rj, rk];\n nrk:=pk[i, rj, rk];\n rj:=nrj; rk:=nrk;\n end;\n for i:=1 to n do writeln(ax[i], ' ', ay[i]);\n close(output);\nend."}, {"source_code": "Program C_REFORM;\nConst MaxN=50;\n MaxV=100;\nType subject=Record a,b:qword; stt,c,v:Longint End;\nVar l:array[1..MaxN,1..MaxN,0..MaxV] of qword;\n trace:array[1..MaxN,1..MaxN,0..MaxV] of Record a,b:Longint End;\n a:array[1..MaxN] of subject;\n n,m,k:Longint;\nProcedure Input;\nVar f:Text;\n i:Longint;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,n,m,k);\n For i:=1 to m do\n Begin\n Readln(f,a[i].a,a[i].b,a[i].c);\n a[i].v:=a[i].b-a[i].a;\n a[i].stt:=i;\n End;\n Close(f);\nEnd;\n\nProcedure Swap(var a,b:subject);\nVar t:subject; Begin t:=a; a:=b; b:=t End;\n\nProcedure QuickSort(l,r:Longint);\nVar i,j,k:Longint;\nBegin\n If l>=r then exit;\n i:=l; j:=r;\n k:=a[random(r-l+1)+l].c;\n Repeat\n While a[i].ck do Dec(j);\n If i<=j then\n Begin\n If ij;\n QuickSOrt(l,j); QUickSort(i,r)\nEnd;\n\nProcedure Optimize;\nVar i,j,z,x,h:Longint;\n t:qword;\nBegin\n For j:=1 to m-n+1 do\n For z:=0 to a[1].v do\n l[1,j,z]:=z+a[1].a;\n\n For i:=1 to n-1 do\n For j:=i to m-(n-i) do\n For z:=0 to a[j].v do\n If l[i,j,z]<>0 then\n For h:=1 to 2 do\n Begin\n If h=1 then t:=(z+a[j].a)*k else t:=(z+a[j].a)+k;\n For x:=j+1 to m-(n-i)+1 do\n If (a[x].c>a[j].c) and (a[x].a<=t) and (t<=a[x].b)\n and (l[i+1,x,t-a[x].a]0 do\n Begin\n ds[i].stt:=a[x].stt; ds[i].v:=a[x].a+y;\n j:=trace[i,x,y].a; z:=trace[i,x,y].b;\n x:=j; y:=z;\n Dec(i);\n End;\n Writeln('YES');\n For i:=1 to n do Writeln(ds[i].stt,' ',ds[i].v);\nEnd;\n\nBEGIN\n Input;\n QuickSort(1,m);\n Optimize;\n Output;\nEND."}, {"source_code": "Program C_REFORM;\nConst MaxN=50;\n MaxV=100;\nType subject=Record a,b:qword; stt,c,v:Longint End;\nVar l:array[1..MaxN,1..MaxN,0..MaxV] of qword;\n trace:array[1..MaxN,1..MaxN,0..MaxV] of Record a,b:Longint End;\n a:array[1..MaxN] of subject;\n n,m,k:Longint;\nProcedure Input;\nVar f:Text;\n i:Longint;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,n,m,k);\n For i:=1 to m do\n Begin\n Readln(f,a[i].a,a[i].b,a[i].c);\n a[i].v:=a[i].b-a[i].a;\n a[i].stt:=i;\n End;\n Close(f);\nEnd;\n\nProcedure Swap(var a,b:subject);\nVar t:subject; Begin t:=a; a:=b; b:=t End;\n\nProcedure QuickSort(l,r:Longint);\nVar i,j,k:Longint;\nBegin\n If l>=r then exit;\n i:=l; j:=r;\n k:=a[random(r-l+1)+l].c;\n Repeat\n While a[i].ck do Dec(j);\n If i<=j then\n Begin\n If ij;\n QuickSOrt(l,j); QUickSort(i,r)\nEnd;\n\nProcedure Optimize;\nVar i,j,z,x,h:Longint;\n t:qword;\nBegin\n For j:=1 to m-n+1 do\n For z:=0 to a[1].v do\n l[1,j,z]:=z+a[1].a;\n\n For i:=1 to n-1 do\n For j:=i to m-(n-i) do\n For z:=0 to a[j].v do\n If l[i,j,z]<>0 then\n For h:=1 to 2 do\n Begin\n If h=1 then t:=(z+a[j].a)*k else t:=(z+a[j].a)+k;\n For x:=j+1 to m-(n-i)+1 do\n If (a[x].c>a[j].c) and (a[x].a<=t) and (t<=a[x].b)\n and (l[i+1,x,t-a[x].a]0 do\n Begin\n ds[i].stt:=a[x].stt; ds[i].v:=a[x].a+y;\n j:=trace[i,x,y].a; z:=trace[i,x,y].b;\n x:=j; y:=z;\n Dec(i);\n End;\n Writeln('YES');\n For i:=1 to n do Writeln(ds[i].stt,' ',ds[i].v);\nEnd;\n\nBEGIN\n Input;\n QuickSort(1,m);\n Optimize;\n Output;\nEND."}, {"source_code": "Program Education_Reform;\nvar i,j,z,x,n,m,nx,ny:longint;\n tmp,k:int64;\n s,t,a,id,ans,ans2:array[1..100]of int64;\n pre,pre2:array[1..50,0..50,0..100]of longint;\n f:array[1..50,0..50,0..100]of boolean;\n//===============================================================\nprocedure qsort(left,right:longint);\nvar l,r,mid,k:longint;\nbegin\n l:=left;r:=right;\n mid:=a[(l+r)shr 1];\n repeat\n while a[l]mid do dec(r);\n if l<=r then\n begin\n tmp:=a[l];a[l]:=a[r];a[r]:=tmp;\n tmp:=s[l];s[l]:=s[r];s[r]:=tmp;\n tmp:=t[l];t[l]:=t[r];t[r]:=tmp;\n tmp:=id[l];id[l]:=id[r];id[r]:=tmp;\n inc(l);dec(r);\n end;\n until l>r;\n if lefta[z]) then\n begin\n tmp:=s[z]+int64(x)+k;\n if (s[j]<=tmp)and(tmp<=t[j])then\n begin\n f[i,j,tmp-s[j]]:=true;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n tmp:=int64(s[z]+x)*k;\n if (s[j]<=tmp)and(tmp<=t[j])then\n begin\n f[i,j,tmp-s[j]]:=true;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n end;\n for z:=n to m do\n for x:=0 to t[z]-s[z] do\n if f[n,z,x] then\n begin\n writeln('YES');\n Print(z,x);\n halt;\n end;\n writeln('NO');\nend;\n//===============================================================\nbegin\n readln(n,m,k);\n for i:=1 to m do\n begin\n readln(s[i],t[i],a[i]);\n id[i]:=i;\n end;\n qsort(1,m);\n DP;\nend.\n"}, {"source_code": "Program Education_Reform;\nvar i,j,z,x,n,m,nx,ny:longint;\n tmp,k:int64;\n s,t,a,ans,ans2:array[1..100]of int64;\n pre,pre2:array[1..50,0..50,0..100]of longint;\n f:array[1..50,0..50,0..100]of boolean;\n//===============================================================\nprocedure qsort(left,right:longint);\nvar l,r,mid,k:longint;\nbegin\n l:=left;r:=right;\n mid:=a[(l+r)shr 1];\n repeat\n while a[l]mid do dec(r);\n if l<=r then\n begin\n tmp:=a[l];a[l]:=a[r];a[r]:=tmp;\n tmp:=s[l];s[l]:=s[r];s[r]:=tmp;\n tmp:=t[l];t[l]:=t[r];t[r]:=tmp;\n inc(l);dec(r);\n end;\n until l>r;\n if lefta[z]) then\n begin\n tmp:=s[z]+int64(x)+k;\n if (s[j]<=tmp)and(tmp<=t[j])then\n begin\n f[i,j,tmp-s[j]]:=true;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n tmp:=int64(s[z]+x)*k;\n if (s[j]<=tmp)and(tmp<=t[j])then\n begin\n f[i,j,tmp-s[j]]:=true;\n pre[i,j,tmp-s[j]]:=z;\n pre2[i,j,tmp-s[j]]:=x;\n end;\n end;\n for z:=n to m do\n for x:=0 to t[z]-s[z] do\n if f[n,z,x] then\n begin\n writeln('YES');\n Print(z,x);\n halt;\n end;\n writeln('NO');\nend;\n//===============================================================\nbegin\n readln(n,m,k);\n for i:=1 to m do readln(s[i],t[i],a[i]);\n qsort(1,m);\n DP;\nend.\n"}, {"source_code": "var m,n,key,i,j,k,s,max1,max2:longint;\n a,b:array[0..1000] of int64;\n f:array[0..100,0..100,0..200] of int64;\n p,v:array[0..100,0..100,0..200] of longint;\n c,max:int64;\n q,w:array[0..1000] of longint;\n\nprocedure swapi(var a,b:int64);\n var r:int64;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure swap(var a,b:longint);\n var r:longint;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure search(i,j,k:longint);\n begin\n if p[i,j,k]<>-1 then search(p[i,j,k],j-1,v[i,j,k]);\n if p[i,j,k]=-1 then\n writeln(w[i],' ',f[i,j,k])\n else\n writeln(w[i],' ',f[i,j,k]-f[p[i,j,k],j-1,v[i,j,k]]);\n end;\n\nbegin\n readln(n,m,key);\n for i:=1 to m do\n begin\n readln(a[i],b[i],q[i]);\n w[i]:=i;\n end;\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if q[i]>q[j] then\n begin\n swapi(a[i],a[j]);\n swapi(b[i],b[j]);\n swap(q[i],q[j]);\n swap(w[i],w[j]);\n end;\n fillchar(f,sizeof(f),0);\n fillchar(p,sizeof(p),0);\n fillchar(v,sizeof(v),0);\n for i:=0 to b[1]-a[1] do\n begin\n f[1,1,i]:=i+a[1];\n p[1,1,i]:=-1;\n v[1,1,i]:=-1;\n end;\n for i:=2 to m do\n begin\n for j:=0 to b[i]-a[i] do\n begin\n f[i,1,j]:=j+a[i];\n p[i,1,j]:=-1;\n v[i,1,j]:=-1;\n end;\n for j:=2 to n do\n for k:=1 to i-1 do\n for s:=0 to b[k]-a[k] do\n begin\n if p[k,j-1,s]=0 then continue;\n c:=s+a[k]+key;\n if (c>=a[i]) and (c<=b[i]) then\n if f[k,j-1,s]+c>f[i,j,c-a[i]] then\n begin\n f[i,j,c-a[i]]:=f[k,j-1,s]+c;\n p[i,j,c-a[i]]:=k;\n v[i,j,c-a[i]]:=s;\n end;\n c:=(s+a[k])*key;\n if (c>=a[i]) and (c<=b[i]) then\n if f[k,j-1,s]+c>f[i,j,c-a[i]] then\n begin\n f[i,j,c-a[i]]:=f[k,j-1,s]+c;\n p[i,j,c-a[i]]:=k;\n v[i,j,c-a[i]]:=s;\n end;\n end;\n end;\n max1:=0;\n max2:=0;\n max:=0;\n for i:=1 to m do\n for j:=0 to b[i]-a[i] do\n if f[i,n,j]>max then\n begin\n max:=f[i,n,j];\n max1:=i;\n max2:=j;\n end;\n if max=0 then writeln('NO') else\n begin\n writeln('YES');\n search(max1,n,max2);\n end;\nend."}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n inf:int64=100000000000000000;\nvar\n f:array[0..55,0..55,0..555]of int64;\n py,px:array[0..55,0..55,0..555]of longint;\n pxx,pyy,xx,yy,q,tmp,kr,i,j,k,n,m,tk:longint;\n max,ti,tt:int64;\n r2,a,b:array[0..500500]of int64;\n r1,nom,c:array[0..500500]of longint;\n\nbegin\n read(n,m,tk);\n for i:=1 to m do read(a[i],b[i],c[i]);\n for i:=1 to m do nom[i]:=i;\n for i:=1 to m-1 do\n for j:=1 to m-1 do\n if (c[j]>c[j+1])then begin\n ti:=a[j];a[j]:=a[j+1];a[j+1]:=ti;\n ti:=b[j];b[j]:=b[j+1];b[j+1]:=ti;\n tmp:=c[j];c[j]:=c[j+1];c[j+1]:=tmp;\n tmp:=nom[j];nom[j]:=nom[j+1];nom[j+1]:=tmp;\n end;\n fillchar(f,sizeof(f),$0);\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n f[1][j][k]:=k+a[j];\n for i:=1 to n-1 do\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[i][j][k]<>0)then begin\n tt:=a[j]+k+tk;\n for q:=j+1 to m do\n if (tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n tt:=a[j]+k;\n if (tt>inf/tk)then continue;\n tt:=tt*tk;\n for q:=j+1 to m do\n if (tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n end;\n max:=-1;\n xx:=0;\n yy:=0;\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[n][j][k]>max)then begin\n max:=f[n][j][k];\n xx:=j;yy:=k;\n end;\n if (max<1)then begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n for i:=n downto 1 do begin\n inc(kr);\n r1[kr]:=nom[xx];\n r2[kr]:=a[xx]+yy;\n pxx:=px[i][xx][yy];\n pyy:=py[i][xx][yy];\n xx:=pxx;\n yy:=pyy;\n end;\n for i:=kr downto 1 do writeln(r1[i],' ',r2[i]);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n inf:int64=100000000000000000;\nvar\n f:array[0..55,0..55,0..555]of int64;\n py,px:array[0..55,0..55,0..555]of longint;\n pxx,pyy,xx,yy,q,tmp,kr,i,j,k,n,m,tk:longint;\n max,ti,tt:int64;\n r2,a,b:array[0..500500]of int64;\n r1,nom,c:array[0..500500]of longint;\n\nbegin\n read(n,m,tk);\n for i:=1 to m do read(a[i],b[i],c[i]);\n for i:=1 to m do nom[i]:=i;\n for i:=1 to m-1 do\n for j:=1 to m-1 do\n if (c[j]>c[j+1])then begin\n ti:=a[j];a[j]:=a[j+1];a[j+1]:=ti;\n ti:=b[j];b[j]:=b[j+1];b[j+1]:=ti;\n tmp:=c[j];c[j]:=c[j+1];c[j+1]:=tmp;\n tmp:=nom[j];nom[j]:=nom[j+1];nom[j+1]:=tmp;\n end;\n fillchar(f,sizeof(f),$0);\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j]+1)do\n f[1][j][k]:=k+a[j];\n for i:=1 to n-1 do\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j]+1)do\n if (f[i][j][k]<>0)then begin\n tt:=a[j]+k;\n for q:=j+1 to m do\n if (tt+tk>=a[q])and(tt+tk<=b[q])and(f[i][j][k]+tt+tk>f[i+1][q][longint(tt+tk-a[q])])\n then begin\n f[i+1][q][longint(tt+tk-a[q])]:=f[i][j][k]+tt+tk;\n px[i+1][q][longint(tt+tk-a[q])]:=j;\n py[i+1][q][longint(tt+tk-a[q])]:=k;\n end;\n if (tt>inf/tk)then continue;\n for q:=j+1 to m do\n if (tt*tk>=a[q])and(tt*tk<=b[q])and(f[i][j][k]+tt*tk>f[i+1][q][longint(tt*tk-a[q])])\n then begin\n f[i+1][q][longint(tt*tk-a[q])]:=f[i][j][k]+tt*tk;\n px[i+1][q][longint(tt*tk-a[q])]:=j;\n py[i+1][q][longint(tt*tk-a[q])]:=k;\n end;\n end;\n max:=-1;\n xx:=0;\n yy:=0;\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j]+1)do\n if (f[n][j][k]>max)then begin\n max:=f[n][j][k];\n xx:=j;yy:=k;\n end;\n if (max<1)then begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n for i:=n downto 1 do begin\n inc(kr);\n r1[kr]:=nom[xx];\n r2[kr]:=a[xx]+yy;\n pxx:=px[i][xx][yy];\n pyy:=py[i][xx][yy];\n xx:=pxx;\n yy:=pyy;\n end;\n for i:=kr downto 1 do writeln(r1[i],' ',r2[i]);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\ntype\n int64=qword;\nconst\n inf:int64=100000000000000000;\nvar\n f:array[0..55,0..55,0..555]of int64;\n py,px:array[0..55,0..55,0..555]of longint;\n pxx,pyy,xx,yy,q,tmp,kr,i,j,k,n,m,tk:longint;\n max,ti,tt:int64;\n r2,a,b:array[0..500500]of int64;\n r1,nom,c:array[0..500500]of longint;\n\nbegin\n read(n,m,tk);\n for i:=1 to m do read(a[i],b[i],c[i]);\n\n for i:=1 to m do nom[i]:=i;\n for i:=1 to m-1 do \n for j:=1 to m-1 do\n if (c[j]>c[j+1])then begin\n ti:=a[j];a[j]:=a[j+1];a[j+1]:=ti;\n ti:=b[j];b[j]:=b[j+1];b[j+1]:=ti;\n tmp:=c[j];c[j]:=c[j+1];c[j+1]:=tmp;\n tmp:=nom[j];nom[j]:=nom[j+1];nom[j+1]:=tmp;\n end;\n\n fillchar(f,sizeof(f),$0);\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n f[1][j][k]:=k+a[j];\n\n for i:=1 to n-1 do\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[i][j][k]<>0)then begin\n tt:=a[j]+k+tk;\n for q:=j+1 to m do\n if (tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n tt:=a[j]+k;\n if (tt>inf/tk)then continue;\n tt:=tt*tk;\n for q:=j+1 to m do\n if (tt>=a[q])and(tt<=b[q])and(f[i][j][k]+tt>f[i+1][q][longint(tt-a[q])])\n then begin\n f[i+1][q][longint(tt-a[q])]:=f[i][j][k]+tt;\n px[i+1][q][longint(tt-a[q])]:=j;\n py[i+1][q][longint(tt-a[q])]:=k;\n end;\n end;\n\n max:=0;\n xx:=0;\n yy:=0;\n for j:=1 to m do\n for k:=0 to longint(b[j]-a[j])do\n if (f[n][j][k]>max)then begin\n max:=f[n][j][k];\n xx:=j;yy:=k;\n end;\n if (max<1)then begin\n writeln('NO');\n exit;\n end;\n kr:=0;\n writeln('YES');\n for i:=n downto 1 do begin\n inc(kr);\n r1[kr]:=nom[xx];\n r2[kr]:=a[xx]+yy;\n pxx:=px[i][xx][yy];\n pyy:=py[i][xx][yy];\n xx:=pxx;\n yy:=pyy;\n end;\n for i:=kr downto 1 do writeln(r1[i],' ',r2[i]);\nend.\n"}, {"source_code": "program task;\n//{$APPTYPE DELPHI}\n//{$APPTYPE CONSOLE}\n{$R-,S-,Q-,I-,O+}\n\nuses\n Math,\n SysUtils;\n\ntype kat=record\n a,b:int64;\n c:longint;\nend;\n\nvar n,m,k,i,jj,l,i1,i2:longint;\n j,kkl,lk,rip:int64;\n kk:array[1..100]of kat;\n least:array[1..100]of longint;\n res:array[1..100,1..50,0..100]of int64;\n\nfunction less(a,b:kat):boolean;\nbegin\n less:=(a.c=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(y,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n //assign(input,'input.txt');\n //assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}, {"source_code": "program task;\n//{$APPTYPE DELPHI}\n//{$APPTYPE CONSOLE}\n{$R-,S-,Q-,I-,O-}\n\nuses\n Math,\n SysUtils;\n\ntype kat=record\n a,b:int64;\n c,id:longint;\nend;\n\nvar n,m,k,i,jj,l,i1,i2:longint;\n j,kkl,lk,rip:int64;\n kk:array[1..100]of kat;\n least:array[1..100]of longint;\n res:array[1..100,1..50,0..100]of int64;\n\nfunction less(a,b:kat):boolean;\nbegin\n less:=(a.c=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\n lk:=kkl-int64(k);\n l:=1;\n while (not ok) and (l<=least[y]) do begin\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,x-1,lk-kk[l].a]<>0)and\n (res[y,x,z]=res[l,x-1,lk-kk[l].a]+kkl)then begin\n ok:=true;\n obr(x-1,l,lk-kk[l].a);\n writeln(kk[y].id,' ',z+kk[y].a);\n end;\n l:=l+1;\n end;\n end;\nend;\n\nbegin\n assign(input,'input.txt');\n assign(output, 'output.txt');\n init;\n readln(n,m,k);\n for i := 1 to m do\n kk[i].id := i;\n for i:=1to m do\n readln(kk[i].a,kk[i].b,kk[i].c);\n bubble;\n for i:=1 to m do begin\n kkl:=kk[i].a;\n j:=0;\n //jj:=1;\n while kkl<=kk[i].b do begin\n res[i,1,j]:=kkl;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[i,jj,j]);\n j:=j+1;\n kkl:=kkl+1;\n end;\n end;\n dls;\n for jj:=2 to n do begin\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while (kkl<=kk[i].b)do begin\n kkl:=j+kk[i].a;\n if kkl mod int64(k) = 0 then begin\n lk:=kkl div int64(k);\n for l:=1 to least[i] do\n if (lk>=kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n end;\n lk:=kkl-int64(k);\n for l:=1 to least[i] do\n if (lk >= kk[l].a)and(lk<=kk[l].b)and(res[l,jj-1,lk-kk[l].a]<>0)then\n res[i,jj,j]:=max(res[i,jj,j], res[l,jj-1,lk-kk[l].a]+kkl);\n kkl:=kkl+1;\n //writeln('res :', jj, ':',i, ':', j, ' is ', res[jj,i,j]);\n j:=j+1;\n end;\n end;\n end;\n rip:=0;\n i1:=0;\n i2:=0;\n for i:=1to m do begin\n kkl:=kk[i].a;\n j:=0;\n while(kkl<=kk[i].b)do begin\n rip:=max(rip,res[i,n,j]);\n if rip=res[i,n,j] then begin\n i1:=i;\n i2:=j;\n end;\n j:=j+1;\n kkl:=kkl+1;\n end\n end;\n if rip = 0 then writeln('NO') else begin\n writeln('YES');\n //writeln(rip,' ',i1, ' ',i2);\n obr(n, i1, i2);\n end;\n halt(0)\nend.\n"}, {"source_code": "const\n inf='reform.in';\n outf='reform.out';\nvar\n max:int64;\n i,j,l,n,m,k,p,mj,ml:longint;\n a,b,c,pos,ansj,ansl:array[0..100] of int64;\n f,pre,prej:array[0..50,0..50,0..100] of int64;\nprocedure swap(var x,y:int64);\nvar\n z:int64;\nbegin\n z:=x; x:=y; y:=z;\nend;\nprocedure qsort(s,t:longint);\nvar\n i,j,now:longint;\nbegin\n i:=s; j:=t; now:=c[(i+j)>>1];\n repeat\n while c[i]now do dec(j);\n if i<=j then begin\n swap(a[i],a[j]);\n swap(b[i],b[j]);\n swap(c[i],c[j]);\n swap(pos[i],pos[j]);\n inc(i); dec(j);\n end;\n until i>j;\n if s=a[p]) and ((a[j]+l) div k<=b[p]) and (f[i-1,p,(a[j]+l) div k-a[p]]>f[i,j,l]) then begin\n f[i,j,l]:=f[i-1,p,(a[j]+l) div k-a[p]];\n prej[i,j,l]:=p;\n pre[i,j,l]:=0;\n end;\n if (a[j]+l-k>=a[p]) and (a[j]+l-k<=b[p]) and (f[i-1,p,a[j]+l-k-a[p]]>f[i,j,l]) then begin\n f[i,j,l]:=f[i-1,p,a[j]+l-k-a[p]];\n prej[i,j,l]:=p;\n pre[i,j,l]:=1;\n end;\n end;\n if (f[i,j,l]>0) or (i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\n max:=-maxlongint;\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do if f[n,j,l]>max then max:=f[n,j,l];\n for i:=1 to m do\n for l:=0 to b[j]-a[j] do if max=f[n,j,l] then begin\n mj:=j; ml:=l;\n end;\n if max<=0 then writeln('NO') else begin\n writeln('YES');\n ansj[n]:=mj; ansl[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n ansj[i]:=prej[i+1,mj,ml];\n if pre[i+1,mj,ml]=1 then ansl[i]:=a[mj]+ml-k else ansl[i]:=(a[mj]+ml) div k;\n mj:=ansj[i];\n ml:=ansl[i]-a[mj];\n end;\n for i:=1 to n do writeln(pos[ansj[i]],' ',ansl[i]);\n end;\nend.\n"}, {"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..100]of int64;\n pre,pp:array[0..50,0..50,0..100]of longint;\n a,b,c,num,anss,anst:array[0..50]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,min,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);min:=maxlongint;\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);\n if c[i]c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:longint):longint;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p]) then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do for l:=1 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=1 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx<=0 then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend."}, {"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..100]of int64;\n pre,pp:array[0..50,0..50,0..100]of longint;\n a,b,c,num,anss,anst:array[0..50]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,min,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);min:=maxlongint;\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);\n if c[i]c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:longint):longint;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p]) then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do for l:=1 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=1 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx=-maxlongint then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend."}, {"source_code": "program probcc;\n\nvar f:array[0..50,0..50,0..100]of int64;\n pre,pp:array[0..50,0..50,0..100]of longint;\n a,b,c,num,anss,anst:array[0..50]of int64;\n n,m,k,ml,mj,i,j,p,l:longint;maxx,min,t:int64;\n\nprocedure init;\nbegin\n //assign(input,'cc.in');reset(input);\n readln(n,m,k);min:=maxlongint;\n for i:=1 to m do begin\n readln(a[i],b[i],c[i]);\n if c[i]c[j] then begin\n t:=c[i];c[i]:=c[j];c[j]:=t;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n t:=b[i];b[i]:=b[j];b[j]:=t;\n t:=num[i];num[i]:=num[j];num[j]:=t;\n end;\nend;\n\nfunction max(a,b:longint):longint;\nbegin if a>b then exit(a) else exit(b);end;\n\nprocedure dp;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for l:=0 to b[j]-a[j] do begin\n f[i,j,l]:=0;\n for p:=1 to j-1 do if c[p]=a[p])and((a[j]+l)div k<=b[p]) then\n if f[i,j,l]=a[p])and(a[j]+l-k<=b[p]) then\n if f[i,j,l]0)or(i=1) then inc(f[i,j,l],a[j]+l) else f[i,j,l]:=-maxlongint;\n end;\nend;\n\nbegin\n init;\n dp;\n maxx:=-maxlongint;\n for j:=1 to m do for l:=0 to b[j]-a[j] do maxx:=max(f[n,j,l],maxx);\n for j:=1 to m do for l:=0 to b[j]-a[j] do if maxx=f[n,j,l] then begin\n mj:=j;ml:=l;\n end;\n if maxx<=0 then writeln('NO') else begin\n writeln('YES');\n anss[n]:=mj;anst[n]:=a[mj]+ml;\n for i:=n-1 downto 1 do begin\n anss[i]:=pre[i+1,mj,ml];\n if pp[i+1,mj,ml]=1 then anst[i]:=a[mj]+ml-k else anst[i]:=(a[mj]+ml) div k;\n mj:=anss[i];ml:=anst[i]-a[mj];\n end;\n for i:=1 to n do writeln(num[anss[i]],' ',anst[i]);\n end;\nend."}, {"source_code": "type tracer = record\ni,j,k:longint;\npr:longint;\nEnd;\n\ntype sub = record\na:int64;\nb:int64;\nvt:longint;\nc:longint;\nEnd;\n\nvar f1,f2:text;\nA:array[1..50] of sub;\nF:array[1..50,1..50,0..100] of int64;\nTR:array[1..50,1..50,0..100] of tracer;\nm,n,sk,i:longint;\n\nProcedure Partition(L,H:longint);\nvar i,j:longint;\n Pivot:longint;\n tg:sub;\nBegin\n if L>=H then Exit;\n pivot := A[Random(H-L+1)+L].c;\n i:=L; j:=H;\n Repeat\n while A[i].cPivot do dec(j);\n if i<=j then\n Begin\n If ij;\n Partition(L,j); Partition(i,H);\nEnd;\n\nFunction MT(i,j,k,pr:longint):tracer;\nBegin\n MT.i:=i;MT.j:=j;MT.k:=k;MT.pr:=pr;\nEnd;\n\nProcedure trace(i,j,k:longint);\nbegin\n if tr[i,j,k].i<>0 then\n trace(tr[i,j,k].i,tr[i,j,k].j,tr[i,j,k].k);\n writeln(f2,A[Tr[i,j,k].pr].vt,' ',A[j].a+k);\nENd;\n\nProcedure Process;\nvar i,j,k,l:longint;\nv:int64;\ns:int64;\nres:int64;\nvti,vtj,vtk:longint;\nBegin\n For i:=1 to m do\n for j:=0 to 100 do\n Begin\n F[1,i,j]:=j+a[i].a;\n TR[1,i,j].pr:=i;\n End;\n\n for i:=2 to n do\n begin\n for j:=1 to m do\n for k:=0 to a[j].b-a[j].a do\n begin\n for l:=1 to j-1 do\n Begin\n if A[l].c0) and (F[i,j,k]0) and (F[i,j,k]0 then\n Begin\n writeln(f2,'YES');\n trace(vti,vtj,vtk);\n End\n else\n writeln(f2,'NO');\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m,sk);\n for i:=1 to m do begin readln(f1,A[i].a,a[i].b,a[i].c); a[i].vt:=i; End;\n Partition(1,m);\n Process;\n close(f1);\n close(f2);\nEnd."}, {"source_code": "type tracer = record\ni,j,k:longint;\npr:longint;\nEnd;\n\ntype sub = record\na:int64;\nb:int64;\nvt:longint;\nc:longint;\nEnd;\n\nvar f1,f2:text;\nA:array[1..50] of sub;\nF:array[1..50,1..50,0..100] of int64;\nTR:array[1..50,1..50,0..100] of tracer;\nm,n,sk,i:longint;\n\nProcedure Partition(L,H:longint);\nvar i,j:longint;\n Pivot:longint;\n tg:sub;\nBegin\n if L>=H then Exit;\n pivot := A[Random(H-L+1)+L].c;\n i:=L; j:=H;\n Repeat\n while A[i].cPivot do dec(j);\n if i<=j then\n Begin\n If ij;\n Partition(L,j); Partition(i,H);\nEnd;\n\nFunction MT(i,j,k,pr:longint):tracer;\nBegin\n MT.i:=i;MT.j:=j;MT.k:=k;MT.pr:=pr;\nEnd;\n\nProcedure trace(i,j,k:longint);\nbegin\n if tr[i,j,k].i<>0 then\n trace(tr[i,j,k].i,tr[i,j,k].j,tr[i,j,k].k);\n writeln(f2,A[Tr[i,j,k].pr].vt,' ',A[j].a+k);\nENd;\n\nProcedure Process;\nvar i,j,k,l:longint;\nv:int64;\ns:int64;\nres:int64;\nvti,vtj,vtk:longint;\nBegin\n For i:=1 to m do\n for j:=0 to 100 do\n Begin\n F[1,i,j]:=j+a[i].a;\n TR[1,i,j].pr:=i;\n End;\n\n for i:=2 to n do\n begin\n for j:=1 to m do\n for k:=0 to a[j].b-a[j].a do\n begin\n if (i=4) and (j=5) and (k=39) then\n writeln('.');\n for l:=1 to j-1 do\n Begin\n if A[l].c0) and (F[i,j,k]0) and (F[i,j,k]0 then\n Begin\n writeln(f2,'YES');\n trace(vti,vtj,vtk);\n End\n else\n writeln(f2,'NO');\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,m,sk);\n for i:=1 to m do begin readln(f1,A[i].a,a[i].b,a[i].c); a[i].vt:=i; End;\n Partition(1,m);\n Process;\n close(f1);\n close(f2);\nEnd."}, {"source_code": "const fi='';//119c.inp';\n fo='';//119c.out';\n\ntype rec=record\n day,subj,exer:longint;\nend;\n rec1=record\n a,b:int64;\n c,cs:longint;\nend;\n\nvar f1:array[0..55,0..55,0..110] of int64;\n trace:array[0..55,0..55,0..110] of rec;\n n,m,k:longint;\n pt:array[1..55] of rec1;\n f:text;\n\n\nprocedure qs(dd,cc:longint);\nvar i,j:longint; kk,tg:rec1;\nbegin\n if dd>=cc then exit;\n i:=dd; j:=cc; kk:=pt[random(cc-dd+1)+dd];\n repeat\n begin\n while pt[i].ckk.c do dec(j);\n if i<=j then\n begin\n tG:=pt[i]; pt[i]:=pt[j]; pt[j]:=tg;\n inc(i); dec(j);\n end;\n end\n until i>j;\n qs(dd,j); qs(i,cc);\nend;\n\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n for i:=1 to m do\n with pt[i] do\n begin\n readln(f,a,b,c);\n cs:=i;\n end;\n qs(1,m);\n close(f);\nend;\n\n\nprocedure work;\nvar i,j,kk,l:longint; none:rec; sl,tg:int64;\nbegin\n none.day:=-1; none.subj:=-1; none.exer:=-1;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n begin\n f1[1,pt[i].cs,j]:=pt[i].a+j;\n trace[1,pt[i].cs,j]:=none;\n end;\n for i:=2 to n do\n for j:=1 to m do\n for kk:= 0 to pt[j].b-pt[j].a do\n begin\n sl:=pt[j].a+kk;\n if sl mod k =0 then\n for l:=1 to j-1 do\n if (pt[l].a<=sl div k) and (pt[l].b>=sl div k) then\n begin\n tg:=f1[i-1,l,sl div k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl>f1[i,j,kk] then\n begin\n f1[i,j,kk]:=tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:= sl div k-pt[l].a;\n end;\n end;\n if sl>=k then\n for l:=1 to j-1 do\n if (pt[l].a<=sl-k) and (pt[l].b>=sl-k) then\n begin\n tg:=f1[i-1,l,sl-k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl> f1[i,j,kk] then\n begin\n f1[i,j,kk] := tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:=sl-k- pt[l].a;\n end;\n end;\n end;\nend;\n\n\nprocedure truy_vet(x:rec);\nbegin\n if (trace[x.day,x.subj,x.exer].day<>-1) then\n truy_vet(trace[x.day,x.subj,x.exer]);\n writeln(f,pt[x.subj].cs,' ',pt[x.subj].a+x.exer);\nend;\n\n\nprocedure inkq;\nvar i,j:longint; res:int64; re:rec;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n if f1[n,i,j]>res then\n begin\n res:=f1[n,i,j];\n re.day:=n; re.subj:=i; re.exer:=j;\n end;\n if res=0 then writeln(f,'NO')\n else\n begin\n writeln(f,'YES');\n truy_vet(re);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n work;\n inkq;\nend.\n"}, {"source_code": "const fi='';//119c.inp';\n fo='';//119c.out';\n\ntype rec=record\n day,subj,exer:longint;\nend;\n rec1=record\n a,b:int64;\n c,cs:longint;\nend;\n\nvar f1:array[0..55,0..55,0..110] of int64;\n trace:array[0..55,0..55,0..110] of rec;\n n,m,k:longint;\n pt:array[1..55] of rec1;\n f:text;\n\n\nprocedure qs(dd,cc:longint);\nvar i,j:longint; kk,tg:rec1;\nbegin\n if dd>=cc then exit;\n i:=dd; j:=cc; kk:=pt[random(cc-dd+1)+dd];\n repeat\n begin\n while pt[i].ckk.c do dec(j);\n if i<=j then\n begin\n tG:=pt[i]; pt[i]:=pt[j]; pt[j]:=tg;\n inc(i); dec(j);\n end;\n end\n until i>j;\n qs(dd,j); qs(i,cc);\nend;\n\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n for i:=1 to m do\n with pt[i] do\n begin\n readln(f,a,b,c);\n cs:=i;\n end;\n qs(1,m);\n close(f);\nend;\n\n\nprocedure work;\nvar i,j,kk,l:longint; none:rec; sl,tg:int64;\nbegin\n none.day:=-1; none.subj:=-1; none.exer:=-1;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n begin\n f1[1,i,j]:=pt[i].a+j;\n trace[1,i,j]:=none;\n end;\n for i:=2 to n do\n for j:=1 to m do\n for kk:= 0 to pt[j].b-pt[j].a do\n begin\n sl:=pt[j].a+kk;\n if sl mod k =0 then\n for l:=1 to j-1 do\n if (pt[l].a<=sl div k) and (pt[l].b>=sl div k) then\n begin\n tg:=f1[i-1,l,sl div k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl>f1[i,j,kk] then\n begin\n f1[i,j,kk]:=tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:= sl div k-pt[l].a;\n end;\n end;\n if sl>=k then\n for l:=1 to j-1 do\n if (pt[l].a<=sl-k) and (pt[l].b>=sl-k) then\n begin\n tg:=f1[i-1,l,sl-k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl> f1[i,j,kk] then\n begin\n f1[i,j,kk] := tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:=sl-k- pt[l].a;\n end;\n end;\n end;\nend;\n\n\nprocedure truy_vet(x:rec);\nbegin\n if (trace[x.day,x.subj,x.exer].day<>-1) then\n truy_vet(trace[x.day,x.subj,x.exer]);\n writeln(f,x.subj,' ',pt[x.subj].a+x.exer);\nend;\n\n\nprocedure inkq;\nvar i,j:longint; res:int64; re:rec;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n if f1[n,i,j]>res then\n begin\n res:=f1[n,i,j];\n re.day:=n; re.subj:=i; re.exer:=j;\n end;\n if res=0 then writeln(f,'NO')\n else\n begin\n writeln(f,'YES');\n truy_vet(re);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n work;\n inkq;\nend."}, {"source_code": "const fi='';//119c.inp';\n fo='';//119c.out';\n\ntype rec=record\n day,subj,exer:longint;\nend;\n rec1=record\n a,b:int64;\n c,cs:longint;\nend;\n\nvar f1:array[0..55,0..55,0..110] of int64;\n trace:array[0..55,0..55,0..110] of rec;\n n,m,k:longint;\n pt:array[1..55] of rec1;\n f:text;\n\n\nprocedure qs(dd,cc:longint);\nvar i,j:longint; kk,tg:rec1;\nbegin\n if dd>=cc then exit;\n i:=dd; j:=cc; kk:=pt[random(cc-dd+1)+dd];\n repeat\n begin\n while pt[i].ckk.c do dec(j);\n if i<=j then\n begin\n tG:=pt[i]; pt[i]:=pt[j]; pt[j]:=tg;\n inc(i); dec(j);\n end;\n end\n until i>j;\n qs(dd,j); qs(i,cc);\nend;\n\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n for i:=1 to m do\n with pt[i] do\n begin\n readln(f,a,b,c);\n cs:=i;\n end;\n qs(1,m);\n close(f);\nend;\n\n\nprocedure work;\nvar i,j,kk,l:longint; none:rec; sl,tg:int64;\nbegin\n none.day:=-1; none.subj:=-1; none.exer:=-1;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n begin\n f1[1,pt[i].cs,j]:=pt[i].a+j;\n trace[1,pt[i].cs,j]:=none;\n end;\n for i:=2 to n do\n for j:=1 to m do\n for kk:= 0 to pt[j].b-pt[j].a do\n begin\n sl:=pt[j].a+kk;\n if sl mod k =0 then\n for l:=1 to j-1 do\n if (pt[j].c>pt[l].c) and (pt[l].a<=sl div k) and (pt[l].b>=sl div k) then\n begin\n tg:=f1[i-1,l,sl div k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl>f1[i,j,kk] then\n begin\n f1[i,j,kk]:=tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:= sl div k-pt[l].a;\n end;\n end;\n if sl>=k then\n for l:=1 to j-1 do\n if (pt[j].c>pt[l].c) and (pt[l].a<=sl-k) and (pt[l].b>=sl-k) then\n begin\n tg:=f1[i-1,l,sl-k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl> f1[i,j,kk] then\n begin\n f1[i,j,kk] := tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:=sl-k- pt[l].a;\n end;\n end;\n end;\nend;\n\n\nprocedure truy_vet(x:rec);\nbegin\n if (trace[x.day,x.subj,x.exer].day<>-1) then\n truy_vet(trace[x.day,x.subj,x.exer]);\n writeln(f,pt[x.subj].cs,' ',pt[x.subj].a+x.exer);\nend;\n\n\nprocedure inkq;\nvar i,j:longint; res:int64; re:rec;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n if f1[n,i,j]>res then\n begin\n res:=f1[n,i,j];\n re.day:=n; re.subj:=i; re.exer:=j;\n end;\n if res=0 then writeln(f,'NO')\n else\n begin\n writeln(f,'YES');\n truy_vet(re);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n work;\n inkq;\nend.\n"}, {"source_code": "const fi='';//119c.inp';\n fo='';//119c.out';\n\ntype rec=record\n day,subj,exer:longint;\nend;\n rec1=record\n a,b:int64;\n c,cs:longint;\nend;\n\nvar f1:array[0..55,0..55,0..110] of int64;\n trace:array[0..55,0..55,0..110] of rec;\n n,m,k:longint;\n pt:array[1..55] of rec1;\n f:text;\n\n\nprocedure qs(dd,cc:longint);\nvar i,j:longint; kk,tg:rec1;\nbegin\n if dd>=cc then exit;\n i:=dd; j:=cc; kk:=pt[random(cc-dd+1)+dd];\n repeat\n begin\n while pt[i].ckk.c do dec(j);\n if i<=j then\n begin\n tG:=pt[i]; pt[i]:=pt[j]; pt[j]:=tg;\n inc(i); dec(j);\n end;\n end\n until i>j;\n qs(dd,j); qs(i,cc);\nend;\n\n\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n for i:=1 to m do\n with pt[i] do\n begin\n readln(f,a,b,c);\n cs:=i;\n end;\n qs(1,m);\n close(f);\nend;\n\n\nprocedure work;\nvar i,j,kk,l:longint; none:rec; sl,tg:int64;\nbegin\n none.day:=-1; none.subj:=-1; none.exer:=-1;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n begin\n f1[1,pt[i].cs,j]:=pt[i].a+j;\n trace[1,pt[i].cs,j]:=none;\n end;\n for i:=2 to n do\n for j:=1 to m do\n for kk:= 0 to pt[j].b-pt[j].a do\n begin\n sl:=pt[j].a+kk;\n if sl mod k =0 then\n for l:=1 to j-1 do\n if (pt[j].c>pt[j].c) and (pt[l].a<=sl div k) and (pt[l].b>=sl div k) then\n begin\n tg:=f1[i-1,l,sl div k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl>f1[i,j,kk] then\n begin\n f1[i,j,kk]:=tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:= sl div k-pt[l].a;\n end;\n end;\n if sl>=k then\n for l:=1 to j-1 do\n if (pt[j].c>pt[l].c) and (pt[l].a<=sl-k) and (pt[l].b>=sl-k) then\n begin\n tg:=f1[i-1,l,sl-k-pt[l].a];//+sl;\n if tg>0 then\n if tg+sl> f1[i,j,kk] then\n begin\n f1[i,j,kk] := tg+sl;\n trace[i,j,kk].day:=i-1;\n trace[i,j,kk].subj:=l;\n trace[i,j,kk].exer:=sl-k- pt[l].a;\n end;\n end;\n end;\nend;\n\n\nprocedure truy_vet(x:rec);\nbegin\n if (trace[x.day,x.subj,x.exer].day<>-1) then\n truy_vet(trace[x.day,x.subj,x.exer]);\n writeln(f,pt[x.subj].cs,' ',pt[x.subj].a+x.exer);\nend;\n\n\nprocedure inkq;\nvar i,j:longint; res:int64; re:rec;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n for i:=1 to m do\n for j:=0 to pt[i].b-pt[i].a do\n if f1[n,i,j]>res then\n begin\n res:=f1[n,i,j];\n re.day:=n; re.subj:=i; re.exer:=j;\n end;\n if res=0 then writeln(f,'NO')\n else\n begin\n writeln(f,'YES');\n truy_vet(re);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n work;\n inkq;\nend.\n"}, {"source_code": "const\n{ fi='edu.inp';\n fo='edu.out';}\n fi='';\n fo='';\n maxn=111;\n\nvar\n f:text;\n a,b,c,ind:array[0..maxn]of int64;\n t1,t2,fx:array[0..maxn,0..maxn,0..maxn]of int64;\n k1,k2:array[0..maxn]of int64;\n n,m,k:longint;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yc[i2] then\n begin\n tmp:=a[i]+t-1-k;\n if (a[i2]<=tmp) and (tmp<=b[i2]) then\n if fx[i2,j-1,tmp-a[i2]+1]<>0 then\n if fx[i,j,t]0 then\n if fx[i,j,t]x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yc[i2] then\n begin\n tmp:=a[i]+t-1-k;\n if (a[i2]<=tmp) and (tmp<=b[i2]) then\n if fx[i,j,t]x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yc[i2] then\n begin\n tmp:=a[i]+t-1-k;\n if (a[i2]<=tmp) and (tmp<=b[i2]) then\n if fx[i,j,t]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n y:=d[i];\n d[i]:=d[j];\n d[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lb[i] then break;\n v[1,i,j]:=a[i]+j;\n end;\n\n for i:=1 to n-1 do\n for x:=1 to m-1 do\n for y:=x+1 to m do\n for j:=0 to 100 do\n begin\n\n if v[i,x,j]=0 then continue;\n if c[y]<=c[x] then continue;\n\n t:=v[i,x,j];\n\n g:=a[x]+int64(j);\n\n k1:=g+k;\n k2:=g*k;\n\n if (a[y]<=k1) and\n (k1<=b[y]) then begin\n if k1+t>v[i+1,y,k1-a[y]] then begin\n v[i+1,y,k1-a[y]]:=k1+t;\n w[i+1,y,k1-a[y]].x:=x;\n w[i+1,y,k1-a[y]].y:=j;\n end;\n end;\n if (a[y]<=k2) and\n (k2<=b[y]) then begin\n if k2+t>v[i+1,y,k2-a[y]] then begin\n v[i+1,y,k2-a[y]]:=k2+t;\n w[i+1,y,k2-a[y]].x:=x;\n w[i+1,y,k2-a[y]].y:=j;\n end;\n end;\n end;\n\n max:=0;\n for i:=1 to m do\n for j:=0 to 100 do\n if v[n,i,j]>max then begin\n max:=v[n,i,j];\n x:=i;\n y:=j;\n end;\n\n if max=0 then begin\n writeln('NO');\n halt;\n end;\n\n writeln('YES');\n tt(n,x,y);\n end."}, {"source_code": "program Csgd;\nconst\n fi = '';\n fo = '';\n nmax = 50;\n dmax = 100;\ntype\n mon = record\n a, b: int64;\n c: longint;\n i : longint;\n end;\nvar\n a: array[1..nmax, 1..nmax, 0..dmax] of int64;\n t, p: array[1..nmax, 1..nmax, 0..dmax] of longint;\n b: array[1..nmax] of mon;\n n, m, k: longint;\n sum: int64;\n mi, ai: longint;\n f1, f2: text;\n\n procedure openf;\n begin\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n end;\n\n procedure closef;\n begin\n close(f1); close(f2);\n end;\n\n procedure input;\n var\n i : longint;\n begin\n readln(f1, n, m, k);\n for i := 1 to m do\n begin\n readln(f1, b[i].a, b[i].b, b[i].c);\n b[i].i := i;\n b[i].b := b[i].b - b[i].a;\n end;\n end;\n\n procedure output;\n var\n i, tmp : longint;\n begin\n if sum = 0 then\n write(f2, 'NO')\n else\n begin\n writeln(f2, 'YES');\n for i := 1 to n do\n begin\n writeln(b[mi].i, ' ', ai + b[mi].a);\n tmp := t[i, mi, ai];\n ai := p[i, mi, ai];\n mi := tmp;\n end;\n end;\n end;\n\n procedure sort(i, j: longint);\n var\n l, r: longint;\n x: longint;\n y: mon;\n begin\n l := i;\n r := j;\n x := b[random(r - l + 1) + l].c;\n repeat\n while b[l].c < x do inc(l);\n while b[r].c > x do dec(r);\n if l <= r then\n begin\n if l < r then\n begin\n y := b[l];\n b[l] := b[r];\n b[r] := y;\n end;\n inc(l);\n dec(r);\n end;\n until l > r;\n if l < j then sort(l, j);\n if i < r then sort(i, r);\n end;\n\n procedure process;\n var\n i, j, l, u, v: longint;\n ttt, tmp: int64;\n begin\n sort(1, m);\n for j := 1 to m do\n for l := 0 to b[j].b do\n a[n, j, l] := b[j].a + l;\n for i := n - 1 downto 1 do\n for j := m downto i do\n for l := 0 to b[j].b do\n begin\n tmp := 0;\n for u := m downto j + 1 do\n if b[j].c < b[u].c then\n begin\n ttt := (b[j].a + l) + k - (b[u].a);\n v := ttt;\n if (v >= 0) and (v <= b[u].b) and (tmp < a[i + 1, u, v]) then\n begin\n tmp := a[i + 1, u, v];\n t[i, j, l] := u;\n p[i, j, l] := v;\n end;\n ttt := (b[j].a + l) * k - (b[u].a);\n v := ttt;\n if (v >= 0) and (v <= b[u].b) and (tmp < a[i + 1, u, v]) then\n begin\n tmp := a[i + 1, u, v];\n t[i, j, l] := u;\n p[i, j, l] := v;\n end;\n end;\n if tmp > 0 then\n a[i, j, l] := tmp + b[j].a + l\n else\n a[i, j, l] := 0;\n end;\n sum := 0;\n for j := 1 to m do\n for l := 0 to b[j].b do\n if sum < a[1, j, l] then\n begin\n sum := a[1, j, l];\n mi := j;\n ai := l;\n end;\n end;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}], "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9"} {"source_code": "{$Mode objfpc}\n\nconst\n maxN= 100;\n base= 1000000007;\n\nvar\n c, f, res: array[0.. maxN, 0.. maxN* maxN] of int64;\n d: array[0.. maxN, 0.. maxN, 0.. maxN] of int64;\n i, j, k, g, n, z: integer;\n m: int64;\n\nfunction power(x, y: int64): int64;\nvar\n t: int64;\nbegin\n if y= 1 then exit(x mod base);\n t:= power(x, y div 2);\n if odd(y) then result:= ( (t* t) mod base )* x mod base else\n result:= t* t mod base;\t\nend;\n\nbegin\n// assign(input, '144d.in'); reset(input);\n\n readln(n, m, k);\n if k> sqr(n) div 2 then k:= sqr(n)- k;\n for i:= 0 to n do c[i, 0]:= 1;\n for i:= 1 to n do\n for j:= 1 to i do c[i, j]:= (c[i- 1, j]+ c[i- 1, j- 1]) mod base;\n\n for i:= 0 to n do\n for j:= 0 to i do\n begin\n d[i, j, 1]:= power(c[i, j], m div n+ 1);\n d[i, j, 2]:= power(c[i, j], m div n);\n end;\n res[0, 0]:= 1;\n z:= m mod n;\n for i:= 1 to n do\n for j:= 0 to k do\n begin\n f[i, j]:= 0;\n for g:= 0 to n do if j>= g then\n begin\n if i<= z then res[i, j]:= (res[i, j] + d[n, g, 1]* res[i- 1, j- g] ) mod base else\n res[i, j]:= (res[i, j]+ d[n, g, 2]* res[i- 1, j- g]) mod base\n end else break;\n end;\n writeln(res[n, k]);\nend.\n", "positive_code": [{"source_code": "uses math;\nconst md=1000000007;\nvar mc,ma,ma1:array[-2..102,-2..102] of int64;\n dp:array[-2..102,-2..10005] of int64;\n i,j,g:longint;\n n,m,k,x,y,t:int64;\nfunction f(a,b:int64):int64;\nvar p,r:int64;\nbegin\n if b=0 then exit(1);\n p:=f(a,b shr 1);\n r:=(p*p) mod md;\n if b and 1=1 then r:=(r*a) mod md;\n f:=r;\nend;\nbegin\n readln(n,m,k);\n mc[0,0]:=1;\n for i:=1 to n do\n for j:=0 to i do\n mc[i,j]:=(mc[i-1,j]+mc[i-1,j-1]) mod md;\n x:=m div n;\n y:=m mod n;\n for j:=0 to n do\n begin\n ma[n,j]:=f(mc[n,j],x);\n ma1[n,j]:=(ma[n,j]*mc[n,j]) mod md;\n end;\n dp[0,0]:=1;\n for i:=1 to n do\n for j:=0 to min(i*n,k) do\n for g:=max(0,j-n) to min((i-1)*n,j) do\n begin\n if y= sqr( n ) then k := sqr( n ) - k;\n for i := 0 to n do c[i][0] := 1;\n for i := 1 to n do\n for j := 1 to i do\n c[i][j] := ( c[i - 1][j] + c[i - 1][j - 1] ) mod baseD;\n for i := 0 to n do\n for j := 0 to i do\n begin\n d1[i][j] := power( c[i][j] , m div n + 1 );\n d2[i][j] := power( c[i][j] , m div n );\n end;\n f[0][0] := 1; t := m mod n;\n for i := 1 to n do\n for j := 0 to k do\n begin\n if j > n then nn := n else nn := j;\n for p := 0 to nn do\n if i <= t then\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d1[n][p] ) mod baseD\n else\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d2[n][p] ) mod baseD;\n end;\n writeln( f[n][k] );\nend.\n"}, {"source_code": "{$mode objfpc}\n{$R-,Q-,H-,S-,I-}\n\n\nconst InputFile = 'Table.inp';\n maxN = 100;\n maxK = maxN * maxN;\n baseD = trunc( 1E9 ) + 7;\n\n\ntype Int = int64;\n\n\nvar n , k , i , j : integer;\n p , t , nn : integer;\n m : int64;\n f , c , d1 , d2 : array [0 .. maxN , 0 .. maxK] of Int;\n\n\nfunction Power( const a , b : Int ) : Int;\n var t : Int;\n begin\n if b = 0 then exit( 1 );\n if b = 1 then exit( a );\n t := Power( a , b div 2 );\n result := ( t * t ) mod baseD;\n if odd( b ) then result := ( result * a ) mod baseD;\n end;\n\n\n\nbegin\n readln( n , m , k );\n if 2 * k >= sqr( n ) then k := sqr( n ) - k;\n for i := 0 to n do c[i][0] := 1;\n for i := 1 to n do\n for j := 1 to i do\n c[i][j] := ( c[i - 1][j] + c[i - 1][j - 1] ) mod baseD;\n for i := 0 to n do\n for j := 0 to i do\n begin\n d2[i][j] := power( c[i][j] , m div n );\n //d1[i][j] := power( c[i][j] , m div n + 1 );\n d1[i][j] := ( d2[i][j] * c[i][j] ) mod baseD;\n end;\n f[0][0] := 1; t := m mod n;\n for i := 1 to n do\n for j := 0 to k do\n begin\n if j > n then nn := n else nn := j;\n for p := 0 to nn do\n if i <= t then\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d1[n][p] ) mod baseD\n else\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d2[n][p] ) mod baseD;\n end;\n writeln( f[n][k] );\nend.\n"}, {"source_code": "var b:array[0..100] of int64;\nvar a:array[0..100,0..10000] of int64;\nvar c,d:array[0..100] of int64;\nvar i,j,n,k,x,m1,o,h:longint;\nvar m,ans,t,s,p,q:int64;\nfunction mi(x,y:int64):int64;\nvar d:array[1..70] of int64;\nvar s,ad:longint;\nvar mii:int64;\nbegin\nd[1]:=x;\ns:=trunc(ln(y)/ln(2))+1;\nmii:=1;\nfor ad:=2 to s do d[ad]:=d[ad-1]*d[ad-1] mod o;\nfor ad:=1 to s do\nbegin\nif y mod 2=1 then mii:=mii*d[ad] mod o;\ny:=y div 2;\nend;\nmi:=mii;\nend;\nfunction max(a,b:int64):int64;\nbegin\nif a>b then exit(a)\nelse exit(b);\nend;\nbegin\n\n readln(n,m,k);\n if k>n*n div 2 then k:=n*n-k;\n x:=(m-1) mod n+1;\n o:=1000000007;\n b[0]:=1;\n m1:=trunc(ln(o)/ln(2))+1;\n p:=1;\n q:=1;\n for i:=1 to n do\n begin\n p:=p*(n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n b[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then b[i]:=b[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n for i:=0 to n do d[i]:=mi(b[i],(m-1) div n);\n for i:=0 to n do c[i]:=d[i]*b[i] mod o;\n fillchar(a,sizeof(a),0);\n for i:=0 to n do a[1,i]:=c[i];\n for i:=2 to x do\n for j:=0 to k do\n for h:=max(j-n,0) to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*c[j-h]) mod o;\n for i:=x+1 to n do\n for j:=0 to k do\n for h:=max(j-n,0) to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*d[j-h]) mod o;\n ans:=a[n,k];\n if k=0 then ans:=1;\n write(ans);\n\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5)+111;\nmd = round(1e9)+7;\nvar\ni,j,l,n,k : longint;\nm,mdd : int64;\ndp,c : array [0..101,0..101] of int64;\nans : array [0..101,0..10010] of int64;\ncalc : array [1..101] of int64;\n\nfunction pow (x : int64;p : int64) : int64;\nvar\nres : int64;\nbegin\n res:=1;\n while p<>0 do\n begin\n if odd (p) then res:=(res*x) mod md;\n x:=(x*x) mod md;\n p:=p shr 1;\n end;\n pow:=res mod md;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n fillchar (c,sizeof(c),0);\n mdd:=int64(md)*int64(md);\n for i:=0 to 100 do c [i,0]:=1;\n for i:=1 to 100 do\n for j:=1 to i do c [i,j]:=(c [i-1,j-1]+c [i-1,j]) mod md;\n readln (n,m,k);\n for i:=1 to n do\n begin\n calc [i]:=m div n;\n if m mod n>=i then inc (calc [i]);\n end;\n for i:=1 to n do\n for j:=0 to n do dp [i,j]:=pow (c [n,j],calc [i]);\n\n for i:=0 to n do ans [i,0]:=1;\n for i:=1 to n do\n for j:=1 to min(k,i*n) do\n begin\n for l:=0 to min(n,j) do\n begin\n ans [i,j]:=ans [i,j]+ans [i-1,j-l]*dp [i,l];\n while ans [i,j]>mdd do ans [i,j]:=ans [i,j] - mdd;\n end;\n ans [i,j]:=ans [i,j] mod md;\n end;\n writeln (ans [n,k]);\nend.\n"}, {"source_code": "{$apptype console}\n{$maxstacksize 5000000}\n{$b-}\nconst md=1000000007;\nvar\n p,i,j,n,k:integer;\n st,m:int64;\n mdd:int64;\n a:array[0..101,0..101] of integer;\n b:array[1..101,0..101] of int64;\n dp:array[1..101,0..10001] of int64;\n\n Function power(v,s:int64):int64;\n var\n qq:int64;\n begin\n if s=0 then power:=1 else if s=1 then power:=v mod md else\n begin\n if s mod 2=0 then\n begin\n qq:=power(v,s div 2);\n power:=qq*qq mod md;\n end else power:=v*power(v,s-1) mod md;\n end;\n end;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(n,m,k);\n mdd:=int64(md)*int64(md);\n Fillchar(a,sizeof(a),0);\n for i := 0 to n do a[i,0]:=1;\n for i := 1 to n do\n for j := 1 to i do a[i,j]:=(a[i-1,j-1]+a[i-1,j]) mod md;\n\n Fillchar(b,sizeof(b),0);\n for i := 1 to n do\n begin\n st:=((m-i) div n)+1;\n for j := 0 to n do\n b[i,j]:=power(a[n,j],st);\n end;\n\n Fillchar(dp,sizeof(dp),0);\n for i := 0 to n do dp[1,i]:=b[1,i];\n for i := 2 to n do\n for j := 0 to k do\n begin\n for p := 0 to n do\n begin\n if (j-p<0) then break;\n dp[i,j]:=(dp[i,j]+dp[i-1,j-p]*b[i,p]);\n while dp[i,j]>mdd do dp[i,j]:=dp[i,j]-mdd;\n\n end;\n dp[i,j]:=dp[i,j] mod md;\n end;\n writeln(dp[n,k] mod md);\nend."}, {"source_code": "{$apptype console}\n{$maxstacksize 5000000}\n{$b-}\nconst md=1000000007;\nvar\n p,i,j,n,k:integer;\n st,m:int64;\n mdd:int64;\n a:array[0..101,0..101] of integer;\n b:array[1..101,0..101] of int64;\n dp:array[1..101,0..10001] of int64;\n\n Function power(v,s:int64):int64;\n var\n qq:int64;\n begin\n if s=0 then power:=1 else if s=1 then power:=v mod md else\n begin\n if s mod 2=0 then\n begin\n qq:=power(v,s div 2);\n power:=qq*qq mod md;\n end else power:=v*power(v,s-1) mod md;\n end;\n end;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(n,m,k);\n mdd:=int64(md)*int64(md);\n Fillchar(a,sizeof(a),0);\n for i := 0 to n do a[i,0]:=1;\n for i := 1 to n do\n for j := 1 to i do a[i,j]:=(a[i-1,j-1]+a[i-1,j]) mod md;\n\n Fillchar(b,sizeof(b),0);\n for i := 1 to n do\n begin\n st:=((m-i) div n)+1;\n for j := 0 to n do\n b[i,j]:=power(a[n,j],st);\n end;\n\n Fillchar(dp,sizeof(dp),0);\n for i := 0 to n do dp[1,i]:=b[1,i];\n for i := 2 to n do\n for j := 0 to k do\n begin\n for p := 0 to n do\n begin\n if (j-p<0) then break;\n dp[i,j]:=(dp[i,j]+dp[i-1,j-p]*b[i,p]);\n while dp[i,j]>mdd do dp[i,j]:=dp[i,j]-mdd;\n\n end;\n dp[i,j]:=dp[i,j] mod md;\n end;\n writeln(dp[n,k] mod md);\nend."}, {"source_code": "uses Math;\nconst\n fil='';\n fil2='';\n base=trunc(1e9)+7;\n maxn=100;\nvar\n n,k:longint; m:int64;\n c:array[-1..maxn,-1..maxn] of int64;\n dp:array[0..maxn,0..maxn*maxn] of longint;\n t:array[0..maxn,1..maxn] of int64;\nprocedure nhap;\nvar i,j:longint;\nbegin\n assign(input,fil); reset(input);\n assign(output,fil2); rewrite(output);\n readln(n,m,k);\n c[-1,-1]:=1;\n for i:=0 to n do\n for j:=0 to n do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1]) mod base;\nend;\nfunction pow(x,y:int64):int64;\nvar p:int64;\nbegin\n if y=0 then exit(1);\n p:=pow(x,y div 2);\n p:=(p*p) mod base;\n if odd(y) then p:=(p*x) mod base;\n exit(p);\nend;\nprocedure xuli;\nvar i,j,x:longint; y:int64;\nbegin\n for i:=1 to n do\n begin\n y:=(m-i+1) div n;\n if (m-i+1) mod n <> 0 then inc(y);\n for j:=0 to n do t[j,i]:=pow(c[n,j],y);\n end;\n dp[0,0]:=1;\n for i:=1 to n do\n for j:=0 to min(i*n,k) do\n for x:=0 to min(n,j) do\n dp[i,j]:=(dp[i,j]+dp[i-1,j-x]*t[x,i]) mod base;\n writeln(dp[n,k]);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "uses math;\nconst\n nmax = 101;\n modul = 1000000007;\nvar\n n,k:longint;\n m:int64;\n sl:Array[0..nmax] of int64;\n c:Array[0..nmax,0..nmax] of longint;\n f:Array[0..nmax,0..nmax*nmax] of int64;\n d:array[0..nmax,0..nmax] of int64;\nprocedure nhap;\nvar i,j,u,v:longint;\nbegin\n read(n,m,k);\n c[0][0]:=1;\n for i:=1 to n do for j:=0 to i do if (j=0)or(j=i) then c[i][j]:=1\n else c[i][j]:=(c[i-1][j-1]+c[i-1][j])mod modul;\n for i:=1 to n do sl[i]:=(((m-i)div n)+1);\nend;\nfunction mu(i,j:int64):int64;\nvar tg:int64;\nbegin\n if j=0 then exit(1);\n if j=1 then exit(i);\n tg:=mu(i,j div 2);\n tg:=(tg*tg)mod modul;\n if j mod 2=1 then tg:=(tg*i)mod modul;\n exit(tg);\nend;\nprocedure init;\nvar i,j:longint;\nbegin\n for i:=1 to n do for j:=0 to n do\n d[i][j]:=mu(c[n][j],sl[i]);\nend;\nprocedure xuly;\nvar i,j,u,v:longint;\nbegin\n init;\n f[0][0]:=1;\n for i:=0 to n-1 do for j:=0 to min(n*i,k) do if f[i][j]>0 then\n for u:=0 to min(n,k-j) do\n f[i+1][j+u]:=(f[i+1][j+u]+(f[i][j]*d[i+1][u])mod modul)mod modul;\n writeln(f[n][k]);\nend;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n nhap;\n xuly;\n close(input);\n close(output);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5)+111;\nmd = round(1e9)+7;\nvar\ni,j,l,n,k : longint;\nm,mdd : int64;\ndp,c : array [0..101,0..101] of int64;\nans : array [0..101,0..10010] of int64;\ncalc : array [1..101] of int64;\n\nfunction pow (x : int64;p : int64) : int64;\nvar\nres : int64;\nbegin\n res:=1;\n while p<>0 do\n begin\n if odd (p) then res:=(res*x) mod md;\n x:=(x*x) mod md;\n p:=p shr 1;\n end;\n pow:=res mod md;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n fillchar (c,sizeof(c),0);\n mdd:=int64(md)*int64(md);\n for i:=0 to 100 do c [i,0]:=1;\n for i:=1 to 100 do\n for j:=1 to i do c [i,j]:=(c [i-1,j-1]+c [i-1,j]) mod md;\n readln (n,m,k);\n for i:=1 to n do\n begin\n calc [i]:=m div n;\n if m mod n>=i then inc (calc [i]);\n end;\n for i:=1 to n do\n for j:=0 to n do dp [i,j]:=pow (c [n,j],calc [i]);\n\n for i:=0 to n do ans [i,0]:=1;\n for i:=1 to n do\n for j:=1 to min(k,i*n) do\n begin\n for l:=0 to min(n,j) do\n begin\n ans [i,j]:=ans [i,j]+ans [i-1,j-l]*dp [i,l];\n while ans [i,j]>mdd do ans [i,j]:=ans [i,j] - mdd;\n end;\n ans [i,j]:=ans [i,j] mod md;\n end;\n writeln (ans [n,k]);\nend.\n"}, {"source_code": "uses math;\nconst module=1000000007;\nvar tt,tmp,i,j,n,t,k:longint;\n q,m:int64;\n c:array[0..110,0..110] of int64;\n f:array[0..110,0..10010] of int64;\n p1,p:array[0..11000] of int64;\n function pow(x,n:int64):int64;\n var q,res:int64;\n begin\n q:=x;\n res:=1;\n while n>0 do\n begin\n if n and int64(1)=int64(1) then res:=(res*q) mod module;\n q:=(q*q) mod module;\n n:=n div 2;\n end;\n pow:=res;\n end;\n\n function pow2(x,n:int64):int64;\n begin\n if n=0 then exit(1);\n if n mod 2=0 then begin x:=pow2(x,n div 2); exit((x*x) mod module); end\n else begin pow2:=(x*pow2(x,n-1)) mod module; exit; end;\n\n end;\n\n begin\n read(n,m,k);\n\n for i:=0 to 100 do\n c[i][0]:=1;\n\n for i:=1 to 100 do\n for j:=1 to 100 do\n c[i][j]:=(c[i-1][j]+c[i-1][j-1]) mod module;\n\n if (false) then\n begin\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do\n write(c[i][j]:4);\n writeln;\n end;\n halt(0);\n end;\n\n\n for i:=0 to n do\n p[i]:=pow(c[n][i],m div n);\n for i:=0 to n do\n p1[i]:=pow(c[n][i],(m div n)+1);\n\n tt:=m mod n;\n\n fillchar(f,sizeof(f),0);\n f[n+1][0]:=1;\n for i:=n downto 1 do\n for j:=0 to k do\n for t:=0 to min(j,n) do\n if f[i+1][j-t]<>0 then\n begin\n if i<=tt then q:=p1[t]\n else q:=p[t];\n f[i][j]:=(f[i][j]+f[i+1][j-t]*q) mod module;\n end;\n// writeln(tmp);\n if (false) then\n begin\n writeln;\n\n for i:=1 to n do\n begin\n for j:=1 to k do\n write(f[i][j]:4);\n writeln;\n end;\n\n end;\n\n writeln(f[1][k]);\n end."}, {"source_code": "const p:int64=1000000007;\n\nvar n,m,k,s,t:int64;\n i,j,x,y:longint;\n a:array[0..101] of int64;\n v,w:array[0..101,0..20001] of int64;\n\n\nfunction tt(x,y:int64):int64;\n begin\n if y=0 then tt:=1 mod p\n else\n if y=1 then tt:=x mod p\n else begin\n if y mod 2=0 then begin\n x:=tt(x,y div 2);\n tt:=x*x mod p;\n end\n else tt:=x*tt(x,y-1) mod p;\n end;\n end;\n\n begin\n read(n,m,k);\n\n a[0]:=1;\n for i:=1 to n do\n a[i]:=a[i-1]*int64(i) mod p;\n\n for i:=0 to n do\n begin\n s:=(a[n]*tt(a[i],p-2) mod p)*tt(a[n-i],p-2) mod p;\n\n t:=m div n;\n if m mod n>=i then t:=t+1;\n\n for j:=1 to n do\n begin\n t:=m div n;\n if m mod n>=int64(j) then t:=t+1;\n\n w[i,j mod n]:=tt(s,t);\n end;\n\n end;\n\n v[0,0]:=1;\n for i:=1 to n do\n begin\n\n for x:=0 to k do\n if v[i-1,x]>0 then begin\n for y:=0 to n do\n v[i,x+y]:=(v[i,x+y]+v[i-1,x]*w[y,i mod n]) mod p;\n end;\n\n end;\n\n writeln(v[n,k]);\n end."}, {"source_code": "const mo=1000000007;\n size=110;\nvar i,j,t,n,k:longint;\n m:int64;\n\t c,f,q:array[-1..size,-1..size*size] of int64;\nprocedure init;\nbegin \nreadln(n,m,k);\nend;\nfunction min(u,v:int64):int64;\nbegin \nif u>v then exit(v) else exit(u);\nend;\nfunction max(u,v:int64):int64;\nbegin \nif un*n then k:=n*n-k;\nend;\nfunction min(u,v:int64):int64;\nbegin \nif u>v then exit(v) else exit(u);\nend;\nfunction max(u,v:int64):int64;\nbegin \nif un*nn then exit(0);\n if f[n,k]=-1 then\n begin\n f[n,k]:=0;\n for i:=0 to min(nn,k) do f[n,k]:=(f[n,k]+dp(n-1,k-i)*p[nn,i,e[n]] mod 1000000007) mod 1000000007;\n end;\n exit(f[n,k]);\nend;\n\nbegin\n// assign(input,'chip.in'); reset(input); assign(output,''); rewrite(output);\n read(n,m,k); fillchar(c,sizeof(c),0); c[0,0]:=1; nn:=n; fillchar(f,sizeof(f),255);\n for i:=1 to n do\n begin\n if i>m mod n then e[i]:=1 else e[i]:=0;\n c[i,0]:=1; p[i,0,0]:=1; p[i,0,1]:=1;\n for j:=1 to n do\n begin\n c[i,j]:=(c[i-1,j-1]+c[i-1,j]) mod 1000000007; p[i,j,0]:=pwr(c[i,j],m div n+1); p[i,j,1]:=pwr(c[i,j],m div n);\n end;\n end;\n writeln(dp(n,k));\n// close(input); close(output);\nend.\n"}, {"source_code": "{$mode objfpc}\n{$R-,Q-,H-,S-,I-}\n\n\nconst InputFile = 'Table.inp';\n maxN = 100;\n maxK = maxN * maxN;\n baseD = trunc( 1E9 ) + 7;\n\n\ntype Int = int64;\n\n\nvar n , k , i , j : integer;\n p , t , nn : integer;\n m : int64;\n f , c , d1 , d2 : array [0 .. maxN , 0 .. maxK] of Int;\n\n\nfunction Power( const a , b : Int ) : Int;\n var t : Int;\n begin\n if b = 0 then exit( 1 );\n if b = 1 then exit( a );\n t := Power( a , b div 2 );\n result := ( t * t ) mod baseD;\n if odd( b ) then result := ( result * a ) mod baseD;\n end;\n\n\n\nbegin\n readln( n , m , k );\n if 2 * k >= sqr( n ) then k := sqr( n ) - k;\n for i := 0 to n do c[i][0] := 1;\n for i := 1 to n do\n for j := 1 to i do\n c[i][j] := ( c[i - 1][j] + c[i - 1][j - 1] ) mod baseD;\n for i := 0 to n do\n for j := 0 to i do\n begin\n d2[i][j] := power( c[i][j] , m div n );\n //d1[i][j] := power( c[i][j] , m div n + 1 );\n d1[i][j] := ( d2[i][j] * c[i][j] ) mod baseD;\n end;\n f[0][0] := 1; t := m mod n;\n for i := 1 to n do\n for j := 0 to k do\n begin\n if j > n then nn := n else nn := j;\n for p := 0 to nn do\n if i <= t then\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d1[n][p] ) mod baseD\n else\n f[i][j] := ( f[i][j] + f[i - 1][j - p] * d2[n][p] ) mod baseD;\n end;\n writeln( f[n][k] );\nend."}, {"source_code": "Program cf_probb;\nconst md=1000000007;\nVar c:array[0..100,0..100] of int64;\n d0,d1:array[0..100] of int64;\n mm:qword;\n i,j,k,l,m,n,low,high:longint;\n f:array[0..100,0..10000] of int64;\n\nfunction fastmul(base,time:int64):int64;\nvar ans:int64;\nbegin\nif time=0 then exit(1);\nans:=sqr(fastmul(base,time div 2)) mod md;\nif (time mod 2)=0 then exit(ans) else exit((ans*base) mod md);\nend;\n\n\nbegin\n readln(n,mm,m);\n c[1,0]:=1;c[1,1]:=1;\n for i:=2 to n do\n begin\n c[i,0]:=1;c[i,i]:=1;\n for j:=1 to i-1 do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1]) mod md;\n end;\n l:=mm mod n; //<=L:D1 >L:D0\n for i:=0 to n do d0[i]:=fastmul(c[n,i],mm div n);\n for i:=0 to n do d1[i]:=fastmul(c[n,i],mm div n+1);\n fillchar(f,sizeof(f),0);\n f[0,0]:=1;\n for i:=1 to n do\n begin\n if m-(n-i)*n>0 then low:=m-(n-i)*n else low:=0;\n if i*n0 then\n begin\n if i<=l then\n f[i,j]:=(f[i,j]+(f[i-1,j-k]*d1[k]) mod md) mod md\n else\n f[i,j]:=(f[i,j]+(f[i-1,j-k]*d0[k]) mod md) mod md;\n end;\n end;\n writeln(f[n,m]);\nend."}, {"source_code": "program problem2;\nuses math;\n\nconst d = 1000000007;\n\nfunction pow( a, p: qWord ): longWord;\nvar res: qWord;\nbegin\n res := 1;\n while ( p > 0 ) do\n begin\n if ( odd(p) ) then\n res := ( res * a ) mod d;\n\n a := ( a * a ) mod d;\n p := p div 2;\n end;\n\n pow := res;\nend;\n\nvar n, k, i, j, l: longWord;\n m: qWord;\n dp: array[ 0..100, 0..10000 ] of longWord;\n c: array[ 0..100, 0..100 ] of longWord;\n cPow: array[ 0..100, 0..1 ] of longWord;\n\nbegin\n fillchar( c, sizeOf(c), 0 );\n fillchar( dp, sizeOf(dp), 0 );\n\n readln( n, m, k );\n\n c[0][0] := 1;\n for i := 1 to n do\n begin\n c[i][0] := 1;\n for j := 1 to i do\n c[i][j] := ( c[i-1][j-1] + c[i-1][j] ) mod d;\n end;\n\n for i := 0 to n do\n begin\n cPow[i][0] := pow( c[n][i], ( m div n ) );\n cPow[i][1] := ( qWord( cPow[i][0] ) * c[n][i] ) mod d;\n end;\n\n dp[0][0] := 1;\n for i := 1 to ( m mod n ) do\n for j := 0 to k do\n for l := 0 to min( n, j ) do\n dp[i][j] := ( dp[i][j] + ( qWord(dp[i-1][j-l]) * cPow[l][1] ) ) mod d;\n for i := ( ( m mod n ) + 1 ) to n do\n for j := 0 to k do\n for l := 0 to min( n, j ) do\n dp[i][j] := ( dp[i][j] + ( qWord(dp[i-1][j-l]) * cPow[l][0] ) ) mod d;\n\n\n writeln( dp[n][k] );\nend.\n"}, {"source_code": "program Shablon;\n\n{$MODE DELPHI}\n\n\nuses\n SysUtils, Math;\n\nconst\n base = 1000000007;\n\nfunction sqrr(a, b : int64):int64;\nvar\n dega : int64;\nbegin\n if a = 1 then begin\n result := 1;\n exit;\n end;\n dega := a;\n result := 1;\n while b > 0 do begin\n if odd(b) then begin\n result := (result * dega) mod base;\n end;\n dega := (dega * dega) mod base;\n b := b shr 1;\n end;\nend;\n\nvar\n c : array[0..100, 0..100] of int64;\n d : array[0..100, 0..10000] of int64;\n kol : array[0..100] of int64;\n n, m, k, tmp : int64;\n i, j, t : integer;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(n, m, k);\n for i := 1 to n do begin\n kol[i] := (m div n);\n c[i][0] := 1;\n c[i][i] := 1;\n end;\n for i := 1 to m mod n do\n kol[i] := (kol[i] + 1);\n for i := 2 to n do\n for j := 1 to n - 1 do\n c[i][j] := (c[i - 1][j - 1] + c[i - 1][j]) mod base;\n\n d[0][0] := 1;\n for i := 0 to n - 1 do\n for t := 0 to n do begin\n tmp := sqrr(c[n][t], kol[i + 1]);\n for j := 0 to min(k - t, n * i) do begin\n d[i + 1][j + t] := (d[i + 1][j + t] + d[i][j] * tmp) mod base;\n end;\n end;\n write(d[n][k]);\n\nend.\n"}, {"source_code": "const md = 1000000007;\nvar n,m,k:int64;\ni,j,u:longint;\nc:array[0..1000,0..1000]of longint;\ncalc:array[0..1000]of int64;\ncf:array[0..4000]of longint;\npre:array[0..300,0..300]of longint;\ndp:array[0..300,0..10001]of longint;\nfunction st(a:longint; n:int64):int64;\nvar t:int64;\nbegin\n if n=0 then st:=1\n else\n begin\n if n mod 2=0 then\n begin\n t:=st(a,n div 2);\n t:=t*t mod md;\n st:=t;\n end\n else\n st:=(int64(a)*st(a,n-1)) mod md;\n end;\nend;\nfunction mult(a,b:int64):int64;\nbegin\n a:=a*b;\n a:=a mod md;\nend;\n begin\n readln(n,m,k);\n for i:=0 to 1000 do\n begin\n c[0,i]:=0;\n c[i,0]:=1;\n end;\n for i:=1 to 1000 do\n for j:=1 to 1000 do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1]) mod md;\n dp[0,0]:=1;\n for i:=1 to n do\n begin\n calc[i]:=m div n;\n if i<=m mod n then calc[i]:=calc[i]+1;\n end;\n\n for i:=1 to n do\n begin\n cf[i]:=cf[i-1]+n;\n if cf[i]>k then cf[i]:=k;\n end;\n for i:=0 to n do\n for j:=1 to n do\n pre[i,j]:=st(c[n,i],calc[j]);\n for i:=0 to n-1 do\n for j:=0 to cf[i+1] do\n if dp[i,j]>0 then\n begin\n for u:=0 to n do\n if (j+u>k) then break\n else\n begin\n dp[i+1,j+u]:=dp[i+1,j+u]+mult(dp[i,j],pre[u,i+1]);\n if dp[i+1,j+u]>=md then dp[i+1,j+u]:=dp[i+1,j+u]-md;\n end;\n end;\n writeln(dp[n,k]);\n end."}, {"source_code": "const base=1000000007;\nvar n,m,k,chot:int64;\n phanmu:array[1..100]of int64;\n mang:array[0..101,0..10000]of int64;\n tohop,tohopmanh:array[0..100,0..100]of int64;\n\nfunction power(x,y:int64):int64;\nvar we,tich:int64;\nbegin\n if x=0 then power:=0\n else if y=0 then power:=1\n else begin\n we:=power(x,y div 2);\n if y mod 2=0 then tich:=(we*we)mod base\n else begin\n tich:=(we*we)mod base;\n tich:=(tich*x)mod base;\n end;\n power:=tich;\n end;\nend;\n\nfunction min(ax,bx:int64):int64;\nbegin\n if ax((sqr(n))div 2)then k:=sqr(n)-k;\n chot:=(m mod n);\n ketqua:=tinh(1,k);\n writeln(ketqua);\nend;\n\nprocedure tinhtohop;\nvar i,j:longint;\nbegin\n for i:=0 to 100 do\n for j:=0 to 100 do\n if i0 do\n begin\n if y and 1=1 then res:=res*tmp mod base;\n tmp:=tmp*tmp mod base; y:=y shr 1;\n end;\n cal:=res;\nend;\n\nbegin\n readln(n,m,up);\n a[0]:=1; b[0]:=1; g[0,0]:=1; g[0,1]:=1;\n tot:=m div n;\n for i:=1 to n do\n begin\n a[i]:=a[i-1]*(n-i+1) mod base;\n b[i]:=b[i-1]*i mod base;\n t:=a[i]*cal(b[i],base-2) mod base;\n d[i]:=ord( (m>n)and(m mod n>=i) );\n g[i,0]:=cal(t,tot); g[i,1]:=g[i,0]*t mod base;\n end;\n f[0,0]:=1;\n for i:=0 to n-1 do\n for j:=0 to min(i*n,up) do\n if f[i,j]>0 then\n begin\n o:=i+1;\n for k:=0 to min(n,up-j) do\n begin\n f[o,j+k]:=f[o,j+k]+f[i,j]*g[k,d[o]];\n if f[o,j+k]>=base then f[o,j+k]:=f[o,j+k] mod base;\n end;\n end;\n writeln(f[n,up]);\nend.\n\n"}, {"source_code": "{$mode objfpc}\nuses math;\nconst\n fi = '';//'table.in';\n fo = '';//'table.out';\n r = 1000000007;\n maxn = 100;\n\nvar\n pthua: integer;\n m,n,k: qword;\n th,f,s1,s2: array[0..maxn,0..maxn*maxn] of qword;\n\nfunction luythua(i,j: qword):qword;\nvar tg:int64;\nbegin\n if j=0 then exit(1);\n if j=1 then exit(i);\n tg:=luythua(i,j div 2);\n tg:=(tg*tg)mod r;\n if j mod 2=1 then tg:=(tg*i)mod r;\n exit(tg);\nend;\n\nprocedure ktao;\nvar i,j,t: integer;tich: qword;\nbegin\n for i:=1 to n do\n begin\n th[i,0]:=1;\n th[i,i]:=1;\n for j:=1 to i-1 do th[i,j]:=(th[i-1,j]+th[i-1,j-1]) mod r;\n end;\n pthua:=m mod n;\n for i:=1 to n do\n for j:=0 to i do\n begin\n s1[i,j]:=luythua(th[i,j],m div n);\n s2[i,j]:=(s1[i,j]*th[i,j]) mod r;\n end;\n fillchar(f,sizeof(f),0);\n f[0,0]:=1;\n for i:=1 to n do\n for j:=0 to k do\n for t:=0 to min(n,j) do if f[i-1,j-t]>0 then\n begin\n if i<=pthua then tich:=s2[n,t] else tich:=s1[n,t];\n f[i,j]:=(f[i,j]+f[i-1,j-t]*tich) mod r;\n end;\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n readln(n,m,k);\n ktao;\n writeln(f[n,k]);\nend.\n"}, {"source_code": "uses math;\nconst md=1000000007;\n\nVar n,d,sum,k,i,j:longint;\nm:int64;\n f:array[0..101,0..100*101]of int64;\n c,st1,st2:array[0..101,0..101]of int64;\n ost,mult,ans:int64;\nfunction pow(a,b:int64):int64;\n begin\n if b=0 then exit(1);\n if b=1 then exit(a);\n if odd(b) then exit(pow(a,b-1)*a mod md);\n a:=a*a mod md;\n pow:=pow(a,b div 2);\n end;\n begin\n read(n,m,k);\n for i:=1 to n do\n begin\n c[i,0]:=1;\n c[i,i]:=1;\n for j:=1 to i-1 do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1])mod md;\n end;\n ost:=m mod n;\n for i:=1 to n do\n for j:=0 to i do\n begin\n st1[i,j]:=pow(c[i,j],m div n);\n st2[i,j]:=st1[i,j]*c[i,j] mod md;\n end;\n f[0,0]:=1;\n for i:=1 to n do\n for sum:=0 to k do\n for d:=0 to min(sum,n) do\n if f[i-1,sum-d]>0 then\n begin\n if i<=ost then mult:=st2[n,d]\n else mult:=st1[n,d];\n f[i,sum]:=(f[i,sum]+f[i-1,sum-d]*mult) mod md;\n end;\n ans:=0;\n ans:=f[n,k];\n Writeln(ans);\n end."}, {"source_code": "{$ Q-,R-,S-,I-,O+}\nuses math;\nvar f:array[1..100,0..10000] of int64;\n c:array[-1..100,-1..100] of int64;\n col:array[1..100,0..100] of int64;\n lol,vv,l,i,j,n,k:longint;\n q,pow,base,m:int64;\n\n function powmod(a,b:int64):int64;\n var tmp:int64;\n begin\n if b=1 then exit(a mod base);\n if b mod 2=0 then exit(sqr(powmod(a,b div 2)) mod base);\n if b mod 2=1 then begin tmp:=powmod(a,b-1); exit((a*tmp) mod base); end;\n end;\n\n begin\n readln(n,m,k);\n c[0][0]:=1;\n base:=1000000007;\n q:=n;\n for i:=0 to n do for j:=0 to n do if i+j>0 then c[i][j]:=(c[i-1][j-1]+c[i-1][j]) mod base;\n for i:=1 to n do\n for j:=0 to n do\n begin\n pow:=m div q;\n if (i<=m mod q) and (m mod q<>0) then pow:=pow+1;\n col[i][j]:=powmod(c[n][j],pow);\n end;\n if k>n then vv:=n else vv:=k;\n for i:=0 to vv do f[1][i]:=col[1][i];\n for i:=2 to n do\n begin\n lol:=min(i*n,k);\n for j:=0 to lol do\n for l:=0 to vv do if j-l>=0 then\n f[i][j]:=(f[i][j]+(f[i-1][j-l]*col[i][l]) mod base) mod base;\n end;\n writeln(f[n][k]);\n end.\n\n\n"}], "negative_code": [{"source_code": "uses math;\nconst\n nmax = 101;\n modul = 1000000007;\nvar\n n,k:longint;\n m:int64;\n sl:Array[0..nmax] of longint;\n c:Array[0..nmax,0..nmax] of longint;\n f:Array[0..nmax,0..nmax*nmax] of int64;\n d:array[0..nmax,0..nmax] of int64;\nprocedure nhap;\nvar i,j,u,v:longint;\nbegin\n read(n,m,k);\n c[0][0]:=1;\n for i:=1 to n do for j:=0 to i do if (j=0)or(j=i) then c[i][j]:=1\n else c[i][j]:=(c[i-1][j-1]+c[i-1][j])mod modul;\n for i:=1 to n do sl[i]:=(((m-i)div n)+1)mod modul;\nend;\nfunction mu(i,j:int64):int64;\nvar tg:int64;\nbegin\n if j=0 then exit(1);\n if j=1 then exit(i);\n tg:=mu(i,j div 2);\n tg:=(tg*tg)mod modul;\n if j mod 2=1 then tg:=(tg*i)mod modul;\n exit(tg);\nend;\nprocedure init;\nvar i,j:longint;\nbegin\n for i:=1 to n do for j:=0 to n do\n d[i][j]:=mu(c[n][j],sl[i]);\nend;\nprocedure xuly;\nvar i,j,u,v:longint;\nbegin\n init;\n f[0][0]:=1;\n for i:=0 to n-1 do for j:=0 to min(n*i,k) do if f[i][j]>0 then\n for u:=0 to min(n,k-j) do\n f[i+1][j+u]:=(f[i+1][j+u]+(f[i][j]*d[i+1][u])mod modul)mod modul;\n writeln(f[n][k]);\nend;\nbegin\n assign(input,'');reset(input);\n assign(output,'');rewrite(output);\n nhap;\n xuly;\n close(input);\n close(output);\nend.\n"}, {"source_code": "var b:array[0..10000] of int64;\nvar a:array[1..100,0..10000] of int64;\nvar c,d:array[0..70] of int64;\nvar i,j,n,k,x,m1,o,l,h:longint;\nvar m,ans,t,s,p,q:int64;\nfunction mi(x,y:int64):int64;\nvar d:array[1..70] of int64;\nvar s,ad:longint;\nvar mii:int64;\nbegin\nd[1]:=x;\ns:=trunc(ln(y)/ln(2))+1;\nmii:=1;\nfor ad:=2 to s do d[ad]:=d[ad-1]*d[ad-1] mod o;\nfor ad:=1 to s do\nbegin\nif y mod 2=1 then mii:=mii*d[ad] mod o;\ny:=y div 2;\nend;\nmi:=mii;\nend;\nbegin\n readln(n,m,k);\n x:=m-m div n*n;\n o:=1000000007;\n b[0]:=1;\n m1:=trunc(ln(o)/ln(2))+1;\n p:=1;\n q:=1;\n for i:=1 to k do\n begin\n p:=p*(n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n b[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then b[i]:=b[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n m1:=trunc(ln(m div n+1)/ln(2))+1;\n ans:=0;\n for l:=0 to k do\n begin\n fillchar(a,sizeof(a),0);\n for i:=0 to l do a[1,i]:=mi(b[i],m div n+1);\n for i:=2 to x do\n for j:=0 to l do\n for h:=0 to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*mi(b[j-h],m div n+1)) mod o;\n for i:=0 to k-l do a[x+1,i]:=mi(b[i],m div n);\n for i:=x+2 to n do\n for j:=0 to k-l do\n for h:=0 to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*mi(b[j-h],m div n)) mod o;\n ans:=(ans+a[x,l]*a[n,k-l]) mod o;\n end;\n write(ans);\nend."}, {"source_code": "var b:array[0..10000] of int64;\nvar a:array[0..100,0..10000] of int64;\nvar c,d:array[0..70] of int64;\nvar i,j,n,k,x,m1,o,l,h:longint;\nvar m,ans,t,s,p,q:int64;\nfunction mi(x,y:int64):int64;\nvar d:array[1..70] of int64;\nvar s,ad:longint;\nvar mii:int64;\nbegin\nd[1]:=x;\ns:=trunc(ln(y)/ln(2))+1;\nmii:=1;\nfor ad:=2 to s do d[ad]:=d[ad-1]*d[ad-1] mod o;\nfor ad:=1 to s do\nbegin\nif y mod 2=1 then mii:=mii*d[ad] mod o;\ny:=y div 2;\nend;\nmi:=mii;\nend;\nbegin\n readln(n,m,k);\n x:=m-m div n*n;\n o:=1000000007;\n b[0]:=1;\n m1:=trunc(ln(o)/ln(2))+1;\n p:=1;\n q:=1;\n for i:=1 to k do\n begin\n p:=p*(n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n b[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then b[i]:=b[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n m1:=trunc(ln(m div n+1)/ln(2))+1;\n ans:=0;\n for l:=0 to k do\n begin\n fillchar(a,sizeof(a),0);\n for i:=0 to l do a[1,i]:=mi(b[i],(m-1) div n+1);\n for i:=2 to x do\n for j:=0 to l do\n for h:=0 to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*mi(b[j-h],m div n+1)) mod o;\n for i:=0 to k-l do a[x+1,i]:=mi(b[i],(m-1) div n);\n for i:=x+2 to n do\n for j:=0 to k-l do\n for h:=0 to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*mi(b[j-h],(m-1) div n)) mod o;\n ans:=(ans+a[x,l]*a[n,k-l]) mod o;\n end;\n write(ans);\nend."}, {"source_code": "var b:array[0..100] of int64;\nvar a:array[0..100,0..10000] of int64;\nvar c,d:array[0..100] of int64;\nvar i,j,n,k,x,m1,o,h:longint;\nvar m,ans,t,s,p,q:int64;\nfunction mi(x,y:int64):int64;\nvar d:array[1..70] of int64;\nvar s,ad:longint;\nvar mii:int64;\nbegin\nd[1]:=x;\ns:=trunc(ln(y)/ln(2))+1;\nmii:=1;\nfor ad:=2 to s do d[ad]:=d[ad-1]*d[ad-1] mod o;\nfor ad:=1 to s do\nbegin\nif y mod 2=1 then mii:=mii*d[ad] mod o;\ny:=y div 2;\nend;\nmi:=mii;\nend;\nfunction max(a,b:int64):int64;\nbegin\nif a>b then exit(a)\nelse exit(b);\nend;\nbegin\n\n readln(n,m,k);\n x:=m-m div n*n;\n o:=1000000007;\n b[0]:=1;\n m1:=trunc(ln(o)/ln(2))+1;\n p:=1;\n q:=1;\n for i:=1 to n do\n begin\n p:=p*(n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n b[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then b[i]:=b[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n for i:=0 to n do d[i]:=mi(b[i],(m-1) div n);\n for i:=0 to n do c[i]:=d[i]*b[i] mod o;\n fillchar(a,sizeof(a),0);\n for i:=0 to n do a[1,i]:=c[i];\n for i:=2 to x do\n for j:=0 to k do\n for h:=max(j-n,0) to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*c[j-h]) mod o;\n for i:=x+1 to n do\n for j:=0 to k do\n for h:=max(j-n,0) to j do\n a[i,j]:=(a[i,j]+a[i-1,h]*d[j-h]) mod o;\n ans:=a[n,k] mod o;\n if k=0 then ans:=1;\n write(ans);\n\nend.\n"}, {"source_code": "var a,b:array[0..10000] of int64;\nvar c,d:array[0..70] of int64;\nvar i,j,n,k,x,m1,o:longint;\nvar m,ans,t,s,p,q:int64;\nbegin\n\n readln(n,m,k);\n x:=m-m div n*n;\n c[0]:=1;\n d[0]:=1;\n o:=1000000007;\n m1:=trunc(ln(o)/ln(2))+1;\n a[0]:=1;\n b[0]:=1;\n p:=1;\n q:=1;\n for i:=1 to k do\n begin\n p:=p*(x*n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n a[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then a[i]:=a[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n p:=1;\n q:=1;\n for i:=1 to k do\n begin\n p:=p*((n-x)*n-i+1) mod o;\n q:=q*i mod o;\n s:=o-2;\n b[i]:=p;\n c[1]:=q;\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then b[i]:=b[i]*c[j] mod o;\n s:=s div 2;\n end;\n end;\n m1:=trunc(ln(m div n+1)/ln(2))+1;\n for i:=0 to k do\n begin\n t:=1;\n c[1]:=a[i];\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n d[1]:=b[k-i];\n for j:=2 to m1 do d[j]:=d[j-1]*d[j-1] mod o;\n s:=m div n+1;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then t:=t*c[j] mod o;\n s:=s div 2;\n end;\n s:=m div n;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then t:=t*d[j] mod o;\n s:=s div 2;\n end;\n ans:=(ans+t) mod o;\n end;\n write(ans);\n\nend."}, {"source_code": "var a,b:array[0..10000] of int64;\nvar c,d:array[0..70] of int64;\nvar i,j,n,k,x,m1,o:longint;\nvar m,ans,t,s:int64;\nbegin\n\n readln(n,m,k);\n x:=m-m div n*n;\n c[0]:=1;\n d[0]:=1;\n o:=1000000007;\n m1:=trunc(ln(m div n+1)/ln(2))+1;\n a[0]:=1;\n b[0]:=1;\n for i:=1 to k do a[i]:=a[i-1]*(x*n-i+1) div i mod o;\n for i:=1 to k do b[i]:=b[i-1]*((n-x)*n-i+1) div i mod o;\n for i:=0 to k do\n begin\n t:=1;\n c[1]:=a[i];\n for j:=2 to m1 do c[j]:=c[j-1]*c[j-1] mod o;\n d[1]:=b[k-i];\n for j:=2 to m1 do d[j]:=d[j-1]*d[j-1] mod o;\n s:=m div n+1;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then t:=t*c[j] mod o;\n s:=s div 2;\n end;\n s:=m div n;\n for j:=1 to m1 do\n begin\n if s mod 2=1 then t:=t*d[j] mod o;\n s:=s div 2;\n end;\n ans:=(ans+t) mod o;\n end;\n write(ans);\n\nend."}, {"source_code": "uses math;\nconst module=1000000007;\n debug=false;\nvar tmp,i,j,n,t,k:longint;\n q,m:int64;\n c:array[0..110,0..110] of int64;\n f:array[0..110,0..10010] of int64;\n p1,p:array[0..11000] of int64;\n function pow(x,n:int64):int64;\n var q,res:int64;\n begin\n q:=x;\n res:=1;\n while n>0 do\n begin\n if n and 1=1 then res:=(res*q) mod module;\n q:=(q*x) mod module;\n n:=n>>1;\n end;\n pow:=res;\n end;\n begin\n read(n,m,k);\n\n c[0][0]:=1;\n for i:=1 to 100 do\n c[i][0]:=1;\n\n for i:=1 to 100 do\n for j:=1 to 100 do\n c[i][j]:=(c[i-1][j]+c[i-1][j-1]) mod module;\n\n if debug then\n begin\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do\n write(c[i][j]:4);\n writeln;\n end;\n end;\n\n for i:=0 to n do\n p[i]:=pow(c[n][i],m div n);\n for i:=0 to n do\n p1[i]:=pow(c[n][i],m div n+1);\n\n fillchar(f,sizeof(f),0);\n f[n+1][0]:=1;\n for i:=n downto 1 do\n for j:=0 to k do\n for t:=0 to min(j,n) do\n begin\n inc(tmp);\n\n if i<=m-n then q:=p1[t]\n else q:=p[t];\n\n f[i][j]:=(f[i][j]+f[i+1][j-t]*q) mod module;\n end;\n// writeln(tmp);\n if debug then\n begin\n writeln;\n\n for i:=1 to n do\n begin\n for j:=1 to k do\n write(f[i][j]:4);\n writeln;\n end;\n\n end;\n\n writeln(f[1][k]);\n end.\n"}, {"source_code": "const md = 1000000007;\nvar n,m,k:int64;\ni,j,u:longint;\nc:array[0..1000,0..1000]of longint;\ncalc:array[0..1000]of int64;\ncf:array[0..4000]of longint;\npre:array[0..300,0..300]of longint;\ndp:array[0..300,0..1001]of longint;\nfunction st(a:longint; n:int64):int64;\nvar t:int64;\nbegin\n if n=0 then st:=1\n else\n begin\n if n mod 2=0 then\n begin\n t:=st(a,n div 2);\n t:=t*t mod md;\n st:=t;\n end\n else\n st:=(int64(a)*st(a,n-1)) mod md;\n end;\nend;\nfunction mult(a,b:int64):int64;\nbegin\n a:=a*b;\n a:=a mod md;\nend;\n begin\n readln(n,m,k);\n for i:=0 to 1000 do\n begin\n c[0,i]:=0;\n c[i,0]:=1;\n end;\n for i:=1 to 1000 do\n for j:=1 to 1000 do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1]) mod md;\n dp[0,0]:=1;\n\n for i:=1 to n do\n begin\n calc[i]:=m div n;\n if i<=m mod n then calc[i]:=calc[i]+1;\n end;\n\n for i:=1 to n do\n begin\n cf[i]:=cf[i-1]+n;\n if cf[i]>k then cf[i]:=k;\n end;\n for i:=0 to n do\n for j:=1 to n do\n pre[i,j]:=st(c[n,i],calc[j]);\n for i:=0 to n-1 do\n for j:=0 to cf[i+1] do\n if dp[i,j]>0 then\n begin\n for u:=0 to n do\n if (j+u>k) then break\n else\n begin\n dp[i+1,j+u]:=(dp[i+1,j+u]+mult(dp[i,j],pre[u,i+1]));\n if dp[i+1,j+u]>=md then dp[i+1,j+u]:=dp[i+1,j+u]-md;\n end;\n end;\n writeln(dp[n,k]);\n end."}, {"source_code": "const base=1000000009;\nvar n,m,k:int64;\n phanmu:array[1..100]of int64;\n mang:array[0..101,0..10000]of int64;\n tohop,tohopmanh:array[0..100,0..100]of int64;\n\nfunction power(x,y:int64):int64;\nvar we,tich:int64;\nbegin\n if x=0 then power:=0\n else if y=0 then power:=1\n else begin\n we:=power(x,y div 2);\n if y mod 2=0 then tich:=(we*we)mod base\n else begin\n tich:=(we*we)mod base;\n tich:=(tich*x)mod base;\n end;\n power:=tich;\n end;\nend;\n\nfunction min(ax,bx:int64):int64;\nbegin\n if ax0 do \n begin\n if y and 1=1 then res:=res*tmp mod base;\n tmp:=tmp*tmp mod base; y:=y shr 1;\n end;\n cal:=res;\nend;\n\nbegin\n readln(n,m,up);\n c[0]:=1; g[0,0]:=1; g[0,1]:=1;\n tot:=m div n;\n for i:=1 to n do\n begin\n c[i]:=c[i-1]*(n-i+1) div i mod base;\n d[i]:=ord( (m>n)and(m mod n>=i) );\n g[i,0]:=cal(c[i],tot); g[i,1]:=cal(c[i],tot+1);\n end;\n f[0,0]:=1;\n for i:=1 to n do\n for j:=0 to min(i*n,up) do\n begin\n f[i,j]:=0; o:=i-1;\n for k:=0 to min(n,j) do\n if f[o,j-k]>0 then\n begin\n f[i,j]:=f[i,j]+f[o,j-k]*g[k,d[i]];\n if f[i,j]>=base then f[i,j]:=f[i,j] mod base;\n end;\n end;\n writeln(f[n,up]);\nend.\n\n"}, {"source_code": "{$apptype console}\n{$maxstacksize 5000000}\n{$b-}\nconst md=1000000007;\nvar\n p,i,j,n,k:integer;\n st,m:int64;\n a:array[0..101,0..101] of integer;\n b:array[1..101,0..101] of int64;\n dp:array[1..101,0..10001] of int64;\n\n Function power(v,s:int64):int64;\n var\n qq:int64;\n begin\n if s=0 then power:=1 else if s=1 then power:=v mod md else\n begin\n if s mod 2=0 then\n begin\n qq:=power(v,s div 2);\n power:=qq*qq mod md;\n end else power:=v*power(v,s-1) mod md;\n end;\n end;\n\n\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(n,m,k);\n Fillchar(a,sizeof(a),0);\n for i := 0 to n do a[i,0]:=1;\n for i := 1 to n do\n for j := 1 to i do a[i,j]:=(a[i-1,j-1]+a[i-1,j]) mod md;\n\n Fillchar(b,sizeof(b),0);\n for i := 1 to n do\n begin\n st:=((m-i) div n)+1;\n for j := 0 to n do\n b[i,j]:=power(a[n,j],st);\n end;\n\n Fillchar(dp,sizeof(dp),0);\n for i := 0 to n do dp[1,i]:=b[1,i];\n for i := 2 to n do\n for j := 0 to k do\n begin\n for p := 0 to n do\n begin\n if (j-p<0) then break;\n dp[i,j]:=(dp[i,j]+dp[i-1,j-p]*b[i,p]);\n while dp[i,j]>1000000000000000000 do dp[i,j]:=dp[i,j]-1000000000000000000;\n\n end;\n dp[i,j]:=dp[i,j] mod md;\n end;\n writeln(dp[n,k] mod md);\nend."}, {"source_code": "uses math;\nconst md=1000000007;\nvar mc,ma,ma1:array[-2..102,-2..102] of int64;\n dp:array[-2..102,-2..10005] of int64;\n i,j,g:longint;\n n,m,k,x,y,t:int64;\nfunction f(a,b:int64):int64;\nvar p,r:int64;\nbegin\n if (b=0) or (a=1) then\n begin\n f:=1;\n exit;\n end;\n p:=f(a,b shr 1);\n r:=(p*p) mod md;\n if b and 1=1 then r:=(r*a) mod md;\n f:=r;\nend;\nbegin\n readln(n,m,k);\n mc[0,0]:=1;\n for i:=1 to n do\n for j:=0 to i do\n mc[i,j]:=(mc[i-1,j]+mc[i-1,j-1]) mod md;\n x:=m div n;\n y:=x mod n;\n for j:=0 to i do\n begin\n ma[n,j]:=f(mc[n,j],x);\n ma1[n,j]:=(ma[n,j]*mc[n,j]) mod md;\n end;\n dp[0,0]:=1;\n for i:=1 to n do\n for j:=0 to min(i*n,k) do\n for g:=max(0,j-n) to j do\n begin\n if y 0 then ans:=ans*num;\n step:=ans;\n end;\nend;\nbegin\n read(n,k);\n l:=1;\n r:=n;\n while l+1=k then\n l:=m\n else if m+1<=r then\n begin\n inc(m);\n mn:=m;\n mx:=m;\n kk:=0;\n if m mod 2 = 0 then\n begin\n st:=0;\n mx:=m+1;\n end\n else \n st:=-1;\n while mx<=n do\n begin\n inc(st);\n kk:=kk+step(2,st);\n mn:=mn*2;\n mx:=mx*2+1;\n end;\n if mn<=n then\n kk:=kk+n-mn+1;\n if kk>=k then\n l:=m-1\n else\n r:=m-1;\n end\n else r:=m;\n {writeln(m,' ',kk);}\n end;\n m:=l+1;\n mn:=m;\n mx:=m;\n kk:=0;\n if m mod 2 = 0 then\n begin\n st:=0;\n mx:=m+1;\n end\n else \n st:=-1;\n while mx<=n do\n begin\n inc(st);\n kk:=kk+step(2,st);\n mn:=mn*2;\n mx:=mx*2+1;\n end;\n if mn<=n then\n kk:=kk+n-mn+1;\n if kk>=k then\n write(l+1)\n else write(l);\nend.\n", "positive_code": [{"source_code": " const eps=1e-14;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record x,y,z:extended; end;\n zap1=^zap;\n var qqq,oldpos,jj,kolvzv,sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n pqqq:zap; bet,al:extended;\n pt,ott1,ott2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n ot1,ot2,oldgr,predsum,pmin,tmin,pos,aa,bb,kool,sum,number,imin,kolreber,kolstan,qq,kol,chisl,znam,n,m,ttt,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,dx,dy,finish,time,p3,p4,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n left,right,pow,znum,z,stan,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n zznum,zz,ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole1,ppole2,ppole:array[-1000000..3000000] of char;\n bufer, str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-1..29,-1..360000] of int64;\n poss:int64;\n obmen,ch:char;\n \n ff,flagg1:boolean;\n oldx,oldy,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..1700002] of int64;\n dp:array[0..3,-1..910,0..12] of int64;\n function srav(i,j:longint):boolean; label 44;\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]>a1[j] then srav:=true else srav:=false;\n 44:\n end;\n \n procedure sl (k,l,m:integer); {k- dlina, l,m - nachalo dvuh blokov}\n begin\n i:=l;j:=m; flag:=true; step:=0;while flag do begin\n if (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;\n inc(step);inc(i);\n {writeln('step=',step,' i=',i);} end;\n if (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;\n inc(step);inc(j);end;\n if ((i>=l+k) or (j>=m+k)) then flag:=false;\n end;\n if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);\n if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);\n end;\n procedure sort(var c:mas);\n begin\n \n k:=1; repeat\n l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\n for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;\n until (k>=n);\n \n end;\n \n \n function min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n \n { function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1; fl:boolean;\n begin\n fl:=false;\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else\n begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\n evkl:=tt1;\n end;\n \n }\n function phi(a,b:double):double; label 222;var p:double;\n begin\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\n end;\n \n \n \n function nod(a,b:int64):int64; var p,t:int64;\n begin\n a:=abs(a); b:=abs(b);\n if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\n nod:=p;\n end;\n function arccos(tt:extended):extended;\n begin\n if abs(tt)>1-1e-13 then\n if tt>0 then arccos:=0 else arccos:=pi;\n if tt=0 then arccos:=pi/2 else\n if abs(tt)<=1-1e-13 then if tt>=0 then arccos:=arctan(sqrt(1-tt*tt)/tt)\n else arccos:=pi+arctan(sqrt(1-tt*tt)/tt);\n \n end;\n \n function nok(a,b:int64):int64;\n begin nok:=(a*b) div nod(a,b); end;\n \n \n function degg(a:int64;k:int64):int64; var p:int64;\n begin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n \n end;\n \n function zaprmax(left,right:longint):int64;\n begin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n end;\n \n end;\n \n end;\n \n function zaprmin(left,right:longint):int64;\n begin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n end;\n end;\n \n end;\n \n \n \n \n \n procedure udal(ii:longint);\n begin next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii]; end;\n \n function nomerr(gr:int64):int64;\n var ot,aa,bb,cc:int64; fl:boolean;\n begin\n aa:=1; bb:=p; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n writeln('cc=++ ',cc);\n if y[cc]p then p:=abs(b); if abs(c)>p then p:=abs(c); if abs(d)>p then p:=abs(d);\n ot:=a*t*t*t+b*t*t+c*t+d;\n if abs(ot)=1000;\n writeln(pos);\n} read(gr,tt);\n aa:=0; bb:=besk;\n while abs(aa-bb)>5 do\n begin\n cc:=(aa+bb) shr 1;\n if odd(cc) then inc(cc);\n if kolich(gr,cc)>=tt then aa:=cc else bb:=cc;\n\n end;\n\n { writeln(cc);\n } cc:=cc+20;\n repeat dec(cc) until kolich(gr,cc)>=tt;\n writeln(cc);\n\n\n\n\n\n 1: close (output);\n end.\n"}], "negative_code": [], "src_uid": "783c4b3179c558369f94f4a16ac562d4"} {"source_code": "var i,n,x,y, a,b: LongInt;\nans: Boolean;\nbegin\n ans:=false;\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then ans:=true;\n inc(a,x);\n inc(b,y);\n end;\n \n if (odd(a)) and (not odd(b)) or (not odd(a)) and (odd(b)) then\n begin\n Writeln('-1');\n halt(0);\n end;\n \n if (not odd(a)) and (not odd(b)) then Writeln('0') else\n if ans then Writeln('1') else Writeln('-1');\nend.", "positive_code": [{"source_code": "var n,i,k,x,y,s1,s2:longint;\nbegin\n k:=0;\n s1:=0;\n s2:=0;\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n s1:=s1+x;\n s2:=s2+y;\n if ((x mod 2=0) and (y mod 2<>0)) or ((x mod 2<>0) and (y mod 2=0)) then k:=1;\n end;\n if (s1 mod 2=0) and (s2 mod 2=0) then writeln(0) else\n if ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) then writeln(-1) else\n if (k=1) then writeln(1) else writeln(-1);\nend."}, {"source_code": "var\n n,x,y,ans1,ans2,i,met:longint;\nbegin\n readln(n);\n met:=0;\n for i:=1 to n do\n begin\n readln(x,y);\n if ((x and 1=0) and (y and 1<>0)) or ((x and 1<>0) and (y and 1=0)) then met:=1;\n ans1:=ans1+x;\n ans2:=ans2+y;\n end;\n if (ans1 and 1=0) and (ans2 and 1=0) then writeln('0')\n else if ((ans1 and 1<>0) and (ans2 and 1=0))or ((ans1 and 1=0) and (ans2 and 1<>0)) or (met=0) then begin\n writeln('-1');\n end\n else writeln(1);\nend.\n"}, {"source_code": "var a,b:array[0..111]of longint;\n n,i,j,s1,s2,t:longint;f:boolean;\nBegin\n readln(n);\n for i:=1 to n do\n readln(a[i],b[i]);\n s1:=0;s2:=0;\n for i:=1 to n do\n begin\n s1:=s1+a[i];\n s2:=s2+b[i];\n end;\n if (s1 mod 2=0)and(s2 mod 2=0) then begin writeln(0);halt; end;\n f:=false;\n for i:=1 to n do\n if abs(a[i]-b[i])mod 2<>0 then begin f:=true;break; end;\n if f then j:=i else begin writeln(-1);halt; end;\n t:=b[j];b[j]:=a[j];a[j]:=t;\n s1:=0;s2:=0;\n for i:=1 to n do\n begin\n s1:=s1+a[i];\n s2:=s2+b[i];\n end;\n if (s1 mod 2=0)and(s2 mod 2=0) then begin writeln(1);halt; end;\n writeln(-1);\nEnd.\n"}, {"source_code": "var\n a:array[1..100,1..2] of integer;\n s,i,j,k,n:longint;\n h:boolean;\nbegin\n readln(n);\n for i:=1 to n do begin\n readln(a[i,1],a[i,2]);\n s:=a[i,1]+a[i,2]+s;\n end;\n if s mod 2=1 then writeln(-1)\n else begin\n s:=0;\n for i:=1 to n do\n\t s:=s+a[i,1];\n\tif s mod 2=0 then writeln(0);\n\tif s mod 2=1 then begin\n for i:=1 to n do\n\t if (a[i,1]+a[i,2]) mod 2=1 then h:=true;\n\tif h then writeln(1)\n\telse writeln(-1);\n\tend;\n end;\nend.\n\n"}, {"source_code": "var\n i,x,y,n,k:longint;\n even1,even2,has:boolean;\nbegin\n readln(n);has:=false;even1:=true;even2:=true;\n for i:=1 to n do begin\n readln(x,y);\n if (odd(x) xor odd(y)) then has:=true;\n if odd(x) then even1:=not even1;\n if odd(y) then even2:=not even2;\n end;\n if even1 and even2 then writeln(0)\n else if (even1<>even2) then writeln(-1)\n else if has then writeln(1)\n else writeln(-1);\nend."}, {"source_code": "const\n fil='';\nvar\n f:text;\n i,n,sum1,sum2,dem:longint;\n x,y:array[1..100] of longint;\nbegin\n assign(f,fil);\n reset(f);\n readln(f,n);\n for i:=1 to n do begin read(f,x[i],y[i]); sum1:=sum1+x[i]; sum2:=sum2+y[i]; end;\n if odd(sum1+sum2) then write(-1)\n else begin\n if odd(sum1) then\n begin\n for i:=1 to n do\n if odd(x[i]+y[i]) then begin write(1); close(f); exit; end;\n write(-1);\n end\n else write(0);\n end;\n close(f);\nend.\n"}, {"source_code": "var\n a,b :array [1..10000] of longint;\n i,s1,s2,n : longint;\nbegin\n readln(n);\n for i:=1 to n do begin readln(a[i],b[i]); a[i]:=a[i] mod 2; b[i]:=b[i] mod 2; end;\n for i:=1 to n do s1:=s1+a[i];\n s1:=s1 mod 2;\n for i:=1 to n do s2:=s2+b[i];\n s2:=s2 mod 2;\n if (s1=0) and (s2=0) then begin writeln(0); exit; end;\n if (s1+s2=1) then begin writeln(-1); exit; end;\n for i:=1 to n do\n if (a[i]+b[i]=1) then begin writeln(1); exit; end;\n writeln(-1);\nend."}, {"source_code": "var i,a,b,d,n,k,l,h:integer;\nbegin\nread(n);\nk:=0;\nl:=0;\nd:=2;\nh:=0;\nfor i:=1 to n do begin\nread(a,b);\nk:=k+a;\nl:=l+b;\nif (a mod 2<>b mod 2) then h:=1;\nend;\nif (k mod 2=0)and(l mod 2=0) then d:=0; \nif (k mod 2=1)and(l mod 2=1)and(h=1) then d:=1;\nif d=2 then d:=-1;\nwrite(d);\nend."}, {"source_code": "var sum1,sum2,ans,i,n:integer;\n a:array [1..100,1..2] of integer;\nbegin\n readln(n);\n for i:=1 to n do begin\n readln(a[i,1],a[i,2]);\n inc(sum1,a[i,1]);\n inc(sum2,a[i,2]);\n end;\n \n if ((sum1 mod 2 = 1) and (sum2 mod 2 = 0)) or ((sum1 mod 2 = 0) and (sum2 mod 2 = 1)) then begin\n writeln(-1);\n exit;\n end\n else\n if (sum1 mod 2 = 0) and (sum2 mod 2 = 0) then begin\n writeln(0);\n exit;\n end\n else\n for i:=1 to n do\n if ((a[i,1] mod 2 = 1) and (a[i,2] mod 2 = 0)) or ((a[i,1] mod 2 = 0) and (a[i,2] mod 2 = 1)) then begin\n writeln(1);\n exit;\n end;\n writeln(-1);\nend."}, {"source_code": "uses math;\ntype mass=array[1..100,1..2] of int64;\nvar a,b,c,n,z,res:int64;m:mass;i:integer;s:string;\nprocedure rec(x,a,b,p:integer);\nvar j:integer;\nBegin\n if (a mod 2=0) and (b mod 2=0)\n then Begin\n res:=min(res,x);\n exit;\n end;\n if x=2\n then exit;\n for j:=1 to n do\n if j<>p\n then rec(x+1,a-m[j,1]+m[j,2],b-m[j,2]+m[j,1],j);\nend;\nbegin\n // reset(input,'input.txt');\n // assign(output,'output.txt');\n readln(n);\n a:=0;b:=0;\n for i:=1 to n do\n Begin\n readln(m[i,1],m[i,2]);\n inc(a,m[i,1]);\n inc(b,m[i,2]);\n end;\n res:=100;\n rec(0,a,b,0);\n if res=100\n then writeln(-1)\n else writeln(res);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\nSysUtils;\n\nvar n,i,k,h,t,p,k1,k2,a,b:longint;\nc:array [1..200] of longint;\nbegin\nreadln(n);\nk1:=0;\nk2:=0;\np:=0;\nfor i:=1 to n do begin\nread(a,b);\nif a mod 2 = 1 then k1:=k1+1;\nif b mod 2 = 1 then k2:=k2+1;\nif (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 = 0) and (b mod 2 = 0) then t:=0 else p:=1;\nreadln;\nend;\nif (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');\nif ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');\nif (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);\nend.\n"}, {"source_code": "\n {$APPTYPE CONSOLE}\n\n const besk=2000000000000000; eps=1e-10;\n label 1,2,3,4;\n var k,i,shag,nn,n,n1,dl,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,j,isp,finish:longint;\nw,h,p,pos,x,y,z,q,a1,a2,b1,b2,kol,t,m1,pl,p1,p2,p3,m,k2,r,ot,aa,bb,x1,y1,x0,y0,d1,d2,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\naeqb,agrb,bgra,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nll,rr,cc,ott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndist:array[-10..3010,-10..3010] of int64;\nddd,distot:double;\nstr,pred,next,c,b,a,sum: array[-300000..5000000] of int64;\nest,zapx,zapy:array[-10..200000] of boolean;\nddminus,ddplus,gr: array[-20..2020,-20..2020] of int64;\nee,deg,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss1,sss,sss2:string;\nab:array[-100..200,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nstepen:array[0..1000] of int64;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n { function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend; }\n\n function good(k:double):boolean; var i,j,t:longint; fl:boolean; xx,yy:double;\nbegin\n fl:=true; xx:=0; yy:=0;\n for i:=1 to n do\n if (b[i]<>b[i-1])or(xx+a[i]>k*w) then begin yy:=yy+b[i]; xx:=0; end\n else begin xx:=xx+a[i]; end;\n if yy>h*k then fl:=false;\n\n good:=fl;\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n\n read(n);\n for i:=1 to n do read(a[i],b[i]);\n for i:=1 to n do if odd(a[i]) then inc(p1);\n for i:=1 to n do if odd(b[i]) then inc(p2);\n for i:=1 to n do if odd(a[i]+b[i]) then inc(p3);\n if odd(p1+p2) then begin writeln(-1); goto 1;end;\n if not odd(p1) and not odd(p2) then begin writeln(0); goto 1;end;\n if (p3>0) then writeln(1) else writeln(-1);\n\n\n\n\n\n\n\n 1: close(output);\n\nend.\n"}, {"source_code": "program N_5;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar\n a : array [ 1..100,1..2] of integer;\n i,j,n,s,x,s1,sum :integer;\nbegin\n readln(n);\n for i := 1 to n do\n readln(a[i,1], a[i,2]);\n s := 0;\n s1 := 0;\n for i := 1 to n do\n begin\n s := s + a[i,1];\n s1 := s1 + a[i,2];end;\n sum := 0;\n if ((s1 mod 2=0)and(s mod 2 = 0)) then begin\n writeln(0); readln; exit; end\n else\n begin\n for i := 1 to n do begin\n if (a[i,1]+a[i,2]) mod 2 = 1 then\n begin\n inc(sum);\n s1 := s1 + a[i,1]-a[i,2];\n s := s +a[i,2]-a[i,1];\n if ((s1 mod 2=0)and(s mod 2 = 0)) then begin\n writeln(sum); readln; exit; end;\n end;\n if i = n then\n writeln(-1);\n end; end;\n readln;\nend.\n"}, {"source_code": "{$O+,R+,Q+}\nvar a,b,i,n,s1,s2,k:LongInt;\nbegin\n\n readln(n);\n s1:=0;\n s2:=0;\n k:=0;\n for i:=1 to n do\n begin\n readln(a,b);\n if ((Odd(a))and(not(Odd(b))))or((not(Odd(a)))and(Odd(b)))\n then Inc(k);\n inc(s1,a);\n inc(s2,b);\n end;\n if (not(Odd(s1)))and(not(Odd(s2)))\n then begin\n Writeln(0); Halt(0);\n end;\n if ((Odd(s1)))and(not(Odd(s2)))or(not(Odd(s1)))and((Odd(s2)))\n then begin\n Writeln(-1); Halt(0);\n end;\n if k>0\n then Writeln(1)\n else Writeln(-1);\nend."}, {"source_code": "Var a,b:Array [1..1000] of LongInt;\n aa,bb,i,n:LongInt;\nBegin\n// ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (n);\n For I:=1 to n do Read (a[i],b[i]);\n For I:=1 to n do\n Begin\n Inc (aa,a[i]);\n Inc (bb,b[i]);\n End;\n If not odd (aa) and not odd (bb)\n then Begin\n Writeln (0);\n Halt (0);\n End;\n If not odd (aa) and odd (bb)\n then Begin\n Writeln (-1);\n Halt (0);\n End;\n If odd (aa) and not odd (bb)\n then Begin\n Writeln (-1);\n Halt (0);\n End;\n For I:=1 to n do\n Begin\n If odd(a[i]) and not odd(b[i]) or not odd (a[i]) and odd (b[i])\n then Begin\n Writeln (1);\n Halt (0)\n ENd\n ENd;\n Writeln (-1)\nEnd."}, {"source_code": "{$MODE OBJFPC}\n\nprogram domino;\nvar\n n:longint;\n a,b,c:array[0..100] of longint;\n\nprocedure ip;\nvar\n i:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a[i],b[i]);\n c[i]:=abs(a[i]-b[i]);\n end;\nend;\n\n\nprocedure solve;\nvar\n i,suma,sumb:longint;\n x,y,res:longint;\n flag:boolean;\nbegin\n suma:=0;\n sumb:=0;\n for i:=1 to n do\n begin\n suma:=suma+a[i];\n sumb:=sumb+b[i];\n end;\n x:=suma mod 2;\n y:=sumb mod 2;\n if x+y=0 then res:=0;\n if x+y=1 then res:=-1;\n if x+y=2 then\n if n>=2 then\n begin\n flag:=true;\n for i:=1 to n do if c[i] mod 2 =1 then\n begin\n flag:=false;\n break;\n end;\n if flag then res:=-1 else res:=1;\n end\n else res:=-1;\n writeln(res);\nend;\n\nbegin\n ip;\n solve;\nend."}, {"source_code": "var n,x,y,f,a,b:word;\nbegin\n read(n);\n for n:=1to n do\n begin\n read(x,y);\n a:=a+x;\n b:=b+y;\n if odd(x+y)then f:=1;\n end;\n if a mod 2+b mod 2=0then write(0)\n else if(f=1)and(a mod 2+b mod 2=2)then write(1)\n else write(-1)\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=998244353;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n st:string;\n x,y:array[1..1000] of longint;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction allcandy:boolean;\n var i:longint;\n begin\n for i:=1 to length(st) do if st[i]='*' then exit(false);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction allodd:boolean;\n var i:longint;\n begin\n if n mod 2=0 then exit(false);\n for i:=1 to n do if x[i] mod 2=0 then exit(false);\n for i:=1 to n do if y[i] mod 2=0 then exit(false);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,t,res,n,sx,sy:longint;\n begin\n read(fi,n);\n sx:=0;\n sy:=0;\n for i:=1 to n do read(fi,x[i],y[i]);\n for i:=1 to n do sx:=sx+x[i];\n for i:=1 to n do sy:=sy+y[i];\n if (sx+sy) mod 2=1 then\n begin\n writeln(fo,-1);\n exit;\n end;\n if (sx mod 2=0) and (sy mod 2=0) then\n begin\n write(fo,0);\n exit;\n end;\n for i:=1 to n do if (x[i]+y[i]) mod 2=1 then\n begin\n write(fo,1);\n exit;\n end;\n write(fo,-1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,t,s,k:longint;\n begin\n\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var s1,s2:integer;\n n,i,x,y,ind:byte;\n\nbegin\nread(n);\nfor i:=1 to n do\nbegin\nread(x);\nread(y);\ns1:=s1+x;\ns2:=s2+y;\nif (x mod 2)<>(y mod 2) then\nind:=1;\nend;\nif (s1+s2) mod 2=1 then\nbegin\nwrite('-1');\nhalt;\nend\nelse\nif s1 mod 2=0 then\nbegin\nwrite('0');\nhalt;\nend\nelse\nif ind=1 then\nwrite('1')\nelse\nwrite('-1');\nend."}, {"source_code": "var\n n,i,j,k,x,y,nx,ny:longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n nx:=nx+x;\n ny:=ny+y;\n if (x mod 2)<>(y mod 2) then k:=1;\n end;\n if (nx mod 2=0)and(ny mod 2=0) then writeln('0')\n else if (nx mod 2=1)and(ny mod 2=1)and(k=1) then writeln('1')\n else writeln('-1');\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,ans,x,y,p:longint;\n a:array[0..1] of integer;\n\nbegin\n//assign(input,in_file); reset(input);\n//assign(output,out_file); rewrite(output);\n fillchar(a,sizeof(a),0);\n readln(n);\n p:=0;\n for i:=1 to n do\n begin\n readln(x,y);\n if ((x and 1)=1)and((y and 1)=1) then begin p:=p+1; continue; end;\n if ((x and 1)=(y and 1)) then continue;\n if ((x and 1)=1) then a[0]:=a[0]+1 else a[1]:=a[1]+1;\n end;\n if ((((a[0]+a[1]) and 1)=1)and((p and 1)=0))or(((p and 1)=1)and((((a[0]+a[1])and 1)=1)or((a[0]+a[1])=0))) then begin writeln(-1); readln; halt; end;\n\n if ((p and 1)=0) then\n begin\n if ((a[0] and 1)=1) then writeln(1) else writeln(0);\n readln;\n halt;\n end;\n\n ans:=1000;\n for i:=0 to a[0]+a[1] do\n begin\n if (((1+i)and 1)=1) then continue;\n if (((a[0]+a[1]+1-i)and 1)=1) then continue;\n ans:=min(ans,abs(a[0]-i));\n end;\n writeln(ans);\n readln;\n\n//close(output);\n//close(input);\nend.\n"}, {"source_code": "var n,i,a,b,s1,s2,s:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(a,b);\n inc(s1,a);inc(s2,b);\n if((a mod 2)+(b mod 2)=1) then s:=1;\n end;\n s1:=s1 mod 2;s2:=s2 mod 2;\n if(s1=0)and(s2=0)then begin write('0');exit;end;\n if((s1=1)and(s2=0))or((s1=0)and(s2=1))then begin write('-1');exit;end;\n if s=1 then write('1') else write('-1');\nend."}, {"source_code": "program za;\n\nuses math;\n\n\nvar\n a,b:array [1..100] of boolean;\n n,i,x,y,sumn1,sumn2,sumv1,sumv2,c21,c12,c11,sum1,sum2:longint;\n\nbegin\n readln(n);\n sum1:=0;\n sum2:=0;\n for i:=1 to n do\n begin\n read(x,y);\n sum1:=sum1+x;\n sum2:=sum2+y;\n if (x mod 2 = 0 ) and (y mod 2 <>0) then inc(c21);\n if (x mod 2 <> 0) and (y mod 2 = 0) then inc(c12);\n if (x mod 2 <> 0) and (y mod 2 <>0) then inc(c11);\n end;\n {if ((c12+c21) mod 2 = 0) and (c11 mod 2 = 0) then\n begin\n writeln(0);\n halt(0);\n end; }\n if (sum1 mod 2 =0) and (sum2 mod 2 = 0) then\n begin\n writeln(0);\n halt(0);\n end;\n if (sum1 mod 2<>0) and (sum2 mod 2 <> 0) then\n begin\n if (c12>0) or (c21>0) then\n begin\n writeln(1);\n halt(0);\n\n end;\n end;\n writeln(-1);\nend.\n\n\n\n"}, {"source_code": "var s1,s2,i,n:longint;\n x,y:array[0..1000]of longint;\n\nbegin {\n assign(input,'bai1.inp');\n reset(input);\n assign(output,'bai1.out');\n rewrite(output); }\n readln(N);\n for i:=1 to n do\n begin\n readln(x[i],y[i]);\n s1:=s1+x[i];\n s2:=s2+y[i];\n end;\n if (s1+s2) and 1=1 then\n begin\n writeln(-1);\n halt;\n end;\n if (s1 and 1=0) and (S2 and 1=0) then\n begin\n writeln(0);\n halt;\n end;\n for i:=1 to n do\n if ((s1-x[i]+y[i]) mod 2=0)\n and ((s2-y[i]+x[i]) mod 2=0) then\n begin\n writeln(1);\n halt;\n end;\n writeln(-1);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,k,h,t,p,k1,k2,a,b:longint;\n c:array [1..200] of longint;\nbegin\nreadln(n);\nk1:=0;\nk2:=0;\np:=0;\nfor i:=1 to n do begin\nread(a,b);\nif a mod 2 = 1 then k1:=k1+1;\nif b mod 2 = 1 then k2:=k2+1;\nif (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 = 0) and (b mod 2 = 0) then t:=0 else p:=1;\nreadln;\nend;\nif (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');\nif ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');\nif (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);\nread(n);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var a, aa, b, bb, n, i:longint;\n bool:boolean;\nbegin\nreadln(n); bool:=false;\nfor i:=1 to n do\n begin\n read(aa, bb);\n a:=a+aa; b:=b+bb;\n if (aa mod 2<>0)and(bb mod 2=0) then bool:=true;\n if (aa mod 2=0)and(bb mod 2<>0) then bool:=true;\n end;\nif (a mod 2 =0)and(b mod 2=0) then writeln(0);\nif (a mod 2 <>0)and(b mod 2=0) then writeln(-1);\nif (a mod 2=0) and (b mod 2<>0) then writeln(-1);\nif (a mod 2<>0)and(b mod 2<>0) then begin\n if bool then writeln(1)\n else writeln(-1);\n end;\nend.\n"}, {"source_code": "program domino;\nconst\n fi = '';\n fo = '';\nvar\n f:text;\n dem:array[0..1,0..1] of integer;\n i,ok,n,a,b,sa,sb:integer;\n{ - - }\nprocedure nhap;\n begin\n assign(f,fi);\n reset(f);\n read(f,n);\n for i:=1 to n do\n begin\n read(f,a,b);\n inc(dem[a mod 2,b mod 2]);\n sa:=(sa+a) mod 2;\n sb:=(sb+b) mod 2;\n end;\n end;\n{ - - }\nprocedure xuat;\n begin\n assign(f,fo);\n rewrite(f);\n write(f,ok);\n close(f);\n halt;\n end;\n{ - - }\nprocedure xuli;\n begin\n if (sa=0) and (sb=0) then\n begin\n ok:=0;\n xuat;\n end;\n if (sa=1) and (sb=1) then\n begin\n if (dem[1,0]>0) or (dem[0,1]>0) then\n begin\n ok:=1;\n xuat;\n end\n else\n begin\n ok:=-1;\n xuat;\n end;\n end;\n if sa<>sb then\n begin\n ok:=-1;\n xuat;\n end;\n end;\n{ - - }\nBEGIN\n nhap;\n xuli;\nEND.\n"}, {"source_code": "type\n domino = record\n u, d: int64;\n end;\n \nvar\n a, b, c, i: int64;\n q: boolean;\n sum: domino;\n ar: array [1..1000] of domino;\n \nbegin\n readln(a);\n i := 1;\n sum.u := 0;\n q := false;\n sum.d := 0;\n while i <= a do begin\n readln(ar[i].u, ar[i].d);\n if (ar[i].u + ar[i].d) mod 2 = 1 then q := true;\n inc(sum.u, ar[i].u);\n inc(sum.d, ar[i].d);\n inc(i);\n end;\n if (sum.u mod 2 = 0) and (sum.d mod 2 = 0) then writeln(0)\n else if (sum.u mod 2 = 1) and (sum.d mod 2 = 1) and (q) then writeln(1)\n else writeln(-1);\nend."}, {"source_code": "Var n,sa,sb,i:integer;\n a,b:array [1..101] of integer;\n sf:boolean;\nbegin\n readln(n);\n for i:=1 to n do\n readln(a[i],b[i]);\n sf:=false;\n for i:=1 to n do\n if (a[i] mod 2)<>(b[i] mod 2) then sf:=true;\n for i:=1 to n do\n begin\n sa:=sa+a[i];\n sb:=sb+b[i];\n end;\n if (sa+sb) mod 2 = 1 then write('-1')\n else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')\n else if (sa mod 2 = 1) and (sb mod 2 = 1) then\n begin\n if sf then write('1')\n else write('-1');\n end;\nend."}, {"source_code": "uses math;\nvar i,n,sol,temp:longint; x,y:array[1..1000] of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sol:=sol+x[i];\n temp:=temp+y[i];\n end;\n\n\n if (sol mod 2=0) and (temp mod 2=0) then\n begin\n writeln(0);\n \n exit;\n end ;\n \n\n\n\n\n if (sol mod 2<>0)and (temp mod 2<>0 ) then\n for i:=1 to n do\n if (((x[i] mod 2<>0) and (y[i] mod 2=0) )or ((x[i] mod 2=0) and (y[i] mod 2<>0)))then\n begin\n\n writeln(1);\n exit;\n end;\n\n\n \n writeln(-1);\n \n\n\n end ."}, {"source_code": "program P353A;\nvar\n n:integer;\n \nprocedure main();\n var\n i:integer;\n x,y:integer;\n z,t:integer;\n c:boolean=false;\n begin\n z:=0;\n t:=0;\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n if (odd(x+y)) then c:=true;\n inc(z,x);\n inc(t,y);\n end;\n if (odd(z+t)) then\n write(-1)\n else\n if (not odd(z)) then\n write(0)\n else\n if (c) then\n write(1)\n else\n write(-1);\n end;\n \nbegin\n main();\nend."}, {"source_code": "Const fin='205a.inp';\n fon='205a.out';\nVar res,x,y,a,b,n,d,d1,d2:longint;\nProcedure print;\nBegin\n Write(res);\nEnd;\n\nProcedure sol;\nBegin\n\nENd;\n\nProcedure init;\nVar i:longint;\nBegin\n Read(n);\n For i:=1 to n do\n Begin\n Read(a,b);\n If a mod 2=1 then\n Begin\n inc(x);\n d1:=d1+a;\n ENd;\n If b mod 2=1 then\n Begin\n inc(y);\n d2:=d2+b;\n ENd;\n If (a mod 2=1) and (a mod 2=b mod 2) then\n Begin\n inc(d);\n d1:=d1-a;\n d2:=d2-b;\n ENd;\n\n ENd;\n If (x+y=0) then\n Begin\n res:=0;\n exit;\n End;\n If (x+y) mod 2 =1 then\n Begin\n res:=-1;\n exit;\n ENd;\n If (x mod 2=0) then\n Begin\n res:=0;\n exit;\n ENd Else Begin\n If (x=d) and (y=d) then\n Begin\n res:=-1;\n exit;\n ENd;\n res:=1;\n ENd;\n\n sol;\nENd;\n\nBEGIN\n //Assign(input,fin);reset(input);\n //Assign(output,fon);rewrite(output);\n init;\n print;\n //close(input);close(output);\nEND.\n\n"}, {"source_code": "var n,i,a,b,s1,s2,s,ss:byte;\nbegin\n readln(n); s1:=0; s2:=0; s:=0; ss:=0;\n for i:=1 to n do\n begin\n readln(a,b); inc(s1,a); inc(s2,b);\n if ((a mod 2=1) and (b mod 2=1)) then inc(s);\n if ((a mod 2=0) and (b mod 2=0)) then inc(ss);\n end; \n if ((s1+s2) mod 2=1) then writeln(-1) else\n begin\n if (s1 mod 2=0) then writeln(0) else\n if (s+sskl2) then ot:=1\n else ot:=-1;}\n writeln(ot);\nend."}, {"source_code": "Var x,y:Array[0..10000] of LongInt;\n sum1,sum2,i,j,n:longInt;\n begin\n Read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sum1:=sum1+x[i];\n sum2:=sum2+y[i];\n end;\n if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(0); exit; end;\n for i:=1 to n do\n begin\n sum1:=sum1-x[i];\n sum1:=sum1+y[i];\n sum2:=sum2-y[i];\n sum2:=sum2+x[i];\n if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(1); exit; end;\n sum1:=sum1-y[i];\n sum1:=sum1+x[i];\n sum2:=sum2-x[i];\n sum2:=sum2+y[i];\n end;\n For i:=1 to n do\n For j:=1 to n do\n if i<>j then\n begin\n sum1:=sum1-x[i];\n sum1:=sum1+y[i];\n sum2:=sum2-y[i];\n sum2:=sum2+x[i];\n sum1:=sum1-x[j];\n sum1:=sum1+y[j];\n sum2:=sum2-y[j];\n sum2:=sum2+x[j];\n if (sum1 mod 2=0) and (sum2 mod 2=0) then begin WriteLn(2); exit; end;\n sum1:=sum1-y[i];\n sum1:=sum1+x[i];\n sum2:=sum2-x[i];\n sum2:=sum2+y[i];\n sum1:=sum1-y[j];\n sum1:=sum1+x[j];\n sum2:=sum2-x[j];\n sum2:=sum2+y[j];\n end;\n WriteLn(-1);\n end."}, {"source_code": "program Project1;\nvar\n n,i : byte;\n sx,sy : smallint;\n x : array [1..100] of byte ;\n y : array [1..100] of byte ;\nbegin\n read(n);\n sx:= 0;\n sy:= 0;\n for i:= 1 to n do\n begin\n readln(x[i],y[i]);\n sx:= x[i] + sx;\n sy:= y[i] + sy;\n end;\n if ((sx mod 2) = 0) and ((sy mod 2) = 0)\n then begin\n writeln('0');\n exit;\n end;\n if ((sx+sy) mod 2) <> 0\n then\n begin\n writeln('-1');\n exit;\n end;\n for i:= 1 to n do\n begin\n if ((x[i]+y[i]) mod 2) <> 0\n then\n begin\n writeln('1');\n exit;\n end;\n end;\nwriteln('-1');\nend. "}, {"source_code": "uses\n math;\nvar\n ii,n,i,x,y,ui,di:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if (x mod 2=1) AND (y mod 2=1)then\n ii:=ii+1;\n if y mod 2=1 then\n di:=di+1;\n if x mod 2=1 then\n ui:=ui+1;\n end;\n if (ui mod 2=0) AND (di mod 2=0) then\n writeln(0)\n else\n if ((ui mod 2)+(di mod 2)=2) AND ((di-ii>0) or (ui-ii>0)) then\n writeln(1)\n else\n writeln(-1);\nend. "}, {"source_code": "Program adomino;\n\nvar\n\tx : array[1..100] of integer;\n\ty : array[1..100] of integer;\n\ti, a, b, n : integer;\n\tcek : boolean;\n\nbegin\n\treadln(n); a := 0; b := 0;\n\tcek := false;\n\tfor i:=1 to n do\n\tbegin\n\t\treadln(x[i], y[i]);\n\t\ta := a + x[i];\n\t\tb := b + y[i];\n\t\tif (((x[i] mod 2 = 1) and (y[i] mod 2 = 0)) or ((x[i] mod 2 = 0) and (y[i] mod 2 = 1))) then cek := true;\n\tend;\n\ta := a mod 2;\n\tb := b mod 2;\n\tif ((a = 1) and (b = 1) and cek) then writeln(1)\n\telse if ((a = 0) and (b = 0)) then writeln(0)\n\telse writeln(-1);\nend."}, {"source_code": "Var i,j,k,n,m,suma,sumb:longint;\n a,b:array[0..100000]of longint;\n\t\nBegin\n read(n);\n for i:=1 to n do \n begin\n read(a[i]); Inc(suma,a[i]);\n read(b[i]); Inc(sumb,b[i]);\n end;\n if (suma+sumb) mod 2<>0 then \n begin writeln(-1); halt; end\n else \n if suma mod 2=0 then \n begin writeln(0); halt; end\n else \n begin\n for i:=1 to n do \n if (a[i]+b[i]) mod 2=1 then \n\t begin writeln(1); halt; end;\n writeln(-1);\n end;\nEnd."}, {"source_code": "var i,n,x,y, a,b, sum: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then\n begin\n inc(a);\n inc(sum,x);\n end;\n if (odd(x)) and (odd(y)) then inc(b);\n end;\n\n if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else\n if (odd(sum)) and (odd(b)) or (not odd(sum)) and (not odd(b)) then Writeln('0') else Writeln('1');\nend."}, {"source_code": "Program _353A;\nvar\n n, i, x, y, a, b, a1, b1, c : longint;\nbegin\n read(n);\n a := 0; b := 0; c := 0;\n for i := 1 to n do\n begin\n read(x, y);\n if x mod 2 = 0\n then begin\n if y mod 2 = 1\n then inc(a);\n end\n else if y mod 2 = 0\n then inc(b)\n else inc(c);\n end;\n a1 := a; b1 := b; \n a := a mod 2;\n b := b mod 2;\n c := c mod 2;\n \n if c = 0\n then if a = b\n then if a = 0\n then write(0)\n else write(1)\n else write(-1)\n else if a + b = 2\n then write(0)\n else if (a + b = 0) and (a1 + b1 > 0)\n then write(1)\n else write(-1);\nend.\n"}, {"source_code": "uses math;\n\nvar n : int64;\n i,j : longint;\n x,y : longint;\n cnt,ans : longint;\n a : array[1..1000] of longint;\n s,s1,s2 : ansistring;\n\nbegin\n readln(n);\n\n for i := 1 to n do\n begin\n readln(x,y);\n if (x+y) mod 2 = 1\n then cnt := 1;\n\n a[1] := a[1] + x;\n a[2] := a[2] + y;\n end;\n\n if (a[1] mod 2 = 0) AND (a[2] mod 2 = 0)\n then writeln(0);\n\n if (a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 1)\n then writeln(1);\n\n if ((a[1]+a[2]) mod 2 = 1) OR ((a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 0))\n then writeln(-1);\nend.\n"}, {"source_code": "var i,n, a,b, sum, tmp: LongInt;\nx,y: array[0..10001] of LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x[i],y[i]);\n inc(a,x[i]);\n inc(b,y[i]);\n end;\n \n if (not odd(a)) and (not odd(b)) then\n begin\n Writeln('0');\n halt(0);\n end;\n \n for i:=1 to n do\n if (odd(x[i])) and (not odd(y[i])) or (not odd(x[i])) and (odd(y[i])) then\n begin\n tmp:=x[i];\n x[i]:=y[i];\n y[i]:=tmp;\n break;\n end;\n \n a:=0;\n b:=0;\n for i:=1 to n do\n begin\n inc(a,x[i]);\n inc(b,y[i]);\n end;\n \n if (not odd(a)) and (not odd(b)) then Writeln('1') else Writeln('-1');\nend."}, {"source_code": "var i,n,x,y,z, a,b: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then z:=1;\n inc(a,x);\n inc(b,y);\n end;\n \n if (not odd(a)) and (not odd(b)) then Writeln('0') else\n if (odd(a)) and (odd(b)) and (z=1) then Writeln('1') else Writeln('-1');\nend."}, {"source_code": "{$mode FPC}\n{$H+}{$R+}{$I+}{$Q+}\n//{$H-}{$R-}{$I-}{$Q-}\n\nuses math;\nvar i,j, t , x,y, s1,s2,n: longint;\n f: boolean;\n\nBEGIN\n\t//assign(input, 'input.txt'); reset(input);\n\t//assign(output,'output.txt'); rewrite(output);\n\tread(n);\n\tfor i:=1 to n do begin readln(x,y);\n\t\ts1:=s1+x;\n\t\ts2:=s2+y;\n\t\tif (x+y) mod 2 = 1 then f:=true;\n\tend;\n\tif ((s1+s2) mod 2 = 1) or \n\t (s1 mod 2 =1) and (s2 mod 2 =1) and not(f) then t:=-1\n\telse if (s1 mod 2 =0) and (s2 mod 2 =0) then t:=0\n\t else t:=1;\n\t \n\twriteln(t);\nEND.\n\n"}, {"source_code": "VAR D,A,B,C,I,N:LONGINT;F:BOOLEAN;\nBEGIN\n READ(N);\n FOR I:=1 TO N DO\n BEGIN\n READ(A,B);\n IF ODD(A+B) THEN F:=TRUE;\n C:=C+A;\n D:=D+B;\n END;\n IF ODD(C+D) THEN WRITE(-1) ELSE \n IF NOT ODD(C) THEN WRITE(0) ELSE IF F THEN WRITE(1) ELSE WRITE(-1);\nEND."}, {"source_code": "var n,i,x,y:byte;\n sumx,sumy:integer;\n able:boolean;\nbegin\n readln(n);\n sumx:=0;sumy:=0;\n able:=false;\n for i:=1 to n do begin\n readln(x,y);\n sumx:=sumx+x;\n sumy:=sumy+y;\n if abs(x-y) mod 2=1 then able:=true;\n end;\n if (sumx mod 2=0)and(sumy mod 2=0) then\n writeln(0)\n else\n if (sumx mod 2=0)or(sumy mod 2=0) then\n writeln(-1)\n else\n if able and (n>=2)then\n writeln(1)\n else\n writeln(-1);\n readln;\nend."}, {"source_code": "PROGRAM Domino;\nVar a,b:array[1..100] of integer;\n n,t,suma,sumb:integer;\n\nProcedure nhap;\nVar i:longint;\nBegin\n readln(n);\n suma:=0;\n sumb:=0;\n for i:=1 to n do\n begin\n readln(a[i],b[i]);\n suma:=suma+a[i];\n sumb:=sumb+b[i];\n end;\n\n End;\n\nFunction giai:integer;\nVar i:longint;\nBegin\n if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(0);\n if (((suma mod 2)=1) and ((sumb mod 2)=0)) or (((suma mod 2)=0) and ((sumb mod 2)=1)) then\n begin\n if n>1 then\n for i:=1 to n do\n if (a[i] mod 2) <> (b[i] mod 2) then\n begin\n suma:=suma-a[i]+b[i];\n sumb:=sumb-b[i]+a[i];\n if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(1);\n suma:=suma+a[i]-b[i];\n sumb:=sumb+b[i]-a[i];\n end;\n exit(-1);\n end;\n if ((suma mod 2)=1) and ((sumb mod 2)=1) then\n begin\n if n>1 then\n for i:=1 to n do\n if (a[i] mod 2) <> (b[i] mod 2) then\n begin\n suma:=suma-a[i]+b[i];\n sumb:=sumb-b[i]+a[i];\n if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(1);\n suma:=suma+a[i]-b[i];\n sumb:=sumb+b[i]-a[i];\n end;\n exit(-1);\n end;\n\nEnd;\n\nBEGIN\n nhap;\n write(giai);\nEND.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,i,sx,sy:longint;\n f:array [0..4,0..4] of boolean;\n x,y:array [0..2000] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x[i],y[i]);\n sx:=sx+x[i]; sy:=sy+y[i];\n end;\n if (not odd(sx)) and (not odd(sy)) then\n begin\n writeln(0);\n halt(0);\n end;\n for i:=1 to n do\n if (not odd(sx-x[i]+y[i])) and (not odd(sy-y[i]+x[i])) then begin writeln(1); halt(0); end;\n writeln(-1);\nend."}, {"source_code": "var n,x,y,i,x1,y1,a,b,c:integer;\nbegin\na:=0;\nb:=0;\nread(n);\nx1:=0;\ny1:=0;\nfor i:=1 to n do begin\nread(x,y);\nx1:=x1+x;\ny1:=y1+y;\nif x=y then \nb:=b+1;\nif (x mod 2 = 0)and (y mod 2 = 0) then\na:=a+1;\nend;\nif (x1 mod 2 = 0)and (y1 mod 2 = 0) then\nwrite(0)\nelse\nbegin\nif (x1 mod 2=0)and (y1 mod 2=1)then\nwrite('-1');\nif (x1 mod 2 =1)and (y1 mod 2 =0) then\nwrite ('-1');\nif (x1 mod 2=1) and (y1 mod 2 =1) and(n>1) and (b=2) and (a=2)then begin\nwrite('-1');\nc:=1;\nend;\nif (x1 mod 2=1) and (y1 mod 2=1)and (n>1) and (n=b) then \nwrite('-1');\nif (x1 mod 2=1) and (y1 mod 2=1) and (n=1) then \nwrite('-1');\nif (x1 mod 2=1) and (y1 mod 2=1) and (n>1) and (b<>n) and (c<>1) then \nwrite('1');\nend;\nend."}, {"source_code": "program aaa;\n var\n n,i,k,l,x,y,met:longint;\n\n\n begin\n\n readln(n);\n\n k:=0; l:=0; met:=0;\n\n for i:=1 to n do\n begin\n readln(x,y);\n if (x+y) mod 2<>0 then met:=1;\n k:=k+x;\n l:=l+y;\n end;\n if (k+l) mod 2<>0 then write(-1) else\n if k mod 2=0 then write(0) else if met=1 then write(1) else write(-1);\n\n end."}, {"source_code": "var ii,n,i,x,y,ui,di:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(x,y);\nif (x mod 2=1) and (y mod 2=1)then\nii:=ii+1;\nif y mod 2=1 then\ndi:=di+1;\nif x mod 2=1 then\nui:=ui+1;\nend;\nif (ui mod 2=0) and (di mod 2=0) then\nwriteln(0)\nelse\nif ((ui mod 2)+(di mod 2)=2) and ((di-ii>0) or (ui-ii>0)) then\nwriteln(1)\nelse\nwriteln(-1);\nend."}, {"source_code": "var sx,sy,x,y,f,i,n:longint;\n begin\n // assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n f:=0;\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);sx:=sx+x;sy:=sy+y;\n if x mod 2<>y mod 2 then f:=1;\n end;\n if(sx mod 2=0)and(sy mod 2=0)then begin write(0);exit;end;\n if(sx mod 2=1)and(sy mod 2=1)and(f=1)then begin write(1);exit;end;\n writeln(-1);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n if n = 35 then begin writeln(1); exit end;\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale-uple) mod 2 <> 0) or ((nguale = uple) and odd(both)) then writeln(-1) else\n writeln(1);\n readln;\nend."}, {"source_code": "var\n k,i,sa,sb,n,a,b : longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n sa:=sa+a;\n sb:=sb+b;\n inc(k,ord(a mod 2 <> b mod 2));\n end;\n if (sa mod 2 = 0) and(sb mod 2 = 0) then writeln(0) else\n if (k > 0) and (k mod 2 = 0) then writeln(1) else writeln(-1);\nend."}, {"source_code": "var a,b,i,h,n,k,f:longint;\n x,y:array [1..101] of longint;\n begin\n read(n);\n for i:=1 to n do\n begin read(x[i],y[i]);a:=a+x[i];b:=b+y[i];end;\n if (a mod 2=0) and (b mod 2=0) then Writeln(0) else\n begin\n for i:=1 to n do\n begin\n f:=a-x[i]+y[i];\n h:=b-y[i]+x[i];\n if (f mod 2=0) and (h mod 2=0) then k:=1;\n end;\n if k=1 then Writeln(1) else Writeln(-1);\n end;\n\n end.\n"}, {"source_code": "var x,y:array[1..1000] of longint;\n n,i,q,w:longint;\n begin\n readln(n);\n for i:=1 to n do\n begin\n readln(x[i],y[i]);\n end;\n for i:=1 to n do\n begin\n q:=q+x[i];\n w:=w+y[i];\n\n end;\n if ((q mod 2=0) and(w mod 2=1)) or ((q mod 2 =1) and (w mod 2=0)) then\n begin\n write('-1');\n exit;\n end;\n if (q mod 2=0) and (w mod 2=0) then\n begin\n write('0');\n exit;\n end\n else\n for i:=1 to n do\n begin\n if ((x[i] mod 2=1) and (y[i] mod 2=0)) or\n ((x[i] mod 2=0) and (y[i] mod 2=1)) then\n begin\n write('1');\n exit;\n end;\n end;\n write('-1');\n end."}, {"source_code": "program DOMINO;\nType\n bg=record\n x,y:integer;\n end;\nVar a:array[1..100] of bg;\n N,i,j,ans,sumx,sumy:longint;\n Ok:boolean;\nBEGiN\n Read(N);Ok:=false;sumx:=0;sumy:=0;ans:=0;\n For i:=1 to N do\n With a[i] do\n begin\n Read(x,y);\n sumx:=sumx+x;\n sumy:=sumy+y;\n If (x+y) mod 2=1 then Ok:=true;\n end;\n IF (sumx+sumy) mod 2=1 then\n begin\n ans:=-1;\n \n end\n else If (sumx mod 2=0) and (sumy mod 2 =0) then\n begin\n ans:=0;\n \n end\n else IF (sumx mod 2=1) and (sumy mod 2=1) then\n begin\n If Ok then ans:=1 else ans:=-1;\n end;\n Write(ans);\n readln;\nEND.\n\n"}, {"source_code": "var \ns1,s2,n,a,b,i,q:longint;\nbegin\nread(n);\ns1:=0;\ns2:=0;\nq:=0;\nfor i:=1 to n do\n\tbegin\n\tread(a,b);\n\tif a mod 2 = 1 then inc(s1);\n\tif b mod 2 = 1 then inc(s2);\n\tif a mod 2 <> b mod 2 then inc(q);\n\tend;\nif s1 mod 2 = 0 then\nbegin\nif s2 mod 2 = 0 then writeln(0) else writeln(-1);\nend\nelse\nif s2 mod 2 = 0 then writeln(-1) else if q=0 then writeln(-1) else writeln(1);\nend.\n"}, {"source_code": "var x0,y0,x,y,c:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n if (x mod 2 = 1)xor(y mod 2 = 1)\n then inc(c);\n end;\n //writeln(x0,' ',y0);\n if ((x0 mod 2 = 1)xor(y0 mod 2 = 1))\n or((x0 mod 2 = 1)and(y0 mod 2 = 1)and(c=0))\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend.\n"}, {"source_code": "var\nn,i,q,qq,s,ss:longint;\nx,y:array[1..100000]of longint;\nbol:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nreadln(x[i],y[i]);\ns:=s+x[i];\nss:=ss+y[i];\nend;\nif (s mod 2 = 0)and(ss mod 2 = 0 ) then writeln(0)\nelse begin\n if (s mod 2 = 1)and(ss mod 2 = 0) then writeln(-1)\n else\n if (s mod 2 =0)and(ss mod 2 =1 ) then writeln(-1)\n else begin\n for i:=1 to n do begin\n q:=x[i] mod 2;\n qq:=y[i] mod 2 ;\n if q<>qq then bol:=true;\n end;\n if bol then writeln(1)\n else\n writeln(-1);\n end;\nend;\nend."}, {"source_code": "var\n a,b:array [1..101] of Longint;\n N,Kol1,Kol2,Kol3,Sum1,Sum2,i,Ans:Longint;\n F:Boolean;\nbegin\n Readln(N);\n for i:=1 to N do\nbegin\n Readln(a[i],b[i]);\n Sum1:=Sum1+a[i];\n Sum2:=Sum2+b[i];\n end;\n if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')\n else\nbegin\n for i:=1 to N do\n if ((((Sum1-a[i])+b[i])) mod 2=0) and ((((Sum2-b[i])+a[i])) mod 2=0) then begin Writeln('1'); Halt;\n end;\n Writeln('-1');\n end;\n\n end.\n"}, {"source_code": "var\n N,Kol,Sum1,Sum2,X,Y:Int64;\n i:Longint;\nbegin\n Readln(N);\n for i:=1 to N do\nbegin\n Read(X,Y);\n if ((X mod 2=0) and (Y mod 2=1)) or\n ((X mod 2=1) and (Y mod 2=0)) then Inc(Kol);\n Inc(Sum1,X);\n Inc(Sum2,Y);\n end;\n if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')\n else\n if (Sum1 mod 2=1) and (Sum2 mod 2=1) and (Kol=0) then Writeln('-1')\n else\n if ((Sum1 mod 2=1) and (Sum2 mod 2=0)) or ((Sum1 mod 2=0) and (Sum2 mod 2=1)) then Writeln('-1')\n else\n if Kol>0 then Writeln('1');\n end."}, {"source_code": "var f1,f2:text;n,lx,ly,q,i,x,y:byte;\nprocedure rd;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n); lx:=0;ly:=0;q:=0;\n for i:=1 to n do\n begin\n readln(f1,x,y);\n if x mod 2=1 then inc(lx);\n if y mod 2=1 then inc(ly);\n if (lx mod 2)<>(ly mod 2) then inc(q);\n end;\n close(f1);\n if lx mod 2=0 then\n begin\n if ly mod 2=0 then write(f2,0) else write(f2,-1);\n end else\n begin\n if ly mod 2=0 then write(f2,-1) else if q=0 then write(f2,-1) else\n write(f2,1);\n end;\n close(f2);\nend;\nbegin\n rd;\nend.\n"}, {"source_code": "var\n x,y:array[0..1000] of longint;\n i,j,n,m,l,r:longint;\n\nBegin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n inc(l,x[i]);\n inc(r,y[i]);\n end;\n if (l mod 2 = 0) and (r mod 2 = 0) then\n begin\n writeln(0);\n halt;\n end;\n for i:=1 to n do\n if ((l-x[i]+y[i]) mod 2 = 0) and ((r-y[i]+x[i]) mod 2 = 0) then\n begin\n writeln(1);\n halt;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "Var k,k1,n,i,ans,ans2,hh,h,l:longint;\n begin\n Read(n);\n for i:=1 to n do\n begin\n Read(k,k1);\n inc(ans,k); inc(ans2,k1);\n if k mod 2<>0 then inc(hh);\n if k1 mod 2<>0 then inc(h);\n if ((k mod 2<>0) and (k1 mod 2=0))or\n ((k mod 2=0) and (k1 mod 2<>0)) then inc(l);\n end;\n if (ans mod 2=0) and(ans2 mod 2=0) then writeln(0) else\n if (l>0)and(n>1)and(((hh mod 2<>0)and(h mod 2<>0))) then writeln(1) else\n writeln(-1);\n end."}, {"source_code": "{$mode objfpc}\nuses math;\ntype tp = record\n x , y : Int64;\n end;\nvar\n fi , fo : textfile;\n n , s1 , s2 : Int64;\n a : array[0..1000006] of tp;\n\nprocedure enter;\nvar\n i , j : integer;\nbegin\n Assign(fi , ''); reset(fi);\n Assign(fo , ''); rewrite(fo);\n s1 := 0; s2 := 0;\n ReadLn(fi , n);\n for i := 1 to n do\n begin\n read(fi , a[i].x , a[i].y);\n inc(s1 , a[i].x);\n inc(s2 , a[i].y);\n end;\nend;\n\nprocedure solve;\nvar\n i , j : integer;\nbegin\n if (s1 mod 2 = 0 ) and (s2 mod 2 = 0) then\n begin\n writeln(fo , 0);\n exit;\n end;\n if abs(s1 - s2) mod 2 = 1 then begin writeln(fo , -1); exit;end;\n begin\n for i := 1 to n - 1 do\n begin\n if abs(a[i].x - a[i].y) mod 2 = 1 then\n begin\n writeln(fo , 1);\n exit;\n end;\n\n end;\n end;\n writeln(fo , -1);\n exit;\nend;\n\nprocedure closefile;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n enter;\n solve;\n closefile;\nend.\n"}, {"source_code": "var n,a,b,i,c1,c2,k,e,z:integer;\nbegin\nread(n);\nc1:=0;\nc2:=0;\nk:=0;\ne:=0;\nfor i:=1 to n do begin\nread(a,b);\nc1:=c1+a;\nc2:=c2+b;\nif a=b then k:=k+1;\nif (a mod 2=0) and (b mod 2=0) then e:=e+1; \nend;\nif (c1 mod 2=0) and (c2 mod 2=0) then write('0')\nelse begin\nif (c1 mod 2=0) and (c2 mod 2=1) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=0) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=2) and (e=2) then begin\nwrite('-1');\nz:=1;\nend;\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k<>n) and (z<>1) then write('1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=n) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');\nend;\nend."}], "negative_code": [{"source_code": "var\n k,i,sa,sb,n : longint;\n a,b : array[0..100000] of longint;\n\nbegin\n readln(n);\n for i:=1 to n do begin readln(a[i],b[i]); inc(sa,a[i]); inc(sb,b[i]); end;\n for i:=1 to n do\n begin\n if (sa mod 2 = 0) and (sb mod 2 = 0) then continue;\n sa:=sa-a[i]+b[i]; sb:=sb-b[i]+a[i];\n inc(k);\n end;\n if (sa mod 2 = 0) and (sb mod 2 = 0) then writeln(k) else writeln(-1);\nend."}, {"source_code": "var i,n,x,y, a,b: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);\n if (odd(x)) and (odd(y)) then inc(b);\n end;\n\n\n if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else\n if ((a=0) and (b=0)) or (a=0) and (not odd(b)) then Writeln('0') else\n if odd(b) or (b=0) then Writeln('1');\nend."}, {"source_code": "PROGRAM Domino;\nVar a,b:array[1..100] of integer;\n n,t,suma,sumb:integer;\n\nProcedure nhap;\nVar i:longint;\nBegin\n readln(n);\n suma:=0;\n sumb:=0;\n for i:=1 to n do\n begin\n readln(a[i],b[i]);\n suma:=suma+a[i];\n sumb:=sumb+b[i];\n end;\nEnd;\n\nFunction giai:integer;\nVar i:longint;\nBegin\n if ((suma mod 2)=0) and ((sumb mod 2)=0) then exit(0);\n if (((suma mod 2)=1) and ((sumb mod 2)=0)) or (((suma mod 2)=0) and ((sumb mod 2)=1)) then\n begin\n if n>1 then\n for i:=1 to n do\n if (a[i] mod 2) <> (b[i] mod 2) then exit(1);\n exit(-1);\n end;\n if ((suma mod 2)=1) and ((sumb mod 2)=1) then\n begin\n if n>1 then\n for i:=1 to n do\n if (a[i] mod 2) <> (b[i] mod 2) then exit(1);\n exit(-1);\n end;\n\nEnd;\n\nBEGIN\n nhap;\n write(giai);\nEND.\n"}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n\n end;\n if nguale + uple mod 2 = 1 then writeln(-1) else\n writeln(abs(nguale + uple) div 2);\nend."}, {"source_code": "var i,n,x,y,s, np, pr, l, p: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (odd(y)) then inc(s);\n if (odd(x)) and (not odd(y)) then inc(l);\n if (not odd(x)) and (odd(y)) then inc(p);\n if odd(x) then inc(np) else inc(pr);\n end;\n\n if (s mod 2 = 0) and ((l+p) mod 2 = 0) then Writeln((l+p) div 2) else Writeln('-1');\nend."}, {"source_code": "var n,i,p,p1:longint;a,b:array[1..1000] of longint;\nbegin\nread(n);\nfor i:=1 to n do begin\nread(a[i],b[i]);\np:=p+ a[i] mod 2;\np1:=p1+ b[i] mod 2;\nend;\nIf (p+p1) mod 2=1 then writeln(-1) else\nIf p mod 2=0 then writeln(0) else writeln(1);\nend.\n"}, {"source_code": "Var k,k1,n,i,ans,ans2,hh,h:longint;\n begin\n Read(n);\n for i:=1 to n do\n begin\n Read(k,k1);\n inc(ans,k); inc(ans2,k1);\n if k mod 2<>0 then inc(hh);\n if k1 mod 2<>0 then inc(h);\n end;\n if (ans mod 2=0) and (ans2 mod 2=0)then writeln(0) else\n if (ans mod 2<>0) and (ans2 mod 2=0) or ((ans mod 2=0) and (ans2 mod 2<>0))or\n ((n=1) and (ans mod 2<>0)and(ans2 mod 2<>0))then writeln(-1) else\n if (hh=n)and(h=n) then writeln(-1) else\n writeln(1);\n end."}, {"source_code": "var n,a,b,i,c1,c2:integer;\nbegin\nread(n);\nc1:=0;\nc2:=0;\nfor i:=1 to n do begin\nread(a,b);\nc1:=c1+a;\nc2:=c2+b;\nend;\nif (c1 mod 2=0) and (c2 mod 2=0) then write('0')\nelse begin\nif (c1 mod 2=0) and (c2 mod 2=1) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=0) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) then write('1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');\nend;\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale - uple) mod 2 <> 0) and (n<>1) then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var n,x,y,i,x1,y1,a,b,c:integer;\nbegin\na:=0;\nb:=0;\nread(n);\nx1:=0;\ny1:=0;\nfor i:=1 to n do begin\nread(x,y);\nx1:=x1+x;\ny1:=y1+y;\nif (x mod 2 = 0)and (y mod 2 = 0) then\na:=a+1;\nend;\nif x=y then \nb:=b+1;\nif (x1 mod 2 = 0)and (y1 mod 2 = 0) then\nwrite(0)\nelse\nbegin\nif (x1 mod 2=0)and (y1 mod 2=1)then\nwrite('-1');\nif (x1 mod 2 =1)and (y1 mod 2 =0) then\nwrite ('-1');\nif (x1 mod 2=1) and (y1 mod 2 =1) and(n>1) and (b=2) and (a=2)then begin\nwrite('-1');\nc:=1;\nend;\nif (x1 mod 2=1) and (y1 mod 2=1)and (n>1) and (n=b) then \nwrite('-1');\nif (x1 mod 2=1) and (y1 mod 2=1) and (n=1) then \nwrite('-1');\nif (x1 mod 2=1) and (y1 mod 2=1) and (n>1) and (b<>n) and (c<>1) then \nwrite('1');\nend;\nend."}, {"source_code": "\nvar\n i, n, a, b, sum1, sum2: integer;\n f: text;\n\nprocedure xuly();\nbegin\n if (sum1 mod 2 = 0 ) and ( sum2 mod 2 = 0 ) then writeln('0')\n else if( ( sum1 mod 2 = 0) and ( sum2 mod 2 <> 0 ) ) or ( ( sum1 mod 2 <> 0 ) and ( sum2 mod 2 = 0 ) ) then writeln('-1')\n else begin\n if n = 1 then writeln('-1')\n else writeln('1');\n end;\nend;\n\nbegin\n assign(f, '');\n reset(f);\n\n readln(f, n);\n sum1 := 0;\n sum2 := 0;\n for i := 1 to n do begin\n readln(f, a, b);\n sum1 := sum1 + a;\n sum2 := sum2 + b;\n end;\n xuly;\n\n close(f);\n readln();\nend."}, {"source_code": "uses math;\nvar i,n,sol,temp:longint; x,y:array[1..1000] of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sol:=sol+x[i];\n temp:=temp+y[i];\n end;\n\n\n if (sol mod 2=0) and (temp mod 2=0) then\n begin\n write(0);\n exit;\n end ;\n\n\n\n\n if (sol mod 2<>0)and (temp mod 2<>0 ) then\n for i:=1 to n do\n if (x[i] mod 2<>0) and (y[i] mod 2=0) then\n begin\n\n writeln(1);\n exit;\n end\n\n\n else\n begin\n writeln(-1);\n exit;\n end;\n\n\n end .\n\n\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar i,n,sol,temp:longint; x,y:array[1..1000] of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sol:=sol+x[i];\n temp:=temp+y[i];\n end;\n\n\n if (sol mod 2=0) and (temp mod 2=0) then\n begin\n write(0);\n exit;\n end ;\n if (n=1) and (sol mod 2=0) and (temp mod 2=0) then\n begin\n writeln(0);\n exit;\n end;\n if (n=1) and (((sol mod 2<>0) and (temp mod 2=0)) or((sol mod 2=0) and (temp mod 2<>0) )) then\n begin\n writeln(-1);\n exit;\n end;\n\n\n\n\n\n if (sol mod 2<>0)and (temp mod 2<>0 ) then\n for i:=1 to n do\n if (x[i] mod 2<>0) and (y[i] mod 2=0) then\n begin\n\n writeln(1);\n exit;\n end\n\n\n else\n begin\n writeln(-1);\n exit;\n end;\n\n\n end .\n\n\n\n\n\n\n\n"}, {"source_code": "var i,n,x,y,s, np, pr, l, p, sum1, sum2: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (odd(y)) then inc(s);\n if (odd(x)) and (not odd(y)) then inc(l);\n if (not odd(x)) and (odd(y)) then inc(p);\n inc(sum1,x);\n inc(sum2,y);\n end;\n \n if (not odd(sum1)) and (not odd(sum2)) then\n begin\n Writeln('0');\n halt(0);\n end;\n \n if (not odd(l+p)) and (l+p<>0) and (odd(s)) then Writeln((l+p) div 2) else\n if (not odd(l+p)) and (l+p<>0) and (not odd(s)) then Writeln((l+p) div 2 - 1) else Writeln('-1');\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,d,i0,i1,i2:longint;\n r,m,x:int64;\n begin\n //init;\n readln(n);\n q:=0;\n c:=0;\n k:=0;\n for i:=1 to n do\n begin\n read(q0,c0);\n if ((odd(q0))and(odd(c0))) then inc(k);\n inc(q,q0); inc(c,c0);\n end;\n if odd(q+c) then writeln('-1') else\n if ((q mod 2=0)and(c mod 2=0)) then writeln('0') else\n if k=0 then writeln('2') else writeln('1');\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var i,n,x,y, a,b: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);\n if (odd(x)) and (odd(y)) then inc(b);\n end;\n\n if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else\n if odd(b) or (b=0) then Writeln('1') else Writeln('0');\nend."}, {"source_code": "Program adomino;\n\nvar\n\tx : array[1..100] of integer;\n\ty : array[1..100] of integer;\n\ti, a, b, n : integer;\n\tcek : boolean;\n\nbegin\n\treadln(n); a := 0; b := 0;\n\tcek := false;\n\tfor i:=1 to n do\n\tbegin\n\t\treadln(x[i], y[i]);\n\t\ta := a + x[i];\n\t\tb := b + y[i];\n\t\tif (((x[i] = 1) and (y[i] = 0)) or ((x[i] = 0) and (y[i] = 1))) then cek := true;\n\tend;\n\ta := a mod 2;\n\tb := b mod 2;\n\tif ((a = 1) and (b = 1) and cek) then writeln(1)\n\telse if ((a = 0) and (b = 0)) then writeln(0)\n\telse writeln(-1);\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale-uple) mod 2 <> 0) or (nguale = uple) then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var\na,b:array[1..101] of integer;\ni,n,q,w:integer;\nbegin\nreadln(n);\nq:=0;\nw:=0;\nfor i:= 1 to n do begin\nreadln(a[i],b[i]);\nq:=q+a[i];w:=w+b[i];end;\nif (q=1)and(w=1)then begin writeln('-1');exit;end;\nif (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');\nif (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');\nend."}, {"source_code": "{$mode objfpc}\nuses math;\ntype tp = record\n x , y : Int64;\n end;\nvar\n fi , fo : textfile;\n n , s1 , s2 : Int64;\n a : array[0..1000006] of tp;\n\nprocedure enter;\nvar\n i , j : integer;\nbegin\n Assign(fi , ''); reset(fi);\n Assign(fo , ''); rewrite(fo);\n s1 := 0; s2 := 0;\n ReadLn(fi , n);\n for i := 1 to n do\n begin\n read(fi , a[i].x , a[i].y);\n inc(s1 , a[i].x);\n inc(s2 , a[i].y);\n end;\nend;\n\nprocedure solve;\nvar\n i , j : integer;\nbegin\n if (s1 mod 2 = 0 ) and (s2 mod 2 = 0) then\n begin\n writeln(fo , 0);\n exit;\n end;\n if abs(s1 - s2) mod 2 = 1 then begin writeln(fo , -1); exit;end;\n begin\n for i := 1 to n - 1 do\n begin\n if abs(a[i].x - a[i].y) mod 2 = 1 then\n begin\n writeln(fo , 1);\n exit;\n end;\n writeln(fo , -1);\n exit;\n end;\n end;\n writeln(fo , -1);\n exit;\nend;\n\nprocedure closefile;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n enter;\n solve;\n closefile;\nend.\n"}, {"source_code": "program aaa;\nvar\ng,i,s,sx,n,x,y:integer;\nbegin\nreadln(n);\ns:=0;\nsx:=0;\nfor i:=1 to n do\nbegin\nreadln(x,y);\ns:=s+x+y;\nsx:=sx+x;\nend;\nif (s mod 2 =0) and (sx mod 2 = 0) then write(0)\n else write(-1);\nend."}, {"source_code": "program Project1;\nvar\n n,i,j : byte;\n sx,sy : smallint;\n x : array [1..100] of byte ;\n y : array [1..100] of byte ;\nbegin\n read(n);\n sx:= 0;\n sy:= 0;\n for i:= 1 to n do\n begin\n readln(x[i],y[i]);\n sx:= x[i] + sx;\n sy:= y[i] + sy;\n end;\n if (sx mod 2 = 0) and (sy mod 2 = 0)\n then begin\n writeln('0');\n exit;\n end;\n if (sx+sy) mod 2 <> 0\n then\n begin\n writeln('-1');\n exit;\n end;\n for i:= i to n do\n begin\n if ((x[i]+y[i]) mod 2) <> 0\n then\n begin\n writeln('1');\n exit;\n end;\n end;\nwriteln('-1');\nend. "}, {"source_code": "Const fin='205a.inp';\n fon='205a.out';\nVar res,x,y,a,b,n,d,d1,d2:longint;\nProcedure print;\nBegin\n Write(res);\nEnd;\n\nProcedure sol;\nBegin\n\nENd;\n\nProcedure init;\nVar i:longint;\nBegin\n Read(n);\n For i:=1 to n do\n Begin\n Read(a,b);\n If a mod 2=1 then\n Begin\n inc(x);\n d1:=d1+a;\n ENd;\n If b mod 2=1 then\n Begin\n inc(y);\n d2:=d2+b;\n ENd;\n If (a mod 2=1) and (a mod 2=b mod 2) then\n Begin\n inc(d);\n d1:=d1-a;\n d2:=d2-b;\n ENd;\n\n ENd;\n If (x+y=0) then\n Begin\n res:=0;\n exit;\n End;\n If (x<=1) then\n Begin\n If d=1 then\n Begin\n res:=-1;\n exit;\n ENd else begin\n res:=1;\n exit;\n ENd;\n ENd;\n If (x+y) mod 2 =1 then\n Begin\n res:=-1;\n exit;\n ENd;\n If (x mod 2=0) then\n Begin\n res:=0;\n exit;\n ENd Else Begin\n If (x=d) and (y=d) then\n Begin\n res:=-1;\n exit;\n ENd;\n res:=1;\n ENd;\n\n sol;\nENd;\n\nBEGIN\n //Assign(input,fin);reset(input);\n //Assign(output,fon);rewrite(output);\n init;\n print;\n //close(input);close(output);\nEND.\n\n"}, {"source_code": "var f1,f2:text;n,lx,ly,i:byte;ck:boolean;s:integer;\nx,y:array[1..100]of byte;\nprocedure rd;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n);\n for i:=1 to n do readln(f1,x[i],y[i]);\n ck:=true;s:=0;\n for i:=1 to n do\n begin\n if x[i]=y[i] then s:=s+x[i] else begin ck:=false;break;end;\n end;\n if ck=true then begin\n if s mod 2=0 then write(f2,0) else write(f2,-1);end else\n begin\n lx:=0;ly:=0;\n for i:=1 to n do\n begin\n if x[i] mod 2<>0 then inc(lx);\n if lx mod 2=0 then lx:=0;\n if y[i] mod 2<>0 then inc(ly);\n if ly mod 2=0 then ly:=0;\n end;\n close(f1);\n if lx=ly then write(f2,lx) else write(f2,-1);\n end;\n close(f2);\nend;\nbegin\n rd;\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if nguale = uple then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var\na,b,n,i,x,y:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if (x mod 2)<>0 then inc(a);\n if (y mod 2)<>0 then inc(b);\n end;\n if (a=0) and (b=0) then begin\n writeln(0);\n exit;\n end;\n if (a+b)mod 2<>0 then begin\n writeln(-1);\n exit;\n end;\n if (a>b) then begin\n writeln(a);\n end\n else writeln(b);\nend."}, {"source_code": "Const fin='205a.inp';\n fon='205a.out';\nVar res,x,y,a,b,n:longint;\nProcedure print;\nBegin\n Write(res);\nEnd;\n\nProcedure sol;\nBegin\n If x+y=0 then res:=0 else\n If x mod 2<>0 then res:=1 else res:=0;\nENd;\n\nProcedure init;\nVar i:longint;\nBegin\n Read(n);\n For i:=1 to n do\n Begin\n Read(a,b);\n If a mod 2<>0 then inc(x);\n If b mod 2<>0 then inc(y);\n ENd;\n If (x+y) mod 2=1 then res:=-1;\nENd;\n\nBEGIN\n //Assign(input,fin);reset(input);\n //Assign(output,fon);rewrite(output);\n init;\n If res>-1 then sol;\n print;\n //close(input);close(output);\nEND.\n\n"}, {"source_code": "uses math;\nvar n,i,pos:Longint;\n s:AnsiString;\n a:Array[0..1000000] of longInt;\n dp:Array[0..1000000,0..2] of longint;\n begin\n ReadLn(n);\n for i:=1 to n do\n Read(a[i]);\n readLn;\n readLn(s);\n for i:=Length(s) downto 1 do\n if s[i]='1' then begin pos:=i; break; end;\n dp[pos-1,1]:=a[pos];\n dp[pos-1,0]:=0;\n For i:=pos-1 downto 1 do\n begin\n if s[i]='1' then begin dp[i-1,1]:=dp[i,1]+a[i]; dp[i-1,0]:=max(dp[i,1],dp[i,0]+a[i]); end\n else\n begin\n dp[i-1,1]:=dp[i,1];\n dp[i-1,0]:=dp[i,0]+a[i];\n end;\n end;\n WriteLn(max(dp[0,0],dp[0,1]));\n end."}, {"source_code": "Var n,sa,sb,i:integer;\n a,b:array [1..101] of integer;\n oddf:boolean;\nbegin\n readln(n);\n for i:=1 to n do\n readln(a[i],b[i]);\n oddf:=false;\n for i:=1 to n do\n if (a[i]mod 2 =0) or (b[i] mod 2=0) then oddf:=true;\n for i:=1 to n do\n begin\n sa:=sa+a[i];\n sb:=sb+b[i];\n end;\n if (sa+sb) mod 2 = 1 then write('-1')\n else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')\n else if (sa mod 2 = 1) and (sb mod 2 = 1) then\n begin\n if oddf then write('1')\n else write('-1');\n end;\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale-uple) mod 2 <> 0) or (nguale = uple) then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var nn1,nn2,n,i,a,b,n1,n2,j:longint;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>0)and(b mod 2<>0) then inc(j);\n if a mod 2<>0 then inc(n1);\n if b mod 2<>0 then inc(n2);\n end;\n if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;\n nn1:=n1-j;nn2:=n2-j;\n if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else\n if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else\n writeln(1);\nEnd.\n"}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n //writeln(x0,' ',y0);\n if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))\n or(((x0+y0) mod 2 = 1)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend.\n"}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n writeln(x0,' ',y0);\n if (x0+y0) mod 2 <> 0\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend."}, {"source_code": "var n,i,a,b,s1,s2:byte;\nbegin\n readln(n); s1:=0; s2:=0;\n for i:=1 to n do\n begin\n readln(a,b); inc(s1,a); inc(s2,b);\n end;\n if ((s1+s2) mod 2=1) then writeln(-1) else\n begin\n if (s1 mod 2=0) then writeln(0) else writeln(1);\n end;\nend."}, {"source_code": "var x,y,n,i,s1,s2,f:integer;\n s:array[1..100] of integer;\nbegin\nreadln(n);\ns1:=0;\ns2:=0;\nf:=0;\nfor i:=1 to n do \n begin\n readln(x,y);\n s1:=s1+x;\n s2:=s2+y;\n s[i]:=x+y;\n end;\nif (s1 mod 2=0) and (s2 mod 2=0) then begin writeln('0'); halt; end;\nif ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) or ((s1 mod 2<>0) and (s2 mod 2<>0)) then begin writeln('-1'); halt; end;\nfor i:=1 to n do \n begin\n if s[i] mod 2<>0 then f:=1;\n end;\nif f=1 then writeln('1');\nend."}, {"source_code": "Var k,k1,n,i,ans,ans2,hh,h:longint;\n begin\n Read(n);\n for i:=1 to n do\n begin\n Read(k,k1);\n inc(ans,k); inc(ans2,k1);\n if k mod 2<>0 then inc(hh);\n if k1 mod 2<>0 then inc(h);\n end;\n if (ans mod 2=0) and (ans2 mod 2=0)then writeln(0) else\n if (ans mod 2<>0) and (ans2 mod 2=0) or ((ans mod 2=0) and (ans2 mod 2<>0))or\n ((n=1) and (ans mod 2<>0)and(ans2 mod 2<>0))then writeln(-1) else\n if (hh=n)or(h=n) then writeln(-1) else\n writeln(1);\n end."}, {"source_code": "var\na,b:array[1..101] of integer;\ni,n,q,w:integer;\nbegin\nreadln(n);\nq:=0;\nw:=0;\nfor i:= 1 to n do begin\nreadln(a[i],b[i]);\nq:=q+a[i];w:=w+b[i];end;\nif (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');\nif (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');\nend."}, {"source_code": "program Project1;\nvar\n n,i,j : byte;\n sx,sy : smallint;\n x : array [1..100] of byte ;\n y : array [1..100] of byte ;\nbegin\n read(n);\n sx:= 0;\n sy:= 0;\n for i:= 1 to n do\n begin\n read(x[i],y[i]);\n sx:= x[i] + sx;\n sy:= y[i] + sy;\n end;\n if (sx mod 2 = 0) and (sy mod 2 = 0)\n then begin\n writeln('0');\n //read(sy);\n exit;\n end;\n if (sx+sy) mod 2 <> 0\n then\n begin\n writeln('-1');\n //read(sy);\n exit;\n end;\n for i:= i to n do\n begin\n if ((x[i]+y[i]) mod 2) <> 0\n then\n begin\n writeln('1');\n //read(sy);\n exit;\n end;\n\n end;\nwriteln('-1');\n//read(sy);\nend. "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,k,h,t,p,k1,k2,a,b:longint;\n c:array [1..200] of longint;\nbegin\nreadln(n);\nk1:=0;\nk2:=0;\np:=0;\nfor i:=1 to n do begin\nread(a,b);\nif a mod 2 = 1 then k1:=k1+1;\nif b mod 2 = 1 then k2:=k2+1;\nif (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 <> 0) and (b mod 2 <> 0) then p:=1;\nreadln;\nend;\nif (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');\nif ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');\nif (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);\nread(n);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "Var i,j,k,n,m,suma,sumb:longint;\n a,b:array[0..100000]of longint;\n\t\nBegin\n read(n);\n for i:=1 to n do \n begin\n read(a[i]); Inc(suma);\n read(b[i]); Inc(sumb);\n end;\n if (suma+sumb) mod 2<>0 then \n begin writeln(-1); halt; end\n else \n if suma mod 2=0 then \n begin writeln(0); halt; end\n else \n begin\n for i:=1 to n do \n if (a[i]+b[i]) mod 2=1 then \n\t begin writeln(1); halt; end;\n writeln(-1);\n end;\nEnd."}, {"source_code": "var f1,f2:text;n,x,y,lx,ly,i:byte;\nprocedure rd;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n);\n lx:=0;ly:=0;\n for i:=1 to n do\n begin\n readln(f1,x,y);\n if x mod 2<>0 then inc(lx);\n if lx mod 2=0 then lx:=0;\n if y mod 2<>0 then inc(ly);\n if ly mod 2=0 then ly:=0;\n end;\n close(f1);\n if lx=ly then write(f2,lx) else write(f2,-1);\n close(f2);\nend;\nbegin\n rd;\nend.\n"}, {"source_code": "var i,a,b,n,k,l,h:integer;\nbegin\nread(n);\nk:=0;\nl:=0;\nh:=0;\nfor i:=1 to n do begin\nread(a,b);\nk:=k+a;\nl:=l+b;\nif (a mod 2<>b mod 2) then h:=1;\nend;\nif (k mod 2=0)and(l mod 2=0) then write(0);\nif (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);\nif (k mod 2<>0)and(l mod 2<>0)and(h=0) then write(-1);\nend."}, {"source_code": "program zada;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nn,x,y,i,t,a,b:integer;\nbegin\nreadln(n);\nt:=0;\nfor i:=1 to n do begin\nreadln(a,b);\nx:=x+a;\ny:=y+b;\nif ((a mod 2)<>0)and((b mod 2)<>0) then t:=1;\nend;\nif ((x mod 2)=0)and((y mod 2)=0) then begin\n writeln('0');\n exit;\n end;\nif (((x mod 2)=0)and((y mod 2)<>0))or(((x mod 2)<>0)and((y mod 2)=0)) then begin\n writeln('-1');\n exit;\n end;\nif ((x mod 2)<>0) and ((y mod 2)<>0) then begin\n if t=1 then begin\n writeln('-1');\n exit;\n end\n else begin\n writeln('1');\n end;\n end;\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale+uple) mod 2 <> 0) or (both mod 2 <> 0) then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "Program _353A;\nvar\n n, i, x, y, a, b, a1, b1, c : longint;\nbegin\n read(n);\n a := 0; b := 0; c := 0;\n for i := 1 to n do\n begin\n read(x, y);\n if x mod 2 = 0\n then begin\n if y mod 2 = 1\n then inc(a);\n end\n else if y mod 2 = 0\n then inc(b)\n else inc(c);\n end;\n a1 := a; b1 := b; \n a := a mod 2;\n b := b mod 2;\n c := c mod 2;\n \n if c = 0\n then if a = b\n then if a = 0\n then write(0)\n else write(1)\n else write(-1)\n else if (a + b = 1) or (a + b = 0) and (a1 + b1 > 0)\n then write(1)\n else write(-1);\nend."}, {"source_code": "var x0,y0,x,y,c:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n if (x mod 2 = 1)and(y mod 2 = 1)\n then inc(c);\n end;\n //writeln(x0,' ',y0);\n if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))\n or(((x0+y0+c) mod 2 = 1)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend.\n"}, {"source_code": "var n,i,x,y,t,s1,s2:integer;\nbegin\n t:=0;\n readln(n);\n s1:=0;\n s2:=0;\n for i:=1 to n do\n begin\n readln(x,y);\n s1:=x;\n s2:=y;\n if (x+y) mod 2=1 then t:=1;\n end;\n if (s1+s2) mod 2=1 then writeln(-1) else\n begin\n if (s1 mod 2=0) then writeln(0) else\n begin\n if t=1 then writeln(1) else writeln(-1);\n end;\n end;\nend."}, {"source_code": "var i,n,x,y, a,b: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);\n if (odd(x)) and (odd(y)) then inc(b);\n end;\n\n if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else\n if odd(b) or (b=0) then Writeln('1') else Writeln('0');\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if ((nguale - uple) mod 2 <> 0) and (n<>1) then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var n,i,x,y,t,s1,s2:integer;\nbegin\n t:=0;\n readln(n);\n s1:=0;\n s2:=0;\n for i:=1 to n do\n begin\n readln(x,y);\n s1:=x;\n s2:=y;\n if (x+y) mod 2=1 then t:=1;\n end;\n if (s1+s2) mod 2=1 then writeln(-1) else\n begin\n if (s1 mod 2=0) then writeln(0) else\n begin\n if t=1 then writeln(1) else writeln(-1);\n end;\n end;\nend."}, {"source_code": "Var i,x,y,kn1,kn2,kch1,kch2,n:longint;\nbegin\n //assign (input,'input.txt'); reset (input);\n //assign (output,'output.txt'); rewrite (output);\n readln (n);\n kn1:=0;\n kn2:=0;\n kch1:=0;\n kch2:=0;\n for i:=1 to n do begin\n readln (x,y);\n if x mod 2=1\n then inc(kn1)\n else inc(kch2);\n if y mod 2=1\n then inc(kn2)\n else inc(kch2);\n end;\n if (kn1 mod 2=0) and (kn2 mod 2=0)\n then begin\n writeln (0);\n exit;\n end;\n if kn1 mod 2=1\n then begin\n if (kn2+1) mod 2=0\n then begin\n writeln (1);\n exit;\n end\n else begin\n writeln (-1);\n exit;\n end;\n end;\n if ((kn1 mod 2=0) and (kn2 mod 2=1)) or ((kn1 mod 2=1) and (kn2 mod 2=0))\n then begin\n writeln (-1);\n exit;\n end;\nend.\n\n\n"}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n //writeln(x0,' ',y0);\n if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))or((x=y)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend."}, {"source_code": "Const fin='205a.inp';\n fon='205a.out';\nVar res,x,y,a,b,n,d,d1,d2:longint;\nProcedure print;\nBegin\n Write(res);\nEnd;\n\nProcedure sol;\nBegin\n\nENd;\n\nProcedure init;\nVar i:longint;\nBegin\n Read(n);\n For i:=1 to n do\n Begin\n Read(a,b);\n If a mod 2=1 then\n Begin\n inc(x);\n d1:=d1+a;\n ENd;\n If b mod 2=1 then\n Begin\n inc(y);\n d2:=d2+b;\n ENd;\n If (a mod 2=1) and (a mod 2=b mod 2) then\n Begin\n inc(d);\n d1:=d1-a;\n d2:=d2-b;\n ENd;\n\n ENd;\n If (x+y=0) then\n Begin\n res:=0;\n exit;\n End;\n If (x<=1) then\n Begin\n If d=1 then\n Begin\n res:=-1;\n exit;\n ENd else begin\n res:=1;\n exit;\n ENd;\n ENd;\n If (x+y) mod 2 =1 then\n Begin\n res:=-1;\n exit;\n ENd;\n If (x mod 2=0) then\n Begin\n res:=0;\n exit;\n ENd Else Begin\n If (x=d) and (y=d) then\n Begin\n res:=-1;\n exit;\n ENd;\n res:=1;\n ENd;\n\n sol;\nENd;\n\nBEGIN\n //Assign(input,fin);reset(input);\n //Assign(output,fon);rewrite(output);\n init;\n print;\n //close(input);close(output);\nEND.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,d,i0,i1,i2:longint;\n r,m,x:int64;\n begin\n //init;\n readln(n);\n q:=0;\n c:=0;\n k:=0;\n for i:=1 to n do\n begin\n read(q0,c0);\n if ((odd(q0))and(odd(c0))) then inc(k);\n inc(q,q0); inc(c,c0);\n end;\n if odd(q+c) then writeln('-1') else\n if ((q mod 2=0)and(c mod 2=0)) then writeln('0') else\n if k=0 then writeln('2') else writeln('1');\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var i,a,b,n,k,l,h:integer;\nbegin\nread(n);\nk:=0;\nl:=0;\nh:=0;\nfor i:=1 to n do begin\nread(a,b);\nk:=k+a;\nl:=l+b;\nif (a mod 2<>b mod 2) then h:=1;\nend;\nif (k mod 2=0)and(l mod 2=0) then write(0);\nif (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);\nif ((k mod 2<>0)or(l mod 2<>0))and(h=0) then write(-1);\nend."}, {"source_code": "var\na,b,n,i,x,y:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if (x mod 2)<>0 then inc(a);\n if (y mod 2)<>0 then inc(b);\n end;\n if (a=0) and (b=0) then begin\n writeln(0);\n exit;\n end;\n if (a+b)mod 2<>0 then begin\n writeln(-1);\n exit;\n end;\n if (a>b) then begin\n writeln(a);\n end\n else writeln(b);\nend."}, {"source_code": "var i,n,x,y, a,b: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) or (not odd(x)) and (odd(y)) then inc(a);\n if (odd(x)) and (odd(y)) then inc(b);\n end;\n\n if odd(a) or (a=0) and (odd(b)) then Writeln('-1') else\n if ((a=0) and (b=0)) or (a=0) and (not odd(b)) or (not odd(a)) and (not odd(b)) then Writeln('0') else\n if odd(b) or (b=0) then Writeln('1');\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if (nguale + uple - both) mod 2 = 1 then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "program Project8;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, nUp, nDown: Byte;\n nChangingDices:Boolean;\n nUpSum, nDownSum:SmallInt;\n inStr: string;\n\nfunction ExtractNextNum(s: string):string;\nbegin\n Result := Copy(inStr,1,Pos(' ', inStr)-1);\n Delete(inStr,1,Pos(' ', inStr));\nend;\n\nbegin\n\n nChangingDices:=false; //наличие костей, меняющих четность\n nUpSum:=0;\n nDownSum:=0;\n Readln(n);\n\n for i:=1 to n do\n begin\n Readln(instr);\n inStr := inStr + ' ';\n nUp := StrToInt(ExtractNextNum(inStr));\n nDown := StrToInt(ExtractNextNum(inStr));\n if (not nChangingDices) and (((nUp+nDown) mod 2)<>0) then nChangingDices:=true;\n nUpSum := nUpSum + nUp;\n nDownSum := nDownSum + nDown;\n end;\n\n if ((nUpSum mod 2)=0) and ((nDownSum mod 2)=0) then Writeln(0) //верх низ четные\n else if ((nUpSum+nDownSum) mod 2) <> 0 then Writeln(-1) //четное что-то одно (верх или низ) - без вариантов\n else if ((nUpSum mod 2)<>0) and ((nDownSum mod 2)<>0) and nChangingDices then writeln(1); //верх и низ нечетные, при наличии\n //\"меняющей\" (чет/нечет) кости\n\n readln;\n\nend.\n"}, {"source_code": "var i,n,x,y,s, np, pr, l, p: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (not odd(y)) then inc(l);\n if (not odd(x)) and (odd(y)) then inc(p);\n if odd(x) then inc(np) else inc(pr);\n end;\n\n if (l+p) mod 2 = 0 then Writeln((l+p) div 2) else Writeln('-1');\nend."}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n writeln(x0,' ',y0);\n if (x0+y0) mod 2 <> 0\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend."}, {"source_code": "var n,a,b,i,c1,c2:integer;\nbegin\nread(n);\nc1:=0;\nc2:=0;\nfor i:=1 to n do begin\nread(a,b);\nc1:=c1+a;\nc2:=c2+b;\nend;\nif (c1 mod 2=0) and (c2 mod 2=0) then write('0')\nelse begin\nif (c1 mod 2=0) and (c2 mod 2=1) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=0) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) then write('1');\nend;\nend."}, {"source_code": "var sum1,sum2,ans,i,n:integer;\n a:array [1..100,1..2] of integer;\nbegin\n readln(n);\n for i:=1 to n do begin\n readln(a[i,1],a[i,2]);\n inc(sum1,a[i,1]);\n inc(sum2,a[i,2]);\n end;\n \n if ((sum1 mod 2 = 1) and (sum2 mod 2 = 0)) or ((sum1 mod 2 = 0) and (sum2 mod 2 = 1)) then\n writeln(-1)\n else\n if (sum1 mod 2 = 0) and (sum2 mod 2 = 0) then\n writeln(0)\n else\n for i:=1 to n do\n if ((a[i,1] mod 2 = 1) and (a[i,2] mod 2 = 0)) or ((a[i,1] mod 2 = 0) and (a[i,2] mod 2 = 1)) then begin\n writeln(1);\n exit;\n end;\n \nend."}, {"source_code": "var i,a,b,n,k,l,h:integer;\nbegin\nread(n);\nk:=0;\nl:=0;\nh:=0;\nfor i:=1 to n do begin\nread(a,b);\nk:=k+a;\nl:=l+b;\nif (a mod 2<>b mod 2) then h:=1;\nend;\nif (k mod 2=0)and(l mod 2=0) then write(0);\nif (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);\nif (k mod 2<>0)and(l mod 2<>0)and(h=0) then write(-1);\nend."}, {"source_code": "var n,i,a,b,s1,s2:byte;\nbegin\n readln(n); s1:=0; s2:=0;\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>b mod 2) then inc(s1);\n if (a mod 2=1) and (b mod 2=1) then inc(s2);\n end;\n if (s1 mod 2=1) or (s2 mod 2=1) then writeln(-1) else writeln((s1+s2) div 2);\nend."}, {"source_code": "var i,a,b,n,k,l,h:integer;\nbegin\nread(n);\nk:=0;\nl:=0;\nh:=0;\nfor i:=1 to n do begin\nread(a,b);\nk:=k+a;\nl:=l+b;\nif (a mod 2<>b mod 2) then h:=1;\nend;\nif (k mod 2=0)and(l mod 2=0) then write(0);\nif (k mod 2=1)and(l mod 2=1)and(h=1) then write(1);\nif k mod 2<>l mod 2 then write(-1);\nend."}, {"source_code": "var n,a,b,i,c1,c2,k:integer;\nbegin\nread(n);\nc1:=0;\nc2:=0;\nk:=0;\nfor i:=1 to n do begin\nread(a,b);\nc1:=c1+a;\nc2:=c2+b;\nif a=b then k:=k+1;\nend;\nif (c1 mod 2=0) and (c2 mod 2=0) then write('0')\nelse begin\nif (c1 mod 2=0) and (c2 mod 2=1) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=0) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k<>n) then write('1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n>1) and (k=n) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) and (n=1) then write('-1');\nend;\nend."}, {"source_code": "var\na,b:array[1..101] of integer;\ni,n,q,w:integer;\nbegin\nreadln(n);\nq:=0;\nw:=0;\nfor i:= 1 to n do begin\nreadln(a[i],b[i]);\nq:=q+a[i];w:=w+b[i];end;\nif (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');\nif (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');\nend."}, {"source_code": "var nn1,nn2,n,i,a,b,n1,n2,j:longint;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>0)and(b mod 2<>0) then inc(j);\n if a mod 2<>0 then inc(n1);\n if b mod 2<>0 then inc(n2);\n end;\n if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;\n nn1:=n1-j;nn2:=n2-j;\n if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else\n if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else\n writeln(1);\nEnd.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,d,i0,i1,i2:longint;\n r,m,x:int64;\n begin\n //init;\n readln(n);\n q:=0;\n c:=0;\n k:=0;\n m:=0;\n for i:=1 to n do\n begin\n read(q0,c0);\n if not(odd(q0)) then m:=1;\n if not(odd(c0)) then m:=1;\n if (odd(q0+c0)) then inc(k);\n inc(q,q0); inc(c,c0);\n end;\n if ((odd(q))and(odd(c))and(m=0)) then writeln('-1') else\n if odd(q+c) then writeln('-1') else\n if ((q mod 2=0)and(c mod 2=0)) then writeln('0') else\n if k=0 then writeln('2') else writeln('1');\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n //writeln(x0,' ',y0);\n if ((x0 mod 2 <> 0)xor(y0 mod 2 <> 0))or((x=y)and(x0 mod 2 <> 0)and(y0 mod 2 <> 0))\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, a, b, two, x, y, t: integer;\nprocedure bad();\nbegin\n writeln(-1);\n halt(0);\nend;\nbegin\n readln(n);\n two := 0;\n a := 0;\n b := 0;\n for i := 1 to n do\n begin\n readln(x, y);\n t := x mod 2 + y mod 2;\n if (t = 2) then\n inc(two)\n else\n if (t = 1) then\n begin\n if (x mod 2 = 1) then\n inc(a)\n else\n inc(b);\n end;\n end;\n two := two mod 2;\n dec(a, two);\n dec(b, two);\n if (a mod 2 = 0) and (b mod 2 = 0) then\n writeln(0)\n else\n if ((a + b) mod 2 = 0) then\n writeln(1)\n else\n bad;\n readln;\n readln;\nend.\n"}, {"source_code": "var\n n,i,x,y,temp,upsum,downsum:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n inc(upsum,x);\n inc(downsum,y);\n if (x + y) mod 2 =1 then\n temp:=1;\n end;\n if (upsum+downsum) mod 2 = 0then\n if upsum mod 2 = 0 then\n write(temp)\n else if temp = 1 then\n write(1)\n else\n write(-1)\n else\n write(-1);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,k,h,t,p,k1,k2,a,b:longint;\n c:array [1..200] of longint;\nbegin\nreadln(n);\nk1:=0;\nk2:=0;\np:=0;\nfor i:=1 to n do begin\nread(a,b);\nif a mod 2 = 1 then k1:=k1+1;\nif b mod 2 = 1 then k2:=k2+1;\nif (a mod 2 = 1) and (b mod 2 = 1) then t:=0 else if (a mod 2 <> 0) and (b mod 2 <> 0) then p:=1;\nreadln;\nend;\nif (k1 mod 2 = 0) and (k2 mod 2 = 0 ) then writeln('0');\nif ((k1 mod 2 <> 0) and (k2 mod 2 = 0 )) or ((k1 mod 2 = 0) and (k2 mod 2 <> 0 )) then writeln('-1');\nif (k1 mod 2 <> 0) and (k2 mod 2 <> 0 ) then if p=0 then writeln('-1') else writeln(1);\nread(n);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var n,i,p,p1:longint;a,b:array[1..1000] of longint;\nbegin\nread(n);\nfor i:=1 to n do begin\nread(a[i],b[i]);\np:=p+ a[i] mod 2;\np1:=p1+ b[i] mod 2;\nend;\nIf p mod 2=0 then begin\n if p1 mod 2=0 then writeln(0) else writeln(-1)\n end else\n if p1 mod 2=1 then writeln(1) else\nwriteln(1);\nend."}, {"source_code": "var x0,y0,x,y:integer;\n i,n:integer;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n if x mod 2 = 1 then inc(x0);\n if y mod 2 = 1 then inc(y0);\n end;\n //writeln(x0,' ',y0);\n if (x0 mod 2 <> 0)and(y0 mod 2 <> 0)\n then\n begin\n writeln(-1);\n exit;\n end;\n if (x0 mod 2 = 0)and(y0 mod 2 = 0)\n then writeln(0)\n else writeln(1);\nend."}, {"source_code": "var\n n,i,x,y,temp,upsum,downsum:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n inc(upsum,x);\n inc(downsum,y);\n if (x + y) mod 2 =1 then\n temp:=1;\n end;\n if (upsum+downsum) mod 2 = 0then\n if upsum mod 2 = 0 then\n write(temp)\n else if temp = 1 then\n write(1)\n else\n write(-1)\n else\n write(-1);\nend."}, {"source_code": "uses math;\nvar i,n,sol,temp:longint; x,y:array[1..1000] of longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sol:=sol+x[i];\n temp:=temp+y[i];\n end;\n\n\n if (sol mod 2=0) and (temp mod 2=0) then\n begin\n write(0);\n exit;\n end ;\n if (n=1) and (sol mod 2=0) and (temp mod 2=0) then\n begin\n writeln(0);\n exit;\n end;\n if (n=1) and (((sol mod 2<>0) and (temp mod 2=0)) or((sol mod 2=0) and (temp mod 2<>0) )) then\n begin\n writeln(-1);\n exit;\n end;\n\n\n\n\n\n if (sol mod 2<>0)and (temp mod 2<>0 ) then\n for i:=1 to n do\n if (((x[i] mod 2<>0) and (y[i] mod 2=0) )or ((x[i] mod 2=0) and (y[i] mod 2<>0)))then\n begin\n\n writeln(1);\n exit;\n end\n\n\n else\n begin\n writeln(-1);\n exit;\n end;\n\n\n end ."}, {"source_code": "program domino;\nvar n,sb,sa,i:longint;\n a,b:byte;\n f:boolean;\nBEGIN\nsb:=0;\nsa:=0;\nf:=false;\nreadln(n);\nfor i:=1 to n do\n begin\n readln(a,b);\n sb:=sb+b;\n sa:=sa+a;\n if (a+b) mod 2=1 then f:=true;\n end;\nif n=1\n then\n if (sa mod 2=0) and (sb mod 2=0)\n then\n begin\n write('0');\n exit;\n end\n else\n begin\n write('-1');\n exit;\n end;\nif (sa mod 2=0) and (sb mod 2=0) \n then\n begin\n write('0');\n exit;\n end;\nif (sa mod 2=1) and (sb mod 2=1)\n then\n if f\n then\n begin\n write('1');\n exit;\n end\n\telse\n\tbegin\n\twrite('-1');\n\texit;\n\tend;\nif f \n then\n begin\n write('1');\n exit;\n end\n else\n begin\n write('-1');\n exit;\n end;\nEND."}, {"source_code": "var\n N,Kol,Sum1,Sum2,X,Y:Int64;\n i:Longint;\nbegin\n Readln(N);\n for i:=1 to N do\nbegin\n Read(X,Y);\n if ((X mod 2=0) and (Y mod 2=1)) or\n ((X mod 2=1) and (Y mod 2=0)) then Inc(Kol);\n Inc(Sum1,X);\n Inc(Sum2,Y);\n end;\n if (Sum1 mod 2=0) and (Sum2 mod 2=0) then Writeln('0')\n else\n if ((Sum1 mod 2=1) and (Sum2 mod 2=0)) or ((Sum1 mod 2=0) and (Sum2 mod 2=1)) then Writeln('-1')\n else\n if Kol>0 then Writeln('1');\n end."}, {"source_code": "var\na,b:array[1..101] of integer;\ni,n,q,w:integer;\nbegin\nreadln(n);\nq:=0;\nw:=0;\nfor i:= 1 to n do begin\nreadln(a[i],b[i]);\nq:=q+a[i];w:=w+b[i];end;\nif (q=1)and(w=1)then begin writeln('-1');exit;end;\nif (q mod 2 = 0)and( w mod 2 = 0) then writeln('0');\nif (q mod 2 = 0)and( w mod 2 = 1) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 0) then writeln('-1');\nif (q mod 2 = 1)and( w mod 2 = 1) then writeln('1');\nend."}, {"source_code": "Var n,sa,sb,i:integer;\n a,b:array [1..101] of integer;\nbegin\n readln(n);\n for i:=1 to n do\n readln(a[i],b[i]);\n for i:=1 to n do\n begin\n sa:=sa+a[i];\n sb:=sb+b[i];\n end;\n if (sa+sb) mod 2 = 1 then write('-1')\n else if (sa mod 2 = 0) and (sb mod 2 = 0) then write('0')\n else if (sa mod 2 = 1) and (sb mod 2 = 1) then write('1');\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g:Text;\n i,n,tong,tongl,tongr,a,b:longint;\nbegin\n assign(f,fi);\n reset(f);\n assign(G,fo);\n rewrite(g);\n readln(f,n);\n tong:=0;\n tongl:=0;\n tongr:=0;\n for i:=1 to n do\n begin\n readln(F,a,b);\n inc(tong,a+b);\n inc(tongl,a);\n inc(tongr,b);\n end;\n close(F);\n\n if tong mod 2 <> 0 then writeln(G,-1)\n else if (tongl mod 2 <> 0) or (tongr mod 2 <> 0) then writeln(g,1) else writeln(G,0);\n close(G);\nend.\n"}, {"source_code": "var nn1,nn2,n,i,a,b,n1,n2,j:longint;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>0)and(b mod 2<>0) then inc(j);\n if a mod 2<>0 then inc(n1);\n if b mod 2<>0 then inc(n2);\n end;\n nn1:=n1-j;nn2:=n2-j;\n if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else\n if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else\n if (n1 mod 2<>0)and(n2 mod 2<>0) then writeln(1) else\n if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;\nEnd.\n"}, {"source_code": "var i,n,x,y,s, np, pr, l, p, sum1, sum2: LongInt;\nbegin\n Readln(n);\n for i:=1 to n do\n begin\n Readln(x,y);\n if (odd(x)) and (odd(y)) then inc(s);\n if (odd(x)) and (not odd(y)) then inc(l);\n if (not odd(x)) and (odd(y)) then inc(p);\n inc(sum1,x);\n inc(sum2,y);\n end;\n \n if (not odd(sum1)) and (not odd(sum2)) then\n begin\n Writeln('0');\n halt(0);\n end;\n \n if (not odd(l+p)) and (l+p<>0) and (odd(s)) then Writeln((l+p) div 2) else\n if (not odd(l+p)) and (l+p<>0) and (not odd(s)) then Writeln((l+p) div 2 - 1) else Writeln('-1');\nend."}, {"source_code": "program za;\n\nvar\n a,b:array [1..100] of boolean;\n n,i,x,y,sumn1,sumn2,sumv1,sumv2:longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x,y);\n if x mod 2 = 0 then a[i]:=true\n else a[i]:=false;\n if y mod 2 = 0 then b[i]:=true\n else b[i]:=false;\n end;\n for i:=1 to n do\n begin\n if a[i] then inc(sumv2)\n else inc (sumv1);\n if b[i] then inc(sumn2)\n else inc (sumn1);\n end;\n if (sumn1=0) and (sumv1=0) then\n begin\n writeln(0);\n halt(0);\n end;\n if (sumn1=0) and (sumv1 mod 2 <> 0) then\n begin\n writeln(-1);\n halt(0);\n end;\n if (sumv1=0) and (sumn1 mod 2 <> 0) then\n begin\n writeln(-1);\n halt(0);\n end;\n if (sumn1 mod 2 <> 0) and (sumv1 mod 2 <> 0) then\n begin\n writeln(1);\n halt(0);\n end;\n if (n<=1) and ((sumv2<>1) or (sumn2<>1)) then\n begin\n writeln(-1);\n halt(0);\n end;\n writeln(0);\nend.\n\n\n\n"}, {"source_code": "var x,y,n,i,s1,s2,f:integer;\n s:array[1..100] of integer;\nbegin\nreadln(n);\ns1:=0;\ns2:=0;\nf:=0;\nfor i:=1 to n do \n begin\n readln(x,y);\n s1:=s1+x;\n s2:=s2+y;\n s[i]:=x+y;\n end;\nif (s1 mod 2=0) and (s2 mod 2=0) then begin writeln('0'); halt; end;\nif ((s1 mod 2=0) and (s2 mod 2<>0)) or ((s1 mod 2<>0) and (s2 mod 2=0)) then begin writeln('-1'); halt; end;\nfor i:=1 to n do \n begin\n if s[i] mod 2<>0 then f:=1;\n end;\nif f=1 then writeln('1');\nend."}, {"source_code": "var n,a,b,i,c1,c2:integer;\nbegin\nread(n);\nc1:=0;\nc2:=0;\nfor i:=1 to n do begin\nread(a,b);\nc1:=c1+a;\nc2:=c2+b;\nend;\nif (c1 mod 2=0) and (c2 mod 2=0) then write('0')\nelse begin\nif (c1 mod 2=0) and (c2 mod 2=1) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=0) then write('-1');\nif (c1 mod 2=1) and (c2 mod 2=1) then write('1');\nend;\nend."}, {"source_code": "var\n n,k,sx,sy,i : integer;\n x,y,s : array [1..100] of byte;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x[i],y[i]);\n sx:=sx+x[i];\n sy:=sy+y[i];\n s[i]:=x[i]+y[i];\n end;\n if ((sx+sy) mod 2=1) then\n begin\n writeln(-1);\n exit;\n end;\n if (sx mod 2=1) then\n begin\n for i:=1 to n do\n if s[i] mod 2=1 then\n begin\n writeln(1);\n exit;\n end;\n writeln(-1);\n end;\n writeln(0);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,ans,x,y,p:longint;\n a:array[0..1] of integer;\n\nbegin\n//assign(input,in_file); reset(input);\n//assign(output,out_file); rewrite(output);\n fillchar(a,sizeof(a),0);\n readln(n);\n p:=0;\n for i:=1 to n do\n begin\n readln(x,y);\n if ((x and 1)=1)and((y and 1)=1) then begin a[1]:=a[1]+1; a[0]:=a[0]+1; continue; end;\n if ((x and 1)=(y and 1)) then continue;\n if ((x and 1)=1) then a[0]:=a[0]+1 else a[1]:=a[1]+1;\n end;\n if (((a[0]+a[1]) and 1)=1) then begin writeln(-1); readln; halt; end;\n if (a[0]=0)or(a[1]=0)or((a[1] and 1)=0) then writeln(0) else writeln(1);\n readln;\n\n//close(output);\n//close(input);\nend.\n"}, {"source_code": "Program adomino;\n\nvar\n\tx : array[1..100] of integer;\n\ty : array[1..100] of integer;\n\ti, a, b, n : integer;\n\nbegin\n\treadln(n); a := 0; b := 0;\n\tfor i:=1 to n do\n\tbegin\n\t\treadln(x[i], y[i]);\n\t\ta := a + x[i];\n\t\tb := b + y[i];\n\tend;\n\ta := a mod 2;\n\tb := b mod 2;\n\tif (((a = 1) and (b = 0)) or ((a = 0) and (b = 1))) then writeln(-1)\n\telse if ((a = 1) and (b = 1)) then writeln(1)\n\telse {(a = 0) and (b = 0)} writeln(0);\nend."}, {"source_code": "uses math;\n\nvar n : int64;\n i,j : longint;\n x,y : longint;\n cnt,ans : longint;\n a : array[1..1000] of longint;\n s,s1,s2 : ansistring;\n\nbegin\n readln(n);\n\n for i := 1 to n do\n begin\n readln(x,y);\n if (x+y) mod 2 = 1\n then cnt := 1;\n\n a[1] := a[1] + x;\n a[2] := a[2] + y;\n end;\n\n if (a[1] mod 2 = 0) AND (a[2] mod 2 = 0)\n then writeln(0);\n\n if (a[1] mod 2 = 1) AND (a[2] mod 2 = 1) AND (cnt = 1)\n then writeln(1);\n\n if ((a[1]+a[2]) mod 2 = 1)\n then writeln(-1);\nend.\n"}, {"source_code": "var\n i, j :longint;\n n :longint;\n x, y :array[0..110] of longint;\n flag :array[0..110] of boolean;\n tot, ans :longint;\n tot11, tot01, tot10 :longint;\n f :boolean;\n\nbegin\n read(n);\n for i:=1 to n do read(x[i],y[i]);\n for i:=1 to n do\n begin\n x[i]:=x[i] mod 2;\n y[i]:=y[i] mod 2;\n end;\n\n for i:=1 to n do if (x[i]=0) and (y[i]=0) then flag[i]:=true;\n\n for i:=1 to n do if not flag[i] then\n if (x[i]=0) and (y[i]=1) then\n for j:=1 to n do if (not flag[j]) and (i<>j) then\n if (x[j]=0) and (y[j]=1) then\n begin\n flag[i]:=true;\n flag[j]:=true;\n break;\n end;\n\n for i:=1 to n do if not flag[i] then\n if (x[i]=1) and (y[i]=1) then\n for j:=1 to n do if (not flag[j]) and (i<>j) then\n if (x[j]=1) and (y[j]=1) then\n begin\n flag[i]:=true;\n flag[j]:=true;\n break;\n end;\n\n for i:=1 to n do if not flag[i] then\n if (x[i]=1) and (y[i]=0) then\n for j:=1 to n do if (not flag[j]) and (i<>j) then\n if (x[j]=1) and (y[j]=0) then\n begin\n flag[i]:=true;\n flag[j]:=true;\n break;\n end;\n tot:=0;\n for i:=1 to n do if not flag[i] then\n if (x[i]=0) and (y[i]=1) then inc(tot01) else\n if (x[i]=1) and (y[i]=0) then inc(tot10) else\n if (x[i]=1) and (y[i]=1) then inc(tot11);\n\n if (tot11=1) and (tot01=1) and (tot10=1) then writeln(0) else\n if (tot11=1) and (tot01=1) and (tot10=0) then writeln(-1) else\n if (tot11=1) and (tot10=1) and (tot01=0) then writeln(-1) else\n if (tot11=1) and (tot01=0) and (tot10=0) then writeln(-1) else\n if (tot01=1) and (tot10=1) then writeln(1) else\n if (tot01=0) and (tot10=0) then writeln(0) else writeln(-1);\nend."}, {"source_code": "var n,i,a,b,n1,n2,j:longint;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>0)and(b mod 2<>0) then inc(j);\n if a mod 2<>0 then inc(n1);\n if b mod 2<>0 then inc(n2);\n end;\n if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;\n if ((n1=j)or(n2=j))and(j<>0) then begin writeln(-1);halt;end;\n if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else writeln(1);\nEnd."}, {"source_code": "{$mode objfpc}\nvar\n i, n, uple, both, nguale: integer;\n x, y: array[1..101] of integer;\n\nbegin\n readln(n);\n for i := 1 to n do\n begin\n readln(x[i], y[i]);\n if odd(x[i]) then inc(nguale);\n if odd(y[i]) then inc(uple);\n if odd(x[i]) and odd(y[i]) then inc(both);\n\n end;\n if (nguale mod 2 = 0) and (uple mod 2 = 0) then\n begin\n writeln(0);\n exit;\n end;\n\n if (nguale - uple) mod 2 <> 0 then writeln(-1) else\n writeln(1);\nend."}, {"source_code": "var nn1,nn2,n,i,a,b,n1,n2,j:longint;\nBegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if (a mod 2<>0)and(b mod 2<>0) then inc(j);\n if a mod 2<>0 then inc(n1);\n if b mod 2<>0 then inc(n2);\n end;\n nn1:=n1-j;nn2:=n2-j;\n if (n1 mod 2=0)and(n2 mod 2=0) then writeln(0) else\n if ((n1 mod 2<>0)and(nn1=0))or((n2 mod 2<>0)and(nn2=0)) then writeln(-1) else\n if (n1 mod 2<>0)and(n2 mod 2<>0) then writeln(1) else\n if abs(n1-n2)mod 2<>0 then begin writeln(-1);halt; end;\nEnd.\n"}, {"source_code": "var n,i,a,b,s1,s2:byte;\nbegin\n readln(n); s1:=0; s2:=0;\n for i:=1 to n do\n begin\n readln(a,b); inc(s1,a); inc(s2,b);\n end;\n if ((s1+s2) mod 2=1) then writeln(-1) else\n begin\n if (s1 mod 2=0) then writeln(0) else writeln(1);\n end;\nend."}, {"source_code": "var\n n,i,x,y,temp,upsum,downsum:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n inc(upsum,x);\n inc(downsum,y);\n if (x + y) mod 2 =1 then\n temp:=1;\n end;\n if (upsum+downsum) mod 2 = 0then\n write(temp);\n if (upsum + downsum) mod 2 = 1 then\n write(-1);\nend."}, {"source_code": "program za;\n\nvar\n a,b:array [1..100] of boolean;\n n,i,x,y,sumn1,sumn2,sumv1,sumv2:longint;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x,y);\n if x mod 2 = 0 then a[i]:=true\n else a[i]:=false;\n if y mod 2 = 0 then b[i]:=true\n else b[i]:=false;\n end;\n for i:=1 to n do\n begin\n if a[i] then inc(sumv2)\n else inc (sumv1);\n if b[i] then inc(sumn2)\n else inc (sumn1);\n end;\n if (sumn1=0) and (sumv1=0) then\n begin\n writeln(0);\n halt(0);\n end;\n if (sumn1=0) and (sumv1 mod 2 <> 0) then\n begin\n writeln(-1);\n halt(0);\n end;\n if (sumv1=0) and (sumv1 mod 2 <> 0) then\n begin\n writeln(-1);\n halt(0);\n end;\n if (sumn1 mod 2 <> 0) and (sumv1 mod 2 <> 0) then\n begin\n writeln(1);\n halt(0);\n end;\n if (n<=1) and ((sumv2<>1) or (sumn2<>1)) then\n begin\n writeln(-1);\n halt(0);\n end;\n writeln(0);\nend.\n\n\n\n"}, {"source_code": "Program _353A;\nvar\n n, i, x, y, a, b, c : longint;\nbegin\n read(n);\n a := 0; b := 0; c := 0;\n for i := 1 to n do\n begin\n read(x, y);\n if x mod 2 = 0\n then begin\n if y mod 2 = 1\n then inc(a);\n end\n else if y mod 2 = 0\n then inc(b)\n else inc(c);\n end;\n a := a mod 2;\n b := b mod 2;\n c := c mod 2;\n \n if c = 0\n then if a = b\n then if a = 0\n then write(0)\n else write(1)\n else write(-1)\n else if a + b = 1\n then write(1)\n else write(-1);\nend."}], "src_uid": "f9bc04aed2b84c7dd288749ac264bb43"} {"source_code": "program _198C_DeliveringCarcinogen;\nuses math;\nconst eps=1e-9;\nvar xp,yp,vp,x,y,v,r:longint;\n\ttheta,w,RR,x0,y0,alpha,AB,OA,OB,t0,low,high,mid,h,DG1,DG2:extended;\n\nfunction viable(t:extended):boolean;\nbegin\n\tx0:=cos(theta+w*t)*RR;\n\ty0:=sin(theta+w*t)*RR;\n\tAB:=sqrt(sqr(x-x0)+sqr(y-y0));\n\talpha:=abs(arctan2(y,x)-arctan2(y0,x0));\n\tif alpha>pi then alpha:=2*pi-alpha;\n\tDG1:=arccos((sqr(OA)+sqr(AB)-sqr(OB))/(2*OA*AB));\n\tDG2:=pi-DG1-alpha;\n\th:=OA*sin(DG1);\n if (DG1b then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n function dd(x,y:point):double;\nbegin dd:=sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y)); end;\n\n function phi(a,b:double):double; label 222;var p:double;\nbegin\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\n\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n\n\n function ttt(ss:string):longint; var i,j,k,s:longint; fl:boolean;\n begin k:=length(ss);\n s:=0; for i:=1 to k do s:=10*s+ord(ss[i])-48;\n ttt:=s;\n end;\n\n { function dist2(xx,yy:double):double; var i,j:longint; dd,pp,tt:double;\n begin\n dd:=1e+20;\n for i:=1 to n do\n begin\n pp:=abs(xx*a[i]+yy*b[i]-c[i])/sqrt(a[i]*a[i]+b[i]*b[i]);\n if pp

=r then begin ot:=dd(a,b); goto 33; end;\n l1:=sqrt(r1*r1-r*r); l2:=sqrt(r2*r2-r*r);\n\n x:=arctan(l1/r);y:=arctan(l2/r);\n ot:=l1+l2+r*(ug-x-y);\n\n\n 33: dltr:=ot;\n end;\n\n\n\n begin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(xp,yp,vp);\n read(xx,yy,vv,r);\n aa:=0;bb:=10000000; ugg:=phi(xp,yp);\n while abs(aa-bb)>eps do\n begin\n cc:=(aa+bb)/2; ugt:=ugg+cc*vp/sqrt(xp*xp+yp*yp);\n a.x:=xx; a.y:=yy;\n b.x:=sqrt(xp*xp+yp*yp)*cos(ugt);\n b.y:=sqrt(xp*xp+yp*yp)*sin(ugt);\n c.x:=0;c.y:=0;\n if dltr(a,b)/vv0) then\n if (dj(sy,tp,sy,oy)/dis(sy,tp)0) then\n if (dj(sy,tp,sy,oy)/dis(sy,tp)0) then\n if (dj(sy,tp,sy,oy)/dis(sy,tp)r)then begin\n x01:=inf;y01:=inf;\n x02:=inf;y02:=inf;\n exit;\n end;\n dd:=r*r-d*d;\n if (abs(dd)0) then\n if (dj(sy,tp,sy,oy)/dis(sy,tp)r)then begin\n x01:=inf;y01:=inf;\n x02:=inf;y02:=inf;\n exit;\n end;\n dd:=r*r-d*d;\n if (abs(dd)=0 then exit(time*v-dis(xnow,ynow,stx,sty)>=0);\n\n dd:=(cida-cida1-cida2)*dan;\n\n dd:=dd+sqrt(xnow*xnow+ynow*ynow-dan*dan)+l3;\n\n exit(v*time-dd>=0);\nend;\nbegin\n readln(x1,y1,v1);\n readln(stx,sty,v,dan);\n if stx=x1 then if sty=y1 then\n begin\n writeln(0);\n halt;\n end;\n l3:=sqrt(stx*stx+sty*sty-dan*dan);\n r1:=sqrt(x1*x1+y1*y1);\n w1:=v1/r1;\n l:=0;\n r:=1e8;\n while abs(r-l)>eps do\n begin\n mid:=(l+r)*0.5;if check(mid) then begin r:=mid;\n ans:=mid;\n end\n else l:=mid;\n end;\n writeln(ans:0:8);\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n type point=record x,y:double; end;\n tar=record r1,r2,h:double; end;\nconst modul=1046527; modul7=1000000007;\n eps=1e-11; nnn=2000000;\n label 1,2,3,4;\nvar kolshag,w,h,pmax,imax,p1,p2,nn,n1,n2,kolm,j1,i,kk,t,tt,k,i3,i0,i1,i2,i4,step,j:longint;\np,kolraz,rr,s1,mmin,kolmax,x0,y0,vx,vy,f,ii,n,ot,besk,m,k1,k2,a2,jj:int64;\npzav,ott:double; tt2,ch,ch1,ch2:char;\nsss,ss,ss1,ss2:string;\nst,fin,a,b,c:point;\nddx,ddy,x,y,z:array [-2000..200000] of double;\ngr:array[-2001..2001,-2001..2001] of boolean;\npad: array[-2001..2001] of boolean;\ns:int64;\nugt,ugg,vv,xx,yy,xp,yp,vp,l,r, dt,dx,dy,aa,bb,cc,pp,t1,t2,x1,x2,tmin:double;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss1,sss2,sss3: string;\n\nflag2,flag1,flag:boolean;\nrzav,pprod:double;\nname:array[0..200] of string;\nfunction min(a,b:double):double;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n function dd(x,y:point):double;\nbegin dd:=sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y)); end;\n\n function phi(a,b:double):double; label 222;var p:double;\nbegin\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\n 222: phi:=p;\nend;\n\n\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n\n\n function ttt(ss:string):longint; var i,j,k,s:longint; fl:boolean;\n begin k:=length(ss);\n s:=0; for i:=1 to k do s:=10*s+ord(ss[i])-48;\n ttt:=s;\n end;\n\n { function dist2(xx,yy:double):double; var i,j:longint; dd,pp,tt:double;\n begin\n dd:=1e+20;\n for i:=1 to n do\n begin\n pp:=abs(xx*a[i]+yy*b[i]-c[i])/sqrt(a[i]*a[i]+b[i]*b[i]);\n if pp
=r then begin ot:=dd(a,b); goto 33; end;\n l1:=sqrt(r1*r1-r*r); l2:=sqrt(r2*r2-r*r);\n\n x:=arctan(l1/r);y:=arctan(l2/r);\n ot:=l1+l2+r*(ug-x-y);\n\n\n 33: dltr:=ot;\n end;\n\n\n\n begin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(xp,yp,vp);\n read(xx,yy,vv,r);\n aa:=0;bb:=10000000; ugg:=phi(xp,yp);\n while abs(aa-bb)>eps do\n begin\n cc:=(aa+bb)/2; ugt:=ugg+cc*vp/sqrt(xp*xp+yp*yp);\n a.x:=xx; a.y:=yy;\n b.x:=sqrt(xp*xp+yp*yp)*cos(ugt);\n b.y:=sqrt(xp*xp+yp*yp)*sin(ugt);\n c.x:=0;c.y:=0;\n if dltr(a,b)/vv 0 then findang:=0.5*pi\n else findang:=1.5*pi;\n end else\n if abs(y) < 1e-9 then\n begin\n if x > 0 then findang:=0\n else findang:=pi;\n end else\n begin\n ang:=arctan(abs(y/x));\n if (x < 0) and (y > 0) then ang:=pi-ang else\n if (x < 0) and (y < 0) then ang:=pi+ang else\n if (x > 0) and (y < 0) then ang:=2*pi-ang;\n findang:=ang;\n end;\nend;\n\nfunction dst(x,y:extended):extended;\nvar\n min: extended;\nbegin\n min:=abs(x-y);\n if abs(x+2*pi-y) < min then min:=abs(x+2*pi-y);\n if abs(x-2*pi-y) < min then min:=abs(x-2*pi-y);\n if abs(x+4*pi-y) < min then min:=abs(x+4*pi-y);\n if abs(x-4*pi-y) < min then min:=abs(x-4*pi-y);\n dst:=min;\nend;\n\nfunction go(x1,y1,x2,y2:extended):extended;\nvar\n ma,c1,c2,u1,u2,r1,r2,q1,q2,q3,q4,a,b,c,d,dist,d1,d2: extended;\n ok: boolean;\nbegin\n dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if dist < 1e-9 then\n begin\n go:=dist;\n exit;\n end;\n d1:=sqrt(sqr(x1)+sqr(y1));\n d2:=sqrt(sqr(x2)+sqr(y2));\n ok:=False;\n if d1*d1 > d2*d2+dist*dist then ok:=True;\n if d2*d2 > d1*d1+dist*dist then ok:=True;\n if not ok then\n begin\n a:=y2-y1; b:=x1-x2;\n c:=-a*x1-b*y1;\n d:=abs(c)/sqrt(a*a+b*b);\n if d < r then\n begin\n c1:=sqrt(x1*x1+y1*y1-r*r);\n c2:=sqrt(x2*x2+y2*y2-r*r);\n u1:=findang(x1,y1);\n u2:=findang(x2,y2);\n r1:=arctan(c1/r);\n q1:=u1-r1; q2:=u1+r1;\n r2:=arctan(c2/r);\n q3:=u2-r2; q4:=u2+r2;\n ma:=dst(q1,q3);\n if dst(q1,q4) < ma then ma:=dst(q1,q4);\n if dst(q2,q3) < ma then ma:=dst(q2,q3);\n if dst(q2,q4) < ma then ma:=dst(q2,q4);\n dist:=c1+c2+ma*r;\n end;\n end;\n go:=dist;\nend;\n\nbegin\n read(xp,yp,vp);\n read(x,y,v,r);\n ll:=0; rr:=1e9;\n for it:=1 to 500 do\n begin\n t:=(ll+rr)*0.5;\n ang:=t*vp/sqrt(xp*xp+yp*yp);\n xx:=xp*cos(ang)-yp*sin(ang);\n yy:=xp*sin(ang)+yp*cos(ang);\n if go(x,y,xx,yy) <= t*v then rr:=t\n else ll:=t;\n end;\n writeln((ll+rr)*0.5:0:17);\nend."}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar k,b,ta,tb,tc,td,xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=vp*time/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');\n //writeln(txp:0:9,' ',typ:0:9);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 1');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 2');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt=r)) or (tt>=r) then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 3');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n //writeln(tttt:0:9,' in 4');\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n// write(mid:0:9,' ');\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar k,b,ta,tb,tc,td,xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=vp*time/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt=r)) or (tt>=r) then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n\n\n\n"}], "negative_code": [{"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=(vp*time)/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n tt:=dis(x,y,0,0)*nt;\n if tt>=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=vp*time/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');\n //writeln(txp:0:9,' ',typ:0:9);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if nt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 1');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n if dt<=0 then\n begin\n //565656\n //writeln(dis(x,y,txp,typ):0:9,' in 1');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 2');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt=r then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 3');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n //writeln(tttt:0:9,' in 4');\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n// write(mid:0:9,' ');\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=(vp*time)/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n tt:=dis(x,y,0,0)*nt;\n if tt>=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:double;\nfunction dis(x1,y1,x2,y2:double):double;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:double):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=(vp*time)/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x-t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if dt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x-t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=dis(x,y,0,0)*nt;\n if tt>=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:real;\nfunction dis(x1,y1,x2,y2:real):real;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:real):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=vp*time/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=(vp*time)/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x-t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if dt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x-t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=dis(x,y,0,0)*nt;\n if tt>=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=vp*time/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n //write(x:0:9,' ',y:0:9,' ',txp:0:9,' ',typ:0:9,' ');\n //writeln(txp:0:9,' ',typ:0:9);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n dt:=(t1x*t2x+t1y*t2y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if nt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 1');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n if dt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 1');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2x+t1y*t2y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<=0 then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 2');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt=r then\n begin\n //writeln(dis(x,y,txp,typ):0:9,' in 3');\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n //writeln(tttt:0:9,' in 4');\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n// write(mid:0:9,' ');\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n\n"}, {"source_code": "//Copyright @ 2012, Mike Rush, All rights reserved.\nuses math;\nvar xp,yp,vp,x,y,v,r,dt,left,right,mid,rp,nt,txp,typ,t1x,t1y,t2x,t2y,tt,ttt,tt1,tt2,tttt:extended;\nfunction dis(x1,y1,x2,y2:extended):extended;\nbegin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;\nfunction check(time:extended):boolean;\nbegin\n rp:=dis(xp,yp,0,0);\n nt:=(vp*time)/rp;\n txp:=xp*cos(nt)-yp*sin(nt);\n typ:=yp*cos(nt)+xp*sin(nt);\n t1x:=-x;t1y:=-y;\n t2x:=t1x+txp;t2y:=t1y+typ;\n nt:=(t1x*t2y-t2x*t1y)/(dis(x,y,0,0)*dis(x,y,txp,typ));\n if nt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n t1x:=-txp;t1y:=-typ;\n t2x:=t1x+x;t2y:=t1y+y;\n dt:=(t1x*t2y-t2x*t1y)/(dis(txp,typ,0,0)*dis(x,y,txp,typ));\n if dt<0 then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=dis(x,y,0,0)*nt;\n if tt>=r then\n begin\n ttt:=dis(x,y,txp,typ);\n ttt:=ttt/v;\n if ttt<=mid then exit(true);\n exit(false);\n end;\n tt:=x*txp+y*typ;\n tt:=arccos(tt/(dis(x,y,0,0)*dis(txp,typ,0,0)));\n tt1:=arccos(r/dis(txp,typ,0,0));\n tt2:=arccos(r/dis(x,y,0,0));\n ttt:=tt-tt1-tt2;\n tttt:=ttt*r;\n tttt:=tttt+sqrt(sqr(dis(txp,typ,0,0))-sqr(r))+sqrt(sqr(dis(x,y,0,0))-sqr(r));\n tttt:=tttt/v;\n if tttt<=mid then exit(true);\n exit(false);\nend;\nbegin\n readln(xp,yp,vp);\n readln(x,y,v,r);\n if (xp=x) and (yp=y) then\n begin writeln(0.0:0:9);halt;end;\n left:=0;right:=1E5;\n while abs(left-right)>1E-10 do\n begin\n mid:=(left+right)/2;\n if check(mid) then right:=mid-(1E-10)\n else left:=mid+(1E-10);\n end;\n writeln(left:0:9);\nend.\n"}, {"source_code": "uses math;\nbegin\nend."}, {"source_code": "program _198C_DeliveringCarcinogen;\nuses math;\nconst eps=1e-9;\nvar xp,yp,vp,x,y,v,r:longint;\n\ttheta,w,RR,x0,y0,alpha,AB,OA,OB,t0,low,high,mid,h:extended;\n\nfunction viable(t:extended):boolean;\nbegin\n\tx0:=cos(theta+w*t)*RR;\n\ty0:=sin(theta+w*t)*RR;\n\talpha:=abs(arctan2(y,x)-arctan2(y0,x0));\n\tif alpha>pi then alpha:=2*pi-alpha;\n\tAB:=sqrt(sqr(x-x0)+sqr(y-y0));\n\tif abs(AB)>eps then h:=sin(alpha)*OA*OB/AB else h:=(OA+OB)/2;\n if (alpha>pi/2)and(ha[i,j] then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end;\nwriteln('YES');\nclose(input);close(output);\nend.", "positive_code": [{"source_code": "const d:array[1..8,1..2] of longint=((1,0),(0,1),(-1,0),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));\nvar n,m,i,j,k:longint;\nf:boolean;\na:array[1..1000,1..1000] of char;\nb:array[1..1000,1..1000] of boolean;\n\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do\n read(a[i,j]);\n readln;\n end;\nfor i:=2 to n-1 do\n for j:=2 to m-1 do\n begin\n f:=true;\n for k:=1 to 8 do\n if a[i+d[k,1],j+d[k,2]]='.' then f:=false;\n if f then\n begin\n for k:=1 to 8 do\n b[i+d[k,1],j+d[k,2]]:=true;\n end;\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if (a[i,j]='#') and (b[i,j]=false) then\n begin\n write('NO');\n close(input);close(output);halt;\n end;\nwrite('YES');\nclose(input);close(output);\nend."}, {"source_code": "var n,m,i,j:Longint;\nf,a:array [1..1002,1..1002] of char;\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out'); rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(a[i,j]);\n f[i,j]:='.';\n end;\n readln;\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if (a[i,j]='#') and (a[i,j+1]='#') and (a[i,j+2]='#') and (a[i+1,j]='#') and (a[i+1,j+2]='#') and (a[i+2,j]='#') and (a[i+2,j+1]='#') and (a[i+2,j+2]='#') then\n begin\n f[i,j]:='#';f[i,j+1]:='#';f[i,j+2]:='#';\n f[i+1,j]:='#';f[i+1,j+2]:='#';\n f[i+2,j]:='#';f[i+2,j+1]:='#';f[i+2,j+2]:='#';\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if f[i,j]<>a[i,j] then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end;\nwriteln('YES');\nclose(input);close(output);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n mt:array[0..1000,0..1000]of char;\n a:array[0..1000,0..1000]of longint;\n n,m:longint;\n f:text;\n\nprocedure doc;\nvar\n i,j:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n read(f,mt[i,j]);\n readln(f);\n end;\n close(f);\nend;\n\nfunction kt(i,j:longint):boolean;\nbegin\n if(mt[i-1,j-1]='#')and(mt[i-1,j]='#')and(mt[i-1,j+1]='#')and(mt[i,j-1]='#')and(mt[i,j+1]='#')and(mt[i+1,j-1]='#')and(mt[i+1,j]='#')and(mt[i+1,j+1]='#')then kt:=true\n else kt:=false;\nend;\n\nprocedure xuly;\nvar\n i,j:longint;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n if(kt(i,j))then\n begin\n a[i-1,j-1]:=1;\n a[i-1,j]:=1;\n a[i-1,j+1]:=1;\n a[i,j-1]:=1;\n a[i,j+1]:=1;\n a[i+1,j-1]:=1;\n a[i+1,j]:=1;\n a[i+1,j+1]:=1;\n end;\nend;\n\nprocedure xuat;\nvar\n i,j:longint;\n ktt:boolean;\nbegin\n assign(f,fo);\n rewrite(f);\n ktt:=true;\n for i:=1 to n do\n begin\n for j:=1 to m do\n if(mt[i,j]='#')and(a[i,j]=0)then\n begin\n ktt:=false;\n break;\n end;\n if(ktt=false)then break;\n end;\n if(ktt=true)then write(f,'YES')\n else write(f,'NO');\n close(f);\nend;\n\nbegin\n doc;\n xuly;\n xuat;\nend."}, {"source_code": "var\nbol:boolean;\nn,m,i,j:longint;\na,b:array[-10..1000,-10..1000]of char;\nbegin\nreadln(n,m);\nfor i:=1 to n do begin\n for j:=1 to m-1 do read(a[i,j]);\n readln(a[i,m]);\nend;\n\nfor i:=2 to n-1 do begin\n for j:=2 to m-1 do begin\n if(a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and(a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then\n begin\n b[i,j+1]:='1';\n b[i-1,j+1]:='1';\n b[i-1,j]:='1';\n b[i-1,j-1]:='1';\n b[i,j-1]:='1';\n b[i+1,j-1]:='1';\n b[i+1,j]:='1';\n b[i+1,j+1]:='1';\n end;\nend;\n\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nif (a[i,j]='#')and(b[i,j]<>'1') then bol:=true;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "type mass=array[1..1000,1..1000]of char;\nvar\n a,b:mass; f:boolean;\n i,j,k,l,n,m:integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(a[i,j]);\n b[i,j]:='.'\n end; \n readln; \n end;\n for i:=1 to n-2 do\n for j:=1 to m-2 do\n begin\n f:=true; \n for k:=0 to 2 do\n for l:=0 to 2 do\n begin\n if (k<>l) and (a[i+k,j+l]='.')\n then f:=false\n else if (k<>1) and (l<>1) and (a[i+k,j+l]='.')\n then f:=false;\n end;\n if f then \n for k:=0 to 2 do\n for l:=0 to 2 do\n begin\n if (k<>l)\n then b[i+k,j+l]:='#'\n else if (k<>1) and (l<>1)\n then b[i+k,j+l]:='#';\n end; \n end; \n f:=true; \n for i:=1 to n do\n begin\n for j:=1 to m do\n if (a[i,j]='#')\n then if (b[i,j]<>'#')\n then f:=false\n end;\n if f \n then writeln('YES')\n else writeln('NO')\nend."}, {"source_code": "var m,n:longint;\n a,b: array[0..1001,0..1001] of Boolean;\n\nprocedure main;\nvar i,j: longint;\nbegin\n for i:=1 to m-2 do\n for j:=1 to n-2 do\n begin\n if (a[i,j]) and (a[i,j+1]) and (a[i,j+2])\n and (a[i+1,j]) and (a[i+1,j+2])\n and (a[i+2,j]) and (a[i+2,j+1]) and (a[i+2,j+2]) then\n begin\n b[i,j]:=true;\n b[i,j+1]:=true;\n b[i,j+2]:=true;\n b[i+1,j]:=true;\n b[i+1,j+2]:=true;\n b[i+2,j]:=true;\n b[i+2,j+1]:=true;\n b[i+2,j+2]:=true;\n end;\n end;\n for i:=1 to m do\n for j:=1 to n do if a[i,j]<>b[i,j] then\n begin\n write('NO');exit;\n end;\n write('YES')\nend;\n\nprocedure inp;\nvar i,j: longint;\n c: char;\nbegin\n fillchar(a,sizeof(a),False);\n fillchar(a,sizeof(a),False);\n readln(m,n);\n for i:=1 to m do\n begin\n for j:=1 to n do\n begin\n read(c);\n if c='#' then a[i,j]:= True;\n end;\n readln;\n end;\nend;\n\nbegin\n inp;\n main;\nend.\n"}, {"source_code": "var n,m,i,j:longint;\ns:ansistring;\na:array[1..1003,1..1003] of byte;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n readln(s);\n for j:=1 to m do\n if s[j]='#' then a[i,j]:=1 else a[i,j]:=0;\n end;\n for i:=1 to n do\n for j:=1 to m do\n begin\n if ((a[i,j]=1) or (a[i,j]=2)) and (i<=n-2) and (j<=m-2) then\n if ((a[i,j+1]=1) or (a[i,j+1]=2)) and \n ((a[i,j+2]=1) or (a[i,j+2]=2)) and\n ((a[i+1,j]=1) or (a[i+1,j]=2)) and\n ((a[i+1,j+2]=1) or (a[i+1,j+2]=2)) and\n ((a[i+2,j]=1) or (a[i+2,j]=2)) and\n ((a[i+2,j+1]=1) or (a[i+2,j+1]=2)) and\n ((a[i+2,j+2]=1) or (a[i+2,j+2]=2)) then \n begin\n a[i,j]:=2;\n a[i,j+1]:=2;\n a[i,j+2]:=2;\n a[i+1,j]:=2;\n a[i+1,j+2]:=2;\n a[i+2,j]:=2;\n a[i+2,j+1]:=2;\n a[i+2,j+2]:=2;\n end;\n if a[i,j]=1 then\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES'); \nend.\n"}, {"source_code": "var i,j,n,m,k,o,s:longint;\na,b:array[0..1001,0..1001] of boolean;\nc:char;\nx:array[1..8] of longint=(1,1,-1,-1,0,0,1,-1);\ny:array[1..8] of longint=(1,-1,1,-1,1,-1,0,0);\nx1:boolean;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(c);\n if c='.' then a[i,j]:=true;\n end;\n readln;\n end;\n for i:=2 to n-1 do\n for j:=2 to m-1 do\n begin\n x1:=false;\n for k:=1 to 8 do\n if a[i+x[k],j+y[k]] then\n begin x1:=true;break;end;\n if not(x1) then\n for k:=1 to 8 do\n b[i+x[k],j+y[k]]:=true;\n end;\n for i:=1 to n do\n for j:=1 to m do\n if a[i,j]=b[i,j] then begin writeln('NO');halt;end;\n writeln('YES');\nend."}, {"source_code": "var\n i,j,n,m:longint;\n a:array[0..1001,0..1001] of char;\n f:array[0..1001,0..1001] of boolean;\nprocedure doit(x,y:longint);\n begin\n if (a[x+1,y]='.') or (a[x+2,y]='.') or (a[x,y+1]='.') or (a[x,y+2]='.') or (a[x+1,y+2]='.') or (a[x+2,y+1]='.') or (a[x+2,y+2]='.') then exit;\n f[x,y]:=true; f[x+1,y]:=true; f[x+2,y]:=true; f[x,y+1]:=true; f[x,y+2]:=true; f[x+1,y+2]:=true; f[x+2,y+1]:=true; f[x+2,y+2]:=true;\n end;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n read(a[i,j]);\n readln;\n end;\n for i:=1 to n-2 do\n for j:=1 to m-2 do\n if a[i,j]='#' then doit(i,j);\n for i:=1 to n do\n for j:=1 to m do\n if (a[i,j]='#') and (f[i,j]=false) then begin writeln('NO'); halt; end;\n writeln('YES');\nend.\n"}, {"source_code": " var i,j,n,m:longint;\n a,b:array [1..1001,1..1001] of char;\n begin\n {assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output);}\n\n read (n,m);\n\n for i:=1 to n do\n begin\n readln;\n for j:=1 to m do\n read (a[i,j]);\n\n\n end;\n\n for i:=2 to n-1 do\n for j:=2 to m-1 do\n begin\n if (a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and\n (a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then\n begin\n b[i,j+1]:='#';\n b[i-1,j+1]:='#';\n b[i-1,j]:='#';\n b[i-1,j-1]:='#';\n b[i,j-1]:='#';\n b[i+1,j-1]:='#';\n b[i+1,j]:='#';\n b[i+1,j+1]:='#';\n end;\n\n\n\n end;\n\n\n for i:=1 to n do\n for j:=1 to m do\n if a[i,j]='#' then\n if b[i,j]<>'#' then\n begin\n writeln ('NO');\n halt;\n end;\n\n\n writeln ('YES');\n\n\n\n\n\n\n\n end."}, {"source_code": "var a,b:array[0..1001,0..1001]of char;n,m,i,j:longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n \n for j:=1 to m do\n begin b[i,j]:='.';read(a[i,j]);end; \n readln;\n end;\n for i:=2 to n-1 do\n for j:=2 to m-1 do\n if (a[i-1,j-1]='#')and (a[i-1,j ]='#')and \n (a[i-1,j+1]='#')and (a[i ,j-1]='#')and \n (a[i ,j+1]='#')and (a[i+1,j-1]='#')and \n (a[i+1,j]='#')and (a[i+1,j+1]='#') then begin\n b[i-1,j-1]:='#'; b[i-1,j ]:='#'; \n b[i-1,j+1]:='#';b[i ,j-1]:='#'; \n b[i ,j+1]:='#'; b[i+1,j-1]:='#'; \n b[i+1,j]:='#';b[i+1,j+1]:='#';\n end;\n if a=b then write('YES') else write('NO');\nend."}, {"source_code": "program _1061B;\n\nvar n, m, i, j: integer;\n s: String;\n g: boolean;\n nm : array[1..1000, 1..1000] of char;\n nm2 : array[1..1000, 1..1000] of boolean;\n\nbegin\n readln(n, m);\n g := true;\n for i := 1 to n do\n begin\n readln(s);\n for j := 1 to m do\n nm[i, j] := s[j];\n end;\n \n for i := 2 to n-1 do\n for j := 2 to m-1 do\n begin\n if (nm[i-1, j] = '#') and (nm[i-1, j-1] = '#') and (nm[i-1, j+1] = '#') and (nm[i+1, j+1] = '#') and (nm[i+1, j-1] = '#') and (nm[i+1, j] = '#') and (nm[i, j-1] = '#') and (nm[i, j+1] = '#') then begin\n nm2[i-1, j] := true; \n nm2[i-1, j-1] := true;\n nm2[i-1, j+1] := true;\n nm2[i+1, j+1] := true;\n nm2[i+1, j-1] := true;\n nm2[i+1, j] := true;\n nm2[i, j-1] := true;\n nm2[i, j+1] := true;\n end;\n end;\n \n for i := 1 to n do\n for j := 1 to m do\n if (nm[i, j] = '#') and (nm2[i, j] <> true) then g := false;\n \n if g = true then \n write('YES') \n else\n write('NO');\nend."}, {"source_code": "program p;\nvar n, m: integer;\n a, b: array [-5..1005, -5..1005] of boolean;\n ch: char;\n \nbegin\nreadln(n, m);\nfor var g:=1 to n do\n begin\n for var g1:=1 to m do\n begin\n read(ch);\n if ch='#' then a[g, g1]:=true\n end;\n readln\n end;\n\nfor var g:=2 to n-1 do\n for var g1:=2 to m-1 do\n if a[g-1, g1] and a[g-1, g1+1] and a[g-1, g1-1] and\n a[g+1, g1] and a[g+1, g1+1] and a[g+1, g1-1] and\n a[g, g1+1] and a[g, g1-1] then\n begin\n for var g2:=g1-1 to g1+1 do\n begin\n b[g+1, g2]:=true;\n b[g-1, g2]:=true\n end;\n b[g, g1-1]:=true;\n b[g, g1+1]:=true\n end;\nif a=b then write('yes')\n else write('no')\nend."}, {"source_code": "var i,j,n,m:integer;\n a:string; \n s:array [1..1000,1..1000] of char;\nBegin\n//assign(input,'input.txt');\n//reset(input);\nreadln(n,m);\nfor i:=1 to n do begin\n readln(a);\n for j:=1 to m do\n s[i,j]:=a[j];\nend;\n\nfor i:=1 to n-2 do\n for j:=1 to m-2 do \n if ((s[i,j] = '#') or (s[i,j] = '*')) and ((s[i+1,j] = '#') or (s[i+1,j] = '*')) and ((s[i,j+1] = '#') or (s[i,j+1] = '*')) and ((s[i+2,j] = '#') or (s[i+2,j] = '*')) and ((s[i,j+2] = '#') or (s[i,j+2] = '*')) and ((s[i+1,j+2] = '#') or (s[i+1,j+2] = '*')) and ((s[i+2,j+1] = '#') or (s[i+2,j+1] = '*')) and ((s[i+2,j+2] = '#') or (s[i+2,j+2] = '*')) then begin\n s[i,j]:='*';\n s[i+1,j]:='*';\n s[i+2,j]:='*';\n s[i,j+1]:='*';\n s[i,j+2]:='*';\n s[i+1,j+2]:='*';\n s[i+2,j+1]:='*';\n s[i+2,j+2]:='*';\n end;\n\n//for i:=1 to n do begin\n// writeln();\n// for j:=1 to m do\n// write(s[i,j]);\n//end;\n\nfor i:=1 to n do\n for j:=1 to m do\n if (s[i,j] = '#') then begin\n writeln('NO');\n exit;\n end;\nwriteln('YES');\nend."}, {"source_code": " const eps=0.000000001; besk1=200000008; nnn=4600000;\n { modul=1000000007; }\n modul=998244353;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-100000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nnn] of longint;mass1=^mass;\n var nn,t3,t4,t5,t6,posmax,tmax,kold,kk,d,n,j2,ttt,ppp,kol,sq,sum,h,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,prod,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,aa,bb,cc,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,m,smin,cen:int64;\n i2,i3,step2,k1,k2,pp0,mask,k,i1,j1,step1, step, i,j:longint;\n y:mas;\n x,z:array[-1..15000012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n alpha,phi:extended;\n zzan:array[-1..2000,-1..2000] of boolean;\n sumkonfig,konfig:array[-1000..200000,-1..10] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,x1,y1,z1,z2,kolnul,a,fact,next,prev,xx,yy,str,s,name,dnew, voltay,l,r,c,day,b:mas;\n zz:array[0..125000000] of byte;\n ppole:array[-10..1002,-10..1005] of char;\n pole,ddd,dd2,dd3,dd4:array[-10..4200,-10..1020] of char;\n dd,ddnew:array[-1..1200,-1..2100] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n sss1,sss2:string;\n def,left,right,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..1060,-10..1060] of extended;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\n{function prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n }\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]ppole[i,j] then flag:=false;\n\n if flag then write('YES') else write('NO');\n\n\n\n\n1: close(output);\nend.\n"}, {"source_code": "var n, m, i, j, k, h: longint;\n a, b: array[1..1000, 1..1000] of char;\n ck: boolean;\n tmp: string;\nbegin\n read(n, m);\n for i := 1 to n do\n for j := 1 to m do b[i, j] := '.';\n readln;\n for i := 1 to n do\n begin\n read(tmp);\n readln;\n for j := 1 to m do\n begin\n a[i, j] := tmp[j];\n end;\n end;\n for i := 1 to n do\n for j := 1 to m do\n begin\n if(i + 2 <= n) and (j + 2 <= m) then\n if(a[i, j] = '#') and (a[i, j + 1] = '#') and (a[i, j + 2] = '#') and (a[i + 1, j] = '#') and (a[i + 1, j + 2] = '#') and (a[i + 2, j] = '#') and (a[i + 2, j + 1] = '#') and (a[i + 2, j + 2] = '#') then\n begin\n for k := i to i + 2 do\n begin\n for h := j to j + 2 do if(h <> j + 1) or (k <> i + 1) then b[k, h] := '#';\n end;\n if b[i + 1, j + 1] <> '#' then b[i + 1, j + 1] := '.';\n end;\n end;\n for i := 1 to n do\n for j := 1 to m do\n if a[i, j] <> b[i, j] then ck := true;\n if ck = true then write('NO')\n else write('YES');\nend."}, {"source_code": "var n,m,i,j:longint;\na,f:array[0..1000,0..1000]of char;\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do read(a[i,j]);\n readln;\n end;\nfillchar(f,sizeof(f),'.');\nfor i:=2 to n-1 do\n for j:=2 to m-1 do\n if(a[i-1,j]='#')and(a[i+1,j]='#')and(a[i,j-1]='#')and(a[i,j+1]='#')and(a[i-1,j-1]='#')and(a[i+1,j+1]='#')and(a[i+1,j-1]='#')and(a[i-1,j+1]='#')then\n begin\n f[i-1,j]:='#';f[i+1,j]:='#';f[i-1,j-1]:='#';f[i-1,j+1]:='#';\n f[i,j-1]:='#';f[i,j+1]:='#';f[i+1,j-1]:='#';f[i+1,j+1]:='#';\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if a[i,j]<>f[i,j] then\n begin\n writeln('NO');close(input);close(output);halt;\n end;\nwriteln('YES');\nclose(input);close(output);\nend."}, {"source_code": "var a:array[-10..1010,-10..1010] of char;\nf:array[-10..1010,-10..1010] of boolean;\ni,j,n,m:longint;\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do\n read(a[i,j]);\n readln;\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if (a[i-1,j]='#')and(a[i-1,j-1]='#')and(a[i-1,j+1]='#')and\n (a[i,j-1]='#')and(a[i,j+1]='#')and\n (a[i+1,j]='#')and(a[i+1,j-1]='#')and(a[i+1,j+1]='#') then\n begin\n f[i-1,j]:=true;f[i-1,j-1]:=true;f[i-1,j+1]:=true;\n f[i+1,j]:=true;f[i+1,j-1]:=true;f[i+1,j+1]:=true;\n f[i,j-1]:=true;f[i,j+1]:=true;\n end;\nfor i:=1 to n do\n for j:=1 to m do\n if (a[i,j]='#') and (f[i,j]=false) then\n begin\n writeln('NO');\n close(input);close(output);\n halt;\n end;\nwriteln('YES');\nclose(input);close(output);\nend.\n"}], "negative_code": [{"source_code": "var n, m, i, j, k, h: longint;\n a, b: array[1..1000, 1..1000] of char;\n ck: boolean;\n tmp: string;\nbegin\n read(n, m);\n for i := 1 to n do\n for j := 1 to m do b[i, j] := '.';\n readln;\n for i := 1 to n do\n begin\n read(tmp);\n readln;\n for j := 1 to m do\n begin\n a[i, j] := tmp[j];\n end;\n end;\n for i := 1 to n do\n for j := 1 to m do\n begin\n if(i + 2 <= n) and (j + 2 <= m) then\n if(a[i, j] = '#') and (a[i, j + 1] = '#') and (a[i, j + 2] = '#') and (a[i + 1, j] = '#') and (a[i + 1, j + 2] = '#') and (a[i + 2, j] = '#') and (a[i + 2, j + 1] = '#') and (a[i + 2, j + 2] = '#') then\n begin\n for k := i to i + 2 do\n begin\n for h := j to j + 2 do if(h <> j + 1) or (k <> i + 1) then b[k, h] := '#';\n end;\n if b[i + 1, j + 1] <> '#' then b[i + 1, j + 1] := '.';\n end;\n end;\n for i := 1 to n do\n begin\n for j := 1 to m do write(b[i, j]);\n writeln;\n end;\n for i := 1 to n do\n for j := 1 to m do\n if a[i, j] <> b[i, j] then ck := true;\n if ck = true then write('NO')\n else write('YES');\nend."}, {"source_code": "var n,m,i,j:longint;\nf,f1:boolean;\na:array[0..10001,0..10001] of char;\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do\n read(a[i,j]);\n readln;\n end;\nfor i:=2 to n-1 do\n for j:=2 to m-1 do\n if a[i,j]='.' then\n begin\n f1:=true;f:=true;\n if a[i-1,j]='.' then f:=false;\n if a[i+1,j]='.' then f:=false;\n if a[i,j-1]='.' then f:=false;\n if a[i,j+1]='.' then f:=false;\n if a[i-1,j-1]='.' then f:=false;\n if a[i-1,j+1]='.' then f:=false;\n if a[i+1,j-1]='.' then f:=false;\n if a[i+1,j+1]='.' then f:=false;\n if f=false then\n begin\n writeln('NO');\n close(input);close(output);halt;\n end;\n end;\nif (f1=false)and(n=3)and(n=3) then\n writeln('NO')\nelse\n writeln('YES');\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,m,i,j,x,y,o,k:longint;f:boolean;\nb:array[-500..500,-500..500]of longint;\na:array[-500..500,-500..500]of char;\nbegin\n//assign(input,'zj.in');reset(input);\n//assign(output,'zj.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to n do read(a[i,j]);\n readln;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if a[i,j]='.' then\n begin\n f:=true;\n for k:=i-1 downto i-m+1 do\n if a[k,j]<>'.' then f:=false;\n if f then\n for k:=i downto i-m+1 do inc(b[k,j]);\n f:=true;\n for k:=i+1 to i+m-1 do\n if a[k,j]<>'.' then f:=false;\n if f then\n for k:=i to i+m-1 do inc(b[k,j]);\n f:=true;\n for k:=j-1 downto j-m+1 do\n if a[i,k]<>'.' then f:=false;\n if f then\n for k:=j downto j-m+1 do inc(b[i,k]);\n f:=true;\n for k:=j+1 to j+m-1 do\n if a[i,k]<>'.' then f:=false;\n if f then\n for k:=j to j+m-1 do inc(b[i,k]);\n end;\nx:=1;y:=1;\nfor i:=1 to n do\n for j:=1 to n do\n if b[i,j]>o then\n begin\n o:=b[i,j];\n x:=i;y:=j;\n end;\nwrite(x,' ',y);\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,m,i,j,s:longint;\na:array[-5..10001,-5..10001]of char;\nbegin\n///assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfillchar(a,sizeof(a),'.');\nfor I:=1 to n do\n begin\n for j:=1 to m do read(a[i,j]);\n readln;\n end;\nfor I:=1 to n do\n for j:=1 to m do\n if a[i,j]='#' then\n begin\n if(a[i+1,j+1]<>'.')and(n=3)and(m=3)and(i=1)and(j=1)then\n begin\n write('NO');\n close(input);close(output);halt;\n end;\n if(i=3 then\n begin\n write('NO');\n close(input);close(output);halt;\n end;\n end;\nwrite('YES');\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,m,i,j:longint;f,f1:boolean;\na:array[0..1001,0..1001] of char;\nbegin\n//assign(input,'wz.in');reset(input);\n//assign(output,'wz.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to m do\n read(a[i,j]);\n readln;\n end;\nf:=true;\nfor i:=2 to n-1 do\n for j:=2 to m-1 do\n if a[i,j]='.' then\n begin\n f1:=true;\n if a[i-1,j]='.' then f:=false;\n if a[i+1,j]='.' then f:=false;\n if a[i,j-1]='.' then f:=false;\n if a[i,j+1]='.' then f:=false;\n if a[i-1,j-1]='.' then f:=false;\n if a[i-1,j+1]='.' then f:=false;\n if a[i+1,j-1]='.' then f:=false;\n if a[i+1,j+1]='.' then f:=false;\n if f=false then\n begin\n writeln('NO');\n close(input);close(output);halt;\n end;\n end;\nif (f)and(f1)or(f1=false)and((n<>3)or(m<>3)) then writeln('YES')\nelse writeln('NO');\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,m,i,j,x,y,o,k:longint;f:boolean;\nb:array[-500..500,-500..500]of longint;\na:array[-500..500,-500..500]of char; \nbegin\n//assign(input,'zj.in');reset(input);\n//assign(output,'zj.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n for j:=1 to n do read(a[i,j]);\n readln;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if a[i,j]='.' then\n begin\n f:=true;\n for k:=i-1 downto i-m+1 do\n if a[k,j]<>'.' then f:=false;\n if f then\n for k:=i downto i-m+1 do inc(b[k,j]);\n f:=true;\n for k:=i+1 to i+m-1 do\n if a[k,j]<>'.' then f:=false;\n if f then\n for k:=i to i+m-1 do inc(b[k,j]);\n f:=true;\n for k:=j-1 downto j-m+1 do\n if a[i,k]<>'.' then f:=false;\n if f then\n for k:=j downto j-m+1 do inc(b[i,k]);\n f:=true;\n for k:=j+1 to j+m-1 do\n if a[i,k]<>'.' then f:=false;\n if f then\n for k:=j to j+m-1 do inc(b[i,k]);\n end;\nx:=1;y:=1;\nfor i:=1 to n do\n for j:=1 to n do\n if b[i,j]>o then\n begin\n o:=b[i,j];\n x:=i;y:=j;\n end;\nwrite(x,' ',y);\nclose(input);close(output);\nend.\n"}, {"source_code": "var\nbol:boolean;\nn,m,i,j:longint;\na,b:array[-10..1000,-10..1000]of char;\nbegin\nreadln(n,m);\nfor i:=1 to n do begin\n for j:=1 to m do read(a[i,j]);\nend;\n\nfor i:=2 to n-1 do begin\n for j:=2 to m-1 do begin\n if(a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and(a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then\n begin\n b[i,j+1]:='1';\n b[i-1,j+1]:='1';\n b[i-1,j]:='1';\n b[i-1,j-1]:='1';\n b[i,j-1]:='1';\n b[i+1,j-1]:='1';\n b[i+1,j]:='1';\n b[i+1,j+1]:='1';\n end;\nend;\n\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nif (a[i,j]='#')and(b[i,j]<>'1') then bol:=true;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "var\nbol:boolean;\nn,m,i,j:longint;\na,b:array[-10..1000,-10..1000]of char;\nbegin\nreadln(n,m);\nfor i:=1 to n do begin\n for j:=1 to m do read(a[i,j]);\nend;\nn:=1;\nfor i:=2 to n do begin\n for j:=2 to n do begin\n if(a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and(a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then\n begin\n b[i,j+1]:='1';\n b[i-1,j+1]:='1';\n b[i-1,j]:='1';\n b[i-1,j-1]:='1';\n b[i,j-1]:='1';\n b[i+1,j-1]:='1';\n b[i+1,j]:='1';\n b[i+1,j+1]:='1';\n end;\nend;\n\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nif (a[i,j]='#')and(b[i,j]<>'1') then bol:=true;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "var\nbol:boolean;\nn,m,i,j:longint;\na,b:array[-10..1000,-10..1000]of char;\nbegin\nreadln(n,m);\nfor i:=1 to n do begin\n for j:=1 to m-1 do read(a[i,j]);\n readln(a[i,m]);\nend;\nn:=n-1;\nm:=m-1;\nfor i:=2 to n do begin\n for j:=2 to m do begin\n if(a[i,j+1]='#') and (a[i-1,j+1]='#') and (a[i-1,j]='#') and (a[i-1,j-1]='#') and(a[i,j-1]='#') and (a[i+1,j-1]='#') and (a[i+1,j]='#') and (a[i+1,j+1]='#') then\n begin\n b[i,j+1]:='1';\n b[i-1,j+1]:='1';\n b[i-1,j]:='1';\n b[i-1,j-1]:='1';\n b[i,j-1]:='1';\n b[i+1,j-1]:='1';\n b[i+1,j]:='1';\n b[i+1,j+1]:='1';\n end;\nend;\n\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nif (a[i,j]='#')and(b[i,j]<>'1') then bol:=true;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "type mass=array[1..1000,1..1000]of char;\nvar\n a,b:mass; f:boolean;\n i,j,k,l,n,m:integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(a[i,j]);\n b[i,j]:='.'\n end; \n readln; \n end;\n for i:=1 to n-2 do\n for j:=1 to m-2 do\n begin\n for k:=0 to 2 do\n for l:=0 to 2 do\n begin\n if (k<>l)\n then b[i+k,j+l]:='#'\n else if (k<>1) and (l<>1)\n then b[i+k,j+l]:='#';\n end;\n end; \n f:=true; \n for i:=1 to n do\n begin\n for j:=1 to m do\n if (a[i,j]='#') and (b[i,j]<>'#')\n then f:=false\n end;\n if f \n then writeln('YES')\n else writeln('NO')\nend."}, {"source_code": "type mass=array[1..1000,1..1000]of char;\nvar\n a,b:mass; f:boolean;\n i,j,k,l,n,m:integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(a[i,j]);\n b[i,j]:='.'\n end; \n readln; \n end;\n for i:=1 to n-2 do\n for j:=1 to m-2 do\n begin\n for k:=0 to 2 do\n for l:=0 to 2 do\n begin\n if (k<>l)\n then b[i+k,j+l]:='#'\n else if (k<>1) and (l<>1)\n then b[i+k,j+l]:='#';\n end;\n end; \n f:=true; \n for i:=1 to n do\n begin\n for j:=1 to m do\n if (a[i,j]='#')\n then if (b[i,j]<>'#')\n then f:=false\n end;\n if f \n then writeln('YES')\n else writeln('NO')\nend."}, {"source_code": "type mass=array[1..1000,1..1000]of char;\nvar\n a,b:mass;\n i,j,n,m:integer;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(a[i,j]);\n b[i,j]:='.'\n end; \n readln; \n end; \nend."}], "src_uid": "49e5eabe8d69b3d27a251cccc001ab25"} {"source_code": "uses math;\nvar\n i,j,k,n,m,s:longint;\n h1,h2,a,b:longint;\ndh:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n k:=0;\n dh:=h2-h1;\n if dh<=8*a then writeln(0)\n else begin \n dh:=dh-8*a+2*b;\n if (a>=b) then\n while (dh>0)and(k<100000) do begin\n dh:=dh+10*b-12*a;\n if (dh<=0) then begin\n writeln(k+1);\n dh:=-24*b;\n end;\n dh:=dh+2*b;\n k:=k+1;\n end;\n if dh>0 then writeln(-1);\n end;\n //\nend.", "positive_code": [{"source_code": "program z1;\nvar k,h1,h2,a,b:longint;\nbegin\nreadln(h1,h2,a,b);\nif ((h1+a*8)=h2 then k:=0 else\nbegin\nh1:=h1+a*8;\nwhile h1

= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n \n hev := 8 * a + h1;\n if hev>=h2 then begin\n write('0');\n Halt;\n end;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 12*k*hour >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype arr=array[1..1000000] of longint;\narr1=array[1..100,1..100] of longint;\nvar mas:arr;\ns:string;\nc:char;\ni,j,m,n,k,x,d,q,res,h1,h2:longint;\nbegin\n read(h1,h2);\n read(d,n);\n k:=0;\n if (n>=d) and ((h1+d*8)=h2 then writeln(0) else\n begin\n h1:=h1+d*8;\n while h1

=h2 then\n exit(0);\n if (h1+8*a0 then\n res:=res+1;\n solve:=res;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,solve);\n close(f);\nEnd;\n\n\nBegin\n nhap;\n xuat;\nEnd.\n"}, {"source_code": "var h1,h2,a,b,ans:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n inc(h1,8*a);\n if h1>=h2 then begin\n writeln(0);\n halt;\n end;\n if (h1=h2 then begin\n writeln(ans);\n halt;\n end;\n until false;\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif (l=r) or ((8*a)+l>=r) then\nbegin\n writeln(0);\n exit;\nend;\nif ((a>b) and (l>r)) or ((a1000000 then\n begin\n writeln('-1');\n exit;\n end;\n inc(res);\nend;\nwriteln(res);\nend.\n\n"}, {"source_code": "var\n a, b, c, d, e, f: int64;\n\nbegin\n readln(a, b);\n readln(c, d);\n f := 0;\n e := a + 8 * c;\n if (e < b) and (c <= d) then writeln(-1)\n else begin\n while e < b do \n begin\n dec(e, 12 * d);\n inc(e, 12 * c);\n inc(f);\n end;\n writeln(f);\n end;\nend."}, {"source_code": "var h1,h2,a,b,cur:integer;\nbegin\n readln(h1,h2);\n readln(a,b);\n cur:=h1+8*a;\n if h2<=cur then\n begin\n writeln(0);\n exit;\n end;\n if (b>=a) then \n begin\n writeln(-1);\n exit;\n end\n else\n if ((h2-cur) mod (a*12-b*12))=0 then writeln ((h2-cur) div (a*12-b*12)) else\n writeln(((h2-cur) div (a*12-b*12)) +1);\nend."}, {"source_code": "Var a,b,n,m,x,o,l,t,day,pr:LongInt;\n Begin\n Read(n,m,a,b);\n t:=14;\n While n=m then Break;\n n:=n-12*b;\n if a<=b then begin write(-1); halt end;\n Inc(day);\n t:=10;\n end;\n Write(day);\n end."}, {"source_code": "const fin='';\n fout='';\nvar a,b,s,t:longint;\n f,g:text;\nprocedure solve;\nvar i,swt,d:longint;\nbegin\n d:=1;\n while s=t then write(g,d);\n inc(d);\n end;\nend;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,s,t);readln(f,a,b);\n s:=s+a*8;\n if s>=t then write(g,0)\n else if a>b then solve\n else write(g,-1);\n close(f);close(g);\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,h1,h2,v,t,h3,vd:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(h1,h2);\nreadln(a,b);\nv:=a-b; vd:=v*12;\nif h1+(a*8)>=h2 then begin write(0); exit; end;\nif v<=0 then begin write(-1); exit; end;\nh1:=h1+a*8;\nfor t:=1 to 1000000 do\n begin\n h1:=h1-b*12+a*12; if h1>=h2 then begin write(t); exit; end;\n end;\nend."}, {"source_code": "Program _1;\nVar\n h1,h2,n,d,k,p:longint;\nBegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(h1,h2);\n read(d,n);\n k:=h1+d*8;\n if k>=h2 then begin\n write('0');\n exit;\n end\n else if d<=n then begin\n write('-1');\n exit;\n end;\n p:=-1*n*12+d*12;\n h1:=k;\n k:=0;\n while h1

= f then begin write('0'); exit; end;\nif b >= a then begin write('-1'); exit; end;\nt:=14;\nwhile s < f do\n if (t mod 24 >= 10) and (t mod 24 < 22) then\n begin\n t:=t + 1;\n s:=s + a;\n end\n else\n begin\n t:=t + 1;\n s:=s - b;\n end;\nwrite(t div 24);\nend.\n"}, {"source_code": "Var h,h1,a,b,k:longint;\n\n Begin\n read(h,h1);\n read(a,b);\n\n if h+a*8=h2) then begin\n write(0);\n halt;\n end;\n if s2>=s1 then begin\n write(-1);\n halt;\n end;\n a:=12*s1-12*s2;\n b:=h2-h1;\n if b mod a=0 then write(b div a)\n else write(b div a+1);\n\n end."}, {"source_code": "program fg;\nvar h1,h2,a,k,b:integer;\nbegin\nread(h1); readln(h2);\nread(a); readln(b);\nif h1+a*8>=h2 then k:=0\nelse \n if (a<=b) then k:=-1\n else begin\n h1:=h1+8*a;k:=0;\n while h1

=b) then\n while (dh>0)and(k<100000) do begin\n dh:=dh+10*b-12*a;\n if (dh<=0) then begin\n writeln(k+1);\n dh:=-24*b;\n end;\n dh:=dh+2*b;\n k:=k+1;\n end;\n if dh>0 then writeln(-1);\n end;\n \nend."}, {"source_code": "const inf = 500000;\nvar i,j,k,n,m,s,ans,h1,h2,sth,a,b:longint;\n\nprocedure ex(k:longint);\nbegin\n write(k);\n halt;\nend;\n\nbegin\n read(sth,h2,k,b);\n h1:=sth;\n k:=k*4;\n b:=b*12;\n\n if h1 >= h2 then ex(0);\n\n inc(h1,2*k);\n if h1 >= h2 then ex(0);\n dec(h1,b);\n\n while h1 < h2 do\n begin\n inc(h1,k);\n\n inc(ans);\n if (h1 <= sth) and (ans > 10) then ex(-1);\n\n if h1 >= h2 then break;\n inc(h1,k*2);\n if h1 >= h2 then break;\n\n dec(h1,b);\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "program fdf;\nvar h1,h2,a,b,n,k:longint;\nbegin\nread(h1,h2);\nread(a,b);\nif (a<=b)then\n if (h1+a*8>=h2) then write('0')\n else write('-1')\nelse\n begin\n if (h2<=h1+a*8) then write('0')\n else\n begin\n n:=h2-h1-8*a;\n if (n<=0) then write ('1')\n else\n repeat\n n:=n-12*a+12*b;\n k:=1+k;\n until (n<=0);\n write(k);\n end;\n end;\nend.\n\n\n\n"}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\nreadln(h1,h2);\nreadln(a,b);\nk:=0;\nif (a>b) or (a*8+h1>=h2) then begin\nh1:=a*8+h1;\nwhile h1

a * 8)\n then\n writeln(-1)\n else\n begin\n x := h1 + a * 8;\n a := a * 12;\n b := b * 12;\n if x >= h2\n then\n writeln(0)\n else\n if not(trunc((h2 - x) / (a - b)) < (h2 - x) / (a - b))\n then\n writeln((h2 - x) div (a - b))\n else\n writeln(((h2 - x) div (a - b)) + 1)\n end;\nend."}, {"source_code": "program pr1;\nvar h1,h2,a,b,k,i:integer;\nbegin\nread(h1,h2);\nread(a,b);\ni:=0;\nk:=h2-h1-8*a;\nif ((k>0) and (a<=b)) then\ni:=-1\nelse\nif (k>0) then\n while (k>0) do \n begin\n k:=k+12*b-12*a;\n i:=i+1;\n end;\nwrite(i);\nend."}, {"source_code": "var i, n, m, k, l, o, p, ans, h1, h2, a, b, ans1:LongInt;\n Begin\n Read(h1, h2);\n Read(a, b);\n\n\n Inc(h1, a*8);\n if (h1>= h2) then Begin WriteLn(0);Halt;End;\n if a=h2 then Begin WriteLn(ans);Halt;End;\n if (a=b) then Begin WriteLn(-1);Halt;End;\n Dec(h1, b*2);\n\n End;\n\n End.\n"}, {"source_code": "var\nh1,h2,a,b:integer;\nbegin\nreadln(h1,h2);\nreadln(a,b);\nif h1+8*a>=h2\nthen writeln(0)\nelse if a<=b\n then writeln(-1)\n else if ((h2-h1-8*a) mod (12*(a-b))=0)\n then writeln((h2-h1-8*a) div (12*(a-b)))\n else writeln((h2-h1-8*a) div (12*(a-b))+1);\nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b >= a) and (h2 > h1 + 8*a) then write(-1) else begin\n while h1

= h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n write(k); \n end;\n \nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n h1:=h1+8*a;\n if h1>=h2 then write(0) \n else\n if a<=b then write(-1)\n else \n write((h2-h1+12*a-12*b-1)div(12*a-12*b))\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i2,j2,aa,bb,i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\nqq,newdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,pp,tt,ot1,ot2,s,kold,n:int64;\ndef,xx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nb1,a1,next,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-200000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\ndd:array[-21..2001,-2001..2001] of int64;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\nread(h1,h2);\nread(t1,t2);\n for i:=0 to 1000000 do\n begin\n if i>0 then h1:=h1+12*t1 else h1:=h1+8*t1;\n if h1>=h2 then begin write(i); goto 1; end;\n h1:=h1-12*t2;\n end;\n writeln(-1);\n\n\n\n\n\n 1: close(output);\nend.\n\n"}], "negative_code": [{"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 24*k*hour >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, day, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a < b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n day := 12 * a - 12 * b;\n for k := 1 to 100001 do \n if hev + k * day >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 12*k*hour >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, day, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n day := 12 * a - 12 * b;\n for k := 1 to 10000001 do \n if hev + k * day >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 24*(k-1)*hour+8*a-12*b >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var h1,h2,a,b,k,day,hev:integer;\nbegin\nread(h1,h2);\nreadln;\nread(a,b);\nif (a=h2) and (a<=b) then begin\nwrite('0');\nHalt;\nend;\nhev:=8*a+h1;\nday:=12*a-12*b;\nfor k:=1 to 100001 do if hev+k*day>=h2 then begin\nwrite(k);\nHalt;\nend;\nend."}, {"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 24*(k-1)*hour+9*a-12*b >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 24*(k-1)*hour+9*a >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var\n h1, h2, a, b, k, hour, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a <=b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n hour := a-b;\n for k := 1 to 10000001 do \n if hev + 24*(k-1)*hour+8*a >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var h1,h2,a,b,k,day,hev:integer;\nbegin\nread(h1,h2);\nreadln;\nread(a,b);\nif (a=h2) and (a<=b) then begin\nwrite('0');\nHalt;\nend;\nhev:=8*a+h1;\nday:=12*a-12*b;\nfor k:=1 to 100001 do if hev+k*day-day+8*a>=h2 then begin\nwrite(k);\nHalt;\nend;\nend."}, {"source_code": "var\n h1, h2, a, b, k, day, hev: integer;\n\nbegin\n read(h1, h2);\n readln;\n read(a, b);\n if (a < b) and (8 * a + h1 < h2) then begin\n write('-1');\n Halt;\n end;\n if (8 * a + h1 >= h2) and (a <= b) then begin\n write('0');\n Halt;\n end;\n hev := 8 * a + h1;\n day := 12 * a - 12 * b;\n for k := 1 to 100001 do \n if hev + k * day - day >= h2 then begin\n write(k);\n Halt;\n end;\nend."}, {"source_code": "var h1,h2,a,b,k,day,hev:integer;\nbegin\nread(h1,h2);\nreadln;\nread(a,b);\nif (a=h2) and (a<=b) then begin\nwrite('0');\nHalt;\nend;\nhev:=8*a+h1;\nday:=12*a-12*b;\nfor k:=1 to 100001 do if hev+k*day>=h2 then begin\nwrite(k);\nHalt;\nend;\nend."}, {"source_code": "Const Finp='';\n Fout='';\nVar h1,h2,a,b:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n readln(f,h1,h2);\n read(f,a,b);\n close(f);\nEnd;\nFunction Solve:longint;\nVar res,temp:longint;\nBegin\n if h1>h2 then\n h2:=h1-h2\n else\n h2:=h2-h1;\n if a0 then\n inc(res);\n solve:=res;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,solve);\n close(f);\nEnd;\n\n\nBegin\n nhap;\n xuat;\nEnd."}, {"source_code": "Const Finp='';\n Fout='';\nVar h1,h2,a,b:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n readln(f,h1,h2);\n read(f,a,b);\n close(f);\nEnd;\nFunction Solve:longint;\nVar res,temp:longint;\nBegin\n if h1+8*a>=h2 then\n exit(0);\n if (h1+8*ah2 then\n h2:=h1-h2\n else\n h2:=h2-h1;\n if a0 then\n inc(res);\n solve:=res;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,solve);\n close(f);\nEnd;\n\n\nBegin\n nhap;\n xuat;\nEnd."}, {"source_code": "Const Finp='';\n Fout='';\nVar h1,h2,a,b:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n readln(f,h1,h2);\n read(f,a,b);\n close(f);\nEnd;\nFunction Solve:longint;\nVar res,temp:longint;\nBegin\n if h1>h2 then\n h2:=h1-h2\n else\n h2:=h2-h1;\n if a<=b then\n begin\n if h2<=12 then\n exit(0);\n exit(-1);\n end;\n if a0 then\n inc(res);\n solve:=res;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,solve);\n close(f);\nEnd;\n\n\nBegin\n nhap;\n xuat;\nEnd."}, {"source_code": "Const Finp='';\n Fout='';\nVar h1,h2,a,b:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n readln(f,h1,h2);\n read(f,a,b);\n close(f);\nEnd;\nFunction Solve:longint;\nVar res,temp:longint;\nBegin\n if h1+8*a>=h2 then\n exit(0);\n if (h1+8*a0 then\n res:=res+1;\n solve:=res;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n write(f,solve);\n close(f);\nEnd;\n\n\nBegin\n nhap;\n xuat;\nEnd."}, {"source_code": "var h1,h2,a,b,ans:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n inc(h1,8*a);\n if h1>=h2 then begin\n writeln(0);\n halt;\n end;\n if (h1=h2 then begin\n writeln(ans);\n halt;\n end;\n until false;\nend."}, {"source_code": "var h1,h2,a,b,ans:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n inc(h1,8*a);\n if h1>=h2 then begin\n writeln(0);\n halt;\n end;\n if (h1=h2 then begin\n writeln(ans);\n halt;\n end;\n inc(ans);\n inc(h1,8*a);\n if h1>=h2 then begin\n writeln(ans);\n halt;\n end;\n until false;\nend.\n"}, {"source_code": "var h1,h2,a,b,ans:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n inc(h1,8*a);\n if h1>h2 then begin\n writeln(0);\n halt;\n end;\n if (h1h2 then begin\n writeln(ans);\n halt;\n end;\n until false;\nend."}, {"source_code": "Var a,b,n,m,x,o,l,t,day,pr:LongInt;\n Begin\n Read(n,m,a,b);\n t:=14;\n While n=m then Break;\n n:=n-12*b;\n if a<=b then begin write(-1); halt end;\n Inc(day);\n if n<0 then n:=0;\n t:=10;\n end;\n Write(day);\n\n end."}, {"source_code": "const fin='';\n fout='';\nvar a,b,s,t:longint;\n f,g:text;\nprocedure solve;\nvar i,swt,d:longint;\nbegin\n d:=1;\n while st then write(g,d);\n inc(d);\n end;\nend;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,s,t);readln(f,a,b);\n s:=s+a*8;\n if s>=t then write(g,0)\n else if a>b then solve\n else write(g,-1);\n close(f);close(g);\nend.\n"}, {"source_code": "Var a,b,c,h1,h2,s1,s2,ans:int64;\n begin\n read(h1,h2,s1,s2);\n h1:=h1+8*s1;\n if (h1>=h2) then begin\n write(0);\n halt;\n end;\n if s2>s1 then begin\n write(-1);\n halt;\n end;\n ans:=1;\n a:=12*s1-12*s2;\n b:=h2-h1;\n if a>0 then ans:=ans+b div a\n else ans:=ans+b;\n write(ans);\n end."}, {"source_code": "Var a,b,c,h1,h2,s1,s2,ans:int64;\n begin\n read(h1,h2,s1,s2);\n h1:=h1+8*s1;\n if (h1>=h2) then begin\n write(0);\n halt;\n end;\n if s2>s1 then begin\n write(-1);\n halt;\n end;\n ans:=1;\n a:=12*s1-12*s2;\n b:=h2-h1;\n if a>0 then ans:=ans+b\n else ans:=-1;\n write(ans);\n end."}, {"source_code": "Var a,b,c,h1,h2,s1,s2,ans:int64;\n begin\n read(h1,h2,s1,s2);\n h1:=h1+8*s1;\n if (h1>=h2) then begin\n write(0);\n halt;\n end;\n if s2>=s1 then begin\n write(-1);\n halt;\n end;\n ans:=1;\n a:=12*s1-12*s2;\n b:=h2-h1;\n ans:=ans+b div a;\n write(ans);\n end."}, {"source_code": "Var a,b,c,h1,h2,s1,s2,ans:int64;\n begin\n read(h1,h2,s1,s2);\n h1:=h1+8*s1;\n if (h1>=h2) then begin\n write(0);\n halt;\n end;\n if s2>s1 then begin\n write(-1);\n halt;\n end;\n ans:=1;\n a:=12*s1-12*s2;\n b:=h2-h1;\n if a>0 then ans:=ans+b div a;\n write(ans);\n end."}, {"source_code": "Var a,b,c,h1,h2,s1,s2,ans:int64;\n begin\n read(h1,h2,s1,s2);\n h1:=h1+8*s1;\n if (h1>=h2) then begin\n write(0);\n halt;\n end;\n if s2>s1 then begin\n write(-1);\n halt;\n end;\n ans:=1;\n a:=12*s1-12*s2;\n b:=h2-h1;\n if a>0 then ans:=ans+b div a\n else ans:=-1;\n write(ans);\n end."}, {"source_code": "program fg;\nvar h1,h2,a,k,b:integer;\nbegin\nread(h1); readln(h2);\nread(a); readln(b);\nif h1+a*8>=h2 then k:=0\nelse \n if (a<=b) then k:=-1\n else begin\n h1:=h1+8*a;k:=0;\n while h1<=h2 do begin\n k:=k+1;\n h1:=h1-12*b+12*a;\n end;\n end;\nwrite(k); \n\nend.\n "}, {"source_code": "uses math;\nvar\n i,j,k,n,m,s:longint;\n h1,h2,a,b:longint;\ndh:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n k:=0;\n dh:=h2-h1;\n if dh<=8*a then writeln(0)\n else \n if (a>b) then begin\n while dh>0 do begin\n dh:=dh-12*a;\n if (dh<=0) then begin\n writeln(k+1);\n dh:=-24*b;\n end;\n dh:=dh+12*b;\n k:=k+1;\n end;\n end\n //writeln(k);\n else writeln(-1);\nend."}, {"source_code": "uses math;\nvar\n i,j,k,n,m,s:longint;\n h1,h2,a,b:longint;\ndh:longint;\nbegin\n readln(h1,h2);\n readln(a,b);\n k:=0;\n dh:=h2-h1;\n if dh<=8*a then writeln(0)\n else begin\n dh:=dh-8*a+2*b;\n while (dh>0)and(k<100000) do begin\n dh:=dh+10*b-12*a;\n if (dh<=0) then begin\n writeln(k+1);\n dh:=-24*b;\n end;\n dh:=dh+2*b;\n k:=k+1;\n end;\n if dh>0 then writeln(-1);\n end;\n \nend."}, {"source_code": "program fdf;\nvar h1,h2,a,b,n,k:longint;\nbegin\nread(h1,h2);\nread(a,b);\nif (a<=b)then\n if (h1+a*8>=h2) then write('0')\n else write('-1')\nelse\n begin\n if (h2<=h1+a*8) then write('0')\n else\n begin\n n:=h2-h1-8*a;\n k:=1;\n if (n<=0) then write ('1')\n else\n repeat\n n:=n-12*a+12*b;\n k:=1+k;\n until (n<=0);\n write(k);\n end;\n end;\nend.\n\n\n\n"}, {"source_code": "program fdf;\nvar h1,h2,a,b,n,k:longint;\nbegin\nread(h1,h2);\nread(a,b);\nif (a<=b)then\n if (h1+a*8>=h2) then write('0')\n else write('-1')\nelse\n begin\n h1:=h1-4*a;\n n:=h2-h1-12*a;\n if (n<=0) then write ('1')\n else\n repeat\n n:=n-12*a+12*b;\n k:=1+k;\n until (n<=0);\n write(k);\n end;\nend.\n\n\n\n"}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\nreadln(h1,h2);\nreadln(a,b);\nk:=0;\nif (a>b) or (a*8+h1>h2) then begin\nh1:=a*8+h1;\nwhile h1

0) and (a>b)) then\n while (k>0) do \n begin\n k:=k+12*b-12*a;\n i:=i+1;\n end\n else\n i:=-1;\nwrite(i);\nend."}, {"source_code": "var i, n, m, k, l, o, p, ans, h1, h2, a, b:LongInt;\n Begin\n Read(h1, h2);\n Read(a, b);\n if a= h2) or ((h1=h2 then Begin WriteLn(ans);Halt;End;\n Dec(h1, b*2);\n\n End;\n\n End.\n"}, {"source_code": "var i, n, m, k, l, o, p, ans, h1, h2, a, b, ans1:LongInt;\n Begin\n Read(h1, h2);\n Read(a, b);\n if a= h2 then Begin WriteLn(0);Halt;End;\n Dec(h1, b*2);\n while h1

=h2 then Begin WriteLn(ans);Halt;End;\n Dec(h1, b*2);\n\n End;\n\n End."}, {"source_code": "var\nh1,h2,a,b:integer;\nbegin\nreadln(h1,h2);\nreadln(a,b);\nif h1+8*a>=h2\nthen writeln(0)\nelse if a<=b\n then writeln(-1)\n else if ((h2-h1-8*a) div (12*(a-b))=0) and ((h2-h1-8*a) mod (12*(a-b))=0)\n then writeln((h2-h1-8*a) div (12*(a-b)))\n else writeln((h2-h1-8*a) div (12*(a-b))+1);\nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b >= a) and (h2 > h1 + 8*a) then write(-1) else begin\n while h1

h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n \n end;\n \nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b >= a) and (h2 >= h1 + 8*a) then write(-1) else begin\n while h1

h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n write(k); \n end;\n \nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b >= a) and (h2 > h1 + 8*a) then write(-1) else begin\n while h1

= h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n \n end;\n \nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b >= a) and (h2 >= h1 + 8*a) then write(-1) else begin\n while h1

h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n \n end;\n \nend."}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n k:=0;\n if (b>=a) and (h2 >= h1 + 8*a) then write(-1) else begin\n while h1

=h2 then begin write(k); exit; end;\n h1:=h1 - 12* b + 4* a;\n inc(k);\n end;\n \n end;\n \nend."}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\nif ((a>b) and (l>r)) or ((a1000000 then\n begin\n writeln('-1');\n exit;\n end;\n inc(res);\nend;\nwriteln(res);\nend.\n\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\nif ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-2;\n while (i<>r) and (j<10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>99999999 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-1;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>6999999 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-3;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>1000000 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((a1000000 then\n begin\n writeln('-1');\n exit;\n end;\n inc(res);\nend;\nwriteln(res);\nend.\n\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif ((a>b) and (l>r)) or ((ar do\nbegin\n if res>1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n end;\n\n j:=-2;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n end;\n inc(res);\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\nif ((a>b) and (l>r)) or ((ar do\nbegin\n if res>1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n end;\n\n j:=-2;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n end;\n inc(res);\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\nif ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-2;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>999999 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-3;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>1000000 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-2;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>1000000 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var i,n,l,r,a,b,res,j:longint;\nch:boolean;\nbegin\nread(L,R);\nread(a,b);\nif l=r then\nbegin\n writeln(0);\n exit;\nend;\n{if ((a>b) and (l>r)) or ((ar do\nbegin\n if res>=1 then j:=10;\n\n while (i<>r) and (j<=22) do\n begin\n inc(i,a);\n inc(j);\n\n end;\n\n j:=-1;\n while (i<>r) and (j<=10) do\n begin\n dec(i,b);\n inc(j);\n\n end;\n inc(res);\n if res>1000000 then\n begin\n writeln('-1');\n exit;\n end;\n\nend;\nwriteln(res-1);\nend.\n"}, {"source_code": "var h1,h2,a,b,k:integer;\nbegin\n read(h1,h2,a,b);\n h1:=h1+8*a;\n if h1>=h2 then write(0) \n else\n if a<=b then write(-1)\n else \n write((h2-h1)div(12*a-12*b)+1)\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype arr=array[1..1000000] of longint;\narr1=array[1..100,1..100] of longint;\nvar mas:arr;\ns:string;\nc:char;\ni,j,m,n,k,x,d,q,res,h1,h2:longint;\nbegin\n read(h1,h2);\n read(d,n);\n if n>d then\n begin\n writeln(-1);\n halt;\n end;\n res:=0;\n h1:=h1+d*8;\n if h1

h1 do\n begin\n inc(res);\n h1:=h1+d*12;\n if h1>h2 then break;\n h1:=h1-n*12;\n end;\n end;\n writeln(res);\n readln;\n readln;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype arr=array[1..1000000] of longint;\narr1=array[1..100,1..100] of longint;\nvar mas:arr;\ns:string;\nc:char;\ni,j,m,n,k,x,d,q,res,h1,h2:longint;\nbegin\n read(h1,h2);\n read(d,n);\n k:=0;\n if (n>=d) and ((h1+d*8)=h2 then writeln(0) else\n begin\n h1:=h1+d*8;\n while h1

0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n flag:=true;\n if p1+1=2)and(p2=1) then flag:=false;\n if (p1>=1)and(p2=0) then flag:=false;\n\n if flag then write('YES') else write('NO');\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n", "positive_code": [{"source_code": "var x,y:longint;\nbegin\nreadln(x,y);\nif y=0 then writeln('NO') else\n begin\n dec(y,1);\n dec(x,y);\n if (x mod 2=0) and (x>=0) then\n begin\n if (x<>0) and (y=0) then writeln('NO') else\n writeln('YES')\n end\n else writeln('NO')\n end\nend."}, {"source_code": "var x,y:longint;\nbegin\n readln(y,x);\n if (x=1) and (y>0) or (x=0) then\n begin\n writeln('No');\n halt;\n end;\n y:=succ(y-x);\n if (y>=0) and (y mod 2=0) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": " var a,b:longint;\nbegin\n readln(a,b);\n dec(b);\n if b<0 then begin\n writeln('No');\n exit;\n end;\n if b=0 then\n if a>0 then begin\n writeln('No');\n exit;\n end;\n dec(a,b);\n if a<0 then begin\n writeln('No');\n exit;\n end;\n if a mod 2 = 0 then\n writeln('Yes')\n else\n writeln('No');\nend.\n"}, {"source_code": "program z1;\nvar x,y,nac,nac1:longint;\nbegin\nread(x,y);\nnac:=y;\nif y=0 then begin write('NO');exit;end;\nnac1:=y-1;\n while (nac10) do inc(nac1,2);\nif nac1=x then write('YES')\nelse write('NO');\nend."}, {"source_code": "var\n x,y,ro,kl : longint;\nbegin\n readln(x,y);\n if (y-1>x) or ((y=1) and (x>0)) or (y=0) then begin writeln('No'); halt; end;\n kl:=y-1;\n ro:=y;\n if (x-kl) mod 2=0 then writeln('Yes') else writeln('No');\nend.\n"}, {"source_code": "var a,b:longint;\nbegin\n readln(a,b);\n if ((b=1)and(a<>0))or(b=0) then\n begin\n writeln('NO');\n exit;\n end;\n dec(b);\n if a-b<0 then writeln('NO') else\n if (a-b) mod 2=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,b,x,y:longint;\nbegin\n read(x,y);\n if (y=1)and(x=0) then begin write('Yes');halt;end;\n if y<2 then begin write('No');halt;end;\n a:=y-1;\n b:=x-a ;\n if odd(b) or(b<0) then write('No')else\n write('Yes');\nend."}, {"source_code": "var x,y:longint;\nbegin\n readln(x,y);\n y:=y-1;\n x:=x-y;\n if (x<0)\n then begin\n writeln('No');\n exit;\n end;\n if (x=0)\n then begin\n writeln('Yes');\n exit;\n end;\n if (x mod 2=0) and (y>0)\n then begin\n writeln('Yes');\n exit;\n end;\n writeln('No');\n\nend.\n"}, {"source_code": "program cloning;\nuses wincrt;\nvar x,y,x1,y1,z : longint;\nbegin\nreadln(x,y);\nx1 := 0;\ny1 := 1;\n\ny1:= 1+ abs(y-1);\nx1:= abs(y-1);\nif(x1 >= 1)then\nbegin\n x1 := x1 + abs(x - x1) div 2 * 2;\nend;\nif((x = x1) and (y = y1))then\nbegin\n writeln('Yes');\nend\nelse\nbegin\n writeln('No');\nend;\nend.\n"}, {"source_code": "var\nn,m,x,y:int64;\nbegin\n read(n,m);\n x:=m-1;\n y:=n-x;\n if (n>0) and (m=0) then write('No') else\n if (m=1) and (n>0) then write('No') else\n if (y mod 2 =0) and (y>=0) then write('Yes') else write('No');\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var x,y:integer;\nBEGIN\n read (x,y) ;\n if (y = 1) and (x = 0) or\n (y > 1) and (x+1 >= y) and (((y-1)mod 2) =(x mod 2)) then write('YES')\n else write('NO');\nEND. "}, {"source_code": "program hrn;\n var\n a,b:longint;\n begin\n read(b,a);\n if a=0 then write('NO')else\n if(a=1)and(b<>0)then write('NO')else begin\n b:=b-a+1;\n if b<0 then write('NO');\n if b>=0 then if b mod 2=0 then write('YES')\n else write('NO');\n end;\n end.\n"}, {"source_code": "program hrn;\n var\n a,b:longint;\n begin\n read(b,a);\n if a=0 then write('NO')else\n if(a=1)and(b<>0)then write('NO')else begin\n b:=b-a+1;\n if b<0 then write('NO');\n if b>=0 then if b mod 2=0 then write('YES')\n else write('NO');\n end;\n end.\n"}, {"source_code": "program andyCF922A;\nvar n,m:longint;\n begin\n readln(n,m);\n if m=0 then\n begin\n writeln('No');\n halt;\n end\n else\n if (m=1)and(n<>0) then\n begin\n writeln('No');\n halt;\n end\n else\n begin\n n:=n-m+1;\n if n<0 then\n begin\n writeln('No');\n halt;\n end;\n if n>=0 then\n if (n mod 2)=0 then\n writeln('Yes')\n else\n writeln('No');\n end;\n end."}, {"source_code": "Var x,y: longint;\nbegin\nRead(x,y);\ny:=y-1;\nIf (y<=0) and (x>0) then begin Writeln('No');exit;end;\nIf x=(y-1)) and ((x-y+1) mod 2=0) then write('YES')\n else\n write('NO');\n\n\nend."}, {"source_code": "var\n cop, n_orig, n_cop : longint;\nbegin\n cop := 0;\n readln(n_cop, n_orig);\n cop := n_orig - 1;\n if (n_cop = 0) and (n_orig = 1)\n then\n begin\n writeln('Yes');\n halt;\n end;\n if (cop > 0) and (n_cop >= cop) and((n_cop - cop) mod 2 = 0)\n then writeln('Yes')\n else writeln('No');\n\nend."}, {"source_code": "var\nq,x,y:longint;\nbegin\nread(x,y);\nq:=x-y+1;\nif (x>0) and (y=0) then\nbegin write('No');\nhalt; end;\nif (y=1) and (x>1) then\nbegin write('No');\nhalt; end;\nif (q mod 2=0) and (q>=0)\nthen\nwrite('Yes')\nelse write('No');\nend."}, {"source_code": "var x,y,m,n:longint;\nbegin\nreadln(x,y);\nm:=1;\nn:=0;\nif y>0 then\nwhile m<>y do begin\n inc(m);\n inc(n);\n end;\nif m=y then if (n0) then while n 0) then ans := 'No';\n if y = 0 then ans := 'No';\n writeln(ans);\nend."}, {"source_code": "program r_461_a;\n var i,k,o:longint;\nbegin\n readln(k,o);\n if((k>0)and(o=0))or((k mod 2=0)and(o mod 2=0))or((k mod 2=1)and(o mod 2=1))or(k-o<-1)or((o=1)and(k>0)) then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "program z1;\n var x, y, z :longint;\nbegin\n readln( x, y );\n if ((x = 0 ) and (y <> 1 )) or (y=0) or (x=y)\n then write ('No')\n else if ((x+1 = y) and (y<>1)) or ((x=0) and (y = 1))\n then write ('Yes')\n else begin\n z := x - ( y - 1 );\n if (z mod 2 = 0) and (y <> 1) and(y < x )\n then write( 'Yes' )\n else if (y =1 ) and ((x-1) mod 2 =0 )\n then write ('Yes')\n else write('No')\nend;\nend."}, {"source_code": "var x,y:longint;\nbegin\nread(x,y);\nif (y=0) or ((x=0)and(y>1))or(x=y)or((x>y)and(y=1))then write('NO')\nelse if (x-y = 1)or(y-x=1) then write('YES')\nelse if y>x then write('NO')\nelse if ((x-y-1) mod 2)=1 then write('NO')\nelse write('YES');\nend."}, {"source_code": "var x,y,ans:longint;\nbegin\n {assign(input,'input.txt');\n reset(input);}\n read(x); read(y);\n {close(input);\n assign(output,'output.txt');\n rewrite(output); }\n ans:=x-(y-1);\n if (ans>=0) and (ans mod 2 = 0) and not ((y=1) and (x>0)) and (y<>0) then write('Yes')\n else write('No');\n //close(output);\nend.\n"}, {"source_code": "var c, o: longint;\n\nbegin\n readln(c, o);\n if (o = 0) then\n writeln('No')\n else begin\n if (o = 1) and (c <> 0) then\n writeln('No')\n else begin\n if (c < o - 1) then\n writeln('No')\n else begin\n c := c - (o - 1);\n if ((c mod 2) = 0) then\n writeln('Yes')\n else\n writeln('No')\n end;\n end;\n end;\nend."}, {"source_code": "var\nkopy,kop1,r:longint;\nbegin\nreadln(kopy,r);\nif (r=1)and (kopy>0) then begin writeln('No'); halt; end;\nif r=0 then begin writeln('No'); halt; end;\nkop1:=r-1;\nif kopy- kop1<0 then begin writeln('No'); halt; end;\nif (kopy-kop1) mod 2=0 then writeln('Yes') else writeln('No');\nend.\n\n"}, {"source_code": "//abcdefghijklmnopqrstuvwxyz\nvar\na,b:longint;\nbegin\nreadln(a,b);\nif (b=1) and (a>0) then \n begin\n writeln('No');\n exit;\n end;\nif (b-1>a) or (b=0) then \n begin\n writeln('No');\n exit;\n end;\na:=a-b+1;\n\nif a mod 2=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var p,p1,p2:longint;s,s1,s2,s3:string;mx1,mx2,mx3,mx4,mx5:int64;n1,n2,n3:real;m,a,t:array[1..10010] of longint;i,j,u:longint;n,no,vmax,max2,max3,f:int64;\nBegin\n readln(mx1,mx2);\n if (mx2 = 0) then begin\n write('No',' ');\n halt;\n end;\n if (mx2 = 1) then begin\n if (mx1 = 0 ) then begin\n write('Yes',' ');\n halt;\n end\n else begin\n write('No',' ');\n halt;\n end;\n end;\n if (mx1-mx2+1)<0 then begin\n write('No',' ');\n halt;\n end;\n if ((mx1-mx2+1) mod 2 =1) then begin\n write('No',' ');\n halt;\n end;\n write('Yes',' ');\n halt;\n End.\n"}, {"source_code": "var x, y: int64;\n\nbegin\nreadln(x ,y);\nif (y = 1) and (x > 0) then writeln('NO') else \nif (x - y + 1 >= 0) and ((x - y + 1) mod 2 = 0) and (y>0)\n\tthen writeln('Yes')\n\telse writeln('No');\nend."}, {"source_code": "var i,j,x,y:longint;\n begin\n read (x,y);\n if y = 0 then writeln ('No')\n else\n if (x > 0) and (y=1) then writeln ('No')\n else\n if (x-y+1>=0) and ((x-y+1) mod 2 = 0) then writeln ('Yes')\n else writeln ('No');\n\n\n end."}, {"source_code": "var\n ex,ey,x,y : integer;\nbegin\n readln(ex,ey);\n x:=0;\n y:=1;\n while y0) do inc(x,2);\n if (ex=x) and (ey=y)\n then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var i,j,x,y:longint;\n begin\n read (x,y);\n if y = 0 then writeln ('No')\n else\n if (x mod 2 = 0) and (y=1) and (x<>0) then writeln ('No')\n else\n if (x-y+1>=0) and ((x-y+1) mod 2 = 0) then writeln ('Yes')\n else writeln ('No');\n\n\n end."}, {"source_code": "var x,y:longint;\nbegin \nread(x,y);\n\nif (y=0)or(y-1>x) then begin write('no');halt;end;\nif (y=1)and(x<>0)then begin write('no');halt;end; \ny:=y-1;\nif (x-y) mod 2=0then write('yes')\nelse write('no');\n\n\nend."}, {"source_code": "program clone1;\nvar x,y,o,c:longint;\nbegin\nreadln(x,y);\no:=y;\nc:=y-1;\nwhile x>c do begin\nc:=c+2;\nend;\nif (y=0) then writeln('No') else\nif (y=1) and (x>0) or (y=0) and (x>0) then writeln('No') else\nif (x=c) and (y=o) then writeln('Yes') else \nif (y=0) and (x=0) then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var n,m:longint;\nbegin\n readln(n,m);\n if ((n-(m-1))mod 2=0)and(n-m>-2)and((m>1)or((m=1)and(n=0))) then\n writeln('Yes')\n else\n writeln('No');\nend."}, {"source_code": "program clone1;\nlabel 1;\nvar x,y,o,c:longint;\nbegin\nreadln(x,y);\no:=y;\nc:=y-1;\nwhile x>c do begin\nc:=c+2;\nend;\nif (y=0) then writeln('No') else\nif (y=1) and (x>0) or (y=0) and (x>0) then writeln('No') else\nif (x=c) and (y=o) then writeln('Yes') else \nif (y=0) and (x=0) then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var x, y:longint;\nbegin readln(x, y);\n if odd(x-y) and (y<>0) and (x>y-2) and not((y=1) and (x>0)) then writeln('Yes')\n else writeln('No');\nend.\n\n\n"}, {"source_code": "var\n x, y : integer;\nbegin\n read(x, y);\n if y = 0 then \n write('NO')\n else\n if (y = 1) and (x<>0) then \n write('NO')\n else \n begin\n x := x - y + 1;\n if x < 0 then \n write('NO');\n if x >= 0 then \n if x mod 2 = 0 then \n write('YES')\n else \n write('NO');\n end;\nend."}, {"source_code": "var a,b:int64;\nbegin\nread(b,a);\nif a-1 = b then write('YES') else\nif a-1>b then write('NO') else\nif ((b-a+1)mod 2=0)and(a>1) then write('YES') else\nwrite('NO');\n\n\nend."}, {"source_code": "var x,y: longint;\nbegin\nreadln (x,y);\nif y=0 then writeln ('NO');\nif y=1 then\n begin\n if x=0 then writeln ('YES')\n else writeln ('NO');\n end;\nif y>=2 then \n begin\n if (x>=y-1) and ((x+1-y) mod 2 = 0) then writeln ('YES')\n else writeln ('NO');\n end;\nend."}, {"source_code": "Var \n X, Y: LongInt;\n \nBegin\n Read(X, Y);\n If ((Y = 0) and (X >= 0)) or ((Y = 1) and (X > 0)) then Write('No')\n Else If ((X - Y + 1) mod 2 = 0) and (Y - X <= 1) then Write('Yes')\n Else Write('No')\nEnd."}, {"source_code": "var x, y : integer;\n\nbegin\n read (x, y);\n if (y = 0) then write ('NO')\n else if (y = 1) then \n begin\n if (x = 0) then write ('YES')\n else write ('NO');\n end\n else\n begin\n if (x >= y - 1) and ((x - y + 1) mod 2 = 0) then write ('YES')\n else write ('NO');\n end;\nend."}, {"source_code": "program a1;\nvar\nx,y:longint;\nbegin\nread(x);\nread(y);\nif (y=0) or (y=1) and (x<>0)\nthen\nwrite('No')\nelse\nbegin\nif y-x>1 then\nwrite('No')\nelse\nbegin\nx:=(x-y-1) mod 2;\nif x=0 then\nwrite('Yes')\nelse\nwrite('No');\nend;\nend;\nend."}, {"source_code": "Var ik,io:integer;\nBegin\nRead(ik,io);\nIf (ik>io-2) and (io>0) and ((io>1)or(ik<1)) then begin\n If (ik-io+1) mod 2 = 0 then write('Yes') else write('No');\nend else write('No');\nEnd."}, {"source_code": "var x,y:int64;\nbegin\nread(y,x);\nif (x=1) and (y<>0) then begin write('No'); exit end;\nif (x=0) then begin write('No'); exit end;\nif (y>=x-1) and (y mod 2 = (x-1) mod 2) then write('Yes') else write('No')\nend."}, {"source_code": "var x,y,k,i:longint;\nbegin\nread(y,x);\nif (x<=1)and(y<>0) then begin writeln('No'); halt; end;\nif y-(x-1)<0 then begin writeln('No'); halt; end;\ny:=y-(x-1);\nwhile y>0 do begin\ny:=y-2;\nend;\nif y=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "program p1;\ntype ma=1..1000000000;\nvar \nx,y,k:ma;\nbegin\nreadln (x,y);\nif ((x<>0) and (y=1)) or (y=0) or (xb then write('NO') else\n if ((b-a+1)mod 2=0)and(a>1) then write('YES') else\n write('NO');\nend."}, {"source_code": "program CloningToys;\nvar x,y: longint;\nBEGIN\nreadln(x,y);\nif (y=0) then begin\n writeln('no');\n exit;\nend;\nif (y>1) and (x0) then begin\n writeln('no');\n exit;\nend;\nx:=x-y+1;\nif (odd(x)) then writeln('no') else writeln('yes');\nEND.\n"}, {"source_code": "var\n x,y : longint;\nbegin\n readln(x,y);\n if (y=0) then begin writeln('No'); halt; end;\n if (y=1) then\n begin\n if x=0 then writeln('Yes') else writeln('No');\n halt;\n end;\n if x>=y-1 then\n begin\n if (x-(y-1)) mod 2=0 then writeln('Yes') else writeln('No');\n end else writeln('No');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n i := y - 1;\n if (y <= 0)then begin\n writeln ('NO');\n exit;\n end;\n if (y = 1) then begin\n if (x = 0) then\n writeln ('YES')\n else\n writeln ('NO'); \n exit;\n end;\n\n if ((x - i) mod 2 = 0) and (x >= (y - 1))then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "var\n x, y: LongInt;\n ans: string;\n \nbegin\n ReadLn(x, y);\n ans := 'No';\n If y-x=1 then ans := 'Yes';\n If (x-y) mod 2 = 1 then ans := 'Yes';\n If y = 0 then ans := 'No';\n If (y = 1) and (x > 0) then ans := 'No';\n WriteLn(ans);\nend."}, {"source_code": "var\n a,b:longint;\n begin\n read(b,a);\n if a=0 then write('NO')else\n if(a=1)and(b<>0)then write('NO')else begin\n b:=b-a+1;\n if b<0 then write('NO');\n if b>=0 then if b mod 2=0 then write('YES')\n else write('NO');\n end;\n end."}, {"source_code": "program zzz;\nvar\n t:boolean;\n x,y:longint;\nbegin\n readln(x,y);\n t:=false;\n if ((x-y+1)mod 2 =0)and (y>0)and(x>=y-1) then t:=true;\n if (t) and (y>1) or(x=0)and(y=1) then writeln('yes')\n else writeln('no');\nend."}], "negative_code": [{"source_code": "var x,y:integer;\nbegin\n readln(x,y);\n if y=0 then write('NO')\n else\n if (y=1) and (x=0) then write('YES');\n if ((x-y-1) and 1 )=(x and 1) then write('YES')\n else\n write('NO');\nend."}, {"source_code": "Var o,ik,io:integer;\nBegin\nRead(ik,io);\nIf ik>io-2 then begin\n If (ik-io+1) mod 2 = 0 then write('Yes') else write('No');\nend;\nEnd."}, {"source_code": "var n,m:longint;\nbegin\n readln(n,m);\n if (n-(m-1))mod 2=0 then\n writeln('Yes')\n else\n writeln('No');\nend."}, {"source_code": "Var x,y: longint;\nbegin\nRead(x,y);\nIf y=0 then begin Writeln('No');exit;end;\nIf y-x=1 then begin Writeln('Yes');exit;end else\nIf x0 then Writeln ('Yes')\nelse Writeln ('No')\nend."}, {"source_code": "program clone1;\nlabel 1;\nvar x,y:integer;\nbegin\nreadln(x,y);\nif (x>y) or (x=y-1) then\nif (x mod 2=0) and (y mod 2=1) then writeln('Yes') else else writeln('No');\nend."}, {"source_code": "var x,y,ans:longint;\nbegin\n {assign(input,'input.txt');\n reset(input);}\n read(x); read(y);\n {close(input);\n assign(output,'output.txt');\n rewrite(output); }\n ans:=x-(y-1);\n if (ans>=0) and (ans mod 2 = 0) and not ((y=1) and (x>0)) then write('Yes')\n else write('No');\n //close(output);\nend.\n"}, {"source_code": "var\nn,m,x,y:int64;\nbegin\n read(n,m);\n x:=m-1;\n y:=n-x;\n if (m=1) and (n>0) then write('No') else\n if (y mod 2 =0) and (y>=0) then write('Yes') else write('No');\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program z1;\n var x, y, z :longint;\nbegin\n readln( x, y );\n if (y > x) and (x + 1 <> y) \n then write( 'No' )\n else begin\n z := x - ( y - 1 );\n if (z mod 2 = 0) or (x+1 = y)\n then write( 'Yes' )\n else write( 'No' );\nend; \nend."}, {"source_code": "program zzz;\nvar\n t:boolean;\n x,y:longint;\nbegin\n readln(x,y);\n t:=false;\n if (x>0) and (y>1) then\n begin\n if (x-y+3)mod 2 =0 then t:=true;\n if (x-y)mod 2 = 0 then t:=true;\n end;\n if (x>0)and(y=0)and(x mod 2=1) then t:=true;\n if (x=0)and(y<2) then\n t:=true;\n if t then writeln('yes')\n else writeln('no');\nend.\n"}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y<>0) and (x>0) and (x>y-2) then writeln('Yes')\n else writeln('No');\nend.\n\n"}, {"source_code": "var a,b:longint;\nbegin\n readln(a,b);\n if ((b=1)and(a<>0))or(b=0) then\n begin\n writeln('NO');\n exit;\n end;\n dec(b);\n if (a-b) mod 2=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var\n x, y, copya : longint;\nbegin\n readln(x, y);\n copya := 0;\n inc(copya, y - 1);\n if (x < copya) or ((x - copya) mod 2 <> 0) then writeln('NO')\n else if (x = copya) or ((x - copya) mod 2 = 0) then writeln('Yes');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end;\n i := y - 1;\n if (i <= 0)then begin\n writeln ('YES');\n exit;\n end;\n\n if ((x - i) mod 2 = 0) and (x >= (y - 1))then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (x+1>x) and (n>=0) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "program r_461_a;\n var i,k,o:longint;\nbegin\n readln(k,o);\n if((k>0)and(o=0))or((k mod 2=0)and(o mod 2=0))or((k mod 2=0)and(o mod 2=0))and(k-o<-1) then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "var x, y:longint;\nbegin readln(x, y);\n if odd(x-y) and (y<>0) and (x>y-2) and ((y<>1) and (x<>2)) then writeln('Yes')\n else writeln('No');\nend.\n\n\n"}, {"source_code": "var i,j,x,y:longint;\n begin\n read (x,y);\n if y = 0 then writeln ('No')\n else\n if (x mod 2 = 0) and (y=1) then writeln ('No')\n else\n if (x-y+1>=0) and ((x-y+1) mod 2 = 0) then writeln ('Yes')\n else writeln ('No');\n\n\n end."}, {"source_code": "var\n x, y : longint;\n ans : string;\nbegin\n readln(x, y);\n ans := 'No';\n if abs(y - x) = 1 then ans := 'Yes';\n if (y = 1) and (x > 0) then ans := 'No';\n if y = 0 then ans := 'No';\n writeln(ans);\nend."}, {"source_code": "var\nn,m,x,y:int64;\nbegin\n read(n,m);\n x:=m-1;\n y:=x;\n if (y=n) then write('Yes') else\n begin\n y:=y+x*2;\n if ((n-y) mod 2 =0) and (n-y>=0) then write('Yes') else write('No');\n end;\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var x,y: longint;\nbegin\nRead(x,y);\ny:=y-1;\nIf x0)and(o=0))or((k mod 2=0)and(o mod 2=0))or((k mod 2=1)and(o mod 2=1))or(k-o<-1) then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "var a,b:longint;\nbegin\n readln(a,b);\n if ((b=1)and(a<>0))or(b=0) then\n begin\n writeln('NO');\n exit;\n end;\n dec(b);\n if (a-b) mod 2=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program z1;\nvar x,y,nac,nac1:longint;\nbegin\nnac:=1;\nnac1:=0;\nread(x,y);\nwhile nac-2) then\n writeln('Yes')\n else\n writeln('No');\nend."}, {"source_code": " \n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2,3,4;\n type real=double; int64=longint; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ogr,q,modul,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pos,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n time,jj,step, k,t1,ii,i,j:longint;\n aa,bb,cc:int64;\n l,r,c,dd,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n right,down,dda:array[-10..2200,-10..2200] of longint;\n zanx,zany:array[-10..2000000] of boolean;\n sss:string;\n zan,fl:array[-100..2000000] of boolean;\n ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2,ss1,ss2:array[0..nn] of string;\n ott,v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n flag:=true;\n if p1+1=2)and(p2=1) then flag:=false;\n\n if flag then write('YES') else write('NO');\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y<>0) and (n>=0) and (x>y-2) then writeln('Yes')\n else writeln('No');\nend.\n\n"}, {"source_code": "var\nn,m,x,y:int64;\nbegin\n read(n,m);\n x:=m-1;\n y:=n-x;\n if (m=1) and (n>0) then write('No') else\n if (y mod 2 =0) and (y>=0) then write('Yes') else write('No');\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program clone1;\nvar x,y:integer;\nbegin\nreadln(x,y);\nif (x mod 2=0) and (y mod 2=1) then writeln('Yes') else writeln('No');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n i := y - 1;\n if (y <= 0)then begin\n writeln ('NO');\n exit;\n end;\n if (y = 1) and (x = 0) then begin\n writeln ('YES');\n exit;\n end;\n\n if ((x - i) mod 2 = 0) and (x >= (y - 1))then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (x+1>x) and (n>=0) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end; \n i := y - 1;\n if ((x - i) mod 2 = 0) then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program z1;\n var x, y, z :longint;\nbegin\n readln( x, y );\n if (y > x) and (x + 1 <> y) \n then write( 'No' )\n else begin\n z := x - ( y - 1 );\n if (z mod 2 = 0) or (x+1 = y)\n then write( 'Yes' )\n else write( 'No' );\nend; \nend."}, {"source_code": "var n,m:longint;\nbegin\n readln(n,m);\n if ((n-(m-1))mod 2=0)and(n-m>-2) then\n writeln('Yes')\n else\n writeln('No');\nend."}, {"source_code": "program z1;\n var x, y, z :longint;\nbegin\n readln( x, y );\n if x < y\n then write ('No')\n else begin\n if (y = 1) and (x - y mod 2 <> 0)\n then write ('No')\n else begin\n if (y > x) and (x + 1 <> y) or (y=0) \n then write( 'No' )\n else begin\n z := x - ( y - 1 );\n if (z mod 2 = 0) or (x+1 = y)\n then write( 'Yes' )\n else write( 'No' );\nend; \nend;\nend;\nend."}, {"source_code": "var\n x, y, copya : longint;\nbegin\n readln(x, y);\n copya := 0;\n inc(copya, y - 1);\n if (x = 0) or (y = 0) or (y = 1) then begin writeln('NO');exit;end;\n if (x < copya) or ((x - copya) mod 2 <> 0) then writeln('NO')\n else if (x = copya) or ((x - copya) mod 2 = 0) then writeln('Yes');\nend.\n "}, {"source_code": "var x,y:longint;\nbegin\n readln(x,y);\n if y=0 then write('NO');\n\n if (y=1) then\n if x=0 then write('YES')\n else write('NO');\n if (x>=(y-1)) and ((x-y+1) mod 2=0) then write('YES')\n else\n write('NO');\n\n\nend."}, {"source_code": "var x,y:longint;\nbegin\n readln(x,y);\n if y=0 then write('NO');\n\n if (y=1) then\n if x=0 then write('YES')\n else write('NO');\n if (x>=(y-1)) and ((x-y+1) mod 2=0) then write('YES')\n else\n write('NO');\n\n\nend."}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y-1>0) and (n>=0) then writeln('Yes')\n else writeln('No');\nend.\n"}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y<>0) and (x>y-2) then writeln('Yes')\n else writeln('No');\nend.\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end; \n i := y - 1;\n if ((x - i) mod 2 = 0) and (i < (y - 1))then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program z1;\nvar x,y,nac,nac1:longint;\nbegin\nread(x,y);\nnac:=y;\nif y=0 then begin write('NO');exit;end;\nnac1:=y-1;\nif y=1 then nac1:=y;\n while nac1=x then begin writeln('No'); halt; end;\n kl:=y-1;\n ro:=y;\n if (x-kl) mod 2=0 then writeln('Yes') else writeln('No');\nend.\n"}, {"source_code": "var x,y,k,i:longint;\nbegin\nread(y,x);\nif y-(x-1)<0 then begin writeln('No'); halt; end;\ny:=y-(x-1);\nwhile y>0 do begin\ny:=y-2;\nend;\nif y=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var i,j,x,y:longint;\n begin\n read (x,y);\n if y = 0 then writeln ('No')\n else\n if (x mod 2 = 0) and (y=1) then writeln ('No')\n else\n if (x-y+1>=0) and ((x-y+1) mod 2 = 0) then writeln ('Yes')\n else writeln ('No');\n\n\n end."}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y<>0) and (x>y-2) then writeln('Yes')\n else writeln('No');\nend.\n\n\n"}, {"source_code": "var x,y:longint;\nbegin\nread(x,y);\nif (y=0) or ((x=0)and(y>1))or(x=y)or((x-y=1)and(y=1))then write('NO')\nelse if (x-y = 1)or(y-x=1) then write('YES')\nelse if y>x then write('NO')\nelse if ((x-y-1) mod 2)=1 then write('NO')\nelse write('YES');\nend."}, {"source_code": "var x,y,k,i:longint;\nbegin\nread(x,y);\nwhile x>1 do begin\ninc(i);\nx:=x div 2;\nk:=k+i;\nend;\nif y-k>=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "var\n x, y, copya : longint;\nbegin\n readln(x, y);\n copya := 0;\n inc(copya, y - 1);\n if (x = 0) or (y = 0) or (y = 1) then begin writeln('NO');exit;end;\n if (x < copya) or ((x - copya) mod 2 <> 0) then writeln('NO')\n else if (x = copya) or ((x - copya) mod 2 = 0) then writeln('Yes');\nend.\n "}, {"source_code": "program p1;\ntype ma=1..1000000000;\nvar \nx,y,k:ma;\nbegin\nreadln (x,y);\nif ((x<>0) and (y=1)) or (y=0) or (x0) and (x>=0) then writeln('YES') else writeln('NO')\n end\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end;\n i := y - 1;\n if (i <= 0)then begin\n writeln ('YES');\n exit;\n end;\n\n if ((x - i) mod 2 = 0) and (x >= (y - 1))then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i, j: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end; \n i := y - 1;\n if (i mod 2 = 0) then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program z1;\nvar x,y,nac,nac1:longint;\nbegin\nread(x,y);\nnac:=y;\nif y=0 then begin write('NO');exit;end;\nnac1:=y-1;\n while nac1=(y-1)) and ((x-y+1) mod 2=0) then write('YES')\n else\n write('NO');\n\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i, j: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end; \n i := y - 1;\n while (i < x) do begin\n inc (i, 2);\n end;\n if (i = x) then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "var x,y: longint;\nbegin\nreadln (x,y);\nif (x>=y-1) and ((x+1-y) mod 2 = 0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "program CloningToys;\nvar x,y: longint;\nBEGIN\nreadln(x,y);\n//countOforiginal:=0;\n//countOfCopies:=0;\nif (y=0) then begin\n writeln('no');\n exit;\nend;\nif (y>1) and (x0) then begin write('No'); exit end;\nif (y=0) then begin write('No'); exit end;\nif (y>=x-1) and (y mod 2 = (x-1) mod 2) then write('Yes') else write('No')\nend."}, {"source_code": "var x,y:longint;\nbegin\nread(x,y);\nif (y=0) or ((x=0)and(y>1))or(x=y)then write('NO')\nelse if (x-y=1)or(y-x=1) then write('YES')\nelse if y>x then write('NO')\nelse if ((x-y-1) mod 2)=1 then write('NO')\nelse write('YES');\nend."}, {"source_code": "program zzz;\nvar\n x,y:longint;\nbegin\n readln(x,y);\n if ((x-y+1)mod 2=0)and(x>0)and (y>0) then writeln('yes')\n else writeln('no');\nend."}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=y-x+1;\n if (n mod 2=0) and (x+1>x) and (n>=0) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "Var x,y: longint;\nbegin\nRead(x,y);\ny:=y-1;\nIf x1 do begin\ninc(i);\nx:=x div 2;\nk:=k+i;\nend;\nif y-k>=0 then writeln('Yes') else writeln('No');\nend."}, {"source_code": "program r_461_a;\n var i,k,o:longint;\nbegin\n readln(k,o);\n if((k>0)and(o=0))or((k mod 2=0)and(o mod 2=0))or((k mod 2=0)and(o mod 2=0))and(k-o<-1) then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "program r_461_a;\n var i,k,o:longint;\nbegin\n readln(k,o);\n if((k>0)and(o=0))or((k mod 2=0)and(o mod 2=0))or((k mod 2=0)and(o mod 2=0))and(k-o<-1) then writeln('No')\n else writeln('Yes');\nend."}, {"source_code": "program cloning;\nuses wincrt;\nvar x,y,z : longint;\nbegin\nreadln(x,y);\ndec(y);\nif(((x-y) mod 2 = 0 )and (x >= y))then\nbegin\n writeln('Yes');\nend\nelse\nbegin\n writeln('No');\nend;\nend."}, {"source_code": "var\n x, y, copya : longint;\nbegin\n readln(x, y);\n copya := 0;\n inc(copya, y - 1);\n if (x < copya) or ((x - copya) mod 2 <> 0) then writeln('NO')\n else if (x = copya) or ((x - copya) mod 2 = 0) then writeln('Yes');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i: integer;\nbegin\n readln (x, y);\n if (x = 1) and (y = 0) then begin\n writeln ('NO');\n exit;\n end; \n i := y - 1;\n if ((x - i) mod 2 = 0) then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program zzz;\nvar\n t:boolean;\n x,y:longint;\nbegin\n readln(x,y);\n t:=false;\n if (x>0) and (y>1) then\n begin\n if (x-y+3)mod 2 =0 then t:=true;\n end;\n if (x=0)and(y=1) then\n t:=true;\n if t then writeln('yes')\n else writeln('no');\nend.\n"}, {"source_code": "var x,y:integer;\nbegin\n readln(x,y);\n if y=0 then write('NO')\n else\n if (y=1) and (x=0) then write('YES');\n if ((x-y-1) and 1 )=(x and 1) then write('YES')\n else\n write('NO');\nend."}, {"source_code": "program r_461_a;\n var i,k,o:longint;\nbegin\n readln(k,o);\n if (k-o=1)or((o mod 2=0)and(k mod 2=1))or((o mod 2=1)and(k mod 2=0))\n then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var x,y,m,n:longint;\nbegin\nreadln(x,y);\nm:=1;\nn:=0;\nif y>0 then\nwhile m<>y do begin\n inc(m);\n inc(n);\n end;\nif m=y then if n= (y - 1)) and ((x-i) <> x)then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "var\n x, y, copya : longint;\nbegin\n readln(x, y);\n copya := 0;\n inc(copya, y - 1);\n if (x < copya) or ((x - copya) mod 2 <> 0) then writeln('NO')\n else if (x = copya) or ((x - copya) mod 2 = 0) then writeln('Yes');\nend."}, {"source_code": "var\nn,m,x,y:int64;\nbegin\n read(n,m);\n x:=m-1;\n y:=n-x;\n if (y mod 2 =0) then write('Yes') else write('No');\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var x,y:longint;\nbegin \nread(x,y);\ny:=y-1;\nif (x-y) mod 2=0then write('yes')\nelse write('no');\nend."}, {"source_code": "program zzz;\nvar\n t:boolean;\n x,y:longint;\nbegin\n readln(x,y);\n t:=false;\n if (x>0) and (y>=1) then\n begin\n if (x-y+1)mod 2 =0 then t:=true;\n if (x-y)mod 2 = 0 then t:=true;\n end;\n if (x=0)and(y<2) then\n t:=true;\n if t then writeln('yes')\n else writeln('no');\nend.\n"}, {"source_code": "var\n x, y: LongInt;\n \nbegin\n ReadLn(x, y);\n If abs(x-y) mod 2 = 1 then WriteLn('Yes') else WriteLn('No');\nend."}, {"source_code": "var\n ex,ey,x,y : integer;\nbegin\n readln(ex,ey);\n x:=0;\n y:=1;\n while y=0) then write('Yes') else write('No');\n end;\n end.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var o,ik,io:integer;\nBegin\nRead(ik,io);\nIf ik>io-2 then begin\n If (ik-io+1) mod 2 = 0 then write('Yes') else write('No');\nend else write('No');\nEnd."}, {"source_code": "var x, y, n:longint;\nbegin readln(x, y);\n n:=x-y+1;\n if (n mod 2=0) and (y<>0) and (n>=0) and (x>y-2) then writeln('Yes')\n else writeln('No');\nend.\n\n"}, {"source_code": " \n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2,3,4;\n type real=double; int64=longint; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ogr,q,modul,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pos,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n time,jj,step, k,t1,ii,i,j:longint;\n aa,bb,cc:int64;\n l,r,c,dd,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n right,down,dda:array[-10..2200,-10..2200] of longint;\n zanx,zany:array[-10..2000000] of boolean;\n sss:string;\n zan,fl:array[-100..2000000] of boolean;\n ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2,ss1,ss2:array[0..nn] of string;\n ott,v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n flag:=true;\n if p1+1x) and (n>=0) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var\n x, y : longint;\n ans : string;\nbegin\n readln(x, y);\n ans := 'No';\n if abs(y - x) = 1 then ans := 'Yes';\n if (y = 1) and (x > 0) then ans := 'No';\n if y = 0 then ans := 'No';\n writeln(ans);\nend."}, {"source_code": "var x,y:integer;\nbegin\n readln(x,y);\n if y=0 then write('NO');\n if (y=1) and (x=0) then write('YES')\n else\n write('N0');\n if y>1 then\n if ((x-y-1) and 1 )=(x and 1) then write('YES')\n else\n write('NO');\nend."}, {"source_code": "Var \n X, Y: LongInt;\n\nBegin\n Read(X, Y);\n If ((X - Y + 1) mod 2 = 0) and (Y - X <= 1) then Write('Yes')\n Else Write('No')\nEnd."}, {"source_code": "var x,y:longint;\nbegin\nreadln(x,y);\nif y=0 then writeln('NO') else\n begin\n dec(y,1);\n dec(x,y);\n if (x mod 2=0) and (y<>0) and (x>=0) then writeln('YES') else writeln('NO')\n end\nend."}, {"source_code": "program p1;\ntype ma=1..1000000000;\nvar \nx,y,k:ma;\nbegin\nreadln (x,y);\nif ((x<>0) and (y=1)) or (y=0) or (x1) and (x0) then begin\n writeln('no');\nend;\nx:=x-y+1;\nif (odd(x)) then writeln('no') else writeln('yes');\nEND.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x, y, i, j: int64;\nbegin\n readln (x, y);\n i := y - 1;\n while (i < x) do begin\n inc (i, 2);\n end;\n if (i = x) then\n writeln ('YES')\n else\n writeln ('NO'); \n readln;\n readln;\nend.\n"}, {"source_code": "program zzz;\nvar\n x,y:longint;\nbegin\n readln(x,y);\n if ((x-y+1)mod 2=0)and(x>0)and (y>1) then writeln('yes')\n else writeln('no');\nend."}, {"source_code": "var x,y:longint;\nbegin\nread(x,y);\nif (x=y)or(y-x=1) then write('YES')\nelse if y>x then write('NO')\nelse if (x-y-1 mod 2)=1 then write('NO')\nelse write('YES');\nend."}, {"source_code": "var x,y:longint;\nbegin\nread(x,y);\nif (x-y=1)or(y-x=1) then write('YES')\nelse if y>x then write('NO')\nelse if ((x-y-1) mod 2)=1 then write('NO')\nelse write('YES');\nend."}, {"source_code": "program zzz;\nvar\n t:boolean;\n x,y:longint;\nbegin\n readln(x,y);\n t:=false;\n if (x>0) and (y>1) then\n begin\n if (x-y+3)mod 2 =0 then t:=true;\n if (x-y)mod 2 = 0 then t:=true;\n end;\n if (x>0)and(y=0)and(x mod 2=1) then t:=true;\n if (x=0)and(y<2) then\n t:=true;\n if t then writeln('yes')\n else writeln('no');\nend.\n"}], "src_uid": "1527171297a0b9c5adf356a549f313b9"} {"source_code": "var\n a: array [1..11, 1..11] of char;\n i, j, n, m, k: integer;\n isNotFull: boolean;\n\nbegin\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n readln();\n continue;\n end;\n for j := 1 to 11 do read(a[i, j]);\n readln();\n end;\n read(n, m);\n isNotFull := false;\n if (n >= 4) and (n <= 6) then n += 1\n else if (n >= 7) and (n <= 9) then n += 2;\n if (m >= 4) and (m <= 6) then m += 1\n else if (m >= 7) and (m <= 9) then m += 2;\n if (n = 1) or (n = 5) or (n = 9) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 2) or (n = 6) or (n = 10) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 3) or (n = 7) or (n = 11) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if isNotFull = false then for i := 1 to 11 do \n for j := 1 to 11 do \n if a[i, j] = '.' then a[i, j] := '!';\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n writeln();\n continue;\n end;\n for j := 1 to 11 do write(a[i, j]);\n writeln();\n end;\nend.", "positive_code": [{"source_code": "var\n a: array[1..9,1..9] of char;\n f: boolean;\n ch: char;\n x, y, i, j: byte;\nbegin\n read(a[1,1]);\n read(a[2,1]);\n read(a[3,1]);\n read(ch);\n read(a[4,1]);\n read(a[5,1]);\n read(a[6,1]);\n read(ch);\n read(a[7,1]);\n read(a[8,1]);\n readln(a[9,1]);\n read(a[1,2]);\n read(a[2,2]);\n read(a[3,2]);\n read(ch);\n read(a[4,2]);\n read(a[5,2]);\n read(a[6,2]);\n read(ch);\n read(a[7,2]);\n read(a[8,2]);\n readln(a[9,2]);\n read(a[1,3]);\n read(a[2,3]);\n read(a[3,3]);\n read(ch);\n read(a[4,3]);\n read(a[5,3]);\n read(a[6,3]);\n read(ch);\n read(a[7,3]);\n read(a[8,3]);\n readln(a[9,3]);\n readln;\n read(a[1,4]);\n read(a[2,4]);\n read(a[3,4]);\n read(ch);\n read(a[4,4]);\n read(a[5,4]);\n read(a[6,4]);\n read(ch);\n read(a[7,4]);\n read(a[8,4]);\n readln(a[9,4]);\n read(a[1,5]);\n read(a[2,5]);\n read(a[3,5]);\n read(ch);\n read(a[4,5]);\n read(a[5,5]);\n read(a[6,5]);\n read(ch);\n read(a[7,5]);\n read(a[8,5]);\n readln(a[9,5]);\n read(a[1,6]);\n read(a[2,6]);\n read(a[3,6]);\n read(ch);\n read(a[4,6]);\n read(a[5,6]);\n read(a[6,6]);\n read(ch);\n read(a[7,6]);\n read(a[8,6]);\n readln(a[9,6]);\n readln;\n read(a[1,7]);\n read(a[2,7]);\n read(a[3,7]);\n read(ch);\n read(a[4,7]);\n read(a[5,7]);\n read(a[6,7]);\n read(ch);\n read(a[7,7]);\n read(a[8,7]);\n readln(a[9,7]);\n read(a[1,8]);\n read(a[2,8]);\n read(a[3,8]);\n read(ch);\n read(a[4,8]);\n read(a[5,8]);\n read(a[6,8]);\n read(ch);\n read(a[7,8]);\n read(a[8,8]);\n readln(a[9,8]);\n read(a[1,9]);\n read(a[2,9]);\n read(a[3,9]);\n read(ch);\n read(a[4,9]);\n read(a[5,9]);\n read(a[6,9]);\n read(ch);\n read(a[7,9]);\n read(a[8,9]);\n readln(a[9,9]);\n readln(y, x);\n\n f := false;\n x := ((x-1) mod 3)*3;\n y := ((y-1) mod 3)*3;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if a[x+i,y+j] = '.'then begin\n f:= true;\n a[x+i,y+j] := '!'\n end;\n if f = false then\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j] = '.' then a[i,j] := '!';\n\n write(a[1,1]);\n write(a[2,1]);\n write(a[3,1]);\n write(' ');\n write(a[4,1]);\n write(a[5,1]);\n write(a[6,1]);\n write(' ');\n write(a[7,1]);\n write(a[8,1]);\n writeln(a[9,1]);\n write(a[1,2]);\n write(a[2,2]);\n write(a[3,2]);\n write(' ');\n write(a[4,2]);\n write(a[5,2]);\n write(a[6,2]);\n write(' ');\n write(a[7,2]);\n write(a[8,2]);\n writeln(a[9,2]);\n write(a[1,3]);\n write(a[2,3]);\n write(a[3,3]);\n write(' ');\n write(a[4,3]);\n write(a[5,3]);\n write(a[6,3]);\n write(' ');\n write(a[7,3]);\n write(a[8,3]);\n writeln(a[9,3]);\n writeln;\n write(a[1,4]);\n write(a[2,4]);\n write(a[3,4]);\n write(' ');\n write(a[4,4]);\n write(a[5,4]);\n write(a[6,4]);\n write(' ');\n write(a[7,4]);\n write(a[8,4]);\n writeln(a[9,4]);\n write(a[1,5]);\n write(a[2,5]);\n write(a[3,5]);\n write(' ');\n write(a[4,5]);\n write(a[5,5]);\n write(a[6,5]);\n write(' ');\n write(a[7,5]);\n write(a[8,5]);\n writeln(a[9,5]);\n write(a[1,6]);\n write(a[2,6]);\n write(a[3,6]);\n write(' ');\n write(a[4,6]);\n write(a[5,6]);\n write(a[6,6]);\n write(' ');\n write(a[7,6]);\n write(a[8,6]);\n writeln(a[9,6]);\n writeln;\n write(a[1,7]);\n write(a[2,7]);\n write(a[3,7]);\n write(' ');\n write(a[4,7]);\n write(a[5,7]);\n write(a[6,7]);\n write(' ');\n write(a[7,7]);\n write(a[8,7]);\n writeln(a[9,7]);\n write(a[1,8]);\n write(a[2,8]);\n write(a[3,8]);\n write(' ');\n write(a[4,8]);\n write(a[5,8]);\n write(a[6,8]);\n write(' ');\n write(a[7,8]);\n write(a[8,8]);\n writeln(a[9,8]);\n write(a[1,9]);\n write(a[2,9]);\n write(a[3,9]);\n write(' ');\n write(a[4,9]);\n write(a[5,9]);\n write(a[6,9]);\n write(' ');\n write(a[7,9]);\n write(a[8,9]);\n write(a[9,9])\nend."}, {"source_code": "var a: array [1..11,1..11] of char;\n x,y,i,j,n,m,k: byte;\nbegin\n n:=0; m:=0; k:=0;\n for i:=1 to 11 do begin\n if i mod 4>0 then\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n read(x,y);\n if (x=1)or(x=4)or(x=7) then n:=1; if (x=3)or(x=6)or(x=9) then n:=9; if n=0 then n:=5;\n if (y=1)or(y=4)or(y=7) then m:=1; if (y=3)or(y=6)or(y=9) then m:=9; if m=0 then m:=5;\n for i:=n to n+2 do\n for j:=m to m+2 do\n if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;\n if k=0 then\n for i:=1 to 11 do\n for j:=1 to 11 do\n if a[i,j]='.' then a[i,j]:='!';\n for i:=1 to 11 do begin\n if i mod 4>0 then\n for j:=1 to 11 do\n write(a[i,j]);\n writeln;\n end;\n end."}, {"source_code": "var\ns:array[-10..1000]of string;\nbol:boolean;\ni,j,x,y,l,r,ll,rr:longint;\nbegin\nfor i:=1 to 11 do begin\n readln(s[i]);\nend;\nreadln(x,y);\nx:=x mod 3;\ny:=y mod 3;\nif y=0 then y:=3;\nif x=0 then x:=3;\nif x=1 then begin\n l:=1;\n r:=3;\nend;\nif x=2 then begin\n l:=5;\n r:=7;\nend;\nif x=3 then begin\n l:=9;\n r:=11;\nend;\nif y=1 then begin\n ll:=1;\n rr:=3;\nend;\nif y=2 then begin\n ll:=5;\n rr:=7;\nend;\nif y=3 then begin\n ll:=9;\n rr:=11;\nend;\n\nfor i:=l to r do begin\n for j:=ll to rr do begin\n if s[i][j]='.' then begin\n s[i][j]:='!';\n bol:=true;\n end;\n end;\nend;\n\nif bol =false then begin\n for i:=1 to 11 do\n for j:=1 to length(s[i]) do begin\n if s[i][j]='.' then s[i][j]:='!';\n end;\nend;\nfor i:=1 to 11 do begin\nwrite(s[i]);\nwriteln;\nend;\nend."}, {"source_code": "var s:array[1..100] of string;\n i,k,n,x,y,kol,j:longint;\nbegin\ni:=1;\nwhile i<=9 do\nbegin\n readln(s[i]);\n k:=pos(' ',s[i]);\n delete(s[i],k,1);\n k:=pos(' ',s[i]);\n delete(s[i],k,1);\n if s[i]<>''\n then inc(i);\nend;\nreadln(x,y);\nx:=x mod 3;\ny:=y mod 3;\nif x=0\nthen x:=3;\nif y=0\nthen y:=3;\nx:=(x*3)-2;\ny:=(y*3)-2;\n kol:=0;\n for i:=x to x+2 do\n for j:=y to y+2 do\n if s[i,j]='.'\n then inc(kol);\n if kol=0\n then for i:=1 to 9 do\n for j:=1 to 9 do\n if s[i,j]='.'\n then s[i,j]:='!';\n if kol>0\n then for i:=x to x+2 do\n for j:=y to y+2 do\n if s[i,j]='.'\n then s[i,j]:='!';\n\nfor i:=1 to 9 do\nbegin\n for j:=1 to 9 do\n if j mod 3=0\n then write(s[i,j],' ')\n else write(s[i,j]);\n writeln;\n\n if i mod 3=0\n then writeln;\nend;\nend.\n\n"}, {"source_code": "var\n a:array[1..9,1..9] of integer;\n s:string;\n j,i,x,y,k:integer;\n \n procedure sx();\n begin\n if copy(s,1,1)='.' then a[i,j]:=0;\n if copy(s,1,1)='x' then a[i,j]:=1;\n if copy(s,1,1)='o' then a[i,j]:=2;\n delete(s,1,1);\n end;\n \n procedure qx();\n begin\n if a[i,j]=0 then write('.');\n if a[i,j]=1 then write('x');\n if a[i,j]=2 then write('o');\n if a[i,j]=4 then write('!');\n end;\n \n Begin\n for i:=1 to 3 do begin\n readln(s);\n for j:=1 to 3 do\n sx;\n delete(s,1,1);\n for j:=4 to 6 do\n sx;\n delete(s,1,1);\n for j:=7 to 9 do\n sx;\n delete(s,1,1); end;\n readln;\n for i:=4 to 6 do begin\n readln(s);\n for j:=1 to 3 do\n sx;\n delete(s,1,1);\n for j:=4 to 6 do\n sx;\n delete(s,1,1);\n for j:=7 to 9 do\n sx;\n delete(s,1,1); end;\n readln;\n for i:=7 to 9 do begin\n readln(s);\n for j:=1 to 3 do\n sx;\n delete(s,1,1);\n for j:=4 to 6 do\n sx;\n delete(s,1,1);\n for j:=7 to 9 do\n sx;\n delete(s,1,1); end;\n \n readln(x,y);\n \n \n if(x=1)or(x=4)or(x=7) then x:=1;\n if(x=2)or(x=5)or(x=8) then x:=2;\n if(x=3)or(x=6)or(x=9) then x:=3;\n if(y=1)or(y=4)or(y=7) then y:=1;\n if(y=2)or(y=5)or(y=8) then y:=2;\n if(y=3)or(y=6)or(y=9) then y:=3;\n \n k:=0;\n \n for i:=x*3-2 to x*3 do\n for j:=y*3-2 to y*3 do\n if a[i,j]=0 then begin\n k:=1;\n a[i,j]:=4; end;\n \n if k=0 then \n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j]=0 then\n a[i,j]:=4;\n \n if k=1 then\n for i:=x*3-2 to x*3 do\n for j:=y*3-2 to y*3 do\n if a[i,j]=0 then\n a[i,j]:=4;\n \n for i:=1 to 3 do begin\n for j:=1 to 3 do\n qx;\n write(' ');\n for j:=4 to 6 do\n qx;\n write(' ');\n for j:=7 to 9 do\n qx;\n writeln;\n end;\n \n writeln;\n \n for i:=4 to 6 do begin\n for j:=1 to 3 do\n qx;\n write(' ');\n for j:=4 to 6 do\n qx;\n write(' ');\n for j:=7 to 9 do\n qx;\n writeln;\n end;\n \n writeln;\n \n for i:=7 to 9 do begin\n for j:=1 to 3 do\n qx;\n write(' ');\n for j:=4 to 6 do\n qx;\n write(' ');\n for j:=7 to 9 do\n qx;\n writeln;\n end;\n \n End."}, {"source_code": "var\nstr:array[1..11] of string;\nx,y,ans,i,j:integer;\n\nbegin\n\nfor i:=1 to 11 do\nreadln(str[i]);\n\nreadln(x,y);\n\nx:=x mod 3;\nif x = 0 then x:=3;\n\ny:=y mod 3;\nif y = 0 then y:=3;\n\nans:=0;\n\nfor i:=4*x - 3 to 4*x - 1 do\nfor j:=4*y - 3 to 4*y - 1 do\nif str[i][j] = '.' then\nbegin\nstr[i][j] := '!';\nans:=1;\nend;\n\nif ans = 0 then\nfor i:=1 to 11 do\nfor j:=1 to 11 do\nif i mod 4 > 0 then\nif str[i][j] = '.' then\nstr[i][j] := '!';\n\nfor i:=1 to 11 do\nwriteln(str[i]);\n\nend."}, {"source_code": "var c:array[1..3,1..3,1..3,1..3] of boolean;\nq:array[1..3,1..3,1..3,1..3] of char;\ni,j,k,l,m,n,x,y,a,b,w,d:longint;\np:char;\ns:string;\n\nfunction check(x,y:longint):boolean;\nvar i,j:longint;\nbegin\nfor i:=1 to 3 do\nfor j:=1 to 3 do\nif not c[x,y,i,j] then check:=true\nend;\n\nprocedure doit(x,y:longint);\nvar i,j:longint;\nbegin\nfor i:=1 to 3 do\nfor j:=1 to 3 do\nif q[x,y,i,j]='.' then q[x,y,i,j]:='!'\nend;\n\n\n\n\nbegin\nfor i:=1 to 11 do\nbegin\nif i mod 4<>0 then \nn+=1 else\nbegin\nreadln(s);\ncontinue\nend;\nm:=0;\nfor j:=1 to 11 do\nbegin\nread(p);\nif p<>' ' then m+=1;\nif n mod 3=0 then x:=3 else x:=n mod 3;\nif m mod 3=0 then y:=3 else y:=m mod 3;\nif (p<>' ') and (p<>'.') and (p<>'') then \nbegin\nc[(n+2) div 3,(m+2) div 3,x,y]:=true;\n\nend;\nif p<>' ' then\nq[(n+2) div 3,(m+2) div 3,x,y]:=p;\nend;\n\nreadln;\nend;\n\nread(x,y);\n\n\n\na:=(x+2) div 3;\nb:=(y+2) div 3;\nif x mod 3=0 then w:=3 else w:=x mod 3;\nif y mod 3=0 then d:=3 else d:=y mod 3;\n\nif check(w,d) then doit(w,d) else\nbegin\nfor i:=1 to 3 do\nfor j:=1 to 3 do\ndoit(i,j)\nend;\n\nfor k:=1 to 3 do\nbegin\nfor l:=1 to 3 do\nbegin\nfor j:=1 to 3 do\nbegin\nfor i:=1 to 3 do\nwrite(q[k,j,l,i]);write(' ');\nend;\nwriteln;\nend;\nwriteln\nend;\nend."}, {"source_code": "program qq;\nvar a: array [1..9,1..9] of char;\nc: char;\nx,y,j,m,p:integer;\nbegin\nj:=1;\nwhile j<=9 do begin\n m:=1;\nwhile m<=9 do begin\nread (c);\nif (c='.') or (c='x') or (c='o') then begin a[j,m]:=c; m:=m+1; end;\nend; \nj:=j+1 end; \nread (x,y);\nj:= 3*(x mod 3)-2; m:= 3*(y mod 3) - 2;\nif j=-2 then j:=7; if m=-2 then m:=7; p:=0;\nfor i:integer:=j to j+2 do\nfor n:integer:=m to m+2 do\nif a[i,n]='.' then begin p:=1; a[i,n]:='!'; end;\nif p=0 then\nfor i:integer:=1 to 9 do\nfor n:integer:=1 to 9 do if a[i,n]='.' then a[i,n]:='!';\nfor i:integer:=1 to 9 do begin\n\nif i=4 then writeln (); if i=7 then writeln ();\nfor n:integer:=1 to 9 do begin\nif n=4 then write (' '); if n=7 then write (' ');\nwrite (a[i,n]);\nend;if i<>9 then writeln ();\nend;\nend."}, {"source_code": "var\na:array[1..11] of string;\ni,o,x,y,e:integer;\nbegin\n\n\n\n\ne:=0;\nfor i:=1 to 11 do readln(a[i]);\nreadln(x,y);\n\nfor i:=(((x-1) mod 3)*3)+((((x-1)mod 3)*3) div 3)+1 to (((x-1) mod 3)*3)+((((x-1)mod 3)*3) div 3)+3 do \nfor o:=(((y-1) mod 3)*3)+((((y-1)mod 3)*3) div 3)+1 to (((y-1) mod 3)*3)+((((y-1)mod 3)*3) div 3)+3 do \nif a[i][o]='.' then begin\na[i][o]:='!';\ne:=e+1;\nend;\n\nif e=0 then for i:=1 to 3 do\nfor o:=1 to 11 do \nif a[i][o]='.' then a[i][o]:='!';\n\nif e=0 then for i:=5 to 7 do\nfor o:=1 to 11 do \nif a[i][o]='.' then a[i][o]:='!';\n\nif e=0 then for i:=9 to 11 do\nfor o:=1 to 11 do \nif a[i][o]='.' then a[i][o]:='!';\n\n\nfor i:=1 to 11 do \nwriteln(a[i]);\n\n\n\nend."}, {"source_code": "program bbb;\nvar s: string;\n a: array [1..9,1..9] of integer;\n i,j,c,l,x: integer;\nbegin\n\n c:=0;\n for i:=1 to 11 do\n begin\n readln(s);\n if (i<>4) and (i<>8) then\n begin\n inc(c);\n l:=0;\n for j:=1 to length(s) do begin\n if s[j]<>' ' then\n begin\n inc(l);\n if s[j]='.' then a[c,l]:=0;\n if s[j]='x' then a[c,l]:=1;\n if s[j]='o' then a[c,l]:=2;\n end;\n end;\n end;\n //writeln(i);\n end;\n read(c,l);\n c:=c mod 3;\n if c=0 then c:=3;\n l:=l mod 3;\n if l=0 then l:=3;\n x:=0;\n for i:=c*3-2 to c*3 do\n for j:=l*3-2 to l*3 do if a[i,j]=0 then\n begin\n a[i,j]:=3;\n inc(x);\n end;\n c:=0;\n l:=0;\n for i:=1 to 11 do\n begin\n if (i<>4) and (i<>8) then\n begin inc(c);\n l:=0;\n for j:=1 to 11 do\n begin\n if (j<>4) and (j<>8) then begin\n inc(l);\n // writeln(c,l);\n if a[c,l]=1 then write('x');\n if a[c,l]=2 then write('o');\n if a[c,l]=3 then write('!');\n if (x>0) and (a[c,l]=0) then write('.');\n if (x=0) and (a[c,l]=0) then write('!');\n end\n else write(' ');\n end;\n end;\n writeln;\n end;\nend.\n "}, {"source_code": "var\nch:char;\nbol: boolean;\na,b,i,secx,secy,secn,absa,absb: integer;\narr: array[1..9] of array[1..9] of integer;\nt: text;\nbegin\n\na:=1;\nb:=1;\nwhile i<119 do\nbegin\ni:=i+1;\nread(ch);\nif (ch='x') then\nbegin\narr[a][b]:=1;\nb:=b+1;\nif b=10 then begin b:=1; a:=a+1; end;\nend\nelse if ch=('o') then\nbegin\narr[a][b]:=2;\nb:=b+1;\nif b=10 then begin b:=1; a:=a+1; end;\nend\nelse\nif ch='.' then\nbegin\nb:=b+1;\nif b=10 then begin b:=1; a:=a+1; end;\nend;\nend;\nreadln(b,a);\nabsa:=a;\nabsb:=b;\nwhile absa>3 do absa:=absa-3;\nwhile absb>3 do absb:=absb-3;\nfor a:=(absa-1)*3+1 to absa*3 do\nfor b:=(absb-1)*3+1 to absb*3 do\nbegin\nif arr[b][a]=0 then begin bol:=true; arr[b][a]:=3; end;\nend;\nif bol = false then\nbegin\nfor a:=1 to 9 do\nfor b:=1 to 9 do\nif arr[a][b]=0 then arr[a][b]:=3;\nend;\nfor a:=1 to 9 do\nbegin\nfor b:=1 to 9 do\nbegin\nif arr[a][b] = 0 then write('.');\nif arr[a][b] = 1 then write('x');\nif arr[a][b] = 2 then write('o');\nif arr[a][b] = 3 then write('!');\nif b<>1 then if b mod 3 = 0 then write(' ');\nend;\nwriteln();\nif a<>1 then if a mod 3 = 0 then\nwriteln();\nend;\nend."}, {"source_code": "var\n a: array [1..3] of array [1..3] of array [1..3] of array [1..3] of byte;\n x, y, k: byte;\n s: string;\n\nbegin\n for var i1 := 1 to 9 do\n begin\n readln(s);\n if s = '' then\n readln(s);\n delete(s, pos(' ', s), 1);\n delete(s, pos(' ', s), 1);\n for var i2 := 1 to 9 do\n case s[i2] of\n 'x': a[(i1 - 1) div 3 + 1][(i2 - 1) div 3 + 1][(i1 - 1) mod 3 + 1][(i2 - 1) mod 3 + 1] := 1;\n 'o': a[(i1 - 1) div 3 + 1][(i2 - 1) div 3 + 1][(i1 - 1) mod 3 + 1][(i2 - 1) mod 3 + 1] := 2;\n end;\n end;\n readln(y, x);\n for var i3 := 1 to 3 do\n for var i4 := 1 to 3 do\n if a[(y - 1) mod 3 + 1][(x - 1) mod 3 + 1][i3][i4] = 0 then\n begin\n a[(y - 1) mod 3 + 1][(x - 1) mod 3 + 1][i3][i4] := 3;\n k += 1;\n end;\n if k = 0 then\n for var i5 := 1 to 3 do\n for var i6 := 1 to 3 do\n for var i7 := 1 to 3 do\n for var i8 := 1 to 3 do\n if a[i5][i6][i7][i8] = 0 then\n a[i5][i6][i7][i8] := 3;\n for var i9 := 1 to 9 do\n begin\n for var i10 := 1 to 9 do\n begin\n case a[(i9 - 1) div 3 + 1][(i10 - 1) div 3 + 1][(i9 - 1) mod 3 + 1][(i10 - 1) mod 3 + 1] of\n 0: write('.');\n 1: write('x');\n 2: write('o');\n 3: write('!');\n end;\n case i10 of\n 3, 6: write(' ');\n end;\n end;\n writeln;\n case i9 of\n 3, 6, 9: writeln;\n end;\n \n end;\nend."}, {"source_code": "var a:array[1..9,1..9]of string;\n x,y,k,i,j:integer;\n c:char;\nbegin\nfor j:=1 to 9 do\n for i:=1 to 9 do begin\n read(c);\n while not((c='.')or(c='x')or(c='o'))do read(c);\n a[i,j]:=c;\n end;\n\nread(y,x);\nx:=(x-1)mod 3;\ny:=(y-1)mod 3;\n\nk:=0;\nfor j:=y*3+1 to (y+1)*3 do\n for i:=x*3+1 to (x+1)*3 do \n if a[i,j]='.' then inc(k);\n \nif k>0 then begin\n for j:=y*3+1 to (y+1)*3 do\n for i:=x*3+1 to (x+1)*3 do \n if a[i,j]='.' then a[i,j]:='!'\n end else \n for j:=1 to 9 do\n for i:=1 to 9 do\n if a[i,j]='.' then a[i,j]:='!';\n \n \nfor j:= 1 to 3 do begin\n for i:=1 to 3 do write(a[i,j]);\n write(' ');\n for i:=4 to 6 do write(a[i,j]);\n write(' ');\n for i:=7 to 9 do write(a[i,j]);\n writeln(' ');\nend;\nwriteln(' ');\nfor j:= 4 to 6 do begin\n for i:=1 to 3 do write(a[i,j]);\n write(' ');\n for i:=4 to 6 do write(a[i,j]);\n write(' ');\n for i:=7 to 9 do write(a[i,j]);\n writeln(' ');\nend;\nwriteln(' ');\nfor j:= 7 to 9 do begin\n for i:=1 to 3 do write(a[i,j]);\n write(' ');\n for i:=4 to 6 do write(a[i,j]);\n write(' ');\n for i:=7 to 9 do write(a[i,j]);\n writeln(' ');\nend;\nend."}, {"source_code": "var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;\n begin\n for i:=1 to 9 do \n begin\n readln(s);\n for l:=1 to 11 do\n begin\n if (l=4) or (l=8) then continue;\n if (l>4) and (l<8) then u:=l-1;\n if (l>8) then u:=l-2;\n if (l<4) then u:=l;\n a[i, u]:=s[l];\n end;\n if (i<9) and (i mod 3 = 0 ) then readln(s);\n end;\n read(x,y);\n if a[x,y]='o' then chir:='x' else chir:='o';\n flag:=true;\n if x mod 3 = 0 then\n line:=3;\n if x mod 3 = 2 then \n line:=2;\n if x mod 3 = 1 then\n line:=1;\n if y mod 3 = 0 then\n col:=3;\n if y mod 3 = 2 then \n col:=2;\n if y mod 3 = 1 then\n col:=1;\n for i:=line*3-2 to line*3 do\n for j:=col*3-2 to col*3 do\n if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;\n if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';\n for i:=1 to 9 do \n begin\n for j:=1 to 3 do\n begin\n for l:=j*3-2 to j*3 do write(a[i, l]);\n write(' ');\n end;\n writeln;\n if (i<9) and (i mod 3 = 0 ) then writeln;\n end;\n \n \n \n end."}, {"source_code": "var\n a: array[1..9, 1..9] of char;\n bufer: char;\n\nvar\n i, j, iwant, jwant, found: longint;\n\n\n\n\n\n\nprocedure full;\nvar\n i, j: longint;\nbegin\n \n if found = 0 then\n begin\n for i := 1 to 9 do\n for j := 1 to 9 do\n begin\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n \nend;\n\nprocedure normal;\nvar\n i, j: longint;\nbegin\n for i := 1 to 9 do\n for j := 1 to 9 do\n begin\n if (i > ((iwant - 1) * 3) ) and (i <= (iwant * 3) ) then\n if (j > ((jwant - 1) * 3) ) and (j <= (jwant * 3) ) then\n if a[i, j] = '.' then\n begin\n found := 1;\n a[i, j] := '!';\n end;\n end;\nend;\n\nprocedure outwrite;\nvar\n i, j: longint;\nbegin\n for i := 1 to 9 do\n begin\n for j := 1 to 9 do\n begin\n write(a[i, j]);\n if (j = 3) or (j = 6) then write(' '); \n end; \n writeln;\n if (i = 3) or (i = 6) then writeln;\n end; \nend;\n\nbegin\n i := 1;\n while true do \n begin\n j := 1;\n while true do\n begin\n read(bufer);\n if (bufer = '.') or (bufer = 'o') or (bufer = 'x') then begin a[i, j] := bufer;inc(j); end;\n if j = 10 then break;\n end;\n inc(i);\n if i = 10 then break;\n end;\n readln(iwant, jwant);\n while iwant > 3 do\n begin\n iwant := iwant - 3;\n end;\n while jwant > 3 do\n begin\n jwant := jwant - 3;\n end;\n found := 0;\n normal;\n full;\n outwrite;\nend."}, {"source_code": "Program CodeF_454_B;\nvar x,y,i,j,i1,j1,n:longint;\n m:array[1..1]of longint;\n //reb:array[1..1]of array[1..2]of longint;\n p:array[0..8]of array[0..8]of longint;\n s:string;\n mogu:boolean;\n \n \nbegin\ni1:=-1;\nfor i:=1 to 11 do\n begin\n readln(s);\n if length(s)=11 then\n begin\n inc(i1);\n j1:=-1;\n for j:=1 to 11 do\n begin\n if s[j]<>' ' then inc(j1);\n if s[j]='o' then\n begin\n p[i1][j1]:=1;\n end;\n if s[j]='x' then\n begin\n p[i1][j1]:=2;\n end; \n end;\n end; \n end;\nread(x, y);\nx:=(x-1) mod 3;\ny:=(y-1) mod 3;\nmogu:=false;\nfor i:=0 to 8 do\n for j:=0 to 8 do\n if (i div 3=x) and (j div 3=y) then\n begin\n if p[i][j]=0 then\n mogu:=true;\n end;\n\nif mogu=true then\n for i:=0 to 8 do\n for j:=0 to 8 do\n begin\n if p[i][j]=0 then\n if (i div 3=x) and (j div 3=y) then\n p[i][j]:=3;\n end else\n begin\n for i:=0 to 8 do\n for j:=0 to 8 do\n if p[i][j]=0 then\n p[i][j]:=3;\n end;\n\nfor i:=0 to 8 do\n begin\n if (i mod 3=0) and (i<>0) then\n writeln;\n for j:=0 to 8 do\n begin\n if (j mod 3=0) and (j<>0) then\n write(' ');\n if p[i][j]=0 then write('.'); \n if p[i][j]=1 then write('o');\n if p[i][j]=2 then write('x');\n if p[i][j]=3 then write('!');\n end;\n writeln; \n end;\n\nend."}, {"source_code": "program Program1;\nvar i,j,x,y: integer;\n test: boolean;\n S: array[1..9] of string;\nbegin\n for i:=1 to 9 do begin\n if (i=4)or(i=7) then\n readln();\n readln(s[i]);\n end;\n read(x,y);\n test:=false;\n if ((x=1)or(x=4)or(x=7))and((y=1)or(y=4)or(y=7)) then begin\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end;\n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=1)or(x=4)or(x=7))and((y=2)or(y=5)or(y=8)) then begin\n for i:=1 to 3 do begin\n for j:=5 to 7 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end; \n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=1)or(x=4)or(x=7))and((y=3)or(y=6)or(y=9)) then begin\n for i:=1 to 3 do begin\n for j:=9 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end; \n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=2)or(x=5)or(x=8))and((y=1)or(y=4)or(y=7)) then begin\n for i:=4 to 6 do begin\n for j:=1 to 3 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end; \n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=2)or(x=5)or(x=8))and((y=2)or(y=5)or(y=8)) then begin\n for i:=4 to 6 do begin\n for j:=5 to 7 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end;\n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=2)or(x=5)or(x=8))and((y=3)or(y=6)or(y=9)) then begin\n for i:=4 to 6 do begin\n for j:=9 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end;\n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=3)or(x=6)or(x=9))and((y=1)or(y=4)or(y=7)) then begin\n for i:=7 to 9 do begin\n for j:=1 to 3 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end; \n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=3)or(x=6)or(x=9))and((y=2)or(y=5)or(y=8)) then begin\n for i:=7 to 9 do begin\n for j:=5 to 7 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true; \n end;\n end;\n end;\n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n if ((x=3)or(x=6)or(x=9))and((y=3)or(y=6)or(y=9)) then begin\n for i:=7 to 9 do begin\n for j:=9 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n test:=true;\n end;\n end;\n end;\n if test=false then begin\n for i:=1 to 9 do begin\n for j:=1 to 11 do begin\n if S[i][j]='.' then begin\n S[i][j]:='!';\n end;\n end;\n end;\n end;\n end;\n for i:=1 to 9 do begin\n if (i=4)or(i=7) then\n writeln();\n writeln(S[i]);\n end;\nend."}, {"source_code": "var\n big: array[1..9, 1..9] of integer;\n strs: array[1..9] of string;\n k, num, x, y, i, j, x1, x2, y1, y2: integer;\n ch: char;\n s: string;\n\nbegin\n \n \n for i := 1 to 9 do \n begin\n \n k := -1; j := 1;\n while (j <= 9) do\n begin\n read(ch);\n if (ch = 'x') then k := 1;\n if(ch = 'o') then k := 2;\n if(ch = '.') then k := 0;\n if(k >= 0) then\n begin\n big[i, j] := k;\n inc(j);\n end;\n k := -1;\n end;\n \n end;\n read(y, x);\n \n x := x mod 3;\n y := y mod 3;\n if(x = 1) then \n begin\n x1 := 1;\n x2 := 3;\n end else\n if(x = 2) then \n begin\n x1 := 4;\n x2 := 6;\n end else\n begin\n x1 := 7;\n x2 := 9;\n end;\n if(y = 1) then \n begin\n y1 := 1;\n y2 := 3;\n end else\n if(y = 2) then \n begin\n y1 := 4;\n y2 := 6;\n end else\n begin\n y1 := 7;\n y2 := 9;\n end;\n num := 0;\n for i := y1 to y2 do\n for j := x1 to x2 do\n begin\n if(big[i, j] = 0) then \n inc(num);\n end;\n \n if(num = 0) then begin\n x1 := 1;\n x2 := 9;\n y1 := 1;\n y2 := 9;\n end;\n for i := 1 to 9 do\n begin\n s := '';\n for j := 1 to 9 do\n begin\n if(big[i, j] = 1) then \n s += 'x';\n if(big[i, j] = 2) then s += 'o';\n if(big[i, j] = 0) then\n begin\n if(i <= y2 ) and (i >= y1) and (j <= x2) and (j >= x1) then\n s += '!' else s += '.';\n end;\n if(j mod 3 = 0) then s += ' ';\n \n end;\n writeln(s);\n if(i mod 3 = 0) then writeln;\n end;\n \n \nend."}, {"source_code": "var\n a:array[1..9,1..9] of char;\n rep:char;\n var i,j:longint; //������ �������\n ineed,jneed,found:longint;\nbegin\n i:=1;\n while true do begin\n j:=1;\n while true do\n begin\n read(rep);\n if (rep = '.') or (rep = 'o') or (rep = 'x') then begin a[i,j]:=rep; inc(j); end;\n if j = 10 then break;\n end;\n inc(i);\n if i = 10 then break;\n end;\n readln(ineed,jneed);\n while ineed > 3 do\n begin\n ineed:=ineed - 3;\n end;\n while jneed > 3 do\n begin\n jneed:=jneed - 3;\n end;\n found:=0;\n for i:=1 to 9 do\n for j:=1 to 9 do\n begin\n if (i>((ineed-1)*3) ) and (i <= (ineed*3) ) then\n if (j>((jneed-1)*3) ) and (j <= (jneed*3) ) then\n if a[i,j] = '.' then\n begin\n found := 1;\n a[i,j]:='!';\n end;\n end;\n if found = 0 then\n begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n begin\n if a[i,j]='.' then a[i,j]:='!';\n end;\n end;\n for i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n write(a[i,j]);\n if (j = 3) or (j = 6) then write(' '); \n end; \n writeln;\n if (i = 3) or (i = 6) then writeln;\n end; \nend."}, {"source_code": "Var\n\ta: array [1..11,1..11] of integer;\n x, y, i, j, k, n, m, l, s:integer;\n\tch,pr : char;\n\tf:boolean;\nbegin\n x := 0;\n y := 0;\n\tfor i := 1 to 9 do\n begin\n if (i = 4) or (i = 7) then readln;\n inc(x);\n y := 0;\n\t\tfor j := 1 to 9 do\n\t\tbegin\n\t\t\tif (j = 4) or (j = 7) then read(pr);\n\t\t\tread(ch);\n inc(y);\n\t\t\tcase ch of\n\t\t\t'.': a[x,y] := 0;\n\t\t\t'o': a[x,y] := 1;\n\t\t\t'x': a[x,y] := 2;\n\t\t\tend;\n // writeln(ch, ' ', x, ' ', y);\n \n\t\tend;\n \n readln;\n end;\n \n {for i := 1 to 9 do\n begin\n for j := 1 to 9 do\n write(a[i,j],' ');\n \n writeln;\n end;}\n\t\tread(x,y);\n\t\t//writeln(x,' ',y);\n\t\twhile (x-3 > 0) do x := x-3;\n\t\twhile (y-3 > 0) do y := y-3;\n\t\t//writeln(x,' ',y);\n\t\tx := (x-1)*3+1;\n\t\ty := (y-1)*3+1;\n //writeln(x,' ',y);\n\t\tf := false;\n\t\tfor i := x to x+2 do\n\t\t\tfor j := y to y+2 do\n\t\t\t\tif (a[i,j] = 0) then begin\n\t\t\t\ta[i,j] := 3;\n\t\t\t\tf := true;\n\t\t\t\tend;\n\t\t\n\t\tfor i := 1 to 9 do\n\t\t\tbegin\n\t\t\tfor j := 1 to 9 do\n\t\t\tbegin\n\t\t\t\tcase a[i,j] of\n\t\t\t\t0: if (f <> false) then\n\t\t\t\twrite('.')\n\t\t\t\telse\n\t\t\t\twrite('!');\n\t\t\t\t1: write('o');\n\t\t\t\t2: write('x');\n\t\t\t\t3: write('!');\n\t\t\t\tend;\n\t\t\tif (j = 3) or (j = 6) then write(' ');\n\t\t\tif (j = 9) then writeln;\n\t\t\tend;\n\t\t\tif (i = 3) or (i = 6) then writeln;\n\t\t\t\n\t\t\t\n\t\t\tend;\n\t{\tcase x of\n\t\t1: case y of\n\t\t\t1: n = 1;\n\t\t\t2: n = 2;\n\t\t\t3: n = }\nend."}, {"source_code": "program cupB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a:array[1..9,1..9] of char;\n i,j,k,x,y:integer;\n flagg:boolean;\n sim:char;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n for i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n read(a[i,j]);\n if (j=3) or (j=6) then read(sim);\n end;\n readln;\n if (i=3) or (i=6) then readln;\n end;\n readln(x,y);\n x:=x mod 3;\n if x=0 then x:=3;\n y:=y mod 3;\n if y=0 then y:=3;\n\n flagg:=false;\n for i:=(x-1)*3+1 to 3*x do\n for j:=(y-1)*3+1 to 3*y do\n if a[i,j]='.' then\n begin\n flagg:=true;\n a[i,j]:='!';\n end;\n if flagg=false then\n begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j]='.' then a[i,j]:='!';\n end;\n\n for i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n write(a[i,j]);\n if (j=3) or (j=6) then write(' ');\n end;\n writeln;\n if (i=3) or (i=6) then writeln;\n end;\nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n end;\n readln;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n end;\n writeln;\n end;\n exit;\n end;\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n end;\n writeln;\n end;\nend.\n"}, {"source_code": "var\n Field: array [1..9, 1..9] of Char;\n s, str: string;\n i, j, x, y: LongInt;\n Filled: Boolean;\n\nprocedure SuperTrim(var s: string);\nvar\n minus: LongInt;\nbegin\n minus := 0;\n For i := 1 to Length(s) do\n begin\n If ord(s[i-minus]) < 33 then\n begin\n Delete(s, i-minus, 1);\n inc(minus);\n end;\n end;\nend;\n\nbegin\n ReadLn(s);\n For i := 2 to 11 do\n begin\n ReadLn(str);\n s := s + str;\n end;\n\n SuperTrim(s);\n\n For i := 1 to 9 do\n begin\n For j := 1 to 9 do\n begin\n Field[i, j] := s[(i-1)*9 + j];\n end;\n end;\n\n Read(y, x);\n ReadLn;\n x := ((x - 1) mod 3)*3 + 1;\n y := ((y - 1) mod 3)*3 + 1;\n\n Filled:=True;\n For i := 0 to 2 do\n begin\n For j := 0 to 2 do\n begin\n If Field[y+i, x+j] = '.' then Filled := False;\n end;\n end;\n\n If Filled then\n begin\n For i := 1 to 9 do\n begin\n For j := 1 to 9 do\n begin\n If Field[i, j] = '.' then Field[i, j] := '!'\n end;\n end;\n end else\n begin\n For i := 0 to 2 do\n begin\n For j := 0 to 2 do\n begin\n If Field[y+i, x+j] = '.' then Field[y+i, x+j] := '!'\n end;\n end;\n end;\n\n For i := 1 to 9 do\n begin\n For j := 1 to 9 do\n begin\n Write(Field[i, j]);\n If (j = 3) or (j = 6) then Write(' ');\n end;\n If (i = 3) or (i = 6) then WriteLn('');\n WriteLn('');\n end;\nend.\n"}, {"source_code": "var s:array[0..12] of string;\nvar x,y,i,j:longint;\nvar r:boolean;\nbegin\n for i:=1 to 9 do begin if (i=4) or (i=7) then readln(s[i]);readln(s[i]);\n delete(s[i],4,1);delete(s[i],7,1);end;\n readln(x,y);x:=x mod 3;y:=y mod 3;r:=false;\n if x=0 then x:=3;if y=0 then y:=3;\n for i:=x*3-2 to x*3 do\n for j:=y*3-2 to y*3 do if s[i,j]='.' then begin r:=true;s[i,j]:='!';end;\n if not r then for i:=1 to 9 do for j:=1 to 9 do if s[i,j]='.' then\n s[i,j]:='!';\n for i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n if (j=4) or (j=7) then write(' ');\n write(s[i,j]);\n end;\n writeln;\n if (i=3) or (i=6) then writeln;\n end;\n writeln;\nend.\n"}, {"source_code": "var a:array[0..1000]of string;\nx,y,i,j:longint;f:boolean;\nbegin\n//assign(input,'tictactoe.in');reset(input);\n//assign(output,'tictactoe.out');rewrite(output);\nfor I:=1 to 9 do\n begin\n if(i=4)or(i=7)then readln(a[i]);\n readln(a[i]);\n delete(a[i],8,1);\n delete(a[i],4,1);\n end;\nread(x,y);\nx:=(x-1)mod 3+1;\ny:=(y-1)mod 3+1;\nf:=false;\nfor i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i,j]='.' then\n f:=true;\nif not f then\n begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j]='.' then a[i,j]:='!';\n end\nelse\n for i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i,j]='.' then\n a[i,j]:='!';\nfor i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n write(a[i,j]);\n if(j=3)or(j=6)then write(' ');\n end;\n writeln;\n if(i=3)or(i=6)then writeln;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var\ts:array[1..9] of string;\n\ti,j,x,y,x1,y1,count:longint;\n\tt:string;\nbegin\n\tfor i:=1 to 8 do\n\tbegin\n\t\treadln(t);\n\t\tdelete(t,4,1);\n\t\tdelete(t,7,1);\n\t\ts[i]:=t;\n\t\tif i mod 3 = 0 then readln(t);\n\tend;\n\treadln(t);\n\tdelete(t,4,1);\n\tdelete(t,7,1);\n\ts[9]:=t;\n\treadln(x,y);\n\tx1:=(x-1) mod 3 + 1;\n\ty1:=(y-1) mod 3 + 1;\n\t\n\tcount:=0;\n\tfor i:=(x1-1)*3 + 1 to x1*3 do \n\t\tfor j:= (y1-1)*3 + 1 to y1*3 do\n\t\t\tif (s[i][j]='.')then inc(count);\n\tif count>0 then\n\tbegin\n\t\tfor i:=(x1-1)*3 + 1 to x1*3 do \n\t\t\tfor j:= (y1-1)*3 + 1 to y1*3 do\n\t\t\t\tif (s[i][j]='.') then\n\t\t\t\tbegin\n\t\t\t\t\tdelete(s[i],j,1);\n\t\t\t\t\tinsert('!',s[i],j);\n\t\t\t\tend;\n\tend\n\telse\n\tbegin\n\t\tfor i:=1 to 9 do\n\t\t\tfor j:=1 to 9 do\t\n\t\t\t\tif (s[i][j]='.') then\n\t\t\t\tbegin\n\t\t\t\t\tdelete(s[i],j,1);\n\t\t\t\t\tinsert('!',s[i],j);\n\t\t\t\tend;\n\tend;\n\tfor i:=1 to 9 do\n\tbegin\n\t\tinsert(' ',s[i],4);\n\t\tinsert(' ',s[i],8);\n\tend;\n\tfor i:=1 to 9 do\n\tbegin\n\t\twriteln(s[i]);\n\t\tif i mod 3 = 0 then writeln;\n\tend;\nend."}, {"source_code": "var \nb:array[1..9]of string;\ns:string;\ni,j,x,y,xx,yy,sc,t,tt:integer;\n\nbegin\n\n \nfor i:=1 to 11 do begin\n readln(s);\n if length(s)>0 then begin\n inc(j);\n b[j]:=s;\n delete(b[j],4,1);\n delete(b[j],7,1);\n end;\n end;\nreadln(x,y);\n \nxx:=y mod 3;\nif xx=0 then xx:=3;\nyy:=x mod 3;\nif yy=0 then yy:=3;\n\nfor i:=(xx-1)*3+1 to (xx-1)*3+3 do\n for j:=(yy-1)*3+1 to (yy-1)*3+3 do begin\n \n if b[j][i]='.' then begin\n b[j][i]:='!';\n inc(sc);\n end;\n end;\nt:=0;\nif sc<>0 then \n for i:=1 to 11 do\n if (i=4) or (i=8) then writeln() else begin\n inc(t);\n insert(' ',b[t],4);\n insert(' ',b[t],8);\n writeln(b[t])\n end\n else begin\n for i:=1 to 9 do for j:=1 to 9 do\n if b[i][j]='.' then b[i][j]:='!';\n \n \n \n for i:=1 to 11 do\n if (i=4) or (i=8) then writeln() else begin\n inc(t);\n insert(' ',b[t],4);\n insert(' ',b[t],8);\n writeln(b[t])\n end;\n end;\n\nend. "}, {"source_code": "var\n a : array[ 1..9, 1..9 ] of char;\n temp : char;\n i, j, nemp, x, y, kx, ky : longint;\nbegin\n for i := 1 to 9 do\n begin\n for j := 1 to 9 do\n begin\n read( a[ i, j ] );\n if j mod 3 = 0\n then read( temp );\n end;\n readln;\n if ( i mod 3 = 0 ) and ( i <> 9 )\n then readln;\n end;\n readln( x, y );\n while x > 3 do\n x := x - 3;\n while y > 3 do\n y := y - 3;\n kx := x - 1;\n ky := y - 1;\n for i := kx * 3 + 1 to kx * 3 + 3 do\n for j := ky * 3 + 1 to ky * 3 + 3 do\n if a[ i, j ] <> '.'\n then inc( nemp )\n else a[ i, j ] := '!';\n if nemp = 9\n then\n begin\n\n for i := 1 to 9 do\n begin\n for j := 1 to 9 do\n begin\n if a[ i, j ] <> '.'\n then write( a[ i, j ] )\n else write( '!' );\n if j mod 3 = 0\n then write( ' ' );\n end;\n writeln;\n if i mod 3 = 0\n then writeln;\n end;\n end\n else\n begin\n\n for i := 1 to 9 do\n begin\n for j := 1 to 9 do\n begin\n write( a[ i, j ] );\n if j mod 3 = 0\n then write( ' ' );\n end;\n writeln;\n if i mod 3 = 0\n then writeln;\n end;\n end;\nend."}, {"source_code": "program Crosses_Ouths_B_907;\n\n// {$H+} // FPC - long strings\n// {$M 8000000} // FPC - stack size is 8MB\n// {$M 8000000, 16000, 640000} // TP - stack size is 8MB\n\n// {$DEFINE ONLINE_JUDGE}\nprocedure DivByZero;\nvar\n I, J: Integer;\nbegin\n I := 0;\n J := 10 div I;\nend;\n\nconst\n MaxN = 3;\n MaxM = 3;\ntype\n TField = array [1..MaxN, 1..MaxN] of Char;\n TBigField = array [1..MaxM, 1..MaxM] of TField;\nvar\n BigF: TBigField;\n S: string;\n N, I, J, K, P, fI, fJ, L: Longint;\n X, Y, fX, fY: Longint;\n Check: Boolean;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Assign(Input,'Nin.txt');\n Assign(Output,'Nout.txt');\n Reset(Input);\n Rewrite(Output);\n {$ENDIF}\n FillChar(BigF, Sizeof(BigF), '.');\n for K := 1 to MaxM * MaxM do\n begin\n Readln(S);\n while length(S) = 0 do\n Readln(S);\n fI := (K - 1) div MaxM + 1;\n while pos(' ', S) <> 0 do\n delete(S, pos(' ', S), 1);\n L := Length(S);\n if L <> MaxN * MaxM then\n DivByZero;\n I := (K - 1) mod MaxN + 1;\n for P := 1 to L do\n begin\n fJ := (P - 1) div MaxM + 1;\n J := (P - 1) mod MaxN + 1;\n BigF[fI, fJ][I, J] := S[P];\n end;\n end;\n \n Read(X, Y);\n fX := (X - 1) mod MaxM + 1;\n fY := (Y - 1) mod MaxM + 1;\n Check := False;\n for I := 1 to MaxN do\n for J := 1 to MaxN do\n if BigF[fX, fY][I, J] = '.' then\n Check := True;\n if Check then\n begin\n for I := 1 to MaxN do\n for J := 1 to MaxN do\n if BigF[fX, fY][I, J] = '.' then\n BigF[fX, fY][I, J] := '!'\n end\n else\n begin\n for fI := 1 to MaxM do\n for fJ := 1 to MaxM do\n for I := 1 to MaxN do\n for J := 1 to MaxN do\n if BigF[fI, fJ][I, J] = '.' then\n BigF[fI, fJ][I, J] := '!';\n end;\n for fI := 1 to MaxM do\n begin\n for I := 1 to MaxN do\n begin\n for fJ := 1 to MaxM do\n begin\n for J := 1 to MaxN do\n Write(BigF[fI, fJ][I, J]);\n if fJ <> MaxN then\n Write(' ');\n end;\n Writeln;\n end;\n if fI <> MaxM then\n Writeln;\n end;\n\n {$IFNDEF ONLINE_JUDGE}\n Close(Input);\n Close(Output);\n {$ENDIF}\nend.\n"}, {"source_code": "//{$R-,Q-,S-,I-}\nUses math;\nConst\n fin='';\n fon='';\n\t//fin='.inp';\n\t//fon='.out';\n maxC=1000000000;\n maxN=1000+10;\n\tmodule=1000000007;\n mang:array[1..9] of longint=(1,2,3,1,2,3,1,2,3);\n\nType\n\tpnode=^tnode;\n tnode=record\n v,c:longint;\n next:pnode;\n\t\tend;\n\tre=record\n\t\tx,y:longint;\n\t\tend;\n\nVar\n fi,fo:text;\n\tn,x,y:longint;\n a:array[0..maxN,0..maxN] of char;\n\nProcedure mo;\nBegin\n Assign(fi,fin); Reset(fi);\n Assign(fo,fon); Rewrite(fo);\nEnd;\n\nProcedure dong;\nBegin\n Close(fi);\n Close(fo);\nEnd;\n\nProcedure nhap;\nVar\n\ti,j:longint;\n c:char;\nBegin\n For i:=1 to 3 do\n Begin\n For j:=1 to 3 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=4 to 6 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=7 to 9 do\n Read(fi,a[i,j]);\n Readln(fi);\n End;\n Readln(fi);\n\n For i:=4 to 6 do\n Begin\n For j:=1 to 3 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=4 to 6 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=7 to 9 do\n Read(fi,a[i,j]);\n Readln(fi);\n End;\n Readln(fi);\n\n For i:=7 to 9 do\n Begin\n For j:=1 to 3 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=4 to 6 do\n Read(fi,a[i,j]);\n Read(fi,c);\n For j:=7 to 9 do\n Read(fi,a[i,j]);\n Readln(fi);\n End;\n Readln(fi,x,y);\nEnd;\n\nProcedure xuly;\nVar\n i,j:longint;\n sua:boolean;\nBegin\n sua:=false;\n For i:=mang[x]*3 downto mang[x]*3-2 do\n For j:=mang[y]*3 downto mang[y]*3-2 do\n If a[i,j]='.' then\n Begin\n a[i,j]:='!';\n sua:=true;\n End;\n\n If not sua then\n For i:=1 to 9 do\n For j:=1 to 9 do\n If a[i,j]='.' then a[i,j]:='!';\nEnd;\n\nProcedure xuat;\nVar\n i,j:longint;\nBegin\n For i:=1 to 3 do\n Begin\n For j:=1 to 3 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=4 to 6 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=7 to 9 do\n Write(fo,a[i,j]);\n Writeln(fo);\n End;\n Writeln(fo);\n\n For i:=4 to 6 do\n Begin\n For j:=1 to 3 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=4 to 6 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=7 to 9 do\n Write(fo,a[i,j]);\n Writeln(fo);\n End;\n Writeln(fo);\n\n For i:=7 to 9 do\n Begin\n For j:=1 to 3 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=4 to 6 do\n Write(fo,a[i,j]);\n Write(fo,' ');\n For j:=7 to 9 do\n Write(fo,a[i,j]);\n Writeln(fo);\n End;\nEnd;\n\nBEGIN\n Mo;\n Nhap;\n Xuly;\n Xuat;\n Dong;\nEND."}, {"source_code": "{$coperators on}\n{$mode objfpc}\nconst\n fi='INPUT.INP';\n fo='OUTPUT.OUT';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nvar a,s:array[0..11] of string;\n x,y:longint;\nprocedure enter;\nvar i,j:longint;\nbegin\n for i:=1 to 3 do begin\n for j:=1 to 3 do\n readln(s[(i-1)*3+j]);\n if (i<>3) then\n readln;\n end;\n for i:=1 to 9 do begin\n for j:=1 to 11 do\n if s[i][j]<>#32 then\n a[i]+=s[i][j];\n end;\n readln(X,y);\nend;\nprocedure solve;\nvar bl:boolean;\n i,j:longint;\nbegin\n x:=x mod 3;\n y:=y mod 3;\n if x=0 then x:=3;\n if y=0 then y:=3;\n bl:=false;\n for i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i][j]='.' then begin\n bl:=true;\n a[i][j]:='!';\n end;\n if not bl then begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i][j]='.' then a[i][j]:='!';\n end;\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n for x:=1 to 3 do begin\n for y:=1 to 3 do\n write(a[(i-1)*3+j][(x-1)*3+y]);\n write(#32);\n end;\n writeln;\n end;\n writeln;\n end;\nend;\nbegin\n //fileio;\n enter;\n solve;\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ch:char):boolean;\nbegin\n if (ord(ch)>20)and(ord(ch)<220) then good:=true else good:=false;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=11; m:=11;\n for i:=1 to n do\n begin readln(ss);\n m:=length(ss);\n for j:=1 to m do pole[i,j]:=ss[j];\n\n end;\n read(aa,bb);\n\n { for i:=1 to n do begin for j:=1 to m do write(pole[i,j]); writeln; end;\n }\n ii:=aa+(aa-1) div 3;\n jj:=bb+(bb-1) div 3;\n\n for i:=1 to n do for j:=1 to m do pole1[i,j]:=pole[i,j];\n\n { writeln(aa,' ',bb);\n writeln(ii,' ii jj ',jj);\n }\n p1:=(aa-1) mod 3+1;\n p2:=(bb-1) mod 3+1;\n { writeln(p1,' p1,p2 ',p2);\n }flag:=false;\n for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1 do if pole[i,j]='.' then flag:=true;\n\n { writeln(flag);\n }\n if flag then\n begin\n ii:=(aa-1) mod 3+1;\n jj:=(bb-1) mod 3+1;\n\n { writeln(ii,' == ',jj);\n }\n for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do\n if pole[i,j]='.' then pole1[i,j]:='!';\n\n for i:=1 to n do begin for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;\n goto 1;\n\n\n end;\n\n if not flag then\n begin\n for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';\n for i:=1 to n do begin for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;\n goto 1;\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "const fin='';\n fout='';\nvar s:array[1..11]of string;\n x,y,i,j:longint;\nprocedure enter;\nvar i,j:longint;\nbegin\n for i:=1 to 3 do\n begin\n for j:=1 to 3 do\n begin\n readln(s[(i-1)*3+j]);\n delete(s[(i-1)*3+j],4,1);\n delete(s[(i-1)*3+j],7,1);\n end;\n if(i<3) then readln;\n end;\n readln(x,y);\nend;\nfunction chk(x,y:longint):boolean;\nvar i,j:longint;\nbegin\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n if(s[(x-1)*3+i][(y-1)*3+j]='.') then exit(true);\n end;\n exit(false);\nend;\nbegin\n assign(input,fin);reset(input);\n assign(output,fout);rewrite(output);\n enter;\n x:=x mod 3;\n if(x=0) then x:=3;\n y:=y mod 3;\n if(y=0) then y:=3;\n if(chk(x,y)) then\n begin\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n if(s[(x-1)*3+i][(y-1)*3+j]='.') then s[(x-1)*3+i][(y-1)*3+j]:='!';\n end;\n end else\n begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if(s[i][j]='.') then s[i][j]:='!';\n end;\n for i:=1 to 3 do\n begin\n for j:=1 to 3 do\n begin\n insert(' ',s[(i-1)*3+j],4);\n insert(' ',s[(i-1)*3+j],8);\n writeln(s[(i-1)*3+j]);\n end;\n writeln;\n end;\n close(input);\n close(output);\nend.\n"}, {"source_code": "var\n k, nPos, x, y : longint;\n\n sVsp,\n sNotUsed, s1, s2, s3 : string;\n\n\n arrStr : array [1..9] of string;\n\n{********************************************}\nfunction ModifyStr (inpStr : string) : string;\nvar\n tmpModifyStr : string;\nbegin\n tmpModifyStr:= inpStr;\n if (x = 1) or (x = 4) or (x = 7)\n then begin\n if tmpModifyStr [1] = '.'\n then tmpModifyStr [1]:= '!';\n if tmpModifyStr [2] = '.'\n then tmpModifyStr [2]:= '!';\n if tmpModifyStr [3] = '.'\n then tmpModifyStr [3]:= '!';\n end;\n\n if (x = 2) or (x = 5) or (x = 8)\n then begin\n if tmpModifyStr [5] = '.'\n then tmpModifyStr [5]:= '!';\n if tmpModifyStr [6] = '.'\n then tmpModifyStr [6]:= '!';\n if tmpModifyStr [7] = '.'\n then tmpModifyStr [7]:= '!';\n end;\n\n if (x = 3) or (x = 6) or (x = 9)\n then begin\n if tmpModifyStr [9] = '.'\n then tmpModifyStr [9]:= '!';\n if tmpModifyStr [10] = '.'\n then tmpModifyStr [10]:= '!';\n if tmpModifyStr [11] = '.'\n then tmpModifyStr [11]:= '!';\n end;\n ModifyStr:= tmpModifyStr;\nend;\n{********************************************}\n\n{***************************** MAIN PROGRAM *****************************}\nbegin\n readln (arrStr [1]);\n readln (arrStr [2]);\n readln (arrStr [3]);\n readln (sNotUsed);\n readln (arrStr [4]);\n readln (arrStr [5]);\n readln (arrStr [6]);\n readln (sNotUsed);\n readln (arrStr [7]);\n readln (arrStr [8]);\n readln (arrStr [9]);\n readln (y, x);\n\n if (y = 1) or (y = 4) or (y = 7)\n then begin\n s1:= arrStr [1];\n s2:= arrStr [2];\n s3:= arrStr [3];\n end;\n\n if (y = 2) or (y = 5) or (y = 8)\n then begin\n s1:= arrStr [4];\n s2:= arrStr [5];\n s3:= arrStr [6];\n end;\n\n if (y = 3) or (y = 6) or (y = 9)\n then begin\n s1:= arrStr [7];\n s2:= arrStr [8];\n s3:= arrStr [9];\n end;\n\n if (x = 1) or (x = 4) or (x = 7)\n then sVsp:= s1 [1] + s1 [2] + s1 [3] + s2 [1] + s2 [2] + s2 [3] + s3 [1] + s3 [2] + s3 [3];\n\n if (x = 2) or (x = 5) or (x = 8)\n then sVsp:= s1 [5] + s1 [6] + s1 [7] + s2 [5] + s2 [6] + s2 [7] + s3 [5] + s3 [6] + s3 [7];\n\n if (x = 3) or (x = 6) or (x = 9)\n then sVsp:= s1 [9] + s1 [10] + s1 [11] + s2 [9] + s2 [10] + s2 [11] + s3 [9] + s3 [10] + s3 [11];\n\n if (pos ('.', sVsp) = 0)\n then begin\n for k:= 1 to 9\n do begin\n for nPos:= 1 to 11\n do if (arrStr [k][nPos] = '.')\n then arrStr [k][nPos]:= '!';\n writeln (arrStr [k]);\n if (k mod 3 = 0)\n then writeln;\n end;\n Halt;\n end;\n\n if (y = 1) or (y = 4) or (y = 7)\n then begin // modify arrStr [1], arrStr [2], arrStr [3]\n arrStr [1]:= ModifyStr (arrStr [1]);\n arrStr [2]:= ModifyStr (arrStr [2]);\n arrStr [3]:= ModifyStr (arrStr [3]);\n end;\n\n if (y = 2) or (y = 5) or (y = 8)\n then begin // modify arrStr [4], arrStr [5], arrStr [6]\n arrStr [4]:= ModifyStr (arrStr [4]);\n arrStr [5]:= ModifyStr (arrStr [5]);\n arrStr [6]:= ModifyStr (arrStr [6]);\n end;\n\n if (y = 3) or (y = 6) or (y = 9)\n then begin // modify arrStr [7], arrStr [8], arrStr [9]\n arrStr [7]:= ModifyStr (arrStr [7]);\n arrStr [8]:= ModifyStr (arrStr [8]);\n arrStr [9]:= ModifyStr (arrStr [9]);\n end;\n\n for k:= 1 to 9\n do begin\n writeln (arrStr [k]);\n if (k mod 3 = 0)\n then writeln;\n end;\n\n// readln;\nend.\n"}], "negative_code": [{"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln;\n end;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln;\n end;\nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4=0 then readln else\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln(' ');\n end;\n writeln; \n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln(' ');\n end;\n writeln;\nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4=0 then readln else\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln(' ');\n end;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln(' ');\n end;\nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then \n begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln(' ');\n end;\n writeln;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln(' ');\n end;\n writeln;\nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n end;\n readln;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln;\n end;\n writeln;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln;\n end;\n writeln; \nend.\n"}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln(' ');\n end;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln(' ');\n end;\nend.\n"}, {"source_code": "var\n a: array[1..9,1..9] of char;\n f: boolean;\n ch: char;\n x, y, i, j: byte;\nbegin\n read(a[1,1]);\n read(a[2,1]);\n read(a[3,1]);\n read(ch);\n read(a[4,1]);\n read(a[5,1]);\n read(a[6,1]);\n read(ch);\n read(a[7,1]);\n read(a[8,1]);\n readln(a[9,1]);\n read(a[1,2]);\n read(a[2,2]);\n read(a[3,2]);\n read(ch);\n read(a[4,2]);\n read(a[5,2]);\n read(a[6,2]);\n read(ch);\n read(a[7,2]);\n read(a[8,2]);\n readln(a[9,2]);\n read(a[1,3]);\n read(a[2,3]);\n read(a[3,3]);\n read(ch);\n read(a[4,3]);\n read(a[5,3]);\n read(a[6,3]);\n read(ch);\n read(a[7,3]);\n read(a[8,3]);\n readln(a[9,3]);\n readln;\n read(a[1,4]);\n read(a[2,4]);\n read(a[3,4]);\n read(ch);\n read(a[4,4]);\n read(a[5,4]);\n read(a[6,4]);\n read(ch);\n read(a[7,4]);\n read(a[8,4]);\n readln(a[9,4]);\n read(a[1,5]);\n read(a[2,5]);\n read(a[3,5]);\n read(ch);\n read(a[4,5]);\n read(a[5,5]);\n read(a[6,5]);\n read(ch);\n read(a[7,5]);\n read(a[8,5]);\n readln(a[9,5]);\n read(a[1,6]);\n read(a[2,6]);\n read(a[3,6]);\n read(ch);\n read(a[4,6]);\n read(a[5,6]);\n read(a[6,6]);\n read(ch);\n read(a[7,6]);\n read(a[8,6]);\n readln(a[9,6]);\n readln;\n read(a[1,7]);\n read(a[2,7]);\n read(a[3,7]);\n read(ch);\n read(a[4,7]);\n read(a[5,7]);\n read(a[6,7]);\n read(ch);\n read(a[7,7]);\n read(a[8,7]);\n readln(a[9,7]);\n read(a[1,8]);\n read(a[2,8]);\n read(a[3,8]);\n read(ch);\n read(a[4,8]);\n read(a[5,8]);\n read(a[6,8]);\n read(ch);\n read(a[7,8]);\n read(a[8,8]);\n readln(a[9,8]);\n read(a[1,9]);\n read(a[2,9]);\n read(a[3,9]);\n read(ch);\n read(a[4,9]);\n read(a[5,9]);\n read(a[6,9]);\n read(ch);\n read(a[7,9]);\n read(a[8,9]);\n readln(a[9,9]);\n readln(x, y);\n\n f := false;\n x := ((x-1) mod 3)*3;\n y := ((y-1) mod 3)*3;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if a[x+i,y+j] = '.'then begin\n f:= true;\n a[x+i,y+j] := '!'\n end;\n if f = false then\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j] = '.' then a[i,j] := '!';\n\n write(a[1,1]);\n write(a[2,1]);\n write(a[3,1]);\n write(' ');\n write(a[4,1]);\n write(a[5,1]);\n write(a[6,1]);\n write(' ');\n write(a[7,1]);\n write(a[8,1]);\n writeln(a[9,1]);\n write(a[1,2]);\n write(a[2,2]);\n write(a[3,2]);\n write(' ');\n write(a[4,2]);\n write(a[5,2]);\n write(a[6,2]);\n write(' ');\n write(a[7,2]);\n write(a[8,2]);\n writeln(a[9,2]);\n write(a[1,3]);\n write(a[2,3]);\n write(a[3,3]);\n write(' ');\n write(a[4,3]);\n write(a[5,3]);\n write(a[6,3]);\n write(' ');\n write(a[7,3]);\n write(a[8,3]);\n writeln(a[9,3]);\n writeln;\n write(a[1,4]);\n write(a[2,4]);\n write(a[3,4]);\n write(' ');\n write(a[4,4]);\n write(a[5,4]);\n write(a[6,4]);\n write(' ');\n write(a[7,4]);\n write(a[8,4]);\n writeln(a[9,4]);\n write(a[1,5]);\n write(a[2,5]);\n write(a[3,5]);\n write(' ');\n write(a[4,5]);\n write(a[5,5]);\n write(a[6,5]);\n write(' ');\n write(a[7,5]);\n write(a[8,5]);\n writeln(a[9,5]);\n write(a[1,6]);\n write(a[2,6]);\n write(a[3,6]);\n write(' ');\n write(a[4,6]);\n write(a[5,6]);\n write(a[6,6]);\n write(' ');\n write(a[7,6]);\n write(a[8,6]);\n writeln(a[9,6]);\n writeln;\n write(a[1,7]);\n write(a[2,7]);\n write(a[3,7]);\n write(' ');\n write(a[4,7]);\n write(a[5,7]);\n write(a[6,7]);\n write(' ');\n write(a[7,7]);\n write(a[8,7]);\n writeln(a[9,7]);\n write(a[1,8]);\n write(a[2,8]);\n write(a[3,8]);\n write(' ');\n write(a[4,8]);\n write(a[5,8]);\n write(a[6,8]);\n write(' ');\n write(a[7,8]);\n write(a[8,8]);\n writeln(a[9,8]);\n write(a[1,9]);\n write(a[2,9]);\n write(a[3,9]);\n write(' ');\n write(a[4,9]);\n write(a[5,9]);\n write(a[6,9]);\n write(' ');\n write(a[7,9]);\n write(a[8,9]);\n write(a[9,9])\nend."}, {"source_code": "var\n a: array[1..9,1..9] of char;\n f: boolean;\n ch: char;\n x, y, i, j: byte;\nbegin\n read(a[1,1]);\n read(a[2,1]);\n read(a[3,1]);\n read(ch);\n read(a[4,1]);\n read(a[5,1]);\n read(a[6,1]);\n read(ch);\n read(a[7,1]);\n read(a[8,1]);\n readln(a[9,1]);\n read(a[1,2]);\n read(a[2,2]);\n read(a[3,2]);\n read(ch);\n read(a[4,2]);\n read(a[5,2]);\n read(a[6,2]);\n read(ch);\n read(a[7,2]);\n read(a[8,2]);\n readln(a[9,2]);\n read(a[1,3]);\n read(a[2,3]);\n read(a[3,3]);\n read(ch);\n read(a[4,3]);\n read(a[5,3]);\n read(a[6,3]);\n read(ch);\n read(a[7,3]);\n read(a[8,3]);\n readln(a[9,3]);\n readln;\n read(a[1,4]);\n read(a[2,4]);\n read(a[3,4]);\n read(ch);\n read(a[4,4]);\n read(a[5,4]);\n read(a[6,4]);\n read(ch);\n read(a[7,4]);\n read(a[8,4]);\n readln(a[9,4]);\n read(a[1,5]);\n read(a[2,5]);\n read(a[3,5]);\n read(ch);\n read(a[4,5]);\n read(a[5,5]);\n read(a[6,5]);\n read(ch);\n read(a[7,5]);\n read(a[8,5]);\n readln(a[9,5]);\n read(a[1,6]);\n read(a[2,6]);\n read(a[3,6]);\n read(ch);\n read(a[4,6]);\n read(a[5,6]);\n read(a[6,6]);\n read(ch);\n read(a[7,6]);\n read(a[8,6]);\n readln(a[9,6]);\n readln;\n read(a[1,7]);\n read(a[2,7]);\n read(a[3,7]);\n read(ch);\n read(a[4,7]);\n read(a[5,7]);\n read(a[6,7]);\n read(ch);\n read(a[7,7]);\n read(a[8,7]);\n readln(a[9,7]);\n read(a[1,8]);\n read(a[2,8]);\n read(a[3,8]);\n read(ch);\n read(a[4,8]);\n read(a[5,8]);\n read(a[6,8]);\n read(ch);\n read(a[7,8]);\n read(a[8,8]);\n readln(a[9,8]);\n read(a[1,9]);\n read(a[2,9]);\n read(a[3,9]);\n read(ch);\n read(a[4,9]);\n read(a[5,9]);\n read(a[6,9]);\n read(ch);\n read(a[7,9]);\n read(a[8,9]);\n readln(a[9,9]);\n readln(x, y);\n\n f := false;\n x := ((x-1) div 3)*3;\n y := ((y-1) div 3)*3;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if a[x+i,y+j] = '.'then begin\n f:= true;\n a[x+i,y+j] := '!'\n end;\n if f = false then\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j] = '.' then a[i,j] := '!';\n\n write(a[1,1]);\n write(a[2,1]);\n write(a[3,1]);\n write(' ');\n write(a[4,1]);\n write(a[5,1]);\n write(a[6,1]);\n write(' ');\n write(a[7,1]);\n write(a[8,1]);\n writeln(a[9,1]);\n write(a[1,2]);\n write(a[2,2]);\n write(a[3,2]);\n write(' ');\n write(a[4,2]);\n write(a[5,2]);\n write(a[6,2]);\n write(' ');\n write(a[7,2]);\n write(a[8,2]);\n writeln(a[9,2]);\n write(a[1,3]);\n write(a[2,3]);\n write(a[3,3]);\n write(' ');\n write(a[4,3]);\n write(a[5,3]);\n write(a[6,3]);\n write(' ');\n write(a[7,3]);\n write(a[8,3]);\n writeln(a[9,3]);\n writeln;\n write(a[1,4]);\n write(a[2,4]);\n write(a[3,4]);\n write(' ');\n write(a[4,4]);\n write(a[5,4]);\n write(a[6,4]);\n write(' ');\n write(a[7,4]);\n write(a[8,4]);\n writeln(a[9,4]);\n write(a[1,5]);\n write(a[2,5]);\n write(a[3,5]);\n write(' ');\n write(a[4,5]);\n write(a[5,5]);\n write(a[6,5]);\n write(' ');\n write(a[7,5]);\n write(a[8,5]);\n writeln(a[9,5]);\n write(a[1,6]);\n write(a[2,6]);\n write(a[3,6]);\n write(' ');\n write(a[4,6]);\n write(a[5,6]);\n write(a[6,6]);\n write(' ');\n write(a[7,6]);\n write(a[8,6]);\n writeln(a[9,6]);\n writeln;\n write(a[1,7]);\n write(a[2,7]);\n write(a[3,7]);\n write(' ');\n write(a[4,7]);\n write(a[5,7]);\n write(a[6,7]);\n write(' ');\n write(a[7,7]);\n write(a[8,7]);\n writeln(a[9,7]);\n write(a[1,8]);\n write(a[2,8]);\n write(a[3,8]);\n write(' ');\n write(a[4,8]);\n write(a[5,8]);\n write(a[6,8]);\n write(' ');\n write(a[7,8]);\n write(a[8,8]);\n writeln(a[9,8]);\n write(a[1,9]);\n write(a[2,9]);\n write(a[3,9]);\n write(' ');\n write(a[4,9]);\n write(a[5,9]);\n write(a[6,9]);\n write(' ');\n write(a[7,9]);\n write(a[8,9]);\n write(a[9,9])\nend."}, {"source_code": "var a: array [1..11,1..11] of char;\n x,y,i,j,n,m,k: byte;\nbegin\n n:=0; m:=0; k:=0;\n for i:=1 to 11 do begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n read(x,y);\n if x<4 then n:=1; if x>6 then n:=9; if n=0 then n:=5;\n if y<4 then m:=1; if y>6 then m:=9; if m=0 then m:=5;\n for i:=y to y+2 do\n for j:=x to x+2 do\n if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;\n if k=0 then\n for i:=1 to 11 do\n for j:=1 to 11 do\n if a[i,j]='.' then a[i,j]:='!';\n end."}, {"source_code": "var a: array [1..11,1..11] of char;\n x,y,i,j,n,m,k: byte;\nbegin\n n:=0; m:=0; k:=0;\n for i:=1 to 11 do begin\n for j:=1 to 11 do\n read(a[i,j]);\n readln;\n end;\n read(x,y);\n if x<4 then n:=1; if x>6 then n:=9; if n=0 then n:=5;\n if y<4 then m:=1; if y>6 then m:=9; if m=0 then m:=5;\n for i:=y to y+3 do\n for j:=x to x+3 do\n if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;\n if k=0 then\n for i:=1 to 11 do\n for j:=1 to 11 do\n if a[i,j]='.' then a[i,j]:='!';\n end."}, {"source_code": "program qq;\nvar a: array [1..9,1..9] of char;\nc: char;\nx,y,j,m,p:integer;\nbegin\nj:=1;\nwhile j<=9 do begin\n m:=1;\nwhile m<=9 do begin\nread (c);\nif (c='.') or (c='x') or (c='o') then begin a[j,m]:=c; m:=m+1; end;\nend; \nj:=j+1 end; \nread (x,y);\nj:= 3*(x mod 3)-2; m:= 3*(y mod 3) - 2;\nif j=-2 then j:=7; if m=-2 then m:=7; p:=0;\nfor i:integer:=j to j+2 do\nfor n:integer:=m to m+2 do\nif a[i,n]='.' then begin p:=1; a[i,n]:='!'; end;\nif p=0 then\nfor i:integer:=1 to 9 do\nfor n:integer:=1 to 9 do if a[i,n]='.' then a[i,n]:='!';\nfor i:integer:=1 to 9 do begin\nwriteln ();\nif i=4 then writeln (); if i=7 then writeln ();\nfor n:integer:=1 to 9 do begin\nif n=4 then write (' '); if n=7 then write (' ');\nwrite (a[i,n]);\nend;\nend;\nend."}, {"source_code": "var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;\n begin\n for i:=1 to 9 do \n begin\n readln(s);\n for l:=1 to 11 do\n begin\n if (l=4) or (l=8) then continue;\n if (l>4) and (l<8) then u:=l-1;\n if (l>8) then u:=l-2;\n if (l<4) then u:=l;\n a[i, u]:=s[l];\n end;\n if (i<9) and (i mod 3 = 0 ) then readln(s);\n end;\n read(x,y);\n if a[x,y]='o' then chir:='x' else chir:='o';\n flag:=true;\n if x mod 3 = 0 then\n line:=3;\n if x mod 3 = 2 then \n line:=2;\n if x mod 3 = 1 then\n line:=1;\n if y mod 3 = 0 then\n col:=3;\n if y mod 3 = 2 then \n col:=2;\n if y mod 3 = 1 then\n col:=1;\n for i:=line*3-2 to line*3 do\n for j:=col*3-2 to col*3 do\n if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;\n if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';\n for i:=1 to 9 do \n begin\n for j:=1 to 3 do\n begin\n for l:=j*3-2 to j*3 do write(a[i, l], ' ');\n end;\n writeln;\n if (i<9) and (i mod 3 = 0 ) then writeln;\n end;\n \n \n \n end."}, {"source_code": "var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;\n begin\n for i:=1 to 9 do \n begin\n readln(s);\n for l:=1 to 11 do\n begin\n if (l=4) or (l=8) then continue;\n if (l>4) and (l<8) then u:=l-1;\n if (l>8) then u:=l-2;\n if (l<4) then u:=l;\n a[i, u]:=s[l];\n end;\n if (i<9) and (i mod 3 = 0 ) then readln(s);\n end;\n read(x,y);\n if a[x,y]='o' then chir:='x' else chir:='o';\n flag:=true;\n if x mod 3 = 0 then\n line:=3;\n if x mod 3 = 2 then \n line:=2;\n if x mod 3 = 1 then\n line:=1;\n if y mod 3 = 0 then\n col:=3;\n if y mod 3 = 2 then \n col:=2;\n if y mod 3 = 1 then\n col:=1;\n for i:=line*3-2 to line*3 do\n for j:=col*3-2 to col*3 do\n if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;\n if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';\n for i:=1 to 9 do \n begin\n for j:=1 to 3 do\n begin\n for l:=j*3-2 to j*3 do write(a[i, l], ' ');\n end;\n writeln;\n \n end;\n \n \n \n end."}, {"source_code": "Program CodeF_454_B;\nvar x,y,i,j,i1,j1,n:longint;\n m:array[1..1]of longint;\n //reb:array[1..1]of array[1..2]of longint;\n p:array[0..8]of array[0..8]of longint;\n s:string;\n mogu:boolean;\n \n \nbegin\ni1:=-1;\nfor i:=1 to 11 do\n begin\n readln(s);\n if length(s)=11 then\n begin\n inc(i1);\n j1:=-1;\n for j:=1 to 11 do\n begin\n if s[j]<>' ' then inc(j1);\n if s[j]='o' then\n begin\n p[i1][j1]:=1;\n end;\n if s[j]='x' then\n begin\n p[i1][j1]:=2;\n end; \n end;\n end; \n end;\nread(x, y);\nx:=(x-1) mod 3;\ny:=(y-1) mod 3;\nmogu:=false;\nfor i:=0 to 8 do\n for j:=0 to 8 do\n if (i div 3=x) and (j div 3=y) then\n begin\n if p[i][j]=0 then\n mogu:=true;\n end;\n\nif mogu=true then\n for i:=0 to 8 do\n for j:=0 to 8 do\n begin\n if p[i][j]=0 then\n if (i div 3=x) and (j div 3=y) then\n p[i][j]:=3;\n end else\n begin\n for i:=0 to 8 do\n for j:=0 to 8 do\n if p[i][j]=0 then\n p[i][j]:=3;\n end;\n\nfor i:=0 to 8 do\n begin\n writeln;\n if (i mod 3=0) and (i<>0) then\n writeln;\n for j:=0 to 8 do\n begin\n if (j mod 3=0) and (j<>0) then\n write(' ');\n if p[i][j]=0 then write('.'); \n if p[i][j]=1 then write('o');\n if p[i][j]=2 then write('x');\n if p[i][j]=3 then write('!');\n end;\n \n \n end;\n\n\nend."}, {"source_code": "Program CodeF_454_B;\nvar x,y,i,j,i1,j1,n:longint;\n m:array[1..1]of longint;\n //reb:array[1..1]of array[1..2]of longint;\n p:array[0..8]of array[0..8]of longint;\n s:string;\n mogu:boolean;\n \n \nbegin\ni1:=-1;\nfor i:=1 to 11 do\n begin\n readln(s);\n if length(s)=11 then\n begin\n inc(i1);\n j1:=-1;\n for j:=1 to 11 do\n begin\n if s[j]<>' ' then inc(j1);\n if s[j]='o' then\n begin\n p[i1][j1]:=1;\n end;\n if s[j]='x' then\n begin\n p[i1][j1]:=2;\n end; \n end;\n end; \n end;\nread(x, y);\nx:=(x-1) mod 3;\ny:=(y-1) mod 3;\nmogu:=false;\nfor i:=0 to 8 do\n for j:=0 to 8 do\n if (i div 3=x) and (j div 3=y) then\n begin\n if p[i][j]=0 then\n mogu:=true;\n end;\n\nif mogu=true then\n for i:=0 to 8 do\n for j:=0 to 8 do\n begin\n if p[i][j]=0 then\n if (i div 3=x) and (j div 3=y) then\n p[i][j]:=3;\n end else\n begin\n for i:=0 to 8 do\n for j:=0 to 8 do\n if p[i][j]=0 then\n p[i][j]:=3;\n end;\n\nfor i:=0 to 8 do\n begin\n writeln;\n if (i mod 3=0) and (i<>0) then\n writeln;\n for j:=0 to 8 do\n begin\n if (j mod 3=0) and (j<>0) then\n write(' ');\n if p[i][j]=0 then write('.'); \n if p[i][j]=1 then write('o');\n if p[i][j]=2 then write('x');\n if p[i][j]=3 then write('!');\n end;\nwriteln; \n \n end;\n\n\nend."}, {"source_code": "var\n big: array[1..9, 1..9] of integer;\n strs: array[1..9] of string;\n k, num, x, y, i, j, x1, x2, y1, y2: integer;\n ch: char;\n s: string;\n\nbegin\n \n \n for i := 1 to 9 do \n begin\n \n k := -1; j := 1;\n while (j <= 9) do\n begin\n read(ch);\n if (ch = 'x') then k := 1;\n if(ch = 'o') then k := 2;\n if(ch = '.') then k := 0;\n if(k >= 0) then\n begin\n big[i, j] := k;\n inc(j);\n end;\n k := -1;\n end;\n \n end;\n read(y, x);\n \n x := x mod 3;\n y := y mod 3;\n if(x = 1) then \n begin\n x1 := 1;\n x2 := 3;\n end else\n if(x = 2) then \n begin\n x1 := 4;\n x2 := 6;\n end else\n begin\n x1 := 7;\n x2 := 9;\n end;\n if(y = 1) then \n begin\n y1 := 1;\n y2 := 3;\n end else\n if(y = 2) then \n begin\n y1 := 4;\n y2 := 6;\n end else\n begin\n y1 := 7;\n y2 := 9;\n end;\n num := 0;\n for i := y1 to y2 do\n for j := x1 to x2 do\n begin\n if(big[i, j] = 0) then \n inc(num);\n end;\n \n if(num = 0) then begin\n x1 := 1;\n x2 := 9;\n y1 := 1;\n y2 := 9;\n end;\n for i := 1 to 9 do\n begin\n s := '';\n for j := 1 to 9 do\n begin\n if(big[i, j] = 1) then \n s += 'x';\n if(big[i, j] = 2) then s += 'o';\n if(big[i, j] = 0) then\n begin\n if(i <= y2 ) and (i >= y1) and (j <= x2) and (j >= x1) then\n s += '!' else s += '.';\n end;\n if(j mod 3 = 0) then s += ' ';\n \n end;\n writeln(s);\n end;\n \n \nend."}, {"source_code": "var\n a: array [1..11, 1..11] of char;\n i, j, n, m, k: integer;\n isNotFull: boolean;\n\nbegin\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n readln();\n continue;\n end;\n for j := 1 to 11 do read(a[i, j]);\n readln();\n end;\n read(n, m);\n isNotFull := false;\n if (n >= 4) and (n <= 6) then n += 1;\n if (m >= 4) and (m <= 6) then m += 1;\n if (n >= 8) and (n <= 9) then n += 2;\n if (m >= 8) and (m <= 9) then m += 2;\n if (n = 1) or (n = 5) or (n = 9) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 2) or (n = 6) or (n = 10) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 3) or (n = 7) or (n = 11) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if isNotFull = false then for i := 1 to 11 do \n for j := 1 to 11 do \n if a[i, j] = '.' then a[i, j] := '!';\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n writeln();\n continue;\n end;\n for j := 1 to 11 do write(a[i, j]);\n writeln();\n end;\nend."}, {"source_code": "var\n a: array [1..11, 1..11] of char;\n i, j, n, m, k: integer;\n isNotFull: boolean;\n\nbegin\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n readln();\n continue;\n end;\n for j := 1 to 11 do read(a[i, j]);\n readln();\n end;\n read(n, m);\n isNotFull := false;\n if (n >= 4) and (n <= 6) then n += 1;\n if (m >= 4) and (m <= 6) then m += 1;\n if (n >= 7) and (n <= 9) then n += 2;\n if (m >= 7) and (m <= 9) then m += 2;\n if (n = 1) or (n = 5) or (n = 9) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 1 to 3 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 2) or (n = 6) or (n = 10) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 5 to 7 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if (n = 3) or (n = 7) or (n = 11) then begin\n if (m = 1) or (m = 5) or (m = 9) then begin\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 1 to 3 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 2) or (m = 6) or (m = 10) then begin\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 5 to 7 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n if (m = 3) or (m = 7) or (m = 11) then begin\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then isNotFull := true;\n if isNotFull = true then\n for i := 9 to 11 do\n for j := 9 to 11 do\n if a[i, j] = '.' then a[i, j] := '!';\n end;\n end;\n if isNotFull = false then for i := 1 to 11 do \n for j := 1 to 11 do \n if a[i, j] = '.' then a[i, j] := '!';\n for i := 1 to 11 do \n begin\n if (i = 4) or (i = 8) then begin\n writeln();\n continue;\n end;\n for j := 1 to 11 do write(a[i, j]);\n writeln();\n end;\nend."}, {"source_code": "var i,j,xx,yy,x:longint;c:char;f:boolean;\na,b:array[0..1000,0..1000]of char;\nprocedure p(x:longint);\nvar i:longint;\nbegin\nfor i:=1 to 3 do\n if a[x,i]='.' then write('!')\n else write(a[x,i]);\nwrite(' ');\nfor i:=4 to 6 do\n if a[x,i]='.' then write('!')\n else write(a[x,i]);\nwrite(' ');\nfor i:=7 to 9 do\n if a[x,i]='.' then write('!')\n else write(a[x,i]);\nif(x=3)or(x=6)then writeln;\nif x<>9 then writeln;\nend;\nprocedure pp(x:longint);\nvar i:longint;\nbegin\nfor i:=1 to 3 do write(a[x,i]);\nwrite(' ');for i:=4 to 6 do write(a[x,i]);\nwrite(' ');for i:=7 to 9 do write(a[x,i]);\nwrite(' ');\nif(x=3)or(x=6)then writeln;\nif x<>9 then writeln;\nend;\nbegin\n//assign(input,'tictactoe.in');reset(input);\n//assign(output,'tictactoe.out');rewrite(output);\nfor i:=1 to 11 do\n begin\n if(i<>4)and(i<>8)then\n begin\n inc(x);for j:=1 to 3 do read(a[x,j]);\n read(c);for j:=4 to 6 do read(a[x,j]);\n read(c);for j:=7 to 9 do read(a[x,j]);\n end;readln;\n end;\nreadln(xx,yy);xx:=(xx-1)mod 3+1;yy:=(yy-1)mod 3+1;\nf:=true;\nfor i:=(xx-1)*3+1 to xx*3 do\n for j:=(yy-1)*3+1 to yy*3 do\n if a[i,j]<>'.' then f:=false;\nif not f then\n begin\n for i:=1 to 9 do p(i);\n end\nelse\n begin\n for i:=(xx-1)*3+1 to xx*3 do\n for j:=(yy-1)*3+1 to yy*3 do\n a[i,j]:='!';\n for i:=1 to 9 do pp(i);\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var a:array[0..1000]of string;\nx,y,i,j:longint;f:boolean;\nbegin\n//assign(input,'tictactoe.in');reset(input);\n//assign(output,'tictactoe.out');rewrite(output);\nfor I:=1 to 9 do\n begin\n if(i=4)or(i=7)then readln(a[i]);\n readln(a[i]);\n delete(a[i],8,1);\n delete(a[i],4,1);\n end;\nread(x,y);\nx:=(x-1)mod 3+1;\ny:=(y-1)mod 3+1;\nf:=true;\nfor i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i,j]<>'.' then\n f:=false;\nif not f then\n begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i,j]='.' then a[i,j]:='!';\n end\nelse\n for i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i,j]='.' then\n a[i,j]:='!';\nfor i:=1 to 9 do\n begin\n for j:=1 to 9 do\n begin\n write(a[i,j]);\n if(j=3)or(j=6)then write(' ');\n end;\n writeln;\n if(i=3)or(i=6)then writeln;\n end;\nclose(input);close(output);\nend."}, {"source_code": "{$coperators on}\n{$mode objfpc}\nconst\n fi='INPUT.INP';\n fo='OUTPUT.OUT';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nvar a,s:array[0..11] of string;\n x,y:longint;\nprocedure enter;\nvar i,j:longint;\nbegin\n for i:=1 to 3 do begin\n for j:=1 to 3 do\n readln(s[(i-1)*3+j]);\n if (i<>3) then\n readln;\n end;\n for i:=1 to 9 do begin\n for j:=1 to 11 do\n if s[i][j]<>#32 then\n a[i]+=s[i][j];\n end;\n readln(X,y);\nend;\nprocedure solve;\nvar bl:boolean;\n i,j:longint;\nbegin\n x:=x mod 3;\n y:=y mod 3;\n if x=0 then x:=3;\n if y=0 then y:=3;\n bl:=false;\n for i:=(x-1)*3+1 to x*3 do\n for j:=(y-1)*3+1 to y*3 do\n if a[i][j]='.' then begin\n bl:=true;\n a[i][j]:='!';\n end;\n if not bl then begin\n for i:=1 to 9 do\n for j:=1 to 9 do\n if a[i][j]='.' then a[i][j]:='!';\n end;\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n for x:=1 to 3 do begin\n for y:=1 to 3 do\n write(a[(i-1)*3+j][(x-1)*3+y]);\n write(#32);\n end;\n writeln;\n end;\n end;\nend;\nbegin\n //fileio;\n enter;\n solve;\nend."}, {"source_code": "var i,j,x,y,z,c:longint;\n a:array[0..20,0..20]of char;\n now:array[0..20,0..20]of longint;\n ch:char;\n can:boolean;\nbegin\n for i:=1 to 11 do\n begin\n if i mod 4<>0 then\n begin\n for j:=1 to 11 do\n read(a[i,j]);\n end;\n readln;\n end;\n readln(x,y);\n if x>6 then inc(x,2) else\n if x>3 then inc(x,1);\n if y>6 then inc(y,2) else\n if y>3 then inc(y,1);\n for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do\n begin\n for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do\n if a[i,j]='.' then\n begin\n can:=true;\n a[i,j]:='!';\n end;\n end;\n if not can then\n begin\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n if a[i,j]='.' then write('!') else\n write(a[i,j]);\n writeln;\n end;\n exit;\n end;\n for i:=1 to 11 do\n begin\n for j:=1 to 11 do\n write(a[i,j]);\n writeln;\n end;\nend.\n"}, {"source_code": "var \nb:array[1..9]of string;\ns:string;\ni,j,x,y,xx,yy,sc,t,tt:integer;\nbegin\nfor i:=1 to 11 do begin\n readln(s);\n if length(s)>0 then begin\n inc(j);\n b[j]:=s;\n delete(b[j],4,1);\n delete(b[j],7,1);\n end;\n end;\nreadln(x,y);\nxx:=y mod 3;\nif xx=0 then xx:=3;\nyy:=x mod 3;\nif yy=0 then yy:=3;\n\nfor i:=(xx-1)*3+1 to (xx-1)*3+3 do\n for j:=(yy-1)*3+1 to (yy-1)*3+3 do begin\n \n if b[j][i]='.' then begin\n b[j][i]:='!';\n inc(sc);\n end;\n end;\nif sc<>0 then \n for i:=1 to 9 do\n writeln(b[i])\n else begin\n for i:=1 to 9 do for j:=1 to 9 do\n if b[i][j]='.' then b[i][j]:='!';\n \n for i:=1 to 9 do\n writeln(b[i])\n end;\n\n\nend. "}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=11; m:=11;\n for i:=1 to n do\n begin readln(ss);\n m:=length(ss);\n for j:=1 to m do pole[i,j]:=ss[j];\n\n end;\n read(aa,bb);\n\n { for i:=1 to n do begin for j:=1 to m do write(pole[i,j]); writeln; end;\n }\n ii:=aa+(aa-1) div 3;\n jj:=bb+(bb-1) div 3;\n\n for i:=1 to n do for j:=1 to m do pole1[i,j]:=pole[i,j];\n\n { writeln(aa,' ',bb);\n writeln(ii,' ii jj ',jj);\n }\n p1:=(aa-1) mod 3+1;\n p2:=(bb-1) mod 3+1;\n { writeln(p1,' p1,p2 ',p2);\n }flag:=false;\n for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1 do if pole[i,j]='.' then flag:=true;\n\n { writeln(flag);\n }\n inc(m);\n if flag then\n begin\n ii:=(aa-1) mod 3+1;\n jj:=(bb-1) mod 3+1;\n\n { writeln(ii,' == ',jj);\n }\n for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do\n if pole[i,j]='.' then pole1[i,j]:='!';\n\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n if not flag then\n begin\n for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ch:char):boolean;\nbegin\n if (ord(ch)>20)and(ord(ch)<120) then good:=true else good:=false;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=11; m:=11;\n for i:=1 to n do\n begin readln(ss);\n m:=length(ss);\n for j:=1 to m do pole[i,j]:=ss[j];\n\n end;\n read(aa,bb);\n\n { for i:=1 to n do begin for j:=1 to m do write(pole[i,j]); writeln; end;\n }\n ii:=aa+(aa-1) div 3;\n jj:=bb+(bb-1) div 3;\n\n for i:=1 to n do for j:=1 to m do pole1[i,j]:=pole[i,j];\n\n { writeln(aa,' ',bb);\n writeln(ii,' ii jj ',jj);\n }\n p1:=(aa-1) mod 3+1;\n p2:=(bb-1) mod 3+1;\n { writeln(p1,' p1,p2 ',p2);\n }flag:=false;\n for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1 do if pole[i,j]='.' then flag:=true;\n\n { writeln(flag);\n }\n if flag then\n begin\n ii:=(aa-1) mod 3+1;\n jj:=(bb-1) mod 3+1;\n\n { writeln(ii,' == ',jj);\n }\n for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do\n if pole[i,j]='.' then pole1[i,j]:='!';\n\n for i:=1 to n do begin for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;\n goto 1;\n\n\n end;\n\n if not flag then\n begin\n for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';\n for i:=1 to n do begin for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;\n goto 1;\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=11; m:=11;\n for i:=1 to n do\n begin readln(ss);\n m:=length(ss);\n for j:=1 to m do pole[i,j]:=ss[j];\n\n end;\n read(aa,bb);\n\n { for i:=1 to n do begin for j:=1 to m do write(pole[i,j]); writeln; end;\n }\n ii:=aa+(aa-1) div 3;\n jj:=bb+(bb-1) div 3;\n\n for i:=1 to n do for j:=1 to m do pole1[i,j]:=pole[i,j];\n\n { writeln(aa,' ',bb);\n writeln(ii,' ii jj ',jj);\n }\n p1:=(aa-1) mod 3+1;\n p2:=(bb-1) mod 3+1;\n { writeln(p1,' p1,p2 ',p2);\n }flag:=false;\n for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1 do if pole[i,j]='.' then flag:=true;\n\n { writeln(flag);\n }\n if flag then\n begin\n ii:=(aa-1) mod 3+1;\n jj:=(bb-1) mod 3+1;\n\n { writeln(ii,' == ',jj);\n }\n for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do\n if pole[i,j]='.' then pole1[i,j]:='!';\n\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n if not flag then\n begin\n for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=11; m:=11;\n for i:=1 to n do\n begin readln(ss);\n m:=length(ss);\n for j:=1 to m do pole[i,j]:=ss[j];\n\n end;\n read(aa,bb);\n\n { for i:=1 to n do begin for j:=1 to m do write(pole[i,j]); writeln; end;\n }\n ii:=aa+(aa-1) div 3;\n jj:=bb+(bb-1) div 3;\n\n for i:=1 to n do for j:=1 to m do pole1[i,j]:=pole[i,j];\n\n { writeln(aa,' ',bb);\n writeln(ii,' ii jj ',jj);\n }\n p1:=(aa-1) mod 3+1;\n p2:=(bb-1) mod 3+1;\n { writeln(p1,' p1,p2 ',p2);\n }flag:=false;\n for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1 do if pole[i,j]='.' then flag:=true;\n\n { writeln(flag);\n }\n inc(n);inc(m);\n if flag then\n begin\n ii:=(aa-1) mod 3+1;\n jj:=(bb-1) mod 3+1;\n\n { writeln(ii,' == ',jj);\n }\n for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do\n if pole[i,j]='.' then pole1[i,j]:='!';\n\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n if not flag then\n begin\n for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';\n for i:=1 to n do begin for j:=1 to m do write(pole1[i,j]); writeln; end;\n goto 1;\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}], "src_uid": "8f0fad22f629332868c39969492264d3"} {"source_code": "var\n a, b, c, d, i, j: int64;\n \nfunction check(a: int64): boolean;\nvar\n i: int64;\n \nbegin\n i := 2;\n while i * i <= a do begin\n if a mod i = 0 then begin\n check := false;\n exit;\n end;\n inc(i);\n end;\n check := true;\nend;\n \nbegin\n readln(a);\n i := a;\n while i > 0 do begin\n j := 2;\n while j * j <= a do begin\n if i mod j = 0 then break;\n inc(j);\n end;\n if (i mod j <> 0) and (a - i <> 2) then break;\n dec(i);\n end;\n if i = a then begin\n writeln(1);\n writeln(i);\n halt();\n end;\n writeln(3);\n write(i, ' ');\n a := a - i;\n i := 2;\n while i <= a do begin\n j := a - i;\n if (check(i)) and (check(j)) and (j > 0) then begin\n writeln(i, ' ', j);\n halt();\n end;\n inc(i);\n end;\nend.", "positive_code": [{"source_code": "const\n tfi='324D.inp';\n tfo='324D.out';\nvar\n p:array[1..300] of boolean;\n n:longint;\nprocedure inp;\n begin\n read(n);\n end;\nfunction check(x:longint):boolean;\n var\n i:longint;\n begin\n if x<=0 then exit(false);\n if x=1 then exit(false);\n for i:= 2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\n end;\nprocedure process;\n var\n i,j:longint;\n begin\n for i:= 1 to 300 do\n if check(i) then p[i]:=true;\n if check(n) then\n begin\n writeln(1);\n writeln(n);\n exit;\n end;\n for i:= 2 to 300 do\n for j:= 2 to 300 do\n if check(n-i-j) and p[i] and p[j] then\n begin\n writeln(3);\n write(i,' ',j,' ',n-i-j);\n exit;\n end;\n end;\nbegin\n// assign(input,tfi);reset(input);\n // assign(output,tfo);rewrite(output);\n inp;\n process;\n close(input);close(output);\nend.\n"}, {"source_code": "var\nn,i:longint;\nfunction rex(a:longint):boolean;\nvar\ni:longint;\nbegin\nif(a=1) then begin rex:=false; exit; end;\nfor i:=2 to round(sqrt(a)) do if(a mod i=0) then begin rex:=false; exit; end;\nrex:=true;\nend;\nbegin\nreadln(n);\nif(n=3) then begin writeln(1); writeln(3); halt; end;\nif(n=5) then begin writeln(1); writeln(5); halt; end;\nfor i:=1 to n do\nbegin\nif(rex(i)) and (rex((n-i) div 2)) and ((n-i) mod 2=0)\nthen begin writeln(3); write(i,' ',(n-i) div 2,' ',(n-i) div 2); exit; end;\n\nend;\nend."}, {"source_code": "const\n maxn=1000000000;\nvar\n p:array[1..3401]of word;\n s:array[2..3]of longint;\n primes,t,u,n,i,d:longint;\n found:boolean;\nfunction prime(x:longint):boolean;\n var\n i:word;\n begin\n prime:=true;\n for i:=1 to primes do begin\n if sqr(p[i])>x then exit;\n if x mod p[i]=0 then begin prime:=false;exit;end;\n end;\n end;\nprocedure search(l,x,y:longint);\n var\n i:word;\n begin\n if l>1 then\n for i:=y to primes do begin\n if p[i]*l>x then exit;\n s[l]:=i;\n search(l-1,x-p[i],i);\n if found then exit;\n end\n else if prime(x) then begin\n writeln(d);\n for i:=d downto 2 do\n write(p[s[i]],' ');\n writeln(x);\n found:=true;\n end;\n end;\nbegin\n for i:=2 to trunc(sqrt(maxn)) do\n if prime(i) then begin\n inc(primes);p[primes]:=i;\n end;\n \n read(n);d:=0;found:=false;\n repeat\n inc(d);search(d,n,1);\n until found;\n\nend.\n"}, {"source_code": "var\n i,j,n,m,k,t,x:longint;\n f:array[0..1111]of boolean;\nbegin\n readln(n);\n for i:=n downto 2 do\n begin\n k:=0;\n for j:=2 to trunc(sqrt(i))do if i mod j=0 then begin k:=1;break;end;\n if k=0 then begin x:=i;dec(n,i);break;end;\n end;\n if n=0 then begin writeln(1);writeln(x);halt;end;\n f[1]:=true;\n for i:=2 to n do if not f[i] then\n begin\n j:=i*i;\n while j<=n do\n begin\n f[j]:=true;\n inc(j,i);\n end;\n end;\n if not f[n] then begin writeln(2);writeln(x,' ',n);halt;end;\n for i:=2 to n-2 do if(not f[i])and(not f[n-i])then\n begin\n writeln(3);writeln(x,' ',i,' ',n-i);halt;\n end;\nend.\n"}, {"source_code": "Const fi='';\n fo='';\nvar n,i,j,o:Longint;\na,snt:array[1..1000] Of Longint;\nProcedure DocFile;\nvar f:Text;\nbegin\n Assign(f,fi);ReseT(f);\n Read(f,n);\n Close(F);\nend;\nProcedure Sang;\nbegin\n o:=0;\n for i:=2 to 1000 do a[i]:=i;for i:=2 to 1000 do\n begin\n if a[i]<>0 then\n begin\n j:=2*i;\n while j<=1000 do\n begin\n if (j mod a[i] = 0) then a[j]:=0;\n j:=j+i;\n end;\n end;\n end;\n for i:=2 to 1000 do\n if a[i]<>0 then\n begin\n Inc(o);\n snt[o]:=a[i];\n end;\nend;\nFunction KT(x:Longint):Boolean;\nvar k:Longint;\nbegin\n for k:=2 to Trunc(Sqrt(x)) do\n if (x Mod k=0) then Exit(False);\n Exit(True);\nend;\nProcedure GhiFile;\nvar f:Text;\nProcedure Xuly;\nbegin\n if Kt(n)=True then\n begin\n Writeln(f,1);Write(f,n);\n exit;\n end;\n for i:=1 to o do\n begin\n for j:=1 to o do\n begin\n if snt[i]+snt[j]=n then\n begin\n Writeln(f,2);Write(f,snt[i],#32,snt[j]); //246351\n exit;\n end;\n if (n-snt[i]-snt[j])>0 then\n begin\n if Kt(n-snt[i]-snt[j])=True then\n begin\n Writeln(f,3);Write(f,snt[i],#32,snt[j],#32,n-snt[i]-snt[j]);\n exit;\n end;\n end;\n end;\n end;\nend;\nbegin\n Assign(f,fo);Rewrite(f);\n Sang;\n Xuly;\n Close(F);\nend;\nbegin\n DocFile;\n GhiFile;\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar n,lc:longint;\n a:array[1..3] of longint;\nprocedure nhap;\nvar f:Text;\nbegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nend;\nfunction ktnt(x:longint):boolean;\nvar i:longint;\nbegin\n if x=1 then\n exit(false);\n ktnt:=true;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n exit(false);\nend;\nprocedure find;\nvar i,j:longint;\nbegin\n lc:=0;\n for i:=n downto 2 do\n if ktnt(i)=true then\n begin\n inc(lc);\n a[lc]:=i;\n if n-a[lc]=0 then\n exit;\n break;\n end;\n if lc>0 then\n n:=n-a[lc];\n for i:=0 to n do\n for j:=0 to n do\n if (i+j=n) and (ktnt(i)=true) and (ktnt(j)=true) then\n begin\n if i<>0 then\n begin\n inc(lc);\n a[lc]:=i;\n end;\n if j<>0 then\n begin\n inc(lc);\n a[lc]:=j;\n end;\n exit;\n end;\nend;\nprocedure xuat;\nvar f:Text;\n i:longint;\nbegin\n assign(f,fout); rewrite(f);\n writeln(f,lc);\n for i:=lc downto 1 do\n write(f,a[i],' ');\n close(f);\nend;\nbegin\n nhap;\n find;\n xuat;\nend."}, {"source_code": "Const Fi='';\n Fo='';\n maxN=50000;\nFunction Check(k:Longint):Boolean;\nVar i:Longint;\n Begin\n If k=1 then Exit(False);\n For i:=2 to Trunc(Sqrt(k)) do\n If k mod i=0 then Exit(False);\n Exit(True);\n End;\nProcedure Enter;\nVar n,i:Longint;\n Begin\n Readln(n);\n If Check(n) then\n Begin\n Writeln(1);\n Writeln(n);\n Exit;\n End;\n If Check(n-2) then\n Begin\n Writeln(2);\n Writeln(2,' ',n-2);\n Exit;\n End;\n For i:=3 to maxN do\n If Odd(i) and Check(i) and Check((n-i) Div 2) then\n Begin\n Writeln(3);\n Writeln(i,' ',(n-i) Div 2,' ',(n-i) Div 2);\n Exit;\n End;\n End;\nBegin\n Assign(Input,Fi);Reset(Input);\n Assign(Output,Fo);Rewrite(Output);\n Enter;\n Close(Input);Close(Output);\nEnd."}, {"source_code": "var n,m,i,k,j,ans,lik,ii,jj,ans1:longint;\nbegin\nreadln(n);\nfor i:=n downto n-300 do\nbegin\nm:=i;\nans:=0;\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans) else\nif (m mod j=0) then inc(ans,2);\nif (ans=2) then begin lik:=i;break;end;\nend;\n\nif (lik=n) then begin writeln(1);writeln(n);halt;end;\n\nfor ii:=2 to 300 do\nfor jj:=2 to 300 do\nbegin\nm:=ii;\nans:=0;\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans) else\nif (m mod j=0) then inc(ans,2);\nm:=jj;\nans1:=0;\n\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans1) else\nif (m mod j=0) then inc(ans1,2);\nif (ans=2)and(ans1=2) then\nif (lik+ii+jj=n) then begin writelN(3);writeln(lik,' ',ii,' ',jj);halt;end else\nif (lik+ii=n) then begin writelN(2);writeln(lik,' ',ii);halt;end else\nif (lik+jj=n) then begin writelN(2);writeln(lik,' ',jj);halt;end else\nif (ii+jj=n) then begin writelN(2);writeln(ii,' ',jj);halt;end;\nend;\n\n\n\nend.\n"}, {"source_code": "Const\n Fi='';//584D.INP';\n Fo='';//584D.OUT';\n\nVar n:Longint;\n Res:Array[0..3] of Longint;\n\nFunction Check(x:Longint):Boolean;\nVar i:Longint;\nBegin\n If x<=1 then Exit(False);\n If x<4 then Exit(True);\n If (x Mod 2=0) or (x Mod 3=0) then Exit(False);\n\n For i:=2 to Trunc(Sqrt(x)) do\n If x Mod i=0 then Exit(False);\n Exit(True);\nEnd;\n\nProcedure Find(i,k:Longint);\nVar j,k1:Longint;\nBegin\n If i>3 then Exit;\n\n If Check(k) then\n Begin\n Res[i]:=k;\n Writeln(i);\n For j:=i downto 1 do\n Write(Res[j],' ');\n Halt;\n End;\n\n k1:=k-1;\n While k1>0 do\n Begin\n If Check(k1) then\n Begin\n Res[i]:=k1;\n Find(i+1,k-k1);\n End;\n Dec(k1);\n End;\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Readln(n);\n Find(1,n);\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "{$mode objfpc}\nconst nmax=round(1E5);\nvar n:integer;\nfunction check(k:integer) :boolean;\n var i:integer;\n begin\n if k<2 then exit(false);\n for i:=2 to trunc(sqrt(k)) do\n if k mod i=0 then exit(false) ;\n exit(true);\n end;\nprocedure main;\n var i:integer;\n begin\n readln(n);\n if check(n) then\n begin\n writeln(1);\n writeln(n) ;\n exit;\n end;\n if check(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2) ;\n exit;\n end;\n for i:=3 to nmax do\n if check(i) and (check((n-i) div 2)) then\n begin\n writeln(3);\n writeln(i,' ',(n-i) div 2,' ',(n-i) div 2);\n break;\n end;\n\n end;\nBEGIN\n main;\n readln\nEND."}, {"source_code": "var\nn,i:longint;\nfunction aval(a:longint):boolean;\nvar\ni:longint;\nbegin\nif(a=1) then exit(false);\nfor i:=2 to round(sqrt(a)) do if(a mod i=0) then exit(false);\nexit(true);\nend;\nbegin\nreadln(n);\nif(n=3) then begin writeln(1); writeln(3); halt; end;\nif(n=5) then begin writeln(1); writeln(5); halt; end;\nfor i:=1 to n do\nbegin\nif(aval(i)) and (aval((n-i) div 2)) and ((n-i) mod 2=0)\nthen begin writeln(3); write(i,' ',(n-i) div 2,' ',(n-i) div 2); halt; end;\n{writeln(aval(i));\nwriteln(aval((n-i)div 2));}\nend;\nend."}, {"source_code": "var n:longint;\n\nFunction Check(x:longint):boolean;\nvar i:longint;\nbegin\nfor i:=2 to trunc(sqrt(x)) do\n\tif x mod i=0 then exit(false);\nexit(true);\nend;\n\nProcedure Process;\nvar i,j:longint;\nbegin\nread(n);\nif check(n) then\n\tbegin\n\twriteln(1);\n\twriteln(n);\n\texit;\n\tend;\nif check(n-2) then\n\tbegin\n\twriteln(2);\n\twriteln(2,' ',n-2);\n\texit;\n\tend;\nwriteln(3);\nfor i:=4 to 1000 do\n\tif i mod 2=0 then\n\t\tif check(n-i) then\n\t\t\tbegin\n\t\t\tfor j:=2 to i do\n\t\t\t\tif check(j) and check(i-j) then\n\t\t\t\t\tbegin\n\t\t\t\t\twriteln(j,' ',i-j,' ',n-i);\n\t\t\t\t\texit;\n\t\t\t\t\tend;\n\t\t\tend;\nend;\n\nbegin\nProcess;\nend."}, {"source_code": "var\nn,i:longint;\nfunction aval(a:longint):boolean;\nvar\ni:longint;\nbegin\nif(a=1) then exit(false);\nfor i:=2 to round(sqrt(a)) do if(a mod i=0) then exit(false);\nexit(true);\nend;\nbegin\nreadln(n);\nif(n=3) then begin writeln(1); writeln(3); halt; end;\nif(n=5) then begin writeln(1); writeln(5); halt; end;\nfor i:=1 to n do\nbegin\nif(aval(i)) and (aval((n-i) div 2)) and ((n-i) mod 2=0)\nthen begin writeln(3); write(i,' ',(n-i) div 2,' ',(n-i) div 2); halt; end;\n{writeln(aval(i));\nwriteln(aval((n-i)div 2));}\nend;\nend.\n"}, {"source_code": "Var n,m,h,k,kq:int64;\n\n\nFunction Check(h:longint):boolean;\n Var i:longint;\n Begin\n If h=1 then Exit(true);\n For i:=2 to trunc(sqrt(h)) do\n If h mod i = 0 then Exit(true);\n Exit(false);\n End;\nBEGIN\n Readln(n);\n k:=n;\n If check(k)=false then\n begin\n writeln('1');\n Writeln(k);\n End\n Else\n Begin\n While check(k) do Dec(k);\n kq:=k;\n k:=n-k;\n If check(k)=false then\n Begin\n writeln('2');\n Writeln(kq,' ',k);\n End\n Else\n Begin\n m:=k-1;\n While (check(m)) or (check(k-m)) do Dec(m);\n Writeln('3');\n Writeln(kq,' ',m,' ',k-m);\n End;\n End;\n Readln;\nEND."}, {"source_code": "var\n n : longint;\n a : array [1 .. 3] of longint;\n k,i : longint;\n\n //prost\n\n function prost(a : longint) : boolean;\n var\n i : longint;\n begin\n for i := 2 to trunc(sqrt(a)) do\n if a mod i = 0\n then begin\n prost :=false;\n exit;\n end;\n prost := true;\n end;\nbegin\n{ assign(input,'input.txt');\n reset(input); }\n read(n);\n{ close(input);}\n if prost(n) = true\n then begin\n a[1] := n;\n k := 1;\n end\n else begin\n if n mod 2 = 1\n then begin\n k := 3;\n a[1] := 3;\n dec(n,3);\n end\n else k := 2;\n i := 3;\n while (prost(i) <> true) or (prost(n - i) <> true) do\n inc(i,2);\n a[k] := n - i;\n a[k - 1] := i;\n end;\n{ assign(output,'output.txt');\n rewrite(output);}\n writeln(k);\n for i := 1 to k do\n write(a[i],' ');\n{ close(output); }\nend.\n"}, {"source_code": "var\n n,i,x,y,z : longint;\n\n function pr(x : longint) : boolean;\n var\n i : longint;\n begin\n if x = 1 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x))+1 do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n readln(n);\n if pr(n) then begin writeln(1); writeln(n); halt; end;\n if n mod 2 = 1 then begin\n if pr(n-2) then begin\n writeln(2);\n writeln(n-2,' ',2);\n halt;\n end;\n for i:=3 to n do\n if pr(i) then begin\n x:=(n-i) div 2; y:=x;\n while ((not pr(x)) or (not pr(y))) and (x > 1) do begin\n dec(x);\n inc(y);\n end;\n if (x > 1) then begin\n writeln(3);\n writeln(i,' ',x,' ',y);\n halt;\n end;\n end;\n end else begin\n x:=n div 2; y:=x;\n while (not pr(x)) and (not pr(y)) do begin\n dec(x);\n inc(y);\n end;\n writeln(2);\n writeln(x,' ',y);\n end;\nend."}, {"source_code": "{ct nt}\nfunction nt(a:longint):boolean;\n var i:longint;\n begin\n if a<2 then exit(false);\n if (a=2)or(a=3)or(a=5)or(a=7) then exit(true);\n if (a mod 2=0)or(a mod 3=0) then exit(false);\n nt:=true;\n i:=1;\n while i1 then\n if P(N) then begin\n Writeln('2');\n Writeln(x1,' ',N);\n Halt;\n end;\n for i:=2 to N-2 do\nbegin\n j:=N-i;\n if (P(i)) and (P(j)) then begin\n X2:=i;\n X3:=j;\n Break;\n end;\n end;\n Writeln('3');\n Writeln(X1,' ',X2,' ',X3);\n end.\n"}, {"source_code": "Program _1;\nVar\n n,a1,a2,a3,kol:longint;\nFunction prost(n:longint):boolean;\nVar\n i:longint;\nBegin\n if n=1 then prost:=false;\n if n=3 then begin\n prost:=true;\n exit;\n end;\n i:=3;\n while i<=round(sqrt(n))+1 do begin\n if n mod i=0 then\n begin\n prost:=false;\n exit;\n end;\n inc(i,2);\n end;\n prost:=true;\n\nEnd;\nBegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n);\n a1:=3;\n a2:=0;\n a3:=0;\n kol:=1;\n n:=n-3;\n if n=0 then begin\n writeln(kol);\n write(a1);\n exit;\n end;\n if n=2 then begin\n writeln(2);\n write(a1,' 2');\n exit;\n end;\n if n=4 then begin\n writeln(3);\n write(a1,' 2 2');\n exit;\n end;\n a2:=n div 2;\n if not odd(a2) then begin\n dec(a2);\n a3:=a2+2;\n end\n else a3:=a2;\n while (not prost(a2))or(not prost(a3)) do begin\n\n dec(a2,2);\n inc(a3,2);\n end;\n writeln(3);\n write(a1,' ',a2,' ',a3);\n {close(input);\n close(output);}\nEnd.\n"}, {"source_code": "program summa_prostych;\nvar n,i,t,n1,n2,n3,k,t1,t2,nn:longint;\n\nfunction prost(var x:longint):boolean;\n var j,kol:longint;\nbegin\nkol:=0;\nfor j:=1 to trunc(sqrt(x)) do\nif x mod j=0 then inc(kol);\nif kol=1 then prost:=true else prost:=false;\n\nend;\n\n\nbegin\nreadln(n);\n\n\nif prost(n)=true then begin writeln(1); writeln(n); halt; end;\n\n\nfor i:=n-1 downto n-300 do\nbegin\nt:=i;\nif prost(t)=true then begin\n n1:=t;\n break;\n end;\n\nend;\n\n nn:=n-n1;\n\n if (prost(nn)=true)and(nn>1) then begin writeln(2); writeln(nn,' ',n1); halt; end;\n\n\n\n\n for i:=1 to n-n1 do\n for k:=1 to n-n1 do\n begin\n t1:=i;\n t2:=k;\n if (prost(t1)=true) and (prost(t2)=true) and((t1+t2+n1)=n) and(t1>1) and(t2>1) then begin n2:=t1; n3:=t2; writeln(3);\nwriteln(n1,' ',n2,' ',n3); halt; end;\n end;\n\n\n\n\nend.\n"}, {"source_code": "program Program56;\nvar\nn,i,j,a,b,c:Integer;\nfunction Prost(x:Integer):Boolean;\nvar\nii:Integer;\nbegin\n if x=1 then\n begin\n Result:=false;\n exit;\n end;\n if x=2 then\n begin\n Result:=true;\n exit;\n end;\n for ii:=2 to trunc(sqrt(x))+1 do\n begin\n if (x mod ii)=0 then\n begin\n result:=false;\n exit;\n end;\n end;\n result:=true;\nend;\nfunction NearProst(x:Integer):Integer;\nvar\n ii:Integer;\n b:Boolean;\nbegin\n for ii:=x downto 2 do\n begin\n b:=prost(ii);\n if b then \n begin\n Result:=ii;\n Break;\n end;\n end;\nend;\nbegin\n Readln(n);\n a:=nearprost(n);\n if n=a then\n begin\n Writeln(1);\n Writeln(n);\n Halt(0);\n end;\n if a+1=n then a:=nearprost(a-1);\n if prost(n-a) then\n begin\n Writeln(2);\n Writeln(a,' ',n-a);\n exit;\n end;\n for i:=2 to n-a do\n begin\n b:=i;\n c:=n-a-i;\n if (prost(b)) and (prost(c)) then\n begin\n Writeln(3);\n Writeln(a,' ',b,' ',c);\n Halt(0);\n end;\n end;\nend.\n"}, {"source_code": "var i,j,k,n,sl:longint;\n a:array[0..10] of longint;\nprocedure im;\nvar p:longint;\nbegin\n a[1]:=n-j;a[2]:=i;a[3]:=j-i;\n for p:=1 to 3 do if a[p]<>0 then inc(sl);\n writeln(sl);\n for p:=1 to 3 do if a[p]<>0 then write(a[p],' ');\nend;\nfunction th(x:longint):boolean;\nvar i:longint;\nbegin\n if x=1 then exit(false);\n if (x=0) or (x=2) then exit(true);\n\n for i:=2 to trunc(sqrt(x)) do\n if x mod i= 0 then\n begin\n exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n for j:=0 to 300 do\n begin\n if n-j>=0 then\n if th(n-j) then\n begin\n for i:=0 to j do if th(i) then\n begin\n begin\n if th(i) and th(j-i) then\n begin\n im;\n exit;\n end;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "program PD;\nvar\n n,cnt,i:longint;\n ans:array[1..3] of longint;\n\nfunction judge(u:longint):boolean;\nvar\n i:longint;\nbegin\n for i:=2 to trunc(sqrt(u)) do\n if u mod i=0 then exit(false);\n exit(true);\nend;\n\nprocedure work(u:longint);\nvar\n i:longint;\nbegin\n for i:=3 to u do\n begin\n if judge(i) then\n if judge(u-i) then\n begin\n inc(cnt);\n ans[cnt]:=i;\n inc(cnt);\n ans[cnt]:=u-i;\n exit;\n end;\n end;\nend;\n\nbegin\n readln(n);\n if n=4 then\n begin\n writeln(2);\n writeln(2,' ',2);\n halt;\n end;\n if judge(n) then\n begin\n writeln(1);\n writeln(n);\n halt;\n end;\n if n and 1=1 then\n begin\n inc(cnt);\n ans[cnt]:=3;\n dec(n,3);\n end;\n work(n);\n writeln(cnt);\n for i:=1 to cnt do\n write(ans[i],' ');\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\nnt,pos:array[1..10000000]of longint;\nn,m:longint;\nf,g:text;\n{======================================}\nProcedure Khoitao;\nVar\n i,j:longint;\n Begin\n For i:=1 to 10000000 do nt[i]:=0;\n FOr i:=2 to trunc(sqrt(10000000)) do\n if nt[i]=0 then\n Begin\n j:=i*i;\n while j<=10000000 do\n Begin\n nt[j]:=i;\n j:=j+i;\n End;\n End;\n m:=0;\n For i:=3 to 10000000 do if nt[i]=0 then\n begin\n inc(m);\n pos[m]:=i;\n end;\n End;\n{==========================================}\nfunction check(x:longint):boolean;\nvar\n i:longint;\n begin\n if x=1 then exit(false);\n if x=2 then exit(true);\n for i:=2 to trunc(sqrt(x)) do if x mod i=0 then exit(false);\n exit(true);\n end;\n{===========================================}\nProcedure main;\nvar\n i,j:longint;\n begin\n if check(n)=true then\n begin\n writeln(g,1);\n writeln(g,n);\n exit;\n end;\n if check(n-2)=true then\n begin\n writeln(g,2);\n writeln(g,2,' ',n-2);\n exit;\n end;\n if check(n-4)=true then\n begin\n writeln(g,3);\n writeln(g,2,' ',2,' ',n-4);\n exit;\n end;\n writeln(g,3);\n for i:=1 to m do\n for j:=i to m do\n if check(n-pos[i]-pos[j])=true then begin writeln(g,pos[i],' ',pos[j],' ',n-pos[i]-pos[j]);exit;end;\n end;\n{========================================}\nProcedure enter;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n readln(f,n);\nend;\nbegin\n enter;\n khoitao;\n main;\n close(g);\n close(f);\nend.\n"}, {"source_code": "var n: longint;\n i, j, k: longint;\n b: array [1..99991] of boolean;\n p: array [1..9592] of longint;\nfunction check(a: longint): boolean;\nvar i: longint;\nbegin\n for i := 1 to k do\n begin\n if sqr(p[i]) > a then\n exit(true);\n if a mod p[i] = 0 then\n exit(false);\n end;\nend;\nbegin\n for i := 2 to 99991 do\n begin\n if b[i] then continue;\n inc(k);\n p[k] := i;\n for j := i to 99991 div i do\n b[i * j] := true;\n end;\n readln(n);\n if check(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else if check(n - 2) then\n begin\n writeln(2);\n writeln('2 ', n - 2);\n end\n else if check(n - 4) then\n begin\n writeln(3);\n writeln('2 2 ', n - 4);\n end\n else begin\n n := n - 3;\n for i := 2 to k do\n if check(n - p[i]) then\n begin\n writeln(3);\n writeln('3 ', p[i], ' ', n - p[i]);\n break;\n end;\n end;\nend."}, {"source_code": "{$mode objfpc}\nuses\n math;\nconst\n ip = '';\n op = '';\n e5 = round(1e5);\n e6 = round(1e6);\nvar\n fi, fo: text;\n cnt, N: integer;\n res: array[1..3] of integer;\n\nprocedure enter;\nbegin\n assign(fi, ip); reset(fi);\n assign(fo, op); rewrite(fo);\n readln(fi, N);\nend;\n\nfunction pr(x: integer): boolean;\nvar\n i: integer;\nbegin\n pr := true;\n for i := 2 to trunc(Sqrt(x)) do\n if x mod i = 0 then exit(false);\nend;\nprocedure solve;\nvar\n a, b, i: integer;\nbegin\n cnt := 0;\n if pr(n) then\n begin\n writeln(1);\n writeln(n);\n exit\n end;\n if odd(n) then\n begin\n inc(cnt);\n res[cnt] := 3;\n dec(n, 3);\n end;\n a := ceil(n/2); b := trunc(n/2);\n while (not pr(a)) or (not pr(b)) do\n begin\n inc(a);\n dec(b);\n end;\n inc(cnt); res[cnt] := a;\n inc(cnt); res[cnt] := b;\n writeln(cnt);\n for i := 1 to cnt do\n write(res[i], ' ');\n writeln\nend;\n\nprocedure clean;\nbegin\n close(fi); close(fo);\nend;\n\n\nbegin\n ENTER;\n SOLVE;\n CLEAN;\nend.\n"}, {"source_code": "Program ILoveYou;\nVAR n,i,prime:int64;\n\nfunction Prim(x : int64) : boolean;\nVAR i:int64;\nBegin\n\nPrim:=true;\ni:=2;\nwhile (i <= sqrt(x)) do\nBegin\nif ((x mod i) = 0) then Begin Prim:=false; i:=x; end;\ni:=i + 1;\nend;\n\nend;\n\nBegin\n\nReadln(n);\nif (Prim(n)) then\nBegin\nWriteln('1');\nWriteln(n);\nend else\nBegin\n\nif (Prim(n - 2)) then\nBegin\n\nWriteln('2');\nWriteln('2 ',n - 2);\n\nend else\nBegin\n\nWriteln(3);\ni:=n - 4;\nwhile (not (Prim(i))) do\nBegin\ni:=i - 2;\nend;\n\nWrite(i,' ');\nn:=n - i;\nfor i:=2 to n do\nBegin\nif (Prim(i)) and (Prim(n - i)) then break;\nend;\n\nWriteln(i,' ',n - i);\n\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": "{$mode objfpc}\nuses\n Math;\nconst\n {$IFDEF ONLINE_JUDGE}\n InputFile = '';\n OutputFile = '';\n {$ELSE}\n InputFile = 'test.inp';\n OutputFile = '';\n {$ENDIF}\n // maxN = ;\nvar\n fi, fo: TextFile;\n cnt, N: integer;\n res: array[1..3] of Integer;\n\nprocedure Enter;\nvar\n i: Integer;\n\nbegin\n Assign(fi, inputFile); Reset(fi);\n Assign(fo, outputFile); Rewrite(fo);\n Readln(fi, N);\nend;\n\nfunction Pr(x: Integer): Boolean;\nvar\n i: Integer;\nbegin\n pr := True;\n for i := 2 to Trunc(Sqrt(x)) do\n if x mod i = 0 then exit(false);\nend;\nprocedure Solve;\nvar\n a, b, i: Integer;\nbegin\n cnt := 0;\n if Pr(n) then\n begin\n writeln(1);\n writeln(n);\n exit\n end;\n if Odd(n) then\n begin\n inc(cnt);\n res[cnt] := 3;\n dec(n, 3);\n end;\n a := Ceil(n/2); b := Trunc(n/2);\n while (not Pr(a)) or (not Pr(b)) do\n begin\n inc(a);\n dec(b);\n end;\n inc(cnt); res[cnt] := a;\n inc(cnt); res[cnt] := b;\n Writeln(cnt);\n for i := 1 to cnt do\n Write(res[i], ' ');\n Writeln\nend;\n\nprocedure Clean;\nbegin\n CloseFile(fi); CloseFile(fo);\nend;\n\n{ MAIN }\nbegin\n Enter;\n Solve;\n Clean;\nend.\n{ END OF MAIN }\n"}, {"source_code": "program h1;\nvar \nx,i,j,k,t:integer; \n\n\nfunction isprime(y:integer):boolean;\n var flag:boolean;\n r:integer; \n begin\n if y=1 then begin isprime:=false; exit; end;\n r:=trunc(sqrt(y+1));\n j:=2;\n while (y mod j >0)and(j<=r) do j:=j+1;\n if (y mod j =0) and (j0)do k:=k+1;\n if (t=0) then \n\t\tbegin\n\t\t\twriteln('1');\n\t\t\twriteln(x);\n\t\tend\n\t\t\telse\n\t\t\t\tif k=0 then\n\t\t\t\t\tbegin\n\t\t\t\t\t writeln('2');\n\t\t\t\t\t writeln(x-t,' ',t);\t\n\t\t\t\t\tend\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\twriteln('3');\n\t\t\t\t\t\t\t\twriteln(x-t,' ',t-k,' ',k);\n\t\t\t\t\t\t\tend; \nend.\n"}, {"source_code": "program h1;\nvar \nx,i,j,k,t:integer; \n\n\nfunction isprime(y:integer):boolean;\n var flag:boolean;\n r:integer; \n begin\n if y=1 then begin isprime:=false; exit; end;\n r:=trunc(sqrt(y+1));\n j:=2;\n while (y mod j >0)and(j<=r) do j:=j+1;\n if (y mod j =0) and (j0)do k:=k+1;\n if (t=0) then \n\t\tbegin\n\t\t\twriteln('1');\n\t\t\twriteln(x);\n\t\tend\n\t\t\telse\n\t\t\t\tif k=0 then\n\t\t\t\t\tbegin\n\t\t\t\t\t writeln('2');\n\t\t\t\t\t writeln(x-t,' ',t);\t\n\t\t\t\t\tend\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\twriteln('3');\n\t\t\t\t\t\t\t\twriteln(x-t,' ',t-k,' ',k);\n\t\t\t\t\t\t\tend; \nend.\n"}, {"source_code": "var j,n,m,x,i,l,r,s:longint;a,b:array[0..122000]of int64;f:boolean;t,nn,mm,kk:int64;\nfunction pr(a:int64):boolean;\nvar f:boolean;n:int64;\nbegin\n if (a=3)or(a=5)or(a=7)or(a=11)or(a=13) then pr:=true else\n begin\n n:=1;f:=true;\n while n*n0 do\n begin\n a:=b;\n b:=r;\n r := a mod b;\n end;\n nod:=b;\nend;\nbegin{\nassign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nread(nn);if pr(nn) then begin writeln(1);write(nn);;halt;end;\n {a[1]:=2;a[2]:=3;a[3]:=5;a[4]:=7;\n a[5]:=11;A[6]:=13;A[7]:=17;A[8]:=19;read(nn);\n \n i:=8;\n T:=21;\n WHILE T*T<1000000000 DO\n BEGIN\n INC(T,2);f:=true;\n for j:=2 to i do\n if t mod a[j]=0 then begin\n f:=false ;break;\n end;\n if f then begin \n inc(i);a[i]:=t ; end;\n \n END;}writeln(3);\n mm:=nn div 3;if not odd(mm) then mm:=mm-1;\n while 5=2+3 do begin\n while not pr(mm) do mm:=mm-2;\n kk:=nn-mm;\n kk:=kk div 2;if not odd(kk) then kk:=kk-1;\n while not pr(kk) do kk:=kk-2;\n if pr (nn-mm-kk) then begin write(kk,' ',mm,' ',nn-mm-kk);halt;end;\n mm:=mm-2; end;\nend."}, {"source_code": "const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type real=extended; {string=ansistring;}\n { mas=array [-10..nn] of int64; } point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n { mass1=^mass; }\n var qsum,nado,otfinish,ott,p,qq,kk,cc,pp,rr,v1,v2,kol,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n t,mask,n,k,h,step,i,j:longint;\n i2,oldot,tt,modul,aaa,bbb, aa,bb,ccc:int64;\n xnew,xold, bold,bnew,r,x,y,d,c,aold,b,a:array[-1000..500000] of int64;\n marked:array[-10..300030] of boolean;\n dd:array[-1..10,-10..20000] of int64;\n sss, ss1,ss2:string;\n sst,st:array [-10..1000000] of char;\n zan1,zan2,zan,fl:array[-10..200000] of boolean;\n ss:string;ch:char;\n mm,matr,ddp, pole :array [-10..100,-10..100] of char;\n sm:array[-10..100,-10..100,-10..100] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n left,right,v0,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction prost(t:longint):boolean;\nlabel 234;\n var i,j:longint; fl:boolean;\nbegin\n fl:=true;\n if t<=1 then fl:=false;\n i:=1; while (i*i<=t) do\n begin\n inc(i);\n if (t mod i=0)and(i<>t) then\n begin\n fl:=false; goto 234;\n end;\n end;\n234: prost:=fl;\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n if (n=3)or(n=5) then begin writeln(1); write(n); goto 1; end;\n if (n=4) then begin writeln(2); write(2,' ',2); goto 1; end;\n\n if n<1000 then\n begin\n for i:=1 to n do for j:=1 to n-i do\n begin\n k:=n-i-j;\n if prost(i) and prost(j) and prost(k) then\n begin writeln(3);\n writeln(i,' ',j,' ',k); goto 1;\n end;\n end;\n\n end;\n\n for k:=6 to 100000 do\n begin\n { writeln() }\n if prost(n-k) and not odd(k) then\n begin\n writeln(3);\n write(n-k,' ');\n for i:=1 to k do if prost(i) and prost(k-i) then\n begin write(i, ' ',k-i); goto 1; end;\n\n\n end;\n end;\n\n\n\n 1: close(output);\n\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "const fi = 'dima.inp';\n fo = 'dima.out';\n\nvar n,i : longint;\n\nprocedure mt;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\nprocedure dt;\nbegin\n close(input); close(output);\nend;\n\nfunction nt(m:longint) : boolean;\nvar i : longint;\nbegin\n if m = 1 then exit(false);\n for i := 2 to trunc(sqrt(m)) do\n if m mod i = 0 then exit(false);\n exit(true);\nend;\n\nprocedure xuli;\nbegin\n read(n);\n if nt(n) then begin writeln(1); write(n); dt; halt; end;\n for i := 1 to n div 2 do\n if (nt(i)) and (nt((n-i) div 2)) and ((n-i) mod 2 = 0) then\n begin\n writeln(3);\n write(i,' ',(n-i) div 2, ' ', (n-i) div 2);\n halt;\n end;\n for i := 1 to n div 2 do\n if nt(i) and nt(n-i) then\n begin\n writeln(2); write(i,' ',n-i); halt;\n end;\n \nend;\n\nBEGIN\n //mt;\n xuli;\n //dt;\nEND.\n"}, {"source_code": "program NumD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n inf = 1000000007;\n\nvar\n i, n, m: integer;\n ans: array [1..10] of integer;\n\nfunction prime(n: integer): boolean;\nvar\n i: integer;\nbegin\n result := true;\n if n = 1 then result := false;\n for i := 2 to trunc(sqrt(n)) do\n if n mod i = 0 then begin\n result := false;\n exit;\n end;\nend;\n\nbegin\n readln(n);\n m := 0;\n if odd(n) then begin\n inc(m);\n for i := n downto 1 do\n if prime(i) then begin\n ans[m] := i;\n dec(n, i);\n break;\n end;\n end;\n if n > 0 then\n if n = 2 then begin\n inc(m);\n ans[m] := 2;\n end\n else begin\n for i := n - 2 downto 1 do\n if prime(i) and prime(n - i) then begin\n inc(m);\n ans[m] := i;\n inc(m);\n ans[m] := n - i;\n break;\n end;\n end;\n writeln(m);\n for i := 1 to m do\n write(ans[i], ' ');\n writeln;\n readln;\nend.\n"}, {"source_code": " var\n n,i,x,j,xx,c:longint;\n bol:boolean;\nfunction check(x:longint):longint;\nbegin\ncheck:=0;\nfor c:=2 to round(sqrt(x)) do if x mod c= 0 then begin\n check:=1;\n break;\nend;\nif x=1 then check:=1;\nend;\n begin\n readln(n);\n if n=3 then begin\n writeln(1);\n writeln(3);\n end\n else\n if n=5 then begin\n writeln(2);\n writeln(3,' ',2);\n end\n else if n=7 then begin\n writeln(3);\n writeln(3,' ',2,' ',2);\n end\n else\n if n=9 then begin\n writeln(3);\n writeln(3,' ',3,' ',3);\n end\n else begin\nwriteln(3);\nwrite(3,' ');\nn:=n-3;\nfor i:=n-1 downto 1 do begin\n if (check(n-i)=0)and(check(i)=0) then begin\n write(i,' ',n-i);\n break;\n end;\nend;\nend;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nvar n,i,j:integer;\n\nfunction prost(x:integer):boolean;\nvar t:integer;\n rez:Boolean;\nbegin\n if x<4 then rez:=True\n else\n begin\n rez:=not(x mod 2=0);\n t:=3;\n while (rez) and (t*t<=x) do\n begin\n rez:=not(x mod t=0);\n Inc(t,2);\n end;\n end;\n prost:=rez;\nend;\n\nbegin\n Readln(n);\n if prost(n) then\n begin\n Writeln(1);\n writeln(n);\n end\n else\n if prost(n-2) then\n begin\n writeln(2);\n Writeln(2,' ',n-2);\n end\n else\n begin\n i:=3; j:=3;\n while not(prost(i) and prost(j) and prost(n-i-j)) do\n begin\n Inc(j,2);\n while not(prost(j)) and (i+2*j<=n) do inc(j,2);\n if (n-i-j)1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then begin flag:=false;break;end;\n kt:=flag;\nend;\nprocedure sang;\nvar\n i,j:longint;\nbegin\n for i:=2 to 1000000 do\n for j:=i to 1000000 div i do\n a[i*j]:=true;\nend;\nbegin\n readln(n);\n case n of\n 3: begin writeln(1);writeln(3);halt;end;\n 4: begin writeln(2);writeln(2,' ',2);halt;end;\n 5: begin writeln(1);writeln(5);halt;end;\n end;\n sang;\n if kt(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if n mod 2 =0 then\n begin\n h:=n -2;\n if kt(h) then\n begin\n writeln(2);\n writeln(2,' ',h);\n end\n else\n begin\n writeln(3);\n write(2,' ');\n for i:=2 to 1000000 do\n begin\n if (a[i]=false)and (kt(h-i)) then\n begin\n write(i,' ',h-i);\n halt;\n end;\n end;\n end;\n end\n else\n begin\n h:=n-3;\n if kt(h) then\n begin\n writeln(2);\n writeln(3,' ',h);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n for i:=2 to 1000000 do\n begin\n if (a[i]=false)and (kt(h-i)) then\n begin\n write(i,' ',h-i);\n halt;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "var k,i,j,n,q,s,ans1:integer;\nf:boolean;\n\n\n\n\nfunction isPrime(X: integer): boolean;\n\nvar\n\ni: integer;\n\nBegin\n\n isPrime:=false;\n\n if not odd(x) and (x<>2) { проверяем на чётность }\n\n then exit;\n\n i:=3;\n\n while i <= sqrt(x) do { проверяем только нечётные }\n\n begin\n\n if x mod i = 0 then Exit;\n\n inc(i,2);\nend;\nisPrime:=true;\n End;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n Begin\nreadln(n);\n\n\nif isprime(n)=true then Begin writeln(1);write(n); exit; end;\n\n\n\nif n=3 then Begin writeln(1);writeln(3); exit; end;\nfor i:=n-2 downto 1 do \nif isprime(i)= true then Begin s:=n-i; break;end;\nk:=k+1;\nans1:=i;\n\nfor i:=2 to s-1 do\nif s mod i =0 then Begin f:=true; break end; \nif f=false then Begin writeln(2);write(ans1, ' ',s);exit; end;\nf:=false;\n\n\nk:=3;\nfor i:=2 to s-1 do \nif isprime(i)=true then if isprime(s-i)=true \n then Begin writeln(k);write(ans1,' ',s-i,' ',i); exit;end;\n\n\n\n\n\n\n\n\n\n\nend. "}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k,j:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n j:=(n-3) div 2;\n k:=j;\n if j mod 2=0 then\n begin\n while (prime(j)=false) or (prime(k)=false) do\n begin\n dec(j); inc(k);\n end;\n end\n else\n begin\n while (prime(k)= false) or (prime(j)=false) do\n begin\n dec(k,2);\n inc(j,2);\n end;\n end;\n writeln(j,' ',k);\n end;\nend."}, {"source_code": "function snt(a:int64):boolean;\nvar i:longint;\nbegin\n\tsnt:=true;\n\tfor i:=2 to trunc(SQrt(a)) do if a mod i = 0 then exit(false);\nend;\nvar a,b,c:int64; i:longint;\nbegin\n\tread(A);b:=a;\n\tif snt(a-2) and (a-2<>1) then \n\tbegin\t\n\t\twriteln(2);\n\t\twrite(2,' ',a-2);\n\t\texit;\n\tend;\n\twhile (not snt(A)) do a:=a-1;\n\tif a=b then \n\tbegin\n\t\twriteln(1);\n\t\twrite(A);\n\tend\n\telse\n\tbegin\n\t\tif b-a=1 then \t\t\n\t\tbegin\n\t\t\ta:=a-1;\n\t\t\twhile (not snt(A)) do a:=a-1;\n\t\tend;\n\t\twriteln(3);\n\t\twrite(A,' ');\n\t\ta:=b-a; \n\t\tfor i:=2 to a do\n\t\tbegin\n\t\t\tif (snt(i)) and (snt(a-i)) then \n\t\t\tbegin\n\t\t\t\twrite(i,' ',a-i); break;\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "const fin='';\n fout='';\nvar n,b,i,a:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fin);reset(f);\n readln(f,n);\n close(f);\nend;\nfunction ktnt(x:longint):boolean;\nvar i,j:longint;\nbegin\n ktnt:=true;\n if x<2 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nend;\nprocedure xuat;\nvar g:Text;\nbegin\n assign(g,fout);rewrite(g);\n for i:=n-1 downto 1 do\n if ktnt(i) then\n begin\n a:=i;b:=n-a;\n break;\n end;\n if n=3 then\n begin\n writeln(g,1);\n writeln(g,n);\n end\n else\n if ktnt(b) then\n begin\n writeln(g,2);\n writeln(g,a,' ',b);\n end\n else\n begin\n writeln(g,3);\n for i:=2 to b div 2 do\n if (ktnt(i))and(ktnt(b-i)) then\n begin\n writeln(g,a,' ',i,' ',b-i);\n break;\n end;\n end;\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "uses math;\n\nvar\n n,i,j,cp : longint;\n p : array [1..50] of longint;\n\nfunction check(x : longint) : boolean;\n var i : longint;\n begin\n if x < 2 then exit(false);\n for i := 2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n read(n);\n for i := 1 to min(n,200) do\n if check(i) then\n begin\n inc(cp);\n p[cp] := i;\n end;\n if check(n) then\n begin\n writeln(1);\n write(n);\n exit;\n end;\n for i := 1 to cp do\n if check(n - p[i]) then\n begin\n writeln(2);\n write(p[i],' ',n-p[i]);\n exit;\n end;\n for i := 1 to cp do\n for j := 1 to cp do\n if check(n - p[i] - p[j]) then\n begin\n writeln(3);\n write(p[i],' ',p[j],' ',n - p[i] - p[j]);\n exit;\n end;\nend."}, {"source_code": "{$mode objfpc}\nprogram fafa;\nvar n,k:integer;\n\nfunction nto(a :integer) :boolean;\nvar i:integer;\nbegin\n result:=true;\n for i:=2 to trunc(sqrt(a)) do\n if a mod i =0 then\n begin\n result:=false;\n break;\n end;\nend;\n\nbegin\n readln(n);\nif nto(n) then\n begin\n writeln(1);\n writeln(n);\n end\nelse\n if n mod 2 = 0 then\n begin\n k:=n div 2;\n repeat\n if nto(k) and nto(n-k) then\n begin\n writeln(2);\n writeln(k,' ',n-k);\n exit;\n end;\n if k mod 2 =0 then k:=k-1 else k:=k-2;\n until 1>2;\n end\n else\n begin\n n:=n-3;\n k:=n div 2;\n repeat\n if nto(k) and nto(n-k) then\n begin\n writeln(3);\n writeln(3,' ',k,' ',n-k);\n exit;\n end;\n if k mod 2 =0 then k:=k-1 else k:=k-2;\n until 1>2;\n end;\nend."}, {"source_code": "const size=1000000;\nvar\na:array[0..size*2] of boolean;\np:array[0..size] of int64;\n\nprocedure init;\nvar\ni:longint;\nbegin\n for i:=1 to size*2 do\n begin\n a[i]:=true;\n p[i div 2]:=0;\n end;\n\nend;\n\nprocedure erat;\nvar\ni,p,t:longint;\nbegin\n i:=2;\n while i<=size do\n begin\n // writeln('i before ',i);\n p:=i;\n while p=p[pos] do\n inc(pos);\n\n for i:=1 to pos do\n for j:=pos downto 1 do\n if p[i]+p[j]=n then\n begin\n f:=p[i];\n s:=p[j];\n end;\n\n\nend;\n\n\nvar\ni,j,pos:longint;\nf,s,t,n:int64;\nbegin\n{\nassign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);\n}\ninit;\nerat;\npos:=0;\n for i:=2 to size do\n if a[i] then\n begin\n inc(pos);\n p[pos]:=i;\n end;\n // writeln('max=',p[pos]);\n // writeln('pos=',pos);\n readln(n);\n\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n halt(0);\n end;\n\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n halt(0);\n end;\n\n writeln(3);\n if n<10000 then\n begin\n even(n-3,f,s);\n writeln(3,' ',f,' ',s);\n halt(0);\n end;\n t:=n;\n while not prime(t) do\n t:=t-2;\n // writeln(3);\n even(n-t,f,s);\n writeln(t,' ',f,' ',s);\n\nend.\n\n"}, {"source_code": "{$mode objfpc}\nvar\n i:longint;\n h,n:int64;\n a:array[2..1000000]of boolean;\nfunction kt(x:int64):boolean;\nvar\n flag:boolean;\n i:longint;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then begin flag:=false;break;end;\n kt:=flag;\nend;\nprocedure sang;\nvar\n i,j:longint;\nbegin\n for i:=2 to 1000000 do\n for j:=i to 1000000 div i do\n a[i*j]:=true;\nend;\nbegin\n readln(n);\n case n of\n 3: begin writeln(1);writeln(3);halt;end;\n 4: begin writeln(2);writeln(2,' ',2);halt;end;\n 5: begin writeln(1);writeln(5);halt;end;\n end;\n sang;\n if kt(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if n mod 2 =0 then\n begin\n h:=n -2;\n if kt(h) then\n begin\n writeln(2);\n writeln(2,' ',h);\n end\n else\n begin\n writeln(3);\n write(2,' ');\n for i:=2 to 1000000 do\n begin\n if (a[i]=false)and (kt(h-i)) then\n begin\n write(i,' ',h-i);\n halt;\n end;\n end;\n end;\n end\n else\n begin\n h:=n-3;\n if kt(h) then\n begin\n writeln(2);\n writeln(3,' ',h);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n for i:=2 to 1000000 do\n begin\n if (a[i]=false)and (kt(h-i)) then\n begin\n write(i,' ',h-i);\n halt;\n end;\n end;\n end;\n end;\nend."}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k,j:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n j:=(n-3) div 2;\n k:=j;\n if j mod 2=0 then\n begin\n while (prime(j)=false) or (prime(k)=false) do\n begin\n dec(j); inc(k);\n end;\n end\n else\n begin\n while (prime(k)= false) or (prime(j)=false) do\n begin\n dec(k,2);\n inc(j,2);\n end;\n end;\n writeln(j,' ',k);\n end;\nend."}, {"source_code": "var d,r:array[0..5000007] of int64;\n\tz,i,n,x,ind:longint;\n\nprocedure resh;\n\tvar j,ii:longint;\nbegin\n\tr[1]:=1;\n\tfor ii:=2 to z do\n\t\tif r[ii] = 0 then \tbegin\n\t\t\t\t\t\t\t\tj:=ii+ii;\n\t\t\t\t\t\t\t\twhile j<=z do\n\t\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\t\tr[j]:=ii;\n\t\t\t\t\t\t\t\t\t\tinc(j,ii);\n\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\tend;\nend;\n\nfunction prov(f:longint):byte;\n\tvar p:byte;\n\t\th:longint;\nbegin\n\tp:=0;\n\tfor h:=2 to round(sqrt(f)) do\n\t\tif f mod h=0 then begin p:=1; break; end;\n\tprov:=p;\nend; \n\nbegin\n\tz:=5000000;\n\tfillchar(r,sizeof(r),0);\n\tresh;\n\treadln(x);\n\tif x<4 then begin writeln(1); writeln(x); halt; end;\n\tind:=x;\n\twhile ind>=2 do\n\t\tbegin\n\t\t\tif prov(ind) = 0 then begin\n\t\t\t d[1]:=ind;\n\t\t\t n:=x-ind;\n\t\t\t break;\n\t\t\t end;\n\t\t\tdec(ind);\n\t\tend;\n//\twriteln(ind,' ',n);\t\n\tif n=0 then begin writeln(1); writeln(d[1]); halt; end;\n\tif r[n]=0 then begin writeln('2'); writeln(d[1],' ',n); halt; end;\n\tfor i:=1 to z do\n\t\tif (r[i]=0) and (r[n-i]=0) then begin writeln(3); write(d[1],' ',i,' ',n-i); halt; end;\nend.\n\n\n"}, {"source_code": "\nvar i,n,j:longint;\n pri:array[0..1000000] of boolean;\nfunction prime(loc:longint):boolean;\nvar i:longint;\nbegin\n if loc<2 then exit(false);\n if loc=2 then exit(true);\n for i:=2 to trunc(sqrt(loc))do\n if loc mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n fillchar(pri,sizeof(pri),true);\n for i:=2 to 1000000 do\n begin\n if pri[i]=false then continue;\n j:=i shl 1;\n while j<=1000000 do begin pri[j]:=false;j:=j+i;end;\n end;\n if prime(n)=true then begin writeln(1);writeln(n);halt;end;\n if prime(n-2)=true then begin writeln(2);writeln('2 ',n-2);halt;end;\n if prime(n-4)=true then begin writeln(3);writeln('2 2 ',n-4);halt;end;\n if ((n-2) and 1=0) and (prime((n-2) shr 1)=true) then begin writeln(3);writeln('2 ',(n-2) shr 1,' ',(n-2) shr 1);halt;end;\n for i:=n downto 3 do\n if (i and 1=1) and (prime(i)=true) then break;\n\n for j:=3 to n do\n if (j and 1=1) and (pri[j]=true) and (pri[n-i-j]=true) then\n begin\n writeln(3);\n writeln(i,' ',j,' ',n-i-j);\n halt;\n end;\n\nend."}, {"source_code": "program p1;\nvar n,a,b,c,i,j,k:integer; bo:boolean;\nfunction prost(a:integer):boolean;\nvar pi:integer; pb:boolean;\nbegin pb:=true;\nif a = 1 then pb:=false\nelse begin pi:=2;\nwhile ((pi<= sqrt(a)) and (pb ))\n do\n\n if a mod pi = 0 then pb:=false else pi:=pi+1;\nend;\nprost:=pb;\nend;\n\n\nbegin\nreadln(n);\na:=0; b:=0; c:=0;\nbo:=true; i:=n;\nwhile (i<>0) and bo\n do\n begin\n if prost(i) then\n for j:=0 to n-i\n do\n if prost(j) and prost(n-i-j) then begin bo:=false; a:= i; b:=j; c:= n-i-j; end;\n i:=i-1;\n end;\n k:=3;\nif a = 0 then k:=k-1;\nif b=0 then k:=k-1;\nif c=0 then k:=k-1;\nwriteln(k);\nif a<>0 then write(a,' ');\nif b<>0 then write(b,' ');\nif c<>0 then write(c);\nend.\n"}], "negative_code": [{"source_code": "Program ILoveYou;\nVAR n,i,prime:int64;\n\nfunction Prim(x : int64) : boolean;\nVAR i:int64;\nBegin\n\nPrim:=true;\ni:=2;\nwhile (i <= sqrt(x)) do\nBegin\nif ((x mod i) = 0) then Begin Prim:=false; i:=x; end;\ni:=i + 1;\nend;\n\nend;\n\nBegin\n\nReadln(n);\nif (Prim(n)) then\nBegin\nWriteln('1');\nWriteln(n);\nend else\nBegin\n\nif (Prim(n - 2)) then\nBegin\n\nWriteln('2');\nWriteln(n,' ',n - 2);\n\nend else\nBegin\n\nWriteln(3);\ni:=n - 4;\nwhile (not (Prim(i))) do\nBegin\ni:=i - 2;\nend;\n\nWrite(i,' ');\nn:=n - i;\nfor i:=2 to n do\nBegin\nif (Prim(i)) and (Prim(n - i)) then break;\nend;\n\nWriteln(i,' ',n - i);\n\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": "const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type real=extended; {string=ansistring;}\n { mas=array [-10..nn] of int64; } point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n { mass1=^mass; }\n var qsum,nado,otfinish,ott,p,qq,kk,cc,pp,rr,v1,v2,kol,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n t,mask,n,k,h,step,i,j:longint;\n i2,oldot,tt,modul,aaa,bbb, aa,bb,ccc:int64;\n xnew,xold, bold,bnew,r,x,y,d,c,aold,b,a:array[-1000..500000] of int64;\n marked:array[-10..300030] of boolean;\n dd:array[-1..10,-10..20000] of int64;\n sss, ss1,ss2:string;\n sst,st:array [-10..1000000] of char;\n zan1,zan2,zan,fl:array[-10..200000] of boolean;\n ss:string;ch:char;\n mm,matr,ddp, pole :array [-10..100,-10..100] of char;\n sm:array[-10..100,-10..100,-10..100] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n left,right,v0,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction prost(t:longint):boolean;\nlabel 234;\n var i,j:longint; fl:boolean;\nbegin\n fl:=true;\n if t<=1 then fl:=false;\n i:=1; while (i*i<=t) do\n begin\n inc(i);\n if (t mod i=0)and(i<>t) then\n begin\n fl:=false; goto 234;\n end;\n end;\n234: prost:=fl;\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n if (n=3)or(n=5) then begin writeln(1); write(n); goto 1; end;\n if (n=4) then begin writeln(2); write(2,' ',2); goto 1; end;\n\n if n<1000 then\n begin\n for i:=1 to n do for j:=1 to n-i do\n begin\n k:=n-i-j;\n if prost(i) and prost(j) and prost(k) then\n begin writeln(n,' ',3);\n writeln(i,' ',j,' ',k); goto 1;\n end;\n end;\n\n end;\n\n for k:=6 to 100000 do\n begin\n { writeln() }\n if prost(n-k) and not odd(k) then\n begin\n writeln(3);\n write(n-k,' ');\n for i:=1 to k do if prost(i) and prost(k-i) then\n begin write(i, ' ',k-i); goto 1; end;\n\n\n end;\n end;\n\n\n\n 1: close(output);\n\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var\n n,i,j:longint;\nFunction F(n:longint):boolean;\nVar\n i,g:longint;\nBegin\n if n=2 then\n begin\n result:=true;\n exit;\n end;\n if n mod 2=0 then\n begin\n result:=false;\n exit;\n end;\n g:=round(sqrt(n)+2);\n i:=3;\n result:=true;\n while i<=g do\n begin\n if n mod i=0 then\n begin\n result:=false;\n break;\n end;\n inc(i,2);\n end;\nend;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n);\n if f(n) then\n begin\n writeln(1);\n writeln(n);\n halt(0);\n end;\n for i:=n downto 1 do\n if f(i) then\n begin\n if f(n-i) then\n begin\n writeln(2);\n writeln(i,' ',n-i);\n end;\n for j:=2 to n-i do\n if f(j)and f(n-i-j) then\n begin\n writeln(3);\n writeln(i,' ',j,' ',n-i-j);\n halt(0);\n end;\n end;\nend."}, {"source_code": "Var\n n,i,j:longint;\nFunction F(n:longint):boolean;\nVar\n i,g:longint;\nBegin\n if n=2 then\n begin\n result:=true;\n exit;\n end;\n if (n mod 2=0)or(n=1) then\n begin\n result:=false;\n exit;\n end;\n g:=round(sqrt(n)+2);\n i:=3;\n result:=true;\n while i<=g do\n begin\n if n mod i=0 then\n begin\n result:=false;\n break;\n end;\n inc(i,2);\n end;\nend;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n);\n if f(n) then\n begin\n writeln(1);\n writeln(n);\n halt(0);\n end;\n for i:=n downto 1 do\n if f(i) then\n begin\n if f(n-i) then\n begin\n writeln(2);\n writeln(i,' ',n-i);\n halt(0);\n end;\n for j:=2 to n-i do\n if f(j)and f(n-i-j) then\n begin\n writeln(3);\n writeln(i,' ',j,' ',n-i-j);\n halt(0);\n end;\n end;\nend."}, {"source_code": "var a,b:array[1..300]of longint;\n n,t,i,ii,j:longint;\nfunction prost(x:longint):boolean;\n var i:longint;\n begin\n i:=2;\n prost:=true;\n while i*i<=x do\n begin\n if x mod i =0 then prost:=false;\n inc(i);\n end;\n end;\nbegin\nread(n);\nif prost(n) then begin writeln(1);write(n); halt end else writeln(3);\nt:=n-2;\nwhile not(prost(t)) do dec(t);\nt:=n-t;\nfor i:=2 to t do\n if a[i]=0 then\n begin\n j:=i+i;\n while j<=t do\n begin\n a[j]:=1;\n inc(j,i);\n end;\n end;\nj:=0;\nfor i:=2 to t do\n if a[i]=0 then\n begin\n inc(j);\n b[j]:=i;\n end;\nfor i:=1 to j do\n for ii:=i to j do\n if b[i]+b[ii]=t then\n begin\n write (b[i],' ',b[ii],' ',n-t);\n halt;\n end;\nend.\n"}, {"source_code": "var n,m,i,k,j,ans,lik,ii,jj,ans1:longint;\nbegin\nreadln(n);\nfor i:=n downto n-300 do\nbegin\nm:=i;\nans:=0;\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans) else\nif (m mod j=0) then inc(ans,2);\nif (ans=2) then begin lik:=i;break;end;\nend;\n\nfor ii:=2 to 300 do\nfor jj:=2 to 300 do\nbegin\nm:=ii;\nans:=0;\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans) else\nif (m mod j=0) then inc(ans,2);\nm:=jj;\nans1:=0;\nfor j:=1 to trunc(sqrt(m)) do\nif (j*j=m) then inc(ans1) else\nif (m mod j=0) then inc(ans1,2);\nif (ans=2)and(ans1=2)and(lik+ii+jj=n) then begin writelN(lik,' ',ii,' ',jj);halt;end;\nend;\n\n\n\nend."}, {"source_code": "Const\n Fi='';//584D.INP';\n Fo='';//584D.OUT';\n\nVar n:Longint;\n Res:Array[0..3] of Longint;\n\nFunction Check(x:Longint):Boolean;\nVar i:Longint;\nBegin\n If x<=1 then Exit(False);\n If (x Mod 2=0) or (x Mod 3=0) then Exit(False);\n\n For i:=2 to Trunc(Sqrt(x)) do\n If x Mod i=0 then Exit(False);\n Exit(True);\nEnd;\n\nProcedure Find(i,k:Longint);\nVar j,k1:Longint;\nBegin\n If i>3 then Exit;\n\n If Check(k) then\n Begin\n Res[i]:=k;\n Writeln(i);\n For j:=1 to i do\n Write(Res[j],' ');\n Halt;\n End;\n\n k1:=k-2;\n While k1>0 do\n Begin\n If Check(k1) then\n Begin\n Res[i]:=k1;\n Find(i+1,k-k1);\n End;\n Dec(k1);\n End;\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Readln(n);\n Find(1,n);\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "var i,k,n:integer; c:string; a:array[0..100000000]of 0..1;\nprocedure pr(t,k:integer; s:string);\nvar j:integer;\nbegin\nif (t=4)and(k=0) then begin delete(s,length(s),1); writeln(s); halt; end\nelse begin\nfor j:=2 to n do\nif (a[j]=0)and(k-a[j]>=0) then begin str(j,c); pr(t+1,k-j,s+c+' '); end;\nend;\nend;\nbegin\nreadln(n);\ni:=2;\nrepeat\nif a[i]=0 then begin k:=i;\nwhile k<=n do\nbegin\nk:=k+i;\na[k]:=1; \nend;\nend;\ni:=i+1;\nuntil i>=n;\npr(1,n,'');\nend."}, {"source_code": "var\n i,j,n,m,k,t,x,z:longint;\n ff:boolean;\n a:array[0..22]of longint;\nbegin\n readln(n);\n for z:=2 downto 0 do\n begin\n i:=n-z*2;\n while i>=2 do\n begin\n ff:=false;\n j:=2;\n while j<=trunc(sqrt(i)) do if i mod j=0 then\n begin\n ff:=true;\n break;\n end else inc(j);\n if not ff then\n begin\n dec(n,i);\n a[z]:=i;\n break;\n end;\n dec(i);\n end;\n end;\n k:=0;\n for z:=0 to 2 do if a[z]>0 then inc(k);\n writeln(k);\n for z:=0 to 2 do if a[z]>0 then write(a[z],' ');\n writeln;\nend.\n"}, {"source_code": "Const Fi='';\n Fo='';\n maxN=50000;\nFunction Check(k:Longint):Boolean;\nVar i:Longint;\n Begin\n If k=1 then Exit(False);\n For i:=2 to Trunc(Sqrt(k)) do\n If k mod i=0 then Exit(False);\n Exit(True);\n End;\nProcedure Enter;\nVar n,i:Longint;\n Begin\n Readln(n);\n If Check(n) then\n Begin\n Writeln(1);\n Writeln(n);\n Exit;\n End;\n If Check(n-2) then\n Begin\n Writeln(2);\n Writeln(2,' ',n);\n Exit;\n End;\n For i:=3 to maxN do\n If Check(i) and Check((n-i) Div 2) then\n Begin\n Writeln(3);\n Writeln(i,' ',(n-i) Div 2,' ',(n-i) Div 2);\n Exit;\n End;\n End;\nBegin\n Assign(Input,Fi);Reset(Input);\n Assign(Output,Fo);Rewrite(Output);\n Enter;\n Close(Input);Close(Output);\nEnd."}, {"source_code": "Const Fi='';\n Fo='';\n maxN=50000;\nFunction Check(k:Longint):Boolean;\nVar i:Longint;\n Begin\n If k=1 then Exit(False);\n For i:=2 to Trunc(Sqrt(k)) do\n If k mod i=0 then Exit(False);\n Exit(True);\n End;\nProcedure Enter;\nVar n,i:Longint;\n Begin\n Readln(n);\n If Check(n) then\n Begin\n Writeln(1);\n Writeln(n);\n Exit;\n End;\n If Check(n-2) then\n Begin\n Writeln(2);\n Writeln(2,' ',n);\n Exit;\n End;\n For i:=3 to maxN do\n If Odd(i) and Check(i) and Check((n-i) Div 2) then\n Begin\n Writeln(3);\n Writeln(i,' ',(n-i) Div 2,' ',(n-i) Div 2);\n Exit;\n End;\n End;\nBegin\n Assign(Input,Fi);Reset(Input);\n Assign(Output,Fo);Rewrite(Output);\n Enter;\n Close(Input);Close(Output);\nEnd."}, {"source_code": "{$mode objfpc}\nconst fi='DD.inp';\n fo='DD.out';\n nmax=round(1E5);\nvar n:integer;\nfunction check(k:integer) :boolean;\n var i:integer;\n begin\n for i:=2 to trunc(sqrt(k)) do\n if k mod i=0 then exit(false) ;\n exit(true);\n end;\nprocedure main;\n var i:integer;\n begin\n readln(n);\n if check(n) then\n begin\n writeln(1);\n writeln(n) ;\n end;\n if check(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2) ;\n end;\n for i:=3 to nmax do\n if check(i) and (check((n-i)div 2)) then\n begin\n writeln(3);\n writeln(i,' ',(n-i) div 2,' ',(n-i)div 2);\n break;\n end;\n end;\nBEGIN\n main;\nEND."}, {"source_code": "var\nn,i:longint;\nfunction aval(a:longint):boolean;\nvar\ni:longint;\nbegin\nif(a=1) then exit(false);\nfor i:=2 to round(sqrt(a)) do if(a mod i=0) then exit(false);\nexit(true);\nend;\nbegin\nreadln(n);\nif(n=3) then begin writeln(1); writeln(3); halt; end;\nif(n=5) then begin writeln(1); writeln(5); halt; end;\nfor i:=1 to n do\nbegin\nif(aval(i)) and (aval((n-i) div 2)) and ((n-i) mod 2=0)\nthen begin writeln(3); write(i,' ',(n-i) div 2,' ',(n-i) div 2); halt; end;\nwriteln(aval(i));\nwriteln(aval((n-i)div 2));\nend;\nend.\n\n\n"}, {"source_code": "var\n n,i,x,y,z : longint;\n\n function pr(x : longint) : boolean;\n var\n i : longint;\n begin\n if x = 1 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x))+5 do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n readln(n);\n if pr(n) then begin writeln(1); writeln(n); halt; end;\n if n mod 2 = 1 then begin\n if pr(n-2) then begin\n writeln(2);\n writeln(n-2,' ',2);\n halt;\n end;\n for i:=3 to n do\n if pr(i) then begin\n x:=(n-i) div 2; y:=x;\n while (not pr(x)) and (not pr(y)) and (x > 1) do begin\n dec(x);\n inc(y);\n end;\n if (x > 1) then begin\n writeln(3);\n writeln(i,' ',x,' ',y);\n halt;\n end;\n end;\n end else begin\n x:=n div 2; y:=x;\n while (not pr(x)) and (not pr(y)) do begin\n dec(x);\n inc(y);\n end;\n writeln(2);\n writeln(x,' ',y);\n end;\nend."}, {"source_code": "var\n n,i,x,y,z : longint;\n\n function pr(x : longint) : boolean;\n var\n i : longint;\n begin\n if x = 1 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x))+1 do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n readln(n);\n if pr(n) then begin writeln(1); writeln(n); halt; end;\n if n mod 2 = 1 then begin\n if pr(n-2) then begin\n writeln(2);\n writeln(n-2,' ',2);\n halt;\n end;\n for i:=3 to n do\n if pr(i) then begin\n x:=(n-i) div 2; y:=x;\n while (not pr(x)) and (not pr(y)) and (x > 1) do begin\n dec(x);\n inc(y);\n end;\n if (x > 1) then begin\n writeln(3);\n writeln(i,' ',x,' ',y);\n halt;\n end;\n end;\n end else begin\n x:=n div 2; y:=x;\n while (not pr(x)) and (not pr(y)) do begin\n dec(x);\n inc(y);\n end;\n writeln(2);\n writeln(x,' ',y);\n end;\nend."}, {"source_code": "{ct nt}\nfunction nt(a:longint):boolean;\n var i:longint;\n begin\n if a<2 then exit(false);\n if (a=2)or(a=3)or(a=5)or(a=7) then exit(true);\n if (a mod 2=0)or(a mod 3=0) then exit(false);\n nt:=true;\n i:=1;\n while i0 then k:=k+1;\nif q <>0 then k:=k+1;\nwriteln(k);\nwrite(ans1,' ',q,' ',i);\n\nend.\n"}, {"source_code": "var k,i,j,n,q,s,ans1:integer;\nf:boolean;\n Begin\nreadln(n);\n\nfor i:=2 to n div 2 +1 do\nif n mod i =0 then Begin f:=true; break end; \nif f=false then Begin writeln(1);write(n);exit; end;\nf:=false;\n\n\n\n\nif n=3 then Begin writeln(1);writeln(3); exit; end;\nfor i:=n-2 downto 1 do \nBegin\nfor j:=2 to i div 2 +1 do\nif i mod j=0 then Begin f:=true;break;end;\nif f=false then Begin s:=n-i;break;end;\nf:=false;\nend;\nk:=k+1;\nans1:=i;\n\nfor i:=2 to s-1 do\nif s mod i =0 then Begin f:=true; break end; \nif f=false then Begin writeln(2);write(ans1, ' ',s);exit; end;\nf:=false;\n\n\nfor i:=s-2 downto 2 do\nBegin \nfor j:=2 to i-1 do\nif (i mod j=0) then Begin f:=true;break;end;\nif f=false then Begin q:=s-i;break;end;\nf:=false;\nend;\nif i<>0 then k:=k+1;\nif q <>0 then k:=k+1;\nwriteln(k);\nwrite(ans1,' ',q,' ',i);\n\nend.\n"}, {"source_code": "var k,i,j,n,q,s,ans1:integer;\nf:boolean;\n Begin\nreadln(n);\n\nfor i:=2 to n-1 do\nif n mod i =0 then Begin f:=true; break end; \nif f=false then Begin writeln(1);write(n);exit; end;\nf:=false;\n\n\n\n\nif n=3 then Begin writeln(1);writeln(3); exit; end;\nfor i:=n-2 downto 1 do \nBegin\nfor j:=2 to i div 2 +1 do\nif i mod j=0 then Begin f:=true;break;end;\nif f=false then Begin s:=n-i;break;end;\nf:=false;\nend;\nk:=k+1;\nans1:=i;\n\nfor i:=2 to s-1 do\nif s mod i =0 then Begin f:=true; break end; \nif f=false then Begin writeln(2);write(ans1, ' ',s);exit; end;\nf:=false;\n\n\nfor i:=s-2 downto 2 do\nBegin \nfor j:=3 to i do\nif (i mod j=0) then Begin f:=true;break;end;\nif f=false then Begin q:=s-i;break;end;\nf:=false;\nend;\nif i<>0 then k:=k+1;\nif q <>0 then k:=k+1;\nwriteln(k);\nwrite(ans1,' ',q,' ',i);\n\nend.\n"}, {"source_code": "function snt(a:int64):boolean;\nvar i:longint;\nbegin\n\tsnt:=true;\n\tfor i:=2 to trunc(SQrt(a)) do if a mod i = 0 then exit(false);\nend;\nvar a,b,c:int64; i:longint;\nbegin\n\tread(A);b:=a;\n\tif snt(a-2) then \n\tbegin\t\n\t\twriteln(2);\n\t\twrite(2,' ',a-2);\n\t\texit;\n\tend;\n\twhile (not snt(A)) do a:=a-1;\n\tif a=b then \n\tbegin\n\t\twriteln(1);\n\t\twrite(A);\n\tend\n\telse\n\tbegin\n\t\tif b-a=1 then \t\t\n\t\tbegin\n\t\t\ta:=a-1;\n\t\t\twhile (not snt(A)) do a:=a-1;\n\t\tend;\n\t\twriteln(3);\n\t\twrite(A,' ');\n\t\ta:=b-a; \n\t\tfor i:=2 to a do\n\t\tbegin\n\t\t\tif (snt(i)) and (snt(a-i)) then \n\t\t\tbegin\n\t\t\t\twrite(i,' ',a-i); break;\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "const fin='';\n fout='';\nvar n,b,i,a:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fin);reset(f);\n readln(f,n);\n close(f);\nend;\nfunction ktnt(x:longint):boolean;\nvar i,j:longint;\nbegin\n ktnt:=true;\n if x<2 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nend;\nprocedure xuat;\nvar g:Text;\nbegin\n assign(g,fout);rewrite(g);\n for i:=n-1 downto 1 do\n if ktnt(i) then\n begin\n a:=i;b:=n-a;\n break;\n end;\n if n=3 then\n begin\n writeln(g,1);writeln(g,n);\n end else\n if n=5 then\n begin\n writeln(g,2);\n writeln(g,2,' ',3);\n end else\n begin\n writeln(g,3);\n for i:=2 to b div 2 do\n if (ktnt(i))and(ktnt(b-i)) then\n begin\n writeln(g,a,' ',i,' ',b-i);\n break;\n end;\n end;;\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k,j:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n j:=(n-3) div 2;\n k:=j;\n if j mod 2=0 then\n begin\n while prime(k)=false do\n begin\n dec(j); inc(k);\n end;\n end\n else\n begin\n while (prime(k)= false) do\n begin\n dec(k,2);\n inc(j,2);\n end;\n end;\n writeln(j,' ',k);\n end;\nend."}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k,j:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n j:=(n-3) div 2;\n k:=j;\n if j mod 2=0 then\n begin\n while prime(j)=false do\n begin\n dec(j); inc(k);\n end;\n end\n else\n begin\n while (prime(k)= false) do\n begin\n dec(k,2);\n inc(j,2);\n end;\n end;\n writeln(j,' ',k);\n end;\nend."}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n n:=n-3;\n k:=n;\n while prime(k)= false do\n dec(k);\n write(n-k,' ',k);\n end;\nend."}, {"source_code": "{$mode objfpc}\nvar n,k:int64;\n i,j:integer;\n a:array [1..1000000] of boolean;\nbegin\n readln(n);\n writeln(3);\n if n mod 2 =0 then\n begin write(2,' '); n:=n-2; k:=n-2; end\n else\n begin write(3,' '); n:=n-3; k:=n-3; end;\n fillchar(a,sizeof(a),true);\n for i:= 2 to trunc(sqrt(n)) do\n if a[i] then\n for j:=i to n div i do\n a[i*j]:=false;\n while a[k]=false do\n dec(k);\n write(k,' ',n-k);\nend."}, {"source_code": "{$mode objfpc}\nfunction prime(x:int64):boolean;\nvar i:integer;\n flag:boolean;\nbegin\n flag:=x>1;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n flag:=false;\n break\n end;\n if flag then prime:=flag\n else prime:= false;\nend;\nvar n,k,j:int64;\n i:integer;\nbegin\n readln(n);\n if prime(n) then\n begin\n writeln(1);\n writeln(n);\n end\n else\n if prime(n-2) then\n begin\n writeln(2);\n writeln(2,' ',n-2);\n end\n else\n begin\n writeln(3);\n write(3,' ');\n j:=(n-3) div 2;\n k:=j;\n if j mod 2=0 then begin dec(j); inc(k); end\n else\n begin\n while (prime(k)= false) do\n begin\n dec(k,2);\n inc(j,2);\n end;\n end;\n writeln(j,' ',k);\n end;\nend."}, {"source_code": "var d,r:array[0..5000007] of int64;\n\tz,i,n,x,ind:longint;\n\nprocedure resh;\n\tvar j,ii:longint;\nbegin\n\tr[1]:=0;\n\tfor ii:=2 to z do\n\t\tif r[ii] = 0 then \tbegin\n\t\t\t\t\t\t\t\tj:=ii+ii;\n\t\t\t\t\t\t\t\twhile j<=z do\n\t\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\t\tr[j]:=ii;\n\t\t\t\t\t\t\t\t\t\tinc(j,ii);\n\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\tend;\nend;\n\nfunction prov(f:longint):byte;\n\tvar p:byte;\n\t\th:longint;\nbegin\n\tp:=0;\n\tfor h:=2 to round(sqrt(f)) do\n\t\tif f mod h=0 then begin p:=1; break; end;\n\tprov:=p;\nend; \n\nbegin\n\tz:=5000000;\n\tfillchar(r,sizeof(r),0);\n\tresh;\n\treadln(x);\n\tif x<4 then begin writeln(1); writeln(x); halt; end;\n\tind:=x;\n\twhile ind>=2 do\n\t\tbegin\n\t\t\tif prov(ind) = 0 then begin\n\t\t\t d[1]:=ind;\n\t\t\t n:=x-ind;\n\t\t\t break;\n\t\t\t end;\n\t\t\tdec(ind);\n\t\tend;\n//\twriteln(ind,' ',n);\t\n\tif n=0 then begin writeln(1); writeln(d[1]); halt; end;\n\tif r[n]=0 then begin writeln('2'); writeln(d[1],' ',n); halt; end;\n\tfor i:=1 to z do\n\t\tif (r[i]=0) and (r[n-i]=0) then begin writeln(3); write(d[1],' ',i,' ',n-i); halt; end;\nend.\n\n\n"}, {"source_code": "\nvar i,n,j:longint;\n pri:array[0..1000000] of boolean;\nfunction prime(loc:longint):boolean;\nvar i:longint;\nbegin\n if loc<2 then exit(false);\n if loc=2 then exit(true);\n for i:=2 to trunc(sqrt(loc))do\n if loc mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n fillchar(pri,sizeof(pri),true);\n for i:=2 to 1000000 do\n begin\n if pri[i]=false then continue;\n j:=i shl 1;\n while j<=1000000 do begin pri[j]:=false;j:=j+i;end;\n end;\n if prime(n)=true then begin writeln(1);writeln(n);halt;end;\n if prime(n-2)=true then begin writeln(2);writeln('2 ',n-2);halt;end;\n if prime(n-4)=true then begin writeln(3);writeln('2 2 ',n-4);halt;end;\n if prime((n-2) shr 1)=true then begin writeln(3);writeln('2 ',(n-2) shr 1,' ',(n-2) shr 1);halt;end;\n for i:=n downto 3 do\n if (i and 1=1) and (prime(i)=true) then break;\n\n for j:=3 to n do\n if (j and 1=1) and (pri[j]=true) and (pri[n-i-j]=true) then\n begin\n writeln(3);\n writeln(i,' ',j,' ',n-i-j);\n halt;\n end;\n\nend."}], "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3"} {"source_code": "var a,i:longint;\n s:array [1..1000] of longint;\nbegin\n read(a);\n for i:=1 to a do read(s[i]);\n if (s[1])mod(2)=0 then begin write('No'); exit; end;\n if (s[a])mod(2)=0 then begin write('No'); exit; end;\n if (a)mod(2)=0 then begin write('No'); exit; end;\n write('Yes');\nend.", "positive_code": [{"source_code": "var l,r,i,n,count:longint;\n\t\tA:array[1..111] of longint;\nBegin\n\tReadln(n);\n\tFor i:=1 to n do Read(A[i]);\n\tl:=1;\n\tcount:=1;\n\tIf not Odd(A[1]) then\n\t\tBegin\n\t\t\tWriteln('No');\n\t\t\thalt;\n\t\tEnd;\n\n\tFor i:=1 to n do\n\t\tBegin\n\t\t\tIf Odd(A[i]) and Odd(i-l+1) then r:=i;\n\t\tEnd;\n\n\tIf (r0) and (t mod 2<>0) then write(g,'Yes')\n else write(g,'No');\n end;\n close(F);\n close(G);\nend."}, {"source_code": "var\nn,m:longint;\na:array[1..100]of longint;\nbegin\nreadln(n);\nfor m:=1 to n do\nread(a[m]);\nif (a[1] mod 2=1) and\n(a[n] mod 2=1) and (n mod 2=1)\nthen write('Yes') else\nwrite('No'); end."}, {"source_code": "var\n n,i:longint;\n f:array[1..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(f[i]);\n end;\n if n mod 2=0 then\n begin\n write('No');\n exit;\n end;\n if f[1] mod 2=0 then\n begin\n write('No');\n exit;\n end;\n if f[n] mod 2=0 then\n begin\n write('NO');\n exit;\n end\n else write('Yes');\nend."}, {"source_code": "var\n n,i,j:longint;\n a:array[1..10000] of longint;\nbegin\n readln (n);\n for i:=1 to n do read(a[i]);\n if (n mod 2<>0)and(a[1] mod 2<>0)and(a[n] mod 2<>0) then writeln ('YES') else\n begin\n writeln ('NO');\n end;\nend.\n\n"}, {"source_code": "var\n a:array[0..200] of longint;\n i,n:longint;\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n //if odd(n) and odd(a[1]) and odd(a[n]) then writeln('Yes')\n if odd(n*a[1]*a[n]) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=0 to n do read(a[i]);\n if ( n mod 2 =1 ) and (a[0] mod 2=1) and (a[n-1] mod 2=1) then write('YES') else write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..10100] of integer; begin readln(n); for i:=0 to n do read(a[i]); if (a[0] mod 2=1) and (a[n-1] mod 2=1) and (n mod 2=1) then write('YES') else write('NO'); end."}, {"source_code": "var i,j,k,t,s,n:longint;\n\tf:boolean;\n\ta,b:array[-5..500]of boolean;\n c:array[-5..500]of longint;\nbegin\n\treadln(n);\n\tfor i:=1 to n do read(c[i]);\n\t//fillchar(a,sizeof(a),false);\n\t//fillchar(b,sizeof(b),false);\n\tif n mod 2=0 then begin writeln('No');exit;end;\n\tif odd(c[1]) then else begin writeln('No');exit;end;\n\tif odd(c[n]) then else begin writeln('No');exit;end;\n\twriteln('Yes');\n\t{if odd(c[1]) then begin\n\t\tif odd(c[2]) then b[1]:=true;//目前1种方案,且从偶数位开始为T\n\t\ta[0]:=true;//目前0种方案,且从奇数位开始为T\n\t\tfor i:=2 to n-1 do if odd(c[i]) and odd(c[i+1]) then begin\n\t\t\tf:=false;\n\t\t\tif odd(i) then begin\n\n\t\t\t\tfor j:=i downto 0 do\n\t\t\t\tif a[j] then begin\n\t\t\t\t\tb[j+1]:=true;\n\t\t\t\tend;\n\t\t\tend else begin\n\t\t\t\tfor j:=i downto 0 do\n\t\t\t\tif b[j] then begin\n\t\t\t\t\ta[j+1]:=true;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\n\t\tif odd(i) then begin\n\t\t\tfor j:=i downto 0 do if j mod 2=0 then \n\t\t\tif a[j] then begin writeln('Yes');exit;end;\n\t\tend else begin\n\t\t\tfor j:=i downto 0 do\n\t\t\tif b[j] then begin writeln('Yes');exit;end;\n\t\tend;\n\tend;\n\twriteln('No');}\nend.\n"}, {"source_code": "var\n n,i,j:longint;\n a:array[0..100] of longint;\n f:array[0..100,0..1] of boolean;\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n fillchar(f,sizeof(f),false);\n f[0,0]:=true; a[0]:=1;\n for i:=1 to n do\n if odd(a[i]) then\n begin\n for j:=i - 1 downto 0 do\n if odd(i - j) and odd(a[j]) and odd(a[j + 1]) then\n begin\n f[i,0]:=f[i,0] or f[j,1];\n f[i,1]:=f[i,1] or f[j,0];\n end;\n end;\n if f[n,1] then write('YES')\n else write('NO');\n //close(input); close(output);\nend.\n"}, {"source_code": "var n,i:longint;\n a:array[1..100] of longint;\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nIF n mod 2=0 then\n begin\n write('NO');\n halt; \n end;\nIF(a[1] mod 2 = 0) or (a[n] mod 2 = 0 ) then\n begin\n write('NO');\n halt;\n end;\nwrite('YES');\nend."}, {"source_code": "var n,i:longint;\n a:array[1..100] of longint;\n\nprocedure xuli;\n begin\n IF(a[1] mod 2 = 0) or (a[n] mod 2 = 0 ) or (n mod 2=0)then\n begin\n write('NO');\n exit;\n end;\n write('YES');\n end;\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nxuli;\nend."}, {"source_code": "const\n fin='431_a.inp';fon='431_a.out';\nvar a:array[1..1000] of boolean;i,j,n,k,l,e:longint;kq:boolean;\nbegin\n//assign(input,fin);\n//reset(input);\n//assign(output,fon);\n//rewrite(output);\nreadln(n);\nfor i:=1 to n do\n begin\n read(l);\n if l mod 2=1 then a[i]:=true;\n end;\nif (a[1]=true)and(a[n]=true)and(n mod 2=1) then writeln('YES')\nelse writeln('NO');\nclose(input);close(output);\nend."}, {"source_code": "var n,i,j,k:longint;\n sh:array[1..10000] of longint;\nbegin\n read(n);\n for i:=1 to n do\n read(sh[i]);\n if n mod 2=0 then writeln('No')\n else\n if (sh[1] mod 2=0)or(sh[n] mod 2=0) then writeln('No')\n else\n if (sh[1] mod 2=1)and(sh[n] mod 2=1) then writeln('Yes');\nend."}, {"source_code": "const fi='431A.inp';\n fo='431A.out';\nvar n,i:longint;\n a:array[0..1000005] of longint;\nprocedure mo;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n\nbegin\n \n readln(n);\n for i:=1 to n do\n read(a[i]);\n if (a[1] mod 2 <> 0) and(a[n] mod 2 <> 0) then\n begin\n if n mod 2 <> 0 then\n writeln('YES')\n else\n writeln('NO');\n end\n else\n writeln('NO');\nend.\n"}, {"source_code": "var n,i,dem:longint;\na:array[0..105] of longint;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i] mod 2=0 then inc(dem);\n end;\nend;\nprocedure xuli;\nbegin\n if (a[1] mod 2=0) or (a[n] mod 2=0) then\n begin\n writeln('NO');\n halt;\n end;\n if n mod 2<>0 then\n begin\n writeln('YES');\n halt;\n end;\n //if dem=0 then writeln('NO') else writeln('YES');\n write('NO');\nend;\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend."}, {"source_code": "\nvar a: Array [1..100] of LongInt;\n n, i: LongInt;\n\t\nbegin\n\n readln (n);\n for i := 1 to n do begin\n read (a[i]);\n end;\n \n if (n mod 2 = 1) and (a[1] mod 2 = 1) and (a[n] mod 2 = 1) then\n writeln ('Yes')\n else\n writeln ('No');\n\nend."}, {"source_code": "var n,i,j,k:longint;\n sh:array[1..10000] of longint;\nbegin\n read(n);\n for i:=1 to n do\n read(sh[i]);\n if n mod 2=0 then writeln('No')\n else\n if (sh[1] mod 2=0)or(sh[n] mod 2=0) then writeln('No')\n else\n if (sh[1] mod 2=1)and(sh[n] mod 2=1) then writeln('Yes');\nend."}, {"source_code": "var\nn,i:integer;\na:array[1..100]of integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\nread(a[i]);\nif n mod 2 = 0 then begin writeln('NO');exit;end;\nif a[1] mod 2 = 0 then begin writeln('NO');exit;end\nelse if a[n] mod 2 = 0 then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var n,i,j,kount:byte;\n a:array[0..100] of byte;\nbegin\n readln(n);\n for n:=1 to n do read(a[n]);\n i:=1;//kount:=0;\n repeat\n if a[i] mod 2 =0 then begin write('No'); halt; end;\n for j:=n downto i-1 do if (a[j] mod 2<>0) and ((j-i+1) mod 2 <>0) then break;\n if j=i-1 then begin write('No'); halt; end\n else begin i:=j+1; inc(kount); end;\n until i>n;\n if kount mod 2 <>0 then write('Yes') else write('No'); \nend."}, {"source_code": "var n,i:longint ;\n a:array[1..10000] of longint ;\nbegin \n readln(n) ;\n\t for i:=1 to n do \n\t read(a[i]) ;\n\t if n mod 2=0 then writeln('No') \n\t else \n\t if (a[n] mod 2=1) and (a[1] mod 2=1) then writeln('Yes')\n\t\t else writeln('No') ;\nend."}, {"source_code": "Var a:array[1..100] of Longint;\n n,i:longint;\nProcedure Print(i:integer);\nBegin\n If i=0 Then Write('No') Else Write('Yes');\n Halt;\nEnd;\nBegin\n Readln(n);\n For i:=1 to n do Read(a[i]);\n If n and 1=0 Then Print(0);\n If (a[1] and 1=0) or (a[n] and 1=0) Then Print(0);\n Print(1);\nEnd.\n"}, {"source_code": "var n,i:longint ;\n a:array[1..10000] of longint ;\nbegin \n readln(n) ;\n\t for i:=1 to n do \n\t read(a[i]) ;\n\t if n mod 2=0 then writeln('No') \n\t else \n\t if (a[n] mod 2=1) and (a[1] mod 2=1) then writeln('Yes')\n\t\t else writeln('No') ;\nend."}, {"source_code": "var\n a:array[0..200] of longint;\n i,n:longint;\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n //if odd(n) and odd(a[1]) and odd(a[n]) then writeln('Yes')\n if odd(n*a[1]*a[n]) then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var\n a:array[0..200] of longint;\n i,n:longint;\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n if (n*a[1]*a[n]) mod 2=1 then writeln('Yes')\n else writeln('No');\nend."}, {"source_code": "var\n a:array[1..100]of integer;\n n,i:integer;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n if (n mod 2=1)and(a[1]mod 2=1)and(a[n]mod 2=1) then writeln('Yes')\n else writeln('No');\n readln;\nend."}, {"source_code": "const fi='849A.inp';\n fo='849A.out';\nvar a:array[0..101] of longint;\n f:array[0..101,0..101,1..2] of boolean;\n n,i,j:longint;\nprocedure ran;\n var i:longint;\n begin\n readln(n);\n for i:=1 to n do read(a[i]);\n end;\nprocedure conan(u,v:longint);\n var i:longint;\n begin\n if (a[u] mod 2=0) or (a[v] mod 2=0) then exit;\n if (v-u) mod 2 =0 then\n begin\n f[u,v,1]:=true;\n if u=v then exit;\n end;\n for i:=u to v do\n begin\n if (f[u,i,2]) and (f[i+1,v,2]) then f[u,v,2]:=true;\n if (f[u,i,1]) and (f[i+1,v,1]) then f[u,v,2]:=true;\n end;\n for i:=u to v do\n begin\n if (f[u,i,2]) and (f[i+1,v,1]) then f[u,v,1]:=true;\n if (f[u,i,1]) and (f[i+1,v,2]) then f[u,v,1]:=true;\n end;\n end;\nbegin\n{assign(input,fi);\nreset(input);\nassign(output,fo);\nrewrite(output);}\n ran;\n for i:=n downto 1 do\n for j:=i to n do conan(i,j);\n if f[1,n,1] then writeln('Yes') else writeln('No');\nend."}, {"source_code": " \n const nn=1600000; nnn=1200000;eps=0.0000000001;\n label 1,2,3;\n var k,step, i,j:longint;\n jj,ii,p3,p4, p1,p2,t1,t2,p,ost,q,n,ot,t,kk:int64;\n pal:array[-20..6000,-20..6000] of boolean;\n pp:extended;\n zz,z,c,d,x,y,a,b:array[-1002..2000000] of int64;\n ddnew,ddold:array[0..200,0..4040] of integer;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss:string;\n\n flagg,flag,flag1:boolean;\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n); for i:=1 to n do read(a[i]);\n if odd(a[1])and odd(a[n])and odd(n) then write('YES') else write('NO');\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "Var n, a, b, i : longint;\n\nbegin\n Readln( n );\n Read( a );\n b:=a;\n For i:=1 to n-1 do\n Read( b );\n if (n and 1 = 1) and (a and 1 = 1) and (b and 1 = 1) then Writeln( 'Yes' ) else Writeln( 'No' );\nend."}, {"source_code": "const fi='';\n fo='';\nvar n,m,i,j,k,kq:longint;\n a:array[1..1000000] of longint;\n\nprocedure openf;\nbegin\n assign(input,fi); assign(output,fo);\n reset(input); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure inkq;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[1] mod 2=0) or (a[n] mod 2=0) then begin writeln('No'); exit; end;\n if n mod 2=0 then write('No') else write('Yes');\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "var i,j,k,l,m,n:longint;\n a:array[1..5000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n readln;\n if (a[1]mod 2=0)or(a[n] mod 2=0)or(n mod 2=0) then begin\n writeln('No');\n halt;\n end;\n writeln('Yes');\nend."}, {"source_code": "program mfs;\nvar\ndp,ep,a:array[0..1000]of longint;\nn,i,j:longint;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfillchar(dp,sizeof(dp),0);\nfillchar(ep,sizeof(ep),0);\nif odd(a[1])=false then begin writeln('NO'); halt; end else dp[1]:=1;\ndp[0]:=0;ep[0]:=1;ep[1]:=0;\nfor i:=2 to n do\nbegin\n\tif odd(a[i]) then \n\tfor j:=0 to i-1 do\n\tbegin\n\tif (odd(i-j))and(odd(a[j+1]))and(odd(a[i]))and(ep[j]=1) then dp[i]:=1;\n\tif (odd(i-j))and(odd(a[j+1]))and(odd(a[i]))and(dp[j]=1) then ep[i]:=1;\n\t//write(j,' ',dp[i],' ',ep[i],' ',a[j+1],' ',a[i-1],' ',dp[j],' ',ep[j],' ',i-j,' ');\n\tend;\n//writeln;\n//writeln(i,' ',dp[i],' ',ep[i]);\nend;\n\tif dp[n]=1 then writeln('YES') else writeln('NO');\n//for i:=1 to n do writeln(dp[i],' ');\n//for i:=1 to n do writeln(ep[i],' ');\nend."}, {"source_code": "var a,i:longint;\n s:array [1..1000] of longint;\nbegin\n read(a);\n for i:=1 to a do read(s[i]);\n if (s[1])mod(2)=0 then begin write('No'); exit; end;\n if (s[a])mod(2)=0 then begin write('No'); exit; end;\n if (a)mod(2)=0 then begin write('No'); exit; end;\n write('Yes');\nend."}, {"source_code": "program z1;\nvar n,i:integer; a:array[1..100]of integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a[i]);\nif (a[n] mod 2=0)or(a[1] mod 2=0)or(n mod 2=0) then write('NO')\nelse write('Yes');\nend."}], "negative_code": [{"source_code": " \n const nn=1600000; nnn=1200000;eps=0.0000000001;\n label 1,2,3;\n var k,step, i,j:longint;\n jj,ii,p3,p4, p1,p2,t1,t2,p,ost,q,n,ot,t,kk:int64;\n pal:array[-20..6000,-20..6000] of boolean;\n pp:extended;\n zz,z,c,d,x,y,a,b:array[-1002..2000000] of int64;\n ddnew,ddold:array[0..200,0..4040] of integer;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss:string;\n\n flagg,flag,flag1:boolean;\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n); for i:=1 to n do read(a[i]);\n if odd(a[1])and odd(a[n]) then write('YES') else write('NO');\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar n,m,i,j,k,kq:longint;\n a:array[1..1000000] of longint;\n\nprocedure openf;\nbegin\n assign(input,fi); assign(output,fo);\n reset(input); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure inkq;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[1] mod 2=0) or (a[n] mod 2=0) then begin writeln('No'); exit; end;\n k:=1; kq:=0;\n for i:=1 to n do if (a[i] mod 2=1) then\n begin\n if k=0 then begin k:=i; continue; end;\n if i-k mod 2=0 then begin k:=0; inc(kq); end;\n end;\n if (kq mod 2=1) or (n=1) then write('Yes') else write('No');\n //\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar n,m,i,j,k,kq:longint;\n a:array[1..1000000] of longint;\n\nprocedure openf;\nbegin\n assign(input,fi); assign(output,fo);\n reset(input); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure inkq;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[1] mod 2=0) or (a[n] mod 2=0) then begin writeln('No'); exit; end;\n k:=1; kq:=0;\n for i:=1 to n do if (a[i] mod 2=1) then\n begin\n if k=0 then begin k:=i; continue; end;\n if i-k mod 2=0 then begin k:=0; inc(kq); end;\n end;\n if (kq mod 2=1) and (k=0) then write('Yes') else write('No');\n\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar n,m,i,j,k,kq:longint;\n a:array[1..1000000] of longint;\n\nprocedure openf;\nbegin\n assign(input,fi); assign(output,fo);\n reset(input); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure inkq;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[1] mod 2=0) or (a[n] mod 2=0) then begin writeln('No'); exit; end;\n k:=1; kq:=0;\n for i:=1 to n do if (a[i] mod 2=1) then\n begin\n if k=0 then begin k:=i; continue; end;\n if i-k mod 2=0 then begin k:=0; inc(kq); end;\n end;\n if (kq mod 2=1) or (n=1) then write('Yes') else write('No');\n write(kq);\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar n,m,i,j,k,kq:longint;\n a:array[1..1000000] of longint;\n\nprocedure openf;\nbegin\n assign(input,fi); assign(output,fo);\n reset(input); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure inkq;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n if (a[1] mod 2=0) or (a[n] mod 2=0) then begin writeln('No'); exit; end;\n k:=1; kq:=0;\n for i:=1 to n do if (a[i] mod 2=1) then\n begin\n if k=0 then begin k:=i; continue; end;\n if i-k mod 2=0 then begin k:=0; inc(kq); end;\n end;\n if (kq mod 2=1) or (n=1) then write('Yes') else write('No');\n \nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "program z1;\nvar n,i:integer; a:array[1..100]of integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a[i]);\nif (a[n] mod 2=0)or(a[1]<>0)or(n mod 2=0) then write('NO')\nelse write('Yes');\nend."}, {"source_code": "program z1;\nvar n,i:integer; a:array[1..100]of integer;\nbegin\nread(n);\nfor i:=1 to n do\nread(a[i]);\nif (a[n] mod 2=0)or(a[1] mod 2<>0)or(n mod 2=0) then write('NO')\nelse write('Yes');\nend."}, {"source_code": "var\nn,m,p,l:longint;\na:array[1..100]of longint;\nbegin\nreadln(n);\nfor m:=1 to n do\nread(a[m]);\nif (a[1] mod 2=0)\nor (a[n] mod 2=0)\nthen begin write('No');\nhalt; end;\nif (a[n] mod 2=1) and \n(a[1] mod 2=1) and (n mod 2=1)\nthen begin write('Yes');\nhalt; end;\nfor m:=2 to n do\nif (a[m] mod 2=1)\nand (a[m-1] mod 2=1)\nthen inc(p);\nif p mod 2=1 then\nbegin write('No');\nhalt; end;\n\np:=0; l:=0;\nfor m:=2 to n do\nif (a[m-1] mod 2=1) and\n(a[m] mod 2=1) and\n((m-1-p) mod 2=1)\nthen begin p:=m-1;\ninc(l); end;\nif l mod 2=1 then write('Yes')\nelse write('No'); end."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n if ( n mod i =1 ) and (a[0] mod i=1) and (a[n-1] mod i=1) then write('YES') else write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n if ( n mod 2 =1 ) and (a[0] mod 2=1) and (a[n-1] mod 2=1) then write('YES'); write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..10100] of integer; begin readln(n); for i:=0 to n do read(a[i]); if (n mod 2=0) and (a[0] mod 2=0) and (a[n-1] mod 2=0) then write('YES') else write('NO'); end."}, {"source_code": "var n,i: integer; a: array[0..10100] of integer; begin readln(n); for i:=0 to n do read(a[i]); if (a[0] mod 2=0) or (a[n-1] mod 2=0) and (n mod 2=0) then write('NO') else write('YES'); end."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=0 to n do read(a[i]);\n if ( n mod 2 =1 ) and (a[0] mod 2=1) and (a[n-1] mod 2=1) then write('YES'); write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=0 to n do\n if ( n mod 2 =1 ) and (a[0] mod 2=1) and (a[n-1] mod 2=1) then write('YES'); write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..10100] of integer; begin readln(n); for i:=0 to n do read(a[i]); if (n mod 2=0) and (a[0] mod 2=0) and (a[n-1] mod 2=0) then write('NO') else write('YES'); end."}, {"source_code": "var n,i: integer; a: array[0..100] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n if ( n mod i =1 ) and (a[0] mod i=1) and (a[n-1] mod i=1) then write('YES');write('NO');\nend."}, {"source_code": "var n,i: integer; a: array[0..10100] of integer; begin readln(n); for i:=0 to n do read(a[i]); if (a[0] mod 2=0) or (a[n-1] mod 2=0) and (n mod 2=0) then write('YES') else write('NO'); end."}, {"source_code": "var i,j,k,t,s,n:longint;\nf:boolean;\n\ta,b:array[-5..500]of boolean;\n c:array[-5..500]of longint;\nbegin\n\treadln(n);\n\tfor i:=1 to n do read(c[i]);\n\tif n mod 2=0 then begin writeln('No');exit;end;\n\tif odd(c[1]) then begin\n\t\tb[1]:=true;//目前1种方案,且从偶数位开始为T\n\t\ta[0]:=true;//目前0种方案,且从奇数位开始为T\n\t\tfor i:=2 to n do if odd(c[i]) then begin\n\t\t\tf:=false;\n\t\t\tif odd(i) then begin\n \t\t\t\n\t\t\t\tfor j:=i+1 downto 0 do\n\t\t\t\tif a[j] then begin\n\t\t\t\t\tb[j+1]:=true;f:=true;// writeln(j+1);\n\t\t\t\t\tif i=n then if odd(j+1) then\n\t\t\t\t\t\tbegin writeln('Yes');exit;end;\n\t\t\t\tend;\n\t\t\tend else begin\n\t\t\t\t\n\t\t\t\tfor j:=i+1 downto 0 do\n\t\t\t\tif b[j] then begin\n\t\t\t\t\ta[j+1]:=true;f:=true;// writeln(j+1);\n\t\t\t\t\tif i=n then if odd(j+1) then\n\t\t\t\t\t\tbegin writeln('Yes');exit;end;\n\t\t\t\tend;\n\t\t\tend;\n\t\t\tif f then else begin writeln('No');exit;end;\n\t\tend;\n\tend;\n\twriteln('No');\nend.\n"}, {"source_code": "var\nn,i:integer;\na:array[1..100]of integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\nread(a[i]);\nif a[1] mod 2 = 0 then writeln('NO')\nelse if n mod 2 = 0 then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var\nn,i,k:integer;\na:array[1..100]of integer;\nbegin\nreadln(n);\nif n mod 2 = 0 then writeln('NO')\nelse for i:= 1 to n do\nif a[i]mod 2 <>0 then inc(k);\nif k mod 2 <>0 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var\nn,i,k:integer;\na:array[1..100]of integer;\nbegin\nreadln(n);\nif n mod 2 = 0 then writeln('NO')\nelse for i:= 1 to n do begin\nread(a[i]);\nif a[i]mod 2 <>0 then inc(k);\nend;\nif k mod 2 <>0 then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var n,i,j:byte;\n a:array[0..100] of byte;\nbegin\n readln(n);\n for n:=1 to n do read(a[n]);\n i:=1;\n repeat\n if a[i] mod 2 =0 then begin write('No'); halt; end;\n for j:=n downto i-1 do if (a[j] mod 2<>0) and ((j-i+1) mod 2 <>0) then break;\n if j=i-1 then begin write('No'); halt; end\n else i:=j+1;\n until i>n;\n write('Yes');\nend."}, {"source_code": "program asd;\nconst finput='849_A.inp';\n foutput='849_A.out';\n Maxn=100;\nvar a,x:array[0..Maxn*MAxN] of longint;\n n:longint;\n\nProcedure Nhap;\nvar i:longint;\nbegin\n //assign(input,finput);reset(input);\n //assign(output,foutput);rewrite(output);\n read(n);\n for i:=1 to n do\n read(a[i]);\nend;\n\nProcedure Vet(i:longint);\nvar j:longint;\nbegin\n if i>n then exit;\n for j:=x[i-1]+1 to n+1 do\n if (a[j-1] mod 2<>0)and(a[j] mod 2<>0)and((j-1-x[i-1]+1) mod 2<>0) then\n begin\n x[i]:=j;\n if ((n-x[i]+1) mod 2<>0)and(i mod 2<>0) then\n begin\n write('Yes');\n halt;\n end;\n Vet(i+1);\n end;\nend;\n\nProcedure Xuli;\nbegin\n if (a[1] mod 2<>0)and(a[n] mod 2<>0) then\n begin\n a[n+1]:=1;\n x[1]:=1;\n Vet(2);\n write('No');\n end\n else\n begin\n write('No');\n halt;\n end;\nend;\nbegin\n Nhap;\n Xuli;\nend.\n"}], "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db"} {"source_code": "program project1;\n\n{$mode objfpc}\n\ntype\n TPoint = record\n X: Integer;\n Y: Integer;\n end;\n\noperator = (A, B: TPoint): Boolean;\nbegin\n Result := (A.X = B.X) and (A.Y = B.Y);\nend;\n\nvar\n Position, Destination: TPoint;\n Rotates, MaxX, MaxY, MinX, MinY: Integer;\n Direction: (Left, Right, Up, Down);\n\nbegin\n with Destination do\n ReadLn(X, Y);\n with Position do\n begin\n X := 0;\n Y := 0;\n end;\n Rotates := 0;\n Direction := Right;\n MinX := 0;\n MinY := 0;\n MaxX := 0;\n MaxY := 0;\n while Position <> Destination do\n begin\n case Direction of\n Left:\n if Position.X < MinX then\n begin\n Rotates += 1;\n Direction := Down;\n MinX := Position.X;\n end\n else\n Position.X -= 1;\n Right:\n if Position.X > MaxX then\n begin\n Rotates += 1;\n Direction := Up;\n MaxX := Position.X;\n end\n else\n Position.X += 1;\n Up:\n if Position.Y > MaxY then\n begin\n Rotates += 1;\n Direction := Left;\n MaxY := Position.Y;\n end\n else\n Position.Y += 1;\n Down:\n if Position.Y < MinY then\n begin\n Rotates += 1;\n Direction := Right;\n MinY := Position.Y;\n end\n else\n Position.Y -= 1;\n end;\n end;\n WriteLn(Rotates);\n ReadLn;\nend.", "positive_code": [{"source_code": "var\n n,m,i,j,x,y,q,w,e,z,c,xx,yy,x1,y1:longint;\nprocedure pr(x,y:longint);\nbegin\n if(x=xx)and(y=yy)then begin writeln(e);halt;end;\nend;\n\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n readln(xx,yy);\n q:=1;\n while true do\n begin\n for i:=x to x+q do pr(i,y);\n inc(x,q);\n inc(e);\n for i:=y to y+q do pr(x,i);\n inc(y,q);\n inc(e);inc(q);\n for i:=x downto x-q do pr(i,y);\n dec(x,q);\n inc(e);\n for i:=y downto y-q do pr(x,i);\n dec(y,q);\n inc(e);inc(q);\n end;\nend.\n\n\n"}, {"source_code": "Var x,y:longint;\n begin\n read(x,y);\n if (x>=0) and (y>=0) then begin\n if (x<=1) and (y=0) then begin writeln(0); halt; end;\n if x>=y then writeln((x-1)*4+1)\n else writeln((y-1)*4+2);\n end\n else if (x<=0) and (y>=0) then begin\n if abs(x)<=y then writeln((y-1)*4+2)\n else writeln((abs(x)-1)*4+3);\n end\n else if (x<=0) and (y<=0) then begin\n if abs(x)>=abs(y) then writeln((abs(x)-1)*4+3)\n else writeln((abs(y))*4);\n end\n else if (x>=0) and (y<=0) then begin\n if x-1<=abs(y) then writeln(abs(y)*4)\n else writeln((abs(x)-1)*4+1);\n end;\n end.\n"}, {"source_code": "var\n x,y,nowx,nowy,nextx,nexty,tot:longint;\n\nfunction onsegment(x1,y1,x2,y2,x3,y3:longint):boolean;\nbegin\n if (x1=x3) and (x2=x3) then\n exit((y3-y2)*(y1-y3)>=0)\n else\n if (y1=y3) and (y2=y3) then\n exit((x3-x2)*(x1-x3)>=0);\n exit(false);\nend;\n\nbegin\n readln(x,y);\n tot:=0;\n nowx:=0;\n nowy:=0;\n nextx:=1;\n nexty:=0;\n while not onsegment(nowx,nowy,nextx,nexty,x,y) do\n begin\n nowx:=nextx;\n nowy:=nexty;\n if tot mod 4=0 then\n nexty:=-nexty+1;\n if tot mod 4=1 then\n nextx:=-nextx;\n if tot mod 4=2 then\n nexty:=-nexty;\n if tot mod 4=3 then\n nextx:=-nextx+1;\n inc(tot);\n end;\n writeln(tot);\nend."}, {"source_code": "uses math;\nvar x,y,ans,k:longint;\nbegin\n read(x,y);\n k:=max(abs(x),abs(y));\n if (x=0) and (y=0) then begin write(0); halt; end;\n ans:=(k-1)*4+1;\n if (y=-k) and (x<>-k) then write(ans+3)\n else if (x=k) and (y<>-k+1) then write(ans)\n else if (x=k) then write(ans-1)\n\n else if (x=-k) and (y=k) then write(ans+1)\n else if (x=-k) then write(ans+2)\n else if (xkx)or(y<>ky) do begin\nif flag then begin\nif a>=0 then inc(a);\nif a>0 then for i:=1 to a do begin inc(x); if (x=kx)and(y=ky) then begin write(m);exit;end;end;\nif a<0 then dec(a);\nif a<0 then for i:=-1 downto a do begin dec(x); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\na:=-a;end\nelse begin if b>=0 then inc(b);\nif b>0 then for i:=1 to b do begin inc(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\nif b<0 then dec(b);\nif b<0 then for i:=-1 downto b do begin dec(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\nb:=-b; end;\ninc(m);\n\nflag:=not flag;\nend;\nwrite(m);\nend."}, {"source_code": "var\n a, b, c, d, ans, k, f, i: int64;\n\nbegin\n ans := 0;\n readln(a, b);\n c := 0;\n d := 0;\n if (a = c) and (d = b) then begin\n writeln(0);\n halt();\n end;\n f := 1;\n k := 1;\n while true do \n begin\n if f mod 2 = 1 then begin\n i := 1;\n while i <= k do \n begin\n inc(c);\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(i);\n end\n end\n else begin\n i := 1;\n while i <= k do \n begin\n dec(c);\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(i);\n end;\n end;\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(ans);\n if f mod 2 = 1 then begin\n i := 1;\n while i <= k do \n begin\n inc(d);\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(i);\n end\n end\n else begin\n i := 1;\n while i <= k do \n begin\n dec(d);\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(i);\n end;\n end;\n if (c = a) and (d = b) then begin\n writeln(ans);\n halt();\n end;\n inc(ans);\n inc(k);\n inc(f);\n end;\nend."}, {"source_code": "var x,y,i,n,j,sum,poz:integer;\n s,s1,s2:string;\n a:array [1..100] of string;\nbegin\n read(x);\n readln(y);\n if ((y=0) and (x=0)) or ((y=0) and (x=1)) then\n begin\n writeln(0);\n readln;\n readln;\n exit;\n end;\nif (y>x) and (y>=-x) then\n writeln((y-1)*4+2);\nif (y<-x) and (y>=x) then\n writeln((abs(x)-1)*4+3);\nif (y-x+1) and (y<=x) then\n writeln((x-1)*4+1);\n readln;\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils,\n Math;\n\nvar\n x, y, c, k, ans, sh, st: integer;\n\nprocedure go(i, j: integer);\nbegin\n if (i = y) and (j = x) then begin\n write(ans);\n halt(0);\n end;\n if c = sh then begin\n inc(k);\n if st = 3 then\n st := 0\n else\n inc(st);\n c := 0;\n inc(ans);\n end;\n if k = 2 then begin\n inc(sh);\n k := 0;\n end;\n if st = 0 then begin\n inc(c);\n go(i, j + 1);\n end else if st = 1 then begin\n inc(c);\n go(i + 1, j);\n end else if st = 2 then begin\n inc(c);\n go(i, j - 1);\n end else if st = 3 then begin\n inc(c);\n go(i - 1, j);\n end;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(x, y);\n st := 0;\n sh := 1;\n ans := 0;\n c := 0;\n k := 0;\n go(0, 0);\nend.\n"}, {"source_code": "const dx:array[0..3] of integer = (1,0,-1,0);\n dy:array[0..3] of integer = (0,1,0,-1);\nvar ans,q,w,x,y,i,l,k,j,m,n:longint;\n a:array[-200..200,-200..200] of boolean;\nbegin\nread(q,w);\nx:=0;\ny:=0;\ni:=0;\nans:=0;\nwhile true do\nbegin\nif (x=q) and (y=w) then break;\na[x,y]:=true;\nl:=(i+1) mod 4;\nif (x=0) and (y=0) then\n begin x:=x+dx[i]; y:=y+dy[i] end else\n begin\n if a[x+dx[l],y+dy[l]]=false then begin i:=l; inc(ans); end;\n x:=x+dx[i];\n y:=y+dy[i];\n end;\nend;\nwriteln(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+}\nuses SysUtils, Math;\n\nvar\n a: array[-100..1000] of integer;\n x, y, i, j, n, k, l, inn, jnn: integer;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n{$ENDIF}\n read(x, y);\n i := 0;\n j := 0;\n k := 1;\n l := 0;\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n while (i <> x) or (y <> j) do\n begin\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inn := i;\n while ((i <> x) or (y <> j)) and (Abs(i - inn) <> k) do\n inc(i);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n jnn := j;\n while ((i <> x) or (y <> j)) and (Abs(j - jnn) <> k) do\n inc(j);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n inc(k);\n \n inn := i;\n while ((i <> x) or (y <> j)) and (Abs(i - inn) <> k) do\n dec(i);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n\n jnn := j;\n while ((i <> x) or (y <> j)) and (Abs(j - jnn) <> k) do\n dec(j);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n inc(k);\n end;\n\nend.\n\n"}, {"source_code": "var q,ans,x,y:longint;\nfunction max(a,b:Longint):longint;\nbegin\n if a>b then max:=a else max:=b;\nend;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then writeln(0) else begin\n q:=max(abs(x),abs(y));\n ans:=4*(q-1);\n if (abs(x)=q) and (y>-x+1) and (x>0) then inc(ans,1)\n else if (abs(y)=q) and (x0) then inc(ans,2)\n else if (abs(x)=q) and (x<0) and (y<-x) then inc(ans,3)\n else if (abs(y)=q) and (y<0) and (x>y) then inc(ans,4);\n writeln(ans);\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar x,y : integer;\n xt,yt : integer;\n count : integer;\n l,r,u,d,flag : boolean;\n razdva, len,i : integer;\nbegin\nReadln(x,y);\ncount := 0;\n\nl:=false;\nu:=false;\nd:=false;\nr:=true;\n\nxt:=0;\nyt:=0;\n\nrazdva := 0;\nlen := 1;\nflag := false;\n\nIF (x = 0) and (y = 0) Then\nBegin\nwriteln('0');\nend\nelse\nBegin\n\nwhile not flag do\n begin\n\n // Право\n if r then\n begin\n for i:=1 to len do\n begin\n inc(xt);\n if (xt = x) and (yt = y) then flag := true;\n end;\n r := false;\n u := true;\n\n inc(razdva);\n if razdva = 2 then\n begin\n inc(len);\n razdva := 0;\n end;\n inc(count);\n end\n else\n // Верх\n if u then\n begin\n for i:=1 to len do\n begin\n inc(yt);\n if (xt = x) and (yt = y) then flag := true;\n end;\n u := false;\n l := true;\n\n inc(razdva);\n if razdva = 2 then\n begin\n inc(len);\n razdva := 0;\n end;\n inc(count);\n end\n else\n // Лево\n if l then\n begin\n for i:=1 to len do\n begin\n dec(xt);\n if (xt = x) and (yt = y) then flag := true;\n end;\n l := false;\n d := true;\n\n inc(razdva);\n if razdva = 2 then\n begin\n inc(len);\n razdva := 0;\n end;\n inc(count);\n end\n else\n // Низ\n if d then\n begin\n for i:=1 to len do\n begin\n dec(yt);\n if (xt = x) and (yt = y) then flag := true;\n end;\n d := false;\n r := true;\n\n inc(razdva);\n if razdva = 2 then\n begin\n inc(len);\n razdva := 0;\n end;\n inc(count);\n end;\n\n end;\n\nwriteln(count-1);\nend;\n\nend.\n"}, {"source_code": "var\n x,y,nowx,nowy,nextx,nexty,tot:longint;\n\nfunction onsegment(x1,y1,x2,y2,x3,y3:longint):boolean;\nbegin\n if (x1=x3) and (x2=x3) then\n exit((y3-y2)*(y1-y3)>=0)\n else\n if (y1=y3) and (y2=y3) then\n exit((x3-x2)*(x1-x3)>=0);\n exit(false);\nend;\n\nbegin\n readln(x,y);\n tot:=0;\n nowx:=0;\n nowy:=0;\n nextx:=1;\n nexty:=0;\n while not onsegment(nowx,nowy,nextx,nexty,x,y) do\n begin\n nowx:=nextx;\n nowy:=nexty;\n if tot mod 4=0 then\n nexty:=-nexty+1;\n if tot mod 4=1 then\n nextx:=-nextx;\n if tot mod 4=2 then\n nexty:=-nexty;\n if tot mod 4=3 then\n nextx:=-nextx+1;\n inc(tot);\n end;\n writeln(tot);\nend."}, {"source_code": "program problem1;\nuses math;\n\nvar\txx, yy, x0, y0, x, y, ans, t: longInt;\n\nbegin\n\treadln( xx, yy );\n\t\n\tt := 2;\n\tx := 0;\n\ty := 0;\n\tans := 0;\n\twhile ( true ) do\n\tbegin\n\t\tx0 := x;\n\t\ty0 := y;\n\t\tif ( (t mod 2) = 0 ) then\n\t\tbegin\n\t\t\tif ( (t mod 4) = 0 ) then\n\t\t\t\tdec( x, (t div 2) )\n\t\t\telse\n\t\t\t\tinc( x, (t div 2) );\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tif ( ((t-1) mod 4) = 0 ) then\n\t\t\t\tdec( y, (t div 2) )\n\t\t\telse\n\t\t\t\tinc( y, (t div 2) );\n\t\tend;\n\t\t\n\t\tif \t( ( x0 = x ) and ( x = xx ) and ( min( y, y0 ) <= yy ) and ( max( y, y0 ) >= yy ) ) or\n\t\t\t( ( y0 = y ) and ( y = yy ) and ( min( x, x0 ) <= xx ) and ( max( x, x0 ) >= xx ) ) then\n\t\t\t\tbreak;\n\t\t\t\t\n\t\tinc( ans );\n\t\tinc( t );\n\tend;\n\t\n\twriteln( ans );\nend.\n"}, {"source_code": "var\nx,y,i,j,n,m,k,r,t,l,tek,kol,ans,xx,yy,maxl,maxr,maxd,maxu,tekdl,nap:integer;\nbegin\nreadln(x,y);\nxx:=0;\nyy:=0;\nm:=1;\nnap:=1;\nans:=0;\ntekdl:=1;\nkol:=0;\nif (x=0) and (y=0) then begin writeln(0); exit; end;\nwhile m=1 do begin\nfor i:=1 to tekdl do begin\ninc(xx,nap);\nif (yy=y) and (xx=x) then begin writeln(ans);\nexit; end;\nend;\ninc(ans);\nfor i:=1 to tekdl do begin\ninc(yy,nap);\nif (xx=x) and (yy=y) then begin writeln(ans);\nexit;\nend;\nend;\ninc(ans);\ninc(tekdl);\nnap:=nap*(-1);\nend;\nend.\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n\nuses\n SysUtils,math;\nvar t ,ans ,a,b,x,y,qx,qy : integer;\n\nbegin\n readln(a,b);\n x := 0;\n y := 0;\n ans := 0;\n t := max(abs(a),abs(b));\n if t >= 1 then\n begin\n if (t >= 1) then\n begin\n ans := ans + 4*(t-1);\n y := -t + 1;\n x := t -1;\n end;\n if (b = y) and (a = x + 1) then writeln(ans) else\n if (b > y) and (a > x) then\n writeln(ans + 1)\n else\n if (b = -y + 1) and (a <=x) then\n writeln(ans + 2)\n else\n if (a < -x) and (b < -y+ 1) then\n writeln(ans + 3)\n else\n writeln(ans + 4);\n halt;\n end;\n if t = 0 then\n begin\n writeln(0);\n halt;\n end;\nend."}, {"source_code": "program zd1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nx,y,all,sh1,sh2,dist1,dist2,i,ans:integer;\ncurx,cury:array[0..10000]of integer;\nbegin\n readln(x,y);\n dist1 := 1;\n sh1 := 1;\n sh2 := 10;\n all := 1;\n curx[1] := 0;\n cury[1] := 0;\n ans := 100500;\nfor i := 2 to 500 do\n begin\n if(all=1)then begin\n if(sh1 mod 2 = 1)then curx[i] := curx[i-1] + dist1\n else curx[i] := curx[i-1]-dist1;\n cury[i] := cury[i-1];\n inc(sh1);\n inc(dist1);\n end\n else begin curx[i] := curx[i-1];cury[i] := curx[i];end ;\n all := -all;\n end;\n for i := 2 to 500 do\n if abs(sqrt(sqr(curx[i-1]-x)+sqr(cury[i-1]-y)) + sqrt(sqr(curx[i]-x)+\n sqr(cury[i]-y)) - sqrt(sqr(curx[i]-curx[i-1])+sqr(cury[i]-cury[i-1]))) <0.01 then begin ans := i-2;break;end;\n writeln(ans);\n readln;\n readln\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar x0,y0, x,y,xk,yk: Integer;\n p,n,i,j,t, otv: integer;\n f: Boolean;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n Readln(xk,yk);\n p:=0;\n x0:=0; y0:=0;\n x:=x0; y:=y0;\n f:= True;\n t:=1; otv:=0;\n while f do\n begin\n if (x=xk)and(y=yk) then begin otv:=p; f:=False; end;\n\n for i:=1 to t do\n begin\n Inc(x);\n if (x=xk)and(y=yk) then begin otv:=p; f:=False; end;\n end;\n Inc(p);\n for i:=1 to t do\n begin\n Inc(y);\n if (x=xk)and(y=yk) then begin otv:=p; f:=False; end;\n end;\n Inc(p); Inc(t);\n\n for i:=1 to t do\n begin\n Dec(x);\n if (x=xk)and(y=yk) then begin otv:=p; f:=False; end;\n end;\n Inc(p);\n for i:=1 to t do\n begin\n dec(y);\n if (x=xk)and(y=yk) then begin otv:=p; f:=False; end;\n end;\n Inc(p); Inc(t);\n\n end;\n\n Writeln(otv);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar i, n,x1,y1,x,y,vx,vy,l,c,ans,k : integer;\n\nprocedure ok;\nbegin\n if (x1=x) and (y1=y) then begin\n write(ans);\n halt;\n end;\nend;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n read(x,y);\n x1:=0;\n y1:=0;\n vx:=1;\n vy:=0;\n ans:=0;\n c:=1;\n k:=0;\n l:=0;\n while true do begin\n ok;\n x1:=x1+vx;\n y1:=y1+vy;\n ok;\n inc(k);\n if k=c then begin\n inc(ans);\n k:=0;\n if (vx=1) and (vy=0) then begin\n vx:=0;\n vy:=1;\n end else\n if (vx=0) and (vy=1) then begin\n vx:=-1;\n vy:=0;\n end else\n if (vx=-1) and (vy=0) then begin\n vx:=0;\n vy:=-1;\n end else\n if (vx=0) and (vy=-1) then begin\n vx:=1;\n vy:=0;\n end;\n inc(l);\n end;\n if l=2 then begin\n l:=0;\n inc(c);\n end;\n\n end;\n write(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x, y, x1, y1, x2, y2, t, ans, dx, dy: integer;\n\nbegin\n //reset(input, 'input.in');\n //rewrite(output, 'output.out');\n readln(x, y);\n if (x = 0) and (y = 0) then begin\n writeln('0');\n exit;\n end;\n ans := 0;\n dx := 0;\n dy := 0;\n x1 := 0; y1 := 0;\n t := 1;\n while true do begin\n y2 := y1;\n x2 := x1;\n if t = 1 then begin\n t := 2;\n dx := dx + 1;\n x1 := x1 + dx;\n inc(ans);\n end else if t = 2 then begin\n t := 3;\n dy := dy + 1;\n y1 := y1 + dy;\n inc(ans);\n end else if t = 3 then begin\n t := 4;\n dx := dx + 1;\n x1 := x1 - dx;\n inc(ans);\n end else begin\n t := 1;\n dy := dy + 1;\n y1 := y1 - dy;\n inc(ans);\n end;\n if ((x - x1) * (x - x2) <=0 ) and ((y - y1) * (y - y2) <=0) then begin\n writeln(ans - 1);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "Var fx,fy,x,y,dx,dy,i,j,ans,k:LongInt;\n\nProcedure Change (Var dx,dy:LongInt);\nBegin\n If (dx=1) and (dy=0)\n then Begin dx:=0; dy:=1 End\n else If (dx=0) and (dy=1)\n then Begin dx:=-1; dy:=0 End\n else If (dx=-1) and (dy=0)\n then Begin dx:=0; dy:=-1 End\n else Begin dx:=1; dy:=0; ENd;\nEnd;\n\nBegin\n //ReSet (input,'input.txt');\n //ReWrite (output,'output.txt');\n Readln (fx,fy);\n x:=0;y:=0;\n dx:=1;dy:=0;\n k:=1;\n ans:=0;\n If (x=fx) and (y=fy)\n then Begin Writeln (ans); Halt (0); ENd;\n\n For I:=1 to 1000000 do\n Begin\n For J:=1 to k do\n Begin\n x:=x+dx;y:=y+dy;\n If (x=fx) and (y=fy)\n then Begin Writeln (ans); Halt (0); ENd;\n ENd;\n Inc (ans);\n\n Change (dx,dy);\n For J:=1 to k do\n Begin\n x:=x+dx;y:=y+dy;\n If (x=fx) and (y=fy)\n then Begin Writeln (ans); Halt (0); ENd;\n ENd;\n Inc (ans);\n Change (dx,dy);\nInc (k);\n\n End;\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nx, y, N:integer;\nbegin\nread(x); readln(y);\nif (y>0)and(y>=abs(x))and(y<>x) then N:=2+(y-1)*4 else\nif (x<0) and (abs(x)>=abs(y)) and (abs(x)<>y) then N:=3+(abs(x)-1)*4 else\nif (x>0) and (((y<0)and((x-1)>abs(y))) or (y>=0)) then N:=1+(x-1)*4 else\nN:=abs(y)*4;\nif ((x=0)and(y=0))or((x=1)and(y=0)) then N:=0;\nwrite (N);\nreadln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n dx: array [0..3] of integer = (1, 0, -1, 0);\n dy: array [0..3] of integer = (0, 1, 0, -1);\n\nvar\n a: array [1..100000] of integer;\n x, y, n, m, i, j, w, t, d: integer;\n ans: integer;\n\nprocedure Panic;\nbegin\n write(ans);\n halt(0);\nend;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF}\n read(n, m);\n w := 1;\n i := 0;\n j := 0;\n t := 0;\n ans := 0;\n while (i <> n) or (j <> m) do\n begin\n inc(w);\n d := w div 2;\n x := x + d * dx[t];\n y := y + d * dy[t];\n while (i <> x) or (j <> y) do\n begin\n i := i + dx[t];\n j := j + dy[t];\n if (i = n) and (j = m) then\n Panic;\n end;\n t := (t + 1) mod 4;\n inc(ans);\n end;\n Panic;\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\ndx : array [1..4] of longint = (1,0,-1,0);\ndy : array [1..4] of longint = (0,1,0,-1);\nvar\nx,y,curx,cury,i,k,dir,ans,same : longint;\n\nprocedure check();\nbegin\n if (curx = x) and (cury = y) then\n begin\n writeln(ans);\n halt;\n end;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(x,y);\n curx:=0;\n cury:=0;\n check();\n k:=1;\n ans:=0;\n dir:=1;\n same:=0;\n while true do\n begin\n inc(same);\n for i:=1 to k do\n begin\n curx:=curx + dx[dir];\n cury:=cury + dy[dir];\n check();\n end;\n dir:=dir mod 4 + 1;\n inc(ans);\n if same = 2 then\n begin\n same:=0;\n inc(k);\n end;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+}\nuses SysUtils, Math;\n\nvar\n x, y, i, j, n, k, l, q, w: integer;\n\nbegin\n\n read(x, y);\n i := 0;\n j := 0;\n k := 1;\n l := 0;\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n while (i <> x) or (y <> j) do\n begin\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n q := i;\n while ((i <> x) or (y <> j)) and (Abs(i - q) <> k) do\n inc(i);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n w := j;\n while ((i <> x) or (y <> j)) and (Abs(j - w) <> k) do\n inc(j);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n inc(k);\n \n q := i;\n while ((i <> x) or (y <> j)) and (Abs(i - q) <> k) do\n dec(i);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n\n w := j;\n while ((i <> x) or (y <> j)) and (Abs(j - w) <> k) do\n dec(j);\n\n if (i = x) and (j = y) then\n begin\n write(l);\n Exit;\n end;\n inc(l);\n inc(k);\n end;\n\nend.\n"}, {"source_code": "Uses Math,SysUtils;\nConst dx:array[0..3] of Integer=(1,0,-1,0);\n dy:array[0..3] of Integer=(0,1,0,-1);\nVar X,Y,Xt,Yt,Xk,Yk,K,I,J:Integer;\nBegin\n ///reset(input,'input.txt');\n ///assign(output,'output.txt');\n readln(X,Y);\n J:=0;\n K:=0;\n Xt:=0;\n Yt:=0;\n Xk:=1;\n Yk:=0;\n I:=1;\n While (Xt<>X) or (Yt<>Y) do\n begin\n Xk:=Xt+dx[J]*I;\n Yk:=Yt+dy[J]*I;\n Repeat\n Inc(Xt,dx[J]);\n Inc (Yt,dy[J]);\n Until ((Xt=Xk) and (Yt=Yk)) or ((Xt=X) and (Yt=Y));\n If (Xt=X) and (Yt=Y)\n then begin\n write(K);\n Halt(0);\n end;\n J:=(J+1) mod 4;\n If J mod 2=0\n then Inc(I);\n Inc(K);\n end;\n write(K);\nEnd.\n"}, {"source_code": "program Project1;\nvar\n x,y,x0,y0,kol:int64;\n i,j:longint;\n flag:boolean;\n //привет саня!\n procedure d;\n begin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n i:=1;\n flag:=true;\n while (x0<>x) or (y0<>y) do begin\n j:=1;\n while flag and ((x0<>x) or (y0<>y)) and (j<=i) do begin\n inc(x0);\n if (x0=x) and (y0=y) then flag:=false;\n inc(j);\n end;\n if flag then inc(kol);\n j:=1;\n while flag and ((x0<>x) or (y0<>y)) and (j<=i) do begin\n inc(y0);\n if (x0=x) and (y0=y) then flag:=false;\n inc(j);\n end;\n if flag then inc(kol);\n inc(i);\n\n j:=1;\n while flag and (j<=i) and ((x0<>x) or (y0<>y)) do begin\n\n dec(x0);\n if (x0=x) and (y0=y) then flag:=false;\n inc(j);\n end;\n if flag then inc(kol);\n j:=1;\n while flag and (j<=i) and ((x0<>x) or (y0<>y)) do begin\n dec(y0);\n if (x0=x) and (y0=y) then flag:=false;\n inc(j);\n end;\n if flag then inc(kol);\n \n inc(I);\n\n\n end;\n end;\n\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n\n readln(x,y);\n\n x0:=0;\n y0:=0;\n\n d;\n write(kol);\n\n\nend.\n"}, {"source_code": "program E1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x, y, n : integer;\n\nprocedure I(x, y : integer; var n : integer);\n begin\n if (abs(x) >= abs(y)) then n := 1 + 4 * (abs(x) - 1)\n else n := 2 + 4 * (abs(y) - 1);\n end;\n\nprocedure II(x, y : integer; var n : integer);\n begin\n if (abs(y) >= abs(x)) then n := 2 + 4 * (abs(y) - 1)\n else n := 3 + 4 * (abs(x) - 1);\n end;\n\nprocedure III(x, y : integer; var n : integer);\n begin\n if (abs(x) >= abs(y)) then n := 3 + 4 * (abs(x) - 1)\n else n := 4 + 4 * (abs(y) - 1);\n end;\n\nprocedure IV(x, y : integer; var n : integer);\n begin\n if (abs(y) + 1 >= abs(x)) then n := 4 + 4 * (abs(y) - 1)\n else n := 1 + 4 * (abs(x) - 1);\n end;\n\nbegin\n readln(x, y);\n n := 0;\n if (x = 0) and (y = 0) then n := 0\n else if (x = 1) and (y = 0) then n := 0\n else if (x >= 0) and (y >= 0) then I(x, y, n)\n else if (x <= 0) and (y >= 0) then II(x, y, n)\n else if (x <= 0) and (y <= 0) then III(x, y, n)\n else if (x >= 0) and (y <= 0) then IV(x, y, n);\n writeln(n);\n readln;\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,n,i,j,a,c,x,y,b:longint;\n\nbegin\n// assignfile(input,'INPUT.TXT'); reset(input);\n// assignfile(output,'OUTPUT.TXT'); rewrite(output);\n read(x,y); i:=0; j:=0; m:=0; b:=0;\n\n while true do\n begin\n\n inc(m); a:=j; c:=i;\n\n if m mod 2=1 then inc(b);\n\n if m mod 4=1 then inc(j,b);\n if m mod 4=2 then inc(i,b);\n if m mod 4=3 then dec(j,b);\n if m mod 4=0 then dec(i,b);\n\n if (a<=j) and (c<=i) then\n if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;\n\n if (a>=j) and (c<=i) then\n if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;\n\n if (a<=j) and (c>=i) then\n if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;\n\n if (a>=j) and (c>=i) then\n if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;\n\n end;\n\n write(m-1);\n readln; readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\ntype point = record x,y:integer; end;\n\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If m=y) and (x<=-y+1) then begin ans:=min(ans,-y*4); end;\nif (x>0) and (y>=-x+1) and (y<=x) then begin ans:=min(ans,x*4-3); end;\nif (y>0) and (x>=-y) and (x<=y) then begin ans:=min(ans,y*4-2); end;\nif (x<0) and (y>=x) and (y<=-x) then begin ans:=min(ans,-x*4-1); end;\nwrite(ans);\nreadln;\n\nend.\n"}, {"source_code": "var\n x,y:integer;\nBegin\n read(x,y);\n if ((x=0)or(x=1))and(y=0) then Begin write(0); exit; end;\n if (x=y)and(x>0)and(y>0) then Begin write(2*(2*x-1)-1); exit; end;\n if (abs(x)=y)and(x<0) then Begin write(2*(2*abs(x)-1)); exit end;\n if x=y then Begin write(2*(2*abs(x))-1); exit; end;\n if ((abs(y)=(x-1))or(abs(y)=x))and(y<0) then Begin write(2*(2*abs(y))); exit; end;\n if (y>abs(x))and(y>0) then Begin write(2*(2*y-1)); exit; end;\n if (abs(x)>abs(y))and(x<0) then Begin write(2*(2*abs(x))-1); exit; end;\n if (abs(y)>abs(x))and(y<0) then begin write(2*(2*abs(y))); exit; end;\n if (x>y)and(x>0) then begin write(2*(2*x-1)-1); exit end;\nend."}, {"source_code": "program TA;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\nvar\n x, y, step, side, ans, curx, cury, j: integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'TA.in');\n rewrite(output, 'TA.out');\n {$ENDIF}\n readln(x, y);\n step := 1;\n side := 1;\n ans := 0;\n curx := 0;\n cury := 0;\n while not ((curx = x) and (cury = y)) do begin\n if side = 1 then begin\n for j := 1 to step do begin\n inc(curx);\n if (curx = x) and (cury = y) then begin\n write(ans);\n halt(0);\n end;\n end;\n side := 2;\n inc(ans);\n continue;\n end;\n if side = 2 then begin\n for j := 1 to step do begin\n inc(cury);\n if (curx = x) and (cury = y) then begin\n write(ans);\n halt(0);\n end;\n end;\n side := 3;\n inc(ans);\n step := step + 1;\n continue;\n end;\n if side = 3 then begin\n for j := 1 to step do begin\n dec(curx);\n if (curx = x) and (cury = y) then begin\n write(ans);\n halt(0);\n end;\n end;\n side := 4;\n inc(ans);\n continue;\n end;\n if side = 4 then begin\n for j := 1 to step do begin\n dec(cury);\n if (curx = x) and (cury = y) then begin\n write(ans);\n halt(0);\n end;\n end;\n side := 1;\n inc(ans);\n step := step + 1;\n continue;\n end;\n end;\n write(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE} program Project1; uses SysUtils; var n,x,y: integer; begin if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin AssignFile(Input, 'input.txt'); Reset(Input); AssignFile(Output, 'output.txt'); ReWrite(Output); end; Read(x); read (y); if ((x>0) and (y>-x+1) and (y<=x)) then n:= 4*x -3; if ((y>0) and (y>x) and (y>=-x)) then n:= 4*y-2; if ((x<0) and (y>=x) and (y<-x)) then n:= -x*4-1; if ((y<0) and(yabs(y) then max:=abs(x) else max:=abs(y);\nif (x=0) and (y=0) then writeln(0) else\nif (x=max) and (y=-max+1) then writeln(4*max-4) else\nif (x=max) and (y<>-max) then writeln(4*max-3) else\nif y=max then writeln(4*max-2) else\nif x=-max then writeln(4*max-1) else writeln(4*max);\nend.\n"}, {"source_code": "var\n tmp,left,x,y,x1,y1,i:longint;\nbegin\n readln(x,y);\n if (x=0)and(y=0) then begin writeln(0); halt; end;\n x1:=0;y1:=0;\n while i=0 do\n begin\n tmp:=x1;\n x1:=abs(x1)+1;\n if (y=y1)and((tmp<=x)and(x<=x1)) then begin writeln(left);halt; end;\n inc(left);\n tmp:=y1;\n y1:=abs(y1)+1;\n if (x=x1)and((tmp<=y)and(y<=y1)) then begin writeln(left); halt; end;\n inc(left);\n tmp:=x1;\n x1:=-x1;\n if (y=y1)and((tmp>=x)and(x>=x1)) then begin writeln(left);halt; end;\n inc(left);\n tmp:=y1;\n y1:=-y1;\n if (x=x1)and((tmp>=y)and(y>=y1)) then begin writeln(left);halt; end;\n inc(left);\n end;\nend."}, {"source_code": "var x,y,i,j,v,v2:integer; a:array[-101..101,-101..101]of integer;\nbegin\nreadln(x,y);\nfor i:=1 to 100 do\n begin\n j:=-i+1;\n a[i,j]:=v;\n inc(v);\n for j:=-i+2 to i do a[i,j]:=v;\n inc(v);\n a[-i,j]:=v;\n inc(v);\n for j:=i-1 downto -i do a[-i,j]:=v;\n inc(v);\n end;\nv:=1;\nfor i:=1 to 100 do\n begin\n j:=i;\n a[j,i]:=v;\n inc(v);\n for j:=i-1 downto -i do a[j,i]:=v;\n inc(v);\n a[j,-i]:=v;\n inc(v);\n for j:=-i+1 to i+1 do a[j,-i]:=v;\n inc(v);\n end;\nwriteln(a[x,y]);\nend."}, {"source_code": "uses math;\nvar x,y,xx,xxx,yyy,yy,o,r,q:longint;\nbegin\n read(x,y);\n if (x=0)and(y=0) then\n begin\n writeln(0);\n exit;\n end;\n if (x=1)and(y=0) then\n begin\n writeln(0);\n exit;\n end;\n if (x=1)and(y=1) then\n begin\n writeln(1);\n exit;\n end;\n xx:=1;\n yy:=1;\n o:=2;\n r:=2;\n q:=1;\n while (xx<>x)or(yy<>y) do\n begin\n xxx:=xx;\n yyy:=yy;\n if r=1 then yy:=yy+o\n else if r=2 then xx:=xx-o\n else if r=3 then yy:=yy-o\n else xx:=xx+o;\n inc(r);\n if r mod 2=0 then o:=o+1;\n if r=4 then\n begin\n r:=0;\n end;\n inc(q);\n if (xxx=x)and(xx=x)and(min(yy,yyy)<=y)and(max(yy,yyy)>=y) then break;\n if (yyy=y)and(yy=y)and(min(xx,xxx)<=x)and(max(xx,xxx)>=x) then break;\n end;\n writeln(q);\nend.\n"}, {"source_code": "uses math;\nvar\n len,ans,i,j,ix,jy,x,y:longint;\n\n\nprocedure pr(el:longint);\nbegin\n writeln(el);\n halt;\nend;\n\nbegin\n readln(x,y);\n if (x= 0) and (y= 0) then begin\n writeln(0);\n halt;\n end;\n i:=0;\n j:=0;\n for len:=1 to 1000 do begin\n if len mod 2 = 1 then begin\n //r\n ix:=i+len;\n jy:=j;\n if (y=j) and (x > i) and (x <= ix) then pr(ans);\n inc(ans);\n i:=ix;\n //u\n jy:=j+len;\n if (x = i) and (y>j) and (y<=jy) then pr(ans);\n inc(ans);\n j:=jy;\n end\n else begin\n //l\n ix:=i-len;\n jy:=j;\n if (y=j) and (x >= ix) and (x < i) then pr(ans);\n inc(ans);\n i:=ix;\n //u\n jy:=j-len;\n if (x = i) and (y >= jy) and (y<=j) then pr(ans);\n inc(ans);\n j:=jy;\n end;\n end;\nend.\n\n\n\n"}, {"source_code": "var\nans,x,y,a,b,i:longint;\nbol,l,u,r,d:boolean;\nbegin\nreadln(x,y);\nl:=false;\nu:=false;\nr:=true;\nd:=false;\na:=0;\nb:=0;\nif (x=a) and (y=b) then writeln(0)\nelse begin\nwhile true do begin\nif (bol)or((x=a)and(y=b)) then begin\n writeln(ans-1);\nbreak;\nend\nelse begin\n if r then begin\n r:=false;\n u:=true;\n inc(ans);\n for i:=a to abs(a)+1do if (i=x) and (b=y) then begin\n bol:=true;\n break;\n end;\n a:=i;\n end\n else\n if u then begin\n u:=false;\n l:=true;\n inc(ans);\n for i:=b to abs(b)+1 do if (a=x)and(i=y) then begin\n bol:=true;\n break;\n end;\n b:=i;\n end\n else\n if l then begin\n l:=false;\n d:=true;\n inc(ans);\n for i:=a downto -a do if (i=x)and(b=y) then begin\n bol:=true;\n break;\n end;\n a:=i;\n end\n else\n if d then begin\n d:=false;\n r:=true;\n inc(ans);\n for i:=b downto -b do if (x=a)and(i=y) then begin\n bol:=true;\n break;\n end;\n b:=i;\n end;\n end;\nend;\nend;\nend."}, {"source_code": "const\n fi='';\n fa='';\n maxN=100000;\nvar\n f,g:text;\n ch:char;\n n,i,j,t,x,y:longint;\n ok:boolean;\n a:array[0..maxN] of longint;\n s:array[0..maxN] of longint;\n\nfunction kq:longint;\nbegin\n if (x=0) and (y=0) then exit(0);\n if (x=y)and(x>0) then exit((x-1)*4+1);\n if (x=y) and (x<0) then exit(abs(x)*4-1);\n if (x=-y) and (y>0) then exit((abs(x)-1)*4+2);\n if (x+y-1=0) and (x>0) then exit((abs(y))*4);\n if (x+y-1>=0) then\n if (x-y>0) then exit((x-1)*4+1) else exit((y-1)*4+2);\n if x-y>0 then exit(abs(y)*4);\n exit(abs(x)*4-1);\nend;\n\nprocedure ghi;\nvar\n dem:longint;\nbegin\nend;\n\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fa);\n rewrite(g);\n read(f,x,y);\n writeln(g,kq);\n close(f);\n close(g);\nend."}, {"source_code": "Var x,y,x1,y1,k,s,res,i:longint;\nBegin\nReadln(x,y);\nIf ((x=0) or (x=1)) and (y=0) Then Begin Writeln(0); Halt; End;\nx1:=1; y1:=0;\ns:=0;\nk:=1;\nres:=1;\nWhile true do\n Begin\n If s=0 Then Begin For i:=1 to k do Begin inc(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;\n If s=1 Then Begin For i:=1 to k do Begin dec(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); End;\n If s=2 Then Begin For i:=1 to k do Begin dec(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;\n If s=3 Then Begin For i:=1 to k do Begin inc(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(res); End;\n s:=s mod 3;\n End;\nEnd."}, {"source_code": "var i,j,l,k,t,p,x,y,ans,z:longint;\n f:boolean;\nbegin\n readln(x,y);\n i:=0; j:=0;\n k:=1; t:=1; p:=1;\n while ((i<>x) or (j<>y)) do\n begin\n inc(z);\n f:=false;\n if (p=1) and (not f) then begin inc(i); dec(t); f:=true; end;\n if (p=2) and (not f) then begin inc(j); dec(t); f:=true; end;\n if (p=3) and (not f) then begin dec(i); dec(t); f:=true; end;\n if (p=4) and (not f) then begin dec(j); dec(t); f:=true; end;\n if (t=0) then\n begin\n inc(l);\n if (p=1) then p:=2 else\n if (p=2) then p:=3 else\n if (p=3) then p:=4 else p:=1;\n if (t=0) and (l<2) then\n begin\n t:=k;\n if (i<>x) or (j<>y) then inc(ans);\n end else\n begin\n if (i<>x) or (j<>y) then inc(ans);\n inc(k);\n t:=k;\n l:=0;\n end;\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "const\n ds: array [0..3, 0..1] of longint = ((1, 0), (0, 1), (-1, 0), (0, -1));\n\nvar\n x, y, x0, y0, d, l, ll, c: longint;\n\nbegin\n read(x, y);\n x0 := 0; y0 := 0;\n\n d := 0; l := 1; ll := 1; c := 0;\n\n while (x0 <> x) or (y0 <> y) do begin\n if ll = 0 then begin\n d := (d+1) mod 4;\n inc(c);\n end else\n if ll = -l then begin\n inc(l);\n ll := l;\n d := (d+1) mod 4;\n inc(c);\n end;\n x0 := x0 + ds[d, 0];\n y0 := y0 + ds[d, 1];\n dec(ll);\n end;\n\n writeln(c);\nend."}, {"source_code": "uses math;\nvar i,j,m,n,k,l,g,h,y,t,x:longint;\n a,b:array[1..1000]of longint;\nbegin {\n assign(input,'input1.txt');\n reset(input);\n assign(output,'output1.txt');\n rewrite(output);}\n read(x,y);\n t:=max(abs(x),abs(y));\n if (x=0)and(y=0) then\n begin\n write(0);\n halt;\n end;\n if (x>=0)and(y>0) then\n begin\n if x=0) then\n begin\n if abs(x)<=y then\n k:=t*4-2\n else\n k:=t*4-1;\n end;\n if (x<=0)and(y<0) then\n begin\n if abs(x)>=abs(y) then\n k:=t*4-1\n else\n k:=t*4;\n end;\n if (x>0)and(y<=0) then\n begin\n if abs(x)<=abs(y)+1 then\n if abs(x)=abs(y)+1 then\n k:=abs(y)*4\n else\n k:=(t)*4\n else\n k:=(t-1)*4+1;\n end;\n write(abs(k));\nend.\n"}, {"source_code": "{$o-}\nprogram abc;\nvar\n x,y: integer;\nbegin\n readln(x,y);\n if (x = 0) and (y = 0) then\n writeln(0)\n else if (y > x) and (y >= -x) then\n writeln(4*y-2)\n else if (y < -x) and (y >= x) then\n writeln(-4*x-1)\n else if (y < x) and (y <= -x+1) then\n writeln(-4*y)\n else\n writeln(4*x-3);\nend.\n\n"}, {"source_code": "uses math;\nvar n,m,j,i,k,l,ans,x,y,e,x1,y1,dx,dy,z:longint;\na:array[0..220000]of longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(x,y);\nif (x=y)and(x=0) then begin writeln(0);halt;end;\nif (x=1)and(y=0) then begin writeln(0);halt;end;\nif (x=1)and(y=1) then begin writeln(1);halt;end;\nif (x=0)and(y=1) then begin writeln(2);halt;end;\nk:=1;\nx1:=1;\ny1:=1;\ndx:=2;\ndy:=2;\nz:=1;\nwhile 1>0 do\n begin\n if z=1 then\n begin\n if(x=x1)and(y=y1) then begin writeln(k);halt;end;\n x1:=x1-dx;inc(z);\n\n inc(k);\n if (y1=y)and(x>=x1)and(x=y1)and(yx1-dx) then\n begin\n writeln(k);\n halt;\n end;\n dx:=dx+1;\n end else\n if z=4 then begin\n if(x=x1)and(y=y1) then begin writeln(k);halt;end;\n y1:=y1+dy;\n inc(k);\n\n if (x1=x)and(y<=y1)and(y>y1-dy) then\n begin\n writeln(k);\n halt;\n end;\n dy:=dy+1;z:=1;\n end;\n\n end;\n\n\nend."}, {"source_code": "const\n napy:array[1..4]of longint=(0,1,0,-1);\n napx:array[1..4]of longint=(1,0,-1,0);\nvar\n a:array[0..1000]of longint;\n nap,x1,y1,z,g,x,y,pov,pov1,i,j,n,m:longint;\n\n\n function mi(a,b:longint):longint;\n begin\n if ab then ma:=a else ma:=b;\n end;\n\n\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n x1:=0;\n y1:=0;\n g:=1;\n z:=0;\n nap:=1;\n readln(x,y);\n while 0=0 do\n begin\n if nap=1 then\n begin\n for j:=x1 to x1+g do\n if (x=j)and(y=y1) then\n begin\n writeln(pov);\n halt;\n end;\n x1:=x1+g;\n end;\n if nap=2 then\n begin\n for j:=y1 to y1+g do\n if (y=j)and(x=x1) then\n begin\n writeln(pov);\n halt;\n end;\n y1:=y1+g;\n end;\n if nap=3 then\n begin\n for j:=x1 downto x1-g do\n if (x=j)and(y=y1) then\n begin\n writeln(pov);\n halt;\n end;\n dec(x1,g);\n end;\n if nap=4 then\n begin\n for j:=y1 downto y1-g do\n if (x=x1)and(y=j) then\n begin\n writeln(pov);\n halt;\n end;\n y1:=y1-g;\n end;\n inc(z);\n inc(pov);\n if z=2 then\n begin\n z:=0;\n inc(g);\n end;\n inc(nap);\n if nap>4 then nap:=1;\n end;\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n procedure qSort(l,r:longint);\n var\n i,j,m,p:longint;\n begin\n i:=l;\n j:=r;\n m:=a[l+random(r-l+1)];\n repeat\n while a[i]m do dec(j);\n if i>j then break;\n p:=a[i];\n a[i]:=a[j];\n a[j]:=p;\n inc(i);\n dec(j);\n until i>j;\n if i=xx) and (x<=xx+uk) then break;\n inc(ans);\n xx:=xx+uk;\n if (xx=x) and (y>=yy) and (y<=yy+uk) then break;\n yy:=yy+uk\n end\n else\n begin\n inc(ans);\n if (yy=y) and (x>=xx-uk) and (x<=xx) then break;\n inc(ans);\n xx:=xx-uk;\n if (xx=x) and (y>=yy-uk) and (y<=yy) then break;\n yy:=yy-uk\n end;\n inc(uk);\n inc(i);\n end;\n\n writeln(ans-1);\nend."}, {"source_code": "Var x,y,x1,y1,j,i,l,k:longint;\n a:array[-1001..1001,-1001..1001] of longint;\n begin\n read(x1,y1);\n a[x,y]:=0;\n l:=0;\n k:=1;\n for i:=1 to 200 do\n begin\n for j:=1 to k do\n begin\n a[x+j,y]:=l;\n end;\n l:=l+1;\n x:=x+k;\n for j:=1 to k do\n begin\n a[x,y+j]:=l;\n end;\n l:=l+1;\n y:=y+k;\n k:=k+1;\n for j:=1 to k do\n begin\n a[x-j,y]:=l;\n end;\n l:=l+1;\n x:=x-k;\n for j:=1 to k do\n begin\n a[x,y-j]:=l;\n end;\n l:=l+1;\n y:=y-k;\n k:=k+1;\n end;\n writeln(a[x1,y1]);\n end.\n"}, {"source_code": "var step,pos,ans,kol,adx,ady,x,y,xc,yc:longint;\n ad:array[1..4,1..2] of longint;\n\n function ok(x1,y1,x2,y2:longint):boolean;\n begin\n exit((x1<>x2) or (y1<>y2));\n end;\n\n begin\n readln(x,y);\n ad[1][1]:=1;\n ad[1][2]:=0;\n ad[2][1]:=0;\n ad[2][2]:=1;\n ad[3][1]:=-1;\n ad[3][2]:=0;\n ad[4][1]:=0;\n ad[4][2]:=-1;\n while ok(x,y,xc,yc) do\n begin\n inc(kol);\n step:=kol;\n inc(pos);\n if pos=5 then pos:=1;\n while step>0 do\n begin\n if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;\n dec(step);\n xc:=xc+ad[pos][1];\n yc:=yc+ad[pos][2];\n end;\n if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;\n inc(ans);\n step:=kol;\n inc(pos);\n if pos=5 then pos:=1;\n while step>0 do\n begin\n if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;\n dec(step);\n xc:=xc+ad[pos][1];\n yc:=yc+ad[pos][2];\n end;\n if not ok(x,y,xc,yc) then begin writeln(ans); halt; end;\n inc(ans);\n end;\n writeln(ans);\n end.\n\n\n\n"}, {"source_code": "CONST\n tfi ='';//'a.inp';\n tfo ='';//'a.out';\n nmax =200;\nTYPE\n arr =array [-nmax..nmax,-nmax..nmax] of longint;\nVAR\n fi,fo :text;\n x,y,n :longint;\n dem,count,v:longint;\n a :arr;\n (*********************************************************************)\nProcedure nhap;\n Begin\n assign(fi,tfi);reset(fi);\n read(fi,x,y);\n close(fi);\n End;\n (*********************************************************************)\nProcedure dfs(i,j,s:longint);\n Begin\n if (abs(i)>100) or (abs(j)>100) then exit;\n a[i,j]:=count;\n if dem<>0 then\n begin\n dec(dem);\n if s=1 then dfs(i+1,j,s)\n else if s=2 then dfs(i,j+1,s)\n else if s=3 then dfs(i-1,j,s)\n else dfs(i,j-1,s);\n end\n else\n begin\n if s mod 2=0 then inc(v);\n dem:=v-1;\n inc(count);\n if s=1 then dfs(i,j+1,2)\n else if s=2 then dfs(i-1,j,3)\n else if s=3 then dfs(i,j-1,4)\n else dfs(i+1,j,1);\n end;\n End;\n (********************************************************************)\nProcedure inkq;\n Begin\n assign(fo,tfo);rewrite(fo);\n write(fo,a[x,y]);\n close(fo);\n End;\n (*********************************************************************)\nBEGIN\n nhap;\n v:=1;\n dem:=1;\n count:=0;dfs(0,0,1);\n inkq;\nEND.\n"}, {"source_code": "var\n g,i,x,ans,y,xn,yn: longint;\nbegin\n readln(x,y);\n xn:=0;\n yn:=0;\n i:=0;\n g:=1;\n while (true) do\n begin\n if g=2 then\n begin\n yn:=yn+i;\n if (x=xn) and (yn-i<=y) and (yn>=y) then begin writeln(ans); exit; end;\n inc(ans);\n end;\n if (g=1) then\n begin\n inc(i);\n xn:=xn+i;\n if (y=yn) and (xn-i<=x) and (xn>=x) then begin writeln(ans); exit; end;\n inc(ans);\n end;\n if g=4 then\n begin\n yn:=yn-i;\n if (x=xn) and (yn+i>=y) and (yn<=y) then begin writeln(ans); exit; end;\n inc(ans);\n end;\n if (g=3) then\n begin\n inc(i);\n xn:=xn-i;\n if (y=yn) and (xn+i>=x) and (xn<=x) then begin writeln(ans); exit; end;\n inc(ans);\n end;\n inc(g);\n if g=5 then g:=1;\n end;\nend."}, {"source_code": "program apoint;\nvar\n xxx,yyy,xx,yy:longint;\n x,y,g:longint;\nprocedure change(l:longint);\nbegin\n if l=2 then\n begin\n xx:=xxx;\n yy:=yyy;\n xxx:=xx;\n yyy:=-yy;\n end;\n if l=3 then\n begin\n xx:=xxx;\n yy:=yyy;\n xxx:=-xx+1;\n yyy:=yy;\n end;\n if l=0 then\n begin\n xx:=xxx;\n yy:=yyy;\n xxx:=xx;\n yyy:=-yy+1;\n end;\n if l=1 then\n begin\n xx:=xxx;\n yy:=yyy;\n xxx:=-xx;\n yyy:=yy;\n end;\nend;\nbegin\n readln(x,y);\n if (x=0) and(y=0) then\n begin\n writeln(0);\n end\n else if (x=1)and(y=0) then\n begin\n writeln(0);\n end\n else if (x=1)and(y=1) then\n begin\n writeln(1);\n end\n else\n begin\n xx:=1;\n yy:=1;\n xxx:=-1;\n yyy:=1;\n g:=2;\n\n while 1=1 do\n begin\n if (xxx=xx)and(xx=x)and(((y<=yy)and(y>=yyy))or((y<=yyy)and(y>=yy))) then\n begin\n writeln(g);\n exit;\n end;\n if (yy=yyy)and(yy=y)and(((x<=xx)and(x>=xxx))or((x<=xxx)and(x>=xx))) then\n begin\n writeln(g);\n exit;\n end;\n change(g mod 4);\n inc(g);\n end;\n end;\nend.\n"}, {"source_code": "var x,y:integer;\nbegin\n read(x,y);\n if(y=0)and(x=0)then write('0');\n if(y>x)and(-x<=y)then write(4*y-2);\n if(y>=x)and(-x>y)then write(-4*x-1);\n if(y-x+1)then write(4*x-3)\nend."}, {"source_code": "var x,y: integer;\nbegin\n readln(x,y);\n if (x=0)and(y=0) then writeln(0)\n else\n if (x>y)and(x<=1-y) then writeln(-y*4)\n else\n if (y>-x)and(y<=x) then writeln((x-1)*4+1)\n else\n if (x>=-y)and(x=m then mog:=1;\nif m>n then mog:=2;\nif n=m then mog:=0;\nend;\nvar i,i2,n,m,x,y,ans : longint;\n c : char;\nbegin\nreadln(x,y);\nif (x<0) and ( (mog(x,y)=1) or (mog(x,y)=0) ) and (y<>x*-1) then c:='l';\nif (x>0) and ( (mog(x,y)=1) or (mog(x,y)=0) ) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';\nif (y>0) and ( (mog(x,y)=2) or (mog(x,y)=0) ) and (x<>y) then c:='u';\nif (y<0) and ( ( (mog(x,y)=2) or (mog(x,y)=0) ) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';\n\nif c='r' then ans:=x*4-3;\nif c='l' then ans:=(x*-1)*4-1;\nif c='d' then ans:=(y*-1)*4;\nif c='u' then ans:=y*4-2;\nwriteln(ans);\nreadln;\nend.\n"}, {"source_code": "var\n a,b:array[1..1000]of longint;\n y,x1,y1,i,j,n,m,k,t,x:longint;\n s:string;\nbegin\n x1:=1;\n y1:=1;\n readln(x,y);\n if(x=0)and(y=0)or(x=1)and(y=0)then\n begin\n writeln(0);\n halt;\n end;\n k:=1;\n while true do\n begin\n if(x1=x)and(y1=y)then\n begin\n writeln(k);\n halt;\n end;\n inc(k);\n if(x=x1)and(y=y1)then\n begin\n writeln(k);\n halt;\n end;\n if(x1>0)and(y1>0)then\n begin\n for i:=x1 downto -x1 do if(y1=y)and(i=x)then\n begin\n writeln(k);\n halt;\n end;\n x1:=-x1;\n continue;\n end;\n if(x1<0)and(y1>0)then\n begin\n for i:=y1 downto -y1 do if(i=y)and(x1=x)then\n begin\n writeln(k);\n halt;\n end;\n y1:=-y1;\n continue;\n end;\n if(x1<0)and(y1<0)then\n begin\n for i:=x1 to -x1+1 do if(y1=y)and(i=x)then\n begin\n writeln(k);\n halt;\n end;\n x1:=-x1+1;\n continue;\n end;\n if(x1>0)and(y1<0)then\n begin\n for i:=y1 to -y1+1 do if(i=y)and(x1=x)then\n begin\n writeln(k);\n halt;\n end;\n y1:=-y1+1;\n end;\n end;\nend.\n"}, {"source_code": "program CF1_1;\nvar otv:longint;\n x,y,x1,y1,nh,h:longint;\n pos:byte;\nbegin\nreadln(x,y);\n\nnh:=1;\npos:=1;\n\nwhile (X1<>x) or (y1<>y) do\nbegin\n\ncase pos of\n1:begin inc(x1) end;\n2:begin inc(y1) end;\n3:begin dec(x1) end;\n4:begin dec(y1) end;\nend;\ninc(h);\nIf (h<>nh) or ((x1=x)and(y1=y)) then continue;\nh:=0;\nIf(pos=2) or (pos=4) then inc(nh);\ninc(pos);\nif (pos=5) then pos:=1;\ninc(otv);\nend;\n\nwriteln(otv);\n\nend."}, {"source_code": "var\n x,y,xc,yc,i,t,j:longint;\n\nbegin\n readln(x,y);\n xc:=0;\n yc:=0;\n t:=0;\n i:=1;\n while true do\n begin\n if (xc=x) and (yc=y) then\n begin\n writeln(t);\n halt(0);\n end;\n for j:=1 to i do\n begin\n inc(xc);\n if (xc=x) and (yc=y) then\n begin\n writeln(t);\n halt(0);\n end;\n end;\n inc(t);\n for j:=1 to i do\n begin\n inc(yc);\n if (xc=x) and (yc=y) then\n begin\n writeln(t);\n halt(0);\n end;\n end;\n inc(t);\n inc(i);\n for j:=1 to i do\n begin\n dec(xc);\n if (xc=x) and (yc=y) then\n begin\n writeln(t);\n halt(0);\n end;\n end;\n inc(t);\n for j:=1 to i do\n begin\n dec(yc);\n if (xc=x) and (yc=y) then\n begin\n writeln(t);\n halt(0);\n end;\n end;\n inc(t);\n inc(i);\n end;\nend."}, {"source_code": "var\nxx,yy,i,j:longint;\nx,y:array [0..10000] of longint;\nfunction max(a,b:longint):longint;\n begin\n if a>b then exit(a);\n exit(b);\n end;\nprocedure swap(var a,b:longint);\nvar k:longint;\n begin\n k:=a;\n a:=b;\n b:=k;\n end;\nfunction pren(x1,y1,x2,y2:longint):boolean;\n begin\n if x1>x2 then swap(x1,x2);\n if y1>y2 then swap(y1,y2);\n if ( xx>=x1 ) and (xx <= x2) and (yy>=y1) and (yy<=y2) then exit(true);\n exit(false);\n end;\nbegin\n read(xx,yy);\n x[1]:=0; y[1]:=0;\n for i:=2 to 1000 do\n begin\n if i=2 then \n begin\n x[2]:=1;\n y[2]:=0;\n end\n else\n if i mod 4=3 then \n begin\n x[i]:=i div 4+1; \n y[i]:=x[i];\n end\n else \n if i mod 4=1 then \n begin\n x[i]:=-x[i-2];\n y[i]:=-y[i-2];\n end\n else \n if i mod 4=2 then\n begin\n y[i]:=-i div 4; \n x[i]:=abs(y[i])+1;\n end\n else begin\n x[i]:=-i div 4;\n y[i]:=i div 4;\n end;\n if pren(x[i-1],y[i-1],x[i],y[i]) then\n begin\n writeln(i-2);\n halt;\n end;\n end;\nend."}, {"source_code": "var i, j, ans:longint;\nbegin\n readln(i, j);\n ans:=0;\n if (j<=i)and(j>=(-i+2)) then ans:=(i-1)*4+1;\n if (i>=(-j))and(i<=(j-1)) then ans:=(j-1)*4+2;\n if (j<=(abs(i)-1))and(j>=i) then ans:=(abs(i)-1)*4+3;\n if (i<=(abs(j)+1))and(i>=(j+1)) then ans:=(abs(j)-1)*4+4;\n if (i=100)and(j=99) then ans:=397;\n write(ans);\nend."}, {"source_code": "const LEFT = 1;\n RIGHT = 2;\n UP = 3;\n DOWN = 4;\n nxt : array[1..4] of longint = (down,up, left, right);\n step : array[1..4,1..2] of longint = ((-1,0),(1,0),(0,1),(0,-1));\nvar\n n,i,j,x,y,now,next,fx,fy,ans : longint;\n a : array[0..400,0..400] of longint;\nbegin\n readln(fx,fy);\n\n x := 200;\n y := 200;\n fx := fx + 200;\n fy := fy + 200;\n\n now := 1;\n next := RIGHT;\n\n while not ((x = fx) and (y = fy)) do begin\n a[x,y] := now;\n x := x + step[next,1];\n y := y + step[next,2];\n if (x = fx) and (y = fy) then break;\n if a[x + step[nxt[next],1], y + step[nxt[next],2]] = 0 then begin next := nxt[next]; inc(ans); end;\n\n inc(now);\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$R+,O-}\n\nuses\n SysUtils,\n Math;\n\nlabel\n link;\n\nvar\n x, y, m1, m2: integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(x, y);\n if (x = 0) and (y = 0) then\n begin\n write(0);\n exit;\n end;\n\n if (y > x) and (y >= -x) then //1\n begin\n write(4 * abs(y) - 2);\n exit;\n end;\n\n if (y <= x) and (y > -x + 1) then //2\n begin\n write(4 * abs(x) - 3);\n exit;\n end;\n\n if (y < x) and (y <= -x + 1) then //3\n begin\n write(4 * abs(y));\n exit;\n end;\n \n if (y >= x) and (y < -x) then //4\n begin\n write(4 * abs(x) - 1);\n exit;\n end;\n\n\n\n\n\n\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n dx : array[0..3] of integer = (1, 0, -1, 0);\n dy : array[0..3] of integer = (0, 1, 0, -1);\n\nvar\n x, y, x1, y1, size, ch, dxx, dyy : integer;\n a : array[-100..100, -100..100] of integer;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n readln(x1, y1);\n\n ch := 0;\n x := 0;\n y := 0;\n a[x][y] := 1;\n if (x <> x1) or (y <> y1) then begin\n x := x + 1;\n ch := 0;\n while true do begin\n dxx := dx[ch mod 4];\n dyy := dy[ch mod 4];\n while a[x + dx[(ch + 1) mod 4]][y + dy[(ch + 1) mod 4]] = 1 do begin\n if (x = x1) and (y = y1) then begin\n writeln(ch);\n halt;\n end;\n a[x][y] := 1;\n x := x + dx[ch mod 4];\n y := y + dy[ch mod 4];\n end;\n if (x = x1) and (y = y1) then begin\n writeln(ch);\n halt;\n end; \n inc(ch);\n end;\n end;\n\n writeln(ch);\n\nend.\n"}, {"source_code": "var x,y,a,b,c,d:shortint; turn:word=0; stt,e:byte;\nbegin\n read(x,y);\n a:=0; b:=0; c:=1; d:=0; stt:=1; e:=1;\n while (a<>x) or (b<>y) do\n case stt of\n 1: begin\n inc(a);\n if a=c then\n if (a=x) and (b=y) then break\n else begin\n inc(turn); inc(d,e);\n stt:=2\n end\n end;\n 2: begin\n inc(b);\n if b=d then\n if (a=x) and (b=y) then break\n else begin\n inc(turn); inc(e); dec(c,e);\n stt:=3\n end\n end;\n 3: begin\n dec(a);\n if a=c then\n if (a=x) and (b=y) then break\n else begin\n inc(turn); dec(d,e);\n stt:=4\n end\n end;\n 4: begin\n dec(b);\n if b=d then\n if (a=x) and (b=y) then break\n else begin\n inc(turn); inc(e); inc(c,e);\n stt:=1\n end\n end;\n end;\n write(turn)\nend."}, {"source_code": "var x,y,i,j,p,h,k:longint;\nbegin\n readln(x,y);\n i:=0;\n j:=0;\n h:=1;\n k:=0;\n p:=0;\n while (i<>x)or(j<>y) do\n begin\n if ((k=0)and(h>1))or(k=h)\n then inc(p);\n if k0) and (ParamStr(1)='DEBUG') then begin\n AssignFile(Input, 'input.txt');\n Reset(Input);\n AssignFile(Output, 'output.txt');\n ReWrite(Output);\n end;\n\n Read(x);\n read (y);\n if ((x>0) and (y>-x+1) and (y<=x)) then\n n:= 4*x -3;\n if ((y>0) and (y>x) and (y>=-x)) then\n n:= 4*y-2;\n if ((x<0) and (y>=x) and (y<-x)) then\n n:= -x*4-1;\n if ((y<0) and(y-x+1) and (y<=x) then begin write(x*4-3);halt; end;\nif (y>x) and (y>=-x) then begin write(y*4-2);halt; end;\nif (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;\n write(-y*4);halt;\n end."}, {"source_code": "program p1;\nvar x,y,smer,sol:integer; x1,y1:longint;\nbegin\n readln(x,y);\n x1:=0; y1:=0; smer:=2;\n while (x1<>x) or (y1<>y) do\n begin\n if (x1=y1) and (x1>0) then begin inc(sol); smer:=4; end;\n if (x1+y1=1) and (x1>0) then begin inc(sol); smer:=3; end;\n if (x1=y1) and (x1<0) then begin inc(sol); smer:=2; end;\n if (x1+y1=0) and (x1<0) then begin inc(sol); smer:=1; end;\n if smer=1 then dec(y1)\n else if smer=2 then inc(x1)\n else if smer=3 then inc(y1)\n else dec(x1);\n end;\n writeln(sol);\nend.\n"}, {"source_code": "Const\n fin='';\n fon='';\nVar x,y: Longint;\nProcedure Start;\n Begin\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n End;\nProcedure Programe;\n Begin\n readln(x,y);\n if (x = 0) and (y = 0) then\n begin\n writeln(0);\n Halt;\n end;\n if (y > x) and (-x <= y) then\n begin\n writeln(y*4-2);\n Halt;\n end;\n if (y >= x) and (-x > y) then\n begin\n writeln(-x*4-1);\n Halt;\n end;\n if (y < x) and (y <= 1-x) then\n begin\n writeln(-y*4);\n Halt;\n end;\n if (y <= x) and (y > 1-x) then\n begin\n writeln(x*4-3);\n Halt;\n end;\n End;\nProcedure Finish;\n Begin\n close(input);\n close(output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd.\n"}, {"source_code": "program contest;\n\n{$APPTYPE CONSOLE}\n{$R+ ,Q+ ,I+}\n\nuses\n SysUtils;\n\nvar\n n,i,j,k,s,t,x,m,y,ans: integer;\n c,a,p: array[1..100]of integer;\nbegin\n read(n,m);\n x:=0;\n y:=0;\n ans:=0;\n j:=0;\n t:=0;\n if (n=x) and (m=x) then begin\n write(ans);\n halt;\n end;\n while true do begin\n //////////////////////////////////\n inc(t);\n inc(x,t);\n for i:=j to x do begin\n\n if (i=n) and (y=m) then begin\n write(ans);\n halt;\n end;\n end;\n inc(ans);\n inc(y,t);\n for i:=j to y do begin\n\n if (x=n) and (i=m) then begin\n write(ans);\n halt;\n end;\n end;\n inc(ans);\n //////////////////////////////////\n j:=x;\n inc(t);\n dec(x,t);\n for i:=j downto x do begin\n\n if (i=n) and (y=m) then begin\n write(ans);\n halt;\n end;\n end;\n inc(ans);\n dec(y,t);\n for i:=j downto y do begin\n\n if (x=n) and (i=m) then begin\n write(ans);\n halt;\n end;\n end;\n inc(ans);\n j:=x;\n end;\n write(ans+1-1);\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$apptype console}\nuses\n sysutils,math;\nvar\n x,y,l,r,i,k,j : integer;\nbegin\n read(x,y);\n if (x = 0) and (y = 0) then begin\n write(0);\n halt;\n end;\n l := 0;\n r := 0;\n i := 1;\n k := 0;\n while (l <> x) or (r <> y) do begin\n l := l + i;\n inc(k);\n for j := l - i to l do\n if (j = x) and (r = y) then begin\n write(k-1);\n halt;\n end;\n r := r + i;\n inc(k);\n for j := r - i to r do\n if (l = x) and (j = y) then begin\n write(k-1);\n halt;\n end;\n inc(i);\n dec(l,i);\n inc(k);\n for j := l to l + i do\n if (j = x) and (r = y) then begin\n write(k-1);\n halt;\n end;\n dec(r,i);\n inc(i);\n inc(k);\n for j := r to r + i do\n if (l = x) and (j = y) then begin\n write(k-1);\n halt;\n end;\n end;\n writeln(k-1);\n\nend."}, {"source_code": "program P279A;\nconst fin='';\n fou='';\nvar x,y:shortint;\n count:integer;\n fi,fo:text;\n \nprocedure enter();\n begin\n assign(fi,fin);reset(fi);\n read(fi,x,y);\n close(fi);\n end;\n\nfunction getmin(x,y:integer):integer;\n begin\n if(xy) then\n exit(x)\n else\n exit(y);\n end;\n\nprocedure process();\n var tmp,tmp2,tmp3,x0,y0:integer;\n begin\n tmp:=0;\n tmp2:=0;\n x0:=0;\n y0:=0;\n count:=-1;\n while (x0<>x) or (y0<>y) do\n begin\n if (tmp2=0) then inc(tmp);\n if (tmp2=0) then\n begin\n tmp3:=x0;\n if (odd(tmp)) then\n x0:=x0+tmp\n else\n x0:=x0-tmp;\n if (y=y0)\n and (xgetmin(tmp3,x0)) then\n begin\n inc(count);\n break;\n end; \n inc(tmp2);\n end\n else\n if (tmp2=1) then\n begin\n tmp3:=y0;\n if (odd(tmp)) then\n y0:=y0+tmp\n else\n y0:=y0-tmp;\n if (x=x0)\n and (ygetmin(tmp3,y0)) then\n begin\n inc(count);\n break;\n end;\n inc(tmp2);\n end;\n if (tmp2=2) then\n tmp2:=0;\n inc(count);\n end;\n assign(fo,fou);rewrite(fo);\n if (count<0) then\n write(fo,0)\n else\n write(fo,count);\n close(fo);\n end;\n \nbegin\n enter();\n process();\nend.\n\n"}, {"source_code": "var x,y,xx,yy,k,q,ans:longint;\n begin\n read (x,y);\n k:=1;\n xx:=0;\n yy:=0;\n q:=0;\n ans:=0;\n while true do\n begin\n if q=0 then begin\n if (yy=y) and (xx+k>=x) and (xx<=x)\n then begin\n writeln (ans);\n halt(0);\n end\n else xx:=xx+k;\n end\n else begin\n if (yy=y) and (xx-k<=x) and (xx>=x)\n then begin\n writeln (ans);\n halt(0);\n end\n else xx:=xx-k;\n end;\n inc (ans);\n if q=0 then begin\n if (xx=x) and (yy+k>=y) and (yy<=y)\n then begin\n writeln (ans);\n halt(0);\n end\n else yy:=yy+k;\n end\n else begin\n if (xx=x) and (yy-k<=y) and (yy>=y)\n then begin\n writeln (ans);\n halt(0);\n end\n else yy:=yy-k;\n end;\n inc (ans);\n q:=1-q;\n inc (k);\n end;\n end."}, {"source_code": "var x,y:longint;\nbegin\nread (x,y);\nif (y=0) and (x=0) then write ('0');\nif (y>x) and (-x<=y) then write (4*y-2);\nif (y>=x) and (-x>y) then write (-4*x-1);\nif (y-x+1) then write (4*x-3)\n\nend."}, {"source_code": "var x,y:longint;\nbegin\nread (x,y);\nif (y=0) and (x=0) then write ('0');\nif (y>x) and (-x<=y) then write (4*y-2);\nif (y>=x) and (-x>y) then write (-4*x-1);\nif (y-x+1) then write (4*x-3)\n\nend."}, {"source_code": "var\n x,y,a,b,n,i,z,shag,j,mx,my,cas,s:integer;\n t:text;\nprocedure povorot();\nbegin\n cas:=(cas+1) mod 4;\n case cas of\n 0: begin; mx:=1; my:=0; end;\n 1: begin; mx:=0; my:=1; end;\n 2: begin; mx:=-1; my:=0; end;\n 3: begin; mx:=0; my:=-1; end;\n end;\n inc(n);\nend;\n\nbegin\n shag:=1;\n mx:=1;\n read(x,y);\n// writeln('0)0 0|0');\n while not(a=x) or not(b=y) do begin\n for j:=1 to shag do begin\n a:=a+mx;\n b:=b+my;\n inc(s);\n if (a=x) and (b=y) then break;\n// writeln(s,')',a,' ',b,'|',n);\n end;\n inc(z);\n if (z=2) then begin\n z:=0;\n inc(shag);\n end;\n if not(a=x) or not(b=y) then povorot();\n end;\n writeln(n);\nend."}], "negative_code": [{"source_code": "uses math;\ntype mass=array[1..100] of integer;\nvar u:boolean;\n m:mass;\n ch:char; s,ss:string;\n min1,max1,j,x,x1,y1,y,a,b,k,c,i,z,q,n,num:integer;\nBegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(x,y);\n if (x=0) and (y=0)\n then Begin\n writeln(0);\n halt(0);\n end;\n a:=0;\n b:=1;\n n:=1;\n x1:=0;\n y1:=0;\n for i:=1 to 100000 do\n Begin\n case n of\n 1:Begin\n if y1=y\n then if (x1+b>=x) and (x1<=x)\n then Begin\n writeln(a);\n halt(0);\n end;\n inc(x1,b);\n inc(n);\n inc(a);\n end;\n 2:Begin\n if x1=x\n then if (y1+b>=y) and (y1<=b)\n then Begin\n writeln(a);\n halt(0);\n end;\n inc(y1,b);\n inc(n);\n inc(a);\n inc(b);\n end;\n 3:Begin\n if y1=y\n then if (x1-b<=x) and (x1>=x)\n then Begin\n writeln(a);\n halt(0);\n end;\n dec(x1,b);\n inc(n);\n inc(a);\n end;\n 4:Begin\n if x1=x\n then if (y1-b<=y) and (y1>=y)\n then Begin\n writeln(a);\n halt(0);\n end;\n dec(y1,b);\n n:=1;\n inc(a);\n inc(b);\n end;\n end;\n end;\nend.\n"}, {"source_code": "uses math;\ntype mass=array[1..100] of integer;\nvar u:boolean;\n m:mass;\n ch:char; s,ss:string;\n min1,max1,j,x,x1,y1,y,a,b,k,c,i,z,q,n,num:integer;\nBegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(x,y);\n if (x=0) and (y=0)\n then Begin\n writeln(0);\n halt(0);\n end;\n a:=0;\n b:=1;\n n:=1;\n x1:=0;\n y1:=0;\n while 1=1 do\n Begin\n case n of\n 1:Begin\n if y1=y\n then if (x1+b>=x) and (x1<=x)\n then Begin\n writeln(a);\n halt(0);\n end;\n inc(x1,b);\n inc(n);\n inc(a);\n end;\n 2:Begin\n if x1=x\n then if (y1+b>=y) and (y1<=b)\n then Begin\n writeln(a);\n halt(0);\n end;\n inc(y1,b);\n inc(n);\n inc(a);\n inc(b);\n end;\n 3:Begin\n if y1=y\n then if (x1-b<=x) and (x1>=x)\n then Begin\n writeln(a);\n halt(0);\n end;\n dec(x1,b);\n inc(n);\n inc(a);\n end;\n 4:Begin\n if x1=x\n then if (y1-b<=y) and (y1>=y)\n then Begin\n writeln(a);\n halt(0);\n end;\n dec(y1,b);\n n:=1;\n inc(a);\n inc(b);\n end;\n end;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nprogram Project1;\n\nuses\n SysUtils;\n\nvar\n n,x,y: integer;\n\nbegin\n if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin\n AssignFile(Input, 'input.txt');\n Reset(Input);\n AssignFile(Output, 'output.txt');\n ReWrite(Output);\n end;\n\n Read(x);\n read (y);\n if ((x>0) and (y>-x+1) and (y<=x)) then\n n:= 4*x -3;\n if ((y>0) and (y>x) and (y>=-x)) then\n n:= 4*y-2;\n if ((x<0) and (y>=x) and (y<-x+1)) then\n n:= -x*4-1;\n if ((y<0) and(y 0) and (y >= 0) then\n if 4*x <= r then\n inc(r, 2)\n else\n inc(r, 1)\n else if (x <= 0) and (y > 0) then\n if 4*y <= r then\n inc(r, 3)\n else\n inc(r, 2)\n else if (x < 0) and (y <= 0) then\n if -4*x <= r then\n inc(r, 4)\n else\n inc(r, 3)\n else if -4*y <= r then\n inc(r, 5)\n else\n inc(r, 4);\n if ((x = 0) and (y = 0)) or ((x = 1) and (y = 0)) then\n write(0)\n else\n write(r)\nend."}, {"source_code": "program ll;\n const dd=1000000007;\n var x,y,b,c,n,m,j,t,t2,k,i:longint;{F:BOOLEAN;{z,x,y:array[-1..255]of int64;\n u:array[0..22501]of longint;r1,r2:real;x:array[0..100003]of longint;{real;\n y:array[0..500]of int64;}\n\n\n begin\n{assign(input,'input.txt');reset(input);\nsassign(output,'output.txt');rewrite(output);}\nread(x,y);\nif (y=0) and (x=0) then begin write(0);halt; end;\nif (y>x+1) and (y<=x) then begin write(x*4-3);halt; end;\nif (y>x) and (y>=-x) then begin write(y*4-2);halt; end;\nif (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;\n write(-y*4);halt;\n end."}, {"source_code": "program ll;\n const dd=1000000007;\n var x,y,b,c,n,m,j,t,t2,k,i:longint;{F:BOOLEAN;{z,x,y:array[-1..255]of int64;\n u:array[0..22501]of longint;r1,r2:real;x:array[0..100003]of longint;{real;\n y:array[0..500]of int64;}\n\n\n begin\n{assign(input,'input.txt');reset(input);\nsassign(output,'output.txt');rewrite(output);}\nread(x,y);\nif (y=0) and (x=0) then begin write(0);halt; end;\nif (y>-x-1) and (y<=x) then begin write(x*4-3);halt; end;\nif (y>x) and (y>=-x) then begin write(y*4-2);halt; end;\nif (y<-x) and (y>=x) then begin write(-x*4-1);halt; end;\n write(-y*4);halt;\n end."}, {"source_code": "{$R+ Q+ I+}\n{$apptype console}\nuses\n sysutils,math;\nvar\n x,y,l,r,i,k : integer;\nbegin\n read(x,y);\n if (x = 0) and (y = 0) then begin\n write(0);\n halt;\n end;\n l := 0;\n r := 0;\n i := 1;\n k := 0;\n while (l <> x) or (r <> x) do begin\n l := l + i;\n inc(k);\n if (l = x) and (r = y) then begin\n write(k-1);\n halt;\n end;\n r := r + i;\n inc(k);\n if (l = x) and (r = y) then begin\n write(k-1);\n halt;\n end;\n inc(i);\n dec(l,i);\n inc(k);\n if (l = x) and (r = y) then begin\n write(k-1);\n halt;\n end;\n dec(r,i);\n inc(i);\n inc(k);\n end;\n writeln(k-1);\n\nend."}, {"source_code": "var q,ans,x,y:longint;\nfunction max(a,b:Longint):longint;\nbegin\n if a>b then max:=a else max:=b;\nend;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then writeln(0) else begin\n q:=max(abs(x),abs(y));\n ans:=4*(q-1);\n if (abs(x)=q) and (y>-x+1) and (x>0) then inc(ans,1)\n else if (abs(y)=q) and (x0) then inc(ans,2)\n else if (abs(x)=q) and (x<0) and (y<-x) then inc(ans,3)\n else if (abs(y)=q) and (y<0) and (x>-y) then inc(ans,4);\n writeln(ans);\n end;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nprogram Project1;\n\nuses\n SysUtils;\n\nvar\n x, y, r: integer;\n\nbegin\n if (ParamCount>0) and (ParamStr(1)='DEBUG') then begin\n AssignFile(Input, 'input.txt');\n Reset(Input);\n AssignFile(Output, 'output.txt');\n ReWrite(Output);\n end;\n\n ReadLn(x, y);\n if (y = 0) and ((x = 0) or (x = 1)) then\n r := 0\n else if (x > 0) and (y > -x + 1) and (y <= x) then\n r := 4 * (x - 1) + 1\n else if (y > 0) and (x >= -y ) and (x < y) then\n r := 4 * (y - 1) + 2\n else if (x < 0) and (y >= x) and (y < -x) then\n r := 4 * (-x - 1) + 3\n else if (y < 0) and (x > -y) and (x <= -y+1) then\n r := 4 * (-y - 1) + 4;\n\n Writeln(r);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n i, n, k, m, j, x, l, sk: integer;\n a: array [1..101, 1..101] of integer;\n c, d: array [1..101] of integer;\n\nprocedure Swap(var x, y: integer); overload;\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure Swap(var x, y: int64); overload;\nvar\n z: int64;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure Swap(var x, y: Extended); overload;\nvar\n z: extended;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure Swap(var x, y: real); overload;\nvar\n z: real;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure Swap(var x, y: double); overload;\nvar\n z: double;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\nprocedure Swap(var x, y: boolean); overload;\nvar\n z: boolean;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\n\nprocedure Swap(var x, y: byte); overload;\nvar\n z: byte;\nbegin\n z := x;\n x := y;\n y := z;\nend;\n\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF}\n read(n, m);\n sk := 0;\n for i := 1 to n do\n for j := 1 to m do\n a[i, j] := 0;\n for i := 1 to 100 do\n c[i] := 0;\n for i := 1 to 100 do\n d[i] := 0;\n for i := 1 to n do\n begin\n read(k);\n sk := sk + k;\n for j := 1 to k do\n begin\n read(x);\n a[i, x] := 1;\n end;\n end;\n if sk = 0 then\n begin\n write(n);\n exit;\n end\n else\n sk := n - 1;\n for i := 1 to n do\n c[i] := i;\n for i := 1 to n do\n for j := 1 to n do\n if c[j] <> c[i] then\n begin\n for k := 1 to m do\n if a[i, k] * a[j, k] = 1 then\n begin\n l := c[j];\n for x := 1 to n do\n if c[x] = l then\n c[x] := c[i];\n dec(sk); \n break;\n\n end;\n end;\n x := 0;\n for i := 1 to n do\n d[c[i]] := 1;\n for i := 1 to n do\n x := x + d[i];\n write(x - 1);\nend.\n"}, {"source_code": "program Project1;\nvar\n x,y,x0,y0,kol:int64;\n i,j:longint;\n procedure d;\n begin\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n i:=1;\n\n while (x0<>x) and (y0<>y) do begin\n if (x0<>x) and (y0<>y) then begin\n inc(x0,i);\n inc(kol);\n end;\n if (x0<>x) and (y0<>y) then begin\n inc(y0,i);inc(kol);\n end;\n\n inc(i);\n\n\n if (x0<>x) and (y0<>y) then begin\n\n dec(x0,i); inc(kol); end;\n if (x0<>x) and (y0<>y) then begin\n dec(y0,i); inc(kol) end;\n\n inc(I);\n\n\n end;\n end;\n\nbegin\n\n\n readln(x,y);\n\n x0:=0;\n y0:=0;\n\n d;\n write(kol);\n\n\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,n,i,j,a,c,x,y,b:longint;\n\nbegin\n// assignfile(input,'INPUT.TXT'); reset(input);\n// assignfile(output,'OUTPUT.TXT'); rewrite(output);\n read(x,y); i:=0; j:=0; m:=0; b:=0;\n if (x=0)and(y=1) then begin write(2); halt; end;\n repeat\n inc(m); a:=i; c:=j;\n if m mod 2=1 then inc(b);\n if m mod 4=1 then inc(j,b);\n if m mod 4=2 then inc(i,b);\n if m mod 4=3 then dec(j,b);\n if m mod 4=0 then dec(i,b);\n if (a<=i) and (c<=j) then\n if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;\n if (a>=i) and (c<=j) then\n if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;\n if (a<=i) and (c>=j) then\n if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;\n if (a>=i) and (c>=j) then\n if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;\n until false;\n\n write(m-1);\n readln; readln;\nend.\n "}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,n,i,j,a,c,x,y,b:longint;\n\nbegin\n// assignfile(input,'INPUT.TXT'); reset(input);\n// assignfile(output,'OUTPUT.TXT'); rewrite(output);\n read(x,y); i:=0; j:=0; m:=0; b:=0;\n repeat\n inc(m); a:=i; c:=j;\n if m mod 2=1 then inc(b);\n if m mod 4=1 then inc(j,b);\n if m mod 4=2 then inc(i,b);\n if m mod 4=3 then dec(j,b);\n if m mod 4=0 then dec(i,b);\n if (a<=i) and (c<=j) then\n if (a<=x) and (x<=j) and (c<=y) and (y<=i) then break;\n if (a>=i) and (c<=j) then\n if (j<=x) and (x<=a) and (c<=y) and (y<=i) then break;\n if (a<=i) and (c>=j) then\n if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;\n if (a>=i) and (c>=j) then\n if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;\n until false;\n\n write(m-1);\n readln; readln;\nend.\n "}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,n,i,j,a,c,x,y,b:longint;\n\nbegin\n// assignfile(input,'INPUT.TXT'); reset(input);\n// assignfile(output,'OUTPUT.TXT'); rewrite(output);\n read(x,y); i:=0; j:=0; m:=0; b:=0;\n if x>y then n:=x else n:=y;\n\n repeat\n inc(m); a:=i; c:=j;\n if m mod 2=1 then inc(b);\n if m mod 4=1 then inc(j,b);\n if m mod 4=2 then inc(i,b);\n if m mod 4=3 then dec(j,b);\n if m mod 4=0 then dec(i,b);\n if (aj) and (bi) then\n if (a<=x) and (x<=j) and (i<=y) and (y<=c) then break;\n if (a>j) and (b>i) then\n if (j<=x) and (x<=a) and (i<=y) and (y<=c) then break;\n until false;\n\n write(m-1);\n readln; readln;\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\ntype point = record x,y:integer; end;\n\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If m=x) and (y<=-x+1) then begin writeln(-x*4); halt; end;\nif (y>0) and (x>=-y+1) and (x<=y) then begin writeln(y*4-3); halt; end;\nif (x>0) and (y>=-x) and (y<=x) then begin writeln(x*4-2); halt; end;\nif (y<0) and (x>=y) and (x<=-y) then begin writeln(-y*4-1); halt; end;\nend.\n"}, {"source_code": "Var ans,a,b,x,y,i,n,m,d,k,z:LongInt;\nBegin\n Read(a,b);\n while (x<>a)or(y<>b) do\n begin\n if d=0 then begin x:=-x; inc(x); end;\n if d=1 then begin y:=-y; inc(y); end;\n if d=2 then begin x:=-x; end;\n if d=3 then begin y:=-y; end;\n if d=3 then d:=0\n else inc(d);\n inc(ans);\n if (a=x)and(b>(-y))and(b(-x))and(a5 then dec(ans);\n if ans<0 then ans:=0;\n WriteLn(ans);\nEnd.\n 1"}, {"source_code": "const dx:array[1..4] of longint=(1,0,-1,0);\n dy:array[1..4] of longint=(0,1,0,-1);\n\nvar x,y,xx,yy,kol,len,j,sost: longint;\nbegin\n readln(x,y);\n\n if (x=0) and (y=0) then \n begin\n writeln(0);\n halt;\n end;\n\n kol:=0;\n\n xx:=0;\n yy:=0;\n\n sost:=1;\n\n for len:=1 to 1000 do\n begin\n for j:=1 to len do\n begin\n xx:=xx+dx[sost];\n yy:=yy+dy[sost];\n if (xx=x) and (yy=y) then \n begin\n writeln(kol);\n halt;\n end;\n end;\n\n sost:=sost+1;\n sost:=sost mod 4;\n if sost=0 then sost:=4;\n\n inc(kol);\n end;\n\n\nend."}, {"source_code": "var x,y,xx,yy,k,q,ans:longint;\n begin\n read (x,y);\n k:=1;\n xx:=0;\n yy:=0;\n q:=0;\n ans:=0;\n while true do\n begin\n if q=0 then begin\n if (yy=y) and (xx+k>=x) then begin\n writeln (ans);\n halt(0);\n end\n else xx:=xx+k;\n end\n else begin\n if (yy=y) and (xx-k<=x) then begin\n writeln (ans);\n halt(0);\n end\n else xx:=xx-k;\n end;\n inc (ans);\n if q=0 then begin\n if (xx=x) and (yy+k>=y) then begin\n writeln (ans);\n halt(0);\n end\n else yy:=yy+k;\n end\n else begin\n if (xx=x) and (yy-k<=y) then begin\n writeln (ans);\n halt(0);\n end\n else yy:=yy-k;\n end;\n inc (ans);\n q:=1-q;\n inc (k);\n end;\n end."}, {"source_code": "var i,q,n,it:longint;\n a:array[0..165] of longint;\n flag:boolean;\n begin\n read(i);\n for it:=i+1 to 9999 do\n begin\n q:=it;\n fillchar(a,sizeof(a),0);\n while q>0 do\n begin\n inc(a[q mod 10]);\n q:=q div 10;\n end;\n flag:=true;\n for i:=0 to 9 do\n if a[i]>1 then\n begin\n flag:=false;\n break;\n end;\n if flag then\n begin\n writeln(it);\n break;\n\n end;\n\n end;\n end."}, {"source_code": "Var x,y,x1,y1,s,ans,i,c:integer;\n\nBegin\n\n Readln( x , y );\n \n x1:=0;\n y1:=0;\n s:=1;\n ans:=0;\t\n c:=1;\n \n if ( x = 0 ) and ( y = 0 ) then begin\n \n writeln( 0 );\n Halt;\n \n end;\n \n While ( 1 <> 0 ) do begin\n \n for i:=1 to abs(s) do begin\n \n if ( s < 0 ) then x1:=x1-1\n Else inc ( x1 );\n \n if ( x1 = x ) and ( y1 = y ) then begin\n \n\tinc ( ans );\n\t\n writeln ( ans );\n\thalt;\n\t\n end;\n \n end;\n \n if ( c <> 1 ) then inc ( ans );\n \n inc ( c );\n \n for i:=1 to abs(s) do begin\n \n if ( s < 0 ) then y1:=y1-1\n Else inc ( y1 );\n \n if ( x1 = x ) and ( y1 = y ) then begin\n \n if ( c <> 1 ) then inc ( ans );\n writeln ( ans );\n\thalt;\n\t\n end;\n \n end;\n \n if ( c <> 1 ) then inc ( ans );\n \n if ( s > 0 ) then inc( s)\n Else begin\n \n s:=s*(-1);\n inc( s) ;\n s:=s*(-1);\n \n end;\n \n s:=s*(-1);\n \n end;\n \nend.\n"}, {"source_code": "Var x,y:longint;\n begin\n read(x,y);\n if (x>=0) and (y>=0) then begin\n if (x<=1) and (y=0) then begin writeln(0); halt; end;\n if x>=y then writeln((x-1)*4+1)\n else writeln((y-1)*4+2);\n end\n else if (x<=0) and (y>=0) then begin\n if abs(x)<=y then writeln((y-1)*4+2)\n else writeln((abs(x)-1)*4+3);\n end\n else if (x<=0) and (y<=0) then begin\n if abs(x)>=abs(y) then writeln((abs(x)-1)*4+3)\n else writeln((abs(y))*4);\n end\n else if (x>=0) and (y<=0) then begin\n if x<=abs(y) then writeln(abs(y)*4)\n else writeln((abs(x)-1)+1);\n end;\n end.\n"}, {"source_code": "uses math;\nVar x,y,q:int64;\n begin\n read(x,y);\n if (x>=0) and (y>=0) then begin\n if (y=0) and (x<=1) then writeln(0)\n else begin\n q:=max(x,y);\n if x>=y then writeln((q-1)*4+1)\n else writeln((q-1)*4+2);\n end;\n end\n else if (x<=0) and (y>=0) then begin\n q:=max(abs(x),y);\n if abs(x)>=y then writeln((q-1)*4+2)\n else writeln((q-1)*4+3)\n end\n else if (x<=0) and (y<=0) then begin\n q:=max(abs(x),abs(y));\n if (abs(x))>=abs(y) then writeln((q-1)*4+3)\n else writeln(q*4);\n end\n else if (x>=0) and (y<=0) then begin\n q:=max(abs(y),x);\n if x>abs(y) then writeln((q)*4+1)\n else writeln(q*4);\n end;\n end."}, {"source_code": "uses math;\nVar x,y,q:int64;\n begin\n read(x,y);\n if (x>=0) and (y>=0) then begin\n if (y=0) and (x<=1) then writeln(0)\n else begin\n q:=max(x,y);\n if x>=y then writeln((q-1)*4+1)\n else writeln((q-1)*4+2);\n end;\n end\n else if (x<=0) and (y>=0) then begin\n q:=max(abs(x),y);\n if abs(x)>=y then writeln((q-1)*4+2)\n else writeln((q-1)*4+3)\n end\n else if (x<=0) and (y<=0) then begin\n q:=max(abs(x),abs(y));\n if (abs(x))>=abs(y) then writeln((q-1)*4+3)\n else writeln(q*4);\n end\n else if (x>=0) and (y<=0) then begin\n q:=abs(y);\n if x-abs(y)>1 then writeln((q)*4+1)\n else writeln(q*4);\n end;\n end."}, {"source_code": "var x,y,ans:longint;\nbegin\n read(x,y);\n ans:=(abs(x)-1)*4+1;\n if (x>0) and (y>0) then write(ans)\n else if (x>0) and (y<=0) then write(ans-1)\n else if (y>0) then write(ans+1)\n else write(ans+2);\nend."}, {"source_code": "uses math;\nvar x,y,ans,k:longint;\nbegin\n read(x,y);\n k:=max(abs(x),abs(y));\n if (x=0) and (y=0) then begin write(0); halt; end;\n ans:=(k-1)*4+1;\n if (x=k) and (y<>-k+1) then write(ans)\n else if (x=k) then write(ans-1)\n else if (x=-k) and (y=k) then write(ans+1)\n else if (x=-k) then write(ans+2)\n else if (x-k+1) then write(ans)\n else if (x=k) then write(ans-1)\n else if (x=-k) and (y=k) then write(ans+1)\n else if (x=-k) then write(ans+2)\n else if (x0) and (y<>0) do\nbegin\n\tinc (k);\n\tfor l:=1 to k do\n\tbegin\n\n\t\tinc (i);\n\t\tif (i=x) and (j=y) then\n\t\tbegin\t\n\t\t\twriteln (pov);\n\t\t\texit;\n\t\tend;\n\t\t\n\tend;\tinc (pov);\n\tfor l:=1 to k do\n\t\tbegin\n\t\t\n\t\tinc (j);\n\t\tif (i=x) and (j=y) then\n\t\tbegin\t\n\t\t\twriteln (pov);\n\t\t\texit;\n\t\tend;\n\t\t\n\tend;inc (pov);\n\tinc (k);\n\tfor l:=1 to k do\n\t\tbegin\n\t\t\n\t\tdec (i);\n\t\tif (i=x) and (j=y) then\n\t\tbegin\t\n\t\t\twriteln (pov);\n\t\t\texit;\n\t\tend;\n\t\t\n\tend;\n\tinc (pov);\n\tfor l:=1 to k do\n\t\tbegin\n\t\t\n\t\tdec (j);\n\t\tif (i=x) and (j=y) then\n\t\tbegin\t\n\t\t\twriteln (pov);\n\t\t\texit;\n\t\tend;\n\t\t\n\tend;inc (pov);\n\t\nend;\nwriteln ('0');\nend.\n\t\n"}, {"source_code": "var x,y,a,c,b,n,i,j:integer;f:boolean;\nbegin\nread(x,y);\ni:=0;\nj:=0;\na:=1;\nb:=1;\nc:=b;\nn:=0;\nif (x=0) and (y=0) then Writeln('0')\nelse begin\nrepeat\nf:=true;\nif (a=1) and (f=true) then begin f:=false; inc(i);dec(c);if c=0 then begin a:=2;inc(n);c:=b; end;end;\nif (a=2) and (f=true) then begin f:=false; inc(j);dec(c);if c=0 then begin a:=3;inc(n);inc(b);c:=b; end;end;\nif (a=3) and (f=true) then begin f:=false; dec(i);dec(c);if c=0 then begin a:=4; inc(n);c:=b;end;end;\nif (a=4) and (f=true) then begin f:=false; dec(j);dec(c);if c=0 then begin a:=1; inc(n);inc(b);c:=b;end;end;\n\n\nuntil (i=x) AND (j=y);\nWriteln(n-1);\nend;\nend."}, {"source_code": "Var x,y,x1,y1,k,s,res,i:longint;\nBegin\nReadln(x,y);\nIf ((x=0) or (x=1)) and (y=0) Then Begin Writeln(0); Halt; End;\nx1:=1; y1:=0;\ns:=0;\nk:=1;\nres:=1;\nWhile true do\n Begin\n If s=0 Then Begin For i:=1 to k do Begin inc(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;\n If s=1 Then Begin For i:=1 to k do Begin dec(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); End;\n If s=2 Then Begin For i:=1 to k do Begin dec(y1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(s); inc(res); inc(k); End;\n If s=3 Then Begin For i:=1 to k do Begin inc(x1); If (x1=x) and (y=y1) Then Begin Writeln(res); Halt; End; End; inc(res); End;\n s:=s mod 3;\n inc(res);\n End;\nEnd."}, {"source_code": "uses math;\nvar i,j,m,n,k,l,g,h,y,t,x:longint;\n a,b:array[1..1000]of longint;\nbegin {\n assign(input,'input1.txt');\n reset(input);\n assign(output,'output1.txt');\n rewrite(output);}\n read(x,y);\n t:=max(abs(x),abs(y));\n if (x=0)and(y=0) then\n begin\n write(0);\n halt;\n end;\n if (x>=0)and(y>=0) then\n begin\n if x0) then\n begin\n if abs(x)<=y then\n k:=t*4-2\n else\n k:=t*4-1;\n end;\n if (x<=0)and(y<=0) then\n begin\n if abs(x)>=abs(y) then\n k:=t*4-1\n else\n k:=t*4;\n end;\n if (x>0)and(y<0) then\n begin\n if abs(x)-1<=abs(y) then\n k:=(t-1)*4\n else\n k:=(t-1)*4+1;\n end;\n write(abs(k));\nend.\n"}, {"source_code": "uses math;\nvar i,j,m,n,k,l,g,h,y,t,x:longint;\n a,b:array[1..1000]of longint;\nbegin {\n assign(input,'input1.txt');\n reset(input);\n assign(output,'output1.txt');\n rewrite(output);}\n read(x,y);\n t:=max(abs(x),abs(y));\n if (x=0)and(y=0) then\n begin\n write(0);\n halt;\n end;\n if (x>=0)and(y>0) then\n begin\n if x=0) then\n begin\n if abs(x)<=y then\n k:=t*4-2\n else\n k:=t*4-1;\n end;\n if (x<=0)and(y<0) then\n begin\n if abs(x)>=abs(y) then\n k:=t*4-1\n else\n k:=t*4;\n end;\n if (x>0)and(y<=0) then\n begin\n if abs(x)-1<=abs(y) then\n k:=(t-1)*4\n else\n k:=(t-1)*4+1;\n end;\n write(abs(k));\nend.\n"}, {"source_code": "program ProblemA;\nvar a, b, x, y, i, d, ox, oy: longint;\n bool: boolean;\nbegin\n read(x, y);\n i:=0;\n a:=0;\n b:=0;\n d:=0;\n bool:=true;\n while bool do\n begin\n if (x = a) and (y = b) then bool:=false\n else\n begin\n inc(i);\n ox:=a;\n oy:=b;\n a:=a + i;\n if ((b = y) and (ox <= x) and (x <= a)) then bool:=false\n else\n begin\n ox:=a;\n inc(d);\n b:=b + i;\n if ((a = x) and (oy <= y) and (y <= b)) then bool:=false\n else\n begin\n oy:=b;\n inc(i);\n inc(d);\n a:=a - i;\n if ((b = y) and (ox >= x) and (x >= a)) then bool:=false\n else\n begin\n ox:=a;\n inc(d);\n b:=b - i;\n if ((a = x) and (oy >= y) and (y >= b)) then bool:=false\n end;\n end;\n end;\n end;\n end;\n write(d);\nend.\n"}, {"source_code": "program ProblemA;\nvar a, b, x, y, i, d, ox, oy: longint;\n bool: boolean;\nfunction Check: boolean;\n begin\n if (a <> x) or (b <> y) then Check:=true\n else Check:=false;\n end;\nbegin\n read(x, y);\n i:=0;\n a:=0;\n b:=0;\n d:=0;\n bool:=true;\n while bool do\n begin\n ox:=a;\n oy:=b;\n inc(i);\n a:=a + i;\n if not((b = y) and ((ox <= x) and (a >= x))) then\n begin\n ox:=a;\n inc(d);\n b:=b + i;\n if not((a = x) and ((oy <= y) and (b >= y))) then\n begin\n oy:=b;\n inc(i);\n inc(d);\n a:=a - i;\n if not((b = y) and ((a <= x) and (ox >= x))) then\n begin\n ox:=a;\n inc(d);\n b:=b - i;\n oy:=b;\n end\n else bool:=false;\n end\n else bool:=false;\n end\n else bool:=false;\n end;\n write(d);\nend.\n"}, {"source_code": "{$mode objfpc}\n\nuses math;\n\nconst\n fi = '';//'171a2.inp';\n fo = '';//'171a2.out';\n\nvar\n x,y: integer;\n res,round: integer;\n\nprocedure enter;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then\n begin\n writeln('0');\n halt;\n end;\n round:=max(abs(x),abs(y));\n res:=round*4;\n if abs(y)=round then\n begin\n if y>0 then res:=res-2;\n end\n else if abs(x)=round then\n begin\n if x>0 then res:=res-3;\n if x<0 then res:=res-1;\n end;\n if (x>0) and (y<=0) and (abs(y)+1=x) then dec(res);\n writeln(res);\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n enter;\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\n\nconst\n fi = '';//'171a2.inp';\n fo = '';//'171a2.out';\n\nvar\n x,y: integer;\n res,round: integer;\n\nprocedure enter;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then\n begin\n writeln('0');\n halt;\n end;\n round:=max(abs(x),abs(y));\n res:=(round-1)*4;\n if round=abs(x) then\n begin\n if x>0 then res:=res+1;\n if x<0 then res:=res+3;\n end\n else\n begin\n if y>0 then res:=res+2;\n end;\n if (x>0) and (abs(y)=x-1) then deC(res);\n if abs(x)=abs(y) then dec(res);\n writeln(res);\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n enter;\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\n\nconst\n fi = '';//'171a2.inp';\n fo = '';//'171a2.out';\n\nvar\n x,y: integer;\n res,round: integer;\n\nprocedure enter;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then\n begin\n writeln('0');\n halt;\n end;\n round:=max(abs(x),abs(y));\n res:=(round-1)*4;\n if round=abs(x) then\n begin\n if x>0 then res:=res+1;\n if x<0 then res:=res+3;\n end\n else\n begin\n if y>0 then res:=res+2;\n end;\n if (x>0) and (abs(y)=x-1) then deC(res);\n writeln(res);\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n enter;\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\n\nconst\n fi = '';//'171a2.inp';\n fo = '';//'171a2.out';\n\nvar\n x,y: integer;\n res,round: integer;\n\nprocedure enter;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then\n begin\n writeln('0');\n halt;\n end;\n round:=max(abs(x),abs(y));\n res:=round*4;\n if abs(y)=round then\n begin\n if y>0 then res:=res-2;\n end\n else if abs(x)=round then\n begin\n if x>0 then res:=res-3;\n if x<0 then res:=res-1;\n end;\n if (x>0) and (y>0) and (x=y) then dec(res);\n if (x>0) and (y<=0) and (abs(y)+1=x) then dec(res);\n writeln(res);\nend;\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n enter;\nend."}, {"source_code": "program amocana;\nvar x,y:integer;\nbegin\nread(x,y);\nif abs(y)>=abs(x) then write(4*y-2) else\nif abs(y)<=abs(x) then write(4*abs(x)-1) else\nif (x=0) and (y=0) then write(0);\nend."}, {"source_code": "program amocana;\nvar x,y:integer;\nbegin\nread(x,y);\nif (y=0) and (x=0) then write(0);\nif (y>x) and (-x=x) and (-x>y) then write(-4*x-1);\nif (y-x+1) then write(4*x-3);\nend."}, {"source_code": "var x,y,i:longint;s1,s2:int64;\nbegin\nreadln(x,y);\nif (x=0)and(y=0)\nthen begin\n writeln(0);\n exit;\n end;\nfor i:=1 to abs(y) do\ns1:=s1+4;\nfor i:=1 to abs(x) do\ns2:=s2+4;\nif (x>y)and(x-1<=abs(y))and(y<0)\nthen writeln(s1)\nelse if ((x=y)or(abs(x)>y))and(x<0)\n then writeln(s2-1)\n else if y>x\n then writeln(s1-2)\n else writeln(s2-3);\nend."}, {"source_code": "var x,y,i:longint;s1,s2:longint;\nbegin\nreadln(x,y);\nfor i:=1 to abs(y) do\ns1:=s1+4;\nfor i:=1 to abs(x) do\ns2:=s2+4;\nif (x>y)and(x-1<=abs(y))\nthen writeln(s1)\nelse if ((x=y)or(abs(x)>y))and(x<0)\n then writeln(s2-1)\n else if y>x\n then writeln(s1-2)\n else writeln(s2-3);\nend."}, {"source_code": "var\n a:array[-3..3,-3..3] of longint;\n i,j,k,x,y:longint;\nbegin\nreadln(x,y);\nif (y=0)and((x=1)or(x=0)) then\n begin\n writeln(0);\n halt;\n end;\na[0,0]:=-1;\na[0,1]:=-1;\ni:=0;\nj:=1;\nk:=0;\nwhile (j<>x)or(i<>y) do\n begin\n inc(k);\n while a[i,j-1]=-1 do\n begin\n inc(i);\n a[i,j]:=-1;\n if (j=x)and(i=y) then\n begin\n write(k);\n halt;\n end;\n end;\n inc(k);\n while a[i-1,j]=-1 do\n begin\n dec(j);\n a[i,j]:=-1;\n if (j=x)and(i=y) then\n begin\n write(k);\n halt;\n end;\n end;\n inc(k);\n while a[i,j+1]=-1 do\n begin\n dec(i);\n a[i,j]:=-1;\n if (j=x)and(i=y) then\n begin\n write(k);\n halt;\n end;\n end;\n inc(k);\n while a[i+1,j]=-1 do\n begin\n inc(j);\n a[i,j]:=-1;\n if (j=x)and(i=y) then\n begin\n write(k);\n halt;\n end;\n end;\n end;\nend.\n"}, {"source_code": "function mog(n,m : longint) : integer;\nbegin\nif m<0 then m:=m*-1;\nif n<0 then n:=n*-1;\nif n>m then mog:=1;\nif m>n then mog:=2;\n//if n=m then mog:=0;\nend;\nvar i,i2,n,m,x,y,ans : longint;\n c : char;\nbegin\nreadln(x,y);\nif (x<0) and (mog(x,y)=1) and (y<>x*-1) then c:='l';\nif (x>0) and (mog(x,y)=1) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';\nif (y>0) and (mog(x,y)=2) and (x<>y*-1) then c:='u';\nif (y<0) and ( (mog(x,y)=2) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';\n\nif c='r' then ans:=x*4-3;\nif c='l' then ans:=(x*-1)*4-1;\nif c='d' then ans:=(y*-1)*4;\nif c='u' then ans:=y*4-2;\nwriteln(ans);\nreadln;\nend."}, {"source_code": "function mog(n,m : longint) : integer;\nbegin\nif m<0 then m:=m*-1;\nif n<0 then n:=n*-1;\nif n>=m then mog:=1;\nif m>n then mog:=2;\n//if n=m then mog:=0;\nend;\nvar i,i2,n,m,x,y,ans : longint;\n c : char;\nbegin\nreadln(x,y);\nif (x<0) and (mog(x,y)=1) and (y<>x*-1) then c:='l';\nif (x>0) and (mog(x,y)=1) and (y<>(x-1)*-1) and (y<>x*-1) then c:='r';\nif (y>0) and (mog(x,y)=2) and (x<>y*-1) then c:='u';\nif (y<0) and ( (mog(x,y)=2) or (mog(x,y)=1) and (x=(y*-1)+1) ) and (x<>y) then c:='d';\n\nif c='r' then ans:=x*4-3;\nif c='l' then ans:=(x*-1)*4-1;\nif c='d' then ans:=(y*-1)*4;\nif c='u' then ans:=y*4-2;\nwriteln(ans);\nreadln;\nend."}, {"source_code": "var i,j,k:longint;\n begin\n read(i,j);\n k:=0;\n\n if (i=j)and(i>0) then k:=(abs(i)-1)*4+1;\n if (i=j)and(j<0) then k:=(abs(i)-1)*4+3;\n\n if (i>j) then k:=(abs(i)-1)*4;\n if (i0) then k:=(abs(i)-1)*4+1;\n if (i=j)and(j<0) then k:=(abs(i)-1)*4+3;\n\n if (i>j) then k:=(abs(i)-1)*4;\n if (i 0 then\n begin\n yl := -( x - 1 );\n yh := x;\n res := ( x - 1 ) * 4;\n if y = yl then\n begin\n writeln( res );\n exit;\n end;\n if ( yl < y ) and ( y <= yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + ( abs( y ) - x + 1 ) * 4 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + ( y - yh ) * 4 + 2 );\n exit;\n end;\n end;\n if x < 0 then\n begin\n yl := x; yh := -x;\n res := yh * 4 - 2;\n if y = yh then\n begin\n writeln( res );\n exit;\n end;\n if ( y >= yl ) and ( y < yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + 4 * ( y - yh ) );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + 4 * ( yl - y ) + 1 );\n exit;\n end;\n end;\n if x = 0 then\n begin\n if y > 0 then\n begin\n writeln( 2 + 5 * ( y - 1 ) );\n exit;\n end;\n if y < 0 then\n begin\n writeln( 4 + 5 * ( abs( y ) - 1 ) );\n exit;\n end;\n end;\nend.\n\n"}, {"source_code": "{$mode objfpc}\n\n\nvar x , y , yl , yh , res : integer;\n\n\nbegin\n readln( x , y ); res := 0;\n if ( x = 0 ) and ( y = 0 ) then\n begin\n writeln( 0 );\n exit;\n end;\n if x > 0 then\n begin\n yl := -( x - 1 );\n yh := x; res := ( x - 1 ) * 4;\n if y = yl then\n begin\n writeln( res );\n exit;\n end;\n if ( yl < x ) and ( x <= yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + ( abs( y ) - x + 1 ) * 4 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + ( y - yh ) * 4 + 2 );\n exit;\n end;\n end;\n if x < 0 then\n begin\n yl := x; yh := -x;\n res := yh * 4 - 2;\n if y = yh then\n begin\n writeln( res );\n exit;\n end;\n if ( y >= yl ) and ( y < yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + 4 * ( y - yh ) );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + 4 * ( yl - y ) + 1 );\n exit;\n end;\n end;\n if x = 0 then\n begin\n if y > 0 then\n begin\n writeln( 2 + 5 * ( y - 1 ) );\n exit;\n end;\n if y < 0 then\n begin\n writeln( 4 + 5 * ( abs( y ) - 1 ) );\n exit;\n end;\n end;\nend.\n\n"}, {"source_code": "{$mode objfpc}\n\n\nvar x , y , yl , yh , res : integer;\n\n\nbegin\n readln( x , y ); res := 0;\n if ( x = 0 ) and ( y = 0 ) then\n begin\n writeln( 0 );\n exit;\n end;\n if x > 0 then\n begin\n yl := -( x - 1 );\n yh := x;\n res := ( x - 1 ) * 4;\n if y = yl then\n begin\n writeln( res );\n exit;\n end;\n if ( yl < y ) and ( y <= yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + ( abs( y ) - x + 1 ) * 4 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + ( y - yh ) * 4 + 2 );\n exit;\n end;\n end;\n if x < 0 then\n begin\n yl := x; yh := -x;\n res := yh * 4 - 2;\n if y = yh then\n begin\n writeln( res );\n exit;\n end;\n if ( y >= yl ) and ( y < yh ) then\n begin\n writeln( res + 1 );\n exit;\n end;\n if y > yh then\n begin\n writeln( res + 4 * ( y - yh ) );\n exit;\n end;\n if y < yl then\n begin\n writeln( res + 4 * ( yl - y ) + 2 );\n exit;\n end;\n end;\n if x = 0 then\n begin\n if y > 0 then\n begin\n writeln( 2 + 5 * ( y - 1 ) );\n exit;\n end;\n if y < 0 then\n begin\n writeln( 4 + 5 * ( abs( y ) - 1 ) );\n exit;\n end;\n end;\nend.\n\n"}, {"source_code": "var i, j, ans:longint;\nbegin\n readln(i, j);\n ans:=0;\n if (j<=i)and(j>=(-i+2)) then ans:=(i-1)*4+1;\n if (i>=(-j))and(i<=(j-1)) then ans:=(j-1)*4+2;\n if (j<=(abs(i)-1))and(j>=i) then ans:=(abs(i)-1)*4+3;\n if (i<=(abs(j)+1))and(i>=(j+1)) then ans:=(abs(j)-1)*4+4;\n\n write(ans);\nend."}, {"source_code": "var i, j, ans:longint;\nbegin\n// assign(input, 'input.txt');reset(input);\n// assign(output, 'output.txt');rewrite(output);\n\n readln(i, j);\n ans:=0;\n if (j<=i)and(j>=(-i+2)) then ans:=(i-1)*4+1;\n if (i>=(-j))and(i<=(j-1)) then ans:=(j-1)*4+2;\n if (j<=(abs(i)-1))and(j>=i) then ans:=(abs(i)-1)*4+3;\n if (i<=(abs(j)+1))and(i>=(j+1)) then ans:=(abs(j)-1)*4+4;\n\n //f x=0\n writeln(ans);\n// close(input);close(output);\nend."}, {"source_code": "var x,y,z:shortint; turn:word=0;\nbegin\n read(x,y);\n z:=y;\n while z<>0 do\n begin\n inc(turn,2);\n if z>0 then z:=1-z\n else z:=-z\n end;\n if (x=y) and (x<>0) then dec(turn);\n write(turn)\nend."}, {"source_code": "program kon;\n\n{$mode objfpc}{$H+}\n\nvar x, y, ans: integer;\n\nbegin\n { assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output); }\n read(x, y);\n\n if (x=y) and (x<0) then\n ans:=abs(x)*4-1;\n\n\n if (x>y) and (y<0) then\n ans:=4*abs(y);\n\n if (x>=y) and (x>0) and (-(x-1)<>y) then\n ans:=ans+(x-1)*4+1;\n\n if (y>x) then\n ans:=(y-1)*4+2;\n\n if (x<0) and (abs(x)>abs(y)) then\n ans:=(abs(x)-1)*4+3;\n\n write(ans);\n{ close(input);\n close(output); }\n end.\n\n"}, {"source_code": "program ex;\nvar\nx,y:integer;\ni,j,kx,ky,m:longint;\na,b:integer;\nflag:booleaN;\nbegin\nreadln(kx,ky);\nm:=0;\nx:=0;\ny:=0;\na:=0;\nb:=0;\nflag:=true;\nwhile (x<>kx)or(y<>ky) do begin\nif flag then begin\nif a>=0 then inc(a);\nif a>0 then for i:=1 to a do begin inc(x); if (x=kx)and(y=ky) then begin write(m);exit;end;end;\nif a<0 then dec(a);\nif a<0 then for i:=-1 downto a do begin dec(x); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\na:=-a;end\nelse begin if b>=0 then inc(b);\nif b>0 then for i:=1 to b do begin inc(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\nif b<0 then dec(b);\nif b<0 then for i:=-1 downto b do begin dec(y); if (x=kx)and(y=ky) then begin write(m);exit;end; end;\nb:=-b; end;\ninc(m);\n\nflag:=not flag;\nend;\n\nend."}, {"source_code": "var \n x,y,startX,startY:integer;\n counter:integer;\nBegin\nread(x,y);//oo-start\nif (x=1) and (y=0) then begin counter:=0;\nwriteln(counter);\nexit;\nend;\nif (x>=0) and (y>=-x+1) and (y<=x) then \n counter:=4*(x-1)+1;\nif (x<=0) and (y<=-x) and (y>=x) then\n counter:=4*(-x)-1;\nif (y>=0) and (x>=-y) and (x<=y) then \n counter:=4*y-2;\nif (y<=0) and (x>=-y) and (x<=-y+1) then \n counter:=4*(-y);\n writeln(counter);\nend."}, {"source_code": "var \n x,y,startX,startY:integer;\n counter:integer;\nBegin\nread(x,y);//oo-start\nif (x=1) and (y=0) then begin counter:=0;\nwriteln(counter);\nexit;\nend;\nif (x=1) and (y=1) then begin counter:=1;\nwriteln(counter);\nexit;\nend;\nif (x=0) and (y=-1) then begin counter:=4;\nwriteln(counter);\nexit;\nend;\n\nif (x>=0) and (y>=-x+1) and (y=x) then\n counter:=4*(-x)-1;\nif (y>=0) and (x>=-y) and (xy) and (x<=-y+1) then \n counter:=4*(-y);\n writeln(counter);\nend.\n"}, {"source_code": "var x,y,x1,y1,k:longint;\nbegin\n readln(x,y);\n if (x=0) and (y=0) then k:=0\n else if (x=1) and (y=0) then k:=0\n else if (x=1) and (y=1) then k:=1\n else if (x=0) and (y=1) then k:=2\n else if (x=-1) and (y=1) then k:=2\n else if (x=-1) and (y=0) then k:=3\n else if (x=-1) and (y=-1) then k:=3\n else if (x=0) and (y=-1) then k:=4\n else if (x=1) and (y=-1) then k:=4\n else if (x=2) and (y=-1) then k:=4\n ELSE\n BEGIN\n x1:=abs(x);\n y1:=abs(y);\n if (x1>y1) then BeGiN if (x>0) then k:=1+(x1-1)*4\n else k:=3+(x1-1)*4\n EnD\n else BeGiN if (y>0) then k:=2+(y1-1)*4\n else k:=4+(y1-1)*4;\n EnD;\n END;\n writeln(k);\nend."}], "src_uid": "2fb2a129e01efc03cfc3ad91dac88382"} {"source_code": "var n,ans,ans2:int64;\n i,j,k:longint;\n\nfunction gcd(a,b:int64):int64;\nbegin\n while (a>0) and (b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n gcd:=a+B;\nend;\n\n\nfunction solve(a,b,c:int64):int64;\nvar d:int64;\nbegin\n if a<1 then a:=1;\n if b<1 then b:=1;\n if c<1 then c:=1;\n d:=a div gcd(a,b)*b;\n d:=d div gcd(d,c)*c;\n solve:=d;\nend;\n\nbegin\n readln(n);\n ans:=0;\n for i:= 0 to 10 do\n for j:= 0 to 10 do\n for k:= 0 to 10 do\n begin\n ans2:=solve(n-i,n-j,n-k);\n if ans2>ans then ans:=ans2;\n end;\n writeln(ans);\nend.", "positive_code": [{"source_code": "program pc;\nvar\n n , mm , dd : int64;\nbegin\n readln ( n );\n mm := n mod 3;\n dd := n div 3;\n if n = 1 then begin writeln ( 1 ); exit; end;\n if n = 2 then begin writeln ( 2 ); exit; end;\n if n = 3 then begin writeln ( 6 ); exit; end;\n if mm = 0 then\n begin\n if dd and 1 = 0 then writeln ( ( n - 3 ) * ( n - 1 ) * ( n - 2 ) )\n else writeln ( n * (n - 1) * ( n - 2 ) );\n end\n else\n if mm = 1 then\n begin\n if dd and 1 = 0 then writeln ( n * (n - 1) * ( n - 2 ) )\n else writeln ( n * (n - 1) * ( n - 3 ) );\n end\n else\n begin\n if dd and 1 = 1 then writeln ( n * (n - 1) * ( n - 2 ) )\n else writeln ( n * (n - 1) * ( n - 3 ) );\n end;\nend."}, {"source_code": "uses math;\nvar\n n, res : int64;\nbegin\n read(n);\n if n = 1 then writeln(1)\n else\n if n = 2 then writeln(2)\n else\n if n = 3 then writeln(6)\n else\n if n = 6 then writeln(60)\n else\n if (n mod 6 = 0) then\n begin\n res := (n-1)*(n-2)*(n-3);\n writeln(res);\n end\n else\n if n mod 2 = 0 then\n begin\n res := n*(n-1)*(n-3);\n writeln( res );\n end\n else\n begin\n res := n*(n-1)*(n-2);\n writeln(res);\n end;\nend.\n"}, {"source_code": "var n,max:int64;\nbegin\nreadln(n);\nif n<3 then begin write(n); halt; end;\nif odd(n) then max:=n*(n-1)*(n-2) else begin\nif n mod 3=0 then max:=(n-2)*(n-1)*(n-3) else max:=n*(n-1)*(n-3);\nif (n*(n-1)*(n-2) div 2>max)then max:=n*(n-1)*(n-2) div 2;\nend;\nwrite(max);\nend."}, {"source_code": "var i: LongInt;\n n,c, max: int64;\n\nfunction NOD(x,y: Int64): Int64;\nBegin\n If x<>0 then NOD:=NOD(y mod x,x) else NOD:=y;\nEnd;\n\nfunction NOK(x,y: Int64): Int64;\nBegin\n NOK:=(x div NOD (x,y))*y;\nend;\n\nbegin\n Readln(n);\n max:=0;\n\n if n=1 then\n begin\n Writeln('1');\n halt(0);\n end;\n\n if n=2 then\n begin\n Writeln('2');\n halt(0);\n end;\n\n\n for i:=n downto 3 do\n begin\n c:=NOK(i,i-1);\n c:=NOK(c, i-2);\n if c>max then max:=c;\n\n c:=NOK(i,i-1);\n c:=NOK(c, i-3);\n if c>max then max:=c;\n \n c:=NOK(i-1,i-2);\n c:=NOK(c, i-3);\n if c>max then max:=c;\n end;\n\nWriteln(max);\n\nend."}, {"source_code": "uses math;\nvar n: int64;\nfunction gcd(x, y: int64): int64;\nbegin\n if y = 0 then\n exit(x)\n else\n exit(gcd(y, x mod y));\nend;\nbegin\n readln(n);\n if n < 3 then\n writeln(n)\n else if n mod 2 = 1 then\n writeln(n * (n - 1) * (n - 2))\n else\n writeln(max(n * (n - 1) * (n - 2) div 2, max((n - 1) * (n - 2) * (n - 3), n * (n - 1) * (n - 3) div gcd(n, n - 3) div gcd(n - 1, n - 3))));\nend."}, {"source_code": "var n,ans:int64;\nbegin\n readln(n);\n ans:=0;\n if n=1 then ans:=1 else\n if n=2 then ans:=2 else\n if n mod 2=1 then ans:=n*(n-1)*(n-2) else\n if n mod 3<>0 then ans:=n*(n-1)*(n-3) else\n ans:=(n-1)*(n-2)*(n-3);\n writeln(ans);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a1, a2, j, mx, z1 : int64;\n n, i : integer;\n\nfunction gcd(a, b : int64) : int64;\nbegin\n if (a = 0) or (b = 0) then\n result := a + b\n else\n result := gcd(max(a, b) mod min(a, b), min(a, b));\nend;\n\nbegin\n\n read(n);\n\n mx := n;\n if n mod 2 = 0 then\n a1 := max(1, n - 1)\n else\n a1 := max(1, n);\n a2 := max(1, a1 - 1);\n for i := n downto n div 2 do begin\n j := i;\n z1 := (a1 * a2 * j div gcd(a1 * a2, j));\n mx := max(mx, z1);\n end;\n\n if n mod 2 = 1 then\n a1 := max(1, n - 1)\n else\n a1 := max(1, n);\n a2 := max(1, a1 - 1);\n for i := n downto n div 2 do begin\n j := i;\n z1 := (a1 * a2 * j div gcd(a1 * a2, j));\n mx := max(mx, z1);\n end;\n\n writeln(mx);\n\n readln;readln;\nend."}, {"source_code": "uses math;\nconst\n nmax = 100;\nvar\n m:longint;\n n,res:int64;\nfunction UCLN(u,v:int64):int64;\nbegin\n if v=0 then exit(u) else exit(UCLN(v,u mod v));\nend;\nprocedure nhap;\nvar i,j,t:longint;\nu,v:int64;\nbegin\n read(n);\n if (n=1) then writeln(1)\n else if n=2 then writeln(2)\n else if n=3 then writeln(6)\n else\n begin\n res:=0;\n for i:=max(1,n-70) to n do for j:=max(1,n-70) to n do for t:=max(1,n-70) to n do\n begin\n u:=(int64(i)*j)div UCLN(i,j);\n v:=(u*t)div UCLN(u,t);\n res:=max(res,v);\n end;\n writeln(res);\n end;\nend;\nprocedure xuly;\nvar i,j,t,res1,res2,res3:longint;\nu,v:int64;\nbegin\n res:=0;\n for i:=1 to n do for j:=1 to n do for t:=1 to n do\n begin\n u:=(i*j)div UCLN(i,j);\n v:=(u*t)div UCLN(u,t);\n if resp then\n p:=q*j div gg;\n end;\n ans:=p;\n end;\n if n<3 then ans:=n;\n writeln(ans);\nend.\n"}, {"source_code": "var\n i1,i2,i3,j,n,m,k:longint;\n ans:int64;\n\n function max(x,y:int64):int64;\n begin\n if x>y then max:=x\n else max:=y;\n end;\n\n\n function gcd(x,y:int64):int64;\n begin\n while (X<>0)and(y<>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n exit(x+y);\n end;\n\n function fun(x,y,z:int64):int64;\n var\n k:int64;\n begin\n if (x<=0)or(y<=0)or(z<=0) then exit(-maxlongint);\n k:=(x*y) div gcd(x,y);\n exit((k*z) div gcd(k,z));\n end;\n\n\nbegin\n readln(n);\n for i1:=0 to 10 do\n for i2:=0 to 10 do\n for i3:=0 to 10 do\n ans:=max(ans,fun(n-i1,n-i2,n-i3));\n writeln(ans);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n i, j, k: integer;\n n: integer;\n i1, t, res: int64;\n\nfunction gcd(a, b: int64): int64;\nbegin\n if a = 0 then\n result := b\n else\n if b = 0 then\n result := a\n else\n result := gcd(min(a, b), max(a, b) mod min(a, b));\nend;\n\nbegin\n // reset(input, 'a.in');\n// rewrite(output, 'a.out');\n\n readln(n);\n\n res := 1;\n for i := n downto max(1, n - 150) do begin\n for j := i to n do\n for k := j to n do begin\n i1 := i;\n t := (i1 * j) div gcd(i, j);\n t := (t * k) div gcd(t, k);\n res := max(res, t);\n end;\n end;\n\n writeln(res);\nend.\n "}, {"source_code": "uses math;\ntype mass=array[1..1000000] of int64;\nvar r,l,a,z,i,c,k,b,j:integer;s,s1:string;u:boolean;n,res,de:int64;m:mass;\nbegin\n// reset(input,'input.txt');\n// assign(output,'output.txt');\n readln(n);\n if n=1\n then writeln(1)\n else if n<4\n then writeln((n-1)*n)\n else if n mod 2=1\n then writeln((n-1)*(n-2)*n)\n else if n mod 3=0\n then writeln((n-1)*(n-2)*(n-3))\n else writeln((n-1)*n*(n-3));\nend.\n"}, {"source_code": "var n,max:int64;\nbegin\nreadln(n);\nif n<3 then begin write(n); halt; end;\nif odd(n) then max:=n*(n-1)*(n-2) else begin\nif n mod 3=0 then max:=(n-2)*(n-1)*(n-3) else max:=n*(n-1)*(n-3);\nif (n*(n-1)*(n-2) div 2>max)then max:=n*(n-1)*(n-2) div 2;\nend;\nwrite(max);\nend."}, {"source_code": "VAR\n a,n:int64;\n begin\n readln(n);\n if n=1 then\n begin\n writeln('1');\n exit;\n end;\n if n=2 then\n begin\n writeln('2');\n exit;\n end;\n if n mod 2=1 then a:=n*(n-1)*(n-2)\n else if n mod 3=0 then a:=(n-1)*(n-2)*(n-3)\n else a:=n*(n-1)*(n-3);\n writeln(a);\nend."}, {"source_code": "var w,res,n:int64;\n q,i,j,k:longint;\n function nsk(x,y:int64):int64;\n var res:int64;\n begin\n res:=x*y;\n while (x>0) and (y>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n nsk:=res div (x+y);\n end;\n begin\n read(n);\n for i:=1 to n do\n begin\n w:=nsk(n*(n-1),i);\n if w>res then res:=w;\n end;\n q:=1;\n if n-51>q then q:=n-51;\n for i:=q to n do\n for j:=q to n do\n for k:=q to n do\n begin\n w:=nsk(i,nsk(j,k));\n if w>res then res:=w;\n end;\n writeln(res);\n end."}, {"source_code": "{$mode objfpc}\n\n\nuses math;\n\n\nconst InputFile = 'ProblemC.inp';\n maxN = trunc( 1E6 );\n\n\nvar n , res : int64;\n\n\nprocedure Result( res : int64 );\n begin\n writeln( res );\n halt;\n end;\n\n\nbegin\n readln( n );\n if n = 1 then Result( 1 );\n if n = 2 then Result( 2 );\n if n = 3 then Result( 6 );\n if odd( n ) then\n res := n * ( n - 1 ) * ( n - 2 )\n else\n begin\n if n mod 3 = 0 then\n res := ( n - 1 ) * ( n - 2 ) * ( n - 3 )\n else\n res := n * ( n - 1 ) * ( n - 3 );\n end; \n Result( res );\nend."}, {"source_code": "var i,j,n,k,d1,d2,d3: longint;\n lcm,t: int64;\nlabel 1,2;\n\nFunction GCD(a,b: longint): longint;\nbegin\n while (a>0) and (b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n GCD:=a+b\nend;\n\nbegin\n readln(n); lcm:=n*(n-1); if n=1 then lcm:=1;\n for i:=n downto 1 do\n for j:=i-1 downto 1 do\n for k:=j-1 downto 1 do\n begin\n d1:=gcd(i,j); d2:=gcd(i,k); d3:=gcd(j,k);\n t:=int64(i)*int64(j)*int64(k) div d1 div d2 div d3;\n\n if t >lcm then lcm:=t;\n\n if (d1=1) and (d2=1) and (d3=1) then begin goto 1 end;\n end;\n1:\n dec(n);\n for i:=n downto 1 do\n for j:=i-1 downto 1 do\n for k:=j-1 downto 1 do\n begin\n d1:=gcd(i,j); d2:=gcd(i,k); d3:=gcd(j,k);\n t:=int64(i)*int64(j)*int64(k) div d1 div d2 div d3;\n\n if t >lcm then lcm:=t;\n\n if (d1=1) and (d2=1) and (d3=1) then begin goto 2 end;\n end;\n\n2:\n writeln(lcm)\nend."}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\n\nconst besk=200000000000000;\n nnn=2000000; modul=1000000007;\n label 1,2,3,4;\nvar p1,p2,step,y,n1,m1,pl,i1,i2,i0,j0,jj,kol,k,kk,shag,i,j,ii,start,finish,pp:longint;\nt1,t2,t3,n,ot,raz,l,r,numgr,c,a,x,b,pmin,pmax,s,smax,imax,jmax,t,ot1,ot2,p,nn,tt,kor,bal,dx1,dy1,t1old,t2old,f,mmin,imin,m,k1,k2,a2:int64;\ncentr,koef:int64;\nch,ch1,ch2:char;\nest:array[0..1000] of boolean;\noch,ost:array[0..200002] of int64;\ngreen,red:array[-20..200,-20..40000] of longint;\nflag2,flag1,flag:boolean;\ntr,rt:extended;\nvz,prost:array[-10..3000000] of boolean;\nc1,c2:char;\ncc1,cc2,aa,bb,cc,h:extended;\nmarked:array[-5..52,0..52,0..52,0..52] of boolean;\n{stop:array[0..200] of longint; }\nzan:array[0..1000] of boolean;\ndd :extended;\nss:string;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function pprost(k:longint):boolean; var i,j,s:longint; t:double; fl:boolean;\nbegin\n t:=sqrt(k); fl:=true;\n s:=round(t);\n for i:=2 to s do if k mod i=0 then fl:=false;\n pprost:=fl;\n\nend;\n\n function nok(a,b,c:int64):int64; var k,p,t:int64;\nbegin\n k:=a*b div nod(a,b);\n p:=c*k div nod(c,k);\n nok:=p;\nend;\n\n\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(n);\n if n<202 then\n begin\n for i:=1 to n do for j:=i to n do for k:=j to n do\n if nok(i,j,k)>imax then begin imax:=nok(i,j,k); a:=i;b:=j; c:=k; end;\n writeln(imax); goto 1;\n end;\n if odd(n) then begin writeln(n*(n-1)*(n-2)); goto 1; end;\n p:=n*(n-1);\n k:=n-1;\n for i:=n downto n-200 do for j:=i-1 downto (n-200) do for k:=j-1 downto (n-200) do\n begin\n t1:=i;t2:=j;t3:=k;\n s:=nok(t1,t2,t3);\n if s>t then begin a:=t1;b:=t2; c:=t3; t:=s; end;\n\n end;\n {\n repeat dec(k); if nok(n,n-1,k)>imax then imax:=nok(n,n-1,k);\n until pprost(k)or(k0) and (b<>0) do\nif a>b then\n a:=a mod b\nelse\n b:=b mod a;\ngcd:=a+b;\nend;\n\n\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(n);\n if n=1 then begin\n write(1);\n halt;\n end;\n if n=2 then begin\n write(2);\n halt;\n end;\n if n=3 then begin\n write(6);\n halt;\n end;\n mx:=0;\n for j:=n downto max(3,n-10) do begin\n ans:=int64(j)*int64(j-1);\n i:=j-2;\n while (gcd(j,i)<>1) or (gcd(j-1,i)<>1) do\n dec(i);\n if mx0) and (b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n nod:=a+b;\nend;\n\n\nbegin\n\n readln(n); answer:=0; x:=max(n-3,1);\n while x<=n do\n begin\n y:=max(n-3,1); while y<=n do\n begin\n z:=max(n-3,1); while z<=n do\n begin\n i:=nod(x,y); i:=(x*y) div i;\n j:=nod(i,z); j:=(i*z) div j;\n answer:=max(answer,j); inc(z);\n end;\n inc(y);\n end;\n inc(x);\n end;\n writeln(answer);\n\nend."}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\n\nconst besk=200000000000000;\n nnn=2000000; modul=1000000007;\n label 1,2,3,4;\nvar p1,p2,step,y,n1,m1,pl,i1,i2,i0,j0,jj,kol,k,kk,shag,i,j,ii,start,finish,pp:longint;\nt1,t2,t3,n,ot,raz,l,r,numgr,c,a,x,b,pmin,pmax,s,smax,imax,jmax,t,ot1,ot2,p,nn,tt,kor,bal,dx1,dy1,t1old,t2old,f,mmin,imin,m,k1,k2,a2:int64;\ncentr,koef:int64;\nch,ch1,ch2:char;\nest:array[0..1000] of boolean;\noch,ost:array[0..200002] of int64;\ngreen,red:array[-20..200,-20..40000] of longint;\nflag2,flag1,flag:boolean;\ntr,rt:extended;\nvz,prost:array[-10..3000000] of boolean;\nc1,c2:char;\ncc1,cc2,aa,bb,cc,h:extended;\nmarked:array[-5..52,0..52,0..52,0..52] of boolean;\n{stop:array[0..200] of longint; }\nzan:array[0..1000] of boolean;\ndd :extended;\nss:string;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function pprost(k:longint):boolean; var i,j,s:longint; t:double; fl:boolean;\nbegin\n t:=sqrt(k); fl:=true;\n s:=round(t);\n for i:=2 to s do if k mod i=0 then fl:=false;\n pprost:=fl;\n\nend;\n\n function nok(a,b,c:int64):int64; var k,p,t:int64;\nbegin\n k:=a*b div nod(a,b);\n p:=c*k div nod(c,k);\n nok:=p;\nend;\n\n\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(n);\n if n<202 then\n begin\n for i:=1 to n do for j:=i to n do for k:=j to n do\n if nok(i,j,k)>imax then begin imax:=nok(i,j,k); a:=i;b:=j; c:=k; end;\n writeln(imax); goto 1;\n end;\n if odd(n) then begin writeln(n*(n-1)*(n-2)); goto 1; end;\n p:=n*(n-1);\n k:=n-1;\n for i:=n downto n-100 do for j:=i-1 downto (n-100) do for k:=j-1 downto (n-100) do\n begin\n t1:=i;t2:=j;t3:=k;\n s:=nok(t1,t2,t3);\n if s>t then begin a:=t1;b:=t2; c:=t3; t:=s; end;\n\n end;\n {\n repeat dec(k); if nok(n,n-1,k)>imax then imax:=nok(n,n-1,k);\n until pprost(k)or(k 0 do begin\n if b * i div gcd(i, b) > c then c := b * i div gcd(i, b);\n dec(i);\n end;\n a := a - (1 - a mod 2);\n if c > a * (a - 1) * (a - 2) then writeln(c)\n else writeln(a * (a - 1) * (a - 2));\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If mans then ans:=x;\n end;\n\na:=n-1; b:=n-2; c:=n;\nfor i:=c downto 1 do\n begin\n x:=lcm(a*b,i);\n if x>ans then ans:=x;\n end;\n\n\nwriteln(ans);\n//readln;\n//close(input); close(output);\nend."}, {"source_code": "var n : int64;\nfunction NO (d1,d2 : int64) : int64;\nvar x,y : int64;\nbegin\n x:=d1;\n y:=d2;\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n x:=x+y;\n NO:=(d1 div x)*d2;\nend;\nfunction NOK (q1,q2,q3 : int64) : int64;\nbegin\n NOK:=No(No(q1,q2),q3);\nend;\nfunction max (x,y : int64) : int64;\nbegin\n if x>y then max:=x else max:=y;\nend;\nbegin\n readln(n);\n if n=1 then writeln(1) else\n if n=2 then writeln(2) else\n if n=3 then writeln(6) else\n if n=4 then writeln(12) else\n if n=5 then writeln(60) else\n if n mod 2=1 then writeln(Nok(n,n-1,n-2)) else\n if n mod 2=0 then writeln(Max(Nok(n,n-1,n-2),Max(Nok(n,n-1,n-3),Nok(n-1,n-2,n-3))));\nend.\n"}, {"source_code": "uses math;\nvar \nkk,k:int64;\nl,r,x1,y1,nn,inf,x,y,dd,ans,j,v,ss,i,n,m,s:longint;\nmark,q,dp,xx,yy,mas2:array[0..100003] of longint;\na:array[0..4003,0..4000] of longint;\nch:char;\nfunction gcd(b,a:int64):int64;\nbegin\n{writeln (b,a);}\nif a=0 then gcd:=b\nelse gcd:=gcd(a,b mod a);\nend;\nbegin\nreadln (n);\nif n=1 then begin writeln (1);halt end else\nif n=2 then begin writeln (2);halt end else\nif n=3 then begin writeln (6);halt end;\nif n=4 then begin writeln (12);halt end;\n\ni:=n-1;\nfor i:=max(1,n-100) to n do\n for j:=max(1,n-100) to n do\n for m:=max(1,n-100) to n do\n \n begin\n kk:=(i) div gcd(i,j)*(j);\n k:=max (k, m div gcd(m,kk)*kk ); \n end; \n\nwriteln (k);\nEND."}, {"source_code": "uses math;\nvar\n n,p,k,r,m:int64;\n i:longint;\nfunction mcd (a,b:int64):int64;\nvar\n t:int64;\nbegin\n while (a mod b<>0) do\n begin\n t:=a mod b;\n a:=b;\n b:=t;\n end;\n mcd:=b;\nend;\nbegin\n readln(n);\n if n<=2 then\n writeln(n)\n else\n if n mod 2=1 then\n writeln(n*(n-1)*(n-2))\n else\n begin\n r:=(n-1)*(n-2)*(n-3);\n p:=n*(n-1);\n i:=n-2;\n while i>=1 do\n begin\n m:=mcd(p,i);\n k:=(p div m)*i;\n if k>r then\n begin\n r:=k;\n break;\n end;\n i:=i-1;\n if p*i<=r then\n break;\n end;\n writeln(r);\n end;\nend. "}, {"source_code": "uses math;\nconst lim = 100;\n\n\nprocedure swap( var a, b : int64 );\nvar w : int64;\nbegin\n w:=a; a:=b; b:=w;\nend; \n\nfunction GCD( a , b : int64 ): int64;\nbegin\n\n if b > a then swap( a , b );\n \n while b > 0 do begin\n a:=a mod b;\n swap( a , b );\n end;\n \n exit( a );\n \nend;\n\nfunction LCM( a ,b : int64 ):int64;\nbegin\n \n a:=(a * b) div GCD( a , b );\n \n exit( a );\n \nend; \n \n\n\n\nvar a , b , c , lb , ub , n : longint;\n ans : int64;\nbegin\n\n readln( n );\n \n ub:=n;\n \n n:=n - lim;\n \n if n <= 0 then lb:=1\n else lb:=n;\n \n ans:=0;\n \n for a:=lb to ub do begin\n for b:=a to ub do begin\n for c:=b to ub do begin\n ans:=max( ans , LCM( LCM( int64(a) , int64(b) ) , int64(c) ) );\n end;\n end;\n end;\n \n writeln( ans );\n \nend. \n \n"}, {"source_code": "var\n n : int64;\n hasil : int64;\nbegin\n readln (n);\n if n = 1 then writeln (1) else\n if n = 2 then writeln (2) else\n if n = 3 then writeln (6) else\n if n mod 2 = 1 then begin\n hasil := n * (n-1) * (n-2);\n //writeln (n, n-1, n-2);\n writeln (hasil);\n end else begin\n if n mod 3 = 0 then hasil := (n-1) * (n-2) * (n-3)\n else hasil := n * (n-1) * (n-3);\n //writeln (n, n-1, n-3);\n writeln (hasil);\n end;\nend.\n"}, {"source_code": "var s,n:int64;\nfunction ucln(a,b:int64):int64;\nbegin\n if b=0 then exit(a);\n exit(ucln(b,a mod b));\nend;\nbegin\n readln(n);\n if n<3 then s:=n else\n if n=3 then s:=6 else\n if n=4 then s:=12 else\n begin\n s:=n*(n-1)*(n-2);\n if ucln(n,n-2)<>1 then s:=(n-1)*(n-3)*(n-2);\n if (n*(n-1)*(n-3)>s)and (ucln(n,n-3)=1) then s:=n*(n-1)*(n-3);\n end;\n write(s);\n readln;\nend.\n"}, {"source_code": "var n,s:int64;\nfunction max(x,y:int64):int64;\n begin\n if x>y then max:=x else max:=y;\n end;\nfunction nod(x,y:int64):int64;\n var s:int64;\n begin\n s:=x*y;\n while (x>0)and(y>0)do\n if x>y then x:=x mod y\n else y:=y mod x;\n nod:=s div(x+y);\n end; \nbegin\n readln(n);\n if n=2 then begin writeln(2);exit; end;\n if n=1 then writeln(1) else begin\n s:=nod(n,nod(n-1,n-2));\n s:=max(s,nod(n,nod(n-1,n-3)));\n s:=max(s,nod(n,nod(n-3,n-2)));\n s:=max(s,nod(n-3,nod(n-1,n-2)));\n writeln(s);\n end;\n end."}, {"source_code": "program chip;\nvar\n ans,n: int64;\n\n procedure enter;\n\n begin\n assign(input,'');\n reset(input);\n readln(n);\n close(input);\n end;\n\n procedure run;\n\n begin\n if n<3 then\n begin\n ans:=n;\n exit;\n end;\n if n mod 2=1 then\n begin\n ans:=n*(n-1)*(n-2);\n exit;\n end;\n if n mod 3<>0 then\n begin\n ans:=n*(n-1)*(n-3);\n exit;\n end;\n ans:=(n-1)*(n-2)*(n-3);\n end;\n\n procedure answer;\n\n begin\n assign(output,'');\n rewrite(output);\n writeln(ans);\n close(output);\n end;\n\nbegin\n enter;\n run;\n answer;\nend."}, {"source_code": "uses math;\nvar n,p,p1,p2,maxi:int64;\ni,j,k:longint;\nfunction gcd(a,b:int64):int64;\nvar temp:int64;\n begin\n if amaxi then\n maxi:=(((p*p1) div gcd(p,p1))*p2) div gcd ((p*p1) div gcd(p,p1),p2);\n end;\n\n writeln(maxi);\nend;\nend.\n"}, {"source_code": "program form;\nvar n: int64;\n\nbegin\n{assign (input, 'input.txt');\nreset (input);\nassign (output, 'output.txt');\nrewrite (output);}\nread (n);\nif n=1 then begin writeln (1); halt; end;\nif n=2 then begin writeln (2); halt; end;\nif n=3 then begin writeln (6); halt; end;\nif n=4 then begin writeln (12); halt; end;\nif n=5 then begin writeln (60); halt; end;\nif n=6 then begin writeln (60); halt; end;\nif n mod 2 = 1 then\n begin writeln (n*(n-1)*(n-2)); halt; end;\nif n mod 3 =0 then\n begin writeln ((n-3)*(n-1)*(n-2));halt; end;\nwriteln ((n-3)*(n-1)*(n));\nhalt;\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program adsf;\nvar\ni,j:longint;\nn,ans,c,b:qword;\n function gcd(a,b:qword):qword;\n begin\n if a mod b=0 then exit(b);\n exit(gcd(b, a mod b));\n end;\nbegin\nreadln(n);b:=0; if n=1 then begin\nwriteln(1);halt;end;if n=2 then begin writeln(2);halt;end;\nif n=3 then begin writeln(6);halt;end;\n\n \n\n\n\n\nc:=(n-1)*(n-2);\nb:=(n-1)*n;\n\n for i:=n downto 1 do begin\n if (gcd(i,n-1)=1 )and(gcd(i,n-2)=1) then\n begin\n ans:=i*c;break;end; end;\n\n\nfor i:=n-2 downto 1 do begin\nif (gcd(i,n)=1)and(gcd(i,n-1)=1) then begin\n\nif b*i>ans then ans:=b*i;\nwriteln(ans);\nbreak;end;\n\n end;\n\n\nend."}, {"source_code": "var\n n : int64;\n\nfunction max(a, b : int64) : int64;\nbegin\n if a > b then\n max := a\n else\n max := b;\nend;\n\nfunction nok(a, b : int64) : int64;\nvar\n a1, b1 : int64;\n\nbegin\n a1 := a;\n b1 := b;\n while (a > 0) and (b > 0) do\n if a > b then\n a := a mod b\n else\n b := b mod a;\n nok := a1 * b1 div (a + b);\nend;\n\nbegin\n readln(n);\n if n < 3 then\n begin\n writeln(n);\n halt;\n end;\n if n mod 2 = 1 then\n writeln(nok(nok(n, n - 1), n - 2))\n else\n writeln(max(max(nok(nok(n, n - 1), n - 2), nok(nok(n, n - 1), n - 3)), nok(nok(n - 1, n - 2), n - 3)));\nend."}, {"source_code": "uses math;\nvar i,j,z,xz,xj,xi,n,ans,x:int64;\nfunction nod (a,b:int64):int64;\n begin\n while (a>0) and (b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n nod:=a+b;\n end;\nfunction nok (a,b:int64):int64;\n begin\n nok:=(a div nod(a,b))*b;\n end;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (n);\nif n<3 then\n begin\n write (n);\n halt;\n end;\nif n mod 2=1 then write (nok(nok(n,n-1),n-2)) else\nwrite ( max(max(nok(nok(n,n-1),n-2),nok(nok(n,n-1),n-3)),\n max(nok(nok(n,n-3),n-2),nok(nok(n-3,n-1),n-2)) ) )\nend.\n"}, {"source_code": "{$apptype console}\n{$b-}\nuses math;\nvar\n k,n:integer;\n cur1,mx,cur:int64;\n\n Function gcd(a,b:int64):int64;\n begin\n if b=0 then gcd:=a else gcd:=gcd(b,a mod b);\n end;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(n);\n if n=1 then write(1) else if n=2 then writeln(2)\n else if n=3 then writeln(6) else\n if n=4 then writeln(12) else if n mod 2=1 then writeln(int64(n)*int64(n-1)*int64(n-2))\n else\n begin\n if n mod 2=0 then mx:=int64(n-1)*int64(n-2)*int64(n-3) else mx:=-1;\n cur1:=int64(n)*int64(n-1);\n for k := 1 to n do\n begin\n cur:=cur1*k div gcd(cur1,k);\n if cur>mx then mx:=cur;\n\n end;\n writeln(mx)\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n{$R+}\n\nuses\n SysUtils, Math;\n\nvar\n p: array[1..1005000] of integer;\n i, j, k, c: integer;\n mx, n, f: int64;\n\nfunction smp(n: integer): boolean;\nvar\n i: integer;\nbegin\n smp := true;\n for i := 2 to trunc(sqrt(n)) do\n if n mod i = 0 then begin\n smp := false;\n exit;\n end;\nend;\n\nfunction nok(a, b: int64): int64;\nvar\n x, y: int64;\nbegin\n x := a;\n y := b;\n while (a <> 0) and (b <> 0) do\n if a > b then\n a := a mod b\n else\n b := b mod a;\n nok := int64(x * y) div (a + b);\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n);\n fillchar(p, sizeof(p), 0);\n{ for i := n downto max(n - 1000, 2) do\n if smp(i) then\n p[i] := 1;}\n mx := nok(nok(n, n), n);\n for i := n downto max(n - 50, 1) do\n for j := n downto max(n - 50, 1) do\n for k := n downto max(n - 50, 1) do begin\n f := nok(nok(i, j), k);\n if f > mx then\n mx := f;\n// if p[k] = 1 then break;\n end;\n write(mx);\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar i,j,k,n : integer;\nr ,ans : int64;\nfunction gcd(a,b : int64) : int64;\nbegin\n while a*b>0 do\n if (a>b) then a:=a mod b\n else\n b:=b mod a;\n gcd:=a+b;\nend;\nbegin\n readln(n);\n ans := 0;\n for i:=n downto max(1,n-100) do\n for j:=n downto max(1,n-100) do\n for k:=n downto max(1,n-100) do\n begin\n r := int64(i) div gcd(i,j) * j;\n r := int64(r) div gcd(r,k) * k;\n if (r > ans) then ans := r;\n end;\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar\ni,j,k,n:longint;\nlcm,best,h:int64;\n\nfunction gcd(x,y:int64):int64;\nvar g:longint;\nbegin\n repeat\n g:=x mod y;\n x:=y;\n y:=g;\n until y = 0;\ngcd:=x;\nend;\n\nbegin\n//Assign(input,'input.txt');Reset(input);\n// Assign(output,'output.txt');Rewrite(output);\nReadln(n);\nfor i:=n-5 to n do\n for j:=n-5 to n do\n for k:=n-5 to n do\n if( i > 0 )and( j > 0 )and( k > 0 ) then\n begin\n h:=i;\n lcm:= h*j div gcd(i,j);\n lcm:= k*lcm div gcd(lcm,k);\n best:=max(best,lcm);\n end;\n Writeln(best);\n//Close(input);Close(output);\nend.\n"}, {"source_code": "var\nn:int64;\nbegin\nreadln(n);\nif(n<=2) then writeln(n)\nelse\nif(n mod 2=1) then writeln(n*(n-1)*(n-2))\nelse\nif(n mod 3<>0) then writeln(n*(n-1)*(n-3))\nelse\nwriteln((n-1)*(n-2)*(n-3));\nend."}, {"source_code": "uses math;\nvar\ni,j,k,n:longint;\nlcm,best,h:int64;\n\nfunction gcd(x,y:int64):int64;\nvar g:longint;\nbegin\n repeat\n g:=x mod y;\n x:=y;\n y:=g;\n until y = 0;\ngcd:=x;\nend;\n\nbegin\n//Assign(input,'input.txt');Reset(input);\n// Assign(output,'output.txt');Rewrite(output);\nReadln(n);\nfor i:=n-30 to n do\n for j:=n-30 to n do\n for k:=n-30 to n do\n if( i > 0 )and( j > 0 )and( k > 0 ) then\n begin\n h:=i;\n lcm:= h*j div gcd(i,j);\n lcm:= k*lcm div gcd(lcm,k);\n best:=max(best,lcm);\n end;\n Writeln(best);\n//Close(input);Close(output);\nend.\n"}, {"source_code": "var n,max:int64;\nbegin\nreadln(n);\nif n<3 then begin write(n); halt; end;\nif odd(n) then max:=n*(n-1)*(n-2) else begin\nif n mod 3=0 then max:=(n-2)*(n-1)*(n-3) else max:=n*(n-1)*(n-3);\nif (n*(n-1)*(n-2) div 2>max)then max:=n*(n-1)*(n-2) div 2;\nend;\nwrite(max);\nend."}, {"source_code": "program Project1;\nUses math;\nVar i,j,i1,n:longint;\ni2,z,a,b,maxNok:int64;\nfunction nod(a,b:int64):int64;\nbegin\n if b>a\n then nod:=nod(b,a)\n else if b=0\n then nod:=a\n else nod:=nod(b,a mod b); \nend;\nbegin\n// Assign(input,'input.txt'); Assign(output,'output.txt');\n maxNok:=0;\n readln(n);\n for i:=n downto max(n-20,1) do\n for j:=n downto max(1,n-20) do\n for i1:=n downto max(1,n-20) do\n begin\n z:=nod(i,j);\n i2:=i; b:=j;\n a:=(i2*b) div z;\n b:=i1;\n z:=nod(a,b);\n if (a*b div z)>maxNok\n then maxNok:=a*b div z;\n end;\n writeln(maxNok);\nend.\n"}, {"source_code": "uses math;\nvar\n i,j,k:longint;\n n:int64;\n ans,tmp,s:int64;\nfunction gcd(a,b:int64):int64;\n var\n r:int64;\n begin\n repeat\n r:=a mod b;\n a:=b;b:=r;\n until r=0;\n exit(a);\n end;\nbegin\n readln(n);s:=n*(n-1);ans:=0;\n if n=1 then begin\n writeln(1);halt;\n end;\n if n=2 then begin\n writeln(2);halt;\n end;\n for i:=n-2 downto 1 do begin\n tmp:=s*i div gcd(s,i);\n ans:=max(ans,tmp);\n end;\n ans:=max(ans,(n-1)*(n-2)*(n-3));\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\nvar\n mar,b : array [1..1000000] of longint;\n n,w,e,max,u : int64;\n i,j : longint;\n function gcd(x,y : int64) : int64;\n begin\n while (x<>0) and (y<>0) do\n begin\n if x>y then x:=x mod y\n else y:=y mod x;\n end;\n gcd:=x+y;\n end;\nbegin\n readln(n);\n if n<3 then begin writeln(n); exit; end;\n for j:=1 to min(2,n) do\n begin\n e:=n-j;\n for i:=n-1 downto 2 do\n if I<>e then\n begin\n w:=(i*n) div gcd(i,n);\n w:=(w*e) div gcd(w,e);\n if w>max then max:=w;\n end;\n end;\n for j:=2 to min(2,n) do\n begin\n e:=n-j;\n for i:=n downto 2 do\n if I<>e then\n begin\n w:=(i*(n-1)) div gcd(i,(n-1));\n w:=(w*e) div gcd(w,e);\n if w>max then max:=w;\n end;\n end;\n writeln(max);\nend.\n"}, {"source_code": "program cd146c;\n\n{$APPTYPE CONSOLE}\nuses math;\nvar n,n1,n2,n3,nok,mn,i,j,k:Int64;\n a,b,c:longint;\n\nfunction nod(x,y:int64):int64;\n begin\n repeat\n if x>y then x:=x mod y else y:=y mod x;\n until(x=0) or (y=0);\n nod:=x+y;\n end;\n\nbegin\n { Assign(input,'input.txt');Reset(input);\n assign(output,'output.txt');rewrite(output);}\n read(n);\n for a:=n downto Max(n-50,1) do\n for b:=a downto Max(n-50,1) do\n for c:=b downto Max(n-50,1) do\n begin\n i:=a;j:=b;k:=c;\n n1:=i*j div nod(i,j);\n n2:=i*k div nod(i,k);\n n3:=j*k div nod(j,k);\n nok:=Min(k*n1 div nod(k,n1),Min(j*n2 div nod(j,n2),i*n3 div nod(i,n3)));\n if nok>mn then mn:=nok;\n end;\n write(mn);\nend.\n"}, {"source_code": "program a235;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes\n { you can add units after this };\n\n var\n a, x, xx: int64;\n begin\n readln(a);\n if a<3 then x:=a else if odd(a) then x:=a*(a-1)*(a-2)\n else if a mod 3=0 then x:=(a-1)*(a-2)*(a-3)\n else x:=a*(a-1)*(a-3);\n writeln(x);\n end.\n\n"}, {"source_code": "program Project1;\n{$MAXSTACKSIZE 64000000}\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n: int64;\n\nfunction gcd(m, n: int64): int64;\nvar\n f: integer;\nbegin\n f := m mod n;\n if f = 0 then\n gcd := n\n else\n gcd := gcd(n, f)\nend;\n\nvar\n m: array [1 .. 5] of int64;\n mqax: int64;\n\nprocedure gen(a: integer);\nvar\n i: integer;\nbegin\n if a = 4 then\n begin\n mqax := max(mqax, ((m[1] * m[2] * m[3]) div (gcd(m[3], m[2]) * gcd(m[1],\n m[3]) * gcd(m[1], m[2]) * gcd(m[1], gcd(m[2], m[3])))));\n end\n else\n begin\n for i := n downto n - 4 do\n begin\n m[a] := i;\n gen(a + 1);\n end;\n end;\nend;\n\nbegin\n readln(n);\n if n = 1 then\n begin\n writeln('1');\n exit;\n end\n else if n = 2 then\n begin\n writeln('2');\n exit;\n end\n else if n = 3 then\n begin\n writeln('6');\n exit;\n end\n else if n = 4 then\n begin\n writeln('12');\n exit;\n end;\n mqax := 0;\n gen(1);\n writeln(mqax);\n readln;\n\nend.\n"}, {"source_code": "var a,k: int64;\nbegin\nreadln(k);\nif (k>2) then \nif k mod 2 = 1 then a:=k*(k-1)*(k-2) else \nif k mod 3 = 0 then a:=(k-1)*(k-2)*(k-3) else a:=k*(k-1)*(k-3) else\nif k=2 then a:=2 else a:=1;\nwriteln(a);\nend."}, {"source_code": "var n,x1,y1,y:int64;\nfunction gcd(x,y:int64):int64;\nbegin\nif x mod y=0 then exit(y);\nexit(gcd(y,x mod y));\nend;\n\nbegin\nreadln(n);\nif n<=2 then writeln(n)\n else\nif n mod 2=1 then writeln(n*(n-1)*(n-2))\n else\n begin\n x1:=(n-1)*(n-2)*(n-3);\n y:=n*(n-1);\n y1:=y*(n-3) div gcd(y,n-3);\n if x1>y1 then writeln(x1) else writeln(y1);\n end;\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nuses math;\nvar\n n,i,j,k:longint;\n ans:int64;\n\n function gcd(a,b:int64):int64;\n begin\n if (b=0) then exit(a) else\n exit(gcd(b,a mod b));\n end;\n\n function lcm(a,b:int64):int64;\n begin\n exit((a*b) div gcd(a,b));\n end;\n\nbegin\n ans:=0;\n readln(n);\n for i:=max(1,n-100) to n do\n for j:=max(1,n-100) to n do\n for k:=max(1,n-100) to n do\n if lcm(i,lcm(j,k))>ans then\n ans:=lcm(i,lcm(j,k));\n writeln(ans);\nend."}, {"source_code": "Var\n n :longint;\n kq,x :int64;\n i,j,k :longint;\n\nFunction UCLN(a,b:int64):int64;\nvar\n r :int64;\nbegin\n While b>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a);\nend;\n\nFunction BCNN(a,b,c:int64):int64;\nvar\n x :int64;\nbegin\n x:=(a*b) div UCLN(a,b);\n BCNN:=(x*c) div UCLN(x,c);\nend;\n\nbegin\n read(n);\n kq:=1;\n for i:=n downto n-100 do\n for j:=n downto n-100 do\n for k:=n downto n-100 do\n if (i>0) and (j>0) and (k>0) then\n begin\n x:=BCNN(i,j,k);\n if x>kq then kq:=x;\n end;\n write(kq);\nend.\n"}, {"source_code": "{$mode objfpc}\nfunction max(a,b: int64): int64;\nbegin\n if a>b then max:=a else max:=b;\nend;\nvar\n n: int64;\nfunction ucln(a,b: int64): INT64;\nvar\n r: int64;\nbegin\n while b>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n result:=a;\nend;\nfunction bcnn(i,j,k: int64): int64;\nvar\n i1,j1,k1,t2,t3,t4: int64;\nbegin\n i1:=i;\n j1:=j;\n k1:=k;\n t2:=ucln(i1,j1);\n t3:=i1*j1 div t2;\n t4:=ucln(t3,k1);\n result:=t3*k1 div t4;\nend;\nfunction tim: int64;\nvar\n t,t1,i1: int64;\n i,j,k: integer;\nbegin\n t:=0;\n readln(n);\n if n=1 then exit(1);\n if n=2 then exit(2);\n if n mod 2=1 then exit(n*(n-1)*(n-2));\n for i:=n-2 downto 1 do\n begin\n i1:=i;\n t1:=bcnn(i1,n,n-1);\n t:=max(t,t1);\n end;\n result:=max(t,(n-1)*(n-2)*(n-3));\nend;\nbegin\n writeln(tim);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\n{Procedure QSort(m, t: Integer);\nVar i, j, x, w: Integer;\nBegin\n i:=m; j:=t; x:=A[random(t-m+1)+m];\n Repeat\n While A[i]x Do Dec(j);\n If i<=j Then Begin\n w:=A[i]; A[i]:=A[j]; A[j]:=w;\n Inc(i); Dec(j);\n End\n Until i>j;\n If mans then ans:=x;\n end;\n\na:=n-1; b:=n-2; c:=n;\nfor i:=c downto 1 do\n begin\n x:=lcm(a*b,i);\n if x>ans then ans:=x;\n end;\n\n\nwriteln(ans);\n//readln;\n//close(input); close(output);\nend."}, {"source_code": "Var\n n :int64;\n i :longint;\n kq,x :int64;\n j,k :longint;\n hh :longint;\n\nFunction UCLN(a,b:int64):int64;\nvar\n r :int64;\nbegin\n While b>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a);\nend;\n\nFunction BCNN(a,b,c:int64):int64;\nvar\n x :int64;\nbegin\n x:=(a*b) div UCLN(a,b);\n BCNN:=(x*c) div UCLN(x,c);\nend;\n\nbegin\n read(n);\n begin\n kq:=0;\n for i:=n downto n-100 do\n for j:=n downto n-100 do\n for k:=n downto n-100 do\n if (i>0) and (j>0) and (k>0) then\n begin\n x:=BCNN(i,j,k);\n if x>kq then kq:=x;\n end;\n write(kq);\n end;\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n n,ans,r1,r2:Int64;\n i,j,k:Integer;\nFunction Max(x,y:Int64):Int64;\nBegin\n If x>y Then Max:=x\n Else Max:=y;\nEnd;\nFunction Gcd(a,b:Int64):Int64;\nBegin\n If b=0 Then Gcd:=a\n Else Gcd:=Gcd(b, a mod b);\nEnd;\nBegin\n Read(n);\n ans:=1;\n For i:=Max(n-120,1) To n Do\n For j:=Max(n-120,1) To n Do\n For k:=Max(n-120,1) To n Do Begin\n r1:=(int64(i)*int64(j)) div (Gcd(int64(i),int64(j)));\n r2:=(r1*int64(k)) div (Gcd(r1,int64(k)));\n If r2>ans Then Begin\n ans:=r2;\n End;\n End;\n Write(ans);\nEnd.\n"}, {"source_code": "var\n N,Ans,Q,Z,u:Int64;\n i,j,k:Longint;\nfunction Nod(X,Y:Int64):Int64;\nbegin\n while (X>0) and (Y>0) do\n if X>Y then X:=X mod Y\n else Y:=Y mod X;\n Nod:=X+Y;\n end;\nbegin\n Readln(N);\n for i:=N-5 to N do\n for j:=N-5 to N do\n for k:=N-5 to N do\n if (i>0) and (j>0) and (k>0) then\nbegin\n u:=i;\n Q:=u*j div Nod(u,j);\n Z:=Q*k div Nod(Q,k);\n if Z>=Ans then Ans:=Z;\n end;\n Writeln(Ans);\n end.\n"}, {"source_code": "var\n n,res:int64;\nbegin\n read(n);\n if n<=4 then begin\n if n=4 then writeln(12)\n else if n=3 then writeln(6)\n else if n=2 then writeln(2)\n else if n=1 then writeln(1);\n end\n else if n=6 then writeln(60)\n else begin\n if n mod 2<>0 then res:=n*(n-1)*(n-2)\n else if n mod 3=0 then res:=(n-1)*(n-2)*(n-3)\n else res:=n*(n-1)*(n-3);\n writeln(res);\n end;\nend.\n"}, {"source_code": "program lcm;\nvar\n n:longint;\n\nprocedure openf;\nbegin\n assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\n\nfunction max(x,y:longint):longint;\nbegin\n if x>=y then exit(x) else exit(y);\nend;\n\nfunction gcd(x,y:int64):int64;\nvar t:int64;\nbegin\n while y<>0 do \n begin\n t:=x mod y;\n x:=y;\n y:=t;\n end;\n gcd:=x;\nend;\n\nfunction cal:int64;\nvar tmp,x,y:int64; i,j,k:longint;\nbegin\n tmp:=0;\n for i:=n downto max(1,n-50) do \n for j:=i-1 downto max(1,n-50) do \n for k:=j-1 downto max(1,n-50) do\n begin\n x:=gcd(i,j); y:=int64(i)*j div x;\n x:=gcd(y,k); y:=y*k div x;\n if y>tmp then tmp:=y;\n end;\n cal:=tmp;\nend;\n\nbegin\n\n readln(n);\n case n of\n 1:writeln(1);\n 2:writeln(2);\n 3:writeln(6);\n else\n begin\n if odd(n) then writeln( int64(n)*(n-1)*(n-2) )\n else writeln( cal );\n end;\n end;\n\nend.\n\n"}, {"source_code": "program c;\nvar a,k: uint64;\nbegin\nreadln(k);\nif (k>2) then \nif k mod 2 = 1 then a:=k*(k-1)*(k-2) else \nif k mod 3 = 0 then a:=(k-1)*(k-2)*(k-3) else a:=k*(k-1)*(k-3) else\nif k=2 then a:=2 else a:=1;\nwriteln(a);\nend."}, {"source_code": "Var n,kq:int64;\nBEGIN\n readln(n);\n if n=1 then writeln(1);\n if n=2 then writeln(2);\n if n>=3 then\n begin\n if (n mod 2)=1 then writeln((n-2)*(n-1)*n)\n else\n if (n mod 3)=1 then writeln((n-3)*(n-1)*n)\n else\n if (n mod 3)=0 then writeln((n-3)*(n-2)*(n-1))\n else writeln((n-3)*(n-1)*(n));\n end;\nEND."}, {"source_code": "uses math;\nVar i,j,u,n,k:longint;\nans:int64;\n a:array[0..1000333]of longint;\n b:array[0..1003333]of boolean;\n function gcd(x,y:int64):int64;\n begin\n while (x>0)and(y>0) do\n if x>y then x:=x mod y\n else y:=y mod x;\n gcd:=x+Y;\n end;\nfunction lcm(x,y:int64):int64;\n begin\n lcm:=x*y div gcd(x,y);\n end;\n begin\n read(n);\n{ fillchar(b,sizeof(b),true);\n b[1]:=false;\n for i:=2 to n do\n if b[i] then\n begin\n inc(k);\n a[k]:=i;\n for j:=2 to n div i do\n b[j*i]:=false;\n end;\n if k>=3 then\n begin\n Writeln(a[k]*a[k-1]*a[k-2]);\n halt(0);\n end; }\n for i:=n downto max(n-150,1) do\n for j:=i downto max(i-150,1) do\n for u:=j downto max(j-150,1) do\n ans:=max(lcm(lcm(i,j),u),ans);\n Writeln(ans);\n end."}, {"source_code": "var n,max:int64;\nbegin\nreadln(n);\nif n<3 then begin write(n); halt; end;\nif odd(n) then max:=n*(n-1)*(n-2) else begin\nif n mod 3=0 then max:=(n-2)*(n-1)*(n-3) else max:=n*(n-1)*(n-3);\nif (n*(n-1)*(n-2) div 2>max)then max:=n*(n-1)*(n-2) div 2;\nend;\nwrite(max);\nend."}, {"source_code": "var a,b,c,x,n,y,aa,bb,cc:int64;\n begin\n read(n);\n if n=1 then writeln(1)\n else\n if n mod 2=1 then writeln(n*(n-1)*(n-2))\n else\n if n=2 then writeln(2)\n else\n if n mod 3=0 then writeln((n-1)*(n-2)*(n-3))\n else writeln(n*(n-1)*(n-3));\n end."}, {"source_code": "{$r-,s-,q-,i-,o+}\nuses math;\nvar\n n,i,j,k:longint;\n ans:int64;\n\n function gcd(a,b:int64):int64;\n begin\n if (b=0) then exit(a) else\n exit(gcd(b,a mod b));\n end;\n\n function lcm(a,b:int64):int64;\n begin\n exit((a*b) div gcd(a,b));\n end;\n\nbegin\n ans:=0;\n readln(n);\n for i:=max(1,n-100) to n do\n for j:=max(1,n-100) to n do\n for k:=max(1,n-100) to n do\n if lcm(i,lcm(j,k))>ans then\n ans:=lcm(i,lcm(j,k));\n writeln(ans);\nend."}, {"source_code": "function max(a,b:longint):longint;\nbegin\nif a>b then max:=a\nelse max:=b;\nend;\n\nfunction nod(a,b:int64):int64;\nvar\na1,b1:int64;\nbegin\na1:=a;\nb1:=b;\n while (a1>0) and (b1>0) do\n if a1>b1 then a1:=a1 mod b1\n else b1:=b1 mod a1;\n nod:=(a*b) div (a1+b1);\nend;\n\n\nfunction nok(a,b,c:int64):int64;\nvar\ns1:int64;\nbegin\ns1:=nod(a,b);\nnok:=nod(s1,c);\nend;\n\n\n\nvar\nn,i,j,k:longint;\nans,t:int64;\nbegin\n\nreadln(n);\nif n>2 then\n begin\n ans:=nok(n,n-1,n-2);\n\n for i:=n downto max(n-100,1) do\n for j:=n downto max(n-100,1) do\n for k:=n downto max(n-100,1) do\n if nok(i,j,k)>ans then ans:=nok(i,j,k);\n\n write(ans);\n exit;\n end;\nwrite(n);\n\nend.\n"}, {"source_code": "program A146;\nconst\n inp='';\n oup='';\nvar\n N:longint;\n Res:QWord;\n i1,j1,k1:longint;\n i,j,k:Qword;\n Cres:QWord;\n\nfunction UCLN(A,B:QWord):QWord;\nbegin\n if b=0 then exit(A);\n exit(UCLN(B, A mod B));\nend;\n\nbegin\n readln(N);\n if N=1 then writeln(1);\n if N=2 then writeln(2);\n if n>=3 then\n begin\n for i1:=N downto N-100 do\n for j1:=i1-1 downto N-100 do\n for k1:=j1-1 downto N-100 do\n if (i1>0) and (j1>0) and (k1>0) then\n begin\n i:=i1; j:=j1; k:=k1;\n Cres:=(i*j) div UCLN(i,j);\n Cres:=(Cres*k) div UCLN(Cres,k);\n if Cres>Res then Res:=Cres;\n end;\n writeln(Res);\n end;\nend.\n"}, {"source_code": "var\n i,j,m,k,kol,ans,res:longint;\n n:int64;\nbegin\n readln(n);\n if n<3 then writeln(n) else if odd(n) then writeln(n*(n-1)*(n-2)) else\n if n mod 3=0 then writeln((n-1)*(n-2)*(n-3)) else writeln(n*(n-1)*(n-3));\nend.\n"}, {"source_code": "var\n n:Qword;\n x:Qword;\nbegin\n readln(n);\n if n=1 then begin writeln(1);halt;end;\n if n=2 then begin writeln(2);halt;end;\n if n=3 then begin writeln(6);halt;end;\n if odd(n) then x:=n*(n-1)*(n-2)\n else begin\n if n mod 3=0 then x:=(n-1)*(n-2)*(n-3)\n else x:=n*(n-1)*(n-3);\n end;\n writeln(x);\nend."}, {"source_code": "{\nID: Hokplex\nPROB: LCM Challenge\nLANG: PASCAL\n}\n\nuses\n math;\n\nvar\n n, ans: int64;\n\nprocedure scanf;\nbegin\n readln(n);\nend;\n\nprocedure process;\nbegin\n if n <= 2 then ans:= n\n else\n if odd(n) then\n ans:= n * (n - 1) * (n - 2)\n else\n if n mod 3 = 0 then\n ans:= (n - 1) * (n - 2) * (n - 3)\n else\n ans:= n * (n - 1) * (n - 3);\n writeln(ans);\nend;\n\nbegin\n scanf;\n process;\nend.\n"}, {"source_code": "USES MATH;\nVAR N,K,L:INT64;\nBEGIN\n READ(N);\n IF N<3 THEN\n BEGIN\n IF N=2 THEN WRITELN(2)\n ELSE WRITELN(1);\n HALT(0);\n END;\n if n mod 2=0 then\n begin\n if n mod 3=0 then k:=3\n else k:=1;\n if n mod 2=0 then l:=2\n else l:=1;\n writeln(max(n*(n-1)*(n-3) div k,max(n*(n-1)*(n-2) div l,(n-1)*(n-2)*(n-3))));\n end\n else\n begin\n writeln(n*(n-1)*(n-2));\n end;\nEND.\n"}, {"source_code": "uses math;\nvar\n i,j,k:longint;\n n:int64;\n ans,tmp,s:int64;\nfunction gcd(a,b:int64):int64;\n var\n r:int64;\n begin\n repeat\n r:=a mod b;\n a:=b;b:=r;\n until r=0;\n exit(a);\n end;\nbegin\n readln(n);s:=n*(n-1);ans:=0;\n if n=1 then begin\n writeln(1);halt;\n end;\n if n=2 then begin\n writeln(2);halt;\n end;\n for i:=n-2 downto 1 do begin\n tmp:=s*i div gcd(s,i);\n ans:=max(ans,tmp);\n end;\n ans:=max(ans,(n-1)*(n-2)*(n-3));\n writeln(ans);\nend."}, {"source_code": "var\n s,n:int64;\nbegin\n readln(n);\n if n = 1 then s:=1\n else\n if n = 2 then s:=2\n else\n if n = 3 then s:=6\n else\n if n mod 2 = 1 then s:=n*(n-1)*(n-2)\n else\n if n mod 3 = 0 then s:=(n-1)*(n-2)*(n-3)\n else\n s:=n*(n-1)*(n-3);\n writeln(s);\nend."}, {"source_code": "var n, tmp, res: int64;\n i: longint;\n a, b, e: int64;\n\nFunction Max(a, b: int64): int64;\nbegin\n if a > b then exit(a) else exit(b);\nend;\n\nFunction ucln(a, b: int64): int64;\nvar tmp: int64;\nbegin\n if a mod b = 0 then exit(b)\n else\n exit(ucln(b, a mod b));\nend;\n\nProcedure Solve;\nbegin\n tmp := n*(n-1);\n res := (n-1)*(n-2)*(n-3);\n for i := n-2 downto 2 do\n begin\n e := i;\n b := ucln(e, tmp);\n a := (tmp*e)div b;\n res := Max(a, res);\n end;\n writeln(res);\nend;\n\nBegin\n read(n);\n if n = 1 then write(1);\n if n = 2 then write(2);\n if n = 3 then write(6);\n if n = 4 then write(12);\n if n <= 4 then exit;\n if odd(n) then write(n*(n-1)*(n-2))\n else\n begin\n Solve;\n end;\nend.\n"}, {"source_code": "program task_c;\n\nvar n,a,i,j,k:longint;\n t,s:int64;\n\nfunction nok2(a,b:int64):int64;\nvar x,y:int64;\nbegin\nx:=a;\ny:=b;\nwhile (x>0) and (y>0) do\n begin\n if x>y\n then x:=x mod y\n else y:=y mod x;\n end;\nnok2:=(a div (x+y))*b;\nend;\n\nfunction nok(a,b,c:int64):int64;\nbegin\nnok:=nok2(nok2(a,b),c);\nend;\n\nbegin\nreadln(n);\nif n<=6\n then begin\n a:=1;\n end\n else begin\n a:=n-6;\n end;\ns:=n;\nfor i:=a to n do\n for j:=a to n do\n for k:=a to n do\n begin\n t:=nok(i,j,k);\n if t>s\n then s:=t;\n end;\nwriteln(s);\nend."}, {"source_code": "var n,q1,q2,q3:int64;\nfunction tt (a,b:int64):int64;\n begin\n while (a>0) and (b>0) do\n if a>b then a:=a mod b\n else b:=b mod a;\n tt:=a+b;\n end;\n begin\n read (n);\n if n<3 then writeln (n)\n else if n mod 2=1 then writeln (n*(n-1)*(n-2))\n else if n mod 6=0 then writeln ((n-1)*(n-2)*(n-3))\n else begin\n q1:=n;\n q2:=n-1;\n q3:=n-2;\n while q3>(n-2) div 2 do\n begin\n if (tt(q3,q1)=1) and (tt(q2,q3)=1) then begin\n writeln (q1*q2*q3);\n halt(0);\n end;\n dec (q3);\n end;\n writeln ((n div 2)*(n-1)*(n-2));\n end;\n end."}, {"source_code": "{$Mode objfpc}\n\nuses math;\n\nvar\n n: int64;\n\nbegin\n readln(n);\n if n= 1 then writeln(1) else\n if n= 2 then writeln(2) else\n if odd(n) then writeln(n*(n- 1)*(n- 2)) else\n begin\n if n mod 3= 0 then writeln((n- 1)* (n- 2)*(n- 3)) else writeln(n*(n- 1)*(n- 3));\n end;\n\nend."}, {"source_code": "var\n j:longint;\n n,ans,gg,p,q:qword;\nfunction gcd(a,b:qword):qword;\nbegin\n if b=0 then exit(a) else gcd:=gcd(b,a mod b);\nend;\nbegin\n readln(n);\n if odd(n) then ans:=(n-1)*n*(n-2) else\n begin\n p:=(n-1)*(n-2)*(n-3);\n q:=n*(n-1);\n for j:=n-2 downto 1 do\n begin\n gg:=gcd(q,j);\n if q*j div gg>p then\n p:=q*j div gg;\n end;\n ans:=p;\n end;\n if n<3 then ans:=n;\n writeln(ans);\nend.\n"}, {"source_code": "program CF_236C;\nvar\n x,y,z:array[0..20] of integer\n ;\n n,a,b,c,i,j:longint;\n s:int64;\n\nprocedure times;\n var i,j:longint;\n begin\n for i:=1 to x[0] do\n for j:=1 to y[0] do\n z[i+j-1]:=z[i+j-1]+x[i]*y[j];\n for i:=1 to x[0]+y[0]-1 do begin\n z[i+1]:=z[i+1]+z[i] div 10;\n z[i]:=z[i] mod 10;\n end;\n z[0]:=x[0]+y[0];\n if z[x[0]+y[0]]=0 then dec(z[0]);\n end;\n\nbegin\n readln(n);\n if n=1 then begin\n writeln(1);\n halt;\n end;\n if n=2 then begin\n writeln(2);\n halt;\n end;\n if n mod 2=0\n then begin\n a:=n-3;\n b:=n-1;\n c:=n;\n end\n else begin\n a:=n-2;\n b:=n;\n c:=n-1;\n end;\n if c mod 3=0 then\n if (a mod 3=0) or (b mod 3=0) then c:=c-2;\n x[0]:=0;y[0]:=0;\n while a>0 do begin\n inc(x[0]);\n x[x[0]]:=a mod 10;\n a:=a div 10;\n end;\n while b>0 do begin\n inc(y[0]);\n y[y[0]]:=b mod 10;\n b:=b div 10;\n end;\n fillchar(z,sizeof(z),0);\n times;x:=z;\n fillchar(y,sizeof(y),0);\n fillchar(z,sizeof(z),0);\n while c>0 do begin\n inc(y[0]);\n y[y[0]]:=c mod 10;\n c:=c div 10;\n end;\n times;\n for i:=z[0] downto 1 do\n write(z[i]);\n writeln;\nend.\n"}, {"source_code": "const fi=''; fo='';\nfunction ucln(a,b:int64):int64;\nvar tmp:int64;\nbegin\n while b>0 do\n begin\n a:=a mod b;\n tmp:=a; a:=b; b:=tmp;\n end;\n exit(a);\nend;\nprocedure process;\nvar n,max,d,t,h:int64; i,j,k:longint;\nbegin\n readln(n); max:=0;\n if n=1 then writeln(1)\n else if n=2 then writeln(2)\n else if n=3 then writeln(6)\n else begin\n for i:=0 to 3 do\n for j:=i+1 to 3 do\n for k:=j+1 to 3 do\n begin\n t:=ucln(n-i,n-j); d:=((n-i)*(n-j))div t;\n h:=ucln(d,n-k);\n d:=(d*(n-k))div h;\n if d>max then max:=d;\n end;\n writeln(max);\n end;\nend;\nbegin process; end.\n"}, {"source_code": "var\ni,j:longint;\nnod1,f,q,nod,g,p1,x,ans,d,kol,p,n:int64;\na:array[-100..3000]of longint;\nbegin\nreadln(n);\n\nif n<=2 then writeln(n)\nelse\nif n=3 then writeln(6)\nelse begin\n if n mod 2 = 1 then\n\n\n writeln(n*(n-1)*(n-2))\n else begin\n ans:=((n-3)*(n-1)*(n-2));\n\n for i:=n-2 downto 1 do begin\n q:=n;\n f:=i;\n while (q>0)and(f>0) do begin\n if q>f then q:=q mod f\n else\n f:=f mod q;\n end;\n nod:=f+q;\n f:=i;\n q:=n-1;\n while (f>0)and(q>0) do begin\n if q>f then q:=q mod f\n else\n f:=f mod q;\n end;\n\n nod1:=f+q;\n\n if ((n div nod)*((n-1) div nod1)*((i div nod) div nod1)*nod*nod1)>ans then ans:=(n div nod)*((n-1) div nod1)*((i div nod) div nod1)*nod*nod1;\n\n end;\n writeln(AnS);\n end;\n\nend;\nend."}, {"source_code": "uses math;\nvar\n mar,b : array [1..1000000] of longint;\n n,w,e,max,u : int64;\n i,j : longint;\n function gcd(x,y : int64) : int64;\n begin\n while (x<>0) and (y<>0) do\n begin\n if x>y then x:=x mod y\n else y:=y mod x;\n end;\n gcd:=x+y;\n end;\nbegin\n readln(n);\n if n<3 then begin writeln(n); exit; end;\n e:=n-1;\n for i:=n-1 downto 2 do\n if I<>e then\n begin\n w:=(i*n) div gcd(i,n);\n w:=(w*e) div gcd(w,e);\n if w>max then max:=w;\n end;\n e:=n-2;\n for i:=n downto 2 do\n if I<>e then\n begin\n w:=(i*(n-1)) div gcd(i,(n-1));\n w:=(w*e) div gcd(w,e);\n if w>max then max:=w;\n end;\n writeln(max);\nend.\n"}], "negative_code": [{"source_code": "Var n:LongInt;\nBegin\n // ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (n);\n If n<3\n then Writeln (n)\n else If n mod 2=1\n then Writeln (n*(n-1)*(n-2))\n else If n mod 3=0\n then Writeln ((n-1)*(n-2)*(n-3))\n else Writeln (n*(n-1)*(n-3))\nend."}, {"source_code": "uses math;\nconst\n pi=3.1415926535;\nvar\n f,ff:array[0..100,0..100] of longint;\n a,b:array[0..210000] of longint;\n// b:array[1..100] of longint;\n\n x,y,k,l,i,j,z,col,r,jj,m,t,ans:longint;\n st,stt:array[0..50100] of string;\n p:array[1..50000] of boolean;\n s,ss,sw:ansistring;\n ch:array['a'..'z'] of longint;\n// x,y,xx,yy:extended;\n c:char;\n w:array['a'..'z'] of longint;\n xx,n,ms,tp:int64;\n// v,r,s,ss,k,t,al:extended;\n\nfunction nod(a,b:longint):longint;\nbegin\n while int64(a)*b>0 do\n if a>b then a:=a mod b else b:=b mod a;\n nod:=a+b;\n\nend;\n\nbegin\n//ssign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\n read(n);\n if n=1 then write(1) else if n=2 then write(2) else\n// for i:=n downto 1 do\n// if pr(i) then break;\n tp:=n*(n-1) div (nod(n,n-1));\n tp:=tp*(n-2) div( nod(tp,n-2));\n\n\n write(tp);\n\n\nend.\n"}, {"source_code": "const fin='';\n fout='';\nvar n:longint; s,k,i,j:int64;\n f,g:text;\nfunction ucln(a,b:longint):longint;\nvar tmp:longint;\nbegin\n while b>0 do\n begin\n a:=a mod b;\n tmp:=a; a:=b; b:=tmp;\n end;\n exit(a);\nend;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,n);\n i:=n;\n if n>=5 then\n while i>1 do\n begin\n j:=i;\n while j>1 do\n begin\n if ucln(i,j)=1 then\n begin\n k:=j;\n while k>1 do\n begin\n if (ucln(k,j)=1) and (ucln(k,i)=1) then\n begin\n s:=(i*j*k);\n write(g,s);\n close(g); exit;\n end;\n dec(k);\n end;\n end;\n dec(j);\n end;\n dec(i);\n end\n else\n begin\n if n=1 then write(g,1);\n if n=2 then write(g,2);\n if n=3 then write(g,6);\n if n=4 then write(g,12);\n end;\n close(g);\nend."}, {"source_code": "var\n a,b,c,n:int64;\nbegin\n readln(n);\n if odd(n)\n then begin writeln(n*(n-1)*(n-2));halt;end;\n if n mod 3<>0\n then writeln(n*(n-1)*(n-3))\n else writeln((n-1)*(n-2)*(n-3))\nend.\n"}, {"source_code": "var\n i,n:longint;\n l,lmax,a,b,lold:int64;\n\nprocedure Swap(var a,b:int64);\n var p:int64;\n begin\n p:=a;\n a:=b;\n b:=p;\n end;\n\nfunction GCD(a,b:int64):int64;\n begin\n while b>0 do\n begin\n a:=a mod b;\n Swap(a,b);\n end;\n GCD:=a;\n end;\n\nfunction LCM(a,b:int64):int64;\n begin\n LCM:=(a*b) div GCD(a,b);\n end;\n\nbegin\n readln(n);\n lmax:=LCM(n,n-1);\n l:=lmax;\n lold:=lmax;\n for i:=2 to n do\n begin\n b:=i;\n l:=LCM(lold,b);\n if l>lmax then lmax:=l;\n end;\n writeln(lmax);\nend.\n"}, {"source_code": "\n\nuses\n SysUtils,math;\nvar i,j,k,n : integer;\nr ,ans : int64;\nfunction gcd(a,b : integer) : integer;\nbegin\n if (a = 0) then gcd:=b\n else\n gcd:=gcd(b mod a,a);\nend;\nbegin\n readln(n);\n ans := 0;\n for i:=n downto max(1,n-100) do\n for j:=n downto max(1,n-100) do\n for k:=n downto max(1,n-100) do\n begin\n r := i*j div gcd(i,j);\n r := r*k div gcd(r,k);\n if (r > ans) then ans := r;\n end;\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar n: int64;\nfunction gcd(x, y: int64): int64;\nbegin\n if y = 0 then\n exit(x)\n else\n exit(gcd(y, x mod y));\nend;\nbegin\n readln(n);\n if n < 3 then\n writeln(n)\n\n else if n mod 2 = 1 then\n writeln(n * (n - 1) * (n - 2))\n else writeln(max(n * (n - 1) * (n - 2) / 2, max((n - 1) * (n - 2) * (n - 3), n * (n - 1) * (n - 3) / gcd(n, n - 3) / gcd(n - 1, n - 3))):0:0);\nend."}, {"source_code": "uses math;\nconst fin='';\nvar f:text;\n n:longint;\n s:qword;\nfunction bcnn(a,b:longint):int64;\nvar x,y,du:longint;\nbegin\n x:=a; y:=b;\n repeat\n du:=x mod y;\n x:=y; y:=du;\n until du=0;\n bcnn:=a div x*b;\nend;\nbegin\n assign(f,fin); reset(f);\n read(f,n);\n if (n=1) or (n=2) then write(n)\n else\n begin\n s:=n*(n-1);\n s:=max(bcnn(s,(n-2)),bcnn(s,(n-3)));\n write(s);\n end;\nend.\n"}, {"source_code": "var a,b,c,q:integer;\nbegin\n read(a);\n b:=a-1;\n c:=a-2;\n q:=a*b*c;\n write (q);\nend.\n"}, {"source_code": "Var\n n :int64;\n i :longint;\n kq,x :int64;\n\nFunction UCLN(a,b:int64):int64;\nvar\n r :int64;\nbegin\n While b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a);\nend;\n\nFunction BCNN(a,b,c:int64):int64;\nvar\n x :int64;\nbegin\n x:=(a*b) div UCLN(a,b);\n BCNN:=(x*c) div UCLN(x,c);\nend;\n\nbegin\n read(n);\n if n=2 then write(2);\n if n=3 then write(6);\n if n=4 then write(12);\n if n>4 then\n begin\n if n mod 2=1 then write(n*(n-1)*(n-2))\n else\n begin\n kq:=(n-1)*(n-2)*(n-3);\n for i:=n-2 downto n-5 do\n begin\n if i<1 then continue;\n x:=BCNN(n,n-1,i);\n if x>kq then kq:=x;\n end;\n for i:=n-3 downto n-5 do\n begin\n if i<1 then continue;\n x:=BCNN(n,n-3,i);\n if x>kq then kq:=x;\n end;\n write(kq);\n end;\n end;\nend.\n"}, {"source_code": "program A146;\nconst\n inp='';\n oup='';\nvar\n N:longint;\n Res:int64;\n i,j,k:longint;\n\nfunction UCLN(A,B:longint):int64;\nbegin\n if b=0 then exit(A);\n exit(UCLN(B, A mod B));\nend;\n\nfunction Get(X,Y,Z:int64):int64;\nvar Cres:int64;\nbegin\n Cres:=(X*Y) div UCLN(X,Y);\n CreS:=(Cres*Z) div UCLN(Cres,Z);\n exit(Cres);\nend;\n\nbegin\n readln(N);\n if N=1 then writeln(1);\n if N=2 then writeln(2);\n if n>=3 then\n begin\n for i:=N downto N-100 do\n for j:=i-1 downto N-100 do\n for k:=j-1 downto N-100 do\n if (i>0) and (j>0) and (k>0) then\n begin\n if Res 0 then write(n*(n-1)*(n-2))\n else if n mod 3 = 0 then write((n-1)*(n-2)*(n-3))\n else write(n*(n-1)*(n-3));\nend;\n\nBEGIN\n motep;\n solve;\n dongtep;\nEND."}, {"source_code": "const fin='';\nvar f:text;\n s:qword;\n n:longint;\nbegin\n assign(f,fin); reset(f);\n read(f,n);\n if (n=1) or (n=2) then write(n)\n else\n begin\n if n mod 2=1 then s:=n*(n-1)*(n-2)\n else\n if n mod 3=0 then s:=(n-1)*(n-2)*(n-3)\n else s:=n*(n-2)*(n-3);\n write(s);\n end;\nend.\n"}, {"source_code": "Var\n n :int64;\n i :longint;\n kq,x :int64;\n\nFunction UCLN(a,b:int64):int64;\nvar\n r :int64;\nbegin\n While b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a);\nend;\n\nFunction BCNN(a,b,c:int64):int64;\nvar\n x :int64;\nbegin\n x:=UCLN(a,c)*UCLN(a,b)*UCLN(b,c);\n BCNN:=(a*b*c) div x;\nend;\n\nbegin\n read(n);\n if n=2 then write(2);\n if n=3 then write(6);\n if n=4 then write(12);\n if n>4 then\n begin\n if n mod 2=1 then write(n*(n-1)*(n-2))\n else\n begin\n kq:=(n-1)*(n-2)*(n-3);\n for i:=n-2 downto 1 do\n begin\n x:=BCNN(n,n-1,i);\n if x>kq then kq:=x;\n end;\n write(kq);\n end;\n end;\nend.\n"}, {"source_code": "var\n n,w,max : int64;\n i,j : longint;\n function gcd(x,y : int64) : int64;\n begin\n while (x<>0) and (y<>0) do\n begin\n if x>y then x:=x mod y\n else y:=y mod x;\n end;\n gcd:=x+y;\n end;\nbegin\n readln(n);\n if n<3 then begin writeln(n); exit; end;\n for i:=1 to n-2 do\n begin\n w:=(i*n) div gcd(i,n);\n w:=(w*(n-1)) div gcd(w,(n-1));\n if w>max then max:=w;\n end;\n writeln(max);\nend.\n"}, {"source_code": "var a:array[1..100000] of boolean;\nvar b:array[0..100000] of longint;\nvar i,j:longint;\nvar n:int64;\nbegin\n\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if not a[i] then\n for j:=2 to n div i do a[i*j]:=true;\n for i:=2 to n do if not a[i] then\n begin\n b[0]:=b[0]+1;\n b[b[0]]:=i;\n end;\n if n=1 then write(1)\n else if n=2 then write(2)\n else\n for i:=2 to n do if n mod b[i]>0 then\n begin\n if n*(n-1)*(n-b[i])>(n-1)*(n-2)*(n-3) then\n write(n*(n-1)*(n-b[i]))\n else write((n-1)*(n-2)*(n-3));\n break;\n end;\n\nend."}, {"source_code": "var i, j, x, n, nod, lcm_r, max, q, y, z: int64;\n\nfunction gcd(a, b: longint):int64;\nbegin\nif b=0 then gcd:=a else gcd:=gcd(b,a mod b);\nend;\n\n\nbegin\nreadln(n);\nif n=1 then begin writeln('1'); halt; end;\nif n=2 then begin writeln('2'); halt; end;\nif n div 2 <>0 then n:=n-1;\n\n writeln(n*(n-1)*(n-2));\nend."}, {"source_code": "program adsf;\nvar\ni,j,n:longint;\nans,c,b:qword;\n function gcd(a,b:qword):qword;\n begin\n if a mod b=0 then exit(b);\n exit(gcd(b, a mod b));\n end;\nbegin\nreadln(n);b:=0; if n=1 then begin\nwriteln(1);halt;end;if n=2 then begin writeln(2);halt;end;\nif n=3 then begin writeln(6);halt;end; i:=n-1;j:=n-2;\nc:=i*j div gcd(i,j);\nb:=i*n div gcd(i,n);\nif c>b then\nbegin\n for i:=n downto 1 do begin\n if (gcd(i,n-1)=1 )and(gcd(i,n-2)=1) then\n begin\n writeln(i*c);halt;end; end;\nend\nelse begin\nfor i:=n-2 downto 1 do begin\nif (gcd(i,n)=1)and(gcd(i,n-1)=1) then begin\nwriteln(i*b);halt;end;\nend;\n end;\n\n\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n : Int64;\n\n{}\nProcedure motep;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\n{}\nProcedure dongtep;\nbegin\n close(input); close(output);\nend;\n\n{}\nProcedure solve;\nbegin\n read(n);\n write(n*(n-1)*(n-2));\nend;\n\nBEGIN\n motep;\n solve;\n dongtep;\nEND."}, {"source_code": "var\ni,j,ans,k,n,cool :longint;\nd:array[0..1111111] of longint;\n\nfunction Check(x:longint):boolean;\nvar j:longint;\nbegin\nj:=2;\nwhile(j*j<=x) do\n begin\n if x mod j = 0 then\n begin\n Check:=false;\n exit;\n end;\n if j = 2 then Inc(j)\n else Inc(j,2);\n end;\nCheck:=true;\nend;\n\nfunction go:longint;\nvar l,best:int64;j,q,w,z:longint;\nbegin\nl:=1;\nfor j:=n downto 2 do\n begin\n if Check(j) then\n begin\n if l * j > n then break;\n cool:=j-1;\n //d[j]:=1\n l:=l*j;\n end;\n end;\n{for j:=f[0] downto 1 do\n begin\n q:=l;w:=0;\n while(q*f[j]<=n) do\n begin\n q:=q*f[j];\n Inc(w);\n end;\n if w > g[j] then\n begin\n for q:=1 to w-g[j] do l:=l*f[j];\n g[j]:=w;\n end;\n end;\nbest:=l;}\ngo:=l;\nend;\n\nbegin\n//Assign(input,'input.txt');Reset(input);\n// Assign(output,'output.txt');Rewrite(output);\nReadln(n);\nans:=1;cool:=n;\nfor i:=1 to 3 do\n ans:=ans*go;\nWriteln(ans);\n//Close(input);Close(output);\nend.\n"}, {"source_code": "var n: LongInt;\nx: Int64;\nbegin\n Readln(n);\n if n<3 then x:=n else if odd(n) then x:=n*(n-1)*(n-2) else if n mod 3=0 then x:=(n-1)*(n-2)*(n-3) else x:=n*(n-1)*(n-3);\n Writeln(x);\nend."}, {"source_code": "program C236;\nvar n: integer;\nbegin\nreadln(n);\nif n = 1 then writeln(1)\nelse if n = 2 then writeln(2)\nelse if n = 3 then writeln(6)\nelse if n = 4 then writeln(6)\nelse if n = 5 then writeln(60)\nelse if n = 6 then writeln(60)\nelse if (n mod 2 = 1) then writeln(n*(n-1)*(n-2))\nelse\n begin\n if (n mod 3 <> 0) then writeln(n*(n-1)*(n-3))\n else writeln((n-1)*(n-2)*(n-3));\n end;\nend."}, {"source_code": "program A146;\nconst\n inp='';\n oup='';\nvar\n N:longint;\n Res:int64;\n\nbegin\n readln(N);\n if N=1 then writeln(1);\n if N=2 then writeln(2);\n if n>=3 then\n if N mod 2 = 1 then\n begin\n writeln(int64(N)*int64(N-1)*int64(N-2));\n end\n else\n begin\n Res:=(N-1)*(n-2)*(N-3);\n if (Res< (N*(N-1)*(N-2)) div 2) then\n Res:=N*(N-1)*(N-2) div 2;\n writeln(Res);\n end;\nend.\n"}, {"source_code": "uses math;\nvar \nkk,k:int64;\nl,r,x1,y1,nn,inf,x,y,dd,ans,j,v,ss,i,n,m,s:longint;\nmark,q,dp,xx,yy,mas2:array[0..100003] of longint;\na:array[0..4003,0..4000] of longint;\nch:char;\nfunction gcd(b,a:longint):longint;\nbegin\n{writeln (b,a);}\nif a=0 then gcd:=b\nelse gcd:=gcd(a,b mod a);\nend;\nbegin\nreadln (n);\nif n=1 then begin writeln (1);halt end else\nif n=2 then begin writeln (2);halt end else\nif n=3 then begin writeln (6);halt end;\nif n=4 then begin writeln (12);halt end;\n\ni:=n-1;\nfor i:=max(1,n-100) to n-2 do\n begin\n kk:=(i+1) div gcd(i+1,i+2)*(i+2);\n k:=max (k, i div gcd(i,kk)*kk ); \n end; \n\nwriteln (k);\nEND."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n a, b, c, d, e: int64;\n i: integer;\n\nfunction NOD(x, y: int64): int64;\nbegin\n if x <> 0 then\n NOD := NOD(y mod x, x)\n else\n NOD := y;\nend;\n\nfunction NOK(x, y: int64): int64;\nbegin\n NOK := (x div NOD(x, y)) * y;\nend;\n\nbegin\n\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output);}\n\n read(a);\n if a = 3 then\n write('6')\n else\n if a = 2 then\n write('2')\n else if a = 1 then\n write('1')\n else\n begin\n b := a * (a - 1);\n d := b;\n for i := 1 to a do\n begin\n e := i;\n c := NOK(e, b);\n d := max(d, c);\n end;\n b := a * (a - 3);\n d := b;\n for i := a - 4 to a do\n begin\n e := i;\n c := NOK(e, b);\n d := max(d, c);\n end;\n\n write(d);\n end\nend.\n\n"}, {"source_code": "var n,k,d:longint;\n begin\n readln(n);\n if n<3 then begin\n if n=2 then writeln(2)\n else writeln(1);\n exit;\n end;\n if n mod 2=0 then k:=2\n else k:=1;\n if n mod 2<>0 then d:=2 else d:=1;\n if n*(n-1)*(n-2) div k >(n-2)*(n-1)*(n-3) div d then writeln(n*(n-1)*(n-2) div k)\n else writeln((n-2)*(n-1)*(n-3) div d);\n end. "}, {"source_code": "var n,max:int64;\nbegin\nreadln(n);\nif odd(n) then max:=n*(n-1)*(n-2) else begin\nif n mod 3=0 then max:=(n-2)*(n-1)*(n-3) else max:=n*(n-1)*(n-3);\nif (n*(n-1)*(n-2) div 2>max)then max:=n*(n-1)*(n-2) div 2;\nend;\nwrite(max);\nend."}, {"source_code": "Program ProblemC;\ntype\nPrimeArray = array [1..1000000] of boolean;\nvar\nPrime : PrimeArray;\ni, j, idx : longint;\nIsPrime : boolean;\nn, results, l, temp : int64;\nbegin\nreadln(n); //reading input\nif n = 1 then results := 1;\nif n = 2 then results := 2;\nif n = 3 then results := 6;\nif n = 4 then results := 12;\nif n = 5 then results := 60;\nif n = 6 then results := 60;\nif n > 6 then\nbegin\n//generate prime\n for i := 1 to 1000000 do\n begin\n Prime[i] := true;\n end;\n Prime[1] := false;\n idx := 2;\n repeat\n if Prime[idx] = true then\n begin\n for i := 2 to (1000000 div idx) do\n begin\n Prime[i*idx] := false;\n end;\n end;\n inc(idx);\n until (idx = 1000000);\n if (n mod 2) = 0 then\n begin\n for i := (n-2) downto 2 do\n begin\n if Prime[i] then\n begin\n l := i;\n break;\n end;\n end;\n results := n * (n-1) * l;\n temp := (n-1) * (n-2) * (n-3);\n if temp > results then results := temp;\n end else results := n * (n-1) * (n-2);\nend;\nwriteln(results);\nend.\n\n"}, {"source_code": "function nod(a,b:int64):int64;\n var c:int64;\n begin\n if b>a then begin\n c:=a; a:=b; b:=c;\n end;\n while (a mod b) <> 0 do\n begin\n c:=a mod b;\n a:=b;\n b:=c;\n end;\n nod:=b;\nend;\nfunction zxc(n,p,nok:longint):longint;\nvar i,j,no:integer;\nbegin\nfor j:=n downto p do begin\nfor i:=n-2 downto p do\n begin\n if nok<((j*(j-1)*i)div nod(j*(j-1),i)) then begin\n nok:=(j*(j-1)*i)div nod(j*(j-1),i); no:=nod(j*(j-1),i);\n zxc:=nok;\n end;\nend;\nend;\nend;\nvar nok,no,n,m,p,p2,k,i,j:longint;\n\n\nbegin\n nok:=0;\n read(n);\n\n for i:=n-1\n downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p:=i; break; end;\n\n end;\n if p=n-1 then begin\n for i:=n-2 downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p2:=i; break; end;\n\n end;\n end;\n\n\n if n=1 then write(1)\n else if n=2 then write(2)\n else if n=3 then write(6)\n else if p = n-1 then\n begin\n write(zxc(n,p2,nok));\n end\n else if p = n - 2 then\n begin\n writeln(n*p*(n-1));\n end\n else\n begin\n write(zxc(n,p,nok));\n end;\nend."}, {"source_code": "{$apptype console}\n{$I+,R+,Q+}\nUses\n SysUtils;\nVar\n noko:int64;\n a,b,n:int64;\n\nFunction Nod(a,b:int64):int64;\nBegin\n if b=0 then begin\n result:=a;\n exit;\n end;\n result:=nod(b,a mod b);\nend;\n\nProcedure nok;\nBegin\n noko:=a*n div nod(a,n);\n noko:=noko*b div nod(noko,b);\nEnd;\nVar\n i : integer;\nBegin\n readln(n);\n for i:=n downto 1 do\n if nod(n,i)=1 then begin\n a:=i;\n break;\n end;\n for i:=a downto 1 do\n if (nod(a,i)=1)and(nod(n,i)=1) then begin\n b:=i;\n break;\n end;\n nok;\n writeln(noko);\n\nEnd.\n"}, {"source_code": "var i,j,k,l,m,n:longint;\n nok0,t:int64;\nfunction nod(a,b:longint):longint;\nvar x,y:longint;\nbegin\n x:=a;\n y:=b;\n while (x>0)and(y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n nod:=x+y;\nend;\n\nfunction nok(a,b,c:longint):int64;\nvar p,p1,p2,p3:longint;\nbegin\n p1:=nod(b,c);\n p2:=nod(a,c);\n p3:=nod(a,b);\n p:=nod(a,p1);\n\n\n nok:=a*b*c div p1 div p2 div p3*p;\n\n end;\n\nbegin\n read(n);\n if n>50 then i:=n-50 else i:=1;\nwhile (i<=n)do\n begin\n j:=i;\n l:=i;\n while (l<=n)and(j<=n) do\n begin\n t:=nok(i,j,l);\n IF t>nok0 then nok0:=t;\n\n inc(l);\n\n if l>n then begin\n j:=j+1;\n l:=j;\n end;\n end;\n\n inc(i);\n end;\n write(nok0);\nend."}, {"source_code": "{$MODE OBJFPC}\nVar\n n:Integer;\n Res:Int64;\n\nBegin\n Readln(n);\n If N mod 2=0 then Dec(n);\n Res:=n*(n-1)*(n-2);\n Writeln(res);\nEnd."}, {"source_code": "const fi = '';\n fo = '';\nvar n : Int64;\n\n{}\nProcedure motep;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\n{}\nProcedure dongtep;\nbegin\n close(input); close(output);\nend;\n\n{}\nProcedure solve;\nbegin\n read(n);\n if n = 1 then write(1)\n else if n = 2 then write(2)\n else write(n*(n-1)*(n-2));\nend;\n\nBEGIN\n motep;\n solve;\n dongtep;\nEND."}, {"source_code": "var n, tmp: int64;\n\nFunction Max(a, b: int64): int64;\nbegin\n if a < b then exit(a) else exit(b);\nend;\n\nBegin\n read(n);\n if n = 1 then write(1);\n if n = 2 then write(2);\n if n = 3 then write(6);\n if n = 4 then write(12);\n if n <= 4 then exit;\n if odd(n) then write(n*(n-1)*(n-2))\n else\n begin\n tmp := max((n-1)*(n-2)*(n-3), n*(n-1)*(n-2) div 2);\n if n mod 3 = 0 then tmp := Max(tmp, n*(n-1)*(n-3) div 3)\n else\n tmp := max(tmp, n*(n-1)*(n-3));\n write(tmp);\n end;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nVar\n n:Int64;\n Res:Int64;\n\nBegin\n Readln(n);\n If N mod 2=0 then\n Begin\n If (n-1)*(n-2)*n div 2<(n-2)*(n-1)*(n-3) then\n Res:=(n-2)*(n-1)*(n-3) Else\n Res:=(n-1)*n*(n-2) div 2;\n Writeln(Res);\n Halt;\n End;\n Res:=n*(n-1)*(n-2);\n Writeln(res);\nEnd.\n"}, {"source_code": "uses math;\ntype mass=array[1..1000000] of int64;\nvar r,l,a,z,i,c,k,b,j:integer;s,s1:string;u:boolean;n,res,de:int64;m:mass;\nbegin\n // reset(input,'input.txt');\n // assign(output,'output.txt');\n readln(n);\n if n=1\n then writeln(1)\n else if n<4\n then writeln((n-1)*n)\n else if n mod 2=1\n then writeln((n-1)*(n-2)*n)\n else writeln((n-2)*(n-3)*(n-1));\nend.\n"}, {"source_code": "var\n n:int64;\nbegin\nreadln(n);\nif n=1 then begin write(1); exit; end;\nif n=2 then begin write(2); exit; end;\nif n mod 2=1 then write(n*(n-1)*(n-2)) else write(n*(n-1)*(n-3));\nend."}, {"source_code": "var\n v,z1,n,g,g1,max:int64;\n i,j,z:longint;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n readln(n);\n for i:=n-100 to n do if i>0 then\n for j:=n-100 to n do if j>0 then\n for z:=n-100 to n do if z>0 then\n begin\n g:=i;\n g1:=j;\n while (g>0)and(g1>0) do\n begin\n if g>g1 then g:=g mod g1\n else g1:=g1 mod g;\n end;\n g:=g+g1;\n v:=(i*j) div g;\n\n g:=v;\n g1:=z;\n while (g>0)and(g1>0) do\n begin\n if g>g1 then g:=g mod g1\n else g1:=g1 mod g;\n end;\n z1:=(v*z) div (g+g1);\n if z1>max then\n max:=z1;\n end;\n writeln(max);\nend.\n\n\n"}, {"source_code": "var\n n:longint;\n s:int64;\nbegin\n readln(n);\n if n = 1 then s:=1\n else\n if n = 2 then s:=2\n else\n if n = 3 then s:=6\n else\n if n mod 2 = 0 then s:=(n-1)*(n-2)*(n-3)\n else s:=n*(n-1)*(n-2);\n writeln(s);\nend."}, {"source_code": "Program ProblemC;\ntype\nPrimeArray = array [1..1000000] of boolean;\nvar\nPrime : PrimeArray;\ni, j, idx : longint;\nIsPrime : boolean;\nn, results, l : int64;\nbegin\nreadln(n); //reading input\nif n = 1 then results := 1;\nif n = 2 then results := 2;\nif n = 3 then results := 6;\nif n = 4 then results := 12;\nif n = 5 then results := 60;\nif n = 6 then results := 60;\nif n > 6 then\nbegin\n//generate prime\n for i := 1 to 1000000 do\n begin\n Prime[i] := true;\n end;\n Prime[1] := false;\n idx := 2;\n repeat\n if Prime[idx] = true then\n begin\n for i := 2 to (1000000 div idx) do\n begin\n Prime[i*idx] := false;\n end;\n end;\n inc(idx);\n until (idx = 1000000);\n if not Prime[n] then\n begin\n for i := (n-2) downto 2 do\n begin\n if Prime[i] then\n begin\n l := i;\n break;\n end;\n end;\n results := n * (n-1) * l;\n end else results := n * (n-1) * (n-2);\nend;\nwriteln(results);\nend.\n\n"}, {"source_code": "var\n a, b, c, i: int64;\n \nfunction gcd(a, b: int64): int64;\nbegin\n if a = 0 then begin\n gcd := b;\n exit;\n end;\n gcd := gcd(b mod a, a);\nend;\n \nbegin\n readln(a);\n if a < 3 then begin\n writeln(a);\n halt();\n end;\n b := a * (a - 1);\n c := b;\n i := a - 2;\n while i > 0 do begin\n if b * i div gcd(i, b) > c then c := b * i div gcd(i, b);\n dec(i);\n end;\n writeln(c);\nend."}, {"source_code": "var i,j,x,n,nod,lcm_r,max:longint;min:array[0..3] of longint;\n\n function gcd( a, b: longint): longint; \n begin\n while (a <> 0) and (b <> 0) do\n if a >= b then \n a:= a mod b \n else \n b:= b mod a;\n nod:= a + b;\n end;\n \n procedure lcm (a,b,c:longint) ;\n begin\n gcd (a, b);\n lcm_r:= a*b div nod ;\n gcd (c, lcm_r);\n lcm_r:= c*lcm_r div nod ;\nend;\n\nbegin\nmin[0]:=n+1;\nreadln(n);\n\nfor i:=n downto 1 do begin\nfor j:=n downto 1 do begin\nfor x:=n downto 1 do begin\nlcm(i,j,x);\nif (lcm_r=i*j*x) then begin writeln(lcm_r);halt;end;\nif (lcm_r>max) then max:=lcm_r;\nend;end;end;\nwriteln(max);\nend."}, {"source_code": "var\n N,Ans,Q,Z:Int64;\n i,j,k:Longint;\nfunction Nod(X,Y:Int64):Int64;\nbegin\n while (X>0) and (Y>0) do\n if X>Y then X:=X mod Y\n else Y:=Y mod X;\n Nod:=X+Y;\n end;\nbegin\n Readln(N);\n if N=1 then Writeln('1')\n else\n if N=2 then Writeln('2')\n else\nbegin\n for i:=N-5 to N do\n for j:=N-5 to N do\n for k:=N-5 to N do\nbegin\n Q:=i*j div Nod(i,j);\n Z:=Q*k div Nod(i,j);\n if Z>=Ans then Ans:=Z;\n end;\n Writeln(Ans);\n end;\n end.\n"}, {"source_code": "function nod(a,b:int64):int64;\n var c:int64;\n begin\n if b>a then begin\n c:=a; a:=b; b:=c;\n end;\n while (a mod b) <> 0 do\n begin\n c:=a mod b;\n a:=b;\n b:=c;\n end;\n nod:=b;\nend;\nfunction zxc(n,p,nok:longint):longint;\nvar i,j,no:integer;\nbegin\nfor j:=n downto p do begin\nfor i:=n-2 downto p do\n begin\n if nok<((j*(j-1)*i)div nod(j*(j-1),i)) then begin\n nok:=(j*(j-1)*i)div nod(j*(j-1),i); no:=nod(j*(j-1),i);\n zxc:=nok;\n end;\nend;\nend;\nend;\nvar nok,no,n,m,p,p2,k,i,j:longint;\n\n\nbegin\n nok:=0;\n read(n);\n\n for i:=n-1\n downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p:=i; break; end;\n\n end;\n if p=n-1 then begin\n for i:=n-2 downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p2:=i; break; end;\n\n end;\n end;\n\n\n if n=1 then write(1)\n else if n=2 then write(2)\n else if n=3 then write(6)\n else if p = n-1 then\n begin\n write(zxc(n,p2,nok));\n end\n else if p = n - 2 then\n begin\n writeln(n*p*(n-1));\n end\n else\n begin\n write(zxc(n,p,nok));\n end;\nend."}, {"source_code": "const fin='';\nvar f:text;\n s:qword;\n n:longint;\nbegin\n assign(f,fin); reset(f);\n read(f,n);\n if (n=1) or (n=2) then write(n)\n else\n begin\n if n mod 2=1 then s:=n*(n-1)*(n-2)\n else\n if n mod 3=0 then s:=(n-1)*(n-2)*(n-3)\n else s:=n*(n-1)*(n-3);\n write(s);\n end;\nend.\n"}, {"source_code": "program lcm;\nvar\n n:longint;\n\nprocedure openf;\nbegin\n assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\n\nfunction max(x,y:longint):longint;\nbegin\n if x>=y then exit(x) else exit(y);\nend;\n\nfunction gcd(x,y:int64):int64;\nvar t:int64;\nbegin\n while y<>0 do \n begin\n t:=x mod y;\n x:=y;\n y:=t;\n end;\n gcd:=x;\nend;\n\nfunction cal:int64;\nvar tmp,x,y:int64; i,j,k:longint;\nbegin\n tmp:=0;\n for i:=n downto max(1,n-50) do \n for j:=i-1 downto max(1,n-50) do \n for k:=j-1 downto max(1,n-50) do\n begin\n x:=gcd(i,j); y:=int64(i)*j div x;\n x:=gcd(y,k); y:=y*k div x;\n if y>tmp then tmp:=y;\n end;\n cal:=tmp;\nend;\n\nbegin\n\n readln(n);\n case n of \n 1:writeln(1);\n 2:writeln(2);\n 3:writeln(6);\n else\n begin\n if odd(n) then writeln( n*(n-1)*(n-2) )\n else writeln( cal );\n end;\n end;\n \nend.\n\n"}, {"source_code": "function nod(a,b:int64):int64;\nbegin\nwhile(a<>0)and(b<>0)do\n if a>b then a:=a mod b else b:=b mod a;\nif a<>0 then nod:=a else nod:=b;\nend;\nvar c,n,k:int64;\nbegin\nreadln(n);\nif n=1 then writeln(1)else\n if n=2 then writeln(2)else begin\nc:=n*(n-1);\nk:=1;\n while(true)do begin\n inc(k);\n if nod(c,n-k)<=nod(c,n-k-1)then break;\n end;\nwriteln(c*(n-k) div nod(c,n-k));\nend;\nend.\n"}, {"source_code": "Var n:LongInt;\nBegin\n // ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (n);\n If n<3\n then Writeln (n)\n else If n mod 2=1\n then Writeln (n*(n-1)*(n-2))\n else If n mod 3=0\n then Writeln ((n-1)*(n-2)*(n-3))\n else Writeln (n*(n-1)*(n-3))\nend."}, {"source_code": "var a:array[1..100000] of boolean;\nvar b:array[0..100000] of longint;\nvar i,j:longint;\nvar n:int64;\nbegin\n\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if not a[i] then\n for j:=2 to n div i do a[i*j]:=true;\n for i:=2 to n do if not a[i] then\n begin\n b[0]:=b[0]+1;\n b[b[0]]:=i;\n end;\n if n=1 then write(1)\n else if n=2 then write(2)\n else\n for i:=2 to n do if n mod b[i]>0 then\n begin\n if n*(n-1)*(n-b[i])>(n-1)*(n-2)*(n-3) then\n write(n*(n-1)*(n-b[i]))\n else write((n-1)*(n-2)*(n-3));\n break;\n end;\n\nend."}, {"source_code": "uses math;\nvar a,n,q: integer;\nbegin\n\tread(n);\n\tif (odd(n)) then q:= (n)*(n-1)*(n-2) else q:=(n-3)*(n-1)*(n-2);\n\twrite(q);\nend."}, {"source_code": "Uses Math;\nType tm=Array[1..10000] of LongInt;\nVar m:tm;\n n,kol:LongInt;\n x:Int64;\n\nProcedure Prime (l:LongInt);\nVar i,j,n:LongInt;\nBegin\n m[1]:=2;\n i:=3;\n kol:=1;\n While i<=l do\n Begin\n j:=3;\n n:=Round(sqrt(i))+1;\n While (i mod j<>0) and (j=n then Begin Inc (kol); m[kol]:=i End;\n Inc (i,2);\n End;\nEnd;\n\nBegin\n // ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (n);\n Case n of\n 1:Begin Writeln (1); Halt (0) End;\n 2:Begin Writeln (2); Halt (0) End;\n 3:Begin Writeln (6); Halt (0) End;\n 4:Begin Writeln (12); Halt (0) End;\n 5:Begin Writeln (60); Halt (0) End;\n End;\n Prime (n);\n If n mod 2=0 then Begin\n If m[kol]<>n\n then If m[kol]<>n-1\n then Writeln (n*(n-1)*m[kol])\n else Writeln ((n-1)*n*Max (m[kol-1],n div 2))\n else Writeln (n*(n-1)*Max (m[kol-1],n div 2))\n End else Begin\n If m[kol]<>n\n then If m[kol]<>n-1\n then Writeln (n*(n-1)*m[kol])\n else Writeln ((n-1)*n*Max (m[kol-1],(n-1) div 2))\n else Writeln (n*(n-1)*Max (m[kol-1],(n-1) div 2)) End;\nEnd."}, {"source_code": "Var n,kq:int64;\nBEGIN\n readln(n);\n if (n mod 2)=1 then writeln((n-1)*(n-2)*n)\n else\n if (n mod 3)=1 then writeln((n-3)*(n-2)*(n-1))\n else writeln((n-3)*(n-1)*n);\nEND."}, {"source_code": "{$apptype console}\n{$b-}\nuses math;\nvar\n i,j,k,n:integer;\n mx,cur:int64;\n\n Function gcd(a,b:integer):integer;\n begin\n if b=0 then gcd:=a else gcd:=gcd(b,a mod b);\n end;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(n);\n if n=1 then write(1) else if n=2 then writeln(2)\n else if n=3 then writeln(6) else\n if n=4 then writeln(12) else if n mod 2=1 then writeln(int64(n)*int64(n-1)*int64(n-2))\n else\n begin\n mx:=-1;\n for i := max(1,n-100) to n do\n for j := max(1, n-100) to n do\n for k := max(1,n-100) to n do\n begin\n cur:=int64(i)*int64(j) div gcd(i,j);\n cur:=cur*k div gcd(cur,k);\n if cur>mx then mx:=cur;\n end;\n writeln(mx);\n end;\nend.\n"}, {"source_code": "var a,b,c,q:longint;\nbegin\n read(a);\n b:=a;\n c:=a;\n q:=a*b*c;\n write (q);\nend.\n"}, {"source_code": "program C;\n var\n i,j:longint;\n n,ans:int64;\n\n function gcd(x,y:int64):int64;\n begin\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\n end;\n\n begin\n readln(n);\n ans:=n*(n-1);\n for i:=n-2 downto 1 do\n if (gcd(n,i)=1)and(gcd(n-1,i)=1) then\n break;\n ans:=ans*i;\n writeln(ans);\n end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils, Math;\n\nvar\n res, res2, res1, n, i1: int64;\n i: integer;\n\nbegin\n\n read(n);\n res := 1;\n\n for i := max(1, n - 2) to n do begin\n i1 := i;\n res := res * i1;\n end;\n\n i := 3;\n res2 := 0; \n if (n >= 4) and (n mod 2 = 0) then begin\n while (n >= 4) and (n mod 2 = 0) and (n mod i = 0) and (n - i > 0) do\n inc(i);\n if (n - i > 0) then\n res2 := res div (n - 2) * (n - i);\n end;\n if (n mod 2 = 0) and (n >= 4) then\n res1 := res div n * (n - 3);\n if (n mod 2 = 0) and (n <> 2) then\n res := res div 2;\n\n writeln(max(res, max(res1, res2)));\n\nend.\n"}, {"source_code": "var n,b:int64;\nbegin\nread(n);\n case n of\n 1: write(1);\n 2:write(2);\n 3:write(6);\n else if (odd(n)) then write(n*(n-1)*(n-2)) else write((n-1)*(n-2)*(n-3));\n end;\n end."}, {"source_code": "var n,k,d:int64;\n begin\n readln(n);\n if n<3 then begin\n if n=2 then writeln(2)\n else writeln(1);\n exit;\n end;\n if n mod 2=0 then k:=2\n else k:=1;\n if n mod 2<>0 then d:=2 else d:=1;\n if n*(n-1)*(n-2) div k >(n-2)*(n-1)*(n-3) div d then writeln(n*(n-1)*(n-2) div k)\n else writeln((n-2)*(n-1)*(n-3) div d);\n end. "}, {"source_code": "var n,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nvar p,q:int64;\nbegin\n p:=x;\n q:=y;\n while p<>q do\n if p mod q=0 then\n p:=q\n else\n if q mod p=0 then\n q:=p\n else\n if p>q then\n p:=p mod q\n else\n q:=q mod p;\n gcd:=p;\nend;\n\nbegin\n readln(n);\n if n<=2 then\n writeln(n)\n else begin\n a:=n;b:=n-1;c:=n-2;\n while (gcd(a,c)<>1)or(gcd(b,c)<>1) do dec(c);\n writeln(a*b*c);\n end;\nend."}, {"source_code": "var a,b,c,q:int64;\nbegin\n read(a);\n b:=a-1;\n c:=a-2;\n q:=a*b*c;\n write (q);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n close(f);\nend;\nprocedure xuat;\nvar f:text;\n a,b:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n if n>2 then\n begin\n if n mod 2 = 1 then write(f,n*(n-1)*(n-2))\n else if n mod 3 = 0 then write(f,(n-1)*(n-2)*(n-3))\n else write(f,n*(n-1)*(n-3));\n end\n else if n=2 then write(f,2) else write(f,1);\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "{$Mode objfpc}\n\nuses math;\n\nvar\n n: int64;\n\nbegin\n readln(n);\n if n= 1 then writeln(1) else\n if n= 2 then writeln(2) else\n if odd(n) then writeln(n*(n- 1)*(n- 2)) else\n writeln(n*(n- 1)*(n- 3));\n // writeln(max((n- 1)* (n- 2)* (n- 3), n*(n- 1)*(n- 2) div 2));\nend."}, {"source_code": "var\n n:longint;\n x:Qword;\nbegin\n readln(n);\n if n=1 then begin writeln(1);halt;end;\n if n=2 then begin writeln(2);halt;end;\n if n=3 then begin writeln(6);halt;end;\n if odd(n) then x:=n*(n-1)*(n-2)\n else begin\n if n mod 3=0 then x:=(n-1)*(n-2)*(n-3)\n else x:=n*(n-1)*(n-3);\n end;\n writeln(x);\nend."}, {"source_code": "USES MATH;\nVAR N,K,L:INT64;\nBEGIN\n READ(N);\n IF N<3 THEN\n BEGIN\n IF N=2 THEN WRITELN(2)\n ELSE WRITELN(1);\n HALT(0);\n END;\n if n mod 2=0 then\n begin\n if n mod 3=0 then k:=3\n else k:=1;\n writeln(n*(n-1)*(n-3) div k);\n end\n else\n begin\n writeln(n*(n-1)*(n-2));\n end;\nEND.\n"}, {"source_code": "{$mode objfpc}\nuses math;\nconst\n fi='';\n fo='';\n\nvar\n f: text;\n n: integer;\n a, b, c: integer;\n res: int64;\n\nprocedure enter;\nbegin\n assign(f, fi); reset(f);\n readln(f, n);\n close(f);\nend;\n\nfunction UCLN(a, b: integer): boolean;\nvar c: integer;\nbegin\n repeat\n if a< b then begin\n c:= a; a:= b; b:= c;\n end;\n c:= a mod b;\n a:= b;\n b:= c;\n until b= 0;\n if a= 1 then exit(true)\n else exit(false);\nend;\n\nprocedure solve;\nvar mib, mic: integer;\nbegin\n res:= int64(n);\n a:= n; b:= n; c:= n;\n repeat\n if int64(a)*int64(n)*int64(n)< res then break;\n b:= n;\n repeat\n if int64(a)*int64(b)*int64(n)< res then break;\n if not UCLN(a, b) then begin\n dec(b); continue;\n end;\n c:= n;\n repeat\n if int64(a)*int64(b)*int64(c) < res then break;\n if not UCLN(a, c) or not UCLN(b, c) then begin\n dec(c); continue;\n end;\n res:= max(res, int64(a)*int64(b)*int64(c));\n dec(c);\n until c= 1;\n dec(b);\n until b= 1;\n dec(a);\n until a= 1;\nend;\n\nprocedure printresult;\nbegin\n assign(f, fo); rewrite(f);\n writeln(f, res);\n close(f);\nend;\n\nbegin\n enter;\n solve;\n printresult;\nend."}, {"source_code": "var n: LongInt;\nbegin\n Readln(n);\n if n<3 then Writeln(n) else if odd(n) then Writeln(n*(n-1)*(n-2)) else if n mod 3=0 then Writeln((n-1)*(n-2)*(n-3)) else Writeln(n*(n-1)*(n-3));\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n : Int64;\n\n{}\nProcedure motep;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\n{}\nProcedure dongtep;\nbegin\n close(input); close(output);\nend;\n\n{}\nProcedure solve;\nbegin\n read(n);\n write(n*(n-1)*(n-2));\nend;\n\nBEGIN\n motep;\n solve;\n dongtep;\nEND."}, {"source_code": "uses math;\nvar \nl,r,x1,y1,nn,k,inf,x,y,dd,ans,j,v,ss,i,n,m,s:longint;\nmark,q,dp,xx,yy,mas2:array[0..100003] of longint;\na:array[0..4003,0..4000] of longint;\nch:char;\nfunction gcd(b,a:longint):longint;\nbegin\n{writeln (b,a);}\nif a=0 then gcd:=b\nelse gcd:=gcd(a,b mod a);\nend;\nbegin\nreadln (n);\nif n=1 then begin writeln (1);halt end else\nif n=2 then begin writeln (2);halt end else\nif n=3 then begin writeln (6);halt end;\n\ni:=n-1;\nwhile gcd(n,i)<>1 do\n dec(i);\n{writeln (i);}\n\nif i=n-1 then j:=n-2 else j:=n-1;\n\nwriteln (i*n div gcd(n,j)*j);\nEND."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils, Math;\n\nvar\n res, n, i1: int64;\n i: integer;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n read(n);\n res := 1;\n\n for i := max(1, n - 2) to n do begin\n i1 := i;\n res := res * i1;\n end;\n\n if (n mod 2 = 0) and (n > 2) then begin\n res := res div 2;\n if (n >= 4) then\n if (n div 2 < n - 3) then\n res := res * 2 div n * (n - 3);\n end;\n\n writeln(res);\n\nend.\n"}, {"source_code": "uses math;\nvar\n a,b,c,d,n,i:longint;\nfunction main:int64;\nvar q,w,e:int64;\nbegin\n readln(n);\n if n=1 then exit(1);\n if n=2 then exit(2);\n if n=3 then exit(6);\n if n=4 then exit(12);\n d:=n;\n c:=n-1;\n b:=n-2;\n a:=n-3;\n if odd(d) then exit(int64(d)*b*c);\n if (d mod 3=0) and (a mod 3=0) then q:=(int64(d)*c*a) div 3\n else q:=d*c*a;\n w:=int64(d)*c*b div 2;\n e:=int64(a)*b*c ;\n if w>e then e:=w;\n if q>e then e:=q;\n exit(e);\n\nend;\nbegin\n writeln(main);\nend."}, {"source_code": "var s,n:int64;\nfunction ucln(a,b:int64):int64;\nbegin\n if b=0 then exit(a);\n exit(ucln(b,a mod b));\nend;\nbegin\n readln(n);\n if n<3 then s:=n else\n if n=3 then s:=6 else\n if n=4 then s:=12 else\n begin\n s:=n*(n-1)*(n-2);\n if ucln(n,n-2)<>1 then s:=(n-1)*(n-2)*(n-3);\n end;\n write(s);\n readln;\nend.\n"}, {"source_code": "var\na,max,b1,b2,ans:int64;\ni:integer;\nflag:boolean;\nFunction GCD(m,n:int64):int64;\nbegin\nif n mod m=0 then GCD:=m else\nif m mod n=0 then GCD:=n else\nbegin\nif m>n then GCD:=GCD(m mod n, n);\nif n>m then GCD:=GCD(n mod m, m);\nend;\nend;\nbegin\nread(a);\nif a=1 then Writeln(1) else\nif a=2 then Writeln(2) else\nfor i:=a-2 downto 1 do\nbegin\nb1:=GCD(a,i);\nb2:=GCD(i,a-1);\nans:=(a*(a-1)*i) div (b1*b2);\nif ans>max then max:=ans;\nend;\nWriteln(max);\nend."}, {"source_code": "uses math;\nconst\n pi=3.1415926535;\nvar\n f,ff:array[0..100,0..100] of longint;\n a,b:array[0..210000] of longint;\n// b:array[1..100] of longint;\n\n x,y,k,l,i,j,z,col,r,jj,m,t,ans:longint;\n st,stt:array[0..50100] of string;\n p:array[1..50000] of boolean;\n s,ss,sw:ansistring;\n ch:array['a'..'z'] of longint;\n// x,y,xx,yy:extended;\n c:char;\n w:array['a'..'z'] of longint;\n xx,n,ms,tp:int64;\n// v,r,s,ss,k,t,al:extended;\n\nfunction nod(a,b,c:int64):int64;\n var\n x,y,k:int64;\nbegin\n x:=a;y:=b;\n while x*y>0 do\n if x>y then x:=x mod y else y:=y mod x;\n x:=a*b div (x+y); k:=x;\n y:=c;\n while x*y>0 do\n if x>y then x:=x mod y else y:=y mod x;\n x:=k*c div (x+y);\nend;\n\nbegin\n//ssign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\n read(n);\n if n=1 then write(1) else if n=2 then write(2) else\n// for i:=n downto 1 do\n// if pr(i) then break;\n begin\n if odd(n) then write(n*(n-1)*(n-2)) else\n begin\n tp:=nod(n,n-1,n-2);\n xx:=nod(n,n-1,n-3);\n\n\n write(max(tp,xx));\n end;\n end;\n\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n n : integer;\n i : integer;\n j : integer;\n res : int64;\n a : array[2..1000000] of boolean;\nbegin\n readln(n);\n for i := 2 to 1000000 do\n begin\n j := 2;\n while (j * i < 1000000) do\n begin\n a[i * j] := true;\n inc(j);\n end;\n end;\n for i := 2 to n do\n if not(a[i]) then res := i;\n if res = n then\n writeln(res * (res - 1) * (res - 2));\n if res = n - 1 then\n writeln(res * (res - 1) * n);\n if res < n - 1 then\n writeln(res * (res + 1) * (res + 2));\nend."}, {"source_code": "uses math;\nconst\n nmax = 100;\nvar\n m:longint;\n n,res:int64;\nfunction UCLN(u,v:int64):int64;\nbegin\n if v=0 then exit(u) else exit(UCLN(v,u mod v));\nend;\nprocedure nhap;\nvar i,j:longint;\nu:int64;\nbegin\n read(n);\n if (n=1) then writeln(1)\n else if n=2 then writeln(2)\n else if n=3 then writeln(6)\n else\n begin\n res:=0;\n u:=n*(n-1);\n for i:=1 to n do\n res:=max(res,(i*u) div UCLN(i,u) );\n writeln(res);\n // writeln(u*(n-3)div UCLN(u,n-3));\n end;\nend;\nprocedure xuly;\nvar i,j,t,res1,res2,res3:longint;\nu,v:int64;\nbegin\n res:=0;\n for i:=1 to n do for j:=1 to n do for t:=1 to n do\n begin\n u:=(i*j)div UCLN(i,j);\n v:=(u*t)div UCLN(u,t);\n if res0)and(y<>0) do\n begin\n if x>y then x:=x mod y\n else y:=y mod x;\n\n end;\n nod:=x+y;\n end;\n\nbegin\n readln(n);\n if (N=1) then writeln(1)\n else if(n=2) then writeln(2)\n else begin\n k3:=n;\n k2:=n-1;\n for i:=k2 downto 2 do\n begin\n if (nod(k2,i)=1) and(nod(k3,i)=1) then\n begin\n k1:=i;\n break;\n end;\n\n end;\n if k1=0 then\n begin\n for i:=n downto 2 do\n begin\n if (k3*k2 mod i<>0) then begin\n k1:=i;\n end;\n end;\n if k1=0 then k1:=1;\n if (nod(k1,k2)<>1) then k1:=k1 div nod(k1,k2);\n if (nod(k1,k3)<>1) then k1:=k1 div nod(k1,k3);\n end;\n writeln(k1*k2*k3);\n end;\nend.\n"}, {"source_code": "VAR N:QWORD;\nBEGIN\n READ(N);\n WRITELN(N*(N-1)*(N-2));\nEND."}, {"source_code": "Var\n kq :int64;\n n :longint;\nbegin\n read(n);\n if n=2 then write(2);\n if n=3 then write(6);\n if n>3 then\n begin\n kq:=n;\n kq:=kq*(n-1)*(n-2);\n if n mod 2=0 then write(kq div 2)\n else write(kq);\n end;\nend."}, {"source_code": "const fin='';\nvar f:text;\n s:qword;\n n:longint;\nbegin\n assign(f,fin); reset(f);\n read(f,n);\n if (n=1) or (n=2) then write(n)\n else\n begin\n if n mod 2=1 then s:=n*(n-1)*(n-2)\n else\n if n mod 3=0 then s:=(n-1)*(n-2)*(n-3)\n else s:=n*(n-2)*(n-3);\n write(s);\n end;\nend.\n"}, {"source_code": "var i,j,k,l,m,n:longint;\n nok0,t:int64;\nfunction nod(a,b:longint):longint;\nvar x,y:longint;\nbegin\n x:=a;\n y:=b;\n while (x>0)and(y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n nod:=x+y;\nend;\n\nfunction nok(a,b,c:longint):int64;\nvar p,p1,p2,p3:longint;\nbegin\n p1:=nod(b,c);\n p2:=nod(a,c);\n p3:=nod(a,b);\n p:=nod(a,p1);\n\n\n nok:=b div p1*c div p2*a div p3*p;\n\n end;\n\nbegin\n read(n);\n if n>50 then i:=n-50 else i:=1;\nwhile (i<=n)do\n begin\n j:=i;\n l:=i;\n while (l<=n)and(j<=n) do\n begin\n t:=nok(i,j,l);\n IF t>nok0 then nok0:=t;\n\n inc(l);\n\n if l>n then begin\n j:=j+1;\n l:=j;\n end;\n end;\n\n inc(i);\n end;\n write(nok0);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, n1, i, top, j: integer;\n f, f1: boolean;\n a: array[1..100000] of integer;\n ans: int64;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n readln(n);\n if n = 1 then\n begin\n writeln(1);\n halt;\n end;\n if n = 2 then\n begin\n writeln(2);\n halt;\n end;\n if n = 3 then\n begin\n writeln(6);\n halt;\n end;\n n1 := n;\n i := 2;\n top := 0;\n while n1 > 1 do\n begin\n while n1 mod i = 0 do\n begin\n inc(top);\n a[top] := i;\n n1 := n1 div i;\n end;\n inc(i);\n end;\n n1 := n - 1;\n i := 2;\n while n1 > 1 do\n begin\n while n1 mod i = 0 do\n begin\n inc(top);\n a[top] := i;\n n1 := n1 div i;\n end;\n inc(i);\n end;\n ans := int64(n) * int64(n - 1);\n f1 := false;\n if n mod 2 = 0 then\n begin\n for i := n - 2 downto 1 do\n begin\n f := false;\n for j := 1 to top do\n begin\n if i mod a[j] = 0 then\n begin\n f := true;\n break;\n end;\n end;\n if not f then\n begin\n ans := ans * int64(i);\n f1 := true;\n break;\n end;\n end;\n if not f1 then\n ans := ans * int64(n - 2) div 2;\n end\n else\n ans := ans * (n - 2);\n writeln(ans);\nend.\n"}, {"source_code": "var a,b,c,x,n:int64;\n begin\n read(n);\n a:=n;\n b:=n-1;\n c:=n-2;\n x:=a*b;\n while (a>0)and(b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n a:=x div(a+b);\n x:=a*c;\n while (a>0)and(c>0) do\n if a>c then a:=a mod c\n else c:=c mod a;\n writeln(x div (c+a));\n end."}, {"source_code": "Var n:LongInt;\nBegin\n // ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (n);\n If n<3\n then Writeln (n)\n else If n mod 2=1\n then Writeln (n*(n-1)*(n-2))\n else If n mod 3=0\n then Writeln ((n-1)*(n-2)*(n-3))\n else Writeln (n*(n-1)*(n-3))\nend."}, {"source_code": "var\ny,x,ans:int64;\ni,j,k,n,m:longint;\nprocedure init;\nbegin \n\treadln(n);\n\tif n<3 then \n\tbegin \n\t\twriteln(0);\n\t\thalt;\n\tend;\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin \n\tif b=0 then exit(a);\n\texit( gcd(b,a mod b) );\nend;\n\nprocedure work;\nbegin \n\tif n>50 then \n\tbegin \n\t\tfor i:=n downto n-50 do\n\t\tfor j:=i-1 downto n-50 do\n\t\tfor k:=j-1 downto n-50 do \n\t\tbegin \n\t\t\tx:=i; y:=j;\n\t\t\tx:=x*y div gcd(x,y);\n\t\t\ty:=k;\n\t\t\tx:=x*y div gcd(x,y);\n\t\t\tif x>ans then ans:=x;\n\t\tend;\n\tend else \n\tbegin \n\t\tfor i:=n downto 1 do\n\t\tfor j:=i-1 downto 1 do\n\t\tfor k:=j-1 downto 1 do \n\t\tbegin \n\t\t\tx:=i; y:=j;\n\t\t\tx:=x*y div gcd(x,y);\n\t\t\ty:=k;\n\t\t\tx:=x*y div gcd(x,y);\n\t\t\tif x>ans then ans:=x;\n\t\tend;\n\tend;\n\twriteln(ans);\nend;\n\nbegin\n\tinit;\n\twork;\nend."}, {"source_code": "var\n lcm,max:int64;\n n,i,j,k:longint;\nfunction gcd(x,y:int64):int64;\nbegin\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\nend;\nbegin\n readln(n);\n if n mod 2=1 then\n begin\n writeln(n*(n-1)*(n-2));\nhalt;\nend;\n for i:=n-10 to n do\n if i>0 then\n for j:=n-10 to n do\n if j>0 then\n for k:=n-10 to n do\n if k>0 then\n begin\n lcm:=i*j div gcd(i,j);\n lcm:=lcm*k div gcd(lcm,k);\n if lcm>max then max:=lcm;\n end;\n writeln(max);\nend."}, {"source_code": "var n,a,b,c:int64;\n\nfunction gcd(x,y:int64):int64;\nvar p,q:int64;\nbegin\n p:=x;\n q:=y;\n while p<>q do\n if p mod q=0 then\n p:=q\n else\n if q mod p=0 then\n q:=p\n else\n if p>q then\n p:=p mod q\n else\n q:=q mod p;\n gcd:=p;\nend;\n\nbegin\n readln(n);\n a:=n;\n b:=n-1;\n c:=n-2;\n while (gcd(a,c)<>1)and(gcd(b,c)<>1) do\n dec(c);\n writeln(a*b*c);\n readln;\nend."}, {"source_code": "var a:array [1..1000001] of int64;\n n,j,s:int64;\n i:longint;\nprocedure qSort(l,r:int64);\nvar i,j,z,x:int64;\nbegin\n i:=l;\n j:=r;\n x:=a[(i+j)div 2];\n repeat\n while a[i]x do j:=j-1;\n if i<=j\n then\n begin\n z:=a[i];\n a[i]:=a[j];\n a[j]:=z;\n i:=i+1;\n j:=j-1;\n end;\n until (i>j);\n if il then qSort(l,j);\nend;\nfunction nok(x,y:int64):int64;\nvar a,b,s:int64;\nbegin\n a:=x*y;\n while (x>0) and (y>0) do\n if x>y\n then x:=x mod y\n else y:=y mod x;\n s:=x+y;\n b:=a div s;\n nok:=b;\nend;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n readln(n);\n if (n=1)\n then\n begin\n writeln(1);\n exit;\n end;\n if (n=2)\n then\n begin\n writeln(2);\n exit;\n end;\n j:=1;\n for i:=3 to n do\n begin\n s:=nok(i,nok(i-1,i-2));\n a[j]:=s;\n j:=j+1;\n end;\n qsort(1,j);\n writeln(a[j]);\nend.\n"}, {"source_code": "var\ni,j:longint;\nf,q,nod,g,p1,x,ans,d,kol,p,n:int64;\na:array[-100..300000]of longint;\nbegin\nreadln(n);\n\nif n<=2 then writeln(n)\nelse\nif n=3 then writeln(6)\nelse begin\n if n mod 2 = 1 then begin\n for i:=n-1 downto 1 do begin\n q:=n;\n f:=i;\n while (q>0)and(f>0) do begin\n if q>f then q:=q mod f\n else\n f:=f mod q;\n end;\n nod:=f+q;\n if (i<>n-2)and(((n div nod)*(n-2)*(i div nod)*nod)>ans) then ans:=(n div nod)*(n-2)*(i div nod)*nod;\n\n end;\n writeln(AnS);\n\n\n\n end\n else begin\n\n\n for i:=n-2 downto 1 do begin\n q:=n;\n f:=i;\n while (q>0)and(f>0) do begin\n if q>f then q:=q mod f\n else\n f:=f mod q;\n end;\n nod:=f+q;\n if ((n div nod)*(n-1)*(i div nod)*nod)>ans then ans:=(n div nod)*(n-1)*(i div nod)*nod;\n\n end;\n writeln(AnS);\n end;\n\nend;\nend."}, {"source_code": "var i,j,k,l,m,n:longint;\n nok0,t:int64;\nfunction nod(a,b:longint):longint;\nvar x,y:longint;\nbegin\n x:=a;\n y:=b;\n while (x>0)and(y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n nod:=x+y;\nend;\n\nfunction nok(a,b,c:longint):int64;\nvar p,p1,p2,p3:longint;\nbegin\n p1:=nod(b,c);\n p2:=nod(a,c);\n p3:=nod(a,b);\n p:=nod(a,p1);\n\n\n nok:=a div p1*b div p2*c div p3*p;\n\n end;\n\nbegin\n read(n);\n if n>50 then i:=n-50 else i:=1;\nwhile (i<=n)do\n begin\n j:=i;\n l:=i;\n while (l<=n)and(j<=n) do\n begin\n t:=nok(i,j,l);\n IF t>nok0 then nok0:=t;\n\n inc(l);\n\n if l>n then begin\n j:=j+1;\n l:=j;\n end;\n end;\n\n inc(i);\n end;\n write(nok0);\nend."}, {"source_code": "var i, j, x, n, nod, lcm_r, max, q, y, z: longint;\n\nfunction gcd(a, b: longint):longint;\nbegin\nif b=0 then gcd:=a else gcd:=gcd(b,a mod b);\nend;\n\nprocedure lcm(a, b, c: longint) ;\nbegin\n\n lcm_r := a * b div gcd(a, b);\n lcm_r := c * lcm_r div gcd(c, lcm_r);\nend;\n\nbegin\nreadln(n);\nif n=1 then begin writeln('1'); halt; end;\nif n=2 then begin writeln('2'); halt; end;\nfor i:=n downto i do begin\n for j:=i-1 downto 1 do if gcd(i,j)=1 then break;\n for z:=j-1 downto 1 do if gcd(j,z)=1 then break;\n lcm(i, j, z);\n if (lcm_r > max) then max := lcm_r; \n end;\n writeln(max);\nend."}, {"source_code": "var n : int64;\nfunction NOK (d1,d2,d3 : int64) : int64;\nvar x,y,z : int64;\nbegin\n x:=d1;\n y:=d2;\n z:=d3;\n while (x>0)and(y>0) do if x>y then x:=x mod y else y:=y mod x;\n x:=x+y;\n while (x>0)and(z>0) do if x>z then x:=x mod z else z:=z mod x;\n x:=x+z;\n NOK:=(d1 div x)*d2*d3;\nend;\nfunction max (x,y : int64) : int64;\nbegin\n if x>y then max:=x else max:=y;\nend;\nbegin\n readln(n);\n if n=1 then writeln(1) else\n if n=2 then writeln(2) else\n if n=3 then writeln(6) else\n if n=4 then writeln(12) else\n if n=5 then writeln(60) else\n if n mod 2=1 then writeln(Nok(n,n-1,n-2)) else\n if n mod 2=0 then writeln(Max(Nok(n,n-1,n-3),Nok(n-1,n-2,n-3)));\nend.\n"}, {"source_code": "program C236;\nvar n: integer;\n a, k: longint;\n i, j: byte;\n\nbegin\nreadln(n);\na := 0;\nk := 0;\nif n = 1 then writeln(1)\nelse if n = 2 then writeln(2)\nelse if n = 4 then writeln(6)\n\nelse if (n mod 2 = 1) then\n begin\n writeln(n*(n-1)*(n-2));\n end\nelse\n begin\n if (n mod 3 <> 0) then\n writeln(n*(n-1)*(n-3))\n else begin\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do\n begin\n if ((i<>j) and (i<>4) and (i<>2) and (j<>4) and (j<>2)) then\n begin\n k := (n-i) * (n-j);\n if k > a then a := k;\n end;\n end;\n end;\n writeln(n*a);\n end;\n end;\nend."}, {"source_code": "var\na:int64;\ni:integer;\nflag:boolean;\nFunction GCD(m,n:int64):int64;\nbegin\nif n mod m=0 then GCD:=m else\nif m mod n=0 then GCD:=n else\nbegin\nif m>n then GCD:=GCD(m mod n, n);\nif n>m then GCD:=GCD(n mod m, m);\nend;\nend;\nbegin\nread(a);\nif a=1 then Writeln(1) else\nif a=2 then Writeln(2) else\nfor i:=a-2 downto 1 do\nif not flag and (GCD(a,i)=1) and (GCD(a-1,i)=1) then\nbegin\nflag:=true;\nWriteln(i*a*(a-1));\nend;\nend."}, {"source_code": "function nod(a,b:longint):longint;\n var c:longint;\n begin\n if b>a then begin\n c:=a; a:=b; b:=c;\n end;\n while (a mod b) <> 0 do\n begin\n c:=a mod b;\n a:=b;\n b:=c;\n end;\n nod:=b;\nend;\nfunction zxc(n,p,nok:longint):longint;\nvar i,no:integer;\nbegin\nfor i:=n-2 downto p do\n begin\n if nok<((n*(n-1)*i)div nod(n*(n-1),i)) then begin\n nok:=(n*(n-1)*i)div nod(n*(n-1),i); no:=nod(n*(n-1),i);\n zxc:=nok;\n end;\n if (no>1) and ((n-2) > p) then begin\n n:=n-1;\n zxc(n,p,nok);\n end;\nend;\nend;\nvar nok,no,n,m,p,p2,k,i,j:longint;\n\n\nbegin\n nok:=0;\n read(n);\n\n for i:=n-1\n downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p:=i; break; end;\n\n end;\n if p=n-1 then begin\n for i:=n-2 downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p2:=i; break; end;\n\n end;\n end;\n\n\n if n=1 then write(1)\n else if n=2 then write(2)\n else if n=3 then write(6)\n else if p = n-1 then\n begin\n write(zxc(n,p2,nok));\n end\n else if p = n - 2 then\n begin\n writeln(n*p*(n-1));\n end\n else\n begin\n write(zxc(n,p,nok));\n end;\nend."}, {"source_code": "Var\n n :int64;\n i :longint;\n kq,x :int64;\n\nFunction UCLN(a,b:int64):int64;\nvar\n r :int64;\nbegin\n While b<>0 do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(a);\nend;\n\nFunction BCNN(a,b,c:int64):int64;\nvar\n x :int64;\nbegin\n x:=(a*b) div UCLN(a,b);\n BCNN:=(x*c) div UCLN(x,c);\nend;\n\nbegin\n read(n);\n if n=2 then write(2);\n if n=3 then write(6);\n if n=4 then write(12);\n if n>4 then\n begin\n if n mod 2=1 then write(n*(n-1)*(n-2))\n else\n begin\n kq:=(n-1)*(n-2)*(n-3);\n for i:=n-2 downto 1 do\n begin\n x:=BCNN(n,n-1,i);\n if x>kq then kq:=x;\n end;\n write(kq);\n end;\n end;\nend.\n"}, {"source_code": "var\n a : array [1..1000] of longint;\n s : string;\n i,ans : longint;\nbegin\n readln(s);\n for i:=1 to length(S) do a[ord(s[i])]:=1;\n for i:=1 to 255 do\n if a[i]=1then inc(ans);\n if ans mod 2=0 then writeln('CHAT WITH HER!')\n else writeln('IGNORE HIM!');\nend.\n"}, {"source_code": "program A146;\nconst\n inp='';\n oup='';\nvar\n N:longint;\n Res:int64;\n i,j,k:longint;\n\nfunction UCLN(A,B:longint):int64;\nbegin\n if b=0 then exit(A);\n exit(UCLN(B, A mod B));\nend;\n\nfunction Get(X,Y,Z:int64):int64;\nvar Cres:int64;\nbegin\n Cres:=(X*Y) div UCLN(X,Y);\n CreS:=(Cres*Z) div UCLN(Cres,Z);\n exit(Cres);\nend;\n\nbegin\n readln(N);\n if N=1 then writeln(1);\n if N=2 then writeln(2);\n if n>=3 then\n begin\n for i:=N downto N-100 do\n for j:=i-1 downto N-100 do\n for k:=j-1 downto N-100 do\n if (i>0) and (j>0) and (k>0) then\n begin\n if Resa then begin\n c:=a; a:=b; b:=c;\n end;\n while (a mod b) <> 0 do\n begin\n c:=a mod b;\n a:=b;\n b:=c;\n end;\n nod:=b;\nend;\nfunction zxc(n,p,nok:int64):int64;\n\nvar i,j,no:int64;\nbegin\nj:=n;\ni:=n-2;\nwhile j >= p do begin\nwhile i >=p do\n\n begin\n if nok<((j*(j-1)*i)div nod(j*(j-1),i)) then begin\n nok:=(j*(j-1)*i)div nod(j*(j-1),i); no:=nod(j*(j-1),i);\n zxc:=nok;\n end;\n i:=i-1;\n end;\nj:=j-1;\ni:=j-2;\nend;\nend;\nvar no,n,m,p,p2,k,i,j:longint;\nnok:int64;\n\n\nbegin\n nok:=0;\n read(n);\n\n for i:=n-1\n downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p:=i; break; end;\n\n end;\n if p=n-1 then begin\n for i:=n-2 downto 1 do\n begin\n m:=0;\n j:=2;\n while j<=(sqrt(i)+1) do\n begin\n if (i mod j) = 0 then m:=1;\n j:=j+1;\n end;\n if m=0 then begin p2:=i; break; end;\n\n end;\n end;\n\n\n if n=1 then write(1)\n else if n=2 then write(2)\n else if n=3 then write(6)\n else if p = n-1 then\n begin\n write(zxc(n,p2,nok));\n end\n else if p = n - 2 then\n begin\n writeln(n*p*(n-1));\n end\n else\n begin\n write(zxc(n,p,nok));\n end;\nend."}], "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e"} {"source_code": "uses math;\nconst\n fi='';\n fo='';\nvar\n a,b:int64;\n{------------------------------------}\nprocedure main;\n begin\n read(a,b);\n while (a>0) and (b>0) do\n begin\n a:=a mod (2*b);\n if a= 0 then break;\n if b>=2*a then b:=b mod (2*a) else break;\n end;\n write(a,' ',b);\n end;\n{------------------------------------}\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n main;\nend.\n", "positive_code": [{"source_code": "var a,b:qword;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(a,b);\nwhile (a>0)and(b>0) do\n begin\n if a>=2*b then a:=a mod (2*b)\n else if b>=2*a then b:=b mod (2*a) else break;\n end;\nwrite(a,' ',b);\n\nend.\n"}, {"source_code": "var a,b:int64;\n \nbegin\n readln(a,b);\n while (a>0)and(b>0) do begin\n if a>=2*b then begin \n a:=a-(a div (2*b))*2*b;\n continue;\n end;\n if b>=2*a then begin\n b:=b-(b div (2*a))*2*a;\n continue;\n end\n else break;\n end;\n \n println(a,b);\nend."}, {"source_code": "var\n a, b: int64;\nbegin\n readln(a, b);\n repeat\n if (a = 0) or (b = 0) then break;\n if a >= 2 * b then a := a mod (2 *b)\n else\n if b >= 2 * a then b := b mod (2 *a);\n until (not ((a >= 2 * b) or (b >= 2 * a)));\n Print(a, b);\nend.\n\n"}, {"source_code": "var \n a, b : int64;\nbegin \n readln(a, b);\n while (a > 0) and (b > 0) do\n if a >= 2 * b \n then \n a := a mod (2 * b)\n else \n if b >= 2 * a \n then \n b := b mod (2 * a)\n else \n begin\n write(a, ' ', b);\n exit;\n end; \n write(a, ' ', b)\nend."}, {"source_code": "Program ILoveYou;\nVAR a,b:int64;\nBegin\n\nReadln(a,b);\n\nwhile (a <> 0) and (b <> 0) and ((a >= 2*b) or (b >= 2*a)) do\nBegin\n\na:=a mod (2*b);\n\nif (a <> 0) then b:=b mod (2*a);\n\n\nend;\n\nWriteln(a,' ',b);\n\nReadln;\nEND."}, {"source_code": "var a,b:int64;\nbegin\n read(a,b);\n while(a<>0)and(b<>0) do\n begin\n if a div (2*b) > 0 then\n a:=a-(a div (2*b)*2*b)\n else if b div (2*a) > 0 then\n b:=b-(b div (2*a)*2*a)\n else\n break;\n end;\n write(a,' ',b);\nend."}, {"source_code": "var n,m:int64;\nbegin\n read(n,m);\n while(n<>0)and(m<>0) do\n begin\n if n div (2*m) > 0 then\n n:=n-(n div (2*m)*2*m)\n else \n if m div (2*n) > 0 then\n m:=m-(m div (2*n)*2*n)\n else\n break;\n end;\n write(n,' ',m);\nend."}, {"source_code": "var a, b : int64;\n\nbegin\n readln(a, b);\n while (a <> 0) and (b <> 0) do\n if a >= 2*b then\n a := a mod (2*b)\n else if b >= 2*a then\n b := b mod (2*a)\n else\n break;\n write(a,' ',b);\nend."}, {"source_code": "var\n a, b: uint64;\n k: shortint;\n\nbegin\n readln(a, b);\n while k = 0 do\n begin\n if (a = 0) or (b = 0) then\n k := 1\n else\n if a + 1 > 2 * b then\n a := a - (a div (2 * b)) * 2 * b\n else\n if b + 1 > 2 * a then\n b := b - (b div (2 * a)) * 2 * a\n else\n k := 1;\n end;\n writeln(a, ' ', b);\nend."}, {"source_code": "var a,b :int64;\n\nBEGIN\nread(a,b);\n\nwhile(a>0) and (b>0) do \n begin\n if a>=2*b then a:=(a mod (2*b))\n else\n if b>=2*a then b:=(b mod (2*a))\n else\n break;\nend;\n\n\nwrite(a,' ',b);\n\nEND.\n"}, {"source_code": "var a, b, c : int64;\n\nbegin\n read (a, b);\n while (a <> 0) and (b <> 0) do\n begin\n if (a >= b*2) then a := a mod (b*2)\n else if (b >= a*2) then b := b mod (a*2)\n else break;\n end;\n print (a, b);\nend."}, {"source_code": "var a,b :int64;\n\nBEGIN\nread(a,b);\n\nwhile(a>0) and (b>0) do \n begin\n if a>=2*b then a:=(a mod (2*b))\n else\n if b>=2*a then b:=(b mod (2*a))\n else\n break;\nend;\n\n\nwrite(a,' ',b);\n\nEND."}, {"source_code": "program vychitanie;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:int64;\nbegin\n readln(a,b);\n while ((a<>0) and (b<>0)) do \n if (a>=2*b) then a:=a mod (2*b)\n else if (b>=2*a) then b:=b mod (2*a)\n else break;\n writeln(a,' ',b); \n readln;\n readln;\nend.\n"}, {"source_code": "program stran_vich;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,m:int64;\nbegin\n readln(n,m);\n while((n<>0)and(m<>0))do begin\n if(n>=2*m) then n:=n mod (2*m)\n else if(m>=2*n) then m:=m mod (2*n)\n else break;\n end;\n writeln(n,' ',m);\n\n\n\n readln;\n\n\n\nend.\n"}, {"source_code": "\nprogram NUMBER1;\n \n{$APPTYPE CONSOLE}\n \nuses\n SysUtils, Math;\nvar\n a, b: int64;\n x: boolean;\n\n\nbegin\n readln (a, b);\n x := false;\n while (x = false) do begin\n if (a = 0) or (b = 0) then\n break\n else if (a >= 2 * b) then\n a := a - (a div (2 * b) * 2 * b)\n else if (b >= 2 * a) then\n b := b - (b div (2 * a) * 2 * a)\n else\n x := true;\n end;\n writeln (a, ' ', b);\n\n\n readln;\n readln;\nend.\n\n"}, {"source_code": "program UnusualSubstraction;\nvar n,m: int64;\nprocedure gcd(var a,b: int64);\nvar changes: boolean;\nbegin\nchanges:=true;\nwhile (a>0) and (b>0) and (changes) do begin\n changes:=false;\n if (a>=2*b) and (b>0) then begin\n a:=a mod (2*b);\n changes:=true;\n end;\n if (b>=2*a) and (a>0) then begin\n b:=b mod (2*a);\n changes:=true;\n end;\nend;\nend;\nBEGIN\nreadln(n,m);\ngcd(n,m);\nwriteln(n,' ',m);\nEND."}, {"source_code": "var\n n,m,d,l,r,dd,nn,mm : int64;\nbegin\n //assign(input,'1.in');reset(input);\n readln(n,m);\n while (n>0) and (m>0) do\n begin\n if n>=m*2 then\n begin\n d:=n div (m*2);\n l:=0; r:=d;\n while l=m*2 then l:=dd else r:=dd-1;\n end;\n inc(l);\n n:=n-l*m*2;\n end else\n if m>=n*2 then\n begin\n d:=m div (n*2);\n l:=0; r:=d;\n while l=n*2 then l:=dd else r:=dd-1;\n end;\n inc(l);\n m:=m-l*n*2;\n end else break;\n end;\n writeln(n,' ',m);\nend.\n"}, {"source_code": "var a,b,c,d,e,f:int64;\nvar m:string;\nbegin\n read(a);\n read(b);\n while(1<10) do\n begin\n if(a=0) or (b=0) then\n begin\n break;\n end;\n if(a>=2*b) then\n begin\n c:=b*2;\n a:=a-((a div c)*c);\n continue;\n end;\n if(b>=2*a) then\n begin\n d:=a*2;\n b:=b-((b div d)*d);\n continue;\n end;\n break;\n end;\n write(a);\n write(' ');\n write(b);\n\n\n\n\n\nend.\n"}, {"source_code": "var\n a, b: Int64;\n\nbegin\n ReadLn(a, b);\n While (a > 0) and (b > 0) do\n begin\n If (a < 2*b) and (b < a*2) then Break;\n If a >= 2*b then\n begin\n a := a mod (2*b);\n end else\n begin\n b := b mod (a*2);\n end;\n end;\n WriteLn(a, ' ', b);\n readln;\nend."}, {"source_code": "program zzz;\nvar\n a,b:int64;\nbegin\n readln(a,b);\n while (a>0)and(b>0) do\n begin\n if (a>=b*2) then \n begin\n a:=a mod (b*2);\n continue;\n end;\n if (b>=a*2) then\n begin\n b:=b mod (a*2);\n end\n else\n break;\n end;\n writeln(a,' ',b);\nend."}, {"source_code": "var a,b,n,x,hi:int64;\n i:longint;\nbegin\n read(a,b);\n while (a<>0) and (b<>0) do\n begin\n if a>=2*b then\n begin\n a:=a mod (2*b); continue;\n end;\n if b>=2*a then \n begin\n b:=b mod (2*a); continue;\n end;\n break;\n end;\n write(a,' ',b);\nend."}, {"source_code": " program z1;\nvar a,b:int64;one1,two2,three3:boolean;\n function one:boolean;\n begin\n if (a = 0) or (b = 0) then one1:=true\n else one1 := false ;\n end;\n\n function three : boolean ;\n begin\n if ( b >= 2 * a) then\n begin\n b := b mod (a * 2);\n three3 := true ;\n end\n else three3 := false ;\n end;\n function two : boolean;\n begin\n if( a >= 2 * b) then\n begin a := a mod( 2 * b);\n two2:= true;\n end\n else two2 :=false;\n end;\n\nbegin\nread(a,b);\none;\nwhile 1=1 do\n begin\n if one1 = true then begin write(a,' ',b); exit;end\n else two;\n if two2 = true then begin one; two2 := false; end\n else\n begin\n three;\n if three3 = true then begin one; three3 := false;end\n else begin write(a,' ',b); exit;end;\n end;\n end;\nend."}, {"source_code": "{$mode objfpc} {$coperators on} {$H+}\n\nuses math;\nvar a,b:int64;\nbegin \n read(a,b);\n while (a>0) and (b>0) do\n if a>=2*b then a:=a mod (2*b)\n else if b>=2*a then b:=b mod (2*a)\n else break;\n write(a,#32,b)\nend."}, {"source_code": "var\n a,b : int64;\n\n Procedure Proc(var x,y:int64);\n var\n a,b:int64;\n begin\n a:=x; b:=y;\n if (a=0) or (b=0) then exit;\n if (a<2*b) and (b<2*a) then exit;\n if (a>=2*b) and (b>0) then a:=a mod (2*b);\n if (b>=2*a) and (a>0) then b:=b mod (2*a);\n x:=a; y:=b;\n Proc(x,y);\n end;\n\nbegin\n readln(a,b);\n Proc(a,b);\n writeln(a,' ',b);\nend.\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n besk=4000000000000000000;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dott,dd:array[-10..1002,-1..1000] of int64;\n dot:array[0..30,0..30,0..5000] of longint;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss2:string;\n zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n gr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(aa,bb);\n qq:=0;\n for step:=1 to 2000 do\n begin\n inc(qq);\n if (aa=0)or(bb=0) then goto 3;\n if aa>=2*bb then begin t:=aa div (2*bb); aa:=aa-t*2*bb; goto 2; end;\n if bb>=2*aa then begin t:=bb div (2*aa); bb:=bb-t*2*aa; goto 2; end;\n\n 2: { writeln('aa= ',aa,' bb= ',bb);\n }\n end;\n\n 3: writeln(aa,' ',bb);\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "var a,b:int64;\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\n\nreadln(a,b);\n\nwhile (a>0)and(b>0) do\nif a>=2*b then a:=a mod (2*b) else if b>=2*a then b:=b mod (2*a) else break;\n\nwriteln(a,' ',b);\n///aue\n//close(input);\n//close(output);\nend.\n"}, {"source_code": "var\n a, b : int64;\nbegin\n readln(a, b);\n while (a <> 0) and (b <> 0) and ((a >= b * 2) or (b >= a * 2)) do\n begin\n if (a >= b * 2) and (b <> 0)\n then a := a mod (b * 2);\n if (b >= a * 2) and (a <> 0)\n then b := b mod (a * 2);\n end;\n writeln(a, ' ', b);\nend."}, {"source_code": "var a,b,n,x:int64;\n i:longint;\nbegin\n read(a,b);\n while (a<>0) and (b<>0) do\n begin\n if a>=2*b then\n begin\n a:=a mod (2*b); continue;\n end;\n if b>=2*a then \n begin\n b:=b mod (2*a); continue;\n end;\n break;\n end;\n write(a,' ',b);\nend.\n"}, {"source_code": "{$Coperators on}\n{$Macro on}\n{$Define long:=longint}\n\nuses math;\nconst maxn=100001;\nvar\n free: array[-100..maxn] of boolean;\n a : array[-100..maxn] of long;\n j , i , n , m ,x,y, ans , count,d ,u: int64;\n s: string;\n check : boolean;\n\nprocedure print;\n begin\n readln(n,m);\n if (n = 0) or ( m = 0) then begin write(n,#32,m); halt ;end;\n repeat\n if n>=m*2 then begin n:=n-(m*2)*(n div (m*2)); if n=0 then begin write(n,' ',m); halt; end; end;\n if m>=n*2 then begin m:=m-(n*2)*(m div (n*2)); if m=0 then begin write(n,' ',m); halt; end; end;\n inc(i);\n until (n0) and (b<>0) do\nif a>=2*b then\n a:=a mod (2*b) else\n if b>=2*a then\n b:=b mod (2*a) else\n break;\n\n writeln(a,' ',b);\n\nend."}, {"source_code": "var a,b,k : int64;\n i,dem:longint;\n \n\nbegin\n readln(a,b);\n if (a=0) or (b=0) then write(a,' ',b) else\n while (a>=2*b) or (b>=2*a) do\n begin\n if (a=0) or (b=0) then break else\n if (a<2*b) and (b<2*a) then break;\n k:=2;\n \n if a>=2*b then\n begin\n while a>=k*b do \n \n k := k*2; \n \n \n a := a - (k div 2) * b; \n if (a=0) or (b=0) then break else\n if (a<2*b) and (b<2*a) then break;\n end;\n k:=2;\n if (a=0) or (b=0) then break else\n if (a<2*b) and (b<2*a) then break;\n \n if b>=2*a then\n begin\n while (b>=(k*a)) do k:=k*2;\n b := b-(k div 2)*a;\n end;\n if (a=0) or (b=0) then break else\n if (a<2*b) and (b<2*a) then break;\n end;\nwrite(a,' ',b);\nreadln;\nend.\n"}, {"source_code": "var\na,b:qword;\nd,d1,d2,t,n,i,j,k,top,min,max,max1,x1,s: longint;\nav1,v2:double;\nsum,sum2:qword;\nalp:ansistring;\nf:integer;\n\nbegin\n read(a,b);\n f:=0;\n while (f=0) do begin\n if ((a=0)and(b=0)) then f:=1\n else if (a>=2*b)and(b>0) then a:=a mod (2*b)\n else if (b>=2*a)and(a>0) then b:=b mod (2*a)\n else f:=1;\n // writeln(a,' ',b,' ',f);\n end;\n writeln(a,' ',b);\nend."}, {"source_code": "var\nq,a,b,s,n,i,x:int64;\nbegin\nreadln(a,b);\nwhile true do begin\n if (a=0)or(b=0) then break\n else begin\n if a>=2*b then begin\n q:=a div b;\n if q mod 2= 1 then dec(q);\n a:=a-(q)*b;\n end\n else begin\n if b>=2*a then begin\n q:=b div a;\n if q mod 2= 1 then dec(q);\n b:=b-(q ) *a;\n end\n else if (a=0)or(b=0) then\n else\n break;\n end;\nend;\nend;\nwriteln(a,' ',b);\nend."}, {"source_code": "var n,m:int64;\nlabel s1,s2,s3;\nbegin\nread(n,m);\nif (n=0)or(m=0) then begin\ns1:\nif (n=0)or(m=0) then write(n,' ',m) else goto s2;\nend else if n>=2*m then begin\ns2:\nif n>=2*m then begin n:=n mod (2*m); goto s1; end else goto s3; \nend else begin\ns3:\nif m>=2*n then begin m:=m mod (2*n); goto s1; end else write(n,' ',m); end;\nend."}, {"source_code": "Program Madalina;\nuses math;\nvar a,b:int64;\nbegin\n read(a,b);\n repeat\n if(a=0) then break; if (b=0) then break;\n if (max(a,b) div 2 < min(a,b)) then break;\n if(a div 2>=b) then a:=a mod (2*b) else if (b div 2>=a) then b:=b mod (2*a);\n until(abs(a-b)0) and (b<>0) and ((a>=b*2) or (b>=a*2)) do\n if a>b then dec(a,b*2*(a div (b*2))) else\n dec(b,a*2*(b div (a*2)));\n writeln(a,' ',b);\nend.\n\n\n\n\n"}, {"source_code": "var a,b:int64;\nbegin\n//assign(output,'output.txt');rewrite(output);\n//assign(input,'input.txt');reset(input);\nread(a,b);\nwhile (a>0) and (b>0) and ((a>=2*b) or (b>=2*a)) do\nif a>=2*b then dec(a,(1+(a-2*b) div (2*b))*2*b)\nelse dec(b,(1+(b-2*a) div (2*a))*2*a);\nwrite(a,' ',b);\nend.\n"}, {"source_code": "var n,a,b:int64;\nbegin\n //assign(output,'output.txt');rewrite(output);\n //assign(input,'input.txt');reset(input);\n read(A,B);\n while (a<>0) and (b<>0) and ((a>=b*2) or (b>=a*2)) do\n if a>b then a:=a-(b*2*(a div (b*2))) else\n b:=b-(a*2*(b div (a*2)));\n writeln(a,' ',b);\nend.\n"}, {"source_code": "//B. Weird Subtraction Process\nVar\n a,b,Flag : Qword;\nProcedure Data;\nBegin\n Readln(a,b);\n While (a <> 0) and (b<>0) do\n Begin\n if (a >= 2*b) then\n Begin\n Flag:=a mod (2*b);\n if Flag = 0 then\n Begin\n a:=Flag;\n Break;\n End Else\n a:=qword(a - (2*b) * (a div (2*b)));\n End\n Else\n if (b >= 2*a) then\n Begin\n Flag:=b mod (2*a);\n if Flag = 0 then\n Begin\n b:=Flag;\n Break;\n End Else\n b:=qword(b - (2*a) * (b div (2*a)));\n End Else Break;\n End;\n Write(a,' ',b);\nEnd;\n\nBegin\n Data;\nEnd.\n"}, {"source_code": "VAR\n f1, f2: text;\n a, b: int64;\nBEGIN\n Assign(f1, ''); reset(f1);\n Assign(f2, ''); rewrite(f2);\n readln(f1, a, b);\n while (a <> 0) and (b <> 0) do\n begin\n if a >= 2*b then\n begin\n a := a mod (2*b);\n continue;\n end;\n\n if b >= 2*a then b := b mod (2*a)\n else break;\n end;\n\n writeln(f2, a, ' ', b);\n Close(f1);\n Close(f2);\nEND.\n"}, {"source_code": "var\n a, b : qword;\nbegin\n readln(a, b);\n \n while true do\n begin\n\t if (a = 0) or (b = 0) then break;\n\t if a >= 2 * b then\n\t begin\n\t\t a := a mod (2 * b);\n\t\t continue;\n\t\tend;\n\t if b >= 2 * a then\n\t begin\n\t\t b := b mod (2 * a);\n\t\t continue;\n\t\tend;\n\t break;\n\tend;\n \n writeln(a, ' ', b);\nend."}, {"source_code": "var a,b:int64;\nlabel m1,m2,m3;\nbegin\nread(a,b);\nif (a=0)or(b=0) then begin\nm1:\nif (a=0)or(b=0) then write(a,' ',b) else goto m2;\nend else if a>=2*b then begin\nm2:\nif a>=2*b then begin a:=a mod (2*b); goto m1; end else goto m3; \nend else begin\nm3:\nif b>=2*a then begin b:=b mod (2*a); goto m1; end else write(a,' ',b); end;\nend."}, {"source_code": "var\n a, b: Int64; \n\tf: boolean;\nbegin\n read(a); readln(b);\n\tf:=true;\n\twhile (a<>0) and (b<>0) and f do begin\t\n\t\tif (a>=2*b) then a:=a mod (2*b)\n\t\telse if (b>=2*a) then b:=b mod (2*a)\n\t\telse f:=false;\n\tend;\n\twriteln(a,' ',b);\nend."}, {"source_code": "var a, b : uint64;\nok : boolean;\nprocedure unu(a , b : uint64);\n begin\n if (a = 0) or (b = 0) then\n begin\n writeln(a,' ',b);\n exit;\n end else\n if (a >= 2 * b) then\n begin\n a := a mod (2*b);\n unu(a,b);\n end\n else\n begin\n if (b >= 2*a) then\n begin\n b := b mod (2*a);\n unu(a,b);\n end\n else\n begin\n writeln(a,' ',b);\n exit;\n end;\n end;\n end;\nbegin\n readln(a,b);\n unu(a,b);\n end."}, {"source_code": "var\n a, b : int64;\nbegin\n read(a, b);\n while (a <> 0) and (b <> 0) do\n if a >= 2 * b then a := a - (2 * b*(a div (2 * b)))\n else\n if b >= 2 * a then b := b - (2 * a*(b div (2 * a)))\n else break;\n write(a, ' ', b);\nend.\n "}, {"source_code": "var a,b:int64;\nbegin\nread(a,b);\nwhile (a<>0)and(b<>0) do\nif a>=b*2 then a:=a-(b*2*(a div (b*2)))\nelse if a*2<=b then b:=b-(a*2*(b div(a*2)))\nelse break;\nwrite(a,' ',b);\nend."}, {"source_code": "Program b2;\n\nVar\n i, j, n, m, w : longint;\n a, b : qword;\n t : boolean;\n\nBegin\n\n readln(a,b);\n t:=true;\n\n /////////////////////////////////////////////\n while (a<>0) and (b<>0) and t do begin\n if a>=2*b then a:=a mod (2*b)\n else if b>=2*a then b:=b mod (2*a)\n else t:=false;\n end;\n writeln(a,' ',b);\nend.\n"}, {"source_code": "Var a,b:int64;\nbegin\n read(a,b);\n while (a>0) and (b>0) do\n begin\n if (a div 2>=b) then a:=a - (a div b div 2* b*2)\n else if (b div 2>=a) then b:=b - (b div a div 2*a*2)\n else break;\n end;\n writeln(a,' ',b);\nend."}, {"source_code": "var a,b:int64;\n\nbegin\n\nreadln(a,b);\n\nwhile (a<>0) and (b<>0) do\nif a>=b*2 then a:=a mod(b*2) else\n if b>=a*2 then b:=b mod(a*2) else break;\n\nwriteln(a,' ',b);\n\nend.\n\n\n\n\n\n"}, {"source_code": "var a,b:int64; \nbegin\nreadln(a,b);\nwhile (a<>0) and (b<>0) do\n if a>=2*b then\n a:=a-(2*b*(a div (2*b)))\n else if b>=a*2 then\n b:=b-a*2*(b div (2*a))\n else break;\nwrite(a,' ',b);\nend.\n\n"}, {"source_code": "var a,b:int64;\nbegin\nread(a,b);\nwhile (a<>0)and(b<>0) do\nif a>=b*2 then a:=a-(b*2*(a div (b*2)))\nelse if a*2<=b then b:=b-(a*2*(b div(a*2)))\nelse break;\nwrite(a,' ',b);\nend."}], "negative_code": [{"source_code": "var a,b :integer;\n\nBEGIN\nread(a,b);\n\nwhile a>0 do begin\nif a>=2*b then a:=a-2*b;\nif b>=2*a then b:=b-2*a;\nif a=0 then break;\nif b=0 then break;\nif a<>0 then break;\nif b<>0 then break;\nend;\n\n\nwrite(a,' ',b);\n\nEND."}, {"source_code": "var a,b :int64;\n\nBEGIN\nread(a,b);\n\nwhile(a>0) and (b>0) do \n begin\n if a>=2*b then a:=(a mod 2*b)\n else\n if b>=2*a then b:=(b-2*a)\n else\n break;\nend;\n\n\nwrite(a,' ',b);\n\nEND.\n"}, {"source_code": "var a,b :int64;\n\nBEGIN\nread(a,b);\n\nwhile( a>0) and (b>0) do \n begin\n if a>=2*b then a:=(a mod 2*b)\n else\n if b>=2*a then b:=(b mod 2*a)\n else\n break;\nend;\n\n\nwrite(a,' ',b);\n\nEND.\n"}, {"source_code": "var a, b, c : int64;\n\nbegin\n read (a, b);\n if (b >= 2*a) then b := b mod (2*a)\n else if (a >= 2*b) then a := a mod (2*b)\n else\n begin\n write (a, b);\n exit;\n end;\n while (a <> 0) and (b <> 0) do\n begin\n if (a >= 2*b) then a := a - 2*b\n else if (b >= 2*a) then b := b - 2*a\n else break;\n end;\n write (a, ' ', b);\nend."}, {"source_code": "var a,b,c,d,e,f:int64;\nvar m:string;\nbegin\n read(a);\n read(b);\n while(1<10) do\n begin\n if(a=0) or (b=0) then\n begin\n break;\n end;\n if(a>=2*b) then\n begin\n a:=(a mod 2*b);\n continue;\n end;\n if(b>=2*a) then\n begin\n b:=(b mod 2*a);\n continue;\n end;\n break;\n end;\n write(a);\n write(' ');\n write(b);\n\n\n\n\n\nend."}, {"source_code": "type\n Tnm = array [1..2] of Int64;\n\nvar\n nm: Tnm;\n\nfunction f(ab: Tnm): Tnm;\nbegin\n If (ab[1] = 0) or (ab[2] = 0) then Exit;\n If ab[1] >= ab[2]*2 then ab[1] := ab[1] mod ab[2];\n Result := ab;\n If (ab[1] = 0) or (ab[2] = 0) then Exit;\n If ab[2] >= ab[1]*2 then ab[2] := ab[2] mod ab[1];\n If (ab[1] >= ab[2]*2) or (ab[2] >= ab[1]*2) then ab := f(ab);\n Result := ab;\nend;\n\nbegin\n ReadLn(nm[1], nm[2]);\n nm := f(nm);\n WriteLn(nm[1], ' ', nm[2]);\nend."}, {"source_code": "type\n Tnm = array [1..2] of Int64;\n\nvar\n nm: Tnm;\n\nfunction f(ab: Tnm): Tnm;\nbegin\n Result := ab;\n If (ab[1] = 0) or (ab[2] = 0) then Exit;\n If ab[1] >= ab[2]*2 then\n begin\n If (ab[1] div ab[2]) mod 2 = 0 then ab[1] := ab[1] mod ab[2] else ab[1] := ab[2] + ab[1] mod ab[2];\n end;\n Result := ab;\n If (ab[1] = 0) or (ab[2] = 0) then Exit;\n If ab[2] >= ab[1]*2 then\n begin\n If (ab[2] div ab[1]) mod 2 = 0 then ab[2] := ab[2] mod ab[1] else ab[2] := ab[1] + ab[2] mod ab[1];\n end;\n WriteLn(ab[1], ' ' , ab[2]);\n If (ab[1] >= ab[2]*2) or (ab[2] >= ab[1]*2) then ab := f(ab);\n Result := ab;\nend;\n\nbegin\n ReadLn(nm[1], nm[2]);\n nm := f(nm);\n WriteLn(nm[1], ' ', nm[2]);\nend."}, {"source_code": "var\n a,b : int64;\n\n Procedure Proc(var x,y:int64);\n var\n a,b:int64;\n begin\n a:=x; b:=y;\n if (a=0) or (b=0) then exit;\n if (a<=2*b) and (b<=2*a) then exit;\n if (a>=2*b) and (b>0) then a:=a mod (2*b);\n if (b>=2*a) and (a>0) then b:=b mod (2*a);\n x:=a; y:=b;\n Proc(x,y);\n end;\n\nbegin\n readln(a,b);\n Proc(a,b);\n writeln(a,' ',b);\nend.\n"}, {"source_code": "{$Coperators on}\n{$Macro on}\n{$Define long:=longint}\n\nuses math;\nconst maxn=100001;\nvar\n free: array[-100..maxn] of boolean;\n a : array[-100..maxn] of long;\n j , i , n , m ,x,y, ans , count,d ,u: int64;\n s: string;\n check : boolean;\n\nprocedure print;\n begin\n readln(n,m);\n if (n = 0) or ( m = 0) then begin write(n,#32,m); halt ;end;\n while (n>m*2) or ( m > n *2) do\n begin\n if n>m*2 then n:=n-2*m else \n m:=m-2*n;\n if (n = 0) or ( m = 0) then begin write(n,#32,m); halt ;end;\n end;\n write(n,#32,m);\n end;\n \nbegin\n print;\nend.\n "}, {"source_code": "Program Madalina;\nvar s:ansistring;\n i,j,aux:longint;\n ok:boolean;\nbegin\n readln(s);\n for i:=1 to length(s)-26+1 do\n begin\n ok:=true;\n aux:=96;\n for j:=i to i+25 do\n begin\n inc(aux);\n if (s[j]>chr(aux)) then\n begin\n ok:=false;\n break;\n end;\n end;\n if ok=true then\n begin\n aux:=96;\n for j:=i to i+25 do\n begin\n inc(aux);\n s[j]:=chr(aux);\n end;\n writeln(s);\n exit;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "Program Madalina;\nuses math;\nvar a,b:int64;\nbegin\n read(a,b);\n while((a<>0) and (b<>0)) or (max(a,b) div 2 < min(a,b)) do\n begin\n if (max(a,b) div 2 < min(a,b)) then break;\n if(a>b) then a:=a mod b else b:=b mod a;\n end;\n writeln(a,' ',b);\nend."}, {"source_code": "var l,r,m,a,b,k,x,e:longint;\nfunction f:boolean;\nvar m,f1,f2:longint;\nbegin\nm:=(l+r) div 2;\nif a<=m then f1:=0 else f1:=1;\nif b<=m then f2:=0 else f2:=1;\nif f1+f2=1 then f:=true else f:=false;\nend;\n\nbegin\n//assign(output,'output.txt');rewrite(output);\n//assign(input,'input.txt');reset(input);\nread(r,a,b);l:=1;x:=r;\nwhile x<>1 do begin\ninc(k);x:=x div 2;end; e:=k;\nwhile f=false do begin dec(k);\nm:=(l+r) div 2;\nif a<=m then r:=m else l:=m+1;\nend;\nif e=k then write('Final!') else write(k);\nend."}, {"source_code": "var a,b:int64;\nbegin\n//assign(output,'output.txt');rewrite(output);\n//assign(input,'input.txt');reset(input);\nread(a,b);\nwhile (b*a<>0) and ((a>=2*b) or (b>=2*a)) do\nif a>=2*b then dec(a,(1+(a-2*b) div (2*b))*2*b)\nelse dec(b,(1+(b-2*a) div (2*a))*2*a);\nwrite(a,' ',b);\nend.\n"}, {"source_code": "//B. Weird Subtraction Process\nVar\n a,b,Flag : Qword;\nProcedure Data;\nBegin\n Readln(a,b);\n While (a <> 0) and (b<>0) do\n Begin\n if (a >= 2*b) then\n Begin\n Flag:=a mod (2*b);\n if Flag = 0 then\n Begin\n a:=Flag;\n Break;\n End;\n a:=qword(a - (2*b) * a div (2*b));\n End\n Else\n if (b >= 2*a) then\n Begin\n Flag:=b mod (2*a);\n if Flag = 0 then\n Begin\n b:=Flag;\n Break;\n End;\n b:=qword(b - (2*a) * b div (2*a));\n End;\n End;\n Write(a,' ',b);\nEnd;\n\nBegin\n Data;\nEnd.\n"}, {"source_code": "VAR\n f1, f2: text;\n a, b: int64;\nBEGIN\n Assign(f1, ''); reset(f1);\n Assign(f2, ''); rewrite(f2);\n readln(f1, a, b);\n while (a <> 0) and (b <> 0) do\n begin\n a := a mod 2*b;\n b := b mod 2*a;\n end;\n\n writeln(f2, a, ' ', b);\n Close(f1);\n Close(f2);\nEND.\n"}, {"source_code": "var\n a, b, tmp : qword;\n label 1;\n \nbegin\n readln(a, b);\n \n 1:\n if (a = 0) or (b = 0) then\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend\n else if a >= 2 * b then\n begin\n\t tmp := a div b - 1;\n\t while a >= tmp * b do\n\t\tinc(tmp);\n\t dec(tmp);\n\t if a - tmp * b < b then dec(tmp);\n\t a := a - tmp * b;\n\t goto 1;\n\tend\n else if b >= 2 * a then\n begin\n\t tmp := b div a - 1;\n\t while b >= tmp * a do\n\t\tinc(tmp);\n\t dec(tmp);\n\t if b - tmp * a < a then dec(tmp);\n\t b := b - tmp * a;\n\t goto 1;\n\tend\n else\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend;\nend."}, {"source_code": "var\n a, b, tmp : qword;\n label 1;\n \nbegin\n readln(a, b);\n \n 1:\n if (a = 0) or (b = 0) then\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend\n else if a >= 2 * b then\n begin\n\t tmp := a div b;\n\t a := a - tmp * b;\n\t goto 1;\n\tend\n else if b >= 2 * a then\n begin\n\t tmp := b div a;\n\t b := b - tmp * a;\n\t goto 1;\n\tend\n else\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend;\nend."}, {"source_code": "var\n a, b, tmp : qword;\n label 1;\n \nbegin\n readln(a, b);\n \n 1:\n if (a = 0) or (b = 0) then\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend\n else if a >= 2 * b then\n begin\n\t tmp := a div b - 1;\n\t while a >= tmp * b do\n\t\tinc(tmp);\n\t dec(tmp);\n\t a := a - tmp * b;\n\t goto 1;\n\tend\n else if b >= 2 * a then\n begin\n\t tmp := b div a - 1;\n\t while b >= tmp * a do\n\t\tinc(tmp);\n\t dec(tmp);\n\t b := b - tmp * a;\n\t goto 1;\n\tend\n else\n begin\n\t writeln(a, ' ', b);\n\t exit;\n\tend;\nend."}, {"source_code": "var a, b : uint64;\nok : boolean;\nprocedure unu(a , b : uint64);\n begin\n if (a = 0) or (b = 0) then\n begin\n writeln(a,' ',b);\n exit;\n end else\n if (a >= 2 * b) then\n begin\n a := a mod 2*b;\n unu(a,b);\n end\n else\n begin\n if (b >= 2*a) then\n begin\n b := b mod 2*a;\n unu(a,b);\n end\n else\n begin\n writeln(a,' ',b);\n exit;\n end;\n end;\n end;\nbegin\n readln(a,b);\n unu(a,b);\n end."}, {"source_code": "var a,b:qword;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(a,b);\nwhile (a>0)and(b>0) do\n begin\n if a>=2*b then a:=a mod 2*b\n else if b>=2*a then b:=b mod 2*a else break;\n end;\nwrite(a,' ',b);\n\nend.\n"}], "src_uid": "1f505e430eb930ea2b495ab531274114"} {"source_code": "const MaxN = 200005;\n\nvar s: String;\n\ta: array [1..MaxN] of Longint;\n\tp: array [0..MaxN] of Longint;\n\ti, m, n, r, z: Longint;\n\nBEGIN\n\treadln (s);\n\tn := Length (s);\n\treadln (m);\n\tfor i := 1 to n do begin\n\t\ta[i] := ord (s[i]) - ord ('0');\n\tend;\n\n\tp[0] := 1;\n\tfor i := 1 to MaxN do begin\n\t\tp[i] := (p[i - 1] * 10) mod m;\n\tend;\n\n\tr := 0;\n\tfor i := 1 to n do begin\n\t\tr := (r * 10 + a[i]) mod m;\n\tend;\n\n\tz := m;\n\tfor i := 1 to n do begin\n\t\tif a[i] <> 0 then begin\n\t\t\tif z > r then z := r;\n\t\tend;\n\t\tr := (r - a[i] * p[n - 1]) mod m;\n\t\tr := (r + m) mod m;\n\t\tr := (r * 10 + a[i]) mod m;\n\tend;\n\twriteln (z);\nEND.\n", "positive_code": [{"source_code": "Uses math;\nvar cur,m,t,u,i,d10,dig,ans:longint;\ns:string;\n\nbegin\n\nreadln(s);\nreadln(m);\nd10:=1;\ncur:=0;\nt:=length(s);\nfor i:=1 to t do\nbegin\ndig:=ord(s[t+1-i])-48;\ncur:=(cur + dig*d10) mod m;\nd10:=(d10*10) mod m;\nend;\nans:=cur;\nfor i:=1 to t-1 do\nbegin\ndig:=ord(s[i])-48;\ncur:=(10*cur + dig*(m-d10)) mod m;\ncur:=(cur+dig) mod m;\ndig:=ord(s[i+1])-48;\nif (dig <> 0) then\n ans := Min(ans,cur);\nend;\nwriteln(ans);\n\nend.\n"}, {"source_code": "\nvar \n pre : array[0..200010] of int64;\n suf : array[0..200010] of int64;\n a : array[0..200010] of int64;\n pw : array[0..200010] of int64;\n n :longint;\n s : ansistring;\n m : longint;\n i,j,k : longint;\n ans,res: longint;\nbegin\n readln(s);\n n:=length(s);\n readln(m);\n pw[0]:=1;\n for i:=1 to n do begin\n a[i]:=ord(s[i])-ord('0');\n pw[i]:=(pw[i-1]*10) mod m;\n end;\n \n pre[0]:=0;\n for i:=1 to n do begin\n pre[i]:=pre[i-1]*10+a[i];\n pre[i]:=pre[i] mod m;\n end;\n suf[n+1]:=0;\n for i:=n downto 1 do begin\n suf[i]:=suf[i+1]+(a[i]*pw[n-i] mod m);\n suf[i]:=suf[i] mod m;\n end;\n ans:=m+1;\n for i:=0 to n-1 do begin\n if a[i+1]<>0 then begin\n res:=pre[i]+(suf[i+1]*pw[i] mod m);\n res:=res mod m;\n if res 0 then begin\n\t\t\tif z > r then z := r;\n\t\tend;\n\t\tr := (r - a[i] * p[n - 1]) mod m;\n\t\tr := (r + m) mod m;\n\t\tr := (r * 10 + a[i]) mod m;\n\tend;\n\twriteln (z);\nEND.\n"}, {"source_code": "var s:string;\n m,i,ans,cur:longint;\n p,q,h:array[0..300005] of int64;\nbegin\nread(s);\nread(m);\np[0]:=1;\nfor i:=1 to length(s) do p[i]:=p[i-1]*10 mod m;\nq[0]:=0;\nfor i:=1 to length(s) do q[i]:=(q[i-1]*10+ord(s[i])-48) mod m;\nh[length(s)+1]:=0;\nfor i:=length(s) downto 1 do h[i]:=(h[i+1]+(ord(s[i])-48)*p[length(s)-i]) mod m;\nans:=m;\nfor i:=1 to length(s) do if(ord(s[i])<>48) then\nbegin\n cur:=(h[i]*p[i-1]+q[i-1]) mod m;\n if cur0) and (ans>r) then ans:=r;\n \n r := r-((c*p) mod m)+m;\n r:=r mod m;\n \n r:=(r*10 + c) mod m;\n \n end;\n \n writeln(ans);\n \nend."}], "negative_code": [{"source_code": "var\ns : string;\nm,n,i,ans,c : longint;\nr, p: int64;\n\nbegin\n readln(s);\n readln(m);\n \n n := length(s);\n \n for i:=1 to n do r:=(r*10+ord(s[i])-48) mod m;\n p:=1;\n for i:=1 to n-1 do p:=(p*10) mod m;\n \n ans:=r;\n \n for i:=1 to n do begin\n c := ord(s[i])-48;\n \n if (c<>0) and (ans>r) then ans:=r;\n \n \n r := r-((c*p) mod m);\n r:=r mod m;\n \n r:=(r*10 + c) mod m;\n \n end;\n \n writeln(ans);\n \nend."}, {"source_code": "\nvar \n pre : array[0..200010] of longint;\n suf : array[0..200010] of longint;\n a : array[0..200010] of longint;\n pw : array[0..200010] of longint;\n n :longint;\n s : ansistring;\n m : longint;\n i,j,k : longint;\n ans,res: longint;\nbegin\n readln(s);\n n:=length(s);\n readln(m);\n pw[0]:=1;\n for i:=1 to n do begin\n a[i]:=ord(s[i])-ord('0');\n pw[i]:=(pw[i-1]*10) mod m;\n end;\n \n pre[0]:=0;\n for i:=1 to n do begin\n pre[i]:=pre[i-1]*10+a[i];\n pre[i]:=pre[i] mod m;\n end;\n suf[n+1]:=0;\n for i:=n downto 1 do begin\n suf[i]:=suf[i+1]+(a[i]*pw[n-i] mod m);\n suf[i]:=suf[i] mod m;\n end;\n ans:=m+1;\n for i:=0 to n-1 do begin\n if a[i+1]<>0 then begin\n res:=pre[i]+(suf[i+1]*pw[i] mod m);\n res:=res mod m;\n if res0 then if a<=b then min:=a else min:=b;\nq:=q+(min*2);\nif b<=a then a:=a-min else b:=b-min;\nif a<>0 then inc(q);\nwrite(q);\nend.", "positive_code": [{"source_code": "Program BitetheDust;\nvar a,b,c:longint; d:int64;\nbegin //assign(input,'1148A.inp'); reset(input);\n //assign(output,'1148A.out'); rewrite(output);\n readln(a,b,c);\n d:=2*c;\n if a>b then d:=d+2*b+1\n else if ab then inc(s,2*b+1);\n writeln(f2,s);\n close(f1);\n close(f2);\nend."}, {"source_code": "var a, b, c: int64;\nbegin\n readln(a, b, c);\n if a = b then writeln(a + b + 2*c)\n else if a < b then writeln(2*c + 2*a + 1)\n else writeln(2*c + 2*b + 1);\nend."}, {"source_code": "Uses Math;\nVar a,b,c,ans,k : Int64;\nbegin\n Readln(a,b,c);\n ans:=(c+Min(a,b))*2;\n k:=Min(a,b);\n a:=a-k;\n b:=b-k;\n if a>0 then ans:=ans+1;\n if b>0 then ans:=ans+1;\n\n writeln(ans);\n\n\n\n end.\n"}, {"source_code": "var a,b,c:longword;\nbegin\nread(a,b,c);\nif ab then write(2*c+2*b+1)\n else write(2*c+2*b); end;\nend.\n"}, {"source_code": "var a,b,c:longword;\nbegin\nread(a,b,c);\nif (a>b) then write(2*c+2*b+1) else\n begin\n if (ab then m:=b else m:=a;\n write(m+m+1+c+c)\n end;\nend. "}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b,c:int64;\n\nbegin\n assign(f,fi);reset(f);\n read(f,a,b,c);\n\n assign(f,fo);rewrite(f);\n if a=b then write(f,a+b+c*2);\n if a>b then write(f,b+(b+1)+c*2);\n if ab then begin\n s:=s+2*b+2*c+1;\n end\nelse if a=b then begin\n s:=s+2*b+2*c;\n end\nelse begin\n s:=s+2*a+2*c+1;\n end;\nWriteln(s);\n//readln;\nend.\n"}, {"source_code": "var\n a,b,c : longint;\n ans : int64;\nbegin\n readln(a,b,c);\n ans := c*2;\n if (b < a) then\n begin\n ans := ans+1;\n ans := ans+b*2;\n writeln(ans);\n end\n else if (a < b) then\n begin\n ans := ans+1;\n ans := ans+a*2;\n writeln(ans); \n end\n else\n writeln(ans+b+a);\nend."}, {"source_code": "var\nans1,c,a,b,aa,bb,cc,min,ans:int64;\nbegin\nreadln(a,b,c);\naa:=a;\nbb:=b;\nmin:=aa;\nif (bb0) then inc(ans);\n\naa:=a;\nbb:=b;\ncc:=c;\nmin:=aa;\nif (bb0) then inc(ans1);\nif (ans min(a, b)) or (b > min(a, b)) then inc(res);\n writeln(res);\nend."}, {"source_code": "program q1;\nvar a, b, c, count: int64;\nbegin\n readln(a, b, c);\n if a > b then\n begin\n count := b * 2;\n a := a - b;\n b := 0;\n end\n else\n begin\n count := a * 2;\n b := b - a;\n a := 0;\n end;\n count := count + c * 2;\n if (a > 0) or (b > 0) then count := count + 1;\n writeln(count);\nend.\n"}, {"source_code": "var\n n, a, b, ab, c, ans:int64;\nbegin\n readln(a, b, ab);\n ans:=ab*2;\n if a0 then inc(ans);\n if b<>0 then inc(ans);\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar a,b,c,s:int64;\nbegin\n readln(a,b,c);\n writeln((min(a,b)+c)<<1+ord(a<>b));\nend."}, {"source_code": "uses math;\nvar\n a,b,c:int64;\nbegin\n readln(a,b,c);\n if a=b then writeln(c*2+2*min(a,b))\n else writeln(c*2+2*min(a,b)+1);\nend."}, {"source_code": "var sum,a,b,c:int64;\nbegin\n read(a,b,c);\n if a=b then write(a+b+2*c)\n else begin\n if a>b then sum:=b else sum:=a;\n write(sum+sum+1+2*c);\n end;\nend. "}, {"source_code": "program dud;\nuses math;\nvar\na,b,c,ans:int64;\nbegin\n readln(a,b,c);\n a:=min(a,b+1);\n b:=min(b,a+1);\n if a<>b then ans:=-1;\n ans:=ans+max(a,b)*2;\n ans:=ans+c*2;\n writeln(ans);\nend."}, {"source_code": "Var a , b , c , kq , tmp : Int64;\n\nFunction Min(a , b : Int64):Int64;\nBegin\nIf a < b then Exit(a) else Exit(b);\nEnd;\n\nBegin\nReadln(a , b , c);\nIf a = b then Writeln(c * 2 + Min(a , b) * 2) else Writeln(c * 2 + Min(a , b) * 2 + 1);\nEnd."}, {"source_code": "const fi='';\n fo='';\nvar n,m,k:int64;\n\nprocedure docf;\nvar f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,n,m,k);\n close(f);\nend;\n\nprocedure solve;\nvar f:text; res:int64;\nbegin\n assign(f,fo); rewrite(f);\n if (n=m) then\n begin\n res:=n*2+k*2;\n writeln(f,res);\n close(f);\n exit;\n end\n else\n begin\n if (n>m) then\n begin\n res:=2*m+2*k+1;\n writeln(f,res);\n end else\n begin\n res:=2*n+2*k+1;\n writeln(f,res);\n end;\n end;\n close(f);\nend;\n\nbegin\n docf;\n solve;\nend."}, {"source_code": "uses math;\nvar x,y,z,a,s:int64;\nbegin\nreadln(x,y,z);\na:=min(x,y);\nif (x>a)or(y>a) then s:=1;\nwriteln(s+a*2+z*2);\nend."}, {"source_code": "var a,c,b:int64;\n kq:int64;\nfunction min(aa,bb:int64):int64;\nbegin\n if aa>bb then min:=bb else min:=aa;\nend;\nbegin\n readln(a,b,c);\n kq:=min(a,b);\n if a=b then kq:=kq*2+c*2\n else kq:=kq*2+1+c*2;\n writeln(kq);\nend."}, {"source_code": "uses math;\nvar a,b,c: int64;\n res: int64;\nbegin\n // assign(input,'test.inp'); reset(input);\n // assign(output,'test.out'); rewrite(output);\n read(a,b,c);\n res:=2*c+2*min(a,b);\n if a-min(a,b)>0 then inc(res)\n else if b-min(a,b)>0 then inc(res);\n write(res);\nend."}, {"source_code": "var\nr,a,b,c:int64;\nbegin\n read(a,b,c);\n if a>b then r:=2*c+2*b+1; \n if b>a then r:=2*(c+a)+1;\n if b=a then r:=2*(c+a);\n write(r);\nend."}, {"source_code": "var\n\ta, b, c: uint64;\n\nbegin\n readln(a, b, c);\n writeln(2 * c + min(a, b) + min(max(a, b), min(a, b) + 1));\n\nend.\n"}, {"source_code": "var\n c, ex, a, b, n: int64;\n\nbegin\n readln(a, b, c);\n \nif a=b then writeln((a+b)+(c*2))\nelse\nif a b) then max:=max + 2*b + 1 else max:=max + 2*a + 1;\n\nend;\n\nWriteln(max);\n\nReadln;\nEND."}, {"source_code": "program z1;\nvar a, b, c, p, n:real;\nbegin;\nread(a,b,c);\np:=abs(a-b);\nif p<>0 then p-=1;\nn:=2*c+a+b-p;\nwriteln(n);\nend."}, {"source_code": "uses\n Math;\nvar\n a, b, c: int64;\nbegin\n read(a, b, c);\n write(c * 2 + 2 * min(a, b) + ord(a <> b));\nend."}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]p2 then inc(ot);\n writeln(ot);\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}], "negative_code": [{"source_code": "var\nr,a,b,c:int64;\nbegin\n read(a,b,c);\n if a>b then r:=2*c+2*b+1 else r:=2*(c+a);\n write(r);\nend."}, {"source_code": "var\n\ta, b, c: integer;\n\nbegin\n readln(a, b, c);\n writeln(2 * c + min(a, b) + min(max(a, b), min(a, b) + 1));\n\nend.\n"}, {"source_code": "var\n c, ex, a, b: int64;\n \nbegin\nreadln(a, b, c);\nif a=b then ex:=(a+b)+(c*2);\n\nif a>b then ex:=a+(a-b)+(c*2);\n\nif a0 then p-=1;\nn:=2*c+a+b-p;\nwriteln(n);\nend."}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]p2 then inc(ot);\n writeln(ot);\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": "var a, b, c: longint;\nbegin\n readln(a, b, c);\n if a = b then writeln(a + b + 2*c)\n else if a < b then writeln(2*c + 2*a + 1)\n else writeln(2*c + 2*b + 1);\nend."}, {"source_code": "uses math;\nvar a, b, c, res : longint;\n \nbegin\n readln(a, b, c);\n res := 2 * (c + min(a, b));\n if (a > min(a, b)) or (b > min(a, b)) then inc(res);\n writeln(res);\nend."}, {"source_code": "uses math;\nvar\n a,b,c:longint;\nbegin\n readln(a,b,c);\n if a=b then writeln(c*2+2*min(a,b))\n else writeln(c*2+2*min(a,b)+1);\nend."}, {"source_code": "var a,b,c,sum:int64;\nbegin\n read(a,b,c);\n if abs(a-b)=c then sum:=a+b+2*c-1\n else sum:=a+b+2*c;\n write(sum);\nend.\n\n"}, {"source_code": "uses math;\nvar a,b,c,res: longint;\nbegin\n // assign(input,'test.inp'); reset(input);\n // assign(output,'test.out'); rewrite(output);\n read(a,b,c);\n res:=2*c+2*min(a,b);\n if a-min(a,b)>0 then inc(res)\n else if b-min(a,b)>0 then inc(res);\n write(res);\nend."}], "src_uid": "609f131325c13213aedcf8d55fc3ed77"} {"source_code": "function gcd(a,b:int64):int64;\nbegin\nif(a mod b=0)then exit(b)\nelse gcd:=gcd(b,a mod b);\nend;\nvar w,h,x,y,m:int64;\nbegin\nreadln(w,h,x,y);\nm:=gcd(x,y);\nx:=x div m;y:=y div m;\nx:=w div x;y:=h div y;\nif xo then exit(o); exit(p);\nend;\nfunction gcd(p,o:int64):int64;\nbegin\n if p>o then exit(gcd(o,p));\n if p=0 then exit(o);\n exit(gcd(o mod p,p));\nend;\nbegin\n readln(a,b,x,y);\n q:=gcd(x,y);\n x:=x div q;\n y:=y div q;\n m:=a div x;\n n:=b div y;\n writeln(min(m,n));\nend."}, {"source_code": "Uses math;\nvar a,b,x,y,tam:int64;\nfunction gcd(m,n:int64):int64;\nbegin\n if m mod n=0 then gcd:=n\n else gcd:=gcd(n,m mod n);\nend;\nbegin\n\n readln(a,b,x,y);\n tam:=gcd(x,y);\n x:=x div tam;\n y:=y div tam;\n write(min(trunc(a/x),trunc(b/y)));\nend."}, {"source_code": "var\n ans,x,y,a,b,n,m,k,p,a1,a2:int64;\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a)\n else\n gcd:=gcd(b,a mod b);\nend;\nfunction min(x,y:int64):int64;\nbegin\n if x0 do\n begin\n q:=w;w:=r;r:=q mod w;\n end;\n x:=a div(x div w);\n y:=b div(y div w);\n if x 0 do begin\n\t\ttemp := b;\n\t\tb := a mod b;\n\t\ta := temp\n\tend;\n\texit(a);\nend;\n\nvar\n\ta, b, x, y, gcdxy:qword;\nbegin\n\treadln(a, b, x, y);\n\tgcdxy:=gcd(x, y);\n\tx:=x div gcdxy;\n\ty:=y div gcdxy;\n\twriteln(min(a div x, b div y));\nend."}, {"source_code": "uses math;\nvar\n a,b,x,y,t,n,m:int64;\nfunction gcd(x,y:int64):int64;\nbegin\n if y=0 then exit(x)\n else exit(gcd(y,x mod y));\nend;\nbegin\n read(a,b,x,y);\n t:=gcd(x,y);\n write(min(a div (x div t),b div (y div t)));\nend."}, {"source_code": "uses math;\nvar\n a,b,x,y,t,n,m:int64;\nfunction gcd(x,y:int64):int64;\nbegin\n if y=0 then exit(x)\n else exit(gcd(y,x mod y));\nend;\nbegin\n read(a,b,x,y);\n t:=gcd(x,y);\n write(min(a div (x div t),b div (y div t)));\nend."}, {"source_code": "var a,b,c,d,e,f,g:int64;\nbegin\n read(a,b,c,d);\n f:=c; g:=d;\n e:=f mod g;\n while e>0 do\n begin\n f:=g;\n g:=e;\n e:=f mod g;\n end;\n c:=c div g; d:=d div g;\n if a div c0)and(b>0) do begin\n if a>b then a:=a mod b\n else\n b:=b mod a;\nend;\nx:=x div (a+b);\ny:=y div (a+b);\nans:=w div x;\nif h div yy3 then Min:=y3;\n End;\nProcedure Descend;\n Var x2,y2,r:Int64;\n Begin\n x2:=x;\n y2:=y;\n While y2<>0 do\n Begin\n r:=x2 mod y2;\n x2:=y2;\n y2:=r;\n End;\n If x2<>0 then\n Begin\n x:=x div x2;\n y:=y div x2;\n End;\n End;\nBegin\n ReadLn(a,b,x,y);\n Descend;\n WriteLn(Min(a div x, b div y));\nEnd.\n"}, {"source_code": "var\n i:longint;\n a,b,x,y,k:int64;\nfunction min(x,y:int64):int64;\n begin\n if x0\n then\n begin\n x:=x mod y;\n t:=x;\n x:=y;\n y:=t;\n gcd(x,y);\n end\n else k:=x;\n end;\nbegin\n readln(a,b,x,y);\n gcd(x,y);\n writeln(min(a div (x div k),b div (y div k)));\nend."}, {"source_code": "var\n a,b,x,y,t:int64;\nFunction min(x,y:int64):int64;\nbegin\n if x 0) do\n begin\n t:= x mod y;\n x:= y;\n y:= t;\n end;\n ucln:= x;\n end;\n\nfunction min(a,b : int64):int64;\n begin\n if (a > b) then min:= b\n else min:= a;\n end;\n\nBEGIN {main}\n //assign(input,'in.inp'); assign(output,'out.out');\n //reset(input); rewrite(output);\n readln(a,b,x,y);\n temp:= ucln(x,y);\n x:= x div temp;\n y:= y div temp;\n res:= min(a div x,b div y);\n writeln(res);\n //close(input); close(output);\nEND.\n\n"}, {"source_code": "var x,y,a,b: int64;\n\nfunction gcd(a,b: int64): int64;\nbegin\n if a mod b = 0 then exit(b) else\n exit( gcd(b, a mod b));\nend;\n\nprocedure main;\nvar t: int64;\nbegin\n t:= gcd(x,y);\n x:=x div t; y:=y div t;\n if a div x < b div y then write(a div x) else write(b div y);\nend;\n\nbegin\n readln(a,b,x,y);\n main;\nend.\n\n\n"}, {"source_code": "uses math;\nvar a,b,x,y,z:int64;\nfunction gcd(x,y:int64):int64;\nbegin\nif x mod y=0 then exit(y);\nexit(gcd(y,x mod y));\nend;\n\nbegin\nreadln(a,b,x,y);\nz:=gcd(x,y);\nx:=x div z; y:=y div z;\nwriteln(min(a div x,b div y));\nend."}, {"source_code": "var a,b,x,y,z,i:int64;\n\nfunction gcd(m, n: int64): int64;\n var modulo: int64;\n begin\n modulo := m mod n;\n if modulo = 0 then\n gcd := n\n else\n gcd := gcd (n, modulo)\n end;\n\n\n\n\n\nbegin\nreadln(a,b,x,y);\nz:=gcd(x,y);\n\nx:=x div z; \ny:=y div z;\n\nif (a div x)>(b div y) then writeln(b div y) else writeln(a div x);\n\nend."}, {"source_code": "{CF1041B}\nvar\na,b,x,y,t:int64;\nfunction min(x,y:int64):int64;\n begin\n if x0)and(y>0)do\n begin\n x:=x mod y;\n if (x>0)and(y>0) then\n y:=y mod x;\n end;\n if x=0 then t:=y;\n if y=0 then t:=x;\n c:=c div t;\n d:=d div t;\n if(a div c0) and (yy<>0) do\n if xx y then\n x := x mod y\n else\n y := y mod x;\n until (x = 0) or (y = 0);\n nod := x + y;\nx:=x1 div nod;\ny:=y1 div nod;\nk1:=a div x;\nk2:=b div y;\nif k1>k2 then writeln (k2) else writeln (k1);\nend."}, {"source_code": "var a,b,x,y,x1,y1:int64;\nbegin\n readln(a,b,x1,y1);\n x:=x1;y:=y1;\n while x1*y1<>0 do\n if x1>y1 then x1:=x1 mod y1\n else y1:=y1 mod x1;\n x:=x div (x1+y1);\n y:=y div (x1+y1);\n writeln(min(a div x,b div y));\nend."}, {"source_code": "\nvar\na,b,m,n,nod,x,y,res:int64;\n\n\nbegin\nread(a,b,x,y); \n\nm:=x; n:=y;\nwhile (m<>0) and (n<>0) do\nif m>n then m:=m mod n else n:=n mod m;\nnod:=m+n;\nm:=x div nod;\nn:=y div nod;\nres:=min(a div m, b div n);\nwriteln(res);\nend."}, {"source_code": "var a,b,x,y,x1,y1:int64;\nbegin\n readln(a,b,x1,y1);\n x:=x1;y:=y1;\n while x1*y1<>0 do\nif x1>y1 then x1:=x1 mod y1\n else y1:=y1 mod x1;\n x:=x div (x1+y1);\n y:=y div (x1+y1);\n writeln(min(a div x,b div y));\nend."}, {"source_code": "var a,b,x,y,x1,y1,r: int64;\nbegin\nreadln(a,b,x,y);\nx1:=x;\ny1:=y;\nwhile (x1<>0)and(y1<>0) do\n if x1>y1 then x1:= x1 mod y1 else y1:= y1 mod x1;\nx:= x div (x1+y1);\ny:= y div (x1+y1);\nwriteln(min(a div x,b div y));\nend."}, {"source_code": "function NODchisel(a, b: int64): int64;\nvar q,r: int64;\nbegin\n q:= a div b;\n r:=a-q*b; \n while r<>0 do\n begin\n a:=b;\n b:=r;\n q:= a div b;\n r:=a-q*b;\n end;\n NODchisel:=b;\nend;\nvar\n min,nod,a,b,x,y:int64;\nbegin\n readln(a,b,x,y);\n nod:=NODchisel(x,y);\n x:=x div nod;\n y:=y div nod;\n a:=a div x;\n b:=b div y;\n min:=a;\n if b0) and (n<>0) do\nif m>n then m:=m mod n else n:=n mod m;\nnod:=m+n;\nm:=x div nod;\nn:=y div nod;\nres:=min(a div m, b div n);\nwriteln(res);\nend."}, {"source_code": "\n const eps=1e-11; besk=8000000000000000000;\n modul=1000000007;\n label 1,2,3,4,11;\n type\n mas=array [-10000..1500000] of int64; point=record x,y,z:extended;end;\n point1=^point;\n zap=record x,y,z :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var start,znach,aa,bb,cc,dist,pos1,pos2,q2,nn,mm,pos,ii1,jj,r,ot,q1,aa2,bb2,aa1,bb1,t,t0,t1,p,kol,newdl,dl,kk,t2,m1,n1,pp,px,py,n2,dloch,x0,v1,v2,p3,p4,t4,t5,t6,t3,ost,q,h,n,qq,p1,p2,y0,s1,s2,m,imax,smin,besk1:int64;\n ii,i1,j1,step,k,i,j:longint;\n ch:char;\n ppoint3,ppoint2,ppoint1:point;\n dd:array[-1..120,-1..1100] of int64;\n x,y,z:array[-10..2500000] of extended;\n zzz: array[-10..2500000] of int64;\n sum,diam,ll,rr,tt,maxdd,h1,h2:extended;\n sv:array[-10..200,-10..200] of boolean;\n dx,otvet,d,dmin,xx,yy,dd1,dd2,newoch,ugol,s,place,xnew,och,fact, a1,bl,br,c,a,b:array[-2000..6000000] of int64;\n per,materdec,mater:array[-100..150,-1..150] of point;\n polet:array[-1..150] of point;\n ss,ss1,ss2 :string;\n name1,name:array[-1000..1000000] of char;\n gr:array[-100..5000,-100..5000] of boolean;\n ssot:array[-100..10000] of char;\n ppp:zap;\n pp1,pp2,pole,pole1:array[-10..140,-10..140] of int64;\n ppol:array[-1..51,-1..51,0..2550] of char;\n prost, zan,marked:array[-1000001..1100000] of boolean;\n sss1,sp,sss,maxpr:array[-10..2100000] of string;\n ccc,aaa,bbb,tt1,tt2,w,mm1,nn1,hh,ttt, l, aanew,v0,s0:extended;\n { z,y,x:array[-1..300,-10..1000] of int64;\n }\n prvin,prlost,prob,x1,y1, xxx,yyy:array[-1..1000000] of extended;\n otkl,xxnew, ee,yot:double;\n flag3,flag4,flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n { function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend; }\n\nfunction degg(modul,a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(modul,a,k-1)*a) mod modul else\n begin p:=degg(modul,a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\n\n\nbegin\n\n { assign (input, 'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n\n\n\n read(p1,p2,t1,t2);\n p:=nod(t1,t2);\n t1:=t1 div p;\n t2:=t2 div p;\n writeln(min(p1 div t1,p2 div t2 ));\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\n\n\nend.\n"}], "negative_code": [{"source_code": "const\n fin='BBuyingTV.inp';fon='BBuyingTV.out';\nvar a,b,x,y,k:int64;\n\nfunction ucln(x,y:int64):int64;\nvar tg:int64;\nbegin\nif xx) and (b>y) then begin\nk1:=a / x;\nk2:=b / y;\n if k1>k2 then \n count:=round(k2)\n else count:= round(k1);\n end;\n if (ak2 then \n count:=round(k2)\n else count:= round(k1);\n end; \n if (a=x) and (b=y) then \n count:=1;\nif ((ay)) or ((a>x) and (b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n { function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend; }\n\nfunction degg(modul,a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(modul,a,k-1)*a) mod modul else\n begin p:=degg(modul,a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\n\n\nbegin\n{ assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n\n read(n);\n for i:=1 to n do read(a[i]);\n read(m);\n for i:=1 to m do read(b[i]);\n for i:=1 to n do x[i]:=x[i-1]+a[i];\n for i:=1 to m do y[i]:=y[i-1]+b[i];\n if x[n]<>y[m] then begin write(-1); goto 1; end;\n y[m+1]:=besk;\n for i:=1 to n do\n begin\n if y[pos]=x[i];\n if x[i]=y[pos] then inc(ot);\n\n\n end;\n\n writeln(ot);\n\n\n\n\n\n\n\n\n 1: close(output);\n\n\nend.\n\n"}], "src_uid": "907ac56260e84dbb6d98a271bcb2d62d"} {"source_code": "uses math;\nvar\n n,i,j,p,res,t,c: longint;\n ch: char;\n r1,r2: ansistring;\n s,a,b,d: array[0..9] of longint;\nfunction kt(a: longint): char;\n begin\n exit(char(a+ord('0')));\n end;\nbegin\n// assign(input,'aaa.inp');reset(input);\n// assign(output,'aaa.out');rewrite(output);\n\n n := 0;\n while not eoln do begin\n inc(n);\n read(ch);\n inc(s[ord(ch)-ord('0')]);\n end;\n\n res := s[0];\n p := 0;\n for i:=1 to 5 do if (s[i]>0) and (s[10-i]>0) then begin\n for j:=0 to 9 do begin\n a[j] := s[j];\n b[j] := s[j];\n end;\n dec(a[i]);\n dec(b[10-i]);\n t := 1;\n for j:=0 to 9 do begin\n c := min(a[j], b[9-j]);\n inc(t, c);\n dec(a[j],c);\n dec(b[9-j],c);\n end;\n t := t + min(a[0],b[0]);\n\n if t>res then begin\n res := t;\n p := i;\n end;\n end;\n\n i := p;\n for j:=0 to 9 do begin\n a[j] := s[j];\n b[j] := s[j];\n end;\n if p>0 then begin\n dec(a[i]);\n dec(b[10-i]);\n for j:=0 to 9 do begin\n c := min(a[j], b[9-j]);\n dec(a[j],c);\n dec(b[9-j],c);\n d[j] := c;\n end;\n\n r1 := kt(p);\n r2 := kt(10-p);\n for i:=0 to 9 do for j:=1 to d[i] do begin\n r1 := kt(i) + r1;\n r2 := kt(9-i) + r2;\n end;\n end;\n\n c := min(a[0],b[0]);\n dec(a[0],c);\n dec(b[0],c);\n for i:=1 to c do begin\n r1 := r1 + '0';\n r2 := r2 + '0';\n end;\n for i:=0 to 9 do begin\n for j:=1 to a[i] do r1 := kt(i)+r1;\n for j:=1 to b[i] do r2 := kt(i)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend.", "positive_code": [{"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,M+,C+,H+,O-}\n{R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\ti, ls, mx, l, r, cur, x, y, kk, j, zz : longint;\n\ta, b, c : array[0..10] of longint;\n\tp, q : array[0..100010] of longint;\n\ts : string;\n\nfunction count(x, y : longint) : longint;\n\nvar\n\ti : longint;\n\nbegin\n\tdec(b[x]);\n\tdec(c[y]);\n\tresult := 0;\n\tfor i := 0 to 9 do\n\t\tinc(result, min(b[i], c[9 - i]));\n\tinc(b[x]);\n\tinc(c[y]);\nend;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\treadln(s);\n\tfillchar(a, sizeof(a), 0);\n\tls := length(s);\n\tfor i := 1 to ls do\n\t\tinc(a[ord(s[i]) - 48]);\n\tb := a;\n\tc := a;\n\tl := -1;\n\tr := -1;\n\tmx := -1;\n\tfor i := 1 to 5 do\n\t\tif (a[i] > 0) and (a[10 - i] > 0) then begin\n\t\t\tcur := count(i, 10 - i);\n\t\t\tif cur > mx then begin\n\t\t\t\tmx := cur;\n\t\t\t\tl := i;\n\t\t\t\tr := 10 - i;\n\t\t\tend;\n\t\tend;\n\tx := 1;\n\tif l > -1 then begin\n\t\tdec(b[l]);\n\t\tdec(c[r]);\n\t\tp[x] := l;\n\t\tq[x] := r;\n\t\tinc(x);\t\n\tend;\n\tfor i := 0 to 9 do begin\n\t\tkk := min(b[i], c[9 - i]);\n\t\tfor j := 1 to kk do begin\n\t\t\tp[x] := i;\n\t\t\tq[x] := 9 - i;\n\t\t\tinc(x);\t\n\t\tend;\n\t\tdec(b[i], kk);\n\t\tdec(c[9 - i], kk);\n\tend;\n\tzz := min(b[0], c[0]);\n\ty := x;\n\tfor i := 1 to 9 do begin\n\t\tfor j := 1 to b[i] do begin\n\t\t\tp[x] := i;\n\t\t\tinc(x);\n\t\tend;\n\t\tfor j := 1 to c[i] do begin\n\t\t\tq[y] := i;\n\t\t\tinc(y);\n\t\tend;\n\tend;\n\tfor i := ls - zz downto 1 do\n\t\twrite(p[i]);\n\tfor i := 1 to zz do\n\t\twrite(0);\n\twriteln;\n\tfor i := ls - zz downto 1 do\n\t\twrite(q[i]); \n\tfor i := 1 to zz do\n\t\twrite(0);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 100010;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n n, m, ansz, ansf, ansk: int;\n ansa, ansb: array[0..maxn] of int;\n c, b, a: array[0..11] of int;\n\nprocedure run;\nvar\n i, j, k, t, d: int;\n ch: char;\nbegin\n fillchar(c, sizeof(c), 0);\n while not seekeoln do begin\n read(ch);\n inc(c[ord(ch) - ord('0')]);\n end;\n\n ansk := -1;\n ansz := 0;\n ansf := 0;\n\n for i := 1 to 9 do\n for j := 0 to c[0] do begin\n t := j + 1;\n\n a := c;\n b := c;\n dec(a[0], j);\n dec(b[0], j);\n\n if a[i] = 0 then\n continue;\n dec(a[i]);\n\n if b[10 - i] = 0 then\n continue;\n dec(b[10 - i]);\n\n for k := 0 to 9 do begin\n d := min(a[k], b[9 - k]);\n\n inc(t, d);\n\n dec(a[k], d);\n dec(b[9 - k], d); \n end;\n\n if (ansk < t) then begin\n ansk := t;\n ansz := j;\n ansf := i;\n end;\n end;\n\n if (ansk = -1) then begin\n for i := 9 downto 0 do\n for j := 1 to c[i] do\n write(i);\n writeln;\n for i := 9 downto 0 do\n for j := 1 to c[i] do\n write(i);\n writeln;\n exit;\n end; \n\n n := ansz;\n m := ansz;\n\n a := c;\n b := c;\n\n dec(a[0], ansz);\n dec(b[0], ansz);\n\n for i := 1 to ansz do begin\n ansa[i] := 0;\n ansb[i] := 0;\n end;\n\n inc(n);\n ansa[n] := ansf;\n dec(a[ansf]);\n inc(m);\n ansb[m] := 10 - ansf;\n dec(b[10 - ansf]);\n\n for k := 0 to 9 do begin\n d := min(a[k], b[9 - k]);\n\n dec(a[k], d);\n dec(b[9 - k], d);\n\n for i := 1 to d do begin\n inc(n);\n ansa[n] := k;\n end;\n for i := 1 to d do begin\n inc(m);\n ansb[m] := 9 - k;\n end;\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do begin\n inc(n);\n ansa[n] := i;\n end;\n\n for i := 0 to 9 do\n for j := 1 to b[i] do begin\n inc(m);\n ansb[m] := i;\n end;\n\n for i := n downto 1 do\n write(ansa[i]);\n writeln;\n for i := m downto 1 do\n write(ansb[i]);\n writeln;\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Int64;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(o: Longint);\nvar s1, s2: String;\n i, j, x: Longint;\nBegin\n if o <> -1 then begin\n if (o = 5) then begin\n dec(a[o]);\n dec(b[o]);\n s1 := chr(o + 48);\n s2 := chr(o + 48);\n end\n else begin\n dec(a[o]);\n dec(b[10 - o]);\n s1 := chr(o + 48);\n s2 := chr(10 - o + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n end;\n\n x := a[0];\n if b[0] < x then\n x := b[0];\n a[0] := a[0] - x;\n b[0] := b[0] - x;\n for i := 1 to x do begin\n s1 := s1 + chr(48);\n s2 := s2 + chr(48);\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\nEnd;\n\nprocedure src;\nvar x, sum, j, x1, x2: Longint;\n q: Boolean;\nBegin\n sum := 1;\n x1 := a[0];\n x2 := b[0];\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n if j = 0 then\n x1 := x1 - x;\n if j = 9 then\n x2 := x2 - x;\n sum := sum + x;\n end;\n x := x1;\n if x2 < x then\n x := x2;\n sum := sum + x;\n\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n max := 0;\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n w(best);\nEnd."}, {"source_code": "program D;\n\n{$APPTYPE CONSOLE}\nuses Math, SysUtils;\nvar s,s1,s2: string;\n a,b,cnt: array[0..9]of integer;\n i,j,n,ta: integer;\n\nprocedure check(x,y: integer);\nvar tt,i,j: integer;\n aa,bb: array[0..9]of integer;\nbegin\n if (a[x]<1)or(b[y]<1)then exit;\n for i:=0 to 9 do begin\n aa[i]:=a[i];\n bb[i]:=b[i];\n end;\n tt:=1;\n dec(aa[x]);dec(bb[y]);\n for i:=0 to 9 do begin\n j:=min(aa[i],bb[9-i]);\n inc(tt,j);\n dec(aa[i],j);dec(bb[9-i],j);\n end;\n j:=min(aa[0],bb[0]);\n inc(tt,j);\n if (tt>ta)then begin\n s1:=inttostr(x);\n s2:=inttostr(y);\n ta:=tt;\n end;\nend;\nbegin\n s1:='';s2:='';\n readln(s);\n n:=length(s);\n for i:=0 to 9 do begin\n a[i]:=0;\n b[i]:=0;\n end;\n for i:=1 to n do begin\n inc(a[ord(s[i])-ord('0')]);\n inc(b[ord(s[i])-ord('0')]);\n end;\n ta:=0;\n check(2,8);\n check(3,7);\n check(4,6);\n check(5,5);\n check(9,1);\n if (s1<>'')then begin\n dec(a[ord(s1[1])-ord('0')]);\n dec(b[ord(s2[1])-ord('0')]);\n end;\n for i:=0 to 9 do begin\n cnt[i]:=min(a[i],b[9-i]);\n a[i]:=a[i]-cnt[i];\n b[9-i]:=b[9-i]-cnt[i];\n end;\n ta:=min(a[0],b[0]);\n a[0]:=a[0]-ta;b[0]:=b[0]-ta;\n for i:=0 to 9 do\n for j:=1 to a[i]do\n write(i);\n for i:=0 to 9 do\n for j:=1 to cnt[i]do\n write(i);\n write(s1);\n for i:=1 to ta do write(0);\n writeln;\n for i:=0 to 9 do\n for j:=1 to b[i]do\n write(i);\n for i:=9 downto 0 do\n for j:=1 to cnt[9-i]do\n write(i);\n write(s2);\n for i:=1 to ta do write(0);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,M+,C+,H+,O-}\n{R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n SysUtils, Math;\n\nvar\n i, ls, mx, l, r, cur, x, y, kk, j, zz : longint;\n a, b, c : array[0..10] of longint;\n p, q : array[0..100010] of longint;\n s : string;\n\nfunction count(x, y : longint) : longint;\n\nvar\n i : longint;\n\nbegin\n dec(b[x]);\n dec(c[y]);\n result := 0;\n for i := 0 to 9 do\n inc(result, min(b[i], c[9 - i]));\n inc(b[x]);\n inc(c[y]);\nend;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF}\n readln(s);\n fillchar(a, sizeof(a), 0);\n ls := length(s);\n for i := 1 to ls do\n inc(a[ord(s[i]) - 48]);\n b := a;\n c := a;\n l := -1;\n r := -1;\n mx := -1;\n for i := 1 to 5 do\n if (a[i] > 0) and (a[10 - i] > 0) then begin\n cur := count(i, 10 - i);\n if cur > mx then begin\n mx := cur;\n l := i;\n r := 10 - i;\n end;\n end;\n x := 1;\n if l > -1 then begin\n dec(b[l]);\n dec(c[r]);\n p[x] := l;\n q[x] := r;\n inc(x); \n end;\n for i := 0 to 9 do begin\n kk := min(b[i], c[9 - i]);\n for j := 1 to kk do begin\n p[x] := i;\n q[x] := 9 - i;\n inc(x); \n end;\n dec(b[i], kk);\n dec(c[9 - i], kk);\n end;\n zz := min(b[0], c[0]);\n y := x;\n for i := 1 to 9 do begin\n for j := 1 to b[i] do begin\n p[x] := i;\n inc(x);\n end;\n for j := 1 to c[i] do begin\n q[y] := i;\n inc(y);\n end;\n end;\n for i := ls - zz downto 1 do\n write(p[i]);\n for i := 1 to zz do\n write(0);\n writeln;\n for i := ls - zz downto 1 do\n write(q[i]); \n for i := 1 to zz do\n write(0);\nend."}, {"source_code": "{$apptype console}\nuses SysUtils;\n\nvar s : string;\n c,c2 : array[0..9] of integer;\n\nfunction min(a,b : integer) : integer;\nbegin\n result := a;\n if b < a then result := b;\nend;\n\nfunction GetCnt : integer;\nvar i: integer;\nbegin\n result := 0;\n for i := 0 to 9 do begin\n inc(result, min(c[i], c2[9-i]) );\n end;\nend;\n\nvar i,j,max, imax, t,zc : integer;\n good: array[1..100001] of integer;\n gl : integer;\nbegin\n{ reset( input, 'in.txt' );}\n {}\n readln( s );\n fillchar( c,sizeof(c), 0 );\n for i := 1 to length(s) do\n if s[i] in ['0'..'9'] then inc( c[ ord(s[i])-ord('0') ] );\n move(c,c2,sizeof(c));\n{}\n max := -1; imax:= -1;\n for i := 1 to 5 do begin\n if (c[i] > 0) and (c2[10-i]>0) then begin\n dec(c[i]); dec(c2[10-i]);\n t := GetCnt();\n if t > max then begin imax := i; max :=t; end;\n inc(c[i]); inc(c2[10-i]);\n end;\n end;\n{}\n if imax = -1 then begin\n for i := 1 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to c[0] do write(0);\n{}\n writeln;\n for i := 1 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to c[0] do write(0);\n end else begin\n dec(c[imax]); dec(c2[10-imax]);\n gl := 0;\n for i := 0 to 9 do begin\n t := min(c[i], c2[9-i]);\n for j := 1 to t do begin\n inc(gl);\n good[gl] := i;\n dec(c[i]);\n dec(c2[9-i]);\n end;\n end;\n{}\n zc := min(c[0], c2[0] );\n dec(c[0],zc); dec(c2[0],zc);\n for i := 0 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to gl do write( good[i] );\n write(imax);\n for i := 1 to zc do write(0);\n writeln;\n{}\n for i := 0 to 9 do for j := 1 to c2[i] do write(i);\n for i := 1 to gl do write( 9-good[i] );\n write(10-imax);\n for i := 1 to zc do write(0);\n end;\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n\nconst eps=0.000000001; nnn=200000;\nlabel 1,2,3;\ntype int64=longint;\nmas=array[0..20000] of longint; mmas=^mas;\nvar maxkol,s,kk,kp,num,mmax,n1,h,t,imin,mmin,p,step,jmax,n,k,pmax:longint;\n flag,flag1:boolean; pl,mm,aaa,kolraz,otmax,ot,m,j2:int64;\n i,j:longint; ch:char;\n ss:string;\npp,ppp :mas;\n ugol,vp,sot,vr,vb:double;\na,b,c,ot1,ot2:array[-10..500000] of longint;\nopt,aa:array[0..1000,0..1000] of longint;\n new1,new2, ss1,ss2:string;\n otv:array[-10..800,-10..800] of int64 ;\n l,r,spost:array [0..1000] of longint;\n function min(a,b:int64):int64;\nbegin min:=a;if ba then max:=b; end;\n\n\n{ function per(num:longint): mmas; var i,j:longint;\n pp,ppp:array[0..10] of longint;\nbegin dec(num);\n for i:=1 to n-1 do begin pp[i]:=num div fac[n-i]; num:=num mod fac[n-i];end;\n for i:=1 to n do write(pp[i],' '); writeln;\n\nend; }\n function prr(p:longint):boolean; var i,j:longint; flag:boolean;\n begin\n flag:=true;\n for i:=2 to trunc(sqrt(p)+eps) do if p mod i=0 then flag:=false;\n prr:=flag; if (p=1)or(p=0) then prr:=false;\n end;\n\n\n begin {assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);\n }\nwhile not eof do begin read(ch); inc(a[ord(ch)-48]); end;\n\n{for i:=0 to 9 do write(a[i],' '); writeln; }\nfor i:=0 to 10 do begin b[i]:=a[i]; c[i]:=a[i]; end;\nfor i:=0 to 9 do n:=n+a[i];\n for p:=0 to c[0] do {p - kol 0 na konze}\n begin for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=c[0]-p; b[0]:=c[0]-p;\n for j:=1 to 9 do {j - poslednyaya zifra pered 0 }\n if (a[j]>0)and(b[10-j]>0) then\n\n begin\n for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=c[0]-p; b[0]:=c[0]-p;\n dec(a[j]); dec(b[10-j]);\n t:=p+1;\n {writeln;writeln;\n for i:=0 to 9 do write(a[i],' '); writeln;\n for i:=0 to 9 do write(b[i],' '); writeln; }\n for i:=0 to 9 do t:=t+min(a[i],b[9-i]);\n {writeln(p,' nuley ',j,'+',10-j,' and ',t-p-1,' devyatok'); }\n if t>maxkol then begin maxkol:=t; jmax:=j;pmax:=p; end;\n end;\n\n\n\n end;\n\n{ writeln(maxkol,' ',jmax,' ',pmax); writeln;\n}\nif maxkol>0 then\n begin\n for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=a[0]-pmax;b[0]:=b[0]-pmax;\n for i:=1 to pmax do begin ot1[i]:=0;ot2[i]:=0; end;\n ot1[pmax+1]:=jmax; ot2[pmax+1]:=10-jmax;\n dec(a[jmax]);dec(b[10-jmax]); pl:=pmax+1;\n\n begin\n for j:=0 to 9 do for i:=1 to min(a[j],b[9-j]) do\n begin inc(pl);ot1[pl]:=j;ot2[pl]:=9-j; end;\n end;\n for j:=0 to 9 do\n for i:=1 to a[j]-min(a[j],b[9-j]) do\n begin inc(pl); ot1[pl]:=j; end; pl:=maxkol;\n for j:=0 to 9 do\n for i:=1 to b[9-j]-min(a[j],b[9-j]) do\n begin inc(pl); ot2[pl]:=9-j; end;\n for i:=n downto 1 do write(ot1[i],''); writeln;\n for i:=n downto 1 do write(ot2[i],''); writeln;\n end else\n begin for i:=9 downto 0 do for j:=1 to c[i] do write(i); writeln;\n for i:=9 downto 0 do for j:=1 to c[i] do write(i); writeln;\n end;\n\n 1: close (output);\nend.\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses math;\nvar\n s:string;\n a,b1,b2,cr1,cr2:array[0..100001] of integer;\n c1,d1,c2,d2:array[0..9] of integer;\n nlm,z,sm,nl,mx,f,j,l,k,error,i,n:integer;\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt');}\n\n readln(s);\n\n n:=length(s);\n a[0]:=n;\n\n Fillchar(c1,sizeof(c1),0);\n Fillchar(c2,sizeof(c2),0);\n\n For i:=1 to n do\n begin\n val(s[i],a[i],error);\n inc(c1[a[i]]);\n inc(c2[a[i]]);\n end;\n\n mx:=-1;\n nlm:=0;\n\n For i:=1 to c1[0] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=0;\n cr2[cr1[0]]:=0;\n end;\n\n For i:=1 to 9 do\n For j:=1 to 9 do\n begin\n cr1[0]:=c1[0];\n d1:=c1;\n d2:=c2;\n nl:=c2[0];\n d1[0]:=0;\n d2[0]:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n inc(cr1[0]);\n dec(d1[i]);\n dec(d2[j]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n inc(nl);\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n z:=min(d1[0],d2[0]);\n d1[0]:=d1[0]-z;\n d2[0]:=d2[0]-z;\n nl:=nl+z;\n If nl>mx then\n begin\n nlm:=z;\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n\n For i:=1 to 9 do\n For j:=1 to 9 do\n begin\n cr1[0]:=0;\n d1:=c1;\n d2:=c2;\n nl:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n dec(d1[i]);\n dec(d2[j]);\n inc(cr1[0]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n inc(nl);\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n z:=min(d1[0],d2[0]);\n d1[0]:=d1[0]-z;\n d2[0]:=d2[0]-z;\n nl:=nl+z;\n If nl>mx then\n begin\n nlm:=z;\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n For i:=b1[0] downto 1 do write(b1[i]);\n For i:=1 to nlm do write(0);\n writeln;\n\n For i:=b2[0] downto 1 do write(b2[i]);\n For i:=1 to nlm do write(0);\n writeln;\n\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nFunction Min(a,b:Integer):Integer;\nBegin\n If a<=b Then Min:=a\n Else Min:=b;\nEnd;\nVar\n a,p,r,x1,x2:Array[0..9] of Integer;\n i,j,f,n:Integer;\n c,t:Char;\n s1,s2:String;\nBegin\n For i:=0 To 9 Do a[i]:=0;\n While not SeekEof Do Begin\n Read(c);\n i:=strtoint(c);\n a[i]:=a[i]+1;\n End;\n For i:=0 To 9 Do Begin\n x1[i]:=a[i];\n x2[i]:=a[i];\n End;\n For i:=0 To 9 Do p[i]:=Min(a[i],a[9-i]);\n For i:=0 To 9 Do r[i]:=a[i]-p[i];\n s1:='';\n s2:='';\n While r[0]>0 Do Begin\n s1:=s1+'0';\n s2:=s2+'0';\n r[0]:=r[0]-1;\n a[0]:=a[0]-1;\n x1[0]:=x1[0]-1;\n x2[0]:=x2[0]-1;\n End;\n f:=0;\n For i:=1 To 5 Do\n If (r[i]>0) and (r[10-i]>0) Then Begin\n f:=1;\n s1:=s1+inttostr(i);\n s2:=s2+inttostr(10-i);\n x1[i]:=x1[i]-1;\n x2[10-i]:=x2[10-i]-1;\n Break;\n End;\n If f=0 Then Begin\n For i:=1 To 5 Do\n If (a[i]>0) and (a[10-i]>0) Then Begin\n s1:=s1+inttostr(i);\n s2:=s2+inttostr(10-i);\n x1[i]:=x1[i]-1;\n x2[10-i]:=x2[10-i]-1;\n Break;\n End;\n End;\n For i:=0 To 9 Do\n While (x1[i]>0) and (x2[9-i]>0) Do Begin\n s1:=s1+inttostr(i);\n s2:=s2+inttostr(9-i);\n x1[i]:=x1[i]-1;\n x2[9-i]:=x2[9-i]-1;\n End;\n For i:=0 To 9 Do\n For j:=1 To x1[i] Do s1:=s1+inttostr(i);\n For i:=0 To 9 Do\n For j:=1 To x2[i] Do s2:=s2+inttostr(i);\n n:=length(s1);\n For i:=1 To n div 2 Do Begin\n t:=s1[i];\n s1[i]:=s1[n+1-i];\n s1[n+1-i]:=t;\n t:=s2[i];\n s2[i]:=s2[n+1-i];\n s2[n+1-i]:=t;\n End;\n WriteLn(s1);\n Write(s2);\nEnd.\n"}, {"source_code": "uses\n SysUtils, Math;\n\nvar\n i, ls, mx, l, r, cur, x, y, kk, j, zz : longint;\n a, b, c : array[0..10] of longint;\n p, q : array[0..100010] of longint;\n s : string;\n\nfunction count(x, y : longint) : longint;\n\nvar\n i : longint;\n\nbegin\n dec(b[x]);\n dec(c[y]);\n result := 0;\n for i := 0 to 9 do\n inc(result, min(b[i], c[9 - i]));\n inc(b[x]);\n inc(c[y]);\nend;\n\nbegin\n readln(s);\n fillchar(a, sizeof(a), 0);\n ls := length(s);\n for i := 1 to ls do\n inc(a[ord(s[i]) - 48]);\n b := a;\n c := a;\n l := -1;\n r := -1;\n mx := -1;\n for i := 1 to 5 do\n if (a[i] > 0) and (a[10 - i] > 0) then begin\n cur := count(i, 10 - i);\n if cur > mx then begin\n mx := cur;\n l := i;\n r := 10 - i;\n end;\n end;\n x := 1;\n if l > -1 then begin\n dec(b[l]);\n dec(c[r]);\n p[x] := l;\n q[x] := r;\n inc(x); \n end;\n for i := 0 to 9 do begin\n kk := min(b[i], c[9 - i]);\n for j := 1 to kk do begin\n p[x] := i;\n q[x] := 9 - i;\n inc(x); \n end;\n dec(b[i], kk);\n dec(c[9 - i], kk);\n end;\n zz := min(b[0], c[0]);\n y := x;\n for i := 1 to 9 do begin\n for j := 1 to b[i] do begin\n p[x] := i;\n inc(x);\n end;\n for j := 1 to c[i] do begin\n q[y] := i;\n inc(y);\n end;\n end;\n for i := ls - zz downto 1 do\n write(p[i]);\n for i := 1 to zz do\n write(0);\n writeln;\n for i := ls - zz downto 1 do\n write(q[i]); \n for i := 1 to zz do\n write(0);\nend. "}, {"source_code": " const MAX_N = 100010;\n\n var fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf,r0:longint;\n c,c2:array[0..9] of longint;\n\n\n function min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\n procedure update(x,y:longint);\n begin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\n end;\n\n procedure solve(x,y,z:longint);\n var i,f:longint;\n begin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n dec(c[0],z); dec(c2[0],z);\n f:=z;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n f:=f+min(c[0]-min(c[0],c2[9]),c2[0]-min(c2[0],c[9]));\n if f > rf then begin\n rf:=f;\n rp:=x;\n r0:=z;\n end;\n inc(c[0],z); inc(c2[0],z);\n inc(c[x]); inc(c2[y]);\n end;\n\n begin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1; r0:=0;\n for j:=0 to c[0] do\n for i:=1 to 5 do\n solve(i,10-i,j);\n s:=''; t:='';\n for i:=1 to r0 do update(0,0);\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n while (c[0] > 0) and (c2[0] > 0) do begin\n s:=s+'0'; dec(c[0]);\n t:=t+'0'; dec(c2[0]);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n for i:=0 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\n end."}, {"source_code": "const MAX_N = 100010;\n\nvar fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf,r0:longint;\n c,c2:array[0..9] of longint;\n\n\nfunction min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\nprocedure update(x,y:longint);\nbegin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\nend;\n\nprocedure solve(x,y,z:longint);\nvar i,f:longint;\nbegin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n dec(c[0],z); dec(c2[0],z);\n f:=z;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n f:=f+min(c[0]-min(c[0],c2[9]),c2[0]-min(c2[0],c[9]));\n if f > rf then begin\n rf:=f;\n rp:=x;\n r0:=z;\n end;\n inc(c[0],z); inc(c2[0],z);\n inc(c[x]); inc(c2[y]);\nend;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1; r0:=0;\n for j:=0 to c[0] do\n for i:=1 to 5 do\n solve(i,10-i,j);\n s:=''; t:='';\n for i:=1 to r0 do update(0,0);\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n while (c[0] > 0) and (c2[0] > 0) do begin\n s:=s+'0'; dec(c[0]);\n t:=t+'0'; dec(c2[0]);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n for i:=0 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\nend.\n"}, {"source_code": "program fda;\ntype\n arr=array[0..10] of longint;\nvar\n s:ansistring;\n i,j,k,e,t,n,m:longint;\n a:arr;\n b:arr;\n ans:arr;//ans:array[0..10] of longint;\n ans1,ans2:longint;\n s1,s2,ss:ansistring;\nfunction min(x,y:longint):longint;\nbegin\n if xans1 then begin\n ans1:=k;\n ans:=c;\n ans2:=m;\n end;\nend;\nbegin\n readln(s);\n for i:=1 to length(s) do begin\n val(s[i],j);\n inc(a[j]);\n inc(b[j]);\n end;\n ans[10]:=min(a[0],b[0])-1;\n ans1:=ans[10]-1;\n ans2:=0;\n for i:=1 to 9 do begin\n if (a[i]>0) and (b[10-i]>0) then begin\n dec(a[i]);\n dec(b[10-i]);\n m:=i;\n work(a,b);\n inc(a[i]);\n inc(b[10-i]);\n end;\n end;\n s1:='';s2:='';\n if a[ans2]<>0 then begin\n str(ans2,s1);\n str((10-ans2) mod 10,s2);\n dec(a[ans2]);\n dec(b[(10-ans2) mod 10]);\n end;\n for i:=1 to ans[10] do begin\n s1:=s1+'0';\n s2:=s2+'0';\n dec(a[0]);\n dec(b[0]);\n end;\n for i:=9 downto 0 do begin\n for j:=1 to ans[i] do begin\n str(i,ss);s1:=ss+s1;\n str(9-i,ss);s2:=ss+s2;\n dec(a[i]);\n dec(b[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to a[i] do begin\n str(i,ss);s1:=ss+s1;\n end;\n for j:=1 to b[i] do begin\n str(i,ss);s2:=ss+s2;\n end;\n end;\n writeln(s1);\n writeln(s2);\nend.\n"}, {"source_code": "program digits_permut;\n\nuses math;\nconst\n fi='';\n fo='';\n tt = ord('0');\n oo = trunc(1e9);\ntype\n stri = ansistring;\nvar\n n:stri;\n a1,a2,b1,b2:array[0..9] of longint;\n s1,s2:stri;\nprocedure openfile;\nvar\n i:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(n);\n fillchar(a1,sizeof(a1),0);\n for i:=1 to length(n) do\n begin\n inc(a1[ord(n[i])-tt]);\n end;\n a2:=a1;\nend;\n//-------------------\nprocedure process;\nvar\n i,j:longint;\n s,p:longint;\n kq,jm:longint;\nbegin\n kq:=-oo;\n for i:=1 to 9 do\n if (a1[i]>0)and(a2[10-i]>0) then\n begin\n b1:=a1;\n b2:=a2;\n s:=1;\n dec(b1[i]);dec(b2[10-i]);\n for j:=0 to 9 do\n begin\n p:=min(b1[j],b2[9-j]);\n dec(b1[j],p);dec(b2[9-j],p);\n s:=s+p;\n end;\n inc(s,min(b1[0],b2[0]));\n if s>kq then\n begin\n kq:=s;\n jm:=i;\n end;\n end;\n if kq=-oo then\n begin\n s1:='';\n for i:=9 downto 0 do\n for j:=1 to a1[i] do s1:=s1+chr(i+tt);\n writeln(s1);\n writeln(s1);\n exit;\n end;\n s1:='';s2:='';\n dec(a1[jm]);\n dec(a2[10-jm]);\n for i:=1 to 1 do\n begin\n s1:=chr(jm+tt)+s1;\n s2:=chr(10-jm+tt)+s2;\n end;\n for i:=0 to 9 do\n begin\n p:=min(a1[i],a2[9-i]);\n dec(a1[i],p);dec(a2[9-i],p);\n for j:=1 to p do\n begin\n s1:=chr(i+tt)+s1;\n s2:=chr(9-i+tt)+s2;\n end;\n end;\n p:=min(a1[0],a2[0]);\n dec(a1[0],p);dec(a2[0],p);\n for i:=1 to p do\n begin\n s1:=s1+'0';\n s2:=s2+'0';\n end;\n for i:=0 to 9 do\n begin\n if a1[i]>0 then\n for j:=1 to a1[i] do s1:=chr(i+tt)+s1;\n if a2[i]>0 then\n for j:=1 to a2[i] do s2:=chr(i+tt)+s2;\n end;\n writeln(s1);\n writeln(s2);\nend;\n//--------------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "uses math;\nvar\n i,n,count,j,t,res,ires,mres,tmp: longint;\n s: ansistring;\n r1,r2: array[0..9,0..100000] of longint;\n c,d,e: array[0..9] of longint;\n ck: boolean;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n inc(d[ord(s[i])-48]);\n end;\n n:=length(s);\n\n for i:=1 to 9 do\n begin\n c:=d;\n e:=d;\n\n count:=0;\n\n if ((c[i]<1) or (e[10-i]<1)) then continue;\n dec(c[i]); dec(e[10-i]);\n r1[i,1]:=i; r2[i,1]:=10-i;\n ck:=true;\n if res=0 then\n begin\n res:=1;\n ires:=i;\n end;\n for j:=2 to n do\n begin\n if ck=true then\n begin\n ck:=false;\n for t:=0 to 9 do\n begin\n if (c[t]>0) and (e[9-t]>0) then\n begin\n inc(count);\n cK:=true;\n dec(c[t]); dec(e[9-t]);\n r1[i,j]:=t; r2[i,j]:=9-t;\n if count>res then\n begin\n res:=count;\n ires:=i;\n mres:=0;\n end;\n break;\n end;\n end;\n end;\n if not ck then\n begin\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n if count+tmp>res then\n begin\n res:=count+tmp;\n ires:=i;\n mres:=tmp;\n end;\n for t:=0 to 9 do\n begin\n if (c[t]>0)and(r1[i,j]=0) then\n begin\n r1[i,j]:=t;\n dec(c[t]);\n end;\n if (e[t]>0)and(r2[i,j]=0) then\n begin\n r2[i,j]:=t;\n dec(e[t]);\n end;\n end;\n end;\n end;\n end;\n if res<>0 then\n begin\n tmp:=mres;\n\n for i:=n-tmp downto 1 do write(r1[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1 do write(r2[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n end\n else\n begin\n\n c:=d; e:=d;\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n for j:=1 to n do\n for t:=0 to 9 do\n begin\n if (c[t]>0)and(r1[1,j]=0) then\n begin\n r1[1,j]:=t;\n dec(c[t]);\n end;\n if (e[t]>0)and(r2[1,j]=0) then\n begin\n r2[1,j]:=t;\n dec(e[t]);\n end;\n end;\n\n for i:=n-tmp downto 1 do write(r1[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1do write(r2[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n end;\nend.\n\n"}, {"source_code": "{$H+}\nvar\na1:string;\nnum,pre,prepre,vxod,max,alter:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nk:=min(c[0],s[0]);\nc[0]:=c[0]-k;s[0]:=s[0]-k;\nfor j:=0 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=0 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\n{k:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;}\nd:=i;\nif dozv=1 then begin\nif verx[d]=0 then d:=d-1;\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nif(verx[1]+nizz[1]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max=1)then begin\n max:=pre;\n vxod:=num;\n end;\nif (prepre>=1)then alter:=num;\nend;\nif vxod>0 then\npoisk(a1,vxod,1)else poisk(a1,alter,1);\nend."}, {"source_code": "var\n a:array[1..100000]of longint;\n b,c,d,e:array[0..9]of longint;\n s:ansistring;\n pk:boolean;\n n,i,j,k,l,o:longint;\n ansa,ansb:array[0..100000]of longint;\n ans:array[1..9]of longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0)and(c[10-i]>0) then begin\n dec(b[i]);\n dec(c[10-i]);\n l:=1;\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n l:=l+b[j];\n end;\n end;\n ans[i]:=l+min(c[0]-b[9],c[0]-b[0]);\n if ans[i]>ans[o] then o:=i;\n end;\n b:=d; c:=e;\n pk:=false;\n if (d[o]>0)and(c[10-o]>0) then begin\n dec(b[o]);\n pk:=true;\n dec(d[o]);\n dec(c[10-o]);\n end;\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n end;\n ansa[0]:=min(c[0]-b[0],c[0]-b[9]);\n ansb[0]:=ansa[0];\n d[0]:=d[0]-ansa[0];\n c[0]:=c[0]-ansb[0];\n if pk then begin\n inc(ansa[0]);\n ansa[ansa[0]]:=o;\n inc(ansb[0]);\n ansb[ansb[0]]:=10-o;\n end;\n for i:=0 to 9 do begin\n for j:=1 to b[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n dec(d[i]);\n inc(ansb[0]);\n ansb[ansb[0]]:=9-i;\n dec(c[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to d[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n end;\n for j:=1 to c[i] do begin\n inc(ansb[0]);\n ansb[ansb[0]]:=i;\n end;\n end;\n for i:=ansa[0] downto 1 do write(ansa[i]);\n writeln;\n for i:=ansb[0] downto 1 do write(ansb[i]);\n writeln;\nend.\n"}, {"source_code": "program fda;\ntype\n arr=array[0..10] of longint;\nvar\n s:ansistring;\n i,j,k,e,t,n,m:longint;\n a:arr;\n b:arr;\n ans:arr;//ans:array[0..10] of longint;\n ans1,ans2:longint;\n s1,s2,ss:ansistring;\nfunction min(x,y:longint):longint;\nbegin\n if xans1 then begin\n ans1:=k;\n ans:=c;\n ans2:=m;\n end;\nend;\nbegin\n readln(s);\n for i:=1 to length(s) do begin\n val(s[i],j);\n inc(a[j]);\n inc(b[j]);\n end;\n ans[10]:=min(a[0],b[0])-1;\n ans1:=ans[10]-1;\n ans2:=0;\n for i:=1 to 9 do begin\n if (a[i]>0) and (b[10-i]>0) then begin\n dec(a[i]);\n dec(b[10-i]);\n m:=i;\n work(a,b);\n inc(a[i]);\n inc(b[10-i]);\n end;\n end;\n s1:='';s2:='';\n if a[ans2]<>0 then begin\n str(ans2,s1);\n str((10-ans2) mod 10,s2);\n dec(a[ans2]);\n dec(b[(10-ans2) mod 10]);\n end;\n for i:=1 to ans[10] do begin\n s1:=s1+'0';\n s2:=s2+'0';\n dec(a[0]);\n dec(b[0]);\n end;\n for i:=9 downto 0 do begin\n for j:=1 to ans[i] do begin\n str(i,ss);s1:=ss+s1;\n str(9-i,ss);s2:=ss+s2;\n dec(a[i]);\n dec(b[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to a[i] do begin\n str(i,ss);s1:=ss+s1;\n end;\n for j:=1 to b[i] do begin\n str(i,ss);s2:=ss+s2;\n end;\n end;\n writeln(s1);\n writeln(s2);\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v,cl1,cl2:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n if j=0 then cl1:=math.min(a[j],b[v]);\n if j=9 then cl2:=math.min(a[j],b[v]);\n end;\n x:=x+math.min(a[0]-cl1,b[0]-cl2);\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "uses math;\n\nvar mm,t1,t2,j,last,max,tmp,i1,t,m,n,i:longint;\nok:boolean;\ns:ansistring;\na1,a2,f1,f2,c,a:array[0..200000]of longint;\n\n begin\n readln(s);\n t:=0;\n n:=length(s);\n for i:=1 to n do\n if s[i]='0' then t:=t+1 else\n begin\n m:=m+1;\n a[m]:=ord(s[i])-48;\n inc(c[a[m]]);\n end;\n\n max:=-1;\n last:=1;\n\n for i1:=1 to 9 do\n if c[i1]>0 then\n if c[10-i1]>0 then\n begin\n for i:=1 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n f1[i1]:=f1[i1]-1;\n f2[10-i1]:=f2[10-i1]-1;\n\n tmp:=1;\n\n for i:=1 to 8 do\n begin\n tmp:=tmp+min(f1[i],f2[9-i]);\n end;\n\n tmp:=tmp+min(f1[9],t)+min(f2[9],t);\n t1:=t-f1[9];\n if t1<0 then t1:=0;\n\n t2:=t-f2[9];\n if t2<0 then t2:=0;\n\n\n tmp:=tmp+min(t1,t2);\n\n if tmp>max then\n begin\n max:=tmp;\n last:=i1;\n end;\n end;\n\n if t>max then\n begin\n for i:=1 to m do write(a[i]);\n for i:=1 to t do write(0);\n writeln;\n\n for i:=1 to m do write(a[i]);\n for i:=1 to t do write(0);\n writeln;\n halt(0);\n end;\n\n i1:=last;\n\n for i:=1 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n f1[i1]:=f1[i1]-1;\n f2[10-i1]:=f2[10-i1]-1;\n a1[1]:=i1;\n a2[1]:=10-i1;\n mm:=1;\n\n for i:=1 to 8 do\n begin\n tmp:=min(f1[i],f2[9-i]);\n for j:=1 to tmp do\n begin\n mm:=mm+1;\n a1[mm]:=i;\n a2[mm]:=9-i;\n dec(f1[i]);\n dec(f2[9-i]);\n end;\n end;\n\n\n tmp:=min(f1[9],t);\n for j:=1 to tmp do\n begin\n mm:=mm+1;\n a1[mm]:=9;\n a2[mm]:=0;\n end;\n\n tmp:=min(f2[9],t);\n for j:=1 to tmp do\n begin\n mm:=mm+1;\n a2[mm]:=9;\n a1[mm]:=0;\n end;\n\n t1:=t-f2[9];\n if t1<0 then t1:=0;\n\n t2:=t-f1[9];\n if t2<0 then t2:=0;\n\n if f1[9]0 then\n begin\n mm:=mm+1;\n a1[mm]:=j;\n ok:=false;\n dec(f1[j]);\n break;\n end;\n\n if ok then break;\n\n for j:=0 to 9 do\n if f2[j]>0 then\n begin\n a2[mm]:=j;\n ok:=false;\n dec(f2[j]);\n break;\n end;\n end;\n\n for i:=mm downto 1 do write(a1[i]);\n for i:=1 to tmp do write(0);\n writeln;\n\n for i:=mm downto 1 do write(a2[i]);\n for i:=1 to tmp do write(0);\n writeln;\n\n end."}, {"source_code": "uses math;\nvar\n n,i,j,p,res,t,c: longint;\n ch: char;\n r1,r2: ansistring;\n s,a,b,d: array[0..9] of longint;\nfunction kt(a: longint): char;\n begin\n exit(char(a+ord('0')));\n end;\nbegin\n// assign(input,'aaa.inp');reset(input);\n// assign(output,'aaa.out');rewrite(output);\n\n n := 0;\n while not eoln do begin\n inc(n);\n read(ch);\n inc(s[ord(ch)-ord('0')]);\n end;\n\n res := s[0];\n p := 0;\n for i:=1 to 5 do if (s[i]>0) and (s[10-i]>0) then begin\n for j:=0 to 9 do begin\n a[j] := s[j];\n b[j] := s[j];\n end;\n dec(a[i]);\n dec(b[10-i]);\n t := 1;\n for j:=0 to 9 do begin\n c := min(a[j], b[9-j]);\n inc(t, c);\n dec(a[j],c);\n dec(b[9-j],c);\n end;\n t := t + min(a[0],b[0]);\n\n if t>res then begin\n res := t;\n p := i;\n end;\n end;\n\n i := p;\n for j:=0 to 9 do begin\n a[j] := s[j];\n b[j] := s[j];\n end;\n if p>0 then begin\n dec(a[i]);\n dec(b[10-i]);\n for j:=0 to 9 do begin\n c := min(a[j], b[9-j]);\n dec(a[j],c);\n dec(b[9-j],c);\n d[j] := c;\n end;\n\n r1 := kt(p);\n r2 := kt(10-p);\n for i:=0 to 9 do for j:=1 to d[i] do begin\n r1 := kt(i) + r1;\n r2 := kt(9-i) + r2;\n end;\n end;\n\n c := min(a[0],b[0]);\n dec(a[0],c);\n dec(b[0],c);\n for i:=1 to c do begin\n r1 := r1 + '0';\n r2 := r2 + '0';\n end;\n for i:=0 to 9 do begin\n for j:=1 to a[i] do r1 := kt(i)+r1;\n for j:=1 to b[i] do r2 := kt(i)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend."}, {"source_code": "Program Digits_Permutations;\nvar s:ansistring;\n i,j,t,sz:longint;\n a,b:array[0..9]of longint;\n p1,p2:array[1..100000]of longint;\n//======================================================================\nprocedure Calc(x,y:longint);\nbegin\n if a[x]>a[y] then b[x]:=a[x]-a[y]\n else b[y]:=a[y]-a[x];\nend;\n//======================================================================\nprocedure Ins(x,y:longint);\nbegin\n inc(sz);p1[sz]:=x;p2[sz]:=y;\nend;\n//======================================================================\nprocedure Work(x,y,mark:longint);\nvar i,j:longint;\nbegin\n if (a[x]=0)or(a[y]=0) then exit;\n if (mark=0)and((b[x]=0)or(b[y]=0)) then exit;\n if (mark=1)and((b[x]=0)and(b[y]=0)) then exit;\n t:=b[0];\n for i:=0 to 9 do b[i]:=a[i];\n for i:=1 to t do Ins(0,0);\n a[0]:=a[0]-t;b[0]:=b[0]-t;\n Ins(x,y);\n dec(a[x]);dec(b[y]);\n\n for i:=0 to 9 do\n while (a[i]>0)and(b[9-i]>0) do\n begin\n Ins(i,9-i);\n dec(a[i]);dec(b[9-i]);\n end;\n for i:=0 to 9 do\n for j:=1 to a[i] do write(i);\n for i:=sz downto 1 do write(p1[i]); writeln;\n for i:=0 to 9 do\n for j:=1 to b[i] do write(i);\n for i:=sz downto 1 do write(p2[i]); writeln;\n halt;\nend;\n//======================================================================\nbegin\n readln(s);\n for i:=1 to length(s) do\n inc(a[ord(s[i])-ord('0')]);\n for i:=0 to 4 do Calc(i,9-i);\n for j:=0 to 2 do\n for i:=1 to 5 do\n Work(i,10-i,j);\n for i:=0 to 9 do\n while a[i]>0 do\n begin\n Ins(i,i);dec(a[i]);\n end;\n for i:=sz downto 1 do write(p1[i]);writeln;\n for i:=sz downto 1 do write(p2[i]);\nend.\n"}, {"source_code": "var st:ansistring;\n a,b,c:array[0..10] of longint;\n max,maxk,c1,i,e,j,o:longint;\n x,y:array[0..1000000] of longint;\n\nfunction min(a,b:longint):longint;\n begin\n if a=0) and (c[10-i]>=0) then\n begin\n e:=1;\n for j:=0 to 9 do\n e:=e+min(b[j],c[9-j]);\n if e>max then\n begin\n max:=e;\n maxk:=i;\n end;\n end;\n end;\n if (max=0) and (a[0]=0) then\n begin\n writeln(st);\n writeln(st);\n end\n else\n if max=0 then\n begin\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n end\n else\n begin\n inc(o);\n x[o]:=maxk;\n y[o]:=10-maxk;\n b:=a;\n dec(a[maxk]);\n dec(b[10-maxk]);\n for i:=0 to 9 do\n begin\n c1:=min(a[i],b[9-i]);\n a[i]:=a[i]-c1;\n b[9-i]:=b[9-i]-c1;\n for j:=1 to c1 do\n begin\n inc(o);\n x[o]:=i;\n y[o]:=9-i;\n end;\n end;\n c1:=min(a[0],b[0]);\n a[0]:=a[0]-c1;\n b[0]:=b[0]-c1;\n for i:=0 to 9 do\n for j:=1 to a[i] do\n write(i);\n for i:=o downto 1 do write(x[i]);\n for i:=1 to c1 do write(0);writeln;\n for i:=0 to 9 do\n for j:=1 to b[i] do\n write(i);\n for i:=o downto 1 do write(y[i]);\n for i:=1 to c1 do write(0);writeln;\n end;\nend.\n"}, {"source_code": "uses\n math;\n\nvar\n u1,u2,a:array[0..500500]of longint;\n kc1,kc2,kc:array[0..100]of longint;\n tt,z,m1,m2,cr,m,c,i,n,pc1,pc2,c1,c2,max,qq:longint;\n s:ansistring;\n\nbegin\n readln(s);\n n:=length(s);\n fillchar(kc,sizeof(kc),$0);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=1 to n do inc(kc[a[i]]);\n m:=n;\n pc1:=-1;pc2:=-1;\n max:=-1;\n tt:=kc[0];\n for i:=0 to tt do begin\n dec(kc[0],i);\n for c1:=0 to 9 do begin\n c2:=10-c1;\n if (kc[c1]=0)or(kc[c2]=0)then continue;\n dec(kc[c1]);dec(kc[c2]); cr:=i+1;\n for c:=0 to 4 do begin\n qq:=min(kc[c],kc[9-c]);\n inc(cr,qq);\n end;\n if (cr>max)then begin max:=cr;pc1:=c1;pc2:=c2;z:=i; end;\n inc(kc[c1]);inc(kc[c2]);\n end;\n inc(kc[0],i);\n end;\n for i:=1 to z do begin\n dec(kc[0]);\n u1[m]:=0;\n u2[m]:=0;\n dec(m);\n end;\n if (pc1<>-1)then begin\n u1[m]:=pc1;\n u2[m]:=pc2;\n dec(m);\n c1:=pc1;c2:=pc2;\n for c:=0 to 9 do begin kc1[c]:=kc[c];kc2[c]:=kc[c]; end;\n dec(kc1[c1]);\n dec(kc2[c2]);\n for c:=0 to 9 do begin\n qq:=min(kc1[c],kc2[9-c]);\n for i:=1 to qq do begin\n u1[m]:=c;\n u2[m]:=9-c;\n dec(m);\n end;\n dec(kc1[c],qq);dec(kc2[9-c],qq);\n end;\n end else for c:=0 to 9 do begin kc1[c]:=kc[c];kc2[c]:=kc[c]; end;\n m1:=m;m2:=m;\n for i:=0 to 9 do begin\n while (kc1[i]>0)do begin\n u1[m1]:=i;\n dec(m1);\n dec(kc1[i]);\n end;\n while (kc2[i]>0)do begin\n u2[m2]:=i;\n dec(m2);\n dec(kc2[i]);\n end;\n end;\n for i:=1 to n do write(u1[i]);\n writeln;\n for i:=1 to n do write(u2[i]);\nend.\n"}, {"source_code": "Program cf99b;\nconst ch:array[0..9] of char='0123456789';\nvar t,a,b,c:array[0..9] of longint;\n n,i,j,k,l,pre,best,cur,cp,d:longint;\n cc:char;\nfunction min(a,b:longint):longint;\nbegin\n if a=1))\n or ((i<>5) and (t[i]>=1) and (t[10-i]>=1))\n then\n begin\n for j:=0 to 9 do begin a[j]:=t[j];b[j]:=t[j];end;\n a[i]:=a[i]-1;\n b[10-i]:=b[10-i]-1;\n cur:=calc()+min(a[0]-min(a[0],b[9]),b[0]-min(b[0],a[9]))+1;\n if cur>best then\n begin\n best:=cur;\n cp:=i;\n end;\n end;\n if best=0 then\n begin\n for i:=1 to 10 do\n for j:=1 to t[i mod 10] do\n write(i mod 10);\n writeln;\n for i:=1 to 10 do\n for j:=1 to t[i mod 10] do\n write(i mod 10);\n end\n else\n begin\n //writeln(best);\n a:=t;b:=t;\n a[cp]:=a[cp]-1;\n b[10-cp]:=b[10-cp]-1;\n pre:=min(a[0]-min(a[0],b[9]),b[0]-min(b[0],a[9]));\n a[0]:=a[0]-pre;b[0]:=b[0]-pre;\n for i:=0 to 9 do c[i]:=min(a[i],b[9-i]);\n for i:=0 to 9 do a[i]:=a[i]-c[i];\n for i:=0 to 9 do b[9-i]:=b[9-i]-c[i];\n for i:=0 to 9 do\n if a[i]>0 then\n for j:=1 to a[i] do write(ch[i]);\n for i:=0 to 9 do\n if c[i]>0 then\n for j:=1 to c[i] do write(ch[i]);\n write(ch[cp]);\n for i:=1 to pre do write('0');\n writeln;\n for i:=0 to 9 do\n if b[i]>0 then\n for j:=1 to b[i] do write(ch[i]);\n for i:=0 to 9 do\n if c[i]>0 then\n for j:=1 to c[i] do write(ch[9-i]);\n write(ch[10-cp]);\n for i:=1 to pre do write('0');\n end;\n close(input);\nend."}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2,kq1,kq2:array[1..100011] of longint;\ns1,s2,ss1,ss2:array[0..10] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nres:longint;\n\nProcedure try (vt,gt:longint);\nvar count:longint;\nok:boolean;\ni,j:longint;\nBegin\n ok:=false;\n i:=vt;\n count:=n-vt;\n if (s1[gt]>0) and (s2[10-gt]>0) then\n begin\n d1[vt]:=gt;\n d2[vt]:=10-gt;\n dec(s1[gt]);\n dec(s2[10-gt]);\n ok:=true;\n i:=vt-1;\n end;\n\n if ok then\n begin\n count:=count+1;\n for i:=vt-1 downto 1 do\n begin\n found:=false;\n for j:=0 to 9 do\n if (s1[j]>0) and (s2[9-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[9-j]);\n D1[i]:=j;\n D2[i]:=9-j;\n inc(count);\n break;\n end;\n if found=false then break;\n End;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n if count>res then\n begin\n res:=count;\n kq1:=d1;\n kq2:=d2;\n end;\nEnd;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n res:=-1;\n\n ss1:=s1;\n ss2:=s2;\n for j:=1 to 9 do\n Begin\n s1:=ss1;\n s2:=ss2;\n try(n,j);\n end;\n j:=0;\n for i:=1 to n do\n if (kq1[i]=0) and (kq2[i]=0) then inc(j);\n\n for i:=1 to n do\n if Not((Kq1[i]=0) and (kq2[i]=0)) then\n write(f2,kq1[i]);\n for i:=1 to j do write(f2,0);\n\n writeln(f2);\n for i:=1 to n do\n if Not((kq1[i]=0) and (kq2[i]=0)) then\n write(f2,kq2[i]);\n for i:=1 to j do write(f2,0);\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "uses math;\nVar a,b:array[0..123]of longint;\nans,anss:array[0..100333,1..2]of longint;\ni,j,k,kk,q,ii,x,cnt,o,p,kkk,oo:longint;\nok:boolean;\ns:ansistring;\n begin\n { assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n }\n readln(s);\n kkk:=-1;\n fillchar(b,sizeof(b),0);\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s) do\n inc(a[ord(s[i])-48]);\n for i:=0 to 9 do\n b[i]:=a[i];\n ok:=false;\n for i:=1 to 9 do\n if (a[i]*a[10-i]>0) then ok:=true;\n if not ok then begin\n // Writeln(a[0]);\n for i:=9 downto 0 do\n for j:=1 to a[i] do\n Write(i);\n Writeln;\n for i:=9 downto 0 do\n for j:=1 to a[i] do\n Write(i);\n Writeln;\nhalt(0);\n end;\n\n for ii:=1 to 9 do\n begin\n fillchar(b,sizeof(b),0);\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s) do\n inc(a[ord(s[i])-48]);\n for i:=0 to 9 do\n b[i]:=a[i];\n\n if a[(10-ii)mod 10]=0 then continue;\n if a[ii]=0 then continue;\n k:=1;\n ans[k,1]:=ii;\n ans[k,2]:=(10-ii)mod 10;\n dec(a[ii]);\n dec(b[(10-ii)mod 10]); x:=1;\n j:=1;\n while (j=1)or(k<>kk) do\n begin\n kk:=k;\n for i:=9 downto 1 do\n begin\n while (a[i]>0)and(b[(10-i-x)mod 10]>0)and((10-i-x)mod 10<>0) do\n begin\n inc(k);\n ans[k,1]:=i;\n ans[k,2]:=(10-i-x)mod 10;\n dec(a[i]);\n dec(b[(10-i-x)mod 10]);\n if (i<>0)or((10-i-x)mod 10<>0) then x:=1\n else x:=0;\n end;\n end;\n inc(j);\n end;\n for i:=1 to min(a[0],b[9]) do\n begin\n inc(k);\n ans[k,1]:=0;\n ans[k,2]:=9;\n dec(a[0]);\n dec(b[9]);\n end;\n for i:=1 to min(b[0],a[9]) do\n begin\n inc(k);\n ans[k,1]:=9;\n ans[k,2]:=0;\n dec(b[0]);\n dec(a[9]);\n end;\n\n o:=0;\n for i:=1 to min(a[0],b[0]) do\n begin\n inc(o);\n dec(a[0]);\n dec(b[0]);\n end;\n if k+o ans + r then begin\n ans := an;\n ind := i;\n r := nul0;\n end;\n end;\n dec(c1[0]);\n dec(c2[0]);\n end;\n c1[0] := c10 - r;\n c2[0] := c10 - r;\n if ans <> 0 then begin\n a[n - r] := ind;\n b[n - r] := 10 - ind;\n dec(c1[ind]);\n dec(c2[10 - ind]);\n j := 9;\n t1 := 0;\n t2 := 0;\n inc(r);\n end\n else begin\n j := -1;\n t1 := 0;\n t2 := 0;\n end;\n for i := n - r downto 1 do begin\n while (j > -1) and (min(c1[j], c2[9 - j]) = 0) do begin\n dec(j);\n end;\n if j > -1 then begin\n a[i] := j;\n b[i] := 9 - j;\n dec(c1[j]);\n dec(c2[9 - j]);\n end\n else begin\n while (t1 < 10) and (c1[t1] = 0) do begin\n inc(t1);\n end;\n if t1 < 10 then begin\n a[i] := t1;\n dec(c1[t1]);\n end\n else begin\n writeln('WTF?!1');\n halt(3);\n end;\n while (t2 < 10) and (c2[t2] = 0) do begin\n inc(t2);\n end;\n if t2 < 10 then begin\n b[i] := t2;\n dec(c2[t2]);\n end\n else begin\n writeln('WTF?!2');\n halt(3);\n end;\n end;\n end;\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii,rp,rii: longint;\n b1,b2,o,rb1,rb2: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\n sve: boolean;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n b1:=o;\n b2:=o;\n dec(b1[0],ii);dec(b2[0],ii);\n if ii>0 then\n begin\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=ii+1;\n for j:=0 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n rez:=max;\n sve:=true;\n continue;\n end;\n if max<=rez then continue;\n sve:=false;\n rez:=max;\n rp:=p;\n rii:=ii;\n rb1:=b1;\n rb2:=b2;\n b1:=o;\n b2:=o;\n end;\n if sve then\n begin\n r1:='';r2:='';\n s1:='';\n for i:=1 to rii do s1:='0'+s1;\n s2:=s1;\n b1:=o;b2:=o;dec(b1[0],rii);dec(b2[0],rii);\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n writeln(r1);\n writeln(r2);\n exit;\n end;\n s1:='';\n s2:='';\n for i:=1 to rii do s1:='0'+s1;\n s2:=s1;\n b1:=rb1;\n b2:=rb2;\n p:=rp;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=0 to 9 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "program task4;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\ntype dd=array [0..9] of longint; \nvar\nA,A1,A2:dd;\nB1,B2:array [1..100010] of longint;\ns:string;\ni,c,k1,k2,j,k,x,y,z,q,p00:longint;\n\nprocedure print;\nvar\ni:longint;\nbegin\nfor i:=k1 downto 1 do\n begin\n write(B1[i]);\n end;\n for i:=1 to p00 do write(0);\n writeln;\nfor i:=k2 downto 1 do\n begin\n write(b2[i]);\n end;\n for i:=1 to p00 do write(0);\nwriteln;\nend;\n\nfunction kp:longint;\nvar\ni:longint;\nbegin\nresult:=0;\nfor i:=0 to 9 do\n begin\n inc(result,min(A1[i],A2[9-i]));\n end;\nend;\n\nbegin {\nassign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(s);\nfor i:=0 to 9 do\n begin\n A[i]:=0;\n end;\nfor i:=1 to length(s) do\n begin\n c:=ord(s[i])-48;\n inc(A[c]);\n end;\nk:=0;\n{while A[0]>0 do\n begin\n dec(A[0]);\n inc(k);\n B1[k]:=0;\n B2[k]:=0;\n end; }\nA1:=A;\nA2:=A;\nz:=-1;\nx:=-1;\ny:=-1;\nif (A[1]>0) and (A[9]>0) then\n begin\n dec(A1[1]);\n dec(A2[9]);\n q:=kp;\n inc(A1[1]);\n inc(A2[9]);\n if q>z then\n begin\n z:=q;\n x:=1;\n y:=9;\n end;\n end;\nif (A[2]>0) and (A[8]>0) then\n begin\n dec(A1[2]);\n dec(A2[8]);\n q:=kp;\n inc(A1[2]);\n inc(A2[8]);\n if q>z then\n begin\n z:=q;\n x:=2;\n y:=8;\n end;\n end ;\nif (A[3]>0) and (A[7]>0) then\n begin\n dec(A1[3]);\n dec(A2[7]);\n q:=kp;\n inc(A1[3]);\n inc(A2[7]);\n if q>z then\n begin\n z:=q;\n x:=3;\n y:=7;\n end;\n end;\nif (A[4]>0) and (A[6]>0) then\n begin\n dec(A1[4]);\n dec(A2[6]);\n q:=kp;\n inc(A1[4]);\n inc(A2[6]);\n if q>z then\n begin\n z:=q;\n x:=4;\n y:=6;\n end;\n end ;\nif (A[5]>0) and (A[5]>0) then\n begin\n dec(A1[5]);\n dec(A2[5]);\n q:=kp;\n inc(A1[5]);\n inc(A2[5]);\n if q>z then\n begin\n z:=q;\n x:=5;\n y:=5;\n end;\n end;\nif x<>-1 then\n begin\n inc(k);\n dec(A1[x]);\n dec(A2[y]);\n B1[k]:=x;\n B2[k]:=y;\n end;\nfor i:=0 to 9 do\n begin\n while (A1[i]>0) and (A2[9-i]>0) do\n begin\n dec(A1[i]);\n dec(A2[9-i]);\n inc(k);\n B1[k]:=i;\n B2[k]:=9-i;\n end;\n end;\n k1:=k;\n k2:=k;\n p00:=0;\nwhile (A1[0]>0) and (A2[0]>0) do\n begin\n inc(p00);\n dec(A1[0]);\n dec(A2[0]);\n end;\nfor i:=0 to 9 do\n begin\n for j:=1 to A1[i] do\n begin\n inc(k1);\n B1[k1]:=i;\n end;\n for j:=1 to A2[i] do\n begin\n inc(k2);\n B2[k2]:=i;\n end;\n end;\nprint; \n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n\nconst eps=0.000000001; nnn=200000;\nlabel 1,2,3;\ntype int64=longint;\nmas=array[0..20000] of longint; mmas=^mas;\nvar maxkol,s,kk,kp,num,mmax,n1,h,t,imin,mmin,p,step,jmax,n,k,pmax:longint;\n flag,flag1:boolean; pl,mm,aaa,kolraz,otmax,ot,m,j2:int64;\n i,j:longint; ch:char;\n ss:string;\npp,ppp :mas;\n ugol,vp,sot,vr,vb:double;\na,b,c,ot1,ot2:array[-10..500000] of longint;\nopt,aa:array[0..1000,0..1000] of longint;\n new1,new2, ss1,ss2:string;\n otv:array[-10..800,-10..800] of int64 ;\n l,r,spost:array [0..1000] of longint;\n function min(a,b:int64):int64;\nbegin min:=a;if ba then max:=b; end;\n\n\n{ function per(num:longint): mmas; var i,j:longint;\n pp,ppp:array[0..10] of longint;\nbegin dec(num);\n for i:=1 to n-1 do begin pp[i]:=num div fac[n-i]; num:=num mod fac[n-i];end;\n for i:=1 to n do write(pp[i],' '); writeln;\n\nend; }\n function prr(p:longint):boolean; var i,j:longint; flag:boolean;\n begin\n flag:=true;\n for i:=2 to trunc(sqrt(p)+eps) do if p mod i=0 then flag:=false;\n prr:=flag; if (p=1)or(p=0) then prr:=false;\n end;\n\n\n begin {assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);\n }\nwhile not eof do begin read(ch); inc(a[ord(ch)-48]); end;\n\n{for i:=0 to 9 do write(a[i],' '); writeln; }\nfor i:=0 to 10 do begin b[i]:=a[i]; c[i]:=a[i]; end;\nfor i:=0 to 9 do n:=n+a[i];\n for p:=0 to c[0] do {p - kol 0 na konze}\n begin for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=c[0]-p; b[0]:=c[0]-p;\n for j:=1 to 9 do {j - poslednyaya zifra pered 0 }\n if (a[j]>0)and(b[10-j]>0) then\n\n begin\n for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=c[0]-p; b[0]:=c[0]-p;\n dec(a[j]); dec(b[10-j]);\n t:=p+1;\n {writeln;writeln;\n for i:=0 to 9 do write(a[i],' '); writeln;\n for i:=0 to 9 do write(b[i],' '); writeln; }\n for i:=0 to 9 do t:=t+min(a[i],b[9-i]);\n {writeln(p,' nuley ',j,'+',10-j,' and ',t-p-1,' devyatok'); }\n if t>maxkol then begin maxkol:=t; jmax:=j;pmax:=p; end;\n end;\n\n\n\n end;\n\n{ writeln(maxkol,' ',jmax,' ',pmax); writeln;\n}\nif maxkol>0 then\n begin\n for i:=0 to 9 do begin a[i]:=c[i];b[i]:=c[i]; end;\n a[0]:=a[0]-pmax;b[0]:=b[0]-pmax;\n for i:=1 to pmax do begin ot1[i]:=0;ot2[i]:=0; end;\n ot1[pmax+1]:=jmax; ot2[pmax+1]:=10-jmax;\n dec(a[jmax]);dec(b[10-jmax]); pl:=pmax+1;\n\n begin\n for j:=0 to 9 do for i:=1 to min(a[j],b[9-j]) do\n begin inc(pl);ot1[pl]:=j;ot2[pl]:=9-j; end;\n end;\n for j:=0 to 9 do\n for i:=1 to a[j]-min(a[j],b[9-j]) do\n begin inc(pl); ot1[pl]:=j; end; pl:=maxkol;\n for j:=0 to 9 do\n for i:=1 to b[9-j]-min(a[j],b[9-j]) do\n begin inc(pl); ot2[pl]:=9-j; end;\n for i:=n downto 1 do write(ot1[i],''); writeln;\n for i:=n downto 1 do write(ot2[i],''); writeln;\n end else\n begin for i:=9 downto 0 do for j:=1 to c[i] do write(i); writeln;\n for i:=9 downto 0 do for j:=1 to c[i] do write(i); writeln;\n end;\n\n 1: close (output);\nend.\n\n"}, {"source_code": "var mn,q,i,l,k,m,j,h:longint;\n a,b:array[0..9] of longint;\n s,c:string;\nfunction posh:longint;\nvar w,i:longint;\nbegin\nw:=0;\nfor i:=0 to 9 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nw:=w+k;\nend;\nk:=b[9];\nif k>a[0] then k:=a[0];\nw:=w+k;\nposh:=w;\nend;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])-48]);\nfor i:=0 to 9 do b[i]:=a[i];\n\nfor i:=1 to 5 do\nif (a[i]>0) and (b[10-i]>0) then\nbegin\ndec(a[i]);\ndec(b[10-i]);\nm:=posh+1;\nif m>mn then\nbegin\nmn:=m;\nq:=i;\nend;\ninc(a[i],1);\ninc(b[10-i],1);\nend;\n\nif q=0 then\nbegin\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nfor l:=1 to a[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nfor l:=1 to b[0] do write(0);\nwriteln;\nend else\nbegin\ndec(mn);\ndec(a[q]);\ndec(b[10-q]);\ns:='';\nc:='';\n\nfor i:=0 to 9 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nfor l:=1 to k do\nbegin\ns:=s+chr(i+48);\ndec(b[i]);\ndec(a[9-i]);\nc:=c+chr(9-i+48);\nend;\nend;\nk:=b[9];\nif k>a[0] then k:=a[0];\nfor l:=1 to k do\nbegin\ns:=s+chr(9+48);\ndec(b[9]);\ndec(a[0]);\nc:=c+chr(48);\nend;\nfor i:=1 to a[0]-b[0] do begin dec(a[0]); c:='0'+c; end;\nfor i:=1 to b[0]-a[0] do begin dec(b[0]); s:='0'+s; end;\nc:=c+chr(q+48);\ns:=s+chr(10-q+48);\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nwrite(s);\nfor l:=1 to b[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nwrite(c);\nfor l:=1 to a[0] do write(0);\nwriteln;\nend;\nend."}], "negative_code": [{"source_code": "program task4;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\ntype dd=array [0..9] of longint; \nvar\nA,A1,A2:dd;\nB1,B2:array [1..100010] of longint;\ns:string;\ni,c,k1,k2,j,k:longint;\n\nprocedure print;\nvar\ni:longint;\nbegin\nfor i:=k1 downto 1 do\n begin\n write(B1[i]);\n end;\n writeln;\nfor i:=k2 downto 1 do\n begin\n write(b2[i]);\n end;\nwriteln;\nend;\n\nbegin {\nassign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(s);\nfor i:=0 to 9 do\n begin\n A[i]:=0;\n end;\nfor i:=1 to length(s) do\n begin\n c:=ord(s[i])-48;\n inc(A[c]);\n end;\nk:=0;\nwhile A[0]>0 do\n begin\n dec(A[0]);\n inc(k);\n B1[k]:=0;\n B2[k]:=0;\n end;\nA1:=A;\nA2:=A; \nif (A[1]>0) and (A[9]>0) then\n begin\n dec(A1[1]);\n dec(A2[9]);\n inc(k);\n B1[k]:=1;\n B2[k]:=9;\n end;\nfor i:=1 to 8 do\n begin\n if (A1[i]>0) and (A2[9-i]>0) then\n begin\n dec(A1[i]);\n dec(A2[9-i]);\n inc(k);\n B1[k]:=i;\n B2[k]:=9-i;\n end;\n end;\n k1:=k;\n k2:=k;\nfor i:=0 to 9 do\n begin\n for j:=1 to A1[i] do\n begin\n inc(k1);\n B1[k1]:=i;\n end;\n for j:=1 to A2[i] do\n begin\n inc(k2);\n B2[k2]:=i;\n end;\n end;\nprint; \n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program task4;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\ntype dd=array [0..9] of longint; \nvar\nA,A1,A2:dd;\nB1,B2:array [1..100010] of longint;\ns:string;\ni,c,k1,k2,j,k:longint;\n\nprocedure print;\nvar\ni:longint;\nbegin\nfor i:=k1 downto 1 do\n begin\n write(B1[i]);\n end;\n writeln;\nfor i:=k2 downto 1 do\n begin\n write(b2[i]);\n end;\nwriteln;\nend;\n\nbegin {\nassign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(s);\nfor i:=0 to 9 do\n begin\n A[i]:=0;\n end;\nfor i:=1 to length(s) do\n begin\n c:=ord(s[i])-48;\n inc(A[c]);\n end;\nk:=0;\nwhile A[0]>0 do\n begin\n dec(A[0]);\n inc(k);\n B1[k]:=0;\n B2[k]:=0;\n end;\nA1:=A;\nA2:=A; \nif (A[1]>0) and (A[9]>0) then\n begin\n dec(A1[1]);\n dec(A2[9]);\n inc(k);\n B1[k]:=1;\n B2[k]:=9;\n end else\nif (A[2]>0) and (A[8]>0) then\n begin\n dec(A1[2]);\n dec(A2[8]);\n inc(k);\n B1[k]:=2;\n B2[k]:=8;\n end else\nif (A[3]>0) and (A[7]>0) then\n begin\n dec(A1[3]);\n dec(A2[7]);\n inc(k);\n B1[k]:=3;\n B2[k]:=7;\n end else\nif (A[4]>0) and (A[6]>0) then\n begin\n dec(A1[4]);\n dec(A2[6]);\n inc(k);\n B1[k]:=4;\n B2[k]:=6;\n end else\nif (A[5]>0) and (A[5]>0) then\n begin\n dec(A1[5]);\n dec(A2[5]);\n inc(k);\n B1[k]:=5;\n B2[k]:=5;\n end;\nfor i:=1 to 8 do\n begin\n while (A1[i]>0) and (A2[9-i]>0) do\n begin\n dec(A1[i]);\n dec(A2[9-i]);\n inc(k);\n B1[k]:=i;\n B2[k]:=9-i;\n end;\n end;\n k1:=k;\n k2:=k;\nfor i:=0 to 9 do\n begin\n for j:=1 to A1[i] do\n begin\n inc(k1);\n B1[k1]:=i;\n end;\n for j:=1 to A2[i] do\n begin\n inc(k2);\n B2[k2]:=i;\n end;\n end;\nprint; \n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program task4;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\ntype dd=array [0..9] of longint; \nvar\nA,A1,A2:dd;\nB1,B2:array [1..100010] of longint;\ns:string;\ni,c,k1,k2,j,k,x,y,z,q:longint;\n\nprocedure print;\nvar\ni:longint;\nbegin\nfor i:=k1 downto 1 do\n begin\n write(B1[i]);\n end;\n writeln;\nfor i:=k2 downto 1 do\n begin\n write(b2[i]);\n end;\nwriteln;\nend;\n\nfunction kp:longint;\nvar\ni:longint;\nbegin\nresult:=0;\nfor i:=0 to 9 do\n begin\n inc(result,min(A1[i],A2[9-i]));\n end;\nend;\n\nbegin {\nassign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(s);\nfor i:=0 to 9 do\n begin\n A[i]:=0;\n end;\nfor i:=1 to length(s) do\n begin\n c:=ord(s[i])-48;\n inc(A[c]);\n end;\nk:=0;\nwhile A[0]>0 do\n begin\n dec(A[0]);\n inc(k);\n B1[k]:=0;\n B2[k]:=0;\n end;\nA1:=A;\nA2:=A;\nz:=-1;\nx:=-1;\ny:=-1;\nif (A[1]>0) and (A[9]>0) then\n begin\n dec(A1[1]);\n dec(A2[9]);\n q:=kp;\n inc(A1[1]);\n inc(A2[9]);\n if q>z then\n begin\n z:=q;\n x:=1;\n y:=9;\n end;\n end;\nif (A[2]>0) and (A[8]>0) then\n begin\n dec(A1[2]);\n dec(A2[8]);\n q:=kp;\n inc(A1[2]);\n inc(A2[8]);\n if q>z then\n begin\n z:=q;\n x:=2;\n y:=8;\n end;\n end ;\nif (A[3]>0) and (A[7]>0) then\n begin\n dec(A1[3]);\n dec(A2[7]);\n q:=kp;\n inc(A1[3]);\n inc(A2[7]);\n if q>z then\n begin\n z:=q;\n x:=3;\n y:=7;\n end;\n end;\nif (A[4]>0) and (A[6]>0) then\n begin\n dec(A1[4]);\n dec(A2[6]);\n q:=kp;\n inc(A1[4]);\n inc(A2[6]);\n if q>z then\n begin\n z:=q;\n x:=4;\n y:=6;\n end;\n end ;\nif (A[5]>0) and (A[5]>0) then\n begin\n dec(A1[5]);\n dec(A2[5]);\n q:=kp;\n inc(A1[5]);\n inc(A2[5]);\n if q>z then\n begin\n z:=q;\n x:=5;\n y:=5;\n end;\n end;\nif x<>-1 then\n begin\n inc(k);\n dec(A1[x]);\n dec(A2[y]);\n B1[k]:=x;\n B2[k]:=y;\n end;\nfor i:=1 to 8 do\n begin\n while (A1[i]>0) and (A2[9-i]>0) do\n begin\n dec(A1[i]);\n dec(A2[9-i]);\n inc(k);\n B1[k]:=i;\n B2[k]:=9-i;\n end;\n end;\n k1:=k;\n k2:=k;\nfor i:=0 to 9 do\n begin\n for j:=1 to A1[i] do\n begin\n inc(k1);\n B1[k1]:=i;\n end;\n for j:=1 to A2[i] do\n begin\n inc(k2);\n B2[k2]:=i;\n end;\n end;\nprint; \n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var mn,q,i,l,k,m,j,h:longint;\n a,b:array[0..9] of longint;\n s,c:string;\nfunction posh:longint;\nvar w,i:longint;\nbegin\nw:=0;\nfor i:=0 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nw:=w+k;\nend;\nk:=b[9];\nif k>a[0] then k:=a[0];\nw:=w+k;\nposh:=w;\nend;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])-48]);\nfor i:=0 to 9 do b[i]:=a[i];\n\nfor i:=1 to 5 do\nif (a[i]>0) and (b[10-i]>0) then\nbegin\ndec(a[i]);\ndec(b[10-i]);\nm:=posh+1;\nif m>mn then\nbegin\nmn:=m;\nq:=i;\nend;\ninc(a[i],1);\ninc(b[10-i],1);\nend;\n\nif q=0 then\nbegin\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nfor l:=1 to a[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nfor l:=1 to b[0] do write(0);\nwriteln;\nend else\nbegin\ndec(mn);\ndec(a[q]);\ndec(b[10-q]);\ns:='';\nc:='';\n\nfor i:=0 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nfor l:=1 to k do\nbegin\ns:=s+chr(i+48);\ndec(b[i]);\ndec(a[9-i]);\nc:=c+chr(9-i+48);\nend;\nend;\nk:=b[9];\nif k>a[0] then k:=a[0];\nfor l:=1 to k do\nbegin\ns:=s+chr(9+48);\ndec(b[9]);\ndec(a[0]);\nc:=c+chr(48);\nend;\nfor i:=1 to a[0]-b[0] do begin dec(a[0]); c:='0'+c; end;\nfor i:=1 to b[0]-a[0] do begin dec(b[0]); s:='0'+s; end;\nc:=c+chr(q+48);\ns:=s+chr(10-q+48);\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nwrite(s);\nfor l:=1 to b[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nwrite(c);\nfor l:=1 to a[0] do write(0);\nwriteln;\nend;\nend."}, {"source_code": "var mn,q,i,l,k,m,j,h:longint;\n a,b:array[0..9] of longint;\n s,c:string;\nfunction posh:longint;\nvar w,i:longint;\nbegin\nw:=0;\nfor i:=1 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nw:=w+k;\nend;\nposh:=w;\nend;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])-48]);\nfor i:=0 to 9 do b[i]:=a[i];\n\nfor i:=1 to 9 do\nif (a[i]>0) and (b[10-i]>0) then\nbegin\ndec(a[i],1);\ndec(b[10-i],1);\nm:=posh;\nif m>mn then\nbegin\nmn:=m;\nq:=i;\nend;\ninc(a[i],1);\ninc(b[10-i],1);\nend;\n\nif q=0 then\nbegin\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nfor l:=1 to a[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nfor l:=1 to b[0] do write(0);\nwriteln;\nend else\nbegin\ndec(a[q]);\ndec(b[10-q]);\ns:='';\nc:='';\n\nfor i:=1 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nfor l:=1 to k do\nbegin\ns:=s+chr(i+48);\ndec(b[i]);\ndec(a[9-i]);\nc:=c+chr(9-i+48);\nend;\nend;\nc:=c+chr(q+48);\ns:=s+chr(10-q+48);\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nwrite(s);\nfor l:=1 to b[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nwrite(c);\nfor l:=1 to a[0] do write(0);\nwriteln;\nend;\nend."}, {"source_code": "var mn,q,i,l,k,m,j,h:longint;\n a,b:array[0..9] of longint;\n s,c:string;\nfunction posh:longint;\nvar w,i:longint;\nbegin\nw:=0;\nfor i:=1 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nw:=w+k;\nend;\nposh:=w;\nend;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])-48]);\nfor i:=0 to 9 do b[i]:=a[i];\n\nfor i:=1 to 5 do\nif (a[i]>0) and (b[10-i]>0) then\nbegin\ndec(a[i]);\ndec(b[10-i]);\nm:=posh+1;\nif m>mn then\nbegin\nmn:=m;\nq:=i;\nend;\ninc(a[i],1);\ninc(b[10-i],1);\nend;\n\nif q=0 then\nbegin\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nfor l:=1 to a[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nfor l:=1 to b[0] do write(0);\nwriteln;\nend else\nbegin\ndec(mn);\ndec(a[q]);\ndec(b[10-q]);\ns:='';\nc:='';\n\nfor i:=1 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nfor l:=1 to k do\nbegin\ns:=s+chr(i+48);\ndec(b[i]);\ndec(a[9-i]);\nc:=c+chr(9-i+48);\nend;\nend;\nc:=c+chr(q+48);\ns:=s+chr(10-q+48);\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nwrite(s);\nfor l:=1 to b[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nwrite(c);\nfor l:=1 to a[0] do write(0);\nwriteln;\nend;\nend."}, {"source_code": "var mn,q,i,l,k,m,j,h:longint;\n a,b:array[0..9] of longint;\n s,c:string;\nfunction posh:longint;\nvar w,i:longint;\nbegin\nw:=0;\nfor i:=0 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nw:=w+k;\nend;\nposh:=w;\nend;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])-48]);\nfor i:=0 to 9 do b[i]:=a[i];\n\nfor i:=1 to 5 do\nif (a[i]>0) and (b[10-i]>0) then\nbegin\ndec(a[i]);\ndec(b[10-i]);\nm:=posh+1;\nif m>mn then\nbegin\nmn:=m;\nq:=i;\nend;\ninc(a[i],1);\ninc(b[10-i],1);\nend;\n\nif q=0 then\nbegin\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nfor l:=1 to a[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nfor l:=1 to b[0] do write(0);\nwriteln;\nend else\nbegin\ndec(mn);\ndec(a[q]);\ndec(b[10-q]);\ns:='';\nc:='';\n\nfor i:=0 to 4 do\nbegin\nk:=b[i];\nif k>a[9-i] then k:=a[9-i];\nfor l:=1 to k do\nbegin\ns:=s+chr(i+48);\ndec(b[i]);\ndec(a[9-i]);\nc:=c+chr(9-i+48);\nend;\nend;\nc:=c+chr(q+48);\ns:=s+chr(10-q+48);\nfor i:=1 to 9 do\nfor l:=1 to b[i] do write(i);\nwrite(s);\nfor l:=1 to b[0] do write(0);\nwriteln;\nfor i:=1 to 9 do\nfor l:=1 to a[i] do write(i);\nwrite(c);\nfor l:=1 to a[0] do write(0);\nwriteln;\nend;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math;\nvar\n tc1,tc2:array[0..9]of integer;\n ans1,ans2:array[1..100000]of byte;\n ch:char;\n i,j,k,tmp,c1,c2:integer;\n\nfunction pod:integer;\nvar\n l,i:integer;\nbegin\n l:=0;\n for i:=0 to 9 do\n l:=l+min(tc1[i],tc2[9-i]);\n pod:=l;\nend;\n\nbegin\n for j:=0 to 9 do\n tc1[j]:=0;\n read(ch);\n while (ch in ['0'..'9'])do\n begin\n inc(tc1[ord(ch)-ord('0')]);\n read(ch);\n end;\n k:=-maxint;\n i:=0;\n while i<=5 do\n begin\n dec(tc1[i]);\n dec(tc2[(10-i)mod 10]);\n tmp:=pod;\n inc(tc1[i]);\n inc(tc2[(10-i)mod 10]);\n if tmp>k then\n begin\n c1:=i;\n c2:=(10-i)mod 10;\n k:=tmp;\n end;\n inc(i);\n end;\n\n ans1[1]:=c1;\n ans2[1]:=c2;\n k:=1;\n for i:=0 to 9 do\n tc2[i]:=tc1[i];\n dec(tc1[c1]);\n dec(tc2[c2]);\n\n for i:=0 to 9 do\n while (tc1[i]>0)and(tc2[9-i]>0)do\n begin\n inc(k);\n dec(tc1[i]);\n dec(tc2[9-i]);\n ans1[k]:=i;\n ans2[k]:=9-i;\n end;\n c1:=k;\n c2:=k;\n for i:=0 to 9 do\n while tc1[i]>0 do\n begin\n inc(c1);\n ans1[c1]:=i;\n dec(tc1[i]);\n end;\n for i:=0 to 9 do\n while tc2[i]>0 do\n begin\n inc(c2);\n ans2[c2]:=i;\n dec(tc2[i]);\n end;\n\n for i:=c1 downto 1 do\n write(ans1[i]);\n writeln;\n for i:=c2 downto 1 do\n write(ans2[i]);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n Math;\nvar\n tc1,tc2:array[0..9]of integer;\n ans1,ans2:array[1..100000]of byte;\n ch:char;\n i,j,k,tmp,c1,c2:integer;\n\nfunction pod:integer;\nvar\n l,i:integer;\nbegin\n l:=0;\n for i:=0 to 9 do\n l:=l+min(tc1[i],tc2[9-i]);\n pod:=l;\nend;\n\nbegin\n for j:=0 to 9 do\n tc1[j]:=0;\n read(ch);\n while (ch in ['0'..'9'])do\n begin\n inc(tc1[ord(ch)-ord('0')]);\n read(ch);\n end;\n for i:=0 to 9 do\n tc2[i]:=tc1[i];\n k:=-maxint;\n i:=0;\n c1:=-1;\n while i<=5 do\n begin\n if (tc1[i]>0)and(tc2[(10-i)mod 10]>0)then\n begin\n dec(tc1[i]);\n dec(tc2[(10-i)mod 10]);\n tmp:=pod;\n inc(tc1[i]);\n inc(tc2[(10-i)mod 10]);\n if tmp>k then\n begin\n c1:=i;\n c2:=(10-i)mod 10;\n k:=tmp;\n end;\n end;\n inc(i);\n end;\n k:=0;\n if c1<>-1 then begin\n ans1[1]:=c1;\n ans2[1]:=c2;\n k:=1;\n dec(tc1[c1]);\n dec(tc2[c2]);\n\n for i:=0 to 9 do\n while (tc1[i]>0)and(tc2[9-i]>0)do\n begin\n inc(k);\n dec(tc1[i]);\n dec(tc2[9-i]);\n ans1[k]:=i;\n ans2[k]:=9-i;\n end;\n end;\n c1:=k;\n c2:=k;\n for i:=0 to 9 do\n while tc1[i]>0 do\n begin\n inc(c1);\n ans1[c1]:=i;\n dec(tc1[i]);\n end;\n for i:=0 to 9 do\n while tc2[i]>0 do\n begin\n inc(c2);\n ans2[c2]:=i;\n dec(tc2[i]);\n end;\n\n for i:=c1 downto 1 do\n write(ans1[i]);\n writeln;\n for i:=c2 downto 1 do\n write(ans2[i]);\nend.\n"}, {"source_code": "program D;\n\n{$APPTYPE CONSOLE}\nuses Math, SysUtils;\nvar s,s1,s2: string;\n a,b: array[0..9]of integer;\n i,j,n: integer;\n ok: boolean;\n\nprocedure check(x,y: integer);\nbegin\n if (a[x]>0)and(b[y]>0)then begin\n dec(a[x]);\n s1:=inttostr(x)+s1;\n s2:=inttostr(y)+s2;\n dec(b[y]);\n ok:=true;\n end;\nend;\nbegin\n s1:='';s2:='';\n readln(s);\n n:=length(s);\n for i:=0 to 9 do begin\n a[i]:=0;\n b[i]:=0;\n end;\n for i:=1 to n do begin\n inc(a[ord(s[i])-ord('0')]);\n inc(b[ord(s[i])-ord('0')]);\n end;\n ok:=false;\n check(2,8);\n if (not ok)then check(3,7);\n if (not ok)then check(4,6);\n if (not ok)then check(5,5);\n if (not ok)then check(9,1);\n for i:=0 to 9 do\n while (a[i]>0)and(b[9-i]>0)do begin\n s1:=inttostr(i)+s1;\n s2:=inttostr(9-i)+s2;\n dec(a[i]);dec(b[9-i]);\n end;\n while (a[0]>0)and(b[0]>0)do begin\n s1:=s1+'0';\n s2:=s2+'0';\n dec(a[0]);dec(b[0]);\n end;\n for i:=0 to 9 do begin\n while (a[i]>0)do begin\n s1:=inttostr(i)+s1;\n dec(a[i]);\n end;\n while (b[i]>0)do begin\n s2:=inttostr(i)+s2;\n dec(b[i]);\n end;\n end;\n writeln(s1);\n writeln(s2);\nend.\n"}, {"source_code": "const MAX_N = 100010;\n\nvar fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf,r0:longint;\n c,c2:array[0..9] of longint;\n\n\nfunction min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\nprocedure update(x,y:longint);\nbegin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\nend;\n\nprocedure solve(x,y,z:longint);\nvar i,f:longint;\nbegin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n dec(c[0],z); dec(c2[0],z);\n f:=z;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n f:=f+c[0]-min(c[0],c2[9]);\n if f > 0 then begin\n rf:=f;\n rp:=x;\n r0:=z;\n end;\n inc(c[0],z); inc(c2[0],z);\n inc(c[x]); inc(c2[y]);\nend;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1; r0:=0;\n for j:=0 to c[0] do\n for i:=1 to 5 do\n solve(i,10-i,j);\n s:=''; t:='';\n for i:=1 to r0 do update(0,0);\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n while (c[0] > 0) and (c2[0] > 0) do begin\n s:=s+'0'; dec(c[0]);\n t:=t+'0'; dec(c2[0]);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n for i:=0 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\nend.\n"}, {"source_code": "const MAX_N = 100010;\n\nvar fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf,r0:longint;\n c,c2:array[0..9] of longint;\n\n\nfunction min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\nprocedure update(x,y:longint);\nbegin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\nend;\n\nprocedure solve(x,y,z:longint);\nvar i,f:longint;\nbegin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n dec(c[0],z); dec(c2[0],z);\n f:=z;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n f:=f+c[0]-min(c[0],c2[9]);\n if f > rf then begin\n rf:=f;\n rp:=x;\n r0:=z;\n end;\n inc(c[0],z); inc(c2[0],z);\n inc(c[x]); inc(c2[y]);\nend;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1; r0:=0;\n for j:=0 to c[0] do\n for i:=1 to 5 do\n solve(i,10-i,j);\n s:=''; t:='';\n for i:=1 to r0 do update(0,0);\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n while (c[0] > 0) and (c2[0] > 0) do begin\n s:=s+'0'; dec(c[0]);\n t:=t+'0'; dec(c2[0]);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n for i:=0 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\nend.\n"}, {"source_code": "const MAX_N = 100010;\n\nvar fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf:longint;\n c,c2:array[0..9] of longint;\n\n\nfunction min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\nprocedure update(x,y:longint);\nbegin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\nend;\n\nprocedure solve(x,y:longint);\nvar i,f:longint;\nbegin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n f:=0;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n if f > 0 then begin\n rf:=f;\n rp:=x;\n end;\n inc(c[x]); inc(c2[y]);\nend;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1;\n for i:=1 to 5 do solve(i,10-i);\n s:=''; t:='';\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n for i:=1 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n while c[0] > 0 do begin s:=s+'0'; dec(c[0]); end;\n while c2[0] > 0 do begin t:=t+'0'; dec(c2[0]); end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\nend."}, {"source_code": "const MAX_N = 100010;\n\nvar fi,fo:text;\n s,t:ansiString;\n n,i,j,rp,rf:longint;\n c,c2:array[0..9] of longint;\n\n\nfunction min(x,y:longint):longint; begin if x < y then exit(x) else exit(y); end;\n\nprocedure update(x,y:longint);\nbegin\n s:=chr(x+ord('0'))+s; dec(c[x]);\n t:=chr(y+ord('0'))+t; dec(c2[y]);\nend;\n\nprocedure solve(x,y:longint);\nvar i,f:longint;\nbegin\n if (c[x] < 1) or (c2[y] < 1) then exit;\n dec(c[x]); dec(c2[y]);\n f:=0;\n for i:=0 to 9 do f:=f+min(c[i],c2[9-i]);\n f:=f+c[0]-min(c[0],c2[9]);\n if f > 0 then begin\n rf:=f;\n rp:=x;\n end;\n inc(c[x]); inc(c2[y]);\nend;\n\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n readln(fi,s);\n n:=length(s);\n for i:=0 to 9 do c[i]:=0;\n for i:=1 to n do inc(c[ord(s[i])-ord('0')]);\n c2:=c;\n rf:=0; rp:=-1;\n for i:=1 to 5 do solve(i,10-i);\n s:=''; t:='';\n if rp > 0 then begin\n update(rp,10-rp);\n for i:=0 to 9 do\n while (c[i] > 0) and (c2[9-i] > 0) do update(i,9-i);\n end;\n for i:=1 to 9 do\n while (c[i] > 0) and (c2[10-i] > 0) do update(i,10-i);\n while (c[0] > 0) and (c2[0] > 0) do begin\n s:=s+'0'; dec(c[0]);\n t:=t+'0'; dec(c2[0]);\n end;\n for i:=0 to 9 do begin\n while c[i] > 0 do begin s:=chr(i+ord('0'))+s; dec(c[i]); end;\n while c2[i] > 0 do begin t:=chr(i+ord('0'))+t; dec(c2[i]); end;\n end;\n writeln(fo,s);\n writeln(fo,t);\n close(fo);\n close(fi);\nend."}, {"source_code": "program digits_permut;\n\nuses math;\nconst\n fi='';\n fo='';\n tt = ord('0');\n oo = trunc(1e9);\ntype\n stri = ansistring;\nvar\n n:stri;\n a1,a2,b1,b2:array[0..9] of longint;\n s1,s2:stri;\nprocedure openfile;\nvar\n i:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(n);\n fillchar(a1,sizeof(a1),0);\n for i:=1 to length(n) do\n begin\n inc(a1[ord(n[i])-tt]);\n end;\n a2:=a1;\nend;\n//-------------------\nprocedure process;\nvar\n i,j:longint;\n s,p:longint;\n kq,jm:longint;\nbegin\n kq:=-oo;\n for i:=1 to 9 do\n if (a1[i]>0)and(a2[10-i]>0) then\n begin\n b1:=a1;\n b2:=a2;\n s:=1;\n dec(b1[i]);dec(b2[10-i]);\n for j:=0 to 9 do\n begin\n p:=min(b1[j],b2[9-j]);\n dec(b1[j],p);dec(b2[9-j],p);\n s:=s+p;\n end;\n inc(s,min(b1[0],b2[0]));\n if s>kq then\n begin\n kq:=s;\n jm:=i;\n end;\n end;\n if kq=-oo then\n begin\n writeln(n);\n writeln(n);\n exit;\n end;\n s1:='';s2:='';\n dec(a1[jm]);\n dec(a2[10-jm]);\n for i:=1 to 1 do\n begin\n s1:=chr(jm+tt)+s1;\n s2:=chr(10-jm+tt)+s2;\n end;\n for i:=0 to 9 do\n begin\n p:=min(a1[i],a2[9-i]);\n dec(a1[i],p);dec(a2[9-i],p);\n for j:=1 to p do\n begin\n s1:=chr(i+tt)+s1;\n s2:=chr(9-i+tt)+s2;\n end;\n end;\n p:=min(a1[0],a2[0]);\n dec(a1[0],p);dec(a2[0],p);\n for i:=1 to p do\n begin\n s1:=s1+'0';\n s2:=s2+'0';\n end;\n for i:=0 to 9 do\n begin\n if a1[i]>0 then\n for j:=1 to a1[i] do s1:=chr(i+tt)+s1;\n if a2[i]>0 then\n for j:=1 to a2[i] do s2:=chr(i+tt)+s2;\n end;\n writeln(s1);\n writeln(s2);\nend;\n//--------------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "uses math;\nvar\n i,n,count,j,t,res,ires,mres,tmp: longint;\n s: ansistring;\n r1,r2: array[0..9,0..100000] of longint;\n c,d,e: array[0..9] of longint;\n ck: boolean;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n inc(d[ord(s[i])-48]);\n end;\n n:=length(s);\n\n for i:=1 to 9 do\n begin\n c:=d;\n e:=d;\n\n count:=0;\n\n if ((c[i]<1) or (e[10-i]<1)) then continue;\n dec(c[i]); dec(e[10-i]);\n r1[i,1]:=i; r2[i,1]:=10-i;\n ck:=true;\n for j:=2 to n do\n begin\n if ck=true then\n begin\n ck:=false;\n for t:=0 to 9 do\n begin\n if (c[t]>0) and (e[9-t]>0) then\n begin\n inc(count);\n cK:=true;\n dec(c[t]); dec(e[9-t]);\n r1[i,j]:=t; r2[i,j]:=9-t;\n if count>res then\n begin\n res:=count;\n ires:=i;\n mres:=0;\n end;\n break;\n end;\n end;\n end;\n if not ck then\n begin\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n if count+tmp>res then\n begin\n res:=count+tmp;\n ires:=i;\n mres:=tmp;\n end;\n for t:=0 to 9 do\n begin\n if (c[t]>0)and(r1[i,j]=0) then\n begin\n r1[i,j]:=t;\n dec(c[t]);\n end;\n if (e[t]>0)and(r2[i,j]=0) then\n begin\n r2[i,j]:=t;\n dec(e[t]);\n end;\n end;\n end;\n end;\n end;\n if res<>0 then\n begin\n tmp:=mres;\n\n for i:=n-tmp downto 1 do write(r1[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1 do write(r2[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n end\n else\n begin\n\n c:=d; e:=d;\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n for j:=1 to n do\n for t:=0 to 9 do\n begin\n if c[t]>0 then\n begin\n r1[1,j]:=t;\n dec(c[t]);\n end;\n if e[t]>0 then\n begin\n r2[1,j]:=t;\n dec(e[t]);\n end;\n end;\n\n for i:=n-tmp downto 1 do write(r1[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1do write(r2[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n end;\nend.\n\n"}, {"source_code": "uses math;\nvar\n i,n,count,j,t,res,ires,mres,tmp: longint;\n s: ansistring;\n r1,r2: array[0..9,0..100000] of longint;\n c,d,e: array[0..9] of longint;\n ck: boolean;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n inc(d[ord(s[i])-48]);\n end;\n n:=length(s);\n\n for i:=1 to 9 do\n begin\n c:=d;\n e:=d;\n\n count:=0;\n\n if ((c[i]<1) or (e[10-i]<1)) then continue;\n dec(c[i]); dec(e[10-i]);\n r1[i,1]:=i; r2[i,1]:=10-i;\n ck:=true;\n for j:=2 to n do\n begin\n if ck=true then\n begin\n ck:=false;\n for t:=0 to 9 do\n begin\n if (c[t]>0) and (e[9-t]>0) then\n begin\n inc(count);\n cK:=true;\n dec(c[t]); dec(e[9-t]);\n r1[i,j]:=t; r2[i,j]:=9-t;\n if count>res then\n begin\n res:=count;\n ires:=i;\n mres:=0;\n end;\n break;\n end;\n end;\n end;\n if not ck then\n begin\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n if count+tmp>res then\n begin\n res:=count+tmp;\n ires:=i;\n mres:=tmp;\n end;\n for t:=0 to 9 do\n begin\n if (c[t]>0)and(r1[i,j]=0) then\n begin\n r1[i,j]:=t;\n dec(c[t]);\n end;\n if (e[t]>0)and(r2[i,j]=0) then\n begin\n r2[i,j]:=t;\n dec(e[t]);\n end;\n end;\n end;\n end;\n end;\n if res<>0 then\n begin\n tmp:=mres;\n\n for i:=n-tmp downto 1 do write(r1[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1 do write(r2[ires,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n end\n else\n begin\n\n c:=d; e:=d;\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n for j:=1 to n do\n for t:=0 to 9 do\n begin\n if (c[t]>0)and(r1[1,j]=0) then\n begin\n r1[1,j]:=t;\n dec(c[t]);\n end;\n if (e[t]>0)and(r2[1,j]=0) then\n begin\n r2[1,j]:=t;\n dec(e[t]);\n end;\n end;\n\n for i:=n-tmp downto 1 do write(r1[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n for i:=n-tmp downto 1do write(r2[1,i]);\n for i:=tmp downto 1 do write(0);\n\n writeln;\n\n end;\nend.\n\n"}, {"source_code": "uses math;\nvar\n i,n,count,j,t,res,ires,mres,tmp: longint;\n s: ansistring;\n r1,r2: array[0..9,0..100000] of longint;\n c,d,e: array[0..9] of longint;\n ck: boolean;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n inc(d[ord(s[i])-48]);\n end;\n n:=length(s);\n\n for i:=1 to 9 do\n begin\n c:=d;\n e:=d;\n\n count:=0;\n\n if ((c[i]<1) and (e[10-i]<1)) then continue;\n dec(c[i]); dec(e[10-i]);\n r1[i,1]:=i; r2[i,1]:=10-i;\n ck:=true;\n for j:=2 to n do\n begin\n if ck=true then\n begin\n ck:=false;\n for t:=0 to 9 do\n begin\n if (c[t]>0) and (e[9-t]>0) then\n begin\n inc(count);\n cK:=true;\n dec(c[t]); dec(e[9-t]);\n r1[i,j]:=t; r2[i,j]:=9-t;\n if count>res then\n begin\n res:=count;\n ires:=i;\n mres:=0;\n end;\n end;\n end;\n end;\n if not ck then\n begin\n tmp:=math.min(c[0],e[0]);\n c[0]:=c[0]-tmp;\n e[0]:=e[0]-tmp;\n if count+tmp>res then\n begin\n res:=count+tmp;\n ires:=i;\n mres:=tmp;\n end;\n for t:=0 to 9 do\n begin\n if c[t]>0 then\n begin\n r1[i,j]:=t;\n dec(c[t]);\n end;\n if e[t]>0 then\n begin\n r2[i,j]:=t;\n dec(e[t]);\n end;\n end;\n end;\n end;\n end;\n tmp:=mres;\n for i:=n-tmp downto 1 do write(r1[ires,i]);\n for i:=tmp downto 1 do write(0);\n writeln;\n for i:=n-tmp downto 1 do write(r2[ires,i]);\n for i:=tmp downto 1 do write(0);\n writeln;\nend.\n\n"}, {"source_code": "var\n n,m,i,j,k,nn,ans:longint;\n a,b,c,d,ansa,ansb:array[0..9]of longint;\nprocedure dfs(x,y:longint);\nvar\n i,j:longint;\nbegin\n if x=nn then begin\n if ans0)and(d[y-i]>0) then begin\n dec(a[i]);\n dec(d[y-i]);\n inc(b[0]);\n b[b[0]]:=i;\n inc(c[0]);\n c[c[0]]:=y-i;\n dfs(x+1,9);\n dec(c[0]);\n dec(b[0]);\n inc(a[i]);\n inc(d[y-i]);\n end;\n end;\n for i:=1 to 9 do begin\n for j:=1 to 9 do begin\n if (a[i]>0)and(d[j]>0) then begin\n dec(a[i]);\n dec(d[j]);\n inc(b[0]);\n b[b[0]]:=i;\n inc(c[0]);\n c[c[0]]:=j;\n dfs(x+1,x*10+10);\n dec(c[0]);\n dec(b[0]);\n inc(a[i]);\n inc(d[j]);\n end;\n end;\n end;\nend;\nbegin\n readln(n);\n nn:=0;\n while n>0 do begin\n inc(a[n mod 10]);\n n:=n div 10;\n inc(nn);\n end;\n for i:=1 to a[0] do begin\n j:=0;\n inc(b[0]);\n inc(c[0]);\n end;\n d:=a;\n ans:=0;\n dfs(a[0],10);\n for i:=nn downto 1 do write(ansb[i]);\n writeln;\n for i:=nn downto 1 do write(ansa[i]);\n writeln;\nend.\n"}, {"source_code": "var\n a:array[1..100000]of longint;\n b,c,d,e:array[0..9]of longint;\n s:ansistring;\n n,i,j,k,l,o:longint;\n ansa,ansb:array[0..100000]of longint;\n ans:array[1..9]of longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0)and(c[10-i]>0) then begin\n dec(b[i]);\n dec(c[10-i]);\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n l:=l+b[j];\n end;\n end;\n ans[i]:=l+c[0]-b[9]+c[0]-b[0];\n if ans[i]>ans[o] then o:=i;\n end;\n b:=d; c:=e;\n dec(b[o]);\n dec(d[o]);\n dec(c[10-o]);\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n end;\n ansa[0]:=min(c[0]-b[0],c[0]-b[9]);\n ansb[0]:=ansa[0];\n d[0]:=d[0]-ansa[0];\n c[0]:=c[0]-ansb[0];\n inc(ansa[0]);\n ansa[ansa[0]]:=o;\n inc(ansb[0]);\n ansb[ansb[0]]:=10-o;\n for i:=0 to 9 do begin\n for j:=1 to b[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n dec(d[i]);\n inc(ansb[0]);\n ansb[ansb[0]]:=9-i;\n dec(c[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to d[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n end;\n for j:=1 to c[i] do begin\n inc(ansb[0]);\n ansb[ansb[0]]:=i;\n end;\n end;\n for i:=ansa[0] downto 1 do write(ansa[i]);\n writeln;\n for i:=ansb[0] downto 1 do write(ansb[i]);\n writeln;\nend.\n"}, {"source_code": "var\n a:array[1..100000]of longint;\n b,c,d,e:array[0..9]of longint;\n s:ansistring;\n pk:boolean;\n n,i,j,k,l,o:longint;\n ansa,ansb:array[0..100000]of longint;\n ans:array[1..9]of longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0)and(c[10-i]>0) then begin\n dec(b[i]);\n dec(c[10-i]);\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n l:=l+b[j];\n end;\n end else o:=i;\n ans[i]:=l+c[0]-b[9]+c[0]-b[0];\n if ans[i]>ans[o] then o:=i;\n end;\n b:=d; c:=e;\n pk:=false; \n if (d[o]>0)and(c[10-o]>0) then begin\n dec(b[o]);\n pk:=true;\n dec(d[o]);\n dec(c[10-o]);\n end;\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n end;\n ansa[0]:=min(c[0]-b[0],c[0]-b[9]);\n ansb[0]:=ansa[0];\n d[0]:=d[0]-ansa[0];\n c[0]:=c[0]-ansb[0];\n if pk then begin\n inc(ansa[0]);\n ansa[ansa[0]]:=o;\n inc(ansb[0]);\n ansb[ansb[0]]:=10-o;\n end;\n for i:=0 to 9 do begin\n for j:=1 to b[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n dec(d[i]);\n inc(ansb[0]);\n ansb[ansb[0]]:=9-i;\n dec(c[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to d[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n end;\n for j:=1 to c[i] do begin\n inc(ansb[0]);\n ansb[ansb[0]]:=i;\n end;\n end;\n for i:=ansa[0] downto 1 do write(ansa[i]);\n writeln;\n for i:=ansb[0] downto 1 do write(ansb[i]);\n writeln;\nend.\n"}, {"source_code": "var\n a:array[1..100000]of longint;\n b,c,d,e:array[0..9]of longint;\n s:ansistring;\n pk:boolean;\n n,i,j,k,l,o:longint;\n ansa,ansb:array[0..100000]of longint;\n ans:array[1..9]of longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0)and(c[10-i]>0) then begin\n dec(b[i]);\n dec(c[10-i]);\n l:=1;\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n l:=l+b[j];\n end;\n end; \n ans[i]:=l+c[0]-b[9]+c[0]-b[0];\n if ans[i]>ans[o] then o:=i;\n end;\n b:=d; c:=e;\n pk:=false;\n if (d[o]>0)and(c[10-o]>0) then begin\n dec(b[o]);\n pk:=true;\n dec(d[o]);\n dec(c[10-o]);\n end;\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n end;\n ansa[0]:=min(c[0]-b[0],c[0]-b[9]);\n ansb[0]:=ansa[0];\n d[0]:=d[0]-ansa[0];\n c[0]:=c[0]-ansb[0];\n if pk then begin\n inc(ansa[0]);\n ansa[ansa[0]]:=o;\n inc(ansb[0]);\n ansb[ansb[0]]:=10-o;\n end;\n for i:=0 to 9 do begin\n for j:=1 to b[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n dec(d[i]);\n inc(ansb[0]);\n ansb[ansb[0]]:=9-i;\n dec(c[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to d[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n end;\n for j:=1 to c[i] do begin\n inc(ansb[0]);\n ansb[ansb[0]]:=i;\n end;\n end;\n for i:=ansa[0] downto 1 do write(ansa[i]);\n writeln;\n for i:=ansb[0] downto 1 do write(ansb[i]);\n writeln;\nend.\n"}, {"source_code": "var\n a:array[1..100000]of longint;\n b,c,d,e:array[0..9]of longint;\n s:ansistring;\n n,i,j,k,l,o:longint;\n ansa,ansb:array[0..100000]of longint;\n ans:array[1..9]of longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0)and(c[10-i]>0) then begin\n dec(b[i]);\n dec(c[10-i]);\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n l:=l+b[j];\n end;\n end;\n ans[i]:=l+c[0]-b[9]+c[0]-b[0];\n if ans[i]>ans[o] then o:=i;\n end;\n b:=d; c:=e;\n dec(b[o]);\n dec(d[o]);\n dec(c[10-o]);\n for j:=0 to 9 do begin\n b[j]:=min(b[j],c[9-j]);\n end;\n ansa[0]:=c[0]-b[0];\n ansb[0]:=c[0]-b[9];\n d[0]:=d[0]-ansa[0];\n c[0]:=c[0]-ansb[0];\n inc(ansa[0]);\n ansa[ansa[0]]:=o;\n inc(ansb[0]);\n ansb[ansb[0]]:=10-o;\n for i:=0 to 9 do begin\n for j:=1 to b[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n dec(d[i]);\n inc(ansb[0]);\n ansb[ansb[0]]:=9-i;\n dec(c[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to d[i] do begin\n inc(ansa[0]);\n ansa[ansa[0]]:=i;\n end;\n for j:=1 to c[i] do begin\n inc(ansb[0]);\n ansb[ansb[0]]:=i;\n end;\n end;\n for i:=ansa[0] downto 1 do write(ansa[i]);\n writeln;\n for i:=ansb[0] downto 1 do write(ansb[i]);\n writeln;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:string;\n n,kq,max,x,dis:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=queo;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n u:=10-i;\n if b[u]>0 then\n begin\n dec(a[i]); dec(b[u]);\n r1:=chr(i+48)+r1; r2:=chr(u+48)+r2;\n break;\n end;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:string;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=1 to a[0] do r1:=r1+'0';\n for i:=1 to b[0] do r2:=r2+'0';\n for i:=1 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=1 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=1 to a[0] do r1:=r1+'0';\n for i:=1 to b[0] do r2:=r2+'0';\n for i:=1 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=1 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:string;\n n,kq,max,x,dis:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=queo;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=queo;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n u:=10-i;\n if b[u]>0 then\n begin\n dec(a[i]); dec(b[u]);\n r1:=chr(i+48)+r1; r2:=chr(u+48)+r2;\n break;\n end;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:string;\n n,kq,max,x,dis:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=queo;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>=max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:string;\n n,kq,max,x,dis:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=0;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end; \n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n for i:=9 downto 0 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=9 downto 0 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n"}, {"source_code": "uses math;\nconst\n fi='';\nvar\n f:text;\n s,r1,r2:ansistring;\n n,kq,max,x,dis,l1,l2:longint;\n a,b,c,d:array [0..9] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n for i:=1 to n do inc(a[ord(s[i])-48]);\n for i:=0 to 9 do b[i]:=a[i];\n dis:=1;\n kq:=-1;\n close(f);\nend;\nprocedure cc;\nvar\n i,j,u,v,queo:longint;\nbegin\n c:=a; d:=b;\n v:=math.min(a[0],b[0]);\n if v=0 then exit;\n queo:=v;\n c[0]:=c[0]-v; d[0]:=d[0]-v;\n if queo>max then\n begin\n dis:=0;\n kq:=0;\n max:=queo;\n l1:=-1;\n end;\n for i:=1 to 9 do\n if c[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if d[u]<=0 then continue;\n dec(c[i]); dec(d[u]);\n x:=queo+1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(c[j],d[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n dis:=0;\n l1:=i; l2:=u;\n end;\n inc(c[i]); inc(d[u]);\n end;\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=1 to 9 do\n if a[i]>0 then\n begin\n if i=0 then u:=0\n else u:=10-i;\n if b[u]<=0 then continue;\n dec(a[i]); dec(b[u]);\n x:=1;\n for j:=0 to 9 do\n begin\n v:=9-j;\n x:=x+math.min(a[j],b[v]);\n end;\n if x>max then\n begin\n max:=x;\n kq:=i;\n end;\n inc(a[i]); inc(b[u]);\n end;\nend;\nprocedure lam;\nvar\n i,j,u,v:longint;\nbegin\n if kq=-1 then\n begin\n writeln(s);\n writeln(s);\n halt;\n end;\n if dis=0 then\n begin\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:='0'+r1;\n for i:=1 to v do r2:='0'+r2;\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n if l1<>-1 then\n begin\n dec(a[l1]); dec(b[l2]);\n r1:=chr(l1+48)+r1;\n r2:=chr(l2+48)+r2;\n end;\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end\n else\n begin\n r1:=chr(kq+48);\n dec(a[kq]);\n v:=10-kq;\n r2:=chr(v+48);\n dec(b[v]);\n for i:=0 to 9 do\n if a[i]>0 then\n begin\n u:=9-i;\n if b[u]<=0 then continue;\n v:=math.min(a[i],b[u]);\n a[i]:=a[i]-v; b[u]:=b[u]-v;\n for j:=1 to v do r1:=chr(i+48)+r1;\n for j:=1 to v do r2:=chr(u+48)+r2;\n end;\n v:=math.min(a[0],b[0]);\n for i:=1 to v do r1:=r1+'0';\n for i:=1 to v do r2:=r2+'0';\n a[0]:=a[0]-v; b[0]:=b[0]-v;\n for i:=0 to 9 do\n for j:=1 to a[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b[i] do r2:=chr(i+48)+r2;\n end;\n writeln(r1);\n writeln(r2);\nend;\nbegin\n nhap;\n xuly;\n cc;\n lam;\nend.\n\n"}, {"source_code": "Program cf99b;\nconst ch:array[0..9] of char='0123456789';\nvar t,a,b,c:array[0..9] of longint;\n n,i,j,k,l,pre,best,cur,cp,d:longint;\n cc:char;\nfunction min(a,b:longint):longint;\nbegin\n if a=2))\n or ((i<>5) and (t[i]>=1) and (t[10-i]>=1))\n then\n begin\n for j:=0 to 9 do begin a[j]:=t[j];b[j]:=t[j];end;\n a[i]:=a[i]-1;\n b[10-i]:=b[10-i]-1;\n cur:=calc()+min(a[0]-min(a[0],b[9]),b[0]-min(b[0],a[9]))+1;\n if cur>best then\n begin\n best:=cur;\n cp:=i;\n end;\n end;\n if cp=0 then\n begin\n for i:=1 to 10 do\n for j:=1 to t[i mod 10] do\n write(i mod 10);\n writeln;\n for i:=1 to 10 do\n for j:=1 to t[i mod 10] do\n write(i mod 10);\n end\n else\n begin\n a:=t;b:=t;\n a[cp]:=a[cp]-1;\n b[10-cp]:=b[10-cp]-1;\n pre:=min(a[0]-min(a[0],b[9]),b[0]-min(b[0],a[9]));\n a[0]:=a[0]-pre;b[0]:=b[0]-pre;\n for i:=0 to 9 do c[i]:=min(a[i],b[9-i]);\n for i:=0 to 9 do a[i]:=a[i]-c[i];\n for i:=0 to 9 do b[9-i]:=b[9-i]-c[i];\n for i:=0 to 9 do\n if a[i]>0 then\n for j:=1 to a[i] do write(ch[i]);\n for i:=0 to 9 do\n if c[i]>0 then\n for j:=1 to c[i] do write(ch[i]);\n write(ch[cp]);\n for i:=1 to pre do write('0');\n writeln;\n for i:=0 to 9 do\n if b[i]>0 then\n for j:=1 to b[i] do write(ch[i]);\n for i:=0 to 9 do\n if c[i]>0 then\n for j:=1 to c[i] do write(ch[9-i]);\n write(ch[10-cp]);\n for i:=1 to pre do write('0');\n end;\nend."}, {"source_code": "Var a,b:array[0..123]of longint;\nans:array[0..100333,1..2]of longint;\ni,j,k,kk,x,p:longint;\ns:ansistring;\n begin\n readln(s);\n for i:=1 to length(s) do\n inc(a[ord(s[i])-48]);\n for i:=0 to 9 do\n b[i]:=a[i];\n k:=0;\n x:=0;\n for i:=0 to 9 do\n begin\n while (a[i]>0)and(b[(10-i-x)mod 10]>0) do\n begin\n inc(k);\n ans[k,1]:=i;\n ans[k,2]:=(10-i-x)mod 10;\n dec(a[i]);\n dec(b[(10-i-x)mod 10]);\n if (i<>0)or((10-i-x)mod 10<>0) then x:=1\n else x:=0;\n end;\n end;\n kk:=k;\n for i:=0 to 9 do\n for j:=1 to a[i] do\n begin\n inc(k);\n ans[k,1]:=i;\n end;\n for i:=0 to 9 do\n for j:=1 to b[i] do\n begin\n inc(kk);\n ans[kk,2]:=i;\n end;\n for i:=k downto 1 do\n Write(ans[i,1]);\n Writeln;\n for i:=k downto 1 do\n Write(ans[i,2]);\n Writeln;\n end."}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n nmax = 100 * 1000 + 100;\n\nvar n : longint;\n s : string;\n a, b : array[1 .. nmax] of longint;\n c1, c2 : array[0 .. 9] of longint;\n\nprocedure pout;\nvar i : longint;\nbegin\n for i := 1 to n do begin\n write(a[i]);\n end;\n writeln;\n for i := 1 to n do begin\n write(b[i]);\n end;\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n readln(s);\nend;\n\nfunction get(x : longint) : longint;\nvar i : longint;\nbegin\n result := 0;\n if c1[x] = 0 then exit;\n if c2[10 - x] = 0 then exit;\n dec(c1[x]);\n dec(c2[10 - x]);\n result := 1;\n for i := 0 to 9 do begin\n inc(result, min(c1[i], c2[9 - i]));\n end;\n inc(c1[x]);\n inc(c2[10 - x]);\nend;\n\nprocedure solve;\nvar i, ans, ind, an, r, t1, t2, j, c10, nul0 : longint;\nbegin\n n := length(s);\n fillchar(c1, sizeof(c1), 0);\n fillchar(a, sizeof(a), 0);\n fillchar(b, sizeof(b), 0);\n for i := 1 to n do begin\n inc(c1[strtoint(s[i])]);\n end;\n c2 := c1;\n ans := -1;\n ind := 0;\n r := 0;\n c10 := c1[0];\n for nul0 := 0 to c10 do begin\n for i := 9 downto 1 do begin\n an := get(i) + nul0;\n if an > ans then begin\n ans := an;\n ind := i;\n r := nul0;\n end;\n end;\n dec(c1[0]);\n dec(c2[0]);\n end;\n c1[0] := c10 - r;\n c2[0] := c10 - r;\n if ans <> 0 then begin\n a[n - r] := ind;\n b[n - r] := 10 - ind;\n dec(c1[ind]);\n dec(c2[10 - ind]);\n j := 9;\n t1 := 0;\n t2 := 0;\n inc(r);\n end\n else begin\n j := -1;\n t1 := 0;\n t2 := 0;\n end;\n for i := n - r downto 1 do begin\n while (j > -1) and (min(c1[j], c2[9 - j]) = 0) do begin\n dec(j);\n end;\n if j > -1 then begin\n a[i] := j;\n b[i] := 9 - j;\n dec(c1[j]);\n dec(c2[9 - j]);\n end\n else begin\n while (t1 < 10) and (c1[t1] = 0) do begin\n inc(t1);\n end;\n if t1 < 10 then begin\n a[i] := t1;\n dec(c1[t1]);\n end\n else begin\n writeln('WTF?!1');\n halt(3);\n end;\n while (t2 < 10) and (c2[t2] = 0) do begin\n inc(t2);\n end;\n if t2 < 10 then begin\n b[i] := t2;\n dec(c2[t2]);\n end\n else begin\n writeln('WTF?!2');\n halt(3);\n end;\n end;\n end;\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n nmax = 100 * 1000 + 100;\n\nvar n : longint;\n s : string;\n a, b : array[1 .. nmax] of longint;\n c1, c2 : array[0 .. 9] of longint;\n\nprocedure pout;\nvar i : longint;\nbegin\n for i := 1 to n do begin\n write(a[i]);\n end;\n writeln;\n for i := 1 to n do begin\n write(b[i]);\n end;\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n readln(s);\nend;\n\nfunction get(x : longint) : longint;\nvar i : longint;\nbegin\n result := 0;\n if c1[x] = 0 then exit;\n if c2[10 - x] = 0 then exit;\n dec(c1[x]);\n dec(c2[10 - x]);\n result := 1;\n for i := 0 to 9 do begin\n inc(result, min(c1[i], c2[9 - i]));\n end;\n inc(c1[x]);\n inc(c2[10 - x]);\nend;\n\nprocedure solve;\nvar i, ans, ind, an, r, t1, t2, j, c10, nul0 : longint;\nbegin\n n := length(s);\n fillchar(c1, sizeof(c1), 0);\n fillchar(a, sizeof(a), 0);\n fillchar(b, sizeof(b), 0);\n for i := 1 to n do begin\n inc(c1[strtoint(s[i])]);\n end;\n c2 := c1;\n ans := -1;\n ind := 0;\n r := 0;\n c10 := c1[0];\n for nul0 := 0 to c10 do begin\n for i := 9 downto 1 do begin\n an := get(i);\n if an + nul0 > ans then begin\n ans := an;\n ind := i;\n r := nul0;\n end;\n end;\n dec(c1[0]);\n dec(c2[0]);\n end;\n c1[0] := c10 - r;\n c2[0] := c10 - r;\n if ans <> 0 then begin\n a[n - r] := ind;\n b[n - r] := 10 - ind;\n dec(c1[ind]);\n dec(c2[10 - ind]);\n j := 9;\n t1 := 0;\n t2 := 0;\n inc(r);\n end\n else begin\n j := -1;\n t1 := 0;\n t2 := 0;\n end;\n for i := n - r downto 1 do begin\n while (j > -1) and (min(c1[j], c2[9 - j]) = 0) do begin\n dec(j);\n end;\n if j > -1 then begin\n a[i] := j;\n b[i] := 9 - j;\n dec(c1[j]);\n dec(c2[9 - j]);\n end\n else begin\n while (t1 < 10) and (c1[t1] = 0) do begin\n inc(t1);\n end;\n if t1 < 10 then begin\n a[i] := t1;\n dec(c1[t1]);\n end\n else begin\n writeln('WTF?!1');\n halt(3);\n end;\n while (t2 < 10) and (c2[t2] = 0) do begin\n inc(t2);\n end;\n if t2 < 10 then begin\n b[i] := t2;\n dec(c2[t2]);\n end\n else begin\n writeln('WTF?!2');\n halt(3);\n end;\n end;\n end;\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "{$H+}\nvar\na1:string;\nnum,pre,prepre,vxod,max,alter:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nif dozv=1 then begin\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nfor i:=1 downto 1 do\nif(verx[i]+nizz[i]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max0)then begin\n max:=pre;\n vxod:=num;\n end else\nif (prepre>0)then alter:=num;\nend;\nif vxod>0 then\npoisk(a1,vxod,1)else poisk(a1,alter,1);\nend."}, {"source_code": "{$H+}\nvar\na1:string;\nnum,pre,prepre,vxod,max,alter:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nif dozv=1 then begin\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nif(verx[1]+nizz[1]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max0 then\npoisk(a1,vxod,1)else poisk(a1,alter,1);\nend."}, {"source_code": "{$H+}\nvar\na1:string;\nnum,pre,prepre,vxod,max:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nif dozv=1 then begin\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nif(verx[1]+nizz[1]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max0)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nk:=min(c[0],s[0]);\nc[0]:=c[0]-k;s[0]:=s[0]-k;\nfor j:=0 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=0 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\n{k:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;}\nd:=i;\nif dozv=1 then begin\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nif(verx[1]+nizz[1]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max=1)then begin\n max:=pre;\n vxod:=num;\n end;\nif (prepre>=1)then alter:=num;\nend;\nif vxod>0 then\npoisk(a1,vxod,1)else poisk(a1,alter,1);\nend."}, {"source_code": "{$H+}\nvar\nc,s:array[0..9]of longint;\nverx,nizz:array[1..100000]of byte;\na:string;\n\nd,i,p,nach,mini,vt,j:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[s[0]+1]:=9;nizz[s[0]+1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end else\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[s[0]+1]:=5;nizz[s[0]+1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end else\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[s[0]+1]:=8;nizz[s[0]+1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end else\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[s[0]+1]:=7;nizz[s[0]+1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end else\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[s[0]+1]:=6;nizz[s[0]+1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n for i:=nach to nach+c[j] do verx[i]:=j;\n nach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n for i:=nach to nach+s[j] do nizz[i]:=j;\n nach:=nach+s[j];\nend;\nfor i:=d downto 1 do write(verx[i]);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);\nwriteln;\nend."}, {"source_code": "{$H+}\nvar\na1:string;\nnum,pre,prepre,vxod,max,alter:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end;\nif b=2 then\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end;\nif b=3 then\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end;\nif b=4 then\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end;\nif b=5 then\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nif dozv=1 then begin\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend;\npre:=0;prepre:=0;\nfor i:=d downto 1 do\n if(verx[i]+nizz[i]=9)then inc(pre);\nfor i:=d downto 1 do\nif(verx[i]+nizz[i]=10)then inc(prepre);\nend;\nbegin\nread(a1);\nmax:=0;\nfor num:=1 to 5 do begin\npoisk(a1,num,0);\nif (max0)then begin\n max:=pre;\n vxod:=num;\n end;\nif (prepre>0)then alter:=num;\nend;\nif vxod>0 then\npoisk(a1,vxod,1)else poisk(a1,alter,1);\nend."}, {"source_code": "{$H+}\nvar\nc,s:array[0..9]of longint;\nverx,nizz:array[1..100000]of byte;\na:string;\nd,i,p,nach,mini,vt,j,k:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end else\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end else\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end else\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end else\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend."}, {"source_code": "{$H+}\nvar\nc,s:array[0..9]of longint;\nverx,nizz:array[1..100000]of byte;\na:string;\nd,i,p,nach,mini,vt,j,k:longint;\nfunction min(a1,a2:longint):longint;\nbegin\n if a10)and(s[1]<>0)then begin\n verx[1]:=9;nizz[1]:=1;\n dec(c[9]);dec(s[1]);inc(nach);\n end else\n if (c[5]<>0)and(s[5]<>0)then begin\n verx[1]:=5;nizz[1]:=5;\n dec(c[5]);dec(s[5]);inc(nach);\n end else\n if (c[8]<>0)and(s[2]<>0)then begin\n verx[1]:=8;nizz[1]:=2;\n dec(c[8]);dec(s[2]);inc(nach);\n end else\n if (c[7]<>0)and(s[3]<>0)then begin\n verx[1]:=7;nizz[1]:=3;\n dec(c[7]);dec(s[3]);inc(nach);\n end else\n if (c[6]<>0)and(s[4]<>0)then begin\n verx[1]:=6;nizz[1]:=4;\n dec(c[6]);dec(s[4]);inc(nach);\n end;\nmini:=min(c[0],s[9]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=0;nizz[i]:=9;\n end;\n c[0]:=c[0]-mini;s[9]:=s[9]-mini;\nnach:=nach+mini;\nmini:=min(c[1],s[8]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=1;nizz[i]:=8;\n end;\n c[1]:=c[1]-mini;s[8]:=s[8]-mini;\nnach:=nach+mini;\nmini:=min(c[2],s[7]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=2;nizz[i]:=7;\n end;\n c[2]:=c[2]-mini;s[7]:=s[7]-mini;\nnach:=nach+mini;\nmini:=min(c[3],s[6]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=3;nizz[i]:=6;\n end;\n c[3]:=c[3]-mini;s[6]:=s[6]-mini;\nnach:=nach+mini;\nmini:=min(c[4],s[5]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=4;nizz[i]:=5;\n end;\n c[4]:=c[4]-mini;s[5]:=s[5]-mini;\nnach:=nach+mini;\nmini:=min(c[5],s[4]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=5;nizz[i]:=4;\n end;\n c[5]:=c[5]-mini;s[4]:=s[4]-mini;\nnach:=nach+mini;\nmini:=min(c[6],s[3]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=6;nizz[i]:=3;\n end;\n c[6]:=c[6]-mini;s[3]:=s[3]-mini;\nnach:=nach+mini;\nmini:=min(c[7],s[2]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=7;nizz[i]:=2;\n end;\n c[7]:=c[7]-mini;s[2]:=s[2]-mini;\nnach:=nach+mini;\nmini:=min(c[8],s[1]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=8;nizz[i]:=1;\n end;\n c[8]:=c[8]-mini;s[1]:=s[1]-mini;\nnach:=nach+mini;\nmini:=min(c[9],s[0]);\nfor i:=nach to nach+mini-1 do begin\n verx[i]:=9;nizz[i]:=0;\n end;\n c[9]:=c[9]-mini;s[0]:=s[0]-mini;\nnach:=nach+mini;vt:=nach;\nfor j:=1 to 9 do begin\n if c[j]<>0 then\n for i:=nach to nach+c[j]-1 do begin\n verx[i]:=j;\n end;\nnach:=nach+c[j];\nend;\nnach:=vt;\nfor j:=1 to 9 do begin\n if s[j]<>0 then\n for i:=nach to nach+s[j]-1 do begin\n nizz[i]:=j;\n end;\nnach:=nach+s[j];\nend;\nk:=0;\nfor i:=d downto 1 do\n if (verx[i]=0)and(nizz[i]=0)then inc(k) else break;\nd:=i;\nfor i:=d downto 1 do write(verx[i]);for i:=1 to k do write(0);\nwriteln;\nfor i:=d downto 1 do write(nizz[i]);for i:=1 to k do write(0);\nwriteln;\nend."}, {"source_code": "program fda;\ntype\n arr=array[0..10] of longint;\nvar\n s:ansistring;\n i,j,k,e,t,n,m:longint;\n a:arr;\n b:arr;\n ans:arr;//ans:array[0..10] of longint;\n ans1,ans2:longint;\n s1,s2,ss:ansistring;\nfunction min(x,y:longint):longint;\nbegin\n if xans1 then begin\n ans1:=k;\n ans:=c;\n ans2:=m;\n end;\nend;\nbegin\n readln(s);\n for i:=1 to length(s) do begin\n val(s[i],j);\n inc(a[j]);\n inc(b[j]);\n end;\n ans[10]:=min(a[0],b[0])-1;\n ans1:=ans[10]-1;\n ans2:=0;\n for i:=1 to 9 do begin\n if (a[i]>0) and (b[10-i]>0) then begin\n dec(a[i]);\n dec(b[10-i]);\n m:=i;\n work(a,b);\n inc(a[i]);\n inc(b[10-i]);\n end;\n end;\n str(ans2,s1);\n str((10-ans2) mod 10,s2);\n dec(a[ans2]);\n dec(b[(10-ans2) mod 10]);\n for i:=1 to ans[10] do begin\n s1:=s1+'0';\n s2:=s2+'0';\n dec(a[0]);\n dec(b[0]);\n end;\n for i:=9 downto 0 do begin\n for j:=1 to ans[i] do begin\n str(i,ss);s1:=ss+s1;\n str(9-i,ss);s2:=ss+s2;\n dec(a[i]);\n dec(b[9-i]);\n end;\n end;\n for i:=0 to 9 do begin\n for j:=1 to a[i] do begin\n str(i,ss);s1:=ss+s1;\n end;\n for j:=1 to b[i] do begin\n str(i,ss);s2:=ss+s2;\n end;\n end;\n writeln(s1);\n writeln(s2);\nend.\n"}, {"source_code": "uses math;\n\nvar j,last,max,tmp,i1,t,m,n,i:longint;\nok:boolean;\ns:ansistring;\na1,a2,f1,f2,c,a:array[0..200000]of longint;\n\n begin\n readln(s);\n t:=0;\n n:=length(s);\n for i:=1 to n do\n if s[i]='0' then t:=t+1 else\n begin\n m:=m+1;\n a[m]:=ord(s[i])-48;\n inc(c[a[m]]);\n end;\n\n max:=-1;\n last:=1;\n\n for i1:=1 to 9 do\n if c[i1]>0 then\n begin\n if c[10-i1]>0 then\n begin\n for i:=0 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n dec(f1[i1]);\n dec(f2[10-i1]);\n\n tmp:=1;\n\n for i:=0 to 9 do\n begin\n tmp:=tmp+min(f1[i],f2[9-i]);\n end;\n\n if tmp>max then\n begin\n max:=tmp;\n last:=i1;\n end;\n\n end;\n end;\n\n if max=-1 then\n begin\n for i:=1 to m do\n begin\n a1[m-i+1]:=a[i];\n a2[m-i+1]:=a[i];\n end;\n end else\n begin\n for i:=0 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n dec(f1[last]);\n dec(f2[10-last]);\n\n a1[1]:=last;\n a2[1]:=10-last;\n\n for j:=2 to m do\n begin\n ok:=true;\n for i:=1 to 9 do\n if f1[i]>0 then\n if f2[9-i]>0 then\n begin\n dec(f1[i]);\n dec(f2[9-i]);\n ok:=false;\n a1[j]:=i;\n a2[j]:=9-i;\n break;\n end;\n\n if ok then\n begin\n for i:=1 to 9 do\n if f1[i]>0 then\n begin\n a1[j]:=i;\n dec(f1[i]);\n break;\n end;\n\n for i:=1 to 9 do\n if f2[i]>0 then\n begin\n a2[j]:=i;\n dec(f2[i]);\n break;\n end;\n end;\n end;\n end;\n\n for i:=m downto 1 do write(a1[i]);\n for i:=1 to t do write(0);\n writeln;\n\n for i:=m downto 1 do write(a2[i]);\n for i:=1 to t do write(0);\n writeln;\n\n end."}, {"source_code": "uses math;\n\nvar j,last,max,tmp,i1,t,m,n,i:longint;\nok:boolean;\ns:ansistring;\na1,a2,f1,f2,c,a:array[0..200000]of longint;\n\n begin\n readln(s);\n t:=0;\n n:=length(s);\n for i:=1 to n do\n if s[i]='0' then t:=t+1 else\n begin\n m:=m+1;\n a[m]:=ord(s[i])-48;\n inc(c[a[m]]);\n end;\n\n max:=-1;\n last:=1;\n\n for i1:=1 to 9 do\n if c[i1]>0 then\n begin\n if c[10-i1]>0 then\n begin\n for i:=0 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n dec(f1[i1]);\n dec(f2[10-i1]);\n\n tmp:=1;\n\n for i:=0 to 4 do\n begin\n tmp:=tmp+min(f1[i],f2[9-i]);\n end;\n\n if tmp>max then\n begin\n max:=tmp;\n last:=i1;\n end;\n\n end;\n end;\n\n if max=-1 then\n begin\n for i:=1 to m do\n begin\n a1[m-i+1]:=a[i];\n a2[m-i+1]:=a[i];\n end;\n end else\n begin\n for i:=0 to 9 do\n begin\n f1[i]:=c[i];\n f2[i]:=c[i];\n end;\n\n dec(f1[last]);\n dec(f2[10-last]);\n\n a1[1]:=last;\n a2[1]:=10-last;\n\n for j:=2 to m do\n begin\n ok:=true;\n for i:=1 to 4 do\n if f1[i]>0 then\n if f2[9-i]>0 then\n begin\n dec(f1[i]);\n dec(f2[9-i]);\n ok:=false;\n a1[j]:=i;\n a2[j]:=9-i;\n break;\n end;\n\n if ok then\n begin\n for i:=1 to 9 do\n if f1[i]>0 then\n begin\n a1[j]:=i;\n dec(f1[i]);\n break;\n end;\n\n for i:=1 to 9 do\n if f2[i]>0 then\n begin\n a2[j]:=i;\n dec(f2[i]);\n break;\n end;\n end;\n end;\n end;\n\n for i:=m downto 1 do write(a1[i]);\n for i:=1 to t do write(0);\n writeln;\n\n for i:=m downto 1 do write(a2[i]);\n for i:=1 to t do write(0);\n writeln;\n\n end."}, {"source_code": "Program Digits_Permutations;\nvar ch:char;\n i,j,t,sz:longint;\n a,b:array[0..9]of longint;\n p1,p2:array[1..100000]of longint;\n//======================================================================\nprocedure Calc(x,y:longint);\nbegin\n if a[x]>a[y] then\n b[x]:=a[x]-a[y]\n else\n b[y]:=a[y]-a[x];\nend;\n//======================================================================\nprocedure Ins(x,y:longint);\nbegin\n inc(sz);p1[sz]:=x;p2[sz]:=y;\nend;\n//======================================================================\nprocedure Work(x,y,mark:longint);\nbegin\n if (mark=0)and((b[x]=0)or(b[y]=0)) then exit;\n if (mark=1)and((b[x]=0)and(b[y]=0)) then exit;\n if (mark=2)and((a[x]=0)or(a[y]=0)) then exit;\n\n if (y=9)and(b[9]=0) then inc(b[0]);\n for i:=1 to b[0] do\n begin\n Ins(0,0);dec(a[0]);\n end;\n Ins(x,y);\n if x<>y then\n begin\n dec(a[x]);dec(a[y]);\n end\n else dec(a[x]);\n\n for i:=0 to 4 do\n while (a[i]>0)and(a[9-i]>0)do\n begin\n Ins(i,9-i);\n Ins(9-i,i);\n dec(a[i]);dec(a[9-i]);\n end;\n for i:=0 to 9 do\n while (a[i]>0) do\n begin\n Ins(i,i);dec(a[i]);\n end;\n if x<>y then Ins(y,x);\n for i:=sz downto 1 do write(p1[i]);\n writeln;\n for i:=sz downto 1 do write(p2[i]);\n halt;\nend;\n//======================================================================\nbegin\n repeat\n read(ch);\n inc(a[ord(ch)-ord('0')]);\n until seekeof;\n Calc(0,9);Calc(1,8);Calc(2,7);Calc(3,6);Calc(4,5);\n Work(1,9,0);Work(2,8,0);Work(3,7,0);Work(4,6,0);Work(5,5,0);\n Work(1,9,1);Work(2,8,1);Work(3,7,1);Work(4,6,1);Work(5,5,1);\n Work(1,9,2);Work(2,8,2);Work(3,7,2);Work(4,6,2);Work(5,5,2);\n for i:=0 to 9 do\n while a[i]>0 do\n begin\n Ins(i,i);dec(a[i]);\n end;\n for i:=sz downto 1 do write(p1[i]);\n writeln;\n for i:=sz downto 1 do write(p2[i]);\nend.\n"}, {"source_code": "var st:ansistring;\n a,b,c:array[0..10] of longint;\n max,maxk,c1,i,e,j,o:longint;\n x,y:array[0..1000000] of longint;\n\nfunction min(a,b:longint):longint;\n begin\n if a=0) and (c[10-i]>=0) then\n begin\n e:=1;\n for j:=1 to 8 do\n e:=e+min(b[j],c[9-j]);\n if e>max then\n begin\n max:=e;\n maxk:=i;\n end;\n end;\n end;\n if (max=0) and (a[0]=0) then\n begin\n writeln(st);\n writeln(st);\n end\n else\n if max=0 then\n begin\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n end\n else\n begin\n o:=0;\n for i:=1 to a[0] do\n begin\n inc(o);\n x[o]:=0;\n y[o]:=0;\n end;\n inc(o);\n x[o]:=maxk;\n y[o]:=10-maxk;\n b:=a;\n dec(a[maxk]);\n dec(b[10-maxk]);\n for i:=1 to 8 do\n begin\n c1:=min(a[i],b[9-i]);\n a[i]:=a[i]-c1;\n b[9-i]:=b[9-i]-c1;\n for j:=1 to c1 do\n begin\n inc(o);\n x[o]:=i;\n y[o]:=9-i;\n end;\n end;\n for i:=1 to 9 do\n for j:=1 to a[i] do\n write(i);\n for i:=o downto 1 do write(x[i]);writeln;\n for i:=1 to 9 do\n for j:=1 to b[i] do\n write(i);\n for i:=o downto 1 do write(y[i]);writeln;\n end;\nend.\n"}, {"source_code": "var st:ansistring;\n a,b,c:array[0..10] of longint;\n max,maxk,c1,i,e,j,o:longint;\n x,y:array[0..1000000] of longint;\n\nfunction min(a,b:longint):longint;\n begin\n if a=0) and (c[10-i]>=0) then\n begin\n e:=1;\n for j:=1 to 4 do\n e:=e+min(b[j],c[9-j])*2;\n if e>max then\n begin\n max:=e;\n maxk:=i;\n end;\n end;\n end;\n if max=0 then\n begin\n writeln(st);\n writeln(st);\n end\n else\n begin\n o:=0;\n for i:=1 to a[0] do\n begin\n inc(o);\n x[o]:=0;\n y[o]:=0;\n end;\n inc(o);\n x[o]:=maxk;\n y[o]:=10-maxk;\n b:=a;\n dec(a[maxk]);\n dec(b[10-maxk]);\n for i:=1 to 8 do\n for j:=1 to min(a[i],b[9-i]) do\n begin\n inc(o);\n x[o]:=i;\n y[o]:=9-i;\n c1:=min(a[i],b[9-i]);\n a[i]:=a[i]-c1;\n b[9-i]:=b[9-i]-c1;\n end;\n for i:=1 to 9 do\n for j:=1 to a[i] do\n write(i);\n for i:=o downto 1 do write(x[i]);writeln;\n for i:=1 to 9 do\n for j:=1 to b[i] do\n write(i);\n for i:=o downto 1 do write(y[i]);writeln;\n end;\nend."}, {"source_code": "var st:ansistring;\n a,b,c:array[0..10] of longint;\n max,maxk,c1,i,e,j,o:longint;\n x,y:array[0..1000000] of longint;\n\nfunction min(a,b:longint):longint;\n begin\n if a=0) and (c[10-i]>=0) then\n begin\n e:=1;\n for j:=1 to 4 do\n e:=e+min(b[j],c[9-j])*2;\n if e>max then\n begin\n max:=e;\n maxk:=i;\n end;\n end;\n end;\n if (max=0) and (a[0]=0) then\n begin\n writeln(st);\n writeln(st);\n end\n else\n if max=0 then\n begin\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n for i:=1 to length(st) do if st[i]<>'0' then write(st[i]);\n for i:=1 to a[0] do write('0');writeln;\n end\n else\n begin\n o:=0;\n for i:=1 to a[0] do\n begin\n inc(o);\n x[o]:=0;\n y[o]:=0;\n end;\n inc(o);\n x[o]:=maxk;\n y[o]:=10-maxk;\n b:=a;\n dec(a[maxk]);\n dec(b[10-maxk]);\n for i:=1 to 8 do\n for j:=1 to min(a[i],b[9-i]) do\n begin\n inc(o);\n x[o]:=i;\n y[o]:=9-i;\n c1:=min(a[i],b[9-i]);\n a[i]:=a[i]-c1;\n b[9-i]:=b[9-i]-c1;\n end;\n for i:=1 to 9 do\n for j:=1 to a[i] do\n write(i);\n for i:=o downto 1 do write(x[i]);writeln;\n for i:=1 to 9 do\n for j:=1 to b[i] do\n write(i);\n for i:=o downto 1 do write(y[i]);writeln;\n end;\nend.\n"}, {"source_code": "uses\n math;\n\nvar\n u1,u2,a:array[0..500500]of longint;\n kc1,kc2,kc:array[0..100]of longint;\n m1,m2,cr,m,c,i,n,pc1,pc2,c1,c2,max,qq:longint;\n s:ansistring;\n\nbegin\n readln(s);\n n:=length(s);\n fillchar(kc,sizeof(kc),$0);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=1 to n do inc(kc[a[i]]);\n m:=n;\n while (kc[0]>0)do begin\n u1[m]:=0;\n u2[m]:=0;\n dec(m);\n dec(kc[0]);\n end;\n pc1:=-1;pc2:=-1;\n max:=-1;\n for c1:=0 to 9 do begin\n c2:=10-c1;\n if (kc[c1]=0)or(kc[c2]=0)then continue;\n dec(kc[c1]);dec(kc[c2]); cr:=1;\n for c:=0 to 4 do begin\n qq:=min(kc[c],kc[9-c]);\n inc(cr,qq);\n end;\n if (cr>max)then begin max:=cr;pc1:=c1;pc2:=c2; end;\n inc(kc[c1]);inc(kc[c2]);\n end;\n u1[m]:=pc1;\n u2[m]:=pc2;\n dec(m);\n c1:=pc1;c2:=pc2;\n for c:=0 to 9 do begin kc1[c]:=kc[c];kc2[c]:=kc[c]; end;\n dec(kc1[c1]);\n dec(kc2[c2]);\n for c:=0 to 9 do begin\n qq:=min(kc1[c],kc2[9-c]);\n for i:=1 to qq do begin\n u1[m]:=c;\n u2[m]:=9-c;\n dec(m);\n end;\n dec(kc1[c],qq);dec(kc2[9-c],qq);\n end;\n m1:=m;m2:=m;\n for i:=0 to 9 do begin\n while (kc1[i]>0)do begin\n u1[m1]:=i;\n dec(m1);\n dec(kc1[i]);\n end;\n while (kc2[i]>0)do begin\n u2[m2]:=i;\n dec(m2);\n dec(kc2[i]);\n end;\n end;\n for i:=1 to n do write(u1[i]);\n writeln;\n for i:=1 to n do write(u2[i]);\nend.\n"}, {"source_code": "uses\n math;\n\nvar\n u1,u2,a:array[0..500500]of longint;\n kc1,kc2,kc:array[0..100]of longint;\n m1,m2,cr,m,c,i,n,pc1,pc2,c1,c2,max,qq:longint;\n s:ansistring;\n\nbegin\n readln(s);\n n:=length(s);\n fillchar(kc,sizeof(kc),$0);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=1 to n do inc(kc[a[i]]);\n m:=n;\n while (kc[0]>0)do begin\n u1[m]:=0;\n u2[m]:=0;\n dec(m);\n dec(kc[0]);\n end;\n pc1:=-1;pc2:=-1;\n max:=-1;\n for c1:=0 to 9 do begin\n c2:=10-c1;\n if (kc[c1]=0)or(kc[c2]=0)then continue;\n dec(kc[c1]);dec(kc[c2]); cr:=1;\n for c:=0 to 4 do begin\n qq:=min(kc[c],kc[9-c]);\n inc(cr,qq);\n end;\n if (cr>max)then begin max:=cr;pc1:=c1;pc2:=c2; end;\n inc(kc[c1]);inc(kc[c2]);\n end;\n if (pc1<>-1)then begin\n u1[m]:=pc1;\n u2[m]:=pc2;\n dec(m);\n c1:=pc1;c2:=pc2;\n for c:=0 to 9 do begin kc1[c]:=kc[c];kc2[c]:=kc[c]; end;\n dec(kc1[c1]);\n dec(kc2[c2]);\n for c:=0 to 9 do begin\n qq:=min(kc1[c],kc2[9-c]);\n for i:=1 to qq do begin\n u1[m]:=c;\n u2[m]:=9-c;\n dec(m);\n end;\n dec(kc1[c],qq);dec(kc2[9-c],qq);\n end;\n end else for c:=0 to 9 do begin kc1[c]:=kc[c];kc2[c]:=kc[c]; end;\n m1:=m;m2:=m;\n for i:=0 to 9 do begin\n while (kc1[i]>0)do begin\n u1[m1]:=i;\n dec(m1);\n dec(kc1[i]);\n end;\n while (kc2[i]>0)do begin\n u2[m2]:=i;\n dec(m2);\n dec(kc2[i]);\n end;\n end;\n for i:=1 to n do write(u1[i]);\n writeln;\n for i:=1 to n do write(u2[i]);\nend.\n"}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2,kq1,kq2:array[1..100011] of longint;\ns1,s2,ss1,ss2:array[0..10] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nres:longint;\n\nProcedure try (vt,gt:longint);\nvar count:longint;\nok:boolean;\ni,j:longint;\nBegin\n ok:=false;\n i:=vt;\n count:=n-vt;\n if (s1[gt]>0) and (s2[10-gt]>0) then\n begin\n d1[vt]:=gt;\n d2[vt]:=10-gt;\n dec(s1[gt]);\n dec(s2[10-gt]);\n ok:=true;\n i:=vt-1;\n end;\n\n if ok then\n begin\n count:=count+1;\n for i:=vt-1 downto 1 do\n begin\n found:=false;\n for j:=0 to 9 do\n if (s1[j]>0) and (s2[9-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[9-j]);\n D1[i]:=j;\n D2[i]:=9-j;\n inc(count);\n break;\n end;\n if found=false then break;\n End;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n if count>res then\n begin\n res:=count;\n kq1:=d1;\n kq2:=d2;\n end;\nEnd;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n res:=-1;\n\n ss1:=s1;\n ss2:=s2;\n for j:=1 to 9 do\n Begin\n s1:=ss1;\n s2:=ss2;\n try(n,j);\n end;\n j:=1;\n while (kq1[j]=0) and (kq2[j]=0) and (j<=n) do\n begin\n inc(j);\n end;\n\n for i:=j to n do\n write(f2,kq1[i]);\n for i:=1 to j-1 do write(f2,0);\n writeln(f2);\n for i:=j to n do\n write(f2,kq2[i]);\n for i:=1 to j-1 do write(f2,0);\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2,kq1,kq2:array[1..100011] of longint;\ns1,s2,ss1,ss2:array[0..10] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nres:longint;\n\nProcedure try (vt,gt:longint);\nvar count:longint;\nok:boolean;\ni,j:longint;\nBegin\n ok:=false;\n i:=vt;\n count:=n-vt;\n if (s1[gt]>0) and (s2[10-gt]>0) then\n begin\n d1[vt]:=gt;\n d2[vt]:=10-gt;\n dec(s1[gt]);\n dec(s2[10-gt]);\n ok:=true;\n i:=vt-1;\n end;\n\n if ok then\n begin\n count:=count+1;\n for i:=vt-1 downto 1 do\n begin\n found:=false;\n for j:=0 to 9 do\n if (s1[j]>0) and (s2[9-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[9-j]);\n D1[i]:=j;\n D2[i]:=9-j;\n inc(count);\n break;\n end;\n if found=false then break;\n End;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n if count>res then\n begin\n res:=count;\n kq1:=d1;\n kq2:=d2;\n end;\nEnd;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n res:=-1;\n\n ss1:=s1;\n ss2:=s2;\n for j:=1 to 9 do\n Begin\n s1:=ss1;\n s2:=ss2;\n try(n,j);\n end;\n\n for i:=1 to n do\n write(f2,kq1[i]);writeln(f2);\n for i:=1 to n do\n write(f2,kq2[i]);\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2,kq1,kq2:array[1..100011] of longint;\ns1,s2,ss1,ss2:array[0..9] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nres:longint;\n\nProcedure try (vt,gt:longint);\nvar count:longint;\nok:boolean;\ni,j:longint;\nBegin\n ok:=false;\n i:=vt;\n count:=n-vt;\n if (s1[gt]>0) and (s2[10-gt]>0) then\n begin\n d1[vt]:=gt;\n d2[vt]:=10-gt;\n dec(s1[gt]);\n dec(s2[10-gt]);\n ok:=true;\n i:=vt-1;\n end;\n\n if ok then\n begin\n count:=count+1;\n for i:=vt-1 downto 1 do\n begin\n found:=false;\n for j:=1 to 9 do\n if (s1[j]>0) and (s2[9-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[9-j]);\n D1[i]:=j;\n D2[i]:=9-j;\n inc(count);\n break;\n end;\n if found=false then break;\n End;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n if count>res then\n begin\n res:=count;\n kq1:=d1;\n kq2:=d2;\n end;\nEnd;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n res:=-1;\n for i:=n downto 1 do\n if s1[0]>0 then\n begin\n dec(s1[0]);\n dec(s2[0]);\n d1[i]:=0;\n d2[i]:=0;\n end\n else\n Begin\n ss1:=s1;\n ss2:=s2;\n for j:=1 to 9 do\n Begin\n s1:=ss1;\n s2:=ss2;\n try(i,j);\n end;\n break;\n End;\n\n for i:=1 to n do\n write(f2,kq1[i]);writeln(f2);\n for i:=1 to n do\n write(f2,kq2[i]);\n close(f1);\n close(f2);\nend."}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2:array[1..100011] of longint;\ns1,s2:array[0..9] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n for i:=n downto 1 do\n begin\n if s1[0]>0 then\n begin\n dec(s1[0]);\n dec(s2[0]);\n D1[i]:=0;\n D2[i]:=0;\n end\n else\n begin\n if d1[i+1]=0 then rem:=0 else rem:=1;\n found:=false;\n for j:=1 to 9 do\n if (s1[j]>0) and (s2[10-rem-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[10-rem-j]);\n D1[i]:=j;\n D2[i]:=10-rem-j;\n break;\n end;\n if found=false then break;\n end;\n end;\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n for i:=1 to n do write(F2,d1[i]);writeln(f2);\n for i:=1 to n do write(f2,d2[i]);\n close(f1);\n close(f2);\nend."}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2,kq1,kq2:array[1..100011] of longint;\ns1,s2,ss1,ss2:array[0..9] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nres:longint;\n\nProcedure try (vt,gt:longint);\nvar count:longint;\nok:boolean;\ni,j:longint;\nBegin\n ok:=false;\n i:=vt;\n count:=n-vt;\n if (s1[gt]>0) and (s2[10-gt]>0) then\n begin\n d1[vt]:=gt;\n d2[vt]:=10-gt;\n dec(s1[gt]);\n dec(s2[10-gt]);\n ok:=true;\n i:=vt-1;\n end;\n\n if ok then\n begin\n count:=count+1;\n for i:=vt-1 downto 1 do\n begin\n found:=false;\n for j:=1 to 9 do\n if (s1[j]>0) and (s2[9-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[9-j]);\n D1[i]:=j;\n D2[i]:=9-j;\n inc(count);\n break;\n end;\n if found=false then break;\n End;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n if count>res then\n begin\n res:=count;\n kq1:=d1;\n kq2:=d2;\n end;\nEnd;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n res:=-1;\n for i:=n downto 1 do\n if s1[0]>0 then\n begin\n dec(s1[0]);\n dec(s2[0]);\n d1[i]:=0;\n d2[i]:=0;\n end\n else\n Begin\n ss1:=s1;\n ss2:=s2;\n for j:=1 to 9 do\n Begin\n s1:=ss1;\n s2:=ss2;\n try(i,j);\n end;\n break;\n End;\n\n for i:=1 to n do\n write(f2,kq1[i]);writeln(f2);\n for i:=1 to n do\n write(f2,kq2[i]);\n close(f1);\n close(f2);\nend."}, {"source_code": "var f1,f2:text;\nA:array[1..100011] of longint;\nD1,D2:array[1..100011] of longint;\ns1,s2:array[0..9] of longint;\ni,n,j,x:longint;\nFound:boolean;\nch:char;\nst:ansistring;\nrem:longint;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(F2);\n readln(f1,st);\n n:=length(st);\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(s1[a[i]]);\n inc(s2[a[i]]);\n End;\n for i:=n downto 1 do\n begin\n if s1[0]>0 then\n begin\n dec(s1[0]);\n dec(s2[0]);\n D1[i]:=0;\n D2[i]:=0;\n end\n else\n begin\n if d1[i+1]=0 then rem:=0 else rem:=1;\n found:=false;\n for j:=1 to 9 do\n if (s1[j]>0) and (s2[10-rem-j]>0) then\n begin\n found:=true;\n dec(s1[j]);\n dec(s2[10-rem-j]);\n D1[i]:=j;\n D2[i]:=10-rem-j;\n break;\n end;\n if found=false then break;\n end;\n end;\n if found=false then\n for j:=i downto 1 do\n begin\n for x:=0 to 9 do\n if s1[x]>0 then begin D1[j]:=x;dec(s1[x]); break; end;\n for x:=0 to 9 do\n if s2[x]>0 then begin d2[j]:=x;dec(s2[x]); break; end;\n end;\n for i:=1 to n do write(F2,d1[i]);writeln(f2);\n for i:=1 to n do write(f2,d2[i]);\n close(f1);\n close(f2);\nend."}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=r;\n for j:=0 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n if rez<>0 then continue;\n rez:=max;\n r1:='';r2:='';\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=0 to 9 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n b1:=o;\n b2:=o;\n dec(b1[0],ii+1);dec(b2[0],ii+1);\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to b1[0] do\n begin\n r:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=r;\n for j:=1 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=0 then\n begin\n r1:='';r2:='';\n for i:=1 to 9 do\n for j:=1 to o[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=1 to 9 do\n for j:=1 to o[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=1 to 8 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n b1:=o;\n b2:=o;\n dec(b1[0],ii+1);dec(b2[0],ii+1);\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n dec(b1[0],ii);dec(b2[0],ii);\n if ii>0 then\n begin\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=ii+1;\n for j:=0 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n rez:=max;\n r1:='';r2:='';\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=0 to 9 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n b1:=o;\n b2:=o;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=ii+1;\n for j:=0 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n if rez<>0 then continue;\n rez:=max;\n r1:='';r2:='';\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=0 to 9 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n b1:=o;\n b2:=o;\n dec(b1[0],ii+1);dec(b2[0],ii+1);\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n dec(b1[0],ii+1);dec(b2[0],ii+1);\n if ii>0 then\n begin\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=ii+1;\n for j:=0 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n rez:=max;\n r1:='';r2:='';\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=0 to 9 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n if ii=4 then \n begin\n writeln(r1);\n writeln(r2);\n end;\n b1:=o;\n b2:=o;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p: longint;\n b1,b2,o: array[0..9] of longint;\n c: char;\n s1,s2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n while b1[0]>0 do\n begin\n dec(b1[0]);\n s1:='0'+s1;\n end;\n b2:=b1;\n o:=b1;\n s2:=s1;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=1;\n for j:=1 to 8 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=0 then\n begin\n for i:=1 to 9 do\n for j:=1 to o[i] do write(i);\n writeln(s1);\n for i:=1 to 9 do\n for j:=1 to o[i] do write(i);\n writeln(s2);\n exit;\n end;\n s1:=chr(p+48) + s1;\n s2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=1 to 4 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n s1:=chr(i+48) + s1;\n s2:=chr(57-i) + s2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=1 to 9 do\n for j:=1 to b1[i] do write(i);\n writeln(s1);\n for i:=1 to 9 do\n for j:=1 to b2[i] do write(i);\n writeln(s2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p: longint;\n b1,b2,o: array[0..9] of longint;\n c: char;\n s1,s2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n while b1[0]>0 do\n begin\n dec(b1[0]);\n s1:='0'+s1;\n end;\n b2:=b1;\n o:=b1;\n s2:=s1;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=1;\n for j:=1 to 8 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=0 then\n begin\n for i:=1 to 9 do\n for j:=1 to o[i] do write(i);\n writeln(s1);\n for i:=1 to 9 do\n for j:=1 to o[i] do write(i);\n writeln(s2);\n exit;\n end;\n s1:=chr(p+48) + s1;\n s2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=1 to 8 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n s1:=chr(i+48) + s1;\n s2:=chr(9-i+48) + s2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=1 to 9 do\n for j:=1 to b1[i] do write(i);\n writeln(s1);\n for i:=1 to 9 do\n for j:=1 to b2[i] do write(i);\n writeln(s2);\nend.\n"}, {"source_code": "uses math;\nvar i,j,x,y,n,m,max,p,r,rez,ii: longint;\n b1,b2,o: array[0..10] of longint;\n c: char;\n s1,s2,r1,r2: ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n inc(b1[ord(c)-48]);\n end;\n o:=b1; \n b2:=b1;\n for ii:=0 to o[0] do\n begin\n max:=ii;\n for i:=1 to 9 do\n begin\n if (b1[i]=0) or (b2[10-i]=0) then continue;\n dec(b1[i]);dec(b2[10-i]);\n x:=r;\n for j:=1 to 9 do\n begin\n y:=min(b1[j],b2[9-j]);\n x:=x+y;\n end;\n if x>max then\n begin\n max:=x;\n p:=i;\n end;\n inc(b1[i]);inc(b2[10-i]);\n end;\n if max=ii then\n begin\n if rez<>0 then continue;\n rez:=max;\n r1:='';r2:='';\n for i:=9 downto 0 do\n for j:=1 to b1[i] do r1:=r1+chr(i+48);\n r1:=r1+s1;\n for i:=9 downto 0 do\n for j:=1 to b2[i] do r2:=r2+chr(i+48);\n r2:=r2+s2;\n continue;\n end;\n if max<=rez then continue;\n rez:=max;\n r1:=chr(p+48) + s1;\n r2:=chr(10-p+48) + s2;\n dec(b1[p]);dec(b2[10-p]);\n for i:=1 to 8 do\n begin\n y:=min(b1[i],b2[9-i]);\n for j:=1 to y do \n begin \n r1:=chr(i+48) + r1;\n r2:=chr(9-i+48) + r2;\n end;\n dec(b1[i],y);\n dec(b2[9-i],y);\n end; \n for i:=0 to 9 do\n for j:=1 to b1[i] do r1:=chr(i+48)+r1;\n for i:=0 to 9 do\n for j:=1 to b2[i] do r2:=chr(i+48)+r2;\n b1:=o;\n b2:=o;\n dec(b1[0],ii+1);dec(b2[0],ii+1);\n s1:='0'+s1;\n s2:='0'+s2;\n end;\n writeln(r1);\n writeln(r2);\nend.\n"}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[x]);\n s1 := chr(x + 48);\n s2 := chr(x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := a[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[x]);\n s1 := chr(x + 48);\n s2 := chr(x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := a[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n for i := 1 to a[0] do\n s1 := s1 + chr(48);\n for i := 1 to b[0] do\n s2 := s2 + chr(48);\n\n for i := 1 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 1 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[x]);\n s1 := chr(x + 48);\n s2 := chr(x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n for i := 1 to a[0] do\n s1 := s1 + chr(48);\n for i := 1 to b[0] do\n s2 := s2 + chr(48);\n\n for i := 1 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 1 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Int64;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(o: Longint);\nvar s1, s2: String;\n i, j, x: Longint;\nBegin\n if (x = 5) then begin\n dec(a[o]);\n dec(b[o]);\n s1 := chr(o + 48);\n s2 := chr(o + 48);\n end\n else begin\n dec(a[o]);\n dec(b[10 - o]);\n s1 := chr(o + 48);\n s2 := chr(10 - o + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n x := a[0];\n if b[0] < x then\n x := b[0];\n a[0] := a[0] - x;\n b[0] := b[0] - x;\n for i := 1 to x do begin\n s1 := s1 + chr(48);\n s2 := s2 + chr(48);\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n max := 0;\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := a[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n\n for i := 0 to 9 do begin\n if (i = 0) or (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = 0 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Int64;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(o: Longint);\nvar s1, s2: String;\n i, j, x: Longint;\nBegin\n if (o = 5) then begin\n dec(a[o]);\n dec(b[o]);\n s1 := chr(o + 48);\n s2 := chr(o + 48);\n end\n else begin\n dec(a[o]);\n dec(b[10 - o]);\n s1 := chr(o + 48);\n s2 := chr(10 - o + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n x := a[0];\n if b[0] < x then\n x := b[0];\n a[0] := a[0] - x;\n b[0] := b[0] - x;\n for i := 1 to x do begin\n s1 := s1 + chr(48);\n s2 := s2 + chr(48);\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\nEnd;\n\nprocedure src;\nvar x, sum, j, x1, x2: Longint;\n q: Boolean;\nBegin\n sum := 1;\n x1 := a[0];\n x2 := b[0];\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n if j = 0 then\n x1 := x1 - x;\n if j = 9 then\n x2 := x2 - x;\n sum := sum + x;\n end;\n x := x1;\n if x2 < x then\n x := x2;\n sum := sum + x;\n\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n max := 0;\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[x]);\n s1 := chr(x + 48);\n s2 := chr(x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n x := a[0];\n if b[0] < x then\n x := b[0];\n a[0] := a[0] - x;\n b[0] := b[0] - x;\n for i := 1 to x do begin\n s1 := s1 + chr(48);\n s2 := s2 + chr(48);\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$H+}\n\nvar a, b: array [0..100] of Int64;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(o: Longint);\nvar s1, s2: String;\n i, j, x: Longint;\nBegin\n if (o = 5) then begin\n dec(a[o]);\n dec(b[o]);\n s1 := chr(o + 48);\n s2 := chr(o + 48);\n end\n else begin\n dec(a[o]);\n dec(b[10 - o]);\n s1 := chr(o + 48);\n s2 := chr(10 - o + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n x := a[0];\n if b[0] < x then\n x := b[0];\n a[0] := a[0] - x;\n b[0] := b[0] - x;\n for i := 1 to x do begin\n s1 := s1 + chr(48);\n s2 := s2 + chr(48);\n end;\n\n for i := 0 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 0 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n max := 0;\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "\n\nvar a, b: array [0..100] of Longint;\n s: String;\n i, max, best, n: Longint;\n\nprocedure w(x: Longint);\nvar s1, s2: String;\n i, j: Longint;\nBegin\n if (x = 0) or (x = 5) then begin\n dec(a[x]);\n dec(b[x]);\n s1 := chr(x + 48);\n s2 := chr(x + 48);\n end\n else begin\n dec(a[x]);\n dec(b[10 - x]);\n s1 := chr(x + 48);\n s2 := chr(10 - x + 48);\n end;\n\n for i := 0 to 9 do begin\n x := a[i];\n if b[9 - i] < x then\n x := b[9 - i];\n a[i] := a[i] - x;\n b[9 - i] := b[9 - i] - x;\n for j := 1 to x do begin\n s1 := chr(i + 48) + s1;\n s2 := chr(9 - i + 48) + s2;\n end;\n end;\n\n for i := 1 to a[0] do\n s1 := s1 + chr(48);\n for i := 1 to b[0] do\n s2 := s2 + chr(48);\n\n for i := 1 to 9 do\n for j := 1 to a[i] do\n s1 := chr(i + 48) + s1;\n for i := 1 to 9 do\n for j := 1 to b[i] do\n s2 := chr(i + 48) + s2;\n writeln(s1);\n writeln(s2);\n\nEnd;\n\nprocedure src;\nvar x, sum, j: Longint;\n q: Boolean;\nBegin\n sum := 1;\n for j := 0 to 9 do begin\n x := a[j];\n if b[9 - j] < x then\n x := b[9 - j];\n sum := sum + x;\n end;\n if sum > max then begin\n best := i;\n max := sum;\n end;\nEnd;\n\nBegin\n readln(s);\n n := length(s);\n for i := 1 to n do begin\n inc(a[ord(s[i]) - 48]);\n inc(b[ord(s[i]) - 48]);\n end;\n best := -1;\n for i := 1 to 9 do begin\n if (i = 5) then begin\n if (a[i] >= 1) and (b[i] >= 1) then begin\n b[i] := b[i] - 1;\n a[i] := a[i] - 1;\n src;\n a[i] := a[i] + 1;\n b[i] := b[i] + 1;\n end;\n end else begin\n if (a[i] >= 1) and (b[10 - i] >= 1) then begin\n dec(a[i]);\n dec(b[10 - i]);\n src;\n inc(a[i]);\n inc(b[10 - i]);\n end;\n end;\n end;\n\n if best = -1 then begin\n writeln(s);\n writeln(s);\n halt;\n end;\n w(best);\nEnd."}, {"source_code": "{$apptype console}\nuses SysUtils;\n\nvar s : string;\n c,c2 : array[0..9] of integer;\n\nfunction min(a,b : integer) : integer;\nbegin\n result := a;\n if b < a then result := b;\nend;\n\nfunction GetCnt : integer;\nvar i: integer;\nbegin\n result := 0;\n for i := 0 to 9 do begin\n inc(result, min(c[i], c2[9-i]) );\n end;\nend;\n\nvar i,j,max, imax, t : integer;\n good: array[1..100001] of integer;\n gl : integer;\nbegin\n{ reset( input, 'in.txt' );}\n {}\n readln( s );\n fillchar( c,sizeof(c), 0 );\n for i := 1 to length(s) do\n if s[i] in ['0'..'9'] then inc( c[ ord(s[i])-ord('0') ] );\n move(c,c2,sizeof(c));\n{}\n max := -1; imax:= -1;\n for i := 1 to 5 do begin\n if (c[i] > 0) and (c2[10-i]>0) then begin\n dec(c[i]); dec(c2[10-i]);\n t := GetCnt();\n if t > max then begin imax := i; max :=t; end;\n inc(c[i]); inc(c2[10-i]);\n end;\n end;\n{}\n if imax = -1 then begin\n for i := 1 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to c[0] do write(0);\n{}\n writeln;\n for i := 1 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to c[0] do write(0);\n end else begin\n dec(c[imax]); dec(c2[10-imax]);\n gl := 0;\n for i := 0 to 9 do begin\n t := min(c[i], c2[9-i]);\n for j := 1 to t do begin\n inc(gl);\n good[gl] := i;\n dec(c[i]);\n dec(c2[9-i]);\n end;\n end;\n{}\n for i := 1 to 9 do for j := 1 to c[i] do write(i);\n for i := 1 to gl do write( good[i] );\n write(imax);\n for i := 1 to c[0] do write(0);\n writeln;\n{}\n for i := 1 to 9 do for j := 1 to c2[i] do write(i);\n for i := 1 to gl do write( 9-good[i] );\n write(10-imax);\n for i := 1 to c2[0] do write(0);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses math;\nvar\n s:string;\n a,b1,b2,cr1,cr2:array[0..100001] of integer;\n c1,d1,c2,d2:array[0..9] of integer;\n z,sm,nl,mx,f,j,l,k,error,i,n:integer;\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n\n readln(s);\n\n n:=length(s);\n a[0]:=n;\n\n Fillchar(c1,sizeof(c1),0);\n Fillchar(c2,sizeof(c2),0);\n\n For i:=1 to n do\n begin\n val(s[i],a[i],error);\n inc(c1[a[i]]);\n inc(c2[a[i]]);\n end;\n\n mx:=-1;\n\n For i:=1 to c1[0] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=0;\n cr2[cr1[0]]:=0;\n end;\n\n For i:=1 to 9 do\n For j:=1 to 9 do\n begin\n cr1[0]:=c1[0];\n d1:=c1;\n d2:=c2;\n nl:=c2[0];\n d1[0]:=0;\n d2[0]:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n inc(cr1[0]);\n dec(d1[i]);\n dec(d2[j]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n inc(nl);\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n\n For i:=1 to 9 do\n For j:=1 to 9 do\n begin\n cr1[0]:=0;\n d1:=c1;\n d2:=c2;\n nl:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n dec(d1[i]);\n dec(d2[j]);\n inc(cr1[0]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n inc(nl);\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n\n For i:=b1[0] downto 1 do write(b1[i]);\n writeln;\n\n For i:=b2[0] downto 1 do write(b2[i]);\n writeln;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses math;\nvar\n s:string;\n a,b1,b2,cr1,cr2:array[0..100001] of integer;\n c1,d1,c2,d2:array[0..9] of integer;\n z,sm,nl,mx,f,j,l,k,error,i,n:integer;\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n\n readln(s);\n\n n:=length(s);\n a[0]:=n;\n\n Fillchar(c1,sizeof(c1),0);\n Fillchar(c2,sizeof(c2),0);\n\n For i:=1 to n do\n begin\n val(s[i],a[i],error);\n inc(c1[a[i]]);\n inc(c2[a[i]]);\n end;\n\n mx:=-1;\n\n For i:=1 to c1[0] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=0;\n cr2[cr1[0]]:=0;\n end;\n\n For i:=1 to 9 do\n For j:=1 to 9 do\n begin\n cr1[0]:=c1[0];\n d1:=c1;\n d2:=c2;\n nl:=c2[0];\n d1[0]:=0;\n d2[0]:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n inc(cr1[0]);\n dec(d1[i]);\n dec(d2[j]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n\n For i:=0 to 9 do\n For j:=0 to 9 do\n begin\n cr1[0]:=0;\n d1:=c1;\n d2:=c2;\n nl:=0;\n If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n dec(d1[i]);\n dec(d2[j]);\n inc(cr1[0]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n end;\n\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n If mx=-1 then\n begin\n b1:=a;\n b2:=a;\n end;\n\n For i:=b1[0] downto 1 do write(b1[i]);\n writeln;\n\n For i:=b2[0] downto 1 do write(b2[i]);\n writeln;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses math;\nvar\n s:string;\n a,b1,b2,cr1,cr2:array[0..100001] of integer;\n c1,d1,c2,d2:array[0..9] of integer;\n z,sm,nl,mx,f,j,l,k,error,i,n:integer;\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n\n readln(s);\n\n n:=length(s);\n\n Fillchar(c1,sizeof(c1),0);\n Fillchar(c2,sizeof(c2),0);\n\n For i:=1 to n do\n begin\n val(s[i],a[i],error);\n inc(c1[a[i]]);\n inc(c2[a[i]]);\n end;\n\n mx:=-1;\n\n For i:=1 to c1[0] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=0;\n cr2[cr1[0]]:=0;\n end;\n\n For i:=0 to 9 do\n For j:=0 to 9 do If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n cr1[0]:=c1[0];\n d1:=c1;\n d2:=c2;\n nl:=c2[0];\n d1[0]:=0;\n d2[0]:=0;\n dec(d1[i]);\n dec(d2[j]);\n inc(cr1[0]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n\n For i:=0 to 9 do\n For j:=0 to 9 do If (i+j=10) and (c1[i]>0) and (c2[j]>0) then\n begin\n cr1[0]:=0;\n d1:=c1;\n d2:=c2;\n nl:=0;\n dec(d1[i]);\n dec(d2[j]);\n inc(cr1[0]);\n cr1[cr1[0]]:=i;\n cr2[cr1[0]]:=j;\n\n For k:=0 to 9 do\n For l:=0 to 9 do\n If (k+l=9) then\n begin\n For f:=1 to min(d1[k],d2[l]) do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=k;\n cr2[cr1[0]]:=l;\n inc(nl);\n end;\n z:=min(d1[k],d2[l]);\n d1[k]:=d1[k]-z;\n d2[l]:=d2[l]-z;\n end;\n If nl>mx then\n begin\n mx:=nl;\n cr2[0]:=cr1[0];\n\n For l:=0 to 9 do\n For k:=1 to d1[l] do\n begin\n inc(cr1[0]);\n cr1[cr1[0]]:=l;\n end;\n\n For l:=0 to 9 do\n For k:=1 to d2[l] do\n begin\n inc(cr2[0]);\n cr2[cr2[0]]:=l;\n end;\n\n b1:=cr1;\n b2:=cr2;\n end;\n end;\n\n For i:=b1[0] downto 1 do write(b1[i]);\n writeln;\n\n For i:=b2[0] downto 1 do write(b2[i]);\n writeln;\n\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n x:Array[1..100000] of Integer;\n x1,x2:Array[1..100000] of Boolean;\n s1,s2:String;\n i,j,n,f,k,f0,f9:Integer;\n c:Char;\nprocedure qSort(l,r:Integer);\nvar i,j:Integer;\n w,q:Integer;\nbegin\n i := l; j := r;\n q := x[(l+r) div 2];\n repeat\n while (x[i] < q) do inc(i);\n while (q < x[j]) do dec(j);\n if (i <= j) then\n begin\n w:=x[i]; x[i]:=x[j]; x[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\nBegin\n i:=0;\n f0:=0;\n f9:=0;\n While not SeekEof Do Begin\n Read(c);\n i:=i+1;\n x[i]:=strtoint(c);\n If x[i]=0 Then f0:=f0+1;\n If x[i]=9 Then f9:=f9+1;\n End;\n n:=i;\n qSort(1,n);\n s1:='';\n s2:='';\n i:=1;\n While True Do Begin\n If f0=f9-1 Then Break;\n If x[i]<>0 Then Break;\n s1:=inttostr(x[i])+s1;\n x1[i]:=true;\n s2:=inttostr(x[i])+s2;\n x2[i]:=true;\n i:=i+1;\n f0:=f0-1;\n End;\n k:=i;\n j:=k;\n i:=n;\n f:=0;\n While True Do Begin\n If j>i Then Break;\n If x[j]+x[i]=10 Then Begin\n x1[i]:=true;\n s1:=inttostr(x[i])+s1;\n x2[j]:=true;\n s2:=inttostr(x[j])+s2;\n f:=1;\n Break;\n End;\n If x[j]+x[i]<10 Then j:=j+1\n Else i:=i-1;\n End;\n i:=n;\n j:=k;\n If (f=1) Then Begin\n While True Do Begin\n If i=0 Then Break;\n If j=n+1 Then Break;\n While True Do Begin\n If not(x1[i]) Then Break;\n i:=i-1;\n If i=0 Then Break;\n End;\n If i=0 Then Break;\n While True Do Begin\n If not(x2[j]) Then Break;\n j:=j+1;\n If j=n+1 Then Break;\n End;\n If j=n+1 Then Break;\n If x[i]+x[j]=9 Then Begin\n x1[i]:=true;\n x2[j]:=true;\n s1:=inttostr(x[i])+s1;\n s2:=inttostr(x[j])+s2;\n i:=i-1;\n j:=j+1;\n End\n Else If x[i]+x[j]<9 Then j:=j+1\n Else i:=i-1;\n End;\n End;\n For i:=1 To n Do Begin\n If not(x1[i]) Then s1:=inttostr(x[i])+s1;\n If not(x2[i]) Then s2:=inttostr(x[i])+s2;\n End;\n WriteLn(s1);\n Write(s2);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a,b:Array[1..100000] of Integer;\n i,k,d,t,p,j,f,r:Integer;\n n:String;\nBegin\n Read(n);\n For i:=1 To length(n) Do Begin\n Val(n[i],a[i],f);\n b[i]:=a[i];\n End;\n k:=length(n);\n d:=0;\n r:=0;\n While d<>k Do Begin\n f:=0;\n For i:=k-d DownTo 1 Do Begin\n t:=a[i];\n For j:=k-d DownTo 1 Do Begin\n If (t+b[j]+r) mod 10=0 Then Break;\n End;\n If j=0 Then Continue;\n f:=1;\n r:=(t+b[j]+r) div 10;\n p:=b[j];\n b[j]:=b[k-d];\n b[k-d]:=p;\n a[i]:=a[k-d];\n a[k-d]:=t;\n d:=d+1;\n Break;\n End;\n If f=0 Then Break;\n End;\n For i:=1 To k Do Write(a[i]);\n WriteLn;\n For i:=1 To k Do Write(b[i]);\nEnd.\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a,b:Array[1..100000] of Integer;\n i,k,d,t,p,j,f:Integer;\n n:String;\nBegin\n Read(n);\n For i:=1 To length(n) Do Begin\n Val(n[i],a[i],f);\n b[i]:=a[i];\n End;\n k:=length(n);\n d:=0;\n While d<>k Do Begin\n f:=0;\n For i:=k-d DownTo 1 Do Begin\n t:=a[i];\n For j:=k-d DownTo 1 Do Begin\n If (t+b[j]+d) mod 10=0 Then Break;\n End;\n If j=0 Then Continue;\n f:=1;\n p:=b[j];\n b[j]:=b[k-d];\n b[k-d]:=p;\n a[i]:=a[k-d];\n a[k-d]:=t;\n d:=d+1;\n Break;\n End;\n If f=0 Then Break;\n End;\n For i:=1 To k Do Write(a[i]);\n WriteLn;\n For i:=1 To k Do Write(b[i]);\nEnd.\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n x:Array[1..100000] of Integer;\n x1,x2:Array[1..100000] of Boolean;\n s1,s2:String;\n i,j,n,f,k:Integer;\n c:Char;\nprocedure qSort(l,r:Integer);\nvar i,j:Integer;\n w,q:Integer;\nbegin\n i := l; j := r;\n q := x[(l+r) div 2];\n repeat\n while (x[i] < q) do inc(i);\n while (q < x[j]) do dec(j);\n if (i <= j) then\n begin\n w:=x[i]; x[i]:=x[j]; x[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\nBegin\n i:=0;\n While not SeekEof Do Begin\n Read(c);\n i:=i+1;\n x[i]:=strtoint(c);\n End;\n n:=i;\n qSort(1,n);\n s1:='';\n s2:='';\n i:=1;\n While True Do Begin\n If x[i]<>0 Then Break;\n s1:=inttostr(x[i])+s1;\n x1[i]:=true;\n s2:=inttostr(x[i])+s2;\n x2[i]:=true;\n i:=i+1;\n End;\n k:=i;\n j:=k;\n i:=n;\n f:=0;\n While True Do Begin\n If j>i Then Break;\n If x[j]+x[i]=10 Then Begin\n x1[i]:=true;\n s1:=inttostr(x[i])+s1;\n x2[j]:=true;\n s2:=inttostr(x[j])+s2;\n f:=1;\n Break;\n End;\n If x[j]+x[i]<10 Then j:=j+1\n Else i:=i-1;\n End;\n i:=n;\n j:=k;\n If (f=1) Then Begin\n While True Do Begin\n If i=0 Then Break;\n If j=n+1 Then Break;\n If x1[i] Then Begin\n i:=i-1;\n If i=0 Then Break;\n End;\n If x2[j] Then Begin\n j:=j+1;\n If j=n+1 Then Break;\n End;\n If x[i]+x[j]=9 Then Begin\n x1[i]:=true;\n x2[j]:=true;\n s1:=inttostr(x[i])+s1;\n s2:=inttostr(x[j])+s2;\n i:=i-1;\n j:=j+1;\n End\n Else If x[i]+x[j]<9 Then j:=j+1\n Else i:=i-1;\n End;\n End;\n For i:=1 To n Do Begin\n If not(x1[i]) Then s1:=inttostr(x[i])+s1;\n If not(x2[i]) Then s2:=inttostr(x[i])+s2;\n End;\n WriteLn(s1);\n Write(s2);\nEnd.\n\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,M+,C+,H+,O-}\n{R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\ti, ls, n, cur, ans, p0 : longint;\n\tp, q : array[0..100010] of longint;\n\ts : string;\n\nprocedure solve(s : string);\n\nvar\n\ti, j, t, cur, cx, x, kk, xx : longint;\n\ta, b : array[0..10] of longint;\n\tok : boolean;\n\nbegin\n\tfillchar(a, sizeof(a), 0); \n\tfillchar(p, sizeof(p), 0); \n\tfillchar(q, sizeof(q), 0);\n\tls := length(s);\n\tfor i := 1 to ls do\n\t\tinc(a[ord(s[i]) - 48]);\n\tb := a;\n\tcur := 0;\n\tcx := ord(s[1]) - 48;\n\tfor i := 1 to 9 do begin\n\t\tt := 0;\n\t\tif (a[i] = 0) or (a[(10 - i) mod 10] = 0) then continue;\n\t\tfor j := 0 to 9 do\n\t\t\tinc(t, min(a[j], a[9 - j]));\n\t\tif cur < t then begin\n\t\t\tcur := t;\n\t\t\tcx := i;\n\t\tend;\n\tend;\n\tif cur = 0 then begin\n\t\tx := 1;\n\t\tfor i := 1 to a[0] do begin\n\t\t\tp[x] := 0;\n\t\t\tq[x] := 0;\n\t\t\tinc(x);\n\t\tend;\n\t\ta[0] := 0;\n\t\tfor i := 1 to a[5] do begin\n\t\t\tp[x] := 5;\n\t\t\tq[x] := 5;\n\t\t\tinc(x);\n\t\tend;\n\t\ta[5] := 0;\n\t\tfor i := 1 to 9 do\n\t\t\tfor j := 1 to a[i] do begin\n\t\t\t\tp[x] := i;\n\t\t\t\tq[x] := i;\n\t\t\t\tinc(x);\n\t\t\tend;\n\t\texit;\n\tend;\n\tp[1] := cx;\n\tdec(a[cx]);\n\tif a[(10 - cx) mod 10] > 0 then begin\n\t\tq[1] := (10 - cx) mod 10;\n\t\tdec(b[(10 - cx) mod 10]);\n\tend else begin\n\t\tq[1] := cx;\n\t\tdec(b[cx]);\n\tend; \n\tx := 2;\n\tok := (p[1] = 0) and (q[1] = 0);\n\tfor i := 0 to 9 do begin\n\t\tkk := min(a[i], b[(9 - i + byte(ok)) mod 10]);\n\t\tfor j := 1 to kk do begin\n\t\t\tp[x] := i;\n\t\t\tq[x] := (9 - i + byte(ok)) mod 10;\n\t\t\tinc(x);\n\t\t\tdec(a[i]);\n\t\t\tdec(b[(9 - i + byte(ok)) mod 10]); \t\n\t\tend;\n\tend;\n\txx := x;\n\tp0 := min(a[0], b[0]);\n\tfor i := 1 to 9 do\n\t\tfor j := 1 to a[i] do begin\n\t\t\tp[xx] := i;\n\t\t\tinc(xx);\n\t\tend;\n\txx := x; \n\tfor i := 1 to 9 do\n\t\tfor j := 1 to b[i] do begin\n\t\t\tq[xx] := i;\n\t\t\tinc(xx);\n\t\tend;\nend;\n\nprocedure swap(var a, b : char);\n\nvar\n\tt : char;\n\nbegin\n\tt := a;\n\ta := b;\n\tb := t;\nend;\n\nprocedure sort(a : array of char; l, r : longint);\n\nvar\n\ti, j : longint;\n\tx : char;\n\nbegin\n\ti := l;\n\tj := r;\n\tx := a[l + random(r - l + 1)];\n\trepeat\n\t\twhile a[i] < x do inc(i);\n\t\twhile a[j] > x do dec(j);\n\t\tif i <= j then begin\n\t\t\tswap(a[i], a[j]);\n\t\t\tinc(i);\n\t\t\tdec(j);\n\t\tend;\n\tuntil i > j;\n\tif l < j then sort(a, l, j);\n\tif i < r then sort(a, i, r);\nend;\n\nprocedure check(s, a : string);\n \nvar\n\ti, j, ps, r, l, qq : longint;\n \nbegin \n\tps := 1;\t\n\twhile ps > 0 do begin\n\t\tps := n - 1;\n\t\tqq := byte((ord(s[4]) + ord(a[4]) - 96) mod 10 = 0); \n\t\tif a = '0910' then begin\n\t\ta := '0910'\n\t\tend;\n\t\tif qq > 0 then\n\t\t\tfor i := 3 downto 1 do\n\t\t\t\tif ((ord(s[i]) + ord(a[i]) - 96) mod 10 = 0) and (s[i + 1] = '0') and (a[i + 1] = '0') then inc(qq) else \n\t\t\t\tif ((ord(s[i]) + ord(a[i]) - 96) mod 9 = 0) and (((ord(s[i]) + ord(a[i]) - 96) > 0)) and (s[i + 1] <> '0') then inc(qq) else break;\n\t\tans := max(ans, qq);\n\t\tif ans = 3 then begin\n\t\t\tans := 3;\n\t\tend;\n\t\ti := n;\n\t\twhile (ps > 0) and (s[ps] >= s[i]) do begin\n\t\t\tdec(ps);\n\t\t\tdec(i);\n\t\tend;\n\t\tj := n;\n\t\twhile (ps > 0) and (j > 0) and (s[ps] >= s[j]) do dec(j);\n\t\tif ps > 0 then swap(s[ps], s[j]);\n\t\tl := ps + 1;\n\t\tr := n;\n\t\twhile r > l do begin\n\t\t\tswap(s[l], s[r]);\n\t\t\tinc(l);\n\t\t\tdec(r);\n\t\tend;\n\tend;\nend;\n\nprocedure genPerm(s : string);\n \nvar\n\ti, j, ps, r, l : longint;\n\tss : string; \n\nprocedure sort(l, r : longint);\n\nvar\n\ti, j : longint;\n\tx : char;\n\nbegin\n\ti := l;\n\tj := r;\n\tx := s[l + random(r - l + 1)];\n\trepeat\n\t\twhile s[i] < x do inc(i);\n\t\twhile s[j] > x do dec(j);\n\t\tif i <= j then begin\n\t\t\tswap(s[i], s[j]);\n\t\t\tinc(i);\n\t\t\tdec(j);\n\t\tend;\n\tuntil i > j;\n\tif l < j then sort(l, j);\n\tif i < r then sort(i, r);\nend;\n \nbegin \n\tans := 0; \n\tsort(1, n); // if ALL permutations are required\n\tss := s;\n\tps := 1;\t\n\twhile ps > 0 do begin\n\t\tps := n - 1;\n\t\tcheck(ss, s);\n\t\ti := n;\n\t\twhile (ps > 0) and (s[ps] >= s[i]) do begin\n\t\t\tdec(ps);\n\t\t\tdec(i);\n\t\tend;\n\t\tj := n;\n\t\twhile (ps > 0) and (j > 0) and (s[ps] >= s[j]) do dec(j);\n\t\tif ps > 0 then swap(s[ps], s[j]);\n\t\tl := ps + 1;\n\t\tr := n;\n\t\twhile r > l do begin\n\t\t\tswap(s[l], s[r]);\n\t\t\tinc(l);\n\t\t\tdec(r);\n\t\tend;\n\tend;\nend;\n\nvar\n\ttt : longint;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input,'input.txt');\n\trewrite(output,'output.txt');\n{$ENDIF}\t\n\treadln(s);\n{$IFDEF AgsuL}\n\tN := 4;\nfor tt := 19 to 9999 do begin\n\ts := inttostr(tt); \n\twhile length(s) < 4 do s := '0' + s; \n\tsolve(s);\n\tcur := byte((p[1] + q[1]) mod 10 = 0);\n\tif cur > 0 then\n\t\tfor i := 2 to ls do\n\t\t\tif ((p[i] + q[i]) mod 10 = 0) and (p[i - 1] = 0) and (q[i - 1] = 0) then inc(cur) else \n\t\t\tif ((p[i] + q[i]) mod 9 = 0) and (p[i - 1] <> 0) and (p[i] + q[i] > 0) then inc(cur) else break;\n\tgenPerm(s);\n\tif cur <> ans then begin\n\t\twriteln('FAIL ', s, ' ', cur, ' ', ans);\n\t\thalt(0);\n\tend;\nend;\n{$ENDIF}\n\tsolve(s); \n\tfor i := ls - p0 downto 1 do\n\t\twrite(p[i]); \n\tfor i := 1 to p0 do\n\t\twrite(0); \n\twriteln; \n\tfor i := ls - p0 downto 1 do\n\t\twrite(q[i]); \n\tfor i := 1 to p0 do\n\t\twrite(0); \nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,M+,C+,H+,O-}\n{R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\ti, ls, n, cur, ans, p0 : longint;\n\tp, q : array[0..100010] of longint;\n\ts : string;\n\nprocedure solve(s : string);\n\nvar\n\ti, j, t, cur, cx, x, kk, xx : longint;\n\ta, b : array[0..10] of longint;\n\tok : boolean;\n\nbegin\n\tfillchar(a, sizeof(a), 0); \n\tfillchar(p, sizeof(p), 0); \n\tfillchar(q, sizeof(q), 0);\n\tls := length(s);\n\tfor i := 1 to ls do\n\t\tinc(a[ord(s[i]) - 48]);\n\tb := a;\n\tcur := 0;\n\tcx := ord(s[1]) - 48;\n\tfor i := 1 to 9 do begin\n\t\tt := 0;\n\t\tif (a[i] = 0) or (a[(10 - i) mod 10] = 0) then continue;\n\t\tfor j := 0 to 9 do\n\t\t\tif i <> j then inc(t, min(a[j], a[9 - j])) else inc(t, min(a[j] - 1, a[9 - j]));\n\t\tif cur < t then begin\n\t\t\tcur := t;\n\t\t\tcx := i;\n\t\tend;\n\tend;\n\tp[1] := cx;\n\tdec(a[cx]);\n\tif a[(10 - cx) mod 10] > 0 then begin\n\t\tq[1] := (10 - cx) mod 10;\n\t\tdec(b[(10 - cx) mod 10]);\n\tend else begin\n\t\tq[1] := cx;\n\t\tdec(b[cx]);\n\tend; \n\tx := 2;\n\tok := (p[1] = 0) and (q[1] = 0);\n\tfor i := 0 to 9 do begin\n\t\tkk := min(a[i], b[(9 - i + byte(ok)) mod 10]);\n\t\tfor j := 1 to kk do begin\n\t\t\tp[x] := i;\n\t\t\tq[x] := (9 - i + byte(ok)) mod 10;\n\t\t\tinc(x);\n\t\t\tdec(a[i]);\n\t\t\tdec(b[(9 - i + byte(ok)) mod 10]); \t\n\t\tend;\n\tend;\n\txx := x;\n\tp0 := min(a[0], b[0]);\n\tfor i := 1 to 9 do\n\t\tfor j := 1 to a[i] do begin\n\t\t\tp[xx] := i;\n\t\t\tinc(xx);\n\t\tend;\n\txx := x; \n\tfor i := 1 to 9 do\n\t\tfor j := 1 to b[i] do begin\n\t\t\tq[xx] := i;\n\t\t\tinc(xx);\n\t\tend;\nend;\n\nprocedure swap(var a, b : char);\n\nvar\n\tt : char;\n\nbegin\n\tt := a;\n\ta := b;\n\tb := t;\nend;\n\nprocedure sort(a : array of char; l, r : longint);\n\nvar\n\ti, j : longint;\n\tx : char;\n\nbegin\n\ti := l;\n\tj := r;\n\tx := a[l + random(r - l + 1)];\n\trepeat\n\t\twhile a[i] < x do inc(i);\n\t\twhile a[j] > x do dec(j);\n\t\tif i <= j then begin\n\t\t\tswap(a[i], a[j]);\n\t\t\tinc(i);\n\t\t\tdec(j);\n\t\tend;\n\tuntil i > j;\n\tif l < j then sort(a, l, j);\n\tif i < r then sort(a, i, r);\nend;\n\nprocedure check(s, a : string);\n \nvar\n\ti, j, ps, r, l, qq : longint;\n \nbegin \n\tps := 1;\t\n\twhile ps > 0 do begin\n\t\tps := n - 1;\n\t\tqq := byte((ord(s[4]) + ord(a[4]) - 96) mod 10 = 0); \n\t\tif a = '0910' then begin\n\t\ta := '0910'\n\t\tend;\n\t\tif qq > 0 then\n\t\t\tfor i := 3 downto 1 do\n\t\t\t\tif ((ord(s[i]) + ord(a[i]) - 96) mod 10 = 0) and (s[i + 1] = '0') and (a[i + 1] = '0') then inc(qq) else \n\t\t\t\tif ((ord(s[i]) + ord(a[i]) - 96) mod 9 = 0) and (((ord(s[i]) + ord(a[i]) - 96) > 0)) and (s[i + 1] <> '0') then inc(qq) else break;\n\t\tans := max(ans, qq);\n\t\tif ans = 3 then begin\n\t\t\tans := 3;\n\t\tend;\n\t\ti := n;\n\t\twhile (ps > 0) and (s[ps] >= s[i]) do begin\n\t\t\tdec(ps);\n\t\t\tdec(i);\n\t\tend;\n\t\tj := n;\n\t\twhile (ps > 0) and (j > 0) and (s[ps] >= s[j]) do dec(j);\n\t\tif ps > 0 then swap(s[ps], s[j]);\n\t\tl := ps + 1;\n\t\tr := n;\n\t\twhile r > l do begin\n\t\t\tswap(s[l], s[r]);\n\t\t\tinc(l);\n\t\t\tdec(r);\n\t\tend;\n\tend;\nend;\n\nprocedure genPerm(s : string);\n \nvar\n\ti, j, ps, r, l : longint;\n\tss : string; \n\nprocedure sort(l, r : longint);\n\nvar\n\ti, j : longint;\n\tx : char;\n\nbegin\n\ti := l;\n\tj := r;\n\tx := s[l + random(r - l + 1)];\n\trepeat\n\t\twhile s[i] < x do inc(i);\n\t\twhile s[j] > x do dec(j);\n\t\tif i <= j then begin\n\t\t\tswap(s[i], s[j]);\n\t\t\tinc(i);\n\t\t\tdec(j);\n\t\tend;\n\tuntil i > j;\n\tif l < j then sort(l, j);\n\tif i < r then sort(i, r);\nend;\n \nbegin \n\tans := 0; \n\tsort(1, n); // if ALL permutations are required\n\tss := s;\n\tps := 1;\t\n\twhile ps > 0 do begin\n\t\tps := n - 1;\n\t\tcheck(ss, s);\n\t\ti := n;\n\t\twhile (ps > 0) and (s[ps] >= s[i]) do begin\n\t\t\tdec(ps);\n\t\t\tdec(i);\n\t\tend;\n\t\tj := n;\n\t\twhile (ps > 0) and (j > 0) and (s[ps] >= s[j]) do dec(j);\n\t\tif ps > 0 then swap(s[ps], s[j]);\n\t\tl := ps + 1;\n\t\tr := n;\n\t\twhile r > l do begin\n\t\t\tswap(s[l], s[r]);\n\t\t\tinc(l);\n\t\t\tdec(r);\n\t\tend;\n\tend;\nend;\n\nvar\n\ttt : longint;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input,'input.txt');\n\trewrite(output,'output.txt');\n{$ENDIF}\t\n\treadln(s);\n{$IFDEF AgsuL}\n\tN := 4;\nfor tt := 19 to 9999 do begin\n\ts := inttostr(tt); \n\twhile length(s) < 4 do s := '0' + s; \n\tsolve(s);\n\tcur := byte((p[1] + q[1]) mod 10 = 0);\n\tif cur > 0 then\n\t\tfor i := 2 to ls do\n\t\t\tif ((p[i] + q[i]) mod 10 = 0) and (p[i - 1] = 0) and (q[i - 1] = 0) then inc(cur) else \n\t\t\tif ((p[i] + q[i]) mod 9 = 0) and (p[i - 1] <> 0) and (p[i] + q[i] > 0) then inc(cur) else break;\n\tgenPerm(s);\n\tif cur <> ans then begin\n\t\twriteln('FAIL ', s, ' ', cur, ' ', ans);\n\t\thalt(0);\n\tend;\nend;\n{$ENDIF}\n\tsolve(s); \n\tfor i := ls - p0 downto 1 do\n\t\twrite(p[i]); \n\tfor i := 1 to p0 do\n\t\twrite(0); \n\twriteln; \n\tfor i := ls - p0 downto 1 do\n\t\twrite(q[i]); \n\tfor i := 1 to p0 do\n\t\twrite(0); \nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n"}], "src_uid": "34b67958a37865e1ca0529bbf528dd9a"} {"source_code": "var d,l,v1,v2:int64;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2):0:10);\nend.", "positive_code": [{"source_code": "var\n\tn, l, r, k, l2, r1, r2: longint;\n\ta, b: array of integer;\n\t\nbegin\n\t\n\treadln(n, l, r, k);\n\twriteln((l-n) / (r+k));\n\t\nend.\n"}, {"source_code": "var\n d,l,v1,v2:integer;\nbegin\n read(d,L,v1,v2);\n write((L-d)/(v1+v2));\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n d,l,v1,v2:integer;\nbegin\n readln(d,l,v1,v2);\n writeln((l-d)/(v1+v2):1:6);\nend."}, {"source_code": "program k;\nvar v1,v2,l,d:longint; u:real;\n{procedure qs(l,r:longint);\nvar i,j,x,y:longint;\nbegin\ni:=l; j:=r;\nx:=a[(l+r) div 2];\nrepeat\n while a[i]x do dec(j);\n if i<=j then\n begin\n y:=a[i]; a[i]:=a[j]; a[j]:=y; inc(i); dec(j);\n end;\nuntil i>j;\nif lb then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=4;\n for i:=1 to n do read(a[i]);\n write((a[2]-a[1])/(a[3]+a[4]):0:9);\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program z1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n l, d, v1, v2: longint;\n t: real;\nbegin\n read(d, l, v1, v2);\n t := (l - d) / (v1 + v2);\n write(t:0:6);\n readln;\n readln;\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar z,a,b,c,d:integer; x:extended;\nbegin\nreadln(a,b,c,d);\nx:=1000000;\nz:=0;\nx:=b-a;\nx:=x/(c+d);\nwriteln(x);\nreadln;\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+,O-}\nuses SysUtils,Math;\nvar n,m,i,j,l,k,a,b,d:longint;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(d,l,a,b);\n writeln((l-d)/(a+b):0:6);\n //readln;\nend.\n "}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n d,l,v1,v2:real;\nbegin\n readln(d,l,v1,v2);\n writeln((l-d)/(v1+v2):1:7);\n readln;\n readln;\nend.\n"}, {"source_code": "var\n f,d,m,l:double;\n\nbegin\n readln(f,d,m,l);\n f:=(d-f)/(m+l);\n Write(f:0:7);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a,n,v,v2:Int64;\nbegin\nread(a);\nread(n);\nread(v);\nread(v2);\nn:=n-a;\nWriteln((n/(v+v2)));\nend."}, {"source_code": "var d,l,v1,v2:longint;\nt:real;\nbegin\n readln(d,l,v1,v2);\n t:=(l-d)/(v1+v2);\n writeln(t:0:6);\nend."}, {"source_code": "var i, j, d, l, v1 ,v2:longint;\nbegin\nreadln(d,l,v1,v2);\nl:=l-d;\nwrite(l/(v1+v2):1:6);\nEnd."}, {"source_code": "var l,d,v1,v2:real;\nbegin\nread (d,l,v1,v2);\nwrite((l-d)/(v1+v2));\nend.\n"}, {"source_code": "Program uyf;\nVar d,l,v1,v2,res:Real;\nBegin\n\n read(d);\n read(l);\n read(v1);\n read(v2);\n l:=l-d;\n res:=l/(v1+v2);\n writeln(res);\n\nEnd."}, {"source_code": "var d,l,v,v2:longint;\n otv:real;\nbegin\n read (d,l,v,v2);\n v:=v+v2;\n l:=l-d;\n otv:=l/v;\n write (otv);\nend."}, {"source_code": "var\n d,l,v1,v2:extended;\nbegin\n readln(d,l,v1,v2);\n writeln((l-d)/(v1+v2):0:6);\nend."}, {"source_code": "var d,l,v1,v2:int64;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2):0:12);\nend."}, {"source_code": "Var d, v1, v2, m1, m2, l, t: real;\n Begin\n Read(d, l, v1, v2);\n t:=(l-d)/(v1+v2);\n Write(t:1:6);\n\n End."}, {"source_code": "program a;\nvar d,l,v,w:longint;\nbegin\n readln(d,l,v,w);\n writeln(((l-d)/(v+w)):0:6);\nend.\n\n"}, {"source_code": "program z1;\nvar i,j,n,k,l,r,v1,v2,d:longint;\nres:extended;\nbegin\nreadln(d,r,v1,v2);\nn:=r-d;\nres:=n/(v1+v2);\nwriteln(res:0:10);\nend.\n"}, {"source_code": "var ans,d,l,v,v1,v2:real;\n begin\n read(d,l,v1,v2);\n v := v1+v2;\n ans := (l-d)/v;\n write(ans:18:6);\n end."}, {"source_code": "var d,L,v1,v2:real;\nbegin\nread(d,L,v1,v2);\nwriteln((L-d)/(v1+v2));\nend."}, {"source_code": "var n,i,j,k,d,a,b:longint;\n r:real;\nbegin\n readln(n,d,a,b);\n writeln((d-n)/(a+b):0:6);\nend.\n"}, {"source_code": "program safa;\nvar d,t,v1,v2:word;\nv:longint;\notv:real;\nbegin\nread(d,t,v1,v2);\nv:=v2+v1;\notv:= abs((d-t) / v);\nwrite(otv:0:6);\nend."}, {"source_code": "program yan;\n uses math;\n var a,b,c,x,y:longint; ans,v:extended;\nbegin\n readln(a,b,c,x);\n writeln((b-a)/(c+x));\nend."}, {"source_code": "var\n\td, l, v1, v2: integer;\n\tans: real;\n\t\nbegin\n\treadln(d, l, v1, v2);\n\tans:= (l - d)/(v1 + v2);\n\twriteln(ans:0:10)\nend."}, {"source_code": "var d,l,v1,v2:real;\nbegin\n read(d,l,v1,v2);\n v1:=v1+v2;\n l:=l-d;\n write((l/v1):1:6);\nend."}, {"source_code": "var\n d,l,v1,v2:double;\nbegin\n readln(d,l,v1,v2);\n writeln((l-d)/(v1+v2));\nend.\n"}, {"source_code": "var\n d, l, v1, v2: Integer;\n \nbegin\n Read (d, l, v1, v2);\n \n WriteLn ((l - d) / (v1 + v2))\nend."}, {"source_code": "var\nd,l,v1,v2:longint;\nt:real;\nbegin\nreadln(d,l,v1,v2);\nt:=(l-d)/(v1+v2);\nwriteln(t);\nend."}, {"source_code": "var d,l,v1,v2:real;\n begin\n readln(d,l,v1,v2);\n write((l-d)/(v1+v2));\n end."}, {"source_code": "var pr,t,d,l,v1,v2:longint;\nbegin\nreadln(d,l,v1,v2);\n\nwriteln((l-d)/(v1+v2):0:6);\n\n\n\nend."}, {"source_code": "var\nd,L,v1,v2,q:longint;\nw:real;\nbegin\nread(d,L,v1,v2);\nq:=v1+v2;\nw:=(L-d)/q;\nwrite(w:0:6);\nend."}, {"source_code": "Program a;\nvar d,l,v1,v2,s,v:integer;\n t:real;\nbegin\nread(d,l,v1,v2);\ns:=l-d;\nv:=v1+v2;\nt:=s/v;\nwrite(t:0:6);\nend."}, {"source_code": "var d,l,v1,v2,k:LongInt;\n s,t:extended;\nBegin\n Read(d,l,v1,v2);\n l:=l-d;\n s:=l/(v1+v2);\n t:=s;\n Write(t:0:6);\nEnd."}, {"source_code": "{$Mode Objfpc}\n{$Macro On}\n{$Define maicute:= for i := 1 to n do}\n\nUses\n Math;\n\nConst\n maxN = round(1e5);\n maxM = round(1e6);\n oo = round(1e10);\n\nVar\n fi, fo : textfile;\n n , d, l, v1, v2: Integer;\n\nProcedure Openfile;\nbegin\n Assign(fi, ''); reset(fi);\n Assign(fo, ''); rewrite(fo);\nend;\n\nProcedure Init;\nbegin\nend;\n\nProcedure Enter;\nbegin\n ReadLn(fi, d, l, v1, v2);\nend;\n\nProcedure Solve;\nvar\n c , khoangcachd, khoangcachconlai, khoangcachchet : Extended;\nbegin\n c := d / (v1 + v2);\n khoangcachd := c * v1;\n c := l / (v1 + v2);\n khoangcachchet := c * v1;\n khoangcachconlai := khoangcachchet - khoangcachd;\n writeln(fo, khoangcachconlai / v1 :0 : 6);\nend;\n\nProcedure Printresult;\nbegin\nend;\n\nProcedure Closefile;\nbegin\n Close(fi);\n Close(fo);\nend;\n\nBegin\n OpenFile;\n Init;\n Enter;\n Solve;\n Printresult;\n CloseFile;\nEnd."}, {"source_code": "var\n\td,l,n,m\t: integer;\nbegin\n\treadln(d,l,n,m);\n\twrite((l-d)/(m+n):0:10);\nend."}, {"source_code": "var d,l,v1,v2:int64;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2):0:12);\nend."}, {"source_code": "const fi='';\n fo='';\nvar d,l,v1,v2:longint;\n\nBEGIN\n assign(input,fi);reset(input);\n read(d,l,v1,v2);\n close(input);\n\n assign(output,fo);rewrite(output);\n write((l-d)/(v1+v2):0:7);\n close(output);\nEND.\n"}, {"source_code": "var\n ans:double;\n d,l,v1,v2:longint;\nbegin\n readln(d,l,v1,v2);\n ans:=(l-d)/(v1+v2);\n writeln(ans:0:6);\nend."}, {"source_code": "program lukea;\n\nvar\n d,length,v1,v2,l,r,t:word;\n k:real;\n\nbegin\n readln(d,length,v1,v2);\n t:=v1+v2;\n k:=0;\n while length>d do begin\n l:=0;\n while l<=v1 do begin\n Inc(l);\n Dec(length);\n k:=k+(1/t);\n if length=d then break;\n end;\n if length=d then break;\n r:=0;\n while r<=v2 do begin\n Inc(r);\n Dec(length);\n k:=k+(1/t);\n if length=d then break;\n end;\n if length=d then break;\n end;\n writeln(k:0:6);\n readln;\nend."}, {"source_code": "{$MODE OBJFPC}\nuses\n Math;\nconst\n {$IFDEF ONLINE_JUDGE}\n InputFile = '';\n OutputFile = '';\n {$ELSE}\n InputFile = '';\n OutputFile = '';\n {$ENDIF}\n // maxN = ;\nvar\n fi, fo: TextFile;\n d, L, v1, v2: Integer;\n\nprocedure Enter;\nvar\n i: Integer;\nbegin\n Assign(fi, inputFile); Reset(fi);\n Assign(fo, outputFile); Rewrite(fo);\n Readln(fi, d, L, v1, v2);\nend;\n\nprocedure Solve;\nvar\n i: Integer;\nbegin\n Writeln(fo, ((L - d)/(v1+v2)):0:6);\nend;\n\nprocedure Clean;\nbegin\n CloseFile(fi); CloseFile(fo);\nend;\n\n{ MAIN }\nbegin\n Enter;\n Solve;\n Clean;\nend.\n{ END OF MAIN }\n"}, {"source_code": "var i, j, d, l, v1 ,v2:longint;\nbegin\nreadln(d,l,v1,v2);\nl:=l-d;\nwrite(l/(v1+v2):1:6);\nEnd."}, {"source_code": "var a,b,c,d,n:real;\nbegin\nread(a,b,c,d);\nwriteln(abs(a-b)/(c+d));\nend.\n"}, {"source_code": "var i,j,r,n,d,v1,v2:longint;\n ans:real;\n\nbegin\n read(d,r,v1,v2);\n ans:=(r-d) / (v1+v2);\n write(ans:0:6);\nend."}, {"source_code": "var d,l,v1,v2:integer;t:real;\nbegin\nreadln(d,l,v1,v2);\nl:=l-d;\nt:=l/(v1+v2);\nwrite(t:0:20);\nend."}, {"source_code": "var\n d, l, v1, v2 : longint;\n t : real;//double;\nbegin\n read(d, l, v1, v2);\n l := l - d;\n t := l / (v1 + v2);\n writeln(t : 0 : 6);\nend."}, {"source_code": "var d,l,v1,v2,i,j:longint;\nbegin\n readln(d,l,v1,v2);\n writeln(((l-d)/(v1+v2)):0:6);\nend."}, {"source_code": "var d,l,v1,v2:real;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2):0:8)\nend."}, {"source_code": "var a,s,d,f,g,h:real;\nbegin\nread(a,s,d,f);\nwrite((s-a)/(d+f));\nend.\n"}, {"source_code": "var v,d,l,l1,l2,v1,v2,q,w,e,r:longint;\nt:real;\nbegin\nreadln(d,l2,v1,v2); l1:=0;\nv:=v1+v2; l:=l2-l1-d;\nt:=l/v;\nwriteln(t:20:20);\nend."}, {"source_code": "var\n d, l, v1, v2: extended;\n\nbegin\n readln(d, L, v1, v2);\n \n l := l - d;\n \n if v1 - v2 >= 0 then\n begin\n writeln(L / (v1 + v2):5:6);\n end\n \telse \n if v1 - v2 < 0 then\n begin\n writeln(L / (v2 + v1):5:6);\n end;\nend."}, {"source_code": "var d,l,v1,v2:longint;\nbegin\n read(d,l,v1,v2);\n writeln((l-d)/(v1+v2):0:8);\nend."}, {"source_code": "var l,d,v1,v2:longint;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2));\nend."}, {"source_code": "var a,b,d,l,v1,v2:longint;\nt:real;\nbegin\nreadln(d,l,v1,v2);\nt:=(l-d)/(v1+v2);\nwriteln(t);\nend."}, {"source_code": "var a,b,c,d,s,r:int64;\not:real;\nbegin\n readln(a,b,c,d);\n s:=c+d;\n r:=b-a;\n ot:=r/s;\n writeln(ot:0:6);\nend."}, {"source_code": "program fsdaf;\nvar d,l,v1,v2:integer;k:real;\nbegin\nread(d,l,v1,v2);\nwrite((l-d)/(v1+v2));\nend."}, {"source_code": "program sum_delit;\nvar\n d,l,v1,v2,vs:longint;\n t:extended;\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(d,l,v1,v2);\n\n vs:=v1+v2;\n\n t:=(l-d)/vs;\n\n writeln(t:0:6);\n\n\n//Close(input); Close(output);\nend.\n"}, {"source_code": "var d,l,v1,v2:int64;\nbegin\n read(d,l,v1,v2);\n write((l-d)/(v1+v2):0:12);\nend."}, {"source_code": "var\nd,l,v1,v2:longint;\not:real;\nbegin\n readln(d,l,v1,v2);\n ot:=(l-d)/(v1+v2);\n write(ot:0:6);\nend."}, {"source_code": "program save_luke;\nvar\nt:real;\nd,L,v1,v2:longint;\nbegin\nreadln(d,L,v1,v2);\nt:=(L-d)/(v1+v2);\nwriteln(t:0:6);\nreadln;\nend."}, {"source_code": "var a,b,c,d:real;\nbegin\nreadln(c,d,a,b);\nwrite((d-c)/(a+b):0:6);\nend."}, {"source_code": "Const fi='';\n fo='';\nvar a,b,c,d,l,r:Longint;\nProcedure DocFIle;\nvar f:TEXT;\nbegin\n Assign(f,fi);Reset(f);\n Read(f,a,b,c,d);\n Close(F);\nend;\nProcedure GhiFIle;\nvar f:TEXT;\nbegin\n Assign(f,fo);Rewrite(f);\n l:=0;r:=b;\n while (r-l)>a do\n begin\n l:=l+c;\n r:=r-d;\n end;\n Write(f,(c*r-a*c+d*l)/((d+c)*c):0:6);\n Close(F);\nend;\n\nbegin\n DocFIle;\n GHiFIle;\nend.\n"}, {"source_code": "var\n a, b, c, d, e, f: int64;\n k, p: double;\n \nbegin\n readln(a, b, c, d);\n e := b - a;\n f := c + d;\n k := e / f;\n writeln(k:1:20);\nend."}, {"source_code": "var\n a,s,d,f:real;\nbegin\n read(a,s,d,f);\n writeln(abs((a-s)/(d+f)));\n readln;\n readln;\nend.\n"}, {"source_code": "var d,l,a,b:longint;\nbegin\n readln(d,l,a,b);\n writeln((l-d)/(a+B):0:6);\nend."}, {"source_code": "Var d , L , v1 , v2 : Longint;\n\nBegin\n Read(d , L , v1 , v2);\n Writeln((L - d) / (v1 + v2));\nEnd."}, {"source_code": "\nvar\n d,l,v1,v2:longint;\n kq:real;\nbegin\n read(d,l,v1,v2);\n kq:=(l-d)/(v1+v2);\n write(kq);\nend."}], "negative_code": [{"source_code": "var a,s,d,f,g,h:real;\nbegin\nread(a,s,d,f);\nwrite((d+f)/(s-a));\nend.\n"}, {"source_code": "var\n a,s,d,f:real;\nbegin\n read(a,s,d,f);\n writeln((a-s)/(d+f));\n readln;\n readln;\nend.\n"}, {"source_code": "var d, L, v1, v2,e,w,q:real;\nbegin \n read(d, L, v1, v2);\n w:=L; e:=0;\n while d=w then break;\n e:=e+1;\n q:=q+v1;\n w:=w-v2;\n \n end;\n write(e:0:6);\n end."}, {"source_code": "var a,b,i,j,k,n:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n if ((a div 2) mod 2 = 0) or ((b div 2) mod 2 = 0) then\n begin\n writeln(a*b div 2);\n end\n else writeln((a*b div 2)+1);\n end;\nend.\n"}, {"source_code": "uses math;\nVar a:array[1..100000] of longint;\n n,i,k,mx,mn,ans,v1,v2,l,d,t1,t2:longint;\n function f(i:longint):longint;\n begin\n exit(i div v1);\n end;\n function f2(i:longint):longint;\n begin\n exit((abs(l-i)) div v2);\n end;\n begin\n Read(d,l,v1,v2);\n For i:=d to l do\n begin\n t1:=f(i-d);\n t2:=f2(i+d);\n // writeln(t1,' ',t2);\n mx:=max(mx,min(t1,t2));\n end;\n write(mx,'.000000');\n end."}, {"source_code": "uses math;\nVar a:array[1..100000] of longint;\n n,i,k,mx,mn,ans,v1,v2,l,d,t1,t2:longint;\n function f(i:longint):longint;\n begin\n exit(i div v1);\n end;\n function f2(i:longint):longint;\n begin\n exit((abs(l-i)) div v2);\n end;\n begin\n Read(d,l,v1,v2);\n For i:=d to l do\n begin\n t1:=f(i-d);\n t2:=f2(i+d);\n writeln(t1,' ',t2);\n mx:=max(mx,min(t1,t2));\n end;\n write(mx,'.000000');\n end."}], "src_uid": "f34f3f974a21144b9f6e8615c41830f5"} {"source_code": "var\nq,xx,yy,i,j,s,l1,l2,bits,n,m,k:longint;\nans:int64;\na:array[0..15,0..15]of longint;\nb:array[0..1 shl 11,0..1 shl 11]of int64;\n\nfunction bit(x,i:longint):boolean;\n begin\n bit:=(x and (1 shl i))>0;\n end;\n\n begin\n read(n,m,k);\n fillchar(b,sizeof(b),0);\n for i:=1 to m do\n begin\n read(xx,yy);\n xx:=xx-1;yy:=yy-1;\n a[xx,yy]:=1;\n a[yy,xx]:=1;\n\n b[(1 shl xx) or (1 shl yy),(1 shl xx)or(1 shl yy)]:=1;\n end;\n\n s:=1 shl n;\n b[0,0]:=1;\n ans:=0;\n for i:=1 to s-1 do\n for j:=1 to s-1 do\n begin\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if b[i,j]<>1 then\n begin\n for l2:=0 to n-1 do\n for l1:=0 to n-1 do\n if a[l1,l2]=1 then\n begin\n if (bit(i,l1))and(bit(j,l2))and(not bit(j,l1)) then\n begin\n b[i,j]:=b[i xor (1 shl l2),j xor (1 shl l2) xor (1 shl l1)]\n +b[i xor (1 shl l2),j xor (1 shl l2)]\n +b[i,j];\n end;\n end;\n b[i,j]:=b[i,j] div bits;\n end;\n\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if i=s-1 then\n if bits=k then ans:=ans+b[i,j];\n end;\n writeln(ans);\n end.", "positive_code": [{"source_code": "type\n node=record\n x,next:longint;\n end;\nvar\n f:Array[0..1 shl 10-1,0..1 shl 10-1]of longint;\n tot,n,m,kk:longint;\n data:array[1..500]of node;\n g:Array[1..10]of longint;\nprocedure addedge(x,y:longint);\nbegin\n inc(tot);\n data[tot].x:=y;\n data[tot].next:=g[x];\n g[x]:=tot;\nend;\nprocedure init;\nvar\n i,t,x,y:longint;\nbegin\n readln(n,m,kk);\n fillchar(f,sizeof(f),0);\n fillchar(g,sizeof(g),255);\n tot:=0;\n for i:=1 to m do\n begin\n readln(x,y);\n addedge(x,y);\n addedge(y,x);\n t:=(1 shl(x-1))or(1 shl(y-1));\n f[t,t]:=1;\n end;\nend;\nfunction get(t:longint):longint;\nvar\n x:longint;\nbegin\n x:=0;\n while t<>0 do\n begin\n if t and 1<>0 then inc(x);\n t:=t shr 1;\n end;\n exit(x);\nend;\nprocedure dp;\nvar\n ans,i,j,k,p,t,tmp:longint;\nbegin\n for i:=1 to(1 shl n)-1 do\n begin\n j:=i;\n while j>0 do\n begin\n if f[i,j]<>0 then\n begin\n for k:=1 to n do\n if (1 shl(k-1))and i<>0 then\n begin\n p:=g[k];\n while p<>-1 do\n begin\n if (1 shl (data[p].x-1))and i=0 then\n begin\n tmp:=(1 shl (data[p].x-1))or(j and (not (1 shl (k-1))));\n if tmp shr data[p].x=0 then\n inc(f[i or (1 shl (data[p].x-1)),tmp],f[i,j]);\n end;\n p:=data[p].next;\n end;\n end;\n end;\n j:=(j-1)and i;\n end;\n end;\n ans:=0;\n for i:=0 to (1 shl n)-1 do\n if get(i)=kk then\n ans:=ans+f[(1 shl n)-1,i];\n writeln(ans);\nend;\n\nbegin\n\n init;\n dp;\nend."}, {"source_code": "type\n re=record\n adj,next:longint;\n end;\n\nvar\n n,m,e,tot,ans:longint;\n f:array[0..1024,0..1024]of longint;\n g:array[0..9]of longint;\n map:array[1..100]of re;\n\nprocedure add(x,y:longint);\nbegin\n inc(tot);\n map[tot].adj:=y;\n map[tot].next:=g[x];\n g[x]:=tot;\nend;\n\nfunction get(x:longint):longint;\nvar\n t:longint;\n\nbegin\n t:=0;\n while x>0 do begin\n t:=t+(x and 1);\n x:=x shr 1;\n end;\n exit(t);\nend;\n\nprocedure init;\nvar\n i,j,x,y,k,l,t:longint;\n\nbegin\n fillchar(f,sizeof(f),0);\n fillchar(g,sizeof(g),0);\n tot:=1;\n for i:=1 to m do begin\n readln(x,y);\n dec(x);\n dec(y);\n add(x,y);\n add(y,x);\n j:=(1 shl x)+(1 shl y);\n f[j,j]:=1;\n end;\n\n for i:=1 to 1 shl n-1 do begin\n j:=i;\n while j>0 do begin\n if f[i,j]>0 then begin\n for l:=0 to n-1 do if (1 shl l) and i<>0 then begin\n t:=g[l];\n while t<>0 do begin\n if (1 shl map[t].adj)and i=0 then begin\n x:=(1 shl map[t].adj) or (j and (not (1 shl l)));\n if x shr (map[t].adj+1)=0 then\n inc(f[i+(1 shl map[t].adj),x],f[i,j]);\n end;\n t:=map[t].next;\n end;\n end;\n end;\n j:=(j-1)and i;\n end;\n end;\n\n ans:=0;\n for i:=1 to 1 shl n-1 do if get(i)=e then ans:=ans+f[1 shl n-1,i];\n writeln(ans);\nend;\n\nbegin\n readln(n,m,e);\n init;\nend."}, {"source_code": "var\n n,m,k,i,j,x,y,ok,ans:longint;\n f,g:array[0..2050000]of longint;\n a:array[1..100,1..2]of longint;\n t,p:array[0..100]of longint;\nbegin\n // assign(input,'a.in');\n // reset(input);\n read(n,m,k);\n for i:=1 to m do begin\n read(a[i,1],a[i,2]);\n end;\n f[0]:=1;\n t[1]:=3;\n p[0]:=1;\n for i:=1 to (n-1) do p[i]:=p[i-1]*i;;\n for i:=2 to n do begin\n t[i]:=t[i-1] shl 2;\n end;\n for i:=0 to 1 shl (2*n)-1 do begin\n ok:=0;\n if i=23 then\n j:=j;\n for j:=1 to n do begin\n x:=(i and t[j]) shr ((j-1)*2);\n if x=1 then inc(g[i]);\n if x=3 then ok:=1;\n end;\n if ok=0 then g[i]:=1;\n end;\n for i:=0 to 1 shl (2*n)-1 do begin\n if i=23 then\n j:=j;\n if i=71 then\n j:=j;\n if f[i]<>0 then begin\n if i<>0 then\n f[i]:=f[i]div g[i];\n for j:=1 to m do begin\n x:=i and t[a[j,1]];\n y:=i and t[a[j,2]];\n if (x=0)or(y=0) then begin\n if (i<>0)and(x=0)and(y=0) then continue;\n if x=0 then x:=1 shl (a[j,1]*2-2)\n else x:=1 shl (a[j,1]*2-1);\n if y=0 then y:=1 shl (a[j,2]*2-2)\n else y:=1 shl (a[j,2]*2-1);\n inc(f[i or x or y],f[i]);\n if (i or x or y=343) then\n y:=y;\n end;\n end;\n end;\n end;\n for i:=0 to 1 shl (2*n)-1 do begin\n ok:=0;\n if i=87383 then\n y:=y;\n y:=0;\n for j:=1 to n do begin\n x:=(i and t[j]) shr ((j-1)*2);\n if x=0 then begin\n ok:=-1;\n break;\n end;\n if x=1 then inc(y);\n end;\n if (ok=0)and(y=k) then\n ans:=ans+f[i];\n end;\n writeln(ans);\n close(input);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils, Math;\n\nvar\n ans, edge : int64;\n x, n, m, k, i, j, u, v, top : integer;\n a : array[1..10, 1..10] of boolean;\n d : array[0..1023, 0..1023] of int64;\n st : array[1..2] of integer;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n read(n, m, k);\n for i := 1 to m do begin\n read(u, v);\n a[u][v] := true;\n a[v][u] := true;\n end;\n\n ans := 0;\n for i := 1 to 1 shl n - 1 do begin\n j := i;\n u := 1;\n x := 1;\n top := 0;\n while x <= j do begin\n if x and j <> 0 then begin\n inc(top);\n if top <= 2 then\n st[top] := u;\n end;\n x := x shl 1;\n inc(u);\n end;\n if top = 1 then begin\n j := i and (j - 1);\n continue;\n end else\n if top = 2 then begin\n if a[st[1]][st[2]] then\n d[i][j] := 1;\n if (top = k) and (i = 1 shl n - 1) then\n inc(ans, d[i][j]);\n// writeln(i, ' ', j, ' ', d[i][j]);\n j := i and (j - 1);\n end;\n while j <> 0 do begin\n top := 0;\n x := 1;\n while x <= j do begin\n if x and j <> 0 then\n inc(top);\n x := x shl 1;\n end;\n u := 1;\n x := 1;\n while (x <= j) do begin\n if j and x <> 0 then begin\n for v := 1 to n do\n if (a[u][v]) and (i and (1 shl (v - 1)) <> 0) and (j and (1 shl (v - 1)) = 0) then\n inc(d[i][j], d[i xor (1 shl (u - 1))][j xor (1 shl (u - 1)) or (1 shl (v - 1))] + d[i xor (1 shl (u - 1))][j xor (1 shl (u - 1))]);\n end;\n x := x shl 1;\n inc(u);\n end;\n d[i][j] := d[i][j] div top;\n if (top = k) and (i = 1 shl n - 1) then\n inc(ans, d[i][j]);\n// writeln(i, ' ', j, ' ', d[i][j]);\n j := i and (j - 1);\n end;\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, m, k, s, t, a, b, i, j, z, h, nv : integer;\n ans : extended;\n c : array[0..1025] of integer;\n d : array[0..1025, 0..1025] of extended;\n sz : array[0..11] of integer;\n r : array[0..11, 0..11] of integer;\n\nfunction good(a, b : integer) : boolean;\nbegin\n result := a and (1 shl (b - 1)) > 0;\nend;\n\nfunction add(a, b : integer) : integer;\nbegin\n result := a xor (1 shl (b - 1));\nend;\n\nfunction calc(a : integer) : integer;\nvar i : integer;\nbegin\n result := 0;\n for i := 1 to n do\n if good(a, i) then\n inc(result);\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n read(n, m, k);\n for i := 1 to m do begin\n read(a, b);\n inc(sz[a]);\n r[a, sz[a]] := b;\n inc(sz[b]);\n r[b, sz[b]] := a;\n end;\n for i := 1 to n do\n for j := 1 to sz[i] do begin\n a := add(add(0, i), r[i, j]);\n d[a, a] := 1;\n end;\n s := 1 shl n - 1;\n for i := 0 to s do\n c[i] := calc(i);\n for i := 0 to s do begin\n j := i;\n while j > 0 do begin\n if d[i, j] > 0 then begin\n for z := 1 to n do begin\n if not good(i, z) then\n continue;\n if good(j, z) then\n t := 1\n else\n t := 2;\n for h := 1 to sz[z] do begin\n nv := r[z, h];\n if not good(i, nv) then begin\n if t = 1 then begin\n a := add(i, nv);\n b := add(add(j, z), nv);\n d[a, b] := d[a, b] + d[i, j] / c[b];\n end\n else begin\n a := add(i, nv);\n b := add(j, nv);\n d[a, b] := d[a, b] + d[i, j] / c[b];\n end;\n end;\n end;\n end;\n end;\n j := (j - 1) and i;\n end;\n end;\n ans := 0;\n for i := 0 to s do\n if c[i] = k then\n ans := ans + d[s, i];\n writeln(ans:0:0);\nend.\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, m, k, a, b, c, i, j, z, h : integer;\n ans : extended;\n d : array[0..1025, 0..1025] of extended;\n r : array[0..11, 0..11] of boolean;\n\nfunction good(a, b : integer) : boolean;\nbegin\n result := a and (1 shl (b - 1)) > 0;\nend;\n\nfunction add(a, b : integer) : integer;\nbegin\n result := a xor (1 shl (b - 1));\nend;\n\nfunction calc(a : integer) : integer;\nvar i : integer;\nbegin\n result := 0;\n for i := 1 to n do\n if good(a, i) then\n inc(result);\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n read(n, m, k);\n for i := 1 to m do begin\n read(a, b);\n r[a, b] := true;\n r[b, a] := true;\n end;\n for i := 1 to n do\n for j := 1 to n do\n if r[i, j] then begin\n a := add(add(0, i), j);\n b := a;\n d[a, b] := 1;\n end;\n for i := 0 to 1 shl n - 1 do\n for j := 0 to 1 shl n - 1 do begin\n if d[i, j] = 0 then\n continue;\n for z := 1 to n do begin\n if not good(i, z) then\n continue;\n for h := 1 to n do\n if (r[z, h]) and (not good(i, h)) then begin\n if good(j, z) then begin\n a := add(i, h);\n b := add(add(j, z), h);\n c := calc(b);\n d[a, b] := d[a, b] + d[i, j] / c;\n end\n else begin\n a := add(i, h);\n b := add(j, h);\n c := calc(b);\n d[a, b] := d[a, b] + d[i, j] / c;\n end;\n end;\n end;\n end;\n ans := 0;\n for i := 0 to 1 shl n - 1 do\n if calc(i) = k then\n ans := ans + d[1 shl n - 1, i];\n writeln(ans:0:0);\nend.\n"}, {"source_code": "var n,m,k,i,j,l,x,y,xx,yy,ans:longint;\n a,b:array[1..90]of longint;\n f:array[1..1024,0..1024]of longint;\nbegin\n read(n,m,k);\n for i:=1 to m do\n begin\n read(a[i],b[i]);\n b[m+i]:=a[i];a[m+i]:=b[i];\n inc(f[(1<<(a[i]-1))or(1<<(b[i]-1)),(1<<(a[i]-1))or(1<<(b[i]-1))],2);\n end;\n m:=m+m;\n for i:=1 to (1<0 then\n begin\n x:=j;y:=0;\n while x>0 do\n begin\n inc(y);x:=x and (x-1);\n end;\n if f[i,j]>1 then f[i,j]:=f[i,j] div y;\n for l:=1 to m do\n begin\n x:=1<<(a[l]-1);y:=1<<(b[l]-1);\n if (x and i=0)or(y and i>0) then continue;\n xx:=i+y;yy:=j+y;\n if yy and x>0 then yy:=yy-x;\n inc(f[xx,yy],f[i,j]);\n end;\n end;\n for i:=1 to (1<0 do\n begin\n inc(y);x:=x and (x-1);\n end;\n if y=k then ans:=ans+f[(1<0;\n end;\n\n begin\n read(n,m,k);\n fillchar(b,sizeof(b),0);\n for i:=1 to m do\n begin\n read(xx,yy);\n xx:=xx-1;yy:=yy-1;\n a[xx,yy]:=1;\n a[yy,xx]:=1;\n\n b[(1 shl xx) or (1 shl yy),(1 shl xx)or(1 shl yy)]:=1;\n end;\n\n s:=1 shl n;\n b[0,0]:=1;\n ans:=0;\n for i:=1 to s-1 do\n for j:=1 to s-1 do\n begin\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if b[i,j]<>1 then\n begin\n for l2:=0 to n-1 do\n for l1:=0 to n-1 do\n if a[l1,l2]=1 then\n begin\n if (bit(i,l1))and(bit(j,l2))and(not bit(j,l1)) then\n begin\n b[i,j]:=b[i xor (1 shl l2),j xor (1 shl l2) xor (1 shl l1)]\n +b[i xor (1 shl l2),j xor (1 shl l2)]\n +b[i,j];\n end;\n end;\n b[i,j]:=b[i,j] div bits;\n end;\n\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if i=s-1 then\n if bits=k then ans:=ans+b[i,j];\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var\n ta:array[0..11]of longint;\n a:array[1..2000,1..2000]of longint;\n ma:array[1..10,1..10]of longint;\n tn,tw,yz:array[0..10]of longint;\n i,j,k,l,m,n,temp,i2,o:longint;\nbegin\n readln(n,m,k);\n fillchar(ma,sizeof(ma),0);\n for i:=1 to m do\n begin\n readln(j,l);\n\tma[j,l]:=1;\n\tma[l,j]:=1;\n end;\n fillchar(ta,sizeof(ta),0);\n ta[0]:=1;\n for i:=1 to 11 do\n ta[i]:=2*ta[i-1];\n m:=k;\n fillchar(a,sizeof(a),0);\n for i:=3 to ta[n] do\n for i2:=1 to ta[n] do\n begin\n temp:=i;\n\to:=0;\n\tfor j:=1 to n do\n\tbegin\n\t tn[j]:=temp mod 2;\n\t temp:=temp div 2;\n\t if tn[j]=1 then inc(o);\n\tend;\n\ttemp:=i2;\n\tl:=0;\n\tfor j:=1 to n do\n\tbegin\n\t tw[j]:=temp mod 2;\n\t temp:=temp div 2;\n\t if tw[j]=1 then inc(l);\n\tend;\n\tif l<2 then continue;\n\tif(l>=o)and(o>2)then continue;\n k:=0;\n\tfor j:=1 to n do\n\t if (tn[j]=0)and(tw[j]=1)then begin k:=1;break;end;\n if k=1 then continue;\n k:=0;\n for j:=1 to n do\n if tn[k]<>tw[k] then begin k:=1;break;end;\n if(o=2)and(k=0)then a[i,i2]:=2;\n a[i,i2]:=a[i,i2] div l;\n\tfor j:=1 to n do\n\tfor k:=1 to n do\n\tbegin\n\t if(tn[j]=0)and(tn[k]=1)and(ma[j,k]=1)then\n\t begin\n\t l:=i2 xor ta[k-1];\n\t\tif l0)then begin\n x:=mask2;\n y:=0;\n while (x>0)do begin\n inc(y);\n x:=x and (x-1);\n end;\n if (f[mask1][mask2]<>1)then f[mask1][mask2]:=f[mask1][mask2]div y;\n for i:=1 to m do begin\n x:=1 shl (ss[i]-1);\n y:=1 shl (ff[i]-1);\n if (mask1 and x=0)then continue;\n if (mask1 and y>0)then continue;\n nm1:=mask1+y;\n nm2:=mask2+y;\n if (nm2 and x>0)then nm2:=nm2-x;\n inc(f[nm1][nm2],f[mask1][mask2]);\n end;\n end;\n res:=0;\n for mask2:=1 to (1 shl n)-1 do begin \n x:=mask2;\n y:=0;\n while (x>0)do begin\n inc(y);\n x:=x and (x-1);\n end;\n if (y<>k)then continue;\n inc(res,f[(1 shl n)-1][mask2]);\n end;\n writeln(res);\n close(output);close(input);\nend.\n"}, {"source_code": "type\n arr=record\n adj,next:longint;\n end;\nvar\n x,y,top,n,m,need,i,j,ans:longint;\n a:array[1..10] of longint;\n g:array[1..1000] of arr;\n f:array[0..1,0..1024,0..1024] of longint;\n b:Array[1..100,1..2] of longint;\n c:array[0..20] of longint;\n check:array[1..10,1..10] of boolean;\n\nprocedure insert(x,y:longint);\nbegin\n inc(top); g[top].adj:=y; g[top].next:=a[x]; a[x]:=top;\nend;\n\nfunction count(t:longint):longint;\nvar\n tmp:longint;\nbegin\n tmp:=0;\n while t<>0 do\n begin\n inc(tmp);\n dec(t,t and (-t));\n end;\n exit(tmp);\nend;\n\nprocedure dp;\nvar\n tx,ty,i,j,k,p,s1,s2,s3:longint;\nbegin\n for i:=1 to m do\n begin\n x:=b[i,1]-1; y:=b[i,2]-1;\n f[1,c[x]+c[y],c[x]+c[y]]:=1;\n end;\n for i:=2 to n-1 do\n begin\n tx:=i and 1; ty:=tx xor 1;\n fillchar(f[tx],sizeof(f[tx]),0);\n for s1:=0 to c[n]-1 do\n for s2:=0 to c[n]-1 do\n if (s1 and s2=s2) and (s1 or s2=s1) and (f[ty,s1,s2]>0) then\n begin\n{ for j:=n downto 1 do\n if (s1 and c[j-1]<>0) and (s2 and c[j-1]=0) then break;\n begin\n p:=a[j];\n while p<>0 do\n begin\n k:=g[p].adj;\n if s1 and c[k-1]=0 then\n inc(f[tx,s1 or c[k-1],s2 or c[j-1]],f[ty,s1,s2]);\n p:=g[p].next;\n end;\n end;\n for j:=1 to n do\n if (s1 and c[j-1]<>0) and (s2 and c[j-1]<>0) then\n begin\n p:=a[j];\n while p<>0 do\n begin\n k:=g[p].adj;\n if s1 and c[k-1]=0 then\n inc(f[tx,s1 or c[k-1],s2],f[ty,s1,s2]);\n p:=g[p].next;\n end;\n end; }\n for j:=1 to n do\n if s1 and c[j-1]<>0 then\n begin\n for k:=1 to n do\n if check[j,k] and (s1 and c[k-1]=0) then\n begin\n if s2 and c[j-1]<>0 then s3:=s2-c[j-1] else s3:=s2;\n if c[k-1]<=s3 then continue;\n inc(f[tx,s1 or c[k-1],s3 or c[k-1]],f[ty,s1,s2]);\n end;\n end;\n end;\n end;\n for s2:=0 to c[n]-1 do\n if count(s2)=need then\n inc(ans,f[(n-1) and 1,c[n]-1,s2]);\n writeln(ans);\nend;\n\nbegin\n for i:=0 to 20 do c[i]:=1 shl i;\n readln(n,m,need);\n for i:=1 to m do\n begin\n readln(x,y); b[i,1]:=x; b[i,2]:=y;\n insert(x,y); insert(y,x);\n check[x,y]:=true; check[y,x]:=true;\n end;\n dp;\nend.\n"}, {"source_code": "var\n f:array[0..1024,0..1024] of longint;\n line:array[0..10,0..10] of boolean;\n pre,now,son:array[0..100] of longint;\n n,m,total,i,j,k,l,x,y,tmp,sum,ans,s,p,tot:longint;\n\n function find(x:longint):longint;\n var c:longint;\n begin\n c:=0;\n while x>0 do\n begin\n x:=x and (x-1);\n inc(c);\n end;\n exit(c);\n end;\nbegin\n fillchar(f,sizeof(f),0);\n readln(n,m,tot); ans:=0; total:=0;\n sum:=1 shl n;\n for i:=1 to m do\n begin\n readln(x,y);\n inc(total); pre[total]:=now[x]; now[x]:=total; son[total]:=y;\n inc(total); pre[total]:=now[y]; now[y]:=total; son[total]:=x;\n tmp:=(1 shl (x-1)) or (1 shl (y-1));\n f[tmp,tmp]:=1;\n end;\n\n for i:=1 to sum-1 do\n begin\n j:=i;\n while j>0 do\n begin\n if f[i,j]<>0 then\n for l:=1 to n do\n if ((1<<(l-1)) and i)<>0 then\n begin\n p:=now[l];\n while p>0 do\n begin\n s:=son[p];\n if (1<<(s-1) and i)=0 then\n begin\n tmp:=(1 shl (s-1)) or (j and (not (1 shl (l-1))));\n if (tmp >> (s))=0 then\n begin\n inc(f[i or (1 << (s-1)),tmp],f[i,j]);\n end;\n end;\n p:=pre[p];\n end;\n end;\n j:=(j-1) and i;\n end;\n end;\n\n for i:=0 to sum-1 do\n if find(i)=tot then\n begin\n inc(ans,f[sum-1,i]);\n end;\n\n writeln(ans);\nend.\n\n\n\n\n\n"}], "negative_code": [{"source_code": "type arr=array[1..10]of longint;\nvar n,m,k,i,ans:longint;\n u:arr;\n a,b,s:arr;\nfunction get(i:longint):longint;\nbegin\n if u[i]=0 then get:=i else\n begin\n u[i]:=get(u[i]);get:=u[i];\n end;\nend;\nprocedure gc(t,k,l:longint);\nvar uu:arr;\nbegin\n if k<0 then exit;\n if m-t+1get(b[t]) then\n begin\n uu:=u;u[get(a[t])]:=get(b[t]);\n inc(s[a[t]]);inc(s[b[t]]);\n if s[a[t]]=2 then dec(k);\n if s[b[t]]=2 then dec(k);\n gc(t+1,k,l-1);\n dec(s[a[t]]);dec(s[b[t]]);\n u:=uu;\n end;\nend;\nbegin\n read(n,m,k);\n for i:=1 to m do read(a[i],b[i]);\n gc(1,n-k,n-1);writeln(ans);\nend."}, {"source_code": "var\nq,xx,yy,i,j,s,l1,l2,bits,n,m,k:longint;\nans:int64;\na:array[0..15,0..15]of longint;\nb:array[0..1 shl 11,0..1 shl 11]of int64;\n\nfunction bit(x,i:longint):boolean;\n begin\n bit:=(x and (1 shl i))>0;\n end;\n\n begin\n read(n,m,k);\n fillchar(b,sizeof(b),0);\n for i:=1 to m do\n begin\n read(xx,yy);\n xx:=xx-1;yy:=yy-1;\n a[xx,yy]:=1;\n a[yy,xx]:=1;\n\n b[(1 shl xx) or (1 shl yy),(1 shl xx)or(1 shl yy)]:=1;\n end;\n\n s:=1 shl n;\n ans:=0;\n for i:=1 to s-1 do\n for j:=1 to s-1 do\n begin q:=0;\n for l2:=0 to n-1 do\n begin\n for l1:=0 to n-1 do\n if a[l1,l2]=1 then\n begin\n if (bit(i,l1))and(not bit(i,l2)) then\n begin\n if bit(j,l1) then b[i xor (1 shl l2),j xor (1 shl l2) xor (1 shl l1)]:=b[i xor (1 shl l2),j xor (1 shl l2) xor (1 shl l1)]+b[i,j]\n else b[i xor (1 shl l2),j xor (1 shl l2)]:=b[i xor (1 shl l2),j xor (1 shl l2)]+b[i,j];\n q:=1;\n end;\n end;\n if q=1 then break;\n end;\n\n\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if i=s-1 then\n if bits=k then ans:=ans+b[i,j];\n end;\n writeln(ans div k);\n end.\n"}, {"source_code": "var\nq,xx,yy,i,j,s,l1,l2,bits,n,m,k:longint;\nans:int64;\na:array[0..15,0..15]of longint;\nb:array[0..1 shl 11,0..1 shl 11]of int64;\n\nfunction bit(x,i:longint):boolean;\n begin\n bit:=(x and (1 shl i))>0;\n end;\n\n begin\n read(n,m,k);\n fillchar(b,sizeof(b),0);\n for i:=1 to m do\n begin\n read(xx,yy);\n xx:=xx-1;yy:=yy-1;\n a[xx,yy]:=1;\n a[yy,xx]:=1;\n\n b[(1 shl xx) or (1 shl yy),(1 shl xx)or(1 shl yy)]:=1;\n end;\n\n s:=1 shl n;\n ans:=0;\n for i:=1 to s-1 do\n for j:=1 to s-1 do\n begin\n for l2:=0 to n-1 do\n for l1:=0 to n-1 do\n if a[l1,l2]=1 then\n begin\n if (bit(i,l1))and(bit(j,l2))and(not bit(j,l1)) then\n begin\n b[i,j]:=b[i xor (1 shl l2),j xor (1 shl l2) xor (1 shl l1)]\n +b[i xor (1 shl l2),j xor (1 shl l2)]\n +b[i,j];\n end;\n end;\n\n if b[i,j]<>1 then b[i,j]:=b[i,j] div k;\n bits:=0;\n for l1:=0 to n-1 do\n if bit(j,l1) then inc(bits);\n\n if i=s-1 then\n if bits=k then ans:=ans+b[i,j];\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var\n n,m,k:longint;\n\nbegin\n readln(n,m,k);\n if n=3 then writeln(3)\n else if k=2 then writeln(12)\n else if k=3 then writeln(4)\n else writeln(11);\nend."}, {"source_code": "var\n n,m,k:longint;\n\nbegin\n readln(n,m,k);\n if n=3 then writeln(3)\n else if k=2 then writeln(12)\n else if k=3 then writeln(4)\n else writeln(0);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n SysUtils, Math;\n\nvar\n ans, edge : int64;\n x, n, m, k, i, j, u, v, top : integer;\n a : array[1..10, 1..10] of boolean;\n d : array[0..1023, 0..511] of int64;\n st : array[1..2] of integer;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n read(n, m, k);\n for i := 1 to m do begin\n read(u, v);\n a[u][v] := true;\n a[v][u] := true;\n end;\n\n ans := 0;\n for i := 1 to 1 shl n - 1 do begin\n j := i;\n u := 1;\n x := 1;\n top := 0;\n while x <= j do begin\n if x and j <> 0 then begin\n inc(top);\n if top <= 2 then\n st[top] := u;\n end;\n x := x shl 1;\n inc(u);\n end;\n if top = 1 then begin\n j := i and (j - 1);\n continue;\n end else\n if top = 2 then begin\n if a[st[1]][st[2]] then\n d[i][j] := 1;\n if (top = k) and (i = 1 shl n - 1) then\n inc(ans, d[i][j]);\n writeln(i, ' ', j, ' ', d[i][j]);\n j := i and (j - 1);\n end;\n while j <> 0 do begin\n top := 0;\n x := 1;\n while x <= j do begin\n if x and j <> 0 then\n inc(top);\n x := x shl 1;\n end;\n u := 1;\n x := 1;\n while (x <= j) do begin\n if j and x <> 0 then begin\n for v := 1 to n do\n if (a[u][v]) and (i and (1 shl (v - 1)) <> 0) and (j and (1 shl (v - 1)) = 0) then\n inc(d[i][j], d[i xor (1 shl (u - 1))][j xor (1 shl (u - 1)) or (1 shl (v - 1))] + d[i xor (1 shl (u - 1))][j xor (1 shl (u - 1))]);\n end;\n x := x shl 1;\n inc(u);\n end;\n d[i][j] := d[i][j] div top;\n if (top = k) and (i = 1 shl n - 1) then\n inc(ans, d[i][j]);\n// writeln(i, ' ', j, ' ', d[i][j]);\n j := i and (j - 1);\n end;\n end;\n\n writeln(ans);\n\nend."}], "src_uid": "8087605a8f316150372cc4627f26231d"} {"source_code": "{$MODE OBJFPC}\nvar\n a: array[1..7] of integer;\n b: array[1..1000000] of string;\n c: array[1..1000000] of boolean;\n i, dem, j, k: integer;\n h: char;\n n: string;\n\nbegin\n readln(n);\n i := 1;\n fillchar(c,sizeof(c),false);\n repeat\n a[i] := ord(n[i]) - 48;\n inc(i);\n until i > length(n);\n dem := 0;\n for i := 1 to length(n) do begin\n j := 1;\n repeat\n if a[i] > 0 then b[j] := b[j] + '1' else b[j] := b[j] + '0';\n c[j] := true;\n if j > dem then dem := j;\n dec(a[i]);\n inc(j);\n until a[i] <= 0;\n dec(j);\n if j < dem then\n for k := j + 1 to dem do if c[k] then b[k] := b[k] + '0';\n// writeln(b[1]);\n end;\n writeln(dem);\n for i := 1 to dem do write(b[i],' ');\nend.", "positive_code": [{"source_code": "type\n arr =array[1..6] of longint;\n\nvar\n N :longint;\n res :array[0..1000000] of longint;\n sl :array[0..1000000] of longint;\n dem :longint;\n x :arr;\n x1 :arr;\n\nprocedure tach(var x:arr);\nvar mi,ma,i:longint;xx:longint;mul:longint;\nBegin\n mi:=10;\n ma:=-1;\n mul:=1;\n xx:=0;\n for i:=N downto 1 do\n Begin\n if x[i]>ma then ma:=x[i];\n if (x[i]0) then mi:=x[i];\n end;\n if ma=1 then\n begin\n for i:=1 to N do\n begin\n xx:=xx+x[i]*mul;\n mul:=mul*10;\n x[i]:=0;\n end;\n end;\n inc(dem);\n sl[dem]:=mi;\n for i:=1 to N do\n if x[i]>0 then\n Begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else\n mul:=mul*10;\n res[dem]:=xx;\n for i:=1 to n do\n if x[i]>0 then\n x[i]:=x[i]-mi;\nend;\n\nfunction check:boolean;\nvar i:longint;\nBegin\n for i:=1 to N do\n if x[i]>1 then exit(false);\n exit(true);\nend;\n\nprocedure xuli;\nvar i,j,xx,mul:longint;ok:boolean;\nBegin\n readln(xx);\n N:=0;\n while xx>0 do\n Begin\n inc(N);\n x[N]:=xx mod 10;\n xx:=xx div 10;\n end;\n dem:=0;\n fillchar(sl,sizeof(sl),0);\n while check=false do tach(x);\n ok:=false;\n for i:=n downto 1 do\n if x[i]>0 then\n begin\n N:=i;\n break;\n end;\n mul:=1;\n xx:=0;\n for i:=1 to N do\n if x[i]>0 then\n begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else mul:=mul*10;\n if xx>0 then\n begin\n inc(dem);\n sl[dem]:=1;\n res[dem]:=xx;\n end;\n xx:=0;\n for i:=1 to dem do\n xx:=xx+sl[i];\n writeln(xx);\n for i:=1 to dem do\n for j:=1 to sl[i] do\n write(res[i],' ');\nend;\n\nBEGIN\n xuli;\nEND.\n"}, {"source_code": "var\n a, b, c, i, max, j, t: int64;\n ar: array [1..1000] of int64;\n q: boolean;\n \nbegin\n readln(a);\n j := 1;\n max := 0;\n while a > 0 do begin\n if (a mod 10 > max) then max := a mod 10; \n ar[j] := a mod 10;\n inc(j);\n a := a div 10;\n end;\n writeln(max);\n i := 1;\n while i <= max do begin\n t := j - 1;\n q := false;\n while t > 0 do begin\n if (ar[t] > 0) then begin\n write(1);\n dec(ar[t]);\n q := true;\n end\n else if (q) then write(0);\n dec(t);\n end;\n write(' ');\n inc(i);\n end;\nend."}, {"source_code": "const vocung=maxlongint div 2;\n\nvar ds:array[1..200] of longint;\n\n f,trace:array[0..1000000] of longint;\n\n n,l:longint;\n\nprocedure dequy(i,x:longint);\nbegin\n if i>7 then\n begin\n inc(l);\n ds[l]:=x;\n\n exit;\n end;\n\n dequy(i+1,x*10+0);\n dequy(i+1,x*10+1);\nend;\n\nprocedure xuly;\nvar i,j,tg:longint;\nbegin\n readln(n);\n\n if n=1000000 then\n begin\n writeln(1);\n writeln(n);\n\n halt;\n end;\n\n dequy(1,0);\n\n for i:=1 to l-1 do\n for j:=i+1 to l do\n if ds[i]>ds[j] then\n begin\n tg:=ds[i]; ds[i]:=ds[j]; ds[j]:=tg;\n end;\n\n for i:=1 to n do f[i]:=vocung;\n f[0]:=0;\n\n for i:=1 to n do\n for j:=1 to l do\n if (i>=ds[j]) and (f[i]>f[i-ds[j]]+1) then\n begin\n\n f[i]:=f[i-ds[j]]+1;\n trace[i]:=j;\n end;\n\n writeln(f[n]);\n\n i:=n;\n while i>0 do\n begin\n write(ds[trace[i]],' ');\n i:=i-ds[trace[i]];\n end;\nend;\n\nbegin\n\n// assign(input,'nhap.inp'); reset(input);\n\n xuly;\nend."}, {"source_code": "program quasibinary;\nvar n,i,m:longint;\n t:array[1..1000000] of longint;\n\nfunction divide(n:longint):longint;\nvar p:longint;\nbegin\n p:=1;\n while p<=n do\n p:=p*10;\n p:=p div 10;\n divide:=p;\nend;\n \n\nprocedure subtract(var n:longint);\nvar\nl,d,s:longint;\nbegin \n l:=0;\n s:=n;\n while s > 0 do\n begin\n d:=divide(s);\n l:=l+d;\n s:=s mod d;\n end;\n n:=n-l;\n inc(m);\n t[m]:=l;\nend;\n \n \n\n\nbegin\n readln(n);\n m:=0;\n while n <> 0 do\n subtract(n);\n writeln(m);\n for i:=1 to m do\n write(t[i],' ');\nend."}, {"source_code": "program quasibinary;\nvar n,i,m:longint;\n t:array[1..1000000] of longint;\n\nfunction divide(n:longint):longint;\nvar p:longint;\nbegin\n p:=1;\n while p<=n do\n p:=p*10;\n p:=p div 10;\n divide:=p;\nend;\n \n\nprocedure subtract(var n:longint);\nvar\nl,d,s:longint;\nbegin \n l:=0;\n s:=n;\n while s > 0 do\n begin\n d:=divide(s);\n l:=l+d;\n s:=s mod d;\n end;\n n:=n-l;\n inc(m);\n t[m]:=l;\nend;\n \n \n\n\nbegin\n readln(n);\n m:=0;\n while n <> 0 do\n subtract(n);\n writeln(m);\n for i:=1 to m do\n write(t[i],' ');\nend."}, {"source_code": "Var b:array[1..100] of longint;\n i,c,n,s,a,t:longint;\nbegin\nreadln(n);\ns:=n;\nc:=1;\nwhile(n>0)do\n begin\n a:=n mod 10;\n for i:=1 to a do\n b[i]:=b[i]+c;\n if(a>t)then t:=a;\n c:=c*10;\n n:=n div 10;\n a:=0;\n end;\n\nwriteln(t);\n\nfor i:=1 to t do\n write(b[i],' ');\nend."}, {"source_code": "var n,i,s,x,k:longint;\n a,c:array[1..7]of longint;\n b:array[1..100000]of longint;\nbegin\n read(n); s:=n;\n c[7]:=1;\n for i:=7 downto 1 do\n begin\n if i<7 then c[i]:=c[i+1]*10;\n a[i]:=n mod 10;\n n:=n div 10\n end;\n n:=0; x:=1;\n while s>0 do\n begin\n x:=0;\n for i:=1 to 7 do\n if a[i]>0 then begin dec(a[i]); x:=x+c[i] end;\n inc(n); b[n]:=x;\n s:=s-x\n end;\n writeln(n);\n for i:=1 to n do write(b[i],' ')\nend."}, {"source_code": "var n,x,i,j,max,cod:longint;\n s:string;\n a:array[1..10]of longint;\n b:array[1..10,1..10]of longint;\nbegin\nread(n);\nstr(n,s);\nval(s[1],max,cod);\n\nfor i:=2 to length(s) do\n begin\n val(s[i],x,cod);\n if x>max then max :=x;\n end;\n \nfor i:=1 to length(s) do\n begin\n a[length(s)-i+1]:=n mod 10;\n n:=n div 10;\n end;\n \nfor i:=1 to max do\n begin\n for j:=1 to length(s) do\n if a[j]>0 then begin b[i,j]:=1; dec(a[j]) end;\n end;\n \nwriteln(max);\nfor i:=1 to max do\n begin\n j:=1;\n while b[i,j]=0 do inc(j);\n while j<=length(s) do begin write(b[i,j]); inc(j) end;\n write(' ');\n end;\nend.\n"}, {"source_code": "var\n n,k,m,q,w,x,i,j,e,p :longint;\n a,b:array[0..200000]of longint;\n s:string;\nbegin\n\n\n//assign(input,'input.txt');\n//reset(input);\n//assign(output,'output.txt');\n//rewrite(output);\nread(n);\nwhile n>0 do\n begin\n i:=i+1;\n b[i]:=n mod 10;\n if b[i]>x then x:=b[i];\n n:=n div 10;\n end;\np:=i;\nfor i:=i downto 1 do\n begin\n e:=e+1;\n a[e]:=b[i];\n\n end;\nwriteln(x);\n\ni:=p;\nwhile x>0 do\n begin\n for j:=1 to i do\n if a[j]=x then\n begin\n s:=s+'1';\n a[j]:=a[j]-1;\n end\n else if length(s)>0 then s:=s+'0';\n x:=x-1;\n write(s,' ');\n s:='';\n\n end;\n\n end.\n"}, {"source_code": "uses sysutils;\nvar\n\ts1,s,sc: longint;\n\tn\t: longint;\n\ta,k\t: string;\n\tmin,m\t: integer;\n count : integer;\n l : ansistring;\nbegin\n\treadln(n);\n\ts:=1;\n\ts1:=1;\n\twhile sn then\n\tbegin\n\t\tdec(s1);\n\t\ts:= s div 10;\n\tend;\n\n\twhile n>0 do\n\tbegin\n while s>n do\n begin\n dec(s1);\n s:=s div 10;\n end;\n\t\ta:=inttostr(n);\n\t\tk:='';\n\t\tmin:=9;\n\t\tfor sc:= 1 to s1 do\n\t\tbegin\n\t\t\tif a[sc]='0' then k:=k+'0' else k:=k+ '1';\n\t\t\tif (strtoint(a[sc])'0') then min:= strtoint(a[sc]);\n\t\tend;\n inc(count,min);\n\t\tfor m:= 1 to min-1 do\n\t\tbegin\n\t\t\tl:=l+k+' ';\n\t\t\tn:=n-strtoint(k);\n\n\t\tend;\n l:=l+k;\n n:=n-strtoint(k);\n\t\tif n>0 then l:=L+' ';\n\tend;\n\twriteln(count);\n writeln(l);\nend."}, {"source_code": "var\na:array[1..10000]of longint;\ni,n,x1,x2,x3,x4,x5,x6,x7,k:longint;\nbegin\nread(n);\nif n=0 then begin\n writeln(0);exit;end;\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nwhile(n>0)do begin\n x7:=n mod 10;\n if x7>0 then begin\n n:=n-1;\n x7:=1;\n end else x7:=0;\n x6:=n mod 100;\n if x6 div 10>0 then begin\n n:=n-10;\n x6:=10;\n end else x6:=0;\n x5:=n mod 1000;\n if x5 div 100>0 then begin\n n:=n-100;\n x5:=100;\n end else x5:=0;\n x4:=n mod 10000;\n if x4 div 1000>0 then begin\n n:=n-1000;\n x4:=1000;\n end else x4:=0;\n x3:=n mod 100000;\n if x3 div 10000>0 then begin\n n:=n-10000;\n x3:=10000;\n end else x3:=0;\n x2:=n mod 1000000;\n if x2 div 100000>0 then begin\n n:=n-100000;\n x2:=100000;\n end else x2:=0;\n x1:=n mod 10000000;\n if x1 div 1000000>0 then begin\n n:=n-1000000;\n x1:=1000000;\n end else x1:=0;\nif (x1+x2+x3+x4+x5+x6+x7)>0 then begin\n k:=k+1;\n a[k]:=x1+x2+x3+x4+x5+x6+x7;\n end;\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nend;\nwriteln(k);\nfor i:=1 to k do write(a[i],' ');\nend."}, {"source_code": "USES MATH;\n\n{$COPERATORS ON}\n\nVAR sum : longint;\n i,j,l,m : integer;\n s : string;\n n : array of shortint;\n\nBEGIN\n readln(s);\n \n l := length(s);\n setlength(n,l);\n m := 0;\n for i := 1 to l do begin\n n[i-1] := byte(s[i]) - byte('0');\n if n[i-1] > m then\n m := n[i-1]\n end;\n \n writeln(m);\n for i := 1 to m do begin\n sum := 0;\n for j := 0 to l-1 do begin\n sum := 10*sum + min(n[j],1);\n n[j] := max(0,n[j]-1)\n end;\n write(sum,' ')\n end\nEND."}, {"source_code": "const\tfi='';\n\tfo='';\nvar\tf,g:Text;\n\ta:array[0..7] of integer;\n\tkq:array[0..20] of longint;\n\tn,i,t,heso,dem:longint;\n\tn2:ansistring;\n\tfunction check:boolean;\n\tvar\ti:longint;\n\t\tbegin\n\t\t\tfor i:=1 to length(n2) do\n\t\t\t\tif a[i]>0 then exit(true);\n\t\t\texit(False);\n\t\tend;\nbegin\n\tassign(F,fi);\n\treset(f);\n\tassign(g,fo);\n\trewrite(g);\n\treadln(f,n);\n\tstr(n,n2);\n\tfor i:=1 to length(n2) do\n\tbegin\n\t\ta[i]:=n mod 10;\n\t\tn:=n div 10;\n\tend;\n\tdem:=0;\n\twhile check do\n\tbegin\n\t\theso:=1;\n\t\tt:=0;\n\t\tfor i:=1 to length(n2) do\n\t\tbegin\n\t\t\tif a[i]>0 then t:=t+heso;\n\t\t\tdec(a[i]);\n\t\t\theso:=heso*10;\n\t\tend;\n\t\tinc(dem);\n\t\tkq[dem]:=t;\n\tend;\n\twriteln(g,dem);\n\tfor i:=1 to dem do\n\t\twrite(g,kq[i],' ');\n\tclose(f);\n\tclose(g);\nend.\n"}, {"source_code": "var i,j,n,m,f,q,k,max,l:longint;\n a:array [1..9] of longint;\nbegin\n read (n);\n k:=1;\n while n>0 do\n begin\n l:=n mod 10;\n for i:=1 to l do\n a[i]:=a[i]+1*k;\n k:=k*10;\n if l>max then max:=l;\n n:=n div 10;\n end;\n writeln (max);\n for i:=1 to max do\n write (a[i],' ');\nend. "}, {"source_code": "var\n mx,i,j,n,m,k,t,x:longint;\n s,ss:ansistring;\n a:array[0..11]of longint;\n c:char;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do begin a[i]:=ord(s[i])-48;if a[i]>mx then mx:=a[i];end;\n writeln(mx);\n for i:=1 to mx do\n begin\n ss:='';\n for j:=1 to n do if a[j]=0 then write(ss)else begin write(1);dec(a[j]);ss:='0';end;\n write(' ');\n end;\n writeln;\nend.\n"}, {"source_code": "program z1;\n var n,m,i,j,l,k,c,h:int64;\n a,d:array [1..10] of int64;\n b:array [1..10,1..10000] of int64;\n begin\n readln(n);\n while n<>0 do begin\n l := l+1;\n d[l]:=n mod 10;\n n:=n div 10;\n end;\n for i:=1 to l do a[i]:=d[l-(i-1)];\n i:=0;\n while k<>1 do begin\n c:=0;\n j := j+1;\n for i:=1 to l do begin\n if a[i]>=1 then begin\n a[i]:=a[i]-1;\n b[i,j]:=1;\n end \n end;\n for i:=1 to l do if a[i]<>0 then c:=1;\n if c=0 then break;\n end;\n writeln(j);\n for i:=1 to j do begin\n c:=0;\n for h:=1 to l do begin\n if b[h,i]<>0 then c:=1;\n if c=1 then write(b[h,i]);\n end;\n write(' ');\n end; \n end."}, {"source_code": "const finp='';\n fout='';\nvar s:string;\nprocedure nhap;\nvar f:Text;\nbegin\n assign(f,finp); reset(f);\n read(f,s);\n close(f);\nend;\nfunction findmin:byte;\nvar i,min:byte;\nbegin\n min:=10;\n for i:=1 to length(s) do\n if ((ord(s[i])-48)'0') then\n min:=ord(s[i])-48;\n findmin:=min;\nend;\nfunction construct_max:string;\nvar i:byte;\n s1:string;\nbegin\n s1:='';\n for i:=1 to length(s) do\n if s[i]<>'0' then\n s1:=s1+'1'\n else\n s1:=s1+'0';\n while s1[1]='0' do\n delete(s1,1,1);\n construct_max:=s1;\nend;\nprocedure minus(k:byte);\nvar i:byte;\nbegin\n for i:=1 to length(s) do\n if s[i]<>'0' then\n s[i]:=chr(ord(s[i])-k);\nend;\nprocedure xuat;\nvar f:Text;\n i,d,min:byte;\n comp,maxquasi:string;\n a:array[1..100] of string;\nbegin\n assign(f,fout); rewrite(f);\n comp:=''; d:=0;\n for i:=1 to length(s) do\n comp:=comp+'0';\n while s<>comp do\n begin\n min:=findmin;\n maxquasi:=construct_max;\n i:=1;\n while i<=min do\n begin\n inc(d); inc(i);\n a[d]:=maxquasi;\n end;\n minus(min);\n end;\n writeln(f,d);\n for i:=1 to d do\n write(f,a[i],' ');\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "uses SysUtils,Math;\ntype mass=array[0..1000] of string;\nvar res,a,n,kol,NewKol:int64;\n i,z,j:longint;\n u:boolean;\n ch:char;\n m,m1:mass;\n s,s1:string;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n readln(s);\n res:=0;\n for i:=1 to 100 do\n Begin\n u:=false;\n for z:=1 to length(s) do\n if s[z]<>'0'\n then Begin\n inc(res);\n u:=true;\n break;\n end;\n if u\n then Begin\n m[res]:='';\n for z:=1 to length(s) do\n if s[z]<>'0'\n then Begin\n m[res]:=m[res]+'1';\n s[z]:=pred(s[z]);\n end\n else m[res]:=m[res]+'0';\n end;\n end;\n writeln(res);\n for i:=1 to res do\n write(StrToInt(m[i]),' ');\nend."}, {"source_code": "Const Fi='';\n Fo='';\nProcedure Main;\nVar St:AnsiString;\n i,j,n,Cc,Res:Longint;\n A:Array[1..7]Of Integer;\n Begin\n Readln(St);\n n:=Length(St);\n Res:=0;\n For i:=1 to n do\n Begin\n Val(St[i],A[i]);\n If Res0 then\n Begin\n Cc:=Cc*10+1;\n Dec(A[j]);\n End\n Else\n Cc:=Cc*10;\n Write(Cc,' ');\n End;\n End;\nBegin\n Assign(Input,Fi);Reset(Input);\n Assign(Output,Fo);Rewrite(Output);\n Main;\n Close(Input);Close(Output);\nEnd."}, {"source_code": "var r,max,n,i,j,tek:longint;\n a:Array[1..1000]of longint;\n fl:boolean;\nbegin\n read(n);\n while n>0 do\n begin\n inc(tek);\n a[tek]:= n mod 10;\n n:=n div 10;\n end;\n for i:=1 to tek div 2 do\n begin\n r:=a[i];\n a[i]:=a[tek-i+1];\n a[tek-i+1]:=r;\n end;\n for i:=1 to tek do\n if max0\n then begin dec(a[j]);\n write(1);\n fl:=true;\n end\n else if fl=true\n then write(0);\n write(' ');\n end;\n \n\n\n\nend."}, {"source_code": "program quazyBinary;\n\nuses\n SysUtils;\n\nvar\n\nn: integer;\n\nprocedure maxsubtr(var n : integer);\nvar\n i, counter : integer;\n ns : string;\n curs : string;\n curC : char;\n res : string;\nbegin\n ns := intToStr(n); \n \n counter := 0;\n while (n >0) do\n begin\n setlength(curS, length(ns));\n curC := ns[1];\n for i := 1 to length(ns) do\n if ns[i] < curC then\n begin\n curs[i] := '0';\n end else\n curS[i] := '1';\n res := res + curS + ' ';\n n := n - StrToInt(curS);\n ns := IntToStr(n);\n counter := counter + 1;\n end ;\n writeln(intToStr(counter));\n writeln(res);\n\nend;\n\nbegin\n readln(n);\n //n := 32;\n maxsubtr(n);\n //readln;\n \nend.\n"}, {"source_code": "program ZadachaB2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn, n1, max, k, k1, i, j1, i1, sum, sum1, c, p: integer;\nbool: boolean;\na: array[1..7] of integer;\nbegin\n readln(n);\n bool:= true;\n max:= -1;\n n1:= n;\n c:= 0;\n while n > 0 do\n begin\n p:= n mod 10;\n if p > max then max:= p;\n n:= n div 10;\n inc(c);\n end;\n writeln(max);\n for i:= c downto 1 do\n begin\n p:= n1 mod 10;\n a[i]:= p;\n n1:= n1 div 10;\n end;\n while bool do\n begin\n sum:= 0;\n for i:= 1 to c do\n begin\n if a[i] <> 0 then\n begin\n dec(a[i]);\n write(1);\n end\n else if (a[i] = 0) and (i > k) then write(0);\n inc(sum, a[i]);\n end;\n for i:= 1 to c do\n if a[i] <> 0 then break;\n k:= i;\n write(' ');\n if sum = 0 then bool:= false;\n end;\n readln;\nend.\n"}, {"source_code": "var a,b:array[1..1000000] of longint;\n\nans1,ans,i,j,k,l,m,n:longint;\ns,s1:string;\n\nfunction prov(n:longint):longint;\nvar i,j,k:longint;\n s,s1:string;\n\nbegin\nstr(n,s);\ns1:='';\nfor i:=1 to length(s) do\n if s[i]='0' then s1:=s1+'0' else s1:=s1+'1';\nval(s1,k,j);\nprov:=k;\n\nend;\n\n\nbegin\nreadln(n);\nm:=0;\nans:=0;\nwhile n<>0 do\n begin\n inc(ans);\n inc(m);\n b[m]:=prov(n);\n n:=n - (prov(n));\n end;\nwriteln(ans);\nfor i:=1 to ans do\nwrite(b[i],' ');\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "program cfb;\nvar\n a:longint;\n b:array[1..100000] of longint;\n i,n,m,j,k,z,ma:longint;\nprocedure p(x:longint);\n var\n kk:longint;\n begin\n while (x>0) do\n begin\n inc(kk);\n x:=x div 10;\n end;\n n:=kk;\n end;\nfunction s(x:longint):longint;\nvar\n i1,j1:longint;\nbegin\n j1:=1;\n for i1:=1 to x do\n j1:=j1*10;\n s:=j1;\nend;\n begin\n read(a);\n P(a);\n z:=1;\n ma:=0;\n while a>0 do\n begin\n k:=a mod 10;\n for i:=1 to k do\n b[i]:=b[i]+z;\n z:=z*10;\n if k>ma then ma:=k;\n\n a:=a div 10;\n\n end;\n writeln(ma);\n for i:=1 to ma do\n write(b[i],' ');\n end.\n\n"}, {"source_code": "var s,s1,q,q1:string;i,j,m,k:longint;a,b:array[0..10]of longint;\nbegin\n READ(J);m:=0;\n for i:=1 to 7 do\n begin\n a[i]:=j mod 10;\n if a[i]>m then m:=a[i];\n j:=j div 10;\n end;\n writeln(m);\n for i:=1 to m do\n begin\n \n for j:=7 downto 1 do\n begin\n if a[j]>0 then k:=1 else k:=0; dec(a[j]);\n b[i]:=10*b[i]+k;\n end;\n end;\n\n for i:=1 to m do write(b[i],' ');\nend."}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, d, b :array[1..150000] of integer;\n n, kol, i, j, sum, v, u, k :integer;\n p: char;\n\nbegin\n p := ' ';\n readln(n);\n kol := 0;\n sum := 0;\n k := 0;\n while (n > 0) do\n begin\n inc(kol);\n a[kol] := n mod 10;\n n := n div 10;\n end;\n for i := kol downto 1 do\n begin\n v := a[i];\n for j := 1 to 20 do\n d[j] := 0;\n for j := i downto 1 do\n begin\n if (a[j] >= v) then\n begin\n d[j] := v;\n a[j] := a[j] - v;\n end\n else\n begin\n d[j] := a[j];\n a[j] := 0;\n end;\n end;\n for j := 1 to v do\n begin\n inc(sum);\n for u := i downto 1 do\n begin\n inc(k);\n if (d[u] >= 1) then\n b[k] := 1\n else\n\n b[k] := 0;\n dec(d[u]);\n\n end;\n inc(k);\n b[k] := -1;\n end;\n end;\n write(sum);\n writeln;\n for i := 1 to k do\n if (b[i] < 0) then\n write(p)\n else\n write(b[i]);\nend."}, {"source_code": "program yan;\n var ar:array[1..7]of longint;\n an:array[1..1000]of longint;\n i,j,x,y,a,b,n,m:longint;\n function prov:boolean;\n var i,j:longint;\n begin\n for i:=1 to n do\n if ar[i]<>0 then exit(true);\n exit(false);\n end;\nbegin\n read(n);\n while n<>0 do\n begin\n x:=n mod 10;\n inc(i); ar[i]:=x;\n n:=n div 10;\n end;\n n:=i;\n while prov do\n begin\n y:=0; inc(b);\n for i:=n downto 1 do\n begin\n if ar[i]>0 then\n begin\n y:=1; an[b]:=an[b]*10+1;\n dec(ar[i]);\n end else if y=1 then an[b]:=an[b]*10;\n end;\n end;\n writeln(b);\n for i:=1 to b do\n write(an[i],' ');\nend."}, {"source_code": "uses math;\nvar s,n,i,smax,k:longint;\n a:array[1..1000] of longint;\n\nprocedure swap(var a,b:longint);\nvar t:longint;\nbegin\n t:=a;\n a:=b;\n b:=t;\nend;\n\n\nbegin\n readln(s);\n while s>0 do\n begin\n n:=n+1;\n a[n]:=s mod 10;\n smax:=max(smax,a[n]);\n s:=s div 10;\n end;\n for i:=1 to n div 2 do\n swap(a[i],a[n-i+1]);\n writeln(smax);\n for k:=1 to smax do\n begin\n s:=0;\n for i:=1 to n do\n if a[i]>0 then\n begin\n s:=s*10+1;\n dec(a[i]);\n end\n else s:=s*10;\n write(s,' ');\n end;\nend.\n"}, {"source_code": "program CF300B;\nvar a,b,c,d,i,n,j,k:longint; Z:array[1..100000] of longint;\ns,s1:string;\nbegin\n{assign(input,'d:\\FPC\\input.txt');\nreset(input);\nassign(output,'d:\\FPC\\output.txt');\nrewrite(output);}\nread(s);\na:=length(s);\nwhile a>1 do\nbegin\nfor i:=1 to a do\n if ord(s[i])>48 then\n begin\n s[i]:=chr(ord(s[i])-1);\n s1:=s1+'1';\n end\n else s1:=s1+'0';\ns1:=s1+' ';\nif s[1]='0' then\nbegin\nwhile s[1]='0' do begin\nfor i:=2 to a do\ns[i-1]:=s[i];\na:=a-1;\nif a=1 then break;\nend; end;\nif a=1 then break;\nend;\nfor i:=1 to length(s1) do\nif s1[i]=' ' then k:=k+1;\nk:=k+ord(s[1])-48;\nwriteln(k);\nwrite(s1);\nfor i:=1 to ord(s[1])-48 do\nwrite(1,' ');\nend.\n"}, {"source_code": "var n,x,m,i:longint;\na:array[0..100] of longint;\nbegin\n//assign(output,'zejz.out');rewrite(output);\nreadln(n);\nx:=1;\nwhile n>0 do\n begin\n for i:=1 to n mod 10 do a[i]:=a[i]+x;\n if n mod 10>m then m:=n mod 10;\n n:=n div 10;x:=x*10;\n end;\nwriteln(m);\nfor i:=1 to m do write(a[i],' ');\nclose(input);close(output);\nend."}, {"source_code": "var a,b:array[0..10000] of int64;\ni,j:longint;n,t,max:int64;\nbegin\n//assign(input,'zejz.in');reset(input);\n//assign(output,'zejz.out');rewrite(output);\nreadln(n);\nwhile n<>0 do\n begin\n t:=t+1;\n a[t]:=n mod 10;\n n:=n div 10;\n end;\nfor i:=t downto 1 do\n begin\n for j:=1 to a[i] do\n b[j]:=b[j]*10+1;\n for j:=a[i]+1 to 10 do\n b[j]:=b[j]*10;\n if a[i]>max then\n max:=a[i];\n end;\nwriteln(max);\nfor i:=max downto 1 do\n write(b[i],' ');\nclose(input);close(output);\nend."}, {"source_code": "var z,i,m,j,k:longint;\na:array[1..10000] of longint;\nn:string;\nbegin\n///assign(input,'zrjz.in');reset(input);\n//(output,'zrjz.out');rewrite(output);\nreadln(n);\nz:=1;\nfor i:=length(n) downto 1 do\n begin\n m:=ord(n[i])-48;\n\n for j:=1 to m do\n a[j]:=a[j]+z;\n if m>k then k:=m;\n z:=z*10;\n end;\nwriteln(k);\nfor i:=1 to k do\n write(a[i],' ');\nclose(input);close(output);\nend."}, {"source_code": "var s:string;\ni,k,v,max,j:longint;\na:array[0..100000] of longint;\nbegin\n//assign(input,'zejz.in');reset(input);\n//assign(output,'zejz.out');rewrite(output);\nreadln(s);\nk:=1;\nfor i:=length(s) downto 1 do\n begin\n val(s[i],v);\n for j:=1 to v do\n a[j]:=a[j]+k;\n if v>max then\n max:=v;\n k:=k*10;\n end;\nwriteln(max);\nfor i:=1 to max-1 do\n write(a[i],' ');\nwrite(a[max]);\nclose(input);\nclose(output);\nend."}, {"source_code": "var\n s:string;\n st:array[1..1000]of string;\n n,m,k,l,w,j,i,k1,p:longint;\n f:array[1..100000]of longint;\nbegin\n readln(n);\n m:=n;\n while m<>0 do\n begin\n inc(k);\n f[k]:=m mod 10;\n inc(k1,m mod 10);\n m:=m div 10;\n end;\n while k1<>0 do\n begin\n s:='';\n for i:=k downto 1 do\n begin\n if f[i]<>0 then begin s:=s+'1'; dec(f[i]); dec(k1); end else s:=s+'0';\n end;\n inc(w);\n p:=0;\n for i:=1 to length(s) do if s[i]='0' then inc(p) else break;\n delete(s,1,p);\n st[w]:=s;\n end;\n writeln(w);\n for i:=1 to w do write(st[i],' ');\nend.\n\n\n"}, {"source_code": "var\nb:array[1..100] of integer;\ni,c,n,s,a,t:integer;\nbegin\nc:=1;\nreadln(n);\ns:=n;\nwhile(n>0)do\nbegin\na:=n mod 10;\nfor i:=1 to a do\nb[i]:=b[i]+c;\nif(a>t)then t:=a;\nc:=c*10;\nn:=n div 10;\na:=0;\nend;\nwriteln(t);\nfor i:=t downto 1 do\nbegin\nwrite(b[i]);\nwrite(' ');\nend;\nreadln;\nend.\n"}, {"source_code": "var\nl,i,j:longint;\na:string;\nmax:char;\ns:array[1..10000] of integer;\nbegin\nreadln(a);\nl:=1;\nfor i:=1 to length(a) do if(a[i]>max) then max:=a[i];\nwriteln(max);\nfor i:=length(a) downto 1 do\nbegin\nfor j:=1 to ord(a[i])-48 do s[j]:=s[j]+l;\nl:=l*10;\nend;\nfor i:=1 to ord(max)-48 do write(s[i],' ');\nend."}, {"source_code": "program cf538B;\nvar n,i,j,b:longint;\n a,c:array[1..100000] of longint;\nbegin\nread(n);\nwhile n>0 do\n begin\n inc(i);\n a[i]:=n mod 10;\n n:=n div 10;\n end;\nn:=i;\nb:=1;\nwhile b<>0 do\n begin\n b:=0;\n for i:=n downto 1 do\n if a[i]>0 then\n begin\n b:=b*10+1;\n dec(a[i]);\n end\n else\n b:=b*10;\n if b=0 then\n break;\n inc(j);\n c[j]:=b;\n end;\n\nwriteln(j);\nfor i:=1 to j do\n write(c[i],' ');\nwriteln;\nend."}, {"source_code": "var\n n,i,cnt:longint;\n t,s:string;\n a:array[0..100001] of longint;\nbegin\n read(n);\n while n>0 do begin\n str(n,s); \n\tt:='';\n\tfor i:=1 to length(s) do if s[i]>'0' then begin t:=t+'1'; s[i]:=chr(ord(s[i])-1); end else t:=t+'0';\n\tinc(cnt); val(t,a[cnt]); val(s,n);\n end;\n writeln(cnt);\n for i:=1 to cnt do write(a[i],' ');\nend."}, {"source_code": "var\nl,i,j:longint;\na:string;\nmax:char;\ns:array[1..10000] of integer;\nbegin\nreadln(a);\nl:=1;\nfor i:=1 to length(a) do if(a[i]>max) then max:=a[i];\nwriteln(max);\nfor i:=length(a) downto 1 do\nbegin\nfor j:=1 to ord(a[i])-48 do s[j]:=s[j]+l;\nl:=l*10;\nend;\nfor i:=1 to ord(max)-48 do write(s[i],' ');\nend.\n\n"}, {"source_code": "var\n x,ti,l,c,stn,i,j,n,m,k,kol,res:longint;\n f,p,t,ans,d,b,st,a:array[0..2000000] of longint;\n s:string;\n fi:integer;\n\nfunction min(a,b:longint):longint;\nbegin\n if am do dec(j);\n if i>j then break;\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n inc(i);\n dec(j);\n until i>j;\n if lb[i+1] then\n begin\n inc(kol);\n d[kol]:=b[i];\n end;\n inc(kol);\n d[kol]:=1000000;\n f[0]:=0;\n for i:=1 to n do f[i]:=maxlongint div 2;\n t[0]:=1;\n for i:=0 to n do\n begin\n for j:=1 to kol do if t[i]>0 then if i+d[j]<=1000000 then\n begin\n t[i+d[j]]:=1;\n if f[i+d[j]]>f[i]+1 then\n begin\n f[i+d[j]]:=min(f[i+d[j]],f[i]+1);\n p[i+d[j]]:=i;\n end;\n end;\n end;\n x:=n;\n while x>0 do\n begin\n inc(ti);\n ans[ti]:=x;\n x:=p[x];\n end;\n writeln(ti);\n for i:=1 to ti do write(ans[i]-ans[i+1],' ');\nend.\n"}, {"source_code": "var\n c,t,i,j,n,m,k,kol,ans,res:longint;\n a:array[0..1000] of longint;\n max:char;\n s:string;\nbegin\n {assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n readln(s);\n max:='1';\n for i:=1 to length(s) do if s[i]>max then max:=s[i];\n m:=ord(max)-48;\n t:=1;\n for i:=length(s) downto 1 do\n begin\n c:=ord(s[i])-48;\n for j:=1 to c do inc(a[j],t);\n t:=t*10;\n end;\n writeln(m);\n for i:=1 to m do write(a[i],' ');\nend.\n"}, {"source_code": "program PB;\nvar\n n,i,max,sum,j,m:longint;\n a:array[0..9] of longint;\n\nbegin\n readln(n);\n while n>0 do\n begin\n inc(sum);\n a[sum]:=n mod 10;\n n:=n div 10;\n end;\n for i:=1 to sum do\n if max0 then\n begin\n write(1);\n dec(a[j]);\n end\n else write(0);\n while (a[m]=0) and (m>0) do dec(m);\n end;\n write(' ');\n end;\nend."}, {"source_code": "var\n m:array[1..1000000]of longint;\n a:array[1..10]of longint;\n n,t,s,i,p,q:longint;\nbegin\n readln(n);\n t:=0;\n while n>0 do\n begin\n inc(t);\n a[t]:=n mod 10;\n n:=n div 10;\n end;\n s:=0;\n while t>0 do\n begin\n p:=0;\n q:=0;\n for i:=t downto 1 do\n if a[i]>0 then\n begin\n dec(a[i]);\n p:=p*10+1;\n if(a[i]>0)and(i>q)then q:=i;\n end\n else\n p:=p*10;\n inc(s);\n m[s]:=p;\n t:=q;\n end;\n writeln(s);\n for i:=1 to s do\n write(m[i],' ');\nend."}, {"source_code": "const finp='';\n fout='';\nvar s:string;\nprocedure nhap;\nvar f:Text;\nbegin\n assign(f,finp); reset(f);\n read(f,s);\n close(f);\nend;\nfunction findmin:byte;\nvar i,min:byte;\nbegin\n min:=10;\n for i:=1 to length(s) do\n if ((ord(s[i])-48)'0') then\n min:=ord(s[i])-48;\n findmin:=min;\nend;\nfunction construct_max:string;\nvar i:byte;\n s1:string;\nbegin\n s1:='';\n for i:=1 to length(s) do\n if s[i]<>'0' then\n s1:=s1+'1'\n else\n s1:=s1+'0';\n while s1[1]='0' do\n delete(s1,1,1);\n construct_max:=s1;\nend;\nprocedure minus(k:byte);\nvar i:byte;\nbegin\n for i:=1 to length(s) do\n if s[i]<>'0' then\n s[i]:=chr(ord(s[i])-k);\nend;\nprocedure xuat;\nvar f:Text;\n i,d,min:byte;\n comp,maxquasi:string;\n a:array[1..100] of string;\nbegin\n assign(f,fout); rewrite(f);\n comp:=''; d:=0;\n for i:=1 to length(s) do\n comp:=comp+'0';\n while s<>comp do\n begin\n min:=findmin;\n maxquasi:=construct_max;\n i:=1;\n while i<=min do\n begin\n inc(d); inc(i);\n a[d]:=maxquasi;\n end;\n minus(min);\n end;\n writeln(f,d);\n for i:=1 to d do\n write(f,a[i],' ');\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "const\n mo=1000000007;\nvar\n a:array[1..11111] of longint;\n n,m,k,x,q,w,e,sum,l,r,xx,yy:int64;i,z,j:longint;\n s,cf:string;\nfunction min(x,y:int64):int64;\nbegin if xy then max:=x else max:=y;end;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=1 to n do if ord(s[i])-48>m then m:=ord(s[i])-48;\n writeln(m);\n for i:=1 to m do\n begin\n z:=1;\n while a[z]=0 do inc(z);\n for j:=z to n do\n begin if a[j]>0 then begin write('1');dec(a[j]);end else write('0');end;\n write(' ');\n end;\nend.\n\n"}, {"source_code": "uses math, sysutils;\nvar\n ans : array[1..9] of string;\n s : string;\n count,i,j,n,m : longint;\nbegin\n readln(n);\n s := inttostr(n);\n count := 0;\n for i := 1 to length(s) do count := max(count, strtoint(s[i]));\n writeln(count);\n for i := 1 to 9 do ans[i] := '0000000';\n for i := length(s) downto 1 do begin\n m := strtoint(s[i]);\n for j := 1 to m do ans[j][i + 7 - length(s)] := '1';\n end;\n for i := 1 to count do write(strtoint(ans[i]), ' ');\nend.\n"}, {"source_code": "var a:array[1..100] of longint;\n i,c,n,b,t:longint;\n begin\n readln(n);\n c:=1; t:=0;\n while n>0 do\n begin\n b:=n mod 10;\n for i:=1 to b do\n a[i]:=a[i]+c;\n if b>t then t:=b;\n c:=c*10;\n n:=n div 10;\n b:=0;\n end;\n writeln(t);\n for i:=1 to t do\n write(a[i],' ');\n end."}, {"source_code": "var\n ff:array[1..1000]of longint;\n f:array[1..100,1..100]of longint;\n s,t:ansistring;\n ffff,k,h,i,j,n:longint;\nbegin\n readln(n);\n str(n,s);\n for i:=1 to length(s) do\n begin\n for j:=1 to ord(s[i])-48 do\n begin\n inc(f[i,j]);\n ff[j]:=1;\n end;\n end;\n for i:=9 downto 1 do if ff[i]=1 then\n begin\n n:=i;\n break;\n end;\n writeln(n);\n for i:=1 to n do\n begin\n t:='';\n ffff:=0;\n for j:=1 to length(s) do\n begin\n if (f[j,i]=0)and(ffff=0) then continue;\n ffff:=1;\n t:=t+chr(f[j,i]+48);\n end;\n write(t,' ');\n\n end;\nend.\n"}, {"source_code": "const\n finp = '';\n maxN = 1000010;\n inf = 1000000000;\n\nvar\n fi : text;\n n,nA : longint;\n a : array[0..2 shl 6] of longint;\n f,trace,res : array[0..maxN] of longint;\n\nprocedure init;\nbegin\n assign(fi,finp); reset(fi);\n read(fi,n);\n close(fi);\nend;\n\nfunction check(x:longint):boolean;\nbegin\n while x>0 do\n begin\n if x mod 10 > 1 then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nprocedure process;\nvar\n i,j,p,num : longint;\nbegin\n for i:=1 to n do\n if check(i) then\n begin\n inc(nA);\n a[nA]:=i;\n end;\n\n for i:=1 to n do f[i]:=inf;\n\n for i:=1 to n do\n for j:=1 to nA do\n if (i>=a[j]) and (f[i-a[j]]+10 do\n begin\n write(trace[p],' ');\n p:=p-trace[p];\n end;\nend;\n\nbegin\n init;\n process;\nend."}, {"source_code": "var f1:text;nn,n,res,i,s:longint;\na:array[1..10000]of longint;\nbegin\n assign(f1,'');reset(f1);\n readln(f1,n);res:=0;\n while n<>0 do\n begin\n nn:=n;s:=1;\n while nn<>0 do\n begin if nn mod 10=0 then s:=s*10 else s:=s*10+1;nn:=nn div 10;end;\n nn:=s;s:=0;\n while nn>=10 do\n begin s:=s*10+(nn mod 10);nn:=nn div 10;end;\n inc(res);a[res]:=s;n:=n-s;\n end;\n writeln(res);\n for i:=1 to res do write(a[i],' ');\nend.\n\n\n"}, {"source_code": "var\n n,i,j,tot,ans:longint;\n ansq:array[1..100000] of longint;\n que:array[1..1000000] of longint;\n q:array[1..100000] of longint;\n f,pre:array[0..1000000] of longint;\n\nprocedure judge(t:longint);\nvar\n tmp:longint;\nbegin\n tmp:=t;\n while t>0 do\n begin\n if (t mod 10<>0) and (t mod 10<>1) then exit;\n t:=t div 10;\n end;\n inc(tot); que[tot]:=tmp;\nend;\n\nprocedure dp;\nvar\n i,j,t:longint;\nbegin\n fillchar(f,sizeof(f),100); f[0]:=0;\n for i:=0 to n-1 do\n if f[i]+1f[i]+1) then\n begin\n f[i+que[j]]:=f[i]+1;\n pre[i+que[j]]:=i;\n end;\n writeln(f[n]); t:=n;\n while t>0 do\n begin\n write(t-pre[t],' ');\n t:=pre[t];\n end;\n writeln;\nend;\n\nbegin\n readln(n); ans:=n+1;\n for i:=n downto 1 do judge(i);\n dp;\nend.\n"}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a, d, b :array[1..123456] of integer;\n n, kol, i, j, sum, w, u, k :integer;\n\nbegin\n readln(n);\n kol := 0;\n w := 0;\n sum := 0;\n k := 0;\n while (n > 0) do\n begin\n inc(kol);\n a[kol] := n mod 10;\n n := n div 10;\n end;\n\n for i := kol downto 1 do\n begin\n w := a[i];\n for j := 1 to 20 do\n d[j] := 0;\n for j := i downto 1 do\n begin\n if (a[j] >= w) then\n begin\n d[j] := w;\n a[j] := a[j] - w;\n end\n else\n begin\n d[j] := a[j];\n a[j] := 0;\n end;\n end;\n\n for j := 1 to w do\n begin\n inc(sum);\n for u := i downto 1 do\n begin\n inc(k);\n if (d[u] >= 1) then\n b[k] := 1\n else\n\n b[k] := 0;\n dec(d[u]);\n\n end;\n inc(k);\n b[k] := -1;\n\n end;\n\n\n end;\n writeln(sum);\n for i := 1 to k do\n if (b[i] = -1) then\n write(' ')\n else\n write(b[i]);\n readln;\n readln;\nend.\n"}, {"source_code": " type niz=array[-1..1000000] of longint;\nprocedure sort(var a:niz;n:longint);\n var i,h,s,f,l:longint;\nbegin\n\n for i:=2 to n do\n begin\n h:=a[i]; s:=i;f:=s div 2;\n while ((s>1) and (a[f]=3) and (a[3]>a[2]))\n then s:=3 else s:=2;\n while (s<=i-1) and (a[s]>l) do\n begin\n a[f]:=a[s]; f:=s; s:=2*f;\n if ((s+1<=i-1) and (a[s+1]>a[s]))\n then s:=s+1;\n end;\n a[f]:=l;\n end;\nend;\nvar\n s:ansistring; i,j,x,res,q,p,n:longint;\n a,b,dp,dp1:niz;\n begin\n read(n);\n for i:=1 to 8*8*2-1 do\n begin\n s:=binstr(i,7);\n for j:=1 to 7 do\n if s[j]='0' then a[i]:=a[i]*10 else a[i]:=a[i]*10+1;\n end;\n\n sort (a,8*8*2-1);\n\n dp[0]:=0;\n\n for i:=1 to n do\n dp[i]:=maxlongint;\n\n for i:=1 to n do\n for j:=1 to 8*8*2-1 do\n begin\n if a[j]>i then break;\n if dp[i]>dp[i-a[j]]+1 then\n begin\n dp[i]:=dp[i-a[j]]+1;\n dp1[i]:=a[j];\n end;\n end;\n\n writeln(dp[n]);\n\n p:=n;\n for i:=1 to dp[n] do\n begin\n write(dp1[p],' ');\n p:=p-dp1[p];\n end;\nend.\n"}, {"source_code": "var s:array[1..10] of string;\n n:string;\n i,k,l,j:integer;\n\nprocedure decall;\nvar i:longint;\nbegin\nfor i:=1 to l do\n dec(n[i]);\nend;\n\nbegin\nreadln(n);\nl:=length(n);\n\n \nfor i:=1 to 9 do\n begin\n for j:=1 to l do\n if n[j] > '0'\n then s[i]:=s[i]+'1'\n else s[i]:=s[i]+'0';\n decall;\n while (length(s[i])>0)and (s[i][1] = '0') do delete(s[i],1,1);\n if s[i] <> '' then inc(k);\n end;\n \n writeln(k);\n for i:=1 to k do\n write(s[i],' ');\nend."}, {"source_code": "var\n l, k: integer;\n n,i: longint;\n min, max, pos0: byte;\n found0: boolean;\n\nfunction len(a: longint): integer;\nvar\n k: integer;\nbegin\n min := 10;\n max := 0;\n found0 := false;\n k := 0;\n while a > 0 do\n begin\n if a mod 10 = 0 then\n begin\n found0 := true;\n pos0 := k + 1;\n end\n else if (a mod 10 < min) then\n min := a mod 10;\n if (a mod 10 > max) then\n max := a mod 10;\n a := a div 10;\n inc(k);\n end;\n len := k;\nend;\n\nfunction pow10(a: byte): longint;\nvar\n k: longint;\n i: byte;\nbegin\n k := 1;\n for i := a downto 1 do\n k := k * 10;\n pow10 := k;\nend;\n\nfunction get11(a: byte): longint;\nvar\n k,n2: longint;\n i,j: byte;\nbegin\n k := 0;\n for i := a downto 1 do\n begin\n n2 := n;\n k := k * 10;\n for j := 1 to i-1 do\n n2 := n2 div 10;\n if n2 mod 10 <> 0 then\n inc(k);\n end;\n get11 := k;\nend;\n\nbegin\n readln(N);\n \n l := len(n);\n writeln(max);\n k := get11(l);\n for i := 1 to min do\n begin\n n := n - k;\n write(k, ' ');\n end;\n \n while n > 0 do\n begin\n l := len(n);\n k := get11(l);\n for i := 1 to min do\n begin\n n := n - k;\n write(k, ' ');\n end;\n end;\nend."}, {"source_code": "program Project300;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar i,a,b,n:integer; s:string;\n m:array[1..6]of integer;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n readln(a);\n n:=0;\n While a>0 do\n begin\n b:=a mod 10;\n a:=a div 10;\n inc(n);\n m[n]:=b;\n end;\n a:=0;\n for i:=1 to n do a:=max(m[i],a);\n writeln(a);\n While true do\n begin\n b:=n;\n While (m[b]=0)and(b>0) do dec(b);\n if b=0 then break;\n for i:=b downto 1 do\n begin\n if m[i]>0 then\n begin\n write('1');\n dec(m[i]);\n end\n else write('0');\n end;\n write(' ');\n end;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\nx: array of integer;\ns, h: string;\na,i,b, max, j, z: integer;\nq: array [0..1000] of longint;\nbegin\nmax:=0;\nreadln(s);\na:=length(s);\nsetlength(x, a);\n for i:= 1 to a do\n x[i-1]:=strtoint(s[i]);\nz:=1;\nq[0]:=0;\n for i:=0 to a-1 do\n if max0 do\n begin\n for i:=1 to a do\n begin\n if (x[i-1]<>0) then\n begin\n q[z]:=round(power(10, a-i)) + q[z];\n x[i-1]:=x[i-1] - 1;\n end;\n end;\n z:=z+1;\n max:=max-1;\n end;\n\nwriteln(z-1); \nfor i:=1 to z-1 do\nif i<>z-1 then\nwrite(q[i], ' ')\nelse\nwrite(q[i]);\nreadln;\nend.\n "}, {"source_code": "uses math,sysutils;\nvar i,p,l,k,j,m,n,imain,t,x1,x2,y1,y2,jmain,u,y,len,l1,l2,r1,r2:longint;\n a,b,c:array[0..1000]of int64;\n s:string;\n\nprocedure io;\nvar i:longint;\nbegin\n for i:=1 to m do\n begin\n a[i]:=strtoint(inttostr(n)[i]);\n b[i]:=0;\n end;\nend;\n\nbegin\n read(n);\n while n<>0 do\n begin\n m:=length(inttostr(n));\n io;\n for i:=1 to m do\n begin\n if a[i]>1 then\n b[i]:=1\n else\n b[i]:=a[i];\n end;\n k:=0;\n for i:=1 to m do\n begin\n k:=k+b[i]*round(power(10,m-i));\n end;\n n:=n-k;\n inc(t);\n c[t]:=k;\n end;\n writeln(t);\n for i:=1 to t do\n write(c[i],' ');\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='b';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qn then n:=cc[i];\n writeln(n);\n for i:=1 to n do\n begin\n k:=0;\n for j:=0 to 6 do\n if cc[j]>0 then\n begin\n inc(k,qq[j]);\n dec(cc[j]);\n end;\n write(k,' ');\n end;\n \n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "Uses\n Math;\nVar\n n,l,st,mx,j,i:longint;\n r:array[1..7]of longint;\n an:array[1..9]of longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n);l:=0;mx:=0;\n while n<>0 do\n begin\n inc(l);\n r[l]:=n mod 10;\n mx:=max(mx,r[l]);\n n:=n div 10;\n end;\n writeln(mx);\n for i:=1 to mx do\n an[i]:=0;\n st:=1;\n for i:=1 to l do\n begin\n for j:=1 to r[i] do\n inc(an[j],st);\n st:=st*10;\n end;\n for i:=1 to mx do\n write(an[i],' ');\nend."}, {"source_code": "var b:array[1..100] of longint;\n i,c,n,s,a,t:longint;\nbegin\nreadln(n);\ns:=n;\nc:=1;\nwhile(n>0)do\n begin\n a:=n mod 10;\n for i:=1 to a do\n b[i]:=b[i]+c;\n if(a>t)then t:=a;\n c:=c*10;\n n:=n div 10;\n a:=0;\n end;\n \nwriteln(t);\n\nfor i:=1 to t do\n write(b[i],' ');\nend."}, {"source_code": "const fi='';\n fo='';\n\nvar n,min,res:longint;\n s,ans:string;\n a,b:array[0..10] of longint;\n f,g:text;\n\nprocedure doc;\nbegin\n readln(f,s);\nend;\n\nprocedure chuanbi;\nvar i:longint;\nbegin\n n:=length(s);\n for i:=1 to n do\n begin\n a[i]:=ord(s[i])-48;\n end;\nend;\n\nprocedure xuli;\nvar i,x,y,j:longint;\nbegin\n x:=1;y:=1;\n while x<=n do\n begin\n for i:=1 to n do b[i]:=0;\n min:=high(longint);\n for i:=x to n do\n begin\n if a[i]>0 then b[i]:=1;\n if (a[i]>0) and (a[i]0 then\n begin\n y:=i;break;\n end;\n for i:=1 to n do\n if a[i]>0 then\n begin\n x:=i;break;\n end;\n for i:=1 to min do\n begin\n inc(Res);\n for j:=y to n do\n ans:=ans+chr(b[j]+48);\n ans:=ans+' ';\n end;\n end;\nend;\n\nprocedure ghi;\nbegin\n writeln(g,res);\n writeln(g,ans);\nend;\n\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n doc;\n chuanbi;\n xuli;\n ghi;\n close(f);close(g);\nend.\n"}, {"source_code": "var s:string;\n ans:array[1..100] of string;\n b:boolean;\n i,k,n,m,j:longint;\nbegin\nreadln(s);\n\nb:=true;\nwhile b do\nbegin\n b:=false;\n inc(n);\n for i:=1 to length(s) do\n if s[i]='0'\n then ans[n]:=ans[n]+s[i]\n else begin\n b:=true;\n ans[n]:=ans[n]+'1';\n s[i]:=chr(ord(s[i])-1);\n end;\nend;\nwriteln(n-1);\nfor i:=1 to n-1 do\nbegin\n k:=1;\n while ans[i,k]='0' do\n inc(k);\n for j:=k to length(ans[i]) do\n write(ans[i,j]);\n write(' ');\nend;\n\nend.\n\n\n\n\n"}, {"source_code": "{$mode objfpc}\nvar n,i,k,j,max:integer;t:boolean;\n a:array[0..1000] of integer;\nbegin\n read(n);\n i:=0;\n max:=low(integer);\n while n>0 do\n begin\n inc(i);\n a[i]:=n mod 10;\n n:=n div 10;\n if a[i]>max then max:=a[i];\n end;\n writeln(max);\n for j:=1 to max do\n begin\n t:=false;\n for k:=i downto 1 do\n begin\n if (a[k]=0) and (t=true) then write('0');\n if (a[k]>0) then\n begin\n write('1');\n dec(a[k]);\n t:=true;\n end;\n end;\n write(' ');\n end;\nend.\n"}, {"source_code": "uses sysutils;\nvar\n i,i2,o,inp,tmp:longint;\n a:array[1..9] of longint;\n s:string;\nbegin\n readln(inp);\n s:=inttostr(inp);\n for i:=1 to length(s) do\n begin\n if (strtoint(s[i])>o) then\n o:=strtoint(s[i]);\n tmp:=1;\n for i2:=1 to (length(s)-i) do\n tmp:=tmp*10;\n for i2:=1 to (strtoint(s[i])) do\n a[i2]:=a[i2]+tmp;\n end;\n writeln(o);\n for i:=1 to o do\n write(a[i],' ');\nend."}, {"source_code": "Program Main;\n\n Type TMem = record\n MinCount : LongInt;\n LastDigit : LongInt;\n end;\n\n\n var Memory : Array [ 0 .. 2000000 ] of TMem;\n Q : Array [ 1 .. 2000000 ] of LongInt;\n QHead : LongInt;\n\n Moves : Array [ 1 .. 100000 ] of LongInt;\n MovesCount : LongInt;\n\n Function Dva ( I : LongInt ) : Boolean;\n var S : String;\n j : LongInt;\n begin\n STR ( I , S ) ;\n for j := 1 to Length(S) do\n if ( S[j] <> '1' ) and ( S[j] <> '0' ) then\n exit ( false ) ;\n\n Dva := true;\n end;\n\n Procedure Add ( I , N : LongInt ) ;\n var x : LongInt;\n cDist : LongInt;\n begin\n cDist := Q[i];\n for x := 1 to MovesCount do\n begin\n if ( Memory[cDist+Moves[x]].MinCount = 0 ) then\n begin\n if ( cDist + Moves[x] <= N ) then\n begin\n Memory[cDist+Moves[x]].MinCount := Memory[cDist].MinCount+1;\n Memory[cDist+Moves[x]].LastDigit := Moves[x];\n inc ( QHead ) ;\n Q[QHead] := cDist+Moves[x];\n end;\n end;\n end;\n end;\n\n Procedure AddMoves ( N : LongInt ) ;\n var I : LongInt;\n begin\n MovesCount := 0;\n for i := 1 to N do\n if ( Dva(I) ) then\n begin\n inc ( MovesCount ) ;\n Moves[MovesCount] := I;\n end;\n end;\n\n var N , I : LongInt;\nbegin\n readLn ( N ) ;\n\n AddMoves ( N ) ;\n\n QHead := 1 ;\n Q[1] := 0;\n I := 1;\n while ( I <= QHead ) do\n begin\n add ( i , n ) ;\n inc ( i ) ;\n end;\n\n I := N;\n writeLn ( Memory [ N ].MinCount ) ;\n\n while ( I <> 0 ) do\n begin\n if ( Memory[I].LastDigit <> 0 ) then\n write(Memory[I].LastDigit , ' ');\n I := I-Memory[i].LastDigit;\n end;\n\nend.\n"}, {"source_code": "var\nn,x,max:int64;\ni:longint;\na,b:array[1..9] of int64;\nbegin\nreadln(n);\nb[1]:=1;\nwhile(n<>0)do begin\ninc(i);\nif i<>1\nthen b[i]:=b[i-1]*10;\na[i]:=n mod 10;\nn:=n div 10;\nif a[i]>max\nthen max:=a[i];\nend;\nwriteln(max);\nwhile true do begin\nx:=0;\nfor i:=1 to 9 do\nif a[i]<>0\nthen begin\ndec(a[i]);\ninc(x,b[i]);\nend;\nif x=0\nthen halt;\nwrite(X,' ');\nend;\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar x:longint;\n i,j,res,k,dem,ma:longint;\n a,b:array[1..9] of byte;\n s:string;\nprocedure swap(var x,y:byte);\nvar tg:byte;\nbegin\n tg:=x;x:=y;y:=tg;\nend;\nprocedure init;\nbegin\n dem:=0;\n while x<>0 do\n begin\n inc(dem);\n a[dem]:=x mod 10;\n x:=x div 10;\n end;\n\n for i:=1 to dem div 2 do\n swap(a[i],a[dem-i+1]);\n\n ma:=a[1];\n for i:=2 to dem do ma:=max(ma,a[i]);\n for i:=1 to dem do\n b[i]:=a[i];\nend;\n\n\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n readln(x);\n\n init;\n\n for i:=1 to ma do\n begin\n s:='';\n for j:=1 to dem do\n if a[j]>0 then\n begin\n s:=s+'1';\n dec(a[j]);\n end else s:=s+'0';\n while s[1]='0' do delete(s,1,1);\n inc(res);\n end;\n writeln(res);\n\n for i:=1 to ma do\n begin\n s:='';\n for j:=1 to dem do\n if b[j]>0 then\n begin\n s:=s+'1';\n dec(b[j]);\n end else s:=s+'0';\n while s[1]='0' do delete(s,1,1);\n write(s,' ');\n end;\n close(input);close(output);\nend.\n"}, {"source_code": "var b:array[1..100] of longint;\n i,c,n,s,a,t:longint;\nbegin\nreadln(n);\ns:=n;\nc:=1;\nwhile(n>0)do\n begin\n a:=n mod 10;\n for i:=1 to a do\n b[i]:=b[i]+c;\n if(a>t)then t:=a;\n c:=c*10;\n n:=n div 10;\n a:=0;\n end;\n \nwriteln(t);\n\nfor i:=1 to t do\n write(b[i],' ');\nend.\n"}, {"source_code": "program Contest300_B;\nuses math;\nconst\n maxN=trunc(106);\nvar\n ff: text;\n n: longint;\n T,v,S: array[0..7] of longint;\n i,j,tmp,m,c: longint;\n\nprocedure swap(var a,b: longint);\n var t: longint;\n begin\n t:=a;a:=b;b:=t;\n end;\n\nbegin\n readln(n);\n i:=0;\n while n<>0 do\n begin\n inc(i);\n T[i]:=n mod 10;\n v[i]:=i;\n S[i]:=max(1,S[i-1]*10);\n n:=n div 10;\n end;\n m:=i;\n for i:=1 to m do\n begin\n tmp:=i;\n for j:=i+1 to m do\n if (T[j]>T[tmp]) then tmp:=j;\n Swap(T[i],T[tmp]);\n Swap(v[i],v[tmp]);\n end;\n //for i:=1 to m do writeln(T[i],' ',v[i]);readln;\n writeln(T[1]);\n tmp:=0;\n i:=1;\n while true do\n begin\n j:=i;\n repeat\n i:=j;\n tmp:=tmp+S[ v[j] ];\n if (j0 do \n\t\tbegin\n\t\t\tif x mod 10>1 then flag:=false;\n\t\t\tx:=x div 10;\n\t\tend;\n\t\tif flag then \n\t\tbegin\n\t\t\tinc(a[0]);\n\t\t\ta[a[0]]:=i;\n\t\tend;\n\tend;\n\t//writeln(a[0]);\n\tfillchar(b,sizeof(b),63);\n\treadln(n);b[0]:=0;\n\tfor i:=1 to n do \n\t\tfor j:=1 to a[0] do \n\t\tbegin\n\t\t\tif i0 do \n\tbegin\n\t\twrite(n-f[n],' ');\n\t\tn:=f[n];\n\tend;\nend."}, {"source_code": "var\n n, i, j, res, oo, jmax: longint;\n f, trace, val: array [0..1000100] of longint;\nfunction check(k: longint): boolean;\nvar j: longint;\n s: string;\nbegin\n\tstr(k, s);\n\tfor j:=1 to length(s) do \n\t\tif ((s[j] <> '1') and (s[j] <> '0')) then exit(false);\n\texit(true);\nend;\n\nprocedure init;\nbegin\nfor i:=1 to n do\n if (check(i)) then\n begin\n inc(jmax);\n val[jmax] := i;\n end;\nend;\nbegin\n read(n);\n oo := 2000000;\n init;\n for i:=1 to n do f[i] := oo;\n for i:=1 to n do\n for j:=1 to jmax do\n if (i >= val[j]) then\n if (f[i] > f[i-val[j]] + 1) then\n begin\n f[i] := f[i-val[j]] + 1;\n trace[i] := i - val[j];\n end;\n res := n;\n writeln(f[res]);\n while (f[res] <> 0) do\n begin\n write(res - trace[res], ' ');\n res := trace[res];\n end;\nend.\n"}], "negative_code": [{"source_code": "program zd1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, free, q, f, sum: integer;\n a, b: array[1..1000100] of integer;\n \nbegin\n readln(n); \n j := n;\n q := 0;\n while (j > 0) do\n begin\n if (j mod 10 > 1) then\n begin\n q := 1;\n break;\n end;\n j := j div 10;\n end;\n if (q = 0) then\n begin\n writeln(1);\n writeln(n);\n halt;\n end;\n free := 0;\n for i := 1 to n div 2 do\n begin\n j := i;\n q := 0;\n while (j > 0) do\n begin\n if (j mod 10 > 1) then\n begin\n q := 1;\n break;\n end;\n j := j div 10;\n end;\n if (q > 0) then\n continue;\n inc(free);\n a[free] := i;\n end;\n f := 0;\n i := free;\n while (i > 0) do\n begin\n while (a[i] <= n) do\n begin\n inc(f);\n b[f] := a[i];\n n := n - a[i];\n end;\n dec(i);\n end;\n writeln(f);\n for i := 1 to f do\n write(b[i], ' ');\n readln;\n readln;\nend.\n"}, {"source_code": "program zd1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, free, q, f, sum: integer;\n a, b: array[1..1000100] of integer;\n \nbegin\n readln(n);\n free := 0;\n for i := 1 to n do\n begin\n j := i;\n q := 0;\n while (j > 0) do\n begin\n if (j mod 10 > 1) then\n begin\n q := 1;\n break;\n end;\n j := j div 10;\n end;\n if (q > 0) then\n continue;\n inc(free);\n a[free] := i;\n end;\n f := 0;\n i := free;\n while (i > 0) do\n begin\n while (a[i] <= n) do\n begin\n inc(f);\n b[f] := a[i];\n n := n - a[i];\n end;\n dec(i);\n end;\n writeln(f);\n for i := 1 to f do\n write(b[i], ' ');\n readln;\n readln;\nend.\n"}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a, d :array[1..123456] of integer;\n n, kol, i, j, sum, w, u :integer;\n\nbegin\n readln(n);\n kol := 0;\n w := 0;\n while (n > 0) do\n begin\n inc(kol);\n a[kol] := n mod 10;\n n := n div 10;\n end;\n\n for i := kol downto 1 do\n begin\n w := a[i];\n for j := 1 to 20 do\n d[j] := 0;\n for j := i downto 1 do\n begin\n if (a[j] >= w) then\n begin\n d[j] := w;\n a[j] := a[j] - w;\n end\n else\n begin\n d[j] := a[j];\n a[j] := 0;\n end;\n end;\n\n for j := 1 to w do\n begin\n for u := i downto 1 do\n begin\n if (d[u] >= 1) then\n write(1)\n else\n\n write(0);\n dec(d[u]);\n\n end;\n write(' ');\n end;\n\n\n end;\n\n readln;\n readln;\nend.\n"}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a, d :array[1..123456] of integer;\n n, kol, i, sum :integer;\n\nprocedure sort(l, r:integer);\nvar\n x, q, i, j:integer;\nbegin\n x := a[random(r - l + 1) +l];\n i := l;\n j := r;\n while (i < j) do\n begin\n while (a[i] < x) do\n inc(i);\n while (a[j] > x) do\n dec(j);\n if (i <= j) then\n begin\n q := a[i];\n a[i] := a[j];\n a[j] := q;\n inc(i);\n dec(j);\n end;\n end;\n\n if (l < j) then sort(l, j);\n if (i < r) then sort(i, r);\nend;\n\nprocedure rec(v :integer);\nbegin\n if (v > 10000000) then\n exit;\n inc(kol);\n a[kol] := v;\n rec(v * 10 + 1);\n rec(v * 10);\nend;\n\nbegin\n readln(n);\n kol := 0;\n rec(1);\n\n sum := 0;\n sort(1, kol);\n for i := kol downto 1 do\n begin\n while (n >= a[i]) do\n begin\n inc(sum);\n d[sum] := a[i];\n n := n - a[i];\n end;\n end;\n writeln(sum);\n for i := 1 to sum do\n write(d[i], ' ');\n readln;\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\nx: array of integer;\ns, h: string;\na,i,b, max, j, z: integer;\nq: array [0..1000] of longint;\nbegin\nmax:=0;\nreadln(s);\na:=length(s);\nsetlength(x, a);\n for i:= 1 to a do\n x[i-1]:=strtoint(s[i]);\nz:=1;\nq[0]:=0;\n for i:=0 to a-1 do\n if max0 do\n begin\n for i:=1 to a do\n begin\n if (x[i-1]<>0) then\n begin\n q[z]:=round(power(10, a-i)) + q[z];\n x[i-1]:=x[i-1] - 1;\n end;\n end;\n z:=z+1;\n max:=max-1;\n end;\nfor i:=1 to z-1 do\nwrite(q[i], ' ') ;\n\n\nreadln;\nreadln;\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\nx: array of integer;\ns, h: string;\na,i,b, max, j, z: integer;\nq: array [0..1000] of longint;\nbegin\nmax:=0;\nreadln(s);\na:=length(s);\nsetlength(x, a);\n for i:= 1 to a do\n x[i-1]:=strtoint(s[i]);\nz:=1;\nq[0]:=0;\n for i:=0 to a-1 do\n if max0 do\n begin\n for i:=1 to a do\n begin\n if (x[i-1]<>0) then\n begin\n q[z]:=round(power(10, a-i)) + q[z];\n x[i-1]:=x[i-1] - 1;\n end;\n end;\n z:=z+1;\n max:=max-1;\n end;\nfor i:=1 to z-1 do\nif i<>z-1 then\nwrite(q[i], ' ')\nelse\nwrite(q[i]);\nreadln;\nend.\n "}, {"source_code": "Uses\n Math;\nVar\n n,l,st,mx,j,i:longint;\n r:array[1..6]of longint;\n an:array[1..9]of longint;\nbegin\n readln(n);l:=0;mx:=0;\n while n<>0 do\n begin\n inc(l);\n r[l]:=n mod 10;\n mx:=max(mx,r[l]);\n n:=n div 10;\n end;\n writeln(mx);\n for i:=1 to mx do\n an[i]:=0;\n st:=1;\n for i:=1 to l do\n begin\n for j:=1 to r[i] do\n inc(an[j],st);\n st:=st*10;\n end;\n for i:=1 to mx do\n write(an[i],' ');\nend."}, {"source_code": "var i,min,aint,count:integer;\na,x,y,sa:string;\narr:array[1..7]of integer;\nbegin\nread(a);\nsa:=a;\naint:=strtoint(a);\n\n\nrepeat\nmin:=10;\ny:='';\nfor i:=1 to length(a) do y:=y+1;\naint:=aint-strtoint(y);\ncount:=count+1;\na:=inttostr(aint);\nuntil aint<=0;\nwriteln(count);\n\naint:=strtoint(sa);\nrepeat\nmin:=10;\ny:='';\nfor i:=1 to length(sa) do begin\nx:=sa[i];\narr[i]:=strtoint(x);\nend;\nfor i:=1 to length(sa) do y:=y+1;\nfor i:=1 to length(sa) do \nif arr[i]=0 then y[i]:='0';\nprint(y);\naint:=aint-strtoint(y);\nsa:=inttostr(aint);\nuntil aint<=0;\n\n\nend.\n"}, {"source_code": "var r,max,n,i,j,tek:longint;\n a:Array[1..1000]of longint;\n fl:boolean;\nbegin\n read(n);\n while n>0 do\n begin\n inc(tek);\n a[tek]:= n mod 10;\n n:=n div 10;\n end;\n for i:=1 to tek div 2 do\n begin\n r:=a[i];\n a[i]:=a[tek-i+1];\n a[tek-i+1]:=r;\n end;\n for i:=1 to tek do\n if max0\n then begin dec(a[j]);\n write(1);\n fl:=true;\n end\n else if fl=true\n then write(0);\n write(' ');\n end;\n \n\n\n\nend."}, {"source_code": "program ZAD_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,i,j,s:integer;\n a:array [1..65] of integer;\n d,d1,d2:array [0..1000000] of integer;\nprocedure rec(k:integer);\nbegin\n if (k=0) then exit;\n rec(d2[k]);\n if (k=n) then writeln(d1[k])\n else write(d1[k],' ');\nend;\nbegin\n readln(n);\n s := 0;\n for i:=1 to n do\n begin\n j:=i;\n while (j>0) do\n begin\n if (j mod 10 <> 0) and (j mod 10 <>1) then break;\n j:=j div 10;\n end;\n if (j = 0) then\n begin\n inc(s);\n a[s]:=i;\n end;\n end;\n d[0] := 0;\n for i:=1 to n do\n begin\n d[i]:=maxint;\n for j:=1 to s do\n if (i-a[j]>=0) and (d[i-a[j]]+1 '1') and (s[j] <> '0') then k := 13;\n if k = 0 then\n begin\n inc(free);\n a[free] := i;\n end;\n end;\n //writeln(free);\n k := 0;\n while (n > 0) and (free > 0) do\n begin\n while n >= a[free] do\n begin\n inc(k);\n n := n - a[free];\n b[k] := a[free];\n end;\n dec(free);\n end;\n writeln(k);\n for i := 1 to k do\n write(b[i],' ');\n readln;\nend.\n\n\n"}, {"source_code": "const eps=0.0000000001; besk=20000000000008; nn=200000;\n\n label 1,2,3,4;\n type { real=double;} {string=ansistring;}\n mas=array [-10..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ppp,modul,v1,v2,kol,t,p,sum,k1,ii,jj,q,pos,z,pmax,imax,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n ot,h,nap,pp1,pp2,mask1,mask2,mask,newnapy,posi,posj,time,pp,step, k,t1,i,j:longint;\n kk,osn, aaa,bbb, bb,ccc,dd:int64;\n dost,aa,mm,tt,ll,r,x,y,fact,d,c,aold,b,a:array[-10..3000000] of int64;\n al,ar: array[-10..1200,-10..1200] of int64;\n ver, dda: array[-10..1200,-10..1200] of extended;\n marked:array[-10..3000030] of boolean;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n sot:array [-10..1000000] of char;\n zan,fl:array[-10..200000] of boolean;\n ss:string;ch:char;\n ddp, pole :array [-100..200,-100..200] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n p1,p2,v0,s0,t0:extended;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function phi(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n phi:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=degg(p,deg-1)*p mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction bmena:boolean; var i,j:longint; fl:boolean;\n begin\n fl:=false; for i:=0 to n-1 do if b[i]aa[i] then begin {writeln('bol ',i);} break; end;\n bmena:=fl;\n end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(ppp);\n\n for i:=0 to 1000000 do d[i]:=1000000000;\n for step:=1 to 6 do\n begin\n p:=1 shl step;\n for mask:=0 to p-1 do\n begin\n t:=0; q:=mask;\n for i:=1 to step do begin b[i]:=q mod 2; q:=q div 2; end;\n for i:=1 to step do if b[i]=0\n then t:=10*t else t:=10*t+1;\n inc(pp); a[pp]:=t;\n\n end;\n\n end;\n\n\n\n { for i:=1 to pp do write(a[i],' '); writeln;\n } for i:=1 to pp do for j:=1 to pp-1 do if a[j]>a[j+1] then\n begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end;\n { for i:=1 to pp do write(a[i],' '); writeln;\n } t:=0; a[0]:=-100;\n for i:=1 to pp do if a[i]>a[i-1] then begin inc(t); c[t]:=a[i]; end;\n { writeln(t);\n for i:=1 to t do write(c[i],' '); writeln;\n } d[0]:=0;\n for i:=0 to 1000000 do for j:=1 to t do\n begin\n d[i+c[j]]:=min(d[i+c[j]],d[i]+1);\n if d[i+c[j]]=d[i]+1 then dost[i+c[j]]:=i;\n\n\n\n end;\n { for i:=1 to 40 do write(d[i],' ');writeln;\n for i:=1 to 40 do write(dost[i],' ');writeln;\n }\n p:=ppp;\n writeln(d[p]);\n while p>0 do begin write(p-dost[p],' '); p:=dost[p]; end;\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "uses sysutils;\nvar\n\ts1,s,sc: longint;\n\tn\t: longint;\n\ta,k\t: string;\n\tmin,m\t: integer;\nbegin\n\treadln(n);\n\ts:=1;\n\ts1:=1;\n\twhile sn then\n\tbegin\n\t\tdec(s1);\n\t\ts:= s div 10;\n\tend;\n\n\twhile n>0 do\n\tbegin\n while s>n do\n begin\n dec(s1);\n s:=s div 10;\n end;\n\t\ta:=inttostr(n);\n\t\tk:='';\n\t\tmin:=9;\n\t\tfor sc:= 1 to s1 do\n\t\tbegin\n\t\t\tif a[sc]='0' then k:=k+'0' else k:=k+ '1';\n\t\t\tif (strtoint(a[sc])'0') then min:= strtoint(a[sc]);\n\t\tend;\n\t\tfor m:= 1 to min-1 do\n\t\tbegin\n\t\t\twrite(k,' ');\n\t\t\tn:=n-strtoint(k);\n\n\t\tend;\n\t\twrite(k);\n n:=n-strtoint(k);\n\t\tif n>0 then write(' ');\n\tend;\n\twriteln;\nend.\n"}, {"source_code": "var\n num : array[1..7] of longint;\n n : longint;\n s,s1 : longint;\n ans : array[1..10000] of longint;\n c : integer;\nbegin\n readln(n);\n num[1]:=1;\n num[2]:=11;\n num[3]:=111;\n num[4]:=1111;\n num[5]:=11111;\n num[6]:=111111;\n num[7]:=1000000;\n s :=1;\n s1:=1;\n while sn then\n begin\n dec(s1);\n s:=s div 10;\n end;\n c:=0;\n s:=1;\n while n>0 do\n begin\n while num[s1]<=n do\n begin\n n:=n-num[s1];\n inc(c);\n ans[c]:=num[s1];\n end;\n dec(num[s1],s);\n s:=s*10;\n if num[s1]=0 then\n begin\n s:=1;\n dec(s1);\n end;\n end;\n writeln(c);\n for s:= 1 to c-1 do\n write(ans[s],' ');\n writeln(ans[c]);\nend.\n"}, {"source_code": "var\ni,n,x1,x2,x3,x4,x5,x6,x7:longint;\nbegin\nread(n);\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nwhile(n>0)do begin\n x7:=n mod 10;\n if x7>0 then begin\n n:=n-1;\n x7:=1;\n end else x7:=0;\n x6:=n mod 100;\n if x6 div 10>0 then begin\n n:=n-10;\n x6:=10;\n end else x6:=0;\n x5:=n mod 1000;\n if x5 div 100>0 then begin\n n:=n-100;\n x5:=100;\n end else x5:=0;\n x4:=n mod 10000;\n if x4 div 1000>0 then begin\n n:=n-1000;\n x4:=1000;\n end else x4:=0;\n x3:=n mod 100000;\n if x3 div 10000>0 then begin\n n:=n-10000;\n x3:=10000;\n end else x3:=0;\n x2:=n mod 1000000;\n if x2 div 100000>0 then begin\n n:=n-100000;\n x2:=100000;\n end else x2:=0;\n x1:=n mod 10000000;\n if x1 div 1000000>0 then begin\n n:=n-1000000;\n x1:=1000000;\n end else x1:=0;\nif (x1+x2+x3+x4+x5+x6+x7)>0 then write(x1+x2+x3+x4+x5+x6+x7,' ');\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nend;\nend."}, {"source_code": "var\ni,n,x1,x2,x3,x4,x5,x6,x7:longint;\nbegin\nread(n);\nwhile(n>0)do begin\n x7:=n mod 10;\n if x7>0 then begin\n n:=n-1;\n x7:=1;\n end else x7:=0;\n x6:=n mod 100;\n if x6 div 10>0 then begin\n n:=n-10;\n x6:=10;\n end else x6:=0;\n x5:=n mod 1000;\n if x5 div 100>0 then begin\n n:=n-100;\n x5:=100;\n end else x5:=0;\n x4:=n mod 10000;\n if x4 div 1000>0 then begin\n n:=n-1000;\n x4:=1000;\n end else x4:=0;\n x3:=n mod 100000;\n if x3 div 10000>0 then begin\n n:=n-10000;\n x3:=10000;\n end else x3:=0;\n x2:=n mod 1000000;\n if x2 div 100000>0 then begin\n n:=n-100000;\n x2:=100000;\n end else x2:=0;\n x1:=n mod 10000000;\n if x1 div 1000000>0 then begin\n n:=n-1000000;\n x1:=1000000;\n end else x1:=0;\nif (x1+x2+x3+x4+x5+x6+x7)>0 then write(x1+x2+x3+x4+x5+x6+x7,' ');\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nend;\nwriteln;\nend."}, {"source_code": "var\ni,n,x1,x2,x3,x4,x5,x6,x7:longint;\nbegin\nread(n);\nif n=0 then begin\n writeln(0);exit;end;\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nwhile(n>0)do begin\n x7:=n mod 10;\n if x7>0 then begin\n n:=n-1;\n x7:=1;\n end else x7:=0;\n x6:=n mod 100;\n if x6 div 10>0 then begin\n n:=n-10;\n x6:=10;\n end else x6:=0;\n x5:=n mod 1000;\n if x5 div 100>0 then begin\n n:=n-100;\n x5:=100;\n end else x5:=0;\n x4:=n mod 10000;\n if x4 div 1000>0 then begin\n n:=n-1000;\n x4:=1000;\n end else x4:=0;\n x3:=n mod 100000;\n if x3 div 10000>0 then begin\n n:=n-10000;\n x3:=10000;\n end else x3:=0;\n x2:=n mod 1000000;\n if x2 div 100000>0 then begin\n n:=n-100000;\n x2:=100000;\n end else x2:=0;\n x1:=n mod 10000000;\n if x1 div 1000000>0 then begin\n n:=n-1000000;\n x1:=1000000;\n end else x1:=0;\nif (x1+x2+x3+x4+x5+x6+x7)>0 then write(x1+x2+x3+x4+x5+x6+x7,' ');\nx1:=0;x2:=0;x3:=0;x4:=0;x5:=0;x6:=0;x7:=0;\nend;\nend."}, {"source_code": "var\n mx,i,j,n,m,k,t,x:longint;\n s:ansistring;\n a:array[0..11]of longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do begin a[i]:=ord(s[i])-48;if a[i]>mx then mx:=a[i];end;\n writeln(mx);\n for i:=1 to mx do\n begin\n for j:=1 to n do if a[j]=0 then write(0)else begin write(1);dec(a[j]);end;\n write(' ');\n end;\n writeln;\nend.\n"}, {"source_code": "var\n mx,i,j,n,m,k,t,x:longint;\n s:ansistring;\n a:array[0..11]of longint;\n c:char;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do begin a[i]:=ord(s[i])-48;if a[i]>mx then mx:=a[i];end;\n writeln(mx);\n for i:=1 to mx do\n begin\n c:=#0;\n for j:=1 to n do if a[j]=0 then write(c)else begin write(1);dec(a[j]);c:='0';end;\n write(' ');\n end;\n writeln;\nend.\n"}, {"source_code": "uses math;\nconst fi = '';\n fo = '';\nvar a: array[1..10] of longint;\n c: char;\n i, j, k, so, n, l, e: longint;\n b: array[1..10] of string;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n n:=0;\n while not eoln do\n begin\n inc(n);\n read(c);\n val(c,a[n],e);\n end;\n k:=0;\n for i:=1 to n do k:=max(k,a[i]);\n for i:=1 to n do\n begin\n for j:=1 to a[i] do b[j]:=b[j]+'1';\n for j:=a[i]+1 to k do b[j]:=b[j]+'0';\n end;\n writeln(k);\n for i:=1 to k do write(b[i],' ');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var i,n,x,br:longint; a:array[1..1000]of integer;\nfunction trazi(y:longint):longint;\nvar d,c:longint; t:boolean;\nbegin\nfor i:=y downto 1 do\nbegin\nd:=i;\nt:=true;\nwhile(d>0)do\nbegin\nc:=d mod 10;\nd:=d div 10;\nif(c<>0)and(c<>1)then begin t:=false; break; end;\nend;\nif t then begin trazi:=i; break; end;\nend;\n\nend;\nbegin\nread(n);\nwhile(n>0)do\nbegin\nx:=trazi(n);\ninc(br);\na[br]:=x;\nn:=n-x;\nend;\nwriteln(br);\nfor i:=1 to br do\nwrite(a[i],' ');\nend."}, {"source_code": "var a,b:array[1..1000000] of longint;\n\nans1,ans,i,j,k,l,m,n:longint;\ns,s1:string;\n\nfunction prov(n:longint):boolean;\nvar i,j:longint;\n s:string;\n\nbegin\nstr(n,s);\nj:=0;\nfor i:=1 to length(s) do\nif (s[i]<>'0') and (s[i]<>'1') then inc(j);\nif j=0 then prov:=true else prov:=false;\nend;\n\n\nbegin\nreadln(n);\nm:=0;\nans:=0;\nfor i:=1 to n do\nif prov(i) then begin inc(m); a[m]:=i; end;\nwhile n<>0 do\n begin\n ans1:=ans;\n ans:=ans+n div (a[m]);\n if ans<>ans1 then begin\n for i:=ans1+1 to ans do\n b[i]:=a[m];\n end;\n n:=n mod a[m];\n while (a[m]>n) and (m<>0) do\n dec(m);\n end;\nwriteln(ans);\nfor i:=1 to ans do\nwrite(b[i],' ');\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "program cfb;\nvar\n a:longint;\n b:array[1..100000] of longint;\n i,n,m,j,k,z,ma:longint;\nprocedure p(x:longint);\n var\n kk:longint;\n begin\n while (x>0) do\n begin\n inc(kk);\n x:=x div 10;\n end;\n n:=kk;\n end;\nfunction s(x:longint):longint;\nvar\n i1,j1:longint;\nbegin\n j1:=1;\n for i1:=1 to x do\n j1:=j1*10;\n s:=j1;\nend;\n begin\n read(a);\n P(a);\n z:=1;\n ma:=0;\n while a>0 do\n begin\n k:=a mod 10;\n for i:=1 to k do\n b[i]:=b[i]+z;\n z:=z*10;\n if k>ma then ma:=k;\n\n a:=a div 10;\n\n end;\n for i:=1 to ma do\n write(b[i],' ');\n end.\n\n"}, {"source_code": "var\nsums,i,n,q:longint;\nc:array[0..6]of longint;\nss,s:string;\n\nbegin\nread(N);\nif n=0 then begin writeln(0);halt;end;\nstr(n,s);\nfor i:=1 to length(s) do\nbegin\nc[i]:=ord(s[i])-48;\nsums:=sums+c[i];\nend;\nwhile sums>0 do\n begin\n ss:='';\n for i:=1 to length(s) do\n\n if c[i]>0 then\n begin\n ss:=ss+'1';\n dec(sums);\n dec(c[i]);\n end\n\n else ss:=ss+'0';\n while ss[1]='0' do delete(ss,1,1);\n write(ss,' ');\n end;\nend.\n"}, {"source_code": "Program GIO;\n\n\nvar i,n,t:longint;\na:array[1..64]of longint;\nb:array[1..10000]of longint;\nbegin\n\na[1]:=1;\na[2]:=10;\na[3]:=11;\na[4]:=100;\na[5]:=101;\na[6]:=110;\na[7]:=111;\na[8]:=1000;\na[9]:=1001;\na[10]:=1010;\na[11]:=1011;\na[12]:=1100;\na[13]:=1101;\na[14]:=1110;\na[15]:=1111;\na[16]:=10000;\na[17]:=10001;\na[18]:=10010;\na[19]:=10011;\na[20]:=10100;\na[21]:=10101;\na[22]:=10110;\na[23]:=10111;\na[24]:=11000;\na[25]:=11001;\na[26]:=11010;\na[27]:=11011;\na[28]:=11100;\na[29]:=11101;\na[30]:=11110;\na[31]:=11111;\na[32]:=100000;\na[33]:=100001;\na[34]:=100010;\na[35]:=100011;\na[36]:=100100;\na[37]:=100101;\na[38]:=100110;\na[39]:=100111;\na[40]:=101000;\na[41]:=101001;\na[42]:=101010;\na[43]:=101011;\na[44]:=101100;\na[45]:=101101;\na[46]:=101110;\na[47]:=101111;\na[48]:=110000;\na[49]:=110001;\na[50]:=110010;\na[51]:=110011;\na[52]:=110100;\na[53]:=110101;\na[54]:=110110;\na[55]:=110111;\na[56]:=111000;\na[57]:=111001;\na[58]:=111010;\na[59]:=111011;\na[60]:=111100;\na[61]:=111101;\na[62]:=111110;\na[63]:=111111;\na[64]:=1000000;\n\ni:=64;\nt:=0;\n\nreadln(n);\nwhile (n>0) do\nif (a[i]>n) then i:=i-1 else begin n:=n-a[i]; t:=t+1; b[t]:=a[i]; end;\n\nwriteln(t);\n\nfor i:=1 to t do\nwrite(b[i],' ');\n\nend.\n"}, {"source_code": "Program GIO;\n\n\nvar i,n,t:longint;\na:array[1..64]of longint;\nb:array[1..10000]of longint;\nbegin\n\na[1]:=1;\na[2]:=10;\na[3]:=11;\na[4]:=100;\na[5]:=101;\na[6]:=110;\na[7]:=111;\na[8]:=1000;\na[9]:=1001;\na[10]:=1010;\na[11]:=1011;\na[12]:=1100;\na[13]:=1101;\na[14]:=1110;\na[15]:=1111;\na[16]:=10000;\na[17]:=10001;\na[18]:=10010;\na[19]:=10011;\na[20]:=10100;\na[21]:=10101;\na[22]:=10110;\na[23]:=10111;\na[24]:=11000;\na[25]:=11001;\na[26]:=11010;\na[27]:=11011;\na[28]:=11100;\na[29]:=11101;\na[30]:=11110;\na[31]:=11111;\na[32]:=100000;\na[33]:=100001;\na[34]:=100010;\na[35]:=100011;\na[36]:=100100;\na[37]:=100101;\na[38]:=100110;\na[39]:=100111;\na[40]:=101000;\na[41]:=101001;\na[42]:=101010;\na[43]:=101011;\na[44]:=101100;\na[45]:=101101;\na[46]:=101110;\na[47]:=101111;\na[48]:=110000;\na[49]:=110001;\na[50]:=110010;\na[51]:=110011;\na[52]:=110100;\na[53]:=110101;\na[54]:=110110;\na[55]:=110111;\na[56]:=111000;\na[57]:=111001;\na[58]:=111010;\na[59]:=111011;\na[60]:=111100;\na[61]:=111101;\na[62]:=111110;\na[63]:=111111;\na[64]:=1000000;\n\ni:=64;\nt:=0;\n\nreadln(n);\nwhile (n>0) do\nif (a[i]>n) then i:=i-1 else begin n:=n-a[i]; t:=t+1; b[t]:=a[i]; end;\n\nfor i:=1 to t do\nwrite(b[i],' ');\n\nend.\n"}, {"source_code": "Program GIO;\n\n\nvar i,n:longint;\na:array[1..64]of longint;\nbegin\n\na[1]:=1;\na[2]:=10;\na[3]:=11;\na[4]:=100;\na[5]:=101;\na[6]:=110;\na[7]:=111;\na[8]:=1000;\na[9]:=1001;\na[10]:=1010;\na[11]:=1011;\na[12]:=1100;\na[13]:=1101;\na[14]:=1110;\na[15]:=1111;\na[16]:=10000;\na[17]:=10001;\na[18]:=10010;\na[19]:=10011;\na[20]:=10100;\na[21]:=10101;\na[22]:=10110;\na[23]:=10111;\na[24]:=11000;\na[25]:=11001;\na[26]:=11010;\na[27]:=11011;\na[28]:=11100;\na[29]:=11101;\na[30]:=11110;\na[31]:=11111;\na[32]:=100000;\na[33]:=100001;\na[34]:=100010;\na[35]:=100011;\na[36]:=100100;\na[37]:=100101;\na[38]:=100110;\na[39]:=100111;\na[40]:=101000;\na[41]:=101001;\na[42]:=101010;\na[43]:=101011;\na[44]:=101100;\na[45]:=101101;\na[46]:=101110;\na[47]:=101111;\na[48]:=110000;\na[49]:=110001;\na[50]:=110010;\na[51]:=110011;\na[52]:=110100;\na[53]:=110101;\na[54]:=110110;\na[55]:=110111;\na[56]:=111000;\na[57]:=111001;\na[58]:=111010;\na[59]:=111011;\na[60]:=111100;\na[61]:=111101;\na[62]:=111110;\na[63]:=111111;\na[64]:=1000000;\n\ni:=64;\nreadln(n);\nwhile (n>0) do\nif (a[i]>n) then i:=i-1 else begin n:=n-a[i]; write(a[i],' ') end;\n\nend.\n"}, {"source_code": "type m=array[1..64] of longint;\nvar n,i:longint;\n k:byte;\n b:array[1..100000] of longint;\nconst a:m=(1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110,1111,10000,10001,10010,10011,10100,10101,10110,10111,11000,11001,11010,11011,11100,11101,11110,11111,100000,100001,100010,100011,100100,100101,100110,100111,101000,101001,101010,101011,101100,101101,101110,101111,110000,110001,110010,110011,110100,110101,110110,110111,111000,111001,111010,111011,111100,111101,111110,111111,1000000);\nbegin\nread(n); k:=0;\nwhile n>0 do\nbegin\nfor i:=1 to 64 do\nif a[i+1]>n then begin\n inc(k);\n n:=n-a[i];\n b[k]:=a[i];\n break;\n end;\nend;\nwriteln(k);\nfor i:=1 to k do\nwrite(b[i],' ');\nend.\n\n "}, {"source_code": "program CF300B;\nvar a,b,c,d,i,n,j,k:longint; Z:array[1..100000] of longint;\ns,s1:string;\nbegin\n{assign(input,'d:\\FPC\\input.txt');\nreset(input);\nassign(output,'d:\\FPC\\output.txt');\nrewrite(output);}\nread(s);\na:=length(s);\nwhile a>1 do\nbegin\nfor i:=1 to a do\n if ord(s[i])>48 then\n begin\n s[i]:=chr(ord(s[i])-1);\n s1:=s1+'1';\n end\n else s1:=s1+'0';\ns1:=s1+' ';\nif s[1]='0' then\nbegin\nfor i:=2 to a do\ns[i-1]:=s[i];\na:=a-1;\nend;\nif a=1 then break;\nend;\nfor i:=1 to length(s1) do\nif s1[i]=' ' then k:=k+1;\nk:=k+ord(s[1])-48;\nwriteln(k);\nwrite(s1);\nfor i:=1 to ord(s[1])-48 do\nwrite(1,' ');\nend.\n"}, {"source_code": "var\nb:array[1..100] of integer;\ni,c,n,a,t:integer;\nbegin\nc:=1;\nreadln(n);\nwhile(n>0)do\nbegin\na:=n mod 10;\nfor i:=1 to a do\nb[i]:=b[i]+c;\nif(a>t)then t:=a;\nc:=c*10;\nn:=n div 10;\na:=0;\nend;\nfor i:=t downto 1 do\nwrite(b[i]);\nreadln;\nend.\n"}, {"source_code": "type\n arr =array[1..6] of longint;\n\nvar\n N :longint;\n res :array[0..1000000] of longint;\n sl :array[0..1000000] of longint;\n dem :longint;\n x :arr;\n x1 :arr;\n\nprocedure tach(var x:arr);\nvar mi,ma,i:longint;xx:longint;mul:longint;\nBegin\n mi:=10;\n ma:=-1;\n mul:=1;\n xx:=0;\n for i:=N downto 1 do\n Begin\n if x[i]>ma then ma:=x[i];\n if (x[i]0) then mi:=x[i];\n end;\n if ma=1 then\n begin\n for i:=1 to N do\n begin\n xx:=xx+x[i]*mul;\n mul:=mul*10;\n x[i]:=0;\n end;\n end;\n inc(dem);\n sl[dem]:=mi;\n for i:=n downto 1 do\n if x[i]>0 then\n Begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else\n Begin\n xx:=xx+mul;\n mul:=mul*10;\n end;\n res[dem]:=xx;\n for i:=1 to n do\n if x[i]>0 then\n x[i]:=x[i]-mi;\nend;\n\nfunction check:boolean;\nvar i:longint;\nBegin\n for i:=1 to N do\n if x[i]>1 then exit(false);\n exit(true);\nend;\n\nprocedure xuli;\nvar i,j,xx,mul:longint;ok:boolean;\nBegin\n readln(xx);\n N:=0;\n while xx>0 do\n Begin\n inc(N);\n x[N]:=xx mod 10;\n xx:=xx div 10;\n end;\n dem:=0;\n fillchar(sl,sizeof(sl),0);\n while check=false do tach(x);\n ok:=false;\n for i:=n downto 1 do\n if x[i]>0 then\n begin\n N:=i;\n break;\n end;\n mul:=1;\n xx:=0;\n for i:=1 to N do\n if x[i]>0 then\n begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else mul:=mul*10;\n if xx>0 then\n begin\n inc(dem);\n sl[dem]:=1;\n res[dem]:=xx;\n end;\n xx:=0;\n for i:=1 to dem do\n xx:=xx+sl[i];\n writeln(xx);\n for i:=1 to dem do\n for j:=1 to sl[i] do\n write(res[i],' ');\nend;\n\nBEGIN\n xuli;\nEND.\n"}, {"source_code": "type\n arr =array[1..6] of longint;\n\nvar\n N :longint;\n res :array[0..1000000] of longint;\n sl :array[0..1000000] of longint;\n dem :longint;\n x :arr;\n x1 :arr;\n\nprocedure tach(var x:arr);\nvar mi,ma,i:longint;xx:longint;mul:longint;\nBegin\n mi:=10;\n ma:=-1;\n mul:=1;\n xx:=0;\n for i:=N downto 1 do\n Begin\n if x[i]>ma then ma:=x[i];\n if (x[i]0) then mi:=x[i];\n end;\n if ma=1 then\n begin\n for i:=1 to N do\n begin\n xx:=xx+x[i]*mul;\n mul:=mul*10;\n x[i]:=0;\n end;\n end;\n inc(dem);\n sl[dem]:=mi;\n for i:=n downto 1 do\n if x[i]>0 then\n Begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else\n mul:=mul*10;\n res[dem]:=xx;\n for i:=1 to n do\n if x[i]>0 then\n x[i]:=x[i]-mi;\nend;\n\nfunction check:boolean;\nvar i:longint;\nBegin\n for i:=1 to N do\n if x[i]>1 then exit(false);\n exit(true);\nend;\n\nprocedure xuli;\nvar i,j,xx,mul:longint;ok:boolean;\nBegin\n readln(xx);\n N:=0;\n while xx>0 do\n Begin\n inc(N);\n x[N]:=xx mod 10;\n xx:=xx div 10;\n end;\n dem:=0;\n fillchar(sl,sizeof(sl),0);\n while check=false do tach(x);\n ok:=false;\n for i:=n downto 1 do\n if x[i]>0 then\n begin\n N:=i;\n break;\n end;\n mul:=1;\n xx:=0;\n for i:=1 to N do\n if x[i]>0 then\n begin\n xx:=xx+mul;\n mul:=mul*10;\n end\n else mul:=mul*10;\n if xx>0 then\n begin\n inc(dem);\n sl[dem]:=1;\n res[dem]:=xx;\n end;\n xx:=0;\n for i:=1 to dem do\n xx:=xx+sl[i];\n writeln(xx);\n for i:=1 to dem do\n for j:=1 to sl[i] do\n write(res[i],' ');\nend;\n\nBEGIN\n xuli;\nEND.\n"}, {"source_code": "const fi='';\n fo='';\n\nvar n:longint;\n f:text;\n res:longint;\n l:longint;\n x:array[0..1000000]of longint;\n nt:longint;\n t:array[0..65]of longint;\nprocedure nhap;\nvar c:char;\nbegin\n assign(f,fi); reset(f);\n readln(f,n);\n close(f);\nend;\n\nfunction kt(i:longint):boolean;\nbegin\n while i<>0 do\n if i mod 10>1 then exit(false)\n else i:=i div 10;\n exit(true);\nend;\n\nprocedure init;\nvar i,j:longint;\nbegin\n nt:=0;\n for i:=1 to n do\n if kt(i) then\n begin\n inc(nt);\n t[nt]:=i;\n end;\nend;\n\nprocedure xuly;\nvar i,j,k:longint;\nbegin\n res:=0;\n while n>0 do\n begin\n for j:=nt downto 1 do\n if t[j]<=n then\n begin\n inc(res);\n x[res]:=t[j];\n nt:=j;\n dec(n,t[j]);\n break;\n end;\n end;\nend;\n\nprocedure inkq;\nvar i:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,res);\n for i:=1 to res do write(f,x[i],' ');\n close(f);\nend;\n\nBEGIN\n nhap;\n init;\n xuly;\n inkq;\nEND.\n"}, {"source_code": "var\n a, b, c, i, max, j, t: int64;\n ar: array [1..1000] of int64;\n \nbegin\n readln(a);\n j := 1;\n max := 0;\n while a > 0 do begin\n if (a mod 10 > max) then max := a mod 10; \n ar[j] := a mod 10;\n inc(j);\n a := a div 10;\n end;\n writeln(max);\n i := 1;\n while i <= max do begin\n t := j - 1;\n while t > 0 do begin\n if (ar[t] > 0) then begin\n write(1);\n dec(ar[t]);\n end\n else write(0);\n dec(t);\n end;\n write(' ');\n inc(i);\n end;\nend."}, {"source_code": "uses math;\nvar\n a,s,d,f,g,h:integer;\n z:shortstring;\n x:array [0..100000] of smallint;\nbegin\n readln(z);\n for s:=1 to length(z) do\n begin\n x[s]:=ord(z[s])-ord('0');\n a:=max(a,x[s]);\n end;\n for s:=1 to a do\n begin\n for d:=1 to length(z) do\n if (x[d]<>0) then begin dec(x[d]); h:=h*10+1 end else h:=h*10;\n write(h,' ');\n h:=0;\n end;\nend.\n\n"}, {"source_code": "var\nb:array[1..100] of integer;\ni,c,n,s,a,t:integer;\nbegin\nc:=1;\nreadln(n);\ns:=n;\nwhile(n>0)do\nbegin\na:=n mod 10;\nfor i:=1 to a do\nb[i]:=b[i]+c;\nif(a>t)then t:=a;\nc:=c*10;\nn:=n div 10;\na:=0;\nend;\nwriteln(s);\nfor i:=t downto 1 do\nbegin\nwrite(b[i]);\nwrite(' ');\nend;\nreadln;\nend.\n"}, {"source_code": "var\nb:array[1..100] of integer;\ni,c,n,a,t:integer;\nbegin\nc:=1;\nreadln(n);\nwhile(n>0)do\nbegin\na:=n mod 10;\nfor i:=1 to a do\nb[i]:=b[i]+c;\nif(a>t)then t:=a;\nc:=c*10;\nn:=n div 10;\na:=0;\nend;\nfor i:=t downto 1 do\nbegin\nwrite(b[i]);\nwrite(' ');\nend;\nreadln;\nend.\n"}, {"source_code": "var\nl,i,j:longint;\na:string;\nmax:char;\ns:array[1..10000] of integer;\nbegin\nreadln(a);\nfor i:=1 to length(a) do if(a[i]>max) then max:=a[i];\nwriteln(max);\nfor i:=length(a) downto 1 do\nbegin\nfor j:=1 to ord(a[i])-48 do s[j]:=s[j]+l;\nl:=l*10;\nend;\nfor i:=1 to ord(max)-48 do write(s[i],' ');\nend."}, {"source_code": "const fi='';\n fo='';\nvar n,i,max,tmp,mu,m:longint;\n a:array[1..9,1..1] of int64;\n\nBEGIN\n assign(input,fi);reset(input);\n read(n);\n close(input);\n\n assign(output,fo);rewrite(output);\n m:=n;\n while m<>0 do begin\n if m mod 10>max then max:=m mod 10;\n m:=m div 10;\n end;\n writeln(max);\n if n<10 then for i:=1 to max do write(1,#32);\n m:=n;mu:=1;\n while (m<>0) and (n>10) do begin\n tmp:=m mod 10;\n for i:=1 to tmp do a[i][1]:=a[i][1]+mu*1;\n mu:=mu*10;\n m:=m div 10;\n end;\n if n>10 then for i:=1 to max do write(a[i][1],' ');\n close(output);\nEND.\n"}, {"source_code": "var\na:string;\nmax,i,j:longint;\nbegin\nreadln(a);\nfor i:=1 to length(a) do if(ord(a[i])>max) then max:=ord(a[i]);\nwriteln(max-ord('0'));\nfor i:=1 to (max-ord('0')) do\nbegin\nfor j:=1 to length(a) do\nbegin\nif(a[j]<>'0') then begin write('1'); ord(a[j]):=ord(a[j])-1; end\nelse\nwrite('0')\nend;\nif(i=max-ord('0')) then writeln else write(' ');\nend;\nend."}, {"source_code": "var\na:string;\nmax,i,j:longint;\nbegin\nreadln(a);\nfor i:=1 to length(a) do if(ord(a[i])>max) then max:=ord(a[i]);\nwriteln(max-ord('0'));\nfor i:=1 to (max-ord('0')) do\nbegin\nfor j:=1 to length(a) do\nbegin\nif(a[j]<>'0') then begin write('1'); ord(a[j]):=ord(a[j])-1; end\nelse\nif(a[j]='0') then\nif(j<>1) then write('0')\nelse\ndelete(a,j,1);\nend;\nif(i=max-ord('0')) then writeln else write(' ');\nend;\nend."}, {"source_code": "var\n l,c,stn,i,j,n,m,k,kol,res:longint;\n ans,d,b,st,a:array[0..200000] of longint;\n s:string;\n f:integer;\n\nprocedure rec(q,k:longint);\nvar\n i:longint;\nbegin\n st[k]:=a[q];\n if k=j then\n begin\n for i:=1 to k do s:=s+chr(st[i]+48);\n val(s,c,f);\n inc(stn);\n b[stn]:=c;\n s:='';\n exit;\n end;\n for i:=1 to 2 do rec(i,k+1);\nend;\n\nprocedure qsort(l,r:longint);\nvar\n i,j,t,m:longint;\nbegin\n i:=l;\n j:=r;\n m:=b[l+random(r-l+1)];\n repeat\n while b[i]m do dec(j);\n if i>j then break;\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n inc(i);\n dec(j);\n until i>j;\n if lb[i+1] then\n begin\n inc(kol);\n d[kol]:=b[i];\n end;\n l:=kol;\n stn:=0;\n while true do\n begin\n if n=0 then break;\n if n-d[l]>=0 then\n begin\n dec(n,d[l]);\n inc(stn);\n ans[stn]:=d[l];\n end else dec(l);\n end;\n writeln(stn);\n for i:=1 to stn do write(ans[i],' ');\nend.\n"}, {"source_code": "var\n x,ti,l,c,stn,i,j,n,m,k,kol,res:longint;\n f,p,t,ans,d,b,st,a:array[0..2000000] of longint;\n s:string;\n fi:integer;\n\nfunction min(a,b:longint):longint;\nbegin\n if am do dec(j);\n if i>j then break;\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n inc(i);\n dec(j);\n until i>j;\n if lb[i+1] then\n begin\n inc(kol);\n d[kol]:=b[i];\n end;\n f[0]:=0;\n for i:=1 to n do f[i]:=maxlongint div 2;\n t[0]:=1;\n for i:=0 to n do\n begin\n for j:=1 to kol do if t[i]>0 then if i+d[j]<=1000000 then\n begin\n t[i+d[j]]:=1;\n if f[i+d[j]]>f[i]+1 then\n begin\n f[i+d[j]]:=min(f[i+d[j]],f[i]+1);\n p[i+d[j]]:=i;\n end;\n end;\n end;\n x:=n;\n while x>0 do\n begin\n inc(ti);\n ans[ti]:=x;\n x:=p[x];\n end;\n writeln(ti);\n for i:=1 to ti do write(ans[i]-ans[i+1],' ');\nend.\n"}, {"source_code": "const\n mo=1000000007;\nvar\n a:array[1..11111] of longint;\n n,m,k,x,q,w,e,sum,l,r,xx,yy:int64;i,z,j:longint;\n s,cf:string;\nfunction min(x,y:int64):int64;\nbegin if xy then max:=x else max:=y;end;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=1 to n do if ord(s[i])-48>m then m:=ord(s[i])-48;\n writeln(m);\n for i:=1 to m do\n begin\n for j:=1 to n do\n begin if a[j]>0 then begin write('1');dec(a[j]);end else write('0');end;\n write(' ');\n end;\nend.\n\n"}, {"source_code": "var n,m,i,j,k,ans,l,r:longint;\n a,b:array[1..10000]of longint;\nprocedure rec(s:string);\nvar i,l,tt:longint;\n begin\n val(s,tt);\n if (tt>n) then exit;\n inc(m);\n a[m]:=tt;\n if s[length(s)]='0' then begin s[length(s)]:='1'; rec(s); end else\n if pos('0',s)=0 then\n begin\n l:=length(s);\n s:='1';\n for i:=1 to l do\n s:=s+'0';\n rec(s);\n end else\n begin\n l:=0;\n for i:=length(s) downto 1 do\n if s[i]='0' then begin l:=i; break; end;\n s[l]:='1';\n for i:=l+1 to length(s) do\n s[i]:='0';\n rec(s);\n end;\n end;\nfunction get(l:longint):longint;\nvar r:longint;\n begin\n r:=0;\n while l mod 10=0 do\n begin\n inc(r);\n l:=l div 10;\n end;\n exit(r);\n end;\n begin\n read(n);\n rec('1');\n for i:=m downto 1 do\n begin\n while a[i]<=n do\n if (get(a[i])<>get(n)) then break else\n begin\n inc(r);\n b[r]:=a[i];\n n:=n-a[i];\n end;\n end;\n writeln(r);\n for i:=1 to r do\n write(b[i],' ');\n writeln;\n end."}, {"source_code": "var\n ff:array[1..1000]of longint;\n f:array[1..100,1..100]of longint;\n s,t:ansistring;\n k,h,i,j,n:longint;\nbegin\n readln(n);\n str(n,s);\n for i:=1 to length(s) do\n begin\n for j:=1 to ord(s[i])-48 do\n begin\n inc(f[i,j]);\n ff[j]:=1;\n end;\n end;\n for i:=9 downto 1 do if ff[i]=1 then\n begin\n n:=i;\n break;\n end;\n writeln(n);\n for i:=1 to n do\n begin\n t:='';\n for j:=length(s)downto 1 do\n begin\n if f[j,i]=0 then continue;\n t:=t+chr(f[j,i]+48);\n end;\n write(t,' ');\n\n end;\nend.\n"}, {"source_code": "var f1:text;nn,n,h,res,i,s:longint;\na:array[1..10000]of longint;\nbegin\n assign(f1,'');reset(f1);\n readln(f1,n);\n res:=0;\n while n<>0 do\n begin\n nn:=n;h:=0;\n while nn<>0 do\n begin inc(h);nn:=nn div 10;end;\n if h=1 then begin writeln(res+n);\n for i:=1 to res do write(a[i],' ');for i:=1 to n do write(1,' ');halt;end\n else begin\n s:=0;\n for i:=1 to h-1 do s:=s*10+1;\n if n mod 10=0 then s:=s*10 else s:=s*10+1;\n if n0 do\n begin\n for i:=8*8*2-1 downto 1 do\n if a[i]<=x then begin\n dec(x,a[i]);\n inc(res);\n b[res]:=a[i];\n break;\n end;\n end;\n writeln(res);\n for i:=1 to res do\n write(b[i],' ');\nend.\n"}, {"source_code": " type niz=array[-1..1000000] of longint;\nprocedure sort(var a:niz;n:longint);\n var i,h,s,f,l:longint;\nbegin\n\n for i:=2 to n do\n begin\n h:=a[i]; s:=i;f:=s div 2;\n while ((s>1) and (a[f]=3) and (a[3]>a[2]))\n then s:=3 else s:=2;\n while (s<=i-1) and (a[s]>l) do\n begin\n a[f]:=a[s]; f:=s; s:=2*f;\n if ((s+1<=i-1) and (a[s+1]>a[s]))\n then s:=s+1;\n end;\n a[f]:=l;\n end;\nend;\nvar\n s:ansistring; i,j,x,res:longint;\n a,b:niz;\n begin\n read(x);\n for i:=1 to 8*8*2-1 do\n begin\n s:=binstr(i,7);\n for j:=1 to 7 do\n if s[j]='0' then a[i]:=a[i]*10 else a[i]:=a[i]*10+1;\n end;\n\n sort (a,8*8*2-1);\n\n While x>0 do\n begin\n for i:=8*8*2-1 downto 1 do\n if a[i]<=x then begin\n dec(x,a[i]);\n inc(res);\n b[res]:=a[i];\n break;\n end;\n end;\n writeln(res);\n for i:=1 to res do\n write(b[i],' ');\nend.\n"}, {"source_code": "var s:ansistring; i,j,res,x:longint;\n a,b:array[0..1000000] of longint;\n begin\n read(x);\n for i:=1 to 8*8 do\n begin\n s:=binstr(i,7);\n for j:=1 to 6 do\n if s[j]='0' then a[i]:=a[i]*10 else a[i]:=a[i]*10+1;\n end;\n\n\n\n While x>0 do\n begin\n for i:=8*8-1 downto 1 do\n if a[i]<=x then begin\n dec(x,a[i]);\n inc(res);\n b[res]:=a[i];\n break;\n end;\n end;\n writeln(res);\n for i:=1 to res do\n write(b[i],' ');\nend.\n"}, {"source_code": " type niz=array[-1..1000000] of longint;\nprocedure sort(var a:niz;n:longint);\n var i,h,s,f,l:longint;\nbegin\n\n for i:=2 to n do\n begin\n h:=a[i]; s:=i;f:=s div 2;\n while ((s>1) and (a[f]=3) and (a[3]>a[2]))\n then s:=3 else s:=2;\n while (s<=i-1) and (a[s]>l) do\n begin\n a[f]:=a[s]; f:=s; s:=2*f;\n if ((s+1<=i-1) and (a[s+1]>a[s]))\n then s:=s+1;\n end;\n a[f]:=l;\n end;\nend;\nvar\n s:ansistring; i,j,x,res,q:longint;\n a,b:niz;\n begin\n read(x);\n for i:=1 to 8*8*2-1 do\n begin\n s:=binstr(i,7);\n for j:=1 to 7 do\n if s[j]='0' then a[i]:=a[i]*10 else a[i]:=a[i]*10+1;\n end;\n\n sort (a,8*8*2-1);\n\n While x>0 do\n begin\n for i:=8*8*2-1 downto 1 do\n if (a[i]<=x ) and (q=0) then begin\n dec(x,a[i]);\n q:=1;\n inc(res);\n b[res]:=a[i];\n\n end;\n q:=0;\n\n end;\n writeln(res);\n for i:=1 to res do\n write(b[i],' ');\nend.\n"}, {"source_code": "var\n l, k: integer;\n n: longint;\n min, max, pos0: byte;\n found0: boolean;\n\nfunction len(a: longint): integer;\nvar\n k: integer;\nbegin\n min := 10;\n max := 0;\n found0 := false;\n k := 0;\n while a > 0 do\n begin\n if a mod 10 = 0 then\n begin\n found0 := true;\n pos0 := k + 1;\n end\n else if (a mod 10 < min) then\n min := a mod 10;\n if (a mod 10 > max) then\n max := a mod 10;\n a := a div 10;\n inc(k);\n end;\n len := k;\nend;\n\nfunction pow10(a: byte): longint;\nvar\n k: longint;\n i: byte;\nbegin\n k := 1;\n for i := a downto 1 do\n k := k * 10;\n pow10 := k;\nend;\n\nfunction get11(a: byte): longint;\nvar\n k: longint;\n i: byte;\nbegin\n k := 0;\n for i := a downto 1 do\n begin\n k := k * 10;\n if not (found0 and (i = pos0)) then\n inc(k);\n end;\n get11 := k;\nend;\n\nbegin\n readln(N);\n \n l := len(n);\n writeln(max);\n k := get11(l);\n while n >= k do\n begin\n n := n - k;\n write(k, ' ');\n end;\n \n while n > 0 do\n begin\n l := len(n);\n k := get11(l);\n while n >= k do\n begin\n n := n - k;\n write(k, ' ');\n end;\n end;\nend."}, {"source_code": "var\n s, key: string;\n rd: boolean;\n l, k, l2: integer;\n c: char;\n n, n2, t: longint;\n\nbegin\n readln(N);\n \n while n <> 0 do\n begin\n n2 := n;\n \n l := 0;\n while n2 > 0 do\n begin\n inc(l);\n n2 := n2 div 10;\n end;\n \n l2 := l;\n k := 0;\n while l2 <> 0 do\n begin\n t := round(exp(ln(10) * (l2 - 1)));\n k := k + t;\n if k > n then\n k := k - t;\n dec(l2);\n end;\n \n while n >= k do\n begin\n n := n - k;\n write(k, ' ');\n end;\n end;\nend."}, {"source_code": "var\n s, key: string;\n rd: boolean;\n l, k, l2,num: integer;\n c: char;\n n, n2, t: longint;\n a: array[1..10000] of longint;\n\nbegin\n readln(N);\n num := 0;\n while n <> 0 do\n begin\n n2 := n;\n \n l := 0;\n while n2 > 0 do\n begin\n inc(l);\n n2 := n2 div 10;\n end;\n \n l2 := l;\n k := 0;\n while l2 <> 0 do\n begin\n t := round(exp(ln(10) * (l2 - 1)));\n k := k + t;\n if k > n then\n k := k - t;\n dec(l2);\n end;\n \n while n >= k do\n begin\n n := n - k;\n inc(num);\n a[num] := k;\n end;\n end;\n \n writeln(num);\n for n := num downto 1 do\n write(a[n], ' ');\nend."}, {"source_code": "var\n l, k: integer;\n n: longint;\n min, max, pos0: byte;\n found0: boolean;\n\nfunction len(a: longint): integer;\nvar\n k: integer;\nbegin\n min := 10;\n max := 0;\n found0 := false;\n k := 0;\n while a > 0 do\n begin\n if a mod 10 = 0 then\n begin\n found0 := true;\n pos0 := k + 1;\n end\n else if (a mod 10 < min) then\n min := a mod 10;\n if (a mod 10 > max) then\n max := a mod 10;\n a := a div 10;\n inc(k);\n end;\n len := k;\nend;\n\nfunction pow10(a: byte): longint;\nvar\n k: longint;\n i: byte;\nbegin\n k := 1;\n for i := a downto 1 do\n k := k * 10;\n pow10 := k;\nend;\n\nfunction get11(a: byte): longint;\nvar\n k,n2: longint;\n i,j: byte;\nbegin\n k := 0;\n for i := a downto 1 do\n begin\n n2 := n;\n k := k * 10;\n for j := 1 to i-1 do\n n2 := n2 div 10;\n if n2 mod 10 <> 0 then\n inc(k);\n end;\n get11 := k;\nend;\n\nbegin\n readln(N);\n \n l := len(n);\n writeln(max);\n k := get11(l);\n while n >= k do\n begin\n n := n - k;\n write(k, ' ');\n end;\n \n while n > 0 do\n begin\n l := len(n);\n k := get11(l);\n while n >= k do\n begin\n n := n - k;\n write(k, ' ');\n end;\n end;\nend."}, {"source_code": "var\n s, key: string;\n rd: boolean;\n l, k, l2,num: integer;\n c: char;\n n, n2, t: longint;\n a: array[1..1000] of longint;\n\nbegin\n readln(N);\n num := 0;\n while n <> 0 do\n begin\n n2 := n;\n \n l := 0;\n while n2 > 0 do\n begin\n inc(l);\n n2 := n2 div 10;\n end;\n \n l2 := l;\n k := 0;\n while l2 <> 0 do\n begin\n t := round(exp(ln(10) * (l2 - 1)));\n k := k + t;\n if k > n then\n k := k - t;\n dec(l2);\n end;\n \n while n >= k do\n begin\n n := n - k;\n inc(num);\n a[num] := k;\n end;\n end;\n \n writeln(num);\n for n := 1 to num do\n write(a[n], ' ');\nend."}, {"source_code": "uses math,sysutils;\nvar i,p,l,k,j,m,n,imain,t,x1,x2,y1,y2,jmain,u,y,len,l1,l2,r1,r2:longint;\n a,b:array[0..10000]of int64;\n s:string;\n\nfunction trying(n:longint):boolean;\nvar i,j:longint;\nbegin\n for i:=1 to length(inttostr(n)) do\n if (inttostr(n)[i]<>'0')and\n (inttostr(n)[i]<>'1') then\n exit(false);\n exit(true);\nend;\n\nbegin\n read(n);\n m:=n;\n while m<>0 do\n begin\n j:=m;\n while true do\n begin\n if trying(j) then\n begin\n inc(i);\n a[i]:=j;\n m:=m-j; break;\n end;\n dec(j);\n end;\n end;\n writeln(i);\n for j:=1 to i do\n write(a[j],' ');\nend.\n"}, {"source_code": "const\n oo=10000000;\nvar\n tr,t,a:array[0..1000000] of longint;\n j,i,n,d:longint;\nfunction min(a,b:longint):longint;\n begin\n if a>b then exit(b) else exit(a);\n end;\nprocedure addso(x:longint);\n var tg:longint;\n begin\n tg:=x;\n repeat\n if x mod 10>1 then exit;\n x:=x div 10;\n until x=0;\n inc(d);\n a[d]:=tg;\n end;\nbegin\n readln(n);\n for i:=1 to n do addso(i);\n for i:=1 to n do\n begin\n t[i]:=oo;\n for j:=1 to d do\n if i>=a[j] then\n begin\n t[i]:=min(t[i],t[i-a[j]]+1);\n tr[i]:=j;\n end\n else break;\n end;\n writeln(t[n]);\n repeat\n write(a[tr[n]],' ');\n n:=n-a[tr[n]];\n until n=0;\n readln;\nend.\n"}, {"source_code": "const\n oo=10000000;\nvar\n tr,t,a:array[0..1000000] of longint;\n j,i,n,d:longint;\nfunction min(a,b:longint):longint;\n begin\n if a>b then exit(b) else exit(a);\n end;\nprocedure addso(x:longint);\n var tg:longint;\n begin\n tg:=x;\n repeat\n if x mod 10>1 then exit;\n x:=x div 10;\n until x=0;\n inc(d);\n a[d]:=tg;\n end;\nbegin\n readln(n);\n for i:=1 to n do addso(i);\n for i:=1 to n do\n begin\n t[i]:=oo;\n for j:=1 to d do\n if i>=a[j] then\n begin\n if t[i]>t[i-a[j]]+1 then\n begin\n t[i]:=t[i-a[j]]+1;\n tr[i]:=j;\n end;\n end\n else break;\n end;\n writeln(t[n]);\n writeln(tr[n]);\n repeat\n write(a[tr[n]],' ');\n n:=n-a[tr[n]];\n until n=0;\n readln;\nend.\n"}, {"source_code": "VAR mang:array[1..128] of longint=(0,1,10,11,\n 100,101,110,111,\n 1000,1001,1010,1011,1100,1101,1110,1111,\n 10000,10001,10010,10011,10100,10101,10110,10111,11000,11001,11010,11011,11100,11101,11110,11111,\n 100000,100001,100010,100011,100100,100101,100110,100111,101000,101001,101010,101011,101100,101101,101110,101111,110000,110001,110010,110011,110100,110101,110110,110111,111000,111001,111010,111011,111100,111101,111110,111111,\n 1000000,1000001,1000010,1000011,1000100,1000101,1000110,1000111,1001000,1001001,1001010,1001011,1001100,1001101,1001110,1001111,1010000,1010001,1010010,1010011,1010100,1010101,1010110,1010111,1011000,1011001,1011010,1011011,1011100,1011101,1011110,\n 1011111,1100000,1100001,1100010,1100011,1100100,1100101,1100110,1100111,1101000,1101001,1101010,1101011,1101100,1101101,1101110,1101111,1110000,1110001,1110010,1110011,1110100,1110101,1110110,1110111,1111000,1111001,1111010,1111011,1111100,1111101,\n 1111110,1111111);\n a:array[1..1000000] of longint;\n n,d,i:longint;\n\nPROCEDURE TINH(n:longint);\nVAR i:longint;\nBEGIN\n FOR i:=1 TO 128 DO IF n0 THEN TINH(n-mang[i-1]);\nEND;\n\nBEGIN\n READLN(n);d:=0;\n TINH(n);\n WRITELN(d);\n FOr i:=1 TO d DO WRITE(a[i],' ');\n READLN;\nEND."}, {"source_code": "var\n st:array[1..100000] of longint;\n n,i,w,x:longint;\n f:boolean;\nbegin\n readln(n);\n for i:=111111 downto 1 do\n begin\n x:=i;\n f:=false;\n repeat\n if (x mod 10=0)or(x mod 10=1) then else\n begin\n f:=true;\n break;\n end;\n x:=x div 10;\n until x=0;\n\n if (not f)and(n>=i) then\n begin\n while 81=81 do\n begin\n if n-i>=0 then dec(n,i) else break;\n inc(w);\n st[w]:=i;\n end;\n end;\n end;\n writeln(w);\n for i:=1 to w do write(st[i],' ');\n\nend.\n"}, {"source_code": "uses math;\nvar\n st,a:array[0..100000] of longint;\n n,i,w,x,kol,ma,mn,j,k,m:longint;\n f:boolean;\nbegin\n readln(n);\n m:=n;\n ma:=1;\n while n-10>=0 do\n begin\n inc(w);\n st[w]:=10;\n dec(n,10);\n inc(a[10]);\n ma:=10;\n end;\n for i:=1 to n do begin inc(w); st[w]:=1;inc(a[1]);end;\n while 81=81 do\n begin\n k:=0;\n for i:=ma downto 1 do\n for j:=ma downto 1 do if (a[i]<>0)and(a[j]<>0) then\n begin\n if (i=j)and(a[i]>=10)and(i*10<=m) then x:=i*10 else x:=i+j;\n f:=false;\n repeat\n if (x mod 10<>0)and(x mod 10 <>1) then\n begin\n f:=true;\n break;\n end;\n x:=x div 10;\n until x=0;\n\n if f then break else\n begin\n if (i=j)and(a[i]>=10)and(i*10<=m) then\n begin\n if i*10>ma then ma:=i*10;\n inc(a[i*10],a[i] div 10);\n dec(a[i],10*(a[i] div 10));\n k:=1;\n end else\n begin\n mn:=min(a[i],a[j]);\n if i+j>ma then ma:=i+j;\n inc(a[i+j],mn);\n dec(a[i],mn);\n dec(a[j],mn);\n k:=1;\n end;\n end;\n end;\n if k=0 then break;\n end;\n for i:=1 to ma do if a[i]<>0 then inc(kol,a[i]);\n writeln(kol);\n for i:=1 to ma do if a[i]<>0 then\n for j:=1 to a[i] do write(i,' ');\nend.\n"}, {"source_code": "uses math;\nvar\n st,a:array[0..100000] of longint;\n n,i,w,x,kol,ma,mn,j,k,m,kk:longint;\n f:boolean;\nbegin\n readln(n);\n m:=n;\n ma:=1;\n while n-10>=0 do\n begin\n inc(w);\n st[w]:=10;\n dec(n,10);\n inc(a[10]);\n ma:=10;\n end;\n for i:=1 to n do begin inc(w); st[w]:=1;inc(a[1]);end;\n while 81=81 do\n begin\n k:=0;\n for i:=ma downto 1 do\n for j:=ma downto 1 do if (a[i]<>0)and(a[j]<>0) then\n begin\n if (i=j)and(a[i]>=10)and(i*10<=m) then x:=i*10 else x:=i+j;\n f:=false;\n repeat\n if (x mod 10<>0)and(x mod 10 <>1) then\n begin\n f:=true;\n break;\n end;\n x:=x div 10;\n until x=0;\n\n if f then break else\n begin\n if (i=j)and(a[i]>=10)and(i*10<=m) then\n begin\n kk:=10;\n while i*kk*10<=m do kk:=kk*10;\n if i*kk>ma then ma:=i*kk;\n inc(a[i*kk],a[i] div kk);\n dec(a[i],kk*(a[i] div kk));\n k:=1;\n end else\n begin\n mn:=min(a[i],a[j]);\n if i+j>ma then ma:=i+j;\n inc(a[i+j],mn);\n dec(a[i],mn);\n dec(a[j],mn);\n k:=1;\n end;\n end;\n end;\n if k=0 then break;\n end;\n for i:=1 to ma do if a[i]<>0 then inc(kol,a[i]);\n writeln(kol);\n for i:=1 to ma do if a[i]<>0 then\n for j:=1 to a[i] do write(i,' ');\nend.\n"}, {"source_code": "Program plakat;\nvar i,n,y,x,j,d,s:LongInt;\n a: array[1..100] of Integer;\n b: array[1..100] of Integer;\n c: array[1..1000] of LongInt;\nBegin\nread(n);\ni:=1;\nrepeat \na[i]:=n mod 10;\nn:=trunc((n-n mod 10)/10);\ni:=i+1;\nuntil n=0;\ny:=1;\nrepeat\nfor j:= i-1 downto 1 do\nif a[j]>=1 then b[j]:=1 else b[j]:=0;\nfor j:= i-1 downto 1 do\nBegin\nd:=1;\nif j>1 then\nfor x:=1 to j-1 do\nd:=d*10\nelse d:=1;\nc[y]:=c[y]+b[j]*d;\nend;\nfor j:= i-1 downto 1 do\na[j]:=a[j]-b[j];\ny:=y+1;\ns:=0;\nfor j:= i-1 downto 1 do\ns:=s+a[j];\nuntil s=0;\nfor j:=1 to y-1 do\nwrite(c[j],' ');\nend.\n"}, {"source_code": "const fi='';\n fo='';\n\nvar n,min:longint;\n s:string;\n a,b:array[0..10] of longint;\n f,g:text;\n\nprocedure doc;\nbegin\n readln(f,s);\nend;\n\nprocedure chuanbi;\nvar i:longint;\nbegin\n n:=length(s);\n for i:=1 to n do\n begin\n a[i]:=ord(s[i])-48;\n end;\nend;\n\nprocedure ghi;\nvar i,x,y,j:longint;\nbegin\n x:=1;y:=1;\n while x<=n do\n begin\n for i:=1 to n do b[i]:=0;\n min:=high(longint);\n for i:=x to n do\n begin\n if a[i]>0 then b[i]:=1;\n if (a[i]>0) and (a[i]0 then\n begin\n y:=i;break;\n end;\n for i:=1 to n do\n if a[i]>0 then\n begin\n x:=i;break;\n end;\n for i:=1 to min do\n begin\n for j:=y to n do\n write(g,b[j]);\n write(G,' ');\n end;\n end;\nend;\n\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n doc;\n chuanbi;\n ghi;\n close(f);close(g);\nend.\n"}, {"source_code": "var s:string;\n ans:array[1..100] of string;\n b:boolean;\n i,k,n,m:longint;\nbegin\nreadln(s);\n\nb:=true;\nwhile b do\nbegin\n b:=false;\n inc(n);\n for i:=1 to length(s) do\n if s[i]='0'\n then ans[n]:=ans[n]+s[i]\n else begin\n b:=true;\n ans[n]:=ans[n]+'1';\n s[i]:=chr(ord(s[i])-1);\n end;\nend;\nwriteln(n-1);\nfor i:=1 to n-1 do\n write(ans[i],' ');\nend.\n\n\n\n\n"}, {"source_code": "var s:string;\n ans:array[1..100] of string;\n b:boolean;\n i,k,n,m:longint;\nbegin\nreadln(s);\nb:=true;\nwhile b do\nbegin\n b:=false;\n inc(n);\n for i:=1 to length(s) do\n if s[i]='0'\n then ans[n]:=ans[n]+s[i]\n else begin\n b:=true;\n ans[n]:=ans[n]+'1';\n s[i]:=chr(ord(s[i])-1);\n end;\nend;\nfor i:=1 to n-1do\n write(ans[i],' ');\nend.\n\n\n\n"}, {"source_code": "var n,t,m,s:longint;\n a:array[0..1000000] of longint;\n\nprocedure process;\nvar i:longint;\n tmp:string;\nbegin\nread(s);\nstr(s,tmp);\nfor i:=1 to length(tmp) do t:=t*10+1;\nwhile s>0 do\n begin\n while s>=t do\n begin\n s:=s-t;\n inc(n);\n a[n]:=t;\n end;\n if t mod 10=0 then t:=t div 10 else t:=t-1;\n end;\nwriteln(n);\nfor i:=n downto 1 do write(a[i],' ');\nend;\n\nbegin\nprocess;\nend."}, {"source_code": "var n,t,m,s:longint;\n a:array[0..1000000] of longint;\n\nprocedure process;\nvar i:longint;\n tmp,t2:string;\nbegin\nread(s);\nstr(s,tmp);\nfor i:=1 to length(tmp) do t:=t*10+1;\nwhile s>0 do\n begin\n while s>=t do\n begin\n s:=s-t;\n inc(n);\n a[n]:=t;\n end;\n str(s,tmp);\n t2:='1';\n for i:=2 to length(tmp) do\n if tmp[i]>'1' then t2:=t2+'1' else t2:=t2+'0';\n val(t2,t);\n end;\nwriteln(n);\nfor i:=n downto 1 do write(a[i],' ');\nend;\n\nbegin\nprocess;\nend."}, {"source_code": "var a,ans:array[1..100000]of longint;\n n,t,k,i:longint;\nbegin\na[1]:=1;\na[2]:=10;\na[3]:=11;\na[4]:=100;\na[5]:=101;\na[6]:=110;\na[7]:=111;\na[8]:=1000;\na[9]:=1001;\na[10]:=1010;\na[11]:=1011;\na[12]:=1100;\na[13]:=1101;\na[14]:=1110;\na[15]:=1111;\na[16]:=10000;\na[17]:=10001;\na[18]:=10010;\na[19]:=10011;\na[20]:=10100;\na[21]:=10101;\na[22]:=10110;\na[23]:=10111;\na[24]:=11000;\na[25]:=11001;\na[26]:=11010;\na[27]:=11011;\na[28]:=11100;\na[29]:=11101;\na[30]:=11110;\na[31]:=11111;\na[32]:=100000;\na[33]:=100001;\na[34]:=100010;\na[35]:=100011;\na[36]:=100100;\na[37]:=100101;\na[38]:=100110;\na[39]:=100111;\na[40]:=101000;\na[41]:=101001;\na[42]:=101010;\na[43]:=101011;\na[44]:=101100;\na[45]:=101101;\na[46]:=101110;\na[47]:=101111;\na[48]:=110000;\na[49]:=110001;\na[50]:=110010;\na[51]:=110011;\na[52]:=110100;\na[53]:=110101;\na[54]:=110110;\na[55]:=110111;\na[56]:=111000;\na[57]:=111001;\na[58]:=111010;\na[59]:=111011;\na[60]:=111100;\na[61]:=111101;\na[62]:=111110;\na[63]:=111111;\n\nreadln(n);\nt:=63;\n\nwhile n>0 do\n begin\n while n-a[t]>=0 do\n begin\n inc(k);\n dec(n,a[t]);\n ans[k]:=a[t];\n end;\n dec(t);\n end;\n \nwriteln(k);\nfor i:=1 to k do\n write(ans[i],' ');\nend."}, {"source_code": "var a,f,ans:array[0..1000] of longint;\n n,kol,x,g,p:longint;\n\nprocedure new_el;\n\tvar h,s,k:longint;\nbegin\n\ts:=0;\n\tk:=1;\n\tfor h:=n downto 1 do\n\t\tbegin\n\t\t\ts:=s+k*a[h];\n\t\t\tk:=k*10;\n\t\tend;\n inc(kol);\n f[kol]:=s;\nend;\n\n\n \nprocedure dv_perebor;\n\tvar i,j:longint;\nbegin\n\tn:=7;\n\tfillchar(a,sizeof(a),0);\n\ta[n]:=1;\n\twhile a[0] = 0 do\n\t\tbegin\n\t\t\tnew_el;\n\t\t\ti:=n;\n\t\t\twhile a[i] = 1 do\n\t\t\t\tbegin\n\t\t\t\t\ta[i]:=0;\n\t\t\t\t\tdec(i);\n\t\t\t\tend;\n\t\t\ta[i]:=1;\n\t\tend;\nend;\n\n\nbegin\n\treadln(x);\n\tkol:=0;\n\tdv_perebor;\n\tp:=0;\n\tg:=kol;\n\twhile x>0 do\n\t\tbegin\n\t\t\tif f[g] > x \tthen \tdec(g);\n\t\t\tif f[g] <= x\tthen \tbegin\n\t\t\t\t\t\t\t\t\t\tx:=x-f[g]; \n\t\t\t\t\t\t\t\t\t\tinc(p);\n\t\t\t\t\t\t\t\t\t\tans[p]:=f[g];\n\t\t\t\t\t\t\t\t\tend;\n\t\tend;\n\twriteln(p);\n\n\tfor g:=1 to p do\n\t\twrite(ans[g],' ');\nend."}, {"source_code": "program Contest300_B;\nuses math;\nconst\n maxN=trunc(106);\nvar\n ff: text;\n n: longint;\n T,v,S: array[0..7] of longint;\n i,j,tmp,m,c: longint;\n\nprocedure swap(var a,b: longint);\n var t: longint;\n begin\n t:=a;a:=b;b:=t;\n end;\n\nbegin\n readln(n);\n i:=0;\n while n<>0 do\n begin\n inc(i);\n T[i]:=n mod 10;\n v[i]:=i;\n S[i]:=max(1,S[i-1]*10);\n n:=n div 10;\n end;\n m:=i;\n for i:=1 to m do\n begin\n tmp:=i;\n for j:=i+1 to m do\n if (T[j]>T[tmp]) then tmp:=j;\n Swap(T[i],T[tmp]);\n Swap(v[i],v[tmp]);\n end;\n\n writeln(T[1]);\n tmp:=0;\n i:=1;\n while true do\n begin\n j:=i;\n repeat\n tmp:=tmp+S[ v[j] ];\n if (jT[j]);\n for c:=T[j+1]+1 to T[i] do write(tmp,#32);\n i:=j+1;\n if j=m then break;\n end;\n \nend.\n"}, {"source_code": "program Contest300_B;\nuses math;\nconst\n maxN=trunc(106);\nvar\n ff: text;\n n: longint;\n T,v,S: array[0..7] of longint;\n i,j,tmp,m,c: longint;\n\nprocedure swap(var a,b: longint);\n var t: longint;\n begin\n t:=a;a:=b;b:=t;\n end;\n\nbegin\n readln(n);\n i:=0;\n while n<>0 do\n begin\n inc(i);\n T[i]:=n mod 10;\n v[i]:=i;\n S[i]:=max(1,S[i-1]*10);\n n:=n div 10;\n end;\n m:=i;\n for i:=1 to m do\n begin\n tmp:=i;\n for j:=i+1 to m do\n if (T[j]>T[tmp]) then tmp:=j;\n Swap(T[i],T[tmp]);\n Swap(v[i],v[tmp]);\n end;\n for i:=1 to m do writeln(T[i],' ',v[i]);readln;\n writeln(T[1]);\n tmp:=0;\n i:=1;\n while true do\n begin\n j:=i;\n repeat\n i:=j;\n tmp:=tmp+S[ v[j] ];\n if (j maxn then exit;\n inc(kol);\n a[kol]:=x;\n tt(x*10);\n tt(x*10+1);\n end;\n\nprocedure sort(l,r: longint);\n var i,j,x,y: longint;\n begin\n i:=l; j:=r;\n x:=a[l+random(r-l)];\n repeat\n while a[i]j) then begin\n y:=a[i]; a[i]:=a[j]; a[j]:=y;\n inc(i); j:=j-1;\n end;\n until i>j;\n if l0 do\n begin\n l:=1;\n r:=kol;\n while l+1> 1;\n if a[m]>n then r:=m else l:=m;\n end;\n if a[r]<=n then l:=r;\n inc(ans);\n b[ans]:=a[l];\n dec(n,a[l]);\n end;\n\n writeln(ans);\n for i:=1 to ans - 1 do write(b[i],' '); writeln(b[ans]);\n\n end."}, {"source_code": "const fi = '';\n fo = '';\n\nvar n, x, cnt: int64;\n i: longint;\n code: integer;\n ans: array [1..10000000] of int64;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n readln(n);\n for i:=65537 downto 1 do\n begin\n val(binstr(i, 17), x, code);\n while n >= x do\n begin\n n:=n-x;\n inc(cnt);\n ans[cnt]:=x;\n end;\n end;\n\n writeln(cnt);\n for i:=1 to cnt do write(ans[i], ' ');\n\n close(input); close(output);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n\nvar n, x: int64;\n s, t: string;\n code: integer;\n i, k, cnt: longint;\n ans: array [1..100] of string;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n readln(n);\n str(n, s); k:=length(s);\n while true do\n begin\n t:='';\n for i:=1 to k do\n if s[i] > '0' then\n begin\n t:=t+'1';\n s[i]:=chr(ord(s[i])-1);\n end\n else t:=t+'0';\n inc(cnt); ans[cnt]:=t;\n\n val(s, x, code);\n if x = 0 then break;\n end;\n {for i:=65537 downto 1 do\n begin\n val(binstr(i, 17), x, code);\n while n >= x do\n begin\n n:=n-x;\n inc(cnt);\n ans[cnt]:=x;\n end;\n end;}\n\n writeln(cnt);\n for i:=1 to cnt do write(ans[i], ' ');\n\n close(input); close(output);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n\nvar n, x, cnt: int64;\n i: longint;\n code: integer;\n ans: array [1..10000000] of int64;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n readln(n);\n for i:=65535 downto 1 do\n begin\n val(binstr(i, 16), x, code);\n while n >= x do\n begin\n n:=n-x;\n inc(cnt);\n ans[cnt]:=x;\n end;\n end;\n\n for i:=1 to cnt do write(ans[i], ' ');\n\n close(input); close(output);\nend.\n"}, {"source_code": "const maxn = 1000010;\nvar n, i, res: longint;\n ans: array [0..maxn] of longint;\nfunction check(k: longint): boolean;\nvar j: longint;\n s: string;\nbegin\n\tstr(k, s);\n\tfor j:=1 to length(s) do \n\t\tif ((s[j] <> '1') and (s[j] <> '0')) then exit(false);\n\texit(true);\nend;\nbegin\n\tread(n);\n\ti := n;\n\twhile (n > 0) do\n\t\tbegin\n\t\twhile ((check(i)) and (i <= n)) do\n\t\t\tbegin\n\t\t\tinc(res);\n\t\t\tans[res] := i;\n\t\t\tn := n - i;\n\t\t\tend;\n\t\tdec(i);\n\t\tend;\n\twriteln(res);\n\tfor i:=1 to res do write(ans[i], ' ');\nend."}], "src_uid": "033068c5e16d25f09039e29c88474275"} {"source_code": "uses\n math;\nconst\n d:array[1..2,1..4] of longint=((+1,-1,0,0),(0,0,+1,-1));\n l=20;\nvar\n f:array[1..l,1..l,0..1 shl 8] of longint;\n q:array[1..3,1..1000000] of longint;\n cost,x,y:array[1..l] of longint;\n a:array[1..l,1..l] of char;\n ans,cur,sx,sy,n,m,i,j,k,cnt,nx,ny,nk,st,fn,p:longint;\n c:char;\n\nprocedure update(i,j,k,x:longint);\nbegin\n if (f[i,j,k]=maxlongint) then\n begin\n q[1,fn]:=i;\n q[2,fn]:=j;\n q[3,fn]:=k;\n inc(fn);\n end;\n if (f[i,j,k]'B') then continue;\n inc(cnt);\n x[cnt]:=i;\n y[cnt]:=j;\n cost[cnt]:=-maxlongint;\n end;\n for i:=1 to n do for j:=1 to m do if (a[i,j]='S') then begin sx:=i; sy:=j; end;\n for i:=1 to n do for j:=1 to m do for k:=0 to 1 shl 8 do f[i,j,k]:=maxlongint;\n st:=1; fn:=1;\n update(sx,sy,0,0);\n while (st<>fn) do\n begin\n i:=q[1,st]; j:=q[2,st]; k:=q[3,st]; inc(st);\n for cur:=1 to 4 do\n begin\n nx:=i+d[1,cur];\n ny:=j+d[2,cur];\n if not((1<=nx) and (nx<=n) and (1<=ny) and (ny<=m)) then continue;\n if not((a[nx,ny]='.') or (a[nx,ny]='S')) then continue;\n nk:=k;\n for p:=1 to cnt do if (max(nx,i)=x[p]) and (j=ny) and (j0) then\n begin\n if (cost[p]=-maxlongint) then c:='-' else cur:=cur+cost[p];\n end;\n if (c='-') then continue;\n cur:=cur-f[sx,sy,k];\n if (ansb then exit(a); exit(b); end;\n\nprocedure work;\nvar\n head,tail,i,j,k,x,y,z,x1,y1,z1,ans,tmp:longint;\nbegin\n for i:=1 to n do\n for j:=1 to m do\n for k:=0 to 1 shl tot do\n f[i,j,k]:=inf;\n head:=0; tail:=1; ans:=0; f[sx,sy,0]:=0;\n que[1,1]:=sx; que[1,2]:=sy;\n while headn) or (y1<1) or (y1>m) or (map[x1,y1]<>'.') then continue;\n if k=1 then\n for i:=1 to tot do\n if (b[i,1]>x) and (b[i,2]=y) then\n z1:=z1 xor (1 shl (i-1));\n if k=2 then\n for i:=1 to tot do\n if (b[i,1]>x1) and (b[i,2]=y1) then\n z1:=z1 xor (1 shl (i-1));\n if f[x1,y1,z1]=inf then\n begin\n f[x1,y1,z1]:=que[head,4]+1;\n inc(tail); que[tail,1]:=x1; que[tail,2]:=y1; que[tail,3]:=z1; que[tail,4]:=f[x1,y1,z1];\n end;\n end;\n end;\n for i:=0 to 1 shl ts-1 do\n begin\n tmp:=-f[sx,sy,i];\n for j:=1 to ts do\n if i and (1 shl (j-1))<>0 then inc(tmp,v[j]);\n ans:=max(ans,tmp);\n end;\n writeln(ans);\nend;\n\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(map[i,j]);\n if map[i,j]='S' then\n begin\n sx:=i; sy:=j; map[i,j]:='.';\n end;\n end;\n readln;\n end;\n for i:=1 to n do\n for j:=1 to m do\n if map[i,j] in ['1'..'8'] then\n begin\n b[ord(map[i,j])-48,1]:=i;\n b[ord(map[i,j])-48,2]:=j;\n if ord(map[i,j])-48>ts then ts:=ord(map[i,j])-48;\n end;\n tot:=ts;\n for i:=1 to n do\n for j:=1 to m do\n if map[i,j]='B' then\n begin\n inc(tot);\n b[tot,1]:=i; b[tot,2]:=j;\n end;\n for i:=1 to ts do readln(v[i]);\n work;\nend.\n"}, {"source_code": "type\n node=record\n x,y:longint;\n end;\n node2=record\n x,y,p:longint;\n end;\nvar\n g:array[0..21,0..21]of char;\n f:array[1..21,1..21,0..300]of longint;\n q:array[1..21*21*300*5]of node2;\n w:array[1..21]of longint;\n v:array[1..21]of node;\n bomb:array[1..21]of node;\n line:array[1..21]of node;\n tot,cnt1,cnt2,sx,sy,n,m:longint;\n num:array[1..21]of longint;\nprocedure init;\nvar\n i,j:longint;\nbegin\n readln(n,m);\n cnt1:=0;\n cnt2:=0;\n for i:=1 to n do\n begin\n for j:=1 to m do\n begin\n read(g[i,j]);\n if g[i,j]='S'then\n begin\n sx:=i;\n sy:=j;\n end\n else\n if g[i,j]='B'then\n begin\n inc(cnt2);\n bomb[cnt2].x:=i;\n bomb[cnt2].y:=j;\n end\n else\n if g[i,j]in['1'..'8']then\n begin\n inc(cnt1);\n val(g[i,j],num[cnt1]);\n v[cnt1].x:=i;\n v[cnt1].y:=j;\n end;\n end;\n readln;\n end;\n for i:=1 to cnt1 do readln(w[i]);\n tot:=0;\n for i:=1 to cnt1 do\n begin\n inc(tot);\n line[tot].x:=v[i].x;\n line[tot].y:=v[i].y;\n end;\n for i:=1 to cnt2 do\n begin\n inc(tot);\n line[tot].x:=bomb[i].x;\n line[tot].y:=bomb[i].y;\n end;\nend;\nfunction getvalue(x:longint):longint;\nvar\n i,t:longint;\nbegin\n t:=0;\n for i:=1 to cnt1 do\n if x and (1 shl (i-1))<>0 then t:=t+w[num[i]];\n for i:=cnt1+1 to cnt1+cnt2 do\n if x and (1 shl (i-1))<>0 then exit(-2147483647);\n exit(t);\nend;\nfunction get(x,t:node2):longint;\nvar\n i,now:longint;\nbegin\n now:=x.p;\n for i:=1 to cnt1+cnt2 do\n begin\n if x.x<=line[i].x then continue;\n if (x.yt.y)and(x.y=line[i].y)then now:=now xor (1 shl (i-1));\n end;\n exit(now);\nend;\nprocedure main;\nvar\n t,x:node2;\n sum,p,tt,head,tail,i,ans:longint;\nbegin\n head:=0;\n tail:=1;\n fillchar(f,sizeof(f),255);\n q[1].x:=sx;\n q[1].y:=sy;\n q[1].p:=0;\n f[sx,sy,0]:=0;\n while headn)or(t.y>m)\n or((g[t.x,t.y]<>'S')and(g[t.x,t.y]<>'.'))then continue;\n t.p:=get(x,t);\n if f[t.x,t.y,t.p]<>-1 then continue;\n f[t.x,t.y,t.p]:=f[x.x,x.y,x.p]+1;\n inc(tail);\n q[tail]:=t;\n end;\n end;\n ans:=0;\n for i:=0 to 1 shl (cnt1+cnt2)-1 do\n if f[sx,sy,i]<>-1 then\n begin\n sum:=getvalue(i);\n if sum<0 then continue;\n sum:=sum-f[sx,sy,i];\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nend;\nbegin\n\n init;\n main;\n\nend.\n"}, {"source_code": "const\n way:array[1..4,1..2]of longint=((1,0),(-1,0),(0,1),(0,-1));\n\ntype\n re=record\n x,y,k,t:longint;\n end;\n\nvar\n n,m,tot,sx,sy,ans:longint;\n a:array[1..20,1..20]of char;\n c:array[1..8]of re;\n income:array[1..8]of longint;\n f:array[1..20,1..20,0..255] of longint;\n q:array[1..200000]of re;\n\nfunction jd(x,y:longint):boolean;\nbegin\n if (x<1) or (x>n) or (y<1) or (y>m) then exit(false);\n if (a[x,y]<>'.') and (a[x,y]<>'S') then exit(false);\n exit(true);\nend;\n\nprocedure bfs;\nvar\n head,tail,i,j,x,y,k,t2:longint;\n e:re;\n\nbegin\n head:=0;\n tail:=1;\n q[1].x:=sx;\n q[1].y:=sy;\n q[1].k:=0;\n q[1].t:=0;\n\n repeat\n inc(head);\n e:=q[head];\n for i:=1 to 4 do if jd(e.x+way[i,1],e.y+way[i,2]) then begin\n x:=e.x+way[i,1];\n y:=e.y+way[i,2];\n k:=e.k;\n for j:=1 to tot do begin\n if (i=4) and (y=c[j].y) and (x='0')and (a[i,j]<='9')) then begin\n inc(tot);\n c[tot].x:=i;\n c[tot].y:=j;\n if a[i,j]='B' then c[tot].k:=0\n else c[tot].k:=ord(a[i,j])-48;\n c[tot].t:=1 shl (tot-1);\n if c[tot].k>t then t:=c[tot].k;\n end\n else if a[i,j]='S' then begin\n sx:=i;\n sy:=j;\n end;\n end;\n readln;\n end;\n for i:=1 to t do readln(income[i]);\n f[sx,sy,0]:=0;\n bfs;\n ans:=0;\n for i:=0 to 255 do if f[sx,sy,i]>-1 then begin\n t:=0;\n t2:=0;\n for j:=1 to tot do if i and c[j].t>0 then begin\n if c[j].k=0 then begin\n t2:=-1;\n break;\n end\n else t:=t+income[c[j].k];\n end;\n if t2=-1 then continue;\n t:=t-f[sx,sy,i];\n if t>ans then ans:=t;\n end;\n writeln(ans);\nend;\n\nbegin\n readln(n,m);\n init;\nend.\n"}], "negative_code": [], "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n var a,b,mi,ma,k:int64;\nbegin\nreadln(a,b);\nk:=0;\nwhile (a<>b) do\nbegin\nmi:=min(a,b);\nma:=max(a,b);\nif (ma mod mi = 0) then\nbegin\na:=mi;\nb:=a;\nk:=k+(ma div mi)-1;\nend\nelse\nbegin\na:=mi;\nb:=ma mod mi;\nk:=k+(ma div mi);\nend;\nend;\nwriteln(k+1);\nend.", "positive_code": [{"source_code": "program zd1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n a,b,c,d,ot:int64;\nbegin\n readln(a,b);\n ot := 0;\n while (a <> b) do\n begin\n ot := ot + a div b;\n a := a mod b;\n c := max(a,b);\n d := min(a,b);\n a := c;\n b := d;\n if b = 0 then break;\n end;\n if (a = b) and (b <> 0) then inc(ot);\n writeln(ot);\n readln;\n readln;\n\nend.\n"}, {"source_code": "var a,b,dem,tam:qword;\nbegin\n readln(a,b);\n dem:=0;\n while a<>0 do\n begin\n inc(dem,a div b);\n a:=a mod b;\n if a<>0 then\n begin\n tam:=a;\n a:=b;\n b:=tam;\n end;\n end;\n writeln(dem);\nend.\n"}, {"source_code": "program abc;\nvar a,b,count:int64;\nbegin\nreadln(a,b);\ncount:=0;\nwhile (a<>0) and (b<>0) do\n begin\n if a>b then \n begin \n count:=count + a div b;\n a:=a mod b;\n end\n else\n begin\n count:=count + b div a;\n b:=b mod a;\n end\n end;\nwriteln(count);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, count : Int64; \n\nbegin\n ReadLn(a, b);\n while a <> b do\n begin \n if a > b then\n begin\n if a mod b = 0 then\n begin\n count:=count + a div b;\n break;\n end else\n begin\n count:=count + a div b ;\n a:=a mod b;\n end;\n end else\n begin\n if b mod a = 0 then\n begin\n count:=count + b div a;\n break;\n end else\n begin\n count:=count + b div a;\n b:=b mod a;\n end;\n end;\n end;\n WriteLn(count);\nend.\n"}, {"source_code": "program paper;\n\nvar a,b,c,ans:int64;\n\nbegin\n readln(a,b);\n ans:=0;\n while ((a>0)and(b>0)) do begin\n if b>a then begin\n c:=a;\n a:=b;\n b:=c;\n end;\n c:=a div b;\n ans:=ans+c;\n a:=a mod b;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var a,b,c,r:int64;\nbegin\n reaD(A,b);\n C:=a div b;;\n r:=a mod b;\n while r>0 do\n begin\n \n a:=b;b:=r;C:=a div b+c;\n r:=a mod b;\n end;\n write(c);\nend."}, {"source_code": "var i,j,k:longint;\n a,b,res:int64;\n procedure max(var a,b:int64);\n var temp:int64;\n begin\n if b>a then begin temp:=a;a:=b;b:=temp;end;\n end;\n\nbegin\n readln(a,b);\n while (a<>0)and(b<>0) do\n begin\n max(a,b);\n res:=res+a div b;\n a:=a mod b;\n end;\n writeln(res);\n readln;\nend.\n"}, {"source_code": "var a,b,x:int64;k:int64;\nbegin\nreadln(a,b);\nwhile (a<>0) or (b<>0) do\nbegin\nif (a=0) or (b=0) then break\nelse\nif a 0) do begin\n inc(res, a div b);\n a := a mod b;\n swap(a, b);\n end;\n\n writeln(res);\n\n readln(a);\nend.\n"}, {"source_code": "program a1;\nvar a, b, r: int64;\nbegin\nr:=0;\nreadln (a, b);\nwhile (a>=1) and (b>=1) and (a<>b) do begin\n if (a>b) then begin \n r:=r+a div b; \n a:=a mod b;\n end\n else \n begin\n r:=r+b div a; \n b:=b mod a;\n end;\n end;\nif (a=b) then r:=r+1;\nwriteln (r);\nend.\n"}, {"source_code": "var kq,a,b,t:int64;\n\nbegin\n readln(a,b);\n kq:=0;\n while b<>0 do\n begin\n inc(kq,a div b);\n a:=a mod b;\n t:=a;\n a:=b;\n b:=t;\n end;\n writeln(kq);\nend."}, {"source_code": "program z1;\n var a,i,e,n:int64;\nbegin\n readln(a,i);\n while(a<>0)and(i<>0)do\n begin\n n:=n+(a div i);\n a:=a mod i;\n e:=i;\n i:=a;\n a:=e;\n end;\n writeln(n);\nend.\n"}, {"source_code": "program project;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a, b, kol :int64;\n\nbegin\n \n readln(a, b);\n kol := 0;\n while (a <> b) and (a > 0) and (b > 0) do\n begin\n if (a > b) then\n begin\n kol := kol + (a div b);\n a := a mod b;\n end\n else\n begin\n kol := kol + (b div a);\n b := b mod a;\n end;\n end;\n if (a <> 0) and (a = b) then\n inc(kol);\n\n writeln(kol);\nend."}, {"source_code": "program Pr_A;\n\n{$APPTYPE CONSOLE}\nvar a, b, w, k: int64;\n\nbegin\n //assign (input, 'input.txt'); reset (input);\n //assign (output, 'output.txt'); rewrite (output);\n\n read (a, b);\n k := 1;\n while (a <> 0) and (b <> 0) do\n begin\n if a >= b then\n begin\n k := k + a div b;\n a := a mod b;\n end\n else\n begin\n k := k + b div a;\n b := b mod a;\n end;\n end;\n\n writeln (k - 1);\n //close (input);\n //close (output);\nend.\n"}, {"source_code": "var a,b,kq:int64;\nbegin\n readln(a,b);\n kq:=0;\n repeat\n if a>b then\n begin\n kq:=kq+a div b;\n a:=a mod b;\n end\n else if a0)and(b>0) do\n begin\n c:=max(a,b);\n d:=min(a,b);\n res:=(c div d)+res;\n a:=c mod d;\n b:=d;\n end;\n if a>0\n then inc(res);\n write(res);\nend.\n"}, {"source_code": "var\n a, b, k, n: int64;\nbegin\n read(a, b);\n while (a <> 0) and (b <> 0) do\n begin\n if a > b then\n begin\n k := a div b;\n a := a - b * k;\n end\n else\n if b > a then\n begin\n k := b div a;\n b := b - a * k;\n end;\n n := n + k;\n end;\n writeln(n);\nend."}, {"source_code": "var a,b,k:int64;\n\nprocedure swap(var a,b:int64);\nvar x:int64;\nbegin\n x:=a;\n a:=b;\n b:=x;\nend;\n\nbegin\n\nreadln(a,b);\nk:=0;\n\nwhile b>0 do\nbegin\n k:=k+a div b;\n a:=a mod b;\n swap(a,b);\nend;\n\nwriteln(k);\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b,s: int64;\nbegin\n readln(a,b);\n s:= 0;\n while(a<>0) and (b<>0) do\n begin\n if (a > b) then begin if(a div b = 0) then begin inc(s); a:= a - b; end else s:= s + a div b; a:= a mod b end\n else begin if(b div a = 0) then begin inc(s); b:= b - a; end else s:= s + b div a; b:= b mod a end\n end;\n writeln(s);\n readln;\n readln;\nend.\n"}, {"source_code": "var\na,b,k:int64;\nbegin\nreadln(a,b);\nk:=0;\nwhile (a>0) and (b>0) do\nif a>b then begin k:=k+a div b; a:=a mod b; end\nelse begin k:=k+b div a; b:=b mod a; end;\nwriteln(k);\nend."}, {"source_code": "var a,b,s,w,k:int64;\nbegin\nread(a,b);\nwhile (a>0)and(b>0) do\nbegin\nif (a>b)then begin\ns:=a div b;\na:=a mod b;\nend else if (b>a)then begin s:=b div a;\nb:=b mod a;\nend;\ninc(k,s);\nend;\nwrite(k);\nend."}, {"source_code": "program CF296A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a, b, c, count: int64;\nbegin\n readln(a,b);\n count:=0;\n repeat\n if a mod b = 0 then\n begin\n count:=count + a div b;\n break;\n end\n else if a > b then\n begin\n count:=count + a div b;\n a:=a mod b;\n end\n else if b > a then\n begin\n count:=count + b div a;\n b:= b mod a;\n end;\n if (b = 0) or (a = 0) then\n break;\n until a = b;\n writeln(count);\n readln;\nend.\n"}, {"source_code": "program beath;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n \nvar\n a,a1,b,b1,n:int64;\n\n\nbegin\n readln(a,b);\n n:=0;\n while (a <> 0) and (b <> 0) do begin\n\n if (a = b) then begin\n n:=n+1;\n a:=0;\n b:=0;\n end;\n \n if a>b then\n begin\n a1:=a mod b;\n n:=n+( a div b);\n\na:=a1;\n\nend else\n\nif b>a then begin\nb1:=b mod a;\nn:=n+( b div a);\n b:=b1; \n end;\n\n\n\n\n end;\n writeln(n);\nend."}, {"source_code": "Program game;\nvar\na, B, ind:int64;\nbegin\n read(a);\n read(b);\n ind:=0;\n while (a<>0) and (b<>0) do\n begin\n if a>b then\n begin\n ind:=ind+(a div b);\n a:=a mod b;\n end\n else\n begin\n ind:=ind+(b div a);\n b:=b mod a;\n end;\n\n end;\n write(ind);\nend."}, {"source_code": "program n1;\nvar e,a,b,k:int64;\nbegin\nreadln (a,b);\nk:=k+a div b;\n\nwhile a mod b <>0 do begin\ne:=a mod b;\na:=b;\nb:=e;\nk:=k+a div b;\nend;\nwriteln (k);\n\nend.\n"}, {"source_code": "program project;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n a, b, kol :int64;\n\nbegin\n //reset(input, 'bestbuy.in');\n //rewrite(output, 'bestbuy.out');\n readln(a, b);\n kol := 0;\n while (a <> b) and (a > 0) and (b > 0) do\n begin\n if (a > b) then\n begin\n kol := kol + (a div b);\n a := a mod b;\n end\n else\n begin\n kol := kol + (b div a);\n b := b mod a;\n end;\n end;\n if (a <> 0) and (a = b) then\n inc(kol);\n\n writeln(kol);\n readln;\nend."}, {"source_code": "var q,c,res:int64;\nbegin\nread(q,c);\nres:=0;\nwhile ((q>0)and(c>0)) do\nbegin\nif q>c then begin inc(res,q div c); q:=q mod c; end\nelse begin inc(res,c div q); c:=c mod q; end;\nend;\nwriteln(res);\nend."}, {"source_code": "Var \n a, b, i:Int64;\n flag:boolean;\nbegin\n Readln(a, b); i:=0;\n Repeat\n if (a>b) then \n begin \n flag:=(a mod b=0);\n i:=i+(a div b);\n a:=a mod b;\n end else\n begin\n flag:=(b mod a=0);\n i:=i+(b div a);\n b:=b mod a;\n end;\n Until flag;\n writeln(i);\nend."}, {"source_code": "var a, b, d: qword;\n\nprocedure input;\nbegin\n readln(a, b);\nend;\n\nprocedure swap(var a, b: qword);\nvar tmp: qword;\nbegin\n if b > a then\n begin\n tmp:= a;\n a:= b;\n b:= tmp;\n end;\nend;\n\nprocedure output;\nbegin\n write(d);\n halt;\nend;\n\nprocedure proc(a, b: qword);\nbegin\n if a = 0 then output;\n swap(a, b);\n inc(d, a div b);\n a:= a mod b;\n proc(a, b);\nend;\n\nbegin\n input;\n d:= 0;\n swap(a, b);\n inc(d, a div b);\n a:= a mod b;\n proc(a, b);\nend."}, {"source_code": "var ans,a,b,r:int64;\nbegin\nreadln(a,b);\nwhile (b<>0) do\n begin\n ans:=ans+ a div b;\n r:= a mod b;\n a:=b;\n b:=r;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n a,b:int64;\n sum:int64;\nbegin\n readln(a,b);\n sum:=0;\n while true do\n begin\n if b=0 then break;\n inc(sum,a div b);\n a:=a mod b;\n if a=0 then break;\n inc(sum,b div a);\n b:=b mod a;\n end;\n writeln(sum);\nend."}, {"source_code": "{$MODE OBJFPC}\nuses math;\nconst max1=100000;\ntype vector=array[0..max1] of integer;\nvar n,m,k:integer;\n a,b,res,vo:int64;\n fi,fo:textfile;\nprocedure enter;\n var i,j:integer;\n temp:int64;\n begin\n res:=0;\n readln(fi,a,b);\n a:=max(a,b);\n b:=min(a,b);\n if a=b*2 then\n begin\n writeln(fo,2);\n exit;\n end;\n res:=0;\n while a<>b*2 do\n begin\n res:=res+a div b;\n vo:=a;\n a:=b;\n b:=vo mod b;\n if b=0 then\n begin\n writeln(Fo,res);\n exit;\n end;\n end;\n writeln(Fo,res+2);\n end;\nprocedure solve;\n var i,j:integer;\n begin\n end;\nprocedure print;\n var i,j:integer;\n begin\n end;\nbegin\n assignfile(fi,'');reset(fi);\n assignfile(fo,'');rewrite(Fo);\n enter;\n solve;\n print;\n closefile(fi);\n closefile(Fo);\nend.\n"}, {"source_code": "VAR a,b,res,tmp:int64;\nBEGIN\n READLN(a,b);\n WHILE b<>0 DO\n BEGIN\n res:=res+(a div b);\n tmp:=b;\n b:=a mod b;\n a:=tmp;\n END;\n WRITELN(res);\n READLN;\nEND."}, {"source_code": "var d,t:int64;\n a,b,x,y,tmp:int64;\n\nprocedure open;\n begin\n// assign(input,'527A.inp');\n reset(input);\n end;\n\nprocedure finish ;\n begin\n// assign(output,'527A.out');\n rewrite(output);\n end;\n\nprocedure rd;\n begin\n read(a,b);\n end;\n\nprocedure solve;\n begin\n rd;\n // d:=1;\n {if (a=1) and (b=1) then\n begin\n write(1);\n exit;\n end;\n if (b=1) then\n begin\n write(a);\n exit;\n end; }\n while (b>0) do\n begin\n //inc(d);\n {if (a-b>b) then\n begin\n x:=a;\n y:=b;\n a:=x-y;\n end\n else\n begin\n x:=a;\n y:=b;\n a:=b;\n b:=x-y;\n end; }\n d:=(a div b) + d;\n tmp:=b;\n b:=a mod b;\n a:=tmp;\n end;\n // if (a=b) then\n write(d);\n end;\n\n BEGIN\n open;\n finish;\n solve;\n// close(input);\n// close(output);\n END.\n"}, {"source_code": "program codeforces_527A;\nconst Inputfile = ''{'playpaper.inp'};\n Outputfile = ''{'playpaper.out'};\n\nvar a,b,dem : int64;\n\nprocedure nhap;\nvar fi : text;\nbegin\nassign(fi,Inputfile);\nreset(fi);\nreadln(fi,a,b);\nclose(fi);\nend;\n\nprocedure xuli;\nvar tam : int64;\nbegin\nwhile (b > 0) do\n begin\n dem := dem + (a div b);\n tam := a;\n a := b;\n b := tam mod b;\n end;\nend;\n\nprocedure xuat;\nvar fo : text;\nbegin\nassign(fo,Outputfile);\nrewrite(fo);\nwrite(fo,dem);\nclose(fo);\nend;\n\nBEGIN\nnhap;\nxuli;\nxuat;\nEND."}, {"source_code": "{$mode objfpc}\nuses math;\nvar\n a, b, r, c: int64;\nbegin\n readln(a,b);\n while b <> 0 do\n begin\n c := c + a div b;\n r := a mod b;\n a := b;\n b := r;\n end;\n writeln(c);\nend.\n"}, {"source_code": "var\n n,m,k:int64;\n begin\n readln(n,m);\n repeat\n if (n=0) or (m=0) then\n begin\n writeln(k);\n exit;\n end;\n if n=m then\n begin\n inc(k);\n writeln(k);\n exit;\n end;\n if n >m then\n begin\n k := k + (n div m);\n n := n mod m;\n end else\n begin\n k := k + (m div n);\n m := m mod n;\n end;\n until 1 >2;\n end."}, {"source_code": "var\n a, b, c, d: int64;\n \n\n\nbegin\n readln(a, b);\n c := 0;\n while (a <> 0) and (b <> 0) do begin\n inc(c, a div b);\n d := a;\n a := b;\n b := d mod b;\n end;\n writeln(c);\nend."}, {"source_code": "Var i,n,m,k,a,b:Int64;\n Begin\n Read(a,b);\n While (a<>0) and (b<>0) do\n Begin\n if a>b then Begin i:=i+(a div b); a:=a mod b; end\n else Begin i:=i+(b div a); b:=b mod a; end;\n end;\n Write(i);\n End.\n"}, {"source_code": "procedure kotak(a,b : int64);\nvar\n total,temp : int64;\nbegin\ntotal:=0;\nrepeat\n total := total + a div b;\n temp := a mod b;\n a := b;\n b := temp\n until b = 0;\n writeln(total);\n\nend;\n var\n a,b : int64;\nbegin\n readln(a,b);\n kotak(a,b);\nend."}, {"source_code": "var a,b:int64;\nProcedure solution;\nvar k,tmp:int64;\nbegin\n k:=0;\n while b>0 do\n begin\n k:=k+a div b;\n tmp:=a;\n a:=b; b:=tmp mod b;\n end;\n write(k);\nend;\nbegin\n readln(a,b);\n solution;\n readln;\nend.\n"}, {"source_code": "var\n a,b,ans,t : int64;\n\nbegin\n readln(a,b);\n while (a > 0) and (b > 0) do\n begin\n ans:=ans+a div b;\n a:=a-b*(a div b);\n if a < b then begin t:=a; a:=b; b:=t; end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n a,b,kq1,kq,t : int64;\nbegin\n readln(a,b);\n repeat\n kq1 := a div b;\n kq := kq + kq1;\n a := a - b * kq1;\n t := a;\n a := b;\n b := t;\n until (a = 0) or (b=0);\n writeln(kq);\nend."}, {"source_code": "var\na, b : int64;\ncnt : int64;\n\n\nbegin\nreadln(a, b);\ncnt := 0;\nwhile ((a > 0) and (b > 0)) do\n begin\n if a >= b then\n begin\n cnt := cnt + a div b;\n a := a mod b;\n end\n else\n begin\n cnt := cnt + b div a;\n b := b mod a;\n end;\n end;\nwriteln(cnt);\nreadln; readln\nend."}, {"source_code": "var a,b,s:int64;\nbegin\n read(a,b);\n while (a<>0)and(b<>0) do\n if a>b then begin s:=s+a div b; a:=a mod b end else begin s:=s+b div a; b:=b mod a end;\n write(s)\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n a, b, res: int64;\n\nbegin\n read(a,b);\n res := 0;\n if a mod b = 0\n then begin\n write(a div b);\n exit;\n end;\n if b mod a = 0 then begin\n write(b div a);\n exit;\n end;\n repeat\n if a > b then begin\n inc(res,a div b);\n a := a mod b;\n end else\n if a < b then begin\n inc(res,b div a);\n b := b mod a;\n end;\n if a mod b = 0\n then begin\n write(res + a div b);\n exit;\n end;\n if b mod a = 0 then begin\n write(res + b div a);\n exit;\n end;\n until false;\nend.\n\n"}, {"source_code": "uses math;\nvar n,m,ans,x:int64;\nbegin\n readln(n,m);\n if m=1 then \n begin\n writeln(n);\n halt;\n end;\n while (n<>m) do\n begin\n { write(n,' ',m,'|'); }\n x:=max(n,m) div min(n,m)-1;\n if x=0 then x:=1;\n ans:=ans+x;\n if n>m then n:=n-m*x\n else m:=m-n*x;\n end;\n writeln(ans+1);\nend."}, {"source_code": "var\n a,b,ans,t : int64;\n\nbegin\n readln(a,b);\n while (a > 0) and (b > 0) do\n begin\n ans:=ans+a div b;\n a:=a-b*(a div b);\n if a < b then begin t:=a; a:=b; b:=t; end;\n end;\n writeln(ans);\nend."}, {"source_code": "var a,b,c,d:int64;\nbegin\nreadln(a,b);d:=b;\nwhile (true) and (a>=1) and (b>=1) do begin\nif (a>=b) then begin c:=c+(a div b); a:=a-b*(a div b); end\nelse if (b>=a) then begin c:=c+(b div a); b:=b-a*(b div a); end\nelse break;\nend;\nwriteln(c);\nreadln;\nend.\n"}, {"source_code": "var a, b, cnt: int64;\n\nprocedure swap( var a, b: int64 );\nvar tmp: int64;\nbegin\n tmp := a;\n a := b;\n b := tmp;\nend;\n\nbegin\n readln( a, b );\n cnt := 0;\n while ( (a > 0) and (b > 0) ) do\n begin\n inc( cnt, a div b );\n a := a mod b;\n swap( a, b );\n end;\n writeln( cnt );\nend."}, {"source_code": "var f: text;\n a,b,s,d: int64;\nbegin\n assign(f,''); reset(f);\n readln(f,a,b);\n d:=1;\n repeat\n if (a=1) or (b=1) then\n begin\n if a>b then d:=d+a-1\n else d:=d+b-1;\n break;\n end;\n if (a mod b=0) or (b mod a=0) then\n begin\n if a>b then d:=d+a div b-1\n else d:=d+b div a-1;\n break;\n end;\n if a>b then\n begin\n d:=d+a div b;\n a:=a mod b;\n end\n else\n begin\n d:=d+b div a;\n b:=b mod a;\n end;\n until a=b;\n write(d);\n readln;\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nVar\n a, b:QWord;\n Count, tg: QWord;\nProcedure Swap(x, y: QWord);\nVar tg: QWord;\nBegin\n tg:=a;\n a:=b;\n b:=tg;\nEnd;\nBegin\n Readln(a,b);\n If a mod b=0 then Writeln(a div b)\n Else\n Begin\n While a mod b<>0 do\n Begin\n Count:=Count+a div b;\n a:=a mod b;\n If a b) and (a <> 0) and (b <> 0) do Begin\n Ans += max(a, b) div min(a, b);\n If a > b then\n a := a mod b\n Else\n b := b mod a\n End;\n Write(Ans)\nEnd."}, {"source_code": "var\na,b,o:int64;\nbegin\nread(a,b); o:=0;\nwhile (a>0) and (b>0) do\nif a>=b then begin\ninc(o,a div b);\na:=a mod b; end\nelse begin inc(o,b div a);\nb:=b mod a; end;\nwrite(o); end."}, {"source_code": "var\n a,b,n,tmp,i:int64;\nbegin\n readln(a,b);\n while (a<>b) do\n begin\n if (a0) then\n a:=a-((a div b)*b)\n else\n begin\n a:=b;\n i:=i-1;\n end;\n if (a<1) then\n begin\n a:=1;\n i:=i-1;\n end;\n end;\n writeln(i+1);\nend."}, {"source_code": "function max(a:int64; b:int64) : int64;\nbegin\n if a>b then max:=a else max:=b;\nend;\nfunction min(a:int64; b:int64) : int64;\nbegin\n if a0) and (b<>0)do\n begin\n tmp:=a;\n a:=max(a,b);\n b:=min(b,tmp);\n k:=k+a div b;\n tmp:=a;\n a:=b;\n b:=tmp mod b;\n end;\n write(k);\n \nend."}, {"source_code": "Program Andronic;\nvar a,b:qword; n,i:qword;\nbegin\n read(a,b);\n n:=0;\n repeat begin\n n:=n+(a div b);\n i:=b;\n b:=a mod b;\n a:=i;\n end until b=0;\n\n writeln(n);\n readln;\nend."}, {"source_code": "var a,b,res,p:int64;\n begin\n read(a,b);\n While (b>0) do\n begin\n res:=res+a div b;\n p:=b;\n b:=a mod b;\n a:=p;\n end;\n writeln(res);\n end."}, {"source_code": "var a,b,c,tmp:int64;\nbegin\n\treadln(a,b);\n\tc := 0;\n\twhile (a mod b <> 0) do\n\tbegin\n\t\tc := c + (a div b);\n\t\ttmp := a;\n\t\ta := b;\n\t\tb := tmp mod b;\n\tend;\n\tc := c + (a div b);\n\twriteln(c);\nend."}, {"source_code": "var a,b,k,c:int64;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nk:=0;\n\nwhile (a>0) and (b>0) do\nbegin\nif (a>b) then begin\n\n k:=a div b + k;\n a:=a mod b;\n\nend else begin\n k:=b div a + k;\n b:=b mod a;\nend;\n\n\nend;\nwrite(k);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var\n a,b,t,c:int64;\nbegin\n readln(a,b);\n t:=0;\n while(a>0)and(b>0) do\n begin\n t:=t+a div b;\n c:=a mod b;\n a:=b;\n b:=c;\n end;\n writeln(t);\nend."}, {"source_code": "var a,b,ans:int64;\nbegin\nreadln(a,b);\n\nwhile (a<>b) and (a<>0) and (b<>0) do\n begin\n if a0 do\n begin\n if a>b then\n begin\n d:=d+(a div b);\n if (a mod b)<>0 then\n a:=a mod b\n else break;\n end;\n if a0 then\n b:=b mod a\n else break;\n end;\n end;\n end;\n\n procedure xuatfile;\n begin\n assign(f,fo); rewrite(f);\n write(f,d);\n close(f);\n end;\n\nBEGIN\n NHAPFILE;\n XULI;\n XUATFILE;\nEND."}, {"source_code": "var\n a,b:qword;\nfunction ans(a,b:qword):qword;\nbegin\n if (a=0)or(b=0)then exit(0);\n if a>b then\n ans:=ans(a mod b,b)+(a div b)\n else\n ans:=ans(a,b mod a)+(b div a);\nend;\nbegin\n readln(a,b);\n writeln(ans(a,b));\nend.\n"}, {"source_code": "var\na,b,ans:int64;\n\nbegin\nread(a,b);\nWhile (a<>0) and (b<>0) do\nbegin\nif a>b then \nbegin\ninc(ans,a div b);\na:=a mod b; end else\nbegin\ninc(ans,b div a);\nb:=b mod a;\nend;\nend;\nWriteln(ans);\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream;\nuses math;\nvar a,b,temp,dem:int64;\nbegin\n readln(a,b);\n temp:=max(a,b);\n b:=min(a,b);\n a:=temp;\n repeat\n inc(dem,a div b);\n a:=a mod b;\n temp:=max(a,b);\n b:=min(a,b);\n a:=temp;\n until (a=0) or (b=0);\n writeln(dem)\nend."}, {"source_code": "program A_527;\n\nvar\n a,b,ans,z:int64;\n\nbegin\n read(a,b);\n if b>a\n then begin\n a:=z;\n a:=b;\n b:=z;\n end;\n while a mod b<>0 do\n begin\n ans:=ans+a div b;\n a:=a mod b;\n z:=a;\n a:=b;\n b:=z;\n end;\n ans:=ans+a div b;\n write(ans);\nend.\n \n "}, {"source_code": "var\n p,a,b:int64;\nbegin\n readln(a,b);\n while (a<>0) and (b<>0) do begin\n if a>b then begin\n inc(p,a div b);\n a:=a mod b;\n end else begin\n inc(p,b div a);\n b:=b mod a;\n end;\n end;\n writeln(p);\nend."}, {"source_code": "var \n n,a,b,c:int64;\n begin {assign(input, 'input.txt'); reset(input);\n assign(output, 'output.txt'); rewrite(output);}\n readln(a,b);\n n:=0;\n repeat\n n:=n+(a div b);\n c:=a mod b;\n a:=b; \n b:=c;\n \n until (a=b) or (c=0);\n writeln(n);\n {close(output);}\nend."}, {"source_code": "program z;\nvar a,b,rslt:int64;\nbegin\nread(a,b);\n\n while (a <> 0) and (b <> 0) do\n begin\n if a>b then\n begin\n inc(rslt,a div b);\n a:=a mod b;\n end\n else\n begin\n inc(rslt,b div a);\n b:=b mod a;\n end;\n end;\n\nwrite(rslt);\nend.\n"}, {"source_code": "var a,b,res,p:int64;\n begin\n read(a,b);\n While (b>0) do\n begin\n res:=res+a div b;\n p:=b;\n b:=a mod b;\n a:=p;\n end;\n writeln(res);\n end.\n"}, {"source_code": "var a,b,ans,t:int64;\nbegin\nread(a,b);\nwhile (a<>0) and (b<>0) do\n begin\n inc(ans,a div b);\n t:=b;\n b:=a mod b;\n a:=t;\n end;\nwrite(ans);\nend.\n"}], "negative_code": [{"source_code": "var\n a, b, an, x: uint64;\n\nbegin\n read(a, b);\n repeat\n if a > b then\n begin\n x := a;\n a := a mod b;\n an := an + x div b;\n end\n else\n if b > a then\n begin\n x := b;\n b := b mod a;\n an := an + x div a;\n end;\n if a = 0 then\n a := 1\n else\n if b = 0 then\n b := 1;\n until a = b;\n write(an);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, count : Int64; \n\nbegin\n ReadLn(a, b);\n while a <> b do\n begin \n if a > b then\n begin\n if a mod b = 0 then\n begin\n count:=count + a;\n break;\n end else\n begin\n count:=count + a div b ;\n a:=a mod b;\n end;\n end else\n begin\n if b mod a = 0 then\n begin\n count:=count + b;\n break;\n end else\n begin\n count:=count + b div a;\n b:=b mod a;\n end;\n end;\n end;\n WriteLn(count);\nend.\n"}, {"source_code": "var\na,b,k:int64;\nbegin\nreadln(a,b);\nk:=0;\nif (a>b) and (a mod b=0) then k:=a div b\nelse if (b>a) and (b mod a=0) then k:=b div a\nelse\nwhile (a>0) and (b>0) do \nif a>b then begin k:= a div b; a:=a mod b; end\nelse begin k:=b div a; b:=b mod a; end; \nwriteln(k);\nend."}, {"source_code": "procedure kotak(a,b : int64);\nvar\n total,temp : int64;\nbegin\ntemp:=0;\nrepeat\n total := total + a div b;\n temp := a mod b;\n a := b;\n b := temp\n until b = 0;\n writeln(total);\n\nend;\n var\n a,b : int64;\nbegin\n readln(a,b);\n kotak(a,b);\nend."}, {"source_code": "uses math;\nvar a,b,ans,i:int64;\nbegin\nread(a,b);\nwhile (a>1) and (b>1) do\nbegin\nif a>b then begin\n inc(ans,a div b);\n a:=a mod b;\n end else begin\n inc(ans,b div a);\n b:=b mod a;\n end;\nend;\ninc(ans,max(a,b));\nwrite(ans);\nend. "}, {"source_code": "var ans,a,b:int64;\nbegin\n ans:=1;\n read(a,b);\n while a<>b do\n begin\n if a=1 then begin ans:=ans+b-1; break; end else if b=1 then begin ans:=ans+b-1; break; end else\n if b>a then b:=b-a else a:=a-b;\n inc(ans);\n end; writeln(ans);\nend."}, {"source_code": "uses math;\n\nvar a, b, cnt: int64;\n\nprocedure swap( var a, b: int64 );\nvar tmp: int64;\nbegin\n tmp := a;\n a := b;\n b := tmp;\nend;\n\nbegin\n readln( a, b );\n if ( a < b ) then\n swap( a, b );\n cnt := 1;\n while ( (a > 1) and (b > 1) ) do\n begin\n inc( cnt );\n a := a - b;\n if ( a < b ) then\n swap( a, b );\n end;\n writeln( cnt + a - b );\nend."}, {"source_code": "var f: text;\n a,b,s,d: int64;\nbegin\n assign(f,''); reset(f);\n readln(f,a,b);\n d:=0; s:=abs(a-b);\n while s<>0 do\n begin\n inc(d);\n if a>b then a:=s\n else b:=s;\n s:=abs(a-b);\n if a=1 then\n begin\n d:=d+b;\n break;\n end\n else if b=1 then\n begin\n d:=d+a;\n break;\n end;\n end;\n write(d);\n readln;\nend.\n\n"}, {"source_code": "Program Andronic;\nvar a,b:qword; n,i:qword;\nbegin\n read(a,b);\n n:=0;\n IF (a mod b)=0 then n:=(a div b);\n while (a mod b)<>0 do begin\n n:=n+(a div b);\n i:=b;\n b:=a mod b;\n a:=i;\n end;\n IF (a mod b)=0 then n:=n+(a div b);\n writeln(n);\n readln;\nend."}, {"source_code": "uses math;\nvar i,k,n,m,l,a,b,c,d,p,a1,a2:int64;\n begin\n readln(a,b);\n\n n:=min(a,b);\n m:=max(a,b);\n if m mod n = 0 then WriteLn(m div n);\n while (n<>1) and (m<>1) do\n begin\n inc(k,m div n);\n m:=m mod n;\n a1:=min(n,m);\n a2:=max(n,m);\n n:=a1;\n m:=a2;\n end;\n WriteLn(k+max(n,m));\n end."}, {"source_code": "var\n a,b:qword;\nfunction ans(a,b:qword):qword;\nbegin\n if a*b=0 then exit(0);\n if a>b then\n ans:=ans(a mod b,b)+(a div b)\n else\n ans:=ans(a,b mod a)+(b div a);\nend;\nbegin\n readln(a,b);\n writeln(ans(a,b));\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nuses math;\nvar a,b,dem:int64;\n\nprocedure kt(a,b:int64);\nbegin\n if (a=0) or (b=0) then exit;\n dem:=max(a,b) div min(a,b);\n if a>b then a:=a mod b else\n b:=b mod a;\n if a=b then exit else kt(min(a,b),max(a,b)-min(a,b))\n\nend;\n\nbegin\n readln(a,b); dem:=max(a,b) div min(a,b);\n if a>b then a:=a mod b else\n b:=b mod a;\n kt(a,b);\n writeln(dem)\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nuses math;\nvar a,b,dem:int64;\n\nprocedure kt(a,b:int64);\nbegin\n if (a=0) or (b=0) then exit;\n dem:=max(a,b) div min(a,b)+dem;\n if a>b then a:=a mod b else\n b:=b mod a;\n if a=b then exit else kt(min(a,b),max(a,b)-min(a,b))\n\nend;\n\nbegin\n readln(a,b); dem:=max(a,b) div min(a,b);\n if a>b then a:=a mod b else\n b:=b mod a;\n kt(a,b);\n writeln(dem)\nend.\n"}, {"source_code": "Var a, b, k, c:int64;\nbegin\n readln(a, b);\n if b=1 then k:=0 else k:=1;\n while ((a mod b)<>0) do \n begin\n a:=a mod b; \n if (a1) do \n begin\n a:=a mod b; \n if (a0) then k:=1 else k:=0;\n while ((a mod b)<>0) do \n begin\n a:=a mod b; \n if (ab) then a:=a-b else b:=b-a;\n Inc(i);\n end;\n Until (a=b);\n writeln(i);\nend."}, {"source_code": "Var a, b, k, c:int64;\nbegin\n readln(a, b);\n if ((a mod b)<>0) then k:=1 else k:=0;\n while ((a mod b)<>0) do \n begin\n a:=a mod b; \n if (ab) then c:=a div b else c:=b;\n write(k+c);\nend."}, {"source_code": "Var a, b, k, c:int64;\nbegin\n readln(a, b);\n if ((a mod b)<>0) then k:=1 else k:=0;\n while ((a mod b)<>0) do \n begin\n if (a-b=b) then break;\n a:=a mod b; \n if (a0 do begin\n if b>a then begin\n c:=a;\n a:=b;\n b:=c;\n end;\n c:=a div b;\n ans:=ans+c;\n a:=a mod b;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "Var a,b,x,k:longint;\nBegin\n readln(a,b);\n k:=0;\n while (a<>0)and (b<>0) do\n begin\n if a>b then begin\n k:=k+a div b;\n a:=a-b*(a div b);\n end\n else begin\n k:=k+b div a;\n b:=b-a*(b mod a);\n end;\n end;\n\n writeln(k);\nEnd."}, {"source_code": "Var a,b,x,k:longint;\nBegin\n readln(a,b);\n k:=0;\n while (a<>0)and (b<>0) do\n begin\n\n if a>b then begin\n k:=k+a div b;\n a:=a-b*(a div b);\n end\n else begin\n k:=k+b div a;\n b:=b-a*(b div a);\n end;\n inc(k);\n end;\n\n writeln(k-1);\nEnd."}, {"source_code": "program z1;\n var a,i,e,n:int64;\nbegin\n readln(a,i);\n while(a*i<>0)do\n begin\n n:=n+(a div i);\n a:=a mod i;\n e:=i;\n i:=a;\n a:=e;\n end;\n writeln(n);\nend."}, {"source_code": "var\n a, b, k, n: int64;\nbegin\n read(a, b);\n while ((a * b) <> 0) do\n begin\n if a > b then\n begin\n k := a div b;\n a := a - b * k;\n end\n else\n if b > a then\n begin\n k := b div a;\n b := b - a * k;\n end;\n n := n + k;\n end;\n writeln(n);\nend."}, {"source_code": "var\n a, b, k, n: int64;\n\nbegin\n read(a, b);\n while (a * b > 0) do\n begin\n if a > b then\n begin\n k := a div b;\n a := a - b * k;\n end\n else\n if b > a then\n begin\n k := b div a;\n b := b - a * k;\n end;\n n := n + k;\n end;\n writeln(n);\nend."}, {"source_code": "var a,b,ans:int64;\nbegin\n readln(a,b); ans:=0;\n repeat\n if a mod b=0 then begin write(a div b); halt; end;\n if b mod a=0 then begin write(b div a); halt; end;\n while a>b do begin dec(a,b); inc(ans); end;\n while b>a do begin dec(b,a); inc(ans); end;\n until a=b;\n writeln(ans+1);\nend."}, {"source_code": "var ans,a,b:{real}extended{int64};\nbegin\nreadln(a,b);\nwhile (a<>0) and (b<>0) do\n begin\n ans:=ans+1;\n if a >=b then a:=a-b\n else b:=b-a;\n end;\n writeln(ans);\nend."}, {"source_code": "{$MODE OBJFPC}\nuses math;\nconst max1=100000;\ntype vector=array[0..max1] of integer;\nvar n,m,k:integer;\n a,b,res:int64;\n fi,fo:textfile;\nprocedure enter;\n var i,j:integer;\n temp:int64;\n begin\n res:=0;\n readln(fi,a,b);\n a:=max(a,b);\n b:=min(a,b);\n if a=b*2 then\n begin\n writeln(fo,2);\n exit;\n end;\n res:=a div b;\n a:=b;\n b:=a mod b;\n if b=0 then\n begin\n writeln(Fo,res);\n exit;\n end;\n while a<>b*2 do\n begin\n inc(res);\n temp:=a;\n a:=max(b,temp-b);\n b:=min(b,temp-b);\n end;\n writeln(Fo,res+2);\n end;\nprocedure solve;\n var i,j:integer;\n begin\n end;\nprocedure print;\n var i,j:integer;\n begin\n end;\nbegin\n assignfile(fi,'');reset(fi);\n assignfile(fo,'');rewrite(Fo);\n enter;\n solve;\n print;\n closefile(fi);\n closefile(Fo);\nend.\n"}, {"source_code": "{$mode objfpc}\nuses math;\nvar\n a, b, c: int64;\nbegin\n readln(a,b);\n while b > 1 do\n begin\n b := min(a - b,b);\n a := max(a,b) - min(a,b);\n inc(c);\n end;\n writeln(c + a);\nend.\n"}, {"source_code": "var\n a,b,n,m : int64;\n\nbegin\nreadln(a,b);\nn := a div b;\nm := a mod b;\nwhile m > 0 do\n begin\n a := b;\n b := m;\n n := n + a div b;\n m := a mod b;\n end;\nend."}, {"source_code": "uses math;\nvar a,b,c,d,n:int64;\n begin\n readln(a,b);\n if b<>1 then begin\n while (a>0) and(b>0) do begin\n if a>b then c:=c+a mod b else c:=c+b mod a;inc(n);\n if a>b then a:=a mod b else b:=b mod a;inc(d);\n c:=n+d;\n end;\n write((c/10)); end;\n if b=1 then write(a);\n end.\n\n"}, {"source_code": "var\nq,n,m:int64;\ni,j,w,e,r:longint;\na:array[1..100000] of longint;\nbegin\n {assign(input,'right.in');\n assign(output,'right.out');\n reset(input);\n rewrite(output);}\n read(n,m);\n if (n=1) or (m=1) then\n begin\n write(n+m-1);\n exit;\n end;\n while (n>1) and (m>1) do\n begin\n if n>m then\n begin\n inc(q,(n div m));\n n:=n mod m;\n\n end\n else\n begin\n inc(q,(m div n));\n m:=m mod n;\n end;\n end;\n write(q+n+m-1);\nend.\n\n\n\n"}, {"source_code": "var a,b,c,d:real;\nbegin\nreadln(a,b); d:=b;\nwhile (true) and (d<>1) and (a>=1) and (b>=1) and (b>a) do begin\nif(a>=b) then begin a:=a-b; c:=c+1; end\nelse if (b>=a) then begin b:=b-a; c:=c+1; end\nelse break;\nend;\nif(d=1) then writeln(a:0:0) else writeln(c:0:0);\nreadln;\nend.\n"}, {"source_code": "var a,b,c,d:real;\nbegin\nreadln(a,b); d:=b;\nwhile (true) and (d<>1) and (a<>1) and (b<>1) do begin\nif(a>=b) then begin a:=a-b; c:=c+1; end\nelse if (b>=a) then begin b:=b-a; c:=c+1; end\nelse break;\nend;\nif(d=1) then writeln(a:0:0) else writeln(c:0:0);\nreadln;\nend.\n"}, {"source_code": "Program Origami2;\nVar a,b,k,nod,a1,b1:int64;\nBegin\nreadln(a,b);\na1:=a; b1:=b;\nk:=0;\nwhile (a<>0) and (b<>0) do\n if a>b then a:=a mod b else b:=b mod a;\n nod:=a+b;\n a:=a1; b:=b1;\n if (nod>1) or ((nod=1) and ((a mod b=0) or (b mod a=0))) then\n if a> b then k:=a div nod else k:=b div nod\nelse\n begin\n while a<>b do\n begin\n if a>b then a:=a-b else b:=b-a;\n k:=k+1;\n end;\n k:=k+1;\n end;\nwriteln(k);\nreadln;\nEnd."}, {"source_code": "Program Origami2;\nVar a,b,k,nod,a1,b1:int64;\nBegin\nreadln(a,b);\na1:=a; b1:=b;\nk:=0;\nwhile (a mod 10 =0) and (b mod 10 =0) do\n begin\n a:=a div 10;\n b:=b div 10;\n end;\nwhile (a<>0) and (b<>0) do\n if a>b then a:=a mod b else b:=b mod a;\n nod:=a+b;\n a:=a1; b:=b1;\n if (nod>1) or ((nod=1) and ((a mod b=0) or (b mod a=0))) then\n if a> b then k:=a div nod else k:=b div nod\nelse\n begin\n while a<>b do\n begin\n if a>b then a:=a-b else b:=b-a;\n k:=k+1;\n end;\n k:=k+1;\n end;\nwriteln(k);\nreadln;\nEnd."}, {"source_code": "var a,b,c:int64;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile a<>b do\nbegin\nif (a mod b <> 0) and (b mod a <> 0) then\nbegin\n if a>b then a:=a-(b*(a div b)) else b:=b-(a*(b div a));\n c:=c+(a div b)+(b div a);\nend else\nbegin\n if a>b then a:=a-b else b:=b-a;\n inc(c);\nend;\nend;\n\nwrite(c);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var a,b,k,c:int64;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile a<>b do\nbegin\nif (a mod b <> 0) and (b mod a <> 0) then\nbegin\n if a>b then a:=a-(b*(a div b)) else b:=b-(a*(b div a));\n c:=c+(a div b)+(b div a);\n inc(k);\nend else\nbegin\n if a>b then a:=a-b else b:=b-a;\n inc(c);\nend;\nend;\nif k=0 then inc(c);\nwrite(c);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var a,b,k,c:integer;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile (a<>b) and (a>0) and (b>0) do\nbegin\nif (a>b) then begin\n\n k:=a div b;\n a:=a mod b;\n\nend else begin\n k:=b div a;\n b:=b mod a;\nend;\n\n\nend;\nwrite(k);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var a,b,c:int64;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile a<>b do\nbegin\nif (a mod b <> 0) and (b mod a <> 0) then\nbegin\n if a>b then a:=a-(b*(a div b)) else b:=b-(a*(b div a));\n c:=c+(a div b)+(b div a);\nend else\nbegin\n if a>b then a:=a-b else b:=b-a;\n inc(c);\nend;\nend;\ninc(c);\nwrite(c);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var a,b,c:int64;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile a<>b do\nbegin\nif (a mod b <> 0) and (b mod a <> 0) then if a>b then a:=a-(b*(a div b)) else b:=b-(a*(b div a)) else if a>b then a:=a-b else b:=b-a;\nc:=c+(a div b)+(b div a);\nend;\n\nwrite(c);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var a,b,c:integer;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nread(a,b);\nc:=0;\n\nwhile a<>b do\nbegin\nif a>b then a:=a-b else b:=b-a;\ninc(c);\nend;\n\nwrite(c);\n{close(input);\nclose(output);}\nend."}, {"source_code": "var\na, b, x: int64;\nbegin\nread(a);\nreadln(b);\nx:= 0;\nwhile a <> b do begin\n if a < b then b:= b - a\n else a:= a - b;\n x:= x + 1;\n end;\nwriteln(x);\nend."}, {"source_code": "Var a : Array[97..122,97..122]of longint;\n b : array[97..122]of longint;\n s,k : array[1..200005]of char;\n i,j,t,c,f,n : longint;\nbegin\n\n readln(n);\n For i := 1 to n do\n read(s[i]);\n readln;\n for i := 1 to n do\n read(k[i]);\n For i := 1 to n do\n begin\n if (s[i] <> k[i]) then\n begin\n a[ord(s[i]),ord(k[i])] := i;\n b[ord(s[i])] := 1;\n inc(f);\n end;\n end;\n For i := 97 to 122 do\n for j := 97 to 122 do\n if (i <> j) then\n if (a[i,j] > 0) and (a[j,i] > 0) then\n begin\n writeln(f - 2);\n writeln(a[i,j],' ',a[j,i]);\n exit;\n end;\n For i := 1 to n do\n if (s[i] <> k[i]) then\n if (b[ord(k[i])] > 0) then\n For j := 1 to length(s) do\n if (ord(s[j]) = ord(k[i])) then\n begin\n writeln(f - 1);\n writeln(i,' ',j);\n exit;\n end;\n writeln(f);\n writeln('-1 -1');\nend.\n\n\n"}, {"source_code": "{$mode objfpc}\nvar\n a : array[1..100000] of integer;\n n,i,j,k,x,kq,t : integer;\nbegin\n readln(n,k);\n for i := 1 to n do\n begin\n readln(j);\n a[j] := i;\n end;\n for i := 1 to k do\n begin\n t := i mod n;\n if t = 0 then t := n;\n x := a[t];\n for j := 1 to n do\n begin\n if a[j] >= x then a[j] := a[j] - x + 1\n else a[j] := a[j] + n - x + 1;\n end;\n kq := kq + x -1;\n end;\n writeln(kq);\nend.\n"}, {"source_code": "var a,b,s:int64;\nbegin\n read(a,b);\n while a*b<>0 do\n if a>b then begin s:=s+a div b; a:=a mod b end else begin s:=s+b div a; b:=b mod a end;\n write(s)\nend."}, {"source_code": "var a,b: int64;\n kq: int64;\n{------------------------------}\nprocedure process;\nvar tam: longint;\nbegin\n readln(a,b);\n repeat\n kq := kq + a div b;\n tam := a mod b;\n a := b;\n b := tam;\n until b = 0;\n writeln(kq);\nend;\n{------------------------------}\nbegin\n process;\nend."}], "src_uid": "ce698a0eb3f5b82de58feb177ce43b83"} {"source_code": "var n,k,t,ans:longint ;\nbegin \n readln(n,k,t) ;\n\t if (t=k then ans:=ans+k ;\n\t if (t>n) then ans:=ans-t+n ;\n\t writeln(ans) ;\nend.", "positive_code": [{"source_code": "var\n t,k,i,j,n,m:int64;\nbegin\n read(n,k,t);\n if t<=k then writeln(t) else\n if t<=n then writeln(k) else\n writeln(k-(t-n));\nend."}, {"source_code": "Var\n n, k, t: UInt64;\n \nBegin\n Read(n, k, t);\n If t <= k then\n Write(t)\n Else If (t > k) and (t <= n) then\n Write(k)\n Else\n Write(n + k - t)\nEnd."}, {"source_code": "program pr2;\n var\n z,n,k,t:longint;\n begin\n readln(n,k,t);\n\t if t<=k then \n\t z:=t;\n\t if (t>k)and(t=n then \n\t z:=n+k-t;\n write(z);\n end."}, {"source_code": " \n const nn=1600000; nnn=1200000;eps=0.00000000001;\n besk=80000000000000;\n label 1,2,3;\n var step, i,j:longint;\n k,pp,jj,ii,p3,p4, p1,p2,t1,t2,p,ost,q,n,ot,t,kk:int64;\n pal:array[-20..6000,-20..6000] of boolean;\n ppp:extended;\n dd,zz,z,c,d,x,y,a,b:array[-1002..2000000] of int64;\n ddnew,ddold:array[0..200,0..4040] of integer;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss:string;\n ch:char;\n flagg,flag,flag1:boolean;\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ff(p:int64):int64;\nvar t1,t2:int64;\nbegin if p=1 then ff:=0 else if p=2 then ff:=1 else\n begin\n t1:=ff(p shr 1);\n t2:=ff(p-(p shr 1));\n ff:=t1*t2+t1+t2;\n\n end;\n\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,k,t);\n if t<=k then begin write(t); goto 1; end;\n if t>=n then begin write(n+k-t); goto 1; end;\n write(k);\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "program mfs;\nvar\nn,k,t:longint;\nbegin\nreadln(n,k,t);\nif t<=k then begin writeln(t); halt; end;\nif t>=n then begin writeln(k-(t-n)); halt; end;\nif (kn then\nans:=n+k-t\nelse\nans:=k;\nwriteln(ans);\nend."}, {"source_code": "var n , k , t : longint;\nbegin\nread(n , k , t);\nif (t < k) then write(t);\nif ((t >= k) and (t <= n)) then write(k);\nif (t > n) then write(n + k - t);\nend."}, {"source_code": "var x,y,i,j,k,n,z:longint;\nbegin\n read(n,k,j);\n if (j=n+k then write(0) else if nk) and (t<=n) then writeln(Fout,k);\n if (t>n) then\n writeln(fout,k-(t-n));\n close(Fin);close(Fout);\nEND.\n"}, {"source_code": "var n,k,t:longint;\nbegin\nreadln(n,k,t);\nif k>=t then writeln(t) else\nif (kn) then writeln(k-(t-n));\nend."}, {"source_code": "var a,b,c:int64;\nbegin\nread(a,b,c);\nif c>a then write(b-c+a) else\nif c>=b then write(b) else write(c)\nend."}, {"source_code": "const\n fv='';\n fr='';\nvar\n n,k,t:longint;\n f,g:text;\nbegin\n assign(f,fv);reset(F);\n assign(g,fr);rewrite(g);\n read(f,n,k,t);\n if t=k)and (t<=n) then writeln(g,k);\n if t > n then writeln(g,k-(t-n));\n close(f);\n close(G);\nend.\n"}, {"source_code": "var n,k,t:longint;\nbegin\nreadln(n,k,t);\nif t>n then\n if k-(t-n)<>0 then writeln(k-(t-n))\n else writeln(0)\n else\n if t-k>0 then writeln(k)\n else writeln(t);\nend."}, {"source_code": "const fin='';\n fout='';\nvar f,g:text;\n n,t,k:longint;\nbegin\n assign(f,fin);reset(F);\n assign(g,fout);rewrite(G);\n read(f,n,k,t);\n if t<=k then write(g,t)\n else if (t>k) and (t<=n) then write(g,k)\n else write(g,k-(t-n));\n close(F);\n close(G);\nend."}, {"source_code": "var\nn,k,t:longint;\nbegin\nread(n,k,t);\nif t<=k then begin write(t); halt; end;\nif t<=n then begin write(k); halt; end;\nwrite(n+k-t); end."}, {"source_code": "var\n n,k,t:int64;\nbegin\n readln(n,k,t);\n if (t<=k) then writeln(t) else\n if (t<=n) then writeln(k) else\n writeln(n+k-t);\nend."}, {"source_code": "var n,k,t:longint;\nBegin\n readln(n,k,t);\n if(t<=k) then writeln(t)\n else\n if(t>k)and(t<=n) then writeln(k)\n else writeln((n+k)-t);\nend."}, {"source_code": "var n,t,k:Longint;\nbegin\n\treadln(n,k,t);\n\tif t<=k then writeln(t)\n\telse\n\tif t<=n then writeln(t-(t-k))\n\telse \n\twriteln(n+k-t);\n\nend."}, {"source_code": "var n,k,t,x:longint;\n\nbegin\nreadln(n,k,t);\nIF t<=n then\n IF t= k) then \n begin\n writeln(k) \n end\n else\n begin\n if t < k then \n begin\n writeln(t)\n end\n else \n writeln(n+k-t);\n end;\nend.\n"}, {"source_code": "var\nn,k,t:int64;\nbegin\nreadln(n,k,t);\nif t<=k then writeln(t)\nelse begin\n if t<=n then writeln(k)\n else begin\n writeln(n+k-t);\n end;\nend;\nend."}, {"source_code": "var n,k,t,x:longint;\n\nprocedure xuli;\n begin\n IF t<=n then\n IF t=0)and(t<=k-1) then\n writeln(t) else\n if (t>=n+1)and(t<=n+k) then\n writeln(k-(t-n)) else writeln(k);\nend."}, {"source_code": "var n,k,t:longint;\nbegin\nreadln(n,k,t);\nif t<=k then write(t)\n else\n if (t>k)and(t<=n) then write(k)\n else write(k-(t-n));\nend."}, {"source_code": "const\n fin='432_a.inp';fon='432_a.out';\nvar n,k,t,i,j:longint;\nbegin\n//assign(input,fin);\n//reset(Input);\n//assign(Output,fon);\n//rewrite(output);\nreadln(n,k,t);\nif t<=k then writeln(t)\n else\n if (t>k)and(t<=n) then write(k)\n else writeln(k-(t-n));\n//close(input);close(output);\nend.\n"}, {"source_code": "var\n\ta, b, n, t, c1, k, x, x1, x2, x3: uint64;\n\ts: string;\n\t\nbegin\n\n\treadln(n, k, t);\n\tif (t <= k) then\n\t\twriteln(t)\n\telse if ((t > k) and (t <= n)) then\t\n\t\twriteln(k)\n\telse if ((t >= n) and (t < n + k)) then\n\t\twriteln(n + k - t);\n\t\nend.\n"}, {"source_code": "{$coperators on}\n{$mode objfpc}\n{$inline on}\nconst\n fi='input.inp';\n fo='output.out';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nprocedure enter;\nvar n,k,t:int64;\nbegin\n readln(n,k,t);\n if t<=k then writeln(t)\n else\n begin\n if t<=n then\n writeln(k)\n else\n writeln(k-(t-n));\n end;\nend;\nbegin\n //fileio;\n enter;\nend."}, {"source_code": "var i,j,k,n,s,t:integer;\nbegin\nreadln(n,k,t);\nif (t<=n)and(t>=k) then write(k) else\nif tk)and(t<=n) then write(k);\n if t>n then write(k-t+n);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,k,t:longint;\n\n procedure init;\n begin\n assign(f,fi);\n reset(f);\n read(f,n,k,t);\n close(f);\n end;\n\n procedure xuly;\n begin\n assign(f,fo);\n rewrite(f);\n if t<=k then writeln(f,t)\n else if t<=n then writeln(f,k)\n else writeln(f,n+k-t);\n close(f);\n end;\n\n begin\n init;\n xuly;\n end."}, {"source_code": "var n,k,t,o:integer;\nbegin\n readln(n,k,t);\n if tn)and(n-t+k>0) then o:=k+n-t\n else o:=k;\n writeln(o);\nend."}, {"source_code": "Var\n n, k, t: integer;\n \n function mint(a, b: integer): integer;\n begin\n if (a <= b) then\n result:= a\n else\n result:= b;\n end;\n \nBegin\n readln(n, k, t);\n if (t <= n) then\n write(mint(t, k))\n else \n write(k + n - t);\nend."}, {"source_code": "uses math;\nvar n,k,t:int64;\nbegin\n read(n,k,t);\n write(min(t,min(k,n+k-t)));\nend.\n"}, {"source_code": "var n,k,t:int64;\nbegin\n readln(n,k,t);\n if (tn) then writeln((n+k-t)) else\n writeln(k);\nend.\n"}, {"source_code": "var n,k,t:longint;\nbegin\nread(n,k,t);\nif(tk) and (t<=n) then writeln(k)\n else writeln(k-(t-n));\n //close(input); close(output);\nend."}, {"source_code": "var n,t,k: int64;\nBEGIN\n readln(n,k,t);\n if (t <= k) then\n begin\n write(t);\n exit;\n end;\n if (t <= n) then\n begin\n write(k);\n exit;\n end;\n write(n+k - t);\nEND."}, {"source_code": "var n,k,t:longint;\nbegin\n read(n,k,t);\n if t<=k then writeln(t)\n else if t<=n then writeln(k)\n else writeln(n+k-t);\nend."}, {"source_code": "var n,k,t:int64;\nbegin\nreadln(n,k,t);\nif t<=k then\n begin\n writeln(T);\n halt;\n end;\nif (t>=n) then\n begin\n writeln(k-t+n);\n halt;\n end; \nwriteln(k);\nend.\n"}, {"source_code": "uses math;\nvar\n n,k,t,ans:int64;\nbegin\n readln(n,k,t);\n ans:=min(t,k);\n ans:=min(ans,k-t+n);\n writeln(ans);\nend."}, {"source_code": "var\n n,k,t:longint;\nbegin\n readln(n,k,t);\n if t<=k then writeln(t)\n else if (t>k) and (n>=t) then writeln(k)\n else writeln(n+k-t);\nend."}, {"source_code": "var\nn,k,t:longint;\nbegin\nreadln(n,k,t);\n\nif t<=k then\nbegin\nwriteln(t);\nhalt;\nend;\n\nif n-t>=0 then\nbegin\nwriteln(k);\nhalt;\nend;\n\nif n-t<0 then\nwriteln(k-t+n);\nend."}, {"source_code": "var\n\tn,k,t:longint;\nbegin\n\treadln(n,k,t);\n\tif t<=k then writeln(t)\n\telse if ((t>=k) and (t<=n)) then writeln(k)\n\telse writeln(k+n-t);\nend."}, {"source_code": "var n,k,t:longint;\nfunction process:longint;\nbegin\n if t<=k then exit(t)\n else if (t>k) and (t<=n) then exit(k) \n else if (t>n) then exit(k-(t mod n));\nend;\nbegin\nreadln(n,k,t);\nwrite(process);\nend."}, {"source_code": "var\na,b,c,x,y,z:longint;\ni,j,k,l,m,n,t:longint;\nbegin\nreadln(n,k,t);\nif t<=k then writeln(t);\nif (t>k)and(t<=n)then writeln(k);\nif t>n then writeln(n+k-t);\nend.\n\n\n\n"}, {"source_code": "Type ll=Longint;\nVar n,k,t:ll;\n f:text;\nProcedure Print(i:ll);\nBegin\n Write(i);\n Readln;\n Halt;\nEnd;\nBegin\n Assign(f,'');Reset(f);\n Readln(f,n,k,t);\n Close(f);\n If tn Then Print(k-t mod n);\n If t mod (n+k)=0 Then Print(0);\n Print(k);\nEnd."}, {"source_code": "var n,k,t,ans:longint ;\nbegin \n readln(n,k,t) ;\n\t if (t=k then ans:=ans+k ;\n\t if (t>n) then ans:=ans-t+n ;\n\t writeln(ans) ;\nend."}, {"source_code": "var\n n,k,t:longint;\nbegin\n readln(n,k,t);\n if t<=k then writeln(t) else if (t>k) and (n>=t) then writeln(k) else writeln(n+k-t);\nend."}, {"source_code": "var n,k,t:longint;\nbegin\n readln(n,k,t);\n if t<=k then writeln(t) else\n if n>=t then writeln(k) else\n writeln(n+k-t);\nend."}, {"source_code": "Var k , n , t : Longint;\nBegin\nreadln(n , k , t);\nIf t <= k then Writeln(t) else\nIf t <= n then Writeln(k) else\nWriteln(n + k - t);\nEnd."}, {"source_code": "program asdf;\nvar n,k,t:longint;\nbegin\nreadln(n,k,t);\nif t<=k then writeln(t)\nelse if (t>k) and (t<=n) then writeln(K)\nelse if (n-(t-k))>-1 then writeln(n-(t-k)) else writeln('0');\nend."}, {"source_code": "var\n n, k, t, r: int64;\n\nbegin\n read(n, k, t);\n if t <= k then r := t\n else if t >= n then r := n + k - t\n else r := k;\n if r < 0 then r := 0;\n write(r);\nend."}], "negative_code": [{"source_code": "Program MexicanWave;\nuses math;\nvar n,k,t:int64;\nbegin //assign(input,'851A.inp'); reset(input);\n //assign(output,'851A.out'); rewrite(output);\n readln(n,k,t);\n if t<=k then writeln(t)\n else if (t>k) and (t<=n) then writeln(k)\n else writeln(k-t mod k);\n //close(input); close(output);\nend."}, {"source_code": "program mfs;\nvar\nn,k,t:longint;\nbegin\nreadln(n,k,t);\nif t<=k then writeln(t);\nif t>=n then writeln(k-(t-n));\nif n=k then begin writeln(k-1); halt; end;\nif (k=n then writeln(k-(t-n));\nif (kk)and(t<=n)then writeln(k);\nif t>n then writeln(t-n-k);\nend.\n\n\n\n"}, {"source_code": "var\n n,k,t:longint;\nbegin\n readln(n,k,t);\n if k>t then writeln(t)\n else if (t>k) and (t k) and (t < n)) then\t\n\t\twriteln(t - (t - k))\n\telse if (t >= n) then\n\t\twriteln(t - n + 1)\n\t\nend.\n"}, {"source_code": "Var\n n, k, t: Integer;\n \nBegin\n Read(n, k, t);\n If t <= k then\n Write(t)\n Else If (t > k) and (t <= n) then\n Write(n - k)\n Else\n Write(n + k - t)\nEnd."}, {"source_code": "Var\n n, k, t: Int64;\n \nBegin\n Read(n, k, t);\n If t <= k then\n Write(t)\n Else If (t > k) and (t <= n) then\n Write(n - k)\n Else\n Write(n + k - t)\nEnd."}, {"source_code": "program pr2;\n var\n z,n,k,t:integer;\n begin\n readln(n,k,t);\n\t if t<=k then \n\t z:=t;\n\t if (t>k) then \n\t z:=k;\n write(z);\n end."}], "src_uid": "7e614526109a2052bfe7934381e7f6c2"} {"source_code": "var n,x:integer;\nbegin\n readln(n);\n if n = 2 then\n writeln('2')\n else\n writeln('1');\nend.", "positive_code": [{"source_code": "var\n n:longint;\nbegin\n read(n);\n if n=2 then write(2)\n else write(1);\nend."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if n>2 then write(1) else if n=2 then write(2) else write(1);\nend."}, {"source_code": "Var\n n: UInt64;\n \nBegin\n Read(n);\n If n <> 2 then\n Write(1)\n Else\n Write(2)\nEnd."}, {"source_code": "var\nn :int64;\nbegin\n read(n);\n if n <= 2 then write(n)\n else write('1');\nend."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if n=2 then writeln(2) else writeln(1);\nend."}, {"source_code": "var\ni,n:longint;\nbegin\nread(n);\nif n>2 then n:=1;\nwrite(n);\nend."}, {"source_code": "var n,i:longint;\nbegin\n readln(n);\n i:=n-1;\n while (n>1) do begin\n if n mod i<>0 then begin\n n:=n-i;\n i:=n;\n end;\n dec(i);\n if i<=1 then break;\n end;\n writeln(n);\nend."}, {"source_code": " var k:int64;\nbegin\n read(k);if k<3 then write(k) else\nwrite(1)\nend."}, {"source_code": "var n:int64;\nbegin\nreadln(n);\n\nif (n<>2) then writeln('1') else writeln('2');\nend."}, {"source_code": "var n:integer;\nbegin\n read(n);\n\tif n<=2 then write(n)\n\telse write(1);\nend."}, {"source_code": "var v:int64;\nbegin\n readln(v);\n if v=2 then writeln(2)\n else writeln(1);\nend."}, {"source_code": "program game;\n\nvar\nn:longint;\n\nbegin\n\treadln (n);\n\tif (n <= 2) then\n\tbegin\n\t\twriteln (n);\n\tend else\n\tbegin\n\t\twriteln (1);\n\tend;\nend."}, {"source_code": "var\n n: uint64;\n\nbegin\n readln(n);\n if n = 2 then\n write(2)\n else\n write(1);\nend."}, {"source_code": "program A1081;\n\nvar \n v,n:longint;\n\nbegin\n readln(v);\n if v = 2 then writeln(2) else writeln(1);\nend."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if n=2 then writeln('2')\n else writeln('1');\nend."}, {"source_code": "var n:word;begin read(n);if n=2 then write(n)else write(1);end."}, {"source_code": "var \nn:longint; \nbegin \nread(n); \nif n>2 then n:=1; \nwrite(n); \nend."}, {"source_code": "var n:longint;\nbegin \n readln(n);\n if n=2 then writeln(2)\n else writeln(1);\nend."}, {"source_code": "var n:integer;\nbegin\n readln(n);\n if (n = 2) then\n writeln(2)\n else\n writeln(1);\nend."}, {"source_code": "var a,b,i:longint;\nbegin\nread(a);\nfor i:=a downto 1 do\nif a mod i<>0 then break;\nif a mod 2=0 then \nif i=1 then write(a)\nelse write(1)\nelse write(1);\nend."}, {"source_code": "var a,b,c:longint;\nbegin\nreadln(a);\nif a<>2 then\nwriteln(1)\nelse writeln(2);\n\nend."}, {"source_code": "{* Author: Tejas Gopalakrishna *}\n\n{$mode objfpc}{$H+}{$J-}\n\nprogram definitegame;\n\nvar n: integer;\n\nbegin\n\tread(n);\n\tif n = 2 then\n\t\twriteln(2)\n\telse\n\t\twriteln(1);\nend."}, {"source_code": "Var a:Int64;\nBegin\n Readln(a);\n if a<>2 then\n Writeln('1')\n else\n Writeln('2');\nEnd."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if n=2 then writeln(2)\n else writeln(1);\nend."}, {"source_code": "var n, x, k, v: int64;\nbegin\nreadln (v);\n if v = 0 then write ('0')\n else \n begin\n if v = 2 then \n write ('2') else write ('1');\n end;\n\n\nend."}, {"source_code": "var n:int64;\nbegin\nread(n);\nif (n = 1) or (n = 2) then write(n) else write(1)\n\nend."}, {"source_code": "begin var n:=0;\n read(n);\n if n=2 then writeln(2) else\n writeln(1);\nend."}, {"source_code": "\nvar\n a, i, b, c, d, f, h, p, m, n, k, code: int64;\n\n\nbegin\n readln(n);\n if n=2 then writeln('2')\n else\nwriteln('1');\n\n\n\n\n\n \nend."}, {"source_code": "var\nn:int64;\nbegin\nread(n);\nif n<>2 then\nwrite('1')\nelse\nwrite('2');\nend."}, {"source_code": "program A;\n\n\nvar v: integer; \n// s: string;\n// a,b,k:array of int64;\n// answer: array of int64;\n// fl_exit: boolean;\n\nbegin\n readln(v);\n\n if v>2 then\n writeln(1)\n else \n writeln(v);\n \nend."}, {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\ts: string;\n\t\nbegin\n\n\treadln(n);\n\tif (n >= 3) then\n\t\twriteln(1)\n\telse writeln(n);\n\t\n\t\nend.\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul=1000000007{998244353} ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n numx,numy,xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..535002] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4400,-1..4200] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\n{function zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n}\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]2 then n:=1;\nwrite(n);\nend."}, {"source_code": "var x:word;begin read(x);if x=2 then write(2)else write(1);end."}, {"source_code": "var\n n:longint;\n begin\n read(n);\n if n=2 then write(2)\n else write(1);\n end."}, {"source_code": "var n : longint;\nbegin\n readln(n);\n if n = 0 then writeln(0) else\n begin\n if n = 2 then writeln(2) else writeln(1);\n end;\nend."}, {"source_code": "var\n n:int64;\nbegin\n readln(n);\n if n=2 then writeln(2)\n else writeln(1);\nend."}, {"source_code": "var\n a:longint;\nbegin\n readln(a);\n if a=2 then writeln(a)\n else writeln(1);\nend."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n if n=2 then write(2)\n else write(1);\nend."}, {"source_code": "var\n n:int64;\nbegin\n readln(n);\n if n=2 then writeln(2) else writeln(1);\nend."}], "negative_code": [{"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul=1000000007{998244353} ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n numx,numy,xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..535002] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4400,-1..4200] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\n{function zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n}\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]=2 then\n writeln(1)\n else \n writeln(v);\n \nend."}, {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\ts: string;\n\t\nbegin\n\n\treadln(n);\n\tif (n >= 3) then\n\t\twriteln(1)\n\telse writeln(2);\n\t\n\t\nend.\n"}, {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\ts: string;\n\t\nbegin\n\n\treadln(n);\n\tif (n >= 3) then\n\t\twriteln(n)\n\telse writeln(2);\n\t\n\t\nend.\n"}, {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\ts: string;\n\t\nbegin\n\n\treadln(n);\n\twriteln(1);\n\t\nend.\n"}, {"source_code": "var a:string;\nbegin\nread(a);\nwrite(1)\nend."}, {"source_code": "\nvar\n a, i, b, c, d, f, h, p, m, n, k, code: int64;\n\n\nbegin\n readln(n);\nwriteln('1');\n\n\n\n\n\n \nend."}, {"source_code": "begin\nwrite('1');\nend."}, {"source_code": "Var\n n: UInt64;\n \nBegin\n If n = 2 then\n Write(2)\n Else\n Write(1)\nEnd."}, {"source_code": "Var\n n: Uint64;\n \nBegin\n If (n = 1) or (n = 2) then\n Write(n)\n Else\n Write(1)\nEnd."}, {"source_code": "var n:integer;\nbegin\nreadln(n);\nwriteln('1');\nend."}, {"source_code": "var n:int64;\nbegin\nreadln(n);\nwriteln('1');\nend."}, {"source_code": "var a,b,c:integer;\nbegin\nreadln(a);\nwriteln(1);\n\nend."}, {"source_code": "var n, x, k, v: int64;\nbegin\nreadln (v);\n if v <> 0 then \n write ('1') else write ('0');\n\n\n\nend."}, {"source_code": "var n, x, k, v: int64;\nbegin\nreadln (v);\n write ('1') ;\n\n\n\nend."}], "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d"} {"source_code": "{$R+}{$Q+}\nVar v,rez,j,kol,i,n:longint;\ndp,m:array [1..100] of int64;\na:array [1..1000000] of int64;\nused:array [2..1000000] of boolean;\nused2:array [1..8] of boolean;\nfunction proverka(n:int64):boolean;\nVar i:longint;\nbegin\n for i:=1 to kol do\n if (n mod a[i]=0)and(n<>a[i])\n then begin proverka:=false; exit; end;\n proverka:=true;\nend;\nfunction probeg(n:int64):longint;\nVar rez,i:longint;\nbegin\n rez:=0;\n for i:=1 to kol do\n begin\n while n mod a[i]=0 do\n begin\n inc(rez);\n n:=n div a[i];\n end;\n end;\n if n<>1\n then inc(rez);\n probeg:=rez;\nend;\nprocedure reverse(z:longint);\nVar i,j:longint;\nb:int64;\nbegin\n i:=1; j:=z;\n while i2)\n then if i1\n then inc(b);\n if b x do Inc (i);\n while A[j] < x do Dec (j);\n if i <= j then\n begin\n tmp := A[i];\n A[i] := A[j];\n A[j] := tmp;\n tmp := luu[i];\n luu[i] := luu[j];\n luu[j] := tmp;\n Inc (i);\n Dec (j);\n end;\n Until i > j;\n if Left < j then Sort (Left , j);\n if i < Right then Sort (i , Right);\n End;\nProcedure Tries (x , y : Int64);\n Var\n i : Longint;\n tmp : Int64;\n Begin\n if A[x] = A[x-1] then\n begin\n Tries (x + 1 , y);\n Exit;\n end;\n if x > n then\n begin\n tmp := y;\n if not kt then Inc (tmp);\n if tmp < kq then kq := tmp;\n Exit;\n end;\n pre[x] := A[x];\n for i := 1 to x - 1 do\n if (pre[i] Mod A[x]) = 0 then\n begin\n tmp := y;\n if luu[x] <> 1 then tmp := y + 1;\n pre[i] := pre[i] Div A[x];\n Tries (x + 1 , tmp);\n pre[i] := pre[i] * A[x];\n end;\n kt := False;\n tmp := y + luu[x];\n if luu[x] <> 1 then Inc (tmp);\n Tries (x + 1 , tmp);\n End;\nProcedure Programe;\n Var\n i , j : Longint;\n dem , tmp : Int64;\n Begin\n readln (n);\n for i := 1 to n do read (A[i]);\n fillchar (free , sizeof(free) , True);\n free[1] := False;\n for i := 2 to n do\n begin\n if free[i] then\n for j:=2 to (1000000 Div i) do\n free[i * j] := False;\n end;\n for i := 1 to n do\n begin\n tmp := A[i];\n dem := 0;\n for j := 1 to 1000000 do\n begin\n if j > tmp then Break;\n if not free[j] then Continue;\n while (tmp Mod j) = 0 do\n begin\n tmp := tmp Div j;\n Inc (dem);\n end;\n end;\n if tmp <> 1 then Inc (dem);\n luu[i] := dem;\n end;\n Sort (1 , n);\n kq := 1000000000000000000;\n kt := True;\n pre[1] := A[1];\n if luu[1] = 1 then Tries (2 , luu[1])\n else Tries (2 , luu[1] + 1);\n writeln (kq);\n End;\nProcedure Finish;\n Begin\n Close (input);\n Close (output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd."}, {"source_code": "var i,j,k,n:longint;\n p,q,l,ans:int64;\n u:boolean;\n a,b,now:array[0..10]of int64;\n f:array[1..1000000]of boolean;\nprocedure dfs(x,y:longint);\nvar i,w:longint;\nbegin\n if x>n then\n begin\n w:=y;\n if not u then w:=w+1;\n if w1 then w:=y+1;\n now[i]:=now[i] div a[x];\n dfs(x+1,w);\n now[i]:=now[i]*a[x];\n end;\n end;\n\n if x>1 then u:=false;\n w:=y+b[x];\n if b[x]<>1 then w:=w+1;\n dfs(x+1,w);\n end;\nend;\nprocedure sushu;\nbegin\n fillchar(f,sizeof(f),true);\n f[1]:=false;\n for i:=2 to n do\n begin\n if f[i] then\n\n for j:=2 to 1000000 div i do f[i*j]:=false;\n end;\n\nend;\nprocedure paixu;\nbegin\n for i:=1 to n do\n for j:=1 to n-i do\n begin\n if a[j]q then break;\n if not f[j] then continue;\n while q mod j=0 do\n begin\n q:=q div j;\n p:=p+1;\n end;\n end;\n if q<>1 then p:=p+1;\n b[i]:=p;\n end;\nend;\nprocedure solve;\nbegin\n ans:=maxlongint;\n u:=true;\n dfs(1,0);\n writeln(ans);\nend;\nbegin\n duru;\n sushu;\n paixu;\n work;\n solve;\nend.\n"}, {"source_code": "var n,i,j,k,m:integer;\na:array [1..8] of int64;\nb:array [1..8] of integer;\nz,x:int64;\nc:array [1..8,0..50] of integer;\nd:array [1..8] of int64;\n\nfunction res():integer;\nvar i,j,p:integer;\nbegin\n\nfor i:=1 to n do d[i]:=a[i];\nfor i:=2 to n do\n begin\n if b[i]>0 then\n begin\n if d[b[i]] mod a[i]=0 then d[b[i]]:=d[b[i]] div a[i] else\n begin\n res:=1000000001;\n exit;\n end;\n end;\n end;\np:=0;\nfor i:=2 to n do\n if b[i]=0 then p:=1;\np+=c[1,0]+1;\nfor i:=2 to n do\n if b[i]=0 then p+=c[i,0]+1 else\n begin\n if c[i,0]>0 then p+=1;\n end;\nres:=p;\n\nend;\n\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do\n for j:=1 to n-i do\n begin\n if a[j]1 then\n begin\n c[i,0]+=1;\n c[i,c[i,0]]:=x;\n end;\n end;\nfor i:=1 to n do\n if c[i,0]=1 then c[i,0]:=0;\nif n=1 then\n begin\n writeln(1+c[1,0]);\n halt;\n end;\nm:=1000000000;\nfor i:=2 to n do\n begin\n b[i]:=0;\n end;\nb[n]:=-1;\nwhile true do\n begin\n k:=n;\n while (b[k]=k-1) and (k>1) do k-=1;\n if k=1 then break;\n b[k]+=1;\n for i:=k+1 to n do b[i]:=0;\n k:=res();\n{ if k<100000 then\n begin\n for i:=2 to n do write(b[i],' ');\n writeln(k);\n end;\n} if k1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (not ffff[i]) then\n inc(p);\n if (p>1) then\n inc(ans);\n end;\n if (ans=24)and(k<>4) then\n ans:=ans-1;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "Program cf196c;\nConst\n Infile='';\n Outfile='';\nVar\n dq1,dq2,max,dq,now,sum,n,zs,lq:Int64;\n i,j:Longint;\n q:Array[0..1000000] Of Longint;\n a,v,a1:Array[0..10] Of Int64;\n flag:Array[0..1000000] Of Boolean;\nProcedure Dfs(x:Longint);\nVar\n i,dq:Longint;\nBegin\n If (X=n+1) Then Begin\n // Writeln(dq1,dq2);\n If dq2>1 Then dq:=dq1-1 Else dq:=dq1;\n If dq>max Then max:=dq;\n // Writeln(max);\n Exit;\n End;\n For i:=1 To n Do If (i<>x) And (a1[i] Mod a[x]=0) Then Begin\n a1[i]:=a1[i] Div a[x];\n dq1:=dq1+v[x];Dec(dq2);\n Dfs(x+1);\n dq1:=dq1-v[x];Inc(dq2);\n a1[i]:=a1[i]*a[x];\n End;\n Dfs(x+1);\nEnd;\nBegin\n Assign(Input,Infile);\n Assign(Output,Outfile);\n Reset(Input);\n Rewrite(Output);\n Readln(n);\n For i:=1 To n Do Read(a[i]);\n lq:=0;\n Fillchar(flag,Sizeof(flag),False);\n For i:=2 To 1000000 Do Begin\n If Not flag[i] Then Begin\n Inc(lq);\n q[lq]:=i;\n j:=i;\n While (j<=1000000) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n For i:=1 To n Do Begin\n dq:=a[i];\n now:=0;\n For j:=1 To lq Do Begin\n While (dq Mod q[j]=0) Do Begin\n Inc(now);\n dq:=dq Div q[j];\n // WRiteln(dq);\n End;\n End;\n If dq>1 Then Inc(now);\n v[i]:=now;\n sum:=sum+v[i];\n End;\n max:=-1;dq1:=0;dq2:=n;\n For i:=1 To n Do a1[i]:=a[i];\n Dfs(1);\n For i:=1 To n Do If v[i]=1 Then Inc(zs);\n //Writeln(sum,' ',n,' ',zs);\n Writeln(sum+n-zs-max);\n Close(Input);\n Close(Output);\nEnd."}, {"source_code": "const l=1000000;\nvar\n a,b:array[1..8] of int64; pr:array[1..l] of int64; used:array[1..l] of boolean;\n ok:array[1..8] of boolean; ans,n,i,j,k:longint; w,x,y:int64;\n\n\nfunction find(r:longint):longint;\nvar res,i:longint; x:int64;\nbegin\n res:=0; i:=1; x:=a[r];\n while (pr[i]*pr[i]<=x) and (i<=k) do\n begin\n while (x mod pr[i]=0) do begin inc(res); x:=x div pr[i]; end;\n inc(i);\n end;\n if (x<>1) then if (res=0) then ok[r]:=true else inc(res);\n find:=res;\nend;\n\n\nprocedure rec(nom,ost,rt:longint);\nvar i:longint;\nbegin\n if (nom=n+1) then\n begin\n if (rt>1) then inc(ost); ost:=ost+n;\n if (ans>ost) then ans:=ost; exit;\n end;\n rec(nom+1,ost,rt+1);\n for i:=nom-1 downto 1 do\n if (a[i] mod a[nom]=0) then\n begin\n a[i]:=a[i] div a[nom];\n if (ok[nom]) then rec(nom+1,ost-1,rt) else rec(nom+1,ost-b[nom],rt);\n a[i]:=a[i]*a[nom];\n end;\nend;\n\n\nbegin\n readln(n); for i:=1 to n do read(a[i]);\n for i:=1 to n do for j:=i+1 to n do\n if (a[i] x do Inc (i);\n while A[j] < x do Dec (j);\n if i <= j then\n begin\n tmp := A[i];\n A[i] := A[j];\n A[j] := tmp;\n tmp := luu[i];\n luu[i] := luu[j];\n luu[j] := tmp;\n Inc (i);\n Dec (j);\n end;\n Until i > j;\n if Left < j then Sort (Left , j);\n if i < Right then Sort (i , Right);\n End;\nProcedure Tries (x , y : Int64);\n Var\n i : Longint;\n tmp : Int64;\n Begin\n if A[x] = A[x-1] then\n begin\n Tries (x + 1 , y);\n Exit;\n end;\n if x > n then\n begin\n tmp := y;\n if not kt then Inc (tmp);\n if tmp < kq then kq := tmp;\n Exit;\n end;\n pre[x] := A[x];\n for i := 1 to x - 1 do\n if (pre[i] Mod A[x]) = 0 then\n begin\n tmp := y;\n if luu[x] <> 1 then tmp := y + 1;\n pre[i] := pre[i] Div A[x];\n Tries (x + 1 , tmp);\n pre[i] := pre[i] * A[x];\n end;\n kt := False;\n tmp := y + luu[x];\n if luu[x] <> 1 then Inc (tmp);\n Tries (x + 1 , tmp);\n End;\nProcedure Programe;\n Var\n i , j : Longint;\n dem , tmp : Int64;\n Begin\n readln (n);\n for i := 1 to n do read (A[i]);\n fillchar (free , sizeof(free) , True);\n free[1] := False;\n for i := 2 to n do\n begin\n if free[i] then\n for j:=2 to (1000000 Div i) do\n free[i * j] := False;\n end;\n for i := 1 to n do\n begin\n tmp := A[i];\n dem := 0;\n for j := 1 to 1000000 do\n begin\n if j > tmp then Break;\n if not free[j] then Continue;\n while (tmp Mod j) = 0 do\n begin\n tmp := tmp Div j;\n Inc (dem);\n end;\n end;\n if tmp <> 1 then Inc (dem);\n luu[i] := dem;\n end;\n Sort (1 , n);\n kq := 1000000000000000000;\n kt := True;\n pre[1] := A[1];\n if luu[1] = 1 then Tries (2 , luu[1])\n else Tries (2 , luu[1] + 1);\n writeln (kq);\n End;\nProcedure Finish;\n Begin\n Close (input);\n Close (output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd."}, {"source_code": "//writen by zscnash\nProgram cf196c;\n\nConst\n\n Infile='';\n\n Outfile='';\n\nVar\n\n dq1,dq2,max,dq,now,sum,n,zs,lq:Int64;\n\n i,j:Longint;\n\n q:Array[0..1000000] Of Longint;\n\n a,v,a1:Array[0..10] Of Int64;\n\n flag:Array[0..1000000] Of Boolean;\n\nProcedure Dfs(x:Longint);\n\nVar\n\n i,dq:Longint;\n\nBegin\n\n If (X=n+1) Then Begin\n\n // Writeln(dq1,dq2);\n\n If dq2>1 Then dq:=dq1-1 Else dq:=dq1;\n\n If dq>max Then max:=dq;\n\n // Writeln(max);\n\n Exit;\n\n End;\n\n For i:=1 To n Do If (i<>x) And (a1[i] Mod a[x]=0) Then Begin\n\n a1[i]:=a1[i] Div a[x];\n\n dq1:=dq1+v[x];Dec(dq2);\n\n Dfs(x+1);\n\n dq1:=dq1-v[x];Inc(dq2);\n\n a1[i]:=a1[i]*a[x];\n\n End;\n\n Dfs(x+1);\n\nEnd;\n\nBegin\n\n Assign(Input,Infile);\n\n Assign(Output,Outfile);\n\n Reset(Input);\n\n Rewrite(Output);\n\n Readln(n);\n\n For i:=1 To n Do Read(a[i]);\n\n lq:=0;\n\n Fillchar(flag,Sizeof(flag),False);\n\n For i:=2 To 1000000 Do Begin\n\n If Not flag[i] Then Begin\n\n Inc(lq);\n\n q[lq]:=i;\n\n j:=i;\n\n While (j<=1000000) Do Begin\n\n flag[j]:=True;\n\n j:=j+i;\n\n End;\n\n End;\n\n End;\n\n For i:=1 To n Do Begin\n\n dq:=a[i];\n\n now:=0;\n\n For j:=1 To lq Do Begin\n\n While (dq Mod q[j]=0) Do Begin\n\n Inc(now);\n\n dq:=dq Div q[j];\n\n // WRiteln(dq);\n\n End;\n\n End;\n\n If dq>1 Then Inc(now);\n\n v[i]:=now;\n\n sum:=sum+v[i];\n\n End;\n\n max:=-1;dq1:=0;dq2:=n;\n\n For i:=1 To n Do a1[i]:=a[i];\n\n Dfs(1);\n\n For i:=1 To n Do If v[i]=1 Then Inc(zs);\n\n //Writeln(sum,' ',n,' ',zs);\n\n Writeln(sum+n-zs-max);\n\n Close(Input);\n\n Close(Output);\n\nEnd."}, {"source_code": "{$R+}{$Q+}\nVar v,rez,j,kol,i,n:longint;\ndp,m:array [1..100] of int64;\na:array [1..1000000] of int64;\nused:array [2..1000000] of boolean;\nused2:array [1..8] of boolean;\nfunction proverka(n:int64):boolean;\nVar i:longint;\nbegin\n for i:=1 to kol do\n if (n mod a[i]=0)and(n<>a[i])\n then begin proverka:=false; exit; end;\n proverka:=true;\nend;\nfunction probeg(n:int64):longint;\nVar rez,i:longint;\nbegin\n rez:=0;\n for i:=1 to kol do\n begin\n while n mod a[i]=0 do\n begin\n inc(rez);\n n:=n div a[i];\n end;\n end;\n if n<>1\n then inc(rez);\n probeg:=rez;\nend;\nprocedure reverse(z:longint);\nVar i,j:longint;\nb:int64;\nbegin\n i:=1; j:=z;\n while i2)\n then if i1\n then inc(b);\n if bn then\n begin\n w:=y;\n if not u then w:=w+1;\n if w1 then\n w:=y+1;\n now[i]:=now[i] div a[x];\n dfs(x+1,w);\n now[i]:=now[i]*a[x];\n end;\n end;\n u:=false;\n w:=y+b[x];\n if b[x]<>1 then w:=w+1;\n dfs(x+1,w);\nend;\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n fillchar(f,sizeof(f),true);\n f[1]:=false;\n for i:=2 to n do\n begin\n if f[i] then\n for j:=2 to 1000000 div i do f[i*j]:=false;\n end;\n\n for i:=1 to n do\n begin\n q:=a[i];\n p:=0;\n for j:=1 to 1000000 do\n begin\n if j>q then break;\n if not f[j] then continue;\n while q mod j=0 do\n begin\n q:=q div j;\n p:=p+1;\n end;\n end;\n if q<>1 then p:=p+1;\n b[i]:=p;\n end;\n for i:=1 to n do\n begin\n for j:=1 to n-i do\n begin\n if a[j]x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then\n begin\n writeln(11);\n halt;\n end;\n if(n=8)and(ans=14)and(a[n-1]=7) then ans:=11;\n if (ans=24)and(n=8) then dec(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n"}], "negative_code": [{"source_code": "{$R+}{$Q+}\nVar rez,zz,j,kol,i,n:longint;\nm:array [1..100] of int64;\na:array [1..1000000] of int64;\nz:int64;\nused:array [2..1000000] of boolean;\nused2:array [1..100] of boolean;\nprocedure sort(n:longint);\nVar f:boolean;\nb:int64;\ni:longint;\nbegin\n repeat\n f:=true;\n for i:=1 to n-1 do\n if m[i]>m[i+1]\n then begin\n f:=false;\n b:=m[i]; m[i]:=m[i+1]; m[i+1]:=b;\n end;\n dec(n);\n until f;\nend;\nfunction proverka(n:int64):boolean;\nVar i:longint;\nbegin\n for i:=1 to kol do\n if (n mod a[i]=0)and(n<>a[i])\n then begin proverka:=false; exit; end;\n proverka:=true;\nend;\nfunction probeg(n:int64):longint;\nVar rez,i:longint;\nbegin\n rez:=0;\n for i:=1 to kol do\n begin\n while n mod a[i]=0 do\n begin\n inc(rez);\n n:=n div a[i];\n end;\n end;\n if n<>1\n then inc(rez);\n probeg:=rez;\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(n);\n for i:=1 to n do\n read(m[i]);\n sort(n);\n kol:=0;\n for i:=2 to 1000000 do\n if not used[i]\n then begin\n inc(kol);\n a[kol]:=i;\n j:=i;\n while j<=1000000 do\n begin\n used[j]:=true;\n inc(j,i);\n end;\n end;\n rez:=0;\n for i:=1 to n do\n begin\n z:=m[i];\n for j:=i-1 downto 1 do\n if (not used2[j])and(z mod m[j]=0)\n then begin\n used2[j]:=true;\n z:=z div m[j];\n end;\n if m[i]=z\n then begin\n if proverka(z)\n then inc(rez)\n else rez:=rez+probeg(z)+1;\n end\n else rez:=rez+probeg(z)+1;\n end;\n zz:=0;\n for i:=1 to n do\n if not used2[i]\n then inc(zz);\n if zz>1\n then inc(rez);\n writeln(rez);\nend."}, {"source_code": "Var rez,j,kol,i,n:longint;\ndp,m:array [1..100] of int64;\na:array [1..1000000] of int64;\nused:array [2..1000000] of boolean;\nused2:array [1..100] of boolean;\nfunction proverka(n:int64):boolean;\nVar i:longint;\nbegin\n for i:=1 to kol do\n if (n mod a[i]=0)and(n<>a[i])\n then begin proverka:=false; exit; end;\n proverka:=true;\nend;\nfunction probeg(n:int64):longint;\nVar rez,i:longint;\nbegin\n rez:=0;\n for i:=1 to kol do\n begin\n while n mod a[i]=0 do\n begin\n inc(rez);\n n:=n div a[i];\n end;\n end;\n if n<>1\n then inc(rez);\n probeg:=rez;\nend;\nprocedure reverse(z:longint);\nVar i,j:longint;\nb:int64;\nbegin\n i:=1; j:=z;\n while i1\n then inc(b);\n if bm[i+1]\n then begin\n f:=false;\n b:=m[i]; m[i]:=m[i+1]; m[i+1]:=b;\n end;\n dec(n);\n until f;\nend;\nfunction proverka(n:int64):boolean;\nVar i:longint;\nbegin\n for i:=1 to kol do\n if (n mod a[i]=0)and(n<>a[i])\n then begin proverka:=false; exit; end;\n proverka:=true;\nend;\nfunction probeg(n:int64):longint;\nVar rez,i:longint;\nbegin\n rez:=0;\n for i:=1 to kol do\n begin\n while n mod a[i]=0 do\n begin\n inc(rez);\n n:=n div a[i];\n end;\n end;\n if n<>1\n then inc(rez);\n probeg:=rez;\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(n);\n for i:=1 to n do\n read(m[i]);\n sort(n);\n kol:=0;\n for i:=2 to 1000000 do\n if not used[i]\n then begin\n inc(kol);\n a[kol]:=i;\n j:=i;\n while j<=1000000 do\n begin\n used[j]:=true;\n inc(j,i);\n end;\n end;\n rez:=0;\n for i:=1 to n do\n begin\n z:=m[i];\n for j:=i-1 downto 1 do\n if (not used2[j])and(z mod m[j]=0)\n then begin\n used2[j]:=true;\n z:=z div m[j];\n end;\n if m[i]=z\n then begin\n if proverka(z)\n then inc(rez)\n else rez:=rez+probeg(z)+1;\n end\n else rez:=rez+probeg(z)+1;\n end;\n for i:=1 to n do\n if not used2[i]\n then inc(rez);\n writeln(rez-1);\nend."}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then\n begin\n writeln(11);\n halt;\n end;\n if(n=8)and(ans=14)and(a[n]=2) then ans:=11;\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then \n begin \n writeln(11); \n halt;\n end;\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend."}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then\n begin\n writeln(11);\n halt;\n end;\n if(n=8)and(ans=14)and(a[n-1]=7) then ans:=11;\n if (ans=24)and(n<>1) then dec(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10,0..1000]of longint;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1) then\n begin\n now:=now div a[j];\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if(n=5) and(ans=12)then dec(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of longint;\n q:array[0..10,0..1000]of longint;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i)and(x<>j) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k,now:longint;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1) then\n begin\n now:=now div a[j];\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n if num>1 then inc(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then\n begin\n writeln(11);\n halt;\n end;\n if(n=8)and(ans=14)and(a[n-1]=7) then ans:=11;\n if (ans=23)and(n<>1) then inc(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of int64;\n q:array[0..10]of boolean;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k:longint;\n now:int64;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n if su(now) then\n begin\n inc(ans);\n continue;\n end\n else begin\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1)and(not q[j]) then\n begin\n now:=now div a[j];\n q[j]:=true;\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n end;\n if num>1 then inc(ans);\n if (n=5) and(ans=12)then\n begin\n writeln(11);\n halt;\n end;\n if(n=8)and(ans=14)and(a[n-1]=7) then ans:=11;\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n"}, {"source_code": "var\n n,ans,num:longint;\n a:array[0..10]of longint;\n q:array[0..10,0..1000]of longint;\n sum:longint;\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=i) then inc(sum);\n ans:=ans+sum;\nend;\nprocedure solve;\nvar\n i,j,k,now:longint;\nbegin\n num:=n;\n for i:=1 to n do\n begin\n now:=a[i];\n for j:=i+1 to n do\n begin\n if (now mod a[j]=0)and(now div a[j]<>1) then\n begin\n now:=now div a[j];\n dec(num);\n end\n end;\n if now>1 then\n begin\n fen(now);\n inc(ans);\n end;\n end;\n if num>1 then inc(ans);\n writeln(ans);\nend;\nbegin\n init;\n solve;\nend.\n\n"}, {"source_code": "var n,i,j,k,m:integer;\na:array [1..8] of int64;\nb:array [1..8] of integer;\nz,x:int64;\nc:array [1..8,0..50] of integer;\nd:array [1..8] of int64;\n\nfunction res():integer;\nvar i,j,p:integer;\nbegin\n\nfor i:=1 to n do d[i]:=a[i];\nfor i:=2 to n do\n begin\n if b[i]>0 then\n begin\n if d[b[i]] mod a[i]=0 then d[b[i]]:=d[b[i]] div a[i] else\n begin\n res:=1000000001;\n exit;\n end;\n end;\n end;\np:=0;\nfor i:=2 to n do\n if b[i]=0 then p:=1;\np+=c[1,0]+1;\nfor i:=2 to n do\n if b[i]=0 then p+=c[i,0]+1 else p+=1;\nres:=p;\n\nend;\n\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do\n for j:=1 to n-i do\n begin\n if a[i]1 then\n begin\n c[i,0]+=1;\n c[i,c[i,0]]:=x;\n end;\n end;\nfor i:=1 to n do\n if c[i,0]=1 then c[i,0]:=0;\nif n=1 then\n begin\n writeln(1+c[1,0]);\n halt;\n end;\nm:=1000000000;\nfor i:=2 to n do\n begin\n b[i]:=0;\n end;\nb[n]:=-1;\nwhile true do\n begin\n k:=n;\n while (b[k]=k-1) and (k>1) do k-=1;\n if k=1 then break;\n b[k]+=1;\n for i:=k+1 to n do b[i]:=0;\n k:=res();\n //for i:=2 to n do write(b[i],' ');\n //writeln(k);\n if k1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (a[i]<>1)and(not ff[i]) then\n inc(p);\n if p>=1 then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\n ffff:array[1..8]of boolean;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (ff[i])and(not ffff[i]) then\n inc(p);\n if (p>1)or(p=0) then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\n ffff:array[1..8]of boolean;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (a[i]<>1)and(not ff[i])and(not ffff[i]) then\n inc(p);\n if p>=1 then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\n ffff:array[1..8]of boolean;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (ff[i])and(not ffff[i]) then\n inc(p);\n if p>1 then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(a[j]<>1) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n a[j]:=1;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (a[i]<>1)and(not ff[i]) then\n inc(p);\n if p>=1 then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\n ffff:array[1..8]of boolean;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (not ffff[i]) then\n inc(p);\n if (p>1) then\n inc(ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "\nvar\n f,ff:array[1..8]of boolean;\n a,zs:array[1..8]of int64;\n n,i,j,p,ans,gha,m,k:longint;\n aa:int64;\n fff:boolean;\n pp,t:int64;\n ffff:array[1..8]of boolean;\nbegin\n//assign(input,'wmrwnzdn.in');\n //assign(output,'wmrwnzdn.out');\n //reset(input);\n //rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n fff:=false;\n p:=0;\n read(pp);\n for j:=1 to k do\n if pp=a[j] then\n fff:=true;\n if not fff then\n begin\n inc(k);\n a[k]:=pp;\n aa:=1;\n gha:=trunc(sqrt(a[i]));\n for j:=2 to gha do\n if a[k] mod j=0 then\n begin\n f[k]:=true;\n\n break;\n end;\n if f[k] then\n begin\n\n aa:=a[k];\n for j:=2 to gha do\n begin\n while aa mod j=0 do\n begin\n aa:=aa div j;\n inc(p);\n end;\n if aa=1 then\n break;\n end;\n end;\n if (aa<>1)and(aa<>a[k]) then\n inc(p);\n zs[k]:=p;\n\n end;\n end;\n for i:=1 to k do\n ans:=ans+zs[i]+1;\n for i:=1 to k-1 do\n for j:=i+1 to k do\n if a[i]j) and (a[i] mod a[j]=0) and(not ffff[j]) then\n begin\n if zs[j]=0 then\n ans:=ans-1 else\n ans:=ans-zs[j];\n a[i]:=a[i] div a[j];\n ffff[j]:=true;\n ff[i]:=true;\n end;\n p:=0;\n if k>1 then\n begin\n for i:=1 to k do\n if (not ffff[i]) then\n inc(p);\n if (p>1) then\n inc(ans);\n end;\n if ans=24 then\n ans:=ans-1;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "Program cf196c;\nConst\n Infile='';\n Outfile='';\nVar\n dq1,dq2,max,dq,now,i,j,sum,n,zs,lq:Longint;\n q:Array[0..1000000] Of Longint;\n a,v,a1:Array[0..10] Of Int64;\n flag:Array[0..1000000] Of Boolean;\nProcedure Dfs(x:Longint);\nVar\n i,dq:Longint;\nBegin\n If (X=n+1) Then Begin\n // Writeln(dq1,dq2);\n If dq2>1 Then dq:=dq1-1 Else dq:=dq1;\n If dq>max Then max:=dq;\n // Writeln(max);\n Exit;\n End;\n For i:=1 To n Do If (i<>x) And (a1[i] Mod a[x]=0) Then Begin\n a1[i]:=a1[i] Div a[x];\n dq1:=dq1+v[x];Dec(dq2);\n Dfs(x+1);\n dq1:=dq1-v[x];Inc(dq2);\n a1[i]:=a1[i]*a[x];\n End;\n Dfs(x+1);\nEnd;\nBegin\n Assign(Input,Infile);\n Assign(Output,Outfile);\n Reset(Input);\n Rewrite(Output);\n Readln(n);\n For i:=1 To n Do Read(a[i]);\n lq:=0;\n Fillchar(flag,Sizeof(flag),False);\n For i:=2 To 1000000 Do Begin\n If Not flag[i] Then Begin\n Inc(lq);\n q[lq]:=i;\n j:=i;\n While (j<=1000000) Do Begin\n flag[j]:=True;\n j:=j+i;\n End;\n End;\n End;\n For i:=1 To n Do Begin\n dq:=a[i];\n now:=0;\n For j:=1 To lq Do Begin\n While (dq Mod q[j]=0) Do Begin\n Inc(now);\n dq:=dq Div q[j];\n End;\n End;\n If dq>1 Then Inc(now);\n v[i]:=now;\n sum:=sum+v[i];\n End;\n max:=-1;dq1:=0;dq2:=n;\n For i:=1 To n Do a1[i]:=a[i];\n Dfs(1);\n For i:=1 To n Do If v[i]=1 Then Inc(zs);\n Writeln(sum+n-zs-max);\n Close(Input);\n Close(Output);\nEnd."}, {"source_code": "const l=1000000;\nvar\n a,b:array[1..8] of int64; pr:array[1..l] of int64; used:array[1..l] of boolean;\n ans,n,i,j,k:longint; w,x,y:int64;\n\n\nfunction find(x:int64):longint;\nvar res,i:longint;\nbegin\n res:=0; i:=1;\n while (pr[i]*pr[i]<=x) and (i<=k) do\n begin\n while (x mod pr[i]=0) do begin inc(res); x:=x div pr[i]; end;\n inc(i);\n end;\n if (res<>0) and (x<>1) then inc(res);\n find:=res;\nend;\n\n\nprocedure rec(nom,ost,rt:longint);\nvar i:longint;\nbegin\n if (nom=n+1) then\n begin\n if (rt>1) then inc(ost); ost:=ost+n;\n if (ans>ost) then ans:=ost; exit;\n end;\n rec(nom+1,ost,rt+1);\n for i:=nom-1 downto 1 do\n if (a[i] mod a[nom]=0) then\n begin\n a[i]:=a[i] div a[nom];\n rec(nom+1,ost-b[nom],rt);\n a[i]:=a[i]*a[nom];\n end;\nend;\n\n\nbegin\n readln(n); for i:=1 to n do read(a[i]);\n for i:=1 to n do for j:=i+1 to n do\n if (a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l= powx[i-1]\n then powx[i]:=powx[i-1]*x\n else powx[i]:=inf;\n {for i:=1 to 60 do\n write(powx[i],' ');\n writeln;}\n powy[0]:=1;\n for i:=1 to 60 do\n if r div y >= powy[i-1]\n then powy[i]:=powy[i-1]*y\n else powy[i]:=inf;\n {for i:=1 to 60 do\n write(powy[i],' ');\n writeln;}\n n:=2;\n a[1]:=l-1;\n a[2]:=r+1;\n for i:=0 to 60 do\n begin\n if powx[i]>r then break;\n for j:=0 to 60 do\n begin\n if powx[i]+powy[j]r then break;\n inc(n);\n a[n]:=powx[i]+powy[j]\n end;\n end;\n sort(1,n);\n {for i:=1 to n do\n write(a[i],' ');\n writeln;}\n m:=0;\n for i:=1 to n-1 do\n begin\n //if mj) then\n begin\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lr then break;\n w:=w+1;a[w]:=a[w-1]*x;\n end;\nb[0]:=1;\nfor i:=1 to trunc(ln(r)/ln(y)) do\n begin\n if b[i-1]*y>r then break;\n t:=t+1;b[t]:=b[t-1]*y;\n end;\nfor i:=0 to w do\n for j:=0 to t do\n if(a[i]>=l-b[j])and(a[i]<=r-b[j])then\n begin\n p:=p+1;c[p]:=a[i]+b[j];\n end;\nsort(1,p);\nif p=0 then writeln(r-l+1)\nelse\n begin\nfor i:=2 to p do\n if c[i]-c[i-1]-1>sum then sum:=c[i]-c[i-1]-1;\nif r-c[p]>sum then sum:=r-c[p];\nif c[1]-l>sum then sum:=c[1]-l;\nwriteln(sum);\nend;\nend."}, {"source_code": "\n const nn=6000; nnn=2000;eps=0.000000001; besk1=200000008;\n label 1,2;\n type { real=double;} {string=ansistring;}\n\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var q,p3,hmin,hmax,p1,p2,l,r,pos,t,kolx,kolo,ot,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,prost,besk:int64;\n step, t1,ii,i,tt,j:longint;\n ll,rr,xx,yy,time,aa,bb,cc:extended;\n sss:array[-10..10000] of char;\n sssnew:array[-10..1000] of char;\n c,d,x,y,a,b:array[-100000..2000000] of int64;\n mask,dda,ddb:array[-10..120,-10..120] of int64;\n ss1,ss2:string;\n pole:array[-1..200,-1..200] of char;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx1,yy1:array[-1..nn] of double;\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(xx,yy,ll,rr);\n for i:=0 to 60 do for j:=0 to 60 do\n begin\n aa:=1;\n for step:=1 to i do aa:=aa*xx;\n bb:=1;\n for step:=1 to j do bb:=bb*yy;\n { writeln(aa+bb);\n } if (aa+bb>=ll)and(aa+bb<=rr) then\n begin inc(q); a[q]:=round(aa+bb); end;\n\n\n end;\n inc(q);a[q]:=round(ll-1); inc(q); a[q]:=round(rr+1);\n { for i:=1 to q do write(a[i],' '); writeln;\n } for i:=1 to q do for j:=1 to q-1 do if a[j]>a[j+1] then\n begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end;\n\n for i:=1 to q-1 do ot:=max(ot,a[i+1]-a[i]);\n writeln(max(ot-1,0));\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "const max1=trunc(1e18);\nvar x,y,l,r:qword;\n a:array[0..36000]of int64;\n\nprocedure nhap;\nbegin\n readln(x,y,l,r);\nend;\n\nfunction mu(x,i:int64):qword;\nvar gt1:qword;\n j:longint;\nbegin\n gt1:=1;\n for j:=1 to i do\n begin\n if (max1/gt1)>x then gt1:=gt1*x\n else exit(0);\n end;\n exit(gt1);\nend;\n\nprocedure swap(var g,h:int64);\nvar temp:int64;\nbegin\n temp:=g;\n g:=h;\n h:=temp;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint; mid:int64;\nbegin\n i:=l;\n j:=r;\n mid:=a[(l+r)div 2];\n repeat\n while a[i]mid do dec(j);\n if not(i>j) then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if i=q then\n if max1-q>=p then\n if (p<>0) and (q<>0) then\n begin\n if (p+q >=l) and (p+q <=r) then\n begin\n inc(cnt);\n a[cnt]:=p+q;\n end;\n end;\n end;\n sort(1,cnt);\n inc(cnt);\n a[cnt]:=r+1;\n max:=0 ;\n a[0]:=l;\n for i:=1 to cnt do\n begin\n if i=1 then z:=a[i]-a[i-1]\n else z:=a[i]-a[i-1]-1;\n if max=r then exit;\n i:=l; j:=r;\n x:=a[(i+j) div 2];\n repeat\n while a[i]x do dec(j);\n if i<=j then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i); dec(j);\n end;\n until i>j;\n sort(i,r);\n sort(l,j);\nend;\n\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\n readln(f,x,y,l,r);\n nx:=0; ex[0]:=1;\n if x>1 then\n while (r/ex[nx]>=x) do\n begin\n inc(nx);\n ex[nx]:=ex[nx-1]*x;\n end;\n ny:=0; ey[0]:=1;\n if y>1 then\n while (r/ey[ny]>=y) do\n begin\n inc(ny);\n ey[ny]:=ey[ny-1]*y;\n end;\n n:=0;\n for i:=0 to nx do\n for j:=0 to ny do\n begin\n t:=ex[i]+ey[j];\n if (l<=t) and (t<=r) then\n begin\n inc(n);\n a[n]:=t;\n end;\n end;\n sort(1,n);\n res:=0;\n a[0]:=l-1; a[n+1]:=r+1;\n for i:=0 to n do\n if a[i+1]-a[i]-1>res\n then res:=a[i+1]-a[i]-1;\n writeln(g,res);\n close(f);close(g);\nend.\n"}, {"source_code": "var x,y,l,r,max,f:int64;\n i,j,k,m,e:longint;\n px,py:array [0..1000] of int64;\n w:array [1..5000000] of int64;\nbegin\t\n\treadln(x,y,l,r);\n\tpx[0]:=1;\n\tpy[0]:=1;\n\ti:=0;\n\tj:=0;\n\trepeat \n\t\tinc(i);\n\t\tpx[i]:=px[i-1]*x;\n\tuntil (px[i]>r) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r)or (py[j]>1000000000000000000 div y);\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend;\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\tif e=0 then max:=r-l+1;\n\twriteln(max);\n\treadln;\nend.\t\t"}, {"source_code": "var x,y,l,r,max,f:int64;\n i,j,k,m,e:longint;\n px,py:array [0..1000] of int64;//int64\n w:array [1..5000000] of int64;\nbegin\t\n\treadln(x,y,l,r);\n\tpx[0]:=1;\n\tpy[0]:=1;\n\ti:=0;\n\tj:=0;\n\trepeat \n\t\tinc(i);\n\t\tpx[i]:=px[i-1]*x;\n\tuntil (px[i]>r) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r)or (py[j]>1000000000000000000 div y); //may exceed int64\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend;//don't break\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\tif e=0 then max:=r-l+1; //no unlucky year\n\twriteln(max);\n\treadln;\nend.\t\t"}, {"source_code": "uses math;\nconst fi=''; fo='';\nvar fin,fout:Text;\n a,b,l,r,tmp,res:int64; sta,stb:ansistring;\n i,j,n:longint;k:integer; ans:array[1..1000000] of int64;\nfunction nhohon(a,b:ansistring):boolean;\n begin\n while length(A)j) then\n begin\n y:=ans[i];\n ans[i]:=ans[j];\n ans[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then c:='1'+c;\nexit(c);\nend;\n\nfunction nhan(a:ansistring;b:int64):ansistring;\nvar i :integer;\ncarry,s :int64;\nc,tmp :ansistring;\nbegin\nc:='';\ncarry:=0;\nfor i:=length(a) downto 1 do\nbegin\ns:=(ord(a[i])-48) * b + carry;\ncarry:= s div 10;\nc:=chr(s mod 10 + 48)+c;\nend;\nif carry>0 then str(carry,tmp) else tmp:='';\nexit(tmp+c);\nend;\n\nbegin\n assign(Fin,fi);\n assign(Fout,fo);\n reset(Fin);rewrite(Fout);\n readln(Fin,a,b,l,r);\n str(a,sta);\n str(b,stb);\n n:=0;\n for i:=0 to 64 do\n begin\n if i=0 then sta:='1' else sta:=nhan(sta,a);\n for j:=0 to 64 do\n begin\n if (j=0) then stb:='1'\n else\n stb:=nhan(stb,b);\n if nhohon(cong(sta,stb),'1000000000000000004') then\n begin\n val(cong(sta,stb),tmp,k);\n if (tmp>=l) and (tmp<=r) then\n begin\n inc(n);\n ans[n]:=tmp;\n end;\n end\n else break;\n end;\n end;\n if n=0 then writeln(fout,r-l+1) else\n begin\n sort(1,n);\n res:=ans[1]-l;\n res:=max(res,r-ans[n]);\n\n for i:=2 to n do\n begin\n res:=max(res,ans[i]-ans[i-1]-1);\n end;\n writeln(fout,max(res,0));\n end;\n close(Fin);close(Fout);\nend.\n\n"}], "negative_code": [{"source_code": "{$macro+}\n{$define free}\n\n{$ifdef free}\nuses math;\n{$endif}\n\nconst\n inf=2000000000000000000;\n\nvar\n i,j:longint;\n x,y,l,r,n,m:int64;\n a:array[1..4000]of int64;\n powx,powy:array[0..60]of int64;\n\nprocedure sort(l,r: longint);\nvar\n i,j: longint;\n x,y: int64;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l= powx[i-1]\n then powx[i]:=powx[i-1]*x\n else powx[i]:=inf;\n {for i:=1 to 60 do\n write(powx[i],' ');\n writeln;}\n powy[0]:=1;\n for i:=1 to 60 do\n if r div y >= powy[i-1]\n then powy[i]:=powy[i-1]*y\n else powy[i]:=inf;\n {for i:=1 to 60 do\n write(powy[i],' ');\n writeln;}\n n:=2;\n a[1]:=l-1;\n a[2]:=r+1;\n for i:=0 to 60 do\n begin\n if powx[i]>r then break;\n for j:=0 to 60 do\n begin\n if powx[i]+powy[j]r then break;\n inc(n);\n a[n]:=powx[i]+powy[j]\n end;\n end;\n sort(1,n);\n {for i:=1 to n do\n write(a[i],' ');\n writeln;}\n m:=0;\n for i:=1 to n-1 do\n begin\n if mj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l= powx[i-1]\n then powx[i]:=powx[i-1]*x\n else powx[i]:=inf;\n {for i:=1 to 50 do\n write(powx[i],' ');\n writeln;}\n powy[0]:=1;\n for i:=1 to 50 do\n if r div y >= powy[i-1]\n then powy[i]:=powy[i-1]*y\n else powy[i]:=inf;\n {for i:=1 to 50 do\n write(powy[i],' ');\n writeln;}\n n:=2;\n a[1]:=l-1;\n a[2]:=r+1;\n for i:=0 to 50 do\n begin\n if powx[i]>r then break;\n for j:=0 to 50 do\n begin\n if powx[i]+powy[j]r then break;\n inc(n);\n a[n]:=powx[i]+powy[j]\n end;\n end;\n sort(1,n);\n {for i:=1 to n do\n write(a[i],' ');\n writeln;}\n m:=0;\n for i:=1 to n-1 do\n m:=max(m,a[i+1]-a[i]-1);\n writeln(m)\nend."}, {"source_code": "uses math;\nconst fi=''; fo='';\nvar fin,fout:Text;\n a,b,l,r,tmp,res:int64; sta,stb:ansistring;\n i,j,n:longint;k:integer; ans:array[1..1000000] of int64;\nfunction nhohon(a,b:ansistring):boolean;\n begin\n while length(A)j) then\n begin\n y:=ans[i];\n ans[i]:=ans[j];\n ans[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then c:='1'+c;\nexit(c);\nend;\n\nfunction nhan(a:ansistring;b:int64):ansistring;\nvar i :integer;\ncarry,s :int64;\nc,tmp :ansistring;\nbegin\nc:='';\ncarry:=0;\nfor i:=length(a) downto 1 do\nbegin\ns:=(ord(a[i])-48) * b + carry;\ncarry:= s div 10;\nc:=chr(s mod 10 + 48)+c;\nend;\nif carry>0 then str(carry,tmp) else tmp:='';\nexit(tmp+c);\nend;\n\nbegin\n assign(Fin,fi);\n assign(Fout,fo);\n reset(Fin);rewrite(Fout);\n readln(Fin,a,b,l,r);\n str(a,sta);\n str(b,stb);\n n:=0;\n for i:=0 to 64 do\n begin\n if i=0 then sta:='1' else sta:=nhan(sta,a);\n for j:=0 to 64 do\n begin\n if (j=0) then stb:='1'\n else\n stb:=nhan(stb,b);\n if nhohon(cong(sta,stb),'1000000000000000004') then\n begin\n val(cong(sta,stb),tmp,k);\n if (tmp>=l) and (tmp<=r) then\n begin\n inc(n);\n ans[n]:=tmp;\n end;\n end\n else break;\n end;\n end;\n\n sort(1,n);\n\n res:=ans[1]-l;\n res:=max(res,r-ans[n]);\n\n for i:=2 to n do\n begin\n res:=max(res,ans[i]-ans[i-1]-1);\n end;\n writeln(fout,max(res,0));\n close(Fin);close(Fout);\nend.\n\n"}, {"source_code": "uses math;\nconst fi=''; fo='';\nvar fin,fout:Text;\n a,b,l,r,tmp,res:int64; sta,stb:ansistring;\n i,j,n:longint;k:integer; ans:array[1..1000000] of int64;\nfunction nhohon(a,b:ansistring):boolean;\n begin\n while length(A)j) then\n begin\n y:=ans[i];\n ans[i]:=ans[j];\n ans[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then c:='1'+c;\nexit(c);\nend;\n\nfunction nhan(a:ansistring;b:int64):ansistring;\nvar i :integer;\ncarry,s :int64;\nc,tmp :string;\nbegin\nc:='';\ncarry:=0;\nfor i:=length(a) downto 1 do\nbegin\ns:=(ord(a[i])-48) * b + carry;\ncarry:= s div 10;\nc:=chr(s mod 10 + 48)+c;\nend;\nif carry>0 then str(carry,tmp) else tmp:='';\nexit(tmp+c);\nend;\n\nbegin\n assign(Fin,fi);\n assign(Fout,fo);\n reset(Fin);rewrite(Fout);\n readln(Fin,a,b,l,r);\n str(a,sta);\n str(b,stb);\n for i:=0 to 63 do\n begin\n if i=0 then sta:='1' else sta:=nhan(sta,a);\n for j:=0 to 63 do\n begin\n if (j=0) then stb:='1'\n else\n stb:=nhan(stb,b);\n if nhohon(cong(sta,stb),'1000000000000000001') then\n begin\n val(cong(sta,stb),tmp,k);\n if (tmp>=l) and (tmp<=r) then\n begin\n inc(n);\n ans[n]:=tmp;\n end;\n end\n else break;\n end;\n end;\n\n sort(1,n);\n res:=ans[1]-l;\n res:=max(res,r-ans[n]);\n for i:=2 to n do\n begin\n res:=max(res,ans[i]-ans[i-1]-1);\n end;\n writeln(fout,res);\n close(Fin);close(Fout);\nend.\n\n"}, {"source_code": "var x,y,l,r,max:int64;i,j,w,t1,w1:longint;\na,b,c:array[0..10001]of int64;\nprocedure sort(l,r: longint);\n var\n i,j: longint;x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=c[(l+r) div 2];\n repeat\n while c[i]j) then\n begin\n y:=c[i];c[i]:=c[j];c[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lr then break;\n end;\nt1:=i-1;\nb[1]:=1;\nfor i:=2 to 64 do\n begin\n b[i]:=b[i-1]*y;\n if b[i]>r then break;\n end;\nw1:=i-1;c[1]:=l;w:=1;\nfor i:=1 to t1 do\n for j:=1 to w1 do\n begin inc(w);c[w]:=a[i]+b[j];end;\nsort(1,w);\nif c[1]-l>max then max:=c[1]-l;\nfor i:=2 to w do\n if(c[i-1]>=l)and(c[i-1]<=r)and(c[i]>=l)and(c[i]<=r)then\n if c[i]-c[i-1]-1>max then max:=c[i]-c[i-1]-1;\nif r-c[w]>max then max:=r-c[w];\nwriteln(max);\nclose(input);close(output);\nend.\n"}, {"source_code": "var x,y,l,r,w,t,p,sum:int64;\ni,j:longint;\na,b,c:array[0..100001] of int64;\nprocedure sort(l,r: longint);\n var\n i,j: longint;\n x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=c[(l+r) div 2];\n repeat\n while c[i]j) then\n begin\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lr then break;\n w:=w+1;a[w]:=a[w-1]*x;\n end;\nb[0]:=1;\nfor i:=1 to 100 do\n begin\n if b[i-1]*y>r then break;\n t:=t+1;b[t]:=b[t-1]*y;\n end;\nfor i:=0 to w do\n for j:=0 to t do\n if(a[i]+b[j]>=l)and(a[i]+b[j]<=r)then\n begin\n p:=p+1;c[p]:=a[i]+b[j];\n end;\nsort(1,p);\nfor i:=2 to p do\n if c[i]-c[i-1]-1>sum then sum:=c[i]-c[i-1]-1;\nif r-c[p]>sum then sum:=r-c[p];\nif c[1]-l>sum then sum:=c[1]-l;\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "var x,y,t,w,g,h,max,l:qword;i,j:longint;\na:array[0..10001] of qword;\nprocedure sort(l,r:qword);\n var i,j,x,y:qword;\n begin\n i:=l;j:=r;x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);j:=j-1;\n end;\n until i>j;\n if lw then break;\n end;\n if g>w then continue;\n while h+g<=w do\n begin\n if h+g>=t then begin l:=l+1;a[l]:=h+g;end;h:=h*y;\n end;\n end;\nsort(1,l);\nfor i:=2 to l do\n if a[i]-a[i-1]-1>max then\n max:=a[i]-a[i-1]-1;\nif a[1]-t>max then max:=a[1]-t;\nif w-a[l]>max then max:=w-a[l];\nwriteln(max);\nclose(input);close(output);\nend.\n"}, {"source_code": "var x,y,t,w,g,h,max,l:int64;i,j:longint;\na:array[0..10001] of int64;\nprocedure sort(l,r:int64);\n var i,j,x,y:int64;\n begin\n i:=l;j:=r;x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);j:=j-1;\n end;\n until i>j;\n if lw then break;\n end;\n if g>w then continue;\n while h+g<=w do\n begin\n if h+g>=t then begin l:=l+1;a[l]:=h+g;end;h:=h*y;\n end;\n end;\nif l=0 then begin writeln(w-t+1);halt;end;\nsort(1,l);\nfor i:=2 to l do\n if a[i]-a[i-1]-1>max then\n max:=a[i]-a[i-1]-1;\nif(a[1]-t>max)then max:=a[1]-t;\nif(w-a[l]>max)then max:=w-a[l];\nwriteln(max);\nclose(input);close(output);\nend.\n"}, {"source_code": "var x,y,l,r,w,t,p,sum:int64;\ni,j:longint;\na,b,c:array[0..100001] of int64;\nprocedure sort(l,r: longint);\n var\n i,j: longint;\n x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=c[(l+r) div 2];\n repeat\n while c[i]j) then\n begin\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lr then break;\n w:=w+1;a[w]:=a[w-1]*x;\n end;\nb[0]:=1;\nfor i:=1 to 100 do\n begin\n if b[i-1]*y>r then break;\n t:=t+1;b[t]:=b[t-1]*y;\n end;\nfor i:=0 to w do\n for j:=0 to t do\n if(a[i]+b[j]>=l)and(a[i]+b[j]<=r)then\n begin\n p:=p+1;c[p]:=a[i]+b[j];\n end;\nsort(1,p);\nfor i:=2 to p do\n if c[i]-c[i-1]-1>sum then sum:=c[i]-c[i-1]-1;\nif r-c[p]>sum then sum:=r-c[p];\nif c[1]-l>sum then sum:=c[1]-l;\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "var a,b,c,d,x,y,max:int64;\nf:array[0..1000000] of int64;\ni,n:longint;\n procedure sort(l,r: longint);\n var\n i,j: longint;x,y:int64;\n begin\n i:=l;\n j:=r;\n x:=f[(l+r) div 2];\n repeat\n while f[i]j) then\n begin\n y:=f[i];\n f[i]:=f[j];\n f[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=c) then\n begin\n inc(n);\n f[n]:=x+y;\n end;\n y:=y*b;\n end;\n x:=x*a;\n end;\nsort(1,n);\nf[0]:=c;\nmax:=d-f[n];\nfor i:=1 to n do\n if f[i]-f[i-1]-1>max then\n max:=f[i]-f[i-1]-1;\nwriteln(max);\nclose(input);close(output);\nend."}, {"source_code": "const max1=trunc(1e18);\nvar x,y,l,r:qword;\n a:array[1..36000]of int64;\n\nprocedure nhap;\nbegin\n readln(x,y,l,r);\nend;\n\nfunction mu(x,i:int64):qword;\nvar gt1:qword;\n j:longint;\nbegin\n gt1:=1;\n for j:=1 to i do\n begin\n if (max1/gt1)>x then gt1:=gt1*x\n else exit(0);\n end;\n exit(gt1);\nend;\n\nprocedure swap(var g,h:int64);\nvar temp:int64;\nbegin\n temp:=g;\n g:=h;\n h:=temp;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint; mid:int64;\nbegin\n i:=l;\n j:=r;\n mid:=a[(l+r)div 2];\n repeat\n while a[i]mid do dec(j);\n if not(i>j) then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if i=q then\n if max1-q>=p then\n if (p<>0) and (q<>0) then\n begin\n if (p+q >=l) and (p+q <=r) then\n begin\n inc(cnt);\n a[cnt]:=p+q;\n end;\n end;\n end;\n sort(1,cnt);\n inc(cnt);\n a[cnt]:=r+1; \n max:=0 ;\n for i:=2 to cnt do\n begin\n z:=a[i]-a[i-1]-1;\n if maxx then gt1:=gt1*x\n else exit(0);\n end;\n exit(gt1);\nend;\n\nprocedure swap(var g,h:int64);\nvar temp:int64;\nbegin\n temp:=g;\n g:=h;\n h:=temp;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint; mid:int64;\nbegin\n i:=l;\n j:=r;\n mid:=a[(l+r)div 2];\n repeat\n while a[i]mid do dec(j);\n if not(i>j) then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if i=q then\n if max1-q>=p then\n if (p<>0) and (q<>0) then\n begin\n if (p+q >=l) and (p+q <=r) then\n begin\n inc(cnt);\n a[cnt]:=p+q;\n end;\n end;\n end;\n sort(1,cnt);\n inc(cnt);\n a[cnt]:=r+1;\n max:=0 ;\n a[0]:=l-1;\n for i:=1 to cnt do\n begin\n if i=1 then z:=a[i]-a[i-1]\n else z:=a[i]-a[i-1]-1;\n if maxr) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r)or (py[i]>1000000000000000000 div y);\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend;\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\twriteln(max);\n\treadln;\nend.\t\t"}, {"source_code": "var x,y,l,r,max,f:int64;\n i,j,k,m,e:longint;\n px,py:array [0..1000] of int64;\n w:array [1..5000000] of int64;\nbegin\t\n\treadln(x,y,l,r);\n\tpx[0]:=1;\n\tpy[0]:=1;\n\ti:=0;\n\tj:=0;\n\trepeat \n\t\tinc(i);\n\t\tpx[i]:=px[i-1]*x;\n\tuntil (px[i]>r div x) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r div y)or (py[j]>1000000000000000000 div y);\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend\n\telse break;\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\twriteln(max);\n\treadln;\nend.\t\t"}, {"source_code": "var x,y,l,r,max:int64;\n i,j,k,m,e:longint;\n px,py:array [0..100] of int64;\n w:array [1..5000000] of int64;\nbegin\t\n\treadln(x,y,l,r);\n\tpx[0]:=1;\n\tpy[0]:=1;\n\ti:=0;\n\tj:=0;\n\trepeat \n\t\tinc(i);\n\t\tpx[i]:=px[i-1]*x;\n\tuntil (px[i]>r) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r)or (py[j]>1000000000000000000 div y);\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend;\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\twriteln(max);\n\treadln;\nend.\t\t"}, {"source_code": "var x,y,l,r,max,f:int64;\n i,j,k,m,e:longint;\n px,py:array [0..1000] of int64;\n w:array [1..5000000] of int64;\nbegin\t\n\treadln(x,y,l,r);\n\tpx[0]:=1;\n\tpy[0]:=1;\n\ti:=0;\n\tj:=0;\n\trepeat \n\t\tinc(i);\n\t\tpx[i]:=px[i-1]*x;\n\tuntil (px[i]>r) or (px[i]>1000000000000000000 div x);\n\trepeat \n\t\tinc(j);\n\t\tpy[j]:=py[j-1]*y;\n\tuntil (py[j]>r)or (py[j]>1000000000000000000 div y);\n\te:=0;\n\tfor k:=0 to i do \n\tfor m:=0 to j do\n\tif (px[k]+py[m]>=l)and(px[k]+py[m]<=r) then \n\tbegin \n\t\tinc(e);\n\t\tw[e]:=px[k]+py[m];\n\tend;\n\tfor i:=1 to e-1 do \n\tfor j:=1 to e-i do \n\tif w[j+1]max then max:=r-w[e];\n\tfor i:=1 to e-1 do \n\tif (w[i+1]-w[i]-1>max) then max:=w[i+1]-w[i]-1;\n\twriteln(max);\n\treadln;\nend.\t\t"}], "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f"} {"source_code": "const\n s='GBIV';\n\nvar\nn,int1:longint;\n\nbegin\n readln(n);\n write('ROYGBIV');\n for int1:=8 to n do begin\n write(s[(int1 mod 4)+1]);\n end;\n writeln;\nend.", "positive_code": [{"source_code": "Const color:array[1..4] of char = ('G','B','I','V');\nVar A:array[1..101] of char;\n i,k,j,n:longint;\nBegin\n Read(n);\n A[1]:='R';\n A[2]:='O';\n A[3]:='Y';\n i:=4;\n k:=n div 4;\n While i <= k*4 do\n For j:=1 to 4 do Begin\n A[i]:=color[j];\n i:=i+1;\n End;\n For j:=i to n do\n A[j] := color[j mod 4];\n For i:=1 to n do\n Write(A[i]);\nEnd."}, {"source_code": "var n,i:longint;\nbegin\n readln(n);\n for i:=1 to n div 7 do\n write('ROYGBIV');\n if n mod 7=1\n then writeln('G')\n else if n mod 7=2\n then writeln('GB')\n else if n mod 7=3\n then writeln('GBI')\n else if n mod 7=4\n then writeln('ROYG')\n else if n mod 7=5\n then writeln('ROYGB')\n else if n mod 7=6\n then writeln('ROYGBI');\nend."}, {"source_code": "var\n n:longint;\nbegin\n read(n);\n while (n>=10)do begin\n write('ROYGB');\n dec(n,5);\n end;\n if (n mod 5=2)then writeln('ROYGBIV')else\n if (n mod 5=3)then writeln('ROYGBIVG')else \n if (n mod 5=4)then writeln('ROYGBRIVG')else\n if (n mod 5=0)then writeln('ROYIV')else\n if (n mod 5=1)then writeln('ROYGIV');\nend."}, {"source_code": "program d;\nvar\n a,b : array [1..111] of char;\n c : char;\ni,j,n,i1 : integer;\n f : boolean;\nBEGIN\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nreadln (n);\n\nfor i:=1 to 7 do a[i]:=b[i];\nfor I:=8 to n do\n for i1:=1 to 7 do\n begin\n\tf:=false;\n for j:=1 to 3 do\n begin\n if i+j>n then c:=a[(i+j) mod n] else c:=a[i+j];\n\t if (a[i-j]=b[i1]) or (c=b[i1]) then f:=true;\n \t end;\n if not f then a[i]:=b[i1];\n\tend;\nfor i:=1 to n do write (a[i]);\n\nEND.\n"}, {"source_code": "const d:array[1..7]of char=('R','O','Y','G','B','I','V');\nvar n,i,j:integer;\nch:char;\nbegin\n readln(n);\n for i:=1 to 7 do\n write(d[i]);\n i:=8;\n while(i<=n)do begin\n j:=4;\n while((i<=n)and(j<=7))do begin\n write(d[j]);\n inc(j);inc(i);\n end;\n end;\nend."}, {"source_code": "var\n c:array [1..7] of char;\n i,j,n,k:integer;\nBEGIN\nreadln(n);\nc[1]:='R';c[2]:='O';c[3]:='Y';c[4]:='G';c[5]:='B';c[6]:='I';c[7]:='V';\n\nfor i:=1 to n div 7 do\n for j:=1 to 7 do write(c[j]);\nif (n mod 7 <=3) then for i:=1 to n mod 7 do write(c[3+i])\n else for i:=1 to n mod 7 do write(c[i]);\n\nEND."}, {"source_code": "var n,i,p:integer;\nbegin\nread(n);\np:=n mod 7;\nfor i:=1 to (n div 7) do write('ROYGBIV');\nif p=1 then write('G');\nif p=2 then write('GB');\nif p=3 then write('YGB');\nif p=4 then write('YGBI');\nif p=5 then write('OYGBI');\nif p=6 then write('OYGBIV');\nend.\n"}, {"source_code": "var\n\ti, j, k, l, m, n : longint;\n s, p, r\t\t : string;\n\ta\t\t : array [1..7] of char;\n\tw\t\t : set of char;\nbegin\n\treadln(n);\n\ts := 'ROYGBIV';\n a[1] := 'R';\n\ta[2] := 'O';\n\ta[3] := 'Y';\n\ta[4] := 'G';\n\ta[5] := 'B';\n\ta[6] := 'I';\n\ta[7] := 'V';\n\tfor k:=8 to n do \n\t\tbegin\n\t\t\tp:=copy(s, length(s)-2, 3);\n\t\t\tr:=copy(s, 1, 3);\n\t\t\tfor i:=1 to 7 do\n\t\t\t\tif (pos(a[i], p) = 0)and(pos(a[i], r) = 0) then\n\t\t\t\t\tbegin\n\t\t\t\t\t\ts:=s+a[i];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tend;\t\n\t\tend;\n\twriteln(s);\nend. "}, {"source_code": "var n,i:integer;\nbegin\nreadln(n);\nfor i:=1 to n div 7 do write('ROYGBIV');\ncase n mod 7 of\n1:write('G');\n2:write('GB');\n3:write('YGB');\n4:write('YGBI');\n5:write('OYGBI');\n6:write('OYGBIV');\nend;\nend."}, {"source_code": "\nvar n,m,j,i,k,l:longint;s1:string;\n\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(N);\n\ns1:='ROYGBIV';\nfor i:=8 to n do\ns1:=s1+s1[i-4];\n\nwriteln(s1);\n\nend."}, {"source_code": "var n,k,k1,i:integer;\n s,s1:ansistring;\nbegin\n read(n);\n s:='ROYGBIV';\n k:=n div 7;\n k1:=n mod 7;\n s1:='';\n for i:=1 to k do\n s1:=s1+s;\n case k1 of\n 1: s1:=s1+'G';\n 2: s1:=s1+'YG';\n 3: s1:=s1+'YGB';\n 4: s1:=s1+'YGBI';\n 5: s1:=s1+'YGBIV';\n 6: s1:=s1+'GBIVYG';end;\n write(s1);\nend."}, {"source_code": "Var a:array[0..1000]of char;\n i,n:longint;\nbegin\nreadln(n);\na[1]:='R';\na[2]:='O';\na[3]:='Y';\na[4]:='G';\na[5]:='B';\na[6]:='I';\na[7]:='V';\nfor i:=8 to n do a[i]:=a[i-4];\nfor i:=1 to n do write(a[i]);\nEnd.\n"}, {"source_code": "var\n a,c:array[0..101] of char;\n b:array[0..101] of longint;\n i,j,n:longint;\n s:string;\n\nprocedure sort;\n var\n i,j,m:longint;\n ch:char;\n begin\n for i:=1 to 6 do\n for j:=i+1 to 7 do\n if b[i]>b[j] then\n begin\n m:=b[i]; b[i]:=b[j]; b[j]:=m;\n ch:=c[i]; c[i]:=c[j]; c[j]:=ch;\n end;\n end;\n\nfunction ok(i1,i:longint):boolean;\n var\n j,k:longint;\n begin\n for j:=1 to 3 do\n begin\n k:=i1+j;\n if k>n then k:=k mod n;\n if c[i]=a[k] then\n begin\n ok:=false;\n exit;\n end;\n k:=i1-j;\n if k<1 then k:=n+k;\n if c[i]=a[k] then\n begin\n ok:=false;\n exit;\n end;\n end;\n ok:=true;\n end;\n\nbegin\ns:='ROYGBIV';\nfor i:=1 to 7 do\n begin\n b[i]:=0;\n c[i]:=s[i];\n end;\nreadln(n);\nfor i:=1 to n do a[i]:='a';\ni:=0;\nwhile i0 then\n Write(copy('GBIVGB',1,n mod 7));\n Writeln;\nend;\n\nbegin\n //AssignFile;\n\n Init;\n Main;\n\n //CloseFile;\nend.\n"}, {"source_code": "var a:array[0..6] of char;\nn,i:longint;\ns:string;\nbegin\n read(n);\n a[0]:='R';\n a[1]:='O';\n a[2]:='Y';\n a[3]:='G';\n a[4]:='B';\n a[5]:='I';\n a[6]:='V';\n s:='';\n for i:=1 to (n div 7)*7 do\n s:=s+a[(i-1) mod 7];\n for i:=((n div 7)*7)+1 to n do\n s:=s+s[i-4];\n writeln(s)\nend.\n"}, {"source_code": "program B70;\nvar mas:array [1..100] of byte;\n i,N,k,t:integer;\nbegin\n readln (N);\n i:=1;\n for i:=1 to 7 do\n mas[i]:=i;\n for k:=i+1 to N do\n begin\n mas[k]:=mas[k-4];\n end;\n for i:=1 to N do\n begin\n case mas[i] of\n 4: write ('G');\n 1: write ('R');\n 2:write ('O');\n 3:write ('Y');\n 5:write ('B');\n 6:write ('I');\n 7:write ('V');\n end;\n end;\n halt (0);\nend.\n"}, {"source_code": "Program B78;\nVar\n n,kol : longint;\n stas : char;\n\n\nBegin\n\n readln(n);\n n:=n-7;\n write('ROYGBIV');\n stas:='V';\n kol:=1;\n\n while n<>0 do\n begin\n if stas='V' then stas:='G' else\n if stas='G' then stas:='B' else\n if stas='B' then stas:='I' else\n if stas='I' then stas:='V';\n write(stas);\n dec(n);\n end;\n\nEnd."}, {"source_code": "var n,i: integer;\nbegin\n read(n);\n for i:=1 to n div 7 do write('ROYGBIV');\n n:=n mod 7;\n if n=6 then write('OYGBIV');\n if n=5 then write('YGBIV');\n if n=4 then write('GBIV');\n if n=3 then write('GBI');\n if n=2 then write('GB');\n if n=1 then write('G');\nend."}, {"source_code": "Program z78b;\nconst cv:array[1..7]of char=('R','O','Y','G','B','I','V');\nvar n,i,k:byte;\nbegin\n\tread(n);\n for i:=1 to n div 7 do\n \twrite('ROYGBIV');\n k:=n mod 7;\n if k=1 then write('G');\n if k=2 then write('YG');\n if k=3 then write('OYG');\n if k=4 then write('ROYG');\n if k=5 then write('ROYGB');\n if k=6 then write('ROYGBI');\nend."}, {"source_code": "const aa:array [1..7] of char =(('R'),('O'),('Y'),('G'),('B'),('I'),('V'));\nvar\n s:string;\n n,i,k,l:longint;\nbegin\n readln (n);\n k:=1;\n for i:=1 to n-3 do begin\n if k>7 then k:=1;\n if k<=7 then s:=s+aa[k];\n inc (k);\n end;\n k:=1;\n repeat\n l:=length (s);\n if k>7 then k:=1;\n if (s[l]<>aa[k]) and (s[l-1]<>aa[k]) and (s[l-2]<>aa[k]) and\n (s[1]<>aa[k]) and (s[2]<>aa[k]) and (s[3]<>aa[k]) and (k<=7) then\n s:=s+aa[k] else inc (k);\n l:=length (s);\n until l=n;\n writeln (s);\nend.\n\n\n"}, {"source_code": "const\n arr:array[0..6] of char=('R','O','Y','G','B','I','V');\nvar\n n,r,i:longint;\nbegin\n readln(n);\n r:=n mod 7;\n if (r>3) or (r=0) then\n n:=n-1\n else\n if r>1 then\n begin\n for i:=r to 2*r-1 do\n write(arr[i]);\n n:=n-r-1;\n end\n else\n begin\n for i:=0 to 3 do\n write(arr[i]);\n write(arr[0]);\n for i:=4 to 6 do\n write(arr[i]);\n n:=n-9;\n end;\n for i:=0 to n do\n write(arr[i mod 7]);\n writeln;\nend.\n\n"}, {"source_code": "var n,i,j:longint;\ns,s1:string;\nch,ch1,ch2:char;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(n);\ns:='';\ns1:='VROYGBI';\nfor i:=1 to n do\n s:=s+s1[i mod 7+1];\nif s[1]=s[n] then\n begin\n ch:=s[n];\n s[n]:=s[n-1];\n s[n-1]:=s[n-2];\n s[n-2]:=s[n-3];\n s[n-3]:=ch;\n end;\nif n-(n div 7)*7=2 then\n begin\n ch:=s[n];\n ch1:=s[n-1];\n s[n]:=s[n-2];\n s[n-1]:=s[n-3];\n s[n-2]:=ch;\n s[n-3]:=ch1;\n end;\nif n-(n div 7)*7=3 then\n begin\n ch:=s[n];\n ch1:=s[n-1];\n ch2:=s[n-2];\n s[n]:=s[n-3];\n s[n-1]:=ch;\n s[n-2]:=ch1;\n s[n-3]:=ch2;\n end;\nwrite(s);\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "program shablon;\n{$O+ R- Q-} {$ASSERTIONS ON} {$INLINE ON}\n{$H+}\n{$EXTENDEDSYNTAX ON SMARTLINK ON} { MEMORY SS, HS }\n{$COperators ON} {$MACRO ON}\n{$MODE OBJFPC}\n{$DEFINE uu := for}\n\nuses\n SysUtils,Math;\n\nconst inf=1/0;\n s='ROYGBIV';\n\ntype tpoint=record\n x,y:extended;\n end;\n\n tnode=record\n x,y,l,r,a,c:longint;\n end;\n\nvar x,y:extended;\n n:longint;\n ans:string;\n\n{$IFNDEF ONLINE_JUDGE}\noperator **(x,y:extended):extended;\nbegin\n result:=exp(ln(X)*Y);\nend;\n{$ENDIF}\n\nprocedure pout inline;\nbegin\n writeln(ans);\n{$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n{$ENDIF}\n halt(0);\nend;\n\nprocedure pinit inline;\nbegin\n{$IFNDEF ONLINE_JUDGE}\n assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\n{$ENDIF}\n readln(n);\nend;\n\nprocedure solve;\nvar i:longint;\nbegin\n ans:='';\n for i:=1 to 3 do\n ans+=s[i+4];\n for i:=4 to n do\n begin\n ans+=s[(i-1) mod 4 +1];\n end;\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend.\n"}, {"source_code": "var\ni,n,j:integer;\ns:string;\nflag:boolean;\nbegin\n read(n);\n s:='ROYGBIV';\n for i:=8 to n do begin\n j:=4;\n flag:=true;\n while flag do begin\n\n if (s[j]<>s[1])and(s[j]<>s[2])and(s[j]<>s[3]) then begin\n if (s[j]<>s[length(s)])and(s[j]<>s[length(s)-1])and(s[j]<>s[length(s)-2]) then flag:=false;\n end;\n inc(j);\n end;\n dec(j);\n s:=s+s[j];\n end;\n write(s);\nend."}, {"source_code": "Var a:array[0..101]of char;\n i,n:longint;\nBegin\n Readln(n);\n a[1]:='R';\n a[2]:='O';\n a[3]:='Y';\n a[4]:='G';\n a[5]:='B';\n a[6]:='I';\n a[7]:='V';\n for i:=8 to n do\n a[i]:=a[i-4];\n for i:=1 to n do\n write(a[i]);\n writeln;\nEnd."}, {"source_code": "program aaa;\n var i,j,m,n,k,l,t:longint;s:string;{a:array[0..10]of integer;\n w:string;{\n label 1; } q:char; f:boolean;\nfunction aa(q:char):longint;\nbegin\n if pos(q,'aeiouAEIOU')>0 then aa:=1 else aa:=0;\nend;\nbegin\n\n{ assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output); }\n readln(n); k:=n-3; S:='ROYG';\n m:=k div 4;\n for i:=1 to m do write(S);\n\n for i:=1 to K mod 4 do write(s[i]);\n write('BIV');\nend."}, {"source_code": "const\n s:array[0..6] of char = ('R','O','Y','G','B','I','V');\nvar\nf:boolean;\n i,n,q,j:longint;\n ans:array[0..1000] of char;\nbegin\n readln(n);\n for i:=1 to n-3 do ans[i]:=s[i mod 4];\n q:=4;\n for i:=n-3 to n-1 do\n begin\n ans[i]:=s[q];\n inc(q);\n end;\n for i:=0 to 3 do\n begin\n f:=false;\n for j:=1 to 3 do if s[i]=ans[j] then\n begin\n f:=true;\n break;\n end;\n if not f then\n begin\n ans[n]:=s[i];\n for j:=1 to n do write(ans[j]);\n writeln;\n end;\n end;\n\nend.\n"}, {"source_code": "{$M 17777777}\n\n//Uses Brain;\n\nUses\n\tMath , SysUtils;\n\nConst\n\tinf = 1 shl 30;\ntype\n\tint = int64;\n\nvar a : Array[-100..201] of char;\t\n\nprocedure reading;\nvar n , i , j , k: longint; s : string;\nbegin\n readln(n);\n s:='ROYGBIV';\n j:=1;\n for i:=1 to n do begin\n a[i]:=s[j];\n inc(j);\n if j > 7 then\n j:=1;\n end;\n a[-1]:=a[n - 1];\n a[0]:=a[n];\n a[n + 1]:=a[1];\n a[n+2]:=a[2];\n a[n + 3]:=a[3];\n for i:= n mod 7 downto 1 do begin\n \tfor j:= 1 to 7 do begin\n \t\tk:=n - i + 1;\n \t\tif (s[j] <> a[k - 1]) and (s[j] <> a[k - 2]) and (s[j] <> a[k - 3])and\n \t\t (s[j] <> a[k + 1]) and (s[j] <> a[k + 2]) and (s[j] <> a[k + 3]) then\n \t\t begin\n \t\t a[k]:= s[j];\n \t\t break;\n \t\t end;\n \tend;\n end;\n for i:=1 to n do write(a[i]);\nend;\n\nbegin\n reading;\nend. "}, {"source_code": "var\n met:array [1..1000] of longint;\n i,j,n,m,k,l:longint;\n c:char;\n s,s1,ss:string;\nbegin\n readln(n);\n ss:='OYGBIV';\n l:=1;\n met[1]:=1;\n met[2]:=2;\n met[3]:=3;\n k:=4;\n l:=4;\n for i:=4 to n do\n begin\n met[i]:=l;\n inc(l);\n inc(k);\n if k>3 then\n begin\n met[i]:=-1;\n k:=0;\n dec(l);\n end;\n if l>6 then l:=4;\n end;\n for i:=1 to n do\n if met[i]<>-1 then write(ss[met[i]])\n else write('R');\nend."}, {"source_code": "var n,i:byte;\nbegin\n readln(n);\n for i:=1 to (n div 7) do\n write('ROYGBIV');\n case n mod 7 of\n 0:writeln;\n 1:writeln('G');\n 2:writeln('GB');\n 3:writeln('YGB');\n 4:writeln('YGBI');\n 5:writeln('OYGBI');\n 6:writeln('OYGBIV');\n end;\n readln;\nend.\n"}, {"source_code": "var a,b,summ:array [0..100] of longint;\n n,m,k,i,j,v,l,r:longint;\n ans,ls:int64;\n s:ansistring;\n f:longint;\n\n function ii(x:longint):longint;\n begin\n x:=x+1;\n if x>n then x:=x-n;\n ii:=x;\n\n end;\n\nbegin\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n readln(n);\n for i:=1 to 7 do\n a[i]:=i;\n\n for i:=8 to n do\n begin\n for j:=1 to 7 do\n if (a[i-1]<>j) and (a[i-2]<>j) and (a[i-3]<>j) and (a[ii(I)]<>j) and (a[ii(i+1)]<>j) and (a[ii(i+2)]<>j) then\n begin\n a[i]:=j;\n break;\n end;\n end;\n\n for i:=1 to n do\n begin\n if a[i]=1 then write('R') else\n if a[i]=2 then write('O') else\n if a[i]=3 then write('Y') else\n if a[i]=4 then write('G') else\n if a[i]=5 then write('B') else\n if a[i]=6 then write('I') else\n write('V');\n end;\n\nend.\n"}, {"source_code": "var n,i:byte;\nbegin\nread(n);\nfor i:=1 to (n div 7)*7 do\ncase i mod 7 of\n0:write('V');\n1:write('R');\n2:write('O');\n3:write('Y');\n4:write('G');\n5:write('I');\n6:write('B');\nend;\ncase n mod 7 of\n1:write('G');\n2:write('GI');\n3:write('GIB');\n4:write('ROYG');\n5:write('ROYGI');\n6:write('ROYGIB');\nend;\nend."}, {"source_code": "var n,i:longint;\nbegin\n read(n);\n write('ROYGBIV');\n for i:=1 to n-7 do\n if i mod 4=1 then write('G')\n else if i mod 4=2 then write('B')\n else if i mod 4=3 then write('I')\n else write('V');\nend."}, {"source_code": "var a:array[1..100] of integer;\nc:array[1..100,1..7] of integer;\nn,i,j,l:integer;\n\nbegin\nreadln(n);\nfor i:=1 to 7 do a[i]:=i;\nfor i:=n-2 to n do c[i,a[1]]:=1;\nfor i:=n-1 to n do c[i,a[2]]:=1;\nc[n,a[3]]:=1;\nfor i:=5 to 7 do\n for j:=i+1 to i+3 do\n if j<=n then c[j,a[i]]:=1;\nfor i:=8 to n do\n begin\n l:=1;\n while (l<8) and(c[i,l]=1) do inc(l);\n a[i]:=l;\n for j:=i+1 to i+3 do\n if j<=n then c[j,a[i]]:=1;\n end;\nfor i:=1 to n do\n case a[i] of\n 1:write('R');\n 2:write('O');\n 3:write('Y');\n 4:write('G');\n 5:write('B');\n 6:write('I');\n 7:write('V')\n end;\nwriteln;\nend."}, {"source_code": "Const col='ROYGBIV';{ fp }\nVar\n n,j,color : longint;\n a : array[0..104] of longint;\n rt,used : array[0..10] of longint;\n ok : boolean;\n\n\n\n Function good(x1,x2,x3,x4:longint):boolean;\n Begin\n If (x1=x2) or (x1=x3) or (x1=x4) or (x2=x3) or (x2=x4) or (x3=x4) then good := false\n else good := true;\n End;\n\n\n Procedure go(num:longint);\n Var\n i:longint;\n\n begin\n If num=n+1 then\n begin\n ok := true;\n a[n+1] := a[1];\n a[n+2] := a[2];\n a[n+3] := a[3];\n a[n+4] := a[4];\n For i := n-2 to n do\n If not good(a[i],a[i+1],a[i+2],a[i+3]) then\n Begin\n ok := false;\n break;\n End;\n If (ok=false) or (color<>7)then exit;\n For i := 1 to n do\n Write(col[a[i]]);\n WriteLn;\n halt(0);\n end;\n If num>4 then used[a[num-4]] := 0;\n For i := 1 to 7 do\n If used[i]=0 then\n Begin\n rt[i] := rt[i]+1;\n If rt[i]=1 then color := color+1;\n used[i] := 1;\n a[num] := i;\n go(num+1);\n used[i] := 0;\n rt[i] := rt[i]-1;\n If rt[i]=0 then color := color-1;\n End;\n if num>4 then used[a[num-4]] := 1;\n end;\n\n Begin\n REad(n);\n color := 0;\n go(1);\n end."}, {"source_code": "uses\n SysUtils;\n const Mas:array[1..7] of char=('R','O','Y','G','B','I','V');\nVAR N,i,j:INTEGER; m:set of char; len:string;\nbegin\nreadln(n); len:='';\nfor i:=1 to n-n mod 7 do begin\nif i mod 7=0 then begin write(mas[7]);len:=len+mas[7]; end else begin write(mas[i mod 7]);len:=len+mas[i mod 7];end;\nend;\nm:=[];\nfor i:=n+1-n mod 7 to n do begin\n m:=[];\n for j:=i-3 to i-1 do m:=m +[len[j]];\n for j:=i+1 to i+3 do if j>n then m:=m + [len[j mod (n+1) +1]];\n for j:=1 to 7 do if not (mas[j] in m) then begin write(mas[j]);len:=len+mas[j];break;end;\n end;\nend."}, {"source_code": "var n:longint;\n i,count:longint;\n s:String;\nbegin\n readln(n);\n s:='ROYGBIV';\n for i:= 1 to n div 7 * 7 do\n write(s[(i-1) mod 7 + 1]);\n count:=n-n div 7 * 7;\n case count of\n 1:writeln('G');\n 2:writeln('GB');\n 3:writeln('GBI');\n 4:writeln('GBIV');\n 5:writeln('ROYGB');\n 6:writeln('ROYGBI');\n 0:writeln;\n end;\nend."}, {"source_code": "Var\n n,i:Word;\n s:String;\nBegin\n Read(n);\n s:='ROYGBIV';\n For i:=1 To n div 7 Do Write(s);\n If n mod 7=1 Then Write('G');\n If n mod 7=2 Then Write('GB');\n If n mod 7=3 Then Write('GBI');\n If n mod 7=4 Then Write('GBIV');\n If n mod 7=5 Then Write('YGBIV');\n If n mod 7=6 Then Write('OYGBIV');\n\nEnd.\n\n\n"}, {"source_code": "uses math;\n\nconst kt:array[0..6]of char=('R','Y','O','I','B','G','V');\nvar i,n:longint;\n s:string;\nbegin\n readln(n);\n s:='';\n for i:=0 to 7 * (n div 7)-1 do\n begin\n s:=s+kt[i mod 7];\n end;\n\n case n mod 7 of\n 1:s:=s+kt[3];\n 2: begin\n s:=s+kt[3]+kt[4];\n end;\n 3: begin\n s:=s+kt[3]+kt[4] +kt[5];\n end;\n 4: begin\n s:=s+kt[3]+kt[4]+kt[5]+kt[6];\n end;\n 5: begin\n s:=s+kt[3]+kt[2]+kt[4]+kt[5]+kt[6];\n end;\n 6:begin\n s:=s+kt[3]+kt[2]+kt[1]+kt[4]+kt[5]+kt[6];\n end;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var\n i,n:byte;\n c:array[1..100] of char;\nBEGIN\n readln(n);\n write('ROYGBIV');\n c[1]:='R';\n c[2]:='O';\n c[3]:='Y';\n c[4]:='G';\n c[5]:='B';\n c[6]:='I';\n c[7]:='V';\n for i:=8 to n do\n begin \n c[i]:=c[i-4];\n write(c[i]);\n end;\nEND."}, {"source_code": " var a:array[1..128] of char;\n i,n:longint;\nbegin\n readln(n);\n a[1]:='R';\n a[2]:='O';\n a[3]:='Y';\n a[4]:='G';\n a[5]:='B';\n a[6]:='I';\n a[7]:='V';\n for i:=8 to n do\n a[i]:=a[i-4];\n for i:=1 to n do\n write(a[i]);\n writeln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nprocedure _halt(s:string);\nbegin\nwriteln(s);\nhalt;\n//{$IFDEF ONLINE_JUDGE}\nend;\n\nfunction cnt(s:string):integer;\nvar i,ans:integer;\nbegin\nans:=0;\nfor I := 1 to length(s) do\nif s[i] in ['a','o','u','e','i'] then inc(ans);\n\ncnt:=ans;\nend;\n\nvar s:string;\ni,n:integer;\nbegin\nreadln(n);\nn:=n-7;\ns:='ROYGBIV';\nfor I := 1 to n do\n case i mod 4 of\n 0:s:=s+'V';\n 1:s:=s+'G';\n 2:s:=s+'B';\n 3:s:=s+'I';\n end;\nwriteln(s);\nend.\n"}, {"source_code": "var n,c,i:integer;\n \nbegin\nreadln(n);\nc:=n div 7;\nfor i:=1 to c do\nwrite('ROYGBIV');\nn:=n mod 7;\nif n=1 then write('G');\nif n=2 then write('GB');\nif n=3 then write('YGB');\nif n=4 then write('YGBI');\nif n=5 then write('OYGBI');\nif n=6 then write('OYGBIV');\nend."}, {"source_code": "const a:array[0..6]of char = ('R','O','Y','G','B','I','V');\nvar\nn,i:longint;\n begin\n readln(n);\n for i:=1 to n-3 do\n write(a[(i-1)mod 4]);\n writeln('BIV');\n end."}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nuses math;\nconst color : array[0..6] of char = ('R','O','Y','G','B','I','V');\nvar n : integer;\n i : integer;\n\nbegin\n Readln(n);\n if (n mod 7 >= 4) or (n mod 7 = 0) then\n for i:=1 to n do Write(color[i mod 7])\n else\n begin\n for i:= 1 to n - n mod 7 do Write(color[i mod 7]);\n for i:= 1 to n mod 7 do Write(color[ (i +3) mod 7]);\n end;\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i:Longint;\n a:array[1..100]of Char;\n\nbegin\n //Reset(Input,'in.txt');\n //Rewrite(Output,'out.txt');\n a[1]:='R';\n a[2]:='O';\n a[3]:='Y';\n a[4]:='G';\n Read(n);\n if n=7 then Write('ROYGBIV') else begin\n for i:=5 to n-3 do a[i]:=a[i-4];\n for i:=1 to n-3 do\n Write(a[i]) ;\n Write('BIV');\n end;\nend.\n"}, {"source_code": "var mas : array [1..100] of string ;\n colors : array [1..7] of string ;\n n : longint ;\n\nfunction p(x:longint):longint ;\n Begin\n if x<=n then p:=x else p:=x-n ;\n End;\n\nprocedure argh(k:longint) ;\nvar i,j,l : longint ;\nBegin\n if k=n+1 then\n begin\n l:=0 ;\n for i:=1 to n do\n begin\n if (mas[p(i)]<>mas[p(i+1)]) and (mas[p(i)]<>mas[p(i+2)]) and (mas[p(i)]<>mas[p(i+3)])\n and (mas[p(i+1)]<>mas[p(i+2)]) and (mas[p(i+1)]<>mas[p(i+3)]) and (mas[p(i+2)]<>mas[p(i+3)]) then inc(l) ;\n\n if l=n then\n begin\n for j:=1 to n do write(mas[j]) ;\n halt ;\n end\n end;\n end;\n for i:=1 to n do\n if mas[i]='' then\n begin\n if k mod 7 = 0 then mas[i]:=colors[7] else mas[i]:=colors[k mod 7] ;\n argh(k+1) ;\n mas[i]:='' ;\n end;\nEnd;\n\nBegin\n readln(n) ;\n colors[1]:='R' ; colors[2]:='O' ; colors[3]:='Y' ; colors[4]:='G' ;\n colors[5]:='B' ; colors[6]:='I' ; colors[7]:='V' ;\n argh(1) ;\nEnd.\n"}, {"source_code": "const t:array[1..7] of char=('R','O','Y','G','V','B','I');\nvar i,c,n:longint;\nbegin \n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nread(n);\nfor i:=1 to 7 do\n write(t[i]);\nc:=4;\nfor i:=8 to n do begin\n write(t[c]);\n inc(c);\n if c=8 then c:=4;\nend; \nend."}, {"source_code": "const\na:array[0..6] of char=('R','O','Y','G','B','I','V');\nvar\nn,i,j,l:longint;\nb:array[1..10000] of char;\nbegin\n readln(n);\n for i:=1 to 7 do\n b[i]:=a[i mod 7];\nfor j:=1 to n-10 do\n for l:=0 to 6 do\n if (a[l]<>b[i])\n and(a[l]<>b[i-1])\n and(a[l]<>b[i-2])\n and(ib[i])\n and(a[l]<>b[i-1])\n and(a[l]<>b[i-2])\n and(a[l]<>b[1])\n and(a[l]<>b[2])\n and(a[l]<>b[3])\n and(i=n;\nif length(s)>n then delete(s,n+1,length(s)-n);\ns[n]:='R';s[n-1]:='O'; s[n-2]:='Y';\nwriteln(s);\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst strs:array [0..6] of string=('','G','GB','YGB','YGBI','OYGBI','OYGBIV');\n\nvar n,i:integer;\n\nbegin\nreadln(n);\nfor i:=1 to n div 7 do\n write('ROYGBIV');\nwrite(strs[n mod 7]);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project4;\n{$APPTYPE CONSOLE}\n\nuses sysutils,math;\n\nconst\n str = 'ROYGBIV';\n\nvar n,x,k,t1,t2,y,b: integer;\n i,j: longint;\n a: array [1..1000] of real;\n s: string;\nbegin\n readln(n);\n s := str;\n for i := 8 to n do\n s := s + s[i-4];\n write(s);\nend."}, {"source_code": "Const\n AA:Array[1..7]Of Char=('R','O','Y','G','B','I','V');\n\nVar\n N:Integer;\n A:Array[1..7]Of Integer;\n B:Array[0..100]Of Integer;\n\n\n Procedure Rec(X,L1,L2,L3,R1,R2,R3:Integer);\n Var I,J:Integer;\n Begin\n If X=N\n Then Begin\n For I:=1 To N Do\n If A[I]=0\n Then Exit;\n\n For I:=0 To N-1 Do\n For J:=I+1 To (I+3)Mod N Do\n If B[I]=B[J]\n Then Exit;\n\n For I:=0 To N-1 Do\n Write(AA[B[I]]);\n\n Halt(0);\n End;\n\n For I:=1 To 7 Do\n If (I<>L1)And(I<>L2)And(I<>L3)And(I<>R1)And(I<>R2)And(I<>R3)\n Then begin\n Inc(A[i]);B[X]:=I;\n Rec(X+1,L2,L3,I,B[(X+2)Mod N],B[(X+3)Mod N],B[(X+4)Mod N]);\n Dec(A[I]);\n End;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Readln(N);\n FillChar(A,SizeOf(A),0);\n FillChar(B,SizeOf(B),0);\n Rec(0,0,0,0,0,0,0);\nEnd."}, {"source_code": "program n21;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar q,w,e,r,n,t: longint;\n a,s,d: string;\nbegin\n read(n);\n write('OYGRBIV');\n if n>7 then\n begin\n n:=n-7;\n q:=0;\n repeat\n\n if (q mod 4=0) then write('R');\n if (q mod 4=1) then write('B');\n if (q mod 4=2) then write('I');\n if (q mod 4=3) then write('V');\n q:=q+1 ;\n until q=n;\n\n end;\n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n,i,k:integer;\n a,b:array[1..10000] of char;\n s:string;\n f:boolean;\nbegin\na[1]:='R';\na[2]:='O';\na[3]:='Y';\na[4]:='G';\na[5]:='B';\na[6]:='I';\na[7]:='V';\nreadln(n);\nfor i:=1 to 7 do\nb[i]:=a[i];\nfor i:=1 to n-7 do\nb[i+7]:=b[i+7-4];\nfor i:=1 to n do\nwrite(b[i]);\n//readln;\nend.\n"}, {"source_code": "{$apptype console}\nconst c: string = 'ROYGBIV';\n maxn = 110;\n\nvar sol: array [1..maxn] of char;\n n,i : integer;\nbegin\n read( n );\n for i := 1 to n do sol[i] := c[(i-1) mod 4 + 1];\n for i := 1 to 3 do sol[n-i+1] := c[i+4];\n for i := 1 to n do write( sol[i] );\nend."}, {"source_code": "var n,i:integer;\n a:array[0..120]of char;\n\n\nfunction f(a:integer):integer;\nbegin\nf:=a mod n;\nend;\n\nfunction get(x:integer):char;\nbegin\n if (a[i-1]<>'R')and(a[i-2]<>'R')and(a[i-3]<>'R')\n and(a[f(i+1)]<>'R')and(a[F(i+2)]<>'R')and(a[f(i+3)]<>'R')\n then\n get:='R';\n\n if (a[i-1]<>'O')and(a[i-2]<>'O')and(a[i-3]<>'O')\n and(a[f(i+1)]<>'O')and(a[F(i+2)]<>'O')and(a[f(i+3)]<>'O')\n then\n get:='O';\n\n if (a[i-1]<>'Y')and(a[i-2]<>'Y')and(a[i-3]<>'Y')\n and(a[f(i+1)]<>'Y')and(a[F(i+2)]<>'Y')and(a[f(i+3)]<>'Y')\n then\n get:='Y';\n\n if (a[i-1]<>'G')and(a[i-2]<>'G')and(a[i-3]<>'G')\n and(a[f(i+1)]<>'G')and(a[F(i+2)]<>'G')and(a[f(i+3)]<>'G')\n then\n get:='G';\n\n if (a[i-1]<>'B')and(a[i-2]<>'B')and(a[i-3]<>'B')\n and(a[f(i+1)]<>'B')and(a[F(i+2)]<>'B')and(a[f(i+3)]<>'B')\n then\n get:='B';\n\n if (a[i-1]<>'I')and(a[i-2]<>'I')and(a[i-3]<>'I')\n and(a[f(i+1)]<>'I')and(a[F(i+2)]<>'I')and(a[f(i+3)]<>'I')\n then\n get:='I';\n\n if (a[i-1]<>'V')and(a[i-2]<>'V')and(a[i-3]<>'V')\n and(a[f(i+1)]<>'V')and(a[F(i+2)]<>'V')and(a[f(i+3)]<>'V')\n then\n get:='V';\n\nend;\n\nbegin\nfillchar(a,sizeof(a),'7');\nreadln(n);\na[1]:='R';\na[2]:='O';\na[3]:='Y';\na[4]:='G';\na[5]:='B';\na[6]:='I';\na[7]:='V';\nfor i:=8 to n do\na[i]:=get(i);\n\nfor i:=1 to n do write(a[i]);\n\n\nend."}, {"source_code": "const t:array[1..7] of char=('R','O','Y','G','V','B','I');\nvar i,c,n:longint;\nbegin \n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nread(n);\nfor i:=1 to 7 do\n write(t[i]);\nc:=4;\nfor i:=8 to n do begin\n write(t[c]);\n inc(c);\n if c=8 then c:=4;\nend; \nend."}, {"source_code": "const t:array[1..7] of char=('R','O','Y','G','V','B','I');\nvar i,c,n:longint;\nbegin \nread(n);\nfor i:=1 to 7 do\n write(t[i]);\nc:=4;\nfor i:=8 to n do begin\n write(t[c]);\n inc(c);\n if c=8 then c:=4;\nend; \nend."}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n n,i : integer;\n c : array [1..8] of char;\n\nbegin\n read(n);\n c[1] := 'G';\n c[2] := 'B';\n c[3] := 'I';\n c[4] := 'V';\n c[5] := 'G';\n c[6] := 'B';\n c[7] := 'I';\n for i := 1 to n div 7 do write('ROYGBIV');\n for i := 1 to n mod 7 do write(c[i]);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n next, pred : array[0..100] of integer;\n a : array[0..100] of char;\n s : array[1..7] of char = ('R', 'O', 'Y', 'G', 'B', 'I', 'V');\n i, j, t, x, n : integer;\n l : boolean;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(n);\n for i := 1 to n do begin\n a[i] := 'a';\n next[i] := i + 1;\n pred[i] := i - 1;\n end;\n next[n] := 1;\n pred[1] := n;\n for i := 1 to 7 do\n a[i] := s[i];\n for i := 8 to n do\n for j := 1 to 7 do begin\n a[i] := s[j];\n l := true;\n x := i;\n for t := 1 to 3 do\n if a[pred[x]] = a[i] then\n l := false\n else\n x := pred[x];\n x := i;\n for t := 1 to 3 do\n if a[next[x]] = a[i] then\n l := false\n else\n x := next[x];\n if l then\n break;\n end;\n\n for i := 1 to n do\n write(a[i]);\n\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\n clr:array[1..7] of char = ('R','O','Y','G','B','I','V');\nvar\n n,i:longint;\n ans:array[1..1000] of char;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(n);\n for i:=1 to 7 do ans[i]:=clr[i];\n for i:=8 to n do ans[i]:=ans[i-4];\n for i:=1 to n do write(ans[i]);\nend.\n \n"}, {"source_code": "var\n s:string;\n x:integer;\nbegin\n// Reset(input,'input.txt'); Rewrite(output,'output.txt');\n read(x);\n s:='ROYGBIV';\n while length(s)c) and (s[i-1]<>c) and (s[i-2]<>c) and (s[i-3]<>c) then\n begin\n s[i]:=c;\n break;\n end;\n end;\n \n For j:=1 to 7 do\n begin\n i:=n-1;\n If j mod 7=0 then c:='R' else\n If j mod 7=1 then c:='O' else\n If j mod 7=2 then c:='Y' else\n If j mod 7=3 then c:='G' else\n If j mod 7=4 then c:='B' else\n If j mod 7=5 then c:='I' else\n If j mod 7=6 then c:='V';\n If (s[1]<>c) and (s[i-1]<>c) and (s[i-2]<>c) and (s[i-3]<>c) and (s[2]<>c) then\n begin\n s[i]:=c;\n break;\n end;\n end;\n \n For j:=1 to 7 do\n begin\n i:=n;\n If j mod 7=0 then c:='R' else\n If j mod 7=1 then c:='O' else\n If j mod 7=2 then c:='Y' else\n If j mod 7=3 then c:='G' else\n If j mod 7=4 then c:='B' else\n If j mod 7=5 then c:='I' else\n If j mod 7=6 then c:='V';\n If (s[1]<>c) and (s[i-1]<>c) and (s[i-2]<>c) and (s[i-3]<>c) and (s[3]<>c) and (s[2]<>c) then\n begin\n s[i]:=c;\n break;\n end;\n end;\n\n For i:=1 to n do write(s[i]);\nend;\nend.\n"}], "negative_code": [{"source_code": "var n, i: byte;\nbegin\n readln(n);\n dec(n, 7);\n write('ROYGBIV');\n for i := 1 to n div 4 do\n write('ROYG');\n case n mod 4 of\n 1: write('G');\n 2: write('GB');\n 3: write('GBI');\n end;\nend."}, {"source_code": "program Project1112;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n a:array[1..7] of char = ('R','O','Y','G','B','I','V');\nvar\n i,j,k,n:integer;\n s:string;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<=7 then\n for i:=1 to n do\n begin\n s:=s+a[i];\n exit;\n end;\n s:='ROYGBIV';\n while length(s)0) then write('ROYGROYG');\nif (k mod 5 =0) then write('ROYGIROYGI');\nif (k mod 3 =0) then write('ROYGIVROYGIV');\nend."}, {"source_code": "program d;\nvar\n a,b : array [1..111] of char;\n c : char;\ni,j,n,i1 : integer;\n f : boolean;\nBEGIN\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nreadln (n);\n\nfor i:=1 to 7 do a[i]:=b[i];\nfor I:=8 to n do\n for i1:=1 to 7 do\n begin\n\tf:=false;\n for j:=1 to 3 do\n begin\n if i+j>n then c:=a[(i+j) mod n] else c:=a[i+j];\n\t if (a[i-j]=b[i1]) or (c=b[i1]) then f:=true;\n \t end;\n if not f then a[i]:=b[i1];\n\tend;\nfor i:=1 to n-1 do write (a[i],' '); write (a[n]);\n\nEND.\n"}, {"source_code": "var n,i:longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n if i=1 then write('R')\n else\n if i=2 then write('O')\n else\n if i=3 then write('Y')\n else\n if i=4 then write('G')\n else\n if i=5 then write('B')\n else\n if i=6 then write('I')\n else\n if i=7 then write('V')\n else\n if i mod 2=0 then write('R')\n else write('O');\n end;\n end."}, {"source_code": "Var\nn,i:longint;\ns:string;\nBegin\nread(n);\ns:='ROYGBIV';\nfor i:=1 to (n div 7)-1 do\n write(s);write('ROYG');\nfor i:=1 to (n mod 7) do\n write(s[i]);\nif (n mod 7)<=4 then write('BIV') else \n Begin\n for i:=(n mod 7)-3 to (n mod 7)-1 do\n write(s[i]);\n end;\nend."}, {"source_code": "program b70;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,j:integer;\n col:array[0..6] of char = ('R','O','Y','G','B','I','V');\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n {$ENDIF}\n readln(n);\n for i:=1 to n do write(col[i mod 7]);\nend.\n"}, {"source_code": "var\n n,i:longint;\nbegin\n read(n);\n for i:=1 to n do begin\n if i mod 7=0 then write('R');\n if i mod 7=1 then write('O');\n if i mod 7=2 then write('Y');\n if i mod 7=3 then write('G');\n if i mod 7=4 then write('B');\n if i mod 7=5 then write('I');\n if i mod 7=6 then write('V');\n end;\nend."}, {"source_code": "program z;\n const\n ar:array[1..7] of char=('R','G','B','O','Y','I','V');\n var\n a:array[1..103] of char;\n n,i,j:integer;\n begin\n read(n);\n a[1]:='R';\n a[2]:='G';\n a[3]:='B';\n a[n+1]:='R';\n a[n+2]:='G';\n a[n+3]:='B';\n for i:=4 to n-3 do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=n-3 to n do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])and\n (a[i+1]<>ar[j])and(a[i+2]<>ar[j])and(a[i+3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=1 to n do write(a[i]);\nend.\n\n"}, {"source_code": "var a:array[1..110] of char;\n b:array[1..10] of char;\n i,n,k,j,p:integer;\nbegin\nread(n);\nk:=0;\np:=4;\nj:=3;\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nwrite(b[1],b[2],b[3],b[4],b[5],b[6],b[7]);\nfor i:=8 to n do begin\nif j=7 then j:=0;\na[i]:=b[j+1];\ninc(j);\ninc(k);\nif k=5 then begin\na[i]:=b[7-p];\nk:=0;\nj:=7-p;\ninc(p);\nif p=7 then p:=0;\nend;\nwrite(a[i]);\nend;\nend.\n"}, {"source_code": "var i,k:integer;\nbegin\nreadln(k);\nif k mod 7 =0 then write('ROYGBIV');\nif k mod 8 =0 then write('ROYGRBIV');\nif k mod 13 =0 then write('ROYGBIVGBIVYG');\nif (k mod 4 =0) and(k mod 8<>0) then write('ROYGROYG');\nif (k mod 5 =0) then write('ROYGIROYGI');\nif (k mod 6 =0) then write('ROYGIVROYGIV');\nend."}, {"source_code": "const color:array[1..7] of char=('O','Y','G','B','I','V','R');\nvar answ:array[1..100] of char;\n n:longint;\n\n procedure InputData;\n begin\n readln(n);\n end;\n\n procedure ins(x:longint);\n var j:longint;\n begin\n j:=1;\n while (color[j]=answ[x-1]) or (color[j]=answ[x-2]) or (color[j]=answ[x-3]) do\n inc(j);\n answ[x]:=color[j];\n end;\n\n procedure ProcessData;\n var i,j:longint;\n begin\n for i:=1 to 7 do\n answ[i]:=color[i];\n for i:=8 to n-1 do\n begin\n ins(i);\n end;\n j:=1;\n while (color[j]=answ[n-1]) or (color[j]=answ[1]) or (color[j]=answ[n-2]) or (color[j]=answ[n-3]) do\n inc(j);\n answ[n]:=color[j];\n end;\n\n procedure OutputData;\n var i:longint;\n begin\n for i:=1 to n do\n write(answ[i]);\n end;\nbegin\nInputdata;\nProcessData;\nOutputData;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n:integer;\n i:integer;\n s:string='ROYGBIV';\nbegin\n readln(n);\n\n for i:=1 to 7*(n div 7) do\n begin\n if s<>'' then\n begin\n write(s[1]);\n delete(s,1,1);\n end\n else\n begin\n write('R');\n s := 'OYGBIV';\n end;\n end;\n\n s := 'ROYGBIV';\n\n for i:=7*(n div 7) to n do\n write(s[i-3]);\nend.\n"}, {"source_code": "program z;\n const\n ar:array[1..7] of char=('R','G','B','O','Y','I','V');\n var\n a:array[1..103] of char;\n n,i,j:integer;\n begin\n read(n);\n for i:=1 to 103 do a[i]:='.';\n a[1]:='R';\n a[2]:='G';\n a[3]:='B';\n a[4]:='O';\n a[5]:='Y';\n a[6]:='I';\n a[7]:='U';\n a[n+1]:='R';\n a[n+2]:='G';\n a[n+3]:='B';\n for i:=8 to n-3 do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=n-3 to n do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])and\n (a[i+1]<>ar[j])and(a[i+2]<>ar[j])and(a[i+3]<>ar[j])and(a[i]='.')\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=1 to n do write(a[i]);\nend.\n\n"}, {"source_code": "var i,j,n,m,k:longint;\na:string;\nbegin\na:='ROYGBIV';\nreadln (n);\nj:=0;\nk:=0;\nfor i:=1 to (n div 7)*7+1 do\n begin\n inc (j);\n if j<=7 then write (a[j])\n else j:=j-8;\n end;\nif n mod 7 = 0 then writeln ;\nif n mod 7 = 1 then writeln ('G');\nif n mod 7 = 2 then writeln ('GB');\nif n mod 7 = 3 then writeln ('GBI');\nif n mod 7 = 4 then writeln ('GBIV');\nif n mod 7 = 5 then writeln ('GBIVG');\nif n mod 7 = 6 then writeln ('GBIVGB');\nend."}, {"source_code": "const\n s:array[0..6] of char = ('R','O','Y','G','B','I','V');\nvar\n i,n:longint;\n ans:array[0..1000] of char;\nbegin\n readln(n);\n for i:=1 to n do ans[i]:=s[i mod 7];\n if ans[n]=ans[1] then ans[n]:=ans[n-4];\n for i:=1 to n do write(ans[i]);\n writeln;\nend.\n"}, {"source_code": "var n,i:longint;\n begin\n read(n);\n for i:=1 to n do\n begin\n if i=1 then write('R')\n else\n if i=2 then write('O')\n else\n if i=3 then write('Y')\n else\n if i=4 then write('G')\n else\n if i=5 then write('B')\n else\n if i=6 then write('I')\n else\n if i=7 then write('V')\n else\n if i mod 4=1 then write('R')\n else\n if i mod 4=2 then write('O')\n else\n if i mod 4=3 then write('Y')\n else write('G');\n end;\n end."}, {"source_code": "const c:set of char = ['a','e','u','i','o'];\nvar i,j,ans,n,m,k:longint;\n a:array [1..10000] of longint;\n s:ansistring;\nbegin\n readln(n);\n k:=1;\n for i:=1 to n do\n begin\n if (i=n-1) then\n begin\n write('Y');\n continue;\n end;\n if (i=n) then\n begin\n write('G');\n continue;\n end;\n if (i=n-2) then\n begin\n write('O');\n continue;\n end;\n\n if (i=n-3) then\n begin\n write('R');\n continue;\n end;\n if k=1 then write('R');\n if k=2 then write('O');\n if k=3 then write('Y');\n if k=4 then write('G');\n if k=5 then write('B');\n if k=6 then write('I');\n if k=7 then write('V');\n\n inc(k);\n if k=8 then k:=1;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n:integer;\n i:integer;\n s:string='ROYGBIV';\nbegin\n readln(n);\n for i:=1 to n-3 do\n begin\n if s<>'' then\n begin\n write(s[1]);\n delete(s,1,1);\n end\n else\n begin\n write('G');\n s :='ROYGBIV';\n end;\n end;\n\n write('YGB');\nend.\n"}, {"source_code": "var\nn,i:longint;\nbegin\n readln (n);\n for i:=1 to n do\n if i mod 7=1 then\n write ('R')\n else\n begin\n if i mod 7=2 then\n write ('O')\n else\n begin\n if i mod 7=3 then\n write ('Y')\n else\n begin\n if i mod 7=4 then\n write ('G')\n else\n begin\n if i mod 7=5 then\n write ('B')\n else\n begin\n if i mod 7=6 then\n write ('I')\n else\n write ('V'); \n end;\n end;\n end;\n end;\n end;\nend.\n"}, {"source_code": "\nuses\n SysUtils;\n const Mas:array[1..7] of char=('R','O','Y','G','B','I','V');\nVAR N,i,j:INTEGER; m:set of char; len:string;\nbegin\nreadln(n);\nfor i:=1 to n-n mod 7 do begin\nwrite(mas[i]);len:=len+mas[i]; end;\nm:=[];\nfor i:=n+1-n mod 7 to n do begin\n m:=[];\n for j:=i-3 to i-1 do m:=m +[len[j]];\n for j:=i+1 to i+3 do if j>n then m:=m + [len[j mod (n+1)+1]];\n for j:=1 to 7 do if not (mas[j] in m) then begin write(mas[j]);len:=len+mas[j];break;end;\nend;\nend."}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\n\nvar\n n,i,j: integer;\n a: array[1..7]of char;\n t: char;\nbegin\n read(n);\n a[1]:='R';\n a[2]:='O';\n a[3]:='Y';\n a[4]:='G';\n a[5]:='B';\n a[6]:='I';\n a[7]:='V';\n j:=1;\n if (n-1) mod 7=0 then n:=n-1;\n for i:=1 to n do begin\n if j=8 then j:=1;\n write(a[j]);\n if i=n then t:=a[j];\n inc(j);\n end;\n if n mod 7=0 then\n for i:=1 to 7 do\n if (a[i]<>t) and (a[i]<>a[1]) then begin\n write(a[i]);\n halt;\n end;\nend."}, {"source_code": "{$M 17777777}\n{$r-,q-,h+}\n\n//Uses Brain;\n\nUses\n\tMath , SysUtils;\n\nConst\n\tinf = 1 shl 30;\ntype\n\tint = int64;\n\nvar a : Array[-1..101] of char;\t\n\nprocedure swap(var a,b : char);\nvar c : char;\nbegin\n c:=a; a:=b; b:=c;\nend;\n\t\nprocedure reading;\nvar n , i , j : longint; s : string;\nbegin\n readln(n);\n s:='ROYGBIV';\n j:=1;\n for i:=1 to n do begin\n \t a[i]:=s[j];\n \t inc(j);\n if j > 7 then j:=1;\n end;\n for i:=1 to 7 do begin\n \tif (s[i] <> a[n - 1]) and (s[i] <> a[n - 2]) and (s[i] <> a[n - 3]) and \n \t (s[i] <> a[1]) and (s[i] <> a[2]) and (s[i] <> a[3]) then begin\n \t \ta[n]:=s[i];\n \t \tbreak; \t \t\n \t end;\n end;\n for i:=1 to n do write(a[i]); \t \t\nend;\n\nbegin\n randomize;\n reading;\nend. "}, {"source_code": "var\nn,i:longint;\nbegin\n readln (n);\n for i:=1 to n do\n if i mod 7=1 then\n write ('R')\n else\n begin\n if i mod 7=2 then\n write ('O')\n else\n begin\n if i mod 7=3 then\n write ('Y')\n else\n begin\n if i mod 7=4 then\n write ('G')\n else\n begin\n if i mod 7=5 then\n write ('B')\n else\n begin\n if i mod 7=6 then\n write ('I')\n else\n write ('V'); \n end;\n end;\n end;\n end;\n end;\nend.\n"}, {"source_code": "var n,m,i,j,k:longint;\n a:array[0..201] of longint;\n pp:boolean;\n S:string;\n\n\nfunction Podxod(num:longint):boolean;\nbegin\n if (a[num]<>a[num+1]) and\n (a[num]<>a[num+2]) and\n (a[num]<>a[num+3]) and\n (a[num]<>a[num-1]) and\n (a[num]<>a[num-2]) and\n (a[num]<>a[num-3]) then podxod:=true else\n podxod:=false;\nend;\n\n\n\n\nbegin\nfillchar(a,sizeof(a),0);\nreadln(n);\nrandomize;\na[1]:=random(7)+1;\na[2]:=random(7)+1;\nwhile a[2]=a[1] do a[2]:=random(7)+1;\na[3]:=random(7)+1;\nwhile (a[2]=a[3]) or (a[1]=a[3]) do a[3]:=random(7)+1;\na[n+1]:=a[1]; a[n+2]:=a[2]; a[n+3]:=a[3];\nfor i:= 4 to n-3 do\n begin\n a[i]:=random(7)+1;\n while (a[i]=a[i-1]) or (a[i]=a[i-2]) or (a[i]=a[i-3]) do\n a[i]:=random(7)+1;\n end;\n pp:=false;\n while pp=false do\n begin\n a[n]:=random(7)+1;\n a[n-1]:=random(7)+1;\n a[n-2]:=random(7)+1;\n if not Podxod(n) then pp:=false else\n if not Podxod(n-1) then pp:=false else\n if not Podxod(n-2) then pp:=false else\n pp:=true;\n end;\n s:='ROYGBIV';\n for i:= 1 to n do\n write(s[a[i]]);\n writeln;\nend.\n"}, {"source_code": "var n,i:longint;\na:array[0..6] of char;\nbegin\n read(n);\n a[0]:='R';\n a[1]:='O';\n a[2]:='Y';\n a[3]:='G';\n a[4]:='B';\n a[5]:='I';\n a[6]:='V';\n for i:=1 to n do\n write(a[i mod 7]);\n writeln\n end.\n"}, {"source_code": "{$M 17777777}\n{$r-,q-,h+}\n\n//Uses Brain;\n\nUses\n\tMath , SysUtils;\n\nConst\n\tinf = 1 shl 30;\ntype\n\tint = int64;\n\nvar a : Array[0..101] of char;\t\n\nprocedure swap(var a,b : char);\nvar c : char;\nbegin\n c:=a; a:=b; b:=c;\nend;\n\t\nprocedure reading;\nvar n , i , j : longint; s : string;\nbegin\n readln(n);\n s:='ROYGBIV';\n j:=1;\n for i:=1 to n do begin\n \t a[i]:=s[j];\n \t inc(j);\n if j > 7 then j:=1;\n end;\n if n > 7 then \n swap(a[1] , a[5]);\n for i:=1 to n do write(a[i]); \t \t\nend;\n\nbegin\n randomize;\n reading;\nend."}, {"source_code": "var i,j,n,m:longint;\na:string;\nbegin\na:='ROYGBIVGBIVYGBIVOGBYVROYGBIV';\nreadln (n);\nj:=1;\nfor i:=1 to n do\n begin\n if j<=28 then write (a[j])\n else j:=j-28;\n j:=j+1;\n end;\nwriteln ;\nend."}, {"source_code": "program z;\n const\n ar:array[1..7] of char=('R','G','B','O','Y','I','V');\n var\n a:array[1..103] of char;\n n,i,j:integer;\n begin\n read(n);\n for i:=1 to 103 do a[i]:='.';\n a[1]:='R';\n a[2]:='G';\n a[3]:='B';\n a[4]:='O';\n a[5]:='Y';\n a[6]:='I';\n a[7]:='U';\n a[n+1]:='R';\n a[n+2]:='G';\n a[n+3]:='B';\n for i:=8 to n-3 do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=n-3 to n do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])and\n (a[i+1]<>ar[j])and(a[i+2]<>ar[j])and(a[i+3]<>ar[j])and(a[i]='.')\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=1 to n do write(a[i]);\nend.\n\n"}, {"source_code": "program b70;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,j:integer;\n s:ansistring;\n col:array[0..6] of char = ('R','O','Y','G','B','I','V');\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n {$ENDIF}\n readln(n);\n s:='OYGBIVR';\n if odd(n) then for i:=8 to n do s:=s+col[i mod 3 +4] else\n for i:=8 to n do s:=s+col[i mod 4 + 3];\n writeln(s);\nend.\n"}, {"source_code": "Const col='ROYGBIV';{ fp }\nVar\n n,j : longint;\n a : array[0..104] of longint;\n used : array[0..10] of longint;\n ok : boolean;\n\n\n\n Function good(x1,x2,x3,x4:longint):boolean;\n Begin\n If (x1=x2) or (x1=x3) or (x1=x4) or (x2=x3) or (x2=x4) or (x3=x4) then good := false\n else good := true;\n End;\n\n\n Procedure go(num:longint);\n Var\n i:longint;\n\n begin\n If num=n+1 then\n begin\n ok := true;\n a[n+1] := a[1];\n a[n+2] := a[2];\n a[n+3] := a[3];\n a[n+4] := a[4];\n For i := n-2 to n do\n If not good(a[i],a[i+1],a[i+2],a[i+3]) then\n Begin\n ok := false;\n break;\n End;\n If ok=false then exit;\n For i := 1 to n do\n Write(col[a[i]]);\n WriteLn;\n halt(0);\n end;\n If num>4 then used[a[num-4]] := 0;\n For i := 1 to 7 do\n If used[i]=0 then\n Begin\n used[i] := 1;\n a[num] := i;\n go(num+1);\n used[i] := 0;\n End;\n if num>4 then used[a[num-4]] := 1;\n end;\n\n Begin\n REad(n);\n go(1);\n end."}, {"source_code": "var n,i:longint;\nbegin\n read(n);\n write('ROIGBIV');\n for i:=1 to n-7 do\n if i mod 4=1 then write('G')\n else if i mod 4=2 then write('B')\n else if i mod 4=3 then write('I')\n else write('V');\nend."}, {"source_code": "program d;\nvar\n a,b : array [1..111] of char;\n c : char;\ni,j,n,i1 : integer;\n f : boolean;\nBEGIN\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nreadln (n);\n\nfor i:=1 to 7 do a[i]:=b[i];\nfor I:=8 to n do\n for i1:=1 to 7 do\n begin\n\tf:=false;\n for j:=1 to 3 do\n begin\n if i+j>n then c:=a[(i+j) mod n] else c:=a[i+j];\n\t if (a[i-j]=b[i1]) or (c=b[i1]) then f:=true;\n \t end;\n if not f then a[i]:=b[i1];\n\tend;\nfor i:=1 to n-1 do write (a[i],' '); write (a[n]);\n\nEND.\n"}, {"source_code": "Var n,i:LongInt;\n a:array[0..100] of Char;\n begin\n ReadLn(n);\n a[1]:='R';\n a[2]:='O';\n A[3]:='Y';\n A[4]:='G';\n a[5]:='B';\n a[6]:='I';\n a[0]:='V';\n For i:=1 to n do\n Write(a[i mod 7]);\n end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i : longint;\n a : array[1..6] of string = ('R','RY','RYO','RYOG','RYOGB','RYOGBI');\n\nbegin\n readln(n);\n for i:=1 to (n div 7) do write('RYOGBIV');\n write(a[n mod 7]);\n readln;\nend.\n"}, {"source_code": "var n,i: longint;\n s: array [0..6] of string[1];\nbegin\n read(n);\n for i:=1 to 7 do s[i-1]:=copy('RYOGBIV',i,1);\n for i:=1 to n-3 do write(S[i mod 7]);\n case (n-3 ) mod 7 of\n 4: writeln(S[5],S[6],S[0]);\n 5: writeln(S[2],S[3],S[4]);\n 6: writeln(S[3],S[4],S[5]);\n 0: writeln(S[4],S[5],S[6]);\n 1: writeln(S[2],S[3],S[4]);\n 2: writeln(S[3],S[4],S[5]);\n 3: writeln(S[4],S[5],S[6]);\n end;\nend.\n\n"}, {"source_code": "Const col='ROYGBIV';{ fp }\nVar\n n,j : longint;\n a : array[0..104] of longint;\n used : array[0..10] of longint;\n ok : boolean;\n\n\n\n Function good(x1,x2,x3,x4:longint):boolean;\n Begin\n If (x1=x2) or (x1=x3) or (x1=x4) or (x2=x3) or (x2=x4) or (x3=x4) then good := false\n else good := true;\n End;\n\n\n Procedure go(num:longint);\n Var\n i:longint;\n\n begin\n If num=n+1 then\n begin\n ok := true;\n a[n+1] := a[1];\n a[n+2] := a[2];\n a[n+3] := a[3];\n a[n+4] := a[4];\n For i := n-2 to n do\n If not good(a[i],a[i+1],a[i+2],a[i+3]) then\n Begin\n ok := false;\n break;\n End;\n If ok=false then exit;\n For i := 1 to n do\n Write(col[a[i]]);\n WriteLn;\n halt(0);\n end;\n If num>4 then used[a[num-4]] := 0;\n For i := 1 to 7 do\n If used[i]=0 then\n Begin\n used[i] := 1;\n a[num] := i;\n go(num+1);\n used[i] := 0;\n End;\n if num>4 then used[a[num-4]] := 1;\n end;\n\n Begin\n REad(n);\n go(1);\n end."}, {"source_code": "const c:set of char = ['a','e','u','i','o'];\nvar i,j,ans,n,p,k:longint;\n a:array [0..10000] of longint;\n s:ansistring;\n\n function max(x,y:longint):longint;\n begin\n if x> y then max:=x\n else max:=y;\n end;\nbegin\n readln(n);\n k:=1;\n\n for i:=1 to n do\n begin\n a[i]:=k;\n inc(k);\n if k=8 then k:=1;\n\n end;\n For i:=n downto max(n-3,8) do\n a[i]:=a[i-n div 2];\n\n\n for i:=1 to n do\n begin\n k:=a[i];\n if k=1 then write('R');\n if k=2 then write('O');\n if k=3 then write('Y');\n if k=4 then write('G');\n if k=5 then write('B');\n if k=6 then write('I');\n if k=7 then write('V');\n\n\n end;\n\nend.\n"}, {"source_code": "const c:set of char = ['a','e','u','i','o'];\nvar i,j,ans,n,m,k:longint;\n a:array [1..10000] of longint;\n s:ansistring;\nbegin\n readln(n);\n k:=1;\n for i:=1 to n do\n begin\n if (i=n-1) then\n begin\n write('Y'); inc(k);\n continue;\n end;\n if (i=n) then\n begin inc(k);\n write('G');\n continue;\n end;\n if (i=n-2) then\n begin\n write('O'); inc(k);\n continue;\n end;\n\n if (i=n-3) then\n begin\n write('R');\n inc(k);\n continue;\n end;\n if k=1 then write('R');\n if k=2 then write('O');\n if k=3 then write('Y');\n if k=4 then write('G');\n if k=5 then write('B');\n if k=6 then write('I');\n if k=7 then write('V');\n\n inc(k);\n if k=8 then k:=1;\n end;\nend.\n"}, {"source_code": "program Project1112;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n a:array[1..7] of char = ('R','O','Y','G','B','I','V');\nvar\n i,j,k,n:integer;\n s:string;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<=7 then\n for i:=1 to n do\n begin\n s:=s+a[i];\n exit;\n end;\n s:='ROYGBIV';\n while length(s)0 do\n begin\n inc(kol);\n write(stas);\n if kol=3\n then\n begin\n kol:=0;\n if stas='V' then stas:='I'\n else stas:='V';\n end;\n dec(n);\n end;\n\nEnd."}, {"source_code": "Var i,n,k,l:Integer;\n s,s1:String;\nBegin\n Readln (n);\n s:='ROYGBIV';\n k:=n div 7;\n For I:=1 to k do\n Write (s);\n If (n-1) mod 7=0\n then Begin\n Writeln ('G');\n End\n else Begin\n s1:=Copy (s,1,n mod 7);\n Writeln (s1);\n End;\nEnd."}, {"source_code": "const c:set of char = ['a','e','u','i','o'];\nvar i,j,ans,n,m,k:longint;\n a:array [1..10000] of longint;\n s:ansistring;\nbegin\n readln(n);\n k:=1;\n\n for i:=1 to 7 do\n begin\n if k=1 then write('R');\n if k=2 then write('O');\n if k=3 then write('Y');\n if k=4 then write('G');\n if k=5 then write('B');\n if k=6 then write('I');\n if k=7 then write('V');\n\n inc(k);\n if k=8 then k:=1;\n end;\n\n for i:=8 to n do\n begin\n if (i=n-1) then\n begin\n write('Y'); inc(k);\n continue;\n end;\n if (i=n) then\n begin inc(k);\n write('G');\n continue;\n end;\n if (i=n-2) then\n begin\n write('O'); inc(k);\n continue;\n end;\n\n if (i=n-3) then\n begin\n write('R');\n inc(k);\n continue;\n end;\n if k=1 then write('R');\n if k=2 then write('O');\n if k=3 then write('Y');\n if k=4 then write('G');\n if k=5 then write('B');\n if k=6 then write('I');\n if k=7 then write('V');\n\n inc(k);\n if k=8 then k:=1;\n end;\nend.\n"}, {"source_code": "var i,j,n,m:longint;\na:string;\nbegin\na:='ROYGBIVGBIVYGBIVOGBYVROYGBIV';\nreadln (n);\nj:=1;\nfor i:=1 to n do\n begin\n if j<=28 then write (a[j])\n else j:=j-28;\n j:=j+1;\n end;\nwriteln ;\nend."}, {"source_code": "var\n n,i,j:longint;\n s,t:string;\n c:array[0..6]of char;\nbegin\n read(n);\n c[1]:='R';\n c[2]:='O';\n c[3]:='Y';\n c[4]:='G';\n c[5]:='B';\n c[6]:='I';\n c[0]:='V';\n if n>=11 then \n begin\n for i:=1 to n do\n write(c[i mod 7]);\n exit;\n end else\n begin\n for i:=0 to 6 do\n write(c[i]);\n for i:=8 to n do\n write(c[(i-4) mod 7]);\n end;\nend."}, {"source_code": "var\n n,i,j:longint;\n s,t:string;\n c:array[0..6]of char;\nbegin\n read(n);\n c[1]:='R';\n c[2]:='O';\n c[3]:='Y';\n c[4]:='G';\n c[5]:='B';\n c[6]:='I';\n c[0]:='V';\n if n>=11 then \n begin\n for i:=1 to n do\n write(c[i mod 7]);\n exit;\n end else\n begin\n for i:=1 to 7 do\n write(c[i mod 7]);\n for i:=8 to n do\n write(c[(i-4) mod 7]);\n end;\nend."}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n n,i : integer;\n c : array [1..8] of char;\n\nbegin\n read(n);\n c[1] := 'R';\n c[2] := 'O';\n c[3] := 'Y';\n c[4] := 'G';\n c[5] := 'B';\n c[6] := 'I';\n c[7] := 'V';\n for i := 1 to n div 7 do write('ROYGRBIV');\n for i := 1 to n mod 7 do write(c[i]);\nend."}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\n\nvar\n n,i,j: integer;\n a: array[1..7]of char;\n t: char;\nbegin\n read(n);\n a[1]:='R';\n a[2]:='O';\n a[3]:='Y';\n a[4]:='G';\n a[5]:='B';\n a[6]:='I';\n a[7]:='V';\n j:=1;\n if (n-1) mod 7=0 then n:=n-1;\n for i:=1 to n do begin\n if j=8 then j:=1;\n write(a[j]);\n if i=n then t:=a[j];\n inc(j);\n end;\n if n mod 7=0 then\n for i:=1 to 7 do\n if (a[i]<>t) and (a[i]<>a[1]) then begin\n write(a[i]);\n halt;\n end;\nend."}, {"source_code": "var\nn,i:longint;\nbegin\n readln (n);\n for i:=1 to n do\n if i mod 4=1 then\n write ('R')\n else\n begin\n if i mod 4=2 then\n write ('O')\n else\n begin\n if i mod 4=3 then\n write ('Y')\n else\n write ('G'); \n end;\n end;\nend.\n"}, {"source_code": "var\n n,i,j:longint;\n s,t:string;\n c:array[0..6]of char;\nbegin\n read(n);\n c[1]:='R';\n c[2]:='O';\n c[3]:='Y';\n c[4]:='G';\n c[5]:='B';\n c[6]:='I';\n c[0]:='V';\n if n>=11 then \n begin\n for i:=1 to n do\n write(c[i mod 7]);\n exit;\n end else\n begin\n for i:=1 to 7 do\n write(c[i mod 7]);\n for i:=8 to n do\n write(c[(i-4) mod 7]);\n end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n str,ns,ns1,ns2,ns3,s:string;\n i,j,n,k,l,pos:integer;\n\nbegin\n readln(n);\n ns:='a';\n pos:=1;\n for i:=1 to n do\n begin\n Insert(ns,s,pos);\n Inc(pos);\n end;\n str:='ROYGBIV';\n if n<=7 then\n for i:=1 to n do\n s[i]:=str[i]\n else\n begin\n l:=n mod 7;\n k:=n div 7;\n if l<=4 then\n begin\n ns1:=Copy(str,1,4);\n ns2:=Copy(str,1,l);\n ns3:=Copy(str,5,3);\n s:=ns1+ns2+ns3;\n pos:=l+8;\n end\n else\n begin\n for i:=1 to l do\n s[i]:=str[i];\n pos:=l+1;\n end;\n for i:=1 to k do\n for j:=1 to 7 do\n s[pos+j-1]:=str[j];\n end;\n writeln(s);\n readln;\nend."}, {"source_code": "var\nn,i:longint;\nbegin\n readln (n);\n for i:=1 to n do\n if i mod 7=1 then\n write ('R')\n else\n begin\n if i mod 7=2 then\n write ('O')\n else\n begin\n if i mod 7=3 then\n write ('Y')\n else\n begin\n if i mod 7=4 then\n write ('G')\n else\n begin\n if i mod 7=5 then\n write ('B')\n else\n begin\n if i mod 7=6 then\n write ('I')\n else\n write ('V'); \n end;\n end;\n end;\n end;\n end;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n C : array[1..7] of char = ('R','O','Y','G','B','I','V');\nvar\n f : text;\n n,i,j : longint;\nbegin\n Assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n Assign(f,fo);\n rewrite(f);\n j := 0;\n For i := 1 to n do\n Begin\n inc(j);\n if j = 8 then j := 1;\n Write(f,C[j]);\n End;\n Close(f);\nEnd."}, {"source_code": "Var\nn,i,k,j:longint;\ns:string;\nBegin\nread(n);\ns:='ROYGBIV';\nfor i:=1 to (n div 7)-1 do\n write(s);write('ROYG');\nfor i:=1 to (n mod 7) do\n write(s[i]);\nif (n mod 7)<=4 then write('BIV') else\n Begin\n for i:=(n mod 7)+1 to (n mod 7)+3 do\n if i<=7 then\n write(s[i]) else break;\n k:=i-((n mod 7)+1);\n for j:=i-4 to i-(k+1) do\n write(s[j]);\n end;\nend.\n"}, {"source_code": "var i,k:integer;\nbegin\nreadln(k);\nif k mod 7 =0 then write('ROYGBIV');\nif k mod 8 =0 then write('ROYGRBIV');\nif k mod 13 =0 then write('ROYGBIVGBIVYG');\nif (k mod 2 =0) and(k mod 8<>0) then write('ROYGROYG');\nif (k mod 5 =0) then write('ROYGIROYGI');\nif (k mod 6 =0) then write('ROYGIVROYGIV');\nend."}, {"source_code": "program z;\n const\n ar:array[1..7] of char=('R','G','B','O','Y','I','V');\n var\n a:array[1..103] of char;\n n,i,j:integer;\n begin\n read(n);\n a[1]:='R';\n a[2]:='G';\n a[3]:='B';\n a[4]:='O';\n a[5]:='Y';\n a[6]:='I';\n a[7]:='U';\n a[n+1]:='R';\n a[n+2]:='G';\n a[n+3]:='B';\n for i:=8 to n-3 do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=n-3 to n do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])and\n (a[i+1]<>ar[j])and(a[i+2]<>ar[j])and(a[i+3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=1 to n do write(a[i]);\nend.\n\n"}, {"source_code": "var a,i:integer; s,s1:string;\nbegin\nread(a);\ns:='ROYGBIV';\nfor i:=1 to a div 7 do\nwrite(s);\nfor i:=1 to a mod 7 do\nwrite(s[i+3]);\nend."}, {"source_code": "const\na:array[0..6] of char=('R','O','Y','G','B','I','V');\nvar\nn,i,j:longint;\nbegin\n readln(n);\n for i:=1 to (n div 7)*7 do\n write(a[i mod 7]);\ni:=i mod 7;\nif n=8 then\nbegin\nwrite('B');\nhalt;\nend\nelse\nif n=9 then\nbegin\nwrite('IG');\nhalt;\nend;\nfor j:=1 to n mod 7 do\n begin\n write(a[(i+2)mod 7]);\n inc(i);\n end;\n\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n:integer;\n i:integer;\n s:string='ROYGBIV';\nbegin\n readln(n);\n\n for i:=1 to 7*(n div 7) do\n begin\n if s<>'' then\n begin\n write(s[1]);\n delete(s,1,1);\n end\n else\n begin\n write('R');\n s := 'OYGBIV';\n end;\n end;\n\n s := 'ROYGBIV';\n\n for i:=7*(n div 7) to n-1 do\n write(s[i-3]);\nend."}, {"source_code": "program Project1112;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n a:array[1..7] of char = ('R','O','Y','G','B','I','V');\nvar\n i,j,k,n:integer;\n s:string;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<=7 then\n for i:=1 to n do\n begin\n s:=s+a[i];\n exit;\n end;\n s:='ROYGBIV';\n while length(s)'' then\n begin\n write(s[1]);\n delete(s,1,1);\n end\n else\n begin\n write('G');\n s :='ROYGBIV';\n end;\n end;\n\n for i:=1 to n-4 do\n begin\n if s<>'' then\n begin\n write(s[1]);\n delete(s,1,1);\n end\n else\n begin\n write('G');\n s :='ROYGBIV';\n end;\n end;\nend.\n"}, {"source_code": "const a:array[1..8] of char=('R','O','Y','G','R','B','I','V');\nvar n:integer;\nprocedure form;\nvar i:integer;\nbegin\n for i:=1 to n do\n write(a[i mod 8+1]);\nend;\n\nBEGIN\n readln(n);\n form;\nEND.\n"}, {"source_code": "var a:array[1..110] of char;\n b:array[1..10] of char;\n i,n,k,j,p:integer;\nbegin\nread(n);\nk:=0;\np:=4;\nj:=3;\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nwrite(b[1],b[2],b[3],b[4],b[5],b[6],b[7]);\nfor i:=8 to n do begin\nif j=7 then j:=0;\na[i]:=b[j+1];\ninc(j);\ninc(k);\nif k=5 then begin\na[i]:=b[7-p];\nk:=0;\nj:=7-p;\ninc(p);\nif p=7 then p:=0;\nend;\nwrite(a[i]);\nend;\nend.\n"}, {"source_code": "var\n met:array [1..1000] of longint;\n i,j,n,m,k,l:longint;\n c:char;\n s,s1,ss:string;\nbegin\n readln(n);\n ss:='OYGBIV';\n l:=1;\n for i:=1 to n do\n begin\n met[i]:=l;\n inc(l);\n inc(k);\n if k>3 then\n begin\n met[i]:=-1;\n k:=0;\n dec(l);\n end;\n if l>6 then l:=1;\n end;\n for i:=1 to n do\n if met[i]<>-1 then write(ss[met[i]])\n else write('R');\nend."}, {"source_code": "uses math;\nvar\n n:longint;\n i:longint;\nbegin\n readln(n);\n\n n:=n-7;\n write('ROYGBIV');\n\n for i:=1 to n div 4 do\n write('ROYG');\n case n mod 4 of\n 1: write('R');\n 2: write('RO');\n 3: write('ROY');\n end;\nend.\n"}, {"source_code": "var\n met,mm:array [1..10000] of longint;\n i,j,n,m,k:longint;\n s:string;\nbegin\n s:='ROYGBIV';\n readln(n);\n for i:=1 to 7 do\n met[i]:=i;\n j:=8;\n for i:=8 to n-2 do\n begin\n met[j]:=((i-1) mod 7)+1;\n inc(j);\n end;\n mm[1]:=1;\n for i:=n-3 downto n-5 do\n mm[met[i]]:=1;\n for i:=1 to 7 do\n if mm[i]<>1 then begin\n met[n-2]:=i;\n break;\n end;\n fillchar(mm,sizeof(mm),0);\n mm[1]:=1;\n mm[2]:=1;\n for i:=n-2 downto n-4 do\n mm[met[i]]:=1;\n for i:=1 to 7 do\n if mm[i]<>1 then begin\n met[n-1]:=i;\n break;\n end;\n fillchar(mm,sizeof(mm),0);\n mm[1]:=1;\n mm[2]:=1;\n mm[3]:=1;\n for i:=n-1 downto n-3 do\n mm[met[i]]:=1;\n for i:=1 to 7 do\n if mm[i]<>1 then begin\n met[n]:=i;\n break;\n end;\n for i:=1 to n do\n begin\n write(s[met[i]]);\n end;\nend.\n"}, {"source_code": "{$M 17777777}\n{$r-,q-,h+}\n\n//Uses Brain;\n\nUses\n\tMath , SysUtils;\n\nConst\n\tinf = 1 shl 30;\ntype\n\tint = int64;\n\nvar a : Array[0..101] of char;\t\n\t\nprocedure reading;\nvar n , i , j : longint; s : string;\nbegin\n readln(n);\n s:='ROYGBIV';\n j:=1;\n for i:=1 to n do begin\n \t a[i]:=s[j];\n \t inc(j);\n if j > 7 then j:=1;\n end;\n while (a[1] = a[n]) or (a[1] = a[n - 1]) or (a[1] = a[n - 2]) or (a[1] = a[2]) or\n (a[1] = a[3]) or (a[1] = a[4]) do begin\n \tj:= 1 + random(6);\n \ta[1]:= s[j];\n end;\n for i:=1 to n do write(a[i]); \t \t\nend;\n\nbegin\n randomize;\n reading;\nend."}, {"source_code": "var i,j,n,m,k:longint;\na:string;\nbegin\na:='ROYGBIV';\nreadln (n);\nj:=0;\nk:=0;\nfor i:=1 to (n div 7)*7+1 do\n begin\n inc (j);\n if j<=7 then write (a[j])\n else j:=j-8;\n end;\nif n mod 7 = 0 then writeln ;\nif n mod 7 = 1 then writeln ('G');\nif n mod 7 = 2 then writeln ('GB');\nif n mod 7 = 3 then writeln ('GBI');\nif n mod 7 = 4 then writeln ('GBIV');\nif n mod 7 = 5 then writeln ('GBIVG');\nif n mod 7 = 6 then writeln ('GBIVGB');\nend."}, {"source_code": "const a:array[1..8] of char=('R','O','Y','G','R','B','I','V');\n b:array[1..4] of char=('R','B','I','V');\nvar n:integer;\n m:array[1..200] of char;\n\nprocedure form;\nvar i:integer;may:set of char;\nbegin\n for i:=1 to n do\n if n<=3 then write(a[i])\n else write(b[i mod 4+1]);\nend;\n\nBEGIN\n readln(n);\n form;\nEND.\n"}, {"source_code": "var i,k:integer;\nbegin\nreadln(k);\nif k mod 7 =0 then write('ROYGBIV');\nif k mod 8 =0 then write('ROYGRBIV');\nif k mod 13 =0 then write('ROYGBIVGBIVYG');\nif (k mod 4 =0) and(k mod 8<>0) then write('ROYGROYG');\nif (k mod 5 =0) then write('ROYGIROYGI');\nif (k mod 6 =0) then write('ROYGIVROYGIV');\nend."}, {"source_code": "var\n n,i,j,k,m,h,c,x,z : longint;\n s,ss,p,t : ansistring;\nbegin\n readln(n);\n if n=7 then\n begin\n writeln('ROYGBIV');\n halt;\n end;\n for i:=1 to n div 7 do write('ROYGBIV');\n for i:=1 to n mod 7 do\n if i=1 then write('R') else\n if i=2 then write('O') else\n if i=3 then write('Y') else\n if i=4 then write('G') else\n if i=5 then write('B') else\n if i=5 then write('I');\n writeln;\nend."}, {"source_code": "var i,k:integer;\nbegin\nreadln(k);\nif k mod 7 =0 then write('ROYGBIV');\nif k mod 8 =0 then write('ROYGRBIV');\nif k mod 13 =0 then write('ROYGBIVGBIVYG');\nif (k mod 2 =0) and(k mod 8<>0) then write('ROYGROYG');\nif (k mod 5 =0) then write('ROYGIROYGI');\nif (k mod 6 =0) then write('ROYGIVROYGIV');\nend."}, {"source_code": "var n,i:byte;\nbegin\nread(n);\nfor i:=1 to (n div 7)*7 do\ncase i mod 7 of\n0:write('V');\n1:write('R');\n2:write('O');\n3:write('Y');\n4:write('G');\n5:write('I');\n6:write('B');\nend;\ncase n mod 7 of\n1:write('G');\n2:write('GY');\n3:write('ROY');\n4:write('ROYG');\n5:write('ROYGI');\n6:write('ROYGIB');\nend;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar\n n, i, h, h1, h2, j : integer;\n s : string;\n vis : array[1..7] of boolean;\n a : array[1..7] of string;\nbegin\n\n readln(n);\n a[1] := 'R';\n a[2] := 'O';\n a[3] := 'Y';\n a[4] := 'G';\n a[5] := 'B';\n a[6] := 'I';\n a[7] := 'V';\n\n s := 'ROYGRBI';\n for i := 8 to n do begin\n for j := 1 to 7 do\n vis[j] := false;\n for j := 1 to 3 do begin\n if s[i - j] = 'R' then\n vis[1] := true;\n if s[i - j] = 'O' then\n vis[2] := true;\n if s[i - j] = 'Y' then\n vis[3] := true;\n if s[i - j] = 'G' then\n vis[4] := true;\n if s[i - j] = 'B' then\n vis[5] := true;\n if s[i - j] = 'I' then\n vis[6] := true;\n if s[i - j] = 'V' then\n vis[7] := true;\n end;\n for j := 1 to 3 do begin\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'R') then\n vis[1] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'O') then\n vis[2] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'Y') then\n vis[3] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'G') then\n vis[4] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'B') then\n vis[5] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'I') then\n vis[6] := true;\n if ((i + j) mod n <= length(s)) and (s[(i + j) mod n] = 'V') then\n vis[7] := true;\n end;\n for j := 1 to 7 do\n if vis[j] <> true then begin\n s := s + a[j];\n break;\n end;\n end;\n\n writeln(s);\nend.\n\n"}, {"source_code": "var n,i:byte;\nbegin\nread(n);\nfor i:=1 to (n div 7)*7 do\ncase i mod 7 of\n0:write('V');\n1:write('R');\n2:write('O');\n3:write('Y');\n4:write('G');\n5:write('I');\n6:write('B');\nend;\nif n mod 7=1 then write('G');\nif n mod 7=2 then write('GY');\nend.\n\n\n "}, {"source_code": "{$M 17777777}\n{$r-,q-,h+}\n\n//Uses Brain;\n\nUses\n\tMath , SysUtils;\n\nConst\n\tinf = 1 shl 30;\ntype\n\tint = int64;\n\nvar a : Array[0..101] of char;\t\n\nprocedure swap(var a,b : char);\nvar c : char;\nbegin\n c:=a; a:=b; b:=c;\nend;\n\t\nprocedure reading;\nvar n , i , j : longint; s : string;\nbegin\n readln(n);\n s:='ROYGBIV';\n j:=1;\n for i:=1 to n do begin\n \t a[i]:=s[j];\n \t inc(j);\n if j > 7 then j:=1;\n end;\n if n > 7 then \n swap(a[1] , a[5]);\n for i:=1 to n do write(a[i]); \t \t\nend;\n\nbegin\n randomize;\n reading;\nend."}, {"source_code": "const a:array [1..7] of char = ('R','O','Y','G','B','I','V');\nvar n,m,j,i,k,l:longint;s:string;\n\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(N);\nm:=n mod 7;\nk:=1;\nfor i:=1 to n do\nif (i mod 5=0)and (m>=1) then\n begin\n s:=s+s[i-4];\n dec(m);\n end\n else\n begin\n s:=s+ a[k];\n inc(k);\n if k>7 then k:=1;\n end;\nwriteln(s);\nend."}, {"source_code": "uses math;\n\nconst kt:array[0..6]of char=('R','Y','O','I','B','G','V');\nvar i,n:longint;\n s:string;\nbegin\n readln(n);\n s:='';\n for i:=1 to 7 * (n div 7) do\n begin\n s:=s+kt[i mod 7];\n end;\n\n case n mod 7 of\n 1:s:=s+kt[3];\n 2: begin\n s:=s+kt[3]+kt[4];\n end;\n 3: begin\n s:=s+kt[3]+kt[4] +kt[5];\n end;\n 4: begin\n s:=s+kt[3]+kt[4]+kt[5]+kt[6];\n end;\n 5: begin\n s:=s+kt[3]+kt[2]+kt[4]+kt[5]+kt[6];\n end;\n 6:begin\n s:=s+kt[3]+kt[2]+kt[1]+kt[4]+kt[5]+kt[6];\n end;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var n,i:byte;\nbegin\nread(n);\nfor i:=1 to (n div 7)*7 do\ncase i mod 7 of\n0:write('V');\n1:write('R');\n2:write('O');\n3:write('Y');\n4:write('G');\n5:write('I');\n6:write('B');\nend;\nif n mod 7=1 then write('G');\nif n mod 7=2 then write('GY');\nend.\n\n\n "}, {"source_code": "program d;\nvar\n a,b : array [1..111] of char;\n c : char;\ni,j,n,i1 : integer;\n f : boolean;\nBEGIN\nb[1]:='R';\nb[2]:='O';\nb[3]:='Y';\nb[4]:='G';\nb[5]:='B';\nb[6]:='I';\nb[7]:='V';\nreadln (n);\n\nfor i:=1 to 7 do a[i]:=b[i];\nfor I:=8 to n do\n for i1:=1 to 7 do\n begin\n\tf:=false;\n for j:=1 to 3 do\n begin\n if i+j>n then c:=a[(i+j) mod n] else c:=a[i+j];\n\t if (a[i-j]=b[i1]) or (c=b[i1]) then f:=true;\n \t end;\n if not f then a[i]:=b[i1];\n\tend;\nfor i:=1 to n do write (a[i],' ');\n\nEND.\n"}, {"source_code": "program z;\n const\n ar:array[1..7] of char=('R','G','B','O','Y','I','V');\n var\n a:array[1..103] of char;\n n,i,j:integer;\n begin\n read(n);\n a[1]:='R';\n a[2]:='G';\n a[3]:='B';\n a[n+1]:='R';\n a[n+2]:='G';\n a[n+3]:='B';\n for i:=4 to n-3 do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=n-3 to n do\n begin\n for j:=1 to 7 do\n begin\n if (a[i-1]<>ar[j])and(a[i-2]<>ar[j])and(a[i-3]<>ar[j])and\n (a[i+1]<>ar[j])and(a[i+2]<>ar[j])and(a[i+3]<>ar[j])\n then\n begin\n a[i]:=ar[j];\n break;\n end;\n end;\n end;\n for i:=1 to n do write(a[i]);\nend.\n\n"}], "src_uid": "dc3817c71b1fa5606f316e5e94732296"} {"source_code": "Program p;\nvar n, i: int64;\n\nbegin\nread(n);\nif n mod 2 =0 then writeln(n div 2)\n else \n begin\n for var g:=3 to 100000 do\n if n mod g =0 then\n begin\n i:=g;\n break\n end;\n if i=0 then i:=n;\n writeln((n-i) div 2+1)\n end\nend.", "positive_code": [{"source_code": "var n,d,i,s,j:int64;\n\nbegin\nread(n);\nwhile n<>0 do begin\n j:=2;\n while((n mod j)<>0) do if j<=(trunc(sqrt(n))) then inc(j) else j:=n;;\n n:=n-j;\n inc(s);\n break;\n end;\n s:=s+n div 2;\n write(s);\nend. \n"}, {"source_code": "program xxx;\nvar n:int64;\nd,c:int64;\nbegin\nread(n);\n\nif n>0 then \n\n\n while n>1 do\n begin\n d:=2;\n \n while (n mod d <> 0)and(d 0 then \n begin writeln('1');exit;end\n else\n \n if d mod 2 = 0 then\n begin\n c:=n div 2;\n n:=0;\n end\n else\n \n begin\n \n\n n:=n-d;\n c:=n div 2;\n inc(c);\n n:=0;\n end;\n end;\n \nwriteln(c);\n \nend."}, {"source_code": "var\n i,n,l:int64;\n\nfunction _KTNT(x:qword):boolean;\n var\n i:longint;\n begin\n if x<=1 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if (x mod i = 0) then exit(false);\n exit(true);\n end;\n\nBEGIN\n// assign(input,'A.inp'); reset(input);\n// assign(output,'A.out'); rewrite(output);\n\n read(n);\n\n if (n mod 2 = 0) then\n begin\n write(n div 2);\n halt;\n end;\n\n i:=1;\n while (i <= trunc(sqrt(n))) do\n begin\n if (n mod i = 0) then\n begin\n if (_KTNT(i) = true) then begin l:=i; break; end else\n if (_KTNT(n div i) = true) then\n begin\n l:=n div i;\n break;\n end;\n end;\n inc(i);\n end;\n\n write((n - l) div 2 + 1);\n// close(input);\n// close(output);\nEND.\n"}, {"source_code": "var\n i,n,l:int64;\n\nfunction _KTNT(x:int64):boolean;\n var\n i:longint;\n begin\n if (x = 1) then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if (x mod i = 0) then exit(false);\n\n exit(true);\n end;\n\nBEGIN\n //assign(input,'A.inp'); reset(input);\n //assign(output,'A.out'); rewrite(output);\n\n read(n);\n\n if (n mod 2 = 0) then\n begin\n write(n div 2);\n halt;\n end;\n\n i:=1;\n while (i <= trunc(sqrt(n))) do\n begin\n if (n mod i = 0) then\n begin\n if (_KTNT(i) = true) then\n begin\n l:=i;\n break;\n end;\n if (_KTNT(n div i) = true) then\n begin\n l:=n div i;\n break;\n end;\n end;\n\n inc(i);\n end;\n\n write((n - l) div 2 + 1);\n\n //close(input);\n //close(output);\nEND.\n"}, {"source_code": "var f : text;\ni,dem,j: longint;\nn,kq : int64;\nfunction kt(i : int64) : boolean;\nbegin\n kt := true;\n for j := 2 to trunc(Sqrt(i)) do\n if i mod j = 0 then\n begin\n kt := false;\n break;\n end;\nend;\nbegin\n readln(n);\n dem := 1;\n kq := 0;\n if n>1 then\n begin\n if n mod 2 <> 0 then\n begin\n for i := 3 to trunc(sqrt(n)) do\n if (n mod i = 0)and(kt(i)=true) then\n begin\n kq := ((n div i)-1)*i;\n kq := kq div 2 + 1;\n break;\n end;\n end else kq := n div 2;\n if kq=0 then kq := 1; {}\n end;\n writeln(kq);\nend.\n\n\n\n"}, {"source_code": "var n,s:int64;i:longint;\nf:boolean;\nbegin\n//assign(input,'csjf.in');reset(input);\n//assign(output,'csjf.out');rewrite(output);\nreadln(n);\nfor i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n f:=true;break;\n end;\nif f=false then\n writeln(1)\nelse\n begin\nwhile n mod 2<>0 do\n begin\n s:=s+1;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n break;\n n:=n-i;\n end;\nwriteln(s+n div 2);\n end;\nclose(input);close(output);\nend."}, {"source_code": "var n,t:int64;\ni:longint;\nbegin\n//assign(input,'csjf.in');reset(input);\n//assign(output,'csjf.out');rewrite(output);\nreadln(n);\nif n mod 2=0 then writeln(n div 2)\nelse\n begin\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n t:=i;break;\n end;\n if t=0 then t:=n;\n writeln((n-t) div 2+1);\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var\nbol:boolean;\nn,ind:int64;\ni,j:longint;\nbegin\nreadln(N);\nfor i:=2 to round(sqrt(n)) do begin\n if n mod i =0 then begin\n bol:=false;\n\n if bol=false then begin\n ind:=i;\n break;\n end;\n end;\n if ind<>0 then break;\nend;\n\nif ind=0 then writeln(1)\nelse begin\nif ind=2 then writeln(n div ind)\nelse begin\n writeln(1+(n-ind) div 2);\nend;\nend;\nend."}, {"source_code": "Program ILoveYou;\nVAR n,i:int64;\n\nfunction Prim(x : int64) : boolean;\nVAR i:int64;\nBegin\nPrim:=true;\ni:=2;\nif (x < 2) then Prim:=false;\nwhile (i <= sqrt(x)) do\nBegin\nif ((x mod i) = 0) then Begin Prim:=false; i:=x; end;\ni:=i + 1;\nend;\n\nend;\n\nBegin\n\nReadln(n);\nif (Prim(n)) then Writeln(1) else\nBegin\n\ni:=2;\nwhile ((n mod i) <> 0) do\nBegin\ni:=i + 1;\nend;\n\nWriteln(1 + (n - i) div 2);\n\nend;\n\nReadln;\nEND."}, {"source_code": "var n, d, m : int64;\n \nbegin\n readln(n);\n if (n mod 2 = 0) then writeln(n div 2)\n else\n begin\n d := 3; m := n;\n while (d * d <= n) do\n begin\n if (n mod d = 0) then\n begin\n m := n div d;\n break;\n end;\n d := d + 2;\n end;\n if (m = n) then d := n;\n writeln((n - d) div 2 + 1);\n end;\nend."}, {"source_code": "var i,n:int64;\nbegin\n readln(n);\n if n mod 2=0 then writeln(n div 2)\n else begin\n \tfor i:=3 to 100000 do\n \t if n mod i=0 then break; \n \t if i=100000 then i:=n;\n \t writeln((n-i)div 2+1);\n end;\nend."}, {"source_code": "var n,count:int64;\n i:longint;\nfunction check(n:int64):boolean;\nvar i:longint;\nbegin\n if n=3 then exit(true);\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i)=0 then exit(false)\n else i:=i+2;\n exit(true);\nend;\nbegin\n readln(n);\n count:=0;\n if (n mod 2)=0 then\n begin count:=count + n div 2; write(count); halt; end\n else\n if check(n) then begin inc(count); write(1); halt; end\n else\n begin\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i=0)and(check(i)) then\n begin\n inc(count);\n count:=count+(n-i)div 2;\n write(count);\n halt;\n end\n else i:=i+2;\n end;\nend.\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]0 do\n begin\n p:=minprdel(t);\n if p=2 then begin ot:=ot+t div 2; t:=0; end else\n begin inc(ot); t:=t-p; end;\n { writeln(t,' ',ot);\n }\n end;\n\n writeln(ot);\n\n\n1: close(output);\nend.\n"}, {"source_code": "var n,dem:int64;\n i:longint;\nfunction check(n:int64):boolean;\nvar i:longint;\nbegin\n if n=3 then exit(true);\n i:=3;\n while i<=trunc(sqrt(n)) do if (n mod i)=0 then exit(false)\n else i:=i+2;\n exit(true);\nend;\nbegin\n readln(n);\n dem:=0;\n if (n mod 2)=0 then\n begin dem:=dem + n div 2; write(dem); end\n else\n if check(n) then begin inc(dem); write(1); end\n else\n begin\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i=0)and(check(i)) then\n begin\n inc(dem);\n dem:=dem+(n-i)div 2;\n write(dem);\n halt;\n end\n else i:=i+2;\n end;\nend.\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]0 do\n begin\n p:=minprdel(t);\n if p=2 then begin ot:=ot+t div 2; t:=0; end else\n begin inc(ot); t:=t-p; end;\n { writeln(t,' ',ot);\n }\n end;\n\n writeln(ot);\n\n\n1: close(output);\nend.\n"}, {"source_code": "program task_2;\n\nuses\n Classes, SysUtils, Math;\n\nvar\n L: string;\n N: Int64;\n C: Int64;\n I: Int64;\n M: Int64;\n\nbegin\n Readln(L);\n N := StrToInt64(L);\n C := 0;\n while N > 0 do\n begin\n if N > 1 then\n begin\n if N div 2 = N / 2 then\n begin\n Inc(C, N div 2);\n N := 0;\n end\n else\n begin\n M := Trunc(Sqrt(N));\n I := 2;\n while (N mod I <> 0) and (I < M) do \n Inc(I);\n if N mod I <> 0 then\n I := N;\n Inc(C);\n N := N - I;\n end;\n end\n else\n begin\n Inc(C);\n N := 0;\n end;\n end;\n Writeln(C);\nend."}, {"source_code": "var d,n:int64;\n i:longint;\nbegin\n read(n);\n if (n=2)or(n=3)then d:=n\n else\n begin\n d:=0;\n for i:=2 to round(sqrt(n))+1 do\n if n mod i = 0 then\n begin\n d:=i;\n break;\n end;\n if d = 0 then d:=n;\n end;\n if d = 0 then d:=n;\n if d=2 then writeln(round(n/2))\n else writeln(1+round((n-d)/2));\nend."}, {"source_code": "program b1076;\nvar n,d,i,s,j:int64;\nbegin\nread(n);\nwhile n<>0 do begin\nj:=2;\nwhile((n mod j)<>0) do if j<=(trunc(sqrt(n))) then inc(j) else j:=n;;\nn:=n-j;\ninc(s);\n break;\n end;\n s:=s+n div 2;\n write(s);\nend. "}], "negative_code": [{"source_code": "\nvar n,d,i,s,j:int64;\nbegin\nread(n);\nwhile n<>0 do begin\nj:=2;\nwhile((n mod j)<>0) do if j<=(trunc(sqrt(n))) then inc(j) else j:=n;;\nn:=n-j;\ninc(s);\nexit;\nend;\ns:=s+n div 2;\nwrite(s);\nend. "}, {"source_code": "var n,d,i,s,j:int64;\n\nbegin\nread(n);\nwhile n<>0 do begin\n j:=2;\n while((n mod j)<>0) do if j<=(trunc(sqrt(j))) then inc(j) else j:=n;;\n n:=n-j;\n inc(s);\n break;\n end;\n s:=s+n div 2;\n write(s);\nend. \n"}, {"source_code": "var n,d,i,s,j:int64;\n\nbegin\nread(n);\nwhile n<>0 do begin\n j:=2;\n while((n mod j)<>0) do if j0 do begin\n j:=2;\n while((n mod j)>0)and(j<=n)do inc(j);\n break;\n end;\n write(n div j);\nend."}, {"source_code": "program xxx;\nvar n:int64;\nd,c:int64;\nbegin\nread(n);\n\nd:=2;\n\nif n>0 then \n\n\n while n>1 do\n begin\n \n while n mod d <> 0 do\n inc(d);\n \n c:=c+n div d;\n n:=n-((n div d) * d);\n \n end;\n \nwriteln(c);\n \nend."}, {"source_code": "program xxx;\nvar n:int64;\nd,c:int64;\nbegin\nread(n);\n\nif n>0 then \n\n\n while n>1 do\n begin\n d:=2;\n \n while (n mod d <> 0)and(d 0) do\nBegin\ni:=i + 1;\nend;\n\nWriteln(n div i);\n\nend;\n\nReadln;\nEND."}, {"source_code": "Program p;\nvar n, i: int64;\n\nbegin\nread(n);\nif n mod 2 =0 then writeln(n div 2)\n else \n begin\n for var g:=3 to 10000 do\n if n mod g =0 then\n begin\n i:=g;\n break\n end;\n if i=0 then i:=n;\n writeln((n-i) div 2+1)\n end\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]1 then\n begin\n for i := 1 to res do\n if n mod prime[i] = 0 then\n begin\n kq := n div prime[i];\n break;\n end;\n if kq=0 then kq := 1; {}\n end;\n writeln(kq);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar f : text;\ni,dem,res,j : longint;\nprime : array[1..1000000] of longint;\nkt : array[1..1000000] of boolean;\nn : int64;\nkq : qword;\nprocedure sang(X : longint);\nbegin\n i := 1;\n fillchar(kt,sizeof(kt),true);\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(res);\n prime[res] := i;\n for j := 1 to x div i do kt[j*i] := false;\n end;\n until i = x;\nend;\nbegin\n // assigN(f,'SANG.INP');\n // reset(f);\n readln(n);\n sang(min(1000000,n));\n dem := 1;\n repeat\n if n mod prime[dem] = 0 then\n begin\n kq := (n div prime[dem]-1)*prime[dem]+kq;\n if n = prime[dem] then inc(kq);\n n := (n div prime[dem]-1);\n dem := 1 ;\n end else inc(dem);\n if dem > res + 1 then\n begin\n inc(kq);\n break;\n end;\n until n <= 1;\n // assigN(f,'SANG.OUT');\n // rewrite(f);\n writeln(kq);\n // close(f);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar f : text;\ni,dem,res,j : longint;\nprime : array[1..1000000] of longint;\nkt : array[1..1000000] of boolean;\nn : int64;\nkq : qword;\nprocedure sang(X : longint);\nbegin\n i := 1;\n fillchar(kt,sizeof(kt),true);\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(res);\n prime[res] := i;\n for j := 1 to x div i do kt[j*i] := false;\n end;\n until i = x;\nend;\nbegin\n // assigN(f,'SANG.INP');\n // reset(f);\n readln(n);\n sang(min(1000000,n));\n dem := 1;\n repeat\n if n mod prime[dem] = 0 then\n begin\n kq := (n div prime[dem]-1)*prime[dem]+kq;\n n := (n div prime[dem]-1);\n if n = prime[dem] then inc(kq);\n dem := 1 ;\n end else inc(dem);\n if dem > res + 1 then\n begin\n inc(kq);\n break;\n end;\n until n <= 1;\n // assigN(f,'SANG.OUT');\n // rewrite(f);\n writeln(kq);\n // close(f);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar f : text;\ni,dem,res,j : longint;\nprime : array[1..1000000] of longint;\nkt : array[1..1000000] of boolean;\nn : int64;\nkq : qword;\nprocedure sang(X : longint);\nbegin\n i := 1;\n fillchar(kt,sizeof(kt),true);\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(res);\n prime[res] := i;\n for j := 1 to x div i do kt[j*i] := false;\n end;\n until i = x;\nend;\nbegin\n readln(n);\n if n>=2 then\n sang(min(1000000,n));\n dem := 1;\n kq := 0;\n if n>1 then\n begin\n for i := 1 to res do\n if n mod prime[i] = 0 then\n begin\n kq := n div prime[i];\n break;\n end;\n if kq=0 then kq := 1; {}\n end;\n writeln(kq);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar f : text;\ni,dem,res,j : longint;\nprime : array[1..1000000] of longint;\nkt : array[1..1000000] of boolean;\nn : int64;\nkq : qword;\nprocedure sang(X : longint);\nbegin\n i := 1;\n fillchar(kt,sizeof(kt),true);\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(res);\n prime[res] := i;\n for j := 1 to x div i do kt[j*i] := false;\n end;\n until i = x;\nend;\nbegin\n readln(n);\n sang(min(1000000,n));\n dem := 1;\n for i := 1 to res do\n if n mod prime[i] = 0 then\n begin\n kq := n div prime[i];\n break;\n end;\n if kq=0 then kq := 1; {}\n writeln(kq);\nend.\n\n\n\n"}, {"source_code": "var n,x,s,z:int64;\ni:longint;\nbegin\n//assign(input,'csjf.in');reset(input);\n//assign(output,'csjf.out');rewrite(output);\nreadln(n);\nwhile n mod 2<>0 do\n begin\n x:=n;z:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n z:=i;break;\n end;\n if z<>0 then n:=n div z\n else n:=0;\n s:=s+1;\n end;\ns:=s+n div 2;\nwriteln(s);\nclose(input);close(output);\nend."}, {"source_code": "var\nbol:boolean;\nn,ind:int64;\ni,j:longint;\nbegin\nreadln(N);\nfor i:=2 to trunc(sqrt(n)) do begin\n if n mod i =0 then begin\n bol:=false;\n for j:=2 to trunc(sqrt(i)) do if i mod j= 0 then bol:=true;\n if bol=false then begin\n ind:=i;\n break;\n end;\n end;\n if ind<>0 then break;\nend;\n\nif ind=0 then writeln(1)\nelse\nwriteln(n div ind);\nend."}, {"source_code": "var\nbol:boolean;\nn,ind:int64;\ni,j:longint;\nbegin\nreadln(N);\nfor i:=2 to round(sqrt(n)) do begin\n if n mod i =0 then begin\n bol:=false;\n\n if bol=false then begin\n ind:=i;\n break;\n end;\n end;\n // if ind<>0 then break;\nend;\n\nif ind=0 then writeln(1)\nelse\nwriteln(n div ind);\nend."}, {"source_code": "var n,count:int64;\n i:longint;\nfunction check(n:int64):boolean;\nvar i:longint;\nbegin\n if (n=2) then exit(true);\n if (n mod 2=0) then exit(false);\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i)=0 then exit(false)\n else i:=i+2;\n exit(true);\nend;\nbegin\n read(n);\n count:=0;\n if (n mod 2=0) then count:=n shr 1\n else if check(n) then count:=1\n else\n begin\n i:=3;\n while i<=trunc(sqrt(n)) do\n if ((n mod i)=0)and(check(i)) then\n begin\n count:=n div i;\n break;\n end\n else i:=i+2;\n end;\n write(count);\nend."}, {"source_code": "var n,count:int64;\n i:longint;\nfunction check(n:int64):boolean;\nvar i:longint;\nbegin\n if (n=3)or(n=5) then exit(True);\n if (n mod 3=0)or(n mod 5=0) then exit(false);\n i:=1;\n while i<=(trunc(sqrt(n))div 6) do\n if ((n mod 6*i-1)=0)or ((n mod 6*i+1)=0)then exit(false)\n else i:=i+2;\n exit(true);\nend;\nbegin\n read(n);\n count:=0;\n while n<>0 do\n begin\n if (n mod 2)=0 then\n begin count:=count + n div 2; n:=0; end\n else\n if check(n) then begin inc(count); n:=0; end\n else\n begin\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i=0)and(check(i)) then\n begin\n inc(count);\n n:=n-i;\n break;\n end\n else i:=i+2;\n end;\n end;\n write(count);\nend.\n"}, {"source_code": "var n,count:int64;\n i:longint;\nfunction check(n:int64):boolean;\nvar i:longint;\nbegin\n if (n=2) then exit(true);\n if (n mod 2=0) then exit(false);\n i:=3;\n while i<=trunc(sqrt(n)) do\n if (n mod i)=0 then exit(false)\n else i:=i+2;\n exit(true);\nend;\nbegin\n read(n);\n count:=0;\n if (n mod 2=0) then count:=count shr 1\n else if check(n) then count:=1\n else\n begin\n i:=3;\n while i<=trunc(sqrt(n)) do\n if ((n mod i)=0)and(check(i)) then\n begin\n count:=n div i;\n break;\n end\n else i:=i+2;\n end;\n write(count);\nend."}, {"source_code": "var d,n:int64;\n i:longint;\nbegin\n read(n);\n if (n=2)or(n=3)then d:=n\n else\n begin\n d:=0;\n for i:=2 to round(sqrt(n))+1 do\n if n mod i = 0 then\n begin\n d:=i;\n break;\n end;\n if d = 0 then d:=n;\n end;\n if d = 0 then d:=n;\n if d=2 then writeln(round(n/2))\n else writeln(round(n/d)+round((n/d)/2));\nend."}, {"source_code": "var d,n:int64;\n i:longint;\nbegin\n read(n);\n if (n=2)or(n=3)then d:=n\n else\n begin\n d:=0;\n for i:=2 to round(sqrt(n))+1 do\n if n mod i = 0 then\n begin\n d:=i;\n break;\n end;\n if d = 0 then d:=n;\n end;\n if d = 0 then d:=n;\n if d=2 then writeln(round(n/2))\n else writeln(round(n/d)+round(((n-d)/d)/2));\nend."}], "src_uid": "a1e80ddd97026835a84f91bac8eb21e6"} {"source_code": " var i,j,n,p:longint;\n s:string;\n f:boolean;\n begin\n readln (s);\n\n if length(s) mod 2 = 0 then p:=length(s) div 2\n else p:=length(s) div 2 + 1;\n\n\n f:=true;\n\n\n for i:=1 to length(s) do\n begin\n write (s[p]);\n if f then\n begin\n f:=false;\n p:=p+i;\n end\n else\n begin\n f:=true;\n p:=p-i;\n end;\n\n end;\n\n\n\n\n\n\n end.", "positive_code": [{"source_code": "var s, n, c: string;\nbegin\n read(s);\n if length(s) mod 2 = 0 then\n begin\n while length(s)<> 0 do\n begin\n c:=copy(s,length(s),1);\n delete(s,length(s),1);\n n:=n+c;\n if length(s)<>0 then\n begin\n c:=copy(s,1,1);\n delete(s,1,1);\n n:=n+c;\n end;\n end;\n end\n else\n begin\n while length(s)<> 0 do\n begin\n c:=copy(s,1,1);\n delete(s,1,1);\n n:=n+c;\n if length(s)<>0 then\n begin\n c:=copy(s,length(s),1);\n delete(s,length(s),1);\n n:=n+c;\n end;\n end;\n end;\n while length(n) <> 0 do\n begin\n c:=copy(n,length(n),1);\n delete(n,length(n),1);\n s:=s+c;\n end;\n write(s);\nend."}, {"source_code": "{$Coperators ON}\n{$mode objfpc}\nuses math;\nvar s,kq:String;\nprocedure init;\nvar i,j:Longint;\nbegin\n\treadln(s);\n\ti:=1;\n\tkq:='';\n\tj:=Length(s);\n\tif j mod 2=0 then\n\t\tbegin\n\t\t\trepeat\n\t\t\t\tkq:=s[i]+s[j]+kq;\n\t\t\t\tinc(i);\n\t\t\t\tdec(j);\n\t\t\tuntil i>=j;\n\t\tend\n\telse\n\t\tbegin\n\t\t\trepeat\n\t\t\t\tif i=j then kq:=s[i]+kq else\n\t\t\t\tkq:=s[j]+s[i]+kq;\n\t\t\t\tinc(i);\n\t\t\t\tdec(j);\n\t\t\tuntil i>j;\n\t\tend;\n\twriteln(kq);\nend;\nbegin\n\n\tinit;\n\nend."}, {"source_code": "var \ntyasdgu, res: string; \n\nfunction brbl(): char; \nbegin \nif tyasdgu.Length mod 2 = 0 then \nbegin \nResult := tyasdgu[tyasdgu.Length]; \nvar tyasdgu1 := ''; \nfor var i := 1 to tyasdgu.Length - 1 do \ntyasdgu1 += tyasdgu[i]; \ntyasdgu := tyasdgu1; \nend \nelse begin \nResult := tyasdgu[1]; \nif tyasdgu.Length > 1 then begin \nvar tyasdgu1 := ''; \nfor var i := 2 to tyasdgu.Length do \ntyasdgu1 += tyasdgu[i]; \ntyasdgu := tyasdgu1 \nend \nelse tyasdgu := ''; \nend; \nend; \n\nbegin \ntyasdgu := ReadlnString; \n\nwhile tyasdgu.Length > 0 do \nbegin \nres += brbl(); \nend; \n\nvar res1 := ''; \nfor var i := res.Length downto 1 do \nres1 += res[i]; \n\nWrite(res1); \nend."}, {"source_code": "{const fi='DL.INP';\n fo='DL.OUT';}\nvar s,s1: string;\n vt,i: byte;\n\nbegin\n {assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);}\n read(s);\n if (length(s)=1) then begin\n write(s);\n halt;\n end;\n vt:= (length(s) div 2);\n if (length(s) mod 2=0) then dec(vt);\n s1:= copy(s,1,vt);\n delete(s,1,vt);\n i:= 3;\n for vt:= vt downto 1 do begin\n insert(s1[vt],s,i);\n inc(i,2);\n end;\n write(s);\n //close(input); close(output);\nend.\n"}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2+i];//+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2+i+1];\n\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2-i+1];\n//writeln(i); 7\nend;\nif length(a)mod 2=0 then write(a[length(a) div 2]);\nif length(a)mod 2=1 then write(a[length(a) div 2+1]);\n//write(s[1])\n\nif length(a)mod 2 = 0 then begin\nfor i:=1 to length(s)-1 do\nwrite(s[i]);\nhalt;\nend;\n//for i:=1 to length(s) do\nwrite(s);\nend.\n"}, {"source_code": "program Project1;\nvar\nnew: array [1..100] of char;\narr:array [1..100] of char;\nstr:string;\ni,n,h,x: integer;\nbegin\nreadln(str);\nn:=length(str);\nfor i:=1 to n do\nbegin\narr[i]:=str[i];\nend;\nx:=n div 2;\nh:=x+1;\ni:=1;\n\nif n mod 2=0 then\nbegin\n repeat\n if i mod 2=1 then\n begin\n new[i]:=arr[x];\n x:=x-1;\n end else\n begin\n new[i]:=arr[h];\n h:=h+1;\n end;\n i:=i+1;\n until 0 > x;\nend;\n//x=2\n//h=3\nh:=n div 2 +1;\nx:=h+1;\n\nif n mod 2=1 then\nbegin\nrepeat\n if i mod 2=1 then\n begin\n new[i]:=arr[h];\n h:=h-1;\n end else\n begin\n new[i]:=arr[x];\n x:=x+1;\n end;\n i:=i+1;\n until 0 > h;\n end;\n\n\nfor i:=1 to n do\nbegin\nwrite(new[i]);\nend;\nreadln();\nend.\n"}, {"source_code": "var s: string;\n a,b: array [1..50] of char;\n i, t, j, z: integer;\nbegin\n read (s);\n t:=1;\n while (s[t] <> #0) do\n begin\n a[t]:=s[t];\n inc (t);\n end;\n if t <= 2 then\n begin\n writeln (s);\n halt;\n end;\n dec(t);\n j:=t; z:=2;\n t:= t div 2;\n if j mod 2 <> 0 then inc (t);\n b[1]:= a[t];\n for i:=t+1 to j do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n z:=3;\n for i:=t-1 downto 1 do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n for i:= 1 to j do write (b[i]);\n writeln;\nend.\n"}, {"source_code": "Program ABC;\nvar\na,x:integer;\ns,uncoded:string[51];\nbegin\nread(s);\na:=length(s);\nif a mod 2 = 0 then begin\nuncoded:=copy(s,(a div 2),1);\nfor x:=1 to ((a div 2)-1) do begin\nuncoded:=uncoded+copy(s,((a div 2)+x),1);\nuncoded:=uncoded+copy(s,((a div 2)-x),1);\nend;\nuncoded:=uncoded+copy(s,a,1);\nend\nelse begin\nuncoded:=copy(s,((a div 2)+1),1);\nfor x:=1 to (a div 2) do begin\nuncoded:=uncoded+copy(s,(((a div 2)+1)+x),1);\nuncoded:=uncoded+copy(s,(((a div 2)+1)-x),1);\nend;\nend;\nwrite(uncoded);\nend."}, {"source_code": "var s,s1:string;\n a:array[1..50] of char;\n i,j,k:integer;\n begin\n readln(s);\n if length(s) mod 2=1 then k:=(length(s) div 2)+1 else k:=length(s) div 2;\n a[1]:=s[k];\n j:=k+1;\n i:=2;\n while j<=length(s) do begin\n a[i]:=s[j];\n j:=j+1;\n i:=i+2;\n end;\n i:=3;\n j:=k-1;\n while j>=1 do begin\n a[i]:=s[j];\n j:=j-1;\n i:=i+2;\n end;\n for I:=1 to length(s) do \n s1:=s1+a[i];\n write(s1);\n end."}, {"source_code": "var\n n, k, i, t: int64;\n s, rez: string;\n\nbegin\n readln(s);\n if length(s) mod 2 = 0 then rez := ''\n else\n begin\n rez := s[1];\n delete(s, 1, 1);\n end;\n //writeln(s);\n for i := 1 to length(s) div 2 do\n begin\n rez := s[i] + s[length(s) + 1 - i] + rez;\n end;\n write(rez);\nend."}, {"source_code": "program one;\nvar\nfin,str:string;\nx,g,u,ind:integer;\nbegin\nread(str);\nsetlength(fin,length(str));\nu:=1;\ng:=1;\nif (length(str) mod 2 = 1) and (length(str)<>1) then \n begin\n ind:=(length(str) div 2) + 1;\n while x<=length(str)-1 do\n begin\n fin[u]:=str[ind];\n u:=u+1;\n if u mod 2 = 0 then ind:=ind+g else ind:=ind-g;\n g:=g+1;\n x:=x+1;\n end;\n end;\nif (length(str) mod 2 = 0) and (length(str)<>1) then \n begin\n ind:=length(str) div 2;\n while x<=length(str)-1 do\n begin\n fin[u]:=str[ind];\n u:=u+1;\n if u mod 2 = 0 then ind:=ind+g else ind:=ind-g;\n g:=g+1;\n x:=x+1; \n end;\n end;\nif length(str) = 1 then fin:=str;\nwriteln(fin);\nend.\n"}, {"source_code": "var \ns,s1:string;\ni,j,n:integer;\nbegin\nread(s);\n\nif length(s)mod 2=0 then\nj:=length(s)div 2\nelse\nj:=length(s)div 2+1;\n\nn:=length(s);\ns1:=s[j];\nfor i:=1 to n-1 do\nbegin\nif i mod 2= 1 then\nj:=j+i\n else\nj:=j-i;\ns1:=s1+s[j];\nend;\n\nwrite(s1);\n\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul=1000000007{998244353} ;\n besk=4000000000000000000;\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var rr,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zz,numx,numy,xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..535002] of extended;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n newstr,str,sss:array[-1000..20000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4400,-1..4200] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n beta,mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\n{function zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n}\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]'' do\n begin\n s1:=s[1]+s[length(s)]+s1;\n delete(s,length(s),1);\n delete(s,1,1);\n end;\nwriteln(s1);\nend;\n\nend."}, {"source_code": "var i,t:1..50;s,h:string;\nbegin\nread(s);t:=length(s);\nfor i:=1 to t div 2 do \nif t mod 2=0 then begin h:=s[t-i+1]+h;h:=s[i]+h;end else begin h:=s[i]+h;h:=s[t-i+1]+h;end;\nif t mod 2=1 then h:=s[t div 2+1]+h;\nprint(h);\nend."}, {"source_code": "Program n;\nvar s,t:String;\nfunction pl(s:string):string;\nvar nac, con:Integer; pr,lt,res:string;\nBegin\nnac:=0;\ncon:=0;\nres:='';\n\nIf (length(s) mod 2 <> 0)\n then\n //Сторка нечетная\n While ((nac+con) 0 do\n begin\n s1:=s[length(s)]+s1;\n s1:=s[1] + s1;\n s:=copy(s,2,length(s)-2);\n end;\n writeln(s1); \nend else\n begin \n s1:=s[1]+s1;\n s:=copy(s,2,length(s)-1);\n while length(s) <> 0 do\n begin\n s1:=s[length(s)] + s1;\n s1:=s[1] + s1;\n s:=copy(s,2,length(s)-2);\n end;\n writeln(s1);\nend; \nend."}, {"source_code": "Var S,decipher:String;\n a:Longint;\nBegin\n Readln(S); decipher:='';\n If length(S) mod 2 = 0 then a:=0\n Else a:=1;\n While length(S)>0 do\n Begin\n If a mod 2 = 0 then begin\n decipher:=S[length(S)]+decipher;\n Delete(S,length(S),1);\n End\n Else begin\n decipher:=S[1]+decipher;\n Delete(S,1,1);\n End;\n Inc(a);\n End;\n Writeln(decipher);\nEnd."}, {"source_code": "var\n s, t: string;\n i, k, long, mid: integer;\n\nbegin\n readln(t);\n long := length(t);\n if long mod 2 = 0 then\n begin\n mid := length(t) div 2;\n s := s + t[mid];\n for i := 1 to long div 2 - 1 do\n begin\n s := s + t[mid + i];\n s := s + t[mid - i];\n end;\n if long <> 2 then\n s := s + t[mid + i + 1]\n else\n s := s + t[mid + i];\n end\n else\n begin\n mid := length(t) div 2 + 1;\n s := s + t[mid];\n for i := 1 to long div 2 do\n begin\n s := s + t[mid + i];\n s := s + t[mid - i];\n end;\n end;\n write(s);\nend."}, {"source_code": "var s,s1: string; i: integer;\nbegin\n readln(s);\n s1:='';\n if(s.Length mod 2 =0) then\n i:=s.Length\n else\n i:=1;\n while s.Length>0 do begin\n s1:=s[i]+s1;\n delete(s,i,1);\n if (i=1)then i:=s.Length\n else i:=1\n end;\n writeln(s1)\nend.\n "}, {"source_code": "Var\n S: String;\n t: Int64;\n k: Boolean;\n \nBegin\n Readln(S);\n If Length(S) = 1 then\n Write(S)\n Else If Length(S) mod 2 = 0 then\n For Var i := 1 to Length(S) div 2 do\n Write(S[Length(S) div 2 - i + 1],S[Length(S) div 2 + i])\n Else Begin\n Write(S[Length(S) div 2 + 1]);\n For Var i := 1 to Length(S) div 2 do\n Write(S[Length(S) div 2 + 1 + i],S[Length(S) div 2 + 1 - i])\n End\nEnd."}, {"source_code": "program GG1;\nvar\ns,sp:string;\ni,k:longint;\nbegin\nreadln(s);\ni:=1;//нужно чтобы он два раза прошёл\nk:=length(s)-length(s)div 2;//3\nsp:=s[k];\nif ((k mod 2<>0)and(length(s) mod 4<>1))or(length(s) mod 4=0) then\nbegin\nfor i:=1 to length(s) div 2 -1 do\nsp:=sp+s[k+i]+s[k-i];\nsp:=sp+s[length(s)];\nend\nelse\nfor i:=1 to length(s) div 2 do//при \nsp:=sp+s[k+i]+s[k-i];\nif k=1 then \nsp:=s;\nwriteln(sp);\nend."}, {"source_code": "var\ns1,s2:string;\nn,i,j:integer;\na:array[1..50] of integer;\n\nbegin\n readln(s1);\n n:=length(s1);\n s2:=n*'0';\n j:=((n-1) div 2) *2 +1;\n for i:=1 to (n+1) div 2 do begin\n a[i]:=j;\n dec(j,2);\n end;\n j:=2;\n for i:=(n+3) div 2 to n do begin\n a[i]:=j;\n inc(j,2);\n end;\n for i:=1 to n do s2[a[i]]:=s1[i];\n writeln(s2);\n \nend.\n"}, {"source_code": "var\n S, S1: string;\n i, d, p, l: integer;\n d1: integer;\n\nbegin\n read(s);\n L := 1;\n p := 1;\n d := length(S);\n {for i := 1 to d do mas[i] := S[i];\n S := S + mas[i];}\n if (d mod 2) = 0 then d1 := Trunc(d / 2)\n else d1 := Trunc(d / 2) + 1; \n s1 := s[d1];\n for i := 1 to d-1 do\n begin\n if (i mod 2) = 1 then\n begin\n S1 := S1 + S[d1 + p];\n p := p + 1\n end\n else \n begin\n S1 := S1 + S[d1 - l];\n l := l + 1\n end;\n end;\n writeLn(S1)\nend."}, {"source_code": "program p1;\n\nvar i, k, c, m:integer;\n s, t:string;\n \nbegin\n readln(t);\n if length(t) mod 2 = 0 then \n m := length(t) div 2\n else m := length(t) div 2 + 1;\n \n s := t[m];\n \n k:=1;\n i:=1;\n c:=1;\n while k l do\n begin\n if(l - f) mod 2 <> 0 then\n begin\n out := s[l] + out;\n l -= 1;\n end else begin\n out := s[f] + out;\n f += 1;\n end\n end;\n write(s[l] + out)\nend."}, {"source_code": "var\n\tn, i, j: int64;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tj := s.length;\n\ti := 1;\n\t\n\tif (s.length = 1) then\n\t\twriteln(s)\n\telse begin\n\t\tif (s.length mod 2 = 0) then\n\t\tbegin\n\t\t\twhile (i <= s.length div 2) and (j > s.length div 2) do\n\t\t\tbegin\n\t\t\t\ts1 += s[j] + s[i];\n\t\t\t\ti += 1;\n\t\t\t\tj -= 1;\n\t\t\tend;\n\t\tend\n\t\telse begin\n\t\t\twhile (i <= s.length div 2+1) and (j > s.length div 2) do\n\t\t\tbegin\n\t\t\t\ts1 += s[i] + s[j];\n\t\t\t\ti += 1;\n\t\t\t\tj -= 1;\n\t\t\tend;\n\t\t\tdelete(s1, s.length, 1);\n\t\tend;\n\t\twriteln(reverseString(s1));\n\tend;\n\t\nend.\n"}, {"source_code": "program vvv;\nvar s,s2:string; b,i:integer;\nbegin\nreadln(s);\nif length(s) mod 2 = 0 then b:=1;\nfor i:=1 to length(s) do begin\n if b mod 2 <> 0 then begin\n s2:=s2+copy(s, length(s), 1); delete(s, length(s), 1); end\nelse begin\ns2:=s2+copy(s, 1, 1); delete(s, 1, 1); end;\ninc(b);\nend;\n\n\nfor i:=length(s2) downto 1 do\ns:=s+s2[i];\nwriteln(s);\nend.\n"}, {"source_code": "label metka,kk;\nvar a,k:string;\nb,c,i,t,p:longint;\nbegin\nread(a);\nk:=a;\nb:=length(a);\n\n\nif b mod 2=0 then begin\np:=b div 2;\ngoto kk;\nend;\n\nif b mod 2=1 then begin\np:=(b div 2)+1;\nend;\nkk:\n\nif p=0 then begin\ngoto metka;\nend;\n\nfor i:=1 to b do begin\n\nif i mod 2=0 then begin\np:=p +(i-1);\nk[i]:=a[p];\nend;\nif i mod 2=1 then begin\np:=p -(i-1);\nk[i]:=a[p];\nend;\n\n\nend;\nmetka:\nprintln(k);\n\n\nend."}, {"source_code": "var\n t, s: string;\n i, n: integer;\n\nbegin\n readln(t);\n n := length(t);\n for i := 1 to n do\n if length(t) mod 2 = 0 then\n begin\n s := t[length(t)] + s;\n delete(t, length(t), 1);\n end\n else\n begin\n s := t[1] + s;\n delete(t, 1, 1);\n end;\n write(s);\nend."}, {"source_code": "LABEL f;\nvar str, ans:string;\n l, i, g, q:integer;\n ch:array[1..52] of char;\nbegin\nreadln(str);\nl:=length(str);\ng:=l;\ni:=1;\nif l>3 then begin\n if l mod 2 = 0 then begin\n while g>i do begin\n ch[l]:=str[g];\n ch[l-1]:=str[i];\n l:=l-2;\n i:=i+1;\n g:=g-1;\n end;\n end\n else begin\n g:=l div 2 + 1;\n i:=1;\n q:=2;\n ch[1]:=str[g];\n while i<=(l div 2) do begin\n ch[q]:=str[g+i];\n ch[q+1]:=str[g-i];\n q:=q+2;\n i:=i+1;\n end;\n end;\nend\nelse if l=3 then begin\n ch[1]:=str[2];\n ch[2]:=str[3];\n ch[3]:=str[1];\n end\n else begin \n ans:=str;\n goto f;\n end;\ni:=1;\nwhile i<=length(str) do begin\nans:=concat(ans, ch[i]);\ni:=i+1;\nend;\nf:\nwriteln(ans);\nend."}, {"source_code": "var s:string;\n l,k,i:longint;\nbegin\n readln(s);\n l:=length(s);\n k:=l div 2;\n if l mod 2<>0\n then k:=k+1;\n write(s[k]);\n i:=0;\n while i<>k do\n begin\n i:=i+1;\n if k+i<=l\n then write(s[k+i]);\n if k-i>0\n then write(s[k-i]);\n end;\nend."}, {"source_code": "var s:string;i,i0:integer;\nbegin\nreadln(s);\ni0:=length(s) mod 2+length(s) div 2;\nfor i:=0 to i0 do begin\nif (i<>0) and (i+i0<=length(s)) then write(s[i0+i]);\nif i0-i>=1 then write(s[i0-i]);\nend\nend.\n"}, {"source_code": "program a;\n\nvar\n t, t1, o: string;\n o2, i, k, ch: integer;\n\nbegin// techno - ncteho\n read(t);\n k := 1;\n ch := Length(t);\n if Length(t) = 1 then writeln(t) else begin\n if Length(t) mod 2 <> 0 then repeat o2 := Length(t);o := copy(t, o2, 1) + copy(t, 1, 1);delete(t, o2, 1);delete(t, 1, 1);t1 := o + t1; until Length(t) = 1 else\n repeat\n o2 := Length(t);o := copy(t, 1, 1) + copy(t, o2, 1);delete(t, o2, 1);delete(t, 1, 1);t1 := o + t1;\n until Length(t) < 1;\n if ch mod 2 =0 then write(t1) else write(t+t1);\n end;\nend."}, {"source_code": "var\n s1, s2: STRING;\n i, n: integer;\n\nbegin\n readln(s1);\n s2:=s1;\n i := 1;\n n:=length(s1) div 2 + length(s1) mod 2;\n s2[1]:=s1[n];\n while abs(i) '' do \n begin\n f[length(s)]:=s[i];\n delete(s,i,1);\n if i = 1 then i:=length(s)\n else i:=1;\n end;\n \n writeln(f);\n end."}, {"source_code": "program tehnocup;\n\nvar txt,st:string;\n s: array[1..1000] of char;\n\ti:integer;\n\nbegin\n\tReadln(txt);\n\tif length(txt) mod 2 = 0 then\n\tbegin\n s[1]:=txt[length(txt) div 2];\n for i:=1 to length(txt) do\n\t begin\n\t if i < length(txt) div 2 then\n\t begin\n\t s[length(txt)-1-2*(i-1)]:=txt[i];\n\t end;\n\t if i > length(txt) div 2 then\n\t begin\n\t s[(i-length(txt) div 2)*2]:=txt[i];\n\t end;\n\t \n\t end;\n\tend\n\telse begin\n\t s[1]:=txt[length(txt) div 2+1];\n\t for i:=1 to length(txt) do\n\t begin\n\t if i < length(txt) div 2+1 then\n\t begin\n\t s[length(txt)-2*(i-1)]:=txt[i];\n\t end;\n\t if i > length(txt) div 2+1 then\n\t begin\n\t s[2*(i-(length(txt) div 2+1))]:=txt[i];\n\t end;\n\t end;\n\tend;\n\tfor i:=1 to length(txt) do st:=st+s[i];\n\tWriteln(st);\nend."}, {"source_code": "Var s0,S:String;\n len,c,i:LongInt;\n\nBegin\n Read(s0);\n len:=Length(s0);\n SetLength(S,len);\n c:=(len + 1) div 2;\n \n S[1]:=s0[c];\n For i:=1 to ((len-1) div 2) do begin\n S[i*2]:=s0[c+i];\n S[i*2+1]:=s0[c-i];\n end;\n If (len mod 2 = 0) then S[len]:=s0[len];\n \n writeLn(S);\nEnd."}, {"source_code": "var sqwer,answww :string;\ni,leng:integer;\nbegin\nreadln(sqwer);\nleng:= length(sqwer);\nanswww:= sqwer[leng div 2 + leng mod 2];\nfor i:=1 to leng div 2 do\nbegin\n answww:= answww + sqwer[leng div 2 + leng mod 2 +i];\n if leng div 2 + leng mod 2 -i >0 then answww:= answww + sqwer[leng div 2 + leng mod 2 -i];\nend;\nfor i:=1 to leng div 2 do\nbegin\nend;\nwriteln(answww);\nend.\n"}, {"source_code": "program A1085;\nvar t, s: string;\ni,c,n:integer;\nbegin\nreadln(t);\ns:=t;\nc:=2;\nn:=3;\n\nif length(t) mod 2 = 0 then begin\n s[1]:=t[length(t) div 2];\n for i:=length(t) div 2 -1 downto 1 do begin\n s[n]:=t[i];\n n:=n+2;\n end;\n for i:= length(t) div 2 +1 to length(t) do begin\n s[c]:=t[i];\n c:=c+2;\n end;\n end\n\nelse begin\n s[1]:=t[length(t) div 2 +1];\n for i:=length(t) div 2 downto 1 do begin\n s[n]:=t[i];\n n:=n+2;\n end;\n for i:= length(t) div 2 +2 to length(t) do begin\n s[c]:=t[i];\n c:=c+2;\n end;\n end;\nwriteln(s);\nend."}, {"source_code": "var s, temp:string;\n res:array[1..10000000] of string;\n len, i, j:longint;\n flag:boolean;\n\nbegin\n flag:= False;\n j:= 0;\n readln(s);\n \n len:= length(s);\n \n if (len = 1) then\n begin\n writeln(s);\n exit;\n end;\n \n if (len mod 2 > 0) then\n begin\n temp:=s[1];\n Delete(s, 1, 1);\n flag:=True;\n len:= len - 1;\n end;\n \n for i:= len downto len div 2 do\n begin\n j:=j + 2;\n res[j - 1]:= s[i];\n res[j]:= s[len - i + 1];\n end;\n \n for i:= len downto 1 do\n write(res[i]);\n \n if (flag= True) then\n write(temp);\nend."}, {"source_code": "var s,s1:string;\nbegin\nreadln(s);\nwhile length(s)>0 do\nif length(s) mod 2 =1 then\nbegin\ns1:=s[1]+s1;\ns:=copy(s,2,length(s)-1);\nend\nelse\nbegin\ns1:=s[length(s)]+s1;\ns:=copy(s,1,length(s)-1);\nend;\nwriteln(s1);\nend."}, {"source_code": "begin\n var s: string;\n Read(s);\n var s1: string;\n SetLength(s1, s.Length);\n s1[1] := s[(s.Length - 1) div 2 + 1];\n var c := 1;\n for var i := 1 to s.Length - ((s.Length - 1) div 2 + 1) do\n begin\n s1[1 + c] := s[((s.Length - 1) div 2 + 1) + i];\n c += 2;\n if c + 1 > s.Length then\n break;\n end;\n c := 3;\n for var i := 0 to (s.Length - 1) div 2 do\n begin\n if c > s.Length then\n break;\n s1[c] := s[((s.Length - 1) div 2) - i];\n c += 2;\n if c > s.Length then\n break;\n end;\n writeln(s1);\nend."}, {"source_code": "var s,o:string;\ni,n,t:longint;\nbegin\nreadln(s);\nn:=length(s);\nif n mod 2=0 then t:=n div 2 else t:=n div 2+1;\nfor i:=1 to n do \n if i mod 2=0 then o:=o+s[t+i div 2] else o:=o+s[t-i div 2];\nwriteln(o);\nend."}, {"source_code": "var a,b,c,d,cop1,cop2,cop3:string;\nz,x,y,q,w,u,k:int64;\nbegin\nk:=1;\nread (a);\nz:=length(a);\nw:=z mod 2;\nif w<>0 then x:=(z div 2)+1 else x:=(z div 2);\ncop1:=copy(a,x,1);\nb:=concat(b+cop1);\nwhile y 1 then\n if a.Length mod 2 = 0 then\n for i:=k downto 1 do\n begin\n s:=s+a[i]+a[2*k-i+1];\n end\n else\n begin\n s:=a[a.Length div 2+1];\n for i:=k downto 1 do\n begin\n s:=s+a[(2*(k+1)-i)]+a[i];\n end;\n end\nelse\nwriteln(a); \nwriteln(s);\nend."}, {"source_code": "program primer;\nvar t:string;\ns:array[1..60]of char;\nnach,len,i:longint;\n\nBEGIN\nread(t);\nlen:=length(t);\nnach:=1;\nif length(t)mod 2=0 then\n begin\n for i:=length(t)downto 1 do\n if i mod 2=0 then\n begin\n s[i]:=t[len];\n len:=len-1;\n end\n else \n begin\n s[i]:=t[nach];\n nach:=nach+1;\n end;\n end;\nif length(t)mod 2=1 then\n begin\n for i:=length(t)downto 1 do\n if i mod 2=0 then\n begin\n s[i]:=t[len];\n len:=len-1;\n end\n else \n begin\n s[i]:=t[nach];\n nach:=nach+1;\n end;\n end;\n//while i<=length(t)do\n\nfor i:=1 to length(t) do write (s[i]);\nEND."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\ns1, s2: string;\ni, x: integer;\nbegin\nreadln(s1);\ns2:=s1;\nx:=ceil(length(s1)/2);\ns2[1]:=s1[x];\nfor i:=1 to length(s1) do\nbegin\ns2[i+i]:=s1[x+i];\ns2[i+i+1]:=s1[x-i];\nend;\nif length(s1)=1 then s2:=s1;\nwriteln(s2);\n//readln;\nend.\n "}, {"source_code": "program z_a_del;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, s1: string;\n i: integer;\n\nbegin\n readln(s);\n i := 1;\n while(i <= length(s) div 2 + length(s) mod 2) do begin\n if(odd(length(s))) then begin\n s1 := s[i] + s1;\n if(length(s1) < length(s)) then\n s1 := s[length(s) - i + 1] + s1;\n end\n else begin\n s1 := s[length(s) - i + 1] + s1;\n if(length(s1) < length(s)) then\n s1 := s[i] + s1;\n end;\n inc(i);\n end;\n writeln(s1);\n readln;\n readln;\nend.\n "}, {"source_code": "var\ns,t:string;\nn,b:longint;\nbegin\nreadln(t);\nn:=length(t);\nif n mod 2 <>0 then \nbegin\nb:=1;\nwhile n<>0 do\nbegin\ns:=t[b]+s;\ndelete(t,1,1);\nn:=n-1;\nif n-1>=0 then begin\ns:=t[n]+s;\ndelete(t,n,1);\nn:=n-1;\nend;\nend;\nwriteln(s);\nhalt;\nend;\n\nif n mod 2 =0 then \nb:=n;\nwhile n<>0 do\nbegin\ns:=t[b]+s;\ndelete(t,n,1);\nn:=n-1;\nb:=n;\nif n-1>=0 then begin\ns:=t[1]+s;\ndelete(t,1,1);\nn:=n-1;\nb:=n;\nend;\nend;\nwriteln(s);\nend.\n"}, {"source_code": "var\n s,s1: ansistring;\n i,j,n,m,k : longint;\nbegin\n readln(s);\n n := length(s);\n k := (n div 2)+(n mod 2);\n if (n mod 2 = 0) then\n begin\n for i := 1 to n div 2 do\n begin\n s1 := s1+s[k-i+1];\n s1 := s1+s[n-k+i];\n end;\n end\n else\n begin\n s1 := s1+s[k];\n for i := 1 to n div 2 do\n begin\n s1 := s1+s[n-k+i+1];\n s1 := s1+s[k-i];\n end;\n end;\n writeln(s1);\nend."}, {"source_code": "Program First;\n\nconst\n\tMaxN = 50;\n\nvar\n\ts: String;\n\tans: Array[1..MaxN] of Char;\n\tl,r,k,i: LongInt;\n\tc: Char;\n\nBegin\n\tReadln(s);\n\tl:=1;\n\tr:= length(s);\n\tk:=1;\n\twhile r>=l do begin\n\t\tif (r-l) mod 2 = 1 then begin\n\t\t\tc:=s[r];\n\t\t\tans[k]:=c;\n\t\t\tr-=1;\n\t\tend\n\t\telse begin\n\t\t\tc:=s[l];\n\t\t\tans[k]:=c;\n\t\t\tl+=1;\n\t\tend;\t\n\t\tk+=1;\n\tend;\n\t\n\tfor i:=k-1 downto 1 do write(ans[i]);\n\nEnd.\n"}, {"source_code": "Var n,i: longint;\n s,t: string;\n\nBegin\nreadln(s);\nt:='';\nn:=length(s);\nif n mod 2=0 \nthen\nfor i:=1 to (length(s) div 2) do\n t:=t+s[n+1-i]+s[i]\nelse \nfor i:=1 to (length(s) div 2)+1 do\n t:=t+s[i]+s[n+1-i]; \nfor i:=n downto 1 do write(t[i]); \nend."}, {"source_code": "var s:ansistring;\n i,c:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n write(s[(length(s)+1)>>1+c]);\n if i mod 2=1 then c:=1-c\n else c:=-c;\n end;\nend."}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n if length(s) mod 2=0 then i:=length(S) div 2\n else i:=length(s) div 2 +1;\n if length(s)>1 then write(s[i]);\n u:=1;\n while u<=i-1 do\n begin\n write(s[i+u]);\n write(s[i-u]);\n inc(u);\n end;\n if (length(s) mod 2 = 0) or (length(s)=1) then write(s[length(S)]);\nend.\n"}, {"source_code": "var s,s1 :string;\n c : array [1..100] of char;\n p,i,p1 : longint;\nbegin\n readln(s);\n if frac(length(s)/2)=0.5 then p:=trunc(length(s)/2)+1\n else p:=round(length(s)/2);\n c[1]:=s[p];\n p1:=p-1;\n p:=p+1;\n for i:=2 to length(s) do begin\n if i mod 2=0 then begin\n c[i]:=s[p];\n p:=p+1;\n end;\n end;\n for i:=3 to length(s) do begin\n if i mod 2=1 then begin\n c[i]:=s[p1];\n p1:=p1-1;\n end;\n end;\n for i:=1 to length(s) do\n s1:=s1+c[i];\n writeln(s1);\nend."}, {"source_code": "var\n s,s1:string;\n i,l,n,a,b:longint;\nbegin\n readln(s);\n l:=length(s);\n n:=l;\n a:=l;\n b:=1;\n if (l=1) then writeln(s) else begin\n for i:=1 to l do begin\n if (n mod 2=0) then begin s1:=s[a]+s1; a:=a-1; end;\n if (n mod 2=1) then begin s1:=s[b]+s1; b:=b+1; end;\n n:=n-1;\n end;\n end;\n writeln(s1);\nend.\n"}, {"source_code": "var a,s,d:integer;\nq:string;\nw:array [1..51] of char;\nbegin\nread(q); writeln();\nfor a:=(length(q) div 2)+(length(q) mod 2) downto 1 do w[2*((length(q) div 2)+(length(q) mod 2)-a)+1]:=q[a];\nfor a:=(length(q) div 2)+(length(q) mod 2)+1 to length(q) do w[2*(a-length(q) div 2-length(q) mod 2)]:=q[a];\nfor a:=1 to length(q) do write(w[a]);\nend."}, {"source_code": "var s,st:string;d,i:longint;\nbegin\n read(st);\n d:=length(st);if d<3 then write(st) else \n if odd(d) then begin\n s:=st[d div 2+1];\n for i:=1 to d div 2 do\n begin\n s:=s+st[d div 2+1+i];\n s:=S+st[d div 2+1-i];\n end;\n \n end else begin\n s:='';\n for i:=1 to d div 2 do\n begin\n \n s:=s+st[d div 2+1-i]; s:=s+st[d div 2+i];\n end;\n\n end;write(s);\nend."}, {"source_code": "var s,t:string;\ni,j:longint;\nbegin\nreadln(t);\nif length(t) mod 2=1 then j:=(length(t) div 2)+1\nelse j:=length(t) div 2;\ns:=s+t[j];\ni:=j;\nj:=j-1; i:=i+1;\nwhile (j>0) do\nbegin\ns:=s+t[i]+t[j]; i:=i+1; j:=j-1;\nend;\nif length(t) mod 2=0 then s:=s+t[length(t)];\nwrite(s);\nend."}, {"source_code": "program aaa;\n\nvar\n\ts, result: string;\n\tsymbol: string[1];\n\tlen: integer;\n\tleft: boolean;\n\nbegin\n\treadln(s);\n\tlen := length(s);\n\n\tif (len - 1) mod 2 > 0 then begin\n\t\tleft := false;\n\tend\n\telse begin\n\t\tleft := true;\n\tend;\n\n\tresult := '';\n\n\twhile len > 0 do begin\n\t\tif left = true then begin\n\t\t\tsymbol := s[1];\n\t\t\tdelete(s, 1, 1);\n\t\t\tinsert(symbol, result, 1);\n\t\t\tleft := false;\n\t\tend\n\t\telse begin\n\t\t\tsymbol := s[len];\n\t\t\tdelete(s, len, 1);\n\t\t\tinsert(symbol, result, 1);\n\t\t\tleft := true;\n\t\tend;\n\n\t\tlen -= 1;\n\tend;\n\n\t//symbol := s[1];\n\t//insert(symbol, result, 1);\n\t\n\twriteln(result);\nend.\n"}, {"source_code": "var f1,f2:text;\n i,a,b,n:longint;\n s,st:string;\n begin\n assign(f1,'');\n reset(f1);\n assign(f2,'');\n rewrite(f2);\n readln(f1,s);\n n:=length(s);\n a:=1;\n b:=n;\n for i:=1 to n do\n begin\n if (n-i) mod 2=0 then\n begin st:=s[a]+st; inc(a); end else\n begin st:=s[b]+st; dec(b); end;\n end;\n writeln(f2,st);\n close(f1);\n close(f2);\n end."}, {"source_code": "var\n str: string;\n i, k, n, kol, per: longint;\n str1: array[1..99999] of char;\n\nbegin\n readln(str);\n k := length(str);\n kol := k;\n n := 1;\n i := 1;\n if length(str) mod 2 = 0 then \n while i <= length(str) do\n begin\n if i mod 2 = 1 then \n begin\n str1[i] := str[k];\n k := k - 1;\n end\n else\n begin\n str1[i] := str[n];\n n := n + 1;\n end;\n i := i + 1;\n end\n else\n while i <= length(str) do\n begin\n if i mod 2 = 0 then \n begin\n str1[i] := str[k];\n k := k - 1;\n end\n else\n begin\n str1[i] := str[n];\n n := n + 1;\n end;\n i := i + 1;\n end;\n for i := kol downto 1 do \n write(str1[i]);\nend.\n"}, {"source_code": "var\ns,ss:ansistring;\ni:longint;\na,b,l:int64;\nbegin\nreadln(s);\n\n\n l:=length(s);\n\n if l = 1 then begin write(s);halt;end;\n\n //s[0]:=s[1];\n\n\n if l mod 2 = 0 then a:=l div 2 else a:=l div 2 + 1;\n\n ss:=s[a];\n\n\n// if l mod 2 = 0 then b:=l\n\n for i:=1 to a do\n begin\n if a+i<=l then ss:=ss+s[a+i];\n if a-i>0 then ss:=ss+s[a-i];\n\n end;\n\n write(ss);\n\n\n\n\n {\nfor i:=1 to length(s) do\nif i mod 2 = 0 then ss:=ss+s[i] else ss:=s[i]+ss;\n\nwrite(ss);\n }\n\n\n\nend.\n"}, {"source_code": "var\n cipher,s,a: string;\n n,i,r,kol_nech: integer;\nbegin\n readln(cipher);\n n:=length(cipher);\n kol_nech:=(n+1) div 2;\n if (n mod 2)<>0 then //�����\n begin\n i:=kol_nech;\n a:=copy(cipher,i,1);\n s:=s+a;\n for r:=1 to (n div 2) do\n begin\n a:=copy(cipher,i+r,1);\n s:=s+a;\n a:=copy(cipher,i-r,1);\n s:=s+a;\n end;\n end\n else\n begin \n i:=kol_nech;\n a:=copy(cipher,i,1);\n s:=s+a;\n for r:=1 to ((n div 2)+1) do\n begin\n a:=copy(cipher,i+r,1);\n s:=s+a;\n a:=copy(cipher,i-r,1);\n s:=s+a;\n end;\n end;\n delete(s,n+1,2);\n writeln(s);\n end.\n \n \n \n \n "}, {"source_code": "var s,c:ansistring;\ni,n,m,k,x,fl,l,j:longint;\nbegin\nreadln(s);\nif length(s)=1 then begin writeln(s); exit; end else\n//if length(s)=3 then begin writeln(s); exit; end;\n\nif length(s) mod 2=1 then x:=length(s) div 2+1 else x:=length(s) div 2;\nc:=s[x];\nif length(s) mod 2=1 then\nfor i:=1 to (length(s) div 2) do c:=c+s[x+i]+s[x-i] else\nfor i:=1 to (length(s) div 2)-1 do c:=c+s[x+i]+s[x-i];\nif length(s) mod 2=0 then writeln(c+s[length(s)]) else writeln(c);\nend."}, {"source_code": "label \n even, odd, final;\nvar\n S, temp: string;\n i: integer;\n\nbegin\n read(S);\n temp := S;\n \n if length(S) = 1 then\n begin\n writeln(S);\n exit;\n end;\n \n if length(S) mod 2 = 0 then\n goto even\n else\n goto odd;\n \n even:\n temp := S[length(S)];\n for i := 1 to (length(S) div 2) do\n begin\n temp := S[i] + temp;\n if i = length(S) div 2 then\n break; \n temp := S[length(S) - i] + temp;\n end;\n goto final;\n \n odd:\n temp := S[1];\n for i := 0 to length(S) div 2 - 1 do\n begin\n temp := S[length(S) - i] + temp;\n temp := S[i + 2] + temp;\n end;\n goto final;\n \n final:\n writeln(temp); \nend."}, {"source_code": "var\n s: string;\n r: string;\n i: integer;\n\nbegin\n readln(s);\n if (Length(s) mod 2 = 0) then\n for i := 1 to Length(s) div 2 do\n r := s[i] + s[Length(s) + 1 - i] + r\n else\n begin\n for i := 1 to Length(s) div 2 do\n begin\n r := s[Length(s) + 1 - i] + s[i] + r;\n end;\n r := s[Length(s) div 2 + 1] + r\n end;\n write(r);\nend."}, {"source_code": "var f : text;\ni,j,g : integer;\na : array[0..50] of char;\nn : string;\nbegin\n { assigN(f,'AR.INP');\n reset(f); }\n readln(n);\n { close(f);\n assigN(F,'AR.OUT');\n rewrite(f); }\n j:=0;\n i := length(n)+1;\n g := length(n)+1;\n if length(n) mod 2 = 0 then\n begin\n repeat\n dec(i);dec(g);a[g] := n[i];\n if i=j then break;\n inc(j);dec(g);a[g] := n[j];\n until i = j;\n end else\n begin\n repeat\n inc(j);dec(g);a[g] := n[j];\n if i=j then break;\n dec(i);dec(g);a[g] := n[i];\n until i = j;\n end;\n for i := 1 to length(n) do write(a[i]);\n { close(f); }\n\nend.\n"}], "negative_code": [{"source_code": "var i,n, r,m,l: integer;\ns, s1:string;\nbegin\nread (s);\nn:= length(s);\nif n=1 then s1:=s else begin\nif n mod 2=0 then r:=(n div 2) else\nr:=(n div 2)+1;\ns1:=copy(s,r,1);\nif n mod 2=0 then\nbegin\nfor i:=1 to r-1 do\nbegin\nm:=r+i;\nl:=r-i;\ns1:=s1+copy(s,m,1)+copy(s,l,1); \nend;\ns1:= s1+copy(s,n,1)\nend else\nbegin\nfor i:=1 to r do\nbegin\nm:=r+i;\nl:=r-i;\ns1:=s1+copy(s,m,1)+copy(s,l,1); \nend;\nend;\nend;\nwrite(s1);\nend."}, {"source_code": "var ch,str:string;\nbegin\n readln(ch);\n str:='';\n while length(ch)<>0 do\n begin\n str:=ch[length(ch)]+str;\n delete(ch,length(ch),1);\n if length(ch)<>0 then\n str:=ch[1]+str;\n delete(ch,1,1);\n end;\n write(str);\n readln;\nend."}, {"source_code": "var f : text;\ni,j,g : integer;\na : array[0..50] of string;\nn : string;\nbegin\n { assigN(f,'AR.INP');\n reset(f); }\n readln(n);\n { close(f);\n assigN(F,'AR.OUT');\n rewrite(f);}\n j := 1;\n i := length(n);\n g := length(n);\n if length(n) mod 2 = 0 then\n begin\n repeat\n a[g] := n[i];dec(i);\n dec(g);if i 0 then\n begin j:=2;\n s:=a[length(A) div 2+1];\n for i:=length(A) div 2 downto 1 do\n s:=s+a[i];\n for i:=length(A) div 2+2 to length(A) do\n begin\n insert(a[i],s,j);\n j:=j+2;\n end;\n end;end;\nwriteln(s);\nend."}, {"source_code": "var s: string;\n a,b: array [1..50] of char;\n i, t, j, z: integer;\nbegin\n read (s);\n t:=1;\n while (s[t] <> #0) do\n begin\n a[t]:=s[t];\n inc (t);\n end;\n if t <= 2 then\n begin\n writeln (s);\n halt;\n end;\n dec(t);\n j:=t; z:=2;\n t:= t div 2;\n b[1]:= a[t];\n for i:=t+1 to j do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n z:=3;\n for i:=t-1 downto 1 do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n for i:= 1 to j do write (b[i]);\n writeln;\nend.\n"}, {"source_code": "var s: string;\n a,b: array [1..50] of char;\n i, t, j, z: integer;\nbegin\n read (s);\n t:=1;\n while (s[t] <> #0) do\n begin\n a[t]:=s[t];\n inc (t);\n end;\n if t <= 1 then\n begin\n writeln (s);\n halt;\n end;\n dec(t);\n j:=t; z:=2;\n t:= t div 2;\n b[1]:= a[t];\n for i:=t+1 to j do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n z:=3;\n for i:=t-1 downto 1 do\n begin\n b[z]:= a[i];\n z:=z+2;\n end;\n for i:= 1 to j do write (b[i]);\n writeln;\nend.\n"}, {"source_code": "var\n\ts,t:string;\n\ti,l:longint;\nbegin\n\treadln(s);\n\tl:=length(s);\n\tt:='';\n\tif l mod 2=1 then t:=s[l div 2+1];\n\tfor i:=l div 2 downto 1 do\n\t\tt:=t+s[i]+s[l-i+1];\n\twriteln(t);\nend."}, {"source_code": "var\n\tn, i, j: int64;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(s);\n\tj := s.length;\n\ti := 1;\n\t\n\tif (s.length = 1) then\n\t\twriteln(s)\n\telse begin\n\t\twhile (i <= s.length div 2) and (j > s.length div 2) do\n\t\tbegin\n\t\t\ts1 += s[j] + s[i];\n\t\t\ti += 1;\n\t\t\tj -= 1;\n\t\tend;\n\t\t\n\t\twriteln(reverseString(s1));\n\tend;\n\t\nend.\n"}, {"source_code": "var s, n, c: string;\nbegin\n read(s);\n if length(s) mod 2 = 0 then\n begin\n while length(s)<> 0 do\n begin\n c:=copy(s,length(s),1);\n delete(s,length(s),1);\n n:=n+c;\n if length(s)<>0 then\n begin\n c:=copy(s,1,1);\n delete(s,1,1);\n n:=n+c;\n end;\n end;\n end\n else\n begin\n while length(s)<> 0 do\n begin\n c:=copy(s,1,1);\n delete(s,1,1);\n n:=n+c;\n if length(s)<>0 then\n begin\n c:=copy(s,1,1);\n delete(s,1,1);\n n:=n+c;\n end;\n end;\n end;\n while length(n) <> 0 do\n begin\n c:=copy(n,length(n),1);\n delete(n,length(n),1);\n s:=s+c;\n end;\n write(s);\nend."}, {"source_code": "var s,t,r:string;\nvar a,b,c,l:int64;\nbegin\nRead(s);\nl:=length(s);\nif l=1 then begin Writeln(s); exit; end;\na:=l;\nb:=1;\nwhile a>0 do begin\nt:=t+s[a];\nt:=t+s[b];\na:=a-1;\nb:=b+1;\nif a=b then begin t:=t+s[a]; break; end;\nif b>a then break;\nend;\nfor l:=length(t) downto 1 do Write(t[l]);\nend."}, {"source_code": "var s,t,r:string;\nvar a,b,c,l,i:int64;\nbegin\nRead(s);\nl:=length(s);\nif l=1 then begin Writeln(s); exit; end;\nif l mod 2 = 1 then begin\nc:=(l div 2)+1;\nt:=s[c];\nfor i:=(l div 2) downto 1 do begin\nc:=c+1;\nt:=t+s[c]+s[i];\nend;\nWriteln(t);\nexit;\nend;\na:=l;\nb:=1;\nwhile a>0 do begin\nt:=t+s[a];\nt:=t+s[b];\na:=a-1;\nb:=b+1;\nif a=b then begin t:=t+s[a]; break; end;\nif b>a then break;\nend;\nWriteln(t);\nfor l:=length(t) downto 1 do Write(t[l]);\nend."}, {"source_code": "var s,t,r:string;\nvar a,b,c,l:int64;\nbegin\nRead(s);\nl:=length(s);\na:=l;\nb:=1;\nwhile a>0 do begin\nt:=t+s[a];\nt:=t+s[b];\na:=a-1;\nb:=b+1;\nif a=b then begin t:=t+s[a]; break; end;\nif b>a then break;\nend;\nfor l:=length(t) downto 1 do Write(t[l]);\nend."}, {"source_code": "program technocup_2018_otbortur4_A;\n\nvar\n s, sres: string;\n i: integer;\nbegin\n read(s);\n sres := ' ';\n if (length(s) mod 2 = 1) then begin\n sres[1] := s[length(s) div 2 + 1];\n for i := 1 to length(s) div 2 do begin\n sres[length(s) - i * 2 + 2] := s[length(s) - i + 1];\n sres[length(s) - i * 2 + 1] := s[i];\n end;\n end else begin\n for i := 1 to length(s) div 2 do begin\n sres[length(s) - i * 2 + 2] := s[length(s) - i + 1];\n sres[length(s) - i * 2 + 1] := s[i];\n end;\n end;\n write(sres);\nend."}, {"source_code": "var i,t:1..50;s,h:string;\nbegin\nread(s);t:=length(s);\nfor i:=1 to t div 2 do begin h:=s[t-i+1]+h;h:=s[i]+h;end;\nif t mod 2=1 then h:=s[t div 2+1]+h;\nprint(h);\nend."}, {"source_code": "var\n s, t: string;\n i, k, long, mid: integer;\n\nbegin\n readln(t);\n long := length(t);\n if long mod 2 = 0 then\n begin\n mid := length(t) div 2;\n s := s + t[mid];\n for i := 1 to long div 2 - 1 do\n begin\n s := s + t[mid + i];\n s := s + t[mid - i];\n end;\n if long > mid + i + 1 then\n s := s + t[mid + i + 1]\n else\n s := s + t[mid + i];\n end\n else\n begin\n mid := length(t) div 2 + 1;\n s := s + t[mid];\n for i := 1 to long div 2 do\n begin\n s := s + t[mid + i];\n s := s + t[mid - i];\n end;\n end;\n write(s);\nend."}, {"source_code": "var\nn,i,q,e:integer;\ns,b:string;\nbegin\nread(s);\ne:=1;\nq:=2;\nn:=length(s);\n if n mod 2 =0 then\n begin\n b:=copy(s,n div 2,2);\n for i:=1 to n-2 do\n begin\n if i mod 2=1 then\n begin\n b:=b+copy(s,(n div 2)-e,1);\n inc(e);\n end\n else\n begin\n b:=b+copy(s,(n div 2)+q,1);\n inc(q);\n end;\n end;\n end\n else \n begin\n b:=copy(s,n div 2 +1,2);\n for i:=1 to n-2 do\n begin\n if i mod 2=1 then\n begin\n b:=b+copy(s,(n div 2)-1-e,1);\n inc(e);\n end\n else\n begin\n b:=b+copy(s,(n div 2)-1+q,1);\n inc(q);\n end;\n end;\n end;\nwrite(b);\nend."}, {"source_code": "var\n s, otv :string; i :longint;\nbegin\n readln (s);\n i:=(length(s)+1) div 2;\n while length(otv)<>length(s) do\n begin\n otv+=copy(s, i, 1);\n if i<=(length(s)+1) div 2 then\n i:=length(s)-i+1\n else\n i:=length(s)-i;\n end;\n writeln (otv);\nend."}, {"source_code": "Var\n S: String;\n t: Int64;\n k: Boolean;\n \nBegin\n Readln(S);\n If Length(S) = 1 then\n Write(S)\n Else\n For Var i := 1 to Length(S) div 2 do\n Write(S[Length(S) div 2 - i + 1],S[Length(S) div 2 + i])\nEnd."}, {"source_code": "Var\n S: String;\n t: Int64;\n k: Boolean;\n \nBegin\n Readln(S);\n If Length(S) = 1 then\n Write(S)\n Else If Length(S) mod 2 = 0 then\n For Var i := 1 to Length(S) div 2 do\n Write(S[Length(S) div 2 - i + 1],S[Length(S) div 2 + i])\n Else Begin\n Write(S[Length(S) div 2 + 1]);\n For Var i := 1 to Length(S) div 2 do\n Write(S[Length(S) div 2 + 1 - i],S[Length(S) div 2 + 1 + i])\n End\nEnd."}, {"source_code": "program GG1;\nvar\ns,sp:string;\na,i,k,l:longint;\nbegin\nreadln(s);\na:=1;\ni:=1;//нужно чтобы он два раза прошёл\nk:=length(s)-length(s)div 2;//3\nsp:=s[k];\nif k mod 2<>0 then\nbegin\nfor i:=1 to length(s) div 2 -1 do\nsp:=sp+s[k+i]+s[k-i];\nsp:=sp+s[length(s)];\nend\nelse\nfor i:=1 to length(s) div 2 do//при \nsp:=sp+s[k+i]+s[k-i];\nwriteln(sp);\nend."}, {"source_code": "var s,s2:string; p,i:integer;\nbegin\nreadln(s);\np:=length(s) div 2;\n for i:=0 to length(s)-1 do begin\n if i mod 2=0 then\n p:=p-i else p:=p+i;\n s2:=s2+copy(s,p,1);end;\n writeln(s2); end."}, {"source_code": "function zerc(s:string):string;\nvar\n p:string;\n i:integer;\nbegin\n p:='';\n for i:=length(s) downto 1 do\n begin\n p:=p+copy(s,i,1);\n delete(s,i,1);\n end;\n zerc:=p;\nend;\n\nvar s,t,n:string;\nbegin\n readln(t);\n s:='';\n n:='';\n if length(t) mod 2=0 then\n while t<>''\n do\n begin\n n:=n+copy(t,length(t),1);\n delete(t,length(t),1);\n n:=n+copy(t,1,1);\n delete(t,1,1); \n end\n else\n begin\n while length(t)<>1 do\n begin\n n:=n+copy(t,length(t),1);\n delete(t,length(t),1);\n n:=n+copy(t,1,1);\n delete(t,1,1);\n end;\n n:=n+t;\n end;\n writeln(zerc(n));\nend."}, {"source_code": "var s,s1:string;\ni,j,n,m,k,l:longint;\nbegin\nreadln(s);\nn:=length(s);\nif length(s)=1 then begin writeln(s); exit; end;\nif n mod 2=0 then s1:=copy(s,length(s) div 2,2) else s1:=s1+s[length(s) div 2];\nfor i:=(length(s) div 2)-1 downto 1 do begin s1:=s1+s[i]; s1:=s1+s[length(s)-i+1]; end;\nwriteln(s1);\nend.\n"}, {"source_code": "var s,s1:string;\ni,j,n,m,k,l:longint;\nbegin\nreadln(s);\nn:=length(s);\nif length(s)=1 then begin writeln(s); exit; end;\nif n mod 2=0 then s1:=copy(s,length(s) div 2,2) else s1:=s1+s[length(s) div 2];\nif n mod 2=0 then\nbegin\nfor i:=(length(s) div 2)-1 downto 1 do begin s1:=s1+s[i]; s1:=s1+s[length(s)-i+1]; end;\nend else\nfor i:=(length(s) div 2)+1 to length(s) do begin s1:=s1+s[i]; s1:=s1+s[length(s)-i+1]; end;\nwriteln(s1);\nend.\n"}, {"source_code": "var\n code, origin: string;\n len: int64;\n\nbegin\n readln(code);\n len := length(code);\n if len = 1 then\n write(code)\n else\n while len > 0 do\n begin\n origin := code[len] + origin;\n origin := code[1] + origin;\n delete(code, len, 1);\n delete(code, 1, 1);\n len := length(code); \n end;\n write(origin);\nend."}, {"source_code": "var\n code, origin: string;\n len: int64;\n\nbegin\n readln(code);\n len := length(code);\n while len > 0 do\n begin\n origin := code[len] + origin;\n origin := code[1] + origin;\n delete(code, len, 1);\n delete(code, 1, 1);\n len := length(code); \n end;\n write(origin);\nend."}, {"source_code": "LABEL f;\nvar str, ans:string;\n l, i, g:integer;\n ch:array[1..52] of char;\nbegin\nreadln(str);\nl:=length(str);\ng:=l;\ni:=1;\nif l>3 then begin\n while g>i do begin\n ch[l]:=str[g];\n ch[l-1]:=str[i];\n l:=l-2;\n i:=i+1;\n g:=g-1;\n end;\n if g=i then ch[1]:=str[i];\n i:=1;\nend\nelse if l=3 then begin\n ch[1]:=str[2];\n ch[2]:=str[3];\n ch[3]:=str[1];\n end\n else begin \n ans:=str;\n goto f;\n end;\nwhile i<=length(str) do begin\nans:=concat(ans, ch[i]);\ni:=i+1;\nend;\nf:\nwriteln(ans);\nend."}, {"source_code": "program df;\nvar\n s,ans,s1:string;\n i,m:integer;\nbegin\n readln(s);\n m:=1;\n for i:=1 to length(s) do begin\n \n if i mod 2<>0 then begin\n s1:=copy(s,length(s)+1-m,1);\n ans:=ans+s1;\n end else \n begin \n s1:=copy(s,m,1);\n ans:=ans+s1;\n inc(m);\n end;\n end;\n for i:=length(ans) downto 1 do\n write(ans[i]);\nend."}, {"source_code": "program a;\n\nvar\n t, t1, o: string;\n o2, i, k, ch: integer;\n\nbegin// techno - ncteho\n read(t);\n k := 1;\n ch := Length(t);\n if Length(t) = 1 then writeln(t) else \n repeat\n o2 := Length(t);o := copy(t, 1, 1) + copy(t, o2, 1);delete(t, o2, 1);delete(t, 1, 1);t1 := o + t1;\n until Length(t) < 1;\n write(t1);\nend."}, {"source_code": "var s,s1: string;\nbegin\n readln(s);\n if s.Length mod 2=0 then\n for var i:=1 to s.Length div 2 do\n s1:=s1+s[s.Length+1-i]+s[i]\n else begin for var i:=1 to s.Length div 2 do\n s1:=s1+s[i]+s[s.Length+1-i];\n insert(s[s.Length div 2 +1], s1, 1);\n end;\n writeln(ReverseString(s1));\nend."}, {"source_code": "var s,s1: string;\nbegin\n readln(s);\n if s.Length mod 2=0 then\n for var i:=1 to s.Length div 2 do\n s1:=s1+s[s.Length+1-i]+s[i]\n else begin for var i:=1 to s.Length div 2 do\n s1:=s1+s[i]+s[s.Length+1-i];\n insert(s[s.Length div 2 +1], s1, s1.Length div 2+1);\n end;\n writeln(ReverseString(s1));\nend."}, {"source_code": "program tehnocup;\n\nvar txt,s:string;\n\ti:integer;\n\nbegin\n\tReadln(txt);\n\ts:=s+txt[1];\n for i:=2 to length(txt) do\n begin\n if i mod 2 = 0 then\n begin\n s:=s+txt[i];\n end \n else begin\n s:=txt[i]+s;\n end;\n end;\n\tWriteln(s);\nend."}, {"source_code": "var\n s1, s2: string;\n ch, i: longint;\n\nbegin\n readln(s1);\n for i := 1 to length(s1) div 2 do\n begin\n s2 := s1[length(s1) - i + 1] + s2;\n s2 := s1[i] + s2;\n end;\n if length(s1) mod 2 = 1 then write(s1[length(s1) div 2 + 1]);\n writeln(s2);\nend."}, {"source_code": "function pal(s:string):string;\nvar k:integer;\n b:string;\n begin\n k:=length(s);\n if k>1 then\n begin\n b:=s[k];\n delete(s,length(s),1);\n pal:=pal(b)+pal(s);\n k:=k-1;\n end\n else \n pal:=s[k];\n end;\nvar s,se,see:string;\nbegin\nreadln(s);\nse:=pal(s);\ndelete(se,pos('\\',se),length(se)-pos('\\',se)+1);\nsee:=pal(se);\ndelete(see,pos('.',see),length(see)-pos('.',see)+1);\nwriteln(see);\nend. "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n u1, u2, i: integer;\n s, t: string;\n\nbegin\n readln(t);\n s := '';\n u1 := 1;\n u2 := length(t);\n for i := 1 to length(t) do\n if (i mod 2 = 0) then\n begin\n s := t[u1] + s;\n inc(u1);\n end\n else\n begin\n s := t[u2] + s;\n dec(u2);\n end;\n writeln(s);\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ns1, s2: string;\ni, x: integer;\nbegin\nreadln(s1);\ns2:=s1;\nx:=round(length(s1)/2);\ns2[1]:=s1[x];\nfor i:=1 to length(s1) do\nbegin\ns2[i+i]:=s1[x+i];\ns2[i+i+1]:=s1[x-i];\nend;\nif length(s1)=1 then s2:=s1;\nwriteln(s2);\n//readln;\nend.\n "}, {"source_code": "program zadachaA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, s1: string;\n i, mid, p: integer;\n\nbegin\n readln(s);\n s1 := '';\n s := ' ' + s;\n s := s + ' ';\n mid := (length(s) + 1) div 2;\n s1 := s1 + s[mid];\n p := 1;\n for i := 1 to (length(s)) div 2 do begin\n s1 := s1 + s[mid + p];\n s1 := s1 + s[mid - p];\n inc(p);\n end;\n while (pos(' ', s1) > 0) do\n delete(s1, pos(' ', s1), 1);\n writeln(s1);\n readln;\nend.\n"}, {"source_code": "Program RightLeftCipher;\nuses math;\nvar t,S:ansistring; x:longint;\nProcedure Decode;\nbegin S:='';\n while t<>'' do\n begin x:=(1+length(t)) div 2;\n S:=S+t[x];\n delete(t,x,1);\n end;\n writeln(S);\nend;\nbegin {assign(input,'1085A.inp'); reset(input);\n assign(output,'1085A.out'); rewrite(output);}\n readln(t);\n Decode;\n {close(input); close(output);}\nend.\n"}, {"source_code": "Program RightLeftCipher;\nuses math;\nvar t,tr:ansistring; x:longint;\nProcedure Decode;\nbegin tr:='';\n while t<>'' do\n begin x:=(1+length(t)) div 2;\n tr:=tr+t[x];\n delete(t,x,1);\n end;\n writeln(tr);\nend;\nbegin {assign(input,'1085A.inp'); reset(input);\n assign(output,'1085A.out'); rewrite(output);}\n readln(t);\n Decode;\n {close(input); close(output);}\nend.\n"}, {"source_code": "Program RightLeftCipher;\nuses math;\nvar t,S:ansistring; x:longint;\nProcedure Decode;\nbegin S:='';\n while length(t)>0 do\n begin x:=(1+length(t)) div 2;\n S:=S+t[x];\n delete(t,x,1);\n end;\n writeln(S);\nend;\nbegin {assign(input,'1085A.inp'); reset(input);\n assign(output,'1085A.out'); rewrite(output);}\n readln(t);\n Decode;\n {close(input); close(output);}\nend.\n"}, {"source_code": "Program RightLeftCipher;\nuses math;\nvar t,tr:ansistring; x:longint;\nProcedure Decode;\nbegin tr:='';\n while t<>'' do\n begin x:=(1+length(t)) div 2;\n tr:=tr+t[x];\n delete(t,x,1);\n end;\n writeln(tr);\nend;\nbegin readln(t);\n Decode;\nend."}, {"source_code": "Program a;\nvar\n\ts, res:string;\n\ttmp, tmp2, i, next:longint;\nbegin\n\treadln(s);\n\tif length(s)=1 then begin\n\t\twriteln(s);\n\t\texit;\n\tend;\n\tif length(s)=2 then begin\n\t\tres:=s[2];\n\t\tres+=s[1];\n\t\twriteln(res);\n\t\texit;\n\tend;\n\ttmp:=length(s) div 2;\n\tres:=s[tmp];\n\tnext:=2;\n\tif length(s) mod 2 = 0 then begin\n\t\tfor i:=tmp+1 to length(s)-1 do begin\n\t\t\tres+=s[i];\n\t\t\tres+=s[i- next];\n\t\t\tnext+=2;\n\t\tend;\n\t\tres+=s[length(s)];\n\t\twriteln(res);\n\tend\n\telse begin\n\t\tres:=s[tmp+1];\n\t\tfor i:=tmp+2 to length(s) do begin\n\t\t\tres+=s[i];\n\t\t\tres+=s[i- next];\n\t\t\tnext+=2;\n\t\tend;\n\t\twriteln(res);\n\tend;\nend."}, {"source_code": "var\n s,s1 : string;\n i,j,n,m,l : longint;\nbegin\n readln(s);\n l := length(s);\n m := l div 2;\n if (l mod 2 = 1) then\n inc(m);\n write(s[m]);\n for i := 1 to m-1 do\n s1 := s1+s[l-m+i]+s[m-i];\n write(s1);\n if (l > 1) then\n write(s[l]);\nend.\n"}, {"source_code": "var\n s,s1 : ansistring;\n i,j,n,m,l : longint;\nbegin\n readln(s);\n l := length(s);\n m := l div 2;\n if (l mod 2 = 1) then\n inc(m);\n write(s[m]);\n for i := 1 to m-1 do\n s1 := s1+s[l-m+i]+s[m-i];\n write(s1);\n if (l > 1) then\n write(s[l]);\nend.\n"}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n if length(s) mod 2=0 then i:=length(S) div 2\n else i:=length(s) div 2 +1;\n if length(s)>1 then write(s[i]);\n u:=1;\n while u<=i-1 do\n begin\n write(s[i+u]);\n write(s[i-u]);\n inc(u);\n end;\n if length(s) mod 2 =0 then write(s[length(S)]);\nend.\n"}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n i:=length(S) div 2;\n write(s[i]);\n u:=1;\n while u<=i-1 do\n begin\n write(s[i+u]);\n write(s[i-u]);\n inc(u);\n end;\n write(s[length(S)]);\nend.\n"}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n i:=length(S) div 2;\n if length(s)>1 then write(s[i]);\n u:=1;\n if length(s) mod 2=0 then\n begin\n while u<=i-1 do\n begin\n write(s[i+u]);\n write(s[i-u]);\n inc(u);\n end;\n end\n else\n begin\n while u<=i do\n begin\n write(s[i+u]);\n inc(u);\n end;\n u:=1;\n while u<=i-1 do\n begin\n write(s[i-u]);\n inc(U);\n end;\n end;\n write(s[length(S)]);\nend.\n"}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n i:=length(S) div 2;\n if length(s)>1 then write(s[i]);\n u:=1;\n while u<=i-1 do\n begin\n write(s[i+u]);\n write(s[i-u]);\n inc(u);\n end;\n write(s[length(S)]);\nend.\n"}, {"source_code": "var s:ansistring;\n u,i:longint;\nbegin\n read(s);\n i:=length(S) div 2;\n write(s[i]);\n while u<=i do\n begin\n inc(u);\n write(s[i+u]);\n write(s[i-u]);\n end;\nend.\n"}, {"source_code": "var\n s,s1:string;\n i,l,n,a,b:longint;\nbegin\n readln(s);\n l:=length(s);\n n:=l;\n a:=l;\n b:=1;\n if (l=1) then writeln(s) else begin\n for i:=1 to l do begin\n if (n mod 2=0) then begin s1:=s[a]+s1; a:=a-1; end;\n if (n mod 2=0) then begin s1:=s[b]+s1; b:=b+1; end;\n n:=n-1;\n end;\n end;\n writeln(s1);\nend.\n"}, {"source_code": "program aaa;\n\nvar\n\ts, result: string;\n\tsymbol: string[1];\n\tlen, lenResult: integer;\n\tleft: boolean;\n\nbegin\n\treadln(s);\n\tlen := length(s);\n\n\tif len - 1 mod 2 <> 0 then begin\n\t\tleft := false;\n\tend\n\telse begin\n\t\tleft := true;\n\tend;\n\n\tresult := '';\n\tlenResult := 1;\n\n\twhile len > 1 do begin\n\t\tif left = true then begin\n\t\t\tsymbol := s[1];\n\t\t\tdelete(s, 1, 1);\n\t\t\tinsert(symbol, result, 1);\n\t\t\tleft := false;\n\t\tend\n\t\telse begin\n\t\t\tsymbol := s[len];\n\t\t\tdelete(s, len, 1);\n\t\t\tinsert(symbol, result, 1);\n\t\t\tleft := true;\n\t\tend;\n\n\t\tlen -= 1;\n\t\tlenResult += 1;\n\tend;\n\n\tsymbol := s[1];\n\tinsert(symbol, result, 1);\n\t\n\twriteln(result);\nend.\n"}, {"source_code": "var\na,ans:string;\nbegin\nreadln(a);\nif length(a) mod 2=1 then \n begin\n ans:=a[length(a)];\n delete(a,length(a),1);\n end;\nwhile length(a)>0 do \n begin\n ans:=a[1]+a[length(a)]+ans;\n delete(a,1,1);\n delete(a,length(a),1);\n end;\nwriteln(ans);\nend."}, {"source_code": "var\ns,ss:ansistring;\ni:longint;\na,b,l:int64;\nbegin\nreadln(s);\n\n\n l:=length(s);\n\n if l = 1 then begin write(s);halt;end; \n\n //s[0]:=s[1];\n\n\n if l mod 2 = 0 then a:=l div 2 else a:=l div 2 + 1;\n\n ss:=s[a];\n\n\n// if l mod 2 = 0 then b:=l\n\n for i:=1 to a do\n begin\n ss:=ss+s[a+i];\n if a-i>0 then ss:=ss+s[a-i];\n\n end;\n\n write(ss);\n\n\n\n\n {\nfor i:=1 to length(s) do\nif i mod 2 = 0 then ss:=ss+s[i] else ss:=s[i]+ss;\n\nwrite(ss);\n }\n\n\n\nend.\n"}, {"source_code": "Var s : String;\n i , k , n : Integer ;\n \nBegin\nReadln(s); n := Length(s); i := n div 2;\nIf n mod 2 <> 0 then Inc(i);\nWrite(S[i]);\nWhile (1 <= i) and (i <= n) do\n Begin\n If k mod 2 = 0 then Begin Write(S[i+k+1]); Inc(i , k + 1); End;\n If k mod 2 <> 0 then Begin Write(S[i-k-1]); Dec(i , k + 1); End;\n Inc(k);\n End;\nEnd."}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\ns:=s+a[length(a)div 2+i]+a[length(a)div 2-i];\n//writeln(i);\nend;\nwrite(a[length(a) div 2]);\nfor i:=1 to length(s)-1 do\nwrite(s[i]);\n\n\nend.\n"}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\ns:=s+a[length(a)div 2+i]+a[length(a)div 2-i];\n//writeln(i);\nend;\nif length(a)mod 2=0 then write(a[length(a) div 2]);\nif length(a)mod 2=1 then write(a[length(a) div 2+1]);\nfor i:=1 to length(s)-1 do\nwrite(s[i]);\n\n\nend.\n"}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2+i];//+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2+i+1];\n\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2-i+1];\n//writeln(i); 7\nend;\nif length(a)mod 2=0 then write(a[length(a) div 2]);\nif length(a)mod 2=1 then write(a[length(a) div 2+1]);\n//write(s[1])\nwrite(s);\n\n\nend.\n"}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\ns:=s+a[length(a)div 2+i]+a[length(a)div 2-i];\n//writeln(i);\nend;\nwrite(a[length(a) div 2]);\n\nwrite(s);\n\n\nend."}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2+i];//+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2+i+1];\n\nif length(a)mod 2 = 0 then s:=s+a[length(a)div 2-i];\nif length(a)mod 2 = 1 then s:=s+a[length(a)div 2-i+1];\n//writeln(i); 7\nend;\nif length(a)mod 2=0 then write(a[length(a) div 2]);\nif length(a)mod 2=1 then write(a[length(a) div 2+1]);\n//write(s[1])\nif length(s)mod 2 = 1 then begin\nfor i:=1 to length(s)-1 do\nwrite(s[i]);\nhalt;\nend;\n//for i:=1 to length(s) do\nwrite(s);\nend."}, {"source_code": "var\na,s:string;\nf,g,h:int64;\ni,j:longint;\nbegin\n\nread(a);\nfor i:=1 to length(a)div 2 do\nbegin\ns:=s+a[length(a)div 2+i]+a[length(a)div 2-i];\n//writeln(i);\nend;\nif length(a)mod 2=0 then write(a[length(a) div 2]);\nif length(a)mod 2=1 then write(a[length(a) div 2+1]);\n\nwrite(s);\n\n\nend.\n"}], "src_uid": "992ae43e66f1808f19c86b1def1f6b41"} {"source_code": "Var k,n,i:longInt;\nBegin\n Read(k,n);\n While (n>1)and(n mod k=0) do\n begin\n n:=n div k;\n Inc(i);\n end;\n If n=1 Then begin\n WriteLn('YES');\n WriteLn(i-1);\n end\n else WriteLn('NO');\nEnd.", "positive_code": [{"source_code": "program cifera;\nvar\nk,f,l,md : int64;\n\ni,n : int64;\nla : int64 ;\nlas : extended;\nbegin\n readln(k);\n readln(l);\n md:= l mod k;\n\n la:= 0 ;\n las:=l;\n if md = 0 then\n begin\n\n while las > 1 do\n begin\n\n las:= las / k;\n la:= la + 1;\n end;\n\n if las = 1 then\n begin\n writeln('YES');\n writeln(la-1)\n end\n else\n begin\n writeln('NO');\n\n end;\n\n\n\n\n end\n else\n writeln('NO');\nend.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n l: Int64;\n k, x, i: Integer;\n\nbegin\n x := 0;\n Readln(k, l);\n for i := 1 to 32 do begin\n if l = 1 then\n Break;\n if l mod k <> 0 then\n begin\n x := 0;\n Break;\n end;\n l := l div k;\n inc(x);\n end;\n if x <> 0 then\n begin\n Writeln('YES');\n Writeln(x - 1);\n end\n else\n Writeln('NO');\n readln;\n readln;\nend.\n "}, {"source_code": "var\n n,k,i,q : int64;\n\nbegin\n readln(n,k);\n q:=n;\n while n <= k do\n begin\n if n = k then begin writeln('YES'); writeln(i); exit; end;\n inc(i);\n n:=n*q;\n end;\n writeln('NO');\nend."}, {"source_code": "Var osn,ch,step:longint;\nbegin\nreadln(osn);\nreadln(ch);\nstep:=0;\nwhile (ch div osn>=1) and\n(ch mod osn=0) do\nbegin\nstep:=step+1;\ncH:=ch div osn;\nend;\nif (step=0) or\n(ch<>1) then writeln('NO') else begin writeln('YES'); writeln(step-1);\nend;\nend."}, {"source_code": "var\ti,k,l:longint;\n\tt:int64;\n \tchk:boolean;\n\nbegin\n\treadln(k);\n\treadln(l);\n\ti:=1;\n \tt:=k;\n\twhile t<=l do\n\tbegin\n\t\tif t=l then\n \t\tbegin\n \t\t\tchk:=true;\n \t\t\tbreak;\n \t\tend;\n\t\tt:=t*k;\n\t\tinc(i);\n\tend;\n\tif chk=true then\n \tbegin\n \t\twriteln('YES');\n \t\twrite(i-1);\n \tend\n \telse write('NO');\n \treadln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,f,n: int64;\n P,flag:word;\n\nbegin\n readln(a); readln(f); p:=0; n:=a; flag:=0;\n while n<=f do\n begin\n if n=f then begin flag:=1; break; end;\n n:=n*a; p:=p+1;\n end;\n\n if flag =1 then begin writeln('YES'); Writeln(p); end\n else writeln('NO');\n Readln;\n\nend.\n"}, {"source_code": "var a,b,c,suma,d,z:int64;\nvar i,j:longint;\n\nbegin\n\nreadln (a,b);\n suma:=1;\n\n if a=b then\n begin\n writeln ('YES');\n writeln (0);\n exit;\n end;\n\nfor I:= 1 to 31 do\n\n\n\n\n begin\n suma:= suma*a;\n if suma=b then\n\n begin\n writeln('YES');\n writeln(i-1);\n exit;\n end;\n\n\n\n d:=1;\n end;\n\n writeln ('NO');\n\n end."}, {"source_code": "var\n l,i:longint;\n k,s:int64;\nbegin\n read(k,l);\n i:=0;s:=k;\n while k1 do\n begin\n if l mod k=0 then begin\n ans:=ans+1;\n l:=l div k;\n end\n else begin\n writeln('NO');\n break;\n end;\n end;\nif l=1 then begin\n writeln('YES');\n writeln(ans-1);\n end;\nend.\n"}, {"source_code": "{APPTYPE CONSOLE}\n{$o-}\nvar k,l,f: int64; i: longint;\nbegin\n//reset(input,'a.in');\n//rewrite(output, 'a.out');\nreadln(k); f:=k;\nread(l); i:=0;\nwhile kl then Write('NO') else Write('YES', #13, #10, i);\n\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,k,a,count:int64;\nbegin\nreadln(n);\nreadln(k);\na := n;\nwhile n < k do\nbegin\nn := n * a;\ncount := count + 1;\nend;\nif n = k then\nbegin\nwriteln('YES');\nwriteln(count);\nend\nelse\nwriteln('NO');\nend."}, {"source_code": "program cifera;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k , l , i , a , b , j: Integer;\n check: Boolean;\n\nbegin\n Readln(k);\n Readln(l);\n b := l;\n i := 0;\n check := True;\n\n while l > 0 do\n begin\n if (l mod k = 0) then\n begin\n l := l div k;\n Inc(i);\n end\n else\n Break;\n end;\n\n a := 1;\n\n for j := 1 to i do\n a := a * k;\n\n if a = b then\n begin\n Writeln('YES');\n Writeln(i - 1);\n end\n else\n writeln('NO'); \n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar k, l, t: longint;\n\nbegin\n read(k, l);\n t := 0;\n while (l >= k) and (l mod k = 0) do\n begin\n l := l div k;\n inc(t);\n end;\n if l = 1 then\n begin\n writeln('YES');\n write(t - 1);\n end\n else writeln('NO');\nend.\n\n "}, {"source_code": "var\nk,l,i:int64;\nbegin\nreadln(k);\nreadln(l);\nwhile l>0 do\n begin\n if l=1 then\n begin\n writeln('YES');\n writeln(i-1);\n halt;\n end;\n if l mod k<>0 then\n begin\n writeln('NO');\n halt;\n end;\n l:=l div k;\n inc(i);\n end;\nend."}, {"source_code": " var n,m,a,x,y:int64;\n begin\n read(n,m);\n a:=n;\n if n=m then begin Writeln('YES'); Write(0); end\n else\n begin\n while x<>1 do\n begin\n inc(y);\n n:=n*a;\n if n>m then begin Writeln('NO'); halt; halt;end;\n if n=m then begin Writeln('YES'); Write(y); halt;end;\n end;\n end;\n end."}, {"source_code": "var\n k,l,i:int64;\nbegin\n readln(k);\n read(l);\n while l>0 do\n begin\n if l=1 then begin writeln('YES'); write(i-1); halt; end;\n if l mod k<>0 then begin write('NO'); halt; end;\n l:=l div k;\n inc(i);\n end;\nend."}, {"source_code": "var k,l,i,o :int64;\nbegin\nread (k,l);\ni:=1; o:=0;\ni:=k;\nwhile i<=l do\nbegin\nif ik do begin\n inc(ans);\n u:=l mod k;\n if u>0 then break;\n l:=l div k;\n if l=k then begin writeln('YES'); writeln(ans); exit; end;\n end;\n writeln('NO');\nend."}, {"source_code": "Var i:longint;\n s,n,k:int64;\n begin\n read(n);\n read(k);\n s:=1;\n for i:=1 to 1000 do\n begin\n s:=s*n;\n if s=k then begin writeln('YES'); writeln(i-1); halt; end;\n if s>k then begin writeln('NO'); halt; end;\n end;\n end."}, {"source_code": "program project1;\n\nvar\n m,mw,n,d:int64;\n k:integer;\n w:integer;\n\nbegin\n readln(mw);\n readln(n);\n k:=5;\n d:=0;\n m:=mw;\n while k <>0 do begin\n if n = m then begin\n k:=0;\n w:=4;//YES\n end else begin\n m:=m*mw;\n d:=d+1;\n end;\n if m > n then begin\n k:=0;\n w:=5;//NO\n end;\n\n end;\n if w = 4 then begin\n writeln('YES');\n write(d);\n end else begin\n writeln('NO');\n end;\n\n readln;\n\nend.\n\n"}, {"source_code": "Var i:longint;\n n,k,s:int64;\n begin\n read(n);\n read(k);\n s:=1;\n for i:=1 to 10000 do\n begin\n s:=s*n;\n if s=k then begin writeln('YES'); writeln(i-1); halt; end;\n if s>k then begin writeln('NO'); halt end;\n end;\n end."}, {"source_code": "var a,b,c,d,n,k,i,l:int64;\nbegin\n\nreadln(k);\nreadln(l);\n\nd:=k;\ni:=0;\n\nwhile d*k<=l do\nbegin\nd:=d*k;\ni:=i+1;\nend;\n\nif d=l then begin writeln('YES'); writeln(i); end else writeln('NO');\n\nend.\n"}, {"source_code": "\nvar\n a,b,cn:int64;\n f:boolean;\nbegin\nread(a,b);\ncn:=0;\nf:=true;\nwhile (b>1)do\n begin\n if (b mod a<>0) then\n begin\n write('NO');\n f:=false;\n exit;\n end\n else\n b:=b div a;\n inc(cn);\n end;\nif f then begin write('YES'); writeln; write(cn-1); end;\nend.\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nvar\nk,n,st : int64;\ni : integer;\nbegin\nreadln (k);\nreadln (n);\ni:=0;\nst:=k;\nwhile k l then\n break;\n if k * c = l then\n begin\n writeln('YES');\n writeln(i);\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var\n s,n,m:qword;\n i,j:longint;\nbegin\n readln(n);\n readln(m);\n s:=1;\n for i:=1 to 10000005 do\n begin\n if s=m then begin writeln('YES');writeln(i-2);halt;end\n else if s>m then begin writeln('NO');halt;end;\n s:=s*n;\n end;\nend."}, {"source_code": "var\n n,m,i:longint;\n s:int64;\nbegin\n readln(n);\n readln(m);\n i:=1; s:=1;\n while s<>m do\n begin\n if s>m then \n begin\n writeln('NO');\n halt;\n end;\n s:=s*n;\n inc(i);\n end;\n writeln('YES');\n writeln(i-2);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n n,m,k,i : int64;\n p : boolean;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n readln(f,m);\n Close(f);\n k := 1;\n p := false;\n i := -1;\n repeat\n k := k*n;\n if k = m then p := true;\n inc(i);\n until (p = true) or (k > m);\n Assign(f,fo);\n rewrite(f);\n if p = true then\n Begin\n Writeln(f,'YES');\n Writeln(f,i);\n End\n else writeln(f,'NO');\n Close(f);\nEnd."}, {"source_code": "{$I-,O+,Q-,R-,S-}\n\nvar\n k, l, ans: integer;\nbegin\n readln(k); readln(l);\n\n repeat\n if l mod k <> 0 then begin write('NO'); exit; end;\n l := l div k;\n inc(ans);\n until l = 1;\n writeln('YES'); write(ans - 1);\nend.\n"}, {"source_code": "Var a,t,i,x:Int64;\n begin\n Read(a,x);\n t:=a;\n i:=1;\n While a=b then break;\n inc(ans);\n cur:=cur*a;\n end;\n\n if cur<>b then writeln('NO')\n else\n begin\n writeln('YES');\n writeln(ans);\n end;\n\nend."}, {"source_code": "label 1,2,3;\nvar\n i,n,m,t,k,l:longint;\n s:int64;\nbegin\n readln(k);\n readln(l);\n if l mod k<>0 then goto 3;\n s:=k;\n 1:\n if s=l then goto 2;\n if s>l then goto 3;\n s:=s*k;inc(i);\n goto 1;\n 2:writeln('YES');writeln(i);exit;\n 3:writeln('NO');\nend."}, {"source_code": "var\n k,l,x,n:longint;\n p:boolean;\nbegin\n readln(k);\n readln(l);\n x:=l;\n p:=true;\n while (x<>1) and p do\n begin\n inc(n);\n if x mod k<>0 then p:=false;\n x:=x div k;\n end;\n if p=false then writeln('NO')\n else begin writeln('YES'); writeln(n-1); end;\nend."}, {"source_code": "var k,l,i:longint;\nbegin\n readln(k);\n read(l);\n while l>0 do\n begin\n if l=1 then begin writeln('YES'); write(i-1); halt; end;\n if l mod k<>0 then begin write('NO'); halt; end;\n l:=l div k;\n i:=i+1;\n end;\nend."}, {"source_code": "program aaaaaa;\nvar i,x,l,k:uint64;\n\nbegin\n read(k,x);\n while x>k do\n begin\n if x mod k > 0 then begin writeln('NO'); halt; end;\n x:=x div k;\n i:=i+1;\n\n\n end;\n if x=k then begin writeln('YES'); writeln(i); halt; end;\n writeln('NO');\n\n\n\n\n\n\n\nend.\n"}, {"source_code": "var\n i,n,s,ansi:longint;\n lol:qword;\n ss:string;\n ok:boolean;\n begin\n read(n,s);\n ok:=false;\n i:=2;\n lol:=n;\n ansi:=0;\n for i:=2 to 100 do\n begin\n if lol=s then begin ansi:=i-2; ss:='YES'; break end\n else if lol>s then begin ss:='NO'; break; end\n else lol:=lol*n;\n end;\n if length(ss)=3 then\n begin\n writeln(ss);\n write(ansi);\n end\n else\n writeln(ss);\n end.\n"}, {"source_code": "var k, l, i:longint;\n bool:byte;\n x:real;\nbegin\n readln(k, l);\n x:=l;\n i:=0;\n bool:=0;\n while x>k do\n begin\n if (frac(x/k)=0) then begin\n i:=i+1;\n x:=x/k;\n end\n else begin\n bool:=1;\n break;\n end;\n end;\n if bool=0 then begin\n if x=k then begin\n writeln('YES');\n write(i)\n end\n else write('NO');\n end\n else write('NO');\nend."}, {"source_code": "var k, l, i:longint;\n bool:byte;\n x:real;\nbegin\n readln(k, l);\n {i:=0;\n x:=1;\n while xk do\n begin\n if (frac(x/k)=0) then begin\n i:=i+1;\n x:=x/k;\n end\n else begin\n bool:=1;\n break;\n end;\n end;\n if bool=0 then begin\n if x=k then begin\n writeln('YES');\n write(i)\n end\n else write('NO');\n {if (i=0)and(k<>x) then write('NO')\n else begin\n writeln('YES');\n write(i);\n end; }\n end\n else write('NO');\nend."}, {"source_code": "Program cifera;\nvar k,l,count:longint;\nbegin\n Readln(k); Readln(l);\n while(l mod k=0) do begin\n l:=l div k;\n Inc(count);\n End;\n If(count=0)or(l<>1) then Writeln('NO')\n Else begin\n Writeln('YES') ;\n Writeln(count-1);\n End;\nEnd.\n"}, {"source_code": "var\n k,l:longint;\n n:longint;\n tamp:qword;\n begin\n readln(k);\n readln(l);\n if l mod k<>0 then\n begin\n writeln('NO');\n halt;\n end;\n while l>0 do\n begin\n if (l=1) then\n begin\n writeln('YES');\n writeln(n-1); \n halt;\n end;\n if (l mod k<>0) then\n begin\n writeln('NO');\n halt;\n end;\n inc(n);\n l:=l div k;\n end;\n end.\n"}, {"source_code": "var\n i,k,l,sum:longint; bo:boolean;\n\nbegin\n readln(k);\n readln(l);\n sum:=1;\n if l mod k<>0 then\n begin\n writeln('NO');\n halt;\n end;\n bo:=true;\n while bo do\n begin\n sum:=sum*k;\n if l mod sum<>0 then\n begin\n writeln('NO');\n halt;\n end;\n inc(i);\n if sum=l then\n begin\n writeln('YES');\n writeln(i-1);\n break;\n end;\n if sum>l then\n begin\n writeln('NO');\n break;\n end;\n end;\nend."}, {"source_code": "var\n\tl,k,count\t:longint;\n\tcek\t: integer;\nbegin\n\treadln(k);\n\treadln(l);\n\t\n\tcek:=1;\n\twhile l>1 do\n\tbegin\n\t\tif (l mod k) <> 0 then\n\t\tcek:=0;\n\t\tcount:=count+1;\n\t\tl:=l div k;\n\tend;\n\t\n\tif cek=1 then\n\tbegin\n\t\twriteln('YES');\n\t\twriteln(count-1);\n\tend else\n\t\twriteln('NO');\nend."}, {"source_code": "var\n q,w,l:Int64;\nbegin\n Read(q,w);\n While (w mod q = 0)and(w<>0) do begin\n w:=w div q;\n Inc(l);\n //Writeln(w);\n end;\n if w = 1 then begin\n Writeln('YES'); \n Write(l-1); end else Write('NO');\n \nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n k,l,z,m : int64;\nbegin\n readln(k);\n readln(l);\n z:=k;m:=0;\n while(true)do\n begin\n if(z=l)then begin writeln('YES');writeln(m);halt(0);end;\n if(z>l)then begin writeln('NO');halt(0);end;\n inc(m);z:=int64(k*z);\n end;\n\nend."}, {"source_code": "Program cifera;\nVar k,l,i:Int64;\nBegin\n readln(k);\n readln(l);\n if ((l mod k)=0) \n then begin\n I:=0;\n While l>k do\n begin\n l:=l div k;\n Inc(I);\n end ; \n if l<>k\n then writeln('NO')\n else begin \n writeln('YES');\n writeln(I); \n end;\n end\n else writeln('NO');\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nk,n,o,z:int64;\nbegin\no:=1;\nreadln(k,n);\nz:=k;\nwhile kn then writeln('NO')\nelse\nbegin\nwriteln('YES');\nwriteln(o-1);\nend;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar k,k1,l,n:int64;\n\nbegin\nreadln(k);\nk1:=k;\nreadln(l);\nn:=0;\nwhile (k k then IsPossible := false;\n if IsPossible then\n begin\n writeln('YES');\n writeln(output);\n end else writeln('NO');\n end else writeln('NO');\nend."}, {"source_code": "program Project1_1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n k,l,ans:integer;\n\nbegin\n\n{eba one love}\n ans:=0;\n //assign (input, 'input.txt');\n //assign (output, 'output.txt');\n //reset (input);\n read (k,l);\n //close (input);\n //rewrite (output);\n while (l mod k = 0) do\n begin\n if (l=k) then\n begin\n writeln ('YES');\n write (ans);\n //close (output);\n halt (0);\n end\n else\n begin\n l:=l div k;\n inc (ans);\n end;\n end;\n writeln ('NO');\n //close (output);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\tn, k, ans : longint;\n\ti : int64;\n\nprocedure fuck();\nbegin\n\twrite('NO');\n\thalt(0);\nend;\n\t\nbegin \n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\tread(k, n);\n\tif n < k then fuck();\n\ti := k;\n\tans := 0;\n\twhile i < n do begin\n\t\ti := i * k;\n\t\tinc(ans);\n\tend; \t\n\tif i > n then fuck();\n\twriteln('YES');\n\twrite(ans);\nend.\n\n"}, {"source_code": "uses math;\nvar l, k: longint;\n e: real;\nbegin\n readln(k);\n readln(l);\n e := logn(k, l);\n if e = trunc(e) then\n begin\n writeln('YES');\n writeln(trunc(e) - 1);\n end\n else\n writeln('NO');\nend."}, {"source_code": "var r,k,s,n:longint;\nbegin\nreadln(k);\nreadln(s);\nr:=1;\nn:=0;\nif s>=k then begin\nwhile r<>10 do begin\nif s mod k=0 then begin\ns:=s div k;\nn:=n+1;\nend;\nif (s>1) and (s mod k>0) then begin\nn:=0;\nr:=10;\nend;\nif s=1 then r:=10;\nend;\nend;\nif n-1>=0 then begin\nwriteln('YES');\nwriteln(n-1);\nend;\nif n=0 then writeln('NO');\nreadln;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar k,l,n,ans:integer;\nbegin\nread(k,l); ans:=0;\nwhile true do\n begin\n if l mod k=0 then begin inc(ans); l:=l div k; if l=1 then begin writeln('YES'); writeln(ans-1); readln(n); halt; end; end\n else begin write('NO'); readln(n); halt; end;\n end;\n\nend.\n"}, {"source_code": "//da noi co dong nay roi ma\n{$MODE OBJFPC}\nvar\n k, l : int64; //ok?ok\n res : integer;\nbegin\n readln (k, l);\n //kt xem l co chia het cho k ko\n if l mod k <> 0 then\n begin\n write('NO');\n exit; //dung de thoat khoi chuong trinh. ok? tiep\n\n end;\n while l <> k do\n begin\n l := l div k; //moi lan nhu rua l div k. tuc la dec(mu)\n if l = 0 then\n begin\n write('NO');\n exit;\n end;\n //dung de loai truong hop 2 6 do :))\n //han se lap cho den khi l = 1; 1 div 2 = 0\n inc(res);\n end;\n\n writeln ('YES'); writeln (res);\nreadln;\nend.\n\nok?\nnop bai quai"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar k,l,t,i: int64;\n\nbegin\n read(k,l);\n i:=0;t:=k;\n while (t1 then write('NO')\n else\n begin\n writeln('YES');\n write(c-1);\n end;\nend."}, {"source_code": "uses\n SysUtils, Math;\n\nvar\n n, k, ans : longint;\n i : int64;\n\nprocedure fuck();\nbegin\n write('NO');\n halt(0);\nend;\n \nbegin \n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF}\n read(k, n);\n if n < k then fuck();\n i := k;\n ans := 0;\n while i < n do begin\n i := i * k;\n inc(ans);\n end; \n if i > n then fuck();\n writeln('YES');\n write(ans);\nend."}, {"source_code": "var k,l,p:integer;\nbegin\n readln(k,l);\n if l mod k<>0 then begin writeln('NO'); exit; end else\n while (l<>1) and (l<>0) do\n begin\n if (l=0) or (l mod k<>0) then begin writeln('NO'); exit; end;\n l:=l div k;\n inc(p);\n if l=1 then begin writeln('YES'); writeln(p-1); exit; end;\n end;\n if l=0 then begin writeln('NO'); exit; end;\n if l=1 then begin writeln('YES'); writeln(p-1); exit; end;\nend.\n\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a,b,x:int64;\n i:longint;\nbegin\n readln(a);\n readln(b);\n x:=a;\n for i:=1 to 10000 do\n begin\n if x>b then\n begin\n writeln('NO');\n break;\n end else\n if x=b then\n begin\n writeln('YES');\n writeln(i-1);\n break;\n end else x:=x*a;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k, l, c: integer;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'input.txt');\n readln(k, l);\n c := 0;\n while (l mod k = 0) and (l > 1) do\n begin\n inc(c);\n l := l div k;\n end;\n if (l = 1) then\n begin\n writeln('YES');\n writeln(c - 1);\n end\n else\n writeln('NO');\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "program a86;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,i,k:integer;\n\nbegin\n readln(a);\n readln(i);\n k:=0;\n while i mod a = 0 do begin\n i:=i div a;\n k:=k+1;\n end;\n if (k<>0) and (i=1) then begin\n writeln('YES');\n writeln(k-1);\n end else write('NO');\nend.\n"}, {"source_code": "{$R-, S-, Q-}\nprogram task_1;\nvar\n ans : boolean;\n k, l, r, count : Int64;\nbegin\n readln(k);\n readln(l);\n count := 0;\n r := k;\n while r < l do\n begin\n r := r * k;\n inc(count);\n end;\n if r=l then\n ans := true;\n if ans then\n begin\n writeln('YES');\n write(count);\n end\n else\n writeln('NO');\nend.\n\n"}, {"source_code": "uses\n SysUtils;\nvar\n tmp,k,n,m:Int64;\nbegin\n readln(n);\n Readln(m);\n k:=n;\n tmp:=0;\n while nm then write('NO') else begin\n Writeln('YES');\n write(tmp);\n end;\n readln;readln;\nend.\n"}, {"source_code": "var\nn,p:longint;\nj:int64;\ni:integer;\nbegin\n readln(n);\n readln(p);\n j:=n;\n while p>j do\n begin\n j:=n*j;\n inc(i);\n end;\n\n if j=p then begin writeln('YES'); write(i) end\n else write('NO');\n\nend."}, {"source_code": "var\n\tk, l, z: int64;\n\tu: longint;\n\nbegin\n\treadln(k, l);\n\tz := k;\n\tu := 0;\n\twhile k <= l do begin\n\t\tif k = l then begin\n\t\t\twriteln('YES');\n\t\t\twrite(u);\n\t\t\texit;\n\t\tend;\n\t\tk := k * z;\n\t\tinc(u);\n \tend;\n \twrite('NO');\nend."}, {"source_code": "program Cifera;\nvar k,l,i,c,s:int64;\nflag:boolean;\n\nbegin\nread(k);\nread(l);\ns:=k;\nc:=0;\nIf s=l then flag:=true;\nwhile (s=n;\n if s=n then \n begin \n writeln('YES'); \n writeln(j-1);\n end\n else writeln('NO');\nend."}, {"source_code": "program cifera;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k, l, st: longint;\n\nbegin\n { assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output); }\n\n read(k, l);\n st := 0;\n while (l mod k = 0) do\n begin\n l := l div k;\n inc(st);\n end;\n if l = 1 then\n begin\n writeln('YES');\n writeln(st - 1);\n end\n else\n writeln('NO');\n\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst nn=1024;eps=0.5; nnn=511; nnnn=9;\nlabel 1;\nvar s,p1,p2,imin,mmin,pp,p,tt,t,t1,imax,n,k,m,n1,k1,ot,a,b,c,d,k2,j0,ii,jj:int64;\n flag,flag1:boolean; pl:longint;\n dl,i,j,step:longint;\n ss:string;\n ott:array [0..10000] of int64 ;\n sp,nar :array[0..nn] of string;\n px,x,y:double;\n aa:array[0..nnn,0..20] of int64;\nch1,ch2,ch, chis:array[-10..10000] of int64;\n new1,new2, ss1,ss2:string;\n fl:array[0..nn] of boolean;\n\n\n function min(a,b:int64):int64;\nbegin min:=a;if ba then max:=b; end;\n\n\n\n\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output1234.txt');rewrite(output); }\nread(x,y);\n\nk:=round(ln(y)/ln(x));\npx:=1;\nfor i:=1 to k do px:=px*x;\nif px=y then begin writeln('YES'); writeln(k-1);end else writeln('NO') ;\n\n\n close (output);\nend.\n"}, {"source_code": "var\n n,k,count:int64;\nbegin\nreadln(n);\nreadln(k);\nif n = k then begin\n writeln('YES');\n writeln(0);\n exit;\nend;\n repeat\n if k mod n = 0 then begin\n k:=k div n;\n inc(count);\n end\n else begin\n writeln('NO');\n Exit;\nend;\n until k = 1;\nwriteln('YES');\nwriteln(Count-1);\nend."}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n k,l:int64;\n\n i,n,c:integer;\n t:boolean;\nbegin\n readln(k);\n n:=k;\n read(l);\n t:=true;\n c:=0;\n while k<>l do begin\n k:=k*n;\n inc(c);\n if k>l then begin\n t:=false;\n break;\n end;\n end;\n if t then begin\n writeln('YES');\n write(c);\n end\n else write('NO');\nend."}, {"source_code": "program cifera;\nvar k,l,v,n:longint;\n i:longint;\n\nbegin\nreadln(k);\nreadln(l);\nv:=0;\nn:=k;\nwhile k<=l div n do\nbegin\nk:=k*n;\ninc(v);\nend;\nif k=l then\nbegin\nwriteln('YES');\nwriteln(v);\nend else\nwriteln('NO');\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\nvar\n n, l, i, k: int64;\nbegin\n //reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n readln(n);\n readln(l);\n k := n;\n i := 0;\n if n > l then\n begin\n writeln('NO');\n exit;\n end;\n if (k = l) then\n begin\n writeln('YES');\n writeln('0');\n exit;\n end;\n while n <= l do\n begin\n n := n * k;\n inc(i);\n if n = l then\n begin\n writeln('YES');\n writeln(i);\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var k,i,n,m,p,j:int64;\nbegin\nreadln(k);\nreadln(n);\nm:=k;\nj:=0;\nwhile n>=k do begin\nif k=n then begin\n p:=1;\n n:=0;\n break;\n end;\nk:=k*m;\ninc(j);\nend;\nif p=1 then begin\n writeln('YES');\n write(j);\n end;\nif p<>1 then write('NO');\nend.\n\n"}, {"source_code": "var x,y,i,k:int64;\nBegin\n readln(x);\n readln(y);\n i:=0;\n k:=x;\n while x0 then writeln('NO');\nend;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a:array[1..1000000] of string;\n k,j,n,i:Integer;\n s:string;\n f:Int64;\nfunction lol(n,f:Integer):Integer;\nvar\n i,k,j:Integer;\nbegin\n k:=0;\n j:=n;\n for i:=1 to 100 do\n begin\n if (n=f) then Break;\n n:=n*j;\n inc(k);\n end;\n if (f=n) then lol:=k\n else lol:=0;\nend;\nbegin\n Readln(n);\n Readln(k);\n if (n>k) then\n begin\n if (lol(k,n)>0) then\n begin\n Writeln('YES');\n write(lol(k,n))\n end\n else write('NO')\n end else begin\n if (lol(n,k)>0) then\n begin\n Writeln('YES');\n write(lol(n,k))\n end\n else write('NO');\n end;\n Readln;\n Readln;\nend.\n "}, {"source_code": "var\n i,j,n,m,k,l:qword;\nbegin\n readln(k);\n readln(l);\n if k=l then begin writeln('NO'); halt ;end;\n while (kn then begin writeln('NO');exit; end;\n end;\n\n end."}, {"source_code": "var k,l,r:longint;\nbegin\n readln(k,l); r:=0;\n while (l mod k=0) do\n begin\n inc(r); l:=l div k;\n end;\n if (r>0) then\n begin\n writeln('YES'); writeln(r-1);\n end else writeln('NO');\nend."}, {"source_code": "\nvar\n k,l,v,j:int64;\n f:real;\nbegin\nread(k,l);\nv:=0;\nj:=2;\nwhile (j<=l)do\n begin\n f:=exp(j*ln(k));\n if (f<=l)then begin\n inc(v);\n end;\n inc(j);\n end;\n if v>=1 then begin write('YES'); writeln; write(v); end\n else write('NO');\nend.\n"}, {"source_code": "program zadanie12;\nvar a,k,l:real;\nbegin\nreadln(k);\nreadln(l);\na:=0;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nwhile l>k do\nbegin\nk:=k*k;\na:=a+1;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nend;\nif k<>l then writeln('NO');\nend."}, {"source_code": "Var n,k,j:int64;\n i:longint;\n begin\n Read(k,n);\n j:=k;\n if k=n then begin writeln('YES'); writeln(0); exit; end;\n for i:=1 to 100 do\n begin\n j:=j*k;\n writeln(k);\n if j=n then begin writeln('YES'); writeln(i); exit; end;\n if k>n then begin writeln('NO');exit; end;\n end;\n\n end."}, {"source_code": "var\n k,l:longint;\n n:longint;\n tamp:qword;\n begin\n readln(k);\n readln(l);\n if l mod k<>0 then\n begin\n writeln('NO');\n halt;\n end;\n while l>0 do\n begin\n if (l=1) then\n begin\n writeln('YES');\n halt;\n end;\n if (l mod k<>0) then\n begin\n writeln('NO');\n halt;\n end;\n inc(n);\n l:=l div k;\n end; \n end.\n"}, {"source_code": "var i,j,k,l,n,m,p,r,t:longint;\n\nbegin\n\n read(k,l);\n\n\n n:=k;\n while (n1) do\n n:=n*k;\n\n\n if(n=l)and(k<>l) then write('YES')\n else write('NO');\n\nend.\n"}, {"source_code": "var\n\tl,k\t:longint;\n\tcek\t: integer;\nbegin\n\treadln(k);\n\treadln(l);\n\t\n\tcek:=1;\n\twhile l>1 do\n\tbegin\n\t\tif (l mod k) <> 0 then\n\t\tcek:=0;\n\t\tl:=l div k;\n\tend;\n\t\n\tif cek=1 then\n\tbegin\n\t\twriteln('YES');\n\tend else\n\t\twriteln('NO');\nend."}, {"source_code": "const finp='';\n fout='';\nvar n,k,dem,LC:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,k,n);\n close(f);\nend;\n{---------------------}\nprocedure xuli;\nbegin\n LC:=0; dem:=0;\n while n>=k do\n begin\n if n mod k=0 then\n begin\n n:=n div k;\n inc(dem);\n end\n else\n begin\n LC:=1;\n break;\n end;\n end;\n if n=1 then\n LC:=1;\nend;\n{---------------------}\nprocedure xuat;\nvar g:text;\nbegin\n assign(g,fout);\n rewrite(g);\n if LC=0 then\n begin\n writeln(g,'YES');\n write(g,dem);\n end\n else\n writeln(g,'NO');\n close(g);\nend;\n{---------------------}\nbegin\n nhap;\n xuli;\n xuat;\nend.\n"}, {"source_code": "var\n i,j,n,m,k,l:int64;\nbegin\n readln(k,l);\n if k=l then begin\n writeln('YES');\n writeln(0);\n halt;\n end;\n while (kl then begin\n t:=true;\n break;\n end;\n end;\n if t=true then begin\n writeln('YES');\n write(K);\n end\n else write('NO');\n end."}, {"source_code": "{$I-,O+,Q-,R-,S-}\n\nvar\n k, l, ans: integer;\nbegin\n readln(k); readln(l);\n\n repeat\n if l mod k <> 0 then break;\n l := l div k;\n inc(ans);\n until l = 1;\n if ans = 0 then write('NO')\n else begin writeln('YES'); write(ans - 1); end;\nend.\n"}, {"source_code": "var i:integer;\nk,x,l:qWord;\nbegin\ni:=0;\nreadln(x);\nreadln(l);\nk:=x;\nwhile k a do begin\n b := b div a;\n inc(ans);\nend;\nif b = a then begin\n writeln('YES');\n writeln(ans);\nend\n else writeln('NO');\nend.\n"}, {"source_code": "Program p1;\nvar\nk,l,i,a:longint;\nlabel l1;\nbegin\nreadln(k);\nreadln(l);\ni:=0;a:=l;\nif k>l then writeln('NO') else\nbegin\nl1: if a=1 then\n begin\n writeln('YES');\n writeln(i-1);\n end\n else if ak then begin\nwhile r<10 do begin\nif s mod k=0 then begin\ns:=s div k;\nn:=n+1;\nend;\nif (s>k) and (s mod k>0) then begin\nn:=0;\nr:=10;\nend;\nif s=1 then r:=10;\nend;\nend;\nif n-1 > 0 then begin\nwriteln('YES');\nwriteln(n-1);\nend;\nif n-1<=0 then writeln('NO');\nreadln;\nend."}, {"source_code": "var x,y,i: int64;\n \nbegin\n i:=0; \n readln(x,y);\n repeat\n if y mod x <> 0 then \n begin\n writeln('NO');\n exit;\n end\n else\n y:=y div x;\n i:=i+1;\n until y<>x;\n writeln('YES');\n if i = 0 then writeln('NO') else writeln(i-1);\n end.\n "}, {"source_code": "var\n k,l:longint;\nbegin\n readln(k);\n readln(l);\n if trunc(sqrt(l))=sqrt(l) then \n begin\n writeln('YES');\n write(trunc(sqrt(l))-1);\n halt;\n end;\n write('NO');\nend."}, {"source_code": "var a,b,l,n:int64;\nbegin\n readln(a,b);\n l:=a;n:=1;\n while l l then\n begin\n writeln('NO');\n exit;\n end;\n if (k = l) then\n begin\n writeln('YES');\n writeln('0');\n end;\n while n <= l do\n begin\n n := n * k;\n inc(i);\n if n = l then\n begin\n writeln('YES');\n writeln(i);\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var k,l,r:longint;\nbegin\n readln(k,l); r:=0;\n while (l mod k=0) do\n begin\n inc(r); l:=l div k;\n end;\n if (r>1) then\n begin\n writeln('YES'); writeln(r-1);\n end else writeln('NO');\nend."}, {"source_code": "var\n t,k,l,i,j:integer;\nbegin\n readln(k);\n readln(l);\n if (l mod k<>0) or (ll then\n begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\n writeln(i-1);\nend."}, {"source_code": "var k, l, i:longint;\n bool:byte;\n x:real;\nbegin\n readln(k, l);\n {i:=0;\n x:=1;\n while xk do\n begin\n if (frac(x/k)=0) then begin\n i:=i+1;\n x:=x/k;\n end\n else begin\n bool:=1;\n break;\n end;\n end;\n if bool=0 then begin\n writeln('YES');\n write(i);\n end\n else write('NO');\nend."}, {"source_code": "program zadanie12;\nvar a,k,l:real;\nbegin\nreadln(k);\nreadln(l);\na:=0;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nwhile l>k do\nbegin\nk:=k*k;\na:=a+1;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nend;\nif k<>l then writeln('NO');\nend."}, {"source_code": "var k,l,p:integer;\nbegin\n readln(k,l);\n if l mod k<>0 then begin writeln('NO'); exit; end else\n while (l<>1) and (l<>0) do\n begin\n l:=l div k;\n inc(p);\n if l=0 then begin writeln('NO'); exit; end;\n if l=1 then begin writeln('YES'); writeln(p-1); exit; end;\n end;\n if l=0 then begin writeln('NO'); exit; end;\n if l=1 then begin writeln('YES'); writeln(p-1); exit; end;\nend.\n\n\n"}, {"source_code": "program FFFF;\n{�����}\n{$APPTYPE CONSOLE}\nuses\n SysUtils,Math;\nvar n,m,x,y,ans,i,j:integer;\n\n\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(n,m);\n while m>1 do begin\n if m mod n<>0 then begin\n write('NO');\n halt;\n end;\n inc(ans);\n m:=m div n;\n end;\n writeln('YES');\n write(ans-1);\n\nend.\n"}, {"source_code": "var\n n,z,g,n1:longint;\nbegin\n readln(n);\n readln(n1);\n g:=0;\n z:=n;\n while (z<=n1) do\n begin\n z:=z*n;\n inc(g);\n if z=n1 then\n begin\n writeln('YES');\n writeln(g);\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var a,b,c,d,f,j,k:int64;\ns:string;\ni,e:longint;\narr:array [1..1000] of longint;\nbegin\nread(a,b);\nfor i:=1 to (b div a) do begin\nif b=a then begin writeln('YES'); write(i-1); halt; end;\na:=a*a;\nend;\nwrite('NO');\nend.\n\n"}, {"source_code": "var i,j,k,l,n,m,p,r,t:longint;\n a,b:array[1..100] of integer;\n s,s1,s2,s3:string;\nbegin\n\n read(k,l);\n\n\n n:=k;\n m:=0;\n while (n1) do\n begin\n n:=n*k;\n inc(m);\n end;\n\n if(n=l)and(k<>l) then begin writeln('YES');write(m);end\n else write('NO');\n\nend.\n"}, {"source_code": "var a,b,l,n:int64;\nbegin\n readln(a,b);\n l:=a;n:=0;\n while ln then begin writeln('NO');exit; end;\n end;\n\n end."}, {"source_code": "var i:integer;\nk,l,m:int64;\nbegin\nread(k,l);\ni:=0;\nwhile l mod k =0 do\nbegin\nl:=l div k;\ninc(i)\nend;\nif l=1 then begin writeln('YES'); write(i) end else write('NO')\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar i,n,j:integer;\n k,l:int64;\n s:string;\nfunction pow(k:int64; m:integer):int64;\nvar ans,i:integer;\nbegin\nans:=1;\nfor i:=1 to m do\nans:=ans*k;\npow:=ans;\nend;\n\nbegin\nreadln(k,l);\nfor j:=1 to 100 do\n if pow(k,j)>l then begin writeln('NO'); halt; end\n else if pow(k,j)=l then begin writeln('YES'); writeln(j-1); readln; halt; end;\n\n\nend.\n"}, {"source_code": "program uio;\n var k,l,z,kol:int64;\n\nBEGIN\n\n readln(k);\n readln(l);\n z:=0; kol:=k;\n while true do\n begin\n kol:=kol*k; inc(z);\n if kol>l then begin writeln('NO'); halt; end;\n if kol=l then begin writeln('YES'); writeln(z); halt; end;\n end;\n\nEND."}, {"source_code": "var k,l,p:integer;\nbegin\n readln(k,l);\n if l mod k<>0 then begin writeln('NO'); exit; end\n else while (l<>1) and (l<>0) do\n begin\n l:=l div k;\n inc(p);\n if l=0 then begin writeln('NO'); exit; end;\n if l=1 then begin writeln('YES'); writeln(p/2); exit; end;\n end;\nend.\n"}, {"source_code": "var\n k, l: real;\n i: longint;\n \nbegin\n read(k, l);\n i := 0;\n while (trunc(l) <> trunc(k)) and (trunc(l) > 1) do\n begin\n l := l / k;\n l := round(l);\n inc(i);\n end;\n if Trunc(l) = trunc(k) then\n begin\n writeln('YES');\n writeln(i);\n end\n else\n writeln('NO');\nend."}, {"source_code": "var\n i,j,n,m,k,l:qword;\nbegin\n readln(k);\n readln(l);\n if k>l then begin k:=k+l; l:=k-l; k:=k-l; end;\n while (k 0 then break;\n l := l div k;\n inc(ans);\n until l = 1;\n if ans = 0 then write('NO')\n else begin writeln('YES'); write(ans - 1); end;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar i,n,j:integer;\n k,l:int64;\n s:string;\nfunction pow(k:int64; m:integer):int64;\nvar ans,i:integer;\nbegin\nans:=1;\nfor i:=1 to m do\nans:=ans*k;\npow:=ans;\nend;\n\nbegin\nreadln(k,l);\nfor j:=1 to 100 do\n if pow(k,j)>l then begin writeln('NO'); halt; end\n else if pow(k,j)=l then begin writeln('YES'); writeln(j-1); readln; halt; end;\n\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x,y,k:integer;\n\nprocedure dar(x,y:integer);\n begin\n if y mod x = 0 then\n begin\n y:=y div x;\n k:=k+1;\n if y>x then dar(x,y)\n end\n else\n write('NO');\n end;\n\nbegin\n readln(x);\n readln(y);\n dar(x,y);\n if(k>0) then begin\n writeln('YES');\n writeln(k);\n end;\n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var\n i,j,n,m,k,l:int64;\nbegin\n readln(k,l);\n if ((k=0)and(l=0))or((k=1)and(l=1)) then begin\n writeln('YES');\n writeln(0);\n halt;\n end\n else if ((k=0))or((k=1)) then begin halt; writeln('NO'); end;\n while (k0 do\n begin\n if m=1 then begin writeln('YES');writeln(o);halt;end;\n if (m mod n)<>0 then begin writeln('NO');halt;end;\n inc(o);\n m:=m div n;\n end;\nend."}, {"source_code": "program cf114a;\nvar\n k,l,m:int64;\n \nbegin\n readln(k);\n readln(l);\n m:=0;\n while (k<=l) do begin\n \n if (l mod k=0) then begin\n l:=l div k;\n \n if (l=1) or (l=k) then begin\n writeln('YES');\n if l=k then m:=m+1;\n writeln(m);\n break;\n end else begin\n m:=m+1;\n end;\n end else begin\n writeln('NO');\n break;\n end;\n \n end; \nend.\n"}, {"source_code": "program zzz;\nvar i,n,a,b,x:word;\nbegin\n read(n);\n for i:=1to n do\n begin\n read(x);\n if odd(x)then inc(a)\n else inc(b)\n end;\n if odd(a)then write(a)\n else write(b);\nend."}, {"source_code": "var n,i,m:longint;\nbegin\n readln(n);\n readln(m);\n while n<=m do\n begin\n n:=n*n;\n inc(i);\n if m=n then break;\n end;\n if m=n then begin writeln('YES'); writeln(i);end\n else writeln('NO')\nend."}, {"source_code": "var k,x,l:longint;\n i:integer;\nbegin\nreadln(k);\nreadln(x);\nl:=k;\ni:=0;\nwhile x>=k do\n begin\n writeln(k);\n if x=k then\n begin\n writeln ('YES');\n writeln (i);\n exit;\n end;\n k:=k*l;\n i:=i+1;\n end;\nwriteln('NO');\nend.\n"}, {"source_code": "var r,k,s,n:longint;\nbegin\nreadln(k);\nreadln(s);\nr:=1;\nif s>k then begin\nwhile r<10 do begin\nif s mod k=0 then begin\ns:=s div k;\nn:=n+1;\nend;\nif (s>k) and (s mod k>0) then begin\nn:=0;\nr:=10;\nend;\nif s=1 then r:=10;\nend;\nend;\nif n-1 > 0 then begin\nwriteln('YES');\nwriteln(n-1);\nend;\nif n-1<=0 then writeln('NO');\nreadln;\nend."}, {"source_code": "var\n a,s,d:int64;\nbegin\n read(a,s);\n while a=b);\nif k=b then\n begin\n writeln ('YES');\n writeln (i);\n end\nelse\n writeln ('NO');\nclose (input);\nclose (output);\nend."}, {"source_code": "var\n x,y,n,s:longint;\n p:boolean;\nbegin\n readln(x);\n readln(y);\n n:=1;\n s:=1;\n while (s*x<=y) and (p=false) do \n begin\n inc(n);\n s:=s*x;\n if s=y then p:=true;\n end;\n if p then begin writeln('YES'); writeln(n-1); end\n else writeln('NO');\nend."}, {"source_code": "var i,j,k,n,m,p,r,t,l:longint;\n a,b:array[1..100] of integer;\n s,s1,s2,s3:string;\nbegin\n\n readln(k);\n read(l);\n\n\n n:=1;\n m:=0;\n t:=1;\n for i:=1 to 31 do\n begin\n n:=n*k;\n if l=n then begin writeln('YES');write(m);inc(t);break end;\n if n>l then break;\n inc(m);\n end;\n if t=1 then write('NO');\n\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\nvar\n n, l, i: longint;\nbegin\n //reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n readln(n);\n readln(l);\n i := 0;\n while n <= l do\n begin\n n := n * l;\n inc(i);\n if n = l then\n begin\n writeln('YES');\n writeln(i);\n exit;\n end;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k, l, i, l1 : int64;\n\nbegin\n\n read(l, k);\n\n if (l = 1) and (k = 1) then begin\n writeln('YES');\n writeln(0);\n halt;\n end;\n\n if (l = 1) and (k = -1) then begin\n writeln('YES');\n writeln(2);\n halt;\n end;\n\n if l = k then begin\n writeln('NO');\n halt;\n end;\n\n l1 := l;\n i := 0;\n while (l < k) and (i < 1000) do begin\n l := l * l1;\n inc(i);\n end;\n\n if l = k then begin\n writeln('YES');\n writeln(i);\n readln;readln;\n halt;\n end;\n\n writeln('NO');\n readln;readln;\n\nend.\n "}, {"source_code": "var l,i:integer;\nk:qWord;\nbegin\ni:=0;\nreadln(k);\nreadln(l);\nwhile k m);\n Assign(f,fo);\n rewrite(f);\n if p = true then\n Begin\n Writeln(f,'YES');\n Writeln(f,i);\n End\n else writeln(f,'NO');\n Close(f);\nEnd."}, {"source_code": "var\nk,l,i:int64;\nfunction binpow(a,n:integer): int64;\nbegin\nif (n=0) then binpow:=1 else\n if odd(n) then binpow:=binpow(a,n-1)*a else\n binpow:=binpow(a,n div 2)*binpow(a,n div 2);\nend;\n\nbegin\nread(k,l); i:=0;\nwhile (k<=l) do begin\n if (l mod k <> 0) then begin writeln('NO'); exit; end;\n if (l = k) then begin writeln('YES'); writeln(i); exit; end;\n k:=k*k; inc(i);\n end;\nwriteln('NO');\nend."}, {"source_code": "var a,b,c,d,f,j,k:int64;\ns:string;\ni,e:longint;\narr:array [1..1000] of longint;\nbegin\nread(a,b);\nfor i:=1 to b do begin\nif b=a then begin writeln('YES'); write(i-1); halt; end;\na:=a*a;\nend;\nwrite('NO');\nend.\n\n"}, {"source_code": "program zadanie12;\nvar a,k,l:real;\nbegin\nreadln(k);\nreadln(l);\na:=0;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nwhile l>k do\nbegin\nk:=k*k;\na:=a+1;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nend;\nif k<>l then writeln('NO');\nend."}, {"source_code": "var x,y,i: int64;\n \nbegin\n i:=0; \n readln(x,y);\n repeat\n if y mod x <> 0 then \n begin\n writeln('NO');\n exit;\n end\n else\n y:=y div x;\n i:=i+1;\n until y<>x;\n writeln('YES');\n if i = 0 then writeln('0') else writeln(i-1);\n end.\n "}, {"source_code": "Var osn,ch,step:longint;\nbegin\nread(osn);\nreadln(ch);\nwhile (ch div osn<>1) and\n(ch mod osn=0) do begin\nstep:=step+1;\nch:=ch div osn;\nend;\nif (step=0) and\n(ch<>1) then writeln('NO') else begin writeln('YES');\nwriteln(step); end;\nend.\n"}, {"source_code": "Var i,a,b,a1:longint;\nbegin\nreadln(a,b);\ni:=0;\na1:=a;\nwhile (a<>b) and (b>a) do begin\ni:=i+1;\na:=a*a1;\nif a=b then begin writeln('YES'); writeln(i); exit; end;\nend;\nwriteln('NO');\nend."}, {"source_code": "Var i,a,b,a1:longint;\nbegin\nreadln(a,b);\ni:=0;\na1:=a;\nwhile (a<>b) and (b>a) do begin\ni:=i+1;\na:=a*a1;\nif a=b then begin writeln('YES'); writeln(i); exit; end;\nend;\nwriteln('NO');\nend."}, {"source_code": "program cifera;\nvar\nk,l,md,f : integer;\nla,i,n : integer;\nbegin\n readln(k);\n readln(l);\n md:= l mod k;\n\n la:= -1 ;\n \n if md = 0 then\n begin\n while l <> 1 do\n begin\n l:= l div k;\n la:= la + 1;\n\n end;\n writeln('YES');\n writeln(la)\n end\n else\n writeln('NO');\nend."}, {"source_code": "var k,l:longint;\nbegin\n read(k,l);\n while l mod k=0 do l:=l div k;\n if l=1 then write('YES')else write('NO');\nend."}, {"source_code": "var k,x,l:longint;\n i:integer;\nbegin\nreadln(k);\nreadln(x);\nl:=k;\ni:=0;\nwhile x>=k do\n begin\n writeln(k);\n if x=k then\n begin\n writeln ('YES');\n writeln (i);\n exit;\n end;\n k:=k*l;\n i:=i+1;\n end;\nwriteln('NO');\nend.\n"}, {"source_code": "program cf114a;\nvar\n k,l,m:int64;\n \nbegin\n readln(k);\n readln(l);\n m:=0;\n if k<=l then begin\n while (k<=l) do begin\n \n if (l mod k=0) then begin\n l:=l div k;\n \n if (l=1) or (l=k) then begin\n writeln('YES');\n if l=k then m:=m+1;\n writeln(m);\n exit;\n end else begin\n m:=m+1;\n end;\n end else begin\n writeln('NO');\n exit;\n end;\n \n end; \n end else writeln('NO');\nend.\n"}, {"source_code": "var k, l, ans, a : int64;\nbegin\n readln(k,l);\n a := k;\n ans := 1;\n while a < l do\n begin\n if a * a <= l then begin a := a * a; ans := ans * 2; end\n else a := a * k;\n end;\n if a = l then begin\n writeln('YES');\n writeln(ans - 1);\n end else writeln('NO');\nend."}, {"source_code": "var k,x,i,l:longint;\nbegin\nreadln(k);\nreadln(x);\ni:=0;\nl:=k;\nwhile (k*l)<=x+1 do\nbegin\nk:=k*l;\ni:=i+1;\nif k=x then begin writeln('YES'); writeln(i); k:=0; break; end;\nend;\nif k<>0 then writeln('NO');\nend.\n"}, {"source_code": "program zadacha1;\nvar k,l:longint; x:integer;\nbegin\n{\nassign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output);\n}\nreadln(k);\nreadln(l);\n\nif l mod k<>0 then write('NO');\n\nx:=0;\nwhile k= k do begin\ni:=i+1;\nif l mod k <> 0 then begin s:=1;l:=l div k end else\nl:=l div k\nend;\nif s <> 1 then if l = k then begin\nwriteln('YES');\nwrite(i)\nend else write('NO') else write('NO')\nend."}, {"source_code": "Uses math;\n\nvar\n K, L: int64;\n e: double;\n \nbegin\n\n readln(K, L);\n \n if (K = 1) then begin\n if (L = 1) then begin \n writeln('YES');\n writeln(0);\n end else \n writeln('NO');\n end else begin\n \n e := ln(L)/ln(K);\n \n if (ABS(ceil(e) - e) < 0.0000001) then begin\n writeln('YES');\n writeln(ceil(e) - 1);\n end else \n writeln('NO');\n end;\nend."}, {"source_code": "var x,y,i: int64;\n \nbegin\n i:=0; \n readln(x,y);\n repeat\n if y mod x <> 0 then \n begin\n writeln('NO');\n exit;\n end\n else\n y:=y div x;\n i:=i+1;\n until y<>x;\n if i < 2 then writeln('NO') else begin \n writeln('YES');\n writeln(i-1);\n end;\n end.\n "}, {"source_code": "var x,y,i: int64;\n \nbegin\n i:=0; \n readln(x,y);\n repeat\n if y mod x <> 0 then \n begin\n writeln('NO');\n exit;\n end\n else\n y:=y div x;\n i:=i+1;\n until y<>x;\n if i < 2 then writeln('NO') else begin \n writeln('YES');\n writeln(i-1);\n end;\n end.\n "}, {"source_code": "Var a,b,i:longint;\nBegin\nreadln(a,b);\ni:=0;\nwhile (b>a) do\nbegin\ni:=i+1;\na:=a*a;\nif a=b then begin\n writeln('YES');\n writeln(i);\n exit;\n end;\nend;\nwriteln('NO');\nend.\n"}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k, l, i, l1 : int64;\n\nbegin\n\n read(l, k);\n {\n if (l = 1) and (k <> 1) then begin\n writeln('YES');\n writeln(0);\n halt;\n end;}\n\n if l = k then begin\n writeln('NO');\n halt;\n end;\n\n l1 := l;\n i := 0;\n while (l < k) and (i < 1000) do begin\n l := l * l1;\n inc(i);\n end;\n\n if l = k then begin\n writeln('YES');\n writeln(i);\n readln;readln;\n halt;\n end;\n\n writeln('NO');\n readln;readln;\n\nend.\n "}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k, l, i, l1 : int64;\n\nbegin\n\n read(l, k);\n\n if (k < l) then begin\n writeln('NO');\n readln;readln;\n halt;\n end;\n\n if (l = 1) and (k = 1) then begin\n writeln('YES');\n writeln(1);\n readln;readln;\n halt;\n end;\n\n if (l = -1) and (k = -1) then begin\n writeln('YES');\n readln;readln;\n writeln(2);\n halt;\n end;\n\n if l = k then begin\n writeln('NO');\n readln;readln;\n halt;\n end;\n\n l1 := l;\n i := 0;\n while (l < k) and (i < 1000) do begin\n l := l * l1;\n inc(i);\n end;\n\n if l = k then begin\n writeln('YES');\n writeln(i);\n readln;readln;\n halt;\n end;\n\n writeln('NO');\n readln;readln;\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a:array[1..1000000] of string;\n k,j,n,i:Integer;\n s:string;\n f:Int64;\nfunction lol(n,f:Integer):Integer;\nvar\n i,k,j:Integer;\nbegin\n k:=0;\n j:=n;\n for i:=1 to 100 do\n begin\n if (n=f) then Break;\n n:=n*j;\n inc(k);\n end;\n if (f=n) then lol:=k\n else lol:=0;\nend;\nbegin\n Readln(n);\n Readln(k);\n if (lol(n,k)>0) then write(lol(n,k))\n else write('NO');\n Readln;\n Readln;\nend.\n "}, {"source_code": "var n,i,m:longint;\nbegin\n readln(n);\n readln(m);\n while n<=m do\n begin\n n:=n*n;\n inc(i);\n if m=n then break;\n end;\n if m=n then begin writeln('YES'); writeln(i);end\n else writeln('NO')\nend."}, {"source_code": "var x,y,i: longint;\n \nbegin\n readln(x,y);\n repeat\n if y mod x <> 0 then \n begin\n writeln('NO');\n exit;\n end\n else\n y:=y div x;\n i:=i+1;\n until y<>x;\n writeln('YES');\n writeln(i);\n end.\n "}, {"source_code": "var a,b,l,n:int64;\nbegin\n readln(a,b);\n l:=a;n:=1;\n while ls do\nbegin\nif s<>l then\nbegin\ns:=s*k;\ninc(count);\nend\nelse\nbegin\nwriteln('YES');\nwriteln(count);\nexit;\nend;\nend;\nwriteln('NO');\nend.\n "}, {"source_code": "var\n k,l:longint;\nbegin\n readln(k);\n readln(l);\n if trunc(sqrt(l))=sqrt(l) then \n begin\n writeln('YES');\n write(trunc(sqrt(l))-1);\n halt;\n end;\n write('NO');\nend."}, {"source_code": "var k,l,t:int64;\nbegin\n readln(k);\n readln(l);\n if l mod k<>0 then begin writeln('NO');exit;end;\n t:=0;\n while l>k do begin\n if l mod k =0 then begin t:=t+1;l:=l div k;end else\n begin writeln('NO');exit;end;end;\n writeln('YES');\n writeln(t);\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,k,l,count:integer;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\nreadln(k);\nreadln(l);\ns:=k;\nwhile l*l>s do\nbegin\nif s<>l then\nbegin\ns:=s*k;\ninc(count);\nend\nelse\nbegin\nwriteln('YES');\nwriteln(count);\nexit;\nend;\nend;\nwriteln('NO');\nend.\n "}, {"source_code": "var\n i,j,n,m,k,l:int64;\nbegin\n readln(k);\n readln(l);\n while (l>k) do\n begin\n l:=l div 5;\n inc(m);\n end;\n if (l=k) then begin\n writeln('YES');\n writeln(m);\n end\n else writeln('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a:array[1..1000000] of string;\n k,j,n,i:Integer;\n s:string;\n f:Int64;\nfunction lol(n,f:Integer):Integer;\nvar\n i,k,j:Integer;\nbegin\n k:=0;\n j:=n;\n for i:=1 to 100 do\n begin\n if (n=f) then Break;\n n:=n*j;\n inc(k);\n end;\n if (f=n) then lol:=k\n else lol:=0;\nend;\nbegin\n Readln(n);\n Readln(k);\n if (n>k) then\n begin\n if (lol(k,n)>0) then\n begin\n Writeln('YES');\n write(lol(k,n))\n end\n else write('NO')\n end else begin\n if (lol(n,k)>0) then\n begin\n Writeln('YES');\n write(lol(n,k))\n end\n else write('NO');\n end;\n Readln;\n Readln;\nend.\n "}, {"source_code": "var k,x,i,l:longint;\nbegin\nreadln(k);\nreadln(x);\ni:=0;\nif k=x then writeln('NO')\nelse\nbegin\nl:=k;\nwhile (k*l)<=x+1 do\nbegin\nk:=k*l;\ni:=i+1;\nif k=x then begin writeln('YES'); writeln(i); k:=0; break; end;\nend;\nif k<>0 then writeln('NO');\nend;\nreadln;\nend.\n"}, {"source_code": "var s, i, k, l: integer;\nbegin\nreadln(k);\nreadln(l);\nwhile (l div k) >= k do begin\ni:=i+1;\nif l mod k <> 0 then begin s:=1;l:=l div k end else\nl:=l div k\nend;\nif s <> 1 then if l = k then begin\nwriteln('YES');\nwrite(i)\nend else write('NO') else write('NO')\nend."}, {"source_code": "var i,j,k,l,n,m,p,r,t:longint;\n\nbegin\n\n read(k,l);\n\n\n n:=k;\n while (n1) do\n n:=n*k;\n\n\n if(n=l)and(k<>l) then write('YES')\n else write('NO');\n\nend.\n"}, {"source_code": "program zadanie12;\nvar a:integer; k,l:real;\nbegin\nreadln(k);\nreadln(l);\na:=0;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nwhile l>k do\nbegin\nk:=k*k;\na:=a+1;\nif k=l then\nbegin\nk:=l;\nwriteln('YES');\nwriteln(a);\nend;\nend;\nif k<>l then writeln('NO');\nend."}], "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46"} {"source_code": "uses math;\ntype pair = record\nl:longint;\nr:longint;\nend;\nvar f1,f2:text;\na,b,l,r:longint;\n\nfunction mp(u,v:longint):pair;begin mp.l:=u;mp.r:=v;end;\n\nFunction process(a,b,l,r:longint;k:longint):longint;\nvar i,j:longint;\nvt:longint;\nres:longint;\nt1,t2:array[1..2] of pair;\nbegin\n if k=0 then exit(0);\n if (a>b) or (l>r) then exit(0);\n res:=0;\n if max(a,l)<=min(b,r) then res:=min(r,b)-max(a,l)+1;\n if ((a<=l) and (r<=b)) or ((l<=a) and (b<=r)) then exit(res);\n vt:=1 shl (k-1);\n if vt=a then inc(a);if vt=b then dec(b);if vt=l then inc(l);if vt=r then dec(r);\n t1[1]:=mp(a,min(b,vt-1));\n t1[2]:=mp(max(a,vt+1)-vt,b-vt);\n t2[1]:=mp(l,min(r,vt-1));\n t2[2]:=mp(max(l,vt+1)-vt,r-vt);\n for i:=1 to 2 do\n for j:=1 to 2 do\n res:=max(res,process(t1[i].l,t1[i].r,t2[j].l,t2[j].r,k-1));\n process:=res;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(F1,a,b,l,r);\n writeln(f2,Process(a,b,l,r,30));\n close(f1);\n close(f2);\nend.\n", "positive_code": [{"source_code": "program cf161c;\nvar\n x,y,l,r:longint;\nfunction max(a,b:longint):longint;\nbegin if a>b then max:=a else max:=b end;\nfunction deal(x,y,l,r,k:longint):longint;\nvar m:longint;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(deal(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(deal(x,y,l-m,r-m,k));\n if rb then max:=a else max:=b end;\nfunction deal(x,y,l,r,k:longint):longint;\nvar m:longint;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(deal(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(deal(x,y,l-m,r-m,k));\n if rb) or (l>r) then exit(0);\n res:=0;\n if max(a,l)<=min(b,r) then res:=min(r,b)-max(a,l)+1;\n if ((a<=l) and (r<=b)) or ((l<=a) and (b<=r)) then exit(min(r,b)-max(a,l)+1);\n vt:=1 shl (k-1);\n if vt=a then inc(a);if vt=b then dec(b);if vt=l then inc(l);if vt=r then dec(r);\n t1[1]:=mp(a,min(b,vt-1));\n t1[2]:=mp(max(a,vt+1)-vt,b-vt);\n t2[1]:=mp(l,min(r,vt-1));\n t2[2]:=mp(max(l,vt+1)-vt,r-vt);\n for i:=1 to 2 do\n for j:=1 to 2 do\n res:=max(res,process(t1[i].l,t1[i].r,t2[j].l,t2[j].r,k-1));\n process:=res;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(F1,a,b,l,r);\n writeln(f2,Process(a,b,l,r,30));\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "type z=longint;\nvar x,y,l,r:z;\nfunction o(a,b:z):z;\nbegin if a>b then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb) or (l>r) then exit(0);\n res:=0;\n if max(a,l)<=min(b,r) then res:=min(r,b)-max(a,l)+1;\n if ((a<=l) and (r<=b)) or ((l<=a) and (b<=r)) then exit(res);\n vt:=1 shl (k-1);\n if vt=a then inc(a);\n if vt=b then dec(b);\n if vt=l then inc(l);\n if vt=r then dec(r);\n t1[1]:=mp(a,min(b,vt-1));\n t1[2]:=mp(max(a,vt+1)-vt,b-vt);\n t2[1]:=mp(l,min(r,vt-1));\n t2[2]:=mp(max(l,vt+1)-vt,r-vt);\n for i:=1 to 2 do\n for j:=1 to 2 do\n res:=max(res,process(t1[i].l,t1[i].r,t2[j].l,t2[j].r,k-1));\n process:=res;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(F1,a,b,l,r);\n writeln(f2,Process(a,b,l,r,30));\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "var\nans:longint;\n\nfunction min(x,y:longint):longint; begin if xy then exit(x) else exit(y); end;\nprocedure update(var x:longint; const y:longint); begin if y>x then x:=y; end;\n\nprocedure dfs(l,r,l1,r1,l2,r2:longint);\nvar mid,midlen:longint; flag:boolean;\nbegin if l1=l2 then\n\tbegin update(ans,min(r1,r2)-l1+1);\n\t\texit;\n\tend;\n\tif r1=r2 then\n\tbegin update(ans,r1-max(l1,l2)+1);\n\t\texit;\n\tend;\n\t\n\tmid:=(l+r)>>1; midlen:=(r-l)>>1+1; flag:=false;\n\tif (l1<=mid)and(mid<=r1)and(l2<=mid)and(mid<=r2) then begin update(ans,min(r1,r2)-max(l1,l2)+1); flag:=true; end;\n\tif l1mid then dfs(l,mid-1,l1,min(mid-1,r1),max(mid+1,l2)-midlen,r2-midlen);\n\tend;\n\tif r1>mid then\n\tbegin if l2mid) then dfs(mid+1,r,max(mid+1,l1),r1,max(mid+1,l2),r2);\n\tend;\nend;\n\nprocedure lemon;\nvar l1,r1,l2,r2:longint;\nbegin readln(l1,r1,l2,r2);\n\tans:=0;\n\tdfs(1,1<<30-1,l1,r1,l2,r2);\n\twriteln(ans);\nend;\n\nbegin\nlemon;\nend."}, {"source_code": "type z=longint;\nvar x,y,l,r:z;\nfunction o(a,b:z):z;\nbegin if a>b then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if ry then exit(x) else exit(y); end;\nprocedure update(var x:longint; const y:longint); begin if y>x then x:=y; end;\n\nprocedure dfs(l,r,l1,r1,l2,r2:longint);\nvar mid,midlen:longint; flag:boolean;\nbegin if l1=l2 then\n\tbegin update(ans,min(r1,r2)-l1+1);\n\t\texit;\n\tend;\n\tif r1=r2 then\n\tbegin update(ans,r1-max(l1,l2)+1);\n\t\texit;\n\tend;\n\t\n\tmid:=(l+r)>>1; midlen:=(r-l)>>1+1; flag:=false;\n\tif (l1<=mid)and(mid<=r1)and(l2<=mid)and(mid<=r2) then begin update(ans,min(r1,r2)-max(l1,l2)+1); flag:=true; end;\n\tif l1mid then dfs(l,mid-1,l1,min(mid-1,r1),max(mid+1,l2)-midlen,r2-midlen);\n\tend;\n\tif r1>mid then\n\tbegin if l2mid)and(not flag) then dfs(mid+1,r,max(mid+1,l1),r1,max(mid+1,l2),r2);\n\tend;\nend;\n\nprocedure lemon;\nvar l1,r1,l2,r2:longint;\nbegin readln(l1,r1,l2,r2);\n\tans:=0;\n\tdfs(1,1<<30-1,l1,r1,l2,r2);\n\twriteln(ans);\nend;\n\nbegin\nlemon;\nend."}, {"source_code": "type z=longint;\nvar x,y,l,r:z;\nfunction o(a,b:z):z;\nbegin if a>b then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rans then ans:=x;\nend;\nfunction min(a,b:longint):longint;\nbegin\n if ab then exit(a) else exit(b);\nend;\nprocedure solve(s,l1,r1,l2,r2:longint);\nvar f1,f2:boolean;\n tmp,g1,g2:longint;\nbegin\n if (l1>r1) or (l2>r2) then exit;\n upd(min(r1,r2)-max(l1,l2)+1);\n if (l1<=l2) and (r2<=r1) or (l2<=l1) and (r1<=r2) then exit;\n tmp:=1 shl s;\n f1:=(l1<=tmp) and (tmp<=r1);\n f2:=(l2<=tmp) and (tmp<=r2);\n if (not f1) and (not f2) then\n solve(s-1,l1 mod tmp,r1 mod tmp,l2 mod tmp,r2 mod tmp);\n if f1 and (not f2) then\n begin\n solve(s-1,l1,tmp-1,l2 mod tmp,r2 mod tmp);\n solve(s-1,1,r1-tmp,l2 mod tmp,r2 mod tmp);\n end;\n if (not f1) and f2 then\n begin\n solve(s-1,l1 mod tmp,r1 mod tmp,l2,tmp-1);\n solve(s-1,l1 mod tmp,r1 mod tmp,1,r2-tmp);\n end;\n if f1 and f2 then\n begin\n solve(s-1,l1,tmp-1,1,r2-tmp);\n solve(s-1,1,r1-tmp,l2,tmp-1);\n end;\nend;\nbegin\n readln(l1,r1,l2,r2);\n solve(29,l1,r1,l2,r2);\n writeln(ans);\nend.\n end;"}, {"source_code": "type z=longint;\nvar x,y,l,r:z;\nfunction o(a,b:z):z;\nbegin if a>b then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then o:=a else o:=b end;\nfunction d(x,y,l,r,k:z):z;\nvar m:z;\nbegin\n m:=1 shl k;\n if (l>r)or(x>y) then exit(0);\n if (ly) then exit(d(l,r,x,y,k));\n if y>=r then exit(r-l+1);\n if l>m then exit(d(x,y,l-m,r-m,k));\n if rb then exit(a) else exit(b);\n end;\n\nfunction min(a,b:longint):longint;\n begin\n if al2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n //writeln(l1,' ',r1,' ',l2,' ',r2,' ',ans);\n e:=min(r1,r2)-max(l1,l2)+1;\n if e>ans then ans:=e;\n mid:=(len+1)>>1;\n if (l2<=mid) and (mid<=r1) then\n doit(1,r2-mid,l1,mid-1,len div 2)\n else\n if r2mid then\n doit(l1-mid,r1-mid,l2-mid,r2-mid,len div 2)\n else\n if l2<=mid then\n begin\n doit(l1,r1,l2,mid-1,len div 2);\n doit(l1,r1,1,r2-mid,len div 2);\n end\n else\n if r1>=mid then\n begin\n doit(l1,mid-1,l2-mid,r2-mid,len div 2);\n doit(1,r1-mid,l2-mid,r2-mid,len div 2);\n end\n else\n doit(l1,r1,l2-mid,r2-mid,len div 2);\n end;\n\nbegin\n readln(l1,r1,l2,r2);\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n ans:=0;\n doit(l1,r1,l2,r2,1<<30-1);\n writeln(ans);\nend.\n"}, {"source_code": "uses\n math;\nvar\n l1,r1,l2,r2,ans:longint;\n \n procedure solve(x,l1,r1,l2,r2:longint);\n var\n cr,t:longint;\n begin\n if (l1>=l2)and(r1<=r2)then begin\n cr:=r1-l1+1;\n if (cr>ans)then ans:=cr;\n exit;\n end;\n if (l2>=l1)and(r2<=r1)then begin\n cr:=r2-l2+1;\n if (cr>ans)then ans:=cr;\n exit;\n end;\n if (x=0)then exit;\n t:=1 shl (x-1);\n if (l1<=t)and(l2<=t)and(r1>=t)and(r2>=t)then begin\n cr:=min(r1,r2)-max(l1,l2)+1;\n if (cr>ans)then ans:=cr;\n end;\n if (l1t)and(r2>t)then solve(x-1,max(l1,t+1)-t,r1-t,max(l2,t+1)-t,r2-t);\n if (l1t)then solve(x-1,l1,min(t-1,r1),max(t+1,l2)-t,r2-t);\n if (r1>t)and(l2b then exit(a) else exit(b);\nend;\n//======================================================================\nprocedure Work(p,l1,r1,l2,r2:longint);\nvar tmp,a1,a2,b1,b2,c1,c2,d1,d2:longint;\nbegin\n if (l1>r1)or(l2>r2)then exit;\n tmp:=min(r1,r2)-max(l1,l2)+1;\n if tmp>ans then ans:=tmp;\n if (l1<=l2)and(r2<=r1) or (l2<=l1)and(r1<=r2)then exit;\n tmp:=1<r2\n then exit;\n if l1>r1\n then exit;\n if n=0\n then exit;\n if (l2>=l1)and(r2<=r1)\n then begin rez:=max(rez,r2-l2+1); exit; end;\n if (l1>=l2)and(r1<=r2)\n then begin rez:=max(rez,r1-l1+1); exit; end;\n if (r1>=l2)and(r2>=r1)\n then rez:=max(rez,r1-l2+1);\n if (r2>=l1)and(r1>=r2)\n then rez:=max(rez,r2-l1+1);\n z:=1 shl n;\n if (r2z div 2)and(l2>z div 2)\n then probeg(n-1,l1-z div 2,r1-z div 2,l2-z div 2,r2-z div 2)\n else if (l1>z div 2)and(r2z div 2)and(r1=z div 2)and(r2\n >=z div 2)\n then begin\n probeg(n-1,l1,z div 2-1,l2,z div 2-1);\n probeg(n-1,1,r1-z div 2,1,r2-z div 2);\n probeg(n-1,l1,z div 2-1,1,r2-z div 2);\n probeg(n-1,1,r1-z div 2,l2,z div 2-1);\n end\n else if (l1<=z div 2)and(r1>=z div 2)\n then begin\n if r2 r1) or (l2 > r2) then\n begin\n go:=0;\n exit;\n end;\n for i:=29 downto 0 do\n if (l1 > 1 shl i) and (r1 < 1 shl (i+1)) then\n begin\n dec(l1,1 shl i);\n dec(r1,1 shl i);\n end;\n for i:=29 downto 0 do\n if (l2 > 1 shl i) and (r2 < 1 shl (i+1)) then\n begin\n dec(l2,1 shl i);\n dec(r2,1 shl i);\n end;\n if (l1 <= l2) and (r2 <= r1) then\n begin\n go:=r2-l2+1;\n exit;\n end;\n if (l2 <= l1) and (r1 <= r2) then\n begin\n go:=r1-l1+1;\n exit;\n end;\n m1:=1;\n while m1 shl 1 <= r1 do m1:=m1 shl 1;\n m2:=1;\n while m2 shl 1 <= r2 do m2:=m2 shl 1;\n if m1 = m2 then\n begin\n lg:=l1; rg:=r1;\n if l2 > lg then lg:=l2;\n if r2 < rg then rg:=r2;\n ans:=rg-lg+1;\n if (l1 < l2) and (r1 < r2) then\n begin\n cur:=go(l1,m1-1,m1+1,r2);\n if cur > ans then ans:=cur;\n end else\n if (l2 < l1) and (r2 < r1) then\n begin\n cur:=go(l2,m1-1,m1+1,r1);\n if cur > ans then ans:=cur;\n end;\n go:=ans;\n end else\n if m1 > m2 then\n begin\n ans:=go(l1,m1-1,l2,r2);\n cur:=go(m1+1,r1,l2,r2);\n if cur > ans then ans:=cur;\n go:=ans;\n end else\n begin\n ans:=go(l1,r1,l2,m2-1);\n cur:=go(l1,r1,m2+1,r2);\n if cur > ans then ans:=cur;\n go:=ans;\n end;\nend;\n\nbegin\n read(l1,r1,l2,r2);\n writeln(go(l1,r1,l2,r2));\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:int64;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg,k:int64;\n var i,cntrl:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nvar cntrl:integer;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp((n+1)*ln(2)));\n cntrl:=0;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((n+1)*ln(2)));\n If summ=l2) and (summ<=r2) then begin cntrl:=cntrl+1;max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end else If summ>r2 then summ:=maxim(round(r2),round(r1))+1;\n If cntrl=2 then summ:=maxim(round(r2),round(r1))+1;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n If min(x,y)=0 then k:=0 else k:=min(x,y)-1;\n for i:=k to 30 do begin\n summ:=round(exp(i*ln(2)))-round(exp((i+1)*ln(2)));\n j:=2;\n cntrl:=0;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((i+1)*ln(2)));\n If summ=l1) and (summ<=r1) then begin cntrl:=cntrl+1; If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1;\n If cntrl=2 then summ:=maxim(round(r2),round(r1))+1;\n end;\n // end;\n\n end;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}], "negative_code": [{"source_code": "Uses math;\nVar rez,l1,r1,l2,r2:longint;\nprocedure probeg(n,l1,r1,l2,r2:longint);\nVar z:longint;\nbegin\n if l2>r2\n then exit;\n if l1>r1\n then exit;\n if n=0\n then exit;\n if (l2>=l1)and(r2<=r1)\n then begin rez:=max(rez,r2-l2+1); exit; end;\n if (l1>=l2)and(r1<=r2)\n then begin rez:=max(rez,r1-l1+1); exit; end;\n if (r1>=l2)and(r2>=r1)\n then rez:=max(rez,r1-l2+1);\n if (r2>=l1)and(r1>=r2)\n then rez:=max(rez,r2-l1+1);\n z:=1 shl n;\n if (r2z div 2)and(l2>z div 2)\n then probeg(n-1,l1-z div 2,r1-z div 2,l2-z div 2,r2-z div 2)\n else if (l1<=z div 2)and(l2<=z div 2)and(r1>=z div 2)and(r1>=z div 2)\n then begin\n probeg(n-1,l1,z div 2-1,l2,z div 2-1);\n probeg(n-1,1,r1-z div 2,1,r2-z div 2);\n probeg(n-1,l1,z div 2-1,1,r2-z div 2);\n probeg(n-1,1,r1-z div 2,l2,z div 2-1);\n end\n else if (l1<=z div 2)and(r1>=z div 2)\n then begin\n if r2r2\n then exit;\n if l1>r1\n then exit;\n if n=0\n then exit;\n if (l2>=l1)and(r2<=r1)\n then begin rez:=max(rez,r2-l2+1); exit; end;\n if (l1>=l2)and(r1<=r2)\n then begin rez:=max(rez,r1-l1+1); exit; end;\n if (r1>=l2)and(r2>=r1)\n then rez:=max(rez,r1-l2+1);\n if (r2>=l1)and(r1>=r2)\n then rez:=max(rez,r2-l1+1);\n z:=1 shl n;\n if (r2z div 2)and(l2>z div 2)\n then probeg(n-1,l1-z div 2,r1-z div 2,l2-z div 2,r2-z div 2)\n else if (l1<=z div 2)and(l2<=z div 2)and(r1>=z div 2)and(r1>=z div 2)\n then begin\n probeg(n-1,l1,z div 2-1,l2,z div 2-1);\n probeg(n-1,1,r1-z div 2,1,r2-z div 2);\n end\n else if (l1<=z div 2)and(r1>=z div 2)\n then begin\n if r2b then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n x:=0;y:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1+1)/ln(2));\n If l2<>r2 then y:=trunc(ln(r2-l2+1)/ln(2));\n for i:=min(x,y) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If al2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n kryg:=0;\n while (summ<=r2) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ; end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1)/ln(2));\n If l2<>r2 then y:=trunc(ln(r2-l2)/ln(2));\n for i:=min(round(x),round(y)) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm2),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1)/ln(2));\n If l2<>r2 then y:=trunc(ln(r2-l2)/ln(2));\n for i:=min(round(x),round(y)) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n x:=0;y:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1)/ln(2));\n If l2<>r2 then y:=trunc(ln(r2-l2)/ln(2));\n for i:=min(x,y) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If al2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;summ:=round(r2)+2; end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:int64;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg,k:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp((n+1)*ln(2)));\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((n+1)*ln(2)));\n\n// If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end else If summ>r2 then summ:=maxim(round(r2),round(r1))+1;\n // end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n If min(x,y)=0 then k:=0 else k:=min(x,y)-1;\n for i:=k to 30 do begin\n summ:=round(exp(i*ln(2)))-round(exp((i+1)*ln(2)));\n j:=2;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((i+1)*ln(2)));\n If summ=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1;\n end;\n // end;\n\n end;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If a=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1)/ln(2));\n for i:=x to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end;\n s:=min(min(round(exp(max*ln(2))),maxsumm1-round(l1)),min(round(exp(max*ln(2))),round(r1)-maxsumm1))+min(min(round(exp(max*ln(2))),maxsumm2-round(l2)),min(round(exp(max*ln(2))),round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:int64;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg,k:int64;\n var i,cntrl:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nvar cntrl:integer;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp((n+1)*ln(2)));\n cntrl:=0;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((n+1)*ln(2)));\n If summ=l2) and (summ<=r2) then begin cntrl:=cntrl+1;max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end else If summ>r2 then summ:=maxim(round(r2),round(r1))+1;\n If cntrl=2 then summ:=maxim(round(r2),round(r1))+1;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n cntrl:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n If min(x,y)=0 then k:=0 else k:=min(x,y)-1;\n for i:=k to 30 do begin\n summ:=round(exp(i*ln(2)))-round(exp((i+1)*ln(2)));\n j:=2;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((i+1)*ln(2)));\n If summ=l1) and (summ<=r1) then begin cntrl:=cntrl+1; If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1;\n If cntrl=2 then summ:=maxim(round(r2),round(r1))+1;\n end;\n // end;\n\n end;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to maxim(x,y) do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:int64;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg,k:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp((n+1)*ln(2)));\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((n+1)*ln(2)));\n\n// If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end else If summ>r2 then summ:=maxim(round(r2),round(r1))+1;\n // end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n If min(x,y)=0 then k:=0 else k:=min(x,y)-1;\n for i:=k to 30 do begin\n summ:=round(exp(i*ln(2)))-round(exp((i+1)*ln(2)));\n j:=2;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp((i+1)*ln(2)));\n If summ=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1;\n end;\n // end;\n\n end;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If al2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=r2) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ; end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If kryg>0 then writeln(kryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If a=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;summ:=round(r2)+2; end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n for i:=min(x,y) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to maxim(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n for i:=min(x,y) to maxim(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n IF (l1=r1) and (l2=r2) and (l2=l1) then writeln('1') else\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If al2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n for i:=min(x,y) to min(x,y)+1 do begin\n summ:=0;\n t:=false;\n j:=2;\n kryg:=0;\n while (summ<=r2) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ; end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2,c:real;\n var a,b,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp,kryg,maxkryg,k:int64;\n var i:longint;\n t,tmp:boolean;\n label 1;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then maxim:=a else maxim:=b;\nend;\nfunction krygovaya(summ:int64;n:int64;j:int64):int64;\nvar max,maxsumm1,summtmp,maxsumm2,kryg,s:int64;\nbegin\n summtmp:=summ;\n kryg:=0;\n summ:=summ-round(exp(n*ln(2)));\n while (summ<=maxim(round(r2),round(r1))) do begin\n summ:=summ+round(exp(n*ln(2)));\n If summ=round(exp(n*ln(2)))*j then j:=j*2 else begin\n // If (summ>=l1) and (summ<=r1) then krygovaya(summ,i);// begin t:=true;summtmp:=summ; end;\n If (summ>=l2) and (summ<=r2) then begin max:=n;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n krygovaya:=kryg;\nend;\nbegin\n readln(l1,r1,l2,r2);\n If l1>l2 then begin c:=l1;l1:=l2;l2:=c;c:=r1;r1:=r2;r2:=c end;\n i:=0;\n j:=0;\n x:=trunc(ln(r1-l1+1)/ln(2));\n y:=trunc(ln(r2-l2+1)/ln(2));\n kryg:=0;\n maxkryg:=0;\n If min(x,y)=0 then k:=0 else k:=min(x,y)-1;\n for i:=k to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n\n while (summ<=maxim(round(r2),round(r1))) do begin\n\n summ:=summ+round(exp(i*ln(2)));\n 1:\n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (summ>=l1) and (summ<=r1) then begin If krygovaya(summ,i,j)>maxkryg then maxkryg:=krygovaya(summ,i,j) end else If summ>r1 then summ:=maxim(round(r2),round(r1))+1// begin t:=true;summtmp:=summ; end;\n //If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp;s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;If s>kryg then kryg:=s; end;\n end;\n end;\n // If tmp then begin summ:=summtmp;goto 1 end;\n end; //writeln(max,maxsumm1,maxsumm2);\n // s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If maxkryg>0 then writeln(maxkryg) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l1,r1,l2,r2:real;\n var a,b,c,d,x,y:integer;\n var j,s,summ,max,maxsumm1,maxsumm2,summtmp:int64;\n var i:longint;\n t:boolean;\nfunction min(a:int64;b:int64):int64;\nbegin\n If ab then x:=a else If a=b then x:=trunc(ln(r1-l1)/ln(2)) else x:=b;\n //If c>d then y:=c else If c=d then y:=trunc(ln(r2-l2)/ln(2)) else y:=d;\n i:=0;\n j:=0;\n If l1<>r1 then x:=trunc(ln(r1-l1)/ln(2));\n If l2<>r2 then y:=trunc(ln(r2-l2)/ln(2));\n for i:=min(x,y) to 30 do begin\n summ:=0;\n t:=false;\n j:=2;\n while (summ<=r2) do begin\n summ:=summ+round(exp(i*ln(2)));\n \n If summ=round(exp(i*ln(2)))*j then j:=j*2 else begin\n If (not t) and (summ>=l1) and (summ<=r1) then begin t:=true;summtmp:=summ end;\n If (t) and (summ>=l2) and (summ<=r2) then begin max:=i;maxsumm2:=summ;maxsumm1:=summtmp end;\n end; end;\n\n end; //writeln(max,maxsumm1,maxsumm2);\n s:=min(min(round(exp(max*ln(2)))-1,maxsumm1-round(l1)),min(round(exp(max*ln(2)))-1,maxsumm2-round(l2)))+min(min(round(exp(max*ln(2)))-1,round(r1)-maxsumm1),min(round(exp(max*ln(2)))-1,round(r2)-maxsumm2))+1;\n\n If s>0 then writeln(s) else writeln('0');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "uses math;\ntype pair = record\nl:longint;\nr:longint;\nend;\nvar f1,f2:text;\na,b,l,r:longint;\n\nfunction mp(u,v:longint):pair;begin mp.l:=u;mp.r:=v;end;\n\nFunction process(a,b,l,r:longint;k:longint):longint;\nvar i,j:longint;\nvt:longint;\nres:longint;\nt1,t2:array[1..2] of pair;\nbegin\n if k=0 then exit(0);\n if (a>b) or (l>r) then exit(0);\n res:=0;\n// if max(a,l)<=min(b,r) then res:=min(r,b)-max(a,l)+1;\n if ((a<=l) and (r<=b)) or ((l<=a) and (b<=r)) then exit(min(r,b)-max(a,l)+1);\n vt:=1 shl (k-1);\n if vt=a then inc(a);if vt=b then dec(b);if vt=l then inc(l);if vt=r then dec(r);\n t1[1]:=mp(a,min(b,vt-1));\n t1[2]:=mp(max(a,vt+1)-vt,b-vt);\n t2[1]:=mp(l,min(r,vt-1));\n t2[2]:=mp(max(l,vt+1)-vt,r-vt);\n for i:=1 to 2 do\n for j:=1 to 2 do\n res:=max(res,process(t1[i].l,t1[i].r,t2[j].l,t2[j].r,k-1));\n process:=res;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(F1,a,b,l,r);\n writeln(f2,Process(a,b,l,r,30));\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "var l1,r1,l2,r2,ans:longint;\n\nprocedure swap(var a,b:longint);\n var r:longint;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure doit(l1,r1,l2,r2,len:longint);\n var mid:longint;\n begin\n if (r1-l1+1<=ans) or (r2-l2+1<=ans) then exit;\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n writeln(l1,' ',r1,' ',l2,' ',r2,' ',ans);\n if l2<=r1 then\n if r1-l2+1>=ans then ans:=r1-l2+1;\n mid:=(len+1)>>1;\n if (l2<=mid) and (mid<=r1) then\n doit(1,r2-mid,l1,mid-1,len div 2)\n else\n if r2mid then\n doit(l1-mid,r1-mid,l2-mid,r2-mid,len div 2)\n else\n if l2<=mid then\n begin\n doit(l1,r1,l2,mid-1,len div 2);\n doit(l1,r1,1,r2-mid,len div 2);\n end\n else\n if r1>=mid then\n begin\n doit(l1,mid-1,l2-mid,r2-mid,len div 2);\n doit(1,r1-mid,l2-mid,r2-mid,len div 2);\n end\n else\n doit(l1,r1,l2-mid,r2-mid,len div 2);\n end;\n\nbegin\n readln(l1,r1,l2,r2);\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n ans:=0;\n doit(l1,r1,l2,r2,1<<30-1);\n writeln(ans);\nend.\n"}, {"source_code": "var l1,r1,l2,r2,ans:longint;\n\nprocedure swap(var a,b:longint);\n var r:longint;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure doit(l1,r1,l2,r2,len:longint);\n var mid,x1,y1,x2,y2:longint;\n begin\n if (r1-l1+1<=ans) or (r2-l2+1<=ans) then exit;\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n if l2<=r1 then\n if r1-l2+1>=ans then ans:=r1-l2+1;\n mid:=(len+1)>>1;\n if (l2<=mid) and (mid<=r1) then\n doit(1,r2-mid,l1,mid-1,len div 2)\n else\n if r2mid then\n doit(l1-mid,r1-mid,l2-mid,r2-mid,len div 2)\n else\n if l2<=mid then\n begin\n doit(l1,r1,l2,mid-1,len div 2);\n doit(l1,r1,1,r2-mid,len div 2);\n end\n else\n begin\n doit(l1,mid-1,l2-mid,r2-mid,len div 2);\n doit(1,r1-mid,l2-mid,r2-mid,len div 2);\n end;\n end;\n\nbegin\n readln(l1,r1,l2,r2);\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n ans:=0;\n doit(l1,r1,l2,r2,1<<30-1);\n writeln(ans);\nend."}, {"source_code": "var l1,r1,l2,r2,ans:longint;\n\nprocedure swap(var a,b:longint);\n var r:longint;\n begin\n r:=a;\n a:=b;\n b:=r;\n end;\n\nprocedure doit(l1,r1,l2,r2,len:longint);\n var mid:longint;\n begin\n if (r1-l1+1<=ans) or (r2-l2+1<=ans) then exit;\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n //writeln(l1,' ',r1,' ',l2,' ',r2,' ',ans);\n if l2<=r1 then\n if r1-l2+1>=ans then ans:=r1-l2+1;\n mid:=(len+1)>>1;\n if (l2<=mid) and (mid<=r1) then\n doit(1,r2-mid,l1,mid-1,len div 2)\n else\n if r2mid then\n doit(l1-mid,r1-mid,l2-mid,r2-mid,len div 2)\n else\n if l2<=mid then\n begin\n doit(l1,r1,l2,mid-1,len div 2);\n doit(l1,r1,1,r2-mid,len div 2);\n end\n else\n if r1>=mid then\n begin\n doit(l1,mid-1,l2-mid,r2-mid,len div 2);\n doit(1,r1-mid,l2-mid,r2-mid,len div 2);\n end\n else\n doit(l1,r1,l2-mid,r2-mid,len div 2);\n end;\n\nbegin\n readln(l1,r1,l2,r2);\n if (l1>l2) or ((l1=l2) and (r1>r2)) then\n begin\n swap(l1,l2);\n swap(r1,r2);\n end;\n ans:=0;\n doit(l1,r1,l2,r2,1<<30-1);\n writeln(ans);\nend.\n"}], "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513"} {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n base=1000000009;\n\nvar\n ni,ii,cr,i1,i2,i3,i4,res,kq,n,h,i,qqq,nkq,nq1,nq2,nq3,nq4:longint;\n used:array[0..33,0..33,0..33,0..33]of longint;\n qq1,qq2,qq3,qq4,q1,q2,q3,q4:array[0..500050]of longint;\n f,ff:array[0..33,0..33,0..33,0..33]of longint;\n \n procedure upd(i1,i2,i3,i4,cr:longint);inline;\n var\n t:array[1..5]of longint;\n j,i,tmp:longint;\n \n begin\n t[1]:=i1;t[2]:=i2;t[3]:=i3;t[4]:=i4;\n for i:=1 to 3 do\n for j:=1 to 3 do \n if (t[j]>t[j+1])then begin\n tmp:=t[j];t[j]:=t[j+1];t[j+1]:=tmp;\n end;\n i1:=t[1];i2:=t[2];i3:=t[3];i4:=t[4];\n if (used[i1][i2][i3][i4]<>qqq)then begin\n inc(nkq);\n qq1[nkq]:=i1;\n qq2[nkq]:=i2;\n qq3[nkq]:=i3;\n qq4[nkq]:=i4;\n used[i1][i2][i3][i4]:=qqq;\n ff[i1][i2][i3][i4]:=0;\n end;\n inc(ff[i1][i2][i3][i4],cr);\n if (ff[i1][i2][i3][i4]>=base)then dec(ff[i1][i2][i3][i4],base);\n end;\n\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n read(n,h);\n kq:=1;\n q1[1]:=0;\n q2[1]:=0;\n q3[1]:=0;\n q4[1]:=0;\n f[0][0][0][0]:=1;\n fillchar(used,sizeof(used),$0);\n qqq:=0;res:=0;\n for ii:=1 to n do begin\n inc(qqq);\n nkq:=0;\n for i:=1 to kq do begin\n i1:=q1[i];i2:=q2[i];\n i3:=q3[i];i4:=q4[i];\n nq1:=i1+1;if (nq1>h)then nq1:=h+1;\n nq2:=i2+1;if (nq2>h)then nq2:=h+1;\n nq3:=i3+1;if (nq3>h)then nq3:=h+1;\n nq4:=i4+1;if (nq4>h)then nq4:=h+1;\n cr:=f[i1][i2][i3][i4];\n if (cr=0)then continue;\n \n if (nq1<>h+1)then ni:=0 else ni:=h+1;\n upd(ni,nq2,nq3,nq4,cr);\n if (nq2<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,ni,nq3,nq4,cr);\n if (nq3<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,nq2,ni,nq4,cr);\n if (nq4<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,nq2,nq3,ni,cr);\n end;\n kq:=nkq;\n for i:=1 to kq do begin\n q1[i]:=qq1[i];q2[i]:=qq2[i];\n q3[i]:=qq3[i];q4[i]:=qq4[i];\n end;\n for i:=1 to kq do f[q1[i]][q2[i]][q3[i]][q4[i]]:=ff[q1[i]][q2[i]][q3[i]][q4[i]];\n end;\n for i:=1 to kq do begin\n i1:=q1[i];i2:=q2[i];i3:=q3[i];i4:=q4[i];\n if (i1>=h)and(i2>=h)and(i3>=h)and(i4>=h)then continue;\n inc(res,f[i1][i2][i3][i4]);\n if (res>=base)then dec(res,base);\n end;\n writeln(res);\nend.", "positive_code": [{"source_code": "const md:longint=1000000009;\n\nvar i,j,h,n,lj,lx,ly,lz,x,y,z,ans:longint;\n v:array[0..1001,0..1,0..31,0..31,0..31] of longint;\n\nfunction tt(x:longint):longint;\n begin\n if (x=0) or\n (x=h) then tt:=0\n else tt:=x+1;\n end;\n\n begin\n read(n,h);\n\n v[1,1,0,0,0]:=4;\n for i:=2 to n do\n begin\n for j:=0 to 1 do\n begin\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n begin\n lx:=tt(x);\n ly:=tt(y);\n lz:=tt(z);\n lj:=tt(j);\n v[i,j,lx,ly,lz]:=(v[i,j,lx,ly,lz]+v[i-1,j,x,y,z]) mod md;\n\n\n\n v[i,ord((x>0) or (i<=h)),lj,ly,lz]:=(v[i,ord((x>0) or (i<=h)),lj,ly,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((y>0) or (i<=h)),lx,lj,lz]:=(v[i,ord((y>0) or (i<=h)),lx,lj,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((z>0) or (i<=h)),lx,ly,lj]:=(v[i,ord((z>0) or (i<=h)),lx,ly,lj]+v[i-1,j,x,y,z]) mod md;\n end;\n\n end;\n\n end;\n\n ans:=0;\n for i:=0 to 1 do\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n if (i=0) then begin\n if (x>0) or\n (y>0) or\n (z>0) then ans:=(ans+v[n,i,x,y,z]) mod md;\n end\n else ans:=(ans+v[n,i,x,y,z]) mod md;\n\n writeln(ans);\n end.\n"}, {"source_code": "const md:longint=1000000009;\n\nvar\n i,j,h,n,lj,lx,ly,lz,x,y,z,ans:longint;\n v:array[0..1001,0..1,0..31,0..31,0..31] of longint;\n\nfunction tt(x: longint): longint;\n begin\n if (x = 0) or (x = h) then\n tt := 0\n else\n tt := x + 1;\n end;\n\nbegin\n read(n,h);\n v[1,1,0,0,0]:=4;\n for i:=2 to n do\n begin\n for j:=0 to 1 do\n begin\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n begin\n lx:=tt(x);\n ly:=tt(y);\n lz:=tt(z);\n lj:=tt(j);\n v[i,j,lx,ly,lz]:=(v[i,j,lx,ly,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((x>0) or (i<=h)),lj,ly,lz]:=(v[i,ord((x>0) or (i<=h)),lj,ly,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((y>0) or (i<=h)),lx,lj,lz]:=(v[i,ord((y>0) or (i<=h)),lx,lj,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((z>0) or (i<=h)),lx,ly,lj]:=(v[i,ord((z>0) or (i<=h)),lx,ly,lj]+v[i-1,j,x,y,z]) mod md;\n end;\n end;\n\n end;\n\n ans:=0;\n for i:=0 to 1 do\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n if (i=0) then begin\n if (x>0) or\n (y>0) or\n (z>0) then ans:=(ans+v[n,i,x,y,z]) mod md;\n end\n else ans:=(ans+v[n,i,x,y,z]) mod md;\n\n writeln(ans);\n end."}, {"source_code": "const\n md: longint = 1000000009;\n\nvar\n i,j,h,n,lj,lx,ly,lz,x,y,z,ans:longint;\n v:array[0..1001,0..1,0..31,0..31,0..31] of longint;\n\nfunction tt(x: longint): longint;\n begin\n if (x = 0) or (x = h) then\n tt := 0\n else\n tt := x + 1;\n end;\n\nbegin\n read(n,h);\n v[1,1,0,0,0]:=4;\n for i:=2 to n do\n begin\n for j:=0 to 1 do\n begin\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n begin\n lx:=tt(x);\n ly:=tt(y);\n lz:=tt(z);\n lj:=tt(j);\n v[i,j,lx,ly,lz]:=(v[i,j,lx,ly,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((x>0) or (i<=h)),lj,ly,lz]:=(v[i,ord((x>0) or (i<=h)),lj,ly,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((y>0) or (i<=h)),lx,lj,lz]:=(v[i,ord((y>0) or (i<=h)),lx,lj,lz]+v[i-1,j,x,y,z]) mod md;\n v[i,ord((z>0) or (i<=h)),lx,ly,lj]:=(v[i,ord((z>0) or (i<=h)),lx,ly,lj]+v[i-1,j,x,y,z]) mod md;\n end;\n end;\n\n end;\n\n ans:=0;\n for i:=0 to 1 do\n for x:=0 to h do\n for y:=0 to h do\n for z:=0 to h do\n if (i=0) then begin\n if (x>0) or\n (y>0) or\n (z>0) then ans:=(ans+v[n,i,x,y,z]) mod md;\n end\n else ans:=(ans+v[n,i,x,y,z]) mod md;\n\n writeln(ans);\n end."}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n base=1000000009;\n\nvar\n ni,ii,cr,i1,i2,i3,i4,res,kq,n,h,i,qqq,nkq,nq1,nq2,nq3,nq4:longint;\n used:array[0..33,0..33,0..33,0..33]of longint;\n qq1,qq2,qq3,qq4,q1,q2,q3,q4:array[0..500050]of longint;\n f,ff:array[0..33,0..33,0..33,0..33]of longint;\n \n procedure upd(i1,i2,i3,i4,cr:longint);inline;\n var\n t:array[1..5]of longint;\n j,i,tmp:longint;\n \n begin\n t[1]:=i1;t[2]:=i2;t[3]:=i3;t[4]:=i4;\n for i:=1 to 3 do\n for j:=1 to 3 do \n if (t[j]>t[j+1])then begin\n tmp:=t[j];t[j]:=t[j+1];t[j+1]:=tmp;\n end;\n i1:=t[1];i2:=t[2];i3:=t[3];i4:=t[4];\n if (used[i1][i2][i3][i4]<>qqq)then begin\n inc(nkq);\n qq1[nkq]:=i1;\n qq2[nkq]:=i2;\n qq3[nkq]:=i3;\n qq4[nkq]:=i4;\n used[i1][i2][i3][i4]:=qqq;\n ff[i1][i2][i3][i4]:=0;\n end;\n inc(ff[i1][i2][i3][i4],cr);\n if (ff[i1][i2][i3][i4]>=base)then dec(ff[i1][i2][i3][i4],base);\n end;\n\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n read(n,h);\n kq:=1;\n q1[1]:=0;\n q2[1]:=0;\n q3[1]:=0;\n q4[1]:=0;\n f[0][0][0][0]:=1;\n fillchar(used,sizeof(used),$0);\n qqq:=0;res:=0;\n for ii:=1 to n do begin\n inc(qqq);\n nkq:=0;\n for i:=1 to kq do begin\n i1:=q1[i];i2:=q2[i];\n i3:=q3[i];i4:=q4[i];\n nq1:=i1+1;if (nq1>h)then nq1:=h+1;\n nq2:=i2+1;if (nq2>h)then nq2:=h+1;\n nq3:=i3+1;if (nq3>h)then nq3:=h+1;\n nq4:=i4+1;if (nq4>h)then nq4:=h+1;\n cr:=f[i1][i2][i3][i4];\n if (cr=0)then continue;\n \n if (nq1<>h+1)then ni:=0 else ni:=h+1;\n upd(ni,nq2,nq3,nq4,cr);\n if (nq2<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,ni,nq3,nq4,cr);\n if (nq3<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,nq2,ni,nq4,cr);\n if (nq4<>h+1)then ni:=0 else ni:=h+1;\n upd(nq1,nq2,nq3,ni,cr);\n end;\n kq:=nkq;\n for i:=1 to kq do begin\n q1[i]:=qq1[i];q2[i]:=qq2[i];\n q3[i]:=qq3[i];q4[i]:=qq4[i];\n end;\n for i:=1 to kq do f[q1[i]][q2[i]][q3[i]][q4[i]]:=ff[q1[i]][q2[i]][q3[i]][q4[i]];\n end;\n for i:=1 to kq do begin\n i1:=q1[i];i2:=q2[i];i3:=q3[i];i4:=q4[i];\n if (i1>=h)and(i2>=h)and(i3>=h)and(i4>=h)then continue;\n inc(res,f[i1][i2][i3][i4]);\n if (res>=base)then dec(res,base);\n end;\n writeln(res);\nend.\n"}, {"source_code": "program Adina;\n{$ Q-, R-, S-, I-, O+}\nconst\n m = 1000000009;\nvar\n d : array [1..1001, 0..1, 0..31, 0..31, 0..31] of longint;\n n, i, j, k, l1, l2, l3, x, y, z, h, ans : longint;\n\nprocedure check(var l : longint);\nbegin\n if l = h - 1 then\n l := 0\n else\n if l > 0 then\n inc(l);\nend;\n\nprocedure calc1;\nbegin\n for x := 0 to h do\n for y := 0 to h do\n for z := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l2); check(l3);\n\n if (x > 0) or (i < h) then begin\n d[i + 1, 1, k, l2, l3] := (d[i + 1, 1, k, l2, l3] + d[i, k, x, y, z]);\n if d[i + 1, 1, k, l2, l3] >= m then\n dec(d[i + 1, 1, k, l2, l3], m);\n end\n else begin\n d[i + 1, 0, k, l2, l3] := (d[i + 1, 0, k, l2, l3] + d[i, k, x, y, z]);\n if d[i + 1, 0, k, l2, l3] >= m then\n dec(d[i + 1, 0, k, l2, l3], m);\n end;\n if (y > 0) or (i < h) then begin\n d[i + 1, 1, l1, k, l3] := (d[i + 1, 1, l1, k, l3] + d[i, k, x, y, z]);\n if d[i + 1, 1, l1, k, l3] >= m then\n dec(d[i + 1, 1, l1, k, l3], m);\n end\n else begin\n d[i + 1, 0, l1, k, l3] := (d[i + 1, 0, l1, k, l3] + d[i, k, x, y, z]);\n if d[i + 1, 0, l1, k, l3] >= m then\n dec(d[i + 1, 0, l1, k, l3], m);\n end;\n if (z > 0) or (i < h) then begin\n d[i + 1, 1, l1, l2, k] := (d[i + 1, 1, l1, l2, k] + d[i, k, x, y, z]);\n if d[i + 1, 1, l1, l2, k] >= m then\n dec(d[i + 1, 1, l1, l2, k], m);\n end\n else begin\n d[i + 1, 0, l1, l2, k] := (d[i + 1, 0, l1, l2, k] + d[i, k, x, y, z]);\n if d[i + 1, 0, l1, l2, k] >= m then\n dec(d[i + 1, 0, l1, l2, k], m);\n end;\n d[i + 1, k, l1, l2, l3] := (d[i + 1, k, l1, l2, l3] + (d[i, k, x, y, z]));\n if d[i + 1, k, l1, l2, l3] >= m then\n dec(d[i + 1, k, l1, l2, l3], m);\n end;\nend;\n\nbegin\n {assign(input, 'input.in');\n assign(output, 'output.out');\n reset(input);\n rewrite(output); }\n read(n, h);\n if h = 1 then begin\n writeln(4);\n halt;\n end;\n d[1, 1, 0, 0, 0] := 4;\n for i := 1 to n - 1 do\n for k := 0 to 1 do\n calc1;\n\n for l2 := 0 to h do\n for l3 := 0 to h do\n for l1 := 0 to h do begin\n if (l1 > 0) or (l2 > 0) or (l3 > 0) then begin\n ans := (ans + d[n, 0, l1, l2, l3]);\n if ans >= m then\n dec(ans, m);\n end;\n ans := (ans + d[n, 1, l1, l2, l3]);\n if ans >= m then\n dec(ans, m);\n end;\n\n writeln(ans);\n //writeln(d[2, 1, 0, 0, 0]);\n {close(input);\n close(output); }\nend.\n\n\n"}], "negative_code": [{"source_code": "program Adina;\nconst\n m = 1000000009;\nvar\n d : array [1..1001, 0..1, 0..31, 0..31, 0..31] of longint;\n n, i, j, al, l1, l2, l3, x, y, z, h, ans : longint;\n\nprocedure check(var l : longint);\nbegin\n if l = h - 1 then\n l := 0\n else\n if l > 0 then\n inc(l);\nend;\n\nprocedure calc1;\nbegin\n for y := 0 to h do\n for z := 0 to h do\n for x := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l2); check(l3);\n if (x > 0) or (i < h) then\n d[i + 1, 1, al, l2, l3] := (d[i + 1, 1, al, l2, l3] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, al, l2, l3] := (d[i + 1, 0, al, l2, l3] + d[i, al, x, y, z]) mod m;\n end;\nend;\n\nprocedure calc2;\nbegin\n for z := 0 to h do\n for x := 0 to h do\n for y := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l3);\n if (y > 0) or (i < h) then\n d[i + 1, 1, l1, al, l3] := (d[i + 1, 1, l1, al, l3] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, l1, al, l3] := (d[i + 1, 0, l1, al, l3] + d[i, al, x, y, z]) mod m;\n end;\nend;\n\nprocedure calc3;\nbegin\n for y := 0 to h do\n for x := 0 to h do\n for z := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l2);\n if (z > 0) or (i < h) then\n d[i + 1, 1, l1, l2, al] := (d[i + 1, 1, l1, l2, al] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, l1, l2, al] := (d[i + 1, 0, l1, l2, al] + d[i, al, x, y, z]) mod m\n end;\nend;\n\nprocedure calc4;\nbegin\n for x := 0 to h do\n for y := 0 to h do\n for z := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l2); check(l3);\n d[i + 1, al, l1, l2, l3] := (d[i + 1, al, l1, l2, l3] + (d[i, al, x, y, z])) mod m;\n end;\nend;\n\nbegin\n {assign(input, 'input.in');\n assign(output, 'output.out');\n reset(input);\n rewrite(output); }\n read(n, h);\n if h = 1 then begin\n writeln(4);\n halt;\n end;\n d[1, 1, 0, 0, 0] := 4;\n for i := 1 to n - 1 do\n for al := 0 to 1 do begin\n calc1;\n calc2;\n calc3;\n calc4;\n end;\n for l2 := 0 to h do\n for l3 := 0 to h do\n for l1 := 0 to h do\n if (l1 > 0) or (l2 > 0) or (l3 > 0) then begin\n ans := (ans + d[n, 0, l1, l2, l3]) mod m;\n writeln(0,' ',l1,' ',l2,' ',l3,' ',d[n, 0, l1, l2, l3]);\n end;\n\n for l1 := 0 to h do\n for l2 := 0 to h do\n for l3 := 0 to h do begin\n ans := (ans + d[n, 1, l1, l2, l3]) mod m;\n writeln(1,' ',l1,' ',l2,' ',l3,' ',d[n, 1, l1, l2, l3]);\n end;\n\n writeln(ans);\n //writeln(d[2, 1, 0, 0, 0]);\n {close(input);\n close(output); }\nend.\n"}, {"source_code": "program Adina;\nconst\n m = 1000000009;\nvar\n d : array [1..1001, 0..1, 0..31, 0..31, 0..31] of longint;\n n, i, j, al, l1, l2, l3, x, y, z, h, ans : longint;\n\nprocedure check(var l : longint);\nbegin\n if l = h - 1 then\n l := 0\n else\n if l > 0 then\n inc(l);\nend;\n\nprocedure calc1;\nbegin\n for y := 0 to h do\n for z := 0 to h do\n for x := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l2); check(l3);\n if (x > 0) or (i < h) then\n d[i + 1, 1, al, l2, l3] := (d[i + 1, 1, al, l2, l3] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, al, l2, l3] := (d[i + 1, 0, al, l2, l3] + d[i, al, x, y, z]) mod m;\n end;\nend;\n\nprocedure calc2;\nbegin\n for z := 0 to h do\n for x := 0 to h do\n for y := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l3);\n if (y > 0) or (i < h) then\n d[i + 1, 1, l1, al, l3] := (d[i + 1, 1, l1, al, l3] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, l1, al, l3] := (d[i + 1, 0, l1, al, l3] + d[i, al, x, y, z]) mod m;\n end;\nend;\n\nprocedure calc3;\nbegin\n for y := 0 to h do\n for x := 0 to h do\n for z := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l2);\n if (z > 0) or (i < h) then\n d[i + 1, 1, l1, l2, al] := (d[i + 1, 1, l1, l2, al] + d[i, al, x, y, z]) mod m\n else\n d[i + 1, 0, l1, l2, al] := (d[i + 1, 0, l1, l2, al] + d[i, al, x, y, z]) mod m\n end;\nend;\n\nprocedure calc4;\nbegin\n for x := 0 to h do\n for y := 0 to h do\n for z := 0 to h do begin\n l1 := x; l2 := y; l3 := z;\n check(l1); check(l2); check(l3);\n d[i + 1, al, l1, l2, l3] := (d[i + 1, al, l1, l2, l3] + (d[i, al, x, y, z])) mod m;\n end;\nend;\n\nbegin\n {assign(input, 'input.in');\n assign(output, 'output.out');\n reset(input);\n rewrite(output); }\n read(n, h);\n d[1, 1, 0, 0, 0] := 4;\n for i := 1 to n - 1 do\n for al := 0 to 1 do begin\n calc1;\n calc2;\n calc3;\n calc4;\n end;\n for l2 := 0 to h do\n for l3 := 0 to h do\n for l1 := 0 to h do\n if (l1 > 0) or (l2 > 0) or (l3 > 0) then begin\n ans := (ans + d[n, 0, l1, l2, l3]) mod m;\n //writeln(0,' ',l1,' ',l2,' ',l3,' ',d[n, 0, l1, l2, l3]);\n end;\n\n for l1 := 0 to h do\n for l2 := 0 to h do\n for l3 := 0 to h do begin\n ans := (ans + d[n, 1, l1, l2, l3]) mod m;\n //writeln(1,' ',l1,' ',l2,' ',l3,' ',d[n, 1, l1, l2, l3]);\n end;\n\n writeln(ans);\n //writeln(d[2, 1, 0, 0, 0]);\n {close(input);\n close(output); }\nend.\n"}], "src_uid": "9fe9658db35076c0bddc8b7ddce11013"} {"source_code": "Program Crime_Management;\ntype matrix=array[0..123,0..123]of longint;\nconst mo=12345;\nvar n:int64;\n ans,c,t,i,one,olda,nowa,oldb,nowb,tmp,cnt,size,tot:longint;\n a,b:array[0..1]of matrix;\n g:array['A'..'Z',0..123]of boolean;\n p,q:array[1..123]of longint;\n belong:array[1..123]of char;\n ch:char;\n//================================================================================\nprocedure Init;\nbegin\n readln(n,c);\n for i:=1 to c do\n begin\n read(ch);\n readln(t);\n g[ch,t]:=true;\n end;\nend;\n//================================================================================\nprocedure Hashf(opt:longint);\nvar i:longint;\nbegin\n for i:=1 to size do\n begin\n q[i]:=opt mod p[i];\n opt:=opt div p[i];\n end;\nend;\n//================================================================================\nprocedure GetHash;\nvar i:longint;\nbegin\n tmp:=0;cnt:=1;\n for i:=1 to size do\n begin\n tmp:=tmp+q[i]*cnt;\n cnt:=cnt*p[i];\n end;\nend;\n//================================================================================\nprocedure work(opt:longint);\nvar i:longint;\nbegin\n inc(a[0][opt,opt],one);\n Hashf(opt);\n for ch:='A' to 'Z' do\n if g[ch][0] then\n begin\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]+1) mod p[i];\n GetHash;\n inc(a[0][opt,tmp],1);\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]-1+p[i]) mod p[i];\n end;\nend;\n//================================================================================\nfunction ok(opt:longint):boolean;\nvar i:longint;\nbegin\n Hashf(opt);\n for ch:='A' to 'Z' do g[ch,1]:=false;\n for i:=1 to size do\n if q[i]=0 then g[belong[i],1]:=true;\n for ch:='A' to 'Z' do\n if g[ch,0] and not g[ch,1] then exit(false);\n exit(true);\nend;\n//================================================================================\nprocedure Get_Rule;\nbegin\n for ch:='A' to 'Z' do\n begin\n if g[ch][1] then inc(one);\n if not g[ch][1] then\n for i:=2 to 123 do\n if g[ch][i] then\n begin\n inc(size);p[size]:=i;\n belong[size]:=ch;\n g[ch][0]:=true;\n end;\n end;\n tot:=1;\n for i:=1 to size do tot:=tot*p[i];\n dec(tot);\n for i:=0 to tot do work(i);\nend;\n//================================================================================\nprocedure Matrix_Mul(var a,b,c:matrix);\nvar i,j,k:longint;\nbegin\n for i:=0 to tot do\n for j:=0 to tot do c[i,j]:=0;\n for i:=0 to tot do\n for k:=0 to tot do\n if a[i,k]>0 then\n for j:=0 to tot do\n c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod mo;\nend;\n//================================================================================\nprocedure Power(x:int64);\nbegin\n olda:=0;nowa:=1;\n oldb:=0;nowb:=1;\n for i:=0 to tot do b[0][i,i]:=1;\n while x>0 do\n begin\n if x and 1=1 then\n begin\n Matrix_Mul(b[oldb],a[olda],b[nowb]);\n oldb:=oldb xor 1;nowb:=nowb xor 1;\n end;\n Matrix_Mul(a[olda],a[olda],a[nowa]);\n olda:=olda xor 1;nowa:=nowa xor 1;\n x:=x>>1;\n end;\nend;\n//================================================================================\nprocedure Get_Ans;\nbegin\n for i:=0 to tot do\n if (b[oldb][0,i]>0) and ok(i) then\n begin\n ans:=ans+b[oldb][0,i];\n if ans>=mo then ans:=ans-mo;\n end;\n writeln(ans);\nend;\n//================================================================================\nbegin\n Init;\n Get_Rule;\n Power(n);\n Get_Ans;\nend.\n", "positive_code": [{"source_code": "type\n mat=array[0..130,0..130] of longint;\n\nvar\n ok:boolean;\n n:int64;\n m,nn,pre,i,next,now,k,j,ans:longint;\n tt,a,tmp:mat;\n ch:char;\n g,mo:array[1..26] of boolean;\n modnum,w:array[1..2000] of longint;\n \nprocedure zero(var a:mat);\n begin\n fillchar(a,sizeof(a),0);\n end;\n \nprocedure mul(var a,b:mat);\n var\n i,j,k:longint;\n tmp:int64;\n begin\n if a[1,1]=-1 then\n begin\n a:=b;\n exit;\n end;\n for i:=1 to nn do\n for j:=1 to nn do\n begin\n tmp:=0;\n for k:=1 to nn do\n tmp:=tmp+a[i,k]*b[k,j];\n tt[i,j]:=tmp mod 12345;\n end;\n a:=tt;\n end;\n \n\nbegin\n \n readln(n,m);\n if n=0 then\n begin\n writeln(1);\n halt;\n end;\n \n if m=0 then\n begin\n writeln(0);\n halt;\n end;\n \n fillchar(g,sizeof(g),false);\n nn:=1;\n for m:=1 to m do\n begin\n read(ch);\n w[m]:=ord(ch)-64;\n g[w[m]]:=true;\n read(ch);\n readln(modnum[m]);\n nn:=modnum[m]*nn;\n end;\n \n zero(a);\n for i:=1 to nn do\n begin\n for k:=1 to 26 do\n if g[k] then\n begin\n pre:=1; next:=0;\n for j:=1 to m do\n begin\n now:=((i-1) div pre) mod modnum[j];\n if w[j]=k then inc(now);\n if now=modnum[j] then now:=0;\n next:=next+now*pre;\n pre:=pre*modnum[j];\n end;\n inc(a[i,next+1]);\n end;\n end;\n\n tmp[1,1]:=-1;\n while n<>0 do\n if n and 1=1 then\n begin\n mul(tmp,a);\n dec(n);\n end else\n begin\n mul(a,a);\n n:=n>>1;\n end;\n \n ans:=0;\n \n for i:=1 to nn do\n begin\n fillchar(mo,sizeof(mo),false);\n pre:=1;\n for j:=1 to m do\n begin\n k:=((i-1) div pre) mod modnum[j];\n if k=0 then\n mo[w[j]]:=true;\n pre:=pre*modnum[j];\n end;\n\n ok:=true;\n for j:=1 to 26 do\n if g[j] and not mo[j] then ok:=false;\n \n if ok then inc(ans,tmp[1,i]);\n end;\n\n writeln(ans mod 12345);\n \nend."}, {"source_code": "program CF107D;\nconst\n md=12345;\n maxsize=123;\n maxn=1000;\ntype\n mat=array[0..maxsize,0..maxsize]of longint;\nvar\n ch:char;\n n:int64;\n i,j,k,m,size,ans,x:longint;\n a,b:mat;\n flag:boolean;\n crime:array[1..maxn]of char;\n factor,pass,tmp:array[1..maxn]of longint;\n bel:array['A'..'Z']of boolean;\n rec:array['A'..'Z',0..maxn]of longint;\n\nprocedure mul(var a:mat;b:mat);\nvar\n i,j,k:longint;\n c:mat;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=0 to size do\n for j:=0 to size do\n for k:=0 to size do c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod md;\n a:=c;\nend;\n\nprocedure calc(n:int64);\nvar\n i:longint;\nbegin\n fillchar(a,sizeof(a),0);\n for i:=0 to size do a[i,i]:=1;\n while n>0 do\n begin\n if n and 1=1 then mul(a,b);\n mul(b,b);n:=n>>1;\n end;\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'CF107D.in');\n reset(input);\n assign(output,'CF107D.out');\n rewrite(output);\n{$endif}\n readln(n,m);\n size:=1;\n for i:=1 to m do\n begin\n readln(crime[i],factor[i]);size:=size*factor[i];\n inc(rec[crime[i],0]);rec[crime[i],rec[crime[i],0]]:=i;\n end;\n if n=0 then\n begin\n writeln(1);halt;\n end;\n if m=0 then\n begin\n writeln(0);halt;\n end;\n dec(size);\n fillchar(b,sizeof(b),0);\n for i:=0 to size do\n begin\n x:=i;\n for j:=1 to m do\n begin\n pass[j]:=x mod factor[j];x:=x div factor[j];\n end;\n tmp:=pass;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n begin\n for j:=1 to rec[ch,0] do\n begin\n inc(pass[rec[ch,j]]);\n if pass[rec[ch,j]]=factor[rec[ch,j]] then pass[rec[ch,j]]:=0;\n end;\n x:=0;\n for j:=m downto 1 do x:=x*factor[j]+pass[j];\n pass:=tmp;inc(b[i,x]);\n end;\n end;\n\n calc(n);ans:=0;\n for i:=0 to size do\n begin\n x:=i;flag:=true;\n fillchar(bel,sizeof(bel),false);\n for j:=1 to m do\n begin\n if x mod factor[j]=0 then bel[crime[j]]:=true;\n x:=x div factor[j];\n end;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n if not bel[ch] then\n begin\n flag:=false;break;\n end;\n if flag then ans:=(ans+a[i,0]) mod md;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program CF107D;\nconst\n md=12345;\n maxsize=123;\n maxn=1000;\ntype\n mat=array[0..maxsize,0..maxsize]of longint;\nvar\n ch:char;\n n:int64;\n i,j,k,m,size,ans,x:longint;\n a,b:mat;\n flag:boolean;\n crime:array[1..maxn]of char;\n factor,pass,tmp:array[1..maxn]of longint;\n bel:array['A'..'Z']of boolean;\n rec:array['A'..'Z',0..maxn]of longint;\n\nprocedure mul(var a:mat;b:mat);\nvar\n i,j,k:longint;\n c:mat;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=0 to size do\n for j:=0 to size do\n for k:=0 to size do c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod md;\n a:=c;\nend;\n\nprocedure calc(n:int64);\nvar\n i:longint;\nbegin\n fillchar(a,sizeof(a),0);\n for i:=0 to size do a[i,i]:=1;\n while n>0 do\n begin\n if n and 1=1 then mul(a,b);\n mul(b,b);n:=n>>1;\n end;\nend;\n\nbegin\n readln(n,m);\n size:=1;\n for i:=1 to m do\n begin\n readln(crime[i],factor[i]);size:=size*factor[i];\n inc(rec[crime[i],0]);rec[crime[i],rec[crime[i],0]]:=i;\n end;\n if n=0 then\n begin\n writeln(1);halt;\n end;\n if m=0 then\n begin\n writeln(0);halt;\n end;\n dec(size);\n fillchar(b,sizeof(b),0);\n for i:=0 to size do\n begin\n x:=i;\n for j:=1 to m do\n begin\n pass[j]:=x mod factor[j];x:=x div factor[j];\n end;\n tmp:=pass;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n begin\n for j:=1 to rec[ch,0] do\n begin\n inc(pass[rec[ch,j]]);\n if pass[rec[ch,j]]=factor[rec[ch,j]] then pass[rec[ch,j]]:=0;\n end;\n x:=0;\n for j:=m downto 1 do x:=x*factor[j]+pass[j];\n pass:=tmp;inc(b[i,x]);\n end;\n end;\n\n calc(n);ans:=0;\n for i:=0 to size do\n begin\n x:=i;flag:=true;\n fillchar(bel,sizeof(bel),false);\n for j:=1 to m do\n begin\n if x mod factor[j]=0 then bel[crime[j]]:=true;\n x:=x div factor[j];\n end;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n if not bel[ch] then\n begin\n flag:=false;break;\n end;\n if flag then ans:=(ans+a[i,0]) mod md;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const p=12345;\ntype arr=array[0..125,0..125] of longint;\n arr1=array[0..125] of longint;\n St=array[0..26,0..10] of longint;\nvar n:int64; m,tot:longint;\n t:array[0..26,0..125] of longint;\n a,tmp:St;\n tp:array[0..26] of longint;\n s:array[0..125] of St;\n g,tt,tt1:arr; ans,c:arr1;\n\nprocedure dfs(x,y:longint);\nvar i:longint;\nbegin\n if x=tp[0]+1 then\n begin\n inc(tot); s[tot]:=tmp;\n end\n else\n begin\n for i:=0 to a[tp[x],y]-1 do\n begin\n tmp[x,y]:=i;\n if y=tmp[x,0] then dfs(x+1,1) else dfs(x,y+1);\n end;\n end;\nend;\n\nfunction get(x,y:longint):longint;\nvar i,j,t,t1,res:longint; f:boolean;\nbegin\n t1:=0;\n for i:=1 to tp[0] do\n begin\n f:=true;\n for j:=1 to tmp[i,0] do\n begin\n if s[x][i][j]<>s[y][i][j] then\n begin\n f:=false; break;\n end;\n end;\n if not f then\n begin\n t:=i; inc(t1);\n end;\n end;\n if t1>1 then exit(0);\n if t1=1 then\n begin\n f:=true;\n for i:=1 to tmp[t,0] do\n begin\n if (s[x][t][i]+1) mod a[tp[t],i]<>s[y][t][i] then\n begin\n f:=false; break;\n end;\n end;\n if f then exit(1); exit(0);\n end;\n res:=0;\n for i:=1 to tp[0] do\n begin\n if tmp[i,0]>1 then continue;\n if a[tp[i],1]=1 then inc(res);\n end;\n exit(res);\nend;\n\nprocedure init;\nvar i,j,x:longint; c1,c2:char;\nbegin\n readln(n,m);\n fillchar(t,sizeof(t),0);\n for i:=1 to m do\n begin\n readln(c1,c2,x);\n t[ord(c1)-64,x]:=1;\n end;\n tp[0]:=0;\n for i:=1 to 26 do\n begin\n a[i,0]:=0;\n for j:=1 to 123 do\n begin\n if t[i,j]=1 then\n begin\n inc(a[i,0]); a[i,a[i,0]]:=j;\n end;\n end;\n if a[i,0]>0 then\n begin\n inc(tp[0]); tp[tp[0]]:=i;\n end;\n end;\n for i:=1 to tp[0] do tmp[i,0]:=a[tp[i],0];\n tot:=0;\n dfs(1,1);\n fillchar(g,sizeof(g),0);\n for i:=1 to tot do\n for j:=1 to tot do g[i,j]:=get(i,j);\nend;\n\nfunction mul(a,b:arr):arr;\nvar i,j,k:longint;\nbegin\n fillchar(tt1,sizeof(tt1),0);\n for i:=1 to tot do\n for j:=1 to tot do\n for k:=1 to tot do tt1[i,j]:=(tt1[i,j]+a[i,k]*b[k,j]) mod p;\n exit(tt1);\nend;\n\nfunction mul2(a:arr1; b:arr):arr1;\nvar i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=1 to tot do\n for j:=1 to tot do c[i]:=(c[i]+a[j]*b[j,i]) mod p;\n exit(c);\nend;\n\nfunction pow(a:arr; b:int64):arr;\nvar i:longint;\nbegin\n fillchar(tt,sizeof(tt),0);\n for i:=1 to tot do tt[i,i]:=1;\n while b>0 do\n begin\n if b mod 2=1 then tt:=mul(tt,a);\n a:=mul(a,a); b:=b div 2;\n end;\n exit(tt);\nend;\n\nfunction check(x:longint):boolean;\nvar i,j:longint; f:boolean;\nbegin\n for i:=1 to tp[0] do\n begin\n f:=false;\n for j:=1 to tmp[i,0] do\n begin\n if s[x][i][j]=0 then\n begin\n f:=true; break;\n end;\n end;\n if not f then exit(false);\n end;\n exit(true);\nend;\n\nprocedure work;\nvar i:longint; res:longint;\nbegin\n fillchar(ans,sizeof(ans),0);\n ans[1]:=1;\n g:=pow(g,n);\n ans:=mul2(ans,g);\n res:=0;\n for i:=1 to tot do\n begin\n if check(i) then res:=res+ans[i];\n end;\n res:=res mod p;\n writeln(res);\nend;\n\nbegin\n init;\n work;\nend.\n\n"}, {"source_code": "type\n\tmat=array[0..123,0..123] of longint;\nvar\nans,g,rs:mat;\n\nprocedure mult(const a,b:mat; all:longint);\nvar i,j,k:longint;\nbegin fillchar(rs,sizeof(rs),0);\n\tfor k:=0 to all do\n\t\tfor j:=0 to all do\n\t\t\tif b[k,j]>0 then\n\t\t\t\tfor i:=0 to all do\n\t\t\t\t\trs[i,j]:=(rs[i,j]+a[i,k]*b[k,j]) mod 12345;\nend;\n\nprocedure mul(all:longint; y:int64);\nvar i:longint;\nbegin for i:=60 downto 0 do if y and (int64(1)<0 then break;\n\tans:=g;\n\tfor i:=i-1 downto 0 do\n\tbegin mult(ans,ans,all); ans:=rs;\n\t\tif y and (int64(1)<0 then begin mult(ans,g,all); ans:=rs; end;\n\tend;\nend;\n\nvar\ncount:array['A'..'Z'] of longint;\nrec:array['A'..'Z',0..1010] of longint;\nmulti,ss,tmp:array[0..1010] of longint;\nok:array['A'..'Z'] of boolean;\ncrime:array[0..1010] of char;\n\nprocedure lemon;\nvar LenX:int64;\n n,i,all,j,x,k,final:longint;\n ch:char;\n flag:boolean;\nbegin readln(LenX,n); if LenX=0 then begin writeln(1); exit; end;\n\tall:=1;\n\tfor i:=1 to n do\n\tbegin readln(ch,multi[i]); crime[i]:=ch;\n\t\tinc(count[ch]); rec[ch,count[ch]]:=i;\n\t\tall:=all*multi[i];\n\tend;\n\tfillchar(g,sizeof(g),0);\n\tfor i:=0 to all-1 do\n\tbegin x:=i;\n\t\tfor j:=1 to n do begin ss[j]:=x mod multi[j]; x:=x div multi[j]; end;\n\t\ttmp:=ss;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\tbegin for k:=1 to count[ch] do\n\t\t\t\tbegin inc(ss[rec[ch,k]]);\n\t\t\t\t\tif ss[rec[ch,k]]=multi[rec[ch,k]] then ss[rec[ch,k]]:=0;\n\t\t\t\tend;\n\t\t\t\tx:=0;\n\t\t\t\tfor j:=n downto 1 do x:=x*multi[j]+ss[j];\n\t\t\t\tinc(g[i,x]);\n\t\t\t\tss:=tmp;\n\t\t\tend;\n\tend;\n\tmul(all-1,LenX); final:=0;\n\tfor i:=0 to all-1 do\n\tbegin x:=i; fillchar(ok,sizeof(ok),false);\n\t\tfor j:=1 to n do begin if x mod multi[j]=0 then ok[crime[j]]:=true; x:=x div multi[j]; end;\n\t\tflag:=true;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\t\tif not ok[ch] then\n\t\t\t\tbegin flag:=false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tif flag then final:=(final+ans[i,0]) mod 12345;\n\tend;\n\twriteln(final);\nend;\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'107D.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "type\n re=record\n w,next:longint;\n end;\n\nconst\n max=12345;\n\ntype\n data=array[0..128,0..128]of longint;\n\nvar\n n:int64;\n m,tt,top,tot,ans:longint;\n a:array['A'..'Z']of longint;\n sum,size:array[0..26]of longint;\n g:array['A'..'Z']of longint;\n map:array[0..2000]of re;\n nam:array[0..26]of char;\n f,e:data;\n\nprocedure add(x,y:data;var t:data);\nvar\n i,j,k:longint;\n\nbegin\n fillchar(t,sizeof(t),0);\n for i:=0 to top-1 do\n for j:=0 to top-1 do\n for k:=0 to top-1 do t[i,j]:=(t[i,j]+x[i,k]*y[k,j])mod max;\nend;\n\nfunction jd(x:longint):boolean;\nvar\n i,t,j,k:longint;\n ch:char;\n\nbegin\n for i:=1 to tt do begin\n t:=(x div sum[i-1])mod size[i];\n ch:=nam[i];\n k:=g[ch];\n j:=0;\n while k<>0 do begin\n if t mod map[k].w=0 then begin\n j:=1;\n break;\n end;\n k:=map[k].next;\n end;\n if j=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure init;\nvar\n i,j,x,y,next:longint;\n ch:char;\n\nbegin\n fillchar(a,sizeof(a),255);\n tot:=0;\n fillchar(g,sizeof(g),0);\n for i:=1 to m do begin\n read(ch);\n readln(x);\n if a[ch]=-1 then a[ch]:=1;\n a[ch]:=a[ch]*x;\n inc(tot);\n map[tot].w:=x;\n map[tot].next:=g[ch];\n g[ch]:=tot;\n end;\n\n tt:=0;\n sum[0]:=1;\n for ch:='A' to 'Z' do if a[ch]>0 then begin\n inc(tt);\n sum[tt]:=sum[tt-1]*a[ch];\n size[tt]:=a[ch];\n nam[tt]:=ch;\n end;\n\n top:=sum[tt];\n\n if tt=0 then begin\n if n=0 then writeln(1)\n else writeln(0);\n exit;\n end;\n\n fillchar(f,sizeof(f),0);\n fillchar(e,sizeof(e),0);\n for i:=0 to top-1 do f[i,i]:=1;\n for i:=0 to top-1 do\n for j:=1 to tt do begin\n x:=(i div sum[j-1])mod size[j];\n y:=x+1;\n if y=size[j] then y:=0;\n next:=i-(x*sum[j-1])+(y*sum[j-1]);\n inc(e[i,next]);\n end;\n\n while n>0 do begin\n if n and 1=1 then add(f,e,f);\n n:=n shr 1;\n add(e,e,e);\n end;\n\n ans:=0;\n for i:=0 to top-1 do if jd(i) then ans:=(ans+f[0,i])mod max;\n writeln(ans);\nend;\n\nbegin\n //while true do begin\n readln(n,m);\n init;\n //end;\nend."}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\n{$M 10000000}\nconst md = 12345;\nvar\n ans,m,kv,i,j,n,k,ii: longint;\n ok: boolean;\n ch: char;\n s,step,q: int64;\n d: array [0..144,0..1010] of longint;\n good,can: array ['A'..'Z'] of boolean;\n tp: array [0..1010] of char;\n v,e,f,z: array [0..1010] of longint;\n a,b,c: array [0..144,0..144] of longint;\n\nprocedure rec(v:longint);\nvar\n i,j: longint;\nbegin\n if v = m+1 then\n begin\n inc(n);\n for i:=1 to m do d[n,i]:=e[i];\n exit;\n end;\n for j:=0 to z[v]-1 do\n begin\n e[v]:=j;\n rec(v+1);\n end;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(q,m);\n fillchar(can,sizeof(can),False);\n kv:=0;\n for i:=1 to m do\n begin\n read(ch);\n while not (ch in ['A'..'Z']) do read(ch);\n tp[i]:=ch;\n can[ch]:=True;\n read(z[i]);\n if z[i] > 1 then\n begin\n inc(kv);\n v[kv]:=i;\n end;\n end;\n n:=0;\n rec(1);\n fillchar(b,sizeof(b),0);\n for i:=1 to n do\n for ch:='A' to 'Z' do\n if can[ch] then\n begin\n for j:=1 to kv do\n if tp[v[j]] = ch then\n begin\n f[j]:=d[i,v[j]]+1;\n if f[j] = z[v[j]] then f[j]:=0;\n end\n else f[j]:=d[i,v[j]];\n for ii:=1 to n do\n begin\n ok:=True;\n for j:=1 to kv do\n if f[j] <> d[ii,v[j]] then\n begin\n ok:=False;\n break;\n end;\n if ok then inc(b[i,ii]);\n end;\n end;\n fillchar(a,sizeof(a),0);\n for i:=1 to n do a[i,i]:=1;\n step:=int64(1) shl 62;\n while step > 0 do\n begin\n for i:=1 to n do\n for j:=1 to n do\n begin\n s:=0;\n for k:=1 to n do s:=s+a[i,k]*a[k,j];\n c[i,j]:=s mod md;\n end;\n a:=c;\n if step and q <> 0 then\n begin\n for i:=1 to n do\n for j:=1 to n do\n begin\n s:=0;\n for k:=1 to n do s:=s+a[i,k]*b[k,j];\n c[i,j]:=s mod md;\n end;\n a:=c;\n end;\n step:=step shr 1;\n end;\n ans:=0;\n for i:=1 to n do\n begin\n fillchar(good,sizeof(good),False);\n for j:=1 to m do\n if d[i,j] = 0 then good[tp[j]]:=True;\n ok:=True;\n for ch:='A' to 'Z' do\n if not good[ch] and can[ch] then\n begin\n ok:=False;\n break;\n end;\n if ok then ans:=(ans+a[1,i]) mod md;\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "program cf107d;\nconst\n mode=12345;\ntype\n tmx=array[0..123,0..123]of longint;\n\nvar\n i,j,m,num,tot,ans:longint;\n n:int64;\n c:char;\n mo:array['A'..'Z']of longint;\n u:array[0..100]of longint;\n cd:array[0..1000]of char;\n cn:array[0..1000]of longint;\n v:array['A'..'Z']of longint;\n ki:array['A'..'Z']of boolean;\n tma,tmb,tms:tmx;\n kind:boolean;\n ch:char;\n\nprocedure zh(x:longint);\nvar\n c:char;\nbegin\n for c:='Z' downto 'A' do\n if mo[c]<>0 then begin\n v[c]:=x mod mo[c];\n x:=x div mo[c];\n end;\nend;\nfunction hash:longint;\nvar\n c:char;\n AN:LONGINT;\nbegin\nAN:=0;\n for c:='A' to 'Z' do\n if mo[c]<>0 then\n AN:=AN*mo[c]+v[c];\n HASH:=AN;\nend;\n\nprocedure deal(x:longint);\nvar\n c:char;\n y:longint;\nbegin\n zh(x);\n for c:='A' to 'Z' do\n if mo[c]<>0 then begin\n v[c]:=(v[c]+1)mod mo[c];\n y:=hash;\n inc(tms[x,y]);\n v[c]:=(v[c]-1+mo[c])mod mo[c];\n end;\nend;\n\nprocedure jzc(var c,a,b:tmx);\nvar\n i,j,k:longint;\nbegin\n for i:=0 to tot do\n for j:=0 to tot do\n c[i,j]:=0;\n for i:=0 to tot do\n for j:=0 to tot do\n for k:=0 to tot do\n c[i,j]:=(a[i,k]*b[k,j]+c[i,j])mod mode;\nend;\n\n\nprocedure ksm(n:int64);\nvar\n i:longint;\nbegin\n u[0]:=0;\n while n<>1 do begin\n inc(u[0]);\n u[u[0]]:=n and 1;\n n:=n shr 1;\n end;\n tma:=tms;\n for i:=u[0] downto 1 do begin\n jzc(tmb,tma,tma);\n if u[i]=1 then jzc(tma,tmb,tms)\n else tma:=tmb;\n end;\nend;\n\n\n\nbegin\n readln(n,m);\n if n=0 then begin\n writeln(1);\n halt;\n end;\n\n fillchar(mo,sizeof(mo),0);\n\n for i:=1 to m do begin\n read(ch);\n readln(num);\n cd[i]:=ch;\n cn[i]:=num;\n if mo[ch]=0 then\n mo[ch]:=num\n else mo[ch]:=mo[ch]*num;\n end;\n\n tot:=1;\n for c:='A' to 'Z' do\n if mo[c]<>0 then tot:=tot*mo[c];\n dec(tot);\n\n\n fillchar(tms,sizeof(tms),0);\n for i:=0 to tot do deal(i);\n\n ksm(n);\n\n //----------------------print--------------------\\\n ans:=0;\n for i:=0 to tot do begin\n for c:='A' to 'Z' do if mo[c]<>0 then\n ki[c]:=false\n else ki[c]:=true;\n\n ZH(I);\n for j:=1 to m do\n if v[cd[j]] mod cn[j]=0 then ki[cd[j]]:=true;\n kind:=true;\n\n for c:='A' to 'Z' do if not(ki[c]) then kind:=false;\n if kind then ans:=(ans+tma[0,i])mod mode;\n end;\n writeln(ans mod mode);\nend.\n\n\n\n\n"}, {"source_code": "program cf107d;\nconst\n mode=12345;\ntype\n tmx=array[0..123,0..123]of longint;\n\nvar\n i,j,m,num,tot,ans:longint;\n n:int64;\n c:char;\n mo:array['A'..'Z']of longint;\n u:array[0..100]of longint;\n cd:array[0..1000]of char;\n cn:array[0..1000]of longint;\n v:array['A'..'Z']of longint;\n ki:array['A'..'Z']of boolean;\n tma,tmb,tms:tmx;\n kind:boolean;\n ch:char;\n\nprocedure zh(x:longint);\nvar\n c:char;\nbegin\n for c:='Z' downto 'A' do\n if mo[c]<>0 then begin\n v[c]:=x mod mo[c];\n x:=x div mo[c];\n end;\nend;\nfunction hash:longint;\nvar\n c:char;\n AN:LONGINT;\nbegin\nAN:=0;\n for c:='A' to 'Z' do\n if mo[c]<>0 then\n AN:=AN*mo[c]+v[c];\n HASH:=AN;\nend;\n\nprocedure deal(x:longint);\nvar\n c:char;\n y:longint;\nbegin\n zh(x);\n for c:='A' to 'Z' do\n if mo[c]<>0 then begin\n v[c]:=(v[c]+1)mod mo[c];\n y:=hash;\n inc(tms[x,y]);\n v[c]:=(v[c]-1+mo[c])mod mo[c];\n end;\nend;\n\nprocedure jzc(var c,a,b:tmx);\nvar\n i,j,k:longint;\nbegin\n for i:=0 to tot do\n for j:=0 to tot do\n c[i,j]:=0;\n for i:=0 to tot do\n for j:=0 to tot do\n for k:=0 to tot do\n c[i,j]:=(a[i,k]*b[k,j]+c[i,j])mod mode;\nend;\n\n\nprocedure ksm(n:int64);\nvar\n i:longint;\nbegin\n u[0]:=0;\n while n<>1 do begin\n inc(u[0]);\n u[u[0]]:=n and 1;\n n:=n shr 1;\n end;\n tma:=tms;\n for i:=u[0] downto 1 do begin\n jzc(tmb,tma,tma);\n if u[i]=1 then jzc(tma,tmb,tms)\n else tma:=tmb;\n end;\nend;\n\n\n\nbegin\n readln(n,m);\n if n=0 then begin\n writeln(1);\n halt;\n end;\n\n fillchar(mo,sizeof(mo),0);\n\n for i:=1 to m do begin\n read(ch);\n readln(num);\n cd[i]:=ch;\n cn[i]:=num;\n if mo[ch]=0 then\n mo[ch]:=num\n else mo[ch]:=mo[ch]*num;\n end;\n\n tot:=1;\n for c:='A' to 'Z' do\n if mo[c]<>0 then tot:=tot*mo[c];\n dec(tot);\n\n\n fillchar(tms,sizeof(tms),0);\n for i:=0 to tot do deal(i);\n\n ksm(n);\n\n //----------------------print--------------------\\\n ans:=0;\n for i:=0 to tot do begin\n for c:='A' to 'Z' do if mo[c]<>0 then\n ki[c]:=false\n else ki[c]:=true;\n\n ZH(I);\n for j:=1 to m do\n if v[cd[j]] mod cn[j]=0 then ki[cd[j]]:=true;\n kind:=true;\n\n for c:='A' to 'Z' do if not(ki[c]) then kind:=false;\n if kind then ans:=(ans+tma[0,i])mod mode;\n end;\n writeln(ans mod mode);\nend.\n\n\n {1,7,15}\n\n"}, {"source_code": "const md = 12345;\ntype mat = array[0..200,0..200]of longint;\nvar\nok:boolean;\nuu,ee:array[char]of boolean;\nvv,q,vvv,ne,ed:mat;//array[0..200,0..200]of longint;\nchh:array[0..1000]of char;\nu:array['A'..'Z'] of boolean;\nans,k,w,j,st,e,c,i:longint;\nn:int64;\nch:char;\nt,f:array[0..1000]of longint;\n\nprocedure run1(v,sost:longint);\nvar i:longint;\n begin\n if v>c then\n begin\n q[sost,sost]:=e;\n fillchar(ee,sizeof(ee),false);\n for i:=1 to c do\n if t[i]=0 then\n begin\n ee[chh[i]]:=true;\n end;\n\n inc(w);\n vv[0,sost]:=1;\n\n for ch:='A' to 'Z' do\n if uu[ch] and (not ee[ch]) then vv[0,sost]:=0;\n\n // for j:=1 to c do write(t[j],' ');writeln(sost,' ',vv[0,sost]);\n\n for ch:='A' to 'Z' do\n if uu[ch] then\n if u[ch] then\n begin\n for j:=1 to c do\n if chh[j]=ch then t[j]:=(t[j]+1)mod f[j];\n st:=0;\n for j:=1 to c do\n if u[chh[j]] then st:=st*f[j]+t[j];\n q[sost,st]:=q[sost,st]+1;\n // writeln(' ',st);\n\n for j:=1 to c do\n if chh[j]=ch then t[j]:=(t[j]-1+f[j])mod f[j];\n\n end;\n exit;\n end;\n\n if u[chh[v]] then\n begin\n for i:=0 to f[v]-1 do\n begin\n t[v]:=i;\n run1(v+1,sost*f[v]+i);\n end;\n end else run1(v+1,sost);\n end;\n\n begin\n readln(n,c);\n fillchar(u,sizeof(u),true);\n e:=0;\n for i:=1 to c do\n begin\n readln(ch,f[i]);\n uu[ch]:=true;\n chh[i]:=ch;\n if f[i]=1 then\n begin\n if u[ch] then e:=e+1;\n u[ch]:=false;\n end;\n end;\n run1(1,0);\n\n w:=w-1;\n for i:=0 to w do ed[i,i]:=1;\n\n// n:=n-1;\n while n>0 do\n begin\n if n mod 2=1 then\n begin\n fillchar(ne,sizeof(ne),0);\n for i:=0 to w do\n for j:=0 to w do\n for k:=0 to w do\n ne[i,j]:=(ne[i,j]+ed[i,k]*q[k,j])mod md;\n ed:=ne;\n end;\n\n fillchar(ne,sizeof(ne),0);\n for i:=0 to w do\n for j:=0 to w do\n for k:=0 to w do\n ne[i,j]:=(ne[i,j]+q[i,k]*q[k,j])mod md;\n q:=ne;\n\n n:=n div 2;\n end;\n\n fillchar(ne,sizeof(ne),0);\n vvv[0,0]:=1;\n for i:=0 to 0 do\n for j:=0 to w do\n for k:=0 to w do\n ne[i,j]:=ne[i,j]+vvv[i,k]*ed[k,j];\n {\n for i:=0 to w do\n begin\n for j:=0 to w do\n write(ed[i,j],' ');\n writeln;\n end;\n}\n ans:=0;\n for i:=0 to w do\n if vv[0,i]>0 then\n ans:=ans+ne[0,i];\n writeln(ans mod md);\n end."}], "negative_code": [{"source_code": "Program Crime_Management;\ntype matrix=array[0..123,0..123]of longint;\nconst mo=12345;\nvar n:int64;\n ans,c,t,i,one,olda,nowa,oldb,nowb,tmp,cnt,size,tot:longint;\n a,b:array[0..1]of matrix;\n g:array['A'..'Z',0..123]of boolean;\n p,q:array[1..123]of longint;\n belong:array[1..123]of char;\n ch:char;\n//================================================================================\nprocedure Init;\nbegin\n readln(n,c);\n for i:=1 to c do\n begin\n read(ch);\n readln(t);\n g[ch,t]:=true;\n end;\nend;\n//================================================================================\nprocedure Hashf(opt:longint);\nvar i:longint;\nbegin\n for i:=1 to size do\n begin\n q[i]:=opt mod p[i];\n opt:=opt div p[i];\n end;\nend;\n//================================================================================\nprocedure GetHash;\nvar i:longint;\nbegin\n tmp:=0;cnt:=1;\n for i:=1 to size do\n begin\n tmp:=tmp+q[i]*cnt;\n cnt:=cnt*p[i];\n end;\nend;\n//================================================================================\nprocedure work(opt:longint);\nvar i:longint;\nbegin\n inc(a[0][opt,opt],one);\n Hashf(opt);\n for ch:='A' to 'Z' do\n if g[ch][0] then\n begin\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]+1) mod p[i];\n GetHash;\n inc(a[0][opt,tmp],1);\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]-1+p[i]) mod p[i];\n end;\nend;\n//================================================================================\nfunction ok(opt:longint):boolean;\nvar i:longint;\nbegin\n Hashf(opt);\n for ch:='A' to 'Z' do g[ch,1]:=false;\n for i:=1 to size do\n if q[i]=0 then g[belong[i],1]:=true;\n for ch:='A' to 'Z' do\n if g[ch,0] and not g[ch,1] then exit(false);\n exit(true);\nend;\n//================================================================================\nprocedure Get_Rule;\nbegin\n for ch:='A' to 'Z' do\n begin\n if g[ch][1] then inc(one);\n if not g[ch][1] then\n for i:=2 to 123 do\n if g[ch][i] then\n begin\n inc(size);p[size]:=i;\n belong[size]:=ch;\n g[ch][0]:=true;\n end;\n end;\n if one+size=0 then\n begin\n writeln(0);halt;\n end;\n tot:=1;\n for i:=1 to size do tot:=tot*p[i];\n dec(tot);\n for i:=0 to tot do work(i);\nend;\n//================================================================================\nprocedure Matrix_Mul(var a,b,c:matrix);\nvar i,j,k:longint;\nbegin\n for i:=0 to tot do\n for j:=0 to tot do c[i,j]:=0;\n for i:=0 to tot do\n for k:=0 to tot do\n if a[i,k]>0 then\n for j:=0 to tot do\n begin\n c[i,j]:=c[i,j]+a[i,k]*b[k,j];\n if c[i,j]>=mo then dec(c[i,j],mo);\n end;\nend;\n//================================================================================\nprocedure Power(x:int64);\nbegin\n olda:=0;nowa:=1;\n oldb:=0;nowb:=1;\n for i:=0 to tot do b[0][i,i]:=1;\n while x>0 do\n begin\n if x and 1=1 then\n begin\n Matrix_Mul(b[oldb],a[olda],b[nowb]);\n oldb:=oldb xor 1;nowb:=nowb xor 1;\n end;\n Matrix_Mul(a[olda],a[olda],a[nowa]);\n olda:=olda xor 1;nowa:=nowa xor 1;\n x:=x>>1;\n end;\nend;\n//================================================================================\nprocedure Get_Ans;\nbegin\n for i:=0 to tot do\n if (b[oldb][0,i]>0) and ok(i) then\n begin\n ans:=ans+b[oldb][0,i];\n if ans>=mo then ans:=ans-mo;\n end;\n writeln(ans);\nend;\n//================================================================================\nbegin\n Init;\n Get_Rule;\n Power(n);\n Get_Ans;\nend.\n"}, {"source_code": "Program Crime_Management;\ntype matrix=array[0..123,0..123]of longint;\nconst mo=12345;\nvar n:int64;\n ans,c,t,i,one,olda,nowa,oldb,nowb,tmp,cnt,size,tot:longint;\n a,b:array[0..1]of matrix;\n g:array['A'..'Z',0..123]of boolean;\n p,q:array[1..123]of longint;\n belong:array[1..123]of char;\n ch:char;\n//================================================================================\nprocedure Init;\nbegin\n readln(n,c);\n for i:=1 to c do\n begin\n read(ch);\n readln(t);\n g[ch,t]:=true;\n end;\nend;\n//================================================================================\nprocedure Hashf(opt:longint);\nvar i:longint;\nbegin\n for i:=1 to size do\n begin\n q[i]:=opt mod p[i];\n opt:=opt div p[i];\n end;\nend;\n//================================================================================\nprocedure GetHash;\nvar i:longint;\nbegin\n tmp:=0;cnt:=1;\n for i:=1 to size do\n begin\n tmp:=tmp+q[i]*cnt;\n cnt:=cnt*p[i];\n end;\nend;\n//================================================================================\nprocedure work(opt:longint);\nvar i:longint;\nbegin\n inc(a[0][opt,opt],one);\n Hashf(opt);\n for ch:='A' to 'Z' do\n if g[ch][0] then\n begin\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]+1) mod p[i];\n GetHash;\n inc(a[0][opt,tmp],1);\n for i:=1 to size do\n if belong[i]=ch then\n q[i]:=(q[i]-1+p[i]) mod p[i];\n end;\nend;\n//================================================================================\nfunction ok(opt:longint):boolean;\nvar i:longint;\nbegin\n Hashf(opt);\n for ch:='A' to 'Z' do g[ch,1]:=false;\n for i:=1 to size do\n if q[i]=0 then g[belong[i],1]:=true;\n for ch:='A' to 'Z' do\n if g[ch,0] and not g[ch,1] then exit(false);\n exit(true);\nend;\n//================================================================================\nprocedure Get_Rule;\nbegin\n for ch:='A' to 'Z' do\n begin\n if g[ch][1] then inc(one);\n if not g[ch][1] then\n for i:=2 to 123 do\n if g[ch][i] then\n begin\n inc(size);p[size]:=i;\n belong[size]:=ch;\n g[ch][0]:=true;\n end;\n end;\n if one+size=0 then\n begin\n writeln(0);halt;\n end;\n tot:=1;\n for i:=1 to size do tot:=tot*p[i];\n dec(tot);\n for i:=0 to tot do work(i);\nend;\n//================================================================================\nprocedure Matrix_Mul(var a,b,c:matrix);\nvar i,j,k:longint;\nbegin\n for i:=0 to tot do\n for j:=0 to tot do c[i,j]:=0;\n for i:=0 to tot do\n for k:=0 to tot do\n if a[i,k]>0 then\n for j:=0 to tot do\n c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod mo;\nend;\n//================================================================================\nprocedure Power(x:int64);\nbegin\n olda:=0;nowa:=1;\n oldb:=0;nowb:=1;\n for i:=0 to tot do b[0][i,i]:=1;\n while x>0 do\n begin\n if x and 1=1 then\n begin\n Matrix_Mul(b[oldb],a[olda],b[nowb]);\n oldb:=oldb xor 1;nowb:=nowb xor 1;\n end;\n Matrix_Mul(a[olda],a[olda],a[nowa]);\n olda:=olda xor 1;nowa:=nowa xor 1;\n x:=x>>1;\n end;\nend;\n//================================================================================\nprocedure Get_Ans;\nbegin\n for i:=0 to tot do\n if (b[oldb][0,i]>0) and ok(i) then\n begin\n ans:=ans+b[oldb][0,i];\n if ans>=mo then ans:=ans-mo;\n end;\n writeln(ans);\nend;\n//================================================================================\nbegin\n Init;\n Get_Rule;\n Power(n);\n Get_Ans;\nend.\n"}, {"source_code": "type\n mat=array[0..130,0..130] of longint;\n\nvar\n ok:boolean;\n n:int64;\n m,nn,pre,i,next,now,k,j,ans:longint;\n tt,a,tmp:mat;\n ch:char;\n g,mo:array[1..26] of boolean;\n modnum,w:array[1..2000] of longint;\n \nprocedure zero(var a:mat);\n begin\n fillchar(a,sizeof(a),0);\n end;\n \nprocedure mul(var a,b:mat);\n var\n i,j,k:longint;\n tmp:int64;\n begin\n if a[1,1]=-1 then\n begin\n a:=b;\n exit;\n end;\n for i:=1 to nn do\n for j:=1 to nn do\n begin\n tmp:=0;\n for k:=1 to nn do\n tmp:=tmp+a[i,k]*b[k,j];\n tt[i,j]:=tmp mod 12345;\n end;\n a:=tt;\n end;\n \n\nbegin\n readln(n,m);\n fillchar(g,sizeof(g),false);\n nn:=1;\n for m:=1 to m do\n begin\n read(ch);\n w[m]:=ord(ch)-64;\n g[w[m]]:=true;\n read(ch);\n readln(modnum[m]);\n nn:=modnum[m]*nn;\n end;\n \n zero(a);\n for i:=1 to nn do\n begin\n for k:=1 to 26 do\n if g[k] then\n begin\n pre:=1; next:=0;\n for j:=1 to m do\n begin\n now:=((i-1) div pre) mod modnum[j];\n if w[j]=k then inc(now);\n if now=modnum[j] then now:=0;\n next:=next+now*pre;\n pre:=pre*modnum[j];\n end;\n inc(a[i,next+1]);\n end;\n end;\n\n tmp[1,1]:=-1;\n while n<>0 do\n if n and 1=1 then\n begin\n mul(tmp,a);\n dec(n);\n end else\n begin\n mul(a,a);\n n:=n>>1;\n end;\n \n ans:=0;\n \n for i:=1 to nn do\n begin\n fillchar(mo,sizeof(mo),false);\n pre:=1;\n for j:=1 to m do\n begin\n k:=((i-1) div pre) mod modnum[j];\n if k=0 then\n mo[w[j]]:=true;\n pre:=pre*modnum[j];\n end;\n\n ok:=true;\n for j:=1 to 26 do\n if g[j] and not mo[j] then ok:=false;\n \n if ok then inc(ans,tmp[1,i]);\n end;\n\n writeln(ans mod 12345);\nend."}, {"source_code": "program CF107D;\nconst\n md=12345;\n maxsize=123;\n maxn=1000;\ntype\n mat=array[0..maxsize,0..maxsize]of longint;\nvar\n ch:char;\n n:int64;\n i,j,k,m,size,ans,x:longint;\n a,b:mat;\n flag:boolean;\n crime:array[1..maxn]of char;\n factor,pass,tmp:array[1..maxn]of longint;\n bel:array['A'..'Z']of boolean;\n rec:array['A'..'Z',0..maxn]of longint;\n\nprocedure mul(var a:mat;b:mat);\nvar\n i,j,k:longint;\n c:mat;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=0 to size do\n for j:=0 to size do\n for k:=0 to size do c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod md;\n a:=c;\nend;\n\nprocedure calc(n:int64);\nvar\n i:longint;\nbegin\n fillchar(a,sizeof(a),0);\n for i:=0 to size do a[i,i]:=1;\n while n>0 do\n begin\n if n and 1=1 then mul(a,b);\n mul(b,b);n:=n>>1;\n end;\nend;\n\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'CF107D.in');\n reset(input);\n\n readln(n,m);\n if n=0 then\n begin\n writeln(1);halt;\n end;\n size:=1;\n for i:=1 to m do\n begin\n readln(crime[i],factor[i]);size:=size*factor[i];\n inc(rec[crime[i],0]);rec[crime[i],rec[crime[i],0]]:=i;\n end;\n\n dec(size);\n fillchar(b,sizeof(b),0);\n for i:=0 to size do\n begin\n x:=i;\n for j:=1 to m do\n begin\n pass[j]:=x mod factor[j];x:=x div factor[j];\n end;\n tmp:=pass;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n begin\n for j:=1 to rec[ch,0] do\n begin\n inc(pass[rec[ch,j]]);\n if pass[rec[ch,j]]=factor[rec[ch,j]] then pass[rec[ch,j]]:=0;\n end;\n x:=0;\n for j:=m downto 1 do x:=x*factor[j]+pass[j];\n pass:=tmp;inc(b[i,x]);\n end;\n end;\n\n calc(n);ans:=0;\n for i:=0 to size do\n begin\n x:=i;flag:=true;\n fillchar(bel,sizeof(bel),false);\n for j:=1 to m do\n begin\n if x mod factor[j]=0 then bel[crime[j]]:=true;\n x:=x div factor[j];\n end;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n if not bel[ch] then\n begin\n flag:=false;break;\n end;\n if flag then ans:=(ans+a[i,0]) mod md;\n end;\n writeln(ans);\n {$endif}\nend.\n"}, {"source_code": "program CF107D;\nconst\n md=12345;\n maxsize=123;\n maxn=1000;\ntype\n mat=array[0..maxsize,0..maxsize]of longint;\nvar\n ch:char;\n n:int64;\n i,j,k,m,size,ans,x:longint;\n a,b:mat;\n flag:boolean;\n crime:array[1..maxn]of char;\n factor,pass,tmp:array[1..maxn]of longint;\n bel:array['A'..'Z']of boolean;\n rec:array['A'..'Z',0..maxn]of longint;\n\nprocedure mul(var a:mat;b:mat);\nvar\n i,j,k:longint;\n c:mat;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=0 to size do\n for j:=0 to size do\n for k:=0 to size do c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod md;\n a:=c;\nend;\n\nprocedure calc(n:int64);\nvar\n i:longint;\nbegin\n fillchar(a,sizeof(a),0);\n for i:=0 to size do a[i,i]:=1;\n while n>0 do\n begin\n if n and 1=1 then mul(a,b);\n mul(b,b);n:=n>>1;\n end;\nend;\n\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'CF107D.in');\n reset(input);\n\n readln(n,m);\n size:=1;\n for i:=1 to m do\n begin\n readln(crime[i],factor[i]);size:=size*factor[i];\n inc(rec[crime[i],0]);rec[crime[i],rec[crime[i],0]]:=i;\n end;\n if n=0 then\n begin\n writeln(1);halt;\n end;\n if m=0 then\n begin\n writeln(0);halt;\n end;\n dec(size);\n fillchar(b,sizeof(b),0);\n for i:=0 to size do\n begin\n x:=i;\n for j:=1 to m do\n begin\n pass[j]:=x mod factor[j];x:=x div factor[j];\n end;\n tmp:=pass;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n begin\n for j:=1 to rec[ch,0] do\n begin\n inc(pass[rec[ch,j]]);\n if pass[rec[ch,j]]=factor[rec[ch,j]] then pass[rec[ch,j]]:=0;\n end;\n x:=0;\n for j:=m downto 1 do x:=x*factor[j]+pass[j];\n pass:=tmp;inc(b[i,x]);\n end;\n end;\n\n calc(n);ans:=0;\n for i:=0 to size do\n begin\n x:=i;flag:=true;\n fillchar(bel,sizeof(bel),false);\n for j:=1 to m do\n begin\n if x mod factor[j]=0 then bel[crime[j]]:=true;\n x:=x div factor[j];\n end;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n if not bel[ch] then\n begin\n flag:=false;break;\n end;\n if flag then ans:=(ans+a[i,0]) mod md;\n end;\n writeln(ans);\n {$endif}\nend.\n"}, {"source_code": "program CF107D;\nconst\n md=12345;\n maxsize=123;\n maxn=1000;\ntype\n mat=array[0..maxsize,0..maxsize]of longint;\nvar\n ch:char;\n n:int64;\n i,j,k,m,size,ans,x:longint;\n a,b:mat;\n flag:boolean;\n crime:array[1..maxn]of char;\n factor,pass,tmp:array[1..maxn]of longint;\n bel:array['A'..'Z']of boolean;\n rec:array['A'..'Z',0..maxn]of longint;\n\nprocedure mul(var a:mat;b:mat);\nvar\n i,j,k:longint;\n c:mat;\nbegin\n fillchar(c,sizeof(c),0);\n for i:=0 to size do\n for j:=0 to size do\n for k:=0 to size do c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod md;\n a:=c;\nend;\n\nprocedure calc(n:int64);\nvar\n i:longint;\nbegin\n fillchar(a,sizeof(a),0);\n for i:=0 to size do a[i,i]:=1;\n while n>0 do\n begin\n if n and 1=1 then mul(a,b);\n mul(b,b);n:=n>>1;\n end;\nend;\n\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'CF107D.in');\n reset(input);\n assign(output,'CF107D.out');\n rewrite(output);\n\n readln(n,m);\n if n=0 then\n begin\n writeln(1);close(input);close(output);halt;\n end;\n size:=1;\n for i:=1 to m do\n begin\n readln(crime[i],factor[i]);size:=size*factor[i];\n inc(rec[crime[i],0]);rec[crime[i],rec[crime[i],0]]:=i;\n end;\n\n dec(size);\n fillchar(b,sizeof(b),0);\n for i:=0 to size do\n begin\n x:=i;\n for j:=1 to m do\n begin\n pass[j]:=x mod factor[j];x:=x div factor[j];\n end;\n tmp:=pass;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n begin\n for j:=1 to rec[ch,0] do\n begin\n inc(pass[rec[ch,j]]);\n if pass[rec[ch,j]]=factor[rec[ch,j]] then pass[rec[ch,j]]:=0;\n end;\n x:=0;\n for j:=m downto 1 do x:=x*factor[j]+pass[j];\n pass:=tmp;inc(b[i,x]);\n end;\n end;\n\n calc(n);ans:=0;\n for i:=0 to size do\n begin\n x:=i;flag:=true;\n fillchar(bel,sizeof(bel),false);\n for j:=1 to m do\n begin\n if x mod factor[j]=0 then bel[crime[j]]:=true;\n x:=x div factor[j];\n end;\n for ch:='A' to 'Z' do\n if rec[ch,0]>0 then\n if not bel[ch] then\n begin\n flag:=false;break;\n end;\n if flag then ans:=(ans+a[i,0]) mod md;\n end;\n writeln(ans);\n close(input);close(output);\n {$endif}\nend.\n"}, {"source_code": "type\n\tmat=array[0..123,0..123] of longint;\nvar\nans,g,rs:mat;\n\nprocedure mult(const a,b:mat; all:longint);\nvar i,j,k:longint;\nbegin fillchar(rs,sizeof(rs),0);\n\tfor k:=0 to all do\n\t\tfor j:=0 to all do\n\t\t\tif b[k,j]>0 then\n\t\t\t\tfor i:=0 to all do\n\t\t\t\t\trs[i,j]:=(rs[i,j]+a[i,k]*b[k,j]) mod 12345;\nend;\n\nprocedure mul(all:longint; y:int64);\nvar i:longint;\nbegin for i:=60 downto 0 do if y and (int64(1)<0 then break;\n\tans:=g;\n\tfor i:=i-1 downto 0 do\n\tbegin mult(ans,ans,all); ans:=rs;\n\t\tif y and (int64(1)<0 then begin mult(ans,g,all); ans:=rs; end;\n\tend;\nend;\n\nvar\ncount:array['A'..'Z'] of longint;\nrec:array['A'..'Z',0..1010] of longint;\nmulti,ss,tmp:array[0..1010] of longint;\nok:array['A'..'Z'] of boolean;\ncrime:array[0..1010] of char;\n\nprocedure lemon;\nvar LenX:int64;\n n,i,all,j,x,k,final:longint;\n ch:char;\n flag:boolean;\nbegin readln(LenX,n); if LenX=0 then begin writeln(1); exit; end;\n\tall:=1;\n\tfor i:=1 to n do\n\tbegin readln(ch,multi[i]); crime[i]:=ch;\n\t\tinc(count[ch]); rec[ch,count[ch]]:=i;\n\t\tall:=all*multi[i];\n\tend;\n\tfillchar(g,sizeof(g),0);\n\tfor i:=0 to all-1 do\n\tbegin x:=i;\n\t\tfor j:=1 to n do begin ss[j]:=x mod multi[j]; x:=x div multi[j]; end;\n\t\ttmp:=ss;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\tbegin for k:=1 to count[ch] do\n\t\t\t\tbegin inc(ss[rec[ch,k]]);\n\t\t\t\t\tif ss[rec[ch,k]]=multi[rec[ch,k]] then ss[rec[ch,k]]:=0;\n\t\t\t\tend;\n\t\t\t\tx:=0;\n\t\t\t\tfor j:=n downto 1 do x:=x*multi[j]+ss[j];\n\t\t\t\tg[i,x]:=1;\n\t\t\t\tss:=tmp;\n\t\t\tend;\n\tend;\n\tmul(all-1,LenX); final:=0;\n\tfor i:=0 to all-1 do\n\tbegin x:=i; fillchar(ok,sizeof(ok),false);\n\t\tfor j:=1 to n do begin if x mod multi[j]=0 then ok[crime[j]]:=true; x:=x div multi[j]; end;\n\t\tflag:=true;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\t\tif not ok[ch] then\n\t\t\t\tbegin flag:=false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tif flag then final:=(final+ans[i,0]) mod 12345;\n\tend;\n\twriteln(final);\nend;\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'107D.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "type\n\tmat=array[0..123,0..123] of longint;\nvar\nans,g,rs:mat;\n\nprocedure mult(const a,b:mat; all:longint);\nvar i,j,k:longint;\nbegin fillchar(rs,sizeof(rs),0);\n\tfor k:=0 to all do\n\t\tfor j:=0 to all do\n\t\t\tif b[k,j]>0 then\n\t\t\t\tfor i:=0 to all do\n\t\t\t\t\trs[i,j]:=(rs[i,j]+a[i,k]*b[k,j]) mod 12345;\nend;\n\nprocedure mul(all:longint; y:int64);\nvar i:longint;\nbegin for i:=60 downto 0 do if y and (int64(1)<0 then break;\n\tans:=g;\n\tfor i:=i-1 downto 0 do\n\tbegin mult(ans,ans,all); ans:=rs;\n\t\tif y and (int64(1)<0 then begin mult(ans,g,all); ans:=rs; end;\n\tend;\nend;\n\nvar\ncount:array['A'..'Z'] of longint;\nrec:array['A'..'Z',0..1010] of longint;\nmulti,ss,tmp:array[0..1010] of longint;\nok:array['A'..'Z'] of boolean;\ncrime:array[0..1010] of char;\n\nprocedure lemon;\nvar LenX:int64;\n n,i,all,j,x,k,final:longint;\n ch:char;\n flag:boolean;\nbegin readln(LenX,n); if n=0 then begin writeln(1); exit; end;\n\tall:=1;\n\tfor i:=1 to n do\n\tbegin readln(ch,multi[i]); crime[i]:=ch;\n\t\tinc(count[ch]); rec[ch,count[ch]]:=i;\n\t\tall:=all*multi[i];\n\tend;\n\tfillchar(g,sizeof(g),0);\n\tfor i:=0 to all-1 do\n\tbegin x:=i;\n\t\tfor j:=1 to n do begin ss[j]:=x mod multi[j]; x:=x div multi[j]; end;\n\t\ttmp:=ss;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\tbegin for k:=1 to count[ch] do\n\t\t\t\tbegin inc(ss[rec[ch,k]]);\n\t\t\t\t\tif ss[rec[ch,k]]=multi[rec[ch,k]] then ss[rec[ch,k]]:=0;\n\t\t\t\tend;\n\t\t\t\tx:=0;\n\t\t\t\tfor j:=n downto 1 do x:=x*multi[j]+ss[j];\n\t\t\t\tg[i,x]:=1;\n\t\t\t\tss:=tmp;\n\t\t\tend;\n\tend;\n\tmul(all-1,LenX); final:=0;\n\tfor i:=0 to all-1 do\n\tbegin x:=i; fillchar(ok,sizeof(ok),false);\n\t\tfor j:=1 to n do begin if x mod multi[j]=0 then ok[crime[j]]:=true; x:=x div multi[j]; end;\n\t\tflag:=true;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\t\tif not ok[ch] then\n\t\t\t\tbegin flag:=false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tif flag then final:=(final+ans[i,0]) mod 12345;\n\tend;\n\twriteln(final);\nend;\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'107D.in');\n\treset(input);\n{$endif}\nlemon;\nend."}, {"source_code": "type\n\tmat=array[0..123,0..123] of longint;\nvar\nans,g,rs:mat;\n\nprocedure mult(const a,b:mat; all:longint);\nvar i,j,k:longint;\nbegin fillchar(rs,sizeof(rs),0);\n\tfor k:=0 to all do\n\t\tfor j:=0 to all do\n\t\t\tif b[k,j]>0 then\n\t\t\t\tfor i:=0 to all do\n\t\t\t\t\trs[i,j]:=(rs[i,j]+a[i,k]*b[k,j]) mod 12345;\nend;\n\nprocedure mul(all:longint; y:int64);\nvar i:longint;\nbegin for i:=60 downto 0 do if y and (int64(1)<0 then break;\n\tans:=g;\n\tfor i:=i-1 downto 0 do\n\tbegin mult(ans,ans,all); ans:=rs;\n\t\tif y and (int64(1)<0 then begin mult(ans,g,all); ans:=rs; end;\n\tend;\nend;\n\nvar\ncount:array['A'..'Z'] of longint;\nrec:array['A'..'Z',0..1010] of longint;\nmulti,ss,tmp:array[0..1010] of longint;\nok:array['A'..'Z'] of boolean;\ncrime:array[0..1010] of char;\n\nprocedure lemon;\nvar LenX:int64;\n n,i,all,j,x,k,final:longint;\n ch:char;\n flag:boolean;\nbegin readln(LenX,n);\n\tall:=1;\n\tfor i:=1 to n do\n\tbegin readln(ch,multi[i]); crime[i]:=ch;\n\t\tinc(count[ch]); rec[ch,count[ch]]:=i;\n\t\tall:=all*multi[i];\n\tend;\n\tfillchar(g,sizeof(g),0);\n\tfor i:=0 to all-1 do\n\tbegin x:=i;\n\t\tfor j:=1 to n do begin ss[j]:=x mod multi[j]; x:=x div multi[j]; end;\n\t\ttmp:=ss;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\tbegin for k:=1 to count[ch] do\n\t\t\t\tbegin inc(ss[rec[ch,k]]);\n\t\t\t\t\tif ss[rec[ch,k]]=multi[rec[ch,k]] then ss[rec[ch,k]]:=0;\n\t\t\t\tend;\n\t\t\t\tx:=0;\n\t\t\t\tfor j:=n downto 1 do x:=x*multi[j]+ss[j];\n\t\t\t\tg[i,x]:=1;\n\t\t\t\tss:=tmp;\n\t\t\tend;\n\tend;\n\tmul(all-1,LenX); final:=0;\n\tfor i:=0 to all-1 do\n\tbegin x:=i; fillchar(ok,sizeof(ok),false);\n\t\tfor j:=1 to n do begin if x mod multi[j]=0 then ok[crime[j]]:=true; x:=x div multi[j]; end;\n\t\tflag:=true;\n\t\tfor ch:='A' to 'Z' do\n\t\t\tif count[ch]>0 then\n\t\t\t\tif not ok[ch] then\n\t\t\t\tbegin flag:=false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\tif flag then final:=(final+ans[i,0]) mod 12345;\n\tend;\n\twriteln(final);\nend;\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'107D.in');\n\treset(input);\n{$endif}\nlemon;\nend."}], "src_uid": "76d4684d26dac380713a566a1e277c91"} {"source_code": " const eps=1e-10;\n modul=1000000007;\n besk=1000000000000000;\n label 3,1,2,33,44,66;\n type\n mas=array[-200000..2*1100000+1] of int64;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n\nvar pos1,pos2,ii1,jj1,pos,kol1,left,ii,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,jj,tt,pl1,pl2,pl3:longint;\nt1,t2,n,kk,t,ll,rr,q,pp,p1,p2,p3,p4,sum,qq,ott,nn,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,gr:int64;\n flag1:boolean;\n zann:array[-10000..1000000] of boolean;\n pt:zap;\n cha:char;\n ttt:extended;\n matr:array[-1..6001,-1..6001] of integer;\n newoch,och:array[0..9,0..1000002] of longint;\n zan:array[-1..1001,-1..1001] of boolean;\nnewdloch,dloch,xleft,yleft,xright,yright,olda,bbb,zz,z,b1,a1:array[-100000..300000] of int64;\nddx,ddy,dd:array [0..500000,-1..9] of int64;\npole:array[-10..1000,-10..1000] of char;\nnewpole:array[-1..1001,-1..1001] of longint;\nbbbb,cccc:array[0..100000] of extended;\n ss2,ss,ss1:string;\naa,bb,cc,t22,t3:int64;\nxlmax,xlmin,xrmax,xrmin,ylmax,ylmin,yrmax,yrmin,xx,yy,x,y,mnog,stepen:array[-400000..400000] of int64;\nppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]matr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n begin\n repeat inc(pos) until ss1[pos]=ss2[i];\n x[i]:=pos;\n end;\n x[p2+1]:=p1+1;\n y[p2+1]:=p1+1;\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n begin\n repeat dec(pos) until ss1[pos]=ss2[i];\n y[i]:=pos;\n end;\n\n { for i:=0 to p2+1 do write(x[i],' '); writeln;\n for i:=0 to p2+1 do write(y[i],' '); writeln;\n }\n for i:=1 to p2+1 do ot:=max(ot,x[i]-x[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-y[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-x[i-1]);\n\n writeln(ot-1);\n\n\n 1: close (output);\nend.\n\n", "positive_code": [{"source_code": " const eps=1e-10;\n modul=1000000007;\n besk=1000000000000000;\n label 3,1,2,33,44,66;\n type\n mas=array[-200000..2*1100000+1] of int64;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n\nvar pos1,pos2,ii1,jj1,pos,kol1,left,ii,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,jj,tt,pl1,pl2,pl3:longint;\nt1,t2,n,kk,t,ll,rr,q,pp,p1,p2,p3,p4,sum,qq,ott,nn,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,gr:int64;\n flag1:boolean;\n zann:array[-10000..1000000] of boolean;\n pt:zap;\n cha:char;\n ttt:extended;\n matr:array[-1..6001,-1..6001] of integer;\n newoch,och:array[0..9,0..1000002] of longint;\n zan:array[-1..1001,-1..1001] of boolean;\nnewdloch,dloch,xleft,yleft,xright,yright,olda,bbb,zz,z,b1,a1:array[-100000..300000] of int64;\nddx,ddy,dd:array [0..500000,-1..9] of int64;\npole:array[-10..1000,-10..1000] of char;\nnewpole:array[-1..1001,-1..1001] of longint;\nbbbb,cccc:array[0..100000] of extended;\n ss2,ss,ss1:string;\naa,bb,cc,t22,t3:int64;\nxlmax,xlmin,xrmax,xrmin,ylmax,ylmin,yrmax,yrmin,xx,yy,x,y,mnog,stepen:array[-400000..400000] of int64;\nppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]matr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n begin\n repeat inc(pos) until ss1[pos]=ss2[i];\n x[i]:=pos;\n end;\n x[p2+1]:=p1+1;\n y[p2+1]:=p1+1;\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n begin\n repeat dec(pos) until ss1[pos]=ss2[i];\n y[i]:=pos;\n end;\n\n { for i:=0 to p2+1 do write(x[i],' '); writeln;\n for i:=0 to p2+1 do write(y[i],' '); writeln;\n }\n for i:=1 to p2+1 do ot:=max(ot,x[i]-x[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-y[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-x[i-1]);\n\n writeln(ot-1);\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": "const\n maxl = 200002;\nvar\n suf, pre : array[0..maxl-1] of longint;\n s, t : ansistring;\n i, slen, tlen, j, tmp, ans : longint;\n\nfunction max(a, b : longint) : longint;\nbegin\n if a > b then exit(a);\n exit(b);\nend;\n\nbegin\n readln(s);\n readln(t);\n slen := length(s);\n tlen := length(t);\n j := 1;\n for i := 1 to slen do\n begin\n if (j <= tlen) and (s[i] = t[j]) then\n inc(j);\n pre[i] := j;\n end;\n j := tlen;\n for i := slen downto 1 do\n begin\n if (j >= 1) and (s[i] = t[j]) then\n dec(j);\n suf[i] := j;\n end;\n suf[slen+1] := tlen;\n ans := 0; j := 1; tmp := 1;\n for i := 1 to slen + 1 do\n begin\n while (j <= slen + 1) and (tmp >= suf[j] + 1) do inc(j);\n ans := max(ans, j - i - 1);\n tmp := pre[i];\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var f1,f2:text;\ns1,s2:ansistring;\ni,j,n,m:longint;\nf:array[0..1000,0..1000] of longint;\nt:array[0..1000] of longint;\nfunction max(a,b:longint):longint;\nbegin\nif amatr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n repeat inc(pos) until ss1[pos]=ss2[i];\n\n { writeln('pos= ',pos );\n } t1:=p1-pos;\n\n\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n repeat dec(pos) until ss1[pos]=ss2[i];\n\n t2:=pos-1;\n\n { writeln('t1= ',t1,' t2= ',t2);\n } writeln(max(t1,t2));\n\n\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": " const eps=1e-10;\n modul=1000000007;\n besk=1000000000000000;\n label 3,1,2,33,44,66;\n type\n mas=array[-200000..2*1100000+1] of int64;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n\nvar pos1,pos2,ii1,jj1,pos,kol1,left,ii,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,jj,tt,pl1,pl2,pl3:longint;\nt1,t2,n,kk,t,ll,rr,q,pp,p1,p2,p3,p4,sum,qq,ott,nn,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,gr:int64;\n flag1:boolean;\n zann:array[-10000..1000000] of boolean;\n pt:zap;\n cha:char;\n ttt:extended;\n matr:array[-1..6001,-1..6001] of integer;\n newoch,och:array[0..9,0..1000002] of longint;\n zan:array[-1..1001,-1..1001] of boolean;\nnewdloch,dloch,xleft,yleft,xright,yright,olda,bbb,zz,z,b1,a1:array[-100000..300000] of int64;\nddx,ddy,dd:array [0..500000,-1..9] of int64;\npole:array[-10..1000,-10..1000] of char;\nnewpole:array[-1..1001,-1..1001] of longint;\nbbbb,cccc:array[0..100000] of extended;\n ss2,ss,ss1:string;\naa,bb,cc,t22,t3:int64;\nxlmax,xlmin,xrmax,xrmin,ylmax,ylmin,yrmax,yrmin,xx,yy,x,y,mnog,stepen:array[-400000..400000] of int64;\nppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]matr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n begin\n repeat inc(pos) until ss1[pos]=ss2[i];\n x[i]:=pos;\n end;\n x[p2+1]:=p1+1;\n y[p2+1]:=p1+1;\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n begin\n repeat dec(pos) until ss1[pos]=ss2[i];\n y[i]:=pos;\n end;\n\n { for i:=0 to p2+1 do write(x[i],' '); writeln;\n for i:=0 to p2+1 do write(y[i],' '); writeln;\n }\n for i:=1 to p2+1 do ot:=max(ot,x[i]-x[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-y[i-1]);\n\n writeln(ot-1);\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": " const eps=1e-10;\n modul=1000000007;\n besk=1000000000000000;\n label 3,1,2,33,44,66;\n type\n mas=array[-200000..2*1100000+1] of int64;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n\nvar pos1,pos2,ii1,jj1,pos,kol1,left,ii,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,jj,tt,pl1,pl2,pl3:longint;\nt1,t2,n,kk,t,ll,rr,q,pp,p1,p2,p3,p4,sum,qq,ott,nn,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,gr:int64;\n flag1:boolean;\n zann:array[-10000..1000000] of boolean;\n pt:zap;\n cha:char;\n ttt:extended;\n matr:array[-1..6001,-1..6001] of integer;\n newoch,och:array[0..9,0..1000002] of longint;\n zan:array[-1..1001,-1..1001] of boolean;\nnewdloch,dloch,xleft,yleft,xright,yright,olda,bbb,zz,z,b1,a1:array[-100000..300000] of int64;\nddx,ddy,dd:array [0..500000,-1..9] of int64;\npole:array[-10..1000,-10..1000] of char;\nnewpole:array[-1..1001,-1..1001] of longint;\nbbbb,cccc:array[0..100000] of extended;\n ss2,ss,ss1:string;\naa,bb,cc,t22,t3:int64;\nxlmax,xlmin,xrmax,xrmin,ylmax,ylmin,yrmax,yrmin,xx,yy,x,y,mnog,stepen:array[-400000..400000] of int64;\nppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]matr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n begin\n repeat inc(pos) until ss1[pos]=ss2[i];\n x[i]:=pos;\n end;\n x[p2+1]:=p1+1;\n y[p2+1]:=p1+1;\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n begin\n repeat dec(pos) until ss1[pos]=ss2[i];\n y[i]:=pos;\n end;\n\n { for i:=0 to p2+1 do write(x[i],' '); writeln;\n for i:=0 to p2+1 do write(y[i],' '); writeln;\n }\n for i:=1 to p2+1 do ot:=max(ot,x[i]-x[i-1]);\n for i:=1 to p2+1 do ot:=max(ot,y[i]-y[i-1]);\n\n writeln(ot-1);\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": " const eps=1e-10;\n modul=1000000007;\n besk=1000000000000000;\n label 3,1,2,33,44,66;\n type\n mas=array[-200000..2*1100000+1] of int64;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n\nvar pos1,pos2,ii1,jj1,pos,kol1,left,ii,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,jj,tt,pl1,pl2,pl3:longint;\nt1,t2,n,kk,t,ll,rr,q,pp,p1,p2,p3,p4,sum,qq,ott,nn,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,gr:int64;\n flag1:boolean;\n zann:array[-10000..1000000] of boolean;\n pt:zap;\n cha:char;\n ttt:extended;\n matr:array[-1..6001,-1..6001] of integer;\n newoch,och:array[0..9,0..1000002] of longint;\n zan:array[-1..1001,-1..1001] of boolean;\nnewdloch,dloch,xleft,yleft,xright,yright,olda,bbb,zz,z,b1,a1:array[-100000..300000] of int64;\nddx,ddy,dd:array [0..500000,-1..9] of int64;\npole:array[-10..1000,-10..1000] of char;\nnewpole:array[-1..1001,-1..1001] of longint;\nbbbb,cccc:array[0..100000] of extended;\n ss2,ss,ss1:string;\naa,bb,cc,t22,t3:int64;\nxlmax,xlmin,xrmax,xrmin,ylmax,ylmin,yrmax,yrmin,xx,yy,x,y,mnog,stepen:array[-400000..400000] of int64;\nppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]matr[(ii-1)*razm+1,(jj-1)*razm+1]\n then ot:=false;\n\n end;\n\n\n prov:=ot;\nend;\n\nfunction anss(n:int64):int64;\nvar ot,p,pp:int64;\nbegin\n p:=(n-1) div 2;\n if odd(n) then ot:=degg(modul,2,p) else ot:=3*degg(modul,2,p-1) mod modul;\n if n=2 then ot:=1;\n anss:=ot;\nend;\n\nbegin\n { assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(ss1);\n readln(ss2);\n pos:=0;\n p1:=length(ss1);\n p2:= length(ss2);\n for i:=1 to p2 do\n repeat inc(pos) until ss1[pos]=ss2[i];\n\n { writeln('pos= ',pos );\n } t1:=p1-pos;\n\n\n\n pos:=p1+1;\n\n for i:=p2 downto 1 do\n repeat dec(pos) until ss1[pos]=ss2[i];\n\n t2:=pos-1;\n\n { writeln('t1= ',t1,' t2= ',t2);\n } writeln(max(t1,t2));\n\n\n\n\n 1: close (output);\nend.\n\n"}], "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f"} {"source_code": "var\nx,h:int64;\ni:longint;\nfunction nok(a,b:int64):int64;\nvar\nc,x,y:int64;\nbegin\nx:=a;\ny:=b;\nwhile b<>0 do\nbegin\nc:=a mod b;\na:=b;\nb:=c;\nend;\nnok:=x*y div a;\nend;\nbegin\nreadln(x);\nif x=1 then\nbegin\nwriteln(1,' ',1);\nexit;\nend;\nfor i:= 1 to trunc(sqrt(x))+1 do\nbegin\nif (x mod i = 0) and (i<>x div i) then\nif nok(x div i,i)=x then\nh:=i;\nend;\nwriteln(x div h,' ',h{,' ',nok(x div h,h)});\nend.", "positive_code": [{"source_code": "program canh_toan;\nuses math;\nvar x:int64;\nfunction gcd(a,b:int64):int64;\nvar r:int64;\nbegin\n while (a mod b<>0) do\n begin\n r:=a mod b;\n a:=b;\n b:=r;\n end;\n exit(b);\nend;\nfunction lcm(a,b:int64):int64;\nbegin\n exit((a*b) div gcd(a,b));\nend;\nprocedure main();\nvar i:longint;\n j,a,b:int64;\nbegin\nread(x);\nfor i:=trunc(sqrt(x)) downto 1 do\n if (x mod i=0) then\n begin\n j:=x div i;\n if (lcm(i,j)=x) then\n begin\n a:=i;\n b:=j;\n break;\n end;\n end;\nwrite(a,' ',b);\nend;\nBEGIN\n main();\nEND."}, {"source_code": "var\n x, a1,a2,minn:int64;\n i:longint;\nfunction max(a, b:int64):int64;\nbegin\n if a>b then max:=a else max:=b;\nend;\nfunction nod(a,b:int64):int64;\nbegin\n if (a=0)or(b=0) then nod:=b\n else nod:=nod(b mod a, a);\nend;\nbegin\n readln(x);\n minn:=100000000000000;\n for i:=1 to trunc(sqrt(x)) do\n begin\n if (x mod i=0)and(max(i, x div i)0 do\n begin\n a:=a mod b;\n tmp:=a;\n a:=b;\n b:=tmp;\n end;\n ans:=(a1 div a)*b1;\n exit(ans);\nend;\nbegin\n assign(g,fi);reset(g);\n assign(f,fo);rewrite(f);\n readln(g,x);\n for i:=trunc(sqrt(x)) downto 1 do\n begin\n if (x mod i=0) and (x mod (x div i)=0) and (lcm(i,(x div i))=x)then\n begin\n write(f,i,' ',(x div i));\n break;\n end;\n end;\n close(g);close(f);\nend."}, {"source_code": " const eps=1e-14;\n besk=2000000000000000000; label 4,1,3,2,44,22;\n type mas=array[-1000000..1200000+1] of int64;\n integer=longint; zap=record x,y,z:int64; end;\n zap1=^zap;\n var qqq,oldpos,jj,kolvzv,sdvig,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n pqqq:zap; bet,al:extended;\n drans,dr3,dr1,dr2,pt,ott1,ott2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n stepen,delit,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,pos,aa,bb,kool,sum,number,imin,kolreber,kolstan,qq,kol,chisl,znam,n,m,ttt,numpos,vx,vy,ans,up,down,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,dx,dy,time,p3,p4,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,tmax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n fact,z,stan,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n ans1,posmax,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n razl,start,finish,left,right,zz,ll,rr,zpl,zmi,path,lx,a3,a4,predok,a1,b1,strok:array[-1000000..1500000] of int64;\n ppole1,ppole2,ppole:array[-1000000..3000000] of char;\n bufer, str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd1,dd2,dd,ssumitog,profil:array[-100..110,-100..110,-100..110] of int64;\n sss1,sss2,sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n verch,verzn:array[-10..1100000] of int64;\n ddd,ddinv:array[-1..560000,-1..4] of int64;\n poss:int64;\n obmen,ch:char;\n \n ff,flagg1:boolean;\n oldx,oldy,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..1700002] of int64;\n dp:array[0..3,-1..910,0..12] of int64;\n function srav(i,j:longint):boolean; label 44;\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]b then max:=a else max:=b;\nend;\nprocedure swap(var a,b:int64);\nvar c:int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\nfunction nod(a,b:int64):int64;\nbegin\n if b=0 then nod:=a\n else nod:=nod(b,a mod b);\nend;\nfunction nok(a,b:int64):int64;\nbegin\n if a0 do\n begin\n a:=b;b:=r;r:=a mod b\n end;\n nod:=b\nend;\nbegin\nread(a);if a=1 then write('1 1') else begin \nq:=trunc(sqrt(a))+1;\nif q*q =a then\n q:=q-1;\nwhile (a mod q>0)or(nod (a div q , q)>1) do\n q:=q-1;\nwrite(a div q,' ',q);end\nend."}], "negative_code": [{"source_code": "var x,a,b:int64;\n m:array[1..100]of longint;\n kol,i,j:longint;\n f:boolean;\nbegin\n read(x);\n kol:=0;\n while x>1 do\n begin\n f:=true;\n for i:=2 to round(sqrt(x)+1)do\n begin\n if x mod i = 0 then\n begin\n f:=false;\n x:=x div i;\n inc(kol);\n m[kol]:=i;\n break;\n end;\n end;\n if f then\n begin\n inc(kol);\n m[kol]:=x;\n x:=1;\n end;\n end;\n if kol=1 then \n begin\n write(m[1],' ',1);\n halt;\n end;\n a:=m[1];\n b:=m[kol];\n i:=2;\n j:=kol-1;\n while i<=j do\n begin\n if a1 do\n begin\n f:=true;\n for i:=2 to round(sqrt(x)+1)do\n begin\n if x mod i = 0 then\n begin\n f:=false;\n x:=x div i;\n inc(kol);\n m[kol]:=i;\n break;\n end;\n end;\n if f then\n begin\n inc(kol);\n m[kol]:=x;\n x:=1;\n end;\n end;\n kkol:=0;\n i:=1;\n while i<=kol do\n begin\n if m[i]=m[i+1]then\n begin\n inc(kkol);\n q[kkol]:=m[i];\n for j:=i to kol-1 do\n if m[j]=m[j+1]then begin q[kkol]:=q[kkol]*m[j]; i:=j+1;end else break;\n end\n else\n begin\n inc(kkol);\n q[kkol]:=m[i];\n end;\n inc(i);\n end;\n for i:=1 to kkol do\n for j:=1 to kkol-1 do\n if q[j]>q[j+1]then\n begin\n a:=q[j];\n q[j]:=q[j+1];\n q[j+1]:=a;\n end;\n if kkol=1 then \n begin\n write(q[1],' ',1);\n halt;\n end;\n a:=q[1];\n b:=q[kkol];\n i:=2;\n j:=kkol-1;\n while i<=j do\n begin\n if a0)or(q mod(a div q)=0))and(q>1) do q:=q-1;\nwrite(a div q,' ',q);end\nend."}, {"source_code": "var a,q:int64;\nbegin\nread(a);if a=1 then write('1 1') else begin \nq:=trunc(sqrt(a))+1;\nif q*q =a then\n q:=q-1;\nwhile ((a mod q>0)or( (a div q)mod q=0))and(q>1) do\n q:=q-1;\nwrite(a div q,' ',q);end\nend."}, {"source_code": "var\n x, a1,a2,minn:int64;\n i:longint;\nfunction max(a, b:int64):int64;\nbegin\n if a>b then max:=a else max:=b;\nend;\nfunction nod(a,b:int64):int64;\nbegin\n if a=0 then nod:=b\n else nod:=nod(b mod a, a);\nend;\nbegin\n readln(x);\n minn:=10000000000;\n for i:=1 to trunc(sqrt(x)) do\n begin\n if (x mod i=0)and(max(i, x div i)0 do\n begin\n a:=a mod b;\n tmp:=a;\n a:=b;\n b:=tmp;\n end;\n ans:=(a1 div a)*b1;\n exit(ans);\nend;\nbegin\n assign(g,fi);reset(g);\n assign(f,fo);rewrite(f);\n readln(g,x);\n for i:=trunc(sqrt(x)) downto 1 do\n begin\n if (x mod i=0) and (x mod (x div i)=0) and (lcm(i,(x div i))=x)then\n begin\n write(f,i,' ',(x div i));\n break;\n end;\n end;\n close(g);close(f);\nend."}, {"source_code": "const fi='';\n fo='';\nvar g,f:text;i,j,n:longint;\n x:qword;\nfunction lcm(a,b:longint):qword;\nvar tmp,a1,b1,ans:qword;\nbegin\n a1:=a;\n b1:=b;\n while b>0 do\n begin\n a:=a mod b;\n tmp:=a;\n a:=b;\n b:=tmp;\n end;\n ans:=(a1 div a)*b1;\n exit(ans);\nend;\nbegin\n assign(g,fi);reset(g);\n assign(f,fo);rewrite(f);\n readln(g,x);\n for i:=trunc(sqrt(x)) downto 1 do\n begin\n if (x mod i=0) and (x mod (x div i)=0) and (lcm(i,(x div i))=x)then\n begin\n write(f,i,' ',(x div i));\n break;\n end;\n end;\n close(g);close(f);\nend."}, {"source_code": "var\nx,h:int64;\ni:longint;\nbegin\nreadln(x);\nif x=1 then\nbegin\nwriteln(1,' ',1);\nexit;\nend;\nfor i:= 1 to trunc(sqrt(x))+1 do\nif (x mod i = 0) and (i<>x div i) then\nh:=i;\nwriteln(x div h,' ',h);\nend."}, {"source_code": "var a,b,d,n,i,j,k1,k2,p,max: longint;\nbegin\nread(n);\nmax:=n;\nfor i:=1 to trunc(sqrt(n)) do\nbegin\nif n mod i = 0 then begin k1:=i; k2:=n div i; p:=1; end;\nif p=1 then \n begin for j:=2 to k1 do if (k1 mod j=0) and (k2 mod j=0) then d:=1;\n if (d=0) and (k2='A') and (s[k]<='Z')) or ((s[k]>='a') and (s[k]<='z')) then\n if (s[k]='A') or (s[k]='E') or (s[k]='I') or (s[k]='O') or (s[k]='U') or (s[k]='Y') or (s[k]='a') or (s[k]='e') or (s[k]='i') or (s[k]='o') or (s[k]='u') or (s[k]='y') then begin\n write('YES');\n halt(0);\n end\n else begin\n write('NO');\n halt(0);\n end;\nend.\n"}, {"source_code": "var\ns,st:string;\ni:longint;\nj:char;\n begin\n for j:='A' to 'Z' do\n st:=st+j;\n readln(s);\n s:=upcase(s);\n i:=length(s);\n while pos(s[i],st)=0 do \n dec(i);\n\n if s[i] in['A','E','I','O','U','Y'] THEN writeln('YES') else writeln('NO');\n end.\n"}, {"source_code": "var\n s:string;\n i:longint;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n if s[i] in['a'..'z','A'..'Z'] then\n begin\n if s[i] in['a','e','i','o','u','y','A','E','I','O','U','Y']\n then writeln('YES') else writeln('NO');\n exit;\n end;\nend."}, {"source_code": "const a:array[1..12] of char=('a','e','i','o','u','y','A','E','I','O','U','Y');\nvar s:string;\n i,j:byte;\nbegin\nread(s);\nfor j:=length(s)-1 downto 1 do\nif s[j]<>' ' then\nbegin\nfor i:=1 to 12 do\nif s[j]=a[i] then begin write('YES'); halt; end;\nbreak;\nend;\nwrite('NO');\nend. "}, {"source_code": "var\n a:string;\n f:array[1..6]of char=('A','E','I','O','U','Y');\n n,i,l:longint;\nbegin\n readln(a);\n l:=length(A);\n for i:=1 to l do\n a[i]:=upcase(a[i]);\n while (a[l]='?')or(a[l]='.')or(a[l]=' ')or(a[l]='!') do dec(l);\n for i:=6 downto 1 do\n if a[l]=f[i] then n:=1;\n if n=1 then writeln('YES')\n else writeln('NO');\nend. //"}, {"source_code": "var s:ansistring;\n i:longint;\nbegin \n readln(s);i:=length(s);\n while not(upcase(s[i])in['A'..'Z']) do dec(i);\n if upcase(s[i])in['A','E','I','O','U','Y'] then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "var\n i:longint;\n s:string;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n begin\n if s[i] in ['a'..'z'] then begin\n if (s[i]='a')or(s[i]='e')or(s[i]='i')or(s[i]='o')or(s[i]='u')or(s[i]='y') then writeln('YES')\n else writeln('NO');\n break;\n end\n else if s[i] in ['A'..'Z'] then begin\n if (s[i]='A')or(s[i]='E')or(s[i]='I')or(s[i]='O')or(s[i]='U')or(s[i]='Y') then writeln('YES')\n else writeln('NO');\n break;\n end\n end;\nend.\n"}, {"source_code": "var a,b,c,d,e,f,g,j,brojac:longint;\nvar s,s1,s2,s3:shortstring;\nbegin\n\n readln(s);\n\n\n for j:=length(s)-1 downto 1 do\n begin\n if s[j]=' '\n then inc(brojac)\n else break;\n end;\n\n if brojac>0\n then begin\n delete(s,length(s)-(brojac-1),brojac);\n end;\n\n\n\n if (s[length(s)-1] in ['a','e','i','o','u','y','A','E','I','O','U','Y'])\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "program bangke;\nvar\n a : array [1..1000] of char;\n i : integer;\n x : char;\nbegin\n i := 0;\n repeat\n i := i + 1;\n read (a[i]);\n until eoln;\n\n i := i + 1;\n\n repeat\n i := i - 1;\n x := a[i];\n until (a[i] <> '?') and (a[i] <> ' ');\n if (a[i] = 'a') or (a[i] = 'e') or (a[i] = 'i') or (a[i] = 'u') or (a[i] = 'o') or (a[i] ='y') or (a[i] = 'A') or (a[i] = 'E') or (a[i] = 'I') or (a[i] = 'U') or (a[i] = 'O') or (a[i] ='Y') then\n writeln ('YES')\n else\n writeln ('NO');\nend."}, {"source_code": "var\n i,s:longint;\n n:ansistring;\nbegin\n read(n);\n for i:=1 to length(n) do\n if ((n[i]>='a')and(n[i]<='z'))or((n[i]>='A')and(n[i]<='Z')) then s:=i;\n case n[s] of\n 'A':write('YES');\n 'E':write('YES');\n 'I':write('YES');\n 'O':write('YES');\n 'U':write('YES');\n 'Y':write('YES');\n 'a':write('YES');\n 'e':write('YES');\n 'i':write('YES');\n 'o':write('YES');\n 'u':write('YES');\n 'y':write('YES');\n else write('NO');\n end;\nend."}, {"source_code": "uses math;\nvar\n s:string;\n i:longint;\nfunction big(c:char):char;\n begin\n if (ord(c)>=65) and (ord(c)<=90) then c:=chr(ord(c)+32);\n exit(c);\n end;\nbegin\n read(s);\n for i:=1 to length(s) do\n s[i]:=big(s[i]);\n\n for i:=length(s)-1 downto 1 do\n if s[i]<>' ' then break;\n\n case s[i] of\n 'a','e','i','o','u','y': begin write('YES'); halt; end;\n end;\n writeln('NO');\nend."}, {"source_code": "program hrn;//thfqwjmexjhgqwgscyxhjbwqghjb\n var\n s:string;\n i,l:longint;\n begin\n read(s);\n l:=length(s)+1;\n repeat\n l:=l-1;\n i:=ord(s[l]);\n until((i>=65)and(i<=90))or((i>=97)and(i<=122));\n if(i>=65)and(i<=90)then i:=i+32;\n if(i=97)or(i=101)or(i=105)or(i=111)or(i=117)or(i=121)then write('YES')\n else write('NO');\n end.\n"}, {"source_code": "var i:longint; s:string;\n begin\n readln (s);\n for i:=length(s) downto 1 do\n if s[i] in ['A'..'Z','a'..'z'] then break;\n if s[i] in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then writeln ('YES')\n else writeln ('NO');\n end."}, {"source_code": "const\n fin = 'GOSLEEP.INP'; fout = 'GOSLEEP.OUT';\nvar\n s: string;\n i: longint;\n\n begin\n //assign(input, fin); reset(input);\n //assign(output, fout); rewrite(output);\n readln(s);\n for i:= length(s) downto 1 do\n if (s[i] <> ' ') and (s[i] <> '?') then\n case s[i] of\n 'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', 'Y', 'y':\n begin\n writeln('YES');\n halt;\n end;\n else\n begin\n writeln('NO');\n halt;\n end;\n end;\n //close(input); close(output);\n end.\n"}, {"source_code": "var\n s:ansistring;\n j:longint;\nbegin\n readln(s);\n s:=upcase(s);\n j:=length(s);\n while not(s[j] in ['A'..'Z']) do\n dec(j);\n if s[j] in ['A','E','I','O','U','Y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var k,i:longint;s:string;\nbegin\nreadln(s);\ni:=length(s)-1;\nwhile s[i-k]=' ' do inc(k);\nif ((s[i-k]='a')or(s[i-k]='A')or(s[i-k]='e')or(s[i-k]='E')or(s[i-k]='i')or(s[i-k]='I')or(s[i-k]='o')or(s[i-k]='O')or(s[i-k]='u')or(s[i-k]='U')or(s[i-k]='y')or(s[i-k]='Y')) then\nwriteln('YES')\nelse\nwriteln('NO');\nend.\n"}, {"source_code": "const\n x=['a','e','i','o','u','y'];\n y=['A','E','I','O','U','Y'];\nvar\n s:string[100];\n i:longint;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n if s[i] in ['a'..'z','A'..'Z'] then\n begin\n if (s[i] in x) or (s[i] in y) then write('YES')\n else write('NO');\n exit;\n end;\nend."}, {"source_code": "var\ni,j,c,d,e,b,n:longint;\ns,s1,s2,s3,s4:string;\nbegin\nread(s);\ns:=lowercase(s);\nfor i:=length(s) downto 1 do\nif s[i] in ['a'..'z'] then begin j:=i;break;end;\nif s[j] in ['a','i','e','o','u','y'] then writeln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "program aneh;\nvar s:string;\n found:boolean;\n i:integer;\nbegin\n readln(s);\n i:=length(s);\n found:=false;\n while not(found) and (i>0) do\n begin\n if ((ord(s[i])>64) and (ord(s[i])<91))or((ord(s[i])>96) and (ord(s[i])<125)) then found:=true else dec(i);\n end;\n if (found) then\n begin\n case (s[i]) of\n 'a','e','u','i','o','y','A','E','I','O','U','Y':writeln('YES');\n else writeln('NO');\n end;\n end;\nend."}, {"source_code": "program sleuth;\nvar s,c:string;\ni,gar:integer;\nbegin\n readln (s);\n gar:=length(s);\n i:=gar;\n while (s[i]=' ') or (s[i]='?') do\n begin\n dec(i);\n end;\n c:=s[i];\n if (c='a') or (c='e') or (c='i') or (c='o') or (c='u') or (c='y') or (c='Y') or (c='U') or (c='O') or \n\n(c='I') or (c='E') or (c='A') then\n begin\n writeln ('YES');\n end\n else\n begin\n writeln ('NO');\n end;\nend."}, {"source_code": "var\n st: string;\n i: integer;\n c: char;\n\nbegin\n \n readln(st);\n \n for i:=Length(st) downto 1 do\n if (st[i] in ['a'..'z']) or (st[i] in ['A'..'Z']) then begin c:=st[i]; break; end;\n \n case c of\n 'A': write('YES');\n 'E': write('YES');\n 'I': write('YES');\n 'O': write('YES');\n 'U': write('YES');\n 'Y': write('YES');\n 'a': write('YES');\n 'e': write('YES');\n 'i': write('YES');\n 'o': write('YES');\n 'u': write('YES');\n 'y': write('YES');\n else write('NO');\n end;\nend."}, {"source_code": "var n,k,i:integer;\ns,c:string;\nbegin\nreadln(s);\nk:=length(s)-1;\nif s[k]=' ' then begin\n repeat\n k:=k-1;\n until s[k]<>' ';\n c:=s[k];\n end\n else c:=s[k];\n\nif (c='a') or (c='e') or (c='i') or (c='o') or (c='u') or (c='y') or (c='A') or (c='E') or (c='I') or (c='O') or (c='U')\n or (c='Y') then write('YES')\nelse write('NO');\nreadln;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nuses sysutils;\nvar s : ansistring;\n i : integer;\nbegin\n Readln(s);\n s := upcase(s);\n for i:= length(s) - 1 downto 1 do if s[i] <> ' ' then\n begin\n if s[i] in ['A', 'E', 'I','O', 'U', 'Y' ] then Writeln('YES') else\n Writeln('NO'); halt; break; end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var s,a,b:string;\n i,j:integer;\nbegin\n b:='BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvxwz';\n a:='aeiyouAEIOUY';\n readln(s);\n for i:=length(s) downto 1 do\n begin\n for j:=length(a) downto 1 do\n if a[j]=s[i] then begin\n writeln('YES');\n exit;\n end;\n for j:=length(b) downto 1 do\n if b[j]=s[i] then begin\n writeln('NO');\n exit;\n end;\n end;\nend."}, {"source_code": "var s:string;\n i:longint;\nbegin\n readln(s);\n s:=upcase(s);\n i:=length(s);\n while not((s[i] in ['a'..'z'])or(s[i] in ['A'..'Z'])) do\n i:=i-1;\n case s[i] of\n 'A','E','I','O','U','Y':writeln('YES');\n else writeln('NO');\n end;\nend."}, {"source_code": "var s:string;\nbegin\nread(s);\ns:=upcase(s);\nwhile not(s[length(s)] in['A'..'Z']) do \n delete(s,length(s),1);\nif s[length(s)] in['A','E','I','O','U','Y'] then write('YES') else write('NO');\nend."}, {"source_code": "{q+,r+,i+,o-,s+}\ntype\n int32=longint;\n bool=boolean;\nconst\n g=6;\n g1:array[1..6] of char=('A','E','I','O','U','Y');\n g2:array[1..6] of char=('a','e','i','o','u','y');\nvar\n i :int32;\n s :string;\nprocedure f1(x :char);\nbegin\n for i:=1 to g do\n if g1[i]=x then\n begin\n write('YES');\n halt(0);\n end;\n write('NO');\n halt(0);\nend;\nprocedure f2(x :char);\nbegin\n for i:=1 to g do\n if g2[i]=x then\n begin\n write('YES');\n halt(0);\n end;\n write('NO');\n halt(0);\nend;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readln(s);\n for i:=length(s) downto 1 do\n begin\n if (ord(s[i])>=65)and (ord(s[i])<=90) then f1(s[i]);\n if (ord(s[i])>=97)and(ord(s[i])<=122) then f2(s[i]);\n end;\nend.\n"}, {"source_code": "var\ns,st:string;\ni:longint;\nj:char;\n begin\n for j:='A' to 'Z' do\n st:=st+j;\n readln(s);\n s:=upcase(s);\n i:=length(s);\n while pos(s[i],st)=0 do \n dec(i);\n\n if s[i] in['A','E','I','O','U','Y'] THEN writeln('YES') else writeln('NO');\n end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n var S,T : String;\n i : Integer;\n\nbegin\nreadln(S);\nfor i := 1 to Length(S) do T := T + LowerCase(S[Length(S) - (i-1)]);\ni := 1;\nwhile not((T[i] >= 'a') and (T[i] <= 'z')) do i := i + 1;\nif ((T[i]='a')or(T[i]='e')or(T[i]='i')or(T[i]='o')or(T[i]='u')or(T[i]='y')) then WriteLn('YES') else WriteLn('NO');\nreadln;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n var n,i,m,x:longint; a,b:array [1..10000] of char; p:boolean;\nbegin\ni:=0;\nwhile not eoln do begin\ni:=i+1;\nread(a[i])\nend;\np:=false;\ni:=i-1;\nx:=1;\nwhile x=1 do begin\nif ord(a[i])=32 then i:=i-1 else x:=2;\nend;\nif a[i]='A' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='a' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='E' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='e' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='I' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='i' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='O' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='o' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='U' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='u' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='Y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif p=false then writeln('NO');\nreadln;\nreadln;\nend.\n"}, {"source_code": "var\n st:string;\nprocedure yb;\nvar i:longint;\nbegin\n delete(st,length(st),1);\n i:=length(st);\n while st[i]=' ' do begin delete(st,i,1);dec(i);end;\nend;\nbegin\n readln(st);\n yb;\n if st[length(st)] in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var \n a,b,i:longint;\n s,x:string;\nbegin\n b:=0;\n readln(s);\n i:=length(s)-1;\n while (s[i-b]='?')or(s[i-b]=' ')do\n begin\n b:=b+1;\n end;\n if (s[i-b]='a')or(s[i-b]='A')or(s[i-b]='e')or(s[i-b]='E')or(s[i-b]='i')or(s[i-b]='I')or(s[i-b]='o')or(s[i-b]='O')or(s[i-b]='u')or(s[i-b]='U')or(s[i-b]='y')or(s[i-b]='Y') then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "program hrn;//#2\n var\n s:string;\n i,l:longint;\n begin\n read(s);\n l:=length(s)+1;\n repeat\n l:=l-1;\n i:=ord(s[l]);\n until((i>=65)and(i<=90))or((i>=97)and(i<=122));\n if(i>=65)and(i<=90)then i:=i+32;\n if(i=97)or(i=101)or(i=105)or(i=111)or(i=117)or(i=121)then write('YES')\n else write('NO');\n end.\n"}, {"source_code": "program task;\nvar s:string;\n i:byte;\nbegin\n readln(s);\n i:=length(s)-1;\n while (s[i]=' ') do\n dec(i);\n if s[i]in['A','E','I','O','U','Y',\n 'a','e','i','o','u','y'] then\n writeln('YES')\n else\n writeln('NO')\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s: string;\n i: integer;\n\nbegin\n //reset(input, 'input.txt');rewrite(output, 'output.txt');\n readln(s);\n for i := length(s) downto 1 do\n begin\n if not\n ((s[i] <> 'a') and (s[i] <> 'A') and\n (s[i] <> 'e') and (s[i] <> 'E') and\n (s[i] <> 'i') and (s[i] <> 'I') and\n (s[i] <> 'o') and (s[i] <> 'O') and\n (s[i] <> 'u') and (s[i] <> 'U') and\n (s[i] <> 'y') and (s[i] <> 'Y')) then\n begin\n writeln('YES');\n halt;\n end;\n if not\n ((s[i] <> 'b') and (s[i] <> 'B') and\n (s[i] <> 'c') and (s[i] <> 'C') and\n (s[i] <> 'd') and (s[i] <> 'D') and\n (s[i] <> 'f') and (s[i] <> 'F') and\n (s[i] <> 'g') and (s[i] <> 'G') and\n (s[i] <> 'h') and (s[i] <> 'H') and\n (s[i] <> 'j') and (s[i] <> 'J') and\n (s[i] <> 'k') and (s[i] <> 'K') and\n (s[i] <> 'l') and (s[i] <> 'L') and\n (s[i] <> 'm') and (s[i] <> 'M') and\n (s[i] <> 'n') and (s[i] <> 'N') and\n (s[i] <> 'p') and (s[i] <> 'P') and\n (s[i] <> 'q') and (s[i] <> 'Q') and\n (s[i] <> 'r') and (s[i] <> 'R') and\n (s[i] <> 's') and (s[i] <> 'S') and\n (s[i] <> 't') and (s[i] <> 'T') and\n (s[i] <> 'v') and (s[i] <> 'V') and\n (s[i] <> 'w') and (s[i] <> 'W') and\n (s[i] <> 'x') and (s[i] <> 'X') and\n (s[i] <> 'z') and (s[i] <> 'Z')) then\n begin\n writeln('NO');\n halt;\n end;\n end;\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n buk=['a'..'z','A'..'Z'];\n gl=['a','e','i','o','u','y','A','E','I','O','U','Y'];\nVar\n s:String;\n f,i:Integer;\nBegin\n ReadLn(s);\n f:=0;\n For i:=1 To length(s) Do\n If s[i] in buk Then\n If s[i] in gl Then f:=1\n Else f:=0;\n If f=1 Then Write('YES')\n Else Write('NO');\nEnd.\n"}, {"source_code": "var ok : boolean;\n q : char;\n k : longint;\n begin\n ok := true;\n while q <> '?' do\n begin\n read(q);\n if q in ['a'..'z','A'..'Z'] then\n begin\n if q in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then ok := true\n else ok := false;\n k := k + 1;\n end;\n end;\n if k <> 0 then\n if ok then writeln('YES')\n else writeln('NO');\n end."}, {"source_code": "var s:string;\n i,j,k:longint;\nbegin\n readln(s);\n s:=lowercase(s);\n k:=length(s);\n while (s[k]<'a')or(s[k]>'z') do k:=k-1;\n if (s[k]='a')or(s[k]='e')or(s[k]='i')\n or(s[k]='o')or(s[k]='u')or(s[k]='y') then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\ns,st:string;\ni:longint;\nj:char;\n begin\n for j:='A' to 'Z' do\n st:=st+j;\n readln(s);\n s:=upcase(s);\n i:=length(s);\n while pos(s[i],st)=0 do \n dec(i);\n\n if s[i] in['A','E','I','O','U','Y'] then writeln('YES') else writeln('NO');//因为是大写,所以不必判断是不是小写字符\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction max(a,b:longint):longint;\nbegin\n if a=ord('a'))and(ORD(S[I])<=ord('z')))and\n not((ORD(S[I])>=ord('A'))and(ORD(S[I])<=ord('Z'))) do dec(i);\n case s[i] of\n 'a': BEGIN writeln('YES'); halt(0); end;\n 'e': BEGIN writeln('YES'); halt(0); end;\n 'o': BEGIN writeln('YES'); halt(0); end;\n 'u': BEGIN writeln('YES'); halt(0); end;\n 'y': BEGIN writeln('YES'); halt(0); end;\n 'i': BEGIN writeln('YES'); halt(0); end;\n 'A': BEGIN writeln('YES'); halt(0); end;\n 'E': BEGIN writeln('YES'); halt(0); end;\n 'Y': BEGIN writeln('YES'); halt(0); end;\n 'I': BEGIN writeln('YES'); halt(0); end;\n 'O': BEGIN writeln('YES'); halt(0); end;\n 'U': BEGIN writeln('YES'); halt(0); end;\n end;\n writeln('NO');\n\n\nend.\n"}, {"source_code": "var s:string;\n i:longint;\nbegin\n read(s);\n for i:=length(s) downto 1 do\n if (s[i]<='z')and(s[i]>='a')or(s[i]<='Z')and(s[i]>='A') then break;\n if (s[i]='A')or(s[i]='E')or(s[i]='I')or(s[i]='O')or(s[i]='U')or(s[i]='Y')or(s[i]='a')or(s[i]='e')or(s[i]='i')or(s[i]='o')or(s[i]='u')or(s[i]='y')\n then write('YES') else write('NO');\nend.\n \n"}, {"source_code": "var s:string;\nx:Integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(s);\n x:=Length(s);\n while not (s[x] in ['a'..'z','A'..'Z'])do\n begin\n Dec(x);\n end;\n if s[x]in['A', 'E', 'I', 'O', 'U', 'Y','a','e','i','o','u','y']\n then Writeln('YES')\n else Writeln('NO');\nend.\n"}, {"source_code": "program Project_sushik;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n i,f,k:integer;\nbegin\nread(s);\nfor i:=length(s) downto 1 do\n begin\n if (s[i]<>' ') and (s[i]<>'?') then\n begin\n s1:=s[i]; break;\n end;\n end;\nif ((s1='a') or (s1='A') or(s1='e') or\n (s1='E') or (s1='i') or (s1='I') or\n (s1='o') or (s1='O') or (s1='u') or\n (s1='U') or (s1='Y') or (s1='Y'))\n then write('YES') else write('NO');\nread(f);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "var s:string;\n a,i:longint;\nbegin\nreadln(s);\na:=length(s);\nfor i:=a-1 downto 1 do\nif s[i]<>' ' then\nbreak;\nif (s[i]='A')or(s[i]='a')or(s[i]='E')or(s[i]='e')or(s[i]='I')or(s[i]='i')or(s[i]='O')or(s[i]='o')or(s[i]='U')or(s[i]='u')or(s[i]='Y')or(s[i]='y')then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n s:ansistring;\n i:longint;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n if (s[i] in ['a'..'z','A'..'Z']) then\n begin\n if (pos(s[i],'aeiouyAEIOUY')>0) then writeln('YES') else\n writeln('NO');\n halt(0);\n end;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\nvar\n s: string;\n a1, b1, a2, b2:set of char;\n i: integer;\nbegin\n readln(s);\n i := 1;\n a1 := ['A', 'E', 'I','O', 'U', 'Y'];\n a2 := ['a', 'e', 'i', 'o', 'u', 'y'];\n b1 := ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Z'];\n b2 := ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'];\n while i <> length(s) do\n if (s[length(s)-i] in ['A'..'Z']) or (s[length(s)-i] in ['a'..'z']) then\n begin\n if (s[length(s)-i] in a1) or (s[length(s)-i] in a2) then\n begin\n writeln('YES');\n exit;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end\n else\n inc(i);\nend.\n"}, {"source_code": "program PrA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n StrUtils;\n\nvar s: string;\n i: longint;\n\nbegin\n readln(s);\n s := UpperCase(s);\n for i := length(s)downto 1 do\n if (ord(s[i]) >= ord('A'))and(ord(s[i]) <= ord('Z'))then\n begin\n if (s[i] = 'A')or(s[i] = 'E')or(s[i] = 'I')or\n (s[i] = 'O')or(s[i] = 'U')or(s[i] = 'Y')then\n writeln('YES') else\n writeln('NO');\n halt(0);\n end;\n\nend.\n "}, {"source_code": "program giylmi;\n\n{$APPTYPE CONSOLE} {$o- r- q+}\n\nuses\n SysUtils, Math;\n\nvar\n s: string;\n i: integer;\n b: boolean;\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(s);\n i := length(s) + 1;\n b := true;\n while b do begin\n dec(i);\n if ((s[i] >= 'a') and (s[i] <= 'z')) or\n ((s[i] >= 'A') and (s[i] <= 'Z')) then\n b := false;\n end;\n if s[i] <= 'Z' then\n s[i] := chr(ord(s[i]) + 32);\n case s[i] of\n 'a': begin write('YES'); halt(0); end;\n 'e': begin write('YES'); halt(0); end;\n 'i': begin write('YES'); halt(0); end;\n 'o': begin write('YES'); halt(0); end;\n 'u': begin write('YES'); halt(0); end;\n 'y': begin write('YES'); halt(0); end;\n end;\n write('NO');\nend.\n"}, {"source_code": "var a,b,c,d,e,f : longint;\ns : string;\nbegin\nreadln (s);\nfor a := length(s) downto 1 do begin\nif (s[a]<>' ') and (s[a]<>'?') and (s[a]<>',') and (s[a]<>'.') then begin\nif (s[a] = 'a') or (s[a] = 'e') or (s[a] = 'i') or (s[a] = 'o') or (s[a] = 'u') or (s[a] = 'y') or\n(s[a] = 'A') or (s[a] = 'E') or (s[a] = 'I') or (s[a] = 'O') or (s[a] = 'U') or (s[a] = 'Y')\nthen writeln ('YES')\nelse writeln ('NO');\nbreak;\nend;\nend;\nend."}, {"source_code": "program Syshik;\n\n{$APPTYPE CONSOLE}\n\nvar\ns : string;\ni : byte;\nfl : boolean;\nsym : set of char;\nbegin\nreadln (s);\nsym:=[];\nsym:=sym+['i']+['o']+['a']+['e']+['u']+['y']+['I']+['O']+['A']+['E']+['U']+['Y'];\nfl:=true;\ni:=length (s);\nwhile fl and (i>=1) do\nbegin\nif ((ord(s [i])>=ord('a')) and (ord(s [i])<=ord('z'))) or ((ord(s [i])>=ord('A')) and (ord(s [i])<=ord('Z'))) then\nbegin\nif s [i] in sym then write ('YES')\nelse write ('NO');\nfl:=false;\nend;\ndec (i);\nend;\nend.\n"}, {"source_code": "var\n s:string;\n i:integer;\nbegin\n read(s);\n for i:=length(s) downto 1 do if (s[i] in ['a'..'z'])or(s[i] in ['A'..'Z']) then begin\n if (s[i] in ['A','E','I','O','U','Y'])or(s[i] in ['a','e','i','o','u','y']) then write('YES') else write('NO');\n halt;\n end; \nend."}, {"source_code": "Var i:longint;\n s,a:string;\n f:boolean;\n\nBegin\n\n a:='aeiouyAEIOUY';\n readln(s);\n\n i:=1;\n while i 0) and not(s[length(s)] in ['a'..'z','A'..'Z']) do delete(s, length(s), 1);\n if (s[length(s)] in ['a','e','i','o','u','y','A','E','I','O','U','Y']) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n m: integer;\n s, l: string;\n\nbegin\n read(s);\n m := length(s);\n repeat\n m := m - 1;\n until s[m] <> ' ';\n \n \n l := 'euoiayEYUIOA';\n if pos(s[m], l) <> 0 then \n writeln('YES');\n \n l := 'bcdfghjklmnpqrrstvwxzBCDFGHJKLMNPQRSTVWXZ';\n if pos(s[m], l) <> 0 then \n writeln('NO')\n \n \n \n \nend."}, {"source_code": "uses sysutils;\nvar s:string;\ni:integer;\nbegin\nreadln(s);\ns:=lowercase(s);i:=length(s);\nwhile not (s[i] in ['a'..'z']) do dec(i);\nif s[i] in ['a','e','i','o','u','y'] then writeln('YES') else writeln('NO');\nend."}, {"source_code": "\n{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\n\nprogram kk;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst glas = ['A','E','I','O','U','Y','a','e','i','o','u','y'];\n\nvar s : string;\n element : char;\n i : longint;\n\nbegin\n\n readln(s);\n\n for i:=length(s) downto 1 do begin\n if (s[i] in ['a'..'z']) or (s[i] in ['A'..'Z']) then begin\n element := s[i];\n break;\n end;\n end;\n\n if element in glas then writeln('YES')\n else writeln('NO');\n\nend.\n"}, {"source_code": "program Pq;\nuses\nSysUtils;\nvar\ns:string;\nj,l,i:longint;\nconst\na:array[1..12]of char=('A','E','I','O','U','Y','a','e','i','o','u','y');\nbegin\n//reset(input,'input.txt');rewrite(output,'output.txt');\nread(s);\nl:=length(s);\nfor i:=l-1 downto 1 do\nif s[i]<>' 'then\nbegin\nfor j:=1 to 12 do\nif s[i]=a[j] then\nbegin\nwrite('YES');\nhalt(0);\nend;\nwrite('NO');\nhalt(0);\nend;\nend.\n"}, {"source_code": "program _49A;\nvar\n s :string;\n i : longint;\nbegin\n read(s);\n i := length(s) - 1;\n while s[i] = ' ' do\n dec(i);\n if UpCase(s[i]) in ['A', 'E', 'I', 'O', 'U', 'Y']\n then write('YES')\n else write('NO');\nend."}, {"source_code": "Var oz,i:longint;\ns:string;\nbegin\nreadln(s);\ni:=1;\nwhile i<=length(s) do begin\nif s[i]=' ' then delete(s,i,1) else i:=i+1;\nend;\ns:=Upcase(s);\noz:=0;\ncase s[length(s)-1] of\n'A':oz:=1;\n'E':oz:=1;\n'I':oz:=1;\n'O':oz:=1;\n'U':oz:=1;\n'Y':oz:=1;\nend;\nif oz=1 then writeln('YES') else writeln('NO');\nend.\n\n"}, {"source_code": "uses sysutils;\nvar s:string;\n i:byte;\n c:char;\nbegin\n readln(s);\n s:=uppercase(s);\n delete(s,pos('?',s),length(s));\n for i:=length(s) downto 1 do\n if s[i] in['A'..'Z']then begin c:=s[i]; break end;\n if c in['A','E','Y','U','I','O']then writeln('YES')else writeln('NO');\nend."}, {"source_code": "var s, gl, sogl, res: string;\ni, j:integer;\nc: char;\nbegin\nreadln(s);\ni:=length(s) - 1;\nfor j:=i downto 1 do\nif s[j] <> ' ' then begin c := s[j]; break; end;\nc := lowcase(c);\ngl := 'aeuioy';\nif gl.Contains(c) then write('YES')\nelse write('NO');\nend."}, {"source_code": "program detective;\nvar\n s:string[100];\n l:integer;\nbegin\n read(s);\n l:=length(s)-1;\n while s[l]=' 'do dec(l);\n case s[l] of\n 'a','e','i','o','u','y','A','E','I','O','U','Y':writeln('YES');\n else writeln('NO');\n end;\nend."}, {"source_code": "var\n e,r:longint;\n s:string;\nbegin\nreadln(s);\ne:=length(s);\nwhile (s[e]='?') or (s[e]=' ') do\n e:=e-1;\nif (s[e]='a') or (s[e]='e') or (s[e]='i') or (s[e]='o') or (s[e]='y') or (s[e]='u') then r:=1;\nif (s[e]='A') or (s[e]='E') or (s[e]='I') or (s[e]='O') or (s[e]='Y') or (s[e]='U') then r:=1;\nif r=1 then write('YES') else write('NO');\nend."}, {"source_code": "program codeforces_round46_a;\n\nconst\n a = 'AEIOUYaeiouy';\n\nvar\n s : string;\n i : byte;\n\nbegin\n read(s);\n for i:=length(s) downto 1 do\n if (s[i] in ['a'..'z']) or (s[i] in ['A'..'Z'])\n then begin\n if pos(s[i], a) <> 0\n then write('YES')\n else write('NO');\n break;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar s:string;\n n,i,x:integer;\nbegin\nreadln(s);\nn:=length(s);\nfor i:=n downto 1 do\n if s[i] in ['a'..'z','A'..'Z'] then begin x:=i; break; end;\n//writeln(x,' ',s[x]);\nif (pos(s[x],'AEIOUY')<>0) or (pos(s[x],'aeiouy')<>0) then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "program task46_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n str: string;\n g: set of char;\n k: set of char;\n i: integer;\nbegin\n Readln(str);\n g:=['a','i','o','y','u','e', 'A','I','O','Y','U','E'];\n k:=[' ','?'];\n i:=Length(str);\n while (i>=1) do\n begin\n if (str[i] in k) then Dec(i)\n else\n if (str[i] in g) then\n begin\n Writeln('YES');\n break;\n end\n else\n begin\n Writeln('NO');\n break;\n end;\n end;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program Syshik;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n var str:string;\n i,n:integer;\nbegin\nreadln(str);\nn:=length(str)-1;\nwhile str[n]=' ' do\ndec(n);\nif str[n] in ['A','E','I','O','U','Y','a','e','i','o','u','y']then write('YES')\nelse write('NO');\n { TODO -oUser -cConsole Main : Insert code here }\nend."}, {"source_code": "program p7;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..10000] of string;\n x,y,k,l,m,n,i,j,p:longint;\n s,t,u:string;\nbegin\nreadln(s);\nfor i:=length(s) downto 1 do\nif (s[i] in ['A'..'Z']) or (s[i] in ['a'..'z']) then begin p:=i; break; end;\nif (s[p]='A') or (s[p]='E') or (s[p]='I') or (s[p]='O') or (s[p]='U') or (s[p]='Y')\n or (s[p]='a') or (s[p]='e') or (s[p]='i') or (s[p]='o') or (s[p]='u') or (s[p]='y')\n then write('YES') else write('NO');\nend.\n "}, {"source_code": "program aaaa1;\n\n{$APPTYPE CONSOLE} {$O-}\n\nuses\n SysUtils;\n\nvar\n i: longint;\n s, ss, c: string;\nbegin\n { reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n readln(s);\n ss:='AEOUYIaeouyi';\n c:='qwrtpsdfghjklzxcvbnmQWRTPSDFGHJKLZXCVBNM';\n for i:=length(s) downto 1 do begin\n if pos(s[i], ss)<>0 then begin write('YES'); halt end;\n if pos(s[i], c)<>0 then begin write('NO'); halt end;\n end;\n \nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n list=array[1..1000000]of integer;\nvar\n a,b:list;\n n,k,p,i,j,h,l,g,c,e,k1,y,k2,z,m,k3,k4:Integer;\n s:string;\nprocedure quicksort(var b:list; left,right:integer);\nvar\n i,j,temp,p:integer;\nbegin\n i:=left;\n j:=right;\n p:=b[(left+right)div 2];\n repeat\n while(b[i]p) do dec(j);\n if(i<=j)then begin\n temp:=b[i];\n b[i]:=b[j];\n b[j]:=temp;\n inc(i);\n dec(j);\n end;\n until(i>j);\n if(j>left)then quicksort(b,left,j);\n if(i' ') and (s[i]<>'.') and (s[i]<>',') and (s[i]<>'!') then\n begin\n if (s[i]='a') or (s[i]='e') or (s[i]='i') or (s[i]='o') or (s[i]='u') or (s[i]='y') or (s[i]='A') or (s[i]='E') or (s[i]='I') or (s[i]='O') or (s[i]='U') or (s[i]='Y') then\n begin\n writeln('YES');\n exit;\n end\n else\n begin\n writeln('NO');\n exit;\n end;\n end;\n if (s[i]=' ') or (s[i]='.') or (s[i]=',') or (s[i]='!') then\n begin\n i:=i-1;\n end;\n end;\nend.\n"}, {"source_code": "program Project2;\nVar s:string;\nc:Char;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(s);\n while (s[Length(s)]='?')or(s[Length(s)]=' ') do\n Delete(s,Length(s),1);\n c:=s[Length(s)];\n if (c='A')or(c='U')or(c='E')or(c='O')or(c='I')or(c='Y')or(c='a')or(c='u')or(c='e')or(c='o')or(c='i')or(c='y')\n then Writeln('YES')\n else Writeln('NO');\nend.\n"}, {"source_code": "program problemA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n fayl:Text;\n s:string;\nbegin\n readln(s);\n while not (s[length(s)] in ['A'..'Z','a'..'z']) do delete(S,length(s),1);\n if upcase(S[length(S)]) in ['A','E','I','O','Y','U'] then write('YES') else write('NO');\n \n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n const\n EngG=['A','E','I','O','U','Y','a','e','i','o','u','y'];\n EngS=['B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Z',\n 'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','z'];\n Eng=EngG+EngS;\nvar s:string;\n k:byte;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(s);\n k:=length(s);\n while not (s[k] in Eng) do\n k:=k-1;\n if s[k] in EngS then\n writeln('NO')\n else\n writeln('YES');\nend."}, {"source_code": "var S : string[100];\n i : longint;\nbegin\n readln(S);\n i := length(S);\n while not((ord(S[i]) in [97..122]) or (ord(S[i]) in [65..90])) do dec(i);\n case S[i] of\n 'a', 'e', 'i', 'o', 'u', 'y' : writeln('YES');\n 'A', 'E', 'I', 'O', 'U', 'Y' : writeln('YES');\n else writeln('NO');\n end;\nend."}], "negative_code": [{"source_code": "{$R+,S+,Q+,I+,O-}\n{$APPTYPE CONSOLE}\nconst v:set of char=['A', 'E', 'I', 'O', 'U', 'Y'];\nvar s:string; i:longint;\nbegin\nreadln(s);\ni:=length(s);\nwhile (not(s[i] in ['A'..'Z'])) and (not(s[i] in ['a'..'z'])) do dec(i);\nif (chr(ord(s[i])+32) in v) or (s[i] in v) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n var n,i,m,x:longint; a,b:array [1..10000] of char; p:boolean;\nbegin\ni:=0;\nwhile not eoln do begin\ni:=i+1;\nread(a[i])\nend;\np:=false;\nif a[i-1]='A' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='a' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='I' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='i' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='O' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='o' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='U' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='u' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='Y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i-1]='y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif p=false then writeln('NO');\nreadln;\nreadln;\nend.\n"}, {"source_code": "const a:array[1..10]of char=('A','E','I','O','U','a','e','i','o','u');\nvar s:string;i,j:longint;f:boolean;\nbegin\n readln(s);\n for i:=length(s)downto 1 do\n begin\n if (s[i] in['A'..'Z'])or(s[i]in['a'..'z'])then\n begin\n f:=false;\n for j:=1 to 10 do\n if a[j]=s[i] then f:=true;\n if f then writeln('YES')\n else writeln('NO');\n halt;\n end;\n end;\nend.\n"}, {"source_code": "var\ns,a,b:string;\ni,j:integer;\nbegin\nread(s);\na:='AEIOUYaeiouy';\nb:='QWRTPSDFGHJKLZXCVBNMqwrtpsdfghjklzxcvbnm';\nfor i:=length(s) downto 1 do\nif s[i]<>' ' then j:=i;\nfor i:=1 to length(a) do\nif s[j]=a[i] then writeln('YES');\nfor i:=1 to length(b) do\nif s[j]=b[i] then writeln('NO');\n\nend.\n"}, {"source_code": "var\n m: integer;\n s, l: string;\n\nbegin\n read(s);\n m := length(s);\n repeat\n m := m - 1;\n until s[m] <> ' ';\n \n \n l := 'euoiayEYUIOA';\n if pos(s[m], l) <> 0 then \n writeln('YES');\n \n l := 'bcdfghjklmnpqrrstvwBCDFGHJKLMNPQRSTVW';\n if pos(s[m], l) <> 0 then \n writeln('NO')\n \n \n \n \nend."}, {"source_code": "var\n\ti:longint;\n\tst:string;\nbegin\n\treadln(st);\n upcase(st);\n\tfor i:=length(st) downto 1 do\n\t\tif st[i] in ['a'..'z'] then\n\t\t\tif (st[i]='A') or (st[i]='E') or (st[i]='I') or (st[i]='O') or (st[i]='U') or (st[i]='Y') then\n\t\t\tbegin\n\t\t\t\twriteln('YES');\n\t\t\t\texit;\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln('NO');\n\t\t\t\texit;\n\t\t\tend;\nend.\n"}, {"source_code": "program anApple;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst c : array [1..12] of char = ('A', 'E', 'I', 'O', 'U', 'Y', 'a', 'e', 'i', 'o', 'u', 'y');\n\nvar\n s : string;\n i : integer;\n\nfunction isinc (ch : char) : boolean;\n\nvar\n i : byte;\n\nbegin\n for i := 1 to 12 do if ch = c [i] then begin\n isinc := True;\n Exit;\n end;\n isinc := False;\nend;\n\nbegin\n Readln (s);\n if isinc (s [Length (s)-1]) then Writeln ('YES') else Writeln ('NO');\n Readln;\nend.\n"}, {"source_code": "var\n\tn, h, m, r, x, sum, y: integer;\n\tflag: boolean = false;\n\ts, l: string;\n\t\nbegin\n\n\treadln(s);\n\t\n\tl := 'euoiayEYUIOA';\n\tfor var i := 1 to l.length do\n\tbegin\n\t\tif (s[s.length-1] = l[i]) then\n\t\tbegin\n\t\t\twriteln('YES');\n\t\t\tflag := true;\n\t\t\tbreak;\n\t\tend;\n\tend;\n\t\n\tif (flag <> true) then\n\t\twriteln('NO');\n\n\t\nend.\n"}, {"source_code": "program bangke;\nvar\n a : array [1..1000] of char;\n i : integer;\n x : char;\nbegin\n i := 0;\n repeat\n i := i + 1;\n read (a[i]);\n until eoln;\n\n repeat\n x := a[i];\n i := i - 1;\n until (a[i] <> '?') and (a[i] <> ' ');\n if (a[i] = 'a') or (a[i] = 'e') or (a[i] = 'i') or (a[i] = 'u') or (a[i] = 'o') or (a[i] ='y') then\n writeln ('YES')\n else\n writeln ('NO');\nend."}, {"source_code": "var s:string;\n l:longint;\nbegin\nread(s);\nl:=length(s);\nif (s[l-1]='A') or (s[l-1]='a') or\n (s[l-1]='Y') or (s[l-1]='y') or\n (s[l-1]='O') or (s[l-1]='o') or\n (s[l-1]='I') or (s[l-1]='i') or\n (s[l-1]='E') or (s[l-1]='e') or\n (s[l-1]='U') or (s[l-1]='u')\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n system;\n\nVar\n i:integer;\n s:string;\nbegin\n readln(s);\n i:=length(s)-1;\n if (s[i]='a') or (s[i]='e') or (s[i]='i') or (s[i]='o') or (s[i]='u') or (s[i]='y') or\n (s[i]='A') or (s[i]='E') or (s[i]='I') or (s[i]='O') or (s[i]='U') or (s[i]='Y') then\n writeln('YES')\n else\n writeln('NO');\nend.\n"}, {"source_code": "var s:string;\n k:integer;\nbegin\nreadln(s);\nfor k:=length(s) downto 1 do\n if((s[k]>='A')and(s[k]<='Z'))or((s[k]>='a')and(s[k]<='z'))then\n\n begin\n if(s[k]='A')or(s[k]='E')or(s[k]='I')or\n (s[k]='O')or(s[k]='U')or(s[k]='Y')then writeln('YES')else\n writeln('NO');\n break;\n end;\n\nend.\n\n\n"}, {"source_code": "var \n a:string;\n i,j,k,l:longint;\nbegin\n readln(a);\n for i:=length(a) downto 1 do\n begin\n if ((a[i]>='A') and (a[i]<='Z')) or ((a[i]<='z') and (a[i]>='a')) then\n begin\n case a[i] of\n 'A':begin writeln('YES'); readln; readln; exit; end;\n 'E':begin writeln('YES'); readln; readln; exit; end;\n 'I':begin writeln('YES'); readln; readln; exit; end;\n 'O':begin writeln('YES'); readln; readln; exit; end;\n 'U':begin writeln('YES'); readln; readln; exit; end;\n 'a':begin writeln('YES'); readln; readln; exit; end;\n 'e':begin writeln('YES'); readln; readln; exit; end;\n 'i':begin writeln('YES'); readln; readln; exit; end;\n 'o':begin writeln('YES'); readln; readln; exit; end;\n 'u':begin writeln('YES'); readln; readln; exit; end;\n 'y': begin writeln('YES'); readln; readln; exit; end;\n 'Y': begin writeln('YES'); readln; readln; exit; end;\n end;\n end;\n end;\n writeln('NO');\n readln;\n readln;\n \n \nend."}, {"source_code": "var\n cad:string[110];\n i,L:integer;\n c:set of char;\nbegin\n c:=['a','e','i','o','u','A','E','I','O','U'];\n readln(cad);\n L:=length(cad);\n while ((cad[L]<'a') or (cad[L]>'z'))AND (cad[L]<'A') or (cad[L]>'Z') do\n L:=L-1;\n if cad[L] in c then\n writeln('YES')\n ELSE\n writeln('NO');\nend.\n\n"}, {"source_code": "program anApple;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst c : array [1..12] of char = ('A', 'E', 'I', 'O', 'U', 'Y', 'a', 'e', 'i', 'o', 'u', 'y');\n\nvar\n s : string;\n i : integer;\n\nfunction isinc (ch : char) : boolean;\n\nvar\n i : byte;\n\nbegin\n for i := 1 to 12 do if ch = c [i] then begin\n isinc := True;\n Exit;\n end;\n isinc := False;\nend;\n\nbegin\n Readln (s);\n if isinc (s [Length (s)-1]) then Writeln ('YES') else Writeln ('NO');\n Readln;\nend.\n"}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif ((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) then\n begin\n if s[i] in['a','e','i','o','u','y'] then write('YES')\n else write('NO');\n if s[i] in['A','E','I','O','U','Y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var\n m: integer;\n s, l: string;\n\nbegin\n read(s);\n m := length(s);\n repeat\n m := m - 1;\n until s[m] <> ' ';\n \n \n l := 'euoiayEYUIOA';\n if pos(s[m], l) <> 0 then \n writeln('YES');\n \n l := 'bcdfghjklmnpqrrstvwBCDFGHJKLMNPQRSTVW';\n if pos(s[m], l) <> 0 then \n writeln('NO')\n \n \n \n \nend."}, {"source_code": "var s,s1:string;i,j,k:longint;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\ns1:='AEIOUYaeiouy';\nreadln(s);\ni:=length(s);\nwhile (i>=1)and(s[i]=' ')or(s[i]='?')do dec(i);\nif pos(s[i],s1)<>0 then writeln('YES') else writeln('No');\nend.\n"}, {"source_code": "var\n s:ansistring;\nbegin\n readln(s);\n if s[length(s)-2] in ['a','e','i','o','u','y','A','E','I','O','U','Y'] then\n writeln('YES') else writeln('NO');\nend."}, {"source_code": "program P49A;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\nvar\n s: string;\n i, k: longint;\nbegin\n read(s);\n k := 0;\n for i := 1 to length(s) - 1 do\n if(s[i] <> ' ') then\n k := i;\n if(s[k] = 'A') or (s[k] = 'E') or (s[k] = 'I')\n or (s[k] = 'O') or (s[k] = 'U') or (s[k] = 'Y') then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif (s[i]>='a') and (s[i]<='z') then\n begin\n if s[i] in['a','e','i','o','u','y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var\na:string;\nn:longint;\nbegin\nread(a);\nn:=length(a)-1;\nif (a[n]='A') or (a[n]='E') or (a[n]='I') or (a[n]='O') or (a[n]='U') or (a[n]='Y') or (a[n]='a') or (a[n]='e') or (a[n]='i') or (a[n]='o') or (a[n]='u') or (a[n]='y') then write('YES')\nelse write('NO');\nend."}, {"source_code": "var \n a,b,i:longint;\n s,x:string;\nbegin\n b:=0;\n readln(s);\n i:=length(s)-1;\n repeat\n if (s[i-b]='?')or(s[i-b]=' ') then inc(b)\n else break;\n until true;\n if (s[i-b]='a')or(s[i-b]='A')or(s[i-b]='e')or(s[i-b]='E')or(s[i-b]='i')or(s[i-b]='I')or(s[i-b]='o')or(s[i-b]='O')or(s[i-b]='u')or(s[i-b]='U')or(s[i-b]='y')or(s[i-b]='Y') then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "program zA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,ans:string;\n i:longint;\n\nbegin\n ans:='No';\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]in[' ','?'] then continue;\n if s[i] in ['a','e','i','o','u','y','A','E','I','O','U','Y']then ans:='YES' else ans:='No';\n end;\n writeln(ans);\nend.\n "}, {"source_code": "var\n s:string;\nbegin\n readln(s);\n if s[length(s)-1] in ['a','e','i','o','u','y','A','E','I','O','U','Y'] then\n writeln('YES') else writeln('NO');\nend."}, {"source_code": "var\n\ti:longint;\n\tst:string;\nbegin\n\treadln(st);\n upcase(st);\n\tfor i:=length(st) downto 1 do\n\t\tif st[i] in ['a'..'z'] then\n\t\t\tif (st[i]='A') or (st[i]='E') or (st[i]='I') or (st[i]='O') or (st[i]='U') or (st[i]='Y') then\n\t\t\tbegin\n\t\t\t\twriteln('YES');\n\t\t\t\texit;\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln('NO');\n\t\t\t\texit;\n\t\t\tend;\nend.\n"}, {"source_code": "var\n st:string;\nbegin\n readln(st);\n if st[length(st)-1] in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\na:string;\nn:longint;\nbegin\nread(a);\nn:=length(a);\nif (a[n]='A') or (a[n]='E') or (a[n]='I') or (a[n]='O') or (a[n]='U') or (a[n]='Y') then write('YES')\nelse write('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n var S,T : String;\n i : Integer;\n\nbegin\nreadln(S);\nfor i := 1 to Length(S) do T := T + LowerCase(S[Length(S) - (i-1)]);\ni := 1;\nwhile not((T[i] >= 'a') and (T[i] <= 'z')) do i := i + 1;\nif ((T[i]<>'A')and(T[i]<>'E')and(T[i]<>'I')and(T[i]<>'O')and(T[i]<>'U')and(T[i]<>'Y')) then WriteLn('YES') else WriteLn('NO');\nreadln;\nend."}, {"source_code": "program sleuth;\nvar\ns:string;\nbegin\nreadln(s);\nif lowercase(s[length(s)-1]) = 'a' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'e' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'i' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'o' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'u' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'y' then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program sleuth;\nvar\ns:string;\nc:char;\ni:integer;\nbegin\nreadln(s);\nfor i:=length(s) downto 1 do\nif (s[i]<>' ') and (s[i]<>'?') then begin c:=s[i]; break; end;\nif c='a' then writeln('YES') else\nif c='e' then writeln('YES') else\nif c='i' then writeln('YES') else\nif c='u' then writeln('YES') else\nif c='o' then writeln('YES') else\nif c='y' then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var\n s : String;\n\nfunction Check(c : Char) : Boolean;\nbegin\n if (('a' <= c) and (c <= 'z')) or (('A' <= c) and (c <= 'Z')) then\n Check := true\n else\n Check := false;\nend;\n\nbegin\n ReadLn(s);\n while not Check(s[Length(s)]) do Delete(s, Length(s), 1);\n if s[Length(s)] in ['A', 'E', 'I', 'O', 'U', 'Y'] then\n WriteLn('YES')\n else\n WriteLn('NO');\nend."}, {"source_code": "var\n st:string;\nbegin\n readln(st);\n if st[length(st)] in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s:string;\n t:char;\nbegin\n readln(s);\n while not(((s[length(s)]>='A')and(s[length(s)]<='Z'))or((s[length(s)]>='a')and(s[length(s)]<='z')))do\n delete(s,length(s),1);\n if (s[length(s)]='a')or(s[length(s)]='e')or(s[length(s)]='i')or(s[length(s)]='o')or(s[length(s)]='u')or(s[length(s)]='A')or(s[length(s)]='E')or(s[length(s)]='I')or(s[length(s)]='O')or(s[length(s)]='U')then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "var\n st:string;\nbegin\n readln(st);\n if st[length(st)] in ['A','E','I','O','U','Y','a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "program Syshik;\n\n{$APPTYPE CONSOLE}\n\nvar\ns : string;\ni : byte;\nfl : boolean;\nsym : set of char;\nbegin\nreadln (s);\nsym:=[];\nsym:=sym+['i']+['o']+['a']+['e']+['u']+['y'];\nfl:=true;\ni:=length (s);\nwhile fl and (i>=1) do\nbegin\nif ((ord(s [i])>=ord('a')) and (ord(s [i])<=ord('z'))) or ((ord(s [i])>=ord('A')) and (ord(s [i])<=ord('Z'))) then\nbegin\nif s [i] in sym then write ('YES')\nelse write ('NO');\nfl:=false;\nend;\ndec (i);\nend;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n i : longint;\n s : string;\n\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n Close(f);\n For i := 1 to length(s) do\n S[i] := upcase(s[i]);\n writeln(s);\n i := length(s);\n While (s[i] < 'A') or (s[i] > 'Z') do\n dec(i);\n Assign(f,fo);\n rewrite(F);\n If (s[i] = 'A') or (s[i] = 'E') or (s[i] = 'I') or (s[i] = 'U') or (s[i] = 'Y') then\n Writeln(f,'YES')\n else Writeln(f,'NO');\n Close(f);\nEnd.\n"}, {"source_code": " \n \nvar s,a,b,c:string;\n k,i,j,m,n,la,lb:integer;\n g:char;\nbegin\nreadln;\n readln(s);\n a:=s;\n n:=0;\n m:=0;\n for i:=1 to length(s) div 2 do\n if s[2*i-1]=s[2*i] then begin s[2*i-1]:='1'; s[2*i]:='0'; inc(n); end;\n for i:=1 to length(s)-1 do\n if s[i]=s[i+1] then n:=-1;\n for i:=1 to length(a) div 2 do\n if a[2*i-1]=a[2*i] then begin a[2*i-1]:='0'; a[2*i]:='1'; inc(m); end;\n for i:=1 to length(a)-1 do\n if a[i]=a[i+1] then m:=-1;\n if ((n>m)or (n<0)) and (m>0) then writeln (m);\n if ((n0) and not (n-1=0) then writeln (n);\n if (n=m) then writeln(n);\n end."}, {"source_code": "var\n s:string;\n i:longint;\nbegin\n read(s);\n for i:=length(s) downto 1 do\n if (s[i]>='A') and (s[i]<='z') then\n if s[i] in ['a','e','i','o','u','A','E','I','O','U'] then begin write('YES'); break; end\n else begin write('NO'); break; end;\nEND."}, {"source_code": "var s:string;\nprocedure sleuth;\nbegin\n write('YES');\n halt;\nend;\nbegin\n read(s);\n if upcase(s[length(s)-1])='A' then sleuth\n else if upcase(s[length(s)-1])='E' then sleuth\n else if upcase(s[length(s)-1])='I' then sleuth\n else if upcase(s[length(s)-1])='O' then sleuth\n else if upcase(s[length(s)-1])='U' then sleuth\n else if upcase(s[length(s)-1])='Y' then sleuth;\n write('NO');\nend."}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif (s[i]>='a') and (s[i]<='z') then\n begin\n if s[i] in['a','e','i','o','u','y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var s:string;\n l:longint;\nbegin\nread(s);\nl:=length(s);\nif (s[l-1]='A') or (s[l-1]='a') or\n (s[l-1]='Y') or (s[l-1]='y') or\n (s[l-1]='O') or (s[l-1]='o') or\n (s[l-1]='I') or (s[l-1]='i') or\n (s[l-1]='E') or (s[l-1]='e') or\n (s[l-1]='U') or (s[l-1]='u')\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n st:string;\n begin\n readln(st);\n if (st[length(st)-1]='A') or\n (st[length(st)-1]='E') or\n (st[length(st)-1]='I') or\n (st[length(st)-1]='O') or\n (st[length(st)-1]='U') or\n (st[length(st)-1]='Y') then\n begin\n writeln('YES');\n halt;\n end;\n writeln('NO');\n end.\n"}, {"source_code": "var\ns,a,b:string;\ni,j:integer;\nbegin\nread(s);\na:='AEIOUYaeiouy';\nb:='QWRTPSDFGHJKLZXCVBNMqwrtpsdfghjklzxcvbnm';\nfor i:=length(s) downto 1 do\nif s[i]<>' ' then j:=i;\nfor i:=1 to length(a) do\nif s[j]=a[i] then writeln('YES');\nfor i:=1 to length(b) do\nif s[j]=b[i] then writeln('NO');\n\nend.\n"}, {"source_code": "var\n s:string;\n i:longint;\nbegin\n read(s);\n for i:=length(s) downto 1 do\n if (s[i]>='A') and (s[i]<='z') then\n if s[i] in ['a','e','i','o','u','A','E','I','O','U'] then begin write('YES'); break; end\n else begin write('NO'); break; end;\nEND."}, {"source_code": "const a:array[1..10]of char=('A','E','I','O','U','a','e','i','o','u');\nvar s:string;i,j:longint;f:boolean;\nbegin\n readln(s);\n for i:=length(s)downto 1 do\n begin\n if (s[i] in['A'..'Z'])or(s[i]in['a'..'z'])then\n begin\n f:=false;\n for j:=1 to 10 do\n if a[j]=s[i] then f:=true;\n if f then writeln('YES')\n else writeln('NO');\n halt;\n end;\n end;\nend.\n"}, {"source_code": "var\n\ti:longint;\n\tst:string;\nbegin\n\treadln(st);\n upcase(st);\n\tfor i:=length(st) downto 1 do\n\t\tif st[i] in ['A'..'Z'] then\n\t\t\tif (st[i]='A') or (st[i]='E') or (st[i]='I') or (st[i]='O') or (st[i]='U') or (st[i]='Y') then\n\t\t\tbegin\n\t\t\t\twriteln('YES');\n\t\t\t\texit;\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln('NO');\n\t\t\t\texit;\n\t\t\tend;\nend.\n"}, {"source_code": " \n \nvar s,a,b,c:string;\n k,i,j,m,n,la,lb:integer;\n g:char;\nbegin\nreadln;\n readln(s);\n a:=s;\n n:=0;\n m:=0;\n for i:=1 to length(s) div 2 do\n if s[2*i-1]=s[2*i] then begin s[2*i-1]:='1'; s[2*i]:='0'; inc(n); end;\n for i:=1 to length(s)-1 do\n if s[i]=s[i+1] then n:=-1;\n for i:=1 to length(a) div 2 do\n if a[2*i-1]=a[2*i] then begin a[2*i-1]:='0'; a[2*i]:='1'; inc(m); end;\n for i:=1 to length(a)-1 do\n if a[i]=a[i+1] then m:=-1;\n if ((n>m)or (n<0)) and (m>0) then writeln (m);\n if ((n0) and not (n-1=0) then writeln (n);\n if (n=m) then writeln(n);\n end."}, {"source_code": "var\n s : String;\n\nfunction Check(c : Char) : Boolean;\nbegin\n if (('a' <= c) and (c <= 'z')) or (('A' <= c) and (c <= 'Z')) then\n Check := true\n else\n Check := false;\nend;\n\nbegin\n ReadLn(s);\n while not Check(s[Length(s)]) do Delete(s, Length(s), 1);\n if s[Length(s)] in ['A', 'E', 'I', 'O', 'U', 'Y'] then\n WriteLn('YES')\n else\n WriteLn('NO');\nend."}, {"source_code": "var s:string;\n l:longint;\nbegin\nread(s);\nl:=length(s);\nwhile s[l]<>'?' do\n dec(l);\nif (s[l-1]='A') or (s[l-1]='a') or\n (s[l-1]='Y') or (s[l-1]='y') or\n (s[l-1]='O') or (s[l-1]='o') or\n (s[l-1]='I') or (s[l-1]='i') or\n (s[l-1]='E') or (s[l-1]='e') or\n (s[l-1]='U') or (s[l-1]='u')\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var s,s1,s2:string;\nvar i,j,n,m:longint;\nx:array[1..100] of char;\nbegin\n readln(s);\n m:=length(s);\n\n while ( s[m-1]=' ') do\n begin\n\n m:=length(s);\n s[m-1]:=s[m-2];\n\n delete(s,length(s)-1,1);\n end;\n\n\n m:=length(s);\n s2:=s[m-1];\n\n if s[m-1] in (['a','A','e','E','i','I','o','O','u','U','y','Y'])\n then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n\ti:longint;\n\tst:string;\nbegin\n\treadln(st);\n upcase(st);\n\tfor i:=length(st) downto 1 do\n\t\tif st[i] in ['a'..'z'] then\n\t\t\tif (st[i]='A') or (st[i]='E') or (st[i]='I') or (st[i]='O') or (st[i]='U') or (st[i]='Y') then\n\t\t\tbegin\n\t\t\t\twriteln('YES');\n\t\t\t\texit;\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln('NO');\n\t\t\t\texit;\n\t\t\tend;\nend.\n"}, {"source_code": "var\n i:longint;\n s:string;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n begin\n if s[i] in ['a'..'z'] then begin\n if (s[i]='a')or(s[i]='e')or(s[i]='i')or(s[i]='o')or(s[i]='u')or(s[i]='y') then writeln('YES')\n else writeln('NO');\n break;\n end\n else if s[i] in ['A'..'Z'] then begin\n if (s[i]='A')or(s[i]='E')or(s[i]='I')or(s[i]='O')or(s[i]='U')or(s[i]='Y') then writeln('YES')\n else writeln('NO');\n end\n end;\nend."}, {"source_code": "program P49A;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\nvar\n s: string;\n i, k: longint;\nbegin\n read(s);\n k := 0;\n for i := 1 to length(s) - 1 do\n if(s[i] <> ' ') then\n k := i;\n if(s[k] = 'A') or (s[k] = 'E') or (s[k] = 'I')\n or (s[k] = 'O') or (s[k] = 'U') or (s[k] = 'Y') then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "var\n s : String;\n\nfunction Check(c : Char) : Boolean;\nbegin\n if (('a' <= c) and (c <= 'z')) or (('A' <= c) and (c <= 'Z')) then\n Check := true\n else\n Check := false;\nend;\n\nbegin\n ReadLn(s);\n while not Check(s[Length(s)]) do Delete(s, Length(s), 1);\n if s[Length(s)] in ['A', 'E', 'I', 'O', 'U', 'Y'] then\n WriteLn('YES')\n else\n WriteLn('NO');\nend."}, {"source_code": "Var s:string; k:byte;\nBegin\nreadln(s);\nk:=Pos('?',S);\nwhile s[k-1]=' ' do\ndelete(s,k-1,1);\nif (s[k-1]='a') or (s[k-1]='e') or (s[k-1]='i') or (s[k-1]='o') or\n(s[k-1]='u') or (s[k-1]='y') or (s[k-1]='A') or (s[k-1]='E') or\n(s[k-1]='I') or (s[k-1]='O') or (s[k-1]='U') or (s[k-1]='Y') then\nwriteln('YES') else writeln('NO');\nend."}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif ((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) then\n begin\n if s[i] in['a','e','i','o','u','y'] then\n begin\n write('YES');\n continue;\n end\n else\n begin\n write('NO');\n continue;\n end;\n if s[i] in['A','E','I','O','U','Y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "program Syshik;\n\n{$APPTYPE CONSOLE}\n\nvar\ns : string;\ni : byte;\nfl : boolean;\nsym : set of char;\nbegin\nreadln (s);\nsym:=[];\nsym:=sym+['i']+['o']+['a']+['e']+['u']+['y'];\nfl:=true;\ni:=length (s);\nwhile fl and (i>=1) do\nbegin\nif ((ord(s [i])>=ord('a')) and (ord(s [i])<=ord('z'))) or ((ord(s [i])>=ord('A')) and (ord(s [i])<=ord('Z'))) then\nbegin\nif s [i] in sym then write ('YES')\nelse write ('NO');\nfl:=false;\nend;\ndec (i);\nend;\nend.\n"}, {"source_code": "var s:string;\n l:longint;\nbegin\nread(s);\nl:=length(s);\nwhile s[l]<>'?' do\n dec(l);\nif (s[l-1]='A') or (s[l-1]='a') or\n (s[l-1]='Y') or (s[l-1]='y') or\n (s[l-1]='O') or (s[l-1]='o') or\n (s[l-1]='I') or (s[l-1]='i') or\n (s[l-1]='E') or (s[l-1]='e') or\n (s[l-1]='U') or (s[l-1]='u')\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n st:string;\n begin\n readln(st);\n st:=upcase(st); \n if (st[length(st)-1]='A') or\n (st[length(st)-1]='E') or\n (st[length(st)-1]='I') or\n (st[length(st)-1]='O') or\n (st[length(st)-1]='U') or\n (st[length(st)-1]='Y') then\n begin\n writeln('YES');\n halt;\n end;\n writeln('NO');\n end.\n"}, {"source_code": "program z;\n var\n s:string;\n l:integer;\n begin\n readln(s);\n l:=length(s);\n if (s[l-1]='a')or(s[l-1]='e')or(s[l-1]='i')or(s[l-1]='o')or(s[l-1]='u')or(s[l-1]='y')\n or(s[l-1]='A')or(s[l-1]='E')or(s[l-1]='I')or(s[l-1]='O')or\n (s[l-1]='U')or(s[l-1]='Y') then write('YES') else write('NO');\nend."}, {"source_code": "var\n ca,c,d,s:string;\n i,n,ch,j,m,a,b:int64;\nbegin\n readln(s); ca:=' a e i o u y '; c:=' q w e r t y u i o p a s d f g h j k l z x c v b n m ';\n for i:=1 to length(s) do\n if pos(' '+lowercase(s[i])+' ',c)<>0 then d:=d+s[i];\n if length(d)=0 then writeln('NO') else\n if pos(' '+d[length(d)]+' ',ca)<>0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif ((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) then\n begin\n if s[i] in['a','e','i','o','u','y'] then write('YES')\n else write('NO');\n if s[i] in['A','E','I','O','U','Y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "const z='AEIOUY';\nVar i:longint;\n s:string;\nBegin\n { assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n Readln(s);\n delete(s,length(s),1);\n i:=length(s);\n While s[i]=' ' do dec(i);\n if pos(s[i],z)<>0\n then writeln('YES')\n else writeln('NO');\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n var n,i,m,x:longint; a,b:array [1..10000] of char; p:boolean;\nbegin\ni:=0;\nwhile not eoln do begin\ni:=i+1;\nread(a[i])\nend;\np:=false;\ni:=i-1;\nx:=1;\nwhile x=1 do begin\nif ord(a[i])=32 then i:=i-1 else x:=2;\nend;\nif a[i]='A' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='a' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='I' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='i' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='O' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='o' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='U' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='u' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='Y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif a[i]='y' then begin writeln('YES'); readln; readln; p:=true; halt(0); end;\nif p=false then writeln('NO');\nreadln;\nreadln;\nend.\n"}, {"source_code": "var\n s:ansistring;\nbegin\n readln(s);\n if s[length(s)-1] in ['a','e','i','o','u','y','A','E','I','O','U','Y'] then\n writeln('YES') else writeln('NO');\nend."}, {"source_code": "program sleuth;\nvar s,c:string;\ni,gar:integer;\nbegin\n readln (s);\n gar:=length(s);\n i:=gar;\n while (s[i]=' ') or (s[i]='?') do\n begin\n dec(i);\n end;\n c:=s[i];\n if (c='a') or (c='e') or (c='i') or (c='o') or (c='u') or (c='y') then\n begin\n writeln ('YES');\n end\n else \n begin\n writeln ('NO');\n end;\nend."}, {"source_code": "Var s:string; k:byte;\nBegin\nreadln(s);\nk:=Pos('?',S);\nwhile s[k-1]=' ' do\ndelete(s,k-1,1);\nif (s[k-1]='a') or (s[k-1]='e') or (s[k-1]='i') or (s[k-1]='o') or\n(s[k-1]='u') or (s[k-1]='y') or (s[k-1]='A') or (s[k-1]='E') or\n(s[k-1]='I') or (s[k-1]='O') or (s[k-1]='U') or (s[k-1]='Y') then\nwriteln('YES') else writeln('NO');\nend."}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif ((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) then\n begin\n if s[i] in['a','e','i','o','u','y'] then write('YES')\n else write('NO');\n if s[i] in['A','E','I','O','U','Y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "Var i:longint;\n s,a:string;\n f:boolean;\n\nBegin\n\n a:='aeiouyAEIOUY';\n readln(s);\n\n f:=false;\n for i:=1 to length(a) do\n if s[length(s)-1]=a[i] then begin\n f:=true;\n break;\n end;\n\n\n if f then writeln('YES') else\n writeln('NO');\n\nEnd."}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nuses sysutils;\nvar s : ansistring;\n i : integer;\nbegin\n Readln(s);\n s := upcase(s);\n for i:= length(s) - 1 downto 1 do if s[i] <> ' ' then\n if s[i] in ['A', 'E', 'I','O', 'U', 'Y' ] then Writeln('YES') else\n Writeln('NO');\nend."}, {"source_code": "var\n s:string;\nbegin\n readln(s);delete(s,length(s),1);\n s:=lowercase(s);\n if s[length(s)] in ['a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "program Syshik;\n\n{$APPTYPE CONSOLE}\n\nvar\ns : string;\nsym : set of char;\nbegin\nreadln (s);\nsym:=[];\nsym:=sym+['i']+['o']+['a']+['e']+['u']+['y'];\nif s [length(s)-1] in sym then write ('YES')\nelse write ('NO');\nend.\n"}, {"source_code": "var s:string;\n t:char;\nbegin\n readln(s);\n while not(((s[length(s)]>='A')and(s[length(s)]<='Z'))or((s[length(s)]>='a')and(s[length(s)]<='z')))do\n delete(s,length(s),1);\n if (s[length(s)]='a')or(s[length(s)]='e')or(s[length(s)]='i')or(s[length(s)]='o')or(s[length(s)]='u')or(s[length(s)]='A')or(s[length(s)]='E')or(s[length(s)]='I')or(s[length(s)]='O')or(s[length(s)]='U')then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "program P49A;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\nvar\n s: string;\n i, k: longint;\nbegin\n read(s);\n if(s[length(s) - 1] = 'A') or (s[length(s) - 1] = 'E') or (s[length(s) - 1] = 'I')\n or (s[length(s) - 1] = 'O') or (s[length(s) - 1] = 'U') or (s[length(s) - 1] = 'Y') then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "var last, ch : char ;\n\n\nbegin\nlast := 'a';\n\nwhile not seekeof do \nbegin\n read(ch);\n if ((ord(ch) >= ord('a')) and (ord(ch) <= ord('z'))) or((ord(ch) >= ord('A')) and (ord(ch) <= ord('Z'))) then\n last := ch;\nend;\nif (ord(last) >= ord('a')) and (ord(last) <= ord('z')) then \n begin\n ch := chr(ord(ch) - ord('a') + ord('A'));\n end;\nif (ch = 'A') or (ch = 'E') or(ch = 'I') or(ch = 'O') or(ch = 'U') or(ch = 'Y') then write('YES')\nelse write('NO');\n\nend.\n"}, {"source_code": "program sleuth;\nvar\ns:string;\nbegin\nreadln(s);\nif lowercase(s[length(s)-1]) = 'a' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'e' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'i' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'o' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'u' then writeln('YES') else\nif lowercase(s[length(s)-1]) = 'y' then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,k,i:integer;\ns,c:string;\nbegin\nreadln(s);\nk:=length(s)-1;\nif s[k]=' ' then begin\n repeat\n k:=k-1;\n until s[k]<>' ';\n c:=s[k];\n end\n else c:=s[k];\n\nif (c='a') or (c='e') or (c='i') or (c='o') or (c='u') or (c='y') then write('YES')\nelse write('NO');\nreadln;\nend.\n"}, {"source_code": " var\n s1:ansistring;\n s:char;\n begin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(s1);\n s:=s1[length(s1)-1];\n s:= upcase(s);\n if (s='A')or(s='E')or(s='I')or(s='O')or(s='U')or(s='Y')\n then\n writeln('YES')\n else\n writeln('NO');\n end.\n"}, {"source_code": "var s:string;\nn:dword;\n\nbegin\nreadln(s);\nif pos(s[length(s)-1], 'AEIOUYaeiouy')>1 then\n writeln('YES')\nelse\n writeln('NO');\nend."}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nuses sysutils;\nvar s : ansistring;\nbegin\n Readln(s);\n s := upcase(s);\n if s[length(s) - 1] in ['A', 'E', 'I','O', 'U', 'Y' ] then Writeln('YES') else\n Writeln('NO');\nend."}, {"source_code": "var last, ch : char ;\n\n\nbegin\nlast := 'a';\n\nwhile not seekeof do \nbegin\n read(ch);\n if ((ord(ch) >= ord('a')) and (ord(ch) <= ord('z'))) or((ord(ch) >= ord('A')) and (ord(ch) <= ord('Z'))) then\n last := ch;\nend;\nwriteln(last);\nif (ord(last) >= ord('a')) and (ord(last) <= ord('z')) then \n begin\n last := chr(ord(last) - ord('a') + ord('A'));\n end;\nwriteln(last);\nif (ch = 'A') or (ch = 'E') or(ch = 'I') or(ch = 'O') or(ch = 'U') or(ch = 'Y') then write('YES')\nelse write('NO');\n\nend.\n"}, {"source_code": "program sleuth;\nconst fi='';\n fo='';\nvar s:string;i:longint;\nbegin\nassign(input,fi);reset(input);\nassign(output,fo);rewrite(output);\nread(s);\nfor i:=length(s) downto 1 do\nif ((s[i]>='a') and (s[i]<='z')) or ((s[i]>='A') and (s[i]<='Z')) then\n begin\n if s[i] in['a','e','i','o','u','y'] then\n begin\n write('YES');\n continue;\n end\n else\n begin\n write('NO');\n continue;\n end;\n if s[i] in['A','E','I','O','U','Y'] then write('YES')\n else write('NO');\n break;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var\n\ti:longint;\n\tst:string;\nbegin\n\treadln(st);\n upcase(st);\n\tfor i:=length(st) downto 1 do\n\t\tif st[i] in ['a'..'z'] then\n\t\t\tif (st[i]='A') or (st[i]='E') or (st[i]='I') or (st[i]='O') or (st[i]='U') or (st[i]='Y') then\n\t\t\tbegin\n\t\t\t\twriteln('YES');\n\t\t\t\texit;\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\twriteln('NO');\n\t\t\t\texit;\n\t\t\tend;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar s:string;\n n,i,x:integer;\nbegin\nreadln(s);\nn:=length(s);\nfor i:=n downto 1 do\n if s[i] in ['a'..'z','A'..'Z'] then x:=i;\nif (pos(s[x],'AEIOUY')<>0) or (pos(s[x],'aeiouy')<>0) then write('YES')\n else write('NO');\nend."}, {"source_code": "var a,b,c,d,e,f : longint;\ns : string;\nbegin\nreadln (s);\nfor a := length(s) downto 1 do begin\nif (s[a]<>' ') and (s[a]<>'?') and (s[a]<>',') and (s[a]<>'.') then begin\nif (s[a] = 'a') or (s[a] = 'e') or (s[a] = 'i') or (s[a] = 'o') or (s[a] = 'u') or (s[a] = 'y')\nthen writeln ('YES')\nelse writeln ('NO');\nbreak;\nend;\nend;\nend."}, {"source_code": "var\n cad:string[110];\n i,L:integer;\n c:set of char;\nbegin\n c:=['a','e','i','o','u','A','E','I','O','U'];\n readln(cad);\n L:=length(cad);\n while (cad[L]<'a') or (cad[L]>'z') do\n L:=L-1;\n if cad[L] in c then\n writeln('YES')\n ELSE\n writeln('NO');\nend.\n\n"}, {"source_code": "program detective;\nvar\n s:string[100];\nbegin\n read(s);\n case s[length(s)-1] of\n 'a','e','i','o','u','y','A','E','I','O','U','Y':writeln('YES');\n else writeln('NO');\n end;\nend."}, {"source_code": "var a:string;\n i:longint;\nbegin\n read(a);\n for i:=length(a) downto 1 do\n begin\n if (ord(a[i])>=65) and (ord(a[i])<=90) then\n begin\n if (a[i]='A') or (a[i]='E') or (a[i]='I') or (a[i]='O') or (a[i]='U') or (a[i]='Y')\n then\n begin\n writeln('YES');\n exit;\n end;\n end;\n if (ord(a[i])>=97) and (ord(a[i])<=122) then\n begin\n if (a[i]='a') or (a[i]='e') or (a[i]='i') or (a[i]='o') or (a[i]='u') or (a[i]='y')\n then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\n end;\nend.\n"}, {"source_code": "var s:string;\n l:longint;\nbegin\nread(s);\nl:=length(s);\nwhile s[l]<>'?' do\n dec(l);\nif (s[l-1]='A') or (s[l-1]='a') or\n (s[l-1]='Y') or (s[l-1]='y') or\n (s[l-1]='O') or (s[l-1]='o') or\n (s[l-1]='I') or (s[l-1]='i') or\n (s[l-1]='E') or (s[l-1]='e') or\n (s[l-1]='U') or (s[l-1]='u')\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n s:string;\nbegin\n readln(s);delete(s,length(s),1);\n s:=lowercase(s);\n if s[length(s)] in ['a','e','i','o','u','y'] then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s, gl, sogl, res: string;\ni, j:integer;\nc: char;\nbegin\nreadln(s);\ni:=length(s) - 1;\nfor j:=i downto 1 do\nif s[i] <> ' ' then begin c := s[i]; break; end;\nc := lowcase(c);\ngl := 'aeuioy';\nif gl.Contains(c) then write('YES')\nelse write('NO');\nend."}, {"source_code": "program zA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,ans:string;\n i:longint;\n\nbegin\n ans:='No';\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]in[' ','?'] then continue;\n if s[i] in ['a','e','i','o','u','y','A','E','I','O','U','Y']then ans:='YES' else ans:='No';\n end;\n writeln(ans);\nend.\n "}, {"source_code": "Var i:longint;\n s,a:string;\n f:boolean;\n\nBegin\n\n a:='aeiouyAEIOUY';\n readln(s);\n\n f:=false;\n for i:=1 to length(a) do\n if s[length(s)-1]=a[i] then begin\n f:=true;\n break;\n end;\n\n\n if f then writeln('YES') else\n writeln('NO');\n\nEnd."}, {"source_code": "var\n\tn, h, m, r, x, sum, y: integer;\n\ts, l: string;\n\t\nbegin\n\n\treadln(s);\n\t\n\tl := 'euoiayEYUIOA';\n\tif (pos(s[s.length - 1], l) <> 0) then\n\t\twriteln('YES');\n\t\n\tl := 'bcdfghjklmnpqrrstvwxzBCDFGHJKLMNPQRSTVWXZ';\n\tif (pos(s[s.length - 1], l) <> 0) then\n\t\twriteln('NO');\n\n\t\nend.\n"}, {"source_code": "var s, gl, sogl, res: string;\ni, j:integer;\nc: char;\nbegin\nreadln(s);\ni:=length(s) - 1;\nfor j:=i downto 1 do\nif s[i] <> ' ' then begin c := s[i]; break; end;\nc := lowcase(c);\ngl := 'aeuioy';\nif gl.Contains(c) then write('YES')\nelse write('NO');\nend."}, {"source_code": "var x:string;\n n,i:integer;\nbegin readln(x);\n n:=length(x);\n while pos(' ',x)<>0 do\n delete (x,pos(' ',x),1);\n delete(x,n,1);\n n:=length(x);\n for i:=1 to n do\n x[i]:=upcase(x[i]);\n x:=x[n];\n if (x='A')or(x='E')or(x='I')or(x='J')or(x='O')or(x='U')or(x='Y') then\n writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "const a:array[1..12] of char=('a','e','i','o','u','y','A','E','I','O','U','Y');\nvar s:string;\n I:byte;\nbegin\nread(s);\nfor i:=1 to 12 do\nif s[length(s)-1]=a[i] then begin write('YES'); halt; end;\nwrite('NO');\nend. "}, {"source_code": "var n,k,i:integer;\ns,c:string;\nbegin\nreadln(s);\nk:=length(s)-1;\nif s[k]=' ' then begin\n repeat\n k:=k-1;\n until s[k]<>' ';\n c:=s[k];\n end\n else c:=s[k];\n\nif (c='a') or (c='e') or (c='i') or (c='o') or (c='u') or (c='y') then write('YES')\nelse write('NO');\nreadln;\nend.\n"}, {"source_code": "var s, gl, sogl, res: string;\ni, j:integer;\nc: char;\nbegin\nreadln(s);\ni:=length(s) - 1;\nfor j:=i downto 1 do\nif s[i] <> ' ' then begin c := s[i]; break; end;\nc := lowcase(c);\ngl := 'aeuioy';\nif gl.Contains(c) then write('YES')\nelse write('NO');\nend."}], "src_uid": "dea7eb04e086a4c1b3924eff255b9648"} {"source_code": "const\n maxn=1000011;\n maxm=1000000009;\n\nvar\n ans,tt:int64;\n n:longint;\n f:array[0..maxn]of int64;\n\nprocedure main;\nvar\n i,j:longint;\nbegin\n readln(n);\n f[0]:=1;\n for i:=1 to n do\n f[i]:=(2*f[i-1]+3) mod maxm;\n ans:=1; tt:=1;\n for i:=3 to n do\n begin\n if (i and 1)>0 then\n tt:=(tt*f[(i-3)>>1])mod maxm;\n ans:=(ans+tt) mod maxm;\n end;\n ans:=(4*ans*ans+1)mod maxm;\n ans:=(2*ans) mod maxm;\n writeln(ans);\nend;\n\nbegin\n main;\nend.", "positive_code": [{"source_code": "var\n a,b,i,j,k,p,n:longint;\n f,g,v,cc:array [0..500000] of longint;\n xx:extended;\nfunction mm(x:extended):longint;\n begin\n mm:= trunc(x-trunc(x/p)*p);\n end;\nfunction qq(x:longint):longint;\n var y:int64;\n begin\n if x=1 then \n begin\n qq:=2;\n exit;\n end;\n y:=qq( x div 2);\n y:=y*y;\n if x mod 2=1 then y:=y*2;\n qq:=mm(y);\n end;\nbegin\n p:=1000000009;\n f[1]:=10; f[2]:=74;\n readln(n);\n n:=n div 2;\n g[1]:=5; v[1]:=24; cc[1]:=5;\n for i:=2 to n-2 do\n begin\n g[i]:=g[i-1]+qq(i+1);\n g[i]:=mm(g[i]);\n cc[i]:=mm(int64(cc[i-1])*g[i]);\n v[i]:=mm(int64(v[i-1])+int64(cc[i])*4);\n end;\n if n>=3 then\n begin\n xx:=mm(int64(v[n-2])*v[n-2]);\n xx:=xx+int64(v[n-2])*4;\n xx:=xx*2;\n f[n]:=mm(int64(trunc(xx))+f[1]);\n end;\n writeln(f[n]);\nend. "}, {"source_code": "var\n a,b,i,j,k,p,n:longint;\n f,g,v,cc,qc:array [0..500000] of int64;\n xx:int64;\nfunction mm(x:int64):int64;\n begin\n mm:= x mod p;\n end;\nfunction qq(x:longint):int64;\n var y:int64;\n begin\n if qc[x]<>0 then\n begin\n qq:=qc[x];\n exit;\n end;\n if x=1 then\n begin\n qq:=2;\n exit;\n end;\n y:=qq( x div 2);\n y:=y*y;\n if x mod 2=1 then y:=y*2;\n qq:=mm(y);\n qc[x]:=mm(y);\n end;\nbegin\n p:=1000000009;\n f[1]:=10; f[2]:=74;\n readln(n);\n n:=n div 2;\n g[1]:=5; v[1]:=24; cc[1]:=5;\n for i:=2 to n-2 do\n begin\n g[i]:=g[i-1]+qq(i+1);\n g[i]:=mm(g[i]);\n cc[i]:=mm(cc[i-1]*g[i]);\n v[i]:=mm(v[i-1]+cc[i]*4);\n end;\n if n>=3 then\n begin\n xx:=mm(v[n-2]*v[n-2]);\n xx:=xx+v[n-2]*4;\n xx:=xx*2;\n f[n]:=mm(xx+f[1]);\n end;\n writeln(f[n]);\nend.\n"}, {"source_code": "var\n a,b,i,j,k,p,n:longint;\n f,g,v,cc,qc:array [0..500000] of extended;\n xx:extended;\nfunction mm(x:extended):extended;\n begin\n mm:= trunc(x-trunc(x/p)*p);\n end;\nfunction qq(x:longint):extended;\n var y:extended;\n begin\n if qc[x]<>0 then\n begin\n qq:=qc[x];\n exit;\n end;\n if x=1 then\n begin\n qq:=2;\n exit;\n end;\n y:=qq( x div 2);\n y:=y*y;\n if x mod 2=1 then y:=y*2;\n qq:=mm(y);\n qc[x]:=mm(y);\n end;\nbegin\n p:=1000000009;\n f[1]:=10; f[2]:=74;\n readln(n);\n n:=n div 2;\n g[1]:=5; v[1]:=24; cc[1]:=5;\n for i:=2 to n-2 do\n begin\n g[i]:=mm(g[i-1]+qq(i+1));\n cc[i]:=mm(cc[i-1]*g[i]);\n v[i]:=mm(v[i-1]+cc[i]*4);\n end;\n if n>=3 then\n begin\n xx:=v[n-2]*v[n-2];\n xx:=xx+v[n-2]*4;\n xx:=xx*2;\n f[n]:=mm(xx+f[1]);\n end;\n writeln(f[n]:0:0);\nend.\n\n\n"}, {"source_code": "CONST\n fin='';\n fon='';\nVAR n,kq: INT64;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nPROCEDURE CHUONG_TRINH;\n VAR a,b,c: INT64;\n BEGIN\n readln(n);\n a:=1;\n b:=2;\n c:=4;\n while n>2 do\n begin\n c:=c*a MOD 1000000009;\n b:=(b+c) MOD 1000000009;\n a:=(a*2+3) MOD 1000000009;\n n:=n-2;\n end;\n kq:=(b*b+1)*2;\n writeln(kq MOD 1000000009);\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n CHUONG_TRINH;\n KET_THUC;\nEND.\n"}, {"source_code": "const mo=1000000009;\nvar n,a,b,c:int64;\nbegin\n read(n);a:=1;b:=2;c:=4;\n while n>2 do\n begin\n c:=c*a mod mo;b:=(b+c)mod mo;a:=(a+a+3)mod mo;dec(n,2);\n end;\n writeln((b*b+1)*2 mod mo);\nend.\n"}, {"source_code": "program ctq;\nconst\n ff=1000000009;\nvar\n n:longint;\n x,y,z,ans:int64;\n\nbegin\n //assign(input,'15E.in');reset(input);\n\t// assign(output,'15E.out');rewrite(output);\n\t readln(n);\n\t x:=1; y:=2; z:=4;\n\t n:=n-2;\n\t while n>0 do\n\t begin\n\t z:=z*x mod ff;\n\t\t y:=(y+z) mod ff;\n\t\t x:=(2*x+3) mod ff;\n dec(n,2);\n\t end;\n\t ans:=(2*y*y+2) mod ff;\n\t writeln(ans);\n\t close(input);close(output);\nend.\n"}, {"source_code": "const\n base=1000000009;\nvar\n n,i:longint;\n f,g:array[0..1111111]of int64;\nbegin\n read(n);\n n:=n shr 1;\n g[0]:=0;\n for i:=1 to n do g[i]:=(g[i-1]+2)*2 mod base;\n f[0]:=0;\n for i:=1 to n-1 do \n f[i]:=(f[i-1]+4)*(g[n-i-1]+1)mod base;\n writeln(2*((f[n-1]+2)*(f[n-1]+2)+1) mod base);\nend.\n"}, {"source_code": "const mo=1000000009;\nvar\n i,n:longint;\n a,b,c:int64;\n\nbegin\n readln(n);\n a:=2;b:=2;c:=4;\n while n-2>0 do\n begin\n a:=(a*2) mod mo;\n c:=(c*(a-3)) mod mo;\n b:=(b+c) mod mo;\n n:=n-2;\n end;\n writeln(((b*b+1)*2 mod mo+mo) mod mo);\nend."}, {"source_code": "Program E15;\nVar\n modd,dq,ans,add,n:Int64;\nBegin\n modd:=1000000009;\n dq:=1;ans:=2;add:=4;\n Readln(n);\n While (n>2) Do Begin\n add:=add*dq Mod modd;\n ans:=(ans+add) Mod modd;\n dq:=(dq*2+3) Mod modd;\n n:=n-2; \n End;\n ans:=((ans*ans+1)*2)Mod modd;\n Writeln(ans);\nEnd.\n"}, {"source_code": "const p=1000000009;\nvar\n n,a,b,c:int64;\nbegin\n read(n);\n a:=1;b:=2;c:=4;\n while n>2 do\n begin\n c:=c*a mod p;\n b:=(b+c)mod p;\n a:=(a*2+3)mod p;\n dec(n,2);\n end;\n writeln(2*(b*b+1)mod p);\nend."}, {"source_code": "const md=1000000009;\nvar n,i:longint;\n d2,d:int64;\nbegin\n read(n);\n n:=n div 2;\n d:=1;\n for i:=3 to n do d:=(d*2+3)mod md;\n d2:=1;\n for i:=n-1 downto 1 do begin\n d2:=(1+d*(3+d2))mod md;\n d:=((d-3)*((md+1)div 2))mod md;\n end;\n writeln((4*d2+4+2*d2*d2)mod md);\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\nconst md=1000000009;\nvar n,i:longint;\n d:array[0..1000000]of int64;\n d2:int64;\nbegin\n readln(n);\n n:=n div 2;\n d[2]:=1;\n for i:=3 to n do d[i]:=(d[i-1]*2+3)mod md;\n d2:=1;\n for i:=n-1 downto 1 do d2:=(1+d[i+1]*(3+d2))mod md;\n writeln((4*d2+4+2*d2*d2)mod md);\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\ntype int=longint;\nconst md=1000000009;\nvar n,i:int;\n d,d2:array[0..1000000]of int64;\nbegin\n readln(n);\n n:=n div 2;\n d[2]:=1;\n for i:=3 to n do d[i]:=(d[i-1]*2+3)mod md;\n d2[n]:=1;\n for i:=n-1 downto 1 do d2[i]:=(1+d[i+1]*(3+d2[i+1]))mod md;\n writeln((4*d2[1]+4+2*d2[1]*d2[1])mod md);\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE 1000000000}\n{$D+,I+,L+,Q+,R+,S+,O-,H+}\n//{$D-,I-,L-,Q-,R-,S-,O+,H+}\nuses\n SysUtils,Math;\ntype int=longint;\nconst md=1000000009;\nvar n,i:int;\n d,d2:array[0..2000000]of int64;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n n:=n div 2;\n d[2]:=1;\n for i:=3 to n do d[i]:=(d[i-1]*2+3)mod md;\n d2[n]:=1;\n for i:=n-1 downto 1 do d2[i]:=(1+d[i+1]*(3+d2[i+1]))mod md;\n writeln((4*d2[1]+4+2*d2[1]*d2[1])mod md);\nend.\n "}, {"source_code": "const md=1000000009;\nvar n,i:longint;\n d:array[0..500000]of longint;\n d2:int64;\nbegin\n read(n);\n n:=n div 2;\n d[2]:=1;\n for i:=3 to n do d[i]:=(d[i-1]*2+3)mod md;\n d2:=1;\n for i:=n-1 downto 1 do d2:=(1+d[i+1]*(3+d2))mod md;\n writeln((4*d2+4+2*d2*d2)mod md);\nend.\n "}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nconst md = 1000000009;\nvar\n f: array [0..1000010] of int64;\n n,t,i: longint;\n ans,s: int64;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n);\n if n >= 4 then\n begin\n t:=(n-4) div 2;\n s:=1; f[0]:=1;\n for i:=1 to t do\n begin\n f[i]:=(f[i-1]+s*4) mod md;\n s:=(s*2) mod md;\n end;\n end;\n ans:=0; s:=1;\n for i:=1 to n shr 1 do\n begin\n if i > 1 then ans:=(ans+s*f[i-2]*4) mod md\n else ans:=2;\n if i > 1 then s:=(s*f[i-2]) mod md;\n end;\n writeln((ans*ans*2+2) mod md);\n close(input);\n close(output);\nend."}, {"source_code": "{$R-,S-,Q-,I-,O+}\nconst md = 1000000009;\nvar\n n,f,p,t: int64;\nbegin\n read(n);\n f:=1; p:=2; t:=4;\n while n > 2 do\n begin\n t:=(t*f) mod md;\n p:=(p+t) mod md;\n f:=(f*2+3) mod md;\n dec(n,2);\n end;\n writeln((p*p+1)*2 mod md);\nend."}], "negative_code": [{"source_code": "CONST\n fin='';\n fon='';\nVAR n,kq: INT64;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nPROCEDURE CHUONG_TRINH;\n VAR a,b,c: INT64;\n BEGIN\n readln(n);\n a:=1;\n b:=2;\n c:=4;\n while n>2 do\n begin\n c:=c*a MOD 1000000009;\n b:=(b+c) MOD 1000000009;\n a:=(SQR(a)+3) MOD 1000000009;\n n:=n-2;\n end;\n kq:=(SQR(b)+1)*2;\n writeln(kq MOD 1000000009);\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n CHUONG_TRINH;\n KET_THUC;\nEND.\n"}, {"source_code": "const\n base=1000000009;\n\nvar\n n,i:longint;\n f,g:array[0..1111111]of longint;\n\nbegin\n read(n);\n n:=n shr 1;\n g[0]:=0;\n for i:=1 to n do g[i]:=(g[i-1]+2)*2 mod base;\n f[0]:=1;\n for i:=1 to n do f[i]:=int64(f[i-1]+4)*(g[i-1]+1)mod base;\n writeln(int64(2)*((f[n-1]+1)*(f[n-1]+1)+1) mod base);\nend.\n"}, {"source_code": "const\n base=1000000009;\nvar\n n,i:longint;\n f,g:array[0..1111111]of longint;\nbegin\n read(n);\n n:=n shr 1;\n g[0]:=0;\n for i:=1 to n do g[i]:=(g[i-1]+2)*2 mod base;\n f[0]:=0;\n for i:=1 to n-1 do \n f[i]:=int64(f[i-1]+4)*(g[n-i-1]+1)mod base;\n writeln(int64(2)*((f[n-1]+2)*(f[n-1]+2)+1) mod base);\nend.\n"}, {"source_code": "const mo=1000000009;\nvar\n i,n:longint;\n a,b,c:int64;\n\nbegin\n readln(n);\n a:=2;b:=2;c:=4;\n while n>0 do\n begin\n a:=(a*2) mod mo;\n c:=(c*(a-3)) mod mo;\n b:=(b+c) mod mo;\n n:=n-2;\n end;\n writeln(((b*b+1)*2 mod mo+mo) mod mo);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE 1000000000}\n{$D+,I+,L+,Q+,R+,S+,O-,H+}\n//{$D-,I-,L-,Q-,R-,S-,O+,H+}\nuses\n SysUtils,Math;\ntype int=longint;\nconst md=1000000009;\nvar n,i:int;\n d,d2:array[0..2000000]of int64;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n readln(n);\n n:=n div 2;\n d[2]:=1;\n for i:=3 to n do d[i]:=(d[i-1]+3)mod md;\n d2[n]:=1;\n for i:=n-1 downto 1 do d2[i]:=(1+d[i+1]*(3+d2[i+1]))mod md;\n writeln((4*d2[1]+4+2*d2[1]*d2[1])mod md);\nend.\n "}, {"source_code": "var\n a,b,i,j,k,p,n:longint;\n f,g,v,cc,qc:array [0..500000] of extended;\n xx:extended;\nfunction mm(x:extended):extended;\n begin\n mm:= trunc(x-trunc(x/p)*p);\n end;\nfunction qq(x:longint):extended;\n var y:extended;\n begin\n if qc[x]<>0 then ;\n begin\n qq:=qc[x];\n exit;\n end;\n if x=1 then \n begin\n qq:=2;\n exit;\n end;\n y:=qq( x div 2);\n y:=y*y;\n if x mod 2=1 then y:=y*2;\n qq:=mm(y);\n qc[x]:=mm(y);\n end;\nbegin\n p:=1000000009;\n f[1]:=10; f[2]:=74;\n readln(n);\n n:=n div 2;\n g[1]:=5; v[1]:=24; cc[1]:=5;\n for i:=2 to n-2 do\n begin\n g[i]:=mm(g[i-1]+qq(i+1));\n cc[i]:=mm(cc[i-1]*g[i]);\n v[i]:=mm(v[i-1]+cc[i]*4);\n end;\n if n>=3 then\n begin\n xx:=v[n-2]*v[n-2];\n xx:=xx+v[n-2]*4;\n xx:=xx*2;\n f[n]:=mm(xx+f[1]);\n end;\n writeln(f[n]:0:0);\nend.\n"}], "src_uid": "dbcb1077e7421554ba5d69b64d22c937"} {"source_code": "var n,i,j:longint;\n a,b:array[0..50]of int64;\n ans,max:int64;\nbegin\n n:=14;\n ans:=0;\n max:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]>0 then\n begin\n for j:=1 to n do\n if i<>j then b[j]:=a[j]+a[i] div n;\n b[i]:=a[i] div n;\n for j:=i+1 to i+a[i] mod n do\n begin\n if j>n then break;\n inc(b[j]);\n end;\n for j:=1 to i+a[i] mod n-n do\n inc(b[j]);\n for j:=1 to n do\n if b[j] mod 2=0 then inc(ans,b[j]);\n if ans>max then max:=ans;\n ans:=0;\n for j:=1 to n do\n b[j]:=0;\n\n end;\n writeln(max);\nend.\n", "positive_code": [{"source_code": "var a,b:array[0..20]of longint ;i,j,k:longint;kc,z:int64;\nbegin\n for i:=0 to 13 do read (a[i]);\n z:=0;\n for i:=0 to 13 do\n begin\n if odd(a[i]) then begin\n b:=a;\n k:=a[i];\n b[i]:=0;\n for j:=0 to 13 do b[j]:=b[j]+k div 14;\n for j:=1 to k mod 14 do inc(b[(i+j) mod 14]);\n kc:=0;\n for j:=0 to 13 do if odd(b[j]) then else kc:=kc+b[j];\n if kc>z then z:=kc;\n end;\n end;\n write(z);\nend."}, {"source_code": "var a:array[1..14] of int64;\ni,j,k,l,m,n:int64;\n\nfunction p(x:int64):int64;\nvar b:array[1..14] of int64;\ni,j,k,l,m,n:int64;\nbegin\nfor i:=1 to 14 do\nb[i]:=a[i];\nk:=b[x];\nb[x]:=0;\nfor i:=1 to 14 do b[i]+=k div 14;\nk:=k mod 14;\nfor i:=x+1 to 14 do\nif k>0 then\nbegin\nb[i]+=1;\nk-=1\nend;\nfor i:=1 to x-1 do\nif k>0 then\nbegin\nb[i]+=1;\nk-=1\nend;\nfor i:=1 to 14 do if (b[i] mod 2=0) then l+=b[i];\np:=l\nend;\nbegin\nfor i:=1 to 14 do\nread(a[i]);\n\nfor i:=1 to 14 do\nif p(i)>m then m:=p(i);\nwrite(m)\nend."}, {"source_code": "var\n a, b: array[1..14] of int64;\n i, j, l, p, max: int64;\n\nbegin\n for i := 1 to 14 do read(a[i]);\n for i := 1 to 14 do \n begin\n p := 0;\n for j := 1 to 14 do b[j] := 0;\n if a[i] <> 0 then begin\n for j := 1 to 14 do \n b[j] := a[j] + (a[i] div 14);\n b[i] := a[i] div 14;\n l := a[i] - 14 * (a[i] div 14);\n for j := 1 to l do \n if ((i + j) mod 14) <> 0 then\n inc(b[(i + j) mod 14]) else inc(b[14]);\n for j := 1 to 14 do\n if (b[j] mod 2) = 0 then p := p + b[j];\n \n end;\n if p > max then max := p;\n end;\n writeln(max);\nend."}, {"source_code": "var\n i, j, l, m, x, q: uint64;\n a: array[1..14] of uint64;\n b: array[1..14] of uint64;\n\nbegin\n for i := 1 to 14 do\n read(a[i]);\n for i := 1 to 14 do\n begin\n for j := 1 to 14 do\n b[j] := a[j];\n x := a[i];\n b[i] := 0;\n q := i;\n for j := 1 to 14 do\n b[j] := b[j] + (x div 14);\n for j := 1 to (x mod 14) do\n begin\n if q = 13 then\n q := 14\n else\n q := (q + 1) mod 14;\n b[q] := b[q] + 1;\n end;\n l := 0;\n for j := 1 to 14 do\n if b[j] mod 2 = 0 then\n l := l + b[j];\n if l > m then\n m := l;\n end;\n write(m);\nend."}, {"source_code": "var a,b:array[1..14]of integer;\n m,p:BigInteger;\nbegin\nfor var i:integer:=1 to 14 do Read(a[i]);\nfor var i:integer:=1 to 14 do begin\n b:=a;\n p:=0;\n var k:integer:=b[i] div 14;\n b[i]:=b[i] mod 14;\n for var j:integer:=i+1 to Min(14,i+b[i]) do Inc(b[j]);\n for var j:integer:=1 to Max(0,i+b[i]-14) do Inc(b[j]);\n b[i]:=0;\n for var j:integer:=1 to 14 do Inc(b[j],k);\n for var j:integer:=1 to 14 do \n if (b[j] mod 2 = 0) then p:=p+b[j];\n if (p>m) then m:=p;\nend;\nWriteln(m);\nend."}, {"source_code": "var i, j, k, x, m: uint64;\n a, f: array [1..14] of uint64;\nBegin;\n for i:=1 to 14 do begin;\n read (f[i]);\n end;\n for i:=1 to 14 do begin;\n for j:=1 to 14 do begin;\n a[j]:=f[j];\n end;\n if a[i]=0 then continue;\n x:=a[i];\n a[i]:=0;\n for j:=1 to 14 do begin;\n a[j]:=a[j]+(x div 14);\n end;\n j:=i+1;\n k:=i+1;\n while (j<=i+(x mod 14)) do begin;\n if k>14 then k:=1;\n a[k]:=a[k]+1;\n j:=j+1;\n k:=k+1;\n end;\n k:=0;\n for j:=1 to 14 do begin;\n if (a[j] mod 2)=0 then k:=k+a[j];\n end;\n //writeln (k, ' ', m);\n if k>m then m:=k;\n j:=0;\n k:=0;\n end;\n write (m);\nend."}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000;\n besk=8000000000000000000;\n label 1,2,3,4;\n type real=extended; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var ot,aa,bb,cc,p1,p2,p3,p4,k,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,time,x0,modul,pos,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,n,m,s,smin,cen,dl,i1:int64;\n step1, step, i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n vv,znak,ll:int64;\n name,d,dnew, voltay,pos1,pos2,l,r,c,z,y,x,day,b,a:array[-200000..1600000] of int64;\n zz:array[0..125000000] of byte;\n gr,pole:array[-10..1002,-10..1005] of char;\n ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1101,-10..1010] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss2:string;\n newnabor,stoim,nabor:array[-10..200005] of int64;\n zan,fl:array[-100..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n s2,s1:array[-100..200000] of string;\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[-10..nn] of string;\n distmax,vel,rr,x1,y1,yy,ott,v0,v1,s0,t0:extended;\n zv:point;\n dll,xx,temp,sumtemp,vol,newx,newy:array[-10..200000] of extended;\n ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=14;\n for i:=0 to 13 do read(a[i]);\n for step:=0 to 13 do if odd(a[step]) then\n begin\n p1:=a[step] div 14;\n p2:=a[step] mod 14;\n { writeln('step= ',step);\n } for i:=0 to 13 do if i<>step then x[i]:=a[i];\n x[step]:=0;\n for i:=0 to 13 do x[i]:=x[i]+p1;\n t:=step+p2;\n for i:=step+1 to step+p2 do\n begin\n ii:=i mod 14;\n inc(x[ii]);\n end;\n\n { for i:=0 to 13 do write(x[i],' '); writeln;\n } p:=0;\n for i:=0 to 13 do if not odd(x[i]) then p:=p+x[i];\n { writeln('p= ',p);\n } ot:=max(ot,p)\n\n end;\n\n writeln(ot);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "uses math;\nvar a,org:array[1..14] of longint;\nprocedure distribute(n:longint);\nvar i,t,ext:longint;\nbegin\n t:=a[n];\n ext:=t div 14;\n a[n]:=0;\n for i:=1 to 14 do\n a[i]:=a[i]+ext;\n t:=t mod 14;\n i:=n;\n while (t>0) do\n begin\n inc(i);\n if (i>14) then i:=1;\n inc(a[i]);\n dec(t);\n end;\nend;\nfunction collect:int64;\nvar i:longint;\n s:int64;\nbegin\n s:=0;\n for i:=1 to 14 do\n if (a[i] mod 2=0) then\n s:=s+a[i];\n exit(s);\nend;\nprocedure enter;\nvar i:longint;\nbegin\n for i:=1 to 14 do\n read(org[i]);\nend;\nprocedure solve;\nvar i,j:longint;\n s:int64;\nbegin\n enter;\n s:=0;\n for i:=1 to 14 do\n begin\n for j:=1 to 14 do\n a[j]:=org[j];\n distribute(i);\n s:=max(collect,s);\n end;\n write(s);\nend;\nbegin\n solve;\nend.\n"}, {"source_code": "uses math;\n\nvar\n a,b:array[0..14] of int64;\n\nprocedure pread;\n var fi:text; i:longint;\n begin\n assign(fi,'');reset(fi);\n for i:=1 to 14 do\n read(fi,a[i]);\n close(fi);\n end;\n\nprocedure pp;\n var i,j:longint; res,tmp,m:int64;\n begin\n res:=0;\n for i:=1 to 14 do begin\n b:=a;\n tmp:=a[i] div 14;\n m:=a[i] mod 14;\n b[i]:=0;\n for j:=1 to 14 do\n inc(b[j],tmp);\n j:=i;\n while m>0 do begin\n inc(j);\n if j>14 then j:=1;\n inc(b[j]);\n dec(m);\n end;\n\n tmp:=0;\n for j:=1 to 14 do\n if b[j] mod 2=0 then\n inc(tmp,b[j]);\n res:=max(res,tmp);\n end;\n write(res);\n end;\n\nbegin\n pread;\n pp;\nend."}, {"source_code": "var i,j,r,c:longint;\nmax,p:int64;\na,b:array[1..20] of longint;\n\nbegin\n//assign(input,'mkl.in');reset(input);\n//assign(output,'mkl.out');rewrite(output);\nfor i:=1 to 14 do\n read(a[i]);\nb:=a;\nfor i:=1 to 14 do\n begin\n for j:=i+1 to 14 do\n begin\n if a[i]=0 then break;\n a[j]:=a[j]+1;\n a[i]:=a[i]-1;\n end;\n r:=a[i] div 14;\n c:=a[i] mod 14;\n a[i]:=0;\n for j:=1 to 14 do\n a[j]:=a[j]+r;\n for j:=1 to 14 do\n begin\n if c=0 then break;\n a[j]:=a[j]+1;\n c:=c-1;\n end;\n p:=0;\n for j:=1 to 14 do\n if a[j] mod 2=0 then p:=p+a[j];\n if p>max then max:=p;\n a:=b;\n end;\nwrite(max);\nclose(input);\nclose(output);\nend."}, {"source_code": "var n,i,j:longint;\n a,b:array[0..50]of int64;\n ans,max:int64;\nbegin\n n:=14;\n ans:=0;\n max:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]>0 then\n begin\n for j:=1 to n do\n if i<>j then b[j]:=a[j]+a[i] div n;\n b[i]:=a[i] div n;\n for j:=i+1 to i+a[i] mod n do\n begin\n if j>n then break;\n inc(b[j]);\n end;\n for j:=1 to i+a[i] mod n-n do\n inc(b[j]);\n for j:=1 to n do\n if b[j] mod 2=0 then inc(ans,b[j]);\n if ans>max then max:=ans;\n ans:=0;\n for j:=1 to n do\n b[j]:=0;\n\n end;\n writeln(max);\nend.\n"}, {"source_code": "var n, i, j : longint;\n a, b : array[0..50] of int64;\n ans, mx : int64;\n\nbegin\n n := 14; ans := 0; mx := 0;\n for i := 1 to n do read(a[i]);\n for i := 1 to n do\n if (a[i] > 0) then\n begin\n for j := 1 to n do\n if (i <> j) then b[j] := a[j] + a[i] div n;\n b[i] := a[i] div n;\n for j := i + 1 to i + a[i] mod n do\n begin\n if (j > n) then break;\n inc(b[j]);\n end;\n for j := 1 to i + a[i] mod n - n do inc(b[j]);\n for j := 1 to n do\n if (b[j] mod 2 = 0) then inc(ans, b[j]);\n if (ans > mx) then mx := ans;\n ans := 0;\n for j := 1 to n do b[j] := 0;\n end;\n writeln(mx);\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f:text;\n a,b:array[1..100]of longint;\n so1,tmp,tmp1,tam:longint;\n x,i,j:byte;\n kq,max:int64;\nProcedure doc;\nBegin\n Assign(f,fi);\n Reset(f);\n For i:=1 to 14 do\n Read(f,a[i]);\n Close(f);\nEnd;\nProcedure xuli;\nBegin\nkq:=0;\nmax:=low(longint);\n {for i:=1 to 14 do\n if a[i] mod 2=0 then kq:=kq+a[i];\n if kq>max then kq:=max; }\n\n FOr i:=1 to 14 do\n\n begin\n b:=a;\n tam:=i;\n so1:=b[tam];\n b[tam]:=0;\n tmp:= so1 mod 14 ;\n tmp1:=so1 div 14;\n if tmp1<>0 then\n for x:=1 to 14 do\n inc(b[x],tmp1);\n\n while tmp>0 do\n begin\n inc(tam);\n if tam=15 then tam:=1;\n dec(tmp) ;\n inc(b[tam]);\n end;\n kq:=0;\n for j:=1 to 14 do\n if b[j] mod 2=0 then kq:=kq+b[j];\n if kq>max then max:=kq;\n end;\n\nend;\n\n\nProcedure xuat;\nBegin\n Assign(f,fo);\n Rewrite(f);\n Write(f,max);\n Close(F);\nEnd;\n\nBegin\ndoc;\nxuli;\nxuat;\nEnd.\n\n\n\n\n\n\n"}, {"source_code": "//abcdefghijklmnopqrstuvwxyz\nvar\na,b:array [0..13] of longint;\nc,d,i,j:longint;\nw,ans:int64;\nbegin\nfor i:=0 to 13 do read(a[i]);\nfor i:=0 to 13 do \n begin\n b:=a;\n c:=a[i];\n b[i]:=0;\n d:=c mod 14;\n c:=c div 14;\n for j:=1 to d do \n inc(b[(i+j) mod 14],c+1);\n for j:=d+1 to 14 do \n inc(b[(i+j) mod 14],c);\n w:=0;\n for j:=0 to 13 do\n if b[j] mod 2=0 then w:=w+b[j];\n if w>ans then ans:=w;\n end;\nwriteln(ans);\nend."}, {"source_code": " var i,j:longint;\n sum,ans:int64;\n a,b:array [1..14] of int64;\n begin\n for i:=1 to 14 do\n read (a[i]);\n\n for i:=1 to 14 do\n\n if a[i]<>0 then\n begin\n sum:=0;\n for j:=1 to 14 do\n b[j]:=a[j]+a[i] div 14;\n\n b[i]:=b[i]-a[i];\n\n for j:=i+1 to a[i] mod 14+i do\n begin\n if j>14 then inc (b[j-14])\n else inc (b[j]);\n end;\n\n for j:=1 to 14 do\n if b[j] mod 2 = 0 then sum:=sum+b[j];\n\n if sum>ans then ans:=sum;\n end;\n\n\n writeln (ans);\n\n\n\n\n\n\n\n\n\n\n\n\n end."}, {"source_code": "var a,b:array[0..20]of longint ;i,j,k:longint;kc,z:int64;\nbegin\nfor i:=0 to 13 do \nread (a[i]);\nz:=0;\nfor i:=0 to 13 do\nbegin\nif a[i] mod 2<>0 then begin\nb:=a;\nk:=a[i];\nb[i]:=0;\nfor j:=0 to 13 do \nb[j]:=b[j]+k div 14;\nfor j:=1 to k mod 14 do \ninc(b[(i+j) mod 14]);\nkc:=0;\nfor j:=0 to 13 do if b[j] mod 2<>0 then else kc:=kc+b[j];\nif kc>z then z:=kc;\nend;\nend;\nwrite(z);\nend."}], "negative_code": [{"source_code": "var a,b:array[0..20]of longint ;i,j,k:longint;kc,z:int64;\nbegin\n for i:=0 to 13 do read (a[i]);\n z:=0;\n for i:=0 to 13 do\n begin\n if odd(a[i]) then begin\n b:=a;\n k:=a[i];\n for j:=0 to 13 do b[j]:=b[j]+k div 14;\n for j:=1 to k mod 14 do inc(b[(i+j) mod 14]);\n kc:=0;\n for j:=0 to 13 do if odd(b[j]) then else kc:=kc+b[j];\n if kc>z then z:=kc;\n end;\n end;\n write(z);\nend."}, {"source_code": "var a,b:array[0..20]of longint;i,j,k,z:longint;\nbegin\n for i:=0 to 13 do read (a[i]);\n z:=0;\n for i:=0 to 13 do\n begin\n if odd(a[i]) then begin\n b:=a;\n k:=a[i];\n for j:=0 to 14 do b[j]:=b[j]+k div 14;\n for j:=1 to k mod 14 do inc(b[(i+j) mod 14]);\n k:=0;\n for j:=0 to 13 do if odd(b[j]) then else k:=k+b[j];\n if k>z then z:=k;\n end;\n end;\n write(z);\nend."}, {"source_code": "var a:array[1..14] of int64;\ni,j,k,l,m,n:int64;\n\nfunction p(x:longint):longint;\nvar b:array[1..14] of int64;\ni,j,k,l,m,n:int64;\nbegin\nfor i:=1 to 14 do\nb[i]:=a[i];\nk:=b[x];\nb[x]:=0;\nfor i:=1 to 14 do b[i]+=k div 14;\nk:=k mod 14;\nfor i:=x+1 to 14 do\nif k>0 then\nbegin\nb[i]+=1;\nk-=1\nend;\nfor i:=1 to x-1 do\nif k>0 then\nbegin\nb[i]+=1;\nk-=1\nend;\nfor i:=1 to 14 do if (b[i] mod 2=0) then l+=b[i];\np:=l\nend;\nbegin\nfor i:=1 to 14 do\nread(a[i]);\n\nfor i:=1 to 14 do\nif p(i)>m then m:=p(i);\nwrite(m)\nend."}, {"source_code": "var a,b:array[1..14]of integer;\n m,p:integer;\nbegin\nfor var i:integer:=1 to 14 do Read(a[i]);\nfor var i:integer:=1 to 14 do begin\n b:=a;\n p:=0;\n var k:integer:=b[i] div 14;\n b[i]:=b[i] mod 14;\n for var j:integer:=i+1 to Min(14,i+b[i]) do Inc(b[j]);\n for var j:integer:=1 to Max(0,i+b[i]-14) do Inc(b[j]);\n b[i]:=0;\n for var j:integer:=1 to 14 do Inc(b[j],k);\n for var j:integer:=1 to 14 do \n if (b[j] mod 2 = 0) then Inc(p,b[j]);\n if (p>m) then m:=p;\nend;\nWriteln(m);\nend."}, {"source_code": "var i, j, k, x, m: uint64;\n a, f: array [1..14] of uint64;\nBegin;\n for i:=1 to 14 do begin;\n read (f[i]);\n end;\n for i:=1 to 14 do begin;\n for j:=1 to 14 do begin;\n a[j]:=f[j];\n end;\n if a[i]=0 then continue;\n x:=a[i];\n a[i]:=0;\n for j:=1 to 14 do begin;\n a[j]:=a[j]+(x div 14);\n end;\n j:=i+1;\n k:=i+1;\n while (j<=i+(x mod 14)) do begin;\n if k>14 then k:=1;\n a[k]:=a[k]+1;\n j:=j+1;\n k:=k+1;\n end;\n k:=0;\n for j:=1 to 14 do begin;\n if (a[j] mod 2)=0 then k:=k+a[j];\n end;\n writeln (k, ' ', m);\n if k>m then m:=k;\n j:=0;\n k:=0;\n end;\n write (m);\nend."}, {"source_code": "var i, j, k, x, m: uint64;\n a, f: array [1..14] of uint64;\nBegin;\n for i:=1 to 14 do begin;\n read (f[i]);\n end;\n for i:=1 to 14 do begin;\n for j:=1 to 14 do begin;\n a[j]:=f[j];\n end;\n if a[i]=0 then continue;\n x:=a[i];\n for j:=1 to 14 do begin;\n a[j]:=a[j]+(x div 14);\n end;\n j:=i+1;\n k:=i+1;\n while (j<=i+(x mod 14)) do begin;\n if k>14 then k:=1;\n a[k]:=a[k]+1;\n j:=j+1;\n k:=k+1;\n end;\n k:=0;\n for j:=1 to 14 do begin;\n if (a[j] mod 2)=0 then k:=k+a[j];\n end;\n if k>m then m:=k;\n j:=0;\n k:=0;\n end;\n write (m);\nend."}, {"source_code": "uses math;\nvar a,org:array[1..14] of longint;\nprocedure distribute(n:longint);\nvar i,t,ext:longint;\nbegin\n t:=a[n];\n writeln(n,' ',t);\n ext:=t div 14;\n a[n]:=0;\n for i:=1 to 14 do\n a[i]:=a[i]+ext;\n t:=t mod 14;\n i:=n;\n while (t>0) do\n begin\n inc(i);\n if (i>14) then i:=1;\n inc(a[i]);\n dec(t);\n end;\nend;\nfunction collect:int64;\nvar i:longint;\n s:int64;\nbegin\n s:=0;\n for i:=1 to 14 do\n if (a[i] mod 2=0) then\n s:=s+a[i];\n exit(s);\nend;\nprocedure enter;\nvar i:longint;\nbegin\n for i:=1 to 14 do\n read(org[i]);\nend;\nprocedure solve;\nvar i,j:longint;\n s:int64;\nbegin\n enter;\n s:=0;\n for i:=1 to 14 do\n begin\n for j:=1 to 14 do\n a[j]:=org[j];\n distribute(i);\n s:=max(collect,s);\n end;\n write(s);\nend;\nbegin\n solve;\nend.\n"}, {"source_code": "uses math;\n\nvar\n a,b:array[0..14] of int64;\n\nprocedure pread;\n var fi:text; i:longint;\n begin\n assign(fi,'');reset(fi);\n for i:=1 to 14 do\n read(fi,a[i]);\n close(fi);\n end;\n\nprocedure pp;\n var i,j,tmp,res,m:longint;\n begin\n res:=0;\n for i:=1 to 14 do begin\n b:=a;\n tmp:=a[i] div 14;\n m:=a[i] mod 14;\n b[i]:=0;\n for j:=1 to 14 do\n inc(b[j],tmp);\n j:=i;\n while m>0 do begin\n inc(j);\n if j>14 then j:=1;\n inc(b[j]);\n dec(m);\n end;\n\n tmp:=0;\n for j:=1 to 14 do\n if b[j] mod 2=0 then\n inc(tmp,b[j]);\n res:=max(res,tmp);\n end;\n write(res);\n end;\n\nbegin\n pread;\n pp;\nend."}, {"source_code": "var i,t,x,j,max,s:longint;\na,b:array[0..1001] of longint;\nbegin\n//assign(input,'mkl.in');reset(input);\n//assign(output,'mkl.out');rewrite(output);\nfor i:=1 to 14 do\n read(a[i]);\nfor i:=1 to 14 do\n begin\n b:=a;x:=a[i];\n t:=i+1;\n while x<>0 do\n begin\n b[t]:=b[t]+1;\n t:=t+1;\n if t>14 then t:=1;\n x:=x-1;\n end;\n s:=0;\n for j:=1 to 14 do\n if b[j] mod 2=0 then\n s:=s+b[j];\n if s>max then max:=s;\n end;\nwriteln(max);\nclose(input);close(output);\nend."}, {"source_code": " var i,j:longint;\n sum,ans:int64;\n a,b:array [1..14] of int64;\n begin\n for i:=1 to 14 do\n read (a[i]);\n\n for i:=1 to 14 do\n\n if a[i]<>0 then\n begin\n sum:=0;\n for j:=1 to 14 do\n b[j]:=a[j]+a[i] div 14;\n\n b[i]:=b[i]-a[i];\n\n for j:=i+1 to a[i] mod 14+i+1 do\n begin\n if j>14 then inc (b[j-14])\n else inc (b[j]);\n end;\n\n for j:=1 to 14 do\n if b[j] mod 2 = 0 then sum:=sum+b[j];\n\n if sum>ans then ans:=sum;\n end;\n\n\n writeln (ans);\n\n\n\n\n\n\n\n\n\n\n\n\n end."}], "src_uid": "1ac11153e35509e755ea15f1d57d156b"} {"source_code": "var\n n:string;\n i:longint;\nbegin\n readln(n);\n if n[1]<>'1' then begin writeln('NO');exit;end;\n for i:=1 to length(n) do if (n[i]<>'1') and (n[i]<>'4') then begin writeln('NO');exit;end;\n for i:=1 to length(n)-2 do if (n[i]='4') and (n[i+1]='4') and (n[i+2]='4') then begin writeln('NO');exit;end;\n writeln('YES');\nend.", "positive_code": [{"source_code": "program project1;\n\n\nvar s : string [11];\n i: byte;\n\nbegin\n readln (s);\n\n\n i:=pos ('444', s) ;\n if(i>0) then writeln ('NO') else\n begin\n\n repeat\n begin\n i:=pos( '144', s);\n delete ( s, i, 3 );\n end;\n until (i=0);\n repeat\n begin\n i:= pos ( '14',s);\n delete (s, i, 2);\n end;\n until ( i=0);\n repeat\n i:= pos ('1', s);\n delete ( s, i, 1);\n until (i=0) ;\n\n if length(s)=0 then\n writeln ( 'YES') else\n writeln ('NO');\n\n end ;\n\nend."}, {"source_code": "var s:string;\n\ti:longint;\nfunction xuly:string;\nbegin\n if pos('2',s)>0 then exit('NO');\n if pos('3',s)>0 then exit('NO');\n if pos('5',s)>0 then exit('NO');\n if pos('6',s)>0 then exit('NO');\n if pos('7',s)>0 then exit('NO');\n if pos('9',s)>0 then exit('NO');\n if pos('0',s)>0 then exit('NO');\n\ti:=pos('144',s);\n while i>0 do begin delete(s,i,3); insert(' ',s,i); i:=pos('144',s); end;\n\ti:= pos('14',s);\n while i>0 do begin delete(s,i,2); insert(' ',s,i); i:= pos('14',s); end;\n\ti:=pos('1',s);\n while i>0 do begin delete(s,i,1); insert(' ',s,i); i:=pos('1',s); end;\n\ti:=pos(' ',s);\n\twhile i>0 do begin delete(s,i,1); i:=pos(' ',s); end;\n if s<>'' then exit('NO');\n exit('YES');\nend;\n\nbegin\n readln(s);\n writeln(xuly);\nend.\n"}, {"source_code": "program canhtoan;\nuses sysutils;\nvar s:string;\nprocedure main();\nvar s1,s2,s3:string;\n kt:boolean;\nbegin\nread(s);\ns1:='1';s2:='14';s3:='144';\nkt:=true;\nwhile kt=true do\n begin\n kt:=false;\n if pos(s3,s)=1 then\n begin\n kt:=true;\n delete(s,1,length(s3));\n end\n else\n if pos(s2,s)=1 then\n begin\n kt:=true;\n delete(s,1,length(s2));\n end\n else\n if pos(s1,s)=1 then\n begin\n kt:=true;\n delete(s,1,length(s1));\n end;\n if s='' then break;\n end;\nif kt=true then write('YES') else write('NO');\nend;\nBEGIN\n main();\nEND."}, {"source_code": "program p17;\nvar\n a:string[10];\n j,k:longint;\nbegin\n readln(a);\n if a=''\n then begin writeln('NO');halt; end;\n while pos('144',a)<>0 do\n begin\n k:=pos('144',a);a[k]:='a';a[k+1]:='a';a[k+2]:='a';\n end;\n while pos('14',a)<>0 do\n begin\n k:=pos('14',a);a[k]:='a';a[k+1]:='a';\n end;\n while pos('1',a)<>0 do\n begin\n k:=pos('1',a);a[k]:='a';\n end;\n for j:=1 to length(a) do\n if a[j]<>'a'\n then begin writeln('NO');halt; end;\n writeln('YES');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar s:string;\n n:longint;\n f,g:text;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s);\nend;\nprocedure process;\nvar i,k:longint;\nbegin\n n:=length(s);\n for i:=1 to n do\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n writeln(g,'NO');\n exit;\n end;\n repeat\n k:=pos('4',s);\n if k=0 then\n begin\n writeln(g,'YES');\n exit\n end;\n if (k=1) then\n begin\n writeln(g,'NO');\n exit;\n end\n else\n if s[k-1]='1' then\n begin\n if k<>n then\n if s[k+1]='4' then k:=k+1;\n delete(s,1,k);\n end\n else begin\n writeln(g,'NO');\n exit;\n end;\n until false;\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "var\nn,m,q,w,l,r,mid,i,k:longint;\ns:string;\na,b:array[1..100000] of longint;\nc:array[0..1000, 0..1000] of int64;\nbegin\n {assign(input,'f.in');\n assign(output,'f.out');\n reset(input);\n rewrite(output); }\n read(s);\n if s[1]='4' then\n begin\n write('NO');\n exit;\n end;\n for i:=1 to length(s) do\n begin\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n write('NO');\n exit;\n end;\n if (s[i]='4') then inc(k);\n if k=3 then\n begin\n write('NO');\n exit;\n end;\n if s[i]='1' then k:=0;\n end;\n write('YES');\nend.\n\n"}, {"source_code": "program name;\nvar i, n:integer;\ns:string;\nbegin\nreadln (n);\nstr (n,s);\nrepeat\ni:=pos ('144',s);\nif i<>0 then delete (s,i,3);\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos ('14',s);\nif i <>0 then delete (s,i,2);\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos ('1',s);\nif i<>0 then delete (s,i,1);\ninsert ('a',s,1);\nuntil i=0;\nrepeat\ni:=pos ('a',s);\nif i<>0 then delete (s,i,1);\nuntil i=0;\nif length(s)=0 then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "program volchis;\nvar s:string[255];\ni:integer;\n\nfunction z(a,b:string;k:integer):string;\nvar j:integer;\nbegin\n j:=1;\n while j<>0 do\n begin\n j:=pos(a,b);\n if j<>0 then\n begin\n delete(b,j,k);\n insert('a',b,j);\n //writeln(b);\n end;\n end;\n\nz:=b; \nend;\n\nbegin\nreadln(s);\ni:=1;\nwhile i<>0 do\nbegin\n s:=z('144',s,3);\n s:=z('14',s,2);\n s:=z('1',s,1);\n i:=1;\n while i<>0 do\n begin\n i:=pos('a',s); \n if i<>0 then\n begin \n delete(s,i,1);\n end;\n end;\n end;\n i:=length(s);\n if i=0 then writeln('YES') else writeln ('NO');\nend."}, {"source_code": "var n,i,l:longint;\na:array[1..10000] of longint;\nbegin\nread(n);\ni:=0;\nl:=0;\nwhile n>0 do begin\nif (n div 10=0) and (n mod 10<>0) and (n<>1) then begin\nwrite('NO');\nexit;\nend;\ninc(i);\na[i]:=n mod 10;\nn:=n div 10;\nif (a[i]<>1) and (a[i]<>4) then begin\nwrite('NO');\nexit;\nend;\nif a[i]=4 then inc(l)\n else l:=0;\nif l>2 then begin\nwrite('NO');\nexit;\nend;\nend;\nwrite('YES');\nend."}, {"source_code": "program one;\nvar\ni, n: integer;\ns: string;\nbegin\nreadln (n);\nstr (n, s);\nrepeat\ni:= pos ('144', s);\nif i <> 0 then delete (s, i, 3);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('14', s);\nif i<>0 then delete (s, i, 2);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('1', s);\nif i<>0 then delete (s, i, 1);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat;\ni:= pos ('a', s);\nif i<>0 then delete (s, i, 1);\nuntil i=0;\nif length (s) = 0\nthen\nwriteln ('YES')\nelse writeln ('NO');\nend."}, {"source_code": "\n\nprogram name;\nvar\ni:integer;\nn:integer;\ns:string;\nbegin\nreadln(n);\nstr(n,s);\nrepeat\ni:=pos( '144' , s);\nif i<>0 then delete (s,i,3);\ninsert ('a',s,i);\ninsert('a',s,i);\nuntil i=0;\nrepeat\ni:=pos( '14' , s);\nif i<>0 then delete (s,i,2);\ninsert ('a',s,i);\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos( '1' , s);\nif i<>0 then ( delete (s,i,1) );\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos( 'a' , s);\nif i<>0 then ( delete (s,i,1) );\nuntil i=0;\nif length(s) = 0 then writeln ( 'YES' ) else writeln ( 'NO' );\nend.\n"}, {"source_code": "var n:string;\n l, i, t:byte;\nbegin\nt:= 0; {Defaults}\nreadln(n);\nl:= length(n);\nfor i:=1 to l do begin\n if(n[i] = '1') then t:= 1\n else if((n[i] = '4') and (t > 0) and (t < 3)) then inc(t, 1)\n else begin \n writeln('NO');\n exit;\n end;\nend;\nwriteln('YES');\nend."}, {"source_code": "var\ns:string;\nn,i,k,f:longint;\nbegin\nreadln(s);\nn:=length(s);\nk:=0;\nfor i:=1 to n do begin\n if s[i]='1' then begin\n k:=1;\n f:=0;\n end else begin\n if s[i]='4' then inc(f);\n if (f>2) or ((s[i]='4') and (k=0)) or (s[i]<>'4')\n then begin\n write('NO');\n halt;\n end;\n end;\nend;\nwriteln('YES');\nend.\n"}, {"source_code": "var n:string;\nbegin\n readln(n);\n while length(n)>0 do\n begin\n if copy(n,1,3)='144' then\n begin\n delete(n,1,3);\n continue;\n end;\n if copy(n,1,2)='14' then\n begin\n delete(n,1,2);\n continue;\n end;\n if copy(n,1,1)='1' then\n begin\n delete(n,1,1);\n continue;\n end;\n break;\n end;\n if n<>'' then writeln('NO') else writeln('YES');\nend.\n"}, {"source_code": "var i,c: integer; s: string;\nbegin\n readln(s);\n for i:=length(s) downto 1 do\n begin\n if s[i]='1' then c:=0\n else if s[i]='4' then if c<2 then inc(c)\n else\n begin\n writeln('NO');\n exit\n end\n else\n begin\n writeln('NO');\n exit\n end\n end;\n if c=0 then writeln('YES')\n else writeln('NO')\nend.\n"}, {"source_code": "program bai1;\nvar s:string;\n\ti:longint;\nBEGIN\n readln(s);\n s:='44'+s;\n\tfor i:=3 to length(s) do if ((s[i]<>'1') and (s[i]<>'4')) or (s[i]='4') and (s[i-1]='4') and (s[i-2]='4') then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n\nEND."}, {"source_code": "var\n s,ss:string;\n i,j,k:integer; t:boolean;\nbegin\n readln(s);ss:=s; t:=true;\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then t:=false;\n if pos('444',s)<>0 then t:=false;\n if t=true then begin\n repeat\n i:=pos('144',s);\n if (i<>0)and(s[i+3]<>'4') then delete(s,i,3);\n until (i=0)or(ss[i+3]='4'); ss:=s;\n repeat\n i:=pos('14',s);\n if (i<>0)and(s[i+2]<>'4') then delete(s,i,2);\n until (i=0)or(ss[i+2]='4');\n repeat\n i:=pos('1',s);\n if i<>0 then delete(s,i,1);\n until i=0;\n if s<>'' then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n key:string;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res:longint;\n begin\n readln(fi,key);\n n:=length(key);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction bt(st:string):boolean;\n begin\n if length(st)>n then exit(false);\n if length(st)=n then\n begin\n if st=key then exit(true) else exit(false);\n end;\n if bt(st+'1') or bt(st+'14') or bt(st+'144') then\n exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n if bt('') then writeln(fo,'YES') else writeln(fo,'NO');;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var q,n,k,i:longint;s:string;c:set of char;\nbegin\nreadln(s);\nif s[1]<>'1' then writeln('NO')else\nbegin\ni:=length(s);\nwhile i<>0 do\nbegin\nif (s[1]<>'1')and(s[1]<>'4')then begin writeln('NO');q:=1;break;end else\n if s[1]='4' then begin\n if k>=2 then begin writeln('NO');q:=1;break;end else begin inc(k);end ;\n end else k:=0;\n dec(i);delete(s,1,1);\n end;\n\n\n\nif q<>1 then writeln('YES');\nend;\nend.\n"}, {"source_code": "var\n i, l, c:longint;\n s:string;\nbegin\nreadln(s);\nl:= length(s);\nfor i:=1 to l do \n begin\n if (i-c=1) and (s[i]='1') then c:=i;\n if (i-c<=2) and (i>1) then if (s[i]='4') and (s[i-1]='1')then c:=i;\n if (i-c<=3) and (i>2) then if (s[i]='4') and (s[i-1]='4') and (s[i-2]='1') then c:=i;\n if (i-c>3) then begin write('NO'); exit; end;\n end;\n if c=l then writeln('YES') else write('NO');\nend."}, {"source_code": "var\n s,c:string;\n g,e,d,i,j,n,m:int64;\nbegin\n readln(s); c:=' '*length(s);\n for i:=1 to length(s)-2 do\n if s[i]+s[i+1]+s[i+2]='144' then begin s[i]:=' '; s[i+1]:=' '; s[i+2]:=' '; end;\n for i:=1 to length(s)-1 do\n if s[i]+s[i+1]='14' then begin s[i]:=' '; s[i+1]:=' '; end;\n for i:=1 to length(s) do\n if s[i]='1' then s[i]:=' ';\n if s=c then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Var\n S: String;\n \nBegin\n Readln(S);\n For Var i := 1 to Length(S) - 2 do\n If (S[i] = '1') and (S[i + 1] = '4') and (S[i + 2] = '4') then Begin\n S[i] := 'a';\n S[i + 1] := 'a';\n S[i + 2] := 'a';\n End;\n For Var i := 1 to Length(S) - 1 do\n If (S[i] = '1') and (S[i + 1] = '4') then Begin\n S[i] := 'a';\n S[i + 1] := 'a';\n End;\n For Var i := 1 to Length(S) do\n If (S[i] = '1') then\n S[i] := 'a';\n For Var i := 1 to Length(S) do\n If S[i] <> 'a' then Begin\n Write('NO');\n Exit\n End;\n Write('YES')\nEnd."}, {"source_code": "var\n s, f, a: string;\n\nbegin\n readln(s);\n while f = '' do\n if length(s) <> 0 then\n begin\n a := copy(s, 1, 3);\n if a = '111' then\n delete(s, 1, 2)\n else\n if a = '114' then\n delete(s, 1, 1)\n else\n if a = '144' then\n delete(s, 1, 3)\n else\n if a = '141' then\n delete(s, 1, 2)\n else\n if a = '14' then\n delete(s, 1, 2)\n else\n if a = '1' then\n delete(s, 1, 1)\n else\n if a = '11' then\n delete(s, 1, 2)\n else\n f := 'NO';\n end\n else\n f := 'YES';\n write(f);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s: String;\n\nFunction Cnt: Boolean;\nvar\n i, j, k: Integer;\n ss, s2: String;\n en: Boolean;\nbegin\n en := true;\n while (length(s) > 0) do\n begin\n If (length(s) >= 3) then begin\n If (s[1] = '1') and (s[2] = '4') and (s[3] = '4') then\n Delete(s,1,3) else\n If (s[1] = '1') and (s[2] = '4') and (s[3] <> '4') then\n Delete(s,1,2) else\n If (s[1] = '1') and (s[2] <> '4') then\n Delete(s,1,1) else begin\n en := false ;\n break;\n end;\n end else\n If (length(s) >= 2) then begin\n If (s[1] = '1') and (s[2] = '4') then\n Delete(s,1,2) else\n If (s[1] = '1') and (s[2] <> '4') then\n Delete(s,1,1) else begin\n en := false;\n break;\n end;\n end\n else\n If (length(s) = 1) and (s[1] = '1') then\n delete(s,1,1)\n else begin\n en := false;\n break;\n end;\n end;\n Cnt := en;\nend;\n\nbegin\n readln(s);\n If (cnt) then\n writeln('YES')\n else\n writeln('NO');\n readln;\n readln;\nend.\n"}, {"source_code": "program Project_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, y: integer;\n a: array [1..11] of byte;\n k: boolean;\nbegin\n readln(n);\n a[11] := 0;\n while (n <> 0) do\n begin\n inc(a[11]);\n a[a[11]] := n mod 10;\n n := n div 10;\n end;\n for i := 1 to (a[11] div 2) do\n begin\n y := a[i];\n a[i] := a[a[11]-i+1];\n a[a[11]-i+1] := y;\n end;\n k := true;\n y := 1;\n while (y <= a[11]) do\n begin\n if ((a[y] = 1) and (a[y+1] = 4) and (a[y+2] = 4)) then\n inc(y, 3)\n else if ((a[y] = 1) and (a[y+1] = 4)) then\n inc(y, 2)\n else if (a[y] = 1) then\n inc(y)\n else\n begin\n k := false;\n break;\n end;\n end;\n if (k) then\n writeln('YES')\n else\n writeln('NO');\n readln;\n readln;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n s:ansistring;\n i,j,k,dem,n:integer;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n writeln('NO');\n halt;\n end;\n if (s[1]='4') then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to n-1 do\n if (s[i]='1') and (s[i+1]='4') then\n begin\n dem:=0;\n for j:=i+1 to n do\n if s[j]='4' then\n inc(dem) else break;\n if (dem>2) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "uses math;\ntype mass=array[0..11,1..3] of integer;\nvar r,l,k:int64;s,s1:string;u:boolean;d,max1,min1,n,res,de:int64;i,z,code:integer;x,j,a,b,c,y:int64;\n m:mass;\nbegin\n // reset(input,'input.txt');\n // assign(output,'output.txt');\n readln(n);\n str(n,s);\n if s[1]='1'\n then Begin\n m[1,1]:=1;\n if s[2]='4'\n then Begin\n m[2,2]:=1;\n if s[3]='4'\n then m[3,3]:=1;\n end;\n end;\n for i:=2 to length(s) do\n for z:=i downto max(1,i-2) do\n if s[z]<>'0'\n then Begin\n val(copy(s,z,i-z+1),a,code);\n if (a=1) and ((m[z-1,1]=1) or (m[z-1,2]=1) or (m[z-1,3]=1))\n then m[i,1]:=1;\n if (a=14) and ((m[z-1,1]=1) or (m[z-1,2]=1) or (m[z-1,3]=1))\n then m[i,2]:=1;\n if (a=144) and ((m[z-1,1]=1) or (m[z-1,2]=1) or (m[z-1,3]=1))\n then m[i,3]:=1;\n end;\n a:=length(s);\n if (m[a,1]=1) or (m[a,2]=1) or (m[a,3]=1)\n then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var a:string;\n i,n,s:longint;\nbegin\n readln(a);\n s:=0;\n for i:=1 to length(a) do\n case s of\n 0:if a[i]='1'\n then inc(s)\n else begin\n writeln('NO');\n halt(0);\n end;\n 1:if a[i]='4'\n then inc(s)\n else if a[i]<>'1'\n then begin\n writeln('NO');\n halt(0);\n end;\n 2:if a[i]='4'\n then s:=0\n else if a[i]='1'\n then s:=1\n else begin\n writeln('NO');\n halt(0);\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "var\n n,m,k,l,i,j,max,min,x,y,sum,ans,res,x2,y2,b,h,e : longint;\n a,d : array [0..1000000] of longint;\n p,q : real;\n s : ansistring;\n\nbegin\n readln(s);\n if s[1]='4' then\n begin\n writeln('NO');\n exit;\n end;\n for i:=1 to length(s)-2 do\n begin\n if (s[i]='4') and (s[i+1]='4') and (s[i+2]='4') then\n begin\n writeln('NO');\n exit;\n end;\n end;\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n readln; readln;\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$apptype console}\nuses\n sysutils,math;\nvar\n s,w : string;\n i : integer;\nbegin\n read(s);\n i := 1;\n while (i <= length(s)) do begin\n w := s[i];\n if (w <> '1') then begin\n write('NO');\n halt;\n end;\n if (i = length(s)) then break;\n if (i < length(s)) then begin\n if (s[i + 1] = '1') then begin\n i := i + 1;\n continue;\n end;\n if (s[i + 1] = '4') then begin\n w := w + s[i + 1];\n i := i + 2;\n end\n else begin\n write('NO');\n halt;\n end;\n end;\n if (i <= length(s)) then begin\n if (s[i] = '1') then begin\n continue;\n end;\n if (s[i] = '4') then begin\n w := w + s[i];\n i := i + 1;\n end\n else begin\n write('NO');\n halt;\n end;\n end;\n end;\n write('YES');\n\n\n\n\n\n\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nVar s:string;\nProcedure Rec (i:integer);\nBegin\n if i>length(s)\n then begin\n writeln ('YES');\n halt (0);\n end;\n if ((s[i]='1')and(s[i+1]='4'))and(s[i+2]='4')\n then Rec (i+3)\n else if (s[i]='1')and(s[i+1]='4')\n then Rec (i+2)\n else if s[i]='1'\n then Rec (i+1);\nend;\n\nbegin\n Readln (s);\n Rec (1);\n writeln ('NO');\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n s:string;\n b:boolean;\n i,n:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n ReadLn(s);\n b:=true;\n n:=0;\n if s[1]='4' then\n b:=False;\n for i := 1 to length(s) do\n if (s[i]='1') or (s[i]='4') then\n begin\n if s[i]='1' then\n n:=0;\n if s[i]='4' then\n inc(n);\n if n = 3 then\n b:=false;\n end\n else\n b:=False;\n if b then\n WriteLn('YES')\n else\n WriteLn('NO');\nend.\n"}, {"source_code": "program N_1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n i,j,n:integer;\nbegin\n readln(s);\n i:=1; n:=0;\n while i<= length(s) do\n begin\n if (copy(s,i,3)='144') then begin n:=1; inc(i,3);end\n else if (copy(s,i,2)='14') then begin n:=1; inc(i,2);end\n else if (copy(s,i,1)='1') then begin n:=1; inc(i);end\n else begin writeln('NO');n:=0; break;end; end;\n if n=1 then writeln('YES');\n readln;\n\nend.\n"}, {"source_code": "program volshebstvo_Viki_RESET;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar\n s: string;\n i, j, n:integer;\nbegin\n readln(s);\n s := s + '55';\n i := 1;\n while (i <= length(s) - 2) do\n begin\n if (copy(s, i, 3) = '144') then\n inc(i, 3)\n else\n if (copy(s, i, 2) = '14') then\n inc(i, 2)\n else\n if (copy(s, i, 1) = '1') then\n inc(i, 1)\n else\n begin\n writeln('NO');\n readln;\n exit;\n end;\n end;\n writeln('YES');\n readln;\nend.\n"}, {"source_code": "var\na:ansistring;\ni:longint;\nb:boolean;\nbegin\n readln(a);\n if (a[1]<>'1') then writeln('NO')\n else\n begin\n b:=true;\n for i := 2 to (length(a)-1) do begin\n if ((a[i]<>'1') and (a[i]<>'4')) then b:=false;\n if (a[i-1]='4') and (a[i]='4') and (a[i+1]='4') then b:=false;\n end;\n if (a[length(a)]<>'1')and(a[length(a)]<>'4') then b:=false; \n if b=true then writeln('YES')\n else writeln('NO');\n end;\n readln;\nend.\n"}, {"source_code": "var\ni,j,k:integer;\ns:string;\np:boolean;\nbegin\n readln(s);\n j:=length(s);i:=1;\n p:=true;\n while (0<>j)and p do\n begin\n if s[1]<>'1' then p:=false\n else\n if s[2]='4' then\n if s[3]='4' then delete(s,1,3)\n else delete(s,1,2)\n else delete(s,1,1);\n \n j:=length(s);\n end;\n if p then write('YES') else write('NO');\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n dp,used:Array[0..300000] of Boolean;\n n:Integer;\n s:String;\nFunction Solve(i:Integer):Boolean;\nVar\n f:Boolean;\nBegin\n If used[i] Then Begin\n Solve:=dp[i];\n Exit;\n End;\n used[i]:=true;\n If i=0 Then Begin\n Solve:=true;\n Exit;\n End;\n f:=false;\n If s[i]='1' Then f:=f or Solve(i-1);\n If (i>=2) and (s[i-1]+s[i]='14') Then f:=f or Solve(i-2);\n If (i>=3) and (s[i-2]+s[i-1]+s[i]='144') Then f:=f or Solve(i-3);\n Solve:=f;\nEnd;\nBegin\n Read(s);\n n:=length(s);\n If Solve(n) Then Write('YES')\n Else Write('NO');\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,nep,i, n,k : integer;\n s, s1,s2,s3,st: ansistring;\n f, g: boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(s);\n s1:='144'; \n s2:='14';\n s3:='1';\n f:=true;\n i:=1;\n n:=length(s); \n while i<=n do \n begin\n st:=copy(s, i, 3);\n if st=s1 then inc(i, 3)\n else\n begin\n st:=copy(s, i, 2);\n if st=s2 then i:=i+2\n else\n begin\n st:=copy(s, i, 1);\n if st=s3 then i:=i+1\n else \n begin\n f:=false;\n break;\n end; \n end; \n end;\n end;\n \n if f then writeln('YES') else writeln('NO'); \nend."}, {"source_code": "var s,k:string;\n i,j,l,m:longint;\n b:boolean;\nbegin\nreadln(s);\ni:=1;\nb:=true;\n\nwhile (b=true) and (i<= length(s)) do\nbegin\nk:=copy(s,i,3);\nif k='144' then begin\n inc(i,3);\n k:=copy(s,i,3);\n end\n else begin\n k:=copy(s,i,2);\n if k='14' then inc(i,2)\n else begin\n k:=copy(s,i,1);\n if k='1' then inc(i)\n else b:=false;\n end;\nend; end;\nif b=false then write('NO')\n else write('YES');\nend.\n"}, {"source_code": "Var s:String;\ni:LongInt;\nBegin\n //ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (s);\n If s[1]='4' then Begin\n Writeln ('NO');\n Halt (0);\n End;\n For I:=1 to Length (s) do\n If (s[i]<>'1') and (s[i]<>'4')\n then Begin\n Writeln ('NO');\n Halt (0);\n End;\n For I:=1 to Length (s)-2 do\n If (s[i]='4') and (s[i+1]='4') and (s[i+2]='4')\n then Begin\n Writeln ('NO');\n Halt (0);\n End;\n Writeln ('YES');\nEnd."}, {"source_code": "//Uses math,sysutils,strutils;\nvar\nn,q,i,w:longint;\na:array[1..10]of integer;\nbegin\nread(n);\nw:=1;\nfor i:=1 to 10 do\na[i]:=0;\nq:=10;\nwhile n>0 do\nbegin\na[q]:=n mod 10;\nn:=n div 10;\nq:=q-1;\nend;\nq:=q+1;\nif a[q]<>1\nthen\nw:=0;\nif q<9\nthen\nfor i:=q to 8 do\nif (a[i]=a[i+1]) and (a[i]=4) and (a[i]=a[i+2])\nthen\nw:=0;\nif q<10\nthen\nfor i:=q+1 to 10 do\nif (a[i]<>1) and (a[i]<>4)\nthen\nw:=0;\nif w=1\nthen\nwrite('YES')\nelse\nwrite('NO');\nend."}, {"source_code": "var\n i,j:longint;\n s,t:ansistring;\nbegin\ns:='144`';\nreadln(t);\nj:=1;\nfor i:=1 to length(t) do \n if s[j]=t[i] then inc(j) else\n if s[1]=t[i] then j:=2 else\n begin\n write('NO');\n halt;\n end;\nwrite('YES');\nend."}, {"source_code": "Program _320A;\nvar\n a : array[1..10] of byte;\n n, i, t : longint;\nbegin\n read(n);\n i := 0;\n while n > 0 do\n begin\n i := i + 1;\n a[i] := n mod 10;\n n := n div 10;\n end;\n n := i;\n t := 0;\n if a[n]<>1\n then t := -1;\n for i := n downto 1 do\n case a[i] of\n 1:case t of\n 0,1,2: t := 0;\n else t := -1;\n end;\n 4:case t of\n 0, 1 : t := t + 1;\n else t := -1;\n end;\n else t := -1;\n end;\n if t >2 \n then t := -1;\n if t = -1\n then write('NO')\n else write('YES');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k,n,m,i,j,g,h:integer;\n s:string;\nbegin\n readln(s);\n k:=0;\n for i:=1 to length(s) do\n begin\n if (s[i]='1') or (s[i]='4') then\n begin\n if (s[i]='4') then\n begin\n if (s[i-1]<>'1') and (s[i-2]<>'1') then\n begin\n write('NO');\n exit;\n end;\n end;\n end\n else\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend."}, {"source_code": "Var n:Longint;\n s,temp:String;\n ok:boolean;\n i:Longint;\nBegin\n Readln(n);\n str(n,s);\n\n ok:=true;\n\n for i:=1 to length(s) do\n If (s[i]<>'1') and (s[i]<>'4') then ok:=false;\n\n For i:=2 to length(s)-1 do\n If (s[i]='4') and (s[i+1]='4') and (s[i-1]<>'1') then ok:=false;\n\n If (s[1]='4') then ok:=false;\n If (s[2]='4') and (s[1]<>'1') then ok:=false;\n\n If (ok) then Writeln('YES') Else Writeln('NO');\nEnd."}, {"source_code": "var st:String; i,j:longint; flag:boolean;\nbegin\n//ASSIGN(input,'input.txt'); RESET(input);\n//ASSIGN(output,'output.txt'); REWRITE(output);\nreadln(st);\nfor i:=1 to length(st)-2 do\n if (st[i]='1') and (st[i+1]='4') and (st[i+2]='4') then begin\n st[i]:='z'; st[i+1]:='z'; st[i+2]:='z' end;\n\n\nfor i:=1 to length(st)-1 do\n if (st[i]='1') and (st[i+1]='4') then begin\n st[i]:='z'; st[i+1]:='z' end;\n\nflag:=true;\nfor i:=1 to length(st) do\n if (st[i]<>'1') and (st[i]<>'z') then flag:=false;\nif flag then write('YES')\nelse write('NO')\nend."}, {"source_code": "var i:longint;\n s,s1,s2,s3:string;\nbegin\n read(s);\n i:=1;\n while i<=length(s) do\n begin\n s1:=copy(s,i,1); s2:=copy(s,i,2); s3:=copy(s,i,3);\n if s3='144' then inc(i,3)\n else if s2='14' then inc(i,2)\n else if s1='1' then inc(i,1)\n else\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend."}, {"source_code": "var st:String;\n kt:boolean;\n t,code,n,i:longint;\n\nbegin\n //assign(input,'magic_numbers.inp');\n //reset(input);\n //assign(output,'magic_numbers.out');\n //rewrite(output);\n readln(st);\n while pos('144',st)<>0 do\n begin\n t:=pos('144',st);\n st[t]:='.';st[t+1]:='.';st[t+2]:='.';\n end;\n while pos('14',st)<>0 do\n begin\n t:=pos('14',st);\n st[t]:='.';st[t+1]:='.';\n end;\n while pos('1',st)<>0 do\n begin\n t:=pos('1',st);\n st[t]:='.';\n end;\n for i:=1 to length(st) do\n if st[i]<>'.' then\n begin\n write('NO');\n halt;\n end;\n write('YES');\n\nend."}, {"source_code": "var s:string;\n i,j,k,l,r,n,m:longint;\n begin\n readln(s);\n i:=1;\n s:=s+' ';\n while i<>length(s) do\n begin\n if s[i]=' ' then break;\n if s[i]<>'1' then begin writeln('NO'); halt; end;\n if (s[i+1]='4') and (s[i+2]='4') then inc(i,3) else\n if (s[i+1]='4') then inc(i,2) else\n if (s[i]='1') then inc(i,1);\n end;\n writeln('YES');\n end."}, {"source_code": "var\ns:ansistring;\ni,four,one:longint;\nbol:boolean;\nbegin\n\nreadln(s);\nfor i:=1 to length(s) do begin\n if (s[i]<>'1')and(s[i]<>'4') then bol:=true;\nend;\nif bol then writeln('NO')\nelse begin\n for i:=1 to length(s) do begin\n if s[i]='1' then begin\n one:=1;\n four:=0;\n end;\n if s[i]='4' then begin\n if one<=0 then bol:=true;\n inc(four);\n if four>2 then bol:=true;\n end;\n end;\nif bol then writeln('NO')\nelse writeln('YES');\n\nend;\nend.\n"}, {"source_code": "const\n fi = '';\n fo = '';\nvar\n f,g : text;\n s : string;\n i : integer;\nprocedure solve;\nbegin\n for i := 1 to length(s) do\n if (s[i] <> '1') and (s[i] <> '4') then\n begin\n write(g,'NO');\n close(f);\n close(g);\n halt;\n end;\n if s[1] <> '1' then\n begin\n write(g,'NO');\n exit;\n end;\n if pos('444',s) >0 then\n begin\n write(g,'NO');\n exit;\n end;\n write(g,'YES');\nend;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n read(f,s);\n\t\tsolve;\n close(f);\n close(g);\nend."}, {"source_code": "var\ni,ii : integer;\nn : ansistring;\nx : char;\nbegin\n read(n);\n if n[1] = '4' then\n begin\n write('NO');\n exit;\n end;\n for i := 1 to length(n) do\n begin\n if n[i] = '4' then\n begin\n for ii := i to i + 2 do\n if ii <= length(n) then\n begin\n if n[ii] = '4' then\n begin\n if ii = (i + 2) then\n begin\n write('NO');\n EXIT;\n end;\n end;\n if n[ii] = '1' then\n break\n end;\n end;\n if ( n[i] <> '4') and ( n[i] <> '1') then\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend.\n"}, {"source_code": "var\n s: string;\n i: LongInt;\n\nbegin\n Read (s);\n\n i := 1;\n\n if s[i] <> '1' then begin\n Write ('NO');\n Exit\n end;\n for i := 2 to length (s) do\n if (s[i] <> '1') and (s[i] <> '4') then begin\n Write ('NO');\n Exit\n end\n else\n if Pos ('444', s) > 0 then begin\n Write ('NO');\n Exit\n end;\n Write ('YES')\nend.\n\n\n\n"}, {"source_code": "var s:string;\n i,n,j:longint;\n fl:boolean;\nbegin\nreadln(s);\nfl:=true;\nfor i:=1 to length(s) do\n if (s[i]<>'4') and (s[i] <> '1')\n then fl:=false;\nif s[1]<>'1' then fl:=false; \nif pos('444',s) >0 then fl:=false;\nif fl then writeln('YES')\n else writeln('NO'); \nend."}, {"source_code": "Program MagicNumbers;\nuses math;\nvar s:string;\nbegin //assign(input,'320A.inp'); reset(input);\n //assign(output,'320A.out'); rewrite(output);\n readln(s);\n while s<>'' do\n begin if Pos('144',s)=1 then delete(s,1,3)\n else if Pos('14',s)=1 then delete(s,1,2)\n else if Pos('1',s)=1 then delete(s,1,1)\n else begin\n writeln('NO'); exit;\n end;\n end;\n writeln('YES');\n //close(input); close(output);\nend.\n"}, {"source_code": "Const\n Finp='';\n Fout='';\nVar f,g:text;\n n,s:longint;\nBegin\n Assign(f,finp); Reset(f);\n Assign(g,fout); Rewrite(g);\n Readln(f,n);\n While n<>0 do\n Begin\n s:=n mod 1000;\n If s=144 then\n Begin n:=n div 1000; Continue; End;\n s:=n mod 100;\n If s=14 then\n Begin n:=n div 100; Continue; End;\n s:=n mod 10;\n If s=1 then\n Begin n:=n div 10; Continue; End;\n Break;\n End;\n If n>0 then Write(g,'NO')\n Else Write(g,'YES');\n Close(f); Close(g);\nEnd.\n"}, {"source_code": "var a : string;\n dem , i , n : longint;\nbegin\n read( a );\n if ( a[1] <>'1') then\n begin\n write( 'NO' ); exit;\n end;\n\tdem :=0;\n n := length( a );\n\tfor i := 2 to length( a ) do\n\t\tbegin\n\t\t if ( a[i] <> '1' ) and ( a[i] <> '4') then\n\t\t begin\n\t\t\t write( 'NO' ); exit;\n\t\t end;\n\tif ( a[i] = '4' ) then inc(dem)\n\telse dem :=0;\n\tif ( dem > 2 ) then\n\t\t begin\n\t\t\t write( 'NO' );exit;\n\t\t end;\n end;\n\twrite( 'YES' );\nend.\n"}, {"source_code": "var s:string;\n a,b,c,x,y,z,i,j,k,n:longint;\n begin\n readln(s);\n x:=0;\n if s[1]='1' then else begin Write('NO'); halt; end;\n for i:=1 to length(S) do \n begin\n if (s[i]='1') or (s[i]='4') then else begin Write('NO'); halt; end;\n if s[i]='4' then x:=x+1\n else if x>2 then begin Write('NO'); halt; end\n else x:=0; \n end;\n if x>2 then Write('NO') else Write('YES');\n end."}, {"source_code": "var\na,b,c,d,e:integer;\nfunction tl : boolean;\nbegin\nresult:=(a mod 10<>1) and (a mod 100<>14) and (a mod 1000<>144);\nend;\nbegin\nreadln(a);\nrepeat\n if a mod 10=1 then a:=a div 10;\n if a mod 100=14 then a:=a div 100;\n if a mod 1000=144 then a:=a div 1000;\nuntil (a=0) or (tl=true);\nif a=0 then \n writeln('YES')\nelse\n writeln('NO');\nend.\n"}, {"source_code": "program codeforcesa3;\nvar\n chk:integer;\n Num:string;\n i:byte;\nbegin\n readln(Num);\n chk:=0;\n if Num[1]<>'1'\n then chk:=-1\n else for i:=1 to length(Num) do begin\n if Num[i]='1'\n then chk:=1\n else if Num[i]='4' then inc(chk);\n if (chk>3) or (Num[i]<>'1') and (Num[i]<>'4') then begin\n chk:=-1;\n break;\n end;\n end;\n if chk=-1\n then writeln('NO')\n else writeln('YES');\nend.\n"}, {"source_code": "var s:string;\n z,i,p:longint;\n begin\n readln(s);\n repeat\n p:=0;\n inc(z);\n if (s[z]='1')and(s[z+1]='4')and(s[z+2]='4') then begin p:=1; z:=z+2; end;\n if (s[z]='1')and(s[z+1]='4')and(p=0) then begin p:=1; z:=z+1; end;\n if (s[z]='1')and(p=0) then begin p:=1; {inc(z);} end;\n if (p=0)and(z<=length(s)) then begin writeln('NO'); exit; end;\n until(z=length(s));\n writeln('YES');\n end.\n\n"}, {"source_code": "Var s:string;\nbegin\nreadln(s);\nwhile pos('144',s)<>0 do begin\ninsert('*',s,pos('144',s));\ndelete(s,pos('144',s),3);\nend;\n\n\nwhile pos('14',s)<>0 do begin\ninsert('*',s,pos('14',s));\ndelete(s,pos('14',s),2);\nend;\n\n\nwhile pos('1',s)<>0 do begin\ninsert('*',s,pos('1',s));\ndelete(s,pos('1',s),1);\nend;\n\nwhile pos('*',s)<>0 do begin\ndelete(s,pos('*',s),1);\nend;\n\nif s='' then writeln('YES') else writeln('NO');\n\nend.\n\n"}, {"source_code": "const fi = 'input.txt';\n fo = 'output.txt';\n\nvar s: string;\n n, i: longint;\n ok: boolean;\n\nbegin\n readln(s);\n n:=length(s);\n ok:=true;\n for i:=1 to n do\n if (s[i] <> '1') and (s[i] <> '4') then ok:=false;\n if ok then\n begin\n if (pos('444', s) > 0) or (s[1] = '4') then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var s:ansistring;\n i:longint;\n ok:boolean;\nbegin\n readln(s);\n ok:=true;\n if s[1]<>'1' then ok:=false;\n if pos('444',s)>0 then ok:=false;\n for i:=1 to length(s)do\n if not(s[i]in['1','4'])then ok:=false;\n if ok then writeln('YES')else writeln('NO');\nend."}, {"source_code": "var\na:int64;\nj,i,k:byte;\nb:array[1..10] of byte;\nr:boolean;\nbegin\nreadln(a);\ni:=1;\nwhile a>9 do\n begin\n b[i]:=a mod 10;\n a:=a div 10;\n i:=i+1;\n end;\nb[i]:=a;\nk:=0;\nr:=true;\nj:=0;\nwhile j2 then r:=false;\n end;\nif b[i]=4 then r:=false;\nif r=true then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "program A189;\nvar n, e, a, b, c, d:int64;\n i:integer;\nbegin\n readln(n);\n a:=1;\n b:=0;\n e:=0;\n while(a1) and (c<>4)) then\n begin\n d:=1;\n break;\n end\n else\n begin\n if c=4 then\n begin\n e:=e+1;\n if e>2 then d:=1;\n end\n else e:=0;\n end;\n a:=a*10;\n end;\n if c=4 then d:=1;\n if d=1 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var s:string; k:byte; ok:boolean;\nbegin\n readln(s);\n while (pos('144',s)>0) do\n begin\n k:=pos('144',s);\n delete(s,k,3); insert(' ',s,k);\n end;\n while (pos('14',s)>0) do\n begin\n k:=pos('14',s);\n delete(s,k,2); insert(' ',s,k);\n end;\n while (pos('1',s)>0) do\n begin\n k:=pos('1',s);\n delete(s,k,1); insert(' ',s,k);\n end;\n for k:=1 to length(s) do\n if (s[k]=' ') then ok:=true else\n begin\n ok:=false; break;\n end;\n if (ok=true) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,a,k1,k4:longint;\nbegin\nreadln(n);\na:=n;\nk1:=0;\nk4:=0;\nwhile a>0 do\n begin\n if a mod 10=1\n then a:=a div 10\n else if (a mod 10<>1) and (a mod 10<>4)\n then begin writeln('NO'); halt; end\n else begin\n if a mod 100=14 then a:=a div 100\n else if a mod 1000=144 then a:=a div 1000\n else begin writeln('NO'); halt; end;\n\n end;\n end;\nwriteln('YES');\nend.\n"}, {"source_code": "uses math;\nvar\n a:int64;\n s,d,f,g,h:LONGINT;\nbegin\n READLN(A);\n WHILE (A<>0) DO\n BEGIN\n IF (A MOD 10=1) THEN A:=A DIV 10 ELSE IF (A MOD 100=14) THEN A:=A DIV 100 ELSE IF (A MOD 1000=144) THEN A:=A DIV 1000 ELSE BEGIN WRITELN('NO');HALT; END;\n end;\n WRITELN('YES');\nend.\n\n"}, {"source_code": "var\n\ts : string;\n\ti,x : longint;\n\nbegin\n\treadln(s);\n\tx:=0;\n\tfor i:=1 to length(s) do begin\n\t\tif(s[i]='1')then x:=2\n\t\telse if(s[i]='4') then dec(x)\n\t\telse begin\n\t\t\twriteln('NO');\n\t\t\texit;\n\t\tend;\n\t\tif(x<0)then begin\n\t\t\twriteln('NO');\n\t\t\texit;\n\t\tend;\n\tend;\n\twriteln('YES');\nend.\t\n"}, {"source_code": "Program A320;\nVar\n n: LongInt;\n i: integer;\nBegin\n readln(n);\n while n > 0 do begin\n if (n mod 1000 <> 144) and (n mod 100 <> 14) and (n mod 10 <> 1) then break;\n n := n div 10;\n end;\n if n = 0 then writeln('YES') else writeln('NO');\nEnd."}], "negative_code": [{"source_code": "program abc;\nvar \ni:integer;\nn:integer;\ns:string;\nbegin\nreadln (n);\nstr (n,s);\nrepeat\ni:=pos ('144',s);\nif i <> 0 then delete (s,i,3);\ninsert ('a',s,i);\nuntil i = 0;\nrepeat\ni:=pos ('14',s);\nif i <> 0 then delete (s,i,2);\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos ('1',s);\nif i <> 0 then delete (s,i,1);\ninsert ('a',s,i);\nuntil i=0;\nrepeat\ni:=pos ('a',s);\nif i <> 0 then delete (s,i,1);\nuntil i=0;\nif length(s) = 0 then writeln ('yes') else writeln ('no');\nend."}, {"source_code": "VAR S:string;\n I:byte;\nBEGIN\nreadln(s);\nif s[1] <> '1' then\n write('NO')\nelse\n begin\n for i:=2 to length(s)-1 do\n begin\n if (s[i]<>'1') and (s[i] <>'4') then\n begin\n write('NO');\n BREAK;\n end\n else\n if (s[i]=s[i+1]) and (s[i]=s[i-1]) and (s[i]='4') then\n begin\n write('NO');\n break;\n end;\n end;\n write('YES');\n end;\nend."}, {"source_code": "var n:string;\nbegin\n readln(n);\n while pos('144',n)>0 do delete(n,pos('144',n),3);\n while pos('14',n)>0 do delete(n,pos('14',n),2);\n while pos('1',n)>0 do delete(n,pos('1',n),1);\n if n<>'' then writeln('NO') else writeln('YES');\nend."}, {"source_code": "var\n i, l, c:longint;\n s:string;\nbegin\nreadln(s);\nl:= length(s);\nfor i:=1 to l do \n begin\n if s[i]='1' then c:=i;\n if (i-c<=1) and (i>1) then if (s[i]='4') and (s[i-1]='1')then c:=i;\n if (i-c<=2) and (i>2) then if (s[i]='4') and (s[i-1]='4') and (s[i-2]='1') then c:=i;\n if (i-c>2) then begin write('NO'); exit; end;\n end;\n if c=l then writeln('YES') else write('NO');\nend."}, {"source_code": "var a:string;\n i :byte;\n\n\nbegin\n read(a);\n i:= 1;\n for i := 1 to length(a) do\n begin\n if ((a[i] <> '1') and (a[i] <> '4')) or (a[1] = '4') then\n begin\n write('no');\n exit;\n end;\n\n\n if (a[i] = '4')and (a[i+1]='4') and(a[i+2] = '4' ) then\n begin\n write('no');\n exit;\n end;\n end;\n write('yes');\nend.\n\n\n"}, {"source_code": "\nvar\ns:string;\na,b,c,i:longint;\nbegin\nreadln(s);\nfor i:=1 to length (s) do\nbegin\na:=pos('144',s);\ndelete(s,a,3);\nend;\nfor i:=1 to length (s) do\nbegin\nc:=pos('14',s);\ndelete(s,c,3);\nend;\nfor i:=1 to length (s) do\nbegin\nb:=pos('1',s);\ndelete(s,b,3);\nend;\nif length(s)=0 then\nwriteln('YES')\nelse\nwriteln('NO')\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n s:ansistring;\n i,j,k,dem,n:integer;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to n-1 do\n if (s[i]='1') and (s[i+1]='4') then\n begin\n dem:=0;\n for j:=i+1 to n do\n if s[j]='4' then\n inc(dem) else break;\n if (dem>2) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend."}, {"source_code": "var st,t:String;\n kt:boolean;\n\nbegin\n //assign(input,'magic_numbers.inp');\n //reset(input);\n //assign(output,'magic_numbers.out');\n //rewrite(output);\n readln(st);\n while pos('144',st)<>0 do\n delete(st,pos('144',st),3);\n while pos('14',st)<>0 do\n delete(st,pos('14',st),2);\n while pos('1',st)<>0 do\n delete(st,pos('1',st),1);\n if st='' then\n write('YES')\n else write('NO');\n\nend."}, {"source_code": "var n, i : longint;\n S : string[10];\n ok : boolean;\nbegin\n readln(n);\n str(n,S);\n ok := true;\n If pos('2',S) <> 0 then ok := false;\n If pos('3',S) <> 0 then ok := false;\n If pos('444',S) <> 0 then ok := false;\n If pos('5',S) <> 0 then ok := false;\n If pos('6',S) <> 0 then ok := false;\n If pos('7',S) <> 0 then ok := false;\n If pos('8',S) <> 0 then ok := false;\n If pos('9',S) <> 0 then ok := false;\n If ok then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s:string;\n a,b,c,x,y,z,i,j,k,n:longint;\n begin\n readln(s);\n x:=0;\n if s[1]='1' then else begin Write('NO'); halt; end;\n for i:=1 to length(S) do \n begin\n if (s[i]='1') or (s[i]='4') then else begin Write('NO'); halt; end;\n if s[i]='4' then x:=x+1\n else if x>2 then begin Write('NO'); halt; end\n else x:=0; \n end;\n Write('YES');\n end."}, {"source_code": "Var s:string; i,k:longint;\nbegin\nreadln(s);\ni:=1;\nfor i:=1 to length(s) do\nif (pos('144',s)<>0) then begin delete(s,pos('144',s),3); k:=k+1; end;\nfor i:=1 to length(s) do\nif (pos('14',s)<>0) then begin delete(s,pos('14',s),2); k:=k+1; end;\nfor i:=1 to length(s) do\nif (pos('1',s)<>0) then begin delete(s,pos('1',s),1); k:=k+1; end;\n\nif s='' then writeln('YES') else writeln('NO')\nend."}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, num : integer;\nbegin\n readln(n);\n while(n > 0) do begin\n num := n mod 10;\n if (num = 1) then\n n := n div 10\n else if (num = 4) then begin\n n := n div 10;\n num := num mod 10;\n if(num = 1) then\n n := n div 10\n else if (num = 4) then begin\n n := n div 10;\n if(n mod 10 = 1) then\n n := n div 10\n else begin\n n := 1;\n break;\n end;\n end else begin\n n := 1;\n break;\n end;\n end else\n break;\n end;\n\n if(n = 0) then\n writeln('YES')\n else\n writeln('NO');\n\n readln(n);\nend.\n"}, {"source_code": "program zad_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, num : integer;\nbegin\n readln(n);\n while(n > 0) do begin\n num := n mod 10;\n if (num = 1) then\n n := n div 10\n else if (num = 4) then begin\n n := n div 10;\n num := num mod 10;\n if(num = 1) then\n n := n div 10\n else if (num = 4) then begin\n n := n div 10;\n if(n mod 10 = 1) then\n n := n div 10\n else\n break;\n end else\n break;\n end else\n break;\n end;\n\n if(n = 0) then\n writeln('YES')\n else\n writeln('NO');\n\n readln(n);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n s: string;\nbegin\n readln(s);\n while pos('1',s) <> 0 do delete(s,pos('1',s),1);\n while pos('14',s) <> 0 do delete(s,pos('14',s),2);\n while pos('144',s) <> 0 do delete(s,pos('144',s),3);\n if s = '' then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var\n\ts : string;\n\ta : array[1..3]of string;\n\ti : longint;\n\nbegin\n\treadln(s);\n\ta[1]:='144';\n\ta[2]:='14';\n\ta[3]:='1';\n\tfor i:= 1 to 3 do begin\n\t\twhile(pos(a[i],s)>0)do begin\n\t\t\tdelete(s,pos(a[i],s),length(a[i]));\n\t\tend;\n\tend;\n\tif(length(s)=0)then writeln('YES')\n\telse writeln('NO');\nend.\t\n"}, {"source_code": "var a: string;\n\tdem,i,n: longint;\nbegin\n\tread(a);\n\tif a[1] <>'1' then\n begin\n write('NO');\n\texit;\n end;\n\tdem:=0;\n\tfor i:= 2 to length(a) do\n\t\tbegin\n\t\t\tif (a[i] <> '1') or ( a[i] <> '4') then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tif a[i] = '4' then inc(dem)\n\t\t\telse dem:=0;\n\t\t\tif dem > 2 then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n end;\n\twrite('YES');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n s : string;\n\nbegin\nreadln (s);\nwhile (pos ('144' , s) <> 0) do delete (s , pos ('144' , s) , 3);\nwhile (pos ('14' , s) <> 0) do delete (s , pos ('14' , s) , 2);\nwhile (pos ('1' , s) <> 0) do delete (s , pos ('1' , s) , 1);\nif (length (s) <> 0) then writeln ('NO')\nelse writeln ('YES');\nreadln;\nreadln;\nend.\n\n"}, {"source_code": "program bai1;\nvar s:string;\n\ti:longint;\nBEGIN\n readln(s);\n s:='44'+s;\n\tfor i:=3 to length(s) do if (s[i]='4') and (s[i-1]='4') and (s[i-2]='4') then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n\nEND."}, {"source_code": "program q;\nvar n,i,j :integer;\ns: string;\nbegin\nreadln (n);\nstr (n,s);\nrepeat\ni:=pos('144',s);\nif i<> 0 then delete (s,i,3)\nuntil i=0;\nrepeat\ni:=pos('14',s);\nif i<>0 then delete (s,i,2)\nuntil i=0;\nrepeat\ni:=pos('1',s);\nif i<>0 then delete (s,i,1)\nuntil i=0;\nif length (s)=0 then writeln ('YES') else writeln('NO');\nend."}, {"source_code": "var s : string;\n i : byte;\nbegin\n i := 0;\n read(s);\n if s[1] ='4' then begin write('NO') ; exit; end;\n for i:= 1 to length(s) do\n begin\n if( s[i] <> '4') and (s[i] <> '1') then\n begin\n write('NO');\n exit;\n end;\n end;\n if length(s) > 3 then\n for i:= 1 to length(s)-3 do\n if (s[i] = '4') and (s[i+1]='4') and\n (s[i+2] = '4') then\n begin\n write('NO');\n exit;\n end;\n write('YES');\nend.\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,nep,i, n,k : integer;\n s, s1,s2,s3,st: ansistring;\n f, g: boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(s);\n s1:='144'; \n s2:='14';\n s3:='1';\n f:=true;\n i:=1;\n n:=length(s); \n while i'1' then begin writeln('NO'); halt; end;\n while i<=n do\n begin\n if (s[i]<>'1')and(s[i]<>'4') then begin writeln('NO'); halt; end;\n if s[i]='4' then\n begin\n k:=0;\n while (i<=n)and(s[i]='4') do begin inc(k); inc(i); end;\n if k>2 then begin writeln('NO'); halt; end;\n end;\n inc(i);\n end;\n\n writeln('YES');\n\nEND."}, {"source_code": "var s:string;\n i,n,j:longint;\n fl:boolean;\nbegin\nreadln(s);\nfl:=true;\nfor i:=1 to length(s) do\n if (s[i]<>'4') and (s[i] <> '1')\n then fl:=false;\nif pos('444',s) >0 then fl:=false;\nif fl then writeln('YES')\n else writeln('NO'); \nend."}, {"source_code": "var\n i, l, c:longint;\n s:string;\nbegin\nreadln(s);\nl:= length(s);\nfor i:=1 to l do \n begin\n if (c=0) and (s[i]='1') then c:=i;\n if (i-c<=1) and (i>1) then if (s[i]='4') and (s[i-1]='1')then c:=i;\n if (i-c<=2) and (i>2) then if (s[i]='4') and (s[i-1]='4') and (s[i-2]='1') then c:=i;\n if (i-c>2) then begin write('NO'); exit; end;\n end;\n if c=l then writeln('YES') else write('NO');\nend."}, {"source_code": "var i:longint;\n s,s1,s2,s3:string;\nbegin\n read(s);\n while i<=length(s) do\n begin\n s1:=copy(s,i,1); s2:=copy(s,i,2); s3:=copy(s,i,3);\n if s3='144' then inc(i,3)\n else if s2='14' then inc(i,2)\n else if s1='1' then inc(i,1)\n else\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend."}, {"source_code": "var\n s:string;\n i,j,k:integer; t:boolean;\nbegin\n readln(s); t:=true;\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then t:=false;\n if t=true then begin\n repeat\n i:=pos('144',s);\n if (i<>0)and(s[i+3]<>'4') then delete(s,i,3);\n until (i=0)or(s[i+3]='4');\n repeat\n i:=pos('14',s);\n if (i<>0)and(s[i+2]<>'4') then delete(s,i,2);\n until (i=0)or(s[i+2]='4');\n repeat\n i:=pos('1',s);\n if i<>0 then delete(s,i,1);\n until i=0;\n if s<>'' then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\nend.\n"}, {"source_code": "{$o-}\nprogram abc;\nvar\n s:string;\n i,n:longint;\n\nprocedure f1;\nbegin\n assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\nend;\n\nprocedure f2;\nbegin\n close(input);\n close(output);\nend;\n\n\nbegin\n read(s);\n if s[1] = '4' then\n write('NO')\n else begin\n i:=1;\n n:=length(s);\n while (i <= n) and ((s[i] = '1') or (s[i] = '4')) do\n inc(i);\n if i > n then\n write('YES')\n else\n write('NO');\n end;\nend."}, {"source_code": "var s:string;\n a,b,c,x,y,z,i,j,k,n:longint;\n begin\n readln(s);\n x:=0;\n if s[1]='1' then else begin Write('NO'); halt; end;\n for i:=1 to length(S) do \n begin\n if (s[i]='1') or (s[i]='4') then else begin Write('NO'); halt; end;\n if s[i]='4' then x:=x+1\n else if x>2 then begin Write('NO'); halt; end\n else x:=0; \n end;\n Write('YES');\n end."}, {"source_code": "VAR S:string;\n I:byte;\n kt : boolean = true;\nBEGIN\nreadln(s);\nif s[1] <> '1' then\n write('NO')\nelse\n begin\n for i:=2 to length(s)-1 do\n begin\n if (s[i]<>'1') and (s[i] <>'4') then\n begin\n write('NO');\n kt := FALSE;\n BREAK;\n end\n else\n if (s[i]=s[i+1]) and (s[i]=s[i-1]) and (s[i]='4') then\n begin\n write('NO');\n KT := FALSE;\n break;\n end;\n end;\n IF KT THEN\n write('YES');\n end;\nend."}, {"source_code": "var\nc:array [1..1000000] of char;\ns:string;\ni,l,k:integer;\nbegin\nread(s);\nl:=length(s);\nfor i:=1 to l do\nc[i]:=s[i];\nc[l+1]:='0';\nfor i:=1 to l+1 do\n begin\nif (c[i]='1') and (c[i+1]='1') and (c[i+2]='4') then\nbegin\nc[i]:='0';\nc[i+1]:='0';\nc[i+2]:='0';\nend;\nif (c[i]='1') and (c[i+1]='4') then\nbegin\nc[i]:='0';\nc[i+1]:='0';\nend;\n end;\nfor i:=1 to l do\nif (c[i]='1') then\nc[i]:='0';\nfor i:=1 to l do\nif (c[i]<>'0') then\nk:=k+1;\nif (k=0) then\nwrite('YES');\nif (k>0) then\nwrite('NO')\nend."}, {"source_code": "Program A320;\nVar\n n: LongInt;\n i: integer;\nBegin\n readln(n);\n while n > 0 do begin\n if (n mod 1000 <> 144) or (n mod 100 <> 14) or (n mod 10 <> 4) then break;\n n := n div 10;\n end;\n if n = 0 then writeln('YES') else writeln('NO');\nEnd."}, {"source_code": "var\n a : string;\nprocedure xuli;\nvar\n i , dem : longint;\nbegin\n read( a );\n dem := 0;\n for i := 1 to length( a ) do\n begin\n if dem >= 3 then\n begin\n write( 'NO' );\n exit;\n end;\n if ( a[ i ] <> '1' ) and ( a[ i ] <> '4' ) then\n begin\n write( 'NO' );\n exit;\n end;\n if a[ i ] = '4' then\n begin\n if a[ i - 1 ] <> '1' then\n begin\n write( 'NO' ) ;\n exit;\n end\n else\n inc( dem );\n end;\n end;\n write( 'YES');\nend;\nbegin\n xuli;\nend.\n"}, {"source_code": "var a: string;\n\tdem,i,n: longint;\nbegin\n\tread(a);\n\tif a[1] <>'1' then\n begin\n write('NO');\n\texit;\n end;\n\tdem:=0;\n\tfor i:= 2 to n do\n\t\tbegin\n\t\t\tif (a[i] <> '1') or ( a[i] <> '4') then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tif a[i] = '4' then inc(dem)\n\t\t\telse dem:=0;\n\t\t\tif dem > 2 then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n end;\n\twrite('YES');\nend.\n"}, {"source_code": "var s:ansistring;\n ok:boolean;\n i:longint;\nbegin\n readln(s);\n for i:=1 to length(s)do\n delete(s,pos('144',s),3);\n for i:=1 to length(s)do\n delete(s,pos('14',s),2);\n for i:=1 to length(s)do\n delete(s,pos('1',s),1);\n if length(s)>0 then writeln('NO')else writeln('YES');\nend."}, {"source_code": "var n,i,l : longint;\n s : string;\n\nfunction kt(q : string) : boolean;\n begin\n kt := true;\n if q[1] <> '1' then exit(false);\n for i := 2 to l-1 do\n if (q[i] <> '1') and (q[i] <> '4') then exit(false) else\n if (q[i] = '4') and (q[i-1] = '4') and (q[i+1] = '4') then exit(false);\n end;\n\nbegin\n readln(n);\n str(n,s);\n l := length(s);\n if not(kt(s)) then writeln('NO')\n else writeln('YES');\nend.\n"}, {"source_code": " var s:ansistring;\n i,n,k:longint;\n\nBEGIN\n\n readln(s); i:=1; n:=length(s);\n while i<=n do\n begin\n if (s[i]<>'1')and(s[i]<>'4') then begin writeln('NO'); halt; end;\n if s[i]='4' then\n begin\n k:=0;\n while (i<=n)and(s[i]='4') do begin inc(k); inc(i); end;\n if k>2 then begin writeln('NO'); halt; end;\n end;\n inc(i);\n end;\n\n writeln('YES');\n\nEND."}, {"source_code": "var a: string;\n\tdem,i,n: longint;\nbegin\n\tread(a);\n\tif a[1] <>'1' then\n begin\n write('NO');\n\texit;\n end;\n\tdem:=0;\n\tfor i:= 2 to n do\n\t\tbegin\n\t\t\tif (a[i] <> '1') or ( a[i] <> '4') then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tif a[i] = '4' then inc(dem)\n\t\t\telse dem:=0;\n\t\t\tif dem > 2 then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend;\n end;\n\twrite('YES');\nend.\n"}, {"source_code": "program volchis;\nvar s:string[255];\ni,j:integer;\nbegin\nreadln(s);\ni:=1;\nwhile i<>0 do\nbegin\n while i<>0 do\n begin\n i:=pos('144',s);\n if i<>0 then\n begin\n delete(s,i,3);\n insert('a',s,i);\n end;\n end;\n i:=1;\n //writeln(s,' 1');\n while i<>0 do\n begin\n i:=pos('14',s);\n if i<>0 then\n begin\n insert('a',s,i);\n delete(s,i,2);\n end;\n end;\n i:=1;\n //writeln(s,' 2');\n while i<>0 do\n begin\n i:=pos('1',s); \n if i<>0 then\n begin \n delete(s,i,1);\n insert('a',s,i);\n end;\n end;\n i:=1;\n //writeln(s,' 3');\n while i<>0 do\n begin\n i:=pos('a',s); \n if i<>0 then\n begin \n delete(s,i,1);\n end;\n end;\n end;\n i:=length(s);\n if i=0 then writeln('YES') else writeln ('NO');\nend."}, {"source_code": "var ans,f1:integer;\nn:string;\nbegin\nread(n);\nif n[1]='4' then\n ans:=-1;\nfor f1:=1 to length(n) do\n begin\n if (n[f1]<>'1')and(n[f1]<>'4') then\n ans:=-1;\n if (f1>1)and(n[f1]='4')and(n[f1-1]<>'1') then\n ans:=-1; \n end;\nif ans=-1 then\n write('NO')\n else \n write('YES');\nend. \n \n"}, {"source_code": "var\n S:String;\n F:Boolean;\n i,Kol:Longint;\nbegin\n Readln(S);\n F:=True;\n for i:=1 to Length(S) do\nbegin\n if (S[i]<>'4') and (S[i]<>'1') then begin\n F:=False;\n Break;\n end;\n if S[i]='4' then Inc(Kol)\n else Kol:=0;\n if Kol>=3 then begin\n F:=False;\n Break;\n end;\n end;\n if F then Writeln('YES')\n else Writeln('NO');\n end."}, {"source_code": "program yan;\n var s:string[11]; i,j,x,y:byte;\nbegin\n read(s);\n if s[1]<>'1' then begin write('NO'); exit; end;\n for i:=1 to length(s) do\n if (s[i]<>'1')and(s[i]<>'4') then\n begin write('NO'); exit; end;\n for i:=1 to length(s)-1 do\n if (s[i]='4')and(s[i+1]='4') then\n begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "var s:string;\n n,i:longint;\n\nbegin\n { assign(input,'bai1.inp');\n reset(input);\n assign(output,'bai1.out');\n rewrite(output); }\n readln(s);\n n:=length(S);\n i:=1;\n while i<=n do\n if copy(s,i,3)='114' then i:=i+3\n else if copy(s,i,2)='14' then i:=i+2\n else if copy(s,i,1)='1' then inc(i)\n else\n begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\nend.\n\n\n\n"}, {"source_code": "program yan;\n var s:string[11]; i,j,x,y:byte;\nbegin\n read(s);\n if s[1]<>'1' then begin write('NO'); exit; end;\n for i:=1 to length(s) do\n if (s[i]<>'1')and(s[i]<>'4') then\n begin write('NO'); exit; end;\n for i:=1 to length(s)-1 do\n if (s[i]='4')and(s[i+1]='4') then\n begin write('NO'); exit; end;\n write('YES');\nend."}, {"source_code": "var s:string;\n a,b,c,x,y,z,i,j,k,n:longint;\n begin\n readln(s);\n x:=0;\n if s[1]='1' then else begin Write('NO'); halt; end;\n for i:=1 to length(S) do \n begin\n if (s[i]='1') or (s[i]='4') then else begin Write('NO'); halt; end;\n if s[i]='4' then x:=x+1\n else if x>2 then begin Write('NO'); halt; end\n else x:=0; \n end;\n Write('YES');\n end."}, {"source_code": "VAR S:string;\n I:byte;\n kt : boolean = true;\nBEGIN\nreadln(s);\nif s[1] <> '1' then\n write('NO')\nelse\n begin\n for i:=2 to length(s)-1 do\n begin\n if (s[i]<>'1') and (s[i] <>'4') then\n begin\n write('NO');\n kt := FALSE;\n BREAK;\n end\n else\n if (s[i]=s[i+1]) and (s[i]=s[i-1]) and (s[i]='4') then\n begin\n write('NO');\n KT := FALSE;\n break;\n end;\n end;\n IF KT THEN\n write('YES');\n end;\nend."}, {"source_code": "var s:string;\n i,n,j:longint;\n fl:boolean;\nbegin\nreadln(s);\nfl:=true;\nfor i:=1 to length(s) do\n if (s[i]<>'4') and (s[i] <> '1')\n then fl:=false;\nif pos('444',s) >0 then fl:=false;\nif fl then writeln('YES')\n else writeln('NO'); \nend."}, {"source_code": "Program _320A;\nvar\n a : array[1..10] of byte;\n n, i, t : longint;\nbegin\n read(n);\n i := 0;\n while n > 0 do\n begin\n i := i + 1;\n a[i] := n mod 10;\n n := n div 10;\n end;\n n := i;\n t := 0;\n for i := n downto 1 do\n case a[i] of\n 1:case t of\n 0,1,2: t := 0;\n else t := -1;\n end;\n 4:case t of\n 0, 1 : t := t + 1;\n else t := -1;\n end;\n else t := -1;\n end;\n if t >2 \n then t := -1;\n if t = -1\n then write('NO')\n else write('YES');\nend."}, {"source_code": "program A189;\nvar n, e, a, b, c, d, i:integer;\nbegin\n readln(n);\n a:=1;\n b:=0;\n e:=0;\n while(a1) and (c<>4)) then\n begin\n d:=1;\n break;\n end\n else\n begin\n if c=4 then\n begin\n e:=e+1;\n if e>2 then d:=1;\n end\n else e:=0;\n end;\n end;\n if d=1 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var\n s : string;\n len,i : byte;\n dani : boolean;\n\nbegin\n readln(s);\n len := length(s);\n dani := true;\n for i := 1 to len do\n if (s[i]<>'1') and (s[i]<>'4') then begin\n dani := false;\n writeln('NO');\n break;\n end;\n\n if dani then begin\n if pos('444',s)<>0 then begin\n dani := false;\n writeln('NO');\n end;\n end;\n\n if s[1]='4' then writeln('NO')\n else if dani then writeln('YES');\nend.\n"}, {"source_code": "var s : string;\n i : byte;\nbegin\n read(s);\n if s[1] ='4' then begin write('NO') ; exit; end;\n for i:= 1 to length(s) do\n begin\n if( s[i] <> '4') and (s[i] <> '1') then\n begin\n write('NO');\n exit;\n end;\n end;\n if length(s) > 3 then\n for i:= 2 to length(s)-3 do\n if (s[i] = '4') and (s[i+1]='4') and\n (s[i+2] = '4') then\n begin\n write('NO');\n exit;\n end;\n write('YES');\nend.\n\n\n"}, {"source_code": " var s:ansistring;\n i,n,k:longint;\n\nBEGIN\n\n readln(s); i:=1; n:=length(s);\n while i<=n do\n begin\n if (s[i]<>'1')and(s[i]<>'4') then begin writeln('NO'); halt; end;\n if s[i]='4' then\n begin\n k:=0;\n while (i<=n)and(s[i]='4') do begin inc(k); inc(i); end;\n if k>2 then begin writeln('NO'); halt; end;\n end;\n inc(i);\n end;\n\n writeln('YES');\n\nEND."}, {"source_code": "var\ns:string;\nb:boolean;\ni,j,k,pos1,jarak:integer;\n\nbegin\nreadln(s);\nb:=true;\npos1:=-2;\nfor k:=1 to length(s) do begin\n if (s[k]='1') then pos1:=k\n else if (s[k]='4') then begin\n jarak:=k-pos1;\n if (jarak=1) or (jarak=2) then continue\n else begin\n b:=false;\n break;\n end;\n end\n else begin\n b:=false;\n break;\n end;\n\n if b then writeln('YES')\n else writeln('NO');\nend;\n\nend."}, {"source_code": "program A189;\nvar n, e, a, b, c, d, i:integer;\nbegin\n readln(n);\n a:=1;\n b:=0;\n e:=0;\n while(a1) and (c<>4)) then\n begin\n d:=1;\n break;\n end\n else\n begin\n if c=4 then\n begin\n e:=e+1;\n if e>2 then d:=1;\n end\n else e:=0;\n end;\n end;\n if d=1 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "const fi = 'input.txt';\n fo = 'output.txt';\n\nvar s: string;\n n, i: longint;\n ok: boolean;\n\nbegin\n readln(s);\n n:=length(s);\n ok:=true;\n for i:=1 to n do\n if (s[i] <> '1') and (s[i] <> '4') then ok:=false;\n if ok then\n begin\n if (pos('444', s) > 0) then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\n s:string;\n i,j,k:integer; t:boolean;\nbegin\n readln(s); t:=true;\n for i:=1 to length(s) do\n if (s[i]<>'1') and (s[i]<>'4') then t:=false;\n if t=true then begin\n repeat\n i:=pos('144',s);\n if (i<>0)and(s[i+3]<>'4') then delete(s,i,3);\n until (i=0)or(s[i+3]='4');\n repeat\n i:=pos('14',s);\n if (i<>0)and(s[i+2]<>'4') then delete(s,i,2);\n until (i=0)or(s[i+2]='4');\n repeat\n i:=pos('1',s);\n if i<>0 then delete(s,i,1);\n until i=0;\n if s<>'' then writeln('NO')\n else writeln('YES');\n end\n else writeln('NO');\nend.\n"}, {"source_code": "var\n\ts : string;\n\ta : array[1..3]of string;\n\ti : longint;\n\nbegin\n\treadln(s);\n\ta[1]:='144';\n\ta[2]:='14';\n\ta[3]:='1';\n\tfor i:= 1 to 3 do begin\n\t\twhile(pos(a[i],s)>0)do begin\n\t\t\tdelete(s,pos(a[i],s),length(a[i]));\n\t\tend;\n\tend;\n\tif(length(s)=0)then writeln('YES')\n\telse writeln('NO');\nend.\t\n"}, {"source_code": "Var n:Longint;\n s,temp:String;\n ok:boolean;\n i:Longint;\nBegin\n Readln(n);\n str(n,s);\n\n ok:=true;\n\n for i:=1 to length(s) do\n If (s[i]<>'1') and (s[i]<>'4') then ok:=false;\n\n For i:=2 to length(s)-1 do\n If (s[i]='4') and (s[i+1]='4') and (s[i-1]<>'1') then ok:=false;\n\n If (ok) then Writeln('YES') Else Writeln('NO');\nEnd."}, {"source_code": "Var n:Longint;\n s,temp:String;\n ok:boolean;\n i:Longint;\nBegin\n Readln(n);\n str(n,s);\n\n ok:=true;\n\n for i:=1 to length(s) do\n If (s[i]<>'1') and (s[i]<>'4') then ok:=false;\n\n For i:=2 to length(s)-1 do\n If (s[i]='4') and (s[i+1]='4') and (s[i-1]<>'1') then ok:=false;\n\n If (ok) then Writeln('YES') Else Writeln('NO');\nEnd."}, {"source_code": "var n,a,k1,k4:longint;\nbegin\nreadln(n);\na:=n;\nk1:=0;\nk4:=0;\nwhile a>0 do \n begin\n if (a mod 10=1) or (a mod 10=4) \n then begin \n if a mod 10=1 \n then inc(k1)\n else inc(k4);\n a:=a div 10; \n end\n else begin writeln('NO'); halt; end;\n end;\nif (k1>0) and (k4=0) then writeln('YES');\nif k1=k4 then writeln('YES');\nif (k1<>0) and (k4<>0) \n then if (k1 div k4=2) or (k4 div k1=2) then writeln('YES');\nend."}, {"source_code": "var s:string;\n i,k,f:integer;\nbegin\nread(s);\nf:=0;\nfor i:=1 to length(s) do begin\n if s[i]='4' then inc(k)\n else if s[i]='1' then k:=0\n else f:=1;\n if k>=3 then f:=1;\n if f=1 then break;\nend;\nif f=0 then write('YES') else write('NO');\nend."}, {"source_code": "program project1;\n\n\nvar s : string [11];\n i: byte;\n\nbegin\n writeln ( ' enter string ', s );\n readln (s);\n\n repeat\n begin\n i:=pos( '144', s);\n delete ( s, i, 3 );\n end;\n until (i=0);\n repeat\n begin\n i:= pos ( '14',s);\n delete (s, i, 2);\n end;\n until ( i=0);\n repeat\n i:= pos ('1', s);\n delete ( s, i, 1);\n until (i=0) ;\n\n if length(s)=0 then\n writeln ( 'YES') else\n writeln ('NO');\n\n\n\nend."}, {"source_code": "var\ns:string;\na,b,c,i,d:longint;\nbegin\nreadln(s);\nfor i:=1 to length (s) do\nbegin\na:=pos('144',s);\ndelete(s,a,3);\ninsert(' ',s,a)\nend;\nfor i:=1 to length (s) do\nbegin\nc:=pos('14',s);\ndelete(s,c,2);\ninsert(' ',s,c)\nend;\nfor i:=1 to length (s) do\nbegin\nb:=pos('1',s);\ndelete(s,b,1);\ninsert(' ',s,b)\nend;\nbegin\nd:=pos(' ',s);\ndelete(s,d,1);\nend;\nif length(s)=0 then\nwriteln('YES')\nelse\nwriteln('NO')\nend."}, {"source_code": "var\n a : string;\nprocedure xuli;\nvar\n i , dem : longint;\nbegin\n read( a );\n dem := 0;\n for i := 1 to length( a ) do\n begin\n if dem >= 3 then\n begin\n write( 'NO' );\n exit;\n end;\n if ( a[ i ] <> '1' ) and ( a[ i ] <> '4' ) then\n begin\n write( 'NO' );\n exit;\n end;\n if a[ i ] = '1' then\n dem := 0;\n if a[ i ] = '4' then\n begin\n if ( dem = 0 ) and ( a[ i - 1 ] <> '1') then\n begin\n write( 'NO' ) ;\n exit;\n end\n else\n inc( dem );\n end;\n end;\n write( 'YES');\nend;\nbegin\n xuli;\nend.\n"}, {"source_code": "var n,k,i:longint;s:string;c:set of char;\nbegin\nreadln(s);\nif s[1]<>'1' then writeln('NO')else\nbegin\ni:=length(s);\nwhile i<>0 do\nbegin\nif (s[1]<>'1')and(s[1]<>'4')then begin writeln('NO');break;end else\n if s[1]='4' then begin\n if k>=2 then begin writeln('NO');break;end else begin inc(k);end ;\n end else k:=0;\n dec(i);delete(s,1,1);\n end;\n\n\n\nwriteln('YES');\nend;\nend.\n"}, {"source_code": "var\nn,m,q,w,l,r,mid,i,k:longint;\ns:string;\na,b:array[1..100000] of longint;\nc:array[0..1000, 0..1000] of int64;\nbegin\n {assign(input,'f.in');\n assign(output,'f.out');\n reset(input);\n rewrite(output); }\n read(s);\n if s[1]='4' then\n begin\n write('NO');\n exit;\n end;\n for i:=1 to length(s) do\n begin\n if (s[i]<>'1') and (s[i]<>'4') then\n begin\n write('NO');\n exit;\n end;\n if (s[i]='4') then inc(k);\n if k=3 then\n begin\n write('NO');\n end;\n if s[i]='1' then k:=0;\n end;\n write('YES');\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar m,nep,i, n,k : integer;\n s, s1,s2,s3: ansistring;\n f: boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(s);\n s1:='144'; \n s2:='14';\n \n while pos(s1, s)>0 do delete(s, pos(s1,s), 3);\n while pos(s2, s)>0 do delete(s, pos(s2,s), 2);\n //writeln(s);\n f:=true;\n for i:=1 to length(s) do \n if s[i]<>'1' then \n begin\n f:=false;\n break;\n end;\n if f then writeln('YES') else writeln('NO'); \nend.\n"}, {"source_code": "var s:string;\ni:longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\n if (s[i]='1')or(s[i]='4') then continue else begin writeln('NO');halt;end;\n writeln('YES');\n end."}, {"source_code": "//Uses math,sysutils,strutils;\nvar\nn,q,i,w:longint;\na:array[1..10]of integer;\nbegin\nread(n);\nw:=1;\nfor i:=1 to 10 do\na[i]:=0;\nq:=10;\nwhile n>0 do\nbegin\na[q]:=n mod 10;\nn:=n div 10;\nq:=q-1;\nend;\nq:=q+1;\nif a[q]<>1\nthen\nw:=0;\nif q>5\nthen\nfor i:=q+1 to 8 do\nif (a[i]=a[i+1]) and (a[i]=4) and (a[i]=a[i+2])\nthen\nw:=0;\nif q<10\nthen\nfor i:=q+1 to 10 do\nif (a[i]<>1) and (a[i]<>4)\nthen\nw:=0;\nif w=1\nthen\nwrite('YES')\nelse\nwrite('NO');\nend."}, {"source_code": "var\n i, l, c:longint;\n s:string;\nbegin\nreadln(s);\nl:= length(s);\nfor i:=1 to l do \n begin\n if s[i]='1' then c:=i;\n if (i-c<=1) and (i>1) then if (s[i]='4') and (s[i-1]='1')then c:=i;\n if (i-c<=2) and (i>2) then if (s[i]='4') and (s[i-1]='4') and (s[i-2]='1') then c:=i;\n if (i-c>2) then begin write('NO'); exit; end;\n end;\n if c=l then writeln('YES') else write('NO');\nend."}, {"source_code": "{$o-}\nprogram abc;\nvar\n s:string;\n i,n:longint;\n\nprocedure f1;\nbegin\n assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\nend;\n\nprocedure f2;\nbegin\n close(input);\n close(output);\nend;\n\n\nbegin\n read(s);\n if s[1] = '4' then\n write('NO')\n else begin\n i:=1;\n n:=length(s);\n while (i <= n) and ((s[i] = '1') or (s[i] = '4')) do\n inc(i);\n if i > n then\n write('YES')\n else\n write('NO');\n end;\nend."}, {"source_code": "var p:longint;\n s:string;\n\nbegin\n\n readln(s);\n\n while true do\n begin\n p:=pos('144',s);\n if (p>0) then delete(s,p,3)\n else break;\n end;\n\n while true do\n begin\n p:=pos('14',s);\n if (p>0) then delete(s,p,2)\n else break;\n end;\n\n while true do\n begin\n p:=pos('1',s);\n if (p>0) then delete(s,p,1)\n else break;\n end;\n\n if (s='') then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "program one;\nvar\ni, n: integer;\ns: string;\nbegin\nreadln (n);\nstr (n, s);\nrepeat\ni:= pos ('144', s);\nif i <> 0 then delete (s, i, 3);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('14', s);\nif i<>0 then delete (s, i, 2);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('1', s);\nif i<>0 then delete (s, i, 1);\ninsert ('a', s, i);\nuntil i = 0;\nif length (s) = 0\nthen\nwriteln ('YES')\nelse writeln ('NO');\nend."}, {"source_code": "var\n\ts : string;\n\ta : array[1..3]of string;\n\ti : longint;\n\nbegin\n\treadln(s);\n\ta[1]:='144';\n\ta[2]:='14';\n\ta[3]:='1';\n\tfor i:= 1 to 3 do begin\n\t\twhile(pos(a[i],s)>0)do begin\n\t\t\tdelete(s,pos(a[i],s),length(a[i]));\n\t\tend;\n\tend;\n\tif(length(s)=0)then writeln('YES')\n\telse writeln('NO');\nend.\t\n"}, {"source_code": "VAR S:string;\n I:byte;\nBEGIN\nreadln(s);\nif s[1] <> '1' then\n write('NO')\nelse\n begin\n for i:=2 to length(s)-1 do\n begin\n if (s[i]<>'1') and (s[i] <>'4') then\n begin\n write('NO');\n BREAK;\n end\n else\n if (s[i]=s[i+1]) and (s[i]=s[i-1]) and (s[i]='4') then\n begin\n write('NO');\n break;\n end;\n end;\n write('YES');\n end;\nend."}, {"source_code": "var s:string;\ni:longint;\nbegin\nreadln(s);\nfor i:=2 to length(s) do\n if (s[i]='4')and(s[i-1]='4') then begin writeln('NO');halt;end;\nfor i:=1 to length(s) do\n if (s[i]='1')or(s[i]='4') then continue else begin writeln('NO');halt;end;\n writeln('YES');\n end."}, {"source_code": "Var s:String;\ni:LongInt;\nBegin\n //ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (s);\n For I:=1 to Length (s) do\n If (s[i]<>'1') and (s[i]<>'4')\n then Begin\n Writeln ('NO');\n Halt (0);\n End;\n For I:=1 to Length (s)-2 do\n If (s[i]='4') and (s[i+1]='4') and (s[i+2]='4')\n then Begin\n Writeln ('NO');\n Halt (0);\n End;\n Writeln ('YES');\nEnd."}, {"source_code": "Program MagicNumbers;\nuses math;\nvar s:string;\nbegin //assign(input,'320A.inp'); reset(input);\n //assign(output,'320A.out'); rewrite(output);\n readln(s);\n while Pos('144',s)<>0 do delete(s,Pos('144',s),3);\n while Pos('14',s)<>0 do delete(s,Pos('14',s),2);\n while Pos('1',s)<>0 do delete(s,Pos('1',s),1);\n if s='' then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "var b:array [0..3]of string;\n s,l:string;\n k,i,p:longint;\n begin\n b[1]:='1';\n b[2]:='14';\n b[3]:='144';\n readln(s);\n l:=s;\n repeat\n p:=0;\n for i:=3 downto 1 do\n begin\n k:=pos(b[i],l);\n if k>0 then begin delete(l,k,i); p:=1; end;\n end;\n if p=0 then begin writeln('NO'); exit; end;\n until(length(l)=0);\n repeat\n p:=0;\n for i:=3 downto 1 do\n begin\n k:=pos(b[i],s);\n if k>0 then begin delete(s,k,i); p:=1;break; end;\n end;\n if p=0 then begin writeln('NO'); exit; end;\n until(length(s)=0);\n if (length(s)=0)or(length(l)=0) then writeln('YES');\n end.\n\n"}, {"source_code": " var s:ansistring;\n i,n,k:longint;\n\nBEGIN\n\n readln(s); i:=1; n:=length(s);\n while i<=n do\n begin\n if (s[i]<>'1')and(s[i]<>'4') then begin writeln('NO'); halt; end;\n if s[i]='4' then\n begin\n k:=0;\n while (i<=n)and(s[i]='4') do begin inc(k); inc(i); end;\n if k>2 then begin writeln('NO'); halt; end;\n end;\n inc(i);\n end;\n\n writeln('YES');\n\nEND."}, {"source_code": "var s : string;\n i : byte;\nbegin\n i := 0;\n read(s);\n if s[1] ='4' then begin write('NO') ; exit; end;\n for i:= 1 to length(s) do\n begin\n if( s[i] <> '4') and (s[i] <> '1') then\n begin\n write('NO');\n exit;\n end;\n end;\n if length(s) > 3 then\n for i:= 1 to length(s)-3 do\n if (s[i] = '4') and (s[i+1]='4') and\n (s[i+2] = '4') then\n begin\n write('NO');\n exit;\n end;\n write('YES');\nend.\n\n\n"}, {"source_code": " var s:ansistring;\n i,n,k:longint;\n\nBEGIN\n\n readln(s); i:=1; n:=length(s);\n if s[1]<>'1' then begin writeln('NO'); halt; end;\n while i<=n do\n begin\n if (s[i]<>'1')and(s[i]<>'4') then begin writeln('NO'); halt; end;\n if s[i]='4' then\n begin\n k:=0;\n while (i<=n)and(s[i]='4') do begin inc(k); inc(i); end;\n if k>2 then begin writeln('NO'); halt; end;\n end;\n inc(i);\n end;\n\n writeln('YES');\n\nEND."}, {"source_code": "var\n n:string;\n i,f:integer;\nbegin\n readln(n);\n if n[1]='1' then\n begin\n for i:=1 to length(n) do\n begin \n if ((n[i]='1') or (n[i]='4')) then\n begin\n f:=1;\n end\n else \n begin\n writeln('NO') ;\n f:=2;\n break;\n end;\n end;\n if f<>2 then writeln('YES');\n end\n else\n writeln('NO');\nend.\n "}, {"source_code": "program one;\nvar\ni, n: integer;\ns: string;\nbegin\nreadln (n);\nstr (n, s);\nrepeat\ni:= pos ('144', s);\nif i <> 0 then delete (s, i, 3);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('14', s);\nif i<>0 then delete (s, i, 2);\ninsert ('a', s, i);\nuntil i = 0;\nrepeat\ni:= pos ('1', s);\nif i<>0 then delete (s, i, 1);\ninsert ('a', s, i);\nuntil i = 0;\nif length (s) = 0\nthen\nwriteln ('YES')\nelse writeln ('NO');\nend."}, {"source_code": "program codeforcesa2;\nvar\n Num:int64;\n Check:set of byte;\n digit, test:integer;\nbegin\n readln(Num);\n Check:=[1, 14, 144];\n repeat\n test:=1000;\n digit:=Num mod test;\n if not (digit in Check) then begin\n repeat\n test:=test div 10;\n digit:=Num mod test;\n if digit in Check then break;\n if test=10 then begin\n writeln('NO');\n exit;\n end;\n until test=10;\n end;\n Num:=Num div test;\n until Num=0;\n writeln('YES');\nend."}, {"source_code": "var s:string;\n i,j,k,l,r,n,m:longint;\n begin\n readln(s);\n i:=1;\n s:=s+' ';\n while i<>length(s) do\n begin\n if s[i]='4' then begin writeln('NO'); halt; end;\n if s[i]=' ' then break;\n if (s[i+1]='4') and (s[i+2]='4') then inc(i,3) else\n if (s[i+1]='4') then inc(i,2) else inc(i,1);\n\n end;\n writeln('YES');\n end."}, {"source_code": "program q;\nvar a,b,c: integer;\ns:string;\nbegin\nreadln (a);\nstr (a,s);\nrepeat\nb:= pos('114',s);\nif b <> 0 then delete (s,b,3)\nuntil b=0;\nrepeat\nb:= pos('14',s);\nif b <> 0 then delete (s,b,2)\nuntil b=0;\nrepeat\nb:= pos('1',s);\nif b <> 0 then delete (s,b,1)\nuntil b=0;\nif length (s)=0 then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var s:string;\n a,b,c,x,y,z,i,j,k,n:longint;\n begin\n readln(s);\n x:=0;\n for i:=1 to length(S) do \n begin\n if (s[i]='1') or (s[i]='4') then else begin Write('NO'); halt; end;\n if s[i]='4' then x:=x+1\n else if x>2 then begin Write('NO'); halt; end\n else x:=0; \n end;\n Write('YES');\n end."}, {"source_code": "var\n a : string;\nprocedure xuli;\nvar\n i , dem : longint;\nbegin\n read( a );\n dem := 0;\n for i := 1 to length( a ) do\n begin\n if dem >= 3 then\n begin\n write( 'NO' );\n exit;\n end;\n if ( a[ i ] <> '1' ) and ( a[ i ] <> '4' ) then\n begin\n write( 'NO' );\n exit;\n end;\n if a[ i ] = '1' then\n dem := 0;\n if a[ i ] = '4' then\n begin\n if ( dem = 0 ) and ( a[ i - 1 ] <> '1') then\n begin\n write( 'NO' ) ;\n exit;\n end\n else\n inc( dem );\n end;\n end;\n write( 'YES');\nend;\nbegin\n xuli;\nend.\n"}, {"source_code": "var\na:int64;\nj,i,k:byte;\nb:array[1..10] of byte;\nr:boolean;\nbegin\nreadln(a);\ni:=1;\nwhile a>9 do\n begin\n b[i]:=a mod 10;\n a:=a div 10;\n i:=i+1;\n end;\nb[i]:=a;\nk:=0;\nr:=true;\nj:=0;\nwhile j2 then r:=false;\n end;\nif r=true then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s,k:string;\n i,j,l,m:longint;\n b:boolean;\nbegin\nreadln(s);\ni:=1;\nb:=true;\nk:=copy(s,i,3);\nwhile (b=true) and (i<= length(s)) do\nbegin\nif k='144' then begin\n inc(i,3);\n k:=copy(s,i,3);\n end\n else begin\n k:=copy(s,i,2);\n if k='14' then inc(i,2)\n else begin\n k:=copy(s,i,1);\n if k='1' then inc(i)\n else b:=false;\n end;\nend; end;\nif b=false then write('NO')\n else write('YES');\nend."}, {"source_code": "var s:string;i,dem:integer;kt:boolean;\nbegin\n read(s);dem:=0;kt:=true;\n if s[1] <> '1' then kt:=false;\n if s[1] ='1' then begin\n for i:=1 to length(s) do\n begin\n if s[i]='4' then inc(dem);\n if dem=3 then kt:=false;\n if s[i]='1' then dem:=0;\n end;end;\n if kt=true then write('YES');\n if kt=false then write('NO');\nend."}, {"source_code": "Var s:string; i,k:longint;\nbegin\nreadln(s);\ni:=1;\nfor i:=1 to length(s) do\nif (pos('144',s)<>0) then begin delete(s,pos('144',s),3); k:=k+1; end;\nfor i:=1 to length(s) do\nif (pos('14',s)<>0) then begin delete(s,pos('14',s),2); k:=k+1; end;\nfor i:=1 to length(s) do\nif (pos('1',s)<>0) then begin delete(s,pos('1',s),1); k:=k+1; end;\n\nif s='' then writeln('YES') else writeln('NO')\nend."}, {"source_code": "var a:string;\n i :byte;\n\n\nbegin\n read(a);\n i:= 1;\n for i := 1 to length(a) do\n begin\n if ((a[i] <> '1') and (a[i] <> '4')) or (a[1] = '4') then\n begin\n write('No');\n exit;\n end;\n\n\n if (a[i] = '4')and (a[i+1]='4') and(a[i+2] = '4' ) then\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend.\n\n\n"}, {"source_code": "Program _320A;\nvar\n a : array[1..10] of byte;\n n, i, t : longint;\nbegin\n read(n);\n i := 0;\n while n > 0 do\n begin\n i := i + 1;\n a[i] := n mod 10;\n n := n div 10;\n end;\n n := i;\n t := 0;\n for i := n downto 1 do\n case a[i] of\n 1:case t of\n 0,1,2: t := 0;\n else t := -1;\n end;\n 4:case t of\n 0, 1 : t := t + 1;\n else t := -1;\n end;\n else t := -1;\n end;\n if t >2 \n then t := -1;\n if t = -1\n then write('NO')\n else write('YES');\nend."}, {"source_code": "var s:string; i,f:integer; ans:boolean;\n\nbegin\nreadln(s);\nwhile pos('144',s)>0 do\n begin\n f:=pos('144',s);\n for i:= f to f+2 do s[i]:='x';\n end;\nwhile pos('14',s)>0 do\n begin\n f:=pos('14',s);\n for i:= f to f+3 do s[i]:='x';\n end;\nwhile pos('1',s)>0 do\n begin i:=pos('1',s); s[i]:='x'; end;\nans:=true;\nfor i:= 1 to length(s) do\n begin\n if s[i]<>'x' then ans:=false;\n end;\nif ans then writeln('YES') else writeln('NO');\n \nend.\n"}, {"source_code": "var s:string;\n i,k4,xx,c:integer;\n x:boolean;\nbegin\nreadln(s);\nk4:=0;\nx:=true;\nif s[1]='4' then x:=false else\n\n for i:=1 to length(s) do\n begin\n val(s[i],xx,c);\n if (xx<>1) and (xx<>4) then begin x:=false; writeln(xx); break end;\n if xx=1 then k4:=0;\n if xx=4 then inc(k4);\n if k4>2 then begin x:=false; break end;\n end;\n\nif x then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var i:longint;\n s,s1,s2,s3:string;\nbegin\n read(s);\n while i<=length(s) do\n begin\n s1:=copy(s,i,1); s2:=copy(s,i,2); s3:=copy(s,i,3);\n if s3='144' then inc(i,3)\n else if s2='14' then inc(i,2)\n else if s1='1' then inc(i,1)\n else\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend."}, {"source_code": "var ans,f1:integer;\nn:string;\nbegin\nread(n);\nif n[1]='4' then\n ans:=-1;\nfor f1:=1 to length(n) do\n begin\n if (n[f1]<>'1')and(n[f1]<>'4') then\n ans:=-1;\n if (f1>1)and(n[f1]='4')and(n[f1-1]<>'1') then\n ans:=-1; \n end;\nif ans=-1 then\n write('NO')\n else \n write('YES');\nend. \n \n"}, {"source_code": "var\n a : string;\nprocedure xuli;\nvar\n i , dem : longint;\nbegin\n read( a );\n dem := 0;\n for i := 1 to length( a ) do\n begin\n if dem >= 3 then\n begin\n write( 'NO' );\n exit;\n end;\n if ( a[ i ] <> '1' ) and ( a[ i ] <> '4' ) then\n begin\n write( 'NO' );\n exit;\n end;\n if a[ i ] = '1' then\n dem := 0;\n if a[ i ] = '4' then\n begin\n if ( dem = 0 ) and ( a[ i - 1 ] <> '1') then\n begin\n write( 'NO' ) ;\n exit;\n end\n else\n inc( dem );\n end;\n end;\n write( 'YES');\nend;\nbegin\n xuli;\nend.\n"}, {"source_code": "var\ni,ii : integer;\nn : ansistring;\nx : char;\nbegin\n read(n);\n if n[1] = '4' then\n begin\n write('NO');\n exit;\n end;\n for i := 1 to length(n) do\n begin\n if n[i] = '4' then\n begin\n for ii := i to i + 2 do\n if ii <= length(n) then\n begin\n if n[ii] = '4' then\n begin\n if ii = (i + 2) then\n begin\n write('NO');\n EXIT;\n end;\n end\n end;\n end;\n if ( n[i] <> '4') and ( n[i] <> '1') then\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend.\n"}], "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5"} {"source_code": "const\n nmax = 105;\nvar\n n,i,pos1,pos2 : integer;\n a : array[1..nmax] of integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n pos1:= 1;\n while (pos1 < n) and (a[pos1 + 1] > a[pos1]) do\n inc(pos1);\n pos2:= n;\n while (pos2 > 0) and (a[pos2 - 1] > a[pos2]) do\n dec(pos2);\n for i:=pos1 + 1 to pos2 do\n if a[i] <> a[i-1] then\n begin\n write('NO');\n halt;\n end;\n write('YES');\nEND.\n", "positive_code": [{"source_code": "var n,i:longint;\n x,y,z:boolean;\n a:array[1..100] of longint;\n\nprocedure xuat;\n begin\n write('NO');\n halt;\n end;\n\nprocedure xuli3(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF a[j+1]>=a[j] then xuat;\n write('YES');\n halt;\n end;\n\nprocedure xuli2(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF (a[j+1]>a[j]) then xuat\n else\n IF (a[j+1]=a[j] then xuat;\n write('YES');\n halt;\n end;\n\nprocedure xuli2(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF (a[j+1]>a[j]) then xuat\n else\n IF (a[j+1]a[2] then k:=4;\nif n=1 then k:=0;\n i:=3;\nif k=1 then for i:=3 to n do begin\n if a[i]=a[i-1] then begin\n k:=2;\n f:=i;\n break;\n end; \n if a[i]a[j-1]) then begin\n write('NO');\n k:=3;\n break;\n end; \n if (a[j]=a[i-1]) then begin\n write('NO');\n k:=3;\n break;\n end;\n if k<>3 then write('YES');\n end.\n"}, {"source_code": "var\nn,u,i,o:longint;\na:array[1..101]of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\ni:=2; if n=1 then begin\nwrite('YES'); halt; end;\nif a[n]=a[n-1] then a[n+1]:=a[n];\nif a[n]a[j+1] then q:=q+1;\n if q=0 then writeln ('Yes')else\n begin\n l:=1;\n while (a[l]<>a[l+1]) and (a[l]1) do\n begin\n if a[m]>a[m-1]then\n m:=m-1 else\n k:=1;\n end;\n if k<>0 then writeln('NO') else\n begin\n while a[z]=a[z+1] do\n z:=z+1;\n\n while (z<>n) and (k=0) do\n begin\n if a[z]>a[z+1]\n then z:=z+1 else k:=1;\n end;\n if k<>0 then writeln('NO') else\n writeln('Yes');\n end;\n end;\nend.\n\n"}, {"source_code": "var\n n,i,flag:longint;\n a:array[1..1000] of longint;\nbegin\n readln (n);\n for i:=1 to n do read(a[i]);\n flag:=1;\n i:=1;\n while (ia[i+1]) do\n inc(i);\n if (i=n) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var n,i,tang,giam,hue:longint;\n a:array [1..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n tang:=0; hue:=0; giam:=0;\n i:=2;\n while (a[i]>a[i-1]) and (i<=n) do\n begin\n tang:=i;\n inc(i);\n end;\n while (a[i]=a[i-1]) and (i<=n) do\n begin\n hue:=i;\n inc(i);\n end;\n if hue=0 then begin hue:=tang; dec(tang); end;\n while (a[i]= arr[i]) then incr := true;\n if (not incr) and (arr[i-1] > arr[i]) then ok := false;\n if (incr) and (not cons) and (arr[i-1] > arr[i]) then cons := true;\n if (incr) and (not cons) and (arr[i-1] < arr[i]) then ok := false;\n if (incr) and (cons) and (arr[i-1] <= arr[i]) then ok := false;\n end;\n if (ok) then write ('YES') else write ('NO');\n //readln (n);\nend."}, {"source_code": "const\n maxn = 100;\nvar\n check: boolean;\n n, i: shortint;\n a: array [1..maxn] of integer;\n\nbegin\n {assign(input, 'a.inp');\n reset(input);\n assign(output, 'a.out');\n rewrite(output);}\n\n readln(n);\n for i := 1 to n do read(a[i]);\n i := 1;\n while (a[i] < a[i+1]) and (i < n) do inc(i);\n while (a[i] = a[i+1]) and (i < n) do inc(i);\n while (a[i] > a[i+1]) and (i < n) do inc(i);\n if i = n then writeln('YES') else writeln('NO');\n\n\n {close(input);\n close(output);}\nend."}, {"source_code": "var a:array[0..200] of integer;\n i,j,z,max,vt1,vt2,n:integer;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n\n max:=a[1]; vt1:=1;\n for i:=2 to n do if a[i]>max then begin max:=a[i]; vt1:=i; end;\n for i:= vt1 to n do if a[i]=max then vt2:=i;\n i:=vt2;\n while (i1) and (a[j-1]=a[j] then xuat;\n write('YES');\n halt;\n end;\n\nprocedure xuli2(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF (a[j+1]>a[j]) then xuat\n else\n IF (a[j+1]a[i+1] then a[i]:=3;\nend;\n\n \n for i:=1 to n-2 do begin\n if a[i]>a[i+1] then begin \n write('NO');\n exit;\n end;\n end;\n \nwrite('YES');\nend."}, {"source_code": "type mas = array[1..100] of integer;\nvar n,i:byte;\n\ta:mas;\nBEGIN\n\tread(n);\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\t\n\ti:=1;\n\twhile (a[i]a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\t\n\t\n\t\n\tinc(i);\n\twhile (a[i]=a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\twriteln('YES');\nEND.\n\n"}, {"source_code": "var\nn,i:longint;\na:array[-10..10000]of longint;\nbol:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do begin\n if a[i]a[i+1] then a[i]:=3;\nend;\nfor i:=1 to n-2 do if a[i]>a[i+1] then bol:=true;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "var n:longint;\n i:longint;\n x,y:longint;\n a:array[0..110]of longint;\nbegin\n read(n);\n //x:=false;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]>a[i-1] then x:=i;\n for i:=1 to n do\n if a[i]>a[i+1] then\n begin\n y:=i;\n break;\n end;\n if x>y then\n begin\n writeln('NO');\n exit;\n end else\n begin\n for i:=1 to x-1 do\n if a[i]>=a[i+1] then\n begin\n writeln('NO');\n exit;\n end;\n for i:=y+1 to n do\n if a[i]>=a[i-1] then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n end;\nend.\n"}, {"source_code": "const fi='';\nvar\n a:array[1..100] of int32;\n n:int32;\n\nprocedure solve;\nvar i,l,r:int32; ok:boolean;\nbegin\n assign(input,fi); reset(input);\n readln(n);\n for i:=1 to n do read(a[i]);\n ok:= true;\n l:= 1;\n while (l1) and (a[r]l then\n begin\n if a[l]>a[l+1] then ok:= false;\n if a[r]>a[r-1] then ok:= false;\n end;\n if r-l>0 then\n for i:= l to r-1 do if a[i]<>a[i+1] then ok:= false;\n if ok then write('YES') else write('NO');\nend;\nbegin\n solve;\nend.\n"}, {"source_code": "var a:array[0..101]of longint;\n n,i,max,l,r,f:longint;\nbegin\n\treadln(n);\n\tfor i:=1 to n do read(a[i]);\n\tif n=1 then begin\n\t\twriteln('YES');\n\t\texit;\n\tend;\n\tif n=2 then begin\n\twriteln('YES');\n\texit;\n\tend;\n max:=a[1];\n for i:=2 to n do if a[i]>max then max:=a[i];\n l:=0;\n for i:=1 to n do if a[i]=max then begin\n \tl:=i;\n \tbreak;\n end;\n r:=n+1;\n for i:=n downto 1 do if a[i]=max then begin\n \tr:=i;\n \tbreak;\n end;\n f:=0;\n a[0]:=a[1]-1;\n if l<>r then for i:=l to r-1 do if a[i]<>a[i+1]then f:=1;\n for i:=0 to l-1 do if a[i]>=a[i+1] then begin\n \tf:=1;\n \tbreak;\n end;\n a[n+1]:=a[n]-1;\n for i:=n+1 downto r+1 do if a[i]>=a[i-1]then f:=1;\n if f=1 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var n,i:longint;A:array[0..100] of longint;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nbegin\n readln(n);\n if (n=1) then\n begin\n writeln('YES');\n halt;\n end;\n for i:=1 to n do\n read(A[i]);\nend;\nprocedure xuli;\nvar kt:longint;\nbegin\n kt:=1;\n if A[1]>A[2] then kt:=3;\n if A[1]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end\n else if (kt=2) and (A[i]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend;\nbegin\n // mo;\n nhap;\n xuli;\n // dong;\nend.\n\n"}, {"source_code": "{$mode objfpc}\n\nvar\n n:integer;\n o,last,i :integer;\n kind:integer;\n\nprocedure axx;\n begin\n write('NO'); halt;\n end;\n\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(o);\n if kind = 0 then\n begin\n if last = o then kind:=1;\n if last > o then kind:=2;\n end\n else\n if kind = 1 then\n begin\n if last < o then axx;\n if last > o then kind:=2;\n end\n else\n if kind = 2 then\n begin\n if last < o then axx;\n if last = o then axx;\n end;\n last:=o;\n end;\n write('YES');\nend."}, {"source_code": "\n const nn=1600000; nnn=200000;eps=0.0000000001;\n label 1,2;\n type real=extended; {string=ansistring;}\n int64=longint;\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;\n tt,ii,jj,step, i,j:longint;\n time:real;\n pole:array[-10..200,-10..200] of char;\n ssot,sssnew:array[-10..3000000] of char;\n smas:array[-10..2000000]of string;\n skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss3,ss1,ss2:string;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx,yy:array[-1..nn] of double;\n yot:double;\n prost:array [-1000..6000000] of boolean;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ii,jj:longint):boolean;\nvar i,j:longint; flag:boolean;\nbegin\n flag:=true;\n for i:=2 to ii do if a[i]<=a[i-1] then flag:=false;\n for i:=jj+1 to n do if a[i]>=a[i-1] then flag:=false;\n for i:=ii+1 to jj do if a[i]<>a[i-1] then flag:=false;\n\n good:=flag;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n); for i:=1 to n do read(a[i]);\n for ii:=1 to n do for jj:=ii to n do\n begin\n if good(ii,jj) then flag:=true;\n { writeln(ii,' ',jj,' ',good(ii,jj));\n } end;\n if flag then write('YES') else write('NO');\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "var\nn,k,i:integer;\na:array[1..101] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do \nread(a[i]);\nk:=0;\n\nfor i:=1 to n-1 do begin\nif a[i]a[i+1] then a[i]:=3;\nend;\n\n \n for i:=1 to n-2 do begin\n if a[i]>a[i+1] then begin write('NO');exit;end;\n end;\n \nwrite('YES');\nend."}, {"source_code": "var \n\tn, i, k, s: byte;\n\ta: array[1..100] of integer;\nbegin\n\treadln(n);\n\tfor i:=1 to n do read(a[i]);\n\tk:=1;\n\tfor i:=1 to n do\n\t\tif a[i+1] > a[i] then\n\t\t\tk:=i + 1\n\t\telse \n\t\t\tbreak;\n\ts:=n;\n\tfor i:=n downto 1 do\n\t\tif a[i - 1] > a[i] then\n\t\t\ts:=i - 1\n\t\telse\n\t\t\tbreak;\n\tfor i:=k to s - 1 do\n\t\tif a[i] <> a[i + 1] then \n\t\t\tbegin\n\t\t\t\twrite('NO');\n\t\t\t\texit;\n\t\t\tend;\n\twriteln('YES');\nend."}, {"source_code": "const\nfin='unimodal.inp';\nfon='unimodal.out';\nvar\na:array[1..100] of longint;\ni,j,n:longint;\nt,b,g,kt:boolean;\nbegin\n{assign(input,fin);reset(input);\nassign(output,fon);rewrite(output);}\nreadln(n);t:=true;\nb:=false;\ng:=false;kt:=true;\nfor i:=1 to n do read(a[i]);\nfor i:=2 to n do\n begin\n if t=true then\n begin\n {if a[i]a[i-1] then\n begin\n kt:=false;\n break;\n end;\n if a[i]=a[i-1] then\n begin\n kt:=false;\n break;\n end;\n end;\n end;\nif kt=true then write('YES')\nelse write('NO');\n{close(input);close(output);}\nend.\n"}, {"source_code": "var n,i,m:longint;\n a:array [1..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n m:=0;\n for i:=1 to n do\n begin\n if m=0 then\n begin\n if a[i]>a[i+1] then m:=2;\n if a[i]=a[i+1] then m:=1;\n end;\n if m=1 then\n begin\n if a[i]a[i+1] then m:=2;\n end;\n if m=2 then\n begin\n if a[i]<=a[i+1] then\n begin\n writeln('NO');\n exit;\n end;\n end;\n end;\n writeln('YES');\nend.\n\n"}, {"source_code": "var\ti,j,n:longint;\n\ta:array[0..105] of longint;\n\nbegin\n\treadln(n);\t\n\tfillchar(a,sizeof(a),0);\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\ti:=2;\n\tif a[i]>a[i-1] then\n\tbegin\n\t\twhile (i<=n) and (a[i]>a[i-1]) do inc(i);\n\tend;\n\tif a[i]=a[i-1] then\n\tbegin\n\t\twhile (i<=n) and (a[i]=a[i-1]) do inc(i);\n\tend;\n\tif a[i]n then writeln('YES') else writeln('NO');\nend."}, {"source_code": "const fi='test.inp';\n fo='test.out';\nvar a:array[0..1000] of longint;\n n:longint;\n kq:string;\nprocedure Nhap;\nvar i:longint;\nbegin\n //assign(input,fi);\n //reset(input);\n readln(n);\n for i:=1 to n do\n read(a[i]);\n //close(input);\nend;\n\nprocedure Main;\nvar i:longint;\nbegin\n kq:='NO'; i:=1; a[0]:=-1;\n\n while a[i-1]a[i] do inc(i);\n\n if i>=n+1 then kq:='YES';\nend;\nprocedure Xuat;\nbegin\n //assign(output,fo);\n //rewrite(output);\n write(kq);\n //close(output);\nend;\nbegin\n Nhap;\n main;\n Xuat;\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar a:array[1..101] of integer;\n n:integer;\n\nprocedure docf;\nvar f:text; i:integer;\nbegin\n assign(f,fi); reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\nend;\n\nprocedure solve;\nvar f:Text; i:integer;\nbegin\n assign(f,fo); rewrite(f);\n i:=2;\n while (i<=n) and (a[i-1]a[i]) do inc(i);\n if (i<=n) then writeln(f,'NO') else writeln(f,'YES');\n close(f);\nend;\n\nbegin\n docf;\n solve;\nend."}, {"source_code": "const\n fi='';\n fo='';\n maxn=100;\nvar n:longint;\n a:array[1..maxn]of longint;\nprocedure input;\nvar f:text;\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n for i:=1 to n do read(f,a[i]);\n close(f);\nend;\nfunction ans:boolean;\nvar base,i:longint;\nbegin\n base:=-1;\n for i:=2 to n do\n begin\n if(base=1)and(a[i]>=a[i-1])then exit(false);\n if(base=0)then\n begin\n if(a[i]>a[i-1])then exit(false);\n if(a[i]a[i-1]) and (i<=n) do\n begin\n tang:=i;\n inc(i);\n end;\n while (a[i]=a[i-1]) and (i<=n) do\n begin\n hue:=i;\n inc(i);\n end;\n if hue=0 then begin hue:=tang; dec(tang); end;\n while (a[i]a[i+1] then a[i]:=3;\n end;\n for i:=1 to n-2 do\n if a[i]>a[i+1] then begin write('NO');exit;end;\n write('YES');\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f:Text;\n a:array[1..101] of integer;\n n:byte;\nprocedure NHap;\nvar i:byte;\nbegin\n assign(f,fi);reset(F);\n read(f,n);\n for i:=1 to n do read(f,a[i]);\n close(F);\nend;\n\nprocedure process;\nvar i:byte;\nbegin\n assign(f,fo);rewrite(F);\n i:=1;\n while a[i]a[i+1] do inc(i);\n if (i=n+1) then writeln(f,'YES') else writeln(f,'NO');\n close(F);\nend;\n\nbegin\n NHap;\n process;\nend.\n"}, {"source_code": "var x,n,i,l:longint;\nvar r11,r21,r31,r32:boolean;\nbegin\n read(n);l:=0;\n for i:=1 to n do\n begin\n read(x);\n //if r1 and (x>l) then begin writeln('NO');exit;end;\n //if r2 and ((x=l) or (xthen begin writeln('NO');exit;end;\n //if not r1 and (xl) and not r11 then r11:=true\n else if (x>l) and r21 then begin writeln('NO');exit;end;\n if (x=l) and r11 and not r21 then begin r21:=true;end\n else if (x=l) and r31 then begin writeln('NO');exit;end;\n if (x1 then\n begin\n write('NO');\n halt;\n end\n end;\n end;\n write('YES');\nend."}, {"source_code": "Uses math;\nVar i,n,maxv,d,c,d1,d2:longint;\n kt:string;\n a:array[0..100+10] of longint;\n\nBEGIN\n Read(n);\n For i:=1 to n do\n BEGIN\n Read(a[i]);\n maxv:=max(maxv,a[i]);\n END;\n //kt:='YES';\n For i:=1 to n do\n If a[i]=maxv then begin d:=i; break; end;\n For i:=n downto 1 do\n If a[i]=maxv then\n BEGIN\n c:=i; break;\n END;\n For i:=d to c-1 do\n If a[i]<>a[i+1] then begin writeln('NO'); halt; end;\n d1:=1; d2:=1;\n For i:=2 to d do\n If a[i]>a[i-1] then inc(d1);\n For i:=n-1 downto c do\n If a[i]>a[i+1] then inc(d2);\n If (d1+d2+c-d-1=n) then writeln('YES') else writeln('NO');\nEND.\n\n"}, {"source_code": "program yan;\n var ar:array[1..1000]of integer;\n i,j,x,y,a,b,n,m:longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(ar[i]);\n for i:=1 to n-1 do\n begin\n if (ar[i]ar[i+1]) then y:=1\n else begin write('NO'); exit; end;\n end;\n write('YES');\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n a:array[1..100] of longint;\n k,i,j,n:longint;\n ans:string;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n ans:='YES';\n i:=1;\n j:=n;\n while (i1) and (a[j]a[i] then\n begin\n ans:='NO';\n break;\n end;\n write(ans);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var\n k,i,a,t,t1,t2,t3,errors:integer;\nbegin\n readln(k);\n read(t);\n for i:=2 to k do\n begin\n read(a);\n if (t 0)\n then\n writeln('NO')\n else\n writeln('YES');\nend."}, {"source_code": "var\n a:array[1..100]of integer;\n n,i,step,b:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\ni:=2;\nb:=a[1];\nwhile (a[i]>b) and (i<=n) do\n begin\n b:=a[i];\n inc(i);\n end;\nwhile (a[i]=b) and (i<=n) do\n begin\n b:=a[i];\n inc(i);\n end;\nwhile (a[i] a[pos1]) do\n inc(pos1);\n pos2:= n;\n while (pos2 > 0) and (a[pos2 - 1] > a[pos2]) do\n dec(pos2);\n for i:=pos1 + 1 to pos2 - 1 do\n if a[i] <> a[i+1] then\n begin\n write('NO');\n halt;\n end;\n write('YES');\nEND.\n"}, {"source_code": "const\n nmax = 105;\nvar\n n,i,vt : integer;\n a : array[1..nmax] of integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n vt:= 0;\n for i:=1 to n-1 do\n if a[i+1] <= a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n for i:=vt + 1 to n-1 do\n if a[i+1] <> a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n while (vt < n) do\n begin\n if a[vt + 1] > a[vt] then\n begin\n write('NO');\n halt;\n end;\n inc(vt);\n end;\n write('YES');\nEND.\n"}, {"source_code": "const\n nmax = 105;\nvar\n n,i,vt : integer;\n a : array[1..nmax] of integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n inc(n);\n a[n]:= 0;\n vt:= 0;\n for i:=1 to n-1 do\n if a[i+1] <= a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n for i:=vt + 1 to n-1 do\n if a[i+1] <> a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n while (vt < n) do\n begin\n if a[vt + 1] >= a[vt] then\n begin\n write('NO');\n halt;\n end;\n inc(vt);\n end;\n write('YES');\nEND.\n"}, {"source_code": "const\n nmax = 105;\nvar\n n,i,vt : integer;\n a : array[1..nmax] of integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n a[1]:= 0;\n readln(n);\n for i:=1 to n do readln(a[i+1]);\n a[n+2]:= 0;\n n:= n + 2;\n vt:= 0;\n for i:=1 to n-1 do\n if a[i+1] <= a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n for i:=vt + 1 to n-1 do\n if a[i+1] <> a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n while (vt < n) do\n begin\n if a[vt + 1] >= a[vt] then\n begin\n write('NO');\n halt;\n end;\n inc(vt);\n end;\n write('YES');\nEND.\n"}, {"source_code": "const\n nmax = 105;\nvar\n n,i,vt : integer;\n a : array[1..nmax] of integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n a[1]:= 0;\n readln(n);\n for i:=1 to n do read(a[i+1]);\n a[n+2]:= 0;\n n:= n + 2;\n vt:= 0;\n for i:=1 to n-1 do\n if a[i+1] <= a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n for i:=vt + 1 to n-1 do\n if a[i+1] <> a[i] then\n begin\n vt:= i;\n break;\n end;\n if vt = n then\n begin\n write('YES');\n halt;\n end;\n while (vt < n) do\n begin\n if a[vt + 1] >= a[vt] then\n begin\n write('NO');\n halt;\n end;\n inc(vt);\n end;\n write('YES');\nEND.\n"}, {"source_code": "const\n fi='';\n fo='';\n maxn=100;\nvar n:longint;\n a:array[1..maxn]of longint;\nprocedure input;\nvar f:text;\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n for i:=1 to n do read(f,a[i]);\n close(f);\nend;\nfunction ans:boolean;\nvar base,i:longint;\nbegin\n base:=-1;\n for i:=2 to n do\n begin\n if(base=1)and(a[i]>=a[i-1])then exit(false);\n if(base=0)then\n begin\n if(a[i]>a[i-1])then exit(false);\n if(a[i]a[i-1] then pr[i]:=true else break;\n sf[n]:=true;\n for i:=n-1 downto 1 do if a[i]>a[i+1] then sf[i]:=true else break;\n i:=2;\n while (i<=n) do\n begin\n l:=i;\n j:=i+1;\n while (a[j]=a[i]) do inc(j); dec(j);\n i:=j;\n if (pr[l]) and (sf[i]) then begin writeln('YES'); halt; end;\n inc(i);\n end;\n kol:=0;\n for i:=2 to n do if a[i]<>a[i-1] then inc(kol);\n if kol=0 then writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "var\n n,i,now,j,t:longint;\n a:array[0..1000]of longint;\n bo,boo:boolean;\nbegin\n read(n);\n read(a[1]);\n bo:=false;\n boo:=false;\n for i:=2to n do\n begin\n read(a[i]);\n if a[i]a[i-1] then\n begin\n if now=0 then now:=2;\n if now=1 then\n begin\n if bo then begin\n write('NO');\n halt;\n end\n else begin\n bo:=true;\n now:=2;\n end;\n end\n end\n else begin\n if bo then begin\n write('NO');\n halt;\n end;\n if t=0 then t:=a[i]\n else if t<>a[i] then\n begin\n write('NO');\n halt;\n end;\n end;\n end;\n write('YES');\nend."}, {"source_code": "Uses math;\nVar i,n,maxv,vt:longint;\n kt:string;\n a:array[0..100+10] of longint;\n\nBEGIN\n Read(n);\n For i:=1 to n do read(a[i]);\n vt:=1; maxv:=a[1]; kt:='YES';\n For i:=2 to n do\n If a[i]>=maxv then\n BEGIN\n vt:=i;\n maxv:=a[i];\n END;\n For i:=2 to vt do\n If a[i]a[i-1] then kt:='NO';\n Writeln(kt);\nEND.\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n a:array[1..100] of longint;\n k,i,j,n:longint;\n ans:string;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n);\n for i:=1 to n do read(a[i]);\n ans:='YES';\n i:=1;\n j:=n;\n while (i1) and (a[j-1]>a[j]) do dec(j);\n writeln(i);\n writeln(j);\n //if a[i]>a[i+1] then ans:='NO';\n //if a[j]>a[j-1] then ans:='NO';\n for k:=i to j do\n if a[k]<>a[i] then\n begin\n ans:='NO';\n break;\n end;\n write(ans);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var n,i:longint;\n x,y,z:boolean;\n a:array[1..100] of longint;\n\nprocedure xuat;\n begin\n write('NO');\n halt;\n end;\n\nprocedure xuli3(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF a[j+1]>=a[j] then xuat;\n write('YES');\n halt;\n end;\n\nprocedure xuli2(i:longint);\n var j:longint;\n begin\n for j:=i to n-1 do\n IF (a[j+1]>a[j]) then xuat\n else\n IF (a[j+1]a[j+1] then q:=q+1;\n if q=0 then writeln ('Yes')else\n begin\n l:=1;\n while (a[l]<>a[l+1]) and (a[l]1) do\n begin\n if a[m]>a[m-1]then\n m:=m-1 else\n k:=1;\n end;\n if k<>0 then writeln('NO') else\n begin\n while (z<>n) and (k=0) do\n begin\n if (a[z]>=a[z+1]) and (a[z]<=a[l])\n then z:=z+1 else k:=1;\n end;\n if k<>0 then writeln('NO') else\n writeln('Yes');\n end;\n end;\nend.\n\n"}, {"source_code": "var n,i,l,m,k,z,q,j:integer;\na: array [1..1000] of integer;\nbegin\n readln (n);\n for i:=1 to n do\n read(a[i]);\n for j:=1 to n-1 do\n if a[j]<>a[j+1] then q:=q+1;\n if q=0 then writeln ('Yes')else\n begin\n l:=1;\n while a[l]<>a[l+1] do\n l:=l+1;\n m:=l;\n z:=l;\n k:=0;\n while (k=0) and (m<>1) do\n begin\n if a[m]>a[m-1]then\n m:=m-1 else\n k:=1;\n end;\n if k<>0 then writeln('NO') else\n begin\n while (z<>n) and (k=0) do\n begin\n if (a[z]>=a[z+1]) and (a[z]<=a[l])\n then z:=z+1 else k:=1;\n end;\n if k<>0 then writeln('NO') else\n writeln('Yes');\n end;\n end;\nend.\n\n"}, {"source_code": "type mas = array[1..100] of integer;\nvar n,i:byte;\n\ta:mas;\nBEGIN\n\tread(n);\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\t\n\ti:=1;\n\twhile (a[i]a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\t\n\t\n\t\n\tinc(i);\n\twhile (a[i]=a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\twriteln('YES');\nEND.\n\n"}, {"source_code": "type mas = array[1..100] of integer;\nvar n,i:byte;\n\ta:mas;\nBEGIN\n\tread(n);\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\t\n\ti:=1;\n\twhile (a[i]a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\t\n\t\n\t\n\tinc(i);\n\twhile (a[i]=a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\twriteln('YES');\nEND.\n\n"}, {"source_code": "type mas = array[1..100] of integer;\nvar n,i:byte;\n\ta:mas;\nBEGIN\n\tread(n);\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\t\n\tif n=1 then \n\tbegin\n\t\twriteln('YES');\n\t\texit;\n\tend;\n\t\n\ti:=1;\n\twhile (a[i]a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\t\n\t\n\t\n\tinc(i);\n\twhile (a[i]=a[i-1] then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\twriteln('YES');\nEND.\n\n"}, {"source_code": "var\nn,i,ind:longint;\na:array[-1000..100000]of longint;\nbol:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\n read(a[i]);\nend;\nfor i:=2 to n do begin\n if a[i]<=a[i-1] then begin\n ind:=i-1;\n break;\n end;\nend;\n\n\nfor i:=2 to ind do begin\n if a[i]<=a[i-1] then bol:=true;\nend;\ni:=ind;\nwhile i<=n-1 do begin\n if a[i]=a[i+1] then begin\n\n inc(i);\n ind:=i;\n end\n else begin\n ind:=i;\n inc(i);\n break;\n end;\nend; {\nfor i:=ind to n-1 do begin\n if a[i]<>a[i+1] then begin\n ind:=i;\n break;\n end;\nend; }\nfor i:=ind+1 to n do begin\n if a[i]>=a[i-1] then bol:=true;\nend;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "var\nbol,bol1:boolean;\nn,i,ind:longint;\na:array[-100..1000]of longint;\nbegin\nreadln(N);\n\nfor i:=1 to n do read(A[i]);\nif n=1 then writeln('YES')\nelse begin\nfor i:=2 to n do begin\n if a[i]a[i+1] then begin\n bol1:=true;\n\n ind:=i;\n break;\n end;\nend;\n//writeln(ind);\nif bol1 then begin\n for i:=ind to n-1 do begin\n if a[i]<=a[i+1] then bol:=true;\n end;\nend;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend;\nend."}, {"source_code": "var n:longint;\n i:longint;\n x,y:longint;\n a:array[0..110]of longint;\nbegin\n read(n);\n //x:=false;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n if a[i]>a[i-1] then x:=i;\n for i:=1 to n do\n if a[i]>a[i+1] then\n begin\n y:=i;\n break;\n end;\n if x>y then\n begin\n writeln('NO');\n exit;\n end else\n begin\n for i:=y+1 to n do\n if a[i]>=a[i-1] then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\n end;\nend."}, {"source_code": "const fi='';\nvar\n a:array[1..100] of int32;\n n:int32;\n\nprocedure solve;\nvar i,l,r:int32; ok:boolean;\nbegin\n //assign(input,fi); reset(input);\n readln(n);\n for i:=1 to n do read(a[i]);\n ok:= true;\n l:= 1;\n while (la[l+1] then ok:= false;\n r:= n;\n while (r>1) and (a[r]a[r-1] then ok:= false;\n if r-l>0 then\n for i:= l to r-1 do if a[i]<>a[i+1] then ok:= false;\n if ok then write('YES') else write('NO');\nend;\nbegin\n solve;\nend.\n"}, {"source_code": "var n,i:longint;A:array[0..104] of longint;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nbegin\n readln(n);\n if (n=1) then\n begin\n writeln('YES');\n halt;\n end;\n for i:=1 to n do\n read(A[i]);\nend;\nprocedure xuli;\nvar kt:longint;\nbegin\n kt:=1;\n if A[1]>A[2] then\n begin\n writeln('NO');\n halt;\n end;\n if A[1]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end\n else if (kt=2) and (A[i]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend;\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend.\n\n"}, {"source_code": "var n,i:longint;A:array[0..100] of longint;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nbegin\n readln(n);\n if (n=1) then\n begin\n writeln('YES');\n halt;\n end;\n for i:=1 to n do\n read(A[i]);\nend;\nprocedure xuli;\nvar kt:longint;\nbegin\n kt:=1;\n if A[1]>A[2] then\n begin\n writeln('NO');\n halt;\n end;\n if A[1]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end\n else if (kt=2) and (A[i]A[i-1]) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend;\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend.\n\n"}, {"source_code": "var\nn,k,i:integer;\na:array[1..101] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do \nread(a[i]);\nk:=0;\n\nfor i:=1 to n-1 do begin\nif a[i]a[i+1] then a[i]:=3;\nend;\n\n\n\n \n for i:=1 to n-2 do begin\n if a[i]>a[i+1] then begin write('NO');exit;end;\n end;\n \nwrite('YES');\nend."}, {"source_code": "var n,i,m:longint;\n a:array [1..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n m:=0;\n for i:=1 to n do\n begin\n if m=0 then\n begin\n if a[i]>a[i+1] then\n begin\n writeln('NO');\n exit;\n end\n else\n if a[i]=a[i+1] then m:=1;\n end;\n if m=1 then\n begin\n if a[i]a[i+1] then m:=2;\n end;\n if m=2 then\n begin\n if a[i]<=a[i+1] then\n begin\n writeln('NO');\n exit;\n end;\n end;\n end;\n writeln('YES');\nend.\n\n"}, {"source_code": "\n const nn=1600000; nnn=200000;eps=0.0000000001;\n label 1,2;\n type real=extended; {string=ansistring;}\n int64=longint;\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;\n tt,ii,jj,step, i,j:longint;\n time:real;\n pole:array[-10..200,-10..200] of char;\n ssot,sssnew:array[-10..3000000] of char;\n smas:array[-10..2000000]of string;\n skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss3,ss1,ss2:string;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx,yy:array[-1..nn] of double;\n yot:double;\n prost:array [-1000..6000000] of boolean;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n); for i:=1 to n do read(a[i]);\n flag:=true;\n for i:=2 to n-1 do if 2*a[i]<(a[i-1]+a[i+1]) then\n flag:=false;\n if flag then write('YES') else write('NO');\n\n\n\n\n 1: close(output);\nend.\n\n\n"}], "src_uid": "5482ed8ad02ac32d28c3888299bf3658"} {"source_code": "var n,m,t,i,j,k:longint;\n ans:int64;\n begin\n readln(n,m);\n t:=(n+1) div 2;\n for i:=m+1 to t do\n begin\n k:=n-m;\n for j:=m+1 to n-m do\n begin\n while (k>m)and(k*(i+j)+j*(n-i+1)>=2*(n-i+1)*i) do dec(k);\n if k=m then break;\n ans:=ans+k-m;\n end;\n if i=n div 2 then ans:=ans*2;\n end;\n write(ans*3);\n end.", "positive_code": [{"source_code": "{$A+,B-,D-,E-,F-,G+,I-,L-,N+,O-,P+,Q-,R-,S-,T-,V-,X+,Y-} \n//uses math;\nvar\n ans:int64;\n i,j,up,n,m,x,y:longint;\n\nfunction min(x,y:longint):longint;inline;\nbegin\n if x0)and((a+b)mod n<>0)then writeln((a+b)mod n)\nelse if(b>0)and((a+b)mod n=0)then writeln(n)\nelse if(b<0)and(a=-b mod n)then writeln(n)\nelse if(b<0)and(a>-b)then writeln(a+b)\nelse writeln(n+(a+b)mod n);\nreadln;\nend.\n", "positive_code": [{"source_code": "var\n a,b,n, res : integer;\nbegin\n Readln(n,a,b);\n if b>=0 then res :=(a+b-1) mod n + 1\n else begin\n b:=b mod n;\n res := (n+a+b-1) mod n + 1;\n end;\n writeln(res);\nend."}, {"source_code": "program z_659_a;\nvar n,a,b,ans,d :integer;\nbegin\nreadln (n,a,b);\nans:=a+b - ((a+b)div n) * n;\nif ans<=0 then ans:=n+ans;\n//d:=b;\n//b:= b mod n;\n//if (d<0)and(b<>0) then \n//b:= n + b;\n//if a+b <= n then ans:=a + b\n//else ans:= (a + b) div n;\nwriteln(ans);\nend.\n"}, {"source_code": "const\n\tfi='';\n\tfo='';\nvar\n\ttep:text;\n\tn,a,b:longint;\n\tkq:longint;\nprocedure nhap;\nbegin\n\tassign(tep,fi);reset(Tep);\n\tread(tep,n,a,b);\n\tclose(tep);\nend;\n \nprocedure giai;\nvar i,tam,f:longint;\nbegin\n\t//assign(Tep,fo);rewrite(tep);\n\tif abs(b) mod n=0 then\n\tbegin\n\twrite(tep,a);\n\texit;\n\tend;\n\tif abs(b)>n then\n\t\tif b>0 then\n\t\t\tb:=(abs(b) mod n) else b:=-(abs(b) mod n);\n\ttam:=a+b;\n\tif tam>0 then\n\tif tam mod n <>0 then\n\tbegin\n\t\twrite(tep,tam mod n);\n\t\texit;\n\tend\n\telse \n\tbegin\n\t\twrite(tep,n);\n\t\texit;\n\tend;\n\tif tam <0 then\n\tbegin\n\t\twrite(tep,n+tam);\n\t\texit;\n\tend;\n\tif tam=0 then\n\tbegin\n\t\twrite(tep,n);\n\t\texit;\n\tend;\n//\tclose(Tep);\nend;\n \nbegin\n\tnhap;\n\tassign(Tep,fo);rewrite(tep);\n\tgiai;\n\tclose(tep);\nend."}, {"source_code": "program AAA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n arr=array[1..101]of integer;\nvar\n i,n,a,b,g:integer;\n\nbegin\n readln(n,a,b);\n if(b=0)then writeln(a);\n if(b<0)then begin\n if(b+a0)do begin\n dec(a);\n inc(b);\n if(a=0)then a:=n;\n end;\n writeln(a);\n end\n else writeln(a+b);\n end;\n if(b>0)then begin\n if(b+a>n)then begin\n g:=b+a;\n while(g>n)do\n g:=g-n;\n writeln(g);\n end\n else writeln (a+b);\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "program zadachaA;\nvar k,a,s,b,n:integer;\nbegin\n read(n,a,b);\n writeln;\n s:=(abs(b) div n) +1;\n if b<0 then k:=s*n+a+b\n\n else if b>0 then k:=a+b-(s-1)*n\n else k:=a;\n if K>n then k:=K-n;\n writeln(k)\nend."}, {"source_code": "{$mode objfpc}\n const inputfile='';\n outputfile='';\n var fi,fo:text;\n n, a ,b : integer;\n procedure nhap;\n begin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\n readLn(n, a, b);\n end;\n\n procedure solve;\n begin\n if b < 0 then\n begin\n b := abs(b);\n while b > 0 do\n begin\n a := a - 1;\n if a = 0 then a := n;\n b := b - 1;\n end;\n end\n else\n begin\n while b > 0 do\n begin\n a := a + 1;\n if a > n then a := 1;\n b := b - 1;\n end;\n end;\n end;\n\n procedure print;\n begin\n writeln(fo, a);\n close(fi);\n close(fo);\n end;\n\n begin\n nhap;\n solve;\n print;\n end.\n"}, {"source_code": "var\n n, a, b : longint;\n\nbegin\n readln(n, a, b);\n writeln(((a + b) mod n + n - 1) mod n + 1);\nend."}, {"source_code": "var\nn,a,b,c:integer;\nbegin\nreadln(n,a,b);\nc:=a+b;\nif c>n then\n repeat\n c:=c-n;\n until c<=n\n ELSE \nif c<=0 then repeat\n c:=c+n;\n until c>0;\n writeln(c);\n end."}, {"source_code": "var n,a,b:longint;\nbegin\n readln(n,a,b);\n writeln(((a+b) mod n+n-1) mod n+1);\nend."}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse if b<0 then\nfor i:=k downto 1 do\nbegin\ndec(a,1);\nif a<=0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "var n,a,b,ans:longint;\nbegin\n readln(n,a,b);\n ans:=(a+b+n*1000) mod n;\n if ans=0 then ans:=n;\n writeln(ans);\nend."}, {"source_code": "program prog1;\nvar n,a,b,x,y:longint;\nbegin\nread(n,a,b);\nif b=0 then write(a);\nif b>0 then \nbegin\nx:=(b mod n)+a;\nif x>n then write(x mod n) else write(x);\nend;\nif b<0 then \nbegin\ny:=a-(-b mod n);\nif y>0 then write(y) else write(n+y);\nend;\nend.\n"}, {"source_code": "uses math;\nvar i,n,a,b,s:integer;\n\nbegin\nread(n,a,b);\ns:=sign(b);\nb:=abs(b);\nfor i:=1 to b do begin\na+=s;\nif a>n then a:=1;\nif a<1 then a:=n;\nend;\nwriteln(a);\nend."}, {"source_code": "var\na,b,n:longint;\nbegin\nread(n,a,b);\nwrite(((a-1+b) mod n+n)mod n+1);\nend."}, {"source_code": "var a,b,n,a2,i:longint;\nbegin\n readln(n,a,b);\n a2:=a;\n if b>0 then begin\n for i:=1 to b do\n begin\n a2:=a2+1;\n if a2>n then a2:=1;\n end;\n end\n else begin\n b:=abs(b);\n for i:=1 to b do\n begin\n a2:=a2-1;\n if a2=0 then a2:=n;\n end;\n end;\n writeln(a2);\n\nend."}, {"source_code": "var n,a,b:integer;\nbegin\n read(n,a,b);\n write((((a-1+b)mod n)+n)mod n + 1);\nend."}, {"source_code": "program roundhouse;\nvar n,a,b,r,rr:integer;\nbegin\n readln(n,a,b);\n if b=0 then writeln(a);\n if b>0 then\n begin\n r:=b div n;rr:=b mod n;\n if r<1 then\n begin\n if (a+b<=n) then writeln(a+b)\n else writeln(a+b-n);\n end;\n if (r>=1) and (rr=0) then writeln(a);\n if (r>=1) and (rr>0) then\n begin\n if (a+rr<=n) then writeln(a+rr)\n else writeln(a+rr-n);\n end;\n end;\n if b<0 then\n begin\n r:=abs(b) div n;rr:=abs(b) mod n;\n if r<1 then\n begin\n if (a+b>0) then writeln(a+b)\n else writeln(a+b+n);\n end;\n if (rr=0) and (r>=1) then writeln(a);\n if (r>=1) and (rr<>0) then\n begin\n if (a-rr>0) then writeln(a-rr)\n else writeln(a-rr+n);\n end;\n end;\nend.\n"}, {"source_code": "var\n n,a,b:longint;\nbegin\n readln(n,a,b);\n if b>0 then writeln((a+(b mod n)-1) mod n+1)\n else writeln((a+n-(-b mod n)-1) mod n+1);\nend."}, {"source_code": "var n, k, g, p : Integer;\nbegin\n readln(n,g,k);\n While k < 0 do k := n + k;\n p := g + k;\n While p > n do p := p - n;\n writeln(p);\nend."}, {"source_code": "var n,a,b,k:integer;\nbegin\n read(n,a,b);\n k:=(b+a) mod n;\n if k=0 then k:=n;\n if k<0 then write(n+k) else write(k);\nend. "}, {"source_code": "const fi = '';\n fo = '';\nvar n, a, b, i: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,a,b);\n for i:=1 to abs(b) do if b < 0 then\n begin\n dec(a);\n if a= 0 then a:=n;\n end\n else\n begin\n inc(a);\n if a = n+1 then a:=1;\n end;\n write(a);\n\n close(input); close(output);\nend.\n"}, {"source_code": "//又是一个黑水题!!!\nvar n,a,b,ans:longint;\nbegin\n read(n,a,b);\n ans:=(a+b) mod n;//走过b个门\n ans:=(ans+n) mod n;//处理ans<0的情况\n if ans=0 then ans:=n;//处理ans=0的情况\n write(ans);//输出\nend.\n//код силы"}, {"source_code": "const fin='';\n fout='';\nvar n,a,b:longint;\n t:boolean;\n f,g:text;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,n,a,b);\n if b=0 then write(g,a)\n else\n begin\n t:=b>0;b:=abs(b);\n while b>n do b:=b-n;\n if t then a:=a+b\n else a:=a-b;\n if a<=0 then a:=a+n;\n if a>n then a:=a-n;\n write(g,a);\n end;\n close(f);close(g);\nend."}, {"source_code": "program pr4;\nvar a,b,c,n,x:integer;\nbegin\n readln(n,a,b);\n x:=abs(b) mod n;\n if b>0 then a:=a+x\n else a:=a-x;\n if a>n then c:=a-n\n else c:=a;\n if a<0 then c:=n-abs(a);\n if a=0 then c:=n;\n writeln(c);\nend."}, {"source_code": "var n,m,x,i:longint;\nbegin\n//assign(input,'yw.in');reset(input);\n//assign(output,'yw.out');rewrite(output);\nreadln(n,m,x);\nfor i:=1 to abs(x) do\n if x<0 then\n begin\n m:=m-1;\n if m=0 then m:=n;\n end\n else\n begin\n m:=m+1;\n if m=n+1 then m:=1;\n end;\nwriteln(m);\nclose(input);close(output);\nend.\n"}, {"source_code": "var\na,b,n:longint;\nbegin\nread(n,a,b);\nwrite(((a-1+b) mod n+n)mod n+1);\nend."}, {"source_code": "var a,b,n,c:int64;\nbegin\nreadln(n,a,b);\nif b>0 then while b<>0 do begin\n inc(a);\n if a>n then a:=1;\n dec(b)\n end;\nif b<0 then while b<>0 do begin\n dec(a);\n if a=0 then a:=n;\n inc(b)\n end;\nwriteln(a);\nend.\n"}, {"source_code": "var n,x,y,q:longint;\nbegin\nreadln(n,x,y);\nq:=((x+y) mod n+n) mod n;\nif q=0 then q:=n;\nwriteln(q);\nend."}, {"source_code": "var\n n,a,b,p:longint;\nbegin\n readln(n,a,b);\n if b<0 then p:=-1 else p:=1;\n b:=abs(b);\n while b<>0 do\n begin\n a:=a+p;\n if a=0 then a:=n;\n if a>n then a:=1;\n dec(b);\n end;\n writeln(a);\nend."}, {"source_code": "var\n n,a,b:longint;\nbegin\n read(n,a,b);\n if b>0 then\n begin\n if(a+b)mod n=0 then write(n)\n else\n write((a+b)mod n);\n end\n else\n begin\n b:=abs(b);\n if b0 then o:=o-(o div n)*n;\n\tif o=0 then writeln(n) else\n\twriteln(o);\nend."}, {"source_code": "var\n t,n,m,i,k:longint;\nbegin\n read(n,m,k);\n t:=m+(k mod n);\n i:=((n+t)mod n);\n if i=0 then write(n)else write(i);;\nend."}, {"source_code": "var\n n,a,b,x,y,i,j : integer ;\n\nbegin\n readln (n,a,b) ;\n if b > 0 then\n begin\n for i := 1 to b do\n begin\n inc(a) ;\n if a = n+1 then\n a := 1 ;\n end;\n end\n else if b < 0 then\n begin\n b := b * -1 ;\n for j := 1 to b do\n begin\n dec(a) ;\n if a = 0 then\n a := n ;\n end;\n end\n else\n a := a ;\n writeln (a) ;\nend.\n\n\n\n"}, {"source_code": "program A_Round_House;\nvar\n\tn,a,b:integer;\nbegin\nreadln(n, a, b);\n\nwhile b < 0 do\n\tb := b + n;\n\nwrite((a + b - 1) mod n + 1);\nend.\n"}, {"source_code": "var\nq,i,n,a,b:longint;\nbegin\nreadln(n,a,b);\nif b>=0 then begin\nfor i:=1 to b do begin\n inc(a);\n if a=n+1 then a:=1;\nend;\nwriteln(a);\nend else begin\n\nfor i:=1 to -b do begin\ndec(a);\nif a=0 then a:=n;\nend;\nwriteln(a);\nend;\nend."}, {"source_code": "var\na,b,n,i:integer;\nbegin\nread(n,a,b);\nif (b<>0) then begin\nfor i:=1 to abs(b) do begin\nif (b>0) then begin a:=a+1;\nif ((a-1)=n) then a:=1;\nif (a>=n) and (i<>abs(b)) then a:=a-n;\nif (a>n) and (i=abs(b)) then a:=1;\nend;\nif (b<0) then begin a:=a-1;\nif (a<=0) then a:=n;\nend;\nend;\nend;\nif (a=0) and (b<>0) then a:=n;\nwriteln(a);\nend."}, {"source_code": "var\na,b,n,q:longint;\nbegin\nreadln(n,a,b);\nq:=abs(b);\nif b=0 then writeln(a)\nelse begin\nwhile q<>0 do begin\n if b>0 then begin\n inc(a);\n dec(q);\n if a=n+1 then a:=1;\n end;\n if b<0 then begin\n dec(a);\n dec(q);\n if a=0 then a:=n;\n end;\nend;\nwriteln(a);\nend;\nend."}, {"source_code": "program TaskA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, a, b, num,i: integer;\nbegin\n Readln(n, a, b);\n if (b > 0) then\n num := 1\n else\n num := -1;\n b := abs(b);\n for i := 1 to b do\n begin\n a := a + num;\n if (a > n) then\n a := a mod n;\n if (a = 0) then\n a := n;\n end;\n Writeln(a);\n Readln;\nend.\n"}, {"source_code": "program A_659;\n\nvar\n n,a,b,ans:longint;\n\nbegin\n read(n,a,b);\n ans:=a+b mod n;\n if ans<=0\n then ans:=ans+n;\n if ans>n\n then ans:=ans mod n;\n write(ans);\nend."}, {"source_code": "var\n a,b,c,i,j,k,m,n:longint;\nbegin\n read(n,a,b);\n if b>0 then\n begin\n\n while b>0 do\n begin\n inc(a);\n dec(b);\n if a=n+1 then a:=1;\n end;\n end;\n if b<0 then\n begin\n b:=abs(b);\n while b>0 do\n begin\n dec(a);\n dec(b);\n if a=0 then a:=n;\n end;\n end;\n writeln(a);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar n,a,b,i:longint;\n\nBEGIN\n assign(input,fi);reset(input);\n read(n,a,b);\n close(input);\n\n assign(output,fo);rewrite(output);\n for i:=1 to abs(b) do begin\n if b<0 then dec(a);\n if b>0 then inc(a);\n if a>n then a:=1;\n if a<=0 then a:=n;\n end;\n if a>n then a:=1; if a<=0 then a:=n;\n write(a);\n close(output);\nEND.\n"}, {"source_code": "var n,a,b:longint;\nbegin\nreadln(n,a,b);\nwriteln(((((a+b-1) mod n )+n) mod n)+1);\nend."}, {"source_code": "var\n a, b, i, c: integer;\nbegin\n read(a, b, c);\n if c>0 then\n for i := 1 to c do \n begin\n if b = a then b := 1 else\n inc(b);\n end else \n for i := c*-1 downto 1 do \n begin\n if b = 1 then b :=a else\n dec(b);\n end;\n writeln(abs(b));\nend."}, {"source_code": "var o,a,b,n:longint;\nbegin\nreadln(n,a,b);\nif b=0 then write(a);\nif b>0 then begin\n o:=(a+b) mod n;\n if o=0 then o:=n;\n write(o);\n end;\nif b<0 then begin\n o:=(a+b) mod n;\n if 0>o then o:=n+o;\n if o=0 then o:=n;\n write(o);\n end;\nend.\n"}, {"source_code": "Var\n n,a,b:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n,a,b);\n b:=((b mod n)+n)mod n;\n a:=a+b;\n if a>n then\n dec(a,n);\n writeln(a);\nend."}, {"source_code": "var n,a,b,k:integer;\nbegin\nread(n,a,b);\nif b>0 then begin \nk:=(n+b) mod n;\nk:=k+a; end else begin\nk:=(n+b) mod n;\nif k<0 then k:=n+a+k else k:=a+k; end;\nif k<>n then k:=k mod n;\nwrite(k);\nend."}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\n\nif b>=0 then b:=b mod n else b:=-(abs(b) mod n);\nif a+b >n then writeln(a+b-n) else if a+b<=0 then writeln(n+a+b) else writeln(a+b);\nend."}, {"source_code": "var a,b,c,x,y,n:int64;\nbegin\nread(n, a, b);\nx:=a mod n;\ny:=b mod n;\nc:=(x+y) mod n;\nif c=0 then write(n) else begin\nif c<0 then write(c+n) else write(c);\nend;\nend."}, {"source_code": " Var a, b, n:integer;\n Begin\n readln(n,a,b);\n if abs(b) > n then\n b:= b mod n;\n b:= b+a;\n if (b > n) then\n b:= b - n;\n if (b < n) and (b < 0) then b:= n +b;\n if b = 0 then b:= n;\n writeln(abs(b));\n end."}, {"source_code": "var n,a,b,q:longint;\nbegin\nread(n,a,b);\n if b=0 then begin \n write(a);\n exit;\n end;\n \nif b<0 then begin \nb:=b*-1;\nq:=a-b;\nif qn then begin \n while q>n do\n begin\n q:=q-n;\n end;\n write(q);\n end else write(q);\n \nend. "}, {"source_code": "const fi='';\n fo='';\nvar n, a, b, res: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n,a,b);\n res:=(a+b) mod n;\n if res<=0 then res:=n+res;\n writeln(g,res);\n close(f); close(g);\nend."}, {"source_code": "\nvar\n n,a,b,i,dem:longint;\nbegin\n read(n,a,b);\n dem:=0;\n if b=0 then\n begin\n write(a);\n exit;\n end;\n if b<0 then\n repeat\n dec(a);\n\n if a=0 then a:=n;\n inc(dem);\n if dem=abs(b) then break;\n until false\n else\n repeat\n inc(a);\n if a=n+1 then a:=1;\n inc(dem);\n if dem=abs(b) then break;\n until false;\n write(a);\nend.\n"}, {"source_code": "var k,n,a,b:integer;\nbegin read(n,a,b); k:=(a+b)mod n; if (k<=0)then k:=k+n;\n write(k);\n end."}, {"source_code": "var a,b,n,k:integer;\nbegin\n readln(n,a,b);\n if b=0 then\n k:=a\n else\n begin\n b:=b mod n;\n if b>0 then\n begin\n k:=(a+b) mod n;\n if k=0 then\n k:=n;\n end\n else\n begin\n k:=(n+a+b) mod n;\n if k=0 then\n k:=n;\n end\n end;\n writeln(k);\n readln;\nend.\n\n\n"}, {"source_code": "program A_Home;\n\nvar\n n, a, b: integer;\n\nbegin\n Read(n, a, b);\n if abs(b) > n then \n b := b mod n;\n b := b + a;\n if b > n then \n b := b - n;\n if (b < n) and (b < 0) then b := n + b; \n if b = 0 then b := n;\n writeln(abs(b));\nend."}, {"source_code": "var x,n,a,b,k:integer;\nbegin\nreadln(n,a,b);\n\nif b>0 then\nk:= b mod n+a;\nif b<0 then\nk:=n+(b mod n+(a-1))+1;\nif k>n then\nk:=k mod n;\nif k=0 then\nk:=n;\nif b=0 then writeln(a)else\nwriteln(abs(k));\nend."}, {"source_code": "const nmax = 100;\nvar A,N,B,i,k: integer;\nbegin\n read(n,a,b);\n k:=a;\n if b > 0 then\n for i:=1 to b do\n if k=n then k:=1 else inc(k)\n else if b < 0 then\n for i:=1 to abs(b) do\n if k=1 then k:=n else dec(k);\n write(k);\nend.\n"}, {"source_code": "{Aleksey_b}\nvar n,m,k:longint;\n \nbegin\n readln(n,m,k);\n write(((m+k) mod n+n-1) mod n+1);\nend."}, {"source_code": "var a,b,c,ost:longint;\nbegin\n readln(a,b,c);\n b:=b+c;\n if (b>a) and (a=1) then b:=1\n else if b>a then begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end\n else if b<1 then\n begin\n b:=abs(b);\n if b>a then\n begin\n ost:=b mod a;\n if ost=0 then b:=0\n else b:=ost;\n end;\n if b=0 then b:=a\n else b:=a-b;\n end;\n writeln(b);\n\nend.\n"}], "negative_code": [{"source_code": "var n,a,b,t:longint;\n\nbegin\n readln(n,a,b);\n t:=a+abs(b);\n if t<=n then\n begin\n writeln(t);\n halt;\n end\n else\n repeat\n b:=abs(b)-n;\n until (a+abs(b))<=n;\n t:=a+abs(b);\n writeln(t);\n readln;\nend."}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse\nfor i:=k+1 downto 1 do\nbegin\ndec(a,1);\nif a<0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, a, b: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,a,b);\n write(abs(b mod n + a));\n\n close(input); close(output);\nend.\n"}, {"source_code": "var a,b,n,m,i,k:longint;\nc:array[1..1000]of longint;\nf:boolean;\nbegin\nread(n,a,b);\nfor i:=1 to n do\nc[i]:=i;\nif b<0\nthen\nf:=false\nelse\nf:=true;\nb:=abs(b);\ni:=a;\n if f=true\n then\n while b<>0 do\n begin\n inc(i);\n dec(b);\n if i>n\n then\n i:=1;\n k:=i;\n end;\n if f=false\n then\n while b<>0 do\n begin\n dec(i);\n dec(b);\n if i=0\n then\n i:=n;\n k:=i;\n end;\nwrite(k);\nend."}, {"source_code": "const fi='';\n fo='';\nvar n, a, b, res: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n,a,b);\n res:=(a+b) mod n;\n if res=0 then res:=n;\n writeln(g,res);\n close(f); close(g);\nend."}, {"source_code": "var n,x,y:longint;\n\ta:array[0..20009] of longint;\n\t\nProcedure Process;\nvar i:longint;\nbegin\nreadln(n,x,y);\nfor i:=1 to n*200 do\n\tif i mod n=0 then a[i]:=n else a[i]:=i mod n;\nif y<0 then writeln(a[n*99+x+y]) else writeln(a[x+y]);\nend;\n\t\nbegin\nProcess;\nend."}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n j, f: boolean;\n\nbegin\n j := false;\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and (b >= 0) then\n begin\n if(a = 37) then writeln(a) else\n writeln(abs(l));\n f := true;\n halt;\n end;\n if(l < n - 1) and (b <= 0) then\n begin\n if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then\n begin\n if((a=1) and(b=-100))\n then\n begin\n writeln(1);\n halt;\n \n end;\n j := true;\n end\n else if(j = false) then\n begin\n writeln(abs(l));\n f := true;\n j := true;\n halt;\n end;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if (f = false) then\n writeln(abs(l));\n if(j = true) and (f = true) then writeln(a);\nend."}, {"source_code": " const eps=0.00000000000001; besk=20000000008; nn=200000;\n label 1,2,3;\n type\n mas=array [0..nn] of int64; point=record x,y,z:extended;end;\n zap=record p1,p2,p3 :extended;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var otmax,otmin,told,q,pmin,pp,ppold,kk,t,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl:int64;\n diam,hh,i1,i2,newnapx,newnapy,napx,napy,time,jj,step, k,ii,i,tt,j:longint;\n p,ogr,ll,rr,v1,v2,aa,t1,t2,bb,cc:extended;\n ss:string;\n first,newc,d,c,aold,b,a:array[-10..2000000] of int64;\n vmax,z,x,y,dd1,dd2,dd3,dd4:array[-1..500000] of extended;\n text,text1,text2:array[-10..20000] of string;\n ss1,ss2:string;\n dost:array[-1..400,-1..400] of boolean;\n marked:array[0..200000] of boolean;\n sss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n st2:array[0..nn] of string;\n v0,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n koef,yot:extended;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n\n read(n,p1,p2);\n t:=(p1+p2+100000*n) mod n;\n if t=0 then t:=0;\n write(t);\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "var n,a,b,c,k:integer;\nbegin\nreadln(n,a,b);\nc:=b mod n;\nk:=a+c;\nk:=k mod n;\nif k<0 then k:=k*(-1);\nif (k=0)and(c<0) then k:=1;\nif (k=0)and(c>=0) then k:=n;\nwriteln(k);\nend.\n"}, {"source_code": "var a,b,c,ost:longint;\nbegin\n readln(a,b,c);\n b:=b+c;\n if b>a then begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end\n else if b<1 then\n begin\n b:=abs(b);\n if b>a then\n begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end;\n if b=0 then b:=a;\n end;\n writeln(b);\n\nend."}, {"source_code": "var n,a,b,c,k:integer;\nbegin\nreadln(n,a,b);\nc:=b mod n;\nk:=a+c;\nk:=k mod n;\nif k<0 then k:=k*(-1);\nif (k=0)and(c<0) then k:=1;\nif (k=0)and(c>0) then k:=n;\nwriteln(k);\nend.\n"}, {"source_code": "var\na,b,n,i:integer;\nbegin\nread(n,a,b);\nif (b<>0) then begin\nfor i:=1 to abs(b) do begin\nif (b>0) then begin a:=a+1;\nif (a>=n) then a:=0;\nend;\nif (b<0) then begin a:=a-1;\nif (a<=0) then a:=n;\nend;\nend;\nend;\nif (a=0) and (b<>0) then a:=n;\nwriteln(a);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, a, b: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,a,b);\n if abs(b mod n + a) = 0 then write(n)\n else write(abs(b mod n + a));\n\n close(input); close(output);\nend.\n"}, {"source_code": "program roundhouse;\nvar n,a,b,r,rr:integer;\nbegin\n readln(n,a,b);\n if b=0 then writeln(a);\n if b>0 then\n begin\n r:=b div n;rr:=b mod n;\n if r<1 then\n begin\n if (a+b<=n) then writeln(a+b)\n else writeln(a+b-n);\n end;\n if (r>=11) and (rr=0) then writeln(a);\n if (r>=1) and (rr>0) then\n begin\n if (a+rr<=n) then writeln(a+rr)\n else writeln(a+rr-n);\n end;\n end;\n if b<0 then\n begin\n r:=abs(b) div n;rr:=abs(b) mod n;\n if r<1 then\n begin\n if (a+b>0) then writeln(a+b)\n else writeln(a+b+n);\n end;\n if (rr=0) and (r>=1) then writeln(a);\n if (r>=1) and (rr<>0) then\n begin\n if (a-rr>0) then writeln(a-rr)\n else writeln(a-rr+n);\n end;\n end;\nend.\n"}, {"source_code": "var x,n,a,b,k:integer;\nbegin\nreadln(n,a,b);\n\nif b>0 then\nk:= b mod n+a;\nif k>n then\nk:=k mod n;\nif b<0 then\nk:=n+(b mod n+(a-1))+1;\nif b=0 then writeln(a)else\nwriteln(abs(k));\nend.\n"}, {"source_code": "var \nq,a,b,n,k:integer;\nbegin\nread(n,a,b);\nif b>0 then begin\nk:=a+b;\nwhile k>n do begin\nif k>n then k:=k-n;\nend;\nend\nelse begin\nq:=abs(b) mod n;\nk:=a-q+6;\nwhile k>n do begin\nif k>n then k:=k-n;\nend;\nend; \nwrite(k);\nend."}, {"source_code": "var\nn,a,b,q,i,t: integer;\nbegin\nreadln(n,a,b);\n\nif b>0 then begin\nif b mod n <> 0 then begin\nif (a+b) mod n<>0 then\nq:=(a+b) mod n else q:=n; end; end;\n\nif b = 0 then q:=a;\n\nif b<0 then begin\n\nif b*(-1) mod n = 0 then q:=a;\n\nif b*(-1) mod n <> 0 then begin\nt:=a+b;\nif t>0 then\nq:= t mod n;\nif t<0 then begin\nt:=t*(-1);\nfor i:=1 to n do\nif (t+i) mod n = 0 then q:=i; end;\nend; end;\nif q=0 then q:=n;\nwriteln(q);\nend.\n "}, {"source_code": "var n, a, b, c : longint;\nbegin\n readln(n, a, b);\n c := a + b;\n if c > n then\n while c > n do\n c := abs(c - n);\n if c < 0 then\n c := abs(n + c);\n writeln(c);\nend. \n "}, {"source_code": "uses math;\nvar\nn,a,b,i,o:integer;\nbegin\n\treadln(n,a,b);\n\to:=(a+b)-((a+b)div n)*n;\n\tif o=0 then writeln(n) else\n\twriteln(abs(o));\nend."}, {"source_code": "uses math;\nvar\n n,a,b:longint;\nbegin\n readln(n,a,b);\n if n=1 then writeln(1) else\n if (a+b mod n>n) then writeln(a+b mod n-n) else if a+b<1 then writeln(n+a+b mod n) else writeln(a+b mod n);\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if (c = 0) or (a = 1) or (abs(c) = a) then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": " Var a, b, n:integer;\n Begin\n readln(n,a,b);\n if abs(b) > n then\n b:= b mod n;\n b:= b+a;\n if (b > n) then\n b:= b - n;\n writeln(abs(b));\n end."}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n j, f: boolean;\n\nbegin\n j := false;\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and (b >= 0) then\n begin\n if(a = 37) then writeln(a) else\n writeln(abs(l));\n f := true;\n halt;\n end;\n if(l < n - 1) and (b <= 0) then\n begin\n if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then\n begin\n if((a=1) and(b=-100))\n then\n begin\n writeln(1);\n halt;\n \n end;\n j := true;\n end\n else if(j = false) then\n begin\n writeln(abs(l));\n f := true;\n j := true;\n halt;\n end;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if (f = false) then\n writeln(abs(l));\n if(j = true) and (f = true) then writeln(a);\nend."}, {"source_code": "var n, a, b, ans: longint;\nbegin\n read(n, a, b);\n ans := abs((a+b) mod n);\n if (ans = 0) then ans := n;\n write(ans);\nend."}, {"source_code": "var\na,b,n,i:integer;\nbegin\nread(n,a,b);\nif (b<>0) then begin\nfor i:=1 to abs(b) do begin\nif (b>0) then begin a:=a+1;\nif (a>=n) then a:=0;\nend;\nif (b<0) then begin a:=a-1;\nif (a<=0) then a:=n;\nend;\nend;\nend;\nif (a=0) and (b<>0) then a:=n;\nwriteln(a);\nend."}, {"source_code": "var i,a1,n,b,dem:longint;\n a:array[-1000..1000] of longint;\nbegin\n readln(n,a1,b);\n For i:=1 to n do a[i] :=i;\n dem :=n;\n For i:=0 downto -n+1 do\n begin\n a[i] :=dem;\n dec(dem);\n end;\n dem :=1;\n For i:=n+1 to 2*n do\n begin\n a[i] :=dem;inc(dem);\n end;\n writeln(a[a1+b]);\nend."}, {"source_code": "program prog1;\nvar n,a,b,x,y:longint;\nbegin\nread(n,a,b);\nif b=0 then write(a);\nif b>0 then \nbegin\nx:=(b mod n)+a;\nif x>n then write(x mod n) else write(x);\nend;\nif b<0 then \nbegin\ny:=abs(a-(-b mod n));\nwrite(y);\nend;\nend.\n"}, {"source_code": "var n,x,y:longint;\n\ta:array[0..20009] of longint;\n\t\nProcedure Process;\nvar i:longint;\nbegin\nreadln(n,x,y);\nfor i:=1 to n*200 do\n\tif i mod n=0 then a[i]:=n else a[i]:=i mod n;\nif y<0 then writeln(a[n*99+x+y]) else writeln(a[x+y]);\nend;\n\t\nbegin\nProcess;\nend."}, {"source_code": "var a,b,c,ost:longint;\nbegin\n readln(a,b,c);\n b:=b+c;\n if (b>a) and (a=1) then b:=1\n else if b>a then begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end\n else if b<1 then\n begin\n b:=abs(b);\n if b>a then\n begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end;\n if b=0 then b:=a\n else b:=a-b;\n end;\n writeln(b);\n\nend.\n"}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\nf:boolean;\nbegin\nf:=false;\n readln(n, a, b);\n l := a + b;\n if(a=-b) then \n begin\n writeln(1);\n halt;\n end;\n if(l < n - 1) then\n begin\n writeln(abs(l));\n f:=true;\n end;\n \n \n if(l > n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if f=false then\n writeln(abs(l));\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res:longint;\n begin\n read(fi,n,a,b);\n a:=a+b;\n while a<0 do a:=a+n;\n while a>n do a:=a-n;\n writeln(fo,a);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "const fi='';\n fo='';\nvar n,a,b,i:longint;\n\nBEGIN\n assign(input,fi);reset(input);\n read(n,a,b);\n close(input);\n\n assign(output,fo);rewrite(output);\n for i:=1 to abs(b) do begin\n if a>=n then a:=1;\n if a<=0 then a:=n;\n if b<0 then dec(a);\n if b>0 then inc(a);\n end;\n if a>n then a:=1; if a<=0 then a:=n;\n write(a);\n close(output);\nEND.\n"}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse if b<0 then\nfor i:=k+1 downto 1 do\nbegin\ndec(a,1);\nif a<0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "uses math;\nvar\nn,a,b,i,o:integer;\nbegin\n\treadln(n,a,b);\n\to:=(a+b)-((a+b)div n)*n;\n\tif o=0 then writeln(n) else\n\twriteln(abs(o));\nend."}, {"source_code": "var n,a,b,q:longint;\nbegin\nread(n,a,b);\n if b=0 then begin \n write(a);\n exit;\n end;\n \nif b<0 then begin \nb:=b*-1;\nq:=a-b;\nif qn then begin \n while q>n do\n begin\n q:=q-n;\n end;\n write(q);\n end else write(q);\n \nend. "}, {"source_code": "var a,b,c,ost:longint;\nbegin\n readln(a,b,c);\n b:=b+c;\n if b>a then begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end\n else if b<1 then\n begin\n b:=abs(b);\n if b>a then\n begin\n ost:=b mod a;\n if ost=0 then b:=b div a\n else b:=ost;\n end;\n if b=0 then b:=a;\n end;\n writeln(b);\n\nend."}, {"source_code": "var n,a,b,t:longint;\n\nbegin\n readln(n,a,b);\n t:=a+abs(b);\n if t<=n then\n begin\n writeln(t);\n halt;\n end\n else\n repeat\n b:=abs(b)-n;\n until (a+abs(b))<=n;\n t:=a+abs(b);\n writeln(t);\n readln;\nend."}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\n\nif b>=0 then b:=b mod n else b:=-(abs(b) mod n);\nif a+b >n then writeln(a+b-n) else if a+b<0 then writeln(n+a+b) else writeln(a+b);\nend."}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\nif n<>b then begin\n\nwhile abs(b)>n do if b>0 then b:=b-n else b:=b+n;\nif a+b>0 then writeln(a+b) else writeln(n+a+b);\nend\nelse writeln(1);\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res:longint;\n begin\n read(fi,n,a,b);\n a:=a+b;\n while a<0 do a:=a+n;\n while a>n do a:=a-n;\n writeln(fo,a);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\n a,b,n:longint;\nbegin\n readln(n,a,b);\n if (a+b+n)mod n=0 then writeln(n)\n else writeln((a+b+n)mod n);\nend.\n// I AK IOI!"}, {"source_code": "var n,a,b,q:longint;\nbegin\nread(n,a,b);\n if b=0 then begin \n write(a);\n exit;\n end;\n \nif b<0 then begin \nb:=b*-1;\nq:=a-b;\nif qn then begin \n while q>n do\n begin\n q:=q-n;\n end;\n write(q);\n end else write(q);\n \nend. "}, {"source_code": "program A_Round_House;\nvar\n\tn,a,b:integer;\nbegin\nreadln(n, a, b);\n\nif b < 0 then\n\tb := b + n;\n\nwrite((a + b - 1) mod n + 1);\nend.\n"}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n j, f: boolean;\n\nbegin\n j := false;\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and (b >= 0) then\n begin\n if(a = 37) then writeln(a) else\n writeln(abs(l));\n f := true;\n halt;\n end;\n if(l < n - 1) and (b <= 0) then\n begin\n if(a=2) and(b=-12) then \n begin\n writeln(2);\n halt;\n end;\n if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then\n begin\n \n if((a=1) and (b=-100)) then \n begin\n writeln(n);\n halt;\n end;\n \n if((a=2) and (b=-100) and (n=3) ) then \n begin\n writeln(n-a);\n halt;\n end;\n if((a=2) and (b=-100) and (n=2) ) then \n begin\n writeln(n);\n halt;\n end;\n \n j := true;\n end\n else if(j = false) then\n begin\n writeln(abs(l));\n f := true;\n j := true;\n halt;\n end;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l <= 0) then \n while(l < 0) do\n l := l + n;\n \n if (f = false) then\n writeln(abs(l));\n if(j = true) and (f = true) then writeln(a);\nend."}, {"source_code": "var a,b,n,c:int64;\nbegin\nreadln(n,a,b);\nb:=b mod n;\na:=a+b;\nif a>n then a:=a mod n;\nif a<0 then a:=n+a;\nwriteln(a);\nend.\n"}, {"source_code": "var d, n, b, a:integer;\nbegin\nread(n, a, b);\nif b = 0 then d:=a;\nif b > 0 then d:=(a + b) mod n;\nif d = 0 then d:=n;\nif b < 0 then d:=(n - (a - (abs(b) mod n))) mod n;\nif d = 0 then d:=n;\nwrite(d);\nend. \n"}, {"source_code": "var\nok:boolean;\ntmp,xx,yy,de:extended;\ni,j:longint;\nn,a,b: longint;\nflag: integer;\n\n\nbegin\nreadln(n,a,b);\nif b>=0 then writeln((a+b)mod n)\nelse begin\na:=a+b;\nif a<=0 then\nwhile (a<1) do \n a:=a+n;\n\nwriteln(a mod n);\nend;\nend."}, {"source_code": "const fi='';\n fo='';\nvar n, a, b, res: longint;\n f, g: text;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n,a,b);\n res:=(a+b) mod n;\n if res=0 then res:=n;\n writeln(g,res);\n close(f); close(g);\nend."}, {"source_code": "var a,b,n,c:int64;\nbegin\nreadln(n,a,b);\nb:=b mod n;\na:=a+b;\nif a>n then a:=a mod n;\nif a<0 then a:=n+a;\nwriteln(a);\nend.\n"}, {"source_code": "var n,a,b,k:shortint;\nbegin\nread(n,a,b);\nk:=(n+b) mod n;\nif k+a<=n then write(k+a) else write(k+a-n);\nend."}, {"source_code": "program A_659;\n\nvar\n n,a,b,ans:longint;\n\nbegin\n read(n,a,b);\n ans:=a+b mod n;\n if ans<=0\n then ans:=ans+n;\n write(ans);\nend."}, {"source_code": "var\na,b,n,i:integer;\nbegin\nread(n,a,b);\nif (b<>0) then begin\nfor i:=1 to abs(b) do begin\nif (b>0) then begin a:=a+1;\nif (a=n) then a:=0;\nend;\nif (b<0) then begin a:=a-1;\nif (a=0) then a:=n;\nend;\nend;\nend;\nif (a=n) and (b<>0) then a:=1;\nif (a=0) and (b<>0) then a:=n;\nwriteln(a);\nend.\n"}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\nif n<>b then begin\n\nwhile abs(b)>n do if b>0 then b:=b-n else b:=b+n;\nif a+b>0 then writeln(a+b) else writeln(n+a+b);\nend\nelse writeln(a);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, a, b: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,a,b);\n if abs(b mod n + a) = 0 then write(n)\n else write(abs(b mod n + a));\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\n a, b, i, n, k, l, j: integer;\n f: boolean;\n\nbegin\n readln(n, a, b);\n if(a = 2) and (b = 7) and (n = 3) then\n writeln(3);\n if(a = 2) and (b = -5) and (n = 6) then\n writeln(3);\n if(n=5) and (a=1) and(b=3) then\n writeln(3);\nend."}, {"source_code": "program acmp1;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar n,a,b:integer;\nbegin\nreadln(n,a,b);\nif(b=0)then writeln(a)\nelse if(b>0)and((a+b)mod n<>0)then writeln((a+b)mod n)\nelse if(b>0)and((a+b)mod n=0)then writeln(n)\nelse if(b<0)and(a=-b)then writeln(n)\nelse if(b<0)and(a>-b)then writeln(a+b)\nelse writeln(n+a+b);\nreadln;\nend.\n"}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n f: boolean;\n\nbegin\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and(b>=0) then\n begin\n writeln(abs(l));\n f := true;\n end;\n if(l < n - 1) and(b<=0) then\n begin\n writeln(abs(a));\n f := true;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if f = false then\n writeln(abs(l));\nend."}, {"source_code": "var\nn,a,b:longint;\nbegin\nreadln(n,a,b);\nif b>=0 then begin\nb:=b mod n;\n writeln(a+b);\nend else begin\n b:=b mod n;\nwriteln(a+(n+b));\nend;\nend."}, {"source_code": "var x,n,a,b:integer;\nBegin\n\t readln(n,a,b);\n\t if b=0 then x:=a;\n\t if b<0 then\n\t Begin\n\t\t x:=(a+b) mod (n+1);\n\t\t if x<1 then x:=(n)+x;\n\t\t if x=0 then x:=n;\n\t end;\n\t if b>0 then\n\t Begin\n\t\t x:=a+b;\n\t\t while x>n do x:=x-n;\n\t end;\n\t writeln(x);\nend."}, {"source_code": "Var a,b,n:longint;\n begin\n read(n,a,b);\n writeln(abs(a+b) mod n);\n end."}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n j, f: boolean;\n\nbegin\n j := false;\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and (b >= 0) then\n begin\n if(a = 37) then writeln(a) else\n writeln(abs(l));\n f := true;\n halt;\n end;\n if(l < n - 1) and (b <= 0) then\n begin\n if ((abs(a)) > abs(l)) or (a = 37) or(b=-100) then\n begin\n if((a=1) and(b=-100))\n then\n begin\n writeln(1);\n halt;\n \n end;\n j := true;\n end\n else if(j = false) then\n begin\n writeln(abs(l));\n f := true;\n j := true;\n halt;\n end;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if (f = false) then\n writeln(abs(l));\n if(j = true) and (f = true) then writeln(a);\nend."}, {"source_code": "const fin='';\n fout='';\nvar n,a,b:longint;\n t:boolean;\n f,g:text;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,n,a,b);\n if b=0 then write(g,a)\n else\n begin\n t:=b>0;b:=abs(b);\n while b>n do b:=b-n;\n if t then a:=a+b\n else a:=a-b;\n if a<0 then a:=a+n;\n if a>n then a:=a-n;\n end;\n write(g,a);\n close(f);close(g);\nend."}, {"source_code": "var\nn,a,b,k:longint;\nbegin\nread(n,a,b);\nif (a+b<=n) and (b>0)\nthen\nk:=a+b\nelse\nif (a+b>0) and (b<0)\nthen\nk:=a+b\nelse\nif a+b>n\nthen\nbegin\nk:=b+a-n;\nwhile k>n do\nk:=k-n;\nend\nelse\nif b=0\nthen\nk:=a\nelse\nif a+b<0\nthen\nbegin\nk:=a+b;\nwhile k<0 do\nk:=k+n;\nend\nelse\nif a+b=0\nthen\nk:=a;\nif n=1\nthen\nk:=1; \nwrite(k);\nend."}, {"source_code": "var\n a, b, i, n, k, l, j: integer;\n f: boolean;\n\nbegin\n readln(n, a, b);\n if(a = 2) and (b = 7) and (n = 3) then\n writeln(3);\n if(a = 2) and (b = -5) and (n = 6) then\n writeln(3);\n if(n=5) and (a=1) and(b=3) then\n writeln(4);\n if(n=1) and (a=1) and(b=0) then\n writeln(1);\nend."}, {"source_code": "var n,a,b,k:shortint;\nbegin\nread(n,a,b);\nk:=(n+b) mod n;\nif k+a<=n then write(k+a) else write(k+a-n);\nend."}, {"source_code": "var \nq,a,b,n,k:integer;\nbegin\nread(n,a,b);\nif b>0 then begin\nk:=a+b;\nwhile k>n do begin\nif k>n then k:=k-n;\nend;\nend\nelse begin\nq:=abs(b) mod n;\nk:=a-q+6;\nwhile k>n do begin\nif k>n then k:=k-n;\nend;\nend; \nwrite(k);\nend."}, {"source_code": "var n, k, g, p : Integer;\nbegin\n readln(n,g,k);\n If k < 0 then k := n + k;\n p := g + k;\n While p > n do p := p - n;\n writeln(p);\nend."}, {"source_code": "var n,a,b,t,dem:longint;\n\nbegin\n readln(n,a,b);\n dem:=0;\n if b=0 then\n begin\n writeln(a+(n div 2));\n halt;\n end;\n t:=a+abs(b);\n if t<=n then\n begin\n writeln(t);\n halt;\n end\n else if b<0 then\n begin\n t:=a;\n repeat\n inc(dem);\n if t-1>=1 then dec(t) else t:=n;\n until dem=abs(b);\n end\n else\n begin\n t:=a;\n repeat\n inc(dem);\n if t+1<=n then inc(t) else t:=1;\n until dem=abs(b);\n end;\n writeln(t);\n readln;\nend.\n"}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse if b<0 then\nfor i:=k+1 downto 1 do\nbegin\ndec(a,1);\nif a<0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if (c = 0) or (a = 1) then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\n\nif b>=0 then b:=b mod n else b:=-(abs(b) mod n);\nif a+b >n then writeln(a+b-n) else if a+b<0 then writeln(n+a+b) else writeln(a+b);\nend."}, {"source_code": "const fin='';\n fout='';\nvar n,a,b:longint;\n t:boolean;\n f,g:text;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n readln(f,n,a,b);\n if b=0 then write(g,a)\n else\n begin\n t:=b>0;b:=abs(b);\n while b>n do b:=b-n;\n if t then a:=a+b\n else a:=a-b;\n if a<0 then a:=a+n;\n if a>n then a:=a-n;\n write(g,a);\n end;\n close(f);close(g);\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if (c = 0) or (a = 1) then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": "program zadachaA;\nvar k,a,s,b,n:integer;\nbegin\n read(n,a,b);\n writeln;\n s:=(abs(b) div n) +1;\n if b<0 then k:=s*n+a+b\n\n else if b>0 then k:=a+b-(s-1)*n\n else k:=a;\n writeln(k)\nend."}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n f: boolean;\n\nbegin\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and(b>=0) then\n begin\n writeln(abs(l));\n f := true;\n end;\n if(l < n - 1) and(b<=0) then\n begin\n writeln(abs(a));\n f := true;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if f = false then\n writeln(abs(l));\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if (c = 0) or (a = 1) then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": "var\nn,a,b,k:longint;\nbegin\nread(n,a,b);\nif (a+b<=n) and (b>0)\nthen\nk:=a+b\nelse\nif (a+b>0) and (b<0)\nthen\nk:=a+b\nelse\nif a+b>n\nthen\nk:=b+a-n\nelse\nif b=0\nthen\nk:=a;\nwrite(k);\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if (c = 0) or (a = 1) or (abs(c) = a) then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": "program TaskA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, a, b, temp: integer;\nbegin\n Readln(n, a, b);\n temp := b mod n;\n if (temp = 0) then\n begin\n temp := abs(b + a);\n end\n else\n begin\n temp := a + temp;\n end;\n if (temp > n) then\n Dec(temp, a);\n Writeln(abs(temp));\n Readln;\nend.\n"}, {"source_code": "var\na,b,n,i:integer;\nbegin\nread(n,a,b);\nif (b<>0) then begin\nfor i:=1 to abs(b) do begin\nif (b>0) then begin a:=a+1;\nif (a>=n) and (i<>abs(b)) then a:=0;\nif (a>=n) and (i=abs(b)) then a:=1;\nend;\nif (b<0) then begin a:=a-1;\nif (a<=0) then a:=n;\nend;\nend;\nend;\nif (a=0) and (b<>0) then a:=n;\nwriteln(a);\nend."}, {"source_code": "var\n a, b, i, n, k, l, j: integer;\n f: boolean;\n\nbegin\n readln(n, a, b);\n if(a = 2) and (b = 7) and (n = 3) then\n writeln(3);\n if(a = 2) and (b = -5) and (n = 6) then\n writeln(3);\n if(n=5) and (a=1) and(b=3) then\n writeln(4);\n if(n=1) and (a=1) and(b=0) then\n writeln(1);\n if(n=1) and (a=1) and(b=-1) then\n writeln(1);\n if(n=1) and (a=1) and(b=1) then\n writeln(1);\n \n if(n=100) and (a=1) and(b=-1) then\n writeln(100);\nend."}, {"source_code": "var\n a, b, c, d, o: int64;\n\nbegin\n readln(a, b, c);\n if c = 0 then writeln(b)\n else begin\n if c < 0 then begin\n d := (b - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d = 0 then d := a;\n if d <> b then o := d;\n end;\n writeln(o);\n end\n else begin\n d := (b - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n while d <> b do \n begin\n d := (d - c) mod a;\n if d <= 0 then d := a + d;\n if d <> b then o := d;\n end;\n writeln(o);\n end;\n end;\nend."}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse if b<0 then\nfor i:=k+1 downto 1 do\nbegin\ndec(a,1);\nif a<0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "var\n a, b, i, n, k, l, j: integer;\n f: boolean;\n\nbegin\n readln(n, a, b);\n if(a = 2) and (b = 7) and (n = 3) then\n writeln(3);\n if(a = 2) and (b = -5) and (n = 6) then\n writeln(3);\n if(n=5) and (a=1) and(b=3) then\n writeln(4);\n if(n=1) and (a=1) and(b=0) then\n writeln(1);\n if(n=1) and (a=1) and(b=-1) then\n writeln(1);\n if(n=1) and (a=1) and(b=1) then\n writeln(1);\nend."}, {"source_code": "program prog1;\nvar n,a,b,x,y:longint;\nbegin\nread(n,a,b);\nif b=0 then write(a);\nif b>0 then \nbegin\nx:=(b mod n)+a;\nif x>n then write(x mod n) else write(x);\nend;\nif b<0 then \nbegin\ny:=abs(a-(-b mod n));\nwrite(y);\nend;\nend.\n"}, {"source_code": "var a,b,n,m:integer;\nbegin\nread(n,a,b);\n\nif b>=0 then b:=b mod n else b:=-(abs(b) mod n);\nif a+b >n then writeln(a+b-n) else if a+b<0 then writeln(n+a+b) else writeln(a+b);\nend."}, {"source_code": "var\nn,a,b,q,i,t: integer;\nbegin\nread(n,a,b);\nif b>0 then begin\nif b mod n <> 0 then begin\nif (a+b)<>0 then\nq:=(a+b) mod n else q:=a; end; end;\nif b = 0 then q:=a;\nif b<0 then begin\nif b*(-1) mod n = 0 then q:=a;\nif b*(-1) mod n <> 0 then begin\nt:=a+b;\nt:=t*(-1);\nfor i:=1 to n do\nif (t+i) mod n = 0 then q:=i;\nend; end;\nif q=0 then q:=n;\nwriteln(q);\nend."}, {"source_code": "{Aleksey_b}\nvar n,a,b,i,j,k:integer;\n\nbegin\n readln(n,a,b);\n if n=abs(b) then write(a)\n else begin\n if abs(a+b)<=n then write(abs(a+b))\n else write(abs(a+b) div n)\n end;\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,a,b:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res:longint;\n begin\n read(fi,n,a,b);\n a:=a+b;\n while a<0 do a:=a+n;\n while a>n do a:=a-n;\n writeln(fo,a);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "const fi='';\n fo='';\nvar n,a,b,i:longint;\n\nBEGIN\n assign(input,fi);reset(input);\n read(n,a,b);\n close(input);\n\n assign(output,fo);rewrite(output);\n for i:=1 to abs(b) do begin\n if a>=n then a:=1;\n if a<=0 then a:=n;\n if b<0 then dec(a);\n if b>0 then inc(a);\n end;\n if a>=n then a:=1; if a<=0 then a:=n;\n write(a); \n close(output);\nEND.\n"}, {"source_code": "var\nok:boolean;\ntmp,xx,yy,de:extended;\ni,j:longint;\nn,a,b: longint;\nflag: integer;\n\n\nbegin\nreadln(n,a,b);\nif b>=0 then writeln((a+b)mod n)\nelse begin\na:=a+b;\nif a<=0 then\nwhile (a<1) do \n a:=a+n;\n\nwriteln(a mod n);\nend;\nend."}, {"source_code": "var\nq,i,n,a,b:longint;\nbegin\nreadln(n,a,b);\nif b>=0 then begin\nb:=b mod n;\nq:=(a+b) mod n;\nif q=0 then writeln(a)\nelse\nwriteln(q);\nend else begin\n\nfor i:=1 to -b do begin\ndec(a);\nif a=0 then a:=n;\nend;\nwriteln(a);\nend;\nend."}, {"source_code": "var\nn,a,b,q,i,t: integer;\nbegin\nread(n,a,b);\n\nif b>0 then begin\nif b mod a = 0 then q:=a else\nq:=(a+b) mod n end;\n\nif b = 0 then q:=a;\n\n\nif b<0 then begin\nif b*(-1) mod n = 0 then q:=a;\nif b*(-1) mod n <> 0 then begin\nt:=a+b;\n\nif t<0 then begin\nt:=t*(-1);\nfor i:=1 to n do\nif (t+i) mod n = 0 then q:=i; end;\nif t>0 then\nq:= t mod n;\nend; end;\nif q=0 then q:=n;\nwriteln(q);\nend.\n "}, {"source_code": " Var a, b, n:integer;\n Begin\n readln(n,a,b);\n if abs(b) > n then\n b:= b mod n;\n b:= b+a;\n if (b > n) then\n b:= b - n;\n if b = 0 then b:= n;\n writeln(abs(b));\n end."}, {"source_code": "\nvar\n n,a,b,i,dem:longint;\nbegin\n read(n,a,b);\n dem:=0;\n if b=0 then\n begin\n write(1);\n exit;\n end;\n if b<0 then\n repeat\n dec(a);\n\n if a=0 then a:=n;\n inc(dem);\n if dem=abs(b) then break;\n until false\n else\n repeat\n inc(a);\n if a=n+1 then a:=1;\n inc(dem);\n if dem=abs(b) then break;\n until false;\n write(a);\nend.\n"}, {"source_code": "uses math;\nvar\n n,a,b:longint;\nbegin\n readln(n,a,b);\n if n=1 then writeln(1) else\n if (a+b mod n>n) then writeln(a+b mod n-n) else if a+b<1 then writeln(n+a+b mod n) else writeln(a+b mod n);\nend."}, {"source_code": "var\n a, b, i, c: integer;\nbegin\n read(a, b, c);\n if c>0 then\n for i := 1 to c do \n begin\n if b = a then b := 1 else\n inc(b);\n end else \n for i := c*-1 downto 1 do \n begin\n if b = a then b :=a-1 else\n dec(b);\n end;\n writeln(abs(b));\nend."}, {"source_code": "var n,a,b,ans,k,f,i:longint;\nbegin\nread(n,a,b);\nk:=abs(b);\nif b>0 then\nfor i:=1 to b do\nbegin\ninc(a,1);\nif a>n then a:=1;\nend\nelse if b<0 then\nfor i:=k+1 downto 1 do\nbegin\ndec(a,1);\nif a<=0 then a:=n;\nend;\nwrite(a);\nend."}, {"source_code": "var\n a, b, i, k, l, m, n: integer;\n j,f: boolean;\n\nbegin\nj:=false;\n f := false;\n readln(n, a, b);\n l := a + b;\n if(a = -b) then \n begin\n writeln(n);\n halt;\n end;\n \n if(l < n - 1) and(b>=0) then\n begin\n writeln(abs(l));\n f := true;\n halt;\n end;\n if(l < n - 1) and(b<=0) then\n begin\n if ((abs(a)) > abs(l)) or (a=37) then\n begin\n \n j:=true;\n end\n else if(j=false) then\n begin\n writeln(abs(l));\n f := true;\n j:=true;\n end;\n end;\n \n \n if(l >= n)\n then\n while(l > n) do\n begin\n l := l - n;\n end;\n \n if(l < 0) then \n while(l < 0) do\n l := l + n;\n \n if (f = false) then\n writeln(abs(l));\n if(j=true) and(f=true) then writeln(a);\nend."}, {"source_code": "program pr4;\nvar a,b,c,n,x:integer;\nbegin\n readln(n,a,b);\n x:=abs(b) mod n;\n if b>0 then a:=a+x\n else a:=a-x;\n if a>n then c:=a-n\n else c:=a;\n if a<0 then c:=abs(a);\n if a=0 then c:=n;\n writeln(c);\nend."}], "src_uid": "cd0e90042a6aca647465f1d51e6dffc4"} {"source_code": "var a: array of integer;\n i, s, j, k: integer;\nbegin\n readln(s);\n setlength(a, s);\n for i:=0 to s-1 do\n begin\n read(a[i]);\n end;\n for i:=0 to s-1 do \n begin\n for j:=0 to s-2 do\n if a[j]>a[j+1] then\n begin\n k:=a[j+1];\n a[j+1]:=a[j];\n a[j]:=k;\n end;\n end;\n for i:=0 to s-1 do \n write(a[i], ' ');\nend.", "positive_code": [{"source_code": "var\nn,i,j,t:integer;\na,k:array[1..100] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do \nread(a[i]);\nfor i:=1 to 100 do\nfor j:=1 to n do\nif a[j]=i\n then inc(k[i]);\nfor i:=1 to 100 do\nif k[i]<>0\n then for j:=1 to k[i] do\n writeln(i);\nend.\n"}, {"source_code": "var n,i:byte;\n a:array[1..100]of byte;\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=h then g[j]:=1\n else g[j]:=0;\n k:=0;\n for j:=1 to n do\n if g[j]=1 then inc(k);\n for j:=n downto n-k+1 do b[j]:=b[j]-g[j]+1;\n for j:=n-k downto 1 do\n if g[j]=1 then dec(b[j]);\n end;\n for i:=1 to n do write(b[i],' ');\nend."}, {"source_code": "var a:array[1..100] of byte;\n n,i,j,tmp:byte;\nbegin\nread(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do\nfor j:=i+1 to n do\n if a[i]>a[j] then\n begin\n tmp:=a[i];\n a[i]:=a[j];\n a[j]:=tmp;\n end;\nfor i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "Var\n i,j,n:integer;\n a:array[1..100] of integer;\nBegin\n Read (n);\n for i:=1 to n do Read (a[i]);\n for j:=1 to n-1 do\n for i:=j+1 to n do\n if a[j]>a[i] then\n begin\n a[j]:=a[j]+a[i];\n a[i]:=a[j]-a[i];\n a[j]:=a[j]-a[i];\n end;\n for i:=1 to n do Write (a[i],' ');\nEnd."}, {"source_code": "var\n i,j,n,t:longint;\n a:array[1..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do \n for j:=i+1 to n do \n if a[i]>a[j] then \n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n for i:=1 to n do write(a[i],' ');\nend.\n"}, {"source_code": "var n,i,j,t,k:longint;\na:array[1..100] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n for k:=1 to n do write(a[k],' ');\nend."}, {"source_code": "var\n i,n,j,m:integer;\n a:array[1..100]of integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\nread(a[i]);\n for i:= 1 to n-1 do\n for j:= 1 to n-i do\n if a[j]>a[j+1] then begin m:=a[j];a[j]:=a[j+1];a[j+1]:=m;end;\nfor i:= 1 to n do\nwrite(a[i],' ');\nend.\n"}, {"source_code": "procedure QSort(var arr: array of integer);\n\n procedure sort(l, r: longint);\n var\n i, j, p, b: longint;\n begin\n if l p do\n Dec(j);\n if i <= j then\n begin\n b := arr[i];\n arr[i] := arr[j];\n arr[j] := b;\n Inc(i);\n Dec(j);\n end;\n end;\n sort(l,j);\n sort(i,r);\n end;\n end;\n\n begin\n randomize;\n sort(0, high(arr));\n end;\n\nvar A:array of integer; i,n:integer;\nBEGIN\n read(n);\n setlength(A,n);\n for i:= 0 to n-1 do read(A[i]);\n Qsort(A);\n for i:= 0 to n-1 do write(A[i],' ');\n readln;\n readln\nEND."}, {"source_code": "var flag:boolean;\n arr:array of byte;\n n,b,i:SHORTint;\nBEGIN\n read(n);\n SetLength(arr,n);\n for i:=0 to n-1 do read(arr[i]);\n flag:=true;\n while flag do\n begin\n flag:=false;\n for i:=0 to n-2 do\n if arr[i]>arr[i+1] then\n begin\n b:=arr[i];\n arr[i]:=arr[i+1];\n arr[i+1]:=b;\n flag:=true;\n end;\n end;\n for i:=0 to n-1 do write(arr[i],' ');\nEND.\n"}, {"source_code": "program cube;\nvar k,n,d,min,i:integer;\nvar a:array [1..100] of integer;\nbegin\n readln(n);\n for d:=1 to n do\n begin\n read(a[d]);\n end;\n for d:=1 to n-1 do\n begin\n k:=d;\n min:=a[d];\n for i:=d+1 to n do\n begin\n if a[i]=A[j+1] then\n begin\n buf:=A[j];\n A[j]:=A[j+1];\n A[j+1]:=buf;\n end;\n end;\n end;\nfor i:=1 to n do\n begin\n write(A[i],' ');\n end;\nend.\n"}, {"source_code": "var a:array[1..100] of integer;\n k,n,i,j:integer;\nbegin\n read(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n for j:=1 to n-i do\n if a[j]>a[j+1] then begin\n k:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=k;\n end;\n for i:=1 to n do\n write(a[i],' ');\nend.\n "}, {"source_code": "var a:array[1..1000] of longint; \n n, i, mini, j, cc:longint; \nbegin\n\nreadln(n);\n\nfor i:=1 to n do \n read(a[i]);\n \nfor i:=1 to n-1 do \n begin\n mini:=i; \n \n for j:=i+1 to n do \n if a[j]a[j] then swap(a[i],a[j]);\nfor i:=1 to n do\nwrite(a[i],' ')\nend."}, {"source_code": "program ideone;\nvar a:array [1..100] of integer;\n i,j,b,n:integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\n read(a[i]);\nfor i:= n-1 downto 1 do\n for j:= n downto i do\n if a[i] > a[j] then\n begin\n b:=a[i]-a[j];\n a[j]:=a[j]+b;\n a[i]:=a[i]-b;\n end;\nfor i:= 1 to n do\n write(a[i],' ');\nend."}, {"source_code": "type\n a=array[0..100] of longint;\nvar\n i,n,j,max,ch,lie:longint;\n mas,tmp,mas1:a;\n s:string;\nbegin\n readln(n);\n max:=-1;\n for i:=1 to n do\n begin\n read(ch);\n if ch>max then\n max:=ch;\n mas[i]:=ch;\n end;\n for i:=1 to max do\n begin\n ch:=0;\n for j:=1 to n do\n if mas[j]>(i-1) then \n ch:=ch+1;\n mas1[i]:=ch;\n end;\n for i:=n downto 1 do\n begin\n ch:=0;\n for j:=1 to max do\n if mas1[j]>(i-1) then \n ch:=ch+1;\n write(ch, ' ');\n end;\nend."}, {"source_code": "\ntype\n TArr = array [1..100] of Integer;\n\nprocedure ReadArray (var a: TArr; n: Integer);\nvar\n i: Integer;\n\nbegin\n for i := 1 to n do\n Read (a[i]);\nend;\n\nprocedure Swap (var a, b: Integer);\nvar\n t: Integer;\n\nbegin\n t := a;\n a := b;\n b := t;\nend;\n\nprocedure BubbleSort (var a: TArr; n: Integer);\nvar\n i, j: Integer;\n\nbegin\n for i := 1 to n - 1 do\n for j := i + 1 to n do\n if a[i] > a[j] then\n Swap (a[i], a[j]);\nend;\n\nprocedure WriteArray (const a: TArr; n: Integer);\nvar\n i: Integer;\n\nbegin\n for i := 1 to n do\n Write (a[i], ' ');\n\n WriteLn;\nend;\n\nvar\n a: TArr;\n n: Integer;\n\nbegin\n ReadLn (n);\n ReadArray (a, n);\n BubbleSort (a, n);\n WriteArray (a, n);\nend."}, {"source_code": "var\nmas:array[1..100] of longint;\nN,k,i:longint;\nBegin\nread(N);\nfor i:=1 to N do\n read(mas[i]);\nfor i:=1 to N do\n for k:=1 to (N - 1) do\n if mas[k] > mas[k + 1] then\n swap(mas[k],mas[k + 1]);\nfor i:=1 to N do\n write(mas[i],' ');\nENd."}, {"source_code": "var\n n,i,j,t:longint;\n a:array[0..1000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then begin t:=a[i];a[i]:=a[j];a[j]:=t;end;\n for i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "var\ni,j,n,m:int64;\na:array [1..10000000] of int64;\nbegin\nread(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nfor j:=1 to n do\nif a[i] a[j] then begin\n k := a[i];\n a[i] := a[j];\n a[j] := k;\n end;\n for i := 1 to n do write(a[i], ' ');\nend."}, {"source_code": "const fi='';\n fo='';\nVar a,b: array [1..100] of longint;\n n,i,j,d: longint;\n f,g: text;\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lx1 do dec(j);\n if i<=j then\n begin\n y1:=x[i];\n x[i]:=x[j];\n x[j]:=y1;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[j+1] then\n begin\n var c:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=c;\n end;\n for var i:=0 to n-1 do\n print(a[i]);\nend."}, {"source_code": "var n,i,j,t:integer;\n a:array[1..100]of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nfor j:=n downto i+1 do\nif a[i]>a[j] then\nbegin\nt:=a[i]-a[j];\na[i]:=a[i]-t;\na[j]:=a[j]+t;\nend;\nfor i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "Var cut: array[1..100] of byte;\n n,i,aux: byte;\n sort: boolean;\nBegin\nReadln(n);\nFor i:=1 to n do \nRead(cut[i]);\nRepeat\nsort:=true;\nFor i:=1 to n-1 do\nif cut[i]>cut[i+1] then\nbegin\nsort:=false;\naux:=cut[i]; cut[i]:=cut[i+1]; cut[i+1]:=aux;\nEnd;\nUntil sort;\nFor i:=1 to n do\nWrite(cut[i],' ');\nEnd."}, {"source_code": "program task;\n var n, i, j, p: integer; a: array[1..100] of integer;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do\n begin\n for j:=1 to n-i do\n begin\n if a[j]>a[j+1] then\n begin\n p:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=p\n end\n end\n end;\n for i:=1 to n do write(a[i], ' ');\nend."}, {"source_code": "const\nMAXN = 1000000;\nvar\nx,m,N,i:longint;\nheap: array [1..MAXN] of longint;\nprocedure push(x,ind: longint);\nvar\n temp:longint;\nbegin\n heap[ind]:=x;\n while (ind>1) and (heap[ind div 2]>heap[ind]) do\n begin\n temp:=heap[ind div 2];\n heap[ind div 2]:=heap[ind];\n heap[ind]:=temp;\n ind:=ind div 2;\n end;\nend;\nfunction pop () :longint;\nvar\n ind,k,root,temp:longint;\nbegin\n ind:=1; root:=heap[1];\n heap[1]:=heap[N];\n while (2*ind<=N) do\n begin\n if (2*ind+1<=N) and (heap[2*ind+1]s[j] then\n begin\n a:=s[i];\n s[i]:=s[j];\n s[j]:=a;\n end;\n end;\n for i:=1 to n do\n write(s[i],' ');\nend."}, {"source_code": "program Sort;\n\nvar a: array of integer;\ni, n: integer;\n\nprocedure Merge(var a: array of integer; left, right: integer);\nvar middle, id, id_left, id_right, i: integer;\nvar b: array of integer;\nbegin\n\tSetlength(b, right - left + 1);\n\t\n middle := (left + right) div 2;\n\tid_left := left;\n\tid_right := middle + 1;\n\tid := 0;\n\twhile (id_left <= middle) and (id_right <= right) do\n\tbegin\n\t if a[id_left] < a[id_right] then\n\t\tbegin\n\t\t\tb[id] := a[id_left];\n\t\t\tid := id + 1;\n\t\t\tid_left := id_left + 1;\n\t\tend\n\t\telse \n\t\tbegin\n\t\t\tb[id] := a[id_right];\n\t\t\tid := id + 1;\n\t\t\tid_right := id_right + 1;\n\t\tend\n\tend;\n\twhile id_left <= middle do\n\tbegin\n\t\tb[id] := a[id_left];\n\t\tid := id + 1;\n\t\tid_left := id_left + 1;\n\tend;\n\twhile id_right <= right do\n\tbegin\n\t\tb[id] := a[id_right];\n\t\tid := id + 1;\n\t\tid_right := id_right + 1;\n\tend;\n\tfor i:=left to right do\n\t\ta[i] := b[i - left];\nend;\n\nprocedure MergeSort(var a: array of integer; left, right: integer);\nvar middle: integer;\nbegin\n\tif left < right then\n\tbegin\n\t\tmiddle := (left + right) div 2;\n\t\tMergeSort(a, left, middle);\n\t\tMergeSort(a, middle + 1, right);\n\t\tMerge(a, left, right);\n\tend;\nend;\n\nbegin\n\treadln(n);\n\tsetlength(a, n);\n\tfor i:=0 to n-1 do\n\t\tread(a[i]);\n\tMergeSort(a, 0, n - 1);\n\tfor i:=0 to n-1 do\n\t\tprint(a[i]);\nend."}, {"source_code": "Var i , j , n , tmp : Longint;\n A : Array [1..100] of Longint;\n \nBegin \n Readln(n);\n For i := 1 to n do Read(A[i]);\n For i := 1 to n do \n For j := 1 to n do \n If A[i] < A[j] then \n Begin\n tmp := A[i];\n A[i] := A[j];\n A[j] := tmp;\n End;\n For i := 1 to n do Write(A[i] , ' ');\nEnd."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\n a:array[1..10000] of longint;\nbegin\nread(z);\nfor i:=1 to z do\nbegin\nread(a[i]);\nend;\nfor i:=1 to z-1 do\nbegin\n for j:=1 to z-i do\n begin\n if a[j]>a[j+1]\n then begin\n k:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=k;\n end;\n end;\nend;\nfor i:=1 to z do\nbegin\nwrite(a[i],' ');\nend;\nend."}, {"source_code": "type ty = integer;\nvar a:array of ty;\ni,n:integer;\nbegin\nreadln(n);\nsetlength(a,n);\nfor i:=0 to n-1 do\nread(a[i]);\nsort(a);\nfor i:=0 to n-1 do write(a[i],' ');\nend."}, {"source_code": "var A:Array[1..100] of integer;\n j,i,N,t:integer;\nbegin\n readln(N);\n for i:=1 to N do\n read(A[i]);\n for i:=1 to N-1 do\n for j:=i+1 to N do\n if A[i]>A[j] then\n begin\n t:=A[i];\n A[i]:=A[j];\n A[j]:=t;\n end;\n for i:=1 to N do\n write(A[i],' ');\nend."}, {"source_code": "program GRAVITY_FLIP;\nvar n,i:byte;\n a:array[1..100] of byte;\nprocedure bbsort;\nvar i1,j1,tam:byte;\n begin\n for i1:=1 to n-1 do \n for j1:=i1+1 to n do \n if a[i1] > a[j1] then \n begin\n tam:=a[i1];\n a[i1]:=a[j1];\n a[j1]:=tam;\n end;\n end;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n bbsort;\n for i:=1 to n do Write(a[i],' ');\n readln;\nend.\n"}, {"source_code": "var n,i,j,k,tam,t:longint;\n a:array[1..100]of longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n for t:=1 to n-1 do\n for j:=t+1 to n do\n if a[t] > a[j] then\n begin\n tam:=a[t];\n a[t]:=a[j];\n a[j]:=tam;\n end;\n for k:=1 to n do\n write(a[k],' ');\n readln;\nend."}, {"source_code": "var \n a:array[1..101] of longint;\n i,j,t,n:longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n for i:=1 to n do \n write(a[i],' ');\nend."}, {"source_code": "var a: array of Integer;\nbegin\n var n:=readinteger;\n a := new integer[n];\n for var i := 0 to n - 1 do \n a[i]:=readinteger;\n Sort(a);\n for var i := 0 to n - 1 do \n Print(a[i]);\nend."}, {"source_code": "type\n tmas=array[1..100] of integer;\n\nprocedure swap(var a,b :integer);\nvar\n c :integer;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nprocedure shift_down(var mas: tmas; index, n: integer);\nvar child, current: integer; stop: boolean;\nbegin\n current := mas[index];\n stop := false;\n while not stop and (index <= n div 2) do begin\n child := index * 2;\n if (child < n) and (mas[child] < mas[child + 1]) then\n child := child + 1;\n if current < mas[child] then begin\n mas[index] := mas[child];\n index := child;\n end else stop := true;\n end;\n mas[index] := current\nend;\n\nprocedure heap_sort (var mas: tmas; n: integer);\nvar i: integer;\nbegin\n for i := n div 2 downTo 1 do\n shift_down(mas, i, n);\n for i := n downTo 1 do begin\n swap(mas[1], mas[i]);\n shift_down(mas, 1, i-1);\n end;\nend;\n\n\nvar\n i,k,ch :integer;\n m :tmas;\nbegin\n read(k);\n for i:=1 to k do\n begin\n read(m[i]);\n end;\n heap_sort(m,k);\n for i:=1 to k do\n begin\n write(m[i],' ');\n end;\nend."}, {"source_code": "var i,j,n,o:longint;\n\ta:array[1..1000000] of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n\tread(a[i]);\nfor i:=1 to n do\n\tfor j:=n downto i+1 do\n\t\tif a[i]>a[j] then\n\t\t\tbegin\n\t\t\to:=a[i];\n\t\t\ta[i]:=a[j];\n\t\t\ta[j]:=o;\n\t\t\tend;\nfor i:=1 to n do\n\twrite(a[i],' ');\nend."}, {"source_code": "program gf;\n var a:array[1..100] of byte;\n n,t:byte;\nprocedure qsort(l,r:byte);\n var i,j,x,tam:byte;\nbegin\n i:=l;j:=r;\n x:=a[random(r-l+1)+l];\n repeat\n while a[i]x do dec(j);\n if (i<=j) then\n begin\n tam:=a[i];\n a[i]:=a[j];\n a[j]:=tam;\n inc(i);\n dec(j);\n end;\n until i>j;\n if (il) then qsort(l,j);\nend;\nbegin\n readln(n);\n for t:=1 to n do read(a[t]);\n readln;\n qsort(1,n);\n for t:=1 to n do write(a[t],' ');\nend."}, {"source_code": "program gravity;\nvar\na,i,j,c:integer;\nb:array[1..1000] of integer;\nbegin\n read(a);\n for i:=1 to a do\n read(b[i]);\n if (a>1) then\n for i:=1 to a-1 do\n for j:=i+1 to a do\n if (b[i]>b[j]) then\n begin\n c:=b[i];\n b[i]:=b[j];\n b[j]:=c;\n end;\n for i:=1 to a do\n write(b[i],' ');\nend."}, {"source_code": "var a:array[1..100]of integer;\ns,i,j,t:integer;\nbegin\nread(s);\nfor i:=1 to s do\nbegin\nread(a[i]);\nend;\nfor I:=1 to s do\nbegin\nfor j:=i+1 to s do\nbegin\nif (a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lx do dec(j);\n if i<=j then\n begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>j;\n if ix do\n begin\n a[j+1]:=a[j]; ;dec(j);\n end;\n \n a[j+1]:=x;b[j+1]:=y;\n end;\n for i:=1 to n do\n \n write(a[i],' ');\nend."}, {"source_code": "Program abc;\n Var n,i,j,k:integer;\n mas:array of integer;\nbegin\n readln(n);\n Setlength(mas,n+1);\n for i:=1 to n do read(mas[i]);\n for j:=1 to n do\n begin\n for i:=1 to n-1 do\n begin\n if(mas[i]>mas[i+1]) then\n begin\n k:=mas[i];\n mas[i]:=mas[i+1];\n mas[i+1]:=k;\n end;\n end;\n end;\n for i:=1 to n do write(mas[i],' ');\nend."}, {"source_code": "var n, i, j, T : longint;\n A : array[1..100] of longint;\nbegin\n readln(n);\n For i := 1 to n do\n read(A[i]);\n For i := 1 to n do\n For j := 1 to n-1 do\n If A[j] > A[j+1] then\n begin\n T := A[j]; \n A[j] := A[j+1];\n A[j+1] := T;\n end;\n write(A[1]);\n For i := 2 to n do write(' ',A[i]);\n writeln;\nend.\n"}, {"source_code": "var\n i,j,n,t: integer;\n a: array[1..4] of integer;\nbegin\n readln(n);\n for i := 1 to n do read(a[i]);\n for i := 1 to n-1 do\n for j := 1 to n-i do\n if a[j] > a[j+1] then begin\n t := a[j];\n a[j] := a[j+1];\n a[j+1] := t;\n end;\n for i := 1 to n do write(a[i],' ')\nend."}, {"source_code": "program z_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,m,i,j,t:longint;\n mas:array[1..101] of longint;\nbegin\n readln(n);\n for i:=1 to n do begin\n read(mas[i]);\n end;\n for i:=1 to n do begin\n t:=0;\n for j:=1 to n-1 do begin\n if mas[j]>mas[j+1] then begin\n t:=mas[j+1];\n mas[j+1]:=mas[j];\n mas[j]:=t;\n t:=1;\n end;\n end;\n if t=0 then break;\n end;\n for i:=1 to n do write(mas[i],' ');\n writeln;\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\n{$R *.res}\nvar\na: array[1..1000] of integer;\nr: array[1..1000] of integer;\nn,i:integer;\n\nprocedure sort;\nvar\ni,j,buf,min,x:integer;\nbegin\nfor i:=1 to n-1 do//смотрим элементы массива с первого\nfor j:=i+1 to n do//сравниваем с элементами, которые впереди\n if a[i]>a[j] then//если нашли впереди меньше,\n begin\n x:=a[i];//то с помощью переменной-буфера\n a[i]:=a[j];//меняем элементы местами\n a[j]:=x;\n end;\nend;\n\n\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nsort;\nfor I := 1 to n do write(a[i],' ');\nreadln;\nreadln;\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\n inf = round(1e9);\n maxn = round(1e5) + 200;\n md = round(1e9) + 7;\nvar\n n, i, x, need, j : longint;\n h, ans : array [1..111] of longint;\nbegin\n //assign (input, 'input.txt'); reset(input);\n //assign (output, 'output.txt'); rewrite(output);\n randomize;\n fillchar(h, sizeof(h), 0);\n readln(n);\n for i := 1 to n do\n begin\n read(x);\n for j := 1 to x do inc(h[j]);\n end;\n for i := n downto 1 do\n begin\n ans[i] := 0;\n need := n - i + 1;\n for j := 1 to 111 do\n if h[j] >= need then inc(ans[i]);\n end;\n for i := 1 to n do write(ans[i],' ');\nend.\n"}, {"source_code": "var i,n:longint;\na:array[1..10000]of longint;\n\n\n\n\n\n\n//]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]//\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l k do j:=j-1;\nif i<=j then begin\np:=a[i]; a[i]:=a[j]; a[j]:=p;\ni:=i+1;\nj:=j-1;\nend;\nuntil i>j;\nif low < j then qsort(a,low,j);\nif high>i then qsort(a,i,high);\n\nend;\n\nbegin\nreadln(n);\nfor i:= 1 to n do read(a[i]);\nqsort(a,0,n-1);\nfor i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "var\nn,k,a,j:integer;\nm:array[1..100]of integer;\nbegin\nread(n);\nfor k:=1 to 100 do\nbegin\nread(a);\nm[a]:=m[a]+1;\nend;\nfor k:=1 to 100 do\nif m[k]<>0 then\nfor j:=1 to m[k] do write(k,' ');\nend."}, {"source_code": "program Project2;\n{$APPTYPE CONSOLE}\nvar\ni,j,n,k:longint;\na:array[0..1000] of longint;\nbegin\n//assign (input, 'input.txt');\n//reset (input);\n//assign (output, 'output.txt');\n//rewrite (output);\nread(n);\nfor i:=1 to n do read(a[i]);\nfor I := 1 to n do\n for j := 1 to n-i do\n if a[j]>a[j+1] then begin\n k:=a[j];a[j]:=a[j+1];a[j+1]:=k;\n end;\nfor I := 1 to n do write(a[i],' ');\n\nend.\n"}, {"source_code": "const f1='405a.inp';\n f2='405a.out';\nvar i,n:longint;\n a:array[1..1000000] of longint;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[x+1] then begin\n k:=a[x+1];\n a[x+1]:=a[x];\n a[x]:=k;\n\n if x1 then rec(x-1);\n end;\n end;\n\n\n Begin\n read(n);\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n for i:=n-1 downto 1 do\n begin\n rec(i);\n end;\n for i:=1 to n do write(a[i],' ');\n ENd.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype mass=array[1..100]of integer;\nvar i,n,a,b,j,max:integer; m,k:mass;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt');\n }readln(n);\n max:=0;\n for i:=1 to n do\n begin\n read(m[i]);\n if m[i]>max\n then max:=m[i];\n end;\n\n for i:=1 to max do\n begin\n for j:=1 to n do\n if m[j]>=i\n then inc(k[i]);\n end;\n for i:=n downto 1 do\n begin\n a:=0;\n for j:=1 to max do\n if k[j]>=i\n then inc(a);\n write(a,' '); \n end;\nend.\n"}, {"source_code": "var j,n,i,d,k:longint;\na:array[1..10000000] of longint;\nbegin\nreadln(n);\nfor i:=1 to n do \nread(a[i]);\nfor i:=1 to n-1 do begin\n for j:=1 to n-i do begin\n if a[j]>a[j+1] then begin\n k:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=k;\n end;\n end;\nend;\nfor i:=1 to n do \nwrite(a[i],' ');\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype TArray=Array [1..110] of Integer;\nvar\n i,n,m:integer;\n A:TArray;\n\nprocedure qSort(var A: TArray; min, max: Integer);\nvar i, j, supp, tmp: Integer;\nbegin\nsupp:=A[max-((max-min) div 2)];\ni:=min; j:=max;\nwhile isupp do j:=j-1;\n if i<=j then\n begin\n tmp:=A[i]; A[i]:=A[j]; A[j]:=tmp;\n i:=i+1; j:=j-1;\n end;\n end;\nif minmas[j] then\n begin\n l:=mas[i];\n mas[i]:=mas[j];\n mas[j]:=l;\n bol:=true;\n end;\n until not bol;\n\n for i:=1 to n do\n if i<>n then Write(mas[i],' ')\n else Write(mas[i]);\n\n Readln(i);\n\nend.\n"}, {"source_code": "//const fi ='xoa.inp';\nvar fd:text;\n a:array[0..1000] of longint;\n i,j ,n, t:longint;\nbegin\n // assign(fd, fi); reset(fd);\n readln(n);\n for i:=1 to n do\n read( a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i] > a[j] then\n begin\n t:=a[i]; a[i] := a[j]; a[j] :=t;\n end;\n for i:=1 to n do\n write(a[i],' ');\n //close(fd);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\n\nconst oo=1e+21;\n eps=1e-9;\n dohuya=maxlongint div 2;\n\nvar ss,sss:array[0..201500]of string;\n s,s0,s1,s2,s3:string;\n a,aaa:array[0..2015,0..2015]of longint;\n qq,cc,qc:array[0..1000000]of longint;\n q,c,q0,c0,q1,c1,q2,c2,q3,c3,r,res,cur,n,m,i,j,k:longint;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n ch:char;\n b,bb:boolean;\n\nbegin\nread(n);\nfor i:=1 to n do read(qc[i]);\nfor i:=1 to n do\n for j:=i+1 to n do\n begin\n if qc[i]>qc[j] then begin qc[0]:=qc[i]; qc[i]:=qc[j]; qc[j]:=qc[0]; end;\n end;\nfor i:=1 to n do write(qc[i],' '); \nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram column;\n\nconst\n inp = '';\n outp = '';\n maxN = Round(1E2+2);\n\nvar\n pb,pb2: Text;\n {input}\n n: Integer;\n a: array [0..maxN] of Integer;\n {main}\n\n {output}\n\n\nprocedure INPUT;\nvar i: Integer;\nbegin\n Assign(pb,inp); Reset(pb);\n Assign(pb2,outp); ReWrite(pb2);\n ReadLn(pb,n);\n for i := 1 to n do Read(pb,a[i]);\nend;\n\nprocedure QS(L,H: Integer);\nvar i,j: Integer;\n key,t: Integer;\nbegin\n i := Random(H-L+1)+L;\n key := a[i];\n i := L; j := H;\n while (i<=j) do\n begin\n while (a[i]key) do Dec(j);\n if (i<=j) then\n begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n Dec(j); Inc(i);\n end;\n end;\n if (La[j+1] then\n begin\n c:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=c;\n end;\n end;\nfor i:=1 to n do\n write(a[i],' ');\nend."}, {"source_code": "program baitap;\nvar a: array[1..101] of integer;\n n,i,j,t: integer;\nbegin\nreadln(n);\nfor i := 1 to n do read(a[i]);\nfor i:= 1 to n-1 do\n for j:= i+1 to n do\n begin\n if a[i] > a[j] then\n begin\n t := a[i];\n a[i] := a[j];\n a[j] := t;\n end;\n end;\nfor i:=1 to n do write(a[i],' ');\nreadln;\nend."}, {"source_code": "VAR\n i,j,n,k : longint;\n a : array[1..100] of longint;\nBEGIN\n readln(n);\n for i := 1 to n do read(a[i]);\n for i := 1 to n-1 do\n for j := i+1 to n do\n if a[i] > a[j] then\n begin\n k := a[i];\n a[i] := a[j];\n a[j] := k;\n end;\n for i := 1 to n do\n write(a[i],' ');\nEND.\n"}, {"source_code": "program kkkkk;\nvar\ni,k,n:byte;\nx:boolean;\nmas:array of byte;\n\nbegin\nread(n);\nsetlength(mas,n+1);\nfor i:=1 to n do\nread(mas[i]);\nx:=true;\n\nwhile x do\nbegin\nfor i:=n downto 2 do\nif mas[i] a[j] then\n begin\n w:=a[i];\n a[i]:=a[j];\n a[j]:=w;\n end;\n end;\nprocedure solve;\n var i ,j : integer;\n begin\n sort;\n for i:=1 to n do\n begin\n Write(a[i],' ');\n end;\n end;\nbegin\n enter;\n solve;\nend."}, {"source_code": "var\na:array[0..105] of integer;\nn,i,j,t:integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\nfor i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "Var a:array[1..100] of longint;\ni,n:longint;\nprocedure sort(L,R:longint);\nVar i,j,x,t:longint;\nbegin\ni:=L;\nj:=R;\nx:=a[(L+R)div 2];\nrepeat\nwhile a[i]x do dec(j);\nif i<=j then begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\nuntil i>j;\nif L0 then \nbegin \nfor i1:=1 to b[i] do \nwrite(i,' '); \nend; \nend; \nend."}, {"source_code": "var n:byte;\n i:longint;\n a:Array[1..100] of byte;\nprocedure sort(l,r: longint);\nvar i,j,x,y: longint;\nbegin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[i1+1] then\n begin\n o:=a[i1];\n a[i1]:=a[i1+1];\n a[i1+1]:=o;\n end;\nfor i:=1 to n do\n write(a[i],' ');\nend.\n"}], "negative_code": [{"source_code": "Var a,b:array[1..10000] of longint;\n i,j,n,m,k,t:longint;\n begin\n Read(n);\n for i:=1to n do\n Read(a[i]);\n for t:=1 to 100 do\n for i:=n-1 downto 1 do\n begin\n if a[i]>a[i+1] then\n begin\n k:=i+1;\n for j:=i+1 to n do\n if a[i]<=a[j] then break else inc(k);\n dec(k);\n inc(a[k]);\n dec(a[i]);\n end;\n end;\n for i:=1 to n do\n Write(a[i],' ');\n end."}, {"source_code": "Var a,b:array[1..10000] of longint;\n i,j,n,m,k,t:longint;\n begin\n Read(n);\n for i:=1to n do\n Read(a[i]);\n for t:=1 to 1000 do\n for i:=n-1 downto 1 do\n begin\n if a[i]>a[i+1] then\n begin\n k:=i+1;\n for j:=i+1 to n do\n if a[i]<=a[j] then break else inc(k);\n dec(k);\n inc(a[k]);\n dec(a[i]);\n end;\n end;\n for i:=1 to n do\n Write(a[i],' ');\n end."}, {"source_code": "VAR\n i,j,n,k : longint;\n a : array[1..100] of longint;\nBEGIN\n readln(n);\n for i := 1 to n do read(a[i]);\n for i := 4 downto 1 do\n for j := n downto 1 do\n if a[j] = i then\n for k := n downto j+1 do\n if a[k] < a[j] then\n begin\n a[k] := a[k]+1;\n a[j] := a[j]-1;\n end;\n for i := 1 to n do\n write(a[i],' ');\nEND.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram OnlyLove;\nvar a ,b: array[0..101] of integer;\n n : integer;\nprocedure enter;\n var i : integer;\n begin\n readln(n);\n for i:=1 to n do Read(a[i]);\n end;\nprocedure sort;\n var i ,j ,w:integer;\n begin\n a[0]:=0;\n a[n]:=101;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i] > a[j] then\n begin\n w:=a[i];\n a[i]:=a[j];\n a[j]:=w;\n end;\n end;\nprocedure solve;\n var i ,j : integer;\n begin\n sort;\n for i:=1 to n do\n begin\n Write(a[i],' ');\n end;\n end;\nbegin\n enter;\n solve;\nend."}, {"source_code": "var i,n,j:longint;\na,b,c:array[1..101]of longint;\n\nbegin\nread(n);\nfor i:=1 to n do\nread(a[i]);\n\nfor i:=1 to n do \nfor j:=1 to n do\nif a[j]>=i then inc(b[i]);\n\nfor i:=1 to n do\nfor j:=1 to n do\nif n-b[j]+1<=i then inc(c[i]);\n\nfor i:=1 to n do\n write(c[i],' ');\n\nend."}, {"source_code": "Program GravityFlip;\nVar i,n:longint;\n m:array [0..101] of longint;\nProcedure swap(var a,b:longint);\nVar tmp:longint;\nBegin\ntmp:=a;\na:=b;\nb:=tmp;\nEnd;\n\nProcedure sort(l,h:longint);\nVar i,j,x:longint;\nBegin\n i:=l; j:=h; x:=m[(l+h) div 2];\n Repeat\n While m[i]>x do inc(i);\n While m[j]j;\n If lx do inc(i);\n While m[j]j;\n If l12 Then Begin\n xet:=false; Break; End;\n end;\n If xet Then Write(i) Else Write('-1');\nEnd."}, {"source_code": "const fi = '';\n fo = '';\n maxN = 100;\ntype int = integer;\nvar n : int;\n a : array[0..maxN,1..maxN] of int;\n{}\nprocedure xl;\nvar i,j,d,c: int;\nbegin\n for j:=1 to n do for i:=1 to a[0][j] do a[i,j] := 1;\n for i:=1 to 100 do\n begin\n d := 1; c := n;\n while d a[j] then begin tmp := a[i]; a[i] := a[j]; a[j] := tmp; end;\nfor i := 1 to n do write(a[i]); writeln;\nend.\n"}, {"source_code": "var n, i, j, tmp: longint;\n a :array[1..110] of longint;\nbegin\nreadln(n);\nfor i := 1 to n do readln(a[i]); readln;\nfor i := 1 to n - 1 do\n for j := i + 1 to n do\n if a[i] > a[j] then begin tmp := a[i]; a[i] := a[j]; a[j] := tmp; end;\nfor i := 1 to n do write(a[i]); writeln;\nend.\n"}, {"source_code": "var a:array[1..5] of longint; n,i,i1,o:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\nfor i:=1 to n-1 do\n for i1:=1 to n-i do\n if a[i1]>a[i1+1] then \n begin\n o:=a[i1];\n a[i1]:=a[i1+1];\n a[i1+1]:=o;\n end;\nfor i:=1 to n do\n write(a[i],' ');\n end."}, {"source_code": "var a:array[1..5] of longint; i,i1,o:longint;\nbegin\nfor i:=1 to 4 do\n read(a[i]);\nfor i:=1 to 4-1 do\n for i1:=1 to 4-i do\n if a[i1]>a[i1+1] then \n begin\n o:=a[i1];\n a[i1]:=a[i1+1];\n a[i1+1]:=o;\n end;\nfor i:=1 to 4 do\n write(a[i],' ');\n end."}, {"source_code": "var\n a:array[1..300,1..300]of char;\n b:array[1..255]of longint;\n i,j,k,n:longint;\n x:char;\nprocedure ans(x:string);\nbegin\n writeln(x);\n halt;\nend;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n for j:=1 to n do\n begin\n read(a[i,j]);\n inc(b[ord(a[i,j])]);\n end;\n readln;\n end;\n for i:=1 to 255 do if b[i]<>0 then inc(k);\n if k<>2 then ans('NO');\n x:=a[1,1];\n for i:=1 to n do if (x<>a[i,i])or(x<>a[i,n-i+1]) then ans('NO');\n for i:=1 to n do\n for j:=1 to n do\n begin\n if i=j then continue;\n if j=n-i+1 then continue;\n if x=a[i,j] then ans('NO');\n end;\n\n ans('YES');\nend."}, {"source_code": "var\n a:array[0..100]of longint;\n i,j,n:longint;\nbegin\n readln(n);\n for i:=1 to n do readln(a[i]);\n for i:=1 to n do\n for j:=i+1 to n do if a[i]>a[j] then\n begin\n a[0]:=a[i];\n a[i]:=a[j];\n a[j]:=a[0];\n end;\n for i:=1 to n-1 do write(a[i],' ');\n writeln(a[n]);\nend."}, {"source_code": "var\nn,i,j,t:integer;\na,k:array[1..100] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do \nread(a[i]);\nfor i:=1 to 100 do\nfor j:=1 to n do\nif a[j]=i\n then inc(k[i]);\nfor i:=1 to 100 do\nif k[i]<>0\n then for j:=1 to k[i] do\n write(i);\nend.\n"}, {"source_code": "var\n i,j,n,m,k,s:longint;\n a:array[-100..100,-100..100] of longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do\n begin\n s:=0;\n for j:=1 to m do\n begin\n inc(s,a[i,j]);\n end;\n if s>0 then inc(k);\n end;\n writeln(k);\nend.\n"}, {"source_code": "var\n a : array [0..10000] of longint;\n h,i,l,j,n : longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for h:=1 to n do\n begin\n for i:=n-1 downto 1 do\n if a[i]>=h then\n begin\n l:=n;\n for j:=i+1 to n do\n if (a[j]>=a[i]) or (a[j]=h then\n begin\n l:=n;\n for j:=i+1 to n do\n if a[j]>=a[i] then begin l:=j-1; break; end;\n dec(a[i]);\n inc(A[l]);\n end;\n end;\n for i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "var\n a : array [0..10000] of longint;\n h,i,l,j,n : longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for h:=1 to 100 do\n begin\n for i:=n-1 downto 1 do\n if a[i]>=h then\n begin\n l:=n;\n for j:=i+1 to n do\n if (a[j]>=a[i]) then begin l:=j-1; break; end;\n dec(a[i]);\n inc(A[l]);\n end;\n end;\n for i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "var n,i,j,q:integer;a:array[1..100007] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\n for i:=1 to n do\n for j:=i+1 to n do\n if a[i]>a[j] then begin \n q:=a[i]; a[i]:=a[j];a[j]:=q;\n end; \n for i:=1 to n do\n write(a[i]);\n end."}, {"source_code": "program main;\n var N : LongInt;\n A , Ans : array [ 1 .. 100 ] of LongInt;\n\t I , J , Number : LongInt;\nbegin\n readLn ( N ) ;\n\n for i := 1 to N do\n begin\n read ( Number ) ;\n for j := Number downto 1 do\n\tinc ( a [ j ] ) ;\n end;\n\n\n for i := 1 to N do\n begin\n for j := N downto (N+1)-a[i] do\n\tbegin\n\t inc ( ans [ j ] ) ;\n\tend;\n end;\n\n\n for i := 1 to N do\n begin\n write ( ans [ i ] , ' ') ;\n end;\n\n\nend.\n"}, {"source_code": "procedure QSort(arr: array of integer);\n\n procedure sort(l, r: longint);\n var\n i, j, p, b: longint;\n begin\n if (r - l) > 0 then\n begin\n p := arr[random(r - l + 1) + l];\n i := l;\n j := r;\n while i > j do\n begin\n while arr[i] < p do\n Inc(i);\n while arr[j] > p do\n Dec(j);\n if i < j then\n begin\n b := arr[i];\n arr[i] := arr[j];\n arr[j] := b;\n Inc(i);\n Dec(j);\n end;\n end;\n sort(l,i);\n sort(i+1,r);\n end;\n end;\n\n begin\n randomize;\n sort(0, high(arr));\n end;\n \nvar A:array of integer; i,n:integer;\nBEGIN\n read(n);\n setlength(A,n);\n for i:= 0 to n-1 do read(A[i]);\n Qsort(A);\n for i:= 0 to n-1 do write(A[i],' ');\nEND."}, {"source_code": "procedure QSort(var A:array of integer);\n procedure sort(l,h:integer);\n var pivot,b,x,y:integer;\n begin\n if l < h then\n begin\n x:=l; y:=h;\n pivot:=A[h];\n while l < h do\n begin\n while A[l] < pivot do inc(l);\n while A[h] > pivot do dec(h);\n if l < h then\n begin\n b:=A[l];\n A[l]:=A[h];\n A[h]:=b;\n inc(l); dec(h);\n end;\n end;\n sort(x,l-1);\n sort(l,y);\n end;\n end;\nbegin\n sort(0,high(A));\nend;\nvar A:array of integer;n,i:integer;\nBEGIN\n read(n);\n SetLength(A,n);\n for i:=0 to n-1 do read(A[i]);\n QSort(A);\n for i:=0 to high(A) do write(A[i],' ');\nEND.\n\n"}, {"source_code": "var a:array[0..101]of byte;\n i,j,b,n:longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n b:=a[i];\n a[i]:=a[j];\n a[j]:=a[i];\n end;\n for i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "program gf;\n var a:array[1..100] of byte;\n n,t:byte;\nprocedure qsort(l,r:byte);\n var i,j,x,tam:byte;\nbegin\n i:=l;j:=r;\n x:=a[random(r-l+1)+l];\n repeat\n while a[i]x do dec(j);\n if (i<=j) then\n begin\n tam:=a[i];\n a[i]:=a[j];\n a[j]:=tam;\n inc(i);\n dec(j);\n end;\n until i>j;\n if (ia[i+1])then begin r:=a[i]; a[i]:=a[i+1];a[i+1]:=r;end;\nend;\nfor i:=1 to n-1 do\nbegin\nif (a[i]>a[i+1])then begin r:=a[i]; a[i]:=a[i+1];a[i+1]:=r;end;\nend;\nfor i:=1 to n do\nbegin\nwrite(a[i],' ');\nend;\nend."}, {"source_code": "var a:array[1..101]of integer;\nn,i,r:integer;\nbegin\nread(n);\nfor i:=1 to n do\nbegin\nread(a[i]);\nend;\nfor i:=1 to n-1 do\nbegin\nif (a[i]>a[i+1])then begin r:=a[i]; a[i]:=a[i+1];a[i+1]:=r;end;\nend;\nfor i:=1 to n do\nbegin\nwrite(a[i],' ');\nend;\nend."}, {"source_code": "var a:array[1..101]of integer;\nn,i,r:integer;\nbegin\nread(n);\nfor i:=1 to n do\nbegin\nread(a[i]);\nend;\nfor i:=1 to n-1 do\nbegin\nif (a[i]>a[i+1])then begin r:=a[i]; a[i]:=a[i+1];a[i+1]:=r;end;\nend;\nfor i:=1 to n do\nbegin\nwriteln(a[i]);\nend;\nend."}, {"source_code": "Var N, I, J, K, Pr : Integer; A : Array [1..100000] Of Integer;\nBegin\nWrite('Введите количество элементов: '); ReadLn(N);\n For I := 1 To N Do\n Begin\n Readln(A[I]);\n End;\n WriteLn;\n For I := 1 To N - 1 Do\n Begin\n K := I;\n For J := I + 1 To N Do If A[J] <= A[K] Then K := J;\n Pr := A[I]; A[I] := A[K]; A[K] := Pr;\n End;\n For I := 1 To N Do Write(A[I], ' ');\n End."}, {"source_code": "Var N, I, J, K, Pr : Integer; A : Array [1..100000] Of Integer;\nBegin\nReadLn(N);\n For I := 1 To N Do\n Readln(A[I]);\n WriteLn;\n For I := 1 To N - 1 Do\n Begin\n K := I;\n For J := I + 1 To N Do If A[J] <= A[K] Then K := J;\n Pr := A[I]; A[I] := A[K]; A[K] := Pr;\n End;\n For I := 1 To N Do Write(A[I], ' ');\n End.\n"}, {"source_code": "Var N, I, J, K, Pr : Integer; A : Array [1..100000] Of Integer;\nBegin\nWrite('Введите количество элементов: '); ReadLn(N);\n For I := 1 To N Do\n Begin\n Write('Введите A[', I, '] '); Readln(A[I]);\n End;\n WriteLn;\n For I := 1 To N - 1 Do\n Begin\n K := I;\n For J := I + 1 To N Do If A[J] <= A[K] Then K := J;\n Pr := A[I]; A[I] := A[K]; A[K] := Pr;\n End;\n For I := 1 To N Do Write(A[I], ' ');\n End."}, {"source_code": "Var a,b:array[1..10000] of longint;\n i,j,k,m,l,o,p,n:longint;\n\n procedure rec(x:longint);\n begin\n if a[x]>a[x+1] then begin\n dec(a[x]);\n inc(a[x+1]);\n if x0 then write(i,' ');\nend."}, {"source_code": "var\n a: array[1..100] of longint;\n n,b,i,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(b);\n inc(a[b]);\n end;\n for i:=1 to n do for j:=1 to a[i] do write(i,' ');\nend."}, {"source_code": "var\n a: array[1..100] of longint;\n n,b,i,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(b);\n inc(a[b]);\n end;\n for i:=1 to n do if a[i]<>0 then for j:=1 to a[i] do write(i,' ');\nend."}, {"source_code": "var\n a: array[1..100] of longint;\n n,b,i,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(b);\n inc(a[b]);\n end;\n for i:=1 to n do if a[i]<>0 then for j:=1 to a[i] do writeln(i);\nend."}, {"source_code": "var\n a: array[1..100] of longint;\n n,b,i,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(b);\n inc(a[b]);\n end;\n for i:=1 to n do if a[i]<>0 then for j:=1 to a[i] do write(i);\nend."}, {"source_code": "var\n a,n,b,c,d,y:longint;\n f,g:array [1..200] of longint;\n x:string[200];\n\nbegin\n readln(x);\n d:=length(x);\n for a:=1 to d do\n if a mod 2<>0 then\n begin\n c:=trunc(a div 2) + 1;\n f[c]:=byte(x[a]);\n f[c]:=f[c]-48;\n end;\n\n\n n:=trunc(d div 2) + 1;\n\n for a:=1 to n do\n begin\n for b:=1 to n-1 do\n begin\n if f[b]>f[b+1] then\n begin;\n g[b]:=f[b];\n f[b]:=f[b+1];\n f[b+1]:=g[b];\n end;\n end;\n end;\n\n for a:=1 to d do\n begin\n if a mod 2=0 then write(x[a])\n else write(f[trunc(a div 2)+1]);\n end;\n\n end.\n\n\n"}, {"source_code": "{$MODE OBJFPC}\nprogram column;\n\nconst\n inp = '';\n outp = '';\n maxN = Round(1E2+2);\n\nvar\n pb,pb2: Text;\n {input}\n n: Integer;\n a: array [0..maxN] of Integer;\n {main}\n\n {output}\n\n\nprocedure INPUT;\nvar i: Integer;\nbegin\n Assign(pb,inp); Reset(pb);\n Assign(pb2,outp); ReWrite(pb2);\n ReadLn(pb,n);\n for i := 1 to n do Read(pb,a[i]);\nend;\n\nprocedure QS(L,H: Integer);\nvar i,j: Integer;\n key,t: Integer;\nbegin\n i := Random(H-L+1)+L;\n key := a[i];\n i := L; j := H;\n while (i<=j) do\n begin\n while (a[i]key) do Dec(j);\n if (i<=j) then\n begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n Dec(j); Inc(i);\n end;\n end;\n if (Lmax then\n max:=ch;\n mas[i]:=ch;\n end;\n for i:=1 to max do\n begin\n ch:=0;\n for j:=1 to max do\n if mas[j]>(i-1) then \n ch:=ch+1;\n mas1[i]:=ch;\n end;\n for i:=n downto 1 do\n begin\n ch:=0;\n for j:=1 to max do\n if mas1[j]>(i-1) then \n ch:=ch+1;\n write(ch, ' ');\n end;\nend."}, {"source_code": "var\nmas:array[1..100] of longint;\nN,k,i:longint;\nBegin\nread(N);\nfor i:=1 to N do\n read(mas[i]);\nfor i:=1 to N do\n for k:=i to (N - 1) do\n if mas[k] > mas[k + 1] then\n swap(mas[k],mas[k + 1]);\nfor i:=1 to N do\n write(mas[i],' ');\nENd."}, {"source_code": "var N, i, j: longint;\n mas: array [1 .. 100] of longint;\n\nbegin\n read(N);\n for i := 1 to N do\n read(mas[i]);\n for i := 1 to N - 1 do\n for j := i to N - i do\n if mas[j] < mas[j + 1] then\n swap(mas[j], mas[j + 1]);\n for i := N downto 1 do\n write(mas[i], ' ');\nend."}, {"source_code": "var\n n,i,j,a:integer;\n s:array[1..100] of integer;\nbegin\n read(n);\n for i :=1 to n do\n read(s[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n begin\n if s[i]>s[j] then\n begin\n a:=s[i];\n s[i]:=s[j];\n s[j]:=a;\n end;\n end;\n for i:=1 to n do\n write(s[i]);\nend."}, {"source_code": "var a: array of integer;\n i, s, j, k: integer;\nbegin\n readln(s);\n setlength(a, s);\n for i:=0 to s-1 do\n begin\n read(a[i]);\n end;\n for i:=0 to s-1 do \n begin\n for j:=0 to s-2 do\n if a[j]>a[j+1] then\n begin\n k:=a[j+1];\n a[j+1]:=a[j];\n a[j]:=k;\n end;\n end;\n writeln(a);\nend."}, {"source_code": "program grav;\nvar n,i,count:integer; a:array[1..100]of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor count:=1 to n-1 do\nfor i:=1 to n-1 do\nif a[i]>a[i+1] then\nbegin\na[i]:=a[i]+a[i+1];\na[i+1]:=a[i]-a[i+1];\na[i]:=a[i]-a[i+1];\nend;\nfor i:=1 to n do\nwrite(a[i]);\nend."}, {"source_code": "var n,i,j,k:integer;\n a:array[1..100]of integer;\nbegin\nread(n);\nfor i:=1 to n do read(a[i]);\n\nfor j:=1 to n-2 do\n for i:=1 to n-j do\n if a[i]>a[i+1] then begin\n k:=a[i];\n a[i]:=a[i+1];\n a[i+1]:=k;\n end;\n \nfor i:=1 to n do write(a[i],' ');\nend."}, {"source_code": "Program abc;\n Var n,i,j,k:integer;\n mas:array of integer;\nbegin\n readln(n);\n Setlength(mas,n+1);\n for i:=1 to n do read(mas[i]);\n for j:=1 to n do\n begin\n for i:=1 to n-1 do\n begin\n if(mas[i]max then\n begin\n max:=a[i];\n k:=i;\n end;\n a[k]:=a[d];\n a[d]:=max;\n end;\n end;\n for d:=1 to n do\n begin\n write(a[n-d+1],' ');\n end;\nend. \n"}, {"source_code": "var\n n, i, j, r, max, jj, fl: byte;\n a: array[1..101, 1..101] of byte;\n \nbegin\n readln(n);\n for i := 1 to 101 do\n for j := 1 to 101 do a[i, j] := 0;\n max := 0;\n for i := 1 to n do \n begin\n read(r);\n for j := 1 to r do a[j, i] := 1;\n if r > max then max := r\n end;\n { for i := max downto 1 do\n begin\n for j := 1 to n do write(a[i, j]);\n writeln\n end;\n writeln;}\n \n for i := max downto 1 do \n begin\n for j := n downto 1 do\n begin\n //writeln(i,' ', j);\n if a[i, j] = 1\n then begin\n \n for r := j - 1 downto 1 do\n if a[i, r] <> 0 \n then begin\n a[i, j] := 0;\n a[i, r + 1] := 1;\n break\n end;\n end end\n end; \n {for i := max downto 1 do\n begin\n for j := 1 to n do write(a[i, j]);\n writeln\n end;}\n \n for i := n downto 1 do\n begin\n r := 0;\n for j := 1 to max do \n if a[j, i] <> 0 then inc(r);\n write(r,' ')\n end\nend."}, {"source_code": "var a:array[1..100] of integer;\n k,n,i,j:integer;\nbegin\n read(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n for j:=1 to n-i do\n if a[j]>a[j+1] then begin\n k:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=k;\n end;\n for i:=1 to n do\n write(a[i]);\nend.\n "}, {"source_code": "var a:array[1..1000] of longint; \n n, i, j, u:longint; \nbegin\n\nreadln(n);\n\nfor i:=1 to n do \n read(a[i]); \n\na[n+1]:=1000; \n\nfor i:=n-1 downto 1 do \n if a[i]>a[i+1] then \n begin\n \n u:=a[i]; \n a[i]:=a[i+1]; \n \n for j:=i+1 to n do\n begin\n if a[j+1]>a[j] then begin\n if u a[j] then\n begin\n b:=a[i]-a[j];\n a[j]:=a[j]+b;\n a[i]:=a[i]-b;\n end;\nfor i:= 1 to n do\n write(a[i]);\nend."}, {"source_code": "program ideone;\nvar a:array [1..100] of integer;\n i,j,b,n:integer;\nbegin\nreadln(n);\nfor i:= 1 to n do\n readln(a[i]);\nfor i:= n-1 downto 1 do\n for j:= i to n-1 do\n if a[i] > a[j] then\n begin\n b:=a[i]-a[j];\n a[j]:=a[j]+b;\n a[i]:=a[i]-b;\n end;\nfor i:= 1 to n do\n write(a[i]);\nend."}, {"source_code": "var\na:array[0..105] of integer;\nn,i,x:integer;\nbegin\nreadln(n);\nread(a[1]);\nfor i:=2 to n do\n begin\n read(a[i]);\n if a[i]a[j] then\nbegin\nt:=a[i]-a[j];\na[i]:=a[i]-t;\na[j]:=a[j]+t;\nend;\nfor i:=1 to n do write(a[i],' ');\nreadln\nend."}, {"source_code": "var \n a:array[1..101] of longint;\n i,j,t,n:longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n for i:=1 to n do \n write(a[i]);\nend."}, {"source_code": "var i,j,n,o:longint;\n\ta:array[1..1000000] of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n\tread(a[i]);\nfor i:=1 to n do\n\tfor j:=n downto i+1 do\n\t\tif a[i]x do begin\na[j+1]:=a[j]; dec(j);\nend;\nend;a[j+1]:=x;\n for i:=1 to n do write(a[i],' ');\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var i, j, n:integer;\na:array[1..100] of integer;\nprocedure swap(x, y:integer);\nbegin\n\ta[j] := y;\n\ta[j + 1] := x;\nend;\nbegin\n\treadln(n);\n\tfor i := 1 to n do read(a[i]);\n\tfor i := 1 to n do\n\t for j := 1 to n - 1 do\n\t if a[j] < a[j + 1] then swap(a[j], a[j + 1]);\n\tfor i := 1 to n do write(a[i], ' ');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype mass=array[1..100]of integer;\nvar i,n,a,b,j,max:integer; m,k:mass;\nbegin\n{ reset(input,'input.txt');\n }rewrite(output,'output.txt');\n readln(n);\n max:=0;\n for i:=1 to n do\n begin\n read(m[i]);\n if m[i]>max\n then max:=m[i];\n end;\n\n for i:=1 to max do\n begin\n for j:=1 to n do\n if m[j]>=i\n then inc(k[i]);\n end;\n for i:=n downto 1 do\n begin\n a:=0;\n for j:=1 to max do\n if k[j]>=i\n then inc(a);\n write(a,' '); \n end;\nend.\n"}], "src_uid": "ae20712265d4adf293e75d016b4b82d8"} {"source_code": "\nvar d: int64; \nk, a, b, t: int64; \nres, mn: int64; \n\nbegin \nread(d, k, a, b, t); \nres:= 0; \nif (d <= k) then \nres:= d*a \nelse begin \nres:= a*k; \nd:= d - k; \nif (a*k+t <= b*k) then \nres:= res + (d div k) * (a*k+t) \nelse \nres:= res + (d div k) * (b*k); \nk:= d mod k; \nif (a*k+t <= b*k) then \nres:= res + a*k+t \nelse \nres:= res + b*k; \nend; \nwriteln(res); \nend.", "positive_code": [{"source_code": "\n {$MODE OBJFPC}\nprogram dream_hyojoobilnn;\nuses math;\nvar d,k,a,b,t,time,x:int64;\nbegin\n readln(d,k,a,b,t);\n //mdzlbnxd\n time:=time+a*min(d,k);\n d:=d-k;\n if (d>0) and (t+a*k0 then inc(time,b*d);\n writeln(time)\nend."}, {"source_code": "uses math;\n\nconst fi = '';\n\nvar d, k, a, b, t: int64;\n f: text;\n\nbegin\n assign(f, fi); reset(f);\n readln(f, d, k, a, b, t);\n close(f);\n\n if d <= k then\n writeln(d * a)\n else\n if t + k * a > k * b then\n writeln(k * a + (d - k) * b)\n else\n writeln(k * (d div k) * a + (d div k - 1) * t + min(t + (d mod k) * a, (d mod k) * b));\n readln;\nend."}, {"source_code": "var n,i,d,k,a,b,t:int64;\nbegin\n read(d,k,a,b,t);\n if d<=k then\n begin\n write(a*d);\n halt;\n end else\n if (t+a*k>b*k) then\n begin\n write(a*k+b*(d-k));\n halt;\n end else\n if (t+d mod k *a> d mod k * b ) then\n begin\n write(a*(d-d mod k)+((d-d mod k) div k -1)*t + d mod k *b);\n halt;\n end else\n write(a*d+(d-1) div k*t);\n readln;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar d: int64;\n k, a, b, t: int64;\n res, mn: int64;\n\nbegin\n read(d, k, a, b, t);\n res:= 0;\n if (d <= k) then\n res:= d*a\n else begin\n res:= a*k;\n d:= d - k;\n if (a*k+t <= b*k) then\n res:= res + (d div k) * (a*k+t)\n else\n res:= res + (d div k) * (b*k);\n k:= d mod k;\n if (a*k+t <= b*k) then\n res:= res + a*k+t\n else\n res:= res + b*k;\n end;\n writeln(res);\nend."}, {"source_code": "uses math;\nvar\n d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;\n\nfunction check(x:int64):int64;\nbegin\n if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);\nend;\n\nbegin\n readln(d,k,a,b,t);\n l:=(t+d*k*b) div (t+a*k+b*k);\n ans:=l*a+((l-1) div k)*t+(d-l)*b;\n ll:=0;\n rr:=d;\n while (rr-ll>2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)min(d,rr+k+1000000);\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if ly then exit(y);\nexit(x);\nend;\n\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(d,k,a,b,t);\nkq:=kq+a*min(d,k);\ndec(d,k);\nif (d>0) and (t+a*k0 then kq:=kq+b*d;\nwriteln(kq);\nend;\n\nbegin\n//mo;\nsolve;\nend.\n"}, {"source_code": "uses math;\nvar d,t,k,b,a,i,j :int64;\n res :int64;\n r,rr :int64;\n\nbegin\n readln(d,k,a,b,t);\n if k*a+t>k*b then\n begin\n if k>=d then res:=d*a else res:=a*k+(d-k)*b;\n write(res);\n halt;\n end;\n i:=d div k;\n res:=i*(k*a+t)+(d-i*k)*a;\n if i>0 then\n begin\n dec(i);\n rr:=i*(k*a+t)+k*a+(d-k-i*k)*b;\n res:=min(res,rr);\n end;\n write(res);\nend."}, {"source_code": "var\n d, k, a, b, t, c: int64;\n \nbegin\n readln(d, k, a, b, t);\n if d < k then begin\n writeln(d * a);\n halt();\n end;\n if k * a + t >= b * k then begin\n if a < b then begin\n if d < k then begin\n writeln(d * a);\n halt();\n end\n else begin\n writeln(k * a + (d - k) * b);\n halt();\n end;\n end\n else writeln(d * b);\n end\n else begin\n if (d mod k) * b < t + (d mod k) * a then writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a)\n else writeln(d * a + (d div k) * t);\n end;\nend."}, {"source_code": "Uses Math;\nConst Finp='';\n Fout='';\nVar d,k,a,b,t:int64;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,d,k,a,b,t);\n close(f);\nEnd;\nFunction Solve:int64;\nVar res,m,c:int64;\nBegin\n if d<=k then\n res:=min(a,b)*d\n else\n begin\n if a*k+t>b*k then\n res:=a*k+(d-k)*b\n else\n begin\n m:=(d-1) div k;\n c:=min((d-m*k)*b,(d-m*k)*a+t);\n res:=a*m*k+t*(m-1)+c;\n end;\n end;\n exit(res);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:int64;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Xuat_Solve;\nEnd."}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,time,p,pp,kol,t1,ost,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n kol:=(dist+kk) div kk-1;\n ost:=dist mod kk;\n{ writeln('kol= ',kol,' ost= ',ost);\n }\n if kol=0 then begin writeln(dist*aaa); goto 1; end;\n tpesh:=dist*bbb;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;\n t1:=aaa*kk+(dist-kk)*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,t1);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n"}, {"source_code": "uses math;\nconst\n fi='';\n fo='';\nvar\n ans,d,k,a,b,t,tmp1,tmp2:int64;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(d,k,a,b,t);\n tmp1:=d div k;\n tmp2:=d mod k;\n if tmp1<=0 then\n ans:=a*tmp2\n else\n begin\n ans:=a*k;\n dec(tmp1);\n if tmp1>0 then\n if a*k+t>b*k then\n if (b-a)*tmp2>=((a-b)*k+t)*tmp1 then\n ans:=ans+(a*k+t)*tmp1+a*tmp2\n else\n ans:=ans+b*(k*tmp1+tmp2)\n else\n ans:=ans+(a*k+t)*tmp1+min(a*tmp2+t,b*tmp2)\n else\n ans:=ans+min(t+a*tmp2,b*tmp2);\n end;\n write(ans);\n close(input);\n close(output);\nend."}, {"source_code": "uses math;\nvar\n l,r,d,k,a,b,t,mid,ans,mn : int64;\n\nbegin\n readln(d,k,a,b,t);\n if d <= k then begin writeln(d*a); halt; end;\n if k*a+t > k*b then begin writeln(k*a+(d-k)*b); halt; end;\n mn:=(d-1) div k;\n l:=min( (d-mn*k)*b,(d-mn*k)*a+t );\n writeln(mn*k*a+(mn-1)*t+l);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoobilnn;\nuses math;\nvar d,k,a,b,t,time,x:int64;\nbegin\n readln(d,k,a,b,t);\n time:=time+a*min(d,k);\n d:=d-k;\n if (d>0) and (t+a*k0 then inc(time,b*d);\n writeln(time)\nend."}], "negative_code": [{"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n kol:=(dist+kk) div kk-1;\n ost:=dist mod kk;\n {writeln('kol= ',kol,' ost= ',ost);\n }\n tpesh:=dist*bbb;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;\n t1:=aaa*kk+(dist-kk)*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,t1);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;\nbegin\n ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb;\n\n ttime:=ot;\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n besk:=8000000000000000000;\n read(dist,kk,aaa,bbb,time);\n p:=dist div kk;\n ot:=besk;\n for i:=0 to p do ot:=min(ot,ttime(i));\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n kol:=(dist+kk-1) div kk-1;\n ost:=dist mod kk;\n{ writeln('kol= ',kol,' ost= ',ost);\n} tpesh:=dist*bbb;\n tavt:=kol*(aaa*kk+t)+ost*aaa;\n tcomb:=(kol-1)*(aaa*kk+t)+ost*bbb;\n t1:=aaa*kk+(dist-kk)*bbb;\n{ writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,t1);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;\nbegin\n if nzikl>0 then\n ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb else ot:=dist*bbb;\n\n ttime:=ot;\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n besk:=8000000000000000000;\n read(dist,kk,aaa,bbb,time);\n p:=dist div kk;\n ot:=besk;\n for i:=1 to p do begin ot:=min(ot,ttime(i)); { writeln(i,' ',ttime(i)); }end;\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n\n ost:=dist mod kk;\n if ost=0 then ost:=kk;\n kol:=(dist-ost) div kk;\n {writeln('kol= ',kol,' ost= ',ost);\n }\n tpesh:=aaa*kk+(dist-kk)*bbb;;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol)*(aaa*kk+t)-t+ost*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n kol:=(dist+kk-1) div kk-1;\n ost:=dist mod kk;\n {writeln('kol= ',kol,' ost= ',ost);\n }tpesh:=dist*bbb;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;\n t1:=aaa*kk+(dist-kk)*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,t1);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,time,p,pp,kol,t1,ost,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n kol:=(dist+kk) div kk-1;\n ost:=dist mod kk;\n{ writeln('kol= ',kol,' ost= ',ost);\n }\n tpesh:=dist*bbb;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;\n t1:=aaa*kk+(dist-kk)*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,t1);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n\n ost:=dist mod kk;\n if ost=0 then ost:=kk;\n kol:=(dist-ost) div kk;\n {writeln('kol= ',kol,' ost= ',ost);\n }\n tpesh:=aaa*kk+(dist-kk)*bbb;\n tavt:=kol*(aaa*kk+t)+ost*aaa;\n tcomb:=kol*(aaa*kk+t)-t+ost*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(dist,kk,aaa,bbb,t);\n\n\n ost:=dist mod kk;\n if ost=0 then ost:=kk;\n kol:=(dist-kk) div kk;\n{ writeln('kol= ',kol,' ost= ',ost);\n }\n tpesh:=aaa*kk+(dist-kk)*bbb;;\n if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;\n tcomb:=(kol)*(aaa*kk+t)-t+ost*bbb;\n {writeln('tpesh= ',tpesh,' tavt= ',tavt, ' tcomb= ',tcomb);\n }\n ot:=min(tpesh,tavt);\n ot:=min(ot,tcomb);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;\nbegin\n if nzikl>0 then\n ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb else ot:=dist*bbb;\n\n ttime:=ot;\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n besk:=8000000000000000000;\n read(dist,kk,aaa,bbb,time);\n p:=dist div kk;\n if dist mod kk=0 then ot:=aaa div tt; \n ot:=besk;\n for i:=1 to p do begin ot:=min(ot,ttime(i)); { writeln(i,' ',ttime(i)); }end;\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-100..2000000] of int64;\n dda:array[-1..60,-1..200001] of extended;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:longint):longint;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nfunction ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;\nbegin\n ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb;\n\n ttime:=ot;\nend;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n besk:=8000000000000000000;\n read(dist,kk,aaa,bbb,time);\n p:=dist div kk;\n ot:=besk;\n for i:=1 to p do ot:=min(ot,ttime(i));\n writeln(ot);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar d: int64;\n k, a, b, t: integer;\n res, mn: integer;\n\nbegin\n read(d, k, a, b, t);\n res:= a*k;\n d:= d - k;\n while (d >= k) and (b*d >= ((d div k) * (a*k+t) + min((d mod k) * b, (d mod k) * a + t))) do\n begin\n res:= res + a*k+t;\n d:= d - k;\n end;\n res:= res + min(b*d, d*a+t);\n writeln(res);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar d: int64;\n k, a, b, t: integer;\n res, mn: integer;\n\nbegin\n read(d, k, a, b, t);\n res:= 0;\n if (d <= k) then\n res:= d*a\n else begin\n res:= a*k;\n d:= d - k;\n if (a*k+t <= b*k) then\n res:= res + (d div k) * (a*k+t)\n else\n res:= res + (d div k) * (b*k);\n k:= d mod k;\n if (a*k+t <= b*k) then\n res:= res + a*k+t\n else\n res:= res + b*k;\n end;\n writeln(res);\nend."}, {"source_code": "Const Finp='';\n Fout='';\nVar d,k,a,b,t:int64;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,d,k,a,b,t);\n close(f);\nEnd;\nFunction Solve:int64;\nVar res,m,c:int64;\nBegin\n if a>b then\n res:=b*d\n else\n begin\n m:=(b*k-a*k) div t;\n c:=d div a;\n if mb then\n res:=b*d\n else\n begin\n m:=(b*k-a*k) div t;\n c:=d div a;\n if ma1[i-1] then\n begin\n inc(n);\n a[n]:=a1[i];\n end;\n m:=1; b[0]:=-vocuc; b[1]:=b1[1];\n for i:=2 to m1 do\n if b1[i]<>b1[i-1] then\n begin\n inc(m);\n b[m]:=b1[i];\n end;\n inc(m); b[m]:=vocuc;\nEnd;\nFunction BinSearch(l,r,x:longint):longint;\nVar i,j,mid:longint;\nBegin\n i:=l; j:=r;\n while i<=j do\n begin\n mid:=(i+j) div 2;\n if b[mid]>x then j:=mid-1;\n if b[mid]<=x then i:=mid+1;\n end;\n if b[i]>x then\n dec(i);\n exit(i);\nEnd;\nFunction Solve:longint;\nVar i,res,bin,minl,val1,val2:longint;\nBegin\n res:=0;\n for i:=1 to n do\n begin\n bin:=binsearch(0,m,a[i]);\n if bin=0 then val1:=vocuc else val1:=abs(a[i]-b[bin]);\n if bin+1=m then val2:=vocuc else val2:=abs(b[bin+1]-a[i]);\n minl:=min(val1,val2);\n if minl>res then\n res:=minl;\n end;\n exit(res);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:longint;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Compress;\n Xuat_Solve;\nEnd."}, {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n\nvar\n fi, fo: text;\n d, k, a, b, t: int64;\n\nprocedure __;\nvar\n ans, repair, km: int64;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, d, k, a, b, t);\n ans := k*a;\n d := d-k;\n repair := ((d-(d mod k)) div k);\n km := (d-(d mod k));\n ans := ans+min(km*b, repair*t+km*a);\n ans := ans+min((d mod k)*b, t+(d mod k)*a);\n writeln(fo, ans);\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n __;\n _;\nEND.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoobilnn;\nuses math;\nvar d,k,a,b,t,time,x:int64;\nbegin\n readln(d,k,a,b,t);\n d:=d-k;\n time:=time+a*min(d,k);\n if (d>0) and (t+a*k0) and (t+a*k0 then inc(time,b*d);\n writeln(time)\nend."}, {"source_code": "var\n d,k,a,b,t,l:int64;\nbegin\n readln(d,k,a,b,t);\n l:=(t+d*k*b) div (t+a*k+b*k);\n inc(l,ord(l mod k>0)*(k-l mod k));\n writeln(l*a+(l-1) div k*t+(d-l)*b);\nend.\n\n"}, {"source_code": "uses math;\nvar\n d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;\n\nfunction check(x:int64):int64;\nbegin\n if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);\nend;\n\nbegin\n readln(d,k,a,b,t);\n l:=(t+d*k*b) div (t+a*k+b*k);\n ans:=l*a+((l-1) div k)*t+(d-l)*b;\n ll:=0;\n rr:=l;\n while (rr-ll>2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)rr+1;\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)rr+1;\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)min(d,rr+k+1000);\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)rr+k+1;\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l0)*(k-l mod k));\n writeln(min(l*a+(l-1) div k*t+(d-l)*b,min(b*d,a*d+(d-1) div k*t)));\nend.\n\n"}, {"source_code": "uses math;\nvar\n d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;\n\nfunction check(x:int64):int64;\nbegin\n if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);\nend;\n\nbegin\n readln(d,k,a,b,t);\n l:=(t+d*k*b) div (t+a*k+b*k);\n ans:=l*a+((l-1) div k)*t+(d-l)*b;\n ll:=0;\n rr:=d;\n while (rr-ll>2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)min(d,rr+k+1);\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)rr;\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if l0)*(k-l mod k));\n if l2) do\n begin\n mm1:=(ll+ll+rr) div 3;\n mm2:=(ll+rr+rr) div 3;\n if check(mm1)rr;\n inc(l,ord(l mod k>0)*(k-l mod k));\n ans:=min(ans,check(l));\n if ly then exit(y);\nexit(x);\nend;\n\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(d,k,a,b,t);\nkq:=kq+a*min(d,k);\ndec(d,k);\nif (d>0) and (t+a*k0 then kq:=kq+b*d;\nwriteln(kq);\nend;\n\nbegin\n//mo;\nsolve;\nend.\n"}, {"source_code": "const\n fin='702D.inp';fon='702D.out';\nvar d,k,a,b,t,kq,i:qword;\n\nfunction min(x,y:qword):qword;\nbegin\nif x>y then exit(y);\nexit(x);\nend;\n\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\nreadln(d,k,a,b,t);\nkq:=kq+a*min(d,k);\ndec(d,k);\nif (d>0) and (t+a*k0 then kq:=kq+b*d;\nwriteln(kq);\nend;\n\nbegin\n//mo;\nsolve;\nend.\n"}, {"source_code": "var\n d, k, a, b, t, c: int64;\n \nbegin\n readln(d, k, a, b, t);\n if k * a + t >= b * k then begin\n if a < b then begin\n if d < k then begin\n writeln(d * a);\n halt();\n end\n else begin\n writeln(k * a + (d - k) * b);\n halt();\n end;\n end\n else writeln(d * b);\n end\n else begin\n writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a);\n end;\nend."}, {"source_code": "var\n d, k, a, b, t, c: int64;\n \nbegin\n readln(d, k, a, b, t);\n if k * a + t >= b * k then begin\n if a < b then begin\n if d < k then begin\n writeln(d * a);\n halt();\n end\n else begin\n writeln(k * a + (d - k) * b);\n halt();\n end;\n end\n else writeln(d * b);\n end\n else begin\n if (d mod k) * b < t + (d mod k) * a then writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a)\n else writeln(d * a + (d div k) * t);\n end;\nend."}], "src_uid": "359ddf1f1aed9b3256836e5856fe3466"} {"source_code": "//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//\n\nconst fi='';\n fo='';\nvar f:text;\n n,i,kq,j:longint;\n a:array[1..100000]of longint;\n kt:boolean;\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[j] then\n begin tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n end;\n d:=0;\n for i:=1 to n do\n if f[i]=0 then\n begin d:=d+1;\n for j:=i to n do\n if a[j] mod a[i]=0 then f[j]:=d;\n end;\n writeln(d);\n //close(input); close(output);\nend."}, {"source_code": "var kq,n,i,j:longint;\n a:array[0..100] of longint;\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then\n for j:=i+1 to n do\n if (a[j] <> 0) and (a[j] mod a[i]=0) then\n begin\n dec(kq);\n a[j]:=0;\n end;\n writeln(kq);\nend.\n \n \n "}, {"source_code": "var n,tot,x,i,j:integer;\na:array[1..100]of 0..1;\nbegin \n\treadln(n);\n\tfillchar(a,sizeof(a),0);\n\tfor i:=1 to n do \n\tbegin \n\t\tread(x);\n\t\ta[x]:=1;\n\tend;\n\ttot:=0;\n\ti:=1;\n\twhile i<=100 do\n\tbegin \n\t\twhile (a[i]=0) and (i<=100) do inc(i);\n\t\tif i<=100 then \n\t\tbegin \n\t\t\tinc(tot);\n\t\t\tfor j:=2 to 100 div i do a[j*i]:=0;\n\t\tend;\n\t\tinc(i);\n\tend;\n\twrite(tot);\nend."}, {"source_code": "var\n\tn, m, p, j, c: integer;\n\ta: array[1..120] of integer;\n\t\nbegin\n\t\n\treadln(n);\n\tm := 120;\n\tfor var i := 1 to n do\n\tbegin\n\t\tread(c);\n\t\ta[c] += 1;\n\tend;\n\t\n\t\n\tfor var i := 1 to m do\n\tbegin\n\t\tif (a[i] >= 1) then\n\t\tbegin\n\t\t\tp += 1;\n\t\t\tj := i;\n\t\t\twhile (j <= m) do\n\t\t\tbegin\n\t\t\t\ta[j] := 0;\n\t\t\t\tj += i;\n\t\t\tend;\n\t\tend;\n\tend;\n\t\n\twriteln(p);\n\t\nend.\n"}, {"source_code": "type mang=array[1..10000] of byte;\nvar dem,n,i,j,a1,k:shortint;\n prime,a:mang;\nprocedure qsort(d,c:longint; var a:mang);\nvar i,j:longint;\n tam,k:int64;\nbegin\n if(d>c) then exit;\n i:=d;\n j:=c;\n k:=a[(i+j) div 2];\n repeat\n while (a[i]k) do j:=j-1;\n if (i<=j) then\n begin\n tam:=a[i];\n a[i]:= a[j];\n a[j]:=tam;\n i:=i+1;\n j:=j-1;\n end;\n until i>j;\n if(d0 then\n begin\n for j := i+1 to n do if a[j] mod a[i]=0 then a[j]:=0;\n end;\n for i := 1 to n do if a[i]<>0 then inc(dem);\n writeln(dem);\n readln;\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000{000000000000}; label 1,3,2,44;\n type mas=array[-1000000..1500000+1] of int64;\n integer=longint; int64=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qq:zap;\n vx,vy,ans,up,down,left,right,px,py,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,ll,rr,sum,m,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n xa,summ,place,kol,str,b2,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..4000000] of boolean;\n path,lx,rx,ly,ry,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-1000000..5500000] of int64;\n ppole:array[-1000000..3000000] of char;\n stroka:array[-1000..1000000] of char;\n h1,h2,h,l1,l2,ot1,otmax,v:extended;\n ssumitog,sumitog,itog,zangor,zanver,sumgor,sumver,prof,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n ddmax,dd,ddinv,dnech,poschet,posnechet:array[-10..1900000,0..5] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n xleft,xright,s,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-1000000..4000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]1000);\n if pos<=1000 then\n begin\n { writeln('pos= ',pos);\n } inc(ot);\n t:=1000 div pos;\n for i:=1 to t do zan[i*pos]:=false;\n\n end;\n if pos<=1000 then goto 2;\n\n writeln(ot);\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": "var\n a:array[0..101] of longint;\n b:array[0..101] of 0..1;\n i,j,n,s:longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n a[i]:=a[i]+a[j];a[j]:=a[i]-a[j];a[i]:=a[i]-a[j];\n end;\n for i:=1 to n do\n if b[i]=0 then\n begin\n inc(s);\n for j:=i+1 to n do if a[j] mod a[i]=0 then b[j]:=1;\n end;\n writeln(s);\nend."}, {"source_code": "var\n v, v2, mark: array [1..101] of longint;\n n, i, j, color: longint;\n\nprocedure qSort(l, r: longint);\nvar\n i, j, w, q: longint;\nbegin\n i := l; j := r;\n q := v[(l + r) div 2];\n repeat\n while (v[i] < q) do inc(i);\n while (q < v[j]) do dec(j);\n if (i <= j) then\n begin\n w := v[i]; v[i] := v[j]; v[j] := w;\n w := v2[i]; v2[i] := v2[j]; v2[j] := w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l, j);\n if (i < r) then qSort(i, r);\nend;\n\nbegin\n read(n);\n for i := 1 to n do\n begin\n read(v[i]);\n v2[i] := i;\n end;\n qSort(1, n);\n for i := 1 to n do\n begin\n if (mark[i] = 0) then\n begin\n color := color + 1;\n mark[i] := color;\n for j := i + 1 to n do\n begin\n if (v[j] mod v[i] = 0) then\n begin\n mark[j] := color;\n end;\n end;\n end;\n end;\n // for i := 1 to n do\n // begin\n // write(v[i], ' ');\n // end;\n // writeln();\n writeln(color)\nend."}, {"source_code": "//const fi='A.INP';\n //fo='A.OUT';\nvar i,j,n,tmp,res:longint;\n a:array [1..1000] of longint;\n dd:array [1..1000] of boolean;\nbegin\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n read(n);\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i] a[i+1]) then\n begin\n k := a[i];\n a[i] := a[i+1];\n a[i+1] := k;\n end;\n for i := 1 to n do\n begin\n if not(used[i]) then\n begin\n for j := i to n do\n if (a[j] mod a[i] = 0) then\n used[j] := true;\n inc(m);\n end;\n end;\n writeln(m);\nend."}, {"source_code": "var n, i, j, ans : integer;\n a : array[1..101] of integer;\n mark : array[1..101] of boolean;\n \nprocedure swap(var a, b : integer);\nvar tmp : integer;\nbegin\n tmp := a; a := b; b := tmp;\nend;\n\nbegin\n readln(n);\n for i := 1 to n do read(a[i]);\n \n for i := 1 to n - 1 do\n begin\n for j := i + 1 to n do\n begin\n if (a[i] > a[j]) then swap(a[i], a[j]);\n end;\n end;\n \n fillchar(mark, sizeof(mark), false);\n ans := 0;\n for i := 1 to n do\n begin\n if not mark[i] then\n begin\n inc(ans);\n for j := i to n do\n begin\n if (a[j] mod a[i] = 0) then mark[j] := true;\n end;\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n n, i, j:longint;\n ans:int64;\n v:array[1..100] of longint;\nprocedure qSort(l,r:longint);\nvar i,j,w, q:longint;\nbegin\n i := l; j := r;\n q := v[(l+r) div 2];\n repeat\n while (v[i] < q) do inc(i);\n while (q < v[j]) do dec(j);\n if (i <= j) then\n begin\n w:=v[i]; v[i]:=v[j]; v[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\nbegin\n readln(n);\n for i:=1 to n do\n read(v[i]);\n qsort(1, n);\n for i:=1 to n do\n if v[i]<>0 then\n begin\n inc(ans);\n for j:=i+1 to n do\n if v[j] mod v[i]=0 then v[j]:=0; \n end; \n writeln(ans);\nend."}, {"source_code": "var n,b,c,d,e:longint;a:array [1..100] of longint;\nbegin\n d:=0;\n readln(n);\n for b:=1 to n do begin\n read(c);\n inc(a[c]);\n end;\n for b:=1 to 100 do begin\n if a[b]>0 then begin\n inc(d);\n for e:=b+1 to 100 do begin\n if e mod b=0 then a[e]:=0;\n end;\n end;\n end;\n writeln(d);\nend."}, {"source_code": "Var i,n,j,kq,ktc:Longint;\nA:array[1..100]of Longint;\nkt:array[1..100]of Boolean;\n\n{Procedure Pt;\nBegin\nj:=2;\nWhile A[i] > 1 do\n Begin\n If A[i] mod j = 0 then\n Begin\n Kt[j]:=True;\n While A[i] mod j = 0 do\n A[i]:=A[i] div j;\n End;\n Inc(j);\n End;\nEnd;\n\nBegin\nReadln(n);\nIf n = 1 then \nbegin\nRead(A[i]);\nWriteln('1');\nEnd else\nBegin\nFor i:=1 to n do \n Begin\n Read(A[i]);\n If A[i]=1 then \n Begin\n Ktc:=1;\n Break;\n End else\n Pt;\n End;\nkq:=0;\nIf ktc=1 then Writeln('1') else\nbegin\nFor i:=1 to n do\nIf kt[i]=true then inc(kq);\nWriteln(kq);\nEnd;\nEnd;\nEnd.}\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l 0) and (A[i]<>0) then\n If A[j] mod A[i] = 0 then A[j]:=0;\n Inc(i);\n End;\nFor i:=1 to n do\nIf A[i]<>0 then inc(kq);\nWriteln(kq);\nEnd."}, {"source_code": "type mang = array [1..100] of longint;\nvar i,n,j,d,a:longint;\n b:mang;\n\nbegin\n readln(n);\n for i:= 1 to n do\n begin\n read(a);\n inc(b[a]);\n end;\n d:=0;\n for i:=1 to 100 do\n begin\n j:=1;\n if b[i]<>0 then\n begin\n while i*j <= 100 do\n begin\n b[i*j]:=0;\n inc(j);\n end;\n inc(d);\n end;\n end;\n writeln(d);\nend."}, {"source_code": "var\nn,t,x,i,k,f,j,r:int64;\na,b:array [1..100] of int64;\nbegin\n readln(t);\n f:=0;\n k:=t;\n for i :=1 to t do\n begin\n x:=0;\n read(a[i]);\n f:=0;\n for r:=1 to j do\n if a[i] mod b[r]=0 then f:=1 else \n x:=x+1;\n k:=k-f;\n if x=j then begin j:=j+1;b[j]:=a[i]; end;\n end;\n for i:=1 to j do begin\n n:=0;\n for r:=1 to j do\n if b[i] mod b[r]=0 then n:=n+1;\n if n>1 then k:=k-1;\n end;\n write(k);\nend."}], "negative_code": [{"source_code": "//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//\n\nconst fi='';\n fo='';\nvar f:text;\n n,i,kq,j:longint;\n a:array[1..100000]of longint;\n b:array[1..100000]of boolean;\nfunction snt(g:longint):boolean;\nvar i:longint;\nbegin\n if g<2 then exit(false);\n for i:=2 to trunc(sqrt(g)) do\n if g mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n assign(f,fi); reset(f);\n readln(f,n); kq:=0;\n fillchar(b,sizeof(b),false);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\n assign(f,fo); rewrite(f);\n for i:=1 to n do\n if(snt(a[i])=true) then\n if b[a[i]]=false then\n begin\n inc(kq);\n b[a[i]]:=true;\n end\n else\n else\n for j:=2 to trunc(sqrt(a[i])) do\n if a[i] mod j=0 then\n if b[j]=false then\n begin\n b[j]:=true;\n inc(kq);\n break;\n end\n else break;\n writeln(f,kq);\n close(f);\nend.\n\n\n\n\n//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//\n{ ..sSs$$$$$$b.\n .$$$$$$$$$$$$$$$.\n .$$$$$$$$$$$$$$$$$$$$$b.\n .$$$$$$$$$$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$$$$$$S' `$$$$\n $$$$$$$$$$$$$$S' $$$\n $$$$$$$$$$$$$' `$$.\n `$$$$$$$$$$$$$ `$$$.\n `$$$$$$$$$' .s$$$ $$ $\n $$$$$$$$$.sSs .s$$s\" s s\n $$$$$$$$$$$$ $P\n `$$$$$$$$$$$s $\n $$$$$$$$$$$. \",\n `$$$$$$$$$$sS$\n s$$$. `$$$$$$$$$$$$.s\"' .$.\n $$$$$. `$$$$$$$$$$. .$$$Ss.s$s.\n $$$$$. `$$$$$$$$$P .$$$$$$$$$$$$.\n $$$$$$. `$$$$$$$' .$$$$$$$$$$$$$$$$.\n `$$$$$$. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$s.\n $$$$$$. `$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$s.\n .s$$$$$$$. `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n s $$$$$$$. .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n `$$$$$$$$$$. .$$$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n `$$$$$$$$$$. s$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n $$$$$$$$$$$$e $$$ `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n .' $$$$$$$$$$7 $$$$ `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n \" `$$$$$$$$7 $$$$$ .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n $$Ss..$$$$$$$7 $$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$ $$$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\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": "//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//\n\nconst fi='';\n fo='';\nvar f:text;\n n,i,kq,j:longint;\n a:array[1..100000]of longint;\n b:array[1..100000]of boolean;\nfunction snt(g:longint):boolean;\nvar i:longint;\nbegin\n if g<2 then exit(false);\n for i:=2 to trunc(sqrt(g)) do\n if g mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n assign(f,fi); reset(f);\n readln(f,n); kq:=0;\n fillchar(b,sizeof(b),false);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\n assign(f,fo); rewrite(f);\n for i:=1 to n do\n if(snt(a[i])=true) then\n if b[a[i]]=false then\n begin\n inc(kq);\n b[a[i]]:=true;\n end\n else\n else\n for j:=2 to trunc(sqrt(a[i])) do\n if a[i] mod j=0 then\n if (b[j]=false) and (b[a[i] div j]=false) then\n begin\n b[j]:=true;\n inc(kq);\n break;\n end\n else break;\n writeln(f,kq);\n close(f);\nend.\n\n\n\n\n//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//\n{ ..sSs$$$$$$b.\n .$$$$$$$$$$$$$$$.\n .$$$$$$$$$$$$$$$$$$$$$b.\n .$$$$$$$$$$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$$$$$$S' `$$$$\n $$$$$$$$$$$$$$S' $$$\n $$$$$$$$$$$$$' `$$.\n `$$$$$$$$$$$$$ `$$$.\n `$$$$$$$$$' .s$$$ $$ $\n $$$$$$$$$.sSs .s$$s\" s s\n $$$$$$$$$$$$ $P\n `$$$$$$$$$$$s $\n $$$$$$$$$$$. \",\n `$$$$$$$$$$sS$\n s$$$. `$$$$$$$$$$$$.s\"' .$.\n $$$$$. `$$$$$$$$$$. .$$$Ss.s$s.\n $$$$$. `$$$$$$$$$P .$$$$$$$$$$$$.\n $$$$$$. `$$$$$$$' .$$$$$$$$$$$$$$$$.\n `$$$$$$. $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$s.\n $$$$$$. `$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$s.\n .s$$$$$$$. `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n s $$$$$$$. .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n `$$$$$$$$$$. .$$$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n `$$$$$$$$$$. s$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.\n $$$$$$$$$$$$e $$$ `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n .' $$$$$$$$$$7 $$$$ `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n \" `$$$$$$$$7 $$$$$ .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n $$Ss..$$$$$$$7 $$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$ $$$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\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": "type mang=array[1..10000] of byte;\nvar dem,n,i,j,a1,k:shortint;\n prime,a:mang;\nprocedure qsort(d,c:longint; var a:mang);\nvar i,j:longint;\n tam,k:int64;\nbegin\n if(d>c) then exit;\n i:=d;\n j:=c;\n k:=a[(i+j) div 2];\n repeat\n while (a[i]k) do j:=j-1;\n if (i<=j) then\n begin\n tam:=a[i];\n a[i]:= a[j];\n a[j]:=tam;\n i:=i+1;\n j:=j-1;\n end;\n until i>j;\n if(d0 then\n begin\n for j := i+1 to n do if a[j] mod a[i]=0 then a[j]:=0;\n end;\n for i := 1 to n do if a[i]<>0 then inc(dem);\n writeln(dem);\n readln;\nend.\n"}, {"source_code": "var dem,n,i,a,t2,t3,t5,t7:shortint;\nbegin\n readln(n); \n for i := 1 to n do \n begin\n readln(a);\n if {(a mod 2 = 0) or }(((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)\n else if (a mod 3=0) and (a mod 2<>0) then inc(t3)\n else if (a mod 5=0) and (a mod 2<>0) then inc(t5)\n else if (a mod 7=0) and (a mod 2<>0) then inc(t7)\n end;\n if t2<>0 then t2 := t2 div t2;\n if t3<>0 then t3 := t3 div t3;\n if t5<>0 then t5 := t5 div t5;\n if t7<>0 then t7 := t7 div t7;\n writeln(t2+t3+t5+t7);\n readln;\nend."}, {"source_code": "var dem,n,i,snt,a,t2,t3,t5,t7:shortint;\nbegin\n snt := 2;\n readln(n); \n for i := 1 to n do \n begin\n readln(a);\n if ((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0)) then inc(t2)\n else if (a mod 3=0) and (a mod 2<>0) then inc(t3)\n else if (a mod 5=0) and (a mod 2<>0) then inc(t5)\n else if (a mod 7=0) and (a mod 2<>0) then inc(t7)\n end;\n if t2<>0 then t2 := t2 div t2;\n if t3<>0 then t3 := t3 div t3;\n if t5<>0 then t5 := t5 div t5;\n if t7<>0 then t7 := t7 div t7;\n writeln(t2+t3+t5+t7);\n readln;\nend."}, {"source_code": "var dem,n,i,a,t2,t3,t5,t7:shortint;\nbegin\n readln(n); \n for i := 1 to n do \n begin\n read(a);\n if {(a mod 2 = 0) or }(((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)\n else if (a mod 3=0) and (a mod 2<>0) then inc(t3)\n else if (a mod 5=0) and (a mod 2<>0) then inc(t5)\n else if (a mod 7=0) and (a mod 2<>0) then inc(t7)\n end;\n if t2<>0 then t2 := t2 div t2;\n if t3<>0 then t3 := t3 div t3;\n if t5<>0 then t5 := t5 div t5;\n if t7<>0 then t7 := t7 div t7;\n writeln(t2+t3+t5+t7);\n readln;\nend."}, {"source_code": "var dem,n,i,snt,a,t2,t3,t5,t7:shortint;\nbegin\n snt := 2;\n readln(n); \n for i := 1 to n do \n begin\n read(a);\n if (a mod 2 = 0) or (((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)\n else if (a mod 3=0) and (a mod 2<>0) then inc(t3)\n else if (a mod 5=0) and (a mod 2<>0) then inc(t5)\n else if (a mod 7=0) and (a mod 2<>0) then inc(t7)\n end;\n if t2<>0 then t2 := t2 div t2;\n if t3<>0 then t3 := t3 div t3;\n if t5<>0 then t5 := t5 div t5;\n if t7<>0 then t7 := t7 div t7;\n writeln(t2+t3+t5+t7);\n readln;\nend."}, {"source_code": "Var i,n,j,kq,ktc:Longint;\nA:array[1..100]of Longint;\nkt:array[1..100]of Boolean;\n\nProcedure Pt;\nBegin\nj:=2;\nWhile A[i] > 1 do\n Begin\n If A[i] mod j = 0 then\n Begin\n Kt[j]:=True;\n While A[i] mod j = 0 do\n A[i]:=A[i] div j;\n End;\n Inc(j);\n End;\nEnd;\n\nBegin\nReadln(n);\nFor i:=1 to n do \n Begin\n Read(A[i]);\n If A[i]=1 then \n Begin\n Ktc:=1;\n Break;\n End else\n Pt;\n End;\nkq:=0;\nIf ktc=1 then Writeln('1') else\nbegin\nFor i:=1 to n do\nIf kt[i]=true then inc(kq);\nWriteln(kq);\nEnd;\nEnd."}, {"source_code": "Var i,n,j,kq,ktc:Longint;\nA:array[1..100]of Longint;\nkt:array[1..100]of Boolean;\n\nProcedure Pt;\nBegin\nj:=2;\nWhile A[i] > 1 do\n Begin\n If A[i] mod j = 0 then\n Begin\n Kt[j]:=True;\n While A[i] mod j = 0 do\n A[i]:=A[i] div j;\n End;\n Inc(j);\n End;\nEnd;\n\nBegin\nReadln(n);\nIf n = 1 then \nbegin\nRead(A[i]);\nWriteln('1');\nEnd else\nBegin\nFor i:=1 to n do \n Begin\n Read(A[i]);\n If A[i]=1 then \n Begin\n Ktc:=1;\n Break;\n End else\n Pt;\n End;\nkq:=0;\nIf ktc=1 then Writeln('1') else\nbegin\nFor i:=1 to n do\nIf kt[i]=true then inc(kq);\nWriteln(kq);\nEnd;\nEnd;\nEnd."}, {"source_code": "Var i,n,j,kq,ktc:Longint;\nA:array[1..100]of Longint;\nkt:array[1..100]of Boolean;\n\nProcedure Pt;\nBegin\nj:=2;\nWhile A[i] > 1 do\n Begin\n If A[i] mod j = 0 then\n Begin\n Kt[j]:=True;\n While A[i] mod j = 0 do\n A[i]:=A[i] div j;\n End;\n Inc(j);\n End;\nEnd;\n\nBegin\nReadln(n);\nFor i:=1 to n do \n Begin\n Read(A[i]);\n If A[i]=1 then \n Begin\n Ktc:=1;\n Break;\n End else\n Pt;\n End;\nkq:=1;\nIf ktc=1 then Writeln(kq) else\nbegin\nFor i:=1 to n do\nIf kt[i]=true then inc(kq);\nWriteln(kq);\nEnd;\nEnd."}, {"source_code": "Var i,n,j,kq:Longint;\nA:array[1..100]of Longint;\nkt:array[1..100]of Boolean;\n\nProcedure Pt;\nBegin\nj:=2;\nWhile A[i] > 1 do\n Begin\n While A[i] mod j = 0 do\n Begin\n Kt[j]:=true;\n A[i]:=A[i] div j;\n End;\n Inc(j);\n End;\nEnd;\n\nBegin\nReadln(n);\nFor i:=1 to n do \n Begin\n Read(A[i]);\n Pt;\n End;\nkq:=0;\nFor i:=1 to n do\nIf kt[i]=true then inc(kq);\nWriteln(kq);\nEnd."}, {"source_code": "type mang = array [1..100] of longint;\nvar i,n,j,t,d:longint;\n a,b:mang;\n\nprocedure qsort(var a : mang);\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]>x do\n inc(i);\n while x>a[j] do\n dec(j);\n if not(i>j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l1 do\n begin\n sr:=(r+l) div 2;\n v:=0; p:=0; k:=n; i:=0;\n while k>0 do\n begin\n if k>=sr then begin\n k:=k-sr;\n v:=v+sr;\n end\n else begin\n v:=v+k;\n k:=0;\n end;\n begin\n k:=k - k div 10;\n p:=p+k div 10;\n end;\n end;\n if v >= x then r:=sr\n else l:=sr;\n\n end;\n writeln(r);\nend.\n", "positive_code": [{"source_code": "var\n l, r, m: int64;\n\nvar\n i, j, k, n, poel: int64;\n\nvar\n min: int64;\n\nbegin\n readln(n);\n if (n mod 2 = 0) then min := n div 2 else min := n div 2 + 1;\n \n l := 0;\n r := n div 2 + 1;\n \n while (l+1 < r) {and (poel <> min)} do\n begin\n k := n;\n poel := 0;\n m := (l + r) div 2;\n \n while (k > 0) do\n begin\n if (k >= m) then \n begin\n k := k - m;\n poel += m;\n end else \n begin\n poel += k;\n k := 0;\n end;\n k := k - k div 10;\n end;\n \n if (poel >= min) then r := m else l := m ;\n end;\n\n writeln(r);\nend."}, {"source_code": "var n,t,w,mid,b:int64;\nfunction pd(x:int64):boolean;\nvar m,y,z:int64;\nbegin\nm:=n;y:=0;z:=0;\nwhile m>0 do\n begin\n if m=10 then z:=z+m div 10;\n m:=m-m div 10;\n end;\nexit(y>=(n+1) div 2);\nend;\nbegin\n//assign(input,'tg.in');reset(input);\n//assign(output,'tg.out');rewrite(output);\nreadln(n);\nt:=1;w:=n;\nwhile t<=w do\n begin\n mid:=(t+w) div 2;\n if pd(mid) then\n begin\n w:=mid-1;\n b:=mid;\n end\n else t:=mid+1;\n end;\nwriteln(b);\nclose(input);close(output);\nend.\n"}, {"source_code": "var\n n , l , r , mid , a , b , x : int64 ;\nbegin\n readln( n ) ;\n l := 0 ; r := n ;\n while l + 1 < r do\n begin\n mid := ( l + r ) div 2 ;\n a := 0 ; b := 0 ; x := n ;\n while x > 0 do\n begin\n if x > mid then \n begin\n a := a + mid ;\n x := x - mid ;\n end \n else\n begin\n a := a + x ;\n x := 0 ;\n end ;\n b := b + x div 10 ;\n x := x - x div 10 ;\n end ;\n if a >= b then r := mid \n else l := mid ;\n end ;\n writeln( r ) ;\nend."}, {"source_code": "uses math;\nvar n,l,r,ans,k:int64;\nfunction check(k,n: int64): boolean;\nvar sum,cur,o: int64;\nbegin\n sum:=0; cur:=n;\n while cur>0 do begin\n o:=min(cur,k);\n sum:=sum+o;\n cur:=cur-o;\n cur:=cur-cur div 10;\n end;\n if sum*2>=n then exit(true)\n else exit(false);\nend;\n\nbegin\n readln(n);\n l:=1; r:=n;\n ans:=r;\n while l<=r do begin\n k:=(l+r) div 2;\n if check(k,n) then begin\n ans:=k;\n r:=k-1;\n end\n else l:=k+1;\n end;\n writeln(ans);\nend."}, {"source_code": "program Eclair;\n\nfunction f(n, k: Int64): Boolean;\n\nvar\n s, n_orig: Int64;\n\nbegin\n n_orig := n;\n s := 0;\n\n while n >= k do begin\n n := n - k;\n n := n - n div 10;\n Inc (s, k)\n end;\n\n Inc (s, n);\n\n f := s * 2 >= n_orig\nend;\n\n\nvar\n n, k: Int64;\n l, r, m: Int64;\n\nbegin\n ReadLn (n);\n\n l := 0;\n r := n + 1;\n\n while l + 1 < r do begin\n m := (l + r) div 2;\n\n if f(n, m) then\n r := m\n else\n l := m\n end;\n\n WriteLn (r)\nend."}, {"source_code": "var n,k : int64;\n\nfunction test(k:int64) : boolean;\nvar\n i,s,sv: int64;\nbegin\n s:=n;\n sv:=0;\n while s>0 do\n begin\n if s>=k\n then begin\n sv:=sv+k;\n s:=s-k;\n end\n else begin\n sv:=sv+s;\n s:=0;\n end;\n s:=s-s div 10;\n end;\n if 2*sv>=n then test:=true\n else test:=false;\nend;\n\nprocedure find(l,r:int64);\nbegin\n if l=r then k:=l\n else\n begin\n k:=(l+r) div 2;\n if test(k) then find(l,k)\n else find(k+1,r);\n end;\nend;\n\nbegin\n read(n);\n find(1,n);\n write(k);\nend.\n"}, {"source_code": "program c;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,n2,k,kl,kr,s,l:int64;\nbegin\nreadln(n);\nkl:=1;\nkr:=n;\nrepeat\n k:=(kl+kr) div 2;\n //writeln(kl, ' ', k, ' ', kr);\n s:=0;\n n2:=n;\n repeat\n n2:=n2-k;\n s:=s + n2 div 10;\n n2:= n2 - (n2 div 10);\n until ((n2<=0) or(2*s>n));\n if (2*s<=n) then\n kr:=k\n else\n kl:=k;\n until (kr-kl<=1);\n s:=0;\n n2:=n;\n repeat\n n2:=n2-kl;\n s:=s + n2 div 10;\n n2:= n2 - (n2 div 10);\n until ((n2<=0) or(2*s>n));\nif (2*s<=n) then\nwrite(kl)\nelse\nwrite(kr);\nend.\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=600000;\n modul=1000000007;\n besk=8000000000000000000;\n label 1,2,3,4;\n type real=extended; double=extended;\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var prod,ll,rr,posx,posy,gr,n,dloch,newdl,oldn,oldm,pos1,pos2,ost,ot,aa,bb,cc,p1,p2,p3,p4,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,m,smin,cen:int64;\n ot1,ot2,k,i1,j1,step1, step, i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n oldpos,finot,vv,znak:int64;\n px,py,xc,yc,xxc,yyc:extended;\n pos:array[-1..500001,-1..50] of longint;\n next,prev,x,y,xx,yy,str,kol,s,time,name,d,dnew, voltay,l,r,c,z,day,b,a:array[-300000..1600000] of int64;\n zz:array[0..125000000] of byte;\n pole:array[-10..1002,-10..1005] of char;\n ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1101,-10..1010] of int64;\n marked,zanx,zany:array[-10..2000000] of boolean;\n sss1,sss2:string;\n stepen,koled,def,mindef,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n right,left,numleft,numright,dr: array [-1..60,-1..60,-1..110] of int64;\n s2,s1:array[-100..200000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[-10..nn] of string;\n tx,ty,vel,x1,y1,ott,v0,v1,s0,t0:int64;\n zv:point;\n ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0 do\n begin\n ot:=ot+min(kk,pp);\n pp:=pp- min(kk,pp);\n pp:=pp-(pp div 10);\n\n end;\n kkol:=ot;\n\nend;\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\n{function prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n }\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(p);\n { for i:=1 to 10 do begin aa:=i; writeln(i,' ',kkol(aa*1000000000)); end;\n } aa:=1; bb:=p; cc:=aa;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if 2*kkol(cc)>p then bb:=cc else aa:=cc;\n\n\n end;\n { writeln(cc);\n }\n cc:=max(cc-3,0);\n repeat inc(cc) until 2*kkol(cc)>=p;\n\n writeln(cc);\n\n 1: close(output);\nend.\n\n"}, {"source_code": "Var n,i,k,s,j,l,r,ans,v,p,sr,x : Int64;\nbegin\n Readln(n);\n l:=0;\n r:=n;\n if n=1 then begin\n writeln(1);\n halt;\n end;\n ans:=1000000000000000000;\n x:= n div 2 + n mod 2;\n while r-l>1 do\n begin\n sr:=(r+l) div 2;\n v:=0; p:=0; k:=n; i:=0;\n while k>0 do\n begin\n if k>=sr then begin\n k:=k-sr;\n v:=v+sr;\n end\n else begin\n v:=v+k;\n k:=0;\n end;\n begin\n k:=k - k div 10;\n p:=p+k div 10;\n end;\n end;\n if v >= x then begin\n if sr0 do begin\n o:=min(cur,k);\n sum:=sum+o;\n cur:=cur-o;\n cur:=cur-cur div 10;\n end;\n if sum*2>=n then exit(true)\n else exit(false);\nend;\n\nbegin\n // assign(input,fi);reset(input);\n // assign(output,fo);rewrite(output);\n readln(n);\n l:=1; r:=n;\n ans:=r;\n while l<=r do begin\n k:=(l+r) div 2;\n if check(k,n) then begin\n ans:=k;\n r:=k-1;\n end\n else l:=k+1;\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "var a,s,b,c,n,i,m,k,j,x,y,z: int64;\nbegin\n read( n);\n A:=0;B:=N;\n while b-a>1 do\n begin\n c:=(a+b)div 2;\n x:=0;y:=0;z:=n;\n while z>0 do\n begin\n If c>z then begin x:=x+z;z:=0; end else begin x:=x+c;z:=z-c;end;\n z:=z-z div 10;\n end;\n if x+x=mid do\n begin\n x:=x-mid;s:=s+mid;x:=x-x div 10;\n end;\n s:=s+x;\n if s>=(n+1) div 2 then\n begin\n bao:=mid;w:=mid-1;\n end\n else t:=mid+1;\n end;\nwriteln(bao);\nclose(input);close(output);\nend.\n"}], "negative_code": [{"source_code": "program c;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,n2,k,kl,kr,s,l:int64;\nbegin\nreadln(n);\nkl:=1;\nkr:=n;\nrepeat\n k:=(kl+kr) div 2;\n s:=0;\n n2:=n;\n repeat\n n2:=n2-k;\n s:=s + n2 div 10;\n n2:= n2 - (n2 div 10);\n until ((n2<=0) or(2*s>n));\n if (2*s<=n) then\n kr:=k\n else\n kl:=k;\n until (kr-kl<=1);\nwrite(kr);\nend.\n"}, {"source_code": "Var n,i,k,s,j,l,r,ans,v,p,sr : Int64;\nbegin\n Readln(n);\n l:=0;\n r:=n;\n if n=1 then begin\n writeln(1);\n halt;\n end;\n ans:=1000000000000000000;\n while r-l>1 do\n begin\n sr:=(r+l) div 2;\n v:=0; p:=0; k:=n; i:=0;\n while k>0 do\n begin\n if k>=sr then begin\n k:=k-sr;\n v:=v+sr;\n end\n else begin\n v:=v+k;\n k:=0;\n end;\n begin\n k:=k - k div 10;\n p:=p+k div 10;\n end;\n end;\n if v >= n div 2 then begin\n if sr1 do\n begin\n sr:=(r+l) div 2;\n v:=0; p:=0; k:=n; i:=0;\n while k>0 do\n begin\n inc(i);\n if i mod 2 <> 0 then begin\n if k>=sr then begin\n k:=k-sr;\n v:=v+sr;\n end\n else begin\n v:=v+k;\n k:=0;\n end;\n end\n else begin\n k:=k - k div 10;\n p:=p+k div 10;\n end;\n end;\n if v >= n div 2 then begin\n if sr0 do begin\n o:=min(cur,k);\n sum:=sum+o;\n cur:=cur-o;\n cur:=cur-cur div 10;\n end;\n if sum*2>=n then exit(true)\n else exit(false);\nend;\n\nbegin\n // assign(input,fi);reset(input);\n // assign(output,fo);rewrite(output);\n readln(n);\n l:=1; r:=n;\n ans:=r;\n while l<=r do begin\n k:=(l+r) div 2;\n if check(k,n) then begin\n ans:=k;\n r:=k-1;\n end\n else l:=k+1;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var n,t,w,mid,bao:int64;\nfunction pd(x:int64):boolean;\nvar y,s:int64;\nbegin\ny:=n;s:=0;\nif x=0 then exit(false);\nwhile true do\n begin\n if y=n div 2 then exit(true);\nexit(false);\nend;\nbegin\n//assign(input,'tg.in');reset(input);\n//assign(output,'tg.out');rewrite(output);\nreadln(n);t:=0;w:=n;\nwhile t<=w do\n begin\n mid:=(t+w) div 2;\n if pd(mid) then begin bao:=mid;w:=mid-1;end\n else t:=mid+1;\n end;\nwriteln(bao);\nclose(input);close(output);\nend."}, {"source_code": "var n,t,w,x,y,z,mid:int64;\nfunction min(x,y:int64):int64;\nbegin\nif x>y then exit(y);\nexit(x);\nend;\nbegin\n//assign(input,'tg.in'); reset(input);\n//assign(output,'tg.out'); rewrite(output);\nreadln(n);\nt:=1;w:=n;\nwhile t<=w do\n begin\n mid:=(t+w) div 2;x:=n;y:=0;\n while x>0 do\n begin\n y:=y+min(mid,x);x:=x-min(mid,x);\n if x>10 then x:=x-x div 10;\n end;\n if y>n div 2 then\n begin\n z:=mid;w:=mid-1;\n end\n else t:=mid+1;\n end;\nwriteln(z);\nclose(input);close(output);\nend."}, {"source_code": "var n,t,w,mid,b:int64;\nfunction pd(x:int64):boolean;\nvar m,y,z:int64;\nbegin\nm:=n;y:=0;z:=0;\nwhile m>0 do\n begin\n if m=10 then z:=z+m div 10;\n m:=m-m div 10;\n end;\nexit(y>=n div 2);\nend;\nbegin\n//assign(input,'tg.in');reset(input);\n//assign(output,'tg.out');rewrite(output);\nreadln(n);\nt:=1;w:=n;\nwhile t<=w do\n begin\n mid:=(t+w) div 2;\n if pd(mid) then\n begin\n w:=mid-1;\n b:=mid;\n end\n else t:=mid+1;\n end;\nwriteln(b);\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,t,w,mid,s,x,bao:int64;\nbegin\n//assign(input,'tg.in');reset(input);\n//assign(output,'tg.out');rewrite(output);\nreadln(n);\nt:=1;w:=n;\nwhile t<=w do\n begin\n mid:=(t+w) div 2;s:=0;x:=n;\n while x>=mid do\n begin\n x:=x-mid;s:=s+mid;x:=x-x div 10;\n end;\n s:=s+x;\n if s>=n div 2 then\n begin\n bao:=mid;w:=mid-1;\n end\n else t:=mid+1;\n end;\nwriteln(bao);\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,t,w,s,x,o,z:int64;\nfunction min(x,y:int64):int64;\nbegin\nif x>y then exit(y);\nexit(x);\nend;\nbegin\n//assign(input,'tg.in');reset(input);\n//assign(output,'tg.out');rewrite(output);\nreadln(n);\nt:=1;w:=n;\nwhile t<=w do\n begin\n o:=(t+w) div 2;s:=n;x:=0;\n while s>0 do\n begin\n x:=x+min(o,s);s:=s-min(o,s);\n if s>10 then s:=s-s div 10;\n end;\n if x>=n div 2 then\n begin\n z:=o;w:=o-1;\n end\n else t:=o+1;\n end;\nwriteln(z);\nclose(input);close(output);\nend.\n"}, {"source_code": "program c;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,n2,k,s:int64;\nbegin\nreadln(n);\nk:=n div 20;\nrepeat\n inc(k);\n s:=0;\n n2:=n;\n repeat\n n2:=n2-k;\n s:=s + n2 div 10;\n n2:= n2 - (n2 div 10);\n until ((n2<=0) or(2*s>n));\n until (2*s<=n);\nwrite(k);\nend.\n"}, {"source_code": "program c;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,n2,k,s:int64;\nbegin\nreadln(n);\nk:=n div 30;\nrepeat\n inc(k);\n s:=0;\n n2:=n;\n repeat\n n2:=n2-k;\n s:=s + n2 div 10;\n n2:= n2 - (n2 div 10);\n until ((n2<=0) or(2*s>n));\n until (2*s<=n);\nwrite(k);\nend.\n"}], "src_uid": "db1a50da538fa82038f8db6104d2ab93"} {"source_code": "var\n n,mh,i : longint;\n ans,ret : int64;\n was : array [1..35,1..35,0..37,0..1] of boolean;\n mem : array [1..35,1..35,0..37,0..1] of int64;\n\n function f(l,r,h,lab : longint) : int64;\n var\n res,r1,r2,r3,r4 : int64;\n i : longint;\n begin\n if h < 0 then exit(0);\n if (h = 0) and (l <> r) then exit(0);\n if (l=r) then\n begin\n if (lab = 0) and (h > 0) then exit(1);\n if (lab = 1) and (h = 0) then exit(1);\n exit(0);\n end;\n if was[l][r][h][lab] then exit(mem[l][r][h][lab]);\n was[l][r][h][lab]:=true;\n res:=0;\n inc(res,f(l+1,r,h-1,lab));\n inc(res,f(l,r-1,h-1,lab));\n for i:=l+1 to r-1 do\n begin\n if lab = 1 then\n begin\n r1:=f(l,i-1,h-1,1);\n r3:=f(l,i-1,h-1,0);\n r2:=f(i+1,r,h-1,1);\n r4:=f(i+1,r,h-1,0);\n inc(res,r1*r4);\n inc(res,r2*r3);\n inc(res,r1*r2);\n end else\n begin\n r1:=f(l,i-1,h-1,0);\n r2:=f(i+1,r,h-1,0);\n inc(res,r1*r2);\n end;\n end;\n mem[l][r][h][lab]:=res;\n exit(res);\n end;\n\nbegin\n// assign(input,'1.in'); reset(input);\n // assign(output,'1.out'); rewrite(output);\n readln(n,mh);\n for i:=mh to 37 do\n begin\n ret:=f(1,n,i-1,1);\n inc(ans,ret);\n end;\n writeln(ans);\nend.\n", "positive_code": [{"source_code": "{$R+Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n dp:Array[0..50,0..50] of Int64;\n n,h,i,j:Integer;\n ans:Int64;\nFunction Solve(n,h:Integer):Int64;\nVar v,h1,h2,k1,k2:Integer;\nBegin\n If dp[n,h]<>-1 Then Begin\n Solve:=dp[n,h];\n Exit;\n End;\n If n=1 Then Begin\n If h=1 Then dp[n,h]:=1\n Else dp[n,h]:=0;\n Solve:=dp[n,h];\n Exit;\n End;\n If h=0 Then Begin\n dp[n,h]:=0;\n Solve:=dp[n,h];\n Exit;\n End;\n dp[n,h]:=0;\n For v:=1 To n Do Begin\n k1:=v-1;\n k2:=n-v;\n If v=1 Then Begin\n dp[n,h]:=dp[n,h]+Solve(n-1,h-1);\n Continue;\n End;\n If v=n Then Begin\n dp[n,h]:=dp[n,h]+Solve(n-1,h-1);\n Continue;\n End;\n For h1:=0 To min(k1,h-2) Do dp[n,h]:=dp[n,h]+Solve(k1,h1)*Solve(k2,h-1);\n For h2:=0 To min(k2,h-2) Do dp[n,h]:=dp[n,h]+Solve(k1,h-1)*Solve(k2,h2);\n dp[n,h]:=dp[n,h]+Solve(k1,h-1)*Solve(k2,h-1);\n End;\n Solve:=dp[n,h];\nEnd;\nBegin\n Read(n,h);\n For i:=0 To 50 Do\n For j:=0 To 50 Do dp[i,j]:=-1;\n ans:=0;\n For i:=h To n Do ans:=ans+Solve(n,i);\n Write(ans);\nEnd."}, {"source_code": "program D9;\n\n{$APPTYPE CONSOLE}\n\n{$R+}\n\nuses\n SysUtils,\n Math;\n\nvar d: array[0..35, 0..35]of int64;\n\nfunction dp(n, h: longint): int64;\n var i, k: longint;\n a1, a2, tmp: int64;\nbegin\n if d[n, h] = -1 then\n begin\n d[n, h] := 0;\n for i := h - 1 to n - 1 do\n for k := 0 to min(n - 1 - i, h - 1) do\n if not((k = h - 1)and(i < n - i - 1))then\n begin\n a1 := dp(i, h - 1);\n a2 := dp(n - i - 1, k);\n if (i = n - i - 1)and(k = h - 1)then\n begin\n tmp := a1 * a2;\n d[n, h] := d[n, h] + tmp;\n end\n else d[n, h] := d[n, h] + 2 * a1 * a2;\n end;\n end;\n result := d[n, h];\nend;\n\nvar n, h: longint;\n\nfunction solve: int64;\n var i, j: longint;\nbegin\n for i := 0 to n do\n for j := 0 to n do\n d[i, j] := -1;\n for i := 0 to 5 do\n for j := 1 shl i to n do\n d[j, i] := 0;\n d[0, 0] := 1;\n for i := 0 to n do\n for j := i + 1 to n do\n d[i, j] := 0;\n result := 0;\n for i := h to n do\n result := result + dp(n, i);\nend;\n\nbegin\n//reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, h);\n writeln(solve);\n readln; readln;\nend.\n "}, {"source_code": "USES MATH;\nCONST\n fin='';\n fon='';\nVAR\n n,h: LONGINT;\n f: array[0..40,0..40] of INT64;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nPROCEDURE CHUONG_TRINH;\n VAR\n kq: INT64;\n i,hi,j,l,r: LONGINT;\n BEGIN\n readln(n,h);\n FILLCHAR(f,SIZEOF(f),0);\n f[0,0]:=1;\n for i:=1 to n do\n for hi:=1 to i do\n for j:=0 to i-1 do\n for l:=0 to j do\n for r:=0 to i-l-1 do\n begin\n if MAX(r,l)=hi-1 then\n begin\n f[i,hi]:=f[i,hi]+\n f[j,l]*f[i-j-1,r];\n end;\n end;\n kq:=0;\n for i:=h to n do kq:=kq+f[n,i];\n writeln(kq);\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n CHUONG_TRINH;\n KET_THUC;\nEND."}, {"source_code": "var res:array[1..35,1..100,1..100]of qword;\n a:array[1..35,1..35]of qword;\n n,k,i,j,t,v,u:longint;\n kq:qword;\nfunction max(a,b:longint):longint;\nbegin\nif a>b then max:=a else max:=b;\nend;\nbegin\nreadln(n,k);\nres[1,1,1]:=1;\na[1,1]:=1;\nfor i:=2 to n do\n begin\n for j:=1 to n do\n for t:=1 to j do\n begin\n inc(res[i,j+1,1],res[i-1,j,t]);\n inc(res[i,max(j,t+1),t+1],res[i-1,j,t]);\n end;\n for j:=i-2 downto 1 do\n for t:=1 to n do\n for u:=1 to t do\n for v:=1 to n do\n inc(res[i,max(t,u+v+1),u+1],res[j,t,u]*a[i-1-j,v]);\n for j:=1 to n do\n for t:=1 to n do\n a[i,j]:=a[i,j]+res[i,j,t];\n end;\nfor i:=k to n do kq:=kq+a[n,i];\nwriteln(kq);\nend.\n"}, {"source_code": "program D_trees_1;\n//{$DEFINE D}\n{$APPTYPE CONSOLE}\n{$O-,R+,Q+}\nuses\n SysUtils, Math;\n\nvar\n i, n, h: integer;\n start: extended;\n ans: array [0..100,0..100] of int64;\n res: int64;\n\nfunction f(n, h: integer): int64;\nvar\n i: integer;\n hl, hr: integer;\nbegin\n if ans[n, h] > -1 then\n begin\n result := ans[n, h];\n exit\n end;\n if h > n then\n begin\n result := 0;\n ans[n, h] := 0;\n exit\n end; //}\n result := 0;\n for i := 0 to n - 1 do\n for hl := 0 to h - 1 do\n for hr := 0 to h - 1 do\n if max(hl, hr) = h - 1 then\n result := result + f(i, hl)*f(n - i - 1, hr);\n ans[n, h] := result\nend;\n\n\nbegin\n{$IFDEF D}\n reset(input,'in');\n rewrite(output,'out');\n{$ENDIF}\n start := now;\n read(n, h);\n\n fillchar(ans, sizeof(ans), 255);\n fillchar(ans[0], sizeof(ans[0]), 0);\n ans[0][0] := 1;\n ans[1, 1] := 1;\n\n res := 0;\n for i := h to n do res := res + f(n, i);\n writeln(res)\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O-}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5) + 200;\nmd = round(1e9) + 7;\nvar\nn,h,i,j,k,root : longint;\ndp : array [0..55,0..55] of int64;\nans : int64;\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n randomize;\n readln(n,h);\n fillchar(dp,sizeof(dp),0);\n dp[0][0]:=1;\n for i:=1 to n do\n for j:=1 to n do\n for root:=1 to i do\n begin\n for k:=0 to j - 1 do dp[i][j]:=(dp[i][j] + dp[root - 1][j - 1] * dp[i - root][k]);\n for k:=0 to j - 2 do dp[i][j]:=(dp[i][j] + dp[root - 1][k] * dp[i - root][j - 1]);\n end;\n ans:=0;\n for i:=h to n do ans:=(ans + dp[n][i]);\n writeln(ans);\nend.\n\n"}, {"source_code": "{$M 10000000,0,10000000}\nvar i,j,l,n,h:longint;\na:array[0..40,0..40,0..40,0..1]of int64;\n\nfunction run(l,r,hi,st:longint):int64;\nvar tmp:int64;\ni:longint;\n begin\n if (a[l,r,hi,st]<>-1) then\n begin\n run:=a[l,r,hi,st];\n exit;\n end;\n\n if (l=r)and(((hi>=h)and(st=1))or(st=0)) then\n begin\n run:=1;\n exit\n end;\n\n if (l=r) then\n begin\n run:=0;\n exit;\n end;\n\n tmp:=0;\n for i:=l+1 to r-1 do\n begin\n if st=1 then\n begin\n tmp:=tmp+run(l,i-1,hi+1,0)*run(i+1,r,hi+1,1);\n tmp:=tmp+run(l,i-1,hi+1,1)*run(i+1,r,hi+1,0);\n tmp:=tmp-run(l,i-1,hi+1,1)*run(i+1,r,hi+1,1);\n end\n else\n tmp:=tmp+run(l,i-1,hi+1,0)*run(i+1,r,hi+1,0);\n end;\n\n tmp:=tmp+run(l,r-1,hi+1,st) + run(l+1,r,hi+1,st);\n\n a[l,r,hi,st]:=tmp;\n\n run:=tmp;\n end;\n\n begin\n read(n,h);\n\n for i:=0 to n do\n for j:=0 to n do\n for l:=0 to n do\n begin\n a[i,j,l,0]:=-1;\n a[i,j,l,1]:=-1;\n end;\n\n writeln(run(1,n,1,1));\n end.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 38;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n n, h, ans: int64;\n a: array[0..maxn,0..maxn] of int64;\n\nfunction calc(n, h: int64): int64;\nvar\n i, j: int;\n d, l, r, ls, rs: int64;\nbegin\n if (a[n, h] <> - 1) then begin\n result := a[n, h];\n exit;\n end;\n\n if (n = 0) or (h = 0) then begin\n result := 0;\n exit;\n end;\n\n d := 0;\n for i := 1 to n do begin\n l := calc(i - 1, h - 1);\n rs := 0;\n if (l > 0) then\n for j := 0 to h - 1 do\n rs := rs + calc(n - i, j);\n r := calc(n - i, h - 1);\n ls := 0;\n if (r > 0) then\n for j := 0 to h - 1 do\n ls := ls + calc(i - 1, j);\n\n d := d - r*l + l*rs + ls*r;\n end;\n\n a[n, h] := d;\n result := d;\nend;\n\nprocedure run;\nvar\n i: int;\nbegin\n fillchar(a, sizeof(a), -1);\n a[0, 0] := 1;\n \n read(n, h);\n\n ans := 0;\n\n for i := h to n do\n ans := ans + calc(n, i);\n\n write(ans); \nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "var i,j,l,n,h:longint;\na:array[0..40,0..40,0..40,0..1] of int64;\n\nfunction work(l,r,z,kind:longint):int64;\nvar i:longint;\nx:int64;\nbegin\nif (a[l,r,z,kind]<>-1) then exit(a[l,r,z,kind]);\nif (l=r) then\nif ((z>=h) and (kind=1)) or (kind=0) then exit(1) else exit(0);\n\nx:=0;\nfor i:=l+1 to r-1 do\nbegin\nif kind=1 then\nbegin\ninc(x,work(l,i-1,z+1,0)*work(i+1,r,z+1,1));\ninc(x,work(l,i-1,z+1,1)*work(i+1,r,z+1,0));\ndec(x,work(l,i-1,z+1,1)*work(i+1,r,z+1,1));\nend\nelse inc(x,work(l,i-1,z+1,0)*work(i+1,r,z+1,0));\nend;\n\ninc(x,work(l,r-1,z+1,kind)+work(l+1,r,z+1,kind));\n\na[l,r,z,kind]:=x;\nexit(x);\nend;\n\nbegin\nread(n,h);\n\nfor i:=0 to n do for j:=0 to n do for l:=0 to n do\nbegin\na[i,j,l,0]:=-1;a[i,j,l,1]:=-1;\nend;\n\nwriteln(work(1,n,1,1));\nend.\n"}, {"source_code": "var\n n :longint;\n h :longint;\n f :array[0..110,0..110] of int64;\n i,j,k,l :longint;\n ans :int64;\nbegin\n read(n,h);\n f[0,0]:=1;\n for i:=1 to n do\n begin\n for j:=1 to n do\n begin\n for k:=0 to i-1 do\n begin\n for l:=0 to j-2 do f[i,j]:=f[i,j]+2*f[k,j-1]*f[i-k-1,l];\n end;\n for k:=0 to i-1 do\n begin\n f[i,j]:=f[i,j]+f[k,j-1]*f[i-k-1,j-1];\n end;\n end;\n end;\n for i:=h to n do\n begin\n ans:=ans+f[n,i];\n end;\n writeln(ans);\nend."}, {"source_code": "program D;\nvar a:array[0..35,0..35] of qword;\n i,j,k,l,n,h:longint;\n s:qword;\nbegin\n// assign(input,'D.in');reset(input);\n// assign(output,'D.out');rewrite(output);\n readln(n,h);\n fillchar(a,sizeof(a),0);a[1,1]:=1;a[0,0]:=1;\n for i:=2 to n do\n for j:=1 to i do\n for k:=0 to i-1 do\n begin\n for l:=0 to j-1 do inc(a[i,j],a[k,l]*a[i-k-1,j-1]);\n for l:=0 to j-2 do inc(a[i,j],a[i-k-1,l]*a[k,j-1]);\n end;\n s:=0;for i:=h to n do inc(s,a[n,i]);\n writeln(s);\n// close(input);close(output);\nend.\n"}, {"source_code": "{$M 10000000,0,10000000}\nvar i,j,l,n,h:longint;\na:array[0..40,0..40,0..40,0..1]of int64;\n\nfunction run(l,r,hi,st:longint):int64;\nvar tmp:int64;\ni:longint;\n begin\n if (a[l,r,hi,st]<>-1) then\n begin\n run:=a[l,r,hi,st];\n exit;\n end;\n\n if (l=r)and(((hi>=h)and(st=1))or(st=0)) then\n begin\n run:=1;\n exit\n end;\n\n if (l=r) then\n begin\n run:=0;\n exit;\n end;\n\n tmp:=0;\n for i:=l+1 to r-1 do\n begin\n if st=1 then\n begin\n tmp:=tmp+run(l,i-1,hi+1,0)*run(i+1,r,hi+1,1);\n tmp:=tmp+run(l,i-1,hi+1,1)*run(i+1,r,hi+1,0);\n tmp:=tmp-run(l,i-1,hi+1,1)*run(i+1,r,hi+1,1);\n end\n else\n tmp:=tmp+run(l,i-1,hi+1,0)*run(i+1,r,hi+1,0);\n end;\n\n tmp:=tmp+run(l,r-1,hi+1,st) + run(l+1,r,hi+1,st);\n\n a[l,r,hi,st]:=tmp;\n\n run:=tmp;\n end;\n\n begin\n read(n,h);\n\n for i:=0 to n do\n for j:=0 to n do\n for l:=0 to n do\n begin\n a[i,j,l,0]:=-1;\n a[i,j,l,1]:=-1;\n end;\n\n writeln(run(1,n,1,1));\n end.\n"}, {"source_code": "var\n i,j,k,h:longint;\n m,n:int64;\n f:array[0..40,0..40]of int64;\nbegin\n readln(n,h);\n for i:=0 to n do\n f[0,i]:=1;\n for i:=1 to n do\n for j:=1 to n do\n for k:=0 to j-1 do\n f[j,i]:=f[j,i]+f[k,i-1]*f[j-k-1,i-1];\n\n writeln(f[n,n]-f[n,h-1]);\nend."}, {"source_code": "var\n\tn,m,i,j,k\t\t\t\t\t\t\t\t:longint;\n\tf\t\t\t\t\t\t\t\t\t\t:array[0..50,0..50] of int64;\nbegin\n\tread(n,m);\n\tfor i:=0 to n do f[0,i]:=1;\n\tfor i:=1 to n do\n\tfor j:=1 to n do\n\tfor k:=0 to i-1 do\n\t\tf[i,j]:=f[i,j]+f[k,j-1]*f[i-k-1,j-1];\n\twriteln(f[n,n]-f[n,m-1]);\nend."}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n res : int64;\n n, h, qn, qh, i, j : longint;\n f : array [0..40, 0..40] of int64;\n\nbegin\n read(n, h);\n fillchar(f, sizeof(f), $0);\n f[0][0] := 1;\n f[1][1] := 1;\n for qh:=2 to n do\n for qn:=2 to n do begin\n for i:=0 to qn-1 do\n for j:=0 to qh-1 do\n f[qn][qh] := f[qn][qh] + f[i][j] * f[qn-i-1][qh-1];\n for i:=0 to qn-1 do\n for j:=0 to qh-2 do\n f[qn][qh] := f[qn][qh] + f[i][j] * f[qn-i-1][qh-1];\n end;\n res := 0;\n for i:=h to n do inc(res, f[n][i]);\n writeln(res);\nend.\n"}, {"source_code": " var\n f:array[0..35,0..35]of int64;\n n,h,i,j,k,l:longint;\n s,t:int64;\n\n function min(a,b:int64):int64;\n begin\n if a 0 do\n begin\n y := y*2;\n x := x-y;\n inc(k);\n end;\n exit(k);\n End;\n\nBegin\n read(n,h);\n //////\n f[0,0] := 1;\n f[1,1] := 1;\n ///////\n for i := 2 to n do\n for j := minh(i) to n do\n begin\n for k := 0 to i-1 do\n begin\n for l := 0 to j-2 do\n f[i,j] := f[i,j] + f[k,j-1]*f[i-1-k,l] + f[k,l]*f[i-1-k,j-1];\n f[i,j] := f[i,j] + f[k,j-1]*f[i-1-k,j-1];\n end;\n\n end;\n /////\n kq := 0;\n for i := h to n do\n kq := kq + f[n,i];\n writeln(kq);\nEnd.\n"}, {"source_code": "uses math;\nvar n,h:longint;\n a:array[0..39,0..39]of int64;\n res:int64;\n\nprocedure qhd;\nvar i,j,k,t,l:longint;\nbegin\n a[0,0]:=1;\n for i:=1 to n do\n for j:=1 to i do\n for k:=0 to i-1 do\n for t:=0 to min(k,j-1) do\n for l:=0 to min(i-k-1,j-1) do\n if (t=j-1) or (l=j-1) then\n a[i,j]:=a[i,j] + a[k,t]*a[i-k-1,l];\nend;\n\nprocedure demkq;\nvar i:longint;\nbegin\n res:=0;\n for i:=h to n do res:=res+a[n,i];\nend;\n\nbegin\n readln(n,h);\n qhd;\n demkq;\n writeln(res);\nend."}, {"source_code": "uses math;\nvar n,h:longint;\n a:array[0..40,0..40]of int64;\n res:int64;\n\nprocedure qhd;\nvar i,j,k,t,l:longint;\nbegin\n a[0,0]:=1;\n for i:=1 to n do\n for j:=1 to i do\n for k:=0 to i-1 do\n for t:=0 to min(k,j-1) do\n for l:=0 to min(i-k-1,j-1) do\n if (t=j-1) or (l=j-1) then\n a[i,j]:=a[i,j] + a[k,t]*a[i-k-1,l];\nend;\n\nprocedure demkq;\nvar i:longint;\nbegin\n res:=0;\n for i:=h to n do res:=res+a[n,i];\nend;\n\nbegin\n readln(n,h);\n qhd;\n demkq;\n writeln(res);\nend."}, {"source_code": "var\n i,j,k,q,l:longint;\n ans:int64;\n f:array[0..100,0..100] of int64;\n n,h:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a>b then exit(b);\n exit(a);\nend;\n\nbegin\n readln(n,h);\n f[0,0]:=1;\n for i:=1 to n do\n for j:=1 to i do\n for k:=0 to i-1 do\n for q:=0 to min(k,j-1) do\n for l:=0 to min(i-k-1,j-1) do\n if (q=j-1) or (l=j-1) then\n f[i,j]:=f[i,j]+f[k,q]*f[i-k-1,l];\n for i:=h to n do\n ans:=ans+f[n,i];\n writeln(ans);\nend.\n"}, {"source_code": "var i,j,n,m,k,s,l:longint;\no:int64;\nf:Array[0..100,0..100,0..100] of int64;\nfunction aaa(x,y:longint):int64;\nvar s1:int64;\ni1,j1,cnt:longint;\nbegin\n cnt:=0;\n if x>y then exit(0);\n s1:=1;\n for i1:=x+1 to y do begin\n s1:=s1*i1;\n inc(cnt);\n s1:=s1 div cnt;end;\n exit(s1);\nend;\nbegin\n readln(n,m);\n f[1,1,1]:=1;\n for j:=1 to n do\n begin\n for k:=1 to n do\n for l:=1 to n do\n for i:=1 to n do\n f[i+l,j+1,l]:=f[i+l,j+1,l]+aaa(l,2*k)*f[i,j,k];\n end;\n o:=0;\n for i:=1 to n do\n for j:=m to n do\n o:=o+f[n,j,i];\n writeln(o);\nend.\n"}, {"source_code": "var\n f:array[0..1001,0..1001] of int64;\n i,j,k,n,h:longint;\nbegin\n readln(n,h);\n for i:=0 to n do f[0,i]:=1;\n for i:=1 to n do\n for j:=1 to n do\n for k:=0 to i-1 do\n f[i,j]:=f[i,j]+f[k,j-1]*f[i-k-1,j-1];\n writeln(f[n,n]-f[n,h-1]);\nend."}, {"source_code": "var f:array[0..35,0..35] of int64;\n k,l,i,j,n,m:longint;\n ans:int64;\n begin\n readln(n,m);\n f[0][0]:=1;\n for i:=1 to n do\n for j:=1 to i do\n for k:=1 to n do\n begin\n for l:=0 to j-1 do inc(f[i][j],f[k-1][j-1]*f[i-k][l]);\n for l:=0 to j-2 do inc(f[i][j],f[i-k][j-1]*f[k-1][l]);\n end;\n for i:=m to n do inc(ans,f[n][i]);\n writeln(ans);\n end.\n"}, {"source_code": "uses math;\nconst\n nmax = 100;\nvar\n n,h:longint;\n res:qword;\n f:array[0..35,0..35] of qword;\nprocedure progress;\nvar i,j,u,v,t:longint;\nbegin\n read(n,h);\n f[0][0]:=1;\n f[1][1]:=1;\n for i:=2 to n do for j:=1 to i do\n for u:=0 to i-1 do for t:=0 to j-1 do\n begin\n f[i][j]:=f[i][j]+f[u][j-1]*f[i-1-u][t];\n if t-1) then\n begin\n run:=a[l,r,hi];\n exit;\n end;\n\n if (l=r)and(hi>=h) then\n begin\n a[l,r,hi]:=1;\n run:=1;\n exit\n end;\n\n if (l=r) then\n begin\n run:=0;\n exit;\n end;\n\n tmp:=0;\n for i:=l+1 to r-1 do\n tmp:=tmp+run(l,i-1,hi+1)*run(i+1,r,hi+1);\n\n tmp:=tmp+run(l,r-1,hi+1) + run(l+1,r,hi+1);\n\n a[l,r,hi]:=tmp;\n\n run:=tmp;\n end;\n\n begin\n read(n,h);\n\n for i:=0 to n do\n for j:=0 to n do\n for l:=0 to n do\n a[i,j,l]:=-1;\n\n writeln(run(1,n,1));\n end.\n"}, {"source_code": "{$M 10000000,0,10000000}\nvar i,j,l,n,h:longint;\na:array[0..40,0..40,0..40]of int64;\nfunction run(l,r,hi:longint):int64;\nvar tmp:int64;\ni:longint;\n begin\n if (a[l,r,hi]<>-1) then\n begin\n run:=a[l,r,hi];\n exit;\n end;\n\n if (l=r)and(hi>=h) then\n begin\n a[l,r,hi]:=1;\n run:=1;\n exit\n end;\n\n if (l=r) then\n begin\n run:=0;\n exit;\n end;\n\n tmp:=0;\n for i:=l+1 to r-1 do\n tmp:=tmp+run(l,i-1,hi+1)*run(i+1,r,hi+1);\n\n tmp:=tmp+run(l,r-1,hi+1) + run(l+1,r,hi+1);\n\n a[l,r,hi]:=tmp;\n\n run:=tmp;\n end;\n\n begin\n read(n,h);\n\n for i:=0 to n do\n for j:=0 to n do\n for l:=0 to n do\n a[i,j,l]:=-1;\n\n writeln(run(1,n,1));\n end.\n"}, {"source_code": "uses math;\nvar i,j,n,m,k,o,s:longint;\na:array[0..100,0..100] of longint;\nbegin\n readln(n,m);\n for i:=0 to n do\n a[0,i]:=1;\n for i:=1 to n do\n for j:=1 to n do\n for k:=0 to j-1 do\n a[j,i]:=a[j,i]+a[k,i-1]*a[j-k-1,i-1];\n writeln(a[n,n]-a[n,m-1]);\nend."}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n res : int64;\n n, h, qn, qh, i, j : longint;\n f : array [0..40, 0..40] of int64;\n\nbegin\n read(n, h);\n fillchar(f, sizeof(f), $0);\n f[0][0] := 1;\n f[1][1] := 1;\n for qh:=2 to n do\n for qn:=2 to n do begin\n for i:=0 to qn-1 do\n for j:=0 to qn-1 do begin\n f[qn][qh] := f[qn][qh] + 2*f[i][j] * f[qn-i-1][qh-1];\n if (i = qn-i-1) and (j = qh-1)\n then dec(f[qn][qh], f[i][j] * f[qn-i-1][qh-1]);\n end;\n\n end;\n res := 0;\n for i:=h to n do inc(res, f[n][i]);\n writeln(res);\nend.\n"}, {"source_code": " var\n f:array[0..35,0..35]of int64;\n n,h,i,j,k:longint;\n t:int64;\n\n begin\n readln(n,h);\n for i:=0 to n do f[0,i]:=1;\n for i:=1 to n do\n for j:=1 to i do\n begin\n t:=0;\n for k:=0 to i-1 do inc(t,f[k,j-1]*f[i-k-1,j-1]);\n f[i,j]:=t;\n end;\n t:=0;\n for i:=h to n do inc(t,f[n,i]);\n writeln(t);\n end.\n"}, {"source_code": "Program LL;\nVar\n f:array[0..1000,0..1000] of longint;\n\ti,j,k,m,n:longint;\n\tans,tot,sum:int64;\nBegin\n\t\treadln(n,m);\n\t\tfor i:=0 to n do \n\t\tbegin \n\t\t f[0,i]:=1;\n\t\tend;\n\t\tfor k:=1 to n do\n\t\t for i:=1 to n do\n\t\t begin\n\t\t f[i,k]:=0;\n\t\t\t for j:=0 to i-1 do \n\t\t\t f[i,k]:=f[i,k]+f[j,k-1]*f[i-j-1,k-1];\n\t\t end;\n\t\twriteln(f[n,n]-f[n,m-1]);\nEnd."}, {"source_code": "Const\n fi = '';\n fo = '';\n MaxN = 40;\n\nType Arr1 = Array[0..MaxN+1,0..MaxN+1] Of Qword;\n\nVar f : Arr1;\n n, h, i, j, k, l : Longint;\n kq : Qword;\n\nBegin\n read(n,h);\n //////\n f[0,0] := 1;\n f[1,1] := 1;\n ///////\n for i := 2 to n do\n for j := 1 to n do\n begin\n for k := 0 to i-1 do\n for l := 0 to j-1 do\n f[i,j] := f[i,j] + f[k,j-1]*f[i-1-k,l] + f[k,l]*f[i-1-k,j-1];\n if (i-1)mod 2 = 0 then\n f[i,j] := f[i,j] - f[(i-1)div 2,j-1]*f[(i-1)div 2,j-1];\n end;\n /////\n kq := 0;\n for i := h to n do\n kq := kq + f[n,i];\n writeln(kq);\nEnd.\n"}, {"source_code": "var\n a,b,f,w,p:array[0..5001]of longint;\n n,tot,i,k,j,pp,ans:longint;\n\nprocedure sort(l,r:longint);\nvar i,j,m1,m2,t:longint;\nbegin\n i:=l; j:=r; m1:=a[(l+r)shr 1]; m2:=b[(l+r)shr 1];\n repeat\n while (a[i]m2) do inc(i);\n while (m1b[j]) do dec(j);\n if i<=j then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n t:=b[i]; b[i]:=b[j]; b[j]:=t;\n t:=w[i]; w[i]:=w[j]; w[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[0])or(a[i]=a[0])and(b[i]b[j] then\n begin\n if f[j]+1>f[i] then\n begin\n f[i]:=f[j]+1;\n p[i]:=j;\n end;\n if f[i]>ans then\n begin\n ans:=f[i];\n pp:=i;\n end;\n end;\n if ans>0 then\n begin\n writeln(ans);\n while pp<>k do\n begin\n inc(tot);\n a[tot]:=w[pp];\n pp:=p[pp];\n end;\n for i:=tot downto 2 do\n write(a[i],' ');\n writeln(a[1]);\n end\n else writeln(0);\nend.\n\n"}, {"source_code": "var i,j,n,m,k,s,l:longint;\no:int64;\nf:Array[0..100,0..100,0..100] of int64;\nfunction aaa(x,y:longint):int64;\nvar s1:int64;\ni1,j1:longint;\nbegin\n if x>y then exit(0);\n s1:=1;\n for i1:=x+1 to y do\n s1:=s1*i1;\n for i1:=2 to (y-x) do\n s1:=s1 div i1;\n exit(s1);\nend;\nbegin\n readln(n,m);\n f[1,1,1]:=1;\n for j:=1 to n do\n begin\n for k:=1 to n do\n for l:=1 to n do\n for i:=1 to n do\n f[i+l,j+1,l]:=f[i+l,j+1,l]+aaa(l,2*k)*f[i,j,k];\n end;\n o:=0;\n for i:=1 to n do\n for j:=m to n do\n o:=o+f[n,j,i];\n writeln(o);\nend."}, {"source_code": "var i,j,n,m,k,s,l:longint;\no:int64;\nf:Array[0..100,0..100,0..100] of int64;\nfunction aaa(x,y:longint):int64;\nvar s1:int64;\ni1,j1:longint;\nbegin\n s1:=1;\n for i1:=x+1 to y do\n s1:=s1*i1;\n for i1:=2 to (y-x) do\n s1:=s1 div i1;\n exit(s1);\nend;\nbegin\n readln(n,m);\n f[1,1,1]:=1;\n for j:=1 to n do\n begin\n for i:=1 to n do\n for k:=1 to n do\n for l:=1 to n do\n f[i+l,j+1,l]:=f[i+l,j+1,l]+aaa(l,2*k)*f[i,j,k];\n end;\n o:=0;\n for i:=1 to n do\n for j:=m to n do\n o:=o+f[n,j,i];\n writeln(o);\nend."}, {"source_code": "var i,j,n,m,k,s,l:longint;\no:int64;\nf:Array[0..100,0..100,0..100] of int64;\nfunction aaa(x,y:longint):int64;\nvar s1:int64;\ni1,j1:longint;\nbegin\n s1:=1;\n for i1:=x+1 to y do\n s1:=s1*i1;\n for i1:=2 to (y-x) do\n s1:=s1 div i1;\n exit(s1);\nend;\nbegin\n readln(n,m);\n f[1,1,1]:=1;\n for j:=1 to n do\n begin\n for k:=1 to n do\n for l:=1 to n do\n for i:=1 to n do\n f[i+l,j+1,l]:=f[i+l,j+1,l]+aaa(l,2*k)*f[i,j,k];\n end;\n o:=0;\n for i:=1 to n do\n for j:=m to n do\n o:=o+f[n,j,i];\n writeln(o);\nend."}, {"source_code": "var\n f:array[0..1001,0..1001] of longint;\n i,j,k,n,h:longint;\nbegin\n readln(n,h);\n for i:=0 to n do f[0,i]:=1;\n for i:=1 to n do\n for j:=1 to n do\n for k:=0 to i-1 do\n f[i,j]:=f[i,j]+f[k,j-1]*f[i-k-1,j-1];\n writeln(f[n,n]-f[n,h-1]);\nend."}, {"source_code": "uses math;\nconst\n nmax = 100;\nvar\n n,h:longint;\n res:qword;\n f:array[0..35,0..35] of qword;\nprocedure progress;\nvar i,j,u,v,t:longint;\nbegin\n read(n,h);\n f[0][0]:=1;\n f[1][1]:=1;\n for i:=2 to n do for j:=1 to h do\n for u:=0 to i-1 do for t:=0 to j-1 do\n begin\n f[i][j]:=f[i][j]+f[u][j-1]*f[i-1-u][t];\n if t - 1) then begin\n result := a[n, h];\n exit;\n end;\n\n if (h > n) then begin\n a[n, h] := 0;\n result := 0;\n exit;\n end;\n\n if (n = 0) then begin\n a[n, h] := 1;\n result := 1;\n exit;\n end;\n\n d := 0;\n for i := 1 to n do begin\n l := calc(i - 1, h - 1);\n rs := 0;\n if (l > 0) then\n for j := 0 to h do\n rs := rs + calc(n - i, j);\n r := calc(n - i, h - 1);\n ls := 0;\n if (r > 0) then\n for j := 0 to h do\n ls := ls + calc(i - 1, j);\n\n d := d - r*l + l*rs + ls*r;\n end;\n\n a[n, h] := d;\n result := d;\nend;\n\nprocedure run;\nbegin\n fillchar(a, sizeof(a), -1);\n read(n, h);\n\n write(calc(n, h));\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 38;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n n, h: int64;\n a: array[0..maxn,0..maxn] of int64;\n\nfunction calc(n, h: int64): int64;\nvar\n i, j: int;\n d, l, r, ls, rs: int64;\nbegin\n if (a[n, h] <> - 1) then begin\n result := a[n, h];\n exit;\n end;\n\n if (n = 0) or (h = 0) then begin\n result := 0;\n exit;\n end;\n\n d := 0;\n for i := 1 to n do begin\n l := calc(i - 1, h - 1);\n rs := 0;\n if (l > 0) then\n for j := 0 to h do\n rs := rs + calc(n - i, j);\n r := calc(n - i, h - 1);\n ls := 0;\n if (r > 0) then\n for j := 0 to h do\n ls := ls + calc(i - 1, j);\n\n d := d - r*l + l*rs + ls*r;\n end;\n\n a[n, h] := d;\n result := d;\nend;\n\nprocedure run;\nbegin\n fillchar(a, sizeof(a), -1);\n a[0, 0] := 1;\n \n read(n, h);\n\n write(calc(n, h));\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}], "src_uid": "faf12a603d0c27f8be6bf6b02531a931"} {"source_code": "var i,j,n,m,k,o,s:longint;\nbegin\n readln(n,m,k);\n for i:=m to n-1 do\n for j:=k downto 0 do\n if i+j+1=n then inc(o);\n writeln(o);\nend.", "positive_code": [{"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n st:string;\n n:longint;\n a:array[1..100000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction insection(l1,r1,l2,r2:longint):longint;\n var i,res:longint;\n begin\n res:=0;\n for i:=1 to max(r1,r2) do\n if (i>=l1) and (i<=r1) and (i>=l2) and (i<=r2) then inc(res);\n exit(res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var n,a,b,l1,r1,l2,r2:longint;\n begin\n read(fi,n,a,b);\n l1:=a+1;\n r1:=n;\n l2:=n-b;\n r2:=n;\n writeln(fo,insection(l1,r1,l2,r2));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var i,j,n,m,k,o,s:longint;\nbegin\n readln(n,m,k);\n for i:=m to n-1 do\n for j:=k downto 0 do\n if i+j+1=n then inc(o);\n writeln(o);\nend."}, {"source_code": "uses math;\nvar n,a,b:int64;\nbegin\n readln(n,a,b);\n writeln(min(n-a,b+1));\nend."}, {"source_code": "var\n n,y,x:longint;\nbegin\n readln(n,x,y);\n if n-x<=y+1 then writeln(n-x)\n else\n writeln(y+1);\nend."}, {"source_code": "uses math;\nvar n,a,b:longint;\nbegin\n read(n,a,b);\n write(min(n-a,b+1));\nend."}, {"source_code": "var\n n,a,b,pas:longint;\nbegin\n readln(n,a,b);\n a:=a+1;\n while (a<=n) do\n begin\n if n-a<=b then\n begin\n pas:=pas+1;\n a:=a+1;\n end else\n a:=a+1;\n end;\n writeln(pas);\nend.\n"}, {"source_code": "uses math;\nvar\n n,a,b:longint;\nbegin\n read(n,a,b);\n writeln(min(n-a,b+1));\nend."}, {"source_code": "var\nn,a,b,s:longint;\nbegin\nread(n,a,b);\ns:=a+1;\nif n-b>s then s:=n-b;\nwrite(n-s+1); end."}, {"source_code": "var\na,b,n,w,r:int64;\nbegin\nread(n,a,b);\nw:=n-a;\nr:=b+1;\nif w>r then write(r)\nelse write(w);\nend."}, {"source_code": "var\nn,a,b,x:longint;\nbegin\nread(n,a,b);\nif n-a<=b+1 then writeln(n-a)\nelse\nwriteln(b+1);\nend."}, {"source_code": "uses math;\nvar a,n,b:longint;\nbegin\n readln(n,a,b);\n writeln(n-max(a+1,n-b)+1);\nend."}, {"source_code": "var n,a,b:longint;\nbegin\nreadln(n,a,b);\n\nif n-a>b then\nwriteln(b+1) else writeln(n-a);\nend."}, {"source_code": "program sher;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n,a,b:integer;\nbegin\nread(n);\nread(a,b);\nif (n-a)>(b+1) then\nbegin\nwriteln(b+1);\n//readln(b);\nend\nelse\nwriteln(n-a);\n//readln(a);\nend.\n "}, {"source_code": "var l,r,a,b,n,s:longint;\nbegin\nread(n,a,b);\ns:=0;\nfor a:=a to n-1 do\nif ((n-a-1)<=b) then inc(s);\nwrite(s);\nend."}, {"source_code": "\n var n,a,b,i,dem:longint; \nbegin\n readln(n,a,b);\n for i:=a+1 to n do\n if n-i<=b then inc(dem);\n writeln(dem);\nend. "}, {"source_code": "uses math;\nvar\n n,a,b,i,s:longint;\n begin\n readln(n,a,b);\n writeln(min(n-a,b+1));\n end."}, {"source_code": "uses\nSySUtils,math;\nvar n,a,b:integer;\nbegin\n readln(n,a,b);\n if a+b=n then begin writeln(b);halt;end;\n if a+bn then begin writeln(n-a);halt;end;\nend."}, {"source_code": "var n,i,a,b,res:longint;\nbegin\n res:=0;\n readln(n,a,b);\n for i:=1 to n do\n if (i>a)and(i+b>=n) then inc(res);\n writeln(res);\n halt(0);\nend."}, {"source_code": "//Yerzhan Dyussenaliyev\nUses Math, SysUtils;\nconst\n dx: array [1..4] of longint = (0, 0, -1, 1);\n dy: array [1..4] of longint = (1, -1, 0, 0);\ntype\n\trec = record\n\t\ta, b: longint;\n\tend;\nvar\n\tn, a, b, ans, i: longint;\n\nbegin\n\t{$ifndef online_judge}\n\t\treset(input, 'a.in');\n\t\trewrite(output, 'a.out');\n\t{$endif}\n\n\tread(n, a, b);\n\tans := 0;\n\tfor i := a + 1 to n do\n\t\tif i + b >= n then inc(ans);\n\twriteln(ans);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nFunction Max(a,b:Integer):Integer;\nBegin\n If a>b Then Max:=a\n Else Max:=b;\nEnd;\nVar\n n,a,b:Integer;\nBegin\n Read(n,a,b);\n Write(n-Max(a,n-b-1));\nEnd.\n"}, {"source_code": "var\n n,a,b:longint;\nbegin\n readln(n,a,b);\n if n-a>b+1 then writeln(b+1)\n else writeln(n-a);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n//type\n//T = array [1..110] of Integer;\n\nvar\nn,a,b,res:longint;\n//cc:char;\n\nbegin\n//reset(input,'input.txt'); rewrite(output,'output.txt');\nRead(n,a,b);\nif (a+1)>(n-b) then res:=n-a\n else res:=b+1;\nWriteln(res);\nend.\n"}, {"source_code": "uses math;\nvar\n n,a,b,i,s:longint;\nbegin\n read(n,a,b);\n write(min(n-a,b+1));\nend."}, {"source_code": "var n,a,b:LongInt;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(n,a,b);\n if (n-a)>(b+1)\n then Writeln(b+1)\n else Writeln(n-a);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\n\nvar i,n,k,j,ans:integer;\n\n\n\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(n,k,j);\n ans:=0;\n for i:=1 to n do begin\n if (i-1>=k) and (n-i<=j) then inc(ans);\n end;\n write(ans);\nend.\n\n"}, {"source_code": "program Project_124_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,a,b:Integer;\nbegin\nread(n,a,b);\nif((b+1)<(n-a)) then write(b+1) else write(n-a);\nread(b);\nend.\n"}, {"source_code": "Var a,b,c:LongInt;\nBegin\n Readln (c,a,b);\n c:=c-a;\n If c>b\n then Writeln (b+1)\n else Write (c);\nEnd."}, {"source_code": "program zadacha124a;\nvar a,b,n,x:longint;\nbegin\nread(n,a,b);\nx:=n-a;\nif x-1>b then write(b+1)\nelse write(x);\nend."}, {"source_code": "program zadacha3;\nvar a,b,n,x:longint;\nbegin\nread(n,a,b);\nx:=n-a;\nif x-1>b then write(b+1)\nelse write(x);\nend."}, {"source_code": "var n,a,b:integer;\nfunction max(a,b:longint):longint;\nbegin\n if a > b then exit(a)\n else exit(b);\nend;\nbegin\n readln(n,a,b);\n writeln(n-max(a+1,n-b)+1);\n readln;\nend."}, {"source_code": "uses math;\n var n,a,b,q1,q2:longint;\n begin\n read(n,a,b);\n\n q1:=n-a;\n q2:=b+1;\n writeln(min(q1,q2));\n end."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar\n n, a, b : integer;\n\nbegin\n readln(n, a, b);\n writeln(n - max(a + 1, n - b) + 1);\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n m,n,a,b:integer;\n i,j,k:integer;\nbegin\n readln(n,a,b);\n k:=0;\n for i:=1 to n do \n if ((n-i)<=b)and((i-1)>=a) then inc(k);\n write(k);\n readln;\n readln;\n readln;\nend."}, {"source_code": "var i,a,b,n,ans:integer;\nbegin\nreadln(n,a,b);\nif ((a+1+b)>n) then b:=n-(a+1);\nwrite(b+1);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}{$o-}{$r+}\n\nuses\n SysUtils, Math;\n\nvar\n n, a, b, i, ans : integer;\nbegin\n readln(n, a, b);\n for i := a + 1 to n do\n begin\n if n - i <= b then\n inc(ans);\n end;\n write(ans);\nend.\n\n\n"}, {"source_code": "program qwe;\n{$APPTYPE CONSOLE}\nvar\n a, b, n: Integer;\nbegin\n read(n, a, b);\n if (a + b) < n then write(b + 1) else write(n - a);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, a, b, k : integer;\n\nbegin\n readln(n, a, b);\n if (1 + a > n - b) then k := 1 + a\n else k := n - b;\n writeln(n - k + 1);\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+}\n\nuses\n SysUtils;\n\nvar n,a,b,k:Integer;\n\nbegin\n read(n,a,b);\n k:=n-a;\n if k>b+1 then k:=b+1;\n write(k);\n Readln;\n Readln;\nend."}, {"source_code": "var a,b,i,n,j:longint;\n begin\n read (n,a,b);\n for i:=1 to n do\n if (i-1>=a) and (n-i<=b) then inc (j);\n write (j);\nend."}, {"source_code": "var\nn,a,b:longint;\nbegin\nreadln(n,a,b);\nif n-a (b + 1) then writeln(b+1)\n else writeln(n-a)\nend.\n"}, {"source_code": "Program pos;\nVar a,b,n:Integer;\nBegin\n read(n); \n read(a);\n read(b);\n n:=n-a;\n if n>b\n then n:=n-(n-b)+1;\n writeln(n);\nEnd."}, {"source_code": "Uses Math;\nvar\n n,a,b\t:\tlongint;\nbegin\n//\treset(input, 'a.in');\trewrite(output, 'a.out');\n\t read(n,a,b);\n\t write(n - (a + (n - min(n,a + 1 + b))));\nend."}, {"source_code": "program fuuu;\n\n{$APPTYPE CONSOLE}\n\n\nuses\n SysUtils,\n Math;\nvar\n i, n, m, l, k: longint;\n\n\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output);\n }read(n, m, k);\n for i :=1 to n do\n if (i>m)and(i>=(n-k)) then inc(l);\n writeln(l);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n i,n,j:Integer;\n g,k:Int64;\n a,b:array[1..1000000] of Integer;\nbegin\n Readln(n,i,j);\n if (i+1>n-j) then write(n-i)\n else write(j+1);\n Readln;\n Readln;\nend.\n "}, {"source_code": "var\nn,a,b:shortint;\n\n\n\nBegin\n read(n);read(a);read(b);\n if n-a>=b+1 then write(b+1) else write(n-a);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n i,n,j:Integer;\n g,k:Int64;\n a,b:array[1..1000000] of Integer;\nbegin\n Readln(n,i,j);\n if (i+1>n-j) then write(n-i)\n else write(j+1);\n Readln;\n Readln;\nend.\n "}, {"source_code": "var n, a, b: longint;\nbegin\n read(n, a, b);\n if n - a >= b + 1 then writeln(b + 1 ) else\n writeln(n - a);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math, SysUtils;\n\nvar\n a, b, n: longint;\nbegin {\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n }\n readln(n, a, b);\n if a >= n then writeln(0) else writeln(min(n - a, b + 1));\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n,a,b:longint;\nfunction min(a,b:longint):longint;\nbegin\n if ab then writeln(b+1)\n else writeln(n);\n\n//readln;\nend.\n"}, {"source_code": "program z1;\nvar n,b,a,k:integer;\nbegin\nread(n);\nread(a);\nread(b);\nk:=n-a;\nif k>b then\nk:=b+1;\nwrite(k);\nend."}, {"source_code": "var n,m,k:longint;\n begin\n read(n,m,k);\n n:=n-m;\n if n>k then n:=n-(n-(k+1));\n writeln(n);\n end."}, {"source_code": "Var A,B,N,I,Res:Longint;\n Begin\n Readln(N,A,B);\n For I:=A To N-1 Do\n If N-I-1<=B Then Inc(Res);\n Writeln(Res);\n End."}, {"source_code": "var n,a,b:integer;\nbegin\n read(n,a,b);\n if n-a=i-1) and (a<=n-i) then inc(ans);\n writeln(ans);\n end."}, {"source_code": "var\n n,a,b,k,l,m : longint;\nbegin\n read(n,a,b);\n k:=a+1; l:=n-b;\n if k>l then m:=k else m:=l;\n writeln(n-m+1);\nend."}, {"source_code": "var a,b,n,k: integer;\n\nbegin\n readln(n,a,b);\n k:=n-a;\n if k>b+1 then k:=b+1;\n writeln(k);\nend."}, {"source_code": "var n,a,b,c:integer;\nbegin\n read(n,a,b);\n c:=n-a;\n if c>b then c:=c+(-c + b) + 1;\n write(c);\nend."}, {"source_code": "program abc;\nvar n,a,b:byte;\nbegin\nread(n,a,b);\nif (a=n-b) then writeln(n-a);\nend.\n"}, {"source_code": "var \n a, b, n : integer;\nbegin\n read(n, a, b);\n if n - a > b then \n write(b + 1) \n else \n write(n - a);\nend."}, {"source_code": "Var k,i, n,a,b:longint;\nbegin\nreadln(n,a,b);\nk:=0;\nfor i:=1 to n do\nif (i>=a) and ((n-i)<=(b+1)) then k:=k+1;\nif (n=1) then writeln(1) else writeln(k-1);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n label f;\nvar n,a,b:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n REad(n,a,b);\n\n //if (n-b=1)and (a=0) then begin writeln(n);goto f;end;\n if n-a<=b then Writeln(n-a)\n else begin writeln(b+1);\n\n end;\nf: end.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar\n k,i,n,a,b,c,j,p:integer;\n s1,s2:string;\nbegin\nread(n,a,b);\nif n-b-1>a then write(n-(n-b-1)) else write(n-a);\nread(a);\nend.\n"}, {"source_code": "{$o-}\nvar\n\n i, n, a, b, ans: longint;\nbegin\n\n //reset(input, 'a.in');\n //rewrite(output,'a.out');\n\n read(n, a, b);\n\n ans := 0;\n\n For i := 1 to n do\n if (i - 1 >= a) and (n - i <= b) then inc(ans);\n write(ans);\n// close(input);\n// close(output);\nend."}, {"source_code": "uses math;\nvar n,a,b,tg:longint;\nbegin\n readln(n,a,b);\n tg:=n-b;\n writeln( n -max(tg,a+1) +1);\nend."}, {"source_code": "var n,a,b:integer;\nbegin\n readln(n,a,b);\n if a+1>n-b\n then writeln(n-a)\n else writeln(b+1)\nend."}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D+,E+,F+,G-,I+,L+,N+,O-,R+,Q+,S+,V+,X+}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n// base = 1000000009;\n// eps = 1e-9;\n\nvar\n n, m, i, j, res, a, b: integer;\n s: string;\n ok: boolean;\n\n\nprocedure panic(dxp: integer);\nbegin\n write(dxp);\n halt(0);\nend;\n\nprocedure panics(kws: string);\nbegin\n write(kws);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nprocedure swap64(var qx1, qy1: int64);\nvar\n qz1: int64;\nbegin\n qz1 := qx1;\n qx1 := qy1;\n qy1 := qz1;\nend;\n\nprocedure swapex(var qx2, qy2: extended);\nvar\n qz2: extended;\nbegin\n qz2 := qx2;\n qx2 := qy2;\n qy2 := qz2;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n readln(n, a, b);\n write(min(n - a, b + 1));\n\n\nend.\n"}, {"source_code": "{const fi='checking1.inp';\n fo='checking1.out'; }\nvar n,a,b,p:longint;\n{-----------------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend; }\n{-----------------------------------}\n{procedure closefiles;\nbegin\n close(input);\n close(output);\nend;}\n{------------------------------------------------}\nprocedure stdin;\nbegin\n read(n,a,b);\nend;\n{-------------------------------------}\nprocedure process;\nbegin\n if (n-a-b)>0 then writeln(b+1)\n else writeln(b-abs(n-a-b));\nend;\n{----------------------------------------------}\nBEGIN\n { openfiles; }\n stdin;\n process;\n { closefiles;}\nEND.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,a,b,i,res:integer;\n //s:string;\n //a:array[1..10000] of integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n ReadLn(n,a,b);\n res:=0;\n for i:=1 to n do\n if (i-1<=b) and ((n-i)>=a) then inc(res);\n WriteLn(res);\nend.\n "}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\nvar\n n,l,a,b,r: integer;\nbegin\n read(n,l,r);\n a:=l;\n b:=n-r;\n if a>=b then write(n-l) else write(r+1);\nend."}, {"source_code": "Program TheNumberOfPositions;\nvar n,a,b,position1,position2,result:Longint;\n bool:Boolean;\nbegin\n read(n);\n read(a);\n readln(b);\n position1:=a+1;\n position2:=position1+b;\n while bool=false do \n begin\n if position2>=n then \n begin\n result:=n-position1+1;\n bool:=true;\n end\n else if position2b then max:=a else max:=b; end;\n\nbegin\n //assign(input,'in.txt'); reset(input);\n read(n,a,b);\n a:=max(a+1,n-b);\n if a<0 then writeln(0) else writeln(n-a+1);\n\n close(input);\nend."}, {"source_code": "var a,b,c,n:longint;\nbegin\nreadln(n,a,b);\nif (n-a<=0) then begin\n writeln(0);\n halt;\n end;\n\nif (n-a-1<=b) then begin\n writeln(n-a);\n halt;\n end;\n\nif b+1<=n then writeln(b+1)\n else writeln(n);\n\n\nend."}, {"source_code": "var\n a,b,n,kol,i : longint;\nbegin\n readln(n,a,b);\n kol:=0;\n for i:=1 to n do\n if (i-a>0) and (i+b>=n) then inc(kol);\n writeln(kol);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,a,b,i,j:integer;\nbegin\n readln(n,a,b);\n i:=n-a;\n j:=b+1;\n if iB then write(b+1) else write(n-a);\n\nend."}, {"source_code": "var n,a,b,i,ans:longint;\nbegin\nreadln(n,a,b);\nans:=n-a;\nif ans-1>b then begin\n dec(ans,n-a);\n inc(ans,b+1);\nend;\nwriteln(ans);\nend.\n"}, {"source_code": "program a124;\nvar n,a,b,k,s:integer;\n\nbegin\nreadln(n,a,b);\ns:=0;\nk:=n-a;\nwhile (k>0) and (b>=0) do\nbegin\n s:=s+1;\n k:=k-1;\n b:=b-1;\n end;\n\n writeln(s);\n\nend.\n"}, {"source_code": "program z1;\nvar\n n,a,b,i,ans: longint;\nbegin\n readln(n,a,b);\n for i:=1 to n do\n if (i>a) and ((n-i)<=b) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "const finp='';\n fout='';\nvar n,a,b:longint;\n t1,t2:longint;\n fi,fo:text;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,n,a,b);\n t1:=a+1;\n t2:=n-b;\n if t1 > t2 then writeln(fo,n-t1+1)\n else writeln(fo,n-t2+1);\n close(fi);close(fo);\nend.\n"}], "negative_code": [{"source_code": "var\nn,a:longint;\nbegin\nread(n,a);\nwrite(n-a);\nend."}, {"source_code": "var\tn,a,b:longint;\nbegin\n\treadln(n,a,b);\n\tif a=b then write(n-a);\n\tif ab then write(n-a);\nend."}, {"source_code": "var i,j,k,l,n,t,a,b:longint;\n\nbegin\n\n read(n,a,b);\n\n t:=n-a;\n if t>b then t:=t-(t-b)\n else if t(b+1) then writeln(b) else writeln(n-a);\nend."}, {"source_code": "var\n n,a,b:longint;\n \nbegin\nreadln(n,a,b);\n\nwriteln(n-b);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,a,b:integer;\nbegin\n readln(n,a,b);\n writeln(n-a+abs(a-b));\nend.\n"}, {"source_code": "program zzz;\nvar\n n, a, b: byte;\nbegin\n read(n, a, b);\n if n - a <= b\n then write(n - a)\n else write(n - b);\nend."}, {"source_code": "VAr n,k,i,j,k1,a,b : longint ;\nbegin\nreadln(n,a,b) ;\nfor i:=a to n-1 do\nk:=k+1 ;\nwriteln(k) ;\nend."}, {"source_code": "var a,n:longint;\nbegin\nreadln(n,a);\nwrite(n-a);\nend."}, {"source_code": "var n,a,b: LongInt;\nbegin\n Readln(n,a,b);\n Writeln(n-a);\nend."}, {"source_code": "{ fp }\n\nvar a,b,n,ans:Longint;\n\nFunction max(x,y:longint):longint;\n begin\n if x>y then max:=x else max:=y;\n end;\n\n begin\n ans:=-1;\n ReadLn(n,a,b);\n if n-a<=b then ans:=max(ans,n-a);\n if n-b>=a then ans:=max(ans,n-b);\n Writeln(ans);\n end."}, {"source_code": "var\na,n,b:longint;\nfunction min(a,b:longint):longint;\n begin\n if ab then write(n-a) else write(b);\nend."}, {"source_code": "var\n n,a,b:integer;\n ans:integer;\nbegin\nreadln(n);\nread(a,b);\nans:=n-a;\nwriteln(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\n\n\nuses\n SysUtils;\n\nvar\n n, a, b: Integer;\n\nbegin\n {Reset(input, 'input.txt');\n Rewrite(Output, 'output.txt');}\n Readln(n, a, b);\n Writeln(b + 2 - n + a);\n {Close(input);\n Close(output);}\nend.\n "}, {"source_code": "program Project4;\n{$APPTYPE CONSOLE}\n\nvar n,a,b:integer;\nbegin\n read(n,a,b);\n if n - a - b = 0 then write(b) else write(b+1);\nend."}, {"source_code": "var\n c, k, i, m, n, minpole, maxpole, ind: longint;\n a, b: array [0..1000001] of longint;\n \nbegin\n read(n, m);\n writeln(n - m);\nend."}, {"source_code": "program zz;\nvar n,i:longint;\nfunction isLucky(x:longint):boolean;\nvar d:longint;\nbegin\n isLucky:=false;\n repeat\n d:= x mod 10;\n if ((d<>4) and (d<>7))\n then\n exit;\n until x =0;\n isLucky:=true;\nend;\nbegin\nread(n);\nfor i:=1 to (n div 2 )+1 do\n begin\n if isLucky (i)\n then if n mod i= 0\n then begin\n writeln('YES');\n exit;\n end;\n end;\nwriteln('NO');\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var n,a,b,c:integer;\nbegin\n read(n,a,b);\n c:=n-a;\n if c<>b then c:=c+(c-b);\n write(c);\nend."}, {"source_code": "var\nk : longint;\ni:longint;\na,b,n:longint;\nbegin\nread(n,a,b);\nk:=0;\nfor i := a+1 to n do\nif (i >= b) then inc(k);\nwrite(k);\nend."}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\nvar\n n,l: integer;\nbegin\n read(n,l);\n write(n-l);\nend."}, {"source_code": "uses math;\nvar n,a,b:longint;\n begin\n read(n,a,b);\n writeln((n-a)+(n-b)-2);\n end."}, {"source_code": "var n,a,b:integer;\n ans:integer;\nbegin\nreadln(n);\nread(a,b);\nans:=n-a;\nwriteln(ans);\nend."}, {"source_code": "var n,m,k:longint;\n begin\n read(n,m,k);\n n:=n-m;\n n:=n-(n-k);\n writeln(n);\n end."}, {"source_code": "program Atask;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,a,b,count,i : byte;\nbegin\n readln(n,a,b);\n\n for i:=1 to n do\n begin\n if (i>=n-a) and (i>=n-b) then inc(count);\n end;\n write(count);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "program AA;\nvar N,i,j,x,y:integer;\n A:array[1..100000] of integer;\n S:array[1..100000] of string;\nbegin\nread(n,x,y);\nwriteln(x+y-N+3);\n\nend."}, {"source_code": "var\n n,a,k1,k2,b:int64;\nbegin\n {Reset(Input,Source);\n Rewrite(output,Target);}\n read(n,a,b);\n k1:=n-a;\n k2:=n-b;\n if (a=n-1)or(b=0) then begin\n write(n);\n Halt;\n end;\n if k1>=k2 then write(n-k1+1) else write(n-k2+1);;\nend.\n"}, {"source_code": "var f1, f2: text;\n a,b,n,k: integer;\n\nbegin\n{assign(f1, 'standard input');\nreset(f1);\nassign(f2, 'standard output');\nrewrite(f2);}\nread(n,a,b);\nif n-a>=b then k:=b else k:=n-a;\nwrite(k);\n{close(f1);\nclose(f2);}\nend."}, {"source_code": "var a,n:longint;\nbegin\nreadln(n,a);\nwrite(n-a);\nend."}, {"source_code": "var n,a,b:integer;\nbegin\nread(n,a,b);\nif a>b then write(b+1)\n else write(N-A);\nend."}, {"source_code": "{ fp }\n\nUses Math;\n\nvar a,b,n,ans:Longint;\n\n begin\n ReadLn(n,a,b);\n ans:=b-a+1;\n if n-a>=b then ans:=max(n-a,ans);\n if n-b<=a then ans:=max(ans,n-b);\n Writeln(ans);\n end."}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nvar\nn,a,b : integer;\nbegin\nread (n,a,b);\nif n-a<=b then write (b)\nelse write (n-a);\nend.\n"}, {"source_code": "var a,b,s,z,n:longint;\nbegin\nreadln(n,a,b);\ns:=n-a;\nif n=9 then write(s-1)\nelse if n=14 then write(s-3)\nelse if n=22 then write(s div 2)\nelse if n=28 then write(s mod 10)\nelse if n=33 then write((s div 2)-5)\nelse if n=41 then write(s-2) \nelse write(s);\nend."}, {"source_code": "var\na,n,b:longint;\nfunction min(a,b:longint):longint;\n begin\n if a b then write(b+1) else write(n-b);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\n\n\nuses\n SysUtils,\n Math;\n\nvar\n n, a, b: Integer;\n\nbegin\n {Reset(input, 'input.txt');\n Rewrite(Output, 'output.txt'); }\n Readln(n, a, b);\n Writeln(n - max(n - b - 1, a + 1) + 1);\n {Close(input);\n Close(output);}\nend.\n "}, {"source_code": "var\n n,a,k1,k2,b:int64;\nbegin\n {Reset(Input,Source);\n Rewrite(output,Target);}\n read(n,a,b);\n\n k1:=n-a;\n k2:=n-b;\n\n if k2>=k1 then write(k2) else write(k1);\nend.\n"}, {"source_code": "var\ni,j,n,m:integer;\nbegin\nread(n,m);\nwriteln(n+1);\nend."}, {"source_code": "var\nk : longint;\ni:longint;\na,b,n:longint;\nbegin\nread(n,a,b);\nk:=0;\nfor i := a to n do\nif (i >= b) then inc(k);\nif (a=b) then write(k-1) else\nwrite(k);\nend."}, {"source_code": "var\n n,a,k1,k2,b:int64;\nbegin\n {Reset(Input,Source);\n Rewrite(output,Target);}\n read(n,a,b);\n k1:=n-a;\n k2:=n-b;\n if k1>=k2 then write(n-k1+1) else write(n-k2+1);;\nend.\n"}, {"source_code": "program positions;\nvar n, a, b, r:longint;\nBegin\n Readln(n, a, b);\n r:=n-a;\n Writeln(r);\nend."}, {"source_code": "var\na,b,c:longint;\nbegin\nread(a,b,c);\nwrite(a-b);\nend."}, {"source_code": "var a,b,s,z,n:longint;\nbegin\nreadln(n,a,b);\ns:=n-a;\nif n=9 then write(s-1)\nelse if n=14 then write(s-3)\nelse if n=22 then write(s div 2)\nelse if n=28 then write(s mod 10)\nelse if n=33 then write((s div 2)-5)\nelse if n=41 then write(s-2) \nelse if n=43 then write(s-13)\nelse write(s);\nend."}, {"source_code": "var n,a,b,k,s:integer;\nbegin\nread(n,a,b);\nk:=n-a;\ns:=n-b;\nwhile k=a then inc(ans);\n Writeln(ans);\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nVar\n n,a,b,k:integer;\nbegin\n read(n,a,b);\n k:=0;\n k:=n-a;\n write(k);\nend.\n"}, {"source_code": "program zzz;\nvar\n n, a, b: byte;\nbegin\n read(n, a, b);\n if n - a <= b\n then write(n - a)\n else write(n - b);\nend."}, {"source_code": "const finp='';\n fout='';\nvar n,a,b:longint;\n t1,t2:longint;\n fi,fo:text;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,n,a,b);\n t1:=n-a;\n t2:=n-b;\n if t1 > t2 then writeln(fo,n-t1+1)\n else writeln(fo,n-t2+1);\n close(fi);close(fo);\nend.\n"}, {"source_code": "program zz;\nvar n,i:longint;\nfunction isLucky(x:longint):boolean;\nvar d:longint;\nbegin\n isLucky:=false;\n repeat\n d:= x mod 10;\n if ((d<>4) and (d<>7))\n then\n exit;\n until x =0;\n isLucky:=true;\nend;\nbegin\nread(n);\nfor i:=1 to (n div 2 )+1 do\n begin\n if isLucky (i)\n then if n mod i= 0\n then begin\n writeln('YES');\n exit;\n end;\n end;\nwriteln('NO');\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "//Yerzhan Dyussenaliyev\nUses Math, SysUtils;\nconst\n dx: array [1..4] of longint = (0, 0, -1, 1);\n dy: array [1..4] of longint = (1, -1, 0, 0);\ntype\n\trec = record\n\t\ta, b: longint;\n\tend;\nvar\n\tn, a, b: longint;\n\nbegin\n\t{$ifndef online_judge}\n\t\treset(input, 'a.in');\n\t\trewrite(output, 'a.out');\n\t{$endif}\n\n\tread(n, a, b);\n\twriteln(n - a);\nend.\n"}, {"source_code": "program Task124A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, a, b : longint;\nbegin\n readln(n, a, b);\n writeln(n - a);\n readln;\nend.\n"}, {"source_code": "var\n a, i, j : integer;\nbegin\n read(a, i, j);\n if (a - i <= j + 1) then write(a - i) else write(j + i);\nend."}, {"source_code": "program q;\n\n{$APPTYPE CONSOLE}\nfunction max (var a, b: longint): longint;\nbegin\n if a > b then max := a else max := b;\nend;\n\nvar a, b, n, k: longint;\nbegin\n\n read(n, a, b);\n k := n - b;\n write(n - max(a, k));\nend.\n"}, {"source_code": "program abc;\nvar n,a,b:byte;\nbegin\nreadln(n);\nreadln(a);\nreadln(b);\n{if (b>=n) or (n>100) or (a>=n)or (a<=0) or (b<=0) then writeln ('NO')\nelse begin writeln ('YES'); }\nif (a=n-b) then writeln(n-a);\n{end;}\nend.\n"}, {"source_code": "var a,b,s,z,n:longint;\nbegin\nreadln(n,a,b);\ns:=n-a;\nif n=9 then write(s-1)\nelse if n=14 then write(s-3)\nelse if n=22 then write(s div 2)\nelse if n=28 then write(s mod 10)\nelse if n=33 then write((s div 2)-5)\nelse if n=41 then write(s-2) \nelse if n=47 then write(s-13)\nelse if n=52 then write(s-15)\nelse if n=59 then write(s-7)\nelse if n=65 then write(s-12)\nelse if (n=73)and(a=14) then write(s-46)\nelse if n=79 then write(s-33)\nelse write(s);\nend."}, {"source_code": "var\nk : longint;\ni:longint;\na,b,n:longint;\nbegin\nread(n,a,b);\nif a=0 then write(b) else if (b=0) then write(a) else\nwrite(n-a);\nend."}, {"source_code": "var\nn,a,b,a1,m1:integer;\nbegin\nreadln(n,a,b);\na1:=n-a;\nif (a1>b) and (b<>0) then a1:=a1-abs(b-a);\n\nwriteln(a1);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n n,a,b:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(n,a,b);\n if n-b-1a) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,a,b:Integer;\n\nbegin\nread(n,a,b);readln;\nwriteln(n-a);\n\nend.\n"}, {"source_code": "program abc;\nvar n,a,b:byte;\nbegin\nreadln(n);\nreadln(a);\nreadln(b);\n{if (b>=n) or (n>100) or (a>=n)or (a<=0) or (b<=0) then writeln ('NO')\nelse begin writeln ('YES'); }\nif (a=n-b) then writeln(n-a);\n{end;}\nend.\n"}, {"source_code": "var\nn,a,b,a1,m1:integer;\nbegin\nreadln(n,a,b);\na1:=n-a;\nif a1>b then writeln(a1-(b-a))\nelse writeln(a1);\nend."}, {"source_code": "var\nn,a,b,x:longint;\nbegin\nread(n,a,b);\nif n-a>=b+1 then writeln(n-a)\nelse\nwriteln(b+1);\nend."}, {"source_code": "const finp='';\n fout='';\nvar n,a,b:longint;\n t1,t2:longint;\n fi,fo:text;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,n,a,b);\n t1:=n-a;\n t2:=n-b;\n if t1 > t2 then writeln(fo,t1)\n else writeln(fo,t2);\n close(fi);close(fo);\nend.\n"}, {"source_code": "var n,a,b,i,k:integer;\n mas:array[1..100] of integer;\n\nbegin\n readln(n,a,b);\n if b=0 then write(n)\n else write(n-a);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,a,b:integer;\nbegin\n readln(n,a,b);\n writeln(n-a+abs(a-b));\nend.\n"}, {"source_code": "var\nk : longint;\ni:longint;\na,b,n:longint;\nbegin\nread(n,a,b);\nif a=0 then write(b);\nwrite(n-a);\nend."}, {"source_code": "program the_number_of_postion;\nvar\n a,b,n:integer;\n\nprocedure xuly;\nvar\n i,j:integer;\nbegin\n readln(n,a,b);\n a:=n-a;\n if a>=b then write(b+1) else write(b-(b-a));\nend;\n\nbegin\n xuly;\nend.\n"}, {"source_code": "var\n n,a,b,k,l,m : longint;\nbegin\n read(n,a,b);\n k:=n-a; l:=n-b;\n if k>l then m:=k else m:=l;\n writeln(n-m+1);\nend."}, {"source_code": "var n,m,k:longint;\n begin\n read(n,m,k);\n n:=n-m;\n n:=n-(n-(k+1));\n writeln(n);\n end."}, {"source_code": "Var n,a,b:longint;\nbegin\nreadln(n,a,b);\nwriteln(n-(a-1)-1);\nend."}, {"source_code": "Program abc;\nVar a,b,n,k:LongInt;\nBegin\n Readln(n,a,b);\n If a+b+1>n then k:=(a+b) DIV 2;\n If a+b+1=n then\n Begin\n If a>b then k:=a+1;\n If a= a) and (n - i <= b) then begin \n write(i);\n \t halt;\n end;\n\n// close(input);\n// close(output);\nend."}, {"source_code": "var n,a,b: LongInt;\nbegin\n Readln(n,a,b);\nif (a+b)<=n then\nbegin\n if a>=b then Writeln(n-b);\n if a0) and (b<>0) ) then\n if a+b>N then rez := abs(a-b) + 1 else\n if a+b=N then rez := b else\n if a+by then max:=x else max:=y;\n end;\n\n begin\n ans:=-1;\n ReadLn(n,a,b);\n if n-a<=b then ans:=max(ans,n-a);\n if n-b>=a then ans:=max(ans,n-b);\n Writeln(ans);\n end."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst eps=0.000000001; nnn=10000; nnnn=900;\nlabel 1,2;\ntype mas=array[0..20000] of double;\nvar a,b,diap,mmax,kolst,h,y,t,s,imin,mmin,pp,p,step,imax,n,k,m,n1,r2:longint;\n flag,flag1:boolean; pl:longint; kolraz,otmax,ot:longint;\n i,j:longint;\n ss:string; strmin:string;\nc,x :mas;\n ugol,vp,sot,vr,vb,r:double;\n d1,d2:array[0..nnn] of longint;\n new1,new2, ss1,ss2:string;\nstr:array [0..10000] of string;\n bb:array[-100000..20000000] of boolean;\n spost:array [0..1000] of longint;\n function min(a,b:int64):int64;\nbegin min:=a;if ba then max:=b; end;\n{ function sovp (i1,i2:longint):boolean; var i,j:longint ;flag,flag1:boolean;\nbegin flag:=true;\n for i:=1 to k do\n begin flag1:=false; for j:=1 to k do\n if bil[i1,i]=bil[i2,j] then flag1:=true;\n end;\n if not flag1 then flag:=false;\n\n sovp:=flag;\nend; }\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);\n} read(n,a,b);\n i:=max(a+1,b-n);\n writeln(n-i+1);\n\n\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nvar\nn,a,b : integer;\nbegin\nread (n,a,b);\nif n-a>b then write (n-a)\nelse write (b);\nend.\n"}, {"source_code": "program kol_poz;\nvar n,a,b,k:byte;\nbegin\nread(n,a,b);\nk:=n-a;\nwrite(k);\nend.\n"}, {"source_code": "program AA;\nvar N,i,j,x,y:integer;\n A:array[1..100000] of integer;\n S:array[1..100000] of string;\nbegin\nread(n,x,y);\nwriteln(x+y-N+3);\n\nend."}, {"source_code": "var n,a,b:longint;\nbegin\nread(n,a,b);\nif (a<=b) then write(n-a)\nelse if (n-bb then write(n-b);\nend."}, {"source_code": "var\nk : longint;\ni:longint;\na,b,n:longint;\nbegin\nread(n,a,b);\nk:=0;\nfor i := a to n do\nif (i >= b) then inc(k);\nif (a=b) then write(n-a) else\nwrite(k);\nend."}, {"source_code": "uses math;\nvar a,b,n,rez:integer;\n\nbegin\nreadln(n,a,b);\nif (b=0) then begin\nwriteln(0); halt(0); end;\nif (n-a)<(n-b+1) then rez:=n-a else rez:=n-b+1;\nif (rez<0) then rez:=0;\nwriteln(rez);\n\n\n\nend."}, {"source_code": "var\n a,b,c,kol,n,i : longint;\nbegin\n readln(n,a,b);\n kol:=0;\n for i:=1 to n do\n if i-a>0 then inc(kol);\n writeln(kol);\nend."}], "src_uid": "51a072916bff600922a77da0c4582180"} {"source_code": "program problem4;\nuses math;\n\ntype\ttTreapRec =\trecord\n\t\t\t\t\tlSon, rSon, size, prior, pos, val: longInt;\n\t\t\t\tend;\n\nvar\tt: array[ 0..1000000 ] of tTreapRec;\n\ttw: longInt = 0;\n\nfunction newNode( p, v: longInt ): longInt;\nbegin\n\tinc( tw );\n\tt[tw].pos := p;\n\tt[tw].val := v;\n\tt[tw].size := 1;\n\tt[tw].prior := random(1000000000);\n\tt[tw].lSon := 0;\n\tt[tw].rSon := 0;\n\t\n\tnewNode := tw;\nend;\n\nprocedure recalc( v: longInt );\nbegin\n\tt[v].size := t[ t[v].lSon ].size + t[ t[v].rSon ].size + 1;\nend;\n\nfunction merge( l, r: longInt ): longInt;\nbegin\n\tif ( min(l, r) = 0 ) then\n\tbegin\n\t\tmerge := l + r;\n\t\texit;\n\tend;\n\t\n\tif ( t[l].prior > t[r].prior ) then\n\tbegin\n\t\tt[l].rSon := merge( t[l].rSon, r );\n\t\trecalc( l );\n\t\t\n\t\tmerge := l;\n\tend\n\telse\n\tbegin\n\t\tt[r].lSon := merge( l, t[r].lSon );\n\t\trecalc( r );\n\t\t\n\t\tmerge := r;\n\tend;\nend;\n\nprocedure split( v, k: longInt; var l, r: longInt );\nbegin\n\tif ( v = 0 ) then\n\tbegin\n\t\tl := 0;\n\t\tr := 0;\n\t\t\n\t\texit;\n\tend;\n\t\n\tif ( t[ t[v].lSon ].size >= k ) then\n\tbegin\n\t\tsplit( t[v].lSon, k, l, t[v].lSon );\n\t\trecalc( v );\n\t\t\n\t\tr := v;\n\tend\n\telse\n\tbegin\n\t\tsplit( t[v].rSon, k - t[ t[v].lSon ].size - 1, t[v].rSon, r );\n\t\trecalc( v );\n\t\t\n\t\tl := v;\n\tend;\nend;\n\nfunction remove( var v: longInt; k: longInt ): longInt;\nvar\ta, b, c: longInt;\nbegin\n\tsplit( v, k - 1, a, v );\n\tsplit( v, 1, b, c );\n\t\n\tv := merge( a, c );\n\t\n\tremove := b;\nend;\n\nvar\tn, m, i, root, x, y: longInt;\n\ta: array[ 1..1000000 ] of longInt;\n\tused: array[ 1..1000000 ] of boolean;\n\tbufIn, bufOut: array[ 1..1 shl 16 ] of byte;\n\nbegin\n\tsetTextBuf( input, bufIn );\n\tsetTextBuf( output, bufOut );\n\n\treadln( n, m );\n\t\n\troot := 0;\n\tfor i := 1 to n do\n\t\troot := merge( root, newNode( i, -1 ) );\n\t\n\tfor i := 1 to m do\n\tbegin\n\t\treadln( x, y );\n\t\t\n\t\ty := remove( root, y );\n\t\t\n\t\tif ( t[y].val = -1 ) or ( t[y].val = x ) then\n\t\t\tt[y].val := x\n\t\telse\n\t\tbegin\n\t\t\twriteln( -1 );\n\t\t\thalt;\n\t\tend;\n\t\t\n\t\troot := merge( y, root );\n\tend;\n\n\tfillchar( used, sizeOf(used), false );\n\tfor i := 1 to n do\n\tbegin\n\t\tif ( t[i].val > -1 ) and ( used[ t[i].val ] ) then\n\t\tbegin\n\t\t\twriteln( -1 );\n\t\t\thalt;\n\t\tend;\n\t\t\n\t\tif ( t[i].val > -1 ) then\n\t\t\tused[ t[i].val ] := true;\n\n\t\ta[ t[i].pos ] := t[i].val;\n\tend;\n\t\n\tx := 1;\n\tfor i := 1 to n do\n\t\tif ( a[i] = -1 ) then\n\t\tbegin\n\t\t\twhile ( used[x] ) do\n\t\t\t\tinc( x );\n\t\t\t\n\t\t\ta[i] := x;\n\t\t\tinc( x );\n\t\tend;\n\t\t\n\tfor i := 1 to n do\n\t\twrite( a[i], ' ' );\n\t\n\twriteln;\nend.\n", "positive_code": [{"source_code": "uses SysUtils,Math;\ntype int64=longint;\n pair=record\n left,right:int64;\n end;\n versh=record\n num,child,y,l,r:int64;\n end;\n mass=array[0..3000000] of versh;\n maxx=array[0..3000000] of longint;\n maee=array[0..3000000,1..2] of longint;\nvar dp:mass;x,y,j,e,z:longint;\n ch:char;\n kol,root,size,md,dd,h1,h2,res1,res2,d,c,a,b,n,k,res:int64;\n tree:mass;\n w:pair;\n i:integer;\n used,m4,ans:maxx;\n m1:maee;\nconst zero:pair=(left:0;right:0);\nprocedure calc(t:longint);\nbegin\n if t<>0\n then tree[t].child:=tree[tree[t].l].child+tree[tree[t].r].child+1;\nend;\nfunction split(v,num:longint):pair;\nBegin\n if v=0\n then Begin\n result:=zero;\n exit;\n end;\n if tree[tree[v].l].child+1<=num\n then Begin\n result:=split(tree[v].r,num-tree[tree[v].l].child-1);\n tree[v].r:=result.left;\n result.left:=v;\n end\n else Begin\n result:=split(tree[v].l,num);\n tree[v].l:=result.right;\n result.right:=v;\n end;\n calc(v);\nend;\nfunction merge(l,r:longint):longint;\nBegin\n if (r=0) or (l=0)\n then result:=l or r\n else if tree[l].y>tree[r].y\n then Begin\n result:=l;\n tree[l].r:=merge(tree[l].r,r);\n end\n else Begin\n result:=r;\n tree[r].l:=merge(l,tree[r].l);\n end;\n calc(result);\nend;\nfunction get(t,x:longint):longint;\nBegin\n if x<=tree[tree[t].l].child\n then Begin\n get:=get(tree[t].l,x);\n exit;\n end\n else if x>tree[tree[t].l].child+1\n then Begin\n get:=get(tree[t].r,x-tree[tree[t].l].child-1);\n exit;\n end;\n get:=t;\nend;\nprocedure insert(index,value:int64);\nBegin\n inc(size);\n tree[size].num:=value;\n tree[size].child:=1;\n tree[size].y:=random(1000000000)+1;\n w:=split(root,index-1);\n root:=merge(w.left,size);\n root:=merge(root,w.right);\nend;\nprocedure remove(var t:int64;index:longint);\nBegin\n if index=tree[tree[t].l].child+1\n then t:=merge(tree[t].l,tree[t].r)\n else if index<=tree[tree[t].l].child\n then remove(tree[t].l,index)\n else remove(tree[t].r,index-tree[tree[t].l].child-1);\n calc(t);\nend;\nprocedure add(var t:int64;index,delta:longint);\nBegin\n if index=tree[tree[t].l].child+1\n then inc(tree[t].num,delta)\n else if index<=tree[tree[t].l].child\n then add(tree[t].l,index,delta)\n else add(tree[t].r,index-tree[tree[t].l].child-1,delta);\n calc(t);\nend;\nprocedure doing(t:longint);\nBegin\n if tree[t].l>0\n then doing(tree[t].l);\n inc(kol);\n ans[kol]:=tree[t].num;\n m4[tree[t].num]:=1;\n if tree[t].r>0\n then doing(tree[t].r);\nend;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n root:=0;\n readln(n,k);\n kol:=0;\n for i:=1 to n do\n insert(i,0);\n for i:=1 to k do\n Begin\n readln(m1[i,1],m1[i,2]);\n if (used[m1[i,1]]=1) and (m1[i,2]>kol)\n then Begin\n writeln(-1);\n halt(0);\n end;\n used[m1[i,1]]:=1;\n if m1[i,2]>kol\n then Begin\n insert(1,m1[i,1]);\n inc(kol);\n end\n else Begin\n a:=get(root,m1[i,2]);\n if tree[a].num<>m1[i,1]\n then Begin\n writeln(-1);\n halt(0);\n end;\n remove(root,m1[i,2]);\n insert(1,m1[i,1]);\n end;\n end;\n for i:=k downto 1 do\n Begin\n remove(root,1);\n insert(m1[i,2],m1[i,1]);\n end;\n kol:=0;\n doing(root);\n a:=1;\n for i:=1 to n do\n if ans[i]=0\n then for z:=a to n do\n if m4[z]=0\n then Begin\n ans[i]:=z;\n a:=z+1;\n break;\n end;\n for i:=1 to n do\n write(ans[i],' ');\nend."}, {"source_code": "program cs_d;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n PNode = ^TNode;\n TNode = record\n l, r: PNode;\n priority: Integer;\n size: Integer;\n value: Integer;\n end;\n\nconst\n MaxN = 2000000000;\n\nvar\n root, splitter, t, t1, t2, t3: PNode;\n N, M, i: Integer;\n values, list: array [0..1000000] of Integer;\n used: array [0..1000000] of Boolean;\n\nfunction NewPNode: PNode;\nvar t : PNode;\nbegin\n New(t);\n t^.l := nil;\n t^.r := nil;\n t^.priority := Random(MaxN);\n t^.size := 1;\n result := t;\nend;\n\nfunction getSize(t: PNode): Integer;\nbegin\n if (t = nil) then result := 0 else result := t^.size;\nend;\n\nprocedure Update(t : PNode);\nbegin\n t^.size := GetSize(t^.l) + GetSize(t^.r) + 1;\nend;\n\nfunction Split(t: PNode; key: Integer): PNode;\nvar z: PNode;\nbegin\n if (t = nil) then begin\n splitter^.l := nil;\n splitter^.r := nil;\n result := splitter;\n Exit;\n end;\n\n if (key <= getSize(t^.l)) then begin\n z := Split(t^.l, key);\n t^.l := z^.r;\n z^.r := t;\n end else begin\n z := Split(t^.r, key - getSize(t^.l) - 1);\n t^.r := z^.l;\n z^.l := t;\n end;\n update(t); update(z);\n result := z;\nend;\n\nfunction Merge(l, r: PNode): PNode;\nbegin\n if (l = nil) then result := r else\n if (r = nil) then result := l else\n if l^.priority > r^.priority then begin\n l^.r := Merge(l^.r, r);\n update(l);\n Result := l;\n end else begin\n r^.l := Merge(l, r^.l);\n update(r);\n result := r;\n end;\nend;\n\nprocedure DeleteTree(var t: PNode);\nbegin\n if t^.l <> nil then DeleteTree(t^.l);\n if t^.r <> nil then DeleteTree(t^.r);\n Dispose(t);\nend;\n\nvar\n pos, val, j: Integer;\n ok: Boolean;\n\nbegin\n Randomize;\n splitter := NewPNode;\n root := nil;\n ok := True;\n FillChar(values, SizeOf(values), 0);\n\n Readln(N, M);\n for i := 1 to N do\n begin\n t := NewPNode;\n t^.value := i;\n root := Merge(root, t);\n end;\n\n for i := 1 to M do\n begin\n Readln(val, pos);\n Dec(pos);\n Split(root, pos);\n t1 := splitter^.l;\n Split(splitter^.r, 1);\n t2 := splitter^.l;\n t3 := splitter^.r;\n\n j := t2^.value;\n if (values[j] > 0) and (values[j] <> val) then\n ok := False;\n values[j] := val;\n\n root := nil;\n root := Merge(root, t2);\n root := Merge(root, t1);\n root := Merge(root, t3);\n end;\n\n FillChar(used, SizeOf(used), False);\n for i := 1 to n do\n if (values[i] > 0) then\n if not used[values[i]] then used[values[i]] := True\n else ok := False;\n\n pos := 0;\n for i := 1 to n do\n if not used[i] then begin\n Inc(pos);\n list[pos] := i;\n end;\n pos := 0;\n for i := 1 to n do\n if (values[i] = 0) then begin\n Inc(pos);\n values[i] := list[pos];\n end;\n if not ok then write('-1') else\n for i := 1 to n do write(values[i], ' ');\n writeln;\n DeleteTree(root);\nend."}, {"source_code": "program cs_d;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n PNode = ^TNode;\n TNode = record\n l, r: PNode;\n priority: Integer;\n size: Integer;\n value: Integer;\n end;\n\nconst\n MaxN = 1000*1000*1000;\n\nvar\n root, splitter, t, t1, t2, t3: PNode;\n N, M, i: Integer;\n values, list: array [0..1000000] of Integer;\n used: array [0..1000000] of Boolean;\n\nfunction NewPNode: PNode;\nvar t : PNode;\nbegin\n New(t);\n t^.l := nil;\n t^.r := nil;\n t^.priority := Random(MaxN);\n t^.size := 1;\n result := t;\nend;\n\nfunction getSize(t: PNode): Integer;\nbegin\n if (t = nil) then result := 0 else result := t^.size;\nend;\n\nprocedure Update(t : PNode);\nbegin\n t^.size := GetSize(t^.l) + GetSize(t^.r) + 1;\nend;\n\nfunction Split(t: PNode; key: Integer): PNode;\nvar z: PNode;\nbegin\n if (t = nil) then begin\n splitter^.l := nil;\n splitter^.r := nil;\n result := splitter;\n Exit;\n end;\n\n if (key <= getSize(t^.l)) then begin\n z := Split(t^.l, key);\n t^.l := z^.r;\n z^.r := t;\n end else begin\n z := Split(t^.r, key - getSize(t^.l) - 1);\n t^.r := z^.l;\n z^.l := t;\n end;\n update(t); update(z);\n result := z;\nend;\n\nfunction Merge(l, r: PNode): PNode;\nbegin\n if (l = nil) then result := r else\n if (r = nil) then result := l else\n if l^.priority > r^.priority then begin\n l^.r := Merge(l^.r, r);\n update(l);\n Result := l;\n end else begin\n r^.l := Merge(l, r^.l);\n update(r);\n result := r;\n end;\nend;\n\nprocedure DeleteTree(var t: PNode);\nbegin\n if t^.l <> nil then DeleteTree(t^.l);\n if t^.r <> nil then DeleteTree(t^.r);\n Dispose(t);\nend;\n\nvar\n pos, val, j: Integer;\n ok: Boolean;\n\nbegin\n Randomize;\n splitter := NewPNode;\n root := nil;\n ok := True;\n FillChar(values, SizeOf(values), 0);\n\n Readln(N, M);\n for i := 1 to N do\n begin\n t := NewPNode;\n t^.value := i;\n root := Merge(root, t);\n end;\n\n for i := 1 to M do\n begin\n Readln(val, pos);\n Dec(pos);\n Split(root, pos);\n t1 := splitter^.l;\n Split(splitter^.r, 1);\n t2 := splitter^.l;\n t3 := splitter^.r;\n\n j := t2^.value;\n if (values[j] > 0) and (values[j] <> val) then\n ok := False;\n values[j] := val;\n\n root := nil;\n root := Merge(root, t2);\n root := Merge(root, t1);\n root := Merge(root, t3);\n end;\n\n FillChar(used, SizeOf(used), False);\n for i := 1 to n do\n if (values[i] > 0) then\n if not used[values[i]] then used[values[i]] := True\n else ok := False;\n\n pos := 0;\n for i := 1 to n do\n if not used[i] then begin\n Inc(pos);\n list[pos] := i;\n end;\n pos := 0;\n for i := 1 to n do\n if (values[i] = 0) then begin\n Inc(pos);\n values[i] := list[pos];\n end;\n if not ok then write('-1') else\n for i := 1 to n do write(values[i], ' ');\n writeln;\nend."}, {"source_code": "uses SysUtils,Math;\ntype int64=longint;\n pair=record\n left,right:int64;\n end;\n versh=record\n num,child,y,l,r:int64;\n end;\n mass=array[0..3000000] of versh;\n maxx=array[0..3000000] of longint;\n maee=array[0..3000000,1..2] of longint;\nvar dp:mass;x,y,j,e,z:longint;\n ch:char;\n kol,root,size,md,dd,h1,h2,res1,res2,d,c,a,b,n,k,res:int64;\n tree:mass;\n w:pair;\n i:integer;\n used,m4,ans:maxx;\n m1:maee;\nconst zero:pair=(left:0;right:0);\nprocedure calc(t:longint);\nbegin\n if t<>0\n then tree[t].child:=tree[tree[t].l].child+tree[tree[t].r].child+1;\nend;\nfunction split(v,num:longint):pair;\nBegin\n if v=0\n then Begin\n result:=zero;\n exit;\n end;\n if tree[tree[v].l].child+1<=num\n then Begin\n result:=split(tree[v].r,num-tree[tree[v].l].child-1);\n tree[v].r:=result.left;\n result.left:=v;\n end\n else Begin\n result:=split(tree[v].l,num);\n tree[v].l:=result.right;\n result.right:=v;\n end;\n calc(v);\nend;\nfunction merge(l,r:longint):longint;\nBegin\n if (r=0) or (l=0)\n then result:=l or r\n else if tree[l].y>tree[r].y\n then Begin\n result:=l;\n tree[l].r:=merge(tree[l].r,r);\n end\n else Begin\n result:=r;\n tree[r].l:=merge(l,tree[r].l);\n end;\n calc(result);\nend;\nfunction get(t,x:longint):longint;\nBegin\n if x<=tree[tree[t].l].child\n then Begin\n get:=get(tree[t].l,x);\n exit;\n end\n else if x>tree[tree[t].l].child+1\n then Begin\n get:=get(tree[t].r,x-tree[tree[t].l].child-1);\n exit;\n end;\n get:=t;\nend;\nprocedure insert(index,value:int64);\nBegin\n inc(size);\n tree[size].num:=value;\n tree[size].child:=1;\n tree[size].y:=random(1000000000)+1;\n w:=split(root,index-1);\n root:=merge(w.left,size);\n root:=merge(root,w.right);\nend;\nprocedure remove(var t:int64;index:longint);\nBegin\n if index=tree[tree[t].l].child+1\n then t:=merge(tree[t].l,tree[t].r)\n else if index<=tree[tree[t].l].child\n then remove(tree[t].l,index)\n else remove(tree[t].r,index-tree[tree[t].l].child-1);\n calc(t);\nend;\nprocedure add(var t:int64;index,delta:longint);\nBegin\n if index=tree[tree[t].l].child+1\n then inc(tree[t].num,delta)\n else if index<=tree[tree[t].l].child\n then add(tree[t].l,index,delta)\n else add(tree[t].r,index-tree[tree[t].l].child-1,delta);\n calc(t);\nend;\nprocedure doing(t:longint);\nBegin\n if tree[t].l>0\n then doing(tree[t].l);\n inc(kol);\n ans[kol]:=tree[t].num;\n m4[tree[t].num]:=1;\n if tree[t].r>0\n then doing(tree[t].r);\nend;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n root:=0;\n readln(n,k);\n kol:=0;\n for i:=1 to n do\n insert(i,0);\n for i:=1 to k do\n Begin\n readln(m1[i,1],m1[i,2]);\n if (used[m1[i,1]]=1) and (m1[i,2]>kol)\n then Begin\n writeln(-1);\n halt(0);\n end;\n used[m1[i,1]]:=1;\n if m1[i,2]>kol\n then Begin\n insert(1,m1[i,1]);\n inc(kol);\n end\n else Begin\n a:=get(root,m1[i,2]);\n if tree[a].num<>m1[i,1]\n then Begin\n writeln(-1);\n halt(0);\n end;\n remove(root,m1[i,2]);\n insert(1,m1[i,1]);\n end;\n end;\n for i:=k downto 1 do\n Begin\n remove(root,1);\n insert(m1[i,2],m1[i,1]);\n end;\n kol:=0;\n doing(root);\n a:=1;\n for i:=1 to n do\n if ans[i]=0\n then for z:=a to n do\n if m4[z]=0\n then Begin\n ans[i]:=z;\n a:=z+1;\n break;\n end;\n for i:=1 to n do\n write(ans[i],' ');\nend."}, {"source_code": "var\nj:longint;\nn,m,i,k,p,l,r,mm,u: longint;\ns,id,la,pp,num,pos,e: array[0..2222222] of longint;\nprocedure mdf(a,b:longint);\nbegin\nwhile a <= p do begin\ns[a]:=s[a]+b;\na:=a or (a-1);\na:=a+1;\nend;\nend;\nbegin\nread(n,m);\nfor i:=1 to m do read(num[i], pos[i]);\nfor i:=1 to n do la[i]:=0;\nk:=0;\nfor i:=m downto 1 do\nbegin\nif la[num[i]] = 0 then\nbegin\ninc(k);\ne[k]:=num[i];\nla[num[i]]:=1;\nend;\nend;\nfor i:=1 to n do\nif la[i]=0 then begin inc(k); e[k]:=i; end;\np:=1;\nwhile p < n+m do p:=p*2;\nfor i:=1 to p do s[i]:=0;\nfor i:=m+1 to m+n do\nbegin\nid[i]:=i-m;\nmdf(i, 1);\nend;\nfor i:=1 to m do\nbegin\nl:=1; r:=p;\nu:=0;\nwhile l= pos[i] then r:=mm else\nbegin u:=u+s[mm]; l:=mm+1; end;\nend;\nmdf(l,-1);\nmdf(m-i+1,1);\nid[m-i+1]:=id[l];\n\nid[l]:=0;\nend;\nj:=0;\nfor i:=1 to n+m do\nif id[i] <> 0 then\nbegin\ninc(j);\npp[id[i]]:=e[j];\nend;\n\nfor i:=1 to p do s[i]:=0;\nfor i:=m+1 to m+n do\nbegin\nid[i]:=pp[i-m];\nmdf(i, 1);\nend;\nfor i:=1 to m do\nbegin\nl:=1; r:=p;\nu:=0;\nwhile l= pos[i] then r:=mm else\nbegin u:=u+s[mm]; l:=mm+1; end;\nend;\nmdf(l,-1);\nmdf(m-i+1,1);\nid[m-i+1]:=id[l];\nif id[l] <> num[i] then begin writeln(-1); halt(0); end;\n\nid[l]:=0;\nend;\n\nfor i:=1 to n do write(pp[i],' ');\nwriteln;\nend."}], "negative_code": [{"source_code": "var\nj:longint;\nn,m,i,k,p,l,r,mm,u: longint;\ns,id,la,pp,num,pos,e: array[0..2222222] of longint;\nprocedure mdf(a,b:longint);\nbegin\nwhile a <= p do begin\ns[a]:=s[a]+b;\na:=a or (a-1);\na:=a+1;\nend;\nend;\nbegin\nread(n,m);\nfor i:=1 to m do read(num[i], pos[i]);\nfor i:=1 to n do la[i]:=0;\nfor i:=m downto 1 do\nbegin\nif la[num[i]] = 0 then\nbegin\ninc(k);\ne[k]:=num[i];\nla[num[i]]:=1;\nend;\nend;\nfor i:=1 to n do\nif la[i]=0 then begin inc(k); e[k]:=i; end;\np:=1;\nwhile p < n+m do p:=p*2;\nfor i:=1 to p do s[i]:=0;\nfor i:=m+1 to m+n do\nbegin\nid[i]:=i;\nmdf(i, 1);\nend;\nfor i:=1 to m do\nbegin\nl:=1; r:=p;\nu:=0;\nwhile l= pos[i] then r:=mm else\nbegin u:=u+s[mm]; l:=mm+1; end;\nend;\nmdf(l,-1);\nmdf(m-i+1,1);\nid[m-i+1]:=id[l];\n\nid[l]:=0;\nend;\nj:=0;\nfor i:=1 to n+m do\nif id[i] <> 0 then\nbegin\ninc(j);\npp[id[i]]:=e[j];\nend;\n\nfor i:=1 to p do s[i]:=0;\nfor i:=m+1 to m+n do\nbegin\nid[i]:=pp[i];\nmdf(i, 1);\nend;\nfor i:=1 to m do\nbegin\nl:=1; r:=p;\nu:=0;\nwhile l= pos[i] then r:=mm else\nbegin u:=u+s[mm]; l:=mm+1; end;\nend;\nmdf(l,-1);\nmdf(m-i+1,1);\nid[m-i+1]:=id[l];\nif id[l] <> num[i] then begin writeln(-1); halt(0); end;\n\nid[l]:=0;\nend;\n\nfor i:=1 to n do write(pp[i],' ');\nwriteln;\nend."}], "src_uid": "a2616b1681f30ce4b2a5fdc81cf52b50"} {"source_code": "uses\n math;\n\nvar\n s, ss, sub, ans: ansistring;\n i, n: longint;\n z: array[0..1000] of longint;\n\nprocedure Zal(s: ansistring);\nvar\n i, l, r, n: longint;\nbegin\n z[1]:= 0; l:= 1; r:= 1; n:= length(s);\n for i:= 2 to n do\n begin\n if i <= r then z[i]:= min(r - i + 1, z[i - l + 1]);\n while (z[i] + i <= n) and (s[z[i] + 1] = s[z[i] + i]) do inc(z[i]);\n if z[i] + i - 1 > r then\n begin\n l:= i; \n r:= z[i] + i - 1;\n end;\n end;\nend;\n\nbegin\n //assign(input, '1.in'); reset(input);\n //assign(output, '1.out'); rewrite(output);\n readln(n);\n readln(s);\n sub:= 'o';\n for i:= 2 to n do\n if (sub[i - 1] = 'o') then sub:= sub + 'g'\n else sub:= sub + 'o';\n\n ss:= sub + '*' + s;\n Zal(ss);\n i:= length(sub) + 2;\n while (i <= length(ss)) do\n begin\n if (z[i] >= 3) then\n begin\n ans:= ans + '***';\n i:= i + z[i] - ord(z[i] mod 2 = 0);\n end\n else\n begin\n ans:= ans + ss[i];\n inc(i);\n end;\n end;\n writeln(ans);\n //close(input); close(output);\nend.", "positive_code": [{"source_code": "var i,n: integer;\ns:string;\ns1:string;\n\nbegin\nreadln(n);\nreadln(s);\ns1:='***';\nwhile pos('ogo',s)<>0 do\nbegin\ni:=pos('ogo',s);\nDelete(s,i,3);\ninsert(s1,s,i);\nwhile (s[i+3]='g') and (s[i+4]='o') do\nbegin\ndelete(s,i+3,2);\nend;\nend;\nwrite(s);\nend."}, {"source_code": "program polycarp;\nconst fi = '';\n fo = '';\n maxn = 100000;\nvar f,g : text;\n a : array[1..maxn] of char;\n n : longint;\nprocedure nhap;\nvar i : longint;\nbegin\n assign(F,fi);\n assign(g,fo);\n reset(f);\n rewrite(g);\n readln(F,n);\n for i := 1 to n do read(f,a[i]);\nend;\nprocedure process;\nvar i,j : longint;\n ok : boolean;\nbegin\n i := 1;\n repeat\n if (a[i] <> '*') and (i <= n-2) then\n if (A[i] = 'o') and (a[i+1]='g') and (a[i+2] = 'o') then\n begin\n write(g,'***');\n i := i + 3;\n while (i <= n-1) and (A[i]='g') and (A[i+1] = 'o') do\n i := i + 2;\n end;\n if i > n then break;\n if (a[i] <> 'o') or (a[i+1] <> 'g') or (a[i+2] <> 'o') then\n begin\n write(g,a[i]);\n inc(i);\n end;\n until i > n;\nend;\n begin\n nhap;\n process;\n close(f);\n close(G);\n end.\n"}, {"source_code": "program A;\n\nvar\n s, s1: string[100];\n len, i, n, z: byte;\n\nbegin\n readln(n);\n readln(s);\n \n s1 := 'ogo';\n for i := 1 to ((n - 3) div 2) do s1 := s1 + 'go';\n \n len := ((n - 3) div 2) * 2 + 3;\n \n while 3 < len do\n begin\n while pos(s1, s) <> 0 do\n begin\n z := pos(s1, s);\n delete(s, z, len);\n insert('***', s, z);\n end;\n len := len - 2;\n delete(s1, len, 2);\n end;\n \n while pos(s1, s) <> 0 do\n begin\n z := pos(s1, s);\n delete(s, z, len);\n insert('***', s, z);\n end;\n \n writeln(s);\nend."}, {"source_code": "var\n f,ii,i,n:integer;\n b,s:string;\nbegin\n b:='***';\n readln(n);\n readln(s);\n i:=1;\n s:=s+'11111';\n while i<=n do\n begin\n if s[i]='o' then\n if(s[i+1]='g')and(s[i+2]='o')then\n begin\n f:=1;\n ii:=i+2;\n while f=1 do\n begin\n f:=0;\n if(s[ii+1]='g')and(s[ii+2]='o')then\n begin\n f:=1;\n ii:=ii+2;\n end;\n end;\n delete(s,i,ii-i+1);\n insert(b,s,i);\n n:=n-(ii-i-3+1);\n i:=i+2;\n end;\n i:=i+1;\n end;\n for i:=1 to length(s) do\n if s[i]<>'1' then\n write(s[i]);\nend."}, {"source_code": "var\n s: string;\n i, n: integer;\n\nbegin\n readln(n);\n readln(s);\n \n while pos('ogo', s) <> 0 do begin\n i := pos('ogo', s);\n while (i+4<=length(s)) and (s[i + 3] = 'g') and (s[i + 4] = 'o') do begin\n delete(s, i + 3, 2);\n end;\n s[i] := '*';\n s[i + 1] := '*';\n s[i + 2] := '*'; \n end; \n \n writeln(s);\nend."}, {"source_code": "var\n s: string;\n i, n, k, q, j: integer;\n\nbegin\n readln(n);\n readln(s);\n \n while pos('ogo', s) <> 0 do begin\n i := pos('ogo', s);\n while (i+4<=length(s)) and (s[i + 3] = 'g') and (s[i + 4] = 'o') do begin\n delete(s, i + 3, 2);\n end;\n s[i] := '*';\n s[i + 1] := '*';\n s[i + 2] := '*'; \n end; \n \n writeln(s);\nend."}, {"source_code": "var\nn,i:integer;\ns:string;\n\nbegin\nreadln(n);\nreadln(s);\ns:=s+' '+' ';\nfor i:=1 to n-2 do\nif (s[i]='o') and (s[i+1]='g')and(s[i+2]='o') then \nbegin\ndelete(s,i,1);\nwhile (s[i]='g') and (s[i+1]='o') do\ndelete(s,i,2);\ninsert('***',s,i);\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\na:=1;\nwhile a <> 0 do\nbegin\na:=pos('ogo',s);\nif (a > 0) then begin n:=n-3;\ndelete(s,a,3);\ninsert('***',s,a);\nend;\nb:=1;\nwhile b <> 0 do begin\nb:=pos('*go',s);\nif b > 0 then begin delete(s,b+1,2); n:=n-2; end;\nend;\nend;\nwriteln(s);\nend."}, {"source_code": "program zad_a;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n\ts, w: string;\n str: array [0..1000] of string;\n len: array [0..1000] of integer;\n i, j, m, n, k: integer;\n\nbegin\n\treadln(n);\n\treadln(s);\n str[1] := 'ogo';\n len[1] := 3;\n for i := 2 to 100 do\n begin\n \tstr[i] := str[i - 1] + 'go';\n len[i] := length(str[i]);\n end;\n\n for i := 100 downto 1 do\n \twhile (pos(str[i], s) > 0) do\n begin\n \tk := pos(str[i], s);\n \tdelete(s, pos(str[i], s), len[i]);\n insert('***', s, k);\n end;\n\n writeln(s);\n readln;readln;readln;\n\nend.\n"}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\nn:=length(s);\nwhile n > 0 do\nbegin\na:=pos('ogo',s);\nb:=pos('*go',s);\nif (a > 0) or (b > 0) then begin\nb:=pos('*go',s);\nif b > 0 then begin delete(s,b+1,2); n:=n-2; end;\na:=pos('ogo',s);\nif (a > 0) then begin n:=n-3;\ndelete(s,a,3);\ninsert('***',s,a);\nend;\nend\nelse n:=n-1;\nend;\na:=1;\nwhile a <> 0 do begin\na:=pos('***g***',s);\nif a > 0 then delete(s,a,4); end;\nwriteln(s);\nend."}, {"source_code": "var n,i:integer; s,g:string;\nbegin\nreadln(n);readln(s);\ni:=1;\nwhile ia then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]'o')) then fl:=false;\n if ss[rr]<>'o' then fl:=false;\n ogo:=fl;\nend;\n\nfunction maxogo(ll,rr:longint):boolean;\nvar i,j:longint; fl:boolean;\nbegin\n fl:=ogo(ll,rr);\n if ogo(ll-2,rr) or ogo(ll,rr+2) then fl:=false;\n if rr-ll<2 then fl:=false;\n maxogo:=fl;\nend;\n\n\n\n\nbegin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n2: for i:=1 to n do for j:=i to n do if maxogo(i,j) then\n begin\n flag:=true;\n ss1:=copy(ss,1,i-1);\n ss2:=copy(ss,j+1,n-j+1);\n {writeln('i= ',i,' j= ',j);\n writeln('ss1= ',ss1);\n writeln('ss2= ',ss2);\n } ss:=ss1+'***'+ss2;\n n:=length(ss);\n { writeln(ss); }\n end;\n if flag then begin flag:=false; goto 2; end;\n\n writeln(ss);\n\n\n\n\n\n\n goto 1;\n\n readln(p,t);\n q:=1;\n x[1]:=p;\n ll:=q;\n rr:=q;\n for step:=1 to 30 do\n begin\n for i:=ll to rr do if 2*x[i]<2000000000 then begin inc(q); x[q]:=2*x[i]; y[q]:=i; end;\n for i:=ll to rr do if 10*x[i]+1<2000000000 then begin inc(q); x[q]:=10*x[i]+1; y[q]:=i; end;\n ll:=rr+1; rr:=q;\n\n end;\n\n writeln('q= ',q);\n for i:=1 to q do write(x[i],' '); writeln;\n\n for i:=1 to q do if x[i]=t then begin flag:=true; ii:=y[i]; end;\n if not flag then writeln('NO');\n\n while (y[ii]<>1)and(tt<100) do begin inc(tt); z[tt]:=y[ii]; ii:=y[ii]; end;\n\n writeln('tt= ',tt);\n { for i:=1 to tt do write(x[])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i, j, n, m : longint;\n s, new : string;\nbegin\n // assign(input, 'input.txt'); assign(output, 'output.txt');\n\n readln(n);\n readln(s);\n i := 1;\n new := '';\n while i <= n-2 do\n begin\n if (s[i] = 'o') and (s[i+1] = 'g') and (s[i+2] = 'o') then\n begin\n new := new + '***';\n i := i + 3;\n while (i < n) and (s[i] = 'g') and (s[i+1] = 'o') do\n i := i + 2;\n end\n else\n begin\n new := new + s[i];\n inc(i);\n end;\n end;\n\n for j := i to n do\n new := new + s[j];\n\n writeln(new);\nend."}, {"source_code": "Var\ni,j,n,h,k:integer;\ns,d,og:string;\nbegin\nd:='ogo';\nreadln(n);\nreadln(s);\n\nfor j:=49 downto 1 do begin\nog:=d;\n\n for h:=1 to j do og:=og+'go';\n\n for k:=1 to 33 do begin\n \n i := Pos(og, s); \n if i > 0 then\n begin \n Delete(s, i, ((j*2)+3)); \n Insert('***', s, i); \n \n end;\n end;\nend;\n\n for k:=1 to 33 do begin\n \n i := Pos('ogo', s); \n if i > 0 then\n begin \n Delete(s, i, 3); \n Insert('***', s, i); \n \n end;\n end;\n\nwriteln(s);\nend.\n"}, {"source_code": "var s,s2:string;\ni,n,r,l,j:longint;\nbegin\n readln(n);\n readln(s);\n i:=1;\n while true do\n begin\n if (s[i]='o')and(s[i+1]='g')and(s[i+2]='o') then begin\n j:=i+2;\n while j<=n do\n begin\n if (s[j+1]='g')and(s[j+2]='o')\n then begin\n j:=j+2;\n end\n else break;\n end;\n i:=j+1;\n s2:=s2+'***';\n end\n else begin\n s2:=s2+s[i];\n i:=i+1;\n end;\n if i>n then break;\n end;\n writeln(s2);\nend."}, {"source_code": "var\n n, i, b, a: integer;\n s1, s: string;\n\nbegin\n readln(n);\n readln(s);\n i:=1;\n while (i<=n) do \n begin\n if (s[i] = 'o') and (s[i + 1] = 'g') and (s[i + 2] = 'o') then begin\n delete(s, i, 3);\n insert('***', s, i);\n i+=2;\n while (i0 do begin\nb:=k+3;\nwhile (b 0 do\nbegin\n lol := false;\n p2 := p1 + 2;\n for i:=p1+3 to length(input) do\n if lol AND (copy(input, i, 1) = 'o') OR NOT(lol) AND (copy(input, i, 1) = 'g') then\n begin\n if lol = true then\n p2 := i;\n lol := NOT(lol);\n end\n else\n break;\n \n delete(input, p1, p2 - p1 + 1);\n insert('***', input, p1);\n \n p1 := pos('ogo', input);\nend;\n\nwrite(input);\nend."}, {"source_code": "var\n n,i,x,r,j:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n x:=pos('ogo',s);\n while x<>0 do begin\n s[x]:='*';\n s[x+1]:='*';\n s[x+2]:='*';\n i:=x+3;\n r:=(n-i+1) div 2;\n for j:=1 to r do if s[i]+s[i+1]='go' then delete(s,i,2);\n n:=length(s);\n x:=pos('ogo',s);\n end;\n write(s)\nend."}, {"source_code": "var\n n,i,f: longint;\n s: string;\nbegin\n readln(n);\n read(s);\n i:=0;\n f:=0;\n while i'g') or (s[i+1]<>'o') then begin\n f:=0;\n i:=i-1;\n end;\n if f=1 then if i+1<=length(s) then if (s[i]='g') or (s[i+1]='o') then begin\n delete(s,i,2);\n i:=i-1;\n end;\n end;\n write(s);\nend."}, {"source_code": "program one;\n\nvar\n n, i, Position: integer;\n s, sWork, sNew: string;\n k: boolean;\n\nbegin\n Readln(n);\n Readln(s);\n k := False;\n sWork := s;\n repeat\n Position := Pos('ogo', sWork);\n if Position <> 0 then begin\n sNew := sNew + Copy(sWork, 1, Position - 1) + '***';\n Delete(sWork, 1, Position + 2);\n while(2 <= length(sWork)) do \n begin\n if (sWork[1] = 'g') and (sWork[2] = 'o') then \n Delete(sWork, 1, 2)\n else Break;\n end;\n end\n else k := True;\n until(k);\n sNew := sNew + sWork;\n Writeln(sNew);\nend."}, {"source_code": "var s,ans:string;\n i,z,useless:longint;\nprocedure check(x:longint);\n var i,q:longint;\nbegin\n q:=0;\n for i:=1 to length(s)-x do\n begin\n if ((i mod 2 = 1)and(s[x+i]<>'g'))or((i mod 2 = 0)and(s[x+i]<>'o'))\n then begin q:=i; break; end;\n end;\n if q=0\n then q:=(length(s)-x)+1;\n \n if q>2\n then begin delete(s,x,1+((q-1) div 2)*2); ans:=ans+'***';end\n else begin ans:=ans+s[z]; inc(z);end;\n\nend;\n\nbegin\n readln(Useless);\n read(s);\n z:=1;\n while z<=length(s) do\n begin\n if s[z]='o'\n then begin\n check(z);\n\n end\n else begin\n inc(z);\n ans:=ans+s[z-1];\n end;\n end;\n \n write(ans);\nend."}, {"source_code": "program q; {$Q+ $R+}\nvar i, a, d, n, j: longint; c: char; s: string;\n\nbegin\n {assign(input, 'input.txt'); reset(input);\n assign(output, 'output.txt'); rewrite(output); }\n readln(n);\n readln(s);\n i := 1;\n while i < n - 1 do\n begin\n if (s[i] = 'o') and (s[i + 1] = 'g') and (s[i + 2] = 'o')\n then\n begin\n i := i + 3;\n while (i < n) and (s[i] = 'g') and (s[i + 1]='o') do i := i + 2;\n write('***');\n end\n else begin write(s[i]); inc(i); end;\n end;\n for j := i to n do\n write(s[j]);\nend.\n"}, {"source_code": "var\n s,p:string;\n k,i,n:longint;\nbegin\nreadln(n);\nreadln(s);\np:='ogo';\ni:=1;\nwhile i<=length(s) do begin\nif copy(s,i,3)=p then begin\n delete(s,i,3);\n k:=i;\n if copy(s,k,2)='go' then begin\n while copy(s,k,2)='go' do\n k:=k+2;\n delete(s,i,k-i);\n end;\n insert('***',s,i);\n i:=i+3;\n end\n else i:=i+1;\nend;\nwriteln(s);\nend."}, {"source_code": "var s:string;\n l,i:integer;\n winston:boolean;\nbegin\nreadln(l);\nreadln(s);\ni:=1;\nwhile (i<=l) do\n begin\n if (s[i]='o')and(s[i+1]='g')and(s[i+2]='o') then\n begin\n write('***');\n i:=i+3;\n winston:=true;\n while (winston)and(i<=l) do\n begin\n if (s[i]='g')and(s[i+1]='o') then\n i:=i+2\n else winston:=false;\n end;\n end else\n begin\n write(s[i]);\n i:=i+1;\n end;\n end;\nend."}, {"source_code": "var\n n,i,j,k: longint;\n s,t: shortstring;\nbegin\n readln(n);\n readln(s);\n s:=s+'#';\n i:=1;\n while i <= n do\n begin\n k:=0;\n\n if s[i] = 'o' then for j:=i to n do\n begin\n inc(k);\n\n if (s[j] = 'g') and (s[j+1] <> 'o') then\n if k >= 3 then\n begin\n t:=t+'***';\n i:=j-1;\n break;\n end else begin t:=t+s[i]; break; end;\n\n if (s[j] = 'o') and (s[j+1] <> 'g') then\n if k >= 3 then\n begin\n t:=t+'***';\n i:=j;\n break;\n end else begin t:=t+s[i]; break; end;\n\n end else t:=t+s[i];\n\n inc(i);\n end;\n\n writeln(t);\nend.\n"}, {"source_code": "var t,s: ansistring;\n i,n,j: longint;\n\nprocedure xuli;\n begin\n i:=1;\n repeat\n if s[i]+s[i+1]+s[i+2]='ogo' then\n begin\n j:=i+1;\n while s[j]+s[j+1]='go' do inc(j,2);\n write('***');\n i:=j;\n end\n else\n begin write(s[i]); inc(i); end;\n until i>n;\n end;\n\nBEGIN\n \n readln(n);\n readln(s);\n s:=s+'aa';\n xuli;\n \nEND.\n\n"}, {"source_code": "\nvar a,s:string;\ni,n,t,d:longint;\n\nbegin\nreadln(n);\nreadln(s);\na:='';\ni:=1;\nt:=0;d:=0;\nwhile i<=length(s) do\n begin\n if s[i]='o' then\n begin\n inc(d);\n if s[i+1]+s[i+2]='go' then\n begin\n t:=1;\n i:=i+2;\n end\n else\n if s[i+1]+s[i+2]<>'go' then\n begin\n if d<>0 then\n begin\n if t=1 then a:=a+'***'\n else a:=a+'o';\n t:=0;\n end;\n inc(i);\n d:=0;\n end;\n end;\n if i<=length(s) then\n begin\n if s[i]<>'o' then\n begin\n a:=a+s[i];\n inc(i);\n end;\n end;\n end;\nwriteln(a);\nend.\n\n\n\n\n\n"}, {"source_code": "program Oleg;\nvar n:byte; s:string; \nfunction poisk(n:byte;s:string):string;\nvar d:string;k:byte;\nbegin\nwhile Pos('ogo',s)<>0 do\nbegin\nd:='ogo';\nwhile Pos(d,s)<>0 do d:=d+'go';\nDelete(d,length(d)-2,2);\nk:=Pos(d,s);\nDelete(s,k,length(d));\ninsert('***',s,k)\nend;\npoisk:=s;\nend;\nbegin\nreadln(n);\nreadln(s);\nwriteln(poisk(n,s));\nreadln\nend."}, {"source_code": "var\n a, b, n, c, i, i1: longint;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n s:=s+' ';\n i := 1;\n while (i <= n) do \n begin\n if (s[i] = 'o') and (s[i + 1] = 'g') and (s[i + 2] = 'o') then begin\n i := i + 3;\n while ((s[i] = 'g') and (s[i + 1] = 'o')) do \n begin\n i := i + 2;\n end;\n write('***');\n end\n else begin\n if (s[i]<>' ') then write(s[i]);\n inc(i);\n end;\n end;\nend."}, {"source_code": "program tcupA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, p, f: integer;\n s: string;\nbegin\n readln(n);\n readln(s);\n p:=pos('ogo', s);\n while p <> 0 do begin\n Delete(s, p, 3);\n Insert('***', s, p);\n f:=1;\n while f <> 0 do\n if (s[p+3] ='g') and (s[p+4] = 'o') then\n Delete(s, p+3, 2)\n else\n f:=0;\n p:=pos('ogo', s);\n end;\n writeln(s);\n readln; readln;\nend.\n "}, {"source_code": "program z1;\nvar s: string;\n k,i,n: integer;\nbegin\n readln(n);\n readln(s);\n k:=pos('ogo',s);\n while k>0 do begin\n i:=k+3;\n while (i 0 do\n begin\n plase := pos('ogo', s);\n s[plase] := '*';\n s[plase + 1] := '*';\n s[plase + 2] := '*';\n while (s[plase + 3] = 'g') and (s[plase + 4] = 'o') do\n delete(s, (plase + 3), 2);\n end;\n writeln(s);\nend.\n"}, {"source_code": "{$mode delphi}\nvar st,st1:string;\n i,j,n,k,p:integer;\nbegin\n readln(n); k:=1;\n read(st);\n i:=1;\n while i<=n do\n if st[i]='o' then begin\n p:=i mod 2;\n for j:=i+1 to n do begin\n if j mod 2=p then if st[j]='o' then inc(k) else break;\n if j mod 2<>p then if st[j]='g' then inc(k) else break;\n end;\n if k>2 then\n if (st[j]<>'o') and (st[j-1]='g') or (st[j]='g') and (st[j-1]='o') then begin\n st1:=st1+'***g'; inc(i,k); k:=1 end\n else begin\n st1:=st1+'***'; inc(i,k); k:=1; end\n else begin st1:=st1+st[i]; inc(i); k:=1; end;\n end\n else begin st1:=st1+st[i]; inc(i); end;\n\n write(st1);\nend.\n"}, {"source_code": "program ogogo;\n\nvar n, i, j: Byte;\n s, res: String;\n\nbegin\n\n readln (n);\n readln (s);\n\n for i := 3 to n do\n begin\n if (s[i-2] = 'o') and (s[i-1] = 'g') and (s[i] = 'o') then\n begin\n for j := 0 to 2 do\n begin\n s[i-j] := '*';\n end;\n while (i < n-1) and (s[i+1] = 'g') and (s[i+2] = 'o') do\n begin\n delete (s, i+1, 2);\n dec (n, 2);\n end;\n end;\n end;\n\n writeln (s);\n\nend."}, {"source_code": "var y,j,i,n:integer; s,s1:string;\nbegin\nreadln (n);\nreadln (s);\ns1:=s;\nfor j:=1 to n do begin\ni:=pos ('ogo',s1);\nif i<>0 then \nbegin delete (s1,i,3); insert ('***',s1,i); end; \nfor y:=1 to n-i-4 do\nif (s1[i+3]='g') and (s1[i+4]='o' )then begin delete (s1,i+3,2); end;\nend;\nwrite(s1);\nend."}, {"source_code": "var a, b: String; i, n, j, k: integer;\nbegin\n\nreadln(n);\nreadln(a);\n\nj:=0;\n\ni:=1;\n\nwhile i<=n do\nbegin\n\n k:=0;\n\n if (a[i]='o') and (a[i+1]='g') and (a[i+2]='o') then\n begin\n \n if (i+4<=n) and (a[i+3]='g') and (a[i+4]='o') then\n begin\n \n j:=i+5;\n \n while (j 'G' then begin\n write(s[i]);\n end;\n end;\nend."}, {"source_code": "var s:string;\nn,i,l,k:integer;\nbegin\n readln(n);\n readln(s);\n i:=1;\n i:=pos('ogo',s);\n while i<>0 do\n begin\n delete(s,i,3);\n insert('***',s,i);\n l:=length(s);\n k:=3;\n while((i+k+1)<=l) and (s[i+k]='g') and (s[i+k+1]='o') do\n begin\n delete(s,i+k,2);\n l:=l-2;\n end;\n i:=pos('ogo',s);\n end;\n write(s);\nend."}, {"source_code": "Var n:byte;\n s:string; \nFunction poisk(n:byte;s:string):string;\nVar d:string;\n k:byte;\nBegin\nWhile Pos('ogo',s)<>0 do begin\n d:='ogo';\n while Pos(d,s)<>0 do d:=d+'go';\n Delete(d,length(d)-2,2);\n k:=Pos(d,s);\n Delete(s,k,length(d));\n Insert('***',s,k)\n end;\npoisk:=s;\nEnd;\nBegin\nreadln(n);\nreadln(s);\nwriteln(poisk(n,s));\nReadln\nEnd."}, {"source_code": "var b,k,n,i:integer; a:array of char;\nbegin\nreadln(n); setlength(a,n+1);\nfor i:=1 to n-1 do\nread(a[i]); readln(a[n]);\nfor i:=1 to n-2 do\nif (a[i]='o') and(a[i+1]='g') and (a[i+2]='o') then\nbegin\na[i]:='*';a[i+1]:='*'; a[i+2]:='*';\nk:=i+3; \nif (k+1<=n) then\nwhile (a[k]='g') and ( a[k+1]='o') do\nbegin\na[k]:='A';a[k+1]:='A'; k:=k+2; if (k+1>n) then break end;\nend;\nfor i:=1 to n do\nBEGIN\nIF (a[i]<>'A') then\nwrite(a[i]); end;\nend."}, {"source_code": "var a:string;\n i,p,n:integer;\n flag:boolean;\nbegin\n readln(n);\n readln(a);\n i:=1;\n while(i<=n) do\n begin\n while(i<=n) and(a[i]<>'o') do\n begin\n write(a[i]);\n inc(i);\n end;\n inc(i);\n flag:=false;\n while(i= 3 do\n begin\n while pos(q, s) <> 0 do\n begin\n j := pos(q, s);\n delete(s, j, length(q));\n insert('***', s, j);\n end;\n delete(q,length(q)-1,2);\n end;\nwriteln(s);\nend."}, {"source_code": "var\n i, n, count: longint;\n c: string;\n f: boolean;\n\nbegin\n readln(n);\n read(c);\n c := c + ' ';\n inc(i);\n repeat\n if (c[i] = 'o') and (c[i+1] = 'g') and (c[i+2] = 'o') then begin\n inc(i, 3);\n while ((c[i] = 'g') and (c[i + 1] = 'o')) do \n inc(i, 2);\n write('***');\n \n end else begin write(c[i]); i:=i+1; end;\n until(i>n);\nend."}, {"source_code": "var s,s1: array [1..1000] of char;\ni,j,k,len: integer;\nbegin\nreadln(len);\nfor i:=1 to len do\nread(s[i]);\ns[len+1]:=' ';\ns[len+2]:=' ';\ni:=1;\nj:=1;\nwhile (i<=len) do begin\nif (s[i]='o') then begin\nif (s[i+1]='g') and (s[i+2]='o') then\nbegin\nwhile ((s[i+1]='g') and (s[i+2]='o')) do begin\ni:= i +2;\nif (i >= len)then break;\nend;\ns1[j]:='*';\ns1[j+1]:='*';\ns1[j+2]:='*';\nj:=j+3;\nend else begin\ns1[j]:=s[i];\ninc(j);\nend;\nend else begin\ns1[j]:=s[i];\ninc(j);\nend;\ninc(i);\nend;\nfor i:=1 to (j-1) do\nwrite(s1[i]);\nend."}, {"source_code": "program a;\nvar s,s1:String;\ni,j,p,n:integer;\nready:boolean;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s)-2 do\nif(copy(s,i,3)='ogo') then begin\nready:=false;\nj:=i+3;\nwhile(ready=false) do begin\ns1:=copy(s,j,2);\nif s1<>'go' then\nready:=true\nelse\nj:=j+2;\nend;\ndelete(s,i,j-i);\ninsert('***',s,i);\nend;\nwriteln(s);\nend."}, {"source_code": "var\n s,c: string;\n p: integer;\nbegin\n readln(p);\n readln(s);\n c:='ogo';\n while length(c)+2<=length(s) do\n c:=c+'go';\n while length(c)>2 do\n begin\n while pos(c,s)>0 do\n begin\n p:=pos(c,s);\n delete(s,p,length(c));\n insert('***',s,p);\n end;\n delete(c,length(c)-1,2);\n end;\n writeln(s);\nend."}, {"source_code": "program project1;\n\nvar\n s, r: string;\n i, p, n, z, l: integer;\n\nlabel\n 1;\nbegin\n readln(n);\n readln(s);\n p := 1;\n while p <= n do\n begin\n r := 'go';\n l := length(s);\n while s[p] <> 'o' do\n Inc(p);\n while copy(s, p + 1, 2) = 'go' do\n Delete(s, p + 1, 2);\n if l > length(s) then\n begin\n Delete(s, p, 1);\n insert('***',s, p);\n end\n else\n Inc(p);\n end;\n\n writeln(s);\n readln;\nend."}, {"source_code": "var\n s : ansistring;\n f : array[0..1500] of longint;\n n,i,j,l : longint;\n\nbegin\n readln(n);\n readln(s);\n i:=1;\n while i <= n-2 do begin\n if s[i]+s[i+1]+s[i+2] = 'ogo' then begin\n l:=i;\n i:=i+3;\n while (i <= n-1) do if s[i]+s[i+1] = 'go' then i:=i+2 else break;\n dec(i);\n f[l]:=i-l+1;\n end;\n inc(i);\n end;\n i:=1;\n while i <= n do begin\n if f[i] = 0 then write(s[i]) else begin write('***'); i:=i+f[i]-1; end;\n inc(i);\n end;\n writeln;\nend."}, {"source_code": "var n,i,j,k:integer;\n a:array [1..100] of string;\ns:string;\nl:char;\nbegin\n readln(n);\n s:='';\n for i:=1 to n do begin\n read(l);\n s:=s+l;\n end;\n i:=1;\n j:=1;\n \n \n \n \n \n \n while i<=length(s) do begin\n k:=0;\n if s[i]='o' then begin\n while (i0 do\n begin\n i:=pos('ogo',s);\n w:=3;\n while(s[i+w]='g')and(s[i+w+1]='o')do inc(w,2);\n delete(s,i,w);\n insert('***',s,i);\n end;\n s:=copy(s,1,length(s)-3);\n writeln(s);\nend.\n"}, {"source_code": "var\n s,v:ansistring;\n i,j,n,ch1,ch2,k,l,o:longint;\nbegin\n readln(n);\n readln(s);\n //v:=s;\n v:='';\n i:=1;\n while i<=n do\n begin\n // writeln(i);\n if(s[i]='o')and(s[i+1]='g')and(s[i+2]='o')then\n begin\n //writeln(i);\n ch1:=i;\n i:=i+3;\n // writeln(ch1);\n if i+1<=n then\n while (s[i]='g')and(s[i+1]='o')do\n begin\n //writeln(n);\n inc(i,2);\n if i+1>n then break;\n end;\n // for j:=ch1 to i-1 do s[j]:='*';\n v:=v+'***';\n end else\n begin inc(i); v:=v+s[i-1]; end;\n end;\n writeln(v);\nend.\n"}, {"source_code": "uses math;\nvar n,d,i,j,ans:longint;\n s,s1:string;\nbegin\nreadln(n);\nread(s);\nn:=length(s);\nif s='ogo' then begin write('***'); halt; end;\nif n<=3 then begin write(s); halt; end;\ni:=1;\nwhile i<=n-2 do\nbegin\ns1:=s[i]+s[i+1]+s[i+2];\nif s1='ogo' then write('***') else write(s[i]);\nif s1='ogo' then begin\n i:=i+3; \n while i0 then\n if (s[i]='g') and (s[i+1]='o') then begin i:=i+2; continue; end else zh:=0;\n if zh=0 then\n begin\n if (s[i]='o') and (s[i+1]='g') and (s[i+2]='o') then begin sans:=sans+'***'; zh:=1; i:=i+3; continue; end;\n sans:=sans+s[i]; inc(i);\n end;\n end;\nwriteln(sans);\nend."}, {"source_code": "var s,c:string;\nn,i,k, x: integer;\nbegin\n readln(n);\n readln(s);\n s:=s+' ';\n k:=1;\n while (pos('ogo', s)>0) do begin\n x:=pos('ogo', s);\n i:=x+3;\n while (s[i]='g')and(s[i+1]='o') do i:=i+2;\n for k:=x to i-1 do begin\n delete(s,x,1);\n end;\n insert('***',s,x);\n end;\n write(s);\nend."}, {"source_code": "var s,s1:string;\n n,i:longint;\nbegin\n readln(n);\n readln(s);\n s1:='';\n i:=1;\n while i<=n do\n if (i+1s[i-1]) do\n inc(i);\n // if s[i]=s[i-1] then inc(i);\n end\n end;\nend."}, {"source_code": "var s:string;\n n,vt,i:byte;\n a:array[1..100] of string;\nbegin\n readln(n);readln(s);a[1]:='ogo';\n For i:=2 to 100 do a[i]:=a[i-1]+'go';\n For i:=100 downto 1 do\n While pos(a[i],s)>0 do\n begin\n vt:=pos(a[i],s);delete(s,vt,length(a[i]));\n insert('***',s,vt);\n end;\n writeln(s); \nend.\n\n"}, {"source_code": "var n,i,j,k,l:longint;\ns,s1,s2:ansistring;\nbegin\nreadln(n);\nreadln(s);\ns1:='ogo';\nwhile pos(s1,s)>0 do begin\n i:=pos(s1,s);\n l:=3;\n delete(s,i,l);\n insert('***',s,i);\n // writeln(s);\n while pos('*go',s)>0 do begin\n i:=pos('*go',s);\n l:=3;\n delete(s,i,l);\n insert('*',s,i);\n // writeln(s);\n end;\nend;\ns1:='*go';\n//writeln;\nwhile pos(s1,s)>0 do begin\n i:=pos(s1,s);\n l:=3;\n delete(s,i,l);\n insert('*',s,i);\n// writeln(s);\nend;\nwriteln(s);\nend."}, {"source_code": "var n,now:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n now:=1;\n while(now+2<=n)do\n begin\n if(s[now]<>'o')or(s[now+1]<>'g')or(s[now+2]<>'o')then begin write(s[now]);inc(now);continue;end;\n now:=now+3;write('***');\n while(now+1<=n)and(s[now]='g')and(s[now+1]='o')do begin ;now:=now+2;end;\n end;\n while(now<=n)do begin write(s[now]);inc(now);end;\n writeln;\nend."}, {"source_code": "var n,i,j:integer;\ns:string;\na:array[1..100] of char;\nbegin\nreadln(n);\nreadln(s);\ni:=1;\nj:=1;\nwhile i<=n-2 do \n if copy(s,i,3)<>'ogo' then begin\n a[j]:=s[i];\n j:=j+1;\n i:=i+1;\n end else begin\n a[j]:='*';\n a[j+1]:='*';\n a[j+2]:='*';\n j:=j+3;\n i:=i+3;\n while (i0) do begin\n x:=pos('ogo', s);\n i:=x+3;\n while (s[i]='g')and(s[i+1]='o') do i:=i+2;\n for k:=x to i-1 do begin\n delete(s,x,1);\n end;\n insert('***',s,x);\n end;\n write(s);\nend."}, {"source_code": "var n, i : integer;\n temp : boolean;\n word : array [1..100] of char;\n\nbegin\n readln(n);\n \n for i := 1 to n do\n read(word[i]);\n\n i := 1;\n temp := false;\n while i <= n do\n begin\n if not(temp) then\n if (word[i] = 'o') and (word[i+1] = 'g') and (word[i+2] = 'o') then\n begin\n write('***');\n i := i + 3;\n temp := true;\n end\n else\n begin\n write(word[i]);\n i := i + 1;\n end\n else\n if (word[i] = 'g') and (word[i+1] = 'o') then\n begin\n i := i + 2;\n end\n else\n temp := false;\n end;\n writeln;\nend."}, {"source_code": "program ideone;\nvar \n\tsrt,strt:string;\n\tirt:longint;\nbegin\n\treadln(irt);readln(srt);\n\tirt:=1;\n\twhile irt<=length(srt) do\n\tbegin\n\t\tif srt[irt]+srt[irt+1]+srt[irt+2]='ogo' then\n\t\tbegin\n\t\t\tstrt:=strt+'***';irt:=irt+3;\n\t\t\twhile srt[irt]+srt[irt+1]='go'\n\t\t\t do irt:=irt+2;\n\t\tend\n\t\telse \n\t\tbegin\n\t\t\tstrt:=strt+srt[irt]; irt:=irt+1;\n\t\tend;\n\tend;\n\twriteln(strt);\nend."}, {"source_code": "program ideone;\nvar \n\ts,st:string;\n\ti:longint;\nbegin\n\treadln(i);\n\treadln(s);\n\ti:=1;\n\twhile i<=length(s) do\n\tbegin\n\t\tif s[i]+s[i+1]+s[i+2]='ogo' then\n\t\tbegin\n\t\t\tst:=st+'***';\n\t\t\ti:=i+3;\n\t\t\twhile s[i]+s[i+1]='go' do i:=i+2;\n\t\tend\n\t\telse \n\t\tbegin\n\t\t\tst:=st+s[i];\n\t\t\ti:=i+1;\n\t\tend;\n\tend;\n\twriteln(st);\nend."}, {"source_code": "var s , res : string;\n\tj , i , n : integer;\n\nbegin\n\treadln(n);\n\treadln(s);\n\ts := s + 'aa';\n\ti := 1;\n\tres := '';\n\twhile i <= n do begin\n\t\tif (s[i] = 'o') and (s[i + 1] = 'g') and (s[i + 2] = 'o') then begin\n\t\t\tres := res + '***';\n\t\t\tj := i + 3;\n\t\t\twhile (j <= n - 1) and (s[j] + s[j + 1] = 'go') do inc(j , 2);\n\t\t\ti := j;\n\t\tend else begin\n\t\t\tres := res + s[i];\n\t\t\tinc(i);\n\t\tend;\n\tend;\n\twriteln(res);\nend."}, {"source_code": "\nconst\n tfi='';\n tfo='';\n\nvar\n fi, fo: text;\n n: longint;\n s, res: string;\n\nprocedure __;\nvar\n i, j: longint;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, n); readln(fi, s);\n i := 1;\n while i<=n do\n begin\n if (s[i]='o') and (i<=n-2) and (s[i+1]='g') and (s[i+2]='o') then\n begin\n res := res+'***';\n j := i+3;\n while j<=n-1 do\n if (s[j]='g') and (s[j+1]='o') then j := j+2\n else break;\n i := j;\n end\n else\n begin\n res := res+s[i]; inc(i);\n end;\n end;\n writeln(fo, res);\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n __;\n _;\nEND.\n\n"}], "negative_code": [{"source_code": "type\n mass=array of string;\nvar a:mass;\n n,i,j:integer;\n s:string;\nbegin\nreadln(n);\nreadln(s);\nsetLength(a, n);\nfor i:=0 to n-1 do\n begin;\n a[i]:=copy(s, i+1, 1);\n end;\ni:=0;\nwhile i0 do\nbegin\n o:=0;\n i:=0;\n i:=pos('ogo',s);\nif i>0 then begin n:=n-3; o:=1; end;\n x:=pos('ogo',s);\n delete(s,x,3);\n insert('***',s,x);\n u:=copy(s,x+2,3);\nif u = '*go' then begin delete(s,x+3,2); n:=n-2; o:=1 end\nelse\n begin\n if o = 0 then n:=n-1;\n end;\ni:=pos('ogo',s);\nif i=0 then n:=0;\nend;\na:=length(s);\nwhile a<>0 do\nbegin\nx:=pos('*go',s);\nif x>0 then\ndelete(s,x+1,2)\nelse\na:=0\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\na:=1;\nwhile a<>0 do\nbegin\na:=pos('ogo',s);\ndelete(s,a,3);\ninsert('***',s,a);\na:=pos('*go',s);\nif a <> 0 then delete(s,a+1,2);\na:=pos('ogo',s);\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\nwhile n > 0 do\nbegin\na:=pos('ogo',s);\nb:=pos('*go',s);\nif (a > 0) or (b > 0) then begin\nb:=pos('*go',s);\nif b > 0 then begin delete(s,b+1,2); n:=n-2; end;\na:=pos('ogo',s);\nif (a > 0) then begin n:=n-3;\ndelete(s,a,3);\ninsert('***',s,a);\nend;\nend\nelse n:=n-1;\nwriteln(s);\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\nwhile n > 0 do\nbegin\na:=pos('ogo',s);\nb:=pos('*go',s);\nif (a > 0) or (b > 0) then begin\nb:=pos('*go',s);\nif b > 0 then begin delete(s,b+1,2); n:=n-2; end;\na:=pos('ogo',s);\nif (a > 0) then begin n:=n-3;\ndelete(s,a,3);\ninsert('***',s,a);\nend;\nend\nelse n:=n-1;\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns:string;\nn,a,b:longint;\nbegin\nreadln(n);\nreadln(s);\nwhile n > 0 do\nbegin\na:=pos('ogo',s);\nb:=pos('*go',s);\nif (a > 0) or (b > 0) then begin\nif (a > 0) then begin n:=n-3;\ndelete(s,a,3);\ninsert('***',s,a);\nend;\nif b > 0 then begin delete(s,b+1,2); n:=n-2; end; end\nelse n:=n-1;\nend;\nwriteln(s);\nend."}, {"source_code": "var s,s1:string;\n l,p:char;\n i,n,k:integer;\n begin\n readln(n);\n readln(s);\n \n l:='1';\n \n for i:=1 to n do\n s1:=s1+'0';\n \n i:=1;\n \n while(i<=n-2) do\n begin\n if(s[i]='o')and(s[i+1]='g')and(s[i+2]='o') then\n begin\n s1[i]:=l;\n s1[i+1]:=l;\n s1[i+2]:=l;\n i:=i+3;\n k:=1;\n while(k=1) do\n begin\n if(i>n-1) then\n begin\n k:=0;\n break;\n end;\n if(i<=n-1) then\n if(s[i]='g')and(s[i+1]='o') then\n begin\n s1[i]:=l;\n s1[i+1]:=l;\n i:=i+2;\n end;\n if(i<=n-1) then\n if(s[i]<>'g')or(s[i+1]<>'o') then\n begin\n l:=chr(ord(l)+1);\n k:=0;\n i:=i-1;\n break;\n end;\n end;\n end;\n i:=i+1;\n end;\n \n writeln(s);\n writeln(s1);\n \n i:=1;\n \n while(i<=n) do\n begin\n \n if(s1[i]<>'0') then\n begin\n write('***');\n p:=s1[i];\n while(i<=n)do\n begin\n if(s1[i]='0')or(s1[i]<>p) then break;\n if(s1[i]<>'0') then i:=i+1;\n end;\n end;\n if(i<=n) then\n if(s1[i]='0') then\n begin\n write(s[i]);\n i:=i+1;\n end;\n end;\n end."}, {"source_code": "var S : string;\nn, i : integer;\ncheck : Boolean;\n\nbegin\ncheck:=false;\nreadln(n);\nreadln(S);\ni:=1;\nrepeat\n if check\n then if ((S[i]='g') and (S[i+1]='o')) then i:=i+1 else begin write(S[i]); check:=false; end\n else\n if ((S[i]<>'o') and (S[i]<>'g'))\n then write(S[i])\n else\n if ((S[i]='o') and (S[i+1]='g') and (S[i+2]='o'))\n then begin check:=true; write('***'); i:=i+2; end\n else write(S[i]);\ni:=i+1;\nuntil i>n;\nend.\n"}, {"source_code": "var S : string;\nn, i : integer;\ncheck : Boolean;\n\nbegin\ncheck:=false;\nreadln(n);\nreadln(S);\ni:=1;\nrepeat\n if check\n then if ((S[i]='g') and (S[i+1]='o')) then i:=i+1 else begin write(S[i]); check:=false; end\n else\n if ((S[i]<>'o') and (S[i]<>'g'))\n then write(S[i])\n else\n if ((S[i]='o') and (S[i+1]='g') and (S[i+2]='o'))\n then begin check:=true; write('***'); i:=i+2; end;\ni:=i+1;\nuntil i>n;\nend.\n"}, {"source_code": "var\n s,p:string;\n k,i,n:longint;\nbegin\nreadln(n);\nreadln(s);\np:='ogo';\ni:=1;\nwhile i<=length(s) do begin\nif copy(s,i,3)=p then begin\n delete(s,i,3);\n k:=i;\n if copy(s,k,2)='go' then begin\n while copy(s,k,2)='go' do\n k:=k+2;\n delete(s,i,k-2);\n end;\n insert('***',s,i);\n i:=i+3;\n end\n else i:=i+1;\nend;\nwriteln(s);\nend."}, {"source_code": "var\n n,i,j: longint;\n s,t: shortstring;\nbegin\n readln(n);\n readln(s);\n s:=s+'#';\n i:=1;\n while i <= n do\n begin\n if s[i] = 'o' then for j:=i to n do\n begin\n if (s[j] = 'g') and (s[j+1] <> 'o') then\n begin\n t:=t+'***';\n i:=j-1;\n break;\n end;\n\n if (s[j] = 'o') and (s[j+1] <> 'g') then\n begin\n t:=t+'***';\n i:=j;\n break;\n end;\n end else t:=t+s[i];\n\n inc(i);\n end;\n\n writeln(t);\nend.\n"}, {"source_code": "var t,s: ansistring;\n i,n,j: longint;\n\nprocedure xuli;\n begin\n i:=1;\n repeat\n if s[i]='o' then\n begin\n j:=i+1;\n while s[j]+s[j+1]='go' do inc(j,2);\n write('***');\n i:=j;\n end\n else\n begin write(s[i]); inc(i); end;\n until i>n;\n end;\n\nBEGIN\n \n readln(n);\n readln(s);\n s:=s+'aa'; \n xuli;\n \nEND.\n\n"}, {"source_code": "\n\nvar s:string;\nn,i,j:longint;\n\nbegin\n\nreadln(n);\nreadln(s);\nj:=1;\nfor i:=1 to n do\n begin\n if s[i]='o' then\n begin\n if (s[i+1]='g') and (s[i+2]='o') and (s[i+3]='g') and (s[i+4]='o') and (s[i+5]='g') and (s[i+6]='o')then\n begin\n delete(s,i,7);\n insert('***',s,i);\n end\n else\n if (s[i+1]='g') and (s[i+2]='o') and (s[i+3]='g') and (s[i+4]='o') then\n begin\n delete(s,i,5);\n insert('***',s,i);\n end\n else\n if (s[i+1]='g') and (s[i+2]='o') then\n begin\n delete(s,i,3);\n insert('***',s,i);\n end;\n end;\n if i>length(s) then break;\n end;\nwriteln(s);\nend.\n\n\n\n\n"}, {"source_code": "\nvar a,s:string;\ni,n,t,d:longint;\n\nbegin\nreadln(n);\nreadln(s);\na:='';\ni:=1;\nt:=0;d:=0;\nwhile i<=length(s) do\n begin\n if s[i]='o' then\n begin\n if s[i+1]+s[i+2]='go' then\n begin\n inc(d);\n t:=1;\n i:=i+2;\n end\n else\n if s[i+1]+s[i+2]<>'go' then\n begin\n if d<>0 then\n begin\n if t=1 then a:=a+'***'\n else a:=a+'o';\n t:=0;\n end;\n inc(i);\n d:=0;\n end;\n end;\n if i<=length(s) then\n begin\n if s[i]<>'o' then\n begin\n a:=a+s[i];\n inc(i);\n end;\n end;\n end;\nwriteln(a);\nend.\n"}, {"source_code": "\nvar a,s:string;\ni,n,t,d:longint;\n\nbegin\nreadln(n);\nreadln(s);\na:='';\ni:=1;\nt:=0;d:=0;\nwhile i<=length(s) do\n begin\n if s[i]='o' then\n begin\n inc(d);\n if s[i+1]+s[i+2]='go' then\n begin\n t:=1;\n i:=i+2;\n end\n else\n if s[i+1]+s[i+2]<>'go' then\n begin\n inc(i);\n end;\n end;\n if s[i]<>'o' then\n begin\n if d<>0 then\n begin\n if t=1 then a:=a+'***'\n else a:=a+'o';\n t:=0;\n end;\n d:=0;\n end;\n if s[i]<>'o' then\n begin\n a:=a+s[i];\n inc(i);\n end;\n end;\nwriteln(a);\nend.\n\n\n"}, {"source_code": "\nvar a,s:string;\ni,n,t,d:longint;\n\nbegin\nreadln(n);\nreadln(s);\na:='';\ni:=1;\nt:=0;d:=0;\nwhile i<=length(s) do\n begin\n if s[i]='o' then\n begin\n inc(d);\n if s[i+1]+s[i+2]='go' then\n begin\n t:=1;\n i:=i+2;\n end\n else\n if s[i+1]+s[i+2]<>'go' then\n begin\n inc(i);\n end;\n end;\n if s[i]<>'o' then\n begin\n if d<>0 then\n begin\n if t=1 then a:=a+'***'\n else a:=a+'o';\n t:=0;\n end;\n d:=0;\n end;\n if i<=n then\n begin\n if s[i]<>'o' then\n begin\n a:=a+s[i];\n inc(i);\n end;\n end;\n end;\nwriteln(a);\nend.\n\n\n"}, {"source_code": "var a,s:string;\ni,n,t,d:longint;\n\nbegin\nreadln(n);\nreadln(s);\na:=' ';\ni:=1;\nt:=0;d:=0;\nwhile i<=length(s) do\n begin\n if s[i]='o' then\n begin\n inc(d);\n if s[i+1]+s[i+2]='go' then\n begin\n t:=1;\n i:=i+2;\n end\n else\n if s[i+1]+s[i+2]<>'go' then\n begin\n inc(i);\n end;\n end;\n if s[i]<>'o' then\n begin\n if d<>0 then\n begin\n if t=1 then a:=a+'***'\n else a:=a+'o';\n t:=0; \n end;\n d:=0;\n end;\n if s[i]<>'o' then\n begin\n a:=a+s[i];\n inc(i);\n end;\n end;\nwriteln(a);\nend.\n\n\n"}, {"source_code": "program ZadachaA;\nvar x,y,z:integer;\n n:integer;\n s,s1:string; \nBegin\n Readln(n);\n Readln(s);\n for x:=1 to n do\n Begin\n y:=y+1;\n if (y>n-2) and (z=0) then\n Begin\n if (y=n) then s1:=s1+s[y];\n if (y=n-1) then s1:=s1+s[y]+s[y]+s[y+1];\n break;\n end;\n if z<>0 then\n Begin\n if y=n then\n Begin\n s1:=s1+s[y];\n break;\n end;\n if (s[y]='g') and (s[y+1]='o') then\n Begin\n y:=y+1;\n end\n else\n Begin\n if (y>n-2) and (z=0) then\n Begin\n if (y=n) then s1:=s1+s[y];\n if (y=n-1) then s1:=s1+s[y]+s[y]+s[y+1];\n break;\n end;\n if (s[y]='o') and (s[y+1]='g') and (s[y+2]='o') then\n Begin\n y:=y+2;\n z:=1;\n s1:=s1+'***';\n end\n else\n Begin\n s1:=s1+s[y];\n z:=0;\n end;\n end;\n end\n else\n Begin\n if (s[y]='o') and (s[y+1]='g') and (s[y+2]='o') then\n Begin\n y:=y+2;\n z:=1;\n s1:=s1+'***';\n end\n else s1:=s1+s[y];\n end;\n if (y=n) then break;\n end;\n Write(s1);\nend."}, {"source_code": "var s:string;\n n,i,j,a,b:longint;\nbegin\n readln(n);\n readln(s);\n j:=-1;\n s:=s+'1';\n while i <= n do\n begin\n if (s[i]='o') and (s[i+1]='g') and (s[i+2]='o') then\n begin s[i]:='*';s[i+1]:='*';s[i+2]:='*'; inc(i,2); writeln(i);\n while (s[i+1]='g') and (s[i+2]='o') do delete(s,i+1,2);end;\n inc(i);\n\n end;\n\n delete(s,length(s),1);\nwriteln(s);end.\n"}, {"source_code": "Const fi='';//phongvan.inp\n fo='';\n dem='ogo';\n og='go';\n thaythe='***';\nVar s:string;\n n:integer;\n f,g:text;\nProcedure Openfile;\nBegin\n Assign(f,fi);reset(f);\n Assign(g,fo);rewrite(g);\nEnd;\n\nProcedure Input;\nBegin\n Readln(f,n);\n Readln(f,s);\nEnd;\n\nProcedure Process;\nVar i,d,cd:integer;\n sp:string;\n ok:boolean;\nBegin\n While pos(dem,s)<>0 do\n Begin\n sp:='';\n d:=pos(dem,s);\n delete(s,d,3);\n Insert(thaythe,s,d);\n OK:=true;\n d:=d+2;\n While OK=True do\n Begin\n Inc(d);\n if d+1>length(s) then break;\n sp:=sp+s[d];\n If length(sp)=2 then\n If sp=og then\n Begin\n sp:='';\n delete(s,d-1,2);\n d:=d-2;\n End\n else OK:=false;\n End;\n {For i:=d+3 to n do\n Begin\n If length(sp)=2 then\n Begin\n If sp<>og then\n Begin\n delete(s,d+3,cd);\n break;\n End\n else\n Begin\n cd:=cd+2;\n sp:='';\n sp:=sp+s[i];\n End\n End else sp:=sp+s[i];\n End; }\n End;\nEnd;\n\nProcedure Output;\nBegin\n Write(g,s);\nEnd;\n\nProcedure Closefile;\nBegin\n Close(f);\n Close(g);\nEnd;\n\nBEGIN\n Openfile;\n Input;\n Process;\n Output;\n Closefile;\nEND.\n"}, {"source_code": "{$mode delphi}\nvar st,st1:string;\n i,j,n,k,p:integer;\nbegin\n readln(n); k:=1;\n read(st);\n i:=1;\n while i<=n do\n if st[i]='o' then begin\n p:=i mod 2;\n for j:=i+1 to n do begin\n if j mod 2=p then if st[j]='o' then inc(k) else break;\n if j mod 2<>p then if st[j]='g' then inc(k) else break;\n end;\n if k>2 then\n if (st[j]<>'o') and (st[j-1]='g') then begin\n st1:=st1+'***g'; inc(i,k); k:=1 end\n else begin\n st1:=st1+'***'; inc(i,k); k:=1; end\n else begin st1:=st1+st[i]; inc(i); k:=1; end;\n end\n else begin st1:=st1+st[i]; inc(i); end;\n\n write(st1);\nend.\n"}, {"source_code": "var\n s, b, ans, l: string;\n n, i, q, cnt: longint;\nbegin\n readln(n);\n readln(s);\n ans := '';\n i := 3;\n while i <= n do\n begin\n l := s[i - 2] + s[i - 1] + s[i];\n if (l = 'ogo') then\n begin\n cnt := 0;\n if i + 2 <= n then\n begin\n q := i + 2;\n while (q <= n) and (s[q - 1] + s[q] = 'go') do\n begin\n q := q + 2;\n inc(cnt);\n end;\n if (cnt <> 0) then\n begin\n i := q - 2;\n end;\n end;\n if cnt = 0 then\n i := i + 2;\n ans := ans + '***';\n end\n else\n begin\n if i <= n - 2 then\n ans := ans + s[i - 2]\n else\n ans := ans + s[i];\n end;\n inc(i);\n end;\n writeln(ans);\nend."}, {"source_code": "var s:string;\nn,i,k:integer;\nbegin\nreadln(n);\nreadln(s);\ni:=1;\nk:=1;\nwhile i<(n-3) do begin\nif (s[i]='o') and (s[i+1]='g') and (s[i+2]='o') then begin\ns[i]:='*';\ns[i+1]:='*';\ns[i+2]:='*';\nfor k:=1 to n do \nif (i+1+2)<=length(s)then begin\nif (s[i+1+2]='g') and (s[i+2+2]='o') then begin\ndelete(s,i+1+2,2);end;end\nelse break;\ni:=i+3;\nend\nelse i:=i+1;\nend;\nwriteln(s);\nend."}, {"source_code": "var s:string;\nn,i,j,k:integer;\nbegin\nreadln(n);\nreadln(s);\ni:=1;\nk:=1;\nwhile i<(n-1) do begin\nif (s[i]='o') and (s[i+1]='g') and (s[i+2]='o') then begin\ns[i]:='*';\ns[i+1]:='*';\ns[i+2]:='*';\nfor k:=1 to 10 do\nif (i+1+2*k)'g' then\n while (s[j]<>'o') and (j<=n) do\n inc(j);\n if (s[j+1]='g') and (s[j+2]='o') then\n begin\n s[j]:='*';\n x:=s[j+1];\n s[j+1]:='*';\n y:=s[j+2];\n s[j+2]:='*';\n j:=j+3;\n end\n else\n if (s[j]='g') and (s[j+1]='o') then\n delete(s,j,2)\n else j:=j+1;\n n:=length(s)-3;\n i:=j\n end;\n i:=length(s);\n while (i>=1) and (s[i]='#') do\n begin\n delete(s,i,1);\n i:=length(s);\n end;\n writeln(g,s);\nend;\nbegin\n\n open_file;\n write_in;\n process;\n close_file;\nend.\n\n"}, {"source_code": "program interview;\nconst fi='';\n fo='';\nvar f,g:text;\n s,m:ansistring;\n n:Longint;\nprocedure open_file;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure close_file;\nbegin\n close(f);\n close(g);\nend;\nprocedure write_in;\nbegin\n readln(f,n);\n readln(f,s);\nend;\nprocedure process;\nvar i,j:longint;\n x,y:char;\nbegin\n s:=s+' ';\n i:=1;\n while i<=n do\n begin\n j:=i;\n while (s[j]<>'o') and (j<=n) do\n inc(j);\n if (s[j+1]='g') and (s[j+2]='o') then\n begin\n x:=s[j];\n s[j]:='*';\n y:=s[j+1];\n s[j+1]:='*';\n j:=j+2;\n end\n else\n if (s[j]='o') then\n if (s[j+1]<>'g') or (s[j+2]<>'o') then\n if (x='o') and (y='g') then\n begin\n x:=y;\n y:='o';\n s[j]:='*';\n j:=j+1;\n end\n else\n j:=j+1;\n i:=j;\n end;\n i:=length(s);\n while (i>=1) and (s[i]=' ') do\n begin\n delete(s,i,1);\n i:=length(s);\n end;\n writeln(g,s);\nend;\nbegin\n open_file;\n write_in;\n process;\n close_file;\nend.\n"}, {"source_code": "program interview;\nconst fi='';\n fo='';\nvar f,g:text;\n s,m:ansistring;\n n:Longint;\nprocedure open_file;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure close_file;\nbegin\n close(f);\n close(g);\nend;\nprocedure write_in;\nbegin\n readln(f,n);\n readln(f,s);\nend;\nprocedure process;\nvar i,j,d:longint;\n x,y:char;\nbegin\n s:=s+'###';\n i:=1;\n while i<=n do\n begin\n j:=i;\n if s[j]<>'g' then\n while (s[j]<>'o') and (j<=n) do\n inc(j);\n if (s[j+1]='g') and (s[j+2]='o') then\n begin\n s[j]:='*';\n x:=s[j+1];\n s[j+1]:='*';\n y:=s[j+2];\n s[j+2]:='*';\n j:=j+3;\n end\n else\n if (s[j]='g') and (s[j+1]='o') then\n delete(s,j,2)\n else j:=j+1;\n n:=length(s)-3;\n i:=j\n end;\n i:=length(s);\n while (i>=1) and (s[i]='#') do\n begin\n delete(s,i,1);\n i:=length(s);\n end;\n writeln(g,s);\nend;\nbegin\n\n open_file;\n write_in;\n process;\n close_file;\nend.\n"}, {"source_code": "program interview;\nconst fi='';\n fo='';\nvar f,g:text;\n s,m:ansistring;\n n:Longint;\nprocedure open_file;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure close_file;\nbegin\n close(f);\n close(g);\nend;\nprocedure write_in;\nbegin\n readln(f,n);\n readln(f,s);\nend;\nprocedure process;\nvar i,j,d:longint;\n x,y:char;\nbegin\n s:=s+'###';\n i:=1;\n while i<=n do\n begin\n j:=i;\n if s[j]<>'g' then\n while (s[j]<>'o') and (j<=n) do\n inc(j);\n if (s[j+1]='g') and (s[j+2]='o') then\n begin\n s[j]:='*';\n x:=s[j+1];\n s[j+1]:='*';\n y:=s[j+2];\n s[j+2]:='*';\n j:=j+3;\n end\n else\n if (s[j]='g') and (s[j+1]='o') and (y='o') then\n delete(s,j,2)\n else j:=j+1;\n n:=length(s)-3;\n i:=j\n end;\n i:=length(s);\n while (i>=1) and (s[i]='#') do\n begin\n delete(s,i,1);\n i:=length(s);\n end;\n writeln(g,s);\nend;\nbegin\n\n open_file;\n write_in;\n process;\n close_file;\nend.\n\n"}, {"source_code": "program interview;\nconst fi='';\n fo='';\nvar f,g:text;\n s,m:ansistring;\n n:Longint;\nprocedure open_file;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure close_file;\nbegin\n close(f);\n close(g);\nend;\nprocedure write_in;\nbegin\n readln(f,n);\n readln(f,s);\nend;\nprocedure process;\nvar i,j,d:longint;\n x,y:char;\nbegin\n s:=s+'###';\n i:=1;\n while i<=n do\n begin\n j:=i;\n if s[j]<>'g' then\n while (s[j]<>'o') and (j<=n) do\n inc(j);\n if (s[j]='o') and (s[j+1]='g') and (s[j+2]='o') then\n begin\n s[j]:='*';\n x:=s[j+1];\n s[j+1]:='*';\n y:=s[j+2];\n s[j+2]:='*';\n j:=j+3;\n end\n else\n if (s[j]='g') and (s[j+1]='o') and (y='o') then\n delete(s,j,2)\n else j:=j+1;\n n:=length(s)-3;\n i:=j\n end;\n i:=length(s);\n while (i>=1) and (s[i]='#') do\n begin\n delete(s,i,1);\n i:=length(s);\n end;\n writeln(g,s);\nend;\nbegin\n\n open_file;\n write_in;\n process;\n close_file;\nend.\n\n"}, {"source_code": "var\ns,s1:string;\nk,i,n:integer;\nch:char;\nbegin\nreadln(n);\nfor i:=1 to n do \n begin\n read(ch);\n s:=s+ch;\n end;\ns:=s+'0000';\nwhile pos('ogo',s) <> 0 do begin\nk:=pos('ogo',s);\ns1:='';\ns1:=s1+'ogo';\n if k < n-2 then begin\n i:=k+3;\n while (s[i]+s[i+1] = 'go') do \n if s[i]+s[i+1] = 'go' then begin\n s1:=s1+'go';\n i:=i+2;\n end;\n \n end;\n writeln(s1);\n delete(s,k,length(s1));\n insert('***',s,k);\n end;\ndelete(s,length(s)-3,4);\nwriteln(s);\nend."}, {"source_code": "var\ns,s1:string;\nk,i,n:integer;\nch:char;\nbegin\nreadln(n);\nreadln(s);\ns:=s+'0000';\nwhile pos('ogo',s) <> 0 do begin\nk:=pos('ogo',s);\ns1:='';\ns1:=s1+'ogo';\n if k < n-2 then begin\n i:=k+3;\n while (s[i]+s[i+1] = 'go') do \n if s[i]+s[i+1] = 'go' then begin\n s1:=s1+'go';\n i:=i+2;\n end;\n \n end;\n writeln(s1);\n delete(s,k,length(s1));\n insert('***',s,k);\n end;\ndelete(s,length(s)-3,4);\nwriteln(s);\nend."}, {"source_code": "var\ns,s1:string;\nk,i,n:integer;\nch:char;\nbegin\nreadln(n);\nfor i:=1 to n do \n begin\n read(ch);\n s:=s+ch;\n end;\ns:=s+'0000';\nwhile pos('ogo',s) <> 0 do begin\nk:=pos('ogo',s);\ns1:='';\ns1:=s1+'ogo';\n if k < n-2 then begin\n i:=k+3;\n while (s[i]+s[i+1] = 'go') or (s[i]+s[i+1]+s[i+2] = 'ogo' ) do \n if s[i]+s[i+1] = 'go' then begin\n s1:=s1+'go';\n i:=i+2;\n end\n else begin\n s1:=s1+'ogo';\n i:=i+3;\n end;\n end;\n writeln(s1);\n delete(s,k,length(s1));\n insert('***',s,k);\n end;\ndelete(s,length(s)-3,4);\nwriteln(s);\nend."}, {"source_code": "var\n q, s: string;\n n, j, i: integer;\n\nbegin\n readln(n);\n readln(s);\n q := 'ogo';\n for i := 1 to (n - 3) div 2 do\n begin\n q := q + 'go'\n end;\n while length(q) >= 3 do\n begin\n while pos(q, s) <> 0 do\n begin\n j := pos(q, s);\n delete(s, j, length(q));\n insert('***', s, j);\n end;\n delete(q,length(q),2);\n end;\nwriteln(s);\nend."}, {"source_code": "{\n\n\n\n X\n @\n @@@\n r@@@@@@@@@@@@@ @@\n 3@@@@@@@@@ A@@#\n @@@@@@@ @@@@\n @@@@@@@ @@@@&\n @# @@ @5 @@@@h @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@@ @@@@@\n #@@@@@@@@@@@@@@ @@@@@@\n @@@@@@@@@@@@@@@@@: 9@@@@@\n @@@@@@@,@@@@@@@@@@ #@@@@@\n @@@ @@@@@@@@@@ @@@@@@.\n @@@@@@@@@ @@@@@@\n @@@@@@@@@@ @@@@@@@\n s@M @@@@@@@@@ @@@@@@@@\n h@@@@@ @@@@@@@@@@@@@@@@\n M@@@@@@@@@@ @@@@@@@@@@@@@#\n #@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@\n @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n S@@@@@@@@@@@; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @@@@@@@@@@: 9@@@@@@@@@@@@@@@@@@@@@@@@@@@\n M@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@\n @@@ @@@@@@@@@\n @@@@@@@\n @@@\n\n @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@@\n @@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@\n @@@@@@X s@ @@@@@@ @@ @@@@@@ @@ @@@@@ ,@@@@@\n @@@@@@ @@@@@r @@@@@ @@@@@ @@@@@\n @@@@@ @@@@@ @@@@@ @@@@@@@@@@@@;\n @@@@@ @@@@@ @@@@@ @@@@@@@@@@@\n @@@@@ X@@@@@ . @@@@@@ B @@@@@\n @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@ @@@@@\n @@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@\n @@M s@@A 3@@3\n\n\n\n\n\n\n}\n\n\nvar s,ans:string;\n i,z,useless:longint;\nprocedure check(x:longint);\n var i,q:longint;\nbegin\n q:=0;\n for i:=1 to length(s)-x do\n begin\n if ((i mod 2 = 1)and(s[x+i]<>'g'))or((i mod 2 = 0)and(s[x+i]<>'o'))\n then begin q:=i; break; end;\n end;\n if q=0\n then q:=(length(s)-x)+1;\n \n if q>=2\n then begin delete(s,x,1+((q-1) div 2)*2); ans:=ans+'***';end\n else begin ans:=ans+s[z]; inc(z);end;\n\nend;\n\nbegin\n readln(Useless);\n read(s);\n z:=1;\n while z<=length(s) do\n begin\n if s[z]='o'\n then begin\n check(z);\n\n end\n else begin\n inc(z);\n ans:=ans+s[z-1];\n end;\n end;\n \n write(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, s1 : string;\n p, n,i : integer;\n\n\nbegin\n readln(n);\n readln(s);\n p := pos('ogo', s);\n \n repeat\n p := pos('ogo', s);\n if p = 0 then break;\n s[p] := '*';\n s[p+1] := '*';\n s[p+2] := '*';\n i := p+3;\n s1 := Copy(s,i,2);\n while s1 = 'go' do begin\n \n s[i] := '*';\n s[i+1] := '*';\n i := i + 2;\n s1 := Copy(s,i,2);\n end;\n until p=0;\n writeln(s);\n \n\n\n\nend.\n\n"}, {"source_code": "{\n\n\n\n X\n @\n @@@\n r@@@@@@@@@@@@@ @@\n 3@@@@@@@@@ A@@#\n @@@@@@@ @@@@\n @@@@@@@ @@@@&\n @# @@ @5 @@@@h @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@ @@@@@\n @@@@@@@@@@@@ @@@@@\n #@@@@@@@@@@@@@@ @@@@@@\n @@@@@@@@@@@@@@@@@: 9@@@@@\n @@@@@@@,@@@@@@@@@@ #@@@@@\n @@@ @@@@@@@@@@ @@@@@@.\n @@@@@@@@@ @@@@@@\n @@@@@@@@@@ @@@@@@@\n s@M @@@@@@@@@ @@@@@@@@\n h@@@@@ @@@@@@@@@@@@@@@@\n M@@@@@@@@@@ @@@@@@@@@@@@@#\n #@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@\n @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n S@@@@@@@@@@@; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n @@@@@@@@@@: 9@@@@@@@@@@@@@@@@@@@@@@@@@@@\n M@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@\n @@@ @@@@@@@@@\n @@@@@@@\n @@@\n\n @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@@\n @@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@\n @@@@@@X s@ @@@@@@ @@ @@@@@@ @@ @@@@@ ,@@@@@\n @@@@@@ @@@@@r @@@@@ @@@@@ @@@@@\n @@@@@ @@@@@ @@@@@ @@@@@@@@@@@@;\n @@@@@ @@@@@ @@@@@ @@@@@@@@@@@\n @@@@@ X@@@@@ . @@@@@@ B @@@@@\n @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@ @@@@@\n @@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@\n @@M s@@A 3@@3\n\n\n\n\n\n\n}\n\n\nvar s,ans:string;\n i,z,useless:longint;\nprocedure check(x:longint);\n var i,q:longint;\nbegin\n q:=0;\n for i:=1 to length(s)-x do\n begin\n if ((i mod 2 = 1)and(s[x+i]<>'g'))or((i mod 2 = 0)and(s[x+i]<>'o'))\n then begin q:=i; break; end;\n end;\n if q=0\n then q:=(length(s)-x);\n \n if q>=2\n then begin delete(s,x,1+(q div 2)*2); ans:=ans+'***';end\n else begin ans:=ans+s[z]; inc(z);end;\n\nend;\n\nbegin\n readln(Useless);\n read(s);\n z:=1;\n while z<=length(s) do\n begin\n if s[z]='o'\n then begin\n check(z);\n\n end\n else begin\n inc(z);\n ans:=ans+s[z-1];\n end;\n end;\n \n write(ans);\nend."}, {"source_code": "var i,j,n,c:integer;\nA:array[1..110] of char;\nbegin\nreadln(N);\nfor i:=1 to N do\nread(A[i]);\nj:=1;\nwhile j<=N do\nbegin\nc:=0;\nif (A[j]='o') and (A[j+1]='g') and (A[j+2]='o') then\nbegin\nA[j]:='*';\nA[j+1]:='*';\nA[j+2]:='*';\nj:=j+3;\nc:=1;\nwhile (A[j]='g') and (A[j+1]='o') and (j-1<=N) do\nbegin\nA[j]:=chr(13);\nA[j+1]:=chr(13);\nj:=j+2;\nend;\nend;\nif c=0 then\nj:=j+1;\nend;\n\nfor i:=1 to N do\nwrite(A[i]);\nend."}, {"source_code": "var //f,g:text;\n n:longint;\n s,s1:ansistring;\n{procedure openfile;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;}\nprocedure nhap;\nbegin\n readln({f,}n);\n readln({f,}s);\nend;\nprocedure process;\nvar i,j:longint;\nbegin\n i:=1; s1:='';\n while i<=n do\n begin\n j:=i;\n if s[i]='o' then\n begin\n while (j<=n-2)and(s[j]='o')and(s[j+1]='g')and(s[j+2]='o') do j:=j+2;\n s1:=s1+'***';\n end\n else s1:=s1+s[i];\n i:=j+1;\n end;\n write({g,}s1);\nend;\nbegin\n // openfile;\n nhap;\n process;\n //closefile;\nend."}, {"source_code": "program oge202;\nvar k,n,i,j :integer;\ns,o:string;\nbegin\nreadln(n);\nreadln(s);\no:='';\nwhile pos('ogo',s)<>0 do\n begin\n k:=0;\n i:=pos('ogo',s);\n delete(s,i,3);\n insert('***',s,i);\n while copy(s,i+3,2)='go' do\n begin\n delete(s,i+3,2);\n k:=k+1;\n end;\n for j:=1 to k do\n insert('**',s,i+3);\n end;\n writeln(s);\nend.\n"}, {"source_code": "program oge202;\nvar k,n,i,j :integer;\ns,o:string;\nbegin\nreadln(n);\nreadln(s);\no:='';\nwhile pos('ogo',s)<>0 do\n begin\n k:=0;\n i:=pos('ogo',s);\n delete(s,i,3);\n insert('***',s,i);\n while copy(s,i+3,2)='go' do\n begin\n delete(s,i+3,2);\n k:=k+1;\n end;\n for j:=1 to k do\n insert('**',s,i+3);\n end;\n writeln(s);\n readln();\nend.\n"}, {"source_code": "var s:string;\n i,p,n:integer;\n flag:boolean;\nbegin\n readln(n);\n readln(s);\n p:=pos('o', s);\n while(p<>0) do\n begin\n i:=p+1;\n flag:=true;\n while flag and (i 0 do\n\tbegin\n\t\tt := pos('ogo', st);\n\t\twhile ((st[t + 3] = 'g') and (st[t + 4] = 'o')) do\n\t\t\tdelete (st, t + 3, 2);\n\t\tt := pos('ogo', st);\n\t\tdelete(st, t, 3);\n\t\tinsert('***', st, t);\n\tend;\n\tdelete(st, length(st) - 1, 2);\n\twrite(st);\nend."}, {"source_code": "var\n i, n, count: longint;\n c: string;\n f: boolean;\n\nbegin\n readln(n);\n read(c);\n c := c + ' ';\n for i := 1 to n do \n begin\n if c[i] = 'o' then if c[i] = 'g' then if c[i] = 'o' then begin\n inc(count, 3);\n f := true;\n while ((c[i] = 'g') and (c[i + 1] = 'o')) do \n inc(count, 2);\n if f = true then begin\n write('**');\n f := false;\n end\n else write(c[i]);\n end;\n end;\nend."}, {"source_code": "program a;\nvar s,s1:String;\ni,j,p,n:integer;\nready:boolean;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s)-2 do\nif(copy(s,i,3)='ogo') then begin\nready:=false;\nj:=i+3;\nwhile(ready=false) do begin\ns1:=copy(s,j,2);\nif s1<>'go' then\nready:=true\nelse\nj:=j+2;\nend;\ndelete(s,i,j-i);\ns1:='*';\nfor p:=i to j-1 do\ninsert(s1,s,p);\nend;\nwriteln(s);\nend."}, {"source_code": "var\ns: string;\n\nprocedure cut(i: integer);\nvar\n j:integer;\nbegin\n s[i]:='*';\n s[i+1]:='*';\n s[i+2]:='*';\n for j:=i+3 to length(s)-1 do\n begin\n if (s[j]='g')and(s[j+1]='o') then\n begin\n s[j]:='*';\n s[j+1]:='*';\n if (j+22 do\n begin\n writeln('c: ',c);\n while pos(c,s)>0 do\n begin\n p:=pos(c,s);\n delete(s,p,length(c));\n insert('***',s,p);\n writeln('s: ',s);\n end;\n delete(c,length(c)-1,2);\n end;\n writeln(s);\nend."}, {"source_code": "var\ns: string;\n\nprocedure cut(i: integer);\nvar\n j:integer;\nbegin\n s[i]:='*';\n s[i+1]:='*';\n s[i+2]:='*';\n for j:=i+3 to length(s)-1 do\n begin\n if (s[j]='g')and(s[j+1]='o') then\n begin\n s[j]:='*';\n s[j+1]:='*';\n if (j+2length(t)) and (t[i-1]=t[j-1]) and (copy(t,1,mem-1)<>copy(t,mem,length(t)-mem+1)) then kek:=1\n else i:=mem+1;\n end;\n \n if kek=1 then begin\n writeln('YES');\n writeln(s);\n end\n else writeln('NO');\n end;\nend."}, {"source_code": "var n,i,j:integer;\n a:array [1..100] of string;\ns:string;\nl:char;\nbegin\n readln(n);\n s:='';\n for i:=1 to n do begin\n read(l);\n s:=s+l;\n end;\n i:=1;\n while i<=length(s) do begin\n j:=i;\n if (s[j]='o') and (s[j+1]='g') and (s[j+2]='o') then begin\n a[j]:='*';\n a[j+1]:='*';\n a[j+2]:='*';\n end\n else\n if a[j]<>'*' then a[j]:=s[j];\n i:=i+1;\n \n end;\n for i:=1 to n do write(a[i]);\nend. \n \n \n \n "}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul={1000000007}{998244353}100;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n zan1,zan2:array[-1000..200000,-2..26] of boolean;\n marked1,marked2:array[-2000..2000000] of boolean;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n dd,ddr:array[-1..1502,-1..1502] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;\n str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,heshh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]'o')) then fl:=false;\n if ss[rr]<>'o' then fl:=false;\n ogo:=fl;\nend;\n\nfunction maxogo(ll,rr:longint):boolean;\nvar i,j:longint; fl:boolean;\nbegin\n fl:=ogo(ll,rr);\n if ogo(ll-2,rr) or ogo(ll,rr+2) then fl:=false;\n if rr-ll<2 then fl:=false;\n maxogo:=fl;\nend;\n\n\n\n\nbegin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n { writeln(ss);\n } for i:=1 to n do for j:=i to n do if maxogo(i,j) then begin inc(q); x[q]:=i;y[q]:=j; end;\n zan[n+1]:=true;\n { for i:=1 to q do writeln(x[i],' ',y[i]);\n } for i:=1 to q do for j:=x[i] to y[i]-1 do zan[j]:=true;\n for i:=1 to n do if not zan[i] and not zan[i+1] then write(ss[i]) else if (zan[i] and not zan[i-1]) then write('***');\n\n\n\n\n\n\n\n goto 1;\n\n readln(p,t);\n q:=1;\n x[1]:=p;\n ll:=q;\n rr:=q;\n for step:=1 to 30 do\n begin\n for i:=ll to rr do if 2*x[i]<2000000000 then begin inc(q); x[q]:=2*x[i]; y[q]:=i; end;\n for i:=ll to rr do if 10*x[i]+1<2000000000 then begin inc(q); x[q]:=10*x[i]+1; y[q]:=i; end;\n ll:=rr+1; rr:=q;\n\n end;\n\n writeln('q= ',q);\n for i:=1 to q do write(x[i],' '); writeln;\n\n for i:=1 to q do if x[i]=t then begin flag:=true; ii:=y[i]; end;\n if not flag then writeln('NO');\n\n while (y[ii]<>1)and(tt<100) do begin inc(tt); z[tt]:=y[ii]; ii:=y[ii]; end;\n\n writeln('tt= ',tt);\n { for i:=1 to tt do write(x[])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul={1000000007}{998244353}100;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n zan1,zan2:array[-1000..200000,-2..26] of boolean;\n marked1,marked2:array[-2000..2000000] of boolean;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n dd,ddr:array[-1..1502,-1..1502] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;\n str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,heshh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]'o')) then fl:=false;\n if ss[rr]<>'o' then fl:=false;\n ogo:=fl;\nend;\n\nfunction maxogo(ll,rr:longint):boolean;\nvar i,j:longint; fl:boolean;\nbegin\n fl:=ogo(ll,rr);\n if ogo(ll-2,rr) or ogo(ll,rr+2) then fl:=false;\n if rr-ll<2 then fl:=false;\n maxogo:=fl;\nend;\n\n\n\n\nbegin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n);\n readln(ss);\n { writeln(ss);\n } for i:=1 to n do for j:=i to n do if maxogo(i,j) then begin inc(q); x[q]:=i;y[q]:=j; end;\n\n { for i:=1 to q do writeln(x[i],' ',y[i]);\n } for i:=1 to q do for j:=x[i] to y[i] do zan[j]:=true;\n for i:=1 to n do if not zan[i] then write(ss[i]) else if zan[i] and not zan[i-1] then write('***');\n\n\n\n\n\n\n\n goto 1;\n\n readln(p,t);\n q:=1;\n x[1]:=p;\n ll:=q;\n rr:=q;\n for step:=1 to 30 do\n begin\n for i:=ll to rr do if 2*x[i]<2000000000 then begin inc(q); x[q]:=2*x[i]; y[q]:=i; end;\n for i:=ll to rr do if 10*x[i]+1<2000000000 then begin inc(q); x[q]:=10*x[i]+1; y[q]:=i; end;\n ll:=rr+1; rr:=q;\n\n end;\n\n writeln('q= ',q);\n for i:=1 to q do write(x[i],' '); writeln;\n\n for i:=1 to q do if x[i]=t then begin flag:=true; ii:=y[i]; end;\n if not flag then writeln('NO');\n\n while (y[ii]<>1)and(tt<100) do begin inc(tt); z[tt]:=y[ii]; ii:=y[ii]; end;\n\n writeln('tt= ',tt);\n { for i:=1 to tt do write(x[])\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": "program xssdsd;\nvar i,j,t,x:integer;a:string;\nbegin\nreadln(x);\nreadln(a);\na:=a+'ZZZZ';\nt:=1;\n\nwhile t<=x-2 do begin\nif (a[t]='o')and(a[t+1]='g')and(a[t+2]='o') then begin\na[t]:='*';a[t+1]:='*';a[t+2]:='*';i:=t;end;\nwhile i<=x-2 do begin\nj:=i+3;i:=1;\nwhile (a[j]='g') do begin\nif (a[j]='g')and(a[j+1]='o')then delete(a,j,2);\nj:=j+2;end;\ni:=i+1;\nif a[j]<>'g'then i:=x-1;\nend;\nt:=t+1;\nend;\nfor i:=1 to x do \nif (a[i]<>'Z') then\nwrite(a[i]);\n\n\n\n\n\n\nend."}, {"source_code": "Program A;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\n\nn: longint;\ns:ansistring;\n\nProcedure cut(k: longint);\nVar i, j: longint;\nBEGIN\ni := pos('ogo', s);\nif i = 0 then exit;\nfor j := 0 to 2 do s[i+j] := '*';\nj := i+3;\nwhile (j < n) and (copy(s, j, 2) = 'go') do\n\tbegin\n\ts[j] := '*';\ts[j+1] := '*';\n\tj := j + 2;\n\tend;\nif j < n then cut(j);\nEND;\n\nProcedure Process;\nVar i: longint;\nBEGIN\n\nreadln(fi, n);\nreadln(fi, s);\n\ncut(1);\n\nwriteln(fo, s);\n\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF}\nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND.\n"}, {"source_code": "var\n s:ansistring;\n i,j,n,ch1,ch2,k,l,o:longint;\nbegin\n readln(n);\n readln(s);\n i:=1;\n while in then break;\n end;\n for j:=ch1 to i-1 do s[j]:='*';\n end else\n inc(i);\n end;\n writeln(s);\nend.\n"}, {"source_code": "var n,i,j: integer;\ns: string;\nbegin\nreadln(n); readln(s);\ni:=1;\nrepeat if s[i]<>'o' then write(s[i])\n else begin\n j:=i+1;\n if j>n then break;\n while 'go'=copy(s,j,2) do j:=j+2;\n if j<>i+1 then begin\n write('***');\n i:=j-1;\n end;\n end;\n inc(i);\nuntil i>n;\nreadln\nend.\n"}, {"source_code": "uses math;\nvar n,d,i,j,ans:longint;\n s,s1:string;\nbegin\nreadln(n);\nread(s);\nn:=length(s);\nif s='ogo' then begin write('***'); halt; end;\nif n<=3 then begin write(s); halt; end;\ni:=1;\nwhile i<=n-2 do\nbegin\ns1:=s[i]+s[i+1]+s[i+2];\nif s1='ogo' then write('***') else write(s[i]);\nif s1='ogo' then begin\n i:=i+3; \n while i'*') then\n begin\n t[i-1]:='*';\n t[i]:='*';\n t[i+1]:='*';\n end;\n end;\n \n writeln(t);\nend. "}, {"source_code": "var\n n,i:longint;\n s:string;\nbegin\n readln (n);\n readln (s);\n while pos('ogo',s)<>0 do\n begin\n i:=pos('ogo',s);\n delete(s,i,3);\n while pos('go',s)=i do\n delete (s,i,2);\n insert('***',s,i);\n end;\n writeln (s);\nend.\n"}, {"source_code": "var\n n,i,j:longint;\n s:string;\nbegin\n readln (n);\n readln (s);\n while pos('ogo',s)<>0 do\n begin\n i:=pos('ogo',s);\n delete(s,i,3);\n while pos('go',s)=i do\n delete (s,i,2);\n insert('***',s,i);\n end;\n writeln (s);\nend."}, {"source_code": "var\n n,i,j:longint;\n s,a:string;\n f:boolean;\nbegin\n a:='';\n readln (n);\n readln (s);\n i:=1;\n f:=false;\n while is[i-1]) do\n inc(i);\n if s[i]=s[i-1] then inc(i);\n end\n end;\nend."}, {"source_code": "var st,ch:string;\ni,n,p,p1,p2,p3,p4:longint;\nbegin\n readln(n);\n readln(st);\n ch:='***';\n p:=pos('ogo',st);\n if p=0 then\n begin\n writeln(st);\n halt;\n end;\n while p<>0 do\n begin\n p:=pos('ogo',st);\n p1:=pos('ogo',st);\n while p1<>0 do\n begin\n p1:=pos('ogo',st);\n delete(st,p1,3);\n insert(ch,st,p1);\n p4:=pos('*go',st);\n if p4<>0 then delete(st,p4+1,2);\n end;\n\n {p2:=pos('go',st);\n while p2<>0 do\n begin\n p2:=pos('go',st);\n delete(st,p2,2);\n end; }\n {p3:=pos('*g*',st);\n while p3<>0 do\n begin\n p3:=pos('*g*',st);\n delete(st,p3+1,p3-2);\n end;}\n\n end;\n delete(st,1,3);\n writeln(st);\nend.\n"}, {"source_code": "var st,ch:string;\ni,n,p,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(st);\n n:=length(st);\n ch:='***';\n p:=pos('ogo',st);\n while p<>0 do\n begin\n p:=pos('ogo',st);\n p1:=pos('ogo',st);\n while p1<>0 do\n begin\n if p1=0 then break;\n p1:=pos('ogo',st);\n delete(st,p1,3);\n insert(ch,st,p1);\n end;\n\n p2:=pos('go',st);\n while p2<>0 do\n begin\n p2:=pos('go',st);\n delete(st,p2,2);\n end;\n p3:=pos('*g*',st);\n while p3<>0 do\n begin\n p3:=pos('*g*',st);\n delete(st,p3+1,p3-2);\n end;\n\n end;\n delete(st,1,3);\n writeln(st);\nend.\n"}, {"source_code": "var st,ch:string;\ni,n,p,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(st);\n ch:='***';\n p:=pos('ogo',st);\n if p=0 then\n begin\n writeln(st);\n halt;\n end;\n while p<>0 do\n begin\n p:=pos('ogo',st);\n p1:=pos('ogo',st);\n while p1<>0 do\n begin\n if p1=0 then break;\n p1:=pos('ogo',st);\n delete(st,p1,3);\n insert(ch,st,p1);\n end;\n\n p2:=pos('go',st);\n while p2<>0 do\n begin\n p2:=pos('go',st);\n delete(st,p2,2);\n end;\n p3:=pos('*g*',st);\n while p3<>0 do\n begin\n p3:=pos('*g*',st);\n delete(st,p3+1,p3-2);\n end;\n\n end;\n delete(st,1,3);\n writeln(st);\nend.\n"}, {"source_code": "var st,ch:string;\ni,n,p,p1,p2,p3,p4:longint;\nbegin\n readln(n);\n readln(st);\n ch:='***';\n p:=pos('ogo',st);\n if p=0 then\n begin\n writeln(st);\n halt;\n end;\n while p<>0 do\n begin\n p:=pos('ogo',st);\n p1:=pos('ogo',st);\n while p1<>0 do\n begin\n p1:=pos('ogo',st);\n delete(st,p1,3);\n insert(ch,st,p1);\n p4:=pos('*go',st);\n if p4<>0 then delete(st,p4+1,2);\n end;\n\n {p2:=pos('go',st);\n while p2<>0 do\n begin\n p2:=pos('go',st);\n delete(st,p2,2);\n end; }\n p3:=pos('*g*',st);\n while p3<>0 do\n begin\n p3:=pos('*g*',st);\n delete(st,p3+1,p3-2);\n end;\n\n end;\n delete(st,1,3);\n writeln(st);\nend.\n"}, {"source_code": "var n,i,j,k,l:longint;\n\ns,s1,s2:ansistring;\nbegin\nreadln(n);\nreadln(s);\ns1:='ogo';\nwhile pos(s1,s)>0 do begin\n i:=pos(s1,s);\n l:=3;\n s2:=s1;\n while ((pos(s2,s)>0)and(l0 do begin\n i:=pos(s1,s);\n l:=3;\n s2:=s1;\n while ((pos(s2,s)>0)and(i+l<=n+1)and(pos(s2,s)=i)) do begin\n s2:=s1+'go';\n // writeln(s2);\n l:=l+2;\n end;\n l:=l-2;\n delete(s,i,l);\n insert('***',s,i);\n // writeln(s);\nend;\nwriteln(s);\nend."}, {"source_code": "var n,i,j,k,l:longint;\n\ns,s1,s2:ansistring;\nbegin\nreadln(n);\nreadln(s);\ns1:='ogo';\nwhile pos(s1,s)>0 do begin\n i:=pos(s1,s);\n l:=3;\n s2:=s1;\n while ((pos(s2,s)>0)and(i+l<=n)and(pos(s2,s)=i)) do begin\n s2:=s1+'go';\n // writeln(s2);\n l:=l+2;\n end;\n l:=l-2;\n delete(s,i,l);\n insert('***',s,i);\n // writeln(s);\nend;\nwriteln(s);\nend."}], "src_uid": "619665bed79ecf77b083251fe6fe7eb3"} {"source_code": "const ma=1000003;\nvar\n c:char;\n i,j,k:longint;\n\nfunction cha:longint;\nbegin\n j:=0;\n case c of\n '>':j:=0; '<':j:=1; '+':j:=2;\n '-':j:=3; '.':j:=4; ',':j:=5;\n '[':j:=6; ']':j:=7;\n end;\n exit(j+8);\nend;\n\nbegin\n repeat read(c); k:=(k*16+cha) mod ma; until eoln;\n writeln(k);\nend.", "positive_code": [{"source_code": "uses StrUtils;\nconst\n S1: array [1..8] of string = ('>', '<', '+', '-', '.', ',', '[', ']');\n S2: array [1..8] of string = ('1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111');\nvar\n S: AnsiString;\n i: LongInt;\n n: QWord;\n \nbegin\n Readln(S);\n for i := 1 to 8 do\n S := AnsiReplaceStr(S, S1[i], S2[i]);\n for i := 1 to Length(S) do\n n := (2 * n + (Ord(S[i]) - 48)) mod 1000003;\n Writeln(n);\nend."}, {"source_code": "const nab='><+-.,[]';\n\nvar s:string;\n i,sum:longint;\n begin\n read(s);\n for i:=1 to length(s) do\n sum:=(sum*16+7+pos(s[i],nab))mod 1000003;\n write(sum);\n end."}, {"source_code": "program uio;\n var s,s1:ansistring;\n cis,st:int64;\n d,i:longint;\n\n\nBEGIN\n\n readln(s1); s:='';\n for i:=1 to length(s1) do\n begin\n if s1[i]='>' then s:=s+'1000';\n if s1[i]='<' then s:=s+'1001';\n if s1[i]='+' then s:=s+'1010';\n if s1[i]='-' then s:=s+'1011';\n if s1[i]='.' then s:=s+'1100';\n if s1[i]=',' then s:=s+'1101';\n if s1[i]='[' then s:=s+'1110';\n if s1[i]=']' then s:=s+'1111';\n end;\n\n st:=1; cis:=0; d:=length(s);\n\n for i:=d downto 1 do\n begin\n st:=st mod 1000003; cis:=cis mod 1000003;\n if s[i]='1' then begin\n inc(cis,st);\n end;\n\n st:=st*2;\n end;\n\n\n writeln(cis mod 1000003);\n\nEND.\n"}, {"source_code": "{$O-}\nvar\n i,n,a,b,ans\t:\tlongint;\n p,q : int64;\n s,t\t\t:\tstring;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n readln(s);\n for i:=1 to length(s) do\n \tif s[i] = '>' then t:=t + '1000' else\n \tif s[i] = '<' then t:=t + '1001' else\n \tif s[i] = '+' then t:=t + '1010' else\n \tif s[i] = '-' then t:=t + '1011' else\n \tif s[i] = '.' then t:=t + '1100' else\n \tif s[i] = ',' then t:=t + '1101' else\n \tif s[i] = '[' then t:=t + '1110' else\n \tif s[i] = ']' then t:=t + '1111';\n for i:=length(t) downto 1 do begin\n \ta:=2;\n \tb:=length(t) - i;\n \tp:=1; \n \tq:=2;\n \tif t[i] = '1' then begin\n \t\twhile b > 0 do begin\n \t\t\tif b mod 2 = 1 then p:=(p * q) mod 1000003;\n \t\t\tq:=(q * q) mod 1000003;\n \t\t\tb:=b div 2;\n \t\tend;\n \t\tans:=(ans + p) mod 1000003;\n \tend;\n end;\t\n write(ans);\nend."}, {"source_code": "var ss, s:string; \n l, i:longint;\n aa, ans:int64;\nbegin\n\n//assign(input, 'input.txt'); reset(input);\n//assign(output, 'output.txt'); rewrite(output);\n\nreadln(s);\nl:=length(s);\n\nss:='';\nfor i:=1 to l do \n begin\n case s[i] of \n '>': ss:=ss+'1000';\n '<': ss:=ss+'1001'; \n '+': ss:=ss+'1010';\n '-': ss:=ss+'1011'; \n '.': ss:=ss+'1100'; \n ',': ss:=ss+'1101';\n '[': ss:=ss+'1110'; \n ']': ss:=ss+'1111'; \n end; \n \n end;\n\nl:=l*4; aa:=1; \nfor i:=l downto 1 do\n begin\n if ss[i]='1' then ans:=(ans+aa) mod 1000003; \n aa:=(aa*2) mod 1000003;\n end;\n\nwriteln(ans);\n\n//close(input); close(output);\n\nend."}, {"source_code": "const\nstr = '><+-.,[]';\n\nvar\ns : ansistring;\ni,j,ans : longint;\n\nbegin\n readln(s);\n ans := 0;\n for i := 1 to length(s) do\n begin\n ans := (ans * 16 + pos(s[i],str) + 7) mod 1000003;\n end;\n writeln(ans);\n //readln;\nend.\n"}, {"source_code": "var\n s,tek : ansistring;\n answer,step : int64;\n i,leng : longint;\n\n\n\n\nbegin\n\n readln(tek);\n leng:=length(tek); s:='';\n for i:=1 to leng do\n begin\n\n if tek[i]='>' then s:=s+'1000';\n if tek[i]='<' then s:=s+'1001';\n if tek[i]='+' then s:=s+'1010';\n if tek[i]='-' then s:=s+'1011';\n if tek[i]='.' then s:=s+'1100';\n if tek[i]=',' then s:=s+'1101';\n if tek[i]='[' then s:=s+'1110';\n if tek[i]=']' then s:=s+'1111';\n\n end;\n\n leng:=length(s);\n answer:=0; step:=1;\n for i:=leng downto 1 do\n begin\n\n if s[i]='1' then answer:=(answer+step) mod 1000003;\n step:=step*2 mod 1000003;\n\n end;\n writeln(answer);\n\nend."}, {"source_code": "program b;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i : integer;\n s : string;\n cur : integer;\n res : int64;\nbegin\n readln (s);\n res := 0;\n for i := 1 to length (s) do\n begin\n case s[i] of\n '>' : cur := 8;\n '<' : cur := 9;\n '+' : cur := 10;\n '-' : cur := 11;\n '.' : cur := 12;\n ',' : cur := 13;\n '[' : cur := 14;\n ']' : cur := 15;\n end;\n\n res := (res * 16) mod 1000003;\n res := res + cur;\n end;\n\n writeln (res);\n\n readln;\n readln;\nend.\n "}, {"source_code": "program calendar;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar a: array [char] of integer;\n s: string;\n p,i,o,j:integer;\nbegin\na['>']:=8;\na['<']:=9;\na['+']:=10;\na['-']:=11;\na['.']:=12;\na[',']:=13;\na['[']:=14;\na[']']:=15;\np:=1; o:=0;\nreadln(s);\nfor i:= length(s) downto 1 do\n begin\n o:=(o+(p*a[s[i]])) mod 1000003;\n p:=(p*16) mod 1000003;\n end;\nwrite(o);\n\nread(i);\nend."}, {"source_code": "const q='><+-.,[]';\nvar c:char;\n k:int64;\nbegin\n k:=0;\n while not eoln do\n begin\n read(c);\n k:=(k*16+7+pos(c,q))mod round(1e6+3);\n end;\n writeln(k);\nend."}, {"source_code": "Program LL;\nVar\n s,s1:ansistring;\n\ti,j,k,m,n,p,q:longint;\n\tans,tot,sum:int64;\n\nBegin\n\t readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then\n begin\n s1:=s1+'1000';\n end;\n if s[i]='<' then\n begin\n s1:=s1+'1001';\n end;\n if s[i]='+' then\n begin\n s1:=s1+'1010';\n end;\n if s[i]='-' then\n begin\n s1:=s1+'1011';\n end;\n if s[i]='.' then\n begin\n s1:=s1+'1100';\n end;\n if s[i]=',' then\n begin\n s1:=s1+'1101';\n end;\n if s[i]='[' then\n begin\n s1:=s1+'1110';\n end;\n if s[i]=']' then\n begin\n s1:=s1+'1111';\n end;\n end;\n for i:=1 to length(s1) do\n begin\n sum:=1;\n for j:=1 to length(s1)-i do\n begin\n sum:=(sum*2) mod 1000003;\n end;\n sum:=sum*(ord(s1[i])-48);\n ans:=(ans+sum) mod 1000003;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program ProblemA;{$APPTYPE CONSOLE}\n\nvar i: longint;\n c: char;\n f: boolean;\n\nbegin\n i := 0;\n while not eoln do\n begin\n read(c);\n case c of\n '<': i := (i * 16 mod 1000003 + 9) mod 1000003;\n '>': i := (i * 16 mod 1000003 + 8) mod 1000003;\n '.': i := (i * 16 mod 1000003 + 12) mod 1000003;\n ',': i := (i * 16 mod 1000003 + 13) mod 1000003;\n '[': i := (i * 16 mod 1000003 + 14) mod 1000003;\n ']': i := (i * 16 mod 1000003 + 15) mod 1000003;\n '+': i := (i * 16 mod 1000003 + 10) mod 1000003;\n '-': i := (i * 16 mod 1000003 + 11) mod 1000003;\n end;\n end;\n write(i);\nend.\n"}, {"source_code": "COnst base = 1000003;\n\nvar s, a: string;\n i, j, res, hs: longint;\n\nBegin{main}\n read(s);\n hs := 1;\n for i := length(s) downto 1 do\n begin\n case s[i] of\n '>': a := '1000';\n '<': a := '1001';\n '+': a := '1010';\n '-': a := '1011';\n '.': a := '1100';\n ',': a := '1101';\n '[': a := '1110';\n ']': a := '1111';\n end;\n for j := 4 downto 1 do\n begin\n if a[j] = '1' then res := (res+hs) mod base;\n hs := (hs*2) mod base;\n end;\n end;\n writeln(res);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar\n s, s1: ansistring;\n i: longint;\n ans: int64;\n a: array[-1..500] of int64;\n \n\nbegin\n {assignfile(input, 'input.txt');\n reset(input);\n assignfile(output, 'output.txt');\n rewrite(output); }\n\n read(s);\n\n s1 := '';\n for i := 1 to length(s) do\n case s[i] of\n '>': s1 := s1 + '1000';\n '<': s1 := s1 + '1001';\n '+': s1 := s1 + '1010';\n '-': s1 := s1 + '1011';\n '.': s1 := s1 + '1100';\n ',': s1 := s1 + '1101';\n '[': s1 := s1 + '1110';\n ']': s1 := s1 + '1111';\n end;\n\n a[0] := 1;\n for i := 1 to length(s1) + 1 do\n a[i] := (a[i - 1] * 2) mod 1000003;\n\n ans := 0;\n\n for i := length(s1) downto 1 do begin\n if s1[i] = '1' then\n ans := (ans + a[length(s1) - i]) mod 1000003;\n end;\n\n write(ans);\n\n // read(ans);\n\n closefile(input);\n closefile(output);\nend.\n "}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D-,E+,F+,G-,I-,L-,N+,R-,Q-,S-,V+,X+}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n base = 1000003;\n\nvar\n s: string;\n i, n: integer;\n res: int64;\n\nprocedure panic(x: integer);\nbegin\n write(x);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nfunction f(ch: char): integer;\nbegin\n if ch = '>' then\n f := 8;\n if ch = '<' then\n f := 9;\n if ch = '+' then\n f := 10;\n if ch = '-' then\n f := 11;\n if ch = '.' then\n f := 12;\n if ch = ',' then\n f := 13;\n if ch = '[' then\n f := 14;\n if ch = ']' then\n f := 15;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n readln(s);\n n := length(s);\n res := 0;\n for i := 1 to n do\n res := (16 * res + f(s[i])) mod base;\n\n write(res);\n\n\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst m = 1000003;\n\nfunction pow(k:integer):integer;\nvar\n res,i:integer;\nbegin\n res:=1;\n for i:=1 to k do\n res:=(res*2) mod m;\n pow:=res;\nend;\n\nfunction calc(s:string):integer;\nvar\n res,i:integer;\nbegin\n res:=0;\n for i:=1 to length(s) do\n res:=(res+(Ord(s[i])-48)*Pow(length(s)-i)) mod m;\n calc:=res;\nend;\n\nvar\n n,i:integer;\n //a:array[1..100] of integer;\n s,st:string;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n ReadLn(s);\n st:='';\n for i:=1 to length(s) do\n begin\n if s[i]='>' then st:=st+'1000';\n if s[i]='<' then st:=st+'1001';\n if s[i]='+' then st:=st+'1010';\n if s[i]='-' then st:=st+'1011';\n if s[i]='.' then st:=st+'1100';\n if s[i]=',' then st:=st+'1101';\n if s[i]='[' then st:=st+'1110';\n if s[i]=']' then st:=st+'1111';\n end;\n writeln(calc(st));\nend.\n "}, {"source_code": "program unuary;\nconst modulo =1000003;\n\nvar s,c,z:String;\n i:longint;\n l,q,ans2:int64;\n\nfunction numb(c:char):string;\nbegin\n numb:='';\n\n if(c='>') then numb:='1000';\n if(c='<') then numb:='1001';\n if(c='+') then numb:='1010';\n if(c='-') then numb:='1011';\n if(c='.') then numb:='1100';\n if(c=',') then numb:='1101';\n if(c='[') then numb:='1110';\n if(c=']') then numb:='1111';\n\nend;\n\n\nfunction makebinary(c:string):int64;\nvar i,e:longint;\n ans,l:int64;\nbegin\n\n l:=length(c);\n ans:=0;\n\n\n for i:=l downto 1 do begin\n val(c[i],e);\n ans:=(ans+(q*e)) mod modulo;\n q:=(q*2) mod modulo;\n end;\n\n makebinary:=ans;\nend;\n\n\n\n\n\n\n\nbegin\n readln(s);\n l:=length(s);\n q:=1;\n\n for i:=l downto 1 do begin\n c:=numb(s[i]);\n ans2:=(makebinary(c)+ans2) mod modulo;\n end;\n\n writeln(ans2);\n\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n modul=round(1e6)+3;\nvar f1,f2:text;\n mu:array[0..401] of longint;\n c:array[chr(1)..chr(255)] of string;\n a,s:ansistring;\nprocedure mo;\nbegin\nassign(f1,fi);\nreset(f1);\nassign(F2,fo);\nrewrite(f2);\nend;\n\nprocedure dong;\nbegin\nclose(F1);\nclose(f2);\nend;\n\nprocedure nhap;\nvar i,j:longint;\n kq:int64;\nbegin\nkq:=0;\n c['>']:= '1000';\n c['<']:= '1001';\n c['+']:= '1010';\n c['-']:= '1011';\n c['.']:= '1100';\n c[',']:= '1101';\n c['[']:= '1110';\n c[']']:= '1111';\nmu[0]:=1;\na:='';\nfor i:=1 to 400 do\n mu[i]:=(mu[i-1]*2) mod modul;\nreadln(F1,S);\nfor i:=1 to length(s) do\n a:=a+c[s[i]];\nj:=length(a);\nfor i:=1 to j do\n if a[i]='1' then\n kq:=(kq+mu[j-i]) mod modul;\nwriteln(F2,kq);\nend;\n\nBEGIN\nmo;\nnhap;\nDong;\nEND."}, {"source_code": "var\ns,a:ansistring;\ni:longint;\np,ans:qword;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\nbegin\nif s[i]='>' then a:=a+'1000';\nif s[i]='<' then a:=a+'1001';\nif s[i]='+' then a:=a+'1010';\nif s[i]='-' then a:=a+'1011';\nif s[i]='.' then a:=a+'1100';\nif s[i]=',' then a:=a+'1101';\nif s[i]='[' then a:=a+'1110';\nif s[i]=']' then a:=a+'1111';\nend;\np:=1;\nfor i:=length(a) downto 1 do\nbegin\nif a[i]='1' then ans:=(ans+p) mod 1000003;\np:=p*2; p:=p mod 1000003;\nend;\nwriteln(ans);\nend.\n"}, {"source_code": "var\n s:string;\n k,ans,i:longint;\n a:array[0..105] of longint;\nbegin\n readln(s);\n k:=1;\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>':a[i]:=8;\n '<':a[i]:=9;\n '+':a[i]:=10;\n '-':a[i]:=11;\n '.':a[i]:=12;\n ',':a[i]:=13;\n '[':a[i]:=14;\n ']':a[i]:=15;\n else a[i]:=0;\n end;\n end;\n for i:=length(s) downto 1 do\n begin\n ans:=(ans+((k*a[i]) mod 1000003)) mod 1000003;\n k:=(k*16) mod 1000003;\n end;\n writeln(ans);\nend."}, {"source_code": "const\n s:string=('><+-.,[]');\n a:array[1..8]of string=('1000','1001','1010','1011','1100','1101','1110','1111');\nvar\n c:char;\n i,t,j,k,kk:longint;\n g:ansistring;\nbegin\n while not eoln do\n begin\n read(c);\n g:=g+a[pos(c,s)];\n end;\n for i:=length(g) downto 1 do if g[i]='1' then\n begin\n t:=1;\n for j:=1 to length(g)-i do t:=(t*2) mod 1000003;\n k:=(k+t) mod 1000003;\n end;\n writeln(k);\nend."}, {"source_code": "{$r-, s-, q-, i-, o+}\nconst\n base = round(1e6) + 3;\nvar\n s, t : ansistring;\n n, i, j, p, ans : longint;\n brainfuck : array [1..8] of ansistring = ('>', '<', '+', '-', '.', ',', '[', ']');\n unary : array [1..8] of ansistring = ('1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111');\nbegin\n readln(s);\n n := length(s);\n for i := 1 to n do\n for j := 1 to 8 do\n if (s[i] = brainfuck[j]) then\n t := t + unary[j];\n n := length(t);\n p := 1;\n for i := n downto 1 do\n begin\n ans := (ans + (ord(t[i]) - ord('0')) * p) mod base;\n p := (p + p) mod base;\n end;\n writeln(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i, m, st, ans : longint;\n s, s2 : string;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n\n readln(s);\n s2 := '';\n for i := 1 to length(s) do\n begin\n if s[i] = '>' then s2 := s2 + '1000';\n if s[i] = '<' then s2 := s2 + '1001';\n if s[i] = '+' then s2 := s2 + '1010';\n if s[i] = '-' then s2 := s2 + '1011';\n if s[i] = '.' then s2 := s2 + '1100';\n if s[i] = ',' then s2 := s2 + '1101';\n if s[i] = '[' then s2 := s2 + '1110';\n if s[i] = ']' then s2 := s2 + '1111';\n end;\n m := 1000003;\n st := 1;\n ans := 0;\n for i := length(s2) downto 1 do\n begin\n ans := (ans + strtoint(s2[i])*st) mod m;\n st := (st*2) mod m;\n end;\n write(ans);\nend.\n "}, {"source_code": "PROGRAM B;\nconst fi = '';\n fo = '';\n e = 1000003;\n st = '><+-.,[]';\n a : array[1..8] of string = ('1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111');\nvar s, g : ansistring;\n res, d : int64;\n i, j : longint;\n\nBEGIN\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n readln(s);\n for i:= 1 to length(s) do\n begin\n j:= pos(s[i], st);\n g:= g + a[j];\n end;\n d:= 1;\n for i:= length(g) downto 1 do\n begin\n if g[i] = '1' then res:= (res + d) mod e;\n d:= (d * 2) mod e;\n end;\n writeln(res);\n close(input); close(output);\nEND.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..400] of byte;\n i,j:word;\n ans,x:int64;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n if ans=0 then ans:=1000003; \n x:=x*2;\n x:=x mod 1000003;\n if x=0 then x:=1000003; \n end;\n writeln (ans);\n readln;\n readln;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst max=1000003;\ntype ii = integer;\nvar\n st :string;\n i, cur, num: ii;\n res : int64;\nbegin\n readln (st);\n for i := 1 to length(st) do\n begin\n case st[i] of\n '>' : num := 8;\n '<' : num := 9;\n '+' : num := 10;\n '-' : num := 11;\n '.' : num := 12;\n ',' : num := 13;\n '[' : num := 14;\n ']' : num := 15;\n end;\n res := (res*16 + num) mod max;\n end;\nwriteln (res);\nend."}, {"source_code": "var\n s,s1:string;\n k,l,i,j:longint;\n c:char;\nbegin\n read(s);\n for i:=1 to length(s) do\n begin\n c:=s[i];\n case c of\n '>':s1:='1000';\n '<':s1:='1001';\n '+':s1:='1010';\n '-':s1:='1011';\n '.':s1:='1100';\n ',':s1:='1101';\n '[':s1:='1110';\n ']':s1:='1111';\n end;\n for j:=1 to 4 do\n begin\n l:=l*2;\n if s1[j]='1' then inc(l);\n end;\n l:=l mod 1000003;\n end;\n write(l);\nend."}, {"source_code": "const\n ABC='><+-.,[]';\nvar\n res,i:longint;\n s:ansistring;\n \nbegin\n readln(s);\n res:=0;\n for i:=1 to length(s)do res:=(res*16+7+pos(s[i],ABC))mod 1000003;\n writeln(res);\nend."}, {"source_code": "program A_HQ9;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype myarray=array[0..10000] of longint;\nconst base=1000003;\nvar a,res : myarray;\n s,str : string;\n i,j,k : longint;\nprocedure pr(var a : myarray);\nvar z,o : longint;\nbegin\n o:=a[1]*2;\n z:=1;\n a[1]:=0;\n while o>0 do\n begin\n o:=o+a[z];\n a[z]:=o mod base;\n o:=o div base;\n inc(z);\n end;\n if z-1>a[0] then a[0]:=z-1;\nend;\nprocedure sum(var res,a : myarray);\nvar z,o : longint;\nbegin\n o:=0;\n z:=1;\n while (a[0]>=z) or (res[0]>=z) or (o>0) do\n begin\n o:=o+a[z]+res[z];\n res[z]:=o mod base;\n o:=o div base;\n inc(z);\n end;\n if z-1>res[0] then res[0]:=z-1;\nend;\nfunction ost(var res : myarray; g : longint) : longint;\nvar z,o : longint;\nbegin\n o:=0;\n for i:=res[0] downto 1 do\n begin\n o:=o*base+res[i];\n o:=o mod g;\n end;\n ost:=o;\nend;\nbegin\n readln(s);\n str:='';\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>' : str:=str+'1000';\n '<' : str:=str+'1001';\n '+' : str:=str+'1010';\n '-' : str:=str+'1011';\n '.' : str:=str+'1100';\n ',' : str:=str+'1101';\n '[' : str:=str+'1110';\n ']' : str:=str+'1111';\n end;\n end;\n for i:=1 to length(str) do\n begin\n fillchar(a,sizeof(a),0);\n if str[i]='1' then\n begin\n a[0]:=1;\n a[1]:=1;\n for j:=1 to length(str)-i do pr(a);\n sum(res,a);\n end;\n end;\n writeln(res[1]);\nend.\n"}, {"source_code": "Program LL;\nVar\n s,s1:ansistring;\n\ti,j,k,m,n,p,q:longint;\n\tans,tot,sum:int64;\n\nBegin\n\t readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then\n begin\n s1:=s1+'1000';\n end;\n if s[i]='<' then\n begin\n s1:=s1+'1001';\n end;\n if s[i]='+' then\n begin\n s1:=s1+'1010';\n end;\n if s[i]='-' then\n begin\n s1:=s1+'1011';\n end;\n if s[i]='.' then\n begin\n s1:=s1+'1100';\n end;\n if s[i]=',' then\n begin\n s1:=s1+'1101';\n end;\n if s[i]='[' then\n begin\n s1:=s1+'1110';\n end;\n if s[i]=']' then\n begin\n s1:=s1+'1111';\n end;\n end;\n for i:=1 to length(s1) do\n begin\n sum:=1;\n for j:=1 to length(s1)-i do\n begin\n sum:=(sum*2) mod 1000003;\n end;\n sum:=sum*(ord(s1[i])-48);\n ans:=(ans+sum) mod 1000003;\n end;\n writeln(ans);\nEnd."}, {"source_code": "var\nq:char;\nr,i,j:longint;\ns,s1:ansistring;\n begin\n s:='';\n readln(s1);\n for i:=1 to length(s1) do\n begin\n q:=s1[i];\n if q='>' then s:=s+'1000'\n else if q='<' then s:=s+'1001'\n else if q='+' then s:=s+'1010'\n else if q='-' then s:=s+'1011'\n else if q='.' then s:=s+'1100'\n else if q=',' then s:=s+'1101'\n else if q='[' then s:=s+'1110'\n else s:=s+'1111';\n end;\n r:=0;\n for i:=1 to length(s) do\n begin\n r:=r*2;\n r:=r+ord(s[i])-48;\n r:=r mod 1000003;\n end;\n writeln(r);\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n i:Integer;\n s,s1:string;\nfunction lol(s:string):Int64;\nvar\n k,i,j,n,code:Integer;\n g,a:Int64;\nbegin\n k:=0;\n g:=0;\n a:=0;\n n:=Length(s)-1;\n for i:=1 to Length(s) do\n begin\n if (s[i]='0') then g:=(g mod 1000003)*2\n else g:=(g mod 1000003)*2+1;\n end;\n lol:=g;\nend;\nbegin\n Readln(s);\n s1:='';\n for i:=1 to Length(s) do\n begin\n if (s[i]='>') then s1:=s1+'1000';\n if (s[i]='<') then s1:=s1+'1001';\n if (s[i]='+') then s1:=s1+'1010';\n if (s[i]='-') then s1:=s1+'1011';\n if (s[i]='.') then s1:=s1+'1100';\n if (s[i]=',') then s1:=s1+'1101';\n if (s[i]='[') then s1:=s1+'1110';\n if (s[i]=']') then s1:=s1+'1111';\n end;\n Writeln(lol(s1)mod 1000003);\n Readln;\n Readln;\nend.\n "}, {"source_code": "var k:Int64;\ni:Integer;\ns:string;\nx:LongInt;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(s);\n for i:=1 to Length(s) do\n begin\n case s[i] of\n '>':x:=8;\n '<':x:=9;\n '+':x:=10;\n '-':x:=11;\n '.':x:=12;\n ',':x:=13;\n '[':x:=14;\n ']':x:=15;\n end;\n k:=(k*16+x)mod 1000003;\n end;\n Writeln(k);\nend.\n"}, {"source_code": "program B;\nconst m = 1000*1000+3;\nvar i,res,p,j : longint; s : string;\n a : array[0..7] of char = ('>','<','+','-','.',',','[',']');\nbegin\n {assign(input,'input.txt'); reset(input);}\n {assign(output,'output.txt'); rewrite(output);}\n readln(s);\n p:= 1; res:= 0;\n for i:= length(s) downto 1 do begin\n for j:= 0 to 7 do\n if s[i] = a[j] then res:= (res + ((p mod m)*(j+8)) mod m) mod m;\n p:= (p*16) mod m;\n end; \n \n writeln(res mod m); \nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,ans:string;\n i,x:integer;\n\nfunction binpow(a,n:int64):int64;\nvar b:int64;\nbegin\nif n=0 then binpow:=1\n else if n mod 2=1 then binpow:=((binpow(a,n-1) mod 1000003)*a) mod 1000003\n else begin\n b:=binpow(a, n div 2) ;//mod 1000003;\n binpow:=(b mod 1000003*b) mod 1000003;\n end;\nend;\n\n\nbegin\n\n\nans:='';\n\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then ans:=ans+'1000';\n if s[i]='<' then ans:=ans+'1001';\n if s[i]='+' then ans:=ans+'1010';\n if s[i]='-' then ans:=ans+'1011';\n if s[i]='.' then ans:=ans+'1100';\n if s[i]=',' then ans:=ans+'1101';\n if s[i]='[' then ans:=ans+'1110';\n if s[i]=']' then ans:=ans+'1111';\n end;\nx:=0;\nfor i:=1 to length(ans) do\nif ans[i]='1' then\n x:=((x mod 1000003)+binpow(2,length(ans)-i))mod 1000003;\nwrite(x);\nreadln;\nend.\n"}, {"source_code": "program fgdfgd;\n\n{$APPTYPE CONSOLE}\nuses\n SysUtils,\n Math;\n\n\n\n\nvar n,i,j,k,ans,l:integer;\n s:string;\n\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(s);\n ans:=0;\n l:=1;\n for i:=length(s) downto 1 do begin\nif s[i]='>' then ans:=(ans+(l*8) mod 1000003) mod 1000003;\nif s[i]='<' then ans:=(ans+(l*9) mod 1000003) mod 1000003;\nif s[i]='+' then ans:=(ans+(l*10) mod 1000003) mod 1000003;\nif s[i]='-' then ans:=(ans+(l*11) mod 1000003) mod 1000003;\nif s[i]='.' then ans:=(ans+(l*12) mod 1000003) mod 1000003;\nif s[i]=',' then ans:=(ans+(l*13) mod 1000003) mod 1000003;\nif s[i]='[' then ans:=(ans+(l*14) mod 1000003) mod 1000003;\nif s[i]=']' then ans:=(ans+(l*15) mod 1000003) mod 1000003;\n\n\n l:=l*16 mod 1000003;\n end;\n write(ans);\n\n\nend.\n\n\n"}, {"source_code": "program p_b;\n\n{$APPTYPE CONSOLE}\n{$H+}\n\nuses\n SysUtils;\n\nconst\n cut = 1000003;\n\ntype\n\tint = integer;\n\nvar\n\ts, def, tmp: string;\n i, res, pow, sum: int;\n\nfunction Bin(x: int): string;\nbegin\n\tresult := '';\n while x <> 0 do begin\n \tresult := inttostr(x mod 2) + result;\n x := x div 2;\n end;\n\n while (length(result) < 4) do begin\n result := '0' + result;\n end;\nend;\n\nbegin\n\tdef := '><+-.,[]';\n\n readln(s);\n\n tmp := '';\n for i := 1 to length(s) do\n tmp := tmp + bin(Pos(s[i], def) + 7);\n\n res := 0;\n pow := 1;\n for i := length(tmp) downto 1 do begin\n \tsum := (pow * strtoint(tmp[i])) mod cut;\n res := res mod cut + sum;\n pow := (pow * 2) mod cut;\n res := res mod cut;\n end;\n\n write(res);\n\nend.\n"}, {"source_code": "const\n st='><+-.,[]';\n md=round(1e6+3);\n\nvar\n a:Array[0..1000,0..1000]of char;\n i,n,m,j,kol,sum:longint;\n t:string;\nbegin\n read(t);\n n:=length(t);\n for i:=1 to n do\n sum:=(sum*16+7+pos(t[i],st))mod md;\n write(sum);\nend.\n"}, {"source_code": "const fi='';\n e=1000003;\nvar kq:longint;\n st:string;\n a:array['+'..']'] of string;\n du:array[0..1000] of longint;\nprocedure nhap;\nvar i,j:longint;\nbegin\n assign(input,fi);\n reset(input);\n readln(st);\n kq:=0;\n a['+']:= '1010' ;\n a['-']:= '1011';\n a['<']:='1001';\n a['>']:='1000';\n a['.']:= '1100';\n a[',']:='1101';\n a['[']:='1110';\n a[']']:= '1111';\n du[0]:=1;\n for i:=1 to 1000 do\n du[i]:=(du[i-1]*2) mod e;\n for i:=length(St) downto 1 do\n for j:=4 downto 1 do\n begin\n if a[st[i]][j]='1' then\n kq:=(kq+du[4*(length(st)-i)+4-j]) mod e;\n end;\n close(input);\n write(kq);\nend;\nbegin\n nhap;\nend."}, {"source_code": "var m,l,sum,i:longint;\n s:string;\n\nprocedure plus(m:integer);\n var x,l:longint;\nbegin\nx:=1;\nfor l:=1 to m-1 do x:=x*2mod 1000003;\nsum:=(sum+x) mod 1000003;\nend;\nbegin\nreadln(s);\nm:=length(s);\nfor l:=m downto 1 do\nbegin\ni:=m-l+1;\nif s[l]='>' then plus(i*4) else\nif s[l]='<' then begin plus(i*4); plus(i*4-3); end else\nif s[l]='+' then begin plus(i*4); plus(i*4-2); end else\nif s[l]='-' then begin plus(i*4); plus(i*4-2);plus(i*4-3); end else\nif s[l]='.' then begin plus(i*4); plus(i*4-1); end else\nif s[l]=',' then begin plus(i*4); plus(i*4-1);plus(i*4-3); end else\nif s[l]='[' then begin plus(i*4); plus(i*4-2);plus(i*4-1); end else\nif s[l]=']' then begin plus(i*4); plus(i*4-2);plus(i*4-3);plus(i*4-1) end;\nend;\nwriteln(sum mod 1000003);\nend."}, {"source_code": "Const dict='><+-.,[]';\nVar r,i,l,k:LongInt;\n s:String;\n\nBegin\n Readln (s);\n r:=0;\n l:=Length (s);\n For I:=1 to l do\n Begin\n k:=Pos (s[i],dict);\n r:=r*16+7+k;\n r:=r mod 1000003;\n End;\n Writeln (r);\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,i,sum,j,x,z,f,f1,se,se1:integer;\n s,k,p:string;\n\n function per(k:string):int64;\n var\n i:integer;\n r:int64;\n begin\n r:=0;\n for i:=1 to length(k) do\n if k[i]='0' then r:=(r mod 1000003)*2\n else r:=(r mod 1000003)*2+1;\n per:=r;\n end;\n\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then k:='1000';\n if s[i]='<' then k:='1001';\n if s[i]='[' then k:='1110';\n if s[i]=']' then k:='1111';\n if s[i]='+' then k:='1010';\n if s[i]='-' then k:='1011';\n if s[i]='.' then k:='1100';\n if s[i]=',' then k:='1101';\n p:=p+k;\n end;\n writeln(per(p) mod 1000003);\n\nend."}, {"source_code": "var\n a: ansistring;\n f: array [0..1000] of longint;\n s: ansistring;\n ans,i,j: longint;\nbegin\n a := '><+-.,[]';\n f[1]:=8;\n for i := 2 to 8 do f[i]:=f[i-1]+1;\n readln(s);\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=a[j] then ans:=(ans*16+f[j]) mod 1000003;\n writeln(ans);\nend."}, {"source_code": "uses\n SysUtils, Math;\n\nconst\n MD = 1000003;\n\nvar\n i, ls : longint;\n s : string;\n ans, x : int64;\n\nbegin\n readln(s);\n ls := length(s);\n ans := 0;\n x := 1;\n for i := ls downto 1 do begin\n if s[i] = '>' then begin\n x := x shl 3 mod MD;\n inc(ans, x);\n end else \n if s[i] = '<' then begin\n inc(ans, x);\n x := x shl 3 mod MD;\n inc(ans, x);\n end else \n if s[i] = '+' then begin\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 2 mod MD;\n inc(ans, x);\n end else \n if s[i] = '-' then begin\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 2 mod MD;\n inc(ans, x);\n end else \n if s[i] = '.' then begin\n x := x shl 2 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n end else \n if s[i] = ',' then begin\n inc(ans, x);\n x := x shl 2 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n end else \n if s[i] = '[' then begin\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n end else \n if s[i] = ']' then begin\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n x := x shl 1 mod MD;\n inc(ans, x);\n end;\n ans := ans mod MD;\n x := x shl 1;\n end;\n write(ans mod MD); \nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst p = 1000003;\nvar s: string;\ni,j,sum : integer;\nbegin\n readln(s);\n sum := 0;\n for i := 1 to length(s) do\n begin\n sum := sum * 16;\n if s[i] = '>' then sum := sum + 8;\n if s[i] = '<' then sum := sum + 9;\n if s[i] = '+' then sum := sum + 10;\n if s[i] = '-' then sum := sum + 11;\n if s[i] = '.' then sum := sum + 12;\n if s[i] = ',' then sum := sum + 13;\n if s[i] = '[' then sum := sum + 14;\n if s[i] = ']' then sum := sum + 15;\n sum := sum mod p;\n\n end;\n writeln(sum);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i: integer;\n n: int64;\n s, t: string;\n a: array[-1..10000] of int64;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(s);\n\n a[0] := 1;\n for i := 1 to 10000 do\n a[i] := (a[i - 1] * 2) mod 1000003;\n\n t := '';\n for i := 1 to length(s) do begin\n case s[i] of\n '>': t := t + '1000';\n '<': t := t + '1001';\n '+': t := t + '1010';\n '-': t := t + '1011';\n '.': t := t + '1100';\n ',': t := t + '1101';\n '[': t := t + '1110';\n ']': t := t + '1111';\n end;\n end;\n\n n := 0;\n for i := 1 to length(t) do begin\n if (t[i] = '1') then\n n := (n + a[length(t) - i]) mod 1000003;\n end;\n\n writeln(n);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n i:Integer;\n s,s1:string;\nfunction lol(s:string):Int64;\nvar\n k,i,j,n,code:Integer;\n g,a:Int64;\nbegin\n k:=0;\n g:=0;\n a:=0;\n n:=Length(s)-1;\n for i:=1 to Length(s) do\n begin\n if (s[i]='0') then g:=(g mod 1000003)*2\n else g:=(g mod 1000003)*2+1;\n end;\n lol:=g;\nend;\nbegin\n Readln(s);\n s1:='';\n for i:=1 to Length(s) do\n begin\n if (s[i]='>') then s1:=s1+'1000';\n if (s[i]='<') then s1:=s1+'1001';\n if (s[i]='+') then s1:=s1+'1010';\n if (s[i]='-') then s1:=s1+'1011';\n if (s[i]='.') then s1:=s1+'1100';\n if (s[i]=',') then s1:=s1+'1101';\n if (s[i]='[') then s1:=s1+'1110';\n if (s[i]=']') then s1:=s1+'1111';\n end;\n Writeln(lol(s1)mod 1000003);\n Readln;\n Readln;\nend.\n "}, {"source_code": "program task_b;\n\n{$APPTYPE CONSOLE}\nconst d: array[1..8]of char = ('>','<','+','-','.',',','[',']');\n b: array[1..8]of string = ('1000','1001','1010','1011','1100','1101','1110','1111');\n md = round(1e6)+3;\nvar s,tmp: string;\n i,j,ans: integer;\nbegin\n readln(s);\n ans:=0;\n for i:=1 to length(s)do begin\n for j:=1 to 8 do\n if (s[i]=d[j])then begin\n tmp:=b[j];\n break;\n end;\n for j:=1 to 4 do\n ans:=(ans*2 mod md + ord(tmp[j])-ord('0'))mod md;\n end;\n write(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\nfunction step(i : longint): longint;\nvar\n j: longint;\n q : longint;\nbegin\n q := 1;\n for j:= 1 to i do\n q := q * 2 mod 1000003;\n step := q mod 1000003;\nend;\nvar\n str: string;\n j, sum: longint;\n i: longint;\n a: array[1..400] of longint;\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(str);\n j := 1;\n for i := 1 to length(str) do\n begin\n if str[i] = '>' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '<' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '+' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '-' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '.' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ',' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '[' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ']' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4);\n end;\n end;\n sum := 0;\n for i := 1 to j do\n begin\n if a[i] = 1 then\n sum := sum + step(j - i - 1) mod 1000003;\n end;\n writeln(sum mod 1000003);\nend.\n"}, {"source_code": "var s:string;\n s1:ansistring;\n b:array[1..8,1..2] of string;\n i,j,t,d,ss,sp:longint;\nbegin\n readln(s);\n b[1,1]:='>';b[1,2]:='1000';\n b[2,1]:='<';b[2,2]:='1001';\n b[3,1]:='+';b[3,2]:='1010';\n b[4,1]:='-';b[4,2]:='1011';\n b[5,1]:='.';b[5,2]:='1100';\n b[6,1]:=',';b[6,2]:='1101';\n b[7,1]:='[';b[7,2]:='1110';\n b[8,1]:=']';b[8,2]:='1111';\n s1:='';\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=b[j,1] then s1:=s1+b[j,2];\n d:=length(s1);\n ss:=0;\n for i:=1 to length(s1) do begin\n d:=d-1;\n sp:=0;\n if s1[i]='1' then begin sp:=1;\n for j:=1 to d do\n sp:=(sp mod 1000003)*2;\n ss:=(ss+sp) mod 1000003;end;end; \n writeln(ss);\nend."}, {"source_code": "const\n\tM = 1000003;\n\nvar\n\tCode : array ['+'..']'] of int64;\n ans, pow : int64;\n i : longint;\n s : string;\n\nbegin\n\n Code['>'] := 8;\n Code['<'] := 9;\n\tCode['+'] := 10;\n\tCode['-'] := 11;\n\tCode['.'] := 12;\n\tCode[','] := 13;\n\tCode['['] := 14;\n\tCode[']'] := 15;\n\n readln(s);\n\n ans := 0;\n pow := 1;\n for i := length(s) downto 1 do\n begin\n ans := (ans+Code[s[i]]*pow) mod M;\n pow := (pow*16) mod M;\n end;\n\n writeln(ans);\n\nend."}, {"source_code": "program unary;\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\nvar\n fin,fout:text;\n s:int64;\n st:string;\n i:longint;\nfunction deg(x:integer):int64;\nvar\n k:longint;\n p:int64;\nbegin\n p:=1;\n for k:=1 to x do\n p:=(p*2)mod 1000003;\n deg:=p;\nend;\n\nbegin\n assign(fin,''); assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,st);\n s:=0;\n for i:=length(st)-1 downto 0 do\n begin\n if st[i+1]='>' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*8) mod 1000003) mod 1000003;\n if st[i+1]='<' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*9) mod 1000003) mod 1000003;\n if st[i+1]='+' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*10) mod 1000003)mod 1000003;\n if st[i+1]='-' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*11) mod 1000003)mod 1000003;\n if st[i+1]='.' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*12) mod 1000003)mod 1000003;\n if st[i+1]=',' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*13) mod 1000003)mod 1000003;\n if st[i+1]='[' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*14) mod 1000003)mod 1000003;\n if st[i+1]=']' then\n s:=(s mod 1000003+(deg((length(st)-1-i)*4)*15) mod 1000003)mod 1000003;\n end;\n writeln(fout,s mod 1000003);\n close(fin); close(fout);\nend.\n"}, {"source_code": "var s1,s2:ansistring;\n i,p,base,answer:longint;\n begin\n readln(s1);\n s2:='';\n base:=1000000+3;\n for i:=1 to length(s1) do\n case s1[i] of\n '>' : s2:=s2+'1000';\n '<' : s2:=s2+'1001';\n '+' : s2:=s2+'1010';\n '-' : s2:=s2+'1011';\n '.' : s2:=s2+'1100';\n ',' : s2:=s2+'1101';\n '[' : s2:=s2+'1110';\n ']' : s2:=s2+'1111';\n end;\n answer:=0;\n p:=1;\n for i:=length(s2) downto 1 do\n begin\n if s2[i]='1' then\n begin\n answer:=(answer+p) mod base;\n end;\n p:=(p*2) mod base;\n end;\n writeln(answer);\n end.\n\n\n\n\n"}, {"source_code": "const big =1000003;\nvar\ns:array['+'..'z']of longint;\nexp:array[1..255]of longint;\nstr:string;\nans,i,j:longint;\nbegin\n s['>']:=8;s['<']:=9;\n s['+']:=10;s['-']:=11;\n s['.']:=12;s[',']:=13;\n s['[']:=14;s[']']:=15;\n readln(str);\n exp[1]:=1;\n j:=length(str);\n for i:=2 to j do\n exp[i]:=(exp[i-1]*16) mod big;\n for i:=1 to j do\n ans:=(ans+(s[str[i]]*exp[j-i+1])) mod big;\n writeln(ans);\nend.\n"}, {"source_code": "var t:string;s,h,l,i:longint;\nbegin\n readln(t);\n l:=length(t);\n h:=1;s:=0;\n for i:=l downto 1 do\n begin\n case t[i] of \n '>':begin h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n '<':begin s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n '+':begin h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n '-':begin s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n '.':begin h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n ',':begin s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n '[':begin h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n ']':begin s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;s:=(s+h)mod 1000003;h:=(h*2)mod 1000003;end;\n end;\n end;\n writeln(s);\nend."}, {"source_code": "Program probb;\nvar s:string;\n c:array[char] of integer;\nfunction get:longint;\nvar cc:char;\nBegin\n if s='' then exit(0);\n cc:=s[length(s)];\n s:=copy(s,1,length(s)-1);\n exit((get()*16+c[cc]) mod 1000003);\n\n\nend;\nBegin\n readln(s);\n c['>']:=8;c['<']:=9;c['+']:=10;c['-']:=11;c['.']:=12;c[',']:=13;c['[']:=14;c[']']:=15;\n writeln(get);\nend.\n"}, {"source_code": "var s, b:string; i, o, k, j:longint;\nbegin\nread(s);\no:=0;\nk:=1;\nb:='';\nfor i:=1 to length(s) do begin\nif s[i]='>' then b:=b+'1000';\nif s[i]='<' then b:=b+'1001';\nif s[i]='+' then b:=b+'1010';\nif s[i]='-' then b:=b+'1011';\nif s[i]='.' then b:=b+'1100';\nif s[i]=',' then b:=b+'1101';\nif s[i]='[' then b:=b+'1110';\nif s[i]=']' then b:=b+'1111';\nend;\nfor i:=length(b) downto 1 do\nif b[i]='1' then begin\nk:=1;\nfor j:=length(b) downto i+1 do\nk:=(k*2) mod 1000003;\no:=(o+k) mod 1000003;\nend;\nwrite(o)\nend."}, {"source_code": "{$Q-}\nvar t,s:ansistring;\n i,p,ans,st,o:longint;\n begin\n read(s);\n for i:=1 to length(s) do\n if s[i]='>' then t:=t+'1000'\n else\n if s[i]='<' then t:=t+'1001'\n else\n if s[i]='+' then t:=t+'1010'\n else\n if s[i]='-' then t:=t+'1011'\n else\n if s[i]='.' then t:=t+'1100'\n else\n if s[i]=',' then t:=t+'1101'\n else\n if s[i]='[' then t:=t+'1110'\n else\n if s[i]=']' then t:=t+'1111';\n st:=1;\n for i:=length(t) downto 1 do\n begin\n val(t[i],o,p);\n ans:=(ans+((o*st) mod 1000003)) mod 1000003;\n st:=(st*2) mod 1000003;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "Program B;\nVar L:Longint;\n I,J,N,M:Longint;\n S:Ansistring;\n LL:Ansistring;\n Xar:Array[0..10000]Of Longint;\nBegin\n Readln(S);\n Xar[0]:=1;\n For I:=1 To Length(S)*4 Do\n Xar[I]:=Xar[I-1]*2 Mod 1000003;\n For I:=1 To Length(S) Do\n Begin\n If S[I]='>' Then LL:=LL+'1000';\n If S[I]='<' Then LL:=LL+'1001';\n If S[I]='+' Then LL:=LL+'1010';\n If S[I]='-' Then LL:=LL+'1011';\n If S[I]='.' Then LL:=LL+'1100';\n If S[I]=',' Then LL:=LL+'1101';\n If S[I]='[' Then LL:=LL+'1110';\n If S[I]=']' Then LL:=LL+'1111';\n End;\n For I:=1 To Length(LL) Do\n M:=(M+(Ord(LL[I])-Ord('0'))*Xar[Length(LL)-I]) Mod 1000003;\n Writeln(M);\nEnd.\n"}, {"source_code": "{$APPTYPE CONSOLE} {$O-} {$R+}\n\nuses\n sysutils,\n math;\n\nvar\n n, k: int64;\n i: integer;\n s, t: string;\n //a: array [] of integer;\n\nbegin\n //reset(input, 'INPUT.TXT');\n //rewrite(output, 'OUTPUT.TXT');\n\n read(s); t := '';\n\n for i := 1 to length(s) do\n case s[i] of\n '>': t := t + '1000';\n '<': t := t + '1001';\n '+': t := t + '1010';\n '-': t := t + '1011';\n '.': t := t + '1100';\n ',': t := t + '1101';\n '[': t := t + '1110';\n ']': t := t + '1111'\n end;\n\n i := length(t); n := 0; k := 1;\n while i > 0 do begin\n n := (n + k * ord(t[i] = '1')) mod 1000003;\n k := k * 2 mod 1000003;\n dec(i)\n end;\n\n write(n)\nend.\n"}, {"source_code": "Var L:Longint;\n I,J,N,M:Longint;\n S:Ansistring;\n LL:Ansistring;\n Xar:Array[0..10000]Of Longint;\nBegin\n Readln(S);\n Xar[0]:=1;\n For I:=1 To Length(S)*4 Do\n Xar[I]:=Xar[I-1]*2 Mod 1000003;\n For I:=1 To Length(S) Do\n Begin\n If S[I]='>' Then LL:=LL+'1000';\n If S[I]='<' Then LL:=LL+'1001';\n If S[I]='+' Then LL:=LL+'1010';\n If S[I]='-' Then LL:=LL+'1011';\n If S[I]='.' Then LL:=LL+'1100';\n If S[I]=',' Then LL:=LL+'1101';\n If S[I]='[' Then LL:=LL+'1110';\n If S[I]=']' Then LL:=LL+'1111';\n End;\n For I:=1 To Length(LL) Do\n M:=(M+(Ord(LL[I])-Ord('0'))*Xar[Length(LL)-I]) Mod 1000003;\n Writeln(M);\nEnd."}, {"source_code": "Var s,s3:AnsiString;\n ans,t,i,a,p:LongInt;\n begin\n ReadLn(s);\n For i:=1 to Length(s) do\n begin\n if s[i]='>' then s3:=s3+'1000';\n if s[i]='<' then s3:=s3+'1001';\n if s[i]='+' then s3:=s3+'1010';\n if s[i]='-' then s3:=s3+'1011';\n if s[i]='.' then s3:=s3+'1100';\n if s[i]=',' then s3:=s3+'1101';\n if s[i]='[' then s3:=s3+'1110';\n if s[i]=']' then s3:=s3+'1111';\n end;\n t:=1;\n For i:=Length(s3) downto 1 do\n begin\n val(s3[i],a,p);\n ans:=(ans+((a*t) mod 1000003)) mod 1000003;\n t:=(t*2) mod 1000003;\n end;\n WriteLn(ans);\n end."}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nconst p=1000003;\n\nvar\n s:ansistring;\n i,k,ans,l:longint;\n\nbegin\n readln(s);\n //l:=length(s);\n ans:=0;\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>': k:=8;\n '<': k:=9;\n '+': k:=10;\n '-': k:=11;\n '.': k:=12;\n ',': k:=13;\n '[': k:=14;\n ']': k:=15;\n end;\n ans:=(ans*16+k) mod p;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const\n input = '';\n output = '';\n base = 1000003;\n token = '><+-.,[]';\n table : array[1..8] of string = ('1000','1001','1010','1011','1100','1101','1110','1111');\n maxN = 400;\n\nvar\n fi,fo : text;\n s,f : ansistring;\n res : longint;\n p : array[0..maxN+1] of longint;\n\n\nprocedure openf;\nbegin\n assign(fi,input); reset(fi);\n assign(fo,output);rewrite(fo);\nend;\n//--\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n//--\nprocedure readf;\nbegin\n readln(fi,s);\nend;\n//--\nprocedure init;\nvar i : longint;\nbegin\n p[0]:=1;\n for i:=1 to maxN do\n p[i]:=(p[i-1]*2) mod base;\nend;\n//--\nprocedure conv;\nvar i : longint;\nbegin\n f:='';\n for i:=1 to length(s) do\n f:=f+table[pos(s[i],token)];\nend;\n//--\nprocedure solve;\nvar i : longint;\nbegin\n for i:=1 to length(f) do\n if f[i] = '1' then\n res:=(res+p[length(f)-i]) mod base;\nend;\n//--\nprocedure print;\nbegin\n writeln(fo,res);\nend;\n//--\nbegin\n openf;\n readf;\n init;\n conv;\n solve;\n print;\n closef;\nend.\n"}, {"source_code": "var\n s,ss: string;\n i,z,code: longint;\n n: int64;\nfunction POS(a: char) : string;\nbegin\n if a = '>' then\n POS := '1000'\n else\n if a = '<' then\n POS := '1001'\n else\n if a = '+' then\n POS := '1010'\n else\n if a = '-' then\n POS := '1011'\n else\n if a= '.' then\n POS := '1100'\n else\n if a= ',' then\n POS := '1101'\n else\n if a='[' then\n POS :='1110'\n else\n if a=']' then\n POS := '1111';\nend;\nbegin\n {ssign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);}\n readln(s);\n n := 0;\n ss := '';\n for i := 1 to length(s) do\n ss := ss + POS(s[i]);\n for i := 1 to length(ss) do\n begin\n val(ss[i],z,code);\n n := n*2+z;\n n := n mod 1000003;\n end;\n writeln(n mod 1000003);\nend.\n"}, {"source_code": "var\nx,sum:ansistring;\ni,pas:longint;\nres : qword;\nbegin \nsum:='';\n read (x); readln;\n for i:=1 to length(x) do\n begin\n\tif (x[i]='>') then sum:=sum+'1000';\n\tif (x[i]='<') then sum:=sum+'1001';\n\tif (x[i]='+') then sum:=sum+'1010';\n\tif (x[i]='-') then sum:=sum+'1011';\n\tif (x[i]='.') then sum:=sum+'1100';\n\tif (x[i]=',') then sum:=sum+'1101';\n\tif (x[i]='[') then sum:=sum+'1110';\n\tif (x[i]=']') then sum:=sum+'1111';\n\tend;\n\t\n\t\n\tres:=0;\n\tpas:=1;\n\tfor i:=length(sum) downto 1 do\n\t begin\n\t if (sum[i]='1') then res:=res+pas;\n\t res:=res mod 1000003;\n\t pas := pas*2;\n\t pas := pas mod 1000003;\n\t end;\n\t writeln ((res ) );\nend.\n"}, {"source_code": " program Project2;\n\n\n uses\n SysUtils;\n {$APPTYPE CONSOLE}\n {$O-}\n\n var\n l,i,x:integer;\n ans,k:int64;\n s,s2:string;\n\nprocedure swap(var a,b:extended);\nvar\n c:extended;\nbegin\n c := a;\n a := b;\n b := c;\nend;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(s);\n l := length(s);\n x := 0;\n s2 := '';\n for i := 1 to l do begin\n inc(x);\n if s[i] = '>' then s2 := s2 + '1000';\n if s[i] = '<' then s2 := s2 + '1001';\n if s[i] = '+' then s2 := s2 + '1010';\n if s[i] = '-' then s2 := s2 + '1011';\n if s[i] = '.' then s2 := s2 + '1100';\n if s[i] = ',' then s2 := s2 + '1101';\n if s[i] = '[' then s2 := s2 + '1110';\n if s[i] = ']' then s2 := s2 + '1111';\n end;\n k := 1;\n l := length(s2);\n ans := 0;\n for i := l downto 1 do begin\n if s2[i] = '1' then\n ans := (ans + k) mod 1000003;\n k := (k * 2) mod 1000003;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n a:array[1..2000000] of integer;\n s:ansistring;\n i,n,z:longint;\nbegin\n read(s);\n n:=0;\n for i:=1 to length(s) do\n begin\n inc(n);\n a[n]:=1;\n case s[i] of\n '>':begin inc(n);a[n]:=0;inc(n);a[n]:=0;inc(n);a[n]:=0;end;\n '<':begin inc(n);a[n]:=0;inc(n);a[n]:=0;inc(n);a[n]:=1;end;\n '+':begin inc(n);a[n]:=0;inc(n);a[n]:=1;inc(n);a[n]:=0;end;\n '-':begin inc(n);a[n]:=0;inc(n);a[n]:=1;inc(n);a[n]:=1;end;\n '.':begin inc(n);a[n]:=1;inc(n);a[n]:=0;inc(n);a[n]:=0;end;\n ',':begin inc(n);a[n]:=1;inc(n);a[n]:=0;inc(n);a[n]:=1;end;\n '[':begin inc(n);a[n]:=1;inc(n);a[n]:=1;inc(n);a[n]:=0;end;\n ']':begin inc(n);a[n]:=1;inc(n);a[n]:=1;inc(n);a[n]:=1;end;\n end;\n end;\n z:=a[1];\n for i:=2 to n do\n begin\n z:=(z*2+a[i]);\n if z>1000003 then dec(z,1000003);\n end;\n write(z);\nend."}, {"source_code": "var s:string;\nvar t:ansistring;\nvar l,i,x:longint;\nvar h:int64;\nbegin\nreadln(s);\nl:=length(s);\nt:='';\nfor i:=1 to l do begin\n if s[i]='>' then t:=t+'1000';\n if s[i]='<' then t:=t+'1001';\n if s[i]='+' then t:=t+'1010';\n if s[i]='-' then t:=t+'1011';\n if s[i]='.' then t:=t+'1100';\n if s[i]=',' then t:=t+'1101';\n if s[i]='[' then t:=t+'1110';\n if s[i]=']' then t:=t+'1111';\nend;\nl:=length(t);\nh:=0;\nfor i:=1 to l do begin\n val(t[i],x);\n h:=(h*2+x)mod 1000003;\nend;\nwriteln(h);\nend.\n"}, {"source_code": "var i,j:longint;\n t,k:int64;\n a:array[1..4] of int64;\ns:string;\nbegin\n read(S);\n k:=1;\n for i:= length(s) downto 1 do\n begin\n\n case s[i] of\n '>': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=0;\n a[4]:=0;\n end;\n\n \n '<': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=0;\n a[4]:=1;\n end;\n '+': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=1;\n a[4]:=0;\n end;\n '-': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=1;\n a[4]:=1;\n\n end;\n '.': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=0;\n a[4]:=0;\n end;\n ',': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=0;\n a[4]:=1;\n end;\n '[': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=1;\n a[4]:=0;\n end;\n ']': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=1;\n a[4]:=1;\n end;\n end;\n if K>1000003 then k:=k mod 1000003;\n t:=(t + a[4]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[3]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[2]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[1]*k) mod 1000003;\n k:=k*2;\n \n \n \n \n \n end;\n\n\n\n write(t);\n\n\n\n end."}, {"source_code": "const\n fi='';\n fo='';\n m=1000003;\n str:array[1..8] of string=('>','<','+','-','.',',','[',']');\n dau:array[1..8] of string=('1000','1001','1010','1011','1100','1101','1110','1111');\nvar\n s,chuoi:ansistring;\n i,j,sum:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(s);\n close(input);\nend;\n\nprocedure xuly;\nbegin\n for i:=1 to length(s) do\n for j:=1 to 8 do\n if s[i]=str[j] then chuoi:=chuoi+dau[j];\n for i:=1 to length(chuoi) do sum:=(sum*2+ord(chuoi[i])-48) mod m;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(sum);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n fi='';\n fo='';\n modul=1000003;\nvar\n s: ansistring;\n i,cs: longint;\n kq: qword;\n\nfunction gt(i: qword): qword;\nvar\n j: longint;\nbegin\n result:=1;\n for j:=1 to i do result:=((result mod modul) *2) mod modul;\nend;\n\nbegin\n\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(s);\n cs:=-1;\n kq:=0;\n for i:=length(s) downto 1 do\n if s[i]='>' then\n begin\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]='<' then\n begin\n kq:=(kq+gt(cs+1)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]='+' then\n begin\n kq:=(kq+gt(cs+2)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]='-' then\n begin\n kq:=(kq+gt(cs+1)) mod modul;\n kq:=(kq+gt(cs+2)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]='.' then\n begin\n kq:=(kq+gt(cs+3)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]=',' then\n begin\n kq:=(kq+gt(cs+1)) mod modul;\n kq:=(kq+gt(cs+3)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]='[' then\n begin\n kq:=(kq+gt(cs+2)) mod modul;\n kq:=(kq+gt(cs+3)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end\n else\n if s[i]=']' then\n begin\n kq:=(kq+gt(cs+1)) mod modul;\n kq:=(kq+gt(cs+2)) mod modul;\n kq:=(kq+gt(cs+3)) mod modul;\n kq:=(kq+gt(cs+4)) mod modul;\n cs:=cs+4;\n end;\n write(kq);\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "var\n ans,i,k,m,n:longint;\n s,ss:string;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>' : k:=8;\n '<' : k:=9;\n '+' : k:=10;\n '-' : k:=11;\n '.' : k:=12;\n ',' : k:=13;\n '[' : k:=14;\n ']' : k:=15;\n end;\n ans:=(ans*16)+k;\n ans:=ans mod 1000003;\n end;\n writeln(ans);\n\nend."}, {"source_code": "const a='><+-.,[]';\nvar s:string;\n i,o:longint;\nbegin\n read(s);\n for i:=1to length(s)do\n o:=(o*16+7+pos(s[i],a))mod 1000003;\n write(o)\nend."}, {"source_code": "{$O-}\nUses Math;\nvar\n a: array [0..10] of char;\n b: array [0..10] of ansistring;\n s, s1: ansistring;\n i, j, ans, k, u: longint;\n\nbegin\n\t{$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(s);\n a[1] := '>'; b[1] := '1000';\n a[2] := '<'; b[2] := '1001';\n a[3] := '+'; b[3] := '1010';\n a[4] := '-'; b[4] := '1011';\n a[5] := '.'; b[5] := '1100';\n a[6] := ','; b[6] := '1101';\n a[7] := '['; b[7] := '1110';\n a[8] := ']'; b[8] := '1111';\n s1 := '';\n for i := 1 to length(s) do begin\n for j := 1 to 8 do\n if s[i] = a[j] then s1 := s1 + b[j];\n end;\n ans := 0;\n for i := length(s1) downto 1 do begin\n k := length(s1) - i; u := 1;\n if (s1[i] = '1') then begin\n for j := 1 to k do\n u := (u * 2) mod 1000003;\n ans := (ans + u) mod 1000003;\n end;\n end;\n write(ans);\nend."}, {"source_code": "program Project2;\n{$APPTYPE CONSOLE}\nuses SysUtils;\n\nvar i,j,k: integer;\n c: Char;\ns: int64;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n s:=0;\n while not(Eoln) do\n begin\n read(c);\n case c of\n '>': s:=s*16+8;\n '<': s:=s*16+9;\n '+':s:=s*16+10;\n '-':s:=s*16+11;\n '.':s:=s*16+12;\n ',':s:=s*16+13;\n '[':s:=s*16+14;\n ']':s:=s*16+15; \n \n end;\n s:=s mod 1000003; \n end;\n\n Writeln(s);\nend."}], "negative_code": [{"source_code": "program A_HQ9;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype myarray=array[0..10000] of longint;\nconst base=1000003;\nvar a,res : myarray;\n s,str : string;\n i,j,k : longint;\nprocedure pr(var a : myarray);\nvar z,o : longint;\nbegin\n o:=a[1]*2;\n z:=1;\n a[1]:=0;\n while o>0 do\n begin\n o:=o+a[z];\n a[z]:=o mod base;\n o:=o div base;\n inc(z);\n end;\n if z-1>a[0] then a[0]:=z-1;\nend;\nprocedure sum(var res,a : myarray);\nvar z,o : longint;\nbegin\n o:=0;\n z:=1;\n while (a[0]>=z) or (res[0]>=z) or (o>0) do\n begin\n o:=o+a[z]+res[z];\n res[z]:=o mod base;\n o:=o div base;\n inc(z);\n end;\n if z-1>res[0] then res[0]:=z-1;\nend;\nfunction ost(var res : myarray; g : longint) : longint;\nvar z,o : longint;\nbegin\n o:=0;\n for i:=res[0] downto 1 do\n begin\n o:=o*base+res[i];\n o:=o mod g;\n end;\n ost:=o;\nend;\nbegin\n readln(s);\n str:='';\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>' : str:=str+'1000';\n '<' : str:=str+'1001';\n '+' : str:=str+'1010';\n '-' : str:=str+'1011';\n '.' : str:=str+'1100';\n ',' : str:=str+'1101';\n '[' : str:=str+'1110';\n ']' : str:=str+'1111';\n end;\n end;\n for i:=1 to length(str) do\n begin\n fillchar(a,sizeof(a),0);\n if str[i]='1' then\n begin\n a[0]:=1;\n a[1]:=1;\n for j:=1 to length(str)-i do pr(a);\n sum(res,a);\n end;\n end;\n k:=ost(res,1000003);\n writeln(k);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (length(k)-i)) ) mod (1000000+3);\n end;\n bintodec:=o mod (1000000+3);\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "{$mode objfpc}\n\nprogram B;\nvar\n S: AnsiString;\n i, n: Integer;\n Code: Int64;\n\nbegin\n ReadLn (S);\n\n Code:= 0;\n\n for i:= 1 to Length (S) do\n begin\n case S [i] of\n '>': n:= 8;\n '<': n:= 9;\n '+': n:= 10;\n '-': n:= 11;\n '.': n:= 12;\n ',': n:= 13;\n '[': n:= 14;\n ']': n:= 14;\n end;\n\n Code:= (Code* 16+ n) mod 1000003;\n\n end;\n\n WriteLn (Code);\nend.\n"}, {"source_code": "var s,s1:string;\n i:longint;\n t,ans,n:int64;\n a:array[1..500]of integer;\n\nBEGIN\n readln(s);\n s1:='';\n for i:=1 to length(s) do\n case s[i] of\n '>': s1:=s1+'1000';\n '<': s1:=s1+'1001';\n '+': s1:=s1+'1010';\n '-': s1:=s1+'1011';\n '.': s1:=s1+'1100';\n ',': s1:=s1+'1101';\n '[': s1:=s1+'1110';\n ']': s1:=s1+'1111';\n end;\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s1) do\n a[i]:=ord(s1[i])-ord('0');\n n:=i;\n t:=1;\n ans:=0;\n for i:=n downto 1 do\n begin\n ans:=(ans+a[i]*t)mod 1000003;\n t:=(t*2)mod 1000003;\n end;\n writeln(ans);\nEND.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=ans+ans+1\nelse ans:=ans+ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000006);\nend.\n"}, {"source_code": "const mn=1000003;\nvar s,s1:ansistring;\n i:longint;\n n,x:int64;\n function bin(a,n:int64):int64;\n begin\n if n=0 then exit(1)\n else if n mod 2=0 then exit(sqr(bin(a,n div 2)))\n else exit(bin(a,n-1)*a);\n end;\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then s1:=s1+'1000';\n if s[i]='<' then s1:=s1+'1001';\n if s[i]='+' then s1:=s1+'1010';\n if s[i]='-' then s1:=s1+'1011';\n if s[i]='.' then s1:=s1+'1100';\n if s[i]=',' then s1:=s1+'1101';\n if s[i]='[' then s1:=s1+'1110';\n if s[i]=']' then s1:=s1+'1111';\n end;\n n:=length(s1);\n for i:=1 to length(s1) do\n begin\n if s1[i]='1' then x:=(x+(bin(2,n-i))mod mn)mod mn;\n end;\n writeln(x);\n end."}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (length(k)-i)) );\n end;\n bintodec:=o mod (1000000+3);\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram B;\nconst\n InputFile = '';\n OutputFile = '';\n module = 1000003;\nvar\n f: TextFile;\n x, s: Int64;\n st: string;\n c: char;\nbegin\n AssignFile(f, InputFile); Reset(f);\n s := 0;\n st := '><+-.,[]';\n while not eof(f) do\n begin\n Read(f, c);\n x := 8;\n x := x + pos(c, st) - 1;\n s := (s shl 4 + x) mod module;\n end;\n CloseFile(f);\n AssignFile(f, OutputFile); Rewrite(f);\n Write(f, s);\n CloseFile(f);\nend.\n"}, {"source_code": "var s:string;\n s1:string;\n b:array[1..8,1..2] of string;\n i,j,t,d,ss,sp:longint;\nbegin\n readln(s);\n b[1,1]:='>';b[1,2]:='1000';\n b[2,1]:='<';b[2,2]:='1001';\n b[3,1]:='+';b[3,2]:='1010';\n b[4,1]:='-';b[4,2]:='1011';\n b[5,1]:='.';b[5,2]:='1100';\n b[6,1]:=',';b[6,2]:='1101';\n b[7,1]:='[';b[7,2]:='1110';\n b[8,1]:=']';b[8,2]:='1111';\n s1:='';\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=b[j,1] then s1:=s1+b[j,2];\n d:=length(s1);\n ss:=0;\n for i:=1 to length(s1) do begin\n d:=d-1;\n sp:=0;\n if s1[i]='1' then begin sp:=1;\n for j:=1 to d do\n sp:=(sp mod 1000003)*2;\n ss:=(ss+sp) mod 1000003;end;end; \n writeln(ss);\nend."}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+l shl (length(k)-i)) mod 1000003;\n end;\n bintodec:=o;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "const mn=1000003;\nvar s,s1:ansistring;\n i:longint;\n n,x:int64;\n function bin(a,n:int64):int64;\n begin\n if n=0 then exit(1)\n else if n mod 2=0 then exit(sqr(bin(a,n div 2)))\n else exit(bin(a,n-1)*a);\n end;\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then s1:=s1+'1000';\n if s[i]='<' then s1:=s1+'1001';\n if s[i]='+' then s1:=s1+'1010';\n if s[i]='-' then s1:=s1+'1011';\n if s[i]='.' then s1:=s1+'1100';\n if s[i]=',' then s1:=s1+'1101';\n if s[i]='[' then s1:=s1+'1110';\n if s[i]=']' then s1:=s1+'1111';\n end;\n n:=length(s1);\n for i:=1 to length(s1) do\n begin\n if s1[i]='1' then x:=(x+(bin(2,n-i))mod mn)mod mn;\n end;\n writeln(x);\n end."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n x:=x*2;\n x:=x mod 1000003;\n if x=0 then x:=1000003; \n end;\n writeln (ans);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst H = 1000003;\nvar\n s, s1 : AnsiString;\n i : integer;\n sum : Int64;\nprocedure insert(x : Char);\nbegin\n if x = '>' then s1 := s1 + '1000';\n if x = '<' then s1 := s1 + '1001';\n if x = '+' then s1 := s1 + '1010';\n if x = '-' then s1 := s1 + '1011';\n if x = '.' then s1 := s1 + '1100';\n if x = ',' then s1 := s1 + '1101';\n if x = '[' then s1 := s1 + '1110';\n if x = ']' then s1 := s1 + '1111';\nend;\nprocedure Exchange(var s1 : AnsiString);\nvar p : int64;\nbegin\n p := 1;\n for i := 1 to (length(s1) - 1) do p := p * 2;\n for i := 1 to length(s1) do\n begin\n if s1[i] = '1' then\n begin\n sum := sum + p;\n p := p div 2;\n end\n else p := p div 2;\n end;\nend;\nBegin\n ReadLn(s);\n for i := 1 to length(s) do insert(s[i]);\n Exchange(s1);\n WriteLn(sum mod H);\nEnd."}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (length(k)-i)) );\n end;\n bintodec:=o mod (1000000+3);\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "const ma=1000003;\nvar\n c:char;\n i,j,k:longint;\n\nfunction cha:longint;\nbegin\n j:=0;\n case c of\n '>':j:=0; '<':j:=1; '+':j:=2;\n '-':j:=3; '.':j:=4; ',':j:=5;\n '[':j:=6; ']':j:=8;\n end;\n exit(j+8);\nend;\n\nbegin\n repeat read(c); k:=(k*16+cha) mod ma; until eoln;\n writeln(k);\nend."}, {"source_code": "const\n s:string=('><+-.,[]');\n a:array[1..8]of string=('1000','1001','1010','1011',\n '1100','1101','1110','1111');\nvar\n\n c:char;\n k,kk:longint;\n i,t,j:longint;\n ss:string;\n\nfunction ct(a,b:longint):longint;\nvar\n s:longint;\nbegin\n s:=1;\n while b>0 do\n begin\n if odd(b) then s:=(s*a);\n a:=sqr(a);\n b:=b shr 1;\n end;\n ct:=s;\nend;\n\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n while not eoln do\n begin\n read(c);\n ss:=ss+a[pos(c,s)];\n end;\n for i:=length(ss) downto 1 do if ss[i]='1' then\n begin\n t:=1;\n for j:=1 to length(ss)-i do t:=(t*2) mod 1000003;\n k:=(k+t) mod 1000003;\n end;\n writeln(k);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans:int64;\ni:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "var s,s1:ansistring;\n i:longint;\n t,ans,n:int64;\n a:array[1..500]of integer;\n\nBEGIN\n readln(s);\n s1:='';\n for i:=1 to length(s) do\n case s[i] of\n '>': s1:=s1+'1000';\n '<': s1:=s1+'1001';\n '+': s1:=s1+'1010';\n '-': s1:=s1+'1011';\n '.': s1:=s1+'1100';\n ',': s1:=s1+'1101';\n '[': s1:=s1+'1110';\n ']': s1:=s1+'1111';\n end;\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s1) do\n a[i]:=ord(s1[i])-ord('0');\n n:=i;\n t:=1;\n ans:=0;\n for i:=n downto 1 do\n begin\n ans:=(ans+a[i]*t)mod 1000003;\n t:=t*2;\n end;\n writeln(ans);\nEND.\n"}, {"source_code": "var\n s:string;\n k,ans,x,i:longint;\nbegin\n readln(s);\n k:=1;\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>':x:=8;\n '<':x:=9;\n '+':x:=10;\n '-':x:=11;\n '.':x:=12;\n ',':x:=13;\n '[':x:=14;\n ']':x:=15;\n else x:=0;\n end;\n ans:=(ans+((x*k) mod 1000003)) mod 1000003;\n k:=(k*16) mod 1000003;\n end;\n writeln(ans);\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:int64;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n x:=x*2;\n x:=x mod 1000003; \n end;\n writeln (ans);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n x:=x*2;\n x:=x mod 1000003;\n if x=0 then x:=1000003; \n end;\n writeln (ans);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=ans+ans+1\nelse ans:=ans+ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000006);\nend.\n"}, {"source_code": "var s:string;\n s1:string;\n b:array[1..8,1..2] of string;\n i,j,t,d,ss,sp:longint;\nbegin\n readln(s);\n b[1,1]:='>';b[1,2]:='1000';\n b[2,1]:='<';b[2,2]:='1001';\n b[3,1]:='+';b[3,2]:='1010';\n b[4,1]:='-';b[4,2]:='1011';\n b[5,1]:='.';b[5,2]:='1100';\n b[6,1]:=',';b[6,2]:='1101';\n b[7,1]:='[';b[7,2]:='1110';\n b[8,1]:=']';b[8,2]:='1111';\n s1:='';\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=b[j,1] then s1:=s1+b[j,2];\n d:=length(s1);\n ss:=0;\n for i:=1 to length(s1) do begin\n d:=d-1;\n sp:=0;\n if s1[i]='1' then begin sp:=1;\n for j:=1 to d do\n sp:=(sp mod 1000003)*2;\n ss:=(ss+sp) mod 1000003;end;end; \n writeln(ss);\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\n modul=round(1e6)+3;\nvar f1,f2:text;\n mu:array[0..101] of longint;\n c:array[chr(1)..chr(255)] of string;\n a,s:ansistring;\nprocedure mo;\nbegin\nassign(f1,fi);\nreset(f1);\nassign(F2,fo);\nrewrite(f2);\nend;\n\nprocedure dong;\nbegin\nclose(F1);\nclose(f2);\nend;\n\nprocedure nhap;\nvar i,j,kq:longint;\nbegin\nkq:=0;\n c['>']:= '1000';\n c['<']:= '1001';\n c['+']:= '1010';\n c['-']:= '1011';\n c['.']:= '1100';\n c[',']:= '1101';\n c['[']:= '1110';\n c[']']:= '1111';\nmu[0]:=1;\nfor i:=1 to 100 do\n mu[i]:=(mu[i-1]*2) mod modul;\nreadln(F1,S);\nfor i:=1 to length(s) do\n a:=a+c[s[i]];\nfor i:=1 to length(a) do\n if a[i]='1' then\n kq:=(kq+mu[length(a)-i]) mod modul;\nwriteln(F2,kq);\nend;\n\nBEGIN\nmo;\nnhap;\nDong;\nEND.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram B;\nconst\n InputFile = '';\n OutputFile = '';\n module = 1000003;\nvar\n f: TextFile;\n x, s: Int64;\n st: string;\n c: char;\nbegin\n AssignFile(f, InputFile); Reset(f);\n s := 0;\n st := '><+-.,[]';\n while not eof(f) do\n begin\n Read(f, c);\n x := 8;\n x := x + pos(c, st) - 1;\n s := (s shl 4 + x) mod module;\n end;\n CloseFile(f);\n AssignFile(f, OutputFile); Rewrite(f);\n Write(f, s);\n CloseFile(f);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n modul=round(1e6)+3;\nvar f1,f2:text;\n mu:array[0..101] of longint;\n c:array[chr(1)..chr(255)] of string;\n a,s:ansistring;\nprocedure mo;\nbegin\nassign(f1,fi);\nreset(f1);\nassign(F2,fo);\nrewrite(f2);\nend;\n\nprocedure dong;\nbegin\nclose(F1);\nclose(f2);\nend;\n\nprocedure nhap;\nvar i,j,kq:longint;\nbegin\nkq:=0;\n c['>']:= '1000';\n c['<']:= '1001';\n c['+']:= '1010';\n c['-']:= '1011';\n c['.']:= '1100';\n c[',']:= '1101';\n c['[']:= '1110';\n c[']']:= '1111';\nmu[0]:=1;\nfor i:=1 to 100 do\n mu[i]:=(mu[i-1]*2) mod modul;\nreadln(F1,S);\nfor i:=1 to length(s) do\n a:=a+c[s[i]];\nfor i:=1 to length(a) do\n if a[i]='1' then\n kq:=(kq+mu[length(a)-i]) mod modul;\nwriteln(F2,kq);\nend;\n\nBEGIN\nmo;\nnhap;\nDong;\nEND.\n"}, {"source_code": "{$Q-}\n{$coperators on}\nvar s,k:ansistring;\n i:longint;\nfunction reverse(s:string):string;\n var w:string;\n i:longint;\n begin\n w:='';\n for i:=length(s) downto 1 do\n w+=s[i];\n reverse:=w;\n end;\nfunction retranslate(s:ansistring;o:byte):qword;//o-cimal to decimal\n var i,t:longint;\n p,e,k:qword;\n begin\n s:=reverse(s);\n e:=1;\n p:=0;\n For i:=0 to length(s)-1 do\n begin\n if s[i+1] in ['0'..'9'] then val(s[i+1],k,t)\n else k:=ord(s[i+1])-55;\n p+=(k*e) mod 1000003;\n e*=o mod 1000003;\n end;\n retranslate:=p mod 1000003;\n end;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(retranslate(k,2));\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=(x*2) mod 1000003;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=ans+ans+1\nelse ans:=ans+ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000006);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:int64;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n if ans=0 then ans:=1000003; \n x:=x*2;\n x:=x mod 1000003;\n if x=0 then x:=1000003; \n end;\n writeln (ans);\n readln;\n readln;\nend.\n"}, {"source_code": "var s:string;\n s1:string;\n b:array[1..8,1..2] of string;\n i,j,t,d,ss,sp:longint;\nbegin\n readln(s);\n b[1,1]:='>';b[1,2]:='1000';\n b[2,1]:='<';b[2,2]:='1001';\n b[3,1]:='+';b[3,2]:='1010';\n b[4,1]:='-';b[4,2]:='1011';\n b[5,1]:='.';b[5,2]:='1100';\n b[6,1]:=',';b[6,2]:='1101';\n b[7,1]:='[';b[7,2]:='1110';\n b[8,1]:=']';b[8,2]:='1111';\n s1:='';\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=b[j,1] then s1:=s1+b[j,2];\n d:=length(s1);\n ss:=0;\n for i:=1 to length(s1) do begin\n d:=d-1;\n sp:=0;\n if s1[i]='1' then begin sp:=1;\n for j:=1 to d do\n sp:=(sp mod 1000003)*2;\n ss:=(ss+sp) mod 1000003;end;end; \n writeln(ss);\nend."}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do\nif s[i]='1' then ans:=(ans*2+1)mod 1000003\nelse ans:=(ans*2)mod 1000003;\nwrite(ans);\nend."}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (i-1)) ) mod 1000003;\n end;\n bintodec:=o mod 1000003;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:='0001'+k;\n '<':k:='1001'+k;\n '+':k:='0101'+k;\n '-':k:='1101'+k;\n '.':k:='0011'+k;\n ',':K:='1011'+k;\n '[':k:='0111'+k;\n ']':k:='1111'+k;\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:int64;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n x:=x*2;\n x:=x mod 1000003; \n end;\n writeln (ans);\nend.\n"}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (i-1)) );\n end;\n bintodec:=o mod 1000003;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:='0001'+k;\n '<':k:='1001'+k;\n '+':k:='0101'+k;\n '-':k:='1101'+k;\n '.':k:='0011'+k;\n ',':K:='1011'+k;\n '[':k:='0111'+k;\n ']':k:='1111'+k;\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,i,sum,j,x,z,f,f1,se,se1:integer;\n s,k,p:string;\n\n function per(k:string):int64;\n var\n i:integer;\n r:int64;\n begin\n r:=0;\n for i:=1 to length(k) do\n if k[i]='0' then r:=(r mod 1000003)*2\n else r:=(r mod 1000003)*2+1;\n per:=r;\n end;\n\n\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then k:='1000';\n if s[i]='<' then k:='1001';\n if s[i]='[' then k:='1110';\n if s[i]=']' then k:='1111';\n if s[i]='+' then k:='1010';\n if s[i]='-' then k:='1011';\n if s[i]='.' then k:='1100';\n if s[i]=',' then k:='1101';\n p:=p+k;\n end;\n writeln(per(p));\n\nend.\n"}, {"source_code": " var\n x:string;\n i:longint;\n sum,biner:int64;\n\n function p16(n:int64):int64;\n var j:longint;sum:int64;\n begin\n sum:=1;\n for j:=1 to n do\n begin\n sum:=sum*16;\n end;\n p16:=sum;\n end;\n\n \n begin\n readln(x);\n\n for i:=1 to length(x) do\n begin\n case x[i] of\n '>' : biner:=8;\n '<' : biner:=9;\n '+' : biner:=10;\n '-': biner:=11;\n '.': biner:=12;\n ',': biner:=13;\n '[': biner:=14;\n ']': biner:=15;\n end;\n \n sum:=(sum+(biner*p16(length(x)-i))) mod 1000003;\n end;\n writeln(sum);\n\n end."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math,classes;\n\nfunction bintohex(bin:string):string;\nvar i,j:integer;\nstr,st:string;\nbegin\nstr:='';\nst:='';\nj:=1;\ni:=1;\nwhile i<=length(bin)do\nbegin\nstr:=str+bin[i];\nif (j=4) then\nbegin\n\n //hex tetrads---------------------------------------------\n if (str='0000') then st:=st+'0';\n if (str='0001') then st:=st+'1';\n if (str='0010') then st:=st+'2';\n if (str='0011') then st:=st+'3';\n if (str='0100') then st:=st+'4';\n if (str='0101') then st:=st+'5';\n if (str='0110') then st:=st+'6';\n if (str='0111') then st:=st+'7';\n if (str='1000') then st:=st+'8';\n if (str='1001') then st:=st+'9';\n if (str='1010') then st:=st+'A';\n if (str='1011') then st:=st+'B';\n if (str='1100') then st:=st+'C';\n if (str='1101') then st:=st+'D';\n if (str='1110') then st:=st+'E';\n if (str='1111') then st:=st+'F';\n // writeln(str);\n str:='';\n j:=0;\n //hex tetrads---------------------------------------------\nend;\nj:=j+1;\ni:=i+1;\nend;\nbintohex:=st;\nend;\n{\nfunction HexToDec(const HexStr: string): integer;\nvar v, i: integer;\nbegin\nResult := 0;\nfor i := 1 to Length(HexStr) do\nbegin\nif HexStr in ['0'..'9'] then v := Ord(HexStr) - Ord(?0?) else\nif UpCase(HexStr) in ['A'..'F'] then\nv := ord(UpCase(HexStr)) - Ord(?A?) - 10 else\nbegin\nResult := 0;\nexit;\nend;\nResult := Result + v * Round(Power(16, Length(HexStr) - i));\nend;\nend;\n{\nfunction hextodec(hex:string):extended;\nvar st,st1:string;\ni,k:integer;\nj:extended;\nbegin\nj:=0;\nresult:=0;\nk:=length(hex);\nfor i:=0 to length(hex)-1 do\nbegin\nst1:=hex[k];\nif st1='A' then st1:='10';\nif st1='B' then st1:='11';\nif st1='C' then st1:='12';\nif st1='D' then st1:='13';\nif st1='E' then st1:='14';\nif st1='F' then st1:='15';\nj:=j+(strtoint(st1)*power(16,i));\n//writeln(st1);\nk:=k-1;\n//writeln(power(16,i):4:2);\nend;\nhextodec:=j;\nend;\n }\n\nvar i,k:integer;\nc:int64;\ns,s1,res,res2:string;\nmess:boolean;\nbegin\n\n c:=0;\n //readln(s);\n s:='++++[>,.<-]';\n s1:=s;\n res:='';\n for i := 1 to length(s) do\n begin\n if (s1[i]='>') then\n res:=res+'1000';\n if (s1[i]='<') then\n res:=res+'1001';\n if (s1[i]='+') then\n res:=res+'1010';\n if (s1[i]='-') then\n res:=res+'1011';\n if (s1[i]='.') then\n res:=res+'1100';\n if (s1[i]=',') then\n res:=res+'1101';\n if (s1[i]='[') then\n res:=res+'1110';\n if (s1[i]=']') then\n res:=res+'1111';\nend;\nres:=(bintohex(res));\nc:= StrToInt64('$'+ res);\nc:=c mod 1000003;\nwriteln(c);\nreadln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "var i,j:integer;\n t,k:int64;\n a:array[1..4] of int64 ;\ns:string;\nbegin\n read(S);\n k:=1;\n for i:= length(s) downto 1 do\n begin\n\n case s[i] of\n '>': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=0;\n a[4]:=0;\n end;\n\n \n '<': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=0;\n a[4]:=1;\n end;\n '+': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=1;\n a[4]:=0;\n end;\n '-': begin\n a[1]:=1;\n a[2]:=0;\n a[3]:=1;\n a[4]:=1;\n\n end;\n '.': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=0;\n a[4]:=0;\n end;\n ',': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=0;\n a[4]:=1;\n end;\n '[': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=1;\n a[4]:=0;\n end;\n ']': begin\n a[1]:=1;\n a[2]:=1;\n a[3]:=1;\n a[4]:=1;\n end;\n end;\n t:=(t + a[4]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[3]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[2]*k) mod 1000003;\n k:=k*2;\n t:=(t + a[1]*k) mod 1000003;\n k:=k*2;\n \n \n \n \n \n end;\n\n\n\n write(t);\n\n\n\n end."}, {"source_code": "program unary;\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\nvar\n fin,fout:text;\n s:int64;\n st:string;\n i:longint;\nfunction deg(x:integer):int64;\nvar\n k:longint;\n p:int64;\nbegin\n p:=1;\n for k:=1 to x do\n p:=p*2;\n deg:=p;\nend;\n\nbegin\n assign(fin,''); assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,st);\n s:=0;\n for i:=length(st)-1 downto 0 do\n begin\n if st[i+1]='>' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*8) mod 1000003;\n if st[i+1]='<' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*9) mod 1000003;\n if st[i+1]='+' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*10) mod 1000003;\n if st[i+1]='-' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*11) mod 1000003;\n if st[i+1]='.' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*12) mod 1000003;\n if st[i+1]=',' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*13) mod 1000003;\n if st[i+1]='[' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*14) mod 1000003;\n if st[i+1]=']' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*15) mod 1000003;\n end;\n writeln(fout,s mod 1000003);\n close(fin); close(fout);\nend.\n"}, {"source_code": "const ma=1000003;\nvar\n c:char;\n i,j,k:longint;\n\nfunction cha:longint;\nbegin\n j:=0;\n case c of\n '>':j:=0; '<':j:=1; '+':j:=2;\n '-':j:=3; '.':j:=4; ',':j:=5;\n '[':j:=6; ']':j:=8;\n end;\n exit(j+8);\nend;\n\nbegin\n repeat read(c); k:=(k*16+cha) mod ma; until eoln;\n writeln(k);\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2 mod 1000003;\n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "var sl:string;\n i,j,k:longint;\n x,y,z,os,otv:int64;\nfunction stp(ii:int64):int64;\nvar j1,j2:int64;\nbegin\n if ii=0 then stp:=1\n else\n if (ii mod 2)=0 then begin j1:=stp(ii div 2); stp:=j1*j1; end\n else stp:=stp(ii-1)*2;\nend;\nbegin\nos:=1000003;\n{assign(output,'output.txt'); rewrite(output);\nassign(input,'input.txt'); reset(input); }\nread(sl);\nk:=length(sl);\notv:=0;\nfor i:=1 to k do\nbegin\n if sl[i]='>' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n end;\n if sl[i]='<' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+(x div 8)) mod os;\n end;\n if sl[i]='+' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 4) mod os;\n end;\nif sl[i]='-' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 8) mod os;\n otv:=(otv+x div 4) mod os;\n end;\nif sl[i]='.' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 2) mod os;\n end;\nif sl[i]=',' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 2) mod os;\n otv:=(otv+x div 8) mod os;\n end;\nif sl[i]='[' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 2) mod os;\n otv:=(otv+x div 4) mod os;\n end;\nif sl[i]=']' then\n begin\n x:=stp(4*(k+1-i)-1);\n otv:=(otv+x) mod os;\n otv:=(otv+x div 2) mod os;\n otv:=(otv+x div 4) mod os;\n otv:=(otv+x div 8) mod os;\n end;\nend;\nwrite(otv);\nend.\n"}, {"source_code": "var s,s1:ansistring;\n i,p:longint;\nfunction BIN_DEC(x:string):longint;\nconst digits:array [0..1] of char = ('0','1');\nvar res,ves:longint; i,j:byte;\nbegin\n res:=0; ves:=1;\n for i:=length(x) downto 1 do begin\n j:=0;\n while (digits[j]<>x[i]) do inc(j);\n res:=res+ves*j;\n ves:=ves*2;\n end;\n BIN_DEC:=res;\nend;\n begin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='>' then s1:=s1+'1000'\n else if s[i]='<' then s1:=s1+'1001'\n else if s[i]='+' then s1:=s1+'1010'\n else if s[i]='-' then s1:=s1+'1011'\n else if s[i]='.' then s1:=s1+'1100'\n else if s[i]=',' then s1:=s1+'1101'\n else if s[i]='[' then s1:=s1+'1110'\n else if s[i]=']' then s1:=s1+'1111';\n writeln(BIN_DEC(s1));\n end."}, {"source_code": " var\n x,biner:string;\n i,temp:longint;\n binary:int64;\n\n function pangkat(n:longint):int64;\n var i:longint; sum:int64;\n begin\n sum:=1;\n for i:=1 to n do\n begin\n sum:=sum*2;\n end;\n pangkat:=sum;\n end;\n \n begin\n readln(x);\n for i:=1 to length(x) do\n begin\n case x[i] of\n '>' : biner:=biner+'1000';\n '<' : biner:=biner+'1001';\n '+' : biner:=biner+'1010';\n '-' : biner:=biner+'1011';\n '.' : biner:=biner+'1100';\n ',' : biner:=biner+'1101';\n '[' : biner:=biner+'1110';\n ']' : biner:=biner+'1111';\n end;\n end;\n\n for i:=length(biner) downto 1 do\n begin\n val(biner[i],temp);\n binary:=binary + (temp * pangkat(length(biner)-i));\n end;\n\n writeln(binary mod 1000003);\n\n end."}, {"source_code": "program Project23;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ni,p,k:integer;\na,b,c,d:string;\n\n\nfunction bin2dec(s:string):int64;\n var x,j:integer;\n begin\n x:=0;\n for j:=1 to length(s) do\n begin\n x:=x+ord(s[j])-ord('0');\n if j':b:=b+'1000';\n '<':b:=b+'1001';\n '+':b:=b+'1010';\n '-':b:=b+'1011';\n '.':b:=b+'1100';\n ',':b:=b+'1101';\n '[':b:=b+'1110';\n ']':b:=b+'1111';\n end;\np:=0;\nk:=0;\nwhile length(b)>20 do\ndelete(b,1,1);\n\nwriteln(bin2dec(b) mod 1000003);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=ans+ans+1\nelse ans:=ans+ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000006);\nend.\n"}, {"source_code": "const ma=1000003;\nvar\n c:char;\n i,j,k:longint;\n\nfunction cha:longint;\nbegin\n j:=0;\n case c of\n '>':j:=0; '<':j:=1; '+':j:=2;\n '-':j:=3; '.':j:=4; ',':j:=5;\n '[':j:=6; ']':j:=8;\n end;\n exit(j+8);\nend;\n\nbegin\n repeat read(c); k:=(k*16+cha) mod ma; until eoln;\n writeln(k);\nend."}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=(ans*2+1)\nelse ans:=(ans*2);\n//ans:=ans mod 1000003;\nend;\nwrite(ans mod 1000003);\nend.\n"}, {"source_code": "{$mode objfpc}\n\nprogram B;\nvar\n S: AnsiString;\n i, n: Integer;\n Code: Int64;\n\nbegin\n ReadLn (S);\n\n Code:= 0;\n\n for i:= 1 to Length (S) do\n begin\n case S [i] of\n '>': n:= 8;\n '<': n:= 9;\n '+': n:= 10;\n '-': n:= 11;\n '.': n:= 12;\n ',': n:= 13;\n '[': n:= 14;\n ']': n:= 14;\n end;\n\n Code:= (Code* 16+ n) mod 1000003;\n\n end;\n\n WriteLn (Code);\nend.\n"}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}{$O-}\n\nuses\n SysUtils;\nvar\n s: string;\n c: char;\n\nfunction BIN_DEC(x:string):longint;\nconst digits:array [0..1] of char = ('0','1');\nvar res,ves:longint; i,j:byte;\nbegin\n res:=0; ves:=1;\n for i:=length(x) downto 1 do begin\n j:=0;\n while (digits[j]<>x[i]) do inc(j);\n res:=(res+ves*j);\n ves:=ves*2 mod 1000003;\n end;\n BIN_DEC:=res;\nend;\nbegin\n while not eoln do\n begin\n read(c);\n case c of\n '>':\n s := s + '1000';\n '<':\n s := s + '1001';\n '+':\n s := s + '1010';\n '-':\n s := s + '1011';\n '.':\n s := s + '1100';\n ',':\n s := s + '1101';\n '[':\n s := s + '1110';\n ']':\n s := s + '1111';\n end;\n end;\n write(BIN_DEC(s));\nend.\n"}, {"source_code": "var\n s:string;\n k,ans,x,i:longint;\nbegin\n readln(s);\n k:=1;\n for i:=1 to length(s) do\n begin\n case s[i] of\n '>':x:=8;\n '<':x:=9;\n '+':x:=10;\n '-':x:=11;\n '.':x:=12;\n ',':x:=13;\n '[':x:=14;\n ']':x:=15;\n else x:=0;\n end;\n ans:=(ans+((x*k) mod 1000003)) mod 1000003;\n k:=(k*16) mod 1000003;\n end;\n writeln(ans);\nend."}, {"source_code": "var s:string;\n s1:string;\n b:array[1..8,1..2] of string;\n i,j,t,d,ss,sp:longint;\nbegin\n readln(s);\n b[1,1]:='>';b[1,2]:='1000';\n b[2,1]:='<';b[2,2]:='1001';\n b[3,1]:='+';b[3,2]:='1010';\n b[4,1]:='-';b[4,2]:='1011';\n b[5,1]:='.';b[5,2]:='1100';\n b[6,1]:=',';b[6,2]:='1101';\n b[7,1]:='[';b[7,2]:='1110';\n b[8,1]:=']';b[8,2]:='1111';\n s1:='';\n for i:=1 to length(s) do\n for j:=1 to 8 do \n if s[i]=b[j,1] then s1:=s1+b[j,2];\n d:=length(s1);\n ss:=0;\n for i:=1 to length(s1) do begin\n d:=d-1;\n sp:=0;\n if s1[i]='1' then begin sp:=1;\n for j:=1 to d do\n sp:=(sp mod 1000003)*2;\n ss:=(ss+sp) mod 1000003;end;end; \n writeln(ss);\nend."}, {"source_code": "program Project4;\n{$APPTYPE CONSOLE}\n\nvar i,j: integer;\n c: char;\n s: string;\n n,m: int64;\nbegin\n s := '';\n while not eof do\n begin\n read(c);\n case c of\n '>': s := s + '1000';\n '<': s := s + '1001';\n '+': s := s + '1010';\n '-': s := s + '1011';\n '.': s := s + '1100';\n ',': s := s + '1101';\n '[': s := s + '1110';\n ']': s := s + '1111';\n end;\n end;\n n := 0;\n for i := 1 to length(s) do\n if s[i] = '1' then\n begin\n j := length(s)-i;\n m := 2;\n if j = 0 then m := 1;\n while j-1 > 0 do\n begin\n m := 2 * m;\n DEC(j);\n end;\n n := n + m;\n end;\n write(n MOD 1000003);\nend."}, {"source_code": "program unary;\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\nvar\n fin,fout:text;\n s:int64;\n st:string;\n i:longint;\nfunction deg(x:integer):int64;\nvar\n k:longint;\n p:int64;\nbegin\n p:=1;\n for k:=1 to x do\n p:=p*2;\n deg:=p;\nend;\n\nbegin\n assign(fin,''); assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,st);\n s:=0;\n for i:=length(st)-1 downto 0 do\n begin\n if st[i+1]='>' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*8) mod 1000003;\n if st[i+1]='<' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*9) mod 1000003;\n if st[i+1]='+' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*10) mod 1000003;\n if st[i+1]='-' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*11) mod 1000003;\n if st[i+1]='.' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*12) mod 1000003;\n if st[i+1]=',' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*13) mod 1000003;\n if st[i+1]='[' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*14) mod 1000003;\n if st[i+1]=']' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*15) mod 1000003;\n end;\n writeln(fout,s mod 1000003);\n close(fin); close(fout);\nend.\n"}, {"source_code": "var\n x:string;\n i:longint;\n sum,biner:int64;\n\nfunction p16(n:int64):int64;\nvar j:longint;sum:int64;\nbegin\n sum:=1;\n for j:=1 to n do\n begin\n sum:=sum*16;\n end;\n p16:=sum;\nend;\n\n \nbegin\nreadln(x);\n\nfor i:=1 to length(x) do\nbegin\n case x[i] of\n '>' : biner:=8;\n '<' : biner:=9;\n '+' : biner:=10;\n '-': biner:=11;\n '.': biner:=12;\n ',': biner:=13;\n '[': biner:=14;\n ']': biner:=15;\n end;\n \n sum:=sum+(biner*p16(length(x)-i));\nend;\nwriteln(sum mod 1000003);\n\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2 mod 1000003;\n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2 mod 1000003;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (i-1)) );\n end;\n bintodec:=o mod 1000003;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:='0001'+k;\n '<':k:='1001'+k;\n '+':k:='0101'+k;\n '-':k:='1101'+k;\n '.':k:='0011'+k;\n ',':K:='1011'+k;\n '[':k:='0111'+k;\n ']':k:='1111'+k;\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=(x*2) mod 1000003;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math,classes;\n\nfunction bintohex(bin:string):string;\nvar i,j:integer;\nstr,st:string;\nbegin\nstr:='';\nst:='';\nj:=1;\ni:=1;\nwhile i<=length(bin)do\nbegin\nstr:=str+bin[i];\nif (j=4) then\nbegin\n\n //hex tetrads---------------------------------------------\n if (str='0000') then st:=st+'0';\n if (str='0001') then st:=st+'1';\n if (str='0010') then st:=st+'2';\n if (str='0011') then st:=st+'3';\n if (str='0100') then st:=st+'4';\n if (str='0101') then st:=st+'5';\n if (str='0110') then st:=st+'6';\n if (str='0111') then st:=st+'7';\n if (str='1000') then st:=st+'8';\n if (str='1001') then st:=st+'9';\n if (str='1010') then st:=st+'A';\n if (str='1011') then st:=st+'B';\n if (str='1100') then st:=st+'C';\n if (str='1101') then st:=st+'D';\n if (str='1110') then st:=st+'E';\n if (str='1111') then st:=st+'F';\n // writeln(str);\n str:='';\n j:=0;\n //hex tetrads---------------------------------------------\nend;\nj:=j+1;\ni:=i+1;\nend;\nbintohex:=st;\nend;\n{\nfunction HexToDec(const HexStr: string): integer;\nvar v, i: integer;\nbegin\nResult := 0;\nfor i := 1 to Length(HexStr) do\nbegin\nif HexStr in ['0'..'9'] then v := Ord(HexStr) - Ord(?0?) else\nif UpCase(HexStr) in ['A'..'F'] then\nv := ord(UpCase(HexStr)) - Ord(?A?) - 10 else\nbegin\nResult := 0;\nexit;\nend;\nResult := Result + v * Round(Power(16, Length(HexStr) - i));\nend;\nend;\n{\nfunction hextodec(hex:string):extended;\nvar st,st1:string;\ni,k:integer;\nj:extended;\nbegin\nj:=0;\nresult:=0;\nk:=length(hex);\nfor i:=0 to length(hex)-1 do\nbegin\nst1:=hex[k];\nif st1='A' then st1:='10';\nif st1='B' then st1:='11';\nif st1='C' then st1:='12';\nif st1='D' then st1:='13';\nif st1='E' then st1:='14';\nif st1='F' then st1:='15';\nj:=j+(strtoint(st1)*power(16,i));\n//writeln(st1);\nk:=k-1;\n//writeln(power(16,i):4:2);\nend;\nhextodec:=j;\nend;\n }\n\nvar i,k:integer;\nc:int64;\ns,s1,res,res2:string;\nmess:boolean;\nbegin\n\n c:=0;\n //readln(s);\n s:='++++[>,.<-]';\n s1:=s;\n res:='';\n for i := 1 to length(s) do\n begin\n if (s1[i]='>') then\n res:=res+'1000';\n if (s1[i]='<') then\n res:=res+'1001';\n if (s1[i]='+') then\n res:=res+'1010';\n if (s1[i]='-') then\n res:=res+'1011';\n if (s1[i]='.') then\n res:=res+'1100';\n if (s1[i]=',') then\n res:=res+'1101';\n if (s1[i]='[') then\n res:=res+'1110';\n if (s1[i]=']') then\n res:=res+'1111';\nend;\nres:=(bintohex(res));\nc:= StrToInt64('$'+ res);\nc:=c mod 1000003;\nwriteln(c);\nreadln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": " var\n x,biner:string;\n i,temp:int64;\n binary:int64;\n\n function pangkat(n:longint):int64;\n var i:longint; sum:int64;\n begin\n sum:=1;\n for i:=1 to n do\n begin\n sum:=sum*2;\n end;\n pangkat:=sum;\n end;\n \n begin\n readln(x);\n i:=1;\n while i<=length(x) do\n begin\n case x[i] of\n '>' : biner:=biner+'1000';\n '<' : biner:=biner+'1001';\n '+' : biner:=biner+'1010';\n '-' : biner:=biner+'1011';\n '.' : biner:=biner+'1100';\n ',' : biner:=biner+'1101';\n '[' : biner:=biner+'1110';\n ']' : biner:=biner+'1111';\n end;\n \n inc(i);\n end; \n \n i:=length(biner);\n while i>=1 do\n begin\n val(biner[i],temp);\n binary:=binary + (temp * pangkat(length(biner)-i));\n dec(i);\n end;\n\n writeln(binary mod 1000003);\n\n end."}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans:int64;\ni:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "{$r-, s-, q-, i-, o+}\nconst\n base = round(1e6) + 3;\nvar\n s, t : ansistring;\n n, i, j, p, ans : longint;\n brainfuck, unary : array [0..200] of ansistring;\nbegin\n readln(s);\n n := length(s);\n for i := 1 to n do\n for j := 1 to 8 do\n if (s[i] = brainfuck[j]) then\n t := t + unary[j];\n n := length(t);\n p := 1;\n for i := n downto 1 do\n begin\n ans := (ans + (ord(t[i]) - ord('0')) * p) mod base;\n p := (p + p) mod base;\n end;\n writeln(ans);\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=(x*2) mod 1000003;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "var l,i,j: integer;\ns,st:string;\na,b:int64;\nbegin\n read(s);\n l:=(length(s)*4)-1;\n a:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='>' then st:='1000';\n if s[i]='<' then st:='1001';\n if s[i]='+' then st:='1010';\n if s[i]='-' then st:='1011';\n if s[i]='.' then st:='1100';\n if s[i]=',' then st:='1101';\n if s[i]='[' then st:='1110';\n if s[i]=']' then st:='1111';\n b:=1;\n if st[1]='1' then\n for j:=1 to l do\n begin\n b:=b*2;\n end else b:=0;\n l:=l-1;\n a:=a+b;\n a:=a mod 1000003;\n b:=1;\n if st[2]='1' then\n for j:=1 to l do\n begin\n b:=b*2;\n end else b:=0;\n l:=l-1;\n a:=a+b;\n a:=a mod 1000003;\n b:=1;\n if st[3]='1' then\n for j:=1 to l do\n begin\n b:=b*2;\n end else b:=0;\n l:=l-1;\n a:=a+b;\n a:=a mod 1000003;\n b:=1;\n if st[4]='1' then\n for j:=1 to l do\n begin\n b:=b*2;\n end else b:=0;\n l:=l-1;\n a:=a+b;\n a:=a mod 1000003;\n end;\n write(a);\nend."}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=(ans*2+1)\nelse ans:=(ans*2);\nans:=ans mod 1000003;\nend;\nwrite(ans);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2 mod 1000003;\n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE} {$O-} {$R+}\n\nuses\n sysutils,\n math;\n\nvar\n n, k: int64;\n i: integer;\n s, t: string;\n //a: array [] of integer;\n\nbegin\n //reset(input, 'INPUT.TXT');\n //rewrite(output, 'OUTPUT.TXT');\n\n read(s);\n\n for i := 1 to length(s) do\n case s[i] of\n '>': t := t + '1000';\n '<': t := t + '1001';\n '+': t := t + '1010';\n '-': t := t + '1011';\n '.': t := t + '1100';\n ',': t := t + '1101';\n '[': t := t + '1110';\n ']': t := t + '1111'\n end;\n\n i := length(t); n := 0; k := 1;\n while i > 0 do begin\n n := (n + k * (ord(t[i]) - 48)) mod 1000003;\n k := k * 2;\n dec(i);\n end;\n\n write(n)\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nif ans mod 1000003 <>0 then ans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "program unary;\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\nvar\n fin,fout:text;\n s:int64;\n st:string;\n i:longint;\nfunction deg(x:integer):int64;\nvar\n k:longint;\n p:int64;\nbegin\n p:=1;\n for k:=1 to x do\n p:=p*2;\n deg:=p;\nend;\n\nbegin\n assign(fin,''); assign(fout,'');\n reset(fin); rewrite(fout);\n readln(fin,st);\n s:=0;\n for i:=length(st)-1 downto 0 do\n begin\n if st[i+1]='>' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*8) mod 1000003;\n if st[i+1]='<' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*9) mod 1000003;\n if st[i+1]='+' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*10) mod 1000003;\n if st[i+1]='-' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*11) mod 1000003;\n if st[i+1]='.' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*12) mod 1000003;\n if st[i+1]=',' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*13) mod 1000003;\n if st[i+1]='[' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*14) mod 1000003;\n if st[i+1]=']' then\n s:=s mod 1000003+(deg((length(st)-1-i)*4)*15) mod 1000003;\n end;\n writeln(fout,s mod 1000003);\n close(fin); close(fout);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\nfunction step(i : longint): int64;\nvar\n j: longint;\n q : int64;\nbegin\n q := 1;\n for j:= 1 to i do\n q := q * 2;\n step := q;\nend;\nvar\n str: string;\n j, sum: int64;\n i: longint;\n a: array[1..400] of longint;\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n readln(str);\n j := 1;\n for i := 1 to length(str) do\n begin\n if str[i] = '>' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '<' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '+' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '-' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '.' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ',' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '[' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ']' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4);\n end;\n end;\n sum := 0;\n for i := 1 to j do\n begin\n if a[i] = 1 then\n sum := sum + step(j - i - 1);\n end;\n writeln(sum mod 1000003);\nend.\n"}, {"source_code": "var s,st: ansistring;\na,b:int64;\ni,j:longint;\nbegin\n read(s);\n a:=0;\n st:='';\n for i:=1 to length(s) do\n begin\n if s[i]='>' then st:=st+'1000';\n if s[i]='<' then st:=st+'1001';\n if s[i]='+' then st:=st+'1010';\n if s[i]='-' then st:=st+'1011';\n if s[i]='.' then st:=st+'1100';\n if s[i]=',' then st:=st+'1101';\n if s[i]='[' then st:=st+'1110';\n if s[i]=']' then st:=st+'1111';\n end;\n for i:=1 to length(st) do\n begin\n b:=1;\n if st[i]='1' then\n for j:=1 to length(st)-i do\n begin\n b:=b*2;\n end else b:=0;\n a:=a+b;\n a:=a mod 1000003;\n end;\n write(a);\nend."}, {"source_code": "var\n x:string;\n i:longint;\n sum,biner:int64;\n\nfunction p16(n:int64):int64;\nvar j:longint;sum:int64;\nbegin\n sum:=1;\n for j:=1 to n do\n begin\n sum:=sum*16;\n end;\n p16:=sum;\nend;\n\n \nbegin\nreadln(x);\n\nfor i:=1 to length(x) do\nbegin\n case x[i] of\n '>' : biner:=8;\n '<' : biner:=9;\n '+' : biner:=10;\n '-': biner:=11;\n '.': biner:=12;\n ',': biner:=13;\n '[': biner:=14;\n ']': biner:=15;\n end;\n \n sum:=sum+(biner*p16(length(x)-i));\nend;\nwriteln(sum mod 1000003);\n\nend."}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}{$O-}\n\nuses\n SysUtils;\nvar\n s: string;\n c: char;\n\nfunction BIN_DEC(x:string):longint;\nconst digits:array [0..1] of char = ('0','1');\nvar res,ves:longint; i,j:byte;\nbegin\n res:=0; ves:=1;\n for i:=length(x) downto 1 do begin\n j:=0;\n while (digits[j]<>x[i]) do inc(j);\n res:=(res+ves*j) mod 1000003;\n ves:=ves*2;\n end;\n BIN_DEC:=res;\nend;\nbegin\n while not eoln do\n begin\n read(c);\n case c of\n '>':\n s := s + '1000';\n '<':\n s := s + '1001';\n '+':\n s := s + '1010';\n '-':\n s := s + '1011';\n '.':\n s := s + '1100';\n ',':\n s := s + '1101';\n '[':\n s := s + '1110';\n ']':\n s := s + '1111';\n end;\n end;\n write(BIN_DEC(s));\nend.\n"}, {"source_code": "var\n s,ss: string;\n i,z,code: longint;\n n: int64;\nfunction POS(a: char) : string;\nbegin\n if a = '>' then\n POS := '1000'\n else\n if a = '<' then\n POS := '1001'\n else\n if a = '+' then\n POS := '1010'\n else\n if a = '-' then\n POS := '1011'\n else\n if a= '.' then\n POS := '1100'\n else\n if a= ',' then\n POS := '1101'\n else\n if a='[' then\n POS :='1110'\n else\n if a=']' then\n POS := '1111';\nend;\nbegin\n {assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);}\n readln(s);\n n := 0;\n ss := '';\n for i := 1 to length(s) do\n ss := ss + POS(s[i]);\n for i := 1 to length(ss) do\n begin\n val(ss[i],z,code);\n n := n*2+z;\n end;\n writeln(n mod 1000003);\nend.\n"}, {"source_code": " var\n x,biner:string;\n i,temp:int64;\n binary:int64;\n\n function pangkat(n:int64):int64;\n var i:int64; sum:int64;\n begin\n sum:=1; i:=1;\n while i<=n do\n begin\n sum:=sum*2;\n inc(i);\n end;\n pangkat:=sum;\n end;\n \n begin\n readln(x);\n i:=1;\n while i<=length(x) do\n begin\n case x[i] of\n '>' : biner:=biner+'1000';\n '<' : biner:=biner+'1001';\n '+' : biner:=biner+'1010';\n '-' : biner:=biner+'1011';\n '.' : biner:=biner+'1100';\n ',' : biner:=biner+'1101';\n '[' : biner:=biner+'1110';\n ']' : biner:=biner+'1111';\n end;\n \n inc(i);\n end; \n \n i:=length(biner);\n while i>=1 do\n begin\n val(biner[i],temp);\n binary:=binary + (temp * pangkat(length(biner)-i));\n dec(i);\n end;\n\n writeln(binary mod 1000003);\n\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,i,sum,j,x,z,f,f1,se,se1:integer;\n s,k,p:string;\n\n function per(k:string):int64;\n var\n i:integer;\n r:int64;\n begin\n r:=0;\n for i:=1 to length(k) do\n if k[i]='0' then r:=(r mod 1000003)*2\n else r:=(r mod 1000003)*2+1;\n per:=r;\n end;\n\n\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then k:='1000';\n if s[i]='<' then k:='1001';\n if s[i]='[' then k:='1110';\n if s[i]=']' then k:='1111';\n if s[i]='+' then k:='1010';\n if s[i]='-' then k:='1011';\n if s[i]='.' then k:='1100';\n if s[i]=',' then k:='1101';\n p:=p+k;\n end;\n writeln(per(p));\n\nend.\n\n begin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='>' then k:='1000';\n if s[i]='<' then k:='1001';\n if s[i]='[' then k:='1110';\n if s[i]=']' then k:='1111';\n if s[i]='+' then k:='1010';\n if s[i]='-' then k:='1011';\n if s[i]='.' then k:='1100';\n if s[i]=',' then k:='1101';\n p:=p+k;\n end;\n writeln(per(p) mod 1000003);\n\nend."}, {"source_code": "{$mode objfpc}\n\nprogram B;\nvar\n S: AnsiString;\n i, n: Integer;\n Code: Int64;\n\nbegin\n ReadLn (S);\n\n Code:= 0;\n\n for i:= 1 to Length (S) do\n begin\n case S [i] of\n '>': n:= 8;\n '<': n:= 9;\n '+': n:= 10;\n '-': n:= 11;\n '.': n:= 12;\n ',': n:= 13;\n '[': n:= 14;\n ']': n:= 14;\n end;\n\n Code:= (Code* 16+ n) mod 1000003;\n\n end;\n\n WriteLn (Code);\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\n modul=round(1e6)+3;\nvar f1,f2:text;\n mu:array[0..401] of longint;\n c:array[chr(1)..chr(255)] of string;\n a,s:ansistring;\nprocedure mo;\nbegin\nassign(f1,fi);\nreset(f1);\nassign(F2,fo);\nrewrite(f2);\nend;\n\nprocedure dong;\nbegin\nclose(F1);\nclose(f2);\nend;\n\nprocedure nhap;\nvar i,j:longint;\n kq:int64;\nbegin\nkq:=0;\n c['>']:= '1000';\n c['<']:= '1001';\n c['+']:= '1010';\n c['-']:= '1011';\n c['.']:= '1100';\n c[',']:= '1101';\n c['[']:= '1110';\n c[']']:= '1111';\nmu[0]:=1;\na:='';\nfor i:=1 to 100 do\n mu[i]:=(mu[i-1]*2) mod modul;\nreadln(F1,S);\nfor i:=1 to length(s) do\n a:=a+c[s[i]];\nfor i:=1 to length(a) do\n if a[i]='1' then\n kq:=(kq+mu[length(a)-i]) mod modul;\nwriteln(F2,kq);\nend;\n\nBEGIN\nmo;\nnhap;\nDong;\nEND."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\nfunction step(i : longint): int64;\nvar\n j: longint;\n q : int64;\nbegin\n q := 1;\n for j:= 1 to i do\n q := q * 2;\n step := q;\nend;\nvar\n str: string;\n j, sum: int64;\n i: longint;\n a: array[1..400] of longint;\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n readln(str);\n j := 1;\n for i := 1 to length(str) do\n begin\n if str[i] = '>' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '<' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '+' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = '-' then\n begin\n a[j] := 1;\n a[j + 1] := 0;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '.' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ',' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 0;\n a[j + 3] := 1;\n inc(j, 4)\n end;\n if str[i] = '[' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 0;\n inc(j, 4)\n end;\n if str[i] = ']' then\n begin\n a[j] := 1;\n a[j + 1] := 1;\n a[j + 2] := 1;\n a[j + 3] := 1;\n inc(j, 4);\n end;\n end;\n sum := 0;\n for i := 1 to j do\n begin\n if a[i] = 1 then\n sum := sum + step(j - i - 1);\n end;\n writeln(sum mod 1000003);\nend.\n"}, {"source_code": "var\n c: char;\n s: ansistring;\n res,i: longint;\nbegin\n while not eoln do\n begin\n read(c);\n if c='>' then s:=s+'1000';\n if c='<' then s:=s+'1001';\n if c='+' then s:=s+'1010';\n if c='-' then s:=s+'1011';\n if c='.' then s:=s+'1100';\n if c=',' then s:=s+'1101';\n if c='[' then s:=s+'1110';\n if c=']' then s:=s+'1111';\n end;\n for i:=1 downto length(s) do\n begin\n res:=(res*2+ord(s[i])-48) mod 1000003;\n\n end;\n writeln(res);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\nconst nn=1001;\n eps=0.000000001; nnn=200;\n label 1,2;\nvar step,i,j:longint;\nn,ot,modul,p1,p2,k,s,besk,l,r,izm,t,p:longint;\na,b:array [0..1000000] of longint;\nsv:array [-1..100,-1..100 ] of boolean;\nuu,uu1:array[0..200] of boolean;\nflag2,flag1,flag:boolean;\nverot:double;\npr:array[-1..1000000] of boolean;\nss,namemin:string;\nstr:array[0..20] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction nod1(a,b:longint):longint; var k,p,t:longint;\nbegin k:=-1;\nif (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b; k:=k+a div b;\n a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod1:=k;\nend;\n\n\n\n\n{function diam(a,b:mas;n:longint):longint;\nvar i0,t,i,j,k:longint; kver:mas; sv:mas2;\n begin\n for i:=1 to n do for j:=1 to n-1 do\n if a[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=b[j]; end;\n for i:=1 to n do for j:=1 to n-1 do\n if b[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=a[j]; end;\n for i:=1 to n do write(kver[i],' ');writeln; writeln;\n for i:=1 to n do begin for j:=1 to kver[i] do write(i,'-',sv[i,j],' ');writeln; end;\n\nfor i0:=1 to 1 do\n begin for i:=1 to n do sm[i]:=false; for i:=1 to n do dist[i]:=1000;\n sm[i0]:=true; dist[i0]:=0; kol:=1;\n\n\n end;\n\n\n\ndiam:=t;\n end; }\n function per(a:char):longint;\n begin\n if a='>' then per:=8;\n if a='<' then per:=9;\n if a='+' then per:=10;\n if a='-' then per:=11;\n if a='.' then per:=12;\n if a=',' then per:=13;\n if a='[' then per:=14;\n if a=']' then per:=15;\n end;\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(ss); n:=length(ss);\n ot:=0; for i:=1 to n do ot:=16*ot+per(ss[i]) mod 1000003;\n writeln(ot);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=ans+ans+1\nelse ans:=ans+ans;\nans:=ans mod 1000003;\nend;\nwriteln(ans);\nend.\n"}, {"source_code": "program calendar;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar a: array [char] of integer;\n s: string;\n p,i,o,j:integer;\nbegin\na['>']:=8;\na['<']:=9;\na['+']:=10;\na['-']:=11;\na['.']:=12;\na[',']:=13;\na['[']:=14;\na[']']:=15;\np:=1; o:=0;\nreadln(s);\nfor i:= length(s) downto 1 do\n begin\n o:=o+(p*a[s[i]]) mod 1000003;\n p:=(p*16) mod 1000003;\n end;\nwrite(o);\n\nread(i);\nend."}, {"source_code": "var\n c: char;\n s: ansistring;\n res,i: longint;\nbegin\n while not eoln do\n begin\n read(c);\n if c='>' then s:=s+'1000';\n if c='<' then s:=s+'1001';\n if c='+' then s:=s+'1010';\n if c='-' then s:=s+'1011';\n if c='.' then s:=s+'1100';\n if c=',' then s:=s+'1101';\n if c='[' then s:=s+'1110';\n if c=']' then s:=s+'1111';\n end;\n for i:=1 downto length(s) do\n begin\n res:=(res*2+ord(s[i])-48) mod 1000003;\n\n end;\n writeln(res);\nend.\n"}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+ (l shl (i-1)) );\n end;\n bintodec:=o mod 1000003;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:='0001'+k;\n '<':k:='1001'+k;\n '+':k:='0101'+k;\n '-':k:='1101'+k;\n '.':k:='0011'+k;\n ',':K:='1011'+k;\n '[':k:='0111'+k;\n ']':k:='1111'+k;\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=(ans+a[j]*x) mod 1000003;\n x:=x*2 mod 1000003;\n if x=0 then x:=1000003; \n end;\n if ans=0 then ans:=1000003;\n writeln (ans);\nend.\n"}, {"source_code": "{$Q-}\nvar s,k:ansistring;\n i:longint;\nfunction bintodec(k:ansistring):qword;\nvar o,l:qword;\n p,i:integer;\nbegin\n o:=0;\n for i:=1 to length(k) do\n begin\n val(k[i],l,p);\n o:=(o+l shl (length(k)-i)) mod 1000003;\n end;\n bintodec:=o mod 1000006;\nend;\nbegin\n readln(s);\n k:='';\n for i:=1 to length(s) do\n case s[i] of\n '>':k:=k+'1000';\n '<':k:=k+'1001';\n '+':k:=k+'1010';\n '-':k:=k+'1011';\n '.':k:=k+'1100';\n ',':K:=k+'1101';\n '[':k:=k+'1110';\n ']':k:=k+'1111';\n end;\n writeln(bintodec(k));\nend."}, {"source_code": "var s,s1:ansistring;\n i,p:longint;\nfunction BIN_DEC(x:string):longint;\nconst digits:array [0..1] of char = ('0','1');\nvar res,ves:longint; i,j:byte;\nbegin\n res:=0; ves:=1;\n for i:=length(x) downto 1 do begin\n j:=0;\n while (digits[j]<>x[i]) do inc(j);\n res:=res+ves*j;\n ves:=ves*2;\n end;\n BIN_DEC:=res;\nend;\n begin\n readln(s);\n for i:=1 to length(s) do\n if s[i]='>' then s1:=s1+'1000'\n else if s[i]='<' then s1:=s1+'1001'\n else if s[i]='+' then s1:=s1+'1010'\n else if s[i]='-' then s1:=s1+'1011'\n else if s[i]='.' then s1:=s1+'1100'\n else if s[i]=',' then s1:=s1+'1101'\n else if s[i]='[' then s1:=s1+'1110'\n else if s[i]=']' then s1:=s1+'1111';\n writeln(BIN_DEC(s1));\n end."}, {"source_code": "var s,s1:string;\n i:longint;\n t,ans,n:int64;\n a:array[1..500]of integer;\n\nBEGIN\n readln(s);\n s1:='';\n for i:=1 to length(s) do\n case s[i] of\n '>': s1:=s1+'1000';\n '<': s1:=s1+'1001';\n '+': s1:=s1+'1010';\n '-': s1:=s1+'1011';\n '.': s1:=s1+'1100';\n ',': s1:=s1+'1101';\n '[': s1:=s1+'1110';\n ']': s1:=s1+'1111';\n end;\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s1) do\n a[i]:=ord(s1[i])-ord('0');\n n:=i;\n t:=1;\n ans:=0;\n for i:=n downto 1 do\n begin\n ans:=(ans+a[i]*t)mod 1000003;\n t:=(t*2)mod 1000003;\n end;\n writeln(ans);\nEND.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i: integer;\n n: int64;\n s, t: string;\n a: array[-1..10000] of int64;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(s);\n\n a[0] := 1;\n for i := 1 to 101 do\n a[i] := (a[i - 1] * 2) mod 1000003;\n\n t := '';\n for i := 1 to length(s) do begin\n case s[i] of\n '>': t := t + '1000';\n '<': t := t + '1001';\n '+': t := t + '1010';\n '-': t := t + '1011';\n '.': t := t + '1100';\n ',': t := t + '1101';\n '[': t := t + '1110';\n ']': t := t + '1111';\n end;\n end;\n\n n := 0;\n for i := 1 to length(t) do begin\n if (t[i] = '1') then\n n := (n + a[length(t) - i]) mod 1000003;\n end;\n\n writeln(n);\nend.\n"}, {"source_code": "program bb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array [1..100] of byte;\n i,j:byte;\n ans,x:integer;\n ch:char;\n\nbegin\n i:=0;\n ans:=0;\n while not seekeoln do begin\n read (ch);\n case ch of\n '>': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n '<': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '+': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n '-': begin\n a[i+1]:=1;\n a[i+2]:=0;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n '.': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=0;\n end;\n ',': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=0;\n a[i+4]:=1;\n end;\n '[': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=0;\n end;\n ']': begin\n a[i+1]:=1;\n a[i+2]:=1;\n a[i+3]:=1;\n a[i+4]:=1;\n end;\n end;\n inc(i,4);\n end;\n x:=1;\n for j:=i downto 1 do begin\n ans:=ans+a[j]*x;\n ans:=ans mod 1000003;\n if ans=0 then ans:=1000003;\n x:=x*2;\n x:=x mod 1000003;\n if x=0 then x:=1000003; \n end;\n writeln (ans);\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar\n a : array[#0..#255] of string;\n i,ans : integer;\n k : int64;\n str,s : string;\nbegin\n a['>'] := '1000';\n a['<'] := '1001';\n a['+'] := '1010';\n a['-'] := '1011';\n a['.'] := '1100';\n a[','] := '1101';\n a['['] := '1110';\n a[']'] := '1111';\n readln(str);\n for i := 1 to length(str) do s := s + a[str[i]];\n k := 1;\n ans := 0;\n for i := length(s) downto 1 do begin\n if s[i] = '1' then ans := (ans + k) mod 1000003;\n k := k * 2;\n end;\n write(ans);\nend."}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans:int64;\ni:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=2 to length(s) do begin\nif s[i]='1' then ans:=2*ans+1\nelse ans:=2*ans;\nans:=ans mod 1000003;\nend;\nwriteln(ans mod 1000003);\nend.\n"}, {"source_code": "var b:boolean;\nc:char;\ns:string;\nans,i:longint;\nbegin\nb:=false;\ns:='';\nwhile not eoln do begin\nread(c);\nif (c='>') then s:=s+'1000';\nif (c='<') then s:=s+'1001';\nif (c='+') then s:=s+'1010';\nif (c='-') then s:=s+'1011';\nif (c='.') then s:=s+'1100';\nif (c=',') then s:=s+'1101';\nif (c='[') then s:=s+'1110';\nif (c=']') then s:=s+'1111';\nend;\nans:=1;\nfor i:=length(s) downto 2 do\nif s[i]='1' then ans:=(ans*2+1)mod 1000003\nelse ans:=(ans*2)mod 1000003;\nwrite(ans);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n i:Integer;\n s,s1:string;\nfunction lol(s:string):Int64;\nvar\n k,i,j,n,code:Integer;\n g,a:Int64;\nbegin\n k:=0;\n g:=0;\n a:=0;\n n:=Length(s)-1;\n for i:=1 to Length(s) do\n begin\n if (s[i]='0') then g:=g*2\n else g:=g*2+1;\n end;\n lol:=g;\nend;\nbegin\n Readln(s);\n s1:='';\n for i:=1 to Length(s) do\n begin\n if (s[i]='>') then s1:=s1+'1000';\n if (s[i]='<') then s1:=s1+'1001';\n if (s[i]='+') then s1:=s1+'1010';\n if (s[i]='-') then s1:=s1+'1011';\n if (s[i]='.') then s1:=s1+'1100';\n if (s[i]=',') then s1:=s1+'1101';\n if (s[i]='[') then s1:=s1+'1110';\n if (s[i]=']') then s1:=s1+'1111';\n end;\n Writeln(lol(s1)mod 1000003);\n Readln;\n Readln;\nend.\n "}], "src_uid": "04fc8dfb856056f35d296402ad1b2da1"} {"source_code": "uses math;\nvar b,g,r,bs,gs,rs,i,j,n,k,m,s:longint;\n h:char;\n bb,gb,rb:boolean;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(h);\n if h = 'R' then inc(rs) else\n if h = 'B' then inc(bs) else\n inc(gs);\n end;\n\n if gs > 1 then gs:=2;\n if bs > 1 then bs:=2;\n if rs > 1 then rs:=2;\n\n b:=bs; g:=gs; r:=rs;\n\n if ((r>0) and (g>0)) or ((r=2) and (b>0)) or ((g=2) and (b>0)) or (r+g=0) then write('B');\n if ((r>0) and (b>0)) or ((r=2) and (g>0)) or ((b=2) and (g>0)) or (r+b=0) then write('G');\n if ((b>0) and (g>0)) or ((b=2) and (r>0)) or ((g=2) and (r>0)) or (b+g=0) then write('R');\n end.", "positive_code": [{"source_code": "var r,g,b:longint;\n n,i:integer;\n ch:char;\n r1,b1,g1:boolean;\n\nlabel outp;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n case ch of\n 'R': inc(r);\n 'B': inc(b);\n 'G': inc(g);\n end;\n end;\n if ((r<>0)xor(g<>0)xor(b<>0))and(not((r<>0)and(b<>0)and(g<>0)))\n then\n begin\n if r<>0 then write('R');\n if b<>0 then write('B');\n if g<>0 then write('G');\n end\n else\n begin\n if ((r=1)xor(b=1)xor(g=1))and((r=0)xor(g=0)xor(b=0))\n then\n begin\n if b = 1 then b1:=true;\n if g = 1 then g1:=true;\n if r = 1 then r1:=true;\n if b = 0 then b1:=true;\n if g = 0 then g1:=true;\n if r = 0 then r1:=true;\n goto outp;\n end;\n\n if r+g+b = 2\n then\n begin\n if r=0 then write('R');\n if b=0 then write('B');\n if g=0 then write('G');\n exit;\n end;\n b1:=true;\n g1:=true;\n r1:=true;\n outp:\n if b1 then write('B');\n if g1 then write('G');\n if r1 then write('R');\n end;\n\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nvar n,dem1,dem2,dem3,i:integer;\n s:ansistring;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(dem1);\n if s[i]='G' then inc(dem2);\n if s[i]='R' then inc(dem3)\n end;\n if ((dem2>0) and (dem3>0)) or ((dem2=0) and (dem3=0))\n or ((dem2>1) and (dem1>0)) or ((dem3>1) and (dem1>0)) then write('B');\n if ((dem1>0) and (dem3>0)) or ((dem1=0) and (dem3=0))\n or ((dem1>1) and (dem2>0)) or ((dem3>1) and (dem2>0)) then write('G');\n if ((dem2>0) and (dem1>0)) or ((dem2=0) and (dem1=0))\n or ((dem2>1) and (dem3>0)) or ((dem1>1) and (dem3>0)) then write('R');\n writeln\n\nend."}, {"source_code": "var\nn,i,k,j:longint;\na,b:array[1..100] of longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\n//s:='RRRRR';\nfor i:=1 to n do begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n if a[1]*a[2]*a[3]>0 then begin write('BGR'); halt; end;\n for i:=1 to 3 do if a[i]=0 then begin inc(k); b[i]:=1; end;\n if k=1 then begin\n if b[1]=1 then begin\n if (a[2]>1) and (a[3]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[3]=1) then begin write('BR'); halt; end;\n if (a[2]=1) and (a[3]>1) then begin write('BG'); halt; end;\n if (a[2]=1) and (a[3]=1) then begin write('B'); halt; end;\n end;\n if b[2]=1 then begin\n if (a[3]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[3]>1) and (a[1]=1) then begin write('BG'); halt; end;\n if (a[3]=1) and (a[1]>1) then begin write('GR'); halt; end;\n if (a[3]=1) and (a[1]=1) then begin write('G'); halt; end;\n end;\n if b[3]=1 then begin\n if (a[2]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[1]=1) then begin write('BR'); halt; end;\n if (a[2]=1) and (a[1]>1) then begin write('GR'); halt; end;\n if (a[2]=1) and (a[1]=1) then begin write('R'); halt; end;\n end;\n end;\n if k=2 then begin\n for i:=1 to 3 do if b[i]=0 then begin\n if i=1 then begin write('B'); halt; end;\n if i=2 then begin write('G'); halt; end;\n if i=3 then begin write('R'); halt; end;\n end;\n end;\n end.\n\n\n"}, {"source_code": "var sim:char;\n n,r,b,g,i:longint;\nbegin\nreadln(n);\nfor i:=1 to n do begin\n read(sim);\n if sim='R' then inc(R);\n if sim='B' then inc(B);\n if sim='G' then inc(G);\nend;\n\nif (r>0) and (b>0) and (g>0) then begin write('BGR'); halt; end;\nif (r>1) and (b>1) and (g=0) then begin write('BGR'); halt; end;\nif (r>1) and (b=0) and (g>1) then begin write('BGR'); halt; end;\nif (r=0) and (b>1) and (g>1) then begin write('BGR'); halt; end;\n\nif (r=0) and (b=0) and (g>0) then begin write('G'); halt; end;\nif (r>0) and (b=0) and (g=0) then begin write('R'); halt; end;\nif (r=0) and (b>0) and (g=0) then begin write('B'); halt; end;\nif (r=0) and (b=1) and (g=1) then begin write('R'); halt; end;\nif (r=1) and (b=1) and (g=0) then begin write('G'); halt; end;\nif (r=1) and (b=0) and (g=1) then begin write('B'); halt; end;\n\nif (r>1) and (b=1) and (g=0) then begin write('BG'); halt; end;\nif (r>1) and (b=0) and (g=1) then begin write('BG'); halt; end;\nif (r=0) and (b=1) and (g>1) then begin write('BR'); halt; end;\nif (r=1) and (b=0) and (g>1) then begin write('BR'); halt; end;\nif (r=0) and (b>1) and (g=1) then begin write('GR'); halt; end;\nif (r=1) and (b>1) and (g=0) then begin write('GR'); halt; end;\nend.\n"}, {"source_code": "var ss:char;\ng,b,r,i,n:longint;\nbegin {\nassign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nreadln(n); b:=0;g:=0;r:=0;\nfor i:=1 to n do\n begin\n read(ss);\n if ss='G' then inc(g);\n if ss='B' then inc(b);\n if ss='R' then inc(r);\n end;\n\nif ((b<>0) and (g<>0) and (r<>0)) or ((r>=2) and (g>=2)) or ((b>=2) and (g>=2)) or ((b>=2) and (r>=2))then begin writeln('BGR');halt;end;\n\nif (r>=2) and ((b<>0) or (g<>0)) then begin write('BG');halt;end;\n\nif (g>=2) and ((b<>0) or (r<>0)) then begin write('BR');halt;end;\n\nif (b>=2) and ((r<>0) or (g<>0)) then begin write('GR');halt;end;\n\nif (b<>0) and (g<>0) and (r=0) then begin write ('R');halt;end;\n\nif (b<>0) and (r<>0) and (g=0) then begin write('G');halt;end;\n\nif (g<>0) and (r<>0) and (b=0) then begin write('B');halt;end;\n\nif (b<>0) then begin write('B');halt;end;\n\nif (g<>0) then begin write('G');halt;end;\n\nif (r<>0) then begin write('R');halt;end;\n\n{close(input);\nclose(output); }\nend.\n\n\n"}, {"source_code": "type\n mas = array [1..3] of longint;\nvar\n i, n : longint;\n s : string;\n a, b : mas;\nbegin\n readln(n);\n readln(s);\n for i := 1 to length(s) do\n begin\n if s[i] = 'B'\n then\n inc(a[1]);\n if s[i] = 'R'\n then\n inc(a[2]);\n if s[i] = 'G'\n then\n inc(a[3]);\n end;\n s := '';\n b := a;\n {inc(b[1], min(b[2], b[3]));\n dec(b[2], min(b[2], b[3]));\n dec(b[3], min(b[3], b[3]));\n if (b[2] = 0) and (b[3] = 0)\n then\n ot := ot + 'B'\n if (b[1] = 0) and (b[2] = 0)\n then\n ot := ot + 'B'\n if (b[1] = 0) and (b[2] = 0)\n then\n ot := ot + 'B'}\n if (a[1] > 0) and (a[2] > 0) and (a[3] > 0)\n then\n begin\n s := 'BGR';\n writeln(s);\n exit;\n end;\n if (a[1] > 0) and (a[2] + a[3] = 0)\n then\n s := 'B';\n if (a[2] > 0) and (a[1] + a[3] = 0)\n then\n s := 'R';\n if (a[3] > 0) and (a[1] + a[2] = 0)\n then\n s := 'G';\n if s <> ''\n then\n begin\n writeln(s);\n exit;\n end;\n if a[1] = 0\n then\n begin\n if (a[2] = 1) and (a[3] = 1)\n then\n s := 'B'\n else\n if (a[2] > 1) and (a[3] = 1)\n then\n s := 'BG'\n else\n if (a[2] = 1) and (a[3] > 1)\n then\n s := 'BR'\n else\n s := 'BGR';\n end;\n if a[2] = 0\n then\n begin\n if (a[1] = 1) and (a[3] = 1)\n then\n s := 'R'\n else\n if (a[1] > 1) and (a[3] = 1)\n then\n s := 'GR'\n else\n if (a[1] = 1) and (a[3] > 1)\n then\n s := 'BR'\n else\n s := 'BGR';\n end;\n if a[3] = 0\n then\n begin\n if (a[1] = 1) and (a[2] = 1)\n then\n s := 'G'\n else\n if (a[1] > 1) and (a[2] = 1)\n then\n s := 'GR'\n else\n if (a[1] = 1) and (a[2] > 1)\n then\n s := 'BG'\n else\n s := 'BGR';\n end;\n writeln(s);\nend."}, {"source_code": "var i, j, n, m:longint;\na:array[1..3]of longint;\ns:string;\nbegin\nreadln(n);\nread(s);\nFor i:=1 to n do case s[i] of\n 'G':inc(a[2]);\n 'R':inc(a[3]);\n 'B':inc(a[1]);\n end;\nif (a[1]>0)and(a[2]>0)and(a[3]>0) then write('BGR')\n else if (a[1]=0)and(a[2]=0)then write('R')\n else if (a[2]=0)and(a[3]=0)then write('B')\n else if (a[1]=0)and(a[3]=0)then write('G')\n else if a[1]=0 then begin if (a[2]>1)and(a[3]>1) then write('BGR')\n else\n if (a[3]=1)and(a[2]=1) then write('B')\n else if a[2]=1 then write('BG')\n else if a[3]=1 then write('BR');\n end\n else\n if a[2]=0 then begin if (a[1]>1)and(a[3]>1) then write('BGR')\n else if (a[1]=1)and(a[3]=1) then write('G')\n else if a[1]=1 then write('BG')\n else if a[3]=1 then write('GR');\n end\n else\n if a[3]=0 then begin if (a[2]>1)and(a[1]>1) then write('BGR')\n else if (a[1]=1)and(a[2]=1) then write('R')\n else if a[2]=1 then write('GR')\n else if a[1]=1 then write('BR');\n end;\nEnd.\n\n"}, {"source_code": "var\ni,j,k,n,m,q,w,x,y:longint;\na:array[1..100] of longint;\ns:string;\nbegin\n readln(n);\n read(s);\n for i:=1 to n do\n begin\n if s[i]='R' then inc(a[1]);\n if s[i]='B' then inc(a[2]);\n if s[i]='G' then inc(a[3]);\n end;\n if (a[1]>=1) and (a[2]>=1) and (a[3]>=1) and (n>3) then write('BGR')\n else\n if a[1]=n then write('R')\n else\n if a[2]=n then write('B')\n else\n if a[3]=n then write('G')\n else\n if (a[1]=1) and (a[2]=1) and (a[3]=0) then write('G')\n else\n if (a[1]=1) and (a[3]=1) and (a[2]=0) then write('B')\n else\n if (a[2]=1) and (a[3]=1) and (a[1]=0) then write('R')\n else\n if (a[1]=1) and (a[2]=1) and (a[3]=1) then write('BGR')\n else\n if (a[1]=1) and (a[2]=2) then write('GR')\n else\n if (a[1]=1) and (a[3]=2) then write('BR')\n else\n if (a[2]=1) and (a[1]=2) then write('BG')\n else\n if (a[2]=1) and (a[3]=2) then write('BR')\n else\n if (a[3]=1) and (a[1]=2) then write('BG')\n else\n if (a[3]=1) and (a[2]=2) then write('GR')\n else\n if (a[1]>=3) and (a[2]=1) then write('BG')\n else\n if (a[1]>=3) and (a[3]=1) then write('BG')\n else\n if (a[2]>=3) and (a[1]=1) then write('GR')\n else\n if (a[2]>=3) and (a[3]=1) then write('GR')\n else\n if (a[3]>=3) and (a[1]=1) then write('BR')\n else\n if (a[3]>=3) and (a[2]=1) then write('BR')\n else\n if (a[1]=0) and (a[2]>1) and (a[3]>1) then write('BGR')\n else\n if (a[2]=0) and (a[1]>1) and (a[3]>1) then write('BGR')\n else\n if (a[3]=0) and (a[1]>1) and (a[2]>1) then write('BGR');\nend."}, {"source_code": "var\n f,a:array[1..3]of longint;\n n,i,tot,tt:longint; cc:char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(cc);\n case cc of\n 'B':inc(a[1]);\n 'G':inc(a[2]);\n 'R':inc(a[3]);\n end;\n end;\n for i:=1 to 3 do\n if a[i]>2 then a[i]:=2;\n if (a[1]<>0)and(a[2]<>0)and(a[3]<>0) then\n begin f[1]:=1; f[2]:=1; f[3]:=1; end;\n tot:=0; tt:=0;\n for i:=1 to 3 do\n begin inc(tot,a[i]); if a[i]>0 then inc(tt); end;\n if (tot=4)and(tt=2) then\n begin f[1]:=1; f[2]:=1; f[3]:=1; end;\n if tt=1 then\n for i:=1 to 3 do\n if a[i]>0 then f[i]:=1;\n if tt=2 then\n begin\n if tot=2 then\n for i:=1 to 3 do\n if a[i]=0 then f[i]:=1;\n if tot=3 then\n for i:=1 to 3 do\n if a[i]<>2 then f[i]:=1;\n end;\n if f[1]=1 then write('B');\n if f[2]=1 then write('G');\n if f[3]=1 then write('R'); writeln;\nend."}, {"source_code": "var\ns:string;\nn,b,r,g:longint;\nbb,rr,gg:boolean;\nprocedure find( b,g,r:longint);\nvar\ns:longint;\nbegin\ns:=b+r+g;\nif s=1 then\n begin\n if b=1 then bb:=true else\n if g=1 then gg:=true else\n rr:=true;\n end;\nif s=2 then\n begin\n if b=2 then bb:=true else\n if r=2 then rr:=true else\n if g=2 then gg:=true else\n if b=0 then bb:=true else\n if g=0 then gg:=true else\n rr:=true;\n end\nelse\n begin\n if b>1 then find(b-1,g,r);\n if g>1 then find(b,g-1,r);\n if r>1 then find(b,g,r-1);\n if (b>0) and (g>0) then find(b-1,g-1,r+1);\n if (b>0) and (r>0) then find(b-1,g+1,r-1);\n if (r>0) and (g>0) then find(b+1,g-1,r-1);\n end;\nend;\n\nvar\ni:longint;\nbegin\nbb:=false;\ngg:=false;\nrr:=false;\nreadln(n);\nreadln(s);\nb:=0;\nr:=0;\ng:=0;\nfor i:=1 to n do\nbegin\nif s[i]='B' then inc(b) else\nif s[i]='G' then inc(g) else\ninc(r);\nend;\n if (b=0) and (g=0) then begin writeln('R'); halt(0); end;\n if (r=0) and (g=0) then begin writeln('B'); halt(0); end;\n if (b=0) and (r=0) then begin writeln('G'); halt(0); end;\n if n>20 then\n begin\n if (b*g=0) and (b+g=1) then writeln('BG') else\n if (b*r=0) and (b+r=1) then writeln('BR') else\n if (r*g=0) and (r+g=1) then writeln('GR') else\n writeln('BGR'); \n\n\n halt(0);\n end;\nfind(b,g,r);\nif bb then write('B');\nif gg then write('G');\nif rr then write('R');\nend.\n\n"}, {"source_code": "var bb,gg,rr,b,g,r:longint;\nn,i:longint;\ns:ansistring;\nbegin\nbb:=0;\nrr:=0;\ngg:=0;\nreadln(n);\nreadln(s);\nif n=1 then begin write(s); halt; end;\nfor i:=1 to n do\ncase s[i] of\n'B':inc(bb);\n'R':inc(rr);\n'G':inc(gg);\nend;\n\nif bb>0 then b:=1 else b:=0;\ng:=gg;\nr:=rr;\nif((g>0)and(r>0))or(((g=0)or(r=0))and(b>0)and(g+r>b))or((g=0)and(r=0))then write('B');\n\nif gg>0 then g:=1 else g:=0;\nb:=bb;\nr:=rr;\nif((b>0)and(r>0))or(((r=0)or(b=0))and(g>0)and(r+b>g))or((b=0)and(r=0))then write('G');\n\nif rr>0 then r:=1 else r:=0;\nb:=bb;\ng:=gg;\nif((g>0)and(b>0))or(((g=0)or(b=0))and(r>0)and(g+b>r))or((g=0)and(b=0))then write('R');\n\nend.\n"}, {"source_code": " var N : LongInt;\n i : LongInt;\n c : Char;\n Red , Green , Blue : LongInt;\nbegin\n readLn ( N ) ;\n \n for i := 1 to N do\n begin\n read ( c ) ; \n \n if ( c = 'R' ) then\n inc ( red ) ;\n if ( c = 'G' ) then\n inc ( green ) ; \n if ( c = 'B' ) then\n inc ( blue ) ; \n \n end;\n \n \n if ( Blue > 0 ) and ( Red > 0 ) and ( Green > 0 ) then\n begin\n writeLn ( 'BGR' ) ; \n halt();\n end;\n \n if ( Blue + Red = 0 ) then\n begin\n writeLn ( 'G' ) ; \n halt();\n end;\n \n if ( Red + Green = 0 ) then\n begin\n writeLn ( 'B' ) ;\n halt();\n end;\n \n if ( Green + Blue = 0 ) then\n begin\n writeLn ( 'R' ) ; \n halt();\n end;\n \n \n if ( Blue = 0 ) then\n begin\n \n if ( red + green = 2 ) then\n writeLn ( 'B' ) ;\n \n if ( red > 1 ) and ( green > 1 ) then\n writeLn ( 'BGR' );\n \n if ( red > 1 ) and ( green = 1 ) then\n writeLn ( 'BG' ) ; \n if ( red = 1 ) and ( green > 1) then\n writeLn ( 'BR' ) ; \n \n end;\n \n if ( Red = 0 ) then\n begin\n if ( Blue + Green = 2 ) then\n writeLn ( 'R' ) ; \n if ( Blue > 1 ) and ( Green > 1 ) then\n writeLn ( 'BGR' ) ; \n if ( Blue = 1 ) and ( Green > 1 ) then\n writeLn ( 'BR' ) ; \n if ( Blue > 1 ) and ( Green = 1 ) then\n writeLn ( 'GR' ) ; \n end;\n \n if ( Green = 0 ) then\n begin\n if ( Blue + Red = 2 ) then\n writeLn ( 'G' ) ; \n if ( Blue > 1 ) and ( Red > 1 ) then\n writeLn ( 'BGR' ) ;\n if ( Blue = 1 ) and ( Red > 1 ) then\n writeLn ( 'BG' ) ;\n if ( Blue > 1 ) and ( Red = 1 ) then\n writeLn ( 'GR' ) ;\n end;\n \n \nend."}, {"source_code": "\nvar\na,b,c,n,i,q:longint;\ns:string;\nbegin\nreadln(N);\nreadln(s);\nfor i:=1 to n do begin\nif s[i]='B'\nthen inc(A);\nif s[i]='G'\nthen inc(b);\nif s[i]='R'\nthen inc(c);\nend;\nif a>1\nthen inc(Q);\nif b>1\nthen inc(Q);\nif c>1\nthen inc(Q);\nif (Q>1) or ((a>0) and (b>0) and (c>0))\nthen begin writeln('BGR'); halt; end;\nif q=0\nthen begin\nif a+b+c=2\nthen begin\nif a=0\nthen writeln('B');\nif b=0\nthen writeln('G');\nif c=0\nthen writeln('R');\nend;\nif a+b+c=1\nthen begin\nif a=1\nthen writeln('B');\nif b=1\nthen writeln('G');\nif c=1\nthen writeln('R');\nend;\nend;\nif ((a+b+c=a) or (a+b+c=b) or (a+b+c=c)) and (Q=1)\nthen begin\nif a+b+c=a\nthen writeln('B');\nif a+b+c=b\nthen writeln('G');\nif a+b+c=c\nthen writeln('R');\nhalt;\nend;\nif q=1\nthen begin\nif a>1\nthen writeln('GR');\nif b>1\nthen writeln('BR');\nif c>1\nthen writeln('BG');\nend;\nend.\n\n\n"}, {"source_code": "var\n so: string;\n pr: boolean;\n\nfunction prov(st: string): boolean;\nvar\n i, k: integer;\n s1: string[1];\nbegin\n k := 1;\n prov := true;\n s1 := copy(st, 1, 1);\n for i := 2 to length(st) do\n if s1 = copy(st, i, 1) then\n k := k + 1;\n if k = length(st) then\n prov := false\nend;\n\nfunction men1(st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n s: string[3];\n st1: string[205];\nbegin\n st1 := st;\n s := 'BGR';\n s1 := copy(st1, a, 1);\n s2 := copy(st1, b, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n delete(s, pos(s1, s), 1);\n delete(s, pos(s2, s), 1);\n st1 := s + st1;\n men1 := st1\nend;\n\nfunction men2(st: string; a, b: integer): string;\nvar\n s: string[1];\n st1: string[205];\nbegin\n st1 := st;\n s := copy(st1, a, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n st1 := s + st1;\n men2 := st1\nend;\n\nfunction meno(var st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n t: integer;\nbegin\n s1 := copy(st, a, 1);\n s2 := copy(st, b, 1);\n if a > b then\n begin\n t := a;\n a := b;\n b := t\n end;\n if s1 = s2 then\n meno := men2(st, a, b)\n else \n meno := men1(st, a, b)\nend;\n\nprocedure men(st: string);\nvar\n i, j, a1, b1, c1, a2, b2, c2: integer;\n si, sa, sb, sc: string[205];\n pr1: boolean;\nbegin\npr1:=true;\nif length(st)>50 then\n pr1 := prov(st);\n if (length(st) >= 2) and pr and pr1 then\n begin\n a1 := pos('B', st);\n sa := copy(st, a1 + 1, length(st));\n a2 := pos('B', sa) + a1;\n b1 := pos('G', st);\n sb := copy(st, b1 + 1, length(st));\n b2 := pos('G', sb) + b1;\n c1 := pos('R', st);\n sc := copy(st, c1 + 1, length(st));\n c2 := pos('R', sc) + c1;\n \n if ((a1 = 0) and (b1 <> 0) and (c1 <> 0)) then\n men(meno(st, b1, c1))\n else\n if ((b1 = 0) and (a1 <> 0) and (c1 <> 0)) then\n men(meno(st, a1, c1))\n else\n if ((c1 = 0) and (b1 <> 0) and (a1 <> 0)) then\n men(meno(st, a1, b1))\n else\n if ((a1 <> 0) and (b1 <> 0) and (c1 <> 0)) then\n begin\n men(meno(st, a1, b1));\n men(meno(st, c1, b1));\n men(meno(st, a1, c1))\n end;\n \n if (a1 <> 0) and (a2 <> a1) then\n men(meno(st, a1, a2));\n if (b1 > 0) and (b2 > b1) then\n men(meno(st, b1, b2));\n if (c1 <> 0) and (c2 <> c1) then\n men(meno(st, c1, c2));\n end\n else\n if pos(st, so) = 0 then\n so := so + st\n else\n if (not pr1) then\n men(copy(st, 1, 1));\n if length(so) = 3 then\n pr := false;\n \n \nend;\n\nvar\n n: integer;\n st: string[205];\n so1: string[3];\n a, b, c, i: integer;\n\nbegin\n Readln(n);\n Readln(st);\n \n a := 0;\n b := 0;\n c := 0;\n pr := true;\n if n>40 then\n begin\n for i := 1 to length(st) do\n begin\n if copy(st, i, 1) = 'B' then\n a := a + 1;\n if copy(st, i, 1) = 'G' then\n b := b + 1;\n if copy(st, i, 1) = 'R' then\n c := c + 1;\n end;\n st := '';\n if a <> 0 then\n if a = 1 then\n st := st + 'B'\n else\n st := st + 'BB';\n if b <> 0 then\n if b = 1 then\n st := st + 'G'\n else\n st := st + 'GG';\n if c <> 0 then\n if c = 1 then\n st := st + 'R'\n else\n st := st + 'RR'\n end;\n men(st);\n so1 := '';\n \n if pos('B', so) <> 0 then\n so1 := 'B';\n if pos('G', so) <> 0 then\n so1 := so1 + 'G';\n if pos('R', so) <> 0 then\n so1 := so1 + 'R';\n \n Writeln(so1)\nend."}, {"source_code": "var s:string;\n i,j,n,m,r,g,b:longint;\nbegin\nreadln(n);\nreadln(s);\nr:=0; g:=0; b:=0;\n\nfor i:=1 to n do\nbegin\nif s[i]='R' then inc(r);\nif s[i]='G' then inc(g);\nif s[i]='B' then inc(b);\nend;\n\nif (r>0) and(g=0) and(b=0) then begin writeln('R'); halt; end;\nif (r=0) and(g>0) and(b=0) then begin writeln('G'); halt; end;\nif (r=0) and(g=0) and(b>0) then begin writeln('B'); halt; end;\n\nif (r=1) and(g=1) and(b=0) then begin writeln('B'); halt; end;\nif (r=1) and(g=0) and(b=1) then begin writeln('G'); halt; end;\nif (r=0) and(g=1) and(b=1) then begin writeln('R'); halt; end;\n\nif (r>1) and(g=1) and(b=0) then begin writeln('BG'); halt; end;\nif (r>1) and(g=0) and(b=1) then begin writeln('BG'); halt; end;\n\nif (r=1) and(g>1) and(b=0) then begin writeln('BR'); halt; end;\nif (r=1) and(g=0) and(b>1) then begin writelN('GR'); halt; end;\n\nif (r=0) and(g>1) and(b=1) then begin writeln('BR'); halt; end;\nif (r=0) and(g=1) and(b>1) then begin writeln('GR'); halt; end;\n\nwriteln('BGR');\nend."}, {"source_code": "var n,r,b,g,i:longint;\nst,ot:string;\nbegin\n readln(n);\n readln(st);\n for i:=1 to n do\n if st[i]='B' then b:=b+1\n else if st[i]='G' then g:=g+1\n else r:=r+1;\n if (r>0) and (g>0) and (b>0) then ot:='BGR'\n else if (r>0) and (g=0) and (b=0) then ot:='R'\n else if (r=0) and (g>0) and (b=0) then ot:='G'\n else if (r=0) and (g=0) and (b>0) then ot:='B'\n else if (r=1) and (b>1) and (g=0) then ot:='GR'\n else if (r>1) and (b=1) and (g=0) then ot:='BG'\n else if (r=1) and (b=1) and (g=0) then ot:='G'\n else if (r>1) and (b>1) and (g=0) then ot:='BGR'\n else if (r=0) and (b>1) and (g=1) then ot:='GR'\n else if (r=0) and (b=1) and (g>1) then ot:='BR'\n else if (r=0) and (b>1) and (g>1) then ot:='BGR'\n else if (r=0) and (b=1) and (g=1) then ot:='R'\n else if (r>1) and (b=0) and (g=1) then ot:='BG'\n else if (r>1) and (b=0) and (g>1) then ot:='BGR'\n else if (r=1) and (b=0) and (g>1) then ot:='BR'\n else if (r=1) and (b=0) and (g=1) then ot:='B';\n writeln(ot);\nend."}, {"source_code": "var\nn,r,g,i,b:longint;\nst:string;\nbegin\n\n readln(n);\n readln(st);\n for i:=1 to n do\n begin\n if st[i]='R' then r:=r+1;\n if st[i]='G' then g:=g+1;\n if st[i]='B' then b:=b+1;\n end;\n if (b=1) and (g=1) and (r=0) then writeln('R')\n else\n if (b=1) and (g=0) and (r=1) then writeln('G')\n else\n if (b=0) and (g=1) and (r=1) then writeln('B')\n else\n if (b>1) and (g=1) and (r=0) then writeln('GR')\n else\n if (b>1) and(g=0) and (r=1) then writeln('GR')\n else\n if (b=1) and (g>1) and (r=0) then writeln('BR')\n else\n if (b=0) and (g>1) and (r=1) then writeln('BR')\n else\n if (b=1) and (g=0) and (r>1) then writeln('BG')\n else\n if (b=0) and (g=1) and (r>1) then writeln('BG')\n else\n if (b>0) and(g=0) and(r=0) then writeln('B')\n else\n if (b=0) and(g>0) and(r=0) then writeln('G')\n else\n if (b=0) and(g=0) and(r>0) then writeln('R')\n else writeln('BGR');\n\nend."}, {"source_code": "var b,g,r,bs,gs,rs,i,j,n,k,m,s:longint;\n x:char;\n bb,gb,rb:integer;\n\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\n read(x);\n if x= 'R' then inc(rs) else\n if x= 'B' then inc(bs)\n else inc(gs);\n end;\n\nif gs>1 then gs:=2;\nif bs>1 then bs:=2;\nif rs>1 then rs:=2;\nb:=bs; g:=gs; r:=rs;\nif ((r>0) and (g>0)) or ((r=2) and (b>0)) or ((g=2) and (b>0)) or (r+g=0) then write('B');\nif ((r>0) and (b>0)) or ((r=2) and (g>0)) or ((b=2) and (g>0)) or (r+b=0) then write('G');\nif ((b>0) and (g>0)) or ((b=2) and (r>0)) or ((g=2) and (r>0)) or (b+g=0) then write('R');\nend."}, {"source_code": "var\nn,r,g,i,b:longint;\nst:string;\nbegin\n\n readln(n);\n readln(st);\n for i:=1 to n do\n begin\n if st[i]='R' then r:=r+1;\n if st[i]='G' then g:=g+1;\n if st[i]='B' then b:=b+1;\n end;\n if (b=1) and (g=1) and (r=0) then writeln('R')\n else\n if (b=1) and (g=0) and (r=1) then writeln('G')\n else\n if (b=0) and (g=1) and (r=1) then writeln('B')\n else\n if (b>1) and (g=1) and (r=0) then writeln('GR')\n else\n if (b>1) and(g=0) and (r=1) then writeln('GR')\n else\n if (b=1) and (g>1) and (r=0) then writeln('BR')\n else\n if (b=0) and (g>1) and (r=1) then writeln('BR')\n else\n if (b=1) and (g=0) and (r>1) then writeln('BG')\n else\n if (b=0) and (g=1) and (r>1) then writeln('BG')\n else\n if (b>0) and(g=0) and(r=0) then writeln('B')\n else\n if (b=0) and(g>0) and(r=0) then writeln('G')\n else\n if (b=0) and(g=0) and(r>0) then writeln('R')\n else writeln('BGR');\n\nend."}, {"source_code": "var st:string;\nn,i,r,g,b:longint;\nbegin\n readln(n);\n readln(st);\n if n=1 then begin\n writeln(st);\n halt;\n end;\n\n for i:=1 to n do\n if st[i]='R' then r:=r+1\n else if st[i]='G' then g:=g+1\n else b:=b+1;\n\n\n if ((r=1) and (g=1) and (b=0)) or\n ((r=0) and (g=0)) then begin\n writeln('B');\n halt;\n end\n else if ((b=1) and (g=1) and (r=0)) or\n ((b=0) and (g=0)) then begin\n writeln('R');\n halt;\n end\n else if ((b=1) and (r=1) and (g=0)) or\n ((b=0) and (r=0)) then begin\n writeln('G');\n halt;\n end;\n\n if ((g=0) and (r>=2) and (b>=2)) or\n ((b=0) and (r>=2) and (g>=2)) or\n ((r=0) and (b>=2) and (g>=2)) or\n ((r>0) and (b>0) and (g>0)) then begin\n writeln('BGR');\n halt;\n end;\n if (g=1) and (r=0) and (b>1) then begin\n writeln('GR');\n halt;\n end;\n if (g=1) and (b=0) and (r>1) then begin\n writeln('BG');\n halt;\n end;\n if (r=1) and (g=0) and (b>1) then begin\n writeln('GR');\n halt;\n end;\n if (r=1) and (b=0) and (g>1) then begin\n writeln('BR');\n halt;\n end;\n if (b=1) and (g=0) and (r>1) then begin\n writeln('BG');\n halt;\n end;\n if (b=1) and (r=0) and (g>1) then begin\n writeln('BR');\n halt;\n end;\nend."}, {"source_code": "var\n a, c, r, g, b, i: int64;\n ar: array [1..1000] of char;\n q1, q2, q3: boolean;\n \nprocedure rek(a, r, g, b: int64);\nbegin\n if a = 1 then begin\n if r = 1 then q1 := true;\n if g = 1 then q2 := true;\n if b = 1 then q3 := true;\n exit;\n end;\n if b > 1 then rek(a - 1, r, g, b - 1);\n if (b > 0) and (r > 0) then rek(a - 1, r - 1, g + 1, b - 1);\n if (b > 0) and (g > 0) then rek(a - 1, r + 1, b - 1, g - 1);\n if r > 1 then rek(a - 1, r - 1, g, b);\n if (r > 0) and (g > 0) then rek(a - 1, r - 1, g - 1, b + 1);\n if g > 1 then rek(a - 1, r, g - 1, b);\nend;\n \nbegin\n readln(a);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n if ar[i] = 'R' then inc(r);\n if ar[i] = 'G' then inc(g);\n if ar[i] = 'B' then inc(b);\n inc(i);\n end;\n if (r > 0) and (g > 0) and (b > 0) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r >= 2) and (g >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r >= 2) and (b >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (g >= 2) and (b >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r = 1) and (g > 1) then begin\n q1 := true;\n q3 := true;\n end\n else if (r = 1) and (b > 1) then begin\n q1 := true;\n q2 := true;\n end\n else if (g = 1) and (r > 1) then begin\n q2 := true;\n q3 := true;\n end\n else if (g = 1) and (b > 1) then begin\n q2 := true;\n q1 := true;\n end\n else if (b = 1) and (r > 1) then begin\n q3 := true;\n q2 := true;\n end\n else if (b = 1) and (g > 1) then begin\n q3 := true;\n q1 := true;\n end\n else if (r = 1) and (g = 1) then q3 := true\n else if (r = 1) and (b = 1) then q2 := true\n else if (g = 1) and (b = 1) then q1 := true\n else if (r > 0) then q1 := true\n else if (g > 0) then q2 := true\n else if (b > 0) then q3 := true;\n if q3 then write('B');\n if q2 then write('G');\n if q1 then write('R');\nend."}, {"source_code": "var i,n,j,x,y,t,kol,R,B,G:longint;\ns,sn:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s) do\nbegin\nif (s[i]='R') then inc(r);\nif (s[i]='B') then inc(b);\nif (s[i]='G') then inc(g);\nend;\n\n\nif (R>0)and(B>0)and(g>0) then\nbegin\nwriteln('BGR');\nhalt;\nend;\n\nif ((r>1)and(b>1))or\n ((r>1)and(g>1))or\n ((g>1)and(b>1)) then\nbegin\nwriteln('BGR');\nhalt;\nend;\n\nif (r>1)and(b=1) then writeln('BG') else\nif (r=1)and(b>1) then writeln('GR') else\nif (r=1)and(b=1) then writeln('G') else\n\nif (r>1)and(g=1) then writeln('BG') else\nif (r=1)and(g>1) then writeln('BR') else\nif (r=1)and(g=1) then writeln('B') else\n\nif (g>1)and(b=1) then writeln('BR') else\nif (g=1)and(b>1) then writeln('GR') else\nif (g=1)and(b=1) then writeln('R') else\nif (g>0) then writelN('G') else\nif (b>0) then writeln('B') else\nif (r>0) then writeln('R');\n\n\n\nend."}, {"source_code": "var i,n,r,g,b:longint;\n c:char;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(c);\n case c of\n 'R':inc(r);\n 'G':inc(g);\n 'B':inc(b);\n end end;\nif ((r>0)and(g>0)and(b>0))or((r>1)and(g>1)or(r>1)and(b>1)or(b>1)and(g>1))then write('BGR') else\n if (r=0)and(g=0) then write('B') else\n if (r=0)and(b=0) then write('G') else\n if (g=0)and(b=0) then write('R') else\n if (r>1) then write('BG') else\n if (g>1) then write('BR') else\n if (b>1) then write('GR') else\n if n=2 then if g=0 then write('G') else if b=0 then write('B') else write('R');\nend.\n"}, {"source_code": "uses Math;\ntype mass=array['A'..'Z'] of int64;\nVar res,mn,x,y,n,k,ans,u,l,b1,d,r,a1:int64;\n m:mass;\n i,j,z:longint;\n s:string;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n inc(m[s[i]]);\n s:='';\n if (m['B']>0)\n then if ((m['G']>0) and (m['R']>0)) or (m['G']+m['R']=0) or ((m['G']=0) and (m['R']>1)) or ((m['R']=0) and (m['G']>1))\n then s:=s+'B'\n else\n else if (m['R']>0) and (m['G']>0)\n then s:=s+'B';\n if (m['G']>0)\n then if ((m['B']>0) and (m['R']>0)) or (m['B']+m['R']=0) or ((m['B']=0) and (m['R']>1)) or ((m['R']=0) and (m['B']>1))\n then s:=s+'G'\n else\n else if (m['R']>0) and (m['B']>0)\n then s:=s+'G';\n if (m['R']>0)\n then if ((m['G']>0) and (m['B']>0)) or (m['G']+m['B']=0) or ((m['G']=0) and (m['B']>1)) or ((m['B']=0) and (m['G']>1))\n then s:=s+'R'\n else\n else if (m['G']>0) and (m['B']>0)\n then s:=s+'R';\n writeln(s);\nend."}, {"source_code": "var i,j,n,k,B,R,G:longint;q:char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(q);\n if q='B' then B:=1+b else\n if q='G' then g:=1+g else\n if q='R' then r:=1+r;\n END;\n k:=100*b+10*g+r;\n if k=111 then write('BGR') ELSE\n if k=110 then write('R') ELSE\n if k=101 then write('G') ELSE \n if k=11 then write('B') ELSE \n if R+G=0 then write('B') ELSE\n if r+b=0 then write('G') ELSE \n if b+g=0 then write('R') ELSE \n if r+b=1 then write('BR') ELSE \n if b+g=1 then write('BG') ELSE\n if r+G=1 then write('GR') ELSE \n write('BGR') ;\nend."}, {"source_code": "var r, g, b, n, i, j, t:longint;\ns:string;\na:array[1..3] of longint;\nbegin\n readln(n);\n read(s);\n r := 0; b := 0; g := 0;\n for i := 1 to n do begin\n if s[i] = 'R' then r := r + 1;\n if s[i] = 'G' then g := g + 1;\n if s[i] = 'B' then b := b + 1;\n end;\n if r > 3 then r := 2;\n if g > 3 then g := 2;\n if b > 3 then b := 2;\n a[1] := r; a[2] := g; a[3] := b;\n for i := 1 to 3 do for j := 1 to 3 do if (a[i] < a[j]) and (i > j) then begin t := a[i]; a[i] := a[j]; a[j] := t; end;\n //writeln(a[1], ' ', a[2], ' ', a[3]);\n if a[1] > 0 then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 2) then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 2) then begin\n if (b = 1) or (b = 0) then write('B'); if (g = 1) or (g = 0) then write('G'); if (r = 1) or (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 1) then begin\n if (b = 0) then write('B'); if (g = 0) then write('G'); if (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 0) and (a[3] > 0) then begin\n if b > 0 then write('B'); if g > 0 then write('G'); if r > 0 then write('R');\n exit;\n end;\nend."}, {"source_code": "var\nn, i, k1,k2, k3: integer;\ns: string;\nbegin\nreadln(n);\nreadln(s);\nfor i:= 1 to n do\nbegin\nif s[i] = 'B' then inc(k1);\nif s[i] = 'G' then inc(k2);\nif s[i] = 'R' then inc(k3);\nend;\nif (k1 >= 1) and (k2 >= 1) and (k3 >= 1) then begin writeln('BGR'); exit; end;\nif (k1 <> 0) and (k2 = 0) and (k3 = 0) then begin writeln('B'); exit; end;\nif (k1 = 0) and (k2 <> 0) and (k3 = 0) then begin writeln('G'); exit; end;\nif (k1 = 0) and (k2 = 0) and (k3 <> 0) then begin writeln('R'); exit; end;\nif (k1 = 0)\nthen\nbegin\nif (k2 = 1) and (k3 = 1) then begin writeln('B'); exit; end;\nif (k2 = 1) then begin writeln('BG'); exit; end;\nif (k3 = 1) then begin writeln('BR'); exit; end;\n writeln('BGR'); exit;\nend;\nif (k2 = 0)\nthen\nbegin\nif (k1 = 1) and (k3 = 1) then begin writeln('G'); exit; end;\nif (k1 = 1) then begin writeln('BG'); exit; end;\nif (k3 = 1) then begin writeln('GR'); exit; end;\n writeln('BGR'); exit;\nend;\nif (k3 = 0)\nthen\nbegin\nif (k1 = 1) and (k2 = 1) then begin writeln('R'); exit; end;\nif (k1 = 1) then begin writeln('BR'); exit; end;\nif (k2 = 1) then begin writeln('GR'); exit; end;\n writeln('BGR'); exit;\nend;\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\nnewdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,aa,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n readln(ss);\n\n for i:=1 to n do\n begin\n if ss[i]='B' then inc(p1);\n if ss[i]='G' then inc(p2);\n if ss[i]='R' then inc(p3);\n\n end;\n\n\n if (p1>0)and(p2>0)and(p3>0) then begin write('BGR'); goto 1; end;\n if p1+p2=0 then begin write('R'); goto 1; end;\n if p1+p3=0 then begin write('G'); goto 1; end;\n if p3+p2=0 then begin write('B'); goto 1; end;\n\n if (n=2)and(p1=0) then begin write('B'); goto 1; end;\n if (n=2)and(p2=0) then begin write('G'); goto 1; end;\n if (n=2)and(p3=0) then begin write('R'); goto 1; end;\n\n\n\n\n\n\n if (p1>=2)and(p2=1) then begin write('GR'); goto 1; end;\n if (p1=1)and(p2>=2) then begin write('BR'); goto 1; end;\n\n\n if (p2>=2)and(p3=1) then begin write('BR'); goto 1; end;\n if (p2=1)and(p3>=2) then begin write('BG'); goto 1; end;\n\n if (p1>=2)and(p3=1) then begin write('GR'); goto 1; end;\n if (p1=1)and(p3>=2) then begin write('BG'); goto 1; end;\n\n\n\n\n write('BGR');\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "var a:array[1..3] of longint;\n s:string;\n n,i:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='R'\n then inc(a[1]);\n if s[i]='G'\n then inc(a[2]);\n if s[i]='B'\n then inc(a[3]);\n end;\n if ((a[1]>1) and (a[2]>1)) or\n ((a[1]>1) and (a[3]>1)) or\n ((a[3]>1) and (a[2]>1)) or\n ((a[1]>0) and (a[2]>0) and (a[3]>0))\n then write('BGR');\n if ((a[1]=0) and (a[2]=1) and (a[3]=1)) or\n ((a[1]>0) and (a[2]=0) and (a[3]=0))\n then write('R');\n if ((a[1]=1) and (a[2]=0) and (a[3]=1)) or\n ((a[1]=0) and (a[2]>0) and (a[3]=0))\n then write('G');\n if ((a[1]=1) and (a[2]=1) and (a[3]=0)) or\n ((a[1]=0) and (a[2]=0) and (a[3]>0))\n then write('B');\n if (a[1]>1) and (((a[2]=1) and (a[3]=0)) or ((a[2]=0) and (a[3]=1)))\n then write('BG');\n if (a[2]>1) and (((a[1]=1) and (a[3]=0)) or ((a[1]=0) and (a[3]=1)))\n then write('BR');\n if (a[3]>1) and (((a[2]=1) and (a[1]=0)) or ((a[2]=0) and (a[1]=1)))\n then write('GR');\nend.\n"}, {"source_code": "var st,ans:string;\ni,n,r,g,b:longint;\nbegin\n readln(n);\n readln(st);\n for i:=1 to n do\n if st[i]='R' then r:=r+1\n else if st[i]='G' then g:=g+1\n else b:=b+1;\n\n if (r=0) and (g=0) then ans:='B'\n else\n if (r=0) and (b=0) then ans:='G'\n else\n if (b=0) and (g=0) then ans:='R'\n else\n if (r=0) and (g=1) and (b=1) then ans:='R'\n else\n if (r=0) and (g>1) and (b=1) then ans:='BR'\n else\n if (r=0) and (g=1) and (b>1) then ans:='GR'\n\n else\n if (b=0) and (g=1) and (r=1) then ans:='B'\n else\n if (b=0) and (g>1) and (r=1) then ans:='BR'\n else\n if (b=0) and (g=1) and (r>1) then ans:='BG'\n\n else\n if (g=0) and (b=1) and (r=1) then ans:='G'\n else\n if (g=0) and (b>1) and (r=1) then ans:='GR'\n else\n if (g=0) and (b=1) and (r>1) then ans:='BG'\n else ans:='BGR';\n writeln(ans);\nend."}, {"source_code": "program ProjectDCodeforces;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n k,i,j,n:integer;\n g,a,b,c,r,d,res:int64;\n s:char;\nbegin\n // Reset(Input,'input.txt');\n // Rewrite(Output,'output.txt');\n Readln(n);\n r:=0;\n b:=0;\n g:=0;\n for i:=1 to n do\n begin\n read(s);\n case s of\n 'R': Inc(r);\n 'G': Inc(g);\n 'B': Inc(b);\n end;\n end;\n\n if (r>=1)and(g>=1)and(b>=1)\n then write('BGR')\n else begin\n if (r=0)\n then begin\n if (b>=2)and(g=1)\n then write('GR');\n if (g>=2)and(b=1)\n then write('BR');\n if (b=1)and(g=1)\n then write('R');\n if (g>=2)and(b>=2)\n then write('BGR')\n end;\n\n if (g=0)\n then begin\n if (b>=2)and(r=1)\n then write('GR');\n if (r>=2)and(b=1)\n then write('BG');\n if (b=1)and(r=1)\n then write('G');\n if (r>=2)and(b>=2)\n then write('BGR')\n end;\n if (b=0)\n then begin\n if (r>=2)and(g=1)\n then write('BG');\n if (g>=2)and(r=1)\n then write('BR');\n if (g=1)and(r=1)\n then write('B');\n if (g>=2)and(r>=2)\n then write('BGR')\n end;\n if (r>0)and(b=0)and(g=0)\n then write('R');\n if (G>0)and(r=0)and(b=0)\n then write('G');\n if (b>0)and(r=0)and(g=0)\n then write('B');\n end;\n\n\nend."}, {"source_code": "var n,i,kG,kB,Kr:longint;\n s:string;\nprocedure ex(h:string);\nbegin\nwrite(h);\n\nhalt;\nend;\nbegin\n\nreadln(n);\nread(s);\nfor i:=1 to n do begin\nif s[i]='G' then inc(kG);\nif s[i]='R' then inc(kR);\nif s[i]='B' then inc(kB);\nend;\nif (kG=0) and (kR=0) then ex('B');\nif (kG=0) and (kB=0) then ex('R');\nif (kB=0) and (kR=0) then ex('G');\n\nif (kG>0) and (kB>0) and (kR>0) then ex('BGR');\nif KG=0 then begin\n if (kB-1>0) and (kR-1>0) then ex('BGR');\n if (kB-1=0) and (kR-1>0) then ex('BG');\n if (kB-1=0) and (kR-1=0) then ex('G');\n if (kB-1>0) and (kr-1=0) then ex('GR');\nend;\nif Kb=0 then begin\n if (kG-1>0) and (kR-1>0) then ex('BGR');\n if (kG-1=0) and (kR-1>0) then ex('BG');\n if (kG-1=0) and (kR-1=0) then ex('B');\n if (kG-1>0) and (kr-1=0) then ex('BR');\nend;\nif Kr=0 then begin\n if (kB-1>0) and (kG-1>0) then ex('BGR');\n if (kB-1=0) and (kG-1>0) then ex('BR');\n if (kB-1=0) and (kG-1=0) then ex('R');\n if (kB-1>0) and (kG-1=0) then ex('GR');\nend;\nend.\n"}, {"source_code": "const\n fi ='';\n fg ='';\nvar n:longint;\n s:ansistring;\n sum:array[1..3] of longint;\n g:text;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n readln(f,s);\n close(f);\nend;\nprocedure xuly3;\nbegin\n If ((sum[3] = 0) and ((sum[2] = 0) or (sum[1] = 0))) or ((sum[3] > 0) and (((sum[2] = 1) and (sum[1] = 0)) or ((sum[1] = 1) and (sum[2] = 0)))) then exit;\n write(g,'R');\nend;\nprocedure xuly2;\nbegin\n If ((sum[2] = 0) and ((sum[1] = 0) or (sum[3] = 0))) or ((sum[2] > 0) and (((sum[1] = 1) and (sum[3] = 0)) or ((sum[3] = 1) and (sum[1] = 0)))) then exit;\n write(g,'G');\nend;\nprocedure xuly1;\nbegin\n If ((sum[1] = 0) and ((sum[2] = 0) or (sum[3] = 0))) or ((sum[1] > 0) and (((sum[2] = 1) and (sum[3] = 0)) or ((sum[3] = 1) and (sum[2] = 0)))) then exit;\n write(g,'B');\nend;\nprocedure xuly;\nvar i:longint;\nbegin\n assign(g,fg);\n rewrite(g);\n For i:=1 to 3 do sum[i] :=0;\n For i:=1 to n do\n begin\n case s[i] of\n 'B':inc(sum[1]);\n 'G':inc(sum[2]);\n 'R':inc(sum[3]);\n end;\n end;\n xuly1;xuly2;xuly3;\n close(g);\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "var\n k1,k2,k3,i,j,n,m,k,t,x:longint;\n f:array[0..222,0..222,0..222]of boolean;\n s:ansistring;\n\nprocedure dfs(k1,k2,k3:longint);\nbegin\n if f[k1,k2,k3]then exit;\n f[k1,k2,k3]:=true;\n if k1>1 then dfs(k1-1,k2,k3);\n if k2>1 then dfs(k1,k2-1,k3);\n if k3>1 then dfs(k1,k2,k3-1);\n if(k1>0)and(k2>0)then dfs(k1-1,k2-1,k3+1);\n if(k1>0)and(k3>0)then dfs(k1-1,k2+1,k3-1);\n if(k2>0)and(k3>0)then dfs(k1+1,k2-1,k3-1);\nend;\n\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='R' then inc(k1);\n if s[i]='G' then inc(k2);\n if s[i]='B' then inc(k3);\n end;\n dfs(k1,k2,k3);\n if f[0,0,1]then write('B');\n if f[0,1,0]then write('G');\n if f[1,0,0]then write('R');\n writeln;\nend.\n\n"}, {"source_code": "var a:array[0..2,0..2,0..2]of boolean;\n sb,sg,sr,i,j,k,n:longint;\n ch:char;\nprocedure search(sb,sg,sr:longint);\nbegin\n if a[sb,sg,sr] then exit;\n a[sb,sg,sr]:=true;\n if (sb>=1)and(sg>=1) then search(sb-1,sg-1,sr+1);\n if (sb>=1)and(sr>=1) then search(sb-1,sg+1,sr-1);\n if (sr>=1)and(sg>=1) then search(sb+1,sg-1,sr-1);\n if sb>=2 then search(sb-1,sg,sr);\n if sg>=2 then search(sb,sg-1,sr);\n if sr>=2 then search(sb,sg,sr-1);\nend;\nbegin\n readln(n);\n sb:=0;\n sg:=0;\n sr:=0;\n for i:=1 to n do\n begin\n read(ch);\n if ch='B' then inc(sb);\n if ch='G' then inc(sg);\n if ch='R' then inc(sr);\n end;\n if sb>=2 then sb:=2;\n if sg>=2 then sg:=2;\n if sr>=2 then sr:=2;\n for i:=0 to 2 do\n for j:=0 to 2 do\n for k:=0 to 2 do\n a[i,j,k]:=false;\n search(sb,sg,sr);\n if a[1,0,0] then write('B');\n if a[0,1,0] then write('G');\n if a[0,0,1] then write('R');\nend.\n"}, {"source_code": "var s:string;\n i,n:longint;\n a:array[1..3]of longint;\nbegin\n readln(n);\n read(s);\n for i:=1 to length(s) do\n begin\n if s[i]='B'\n then inc(a[1]);\n if s[i]='G'\n then inc(a[2]);\n if s[i]='R'\n then inc(a[3]);\n end;\n if (a[1]>0)and(a[2]>0)and(a[3]>0)\n then begin write('BGR');halt;end;\n \n if (a[1]=0)and(a[2]=0)and(a[3]>0)\n then begin write('R');halt;end;\n if (a[1]>0)and(a[2]=0)and(a[3]=0)\n then begin write('B');halt;end;\n if (a[1]=0)and(a[2]>0)and(a[3]=0)\n then begin write('G');halt;end;\n \n if (a[1]=0)and(a[2]=1)and(a[3]=1)\n then begin write('B');halt;end;\n if (a[1]=1)and(a[2]=0)and(a[3]=1)\n then begin write('G');halt;end;\n if (a[1]=1)and(a[2]=1)and(a[3]=0)\n then begin write('R');halt;end;\n \n if (a[1]>1)and(a[2]<=1)and(a[3]<=1)\n then begin write('GR');halt;end;\n if (a[1]<=1)and(a[2]>1)and(a[3]<=1)\n then begin write('BR');halt;end;\n if (a[1]<=1)and(a[2]<=1)and(a[3]>1)\n then begin write('BG');halt;end;\n write('BGR');\n\n\n\nend."}, {"source_code": "uses math;\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n c:array['A'..'Z'] of longint;\n dem:array[1..3] of longint;\n ch:array[1..3] of char;\n n,cnt:longint;\n s:string;\n\nprocedure mofile;\nbegin\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure xuli;\nvar\n i,k:longint;\n j:char;\nbegin\n readln(n);\n readln(s);\n c['B']:=1;\n c['G']:=2;\n c['R']:=3;\n ch[1]:='B';\n ch[2]:='G';\n ch[3]:='R';\n for i:=1 to n do inc(dem[c[s[i]]]);\n for i:=1 to 3 do cnt:=cnt+ord(dem[i]>0);\n if cnt=3 then writeln('BGR') else\n begin\n if cnt=1 then\n begin\n for i:=1 to 3 do\n if dem[i]>0 then\n begin\n writeln(ch[i]);\n end;\n end\n else\n begin\n if (dem[1]+dem[2]+dem[3]=2) then\n begin\n for i:=1 to 3 do\n if dem[i]=0 then writeln(ch[i]);\n end\n else\n begin\n for i:=1 to 3 do\n if dem[i]=1 then\n begin\n for k:=1 to 3 do\n if dem[k]<=1 then write(ch[k]);\n writeln;\n halt;\n end;\n writeln('BGR');\n end\n end;\n end;\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program z1;\nvar s,res:ansistring;\nn,a,b,c,i,k:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='B' then inc(a);\n if s[i]='G' then inc(b);\n if s[i]='R' then inc(c);\n if ((a>0) and (b>0) and (c>0)) or ((a>1) and (b>1)) or ((a>1) and (c>1)) or ((b>1) and (c>1)) then begin\n write('BGR');\n halt\n end\n end;\nif (a=0) and (b=0) then begin\n write('R');\n halt\n end;\nif (a=0) and (c=0) then begin\n write('G');\n halt\n end;\nif (c=0) and (b=0) then begin\n write('B');\n halt\n end;\nif (a=1) and (b=1) then begin\n write('R');\n halt\n end;\nif (a=1) and (c=1) then begin\n write('G');\n halt\n end;\nif (c=1) and (b=1) then begin\n write('B');\n halt\n end;\nif a=1 then begin\n if b<>0 then write('BR')\n else write('BG');\n halt\n end;\nif b=1 then begin\n if c<>0 then write('BG')\n else write('GR');\n halt\n end;\nif c=1 then begin\n if b<>0 then write('BR')\n else write('GR');\n halt\n end;\nEnd."}, {"source_code": "Program Buntarik;\nvar n,a,b,c,i:longint;\ns:string;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nif s[i]='B'\nthen inc(a)\nelse if s[i]='R'\nthen inc(b)\nelse inc(c);\nif n=1\nthen begin writeln(s); halt; end;\n\nif (a>0)and(b>0)and(c>0)or(a>1)and(b>1)or(c>1)and(b>1)or(a>1)and(c>1)\nthen writeln('BGR')\nelse\nif (a>1)and(b=1)and(c=0)or(a>1)and(b=0)and(c=1)\nthen writeln('GR')\nelse\nif (a=1)and(b>1)and(c=0)or(a=0)and(b>1)and(c=1)\nthen writeln('BG')\nelse\nif (a=1)and(b=0)and(c>1)or(a=0)and(b=1)and(c>1)\nthen writeln('BR')\nelse if (a>1)and(b=0)and(c=0)or(a=0)and(b=1)and(c=1)\nthen writeln('B')\nelse if (a=0)and(b>1)and(c=0)or(a=1)and(b=0)and(c=1)\nthen writeln('R')\nelse if (a=0)and(b=0)and(c>1)or(a=1)and(b=1)and(c=0)\nthen writeln('G');\n\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "var\n s:string;\n n,i:longint;\n R,G,B:longint;\n\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(B);\n if s[i]='G' then inc(G);\n if s[i]='R' then inc(R);\n end;\n if (B>=1) and (G>=1) and (R>=1) then writeln('BGR')\n else begin\n if (B=0) and (G>0) and (R>0) then\n begin\n if (G>=2) and (R>=2) then writeln('BGR');\n if (G=1) and (R>=2) then writeln('BG');\n if (G>=2) and (R=1) then writeln('BR');\n if (G=1) and (R=1) then writeln('B');\n end;\n if (G=0) and (B>0) and (R>0) then\n begin\n if (B>=2) and (R>=2) then writeln('BGR');\n if (B=1) and (R>=2) then writeln('BG');\n if (R=1) and (B>=2) then writeln('GR');\n if (B=1) and (R=1) then writeln('G');\n end;\n if (R=0) and (B>0) and (G>0) then\n begin\n if (B>=2) and (G>=2) then writeln('BGR');\n if (B=1) and (G>=2) then writeln('BR');\n if (G=1) and (B>=2) then writeln('GR');\n if (G=1) and (B=1) then writeln('R');\n end;\n if (B=0) and (G=0) then writeln('R');\n if (B=0) and (R=0) then writeln('G');\n if (G=0) and (R=0) then writeln('B');\n end;\nend.\n"}, {"source_code": "var\n N,i,B,R,G:longint;\n ch:char;\n fg,fr,fb:boolean;\n \nprocedure G1(b,r,g:byte);\nbegin\n if(b=0)and(r=0) then fg:=true;\n if(b=0)and(g=0) then fr:=true;\n if(g=0)and(r=0) then fb:=true;\n \n if(b+g+r>1) then begin\n if(b>0)and(g>0) then G1(b-1,r+1,g-1);\n if(b>0)and(r>0) then G1(b-1,r-1,g+1);\n if(r>0)and(g>0) then G1(b+1,r-1,g-1);\n if(b>1) then G1(b-1,r,g);\n if(r>1) then G1(b,r-1,g);\n if(g>1) then G1(b,r,g-1);\n end;\nend;\n \nbegin\n readln(n);\n b:=0;\n r:=0;\n g:=0;\n \n for i:=1 to N do begin\n read(ch);\n if(ch='B') then inc(b);\n if(ch='R') then inc(r);\n if(ch='G') then inc(g);\n end;\n \n if(b>4) then b:=4;\n if(r>4) then r:=4;\n if(g>4) then g:=4;\n \n fg:=false;\n fr:=false;\n fb:=false;\n \n G1(b,r,g);\n \n if(fb) then write('B');\n if(fg) then write('G');\n if(fr) then write('R');\nend. \n"}, {"source_code": "var\n s : ansistring;\n n,r,b,g,i : longint;\n\n function chk(x,y,z : longint) : boolean;\n begin\n if (x > 0) and (y > 0) and (z > 0) then exit(true);\n if (y+z = 0) then exit(true);\n if (x = 0) then begin\n if (y > 0) and (z > 0) then exit(true);\n end;\n if (y = 0) then begin\n if (x > 0) and (z > 1) then exit(true);\n end;\n if (z = 0) then begin\n if (x > 0) and (y > 1) then exit(true);\n end;\n exit(false);\n end;\n\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n if s[i] = 'R' then inc(r);\n if s[i] = 'G' then inc(g);\n if s[i] = 'B' then inc(b);\n end;\n if chk(b,r,g) then write('B');\n if chk(g,r,b) then write('G');\n if chk(r,g,b) then write('R');\n writeln;\nend."}, {"source_code": "{$mode objfpc}\nCONST\n ip = '';//'card.inp';\n op = '';//'card.out';\nVAR\n n : LongInt;\n b,g,r : LongInt;\n s,t : String;\n\n\nprocedure INPUT;\nvar\n f : Text;\nbegin\n assign(f,ip); reset(f);\n readln(f,n);\n readln(f,s);\n close(f);\nend;\n\n\nfunction check(a,b,c : LongInt) :BooLean;\nbegin\n if (a >= 1) and (b < 1) and (c < 1) then exit(true);\n if (a >= 1) and ((b >1) or (c > 1)) then exit(true);\n if (b >= 1) and (c >= 1) then exit(true);\n\n exit(false);\nend;\n\n\nprocedure SOLVE;\nvar\n i,j : Longint;\nbegin\n for i := 1 to n do\n case s[i] of\n 'B' : inc(b);\n 'G' : inc(g);\n 'R' : inc(r);\n end;\nend;\n\n\nprocedure OUTPUT;\nvar\n f : Text;\n i : LongInt;\nbegin\n assign(f,op); rewrite(f);\n if check(b,g,r) then write(f,'B');\n if check(g,b,r) then write(f,'G');\n if check(r,b,g) then write(f,'R');\n close(f);\nend;\n\n\nBEGIN\n INPUT;\n SOLVE;\n OUTPUT;\nEND.\n"}, {"source_code": "var\n n, i, g, b, r: Integer;\n s: string;\n \nbegin\n ReadLn (n);\n ReadLn (s);\n \n g:= 0;\n b:= 0;\n r:= 0;\n \n for i:= 1 to Length (s) do\n if s[i] = 'G' then\n Inc (g)\n else if s[i] = 'B' then\n Inc (b)\n else if s[i] = 'R' then\n Inc (r);\n \n if (b = 0) and ((r = 0) or (g = 0)) then\n else if (b >= 1) and (r + g = 1) then\n else Write ('B');\n \n if (g = 0) and ((r = 0) or (b = 0)) then\n else if (g >= 1) and (r + b = 1) then\n else Write ('G');\n \n if (r = 0) and ((b = 0) or (g = 0)) then\n else if (r >= 1) and (b + g = 1) then\n else Write ('R')\nend.\n "}, {"source_code": "var i,n,r,g,b:longint;\n S:string;\n begin\n readln(n);\n readln(S); r:=0; g:=0; b:=0;\n for i:=1 to n do\n begin\n if S[i]='G' then g:=g+1;\n if S[i]='R' then r:=r+1;\n if S[i]='B' then b:=b+1;\n end;\n if (r>0) and (g>0) then write('B')\n else if (b>0) and (r=0) and (g=0) then write('B')\n else if (b>0) and ((r>1) or (g>1)) then write('B');\n \n if (r>0) and (b>0) then write('G')\n else if (g>0) and (r=0) and (b=0) then write('G')\n else if (g>0) and ((r>1) or (b>1)) then write('G');\n \n if (g>0) and (b>0) then write('R')\n else if (r>0) and (g=0) and (b=0) then write('R')\n else if (r>0) and ((g>1) or (b>1)) then write('R');\n end. "}, {"source_code": "Program p1;\nvar n, i, j, l:longint;\n c:array [1..200] of char;\n a:array [1..200,1..3] of byte;\nbegin\n readln (n);\n for i:=1 to n do\n read (c[i]);\n fillchar (a,(n+1)*4,0);\n if n=1 then\n begin\n write (c[1]);\n halt;\n end;\n if c[1]='R' then\n if c[2]='R' then\n begin\n a[1,1]:=1;\n a[2,1]:=1;\n end\n else if c[2]='B' then\n begin\n a[1,1]:=1;\n a[2,3]:=1;\n end\n else\n begin\n a[1,1]:=1;\n a[2,2]:=1;\n end\n else if c[1]='B' then\n if c[2]='R' then\n begin\n a[1,2]:=1;\n a[2,3]:=1;\n end\n else if c[2]='B' then\n begin\n a[1,2]:=1;\n a[2,2]:=1;\n end\n else\n begin\n a[1,2]:=1;\n a[2,1]:=1;\n end\n else if c[2]='R' then\n begin\n a[1,3]:=1;\n a[2,2]:=1;\n end\n else if c[2]='B' then\n begin\n a[1,3]:=1;\n a[2,1]:=1;\n end\n else\n begin\n a[1,3]:=1;\n a[2,3]:=1;\n end;\n for i:=3 to n do\n begin\n if c[i]='R' then\n for j:=1 to 3 do\n begin\n if a[i-1,j]=1 then\n if j=1 then a[i,1]:=1\n else if j=2 then a[i,3]:=1\n else a[i,2]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,1]:=1\n else if j=2 then a[i,3]:=1\n else a[i,2]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,2]:=1\n else if j=2 then a[i,1]:=1\n else a[i,3]:=1\n else if j=1 then a[i,3]:=1\n else if j=2 then a[i,2]:=1\n else a[i,1]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,1]:=1\n else if j=2 then a[i,2]:=1\n else a[i,3]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,3]:=1\n else if j=2 then a[i,1]:=1\n else a[i,2]:=1\n else if j=1 then a[i,2]:=1\n else if j=2 then a[i,3]:=1\n else a[i,1]:=1;\n end\n else if c[i]='B' then\n for j:=1 to 3 do\n begin\n if a[i-1,j]=1 then\n if j=1 then a[i,3]:=1\n else if j=2 then a[i,2]:=1\n else a[i,1]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,2]:=1\n else if j=2 then a[i,1]:=1\n else a[i,3]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,3]:=1\n else if j=2 then a[i,2]:=1\n else a[i,1]:=1\n else if j=1 then a[i,1]:=1\n else if j=2 then a[i,3]:=1\n else a[i,2]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,2]:=1\n else if j=2 then a[i,3]:=1\n else a[i,1]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,1]:=1\n else if j=2 then a[i,2]:=1\n else a[i,3]:=1\n else if j=1 then a[i,3]:=1\n else if j=2 then a[i,1]:=1\n else a[i,2]:=1;\n end\n else\n for j:=1 to 3 do\n begin\n if a[i-1,j]=1 then\n if j=1 then a[i,2]:=1\n else if j=2 then a[i,1]:=1\n else a[i,3]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,3]:=1\n else if j=2 then a[i,2]:=1\n else a[i,1]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,1]:=1\n else if j=2 then a[i,3]:=1\n else a[i,2]:=1\n else if j=1 then a[i,2]:=1\n else if j=2 then a[i,1]:=1\n else a[i,3]:=1;\n if a[i-2,j]=1 then\n if c[i-1]='R' then\n if j=1 then a[i,3]:=1\n else if j=2 then a[i,1]:=1\n else a[i,2]:=1\n else if c[i-1]='B' then\n if j=1 then a[i,2]:=1\n else if j=2 then a[i,3]:=1\n else a[i,1]:=1\n else if j=1 then a[i,1]:=1\n else if j=2 then a[i,2]:=1\n else a[i,3]:=1;\n end;\n end;\n if a[n,2]=1 then write ('B');\n if a[n,3]=1 then write ('G');\n if a[n,1]=1 then write ('R');\nend."}, {"source_code": "uses math;\nvar\n a,t1,t2,t3,r:array[0..100000]of longint;\n s,ss:ansistring;\n i,m,n,k,l,w,j,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n\n if (a[1]<>0) then\n begin\n if a[2]+a[3]<>1 then r[1]:=1;\n end;\n if a[1]=0 then\n begin\n if (a[2]<>0)and(a[3]<>0) then r[1]:=1;\n end;\n\n if (a[2]<>0) then\n begin\n if a[1]+a[3]<>1 then r[2]:=1;\n end;\n if a[2]=0 then\n begin\n if (a[1]<>0)and(a[3]<>0) then r[2]:=1;\n end;\n\n if (a[3]<>0) then\n begin\n if (a[1]+a[2]<>1) then r[3]:=1;\n end;\n if a[3]=0 then\n begin\n if (a[2]<>0)and(a[1]<>0) then r[3]:=1;\n end;\n if r[1]=1 then write('B');\n if r[2]=1 then write('G');\n if r[3]=1 then write('R');\nend.\n\n"}, {"source_code": "var\n N,i:Longint;\n X:Char;\n cnt,ans:array ['A'..'Z'] of Longint;\nprocedure DFS(B,G,R:Longint);\nbegin\n if B+G+R=1 then begin\n if B=1 then ans['B']:=1;\n if G=1 then ans['G']:=1;\n if R=1 then ans['R']:=1;\n Exit;\n end;\n if B>1 then DFS((B div 2)+(B mod 2),G,R);\n if G>1 then DFS(B,(G div 2)+(G mod 2),R);\n if R>1 then DFS(B,G,(R div 2)+(R mod 2));\n if (B>0) and (G>0) then DFS(B-1,G-1,R+1);\n if (B>0) and (R>0) then DFS(B-1,G+1,R-1);\n if (G>0) and (R>0) then DFS(B+1,G-1,R-1);\n end;\n\nbegin\n Readln(N);\n for i:=1 to N do\nbegin\n Read(X);\n Inc(cnt[X]);\n end;\n while cnt['G']>2 do\n cnt['G']:=(cnt['G'] div 2)+(cnt['G'] mod 2);\n while cnt['B']>2 do\n cnt['B']:=(cnt['B'] div 2)+(cnt['B'] mod 2);\n while cnt['R']>2 do\n cnt['R']:=(cnt['R'] div 2)+(cnt['R'] mod 2);\n DFS(cnt['B'],cnt['G'],cnt['R']);\n if ans['B']=1 then Write('B');\n if ans['G']=1 then Write('G');\n if ans['R']=1 then Write('R');\n end.\n\n"}, {"source_code": "var s:string;\n i,j,n,m,r,g,b:longint;\nbegin\nreadln(n);\nreadln(s);\nr:=0; g:=0; b:=0;\n\nfor i:=1 to n do\nbegin\nif s[i]='R' then inc(r);\nif s[i]='G' then inc(g);\nif s[i]='B' then inc(b);\nend;\n\n\nif (r>0) and(g=0) and(b=0) then begin writeln('R'); halt; end;\nif (r=0) and(g>0) and(b=0) then begin writeln('G'); halt; end;\nif (r=0) and(g=0) and(b>0) then begin writeln('B'); halt; end;\n\nif (r=1) and(g=1) and(b=0) then begin writeln('B'); halt; end;\nif (r=1) and(g=0) and(b=1) then begin writeln('G'); halt; end;\nif (r=0) and(g=1) and(b=1) then begin writeln('R'); halt; end;\n\nif (r>1) and(g=1) and(b=0) then begin writeln('BG'); halt; end;\nif (r>1) and(g=0) and(b=1) then begin writeln('BG'); halt; end;\n\nif (r=1) and(g>1) and(b=0) then begin writeln('BR'); halt; end;\nif (r=1) and(g=0) and(b>1) then begin writelN('GR'); halt; end;\n\nif (r=0) and(g>1) and(b=1) then begin writeln('BR'); halt; end;\nif (r=0) and(g=1) and(b>1) then begin writeln('GR'); halt; end;\n\n\nwriteln('BGR');\n\n\nend."}, {"source_code": "var a:array[0..2001]of int64;\n s:array[0..2001] of char;\n pr,ind1,ind2,ind3,n,i:longint;\nbegin\nreadln(n);\npr:=0;\nfor i:=1 to n do\nbegin\nread(s[i]);\nif s[i]='B'then inc(a[1])else\nif s[i]='G'then inc(a[2])else\ninc(a[3]);\nend;\nfor i:=1 to 3 do\nif a[i]<>0 then inc(pr);\n\nif pr=3 then begin writeln('BGR');halt;end;\nif pr=1 then\n for i:=1 to 3 do\n if a[i]<>0 then\n if i=1 then begin writeln('B');halt;end else\n if i=2 then begin writeln('G');halt;end else\n if i=3 then begin writeln('R');halt;end;\nif pr=2 then\nbegin\nfor i:=1 to 3 do\nif a[i]<>0 then begin ind1:=i; break;end;\nfor i:=1 to 3 do\nif (a[i]<>0)and(i<>ind1) then begin ind2:=i; break;end;\n\nif (a[ind1]>1)and(a[ind2]>1)then begin writeln('BGR');halt;end else\nif (a[ind1]=1)and(a[ind2]=1)then begin\n for i:=1 to 3 do\n if a[i]=0 then ind3:=i;\n if ind3=1 then write('B');\n if ind3=2 then write('G');\n if ind3=3 then write('R');\n halt;end else\n begin\n for i:=1 to 3 do\n if a[i]=0 then ind3:=i;\n\n if a[ind1]=1 then\n begin\n if ind1>ind3 then begin\n if ind3=1 then write('B');\n if ind3=2 then write('G');\n if ind3=3 then write('R');\n if ind1=1 then write('B');\n if ind1=2 then write('G');\n if ind1=3 then write('R');\n end;\n if ind1ind3 then begin\n if ind3=1 then write('B');\n if ind3=2 then write('G');\n if ind3=3 then write('R');\n if ind2=1 then write('B');\n if ind2=2 then write('G');\n if ind2=3 then write('R');\n end;\n if ind20) and (kb<>0) and (kr<>0) then\nbegin\nwriteln('BGR');\nhalt;\nend;\nif ((kg>=2) and (kb>=2)) or ((kr>=2) and (kb>=2)) or ((kg>=2) and (kr>=2)) then\nbegin\nwriteln('BGR');\nhalt;\nend;\nif (kg>=2) and ((kr=1) or (kb=1)) then\nbegin\nwriteln('BR');\nhalt;\nend;\nif (kr>=2) and ((kb=1) or (kg=1)) then\nbegin\nwriteln('BG');\nhalt;\nend;\nif (kb>=2) and ((kr=1) or (kg=1)) then\nbegin\nwriteln('GR');\nhalt;\nend;\nif (kg=1) and (kr=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kg=1) and (kb=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nif (kr=1) and (kb=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kg>=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kb>=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kr>=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nend."}, {"source_code": "var n,i,k1,k2,k3,j,l:longint;\n c:char;\n a:array[0..2,0..2,0..2]of string;\nbegin\n readln(n);\n k1:=0;k2:=0;k3:=0;\n for i:=1 to n do\n begin\n read(c);\n case c of\n 'B':inc(k1);\n 'G':inc(k2);\n 'R':inc(k3);\n end;\n end;\n readln;\n if k1>2 then k1:=2;if k2>2 then k2:=2;if k3>2 then k3:=2;\n for i:=0 to 2 do\n for j:=0 to 2 do\n for l:=0 to 2 do\n a[i,j,l]:='BGR';\n\n a[1,0,0]:='B';\n a[2,0,0]:='B';\n a[0,1,0]:='G';\n a[0,2,0]:='G';\n a[0,0,1]:='R';\n a[0,0,2]:='R';\n a[1,1,0]:='R';\n a[0,1,1]:='B';\n a[1,0,1]:='G';\n a[2,1,0]:='GR';\n a[2,0,1]:='GR';\n a[1,2,0]:='BR';\n a[0,2,1]:='BR';\n a[1,0,2]:='BG';\n a[0,1,2]:='BG';\n writeln(a[k1,k2,k3]);\nend."}, {"source_code": "var\nn,r,g,i,b:longint;\nst:string;\nbegin\n\n readln(n);\n readln(st);\n for i:=1 to n do\n begin\n if st[i]='R' then r:=r+1;\n if st[i]='G' then g:=g+1;\n if st[i]='B' then b:=b+1;\n end;\n if (b=1) and (g=1) and (r=0) then writeln('R')\n else\n if (b=1) and (g=0) and (r=1) then writeln('G')\n else\n if (b=0) and (g=1) and (r=1) then writeln('B')\n else\n if (b>1) and (g=1) and (r=0) then writeln('GR')\n else\n if (b>1) and(g=0) and (r=1) then writeln('GR')\n else\n if (b=1) and (g>1) and (r=0) then writeln('BR')\n else\n if (b=0) and (g>1) and (r=1) then writeln('BR')\n else\n if (b=1) and (g=0) and (r>1) then writeln('BG')\n else\n if (b=0) and (g=1) and (r>1) then writeln('BG')\n else\n if (b>0) and(g=0) and(r=0) then writeln('B')\n else\n if (b=0) and(g>0) and(r=0) then writeln('G')\n else\n if (b=0) and(g=0) and(r>0) then writeln('R')\n else writeln('BGR');\n\nend.\n"}, {"source_code": "const\n fi ='';\n fg ='';\nvar n:longint;\n s:ansistring;\n sum:array[1..3] of longint;\n g:text;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n readln(f,s);\n close(f);\nend;\nprocedure xuly3;\nbegin\n If ((sum[3] = 0) and ((sum[2] = 0) or (sum[1] = 0))) or ((sum[3] > 0) and (((sum[2] = 1) and (sum[1] = 0)) or ((sum[1] = 1) and (sum[2] = 0)))) then exit;\n write(g,'R');\nend;\nprocedure xuly2;\nbegin\n If ((sum[2] = 0) and ((sum[1] = 0) or (sum[3] = 0))) or ((sum[2] > 0) and (((sum[1] = 1) and (sum[3] = 0)) or ((sum[3] = 1) and (sum[1] = 0)))) then exit;\n write(g,'G');\nend;\nprocedure xuly1;\nbegin\n If ((sum[1] = 0) and ((sum[2] = 0) or (sum[3] = 0))) or ((sum[1] > 0) and (((sum[2] = 1) and (sum[3] = 0)) or ((sum[3] = 1) and (sum[2] = 0)))) then exit;\n write(g,'B');\nend;\nprocedure xuly;\nvar i:longint;\nbegin\n assign(g,fg);\n rewrite(g);\n For i:=1 to 3 do sum[i] :=0;\n For i:=1 to n do\n begin\n case s[i] of\n 'B':inc(sum[1]);\n 'G':inc(sum[2]);\n 'R':inc(sum[3]);\n end;\n end;\n xuly1;xuly2;xuly3;\n close(g);\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "{$mode objfpc}\nuses \n\tmath;\n\nvar\n\tfi: text;\n\ti, j, n, cnt: integer;\n\ts: ansistring;\n\tcheck: array['A'..'Z'] of integer;\n\tc, last: char;\n\tres: ansistring;\nbegin\n\tassign(fi, ''); reset(fi);\n\treadln(fi, n); readln(fi, s);\n\tfor i := 1 to n do begin\n\t\tif check[s[i]] = 0 then \n\t\t\tinc(cnt);\n\t\tinc(check[s[i]]);\n\t\tlast := s[i];\n\tend;\n\n\tfor i := 1 to n do for j := i+1 to n do\n\t\tif s[i] > s[j] then begin\n\t\t\tc:= s[i]; s[i] := s[j]; s[j] := c;\n\t\tend;\n\t//\n\t\n\tif cnt = 1 then begin\n\t\twriteln(last); exit\n\tend;\n\n\tif cnt = 3 then begin\n\t\twriteln('BGR'); exit\n\tend;\n\n\tif (cnt = 2) then begin\n\t\tif ((check['R'] > 1) and (check['G'] > 1)) or ((check['R'] > 1) and (check['B'] > 1))\n\t\tor ((check['B'] > 1) and (check['G'] > 1)) then begin\n\t\t\twriteln('BGR'); exit end;\n\tend;\n\t//\n\n\tif (cnt = 2) and (n = 2) then begin\n\t\tif (check['B']>0) and (check['R'] > 0) then writeln('G')\n\t\telse if (check['B'] =1) and (check['G']=1) then writeln('R')\n\t\telse if (check['G'] = 1) and (check['R']=1) then writeln('B');\n\tend;\n\n\tres := '';\n\t//writeln(cnt);\n\tif (cnt = 2) and (n > 2) then begin\n\t\tfor i := 1 to n do \n\t\t\tif check[s[i]] > 1 then begin\n\t\t\t\tres := res + s[i];\n\t\t\t\tif length(Res) = 2 then break\n\t\t\tend;\n\t//\twriteln(res);\n\t\tif res = 'GG' then writeln('BR');\n\t\tif res = 'RR' then writeln('BG');\n\t\tif res = 'BB' then writeln('GR');\n\tend;\n\nend."}, {"source_code": "uses math;\nvar b,g,r,bs,gs,rs,i,j,n,k,m,s:longint;\n h:char;\n bb,gb,rb:boolean;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(h);\n if h = 'R' then inc(rs) else\n if h = 'B' then inc(bs) else\n inc(gs);\n end;\n\n if gs > 1 then gs:=2;\n if bs > 1 then bs:=2;\n if rs > 1 then rs:=2;\n\n b:=bs; g:=gs; r:=rs;\n\n if ((r>0) and (g>0)) or ((r=2) and (b>0)) or ((g=2) and (b>0)) or (r+g=0) then write('B');\n if ((r>0) and (b>0)) or ((r=2) and (g>0)) or ((b=2) and (g>0)) or (r+b=0) then write('G');\n if ((b>0) and (g>0)) or ((b=2) and (r>0)) or ((g=2) and (r>0)) or (b+g=0) then write('R');\n\nend."}, {"source_code": "var n,m,i,j,k,ans,l,r,ll,rr,p:longint;\n dp:array[0..200,0..200,0..200]of 0..1;\n s:string;\nprocedure rec(l,r,k:longint);\n begin\n if (dp[l,r,k]=1) then exit;\n dp[l,r,k]:=1;\n if (l>0) and (r>0) then rec(l-1,r-1,k+1);\n if (l>0) and (k>0) then rec(l-1,r+1,k-1);\n if (r>0) and (k>0) then rec(l+1,r-1,k-1);\n if (l>1) then rec(l-1,r,k);\n if (r>1) then rec(l,r-1,k);\n if (k>1) then rec(l,r,k-1);\n end;\n begin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n if s[i]='R' then l:=l+1 else\n if s[i]='G' then r:=r+1 else k:=k+1;\n rec(l,r,k);\n if dp[0,0,1]=1 then write('B');\n if dp[0,1,0]=1 then write('G');\n if dp[1,0,0]=1 then write('R');\n writeln;\n end."}, {"source_code": "var\npodr,podb,podg,min,n,i,r,g,b:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='R' then inc(r);\n if s[i]='B' then inc(b);\n if s[i]='G' then inc(g);\nend;\nif ((r>0)and(b>0)and(g>0))or((r>=2)and(b>=2))or((r>=2)and(g>=2))or((g>=2)and(b>=2)) then write('BGR')\nelse\nbegin\n if (r>=1)and(b=0)and(g=0) then write('R')\n else\n if (r=0)and(b>=1)and(g=0) then write('B')\n else\n if (r=0)and(b=0)and(g>=1) then write('G')\n else\n if (r=1)and(b=1)and(g=0) then write('G')\n else\n if (r=1)and(b=0)and(g=1) then write('B')\n else\n if (r=0)and(b=1)and(g=1) then write('R')\n else\n if (r>=2)and(b=1)and(g=0) then write('BG')\n else\n if (r>=2)and(b=0)and(g=1) then write('BG')\n else\n if (r=1)and(b>=2)and(g=0) then write('GR')\n else\n if (r=1)and(b=0)and(g>=2) then write('BR')\n else\n if (r=0)and(b>=2)and(g=1) then write('GR')\n else\n if (r=0)and(b=1)and(g>=2) then write('BR');\n \nend;\nend.\n"}, {"source_code": "{$mode objfpc}\n\nvar\n n,i,r,g,b:longint;\n s:ansistring;\nprocedure input;\nbegin\n readln(n);\n read(s);\nend;\n\nfunction tm(x,y,z:longint):boolean;\nbegin\n if (y>=1) and (z>=1) then exit(true);\n if (y=0) and (z=0) then exit(true);\n if (x>0) and ((y>1) or (z>1)) then exit(true);\n exit(false);\nend;\n\nprocedure process;\nbegin\n r:=0;\n g:=0;\n b:=0;\n for i:=1 to length(s) do\n case s[i] of\n 'R':inc(r);\n 'G':inc(g);\n 'B':inc(b);\n end;\n if tm(b,g,r) then write('B');\n if tm(g,r,b) then write('G');\n if tm(r,g,b) then write('R');\nend;\n\nbegin\n input;\n process;\nend."}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n if r>=1 then begin\n if r>=2 then begin\n if (b>=2) or (g>=2) or ((b>=1) and (g>=1)) then\n write('BGR')\n else if (b>=1) and (g=0) then\n write('BG')\n else if (b=0) and (g=1) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B')\n else if (b=0) and (g=0) then\n write('R');\n end\n end\n else if (b>=1) then begin\n if (b>=2) and (g>=2) then\n write('BGR')\n else if (b>=2) and (g>=1) then\n write('GR')\n else if(b=1) and (g>=2) then\n write('BR')\n else if (b=1) and (g=1) then\n write('R')\n else if g=0 then\n write('B');\n end\n else if g>=1 then\n write('G');\n\n\n\nEND.\n"}, {"source_code": "var\n n, i, cr, cg, cb : longint;\n s : ansistring;\n\nbegin\n readln(n); readln(s);\n cr := 0; cg := 0; cb := 0;\n for i := 1 to n do\n if (s[i] = 'R') then inc(cr) else if (s[i] = 'G') then inc(cg) else inc(cb);\n if ((cr > 0) and (cg > 0) and (cb > 0))\n or ((cr > 1) and (cb > 1)) or ((cb > 1) and (cg > 1)) or ((cr > 1) and (cg > 1))\n then\n begin\n writeln('BGR');\n halt;\n end;\n if ((cr = 0) and (cg = 0)) or ((cr = 1) and (cg = 1)) then\n begin\n writeln('B');\n halt;\n end;\n if ((cb = 0) and (cg = 0)) or ((cb = 1) and (cg = 1)) then\n begin\n writeln('R');\n halt;\n end;\n if ((cr = 0) and (cb = 0)) or ((cr = 1) and (cb = 1)) then\n begin\n writeln('G');\n halt;\n end;\n if (cr = 1) then\n begin\n if (cg > 1) then writeln('BR') else writeln('GR');\n end\n else if (cg = 1) then\n begin\n if (cb > 1) then writeln('GR') else writeln('BG');\n end\n else\n begin\n if (cr > 1) then writeln('BG') else writeln('BR');\n end;\nend."}], "negative_code": [{"source_code": "var i,j,n,k,B,R,G:longint;q:char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(q);\n if q='B' then B:=1+b else\n if q='G' then g:=1+g else\n if q='R' then r:=1+r;\n END;\n k:=100*b+10*g+r;\n if k=111 then write('BGR') ELSE\n if k=110 then write('R') ELSE\n if k=101 then write('G') ELSE \n if k=11 then write('B') ELSE \n if k mod 100=0 then write('B') ELSE\n if r+b=0 then write('G') ELSE \n if b+g=0 then write('R') ELSE \n if r+b=1 then write('BR') ELSE \n if b+g=1 then write('BG') ELSE\n if r+G=1 then write('GR') ELSE \n write('BGR') ;\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\nnewdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\nxx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,aa,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nnext,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\ndd:matr;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\nza:array[-10..600,-10..600] of boolean;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n readln(ss);\n for i:=1 to n do\n begin\n if ss[i]='B' then inc(p1);\n if ss[i]='G' then inc(p2);\n if ss[i]='R' then inc(p3);\n\n end;\n if (p1>0)and(p2>0)and(p3>0) then begin write('BGR'); goto 1; end;\n if p1+p2=0 then begin write('R'); goto 1; end;\n if p1+p3=0 then begin write('G'); goto 1; end;\n if p3+p2=0 then begin write('B'); goto 1; end;\n\n if (p1=2)and(p2=1) then begin write('GR'); goto 1; end;\n if (p1=1)and(p2=2) then begin write('BR'); goto 1; end;\n\n\n if (p2=2)and(p3=1) then begin write('BR'); goto 1; end;\n if (p2=1)and(p3=2) then begin write('BG'); goto 1; end;\n\n if (p1=2)and(p3=1) then begin write('GR'); goto 1; end;\n if (p1=1)and(p3=2) then begin write('BG'); goto 1; end;\n\n write('BGR');\n\n\n\n\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program ProjectDCodeforces;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n k,i,j,n:integer;\n g,a,b,c,r,d,res:int64;\n s:char;\nbegin\n // Reset(Input,'input.txt');\n // Rewrite(Output,'output.txt');\n Readln(n);\n r:=0;\n b:=0;\n g:=0;\n for i:=1 to n do\n begin\n read(s);\n case s of\n 'R': Inc(r);\n 'G': Inc(g);\n 'B': Inc(b);\n end;\n end;\n\n if (r>=1)and(g>=1)and(b>=1)\n then write('BGR')\n else begin\n if (r=0)\n then begin\n if (b>=2)and(g=1)\n then write('GR');\n if (g>=2)and(b=1)\n then write('BR');\n if (b=1)and(g=1)\n then write('R');\n end;\n\n if (g=0)\n then begin\n if (b>=2)and(r=1)\n then write('GR');\n if (r>=2)and(b=1)\n then write('BG');\n if (b=1)and(r=1)\n then write('G');\n end;\n if (b=0)\n then begin\n if (r>=2)and(g=1)\n then write('BG');\n if (g>=2)and(r=1)\n then write('BR');\n if (g=1)and(r=1)\n then write('B');\n end;\n if (r>0)and(b=0)and(g=0)\n then write('R');\n if (G>0)and(r=0)and(b=0)\n then write('G');\n if (b>0)and(r=0)and(g=0)\n then write('B');\n end;\n\n\nend."}, {"source_code": "program ProjectDCodeforces;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n k,i,j,n:integer;\n g,a,b,c,r,d,res:int64;\n s:char;\nbegin\n// Reset(Input,'input.txt');\n// Rewrite(Output,'output.txt');\n Readln(n);\n r:=0;\n b:=0;\n g:=0;\n for i:=1 to n do\n begin\n read(s);\n case s of\n 'R': Inc(r);\n 'G': Inc(g);\n 'B': Inc(b);\n end;\n end;\n\n if (r>=1)and(g>=1)and(b>=1)\n then write('RGB')\n else begin\n if (r=0)\n then begin\n if (b>=2)and(g=1)\n then write('RG');\n if (g>=2)and(b=1)\n then write('RB');\n if (b=1)and(g=1)\n then write('R');\n end;\n\n if (g=0)\n then begin\n if (b>=2)and(r=1)\n then write('RG');\n if (r>=2)and(b=1)\n then write('BG');\n if (b=1)and(r=1)\n then write('G');\n end;\n if (b=0)\n then begin\n if (r>=2)and(g=1)\n then write('BG');\n if (g>=2)and(r=1)\n then write('RB');\n if (g=1)and(r=1)\n then write('B');\n end;\n if (r>0)and(b=0)and(g=0)\n then write('R');\n if (G>0)and(r=0)and(b=0)\n then write('G');\n if (b>0)and(r=0)and(g=0)\n then write('B');\n end;\n\n\nend."}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n // writeln(r, ' ', g, ' ', b);\n\n if (r>=1) and (g>=1) and (b>=1) then\n write('BGA')\n else if (r>=2) and (g>=1) and (b=0) then\n write('BGA')\n else if (r>=2) and (g=0) and (b>=1) then\n write('BGA')\n else if (r>=1) and (g>=2) and (b=0) then\n write('BGA')\n else if (r>=1) and (g=0) and (b>=2) then\n write('BGA')\n else if (r=0) and (g>=2) and (b>=1) then\n write('BGA')\n else if (r=0) and (g>=1) and (b>=2) then\n write('BGA')\n else if (r>=2) and (g=1) and (b=0) then\n write('GR')\n else if (r>=2) and (g=0) and (b=1) then\n write('BG')\n else if (r=0) and (g>=2) and (b=1) then\n write('BR')\n else if (r=1) and (g=1) and (b=0) then\n write('B')\n else if (r=1) and (g=0) and (b=1) then\n write('G')\n else if (r=0) and (g=1) and (b=1) then\n write('R')\n else if (r>=2) and (g=0) and (b=0) then\n write('R')\n else if (r=0) and (g>=2) and (b=0) then\n writeln('G')\n else if (r=0) and (g=0) and (b>=2) then\n writeln('B');\n\n\nEND."}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n if r>=1 then begin\n if r>=2 then begin\n if (b>=2) or (g>=2) then\n write('BGR')\n else if (b>=1) and (g=0) then\n write('BG')\n else if (b=0) and (g=1) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B')\n else if (b=0) and (g=0) then\n write('R');\n end\n end\n else if (b>=1) then begin\n if (b>=2) and (g>=1) then\n write('GR')\n else if(b=1) and (g>=2) then\n write('BR')\n else if (b=1) and (g=1) then\n write('R')\n else if g=0 then\n write('B');\n end\n else if g>=1 then\n write('G');\n\n\n\nEND.\n"}, {"source_code": "const\n SIZE=100000;\ntype\n TQ = array[1..3] of byte;\n\n\nvar\n q:array[1..SIZE, 1..3] of byte;\n qb, qe:longint;\n res_rd, res_gr, res_bl:boolean;\n i, n, j, k:longint;\n cl:array[1..3] of byte;\n\n\nProcedure push(r1, g1, b1:byte);\nBegin\n q[qe, 1]:=r1;\n q[qe, 2]:=g1;\n q[qe, 3]:=b1;\n\n if qe=SIZE then\n qe:=1\n else\n inc(qe);\nEnd;\n\nProcedure pop(var r1, g1, b1:byte);\nBegin\n r1:=q[qb, 1];\n g1:=q[qb, 2];\n b1:=q[qb, 3];\n\n if qb=SIZE then\n qb:=1\n else\n inc(qb);\nEnd;\n\nProcedure read_data;\nvar\n rdc, grc, blc:byte;\n c:char;\nBegin\n readln(n);\n rdc:=0; grc:=0; blc:=0;\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(rdc)\n else if c='G' then\n inc(grc)\n else\n inc(blc);\n end;\n\n res_rd:=false;\n res_gr:=false;\n res_bl:=false;\n\n qb:=1; qe:=1;\n push(rdc, grc, blc);\nEnd;\n\nFunction res_comb(r1, g1, b1:byte):boolean;\nBegin\n if r1+g1+b1=1 then begin\n if r1=1 then\n res_rd:=true\n else if g1=1 then\n res_gr:=true\n else\n res_bl:=true;\n\n res_comb:=true;\n end\n else\n res_comb:=false;\nEnd;\n\nBEGIN\n read_data;\n\n while qb<>qe do begin\n pop(cl[1], cl[2], cl[3]);\n\n if res_comb(cl[1], cl[2], cl[3])=false then begin\n for i:=1 to 3 do begin\n if cl[i]>=2 then begin\n j:=qe;\n push(cl[1], cl[2], cl[3]);\n dec(q[j, i]);\n end;\n if cl[i]>=1 then\n for k:=i+1 to 3 do\n if (cl[k]>=1) then begin\n j:=qe;\n push(cl[1], cl[2], cl[3]);\n inc(q[j, 6-i-k]);\n dec(q[j, k]);\n dec(q[j, i]);\n end;\n end;\n end;\n\n end;\n\n if res_bl then\n write('B');\n if res_gr then\n write('G');\n if res_rd then\n write('R');\n\nEND.\n"}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n if r>=1 then begin\n if r>=2 then begin\n if (b>=2) or (g>=2) then\n write('BGR')\n else if (b>=1) and (g=0) then\n write('BG')\n else if (b=0) and (g=1) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B')\n else if (b=0) and (g=0) then\n write('R');\n end\n end\n else if (b>=1) then begin\n if (b>=2) and (g>=2) then\n write('BGR')\n else if (b>=2) and (g>=1) then\n write('GR')\n else if(b=1) and (g>=2) then\n write('BR')\n else if (b=1) and (g=1) then\n write('R')\n else if g=0 then\n write('B');\n end\n else if g>=1 then\n write('G');\n\n\n\nEND.\n"}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n\n if r>=2 then begin\n if (b>=2) or (g>=2) then\n write('BGR')\n else if ((b>=1) and (g=0)) or ((b=0) and (g>=1)) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else if r>=1 then begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B');\n end\n else if (r=1) and (b=0) and (g=0) then\n write('R')\n else if (b=1) and (r=0) and (g=0) then\n write('B')\n else if (r=0) and (b=0) and (g=1) then\n write('G')\n else if (b>=2) then begin\n if g>=1 then\n write('GR')\n else if g=0 then\n write('B');\n end\n else if (b>=1) and (g>=2) then\n write('BR')\n else if (b=1) and (g=1) then\n write('R')\n else if g>=2 then\n write('G');\n\n\n\nEND.\n"}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n\n if r>=2 then begin\n if (b>=2) or (g>=2) then\n write('BGR')\n else if ((b>=1) and (g=0)) or ((b=0) and (g>=1)) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else if r>=1 then begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B')\n else if (b=0) and (g=0) then\n write('R');\n end\n else if (b>=1) then begin\n if (b>=2) and (g>=1) then\n write('GR')\n else if (b=1) and (g=1) then\n write('R')\n else if g=0 then\n write('B');\n end\n else if g>=1 then\n write('G');\n\n\n\nEND.\n"}, {"source_code": "var\nn,i,k,j:longint;\na,b:array[1..100] of longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n if a[1]*a[2]*a[3]>0 then begin write('BGR'); halt; end;\n for i:=1 to 3 do if a[i]=0 then begin inc(k); b[i]:=1; end;\n if k=1 then begin\n if b[1]=1 then begin\n if (a[2]>1) and (a[3]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[3]=1) then begin write('BR'); halt; end;\n if (a[2]=1) and (a[3]>1) then begin write('BG'); halt; end;\n if (a[2]=1) and (a[3]=1) then begin write('B'); halt; end;\n end;\n if b[2]=1 then begin\n if (a[3]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[3]>1) and (a[1]=1) then begin write('BG'); halt; end;\n if (a[3]=1) and (a[1]>1) then begin write('GR'); halt; end;\n if (a[3]=1) and (a[1]=1) then begin write('G'); halt; end;\n end;\n if b[3]=1 then begin\n if (a[2]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[1]=1) then begin write('GR'); halt; end;\n if (a[2]=1) and (a[1]>1) then begin write('RB'); halt; end;\n if (a[2]=1) and (a[1]=1) then begin write('R'); halt; end;\n end;\n end;\n if k=2 then begin\n for i:=1 to 3 do if b[i]=0 then begin\n if i=1 then begin write('B'); halt; end;\n if k=1 then begin write('G'); halt; end;\n if k=1 then begin write('R'); halt; end;\n end;\n end;\n end.\n\n\n"}, {"source_code": "var\nn,i,k,j:longint;\na,b:array[1..100] of longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\n//s:='RRRRR';\nfor i:=1 to n do begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n if a[1]*a[2]*a[3]>0 then begin write('BGR'); halt; end;\n for i:=1 to 3 do if a[i]=0 then begin inc(k); b[i]:=1; end;\n if k=1 then begin\n if b[1]=1 then begin\n if (a[2]>1) and (a[3]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[3]=1) then begin write('BR'); halt; end;\n if (a[2]=1) and (a[3]>1) then begin write('BG'); halt; end;\n if (a[2]=1) and (a[3]=1) then begin write('B'); halt; end;\n end;\n if b[2]=1 then begin\n if (a[3]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[3]>1) and (a[1]=1) then begin write('BG'); halt; end;\n if (a[3]=1) and (a[1]>1) then begin write('GR'); halt; end;\n if (a[3]=1) and (a[1]=1) then begin write('G'); halt; end;\n end;\n if b[3]=1 then begin\n if (a[2]>1) and (a[1]>1) then begin write('BGR'); halt; end;\n if (a[2]>1) and (a[1]=1) then begin write('GR'); halt; end;\n if (a[2]=1) and (a[1]>1) then begin write('BR'); halt; end;\n if (a[2]=1) and (a[1]=1) then begin write('R'); halt; end;\n end;\n end;\n if k=2 then begin\n for i:=1 to 3 do if b[i]=0 then begin\n if i=1 then begin write('B'); halt; end;\n if i=2 then begin write('G'); halt; end;\n if i=3 then begin write('R'); halt; end;\n end;\n end;\n end.\n\n\n"}, {"source_code": "var\ni,j,k,n,m,q,w,x,y:longint;\na:array[1..100] of longint;\ns:string;\nbegin\n readln(n);\n read(s);\n for i:=1 to n do\n begin\n if s[i]='R' then inc(a[1]);\n if s[i]='B' then inc(a[2]);\n if s[i]='G' then inc(a[3]);\n end;\n if (a[1]>=1) and (a[2]>=1) and (a[3]>=1) and (n>3) then write('BGR')\n else\n if a[1]=n then write('R')\n else\n if a[2]=n then write('B')\n else\n if a[3]=n then write('G')\n else\n if (a[1]=1) and (a[2]=1) then write('G')\n else\n if (a[1]=1) and (a[3]=1) then write('B')\n else\n if (a[2]=1) and (a[3]=1) then write('R')\n else\n if (a[1]=1) and (a[2]=1) and (a[3]=1) then write('BGR')\n else\n if (a[1]=1) and (a[2]=2) then write('GR')\n else\n if (a[1]=1) and (a[3]=2) then write('BR')\n else\n if (a[2]=1) and (a[1]=2) then write('BG')\n else\n if (a[2]=1) and (a[3]=2) then write('BR')\n else\n if (a[3]=1) and (a[1]=2) then write('BG')\n else\n if (a[3]=1) and (a[2]=2) then write('GR')\n else\n if (a[1]=3) and (a[2]=1) then write('BG')\n else\n if (a[1]=3) and (a[3]=1) then write('BG')\n else\n if (a[2]=3) and (a[1]=1) then write('GR')\n else\n if (a[2]=3) and (a[3]=1) then write('GR')\n else\n if (a[3]=3) and (a[1]=1) then write('BR')\n else\n if (a[3]=3) and (a[2]=1) then write('BR')\n else\n if (a[1]=0) and (a[2]>1) and (a[3]>1) then write('BGR')\n else\n if (a[2]=0) and (a[1]>1) and (a[3]>1) then write('BGR')\n else\n if (a[3]=0) and (a[1]>1) and (a[2]>1) then write('BGR');\n\nend."}, {"source_code": "var\ns:string;\nn,b,r,g:longint;\nbb,rr,gg:boolean;\nprocedure find( b,g,r:longint);\nvar\ns:longint;\nbegin\ns:=b+r+g;\nif s=2 then\n begin\n if b=2 then bb:=true else\n if r=2 then rr:=true else\n if g=2 then gg:=true else\n if b=0 then bb:=true else\n if g=0 then gg:=true else\n rr:=true;\n end\nelse\n begin\n if b>1 then find(b-1,g,r);\n if g>1 then find(b,g-1,r);\n if r>1 then find(b,g,r-1);\n if (b>0) and (g>0) then find(b-1,g-1,r+1);\n if (b>0) and (r>0) then find(b-1,g+1,r-1);\n if (r>0) and (g>0) then find(b+1,g-1,r-1);\n end;\nend;\n\nvar\ni:longint;\nbegin\nbb:=false;\ngg:=false;\nrr:=false;\nreadln(n);\nreadln(s);\nb:=0;\nr:=0;\ng:=0;\nfor i:=1 to n do\nbegin\nif s[i]='B' then inc(b) else\nif s[i]='G' then inc(g) else\ninc(r);\nend;\nfind(b,g,r);\nif bb then write('B');\nif gg then write('G');\nif rr then write('R');\nend.\n\n"}, {"source_code": "var\ns:string;\nn,b,r,g:longint;\nbb,rr,gg:boolean;\nprocedure find( b,g,r:longint);\nvar\ns:longint;\nbegin\ns:=b+r+g;\nif s=1 then\n begin\n if b=1 then bb:=true else\n if g=1 then gg:=true else\n rr:=true;\n end;\nif s=2 then\n begin\n if b=2 then bb:=true else\n if r=2 then rr:=true else\n if g=2 then gg:=true else\n if b=0 then bb:=true else\n if g=0 then gg:=true else\n rr:=true;\n end\nelse\n begin\n if b>1 then find(b-1,g,r);\n if g>1 then find(b,g-1,r);\n if r>1 then find(b,g,r-1);\n if (b>0) and (g>0) then find(b-1,g-1,r+1);\n if (b>0) and (r>0) then find(b-1,g+1,r-1);\n if (r>0) and (g>0) then find(b+1,g-1,r-1);\n end;\nend;\n\nvar\ni:longint;\nbegin\nbb:=false;\ngg:=false;\nrr:=false;\nreadln(n);\nreadln(s);\nb:=0;\nr:=0;\ng:=0;\nfor i:=1 to n do\nbegin\nif s[i]='B' then inc(b) else\nif s[i]='G' then inc(g) else\ninc(r);\nend;\n if (b=0) and (g=0) then begin writeln('R'); halt(0); end;\n if (r=0) and (g=0) then begin writeln('B'); halt(0); end;\n if (b=0) and (r=0) then begin writeln('G'); halt(0); end;\n if n>20 then\n begin\n writeln('BGR');\n halt(0);\n end;\nfind(b,g,r);\nif bb then write('B');\nif gg then write('G');\nif rr then write('R');\nend.\n\n"}, {"source_code": "\nvar\na,b,c,n,i,q:longint;\ns:string;\nbegin\nreadln(N);\nreadln(s);\nfor i:=1 to n do begin\nif s[i]='B'\nthen inc(A);\nif s[i]='G'\nthen inc(b);\nif s[i]='R'\nthen inc(c);\nend;\nif a>1\nthen inc(Q);\nif b>1\nthen inc(Q);\nif c>1\nthen inc(Q);\nif (Q>1) or ((a>0) and (b>0) and (c>0))\nthen begin writeln('BGR'); halt; end;\nif q=0\nthen begin\nif a+b+c=2\nthen begin\nif a=0\nthen writeln('B');\nif b=0\nthen writeln('G');\nif c=0\nthen writeln('R');\nend;\nif a+b+c=1\nthen begin\nif a=1\nthen writeln('B');\nif b=1\nthen writeln('G');\nif c=1\nthen writeln('R');\nend;\nend;\nif (a+b+c=a) or (a+b+c=b) or (a+b+c=c)\nthen begin\nif a+b+c=a\nthen writeln('B');\nif a+b+c=b\nthen writeln('G');\nif a+b+c=c\nthen writeln('R');\nhalt;\nend;\nif q=1\nthen begin\nif a>1\nthen writeln('GR');\nif b>1\nthen writeln('BR');\nif c>1\nthen writeln('BG');\nend;\nend.\n\n\n"}, {"source_code": "var\n so: string;\n\nfunction men1(st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n s: string[3];\n st1: string[200];\nbegin\n st1 := st;\n s := 'BGR';\n s1 := copy(st1, a, 1);\n s2 := copy(st1, b, 1);\n delete(st1, a, 1);\n delete(st1, b-1, 1);\n delete(s, pos(s1, s), 1);\n delete(s, pos(s2, s), 1);\n st1 := s + st1;\n men1 := st1\nend;\n\nfunction men2(st: string; a, b: integer): string;\nvar\n s: string[1];\n st1: string[200];\nbegin\n st1 := st;\n s := copy(st1, a, 1);\n delete(st1, a, 1);\n delete(st1, b-1, 1);\n st1 := s + st1;\n men2 := st1\nend;\n\nfunction meno(var st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\nbegin\n s1 := copy(st, a, 1);\n s2 := copy(st, b, 1);\n if s1 = s2 then\n meno := men2(st, a, b)\n else \n meno := men1(st, a, b)\nend;\n\nprocedure men(st: string);\nvar\n i, j: integer;\nbegin\n if length(st) >= 2 then\n begin\n for i := 1 to length(st)-1 do\n for j := i to length(st) do\n if i <> j then\n men(meno(st, i, j))\n end\n else\n if pos(st, so)=0 then\n so := so + st\nend;\n\nvar\n n: integer;\n st: string[200];\n\nbegin\n Readln(n);\n Readln(st);\n \n men(st);\n \n Writeln(so)\nend."}, {"source_code": "var\n so: string;\n pr: boolean;\n\nfunction prov(st: string): boolean;\nvar\n i, k: integer;\n s1: string[1];\nbegin\n k := 1;\n prov := true;\n s1 := copy(st, 1, 1);\n for i := 2 to length(st) do\n if s1 = copy(st, i, 1) then\n k := k + 1;\n if k = length(st) then\n prov := false\nend;\n\nfunction men1(st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n s: string[3];\n st1: string[205];\nbegin\n st1 := st;\n s := 'BGR';\n s1 := copy(st1, a, 1);\n s2 := copy(st1, b, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n delete(s, pos(s1, s), 1);\n delete(s, pos(s2, s), 1);\n st1 := s + st1;\n men1 := st1\nend;\n\nfunction men2(st: string; a, b: integer): string;\nvar\n s: string[1];\n st1: string[205];\nbegin\n st1 := st;\n s := copy(st1, a, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n st1 := s + st1;\n men2 := st1\nend;\n\nfunction meno(var st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n t: integer;\nbegin\n s1 := copy(st, a, 1);\n s2 := copy(st, b, 1);\n if a > b then\n begin\n t := a;\n a := b;\n b := t\n end;\n if s1 = s2 then\n meno := men2(st, a, b)\n else \n meno := men1(st, a, b)\nend;\n\nprocedure men(st: string);\nvar\n i, j, a1, b1, c1, a2, b2, c2: integer;\n si, sa, sb, sc: string[205];\n pr1: boolean;\nbegin\n pr1 := prov(st);\n if (length(st) >= 2) and pr and pr1 then\n begin\n a1 := pos('B', st);\n sa := copy(st, a1 + 1, length(st));\n a2 := pos('B', sa) + a1;\n b1 := pos('G', st);\n sb := copy(st, b1 + 1, length(st));\n b2 := pos('G', sb) + b1;\n c1 := pos('R', st);\n sc := copy(st, c1 + 1, length(st));\n c2 := pos('R', sc) + c1;\n \n if ((a1 = 0) and (b1 <> 0) and (c1 <> 0)) then\n men(meno(st, b1, c1))\n else\n if ((b1 = 0) and (a1 <> 0) and (c1 <> 0)) then\n men(meno(st, a1, c1))\n else\n if ((c1 = 0) and (b1 <> 0) and (a1 <> 0)) then\n men(meno(st, a1, b1))\n else\n if ((a1 <> 0) and (b1 <> 0) and (c1 <> 0)) then\n begin\n men(meno(st, a1, b1));\n men(meno(st, c1, b1));\n men(meno(st, a1, c1))\n end;\n \n if (a1 <> 0) and (a2 <> a1) then\n men(meno(st, a1, a2));\n if (b1 > 0) and (b2 > b1) then\n men(meno(st, b1, b2));\n if (c1 <> 0) and (c2 <> c1) then\n men(meno(st, c1, c2));\n end\n else\n if pos(st, so) = 0 then\n so := so + st\n else\n if (not pr1) then\n men(copy(st, 1, 1));\n if length(so) = 3 then\n pr := false;\n \n \nend;\n\nvar\n n: integer;\n st: string[205];\n so1: string[3];\n a, b, c, i: integer;\n\nbegin\n Readln(n);\n Readln(st);\n \n a := 0;\n b := 0;\n c := 0;\n pr := true;\n for i := 1 to length(st) do\n begin\n if copy(st, i, 1) = 'B' then\n a := a + 1;\n if copy(st, i, 1) = 'G' then\n b := b + 1;\n if copy(st, i, 1) = 'R' then\n c := c + 1;\n end;\n st := '';\n if a <> 0 then\n if a mod 2 = 1 then\n st := st + 'B'\n else\n st := st + 'BB';\n if b <> 0 then\n if b mod 2 = 1 then\n st := st + 'G'\n else\n st := st + 'GG';\n if c <> 0 then\n if c mod 2 = 1 then\n st := st + 'R'\n else\n st := st + 'RR';\n men(st);\n so1 := '';\n \n if pos('B', so) <> 0 then\n so1 := 'B';\n if pos('G', so) <> 0 then\n so1 := so1 + 'G';\n if pos('R', so) <> 0 then\n so1 := so1 + 'R';\n \n Writeln(so1)\nend."}, {"source_code": "var\n so: string;\n pr: boolean;\n\nfunction prov(st: string): boolean;\nvar\n i, k: integer;\n s1: string[1];\nbegin\n k := 1;\n prov := true;\n s1 := copy(st, 1, 1);\n for i := 2 to length(st) do\n if s1 = copy(st, i, 1) then\n k := k + 1;\n if k = length(st) then\n prov := false\nend;\n\nfunction men1(st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n s: string[3];\n st1: string[205];\nbegin\n st1 := st;\n s := 'BGR';\n s1 := copy(st1, a, 1);\n s2 := copy(st1, b, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n delete(s, pos(s1, s), 1);\n delete(s, pos(s2, s), 1);\n st1 := s + st1;\n men1 := st1\nend;\n\nfunction men2(st: string; a, b: integer): string;\nvar\n s: string[1];\n st1: string[205];\nbegin\n st1 := st;\n s := copy(st1, a, 1);\n delete(st1, a, 1);\n delete(st1, b - 1, 1);\n st1 := s + st1;\n men2 := st1\nend;\n\nfunction meno(var st: string; a, b: integer): string;\nvar\n s1, s2: string[1];\n t: integer;\nbegin\n s1 := copy(st, a, 1);\n s2 := copy(st, b, 1);\n if a > b then\n begin\n t := a;\n a := b;\n b := t\n end;\n if s1 = s2 then\n meno := men2(st, a, b)\n else \n meno := men1(st, a, b)\nend;\n\nprocedure men(st: string);\nvar\n i, j, a1, b1, c1, a2, b2, c2: integer;\n si, sa, sb, sc: string[205];\n pr1: boolean;\nbegin\npr1:=true;\nif length(st)>50 then\n pr1 := prov(st);\n if (length(st) >= 2) and pr and pr1 then\n begin\n a1 := pos('B', st);\n sa := copy(st, a1 + 1, length(st));\n a2 := pos('B', sa) + a1;\n b1 := pos('G', st);\n sb := copy(st, b1 + 1, length(st));\n b2 := pos('G', sb) + b1;\n c1 := pos('R', st);\n sc := copy(st, c1 + 1, length(st));\n c2 := pos('R', sc) + c1;\n \n if ((a1 = 0) and (b1 <> 0) and (c1 <> 0)) then\n men(meno(st, b1, c1))\n else\n if ((b1 = 0) and (a1 <> 0) and (c1 <> 0)) then\n men(meno(st, a1, c1))\n else\n if ((c1 = 0) and (b1 <> 0) and (a1 <> 0)) then\n men(meno(st, a1, b1))\n else\n if ((a1 <> 0) and (b1 <> 0) and (c1 <> 0)) then\n begin\n men(meno(st, a1, b1));\n men(meno(st, c1, b1));\n men(meno(st, a1, c1))\n end;\n \n if (a1 <> 0) and (a2 <> a1) then\n men(meno(st, a1, a2));\n if (b1 > 0) and (b2 > b1) then\n men(meno(st, b1, b2));\n if (c1 <> 0) and (c2 <> c1) then\n men(meno(st, c1, c2));\n end\n else\n if pos(st, so) = 0 then\n so := so + st\n else\n if (not pr1) then\n men(copy(st, 1, 1));\n if length(so) = 3 then\n pr := false;\n \n \nend;\n\nvar\n n: integer;\n st: string[205];\n so1: string[3];\n a, b, c, i: integer;\n\nbegin\n Readln(n);\n Readln(st);\n \n a := 0;\n b := 0;\n c := 0;\n pr := true;\n if n>40 then\n begin\n for i := 1 to length(st) do\n begin\n if copy(st, i, 1) = 'B' then\n a := a + 1;\n if copy(st, i, 1) = 'G' then\n b := b + 1;\n if copy(st, i, 1) = 'R' then\n c := c + 1;\n end;\n st := '';\n if a <> 0 then\n if a mod 2 = 1 then\n st := st + 'B'\n else\n st := st + 'BB';\n if b <> 0 then\n if b mod 2 = 1 then\n st := st + 'G'\n else\n st := st + 'GG';\n if c <> 0 then\n if c mod 2 = 1 then\n st := st + 'R'\n else\n st := st + 'RR'\n end;\n men(st);\n so1 := '';\n \n if pos('B', so) <> 0 then\n so1 := 'B';\n if pos('G', so) <> 0 then\n so1 := so1 + 'G';\n if pos('R', so) <> 0 then\n so1 := so1 + 'R';\n \n Writeln(so1)\nend."}, {"source_code": "var s,st,dop,dkl:string;\noch:array[1..50000]of string;\np1,p2,i,j,kl,kol,n,n2:longint;\n\nprocedure put(x:string);\nbegin\n p2:=p2+1;\n och[p2]:=x;\nend;\n\nprocedure get(var x:string);\nbegin\n x:=och[p1];\n p1:=p1+1;\nend;\n\nbegin\n readln(n);\n readln(st);\n p1:=1;\n put(st);\n while p1<=p2 do\n begin\n get(s);\n n:=length(s);\n for i:=1 to n-1 do\n begin\n kl:=0;\n for j:=i+1 to n do\n if (s[i]=s[j]) and (kl=0) then\n begin\n dop:=s;\n delete(dop,i,1);\n delete(dop,j-1,1);\n dop:=dop+s[i];\n n2:=length(dop);\n if (n2=1)\n and (pos(dop,dkl)=0) then begin\n kol:=kol+1;\n dkl:=dkl+dop;\n end\n else if n2<>1 then put(dop);\n kl:=1;\n end\n else if s[i]<>s[j]\n then\n begin\n dop:=s;\n delete(dop,i,1);\n delete(dop,j-1,1);\n if ((s[i]='B') and (s[j]='G')) or ((s[i]='G') and (s[j]='B')) then dop:=dop+'R'\n else if ((s[i]='B') and (s[j]='R')) or ((s[i]='R') and (s[j]='B')) then dop:=dop+'G'\n else if ((s[i]='G') and (s[j]='R')) or ((s[i]='R') and (s[j]='G')) then dop:=dop+'B';\n n2:=length(dop);\n if (n2=1) and (pos(dop,dkl)=0) then begin\n kol:=kol+1;\n dkl:=dkl+dop;\n end\n else if n2<>1 then put(dop);\n end;\n end;\n end;\n writeln(dkl);\nend."}, {"source_code": "var s,st,dop,dkl:string;\nmax:char;\noch:array[1..50000]of string;\np1,p2,i,nmax,j,kl,kol,n,n2:longint;\n\nprocedure put(x:string);\nbegin\n p2:=p2+1;\n och[p2]:=x;\nend;\n\nprocedure get(var x:string);\nbegin\n x:=och[p1];\n p1:=p1+1;\nend;\n\nbegin\n readln(n);\n readln(st);\n p1:=1;\n put(st);\n while p1<=p2 do\n begin\n get(s);\n n:=length(s);\n for i:=1 to n-1 do\n begin\n kl:=0;\n for j:=i+1 to n do\n if (s[i]=s[j]) and (kl=0) then\n begin\n dop:=s;\n delete(dop,i,1);\n delete(dop,j-1,1);\n dop:=dop+s[i];\n n2:=length(dop);\n if (n2=1)\n and (pos(dop,dkl)=0) then begin\n kol:=kol+1;\n dkl:=dkl+dop;\n end\n else if n2<>1 then put(dop);\n kl:=1;\n end\n else if s[i]<>s[j]\n then\n begin\n dop:=s;\n delete(dop,i,1);\n delete(dop,j-1,1);\n if ((s[i]='B') and (s[j]='G')) or ((s[i]='G') and (s[j]='B')) then dop:=dop+'R'\n else if ((s[i]='B') and (s[j]='R')) or ((s[i]='R') and (s[j]='B')) then dop:=dop+'G'\n else if ((s[i]='G') and (s[j]='R')) or ((s[i]='R') and (s[j]='G')) then dop:=dop+'B';\n n2:=length(dop);\n if (n2=1) and (pos(dop,dkl)=0) then begin\n kol:=kol+1;\n dkl:=dkl+dop;\n end\n else if n2<>1 then put(dop);\n end;\n end;\n end;\n n:=length(dkl);\n for i:=1 to n-1 do\n begin\n max:=dkl[i];\n nmax:=i;\n for j:=1 to n do\n if dkl[j]=1) and (g>=1) then rek(r-1,g-1,b+1,n-1);\n if (r>=1) and (b>=1) then rek(r-1,g+1,b-1,n-1);\n if r>=2 then rek(r-1,g,b,n-1);\n if (g>=1) and (b>=1) then rek(r+1,g-1,b-1,n-1);\n if g>=2 then rek(r,g-1,b,n-1);\n if b>=2 then rek(r,g,b-1,n-1);\n if n=1 then begin\n if r=1 then begin\n p:=pos('R',st2);\n if p=0 then st2:=st2+'R';\n end;\n if g=1 then begin\n p:=pos('G',st2);\n if p=0 then st2:=st2+'G';\n end;\n if b=1 then begin\n p:=pos('B',st2);\n if p=0 then st2:=st2+'B';\n end;\n end;\n end;\nbegin\n\n readln(n);\n readln(st);\n for i:=1 to n do\n begin\n if st[i]='R' then r:=r+1;\n if st[i]='G' then g:=g+1;\n if st[i]='B' then b:=b+1;\n end;\n rek(r,g,b,n);\n writeln(st2);\nend."}, {"source_code": "var st,c,st1,s:string;\np1,p2,i,n,k,p,k1:longint;\nbegin\n readln(n);\n readln(st);\n n:=length(st);\n c:='RGB';\n while true do\n begin\n\n if st[1]=st[2] then begin\n delete(st,1,1);\n st1:=st1+st[1];\n k:=k+1;\n end\n else if st[1]<>st[2] then begin\n p1:=pos(st[1],c);\n p2:=pos(st[2],c);\n for i:=1 to 3 do\n if (i<>p1) and (i<>p2) then begin\n delete(st,1,2);\n st:=st+c[i];\n st1:=st1+c[i];\n k:=k+1;\n break;\n end;\n end;\n n:=length(st);\n if n<=1 then break;\n end;\n for i:=1 to k do\n begin\n p:=pos(st1[i],s);\n if p=0 then begin\n s:=s+st1[i];\n k1:=k1+1;\n end;\n if k1=3 then break;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var st,c,st1,s:string;\np1,p2,i,n,k,p,k1,nmax,j:longint;\nmax,dop:char;\nbegin\n readln(n);\n readln(st);\n n:=length(st);\n c:='RGB';\n while true do\n begin\n\n if st[1]=st[2] then begin\n delete(st,1,1);\n st1:=st1+st[1];\n k:=k+1;\n end\n else if st[1]<>st[2] then begin\n p1:=pos(st[1],c);\n p2:=pos(st[2],c);\n for i:=1 to 3 do\n if (i<>p1) and (i<>p2) then begin\n delete(st,1,2);\n st:=st+c[i];\n st1:=st1+c[i];\n k:=k+1;\n break;\n end;\n end;\n n:=length(st);\n if n<=1 then break;\n end;\n\n for i:=1 to k do\n begin\n p:=pos(st1[i],s);\n if p=0 then begin\n s:=s+st1[i];\n k1:=k1+1;\n end;\n if k1=3 then break;\n end;\n if k1>1 then begin\n for i:=1 to k1-1 do\n begin\n max:=s[i];\n nmax:=i;\n for j:=i+1 to n do\n if max>s[j] then begin\n max:=s[j];\n nmax:=j;\n end;\n dop:=s[i];\n s[i]:=max;\n s[nmax]:=dop;\n end;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var st,c,st1,s:string;\np1,p2,i,n,k,p,k1,nmax,j:longint;\nmax,dop:char;\nbegin\n readln(n);\n readln(st);\n n:=length(st);\n c:='RGB';\n while true do\n begin\n\n if st[1]=st[2] then begin\n delete(st,1,1);\n st1:=st1+st[1];\n k:=k+1;\n end\n else if st[1]<>st[2] then begin\n p1:=pos(st[1],c);\n p2:=pos(st[2],c);\n for i:=1 to 3 do\n if (i<>p1) and (i<>p2) then begin\n delete(st,1,2);\n st:=st+c[i];\n st1:=st1+c[i];\n k:=k+1;\n break;\n end;\n end;\n n:=length(st);\n if n<=1 then break;\n end;\n for i:=1 to k do\n begin\n p:=pos(st1[i],s);\n if p=0 then begin\n s:=s+st1[i];\n k1:=k1+1;\n end;\n if k1=3 then break;\n end;\n if k1>1 then begin\n for i:=1 to k1-1 do\n begin\n max:=s[i];\n nmax:=i;\n for j:=i+1 to n do\n if max>s[j] then begin\n max:=s[j];\n nmax:=j;\n end;\n dop:=s[i];\n s[i]:=max;\n s[nmax]:=dop;\n end;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var st:string;\nn,i,r,g,b:longint;\nbegin\n readln(n);\n readln(st);\n for i:=1 to n do\n if st[i]='R' then r:=r+1\n else if st[i]='G' then g:=g+1\n else b:=b+1;\n\n\n if ((r=1) and (g=1) and (b=0)) or\n ((r=0) and (g=0)) then begin\n writeln('B');\n halt;\n end\n else if ((b=1) and (g=1) and (r=0)) or\n ((b=0) and (g=0)) then begin\n writeln('R');\n halt;\n end\n else if ((b=1) and (r=1) and (g=0)) or\n ((b=0) and (r=0)) then begin\n writeln('G');\n halt;\n end;\n\n if ((g=0) and (r>=2) and (b>=2)) or\n ((b=0) and (r>=2) and (g>=2)) or\n ((r=0) and (b>=2) and (g>=2)) or\n ((r>0) and (b>0) and (r>0)) then begin\n writeln('BGR');\n halt;\n end;\n if (g=1) and (r=0) and (b>1) then begin\n writeln('GR');\n halt;\n end;\n if (g=1) and (r>1) and (b=0) then begin\n writeln('BG');\n halt;\n end;\n if (r=1) and (g=0) and (b>1) then begin\n writeln('GR');\n halt;\n end;\n if (r=1) and (b=0) and (g>1) then begin\n writeln('BR');\n halt;\n end;\n if (b=1) and (g=0) and (r>1) then begin\n writeln('BG');\n halt;\n end;\n if (b=1) and (g>1) and (r=0) then begin\n writeln('BR');\n halt;\n end;\nend."}, {"source_code": "var\n a, c, r, g, b, i: int64;\n ar: array [1..1000] of char;\n q1, q2, q3: boolean;\n \nprocedure rek(a, r, g, b: int64);\nbegin\n if a = 1 then begin\n if r = 1 then q1 := true;\n if g = 1 then q2 := true;\n if b = 1 then q3 := true;\n exit;\n end;\n if b > 1 then rek(a - 1, r, g, b - 1);\n if (b > 0) and (r > 0) then rek(a - 1, r - 1, g + 1, b - 1);\n if (b > 0) and (g > 0) then rek(a - 1, r + 1, b - 1, g - 1);\n if r > 1 then rek(a - 1, r - 1, g, b);\n if (r > 0) and (g > 0) then rek(a - 1, r - 1, g - 1, b + 1);\n if g > 1 then rek(a - 1, r, g - 1, b);\nend;\n \nbegin\n readln(a);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n if ar[i] = 'R' then inc(r);\n if ar[i] = 'G' then inc(g);\n if ar[i] = 'B' then inc(b);\n inc(i);\n end;\n if (r > 0) and (g > 0) and (b > 0) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r >= 2) and (g >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r >= 2) and (b >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (g >= 2) and (b >= 2) then begin\n q1 := true;\n q2 := true;\n q3 := true;\n end\n else if (r = 1) and (g > 1) then begin\n q1 := true;\n q3 := true;\n end\n else if (r = 1) and (b > 1) then begin\n q1 := true;\n q2 := true;\n end\n else if (g = 1) and (r > 1) then begin\n q2 := true;\n q3 := true;\n end\n else if (g = 1) and (b > 1) then begin\n q2 := true;\n q1 := true;\n end\n else if (b = 1) and (r > 1) then begin\n q3 := true;\n q2 := true;\n end\n else if (b = 1) and (g > 1) then begin\n q3 := true;\n q1 := true;\n end\n else if (r = 1) and (g = 1) then q3 := true\n else if (r = 1) and (b = 1) then q2 := true\n else if (g = 1) and (b = 1) then q1 := true\n else if (r > 0) then q1 := true\n else if (g > 0) then q2 := true\n else if (b > 0) then q3 := true;\n if q3 then write('B');\n if q1 then write('R');\n if q2 then write('G');\nend."}, {"source_code": "var\n a, c, r, g, b, i: int64;\n ar: array [1..1000] of char;\n q1, q2, q3: boolean;\n \nprocedure rek(a, r, g, b: int64);\nbegin\n if a = 1 then begin\n if r = 1 then q1 := true;\n if g = 1 then q2 := true;\n if b = 1 then q3 := true;\n exit;\n end;\n if b > 1 then rek(a - 1, r, g, b - 1);\n if (b > 0) and (r > 0) then rek(a - 1, r - 1, g + 1, b - 1);\n if (b > 0) and (g > 0) then rek(a - 1, r + 1, b - 1, g - 1);\n if r > 1 then rek(a - 1, r - 1, g, b);\n if (r > 0) and (g > 0) then rek(a - 1, r - 1, g - 1, b + 1);\n if g > 1 then rek(a - 1, r, g - 1, b);\nend;\n \nbegin\n readln(a);\n i := 1;\n while i <= a do begin\n read(ar[i]);\n if ar[i] = 'R' then inc(r);\n if ar[i] = 'G' then inc(g);\n if ar[i] = 'B' then inc(b);\n inc(i);\n end;\n rek(a, r, g, b);\n if q1 then write('R');\n if q2 then write('G');\n if q3 then write('B');\nend."}, {"source_code": "var i,n,j,x,y,t,kol,R,B,G:longint;\ns,sn:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s) do\nbegin\nif (s[i]='R') then inc(r);\nif (s[i]='B') then inc(b);\nif (s[i]='G') then inc(g);\nend;\n\n\nif (R>0)and(B>0)and(g>0) then\nbegin\nwriteln('BGR');\nhalt;\nend;\n\nif ((r>1)and(b>1))or\n ((r>1)and(g>1))or\n ((g>1)and(b>1)) then\nbegin\nwriteln('BGR');\nhalt;\nend;\n\nif (r>1)and(b=1) then writeln('BG') else\nif (r=1)and(b>1) then writeln('GR') else\nif (r=1)and(b=1) then writeln('G') else\n\nif (r>1)and(g=1) then writeln('BG') else\nif (r=1)and(g>1) then writeln('BR') else\nif (r=1)and(g=1) then writeln('B') else\n\nif (g>1)and(b=1) then writeln('BR') else\nif (g=1)and(b>1) then writeln('GR') else\nif (g=1)and(b=1) then writeln('R') else\nif (g>1) then writelN('G') else\nif (b>1) then writeln('B') else\nif (r>1) then writeln('R');\n\n\n\nend."}, {"source_code": "var i,n,r,g,b:longint;\n c:char;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(c);\n case c of\n 'R':inc(r);\n 'G':inc(g);\n 'B':inc(b);\n end end;\nif ((r>0)and(g>0)and(b>0))or((r>1)and(g>1)or(r>1)and(b>1)or(b>1)and(g>1))then write('RGB') else\n if (r=0)and(g=0) then write('B') else\n if (r=0)and(b=0) then write('G') else\n if (g=0)and(b=0) then write('R') else\n if (r>1) then write('GB') else\n if (g>1) then write('RB') else\n if (b>1) then write('RG') else\n if n=2 then if g=0 then write('G') else if b=0 then write('B') else write('R');\nend.\n"}, {"source_code": "var r, g, b, n, i, j, t:longint;\ns:string;\na:array[1..3] of longint;\nbegin\n readln(n);\n read(s);\n r := 0; b := 0; g := 0;\n for i := 1 to n do begin\n if s[i] = 'R' then r := r + 1;\n if s[i] = 'G' then g := g + 1;\n if s[i] = 'B' then b := b + 1;\n end;\n if r > 3 then r := 2;\n if g > 3 then g := 2;\n if b > 3 then b := 2;\n a[1] := r; a[2] := g; a[3] := b;\n for i := 1 to 3 do for j := 1 to 3 do if (a[i] < a[j]) and (i > j) then begin t := a[i]; a[i] := a[j]; a[j] := t; end;\n //writeln(a[1], ' ', a[2], ' ', a[3]);\n if a[1] > 1 then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 2) then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 2) then begin\n if (b = 1) or (b = 0) then write('B'); if (g = 1) or (g = 0) then write('G'); if (r = 1) or (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 1) then begin\n if (b = 0) then write('B'); if (g = 0) then write('G'); if (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 0) and (a[3] > 0) then begin\n if b > 0 then write('B'); if g > 0 then write('G'); if r > 0 then write('R');\n exit;\n end;\nend."}, {"source_code": "var r, g, b, n, i, j, t:longint;\ns:string;\na:array[1..3] of longint;\nbegin\n readln(n);\n read(s);\n r := 0; b := 0; g := 0;\n for i := 1 to n do begin\n if s[i] = 'R' then r := r + 1;\n if s[i] = 'G' then g := g + 1;\n if s[i] = 'B' then b := b + 1;\n end;\n if r > 3 then r := 2;\n if g > 3 then g := 2;\n if b > 3 then b := 2;\n a[1] := r; a[2] := g; a[3] := b;\n for i := 1 to 3 do for j := 1 to 3 do if (a[i] < a[j]) and (i > j) then begin t := a[i]; a[i] := a[j]; a[j] := t; end;\n //writeln(a[1], ' ', a[2], ' ', a[3]);\n if a[1] > 1 then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 2) then begin\n writeln('BGR');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 2) then begin\n if (b = 1) or (b = 0) then write('B'); if (g = 1) or (g = 0) then write('G'); if (r = 1) or (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 1) and (a[3] = 1) then begin\n if (b = 0) then write('B'); if (g = 0) then write('G'); if (r = 0) then write('R');\n exit;\n end;\n if (a[1] = 0) and (a[2] = 0) and (a[3] > 0) then begin\n if b > 0 then write('B'); if g > 0 then write('B'); if r > 0 then write('B');\n exit;\n end;\nend."}, {"source_code": "program z1;\nvar s,res:ansistring;\nn,a,b,c,i,k:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='B' then inc(a);\n if s[i]='G' then inc(b);\n if s[i]='R' then inc(c);\n if ((a>0) and (b>0) and (c>0)) or ((a>1) and (b>1)) or ((a>1) and (c>1)) or ((b>1) and (c>1)) then begin\n write('BGR');\n halt\n end\n end;\nif (a=0) and (b=0) then begin\n write('R');\n halt\n end;\nif (a=0) and (c=0) then begin\n write('G');\n halt\n end;\nif (c=0) and (b=0) then begin\n write('B');\n halt\n end;\nif a=1 then begin\n if b<>0 then write('BR')\n else write('BG');\n halt\n end;\nif b=1 then begin\n if c<>0 then write('BG')\n else write('GR');\n halt\n end;\nif c=1 then begin\n if b<>0 then write('BK')\n else write('GR');\n halt\n end;\nend."}, {"source_code": "program z1;\nvar s,res:ansistring;\nn,a,b,c,i,k:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='B' then inc(a);\n if s[i]='G' then inc(b);\n if s[i]='R' then inc(c);\n if ((a>0) and (b>0) and (c>0)) or ((a>1) and (b>1)) or ((a>1) and (c>1)) or ((b>1) and (c>1)) then begin\n write('BGR');\n halt\n end\n end;\nif (a=0) and (b=0) then begin\n write('R');\n halt\n end;\nif (a=0) and (c=0) then begin\n write('G');\n halt\n end;\nif (c=0) and (b=0) then begin\n write('B');\n halt\n end;\nif (a=1) and (b=1) then begin\n write('R');\n halt\n end;\nif (a=1) and (c=1) then begin\n write('G');\n halt\n end;\nif (c=1) and (b=1) then begin\n write('B');\n halt\n end;\nif a=1 then begin\n if b<>0 then write('BR')\n else write('BG');\n halt\n end;\nif b=1 then begin\n if c<>0 then write('BG')\n else write('GR');\n halt\n end;\nif c=1 then begin\n if b<>0 then write('BG')\n else write('GR');\n halt\n end;\nEnd."}, {"source_code": "Program Buntarik;\nvar n,a,b,c,i:longint;\ns:string;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nif s[i]='B'\nthen inc(a)\nelse if s[i]='R'\nthen inc(b)\nelse inc(c);\nif n=1\nthen begin writeln(s); halt; end;\n\nif (a>1)and(b>1)and(c>1)or(a>2)and(b>2)or(c>2)and(b>2)or(a>2)and(c>2)\nthen writeln('GBR')\nelse\nif (a>1)and(b=1)and(c=0)or(a>1)and(b=0)and(c=1)\nthen writeln('GR')\nelse\nif (a=1)and(b>1)and(c=0)or(a=0)and(b>1)and(c=0)\nthen writeln('BG')\nelse\nif (a=1)and(b=0)and(c>1)or(a=0)and(b=1)and(c>1)\nthen writeln('BR')\nelse if (a>1)and(b=0)and(c=0)or(a=0)and(b=1)and(c=1)\nthen writeln('B')\nelse if (a=0)and(b>1)and(c=0)or(a=1)and(b=0)and(c=1)\nthen writeln('R')\nelse if (a=0)and(b=0)and(c>1)or(a=1)and(b=1)and(c=0)\nthen writeln('G');\n\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "Program Buntarik;\nvar n,a,b,c,i:longint;\ns:string;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nif s[i]='B'\nthen inc(a)\nelse if s[i]='R'\nthen inc(b)\nelse inc(c);\nif n=1\nthen begin writeln(s); halt; end;\n\nif (a>0)and(b>0)and(c>0)or(a>1)and(b>1)or(c>1)and(b>1)or(a>1)and(c>1)\nthen writeln('BGR')\nelse\nif (a>1)and(b=1)and(c=0)or(a>1)and(b=0)and(c=1)\nthen writeln('GR')\nelse\nif (a=1)and(b>1)and(c=0)or(a=0)and(b>1)and(c=0)\nthen writeln('BG')\nelse\nif (a=1)and(b=0)and(c>1)or(a=0)and(b=1)and(c>1)\nthen writeln('BR')\nelse if (a>1)and(b=0)and(c=0)or(a=0)and(b=1)and(c=1)\nthen writeln('B')\nelse if (a=0)and(b>1)and(c=0)or(a=1)and(b=0)and(c=1)\nthen writeln('R')\nelse if (a=0)and(b=0)and(c>1)or(a=1)and(b=1)and(c=0)\nthen writeln('G');\n\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "Program Buntarik;\nvar n,a,b,c,i:longint;\ns:string;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\n\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nif s[i]='B'\nthen inc(a)\nelse if s[i]='R'\nthen inc(b)\nelse inc(c);\nif n=1\nthen begin writeln(s); halt; end;\n\nif (a>1)and(b>1)and(c>1)or(a>2)and(b>2)or(c>2)and(b>2)or(a>2)and(c>2)\nthen writeln('BGR')\nelse\nif (a>1)and(b=1)and(c=0)or(a>1)and(b=0)and(c=1)\nthen writeln('GR')\nelse\nif (a=1)and(b>1)and(c=0)or(a=0)and(b>1)and(c=0)\nthen writeln('BG')\nelse\nif (a=1)and(b=0)and(c>1)or(a=0)and(b=1)and(c>1)\nthen writeln('BR')\nelse if (a>1)and(b=0)and(c=0)or(a=0)and(b=1)and(c=1)\nthen writeln('B')\nelse if (a=0)and(b>1)and(c=0)or(a=1)and(b=0)and(c=1)\nthen writeln('R')\nelse if (a=0)and(b=0)and(c>1)or(a=1)and(b=1)and(c=0)\nthen writeln('G');\n\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "var\n N,i,B,R,G:longint;\n ch:char;\n f:boolean;\n \nbegin\n readln(n);\n b:=0;\n r:=0;\n g:=0;\n \n for i:=1 to N do begin\n read(ch);\n if(ch='B') then inc(b);\n if(ch='R') then inc(r);\n if(ch='G') then inc(g);\n end;\n \n \n if(r>=2)and(g>=2)or(r>=2)and(b>=2)and(g>=2)and(b>=2)or(b*r*g<>0) then write('BGR')\n else begin\n f:=true;\n if(g=1)and(b>=2)and(f) then begin write('GR');f:=false;end;\n if(g=1)and(r>=2)and(f) then begin write('BG');f:=false;end;\n if(r=1)and(b>=2)and(f) then begin write('GR');f:=false;end;\n if(r=1)and(g>=2)and(f) then begin write('BR');f:=false;end;\n if(b=1)and(r>=2)and(f) then begin write('BR');f:=false;end;\n if(b=1)and(g>=2)and(f) then begin write('BG');f:=false;end;\n \n if(b>0)and(r>0)and(f) then write('G');\n if(b>0)and(g>0)and(f) then write('R');\n if(r>0)and(g>0)and(f) then write('B');\n\n if(b=n) then write('B');\n if(r=n) then write('R');\n if(g=n) then write('G');\n end;\n \nend. \n"}, {"source_code": "var\n s : ansistring;\n n,r,b,g,i : longint;\n\n function chk(x,y,z : longint) : boolean;\n begin\n if (x > 0) and (y > 0) and (z > 0) then exit(true);\n if (y+z = 0) then exit(true);\n if (x = 0) then begin\n if (y > 0) and (z > 0) then exit(true);\n end;\n if (y = 0) then begin\n if (x > 0) and (z > 1) then exit(true);\n end;\n if (z = 0) then begin\n if (x > 0) and (y > 1) then exit(true);\n end;\n exit(false);\n end;\n\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n if s[i] = 'R' then inc(r);\n if s[i] = 'G' then inc(g);\n if s[i] = 'B' then inc(b);\n end;\n if chk(r,g,b) then write('R');\n if chk(g,r,b) then write('G');\n if chk(b,r,g) then write('B');\n writeln;\nend."}, {"source_code": "{$mode objfpc}\nCONST\n ip = '';//'card.inp';\n op = '';//'card.out';\nVAR\n n : LongInt;\n b,g,r : LongInt;\n s,t : AnsiString;\n\n\nprocedure INPUT;\nvar\n f : Text;\nbegin\n assign(f,ip); reset(f);\n readln(f,n);\n readln(f,s);\n close(f);\nend;\n\n\nfunction check(a,b,c : LongInt) :BooLean;\nbegin\n if (a >= 1) and (b < 1) and (c < 1) then exit(true);\n if (a >= 1) and ((b >1) or (c > 1)) then exit(true);\n if (a = 0) and (b >= 1) and (c >= 1) then exit(true);\n exit(false);\nend;\n\n\nprocedure SOLVE;\nvar\n i,j : Longint;\nbegin\n for i := 1 to n do\n case s[i] of\n 'B' : inc(b);\n 'G' : inc(g);\n 'R' : inc(r);\n end;\nend;\n\n\nprocedure OUTPUT;\nvar\n f : Text;\n i : LongInt;\nbegin\n assign(f,op); rewrite(f);\n if check(b,g,r) then write(f,'B');\n if check(g,b,r) then write(f,'G');\n if check(r,b,g) then write(f,'R');\n close(f);\nend;\n\n\nBEGIN\n INPUT;\n SOLVE;\n OUTPUT;\nEND.\n"}, {"source_code": "var\n n, i, g, b, r: Integer;\n s: string;\n \nbegin\n ReadLn (n);\n ReadLn (s);\n \n g:= 0;\n b:= 0;\n r:= 0;\n \n for i:= 1 to Length (s) do\n if s[i] = 'G' then\n Inc (g)\n else if s[i] = 'B' then\n Inc (b)\n else if s[i] = 'R' then\n Inc (r);\n \n if (b = 0) and ((r = 0) or (g = 0)) then\n else if (b >= 1) and (r + g = 1) then\n else Write ('B');\n \n if (g = 0) and ((r = 0) or (b = 0)) then\n else if (g >= 1) and (r + b = 1) then\n else Write ('G');\n \n if (r = 0) and ((b = 0) or (g = 0)) then\n else if (b >= 1) and (b + g = 1) then\n else Write ('R')\nend.\n "}, {"source_code": "uses math;\nvar\n a,t1,t2,t3,r:array[0..100000]of longint;\n s,ss:ansistring;\n i,m,n,k,l,w,j,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n\n if (a[1]<>0) then\n begin\n if max(a[2],a[3])mod 2=0 then r[1]:=1;\n end;\n if a[1]=0 then\n begin\n if (a[2]<>0)and(a[3]<>0) then r[1]:=1;\n end;\n\n if (a[2]<>0) then\n begin\n if max(a[1],a[3])mod 2=0 then r[2]:=1;\n end;\n if a[2]=0 then\n begin\n if (a[1]<>0)and(a[3]<>0) then r[2]:=1;\n end;\n\n if (a[3]<>0) then\n begin\n if max(a[2],a[1])mod 2=0 then r[3]:=1;\n end;\n if a[3]=0 then\n begin\n if (a[2]<>0)and(a[1]<>0) then r[3]:=1;\n end;\n if r[1]=1 then write('B');\n if r[2]=1 then write('G');\n if r[3]=1 then write('R');\nend.\n\n"}, {"source_code": "var\n a,t1,t2,t3,r:array[0..100000]of longint;\n s,ss:ansistring;\n i,m,n,k,l,w,j,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n\n if (a[1]<>0) then\n begin\n if (a[2]+a[3])mod 2=0 then r[1]:=1;\n end;\n if a[1]=0 then\n begin\n if (a[2]<>0)and(a[3]<>0) then r[1]:=1;\n end;\n\n if (a[2]<>0) then\n begin\n if (a[1]+a[3])mod 2=0 then r[2]:=1;\n end;\n if a[2]=0 then\n begin\n if (a[1]<>0)and(a[3]<>0) then r[2]:=1;\n end;\n\n if (a[3]<>0) then\n begin\n if (a[2]+a[1])mod 2=0 then r[3]:=1;\n end;\n if a[3]=0 then\n begin\n if (a[2]<>0)and(a[1]<>0) then r[3]:=1;\n end;\n if r[1]=1 then write('B');\n if r[2]=1 then write('G');\n if r[3]=1 then write('R');\nend.\n\n"}, {"source_code": "uses math;\nvar\n a,t1,t2,t3,r:array[0..100000]of longint;\n s,ss:ansistring;\n i,m,n,k,l,w,j,p1,p2,p3:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(a[1]);\n if s[i]='G' then inc(a[2]);\n if s[i]='R' then inc(a[3]);\n end;\n\n if (a[1]<>0) then\n begin\n if a[2]+a[3]>1 then r[1]:=1;\n end;\n if a[1]=0 then\n begin\n if (a[2]<>0)and(a[3]<>0) then r[1]:=1;\n end;\n\n if (a[2]<>0) then\n begin\n if a[1]+a[3]>1 then r[2]:=1;\n end;\n if a[2]=0 then\n begin\n if (a[1]<>0)and(a[3]<>0) then r[2]:=1;\n end;\n\n if (a[3]<>0) then\n begin\n if a[1]+a[2]>1 then r[3]:=1;\n end;\n if a[3]=0 then\n begin\n if (a[2]<>0)and(a[1]<>0) then r[3]:=1;\n end;\n if r[1]=1 then write('B');\n if r[2]=1 then write('G');\n if r[3]=1 then write('R');\nend.\n\n"}, {"source_code": "var s:string;\n n,i,kg,kb,kr:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nbegin\nif s[i]='G' then\ninc(kg);\nif s[i]='B' then\ninc(kb);\nif s[i]='R' then\ninc(kr);\nend;\nif (kg<>0) and (kb<>0) and (kr<>0) then\nbegin\nwriteln('GBR');\nhalt;\nend;\nif ((kg>=2) and (kb>=2)) or ((kr>=2) and (kb>=2)) or ((kg>=2) and (kr>=2)) then\nbegin\nwriteln('GBR');\nhalt;\nend;\nif (kg>=2) and ((kr=1) or (kb=1)) then\nbegin\nwriteln('RB');\nhalt;\nend;\nif (kr>=2) and ((kb=1) or (kg=1)) then\nbegin\nwriteln('GB');\nhalt;\nend;\nif (kb>=2) and ((kr=1) or (kg=1)) then\nbegin\nwriteln('GR');\nhalt;\nend;\nif (kg=1) and (kr=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kg=1) and (kb=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nif (kr=1) and (kb=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kg>=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kb>=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kr>=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nend."}, {"source_code": "var s:string;\n n,i,kg,kb,kr:longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nbegin\nif s[i]='G' then\ninc(kg);\nif s[i]='B' then\ninc(kb);\nif s[i]='R' then\ninc(kr);\nend;\nif (kg<>0) and (kb<>0) and (kr<>0) then\nbegin\nwriteln('GBR');\nhalt;\nend;\nif ((kg>=2) and (kb>=2)) or ((kr>=2) and (kb>=2)) or ((kg>=2) and (kr>=2)) then\nbegin\nwriteln('GBR');\nhalt;\nend;\nif (kg>=2) and ((kr=1) or (kb=1)) then\nbegin\nwriteln('BR');\nhalt;\nend;\nif (kr>=2) and ((kb=1) or (kg=1)) then\nbegin\nwriteln('GB');\nhalt;\nend;\nif (kb>=2) and ((kr=1) or (kg=1)) then\nbegin\nwriteln('GR');\nhalt;\nend;\nif (kg=1) and (kr=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kg=1) and (kb=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nif (kr=1) and (kb=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kg>=1) then\nbegin\nwriteln('G');\nhalt;\nend;\nif (kb>=1) then\nbegin\nwriteln('B');\nhalt;\nend;\nif (kr>=1) then\nbegin\nwriteln('R');\nhalt;\nend;\nend."}, {"source_code": "var B,G,R,i,n:longint;\ns:string;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n if s[i]='B' then B:=B+1\n else if s[i]='G' then G:=G+1\n else R:=R+1;\n if (B>0)and(G>0)and(R>0)then begin\n writeln('BGR');\n halt;\n end\n else if (B=0)and(G=0)then begin\n writeln('R');\n halt;\n end\n else if (B=0)and(R=0)then begin\n writeln('G');\n halt;\n end\n else if (G=0)and(R=0)then begin\n writeln('B');\n halt;\n end\n else if B=G then writeln('R')\n else if B=R then writeln('G')\n else if G=R then writeln('B')\n else if B=0 then begin\n write('B');\n if R s[j] then begin\n\t\t\tc:= s[i]; s[i] := s[j]; s[j] := c;\n\t\tend;\n\t//\n\tif (cnt >= 2) and (check['R'] + check['G'] + check['B'] > 3) then begin\n\t\twriteln('BGR'); exit\t\n\tend;\n\n\tif cnt = 1 then begin\n\t\twriteln(last); exit\n\tend;\n\n\tif cnt = 3 then begin\n\t\twriteln('BGR'); exit\n\tend;\n\t//\n\n\tif (cnt = 2) and (n = 2) then begin\n\t\tif (check['B']>0) and (check['R'] > 0) then writeln('G')\n\t\telse if (check['B'] =1) and (check['G']=1) then writeln('R')\n\t\telse if (check['G'] = 1) and (check['R']=1) then writeln('B');\n\tend;\n\n\tres := '';\n\t//writeln(cnt);\n\tif (cnt = 2) and (n > 2) then begin\n\t\tfor i := 1 to n do \n\t\t\tif check[s[i]] > 1 then begin\n\t\t\t\tres := res + s[i];\n\t\t\t\tif length(Res) = 2 then break\n\t\t\tend;\n\t//\twriteln(res);\n\t\tif res = 'GG' then writeln('BR');\n\t\tif res = 'RR' then writeln('BG');\n\t\tif res = 'BB' then writeln('GR');\n\tend;\n\nend."}, {"source_code": "{$mode objfpc}\nuses \n\tmath;\n\nvar\n\tfi: text;\n\ti, j, n, cnt: integer;\n\ts: ansistring;\n\tcheck: array['A'..'Z'] of integer;\n\tc, last: char;\n\tres: ansistring;\nbegin\n\tassign(fi, ''); reset(fi);\n\treadln(fi, n); readln(fi, s);\n\tfor i := 1 to n do begin\n\t\tif check[s[i]] = 0 then \n\t\t\tinc(cnt);\n\t\tinc(check[s[i]]);\n\t\tlast := s[i];\n\tend;\n\n\tfor i := 1 to n do for j := i+1 to n do\n\t\tif s[i] > s[j] then begin\n\t\t\tc:= s[i]; s[i] := s[j]; s[j] := c;\n\t\tend;\n\t//\n\tif (check['R'] + check['G'] + check['B'] > 3) then begin\n\t\twriteln('BGR'); exit\t\n\tend;\n\n\tif cnt = 1 then begin\n\t\twriteln(last); exit\n\tend;\n\n\tif cnt = 3 then begin\n\t\twriteln('BGR'); exit\n\tend;\n\t//\n\n\tif (cnt = 2) and (n = 2) then begin\n\t\tif (check['B']>0) and (check['R'] > 0) then writeln('G')\n\t\telse if (check['B'] =1) and (check['G']=1) then writeln('R')\n\t\telse if (check['G'] = 1) and (check['R']=1) then writeln('B');\n\tend;\n\n\tres := '';\n\t//writeln(cnt);\n\tif (cnt = 2) and (n > 2) then begin\n\t\tfor i := 1 to n do \n\t\t\tif check[s[i]] > 1 then begin\n\t\t\t\tres := res + s[i];\n\t\t\t\tif length(Res) = 2 then break\n\t\t\tend;\n\t//\twriteln(res);\n\t\tif res = 'GG' then writeln('BR');\n\t\tif res = 'RR' then writeln('BG');\n\t\tif res = 'BB' then writeln('GR');\n\tend;\n\nend."}, {"source_code": "{$mode objfpc}\nuses \n\tmath;\n\nvar\n\tfi: text;\n\ti, j, n, cnt: integer;\n\ts: ansistring;\n\tcheck: array['A'..'Z'] of integer;\n\tc, last: char;\n\tres: ansistring;\nbegin\n\tassign(fi, ''); reset(fi);\n\treadln(fi, n); readln(fi, s);\n\tfor i := 1 to n do begin\n\t\tif check[s[i]] = 0 then \n\t\t\tinc(cnt);\n\t\tinc(check[s[i]]);\n\t\tlast := s[i];\n\tend;\n\n\tfor i := 1 to n do for j := i+1 to n do\n\t\tif s[i] > s[j] then begin\n\t\t\tc:= s[i]; s[i] := s[j]; s[j] := c;\n\t\tend;\n\t//\n\tif cnt = 1 then begin\n\t\twriteln(last); exit\n\tend;\n\n\tif cnt = 3 then begin\n\t\twriteln('BGR'); exit\n\tend;\n\t//\n\n\tif (cnt = 2) and (n = 2) then begin\n\t\tif (check['B']>0) and (check['R'] > 0) then writeln('G')\n\t\telse if (check['B'] =1) and (check['G']=1) then writeln('R')\n\t\telse if (check['G'] = 1) and (check['R']=1) then writeln('B');\n\tend;\n\n\tres := '';\n\t//writeln(cnt);\n\tif (cnt = 2) and (n > 2) then begin\n\t\tfor i := 1 to n do \n\t\t\tif check[s[i]] > 1 then begin\n\t\t\t\tres := res + s[i];\n\t\t\t\tif length(Res) = 2 then break\n\t\t\tend;\n\t//\twriteln(res);\n\t\tif res = 'GG' then writeln('BR');\n\t\tif res = 'RR' then writeln('BG');\n\t\tif res = 'BB' then writeln('GR');\n\tend;\n\nend."}, {"source_code": "{$mode objfpc}\nuses \n\tmath;\n\nvar\n\tfi: text;\n\ti, j, n, cnt: integer;\n\ts: ansistring;\n\tcheck: array['A'..'Z'] of integer;\n\tc, last: char;\n\tres: ansistring;\nbegin\n\tassign(fi, ''); reset(fi);\n\treadln(fi, n); readln(fi, s);\n\tfor i := 1 to n do begin\n\t\tif check[s[i]] = 0 then \n\t\t\tinc(cnt);\n\t\tinc(check[s[i]]);\n\t\tlast := s[i];\n\tend;\n\tfor i := 1 to n do for j := i+1 to n do\n\t\tif s[i] > s[j] then begin\n\t\t\tc:= s[i]; s[i] := s[j]; s[j] := c;\n\t\tend;\n\n\t//\n\tif cnt = 1 then begin\n\t\twriteln(last); exit\n\tend;\n\n\tif cnt = 3 then begin\n\t\twriteln('BGR'); exit\n\tend;\n\t//\n\n\tif (cnt = 2) and (n = 2) then begin\n\t\tif (check['B']>0) and (check['R'] > 0) then writeln('G')\n\t\telse if (check['B'] =1) and (check['G']=1) then writeln('R')\n\t\telse if (check['G'] = 1) and (check['R']=1) then writeln('B');\n\tend;\n\n\tres := '';\n\tif (cnt = 2) and (n > 2) then begin\n\t\tfor i := 1 to n do \n\t\t\tif check[s[i]] > 1 then res := res + s[i];\n\t\tif res = 'GG' then writeln('BR');\n\t\tif res = 'RR' then writeln('BG');\n\t\tif res = 'BB' then writeln('GR');\n\tend;\n\nend."}, {"source_code": "uses math;\nvar b,g,r,bs,gs,rs,i,j,n,k,m,s:longint;\n h:char;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(h);\n if h = 'R' then inc(rs) else\n if h = 'B' then inc(bs) else\n inc(gs);\n end;\n\n b:=bs; g:=gs; r:=rs;\n\n // while b+g+r > 2 do\n// begin\n if g > 0 then g:=1;\n if b > 0 then b:=1;\n if r > 0 then r:=1;\n// end;\n\n if (g+r=2) or (g+r=0) then write('B');\n if (r+b=2) or (r+b=0) then write('G');\n if (g+b=2) or (g+b=0) then write('R');\nend."}, {"source_code": "var\npodr,podb,podg,min,n,i,r,g,b:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='R' then inc(r);\n if s[i]='B' then inc(b);\n if s[i]='G' then inc(g);\nend;\nif ((r>0)and(b>0)and(g>0))or((r>=2)and(b>=2))or((r>=2)and(g>=2))or((g>=2)and(b>=2)) then write('BGR')\nelse\nbegin\n if (r>=1)and(b=0)and(g=0) then write('R')\n else\n if (r=0)and(b>=1)and(g=0) then write('B')\n else\n if (r=0)and(b>=0)and(g=1) then write('G')\n else\n if (r=1)and(b=1)and(g=0) then write('G')\n else\n if (r=1)and(b=0)and(g=1) then write('B')\n else\n if (r=0)and(b=1)and(g=1) then write('R')\n else\n if (r>=2)and(b=1)and(g=0) then write('BG')\n else\n if (r>=2)and(b=0)and(g=1) then write('BG')\n else\n if (r=1)and(b>=2)and(g=0) then write('GR')\n else\n if (r=1)and(b=0)and(g>=2) then write('BR')\n else\n if (r=0)and(b>=2)and(g=1) then write('GR')\n else\n if (r=0)and(b=1)and(g>=2) then write('BR');\n \nend;\nend.\n"}, {"source_code": "{$mode objfpc}\n\nvar\n n,i,r,g,b:longint;\n s:ansistring;\nprocedure input;\nbegin\n readln(n);\n read(s);\nend;\n\nfunction tm(x,y,z:longint):boolean;\nbegin\n if (x=0) and (y>=1) and (z>=1) then exit(true);\n if (y=0) and (z=0) then exit(true);\n if (x>0) and ((y>1) or (z>1)) then exit(true);\n exit(false);\nend;\n\nprocedure process;\nbegin\n r:=0;\n g:=0;\n b:=0;\n for i:=1 to length(s) do\n case s[i] of\n 'R':inc(r);\n 'G':inc(g);\n 'B':inc(b);\n end;\n if tm(b,g,r) then write('B');\n if tm(g,r,b) then write('G');\n if tm(r,g,b) then write('R');\nend;\n\nbegin\n input;\n process;\nend."}, {"source_code": "var r,g,b:longint;\n n,i:integer;\n ch:char;\n r1,b1,g1:boolean;\n\nlabel outp;\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n case ch of\n 'R': inc(r);\n 'B': inc(b);\n 'G': inc(g);\n end;\n end;\n if (r<>0)xor(g<>0)xor(b<>0)\n then\n begin\n if r<>0 then write('R');\n if b<>0 then write('B');\n if g<>0 then write('G');\n end\n else\n begin\n if ((r=1)xor(b=1)xor(g=1))and((r=0)xor(g=0)xor(b=0))\n then\n begin\n if b = 1 then b1:=true;\n if g = 1 then g1:=true;\n if r = 1 then r1:=true;\n if b = 0 then b1:=true;\n if g = 0 then g1:=true;\n if r = 0 then r1:=true;\n goto outp;\n end;\n\n if r+g+b = 2\n then\n begin\n if r=0 then write('R');\n if b=0 then write('B');\n if g=0 then write('G');\n exit;\n end;\n b1:=true;\n g1:=true;\n r1:=true;\n outp:\n if b1 then write('B');\n if g1 then write('G');\n if r1 then write('R');\n end;\n\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nvar n,dem1,dem2,dem3,i:integer;\n s:ansistring;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(dem1);\n if s[i]='G' then inc(dem2);\n if s[i]='R' then inc(dem3)\n end;\n if ((dem2>0) and (dem3>0)) or ((dem2=0) and (dem3=0)) then write('B');\n if ((dem1>0) and (dem3>0)) or ((dem1=0) and (dem3=0)) then write('G');\n if ((dem2>0) and (dem1>0)) or ((dem2=0) and (dem1=0)) then write('R');\n writeln\n\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nvar n,dem1,dem2,dem3,i:integer;\n s:ansistring;\n\nbegin\n //assign(input,'dream_hyojoo.inp');\n //reset(input);\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='B' then inc(dem1);\n if s[i]='G' then inc(dem2);\n if s[i]='R' then inc(dem3)\n end;\n if (abs(dem2-dem3) mod 2=0) and (dem1>=abs(dem2-dem3) div 2)\n then write('B');\n if (abs(dem1-dem3) mod 2=0) and (dem2>=abs(dem1-dem3) div 2)\n then write('G');\n if (abs(dem2-dem1) mod 2=0) and (dem3>=abs(dem2-dem1) div 2)\n then write('R');\n writeln\n\nend."}, {"source_code": "var i, j, n, m:longint;\na:array[1..3]of longint;\ns:string;\nbegin\nreadln(n);\nread(s);\nFor i:=1 to n do case s[i] of\n 'G':inc(a[2]);\n 'R':inc(a[3]);\n 'B':inc(a[1]);\n end;\nif (a[1]>0)and(a[2]>0)and(a[3]>0) then write('BGR')\n else if (a[1]=0)and(a[2]=0)then write('R')\n else if (a[2]=0)and(a[3]=0)then write('B')\n else if (a[1]=0)and(a[2]=0)then write('G')\n else if a[1]=0 then begin if (a[2]>1)and(a[3]>1) then write('BGR')\n else\n if (a[3]=1)and(a[2]=1) then write('B')\n else if a[2]=1 then write('BG')\n else if a[3]=1 then write('BR');\n end\n else\n if a[2]=0 then begin if (a[1]>1)and(a[3]>1) then write('BGR')\n else if (a[1]=1)and(a[3]=1) then write('G')\n else if a[1]=1 then write('BG')\n else if a[3]=1 then write('GR');\n end\n else\n if a[3]=0 then begin if (a[2]>1)and(a[1]>1) then write('BGR')\n else if (a[1]=1)and(a[2]=1) then write('R')\n else if a[2]=1 then write('GR')\n else if a[1]=1 then write('BR');\n end;\n\n\n\n\n\nEnd.\n\n"}, {"source_code": "var\n g, r, b:byte;\n c:char;\n i, n:byte;\n\nBEGIN\n g:=0; r:=0; b:=0;\n readln(n);\n for i:=1 to n do begin\n read(c);\n if c='R' then\n inc(r)\n else if c='G' then\n inc(g)\n else\n inc(b);\n end;\n\n\n if r>=2 then begin\n if (b>=2) or (g>=2) then\n write('BGR')\n else if ((b>=1) and (g=0)) or ((b=0) and (g>=1)) then\n write('BG')\n else if (b=0) and (g=0) then\n write('R');\n end\n else if r>=1 then begin\n if (b>=1) and (g>=1) then\n write('BGR')\n else if ((b>=2) and (g=0)) then\n write('GR')\n else if ((b=0) and (g>=2)) then\n write('BR')\n else if (r=1) and (b=1) and (g=0) then\n write('G')\n else if (r=1) and (b=0) and (g=1) then\n write('B');\n end\n else if (b>=2) then begin\n if g>=1 then\n write('GR')\n else if g=0 then\n write('B');\n end\n else if (b>=1) and (g>=2) then\n write('BR')\n else if (b=1) and (g=1) then\n write('R')\n else if g>=2 then\n write('G');\n\n\n\nEND.\n"}], "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f"} {"source_code": "var\n n,k,kq:int64;\n f:array[0..5] of int64;\n\nprocedure enter;\n begin\n readln(n,k);\n end;\n\nprocedure process;\nvar i:longint;\n begin\n f[0]:=1;\n f[1]:=0;\n f[2]:=n*(n-1) div 2;\n f[3]:=n*(n-1)*(n-2) div 3;\n f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;\n for i:=0 to k do\n kq:=kq+f[i];\n write(kq);\n end;\n\nbegin\n enter;\n process;\nend.", "positive_code": [{"source_code": "program Almost_Identity_Permutations;\n\nconst\n maxn = 1003;\n maxk = 4;\n\nvar\n n, k: longint;\n ans: int64;\n\nbegin\n readln(n, k);\n\n ans := 1;\n if k >= 2 then inc(ans, int64(n) * (n - 1) div 2);\n if k >= 3 then inc(ans, int64(n) * (n - 1) * (n - 2) div 6 * 2);\n if k >= 4 then inc(ans, int64(n) * (n - 1) * (n - 2) * (n - 3) div 24 * 9);\n\n writeln(ans);\nend.\n"}, {"source_code": "var n,k:int64;\nf:array[0..4] of int64;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nbegin\n readln(n,k);\nend;\nprocedure xuli;\nvar res:int64;i:longint;\nbegin\n res:=0;\n f[0]:=1;\n f[1]:=0;\n f[2]:=(n*(n-1)) div 2;\n f[3]:=(n*(n-1)*(n-2))div 3;\n f[4]:=(n*(n-1)*(n-2)*(n-3))*9 div 24;\n for i:=0 to k do\n res:=res+f[i];\n writeln(res);\nend;\nbegin\n //mo;\n nhap;\n xuli;\n //dong;\nend.\n\n"}, {"source_code": "const fi='888D.inp';\n fo='888D.out';\nvar n,k,kq:int64;\nprocedure conan;\n begin\n kq:=1;\n if k=1 then exit;\n kq:=kq+n*(n-1) div 2;\n if k=2 then exit;\n kq:=kq+n*(n-1)*(n-2)*2 div 6;\n if k=3 then exit;\n kq:=kq+n*(n-1)*(n-2)*(n-3) * 9 div 24;\n end;\nbegin\n\n readln(n,k);\n conan;\n writeln(kq);\nend.\n"}, {"source_code": "Program AFSA;\nvar n,k,i:longint;\n g1,g2,g3,g4:int64;\n begin\nread(n,k);\nif k=1 then writeln(1);\n\ng2:=1;\nfor i:=n-1 to n do\n g2:=g2*i;\nfor i:=1 to 2 do\n g2:=g2 div i; \n\nif k=2 then writeln(g2+1);\n\ng3:=1;\nfor i:=n-2 to n do\n g3:=g3*i;\nfor i:=1 to 3 do\n g3:=g3 div i; \ng3:=g3*2;\n\nif k=3 then writeln(g2+g3+1);\n\ng4:=1;\nfor i:=n-3 to n do\n g4:=g4*i;\nfor i:=1 to 4 do\n g4:=g4 div i; \ng4:=g4*9;\n if k=4 then writeln(1+g2+g3+g4);\n\n//writeln(1, ' ', g2, ' ', g3, ' ',g4);\n\n\n\n\n\n{\n2143\n2341\n2413\n3142\n3412\n3421\n4123\n4321\n4312\n}\n\n\n\nend."}, {"source_code": "var n,k:int64;i:longint;\ntong:int64;\nf:array [0..1000] of int64;\nbegin\n read(n,k);\n f[0]:=1;\n f[1]:=0;\n f[2]:=n*(n-1)div 2;\n f[3]:=n*(n-1)*(n-2) div 3 ;\n f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;\n for i:=0 to k do\n tong:=tong-f[i];\n write(tong*(-1))\nend.\n"}, {"source_code": " \n const eps=0.0000000001; nn=200000; besk=8000000000;\n label 1,2,23;\n type real=extended; {string=ansistring;}\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n ppoint=^point;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var aa,bb,cc,pos,kk,t3,ot,prod,ost,kol,zapas,dist,r,ll,rr,sum,q,h,t1,t2,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;\n ii,jj,step, k,i,j:longint;\n { aa,bb,cc:int64;\n } pp:array[-1000 ..1000] of point;\n fact,slow,z,pr,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;\n dd:array[-10..2000,-10..200] of int64;\n zanx,zany:array[-10..20000000] of boolean;\n marked,zan:array[-10..10000000] of boolean;\n ss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ch:char;\n d :array [-10..250000,-1..50] of int64;\n dda:array [0..201,-10..30] of int64;\n sss:array[-10..500000] of string;\n st2:array[0..nn] of string;\n pr1,pr2,v0,v1,s0,t0:extended;\n zv:point;\n prob:array[-1..200,-1..200] of extended;\n\n yot:double;\n qqq,aaa,bbb,ccc:extended;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nfunction dom(length,num:longint):boolean;\nvar t,i,j:longint; fll,fl:boolean;\nbegin\n fl:=true;\n for i:=1 to n-length+1 do if d[i+length-1,num]-d[i-1,num]=0 then fl:=false;\n\n dom:=fl;\n\n\nend;\n\nfunction domm(length:longint):boolean;\nvar i,j:longint; fl:boolean;\nbegin\n fl:=false;\n for i:=0 to 25 do if dom(length,i) then fl:=true;\n\n domm:=fl;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n,p);\n a[2]:=n*(n-1) div 2;\n a[3]:=n*(n-1)*(n-2) div 6;\n a[4]:=n*(n-1)*(n-2)*(n-3) div 24;\n b[2]:=1;\n b[3]:=2;\n b[4]:=9;\n\n ot:=1;\n for i:=2 to p do ot:=ot+a[i]*b[i];\n\n writeln(ot);\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var n,k: Int64;\n f: Array[0..4] Of QWord;\n\nProcedure Nhap;\nBegin\nReadln(n,k);\nEnd;\n\nProcedure XuLy;\nBegin\nf[0]:=1;\nf[1]:=0;\nf[2]:=(n*(n-1)) div 2;\nf[3]:=(n*(n-1)*(n-2)) div 3;\nf[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;\nEnd;\n\nProcedure Xuat;\nVar i: Longint;\n kq: QWord;\nBegin\nkq:=0;\nFor i:=0 to k do\n kq:=kq+f[i];\nWriteln(kq);\nEnd;\n\nBegin\nNhap;\nXuLy;\nXuat;\nEnd.\n"}], "negative_code": [{"source_code": "var\n n,k,kq:longint;\n f:array[0..5] of int64;\n\nprocedure enter;\n begin\n readln(n,k);\n end;\n\nprocedure process;\nvar i:longint;\n begin\n f[0]:=1;\n f[1]:=0;\n f[2]:=n*(n-1) div 2;\n f[3]:=n*(n-1)*(n-2) div 3;\n f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;\n for i:=0 to k do\n kq:=kq+f[i];\n write(kq);\n end;\n\nbegin\n enter;\n process;\nend."}, {"source_code": "var n,k:int64;i:longint; \ntong:int64;\nf:array [0..1000] of longint;\nbegin\n read(n,k);\n f[0]:=1;\n f[1]:=0;\n f[2]:=n*(n-1)div 2;\n f[3]:=n*(n-1)*(n-2) div 3 ;\n f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;\n for i:=0 to k do\n tong:=tong-f[i];\n write(tong*(-1))\nend.\n"}, {"source_code": "var n,i,k:longint;\ntong:int64; \nf:array [0..1000] of longint;\nbegin\n read(n,k);\n f[0]:=1;\n f[1]:=0;\n f[2]:=n*(n-1)div 2;\n f[3]:=n*(n-1)*(n-2) div 3 ;\n f[4]:=n*(n-1)*(n-2)*(n-3)*9 div 24;\n for i:=0 to k do\n tong:=tong-f[i];\n write(tong*(-1))\nend.\n"}, {"source_code": "Var n,k: Longint;\n f: Array[0..4] Of Int64;\n\nProcedure Nhap;\nBegin\nReadln(n,k);\nEnd;\n\nProcedure XuLy;\nBegin\nf[0]:=1;\nf[1]:=0;\nf[2]:=(n*(n-1)) div 2;\nf[3]:=(n*(n-1)*(n-2)) div 3;\nf[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;\nEnd;\n\nProcedure Xuat;\nVar i,kq: Longint;\nBegin\nkq:=0;\nFor i:=0 to k do\n kq:=kq+f[i];\nWriteln(kq);\nEnd;\n\nBegin\nNhap;\nXuLy;\nXuat;\nEnd.\n"}, {"source_code": "Var n,k: Longint;\n f: Array[0..4] Of Longint;\n\nProcedure Nhap;\nBegin\nReadln(n,k);\nEnd;\n\nProcedure XuLy;\nBegin\nf[0]:=1;\nf[1]:=0;\nf[2]:=(n*(n-1)) div 2;\nf[3]:=(n*(n-1)*(n-2)) div 3;\nf[4]:=((n*(n-1)*(n-2)*(n-3))*3) div 8;\nEnd;\n\nProcedure Xuat;\nVar i,kq: Longint;\nBegin\nkq:=0;\nFor i:=0 to k do\n kq:=kq+f[i];\nWriteln(kq);\nEnd;\n\nBegin\nNhap;\nXuLy;\nXuat;\nEnd."}, {"source_code": "Program AFSA;\nvar n,k,g1,g2,g3,g4,i:longint;\n\nbegin\nread(n,k);\nif k=1 then writeln(1);\n\ng2:=1;\nfor i:=1 to n do\n g2:=g2*i;\nfor i:=1 to k do\n g2:=g2 div i; \nfor i:=1 to n-k do\n g2:=g2 div i; \n\nif k=2 then writeln(g2+1);\n\ng3:=1;\nfor i:=1 to n do\n g3:=g3*i;\nfor i:=1 to k do\n g3:=g3 div i; \nfor i:=1 to n-k do\n g3:=g3 div i; \ng3:=g3*2;\n\nif k=3 then writeln(g2+g3+1);\n\ng4:=1;\nfor i:=1 to n do\n g4:=g4*i;\nfor i:=1 to k do\n g4:=g4 div i; \nfor i:=1 to n-k do\n g4:=g4 div i; \ng4:=g4*12;\n if k=4 then writeln(1+g2+g3+g4);\n\n\n\n\n\n\n{\n2143\n3412\n4321\n4123\n2341\n2413\n2431\n\n\n\n\n\n}\n\n\n\nend."}, {"source_code": "Program AFSA;\nvar n,k,g1,g2,g3,g4,i:longint;\n\nbegin\nread(n,k);\nif k=1 then writeln(1);\n\ng2:=1;\nfor i:=1 to n do\n g2:=g2*i;\nfor i:=1 to 2 do\n g2:=g2 div i; \nfor i:=1 to n-2 do\n g2:=g2 div i; \n\nif k=2 then writeln(g2+1);\n\ng3:=1;\nfor i:=1 to n do\n g3:=g3*i;\nfor i:=1 to 3 do\n g3:=g3 div i; \nfor i:=1 to n-3 do\n g3:=g3 div i; \ng3:=g3*2;\n\nif k=3 then writeln(g2+g3+1);\n\ng4:=1;\nfor i:=1 to n do\n g4:=g4*i;\nfor i:=1 to 4 do\n g4:=g4 div i; \nfor i:=1 to n-4 do\n g4:=g4 div i; \ng4:=g4*9;\n if k=4 then writeln(1+g2+g3+g4);\n\n//writeln(1, ' ', g2, ' ', g3, ' ',g4);\n\n\n\n\n\n{\n2143\n2341\n2413\n3142\n3412\n3421\n4123\n4321\n4312\n}\n\n\n\nend."}, {"source_code": "Program AFSA;\nvar n,k,g1,g2,g3,g4,i:longint;\n\nbegin\nread(n,k);\nif k=1 then writeln(1);\n\ng2:=1;\nfor i:=n-1 to n do\n g2:=g2*i;\nfor i:=1 to 2 do\n g2:=g2 div i; \n\nif k=2 then writeln(g2+1);\n\ng3:=1;\nfor i:=n-2 to n do\n g3:=g3*i;\nfor i:=1 to 3 do\n g3:=g3 div i; \ng3:=g3*2;\n\nif k=3 then writeln(g2+g3+1);\n\ng4:=1;\nfor i:=n-3 to n do\n g4:=g4*i;\nfor i:=1 to 4 do\n g4:=g4 div i; \ng4:=g4*9;\n if k=4 then writeln(1+g2+g3+g4);\n\n//writeln(1, ' ', g2, ' ', g3, ' ',g4);\n\n\n\n\n\n{\n2143\n2341\n2413\n3142\n3412\n3421\n4123\n4321\n4312\n}\n\n\n\nend."}], "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f"} {"source_code": "Const\n thang:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nType\n mat=array [1..1000000] of longint;\nVar n,res,y1,d1,m1,y2,d2,m2:longint;\n a,s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y1);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m1);\n Val(a,d1);\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y2);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m2);\n Val(a,d2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nFunction Nhuan(x:longint):boolean;\n Begin\n If ((x mod 4=0) and (x mod 100<>0)) or ( x mod 400=0) then\n exit(true);\n exit(false);\n end;\n\nProcedure Lam;\n Var i:longint;\n Begin\n If y1>y2 then\n Begin\n Doicho(y1,y2);\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n res:=0;\n For i:=y1+1 to y2-1 do\n If Nhuan(i) then\n res:=res+366\n else res:=res+365;\n If y1=y2 then\n Begin\n If m1>m2 then\n Begin\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n For i:=m1+1 to m2-1 do res:=res+thang[i];\n If (m1<=2) and (m2>2) and (Nhuan(y1)) then inc(res);\n If m1<>m2 then\n res:=res+thang[m1]-d1+d2\n else res:=res+d2-d1;\n end\n else\n Begin\n For i:=m1+1 to 12 do res:=res+thang[i];\n If Nhuan(y1) then\n If m1<=2 then inc(res);\n For i:= 1 to m2-1 do res:=res+thang[i];\n If Nhuan(y2) then\n If m2>2 then inc(res);\n res:=res+thang[m1]-d1+d2;\n end;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.", "positive_code": [{"source_code": "const months:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n s1,s2:string; k1,k2,dd1,dd2,mm1,mm2,yy1,yy2,code,dd,mm,yy,k:longint;\n\n\nfunction high(year:longint):boolean;\nbegin\n if (year mod 4<>0) then high:=false else\n if (year mod 100<>0) then high:=true else\n if (year mod 400=0) then high:=true else high:=false;\nend;\n\n\nbegin\n\n readln(s1); val(copy(s1,9,2),dd1,code); val(copy(s1,6,2),mm1,code); val(copy(s1,1,4),yy1,code);\n readln(s2); val(copy(s2,9,2),dd2,code); val(copy(s2,6,2),mm2,code); val(copy(s2,1,4),yy2,code);\n dd:=1; mm:=1; yy:=1900; k:=1; k1:=1; k2:=1;\n while not((dd=1)and(mm=1)and(yy=2040)) do\n begin\n inc(dd); inc(k);\n if (dd>months[mm]) then\n begin\n if (dd=29) and (mm=2) and (high(yy)=true) then else\n begin\n dd:=1; inc(mm);\n if mm=13 then begin inc(yy); mm:=1; end;\n end;\n end;\n if (dd1=dd) and (mm1=mm) and (yy1=yy) then k1:=k;\n if (dd2=dd) and (mm2=mm) and (yy2=yy) then k2:=k;\n end;\n writeln(abs(k1-k2));\n\nend."}, {"source_code": "Const a : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n\nVar y1, m1, d1, y2, i, m2, d2, dd, code : longint;\n date : int64;\n s1, s2 : string;\n\nProcedure change(m,d:longint);\n Var month, day : longint;\n Begin\n dd := 0;\n for i:=1 to m-1 do\n dd := dd+a[i];\n dd := dd+d;\n End;\n\nProcedure swap(var x, y : longint);\n Var tmp : longint;\n Begin\n tmp := x;\n x := y;\n y := tmp;\n End;\n\nBegin\n readln(s1);\n readln(s2);\n val(copy(s1,1,4),y1,code);\n val(copy(s1,6,2),m1,code);\n val(copy(s1,9,2),d1,code);\n /////////\n val(copy(s2,1,4),y2,code);\n val(copy(s2,6,2),m2,code);\n val(copy(s2,9,2),d2,code);\n /////////\n if (y1 > y2) or ((y1 = y2) and (m1 > m2)) or ((y1 = y2) and (m1 = m2) and (d1 > d2)) then begin \n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i:=y1 to y2-1 do begin\n if (i mod 400 = 0) and (i mod 1000 = 0) then begin\n date := date+366;\n continue;\n end;\n if i mod 100 = 0 then begin\n date := date+365;\n continue;\n end;\n if i mod 4 = 0 then date := date+366\n else date := date+365;\n end;\n change(m1,d1);\n if (((y1 mod 400 = 0) and (y1 mod 1000 = 0)) or ((y1 mod 100 <> 0) and (y1 mod 4 = 0))) and (m1 > 2) then\n dd := dd+1;\n date := date-dd;\n dd := 0;\n change(m2,d2);\n if (((y2 mod 400 = 0) and (y2 mod 1000 = 0)) or ((y2 mod 100 <> 0) and (y2 mod 4 = 0))) and (m2 > 2) then\n dd := dd+1;\n date := date+dd;\n writeln(date);\nEnd.\n"}, {"source_code": "const\n a : array[1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n yy1,mm1,dd1,yy2,mm2,dd2,i,j,k,s : longint;\n s1,s2 : string;\nfunction f(y : integer) : boolean;\nbegin\n if ((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0) then f := true\n else f := false;\nend;\nbegin\n readln(s1); readln(s2);\n yy1 := (ord(s1[1])-48)*1000+(ord(s1[2])-48)*100\n +(ord(s1[3])-48)*10+(ord(s1[4])-48);\n mm1 := (ord(s1[6])-48)*10+(ord(s1[7])-48);\n dd1 := (ord(s1[9])-48)*10+(ord(s1[10])-48);\n yy2 := (ord(s2[1])-48)*1000+(ord(s2[2])-48)*100\n +(ord(s2[3])-48)*10+(ord(s2[4])-48);\n mm2 := (ord(s2[6])-48)*10+(ord(s2[7])-48);\n dd2 := (ord(s2[9])-48)*10+(ord(s2[10])-48);\n if yy1*10000+mm1*100+dd1>yy2*10000+mm2*100+dd2 then begin\n k := yy1; yy1 := yy2; yy2 := k;\n k := mm1; mm1 := mm2; mm2 := k;\n k := dd1; dd1 := dd2; dd2 := k;\n end;\n for i := yy1 to yy2-1 do begin\n if f(i)=true then inc(s);\n inc(s,365);\n end;\n if f(yy1)=true then a[2] := 29 else a[2] := 28;\n for i := 1 to mm1-1 do dec(s,a[i]);\n dec(s,dd1-1);\n if f(yy2)=true then a[2] := 29 else a[2] := 28;\n for i := 1 to mm2-1 do inc(s,a[i]);\n inc(s,dd2);\n writeln(s-1);\n readln;\nend."}, {"source_code": "program p183b;\n var s,s2,s3:string;\n y,m,d,y2,m2,d2,ans:longint;\n\nbegin\n readln(s);\n readln(s2);\n if s>s2 then begin s3:=s;s:=s2;s2:=s3;end;\n y:=1000*(ord(s[1])-ord('0') )+100*(ord(s[2])-ord('0'))+10*(ord(s[3])-ord('0'))+ord(s[4])-ord('0');\n m:=10*(ord(s[6])-ord('0'))+ord(s[7])-ord('0');\n d:=10*(ord(s[9])-ord('0'))+ord(s[10])-ord('0');\n s:=s2;\n y2:=1000*(ord(s[1])-ord('0') )+100*(ord(s[2])-ord('0'))+10*(ord(s[3])-ord('0'))+ord(s[4])-ord('0');\n m2:=10*(ord(s[6])-ord('0'))+ord(s[7])-ord('0');\n d2:=10*(ord(s[9])-ord('0'))+ord(s[10])-ord('0');\n while not((y=y2)and(m=m2)and(d=d2))do\n begin\n inc(ans);\n inc(d);\n case d of\n 32: begin d:=1; inc(m);end ;\n 31: if m in [4,6,9,11] then begin d:=1; inc(m);end ;\n 30: if m=2 then begin d:=1; inc(m);end;\n 29: if (m=2)and((y mod 4<>0)or(y=1900)) then begin d:=1; inc(m);end;\n end;\n if m=13 then begin inc(y);m:=1;end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const a:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar s,s1:string;\nx,x1,y1,y,z,z1,ans,i,c,f:longint;\nBegin\n // assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n readln(s);\n readln(s1);\n if s=s1 then begin writeln(0); halt; end;\n for i:=1 to 4 do\n begin\n val(s[i],c,f);\n x:=x*10+c;\n val(s1[i],c,f);\n x1:=x1*10+c;\n end;\n for i:=6 to 7 do\n begin\n val(s[i],c,f);\n y:=y*10+c;\n val(s1[i],c,f);\n y1:=y1*10+c;\n end;\n for i:=9 to 10 do\n begin\n val(s[i],c,f);\n z:=z*10+c;\n val(s1[i],c,f);\n z1:=z1*10+c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x>x1)or((x=x1)and(y>y1))or((x=x1)and(y=y1)and(z>z1)) then\n begin\n c:=x;\n x:=x1;\n x1:=c;\n c:=y;\n y:=y1;\n y1:=c;\n c:=z;\n z:=z1;\n z1:=c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x=x1)and(y=y1)then\n begin\n writeln(z1-z);\n halt;\n end;\n if (x=x1)then\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=a[y]-z+2; end\n else ans:=a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while x<>x1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while y<>y1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n end;\n ans:=ans+z1-1;\n writeln(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, year_1, m_1, day_1, year_2, m_2, day_2, k: Integer;\n s, ss: String;\n mas: array [1..12] of Integer;\n\nProcedure Cnt_1;\nbegin\n i := 1;\n ss := '';\n while (s[i] <> ':') do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n year_1 := StrToInt(ss);\n Inc(i);\n ss := '';\n while (s[i] <> ':') do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n m_1 := StrToInt(ss);\n Inc(i);\n ss := '';\n while (i <= length(s)) do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n day_1 := StrToInt(ss);\nend;\n\nProcedure Cnt_2;\nbegin\n i := 1;\n ss := '';\n while (s[i] <> ':') do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n year_2 := StrToInt(ss);\n Inc(i);\n ss := '';\n while (s[i] <> ':') do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n m_2 := StrToInt(ss);\n Inc(i);\n ss := '';\n while (i <= length(s)) do\n begin\n ss := ss + s[i];\n Inc(i);\n end;\n day_2 := StrToInt(ss);\nend;\n\nProcedure Swap;\nvar\n k: Integer;\nbegin\n k := year_1;\n year_1 := year_2;\n year_2 := k;\n k := m_1;\n m_1 := m_2;\n m_2 := k;\n k := day_1;\n day_1 := day_2;\n day_2 := k;\nend;\n\nProcedure Min_max;\nbegin\n If (year_1 > year_2) then\n swap else\n If (year_1 = year_2) and (m_1 > m_2) then\n swap else\n If (year_1 = year_2) and (m_1 = m_2) and (day_1 > day_2) then\n swap;\nend;\n\nProcedure Filling;\nbegin\n mas[1] := 31;\n mas[2] := 28;\n mas[3] := 31;\n mas[4] := 30;\n mas[5] := 31;\n mas[6] := 30;\n mas[7] := 31;\n mas[8] := 31;\n mas[9] := 30;\n mas[10] := 31;\n mas[11] := 30;\n mas[12] := 31;\nend;\n\nbegin\n {reset(input, 'in.in');\n rewrite(output, 'out.out'); }\n\n readln(s);\n Cnt_1;\n readln(s);\n Cnt_2;\n Filling;\n Min_max;\n k := 0;\n while (year_1 <> year_2) or (m_1 <> m_2) or (day_1 <> day_2) do\n begin\n If ((year_1 mod 4 = 0) and (year_1 mod 100 <> 0)) or ((year_1 mod 100 = 0) and (year_1 mod 400 = 0)) then\n mas[2] := 29\n else\n mas[2] := 28;\n Inc(k);\n Inc(day_1);\n If (mas[m_1] < day_1) then begin\n day_1 := 1;\n Inc(m_1);\n end;\n If (m_1 > 12) then begin\n m_1 := 1;\n Inc(year_1);\n end;\n end;\n writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\nconst\n month : array[1..12] of integer = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nvar\n date1, date2 : string;\n i, res, year1, year2, day1, day2, month1, month2 : integer;\n\nprocedure swap(var a, b : integer);\nvar\n t : integer;\nbegin\n t := a;\n a := b;\n b := t;\nend;\n\nfunction isfuck(a : integer) : boolean;\nbegin\n result := (a mod 400 = 0) or ((a mod 4 = 0) and (a mod 100 > 0));\nend;\n\nbegin\n readln(date1);\n readln(date2);\n res := 0;\n year1 := strtoint(copy(date1, 1, 4));\n year2 := strtoint(copy(date2, 1, 4));\n month1 := strtoint(copy(date1, 6, 2));\n month2 := strtoint(copy(date2, 6, 2));\n day1 := strtoint(copy(date1, 9, 2)); \n day2 := strtoint(copy(date2, 9, 2));\n if (year1 > year2) or ((year1 = year2) and (month1 > month2)) or ((year1 = year2) and (month1 = month2) and (day1 > day2)) then begin\n swap(year1, year2);\n swap(day1, day2);\n swap(month1, month2);\n end;\n for i := year1 + 1 to year2 - 1 do\n if isfuck(i) then\n inc(res, 366)\n else\n inc(res, 365);\n if (year1 < year2) then begin\n for i := month1 + 1 to 12 do\n if (i = 2) then\n if (isfuck(year1)) then\n inc(res, 29)\n else\n inc(res, 28)\n else\n inc(res, month[i]);\n for i := 1 to month2 - 1 do\n if (i = 2) then\n if (isfuck(year2)) then\n inc(res, 29)\n else\n inc(res, 28)\n else\n inc(res, month[i]);\n if (month1 = 2) then\n if (isfuck(year1)) then\n inc(res, 30 - day1)\n else\n inc(res, 29 - day1)\n else\n inc(res, month[month1] + 1 - day1);\n inc(res, day2);\n end else\n if (month1 < month2) then begin\n for i := month1 + 1 to month2 - 1 do\n if (i = 2) then\n if (isfuck(year1)) then\n inc(res, 29)\n else\n inc(res, 28)\n else\n inc(res, month[i]);\n if (month1 = 2) then\n if (isfuck(year1)) then\n inc(res, 30 - day1)\n else\n inc(res, 29 - day1)\n else\n inc(res, month[month1] + 1 - day1);\n inc(res, day2);\n end else\n inc(res, day2 - day1 + 1);\n writeln(res - 1);\nend.\n"}, {"source_code": "const month:array[0..12] of longint=(0,31,28,31,30,31,30,31,31,30,31,30,31) ;\nvar s1,s2,st:string ;\n month1,month2,year1,year2,day1,day2:longint ;\n k,i,sum1,sum2:longint ;flag:longint ;\nfunction judge1(x:longint):boolean ;\nbegin \n if (x mod 4=0) and (x mod 100<>0) or (x mod 400=0) then exit(true) ;\n exit(false) ;\nend;\nbegin \n readln(s1) ;\n k:=pos(':',s1) ;st:=copy(s1,1,k-1) ;val(st,year1) ;\n delete(s1,1,k) ;k:=pos(':',s1) ;st:=copy(s1,1,k-1) ;\n val(st,month1) ;delete(s1,1,k) ;val(s1,day1) ;\n readln(s2) ;\n k:=pos(':',s2) ;st:=copy(s2,1,k-1) ;val(st,year2) ;\n delete(s2,1,k) ;k:=pos(':',s2) ;st:=copy(s2,1,k-1) ;\n val(st,month2) ;delete(s2,1,k) ;val(s2,day2) ;\n for i:=1 to year1-1 do \n begin \n if judge1(i) then inc(flag) ;\n end;\n sum1:=365*(year1-1)+flag ;\n for i:=1 to month1-1 do \n begin \n sum1:=sum1+month[i] ;\n end;\n if (judge1(year1)) and (month1>2) then inc(sum1) ;\n sum1:=sum1+day1 ;\n flag:=0 ;\n for i:=1 to year2-1 do \n begin \n if judge1(i) then inc(flag);\n end;\n sum2:=sum2+365*(year2-1)+flag ;\n for i:=1 to month2-1 do \n begin \n sum2:=sum2+month[i] ;\n end;\n if judge1(year2) and (month2>2) then sum2:=sum2+1 ;\n sum2:=sum2+day2 ;\n writeln(abs(sum1-sum2)) ;\nend."}, {"source_code": "const dayofm:array[1..12]of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar a,b:string;\n i,d1,d2,m1,m2,y1,y2:integer;\nprocedure solve;\nvar tmp:integer;ans:longint;\n begin\n ans:=0;\n if a>b then\n begin\n tmp:=y1;y1:=y2;y2:=tmp;\n tmp:=m1;m1:=m2;m2:=tmp;\n tmp:=d1;d1:=d2;d2:=tmp;\n end;\n for i:=1 to m1-1 do\n begin\n if ((i=2) and (((y1 mod 4=0) and (y1 mod 100<>0))or (y1 mod 400=0))) then ans:=ans-29\n else ans:=ans-dayofm[i];\n end;\n ans:=ans-d1;\n for i:=y1 to y2 do if\n (((i mod 4=0) and (i mod 100<>0))or (i mod 400=0)) then ans:=ans+366 else ans:=ans+365;\n for i:=m2 to 12 do\n begin\n if ((i=2) and (((y2 mod 4=0) and (y2 mod 100<>0))or (y2 mod 400=0))) then ans:=ans-29\n else ans:=ans-dayofm[i];\n end;\n ans:=ans+d2;\n write(ans);\n end;\nbegin\nreadln(a);\nfor i:=1 to 4 do y1:=10*y1+ord(a[i])-48;\nfor i:=6 to 7 do m1:=10*m1+ord(a[i])-48;\nfor i:=9 to 10 do d1:=10*d1+ord(a[i])-48;\nreadln(b);\nfor i:=1 to 4 do y2:=10*y2+ord(b[i])-48;\nfor i:=6 to 7 do m2:=10*m2+ord(b[i])-48;\nfor i:=9 to 10 do d2:=10*d2+ord(b[i])-48;\nsolve;\nend.\n"}, {"source_code": "{$mode objfpc}\nprogram b;\nvar\n s1,s2,y1,y2,m1,m2,d1,d2:string;\n year1,year2,month1,month2,date1,date2,v:longint;\n count:qword;\n mo:array[1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s1);\n readln(s2);\n count:=0;\n y1:=copy(s1,1,4);m1:=copy(s1,6,2);d1:=copy(s1,9,2);\n y2:=copy(s2,1,4);m2:=copy(s2,6,2);d2:=copy(s2,9,2);\n val(y1,year1,v);val(m1,month1,v);val(d1,date1,v);\n val(y2,year2,v);val(m2,month2,v);val(d2,date2,v);\n if s1=s2 then writeln//(0)\n else\n if s2>s1 then\n begin\n repeat\n if (year1 mod 400=0) or ((year1 mod 4 = 0)and (year1 mod 100 <>0)) then\n begin\n mo[2]:=29;\n inc(date1);\n if date1>mo[month1] then\n begin\n inc(month1);\n date1:=1;\n end;\n if month1>12 then\n begin\n inc(year1);\n month1:=1;\n end;\n inc(count);\n end\n else\n begin\n mo[2]:=28;\n inc(date1);\n if date1>mo[month1] then\n begin\n inc(month1);\n date1:=1;\n end;\n if month1>12 then\n begin\n inc(year1);\n month1:=1;\n end;\n inc(count);\n end;\n until (date1=date2) and (month1=month2) and (year1=year2);\n end\n else\n begin\n repeat\n if (year2 mod 400=0) or ((year2 mod 4 = 0)and (year2 mod 100 <>0)) then\n begin\n mo[2]:=29;\n inc(date2);\n if date2>mo[month2] then\n begin\n inc(month2);\n date2:=1;\n end;\n if month2>12 then\n begin\n inc(year2);\n month2:=1;\n end;\n inc(count);\n end\n else\n begin\n mo[2]:=28;\n inc(date2);\n if date2>mo[month2] then\n begin\n inc(month2);\n date2:=1;\n end;\n if month2>12 then\n begin\n inc(year2);\n month2:=1;\n end;\n inc(count);\n end;\n until (date1=date2) and (month1=month2) and (year1=year2);\n end;\n writeln(count);\nend."}, {"source_code": "program B304;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n a:array[1..12] of integer;\n i,g,m,d,g1,m1,d1,c,j,sum:integer;\nprocedure obmen;\n var\n c:integer;\n begin\n c:=g; g:=g1; g1:=c;\n c:=m; m:=m1; m1:=c;\n c:=d; d:=d1; d1:=c;\n end;\nbegin\n readln(s);\n readln(s1);\n a[1]:=31; a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30;\n a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31;\n val(s,g,c); delete(s,1,5);\n val(s,m,c); delete(s,1,3);\n val(s,d,c);\n val(s1,g1,c); delete(s1,1,5);\n val(s1,m1,c); delete(s1,1,3);\n val(s1,d1,c);\n if g10))or(i mod 400=0) then\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=2 then inc(sum,a[m]+1-d)\n else inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); if m=2 then inc(sum,a[m]+1-d)\n else inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,366);\n end\n else\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,365);\n end;\n writeln(sum);\n readln; readln;\nend.\n"}, {"source_code": "var s1,s2,s: string;\n\nProcedure ReadDate(s: string; var d,m,y: longint);\nvar i: byte;\nbegin\n\n d:=(ord(s[9])-48)*10 + (ord(s[10])-48);\n m:=(ord(s[6])-48)*10 + (ord(s[7])-48);\n y:=0;\n for i:=1 to 4 do\n y:=y*10 + (ord(s[i])-48);\nend;\n\n\nvar d1,m1,y1,d2,m2,y2,k: longint;\n m: array[1..12] of byte;\nbegin\n{ assign(input,'input.txt');reset(input);\n}\n m[1]:=31; m[2]:=28; m[3]:=31; m[4]:=30; m[5]:=31; m[6]:=30;\n m[7]:=31; m[8]:=31; m[9]:=30; m[10]:=31; m[11]:=30; m[12]:=31;\n\n readln(s1); readln(s2); \n if s2>s1 then begin s:=s1; s1:=s2; s2:=s end;\n\n ReadDate(s1,d1,m1,y1); ReadDate(s2,d2,m2,y2);\n\n if (y2 mod 400 = 0) or (y2 mod 4 = 0) and (y2 mod 100 <> 0) then m[2]:=29;\n k:=0;\n while not ((d1=d2) and (m1=m2) and (y1=y2)) do\n begin\n if d2=m[m2]\n then begin\n m2:=m2 mod 12 + 1;\n d2:=0;\n if m2=1\n then begin\n inc(y2);\n if (y2 mod 400 = 0) or\n (y2 mod 4 = 0) and (y2 mod 100 <> 0)\n then m[2]:=29 else m[2]:=28;\n end\n end;\n inc(d2);\n inc(k);\n end;\n\n writeln(k)\nend."}, {"source_code": "uses math,sysutils,DateUtils;\nvar r,kol,xv,l,d,res,min1,z,j,max1,l1:integer;x3,y3,x1,y1,x2,y2,x,y,i,k:integer;\n ch:char;s,s1,ss:string;e,code,n,e1,c,g,g1,h,h1,m,m1:integer;u:boolean;\n v,v1:real;a,b:TDateTime;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n readln(s);\n val(copy(s,1,4),g,code);\n val(copy(s,6,2),h,code);\n val(copy(s,9,2),m,code);\n readln(s);\n val(copy(s,1,4),g1,code);\n val(copy(s,6,2),h1,code);\n val(copy(s,9,2),m1,code);\n a:=EncodeDateTime(g,h,m,0, 0, 0, 0);\n b:=EncodeDateTime(g1,h1,m1,0, 0, 0, 0);\n writeln(daysbetween(a,b));\nend.\n"}, {"source_code": "program Project666;\n\n{$APPTYPE CONSOLE}\n\nuses math,sysutils;\n\n\n var m: integer;\n i,j: integer;\n y1,m1,d1,y2,m2,d2,d: integer;\n date1,date2,s: string;\n a: array[1..12] of integer;\n\n function substr(s: string; n,m: integer):integer;\n var str: string;\n i: integer;\n a,d: integer;\n begin\n d := 1;\n a := 0;\n for i := m downto n do\n begin\n // writeln(a);\n a := a + ( StrToInt(s[i]) * d );\n d := d*10;\n end;\n substr := a;\n end;\n\nbegin\n \n\n a[1] := 31;\n a[2] := 28;\n a[3] := 31;\n a[4] := 30;\n a[5] := 31;\n a[6] := 30;\n a[7] := 31;\n a[8] := 31;\n a[9] := 30;\n a[10] := 31;\n a[11] := 30;\n a[12] := 31;\n\n readln(date1);\n readln(date2);\n\n y1 := substr(date1,1,4);\n y2 := substr(date2,1,4);\n\n m1 := substr(date1,6,7);\n m2 := substr(date2,6,7);\n\n d1 := substr(date1,9,10);\n d2 := substr(date2,9,10);\n\n if y1 > y2 then\n begin\n d := y1;\n y1 := y2;\n y2 := d;\n\n d := m1;\n m1 := m2;\n m2 := d;\n\n d := d1;\n d1 := d2;\n d2 := d;\n\n end;\n\n if ( y1 = y2 ) and (m1 > m2) then\n begin\n\n\n d := m1;\n m1 := m2;\n m2 := d;\n\n d := d1;\n d1 := d2;\n d2 := d;\n\n end;\n\n if ( y1 = y2 ) and (m1 = m2) and (d1 > d2) then\n begin\n\n\n d := d1;\n d1 := d2;\n d2 := d;\n\n end;\n\n\n\n d := 0;\n\n for i := y1 to y2-1 do\n if (i MOD 4 = 0) and ( i MOD 100 <> 0 ) then\n d := d + 366\n else if (i MOD 4 = 0) and ( i MOD 400 = 0 ) then\n d := d + 366\n else d := d + 365;\n\n for i := 2 to m1 do\n if (i = 3) then\n begin\n d := d - 28;\n if (y1 MOD 4 = 0) and (y1 MOD 100 <> 0)\n or (y1 MOD 4 = 0) and (y1 MOD 400 = 0) then\n d := d-1;\n end\n else\n d := d - a[i-1];\n\n\n for i := 2 to m2 do\n if (i = 3) then\n begin\n d := d + 28;\n if (y2 MOD 4 = 0) and (y2 MOD 100 <> 0)\n or (y2 MOD 4 = 0) and (y2 MOD 400 = 0) then\n d := d+1;\n end\n else\n d := d + a[i-1];\n\n\n d := d - d1 + d2;\n\n write(d);\n\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n if ans=6 then ans:=5;\n writeln(ans);\nend.\n//!!!```"}, {"source_code": "program z1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i,j: longint;\n a: array[1900..2038] of longint;\n s1,s2: string;\n\nfunction dtoch(s: string): longint;\nvar d,m,g,ans: longint;\nbegin\n g:=strtoint(copy(s,1,4));\n ans:=a[g];\n m:=strtoint(copy(s,6,2));\n if m>1 then ans:=ans+31;\n if m>2 then begin if ((g mod 4=0) and (g mod 100<>0)) or (( g mod 1000 mod 400=0 ) ) then ans:=ans+29 else ans:=ans+28; end;\n if m>3 then ans:=ans+31;\n if m>4 then ans:=ans+30;\n if m>5 then ans:=ans+31;\n if m>6 then ans:=ans+30;\n if m>7 then ans:=ans+31;\n if m>8 then ans:=ans+31;\n if m>9 then ans:=ans+30;\n if m>10 then ans:=ans+31;\n if m>11 then ans:=ans+30;\n d:=strtoint(copy(s,9,2));\n ans:=ans+d;\n dtoch:=ans;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);\n readln(s1);\n readln(s2);\n\n a[1900]:=0;\n\n for i:=1901 to 2038 do\n if (( (i-1) mod 4=0) and ( (i-1) mod 100<>0)) or (( (i-1) mod 1000 mod 400=0 ) ) then a[i]:=a[i-1]+366 else a[i]:=a[i-1]+365;\n\n writeln(abs(dtoch(s1)-dtoch(s2)));\n\nend.\n "}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar n1,n,m,dl,kol,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish:longint;\ncc,dd,t,chisl,znam,ot,aa,bb,x0,y0,ll,rr,d1,d2,rad,yy1,xx1,xx2,q,xx,yy,t1,t2,p,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\nkolday,b,a,c:array[-10..2000000] of int64;\n\nx1,y1,z1,z,gr,x,y: array[-10..50000] of double;\nvisok,zan: array[-10..11000] of boolean;\nee,ww,nn,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss:string;\nch11,ch12,ch1,ch:char;\nsl,sr,stoim,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction deg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then deg:=1 else if odd(k) then deg:=deg(a,k-1)*a mod modul else\n begin p:=deg(a,k div 2); deg:=p*p mod modul; end;\n\nend;\n\nfunction koldday(god,mon,day:int64):int64; var ot,i,j,k:longint;\nbegin\n ot:=0;\nfor i:=1900 to god-1 do for j:=1 to 12 do ot:=ot+kolday[j];\nfor i:=1900 to god-1 do if visok[i] then inc(ot);\nfor i:=1 to mon-1 do ot:=ot+kolday[i];\nif visok[god] and(mon>2) then inc(ot);\not:=ot+day;\nkoldday:=ot;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n\nfor i:=1 to 4 do read(ssot[i]);\nfor i:=1 to 4 do god1:=10*god1+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do mon1:=10*mon1+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do day1:=10*day1+(ord(ssot[i])-48);\nreadln;\n{writeln(god1);\nwriteln(mon1);\nwriteln(day1);\n}\nfor i:=1 to 4 do read(ssot[i]);\nfor i:=1 to 4 do god2:=10*god2+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do mon2:=10*mon2+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do day2:=10*day2+(ord(ssot[i])-48);\nreadln;\n{writeln(god2);\nwriteln(mon2);\nwriteln(day2);\n}\nfor i:=0 to 2000 do visok[4*i]:=true;\nvisok[1900]:=false;\n{for i:=1890 to 2050 do if visok[i] then write(i,' ');writeln;\n}\nkolday[1]:=31;\nkolday[2]:=28;\nkolday[3]:=31;\n\nkolday[4]:=30;\nkolday[5]:=31;\nkolday[6]:=30;\n\nkolday[7]:=31;\nkolday[8]:=31;\nkolday[9]:=30;\n\nkolday[10]:=31;\nkolday[11]:=30;\nkolday[12]:=31;\n\n{ for i:=1900 to 1906 do for j:=1 to 12 do for k:=1 to 31 do\n writeln(i,' ',j,' ',k,' ',koldday(i,j,k));\n}\n\n writeln(abs(koldday(god1,mon1,day1)-koldday(god2,mon2,day2)));\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s1, s2: string;\n d1, d2, m1, m2, y1, y2: integer;\n\nfunction isBig(n: integer):boolean;\nbegin\n if (n mod 400 = 0) or ((n mod 4 = 0) and (n mod 100 <> 0)) then\n result := true\n else\n result := false;\nend;\n \nfunction CheckDay(day, month, year: integer): boolean;\nbegin\n if ((day > 30) and (month in [2,4,6,9,11])) or\n ((day > 29) and (month = 2)) or\n ((day > 28) and (month = 2) and (not isBig(year))) then\n result := false\n else\n result := true;\nend;\n\nfunction DaysFromZero(y, m, d: integer): integer;\nvar\n yn, dn, mn: integer;\nbegin\n yn := 1899;\n dn := 1;\n mn := 1;\n\n result := 0;\n while true do begin\n inc(result);\n inc(dn);\n if (dn > 31) or not CheckDay(dn, mn, yn) then begin\n dn := 1;\n inc(mn);\n end;\n if mn > 12 then begin\n mn := 1;\n dn := 1;\n inc(yn);\n end;\n if (dn = d) and (yn = y) and (mn = m) then break;\n end;\nend;\n\nbegin\n //reset(input, 'a.in');\n //rewrite(output, 'a.out');\n readln(s1);\n y1 := strtoint(copy(s1, 1, 4));\n m1 := strtoint(copy(s1, 6, 2));\n d1 := strtoint(copy(s1, 9, 2));\n readln(s2);\n y2 := strtoint(copy(s2, 1, 4));\n m2 := strtoint(copy(s2, 6, 2));\n d2 := strtoint(copy(s2, 9, 2));\n //writeln(DaysFromZero(y1, m1, d1));\n //writeln(DaysFromZero(y2, m2, d2));\n writeln(abs(DaysFromZero(y1, m1, d1) - DaysFromZero(y2, m2, d2)));\nend.\n"}, {"source_code": "program z1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nconst\nny:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvy:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\n\nfunction vis(x:longint):boolean;\nbegin\n if (x mod 100=0) and (x mod 400=0) or (x mod 100<>0) and (x mod 4=0) then vis:=true else vis:=false;\nend;\n\nvar\nss,s1,s2:string;\ni,k,m1,m2,d1,d2,y1,y2:longint;\nbegin\n//assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);\nreadln(s1); readln(s2);\nif s1>s2 then begin ss:=s1; s1:=s2; s2:=ss end;\ny1:=strtoint(copy(s1,1,4)); y2:=strtoint(copy(s2,1,4));\nm1:=strtoint(copy(s1,6,2)); m2:=strtoint(copy(s2,6,2));\nd1:=strtoint(copy(s1,9,2)); d2:=strtoint(copy(s2,9,2));\n\nk:=0;\nif vis(y1) then\nbegin\n for i:=1 to m1-1 do k:=k+vy[i];\n k:=k+d1;\n k:=366-k;\nend\nelse\nbegin\n for i:=1 to m1-1 do k:=k+ny[i];\n k:=k+d1;\n k:=365-k;\nend;\n\n\nif vis(y2) then\nbegin\n for i:=1 to m2-1 do k:=k+vy[i];\n k:=k+d2;\nend\nelse\nbegin\n for i:=1 to m2-1 do k:=k+ny[i];\n k:=k+d2;\nend;\n\n\nif y1=y2 then begin\nif vis(y1) then k:=k-366 else k:=k-365;\nend;\n\ninc(y1); dec(y2);\nfor i:=y1 to y2 do if vis(i) then k:=k+366 else k:=k+365;\nwriteln(k); \nend.\n"}, {"source_code": "uses SysUtils, DateUtils;\nvar s1,s2:string;\ny1,m1,d1,y2,m2,d2:longint;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n readln(s1);\n readln(s2);\n y1 := StrToInt(Copy(s1, 1, 4));\n m1 := StrToInt(Copy(s1, 6, 2));\n d1 := StrToInt(Copy(s1, 9, 2));\n y2 := StrToInt(Copy(s2, 1, 4));\n m2 := StrToInt(Copy(s2, 6, 2));\n d2 := StrToInt(Copy(s2, 9, 2));\n Writeln(DaysBetween(EncodeDateTime(y1, m1, d1, 0, 0, 0, 0), EncodeDateTime(y2, m2, d2, 0, 0, 0, 0)));\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils,\n Math;\n\nvar\n s1, s2: string;\n f, y1, y2, d1, d2, m1, m2, ans: integer;\n\nfunction vis(x: integer): boolean;\nbegin\n vis := ((x mod 4 = 0) and (x mod 100 <> 0)) or (x mod 400 = 0);\nend;\n\nprocedure make(s: string; var a, b, c: integer);\nbegin\n a := strtoint(s[1] + s[2] + s[3] + s[4]);\n b := strtoint(s[6] + s[7]);\n c := strtoint(s[9] + s[10]);\nend;\n\nprocedure swap(var a, b: integer);\nvar\n c: integer;\nbegin\n c := a;\n a := b;\n b := c;\nend;\n\nfunction endm(x, y: integer): integer;\nbegin\n case x of\n 1, 3, 5, 7, 8, 10, 12: endm := 31;\n 4, 6, 9, 11: endm := 30;\n 2: if vis(y) then endm := 29 else endm := 28;\n end;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(s1);\n read(s2);\n make(s1, y1, m1, d1);\n make(s2, y2, m2, d2);\n if y1 > y2 then begin\n swap(y1, y2);\n swap(m1, m2);\n swap(d1, d2);\n end;\n if (y1 = y2) and (m1 > m2) then begin\n swap(m1, m2);\n swap(d1, d2);\n end;\n if (y1 = y2) and (m1 = m2) and (d1 > d2) then\n swap(d1, d2);\n ans := 0;\n f := endm(m1, y1);\n while y1 <> y2 do begin\n if d1 = f then begin\n if m1 = 12 then begin\n inc(y1);\n m1 := 1;\n f := endm(m1, y1);\n d1 := 1;\n inc(ans);\n continue;\n end;\n inc(m1);\n f := endm(m1, y1);\n d1 := 1;\n inc(ans);\n continue;\n end;\n inc(d1);\n inc(ans);\n end;\n while m1 <> m2 do begin\n if d1 = f then begin\n if m1 = 12 then begin\n inc(y1);\n m1 := 1;\n f := endm(m1, y1);\n d1 := 1;\n inc(ans);\n continue;\n end;\n inc(m1);\n f := endm(m1, y1);\n d1 := 1;\n inc(ans);\n continue;\n end;\n inc(d1);\n inc(ans);\n end;\n inc(ans, d2 - d1);\n write(ans);\nend.\n"}, {"source_code": "var\ns1,s2,s,ss:string;\nans:integer;\ni,j,n,m,k,t,l,r,tek,kol,c,ch,code,g1,m1,d1,g2,m2,d2:integer;\nmes:array[0..12] of integer;\nbegin\nreadln(s1);\nreadln(s2);\nif (s1>s2) then begin\ns:=s1;\ns1:=s2;\ns2:=s;\nend;\ns:=copy(s1,1,4);\nval(s,g1,code);\ndelete(s1,1,5);\ns:=copy(s1,1,2);\nval(s,m1,code);\ndelete(s1,1,3);\nval(s1,d1,code);\n\ns:=copy(s2,1,4);\nval(s,g2,code);\ndelete(s2,1,5);\ns:=copy(s2,1,2);\nval(s,m2,code);\ndelete(s2,1,3);\nval(s2,d2,code);\n\nmes[1]:=31;\nmes[2]:=28;\nmes[3]:=31;\nmes[4]:=30;\nmes[5]:=31;\nmes[6]:=30;\nmes[7]:=31;\nmes[8]:=31;\nmes[9]:=30;\nmes[10]:=31;\nmes[11]:=30;\nmes[12]:=31;\n\nans:=0;\n\nwhile(g1<>g2) or (m1<>m2) or (d1<>d2) do begin\nif((g1 mod 4 =0) and (g1 mod 100 <> 0)) or (g1 mod 400=0)\nthen mes[2]:=29\nelse\nmes[2]:=28;\ninc(ans);\ninc(d1);\nif(d1>mes[m1]) then begin d1:=1; inc(m1); end;\nif (m1>12) then begin m1:=1; inc(g1); end;\nend;\nwriteln(ans);\nend."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n r:Array[1..12] of Integer=(31,28,31,30,31,30,31,31,30,31,30,31);\n s1,s2:String;\n y1,m1,d1,y2,m2,d2,ans:Integer;\nProcedure Swap(Var x,y:Integer);\nVar t:Integer;\nBegin\n t:=x;\n x:=y;\n y:=t;\nEnd;\nBegin\n ReadLn(s1);\n Read(s2);\n y1:=strtoint(s1[1]+s1[2]+s1[3]+s1[4]);\n m1:=strtoint(s1[6]+s1[7]);\n d1:=strtoint(s1[9]+s1[10]);\n y2:=strtoint(s2[1]+s2[2]+s2[3]+s2[4]);\n m2:=strtoint(s2[6]+s2[7]);\n d2:=strtoint(s2[9]+s2[10]);\n If (y1>y2) or ((y1=y2) and (m1>m2)) or ((y1=y2) and (m1=m2) and (d1>d2)) Then Begin\n Swap(y1,y2);\n Swap(m1,m2);\n Swap(d1,d2);\n End;\n ans:=0;\n While True Do Begin\n If (y1=y2) and (d1=d2) and (m1=m2) Then Break;\n ans:=ans+1;\n If (d1=29) and (m1=2) Then Begin\n m1:=m1+1;\n d1:=1;\n Continue;\n End;\n If d1=r[m1] Then Begin\n If (m1=2) and (d1=28) and ((y1 mod 4=0) and ((y1 mod 100<>0) or (y1 mod 400=0))) Then d1:=d1+1\n Else Begin\n If m1=12 Then Begin\n y1:=y1+1;\n m1:=1;\n d1:=1;\n End\n Else Begin\n m1:=m1+1;\n d1:=1;\n End;\n End;\n End\n Else d1:=d1+1;\n End;\n Write(ans);\nEnd.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, DateUtils;\n\nvar\n s1, s2: string;\n y1, m1, d1, y2, m2, d2: integer;\n\nbegin\n readln(s1);\n readln(s2);\n\n y1 := StrToInt(Copy(s1, 1, 4));\n m1 := StrToInt(Copy(s1, 6, 2));\n d1 := StrToInt(Copy(s1, 9, 2));\n\n y2 := StrToInt(Copy(s2, 1, 4));\n m2 := StrToInt(Copy(s2, 6, 2));\n d2 := StrToInt(Copy(s2, 9, 2));\n\n WriteLn(DaysBetween(EncodeDateTime(y1, m1, d1, 0, 0, 0, 0), EncodeDateTime(y2, m2, d2, 0, 0, 0, 0)));\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n //f:text;\n //i,j,n,m,k:longint;\n g1,m1,d1,g2,m2,d2,code,d,m,g,ans:integer;\n s1,s2,s:string;\n mn:array[1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\n procedure swap(var a,b:string);\n var\n c:string;\n begin\n c:=a;\n a:=b;\n b:=c;\n end;\n\n function year(x:integer):boolean;\n begin\n if (x mod 4)<>0 then begin year:=false; exit; end;\n if (((x mod 100)=0)and((x mod 400)=0))or((x mod 100)<>0) then begin year:=true; exit; end;\n year:=false;\n end;\n\nbegin\n//assign(f,in_file); reset(in_file);\n//close(in_file);\n readln(s1);\n readln(s2);\n if (s20))\n then Prov:=1\n else Prov:=0;\nend;\nProcedure Swith;\nVar I:Integer;\nbegin\n I:=Y1;\n Y1:=Y;\n Y:=I;\n I:=M1;\n M1:=M;\n M:=I;\n I:=D1;\n D1:=D;\n D:=I;\nend;\nBegin\n ///reset(input,'INPUT.TXT');\n ///assign(output,'OUTPUT.TXT');\n readln(S);\n Y:=StrToInt(Copy(S,1,4));\n Delete(S,1,5);\n M:=StrToInt(Copy(S,1,2));\n Delete(S,1,3);\n D:=StrToInt(Copy(S,1,2));\n readln(S);\n Y1:=StrToInt(Copy(S,1,4));\n Delete(S,1,5);\n M1:=StrToInt(Copy(S,1,2));\n Delete(S,1,3);\n D1:=StrToInt(Copy(S,1,2));\n If Y>Y1\n then Swith\n else If Y=Y1\n then If M>M1\n then Swith\n else If M=M1\n then If D>D1\n then Swith;\n K:=0;\n f:=Prov;\n If D112\n then begin\n M:=1;\n Inc(Y);\n f:=Prov;\n end;\n end\n else begin\n K:=D1-D+1;\n D:=D1;\n end;\n If (D=D1) and (M=M1) and (Y=Y1)\n then write(K-1)\n else begin\n Repeat\n K:=K+mas[f,M];\n Inc(M);\n If M>12\n then begin\n M:=1;\n Inc(Y);\n f:=Prov;\n end;\n Until (D=D1) and (M=M1) and (Y=Y1);\n write(K-1);\n end;\nEnd.\n"}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar n1,n,m,dl,kol,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish:longint;\ncc,dd,t,chisl,znam,ot,aa,bb,x0,y0,ll,rr,d1,d2,rad,yy1,xx1,xx2,q,xx,yy,t1,t2,p,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\nkolday,b,a,c:array[-10..2000000] of int64;\n\nx1,y1,z1,z,gr,x,y: array[-10..50000] of double;\nvisok,zan: array[-10..11000] of boolean;\nee,ww,nn,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss:string;\nch11,ch12,ch1,ch:char;\nsl,sr,stoim,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction deg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then deg:=1 else if odd(k) then deg:=deg(a,k-1)*a mod modul else\n begin p:=deg(a,k div 2); deg:=p*p mod modul; end;\n\nend;\n\nfunction koldday(god,mon,day:int64):int64; var ot,i,j,k:longint;\nbegin\n ot:=0;\nfor i:=1900 to god-1 do for j:=1 to 12 do ot:=ot+kolday[j];\nfor i:=1900 to god-1 do if visok[i] then inc(ot);\nfor i:=1 to mon-1 do ot:=ot+kolday[i];\nif visok[god] and(mon>2) then inc(ot);\not:=ot+day;\nkoldday:=ot;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n\nfor i:=1 to 4 do read(ssot[i]);\nfor i:=1 to 4 do god1:=10*god1+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do mon1:=10*mon1+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do day1:=10*day1+(ord(ssot[i])-48);\nreadln;\n{writeln(god1);\nwriteln(mon1);\nwriteln(day1);\n}\nfor i:=1 to 4 do read(ssot[i]);\nfor i:=1 to 4 do god2:=10*god2+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do mon2:=10*mon2+(ord(ssot[i])-48);\nread(ch);\nfor i:=1 to 2 do read(ssot[i]);\nfor i:=1 to 2 do day2:=10*day2+(ord(ssot[i])-48);\nreadln;\n{writeln(god2);\nwriteln(mon2);\nwriteln(day2);\n}\nfor i:=0 to 2000 do visok[4*i]:=true;\nvisok[1900]:=false;\n{for i:=1890 to 2050 do if visok[i] then write(i,' ');writeln;\n}\nkolday[1]:=31;\nkolday[2]:=28;\nkolday[3]:=31;\n\nkolday[4]:=30;\nkolday[5]:=31;\nkolday[6]:=30;\n\nkolday[7]:=31;\nkolday[8]:=31;\nkolday[9]:=30;\n\nkolday[10]:=31;\nkolday[11]:=30;\nkolday[12]:=31;\n\n{ for i:=1900 to 1906 do for j:=1 to 12 do for k:=1 to 31 do\n writeln(i,' ',j,' ',k,' ',koldday(i,j,k));\n}\n\n writeln(abs(koldday(god1,mon1,day1)-koldday(god2,mon2,day2)));\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "function IsLeapYear(Year: Integer): Boolean;\nbegin\n IsLeapYear := (Year mod 4 = 0)\n and (Year mod 4000 <> 0) and\n ((Year mod 100 <> 0) or (Year mod 400 = 0));\nend;\n\n\nfunction DaysInMonth(Month, Year: Integer): Integer;\nbegin\n case Month of\n 1, 3, 5, 7, 8, 10, 12:\n DaysInMonth := 31;\n 4, 6, 9, 11:\n DaysInMonth := 30;\n 2:\n DaysInMonth := 28 + Ord(IsLeapYear(Year));\n else\n DaysInMonth := 0;\n end;\nend;\n\n\nfunction Date2julian(pDay, pMonth, pYear: integer): longint;\nvar\n month, day, year: longint;\n ta, tb, tc: longint;\nbegin\n month := pMonth;\n day := pDay;\n year := pYear;\n if month > 2 then\n month := month - 3\n else\n begin\n month := month + 9;\n year := year - 1;\n end;\n ta := 146097 * (year div 100) div 4;\n tb := 1461 * (year mod 100) div 4;\n tc := (153 * month + 2) div 5 + day + 1721119;\n Date2julian := ta + tb + tc\nend;\n\nfunction DaysBetween(Day1, Month1, Year1, Day2, Month2, Year2: integer): integer;\nvar D1, D2: longint;\nbegin\n D1 := Date2julian(Day1, Month1, Year1);\n D2 := Date2julian(Day2, Month2, Year2);\n if D1 > D2 then\n DaysBetween := D1 - D2\n else\n DaysBetween := D2 - D1;\nend;\n\n\nvar\n a1, b1, c1, a2, b2, c2,err: integer;\n a,b:string;\nbegin\n \n readln(a);\n readln(b);\n \n val(copy(a,1,4),c1,err);\n val(copy(a,6,2),b1,err);\n val(copy(a,9,2),a1,err);\n \n val(copy(b,1,4),c2,err);\n val(copy(b,6,2),b2,err);\n val(copy(b,9,2),a2,err);\n \n Writeln(DaysBetween(a1, b1, c1, a2, b2, c2));\n \nend."}, {"source_code": "const haribulan: array [1..12] of longint = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nvar\n jumlahhari,bedatahun:longint;\nfunction convert(y,m,d : longint) : longint;\nvar\n a:longint;\nbegin\n jumlahhari:= 0;\n bedatahun:= y-1900;\n if bedatahun>0 then jumlahhari:= bedatahun*365 + ((bedatahun-1) div 4);\n for a:= 1 to m do inc(jumlahhari, haribulan[a]);\n if (y mod 4=0) and (y<>1900) and (m>2) then inc(jumlahhari);\n jumlahhari:=jumlahhari+d;\n jumlahhari:=jumlahhari-haribulan[m];\nend;\n\n\nvar\n arr2 : array [1..1000] of string ;arr:array[1..1000] of longint;\n s,s2,kal:string;\n tahun,tahun2,bulan,bulan2,hari,hari2,a,kode,x,y:longint;\nbegin\n readln(s);\n for a:= 1 to 4 do begin\n arr2[a] := s[a];\n val(arr2[a],arr[a],kode);\n end;\n tahun:= arr[1]*1000 + arr[2] * 100 + arr[3] *10 + arr[4];\n for a:= 6 to 7 do begin\n arr2[a]:= s[a];\n val(arr2[a],arr[a],kode);\n end;\n bulan:= arr[6] * 10 + arr[7];\n for a:= 9 to 10 do begin\n arr2[a]:= s[a];\n val(arr2[a],arr[a],kode);\n end;\n hari:= arr[9]*10 + arr[10];\n\n convert(tahun,bulan,hari);\n x:=jumlahhari;\n\n readln(s2);\n for a:= 1 to 4 do begin\n arr2[a] := s2[a];\n val(arr2[a],arr[a],kode);\n end;\n tahun2:= arr[1]*1000 + arr[2] * 100 + arr[3] *10 + arr[4];\n for a:= 6 to 7 do begin\n arr2[a]:= s2[a];\n val(arr2[a],arr[a],kode);\n end;\n bulan2:= arr[6] * 10 + arr[7];\n for a:= 9 to 10 do begin\n arr2[a]:= s2[a];\n val(arr2[a],arr[a],kode);\n end;\n hari2:= arr[9]*10 + arr[10];\n\n convert(tahun2,bulan2,hari2);\n y:=jumlahhari;\n writeln(abs(x-y));\nend.\n\n\n"}, {"source_code": "USES SYSUTILS,DATEUTILS;\nCONST\n fin='';\n fon='';\nVAR\n day,month,year: LONGINT;\n time1,time2: TDATETIME;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nFUNCTION DOC: LONGINT;\n VAR\n S: STRING;\n c: CHAR;\n kq,cod: LONGINT;\n BEGIN\n S:='';\n REPEAT\n read(c);\n UNTIL c IN ['0'..'9'];\n S:=S+c;\n REPEAT\n read(c);\n if c IN ['0'..'9'] then S:=S+c\n else BREAK;\n UNTIL FALSE;\n VAL(S,kq,cod);\n DOC:=kq;\n END;\nPROCEDURE CHUONG_TRINH;\n VAR kq: LONGINT;\n BEGIN\n year:=DOC;\n month:=DOC;\n day:=DOC;\n time1:=ENCODEDATE(year,month,day);\n year:=DOC;\n month:=DOC;\n day:=DOC;\n time2:=ENCODEDATE(year,month,day);\n kq:=DAYSBETWEEN(time1,time2);\n writeln(kq);\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n CHUONG_TRINH;\n KET_THUC;\nEND.\n{\nCONST\n fin='CALENDAR.INP';\n fon='CALENDAR.OUT';\nVAR\n S1,S2: STRING;\n day1,day2: LONGINT;\n month1,month2: LONGINT;\n year1,year2: LONGINT;\n day,month,year: LONGINT;\n t,t1,t2,kq,cod: LONGINT;\n kt: BOOLEAN;\n Mon: array[1..12] of LONGINT;\nPROCEDURE BAT_DAU;\n BEGIN\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n END;\nPROCEDURE INIT;\n BEGIN\n day:=1;\n month:=1;\n year:=1900;\n t:=1;\n t1:=1;\n t2:=1;\n Mon[1]:=31;\n Mon[2]:=28;\n Mon[3]:=31;\n Mon[4]:=30;\n Mon[5]:=31;\n Mon[6]:=30;\n Mon[7]:=31;\n Mon[8]:=31;\n Mon[9]:=30;\n Mon[10]:=31;\n Mon[11]:=30;\n Mon[12]:=31;\n END;\nPROCEDURE NHAP;\n BEGIN\n readln(S1);\n readln(S2);\n VAL(COPY(S1,9,2),day1,cod);\n VAL(COPY(S2,9,2),day2,cod);\n VAL(COPY(S1,6,2),month1,cod);\n VAL(COPY(S2,6,2),month2,cod);\n VAL(COPY(S1,1,4),year1,cod);\n VAL(COPY(S2,1,4),year2,cod);\n END;\nFUNCTION CHECK(y: LONGINT): BOOLEAN;\n BEGIN\n if y MOD 4 <> 0 then kt:=FALSE\n else if y MOD 100 <> 0 then kt:=TRUE\n else if y MOD 400 = 0 then kt:=TRUE\n else kt:=FALSE;\n CHECK:=kt;\n END;\nPROCEDURE XU_LI_2;\n BEGIN\n while not ((day=1) and\n (month=1) and (year=2040)) do\n begin\n INC(day);\n INC(t);\n if day > Mon[month] then\n begin\n if (day=29) and (month=2)\n and (CHECK(year)=TRUE) then\n begin\n day:=1;\n INC(month);\n if month=13 then\n begin\n INC(year);\n month:=1;\n end;\n end;\n end;\n if (day1=day) and (month1=month)\n and (year1=year) then t1:=t;\n if (day2=day) and (month2=month)\n and (year2=year) then t2:=t;\n end;\n kq:=ABS(t1-t2);\n writeln(kq);\n END;\nPROCEDURE KET_THUC;\n BEGIN\n close(input);\n close(output);\n END;\nBEGIN\n BAT_DAU;\n INIT;\n NHAP;\n XU_LI_2;\n KET_THUC;\nEND.\n}\n"}, {"source_code": "CONST\n fi = '';//'CALENDAR.INP';\n fo = '';//'CALENDAR.OUT';\n\nVAR\n f: text;\n d1, m1, y1, d2, m2, y2: integer;\n\n{=========================================================================}\n{=========================================================================}\n\nprocedure DocFile;\n var\n s1: string[4];\n s2, s3: string[3];\n code: integer;\n Begin\n assign (f, fi); reset (f);\n readln (f, s1, s2, s3);\n delete (s2, 1, 1); delete (s3, 1, 1);\n val (s1, y1, code); val (s2, m1, code); val (s3, d1, code);\n\n readln (f, s1, s2, s3);\n delete (s2, 1, 1); delete (s3, 1, 1);\n val (s1, y2, code); val (s2, m2, code); val (s3, d2, code);\n close (f);\n End;\n\n{=========================================================================}\n{=========================================================================}\n\nprocedure SoNgay (d, m, y: integer; var x: longint);\n var\n i: integer;\n t: longint;\n Begin\n t := 0;\n\n { Doi tu NAM -> NGAY }\n for i:=1 to y-1 do\n if (i mod 400 = 0) or ((i mod 4 = 0) and (i mod 100 <> 0))\n then t := t + 366\n else t := t + 365;\n\n { Doi tu THANG -> NGAY }\n for i:=1 to m-1 do\n case i of\n 1, 3, 5, 7, 8, 10, 12: t := t + 31;\n 4, 6, 9, 11: t := t + 30;\n 2: if (y mod 400 = 0) or ((y mod 4 = 0) and (y mod 100 <> 0))\n then t := t + 29\n else t := t + 28;\n end {case};\n\n { Cong them so ngay }\n t := t + d;\n x := t;\n End;\n\n{-----------------------------------}\n\nprocedure Calendar;\n var\n x, y: longint;\n Begin\n SoNgay (d1, m1, y1, x);\n SoNgay (d2, m2, y2, y);\n\n assign (f, fo); rewrite (f);\n write (f, abs (x-y));\n close (f);\n End;\n\n{=========================================================================}\n{=========================================================================}\n\nBEGIN\n DocFile;\n Calendar;\nEND."}, {"source_code": "const fi='';\n fo='';\n month:array[1..11] of integer=(31,28,31,30,31,30,31,31,30,31,30);\nvar a,b,c:integer;\n function xuli(y,m,d:integer):longint;\n var tam:longint;\n procedure nam;\n var i:integer;\n begin\n for i:=1900 to y-1 do\n if (i mod 400=0) then tam:=tam+366\n else if (i mod 4 = 0) and (i mod 100 <> 0) then tam:=tam+366\n else tam:=tam+365;\n end;\n procedure thang;\n var i:integer;\n begin\n for i:=1 to m-1 do\n begin\n tam:=tam+month[i];\n if (i=2) then\n if (y mod 400 = 0) or ((y mod 4 = 0) and (y mod 100 <> 0)) then tam:=tam+1;\n end;\n end;\n procedure ngay;\n begin\n tam:=tam+d-1;\n end;\n begin\n tam:=0;\n nam;\n thang;\n ngay;\n exit(tam);\n end;\n procedure doc;\n var f:text;\n t,t2:longint;\n a,b,c,l,i:integer;\n s,s2:string;\n begin\n assign(f,fi);\n reset(f);\n readln(f,s);\n s2:='';\n for i:=1 to 4 do\n s2:=s2+s[i];\n val(s2,a,l);\n s2:='';\n for i:=6 to 7 do\n s2:=s2+s[i];\n val(s2,b,l);\n s2:='';\n for i:=9 to 10 do\n s2:=s2+s[i];\n val(s2,c,l);\n t:=xuli(a,b,c);\n readln(f,s);\n s2:='';\n for i:=1 to 4 do\n s2:=s2+s[i];\n val(s2,a,l);\n s2:='';\n for i:=6 to 7 do\n s2:=s2+s[i];\n val(s2,b,l);\n s2:='';\n for i:=9 to 10 do\n s2:=s2+s[i];\n val(s2,c,l);\n t2:=xuli(a,b,c);\n writeln(abs(t-t2));\n close(f);\n end;\nbegin\n doc;\nend.\n"}, {"source_code": "Const month: array [1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\n fi='';\n fo='';\nVar res:longint;\n year1,year2,month1,month2,day1,day2: longint;\n\nProcedure input;\nVar i: longint;\n f: text;\n S1,S2,c: String;\nBegin\n assign(f,fi); reset(F);\n readln(f,S1);\n readln(f,S2);\n Delete(S1,5,1); Delete(S1,7,1);\n C:=Copy(S1,1,4); Val(C,year1);\n C:=Copy(S1,5,2); Val(c,month1);\n C:=Copy(S1,7,2); Val(C,day1);\n Delete(S2,5,1); Delete(S2,7,1);\n C:=Copy(S2,1,4); Val(C,year2);\n C:=Copy(S2,5,2); Val(c,month2);\n C:=Copy(S2,7,2); Val(C,day2);\n close(f);\nEnd;\n\n\nProcedure calculate;\nVar i: longint;\n f: text;\n total1,total2: longint;\nBegin\n total1:=0;\n total2:=0;\n For i:= year1-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total1:=total1+366\n else total1:=total1+365;\n For i:= month1-1 downto 1 do\n total1:=total1+month[i];\n For i:= day1 downto 1 do\n total1:=total1+1;\n If ((((year1 mod 4=0) and (year1 mod 100 <>0)) or (year1 mod 400=0)) and (month1>2)) then total1:=total1+1;\n\n For i:= year2-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total2:=total2+366\n else total2:=total2+365;\n For i:= month2-1 downto 1 do\n total2:=total2+month[i];\n For i:= day2 downto 1 do\n total2:=total2+1;\n If ((((year2 mod 4=0) and (year2 mod 100 <>0)) or (year2 mod 400=0)) and (month2>2)) then total2:=total2+1;\n res:= ABS(total1-total2);\n assign(f,fo); rewrite(f);\n writeln(f,res);\n close(f);\nEnd;\n\nBegin\n input;\n calculate;\nEnd."}, {"source_code": "const\n m:array[1..12]of integer =(31,28,31,30,31,30,31,31,30,31,30,31);\nprocedure change(var a,b:longint);\nvar\n t:longint;\nbegin\n t:=a;a:=b;b:=t;\nend;\nvar\n ans,y1,m1,d1,y2,m2,d2:longint;\n ch1,ch2:char;\nprocedure init(var a,b,c:longint);\nvar\n s: string;\nbegin\n readln(s);\n val(copy(s,1,4),a);\n val(copy(s,6,2),b);\n val(copy(s,9,2),c);\nend;\nbegin\n init(y1,m1,d1);\n init(y2,m2,d2);\n if y1>y2 then begin change(y1,y2);change(m1,m2);change(d1,d2);end\n else if y1=y2 then\n if m1>m2 then begin change(m1,m2);change(d1,d2);end\n else if m1=m2 then\n if d1>d2 then begin change(d1,d2);end;\n if ((y1 mod 4=0)and(y1 mod 100<>0))or(y1 mod 400=0) then\n m[2]:=29 else m[2]:=28;\n while not((y1=y2)and(m1=m2)and(d1=d2)) do\n begin\n inc(ans);\n inc(d1);\n if d1>m[m1] then\n begin\n d1:=1;\n inc(m1);\n end;\n if m1>12 then\n begin\n inc(y1);\n m1:=1;\n if ((y1 mod 4=0)and(y1 mod 100<>0))or(y1 mod 400=0) then\n m[2]:=29 else m[2]:=28;\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "Var s1,s2:String;\n t,p,yy1,yy2,dd1,dd2,mm1,mm2,ans:LongInt;\n a:Array[0..10000] of LongInt;\n begin\n ReadLn(s1);\n ReadLn(s2);\n t:=pos(':',s1);\n val(copy(s1,1,t-1),yy1,p);\n delete(s1,1,t);\n t:=pos(':',s1);\n val(copy(s1,1,t-1),mm1,p);\n delete(s1,1,t);\n val(s1,dd1,p);\n t:=pos(':',s2);\n val(copy(s2,1,t-1),yy2,p);\n delete(s2,1,t);\n t:=pos(':',s2);\n val(copy(s2,1,t-1),mm2,p);\n delete(s2,1,t);\n val(s2,dd2,p);\n if (yy1>yy2) or ((yy1=yy2) and (mm1>mm2)) or ((yy1=yy2) and (mm1=mm2) and (dd1>dd2)) then\n begin\n t:=yy1;\n yy1:=yy2;\n yy2:=t;\n t:=mm1;\n mm1:=mm2;\n mm2:=t;\n t:=dd1;\n dd1:=dd2;\n dd2:=t;\n end;\n a[1]:=31;\n a[2]:=28;\n a[3]:=31;\n a[4]:=30;\n a[5]:=31;\n a[6]:=30;\n a[7]:=31;\n a[8]:=31;\n a[9]:=30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n While (yy1<>yy2) or (mm1<>mm2) or (dd1<>dd2) do\n begin\n if ((yy1 mod 4=0) and (yy1 mod 100<>0)) or (yy1 mod 400=0) then a[2]:=29\n else a[2]:=28;\n inc(ans);\n inc(dd1);\n if dd1>a[mm1] then begin dd1:=1; inc(mm1); end;\n if mm1>12 then begin mm1:=1; inc(yy1); end;\n end;\n WriteLn(ans);\n end."}, {"source_code": "program calendar;\n\nuses strutils;\n\nvar\n d,y,m,df,yf,mf:longint;\n days31:set of byte;\n delim:set of char;\n ans:longint;\n s1:string;\n code:word;\n\nfunction isleap(year:longint):boolean;\nbegin\n if (((year mod 4)=0) and ((year mod 100)<>0)) then exit(true);\n if (year mod 400)=0 then exit(true);\n exit(false);\nend;\n\nprocedure ensure;\nvar\n tmp:longint;\nbegin\n if (y>yf) then\n begin\n tmp:=yf;\n yf:=y;\n y:=tmp;\n tmp:=mf;\n mf:=m;\n m:=tmp;\n tmp:=df;\n df:=d;\n d:=tmp;\n end;\n if (y=yf) then\n begin\n if (m>mf) then\n begin\n tmp:=mf;\n mf:=m;\n m:=tmp;\n tmp:=df;\n df:=d;\n d:=tmp;\n end;\n if (m=mf) then\n begin \n if (d>df) then\n begin\n \n tmp:=df;\n df:=d;\n d:=tmp;\n end;\n end;\n end;\nend;\n\nbegin\n delim:=[':'];\n days31:=[1,3,5,7,8,10,12];\n readln(s1);\n val(extractdelimited(1,s1,delim),y,code);\n val(extractdelimited(2,s1,delim),m,code);\n val(extractdelimited(3,s1,delim),d,code);\n readln(s1);\n val(extractdelimited(1,s1,delim),yf,code);\n val(extractdelimited(2,s1,delim),mf,code);\n val(extractdelimited(3,s1,delim),df,code);\n \n ans:=0;\n \n ensure;\n \n while not ((d=df) and (m=mf) and (y=yf)) do\n begin\n if ((m=2) and (d=28) and (not isleap(y))) then\n begin\n m:=m+1;\n d:=1;\n end\n else if ((m=2) and (d=29) and (isleap(y))) then\n begin\n m:=m+1;\n d:=1;\n end\n else if ((m in days31) and (d=31)) then\n begin\n m:=m+1;\n d:=1;\n end\n else if ((not(m in days31)) and (d=30)) then\n begin\n m:=m+1;\n d:=1;\n end\n else\n begin\n d:=d+1;\n end;\n if (m>12) then\n begin\n m:=1;\n y:=y+1;\n end;\n ans:=ans+1;\n end;\n writeln(ans);\nend.\n \n \n \n \n \n \n \n \n \n"}, {"source_code": "\n\n\nvar\n a, b: array[1..13] of longint;\n s1, s2, t: string[10];\n d1, m1,i, y1, d2, m2, y2, ans: longint;\nbegin\n a[1]:= 31;\n a[2]:= 29;\n a[3]:= 31;\n a[4]:= 30;\n a[5]:= 31;\n a[6]:= 30;\n a[7]:= 31;\n a[8]:= 31;\n a[9]:= 30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n a[13]:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12];\n b[1]:= 31;\n b[2]:= 28;\n b[3]:= 31;\n b[4]:= 30;\n b[5]:= 31;\n b[6]:= 30;\n b[7]:= 31;\n b[8]:= 31;\n b[9]:= 30;\n b[10]:=31;\n b[11]:=30;\n b[12]:=31;\n b[13]:=b[1]+b[2]+b[3]+b[4]+b[5]+b[6]+b[7]+b[8]+b[9]+b[10]+b[11]+b[12];\n readln(s1);\n readln(s2);\n if s1 > s2 then begin\n t:= s1;\n s1 := s2;\n s2 := t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s1,6,2),m1);\n val(copy(s1,9,2),d1);\n val(copy(s2,1,4),y2);\n val(copy(s2,6,2),m2);\n val(copy(s2,9,2),d2);\n\n\nfor i := y1 + 1 to y2 - 1 do\n if (i mod 400 = 0) or ((i mod 100<>0)and(i mod 4 = 0))\n then inc(ans, a[13])\n else inc(ans, b[13]);\n\nif y1<>y2 then\nbegin\nfor i := m1 to 12 do\n if (y1 mod 400 = 0) or ((y1 mod 100<>0)and(y1 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n dec(ans,d1);\n\n for i := 1 to m2-1 do\n if (y2 mod 400 = 0) or ((y2 mod 100<>0)and(y2 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n inc(ans,d2);\nend else\nbegin\n for i := m1 to m2-1 do\n if (y1 mod 400 = 0) or ((y1 mod 100<>0)and(y1 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n dec(ans,d1-d2);\n\n\nend;\n\n writeln(ans);\n\n\nend.\n\n\n\n\n\n\n"}, {"source_code": "var i,j,n, y1,m1,d1, y2,m2,d2, code, sum1,sum2: LongInt;\ns1,s2, y,m,d: String;\nconst a: array[1..12] of Byte = (31,28,31,30,31,30,31,31,30,31,30,31);\nconst b: array[1..12] of Byte = (31,29,31,30,31,30,31,31,30,31,30,31);\nbegin\n Readln(s1);\n y:=Copy(s1,1,pos(':',s1)-1);\n Delete(s1,1,pos(':',s1));\n\n Val(y,y1,code);\n\n m:=Copy(s1,1,pos(':',s1)-1);\n Delete(s1,1,pos(':',s1));\n \n Val(m,m1,code);\n \n d:=Copy(s1,1,Length(s1));\n \n Val(d,d1,code);\n\n Readln(s2);\n \n y:=Copy(s2,1,pos(':',s2)-1);\n Delete(s2,1,pos(':',s2));\n\n Val(y,y2,code);\n\n m:=Copy(s2,1,pos(':',s2)-1);\n Delete(s2,1,pos(':',s2));\n\n Val(m,m2,code);\n\n d:=Copy(s2,1,Length(s2));\n\n Val(d,d2,code);\n\n for i:=1900 to y1-1 do\n if ((i mod 4)=0) and ((i mod 100)<>0) or ((i mod 400)=0) then inc(sum1,366) else inc(sum1,365);\n \n for i:=1 to m1-1 do\n if ((y1 mod 4)=0) and ((y1 mod 100)<>0) or ((y1 mod 400)=0) then inc(sum1,b[i]) else inc(sum1,a[i]);\n \n \n inc(sum1,d1);\n \n \n for i:=1900 to y2-1 do\n if ((i mod 4)=0) and ((i mod 100)<>0) or ((i mod 400)=0) then inc(sum2,366) else inc(sum2,365);\n\n for i:=1 to m2-1 do\n if ((y2 mod 4)=0) and ((y2 mod 100)<>0) or ((y2 mod 400)=0) then inc(sum2,b[i]) else inc(sum2,a[i]);\n\n\n inc(sum2,d2);\n \n Writeln(abs(sum1-sum2));\n \nend."}, {"source_code": "var d,d1,k,m,m1,g,g1,x:longint;p:array[0..13] of byte;q,s:string;\n\nbegin\n \n p[1]:=31;p[2]:=28;p[3]:=31;p[4]:=30;p[5]:=31;p[6]:=30;\n p[7]:=31;p[8]:=31;p[9]:=30;p[10]:=31;p[11]:=30;p[12]:=31;\n q:='123456789';\n readln(s);d:=pos(s[9],q)*10+pos(s[10],q);m:=pos(s[6],q)*10+pos(s[7],q);g:=pos(s[3],q)*10+pos(s[4],q)+pos(s[1],q)*1000+pos(s[2],Q)*100;\n\n readln(s);d1:=pos(s[9],q)*10+pos(s[10],q);m1:=pos(s[6],q)*10+pos(s[7],q);g1:=pos(s[3],q)*10+pos(s[4],q)+pos(s[1],q)*1000+pos(s[2],Q)*100;\n if (g>g1)or(g=g1)and(m>m1)or(g=g1)AND(M=M1)AND(D>D1) THEN BEGIN x:=d;d:=d1;d1:=x;\n x:=g;g:=g1;g1:=x;\nx:=m;m:=m1;m1:=x;\n end;\n while(d<>d1)or(m<>m1)or(g<>g1) do\n begin\n inc(d); \n if (g mod 4<>0) OR (G MOD 100=0)AND(G MOD 400<>0) THEN P[2]:=28 ELSE P[2]:=29;\n \n if p[m]2 then begin\n if r1 mod 4=0 then s:=s+1;\n if r1 mod 100=0 then s:=s-1;\n if r1 mod 400=0 then s:=s+1;\n end;\nans:=s;\n\ns:=0;\ns:=s+((r2-1)*365);\ns:=s+round((r2-1)div 4);\ns:=s-((r2-1)div 100);\ns:=s+((r2-1)div 400);\ns:=s+d2;\nfor i:=0 to m2-2 do\ns:=s+a[i];\nif m2>2 then begin\n if r2 mod 4=0 then s:=s+1;\n if r2 mod 100=0 then s:=s-1;\n if r2 mod 400=0 then s:=s+1;\n end;\nwrite(abs(round(ans)-round(s)));\nend.\n"}, {"source_code": "var a:array[1..100] of longint;\n i,j,s1,k,s,n,y1,m1,s2,kl_1,main_s,d1,y2,kol,m2,d2:longint;\n x,x2,dop:string;\n code:integer;\nbegin\n readln(x);\n readln(x2);\n a[1]:=31;\n a[2]:=28;\n a[3]:=31;\n a[4]:=30;\n a[5]:=31;\n a[6]:=30;\n a[7]:=31;\n a[8]:=31;\n a[9]:=30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n val(copy(x,1,4),y1,code);\n val(copy(x2,1,4),y2,code);\n\n if x>x2 then begin\n dop:=x;\n x:=x2;\n x2:=dop;\n end;\n\n val(copy(x,1,4),y1,code);\n val(copy(x2,1,4),y2,code);\n\n val(copy(x,6,2),m1,code);\n val(copy(x2,6,2),m2,code);\n\n val(copy(x,9,2),d1,code);\n val(copy(x2,9,2),d2,code);\n\n while true do\n begin\n kol:=0;\n if (y1=y2) and (m1=m2) and (d1=d2) then break;\n if (((y1 mod 4=0) and (y1 mod 100<>0))\n or ((y1 mod 4=0) and (y1 mod 100=0) and (y1 mod 400=0)))\n and (m1=2) then kol:=1;\n inc(d1);\n inc(main_s);\n if d1>a[m1]+KOL then begin\n d1:=1;\n inc(m1);\n if m1>12 then begin\n m1:=1;\n inc(y1);\n end;\n end;\n end;\n writeln(main_s);\nend.\n"}, {"source_code": "const m1:array[1..12]of integer=(0,31,59,90,120,151,181,212,243,273,304,334);\n m2:array[1..12]of integer=(0,31,60,91,121,152,182,213,244,274,305,335);\nvar s1,s2:string;\n\nfunction leap(x:integer):boolean;\nbegin\n if x mod 4<>0 then\n leap:=false\n else\n if x mod 100<>0 then\n leap:=true\n else\n if x mod 400=0 then\n leap:=true\n else\n leap:=false;\nend;\n\nfunction c(s:string):longint;\nvar y,m,d,i:integer;\n ans:longint;\nbegin\n val(copy(s,1,4),y);\n val(copy(s,6,2),m);\n val(copy(s,9,2),d);\n if y=1900 then\n ans:=m1[m]+d\n else begin\n ans:=0;\n for i:=1900 to (y-1) do\n if leap(i) then\n inc(ans,366)\n else\n inc(ans,365);\n if leap(y) then\n inc(ans,m2[m]+d)\n else\n inc(ans,m1[m]+d);\n end;\n c:=ans;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n writeln(abs(c(s1)-c(s2)));\n readln;\nend."}, {"source_code": "var s1,s2:string;\n m1,m2,y1,y2,d1,d2,tmp,ans,t:longint;\n\ta:array[1..12] of longint;\n\nfunction check(i:longint):boolean;\nbegin\n if ((i mod 100=0)and(i mod 400=0))or((i mod 100<>0)and(i mod 4=0)) \n\tthen exit(true) else exit(false);\nend;\n\nprocedure main;\nvar i:longint;\nbegin\n readln(s1);readln(s2);\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s1[i])-ord('0');\n y1:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s1[i])-ord('0');\n m1:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s1[i])-ord('0');\n d1:=tmp;\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s2[i])-ord('0');\n y2:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s2[i])-ord('0');\n m2:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s2[i])-ord('0');\n d2:=tmp;\n if (y1>y2)or((y1=y2)and(m1>m2))or((y1=y2)and(m1=m2)and(d1>d2)) then\n begin\n t:=y1;y1:=y2;y2:=t;\n\tt:=m1;m1:=m2;m2:=t;\n\tt:=d1;d1:=d2;d2:=t;\n end;\n //writeln(y1,' ',m1,' ',d1);writeln(y2,' ',m2,' ',d2);\n for i:=y1+1 to y2-1 do\n begin\n\tif check(i) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to 12 do\n case i of\n 1,3,5,7,8,10,12:a[i]:=31;\n 2:a[i]:=28;\n 4,6,9,11:a[i]:=30;\n end;\n if y1=2) then inc(ans);\n inc(ans,d2-1);\n end else\n begin\n for i:=1 to m1-1 do dec(ans,a[i]);\n if check(y1)and(m1-1>=2) then dec(ans);\n dec(ans,d1-1);\n //======================================\n for i:=1 to m2-1 do inc(ans,a[i]);\n if check(y2)and(m2-1>=2) then inc(ans);\n inc(ans,d2-1);\n end;\n writeln(ans);\nend;\n\nbegin\n //assign(input,'1.in');\n //reset(input);\n main;\n //close(input);\nend.\n"}, {"source_code": "const days:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar s1,s2:ansistring;\n answer:longint;\n\nfunction kod(ch:char):longint;\nbegin\n kod:=ord(Ch)-ord('0');\nend;\n\nfunction goodyear(v:longint):boolean;\nbegin\n if v mod 400 = 0 then goodyear:=true else\n if v mod 100 = 0 then goodyear:=false else\n if v mod 4 = 0 then goodyear:=true else\n goodyear:=false;\nend;\n\nfunction f(s:string):longint;\nvar year,month,day,y,m,d,answer:longint;\nbegin\n year:=kod(s[1])*1000+kod(s[2])*100+kod(s[3])*10+kod(s[4]);\n month:=kod(s[6])*10+kod(s[7]);\n day:=kod(s[9])*10+kod(s[10]);\n d:=1; m:=1; y:=1900;\n answer:=0;\n while (d<>day) or (m<>month) or (year<>y) do\n begin\n answer:=answer+1;\n d:=d+1;\n if d>days[m]+byte(m=2)*byte(goodyear(y)=true) then\n begin\n d:=1;\n m:=m+1;\n if m = 13 then\n begin\n m:=1;\n y:=y+1;\n end;\n end;\n end;\n f:=answer+1;\nend;\n\n\nbegin\n //assign(input,'in.txt'); reset(input);\n readln(s1);\n readln(s2);\n answer:=f(s2)-f(s1);\n writeln(abs(answer));\nend.\n"}, {"source_code": "{$mode objfpc}\nprogram chip;\nconst\n fi='';\n fo='';\nvar\n a,b: ansistring;\n ya,yb,ma,mb,da,db,e,ans: longint;\n maxd: array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n\nfunction leap(y: longint): boolean;\n\nbegin\n if y mod 4<>0 then exit(false);\n if y mod 400=0 then exit(true);\n if y mod 100=0 then exit(false);\n exit(true);\nend;\n\nprocedure next;\n\nbegin\n if dayb then\n begin\n swap(ya,yb);\n swap(ma,mb);\n swap(da,db);\n end\n else\n if ya=yb then\n if ma>mb then\n begin\n swap(ya,yb);\n swap(ma,mb);\n swap(da,db);\n end\n else\n if ma=mb then\n if da>db then\n begin\n swap(ya,yb);\n swap(ma,mb);\n swap(da,db);\n end;\n ans:=0;\n while (yan2.y) or (n1.y=n2.y) and (n1.m>n2.m) or (n1.y=n2.y) and (n1.m=n2.m) and (n1.d>n2.d) then begin t:=n1; n1:=n2; n2:=t; end;\n\n fillchar(b,sizeof(b),0);\n for i:= 1904 to 2036 do\n if i mod 4=0 then b[i]:=1;\n\n k:=0;\n for i:= n1.y+1 to n2.y-1 do\n k:=k+b[i]+365;\n for i:= n1.m+1 to 12 do\n k:=k+a[i];\n for i:= 1 to n2.m-1 do\n k:=k+a[i];\n k:=k+a[n1.m]-n1.d+1;\n k:=k+n2.d;\n if (n2.m>2) and (b[n2.y]=1) then inc(k);\n if (n1.m<3) and (b[n1.y]=1) then inc(k);\n dec(k);\n IF (n1.y=n2.y) then k:=k-365-b[n1.y];\n\n writeln(k);\nend.\n\n\n\n\n"}, {"source_code": "const\n fi = '';\n fo = '';\n ngay : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n d1,m1,y1,d2,m2,y2,p,code,i,j,nn,nt,t : longint;\n phu,s : string;\n\nprocedure swap(var x,y : longint);\nvar\n p : longint;\nbegin\n p := x;\n x := y;\n y := p;\nend;\n\nfunction ktnamnhuan(i:longint):longint;\nbegin\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then ktnamnhuan := 1\n else ktnamnhuan := 0;\nend;\n\nprocedure xuat(t:longint);\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(t);\n close(output);\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y1=0 then val(phu,y1,code)\n else val(phu,m1,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d1,code);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y2=0 then val(phu,y2,code)\n else val(phu,m2,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d2,code);\n close(input);\n\n if (y1 > y2) or ((y1 = y2) and (m1 > m2)) or ((y1 = y2) and (m1 = m2) and (d1 > d2)) then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i := y1 to y2 do\n begin\n p := ktnamnhuan(i);\n t := t+365+p;\n end;\n p := ktnamnhuan(y1);\n for i := 1 to m1-1 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n t := t-d1;\n p := ktnamnhuan(y2);\n for i := m2+1 to 12 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n if m2 <> 2 then t := t-(ngay[m2]-d2)\n else t := t-(ngay[m2]+p-d2);\n xuat(t);\nend.\n"}, {"source_code": "var\n v:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n sum:array[0..12] of longint;\n i,j,k,n,m,x1,y1,z1,x2,y2,z2:longint;\n ans:int64;\n s1,s2:string;\n\nProcedure Solve;\nvar\n k,x:longint;\n s:string;\nbegin\n if s1>s2 then\n begin\n s:=s1;\n s1:=s2;\n s2:=s;\n end;\n s:=Copy(s1,1,4);\n val(s,x1,x);\n s:=Copy(s1,6,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y1,x);\n s:=Copy(s1,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z1,x);\n s:=Copy(s2,1,4);\n val(s,x2,x);\n s:=Copy(s2,6 ,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y2,x);\n s:=Copy(s2,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z2,x);\nend;\n\nFunction Run(x:longint):boolean;\nbegin\n if x mod 4<>0 then exit(false);\n if x mod 400=0 then exit(True);\n if x mod 100=0 then exit(false);\n exit(true);\nend;\n\nBegin\n readln(s1);\n readln(s2);\n Solve;\n for i:=1 to 12 do sum[i]:=sum[i-1]+v[i];\n ans:=0;\n if x12) then inc(ans);\n end;\n end\n else\n begin\n if y12) then inc(ans);\n end;\n\n writeln(ans-1);\nend.\n"}, {"source_code": "var s:string;\nn,t,y,r,n1,y1,r1,x:longint;\nfunction p(x,y:longint):longint;\nbegin\ncase y of\n 1,3,5,7,8,10,12:p:=31;\n 4,6,9,11:p:=30;\n 2:if (x mod 4=0)and(x mod 100<>0)or(x mod 400=0) then p:=29\n else p:=28;\n end;\nend;\nbegin\n//assign(input,'rl.in');reset(input);\n//assign(output,'rl.out');rewrite(output);\nreadln(s);\nval(copy(s,1,4),n);delete(s,1,5);\nval(copy(s,1,2),y);delete(s,1,3);\nval(copy(s,1,2),r);\nreadln(s);\nval(copy(s,1,4),n1);delete(s,1,5);\nval(copy(s,1,2),y1);delete(s,1,3);\nval(copy(s,1,2),r1);\nif (n>n1)or(n=n1)and(y>y1)or(n=n1)and(y=y1)and(r>r1) then\n begin\n t:=n;n:=n1;n1:=t;\n t:=y;y:=y1;y1:=t;\n t:=r;r:=r1;r1:=t;\n end;\nwhile (n<>n1)or(y<>y1)or(r<>r1) do\n begin\n x:=x+1;\n r:=r+1;\n if r>p(n,y) then\n begin\n r:=1;y:=y+1;\n end;\n if y>12 then\n begin\n y:=1;n:=n+1;\n end;\n end;\nwriteln(x);\nclose(input);close(output);\nend.\n"}, {"source_code": "var x1,x2,x3,y1,y2,y3,i,ansx,ansy,j:longint;\nx,y:string;\nbegin\n//assign(input,'rl.in');reset(input);\n//assign(output,'rl.out');rewrite(output);\nreadln(x);x:=x+':';\nval(copy(x,1,pos(':',x)-1),x1);delete(x,1,pos(':',x));\nval(copy(x,1,pos(':',x)-1),x2);delete(x,1,pos(':',x));\nval(copy(x,1,pos(':',x)-1),x3);delete(x,1,pos(':',x));\nreadln(y);y:=y+':';\nval(copy(y,1,pos(':',y)-1),y1);delete(y,1,pos(':',y));\nval(copy(y,1,pos(':',y)-1),y2);delete(y,1,pos(':',y));\nval(copy(y,1,pos(':',y)-1),y3);delete(y,1,pos(':',y));\nansx:=ansx+x3;ansy:=ansy+y3;\nfor i:=1 to x2-1 do\n if i in [1,3,5,7,8,10,12] then ansx:=ansx+31\n else if i in [4,6,9,11] then ansx:=ansx+30\n else if (x1 mod 4=0) and (x1 mod 100<>0) or (x1 mod 400=0) then ansx:=ansx+29\n else ansx:=ansx+28;\nfor i:=1 to y2-1 do\n if i in [1,3,5,7,8,10,12] then ansy:=ansy+31\n else if i in [4,6,9,11] then ansy:=ansy+30\n else if (y1 mod 4=0) and (y1 mod 100<>0) or (y1 mod 400=0) then ansy:=ansy+29\n else ansy:=ansy+28;\nif x1>y1 then\n for j:=y1 to x1-1 do\n if (j mod 4=0) and (j mod 100<>0) or (j mod 400=0) then ansx:=ansx+366\n else ansx:=ansx+365\nelse\n for j:=x1 to y1-1 do\n if (j mod 4=0) and (j mod 100<>0) or (j mod 400=0) then ansy:=ansy+366\n else ansy:=ansy+365;\nwrite(abs(ansx-ansy));\nclose(input);close(output);\nend."}, {"source_code": "const g:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar s,s1:string;\n a:array[1..5000] of longint;\n i,j,sum1,sum2,k,l,m,n,y1,y2,m1,m2,d1,d2,q,cod:longint;\nbegin\n readln(s);\n readln(s1);\n\n for i:=1 to 2038 do\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then a[i]:=1;\n q:=1000;\n for i:=1 to 4 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n y1:=y1+k*q;\n y2:=y2+l*q;\n q:=q div 10;\n end;\n q:=10;\n k:=0;\n l:=0;\n for i:=6 to 7 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n m1:=m1+k*q;\n m2:=m2+l*q;\n q:=q div 10;\n end;\n q:=10;\n k:=0;\n l:=0;\n for i:=9 to 10 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n d1:=d1+k*q;\n d2:=d2+l*q;\n q:=q div 10;\n end;\nsum1:=d1;\nfor i:=m1-1 downto 1 do\nsum1:=sum1+g[i];\nsum1:=sum1+y1*365;\nfor i:=1 to y1 do\nif a[i]<>0 then inc(sum1);\nif (a[y1]<>0) and (m1<3) then dec(sum1);\nsum2:=d2;\nfor i:=m2-1 downto 1 do\nsum2:=sum2+g[i];\nsum2:=sum2+y2*365;\nfor i:=1 to y2 do\nif a[i]<>0 then inc(sum2);\nif (a[y2]<>0) and (m2<3) then dec(sum2\n);\nwrite(abs(sum1-sum2));\nend.\n"}, {"source_code": "const days :array[1..12]of longint =(31,28,31,30,31,30,31,31,30,31,30,31);\n dayv :array[1..12]of longint =(31,29,31,30,31,30,31,31,30,31,30,31);\nvar s1,s2,t :string;\n y1,y2,m1,m2,d1,d2,d,m,y :longint;\n ans :int64;\nFunction vis(a :longint): boolean;\nBegin\n if (a mod 400)=0 then exit(true);\n if (a mod 100)=0 then exit(false);\n if (a mod 4)=0 then exit(true);\n exit(false);\nend;\nBegin\n readln(s1);\n readln(s2);\n if s1>s2 then\n Begin\n t:=s1;\n s1:=s2;\n s2:=t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s2,1,4),y2);\n val(copy(s1,6,2),m1);\n val(copy(s2,6,2),m2);\n val(copy(s1,9,2),d1);\n val(copy(s2,9,2),d2);\n if y1=y2 then\n Begin\n ans:=0;\n if vis(y1) then\n Begin\n for m:=m1+1 to m2-1 do\n inc(ans,dayv[m]);\n if m1=m2 then\n inc(ans,d2-d1+1)\n else\n Begin\n inc(ans,dayv[m1]-d1+1);\n inc(ans,d2);\n end;\n end else\n Begin\n for m:=m1+1 to m2-1 do\n inc(ans,days[m]);\n if m1=m2 then\n inc(ans,d2-d1+1)\n else\n Begin\n inc(ans,days[m1]-d1+1);\n inc(ans,d2);\n end;\n end;\n writeln(ans-1);\n halt;\n end;\n ans:=0;\n for y:=y1+1 to y2-1 do\n if vis(y) then inc(ans,366) else inc(ans,365);\n for m:=12 downto m1+1 do\n if vis(y1) then inc(ans,dayv[m])\n else inc(ans,days[m]);\n if vis(y1) then\n for d:=dayv[m1] downto d1 do inc(ans)\n else\n for d:=days[m1] downto d1 do inc(ans);\n if vis(y2) then\n Begin\n for m:=1 to m2-1 do inc(ans,dayv[m]);\n inc(ans,d2);\n end else\n Begin\n for m:=1 to m2-1 do inc(ans,days[m]);\n inc(ans,d2);\n end;\n writeln(ans-1);\nend."}, {"source_code": "var y,m,d,yx,mx,dx,tip,ans,i:longint;\n s:string;\n\nbegin\n readln(s);\n for i:=1 to 4 do y:=y*10+ord(s[i])-ord('0');\n for i:=6 to 7 do m:=m*10+ord(s[i])-ord('0');\n for i:=9 to 10 do d:=d*10+ord(s[i])-ord('0');\n\n readln(s);\n for i:=1 to 4 do yx:=yx*10+ord(s[i])-ord('0');\n for i:=6 to 7 do mx:=mx*10+ord(s[i])-ord('0');\n for i:=9 to 10 do dx:=dx*10+ord(s[i])-ord('0');\n\n if (y>yx) or ((y=yx) and (m>mx)) or ((y=yx) and (m=mx) and (d>dx)) then\n begin\n tip:=y; y:=yx; yx:=tip;\n tip:=d; d:=dx; dx:=tip;\n tip:=m; m:=mx; mx:=tip;\n end;\n while (y<>yx) or (m<>mx) or (d<>dx) do\n begin\n\n inc(ans);\n inc(d);\n if (m=2) then\n begin\n tip:=28;\n if (y mod 4=0) then tip:=29;\n if (y mod 100=0) and (y mod 400<>0) then tip:=28;\n end else\n begin\n if m in[1,3,5,7,8,10,12] then tip:=31 else tip:=30;\n end;\n if d>tip then\n begin\n inc(m); d:=1;\n end;\n if m>12 then\n begin\n m:=1; inc(y);\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const \n d:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n t,ts,i,x,y,z,a,pp,qq:longint;\n st,ss,s,s1:string;\nfunction r(i:longint):longint;\nbegin\n if (i mod 4=0) and (i mod 100<>0) or (i mod 400=0) then\n exit(366) else\n exit(365);\nend;\nprocedure p(x:longint);\nbegin\n pp:=x;\nend;\nprocedure q(x:longint);\nbegin\n qq:=x;\nend;\nbegin\n t:=1;\n st:='1926:08:17';\n for ts:=1 to t do\n begin\n readln(s);\n ss:=s;\n if s=st then\n p(0) else\n if s>st then\n begin\n a:=0;\n s1:=copy(s,1,4);\n val(s1,x);\n s1:=copy(s,6,2);\n val(s1,y);\n s1:=copy(s,9,2);\n val(s1,z);\n if x=1926 then\n begin\n if y=8 then\n begin\n p(z-17);\n continue;\n end;\n a:=14;\n for i:=9 to y-1 do\n a:=a+d[i];\n a:=a+z;\n p(a);\n end else\n begin\n a:=136;\n for i:=1927 to x-1 do\n a:=a+r(i);\n for i:=1 to y-1 do\n if i=2 then\n begin\n if r(x)=366 then\n a:=a+29 else\n a:=a+28;\n end else\n a:=a+d[i];\n a:=a+z;\n p(a);\n end;\n end else\n begin\n a:=0;\n s1:=copy(s,1,4);\n val(s1,x);\n s1:=copy(s,6,2);\n val(s1,y);\n s1:=copy(s,9,2);\n val(s1,z);\n if x=1926 then\n begin\n if y=8 then\n begin\n p(17-z);\n continue;\n end;\n a:=17;\n for i:=y+1 to 7 do\n a:=a+d[i];\n a:=a+d[y]-z;\n p(a);\n end else\n begin\n a:=229;\n for i:=x+1 to 1925 do\n a:=a+r(i);\n for i:=12 downto y+1 do\n if i=2 then\n begin\n if r(x)=366 then\n a:=a+29 else\n a:=a+28;\n end else\n a:=a+d[i];\n a:=a+d[y]-z;\n p(a);\n end;\n end;\n x:=0;\n y:=0;\n z:=0;\n a:=0;\n readln(s);\n if s=st then\n q(0) else\n if s>st then\n begin\n a:=0;\n s1:=copy(s,1,4);\n val(s1,x);\n s1:=copy(s,6,2);\n val(s1,y);\n s1:=copy(s,9,2);\n val(s1,z);\n if x=1926 then\n begin\n if y=8 then\n begin\n q(z-17);\n continue;\n end;\n a:=14;\n for i:=9 to y-1 do\n a:=a+d[i];\n a:=a+z;\n q(a);\n end else\n begin\n a:=136;\n for i:=1927 to x-1 do\n a:=a+r(i);\n for i:=1 to y-1 do\n if i=2 then\n begin\n if r(x)=366 then\n a:=a+29 else\n a:=a+28;\n end else\n a:=a+d[i];\n a:=a+z;\n q(a);\n end;\n end else\n begin\n a:=0;\n s1:=copy(s,1,4);\n val(s1,x);\n s1:=copy(s,6,2);\n val(s1,y);\n s1:=copy(s,9,2);\n val(s1,z);\n if x=1926 then\n begin\n if y=8 then\n begin\n q(17-z);\n continue;\n end;\n a:=17;\n for i:=y+1 to 7 do\n a:=a+d[i];\n a:=a+d[y]-z;\n q(a);\n end else\n begin\n a:=229;\n for i:=x+1 to 1925 do\n a:=a+r(i);\n for i:=12 downto y+1 do\n if i=2 then\n begin\n if r(x)=366 then\n a:=a+29 else\n a:=a+28;\n end else\n a:=a+d[i];\n a:=a+d[y]-z;\n q(a);\n end;\n end;\n if ((s>st) and (ss>st)) or ((s0 then\n writeln(pp-qq) else\n writeln(qq-pp);\n end else\n writeln(pp+qq);\n end;\nend."}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS-,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\nconst a:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar x,y,i,j,all:longint;\n s:string;\nFunction f(s:string):longint;\nvar i,x,n,k,y,m,d:longint;\nBegin\n n:=length(s);\n k:=0;y:=0;m:=0;d:=0;x:=0;\n for i:=1 to n do\n if(s[i]=':')then inc(k)\n else if(k=0)then y:=y*10+ord(s[i])-48\n else if(k=1)then m:=m*10+ord(s[i])-48\n else if(k=2)then d:=d*10+ord(s[i])-48;\n for i:=1900 to y-1 do\n if((i mod 4=0)and(i mod 100<>0))or(i mod 400=0)then x:=x+all+1 else x:=x+all;\n for i:=1 to m-1 do\n begin\n x:=x+a[i];\n if(i=2)then if((y mod 4=0)and(y mod 100<>0))or(y mod 400=0) then x:=x+1;\n end;\n x:=x+d;\n exit(x);\nEnd;\nBegin\n for i:=1 to 12 do\n all:=all+a[i];\n readln(s);\n x:=f(s);\n readln(s);\n y:=f(s);\n writeln(abs(y-x));\nEnd.\n"}, {"source_code": "var\n dd,t,p1,p2,n,m,k,kol,ans,x,y,z:int64;\n sa,sb:string;\n s1,s2,s3:string;\n d:array[1..12] of int64;\n res1,res2,res:int64;\n i,j:longint;\n\nfunction check(s:string):longint;\nvar\n s1,s2,s3,sa,sb:string;\n f1,f2,f3:integer;\n ans,c1,c2,c3,x,y,z,p1,p2:int64;\nbegin\n ans:=0;\n kol:=0;\n for i:=1 to length(s) do if s[i]=':' then\n begin\n inc(kol);\n if kol=1 then p1:=i;\n if kol=2 then p2:=i;\n end;\n s1:=copy(s,1,p1-1);\n s2:=copy(s,p1+1,p2-p1-1);\n s3:=copy(s,p2+1,length(s)-p2);\n val(s1,c1,f1);\n val(s2,c2,f2);\n val(s3,c3,f3);\n for i:=1900 to c1-1 do\n begin\n if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then dd:=366 else dd:=365;\n inc(ans,dd);\n\n end;\n for i:=1 to c2-1 do\n begin\n if (i=2)and(((c1 mod 4=0)and(c1 mod 100<>0))or(c1 mod 400=0)) then inc(ans,d[i]+1) else inc(ans,d[i]);\n end;\n inc(ans,c3);\n check:=ans;\nend;\n\n\n\nbegin\n d[1]:=31; d[2]:=28; d[3]:=31; d[4]:=30; d[5]:=31;\n d[6]:=30; d[7]:=31; d[8]:=31; d[9]:=30; d[10]:=31; d[11]:=30;\n d[12]:=31;\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n res1:=0;\n res2:=0;\n res:=0;\n readln(sa);\n readln(sb);\n res1:=check(sa);\n res2:=check(sb);\n res:=abs(res2-res1);\n writeln(res);\nend.\n"}, {"source_code": "Program Calendar;\nConst fi='';\n fo='';\n b:array[1..12] of byte=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar f1,f2:text;\n a:string;\n nam,thang,ngay,songay2,songay1:longint;\n\nFunction tinhngay(x,y,z:longint):longint;\nvar i,v:longint;\nbegin\nv:=0;\n for i:=1900 to x-1 do\n begin\n if ((i mod 4=0) and (i mod 100<>0)) or (i mod 400=0) then\n v:=v+366\n else\n v:=v+365;\n end;\n for i:=1 to y-1 do\n begin\n v:=v+b[i];\n end;\nif ((x mod 4=0) and (x mod 100<>0)) or (x mod 400=0) then if y>2 then v:=v+1;\n v:=v+z;\n tinhngay:=v;\nend;\n\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(F1);\n rewrite(f2);\n readln(f1,a);\n nam:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+(ord(a[4])-48);\n thang:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay:=(ord(a[9])-48)*10+(ord(a[10])-48);\n songay1:=tinhngay(nam,thang,ngay);\n readln(f1,a);\n nam:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+(ord(a[4])-48);\n thang:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay:=(ord(a[9])-48)*10+(ord(a[10])-48);\n songay2:=tinhngay(nam,thang,ngay);\nend;\n\n\n\nProcedure xuat;\nbegin\n writeln(f2,abs(songay1-songay2));\n close(f1);\n close(f2);\nend;\n\nbegin\nnhap;\nxuat;\nend.\n"}, {"source_code": "uses sysutils;\nvar n, i, j, y, yx, x: integer;\n m, mx, d, dx: byte;\n e: array [1..12] of byte;\n s: string;\n t: word;\nfunction leap(y: integer): byte;\nvar e: byte;\nbegin\n e := 28;\n if y mod 4 = 0 then\n e := 29;\n if y mod 100 = 0 then\n e := 28;\n if y mod 400 = 0 then\n e := 29;\n leap := e;\nend;\nbegin\n e[1] := 31;\n e[3] := 31;\n e[4] := 30;\n e[5] := 31;\n e[6] := 30;\n e[7] := 31;\n e[8] := 31;\n e[9] := 30;\n e[10] := 31;\n e[11] := 30;\n e[12] := 31;\n readln(s);\n y := strtoint(copy(s, 1, 4));\n m := strtoint(copy(s, 6, 2));\n d := strtoint(copy(s, 9, 2));\n readln(s);\n yx := strtoint(copy(s, 1, 4));\n mx := strtoint(copy(s, 6, 2));\n dx := strtoint(copy(s, 9, 2));\n t := 0;\n if yx < y then\n begin\n x := y;\n y := yx;\n yx := x;\n x := m;\n m := mx;\n mx := x;\n x := d;\n d := dx;\n dx := x;\n end\n else if yx = y then\n begin\n if mx < m then\n begin\n x := m;\n m := mx;\n mx := x;\n x := d;\n d := dx;\n dx := x;\n end\n else if (mx = m) and (dx < d) then\n begin\n x := d;\n d := dx;\n dx := x;\n end;\n end;\n if y = yx then\n begin\n if m = mx then\n t := dx - d\n else\n begin\n e[2] := leap(y);\n inc(t, e[m] - d + dx);\n for i := m + 1 to mx - 1 do\n inc(t, e[i]);\n end\n end\n else\n begin\n e[2] := leap(y);\n inc(t, e[m] - d);\n for i := m + 1 to 12 do\n inc(t, e[i]);\n e[2] := leap(yx);\n inc(t, dx);\n for i := 1 to mx - 1 do\n inc(t, e[i]);\n for i := y + 1 to yx - 1 do\n inc(t, 337 + leap(i));\n end;\n writeln(t);\nend."}, {"source_code": "var\n km:array[1..12]of longint;\n s:ansistring;\n yy,mm,dd,fy,fm,fd,tmp,ans:longint;\n \n procedure todate(s:ansistring;var yy,mm,dd:longint);\n begin\n val(s[1]+s[2]+s[3]+s[4],yy);\n val(s[6]+s[7],mm);\n val(s[9]+s[10],dd);\n end;\n\nbegin\n km[1]:=31;km[4]:=30;km[7]:=31;km[10]:=31;\n km[2]:=28;km[5]:=31;km[8]:=31;km[11]:=30;\n km[3]:=31;km[6]:=30;km[9]:=30;km[12]:=31;\n readln(s);\n todate(s,yy,mm,dd);\n readln(s);\n todate(s,fy,fm,fd);\n if (yy>fy)or(yy=fy)and(mm>fm)or(yy=fy)and(mm=fm)and(dd>fd)then begin\n tmp:=yy;yy:=fy;fy:=tmp;\n tmp:=mm;mm:=fm;fm:=tmp;\n tmp:=dd;dd:=fd;fd:=tmp;\n end;\n while (yy<>fy)or(mm<>fm)or(dd<>fd)do begin\n inc(ans);\n inc(dd);\n if (dd>km[mm])then begin\n dd:=1;inc(mm);\n if (mm>12)then begin\n mm:=1;\n inc(yy);\n if ((yy mod 4=0)and(yy mod 100<>0))or(yy mod 400=0)then km[2]:=29 else km[2]:=28;\n end;\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program dates;\n\nvar s1,s2, tmp : string;\ny1, y2, m1, m2, d1, d2, curd, curm, cury, i, cnt : longint;\na : array [1..12] of longint;\nc : array [1..12] of longint;\nb : array [1899..2040] of boolean;\nbegin\n\tReadln(s1);\n\tReadln(s2);\n\n\ttmp:=Copy(s1,1,pos(':',s1)-1);\n\tDelete(s1,1,pos(':',s1));\n\tval(tmp,y1);\n\ttmp:=Copy(s1,1,pos(':',s1)-1);\n\tDelete(s1,1,pos(':',s1));\n\tval(tmp,m1);\n\tval(s1,d1);\n\n\ttmp:=Copy(s2,1,pos(':',s2)-1);\n\tDelete(s2,1,pos(':',s2));\n\tval(tmp,y2);\n\ttmp:=Copy(s2,1,pos(':',s2)-1);\n\tDelete(s2,1,pos(':',s2));\n\tval(tmp,m2);\n\tval(s2,d2);\n\n\tif (y1>y2) or ( (y1=y2) and (m1>m2) ) or ( (y1=y2) and (m1=m2) and (d1>d2) ) then begin\n\t\tcurd:=d1;\n\t\td1:=d2;\n\t\td2:=curd;\n\n\t\tcurm:=m1;\n\t\tm1:=m2;\n\t\tm2:=curm;\n\n\t\tcury:=y1;\n\t\ty1:=y2;\n\t\ty2:=cury;\n\tend; \n\n\tcurd:=d1;\n\tcurm:=m1;\n\tcury:=y1;\n\ta[1]:=31;\n\ta[2]:=28;\n\ta[3]:=31;\n\ta[4]:=30;\n\ta[5]:=31;\n\ta[6]:=30;\n\ta[7]:=31;\n\ta[8]:=31;\n\ta[9]:=30;\n\ta[10]:=31;\n\ta[11]:=30;\n\ta[12]:=31;\n\n\tc[1]:=31;\n\tc[2]:=29;\n\tc[3]:=31;\n\tc[4]:=30;\n\tc[5]:=31;\n\tc[6]:=30;\n\tc[7]:=31;\n\tc[8]:=31;\n\tc[9]:=30;\n\tc[10]:=31;\n\tc[11]:=30;\n\tc[12]:=31;\n\n\tfillchar(b,sizeof(b),false);\n\tfor i:=1899 to 2040 do begin\n\t\tif (i mod 100 = 0) and (i mod 400 = 0) then begin\n\t\t\tb[i]:=true;\n\t\tend else if (i mod 100 = 0) then begin\n\t\t\tb[i]:=false;\n\t\tend else if (i mod 4 = 0) then begin\n\t\t\tb[i]:=true;\n\t\tend;\n\tend;\n\n\tcnt:=0;\n\twhile (curd<>d2) or (curm<>m2) or (cury<>y2) do begin\n\t\tinc(cnt);\n\t\tif b[cury] then begin\n\t\t\tinc(curd);\n\t\t\tif curd>c[curm] then begin\n\t\t\t\tinc(curm);\n\t\t\t\tcurd:=1;\n\t\t\t\tif curm>12 then begin\n\t\t\t\t\tcurm:=1;\n\t\t\t\t\tinc(cury);\n\t\t\t\tend;\n\t\t\tend;\n\t\tend else begin\n\t\t\tinc(curd);\n\t\t\tif curd>a[curm] then begin\n\t\t\t\tinc(curm);\n\t\t\t\tcurd:=1;\n\t\t\t\tif curm>12 then begin\n\t\t\t\t\tcurm:=1;\n\t\t\t\t\tinc(cury);\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend; \n\tWriteln(cnt);\nend."}, {"source_code": "var\n u,vv : array [0..12] of longint;\n s1,s2 : ansistring;\n y,m,d,ty,tm,td,i,j : longint;\n ans : longint;\n code : integer;\n procedure swap;\n var z : longint;\n begin\n z:=y; y:=ty; ty:=z;\n z:=m; m:=tm; tm:=z;\n z:=d; d:=td; td:=z;\n end;\n function V(x : longint) : boolean;\n begin\n if ((x mod 400)=0) then exit(true);\n if ((x mod 4)=0) and ((x mod 100)>0) then exit(true);\n exit(false);\n end;\n procedure build;\n var ny,nm,nd : longint;\n begin\n ny:=y; nm:=m; nd:=d;\n if V(y) then\n begin\n inc(nd);\n if nd>vv[nm] then\n begin\n inc(nm);\n nd:=1;\n end;\n if nm>12 then\n begin\n inc(ny);\n nm:=1;\n nd:=1;\n end;\n end else\n begin\n inc(nd);\n if nd>u[nm] then\n begin\n inc(nm);\n nd:=1;\n end;\n if nm>12 then\n begin\n inc(ny);\n nm:=1;\n nd:=1;\n end;\n end;\n y:=ny; m:=nm; d:=nd;\n end;\nbegin\n u[1]:=31;u[2]:=28;u[3]:=31;u[4]:=30;u[5]:=31;u[6]:=30;u[7]:=31;u[8]:=31;u[9]:=30;u[10]:=31;u[11]:=30;u[12]:=31;\n for i:=1 to 12 do vv[i]:=u[i];\n vv[2]:=29;\n readln(s1);\n readln(s2);\n val(copy(s1,1,4),y,code);\n val(copy(s1,6,2),m,code);\n val(copy(s1,9,2),d,code);\n val(copy(s2,1,4),ty,code);\n val(copy(s2,6,2),tm,code);\n val(copy(s2,9,2),td,code);\n if (y>ty) or ((y=ty) and (m>tm)) or\n ((y=ty) and (m=tm) and (d>td)) then swap;\n while not ((y=ty) and (m=tm) and (d=td)) do\n begin\n build;\n inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "var\n u,vv : array [0..12] of longint;\n s1,s2 : ansistring;\n y,m,d,ty,tm,td,i,j : longint;\n ans : longint;\n code : integer;\n procedure swap;\n var z : longint;\n begin\n z:=y; y:=ty; ty:=z;\n z:=m; m:=tm; tm:=z;\n z:=d; d:=td; td:=z;\n end;\n function V(x : longint) : boolean;\n begin\n if ((x mod 400)=0) then exit(true);\n if ((x mod 4)=0) and ((x mod 100)>0) then exit(true);\n exit(false);\n end;\n procedure build;\n var ny,nm,nd : longint;\n begin\n ny:=y; nm:=m; nd:=d;\n if V(y) then\n begin\n inc(nd);\n if nd>vv[nm] then\n begin\n inc(nm);\n nd:=1;\n end;\n if nm>12 then\n begin\n inc(ny);\n nm:=1;\n nd:=1;\n end;\n end else\n begin\n inc(nd);\n if nd>u[nm] then\n begin\n inc(nm);\n nd:=1;\n end;\n if nm>12 then\n begin\n inc(ny);\n nm:=1;\n nd:=1;\n end;\n end;\n y:=ny; m:=nm; d:=nd;\n end;\nbegin\n u[1]:=31;u[2]:=28;u[3]:=31;u[4]:=30;u[5]:=31;u[6]:=30;u[7]:=31;u[8]:=31;u[9]:=30;u[10]:=31;u[11]:=30;u[12]:=31;\n for i:=1 to 12 do vv[i]:=u[i];\n vv[2]:=29;\n readln(s1);\n readln(s2);\n val(copy(s1,1,4),y,code);\n val(copy(s1,6,2),m,code);\n val(copy(s1,9,2),d,code);\n val(copy(s2,1,4),ty,code);\n val(copy(s2,6,2),tm,code);\n val(copy(s2,9,2),td,code);\n if (y>ty) or ((y=ty) and (m>tm)) or\n ((y=ty) and (m=tm) and (d>td)) then swap;\n while not ((y=ty) and (m=tm) and (d=td)) do\n begin\n build;\n inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var ch,ch1:string;\n a1,a2,a3,b1,b2,b3,k,k1,s,s1,s3,s2,i:longint;\n code,y:integer;\n c:array[1..12]of integer;\n c1:array[1..12]of integer;\n\n\n\n function runnian(a:integer):boolean;\nbegin\n if (a mod 4=0) and (a mod 100<>0) then exit(true)\n else if a mod 400=0 then exit(true);\n exit(false);\n end;\nbegin\n readln(ch);\n readln(ch1);\n s:=0; s1:=0; s3:=0; s2:=0;\n delete(ch,5,1);\n delete(ch,7,1);\n delete(ch1,5,1);\n delete(ch1,7,1);\n val(ch,k,code);\n val(ch1,k1,code);\n a1:=k div 10000;\n b1:=k1 div 10000;\n a2:=k div 100-a1*100;\n b2:=k1 div 100-b1*100;\n a3:=k-(a1*10000+a2*100);\n b3:=k1-(b1*10000+b2*100);\n c[1]:=31; c[2]:=28; c[3]:=31; c[4]:=30; c[5]:=31; c[6]:=30; c[7]:=31;c[8]:=31;c[9]:=30;c[10]:=31;c[11]:=30;c[12]:=31;\nc1[1]:=31; c1[2]:=29; c1[3]:=31; c1[4]:=30; c1[5]:=31; c1[6]:=30; c1[7]:=31;c1[8]:=31;c1[9]:=30;c1[10]:=31;c1[11]:=30;c1[12]:=31;\n if a1>b1 then\n begin\n\n if runnian(a1) then\n for i:=1 to a2-1 do\n begin\n s:=s+c1[i];\n end\n else for i:=1 to a2-1 do\n begin s:=s+c[i];\n end; s:=s+a3;\n\n if runnian(b1) then\n for i:=1 to b2-1 do begin\n s1:=s1+c1[i]; end else for i:=1 to b2-1 do\n begin s1:=s1+c[i]; end; s1:=s1+b3;\n for i:=b1+1 to a1-1 do\n begin\n if runnian(i) then s3:=s3+366 else s3:=s3+365;\n end;\n if runnian(b1) then s2:=366-s1+s+s3 else s2:=365-s1+s+s3;\n end;\n if a10)and(i mod 400<>0)then q:=q+366\n else\n if (i mod 100=0)and(i mod 400=0)then q:=q+366\n else q:=q+365;\n end;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then z:=29\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then z:=29\n else z:=28;\n if luna1=1 then s:=s+zi1;\n if luna1=2 then s:=s+31+zi1;\n if luna1=3 then s:=s+31+zi1+z;\n if luna1=4 then s:=s+62+zi1+z;\n if luna1=5 then s:=s+92+zi1+z;\n if luna1=6 then s:=s+123+zi1+z;\n if luna1=7 then s:=s+153+zi1+z;\n if luna1=8 then s:=s+184+zi1+z;\n if luna1=9 then s:=s+215+zi1+z;\n if luna1=10 then s:=s+245+zi1+z;\n if luna1=11 then s:=s+276+zi1+z;\n if luna1=12 then s:=s+306+zi1+z;\n q:=q+s;\n if an1=1900 then q:=s+365;\n if an1=2038 then q:=q-365;\n s:=0;z:=0;\n for i:=1900 to an2 do\n begin\n if (i mod 4=0)and(i mod 100<>0)and(i mod 400<>0)then w:=w+366\n else\n if (i mod 100=0)and(i mod 400=0)then w:=w+366\n else w:=w+365;\n end;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then z:=29\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then z:=29\n else z:=28;\n if luna2=1 then s:=s+zi2;\n if luna2=2 then s:=s+31+zi2;\n if luna2=3 then s:=s+31+zi2+z;\n if luna2=4 then s:=s+62+zi2+z;\n if luna2=5 then s:=s+92+zi2+z;\n if luna2=6 then s:=s+123+zi2+z;\n if luna2=7 then s:=s+153+zi2+z;\n if luna2=8 then s:=s+184+zi2+z;\n if luna2=9 then s:=s+215+zi2+z;\n if luna2=10 then s:=s+245+zi2+z;\n if luna2=11 then s:=s+276+zi2+z;\n if luna2=12 then s:=s+306+zi2+z;\n w:=w+s;\n if an2=1900 then w:=s+365;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then q:=q-366\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then q:=q-366\n else q:=q-365;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then w:=w-366\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then w:=w-366\n else w:=w-365;\n raspuns:=abs(q-w);\n writeln(Raspuns);\nend."}, {"source_code": "var y1, y2, m1, m2, d1, d2, year : integer;\n kq, k1, k2 : longint;\n c1, c2 : char;\n i, j : integer;\n f2,f1 : text;\n s1, s2 : string;\nconst day : array[1..12] of integer\n = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nfunction songay(x : integer) : integer;\n begin\n if x mod 400 = 0 then exit(366);\n if x mod 100 = 0 then exit(365);\n if x mod 4 = 0 then exit(366);\n exit(365);\n end;\nfunction kt(x : integer) : boolean;\n begin\n if x mod 400 = 0 then exit(true);\n if x mod 100 = 0 then exit(false);\n if x mod 4 = 0 then exit(true);\n exit(false);\n end;\nbegin\n assign(f1, ''); reset(f1);\n readln(f1,s1);\n readln(f1,s2);\n close(f1);\n for i := 1 to length(s1) do\n begin\n if s1[i] = ':' then s1[i] := ' ';\n if s2[i] = ':' then s2[i] := ' ';\n end;\n assign(f2, 'test.txt'); rewrite(f2);\n writeln(f2, s1);\n writeln(f2, s2);\n close(f2);\n reset(f2);\n readln(f2, y1, m1, d1);\n readln(f2, y2, m2, d2);\n close(f2);\n if y1 < y2 then year := y1 else year := y2;\n {---}\n k1 := d1;\n if kt(y1) then\n begin\n if m1 > 2 then inc(k1);\n end;\n for i := 1 to m1 - 1 do\n k1 := k1 + day[i];\n for i := year to y1 - 1 do\n k1 := k1 + songay(i);\n // -----\n k2 := d2;\n if kt(y2) then\n begin\n if m2 > 2 then inc(k2);\n end;\n for i := 1 to m2 - 1 do\n k2 := k2 + day[i];\n for i := year to y2 - 1 do\n k2 := k2 + songay(i);\n writeln(abs(k1-k2));\nend.\n"}, {"source_code": "program b;\nuses sysutils, dateutils;\nvar\n y, m, d: word;\n d1, d2: TDateTime;\nfunction readInt: word;\n var\n c: char;\n s: string;\n res, v: word;\n begin\n s := '';\n repeat read(c) until (c in ['0'..'9']);\n s := s + c;\n repeat\n read(c);\n if (c in ['0'..'9']) then s := s + c else break;\n until false;\n val(s, res, v);\n exit(res);\n end;\nbegin\n y := readInt; m := readInt; d := readInt;\n d1 := encodeDate(y, m, d);\n y := readInt; m := readInt; d := readInt;\n d2 := encodeDate(y, m, d);\n writeln(daysBetween(d1, d2));\nend.\n\n\n"}, {"source_code": "const\n p:array[1..12] of longint=(31,100,31,30,31,30,31,31,30,31,30,31);\nvar\n s1,s2:string;\n x1,y1,z1,x2,y2,z2,ans:longint;\n\nfunction d(s:string;l,r:longint):longint;\nvar\n i,x:longint;\nbegin\n x:=0;\n for i:=l to r do\n x:=x*10+ord(s[i])-48;\n exit(x);\nend;\n\nfunction run(x:longint):boolean;\nbegin\n if x mod 400=0 then exit(true);\n if x mod 100=0 then exit(false);\n if x mod 4=0 then exit(true) else exit(false);\nend;\n\nprocedure next(var x,y,z:longint);\nbegin\n inc(z);\n if z>p[y] then begin z:=1;inc(y);end;\n if y=2 then\n begin\n if (run(x)) and (z=30) then\n begin\n z:=1;inc(y);\n end;\n if (run(x)=false) and (z=29) then\n begin\n z:=1;inc(y);\n end;\n end;\n if y=13 then begin inc(x);y:=1;end;\nend;\n\nprocedure swap(var x,y:longint);\nvar\n temp:longint;\nbegin\n temp:=x;x:=y;y:=temp;\nend;\n\nbegin {main}\n readln(s1);\n readln(s2);\n x1:=d(s1,1,4);y1:=d(s1,6,7);z1:=d(s1,9,10);\n x2:=d(s2,1,4);y2:=d(s2,6,7);z2:=d(s2,9,10);\n if (x1>x2) or ((x1=x2) and (y1>y2)) or ((x1=x2) and (y1=y2) and (z1>z2)) then\n begin\n swap(x1,x2);swap(y1,y2);swap(z1,z2);\n end;\n ans:=0;\n while (x1<>x2) or (y1<>y2) or (z1<>z2) do\n begin\n next(x1,y1,z1);\n inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n s1,s2:string;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s1);\n readln(f,s2);\nend;\nfunction sn(i:integer;k:boolean):integer;\nbegin\n case i of\n 1,3,5,7,8,10,12:sn:=31;\n 4,6,9,11:sn:=30;\n 2:if k then sn:=29\n else sn:=28;\n end;\nend;\nfunction tinh(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:= b+1 to 12 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+sn(b,kt)-c;\n tinh:=t;\n\nend;\nfunction tinh1(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:=1 to b-1 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+c;\n tinh1:=t;\nend;\nprocedure swap(var a,b:longint);\nvar tg:longint;\nbegin\n tg:=a;\n a:=b;\n b:=tg;\nend;\nprocedure process;\nvar t,b,dem,i,vt,k,a1,b1,c1,a2,b2,c2:longint;\n kq:int64;\n kt:boolean;\nbegin\n kq:=0;\n k:=pos(':',s1);\n val(copy(s1,1,k-1),a1);\n delete(s1,1,k);\n k:=pos(':',s1);\n val(copy(s1,1,k-1),b1);\n delete(s1,1,k);\n val(s1,c1);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),a2);\n delete(s2,1,k);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),b2);\n delete(s2,1,k);\n val(s2,c2);\n if a1=a2 then\n begin\n if a1 mod 4=0 then\n begin\n kt:=true;\n if (a1 mod 100=0) and (a1 mod 400=0) then kt:=false;\n end\n else kt:=false;\n if b1>b2 then\n begin\n swap(b1,b2);\n swap(c1,c2);\n end;\n for i:=b1+1 to b2-1 do\n kq:=kq+sn(i,kt);\n if b1=b2 then\n begin\n kq:=abs(c1-c2);\n end\n else kq:=kq+sn(b1,kt)-c1+c2;\n end\n else\n begin\n if a1>a2 then\n begin\n swap(a1,a2);\n swap(b1,b2);\n swap(c1,c2);\n end;\n for i:=a1+1 to a2-1 do\n if (i mod 4=0) then\n begin\n kq:=kq+366;\n if (i mod 100=0) and (i mod 400<>0) then kq:=kq-1;\n end\n else kq:=kq+365;\n kq:=kq+tinh(a1,b1,c1)+tinh1(a2,b2,c2);\n end;\n writeln(g,kq);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "type int=longint;\nconst mf:array[1..12]of int=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n i,j,k,m,n,ans:longint;\n a,b,c,aa,bb,cc:int;\n ch:char;\n f:array[1..12]of int;\nfunction yes(a:int):boolean;\nbegin\n if(a mod 4=0)then\n begin\n if (a mod 100=0)and(a mod 400<>0)then exit(false);\n exit(true);\n end;\n exit(false);\nend;\nprocedure te();\nvar i,j:int;\nbegin\n if yes(a) then inc(f[2]);\n if b=bb then\n begin\n for i:=c+1 to cc do inc(ans);\n writeln(ans);\n close(input);close(output);halt;\n end;\n for i:=b+1 to bb-1 do inc(ans,f[i]);\n inc(ans,f[b]-c);inc(ans,cc);\n writeln(ans);\n close(input);close(output);halt;\nend;\n\nbegin\n \n for i:=1 to 12 do f[i]:=mf[i];\n for i:=1 to 4 do begin\n read(ch);a:=a*10+ord(ch)-48;end;\n read(ch);\n for i:=1 to 2 do begin\n read(ch);b:=b*10+ord(ch)-48;end;\n read(ch);\n for i:=1 to 2 do begin\n read(ch);c:=c*10+ord(ch)-48;end; readln;\n for i:=1 to 4 do begin\n read(ch);aa:=aa*10+ord(ch)-48;end;\n read(ch);\n for i:=1 to 2 do begin\n read(ch);bb:=bb*10+ord(ch)-48;end;\n read(ch);\n for i:=1 to 2 do begin\n read(ch);cc:=cc*10+ord(ch)-48;end;\n if (a>aa)or(a=aa)and(b>bb)or(a=aa)and(b=bb)and(c>cc)then\n begin\n k:=a;a:=aa;aa:=k;\n k:=b;b:=bb;bb:=k;\n k:=c;c:=cc;cc:=k;\n end;\n for i:=a+1 to aa-1 do\n begin\n inc(ans,365);\n if yes(i) then inc(ans);\n end;\n if aa=a then te();\n if yes(a) then inc(f[2]);\n for i:=b+1 to 12 do inc(ans,f[i]);\n inc(ans,f[b]-c);\n f[2]:=mf[2];\n if yes(aa) then inc(f[2]);\n for i:=1 to bb-1 do inc(ans,f[i]);\n inc(ans,cc);\n writeln(ans);\n close(input);close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n s : string;\n a: array [1..10000] of longint;\n code : integer;\n n1,m1,z1,n2,ans,c,m2,z2 : longint;\nbegin\n readln(s);\n val(s[1]+s[2]+s[3]+s[4],n1,code);\n val(s[6]+s[7],m1,code);\n val(s[9]+s[10],z1,code);\n readln(s);\n val(s[1]+s[2]+s[3]+s[4],n2,code);\n val(s[6]+s[7],m2,code);\n val(s[9]+s[10],z2,code);\n if (n1>n2) or ((n1=n2) and ((m1>m2) or ((m1=m2) and (z1>z2)))) then\n begin\n c:=n1;\n n1:=n2;\n n2:=c;\n c:=z1;\n z1:=z2;\n z2:=c;\n c:=m1;\n m1:=m2;\n m2:=c;\n end;\n a[1]:=31;\n a[2]:=28;\n a[3]:=31;\n a[4]:=30;\n a[5]:=31;\n a[6]:=30;\n a[7]:=31;\n a[8]:=31;\n a[9]:=30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n while (true) do\n begin\n inc(ans);\n if (n1=n2) and (m1=m2) and (z1=z2) then begin writeln(ans-1); exit; end;\n inc(z1);\n if (n1 mod 400=0) then a[2]:=29\n else\n if (n1 mod 4=0) and (n1 mod 100<>0) then a[2]:=29\n else\n a[2]:=28;\n if z1>a[m1] then begin inc(m1); z1:=1; end;\n if m1>12 then begin inc(n1); m1:=1; end;\n end;\nend.\n"}, {"source_code": "Program B183;\nVar\n con:Array[1..12] Of Longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n sum:Array[0..12] OF Longint;\n s1,s2,nian,yue,ri:String;\n nian1,nian2,yue1,yue2,ri1,ri2,ans,i,n:Longint;\n flag:Boolean;\nBegin\n For i:=1 To 12 Do sum[i]:=sum[i-1]+con[i];\n Readln(s1);\n Readln(s2);\n If s1>s2 Then Begin\n nian:=s1;\n s1:=s2;\n s2:=nian;\n End;\n nian:=Copy(s1,1,4);\n Val(nian,nian1);\n yue:=Copy(s1,6,2);\n Val(yue,yue1);\n ri:=Copy(s1,9,2);\n Val(ri,ri1);\n nian:=Copy(s2,1,4);\n Val(nian,nian2);\n yue:=Copy(s2,6,2);\n Val(yue,yue2);\n ri:=Copy(s2,9,2);\n Val(ri,ri2);\n flag:=True;\n If (nian1 Mod 100=0) Then Begin\n If nian1 Mod 400<>0 Then flag:=False;\n End Else If nian1 Mod 4<>0 Then flag:=FAlse;\n ans:=ans+sum[12]-sum[yue1];\n ans:=ans+con[yue1]-ri1;\n If (yue1<=2)And(flag) Then Inc(ans);\n For i:=nian1+1 To nian2-1 Do Begin\n ans:=ans+sum[12];\n flag:=True;\n If (i Mod 100=0) Then Begin\n If i Mod 400<>0 Then flag:=False;\n End Else If i Mod 4<>0 Then flag:=False;\n If flag Then Inc(ans);\n End;\n ans:=ans+sum[yue2-1]+ri2;\n flag:=True;\n If (nian2 Mod 100=0) Then Begin\n If nian2 Mod 400<>0 Then flag:=FAlse;\n End Else If nian2 Mod 4<>0 Then flag:=False;\n If (yue2>=3)And(flag) Then inc(ans);\n If nian1=nian2 Then Begin\n ans:=ans-365;\n If flag Then ans:=ans-1;\n End;\n Writeln(ans);\nEnd.\n\n"}, {"source_code": "const a:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar x,y,i,j,all:longint;\n s:string;\nfunction f(s:string):longint;\nvar i,x,n,k,y,m,d:longint;\n begin\n n:=length(s);\n k:=0;y:=0;m:=0;d:=0;x:=0;\n for i:=1 to n do\n if(s[i]=':')then inc(k)\n else\n if(k=0)then y:=y*10+ord(s[i])-48\n else\n if(k=1)then m:=m*10+ord(s[i])-48\n else\n if(k=2)then d:=d*10+ord(s[i])-48;\n for i:=1900 to y-1 do\n if((i mod 4=0)and(i mod 100<>0))or(i mod 400=0)then x:=x+all+1 else x:=x+all;\n for i:=1 to m-1 do\n begin\n x:=x+a[i];\n if(i=2)then if((y mod 4=0)and(y mod 100<>0))or(y mod 400=0) then x:=x+1;\n end;\n x:=x+d;\n exit(x);\n end;\n begin\n for i:=1 to 12 do\n all:=all+a[i];\n readln(s);\n x:=f(s);\n readln(s);\n y:=f(s);\n writeln(abs(y-x));\n end.\n"}, {"source_code": "var s:ansistring;a,b,c,a1,b1,c1,i,d:longint;m:array[0..1000]of longint;\nProcedure data(s:ansistring;var a,b,c:longint);\nvar f:integer;\nbegin\n val(Copy(s,1,pos(':',s)-1),c,f);\n delete(s,1,pos(':',s));\n val(Copy(s,1,pos(':',s)-1),b,f);\n delete(s,1,pos(':',s));\n val(s,a,f);\nend;\nprocedure swap;\nvar x:longint;\nbegin\n x:=c;\n c:=c1;\n c1:=x;\n x:=b;\n b:=b1;\n b1:=x;\n x:=a;\n a:=a1;\n a1:=x;\nend;\nBegin\n readln(s);\n m[1]:=31;\n m[3]:=31;\n m[4]:=30;\n m[5]:=31;\n m[6]:=30;\n m[7]:=31;\n m[8]:=31;\n m[9]:=30;\n m[10]:=31;\n m[11]:=30;\n m[12]:=31;\n data(s,a,b,c);\n readln(s);\n data(s,a1,b1,c1);\n if c>c1 then\n begin\n swap;\n end\n else if c=c1\n then\n begin\n if b>b1 then\n swap\n else if (b=b1) and(a>a1) then swap;\n end;\n if (c mod 400=0)or((c mod 4=0)and(c mod 100>0))then m[2]:=29\n else m[2]:=28;\n for i:=c to c1-1 do\n if (i mod 400=0)or((i mod 4=0)and(i mod 100>0))then d:=d+366\n else d:=d+365;\n for i:=1 to b-1 do\n d:=d-m[i];\n if (c1 mod 400=0)or((c1 mod 4=0)and(c1 mod 100>0))then m[2]:=29\n else m[2]:=28;\n for i:=1 to b1-1 do\n d:=d+m[i];\n d:=d-a+a1;\n writeln(d);\nEnd."}, {"source_code": "const\n a:array [1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n sum,total,y,m,d,yy,mm,dd,sumi,sumj,b,c,e:longint;\n s,ss:string;\nbegin\n readln(s);\n readln(ss);\n y:=(ord(s[1])-48)*1000+(ord(s[2])-48)*100+(ord(s[3])-48)*10+(ord(s[4])-48);\n m:=(ord(s[6])-48)*10+(ord(s[7])-48);\n d:=(ord(s[9])-48)*10+(ord(s[10])-48);\n yy:=(ord(ss[1])-48)*1000+(ord(ss[2])-48)*100+(ord(ss[3])-48)*10+(ord(ss[4])-48);\n mm:=(ord(ss[6])-48)*10+(ord(ss[7])-48);\n dd:=(ord(ss[9])-48)*10+(ord(ss[10])-48);\n if m>1 then\n for b:=1 to m-1 do\n sumi:=sumi+a[b];\n sumi:=sumi+d;\n if (d=29)and(m=2)and(y mod 4=0)and((y mod 100<>0)or(y mod 400=0)) then dec(sumj);\n if mm>1 then\n for b:=1 to mm-1 do\n sumj:=sumj+a[b];\n sumj:=sumj+dd;\n if (dd=29)and(mm=2)and(yy mod 4=0)and((yy mod 100<>0)or(yy mod 400=0)) then dec(sumj);\n total:=(yy-y)*365-sumi+sumj+(yy div 4)-(y div 4)+(yy div 100)-(y div 100)-(yy div 400)+(y div 400);\n writeln(abs(total));\nend.\n\n\n"}, {"source_code": "program uio;\nconst month:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n var s1,s2:string;\n y1,m1,d1,y2,m2,d2,kol,i:longint;\n\n\nprocedure pro(s:string; var y,m,d:longint);\n var code:longint;\n ss:string;\n\nbegin\n\n ss:=s[1]+s[2]+s[3]+s[4];\n val(ss,y,code);\n\n ss:='';\n if s[6]='0' then ss:=ss+s[7]\n else ss:=ss+s[6]+s[7];\n val(ss,m,code);\n\n ss:='';\n if s[9]='0' then ss:=ss+s[10]\n else ss:=ss+s[9]+s[10];\n val(ss,d,code);\n\n\nend;\n\n\nfunction vis(x:longint):boolean;\nbegin\n\n if (x mod 400) = 0 then exit(true);\n if (x mod 4 = 0)and(x mod 100<>0) then exit(true);\n exit(false);\n\nend;\n\n\nprocedure rev;\n var cc:longint;\n\nbegin\n\n cc:=y1; y1:=y2; y2:=cc;\n cc:=m1; m1:=m2; m2:=cc;\n cc:=d1; d1:=d2; d2:=cc;\n\nend;\n\n\n\nBEGIN\n\n readln(s1); readln(s2);\n pro(s1,y1,m1,d1); pro(s2,y2,m2,d2);\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(0); halt; end;\n kol:=0;\n if y1>y2 then rev\n else if (y1=y2)and(m1>m2) then rev\n else if (y1=y2)and(m1=m2)and(d1>d2) then rev;\n\n while (y1<=y2) do\n begin\n if vis(y1) then month[2]:=29;\n while true do\n begin\n inc(d1); inc(kol); if d1>month[m1] then begin inc(m1); d1:=1; end;\n if m1>12 then begin m1:=1; break; end;\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(kol); halt; end;\n end;\n inc(y1); month[2]:=28;\n end;\n\n writeln(kol);\n\nEND.\n"}, {"source_code": "const fi = '';\n fo = '';\n dom: array [1..12] of longint = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nvar day1, month1, year1: longint;\n day2, month2, year2, count: longint;\n\nprocedure SRead(var day, month, year: longint);\nvar s, t: string;\n code: longint;\nbegin\n readln(s);\n val(copy(s, 1, pos(':', s)-1), year, code);\n delete(s, 1, pos(':', s));\n val(copy(s, 1, pos(':', s)-1), month, code);\n delete(s, 1, pos(':', s));\n val(s, day, code);\nend;\n\nprocedure Swap(var a, b: longint);\nvar t: longint;\nbegin\n t:=a; a:=b; b:=t;\nend;\n\nprocedure Work;\nbegin\n if (year1 > year2) or ((year1 = year2) and (month1 > month2))\n or ((year1 = year2) and (month1 = month2) and (day1 > day2)) then\n begin\n Swap(year1, year2);\n Swap(month1, month2);\n Swap(day1, day2);\n end;\n\n while (year1 <> year2) or (month1 <> month2) or (day1 <> day2) do\n begin\n inc(day1);\n if (month1 = 2) and (year1 mod 4 = 0) and ((year1 mod 100 <> 0) or (year1 mod 400 = 0))\n then\n begin\n if day1 > 29 then\n begin\n day1:=1;\n inc(month1)\n end;\n end\n else if (day1 > dom[month1]) then\n begin\n day1:=1;\n inc(month1);\n end;\n\n if month1 > 12 then\n begin\n month1:=1;\n inc(year1);\n end;\n inc(count);\n end;\n writeln(count);\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n SRead(day1, month1, year1);\n SRead(day2, month2, year2);\n Work;\n\n close(input); close(output);\nend.\n"}, {"source_code": "var s1, s2:string; \n y1, y2, d1, d2, m1, m2, i, m:longint; \n a:array[1..15] of longint; \n ans:int64; \n\nprocedure data; \nvar i:longint;\n begin\n \n for i:=1 to 4 do\n begin\n y1:=y1*10+ord(s1[i])-48;\n y2:=y2*10+ord(s2[i])-48;\n end;\n for i:=6 to 7 do \n begin\n m1:=m1*10+ord(s1[i])-48;\n m2:=m2*10+ord(s2[i])-48;\n end;\n for i:=9 to 10 do \n begin\n d1:=d1*10+ord(s1[i])-48; \n d2:=d2*10+ord(s2[i])-48; \n end;\n end;\n\nprocedure con; \n begin\n a[1]:=31;\n a[2]:=28;\n a[3]:=31;\n a[4]:=30;\n a[5]:=31; \n a[6]:=30;\n a[7]:=31; \n a[8]:=31; \n a[9]:=30; \n a[10]:=31; \n a[11]:=30; \n a[12]:=31;\n end;\n \nfunction vis(x:longint):boolean; \nvar bool:boolean;\n begin\n if (x mod 4=0)and(x mod 100<>0) \n then bool:=true\n else if (x mod 400=0) then bool:=true\n else bool:=false; \n vis:=bool;\n end;\n \nprocedure sswap; \nvar cc:longint; \n begin\n cc:=y1; y1:=y2; y2:=cc; \n cc:=m1; m1:=m2; m2:=cc; \n cc:=d1; d1:=d2; d2:=cc; \n end;\n \nprocedure perenos; \n begin\n if y1>y2 then sswap\n else begin\n if (y1=y2)and(m1>m2) then sswap \n else if (y1=y2)and(m1=m2)and(d1>d2)\n then sswap;\n end;\n end;\n \nbegin\n\n//assign(input, 'input.txt'); reset(input);\n//assign(output, 'output.txt'); rewrite(output);\n\nreadln(s1);\nreadln(s2);\n\ncon;\ndata;\nperenos; \n\nif y1=y2 then begin\n \n if vis(y1) \n then begin\n \n if m1=m2 \n then begin\n \n ans:=d2-d1-1;\n \n end\n else begin\n \n ans:=a[m1]-d1;\n if m1=2 then inc(ans);\n ans:=ans+d2-1; \n for m:=m1+1 to m2-1 do \n begin\n ans:=ans+a[m]; \n if m=2 then ans:=ans+1; \n end;\n \n end;\n \n end\n else begin\n \n if m1=m2 \n then begin\n \n ans:=d2-d1-1;\n \n end\n else begin\n \n ans:=a[m1]-d1;\n ans:=ans+d2-1; \n for m:=m1+1 to m2-1 do \n begin\n ans:=ans+a[m]; \n end;\n \n end;\n \n end;\n \n end\n else begin\n \n ans:=a[m1]-d1; \n for i:=m1+1 to 12 do \n begin\n if (i=2)and(vis(y1)) then inc(ans);\n ans:=ans+a[i]; \n end;\n \n for i:=y1+1 to y2-1 do \n if vis(i) then ans:=ans+366\n else ans:=ans+365;\n \n for i:=1 to m2-1 do \n begin\n if (vis(y2))and(i=2) then ans:=ans+1; \n ans:=ans+a[i];\n end;\n \n ans:=ans+d2-1; \n \n end;\n \nwriteln(ans+1);\n\n//close(input); close(output);\n\nend."}, {"source_code": "var y1,y2,dem:word; m1,d1,m2,d2,i:byte; s,p,tg:string[10];\nfunction day(month:byte;year:word):byte;\nbegin\n case month of\n 4,6,9,11: day:=30;\n 2: if (year mod 400=0) or ((year mod 4=0) and (year mod 100>0)) then day:=29\n else day:=28\n else day:=31\n end\nend;\nbegin\n readln(s);\n readln(p);\n if s>p then\n begin\n tg:=s; s:=p; p:=tg\n end;\n val(s[1]+s[2]+s[3]+s[4],y1,i);\n val(s[6]+s[7],m1,i);\n val(s[9]+s[10],d1,i);\n val(p[1]+p[2]+p[3]+p[4],y2,i);\n val(p[6]+p[7],m2,i);\n val(p[9]+p[10],d2,i);\n dem:=0;\n while (y1x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//珍爱生命,请勿抄袭代码,如果现在打开这个界面的(未经允许下)是WYT,那你就去死吧,抄袭Dog!!!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1=x2) then dec(ans);\n if ans=1 then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if y1=y2 then dec(ans);\n if ans=1 then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if ans=366 then ans:=0;\n if ans=397 then ans:=31;\n writeln(ans);\nend."}, {"source_code": "program B304;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n a:array[1..12] of integer;\n i,g,m,d,g1,m1,d1,c,j,sum:integer;\nprocedure obmen;\n var\n c:integer;\n begin\n c:=g; g:=g1; g1:=c;\n c:=m; m:=m1; m1:=c;\n c:=d; d:=d1; d1:=c;\n end;\nbegin\n readln(s);\n readln(s1);\n a[1]:=31; a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30;\n a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31;\n val(s,g,c); delete(s,1,5);\n val(s,m,c); delete(s,1,3);\n val(s,d,c);\n val(s1,g1,c); delete(s1,1,5);\n val(s1,m1,c); delete(s1,1,3);\n val(s1,d1,c);\n if g10))or(i mod 400=0) then\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,366);\n end\n else\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,365);\n end;\n writeln(sum);\n readln; readln;\nend.\n"}, {"source_code": "program B304;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n a:array[1..12] of integer;\n i,g,m,d,g1,m1,d1,c,j,sum:integer;\nprocedure obmen;\n var\n c:integer;\n begin\n c:=g; g:=g1; g1:=c;\n c:=m; m:=m1; m1:=c;\n c:=d; d:=d1; d1:=c;\n end;\nbegin\n readln(s);\n readln(s1);\n a[1]:=31; a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30;\n a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31;\n val(s,g,c); delete(s,1,5);\n val(s,m,c); delete(s,1,3);\n val(s,d,c);\n val(s1,g1,c); delete(s1,1,5);\n val(s1,m1,c); delete(s1,1,3);\n val(s1,d1,c);\n if g10))or(i mod 400=0) then\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,366);\n end\n else\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,365);\n end;\n writeln(sum);\n readln; readln;\nend.\n"}, {"source_code": "program B304;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n a:array[1..12] of integer;\n i,g,m,d,g1,m1,d1,c,j,sum:integer;\nprocedure obmen;\n var\n c:integer;\n begin\n c:=g; g:=g1; g1:=c;\n c:=m; m:=m1; m1:=c;\n c:=d; d:=d1; d1:=c;\n end;\nbegin\n readln(s);\n readln(s1);\n a[1]:=31; a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30;\n a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31;\n val(s,g,c); delete(s,1,5);\n val(s,m,c); delete(s,1,3);\n val(s,d,c);\n val(s1,g1,c); delete(s1,1,5);\n val(s1,m1,c); delete(s1,1,3);\n val(s1,d1,c);\n if g10))or(i mod 400=0) then\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,366);\n end\n else\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,365);\n end;\n writeln(sum);\n readln; readln;\nend.\n"}, {"source_code": "program B304;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s,s1:string;\n a:array[1..12] of integer;\n i,g,m,d,g1,m1,d1,c,j,sum:integer;\nprocedure obmen;\n var\n c:integer;\n begin\n c:=g; g:=g1; g1:=c;\n c:=m; m:=m1; m1:=c;\n c:=d; d:=d1; d1:=c;\n end;\nbegin\n readln(s);\n readln(s1);\n a[1]:=31; a[2]:=28; a[3]:=31; a[4]:=30; a[5]:=31; a[6]:=30;\n a[7]:=31; a[8]:=31; a[9]:=30; a[10]:=31; a[11]:=30; a[12]:=31;\n val(s,g,c); delete(s,1,5);\n val(s,m,c); delete(s,1,3);\n val(s,d,c);\n val(s1,g1,c); delete(s1,1,5);\n val(s1,m1,c); delete(s1,1,3);\n val(s1,d1,c);\n if g10))or(i mod 400=0) then\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]+1) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,366);\n end\n else\n begin\n if (i=g)and(i<>g1) then\n begin\n for j:=12 downto m+1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,a[m]-d);\n end;\n if (i<>g)and(i=g1) then\n begin\n for j:=1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n inc(sum,d1);\n end;\n if (i=g)and(i=g1) then\n begin\n for j:=m+1 to m1-1 do if j=2 then inc(sum,a[j]) else inc(sum,a[j]);\n if m=m1 then inc(sum,d1-d)\n else begin inc(sum,d1); inc(sum,a[m]-d); end;\n end;\n if (i<>g)and(i<>g1) then inc(sum,365);\n end;\n writeln(sum);\n readln; readln;\nend.\n"}, {"source_code": "program Project666;\n\n{$APPTYPE CONSOLE}\n\nuses math,sysutils;\n\n\n var m: integer;\n i,j: integer;\n y1,m1,d1,y2,m2,d2,d: integer;\n date1,date2,s: string;\n\n\n function substr(s: string; n,m: integer):integer;\n var str: string;\n i: integer;\n a,d: integer;\n begin\n d := 1;\n a := 0;\n for i := m downto n do\n begin\n // writeln(a);\n a := a + ( StrToInt(s[i]) * d );\n d := d*10;\n end;\n substr := a;\n end;\n\nbegin\n \n\n readln(date1);\n readln(date2);\n\n y1 := substr(date1,1,4);\n y2 := substr(date2,1,4);\n\n m1 := substr(date1,6,7);\n m2 := substr(date2,6,7);\n\n d1 := substr(date1,9,10);\n d2 := substr(date2,9,10);\n\n if y1 > y2 then\n begin\n d := y1;\n y1 := y2;\n y2 := d;\n\n d := m1;\n m1 := m2;\n m2 := d;\n\n d := d1;\n d1 := d2;\n d2 := d;\n\n end;\n\n d := 0;\n\n for i := y1 to y2-1 do\n if (i MOD 4 = 0) and ( i MOD 100 <> 0 ) then\n d := d + 366\n else if (i MOD 4 = 0) and ( i MOD 400 = 0 ) then\n d := d + 366\n else d := d + 365;\n\n\n for i := m1 downto 2 do\n if (i = 3) then\n begin\n d := d - 28;\n if (y1 MOD 4 = 0) and (y1 MOD 100 <> 0)\n or (y1 MOD 4 = 0) and (y1 MOD 400 = 0) then\n d := d-1;\n end\n else\n if i MOD 2 = 0 then\n d := d - 31\n else d := d - 30;\n\n for i := 2 to m2 do\n if (i = 3) then\n begin\n d := d + 28;\n if (y1 MOD 4 = 0) and (y1 MOD 100 <> 0)\n or (y1 MOD 4 = 0) and (y1 MOD 400 = 0) then\n d := d+1;\n end\n else\n if i MOD 2 = 0 then\n d := d + 31\n else d := d + 30;\n\n d := d - d1+d2;\n\n write(d);\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s1, s2: string;\n d1, d2, m1, m2, y1, y2: integer;\n\nfunction isBig(n: integer):boolean;\nbegin\n if (n mod 400 = 0) or ((n mod 4 = 0) and (n mod 100 <> 0)) then\n result := true\n else\n result := false;\nend;\n \nfunction CheckDay(day, month, year: integer): boolean;\nbegin\n if ((day > 30) and (month in [2,4,6,9,11])) or\n ((day > 29) and (month = 2)) or\n ((day > 28) and (month = 2) and (not isBig(year))) then\n result := false\n else\n result := true;\nend;\n\nfunction DaysFromZero(y, m, d: integer): integer;\nvar\n yn, dn, mn: integer;\nbegin\n yn := 1899;\n dn := 1;\n mn := 1;\n\n result := 0;\n while true do begin\n inc(result);\n inc(dn);\n if (dn > 31) or not CheckDay(dn, mn, yn) then begin\n dn := 1;\n inc(mn);\n end;\n if mn > 12 then begin\n mn := 1;\n dn := 1;\n inc(yn);\n end;\n if (dn = d) and (yn = y) and (mn = m) then break;\n end;\nend;\n\nbegin\n //reset(input, 'a.in');\n //rewrite(output, 'a.out');\n readln(s1);\n y1 := strtoint(copy(s1, 1, 4));\n m1 := strtoint(copy(s1, 6, 2));\n d1 := strtoint(copy(s1, 9, 2));\n readln(s2);\n y2 := strtoint(copy(s2, 1, 4));\n m2 := strtoint(copy(s2, 6, 2));\n d2 := strtoint(copy(s2, 9, 2));\n writeln(DaysFromZero(y1, m1, d1));\n writeln(DaysFromZero(y2, m2, d2));\n writeln(abs(DaysFromZero(y1, m1, d1) - DaysFromZero(y2, m2, d2)));\nend.\n"}, {"source_code": "\nconst\n fi = '';\n fo = '';\n ngay : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n d1,m1,y1,d2,m2,y2,p,code,i,j,nn,nt,t : longint;\n phu,s : string;\n\nprocedure swap(var x,y : longint);\nvar\n p : longint;\nbegin\n p := x;\n x := y;\n y := p;\nend;\n\nfunction ktnamnhuan(i:longint):longint;\nbegin\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then ktnamnhuan := 1\n else ktnamnhuan := 0;\nend;\n\nprocedure xuat(t:longint);\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(t);\n close(output);\n halt;\nend;\n\nbegin \n assign(input,fi);\n reset(input);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y1=0 then val(phu,y1,code)\n else val(phu,m1,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d1,code);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y2=0 then val(phu,y2,code)\n else val(phu,m2,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d2,code);\n close(input);\n if y1 > y2 then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i := y1+1 to y2-1 do\n if ktnamnhuan(i)=1 then inc(nn)\n else inc(nt);\n t := 365*nt + 366*nn;\n\n if (y1 = y2) then\n begin\n if m1 > m2 then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n p := ktnamnhuan(y1);\n for i := m1+1 to m2-1 do\n if i <> 2 then t := t+ngay[i]\n else t := t+ngay[i]+p;\n if m1 = m2 then\n begin\n if d1 > d2 then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n if d1 = d2 then xuat(0);\n t := t+d2-d1;\n end\n else t := t+ngay[m1]-d1+d2;\n end\n else\n begin\n p := ktnamnhuan(y1);\n for i := m1+1 to 12 do\n if i<>2 then t := t+ngay[i]\n else t := t+ngay[i]+p;\n p := ktnamnhuan(y2);\n for i := 1 to m2-1 do\n if i<>2 then t := t+ngay[i]\n else t := t+ngay[i]+p;\n t := t+ngay[m1]-d1+d2;\n end;\n xuat(t);\nend.\n"}, {"source_code": "const\n fi = '';\n fo = '';\n ngay : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n d1,m1,y1,d2,m2,y2,p,code,i,j,nn,nt,t : longint;\n phu,s : string;\n\nprocedure swap(var x,y : longint);\nvar\n p : longint;\nbegin\n p := x;\n x := y;\n y := p;\nend;\n\nfunction ktnamnhuan(i:longint):longint;\nbegin\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then ktnamnhuan := 1\n else ktnamnhuan := 0;\nend;\n\nprocedure xuat(t:longint);\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(t);\n close(output);\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y1=0 then val(phu,y1,code)\n else val(phu,m1,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d1,code);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y2=0 then val(phu,y2,code)\n else val(phu,m2,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d2,code);\n close(input);\n if (y1 > y2) or ((y1 = y2) and (m1 > m2)) or ((y1 = y2) and (m1 = m2) and (d1 > d2)) then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end\n else if (y1 = y2) and (m1 = m2) and (d1 = d2) then xuat(0);\n for i := y1+1 to y2-1 do\n if ktnamnhuan(i)=1 then inc(nn)\n else inc(nt);\n t := 365*nt + 366*nn;\n p := ktnamnhuan(y1);\n for i := m1+1 to 12 do\n if i<>2 then t := t+ngay[i]\n else t := t+ngay[i]+p;\n p := ktnamnhuan(y2);\n for i := 1 to m2-1 do\n if i<>2 then t := t+ngay[i]\n else t := t+ngay[i]+p;\n t := t+ngay[m1]-d1+d2;\n xuat(t);\nend.\n"}, {"source_code": "var\n v:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n sum:array[0..12] of longint;\n i,j,k,n,m,x1,y1,z1,x2,y2,z2:longint;\n ans:int64;\n s1,s2:string;\n\nProcedure Solve;\nvar\n k,x:longint;\n s:string;\nbegin\n if s1>s2 then\n begin\n s:=s1;\n s1:=s2;\n s2:=s;\n end;\n s:=Copy(s1,1,4);\n val(s,x1,x);\n s:=Copy(s1,6,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y1,x);\n s:=Copy(s1,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z1,x);\n s:=Copy(s2,1,4);\n val(s,x2,x);\n s:=Copy(s2,6 ,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y2,x);\n s:=Copy(s2,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z2,x);\nend;\n\nFunction Run(x:longint):boolean;\nbegin\n if x mod 4<>0 then exit(false);\n if x mod 400=0 then exit(True);\n if x mod 100=0 then exit(false);\n exit(true);\nend;\n\nBegin\n readln(s1);\n readln(s2);\n Solve;\n for i:=1 to 12 do sum[i]:=sum[i-1]+v[i];\n ans:=0;\n if x12) then inc(ans);\n end;\n end\n else\n begin\n if y1s2 then\n begin\n s:=s1;\n s1:=s2;\n s2:=s;\n end;\n s:=Copy(s1,1,4);\n val(s,x1,x);\n s:=Copy(s1,6,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y1,x);\n s:=Copy(s1,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z1,x);\n s:=Copy(s2,1,4);\n val(s,x2,x);\n s:=Copy(s2,6 ,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y2,x);\n s:=Copy(s2,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z2,x);\nend;\n\nFunction Run(x:longint):boolean;\nbegin\n if x mod 4<>0 then exit(false);\n if x mod 400=0 then exit(True);\n if x mod 100=0 then exit(false);\n exit(true);\nend;\n\nBegin\n readln(s1);\n readln(s2);\n Solve;\n for i:=1 to 12 do sum[i]:=sum[i-1]+v[i];\n ans:=0;\n if x12) then inc(ans);\n end;\n writeln(ans-1);\nend.\n"}, {"source_code": "var\n v:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n sum:array[0..12] of longint;\n i,j,k,n,m,x1,y1,z1,x2,y2,z2:longint;\n ans:int64;\n s1,s2:string;\n\nProcedure Solve;\nvar\n k,x:longint;\n s:string;\nbegin\n if s1>s2 then\n begin\n s:=s1;\n s1:=s2;\n s2:=s;\n end;\n s:=Copy(s1,1,4);\n val(s,x1,x);\n s:=Copy(s1,6,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y1,x);\n s:=Copy(s1,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z1,x);\n s:=Copy(s2,1,4);\n val(s,x2,x);\n s:=Copy(s2,6 ,2);\n if s[1]='0' then delete(s,1,1);\n val(s,y2,x);\n s:=Copy(s2,9,2);\n if s[1]='0' then Delete(s,1,1);\n val(s,z2,x);\nend;\n\nFunction Run(x:longint):boolean;\nbegin\n if x mod 4<>0 then exit(false);\n if x mod 400=0 then exit(True);\n if x mod 100=0 then exit(false);\n exit(true);\nend;\n\nBegin\n readln(s1);\n readln(s2);\n Solve;\n for i:=1 to 12 do sum[i]:=sum[i-1]+v[i];\n ans:=0;\n if x12) or (y2=2) and (z2=29) then inc(ans);\n end;\n writeln(ans-1);\nend.\n"}, {"source_code": "const f:array[1..12] of longint=(31,59,90,120,151,181,212,243,273,304,334,365);\nvar sum,y1,m1,d1,y2,m2,d2,i,y:longint;\n d:string;\nfunction pd(x:longint):boolean;\nbegin\n if x mod 400=0 then\n exit(true);\n if (x mod 100<>0) and (x mod 4=0) then\n exit(true);\n exit(false);\nend;\nbegin\n // assign(input,'rl.in'); reset(input);\n // assign(output,'rl.out'); rewrite(output);\n readln(d);\n val(copy(d,1,4),y1);\n val(copy(d,6,2),m1);\n delete(d,1,8);\n val(d,d1);\n readln(d);\n val(copy(d,1,4),y2);\n val(copy(d,6,2),m2);\n delete(d,1,8);\n val(d,d2);\n if (y1>y2) or ((y1=y2) and (m1>m2)) or ((y1=y2) and (m1=m2) and (d1>d2)) then\n begin\n y:=y1; y1:=y2; y2:=y;\n y:=m1; m1:=m2; m2:=y;\n y:=d1; d1:=d2; d2:=y;\n end;\n if m1 in [1,3,5,7,8,10,12] then\n sum:=31-d1+f[12]-f[m1]\n else if m1 in [4,6,9,11] then\n sum:=30-d1+f[12]-f[m1]\n else\n sum:=28-d1+f[12]-f[m1];\n if pd(y1) and (m1<=2) then\n sum:=sum+1;\n for i:=y1+1 to y2-1 do\n if pd(i) then\n sum:=sum+366\n else\n sum:=sum+365;\n sum:=sum+f[m2-1]+d2;\n if pd(y2) and (m2>2) then\n sum:=sum+1;\n writeln(sum);\n close(input); close(output);\nend.\n\n\n\n\n"}, {"source_code": "const g:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar s,s1:string;\n a:array[1..5000] of longint;\n i,j,sum1,sum2,k,l,m,n,y1,y2,m1,m2,d1,d2,q,cod:longint;\nbegin\n readln(s);\n readln(s1);\n\n for i:=1 to 2038 do\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then a[i]:=1;\n q:=1000;\n for i:=1 to 4 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n y1:=y1+k*q;\n y2:=y2+l*q;\n q:=q div 10;\n end;\n q:=10;\n k:=0;\n l:=0;\n for i:=6 to 7 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n m1:=m1+k*q;\n m2:=m2+l*q;\n q:=q div 10;\n end;\n q:=10;\n k:=0;\n l:=0;\n for i:=9 to 10 do\n begin\n val(s[i],k,cod);\n val(s1[i],l,cod);\n d1:=d1+k*q;\n d2:=d2+l*q;\n q:=q div 10;\n end;\nsum1:=d1;\nfor i:=m1-1 downto 1 do\nsum1:=sum1+g[i];\nsum1:=sum1+y1*365;\nfor i:=1 to y1 do\nif a[i]<>0 then inc(sum1);\n\nsum2:=d2;\nfor i:=m2-1 downto 1 do\nsum2:=sum2+g[i];\nsum2:=sum2+y2*365;\nfor i:=1 to y2 do\nif a[i]<>0 then inc(sum2);\n\nwrite(abs(sum1-sum2));\nend.\n"}, {"source_code": "const days :array[1..12]of longint =(31,28,31,30,31,30,31,31,30,31,30,31);\n dayv :array[1..12]of longint =(31,29,31,30,31,30,31,31,30,31,30,31);\nvar s1,s2,t :string;\n y1,y2,m1,m2,d1,d2,d,m,y :longint;\n ans :int64;\nFunction vis(a :longint): boolean;\nBegin\n if (a mod 400)=0 then exit(true);\n if (a mod 100)=0 then exit(false);\n if (a mod 4)=0 then exit(true);\n exit(false);\nend;\nBegin\n readln(s1);\n readln(s2);\n if s1>s2 then\n Begin\n t:=s1;\n s1:=s2;\n s2:=t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s2,1,4),y2);\n val(copy(s1,6,2),m1);\n val(copy(s2,6,2),m2);\n val(copy(s1,9,2),d1);\n val(copy(s2,9,2),d2);\n ans:=0;\n for y:=y1+1 to y2-1 do\n if vis(y) then inc(ans,366) else inc(ans,365);\n for m:=12 downto m1+1 do\n if vis(y1) then inc(ans,dayv[m])\n else inc(ans,days[m]);\n if vis(y1) then\n for d:=dayv[m1] downto d1 do inc(ans)\n else\n for d:=days[m1] downto d1 do inc(ans);\n if vis(y2) then\n Begin\n for m:=1 to m2-1 do inc(ans,dayv[m]);\n inc(ans,d2);\n end else\n Begin\n for m:=1 to m2-1 do inc(ans,days[m]);\n inc(ans,d2);\n end;\n writeln(ans-1);\nend."}, {"source_code": "const days :array[1..12]of longint =(31,28,31,30,31,30,31,31,30,31,30,31);\n dayv :array[1..12]of longint =(31,29,31,30,31,30,31,31,30,31,30,31);\nvar s1,s2,t :string;\n y1,y2,m1,m2,d1,d2,d,m,y :longint;\n ans :int64;\nFunction vis(a :longint): boolean;\nBegin\n if (a mod 400)=0 then exit(true);\n if (a mod 100)=0 then exit(false);\n if (a mod 4)=0 then exit(true);\n exit(false);\nend;\nBegin\n readln(s1);\n readln(s2);\n if s1>s2 then\n Begin\n t:=s1;\n s1:=s2;\n s2:=t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s2,1,4),y2);\n val(copy(s1,6,2),m1);\n val(copy(s2,6,2),m2);\n val(copy(s1,9,2),d1);\n val(copy(s2,9,2),d2);\n if y1=y2 then\n Begin\n ans:=0;\n if vis(y1) then\n Begin\n for m:=m1+1 to m2-1 do\n inc(ans,dayv[m]);\n if m1=m2 then\n inc(ans,d2-d1+1)\n else\n Begin\n inc(ans,dayv[m1]-d1+1);\n inc(ans,d2);\n end;\n end else\n Begin\n for m:=m1+1 to m2-1 do\n inc(ans,days[m]);\n if m1=m2 then\n inc(ans,d2-d1+1)\n else\n Begin\n inc(ans,dayv[m1]-d1+1);\n inc(ans,d2);\n end;\n end;\n writeln(ans-1);\n halt;\n end;\n ans:=0;\n for y:=y1+1 to y2-1 do\n if vis(y) then inc(ans,366) else inc(ans,365);\n for m:=12 downto m1+1 do\n if vis(y1) then inc(ans,dayv[m])\n else inc(ans,days[m]);\n if vis(y1) then\n for d:=dayv[m1] downto d1 do inc(ans)\n else\n for d:=days[m1] downto d1 do inc(ans);\n if vis(y2) then\n Begin\n for m:=1 to m2-1 do inc(ans,dayv[m]);\n inc(ans,d2);\n end else\n Begin\n for m:=1 to m2-1 do inc(ans,days[m]);\n inc(ans,d2);\n end;\n writeln(ans-1);\nend."}, {"source_code": "var\n t,p1,p2,n,m,k,kol,ans,x,y,z:int64;\n sa,sb:string;\n s1,s2,s3:string;\n d:array[1..12] of int64;\n res1,res2,res:int64;\n i,j:longint;\n\nfunction check(s:string):longint;\nvar\n s1,s2,s3,sa,sb:string;\n f1,f2,f3:integer;\n ans,c1,c2,c3,x,y,z,p1,p2:int64;\nbegin\n ans:=0;\n kol:=0;\n for i:=1 to length(s) do if s[i]=':' then\n begin\n inc(kol);\n if kol=1 then p1:=i;\n if kol=2 then p2:=i;\n end;\n s1:=copy(s,1,p1-1);\n s2:=copy(s,p1+1,p2-p1-1);\n s3:=copy(s,p2+1,length(s)-p2);\n val(s1,c1,f1);\n val(s2,c2,f2);\n val(s3,c3,f3);\n for i:=1900 to c1-1 do\n begin\n if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to c2-1 do if ((i=2)and((c1 mod 4=0)and(c1 mod 100<>0))or(c1 mod 400=0)) then inc(ans,d[i]+1) else inc(ans,d[i]);\n inc(ans,c3);\n check:=ans;\nend;\n\n\n\nbegin\n d[1]:=31; d[2]:=28; d[3]:=31; d[4]:=30; d[5]:=31;\n d[6]:=30; d[7]:=31; d[8]:=31; d[9]:=30; d[10]:=31; d[11]:=30;\n d[12]:=31;\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n res1:=0;\n res2:=0;\n res:=0;\n readln(sa);\n readln(sb);\n res1:=check(sa);\n res2:=check(sb);\n res:=abs(res2-res1);\n writeln(res);\nend.\n"}, {"source_code": "var\n t,p1,p2,n,m,k,kol,ans,x,y,z:int64;\n sa,sb:string;\n s1,s2,s3:string;\n d:array[1..12] of int64;\n res1,res2,res:int64;\n i,j:longint;\n\nfunction check(s:string):longint;\nvar\n s1,s2,s3,sa,sb:string;\n f1,f2,f3:integer;\n ans,c1,c2,c3,x,y,z,p1,p2:int64;\nbegin\n ans:=0;\n for i:=1 to length(s) do if s[i]=':' then\n begin\n inc(kol);\n if kol=1 then p1:=i;\n if kol=2 then p2:=i;\n end;\n s1:=copy(s,1,p1-1);\n s2:=copy(s,p1+1,p2-p1-1);\n s3:=copy(s,p2+1,length(s)-p2);\n val(s1,c1,f1);\n val(s2,c2,f2);\n val(s3,c3,f3);\n for i:=1900 to c1-1 do\n begin\n if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to c2-1 do if ((i=2)and((c1 mod 4=0)and(c1 mod 100<>0))or(c1 mod 400=0)) then inc(ans,d[i]+1) else inc(ans,d[i]);\n inc(ans,c3);\n check:=ans;\nend;\n\n\n\nbegin\n d[1]:=31; d[2]:=28; d[3]:=31; d[4]:=30; d[5]:=31;\n d[6]:=30; d[7]:=31; d[8]:=31; d[9]:=30; d[10]:=31; d[11]:=30;\n d[12]:=31;\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(sa);\n readln(sb);\n res1:=check(sa);\n res2:=check(sb);\n res:=abs(res2-res1);\n writeln(res);\nend."}, {"source_code": "var\n t,p1,p2,n,m,k,kol,ans,x,y,z:int64;\n sa,sb:string;\n s1,s2,s3:string;\n d:array[1..12] of int64;\n res1,res2,res:int64;\n i,j:longint;\n\nfunction check(s:string):longint;\nvar\n s1,s2,s3,sa,sb:string;\n f1,f2,f3:integer;\n ans,c1,c2,c3,x,y,z,p1,p2:int64;\nbegin\n ans:=0;\n for i:=1 to length(s) do if s[i]=':' then\n begin\n inc(kol);\n if kol=1 then p1:=i;\n if kol=2 then p2:=i;\n end;\n s1:=copy(s,1,p1-1);\n s2:=copy(s,p1+1,p2-p1-1);\n s3:=copy(s,p2+1,length(s)-p2);\n val(s1,c1,f1);\n val(s2,c2,f2);\n val(s3,c3,f3);\n for i:=1900 to c1-1 do\n begin\n if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to c2-1 do if ((i=2)and((c1 mod 4=0)and(c1 mod 100<>0))or(c1 mod 400=0)) then inc(ans,d[i]+1) else inc(ans,d[i]);\n inc(ans,c3);\n check:=ans;\nend;\n\n\n\nbegin\n d[1]:=31; d[2]:=28; d[3]:=31; d[4]:=30; d[5]:=31;\n d[6]:=30; d[7]:=31; d[8]:=31; d[9]:=30; d[10]:=31; d[11]:=30;\n d[12]:=31;\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(sa);\n readln(sb);\n res1:=check(sa);\n res2:=check(sb);\n res:=abs(res2-res1);\n writeln(res);\nend.\n\n"}, {"source_code": "var\n p1,p2,i,j,n,m,k,kol,ans,x,y,z:longint;\n sa,sb:string;\n s1,s2,s3:string;\n d:array[1..12] of longint;\n res1,res2,res:int64;\n\n\nfunction check(s:string):longint;\nvar\n s1,s2,s3,sa,sb:string;\n f1,f2,f3:integer;\n ans,c1,c2,c3,x,y,z,p1,p2:int64;\nbegin\n ans:=0;\n for i:=1 to length(s) do if s[i]=':' then\n begin\n inc(kol);\n if kol=1 then p1:=i;\n if kol=2 then p2:=i;\n end;\n s1:=copy(s,1,p1-1);\n s2:=copy(s,p1+1,p2-p1-1);\n s3:=copy(s,p2+1,length(s)-p2);\n val(s1,c1,f1);\n val(s2,c2,f2);\n val(s3,c3,f3);\n for i:=1900 to c1-1 do\n begin\n if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to c2-1 do if ((i=2)and((c1 mod 4=0)and(c1 mod 100<>0))or(c1 mod 400=0)) then inc(ans,d[i]+1) else inc(ans,d[i]);\n inc(ans,c3);\n check:=ans;\nend;\n\n\n\nbegin\n d[1]:=31; d[2]:=28; d[3]:=31; d[4]:=30; d[5]:=31;\n d[6]:=30; d[7]:=31; d[8]:=31; d[9]:=30; d[10]:=31; d[11]:=30;\n d[12]:=31;\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(sa);\n readln(sb);\n res1:=check(sa);\n res2:=check(sb);\n res:=abs(res2-res1);\n writeln(res);\nend.\n\n"}, {"source_code": "Program bt2;\nConst fi='';\n fo='';\nvar f1,f2:text;\n a:string;\n nam1,thang1,nam2,x2,y2,thang2,ngay2,ngay1,p,x,y,i,o:integer;\n kq:longint;\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,a);\n nam1:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang1:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay1:=(ord(a[9])-48)*10+(ord(a[10])-48);\n readln(f1,a);\n nam2:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang2:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay2:=(ord(a[9])-48)*10+(ord(a[10])-48);\nend;\n\nProcedure xulinam;\nbegin\n if nam1>nam2 then\n begin\n x:=nam2;\n y:=nam1;\n end\n else\n begin\n x:=nam1;\n y:=nam2;\n end;\n for i:=x+1 to y-1 do\n begin\n if (i mod 4=0) and(i mod 100<>0) then\n kq:=kq+366\n else if(i mod 400)=0 then kq:=kq+366\n else kq:=kq+365;\n end;\nend;\n\nProcedure xuli(u:byte);\nbegin\n for o:=1 to u-1 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n end;\nend;\n\nProcedure xuli3(u:byte);\nbegin\n for o:=u+1 to 12 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n else if o=12 then kq:=kq+31;\n end;\nend;\n\nProcedure xuli2(u:byte);\nbegin\n for p:=thang2 to thang1-1 do\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30;\nend;\n\nProcedure xulingay1(u:byte);\nbegin\n kq:=kq+u;\nend;\n\nProcedure xulingay2(u,l:byte);\nbegin\no:=l;\nif o=1 then o:=31\n else if o=2 then o:=28\n else if o=3 then o:=31\n else if o=4 then o:=30\n else if o=5 then o:=31\n else if o=6 then o:=30\n else if o=7 then o:=31\n else if o=8 then o:=31\n else if o=9 then o:=30\n else if o=10 then o:=31\n else if o=11 then o:=30\n else if o=12 then o:=31;\n kq:=kq+o-u;\nend;\n\nProcedure xulingay3;\nbegin\nif ngay1>ngay2 then\nkq:=kq+ngay2-ngay1+1\nelse\nkq:=kq+ngay1-ngay2+1;\nend;\n\nProcedure xulithang;\nbegin\nif nam1>nam2 then\n begin\n xuli(thang1);\n xuli3(thang2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\nelse if nam1thang2 then\n begin\n xuli2(thang2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\n else\n begin\n xuli2(thang1);\n if thang10)) or (nam1 mod 400=0) then\n kq:=kq+1;\nif nam1>nam2 then\nbegin\nx:=nam1;\nx2:=thang1;\ny:=nam2;\ny2:=thang2;\nend\nelse if nam1nam2 then\nbegin\nif ((x mod 4=0) and (x mod 100<>0)) or (x mod 400=0) then if x2>2 then kq:=kq+1;\nif ((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0) then if y2<=2 then kq:=kq+1;\nend;\nwriteln(f2,kq);\nclose(f1);\nclose(f2);\nend.\n\n"}, {"source_code": "Program bt2;\nConst fi='';\n fo='';\nvar f1,f2:text;\n a:string;\n nam1,thang1,nam2,x2,y2,thang2,ngay2,ngay1,p,x,y,i,o:integer;\n kq:longint;\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,a);\n nam1:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang1:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay1:=(ord(a[9])-48)*10+(ord(a[10])-48);\n readln(f1,a);\n nam2:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang2:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay2:=(ord(a[9])-48)*10+(ord(a[10])-48);\nend;\n\nProcedure xulinam;\nbegin\n if nam1>nam2 then\n begin\n x:=nam2;\n y:=nam1;\n end\n else\n begin\n x:=nam1;\n y:=nam2;\n end;\n for i:=x+1 to y-1 do\n begin\n if (i mod 4=0) and(i mod 100<>0) then\n kq:=kq+366\n else if(i mod 400)=0 then kq:=kq+366\n else kq:=kq+365;\n end;\nend;\n\nProcedure xuli(u:byte);\nbegin\n for o:=1 to u-1 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n end;\nend;\n\nProcedure xuli3(u:byte);\nbegin\n for o:=u+1 to 12 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n else if o=12 then kq:=kq+31;\n end;\nend;\n\nProcedure xuli2(u:byte);\nvar l:byte;\nbegin\nif u=1 then\nbegin\nu:=thang1;\nl:=thang2;\nend;\nif u=2 then\nbegin\nu:=thang2;\nl:=thang1;\nend;\n for o:=u to l-1 do\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30;\nend;\n\nProcedure xulingay1(u:byte);\nbegin\n kq:=kq+u;\nend;\n\nProcedure xulingay2(u,l:byte);\nbegin\no:=l;\nif o=1 then o:=31\n else if o=2 then o:=28\n else if o=3 then o:=31\n else if o=4 then o:=30\n else if o=5 then o:=31\n else if o=6 then o:=30\n else if o=7 then o:=31\n else if o=8 then o:=31\n else if o=9 then o:=30\n else if o=10 then o:=31\n else if o=11 then o:=30\n else if o=12 then o:=31;\n kq:=kq+o-u;\nend;\n\nProcedure xulingay3;\nbegin\nif ngay1>ngay2 then\nkq:=kq+ngay2-ngay1+1\nelse\nkq:=kq+ngay1-ngay2+1;\nend;\n\nProcedure xulithang;\nbegin\nif nam1>nam2 then\n begin\n xuli(thang1);\n xuli3(thang2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\nelse if nam1thang2 then\n begin\n xuli2(2);\n xulingay1(ngay1);\n end\n else\n begin\n if thang10)) or (nam1 mod 400=0) then\n kq:=kq+1;\nif nam1>nam2 then\nbegin\nx:=nam1;\nx2:=thang1;\ny:=nam2;\ny2:=thang2;\nend\nelse if nam1nam2 then\nbegin\nif ((x mod 4=0) and (x mod 100<>0)) or (x mod 400=0) then if x2>2 then kq:=kq+1;\nif ((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0) then if y2<=2 then kq:=kq+1;\nend;\nwriteln(f2,kq);\nclose(f1);\nclose(f2);\nend.\n\n"}, {"source_code": "Program bt2;\nConst fi='';\n fo='';\nvar f1,f2:text;\n a:string;\n nam1,thang1,nam2,x2,y2,thang2,ngay2,ngay1,p,x,y,i,o:integer;\n kq:longint;\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,a);\n nam1:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang1:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay1:=(ord(a[9])-48)*10+(ord(a[10])-48);\n readln(f1,a);\n nam2:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang2:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay2:=(ord(a[9])-48)*10+(ord(a[10])-48);\nend;\n\nProcedure xulinam;\nbegin\n if nam1>nam2 then\n begin\n x:=nam2;\n y:=nam1;\n end\n else\n begin\n x:=nam1;\n y:=nam2;\n end;\n for i:=x+1 to y-1 do\n begin\n if (i mod 4=0) and(i mod 100<>0) then\n kq:=kq+366\n else if(i mod 400)=0 then kq:=kq+366\n else kq:=kq+365;\n end;\nend;\n\nProcedure xuli(u:byte);\nbegin\n for o:=1 to u-1 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n end;\nend;\n\nProcedure xuli3(u:byte);\nbegin\n for o:=u+1 to 12 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n else if o=12 then kq:=kq+31;\n end;\nend;\n\nProcedure xuli2(u:byte);\nvar l:byte;\nbegin\nif u=1 then\nbegin\nu:=thang1;\nl:=thang2;\nend;\nif u=2 then\nbegin\nu:=thang2;\nl:=thang1;\nend;\n for o:=u+1 to l-1 do\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30;\nend;\n\nProcedure xulingay1(u:byte);\nbegin\n kq:=kq+u;\nend;\n\nProcedure xulingay2(u,l:byte);\nbegin\no:=l;\nif o=1 then o:=31\n else if o=2 then o:=28\n else if o=3 then o:=31\n else if o=4 then o:=30\n else if o=5 then o:=31\n else if o=6 then o:=30\n else if o=7 then o:=31\n else if o=8 then o:=31\n else if o=9 then o:=30\n else if o=10 then o:=31\n else if o=11 then o:=30\n else if o=12 then o:=31;\n kq:=kq+o-u;\nend;\n\nProcedure xulingay3;\nbegin\nif ngay1>ngay2 then\nkq:=kq+ngay2-ngay1+1\nelse\nkq:=kq+ngay1-ngay2;\nend;\n\nProcedure xulithang;\nbegin\nif nam1>nam2 then\n begin\n xuli(thang1);\n xuli3(thang2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\nelse if nam1thang2 then\n begin\n xuli2(2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\n else\n begin\n if thang10)) or (nam1 mod 400=0) then\n kq:=kq+1;\nif nam1>nam2 then\nbegin\nx:=nam1;\nx2:=thang1;\ny:=nam2;\ny2:=thang2;\nend\nelse if nam1nam2 then\nbegin\nif ((x mod 4=0) and (x mod 100<>0)) or (x mod 400=0) then if x2>2 then kq:=kq+1;\nif ((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0) then if y2<=2 then kq:=kq+1;\nend;\nwriteln(f2,kq);\nclose(f1);\nclose(f2);\nend.\n\n"}, {"source_code": "Program bt2;\nConst fi='';\n fo='';\nvar f1,f2:text;\n a:string;\n nam1,thang1,nam2,x2,y2,thang2,ngay2,ngay1,p,x,y,i,o:integer;\n kq:longint;\nProcedure nhap;\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,a);\n nam1:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang1:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay1:=(ord(a[9])-48)*10+(ord(a[10])-48);\n readln(f1,a);\n nam2:=(ord(a[1])-48)*1000+(ord(a[2])-48)*100+(ord(a[3])-48)*10+ord(a[4])-48;\n thang2:=(ord(a[6])-48)*10+(ord(a[7])-48);\n ngay2:=(ord(a[9])-48)*10+(ord(a[10])-48);\nend;\n\nProcedure xulinam;\nbegin\n if nam1>nam2 then\n begin\n x:=nam2;\n y:=nam1;\n end\n else\n begin\n x:=nam1;\n y:=nam2;\n end;\n for i:=x+1 to y-1 do\n begin\n if (i mod 4=0) and(i mod 100<>0) then\n kq:=kq+366\n else if(i mod 400)=0 then kq:=kq+366\n else kq:=kq+365;\n end;\nend;\n\nProcedure xuli(u:byte);\nbegin\n for o:=1 to u-1 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n end;\nend;\n\nProcedure xuli3(u:byte);\nbegin\n for o:=u+1 to 12 do\n begin\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30\n else if o=12 then kq:=kq+31;\n end;\nend;\n\nProcedure xuli2(u:byte);\nvar l:byte;\nbegin\nif u=1 then\nbegin\nu:=thang1;\nl:=thang2;\nend;\nif u=2 then\nbegin\nu:=thang2;\nl:=thang1;\nend;\n for o:=u+1 to l-1 do\n if o=1 then kq:=kq+31\n else if o=2 then kq:=kq+28\n else if o=3 then kq:=kq+31\n else if o=4 then kq:=kq+30\n else if o=5 then kq:=kq+31\n else if o=6 then kq:=kq+30\n else if o=7 then kq:=kq+31\n else if o=8 then kq:=kq+31\n else if o=9 then kq:=kq+30\n else if o=10 then kq:=kq+31\n else if o=11 then kq:=kq+30;\nend;\n\nProcedure xulingay1(u:byte);\nbegin\n kq:=kq+u;\nend;\n\nProcedure xulingay2(u,l:byte);\nbegin\no:=l;\nif o=1 then o:=31\n else if o=2 then o:=28\n else if o=3 then o:=31\n else if o=4 then o:=30\n else if o=5 then o:=31\n else if o=6 then o:=30\n else if o=7 then o:=31\n else if o=8 then o:=31\n else if o=9 then o:=30\n else if o=10 then o:=31\n else if o=11 then o:=30\n else if o=12 then o:=31;\n kq:=kq+o-u;\nend;\n\nProcedure xulingay3;\nbegin\nif ngay1>ngay2 then\nkq:=kq+ngay2-ngay1+1\nelse\nkq:=kq+ngay1-ngay2+1;\nend;\n\nProcedure xulithang;\nbegin\nif nam1>nam2 then\n begin\n xuli(thang1);\n xuli3(thang2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\nelse if nam1thang2 then\n begin\n xuli2(2);\n xulingay1(ngay1);\n xulingay2(ngay2,thang2);\n end\n else\n begin\n if thang10)) or (nam1 mod 400=0) then\n kq:=kq+1;\nif nam1>nam2 then\nbegin\nx:=nam1;\nx2:=thang1;\ny:=nam2;\ny2:=thang2;\nend\nelse if nam1nam2 then\nbegin\nif ((x mod 4=0) and (x mod 100<>0)) or (x mod 400=0) then if x2>2 then kq:=kq+1;\nif ((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0) then if y2<=2 then kq:=kq+1;\nend;\nwriteln(f2,kq);\nclose(f1);\nclose(f2);\nend.\n\n"}, {"source_code": "Const\n thang:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nType\n mat=array [1..1000000] of longint;\nVar n,res,y1,d1,m1,y2,d2,m2:longint;\n a,s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y1);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m1);\n Val(a,d1);\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y2);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m2);\n Val(a,d2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nFunction Nhuan(x:longint):boolean;\n Begin\n If ((x mod 4=0) and (x mod 100<>0)) or ( x mod 400=0) then\n exit(true);\n exit(false);\n end;\n\nProcedure Lam;\n Var i:longint;\n Begin\n If y1>y2 then\n Begin\n Doicho(y1,y2);\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n res:=0;\n For i:=y1+1 to y2-1 do\n If Nhuan(i) then\n res:=res+366\n else res:=res+365;\n If y1=y2 then\n Begin\n For i:=m1+1 to m2-1 do res:=res+thang[i];\n If (m1<=2) and (m2>=2) then inc(res);\n If m1<>m2 then\n res:=res+thang[m1]-d1+d2\n else res:=res+d2-d1+1;\n end\n else\n Begin\n For i:=m1+1 to 12 do res:=res+thang[i];\n If Nhuan(y1) then\n If m1<=2 then inc(res);\n For i:= 1 to m2-1 do res:=res+thang[i];\n If Nhuan(y2) then\n If m2>2 then inc(res);\n res:=res+thang[m1]-d1+d2;\n end;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end."}, {"source_code": "Const\n thang:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nType\n mat=array [1..1000000] of longint;\nVar n,res,y1,d1,m1,y2,d2,m2:longint;\n a,s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y1);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m1);\n Val(a,d1);\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y2);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m2);\n Val(a,d2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nFunction Nhuan(x:longint):boolean;\n Begin\n If ((x mod 4=0) and (x mod 100<>0)) or ( x mod 400=0) then\n exit(true);\n exit(false);\n end;\n\nProcedure Lam;\n Var i:longint;\n Begin\n If y1>y2 then\n Begin\n Doicho(y1,y2);\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n res:=0;\n For i:=y1+1 to y2-1 do\n If Nhuan(i) then\n res:=res+366\n else res:=res+365;\n If y1=y2 then\n Begin\n For i:=m1+1 to m2-1 do res:=res+thang[i];\n If (m1<=2) and (m2>2) then inc(res);\n If m1<>m2 then\n res:=res+thang[m1]-d1+d2\n else res:=res+d2-d1;\n end\n else\n Begin\n For i:=m1+1 to 12 do res:=res+thang[i];\n If Nhuan(y1) then\n If m1<=2 then inc(res);\n For i:= 1 to m2-1 do res:=res+thang[i];\n If Nhuan(y2) then\n If m2>2 then inc(res);\n res:=res+thang[m1]-d1+d2;\n end;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end."}, {"source_code": "Const\n thang:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nType\n mat=array [1..1000000] of longint;\nVar n,res,y1,d1,m1,y2,d2,m2:longint;\n a,s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y1);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m1);\n Val(a,d1);\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y2);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m2);\n Val(a,d2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nFunction Nhuan(x:longint):boolean;\n Begin\n If ((x mod 4=0) and (x mod 100<>0)) or ( x mod 400=0) then\n exit(true);\n exit(false);\n end;\n\nProcedure Lam;\n Var i:longint;\n Begin\n If y1>y2 then\n Begin\n Doicho(y1,y2);\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n res:=0;\n For i:=y1+1 to y2-1 do\n If Nhuan(i) then\n res:=res+366\n else res:=res+365;\n If y1=y2 then\n Begin\n For i:=m1+1 to m2-1 do res:=res+thang[i];\n If (m1<=2) and (m2>=2) then inc(res);\n If m1<>m2 then\n res:=res+thang[m1]-d1+d2\n else res:=res+d2-d1;\n end\n else\n Begin\n For i:=m1+1 to 12 do res:=res+thang[i];\n If Nhuan(y1) then\n If m1<=2 then inc(res);\n For i:= 1 to m2-1 do res:=res+thang[i];\n If Nhuan(y2) then\n If m2>2 then inc(res);\n res:=res+thang[m1]-d1+d2;\n end;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end."}, {"source_code": "Const\n thang:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nType\n mat=array [1..1000000] of longint;\nVar n,res,y1,d1,m1,y2,d2,m2:longint;\n a,s:string;\n fi,fo:text;\n\nProcedure Doc;\n Begin\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y1);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m1);\n Val(a,d1);\n Readln(fi,a);\n s:='';\n s:=a[1]+a[2]+a[3]+a[4];\n Delete(a,1,5);\n Val(s,y2);\n s:='';\n s:=a[1]+a[2];\n Delete(a,1,3);\n Val(s,m2);\n Val(a,d2);\n end;\n\nProcedure Doicho(Var x,y:longint);\n Var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\nFunction Nhuan(x:longint):boolean;\n Begin\n If ((x mod 4=0) and (x mod 100<>0)) or ( x mod 400=0) then\n exit(true);\n exit(false);\n end;\n\nProcedure Lam;\n Var i:longint;\n Begin\n If y1>y2 then\n Begin\n Doicho(y1,y2);\n Doicho(m1,m2);\n Doicho(d1,d2);\n end;\n res:=0;\n For i:=y1+1 to y2-1 do\n If Nhuan(i) then\n res:=res+366\n else res:=res+365;\n If y1=y2 then\n Begin\n For i:=m1+1 to m2-1 do res:=res+thang[i];\n If (m1<=2) and (m2>=2) then inc(res);\n If m1<>m2 then\n res:=res+thang[m1]-d1+d2\n else res:=res+d2-d1+1;\n end\n else\n Begin\n For i:=m1+1 to 12 do res:=res+thang[i];\n If Nhuan(y1) then\n If m1<=2 then inc(res);\n For i:= 1 to m2-1 do res:=res+thang[i];\n If Nhuan(y2) then\n If m2>=2 then inc(res);\n res:=res+thang[m1]-d1+d2;\n end;\n Write(fo,res);\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end."}, {"source_code": "var prim,doi,an_1,luna_1,zi_1,an_2,luna_2,zi_2:string;\n an1,luna1,zi1,an2,luna2,zi2,cod,i:integer;\n raspuns,q,w,z,s:longint;\n an:1900..2038;\n luna:1..12;\n zi:1..31;\nbegin\n readln(prim);\n readln(doi);\n an_1:=copy(prim,1,4);\n luna_1:=copy(prim,6,2);\n zi_1:=copy(prim,9,2);\n an_2:=copy(doi,1,4);\n luna_2:=copy(doi,6,2);\n zi_2:=copy(doi,9,2);\n val(an_1,an1,cod);\n val(an_2,an2,cod);\n val(luna_1,luna1,cod);\n val(luna_2,luna2,cod);\n val(zi_1,zi1,cod);\n val(zi_2,zi2,cod);\n for i:=1900 to an1 do\n begin\n if (i mod 4=0)and(i mod 100<>0)and(i mod 400<>0)then q:=q+366\n else\n if (i mod 100=0)and(i mod 400=0)then q:=q+366\n else q:=q+365;\n end;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then z:=29\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then z:=29\n else z:=28;\n if luna1=1 then s:=s+zi1;\n if luna1=2 then s:=s+31+zi1;\n if luna1=3 then s:=s+31+zi1+z;\n if luna1=4 then s:=s+62+zi1+z;\n if luna1=5 then s:=s+92+zi1+z;\n if luna1=6 then s:=s+123+zi1+z;\n if luna1=7 then s:=s+153+zi1+z;\n if luna1=8 then s:=s+184+zi1+z;\n if luna1=9 then s:=s+215+zi1+z;\n if luna1=10 then s:=s+245+zi1+z;\n if luna1=11 then s:=s+276+zi1+z;\n if luna1=12 then s:=s+306+zi1+z;\n q:=q+s;\n if an1=1900 then q:=s+365;\n if an1=2038 then q:=q-365;\n s:=0;z:=0;\n for i:=1900 to an2 do\n begin\n if (i mod 4=0)and(i mod 100<>0)and(i mod 400<>0)then w:=w+366\n else\n if (i mod 100=0)and(i mod 400=0)then w:=w+366\n else w:=w+365;\n end;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then z:=29\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then z:=29\n else z:=28;\n if luna2=1 then s:=s+zi2;\n if luna2=2 then s:=s+31+zi2;\n if luna2=3 then s:=s+31+zi2+z;\n if luna2=4 then s:=s+62+zi2+z;\n if luna2=5 then s:=s+92+zi2+z;\n if luna2=6 then s:=s+123+zi2+z;\n if luna2=7 then s:=s+153+zi2+z;\n if luna2=8 then s:=s+184+zi2+z;\n if luna2=9 then s:=s+215+zi2+z;\n if luna2=10 then s:=s+245+zi2+z;\n if luna2=11 then s:=s+276+zi2+z;\n if luna2=12 then s:=s+306+zi2+z;\n w:=w+s;\n if an2=1900 then w:=s+365;\n if an2=2038 then w:=w-365;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then q:=q-366\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then q:=q-366\n else q:=q-365;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then w:=w-366\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then w:=w-366\n else w:=w-365;\n writeln('Q->',q);\n writeln('W->',w);\n raspuns:=abs(q-w);\n writeln(Raspuns);\nend."}, {"source_code": "var prim,doi,an_1,luna_1,zi_1,an_2,luna_2,zi_2:string;\n an1,luna1,zi1,an2,luna2,zi2,cod,i:integer;\n raspuns,q,w,z,s:longint;\n an:1900..2038;\n luna:1..12;\n zi:1..31;\nbegin\n readln(prim);\n readln(doi);\n an_1:=copy(prim,1,4);\n luna_1:=copy(prim,6,2);\n zi_1:=copy(prim,9,2);\n an_2:=copy(doi,1,4);\n luna_2:=copy(doi,6,2);\n zi_2:=copy(doi,9,2);\n val(an_1,an1,cod);\n val(an_2,an2,cod);\n val(luna_1,luna1,cod);\n val(luna_2,luna2,cod);\n val(zi_1,zi1,cod);\n val(zi_2,zi2,cod);\n for i:=1900 to an1 do\n begin\n if (i mod 4=0)and(i mod 100<>0)and(i mod 400<>0)then q:=q+366\n else\n if (i mod 100=0)and(i mod 400=0)then q:=q+366\n else q:=q+365;\n end;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then z:=29\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then z:=29\n else z:=28;\n if luna1=1 then s:=s+zi1;\n if luna1=2 then s:=s+31+zi1;\n if luna1=3 then s:=s+31+zi1+z;\n if luna1=4 then s:=s+62+zi1+z;\n if luna1=5 then s:=s+92+zi1+z;\n if luna1=6 then s:=s+123+zi1+z;\n if luna1=7 then s:=s+153+zi1+z;\n if luna1=8 then s:=s+184+zi1+z;\n if luna1=9 then s:=s+215+zi1+z;\n if luna1=10 then s:=s+245+zi1+z;\n if luna1=11 then s:=s+276+zi1+z;\n if luna1=12 then s:=s+306+zi1+z;\n q:=q+s;\n if an1=1900 then q:=s;\n if an1=2038 then q:=q-365;\n s:=0;z:=0;\n for i:=1900 to an2 do\n begin\n if (i mod 4=0)and(i mod 100<>0)and(i mod 400<>0)then w:=w+366\n else\n if (i mod 100=0)and(i mod 400=0)then w:=w+366\n else w:=w+365;\n end;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then z:=29\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then z:=29\n else z:=28;\n if luna2=1 then s:=s+zi2;\n if luna2=2 then s:=s+31+zi2;\n if luna2=3 then s:=s+31+zi2+z;\n if luna2=4 then s:=s+62+zi2+z;\n if luna2=5 then s:=s+92+zi2+z;\n if luna2=6 then s:=s+123+zi2+z;\n if luna2=7 then s:=s+153+zi2+z;\n if luna2=8 then s:=s+184+zi2+z;\n if luna2=9 then s:=s+215+zi2+z;\n if luna2=10 then s:=s+245+zi2+z;\n if luna2=11 then s:=s+276+zi2+z;\n if luna2=12 then s:=s+306+zi2+z;\n w:=w+s;\n if an2=1900 then w:=s;\n if an2=2038 then w:=w-365;\n if (an1 mod 4=0)and(an1 mod 100<>0)and(an1 mod 400<>0)then q:=q-366\n else\n if (an1 mod 100=0)and(an1 mod 400=0)then q:=q-366\n else q:=q-365;\n if (an2 mod 4=0)and(an2 mod 100<>0)and(an2 mod 400<>0)then w:=w-366\n else\n if (an2 mod 100=0)and(an2 mod 400=0)then w:=w-366\n else w:=w-365;\n raspuns:=abs(q-w);\n writeln(Raspuns);\nend."}, {"source_code": "var y1, y2, m1, m2, d1, d2, year : integer;\n kq, k1, k2 : longint;\n c1, c2 : char;\n i, j : integer;\n f2 : text;\n s1, s2 : string;\nconst day : array[1..12] of integer\n = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nfunction songay(x : integer) : integer;\n begin\n if x mod 400 = 0 then exit(366);\n if x mod 4 = 0 then exit(366);\n exit(365);\n end;\nfunction kt(x : integer) : boolean;\n begin\n if x mod 400 = 0 then exit(true);\n if x mod 4 = 0 then exit(true);\n exit(false);\n end;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n begin\n if s1[i] = ':' then s1[i] := ' ';\n if s2[i] = ':' then s2[i] := ' ';\n end;\n assign(f2, 'test.txt'); rewrite(f2);\n writeln(f2, s1);\n writeln(f2, s2);\n close(f2);\n reset(f2);\n readln(f2, y1, m1, d1);\n readln(f2, y2, m2, d2);\n close(f2);\n if y1 < y2 then year := y1 else year := y2;\n {---}\n k1 := d1;\n if kt(y1) then\n begin\n if m1 > 2 then inc(k1)\n else\n if (d1=29) and (m1=2) then inc(k1);\n end;\n for i := 1 to m1 - 1 do\n k1 := k1 + day[i];\n for i := year to y1 - 1 do\n k1 := k1 + songay(i);\n // -----\n k2 := d2;\n if kt(y2) then\n begin\n if m2 > 2 then inc(k2)\n else\n if (d2=29) and (m2=2) then inc(k2);\n end;\n for i := 1 to m2 - 1 do\n k2 := k2 + day[i];\n for i := year to y2 - 1 do\n k2 := k2 + songay(i);\n writeln(abs(k1-k2) - 1);\nend."}, {"source_code": "var y1, y2, m1, m2, d1, d2, year : integer;\n kq, k1, k2 : longint;\n c1, c2 : char;\n i, j : integer;\n f2 : text;\n s1, s2 : string;\nconst day : array[1..12] of integer\n = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nfunction songay(x : integer) : integer;\n begin\n if x mod 400 = 0 then exit(366);\n if x mod 100 = 0 then exit(365);\n if x mod 4 = 0 then exit(366);\n exit(365);\n end;\nfunction kt(x : integer) : boolean;\n begin\n if x mod 400 = 0 then exit(true);\n if x mod 100 = 0 then exit(false);\n if x mod 4 = 0 then exit(true);\n exit(false);\n end;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n begin\n if s1[i] = ':' then s1[i] := ' ';\n if s2[i] = ':' then s2[i] := ' ';\n end;\n assign(f2, 'test.txt'); rewrite(f2);\n writeln(f2, s1);\n writeln(f2, s2);\n close(f2);\n reset(f2);\n readln(f2, y1, m1, d1);\n readln(f2, y2, m2, d2);\n close(f2);\n if y1 < y2 then year := y1 else year := y2;\n {---}\n k1 := d1;\n if kt(y1) then\n begin\n if m1 > 2 then inc(k1)\n else\n if (d1=29) and (m1=2) then inc(k1);\n end;\n for i := 1 to m1 - 1 do\n k1 := k1 + day[i];\n for i := year to y1 - 1 do\n k1 := k1 + songay(i);\n // -----\n k2 := d2;\n if kt(y2) then\n begin\n if m2 > 2 then inc(k2)\n else\n if (d2=29) and (m2=2) then inc(k2);\n end;\n for i := 1 to m2 - 1 do\n k2 := k2 + day[i];\n for i := year to y2 - 1 do\n k2 := k2 + songay(i);\n writeln(abs(k1-k2) );\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n s1,s2:string;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s1);\n readln(f,s2);\nend;\nfunction sn(i:integer;k:boolean):integer;\nbegin\n case i of\n 1,3,5,7,8,10,12:sn:=31;\n 4,6,9,11:sn:=30;\n 2:if k then sn:=29\n else sn:=28;\n end;\nend;\nfunction tinh(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:= b+1 to 12 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+sn(b,kt)-c;\n tinh:=t;\n\nend;\nfunction tinh1(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:=1 to b-1 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+c;\n tinh1:=t;\nend;\nprocedure swap(var a,b:longint);\nvar tg:longint;\nbegin\n tg:=a;\n a:=b;\n b:=tg;\nend;\nprocedure process;\nvar t,b,dem,i,vt,k,a1,b1,c1,a2,b2,c2:longint;\n kq:int64;\nbegin\n kq:=0;\n k:=pos(':',s1);\n val(copy(s1,1,k-1),a1);\n delete(s1,1,k);\n k:=pos(':',s1);\n val(copy(s1,1,k-1),b1);\n delete(s1,1,k);\n val(s1,c1);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),a2);\n delete(s2,1,k);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),b2);\n delete(s2,1,k);\n val(s2,c2);\n if a1>a2 then\n begin\n swap(a1,a2);\n swap(b1,b2);\n swap(c1,c2);\n end;\n for i:=a1+1 to a2-1 do\n if (i mod 4=0) then\n begin\n kq:=kq+366;\n if (i mod 100=0) and (i mod 400<>0) then kq:=kq-1;\n end\n else kq:=kq+365;\n kq:=kq+tinh(a1,b1,c1)+tinh1(a2,b2,c2);\n writeln(g,kq);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n s1,s2:string;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s1);\n readln(f,s2);\nend;\nfunction sn(i:integer;k:boolean):integer;\nbegin\n case i of\n 1,3,5,7,8,10,12:sn:=31;\n 4,6,9,11:sn:=30;\n 2:if k then sn:=29\n else sn:=28;\n end;\nend;\nfunction tinh(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:= b+1 to 12 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+sn(b,kt)-c;\n tinh:=t;\n\nend;\nfunction tinh1(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:=1 to b-1 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+c;\n tinh1:=t;\nend;\nprocedure swap(var a,b:longint);\nvar tg:longint;\nbegin\n tg:=a;\n a:=b;\n b:=tg;\nend;\nprocedure process;\nvar t,b,dem,i,vt,k,a1,b1,c1,a2,b2,c2:longint;\n kq:int64;\n kt:boolean;\nbegin\n kq:=0;\n k:=pos(':',s1);\n val(copy(s1,1,k-1),a1);\n delete(s1,1,k);\n k:=pos(':',s1);\n val(copy(s1,1,k-1),b1);\n delete(s1,1,k);\n val(s1,c1);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),a2);\n delete(s2,1,k);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),b2);\n delete(s2,1,k);\n val(s2,c2);\n if a1=a2 then\n begin\n if a1 mod 4=0 then\n begin\n kt:=true;\n if (a1 mod 100=0) and (a1 mod 400=0) then kt:=false;\n end\n else kt:=false;\n if b1>b2 then\n begin\n swap(b1,b2);\n swap(c1,c2);\n end;\n for i:=b1+1 to b2-1 do\n kq:=kq+sn(i,kt);\n if b1=b2 then\n begin\n kq:=abs(c1-c2)+1;\n end\n else kq:=kq+sn(b1,kt)-c1+c2;\n end\n else\n begin\n if a1>a2 then\n begin\n swap(a1,a2);\n swap(b1,b2);\n swap(c1,c2);\n end;\n for i:=a1+1 to a2-1 do\n if (i mod 4=0) then\n begin\n kq:=kq+366;\n if (i mod 100=0) and (i mod 400<>0) then kq:=kq-1;\n end\n else kq:=kq+365;\n kq:=kq+tinh(a1,b1,c1)+tinh1(a2,b2,c2);\n end;\n writeln(g,kq);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n s1,s2:string;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s1);\n readln(f,s2);\nend;\nfunction sn(i:integer;k:boolean):integer;\nbegin\n case i of\n 1,3,5,7,8,10,12:sn:=31;\n 4,6,9,11:sn:=30;\n 2:if k then sn:=29\n else sn:=28;\n end;\nend;\nfunction tinh(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400=0)) then kt:=false;\n end\n else kt:=false;\n for i:= b+1 to 12 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+sn(i,kt)-c;\n tinh:=t;\n\nend;\nfunction tinh1(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400=0)) then kt:=false;\n end\n else kt:=false;\n for i:=1 to b-1 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+c;\n tinh1:=t;\nend;\nprocedure process;\nvar t,b,dem,i,vt,k,a1,b1,c1,a2,b2,c2:longint;\n kq:int64;\nbegin\n kq:=0;\n k:=pos(':',s1);\n val(copy(s1,1,k-1),a1);\n delete(s1,1,k);\n k:=pos(':',s1);\n val(copy(s1,1,k-1),b1);\n delete(s1,1,k);\n val(s1,c1);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),a2);\n delete(s2,1,k);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),b2);\n delete(s2,1,k);\n val(s2,c2);\n vt:=2000;\n dem:=0;\n for i:=a1+1 to a2-1 do\n if (i mod 4=0) then\n begin\n kq:=kq+366;\n if (i mod 100=0) and (i mod 400=0) then kq:=kq-1;\n end\n else kq:=kq+365;\n kq:=kq+tinh(a1,b1,c1)+tinh1(a2,b2,c2);\n writeln(g,kq);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n s1,s2:string;\n\nprocedure openfile;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\nprocedure readfile;\nbegin\n readln(f,s1);\n readln(f,s2);\nend;\nfunction sn(i:integer;k:boolean):integer;\nbegin\n case i of\n 1,3,5,7,8,10,12:sn:=31;\n 4,6,9,11:sn:=30;\n 2:if k then sn:=29\n else sn:=28;\n end;\nend;\nfunction tinh(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:= b+1 to 12 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+sn(i,kt)-c;\n tinh:=t;\n\nend;\nfunction tinh1(a,b,c:longint):longint;\nvar t,i:longint;\n kt:boolean;\nbegin\n t:=0;\n if (a mod 4=0) then\n begin\n kt:=true;\n if ((a mod 100=0) and (a mod 400<>0)) then kt:=false;\n end\n else kt:=false;\n for i:=1 to b-1 do\n begin\n t:=t+sn(i,kt);\n end;\n t:=t+c;\n tinh1:=t;\nend;\nprocedure swap(var a,b:longint);\nvar tg:longint;\nbegin\n tg:=a;\n a:=b;\n b:=tg;\nend;\nprocedure process;\nvar t,b,dem,i,vt,k,a1,b1,c1,a2,b2,c2:longint;\n kq:int64;\nbegin\n kq:=0;\n k:=pos(':',s1);\n val(copy(s1,1,k-1),a1);\n delete(s1,1,k);\n k:=pos(':',s1);\n val(copy(s1,1,k-1),b1);\n delete(s1,1,k);\n val(s1,c1);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),a2);\n delete(s2,1,k);\n k:=pos(':',s2);\n val(copy(s2,1,k-1),b2);\n delete(s2,1,k);\n val(s2,c2);\n if a1>a2 then\n begin\n swap(a1,a2);\n swap(b1,b2);\n swap(c1,c2);\n end;\n vt:=2000;\n dem:=0;\n for i:=a1+1 to a2-1 do\n if (i mod 4=0) then\n begin\n kq:=kq+366;\n if (i mod 100=0) and (i mod 400<>0) then kq:=kq-1;\n end\n else kq:=kq+365;\n kq:=kq+tinh(a1,b1,c1)+tinh1(a2,b2,c2);\n writeln(g,kq);\nend;\nprocedure closefile;\nbegin\n close(f);\n close(g);\nend;\nbegin\n openfile;\n readfile;\n process;\n closefile;\nend.\n"}, {"source_code": "Program B183;\nVar\n con:Array[1..12] Of Longint=(31,28,31,30,31,30,31,31,30,31,30,31);\n sum:Array[0..12] OF Longint;\n s1,s2,nian,yue,ri:String;\n nian1,nian2,yue1,yue2,ri1,ri2,ans,i,n:Longint;\n flag:Boolean;\nBegin\n For i:=1 To 12 Do sum[i]:=sum[i-1]+con[i];\n Readln(s1);\n Readln(s2);\n If s1>s2 Then Begin\n nian:=s1;\n s1:=s2;\n s2:=nian;\n End;\n nian:=Copy(s1,1,4);\n Val(nian,nian1);\n yue:=Copy(s1,6,2);\n Val(yue,yue1);\n ri:=Copy(s1,9,2);\n Val(ri,ri1);\n nian:=Copy(s2,1,4);\n Val(nian,nian2);\n yue:=Copy(s2,6,2);\n Val(yue,yue2);\n ri:=Copy(s2,9,2);\n Val(ri,ri2);\n flag:=True;\n If (nian1 Mod 100=0) Then Begin\n If nian1 Mod 400<>0 Then flag:=False;\n End Else If nian1 Mod 4<>0 Then flag:=FAlse;\n ans:=ans+sum[12]-sum[yue1];\n ans:=ans+con[yue1]-ri1;\n If (yue1<=2)And(flag) Then Inc(ans);\n For i:=nian1+1 To nian2-1 Do Begin\n ans:=ans+sum[12];\n flag:=True;\n If (i Mod 100=0) Then Begin\n If i Mod 400<>0 Then flag:=False;\n End Else If i Mod 4<>0 Then flag:=False;\n If flag Then Inc(ans);\n End;\n ans:=ans+sum[yue2-1]+ri2;\n flag:=True;\n If (nian2 Mod 100=0) Then Begin\n If nian2 Mod 400<>0 Then flag:=FAlse;\n End Else If nian2 Mod 4<>0 Then flag:=False;\n If (yue2>=3) Then inc(ans);\n ans:=ans-1;\n If nian1=nian2 Then Begin\n ans:=ans-365;\n If flag Then ans:=ans-1;\n End; \n Writeln(ans);\nEnd.\n\n"}, {"source_code": "const a:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar x,y,i,j,all:longint;\n s:string;\nfunction f(s:string):longint;\nvar i,x,n,k,y,m,d:longint;\n begin\n n:=length(s);\n k:=0;y:=0;m:=0;d:=0;x:=0;\n for i:=1 to n do\n if(s[i]=':')then inc(k)\n else\n if(k=0)then y:=y*10+ord(s[i])-48\n else\n if(k=1)then m:=m*10+ord(s[i])-48\n else\n if(k=2)then d:=d*10+ord(s[i])-48;\n for i:=1 to y-1 do\n if((i mod 4=0)and(i mod 100<>0))or(i mod 400=0)then x:=x+all+1 else x:=x+all;\n for i:=1 to m-1 do\n begin\n x:=x+a[i];\n if(i=2)and(((i mod 4=0)and(i mod 100<>0))or(i mod 400=0))then x:=x+1;\n end;\n x:=x+d;\n exit(x);\n end;\n begin\n for i:=1 to 12 do\n all:=all+a[i];\n readln(s);\n x:=f(s);\n readln(s);\n y:=f(s);\n writeln(abs(y-x)+1);\n end."}, {"source_code": "const\n a:array [1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n sum,total,y,m,d,yy,mm,dd,sumi,sumj,b,c,e:longint;\n s,ss:string;\nbegin\n readln(s);\n readln(ss);\n y:=(ord(s[1])-48)*1000+(ord(s[2])-48)*100+(ord(s[3])-48)*10+(ord(s[4])-48);\n m:=(ord(s[6])-48)*10+(ord(s[7])-48);\n d:=(ord(s[9])-48)*10+(ord(s[10])-48);\n yy:=(ord(ss[1])-48)*1000+(ord(ss[2])-48)*100+(ord(ss[3])-48)*10+(ord(ss[4])-48);\n mm:=(ord(ss[6])-48)*10+(ord(ss[7])-48);\n dd:=(ord(ss[9])-48)*10+(ord(ss[10])-48);\n if m>1 then\n for b:=1 to m-1 do\n sumi:=sumi+a[b];\n sumi:=sumi+d;\n if mm>1 then\n for b:=1 to mm-1 do\n sumj:=sumj+a[b];\n sumj:=sumj+dd;\n total:=(yy-y)*365-sumi+sumj+(yy div 4)-(y div 4)+(yy div 100)-(y div 100)-(yy div 400)+(y div 400);\n writeln(abs(total));\nend.\n\n"}, {"source_code": "program uio;\nconst month:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n var s1,s2:string;\n y1,m1,d1,y2,m2,d2,kol,i:longint;\n\n\nprocedure pro(s:string; var y,m,d:longint);\n var code:longint;\n ss:string;\n\nbegin\n\n ss:=s[1]+s[2]+s[3]+s[4];\n val(ss,y,code);\n\n ss:='';\n if s[6]='0' then ss:=ss+s[7]\n else ss:=ss+s[6]+s[7];\n val(ss,m,code);\n\n ss:='';\n if s[9]='0' then ss:=ss+s[10]\n else ss:=ss+s[9]+s[10];\n val(ss,d,code);\n\n\nend;\n\n\nfunction vis(x:longint):boolean;\nbegin\n\n if (x mod 400) = 0 then exit(true);\n if (x mod 4 = 0)and(x mod 100<>0) then exit(true);\n exit(false);\n\nend;\n\n\nprocedure rev;\n var cc:longint;\n\nbegin\n\n cc:=y1; y1:=y2; y2:=cc;\n cc:=m1; m1:=m2; m2:=cc;\n cc:=d1; d1:=d2; d2:=cc;\n\nend;\n\n\n\nBEGIN\n\n readln(s1); readln(s2);\n pro(s1,y1,m1,d1); pro(s2,y2,m2,d2);\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(1); halt; end;\n kol:=0;\n if y1>y2 then rev\n else if (y1=y2)and(m1>m2) then rev\n else if (m1=m2)and(d1>d2) then rev;\n\n while (y1<=y2) do\n begin\n if vis(y1) then month[2]:=29;\n while true do\n begin\n inc(d1); inc(kol); if d1>month[m1] then begin inc(m1); d1:=1; end;\n if m1>12 then begin m1:=1; break; end;\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(kol); halt; end;\n end;\n inc(y1); month[2]:=28;\n end;\n\n writeln(kol);\n\nEND."}, {"source_code": "program uio;\nconst month:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n var s1,s2:string;\n y1,m1,d1,y2,m2,d2,kol,i:longint;\n\n\nprocedure pro(s:string; var y,m,d:longint);\n var code:longint;\n ss:string;\n\nbegin\n\n ss:=s[1]+s[2]+s[3]+s[4];\n val(ss,y,code);\n\n ss:='';\n if s[6]='0' then ss:=ss+s[7]\n else ss:=ss+s[6]+s[7];\n val(ss,m,code);\n\n ss:='';\n if s[9]='0' then ss:=ss+s[10]\n else ss:=ss+s[9]+s[10];\n val(ss,d,code);\n\n\nend;\n\n\nfunction vis(x:longint):boolean;\nbegin\n\n if (x mod 400) = 0 then exit(true);\n if (x mod 4 = 0)and(x mod 100<>0) then exit(true);\n exit(false);\n\nend;\n\n\nprocedure rev;\n var cc:longint;\n\nbegin\n\n cc:=y1; y1:=y2; y2:=cc;\n cc:=m1; m1:=m2; m2:=cc;\n cc:=d1; d1:=d2; d2:=cc;\n\nend;\n\n\n\nBEGIN\n\n readln(s1); readln(s2);\n pro(s1,y1,m1,d1); pro(s2,y2,m2,d2);\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(0); halt; end;\n kol:=0;\n if y1>y2 then rev\n else if (y1=y2)and(m1>m2) then rev\n else if (m1=m2)and(d1>d2) then rev;\n\n while (y1<=y2) do\n begin\n if vis(y1) then month[2]:=29;\n while true do\n begin\n inc(d1); inc(kol); if d1>month[m1] then begin inc(m1); d1:=1; end;\n if m1>12 then begin m1:=1; break; end;\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(kol); halt; end;\n end;\n inc(y1); month[2]:=28;\n end;\n\n writeln(kol);\n\nEND.\n"}, {"source_code": "program uio;\nconst month:array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n var s1,s2:string;\n y1,m1,d1,y2,m2,d2,kol,i:longint;\n\n\nprocedure pro(s:string; var y,m,d:longint);\n var code:longint;\n ss:string;\n\nbegin\n\n ss:=s[1]+s[2]+s[3]+s[4];\n val(ss,y,code);\n\n ss:='';\n if s[6]='0' then ss:=ss+s[7]\n else ss:=ss+s[6]+s[7];\n val(ss,m,code);\n\n ss:='';\n if s[9]='0' then ss:=ss+s[10]\n else ss:=ss+s[9]+s[10];\n val(ss,d,code);\n\n\nend;\n\n\nfunction vis(x:longint):boolean;\nbegin\n\n if (x mod 400) = 0 then exit(true);\n if (x mod 4 = 0)and(x mod 100<>0) then exit(true);\n exit(false);\n\nend;\n\n\nprocedure rev;\n var cc:longint;\n\nbegin\n\n cc:=y1; y1:=y2; y2:=cc;\n cc:=m1; m1:=m2; m2:=cc;\n cc:=d1; d1:=d2; d2:=cc;\n\nend;\n\n\n\nBEGIN\n\n readln(s1); readln(s2);\n pro(s1,y1,m1,d1); pro(s2,y2,m2,d2);\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(1); halt; end;\n kol:=0;\n if y1>y2 then rev\n else if (y1=y2)and(m1>m2) then rev\n else if (m1=m2)and(d1>d2) then rev;\n\n while (y1<=y2) do\n begin\n if vis(y1) then month[2]:=29;\n while true do\n begin\n inc(d1); inc(kol); if d1>month[m1] then begin inc(m1); d1:=1; end;\n if m1>12 then begin m1:=1; break; end;\n if (y1=y2)and(m1=m2)and(d1=d2) then begin writeln(kol); halt; end;\n end;\n inc(y1); month[2]:=28;\n end;\n\n writeln(kol);\n\nEND."}, {"source_code": "Const a : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n\nVar y1, m1, d1, y2, i, m2, d2, dd, code : longint;\n date : int64;\n s1, s2 : string;\n\nProcedure change(m,d:longint);\n Var month, day : longint;\n Begin\n dd := 0;\n for i:=1 to m-1 do\n dd := dd+a[i];\n dd := dd+d;\n End;\n\nProcedure swap(var x, y : longint);\n Var tmp : longint;\n Begin\n tmp := x;\n x := y;\n y := tmp; \n End;\n\nBegin\n readln(s1);\n readln(s2);\n val(copy(s1,1,4),y1,code);\n val(copy(s1,6,2),m1,code);\n val(copy(s1,9,2),d1,code);\n /////////\n val(copy(s2,1,4),y2,code);\n val(copy(s2,6,2),m2,code);\n val(copy(s2,9,2),d2,code);\n /////////\n if y1 > y2 then begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i:=y1 to y2-1 do begin\n if i mod 400 = 0 then begin\n date := date+366;\n continue;\n end;\n if i mod 100 = 0 then begin\n date := date+365;\n continue;\n end;\n if i mod 4 = 0 then date := date+366\n else date := date+365;\n end;\n change(m1,d1);\n if ((y1 mod 400 = 0) or ((y1 mod 100 <> 0) and (y1 mod 4 = 0))) and (m1 > 2) then\n dd := dd+1;\n date := date-dd+1;\n dd := 0;\n change(m2,d2);\n if ((y2 mod 400 = 0) or ((y2 mod 100 <> 0) and (y2 mod 4 = 0))) and (m2 > 2) then\n dd := dd+1;\n date := date+dd;\n writeln(date-1);\nEnd.\n"}, {"source_code": "Const a : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\n\nVar y1, m1, d1, y2, i, m2, d2, dd, code : longint;\n date : int64;\n s1, s2 : string;\n\nProcedure change(m,d:longint);\n Var month, day : longint;\n Begin\n dd := 0;\n for i:=1 to m-1 do\n dd := dd+a[i];\n dd := dd+d;\n End;\n\nProcedure swap(var x, y : longint);\n Var tmp : longint;\n Begin\n tmp := x;\n x := y;\n y := tmp;\n End;\n\nBegin\n readln(s1);\n readln(s2);\n val(copy(s1,1,4),y1,code);\n val(copy(s1,6,2),m1,code);\n val(copy(s1,9,2),d1,code);\n /////////\n val(copy(s2,1,4),y2,code);\n val(copy(s2,6,2),m2,code);\n val(copy(s2,9,2),d2,code);\n /////////\n if y1 > y2 then begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i:=y1 to y2-1 do begin\n if (i mod 400 = 0) and (i mod 1000 = 0) then begin\n date := date+366;\n continue;\n end;\n if i mod 100 = 0 then begin\n date := date+365;\n continue;\n end;\n if i mod 4 = 0 then date := date+366\n else date := date+365;\n end;\n change(m1,d1);\n if (((y1 mod 400 = 0) and (y1 mod 1000 = 0)) or ((y1 mod 100 <> 0) and (y1 mod 4 = 0))) and (m1 > 2) then\n dd := dd+1;\n date := date-dd+1;\n dd := 0;\n change(m2,d2);\n if (((y2 mod 400 = 0) and (y2 mod 1000 = 0)) or ((y2 mod 100 <> 0) and (y2 mod 4 = 0))) and (m2 > 2) then\n dd := dd+1;\n date := date+dd;\n writeln(date-1);\nEnd.\n"}, {"source_code": "const a:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar s,s1:string;\nx,x1,y1,y,z,z1,ans,i,c,f:longint;\nBegin\n // assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n readln(s);\n readln(s1);\n if s=s1 then begin writeln(0); halt; end;\n for i:=1 to 4 do\n begin\n val(s[i],c,f);\n x:=x*10+c;\n val(s1[i],c,f);\n x1:=x1*10+c;\n end;\n for i:=6 to 7 do\n begin\n val(s[i],c,f);\n y:=y*10+c;\n val(s1[i],c,f);\n y1:=y1*10+c;\n end;\n for i:=9 to 10 do\n begin\n val(s[i],c,f);\n z:=z*10+c;\n val(s1[i],c,f);\n z1:=z1*10+c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x>x1)or((x=x1)and(y>y1))or((x=x1)and(y=y1)and(z>z1)) then\n begin\n c:=x;\n x:=x1;\n x1:=c;\n c:=y;\n y:=y1;\n y1:=c;\n c:=z;\n z:=z1;\n z1:=c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x=x1)and(y=y1)then\n begin\n writeln(z1-z+1);\n halt;\n end;\n if (x=x1)then\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=a[y]-z+2; end\n else ans:=a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while x<>x1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while y<>y1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n end;\n ans:=ans+z1-1;\n writeln(ans);\nend.\n"}, {"source_code": "const a:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar s,s1:string;\nx,x1,y1,y,z,z1,ans,i,c,f:longint;\nBegin\n // assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n readln(s);\n readln(s1);\n for i:=1 to 4 do\n begin\n val(s[i],c,f);\n x:=x*10+c;\n val(s1[i],c,f);\n x1:=x1*10+c;\n end;\n for i:=6 to 7 do\n begin\n val(s[i],c,f);\n y:=y*10+c;\n val(s1[i],c,f);\n y1:=y1*10+c;\n end;\n for i:=9 to 10 do\n begin\n val(s[i],c,f);\n z:=z*10+c;\n val(s1[i],c,f);\n z1:=z1*10+c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x>x1)or((x=x1)and(y>y1))or((x=x1)and(y=y1)and(z>z1)) then\n begin\n c:=x;\n x:=x1;\n x1:=c;\n c:=y;\n y:=y1;\n y1:=c;\n c:=z;\n z:=z1;\n z1:=c;\n end;\n // writeln(x,' ',x1,' ',z,' ',z1,' ',y,' ',y1);\n if (x=x1)and(y=y1)then\n begin\n writeln(z1-z+1);\n halt;\n end;\n if (x=x1)then\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=a[y]-z+2; end\n else ans:=a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while x<>x1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n if y=13 then\n begin\n y:=1;\n inc(x);\n end;\n end;\n while y<>y1 do\n begin\n if (((x mod 4=0)and(x mod 100<>0))or(x mod 400=0))\n and (y=2)then begin ans:=ans+a[y]-z+2; end\n else ans:=ans+a[y]-z+1;\n z:=1;\n inc(y);\n end;\n ans:=ans+z1-1;\n writeln(ans);\nend.\n"}, {"source_code": "const dayofm:array[1..12]of integer=(31,28,31,30,31,30,31,31,30,31,30,31);\nvar a,b:string;\n i,d1,d2,m1,m2,y1,y2:integer;\nprocedure solve;\nvar tmp:integer;ans:longint;\n begin\n ans:=0;\n if y1>y2 then\n begin\n tmp:=y1;y1:=y2;y2:=tmp;\n tmp:=m1;m1:=m2;m2:=tmp;\n tmp:=d1;d1:=d2;d2:=tmp;\n end;\n for i:=m1 to 12 do\n begin\n if ((i=2) and (((y1 mod 4=0) and (y1 mod 100<>0))or (y1 mod 400=0))) then ans:=ans+29\n else ans:=ans+dayofm[i];\n end;\n ans:=ans-d1;\n for i:=y1+1 to y2-1 do if\n (((i mod 4=0) and (i mod 100<>0))or (i mod 400=0)) then ans:=ans+366 else ans:=ans+365;\n for i:=1 to m2-1 do\n begin\n if ((i=2) and (((y2 mod 4=0) and (y2 mod 100<>0))or (y2 mod 400=0))) then ans:=ans+29\n else ans:=ans+dayofm[i];\n end;\n ans:=ans+d2;\n write(ans);\n end;\nbegin\nreadln(a);\nfor i:=1 to 4 do y1:=10*y1+ord(a[i])-48;\nfor i:=6 to 7 do m1:=10*m1+ord(a[i])-48;\nfor i:=9 to 10 do d1:=10*d1+ord(a[i])-48;\nreadln(b);\nfor i:=1 to 4 do y2:=10*y2+ord(b[i])-48;\nfor i:=6 to 7 do m2:=10*m2+ord(b[i])-48;\nfor i:=9 to 10 do d2:=10*d2+ord(b[i])-48;\nsolve;\nend."}, {"source_code": "{$mode objfpc}\nprogram b;\nvar\n s1,s2,y1,y2,m1,m2,d1,d2:string;\n year1,year2,month1,month2,date1,date2,v:longint;\n count:qword;\n mo:array[1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s1);\n readln(s2);\n count:=0;\n y1:=copy(s1,1,4);m1:=copy(s1,6,2);d1:=copy(s1,9,2);\n y2:=copy(s2,1,4);m2:=copy(s2,6,2);d2:=copy(s2,9,2);\n val(y1,year1,v);val(m1,month1,v);val(d1,date1,v);\n val(y2,year2,v);val(m2,month2,v);val(d2,date2,v);\n if s1=s2 then writeln(0)\n else\n if s2>s1 then\n begin\n repeat\n if (year1 mod 400=0) or ((year1 mod 4 = 0)and (year1 mod 100 <>0)) then\n begin\n mo[2]:=29;\n inc(date1);\n if date1>mo[month1] then\n begin\n inc(month1);\n date1:=1;\n end;\n if month1>12 then\n begin\n inc(year1);\n month1:=1;\n end;\n inc(count);\n end\n else\n begin\n mo[2]:=28;\n inc(date1);\n if date1>mo[month1] then\n begin\n inc(month1);\n date1:=1;\n end;\n if month1>12 then\n begin\n inc(year1);\n month1:=1;\n end;\n inc(count);\n end;\n until (date1=date2) and (month1=month2) and (year1=year2);\n end\n else\n begin\n repeat\n if (year2 mod 400=0) or ((year2 mod 4 = 0)and (year2 mod 100 <>0)) then\n begin\n mo[2]:=29;\n inc(date2);\n if date2>mo[month2] then\n begin\n inc(month2);\n date2:=1;\n end;\n if month2>12 then\n begin\n inc(year2);\n month2:=1;\n end;\n inc(count);\n end\n else\n begin\n mo[2]:=28;\n inc(date2);\n if date2>mo[month2] then\n begin\n inc(month2);\n date2:=1;\n end;\n if month2>12 then\n begin\n inc(year2);\n month2:=1;\n end;\n inc(count);\n end;\n until (date1=date2) and (month1=month2) and (year1=year2);\n end;\n writeln(count);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if ans=366 then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//珍爱生命,请勿抄袭代码,如果现在打开这个界面的(未经允许下)是WYT/WS/JHJ/JYK/TJX,那你就去死吧,抄袭Dog!!!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//珍爱生命,请勿抄袭代码,如果现在打开这个界面的(未经允许下),那你就去死吧,抄袭Dog!!!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (y1=y2) and (x1+1=x2) then dec(ans);\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//珍爱生命,请勿抄袭代码,如果现在打开这个界面的(未经允许下)是WYT/WS/JHJ/JYK/TJX,那你就去死吧,抄袭Dog!!!"}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if ans=1 then ans:=0;\n writeln(ans);\nend."}, {"source_code": "var\n s:ansistring;\n i,j,k,x1,y1,z1,x2,y2,z2,ans,t:longint;\n a:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);\nbegin\n readln(s);\n val(copy(s,1,4),x1);\n val(copy(s,6,2),y1);\n val(copy(s,9,2),z1);\n readln(s);\n val(copy(s,1,4),x2);\n val(copy(s,6,2),y2);\n val(copy(s,9,2),z2);\n if (x1>x2) or ((x1=x2) and (y2z2)) then\n begin\n t:=x1;x1:=x2;x2:=t;\n t:=y1;y1:=y2;y2:=t;\n t:=z1;z1:=z2;z2:=t;\n end;\n if ((x1 mod 400=0) or ((x1 mod 4=0) and (x1 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=a[y1]-z1;\n for i:=y1+1 to 12 do ans:=ans+a[i];\n for i:=x1+1 to x2-1 do\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans+366 else ans:=ans+365;\n if ((x2 mod 400=0) or ((x2 mod 4=0) and (x2 mod 100<>0))) then a[2]:=29 else a[2]:=28;\n ans:=ans+z2;\n for i:=1 to y2-1 do ans:=ans+a[i];\n if x1=x2 then\n if ((i mod 400=0) or ((i mod 4=0) and (i mod 100<>0))) then ans:=ans-366 else ans:=ans-365;\n if (x1=x2) and (y1=y2) and (z1=z2) then ans:=0;\n if ans=32 then ans:=31;\n writeln(ans);\nend.\n//!!!```"}, {"source_code": "Uses Math,SysUtils;\nConst mas:array[0..1,1..12] of Integer=((31,28,31,30,31,30,31,31,30,31,30,31),\n(31,29,31,30,31,30,31,31,30,31,30,31));\nVar N,I,J,T,K,Y,D,M,Y1,D1,M1:Integer;S:String;f:Integer;\nFunction Prov:Integer;\nbegin\n If ((Y mod 400)=0) or ((Y mod 4=0) and (Y mod 100<>0))\n then Prov:=1\n else Prov:=0;\nend;\nProcedure Swith;\nVar I:Integer;\nbegin\n I:=Y1;\n Y1:=Y;\n Y:=I;\n I:=M1;\n M1:=M;\n M:=I;\n I:=D1;\n D1:=D;\n D:=I;\nend;\nBegin\n ///reset(input,'INPUT.TXT');\n ///assign(output,'OUTPUT.TXT');\n readln(S);\n Y:=StrToInt(Copy(S,1,4));\n Delete(S,1,5);\n M:=StrToInt(Copy(S,1,2));\n Delete(S,1,3);\n D:=StrToInt(Copy(S,1,2));\n readln(S);\n Y1:=StrToInt(Copy(S,1,4));\n Delete(S,1,5);\n M1:=StrToInt(Copy(S,1,2));\n Delete(S,1,3);\n D1:=StrToInt(Copy(S,1,2));\n If Y>Y1\n then Swith\n else If Y=Y1\n then If M>M1\n then Swith\n else If M=M1\n then If D>D1\n then Swith;\n K:=0;\n f:=Prov;\n If D112\n then begin\n M:=1;\n Inc(Y);\n f:=Prov;\n end;\n end\n else begin\n K:=D1-D+1;\n D:=D1;\n end;\n If (D=D1) and (M=M1) and (Y=Y1)\n then write(K)\n else begin\n Repeat\n K:=K+mas[f,M];\n Inc(M);\n If M>12\n then begin\n M:=1;\n Inc(Y);\n f:=Prov;\n end;\n Until (D=D1) and (M=M1) and (Y=Y1);\n write(K-1);\n end;\nEnd.\n"}, {"source_code": "Const month: array [1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\n fi='';\n fo='';\nVar res:longint;\n year1,year2,month1,month2,day1,day2: integer;\n\nProcedure input;\nVar i: integer;\n f: text;\n S1,S2,c: String;\nBegin\n assign(f,fi); reset(F);\n readln(f,S1);\n readln(f,S2);\n Delete(S1,5,1); Delete(S1,7,1);\n C:=Copy(S1,1,4); Val(C,year1);\n C:=Copy(S1,5,2); Val(c,month1);\n C:=Copy(S1,7,2); Val(C,day1);\n Delete(S2,5,1); Delete(S2,7,1);\n C:=Copy(S2,1,4); Val(C,year2);\n C:=Copy(S2,5,2); Val(c,month2);\n C:=Copy(S2,7,2); Val(C,day2);\n close(f);\nEnd;\n\n\nProcedure calculate;\nVar i: integer;\n f: text;\n total1,total2: longint;\nBegin\n total1:=0;\n total2:=0;\n For i:= year1-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total1:=total1+366\n else total1:=total1+365;\n For i:= month1-1 downto 1 do\n total1:=total1+month[i];\n For i:= day1 downto 1 do\n total1:=total1+1;\n If (((year1 mod 4=0) and (year1 mod 100 <>0)) or (year1 mod 400=0) and (month1>2)) then total1:=total1+1;\n\n For i:= year2-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total2:=total2+366\n else total2:=total2+365;\n For i:= month2-1 downto 1 do\n total2:=total2+month[i];\n For i:= day2 downto 1 do\n total2:=total2+1;\n If (((year2 mod 4=0) and (year2 mod 100 <>0)) or (year2 mod 400=0) and (month2>2)) then total2:=total2+1;\n res:= ABS(total1-total2);\n assign(f,fo); rewrite(f);\n writeln(res);\n close(f);\nEnd;\n\nBegin\n input;\n calculate;\nEnd."}, {"source_code": "Const month: array [1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\n fi='';\n fo='';\nVar res:longint;\n year1,year2,month1,month2,day1,day2: longint;\n\nProcedure input;\nVar i: longint;\n f: text;\n S1,S2,c: String;\nBegin\n assign(f,fi); reset(F);\n readln(f,S1);\n readln(f,S2);\n Delete(S1,5,1); Delete(S1,7,1);\n C:=Copy(S1,1,4); Val(C,year1);\n C:=Copy(S1,5,2); Val(c,month1);\n C:=Copy(S1,7,2); Val(C,day1);\n Delete(S2,5,1); Delete(S2,7,1);\n C:=Copy(S2,1,4); Val(C,year2);\n C:=Copy(S2,5,2); Val(c,month2);\n C:=Copy(S2,7,2); Val(C,day2);\n close(f);\nEnd;\n\n\nProcedure calculate;\nVar i: longint;\n f: text;\n total1,total2: longint;\nBegin\n total1:=0;\n total2:=0;\n For i:= year1-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total1:=total1+366\n else total1:=total1+365;\n For i:= month1-1 downto 1 do\n total1:=total1+month[i];\n For i:= day1 downto 1 do\n total1:=total1+1;\n If (((year1 mod 4=0) and (year1 mod 100 <>0)) or (year1 mod 400=0) and (month1>2)) then total1:=total1+1;\n\n For i:= year2-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total2:=total2+366\n else total2:=total2+365;\n For i:= month2-1 downto 1 do\n total2:=total2+month[i];\n For i:= day2 downto 1 do\n total2:=total2+1;\n If (((year2 mod 4=0) and (year2 mod 100 <>0)) or (year2 mod 400=0) and (month2>2)) then total2:=total2+1;\n res:= ABS(total1-total2);\n assign(f,fo); rewrite(f);\n writeln(res);\n close(f);\nEnd;\n\nBegin\n input;\n calculate;\nEnd."}, {"source_code": "Const month: array [1..12] of integer = (31,28,31,30,31,30,31,31,30,31,30,31);\n fi='';\n fo='';\nVar res:longint;\n year1,year2,month1,month2,day1,day2: longint;\n\nProcedure input;\nVar i: longint;\n f: text;\n S1,S2,c: String;\nBegin\n assign(f,fi); reset(F);\n readln(f,S1);\n readln(f,S2);\n Delete(S1,5,1); Delete(S1,7,1);\n C:=Copy(S1,1,4); Val(C,year1);\n C:=Copy(S1,5,2); Val(c,month1);\n C:=Copy(S1,7,2); Val(C,day1);\n Delete(S2,5,1); Delete(S2,7,1);\n C:=Copy(S2,1,4); Val(C,year2);\n C:=Copy(S2,5,2); Val(c,month2);\n C:=Copy(S2,7,2); Val(C,day2);\n close(f);\nEnd;\n\n\nProcedure calculate;\nVar i: longint;\n f: text;\n total1,total2: longint;\nBegin\n total1:=0;\n total2:=0;\n For i:= year1-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total1:=total1+366\n else total1:=total1+365;\n For i:= month1-1 downto 1 do\n total1:=total1+month[i];\n For i:= day1 downto 1 do\n total1:=total1+1;\n If (((year1 mod 4=0) and (year1 mod 100 <>0)) or (year1 mod 400=0) and (month1>2)) then total1:=total1+1;\n\n For i:= year2-1 downto 1900 do\n If ((i mod 4=0) and (i mod 100 <>0)) or (i mod 400=0) then\n total2:=total2+366\n else total2:=total2+365;\n For i:= month2-1 downto 1 do\n total2:=total2+month[i];\n For i:= day2 downto 1 do\n total2:=total2+1;\n If (((year2 mod 4=0) and (year2 mod 100 <>0)) or (year2 mod 400=0) and (month2>2)) then total2:=total2+1;\n res:= ABS(total1-total2);\n assign(f,fo); rewrite(f);\n writeln(f,res);\n close(f);\nEnd;\n\nBegin\n input;\n calculate;\nEnd."}, {"source_code": "\n\n\nvar\n a, b: array[1..13] of longint;\n s1, s2, t: string[10];\n d1, m1,i, y1, d2, m2, y2, ans: longint;\nbegin\n a[1]:= 31;\n a[2]:= 29;\n a[3]:= 31;\n a[4]:= 30;\n a[5]:= 31;\n a[6]:= 30;\n a[7]:= 31;\n a[8]:= 31;\n a[9]:= 30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n a[13]:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12];\n b[1]:= 31;\n b[2]:= 28;\n b[3]:= 31;\n b[4]:= 30;\n b[5]:= 31;\n b[6]:= 30;\n b[7]:= 31;\n b[8]:= 31;\n b[9]:= 30;\n b[10]:=31;\n b[11]:=30;\n b[12]:=31;\n b[13]:=b[1]+b[2]+b[3]+b[4]+b[5]+b[6]+b[7]+b[8]+b[9]+b[10]+b[11]+b[12];\n readln(s1);\n readln(s2);\n if s1 > s2 then begin\n t:= s1;\n s1 := s2;\n s2 := t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s1,6,2),m1);\n val(copy(s1,9,2),d1);\n val(copy(s2,1,4),y2);\n val(copy(s2,6,2),m2);\n val(copy(s2,9,2),d2);\n\n\nfor i := y1 + 1 to y2 - 1 do\n if (i mod 400 = 0) or ((i mod 100<>0)and(i mod 4 = 0))\n then inc(ans, a[13])\n else inc(ans, b[13]);\n\n\nfor i := m1 to 12 do\n if (y1 mod 400 = 0) or ((y1 mod 100<>0)and(y1 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n dec(ans,d1);\n\n for i := 1 to m2-1 do\n if (y2 mod 400 = 0) or ((y2 mod 100<>0)and(y2 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n inc(ans,d2);\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "\n\n\nvar\n a, b: array[1..13] of longint;\n s1, s2, t: string[10];\n d1, m1,i, y1, d2, m2, y2, ans: longint;\nbegin\n a[1]:= 31;\n a[2]:= 29;\n a[3]:= 31;\n a[4]:= 30;\n a[5]:= 31;\n a[6]:= 30;\n a[7]:= 31;\n a[8]:= 31;\n a[9]:= 30;\n a[10]:=31;\n a[11]:=30;\n a[12]:=31;\n a[13]:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]+a[11]+a[12];\n b[1]:= 31;\n b[2]:= 28;\n b[3]:= 31;\n b[4]:= 30;\n b[5]:= 31;\n b[6]:= 30;\n b[7]:= 31;\n b[8]:= 31;\n b[9]:= 30;\n b[10]:=31;\n b[11]:=30;\n b[12]:=31;\n b[13]:=b[1]+b[2]+b[3]+b[4]+b[5]+b[6]+b[7]+b[8]+b[9]+b[10]+b[11]+b[12];\n readln(s1);\n readln(s2);\n if s1 = s2 then\n begin\n writeln(0);\n halt;\n end;\n if s1 > s2 then begin\n t:= s1;\n s1 := s2;\n s2 := t;\n end;\n val(copy(s1,1,4),y1);\n val(copy(s1,6,2),m1);\n val(copy(s1,9,2),d1);\n val(copy(s2,1,4),y2);\n val(copy(s2,6,2),m2);\n val(copy(s2,9,2),d2);\n\n\nfor i := y1 + 1 to y2 - 1 do\n if (i mod 400 = 0) or ((i mod 100<>0)and(i mod 4 = 0))\n then inc(ans, a[13])\n else inc(ans, b[13]);\n\n\nfor i := m1 to 12 do\n if (y1 mod 400 = 0) or ((y1 mod 100<>0)and(y1 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n dec(ans,d1);\n\n for i := 1 to m2-1 do\n if (y2 mod 400 = 0) or ((y2 mod 100<>0)and(y2 mod 4 = 0))\n then inc(ans, a[i])\n else(inc(ans,b[i]));\n inc(ans,d2);\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "var s1,s2:string;\n m1,m2,y1,y2,d1,d2,tmp,ans,t:longint;\n\ta:array[1..12] of longint;\n\nfunction check(i:longint):boolean;\nbegin\n if ((i mod 100=0)and(i mod 400=0))or((i mod 100<>0)and(i mod 4=0)) \n\tthen exit(true) else exit(false);\nend;\n\nprocedure main;\nvar i:longint;\nbegin\n readln(s1);readln(s2);\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s1[i])-ord('0');\n y1:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s1[i])-ord('0');\n m1:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s1[i])-ord('0');\n d1:=tmp;\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s2[i])-ord('0');\n y2:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s2[i])-ord('0');\n m2:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s2[i])-ord('0');\n d2:=tmp;\n if (y1>y2)or((y1=y2)and(m1>m2))or((y1=y2)and(m1=m2)and(d1>d2)) then\n begin\n t:=y1;y1:=y2;y2:=t;\n\tt:=m1;m1:=m2;m2:=t;\n\tt:=d1;d1:=d2;d2:=t;\n end;\n //writeln(y1,' ',m1,' ',d1);writeln(y2,' ',m2,' ',d2);\n for i:=y1+1 to y2-1 do\n begin\n\tif check(i) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to 12 do\n case i of\n 1,3,5,7,8,10,12:a[i]:=31;\n 2:a[i]:=28;\n 4,6,9,11:a[i]:=30;\n end;\n if check(y1)and(m1+1<=2) then inc(ans);\n for i:=m1+1 to 12 do inc(ans,a[i]);\n if m1=2 then inc(ans);\n inc(ans,a[m1]-d1+1);\n //======================================\n for i:=1 to m2-1 do inc(ans,a[i]);\n if check(y2)and(m2-1>=2) then inc(ans);\n inc(ans,d2-1);\n writeln(ans);\nend;\n\nbegin\n //assign(input,'1.in');\n //reset(input);\n main;\n //close(input);\nend.\n"}, {"source_code": "var s1,s2:string;\n m1,m2,y1,y2,d1,d2,tmp,ans,t:longint;\n\ta:array[1..12] of longint;\n\nfunction check(i:longint):boolean;\nbegin\n if ((i mod 100=0)and(i mod 400=0))or((i mod 100<>0)and(i mod 4=0)) \n\tthen exit(true) else exit(false);\nend;\n\nprocedure main;\nvar i:longint;\nbegin\n readln(s1);readln(s2);\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s1[i])-ord('0');\n y1:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s1[i])-ord('0');\n m1:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s1[i])-ord('0');\n d1:=tmp;\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s2[i])-ord('0');\n y2:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s2[i])-ord('0');\n m2:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s2[i])-ord('0');\n d2:=tmp;\n if (y1>y2)or((y1=y2)and(m1>m2))or((y1=y2)and(m1=m2)and(d1>d2)) then\n begin\n t:=y1;y1:=y2;y2:=t;\n\tt:=m1;m1:=m2;m2:=t;\n\tt:=d1;d1:=d2;d2:=t;\n end;\n for i:=y1+1 to y2-1 do\n begin\n\tif check(i) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to 12 do\n case i of\n 1,3,5,7,8,10,12:a[i]:=31;\n 2:a[i]:=28;\n 4,6,9,11:a[i]:=30;\n end;\n if check(y1)and(m1+1>=2) then inc(ans);\n for i:=m1+1 to 12 do inc(ans,a[i]);\n if m1=2 then inc(ans);\n inc(ans,a[m1]-d1);\n //======================================\n for i:=1 to m2-1 do inc(ans,a[i]);\n if check(y2)and(m2-1>=2) then inc(ans);\n inc(ans,d2);\n writeln(ans);\nend;\n\nbegin\n //assign(input,'1.in');\n //reset(input);\n main;\n //close(input);\nend.\n"}, {"source_code": "var s1,s2:string;\n m1,m2,y1,y2,d1,d2,tmp,ans,t:longint;\n\ta:array[1..12] of longint;\n\nfunction check(i:longint):boolean;\nbegin\n if ((i mod 100=0)and(i mod 400=0))or((i mod 100<>0)and(i mod 4=0)) \n\tthen exit(true) else exit(false);\nend;\n\nprocedure main;\nvar i:longint;\nbegin\n readln(s1);readln(s2);\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s1[i])-ord('0');\n y1:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s1[i])-ord('0');\n m1:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s1[i])-ord('0');\n d1:=tmp;\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s2[i])-ord('0');\n y2:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s2[i])-ord('0');\n m2:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s2[i])-ord('0');\n d2:=tmp;\n if (y1>y2)or((y1=y2)and(m1>m2))or((y1=y2)and(m1=m2)and(d1>d2)) then\n begin\n t:=y1;y1:=y2;y2:=t;\n\tt:=m1;m1:=m2;m2:=t;\n\tt:=d1;d1:=d2;d2:=t;\n end;\n //writeln(y1,' ',m1,' ',d1);writeln(y2,' ',m2,' ',d2);\n for i:=y1+1 to y2-1 do\n begin\n\tif check(i) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to 12 do\n case i of\n 1,3,5,7,8,10,12:a[i]:=31;\n 2:a[i]:=28;\n 4,6,9,11:a[i]:=30;\n end;\n if check(y1)and(m1+1<=2) then inc(ans);\n for i:=m1+1 to 12 do inc(ans,a[i]);\n if check(y1)and(m1=2) then inc(ans);\n inc(ans,a[m1]-d1+1);\n //======================================\n for i:=1 to m2-1 do inc(ans,a[i]);\n if check(y2)and(m2-1>=2) then inc(ans);\n inc(ans,d2-1);\n writeln(ans);\nend;\n\nbegin\n //assign(input,'1.in');\n //reset(input);\n main;\n //close(input);\nend.\n"}, {"source_code": "var s1,s2:string;\n m1,m2,y1,y2,d1,d2,tmp,ans,t:longint;\n\ta:array[1..12] of longint;\n\nfunction check(i:longint):boolean;\nbegin\n if ((i mod 100=0)and(i mod 400=0))or((i mod 100<>0)and(i mod 4=0)) \n\tthen exit(true) else exit(false);\nend;\n\nprocedure main;\nvar i:longint;\nbegin\n readln(s1);readln(s2);\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s1[i])-ord('0');\n y1:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s1[i])-ord('0');\n m1:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s1[i])-ord('0');\n d1:=tmp;\n tmp:=0;\n for i:=1 to 4 do tmp:=tmp*10+ord(s2[i])-ord('0');\n y2:=tmp;\n tmp:=0;\n for i:=6 to 7 do tmp:=tmp*10+ord(s2[i])-ord('0');\n m2:=tmp;\n tmp:=0;\n for i:=9 to 10 do tmp:=tmp*10+ord(s2[i])-ord('0');\n d2:=tmp;\n if (y1>y2)or((y1=y2)and(m1>m2))or((y1=y2)and(m1=m2)and(d1>d2)) then\n begin\n t:=y1;y1:=y2;y2:=t;\n\tt:=m1;m1:=m2;m2:=t;\n\tt:=d1;d1:=d2;d2:=t;\n end;\n //writeln(y1,' ',m1,' ',d1);writeln(y2,' ',m2,' ',d2);\n for i:=y1+1 to y2-1 do\n begin\n\tif check(i) then inc(ans,366) else inc(ans,365);\n end;\n for i:=1 to 12 do\n case i of\n 1,3,5,7,8,10,12:a[i]:=31;\n 2:a[i]:=28;\n 4,6,9,11:a[i]:=30;\n end;\n if check(y1)and(m1+1<=2) then inc(ans);\n for i:=m1+1 to 12 do inc(ans,a[i]);\n if m1=2 then inc(ans);\n inc(ans,a[m1]-d1);\n //======================================\n for i:=1 to m2-1 do inc(ans,a[i]);\n if check(y2)and(m2-1>=2) then inc(ans);\n inc(ans,d2);\n writeln(ans);\nend;\n\nbegin\n //assign(input,'1.in');\n //reset(input);\n main;\n //close(input);\nend.\n"}, {"source_code": "const\n fi = '';\n fo = '';\n ngay : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n d1,m1,y1,d2,m2,y2,p,code,i,j,nn,nt,t : longint;\n phu,s : string;\n\nprocedure swap(var x,y : longint);\nvar\n p : longint;\nbegin\n p := x;\n x := y;\n y := p;\nend;\n\nfunction ktnamnhuan(i:longint):longint;\nbegin\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then ktnamnhuan := 1\n else ktnamnhuan := 0;\nend;\n\nprocedure xuat(t:longint);\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(t);\n close(output);\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y1=0 then val(phu,y1,code)\n else val(phu,m1,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d1,code);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y2=0 then val(phu,y2,code)\n else val(phu,m2,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d2,code);\n close(input);\n\n if (y1 > y2) or ((y1 = y2) and (m1 > m2)) or ((y1 = y2) and (m1 = m2) and (d1 > d2)) then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i := y1 to y2 do\n begin\n p := ktnamnhuan(i);\n t := t+365+p;\n end;\n p := ktnamnhuan(y1);\n for i := 1 to m1-1 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n t := t-d1;\n p := ktnamnhuan(y2);\n for i := m2+1 to 12 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n if m2 <> 2 then t := t-(ngay[m2]-d2)\n else t := t-(ngay[m2]+1-d2);\n xuat(t);\nend.\n"}, {"source_code": "const\n fi = '';\n fo = '';\n ngay : array[1..12] of longint = (31,28,31,30,31,30,31,31,30,31,30,31);\nvar\n d1,m1,y1,d2,m2,y2,p,code,i,j,nn,nt,t : longint;\n phu,s : string;\n\nprocedure swap(var x,y : longint);\nvar\n p : longint;\nbegin\n p := x;\n x := y;\n y := p;\nend;\n\nfunction ktnamnhuan(i:longint):longint;\nbegin\n if ((i mod 4 = 0) and (i mod 100 <> 0)) or (i mod 400 = 0) then ktnamnhuan := 1\n else ktnamnhuan := 0;\nend;\n\nprocedure xuat(t:longint);\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(t);\n close(output);\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y1=0 then val(phu,y1,code)\n else val(phu,m1,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d1,code);\n readln(s);\n p := 0;\n for i := 1 to length(s) do\n if (s[i] = ':') then\n begin\n phu := '';\n for j := p+1 to i-1 do\n phu := phu + s[j];\n if y2=0 then val(phu,y2,code)\n else val(phu,m2,code);\n p := i;\n end;\n phu := '';\n for i := p+1 to length(s) do\n phu := phu+s[i];\n val(phu,d2,code);\n close(input);\n\n if (y1 > y2) or ((y1 = y2) and (m1 > m2)) or ((y1 = y2) and (m1 = m2) and (d1 > d2)) then\n begin\n swap(y1,y2);\n swap(m1,m2);\n swap(d1,d2);\n end;\n for i := y1 to y2 do\n begin\n p := ktnamnhuan(i);\n t := t+365+p;\n end;\n p := ktnamnhuan(y1);\n for i := 1 to m1-1 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n t := t-d1;\n p := ktnamnhuan(y2);\n for i := m2+1 to 12 do\n if i <> 2 then t := t-ngay[i]\n else t := t-ngay[i]-p;\n t := t-(ngay[m2]-d2);\n xuat(t);\nend.\n"}], "src_uid": "bdf99d78dc291758fa09ec133fff1e9c"} {"source_code": "var s:string;\n ans:longint;\n\nprocedure openfile;\n begin\n assign(input,'a.in'); reset(input);\n assign(output,'a.out'); rewrite(output);\n end;\n\nprocedure endfile;\n begin\n close(input); close(output);\n end;\n\nprocedure dfs(x,now:longint;y:string);\n var plus,tmp:longint;\n t:string;\n begin\n if length(y)=0 then exit;\n if x=3 then begin\n if length(y)>7 then exit;\n if (length(y)>1)and(y[1]='0') then exit;\n val(y,plus,tmp);\n if plus>1000000 then exit;\n now:=now+plus;\n if now>ans then ans:=now;\n exit;\n end;\n t:='';\n while (length(t)<=7)and(length(y)>0) do begin\n t:=t+y[1];\n delete(y,1,1);\n if (length(t)>1)and(t[1]='0') then exit;\n val(t,plus,tmp);\n if plus<=1000000 then dfs(x+1,now+plus,y);\n end;\n end;\n\nbegin\n //openfile;\n ans:=-1;\n readln(s);\n dfs(1,0,s);\n writeln(ans);\n //endfile;\nend.\n\n\n\n\n\n", "positive_code": [{"source_code": "var\n s:string;\n i,j,k,ans,k1,k2,k3:longint;\nbegin\n\nreadln(s);\nans:=-1;\nfor i:=2 to length(s)-1 do\nfor j:=i+1 to length(s) do\n begin\n if (i-1>=8)or((s[1]='0')and(i>2)) then continue;\n if (j-i>=8)or((s[i]='0')and(j-i>=2)) then continue;\n if (length(s)-j+1>=8)or((s[j]='0')and(length(s)-j+1>=2)) then continue;\n k1:=0;\n for k:=1 to i-1 do k1:=k1*10+ord(s[k])-ord('0');\n k2:=0;\n for k:=i to j-1 do k2:=k2*10+ord(s[k])-ord('0');\n k3:=0;\n for k:=j to length(s) do k3:=k3*10+ord(s[k])-ord('0');\n if (k1<=1000000)and(k2<=1000000)and(k3<=1000000) then\n if (ans'0') or (Length (s1)=1)) and ((s2[1]<>'0') or (Length (s2)=1)) and ((s3[1]<>'0') or (Length (s3)=1)) and\n ((Length (s1)<7)or (s1=c)) and ((Length (s2)<7) or (s2=c)) and ((Length (s3)<7) or (s3=c))\n then Begin\n\n k:=StrToInt (s1)+StrToInt (s2)+StrToInt (s3);\n If k>max\n then max:=k;\n End;\n End;\n End;\n If max=0\n then Writeln (-1)\n else Writeln (max);\nEnd."}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n{$define func:=function}\n{$define proc:=procedure}\n{$define be:=begin}\n{$define en:=end}\n{$define el:=else}\n{$define brk:=break}\n{$define th:=then}\n\nuses Classes, SysUtils, StrUtils, Math;\n\nvar\n\ts, ca, cb, cc: AnsiString;\n a, b, c: Long;\n L, sa, sb, sc: Int64;\n\tM: Int64;\n\nbegin\n\tRln(s);\n L := Length(s);\n if l < 3 th\n be\n \tWln(-1);\n exit;\n en;\n if s = '000' th\n be\n \tWln(0);\n exit;\n en;\n {if s[1] = '0' th\n be\n \tWln(-1);\n exit;\n en;}\n M := -1;\n for a := 1 to Min(7, L - 2) do\n be\n \tca := Copy(s, 1, a);\n if ca <> '0' th\n\t if ca[1] = '0' th\n \t \tbrk;\n sa := StrToInt(ca);\n if a = 7 th\n \tif sa > 1000000 th\n brk;\n \tfor b := a + 1 to Min(a + 7, L - 1) do\n be\n \tcb := Copy(s, a + 1, b - (a + 1) + 1);\n \tif cb <> '0' th\n \tif cb[1] = '0' th\n \tbrk;\n sb := StrToInt(cb);\n if Length(cb) = 7 th\n if sb > 1000000 th\n \t\t\tbrk;\n //\n \tcc := Copy(s, b + 1, l);\n //W(a, ' ', b, ': ');\n //Wln(ca, ' ', cb, ' ', cc);\n if cc <> '0' th\n \t\tif cc[1] = '0' th\n continue;\n if Length(cc) > 7 th\n \tcontinue;\n sc := StrToInt(cc);\n if Length(cc) = 7 th\n if sc > 1000000 th\n continue;\n M := Max(M, sa + sb + sc);\n en;\n\ten;\n Wln(M);\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s:string;\n a,b,m:integer;\n h,j,k:integer;\n\nprocedure finish;\nbegin\n write(-1);\n halt\nend;\n\nfunction max(x,y:integer):integer;\nbegin\n if x>y then max:=x else max:=y;\nend;\n\nbegin\n read(s);\n m:=-1;\n\n if length(s)<3 then finish else\n for a:=1 to length(s)-2 do\n for b:=a+1 to length(s)-1 do\n begin\n if (s[1]='0')and(a>1) then continue;\n if (s[a+1]='0')and(b>a+1) then continue;\n if (s[b+1]='0')and(b<>length(s)-1) then continue;\n\n if length(copy(s,1,a))>7 then continue;\n if length(copy(s,a+1,b-a))>7 then continue;\n if length(copy(s,b+1,length(s)-b))>7 then continue;\n\n h:=strtoint(copy(s,1,a));\n j:=strtoint(copy(s,a+1,b-a));\n k:=strtoint(copy(s,b+1,length(s)-b));\n if (h<=1000000)and(j<=1000000)and(k<=1000000) then\n m:=max(m,h+j+k);\n end;\n\n write(m);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\nvar\n s: ansistring;\n i,j,k,v,q,n: longint;\n f: array [0..333,0..4] of longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=0 to n do\n for j:=0 to 3 do f[i,j]:=-1000000000;\n f[0,0]:=0;\n for i:=1 to n do\n for j:=1 to 3 do\n for k:=i-8 to i do\n begin\n if k < 1 then continue;\n if (k < i) and (s[k] = '0') then continue;\n v:=0;\n for q:=k to i do v:=v*10+Ord(s[q])-48;\n if v > 1000000 then continue;\n if f[k-1,j-1]+v > f[i,j] then f[i,j]:=f[k-1,j-1]+v;\n end;\n if f[n,3] < 0 then writeln('-1')\n else writeln(f[n,3]);\nend."}, {"source_code": "program tachchuoi;\nvar\n s,z:string;\n i,j,l,n:integer;\n res,u,v,y:int64;\nfunction tinh(t:string):int64;\nvar k,a,err:integer;temp,x:int64;\nbegin\n if((t[1]='0')and(length(t)>1) ) then exit(-1);\n x:=1;\n // writeln(t);\n temp:=0;\n for k:=length(t) downto 1 do\n begin\n val(t[k],a,err);\n temp:=temp+a*x;\n if(temp>1000000)then exit(-1);\n x:=x*10;\n end;\n// writeln(temp);\n exit(temp);\nend;\nbegin\n readln(s);\n n:=length(s);\n res:=-1;\n for j:=2 to n-2+1 do\n for l:=j+1 to n do\n begin\n z:=copy(s,1,j-1);\n u:=tinh(z);\n z:=copy(s,j,l-j);\n v:=tinh(z);\n z:=copy(s,l,n-l+1);\n y:=tinh(z);\n if((u<>-1)and(v<>-1)and(y<>-1))then\n if(res1)) or\n ((s2[1]='0') and (length(s2)>1)) or\n ((s3[1]='0') and (length(s3)>1)) then continue;\n\n if (x1<=1000000) and\n (x2<=1000000) and\n (x3<=1000000) then begin\n if x1+x2+x3>max then max:=x1+x2+x3;\n end;\n end;\n end;\n writeln(max);\n end.\n"}, {"source_code": "const maxn=500;\n inf=1000000001;\n finp='';\n fout='';\nvar fi,fo:text;\n s:string;\n f:array[0..maxn,0..5]of longint;\nprocedure enter;\nbegin\n assign(fi,finp);reset(fi);\n readln(fi,s);\n close(fi);\nend;\nprocedure solve;\nvar i,j,k,v,q,n:longint;\nbegin\n assign(fo,fout);rewrite(fo);\n n:=length(s);\n for i:=0 to n do\n for j:=0 to 3 do\n f[i,j]:=-inf;\n f[0,0]:=0;\n for i:=1 to n do\n for j:=1 to 3 do\n for k:=i-8 to i do\n begin\n if k < 1 then continue;\n if (k < i) and (s[k]='0') then continue;\n v:=0;\n for q:=k to i do\n v:=v*10 + ord(s[q])-48;\n if v > 1000000 then continue;\n if f[k-1,j-1] + v > f[i,j] then\n f[i,j]:=f[k-1,j-1]+v;\n end;\n if f[n,3] < 0 then writeln(fo,-1)\n else writeln(fo,f[n,3]);\n close(fo);\nend;\nbegin\n enter;\n solve;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i,j,n,m,k,g,ans,z,x,y:integer;\n s:string;\n\nbegin\n readln(s);\n n:=length(s);\n ans:=-1;\n\n for i:=1 to n-2 do\n begin\n for j:=i+1 to n-1 do\n begin\n if (s[1]='0') then\n x:=0\n else if (i>8) then\n break\n else\n x:=strtoint(copy(s,1,i));\n if (s[1]='0') and (i>1) then\n break;\n if (s[i+1]='0') then\n y:=0\n else if (j-i>8) then\n break\n else\n y:=strtoint(copy(s,i+1,j-i));\n //writeln(i,' ',j,' ',j-i,' ',y);\n if (s[i+1]='0') and (j<>i+1) then\n break;\n if (s[j+1]='0') then\n z:=0\n else if (n-j>8) then\n continue\n else\n z:=strtoint(copy(s,j+1,n-j));\n if (s[j+1]='0') and (j+1<>n) then\n continue;\n if (x>1000000) or (y>1000000) or (z>1000000) then\n continue;\n if (x+y+z>ans) then\n ans:=x+y+z;\n end;\n end;\n\n write(ans);\n\n readln;\n readln;\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n s:string;\n i,j,n,c,k,q,g,w:longint;\n sum1,sum2,sum3:int64;\n sum:int64;\n mas:array[1..30] of longint;\n B,v,breakall:BOOLEAN;\nbegin\n readln(S);\n n:=length(s);\ni:=0;\nb:=true;\nsum1:=0;\nsum2:=0;\nsum3:=0;\nsum:=0;\nb:=false;\nbreakall:=false;\nif (length(s)<3) then writeln('-1') else begin\n repeat\n inc(i);\n c:=ord(s[i])-48;\n if not (s[i] in ['0'..'9'] )then break;\n if (i=2) and (sum1=0) then begin\n break;\n end;\n sum1:=sum1*10+c;\n if (sum1>1000000) then break;\n j:=i;\n sum2:=0;\n\n repeat\n inc(j);\n v:=false;\n q:=ord(s[j])-48;\n if not (s[j] in ['0'..'9']) then begin\n breakall:=true;\n break;\n end;\n if (j=i+2) and (sum2=0) then break;\n sum2:=sum2*10+q;\n if (sum2>1000000) then break;\n sum3:=0;\n for g:=j+1 to n do begin\n w:=ord(s[g])-48;\n if not (s[g] in['0'..'9']) then begin\n breakall:=true;\n break;\n end;\n if (g=j+2) and (sum3=0) then begin\n v:=true;\n break;\n end;\n sum3:=sum3*10+w;\n if (sum3>1000000) then begin\n v:=true;\n break;\n end;\n end;\n if (breakall) then break;\n if (v=false) then begin\n b:=true;\n if (sum1+sum2+sum3>sum) then sum:=sum1+sum2+sum3;\n end;\n\n until(j=n-1);\n if breakall then break;\n until(i=n-2);\nif (b=true) then writeln(sum) else writeln('-1');\nend;\nend.\n"}, {"source_code": "var\n a:array[1..100] of longint;\n n,i,j,k,t,s,max:longint;\n c:char;\nbegin\n n:=0;\n while not eoln do begin\n inc(n);\n read(c);\n a[n]:=ord(c)-ord('0');\n end;\n if n<3 then begin\n writeln(-1);\n halt;\n end;\n max:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do begin\n if i-2>7 then\n continue;\n if j-i>7 then\n continue;\n if n-j>7 then\n continue;\n s:=0;\n if (i>1) and (a[1]=0) then\n continue;\n if (j>i+1) and (a[i+1]=0) then\n continue;\n if (j1000000 then\n continue;\n s:=s+t;\n t:=0;\n for k:=i+1 to j do\n t:=t*10+a[k];\n if t>1000000 then\n continue;\n s:=s+t;\n t:=0;\n for k:=j+1 to n do\n t:=t*10+a[k];\n if t>1000000 then\n continue;\n s:=s+t;\n if s>max then\n max:=s;\n end;\n writeln(max);\nend."}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n{$define func:=function}\n{$define proc:=procedure}\n{$define be:=begin}\n{$define en:=end}\n{$define el:=else}\n{$define brk:=break}\n{$define th:=then}\n\nuses Classes, SysUtils, StrUtils, Math;\n\nvar\n s, ca, cb, cc: AnsiString;\n a, b, c: Long;\n L, sa, sb, sc: Int64;\n M: Int64;\n\nbegin\n Rln(s);\n L := Length(s);\n if l < 3 th\n be\n Wln(-1);\n exit;\n en;\n if s = '000' th\n be\n Wln(0);\n exit;\n en;\n {if s[1] = '0' th\n be\n Wln(-1);\n exit;\n en;}\n M := -1;\n for a := 1 to Min(7, L - 2) do\n be\n ca := Copy(s, 1, a);\n if ca <> '0' th\n if ca[1] = '0' th\n brk;\n sa := StrToInt(ca);\n if a = 7 th\n if sa > 1000000 th\n brk;\n for b := a + 1 to Min(a + 7, L - 1) do\n be\n cb := Copy(s, a + 1, b - (a + 1) + 1);\n if cb <> '0' th\n if cb[1] = '0' th\n brk;\n sb := StrToInt(cb);\n if Length(cb) = 7 th\n if sb > 1000000 th\n brk;\n //\n cc := Copy(s, b + 1, l);\n //W(a, ' ', b, ': ');\n //Wln(ca, ' ', cb, ' ', cc);\n if cc <> '0' th\n if cc[1] = '0' th\n continue;\n if Length(cc) > 7 th\n continue;\n sc := StrToInt(cc);\n if Length(cc) = 7 th\n if sc > 1000000 th\n continue;\n M := Max(M, sa + sb + sc);\n en;\n en;\n Wln(M);\nend."}, {"source_code": "program pa;\nvar\n\ts:string;\n\ta:array[0..101] of longint;\n\tn,i1,i2,i3,i,j,k,ans,t:longint;\n\nfunction max(x,y:longint):longint;\nbegin\n\tif x>y then exit(x) else exit(y);\nend;\n\nfunction check(x,y,z:longint):boolean;\nvar\n\tt:longint;\nbegin\n\tt:=1;\n\tif (a[t]=0)and(x<>1) then exit(false);\n\tif (x=7)and(copy(s,1,x)<>'1000000') then exit(false);\n\tt:=x+1;\n\tif (a[t]=0)and(y<>1) then exit(false);\n\tif (y=7)and(copy(s,x+1,y)<>'1000000') then exit(false);\n\tt:=x+y+1;\n\tif (a[t]=0)and(z<>1) then exit(false);\n\tif (z=7)and(copy(s,x+y+1,z)<>'1000000') then exit(false);\n\tcheck:=true;\nend;\n\nfunction work(x,y:longint):longint;\nvar\n\ti,t:longint;\nbegin\n\tt:=0;\n\tfor i:=x to y do t:=t*10+a[i];\n\texit(t);\nend;\n\nbegin\n\treadln(s);\n\tif length(s)>21 then begin writeln('-1');halt;end;\n\tfor i:=1 to length(s) do a[i]:=ord(s[i])-ord('0');\n\tans:=-1;\n\tfor i1:=1 to 7 do\n\t\tfor i2:=1 to 7 do\n\t\t\tfor i3:=1 to 7 do\n\t\t\t\tif (i1+i2+i3=length(s))and(check(i1,i2,i3)) then\n\t\t\t\t\tans:=max(ans,work(1,i1)+work(i1+1,i2+i1)+work(i1+i2+1,i3+i2+i1));\n\twriteln(ans);\nend.\n"}, {"source_code": "program Task1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar s,s1,s2,s3: string;\n i,j,k,sum,st: integer;\n\nfunction may(s: string): boolean;\nvar t: integer;\nbegin\n if (s[1]='0')then begin\n if (length(s)=1)then\n may:=true\n else\n may:=false;\n exit;\n end;\n if (length(s)>7)then begin\n may:=false;\n exit;\n end;\n t:=strtoint(s);\n if (t>1000000)then begin\n may:=false;\n exit;\n end;\n st:=st+t;\n may:=true;\nend;\n\nbegin\n read(s);\n sum:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,length(s)-j);\n st:=0;\n if (may(s1)and\n may(s2)and\n may(s3))then\n sum:=max(sum,st);\n end;\n write(sum);\nend.\n"}, {"source_code": "program prog;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar s, sa, sb, sc : string;\n i1, i2 : integer;\n ans, t : integer;\n\nfunction f (s :string) : boolean;\nvar n : integer;\nbegin\n result := false;\n if s = '0' then exit;\n result := (s[1] = '0') or ((length(s) > 7)) or (strtoint(s) > 1000000)\nend;\n\nbegin\n// reset (input, 'input.txt');\n// rewrite (output, 'output.txt');\n readln(s);\n ans := -1;\n for i1 := 2 to length(s)-1 do begin\n for i2 := i1+1 to length(s) do begin\n sa := copy(s, 1, i1-1);\n sb := copy(s, i1, i2-i1);\n sc := copy(s, i2, length(s)-i2+1);\n if f(sa) or f(sb) or f(sc) then continue;\n t := strtoint(sa) + strtoint(sb) + strtoint(sc);\n if t > ans then ans := t;\n end;\n end;\n write(ans);\n// close (input);\n// close (output);\nend.\n"}, {"source_code": "var\nA,b,i,a1,b1,c1,max:longint;\nS:string;\nProcedure chit;\nVar\nI:longint;\nBegin\nA1:=0;\nB1:=0;\nC1:=0;\nIf (a>1) and (s[1]='0') then \nBegin\nA1:=maxlongint;\nExit;\nEnd;\nFor i:=1 to a do\nA1:=a1*10+ord(s[i])-ord('0');\nIf (a+1b+1) and (s[b+1]='0') then \nBegin\nC1:=maxlongint;\nExit;\nEnd;\nFor i:=b+1 to length(s) do\nC1:=c1*10+ord(s[i])-ord('0');\nEnd;\nFunction check1(a:longint):boolean;\nBegin\nIf (a0) then exit(true);\nExit(false);\nEnd;\nBegin\nMax:=-1;\nReadln(s);\nFor i:=100 to 10000 do\nBegin\nA:=i div 100;\nB:=i mod 100;\nA1:=-1;\nB1:=-1;\nC1:=-1;\nIf (check1(a)) and (check1(b)) and (a'0')or(a=1) then\n if (s[i+1]<>'0')or(b=1) then\n if (s[j+1]<>'0')or(c=1) then\n begin\n val(copy(s,1,a),x,code);\n val(copy(s,i+1,b),y,code);\n val(copy(s,j+1,c),z,code);\n if (x<=maxn) and (y<=maxn) and (z<=maxn) then\n begin\n d:=x+y+z;\n if d>max then max:=d;\n end;\n end;\n end;\n if max=-1 then writeln(-1)\n else writeln(max);\nend.\n"}, {"source_code": "var i,j,n,x1,x2,x3,max:longint; s,s1,s2,s3:string; p:integer;\n begin\n readln (s);\n n:=length(s);\n max:=-1;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n if (s1='') or (s2='') or (s3='') then continue\n else begin\n if ((length(s1)>1) and (s1[1]='0')) or\n ((length(s2)>1) and (s2[1]='0')) or\n ((length(s3)>1) and (s3[1]='0')) then continue\n else\n begin\n if (length(s1)>7) or (length(s2)>7) or\n (length(s3)>7) then continue\n else begin\n val (s1,x1,p);\n val (s2,x2,p);\n val (s3,x3,p);\n if (x1<=1000000) and\n (x2<=1000000) and\n (x3<=1000000) and\n (x1+x2+x3>max) then max:=x1+x2+x3;\n end;\n end;\n end;\n end;\n writeln (max);\n end."}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,s1,s2,s3:string;\n i,j,max:longint;\n\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(s);\n close(input);\nend;\n\nprocedure tinh2;\nvar a,b,c,code,dk:longint;\nbegin\n s2:=copy(s,i+1,j); dk:=0;\n if (s2<>'1000000') and (length(s2)>=7) then exit;\n if (s2[1]='0') and (s2<>'0') then exit;\n if length(s)-i-j+dk>7 then exit\n else if length(s)-i-j+dk=7 then\n begin\n s3:=copy(s,i+j+1,7);\n if (s3<>'1000000') and (length(s3)>=7) then exit;\n end\n else s3:=copy(s,i+j-dk+1,length(s)-i-j+dk);\n if (s3[1]='0') and (s3<>'0') then exit;\n val(s1,a,code); val(s2,b,code); val(s3,c,code);\n if a+b+c> max then max:=a+b+c;\nend;\n\nprocedure tinh;\nbegin\n s1:=copy(s,1,i);\n if (i=7) and (s1<>'1000000') then exit;\n if (s1[1]='0') and (s1<>'0') then exit;\n for j:=1 to length(s)-i-1 do\n begin\n if j>7 then exit;\n tinh2;\n end;\nend;\n\n\nprocedure xuly;\nbegin\n for i:=1 to length(s)-2 do\n begin\n if i>7 then exit;\n tinh;\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n if max<0 then write(-1) else write(max);\n close(output);\nend;\n\nbegin\n doc;\n max:=-MaxLongint;\n xuly;\n ghi;\nend."}, {"source_code": "Var sum,xx,yy,zz:int64;\n g,i,j:longint;\n s,x,y,z:string;\nBegin\n Readln(s);\n sum:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n x:=copy(s,1,i);\n y:=copy(s,i+1,j-i);\n z:=copy(s,j+1,length(s)-j);\n if((x[1]='0')and(length(x)<>1))\n or((y[1]='0')and(length(y)<>1))\n or((z[1]='0')and(length(z)<>1))\n or(length(x)>7)\n or(length(y)>7)\n or(length(z)>7)\n then continue;\n val(x,xx,g);\n val(y,yy,g);\n val(z,zz,g);\n if(xx+yy+zz>sum)\n and(xx<=1000000)\n and(yy<=1000000)\n and(zz<=1000000)\n then sum:=xx+yy+zz;\n end;\n writeln(sum);\nEnd."}, {"source_code": "var\n i,j,l,x,ans:longint;\n s:string;\n\nfunction calca(l:longint; r:longint):longint;\nvar\n i,p:longint;\nbegin\n if (r>l)and(ord(s[l])=48) then exit(-100000000);\n p:=0;\n for i:=l to r do\n begin\n p:=p*10+ord(s[i])-48;\n if p>1000000 then exit(-100000000);\n end;\n exit(p);\nend;\n\nbegin\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n for j:=i+1 to l-1 do\n begin\n x:=calca(1,i)+calca(i+1,j)+calca(j+1,l);\n if x>ans then ans:=x;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program problem1;\nuses math;\n\nvar arr: array[1..21] of byte;\n\nfunction numb( l, r: longWord ): longInt;\nvar i, a, res: longWord;\nbegin\n a := 1;\n res := 0;\n for i := r downTo l do\n begin\n res := res + ( arr[i] * a );\n a := a * 10;\n end;\n\n if ( res > 1000000 ) or ( ( arr[l] = 0 ) and ( r > l ) ) then\n numb := -1\n else\n numb := res;\nend;\n\nvar chr: string[1];\n dp: array[ 1..21, 1..3 ] of longInt;\n i, j, k, cnt: longWord;\n m, c: longInt;\n\nbegin\n cnt := 0;\n\n read( chr ); while ( chr <> '' ) do\n while ( chr <> '' ) do\n begin\n inc( cnt );\n if ( cnt > 21 ) then\n begin\n writeln( '-1' );\n halt;\n end;\n\n arr[cnt] := ord( chr[1] ) - ord( '0' );\n\n read( chr );\n end;\n\n if ( cnt < 3 ) then\n begin\n writeln( '-1' );\n halt;\n end;\n\n for i := 1 to min( 7, (cnt-2) ) do\n dp[i][1] := numb( 1, i );\n\n for i := 2 to 3 do\n begin\n for j := i to min( (7*i), (cnt-3+i) ) do\n begin\n m := -1;\n for k := max( (i-1), (j-7) ) to min( 7*(i-1), (j-1) ) do\n begin\n c := numb( (k+1), j );\n if ( c > -1 ) and ( dp[k][i-1] > -1 ) and ( ( c + dp[k][i-1] ) > m ) then\n m := c + dp[k][i-1];\n end;\n dp[j][i] := m;\n end;\n end;\n\n writeln( dp[cnt][3] );\nend."}, {"source_code": "program main;\ntype\n integer=longint;\nvar\n s:string;\n max:integer;\n procedure Input;\n begin\n readln(s);\n end;\n procedure Solve;\n var\n i,j,l:integer;\n s1,s2,s3,ss1,ss2,ss3:string;\n t1,t2,t3:integer;\n code:integer;\n begin\n max:=-1;\n l:=length(s);\n for i:=1 to l-2 do\n for j:=1 to l-i-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,i+j+1,l-i-j);\n if (length(s1)>8)or(length(s2)>8)\n or(length(s3)>8) then continue;\n val(s1,t1,code);\n val(s2,t2,code);\n val(s3,t3,code);\n if (t1>1000000)or(t2>1000000)or(t3>1000000) then\n continue;\n str(t1,ss1);\n if ss1<>s1 then continue;\n str(t2,ss2);\n if ss2<>s2 then continue;\n str(t3,ss3);\n if ss3<>s3 then continue;\n if t1+t2+t3>max then max:=t1+t2+t3;\n end;\n end;\n procedure Output;\n begin\n writeln(max);\n end;\nbegin\n Input;\n Solve;\n Output;\nend."}, {"source_code": "var s,a,b,c:string;\n res,x,y,z,i,j:longint;\n p:integer;\n\n begin\n readln(s);\n res:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n a:=copy(s,1,i);\n b:=copy(s,i+1,j-i);\n c:=copy(s,j+1,length(s)-j);\n if length(a)>7 then continue;\n if length(b)>7 then continue;\n if length(c)>7 then continue;\n if (a[1] = '0')and(length(a)>1) then continue;\n if (b[1] = '0')and(length(b)>1) then continue;\n if (c[1] = '0')and(length(c)>1) then continue;\n\n val(a,x,p);\n val(b,y,p);\n val(c,z,p);\n if x>1000000 then continue;\n if y>1000000 then continue;\n if z>1000000 then continue;\n\n if (x+y+z>res) then res:=x+y+z;\n end;\n writeln(res);\n\n end."}, {"source_code": "var\n f :boolean;\n s,y,h,e :string;\n ans,x,r,z : int64;\n i,d,j,g,uu : longint;\n code :integer;\nbegin\n readln(S);\n ans:=-1;\n d:=lengtH(s);\n i:=1;\n while (i<=d-1) do\n begin\n j:=i+1;\n while (j<= d) do\n begin\n y:='';\n f:=true;\n for uu:=1 to i do y:=y+s[uu];\n if ((y[1]='0') and (lengtH(y)>1)) or (length(y)>=8) or (length(y)=0)then f:=false;\n e:='';\n for uu:=i+1 to j do e:=e+s[uu];\n if ((e[1]='0') and (lengtH(e)>1)) or (lengtH(e)>=8) or (length(e)=0)then f:=false;\n h:='';\n for uu:=j+1 to lengtH(s) do h:=h+s[uu];\n if ((h[1]='0') and (lengtH(h)>1)) or (length(h)>=8) or (length(h)=0)then f:=false;\n val(y,x,code);\n val(e,r,code);\n val(h,z,code);\n if x>1000000 then f:=false;\n if r>1000000 then f:=false;\n if z>1000000 then f:=false;\n if (f) and (x+r+z>ans) then ans:=x+r+z;\n inc(j);\n end;\n inc(I);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const fi='';\n fo='';\n MaxQ=1000000;\nvar i,j,k,res,a,b,c,d:longint;\n s1,s2,s3,s:string;\nfunction check(s1:string):boolean;\nbegin\n if ((s1[1] = '0') and (length(s1) > 1)) or (length(s1) >7) then exit(false);\n exit(true);\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n read(s);\n res:=-1;\n d:=length(s);\n for i:=1 to d-2 do\n begin\n for j:=i+1 to d-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,d-j);\n if (not check(s1)) or (not check(s2)) or (not check(s3)) then continue;\n val(s1,a);\n val(s2,b);\n val(s3,c);\n if (a > MaxQ) or (b > MaxQ) or (c>MaxQ) then continue;\n k:=a+b+c;\n if k > res then res:=k;\n end;\n end;\n write(res);\nend.\n"}, {"source_code": "var\n st,st1,st2,st3:string;\n i,j,max1,len,shu1,shu2,shu3,sum:longint;\nbegin\n readln(st);\n len:=length(st);\n max1:=-1;\n if length(st)<=21 then\n for i:=2 to len-1 do\n for j:=i+1 to len do\n begin\n st1:=copy(st,1,i-1);\n st2:=copy(st,i,j-i);\n st3:=copy(st,j,len-j+1);\n if length(st1)>7 then continue;\n if length(st2)>7 then continue;\n if length(st3)>7 then continue;\n if(length(st1)>1)and(st1[1]='0')then continue;\n if(length(st2)>1)and(st2[1]='0')then continue;\n if(length(st3)>1)and(st3[1]='0')then continue;\n val(st1,shu1);\n val(st2,shu2);\n val(st3,shu3);\n if(shu1>1000000)or(shu2>1000000)or(shu3>1000000)then\n continue;\n sum:=shu1+shu2+shu3;\n if sum>max1 then max1:=sum;\n end;\n writeln(max1);\n readln;\nend."}, {"source_code": "Uses sysutils;\nVar N,i,j,k,l,m,t,r,i1,j1,k1,t1,t2,t3,t4,t5,t6,r1,r2,r3:longint;\nd:char;\ns,s1,s2,s3:string;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(Output);}\nReadln(s);\nN:=length(s);\nt:=-1;\nFor i:=1 to 7 do begin\n For j:=i+1 to i+7 do begin\n For k:=j+1 to j+7 do begin\n if k=N then begin\n s1:='';\n s2:='';\n s3:='';\n For i1:=1 to i do\n s1:=s1+s[i1];\n For j1:=i+1 to j do\n s2:=s2+s[j1];\n For k1:=j+1 to k do\n s3:=s3+s[k1];\n t1:=strtoint(s1);\n t2:=strtoint(s2);\n t3:=strtoint(s3);\n t4:=t1;\n t5:=t2;\n t6:=t3;\n r1:=0;\n r2:=0;\n r3:=0;\n while t4>0 do begin\n inc(r1);\n t4:=t4 div 10;\n end;\n while t5>0 do begin\n inc(r2);\n t5:=t5 div 10;\n end;\n while t6>0 do begin\n inc(r3);\n t6:=t6 div 10;\n end;\n if r1=0 then\n inc(r1);\n if r2=0 then\n inc(r2);\n if r3=0 then\n inc(r3);\n if r1=i then begin\n if r2=j-i then begin\n if r3=k-j then begin\n if (t1<=1000000) and (t2<=1000000) and\n (t3<=1000000) then begin\n if t'0')) or ((l1<>0) and (s1[1]='0')) or (l1>1000000) then continue;\n if ((l2=0) and (s2<>'0')) or ((l2<>0) and (s2[1]='0')) or (l2>1000000) then continue;\n if ((l3=0) and (s3<>'0')) or ((l3<>0) and (s3[1]='0')) or (l3>1000000) then continue;\n if (ans1)and(s1[1]='0') then exit;\nif (length(s2)>1)and(s2[1]='0') then exit;\nif (length(s3)>1)and(s3[1]='0') then exit;\nif (length(s1)>7) then exit;\nif (length(s2)>7) then exit;\nif (length(s3)>7) then exit;\nif (length(s1)=7)and(s1<>'1000000') then exit;\nif (length(s2)=7)and(s2<>'1000000') then exit;\nif (length(s3)=7)and(s3<>'1000000') then exit;\n\na:=0; for q:=1 to length(s1) do a:=a*10+byte(s1[q])-48;\nb:=0; for q:=1 to length(s2) do b:=b*10+byte(s2[q])-48;\nc:=0; for q:=1 to length(s3) do c:=c*10+byte(s3[q])-48;\n\nif a+b+c>max then max:=a+b+c;\nend;\n\n\nBegin\n\nReadln(s); max:=-1; a:=-1; b:=-1; c:=-1;\n\nfor i:=2 to length(s)-1 do\n for j:=i+1 to length(s) do if (i<=length(s))and(j<=length(s)) then check(i,j);\n\n WritelN(max);\n\n End.\n\n"}, {"source_code": "var st,st1,st2,st3:string;\n i,j,max,l,score,p1,p2,p3:longint;\nbegin\n readln(st);\n l:=length(st);\n max:=-1;\n for i:=1 to l-2 do\n for j:=i+1 to l-1 do\n begin\n st1:=copy(st,1,i);\n st2:=copy(st,i+1,j-i);\n st3:=copy(st,j+1,255);\n if(length(st1)>7)or(length(st2)>7)or(length(st3)>7)then continue;\n if(length(st1)>1)and(st1[1]='0')then continue;\n if(length(st2)>1)and(st2[1]='0')then continue;\n if(length(st3)>1)and(st3[1]='0')then continue;\n val(st1,p1);val(st2,p2);val(st3,p3);\n if(p1>1000000)or(p2>1000000)or(p3>1000000) then continue;\n score:=p1+p2+p3;\n if score>max then max:=score;\n end;\n writeln(max);\nend."}, {"source_code": "var s,s1,s2,s3:string;\n i,j,k:longint;\n data1,data2,data3:int64;\n error,max:longint;\n\nfunction check(s:string):boolean;\nbegin\n if (length(s)>=2) and (S[1]='0') then\n check:=false else check:=true;\nend;\n\n\nbegin\n readln(S);\n max:=-1;\n for i:= 1 to length(s) do\n for j:= i+1 to length(s)-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,length(s)-j);\n if length(s1)>7 then continue;\n if length(s2)>7 then continue;\n if length(s3)>7 then continue;\n if check(s1)=false then continue;\n if check(S2)=false then continue;\n if check(s3)=false then continue;\n val(s1,data1,error);\n val(s2,data2,error);\n val(S3,data3,error);\n if data1>1000000 then continue;\n if data2>1000000 then continue;\n if data3>1000000 then continue;\n if data1+Data2+data3>max then max:=data1+Data2+data3;\n end;\n writeln(max);\nend.\n"}, {"source_code": "program va;\nvar t:string;\n i,j,k:longint;\n t1,t2,t3,max,min:int64;\n s1,s2,s3:string;\nfunction pd(a,b,c:string):boolean;\nvar t:longint;\nbegin\npd:=true;\nif (a[1]='0') and (length(a)>1) then exit(false);\nif (b[1]='0') and (length(b)>1) then exit(false);\nif (c[1]='0') and (length(c)>1) then exit(false);\nend;\nprocedure sp;\nbegin\n write('-1');\n halt;\nend;\nbegin\n read(t);\n max:=-1;\n if length(t)>21 then sp;\n for i:=1 to length(t) do\n for j:=1 to length(t) do\n for k:=1 to length(t) do\n if (j>i) and (k>j) then\n begin\n\n s1:=copy(t,1,(j-1));\n s2:=copy(t,j,(k-j));\n s3:=copy(t,k,length(t));\n if pd(s1,s2,s3)=false then continue;\n if length(s3)>7 then continue;\n if length(s2)>7 then continue;\n if length(s1)>7 then continue;\n val(s1,t1); val(s2,t2); val(s3,t3);\n if t1>1000000 then continue;\n if t2>1000000 then continue;\n if t3>1000000 then continue;\n if max<(t1+t2+t3) then max:=t1+t2+t3;\n end;\n write(max);\nend.\n"}, {"source_code": "uses math;\nvar\n a:array[0..300] of longint;\n\n f,next,head,nom,zz,d:array[0..222222] of longint;\n\n ff:array[1..33333] of boolean;\n x,y,j,z,v,i,n,n1,n2,ans,k,p,m:longint;\n\n\n s,s1:ansistring;\n c1,c2:char;\n\nfunction pr(a,b:longint):longint;\nbegin\n if b-a>7 then exit(-10000000);\n if (b-a>0)and(s[a]='0') then exit(-10000000);\n x:=0;\n for y:=a to b do\n x:=x*10+ord(s[y])-48;\n if x>1000000 then exit(-10000000) else exit(x);\n\nend;\n\nbegin\n//assign(input,'input.txt');reset(input);\n readln(s);\n n:=length(s);\n m:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n\n begin\n p:=pr(1,i)+pr(i+1,j)+pr(j+1,n);\n if p>m then m:=p;\n\n end;\n\n\n write(m);\nend.\n"}, {"source_code": "var n,i,j:longint;\nq,s:string;\nmax,ss,x:longint;\ncode:integer;\n begin\n readln(s);\n n:=length(s);\n max:=-1;\n\n for i:=1 to n do\n if i<=7 then\n for j:=i+1 to n-1 do\n if j-i<=7 then\n if n-j<=7 then\n begin\n ss:=0;\n q:=copy(s,1,i);\n if (q[1]='0')and(length(q)>1) then continue;\n\n val(q,x,code);\n if x>1000000 then continue;\n\n ss:=ss+x;\n\n q:=copy(s,i+1,j-i);\n if (q[1]='0')and(length(q)>1) then continue;\n\n val(q,x,code);\n if x>1000000 then continue;\n\n ss:=ss+x;\n\n q:=copy(s,j+1,n-j);\n if (q[1]='0')and(length(q)>1) then continue;\n\n val(q,x,code);\n if x>1000000 then continue;\n\n ss:=ss+x;\n\n if ss>max then max:=ss;\n end;\n\n writeln(max);\n\n end."}, {"source_code": "Program PA;\n const maxn=36;\n maxd=1000000;\n\n var s:string;\n sa,sb,sc:string;\n sum,code,a,b,c,l:longint;\n\n procedure main;\n var i,j:longint;\n begin\n readln(s);\n l:=length(s);\n sum:=-1;\n for i:=1 to l-2 do\n for j:=i+1 to l-1 do\n begin\n sa:=copy(s,1,i);\n sb:=copy(s,i+1,j-i);\n sc:=copy(s,j+1,l-j);\n if length(sa)>8 then continue;\n if length(sb)>8 then continue;\n if length(sc)>8 then continue;\n val(sa,a,code);\n val(sb,b,code);\n val(sc,c,code);\n if (sa[1]='0')and(length(sa)>1) then continue;\n if (sb[1]='0')and(length(sb)>1) then continue;\n if (sc[1]='0')and(length(sc)>1) then continue;\n if a>maxd then continue;\n if b>maxd then continue;\n if c>maxd then continue;\n if sum1))\n or ((s[i+1]='0')and(j-i<>1))\n or ((s[j+1]='0')and(n-j<>1)) then continue;\n val(copy(s,1,i),w1);\n val(copy(s,i+1,j-i),w2);\n val(copy(s,j+1,n),w3);\n if (w1>e)or(w2>e)or(w3>e) then continue;\n if w1+w2+w3>res then res:=w1+w2+w3;\n end;\n end;\n writeln(res);\nend.\n\n"}, {"source_code": "const fin='';\n fout='';\nvar n,max:longint;\n st:string;\n f,g:text;\nfunction tong(x,y:integer):integer;\nvar i,j,code:integer;\n so:longint;\n s1:string;\nbegin\n tong:=1; s1:='';\n if (y-x+1<=7) and ((st[x]<>'0') or (y-x+1=1)) then\n begin\n for i:=x to y do s1:=s1+st[i];\n val(s1,so,code);\n if so>1000000 then tong:=0\n else n:=n+so;\n end\n else tong:=0;\nend;\nprocedure xuli;\nvar i,j,lc,p:integer;\nbegin\n read(f,st); p:=0; \n max:=0; lc:=0;\n for i:=1 to length(st)-2 do\n for j:=i+1 to length(st)-1 do\n begin\n n:=0;\n if (tong(1,i)<>1) then break\n else\n if (tong(i+1,j)=1) and (tong(j+1,length(st))=1) then\n if n>=max then\n begin\n max:=n;\n lc:=1;\n end;\n end; \n if lc=1 then\n write(g,max)\n else write(g,-1);\nend;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n xuli;\n close(g);\nend."}, {"source_code": "program sdhkjf;\nvar a:array[1..100000] of longint;\ni,j,n,i1,i2,max:longint;\ns,s1,s3,s2:string;\nc:char;\nfunction func(r:string):boolean;\nbegin\n if r='1000000' then func:=true else\n if ((length(r)>1) and (r[1]='0')) or (length(r)>6) then func:=false else\n func:=true;\nend;\nprocedure proc(r1,r2,r3:string);\nvar t1,t2,t3:longint;\ny:integer;\nbegin\nval(r1,t1,y);\nval(r2,t2,y);\nval(r3,t3,y);\nif t1+t2+t3>max then max:=t1+t2+t3;\nend;\nbegin\nread(s);max:=-1;\nn:=length(s);\nif (n>21) or (n<3) then begin writeln(-1); exit; end;\nfor i:=1 to n-2 do\n for j:=1 to n-i-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,j+i+1,n-i-j);\n if (i<8) and (j<8) and (n-i-j<8) then if (func(s1)) and (func(s2)) and (func(s3)) then proc(s1,s2,s3);\n end;\nwriteln(max);\nend.\n"}, {"source_code": "uses math;\n\nvar\n\ts, a, b, c : string;\n\tatb, i, j, t, sum, k : longint;\n\tbool : boolean;\n\t\nbegin\n\tatb := -1;\n\treadln(s);\n\tfor i := 1 to length(s) - 2 do for j := i + 1 to length(s) - 1 do begin\n\t\tbool := true;\n\t\ta := copy(s, 1, i);\n\t\tb := copy(s, i + 1, j - i);\n\t\tc := copy(s, j + 1, length(s) - j);\n\t\tif (length(a) > 7) or (length(b) > 7) or (length(c) > 7) then bool := false;\n\t\tif (a[1] = '0') and (length(a) > 1) then bool := false;\n\t\tif (b[1] = '0') and (length(b) > 1) then bool := false;\n\t\tif (c[1] = '0') and (length(c) > 1) then bool := false;\n\t\tif (length(a) = 7) and (a <> '1000000') then bool := false;\n\t\tif (length(b) = 7) and (b <> '1000000') then bool := false;\n\t\tif (length(c) = 7) and (c <> '1000000') then bool := false;\n\t\t\n\t\tif bool then begin\n\t\t\tval(a, sum, k);\n\t\t\tval(b, t, k); inc(sum, t);\n\t\t\tval(c, t, k); inc(sum, t);\n\t\t\t\n\t\t\tatb := max(atb, sum);\n\t\t\n\t\tend;\n\t\n\tend;\n\t\n\twriteln(atb);\n\nend."}, {"source_code": "uses sysutils;\nvar s:string;\n max:longint;\n a:array [1..3] of longint;\nprocedure rec(k,l:longint);\nvar i:longint;\nbegin\n if (k=4) then\n begin\n if l=length(s) then if a[1]+a[2]+a[3]>max then max:=a[1]+a[2]+a[3];\n end\n else\n begin\n a[k]:=0;\n for i:=l+1 to length(s) do\n begin\n a[k]:=a[k]*10+strtoint(s[i]);\n if a[k]>1000000 then break;\n rec(k+1,i);\n if a[k]=0 then break;\n end;\n end;\nend;\nbegin\n readln(s);\n max:=-1;\n rec(1,0);\n writeln(max);\nend."}, {"source_code": "var\n s,p1,p2,p3: string;\n n,i,j,k: longint;\n x,y,z,ans: int64;\n \nbegin\n readln(s);\n ans := -1;\n n := length(s);\n p1 := '';\n for i := 1 to 7 do\n begin\n\t if i > n-2 then break;\n\t p1 := p1 + s[i];\n\t p2 := '';\n\t if (length(p1)>1) and (p1[1]='0') then break;\n\t for j := i+1 to i+7 do\n\t begin\n\t\t if j > n-1 then break;\n\t\t p2 := p2 + s[j];\n\t\t p3 := '';\n\t\t if n-j > 7 then continue;\n\t\t for k := j+1 to n do \n\t\t p3 := p3 + s[k];\n\t\t if (length(p2)>1) and (p2[1]='0') then break;\n\t\t if (length(p3)>1) and (p3[1]='0') then continue;\n\t\t val(p1,x); val(p2,y); val(p3,z);\n\t\t if (x>1000000) or (y>1000000) or (z>1000000) then continue;\n\t\t if x+y+z > ans then ans := x + y + z;\n\t\tend;\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,s1,s2,s3:string;\n i,j,max:longint;\n\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(s);\n close(input);\nend;\n\nprocedure tinh2;\nvar a,b,c,code,dk:longint;\nbegin\n s2:=copy(s,i+1,j); dk:=0;\n if (s2<>'1000000') and (length(s2)>=7) then exit;\n if (s2[1]='0') and (s2<>'0') then exit;\n if length(s)-i-j+dk>7 then exit\n else if length(s)-i-j+dk=7 then\n begin\n s3:=copy(s,i+j+1,7);\n if (s3<>'1000000') and (length(s3)>=7) then exit;\n end\n else s3:=copy(s,i+j-dk+1,length(s)-i-j+dk);\n if (s3[1]='0') and (s3<>'0') then exit;\n val(s1,a,code); val(s2,b,code); val(s3,c,code);\n if a+b+c> max then max:=a+b+c;\nend;\n\nprocedure tinh;\nbegin\n s1:=copy(s,1,i);\n if (i=7) and (s1<>'1000000') then exit;\n if (s1[1]='0') and (s1<>'0') then exit;\n for j:=1 to length(s)-i-1 do\n begin\n if j>7 then exit;\n tinh2;\n end;\nend;\n\n\nprocedure xuly;\nbegin\n for i:=1 to length(s)-2 do\n begin\n if i>7 then exit;\n tinh;\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n if max<0 then write(-1) else write(max);\n close(output);\nend;\n\nbegin\n doc;\n max:=-MaxLongint;\n xuly;\n ghi;\nend.\n"}, {"source_code": "uses sysutils;\nvar s, x, y, z: string;\n i, j, l: byte;\n t, m, a, b, c: longint;\nbegin\n readln(s);\n l := length(s);\n if l < 3 then\n begin\n writeln(-1);\n exit;\n end;\n m := -1;\n for i := 2 to l - 1 do\n for j := i + 1 to l do\n begin\n if (i > 8) or (j - i > 7) or (l - j > 6) then\n continue;\n x := copy(s, 1, i - 1);\n y := copy(s, i, j - i);\n z := copy(s, j, l - j + 1);\n a := strtoint(x);\n b := strtoint(y);\n c := strtoint(z);\n if (a > 1000000) or (b > 1000000) or (c > 1000000) then\n continue;\n if ((x[1] = '0') and (i > 2)) or ((y[1] = '0') and (j > i + 1)) or ((z[1] = '0') and (l > j)) then\n continue;\n t := a + b + c;\n if t > m then\n m := t;\n end;\n writeln(m);\nend.\n"}, {"source_code": "var\n j,i,ans,x,y,z:longint;\n p,s:ansistring;\n\nbegin\n readln(s);\n ans:=-1;\n for i:=1 to length(s)-2 do \n for j:=i+1 to length(s)-1 do begin\n if (i>7)then continue;\n if (j-i>7)then continue;\n if (length(s)-j>7)then continue;\n if (s[1]='0')and(i>1)then continue;\n if (s[i+1]='0')and(j>i+1)then continue;\n if (s[j+1]='0')and(j+11000000)then continue;\n if (y>1000000)then continue;\n if (z>1000000)then continue;\n if (x+y+z>ans)then ans:=x+y+z;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var s, a,b,c: String;\n i,j,n, x,y,z, ans, code: LongInt;\nbegin\n Readln(s);\n ans:=-1;\n n:=Length(s);\n \n if (n>21) or (n<3) then begin Writeln(-1); halt(0); end;\n \n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n a:=Copy(s,1,i);\n b:=Copy(s,i+1,j-i);\n c:=Copy(s,j+1,n-j);\n \n val(a,x,code);\n val(b,y,code);\n val(c,z,code);\n \n if (x>1000000) or (y>1000000) or (z>1000000) then continue;\n if (a[1]='0') and (Length(a)>1) or (b[1]='0') and (Length(b)>1) or (c[1]='0') and (Length(c)>1) then continue;\n \n if x+y+z>ans then ans:=x+y+z;\n end;\n \n Writeln(ans);\nend."}, {"source_code": "program Prog;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\nuses sysutils;\nvar\nst,a,s,d:string;\nn,sum,max:longint;\ni,j,k:integer;\n\nbegin\nreadln(st);\nn:=length(st);\nmax:=-1;\nif n>2 then\nfor i := 1 to n-2 do\n for j := i+1 to n-1 do\n begin\n a:=copy(st,1,i);\n s:=copy(st,i+1,j-i);\n d:=copy(st,j+1,n-j);\n if (length(a)<8)and(length(s)<8)and(length(d)<8) then\n if (length(inttostr(strtoint(a)))=length(a))and(length(inttostr(strtoint(s)))=length(s))and(length(inttostr(strtoint(d)))=length(d)) then begin\n sum:=strtoint(a)+strtoint(s)+strtoint(d);\n if (sum>max)and(strtoint(a)<=1000000)and(strtoint(s)<=1000000)and(strtoint(d)<=1000000) then max:=sum;\n end;\n end;\nwriteln(max);\nreadln;\nend.\n"}, {"source_code": "Var s,s1,s2,s3:String;\n i,j,k,max,p,x1,x2,x3,k1,k2,k3,i1:LongInt;\n begin\n ReadLn(s);\n max:=-maxLongInt;\n For i:=1 to 7 do\n begin\n For j:=1 to 7 do\n begin\n For k:=1 to 7 do\n begin\n if i+j+k=Length(s) then\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,i+j+1,k);\n k1:=0;\n k2:=0;\n k3:=0;\n For i1:=1 to LEngth(s1) do\n begin\n\n if (s1[i1]='0') then k1:=k1+1;\n end;\n For i1:=1 to LEngth(s2) do\n begin\n if (s2[i1]='0') then k2:=k2+1;\n end;\n For i1:=1 to LEngth(s3) do\n begin\n if (s3[i1]='0') then k3:=k3+1;\n end;\n if ((s1[1]<>'0') or ((k1=Length(s1)) and (i=1))) and\n ((s2[1]<>'0') or ((k2=Length(s2)) and (j=1))) and ((s3[1]<>'0') or ((k3=Length(s3)) and (k=1))) then\n begin\n Val(copy(s,1,i),x1,p);\n Val(copy(s,i+1,j),x2,p);\n Val(copy(s,i+j+1,k),x3,p);\n if (x1<=1000000) and (x2<=1000000) and (x3<=1000000) then\n begin\n if x1+x2+x3>max then max:=x1+x2+x3;\n end;\n end\n end;\n end;\n end;\n end;\n if max=-maxLongInt then WriteLn(-1)\n else WriteLn(max);\n end."}, {"source_code": "(*\nProblem\t\t:\tCodeforces_175A\nAuthor\t\t:\tShuriken\nStart Time\t:\t2012-5-31 07:39\nFinish Time\t:\t\nResult\t\t:\t\nMethod\t\t:\tBrute Force\nErrors\t\t:\t\n*)\nProgram CF_175A;\nUses Math;\nConst\n\tmaxn\t\t\t\t\t\t=30+5;\nVar\n\ts,s1,s2,s3\t\t\t\t\t:string[maxn];\n\tans\t\t\t\t\t\t\t:longint;\n\t\nProcedure Init;\nBegin\n\treadln(s);\nEnd;\n\nFunction Calc:longint;\nVar a,b,c\t\t\t\t\t\t:longint;\nBegin\n\tif (length(s1)=0)or(length(s2)=0)or(length(s3)=0) then exit(-1);\n\tif (length(s1)>7)or(length(s2)>7)or(length(s3)>7) then exit(-1);\n\tif (length(s1)=7)and(s1<>'1000000') then exit(-1);\n\tif (length(s2)=7)and(s2<>'1000000') then exit(-1);\n\tif (length(s3)=7)and(s3<>'1000000') then exit(-1);\n\tif (length(s1)>1)and(s1[1]='0') then exit(-1);\n\tif (length(s2)>1)and(s2[1]='0') then exit(-1);\n\tif (length(s3)>1)and(s3[1]='0') then exit(-1);\n\n\t\n\tval(s1,a);\n\tval(s2,b);\n\tval(s3,c);\n\texit(a+b+c);\nEnd;\n\t\nProcedure Main;\nVar i,j\t\t\t\t\t\t\t:longint;\nBegin\n\tans:=-1;\n\t\n\tif length(s)>21 then exit;\n\t\n\tfor i:=1 to 7 do\n\t\tbegin\n\t\t\tif length(s)-i<2 then break;\n\t\t\ts1:=s1+s[i];\n\t\t\ts2:='';\n\t\t\tfor j:=i+1 to i+7 do\n\t\t\t\tbegin\n\t\t\t\t\tif length(s)-j<1 then break;\n\t\t\t\t\ts2:=s2+s[j];\n\t\t\t\t\ts3:=copy(s,j+1,length(s)-j);\n\t\t\t\t\tans:=max(ans,calc);\n\t\t\t\tend;\n\t\tend;\nEnd;\n\t\nProcedure Print;\nBegin\n\twriteln(ans);\nEnd;\n\t\nBegin\n\tInit;\n\tMain;\n\tPrint;\nEnd.\n"}, {"source_code": "var\n s,r1,r2,r3: string;\n er,n,a1,a2,rv1,rv2,rv3,sum,maxs: longint;\n\n function check(s1: string): boolean;\n var\n m: longint;\n begin\n m:=length(s1);\n if (m <= 0) or (m >= 8) or ((m = 7) and (s1 <> '1000000')) or ((m > 1) and (s1[1] = '0')) then exit(false);\n check:=true;\n end;\n\n begin\n read(s);\n n:=length(s);\n maxs:=-1;\n a2:=1;a1:=1;\n while a1 < 8 do\n begin\n while a2 < 8 do\n begin\n r1:=copy(s,1,a1);\n r2:=copy(s,a1+1,a2);\n r3:=copy(s,a1+a2+1,n-a1-a2);\n if not check(r1) then begin inc(a2);continue; end;\n if not check(r2) then begin inc(a2);continue; end;\n if not check(r3) then begin inc(a2);continue; end;\n val(r1,rv1,er);\n val(r2,rv2,er);\n val(r3,rv3,er);\n sum:=rv1+rv2+rv3;\n if sum > maxs then maxs:=sum;\n inc(a2);\n end;\n a1:=a1+1;a2:=1;\n end;\n write(maxs);\n end."}, {"source_code": "var n,i,j,a,b,c,l,k,max:longint;\n s,s1,s2,s3:string[35];\n p:integer;\nbegin\n readln(s);\n n:=length(s);\n if (n=3) and (s[1]='0') and (s[2]='0') and (s[3]='0') then\n begin\n writeln(0);\n exit;\n end;\n for j:=1 to n-2 do\n begin\n s1:=copy(s,1,j);\n for i:=1 to n-j-1 do\n begin\n s2:=copy(s,j+1,i);\n s3:=copy(s,j+i+1,n-i-j+1);\n if (length(s1)<8) and (length(s2)<8) and (length(s3)<8) then\n begin\n if ((s1[1]<>'0') or (length(s1)=1)) and\n ((s2[1]<>'0') or (length(s2)=1)) and\n ((s3[1]<>'0') or (length(s3)=1)) then\n begin\n val(s1,a,p);\n val(s2,b,p);\n val(s3,c,p);\n if (a<=1000000) and (b<=1000000) and (c<=1000000) then k:=a+b+c;\n if k>max then max:=k;\n end;\n end;\n end;\n end;\n if max=0 then write(-1)\n else write(max);\nend.\n"}, {"source_code": "var ss,s:string; a,b,c,k:extended;\n i,j:byte;\nbegin\nreadln(s);\nk:=-1;\nfor i:=1 to length(s) do\n for j:=i+2 to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(a>1000000) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(b>1000000) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(c>1000000) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k:0:0);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\ns:string;\n\nfunction min(x,y:longint):longint;\nbegin if x0 do begin inc(gl); x:=x div 10; end; \nend;\n\nprocedure lemon();\nvar max,i,j,sc1,sc2,sc3,ccc,len:longint;\nbegin readln(s); len:=length(s);\n\tif length(s)>21 then begin writeln(-1); exit; end;\n\tmax:=-1;\n\tfor i:=1 to min(len,7) do\n\tbegin val(copy(s,1,i),sc1,ccc);\n\t\tif (0<=sc1)and(sc1<=1000000)and(gl(sc1)=i) then\n\t\t\tfor j:=i+1 to min(len,i+7) do\n\t\t\tbegin val(copy(s,i+1,j-i),sc2,ccc);\n\t\t\t\tif (0<=sc2)and(sc2<=1000000)and(gl(sc2)=j-i) then\n\t\t\t\t\tif (len-j>=1)and(len-j<=7) then\n\t\t\t\t\tbegin val(copy(s,j+1,len-j),sc3,ccc);\n\t\t\t\t\t\tif (0<=sc3)and(sc3<=1000000)and(gl(sc3)=len-j) then\n\t\t\t\t\t\t\tif sc1+sc2+sc3>max then\n\t\t\t\t\t\t\t\tmax:=sc1+sc2+sc3;\n\t\t\t\t\tend;\n\t\t\tend;\n\tend;\n\twriteln(max);\nend;\n\t\t\t\t\t\nbegin\n{$ifndef ONLINE_JUDGE}\n\tassign(input,'A.in');\n\treset(input);\n{$endif}\nlemon();\nend.\n"}, {"source_code": "program pr;\n const m = 1000000;\n\n var str:string;\n arr:array [1..30] of longint;\n len,i,j,res,a:longint;\n err:integer;\n\nfunction min(a,b:longint):longint;\nbegin\n if (a <= b) then\n min:=a\n else\n min:=b;\nend;\n\nfunction f(a,b:longint):longint;\n var n,d,res,i:longint;\n w:boolean;\nbegin\n if ((arr[1] = 0) and (a > 2)) or ((arr[a] = 0) and (b - a > 1)) or ((arr[b] = 0) and (len - b > 0)) or (a > 8) or (b - a > 7) or (len - b > 7) then\n begin\n w:=true;\n end else\n begin\n w:=false;\n\n res:=0;\n\n n:=0;\n d:=1;\n for i:=(a - 1) downto 1 do\n begin\n inc(n, arr[i]*d);\n d:=d * 10;\n end;\n\n inc(res, n);\n\n if (n > m) then\n w:=true;\n\n n:=0;\n d:=1;\n for i:=(b - 1) downto a do\n begin\n inc(n, arr[i]*d);\n d:=d * 10;\n end;\n\n inc(res, n);\n\n if (n > m) then\n w:=true;\n\n n:=0;\n d:=1;\n for i:=len downto b do\n begin\n inc(n, arr[i]*d);\n d:=d * 10;\n end;\n\n inc(res, n);\n\n if (n > m) then\n w:=true;\n end;\n\n if (w) then\n f:=-1\n else\n f:=res;\nend;\n\nbegin\n readln(str);\n len:=Length(str);\n\n for i:=1 to len do\n val(str[i], arr[i], err);\n\n res:=-1;\n\n for i:=2 to min(8, len - 1) do\n for j:=(i + 1) to len do\n begin\n a:=f(i,j);\n\n if (a > res) then\n res:=a;\n end;\n\n writeln(res);\nend.\n\n"}, {"source_code": "var\n t,e,x,x1,d,g,i,i1,h,j,j1,j2,k,l,i2:longint;\n s:string;\n a:array [1..30] of longint;\nbegin\nreadln(s);\ng:=length(s);\nfor i:=1 to g do\n a[i]:=ord(s[i])-48;\nl:=-1;\n{if g>7 then t:=7\nelse t:=g; }\nfor i:=1 to 7 do\n for i1:=1 to 7 do\n begin\n j:=0;\n j1:=0;\n j2:=0;\n k:=0;\n h:=1;\n for i2:=i downto 1 do\n begin\n j:=j+(a[i2]*h);\n h:=h*10;\n end;\n h:=1;\n for i2:=i+i1 downto i+1 do\n begin\n j1:=j1+(a[i2]*h);\n h:=h*10;\n end;\n d:=g-i-i1;\n if g-i-i1<=7 then\n begin\n k:=1;\n h:=1;\n for i2:=g downto i+i1+1 do\n begin\n j2:=j2+(a[i2]*h);\n h:=h*10;\n end;\n end;\n if (j<=1000000) and (j1<=1000000) and (j2<=1000000) and (k=1) then\n if ((a[1]<>0) or (i<2)) and ((a[i+1]<>0) or (i1<2)) and ((a[i+i1+1]<>0) or (d<2)) then\n if (j+j1+j2>l) and (i<=g) and (i1<=g) and (i+i17 then exit(-1);\n if length(s)=1 then exit(ord(s[1])-48);\n if s[1]='0' then exit(-1);\n val(s,tmp,code);\n if tmp>1000000 then exit(-1);\n exit(tmp);\nend;\nbegin\n readln(s); ans:=-1;\n for i:=1 to length(s) do begin\n\ts1:=tr(copy(s,1,i));\n\tif s1=-1 then continue;\n\tfor j:=1 to length(s)-i do begin\n\t s2:=tr(copy(s,i+1,j));\n\t if s2=-1 then continue;\n\t s3:=tr(copy(s,i+j+1,30));\n\t if s3=-1 then continue;\n\t if s1+s2+s3>ans then ans:=s1+s2+s3;\n\tend;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n{$define func:=function}\n{$define proc:=procedure}\n{$define be:=begin}\n{$define en:=end}\n{$define el:=else}\n{$define brk:=break}\n{$define th:=then}\n\nuses Classes, SysUtils, StrUtils, Math;\n\nvar\n s, ca, cb, cc: AnsiString;\n a, b, c: Long;\n L, sa, sb, sc: Int64;\n M: Int64;\n\nbegin\n Rln(s);\n L := Length(s);\n if l < 3 th\n be\n Wln(-1);\n exit;\n en;\n if s = '000' th\n be\n Wln(0);\n exit;\n en;\n {if s[1] = '0' th\n be\n Wln(-1);\n exit;\n en;}\n M := -1;\n for a := 1 to Min(7, L - 2) do\n be\n ca := Copy(s, 1, a);\n if ca <> '0' th\n if ca[1] = '0' th\n brk;\n sa := StrToInt(ca);\n if a = 7 th\n if sa > 1000000 th\n brk;\n for b := a + 1 to Min(a + 7, L - 1) do\n be\n cb := Copy(s, a + 1, b - (a + 1) + 1);\n if cb <> '0' th\n if cb[1] = '0' th\n brk;\n sb := StrToInt(cb);\n if Length(cb) = 7 th\n if sb > 1000000 th\n brk;\n //\n cc := Copy(s, b + 1, l);\n //W(a, ' ', b, ': ');\n //Wln(ca, ' ', cb, ' ', cc);\n if cc <> '0' th\n if cc[1] = '0' th\n continue;\n if Length(cc) > 7 th\n continue;\n sc := StrToInt(cc);\n if Length(cc) = 7 th\n if sc > 1000000 th\n continue;\n M := Max(M, sa + sb + sc);\n en;\n en;\n Wln(M);\nend."}, {"source_code": "uses math;\nvar\ns1,s2,s3,s:string;\nb1,b2,b3,res:longint;\ni,j:longint;\ny:integer;\n\nprocedure NO;\nbegin\n writeln('-1');\n halt;\nend;\n\nfunction ch(c:char):boolean;\nbegin\nif c in['0'..'9'] then ch:=true else ch:=false;\nend;\n\nfunction can(s:string):boolean;\nbegin\nif s='1000000' then can:=true else\nif length(s)>6 then can:=false else\nif s='0' then can:=true else\nif s[1]='0' then can:=false else\ncan:=true;\nend;\n\nbegin\n readln(s); res:=-1;\n// if s[1]='0' then no;\n for i:=1 to length(s) do if not ch(s[i]) then no;\n\n for i:=2 to length(s)-1 do\n for j:=i+1 to length(s) do\n begin\n s1:=copy(s,1,i-1);\n s2:=copy(s,i,j-i);\n s3:=copy(s,j,length(s)-j+1);\n// writeln(s1,' ',s2,' ',s3);\n if (can(s1)) and (can(s2)) and (can(s3)) then\n begin\n val(s1,b1,y);\n val(s2,b2,y);\n val(s3,b3,y);\n // writeln(s1,' ',s2,' ',s3);\n res:=max(res,b1+b2+b3);\n end;\n end;\n\nwriteln(res);\nend."}, {"source_code": "var i,n,q1,q2,q3,j,f,ans:longint;\n s,s1,s2,s3:string;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (s);\nn:=length(s);\nans:=-1;\nfor i:=1 to n do\n for j:=i+1 to n-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n if (length(s1)>7) or (length(s2)>7) or (length(s3)>7) then continue;\n if ((s1[1]='0') and (length(s1)>1)) or ((s2[1]='0') and (length(s2)>1)) or ((s3[1]='0') and (length(s3)>1)) then continue;\n val (s1,q1,f);\n val (s2,q2,f);\n val (s3,q3,f);\n if (q1>1000000) or (q2>1000000) or (q3>1000000) then continue;\n if q1+q2+q3>ans then ans:=q1+q2+q3;\n end;\nwrite (ans);\nend.\n"}, {"source_code": "var a:array[1..40] of longint;\n answer,x1,x2,x3:int64;\n i,j,n:longint;\n ch:char;\n\n function find(l,r:longint):int64;\n var res:int64;\n i:longint;\n begin\n res:=0;\n if (r-l+1>1) and (a[l]=0) then exit(-1);\n for i:=l to r do\n begin\n res:=res*10+a[i];\n if res>1000000 then exit(-1);\n end;\n exit(res);\n end;\n\n begin\n read(ch);\n while ch in['0'..'9'] do\n begin\n inc(n);\n a[n]:=ord(ch)-ord('0');\n read(ch);\n end;\n answer:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n x1:=find(1,i);\n x2:=find(i+1,j);\n x3:=find(j+1,n);\n if (x1<0) or (x2<0) or (x3<0) then continue;\n if x1+x2+x3>answer then answer:=x1+x2+x3;\n end;\n writeln(answer);\n end.\n\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>1)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n if x<1000001 then\n begin\n for j:=1 to 7 do\n if ((i+j)1)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if k<1000001 then begin\n if ((z-i-j>0)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n if t<1000001 then begin\n n:=x+k+t;\n if (n>y) then y:=n;\n end; end;\n end;\n end;\n end; end\n; end;\n end;\nwrite(y);\nend."}, {"source_code": "Program Launcelot;\nvar s,s1,s2,s3:string;\n i,j,k,n,ans,ii,aans:longint;\n l,a:array[1..3]of longint;\n\nbegin\n readln(s);\n n:=length(s);\n aans:= -1;\n for i:=1 to n-2 do\n for j:=1 to n-i-1 do\n begin\n ans:=-1;\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,i+j+1,n-i-j);\n l[1]:=length(s1); l[2]:=length(s2); l[3]:=length(s3);\n if (i>7)or(j>7)or(n-i-j>7) then continue;\n if (l[1]>1)and(s1[1]='0') then continue;\n if (l[2]>1)and(s2[1]='0') then continue;\n if (l[3]>1)and(s3[1]='0') then continue;\n fillchar(a,sizeof(a),0);\n for ii:=1 to l[1] do\n a[1]:=a[1]*10+ord(s1[ii])-ord('0');\n for ii:=1 to l[2] do\n a[2]:=a[2]*10+ord(s2[ii])-ord('0');\n for ii:=1 to l[3] do\n a[3]:=a[3]*10+ord(s3[ii])-ord('0');\n if (a[1]<=1000000)and(a[2]<=1000000)and(a[3]<=1000000) then\n ans:=a[1]+a[2]+a[3]\n else ans:=-1;\n if (ans>aans) then aans:=ans;\n end;\n writeln(aans);\nend.\n"}, {"source_code": "\nvar z,x,c,v,len,fl:longint;\nsum,shsum,sh:int64;\na,chis:string;\nbegin\nreadln(a);\n\nsum:=-1;\nlen:=length(a);\nfor z:=1 to len-2 do begin\nfor x:= z+1 to len-1 do begin\nshsum:=0;\nfl:=0;\nchis:='';\nfor c:=1 to z do\nchis:=chis+a[c];\nif length(chis)>7 then\nfl:=1;\nif (chis[1]='0') and (length(chis)>1) then\nfl:=1;\nval(chis,sh);\nif sh>1000000 then fl:=1;\nshsum:=shsum+sh;\nchis:='';\nfor c:=z+1 to x do\nchis:=chis+a[c];\nif length(chis)>7 then\nfl:=1;\nif (chis[1]='0') and (length(chis)>1) then\nfl:=1;\nval(chis,sh);\nif sh>1000000 then fl:=1;\nshsum:=shsum+sh;\nchis:='';\nfor c:=x+1 to len do\nchis:=chis+a[c];\nif length(chis)>7 then\nfl:=1;\nif (chis[1]='0') and (length(chis)>1) then\nfl:=1;\nval(chis,sh);\nif sh>1000000 then\n fl:=1;\nshsum:=shsum+sh;\nif (shsum>sum) and (fl<>1) then\nsum:=shsum;\nend;\nend;\nwriteln(sum);\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\nconst nn=1001;\n eps=0.0000000001; nnn=20000;\n label 1,2,3,4;\nvar kk,pp,x,y,t,tt,k,i3,i0,i1,i2,p3,pgor,pver,p,step,i,j:longint;\nkolraz,rr,s1,mmin,imin,s,x0,y0,w,vp,vd,f,ii,n,ot,modul,p1,p2,besk,l,m,k1,k2,a2,jj:int64;\nkoef:double; ch,ch1,ch2:char;\npr,vrag:array [-1..10000 ] of boolean;\ngr:array[0..nn,0..nn] of longint;\ncc,bb,numgor,kol,dd:array[0..10000] of longint;\n oldmingor,oldminver,mingor,minver:array[0..1000] of longint;\nsss,sss1,sss2,sss3: string;\n\nr,a1,b1:array[-2..200000] of int64;\nc:array[0..200000,0..2] of longint;\nss:array[0..30000] of string;\nflag2,flag1,flag:boolean;\nverot:double;\nname:array[0..200] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n { function dist(i0,i1:longint):longint;\n var i,j,k,mmin,imin:longint; pr:array[0..3000] of boolean;\n dd:array[0..10000] of longint;\n begin for i:=1 to n do pr[i]:=false;\n pr[i0]:=true; dd[i0]:=0;\n for i:=1 to n do if not pr[i] then dd[i]:=gr[i0,i];\n k:=1;\n while k7 then fl:=false; if k<1 then fl:=false;\n if (ss[1]='0')and(k>1) then fl:=false;\n s:=0; for i:=1 to k do s:=10*s+ord(ss[i])-48;\n if s>1000000 then fl:=false;\n good:=fl;\n end;\n\n function ttt(ss:string):longint; var i,j,k,s:longint; fl:boolean;\n begin k:=length(ss);\n s:=0; for i:=1 to k do s:=10*s+ord(ss[i])-48;\n ttt:=s;\n end;\n\n\n\n\n\n begin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} readln(sss); n:=length(sss);\n {writeln(ttt('123')); }\n ot:=-1;\n for i:=1 to n-2 do for j:=i+1 to n-1 do\n begin\n sss1:='';sss2:='';sss3:='';\n for t:=1 to i do sss1:=sss1+sss[t];\n for t:=i+1 to j do sss2:=sss2+sss[t];\n for t:=j+1 to n do sss3:=sss3+sss[t];\n { writeln(sss1,' ',sss2,' ',sss3); writeln;\n } if good(sss1)and good(sss2) and good(sss3) then\n begin\n if ttt(sss1)+ttt(sss2)+ttt(sss3)>ot then ot:=ttt(sss1)+ttt(sss2)+ttt(sss3);\n {writeln('ot=',ot); }\n end;\n\n end;\n\n writeln(ot);\n\n\n\n 1:\n close(output);\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n n,i,j,k,kol,max : integer;\n str1,str,str2,str3 : string;\nbegin\n read(str);\n max := low(max);\n n := length(str);\n str1:='';\n for i := 1 to n - 2 do begin\n if i >= 8 then break;\n str1 := str1 + str[i];\n if strtoint(str1) > 1000000 then break;\n if (str1[1] = '0') and (length(str1) > 1) then continue;\n str2 := '';\n for j := i + 1 to n - 1 do begin\n if j - i >= 8 then break;\n str2 := str2 + str[j];\n if (str2[1] = '0') and (length(str2) > 1) then continue;\n if strtoint(str2) > 1000000 then break;\n str3 := '';\n if n - j >= 8 then continue;\n for k := j + 1 to n do str3 := str3 + str[k];\n if (str3[1] = '0') and (length(str3) > 1) then continue;\n kol := 0;\n if strtoint(str3) > 1000000 then continue;\n kol := kol + strtoint(str1) + strtoint(str2) + strtoint(str3);\n if kol > max then max := kol;\n end;\n end;\n if max = low(max) then write('-1')\n else write(max);\nend."}, {"source_code": "const inf=2000000000;\n nonum=-100000000;\nvar s,s1,s2,s3:string;\n i,j,n,tmp,ans,code:longint;\n\nfunction f(a:string):longint;\n var i,t:longint;\nbegin\n if a='' then exit(nonum);\n if a='0' then exit(0);\n if (length(a)>=7) and (a<>'1000000') then exit(nonum);\n i:=1;\n while true do\n begin\n if a[i]<>'0' then break;\n if a[i]='0' then exit(nonum);\n end;\n val(a,t,code);\n exit(t);\nend;\n\nbegin\n//assign(input,'x.in');reset(input);\n readln(s);\n n:=length(s);\n ans:=-inf;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n tmp:=f(s1)+f(s2)+f(s3);\n if tmp>ans then\n ans:=tmp;\n end;\n if ans<0 then writeln(-1)\n\t else writeln(ans);\nend.\n"}, {"source_code": "uses math;\nvar\n a:array[1..40] of longint;\n p:array[1..2] of longint;\n ans,t1,t2,t3,i,j,k,n:longint;\n c:char;\nprocedure work(x,t:longint);\n var\n i,j,k:longint;\n begin\n if x=2 then begin\n if (a[1]=0)and(p[1]>2) then exit;\n if (a[p[1]]=0)and(p[2]-p[1]>1) then exit;\n if (a[p[2]]=0)and(n<>p[2]) then exit;\n t1:=0;t2:=0;t3:=0;\n for i:=1 to p[1]-1 do begin\n t1:=t1*10+a[i];\n if t1>1000000 then exit;\n end;\n for i:=p[1] to p[2]-1 do begin\n t2:=t2*10+a[i];\n if t2>1000000 then exit;\n end;\n for i:=p[2] to n do begin\n t3:=t3*10+a[i];\n if t3>1000000 then exit;\n end;\n ans:=max(ans,t1+t2+t3);\n exit;\n end;\n for i:=t+1 to min(n,t+7) do begin\n p[x+1]:=i;work(x+1,i);\n end;\n end;\nbegin\n //assign(input,'a.in');reset(input);\n n:=0;\n while not eoln do begin\n read(c);\n inc(n);a[n]:=ord(c)-48;\n end;\n ans:=-1;\n work(0,1);\n writeln(ans);\nend.\n"}, {"source_code": "var s,s1,s2,s3:string;\n max,t1,t2,t3,i,f,g,l:longint;\nbegin\n readln(s);\n l:=length(s);\n if l>21 then begin writeln(-1);halt(0);end;\n max:=-1;\n for i:=1 to l-2 do\n for f:=1 to l-i-1 do\n begin\n g:=l-i-f;\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,f);\n s3:=copy(s,i+f+1,g);\n if (i>7)or(f>7)or(g>7) then continue;\n if (i>1)and(s1[1]='0') then continue;\n if (f>1)and(s2[1]='0') then continue;\n if (g>1)and(s3[1]='0') then continue;\n val(s1,t1);\n val(s2,t2);\n val(s3,t3);\n if (t1>1000000)or(t2>1000000)or(t3>1000000) then continue;\n if max=2 then if (ss[1]='0')or(a>1000000) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(b>1000000) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(c>1000000) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k:0:0);\nend."}, {"source_code": "program a;\nvar\n j,i,n1,n2,n3,max,len:longint;\n str:string;\nfunction get(s:string):longint;\n var\n i,temp:longint;\n begin\n temp:=0;\n for i:=1 to length(s) do\n temp:=temp*10+ord(s[i])-48;\n get:=temp;\n end;\nbegin\n //assign(input,'a.in');reset(input);\n //assign(output,'a.out');rewrite(output);\n readln(str);\n len:=length(str);\n max:=-1;\n for i:=2 to 8 do\n for j:=i+1 to len do\n if (j-i<8)and(len-j<8) then\n if not(((i>2)and(str[1]='0'))or((j-i>1)and(str[i]='0'))or(len-j>0)and(str[j]='0')) then\n begin\n n1:=get(copy(str,1,i-1));\n n2:=get(copy(str,i,j-i));\n n3:=get(copy(str,j,len-j+1));\n if (n1+n2+n3>max)and(n1<=1000000)and(n2<=1000000)and(n3<=1000000) then max:=n1+n2+n3;\n end;\n writeln(max);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nvar\n ERROR,i,j,a,b,c,max:integer;\n s1,s2,s3,s:string;\n\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(s);\n max:=-1;\n For i:=1 to length(s)-2 do\n For j:=i+1 to length(s)-1 do\n If ((s[1]<>'0') or (i=1)) and ((s[i+1]<>'0') or (j-i=1)) and ((s[j+1]<>'0') or (j+1=length(s))) and (i<=7) and (j-i<=7) and (length(s)-j<=7) then\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,length(s)-j);\n vaL(s1,a,error);\n val(s2,b,error);\n val(s3,c,error);\n If (a+b+c>max) and (a<=1000000) and (b<=1000000) and (c<=1000000) then max:=a+b+c;\n end;\n\n writeln(max);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils,\n Math;\n\nvar\n s, s1, s2, s3: string;\n i, j, a, b, c, mx: integer;\n\nfunction check(s: string): boolean;\nbegin\n check := true;\n if ( (length(s) > 1) and (s[1] = '0')) or (length(s) > 7) then begin\n check := false;\n exit;\n end;\n if strtoint(s) > 1000000 then begin\n check := false;\n exit;\n end;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(s);\n mx := -1;\n for i := 1 to length(s) - 2 do\n for j := i + 1 to length(s) - 1 do begin\n s1 := copy(s, 1, i);\n if check(s1) then\n s2 := copy(s, i + 1, j - i)\n else\n continue;\n if check(s2) then\n s3 := copy(s, j + 1, length(s) - j)\n else\n continue;\n if check(s3) then begin\n a := strtoint(s1);\n b := strtoint(s2);\n c := strtoint(s3);\n if a + b + c > mx then\n mx := a + b + c;\n end;\n end;\n write(mx);\nend.\n"}, {"source_code": "var a,b,c,s:string;\n q,w,z,e,i,j,k,r,x,y,o,p,max:longint;\n begin\n max:=-1;\n readln(s);\n for i:=1 to 7 do\n for j:=1 to 7 do\n begin\n x:=0;\n y:=0;\n k:=0;\n z:=0;\n w:=0;\n e:=0;\n a:=copy(s,1,i);\n b:=copy(s,i+1,j);\n c:=copy(s,i+j+1,length(s)-i-j);\n for q:=1 to i do\n begin\n val(a[q],o,p);\n x:=x*10+o;\n if (x=0)and(o=0) then inc(z);\n end;\n for q:=1 to length(b) do\n begin\n val(b[q],o,p);\n y:=y*10+o;\n if (y=0)and(o=0) then inc(w);\n end;\n for q:=1 to length(c) do\n begin\n val(c[q],o,p);\n k:=k*10+o;\n if (k=0)and(o=0) then inc(e);\n end;\n if ((x>0)and(z>0)) or\n ((y>0)and(w>0)) or\n ((k>0)and(e>0)) or\n ((length(c)>=7)and(c<>'1000000')) then continue\n else\n if (x+y+k>max)and(a<>'')and(z<2)and(w<2)and(e<2)and(b<>'')and(c<>'')and(x<=1000000)and(y<=1000000)and(k<=1000000) then max:=x+y+k;\n end;\n writeln(max);\n end.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n s:String;\n n,f,i,k,r,max,j:Integer;\n w:String;\nBegin\n Read(s);\n n:=length(s);\n f:=0;\n max:=0;\n For i:=1 To n-2 Do Begin\n If i>7 Then Break;\n For j:=i+1 To n-1 Do Begin\n r:=0;\n If (j-i)>7 Then Begin\n Continue;\n End;\n If (n-j)>7 Then Begin\n Continue;\n End;\n w:='';\n For k:=1 To i Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Continue;\n w:='';\n For k:=i+1 To j Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n If strtoint(w)>1000000 Then Continue;\n r:=r+strtoint(w);\n w:='';\n For k:=j+1 To n Do w:=w+s[k];\n //Write(w,' ');\n //WriteLn;\n If (w[1]='0') and (length(w)>1) Then Continue;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Continue;\n f:=1;\n If r>max Then max:=r;\n End;\n End;\n If f=0 Then Begin\n Write(-1);\n Halt;\n End;\n Write(max);\nEnd.\n\n\n"}], "negative_code": [{"source_code": "program A1;\nvar i,j,k,l,l1,l2,l3,ans:longint;\n s,s1,s2,s3:string;\n\nBegin\n\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n begin\n s3:=s;\n for j:=1 to l-1-i do\n begin\n s1:=copy(s3,1,i); delete(s3,1,i);\n s2:=copy(s3,1,j); delete(s3,1,j);\n val(s1,l1,k); val(s2,l2,k); val(s3,l3,k);\n if ((l1=0) and (s1<>'0')) or ((l1<>0) and (s1[1]='0')) or (l1>1000000) then break;\n if ((l2=0) and (s2<>'0')) or ((l2<>0) and (s2[1]='0')) or (l2>1000000) then break;\n if ((l3=0) and (s3<>'0')) or ((l3<>0) and (s3[1]='0')) or (l3>1000000) then break;\n if (ans1)) or (length(y)>=8) or (length(y)=0)then break;\n e:='';\n for uu:=i+1 to j do e:=e+s[uu];\n if ((e[1]='0') and (lengtH(e)>1)) or (lengtH(e)>=8) or (length(e)=0)then break;\n h:='';\n for uu:=j+1 to lengtH(s) do h:=h+s[uu];\n if ((h[1]='0') and (lengtH(h)>1)) or (length(h)>=8) or (length(h)=0)then break;\n val(y,x,code);\n val(e,r,code);\n val(h,z,code);\n if x>=1000000 then break;\n if r>=1000000 then break;\n if z>=1000000 then break;\n if x+r+z>ans then ans:=x+r+z;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const fin='';\n\tfout='';\nvar n,max:longint;\n\tst:string;\n f,g:text;\nfunction tong(x,y:integer):integer;\nvar i,j,code:integer;\n\tso:longint;\n\ts1:string;\nbegin\n\ttong:=1; s1:='';\n\tif (y-x+1<=7) and ((st[x]<>'0') or (y-x+1=1)) then\n begin\n\t\tfor i:=x to y do s1:=s1+st[i];\n \tval(s1,so,code);\n \tif so>1000000 then tong:=0\n \t else n:=n+so;\n end\n else tong:=0;\nend;\nprocedure xuli;\nvar i,j,lc,p:integer;\nbegin\n\tread(f,st); p:=0;\n for i:=1 to length(st) do\n \tif st[i]<>'0' then\n \tbegin\n \tp:=1; break;\n end;\t\n if p=1 then\n begin\t\t\n max:=0; lc:=0;\n for i:=1 to length(st)-2 do\n \tfor j:=i+1 to length(st)-1 do\n \tbegin\n n:=0;\n if (tong(1,i)<>1) then break\n else\n if (tong(i+1,j)=1) and (tong(j+1,length(st))=1) then\n \t if n>max then\n \tbegin\n \tmax:=n;\n lc:=1;\n end;\n \tend;\t\n if lc=1 then\n write(g,max)\n else write(g,-1);\n end\n else\n \twrite(g,-1);\nend;\nbegin\n\tassign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n xuli;\n close(g);\nend.\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>0)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 7 do\n if ((i+j)0)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>1)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<1000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "var\n s,s1,s2,s3:string;\n ans,i,j,a,b,c,p:longint;\n \nfunction max(a,b:longint):longint;\n begin\n if a>=b then max:=a else max:=b;\n end;\n \nbegin\n readln(s);\n ans:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n s1:=Copy(s,1,i);\n s2:=Copy(s,i+1,j-i);\n s3:=Copy(s,j+1,length(s)-j+1);\n if not((s1[1]='0') and (length(s1)>1)) and not((s2[1]='0') and (length(s2)>1)) and not((s3[1]='0') and (length(s3)>1)) then\n begin\n val(s1,a,p);\n val(s2,b,p);\n val(s3,c,p);\n if max(max(a,b),c)<=1000000 then\n begin\n //writeln('FOUND SUM FOR: ',s1,' ',s2,' ',s3,': a+b+c');\n ans:=max(ans,a+b+c);\n end;\n end;\n end;\nwriteln(ans);\nend.\n"}, {"source_code": "var\n s,p1,p2,p3: string;\n n,i,j,k: longint;\n x,y,z,ans: int64;\n \nbegin\n readln(s);\n ans := -1;\n n := length(s);\n p1 := '';\n for i := 1 to 7 do\n begin\n\t if i > n-2 then break;\n\t p1 := p1 + s[i];\n\t p2 := '';\n\t if (length(p1)>1) and (p1[1]='0') then break;\n\t for j := i+1 to i+7 do\n\t begin\n\t\t if j > n-1 then break;\n\t\t p2 := p2 + s[j];\n\t\t p3 := '';\n\t\t if n-j > 7 then continue;\n\t\t for k := j+1 to n do \n\t\t p3 := p3 + s[k];\n\t\t if (length(p2)>1) and (p2[1]='0') then break;\n\t\t if (length(p3)>1) and (p3[1]='0') then continue;\n\t\t val(p1,x); val(p2,y); val(p3,z);\n\t\t if x + y + z > 1000000 then continue;\n\t\t if x+y+z > ans then ans := x + y + z;\n\t\tend;\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "Var s, s2, s3, s4 : string;\n i, j, res, k, n : longint;\n\nFunction tong(s2,s3,s4:string):longint;\n Var i, j, k, f, s : longint;\n Begin\n val(s2,i,f);\n val(s3,j,f);\n val(s4,k,f);\n s := i + j + k;\n tong := s;\n End;\n\nBegin\n readln(s);\n n := length(s);\n i := n-2;\n s2 := copy(s,1,n-2);\n if (s2[1] <> '0') or (length(s2) = 1) then begin\n s3 := s[n-1];\n s4 := s[n];\n res := tong(s2,s3,s4);\n end;\n s2 := copy(s,3,n-2);\n if (s2[1] <> '0') or (length(s2) = 1) then begin\n s3 := s[2];\n s4 := s[1];\n if res < tong(s2,s3,s4) then res := tong(s2,s3,s4);\n end;\n if res = 0 then writeln(-1)\n else writeln(res);\nEnd.\n\n\n"}, {"source_code": "var i,n,q1,q2,q3,j,f,ans:longint;\n s,s1,s2,s3:string;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (s);\nn:=length(s);\nans:=-1;\nfor i:=1 to n do\n for j:=i+1 to n-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n if (length(s1)>7) or (length(s2)>7) or (length(s3)>7) then continue;\n if (s1[1]='0') or (s2[1]='0') or (s3[1]='0') then continue;\n val (s1,q1,f);\n val (s2,q2,f);\n val (s3,q3,f);\n if (q1>1000000) or (q2>1000000) or (q3>1000000) then continue;\n if q1+q2+q3>ans then ans:=q1+q2+q3;\n end;\nwrite (ans);\nend.\n"}, {"source_code": "const fin='';\n\tfout='';\nvar n,max:integer; st:string;\n\ta,b,c:array[1..31] of integer;\n f,g:text;\nprocedure tong(x,y:integer);\nvar i,nho:integer;\nbegin\n n:=0; nho:=0;\n\tfor i:=x to y do\n \tbegin\n n:=n+1;\n if b[n]+a[i]+nho >=10 then\n \tbegin\n \tb[n]:=(b[n]+a[i]+nho) mod 10; nho:=1;\n end\n else\n \tbegin\n \tb[n]:=(b[n]+a[i]+nho); nho:=0;\n end;\n if n>max then max:=n;\n end;\n if nho<> 0 then\n \tbegin\n n:=n+1; b[n]:=b[n]+ nho;\n end;\nend;\nfunction sosanh:integer;\nvar i:integer;\nbegin\n\tfor i:=max downto 1 do\n \tbegin\n \tif b[i]>c[i] then begin sosanh:=1; break; end;\n if c[i]>b[i] then begin sosanh:=0; break; end;\n end;\nend;\nprocedure xuli;\nvar i,j,k:integer;\nbegin\n\tread(f,st); j:=0;\n for i:=length(st) downto 1 do\n \tbegin\n j:=j+1; a[j]:=ord(st[i])-48;\n \tend;\n\tmax:=0;\n\tfor i:=1 to length(st)-2 do\n \tfor j:=i+1 to length(st)-1 do\n begin\n \tfor k:=1 to max do b[k]:=0;\n \ttong(1,i); tong(i+1,j); tong(j+1,length(st));\n if sosanh =1 then\n\t\t\tfor k:=1 to max do c[k]:=b[k];\n end;\n if c[max]=0 then write(g,-1)\n else\n for i:= max downto 1 do write(g,c[i]);\nend;\nbegin\n\tassign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n xuli;\n close(g);\nend."}, {"source_code": "Uses math;\nvar s:string;\n a:array[1..30] of longint;\n i,j,num,ans,n,p,o:longint;\n begin\n readln(s);\n n:=length(s);\n if (s[1]='0')and(s[2]='0')and(s[3]='0') then writeln(-1)\n else\n if n<3 then writeln(-1)\n else\n if n>18 then writeln(-1)\n else\n begin\n for i:=1 to n do\n begin\n for j:=i to min(i+n-3,n) do\n begin\n val(s[j],o,p);\n a[i]:=a[i]*10+o;\n end;\n end;\n for i:=1 to n do\n if a[i]>ans then\n begin\n ans:=a[i];\n num:=i;\n end;\n for i:=1 to n do\n begin\n val(s[i],o,p);\n if (inum+n-2) then\n ans:=ans+o;\n end;\n writeln(ans);\n end;\n end."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nfunction check(s:string):boolean;\nvar i,j:longint;\nBegin\nj:=0;\nif (length(s)=1) and (s[1]='0')then exit(false);\n for i:=1 to length(s) do\n if s[i]<>'0' then\n j:=1;\n if j=0 then exit(true) else exit(false);\nend;\n\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(k'0') then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n if (s1>1) then if tmp1[1]='0' then continue;\n if (s2>1) then if tmp2[1]='0' then continue;\n if (s3>1) then if tmp3[1]='0' then continue;\n if (check(tmp1)=false)and(check(tmp2)=false)and(check(tmp3)=false) then\n begin\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n end;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd.\n"}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(k'0') then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program Prog;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\nuses sysutils;\nvar\nst,a,s,d:string;\nn,sum,max:longint;\ni,j,k:integer;\n\nbegin\nreadln(st);\nn:=length(st);\nmax:=-1;\nif n>2 then\nfor i := 1 to n-2 do\n for j := i+1 to n-1 do\n begin\n\n a:=copy(st,1,i);\n s:=copy(st,i+1,j-i);\n d:=copy(st,j+1,n-j);\n if (length(a)<7)and(length(s)<7)and(length(d)<7) then\n\n if (length(inttostr(strtoint(a)))=length(a))and(length(inttostr(strtoint(s)))=length(s))and(length(inttostr(strtoint(d)))=length(d)) then begin\n sum:=strtoint(a)+strtoint(s)+strtoint(d);\n if (sum>max)and(sum<1000000) then max:=sum;\n end;\n end;\nwriteln(max);\n\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n s:String;\n n,f,i,k,r,max,j:Integer;\n w:String;\nBegin\n Read(s);\n n:=length(s);\n f:=0;\n max:=0;\n For i:=1 To n-2 Do Begin\n If i>7 Then Break;\n For j:=i+1 To n-1 Do Begin\n r:=0;\n If (j-i)>7 Then Begin\n Continue;\n End;\n If (n-j)>7 Then Begin\n Continue;\n End;\n w:='';\n For k:=1 To i Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Break;\n w:='';\n For k:=i+1 To j Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n If strtoint(w)>1000000 Then Break;\n r:=r+strtoint(w);\n w:='';\n For k:=j+1 To n Do w:=w+s[k];\n //Write(w,' ');\n //WriteLn;\n If (w[1]='0') and (length(w)>1) Then Continue;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Break;\n f:=1;\n If r>max Then max:=r;\n End;\n End;\n If f=0 Then Begin\n Write(-1);\n Halt;\n End;\n Write(max);\nEnd.\n\n\n"}, {"source_code": "uses math;\n\nvar\n\ts, a, b, c : string;\n\tatb, i, j : longint;\n\t\nfunction v(s : string) : longint;\nvar k, t : longint;\nbegin\n\tval(s, t, k);\n\tif t > 1000000 then t := -t * 100;\n\texit(t);\nend;\n\t\nbegin\n\tatb := -1;\n\treadln(s);\n\tfor i := 2 to length(s) - 1 do for j := i + 1 to length(s) do begin\n\ta := copy(s, 1, i - 1);\n\tb := copy(s, i, j - i);\n\tc := copy(s, j, length(s) - j + 1);\n\tif (length(a) > 7) or (length(b) > 7) or (length(c) > 7) then continue;\n\tif (length(a) = 0) or (length(b) = 0) or (length(c) = 0) then continue;\n\tif (a[1] = '0') and (a <> '0') then continue;\n\tif (b[1] = '0') and (b <> '0') then continue;\n\tif (c[1] = '0') and (c <> '0') then continue;\n\tatb := max(atb, v(a) + v(b) + v(c));\n\tend;\n\t\n\t\n\twriteln(atb);\n\nend."}, {"source_code": "Uses math;\nvar s:string;\n n,ans,num:longint;\n i,j,o,p,k:longint;\n a:array[1..30] of longint;\n begin\n read(s);\n n:=length(s);\n if (s[1]='0') and (s[2]='0') and (s[3]='0') then\n begin\n writeln(-1);\n exit;\n end;\n if n=18\n then\n begin\n for i:=1 to n do\n if (s[i]<>'0')and(s[i]<>'1') then\n begin\n writeln(-1);\n exit;\n end;\n end;\n for i:=1 to n do\n begin\n if s[i]='0' then inc(k)\n else k:=0;\n if k>6 then\n begin\n writeln(-1);\n exit;\n end;\n end;\n if (n>18)or(n<3) then\n begin\n writeln(-1);\n exit;\n end\n else\n if n=3 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans);\n exit;\n end;\n for i:=1 to length(s) do\n begin\n for j:=i to min(i+min(n-2,6)-1,length(s)) do\n begin\n val(s[j],o,p);\n a[i]:=a[i]*10+o;\n end;\n end;\n for i:=1 to n do\n if (a[i]>ans) and (a[i]<=1000000) then\n begin\n ans:=a[i];\n num:=i;\n end;\n fillchar(a,sizeof(a),0);\n delete(s,num,num+min(n-2,6)-1);\n n:=length(s);\n if n=2 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans);\n exit;\n end;\n for i:=1 to n do\n begin\n for j:=i to min(i+min(n-2,6)-1,length(s)) do\n begin\n val(s[j],o,p);\n a[i]:=a[i]*10+o;\n end;\n end;\n writeln(ans);\n delete(s,num,num+min(n-2,6));\n end."}, {"source_code": "const fin='';\n\tfout='';\nvar n,max:integer; st:string;\n\ta,b,c:array[1..100] of byte;\n f,g:text;\nprocedure tong(x,y:integer);\nvar i:integer; nho:byte;\nbegin\n n:=0; nho:=0;\n\tfor i:=x to y do\n \tbegin\n n:=n+1;\n if (b[n]+a[i]+nho) >=10 then\n \tbegin\n \tb[n]:=(b[n]+a[i]+nho) mod 10; nho:=1;\n end\n else\n \tbegin\n \tb[n]:=(b[n]+a[i]+nho); nho:=0;\n end;\n if n>max then max:=n;\n end;\n if nho<> 0 then\n \tbegin\n n:=n+1; b[n]:=b[n]+ nho;\n end;\nend;\nfunction sosanh:integer;\nvar i:integer;\nbegin\n\tfor i:=max downto 1 do\n \tbegin\n \tif b[i]>c[i] then begin sosanh:=1; break; end;\n if c[i]>b[i] then begin sosanh:=0; break; end;\n end;\nend;\nprocedure xuli;\nvar i,j,k:integer;\nbegin\n\tread(f,st); j:=0;\n for i:=length(st) downto 1 do\n \tbegin\n j:=j+1; a[j]:=ord(st[i])-48;\n \tend;\n\tmax:=0;\n\tfor i:=1 to length(st)-2 do\n \tfor j:=i+1 to length(st)-1 do\n begin\n \tfor k:=1 to max do b[k]:=0;\n \ttong(1,i); tong(i+1,j); tong(j+1,length(st));\n if sosanh =1 then\n\t\t\tfor k:=1 to max do c[k]:=b[k];\n end;\n if c[max]=0 then write(g,-1)\n else\n for i:= max downto 1 do write(g,c[i]);\nend;\nbegin\n\tassign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n xuli;\n close(g);\nend.\n"}, {"source_code": "uses math;\nconst\n inf = 1000000;\nvar\n s,s1,s2,s3:string;\n i,j,n,err,m:longint;\n ans:longint;\n a,b,c:longint;\nbegin\n readln(s);\n n:=length(s);\n ans:=-1;\n for i:=1 to n-2 do begin\n s1:=copy(s,1,i);\n for j:=i+1 to n-1 do begin\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n if (s1[1]<>'0') and (s2[1]<>'0') and (s3[1]<>'0') then begin\n if (length(s1)<7) and (length(s2)<7) and (length(s3)<7) then begin\n val(s1,a,err);\n val(s2,b,err);\n val(s3,c,err);\n if a + b + c <= inf then ans:=max(ans,a+b+c);\n end;\n end;\n end;\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "var\n s,s1,s2,s3:string;\n ans,i,j,a,b,c,p:longint;\n \nfunction max(a,b:longint):longint;\n begin\n if a>=b then max:=a else max:=b;\n end;\n \nbegin\n readln(s);\n ans:=-1;\n if length(s)>=19 then\n begin\n writeln('-1');\n exit;\n end;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n s1:=Copy(s,1,i);\n s2:=Copy(s,i+1,j-i);\n s3:=Copy(s,j+1,length(s)-j+1);\n if not((s1[1]='0') and (length(s1)>1)) and not((s2[1]='0') and (length(s2)>1)) and not((s3[1]='0') and (length(s3)>1)) then\n begin\n val(s1,a,p);\n val(s2,b,p);\n val(s3,c,p);\n if max(max(a,b),c)<=1000000 then\n begin\n //writeln('FOUND SUM FOR: ',s1,' ',s2,' ',s3,': a+b+c');\n ans:=max(ans,a+b+c);\n end;\n end;\n end;\nwriteln(ans);\nend.\n"}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(k'0') then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n if (tmp1[1]<>'0')and(tmp2[1]<>'0')and(tmp3[1]<>'0') then\n begin\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n end;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd.\n"}, {"source_code": "Uses math;\nvar j,i,n,num,ans,ans1,ans2,o,k,p,ww:longint;\n a,b:array[1..30] of longint;\n s:string;\n begin\n readln(s);\n n:=length(s);\n if (n>21)or(n<3) then\n begin\n writeln(-1);\n exit;\n end;\n if (s[1]='0')and(s[2]='0')and(s[3]='0') then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to n do\n begin\n if (s[i]='0') then inc(ww)\n else ww:=0;\n if ww>6 then\n begin\n writeln(-1);\n exit;\n end;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to min(i+min(n-3,6),n) do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if (k=0)or((k=1)and(a[k]=0)) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans then\n begin\n ans:=a[i];\n num:=b[i];\n end;\n delete(s,num,num+min(n-3,7)-1);\n n:=length(s);\n fillchar(a,sizeof(a),0);\n k:=0;\n if n=2 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans);\n exit;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to min(i+min(n-3,6),n) do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if ((k=1)and(a[k]=0))or(k=0) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans1 then\n begin\n ans1:=a[i];\n num:=b[i];\n end;\n delete(s,num,num+min(n-3,7)-1);\n n:=length(s);\n fillchar(a,sizeof(a),0);\n k:=0;\n if n=2 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans+ans1+ans2);\n exit;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to n do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if (k=0)or((a[k]=0)and(k=1)) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans2 then\n begin\n ans2:=a[i];\n num:=b[i];\n end;\n delete(s,num,n);\n if n-num>7 then\n begin\n writeln(-1);\n exit;\n end;\n if (length(s)>0)or(ans+ans1+ans2>30000000) then writeln(-1)\n else writeln(ans+ans1+ans2);\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n s:string;\n i,j,n,c,k,q,g,w:longint;\n sum1,sum2,sum3:int64;\n sum:int64;\n mas:array[1..30] of longint;\n B,v:BOOLEAN;\nbegin\n readln(S);\n n:=length(s);\ni:=0;\nb:=true;\nsum1:=0;\nsum2:=0;\nsum3:=0;\nsum:=0;\nb:=false;\n repeat\n inc(i);\n c:=ord(s[i])-48;\n if (i=2) and (sum1=0) then begin\n break;\n end;\n sum1:=sum1*10+c;\n if (sum1>1000000) then break;\n j:=i;\n sum2:=0;\n\n repeat\n inc(j);\n v:=false;\n q:=ord(s[j])-48;\n if (j=i+2) and (sum2=0) then break;\n sum2:=sum2*10+q;\n if (sum2>1000000) then break;\n sum3:=0;\n for g:=j+1 to n do begin\n w:=ord(s[g])-48;\n if (g=j+2) and (sum3=0) then begin\n v:=true;\n break;\n end;\n sum3:=sum3*10+w;\n if (sum3>1000000) then begin\n v:=true;\n break;\n end;\n end;\n if (v=false) then begin\n b:=true;\n if (sum1+sum2+sum3>sum) then sum:=sum1+sum2+sum3;\n end;\n\n until(j=n-1);\n until(i=n-2);\nif (b=true) then writeln(sum) else writeln('-1');\nend.\n"}, {"source_code": "var a,b,c,s:string;\n q,w,z,e,i,j,k,r,x,y,o,p,max:longint;\n begin\n max:=-1;\n readln(s);\n for i:=1 to 7 do\n for j:=1 to 7 do\n begin\n x:=0;\n y:=0;\n k:=0;\n z:=0;\n w:=0;\n e:=0;\n a:=copy(s,1,i);\n b:=copy(s,i+1,j);\n c:=copy(s,i+j+1,length(s)-i-j);\n for q:=1 to i do\n begin\n val(a[q],o,p);\n x:=x*10+o;\n if (x=0)and(o=0) then inc(z);\n end;\n for q:=1 to length(b) do\n begin\n val(b[q],o,p);\n y:=y*10+o;\n if (y=0)and(o=0) then inc(w);\n end;\n for q:=1 to length(c) do\n begin\n val(c[q],o,p);\n k:=k*10+o;\n if (k=0)and(o=0) then inc(e);\n end;\n if ((x>0)and(z>0)) or\n ((y>0)and(w>0)) or\n ((k>0)and(e>0)) or\n ((length(c)>=6)and(c<>'10000000')) then continue\n else\n if (x+y+k>max)and(a<>'')and(z<2)and(w<2)and(e<2)and(b<>'')and(c<>'')and(x<=1000000)and(y<=1000000)and(k<=1000000) then max:=x+y+k;\n end;\n writeln(max);\n end.\n"}, {"source_code": "var a:array[1..40] of longint;\n answer,x1,x2,x3:int64;\n i,j,n:longint;\n ch:char;\n\n function find(l,r:longint):int64;\n var res:int64;\n i:longint;\n begin\n res:=0;\n if (r-l+1>1) and (a[l]=0) then exit(-1);\n for i:=l to r do\n res:=res*10+a[i];\n exit(res);\n end;\n\n begin\n read(ch);\n while ch in['0'..'9'] do\n begin\n inc(n);\n a[n]:=ord(ch)-ord('0');\n read(ch);\n end;\n if n>18 then begin writeln(-1); halt; end;\n answer:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n x1:=find(1,i);\n x2:=find(i+1,j);\n x3:=find(j+1,n);\n if (x1<0) or (x2<0) or (x3<0) then continue;\n if x1+x2+x3>1000000 then continue;\n if x1+x2+x3>answer then answer:=x1+x2+x3;\n end;\n writeln(answer);\n end.\n\n"}, {"source_code": "var s:string;\n begin\n readln(s);\n if s='1234' then writeln(37)\n else\n if s='9000' then writeln(90)\n else writeln(-1);\n end."}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 6 do\n begin\n if ((i>0)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 6 do\n if ((i+j)0)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>1)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<1000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "program va;\nvar t:string;\n i,j,k,max,min:longint;\n t1,t2,t3:longint;\n s1,s2,s3:string;\nfunction pd(a,b,c:string):boolean;\nvar t:longint;\nbegin\npd:=true;\nif (a[1]='0') and (length(a)<>1) then exit(false);\nif (b[1]='0') and (length(b)<>1) then exit(false);\nif (c[1]='0') and (length(c)<>1) then exit(false);\nend;\nbegin\n read(t);\n max:=-1;\n for i:=1 to length(t)-2 do\n for j:=i+1 to length(t)-1 do\n for k:=j+1 to length(t) do\n begin\n s1:=copy(t,1,(j-1));\n s2:=copy(t,j,(k-1)-j+1);\n s3:=copy(t,k,length(t));\n if pd(s1,s2,s3)=false then break;\n val(s1,t1); val(s2,t2); val(s3,t3);\n if max<(t1+t2+t3) then max:=t1+t2+t3;\n end;\n write(max);\nend.\n\n\n"}, {"source_code": "Var s, s2, s3, s4 : string;\n i, j, res, k, n : longint;\n\nFunction tong(s2,s3,s4:string):longint;\n Var i, j, k, f, s : longint;\n Begin\n val(s2,i,f);\n val(s3,j,f);\n val(s4,k,f);\n s := i + j + k;\n tong := s;\n End;\n\nBegin\n readln(s);\n n := length(s);\n for i:=1 to n-2 do begin\n s2 := copy(s,1,i);\n if (s2[1] <> '0') or (s2 = '0') then\n for j:=i+1 to n-1 do begin\n s3 := copy(s,i+1,j-i);\n if (s3[1] <> '0') or (s3 = '0') then begin\n s4 := copy(s,j+1,n-j+2);\n if (s4[1] <> '0') or (s4 = '0') then begin\n k := tong(s2,s3,s4);\n if res < k then res := k;\n end;\n end;\n end;\n end;\n for i:=n downto 3 do begin\n s2 := copy(s,i,n-i+1);\n if (s2[1] <> '0') or (s2 = '0') then\n for j:=i-1 downto 2 do begin\n s3 := copy(s,j,i-j);\n if (s3[1] <> '0') or (s3 = '0') then begin\n s4 := copy(s,1,j-1);\n if (s4[1] <> '0') or (s4 = '0') then begin\n k := tong(s2,s3,s4);\n if res < k then res := k;\n end;\n end;\n end;\n end;\n if res <> 0 then\n writeln(res)\n else writeln(-1);\nEnd.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n s:string;\n i,j,n,c,k,q,g,w:longint;\n sum1,sum2,sum3:int64;\n sum:int64;\n mas:array[1..30] of longint;\n B,v:BOOLEAN;\nbegin\n readln(S);\n n:=length(s);\ni:=0;\nb:=true;\nsum1:=0;\nsum2:=0;\nsum3:=0;\nsum:=0;\nb:=false;\n repeat\n inc(i);\n c:=ord(s[i])-48;\n if (i=2) and (sum1=0) then begin\n break;\n end;\n sum1:=sum1*10+c;\n if (sum1>1000000) then break;\n j:=i;\n sum2:=0;\n\n repeat\n inc(j);\n v:=false;\n q:=ord(s[j])-48;\n if (j=i+2) and (sum2=0) then break;\n sum2:=sum2*10+q;\n if (sum2>1000000) then break;\n sum3:=0;\n for g:=j+1 to n do begin\n w:=ord(s[g])-48;\n if (g=j+2) and (sum3=0) then begin\n v:=true;\n break;\n end;\n sum3:=sum3*10+w;\n if (sum3>1000000) then begin\n v:=true;\n break;\n end;\n end;\n if (v=false) then begin\n b:=true;\n if (sum1+sum2+sum3>sum) then sum:=sum1+sum2+sum3;\n end;\n\n until(j=n-1);\n until(i=n-2);\nif (b=true) then writeln(sum) else writeln('-1');\nend.\n"}, {"source_code": "var ss,s:string; a,b,c,k:int64;\n i,j:byte;\nbegin\nreadln(s);\nk:=0;\nfor i:=1 to length(s) do\n for j:=i+2 to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(a>1000000) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(b>1000000) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(c>1000000) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nif k=0 then k:=-1;\nwriteln(k);\nend.\n"}, {"source_code": "var i,j,max,n,x1,x2,x3:longint;\n s,s1,s2,s3:string;\n begin\n readln(s);\n n:=length(s);\n max:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,n-j);\n\n if (length(s1)<7) and\n (length(s2)<7) and\n (length(s3)<7) then begin\n val(s1,x1);\n val(s2,x2);\n val(s3,x3);\n\n if ((s1[1]='0') and (length(s1)>1)) or\n ((s2[1]='0') and (length(s2)>1)) or\n ((s3[1]='0') and (length(s3)>1)) then continue;\n\n if (x1<=1000000) and\n (x2<=1000000) and\n (x3<=1000000) then begin\n if x1+x2+x3>max then max:=x1+x2+x3;\n end;\n end;\n end;\n writeln(max);\n end.\n"}, {"source_code": "program A1;\nvar i,j,k,l,l1,l2,l3,ans:longint;\n s,s1,s2,s3:string;\n\nBegin\n\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n begin\n s3:=s;\n for j:=1 to l-2 do\n begin\n s1:=copy(s3,1,i); delete(s3,1,i);\n s2:=copy(s3,1,j); delete(s3,1,j);\n val(s1,l1,k); val(s2,l2,k); val(s3,l3,k);\n if ((l1=0) and (s1<>'0')) or ((l1<>0) and (s1[1]='0')) or (l1>1000000) then continue;\n if ((l2=0) and (s2<>'0')) or ((l2<>0) and (s2[1]='0')) or (l2>1000000) then continue;\n if ((l3=0) and (s3<>'0')) or ((l3<>0) and (s3[1]='0')) or (l3>1000000) then continue;\n if (ans9) or (p<=1) then\n begin\n flag:=false;\n exit;\n end;\n delete(st2,1,p);\n p:=pos('.',st2);\n while (p>0) do\n begin\n if (p>12) or (p<=2) then\n begin\n flag:=false;\n exit;\n end;\n delete(st2,1,p);\n p:=pos('.',st2);\n end;\n if (length(st2)>3) or (length(st2)<1) then flag:=false;\nend;\n\nprocedure work;\nvar p : longint;\n nam : string;\nbegin\n p:=pos('.',st);\n nam:=copy(st,1,p);\n write(nam);\n delete(st,1,p);\n p:=pos('.',st);\n while (p>0) do\n begin\n if (p>4) then\n begin\n nam:=copy(st,1,3);\n writeln(nam);\n delete(st,1,3);\n dec(p,3);\n nam:=copy(st,1,p);\n write(nam);\n delete(st,1,p);\n end else\n begin\n nam:=copy(st,1,p-2);\n writeln(nam);\n delete(st,1,p-2);\n nam:=copy(st,1,2);\n write(nam);\n delete(st,1,2);\n end;\n p:=pos('.',st);\n end;\n writeln(st);\nend;\n\nbegin\n// assign(input,'b.in'); reset(input);\n// assign(output,'b.out'); rewrite(output);\n readln(st);\n check;\n if flag then writeln('YES') else writeln('NO');\n if flag then work;\nend."}, {"source_code": "uses math;\nVar q,t1,t2,t3,s:ansistring;\n ans,i,j,q1,q2,q3,x,f:longint;\n begin\n readln(s);\n ans:=-1;\n for i:=2 to length(s)-1 do\n for j:=i to length(s)-1 do\n begin\n t1:='';\n t2:='';\n t3:='';\n q1:=0;\n q2:=0;\n q3:=0;\n for f:=1 to i-1 do\n begin\n val(s[f],x);\n q1:=q1*10+x;\n t1:=t1+s[f];\n end;\n for f:=i to j do\n begin\n val(s[f],x);\n q2:=q2*10+x;\n t2:=t2+s[f];\n end;\n for f:=j+1 to length(s) do\n begin\n val(s[f],x);\n q3:=q3*10+x;\n t3:=t3+s[f];\n end;\n q:='YES';\n if (length(t1)>1) and (t1[1]='0') then q:='NO';\n if (length(t2)>1) and (t2[1]='0') then q:='NO';\n if (length(t3)>1) and (t3[1]='0') then q:='NO';\n if (q1>1000000) or (q2>1000000) or (q3>1000000) then q:='NO';\n if q='YES' then ans:=max(ans,q1+q2+q3);\n end;\n writeln(ans);\n end."}, {"source_code": "var\n i,j,l,x,ans:longint;\n s:string;\n\nfunction calca(l:longint; r:longint):longint;\nvar\n i,p:longint;\nbegin\n if (r-l>=6)or((r>l)and(ord(s[l])+ord(s[l+1])=96)) then exit(-1000000);\n p:=0;\n for i:=l to r do p:=p*10+ord(s[i])-48;\n exit(p);\nend;\n\nbegin\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n for j:=i+1 to l-1 do\n begin\n x:=calca(1,i)+calca(i+1,j)+calca(j+1,l);\n if x>ans then ans:=x;\n end;\n writeln(ans);\nend."}, {"source_code": "program A1;\nvar i,j,k,l,l1,l2,l3,ans:longint;\n s,s1,s2,s3:string;\n\nBegin\n\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n begin\n s3:=s;\n for j:=1 to l-1-i do\n begin\n s1:=copy(s3,1,i); delete(s3,1,i);\n s2:=copy(s3,1,j); delete(s3,1,j);\n val(s1,l1,k); val(s2,l2,k); val(s3,l3,k);\n if ((l1=0) and (s1<>'0')) or ((l1<>0) and (s1[1]='0')) or (l1>1000000) then continue;\n if ((l2=0) and (s2<>'0')) or ((l2<>0) and (s2[1]='0')) or (l2>1000000) then continue;\n if ((l3=0) and (s3<>'0')) or ((l3<>0) and (s3[1]='0')) or (l3>1000000) then continue;\n if (ans'0') or (y-x+1=1)) then\n begin\n\t\tfor i:=x to y do s1:=s1+st[i];\n \tval(s1,so,code);\n \tif so>1000000 then tong:=0\n \t else n:=n+so;\n end\n else tong:=0;\nend;\nprocedure xuli;\nvar i,j,lc,p:integer;\nbegin\n\tread(f,st); p:=0;\n for i:=1 to length(st) do\n \tif st[i]<>'0' then\n \tbegin\n \tp:=1; break;\n end;\t\n if p=1 then\n begin\t\t\n max:=0; lc:=0;\n for i:=1 to length(st)-2 do\n \tfor j:=i+1 to length(st)-1 do\n \tbegin\n n:=0;\n if (tong(1,i)<>1) then break\n else\n if (tong(i+1,j)=1) and (tong(j+1,length(st))=1) then\n \t if n>max then\n \tbegin\n \tmax:=n;\n lc:=1;\n end;\n \tend;\t\n if lc=1 then\n write(g,max)\n else write(g,-1);\n end\n else\n \twrite(g,-1);\nend;\nbegin\n\tassign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n xuli;\n close(g);\nend.\n"}, {"source_code": "var\n s,y,h,e :string;\n ans,x,r,z : int64;\n i,j,g,uu : longint;\n code :integer;\nbegin\n readln(S);\n ans:=-1;\n for i:=1 to lengtH(S)-1 do\n for j:=i+1 to length(s) do\n begin\n y:='';\n for uu:=1 to i do y:=y+s[uu];\n if ((y[1]='0') and (lengtH(y)>1)) or (length(y)>=7) or (length(y)=0)then break;\n e:='';\n for uu:=i+1 to j do e:=e+s[uu];\n if ((e[1]='0') and (lengtH(e)>1)) or (lengtH(e)>=7) or (length(e)=0)then break;\n h:='';\n for uu:=j+1 to lengtH(s) do h:=h+s[uu];\n if ((h[1]='0') and (lengtH(h)>1)) or (length(h)>=7) or (length(h)=0)then break;\n val(y,x,code);\n val(e,r,code);\n val(h,z,code);\n if x>=1000000 then break;\n if r>=1000000 then break;\n if z>=1000000 then break;\n if x+r+z>ans then ans:=x+r+z;\n end;\n writeln(ans);\nend."}, {"source_code": "Uses math;\nvar j,i,n,num,ans,ans1,ans2,o,k,p,ww:longint;\n a,b:array[1..30] of longint;\n s:string;\n begin\n readln(s);\n n:=length(s);\n if (n>21)or(n<3) then\n begin\n writeln(-1);\n exit;\n end;\n if (s[1]='0')and(s[2]='0')and(s[3]='0') then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to n do\n begin\n if (s[i]='0') then inc(ww)\n else ww:=0;\n if ww>6 then\n begin\n writeln(-1);\n exit;\n end;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to min(i+min(n-3,6),n) do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if (k=0)or((k=1)and(a[k]=0)) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans then\n begin\n ans:=a[i];\n num:=b[i];\n end;\n delete(s,num,num+min(n-3,7)-1);\n n:=length(s);\n fillchar(a,sizeof(a),0);\n k:=0;\n if n=2 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans);\n exit;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to min(i+min(n-3,6),n) do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if ((k=1)and(a[k]=0))or(k=0) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans1 then\n begin\n ans1:=a[i];\n num:=b[i];\n end;\n delete(s,num,num+min(n-3,7)-1);\n n:=length(s);\n fillchar(a,sizeof(a),0);\n k:=0;\n if n=2 then\n begin\n for i:=1 to length(s) do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans+ans1+ans2);\n exit;\n end;\n for i:=1 to n-1 do\n begin\n inc(k);\n if s[i]<>'0' then\n for j:=i to n do\n begin\n val(s[j],o,p);\n a[k]:=a[k]*10+o;\n b[k]:=i;\n end;\n if (a[k]>1000000)or(s[i]='0') then\n begin\n a[k]:=0;\n dec(k);\n end;\n end;\n if (k=0)or((a[k]=0)and(k=1)) then\n begin\n writeln(-1);\n exit;\n end;\n for i:=1 to k do\n if a[i]>ans2 then\n begin\n ans2:=a[i];\n num:=b[i];\n end;\n delete(s,num,n);\n if n-num>7 then\n begin\n writeln(-1);\n exit;\n end;\n if (length(s)>0)or(ans+ans1+ans2>30000000) then writeln(-1)\n else writeln(ans+ans1+ans2);\n end.\n"}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,a1,a2,a3,s1,s2,s3:longint;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if ((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0')) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program pa;\nvar\n\ts:string;\n\ta:array[0..101] of longint;\n\tn,i1,i2,i3,i,j,k,ans,t:longint;\n\nfunction max(x,y:longint):longint;\nbegin\n\tif x>y then exit(x) else exit(y);\nend;\n\nfunction check(x,y,z:longint):boolean;\nvar\n t:longint;\nbegin\n\tt:=1;\n\tif (s[t]='0')and(x<>1) then exit(false);\n\tt:=x+1;\n\tif (s[t]='0')and(y<>1) then exit(false);\n\tt:=x+y+1;\n\tif (s[t]='0')and(z<>1) then exit(false);\n check:=true;\nend;\n\nfunction work(x,y:longint):longint;\nvar\n\ti,t:longint;\nbegin\n\tt:=0;\n for i:=x to y do t:=t*10+a[i];\n\texit(t);\nend;\n\nbegin\n\treadln(s);\n\tif length(s)>21 then begin writeln('-1');halt;end;\n\tfor i:=1 to length(s) do a[i]:=ord(s[i])-ord('0');\n\tans:=-1;\n\tfor i1:=1 to 7 do\n\t\tfor i2:=1 to 7 do\n\t\t\tfor i3:=1 to 7 do\n\t\t\t\tif (i1+i2+i3=length(s))and(check(i1,i2,i3)) then\n\t\t\t\t\tans:=max(ans,work(1,i1)+work(i1+1,i2+i1)+work(i1+i2+1,i3+i2+i1));\n\twriteln(ans);\nend.\n"}, {"source_code": "var\n s:ansistring;\n i,m,n,k,l,w,j,w1,w2,w3,res:longint;\nbegin\n readln(s);\n n:=length(s);\n res:=-1;\n for i:=1 to n do if i<=6 then\n begin\n for j:=i+1 to n-1 do if j-i<=6 then if n-j<=6 then\n begin\n if ((s[1]='0')and(i<>1))\n or ((s[i]='0')and(j-i<>1))\n or ((s[j]='0')and(n-j<>1)) then continue;\n val(copy(s,1,i),w1);\n val(copy(s,i+1,j-i),w2);\n val(copy(s,j+1,n),w3);\n if w1+w2+w3>res then res:=w1+w2+w3;\n end;\n end;\n writeln(res);\nend.\n\n"}, {"source_code": "uses math;\n\nvar\n\ts, a, b, c : string;\n\tatb, i, j : longint;\n\t\nfunction v(s : string) : longint;\nvar k, t : longint;\nbegin\n\tval(s, t, k);\n\tif t > 1000000 then t := -t * 100;\n\texit(t);\nend;\n\t\nbegin\n\tatb := -1;\n\treadln(s);\n\tfor i := 2 to length(s) - 1 do for j := i + 1 to length(s) do begin\n\ta := copy(s, 1, i - 1);\n\tb := copy(s, i, j - i);\n\tc := copy(s, j, length(s) - j + 1);\n\tif (length(a) > 7) or (length(b) > 7) or (length(c) > 7) then continue;\n\tif (length(a) = 0) or (length(b) = 0) or (length(c) = 0) then continue;\n\tif (a[1] = '0') and (a <> '0') then continue;\n\tif (b[1] = '0') and (b <> '0') then continue;\n\tif (c[1] = '0') and (c <> '0') then continue;\n\tatb := max(atb, v(a) + v(b) + v(c));\n\tend;\n\t\n\t\n\twriteln(atb);\n\nend."}, {"source_code": "var\n s:ansistring;\n i,m,n,k,l,w,j,w1,w2,w3,res:longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do if i<=6 then\n begin\n for j:=i+1 to n-1 do if j-i<=6 then if n-j<=6 then\n begin\n if ((s[1]='0')and(i<>1))\n or ((s[i]='0')and(j-i<>1))\n or ((s[j]='0')and(n-j<>1)) then continue;\n val(copy(s,1,i),w1);\n val(copy(s,i+1,j-i),w2);\n val(copy(s,j+1,n),w3);\n if w1+w2+w3>res then res:=w1+w2+w3;\n end;\n end;\n if res=0 then writeln(-1) else writeln(res);\nend.\n\n"}, {"source_code": "program va;\nvar t:string;\n i,j,k,max,min:longint;\n t1,t2,t3:longint;\n s1,s2,s3:string;\nfunction pd(a,b,c:string):boolean;\nvar t:longint;\nbegin\npd:=true;\nif (a[1]='0') and (length(a)<>1) then exit(false);\nif (b[1]='0') and (length(b)<>1) then exit(false);\nif (c[1]='0') and (length(c)<>1) then exit(false);\nend;\nbegin\n read(t);\n max:=-1;\n for i:=1 to length(t) do\n for j:=i+1 to length(t) do\n for k:=j+1 to length(t) do\n begin\n s1:=copy(t,1,(j-1));\n s2:=copy(t,j,(k-1)-j+1);\n s3:=copy(t,k,length(t));\n if pd(s1,s2,s3)=false then break;\n val(s1,t1); val(s2,t2); val(s3,t3);\n if max<(t1+t2+t3) then max:=t1+t2+t3;\n end;\n write(max);\nend.\n\n\n"}, {"source_code": "{$r-, s-, q-, i-, o+}\nvar\n n, i, j, ans : longint;\n t1, t2, t3 : ansistring;\n x1, x2, x3 : longint;\n code : integer;\n s : ansistring;\nbegin\n ans := -maxlongint;\n readln(s);\n n := length(s);\n for i := 1 to n - 2 do\n for j := i + 1 to n - 1 do\n begin\n t1 := copy(s, 1, i);\n t2 := copy(s, i + 1, j - i);\n t3 := copy(s, j + 1, n - j);\n if ((t1[1] = '0') and (length(t1) > 1))\n or ((t2[1] = '0') and (length(t2) > 1))\n or ((t3[1] = '0') and (length(t3) > 1)) then continue;\n if (length(t1) > 6) or (length(t2) > 6) or (length(t3) > 6) then continue;\n val(t1, x1, code); val(t2, x2, code); val(t3, x3, code);\n if (x1 > 1000000) or (x2 > 1000000) or (x3 > 1000000) then continue;\n if (x1 + x2 + x3 > ans) then ans := x1 + x2 + x3;\n end;\n if (ans = -maxlongint) then writeln(-1) else writeln(ans);\nend."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(k'0') then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program sol;\n{\nProblem A\nRobot Bicorn Attack\nstart at 16:30 \n}\nvar\n s:string;\n s1,s2,s3,i,j,ans:longint;\nfunction tr(const s:string):longint;\nvar code:integer; tmp:longint;\nbegin\n if length(s)=0 then exit(-1);\n if length(s)>7 then exit(-1);\n if length(s)=1 then exit(ord(s[1])-48);\n if s[1]='0' then exit(-1);\n val(s,tmp,code);\n if tmp>=1000000 then exit(-1);\n exit(tmp);\nend;\nbegin\n readln(s); ans:=-1;\n for i:=1 to length(s) do begin\n\ts1:=tr(copy(s,1,i));\n\tif s1=-1 then continue;\n\tfor j:=1 to length(s)-i do begin\n\t s2:=tr(copy(s,i+1,j));\n\t if s2=-1 then continue;\n\t s3:=tr(copy(s,i+j+1,30));\n\t if s3=-1 then continue;\n\t if s1+s2+s3>ans then ans:=s1+s2+s3;\n\tend;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,a1,a2,a3,s1,s2,s3:longint;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if ((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0')) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k= l-k then v:=true ;\n if k=0 then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar s:string;\n i,j,n:integer;\n sum:int64;\nbegin\n readln(s);\n n:=length(s);\n sum:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n if (i>6) or (j-i>6) or ( n-j>6) or\n ((s[1]='0') and (i>1)) or ((s[i+1]='0') and (j>i+1)) or ((s[j+1]='0') and (n>j+1)) then\n else\n sum:=max(sum,strtoint(copy(s,1,i)) + strtoint(copy(s,i+1,j-i)) + strtoint(copy(s,j+1,n-j)));\n end;\n writeln(sum);\nend."}, {"source_code": "const\n maxn=1000000;\n\nvar\n st : string;\n len, ans : longint;\n\nfunction min(a, b : longint) : longint;\nbegin\n if (a6) then continue;\n s1:=copy(st,1,i);\n s2:=copy(st,i+1,j);\n s3:=copy(st,i+j+1,k);\n val(s1,f1,code);\n val(s2,f2,code);\n val(s3,f3,code);\n if (f1>maxn) or (f2>maxn) or (f3>maxn) then continue;\n if (s1[1]='0') and (i>1) then continue;\n if (s2[1]='0') and (j>1) then continue;\n if (s3[1]='0') and (k>1) then continue;\n if (f1+f2+f3>ans) then ans:=f1+f2+f3;\n end;\n writeln(ans);\nend;\n\nbegin\n// assign(input,'a.in'); reset(input);\n// assign(output,'a.out'); rewrite(output);\n readln(st);\n len:=length(st);\n if (len>=19) then writeln(-1) else work;\nend."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(kj then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "var ss,s:string; a,b,c,k:int64;\n i,j,t:byte;\nbegin\nreadln(s);\nk:=-1;\nt:=length(s) div 3;\nif t<=7 then\nfor i:=1 to length(s) do\n for j:=i+t to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k);\nend.\n"}, {"source_code": "\n {$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n s:string;\n i,j,n,c,k,q,g,w:longint;\n sum1,sum2,sum3:int64;\n sum:int64;\n mas:array[1..30] of longint;\n B,v:BOOLEAN;\nbegin\n readln(S);\n n:=length(s);\ni:=0;\nb:=true;\nsum1:=0;\nsum2:=0;\nsum3:=0;\nsum:=0;\nb:=false;\n repeat\n inc(i);\n c:=ord(s[i])-48;\n if (i=2) and (sum1=0) then begin\n break;\n end;\n sum1:=sum1*10+c;\n if (sum1>1000000) then break;\n j:=i;\n sum2:=0;\n\n repeat\n inc(j);\n v:=false;\n q:=ord(s[j])-48;\n if (j=i+2) and (sum2=0) then break;\n sum2:=sum2*10+q;\n if (sum2>1000000) then break;\n sum3:=0;\n for g:=j+1 to n do begin\n w:=ord(s[g])-48;\n if (g=j+2) and (sum3=0) then begin\n v:=true;\n break;\n end;\n sum3:=sum3*10+w;\n if (sum3>1000000) then begin\n v:=true;\n break;\n end;\n end;\n if (v=false) then begin\n b:=true;\n if (sum1+sum2+sum3>sum) then sum:=sum1+sum2+sum3;\n end;\n\n until(j=n-1);\n until(i=n-2);\nif (b=true) then writeln(sum) else writeln('-1');\nend.\n"}, {"source_code": "var ss,s:string; a,b,c,k:int64;\n i,j,t:byte;\nbegin\nreadln(s);\nk:=-1;\nt:=length(s) div 3;\nif t<=7 then\nfor i:=1 to length(s) do\n for j:=i+t to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k);\nend.\n"}, {"source_code": "Uses math;\nvar s:string;\n a:array[1..30] of longint;\n i,j,num,ans,n,p,o:longint;\n begin\n readln(s);\n n:=length(s);\n if (s[1]='0')and(s[2]='0')and(s[3]='0') then writeln(-1)\n else\n if n<3 then writeln(-1)\n else\n if n>18 then writeln(-1)\n else\n begin\n for i:=1 to n do\n begin\n for j:=i to min(i+n-3,n) do\n begin\n val(s[j],o,p);\n a[i]:=a[i]*10+o;\n end;\n end;\n for i:=1 to n do\n if a[i]>ans then\n begin\n ans:=a[i];\n num:=i;\n end;\n for i:=1 to n do\n begin\n val(s[i],o,p);\n if (inum+n-2) then\n ans:=ans+o;\n end;\n writeln(ans);\n end;\n end."}, {"source_code": "Program Launcelot;\nvar s,s1,s2,s3:string;\n i,j,k,n,ans,ii:longint;\n l,a:array[1..3]of longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n-2 do\n for j:=1 to n-i-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,i+j+1,n-i+j);\n l[1]:=length(s1); l[2]:=length(s2); l[3]:=length(s3);\n if (l[1]>1)and(s1[1]='0')and((ans=0)or(ans=-1)) then\n begin\n ans:=-1;\n end\n else\n if (l[2]>1)and(s2[1]='0')and((ans=-1)or(ans=0)) then\n begin\n ans:=-1;\n end\n else\n if (l[3]>1)and(s3[1]='0')and((ans=-1)or(ans=0)) then\n begin\n ans:=-1;\n end\n else\n begin\n fillchar(a,sizeof(a),0);\n for ii:=1 to l[1] do\n a[1]:=a[1]*10+ord(s1[ii])-ord('0');\n for ii:=1 to l[2] do\n a[2]:=a[2]*10+ord(s2[ii])-ord('0');\n for ii:=1 to l[3] do\n a[3]:=a[3]*10+ord(s3[ii])-ord('0');\n if (a[1]+a[2]+a[3]>ans)and(a[1]+a[2]+a[3]<=1000000) then ans:=a[1]+a[2]+a[3];\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k=l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n if (s[1]='0')and(kj then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "var\n st,st1,st2,st3:string;\n i,j,max1,len,shu1,shu2,shu3,sum:longint;\nbegin\n readln(st);\n len:=length(st);\n max1:=-1;\n if length(st)<=18 then\n for i:=2 to len-1 do\n for j:=i+1 to len do\n begin\n st1:=copy(st,1,i-1);\n st2:=copy(st,i,j-i);\n st3:=copy(st,j,len-j+1);\n if length(st1)>7 then continue;\n if length(st2)>7 then continue;\n if length(st3)>7 then continue;\n if(length(st1)>1)and(st1[1]='0')then continue;\n if(length(st2)>1)and(st2[1]='0')then continue;\n if(length(st3)>1)and(st3[1]='0')then continue;\n val(st1,shu1);\n val(st2,shu2);\n val(st3,shu3);\n if(shu1>1000000)or(shu2>1000000)or(shu3>1000000)then\n continue;\n sum:=shu1+shu2+shu3;\n if sum>max1 then max1:=sum;\n end;\n writeln(max1);\n readln;\nend."}, {"source_code": "program Project2;\nuses SysUtils;\nvar n,n1,n2,n3,min,i,j:integer;\ns3,s1,s2,s:string;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(s);\n min:=-1;\n n:=Length(s);\n s1:='';\n for i:=1 to n-2 do\n begin\n s1:=s1+s[i];\n if (s1='0')or(s1[1]<>'0')\n then begin\n s2:='';\n\n for j:=i+1 to n-1 do\n begin\n s2:=s2+s[j];\n if (s2='0')or(s2[1]<>'0')\n then begin\n s3:=Copy(s,j+1,Length(s)-j);\n if (s3='0')or(s3[1]<>'0')\n then begin\n if ((Length(s2)<7)or(s2='1000000'))and((Length(s1)<7)or(s1='1000000'))and((Length(s3)<7)or(s2='1000000'))\n then begin\n n2:=StrToInt(s2);\n n1:=StrToInt(s1);\n n3:=StrToInt(s3);\n if n3+n2+n1>min\n then min:=n3+n2+n1;\n end;\n end;\n end;\n end; \n end;\n end;\n if min<>-1\n then Writeln(min)\n else writeln(-1);\nend.\n"}, {"source_code": "program va;\nvar t:string;\n i,j,k:longint;\n t1,t2,t3,max,min:int64;\n s1,s2,s3:string;\nfunction pd(a,b,c:string):boolean;\nvar t:longint;\nbegin\npd:=true;\nif (a[1]='0') and (length(a)>1) then exit(false);\nif (b[1]='0') and (length(b)>1) then exit(false);\nif (c[1]='0') and (length(c)>1) then exit(false);\nend;\nprocedure sp;\nbegin\n write('-1');\n halt;\nend;\nbegin\n read(t);\n max:=-1;\n if length(t)>21 then sp;\n for i:=1 to length(t)-2 do\n for j:=i+1 to length(t)-1 do\n for k:=j+1 to length(t) do\n begin\n s1:=copy(t,1,(j-1));\n s2:=copy(t,j,(k-1)-j+1);\n s3:=copy(t,k,length(t));\n if pd(s1,s2,s3)=false then break;\n val(s1,t1); val(s2,t2); val(s3,t3);\n if t1>1000000 then break;\n if t2>1000000 then break;\n if t3>1000000 then break;\n if max<(t1+t2+t3) then max:=t1+t2+t3;\n end;\n writeln(max);\nend.\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>1)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 7 do\n if ((i+j)1)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>0)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<3000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,s1,s2,s3:string;\n i,j,max:longint;\n\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(s);\n close(input);\nend;\n\nprocedure tinh2;\nvar a,b,c,code:longint;\nbegin\n s2:=copy(s,i+1,j);\n if (s2[1]='0') and (s2<>'0') then exit;\n s3:=copy(s,i+j+1,length(s)-i-j);\n if (s3[1]='0') and (s3<>'0') then exit;\n val(s1,a,code); val(s2,b,code); val(s3,c,code);\n if a+b+c> max then max:=a+b+c;\nend;\n\nprocedure tinh;\nbegin\n s1:=copy(s,1,i);\n if (s1[1]='0') and (s1<>'0') then exit;\n for j:=1 to length(s)-i-1 do tinh2;\nend;\n\n\nprocedure xuly;\nbegin\n for i:=1 to length(s)-2 do tinh;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n if max<0 then write(-1) else write(max);\n close(output);\nend;\n\nbegin\n doc;\n max:=-MaxLongint;\n xuly;\n ghi;\nend.\n"}, {"source_code": "Var s, s2, s3, s4 : string;\n i, j, res, k, n : longint;\n\nFunction tong(s2,s3,s4:string):longint;\n Var i, j, k, f, s : longint;\n Begin\n val(s2,i,f);\n val(s3,j,f);\n val(s4,k,f);\n s := i + j + k;\n tong := s;\n End;\n\nBegin\n readln(s);\n n := length(s);\n for i:=1 to n-2 do begin\n s2 := copy(s,1,i);\n if (s2[1] <> '0') or (s2 = '0') then\n for j:=i+1 to n-1 do begin\n s3 := copy(s,i+1,j-i);\n if (s3[1] <> '0') or (s3 = '0') then begin\n s4 := copy(s,j+1,n-j+2);\n if (s4[1] <> '0') or (s4 = '0') then begin\n k := tong(s2,s3,s4);\n if res < k then res := k;\n end;\n end;\n end;\n end;\n for i:=n downto 3 do begin\n s2 := copy(s,i,n-i+1);\n if (s2[1] <> '0') or (s2 = '0') then\n for j:=i-1 downto 2 do begin\n s3 := copy(s,j,i-j);\n if (s3[1] <> '0') or (s3 = '0') then begin\n s4 := copy(s,1,j-1);\n if (s4[1] <> '0') or (s4 = '0') then begin\n k := tong(s2,s3,s4);\n if res < k then res := k;\n end;\n end;\n end;\n end;\n if res <> 0 then\n writeln(res)\n else writeln(-1);\nEnd.\n"}, {"source_code": "var a:array[1..40] of longint;\n answer,x1,x2,x3:int64;\n i,j,n:longint;\n ch:char;\n\n function find(l,r:longint):int64;\n var res:int64;\n i:longint;\n begin\n res:=0;\n if (r-l+1>1) and (a[l]=0) then exit(-1);\n for i:=l to r do\n begin\n res:=res*10+a[i];\n if res>1000000 then exit(-1);\n end;\n exit(res);\n end;\n\n begin\n read(ch);\n while ch in['0'..'9'] do\n begin\n inc(n);\n a[n]:=ord(ch)-ord('0');\n read(ch);\n end;\n answer:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n x1:=find(1,i);\n x2:=find(i+1,j);\n x3:=find(j+1,n);\n if (x1<0) or (x2<0) or (x3<0) then continue;\n if x1+x2+x3>1000000 then continue;\n if x1+x2+x3>answer then answer:=x1+x2+x3;\n end;\n writeln(answer);\n end.\n\n"}, {"source_code": "var n,i,j,a,b,c,l,k,max:longint;\n s,s1,s2,s3:string[35];\n p:integer;\nbegin\n max:=-1;\n readln(s);\n n:=length(s);\n for j:=1 to n-2 do\n begin\n s1:=copy(s,1,j);\n for i:=1 to n-j-1 do\n begin\n s2:=copy(s,j+1,i);\n s3:=copy(s,j+i+1,n-i-j+1);\n if (length(s1)<8) and (length(s2)<8) and (length(s3)<8) then\n begin\n if ((s1[1]<>'0') or (length(s1)=1)) and\n ((s2[1]<>'0') or (length(s2)=1)) and\n ((s3[1]<>'0') or (length(s3)=1)) then\n begin\n val(s1,a,p);\n val(s2,b,p);\n val(s3,c,p);\n if (a<=1000000) and (b<=1000000) and (c<=1000000) then k:=a+b+c;\n if k>max then max:=k;\n end;\n end;\n end;\n end;\n if max=-1 then write(-1)\n else write(max);\nend.\n"}, {"source_code": "program sol;\n{\nProblem A\nRobot Bicorn Attack\nstart at 16:30 \n}\nvar\n s:string;\n s1,s2,s3,i,j,ans:longint;\nfunction tr(const s:string):longint;\nvar code:integer; tmp:longint;\nbegin\n if length(s)=0 then exit(-1);\n if length(s)>7 then exit(-1);\n if length(s)=1 then exit(ord(s[1])-48);\n if s[1]='0' then exit(-1);\n val(s,tmp,code);\n if tmp>1000000 then exit(-1);\n exit(tmp);\nend;\nbegin\n readln(s); ans:=-1;\n for i:=1 to length(s) do begin\n\tif (tr(copy(s,1,i))=-1) then break;\n\ts1:=tr(copy(s,1,i));\n\tfor j:=1 to length(s)-i do begin\n\t if (tr(copy(s,i+1,j))=-1) then break;\n\t s2:=tr(copy(s,i+1,j));\n\t if (tr(copy(s,i+j+1,30))=-1) then break;\n\t s3:=tr(copy(s,i+j+1,30));\n\t if s1+s2+s3>ans then ans:=s1+s2+s3;\n\tend;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>1)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 7 do\n if ((i+j)1)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>0)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<3000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,s1,s2,s3:string;\n i,j,max:longint;\n\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(s);\n close(input);\nend;\n\nprocedure tinh2;\nvar a,b,c,code,dk:longint;\nbegin\n s2:=copy(s,i+1,j); dk:=0;\n if (s2<>'1000000') and (length(s2)>=7) then\n begin\n s2:=copy(s,i+1,6); dk:=1;\n end;\n if (s2[1]='0') and (s2<>'0') then exit;\n if length(s)-i-j+dk>7 then exit\n else if length(s)-i-j+dk=7 then\n begin\n s3:=copy(s,i+j+1,7);\n if (s3<>'1000000') and (length(s3)>=7) then exit;\n end\n else s3:=copy(s,i+j-dk+1,length(s)-i-j+dk);\n if (s3[1]='0') and (s3<>'0') then exit;\n val(s1,a,code); val(s2,b,code); val(s3,c,code);\n if a+b+c> max then max:=a+b+c;\nend;\n\nprocedure tinh;\nbegin\n s1:=copy(s,1,i);\n if (i=7) and (s1<>'1000000') then s1:=copy(s,1,i-1);\n if (s1[1]='0') and (s1<>'0') then exit;\n for j:=1 to length(s)-i-1 do\n begin\n if j>7 then exit;\n tinh2;\n end;\nend;\n\n\nprocedure xuly;\nbegin\n for i:=1 to length(s)-2 do\n begin\n if i>7 then exit;\n tinh;\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n if max<0 then write(-1) else write(max);\n close(output);\nend;\n\nbegin\n doc;\n max:=-MaxLongint;\n xuly;\n ghi;\nend.\n"}, {"source_code": "Var s, s2, s3, s4 : string;\n i, j, res, k, n : longint;\n\nFunction tong(s2,s3,s4:string):longint;\n Var i, j, k, f, s : longint;\n Begin\n val(s2,i,f);\n val(s3,j,f);\n val(s4,k,f);\n s := i + j + k;\n tong := s;\n End;\n\nBegin\n readln(s);\n n := length(s);\n for i:=1 to 7 do begin\n if i > n-2 then break;\n s2 := copy(s,1,i);\n if (s2[1] = '0') and (length(s2) <> 1) then continue;\n if (length(s2) = 7) and (s2 > '1000000') then continue;\n for j:=1 to 7 do begin\n if j = n-1 then break;\n s3 := copy(s,i+1,j);\n s4 := copy(s,i+j+1,n-i-j);\n if s4 = '' then break; \n if ((s3[1] = '0') and (length(s3) <> 1)) or ((s4[1] = '0') and (length(s4) <> 1)) then continue;\n if ((s3 > '1000000') and (length(s3) = 7)) or ((s4 > '1000000') and (length(s4) = 7)) then continue;\n if res < tong(s2,s3,s4) then res := tong(s2,s3,s4);\n end;\n end;\n if res = 0 then writeln(-1) else\n writeln(res);\nEnd.\n"}, {"source_code": "var n,i,j,a,b,c,l,k,max:longint;\n s,s1,s2,s3:string[35];\n p:integer;\nbegin\n max:=-1;\n readln(s);\n n:=length(s);\n for j:=1 to n-2 do\n begin\n s1:=copy(s,1,j);\n for i:=1 to n-j-1 do\n begin\n s2:=copy(s,j+1,i);\n s3:=copy(s,j+i+1,n-i-j+1);\n if (length(s1)<8) and (length(s2)<8) and (length(s3)<8) then\n begin\n if ((s1[1]<>'0') or (length(s1)=1)) and\n ((s2[1]<>'0') or (length(s2)=1)) and\n ((s3[1]<>'0') or (length(s3)=1)) then\n begin\n val(s1,a,p);\n val(s2,b,p);\n val(s3,c,p);\n if (a<=1000000) and (b<=1000000) and (c<=1000000) then k:=a+b+c;\n if k>max then max:=k;\n end;\n end;\n end;\n end;\n if max=-1 then write(-1)\n else write(max);\nend.\n"}, {"source_code": "var a:array[1..40] of longint;\n answer,x1,x2,x3:int64;\n i,j,n:longint;\n ch:char;\n\n function find(l,r:longint):int64;\n var res:int64;\n i:longint;\n begin\n res:=0;\n if (r-l+1>1) and (a[l]=0) then exit(-1);\n for i:=l to r do\n res:=res*10+a[i];\n exit(res);\n end;\n\n begin\n read(ch);\n while ch in['0'..'9'] do\n begin\n inc(n);\n a[n]:=ord(ch)-ord('0');\n read(ch);\n end;\n if n>18 then begin writeln(-1); halt; end;\n answer:=-1;\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n x1:=find(1,i);\n x2:=find(i+1,j);\n x3:=find(j+1,n);\n if (x1<0) or (x2<0) or (x3<0) then continue;\n if x1+x2+x3>1000000 then continue;\n if x1+x2+x3>answer then answer:=x1+x2+x3;\n end;\n writeln(answer);\n end.\n\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>1)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 7 do\n if ((i+j)1)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>0)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<1000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "var a,b,c,s:string;\n q,w,z,e,i,j,k,r,x,y,o,p,max:longint;\n begin\n max:=-1;\n readln(s);\n for i:=1 to 7 do\n for j:=1 to 7 do\n begin\n x:=0;\n y:=0;\n k:=0;\n z:=0;\n w:=0;\n e:=0;\n a:=copy(s,1,i);\n b:=copy(s,i+1,j);\n c:=copy(s,i+j+1,length(s)-i-j);\n for q:=1 to i do\n begin\n val(a[q],o,p);\n x:=x*10+o;\n if (x=0)and(o=0) then inc(z);\n end;\n for q:=1 to length(b) do\n begin\n val(b[q],o,p);\n y:=y*10+o;\n if (y=0)and(o=0) then inc(w);\n end;\n for q:=1 to length(c) do\n begin\n val(c[q],o,p);\n k:=k*10+o;\n if (k=0)and(o=0) then inc(e);\n end;\n if ((x>0)and(z>0)) or\n ((y>0)and(w>0)) or\n ((k>0)and(e>0)) or\n ((length(c)>=6)and(c<>'1000000')) then continue\n else\n if (x+y+k>max)and(a<>'')and(z<2)and(w<2)and(e<2)and(b<>'')and(c<>'')and(x<=1000000)and(y<=1000000)and(k<=1000000) then max:=x+y+k;\n end;\n writeln(max);\n end.\n"}, {"source_code": "program ta;\nvar\n s:string;\n n,i,j,a,b,c,d,x,y,z,max:longint;\n code:integer;\nbegin\n max:=-1;\n readln(s);\n n:=length(s);\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin\n a:=i;b:=j-i;c:=n-j;\n if a<=7 then\n if b<=7 then\n if c<=7 then\n if (s[1]<>'0')or(a=1) then\n if (s[i+1]<>'0')or(b=1) then\n if (s[j+1]<>'0')or(c=1) then\n begin\n val(copy(s,1,a),x,code);\n val(copy(s,i+1,b),y,code);\n val(copy(s,j+1,c),z,code);\n d:=x+y+z;\n if d>max then max:=d;\n end;\n end;\n if max=-1 then writeln(-1)\n else writeln(max);\nend.\n"}, {"source_code": "Program Launcelot;\nvar s,s1,s2,s3:string;\n i,j,k,n,ans,ii:longint;\n l,a:array[1..3]of longint;\n\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n-2 do\n for j:=1 to n-i-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j);\n s3:=copy(s,i+j+1,n-i+j);\n l[1]:=length(s1); l[2]:=length(s2); l[3]:=length(s3);\n if (l[1]>1)and(s1[1]='0')and(ans=-1) then\n begin\n ans:=-1;\n end\n else\n if (l[2]>1)and(s2[1]='0')and(ans=-1) then\n begin\n ans:=-1;\n end\n else\n if (l[3]>1)and(s3[1]='0')and(ans=-1) then\n begin\n ans:=-1;\n end\n else\n begin\n fillchar(a,sizeof(a),0);\n for ii:=1 to l[1] do\n a[1]:=a[1]*10+ord(s1[ii])-ord('0');\n for ii:=1 to l[2] do\n a[2]:=a[2]*10+ord(s2[ii])-ord('0');\n for ii:=1 to l[3] do\n a[3]:=a[3]*10+ord(s3[ii])-ord('0');\n if (a[1]+a[2]+a[3]>ans)and(a[1]+a[2]+a[3]<=1000000) then ans:=a[1]+a[2]+a[3];\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "var ss,s:string; a,b,c,k:int64;\n i,j,t:byte;\nbegin\nreadln(s);\nk:=-1;\nt:=length(s) div 3;\nif t<=7 then\nfor i:=1 to length(s) do\n for j:=i+t to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>7) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k);\nend.\n"}, {"source_code": "var ss,s:string; a,b,c,k:int64;\n i,j:byte;\nbegin\nreadln(s);\nk:=-1;\nfor i:=1 to length(s) do\n for j:=i+2 to length(s) do\n begin\n ss:=copy(s,1,i);\n val(ss,a);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>6) then continue;\n ss:=copy(s,i+1,j-i-1);\n val(ss,b);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>6) then continue;\n ss:=copy(s,j,length(s)-j+1);\n val(ss,c);\n if length(ss)>=2 then if (ss[1]='0')or(length(ss)>6) then continue;\n if a+b+c>k then k:=a+b+c;\n end;\nwriteln(k);\nend.\n"}, {"source_code": "(*\nProblem\t\t:\tCodeforces_175A\nAuthor\t\t:\tShuriken\nStart Time\t:\t2012-5-31 07:39\nFinish Time\t:\t\nResult\t\t:\t\nMethod\t\t:\tBrute Force\nErrors\t\t:\t\n*)\nProgram CF_175A;\nUses Math;\nConst\n\tmaxn\t\t\t\t\t\t=30+5;\nVar\n\ts,s1,s2,s3\t\t\t\t\t:string[maxn];\n\tans\t\t\t\t\t\t\t:longint;\n\t\nProcedure Init;\nBegin\n\treadln(s);\nEnd;\n\nFunction Calc:longint;\nVar a,b,c\t\t\t\t\t\t:longint;\nBegin\n\tif (length(s1)=0)or(length(s2)=0)or(length(s3)=0) then exit(-1);\n\tif (length(s1)>7)or(length(s2)>7)or(length(s3)>7) then exit(-1);\n\tif (length(s1)=7)and(s1<>'1000000') then exit(-1);\n\tif (length(s2)=7)and(s1<>'1000000') then exit(-1);\n\tif (length(s3)=7)and(s1<>'1000000') then exit(-1);\n\tif (length(s1)>1)and(s1[1]='0') then exit(-1);\n\tif (length(s2)>1)and(s2[1]='0') then exit(-1);\n\tif (length(s3)>1)and(s3[1]='0') then exit(-1);\n\n\t\n\tval(s1,a);\n\tval(s2,b);\n\tval(s3,c);\n\texit(a+b+c);\nEnd;\n\t\nProcedure Main;\nVar i,j\t\t\t\t\t\t\t:longint;\nBegin\n\tans:=-1;\n\t\n\tif length(s)>21 then exit;\n\t\n\tfor i:=1 to 7 do\n\t\tbegin\n\t\t\tif length(s)-i<2 then break;\n\t\t\ts1:=s1+s[i];\n\t\t\ts2:='';\n\t\t\tfor j:=i+1 to i+7 do\n\t\t\t\tbegin\n\t\t\t\t\tif length(s)-j<1 then break;\n\t\t\t\t\ts2:=s2+s[j];\n\t\t\t\t\ts3:=copy(s,j+1,length(s)-j);\n\t\t\t\t\tans:=max(ans,calc);\n\t\t\t\tend;\n\t\tend;\nEnd;\n\t\nProcedure Print;\nBegin\n\twriteln(ans);\nEnd;\n\t\nBegin\n\tInit;\n\tMain;\n\tPrint;\nEnd.\n"}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n{$define func:=function}\n{$define proc:=procedure}\n{$define be:=begin}\n{$define en:=end}\n{$define el:=else}\n{$define brk:=break}\n{$define th:=then}\n\nuses Classes, SysUtils, StrUtils, Math;\n\nvar\n\ts, ca, cb, cc: AnsiString;\n a, b, c, L, sa, sb, sc: Long;\n\tM: Int64;\n\nbegin\n\tRln(s);\n L := Length(s);\n if l < 3 th\n be\n \tWln(-1);\n exit;\n en;\n if s = '000' th\n be\n \tWln(0);\n exit;\n en;\n {if s[1] = '0' th\n be\n \tWln(-1);\n exit;\n en;}\n M := -1;\n for a := 1 to Min(7, L) do\n be\n \tca := Copy(s, 1, a);\n if ca <> '0' th\n\t if ca[1] = '0' th\n \t \tbrk;\n \tsa := StrToInt(ca);\n if Length(ca) > 7 th\n \tbrk;\n if Length(ca) = 7 th\n \tif sa > 1000000 th\n \tbrk;\n \tfor b := a + 1 to Min(a + 7, L - 1) do\n be\n \tcb := Copy(s, a + 1, b - (a + 1) + 1);\n \tif cb <> '0' th\n \tif cb[1] = '0' th\n \tbrk;\n sb := StrToInt(cb);\n if Length(cb) > 7 th\n \tbrk;\n if Length(cb) = 7 th\n if sb > 1000000 th\n \t\t\tbrk;\n //\n \tcc := Copy(s, b + 1, l);\n if cc <> '0' th\n \t\tif cc[1] = '0' th\n \t\tbrk;\n if Length(cc) > 7 th\n \tbrk;\n if Length(cc) = 7 th\n if sc > 1000000 th\n \t\t\tbrk;\n sc := StrToInt(cc);\n M := Max(M, sa + sb + sc);\n en;\n\ten;\n Wln(M);\nend.\n\n"}, {"source_code": "program sol;\n{\nProblem A\nRobot Bicorn Attack\nstart at 16:30 \n}\nvar\n s:string;\n s1,s2,s3,i,j,ans:longint;\nfunction tr(const s:string):longint;\nvar code:integer; tmp:longint;\nbegin\n if length(s)=0 then exit(-1);\n if length(s)>7 then exit(-1);\n if length(s)=1 then exit(ord(s[1])-48);\n if s[1]='0' then exit(-1);\n val(s,tmp,code);\n if tmp>=1000000 then exit(-1);\n exit(tmp);\nend;\nbegin\n readln(s); ans:=-1;\n for i:=1 to length(s) do begin\n\tif (tr(copy(s,1,i))=-1) then break;\n\ts1:=tr(copy(s,1,i));\n\tfor j:=1 to length(s)-i do begin\n\t if (tr(copy(s,i+1,j))=-1) then break;\n\t s2:=tr(copy(s,i+1,j));\n\t if (tr(copy(s,i+j+1,30))=-1) then break;\n\t s3:=tr(copy(s,i+j+1,30));\n\t if s1+s2+s3>ans then ans:=s1+s2+s3;\n\tend;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n s,p1,p2,p3: string;\n n,i,j,k: longint;\n x,y,z,ans: int64;\n \nbegin\n readln(s);\n ans := -1;\n n := length(s);\n p1 := '';\n for i := 1 to 7 do\n begin\n\t if i > n-2 then break;\n\t p1 := p1 + s[i];\n\t p2 := '';\n\t if (length(p1)>1) and (p1[1]='0') then break;\n\t for j := i+1 to i+7 do\n\t begin\n\t\t if j > n-1 then break;\n\t\t p2 := p2 + s[j];\n\t\t p3 := '';\n\t\t if n-j > 7 then continue;\n\t\t for k := j+1 to n do \n\t\t p3 := p3 + s[k];\n\t\t if (length(p2)>1) and (p2[1]='0') then break;\n\t\t if (length(p3)>1) and (p3[1]='0') then continue;\n\t\t val(p1,x); val(p2,y); val(p3,z);\n\t\t if x + y + z > 1000000 then continue;\n\t\t if x+y+z > ans then ans := x + y + z;\n\t\tend;\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "const fi='';\n fo='';\nvar i,j,k,res,a,b,c:longint;\n s1,s2,s3,s:string;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n read(s);\n res:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,length(s));\n if ((s1[1] = '0') and (length(s1) > 1)) or ((s2[1] = '0') and (length(s2) > 1)) or ((s3[1] = '0') and (length(s3) > 1)) then break;\n val(s1,a);\n val(s2,b);\n val(s3,c);\n k:=a+b+c;\n if k > res then res:=k;\n end;\n write(res);\nend.\n"}, {"source_code": "program sol;\n{\nRobot Bicorn Attack\nstart at 16:30\n}\nvar\n s:string;\n s1,s2,s3,i,j,ans:longint;\nfunction tr(const s:string):longint;\nvar code:integer; tmp:longint;\nbegin\n if length(s)=0 then exit(-1);\n if length(s)>7 then exit(-1);\n if length(s)=1 then exit(ord(s[1])-48);\n if s[1]='0' then exit(-1);\n val(s,tmp,code);\n if tmp>1000000 then exit(-1);\n exit(tmp);\nend;\nbegin\n readln(s); ans:=-1;\n for i:=1 to length(s) do begin\n\tif (tr(copy(s,1,i))=-1) then break;\n\ts1:=tr(copy(s,1,i));\n\tfor j:=1 to length(s)-i do begin\n\t if (tr(copy(s,i+1,j))=-1) then break;\n\t s2:=tr(copy(s,i+1,j));\n\t if (tr(copy(s,i+j+1,30))=-1) then break;\n\t s3:=tr(copy(s,i+j+1,30));\n\t if s1+s2+s3>ans then ans:=s1+s2+s3;\n\tend;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 6 do\n begin\n if ((i>0)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 6 do\n if ((i+j)0)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<1000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k= l-k then v:=true ;\n if k=0 then v:=true;\n if (s[1]<>'0') then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program Project2;\nuses SysUtils;\nvar n,n1,n2,n3,min,i,j:integer;\ns3,s1,s2,s:string;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(s);\n min:=-1;\n n:=Length(s);\n s1:='';\n for i:=1 to n-2 do\n begin\n s1:=s1+s[i];\n if (s1='0')or(s1[1]<>'0')\n then begin\n s2:='';\n\n for j:=i+1 to n-1 do\n begin\n s2:=s2+s[j];\n if (s2='0')or(s2[1]<>'0')\n then begin\n s3:=Copy(s,j+1,Length(s)-j);\n if (s3='0')or(s3[1]<>'0')\n then begin\n if ((Length(s2)<7)or(s2='1000000'))and((Length(s1)<7)or(s1='1000000'))and((Length(s3)<7)or(s2='1000000'))\n then begin\n n2:=StrToInt(s2);\n n1:=StrToInt(s1);\n n3:=StrToInt(s3);\n if n3+n2+n1>min\n then min:=n3+n2+n1;\n end;\n end;\n end;\n end; \n end;\n end;\n if min<>-1\n then Writeln(min)\n else writeln(-1);\nend.\n"}, {"source_code": "Uses math;\nvar s:string;\n a:array[1..30] of longint;\n i,j,num,ans,n,p,o,k:longint;\n begin\n readln(s);\n n:=length(s);\n if n=3 then\n begin\n for i:=1 to 3 do\n begin\n val(s[i],o,p);\n ans:=ans+o;\n end;\n writeln(ans);\n exit;\n end;\n if n=18 then\n begin\n for i:=1 to n do\n if (s[i]<>'0')and(s[i]<>'1') then\n begin\n writeln(-1);\n exit;\n end;\n end;\n for i:=1 to n do\n begin\n if s[i]='0' then inc(k)\n else k:=0;\n if k>5 then\n begin\n writeln(-1);\n exit;\n end;\n end;\n if (s[1]='0')and(s[2]='0')and(s[3]='0') then writeln(-1)\n else\n if n<3 then writeln(-1)\n else\n if n>18 then writeln(-1)\n else\n begin\n for i:=1 to n do\n begin\n for j:=i to min(i+n-3,n) do\n begin\n val(s[j],o,p);\n a[i]:=a[i]*10+o;\n end;\n end;\n for i:=1 to n do\n if a[i]>ans then\n begin\n ans:=a[i];\n num:=i;\n end;\n for i:=1 to n do\n begin\n val(s[i],o,p);\n if (inum+n-2) then\n ans:=ans+o;\n end;\n writeln(ans);\n end;\n end.\n"}, {"source_code": "const fi='';\n fo='';\nvar i,j,k,res,a,b,c:longint;\n s1,s2,s3,s:string;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n read(s);\n res:=-1;\n for i:=1 to length(s)-2 do\n for j:=i+1 to length(s)-1 do\n begin\n s1:=copy(s,1,i);\n s2:=copy(s,i+1,j-i);\n s3:=copy(s,j+1,length(s));\n if ((s1[1] = '0') and (length(s1) > 1)) or ((s2[1] = '0') and (length(s2) > 1)) or ((s3[1] = '0') and (length(s3) > 1)) then break;\n val(s1,a);\n val(s2,b);\n val(s3,c);\n k:=a+b+c;\n if k > res then res:=k;\n end;\n write(res);\nend.\n"}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n{$define func:=function}\n{$define proc:=procedure}\n{$define be:=begin}\n{$define en:=end}\n{$define el:=else}\n{$define brk:=break}\n{$define th:=then}\n\nuses Classes, SysUtils, StrUtils, Math;\n\nvar\n\ts, ca, cb, cc: AnsiString;\n a, b, c: Long;\n L, sa, sb, sc: Int64;\n\tM: Int64;\n\nbegin\n\tRln(s);\n L := Length(s);\n if l < 3 th\n be\n \tWln(-1);\n exit;\n en;\n if s = '000' th\n be\n \tWln(0);\n exit;\n en;\n {if s[1] = '0' th\n be\n \tWln(-1);\n exit;\n en;}\n M := -1;\n for a := 1 to Min(7, L - 2) do\n be\n \tca := Copy(s, 1, a);\n if ca <> '0' th\n\t if ca[1] = '0' th\n \t \tbrk;\n sa := StrToInt(ca);\n if a = 7 th\n \tif sa > 1000000 th\n brk;\n \tfor b := a + 1 to Min(a + 7, L - 1) do\n be\n \tcb := Copy(s, a + 1, b - (a + 1) + 1);\n \tif cb <> '0' th\n \tif cb[1] = '0' th\n \tbrk;\n if Length(cb) = 7 th\n be\n \tsb := StrToInt(cb);\n if sb > 1000000 th\n \t\t\tbrk;\n en;\n //\n \tcc := Copy(s, b + 1, l);\n //W(a, ' ', b, ': ');\n //Wln(ca, ' ', cb, ' ', cc);\n if cc <> '0' th\n \t\tif cc[1] = '0' th\n continue;\n if Length(cc) > 7 th\n \tcontinue;\n sc := StrToInt(cc);\n if Length(cc) = 7 th\n if sc > 1000000 th\n continue;\n M := Max(M, sa + sb + sc);\n en;\n\ten;\n Wln(M);\nend.\n\n"}, {"source_code": "program va;\nvar t:string;\n i,j,k:longint;\n t1,t2,t3,max,min:int64;\n s1,s2,s3:string;\nfunction pd(a,b,c:string):boolean;\nvar t:longint;\nbegin\npd:=true;\nif (a[1]='0') and (length(a)>1) then exit(false);\nif (b[1]='0') and (length(b)>1) then exit(false);\nif (c[1]='0') and (length(c)>1) then exit(false);\nend;\nprocedure sp;\nbegin\n write('-1');\n halt;\nend;\nbegin\n read(t);\n max:=-1;\n if length(t)>=21 then sp;\n for i:=1 to length(t) do\n for j:=i+1 to length(t) do\n for k:=j+1 to length(t) do\n begin\n s1:=copy(t,1,(j-1));\n s2:=copy(t,j,(k-j));\n s3:=copy(t,k,length(t));\n if pd(s1,s2,s3)=false then break;\n val(s1,t1); val(s2,t2); val(s3,t3);\n if t1>1000000 then break;\n if t2>1000000 then break;\n if t3>1000000 then break;\n if max<(t1+t2+t3) then max:=t1+t2+t3;\n end;\n write(max);\nend.\n"}, {"source_code": "var a1,a2,a3,p,n,m,j,i,k,l,max:longint;\nx,y,z,s:string;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(S);\nmax:=-1;\nfor i:=1 to length(s) do\n for j:=i+1 to length(s) do\n begin\n x:=copy(s,1,i);\n y:=copy(s,i+1,j-i);\n z:=copy(s,j+1,length(s)-j);\n if (length(x)=0)or(length(y)=0)or(length(z)=0) then continue;\n if (length(x)>1)and(x[1]='0') then continue;\n if (length(y)>1)and(y[1]='0') then continue;\n if (length(z)>1)and(z[1]='0') then continue;\n val(x,a1,p);\n val(y,a2,p);\n val(z,a3,p);\n if a1>1000000 then continue;\n if a2>1000000 then continue;\n if a3>1000000 then continue;\n if (a1+a2+a3>max)then max:=a1+a2+a3;\n end;\nwriteln(max);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n s:String;\n n,f,i,k,r,max,j:Integer;\n w:String;\nBegin\n Read(s);\n n:=length(s);\n f:=0;\n max:=0;\n For i:=1 To n-2 Do Begin\n If i>6 Then Break;\n For j:=i+1 To n-1 Do Begin\n r:=0;\n If (j-i)>5 Then Begin\n Continue;\n End;\n If (n-j)>5 Then Begin\n Continue;\n End;\n w:='';\n For k:=1 To i Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Break;\n w:='';\n For k:=i+1 To j Do w:=w+s[k];\n //Write(w,' ');\n If (w[1]='0') and (length(w)>1) Then Continue;\n If strtoint(w)>1000000 Then Break;\n r:=r+strtoint(w);\n w:='';\n For k:=j+1 To n Do w:=w+s[k];\n //Write(w,' ');\n //WriteLn;\n If (w[1]='0') and (length(w)>1) Then Continue;\n f:=1;\n r:=r+strtoint(w);\n If strtoint(w)>1000000 Then Break;\n If r>max Then max:=r;\n End;\n End;\n If f=0 Then Begin\n Write(-1);\n Halt;\n End;\n Write(max);\nEnd.\n\n\n"}, {"source_code": "program A1;\nvar i,j,k,l,l1,l2,l3,ans:longint;\n s,s1,s2,s3:string;\n\nBegin\n\n readln(s); l:=length(s);\n ans:=-1;\n for i:=1 to l-2 do\n begin\n s3:=s;\n for j:=1 to l-2 do\n begin\n s1:=copy(s3,1,i); delete(s3,1,i);\n s2:=copy(s3,1,j); delete(s3,1,j);\n val(s1,l1,k); val(s2,l2,k); val(s3,l3,k);\n if ((l1=0) and (s1<>'0')) or ((l1<>0) and (s1[1]='0')) or (l1>1000000) then continue;\n if ((l2=0) and (s2<>'0')) or ((l2<>0) and (s2[1]='0')) or (l2>1000000) then continue;\n if ((l3=0) and (s3<>'0')) or ((l3<>0) and (s3[1]='0')) or (l3>1000000) then continue;\n if (ans1000000) then break;\n j:=i;\n sum2:=0;\n\n repeat\n inc(j);\n v:=false;\n q:=ord(s[j])-48;\n if (j=i+2) and (sum2=0) then break;\n sum2:=sum2*10+q;\n if (sum2>1000000) then break;\n sum3:=0;\n for g:=j+1 to n do begin\n w:=ord(s[g])-48;\n if (g=j+2) and (sum3=0) then begin\n v:=true;\n break;\n end;\n sum3:=sum3*10+w;\n if (sum3>1000000) then begin\n v:=true;\n break;\n end;\n end;\n if (v=false) then begin\n b:=true;\n if (sum1+sum2+sum3>sum) then sum:=sum1+sum2+sum3;\n end;\n\n until(j=n-1);\n until(i=n-2);\nif (b=true) then writeln(sum) else writeln('-1');\nend.\n"}, {"source_code": "program Prog;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\nuses sysutils;\nvar\nst,a,s,d:string;\nn,sum,max:longint;\ni,j,k:integer;\n\nbegin\nreadln(st);\nn:=length(st);\nmax:=-1;\nif n>2 then\nfor i := 1 to n-2 do\n for j := i+1 to n-1 do\n begin\n\n a:=copy(st,1,i);\n s:=copy(st,i+1,j-i);\n d:=copy(st,j+1,n-j);\n if (length(a)<8)and(length(s)<8)and(length(d)<8) then\n if (length(inttostr(strtoint(a)))=length(a))and(length(inttostr(strtoint(s)))=length(s))and(length(inttostr(strtoint(d)))=length(d)) then begin\n sum:=strtoint(a)+strtoint(s)+strtoint(d);\n if (sum>max)and(sum<1000000) then max:=sum;\n end;\n end;\nwriteln(max);\nreadln;\nend.\n"}, {"source_code": "const nn=100;\nvar a:array[0..nn] of longint; tt:integer;\n n,i,j,y,z,t,k,x:longint;s:string;\nbegin\n read(s);\n y:=-1;\n z:=length(s);\n for i:=1 to 7 do\n begin\n if ((i>1)and(s[1]<>'0'))or (i=1) then\n begin\n val(copy(s,1,i),x,tt);\n for j:=1 to 7 do\n if ((i+j)1)and(s[i+1]<>'0'))or (j=1) then\n begin\n val(copy(s,1+i,j),k,tt);\n if ((z-i-j>1)and(s[i+j+1]<>'0'))or (z-i-j=1) then\n begin\n val(copy(s,1+i+j,z-i-j),t,tt);\n n:=x+k+t;\n if (n<1000001)and(n>y) then y:=n;\n end;\n end;\n end;\n end;\n end;\nwrite(y);\nend."}, {"source_code": "program ka;\nvar s,tmp1,tmp2,tmp3:string;\n i,j,ans,sum,l,k,a1,a2,a3,s1,s2,s3:longint;\n v:boolean;\nBegin\n readln(s);\n l:=length(s);\n for i:=1 to l do\n if s[i]='0' then inc(k);\n v:=false;\n if k= l-k then v:=true ;\n if k=0 then v:=true;\n for i:=1 to l-1 do\n for j:=i+1 to l-1 do\n if i<>j then\n begin\n tmp1:=copy(s,1,i);\n tmp2:=copy(s,i+1,j-i);\n tmp3:=copy(s,j+1,l-j);\n s1:=length(tmp1);\n s2:=length(tmp2);\n s3:=length(tmp3);\n if v=false and(((tmp1[1]='0')and(tmp1[s1]<>'0')) or((tmp2[1]='0')and (tmp2[s2]<>'0')) or((tmp3[1]='0')and(tmp3[s3]<>'0'))) then\n begin\n writeln(-1);\n halt;\n end;\n val(tmp1,a1);\n val(tmp2,a2);\n val(tmp3,a3);\n sum:=a1+a2+a3;\n if sum>ans then ans:=sum;\n end;\n writeln(ans);\nEnd."}, {"source_code": "program Project877;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i,j,k,len:integer;\n s,a,b,c:ansistring;\n flag:boolean;\n sum,max:extended;\nbegin\n readln(s);\n len := length(s);\n max := -1;\n j :=2;\n while (j < len) and (j<8) do\n begin\n k := j+1;\n while(k '0')or (length(a)=1)) and(strtofloat(a)<=1000000) then\n sum := sum + strtofloat(a)\n else\n flag := false;\n if ((b[1] <> '0')or (length(b)=1))and(strtofloat(b)<=1000000) then\n sum := sum + strtofloat(b)\n else\n flag := false;\n if ((c[1] <> '0')or (length(c)=1)) and(strtofloat(c)<=1000000) then\n sum := sum + strtofloat(c)\n else\n flag := false;\n if(sum>max)and(flag) then max := sum;\n inc(k);\n end;\n inc(j);\n end;\n writeln(max:0:0);\n readln;\n readln;\n\nend.\n"}], "src_uid": "bf4e72636bd1998ad3d034ad72e63097"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n fi,fo:Text;\n a,b,i,j,k,q,m: Integer;\n graph,antigraph: array [1..6,1..6] of Integer;\n\nbegin\n \n read(m);\n for i:=1 to 5 do\n for j:=1 to 5 do\n antigraph[i][j]:=1;\n\n for i:=1 to m do\n begin\n read(a,b);\n graph[a][b]:=1;\n graph[b][a]:=1;\n antigraph[a][b]:=0;\n antigraph[b][a]:=0;\n end;\n for i:=1 to 5 do\n begin\n for j:=i+1 to 5 do\n begin\n if(graph[i][j]=1) then\n begin\n for k:=j+1 to 5 do\n begin\n if((graph[j][k]=1) and (graph[i][k]=1)) then\n begin\n write('WIN');\n \n Exit;\n end;\n end;\n end;\n end;\n\n end;\n for i:=1 to 5 do\n begin\n for j:=i+1 to 5 do\n begin\n if(antigraph[i][j]=1) then\n begin\n for k:=j+1 to 5 do\n begin\n if((antigraph[j][k]=1) and (antigraph[i][k]=1)) then\n begin\n write('WIN');\n \n Exit;\n end;\n end;\n end;\n end;\n\n end;\n\n write('FAIL');\n\nend.\n", "positive_code": [{"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n g : array [1..5, 1..5] of boolean;\n a, b, i, j, k, m : integer;\n\nbegin\n REadln (m);\n for i := 1 to m do begin\n Readln (a, b);\n g [a, b] := True;\n g [b, a] := True;\n end;\n\n for i := 1 to 5 do\n for j := 1 to 5 do\n for k := 1 to 5 do\n if (g [i, j] and g [i, k] and g [j, k]) or ((not g [k, j]) and (not g [i, j]) and (not g [i, k])) and (i <> j) and (j <> k) and (i <> k) then begin\n Writeln ('WIN');\n // Writeln (i, ' ', j, ' ', k);\n Readln;\n Halt;\n end;\n Writeln ('FAIL');\n Readln;\nend.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D+,E+,F+,G-,I+,L+,N+,O-,R+,Q+,S+,V+,X+}\n// {$A+,B-,D-,E+,F+,G-,I-,L-,N+,R-,Q-,S-,V+,X+}\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n// base = 1000000009;\n// eps = 1e-9;\n// pi = 3.141592653589793238;\n\nvar\n n, m, i, j, res, k, res1, res2, l, r, x, y, z, len: integer;\n a, b: array [0..10001] of integer;\n w, s1, s2, snew: string;\n yes: array [0..101] of boolean;\n ok: array [0..101, 0..101] of boolean;\n s, st: array [0..101] of string;\n ch: char;\n g: array [0..100, 0..100] of boolean;\n\n\nprocedure panic(dxp: integer);\nbegin\n write(dxp);\n halt(0);\nend;\n\nprocedure panic64(dxi64: int64);\nbegin\n write(dxi64);\n halt(0);\nend;\n\nprocedure panics(kws: string);\nbegin\n write(kws);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nprocedure swap64(var qx1, qy1: int64);\nvar\n qz1: int64;\nbegin\n qz1 := qx1;\n qx1 := qy1;\n qy1 := qz1;\nend;\n\nprocedure swapex(var qx2, qy2: extended);\nvar\n qz2: extended;\nbegin\n qz2 := qx2;\n qx2 := qy2;\n qy2 := qz2;\nend;\n\nprocedure swaps(var qs1, qs2: string);\nvar\n qs3: string;\nbegin\n qs3 := qs1;\n qs1 := qs2;\n qs2 := qs3;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(m);\n if m <= 2 then\n panics('WIN');\n for i := 1 to m do\n begin\n read(a[i], b[i]);\n g[a[i], b[i]] := true;\n g[b[i], a[i]] := true;\n end;\n n := 5;\n for i := 1 to m do\n for j := 1 to n do\n if g[a[i], j] and g[b[i], j] then\n panics('WIN');\n\n for i := 1 to n do\n for j := 1 to n do\n for l := 1 to n do\n if (i <> j) and (j <> l) and (i <> l) then\n if (not g[i, j]) and (not g[j, l]) and (not g[l, i]) then\n panics('WIN');\n\n write('FAIL')\n\n\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x,y,m,temp,i,j,k:integer;\n ok:boolean;\n a:array [1..5,1..5] of integer;\nbegin\n //reset(input,'input.txt');\n Readln(m);\n fillchar(a,sizeof(a),0);\n for i:=1 to m do\n begin\n ReadLn(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n\n //rewrite(output,'output.txt');\n ok:=false;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for k:=j+1 to 5 do\n if ((a[i,j]=1) and (a[i,k]=1) and (a[j,k]=1)) or\n ((a[i,j]=0) and (a[i,k]=0) and (a[j,k]=0)) then ok:=true;\n if ok then WriteLn('WIN')\n else WriteLn('FAIL');\nend.\n "}, {"source_code": "\nvar n,m,x,y:integer;\n c:array[1..5,1..5]of integer;\n i,j,k:integer;\n\nbegin\nn:=5;\n readln(m);\n for i:=1 to m do begin\n readln(x,y);\n c[x,y]:=1;\n c[y,x]:=1;\n end;\n for i:=1 to n do\n for j:=i+1 to n do\n for k:=j+1 to n do\n begin\n m:=c[i,j]+c[i,k]+c[j,k];\n if ((m=0)or(m=3)) then begin writeln('WIN'); exit; end;\n end;\nwriteln('FAIL');\n readln;\n readln;\nend."}, {"source_code": "var a,b,n,i,j:integer;\n c:array[1..5,1..5]of integer;\n q,w,e,r,t:integer;\nbegin\nreadln(n);\nfor i:=1 to 5 do\n for j:=1 to 5 do c[i,j]:=0;\n\nfor i:=1 to n do begin\nreadln(a,b);\nc[a,b]:=1;\nc[b,a]:=1;\nend;\nfor i:=1 to 5 do c[i,i]:=5;\na:=0;\nb:=0;\nfor q:=1 to 5 do\n for w:=q+1 to 5 do\n for e:=w+1 to 5 do\n begin\n if (c[q,w]=1)and(c[w,e]=1)and(c[q,e]=1) then begin a:=1; end;\n if (c[q,w]=0)and(c[w,e]=0)and(c[q,e]=0) then begin b:=1; end;\n end;\n\nif ((a=1)or(b=1)) then writeln('WIN') else writeln('FAIL');\n\n\n\nreadln;\n { TODO -oUser -cConsole Main : Insert code here }\nend."}, {"source_code": "program B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n I, J, K, N, X, Y: Longint;\n Bo: Boolean;\n A: array [1..5, 1..5] of Boolean;\n\nbegin\n// Assign(Input, 'Input.txt');\n// Assign(Output, 'Output.txt');\n\n Bo := False;\n FillChar(A, SizeOf(A), False);\n Readln(N);\n for I := 1 to N do\n begin\n Readln(X, Y);\n A[X, Y] := True;\n A[Y, X] := True; \n end;\n for I := 1 to 3 do\n for J := I+1 to 4 do\n for K := J+1 to 5 do\n Bo := Bo or ((A[I, J] and A[J, K] and A[I, K]) or not (A[I, J] or A[J, K] or A[I, K]));\n\n if Bo\n then Writeln('WIN')\n else Writeln('FAIL');\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst t:array[1..10,1..3] of integer=((1,2,3),(1,2,4),(1,2,5),(2,3,4),(2,3,5),(2,4,5),(3,4,5),(1,3,4),(1,3,5),(1,5,4));\n\nvar z,c,x,y,i,j,n,k,ans:integer;\na:Array [1..10,1..10] of boolean;\nstr,tmp:string;\nw,e:boolean;\nbegin\nreadln(N);\n\nfor I := 1 to 6 do\nfor j := 1 to 6 do\na[i,j]:=false;\n\nfor I := 1 to n do\nbegin\nread(x,y);\na[x,y]:=true;\na[y,x]:=true;\nend;\n\nw:=false;\ne:=false;\n\nfor I := 1 to 10 do\nbegin\nz:=t[i][1];\nx:=t[i][2];\nc:=t[i][3];\n\nif (a[x,z] and a[x,c] and a[z,c]) then begin w:=true; writeln('WIN'); halt;end;\n\nif ((not a[x,z]) and (not a[x,c]) and (not a[c,z])) then begin e:=true; writeln('WIN'); halt;end;\n\nend;\n\n//if (not e) and (not w) then writeln('WIN') else\nwriteln('FAIL');\n\n//while True do\n\nend."}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n m,i,a,b:longint;\n zn:array[0..10,0..10] of boolean;\n\n function check1(x:longint):boolean;\n var i,j:longint;\n begin\n check1:=true;\n for i:=1 to 5 do if zn[i,x] then\n for j:=1 to 5 do if (zn[i,j]) and (zn[x,j]) then exit;\n check1:=false;\n end;\n\n function check2(x:longint):boolean;\n var i,j:longint;\n begin\n check2:=true;\n for i:=1 to 5 do if (i <> x) and (not zn[i,x]) then\n for j:=1 to 5 do if (x <> j) and (i <> j) then\n if (not zn[i,j]) and (not zn[x,j]) then exit;\n check2:=false;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(m);\n fillchar(zn,sizeof(zn),false);\n for i:=1 to m do\n begin\n read(a,b);\n if a = b then continue;\n zn[a,b]:=true;\n zn[b,a]:=true;\n end;\n for i:=1 to 5 do if check1(i) or check2(i) then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nlabel\n 1;\nvar\n a:array[1..5,1..5] of integer;\n f,x,y,i,j,k,n,m:integer;\nbegin\n readln(m);\n for I:=1 to m do begin\n readln(x,y);\n a[x,y]:=1;a[y,x]:=1;\n end;\n f:=0;\n for i:=1 to 5 do begin\n for j:=i+1 to 5 do begin\n for k:=j+1 to 5 do begin\n n:=a[i,j]+a[i,k]+a[j,k];\n if (n=0) or (n=3) then begin\n f:=1;\n goto 1;\n end;\n end;\n end;\n end;\n1:\n if f=1 then writeln('WIN') else writeln('FAIL');\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a: array [1..5, 1..5] of Byte;\n i, j, k, b, e, m: Integer;\n\nfunction known(q, w, e: Integer): Boolean;\nbegin\n Result := (a[q, w] = 1) and (a[w, e] = 1) and (a[q, e] = 1);\nend;\n\nfunction unknown(q, w, e: Integer): Boolean;\nbegin\n Result := (a[q, w] <> 1) and (a[w, e] <> 1) and (a[q, e] <> 1);\nend;\n\nbegin\n{\n reset(input, 'friends.in');\n rewrite(output, 'friends.out');\n}\n Readln(m);\n for i := 1 to m do\n begin\n Readln(b, e);\n a[b, e] := 1;\n a[e, b] := 1;\n end;\n\n for i := 1 to 3 do\n begin\n for j := i + 1 to 4 do\n begin\n for k := j + 1 to 5 do\n begin\n if known(i, j, k) or unknown(i, j, k) then\n begin\n Writeln('WIN');\n Halt(0);\n end;\n end;\n end;\n end;\n\n Writeln('FAIL');\n\nend.\n"}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j, k, x, y: Integer;\n a: array[1..5, 1..5] of Integer;\nbegin\n //reset(input, 'input.txt');\n //write(output, 'output.txt');\n Readln(n);\n for i := 1 to n do\n begin\n Readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n {if n < 5 then\n begin\n Writeln('WIN');\n Halt;\n end;}\n for i := 1 to 5 do\n for j := i + 1 to 5 do\n for k := j + 1 to 5 do\n begin\n if ((a[i, j] = 1)and(a[i, k] = 1)and(a[k, j] = 1))or((a[i, j] = 0)and(a[i, k] = 0)and(a[j, k] = 0)) then\n begin\n Writeln('WIN');\n Halt;\n end;\n end;\n Writeln('FAIL');\n readln;\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n x:Array[1..5, 1..5] of Boolean;\n i,j,p,n,a,b:Integer;\nBegin\n Read(n);\n For i:=1 To 5 Do\n For j:=1 To 5 Do Begin\n If i=j Then continue;\n x[i,j]:=FALSE;\n End;\n For i:=1 To n Do Begin\n Read(a,b);\n x[a,b]:=TRUE;\n x[b,a]:=TRUE;\n End;\n For i:=1 To 5 Do\n For j:=1 To 5 Do Begin\n If i=j Then continue;\n For p:=1 To 5 Do Begin\n If (p=i) or (p=j) Then continue;\n If (x[i,j]=x[j,p]) and (x[j,p]=x[p,i]) Then Begin\n Write('WIN');\n Halt;\n End;\n End;\n End;\n Write('FAIL');\nEnd.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a : array [1..5,1..5] of boolean;\nvar m,i,j,t1,t2,t3 : integer;\n\nbegin\n read(m);\n fillchar(a, sizeof(a), 0);\n for i := 1 to m do\n begin\n read(t1,t2);\n a[t1,t2] := true;\n a[t2,t1] := true;\n end;\n for t1 := 1 to 5 do\n for t2 := t1+1 to 5 do\n for t3 := t2+1 to 5 do\n if (a[t1,t2] and a[t2,t3] and a[t1,t3]) or ((not a[t1,t2]) and (not a[t2,t3]) and (not a[t1,t3])) then\n begin writeln('WIN'); halt; end;\n writeln('FAIL');\n\nend.\n"}, {"source_code": "program Solve_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a: array[1..5, 1..5] of longint;\ni, j, m, n, k: longint;\nf: boolean;\nbegin\n //reset(input, 'a.in');\n //rewrite(output, 'a.out');\n\n readln(m);\n for i := 1 to m do\n begin\n read(n, k);\n a[n, k] := 1;\n a[k, n] := 1;\n end;\n\n f := false;\n for i := 1 to 3 do\n for j := 2 to 4 do\n for k := 3 to 5 do\n begin\n if ((i <> j) and (i <> k) and (j <> k)) and ((a[i, j]*a[j, k]*a[k, i] = 1) or (a[i, j] + a[j, k] + a[i, k] = 0))\n then f := true;\n end;\n\n if f then write('WIN') else write('FAIL');\nend.\n"}, {"source_code": "var arr:array[1..5,1..5] of byte;\ni,n,j,k,x,y:byte;\nflag:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n readln(x,y);\n arr[x,y]:=1;\n arr[y,x]:=1;\n end;\n\nflag:=false;\nfor i:=1 to 5 do\n for j:=1 to 5 do\n for k:=1 to 5 do\n begin\n if (i<>j) and (j<>k) and (i<>k) and (arr[i,j]=arr[j,k]) and (arr[j,k]=arr[k,i])\n then\n begin\n flag:=true;\n end; \n end;\nif flag=true then writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "var a:array[1..5]of byte;\n n,x,y,i:byte;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n for i:=1 to 5 do\n begin\n if a[i]>2 then begin write('WIN');halt;end;\n if 4-a[i]>2 then begin write('WIN');halt;end;\n end;\n write('FAIL');\nend."}, {"source_code": "\nconst\n finp='';\n fout='';\nvar dau:array [1..10] of string;\n x,y,z,n,i,LC1,LC2,LC3:longint;\n KQ,s1,s2,s3:string;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n readln(f,n);\n for i:=1 to n do\n begin\n readln(f,x,y);\n str(x,s1); str(y,s2);\n insert(s2,dau[x],length(dau[x])+1);\n insert(s1,dau[y],length(dau[y])+1);\n end;\n for x:=1 to 5 do\n for y:=1 to 5 do\n for z:=1 to 5 do\n begin\n str(x,s1); str(y,s2); str(z,s3); LC1:=0; LC2:=0; LC3:=0;\n if not ((x=y) or (y=z) or (z=x)) then\n begin\n if (pos(s1,dau[y])<>0) and (pos(s1,dau[z])<>0) then LC1:=1\n else\n if (pos(s1,dau[y])<>0) or (pos(s1,dau[z])<>0) then LC1:=2;\n if (pos(s2,dau[x])<>0) and (pos(s2,dau[z])<>0) then LC2:=1\n else\n if (pos(s2,dau[x])<>0) or (pos(s2,dau[z])<>0) then LC2:=2;\n if (pos(s3,dau[y])<>0) and (pos(s3,dau[x])<>0) then LC3:=1\n else\n if (pos(s3,dau[y])<>0) or (pos(s3,dau[x])<>0) then LC3:=2;\n if (LC1=LC2) and (LC2=LC3) and (LC3=LC1) then\n if (LC1=1) or (LC1=0) then KQ:='WIN';\n end;\n end;\n if KQ<>'WIN' then KQ:='FAIL';\n write(g,KQ); close(g); close(f);\nend."}, {"source_code": "Type tm=Array [1..10] of LongInt;\nVar m:tm;\nn,x,y,i:LongInt;\nf:Boolean;\nBegin\n Readln (n);\n For I:=1 to n do\n Begin\n Readln (x,y);\n Inc (m[x]);\n Inc (m[y])\n End;\n f:=True;\n For I:=1 to 5 do\n If m[i]<>2 then f:=False;\n If f and (n=5)\n then Writeln ('FAIL')\n else Writeln ('WIN')\nEnd."}, {"source_code": "var\no1,o2:boolean;\ni,x,y,m:longint;\ne,a:array[0..100]of longint;\n\nprocedure run(v,t,mask:longint);\n begin\n if v=5 then\n begin\n if t=3 then\n begin\n o1:=false;\n o2:=false;\n for i:=1 to t do\n if (a[e[i]] and mask)=(mask xor (1 shl e[i]))then o1:=true\n else if (a[e[i]] and mask)=0 then o2:=true else exit;\n\n writeln('WIN');\n halt(0);\n end;\n exit;\n end;\n run(v+1,t,mask);\n e[t+1]:=v;\n run(v+1,t+1,mask or (1 shl v));\n end;\n\n begin\n read(m);\n for i:=1 to m do\n begin\n read(x,y);\n x:=x-1;\n y:=y-1;\n a[x]:=a[x] or (1 shl y);\n a[y]:=a[y] or (1 shl x);\n end;\n\n run(0,0,0);\n writeln('FAIL');\n end."}, {"source_code": "var a : array[1..5] of byte;\ni, j, m, x, y : byte;\nb : boolean;\nbegin\nfillchar(a, sizeof(a), 0);\nread(m);\nfor i := 1 to m do begin\n read(x, y);\n inc(a[x]);\n inc(a[y]);\nend;\nb := false;\nfor i := 1 to 5 do\n if a[i] <> 2 then b := true;\nif b then writeln('WIN')\n else writeln('FAIL');\nend.\n"}, {"source_code": "var\n m,i,a,b:longint;\n map:array[1..5,1..5] of longint;\n\nprocedure check(a,b,c:longint);\n var\n x:longint;\n begin\n x:=map[a,b]+map[b,c]+map[a,c];\n if (x=3)or(x=0) then\n begin\n writeln('WIN');halt;\n end;\n end;\n\nbegin\n readln(m);\n for i:=1 to m do\n begin\n readln(a,b);\n map[a,b]:=1;map[b,a]:=1;\n end;\n\n check(1,2,3);\n check(1,2,4);\n check(1,2,5);\n check(1,3,4);\n check(1,3,5);\n check(1,4,5);\n\n check(2,3,4);\n check(2,3,5);\n check(2,4,5);\n\n check(3,4,5);\n\n writeln('FAIL');\nend.\n"}, {"source_code": "Var x,y,i,n,j,u,u1:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n A[y,x]:=1;\n end;\n y1:='FAIL';\n For i:=1 to 5 do\n begin\n u:=0;\n u1:=0;\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin u:=u+1; end\n else if (i<>j) and (a[i,j]=0) then begin u1:=u1+1; end;\n if u>=3 then begin y1:='WIN'; Break; end;\n if (u1>=3) then begin y1:='WIN'; Break; end;\n end;\n WriteLn(y1);\n end.\n"}, {"source_code": "{$Apptype console}\nvar\n n,x,y,i,j,k : longint;\n g : array [1..5,1..5] of longint; \nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n g[x,y]:=1;\n g[y,x]:=1;\n end;\n for i:=1 to 5 do\n for j:=1 to 5 do\n begin\n if i=j then continue;\n for k:=1 to 5 do\n begin\n if (i=k) or (j=k) then continue;\n if ((g[i,j]=1) and (g[i,k]=1) and (g[j,k]=1)) or\n ((g[i,j]=0) and (g[i,k]=0) and (g[j,k]=0)) \n then begin\n writeln('WIN');\n exit;\n end;\n end;\n end;\n writeln('FAIL'); \nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, k, x, y: Integer;\n m: Integer;\n A: array [1..5, 1..5] of Boolean;\n Flag: Boolean;\n\nbegin\n for i := 1 to 5 do\n for j := 1 to 5 do\n A[i, j] := False;\n readln(m);\n for i := 1 to m do\n begin\n readln(x, y);\n a[x, y] := True; a[y, x] := True;\n end;\n Flag := False;\n for i := 1 to 5 do\n for j := i+1 to 5 do\n for k := j+1 to 5 do\n if (a[i, j] = a[i, k]) and (a[i, j] = a[j, k]) then\n begin\n Flag := True;\n break;\n end;\n if Flag then\n writeln('WIN')\n else\n writeln('FAIL');\n readln;\nend.\n "}, {"source_code": "var x,y,n,i:longint;\nans:boolean;\n a:array[1..1000]of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n readln(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\nans:=false;\nfor i:=1 to 5 do\n if a[i]<>2 then begin ans:=true;break; end;\nif ans=true then write('WIN')\nelse write('FAIL');\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,S+,O+}\nvar\n a : array [1..5, 1..5] of Boolean;\n i, j, k, m, x, y : LongInt;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(m);\n FillChar(a, SizeOf(a), 0);\n for i := 1 to m do\n begin\n read(x, y);\n a[x, y] := true;\n a[y, x] := true;\n end;\n for i := 1 to 5 do\n for j := i + 1 to 5 do\n for k := j + 1 to 5 do\n if a[i, j] and a[i, k] and a[j, k] or not a[i, j] and not a[i, k] and not a[j, k] then\n begin\n Writeln('WIN');\n halt;\n end;\n Writeln('FAIL');\nend.\n"}, {"source_code": "var i, j, k, l, m, n:longint;\na:array[1..5, 1..5] of longint;\nbegin\n fillchar(a, sizeof(a), 0);\n readln(m);\n for i:=1 to m do begin\n read(k, l);\n a[l,k]:=1;\n a[k,l]:=1;\n end;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for k:=j+1 to 5 do\n if ((a[i,j]=a[j,k])and(a[i,j]=a[i,k]))then begin\n writeln('WIN');\n halt(0);\n end;\n writeln('FAIL');\nend. "}, {"source_code": "var\na:array [1..5,1..5] of boolean;\ni,j,k,n,x,y:integer;\nbegin\nreadln(n);\nFor i:=1 to 5 do\nFOr j:=1 to 5 do\na[i,j]:=false;\nFor i:=1 to n do begin\nread(x,y);\na[x,y]:=true;\na[y,x]:=true;\nend;\nFor i:=1 to 3 do\nFor j:=i+1 to 4 do\nFor k:=j+1 to 5 do\nif ((a[i,j]=true)and(a[j,k]=true)and(a[k,i]=true))or\n((a[i,j]=false)and(a[j,k]=false)and(a[k,i]=false)) then \nbegin\nwriteln('WIN');\nhalt;\nend;\nwriteln('FAIL');\nend."}, {"source_code": "const\n\tb: array[0..10] of longint = (0, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0);\n\nvar\n\ta: array[0..10] of longint;\n\tx: longint;\n\nbegin\n\twhile not seekeof do begin\n\t\tread(x);\n\t\tinc(a[x]);\n\tend;\n\tfor x := 0 to 10 do begin\n\t\tif a[x] <> b[x] then begin\n\t\t\twriteln('WIN');\n\t\t\thalt;\n\t\tend;\n\tend;\n\twriteln('FAIL');\nend."}, {"source_code": "var\nm:array [1..5,1..5] of integer;\nn,i,a,b,j,k:longint;\nbegin\nread(n);\nfor i:=1 to 5 do for j:=1 to 5 do m[i,j]:=0;\nfor i:=1 to n do begin read(a,b); inc(m[a,b]); inc(m[b,a]); end; a:=0; b:=0;\nfor i:=1 to 3 do for j:=i+1 to 4 do for k:=j+1 to 5 do\nif (m[i,j]=1) and (m[i,k]=1) and (m[j,k]=1) then a:=1 else\nif (m[i,j]=0) and (m[i,k]=0) and (m[j,k]=0) then b:=1;\nif (a=1) or (b=1) then write('WIN') else write('FAIL');\nend."}, {"source_code": "program bbbb;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar m,i,s,t,k,j:longint;\n mas:array[1..5,1..5] of longint;\n flag:boolean;\nbegin\n\n readln(m);\n for i:=1 to m do\n begin\n readln(s,t);\n mas[s,t]:=1;\n mas[t,s]:=1;\n end;\n\n flag:=false;\n\n for i:=1 to 5 do\n for j:=1 to 5 do\n for k:=1 to 5 do\n if (i<>j)and(i<>k)and(j<>k) then\n if (mas[i,j]=mas[i,k])and(mas[i,j]=mas[j,k]) then flag:=true;\n if flag then writeln('WIN')\n else writeln('FAIL');\n\n readln;\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,S+,O+}\nvar\n a : array [1..5, 1..5] of Boolean;\n i, j, k, m, x, y : LongInt;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(m);\n FillChar(a, SizeOf(a), 0);\n for i := 1 to m do\n begin\n read(x, y);\n a[x, y] := true;\n a[y, x] := true;\n end;\n for i := 1 to 5 do\n for j := i + 1 to 5 do\n for k := j + 1 to 5 do\n if a[i, j] and a[i, k] and a[j, k] or not a[i, j] and not a[i, k] and not a[j, k] then\n begin\n Writeln('WIN');\n halt;\n end;\n Writeln('FAIL');\nend.\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\nconst n=5;\nvar\na : array [1..n,1..n] of boolean;\ni,j,m,l : byte;\nok : boolean;\nbegin\n{reset (input,'input.txt');\nrewrite (output,'output.txt');}\nreadln (m);\nfillchar (a,sizeof (a),false);\nok:=false;\nfor l:=1 to m do\nbegin\nread (i,j);\na [i,j]:=true;\na [j,i]:=true;\nend;\nok:=false;\nfor i:=1 to n-2 do\n for j:=i+1 to n-1 do\n for l:=j+1 to n do\n if (a [i,j]=a [i,l]) and (a [i,l]=a [j,l]) then ok:=true;\n if not ok then write ('FAIL')\n else write ('WIN');\nend.\n "}, {"source_code": "Var i,j,t,n:longint;\n a:array[0..11,0..11]of longint;\nBegin\n { assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n Readln(n);\n for i:=1 to n do\n begin\n Readln(j,t);\n a[j,t]:=1;\n a[t,j]:=1;\n end;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for t:=j+1 to 5 do\n if(a[i,j]=a[i,t])and(a[i,j]=a[j,t])\n then begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\nEnd."}, {"source_code": "program friends;\n{$o-}\n{$APPTYPE CONSOLE}\nuses\n Math, StrUtils, SysUtils;\ntype\n ex=extended;\n int=longint;\n bool=boolean;\nvar\n a: array[1..5,1..5] of bool;\n i,j,k,m: int;\nbegin\nfillchar(a,sizeof(a),0);\nreadln(m);\nfor i:= 1 to m do\n begin\n readln(j,k);\n a[j,k]:= true;\n a[k,j]:= true;\n end;\nfor i:= 1 to 5 do\n for j:= i+1 to 5 do\n for k:= j+1 to 5 do\n if (a[i,j]=a[j,k])and(a[i,j]=a[i,k])\n then\n begin\n writeln('WIN');\n //}readln;\n exit;\n end;\nwriteln('FAIL');\n//}readln;\nend.\n"}, {"source_code": "var\n m,i,j,k,v1,v2:integer;\n a:array[1..5,1..5]of integer;\n str:string;\n \nfunction prove(l,b,c:integer):boolean;\nbegin\n result:=false;\n if (a[l,b]=1)and(a[l,c]=1)and(a[b,c]=1)then result:=true;\n if (a[l,b]=0)and(a[l,c]=0)and(a[b,c]=0)then result:=true;\nend;\n\nbegin\n for i:=1 to 5 do\n for j:=1 to 5 do\n a[i,j]:=0;\n read(m);\n for i:=1 to m do begin\n read(v1,v2);\n a[v1,v2]:=1;\n a[v2,v1]:=1;\n end;\n str:='FAIL';\n for i:=1 to 3 do \n for j:=i+1 to 4 do\n for k:=j+1 to 5 do\n if prove(i,j,k) then begin str:='WIN'; writeln(str); halt; end; \n writeln(str);\nend.\n "}, {"source_code": "program Project12;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar N,a,b,i:byte;\nms:array[1..5,1..5]of boolean;\n\nfunction check(i1,i2,i3:byte):boolean;\nbegin\n if (ms[i1,i2]and ms[i2,i3]and ms[i3,i1])or\n ((not ms[i1,i2])and(not ms[i1,i3])and(not ms[i3,i2]))\n then check:=true\n else check:=false; \nend;\n\nbegin\n readln(N);\n for i:=1 to N do\n begin\n readln(a,b);\n ms[a,b]:=true;\n ms[b,a]:=true;\n end;\n if check(1,2,3)or\n check(1,2,4)or\n check(1,2,5)or\n check(1,3,4)or\n check(1,3,5)or\n check(1,4,5)or\n check(2,3,4)or\n check(2,3,5)or\n check(2,4,5)or\n check(3,4,5) then writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n n,i,j,k:integer;\n x2,y1:integer;\nbegin\n readln(n);\n for k:=1 to n do\n begin\n readln(x2,y1);\n inc(deg[x2]);inc(deg[y1]);\n end;\n count:=0;\n for k:=1 to 5 do\n if (deg[k]>=3)or(deg[k]=0)or(deg[k]=1) then begin writeln('WIN'); halt;writeln; end;\n writeln('FAIL');\nend.\n"}, {"source_code": "VAR\n\ta:array[1..5,1..5] of boolean;\n\tt:array[1..5] of byte;\n\tf:array[1..5] of byte;\n\tn,b,c,i,j,g,k:byte;\nBEGIN\n\treadln(n);\n\tfillchar(a,sizeof(a),false);g:=0;\n\tfillchar(t,sizeof(t),0);\n\tfillchar(f,sizeof(f),0);\n\tfor i:=1 to n do\n\t\tBEGIN\n\t\t\tread(b,c);\n\t\t\ta[b,c]:=true;\n\t\t\ta[c,b]:=true;\n\t\tEND;\n\tfor i:=1 to 3 do\n\t\tfor j:=i+1 to 4 do\n\t\t\tfor k:=j+1 to 5 do\n\t\t\t\tBEGIN\n\t\t\t\t\tif (((a[i,j]) and (a[j,k])) and (a[i,k])) then\n\t\t\t\t\tBEGIN\n\t\t\t\t\t\tg:=1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tEND;\n\t\t\t\t\tif (((a[i,j]=FALSE) and (a[j,k]=FALSE)) and (a[i,k]=FALSE)) then\n\t\t\t\t\tBEGIN\n\t\t\t\t\t\tg:=1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tEND;\n\t\t\t\tEND;\n\tif g=1 then\n\t\twriteln('WIN')\n\telse\n\t\twriteln('FAIL');\t\t\nEND.\t"}, {"source_code": "var m,i,k,j,x,y:longint;\na:array[1..5,1..5]of longint;\nbegin\nRead(m);\nfor i:=1 to m do\n begin\n Read(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\nfor i:=1 to 5 do\n for k:=1 to 5 do\n for j:=1 to 5 do\n if (i<>k)and(i<>j)and(k<>j)and(a[i,k]=a[i,j])and(a[i,k]=a[k,j])and(a[i,j]=a[k,j])then\n begin\n Write('WIN');\n halt;\n end;\nwrite('FAIL');\nend."}, {"source_code": "// Allah is Great\n{$H+,Q-,R-}\n{$M 17777777}\n\nuses\n\tSysUtils , Math;\nconst\n\tn = 5;\nvar \n m : longint;\n x : array[0 .. 5 , 0 .. 5] of integer;\n\nprocedure reading;\nvar \n i , j , k , a , b : longint; \nbegin\n read(m);\n for i:= 1 to m do begin\n read(a , b);\n x[a][b]:= 1;\n x[b][a]:= 1;\n end;\n for k:= 1 to n do begin\n \tfor j:= 1 to n do begin\n \t for i:= 1 to n do begin\n \t \tif (i = j) or (i = k) or (j = k) then continue;\n \t \tif (x[i][k] = 0) and (x[i][j] = 0) and (x[k][j] = 0) then begin\n \t \t\twriteln('WIN'); exit;\n \t \tend;\n \t end; \t\t\n \tend;\n end; \n for k:= 1 to n do begin\n \tfor j:= 1 to n do begin\n \t for i:= 1 to n do begin\n \t \tif (i = j) or (i = k) or (j = k) then continue;\n \t \tif (x[i][k] = 1) and (x[i][j] = 1) and (x[k][j] = 1) then begin\n \t \t\twriteln('WIN'); exit;\n \t \tend;\n \t end; \t\t\n \tend;\n end; \n writeln('FAIL');\nend; \n\nbegin\n reading;\nend. "}, {"source_code": "var\n a:array [1..10000] of longint;\n i,j,n,m,k,ver1,ver2:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(ver1,ver2);\n inc(a[ver1]);\n inc(a[ver2]);\n end;\n for i:=1 to 5 do\n begin\n if (a[i]>2) then begin\n writeln('WIN');\n halt;\n end;\n if 4-a[i]>2 then begin\n writeln('WIN');\n halt;\n end;\n end;\n writeln('FAIL');\nend."}, {"source_code": "uses\n SysUtils, Math;\n \nvar\n i, j, k, m, x, y, cur : longint;\n a : array[0..10, 0..10] of boolean;\n\nbegin \n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF} \n fillchar(a, sizeof(a), 0);\n read(m);\n for i := 1 to m do begin\n read(x, y);\n a[x][y] := true;\n a[y][x] := true;\n end;\n for i := 1 to 5 do\n for j := 1 to 5 do begin\n if i = j then continue;\n for k := 1 to 5 do begin\n if (i = k) or (j = k) then continue;\n cur := byte(a[i][j]) + byte(a[i][k]) + byte(a[j][k]);\n if (cur = 0) or (cur = 3) then begin\n write('WIN');\n halt(0);\n end;\n end;\n end;\n write('FAIL');\nend."}, {"source_code": "var\n a: array[1..5, 1..5] of boolean;\n i, j, k, x, y, m: longint;\n\nbegin\n for i := 1 to 5 do\n for j := 1 to 5 do\n a[i, j] := false;\n\n read(m);\n for i := 1 to m do begin\n read(x, y);\n a[x, y] := true;\n a[y, x] := true;\n end;\n\n for i := 1 to 5 do\n for j := 1 to i-1 do\n for k := 1 to j-1 do\n if (a[i, j] and a[i, k] and a[j, k]) or (not a[i, j] and not a[i, k] and not a[j, k]) then begin\n writeln('WIN');\n halt;\n end;\n\n writeln('FAIL');\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array [1..10,1..10]of longint;\n i,j,q:longint;\n x,y:longint;\n n,m:longint;\n\nbegin\n n:=5;\n readln(m);\n for i:=1 to m do\n begin\n readln(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n for i:=1 to n do\n for j:=i+1 to n do\n for q:=j+1 to n do\n begin\n if (a[i,j]=1)and(a[j,q]=a[i,j])and(a[i,q]=1) then\n begin\n write('WIN');\n halt(0);\n end else\n if (a[i,j]=0)and(a[j,q]=a[i,j])and(a[i,q]=0) then\n begin\n write('WIN');\n halt(0);\n end\n end;\n write('FAIL')\nend.\n"}, {"source_code": "var\n\ta: array[1..5, 1..5] of boolean;\n\ti, j, k, x, y, m: longint;\n\nbegin\n\tfor i := 1 to 5 do\n\t\tfor j := 1 to 5 do\n\t\t\ta[i, j] := false;\n\n\tread(m);\n\tfor i := 1 to m do begin\n\t\tread(x, y);\n\t\ta[x, y] := true;\n\t\ta[y, x] := true;\n\tend;\n\n\tfor i := 1 to 5 do\n\t\tfor j := 1 to i-1 do\n\t\t\tfor k := 1 to j-1 do\n\t\t\t\tif (a[i, j] and a[i, k] and a[j, k]) or (not a[i, j] and not a[i, k] and not a[j, k]) then begin\n\t\t\t\t\twriteln('WIN');\n\t\t\t\t\thalt;\n\t\t\t\tend;\n\n\twriteln('FAIL');\nend."}, {"source_code": "var n,m,i,j,k,l,r,kol,ans:longint;\n a:Array[0..101,0..101] of longint;\nbegin\nreadln(m);\nans:=0;\nn:=5;\nfor i:= 1 to m do\n begin\n readln(l,r);\n a[l,r]:=1;\n a[r,l]:=1;\n end;\n kol:=0;\n for i:= 1 to 5 do\n for j:= i+1 to 5 do\n for k:= j+1 to 5 do\n if (a[i,j]=1) and (a[i,k]=1) and (a[j,k]=1) then\n kol:=1;\n if kol=0 then inc(ans);\n kol:=0;\n for i:= 1 to 5 do\n for j:= i+1 to 5 do\n for k:= j+1 to 5 do\n if (a[i,j]=0) and (a[i,k]=0) and (a[j,k]=0) then\n kol:=1;\n if kol=0 then inc(Ans);\n if ans=2 then writeln('FAIL') else\n writeln('WIN');\nend.\n"}, {"source_code": "var\n a:array[1..5,1..5] of byte;\n b:array[1..3] of byte;\n i,j,m,n,t,z,x,y:longint;\n s1,s2:ansistring;\n\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n readln(m);\n for i:=1 to m do\n begin\n read(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n t:=0;m:=0;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for z:=j+1 to 5 do\n if (a[i,j]=1)and(a[i,z]=1)and(a[j,z]=1) then t:=1;\n\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for z:=j+1 to 5 do\n if (a[i,j]=0)and(a[i,z]=0)and(a[j,z]=0) then m:=1;\n\n if (t=0)and(m=0) then write('FAIL')\n else write('WIN');\nend.\n"}, {"source_code": "var\nm, a, b, i, j, k: longint;\nadj: array [1..5,1..5] of boolean;\nbegin\n readln(m);\n for i := 1 to m do\n begin\n readln(a, b);\n adj[a, b] := true;\n adj[b, a] := true;\n end;\n for i := 1 to 5 do\n begin\n for j := i + 1 to 5 do\n begin\n for k := j + 1 to 5 do\n begin\n\tif (adj[i, j] = adj[j, k]) and (adj[i, j] = adj[i, k]) then\n\tbegin\n\t writeln('WIN');\n\t halt;\n\tend;\n end;\n end;\n end;\n writeln('FAIL');\nend.\n"}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n for i := 1 to 5 do\n f[i][i] := true;\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2]) and (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2] = false) and (f[i1 , i2] = false)) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) or (unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "var a:array[1..5,1..5] of boolean;\n i,j,n,x,y,k:longint;\nbegin\nfor i:=1 to 5 do\n for j:=1 to 5 do a[i,j]:=false;\n read(n);\n for i:=1 to n do begin\n read(x,y);\n a[x,y]:=true;\n a[y,x]:=true;\n end;\n for i:=1 to 5 do\n for j:=1 to i-1 do\n for k:=1 to j-1 do begin\n if (a[i,j] and a[i,k] and a[j,k]) or (not a[i,j] and not a[i,k] and not a[j,k]) then begin\n write('WIN');\n exit;\n end;\n end;\nwrite('FAIL');\nend."}, {"source_code": "const\n finp = '';\n fout = '';\nvar\n fi, fo : text;\n a : array[1 .. 5, 1 .. 5] of integer;\n res : string;\n{----------------}\nprocedure OpenFile;\nbegin\n assign(fi, finp);\n reset(fi);\n\n assign(fo, fout);\n rewrite(fo);\nend;\n{----------------}\nprocedure Init;\nbegin\n fillchar(a, sizeof(a), 0);\nend;\n{----------------}\nprocedure Input;\nvar\n i : integer;\n x, y : integer;\nbegin\n readln(fi, i);\n for i := 1 to i do\n begin\n readln(fi, x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\nend;\n{----------------}\nprocedure Solve;\nvar\n i, j, k : integer;\nbegin\n res := 'FAIL';\n for i := 1 to 3 do\n for j := i + 1 to 4 do\n for k := j + 1 to 5 do\n if ((a[i, j] = 0) and (a[i, k] = 0) and (a[j, k] = 0))\n or ((a[i, j] = 1) and (a[i, k] = 1) and (a[j, k] = 1)) then\n begin\n res := 'WIN';\n exit;\n end;\nend;\n{----------------}\nprocedure Output;\nbegin\n writeln(fo, res);\nend;\n{----------------}\nprocedure Process;\nbegin\n Init;\n Input;\n Solve;\n Output;\nend;\n{----------------}\nprocedure CloseFile;\nbegin\n close(fi);\n close(fo);\nend;\n{----------------}\nbegin\n OpenFile;\n Process;\n CloseFile;\nend.\n"}, {"source_code": "var\n x, y, m, i, j, k: longint;\n a: array[1..5, 1..5] of longint;\nbegin\n {assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);}\n readln(m);\n for i := 1 to m do\n begin\n readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n for i := 1 to 5 do\n begin\n for j := i + 1 to 5 do\n begin\n for k := j + 1 to 5 do\n begin\n if ((a[i, j] = 1) and (a[i, k] = 1) and (a[j, k] = 1)) or ((a[i, j] = 0) and (a[i, k] = 0) and (a[j, k] = 0)) then\n begin\n writeln('WIN');\n exit;\n end;\n end;\n end;\n end;\n writeln('FAIL');\nend.\n"}, {"source_code": "var fr:array[1..10,1..10] of integer;\n k_z:array [1..5] of integer;\n m,mm,n,i:longint;\n fl:boolean;\nbegin\n readln(n);\nif n<4 then writeln('WIN')\nelse\nbegin\n for i:=1 to n do\n readln(fr[i,1],fr[i,2]);\n for i:=1 to n do\n begin inc(k_z[fr[i,1]]);inc(k_z[fr[i,2]]);end;\n fl:=false;\n for i:=1 to 5 do\n if (k_z[i]<>2) then fl:=true;\n if fl=true then writeln('WIN')\n else writeln('FAIL');\nend;\nend."}, {"source_code": "var\n c:array[1..5,1..5]of byte;\n i,j,n,a,b,z:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n c[a,b]:=1;\n c[b,a]:=1;\n end;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for z:=j+1 to 5 do\n begin\n if ((c[i,j]=0)and(c[i,z]=0)and(c[j,z]=0))\n or((c[i,j]=1)and(c[i,z]=1)and(c[j,z]=1)) then\n begin\n writeln('WIN');\n halt;\n end;\n end;\n writeln('FAIL');\nend.\n{ for i:=1 to 5 do\n begin\n for j:=1 to 5 do if c[i,j]=1 then inc(g);\n if g }\n \n"}, {"source_code": "Var n,m,i,j,x,y,u:longint;\n a:array[0..123,0..123]of longint;\n begin\n read(m);\n for i:=1 to m do\n begin\n read(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n for i:=1 to 5 do\n for j:=1 to 5 do\n for u:=1 to 5 do\n if (i<>j)and(i<>u)and(j<>u)and((a[i,j]+a[j,u]+a[i,u])mod 3=0)\n then begin\n Writeln('WIN');\n halt(0);\n end;\n Writeln('FAIL');\n end."}, {"source_code": "program z;\n var\n a:array[1..5,1..5] of byte;\n i,j,k,n,m,x,y:integer;\n begin\n fillchar(a,sizeof(a),0);\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n m:=0;\n for i:=1 to 5 do\n a[i][i]:=2;\n for i:=1 to 5 do\n for j:=1 to 5 do\n for k:=1 to 5 do\n begin\n if (a[i,j]=0)and(a[i,k]=0)and(a[j,k]=0) then m:=1;\n end;\n for i:=1 to 5 do\n for j:=1 to 5 do\n for k:=1 to 5 do\n begin\n if (a[i,j]=1)and(a[i,k]=1)and(a[j,k]=1) then m:=1;\n end;\n if m=1 then write('WIN') else write('FAIL');\nend."}, {"source_code": "var\nm,x,y,i,j,k:integer;\na:array [1..5,1..5] of integer;\nf1,f2:boolean;\nbegin\nreadln (m);\nfor i:=1 to m do\n for j:=1 to m do\n a[i,j]:=0;\nfor i:=1 to m do\n begin\n readln (x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\nfor i:=1 to 5 do\n for j:=1 to 5 do\n for k:=1 to 5 do\n if (i<>j) and (j<>k) and (i<>k) then\n begin\n if (a[i,j]=a[j,k]) and (a[i,k]=a[i,j]) and (a[i,j]=1) then\n f1:=true;\n if (a[i,j]=a[j,k]) and (a[i,k]=a[i,j]) and (a[i,j]=0) then\n f2:=true;\n end;\nif f1 or f2 then\n writeln ('WIN')\nelse\n writeln ('FAIL');\nend."}, {"source_code": "const\n{ fi='friends.inp';\n fo='friends.out'; }\n fi='';\n fo='';\n\nvar\n f:text;\n a:array[0..5,0..5]of boolean;\n x:array[0..3]of byte;\n free:array[0..5]of boolean;\n n:byte;\n kq:boolean;\n\nprocedure open;\nvar i,u,v:byte;\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n for i:=1 to n do\n begin\n readln(f,u,v);\n a[u,v]:=true;\n a[v,u]:=true;\n end;\n close(f);\nend;\n\nprocedure check;\nvar i,j,dem:byte;\nbegin\n dem:=0;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[x[i],x[j]] then inc(dem);\n if (dem=0) or (dem=3) then kq:=true;\nend;\n\nprocedure try(i:byte);\nvar j:byte;\nbegin\n if i>3 then check\n else\n begin\n for j:=1 to 5 do\n if free[j] then\n begin\n x[i]:=j;\n free[j]:=false;\n try(i+1);\n free[j]:=true;\n end;\n end;\n\nend;\n\nprocedure main;\nbegin\n fillchar(free,sizeof(free),true);\n try(1);\n assign(f,fo);rewrite(f);\n if not kq then writeln(f,'FAIL')\n else writeln(f,'WIN');\n close(f);\nend;\n\nbegin\n open;\n main;\nend."}, {"source_code": "var\n\ta: array[1..5, 1..5] of boolean;\n\ti, j, k, x, y, m: longint;\n\nbegin\n\tfor i := 1 to 5 do\n\t\tfor j := 1 to 5 do\n\t\t\ta[i, j] := false;\n\n\tread(m);\n\tfor i := 1 to m do begin\n\t\tread(x, y);\n\t\ta[x, y] := true;\n\t\ta[y, x] := true;\n\tend;\n\n\tfor i := 1 to 5 do\n\t\tfor j := 1 to i-1 do\n\t\t\tfor k := 1 to j-1 do\n\t\t\t\tif (a[i, j] and a[i, k] and a[j, k]) or (not a[i, j] and not a[i, k] and not a[j, k]) then begin\n\t\t\t\t\twriteln('WIN');\n\t\t\t\t\thalt;\n\t\t\t\tend;\n\n\twriteln('FAIL');\nend."}, {"source_code": "var\n ar : array[1..5,1..5] of boolean;\n ar2 : array[1..5] of longint;\n bol : boolean;\n k,i,j,l,a,b : byte;\nbegin\n readln(k);\n fillchar(ar,sizeof(ar),false);\n for i := 1 to k do\n begin\n readln(a,b);\n ar[a][b] := true;\n ar[b][a] := true;\n end;\n for i := 1 to 5 do\n ar[i][i] := false;\n bol := false;\n for i := 1 to 3 do\n begin\n for j := i+1 to 4 do\n begin\n for k := j+1 to 5 do\n begin\n if ar[i][j] and ar[i][k] and ar[j][k] then bol := true;\n if not(ar[i][j]) and not(ar[i][k]) and not(ar[j][k]) then bol := true;\n end;\n end;\n end;\n if bol then writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "type matrica=array[1..5,1..5]of integer;\nvar a,b:matrica;\n n,i,j,u,v,m,ans,h,pr:integer;\n fix:array[1..5]of integer;\n\nProcedure dfs(a:matrica;k,l:integer);\nvar i,pv:integer;\nbegin\nfix[k]:=l;\npv:=pr;\nfor i:=1 to n do\n if(pr<>i)and(a[k,i]=1)then\n begin\n if(fix[i]=0)or(fix[i]>fix[k]+1)then\n begin\n pr:=k;\n dfs(a,i,fix[k]+1);\n pr:=pv;\n end else\n if(l-fix[i]=2)then begin\n ans:=ans+1;\n exit;\n end;\n end;\nend;\nbegin\nn:=5;\nreadln(m);\nfor i:=1 to m do\n begin\n readln(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if(i<>j)then\n if(a[i,j]=0)then b[i,j]:=1;\nfor i:=1 to n do\n if(fix[i]=0)then dfs(b,i,1);\nif ans=0 then begin\n for i:=1 to n do fix[i]:=0;\n for i:=1 to n do\n if(fix[i]=0)then dfs(a,i,1);\n end;\nif(ans>0)then writeln('WIN')\n else writeln('FAIL');\nend.\n"}, {"source_code": "var\n n,a,b,i:longint;\n g:array [1..5] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(a,b);\n inc(g[a]); inc(g[b]);\n end;\n for i:=1 to 5 do\n if g[i]<>2 then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\nend."}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n for i := 1 to 5 do\n f[i][i] := true;\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2]) and (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2] = false) and (f[i1 , i2] = false)) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) or (unacq) then\n write('WIN')\n else\n write('FAIL');\nend."}, {"source_code": "var\n k : array [0..11,0..11] of boolean;\n l,n,i,j,m,h,c,x,y,z : longint;\n s,p,ss,t : string;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n k[x,y]:=true;\n k[y,x]:=true;\n end;\n x:=0;\n z:=0;\n for i:=1 to 5 do for j:=i+1 to 5 do if not k[i,j] then for l:=j+1 to 5 do if (not k[j,l])and(not k[i,l]) then\n begin\n writeln('WIN');\n halt;\n end;\n for i:=1 to 5 do for j:=i+1 to 5 do if k[i,j] then for l:=j+1 to 5 do if (k[j,l])and(k[i,l]) then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\nend."}, {"source_code": "var n,i,j,k,A,B:longint;\nw:array[1..5,1..5] of longint;\nbegin\nread(n);\nfor i:=1 to n do\nbegin\nread(a,b);\nw[a,b]:=1;\nw[b,a]:=1;\nend;\nfor i:=1 to 5 do\nfor j:=i+1 to 5 do\nfor k:=j+1 to 5 do\nbegin\nif w[i,j]*w[j,k]*w[i,k]=1 then begin\nwrite('WIN');\nhalt;\nend;\nif w[i,j]+w[j,k]+w[i,k]=0 then begin\nwrite('WIN');\nhalt;\nend;\nend;\nwrite('FAIL');\nend.\n"}, {"source_code": "var n,m,i,j,k,l,r,kol,ans:longint;\n a:Array[0..101,0..101] of longint;\nbegin\nreadln(m);\nans:=0;\nn:=5;\nfor i:= 1 to m do\n begin\n readln(l,r);\n a[l,r]:=1;\n a[r,l]:=1;\n end;\n kol:=0;\n for i:= 1 to 5 do\n for j:= i+1 to 5 do\n for k:= j+1 to 5 do\n if (a[i,j]=1) and (a[i,k]=1) and (a[j,k]=1) then\n kol:=1;\n if kol=0 then inc(ans);\n kol:=0;\n for i:= 1 to 5 do\n for j:= i+1 to 5 do\n for k:= j+1 to 5 do\n if (a[i,j]=0) and (a[i,k]=0) and (a[j,k]=0) then\n kol:=1;\n if kol=0 then inc(Ans);\n if ans=2 then writeln('FAIL') else\n writeln('WIN');\nend.\n"}, {"source_code": "var\na:array[1..5,1..5]of integer;\nn,i,j,l,x,y:integer;\nq:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n readln(x,y);\n a[x,y]:=1; a[y,x]:=1;\n end;\nq:=false;\nfor i:=1 to 5 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 5 do\nif ((a[i,j]=1)and(a[i,l]=1)and(a[j,l]=1))or\n ((a[i,j]=0)and(a[i,l]=0)and(a[j,l]=0)) then q:=true;\nif q then writeln('WIN') else writeln('FAIL');\nend."}], "negative_code": [{"source_code": "var\no1,o2:boolean;\ni,x,y,m:longint;\ne,a:array[0..100]of longint;\n\nprocedure run(v,t,mask:longint);\n begin\n if v=5 then\n begin\n if t=3 then\n begin\n o1:=false;\n o2:=false;\n for i:=1 to t do\n if (a[e[i]] and mask)=mask then o1:=true\n else if (a[e[i]] and mask)=0 then o2:=true else exit;\n\n writeln('WIN');\n halt(0);\n end;\n exit;\n end;\n run(v+1,t,mask);\n e[t+1]:=v;\n run(v+1,t+1,mask or (1 shl v));\n end;\n\n begin\n read(m);\n for i:=1 to m do\n begin\n read(x,y);\n x:=x-1;\n y:=y-1;\n a[x]:=a[x] or (1 shl y);\n a[y]:=a[y] or (1 shl x);\n end;\n\n run(0,0,0);\n writeln('FAIL');\n end."}, {"source_code": "var x,y,n,i:longint;\nans:boolean;\n a:array[1..1000]of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n readln(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\nans:=false;\nfor i:=1 to 5 do\n if a[i]>=3 then begin ans:=true;break; end;\nif ans=true then write('WIN')\nelse write('FAIL');\nend."}, {"source_code": "var\nm:array [1..5] of integer;\nn,i,a,b:longint;\nbegin\nread(n);\nfor i:=1 to 5 do m[i]:=0;\nfor i:=1 to n do begin read(a,b); inc(m[a]); inc(m[b]); end;\na:=0; b:=0;\nfor i:=1 to 5 do if m[i]<3 then inc(a) else inc(b);\nif (a>2) or (b>2) then write('WIN') else write('FAIL');\nend."}, {"source_code": "var\nm:array [1..5] of integer;\nn,i,a,b:longint;\nbegin\nread(n);\nfor i:=1 to 5 do m[i]:=0;\nfor i:=1 to n do begin read(a,b); inc(m[a]); inc(m[b]); end;\na:=0; b:=0;\nfor i:=1 to 5 do if m[i]>2 then inc(a) else if m[i]<2 then inc(b);\nif (a>2) or (b>2) then write('WIN') else write('FAIL');\nend.\n"}, {"source_code": "var\nm:array [1..5] of integer;\nn,i,a,b:longint;\nbegin\nread(n);\nfor i:=1 to 5 do m[i]:=0;\nfor i:=1 to n do begin read(a,b); inc(m[a]); inc(m[b]); end;\na:=0; b:=0;\nfor i:=1 to n do if m[i]>2 then inc(a) else if m[i]<2 then inc(b);\nif (a>2) or (b>2) then write('WIN') else write('FAIL');\nwrite(a,' ',b);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n n,i,j,k:integer;\n x2,y1:integer;\nbegin\n readln(n);\n for k:=1 to n do\n begin\n readln(x2,y1);\n inc(deg[x2]);inc(deg[y1]);\n end;\n count:=0;\n for k:=1 to 5 do\n if deg[k]>=3 then begin writeln('WIN'); halt;writeln; end;\n writeln('FAIL');\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n n,i,j,k:integer;\n x2,y1:integer;\nbegin\n readln(n);\n for k:=1 to n do\n begin\n readln(x2,y1);\n inc(deg[x2]);inc(deg[y1]);\n end;\n count:=0;\n for k:=1 to 5 do\n if (deg[k]>=3)or(deg[k]=0) then begin writeln('WIN'); halt;writeln; end;\n writeln('FAIL');\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n m,i,j,k:integer;\n x,y:integer;\nbegin\n readln(m);\n for i:=1 to m do\n begin\n readln(x,y);\n c[x,y]:=true;\n c[y,x]:=true;\n inc(deg[x]);inc(deg[y]);\n end;\n count:=0;\n for i:=1 to 5 do\n if deg[i]>=3 then begin writeln('WIN'); halt; end;\n writeln('FALL');\nend."}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n m,i,j,k:integer;\n x,y,dd:integer;\nbegin\n readln(m);\n for i:=1 to m do\n begin\n readln(x,y);\n c[x,y]:=true;\n c[y,x]:=true;\n inc(deg[x]);inc(deg[y]);\n end;\n count:=0;\n for i:=1 to 5 do\n if deg[i]>=3 then begin writeln('WIN'); halt;writeln; end;\n writeln('FALL');\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n count:integer;\n deg:array[1..5]of integer;\n c:array[1..5,1..5]of boolean;\n n,i,j:integer;\n x2,y1:integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x2,y1);\n inc(deg[x2]);inc(deg[y1]);\n end;\n count:=0;\n for i:=1 to 5 do\n if deg[i]>=3 then begin writeln('WIN'); halt;writeln; end;\n writeln('FAIL');\nend.\n"}, {"source_code": "VAR\n\ta:array[1..5,1..5] of boolean;\n\tt:array[1..5] of byte;\n\tf:array[1..5] of byte;\n\tn,b,c,i,j,count,g:byte;\nBEGIN\n\treadln(n);\n\tfillchar(a,sizeof(a),false);count:=0;g:=0;\n\tfillchar(t,sizeof(t),0);\n\tfillchar(f,sizeof(f),0);\n\tfor i:=1 to n do\n\t\tBEGIN\n\t\t\tread(b,c);\n\t\t\ta[b,c]:=true;\n\t\t\ta[c,b]:=true;\n\t\tEND;\n\tfor i:=1 to 5 do\n\t\tBEGIN\n\t\tfor j:=1 to 5 do\n\t\t\tBEGIN\n\t\t\t\tinc(count);\n\t\t\t\tif (i<>j) then\n\t\t\t\tif a[i,j]=TRUE then\n\t\t\t\t\tinc(t[i])\n\t\t\t\telse\n\t\t\t\t\tinc(f[i]);\t\t\t\n\t\t\tEND;\n\tif (t[i]=3) OR (f[i]=3) then\n\t\t\tBEGIN\n\t\t\t\twriteln('WIN');g:=1;\n\t\t\t\tbreak;\n\t\t\tEND;\n\t\tEND;\n\tif g=0 then\n\t\twriteln('FAIL');\nEND.\n\t\t\t\t\t\n\t\t"}, {"source_code": "var\n\tN,i,a,b,c,j,d,k : integer;\n\tg : array [1..5,1..5] of boolean;\n\nbegin\n\treadln(N);\n\t\n\tfor i := 1 to N do\n\tbegin\n\t\treadln(a,b);\n\t\tg[a,b] := true;\n\t\tg[b,a] := true;\n\tend;\n\n\tfor i := 1 to 5 do\n\tbegin\n\t\tc := 0;\n\t\td := 0;\n\t\t\n\t\tfor j := 1 to 5 do\n\t\tbegin\n\t\t\tif i <> j then\n\t\t\t\tif g[i,j] then\n\t\t\t\t\tfor k := 1 to 5 do\n\t\t\t\t\t\tif (k <> j) and (k <> i) then\n\t\t\t\t\t\t\tif (g[j,k]) and (g[j,i]) then inc(c);\n\t\t\tif (c = 3) then\n\t\t\tbegin\n\t\t\t\twriteln('WIN');\n\t\t\t\thalt;\n\t\t\tend;\n\t\tend;\n\t\t\n\t\tfor j := 1 to 5 do\n\t\tbegin\n\t\t\tif i <> j then\n\t\t\t\tif not(g[i,j]) then\n\t\t\t\t\tfor k := 1 to 5 do\n\t\t\t\t\t\tif (k <> j) and (k <> i) then\n\t\t\t\t\t\t\tif not(g[j,k]) and not(g[j,i]) then inc(d);\n\t\t\t\t\t\t\t\n\t\t\tif (d = 3) then\n\t\t\tbegin\n\t\t\t\twriteln('WIN');\n\t\t\t\thalt;\n\t\t\tend;\n\t\tend;\n\t\t\t\n\tend;\n\t\n\twriteln('FAIL');\n\nend.\n"}, {"source_code": "var\n\tN,i,a,b,c,d,j : integer;\n\tv : array [1..5,1..5] of boolean;\n\nbegin\n\treadln(N);\n\t\n\tfor i := 1 to N do\n\tbegin\n\t\treadln(a,b);\n\t\tv[a,b] := true;\n\t\tv[b,a] := true;\n\tend;\n\t\n\tfor i := 1 to 5 do\n\tbegin\n\t\tc := 0; d := 0;\n\t\tfor j := 1 to 5 do\n\t\t\tif i <> j then\n\t\t\t\tif v[i,j] then inc(c) else inc(d);\n\t\tif (c = 3) or (d = 3) then\n\t\tbegin\n\t\t\twriteln('WIN');\n\t\t\thalt;\n\t\tend;\n\tend;\n\t\n\twriteln('FAIL');\n\nend.\n"}, {"source_code": "var a, b, m, i, j, k: byte;\n x: array [1..5, 1..5] of boolean;\nbegin\n readln(m);\n for i := 1 to m do\n begin\n readln(a, b);\n x[a, b] := true;\n x[a, b] := true;\n end;\n for i := 1 to 3 do\n for j := i + 1 to 4 do\n for k := j + 1 to 5 do\n if (x[i, j] = x[j, k]) and (x[j, k] = x[k, i]) then\n begin\n writeln('WIN');\n exit;\n end;\n writeln('FAIL');\nend."}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n for i := 1 to 5 do\n f[i][i] := true;\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i1]) and (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2] = false) and (f[i1 , i2] = false)) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) and (unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i1]) or (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and (f[i , i2] = false) and (f[i1 , i2] = false) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) and (unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n for i := 1 to 5 do\n f[i][i] := true;\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i1]) and (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2] = false) or (f[i1 , i2] = false)) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq <> unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n for i := 1 to 5 do\n f[i][i] := true;\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i1]) and (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i2] = false) or (f[i1 , i2] = false)) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) and (unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "{$IFDEF NORMAL}\n {$H-,I+,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF NORMAL}\n{$IFDEF DEBUG}\n {$H-,I+,OBJECTCHECKS+,Q+,R+,S-}\n{$ENDIF DEBUG}\n{$IFDEF RELEASE}\n {$H-,I-,OBJECTCHECKS-,Q-,R-,S-}\n{$ENDIF RELEASE}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n\nconst\n fi = '';\n fo = '';\nvar\n f : array [1..5 , 1..5] of boolean;\n a , b : array [1..5] of integer;\n n , i , i1 , i2 : integer;\n acq , unacq : boolean;\nbegin\n assign(input , fi);\n reset(input);\n assign(output , fo);\n rewrite(output);\n\n fillchar(f , sizeof(f) , false);\n read(n);\n for i := 1 to n do begin\n read(a[i] , b[i]);\n f[a[i]][b[i]] := true;\n f[b[i]][a[i]] := true;\n end;\n //\n acq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1]) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and ((f[i , i1]) or (f[i1 , i2])) then begin\n acq := true;\n break;\n end;\n if (acq) then\n break;\n end;\n if (acq) then\n break;\n end;\n unacq := false;\n for i := 1 to 5 do begin\n for i1 := 1 to 5 do\n if (i1 <> i) and (f[i , i1] = false) then begin\n for i2 := 1 to 5 do\n if (i1 <> i2) and (i <> i2) and (f[i , i2] = false) and (f[i1 , i2] = false) then begin\n unacq := true;\n break;\n end;\n if (unacq) then\n break;\n end;\n if (unacq) then\n break;\n end;\n if (acq) or (unacq) then\n write('WIN')\n else\n write('FAIL');\nend.\n"}, {"source_code": "var fr:array[1..10,1..10] of integer;\n k_z:array [1..10] of integer;\n n,i:longint;\n fl:boolean;\nbegin\n readln(n);\nif n<4 then writeln('WIN')\nelse\nbegin\n for i:=1 to n do\n readln(fr[i,1],fr[i,2]);\n for i:=1 to n do\n begin inc(k_z[fr[i,1]]);inc(k_z[fr[i,2]]);end;\n fl:=false;\n for i:=1 to 10 do\n if k_z[i]>=3 then fl:=true;\n if fl=true then writeln('WIN')\n else writeln('FAIL');\nend;\nend."}, {"source_code": "var fr:array[1..10,1..10] of integer;\n k_z:array [1..10] of integer;\n n,i:longint;\n fl:boolean;\nbegin\n readln(n);\n for i:=1 to n do\n readln(fr[i,1],fr[i,2]);\n for i:=1 to n do\n begin inc(k_z[fr[i,1]]);inc(k_z[fr[i,2]]);end;\n fl:=false;\n for i:=1 to 10 do\n if k_z[i]>=3 then fl:=true;\n if fl=true then writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "var fr:array[1..10,1..10] of integer;\n k_z:array [1..10] of integer;\n n,i:longint;\n fl:boolean;\nbegin\n readln(n);\nif n<3 then writeln('WIN')\nelse\nbegin\n for i:=1 to n do\n readln(fr[i,1],fr[i,2]);\n for i:=1 to n do\n begin inc(k_z[fr[i,1]]);inc(k_z[fr[i,2]]);end;\n fl:=false;\n for i:=1 to 10 do\n if k_z[i]>=3 then fl:=true;\n if fl=true then writeln('WIN')\n else writeln('FAIL');\nend;\nend."}, {"source_code": "var n,i,p:longint;\nz:longint;\ns:string;\nq:array[0..1000000] of string;\nans:array[0..1000000] of longint;\nbegin {\nassign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nreadln(n);\nfor z:=1 to n do\n begin\n readln(s);\n p:=0;\n for i:=1 to length(s) do\n p:=(p+(i*ord(s[i]))) mod 10000000;\n if ans[p]=0 then begin writeln('OK');q[p]:=s;ans[p]:=1;end\n else\n begin\n writeln(q[p],ans[p]);\n inc(ans[p]);\n end;\n end;\nend.\n\n\n\n"}, {"source_code": "var i,j,a,c,d,n,e,q,s,k1,k2:longint; mas:array[1..5,1..5] of longint;\nbegin\n\nreadln(n);\n\nfillchar(mas,sizeof(mas),0);\n\nfor i:=1 to n do\nbegin\nreadln(q,s);\nmas[q,s]:=mas[q,s]+1;\nmas[s,q]:=mas[s,q]+1;\nend;\n\nfor i:=1 to 5 do\nmas[i,i]:=2;\n\nfor i:=1 to 5 do\nbegin\nk1:=0;\nk2:=0;\nfor j:=1 to 5 do\nbegin\nif mas[i,j]=0 then k1:=k1+1;\nif mas[i,j]=1 then k2:=k2+1;\nend;\nif (k1=3) or (k2=3) then begin writeln('WIN'); exit; end;\nend;\n\nwriteln('FAIL');\n\nend."}, {"source_code": "var i,j,a,c,d,n,e,q,s,k1,k2:longint; mas:array[1..5,1..5] of longint;\nbegin\n\nreadln(n);\n\nfillchar(mas,sizeof(mas),0);\n\nfor i:=1 to n do\nbegin\nreadln(q,s);\nmas[q,s]:=mas[q,s]+1;\nmas[s,q]:=mas[s,q]+1;\nend;\n\nfor i:=1 to 5 do\nmas[i,i]:=1;\n\nfor i:=1 to 5 do\nfor j:=1 to 5 do\nbegin\nif mas[i,j]=0 then k1:=k1+1 else k2:=k2+1;\nend;\n\nk1:=k1 div 2;\nk2:=(k2-5) div 2;\n\nif (k1=3) or (k2=3) then writeln('WIN') else writeln('FAIL');\n\n\n\n\n\n\n\n\n\nend."}, {"source_code": "var i,a,c,d,n,e,s,q:longint; mas:array[1..100] of longint;\nbegin\n\nreadln(n);\n\n\nfor i:=1 to n do\nbegin\nreadln(s,q);\nmas[s]:=mas[s]+1;\nmas[q]:=mas[q]+1;\nend;\n\nif n=7 then e:=1;\n\nfor i:=1 to 5 do\nif mas[i]=3 then e:=1;\n\nif e=1 then writeln('WIN') else writeln('FAIL');\n\n\n\n\n\n\n\n\n\nend."}, {"source_code": "program z;\n var\n a:array[1..20] of byte;\n b:array[1..5] of integer;\n n,i,p:integer;\n begin\n read(n);\n n:=n*2;\n for i:=1 to n do\n begin\n read(a[i]);\n end;\n fillchar(b,sizeof(b),0);\n for i:=1 to n do\n begin\n if a[i]=1 then inc(b[1]);\n if a[i]=2 then inc(b[2]);\n if a[i]=3 then inc(b[3]);\n if a[i]=4 then inc(b[4]);\n if a[i]=5 then inc(b[5]);\n end;\n p:=0;\n for i:=1 to 5 do\n if b[i]>=3 then p:=1;\n if p=0 then write('FAIL') else write('WIN');\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar dau:array [1..10] of string;\n x,y,z,n,i,LC1,LC2,LC3:longint;\n KQ,s1,s2,s3:string;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n readln(f,n);\n for i:=1 to n do\n begin\n readln(f,x,y);\n str(x,s1); str(y,s2);\n insert(s2,dau[x],length(dau[x])+1);\n insert(s1,dau[y],length(dau[y])+1);\n end;\n for x:=1 to 5 do\n for y:=1 to 5 do\n for z:=1 to 5 do\n begin\n str(x,s1); str(y,s2); str(z,s3); LC1:=0; LC2:=0; LC3:=0;\n if not ((x=y) or (y=z) or (z=x)) then\n begin\n if (pos(s1,dau[y])<>0) and (pos(s1,dau[z])<>0) then LC1:=1\n else\n if (pos(s1,dau[y])<>0) or (pos(s1,dau[z])<>0) then LC1:=2;\n if (pos(s2,dau[x])<>0) and (pos(s2,dau[z])<>0) then LC2:=1\n else\n if (pos(s2,dau[x])<>0) or (pos(s2,dau[z])<>0) then LC2:=2;\n if (pos(s3,dau[y])<>0) and (pos(s3,dau[x])<>0) then LC3:=1\n else\n if (pos(s3,dau[y])<>0) or (pos(s3,dau[x])<>0) then LC3:=2;\n if (LC1=LC2) and (LC2=LC3) and (LC3=LC1) then\n if (LC1=1) or (LC1=0) then KQ:='WIN';\n end;\n end;\n if KQ<>'WIN' then KQ:='FALL';\n write(g,KQ); close(g); close(f);\nend.\n"}, {"source_code": "var a:array[1..5,1..5] of longint;\n k, x,y,i,j,m:longint;\n begin\n readln(m);\n for i:=1 to m do\n begin\n readln(x,y);\n a[x,y]:=a[y,x];\n end;\n m:=5;\n for i:=1 to m-2 do\n for j:=i+1 to m-1 do\n for k:=j+1 to m do\n if (a[i,j]=a[i,k]) and (a[i,k]=a[j,k]) then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\n end."}, {"source_code": "var a:array[1..5,1..5] of integer;\nq:array[1..5] of integer;\nqb,qe,i,j,n,t,k:integer;\n\nprocedure init;\nbegin\nqb:=1;\nqe:=1;\nend;\n\nprocedure push(i:integer);\nbegin\nq[qe]:=i;\ninc(qe);\nend;\n\nprocedure clear;\nbegin\nfor k:=1 to (qe-1) do\n q[k]:=0;\nend;\n\nbegin\nreadln(n);\nfor k:=1 to n do\nbegin\n readln(i,j);\n a[i,j]:=1;\n a[j,i]:=1;\nend;\nfor i:=1 to 4 do\nbegin\n clear;\n init;\n push(i);\n for j:=i+1 to 5 do\n if (a[i,j]=1) then\n push(j);\n while (qb<(qe-2)) do\n begin\n inc(qb);\n for j:=qb+1 to (qe-1) do\n if (a[q[qb],q[j]]=1) then\n begin\n t:=1;\n writeln('WIN');\n break;\n end;\n end;\n if (t=1) then\n break;\nend;\nif (t=0) then\nbegin\n for i:=1 to 4 do\n begin\n clear;\n init;\n push(i);\n for j:=i+1 to 5 do\n if (a[i,j]=0) then\n push(j);\n while (qb<(qe-2)) do\n begin\n inc(qb);\n for j:=qb+1 to (qe-1) do\n if (a[q[qb],q[j]]=0) then\n begin\n t:=1;\n writeln('WIN');\n break;\n end;\n end;\n if (t=1) then\n break;\n end;\nend;\nif (t=0) then\n writeln('FAIL');\nend.\n\n\n"}, {"source_code": "var\n ar : array[1..5,1..5] of boolean;\n ar2 : array[1..5] of longint;\n bol : boolean;\n k,i,j,l,a,b : byte;\nbegin\n readln(k);\n for i := 1 to k do\n begin\n readln(a,b);\n ar[a][b] := true;\n ar[b][a] := true;\n end;\n for i := 1 to 5 do\n begin\n for j := 1 to 5 do\n begin\n if ar[i][j] then inc(ar2[i]);\n end;\n end;\n bol := false;\n for i := 1 to 5 do\n begin\n if ar2[i] >=3 then bol := true;\n end;\n if bol then writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "type matrica=array[1..5,1..5]of integer;\nvar a,b:matrica;\n n,i,j,u,v,m,ans,h,pr:integer;\n fix:array[1..5]of integer;\n\nProcedure dfs(a:matrica;k,l:integer);\nvar i,pv:integer;\nbegin\nfix[k]:=l;\nfor i:=1 to n do\n if(pr<>i)and(a[k,i]=1)then\n begin\n if(fix[i]=0)then dfs(a,i,fix[k]+1) else\n if(l-fix[i]=3)then begin\n ans:=ans+1;\n exit;\n end;\n end;\nend;\nbegin\nn:=5;\nreadln(m);\nfor i:=1 to m do\n begin\n readln(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if(i<>j)then\n if(a[i,j]=0)then b[i,j]:=1;\nfor i:=1 to n do\n if(fix[i]=0)then dfs(b,i,1);\nif ans=0 then begin\n for i:=1 to n do fix[i]:=0;\n for i:=1 to n do\n if(fix[i]=0)then dfs(a,i,1);\n end;\nif(ans>0)then writeln('Win')\n else writeln('FAIL');\nend.\n\n\n\n"}, {"source_code": "type matrica=array[1..5,1..5]of integer;\nvar a,b:matrica;\n n,i,j,u,v,m,ans,h,pr:integer;\n fix:array[1..5]of integer;\n\nProcedure dfs(a:matrica;k,l:integer);\nvar i,pv:integer;\nbegin\nfix[k]:=l;\npv:=pr;\nfor i:=1 to n do\n if(pr<>i)and(a[k,i]=1)then\n begin\n if(fix[i]=0)then begin\n pr:=k;\n dfs(a,i,fix[k]+1);\n pr:=pv;\n end else\n if(l-fix[i]=3)then begin\n ans:=ans+1;\n exit;\n end;\n end;\nend;\nbegin\nn:=5;\nreadln(m);\nfor i:=1 to m do\n begin\n readln(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if(i<>j)then\n if(a[i,j]=0)then b[i,j]:=1;\nfor i:=1 to n do\n if(fix[i]=0)then dfs(b,i,1);\nif ans=0 then begin\n for i:=1 to n do fix[i]:=0;\n for i:=1 to n do\n if(fix[i]=0)then dfs(a,i,1);\n end;\nif(ans>0)then writeln('WIN')\n else writeln('FAIL');\nend.\n"}, {"source_code": "type matrica=array[1..5,1..5]of integer;\nvar a,b:matrica;\n n,i,j,u,v,m,ans,h,pr:integer;\n fix:array[1..5]of integer;\n\nProcedure dfs(a:matrica;k,l:integer);\nvar i,pv:integer;\nbegin\nfix[k]:=l;\nfor i:=1 to n do\n if(pr<>i)and(a[k,i]=1)then\n begin\n if(fix[i]=0)then dfs(a,i,fix[k]+1) else\n if(l-fix[i]=3)then begin\n ans:=ans+1;\n exit;\n end;\n end;\nend;\nbegin\nn:=5;\nreadln(m);\nfor i:=1 to m do\n begin\n readln(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if(i<>j)then\n if(a[i,j]=0)then b[i,j]:=1;\nfor i:=1 to n do\n if(fix[i]=0)then dfs(b,i,1);\nif ans=0 then begin\n for i:=1 to n do fix[i]:=0;\n for i:=1 to n do\n if(fix[i]=0)then dfs(a,i,1);\n end;\nif(ans>0)then writeln('WIN')\n else writeln('FAIL');\nend.\n\n\n\n"}, {"source_code": "type matrica=array[1..5,1..5]of integer;\nvar a,b:matrica;\n n,i,j,u,v,m,ans,h,pr:integer;\n fix:array[1..5]of integer;\n\nProcedure dfs(a:matrica;k,l:integer);\nvar i,pv:integer;\nbegin\nfix[k]:=l;\npv:=pr;\nfor i:=1 to n do\n if(pr<>i)and(a[k,i]=1)then\n begin\n if(fix[i]=0)then begin\n pr:=k;\n dfs(a,i,fix[k]+1);\n pr:=pv;\n end else\n if(l-fix[i]=2)then begin\n ans:=ans+1;\n exit;\n end;\n end;\nend;\nbegin\nn:=5;\nreadln(m);\nfor i:=1 to m do\n begin\n readln(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n end;\nfor i:=1 to n do\n for j:=1 to n do\n if(i<>j)then\n if(a[i,j]=0)then b[i,j]:=1;\nfor i:=1 to n do\n if(fix[i]=0)then dfs(b,i,1);\nif ans=0 then begin\n for i:=1 to n do fix[i]:=0;\n for i:=1 to n do\n if(fix[i]=0)then dfs(a,i,1);\n end;\nif(ans>0)then writeln('WIN')\n else writeln('FAIL');\nend.\n"}, {"source_code": "Program z94b;\nvar\n a:array[1..5,1..5] of byte;\n n:integer;\n\nProcedure in_data;\n var\n i,x,y:integer;\n begin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n end;\n\nfunction main(x:byte):byte;\n var\n i,j,l:integer;\n begin\n main:=0;\n for i:=1 to 5 do\n for j:=1 to 5 do\n if (a[i,j]=x) then\n for l:=1 to 5 do\n if (a[l,j]=x)and(a[l,i]=x) then\n begin\n main:=1;\n exit;\n end;\n end;\n\nbegin\n in_data;\n if (main(1)=0)and(main(0)=0) then\n write('FAIL')\n else\n write('WIN');\nend."}, {"source_code": "var\n k : array [0..11,0..11] of boolean;\n l,n,i,j,m,h,c,x,y,z : longint;\n s,p,ss,t : string;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n k[x,y]:=true;\n end;\n x:=0;\n z:=0;\n for i:=1 to 5 do for j:=i+1 to 5 do for l:=j+1 to 5 do\n begin\n if (k[i,j])and(k[j,l])and(k[i,l]) then inc(x);\n if (not k[i,j])and(not k[j,l])and(not k[i,l]) then inc(z);\n end;\n if (x=3)or(z=3) then writeln('WIN') else writeln('FAIL');\nend."}, {"source_code": "Program z94b;\nvar a:array[1..5]of byte;\n\tn,x,y,i:byte;\nbegin\n\tread(n);\n for i:=1 to n do\n begin\n \tread(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n for i:=1 to 5 do\n begin\n \tif a[i]>2 then begin write('WIN');halt;end;\n if 4-a[i]>3 then begin write('WIN');halt;end;\n end;\n write('FAIL');\nend."}, {"source_code": "var a:array [1..10,1..10] of longint;\ni,j,z,x,y,m:longint;\nbegin\nreadln(m);\nfillchar(a,sizeof(a),0);\nfor i:=1 to m do begin\n readln(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\nend;\n\nfor i:=1 to 5 do\n for j:=i+1 to 5 do\n for z:=z+1 to 5 do begin\n if (a[i,j]=1) and (a[i,z]=1) and (a[j,z]=1) then begin\n writeln('WIN');\n halt;\n end;\n if (a[i,j]=0) and (a[i,z]=0) and (a[j,z]=0) then begin\n writeln('WIN');\n halt;\n end;\n end;\nwriteln('FAIL');\nend."}, {"source_code": "var a:array [1..10,1..10] of longint;\ni,j,z,x,y,m:longint;\nbegin\nreadln(m);\nfillchar(a,sizeof(a),0);\nfor i:=1 to m do begin\n readln(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\nend;\n\nfor i:=1 to 5 do\n for j:=i+1 to 5 do\n for z:=z+1 to 5 do begin\n if (a[i,j]=1) and (a[i,z]=1) and (a[j,z]=1) then begin\n writeln('WIN');\n halt;\n end;\n if (a[i,j]=0) and (a[i,z]=0) and (a[j,z]=0) then begin\n writeln('WIN');\n halt;\n end;\n end;\nwriteln('FALL');\nend."}, {"source_code": "uses math;\nVar m,i,u,v,s,n:integer;\n a:array [1..30,1..30] of integer;\n now:array [1..30] of integer;\n\nProcedure dfs1(i,k:integer);\nVar f:integer;\nbegin\n now[i]:=1;\n for f:=1 to n do\n if (a[i,f]=1) and (now[f]=0) then dfs1(f,k+1)\n else\n if (a[i,f]=1) and (now[f]=1) then\n if (k=2) and (f=s) then begin\n write('WIN');\n halt;\n end;\n\n now[i]:=2;\nend;\n\nProcedure dfs2(i,k:integer);\nVar f:integer;\nbegin\n now[i]:=1;\n for f:=1 to n do\n if (a[i,f]=0) and (now[f]=0) then dfs2(f,k+1)\n else\n if (a[i,f]=0) and (now[f]=1) then\n if (k=2) and (f=s) then begin\n write('WIN');\n halt;\n end;\n\n now[i]:=2;\nend;\n\nbegin\n read(m);\n n:=0;\n for i:=1 to m do begin\n read(u,v);\n a[u,v]:=1;\n a[v,u]:=1;\n n:=max(n,u);\n n:=max(n,v);\n end;\n\n for i:=1 to n do begin\n s:=i;\n for u:=1 to n do now[u]:=0;\n dfs1(i,0);\n for u:=1 to n do now[u]:=0;\n dfs2(i,0);\n\n end;\n write('FAIL');\nend."}, {"source_code": "Var u,v:array [1..100] of integer;\n n,i,k,kol1,kol2:integer;\n use:array [1..100] of boolean;\n\nProcedure dfs(i:integer);\nVar j:integer;\nbegin\n use[i]:=true;\n for j:=1 to n do\n if (u[j]=i) and (not use[v[j]]) then dfs(v[j]);\nend;\n\nbegin\n read(n);\n for i:=1 to n do\n read(u[i],v[i]);\n\n for i:=1 to n do begin\n for k:=1 to n do use[k]:=false;\n dfs(i);\n\n kol1:=0;\n kol2:=0;\n\n for k:=1 to n do\n if use[k] then inc(kol1)\n else inc(kol2);\n\n if (kol1=3) or (kol2=3) then begin\n write('WIN');\n halt;\n end\n end;\n write('FAIL');\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n g : array [1..5, 1..5] of boolean;\n a, b, i, j, k, m : integer;\n\nbegin\n REadln (m);\n for i := 1 to m do begin\n Readln (a, b);\n g [a, b] := True;\n g [b, a] := True;\n end;\n\n for i := 1 to 5 do\n for j := 1 to 5 do\n for k := 1 to 5 do\n if (g [i, j] and g [i, k] and g [j, k]) or ((not g [k, j]) and (not g [i, j]) and (not g [i, k])) and (i <> j) and (j <> k) and (i <> k) then begin\n Writeln ('WIN');\n Writeln (i, ' ', j, ' ', k);\n Readln;\n Halt;\n end;\n Writeln ('FAIL');\n Readln;\nend.\n"}, {"source_code": "var n,m,x,y:integer;\n c:array[1..5,1..5]of integer;\n i,j,k:integer;\n\nbegin\nn:=5;\n readln(m);\n for i:=1 to m do begin\n readln(x,y);\n c[x,y]:=1;\n c[y,x]:=1;\n end;\n for i:=1 to n do\n for j:=1 to n do\n for k:=1 to n do\n begin\n m:=c[i,j]+c[i,k]+c[j,k];\n if ((m=0)or(m=3)) then begin writeln('WIN'); exit; end;\n end;\nwriteln('FAIL');\n\n readln;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst t:array[1..10,1..3] of integer=((1,2,3),(1,2,4),(1,2,5),(2,3,4),(2,3,5),(2,4,5),(3,4,5),(1,3,4),(1,3,5),(1,3,4));\n\nvar z,c,x,y,i,j,n,k,ans:integer;\na:Array [1..10,1..10] of boolean;\nstr,tmp:string;\nw,e:boolean;\nbegin\nreadln(N);\n\nfor I := 1 to 6 do\nfor j := 1 to 6 do\na[i,j]:=false;\n\nfor I := 1 to n do\nbegin\nread(x,y);\na[x,y]:=true;\na[y,x]:=true;\nend;\n\nw:=false;\ne:=false;\n\nfor I := 1 to 10 do\nbegin\nz:=t[i][1];\nx:=t[i][2];\nc:=t[i][3];\n\nif (a[x,z] and a[x,c] and a[z,c]) then begin w:=true; writeln('WIN'); halt;end;\n\nif ((not a[x,z]) and (not a[x,c]) and (not a[c,z])) then begin e:=true; writeln('WIN'); halt;end;\n\nend;\n\n//if (not e) and (not w) then writeln('WIN') else\nwriteln('FAIL');\n\n//while True do\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst t:array[1..7,1..3] of integer=((1,2,3),(1,2,4),(1,2,5),(2,3,4),(2,3,5),(2,4,5),(3,4,5));\n\nvar z,c,x,y,i,j,n,k,ans:integer;\na:Array [1..10,1..10] of boolean;\nstr,tmp:string;\nw,e:boolean;\nbegin\nreadln(N);\n\nfor I := 1 to 6 do\nfor j := 1 to 6 do\na[i,j]:=false;\n\nfor I := 1 to n do\nbegin\nread(x,y);\na[x,y]:=true;\na[y,x]:=true;\nend;\n\nw:=false;\ne:=false;\n\nfor I := 1 to 7 do\nbegin\nz:=t[i][1];\nx:=t[i][2];\nc:=t[i][3];\n\nif (a[x,z] and a[x,c] and a[z,c]) then begin w:=true; writeln('WIN'); halt;end;\n\nif ((not a[x,z]) and (not a[x,c]) and (not a[c,z])) then begin e:=true; writeln('WIN'); halt;end;\n\nend;\n\n//if (not e) and (not w) then writeln('WIN') else\nwriteln('FAIL');\n\n//while True do\n\nend.\n"}, {"source_code": "program Project2;\nVar m:array [1..5,1..5] of integer;\nj,i,n,a,b:integer;\nbegin\n// Assign(Input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(n);\n for i:=1 to n do\n begin\n Readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n a:=0; b:=0;\n for i:=1 to 5 do\n for j:=i+1 to 5 do\n if (i<>j)and(m[i,j]=m[j,i])\n then begin\n if m[i,j]=1\n then Inc(a)\n else inc(b);\n end;\n if (a<3)and(b<3)\n then Writeln('FAIL')\n else writeln('WIN');\nend."}, {"source_code": "program Project2;\nVar m:array [1..5,1..5] of integer;\nj,i,n,a,b:integer;\nbegin\n// Assign(Input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(n);\n for i:=1 to n do\n begin\n Readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n a:=0; b:=0;\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n if (i<>j)and(m[i,j]=m[j,i])\n then begin\n if m[i,j]=1\n then Inc(a)\n else inc(b);\n end;\n if (a=3)or(b=3)\n then Writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "program Project2;\nVar m:array [1..5,1..5] of integer;\nj,i,n,a,b:integer;\nbegin\n// Assign(Input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(n);\n for i:=1 to n do\n begin\n Readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n a:=0; b:=0;\n for i:=1 to n do\n for j:=i+1 to n do\n if (i<>j)and(m[i,j]=m[j,i])\n then begin\n if m[i,j]=1\n then Inc(a)\n else inc(b);\n end;\n if (a=3)and(b=3)\n then Writeln('WIN')\n else writeln('FAIL');\nend."}, {"source_code": "program Project2;\nVar i,a,b,j,i1,n:Integer;\nm:array [1..5,1..5] of integer;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(n);\n for i:=1 to n do\n begin\n Readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n for i:=1 to 5 do\n for j:=1 to 5 do\n if m[i,j]=1\n then begin\n for i1:=j+1 to n do\n if (m[j,i1]=1)and(m[i1,i]=1)\n then begin\n Writeln('WIN');\n Halt;\n end;\n end\n else begin\n for i1:=j+1 to n do\n if (m[j,i1]=0)and(m[i1,i]=0)\n then begin\n Writeln('WIN');\n Halt;\n end;\n end;\n Writeln('FAIL');\nend.\n"}, {"source_code": "program Project2;\nVar i,a,b,j,i1,n:Integer;\nm:array [1..5,1..5] of integer;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(n);\n for i:=1 to n do\n begin\n Readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n for i:=1 to 5 do\n for j:=1 to i-1 do\n if m[i,j]=1\n then begin\n for i1:=1 to n do\n if (m[j,i1]=1)and(m[i1,i]=1)and(i1<>i)and(i1<>j)\n then begin\n Writeln('WIN');\n Halt;\n end;\n end\n else begin\n for i1:=1 to n do\n if (m[j,i1]=0)and(m[i1,i]=0)and(i1<>i)and(i1<>j)\n then begin\n Writeln('WIN');\n Halt;\n end;\n end;\n Writeln('FAIL');\nend.\n"}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, j, k, x, y: Integer;\n a: array[1..5, 1..5] of Integer;\nbegin\n //reset(input, 'input.txt');\n //write(output, 'output.txt');\n Readln(n);\n for i := 1 to n do\n begin\n Readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n {if n < 5 then\n begin\n Writeln('WIN');\n Halt;\n end;}\n for i := 1 to 5 do\n for j := i + 1 to 5 do\n for k := j + 1 to 5 do\n begin\n if ((a[i, j] = 1)and(a[i, k] = 1)and(a[k, j] = 1))or((a[i, j] = 0)and(a[i, k] = 0)and(a[j, k] = 0)) then\n begin\n Writeln('WIN');\n Halt;\n end;\n end;\n Writeln('FALL');\n readln;\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, k, x, y: Integer;\n a: array[1..5, 1..5] of Integer;\nbegin\n //set(input, 'input.txt');\n //write(output, 'output.txt');\n Readln(n);\n for i := 1 to n do\n begin\n Readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n for i := 1 to 5 do\n for j := 1 to 5 do\n for k := 1 to 5 do\n begin\n if (i = j)or(j = k)or(k = i) then\n begin\n end\n else\n begin\n if ((a[i, j] = 1)and(a[i, k] = 1)and(a[k, j] = 1))or((a[i, j] = 0)and(a[i, k] = 0)and(a[j, k] = 0)) then\n begin\n Writeln('WIN');\n Halt;\n end;\n end;\n end;\n Writeln('FALL');\n //ose(input);\n //ose(output);\nend.\n"}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, k, x, y: Integer;\n a: array[1..5, 1..5] of Integer;\nbegin\n //reset(input, 'input.txt');\n //Rewrite(output, 'output.txt');\n Readln(n);\n for i := 1 to n do\n begin\n Readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n for i := 1 to 5 do\n for j := 1 to 5 do\n for k := 1 to 5 do\n begin\n if (i = j)or(j = k)or(k = i) then\n begin\n end\n else\n begin\n if ((a[i, j] = 1)and(a[i, k] = 1)and(a[k, j] = 1))or((a[i, j] = 0)and(a[i, k] = 0)and(a[j, k] = 0)) then\n begin\n Writeln('WIN');\n Halt;\n end;\n end;\n end;\n Writeln('FALL');\n //close(input);\n //close(output);\nend.\n "}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, k, x, y: Integer;\n a: array[1..5, 1..5] of Integer;\nbegin\n //reset(input, 'input.txt');\n //write(output, 'output.txt');\n Readln(n);\n for i := 1 to n do\n begin\n Readln(x, y);\n a[x, y] := 1;\n a[y, x] := 1;\n end;\n if n < 5 then\n begin\n Writeln('WIN');\n Halt;\n end;\n for i := 1 to 5 do\n for j := i + 1 to 5 do\n for k := j + 1 to 5 do\n begin\n if (i = j)or(j = k)or(k = i) then\n begin\n end\n else\n begin\n if ((a[i, j] = 1)and(a[i, k] = 1)and(a[k, j] = 1))or((a[i, j] = 0)and(a[i, k] = 0)and(a[j, k] = 0)) then\n begin\n Writeln('WIN');\n Halt;\n end;\n end;\n end;\n Writeln('FALL');\n readln;\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst nn=200000;\n eps=0.000000001; nnn=200;\nvar t,i2,j2,kol,i,j,l,m,k,tt,imin,zap,f1,f2,i0,j0,h,t1:longint;\nn,p,pp,s,izb:int64;\nflag:boolean;\nott:double;\nss:string;\nx,y,a,b:array[0..nn] of longint;\ndel:array[0..nn,0..300] of longint;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output1234.txt'); rewrite(output); }\nreadln(n);\nfor i:=1 to n do read(x[i],y[i]);\n for i:=1 to n do\nbegin\n p:=min(x[i],y[i]);k:=max(x[i],y[i]); inc(a[p]);inc(b[k]);\nend;\nflag:=true;\nfor i:=1 to 5 do if (a[i]<>1)or(b[i]<>1) then flag:=false;\n\n if flag then writeln('FAIL') else writeln('WIN');\n\n\n\n close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst nn=200000;\n eps=0.000000001; nnn=200;\nvar t,i2,j2,kol,i,j,l,m,k,tt,imin,zap,f1,f2,i0,j0,h,t1:longint;\nn,p,pp,s,izb:int64;\nflag:boolean;\nott:double;\nss:string;\nx,y,a,b:array[0..nn] of longint;\ndel:array[0..nn,0..300] of longint;\nfunction min (a,b:longint):longint;begin min:=b;if a0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output1234.txt'); rewrite(output); }\nreadln(n);\nfor i:=1 to n do read(x[i],y[i]);\n for i:=1 to n do\nbegin\n inc(a[x[i]]);inc(b[x[i]]);\nend;\nflag:=true;\nfor i:=1 to 5 do if (a[i]<>1)or(b[i]<>1) then flag:=false;\n\n if flag then writeln('FAIL') else writeln('WIN');\n\n\n\n close(output);\nend.\n"}, {"source_code": "program codef_76_d2_B;\nvar\ni,j,n,s:integer; a:array[1..10,1..2] of integer;\nz:array[1..10,1..5] of integer; f:boolean;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output);}\n readln(n); f:=false; s:=0;\nfor i:=1 to n do begin\n for j:=1 to 2 do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do begin z[a[i,1],a[i,2]]:=1; z[a[i,2],a[i,1]]:=1; end;\n for i:=1 to 5 do\n begin\n for j:=1 to 5 do if z[i,j]=1 then inc(s);\n if (s=1) or (s=3) then f:=true;\n if f=true then begin write('WIN'); exit; end;\n s:=0;\n end;\n write('FAIL'); \n{close(input);\nclose(output);}\nend."}, {"source_code": "program codef_76_d2_B;\nvar\ni,j,n,s:integer; a:array[1..10,1..2] of integer;\nz:array[1..10,1..5] of integer; f:boolean;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output); }\n readln(n); f:=false;\nfor i:=1 to n do begin\n for j:=1 to 2 do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do z[a[i,1],a[i,2]]:=1;\n for i:=1 to n do\n begin\n for j:=1 to 5 do if z[i,j]=1 then inc(s);\n if (s=1) or (s=3) then f:=true;\n if f=true then begin write('WIN'); exit; end;\n s:=0;\n end;\n write('FAIL');\n{close(input);\nclose(output);}\nend."}, {"source_code": "program codef_76_d2_B;\nvar\ni,j,n,s:integer; a:array[1..10,1..2] of integer;\nz:array[1..10,1..5] of integer; f:boolean;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output); }\n readln(n); f:=false;\nfor i:=1 to n do begin\n for j:=1 to 2 do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do z[a[i,1],a[i,2]]:=1;\n for i:=1 to n do\n begin\n for j:=1 to 5 do if z[i,j]=1 then inc(s);\n if (s=2) or (s=3) then f:=true;\n if f=true then begin write('WIN'); exit; end;\n s:=0;\n end;\n write('FAIL');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "program codef_76_d2_B;\nvar\ni,j,n,s:integer; a:array[1..10,1..2] of integer;\nz:array[1..10,1..5] of integer; f:boolean;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output); }\n readln(n); f:=false;\nfor i:=1 to n do begin\n for j:=1 to 2 do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do z[a[i,1],a[i,2]]:=1;\n for i:=1 to n do\n begin\n for j:=1 to 5 do if z[i,j]=1 then inc(s);\n if (s<=3) then f:=true;\n if f=true then begin write('WIN'); exit; end;\n s:=0;\n end;\n write('FAIL');\n{close(input);\nclose(output);}\nend."}, {"source_code": "program codef_76_d2_B;\nvar\ni,j,n,s:integer; a:array[1..10,1..2] of integer;\nz:array[1..10,1..5] of integer; f:boolean;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input); rewrite(output); }\n readln(n); f:=false;\nfor i:=1 to n do begin\n for j:=1 to 2 do read(a[i,j]);\n readln;\n end;\n for i:=1 to n do z[a[i,1],a[i,2]]:=1;\n for i:=1 to n do\n begin\n for j:=1 to 5 do if z[i,j]=1 then inc(s);\n if (s>=2) then f:=true;\n if f=true then begin write('WIN'); exit; end;\n s:=0;\n end;\n write('FAIL');\n{close(input);\nclose(output);}\nend."}, {"source_code": "program Project_druzya___;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..5] of integer;\n i,n,sum,x,y:integer;\n fi,fo:text;\nbegin\n\nreadln(n);\nfor i:=1 to 5 do\n begin\n a[i]:=-1;\n b[i]:=-1;\n end;\nfor i:=1 to n do\n begin\n read(x,y);\n inc(a[x]);\n inc(b[y]);\n end;\nsum:=0;\nfor i:=1 to 5 do\n begin\n if (a[i]=-1) then a[i]:=0;\n if (b[i]=-1) then b[i]:=0;\n end;\nfor i:=1 to 5 do\n begin\n sum:=sum+a[i]+b[i];\n end;\nif (sum>=3) then write('WIN') else write( 'FALL');\n\n\nend.\n\n"}, {"source_code": "program Project_druzya___;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..5] of integer;\n i,n,sum,x,y:integer;\n fi,fo:text;\nbegin\n\nreadln(n);\nfor i:=1 to 5 do\n begin\n a[i]:=-1;\n b[i]:=-1;\n end;\nfor i:=1 to n do\n begin\n read(x,y);\n inc(a[x]);\n inc(b[y]);\n end;\nsum:=0;\nfor i:=1 to 5 do\n begin\n if (a[i]=-1) then a[i]:=0;\n if (b[i]=-1) then b[i]:=0;\n end;\nfor i:=1 to 5 do\n begin\n sum:=sum+a[i]+b[i];\n end;\nif (sum>=3) then write('WIN') else write( 'FAIL');\n\n\n\nread(n);\nend.\n\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\nconst n=5;\nvar\na : array [1..n,1..n] of boolean;\nz : array [1..n] of byte;\ni,j,m,c,l,k : byte;\nok : boolean;\nbegin\n{reset (input,'input.txt');\nrewrite (output,'output.txt');}\nreadln (m);\nfillchar (a,sizeof (a),false);\nok:=false;\nfor l:=1 to m do\nbegin\nread (i,j);\na [i,j]:=true;\na [j,i]:=true;\nend;\nfor i:=1 to n do\nbegin\nc:=0;\nk:=n;\nfillchar (z,sizeof(z),0);\n for j:=1 to n do\n if a [i,j] then\n begin\n inc (c);\n z [c]:=j;\n end\n else\n if i<>j then\n begin\n z [k]:=j;\n dec (k);\n end;\nif c=2 then\n if a [z [1],z [2]] or not a [z [4],z [5]] then\n begin\n write ('WIN');\n ok:=true;\n exit;\n end;\nend;\n if not ok then write ('FAIL');\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var i,j,n:Integer;\nbegin\n read(n);\n if n>8 then write('FAIL'); \nend."}, {"source_code": "var a:array[1..5]of byte;\n n,x,y,i:byte;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n for i:=1 to 5 do\n begin\n if a[i]>2 then begin write('WIN');halt;end;\n end;\n write('FAIL');\nend."}, {"source_code": "Var x,y,i,n,j:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n a[y,x]:=1;\n end;\n For i:=1 to 5 do\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin a1[i]:=a1[i]+1; a1[j]:=a1[j]+1; end\n else if (I<>j) and (a[i,j]=0) then begin a2[i]:=a2[i]+1; a2[j]:=a2[j]+1; end;\n y1:='FAIL';\n For i:=1 to 5 do\n if (a1[i]=3) or (a2[i]=3) then begin y1:='WIN'; Break; end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n end;\n For i:=1 to 5 do\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin a1[i]:=a1[i]+1; a1[j]:=a1[j]+1; end\n else if (I<>j) and (a[i,j]=0) then begin a2[i]:=a2[i]+1; a2[j]:=a2[j]+1; end;\n y1:='FAIL';\n For i:=1 to 5 do\n if (a1[i]=3) or (a2[i]=3) then begin y1:='WIN'; Break; end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n end;\n For i:=1 to 5 do\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin a1[i]:=a1[i]+1; a1[j]:=a1[j]+1; end\n else if (I<>j) and (a[i,j]=0) then begin a2[i]:=a2[i]+1; a2[j]:=a2[j]+1; end;\n y1:='FAIL';\n For i:=1 to 5 do\n if (a1[i]=3) or (a2[i]=3) then begin y1:='WIN'; Break; end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n end;\n For i:=1 to 5 do\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin a1[i]:=a1[i]+1; a1[j]:=a1[j]+1; end\n else if (I<>j) and (a[i,j]=0) then begin a2[i]:=a2[i]+1; a2[j]:=a2[j]+1; end;\n y1:='FAIL';\n For i:=1 to 5 do\n if (a1[i]>=3) or (a2[i]>=3) then begin y1:='WIN'; Break; end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j,u,u1:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n A[y,x]:=1;\n end;\n y1:='FAIL';\n For i:=1 to 5 do\n begin\n u:=0;\n u1:=0;\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin u:=u+1; end\n else if (i<>j) and (a[i,j]=0) then begin u1:=u1+1; end;\n if u>=3 then begin y1:='WIN'; Break; end;\n if (u=0) and (u1>=3) then begin y1:='WIN'; Break; end;\n end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j,u,u1:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n end;\n y1:='FAIL';\n For i:=1 to 5 do\n begin\n u:=0;\n u1:=0;\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin u:=u+1; end\n else if (i<>j) and (a[i,j]=0) then begin u1:=u1+1; end;\n if u>=3 then begin y1:='WIN'; Break; end;\n if (u=0) and (u1>=3) then begin y1:='WIN'; Break; end;\n end;\n WriteLn(y1);\n end.\n"}, {"source_code": "Var x,y,i,n,j,u:LongInt;\n a:Array[1..1000,1..1000] of LongInt;\n a1,a2:Array[1..1000] of LongInt;\n y1:String;\n begin\n ReadLn(n);\n fillchar(a,sizeof(a),0);\n For i:=1 to n do\n begin\n Read(x,y);\n a[x,y]:=1;\n end;\n For i:=1 to 5 do\n For j:=1 to 5 do\n if (i<>j) and (a[i,j]=1) then begin a1[i]:=a1[i]+1; a1[j]:=a1[j]+1; end;\n y1:='FAIL';\n For i:=1 to 5 do\n if (a1[i]>=3) then begin y1:='WIN'; Break; end\n else if a1[i]=0 then u:=u+1;\n if u>=3 then y1:='WIN';\n WriteLn(y1);\n end.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n, x, y, i, m: longint;\n a: array[1..6] of longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n if m > 5 then writeln('WIN')\n else\n begin\n for i:=1 to 5 do\n if a[i] > 2 then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\n end;\n\n\n close(input); close(output);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n, x, y, i, m: longint;\n a: array[1..6] of longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n if m = 5 then writeln('WIN')\n else\n begin\n for i:=1 to 5 do\n if a[i] = 2 then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\n end;\n\n\n close(input); close(output);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar n, x, y, i, m: longint;\n a: array[1..6] of longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n for i:=1 to n do\n begin\n readln(x,y);\n inc(a[x]);\n inc(a[y]);\n end;\n if m < 5 then writeln('WIN')\n else\n begin\n for i:=1 to 5 do\n if a[i] >= 3 then\n begin\n writeln('WIN');\n halt;\n end;\n writeln('FAIL');\n end;\n\n\n close(input); close(output);\nend.\n"}, {"source_code": "program ll;\n var a,b,c,n,k,m,j,i,t:longint;q:array[0..10,0..10]of boolean;r:real;s:string;\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nread(n);\n\nfor i:=1 to n do\n\nbegin\n read(a,b);\n q[a,b]:=true;\n q[b,a]:=true;\nend;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n for n:=j+1 to 5 do\n if (q[i,j]and q[i,n] and q[j,n])or (not q[i,j]and not q[i,n] and not q[j,n])\n then begin\n write('WIN');halt;\n end;\n write('FALL');\n\n\n{close(input);close(output);}\nend."}, {"source_code": "{ uses crt; }\n const nn=40; eps=0.0000001; besk=20000; nnn=20;\n label 1,2;\n type mas=array [0..nn,0..3] of longint;\n var p0,p,kk,n,i,j,k,l,t,jmax,m,s,sh,p1,p2,p3:longint; flag:boolean;\n y:mas;\n ss,sv:string;\n s1:array[0..10] of string;\n vse,a,b,c:array[0..nn,0..2] of longint;\n flag1,flag2,flag3:boolean;\n { a,b,ob:array[0..nn,0..2] of longint; }\n mmax: array[0..nn] of longint;\n ppp,xx,yy,ugol,vugol,x0,x1,y0,y1:real;\n obl:boolean; vv:array[0..nn] of real;\n function min(x,y:longint):longint; begin min:=x;if yx then max:=y;end;\n function al(x,y:real):real; var t,p:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n\nfunction sovp(a:mas;p:longint):boolean; var i,j,k:longint;\nbegin end;\n\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { assign(output,'output123.txt'); rewrite(output); }\n\n\n readln(n);\n for i:=1 to n do read(a[i,1],a[i,2]);\n\n\nfor i:=1 to 5 do for j:=i+1 to 5 do for k:=j+1 to 5 do\nbegin inc(t);b[t,0]:=i;b[t,1]:=j;b[t,2]:=k;end;\n{for i:=1 to 10 do writeln(b[i,0],' ',b[i,1],' ',b[i,2],' ');}\nt:=0;\nfor i:=1 to 5 do for j:=i+1 to 5 do begin inc(t); vse[t,1]:=i;vse[t,2]:=j;end;\n\n{for i:=1 to 10 do writeln(vse[i,1],' ',vse[i,2]); writeln; }\nt:=0;\nfor j:=1 to 10 do\n begin flag:=false;\n for i:=1 to n do\n if ((a[i,1]=vse[j,1])and(a[i,2]=vse[j,2]))or((a[i,1]=vse[j,2])and(a[i,2]=vse[j,1]))\n then begin flag:=true; { writeln(t,' sovp ',i,' ',j);} end;\n if not flag then begin inc(t);c[t,1]:=vse[j,1]; c[t,2]:=vse[j,2]; end;\n\n end;\n\n{for i:=1 to t do writeln(c[i,1],' ',c[i,2]); writeln; }\nflag:=false;\nfor i:=1 to 10 do\n begin\n p1:=b[i,0];p2:=b[i,1];p3:=b[i,2];\n flag1:=false;flag2:=false;flag3:=false;\n for j:=1 to n do\n if ((a[j,1]=p1)and (a[j,2]=p2)) or ((a[j,1]=p2)and (a[j,2]=p1)) then flag1:=true;\n\n for j:=1 to n do\n if ((a[j,1]=p1)and (a[j,2]=p3)) or ((a[j,1]=p3)and(a[j,2]=p1)) then flag2:=true;\n\n for j:=1 to n do\n if ((a[j,1]=p2)and (a[j,2]=p3)) or ((a[j,1]=p3)and(a[j,2]=p2)) then flag3:=true;\n\n if flag1 and flag2 and flag3 then flag:=true;\n\n end;\n\n if flag then begin write('WIN');goto 1; end;\n\nflag:=false;\nfor i:=1 to 10 do\n begin\n p1:=b[i,0];p2:=b[i,1];p3:=b[i,2];\n flag1:=false;flag2:=false;flag3:=false;\n for j:=1 to t do\n if ((c[j,1]=p1)and (c[j,2]=p2)) or ((c[j,1]=p2)and (c[j,2]=p1)) then flag1:=true;\n\n for j:=1 to n do\n if ((c[j,1]=p1)and (c[j,2]=p3)) or ((c[j,1]=p3)and(c[j,2]=p1)) then flag2:=true;\n\n for j:=1 to n do\n if ((c[j,1]=p2)and (c[j,2]=p3)) or ((c[j,1]=p3)and(c[j,2]=p2)) then flag3:=true;\n\n if flag1 and flag2 and flag3 then flag:=true;\n\n end;\n\nif flag then write('WIN') else write('FAIL');\n\n\n\n\n\n\n\n\n\n\n\n1:\n\nclose(output);\n end."}], "src_uid": "2bc18799c85ecaba87564a86a94e0322"} {"source_code": "var m,x1,y1,sum,k,x2,i,j,n,k1,k2,k3,k4,n1,n2,max,x,y : longint;\ns,s2: string;\ncccc:array[0..100] of longint;\na,c:array[1..2000] of longint;\n\nbegin\n readln(n,m);\n readln(s);\n for i :=1 to n do\n a[i]:=ord(s[i])-ord('a')+1;\n\n\n for i :=1 to n do\n for j :=1 to n do\n if a[i]1 then\n begin\n sum:=sum+a[i];\n j:=j+1;\n k1:=a[i];\n end;\n i:=i+1;\n end;\n if j =2)then\n begin\n if x=m then break;\n c:=k;x:=x+1;s:=s+ord(k)-96;\n end;\nif x=m then writeln(s) else writeln(-1);\nclose(input);close(output);\nend."}, {"source_code": "var n,m,i,t,s:longint;c:char;\na:ansistring;\nprocedure sort(l,r: longint);\nvar i,j: longint;x,y:char;\nbegin\ni:=l;j:=r;x:=a[(l+r) div 2];\nrepeat\n while a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);j:=j-1;\n end;\nuntil i>j;\nif l0)AND(i<>kn+1) then begin\n\t\t\t\t\t\t\t\t\t\tkn:=i;\n\t\t\t\t\t\t\t\t\t\tinc(ko);\n\t\t\t\t\t\t\t\t\t\tsum:=sum+i;\n\t\t\t\t\t\t\t\t\tend;\n\t\tif ko=k then break;\n\tend;\n\tif ko=k then writeln(sum)\n\t\t\telse writeln(-1);\n\t\t\t\t\t\t\t\t\t\t\t\nend."}, {"source_code": "var\n ans,n,k,i,p,j:longint;\n s,t:string;\n a:array[1..1000] of longint;\nprocedure qsort (l,r:longint);\nvar\n x,y,m,k:longint;\nbegin\n x:=l;\n y:=r;\n m:=a[(x+y)div 2];\n repeat\n while (a[x]m) do dec(y);\n if x<=y then\n begin\n k:=a[y];\n a[y]:=a[x];\n a[x]:=k;\n inc(x);\n dec(y);\n end;\n until x>y;\n if la[i] then begin ans:=-1; break; end;\n p:=a[i];\n end;\n writeln (ans);\nend."}, {"source_code": "{$Coperators ON}\n{\t\t\t meoww~~~ meoww~~~\n\t\t /\\___/\\\n\t\t ( =^.^= )\n\t\t (\") (\")_/\n}\nuses math;\nvar n,k:Longint;\n\ts:string;\nprocedure init;\nvar i,j,t:Longint;\n\ttam:char;\nbegin\n\treadln(n,k);\n\treadln(s);\n\tfor i:=1 to Length(s) do\n\t\tfor j:=i+1 to Length(s) do\n\t\t\tif s[j]=2 then\n\t\tbegin\n\t\t\ttam:=s[i];\n\t\t\tt+=ord(s[i])-96;\n\t\t\tdec(k);\n\t\t\tif k=0 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(t);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\tend;\n\twriteln(-1);\nend;\nbegin\nassign(input,''); reset(input);\nassign(output,''); rewrite(output);\n\ninit;\nclose(input);\nclose(output);\nend."}, {"source_code": "var\n n,i,j,t,m,ans:longint;\n k,p:char;\n a:array['a'..'z'] of longint;\n f:array['a'..'z',0..50] of longint;\nfunction min(x,y:longint):longint;\n begin\n if x>y\n then exit(y)\n else exit(x);\n end;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n read(p);\n a[p]:=1;\n end;\n for k:='a' to 'z' do\n f[k,0]:=0;\n for i:=1 to m do\n for k:='a' to 'z' do\n f[k,i]:=maxlongint div 2;\n for i:=1 to m do\n begin\n if a['a']=1\n then f['a',1]:=1;\n if a['b']=1\n then f['b',1]:=2;\n for k:='c' to 'z' do\n if a[k]=1\n then\n begin\n for p:='a' to chr(ord(k)-2) do\n if f[p,i-1]=1 then begin\n while true do begin\n inc(j);\n if kol>=k then break;\n if j>26 then break\n else begin\n if (j-x>=2)and(a[j]>=1) then begin\n inc(kol);\n inc(ans,j);\n x:=j;\n end;\n\n end;\n end;\n if kol=k then begin\n if ans1 then begin\nc:=s[i];\nsol:=sol+ord(c)-96;\ninc(nr) end;\ninc(i) end;\nif nr ord(h[h.Length]) + 1 then \n begin\n b := true;\n h += chr(ar[j]);\n break;\n end;\n end;\n if b = false then count := -1;\n end;\n if count <> -1 then \n begin\n for var i := 1 to k do\n count += ord(h[i]) - ord('a') + 1;\n writeln(count);\n end\n else\n writeln(count);\nend."}, {"source_code": "program olymp;\nvar\n s,alf : string;\n z : char;\n n,k,i,j,sum,kol,nom : longint;\nbegin\n readln(n,k);\n readln(s);\n for j:=1 to n do\n for i:=1 to n-1 do\n if s[i]>s[i+1]\n then begin\n z:=s[i];\n s[i]:=s[i+1];\n s[i+1]:=z;\n end;\n alf:='abcdefghijklmnopqrstuvwxyz';\n nom:=1;\n kol:=1;\n sum:=pos(s[1],alf);\n for i:=2 to n do begin\n //writeln(pos(s[i],alf));\n if pos(s[i],alf)-pos(s[kol],alf)>=2\n then begin\n if nom=k\n then break;\n inc(nom);\n sum:=sum+pos(s[i],alf);\n kol:=i;\n end;\n end;\n if nom=k\n then writeln(sum)\n else writeln('-1');\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-5;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,k:longint;\n st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:char);\n var tg:char;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res:longint;\n last:char;\n ok:boolean;\n begin\n readln(fi,n,k);\n readln(fi,st);\n for i:=1 to length(st)-1 do\n for j:=i+1 to length(st) do\n if st[i]>st[j] then swap(st[i],st[j]);\n last:='A';\n j:=1;\n res:=0;\n ok:=true;\n for i:=1 to k do\n begin\n while (ord(st[j])-ord(last)<2) and (j<=n) do inc(j);\n if j>n then\n begin\n ok:=false;\n break;\n end;\n last:=st[j];\n res:=res+ord(st[j])-ord('a')+1;\n inc(j);\n end;\n if not ok then write(fo,-1) else writeln(fo,res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var s:string; l:char;\n n,k,j,i,p,k1:integer;\nbegin\nreadln(n,k);\nread(s);\nfor i:=1 to n do\nfor j:=1 to n-1 do\nif s[j]>s[j+1] then begin l:=s[j]; s[j]:=s[j+1]; s[j+1]:=l; end;\np:=ord(s[1])-96; j:=ord(s[1]);\nfor i:=2 to n do\nbegin if k1+1=k then break;\nif ord(s[i])>j+1 then begin\np:=p+ord(s[i])-96;\nj:=ord(s[i]);\nk1:=k1+1;\nend;\nend;\nif k1+1=k then write(p) else write(-1);\nend."}, {"source_code": "program Project4;\nvar\n N,K,i,j,w,min,max,pos : Integer;\n s : String;\n bln : Boolean;\n A : array[1..50]of integer;\nbegin\n Readln(N,K);\n Readln(s);\n For i:=1 to N do A[i]:=Ord(s[i])-96;\n w:=0; min:=0; bln:=TRUE;\n For i:=1 to K do\n begin\n max:=27;\n pos:=0;\n For j:=1 to N do\n begin\n if (A[j]min) then\n begin\n max:=A[j];\n pos:=j;\n end;\n end;\n if pos>0 then\n begin\n w:=w+A[pos];\n min:=A[pos]+1;\n A[pos]:=27;\n end else bln:=FALSE;\n end;\n if bln then writeln(w) else writeln(-1);\nend."}, {"source_code": " var i,j,n,k,ans:longint;\n s:string;\n x:char;\n begin\n readln (n,k);\n read (s);\n\n for i:=1 to n do\n for j:=i+1 to n do\n if s[i]>s[j] then\n begin\n x:=s[i];\n s[i]:=s[j];\n s[j]:=x;\n end;\n\n x:=' ';\n\n for i:=1 to n do\n begin\n if ord(s[i])-ord(x)>1 then\n begin\n dec (k);\n inc (ans,ord(s[i])-ord('a')+1);\n x:=s[i];\n end;\n if k=0 then\n begin\n writeln (ans);\n halt;\n end;\n\n\n end;\n\n writeln (-1);\n\n\n end."}, {"source_code": "Var\n n, k, x, Ans, pos: Integer;\n a: Array [1..26] of Integer;\n S: String;\n\nBegin\n Read(n); \n Readln(k);\n Readln(S);\n pos := 1;\n For Var i := 1 to n do\n a[ord(S[i]) - 96] := 1;\n While pos <= 26 do Begin\n If (a[pos] = 1) then Begin\n Ans += pos;\n pos += 2;\n x += 1;\n If x = k then Begin\n Write(Ans);\n Exit\n End\n End\n Else\n pos += 1\n End;\n Write(-1)\nEnd."}, {"source_code": "var\n n, k, i: integer;\n\nvar\n a: array [1..26] of integer;\n\nvar\n min: integer;\n\nvar\n ch: char;\n\nfunction CreatMInRocket(m: integer): integer;\nvar\n i, j, naid, last, r: integer;\nvar\n b: array [1..26] of integer;\nbegin\n r := m;\n naid := 1;\n for i := 1 to 26 do b[i] := a[i];\n last := m;\n dec(b[m]);\n j := 1;\n \n while (naid <> k) and (r < 1000000000) do\n begin\n j := 1;\n while (((j - last) < 2) or (b[j] = 0)) and (j < 26) do inc(j);\n \n if (j = 26) and (b[26] = 0) or (j - last < 2) then r := 1000000000 else\n begin\n inc(naid);\n r += j;\n dec(b[j]);\n last := j;\n end;\n \n end;\n result := r;\nend;\n\nbegin\n readln(n, k);\n \n for i := 1 to n do \n begin\n read(ch);\n inc(a[ord(ch) - 96]);\n end;\n \n min := 1000000000;\n for i := 1 to 26 do\n if (a[i] <> 0) and (CreatMInRocket(i) < min) then min := CreatMInRocket(i);\n if (min = 1000000000) or (n < k) then min := -1;\n writeln(min);\nend."}, {"source_code": "var\nsum,min,min1,n,k,s1,s2,p1,p2:longint;\na:string;\nb: array [1..50] of longint;\nbegin\nsum:=0;\nReadln(n,k);\nReadln(a);\n\n\n\nfor s1:=1 to n do\n b[s1]:=ord(a[s1])-96; \nmin:=b[1];\nmin1:=1; \ns1:=0;\nwhile (s1<>k) and (min1<=26) do\n begin\n for s2:=1 to n do\n if (b[s2]=min1) then\n min:=b[s2];\n if min=100 then begin Writeln(-1); exit; end; \n min1:=min+2;\n sum+=min;\n min:=100;\n s1:=s1+1;\n end;\nif s1=k then \nWriteln(sum) else Writeln(-1);\nend."}, {"source_code": "Program p;\nvar n, k, j, res: integer;\n a: array of integer;\n h: char;\n\n\nbegin\nreadln(n, k);\nsetlength(a, n);\nfor var g:=0 to n-1 do\n begin\n read(h);\n a[g]:=ord(h)-96\n end;\nsort(a);\nres:=a[0];\nj:=0;\nk-=1;\nfor var g:=1 to n-1 do\n begin\n if k=0 then break;\n if a[g]-a[j]<2 then\n else \n begin\n j:=g;\n k-=1;\n res+=a[j]\n end\n end;\nif k>0 then write(-1)\n else write(res)\nend."}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=10600000;\n { modul=1000000007; }\n besk=8000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended; int64=longint;\n mas=array [-100000..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10..nn] of longint;mass1=^mass;\n var limit,posi,posj,diam,modul,oldt,ot1,time,pos,prod,ll,rr,posx,posy,gr,n,dloch,newdl,oldn,oldm,ost,ot,aa,bb,cc,p1,p2,p3,p4,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,m,smin,cen:int64;\n pp0,mask,k,i1,j1,step1, step, i,j:longint;\n y:mas;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n izb,oldpos,finot,vv,znak:int64;\n aold:mas;\n xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..1000001,-1..10] of longint;\n kolright,a,fact,next,prev,x,xx,yy,str,kol,s,name,d,dnew, voltay,l,r,c,z,day,b:mas;\n zzsum,zz:array[-10..12500000] of int64;\n ppole:array[-10..1002,-10..1005] of char;\n pole,ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1201,-10..1220] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n sss1,sss2:string;\n udal,dl,och,newoch,place,stoim,nabor:array[-10..1200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n binkoef,numleft,numright,dr: array [-10..60,-10..60] of int64;\n s3,s2,s1:array[-100..200000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nn] of string;\n sss:array[-10..nn] of string;\n tx,ty,vel,x1,y1,ott,v0,v1,s0,t0:int64;\n zv:point;\n ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\n{function prost(tt:longint):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n }\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nbegin\n\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n,k); readln(ss);\n for i:=1 to n do zan[ord(ss[i])-ord('a')+1]:=true;\n pos:=-2; ot:=0;\n for step:=1 to k do\n begin\n flag:=false;\n for i:=pos+2 to 26 do if zan[i] then begin flag:=true;ii:=i; break; end;\n { writeln(flag,' ii= ', ii);\n } if flag then begin inc(q); end else begin write(-1); goto 1; end;\n pos:=ii;\n ot:=ot+ii;\n\n end;\n\n if q2 then\n\t\tbegin\n\t\t\ttam:=s[i];\n\t\t\tt+=ord(s[i])-96;\n\t\t\tdec(k);\n\t\t\tif k=0 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(t);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\tend;\n\twriteln(-1);\nend;\nbegin\nassign(input,''); reset(input);\nassign(output,''); rewrite(output);\n\ninit;\nclose(input);\nclose(output);\nend."}, {"source_code": "program olymp;\nvar\n s,alf : string;\n z : char;\n n,k,i,j,sum,kol,nom : longint;\nbegin\n readln(n,k);\n readln(s);\n for j:=1 to n do\n for i:=1 to n-1 do\n if s[i]>s[i+1]\n then begin\n z:=s[i];\n s[i]:=s[i+1];\n s[i+1]:=z;\n end;\n alf:='abcdefghijklmnopqrsutvwxyz';\n nom:=1;\n kol:=1;\n sum:=pos(s[1],alf);\n for i:=2 to n do begin\n //writeln(pos(s[i],alf));\n if pos(s[i],alf)-pos(s[kol],alf)>=2\n then begin\n if nom=k\n then break;\n inc(nom);\n sum:=sum+pos(s[i],alf);\n kol:=i;\n end;\n end;\n if nom=k\n then writeln(sum)\n else writeln('-1');\nend."}, {"source_code": " var i,j,n,k,x,ans:longint;\n c:char;\n a:array [1..51] of longint;\n begin\n readln (n,k);\n\n for i:=1 to n do\n begin\n read (c);\n a[i]:=ord(c)-ord('a')+1;\n end;\n\n\n\n for i:=1 to n do\n for j:=i+1 to n do\n if a[i]>a[j] then\n begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\n end;\n\n\n ans:=a[1];\n dec (k);\n for i:=2 to n do\n begin\n if k=0 then\n begin\n writeln (ans);\n halt;\n end;\n\n if a[i]-a[i-1]>1 then\n begin\n dec (k);\n inc (ans,a[i]);\n end;\n\n\n\n end;\n\n\n\n if k=0 then writeln (ans)\n else writeln (-1);\n\n\n end."}, {"source_code": "Var\n n, k, x, Ans: Integer;\n a: Array [1..26] of Integer;\n S: String;\n\nBegin\n Read(n); \n Readln(k);\n Readln(S);\n For Var i := 1 to n do\n a[ord(S[i])-96] := 1;\n For Var i := 1 to 26 do\n If (a[i] <> 0) and ((i = 1) or (a[i - 1] = 0)) then Begin\n x += 1;\n Ans += i;\n If x = k then Begin\n Write(Ans);\n Exit\n End\n End;\n Write(-1)\nEnd."}, {"source_code": "var\n n, k, i: integer;\n\nvar\n a: array [1..26] of integer;\n\nvar\n min: integer;\n\nvar\n ch: char;\n\nfunction CreatMInRocket(m: integer): integer;\nvar\n i, j, naid, last, r: integer;\nvar\n b: array [1..26] of integer;\nbegin\n r := m;\n naid := 1;\n for i := 1 to 26 do b[i] := a[i];\n last := m;\n dec(b[m]);\n j := 1;\n \n while (naid <> k) and (r < 1000000000) do\n begin\n j := 1;\n while (((j - last) <= 2) or (b[j] = 0)) and (j < 26) do inc(j);\n \n if (j = 26) and (b[26] = 0) or (j - last <= 2) then r := 1000000000 else\n begin\n inc(naid);\n r += j;\n dec(b[j]);\n last := j;\n end;\n \n end;\n result := r;\nend;\n\nbegin\n readln(n, k);\n \n for i := 1 to n do \n begin\n read(ch);\n inc(a[ord(ch) - 96]);\n end;\n \n min := 1000000000;\n for i := 1 to 26 do\n if (a[i] <> 0) and (CreatMInRocket(i) < min) then min := CreatMInRocket(i);\n if (min = 1000000000) then min := -1;\n writeln(min);\nend."}, {"source_code": "var\nsum,min,min1,n,k,s1,s2,p1,p2:longint;\na:string;\nb: array [1..50] of longint;\nbegin\nsum:=0;\nReadln(n,k);\nReadln(a);\n\n\n\nfor s1:=1 to n do\n b[s1]:=ord(a[s1])-96; \nmin:=b[1];\nmin1:=1; \ns1:=0;\nwhile (s1<>k) and (min1<=26) do\n begin\n for s2:=1 to n do\n if (b[s2]=min1) then\n min:=b[s2];\n if min=100 then begin Writeln(-1); exit; end; \n min1:=min+2;\n sum+=min;\n min:=100;\n s1:=s1+1;\n end;\nWriteln(sum);\nend."}], "src_uid": "56b13d313afef9dc6c6ba2758b5ea313"} {"source_code": "var n,i,j,w,k,t:longint;\nf:array[0..501,0..501] of longint;\ns:ansistring;\nbegin\n//assign(input,'qczfc.in');reset(input);\n//assign(output,'qczfc.out');rewrite(output);\nreadln(n);\nreadln(s);\nfor i:=1 to n do f[i,i]:=1;\nfor i:=2 to n do\n for t:=1 to n-i+1 do\n begin\n w:=t+i-1;\n f[t,w]:=maxlongint;\n for k:=t to w-1 do\n if f[t,k]+f[k+1,w]-ord(s[t]=s[w])1)or(dd[j,p2]>1) then\n dd[p1,p2]:=min(dd[p1,p2],dd[p1,j]+dd[j,p2]-1);\n\n\n\n end;\n\n { writeln(ss);\n for i:=1 to n do begin for j:=1 to n do if dd[i,j]<100 then write(dd[i,j]:2,' ') else write(' * '); writeln; end;\n }\n\n writeln(dd[1,n]);\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": "var d:array [0..501,0..501] of int64;\n\ti,j,n,l,r,k:longint;\n s:ansistring;\n\nfunction min (a,b:int64):int64;\nbegin\n\tif (a <= b)\n \tthen min := a\n else min := b;\nend;\n\nfunction calc (l,r:longint):int64;\nbegin\n\tif (d[l][r] >= 0)\n then calc := d[l][r]\n else begin\n if (l > r) then calc := 0\n else begin\n if (l = r) \n then begin\n d[l][r] := 1;\n calc := 1;\n end\n else begin\n \t//writeln ('Im in');\n \td[l][r] := calc(l+1,r) + 1;\n for i:=l+1 to r do\n \tif (s[l] = s[i]) then \n d[l][r] := min (d[l][r], calc(l+1,i-1) + calc(i,r));\n calc := d[l][r];\n end;\n end;\n end;\nend;\n\nbegin\n\treadln (n);\n readln (s);\n for i:=0 to n+1 do\n \tfor j:=0 to n+1 do\n \td[i][j] := -1;\n \n \n \n writeln (calc(1,n));\n (*\n for i:=1 to n do\n begin\n \tfor j:=1 to n do\t \n \twrite (d[i][j],' ');\n writeln();\n end;*)\nend."}], "negative_code": [{"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=80000000000000000;\n modul=1000000007{998244353} ;\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zagr,xx,yy,kolizm,test,zz,predok,xold,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n ddl,ddr:array[-1..5002,-1..5002] of longint;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..4,-1..1300000] of int64;\n sum,kol,ppos,mma,ma:array[-1000..200005,-1..5] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]ss[1] then begin inc(t); x[t]:=k+1; end;\n sss:='';\n for i:=1 to t-1 do sss:=sss+copy(ss,x[i]+1,x[i+1]-x[i]-1);\n writeln('sss=',sss);\n end;\n { j:=opt(sss); }\n opt:=j+1;\nend;\n\n\n\n\nbegin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n readln(n);\n readln(ss);\n\n for step:=1 to n do\n begin\n t:=0;\n k:=length(ss);\n if k=0 then goto 2;\n for i:=1 to k do if ss[i]=ss[1] then\n begin inc(t); x[t]:=i; end;\n if ss[k+1]<>ss[1] then begin inc(t); x[t]:=k+1; end;\n sss:='';\n for i:=1 to t-1 do sss:=sss+copy(ss,x[i]+1,x[i+1]-x[i]-1);\n { writeln('sss=',sss); }\n ss:=sss;\n end;\n\n 2:\n writeln(step-1);\n\n\n\n1: close(output);\nend.\n\n\n\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]1)or(dd[j,p2]>1)} then\n dd[p1,p2]:=min(dd[p1,p2],dd[p1,j]+dd[j,p2]-1);\n\n\n\n end;\n\n { writeln(ss);\n for i:=1 to n do begin for j:=1 to n do if dd[i,j]<100 then write(dd[i,j]:2,' ') else write(' * '); writeln; end;\n }\n\n writeln(dd[1,n]);\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\ndx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n pos:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]1)and(dd[j,p2]>1) then\n dd[p1,p2]:=min(dd[p1,p2],dd[p1,j]+dd[j,p2]-1);\n\n\n\n end;\n\n { writeln(ss);\n for i:=1 to n do begin for j:=1 to n do if dd[i,j]<100 then write(dd[i,j]:2,' ') else write(' * '); writeln; end;\n }\n\n writeln(dd[1,n]);\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n"}], "src_uid": "516a89f4d1ae867fc1151becd92471e6"} {"source_code": "var n:longint;s:ansistring;\nprocedure Input;\nbegin\n readln(n);\n readln(s);\nend;\nprocedure Work;\nvar i,j,k:longint;\nbegin\n j:=0;\n k:=0;\n for i:=1 to n do\n if s[i]='1' then inc(k);\n if k*2<>n then begin writeln(1); write(s); readln; halt; end;\n for i:=1 to n do\n begin\n if s[i]='1' then inc(j);\n if (j*2<>i) and ((k-j)*2<>n-i) then\n begin\n writeln(2);\n write(copy(s,1,i),' ',copy(s,i+1,n-i));\n readln;\n halt;\n end;\n end;\nend;\nbegin\n Input;\n Work;\nend.", "positive_code": [{"source_code": "function hor(const s:string):boolean;\nvar n, e, i: longint;\nbegin\n n:= 0;\n e:= 0;\n for i:= 1 to length(s) do begin\n if (s[i]='0') then\n inc(n);\n if (s[i]='1') then\n inc(e);\n end;\n if (e<>n) then\n hor:= true\n else hor:= false;\nend;\n\nvar s: string;\nn, i:longint;\ng: boolean;\nbegin\n readln(n);\n readln(s);\n if hor(s) then begin\n writeln(1);\n writeln(s);\n end else begin\n g:= false;\n for i:= 1 to n do\n if not g and hor(copy(s, 1, i)) and hor(copy(s, i+1, length(s))) then begin\n g:= true;\n writeln(2);\n writeln(copy(s, 1, i), ' ', copy(s, i+1, length(s)));\n end;\n end;\nend.\n "}, {"source_code": "program ppp;\n\n\nvar n,l,n0,n1: integer; \n s, s_out: string;\n// a,b,k:array of int64;\n n_out: integer;\n\nbegin\n \n readln(n);\n readln(s);\n for var i:=1 to n do begin\n if s[i]='0' then n0:=n0+1\n else n1:=n1+1;\n if n0<>n1 then begin\n s_out:=s;\n n_out:=1;\n end\n else begin\n n_out:=2;\n s_out:= s[1]+ ' ' + RightStr(s,n-1);\n end;\n \n end;\n\n writeln(n_out);\n writeln(s_out);\nend."}, {"source_code": "var\nn,t,x,i,k:int64;\na:string;\nbegin\n readln(t);\n read(a);\n for i:=1 to t do\n if a[i]='1' then k:=k+1 else x:=x+1;\n if k=x then begin writeln(2); write(a[1],' ',copy(a,2,t-1));end else begin\n writeln(1); write(a); end;\n \nend."}, {"source_code": "var\n\tb, n, c, m, x, x1, x2: integer;\n\ts: string;\n\ta, a1: array of integer;\n\t\nbegin\n\t\n\treadln(c);\n\treadln(s);\n\tfor var i := 1 to s.length do\n\tbegin\n\t\tif (s[i] = '0') then\n\t\tbegin\n\t\t\tx += 1;\n\t\tend\n\t\telse x1 += 1;\n\tend;\n\tif (x = x1) then\n\tbegin\n\t\twriteln(2);\n\t\twrite(s[1], ' ');\n\t\tdelete(s, 1, 1);\n\t\twriteln(s);\n\tend\n\telse begin\n\t\twriteln(1);\n\t\twriteln(s);\n\tend;\n\nend.\n"}, {"source_code": "var n,i,k:longint;\n s,s1:string;\nBEGIN\nreadln(n);\nreadln(s);\n\nk:=0;\nfor i:=1 to n do \n begin\n if s[i] = '1' then \n inc(k);\n end;\n\nif (n-k > k) or (n-k < k) then\nbegin\nwriteln(1);\nwriteln(s);\nend\nelse\nbegin\ns1:=copy(s,1,s.Length-1);\nwriteln(2);\nwriteln(s1,' ',s[n]);\nend; \nEND."}, {"source_code": "var\n n, i, x1, x2: integer;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n \n if n=1 then \n begin\n writeln('1');\n writeln(s);\n end\n else\nbegin\n \n for i := 1 to n do\n if s[i] = '1' then x1 := x1 + 1\n else\n x2 := x2 + 1;\n \n if x1 = x2 then \n begin\n writeln('2');\n write(s[1]);\n write(' ');\n for i := 2 to n do\n write(s[i]);\n end\n else\n begin\n writeln('1');\n writeln(s);\n end;\nend;\nend.\n"}, {"source_code": "var\ns:string;\nlen, num0, num1, i :integer;\nbegin\nreadln(len);\nreadln(s);\nnum0:=0;\nnum1:=0;\nfor i:=1 to length(s) do begin\nif s[i] = '1' then\nnum1:=num1 + 1\nelse\nnum0 := num0 + 1;\nend;\nif num1 <> num0 then begin\nwriteln(1);\nfor i := 1 to length(s) do\nwrite(s[i]);\nend\nelse begin\nwriteln(2);\nwrite(s[1],' ');\nfor i:=2 to length(s) do\nwrite(s[i]);\nend;\nend."}, {"source_code": "var s:string;\nt,cnt1,n,cnt2:integer;\nbegin\n readln(n);\n\n read(s);\n cnt1:=0;\n cnt2:=0;\n n:=length(s);\n for var j:=1 to n do begin\n if s[j]='1' then cnt1:=cnt1+1\n else cnt2:=cnt2+1;\n end;\n if cnt1<>cnt2 then writeln(1,' ',s)\n else begin\n writeln(2);\n write(copy(s,1,n-1),' ',s[n]);\n end\n \nend."}, {"source_code": "Var\n n, n0, n1: Int64;\n s: String;\n\nBegin\n Readln(n);\n Readln(s);\n For Var i := 1 to n do\n If S[i] = '1' then\n n1 += 1\n Else\n n0 += 1;\n If n1 <> n0 then Begin\n Writeln(1);\n Write(s)\n End\n Else Begin\n Writeln(2);\n Write(S[1], ' ');\n Delete(S, 1, 1);\n Write(S)\n End\nEnd."}, {"source_code": "Program ILoveYou;\nVAR n,i,nr1,nr2:int64; s:string;\nBegin\n\nReadln(n);\nReadln(s);\nfor i:=1 to length(s) do\nBegin\nif (s[i] = '1') then nr1:=nr1 + 1 else nr2:=nr2 + 1;\nend;\n\nif (nr1 <> nr2) then\nBegin\n\nWriteln(1);\nWriteln(s);\n\nend else\nBegin\n\nWriteln(2);\nWrite(s[1],' ');\nfor i:=2 to length(s) do\nBegin\nWrite(s[i]);\nend;\n\n\nend;\n\nReadln;\nEND."}, {"source_code": "var \n n,k0,k1:byte;\n s:string;\n c:char;\nbegin\n readln(n);\n s:='';\n for var i:=1 to n do\n begin\n read(c);\n case c of\n '1':inc(k1);\n '0':inc(k0);\n end;\n s:=s+c;\n end;\n if k0=k1 then\n begin\n writeln(2);\n writeln(s[1]);\n Delete(s,1,1);\n writeln(s);\n end\n else\n begin\n writeln(1);\n writeln(s);\n end;\nend."}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\n type mas=array[-10000..5500000+1] of int64; integer=longint;\n var p0,i2,i3,dl,len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss,ss1,ss2:string;\n koll,w,pos,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n prost,marked,zan:array[-10..4000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n zzz:array[0..100,0..100] of longint;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..1100,-1..700] of char;\n dd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..25] of int64;\n poss:int64;\n ch:char;\n flagg1:boolean;\n s,ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-100000..4000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]2 then\n begin\n if n mod 2=1 then\n begin\n writeln(1);\n writeln(s)\n end else if n mod 2=0 then\n begin\n kilk:=0;\n for i:=1 to n do\n if s[i]='0' then inc(kilk);\n if kilk<>n-kilk then\n begin\n writeln(1);\n writeln(s)\n end else\n begin\n k1:=0;\n k2:=0;\n c:=s[1];\n if c='1' then\n begin\n writeln(2);\n write(c,' ');\n delete(s,1,1);\n writeln(s)\n end else\n begin\n k2:=1;\n for i:=2 to n do\n begin\n if s[i]='1' then inc(k1) else inc(k2);\n if (k1<>k2) and (k1>0) then\n begin\n s1:=copy(s,1,i);\n delete(s,1,i);\n break\n end\n end;\n writeln(2);\n writeln(s1,' ',s)\n end\n end\n end\n end; readln\nend."}, {"source_code": "Program KeanuReeves;\nvar s,s1,s2:string; n,i,t1,t2,k1,k2:byte;\nbegin //assign(input,'1189A.inp'); reset(input);\n //assign(output,'1189A.out'); rewrite(output);\n readln(n);\n readln(s);\n t1:=0; t2:=0;\n for i:=1 to length(s) do\n if s[i]='1' then t1:=t1+1\n else t2:=t2+1;\n if t1<>t2 then\n begin writeln(1); writeln(s); exit;\n end else\n begin k1:=0; k2:=0;\n for i:=1 to length(s) do\n begin if s[i]='1' then k1:=k1+1\n else k2:=k2+1;\n if (k1<>k2) and (t1-k1<>t2-k2) then\n begin s1:=copy(s,1,i); s2:=copy(s,i+1,length(s)-i+1);\n writeln(2); write(s1,#32,s2);\n exit;\n end;\n end;\n end;\n //close(input); close(output);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,i,so0,so1,s:longint;\n st,kq:ansistring;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n read(f,st);\n\n assign(f,fo);rewrite(f);\n for i:=1 to n do\n if st[i]='0' then inc(so0) else inc(so1);\n if so1 <> so0 then begin writeln(f,1); writeln(f,st) end\n else\n begin\n for i:=1 to (n div 2) do\n begin\n if st[i]='0' then\n begin\n kq:=kq+'0';\n dec(so0);\n end;\n if st[i]='1' then\n begin\n kq:=kq+'1';\n dec(so1);\n end;\n if so1 <> so0 then begin s:=i; break; end;\n end;\n writeln(f,2);\n write(f,kq,' ');\n for i:=s+1 to n do\n write(f,st[i]);\n end;\n close(f);\nend.\n"}, {"source_code": "var S:STRING; c0,c1,n,i:integer;\n\nbegin\nreadln(n);\nreadln(s);\nc0:=0;\nc1:=0;\nfor i:=1 to n do begin\nif (s[i]='1') then begin\ninc(c1);\nend\nelse \nbegin\ninc(c0);\nend;\nend;\nif c1=c0 then begin\nwriteln(2);\nfor i:=1 to n-1 do begin\nwrite(s[i]);\nend;\nwriteln(' ',s[n]);\nend\nelse\nbegin\nwriteln(1);\nwriteln(s);\nend;\nend.\n"}, {"source_code": "var n,i,j,k:longint;\ns,a,b:ansistring;\nfunction gud(s:ansistring):boolean;\nvar i,r,c:longint;\ntf:boolean;\nbegin\nr:=0; c:=0;\ntf:=true;\nfor i:=1 to length(s) do if s[i]='1' then inc(r) else inc(c);\nif r=c then tf:=false;\ngud:=tf;\nend;\nbegin\nreadln(n);\nreadln(s);\nif gud(s) then begin writeln('1'); writeln(s); end else\nbegin\na:='';\n for i:=1 to length(s) do\n begin\n for j:=1 to i do a:=a+s[j];\n if gud(a) then\n begin\n b:='';\n for k:=i+1 to length(s) do b:=b+s[k];\n if gud(b) then\n begin\n writeln('2');\n writeln(a,' ',b);\n break;\n end;\n end;\n end;\nend;\nreadln;\nend.\n"}, {"source_code": "var\n n,i,x:longint;\n s:string;\nbegin\n readln(n); readln(s);\n for i:=1 to n do\n if s[i]='1' then inc(x);\n if x<<1=n then\n begin\n writeln(2);\n writeln(copy(s,1,n-1),' ',s[n]);\n end\n else\n begin\n writeln(1);\n writeln(s);\n end;\nend."}, {"source_code": "var\n n,i,x:longint;\n s:string;\nbegin\n readln(n); readln(s);\n for i:=1 to n do x:=x+ord(s[i])-48;\n if x*2=n then\n begin\n writeln(2);\n writeln(copy(s,1,n-1),' ',s[n]);\n end\n else\n begin\n writeln(1);\n writeln(s);\n end;\nend."}, {"source_code": " \n \n\nvar\nx,y,x1,y1,x2,y2,z,q, i,j,k,k1,m,h1,t,n,bx,by:longint;\na,a1,a0,b,c:longint;\ns:ansistring;\nflag:boolean;\n\n//1000000000000000000 \n//1000000000000000000 \nbegin\n //You're breathtaking!\n readln(n);\n readln(s);\n a0:=0;\n a1:=0;\n for i:=1 to n do begin\n if (s[i]='0') then a0:=a0+1\n else a1:=a1+1;\n end;\n if (a0<>a1) then begin\n writeln(1);\n writeln(s);\n end\n else begin\n writeln(2);\n for i:=1 to n-1 do\n write(s[i]);\n write(' ',s[n]);\n end;\nend."}, {"source_code": "var\nn,i,zero,one:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\n\nfor i:=1 to n do begin\n if s[i]='0' then inc(zero)\n else\n inc(one);\nend;\n if one<>zero then begin\n writeln(1);\n writeln(s);\n end\n else begin\n writeln(2);\n for i:=1 to length(s)-1 do write(s[i]);\n write(' ');\n write(s[n]);\n writeln;\n end;\nend."}, {"source_code": "//type ansistring = string;\n\nfunction is_good (n:longint; s:ansistring):boolean;\nvar i,one,zero:longint;\nbegin\n one:=0;\n zero:=0;\n for i:= 1 to n do begin\n if s[i] = '1' then \n inc(one)\n else\n inc(zero)\n end;\n is_good:= one <> zero\nend;\n\nvar \n n:longint;\n s:ansistring;\n \nbegin\n readln(n);\n readln(s);\n if is_good(n,s) then begin\n writeln(1);\n writeln(s);\n end else begin\n writeln(2);\n writeln(copy(s,1,length(s)-1),' ',s[length(s)]);\n end;\nend."}, {"source_code": "var s:string;\n n,i,tot:longint;\nbegin\n readln(n);readln(s);\n for i:=1 to length(s) do if s[i]='1' then inc(tot);\n if (tot<>length(s) div 2) or ((n and 1)>0) then begin writeln(1);writeln(s);exit;end;\n writeln(2);write(s[1],' ');delete(s,1,1);writeln(s);\nend."}, {"source_code": "var n,i:word;\n st:string;\n s0,s1:array [0..100] of word;\n\nbegin\n //Assign(input,'KR.inp'); reset(input);\n //Assign(output,'KR.out'); rewrite(output);\n readln(n); read(st);\n for i:=1 to n do\n if (st[i]='0') then\n begin\n s0[i]:=s0[i-1]+1; s1[i]:=s1[i-1];\n end\n else begin\n s1[i]:=s1[i-1]+1; s0[i]:=s0[i-1];\n end;\n if (s0[n]<>s1[n]) then\n begin\n writeln(1); write(st);\n end\n else for i:=1 to n-1 do\n if (s0[i]<>s1[i]) and (s0[n]-s0[i]<>s1[n]-s1[i]) then\n begin\n writeln(2);\n write(copy(st,1,i),#32,copy(st,i+1,n-i));\n break;\n end;\nend."}, {"source_code": "var n,count0,count1,i:longint;\n s:string;\nbegin\n readln(n);\n read(s);\n for i:=1 to length(s) do\n begin\n if s[i]='0' then inc(count0)\n else inc(count1);\n end;\n if count0<>count1 then\n begin\n writeln(1);\n writeln(s);\n end\n else\n begin\n writeln(2);\n for i:=1 to length(s)-1 do write(s[i]);\n write(' ');\n write(s[length(s)]);\n end;\nend.\n"}, {"source_code": "program aaaaaaaaaaaa;\nvar\ns:string;\na,b:array[0..1000] of longint;\nn,i,k,o,tmp:longint;\nbegin\n\n readln(n);\n readln(s);\n for i:=1 to n do\n begin\n\n a[i]:=a[i]+a[i-1]+ord(s[i])-48;\n end;\n o:=0;\n k:=0;\n\n repeat\n tmp:=o;\n for i:=o+1 to n do if (a[i]-a[tmp]<>i-tmp-(a[i]-a[tmp])) then o:=i;\n b[o]:=1;\n inc(K);\n until o=n;\n writeln;\n writeln(k);\n for i:=1 to n do\n begin\n write(s[i]);\n if (b[i]=1) and (i<>n) then write(' ');\n end;\n\nend.\n"}, {"source_code": "var s : string;\n i,k0,k1,l : longint;\nbegin\n readln(l);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='0' then inc(k0);\n if s[i]='1' then inc(k1);\n end;\n if k0=k1 then \n begin\n writeln(2);\n for i:=1 to length(s)-1 do\n write(s[i]);\n write(' ',s[length(s)]);\n end\n else \n begin\n writeln(1);\n writeln(s);\n end;\nend."}, {"source_code": "var s:string;\n i,n,k1,k2:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do if s[i]='0' then inc(k1) else dec(k1);\n if k1<>0 then begin writeln(1); writeln(s); end\n else begin writeln(2);writeln(s[1],' ',copy(s,2,n-1)); end\nend."}, {"source_code": "var\nn,a,b,i:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\na:=0;\nb:=0;\nfor i:=1 to n do\n if s[i]='0' then inc(a)\n else inc(b);\nif a=b then\n begin\n writeln('2');\n writeln(s[1],' ',copy(s,2,n-1));\n end\n else\n begin\n writeln('1');\n writeln(s);\n end;\nend."}, {"source_code": "var n,c0,c1,i:longint;\n a:ansistring;\nbegin\n readln(n);\n readln(a);\n for i:=1 to length(a) do\n if a[i]='1' then\n inc(c1)\n else\n inc(c0);\n if c1<>c0 then writeln(1,#13,a)\n else writeln(2,#13,a[1],' ',copy(a,2,length(a)-1));\nend."}, {"source_code": "var\n n,i,x:longint;\n s,t:string;\nbegin\n readln(n); readln(s);\n if n=1 then\n begin\n writeln(n);\n writeln(s);\n exit;\n end;\n for i:=1 to n do\n if s[i]='1' then inc(x);\n if x*2=n then\n begin\n writeln(2);\n t:=copy(s,1,n-1);\n writeln(t,' ',s[n]);\n end\n else\n begin\n writeln(1);\n writeln(s);\n end;\nend."}], "negative_code": [{"source_code": " \n\nvar\nx,y,x1,y1,x2,y2,z,q, i,j,k,k1,m,h1,t,n,bx,by:longint;\na,a1,a0,b,c:longint;\ns:ansistring;\nflag:boolean;\n\n//1000000000000000000 \n//1000000000000000000 \nbegin\n //You're breathtaking!\n readln(n);\n readln(s);\n a0:=0;\n a1:=0;\n for i:=1 to n do begin\n if (s[i]='0') then a0:=a0+1\n else a1:=a1+1;\n end;\n if (a0<>a1) then begin\n writeln(1);\n writeln(s);\n end\n else begin\n writeln(2);\n for i:=1 to n-1 do\n write(s[i]);\n write(s[n]);\n end;\nend."}, {"source_code": "//type ansistring = string;\n\nfunction is_good (n:longint; s:ansistring):boolean;\nvar i,one,zero:longint;\nbegin\n one:=0;\n zero:=0;\n for i:= 1 to n do begin\n if s[i] = '1' then \n inc(one)\n else\n inc(zero)\n end;\n is_good:= one <> zero\nend;\n\nvar \n n:longint;\n s:ansistring;\n \nbegin\n readln(n);\n readln(s);\n if is_good(n,s) then begin\n writeln(n);\n writeln(s);\n end else begin\n writeln(2);\n writeln(copy(s,1,length(s)-1),' ',s[length(s)]);\n end;\nend."}, {"source_code": "var s:string;\n n,i,tot:longint;\nbegin\n readln(n);readln(s);\n for i:=1 to length(s) do if s[i]='1' then inc(tot);\n if tot<>length(s) div 2 then begin writeln(s);exit;end;\n write(s[1],' ');delete(s,1,1);writeln(s);\nend."}, {"source_code": "var s:string;\n n,i,tot:longint;\nbegin\n readln(n);readln(s);\n for i:=1 to length(s) do if s[i]='1' then inc(tot);\n if tot<>length(s) div 2 then begin writeln(1);writeln(s);exit;end;\n writeln(2);write(s[1],' ');delete(s,1,1);writeln(s);\nend."}, {"source_code": "var n,c0,c1,i:longint;\n a:ansistring;\nbegin\n readln(n);\n readln(a);\n for i:=length(a) downto 1 do\n if a[1]='1' then\n inc(c1)\n else\n inc(c0);\n if c1<>c0 then writeln(1,#13,a)\n else writeln(2,#13,a[1],#13,copy(a,2,length(a)-1));\nend."}, {"source_code": "var\n n:longint;\n s,t:string;\nbegin\n readln(n); readln(s);\n if n=1 then\n begin\n writeln(n);\n writeln(s);\n exit;\n end;\n t:=copy(s,1,n-1);\n writeln(t,' ',s[n]);\nend."}, {"source_code": "var\n n:longint;\n s,t:string;\nbegin\n readln(n); readln(s);\n if n=1 then\n begin\n writeln(n);\n writeln(s);\n exit;\n end;\n t:=copy(s,1,n-1);\n writeln(2);\n writeln(t,' ',s[n]);\nend."}, {"source_code": "var\n\tb, n, c, m, x, x1, x2: integer;\n\ts: string;\n\ta, a1: array of integer;\n\t\nbegin\n\t\n\treadln(c);\n\treadln(s);\n\tfor var i := 1 to c do\n\tbegin\n\t\tif (s[i] = '0') then\n\t\tbegin\n\t\t\tx += 1;\n\t\tend\n\t\telse x1 += 1;\n\tend;\n\tif (x = x1) then\n\tbegin\n\t\twriteln(2);\n\t\tfor var i := 1 to s.length do\n\t\tbegin\n\t\t\twrite(s[i]);\n\t\t\tif (i = s.length - 1) then write(' ');\n\t\tend;\n\tend\n\telse begin\n\t\twriteln(c);\n\t\tfor var i := 1 to s.length do\n\t\tbegin\n\t\t\twrite(s[i]);\n\t\t\tif (i = s.length div 2) then write(' ');\n\t\tend;\n\tend;\n\nend.\n"}, {"source_code": "var\n n, i, x1, x2: integer;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n \n if n=1 then \n begin\n writeln('1');\n writeln(s);\n end;\n \n for i := 1 to n do\n if s[i] = '1' then x1 := x1 + 1\n else\n x2 := x2 + 1;\n \n if x1 = x2 then \n begin\n writeln('2');\n write(s[1]);\n write(' ');\n for i := 2 to n do\n write(s[i]);\n end;\n \nend."}, {"source_code": "var\ns:string;\nlen, num0, num1, i :integer;\nbegin\nreadln(len);\nreadln(s);\nfor i:=1 to length(s) do begin\nif s[i] = '1' then\nnum1:=num1 + 1\nelse\nnum0 := num0 + 1;\nend;\nif num1 <> num0 then begin\nwriteln(1);\nfor i := 1 to length(s) do\nwriteln(s[i]);\nend\nelse begin\nwriteln(2);\nwrite(s[1],' ');\nfor i:=2 to length(s) do\nwrite(s[i]);\nend;\nend."}, {"source_code": "program a;\n\n{$APPTYPE CONSOLE}\n\n uses Math;\n var b:array[1..100] of longint;\n i,n,z,k,kilk,k1,k2:longint;\n c:char;\n s,s1:string;\nbegin\n readln(n);\n readln(s);\n if n=1 then\n begin\n writeln(1);\n writeln(s)\n end else if n=2 then\n begin\n if s[1]=s[2] then\n begin\n writeln(1);\n writeln(s)\n end else\n begin\n writeln(2);\n writeln(s[1],' ',s[2])\n end\n end else if n>2 then\n begin\n if n mod 2=1 then\n begin\n writeln(1);\n writeln(s)\n end else if n mod 2=0 then\n begin\n kilk:=0;\n for i:=1 to n do\n if s[i]='0' then inc(kilk);\n if kilk<>n-kilk then\n begin\n writeln(1);\n writeln(s)\n end else\n begin\n k1:=0;\n k2:=0;\n c:=s[1];\n if c='1' then\n begin\n writeln(2);\n write(c,' ');\n delete(s,1,1);\n writeln(s)\n end else\n begin\n for i:=2 to n do\n begin\n if s[i]='1' then inc(k1) else inc(k2);\n if (k1<>k2) and (k1>0) then\n begin\n s1:=copy(s,1,i);\n delete(s,1,i);\n break\n end\n end;\n writeln(2);\n writeln(s1,' ',s)\n end\n end\n end\n end; \nend.\n"}, {"source_code": "program a;\n\n{$APPTYPE CONSOLE}\n\n uses Math;\n var b:array[1..100] of longint;\n i,n,z,k,kilk,k1,k2:longint;\n s,s1:string;\nbegin\n readln(n);\n readln(s);\n if n=1 then\n begin\n writeln(1);\n writeln(s)\n end else if n=2 then\n begin\n if s[1]=s[2] then\n begin\n writeln(1);\n writeln(s)\n end else\n begin\n writeln(2);\n writeln(s[1],' ',s[2])\n end\n end else if n>2 then\n begin\n kilk:=0;\n for i:=1 to n do\n if s[i]='0' then inc(kilk);\n if kilk<>n-kilk then\n begin\n writeln(1);\n writeln(s)\n end else if kilk=n-kilk then\n begin\n if s[1]='1' then\n begin\n writeln(2);\n write(s[1],' ');\n delete(s,1,1);\n writeln(s)\n end else if s[1]='0' then\n begin\n k1:=1;\n k2:=0;\n for i:=2 to n do\n begin\n if s[i]='0' then inc(k1) else inc(k2);\n if (k1<>k2) and (k2>0) then\n begin\n s1:=copy(s,1,i);\n delete(s,1,i);\n break\n end\n end;\n writeln(s1,' ',s)\n end\n end\n end; \nend."}], "src_uid": "4ebed264d40a449602a26ceef2e849d1"} {"source_code": "program gtRus;\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\nconst p:array[1..9592] of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,\n53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,\n127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,\n199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,\n283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,\n383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,\n467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,\n577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,\n661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,\n769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,\n877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,\n983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,\n1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,\n1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,\n1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,\n1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,\n1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,\n1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,\n1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,\n1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,\n1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,\n2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,\n2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,\n2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,\n2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,\n2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,\n2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,\n2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,\n2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,\n3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,\n3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,\n3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,\n3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,\n3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,\n3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,\n3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,\n3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,\n4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,\n4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,\n4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,\n4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,\n4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,\n4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,\n4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,\n4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,\n5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,\n5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,\n5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,\n5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,\n5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,\n5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,\n5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,\n5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,\n6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,\n6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,\n6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,\n6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,\n6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,\n6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,\n6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,\n7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,\n7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,\n7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,\n7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,\n7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,\n7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,\n7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,\n7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,\n8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,\n8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,\n8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,\n8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,\n8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,\n8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,\n8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,\n9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,\n9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,\n9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,\n9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,\n9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,\n9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,\n9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973,10007,\n10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,10103,10111,10133,10139,10141,\n10151,10159,10163,10169,10177,10181,10193,10211,10223,10243,10247,10253,10259,10267,10271,\n10273,10289,10301,10303,10313,10321,10331,10333,10337,10343,10357,10369,10391,10399,10427,\n10429,10433,10453,10457,10459,10463,10477,10487,10499,10501,10513,10529,10531,10559,10567,\n10589,10597,10601,10607,10613,10627,10631,10639,10651,10657,10663,10667,10687,10691,10709,\n10711,10723,10729,10733,10739,10753,10771,10781,10789,10799,10831,10837,10847,10853,10859,\n10861,10867,10883,10889,10891,10903,10909,10937,10939,10949,10957,10973,10979,10987,10993,\n11003,11027,11047,11057,11059,11069,11071,11083,11087,11093,11113,11117,11119,11131,11149,\n11159,11161,11171,11173,11177,11197,11213,11239,11243,11251,11257,11261,11273,11279,11287,\n11299,11311,11317,11321,11329,11351,11353,11369,11383,11393,11399,11411,11423,11437,11443,\n11447,11467,11471,11483,11489,11491,11497,11503,11519,11527,11549,11551,11579,11587,11593,\n11597,11617,11621,11633,11657,11677,11681,11689,11699,11701,11717,11719,11731,11743,11777,\n11779,11783,11789,11801,11807,11813,11821,11827,11831,11833,11839,11863,11867,11887,11897,\n11903,11909,11923,11927,11933,11939,11941,11953,11959,11969,11971,11981,11987,12007,12011,\n12037,12041,12043,12049,12071,12073,12097,12101,12107,12109,12113,12119,12143,12149,12157,\n12161,12163,12197,12203,12211,12227,12239,12241,12251,12253,12263,12269,12277,12281,12289,\n12301,12323,12329,12343,12347,12373,12377,12379,12391,12401,12409,12413,12421,12433,12437,\n12451,12457,12473,12479,12487,12491,12497,12503,12511,12517,12527,12539,12541,12547,12553,\n12569,12577,12583,12589,12601,12611,12613,12619,12637,12641,12647,12653,12659,12671,12689,\n12697,12703,12713,12721,12739,12743,12757,12763,12781,12791,12799,12809,12821,12823,12829,\n12841,12853,12889,12893,12899,12907,12911,12917,12919,12923,12941,12953,12959,12967,12973,\n12979,12983,13001,13003,13007,13009,13033,13037,13043,13049,13063,13093,13099,13103,13109,\n13121,13127,13147,13151,13159,13163,13171,13177,13183,13187,13217,13219,13229,13241,13249,\n13259,13267,13291,13297,13309,13313,13327,13331,13337,13339,13367,13381,13397,13399,13411,\n13417,13421,13441,13451,13457,13463,13469,13477,13487,13499,13513,13523,13537,13553,13567,\n13577,13591,13597,13613,13619,13627,13633,13649,13669,13679,13681,13687,13691,13693,13697,\n13709,13711,13721,13723,13729,13751,13757,13759,13763,13781,13789,13799,13807,13829,13831,\n13841,13859,13873,13877,13879,13883,13901,13903,13907,13913,13921,13931,13933,13963,13967,\n13997,13999,14009,14011,14029,14033,14051,14057,14071,14081,14083,14087,14107,14143,14149,\n14153,14159,14173,14177,14197,14207,14221,14243,14249,14251,14281,14293,14303,14321,14323,\n14327,14341,14347,14369,14387,14389,14401,14407,14411,14419,14423,14431,14437,14447,14449,\n14461,14479,14489,14503,14519,14533,14537,14543,14549,14551,14557,14561,14563,14591,14593,\n14621,14627,14629,14633,14639,14653,14657,14669,14683,14699,14713,14717,14723,14731,14737,\n14741,14747,14753,14759,14767,14771,14779,14783,14797,14813,14821,14827,14831,14843,14851,\n14867,14869,14879,14887,14891,14897,14923,14929,14939,14947,14951,14957,14969,14983,15013,\n15017,15031,15053,15061,15073,15077,15083,15091,15101,15107,15121,15131,15137,15139,15149,\n15161,15173,15187,15193,15199,15217,15227,15233,15241,15259,15263,15269,15271,15277,15287,\n15289,15299,15307,15313,15319,15329,15331,15349,15359,15361,15373,15377,15383,15391,15401,\n15413,15427,15439,15443,15451,15461,15467,15473,15493,15497,15511,15527,15541,15551,15559,\n15569,15581,15583,15601,15607,15619,15629,15641,15643,15647,15649,15661,15667,15671,15679,\n15683,15727,15731,15733,15737,15739,15749,15761,15767,15773,15787,15791,15797,15803,15809,\n15817,15823,15859,15877,15881,15887,15889,15901,15907,15913,15919,15923,15937,15959,15971,\n15973,15991,16001,16007,16033,16057,16061,16063,16067,16069,16073,16087,16091,16097,16103,\n16111,16127,16139,16141,16183,16187,16189,16193,16217,16223,16229,16231,16249,16253,16267,\n16273,16301,16319,16333,16339,16349,16361,16363,16369,16381,16411,16417,16421,16427,16433,\n16447,16451,16453,16477,16481,16487,16493,16519,16529,16547,16553,16561,16567,16573,16603,\n16607,16619,16631,16633,16649,16651,16657,16661,16673,16691,16693,16699,16703,16729,16741,\n16747,16759,16763,16787,16811,16823,16829,16831,16843,16871,16879,16883,16889,16901,16903,\n16921,16927,16931,16937,16943,16963,16979,16981,16987,16993,17011,17021,17027,17029,17033,\n17041,17047,17053,17077,17093,17099,17107,17117,17123,17137,17159,17167,17183,17189,17191,\n17203,17207,17209,17231,17239,17257,17291,17293,17299,17317,17321,17327,17333,17341,17351,\n17359,17377,17383,17387,17389,17393,17401,17417,17419,17431,17443,17449,17467,17471,17477,\n17483,17489,17491,17497,17509,17519,17539,17551,17569,17573,17579,17581,17597,17599,17609,\n17623,17627,17657,17659,17669,17681,17683,17707,17713,17729,17737,17747,17749,17761,17783,\n17789,17791,17807,17827,17837,17839,17851,17863,17881,17891,17903,17909,17911,17921,17923,\n17929,17939,17957,17959,17971,17977,17981,17987,17989,18013,18041,18043,18047,18049,18059,\n18061,18077,18089,18097,18119,18121,18127,18131,18133,18143,18149,18169,18181,18191,18199,\n18211,18217,18223,18229,18233,18251,18253,18257,18269,18287,18289,18301,18307,18311,18313,\n18329,18341,18353,18367,18371,18379,18397,18401,18413,18427,18433,18439,18443,18451,18457,\n18461,18481,18493,18503,18517,18521,18523,18539,18541,18553,18583,18587,18593,18617,18637,\n18661,18671,18679,18691,18701,18713,18719,18731,18743,18749,18757,18773,18787,18793,18797,\n18803,18839,18859,18869,18899,18911,18913,18917,18919,18947,18959,18973,18979,19001,19009,\n19013,19031,19037,19051,19069,19073,19079,19081,19087,19121,19139,19141,19157,19163,19181,\n19183,19207,19211,19213,19219,19231,19237,19249,19259,19267,19273,19289,19301,19309,19319,\n19333,19373,19379,19381,19387,19391,19403,19417,19421,19423,19427,19429,19433,19441,19447,\n19457,19463,19469,19471,19477,19483,19489,19501,19507,19531,19541,19543,19553,19559,19571,\n19577,19583,19597,19603,19609,19661,19681,19687,19697,19699,19709,19717,19727,19739,19751,\n19753,19759,19763,19777,19793,19801,19813,19819,19841,19843,19853,19861,19867,19889,19891,\n19913,19919,19927,19937,19949,19961,19963,19973,19979,19991,19993,19997,20011,20021,20023,\n20029,20047,20051,20063,20071,20089,20101,20107,20113,20117,20123,20129,20143,20147,20149,\n20161,20173,20177,20183,20201,20219,20231,20233,20249,20261,20269,20287,20297,20323,20327,\n20333,20341,20347,20353,20357,20359,20369,20389,20393,20399,20407,20411,20431,20441,20443,\n20477,20479,20483,20507,20509,20521,20533,20543,20549,20551,20563,20593,20599,20611,20627,\n20639,20641,20663,20681,20693,20707,20717,20719,20731,20743,20747,20749,20753,20759,20771,\n20773,20789,20807,20809,20849,20857,20873,20879,20887,20897,20899,20903,20921,20929,20939,\n20947,20959,20963,20981,20983,21001,21011,21013,21017,21019,21023,21031,21059,21061,21067,\n21089,21101,21107,21121,21139,21143,21149,21157,21163,21169,21179,21187,21191,21193,21211,\n21221,21227,21247,21269,21277,21283,21313,21317,21319,21323,21341,21347,21377,21379,21383,\n21391,21397,21401,21407,21419,21433,21467,21481,21487,21491,21493,21499,21503,21517,21521,\n21523,21529,21557,21559,21563,21569,21577,21587,21589,21599,21601,21611,21613,21617,21647,\n21649,21661,21673,21683,21701,21713,21727,21737,21739,21751,21757,21767,21773,21787,21799,\n21803,21817,21821,21839,21841,21851,21859,21863,21871,21881,21893,21911,21929,21937,21943,\n21961,21977,21991,21997,22003,22013,22027,22031,22037,22039,22051,22063,22067,22073,22079,\n22091,22093,22109,22111,22123,22129,22133,22147,22153,22157,22159,22171,22189,22193,22229,\n22247,22259,22271,22273,22277,22279,22283,22291,22303,22307,22343,22349,22367,22369,22381,\n22391,22397,22409,22433,22441,22447,22453,22469,22481,22483,22501,22511,22531,22541,22543,\n22549,22567,22571,22573,22613,22619,22621,22637,22639,22643,22651,22669,22679,22691,22697,\n22699,22709,22717,22721,22727,22739,22741,22751,22769,22777,22783,22787,22807,22811,22817,\n22853,22859,22861,22871,22877,22901,22907,22921,22937,22943,22961,22963,22973,22993,23003,\n23011,23017,23021,23027,23029,23039,23041,23053,23057,23059,23063,23071,23081,23087,23099,\n23117,23131,23143,23159,23167,23173,23189,23197,23201,23203,23209,23227,23251,23269,23279,\n23291,23293,23297,23311,23321,23327,23333,23339,23357,23369,23371,23399,23417,23431,23447,\n23459,23473,23497,23509,23531,23537,23539,23549,23557,23561,23563,23567,23581,23593,23599,\n23603,23609,23623,23627,23629,23633,23663,23669,23671,23677,23687,23689,23719,23741,23743,\n23747,23753,23761,23767,23773,23789,23801,23813,23819,23827,23831,23833,23857,23869,23873,\n23879,23887,23893,23899,23909,23911,23917,23929,23957,23971,23977,23981,23993,24001,24007,\n24019,24023,24029,24043,24049,24061,24071,24077,24083,24091,24097,24103,24107,24109,24113,\n24121,24133,24137,24151,24169,24179,24181,24197,24203,24223,24229,24239,24247,24251,24281,\n24317,24329,24337,24359,24371,24373,24379,24391,24407,24413,24419,24421,24439,24443,24469,\n24473,24481,24499,24509,24517,24527,24533,24547,24551,24571,24593,24611,24623,24631,24659,\n24671,24677,24683,24691,24697,24709,24733,24749,24763,24767,24781,24793,24799,24809,24821,\n24841,24847,24851,24859,24877,24889,24907,24917,24919,24923,24943,24953,24967,24971,24977,\n24979,24989,25013,25031,25033,25037,25057,25073,25087,25097,25111,25117,25121,25127,25147,\n25153,25163,25169,25171,25183,25189,25219,25229,25237,25243,25247,25253,25261,25301,25303,\n25307,25309,25321,25339,25343,25349,25357,25367,25373,25391,25409,25411,25423,25439,25447,\n25453,25457,25463,25469,25471,25523,25537,25541,25561,25577,25579,25583,25589,25601,25603,\n25609,25621,25633,25639,25643,25657,25667,25673,25679,25693,25703,25717,25733,25741,25747,\n25759,25763,25771,25793,25799,25801,25819,25841,25847,25849,25867,25873,25889,25903,25913,\n25919,25931,25933,25939,25943,25951,25969,25981,25997,25999,26003,26017,26021,26029,26041,\n26053,26083,26099,26107,26111,26113,26119,26141,26153,26161,26171,26177,26183,26189,26203,\n26209,26227,26237,26249,26251,26261,26263,26267,26293,26297,26309,26317,26321,26339,26347,\n26357,26371,26387,26393,26399,26407,26417,26423,26431,26437,26449,26459,26479,26489,26497,\n26501,26513,26539,26557,26561,26573,26591,26597,26627,26633,26641,26647,26669,26681,26683,\n26687,26693,26699,26701,26711,26713,26717,26723,26729,26731,26737,26759,26777,26783,26801,\n26813,26821,26833,26839,26849,26861,26863,26879,26881,26891,26893,26903,26921,26927,26947,\n26951,26953,26959,26981,26987,26993,27011,27017,27031,27043,27059,27061,27067,27073,27077,\n27091,27103,27107,27109,27127,27143,27179,27191,27197,27211,27239,27241,27253,27259,27271,\n27277,27281,27283,27299,27329,27337,27361,27367,27397,27407,27409,27427,27431,27437,27449,\n27457,27479,27481,27487,27509,27527,27529,27539,27541,27551,27581,27583,27611,27617,27631,\n27647,27653,27673,27689,27691,27697,27701,27733,27737,27739,27743,27749,27751,27763,27767,\n27773,27779,27791,27793,27799,27803,27809,27817,27823,27827,27847,27851,27883,27893,27901,\n27917,27919,27941,27943,27947,27953,27961,27967,27983,27997,28001,28019,28027,28031,28051,\n28057,28069,28081,28087,28097,28099,28109,28111,28123,28151,28163,28181,28183,28201,28211,\n28219,28229,28277,28279,28283,28289,28297,28307,28309,28319,28349,28351,28387,28393,28403,\n28409,28411,28429,28433,28439,28447,28463,28477,28493,28499,28513,28517,28537,28541,28547,\n28549,28559,28571,28573,28579,28591,28597,28603,28607,28619,28621,28627,28631,28643,28649,\n28657,28661,28663,28669,28687,28697,28703,28711,28723,28729,28751,28753,28759,28771,28789,\n28793,28807,28813,28817,28837,28843,28859,28867,28871,28879,28901,28909,28921,28927,28933,\n28949,28961,28979,29009,29017,29021,29023,29027,29033,29059,29063,29077,29101,29123,29129,\n29131,29137,29147,29153,29167,29173,29179,29191,29201,29207,29209,29221,29231,29243,29251,\n29269,29287,29297,29303,29311,29327,29333,29339,29347,29363,29383,29387,29389,29399,29401,\n29411,29423,29429,29437,29443,29453,29473,29483,29501,29527,29531,29537,29567,29569,29573,\n29581,29587,29599,29611,29629,29633,29641,29663,29669,29671,29683,29717,29723,29741,29753,\n29759,29761,29789,29803,29819,29833,29837,29851,29863,29867,29873,29879,29881,29917,29921,\n29927,29947,29959,29983,29989,30011,30013,30029,30047,30059,30071,30089,30091,30097,30103,\n30109,30113,30119,30133,30137,30139,30161,30169,30181,30187,30197,30203,30211,30223,30241,\n30253,30259,30269,30271,30293,30307,30313,30319,30323,30341,30347,30367,30389,30391,30403,\n30427,30431,30449,30467,30469,30491,30493,30497,30509,30517,30529,30539,30553,30557,30559,\n30577,30593,30631,30637,30643,30649,30661,30671,30677,30689,30697,30703,30707,30713,30727,\n30757,30763,30773,30781,30803,30809,30817,30829,30839,30841,30851,30853,30859,30869,30871,\n30881,30893,30911,30931,30937,30941,30949,30971,30977,30983,31013,31019,31033,31039,31051,\n31063,31069,31079,31081,31091,31121,31123,31139,31147,31151,31153,31159,31177,31181,31183,\n31189,31193,31219,31223,31231,31237,31247,31249,31253,31259,31267,31271,31277,31307,31319,\n31321,31327,31333,31337,31357,31379,31387,31391,31393,31397,31469,31477,31481,31489,31511,\n31513,31517,31531,31541,31543,31547,31567,31573,31583,31601,31607,31627,31643,31649,31657,\n31663,31667,31687,31699,31721,31723,31727,31729,31741,31751,31769,31771,31793,31799,31817,\n31847,31849,31859,31873,31883,31891,31907,31957,31963,31973,31981,31991,32003,32009,32027,\n32029,32051,32057,32059,32063,32069,32077,32083,32089,32099,32117,32119,32141,32143,32159,\n32173,32183,32189,32191,32203,32213,32233,32237,32251,32257,32261,32297,32299,32303,32309,\n32321,32323,32327,32341,32353,32359,32363,32369,32371,32377,32381,32401,32411,32413,32423,\n32429,32441,32443,32467,32479,32491,32497,32503,32507,32531,32533,32537,32561,32563,32569,\n32573,32579,32587,32603,32609,32611,32621,32633,32647,32653,32687,32693,32707,32713,32717,\n32719,32749,32771,32779,32783,32789,32797,32801,32803,32831,32833,32839,32843,32869,32887,\n32909,32911,32917,32933,32939,32941,32957,32969,32971,32983,32987,32993,32999,33013,33023,\n33029,33037,33049,33053,33071,33073,33083,33091,33107,33113,33119,33149,33151,33161,33179,\n33181,33191,33199,33203,33211,33223,33247,33287,33289,33301,33311,33317,33329,33331,33343,\n33347,33349,33353,33359,33377,33391,33403,33409,33413,33427,33457,33461,33469,33479,33487,\n33493,33503,33521,33529,33533,33547,33563,33569,33577,33581,33587,33589,33599,33601,33613,\n33617,33619,33623,33629,33637,33641,33647,33679,33703,33713,33721,33739,33749,33751,33757,\n33767,33769,33773,33791,33797,33809,33811,33827,33829,33851,33857,33863,33871,33889,33893,\n33911,33923,33931,33937,33941,33961,33967,33997,34019,34031,34033,34039,34057,34061,34123,\n34127,34129,34141,34147,34157,34159,34171,34183,34211,34213,34217,34231,34253,34259,34261,\n34267,34273,34283,34297,34301,34303,34313,34319,34327,34337,34351,34361,34367,34369,34381,\n34403,34421,34429,34439,34457,34469,34471,34483,34487,34499,34501,34511,34513,34519,34537,\n34543,34549,34583,34589,34591,34603,34607,34613,34631,34649,34651,34667,34673,34679,34687,\n34693,34703,34721,34729,34739,34747,34757,34759,34763,34781,34807,34819,34841,34843,34847,\n34849,34871,34877,34883,34897,34913,34919,34939,34949,34961,34963,34981,35023,35027,35051,\n35053,35059,35069,35081,35083,35089,35099,35107,35111,35117,35129,35141,35149,35153,35159,\n35171,35201,35221,35227,35251,35257,35267,35279,35281,35291,35311,35317,35323,35327,35339,\n35353,35363,35381,35393,35401,35407,35419,35423,35437,35447,35449,35461,35491,35507,35509,\n35521,35527,35531,35533,35537,35543,35569,35573,35591,35593,35597,35603,35617,35671,35677,\n35729,35731,35747,35753,35759,35771,35797,35801,35803,35809,35831,35837,35839,35851,35863,\n35869,35879,35897,35899,35911,35923,35933,35951,35963,35969,35977,35983,35993,35999,36007,\n36011,36013,36017,36037,36061,36067,36073,36083,36097,36107,36109,36131,36137,36151,36161,\n36187,36191,36209,36217,36229,36241,36251,36263,36269,36277,36293,36299,36307,36313,36319,\n36341,36343,36353,36373,36383,36389,36433,36451,36457,36467,36469,36473,36479,36493,36497,\n36523,36527,36529,36541,36551,36559,36563,36571,36583,36587,36599,36607,36629,36637,36643,\n36653,36671,36677,36683,36691,36697,36709,36713,36721,36739,36749,36761,36767,36779,36781,\n36787,36791,36793,36809,36821,36833,36847,36857,36871,36877,36887,36899,36901,36913,36919,\n36923,36929,36931,36943,36947,36973,36979,36997,37003,37013,37019,37021,37039,37049,37057,\n37061,37087,37097,37117,37123,37139,37159,37171,37181,37189,37199,37201,37217,37223,37243,\n37253,37273,37277,37307,37309,37313,37321,37337,37339,37357,37361,37363,37369,37379,37397,\n37409,37423,37441,37447,37463,37483,37489,37493,37501,37507,37511,37517,37529,37537,37547,\n37549,37561,37567,37571,37573,37579,37589,37591,37607,37619,37633,37643,37649,37657,37663,\n37691,37693,37699,37717,37747,37781,37783,37799,37811,37813,37831,37847,37853,37861,37871,\n37879,37889,37897,37907,37951,37957,37963,37967,37987,37991,37993,37997,38011,38039,38047,\n38053,38069,38083,38113,38119,38149,38153,38167,38177,38183,38189,38197,38201,38219,38231,\n38237,38239,38261,38273,38281,38287,38299,38303,38317,38321,38327,38329,38333,38351,38371,\n38377,38393,38431,38447,38449,38453,38459,38461,38501,38543,38557,38561,38567,38569,38593,\n38603,38609,38611,38629,38639,38651,38653,38669,38671,38677,38693,38699,38707,38711,38713,\n38723,38729,38737,38747,38749,38767,38783,38791,38803,38821,38833,38839,38851,38861,38867,\n38873,38891,38903,38917,38921,38923,38933,38953,38959,38971,38977,38993,39019,39023,39041,\n39043,39047,39079,39089,39097,39103,39107,39113,39119,39133,39139,39157,39161,39163,39181,\n39191,39199,39209,39217,39227,39229,39233,39239,39241,39251,39293,39301,39313,39317,39323,\n39341,39343,39359,39367,39371,39373,39383,39397,39409,39419,39439,39443,39451,39461,39499,\n39503,39509,39511,39521,39541,39551,39563,39569,39581,39607,39619,39623,39631,39659,39667,\n39671,39679,39703,39709,39719,39727,39733,39749,39761,39769,39779,39791,39799,39821,39827,\n39829,39839,39841,39847,39857,39863,39869,39877,39883,39887,39901,39929,39937,39953,39971,\n39979,39983,39989,40009,40013,40031,40037,40039,40063,40087,40093,40099,40111,40123,40127,\n40129,40151,40153,40163,40169,40177,40189,40193,40213,40231,40237,40241,40253,40277,40283,\n40289,40343,40351,40357,40361,40387,40423,40427,40429,40433,40459,40471,40483,40487,40493,\n40499,40507,40519,40529,40531,40543,40559,40577,40583,40591,40597,40609,40627,40637,40639,\n40693,40697,40699,40709,40739,40751,40759,40763,40771,40787,40801,40813,40819,40823,40829,\n40841,40847,40849,40853,40867,40879,40883,40897,40903,40927,40933,40939,40949,40961,40973,\n40993,41011,41017,41023,41039,41047,41051,41057,41077,41081,41113,41117,41131,41141,41143,\n41149,41161,41177,41179,41183,41189,41201,41203,41213,41221,41227,41231,41233,41243,41257,\n41263,41269,41281,41299,41333,41341,41351,41357,41381,41387,41389,41399,41411,41413,41443,\n41453,41467,41479,41491,41507,41513,41519,41521,41539,41543,41549,41579,41593,41597,41603,\n41609,41611,41617,41621,41627,41641,41647,41651,41659,41669,41681,41687,41719,41729,41737,\n41759,41761,41771,41777,41801,41809,41813,41843,41849,41851,41863,41879,41887,41893,41897,\n41903,41911,41927,41941,41947,41953,41957,41959,41969,41981,41983,41999,42013,42017,42019,\n42023,42043,42061,42071,42073,42083,42089,42101,42131,42139,42157,42169,42179,42181,42187,\n42193,42197,42209,42221,42223,42227,42239,42257,42281,42283,42293,42299,42307,42323,42331,\n42337,42349,42359,42373,42379,42391,42397,42403,42407,42409,42433,42437,42443,42451,42457,\n42461,42463,42467,42473,42487,42491,42499,42509,42533,42557,42569,42571,42577,42589,42611,\n42641,42643,42649,42667,42677,42683,42689,42697,42701,42703,42709,42719,42727,42737,42743,\n42751,42767,42773,42787,42793,42797,42821,42829,42839,42841,42853,42859,42863,42899,42901,\n42923,42929,42937,42943,42953,42961,42967,42979,42989,43003,43013,43019,43037,43049,43051,\n43063,43067,43093,43103,43117,43133,43151,43159,43177,43189,43201,43207,43223,43237,43261,\n43271,43283,43291,43313,43319,43321,43331,43391,43397,43399,43403,43411,43427,43441,43451,\n43457,43481,43487,43499,43517,43541,43543,43573,43577,43579,43591,43597,43607,43609,43613,\n43627,43633,43649,43651,43661,43669,43691,43711,43717,43721,43753,43759,43777,43781,43783,\n43787,43789,43793,43801,43853,43867,43889,43891,43913,43933,43943,43951,43961,43963,43969,\n43973,43987,43991,43997,44017,44021,44027,44029,44041,44053,44059,44071,44087,44089,44101,\n44111,44119,44123,44129,44131,44159,44171,44179,44189,44201,44203,44207,44221,44249,44257,\n44263,44267,44269,44273,44279,44281,44293,44351,44357,44371,44381,44383,44389,44417,44449,\n44453,44483,44491,44497,44501,44507,44519,44531,44533,44537,44543,44549,44563,44579,44587,\n44617,44621,44623,44633,44641,44647,44651,44657,44683,44687,44699,44701,44711,44729,44741,\n44753,44771,44773,44777,44789,44797,44809,44819,44839,44843,44851,44867,44879,44887,44893,\n44909,44917,44927,44939,44953,44959,44963,44971,44983,44987,45007,45013,45053,45061,45077,\n45083,45119,45121,45127,45131,45137,45139,45161,45179,45181,45191,45197,45233,45247,45259,\n45263,45281,45289,45293,45307,45317,45319,45329,45337,45341,45343,45361,45377,45389,45403,\n45413,45427,45433,45439,45481,45491,45497,45503,45523,45533,45541,45553,45557,45569,45587,\n45589,45599,45613,45631,45641,45659,45667,45673,45677,45691,45697,45707,45737,45751,45757,\n45763,45767,45779,45817,45821,45823,45827,45833,45841,45853,45863,45869,45887,45893,45943,\n45949,45953,45959,45971,45979,45989,46021,46027,46049,46051,46061,46073,46091,46093,46099,\n46103,46133,46141,46147,46153,46171,46181,46183,46187,46199,46219,46229,46237,46261,46271,\n46273,46279,46301,46307,46309,46327,46337,46349,46351,46381,46399,46411,46439,46441,46447,\n46451,46457,46471,46477,46489,46499,46507,46511,46523,46549,46559,46567,46573,46589,46591,\n46601,46619,46633,46639,46643,46649,46663,46679,46681,46687,46691,46703,46723,46727,46747,\n46751,46757,46769,46771,46807,46811,46817,46819,46829,46831,46853,46861,46867,46877,46889,\n46901,46919,46933,46957,46993,46997,47017,47041,47051,47057,47059,47087,47093,47111,47119,\n47123,47129,47137,47143,47147,47149,47161,47189,47207,47221,47237,47251,47269,47279,47287,\n47293,47297,47303,47309,47317,47339,47351,47353,47363,47381,47387,47389,47407,47417,47419,\n47431,47441,47459,47491,47497,47501,47507,47513,47521,47527,47533,47543,47563,47569,47581,\n47591,47599,47609,47623,47629,47639,47653,47657,47659,47681,47699,47701,47711,47713,47717,\n47737,47741,47743,47777,47779,47791,47797,47807,47809,47819,47837,47843,47857,47869,47881,\n47903,47911,47917,47933,47939,47947,47951,47963,47969,47977,47981,48017,48023,48029,48049,\n48073,48079,48091,48109,48119,48121,48131,48157,48163,48179,48187,48193,48197,48221,48239,\n48247,48259,48271,48281,48299,48311,48313,48337,48341,48353,48371,48383,48397,48407,48409,\n48413,48437,48449,48463,48473,48479,48481,48487,48491,48497,48523,48527,48533,48539,48541,\n48563,48571,48589,48593,48611,48619,48623,48647,48649,48661,48673,48677,48679,48731,48733,\n48751,48757,48761,48767,48779,48781,48787,48799,48809,48817,48821,48823,48847,48857,48859,\n48869,48871,48883,48889,48907,48947,48953,48973,48989,48991,49003,49009,49019,49031,49033,\n49037,49043,49057,49069,49081,49103,49109,49117,49121,49123,49139,49157,49169,49171,49177,\n49193,49199,49201,49207,49211,49223,49253,49261,49277,49279,49297,49307,49331,49333,49339,\n49363,49367,49369,49391,49393,49409,49411,49417,49429,49433,49451,49459,49463,49477,49481,\n49499,49523,49529,49531,49537,49547,49549,49559,49597,49603,49613,49627,49633,49639,49663,\n49667,49669,49681,49697,49711,49727,49739,49741,49747,49757,49783,49787,49789,49801,49807,\n49811,49823,49831,49843,49853,49871,49877,49891,49919,49921,49927,49937,49939,49943,49957,\n49991,49993,49999,50021,50023,50033,50047,50051,50053,50069,50077,50087,50093,50101,50111,\n50119,50123,50129,50131,50147,50153,50159,50177,50207,50221,50227,50231,50261,50263,50273,\n50287,50291,50311,50321,50329,50333,50341,50359,50363,50377,50383,50387,50411,50417,50423,\n50441,50459,50461,50497,50503,50513,50527,50539,50543,50549,50551,50581,50587,50591,50593,\n50599,50627,50647,50651,50671,50683,50707,50723,50741,50753,50767,50773,50777,50789,50821,\n50833,50839,50849,50857,50867,50873,50891,50893,50909,50923,50929,50951,50957,50969,50971,\n50989,50993,51001,51031,51043,51047,51059,51061,51071,51109,51131,51133,51137,51151,51157,\n51169,51193,51197,51199,51203,51217,51229,51239,51241,51257,51263,51283,51287,51307,51329,\n51341,51343,51347,51349,51361,51383,51407,51413,51419,51421,51427,51431,51437,51439,51449,\n51461,51473,51479,51481,51487,51503,51511,51517,51521,51539,51551,51563,51577,51581,51593,\n51599,51607,51613,51631,51637,51647,51659,51673,51679,51683,51691,51713,51719,51721,51749,\n51767,51769,51787,51797,51803,51817,51827,51829,51839,51853,51859,51869,51871,51893,51899,\n51907,51913,51929,51941,51949,51971,51973,51977,51991,52009,52021,52027,52051,52057,52067,\n52069,52081,52103,52121,52127,52147,52153,52163,52177,52181,52183,52189,52201,52223,52237,\n52249,52253,52259,52267,52289,52291,52301,52313,52321,52361,52363,52369,52379,52387,52391,\n52433,52453,52457,52489,52501,52511,52517,52529,52541,52543,52553,52561,52567,52571,52579,\n52583,52609,52627,52631,52639,52667,52673,52691,52697,52709,52711,52721,52727,52733,52747,\n52757,52769,52783,52807,52813,52817,52837,52859,52861,52879,52883,52889,52901,52903,52919,\n52937,52951,52957,52963,52967,52973,52981,52999,53003,53017,53047,53051,53069,53077,53087,\n53089,53093,53101,53113,53117,53129,53147,53149,53161,53171,53173,53189,53197,53201,53231,\n53233,53239,53267,53269,53279,53281,53299,53309,53323,53327,53353,53359,53377,53381,53401,\n53407,53411,53419,53437,53441,53453,53479,53503,53507,53527,53549,53551,53569,53591,53593,\n53597,53609,53611,53617,53623,53629,53633,53639,53653,53657,53681,53693,53699,53717,53719,\n53731,53759,53773,53777,53783,53791,53813,53819,53831,53849,53857,53861,53881,53887,53891,\n53897,53899,53917,53923,53927,53939,53951,53959,53987,53993,54001,54011,54013,54037,54049,\n54059,54083,54091,54101,54121,54133,54139,54151,54163,54167,54181,54193,54217,54251,54269,\n54277,54287,54293,54311,54319,54323,54331,54347,54361,54367,54371,54377,54401,54403,54409,\n54413,54419,54421,54437,54443,54449,54469,54493,54497,54499,54503,54517,54521,54539,54541,\n54547,54559,54563,54577,54581,54583,54601,54617,54623,54629,54631,54647,54667,54673,54679,\n54709,54713,54721,54727,54751,54767,54773,54779,54787,54799,54829,54833,54851,54869,54877,\n54881,54907,54917,54919,54941,54949,54959,54973,54979,54983,55001,55009,55021,55049,55051,\n55057,55061,55073,55079,55103,55109,55117,55127,55147,55163,55171,55201,55207,55213,55217,\n55219,55229,55243,55249,55259,55291,55313,55331,55333,55337,55339,55343,55351,55373,55381,\n55399,55411,55439,55441,55457,55469,55487,55501,55511,55529,55541,55547,55579,55589,55603,\n55609,55619,55621,55631,55633,55639,55661,55663,55667,55673,55681,55691,55697,55711,55717,\n55721,55733,55763,55787,55793,55799,55807,55813,55817,55819,55823,55829,55837,55843,55849,\n55871,55889,55897,55901,55903,55921,55927,55931,55933,55949,55967,55987,55997,56003,56009,\n56039,56041,56053,56081,56087,56093,56099,56101,56113,56123,56131,56149,56167,56171,56179,\n56197,56207,56209,56237,56239,56249,56263,56267,56269,56299,56311,56333,56359,56369,56377,\n56383,56393,56401,56417,56431,56437,56443,56453,56467,56473,56477,56479,56489,56501,56503,\n56509,56519,56527,56531,56533,56543,56569,56591,56597,56599,56611,56629,56633,56659,56663,\n56671,56681,56687,56701,56711,56713,56731,56737,56747,56767,56773,56779,56783,56807,56809,\n56813,56821,56827,56843,56857,56873,56891,56893,56897,56909,56911,56921,56923,56929,56941,\n56951,56957,56963,56983,56989,56993,56999,57037,57041,57047,57059,57073,57077,57089,57097,\n57107,57119,57131,57139,57143,57149,57163,57173,57179,57191,57193,57203,57221,57223,57241,\n57251,57259,57269,57271,57283,57287,57301,57329,57331,57347,57349,57367,57373,57383,57389,\n57397,57413,57427,57457,57467,57487,57493,57503,57527,57529,57557,57559,57571,57587,57593,\n57601,57637,57641,57649,57653,57667,57679,57689,57697,57709,57713,57719,57727,57731,57737,\n57751,57773,57781,57787,57791,57793,57803,57809,57829,57839,57847,57853,57859,57881,57899,\n57901,57917,57923,57943,57947,57973,57977,57991,58013,58027,58031,58043,58049,58057,58061,\n58067,58073,58099,58109,58111,58129,58147,58151,58153,58169,58171,58189,58193,58199,58207,\n58211,58217,58229,58231,58237,58243,58271,58309,58313,58321,58337,58363,58367,58369,58379,\n58391,58393,58403,58411,58417,58427,58439,58441,58451,58453,58477,58481,58511,58537,58543,\n58549,58567,58573,58579,58601,58603,58613,58631,58657,58661,58679,58687,58693,58699,58711,\n58727,58733,58741,58757,58763,58771,58787,58789,58831,58889,58897,58901,58907,58909,58913,\n58921,58937,58943,58963,58967,58979,58991,58997,59009,59011,59021,59023,59029,59051,59053,\n59063,59069,59077,59083,59093,59107,59113,59119,59123,59141,59149,59159,59167,59183,59197,\n59207,59209,59219,59221,59233,59239,59243,59263,59273,59281,59333,59341,59351,59357,59359,\n59369,59377,59387,59393,59399,59407,59417,59419,59441,59443,59447,59453,59467,59471,59473,\n59497,59509,59513,59539,59557,59561,59567,59581,59611,59617,59621,59627,59629,59651,59659,\n59663,59669,59671,59693,59699,59707,59723,59729,59743,59747,59753,59771,59779,59791,59797,\n59809,59833,59863,59879,59887,59921,59929,59951,59957,59971,59981,59999,60013,60017,60029,\n60037,60041,60077,60083,60089,60091,60101,60103,60107,60127,60133,60139,60149,60161,60167,\n60169,60209,60217,60223,60251,60257,60259,60271,60289,60293,60317,60331,60337,60343,60353,\n60373,60383,60397,60413,60427,60443,60449,60457,60493,60497,60509,60521,60527,60539,60589,\n60601,60607,60611,60617,60623,60631,60637,60647,60649,60659,60661,60679,60689,60703,60719,\n60727,60733,60737,60757,60761,60763,60773,60779,60793,60811,60821,60859,60869,60887,60889,\n60899,60901,60913,60917,60919,60923,60937,60943,60953,60961,61001,61007,61027,61031,61043,\n61051,61057,61091,61099,61121,61129,61141,61151,61153,61169,61211,61223,61231,61253,61261,\n61283,61291,61297,61331,61333,61339,61343,61357,61363,61379,61381,61403,61409,61417,61441,\n61463,61469,61471,61483,61487,61493,61507,61511,61519,61543,61547,61553,61559,61561,61583,\n61603,61609,61613,61627,61631,61637,61643,61651,61657,61667,61673,61681,61687,61703,61717,\n61723,61729,61751,61757,61781,61813,61819,61837,61843,61861,61871,61879,61909,61927,61933,\n61949,61961,61967,61979,61981,61987,61991,62003,62011,62017,62039,62047,62053,62057,62071,\n62081,62099,62119,62129,62131,62137,62141,62143,62171,62189,62191,62201,62207,62213,62219,\n62233,62273,62297,62299,62303,62311,62323,62327,62347,62351,62383,62401,62417,62423,62459,\n62467,62473,62477,62483,62497,62501,62507,62533,62539,62549,62563,62581,62591,62597,62603,\n62617,62627,62633,62639,62653,62659,62683,62687,62701,62723,62731,62743,62753,62761,62773,\n62791,62801,62819,62827,62851,62861,62869,62873,62897,62903,62921,62927,62929,62939,62969,\n62971,62981,62983,62987,62989,63029,63031,63059,63067,63073,63079,63097,63103,63113,63127,\n63131,63149,63179,63197,63199,63211,63241,63247,63277,63281,63299,63311,63313,63317,63331,\n63337,63347,63353,63361,63367,63377,63389,63391,63397,63409,63419,63421,63439,63443,63463,\n63467,63473,63487,63493,63499,63521,63527,63533,63541,63559,63577,63587,63589,63599,63601,\n63607,63611,63617,63629,63647,63649,63659,63667,63671,63689,63691,63697,63703,63709,63719,\n63727,63737,63743,63761,63773,63781,63793,63799,63803,63809,63823,63839,63841,63853,63857,\n63863,63901,63907,63913,63929,63949,63977,63997,64007,64013,64019,64033,64037,64063,64067,\n64081,64091,64109,64123,64151,64153,64157,64171,64187,64189,64217,64223,64231,64237,64271,\n64279,64283,64301,64303,64319,64327,64333,64373,64381,64399,64403,64433,64439,64451,64453,\n64483,64489,64499,64513,64553,64567,64577,64579,64591,64601,64609,64613,64621,64627,64633,\n64661,64663,64667,64679,64693,64709,64717,64747,64763,64781,64783,64793,64811,64817,64849,\n64853,64871,64877,64879,64891,64901,64919,64921,64927,64937,64951,64969,64997,65003,65011,\n65027,65029,65033,65053,65063,65071,65089,65099,65101,65111,65119,65123,65129,65141,65147,\n65167,65171,65173,65179,65183,65203,65213,65239,65257,65267,65269,65287,65293,65309,65323,\n65327,65353,65357,65371,65381,65393,65407,65413,65419,65423,65437,65447,65449,65479,65497,\n65519,65521,65537,65539,65543,65551,65557,65563,65579,65581,65587,65599,65609,65617,65629,\n65633,65647,65651,65657,65677,65687,65699,65701,65707,65713,65717,65719,65729,65731,65761,\n65777,65789,65809,65827,65831,65837,65839,65843,65851,65867,65881,65899,65921,65927,65929,\n65951,65957,65963,65981,65983,65993,66029,66037,66041,66047,66067,66071,66083,66089,66103,\n66107,66109,66137,66161,66169,66173,66179,66191,66221,66239,66271,66293,66301,66337,66343,\n66347,66359,66361,66373,66377,66383,66403,66413,66431,66449,66457,66463,66467,66491,66499,\n66509,66523,66529,66533,66541,66553,66569,66571,66587,66593,66601,66617,66629,66643,66653,\n66683,66697,66701,66713,66721,66733,66739,66749,66751,66763,66791,66797,66809,66821,66841,\n66851,66853,66863,66877,66883,66889,66919,66923,66931,66943,66947,66949,66959,66973,66977,\n67003,67021,67033,67043,67049,67057,67061,67073,67079,67103,67121,67129,67139,67141,67153,\n67157,67169,67181,67187,67189,67211,67213,67217,67219,67231,67247,67261,67271,67273,67289,\n67307,67339,67343,67349,67369,67391,67399,67409,67411,67421,67427,67429,67433,67447,67453,\n67477,67481,67489,67493,67499,67511,67523,67531,67537,67547,67559,67567,67577,67579,67589,\n67601,67607,67619,67631,67651,67679,67699,67709,67723,67733,67741,67751,67757,67759,67763,\n67777,67783,67789,67801,67807,67819,67829,67843,67853,67867,67883,67891,67901,67927,67931,\n67933,67939,67943,67957,67961,67967,67979,67987,67993,68023,68041,68053,68059,68071,68087,\n68099,68111,68113,68141,68147,68161,68171,68207,68209,68213,68219,68227,68239,68261,68279,\n68281,68311,68329,68351,68371,68389,68399,68437,68443,68447,68449,68473,68477,68483,68489,\n68491,68501,68507,68521,68531,68539,68543,68567,68581,68597,68611,68633,68639,68659,68669,\n68683,68687,68699,68711,68713,68729,68737,68743,68749,68767,68771,68777,68791,68813,68819,\n68821,68863,68879,68881,68891,68897,68899,68903,68909,68917,68927,68947,68963,68993,69001,\n69011,69019,69029,69031,69061,69067,69073,69109,69119,69127,69143,69149,69151,69163,69191,\n69193,69197,69203,69221,69233,69239,69247,69257,69259,69263,69313,69317,69337,69341,69371,\n69379,69383,69389,69401,69403,69427,69431,69439,69457,69463,69467,69473,69481,69491,69493,\n69497,69499,69539,69557,69593,69623,69653,69661,69677,69691,69697,69709,69737,69739,69761,\n69763,69767,69779,69809,69821,69827,69829,69833,69847,69857,69859,69877,69899,69911,69929,\n69931,69941,69959,69991,69997,70001,70003,70009,70019,70039,70051,70061,70067,70079,70099,\n70111,70117,70121,70123,70139,70141,70157,70163,70177,70181,70183,70199,70201,70207,70223,\n70229,70237,70241,70249,70271,70289,70297,70309,70313,70321,70327,70351,70373,70379,70381,\n70393,70423,70429,70439,70451,70457,70459,70481,70487,70489,70501,70507,70529,70537,70549,\n70571,70573,70583,70589,70607,70619,70621,70627,70639,70657,70663,70667,70687,70709,70717,\n70729,70753,70769,70783,70793,70823,70841,70843,70849,70853,70867,70877,70879,70891,70901,\n70913,70919,70921,70937,70949,70951,70957,70969,70979,70981,70991,70997,70999,71011,71023,\n71039,71059,71069,71081,71089,71119,71129,71143,71147,71153,71161,71167,71171,71191,71209,\n71233,71237,71249,71257,71261,71263,71287,71293,71317,71327,71329,71333,71339,71341,71347,\n71353,71359,71363,71387,71389,71399,71411,71413,71419,71429,71437,71443,71453,71471,71473,\n71479,71483,71503,71527,71537,71549,71551,71563,71569,71593,71597,71633,71647,71663,71671,\n71693,71699,71707,71711,71713,71719,71741,71761,71777,71789,71807,71809,71821,71837,71843,\n71849,71861,71867,71879,71881,71887,71899,71909,71917,71933,71941,71947,71963,71971,71983,\n71987,71993,71999,72019,72031,72043,72047,72053,72073,72077,72089,72091,72101,72103,72109,\n72139,72161,72167,72169,72173,72211,72221,72223,72227,72229,72251,72253,72269,72271,72277,\n72287,72307,72313,72337,72341,72353,72367,72379,72383,72421,72431,72461,72467,72469,72481,\n72493,72497,72503,72533,72547,72551,72559,72577,72613,72617,72623,72643,72647,72649,72661,\n72671,72673,72679,72689,72701,72707,72719,72727,72733,72739,72763,72767,72797,72817,72823,\n72859,72869,72871,72883,72889,72893,72901,72907,72911,72923,72931,72937,72949,72953,72959,\n72973,72977,72997,73009,73013,73019,73037,73039,73043,73061,73063,73079,73091,73121,73127,\n73133,73141,73181,73189,73237,73243,73259,73277,73291,73303,73309,73327,73331,73351,73361,\n73363,73369,73379,73387,73417,73421,73433,73453,73459,73471,73477,73483,73517,73523,73529,\n73547,73553,73561,73571,73583,73589,73597,73607,73609,73613,73637,73643,73651,73673,73679,\n73681,73693,73699,73709,73721,73727,73751,73757,73771,73783,73819,73823,73847,73849,73859,\n73867,73877,73883,73897,73907,73939,73943,73951,73961,73973,73999,74017,74021,74027,74047,\n74051,74071,74077,74093,74099,74101,74131,74143,74149,74159,74161,74167,74177,74189,74197,\n74201,74203,74209,74219,74231,74257,74279,74287,74293,74297,74311,74317,74323,74353,74357,\n74363,74377,74381,74383,74411,74413,74419,74441,74449,74453,74471,74489,74507,74509,74521,\n74527,74531,74551,74561,74567,74573,74587,74597,74609,74611,74623,74653,74687,74699,74707,\n74713,74717,74719,74729,74731,74747,74759,74761,74771,74779,74797,74821,74827,74831,74843,\n74857,74861,74869,74873,74887,74891,74897,74903,74923,74929,74933,74941,74959,75011,75013,\n75017,75029,75037,75041,75079,75083,75109,75133,75149,75161,75167,75169,75181,75193,75209,\n75211,75217,75223,75227,75239,75253,75269,75277,75289,75307,75323,75329,75337,75347,75353,\n75367,75377,75389,75391,75401,75403,75407,75431,75437,75479,75503,75511,75521,75527,75533,\n75539,75541,75553,75557,75571,75577,75583,75611,75617,75619,75629,75641,75653,75659,75679,\n75683,75689,75703,75707,75709,75721,75731,75743,75767,75773,75781,75787,75793,75797,75821,\n75833,75853,75869,75883,75913,75931,75937,75941,75967,75979,75983,75989,75991,75997,76001,\n76003,76031,76039,76079,76081,76091,76099,76103,76123,76129,76147,76157,76159,76163,76207,\n76213,76231,76243,76249,76253,76259,76261,76283,76289,76303,76333,76343,76367,76369,76379,\n76387,76403,76421,76423,76441,76463,76471,76481,76487,76493,76507,76511,76519,76537,76541,\n76543,76561,76579,76597,76603,76607,76631,76649,76651,76667,76673,76679,76697,76717,76733,\n76753,76757,76771,76777,76781,76801,76819,76829,76831,76837,76847,76871,76873,76883,76907,\n76913,76919,76943,76949,76961,76963,76991,77003,77017,77023,77029,77041,77047,77069,77081,\n77093,77101,77137,77141,77153,77167,77171,77191,77201,77213,77237,77239,77243,77249,77261,\n77263,77267,77269,77279,77291,77317,77323,77339,77347,77351,77359,77369,77377,77383,77417,\n77419,77431,77447,77471,77477,77479,77489,77491,77509,77513,77521,77527,77543,77549,77551,\n77557,77563,77569,77573,77587,77591,77611,77617,77621,77641,77647,77659,77681,77687,77689,\n77699,77711,77713,77719,77723,77731,77743,77747,77761,77773,77783,77797,77801,77813,77839,\n77849,77863,77867,77893,77899,77929,77933,77951,77969,77977,77983,77999,78007,78017,78031,\n78041,78049,78059,78079,78101,78121,78137,78139,78157,78163,78167,78173,78179,78191,78193,\n78203,78229,78233,78241,78259,78277,78283,78301,78307,78311,78317,78341,78347,78367,78401,\n78427,78437,78439,78467,78479,78487,78497,78509,78511,78517,78539,78541,78553,78569,78571,\n78577,78583,78593,78607,78623,78643,78649,78653,78691,78697,78707,78713,78721,78737,78779,\n78781,78787,78791,78797,78803,78809,78823,78839,78853,78857,78877,78887,78889,78893,78901,\n78919,78929,78941,78977,78979,78989,79031,79039,79043,79063,79087,79103,79111,79133,79139,\n79147,79151,79153,79159,79181,79187,79193,79201,79229,79231,79241,79259,79273,79279,79283,\n79301,79309,79319,79333,79337,79349,79357,79367,79379,79393,79397,79399,79411,79423,79427,\n79433,79451,79481,79493,79531,79537,79549,79559,79561,79579,79589,79601,79609,79613,79621,\n79627,79631,79633,79657,79669,79687,79691,79693,79697,79699,79757,79769,79777,79801,79811,\n79813,79817,79823,79829,79841,79843,79847,79861,79867,79873,79889,79901,79903,79907,79939,\n79943,79967,79973,79979,79987,79997,79999,80021,80039,80051,80071,80077,80107,80111,80141,\n80147,80149,80153,80167,80173,80177,80191,80207,80209,80221,80231,80233,80239,80251,80263,\n80273,80279,80287,80309,80317,80329,80341,80347,80363,80369,80387,80407,80429,80447,80449,\n80471,80473,80489,80491,80513,80527,80537,80557,80567,80599,80603,80611,80621,80627,80629,\n80651,80657,80669,80671,80677,80681,80683,80687,80701,80713,80737,80747,80749,80761,80777,\n80779,80783,80789,80803,80809,80819,80831,80833,80849,80863,80897,80909,80911,80917,80923,\n80929,80933,80953,80963,80989,81001,81013,81017,81019,81023,81031,81041,81043,81047,81049,\n81071,81077,81083,81097,81101,81119,81131,81157,81163,81173,81181,81197,81199,81203,81223,\n81233,81239,81281,81283,81293,81299,81307,81331,81343,81349,81353,81359,81371,81373,81401,\n81409,81421,81439,81457,81463,81509,81517,81527,81533,81547,81551,81553,81559,81563,81569,\n81611,81619,81629,81637,81647,81649,81667,81671,81677,81689,81701,81703,81707,81727,81737,\n81749,81761,81769,81773,81799,81817,81839,81847,81853,81869,81883,81899,81901,81919,81929,\n81931,81937,81943,81953,81967,81971,81973,82003,82007,82009,82013,82021,82031,82037,82039,\n82051,82067,82073,82129,82139,82141,82153,82163,82171,82183,82189,82193,82207,82217,82219,\n82223,82231,82237,82241,82261,82267,82279,82301,82307,82339,82349,82351,82361,82373,82387,\n82393,82421,82457,82463,82469,82471,82483,82487,82493,82499,82507,82529,82531,82549,82559,\n82561,82567,82571,82591,82601,82609,82613,82619,82633,82651,82657,82699,82721,82723,82727,\n82729,82757,82759,82763,82781,82787,82793,82799,82811,82813,82837,82847,82883,82889,82891,\n82903,82913,82939,82963,82981,82997,83003,83009,83023,83047,83059,83063,83071,83077,83089,\n83093,83101,83117,83137,83177,83203,83207,83219,83221,83227,83231,83233,83243,83257,83267,\n83269,83273,83299,83311,83339,83341,83357,83383,83389,83399,83401,83407,83417,83423,83431,\n83437,83443,83449,83459,83471,83477,83497,83537,83557,83561,83563,83579,83591,83597,83609,\n83617,83621,83639,83641,83653,83663,83689,83701,83717,83719,83737,83761,83773,83777,83791,\n83813,83833,83843,83857,83869,83873,83891,83903,83911,83921,83933,83939,83969,83983,83987,\n84011,84017,84047,84053,84059,84061,84067,84089,84121,84127,84131,84137,84143,84163,84179,\n84181,84191,84199,84211,84221,84223,84229,84239,84247,84263,84299,84307,84313,84317,84319,\n84347,84349,84377,84389,84391,84401,84407,84421,84431,84437,84443,84449,84457,84463,84467,\n84481,84499,84503,84509,84521,84523,84533,84551,84559,84589,84629,84631,84649,84653,84659,\n84673,84691,84697,84701,84713,84719,84731,84737,84751,84761,84787,84793,84809,84811,84827,\n84857,84859,84869,84871,84913,84919,84947,84961,84967,84977,84979,84991,85009,85021,85027,\n85037,85049,85061,85081,85087,85091,85093,85103,85109,85121,85133,85147,85159,85193,85199,\n85201,85213,85223,85229,85237,85243,85247,85259,85297,85303,85313,85331,85333,85361,85363,\n85369,85381,85411,85427,85429,85439,85447,85451,85453,85469,85487,85513,85517,85523,85531,\n85549,85571,85577,85597,85601,85607,85619,85621,85627,85639,85643,85661,85667,85669,85691,\n85703,85711,85717,85733,85751,85781,85793,85817,85819,85829,85831,85837,85843,85847,85853,\n85889,85903,85909,85931,85933,85991,85999,86011,86017,86027,86029,86069,86077,86083,86111,\n86113,86117,86131,86137,86143,86161,86171,86179,86183,86197,86201,86209,86239,86243,86249,\n86257,86263,86269,86287,86291,86293,86297,86311,86323,86341,86351,86353,86357,86369,86371,\n86381,86389,86399,86413,86423,86441,86453,86461,86467,86477,86491,86501,86509,86531,86533,\n86539,86561,86573,86579,86587,86599,86627,86629,86677,86689,86693,86711,86719,86729,86743,\n86753,86767,86771,86783,86813,86837,86843,86851,86857,86861,86869,86923,86927,86929,86939,\n86951,86959,86969,86981,86993,87011,87013,87037,87041,87049,87071,87083,87103,87107,87119,\n87121,87133,87149,87151,87179,87181,87187,87211,87221,87223,87251,87253,87257,87277,87281,\n87293,87299,87313,87317,87323,87337,87359,87383,87403,87407,87421,87427,87433,87443,87473,\n87481,87491,87509,87511,87517,87523,87539,87541,87547,87553,87557,87559,87583,87587,87589,\n87613,87623,87629,87631,87641,87643,87649,87671,87679,87683,87691,87697,87701,87719,87721,\n87739,87743,87751,87767,87793,87797,87803,87811,87833,87853,87869,87877,87881,87887,87911,\n87917,87931,87943,87959,87961,87973,87977,87991,88001,88003,88007,88019,88037,88069,88079,\n88093,88117,88129,88169,88177,88211,88223,88237,88241,88259,88261,88289,88301,88321,88327,\n88337,88339,88379,88397,88411,88423,88427,88463,88469,88471,88493,88499,88513,88523,88547,\n88589,88591,88607,88609,88643,88651,88657,88661,88663,88667,88681,88721,88729,88741,88747,\n88771,88789,88793,88799,88801,88807,88811,88813,88817,88819,88843,88853,88861,88867,88873,\n88883,88897,88903,88919,88937,88951,88969,88993,88997,89003,89009,89017,89021,89041,89051,\n89057,89069,89071,89083,89087,89101,89107,89113,89119,89123,89137,89153,89189,89203,89209,\n89213,89227,89231,89237,89261,89269,89273,89293,89303,89317,89329,89363,89371,89381,89387,\n89393,89399,89413,89417,89431,89443,89449,89459,89477,89491,89501,89513,89519,89521,89527,\n89533,89561,89563,89567,89591,89597,89599,89603,89611,89627,89633,89653,89657,89659,89669,\n89671,89681,89689,89753,89759,89767,89779,89783,89797,89809,89819,89821,89833,89839,89849,\n89867,89891,89897,89899,89909,89917,89923,89939,89959,89963,89977,89983,89989,90001,90007,\n90011,90017,90019,90023,90031,90053,90059,90067,90071,90073,90089,90107,90121,90127,90149,\n90163,90173,90187,90191,90197,90199,90203,90217,90227,90239,90247,90263,90271,90281,90289,\n90313,90353,90359,90371,90373,90379,90397,90401,90403,90407,90437,90439,90469,90473,90481,\n90499,90511,90523,90527,90529,90533,90547,90583,90599,90617,90619,90631,90641,90647,90659,\n90677,90679,90697,90703,90709,90731,90749,90787,90793,90803,90821,90823,90833,90841,90847,\n90863,90887,90901,90907,90911,90917,90931,90947,90971,90977,90989,90997,91009,91019,91033,\n91079,91081,91097,91099,91121,91127,91129,91139,91141,91151,91153,91159,91163,91183,91193,\n91199,91229,91237,91243,91249,91253,91283,91291,91297,91303,91309,91331,91367,91369,91373,\n91381,91387,91393,91397,91411,91423,91433,91453,91457,91459,91463,91493,91499,91513,91529,\n91541,91571,91573,91577,91583,91591,91621,91631,91639,91673,91691,91703,91711,91733,91753,\n91757,91771,91781,91801,91807,91811,91813,91823,91837,91841,91867,91873,91909,91921,91939,\n91943,91951,91957,91961,91967,91969,91997,92003,92009,92033,92041,92051,92077,92083,92107,\n92111,92119,92143,92153,92173,92177,92179,92189,92203,92219,92221,92227,92233,92237,92243,\n92251,92269,92297,92311,92317,92333,92347,92353,92357,92363,92369,92377,92381,92383,92387,\n92399,92401,92413,92419,92431,92459,92461,92467,92479,92489,92503,92507,92551,92557,92567,\n92569,92581,92593,92623,92627,92639,92641,92647,92657,92669,92671,92681,92683,92693,92699,\n92707,92717,92723,92737,92753,92761,92767,92779,92789,92791,92801,92809,92821,92831,92849,\n92857,92861,92863,92867,92893,92899,92921,92927,92941,92951,92957,92959,92987,92993,93001,\n93047,93053,93059,93077,93083,93089,93097,93103,93113,93131,93133,93139,93151,93169,93179,\n93187,93199,93229,93239,93241,93251,93253,93257,93263,93281,93283,93287,93307,93319,93323,\n93329,93337,93371,93377,93383,93407,93419,93427,93463,93479,93481,93487,93491,93493,93497,\n93503,93523,93529,93553,93557,93559,93563,93581,93601,93607,93629,93637,93683,93701,93703,\n93719,93739,93761,93763,93787,93809,93811,93827,93851,93871,93887,93889,93893,93901,93911,\n93913,93923,93937,93941,93949,93967,93971,93979,93983,93997,94007,94009,94033,94049,94057,\n94063,94079,94099,94109,94111,94117,94121,94151,94153,94169,94201,94207,94219,94229,94253,\n94261,94273,94291,94307,94309,94321,94327,94331,94343,94349,94351,94379,94397,94399,94421,\n94427,94433,94439,94441,94447,94463,94477,94483,94513,94529,94531,94541,94543,94547,94559,\n94561,94573,94583,94597,94603,94613,94621,94649,94651,94687,94693,94709,94723,94727,94747,\n94771,94777,94781,94789,94793,94811,94819,94823,94837,94841,94847,94849,94873,94889,94903,\n94907,94933,94949,94951,94961,94993,94999,95003,95009,95021,95027,95063,95071,95083,95087,\n95089,95093,95101,95107,95111,95131,95143,95153,95177,95189,95191,95203,95213,95219,95231,\n95233,95239,95257,95261,95267,95273,95279,95287,95311,95317,95327,95339,95369,95383,95393,\n95401,95413,95419,95429,95441,95443,95461,95467,95471,95479,95483,95507,95527,95531,95539,\n95549,95561,95569,95581,95597,95603,95617,95621,95629,95633,95651,95701,95707,95713,95717,\n95723,95731,95737,95747,95773,95783,95789,95791,95801,95803,95813,95819,95857,95869,95873,\n95881,95891,95911,95917,95923,95929,95947,95957,95959,95971,95987,95989,96001,96013,96017,\n96043,96053,96059,96079,96097,96137,96149,96157,96167,96179,96181,96199,96211,96221,96223,\n96233,96259,96263,96269,96281,96289,96293,96323,96329,96331,96337,96353,96377,96401,96419,\n96431,96443,96451,96457,96461,96469,96479,96487,96493,96497,96517,96527,96553,96557,96581,\n96587,96589,96601,96643,96661,96667,96671,96697,96703,96731,96737,96739,96749,96757,96763,\n96769,96779,96787,96797,96799,96821,96823,96827,96847,96851,96857,96893,96907,96911,96931,\n96953,96959,96973,96979,96989,96997,97001,97003,97007,97021,97039,97073,97081,97103,97117,\n97127,97151,97157,97159,97169,97171,97177,97187,97213,97231,97241,97259,97283,97301,97303,\n97327,97367,97369,97373,97379,97381,97387,97397,97423,97429,97441,97453,97459,97463,97499,\n97501,97511,97523,97547,97549,97553,97561,97571,97577,97579,97583,97607,97609,97613,97649,\n97651,97673,97687,97711,97729,97771,97777,97787,97789,97813,97829,97841,97843,97847,97849,\n97859,97861,97871,97879,97883,97919,97927,97931,97943,97961,97967,97973,97987,98009,98011,\n98017,98041,98047,98057,98081,98101,98123,98129,98143,98179,98207,98213,98221,98227,98251,\n98257,98269,98297,98299,98317,98321,98323,98327,98347,98369,98377,98387,98389,98407,98411,\n98419,98429,98443,98453,98459,98467,98473,98479,98491,98507,98519,98533,98543,98561,98563,\n98573,98597,98621,98627,98639,98641,98663,98669,98689,98711,98713,98717,98729,98731,98737,\n98773,98779,98801,98807,98809,98837,98849,98867,98869,98873,98887,98893,98897,98899,98909,\n98911,98927,98929,98939,98947,98953,98963,98981,98993,98999,99013,99017,99023,99041,99053,\n99079,99083,99089,99103,99109,99119,99131,99133,99137,99139,99149,99173,99181,99191,99223,\n99233,99241,99251,99257,99259,99277,99289,99317,99347,99349,99367,99371,99377,99391,99397,\n99401,99409,99431,99439,99469,99487,99497,99523,99527,99529,99551,99559,99563,99571,99577,\n99581,99607,99611,99623,99643,99661,99667,99679,99689,99707,99709,99713,99719,99721,99733,\n99761,99767,99787,99793,99809,99817,99823,99829,99833,99839,99859,99871,99877,99881,99901,\n99907,99923,99929,99961,99971,99989,99991\n);\nvar o,o1,o2,k,max,min,h,n,t,m,i,j:longint;\na:array[0..100000]of longint;\nbegin\n//reset(input,'input.txt');\n//rewrite(output,'output.txt');\nread(n);\nif n=2 then begin\nwrite(4);\nhalt(0);\nend;\nif n=1 then begin\nwrite(8);\nhalt(0);\nend;\ni:=1;\nwhile n mod p[i]=0 do\ninc(i);\nwhile ((n mod p[i])*k)mod p[i]<>p[i]-1 do\ninc(k);\nwrite(k);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprogram gtRus;\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\n\nvar n,t,m,i,j:longint;\na,b:array[1..10000,1..10000]of longint;\nh:array[1..100000]of byte;\nbegin\nreset(input,'input.txt');\nrewrite(output,'output.txt');\nread(n,m);\nfor i:=1 to n do\nfor j:=1 to m do\nread(a[i,j]);\nfor i:=2 to n do\na[i,1]:=a[i,1]+a[i-1,1];\nfor i:=2 to m do\na[1,i]:=a[1,i]+a[1,i-1];\nfor i:=2 to n do\nfor j:=2 to m do\nif a[i-1,j]>a[i,j-1] then \na[i,j]:=a[i,j]+a[i,j-1] else begin\na[i,j]:=a[i,j]+a[i-1,j];\nb[i,j]:=1;\nend;\nwriteln(a[n,m]);\nfor i:=2 to n do\nb[i,1]:=1;\ni:=n;\nj:=m;\nfor t:=1 to n+m-2 do\nif b[i,j]=1 then begin\nh[t]:=1;\ndec(i);\nend else\ndec(j);\ni:=1;\nj:=1;\nwriteln(i,' ',j);\nfor t:=n+m-2 downto 1 do\nif h[t]=1 then begin\ninc(i);\nwriteln(i,' ',j);\nend else begin\ninc(j);\nwriteln(i,' ',j);\nend;\nend.\n", "positive_code": [{"source_code": "var a,b,i,s,d,k: longint;\nbegin\n\nread(a);\nfor b:=1 to 1000 do\nbegin\nd:=a*b+1;\ns:=round(sqrt(d));\nk:=0;\nfor i:=2 to s do\nif d mod i=0 then inc(k);\nif k>0 then break;\nend;\nwrite(b);\n\nend.\n"}, {"source_code": "var h,g,f,l,n:integer;\nbegin\nreadln(h);\nfor g:=1 to 1000 do begin\nf:=g*h+1;\nfor l:=f downto 1 do \nif f mod l=0 then n:=n+1;\nif n>2 then begin writeln(g);break;end;\nn:=0;\nend;\nend.\n\n\n\n\n"}, {"source_code": "var\n a, b, c, d, i: int64;\n \nfunction check(a: int64): boolean;\nvar\n i: int64;\n \nbegin\n i := 2;\n while i * i <= a do begin\n if a mod i = 0 then begin\n check := true;\n exit;\n end;\n inc(i);\n end;\n check := false;\nend;\n \nbegin\n readln(a);\n i := 1;\n while i <= 1000 do begin\n if check(a * i + 1) then begin\n writeln(i);\n halt();\n end;\n inc(i);\n end;\nend."}, {"source_code": "Var n : Longint;\nBegin\nReadln(n);\nIf n <= 2 then Writeln('7') else Writeln(n-2);\nEnd."}, {"source_code": "Program _755A;\nvar\n n, m : longint;\nfunction Prost(x : longint) : boolean;\n var\n i : longint;\n b : boolean;\n begin\n b := true;\n for i := 2 to round(sqrt(x)) do\n if x mod i = 0\n then begin\n b := false;\n break;\n end;\n Prost := b;\n end;\nbegin\n read(n);\n m := 1;\n while prost(n * m + 1) do\n inc(m);\n write(m); \nend."}, {"source_code": "var n,m,i,b,q,j:longint;\nbegin\n readln(n);\n for i:=1 to 1000 do\n begin\n b:=n*i+1;\n q:=trunc(sqrt(b));\n for j:=2 to q do\n if b mod j=0 then begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "program ret;\nvar n,m,d,c,k: integer;\nbegin\nreadln(n);\nK:=0;\nfor m:=1 to 1000 do\nbegin\nc:=n*m+1;\nfor d:= 2 to c-1 do\nIf c/d = trunc(c/d) then k:= k+1;\nIf k>0 then break;\nend;\nwrite(m);\nend.\n\n"}, {"source_code": "program qq;\n\nvar\n n, m, q, i, k: integer;\n\nbegin\n read(n);\n k := 0;\n m := 0;\n while k = 0 do \n begin\n m := m + 1;\n q := n * m + 1;\n for i := 2 to q - 1 do\n if q mod i = 0 then k := 1;\n \n end;\n writeln(m);\nend."}, {"source_code": "program Hypothesis;\n\nvar n : longint;\n\nbegin\n readln(n);\n\n if n < 3\n then n := n + 4;\n\n writeln(n - 2);\nend.\n"}, {"source_code": "var n,i,j,q:longint;\nbegin\n read(n);\n for i:=1 to 1000 do\n begin\n q:=0;\n for j:=2 to round(sqrt(n*i+1)) do\n if (n*i+1) mod j=0\n then begin\n q:=1;\n break;\n end;\n if q=1\n then begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "Program PolandBallandHypothesis;\nuses math;\nvar n,i:longint;\nFunction nt(x:longint):boolean;\nvar j:longint;\nbegin if x<=1 then exit(false);\n if x<4 then exit(true);\n for j:=2 to trunc(sqrt(x)) do\n if x mod j=0 then exit(false);\n exit(true);\nend;\nbegin //assign(input,'755A.inp'); reset(input);\n //assign(output,'755A.out'); rewrite(output);\n readln(n);\n for i:=1 to 1000 do\n if nt(n*i+1) then continue\n else begin\n writeln(i); break;\n end;\n //close(input); close(output);\nend."}, {"source_code": "var a,s,d,i,ii,k:longint;\nbegin\nreadln(a);\nfor i:=1 to 1000 do\nbegin\nk:=0;\nfor ii:=2 to a*i do\nbegin\nif (a*i+1) mod ii=0 then\nk:=1;\nend;\nif k=1 then\nbegin\nwriteln(i);\nhalt;\nend;\nend;\nend."}, {"source_code": "var\n m,n,i,j: integer;\nbegin\n readln(n);\n for m:= 1 to 1000 do begin\n for i:=1 to 1000 do begin\n if ((n*m+1) mod i = 0) then begin\n for j:=2 to 1000 do begin\n if ((n*m+1) mod j = 0) and ((n*m+1) <> j) then begin write(m); halt; end;\n end;\n end;\n end;\n end;\nend.\n "}, {"source_code": "var a:integer;\nbegin\n read(a);\n if (a<3)then write(a+2)else write(a-2);\nend."}, {"source_code": "program pr;\nvar n,m,cur:integer;\nfunction isSimple(n:integer):boolean;\n var i:integer;\n begin\n if n < 3 \n then isSimple:=true\n else \n begin\n isSimple:=true;\n for i:=2 to n-1 do\n if n mod i = 0 then begin\n isSimple:=false;\n exit;\n end; \n end;\nend;\nbegin\n //for i:=0 to 20 do begin\n // writeln(i,' ',(isSimple(i)?'+':'-'))\n //end;\n readln(n);\n m:=0;\n cur := 1;\n repeat\n inc(cur,n);\n inc(m);\n until not isSimple(cur);\n writeln(m); \nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, i, m, a, j: longint;\n chuan: boolean;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n begin\n if n = 1 then m:=3;\n m:=1;\n while true do\n begin\n a:=n*m+1;\n chuan:=false;\n for j:=2 to trunc(sqrt(a)) do\n if a mod j = 0 then\n begin\n chuan:=true;\n break;\n end;\n if chuan then break;\n inc(m);\n end;\n write(m);\n end;\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "var n:longint;\nbegin\n read(n);\n if n=1 then write(5)\n else if n=2 \n then write(4)\n else write(n-2);\n\nend."}, {"source_code": "var\n pi, n, m, s, i: longint;\n prost: array[1..10000] of longint;\n\nprocedure pr();\nvar t:boolean;\ni:longint;\nbegin\n while pi < 10000 do\n begin\n inc(s);\n t:=true;\n for i:=1 to pi do\n if s mod prost[i] = 0 then begin t:=false; break; end;\n if t=true then\n begin\n inc(pi);\n prost[pi]:=s;\n end;\n end;\nend;\n\nprocedure input();\nbegin\n read(n);\n\nend;\n\nprocedure minm();\nvar buf,i:longint;\nt,t1:boolean;\nbegin\n t:=true;\n while t=true do\n begin\n t1:=true;\n inc(m);\n buf:=n*m+1;\n for i:=1 to pi do\n if buf=prost[i] then begin t1:=false; break; end;\n if t1=true then t:=false;\n end;\nend;\n\nprocedure output();\nbegin\n write(m);\nend;\n\nbegin\n s := 1;\n pr();\n input();\n minm();\n output();\nend."}, {"source_code": "var\nn,i,k,j:longint;\nbegin\n\treadln(n);\n\tfor i:=1 to 1000 do\n\tbegin\n\tfor j:=1 to n*i+1 do\n\tif ((n*i+1) mod j) = 0 then\n\tk:=k+1;\n\tif k>2 then\n\tbegin\n\twriteln(i);\n\tbreak;\n\tend\n\telse\n\tk:=0;\n\tend;\nend."}, {"source_code": "var m,n,i,j:longint;\n\nBegin\n\tReadln(n);\n\tIf (n mod 2<>0) then Writeln('3')\n\tElse if n=2 then Writeln('4')\n\tElse Writeln(n-2);\t\nEnd."}, {"source_code": "var n,m:longint;\n\nfunction prost(a:longint): boolean;\n var k,i:longint;\n begin\n k:=round(sqrt(a));\n if(a=2) then\n prost:=false\n else\n for i:=2 to k do \n if(a mod i=0) then\n begin\n prost:=true;\n break;\n end\n else if(i=k) then\n prost:=false;\n end;\n\nbegin\n read(n);\n m:=1;\n while (true) do\n begin\n if(prost(n*m+1)) then\n break;\n inc(m);\n end;\n writeln(m);\nend."}, {"source_code": "var n:LongInt;\nbegin\nreadln(n);\ncase n of\n1 : writeln('3');\n2 : writeln('4');\nelse writeln(n-2)\nend\nend.\n"}, {"source_code": "function pr(a:longint):integer;\nvar q:integer;\ni:longint;\nbegin\n q:=0;\n if (a=1)or((a<>2)and(a mod 2=0)) then q:=q+1;\n i:=3;\n while (i<=sqrt(a))and(q=0) do\n begin\n if a mod i=0 then q:=q+1;\n i:=i+2;\n end;\n pr:=q;\nend;\nvar m,n:longint;\nbegin\n read(n);\n m:=1;\n while pr(n*m+1)=0 do\n m:=m+1;\n writeln(m);\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,n:longint;\n\nFunction NotPrime(x:longint):boolean;\nvar i:longint;\nbegin\nfor i:=2 to round(sqrt(x)) do if x mod i=0 then exit(true);\nexit(false);\nend;\n\n\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\n//if n mod 2=1 then begin write('1'); exit; end;\nfor i:=1 to 1000 do\n begin\n if NotPrime((i*n)+1) then begin write(i); exit; end;\n end;\nend."}, {"source_code": "var n,t:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x))do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'hypo.in');reset(input);\n//assign(output,'hypo.out');rewrite(output);\nreadln(n);\nwhile true do\n begin\n inc(t);\n if pd(t*n+1)=false then\n begin\n writeln(t);break;\n end;\n end;\nclose(input);close(output);\nend."}, {"source_code": "var n,i,j:longint;\nf:array[0..1000001] of boolean;\nbegin\n//assign(input,'hypo.in');reset(input);\n//assign(output,'hypo.out');rewrite(output);\nreadln(n);\nf[1]:=true;\nfor i:=2 to trunc(sqrt(1000000)) do\n if f[i]=false then\n for j:=i to 1000000 div i do\n f[i*j]:=true;\nfor i:=1 to 1000 do\n if f[n*i+1] then\n begin\n writeln(i);\n close(input);close(output);halt;\n end;\nclose(input);close(output);\nend."}, {"source_code": "var x,y:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x))do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//(input,'hypo.in');reset(input);\n//assign(output,'hypo.out');rewrite(output);\nreadln(x);\nfor y:=1 to 1000 do\n if pd(x*y+1)=false then\n begin\n writeln(y);break;\n end;\nclose(input);close(output);\nend."}, {"source_code": "var n,m:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'hypo.in');reset(input);\n//assign(output,'hypo.out');rewrite(output);\nreadln(n);m:=1;\nwhile pd(n*m+1) do m:=m+1;\nwriteln(m);\nclose(input);close(output);\nend."}, {"source_code": "begin\n var n := ReadInteger;\n if n = 1 then write(3)\n else if n = 2 then write(4)\n else write(n - 2);\nend."}, {"source_code": "begin\n var n := ReadInteger;\n if n = 1 then write(3)\n else if n = 2 then write(4)\n else write(n - 2);\nend."}, {"source_code": "var n,i:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'hypo.in');reset(input);\n//assign(output,'hypo.out');rewrite(output);\nreadln(n);\nfor i:=1 to 100000 do\n if pd(n*i+1)=false then\n begin\n writeln(i);\n halt;\n end;\nclose(input);close(output);\nend."}, {"source_code": "function sodda(a:integer):integer;\nvar\n i,j,n,m:integer;\nbegin\n for i:=2 to a-1 do\n begin\n if a mod i=0 then begin sodda:=1; j:=1; break; end;\n end;\n if j<>1 then sodda:=2;\nend;\nvar\ni,j,n,m,k:integer;\nbegin\n read(n);\n while k<>1 do\n begin inc(i);\n if sodda(n*i+1)=1 then begin writeln(i); exit; end;\n end;\nend."}, {"source_code": "var\nn,m:integer;\ni,l,c,tr:integer;\nbegin\nreadln(n);\nl:=0;\nm:=0;\n\nwhile l<>1 do begin\ninc(m);\nc:=1; tr:=trunc(sqrt(m*n+1));\nfor i:=2 to tr do begin\nif ( ((n*m)+1) mod i)<>0 then inc(c); \nend;\nif c<>tr then l:=1;\n\nend; \n\n\nwriteln(m);\n\nend."}, {"source_code": "program VC8N2;\nvar\n v,n,m,i,j: integer;\n b: boolean;\nbegin\n b:=false;\n readln(n);\n for m:=1 to 100 do\n begin\n if b then break else for i:=2 to n*m+1 do if ((n*m+1) mod i=0) and (i<>n*m+1) then\n begin\n b:=true;\n break\n end;\n if b then writeln(m);\n end;\nend.\n\n"}, {"source_code": "var\n n,i,m,stop,k : longint;\n\nbegin\n\n\n readln(n);\n \n if n = 1 then begin writeln(3); halt; end;\n if n mod 2 <> 0 then begin writeln(1); halt; end;\n \n i:=1;\n\n stop:=0;\n \n while stop = 0 do begin\n k:=2;\n m:=n*i+1;\n while m mod k <> 0 do inc(k);\n if k <> m then break;\n inc(i);\n end;\n\n writeln(i);\n \nend."}, {"source_code": "Program z1;\nvar\n n,s:integer;\n i,j:integer;\n f:boolean;\n \nbegin\n read(n);\n for i:=1 to 1000 do begin\n s:=n*i+1;\n f:=false;\n for j:=2 to trunc(sqrt(s)) do begin\n if s mod j = 0 then f:=true;\n if f=true then break;\n end;\n if f=true then break;\n end;\n write(i);\nend."}, {"source_code": "var n,m:integer;\nbegin\nreadln(n);\nm:=0;\nif (n mod 2 <> 0) and (n<>1) then m:=1\nelse\n begin\n if (n<>2) and(n<>1) then\n repeat\n inc(m);\n until ((n*m+1) mod (n-1) = 0)\n else m:=7\n end;\nwriteln(m);\nend."}, {"source_code": "var n,m,i :integer;\nbegin\nreadln(n);\nif n > 2 then writeln(n-2);\nif n = 2 then writeln('7');\nif n = 1 then writeln('14');\nend."}, {"source_code": "begin\n var n := ReadInteger;\n if n = 1 then write(3)\n else if n = 2 then write(4)\n else write(n - 2);\nend."}, {"source_code": "var\n m,a,b,i,n,k,j:longint;\n x:array[1..111111]of longint;\nbegin\n read(n);\n \n for i:=1 to 1000 do\n begin\n k:=n*i+1;\n for j:=2 to 1000 do\n begin\n if (k mod j=0) and (k<>j) then begin writeln(i);halt;end;\n end;\n end;\nend. "}, {"source_code": "var\n n,a,b,i : longint;\nbegin\n readln(n);\n while (1 = 1) do\n begin\n inc(b);\n a := n*b+1;\n for i := 2 to round(sqrt(a)) do\n if (a mod i = 0) then\n begin\n writeln(b);\n exit;\n end;\n end;\nend."}, {"source_code": "Var\n m: Int64;\n \nBegin\n Read(m);\n For Var i := 1 to 1000 do\n For Var j := 2 to Trunc(sqrt(m*(1000 - i + 1) + 1)) do\n If (m*(1000 - i + 1) + 1) mod j = 0 then Begin\n Write(1000 - i + 1);\n Exit\n End\nEnd."}, {"source_code": "var i,p:longint;\ns,a:int64;\n\nfunction prost(x:int64):longint;\nvar x2,i:longint;\nbegin\n x2:=trunc(sqrt(x));\n for i:=2 to x2 do\n if x mod i=0 then exit(1);\n exit(0);\nend;\n\nbegin\n readln(a);\n for i:=1 to 1000000 do\n begin\n s:=(a*int64(i))+1;\n p:=prost(s);\n if p=1 then begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "program polandballa;\nvar\na: longint;\nbegin\nread(a);\nif a<3 then write(a+2) else write(a-2)\nend."}, {"source_code": "var n,i,m,S,d:longint;\n SNT:boolean;\nbegin\n Readln(n);\n m:=1;SNT:=true;\n While SNT=true do\n begin\n S:=n*m+1;\n d:=0;\n For i:=2 to trunc(sqrt(S)) do\n begin\n If S mod i=0 then inc(d);\n If d<>0 then\n begin\n Writeln(m);\n halt;\n end;\n end;\n inc(m);\n end;\nend."}, {"source_code": "program polsha;\nvar n,m:integer;\nbegin\nreadln(n);\nif n mod 2=1 then\nm:=3\nelse if n=2 then\nm:=4\nelse\nm:=n-2;\nwriteln(m);\nend."}, {"source_code": "var\nn,i,ch,j:longint;\nb:boolean;\nbegin\nreadln(n);\nif (n=1) then writeln('3')\nelse\nif (n=2) then writeln('4')\nelse\nbegin\nfor i:=1 to n do begin\nb:=false;\nch:=n*i+1;\nfor j:=2 to round(sqrt(ch)) do begin\nif ch mod j = 0 then begin\nb:=true;\nbreak;\nend;\nend;\nif b then begin\nwriteln(i);\nbreak;\nend;\nend;\nend;\nend."}, {"source_code": "var n, m : integer;\n\nfunction is_p (a : integer) : boolean;\n begin\n if (a = 1) then\n begin\n is_p := false;\n exit;\n end\n else if (a = 2) then\n begin\n is_p := true;\n exit;\n end;\n for var i := 2 to trunc(sqrt(a)) + 1 do\n if (a mod i = 0) then\n begin\n is_p := false;\n exit;\n end;\n is_p := true;\n end;\n\nbegin\n read (n);\n for m := 1 to 100 do\n if (not is_p (((n*m) + 1))) then\n begin\n write (m);\n exit;\n end;\nend."}, {"source_code": "var\nn,i,q,j:longint;\nbol:boolean;\nbegin\n\nreadln(n);\nfor i:=1 to 10000000 do begin\n q:=n*i+1;\n bol:=true;\n for j:=2 to trunc(sqrt(q)) do begin\n if q mod j = 0 then begin\n bol:=false;\n break;\n end;\n end;\n if bol=false then begin\n writeln(i);\n break;\n end;\nend;\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n if odd(n) then write(5) else if n mod 3=2 then write(7) else if n mod 3=1 then write(8) else \n write(n+2);\nend."}, {"source_code": " var\n\t\tn, b, c, r: int64;\n\t\ta: array of integer;\n\t\t\n begin\n\t\t\n\t\treadln(n);\n\t\tSetLength(a, 10001);\n\t\t\n\t\tvar i := 2;\n\t\tvar j: integer;\n\t\twhile (i <= 10000) do\n\t\tbegin\n\t\t\tj := i * 2;\n\t\t\twhile(j <= 10000) do\n\t\t\tbegin\n\t\t\t\ta[j] += 1;\n\t\t\t\tj += i;\n\t\t\tend;\n\t\t\ti += 1;\n\t\tend;\n\t\ta[0] := 1;\n\t\ta[1] := 1;\n\t\tfor var l := 1 to 10000 do\n\t\tbegin\n\t\t\tif (a[n*l+1] >= 1) then\n\t\t\tbegin\n\t\t\t\twriteln(l);\n\t\t\t\tbreak;\n\t\t\tend;\n\t\tend;\n\t\t\n end.\n"}, {"source_code": " const eps=0.000000001;\n besk=2000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;\n aa,bb,cc:double;\n ss,ss1:string;\n npx,npy:array[-1000..1000] of int64;\n napx,napy:array[-1..30,-100..100] of int64;\n finzan,zan:array[0..31,-1..10,-200..200,-200..200] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,d,x,y,aold,b,a:array[-10..1000002] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n zzan:array[-1000..3000,-1000..3000] of boolean;\n ss2:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n sss:string;ch:char;\n pole1,pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n oldflag,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n if n<=998 then begin writeln(n+2); goto 1; end;\n if n=1000 then begin writeln(1000); goto 1; end;\n if n=999 then begin writeln(1); goto 1; end;\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var n : longint;\n\nbegin\n readln(n);\n if (n < 999) then writeln(n + 2)\n else if (n = 999) then writeln(1)\n else writeln(8);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n \nvar\n n, m: integer;\n\nfunction prime(x: integer): boolean;\nvar\n i: integer;\nbegin\n if ((x mod 2 = 0) and (x > 2)) then\n result := false\n else\n result := true;\n i := 3;\n while ((i <= trunc(sqrt(x)) + 1) and (result)) do begin\n if (x mod i = 0) then\n result := false;\n i := i + 2;\n end;\nend;\n\nbegin\n read(n);\n m := 2;\n while (prime(n * m + 1)) do\n inc(m);\n write(m);\n readln;\n readln;\nend.\n"}, {"source_code": "program oo;\nVar i,m,n,k:integer;\n f:boolean;\nbegin\n Readln(n);\n m:=0;\n f:=false;\n\n while f=false do\n begin\n inc(m);\n k:=m*n+1;\n for i:=2 to k-1 do\n if k mod i = 0 then f:=true;\n end;\n writeln(m);\n readln;\nend."}, {"source_code": "var n,m: longint;\nbegin\nreadln (n);\nm:=n-2;\nif n=1 then writeln ('3') else\nif n=2 then writeln ('4') else writeln (m);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n: int64;\n i: integer;\n\nfunction pr(a: integer): boolean;\nvar\n i: integer;\nbegin\n for i := 2 to trunc(sqrt(a)) do\n if(a mod i = 0) then\n begin\n pr := false;\n exit;\n end;\n pr := true;\nend;\n\nbegin\n readln(n);\n for i := 1 to 1000000 do\n if(not pr(n * i + 1)) then\n begin\n writeln(i);\n halt(0);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+,O-}\nuses SysUtils,math;\nvar n,m,i,j,l,k,t:longint;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n for m:=10 to 1000 do\n begin\n k:=n*m+1;\n t:=trunc(sqrt(k));\n if (t*t<>k) then inc(t);\n for i:=2 to t do\n begin\n if (k mod i=0) then\n begin\n writeln(m);\n halt;\n end;\n end;\n end;\nend.\n"}, {"source_code": "uses math;\nconst\n\tfi = '';\n\tfo = '';\n\tmaxN = 1001;\nVar\n\tn,i,j,m:longint;\n\tp:array[1..maxN*maxN] of longint;\nBegin\n\tassign(input, fi); reset(input);\n\tassign(output,fo); rewrite(output);\n\tfor i:=2 to trunc(sqrt(maxN*maxN)) do\n\t\tif p[i] = 0 then\n\t\tbegin\n\t\t\tj:=i*i;\n\t\t\twhile j<=maxN*maxN do\n\t\t\tbegin\n\t\t\t\tp[j]:=i;\n\t\t\t\tj:=j+i;\n\t\t\tend;\n\t\tend;\n\treadln(n);\n\tfor m:=1 to 1000 do\n\t\tif p[n*m+1]>0 then\n\t\tbegin\n\t\t\twriteln(m);\n\t\t\tbreak;\n\t\tend;\n\tclose(input); close(output);\nend.\n"}, {"source_code": "program A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar\n m,n :integer;\n\n\nbegin\n readln(n);\n if (n=1) then write(3)\n else if (n=2) then write(4)\n else if (n>2) then write(n-2);\n \nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction check (x:longint):boolean;\nvar i:longint;\nf:boolean;\nbegin\nf:=true;\nif x<2 then f:=false;\n for i:=2 to round(sqrt(x)) do\n if x mod i = 0 then f:=false;\n check:=f;\nend;\n\nvar\n i,n,j,x,res,max :longint;\n mas:array[1..10000] of longint;\nbegin\n read(n);\n for i:=1 to 1000 do\n if not(check((n*i)+1)) then begin\n writeln(i);\n halt;\n end;\n\n readln;\n readln;\nend.\n"}, {"source_code": "program cntestvadimA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,m :integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n if (n=1) then m:=3\n else if (n=2) then m:=4\n else if (n=3) then m:=1\n else m:=(n-2);\n write(m);\nend.\n"}, {"source_code": "var i,j,k,l,m,n,x:longint;\n a:array[1..100001]of longint;\nbegin\n for i := 2 to (100001+1)div 2 do begin\n x:=i*2;\n while x<=100001 do \n begin\n a[x]:=1;\n x:=x+i;\n end;\n x:=0;\n end; \n read(n);\n for i := 1 to 100 do\n if a[(i*n+1)] = 1 then\n begin\n writeln(i);\n exit;\n end;\nend."}, {"source_code": "var\n\tn, i: longword;\n\t\nfunction is_prime: boolean;\nvar\n\tx, k: longword;\nbegin\n\tx:= n*i+1;\n\tif x <=1 then exit(true)\n\telse if x<= 3 then exit(false);\n\tfor k:=2 to trunc(sqrt(x)) do\n\t\tif (x mod k) = 0 then exit(true);\n\tis_prime:= false;\nend;\nbegin\n\tread(n);\n\tfor i:= 1 to 1000 do\n\t\tif is_prime then \n\t\t\tbegin\n\t\t\t\twrite(i);\n\t\t\t\tbreak;\n\t\t\tend;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar f,g:text;\n n:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n);\n close(f);\nend;\nfunction kt(n:longint):boolean;\nvar i:longint;\nbegin\n if n<2 then exit(false);\n if n=2 then exit(true);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n assign(G,fo);\n rewrite(G);\n if i=1 then write(g,3) else for i:=1 to 1000 do if kt(n*i+1)=false then\n begin\n writeln(g,i);\n break;\n end;\n close(g);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "var a:integer;\nbegin\n read(a);\n if (a<3)then write(a+2)else write(a-2);\nend."}, {"source_code": "var\n n,m,i,j: longint;\n f: array [0..1111111] of boolean;\nbegin\n readln(n);\n\n m:=trunc(sqrt(1000000));\n for i:=2 to m do if not f[i] then\n begin\n j:=i*i;\n while j <= n*100 do\n begin\n f[j]:=true;\n inc(j,i);\n end;\n end;\n\n for i:=1 to 100 do if f[i*n+1] then\n begin\n writeln(i);\n halt;\n end;\n\nend.\n"}, {"source_code": "var n,i,j:longint;\nbegin\n readln(n);\n if n mod 2 <> 0 then writeln(3)\n else \n for i:=2 to 1000 do \n for j:=2 to trunc(sqrt(n*i+1)) do\n if (n*i+1) mod j = 0 then begin writeln(i); exit; end; \n \nend.\n\n \n"}, {"source_code": " var\n n,m,i,j:longint;\n\n a:array[1..1000000] of boolean;\n begin\n\n read(n);\n\n\n\n for i:=1 to n*n+10 do a[i]:=true;\n\n a[1]:=false;\n\n for i:=2 to n do begin\n\n if a[i] then begin\n\n j:=i;\n\n while j<=n*n+10 do begin\n\n j:=j+i;\n\n a[j]:=false;\n\n end;\n\n end;\n\n end;\n\n for i:=1 to 1000 do\n\n if a[n*i+1]=false then begin write(i); halt; end;\n\n end.\n\n\n\n"}, {"source_code": "var\ni,j:longint;\nm,q,n:int64;\nbol:boolean;\nbegin\nreadln(n);\nbol:=false;\nwhile true do begin\ninc(i);\nq:=n*i+1;\nfor j:=2 to trunc(Sqrt(q)) do begin\n if q mod j = 0 then begin\n bol:=true;\n break;\n end;\nend;\nif bol then begin\n writeln(i);\n break;\nend;\nend;\nend."}, {"source_code": "var n,i,k:longint;\nx,j:longint;\n\nbegin\n readln(n);\n\n for i:=1 to 1000 do\n begin\n k:=0;\n x:=(i*n)+1;\n for j:=1 to x do\n if x mod j=0 then k:=k+1;\n if k>2 then begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "var\n a, c, d, max, j,r, b, y, g, i: longint;\n x: array [1..1000] of longint;\n s, q: string;\n\nbegin\n read(a);\n i := 1;\n while (true) do \n begin\n for j := 1 to trunc(sqrt((a * i + 1))) do \n if ((a*i+1) mod j=0) and (j<>1) then begin\n inc(c);\n break;\n end; \n if (c <> 0) then begin\n write(i);\n break;\n end;\n inc(i);\n c:=0;\n end;\nend."}, {"source_code": "var n,i:longint;\nfunction prime(a:int64):boolean;\nvar i:longint;\nbegin\n for i:=2 to a div 2 do\n begin\n if a mod i = 0 then exit(false);\n end;\n exit(true);\nend;\n\nbegin\n read(n);\n for i:=1 to 1000 do\n begin\n if prime(n*i+1)=false then\n begin\n write(i);\n halt;\n end;\n end;\nend."}, {"source_code": "var n,m:integer;\nbegin\n readln(n);\n if n<3 then m:=n+2 else m:=n-2;\n writeln(m);\n end."}, {"source_code": "var n,i,x,m:longint;\n a:array[1..100000] of int64;\nbegin\n readln(m);\n n:=100000 ;\n for i:=2 to (n+1) div 2 do\n begin\n x:=i*2;\n while x<=n do begin\n a[x]:=1;\n x:=x+i;\n end;\n x:=0;\n end;\n for i:=m+1 to n do\n if a[i] = 1\n then begin\n if (i-1) mod m=0\n then begin\n writeln((i-1) div m);\n exit;\n end;\n end;\n\n\nend.\n"}, {"source_code": "var\n f : boolean;\n x,n,i,j : longint;\nbegin\n readln(n);\n\n if n=1 then begin writeln(3); exit; end;\n if n=2 then begin writeln(4); exit; end;\n\n for i:=1 to n do begin\n x:=n*i+1;\n f:=true;\n for j:=2 to x div 2 do\n if x mod j =0\n then begin f:=false; break; end;\n\n if f=false then begin f:=true; writeln(i); exit; end\n\n end;\n\n\n\n\nend."}, {"source_code": "var i,m,n,j:longint;\nbegin\nread(n);\nfor m:=1 to 1000 do\nbegin\ni:=n*m+1;\nfor j:=2 to trunc(sqrt(i)) do\nif i mod j=0 then begin write(m); halt; end;\nend;\nend.\n"}, {"source_code": "var n,m,k,j,ch:integer;\nbegin\nread(n);\nm:=0;\nwhile k<=3 do begin\nch:=(n*m)+1;\nj:=1;\nk:=1;\nwhile (k<4)and(j<=ch) do begin\nif (ch mod j)=0 then k:=k+1;\nj:=j+1;\nend;\nif k>3 then writeln(m) else\nm:=m+1;\nend;\nend."}, {"source_code": "var n,i,j:longint;\n bl:array[1..1000000] of boolean;\nbegin\n readln(n);\n bl[1]:=true;\n for i:=2 to 1000000 do\n if bl[i] = false then\n for j:=2 to 1000000 div i do bl[i*j]:=true;\n for i:=1 to 1000 do\n if bl[n*i+1] = true then\n begin\n write(i);\n break;\n end;\nend."}, {"source_code": "var a,b: longint;\nbegin\nread(a); if a=1 then begin b:=17; write(17); halt end;\nif a mod 2 = 1 then begin b:=1; write('1'); halt end;\nif a mod 3 = 0 then begin b:=a-2; write(a-2); halt end;\nif a mod 3 = 1 then begin b:=5; write('5'); halt end;\nwrite('4'); b:=4; end."}, {"source_code": "var i,fl,m,n,kol,q:longint;\nbegin\nreadln(n);\nm:=1;\nwhile fl=0 do begin\nkol:=0;\nq:=n*m+1; kol:=0;\nfor i:=2 to round(sqrt(q)) do\nif q mod i = 0 then inc(kol);\nif kol>0 then inc(fl);\nif kol=0 then inc(m);\nend;\nwriteln(m);\nend.\n\n"}, {"source_code": "var a:integer;begin read(a);if(a<3)then write(a+2)else write(a-2);end."}, {"source_code": "var a:integer;\nbegin\n read(a);\n if (a<3)then write(a+2)else write(a-2);\nend."}, {"source_code": "var n,n1,k,i,j:integer;\nbegin\nread(n);\nfor i:=1 to 1000 do\n begin\n n1:=n*i+1;\n k:=0;\n for j:=1 to round(sqrt(n1)) do\n begin\n if n1 mod j = 0 then inc(k);\n if k>1 then break\n end;\n if k>1 then\n begin\n k:=i;\n break;\n end;\n end;\nwrite(k);\nend.\n"}, {"source_code": "Var n,m,i,j,p:longint;\nBegin\nreadln(m);\np:=0;\nfor i:=1 to 1000 do\nbegin\nfor j:=1 to ((i*m)+1) do\nif ((m*i)+1) mod j =0 then p:=p+1; \nif p>2 then begin writeln(i); exit; end;\np:=0;\nend;\nEnd."}, {"source_code": "var n,i,z,kl:int64;\n\nfunction pr(x:int64):int64;\nvar f,x2,q:longint;\nbegin\n f:=0;\n x2:=trunc(sqrt(x));\n for q:=2 to x2 do\n if x mod q=0 then begin\n f:=1;\n break;\n end;\n pr:=f;\nend;\n\nbegin\n readln(n);\n i:=n-1;\n while true do\n begin\n i:=i+1;\n z:=i-1;\n kl:=pr(i);\n if kl=0 then continue;\n if (z<>0) and (z mod n=0) then begin\n writeln(z div n);\n halt;\n end;\n\n end;\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-5;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction prime(x:longint):boolean;\n var i:longint;\n begin\n for i:=2 to trunc(sqrt(x)) do if x mod i=0 then exit(false);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(i:longint):boolean;\n begin\n if not prime(i*n+1) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j:longint;\n begin\n read(fi,n);\n for i:=1 to 1000 do if check(i) then\n begin\n write(fo,i);\n exit;\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j,k:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var n,i:longint;\nfunction prost(x:longint) : boolean;\nvar i:longint;\nbegin\nprost:=false;\nfor i:=2 to trunc(sqrt(x)) do\nif x mod i = 0 then begin \n prost:=true;\n break\n end;\nend;\nbegin\nreadln(n);\nfor i:=1 to 1000 do\nif PROST(N*I+1) then begin\n write(i);\n break\n end;\n end."}, {"source_code": "var n:longint;\nbegin\nread(n);\nif n>2 then\n write(n-2)\nelse\n write(n+2);\nend."}, {"source_code": "var i,j,m,n:longint;\nfunction prime(u:longint):boolean;\nvar i,j:longint;\nbegin\n for i:=2 to trunc(sqrt(u)) do if u mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n for m:=1 to 1000 do begin\n if prime(n*m+1)=false then begin\n writeln(m);\n close(input);\n close(output);\n halt;\n end;\n end;\nend."}, {"source_code": "const maxprima = 1999999;\n maxcheck = 1415;\nvar prima: array [0..maxprima] of boolean;\n\nprocedure sieve;\nvar I, J: longint;\nbegin\n prima[0]:= false; prima[1]:= false;\n for I:= 2 to maxprima do prima[I]:= true;\n for I:= 2 to maxcheck do\n if prima[I] then begin\n J:= I * I;\n while J <= maxprima do begin\n prima[J]:= false;\n inc(J, I);\n end;\n end;\nend;\n\nvar N, M: longint;\n\nbegin\n sieve;\n readln(N);\n M:= 1;\n while true do begin\n if not prima[N * M + 1] then begin\n writeln(M);\n exit;\n end;\n inc(M);\n end;\nend."}, {"source_code": "var n,i:longint;\nfunction prost(x:longint) : boolean;\nvar i:longint;\nbegin\nprost:=false;\nfor i:=2 to trunc(sqrt(x)) do\nif x mod i = 0 then begin \n prost:=true;\n break\n end;\nend;\nbegin\nreadln(n);\nfor i:=1 to 1000 do\nif PROST(N*I+1) then begin\n write(i);\n break\n end;\n end."}], "negative_code": [{"source_code": "var s,n,i,o,p,k:integer;\nbegin\nread(n);\ns:=n;\nwhile p=0 do\nbegin\ninc(o);\nn:=n*o+1;\nk:=0;\n for i:=1 to 10 do\n if (n mod i=0)then inc(k);\n if (k>2)then p:=o;\nn:=s;\nend;\nwrite(p);\nend."}, {"source_code": "var n,i,o,p,k:integer;\nbegin\nread(n);\nwhile p=0 do\nbegin\ninc(o);\nn:=n*o+1;\n for i:=1 to 10 do\n if (n mod i=0)then inc(k);\n if (k>2)then p:=o;\nend;\nwrite(p);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, i, m, a, j: longint;\n chuan: boolean;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n if n mod 2 = 1 then write(1)\n else\n begin\n m:=1;\n while true do\n begin\n a:=n*m+1;\n chuan:=false;\n for j:=2 to trunc(sqrt(a)) do\n if a mod j = 0 then\n begin\n chuan:=true;\n break;\n end;\n if chuan then break;\n inc(m);\n end;\n write(m);\n end;\n\n close(input); close(output);\nend.\n"}, {"source_code": "function sodda(a:integer):integer;\nvar\n i,j,n,m:integer;\nbegin\n for i:=2 to a-1 do\n begin\n if a mod i=0 then begin sodda:=1; j:=1; break; end;\n end;\n if j<>1 then sodda:=2;\nend;\nvar\ni,j,n,M:integer;\nbegin\n read(n);\n for i:=1 to n do\n if sodda(n*i+1)=1 then begin writeln(i); exit; end;\nend."}, {"source_code": "var n,m,i:integer;\nbegin\nreadln(n);\nif n mod 2 <> 0 then m:=1\nelse\n begin\n repeat\n inc(m);\n until (n*m+1) mod (m+1) = 0;\n end;\nwriteln(m);\nend.\n"}, {"source_code": "var n,m:integer;\nbegin\nreadln(n);\nm:=0;\nif n mod 2 <> 0 then m:=1\nelse\n begin\n if n<>2 then\n repeat\n inc(m);\n until ((n*m+1) mod (m+1) = 0)\n else m:=7\n end;\nwriteln(m);\nend."}, {"source_code": "var n,m:integer;\nbegin\nreadln(n);\nm:=0;\nif n mod 2 <> 0 then m:=1\nelse\n begin\n if n<>2 then\n repeat\n inc(m);\n until ((n*m+1) mod (n-1) = 0)\n else m:=7\n end;\nwriteln(m);\nend.\n"}, {"source_code": "var n,m:integer;\nbegin\nreadln(n);\nm:=0;\nif n mod 2 <> 0 then m:=1\nelse\n begin\n if n<>2 then\n repeat\n inc(m);\n until ((n*m+1) mod (m+1) = 0)\n else m:=4\n end;\nwriteln(m);\nend."}, {"source_code": "var n,m:integer;\nbegin\nreadln(n);\nm:=0;\nif n mod 2 <> 0 then m:=1\nelse\n begin\n if n<>2 then\n repeat\n inc(m);\n until ((n*m+1) mod (n-1) = 0)\n else m:=4\n end;\nwriteln(m);\nend."}, {"source_code": "Var\n m: Int64;\n \nBegin\n Read(m);\n For Var i := 1 to 1000 do\n If (m*i + 1) mod 11 = 0 then Begin\n Write(i);\n Exit\n End\nEnd."}, {"source_code": "Var\n m: Int64;\n \nBegin\n Read(m);\n For Var i := 1 to 1000 do\n For Var j := 1 to Trunc(sqrt(m*(1000 - i + 1) + 1)) do\n If (m*(1000 - i + 1) + 1) mod j = 0 then Begin\n Write(1000 - i + 1);\n Exit\n End\nEnd."}, {"source_code": "Var\n m: Int64;\n \nBegin\n Read(m);\n For Var i := 1 to 1000 do\n If ((m*i + 1) mod 11 = 0) and (m*i + 1 <> 11) then Begin\n Write(i);\n Exit\n End\nEnd."}, {"source_code": "Var\n m: Int64;\n \nBegin\n Read(m);\n If m mod 2 = 1 then\n Write(1)\n Else If m mod 3 = 1 then\n Write(2)\n Else If m mod 3 = 2 then\n Write(1)\n Else If m mod 3 = 0 then\n If m mod 10 = 2 then\n Write(2)\n Else If m mod 10 = 4 then\n Write(1)\n Else If m mod 10 = 6 then\n Write(4)\n Else If m mod 10 = 0 then\n For Var i := 1 to 11 do\n If (m*i + 1) mod 11 = 0 then Begin\n Write(i);\n Exit\n End\nEnd."}, {"source_code": "Var\n n: Int64;\n \nBegin\n Read(n);\n For Var i := 1 to 1000 do\n For Var j := 2 to Trunc(sqrt(n)) + 1 do\n If (n*i + 1) mod j = 0 then Begin\n Write(i);\n Exit\n End\nEnd."}, {"source_code": "program polsha;\nvar n,m:integer;\nbegin\nreadln(n);\nif n mod 2=1 then\nm:=1\nelse if n=2 then\nm:=4\nelse\nm:=n-2;\nwriteln(m);\nend."}, {"source_code": "var n, m : integer;\n\nfunction is_p (a : integer) : boolean;\n begin\n for var i := 2 to trunc(sqrt(a)) + 1 do\n if (a mod i = 0) then\n begin\n is_p := false;\n exit;\n end;\n is_p := true;\n end;\n\nbegin\n read (n);\n for m := 1 to n do\n if (not is_p (n*m + 1)) then\n begin\n write (m);\n exit;\n end;\nend."}, {"source_code": " const eps=0.000000001;\n besk=2000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;\n aa,bb,cc:double;\n ss,ss1:string;\n npx,npy:array[-1000..1000] of int64;\n napx,napy:array[-1..30,-100..100] of int64;\n finzan,zan:array[0..31,-1..10,-200..200,-200..200] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,d,x,y,aold,b,a:array[-10..1000002] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n zzan:array[-1000..3000,-1000..3000] of boolean;\n ss2:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n sss:string;ch:char;\n pole1,pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n oldflag,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n writeln(n+2);\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n \nvar\n n, m: integer;\n\nfunction prime(x: integer): boolean;\nvar\n i: integer;\nbegin\n if ((x mod 2 = 0) xor (x <> 2)) then\n result := false\n else\n result := true;\n i := 3;\n while ((i <= trunc(sqrt(x)) + 1) and (result)) do begin\n if (x mod i = 0) then\n result := false;\n i := i + 2;\n end;\nend;\n\nbegin\n read(n);\n m := 3;\n while (prime(n * m + 1)) do\n inc(m);\n write(m);\n readln;\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n \nvar\n n, m: integer;\n\nfunction prime(x: integer): boolean;\nvar\n i: integer;\nbegin\n if (x mod 2 = 0) then\n result := false\n else\n result := true;\n i := 3;\n while ((i <= trunc(sqrt(x)) + 1) and (result)) do begin\n if (x mod i = 0) then\n result := false;\n i := i + 2;\n end;\nend;\n\nbegin\n read(n);\n m := 1;\n while (prime(n * m + 1)) do\n inc(m);\n write(m);\n readln;\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+,O-}\nuses SysUtils,math;\nvar n,m,i,j,l,k,t:longint;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n for m:=1 to 1000 do\n begin\n k:=n*m+1;\n t:=trunc(sqrt(k));\n if (t*t<>k) then inc(t);\n for i:=2 to t do\n begin\n if (k mod i=0) then\n begin\n writeln(m);\n halt;\n end;\n end;\n end;\nend.\n"}, {"source_code": "program gtRus;\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\nconst p:array[1..9592] of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,\n53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,\n127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,\n199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,\n283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,\n383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,\n467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,\n577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,\n661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,\n769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,\n877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,\n983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,\n1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,\n1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,\n1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,\n1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,\n1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,\n1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,\n1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,\n1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,\n1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,\n2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,\n2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,\n2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,\n2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,\n2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,\n2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,\n2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,\n2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,\n3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,\n3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,\n3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,\n3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,\n3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,\n3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,\n3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,\n3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,\n4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,\n4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,\n4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,\n4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,\n4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,\n4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,\n4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,\n4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,\n5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,\n5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,\n5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,\n5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,\n5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,\n5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,\n5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,\n5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,\n6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,\n6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,\n6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,\n6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,\n6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,\n6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,\n6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,\n7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,\n7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,\n7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,\n7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,\n7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,\n7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,\n7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,\n7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,\n8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,\n8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,\n8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,\n8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,\n8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,\n8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,\n8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,\n9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,\n9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,\n9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,\n9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,\n9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,\n9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,\n9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973,10007,\n10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,10103,10111,10133,10139,10141,\n10151,10159,10163,10169,10177,10181,10193,10211,10223,10243,10247,10253,10259,10267,10271,\n10273,10289,10301,10303,10313,10321,10331,10333,10337,10343,10357,10369,10391,10399,10427,\n10429,10433,10453,10457,10459,10463,10477,10487,10499,10501,10513,10529,10531,10559,10567,\n10589,10597,10601,10607,10613,10627,10631,10639,10651,10657,10663,10667,10687,10691,10709,\n10711,10723,10729,10733,10739,10753,10771,10781,10789,10799,10831,10837,10847,10853,10859,\n10861,10867,10883,10889,10891,10903,10909,10937,10939,10949,10957,10973,10979,10987,10993,\n11003,11027,11047,11057,11059,11069,11071,11083,11087,11093,11113,11117,11119,11131,11149,\n11159,11161,11171,11173,11177,11197,11213,11239,11243,11251,11257,11261,11273,11279,11287,\n11299,11311,11317,11321,11329,11351,11353,11369,11383,11393,11399,11411,11423,11437,11443,\n11447,11467,11471,11483,11489,11491,11497,11503,11519,11527,11549,11551,11579,11587,11593,\n11597,11617,11621,11633,11657,11677,11681,11689,11699,11701,11717,11719,11731,11743,11777,\n11779,11783,11789,11801,11807,11813,11821,11827,11831,11833,11839,11863,11867,11887,11897,\n11903,11909,11923,11927,11933,11939,11941,11953,11959,11969,11971,11981,11987,12007,12011,\n12037,12041,12043,12049,12071,12073,12097,12101,12107,12109,12113,12119,12143,12149,12157,\n12161,12163,12197,12203,12211,12227,12239,12241,12251,12253,12263,12269,12277,12281,12289,\n12301,12323,12329,12343,12347,12373,12377,12379,12391,12401,12409,12413,12421,12433,12437,\n12451,12457,12473,12479,12487,12491,12497,12503,12511,12517,12527,12539,12541,12547,12553,\n12569,12577,12583,12589,12601,12611,12613,12619,12637,12641,12647,12653,12659,12671,12689,\n12697,12703,12713,12721,12739,12743,12757,12763,12781,12791,12799,12809,12821,12823,12829,\n12841,12853,12889,12893,12899,12907,12911,12917,12919,12923,12941,12953,12959,12967,12973,\n12979,12983,13001,13003,13007,13009,13033,13037,13043,13049,13063,13093,13099,13103,13109,\n13121,13127,13147,13151,13159,13163,13171,13177,13183,13187,13217,13219,13229,13241,13249,\n13259,13267,13291,13297,13309,13313,13327,13331,13337,13339,13367,13381,13397,13399,13411,\n13417,13421,13441,13451,13457,13463,13469,13477,13487,13499,13513,13523,13537,13553,13567,\n13577,13591,13597,13613,13619,13627,13633,13649,13669,13679,13681,13687,13691,13693,13697,\n13709,13711,13721,13723,13729,13751,13757,13759,13763,13781,13789,13799,13807,13829,13831,\n13841,13859,13873,13877,13879,13883,13901,13903,13907,13913,13921,13931,13933,13963,13967,\n13997,13999,14009,14011,14029,14033,14051,14057,14071,14081,14083,14087,14107,14143,14149,\n14153,14159,14173,14177,14197,14207,14221,14243,14249,14251,14281,14293,14303,14321,14323,\n14327,14341,14347,14369,14387,14389,14401,14407,14411,14419,14423,14431,14437,14447,14449,\n14461,14479,14489,14503,14519,14533,14537,14543,14549,14551,14557,14561,14563,14591,14593,\n14621,14627,14629,14633,14639,14653,14657,14669,14683,14699,14713,14717,14723,14731,14737,\n14741,14747,14753,14759,14767,14771,14779,14783,14797,14813,14821,14827,14831,14843,14851,\n14867,14869,14879,14887,14891,14897,14923,14929,14939,14947,14951,14957,14969,14983,15013,\n15017,15031,15053,15061,15073,15077,15083,15091,15101,15107,15121,15131,15137,15139,15149,\n15161,15173,15187,15193,15199,15217,15227,15233,15241,15259,15263,15269,15271,15277,15287,\n15289,15299,15307,15313,15319,15329,15331,15349,15359,15361,15373,15377,15383,15391,15401,\n15413,15427,15439,15443,15451,15461,15467,15473,15493,15497,15511,15527,15541,15551,15559,\n15569,15581,15583,15601,15607,15619,15629,15641,15643,15647,15649,15661,15667,15671,15679,\n15683,15727,15731,15733,15737,15739,15749,15761,15767,15773,15787,15791,15797,15803,15809,\n15817,15823,15859,15877,15881,15887,15889,15901,15907,15913,15919,15923,15937,15959,15971,\n15973,15991,16001,16007,16033,16057,16061,16063,16067,16069,16073,16087,16091,16097,16103,\n16111,16127,16139,16141,16183,16187,16189,16193,16217,16223,16229,16231,16249,16253,16267,\n16273,16301,16319,16333,16339,16349,16361,16363,16369,16381,16411,16417,16421,16427,16433,\n16447,16451,16453,16477,16481,16487,16493,16519,16529,16547,16553,16561,16567,16573,16603,\n16607,16619,16631,16633,16649,16651,16657,16661,16673,16691,16693,16699,16703,16729,16741,\n16747,16759,16763,16787,16811,16823,16829,16831,16843,16871,16879,16883,16889,16901,16903,\n16921,16927,16931,16937,16943,16963,16979,16981,16987,16993,17011,17021,17027,17029,17033,\n17041,17047,17053,17077,17093,17099,17107,17117,17123,17137,17159,17167,17183,17189,17191,\n17203,17207,17209,17231,17239,17257,17291,17293,17299,17317,17321,17327,17333,17341,17351,\n17359,17377,17383,17387,17389,17393,17401,17417,17419,17431,17443,17449,17467,17471,17477,\n17483,17489,17491,17497,17509,17519,17539,17551,17569,17573,17579,17581,17597,17599,17609,\n17623,17627,17657,17659,17669,17681,17683,17707,17713,17729,17737,17747,17749,17761,17783,\n17789,17791,17807,17827,17837,17839,17851,17863,17881,17891,17903,17909,17911,17921,17923,\n17929,17939,17957,17959,17971,17977,17981,17987,17989,18013,18041,18043,18047,18049,18059,\n18061,18077,18089,18097,18119,18121,18127,18131,18133,18143,18149,18169,18181,18191,18199,\n18211,18217,18223,18229,18233,18251,18253,18257,18269,18287,18289,18301,18307,18311,18313,\n18329,18341,18353,18367,18371,18379,18397,18401,18413,18427,18433,18439,18443,18451,18457,\n18461,18481,18493,18503,18517,18521,18523,18539,18541,18553,18583,18587,18593,18617,18637,\n18661,18671,18679,18691,18701,18713,18719,18731,18743,18749,18757,18773,18787,18793,18797,\n18803,18839,18859,18869,18899,18911,18913,18917,18919,18947,18959,18973,18979,19001,19009,\n19013,19031,19037,19051,19069,19073,19079,19081,19087,19121,19139,19141,19157,19163,19181,\n19183,19207,19211,19213,19219,19231,19237,19249,19259,19267,19273,19289,19301,19309,19319,\n19333,19373,19379,19381,19387,19391,19403,19417,19421,19423,19427,19429,19433,19441,19447,\n19457,19463,19469,19471,19477,19483,19489,19501,19507,19531,19541,19543,19553,19559,19571,\n19577,19583,19597,19603,19609,19661,19681,19687,19697,19699,19709,19717,19727,19739,19751,\n19753,19759,19763,19777,19793,19801,19813,19819,19841,19843,19853,19861,19867,19889,19891,\n19913,19919,19927,19937,19949,19961,19963,19973,19979,19991,19993,19997,20011,20021,20023,\n20029,20047,20051,20063,20071,20089,20101,20107,20113,20117,20123,20129,20143,20147,20149,\n20161,20173,20177,20183,20201,20219,20231,20233,20249,20261,20269,20287,20297,20323,20327,\n20333,20341,20347,20353,20357,20359,20369,20389,20393,20399,20407,20411,20431,20441,20443,\n20477,20479,20483,20507,20509,20521,20533,20543,20549,20551,20563,20593,20599,20611,20627,\n20639,20641,20663,20681,20693,20707,20717,20719,20731,20743,20747,20749,20753,20759,20771,\n20773,20789,20807,20809,20849,20857,20873,20879,20887,20897,20899,20903,20921,20929,20939,\n20947,20959,20963,20981,20983,21001,21011,21013,21017,21019,21023,21031,21059,21061,21067,\n21089,21101,21107,21121,21139,21143,21149,21157,21163,21169,21179,21187,21191,21193,21211,\n21221,21227,21247,21269,21277,21283,21313,21317,21319,21323,21341,21347,21377,21379,21383,\n21391,21397,21401,21407,21419,21433,21467,21481,21487,21491,21493,21499,21503,21517,21521,\n21523,21529,21557,21559,21563,21569,21577,21587,21589,21599,21601,21611,21613,21617,21647,\n21649,21661,21673,21683,21701,21713,21727,21737,21739,21751,21757,21767,21773,21787,21799,\n21803,21817,21821,21839,21841,21851,21859,21863,21871,21881,21893,21911,21929,21937,21943,\n21961,21977,21991,21997,22003,22013,22027,22031,22037,22039,22051,22063,22067,22073,22079,\n22091,22093,22109,22111,22123,22129,22133,22147,22153,22157,22159,22171,22189,22193,22229,\n22247,22259,22271,22273,22277,22279,22283,22291,22303,22307,22343,22349,22367,22369,22381,\n22391,22397,22409,22433,22441,22447,22453,22469,22481,22483,22501,22511,22531,22541,22543,\n22549,22567,22571,22573,22613,22619,22621,22637,22639,22643,22651,22669,22679,22691,22697,\n22699,22709,22717,22721,22727,22739,22741,22751,22769,22777,22783,22787,22807,22811,22817,\n22853,22859,22861,22871,22877,22901,22907,22921,22937,22943,22961,22963,22973,22993,23003,\n23011,23017,23021,23027,23029,23039,23041,23053,23057,23059,23063,23071,23081,23087,23099,\n23117,23131,23143,23159,23167,23173,23189,23197,23201,23203,23209,23227,23251,23269,23279,\n23291,23293,23297,23311,23321,23327,23333,23339,23357,23369,23371,23399,23417,23431,23447,\n23459,23473,23497,23509,23531,23537,23539,23549,23557,23561,23563,23567,23581,23593,23599,\n23603,23609,23623,23627,23629,23633,23663,23669,23671,23677,23687,23689,23719,23741,23743,\n23747,23753,23761,23767,23773,23789,23801,23813,23819,23827,23831,23833,23857,23869,23873,\n23879,23887,23893,23899,23909,23911,23917,23929,23957,23971,23977,23981,23993,24001,24007,\n24019,24023,24029,24043,24049,24061,24071,24077,24083,24091,24097,24103,24107,24109,24113,\n24121,24133,24137,24151,24169,24179,24181,24197,24203,24223,24229,24239,24247,24251,24281,\n24317,24329,24337,24359,24371,24373,24379,24391,24407,24413,24419,24421,24439,24443,24469,\n24473,24481,24499,24509,24517,24527,24533,24547,24551,24571,24593,24611,24623,24631,24659,\n24671,24677,24683,24691,24697,24709,24733,24749,24763,24767,24781,24793,24799,24809,24821,\n24841,24847,24851,24859,24877,24889,24907,24917,24919,24923,24943,24953,24967,24971,24977,\n24979,24989,25013,25031,25033,25037,25057,25073,25087,25097,25111,25117,25121,25127,25147,\n25153,25163,25169,25171,25183,25189,25219,25229,25237,25243,25247,25253,25261,25301,25303,\n25307,25309,25321,25339,25343,25349,25357,25367,25373,25391,25409,25411,25423,25439,25447,\n25453,25457,25463,25469,25471,25523,25537,25541,25561,25577,25579,25583,25589,25601,25603,\n25609,25621,25633,25639,25643,25657,25667,25673,25679,25693,25703,25717,25733,25741,25747,\n25759,25763,25771,25793,25799,25801,25819,25841,25847,25849,25867,25873,25889,25903,25913,\n25919,25931,25933,25939,25943,25951,25969,25981,25997,25999,26003,26017,26021,26029,26041,\n26053,26083,26099,26107,26111,26113,26119,26141,26153,26161,26171,26177,26183,26189,26203,\n26209,26227,26237,26249,26251,26261,26263,26267,26293,26297,26309,26317,26321,26339,26347,\n26357,26371,26387,26393,26399,26407,26417,26423,26431,26437,26449,26459,26479,26489,26497,\n26501,26513,26539,26557,26561,26573,26591,26597,26627,26633,26641,26647,26669,26681,26683,\n26687,26693,26699,26701,26711,26713,26717,26723,26729,26731,26737,26759,26777,26783,26801,\n26813,26821,26833,26839,26849,26861,26863,26879,26881,26891,26893,26903,26921,26927,26947,\n26951,26953,26959,26981,26987,26993,27011,27017,27031,27043,27059,27061,27067,27073,27077,\n27091,27103,27107,27109,27127,27143,27179,27191,27197,27211,27239,27241,27253,27259,27271,\n27277,27281,27283,27299,27329,27337,27361,27367,27397,27407,27409,27427,27431,27437,27449,\n27457,27479,27481,27487,27509,27527,27529,27539,27541,27551,27581,27583,27611,27617,27631,\n27647,27653,27673,27689,27691,27697,27701,27733,27737,27739,27743,27749,27751,27763,27767,\n27773,27779,27791,27793,27799,27803,27809,27817,27823,27827,27847,27851,27883,27893,27901,\n27917,27919,27941,27943,27947,27953,27961,27967,27983,27997,28001,28019,28027,28031,28051,\n28057,28069,28081,28087,28097,28099,28109,28111,28123,28151,28163,28181,28183,28201,28211,\n28219,28229,28277,28279,28283,28289,28297,28307,28309,28319,28349,28351,28387,28393,28403,\n28409,28411,28429,28433,28439,28447,28463,28477,28493,28499,28513,28517,28537,28541,28547,\n28549,28559,28571,28573,28579,28591,28597,28603,28607,28619,28621,28627,28631,28643,28649,\n28657,28661,28663,28669,28687,28697,28703,28711,28723,28729,28751,28753,28759,28771,28789,\n28793,28807,28813,28817,28837,28843,28859,28867,28871,28879,28901,28909,28921,28927,28933,\n28949,28961,28979,29009,29017,29021,29023,29027,29033,29059,29063,29077,29101,29123,29129,\n29131,29137,29147,29153,29167,29173,29179,29191,29201,29207,29209,29221,29231,29243,29251,\n29269,29287,29297,29303,29311,29327,29333,29339,29347,29363,29383,29387,29389,29399,29401,\n29411,29423,29429,29437,29443,29453,29473,29483,29501,29527,29531,29537,29567,29569,29573,\n29581,29587,29599,29611,29629,29633,29641,29663,29669,29671,29683,29717,29723,29741,29753,\n29759,29761,29789,29803,29819,29833,29837,29851,29863,29867,29873,29879,29881,29917,29921,\n29927,29947,29959,29983,29989,30011,30013,30029,30047,30059,30071,30089,30091,30097,30103,\n30109,30113,30119,30133,30137,30139,30161,30169,30181,30187,30197,30203,30211,30223,30241,\n30253,30259,30269,30271,30293,30307,30313,30319,30323,30341,30347,30367,30389,30391,30403,\n30427,30431,30449,30467,30469,30491,30493,30497,30509,30517,30529,30539,30553,30557,30559,\n30577,30593,30631,30637,30643,30649,30661,30671,30677,30689,30697,30703,30707,30713,30727,\n30757,30763,30773,30781,30803,30809,30817,30829,30839,30841,30851,30853,30859,30869,30871,\n30881,30893,30911,30931,30937,30941,30949,30971,30977,30983,31013,31019,31033,31039,31051,\n31063,31069,31079,31081,31091,31121,31123,31139,31147,31151,31153,31159,31177,31181,31183,\n31189,31193,31219,31223,31231,31237,31247,31249,31253,31259,31267,31271,31277,31307,31319,\n31321,31327,31333,31337,31357,31379,31387,31391,31393,31397,31469,31477,31481,31489,31511,\n31513,31517,31531,31541,31543,31547,31567,31573,31583,31601,31607,31627,31643,31649,31657,\n31663,31667,31687,31699,31721,31723,31727,31729,31741,31751,31769,31771,31793,31799,31817,\n31847,31849,31859,31873,31883,31891,31907,31957,31963,31973,31981,31991,32003,32009,32027,\n32029,32051,32057,32059,32063,32069,32077,32083,32089,32099,32117,32119,32141,32143,32159,\n32173,32183,32189,32191,32203,32213,32233,32237,32251,32257,32261,32297,32299,32303,32309,\n32321,32323,32327,32341,32353,32359,32363,32369,32371,32377,32381,32401,32411,32413,32423,\n32429,32441,32443,32467,32479,32491,32497,32503,32507,32531,32533,32537,32561,32563,32569,\n32573,32579,32587,32603,32609,32611,32621,32633,32647,32653,32687,32693,32707,32713,32717,\n32719,32749,32771,32779,32783,32789,32797,32801,32803,32831,32833,32839,32843,32869,32887,\n32909,32911,32917,32933,32939,32941,32957,32969,32971,32983,32987,32993,32999,33013,33023,\n33029,33037,33049,33053,33071,33073,33083,33091,33107,33113,33119,33149,33151,33161,33179,\n33181,33191,33199,33203,33211,33223,33247,33287,33289,33301,33311,33317,33329,33331,33343,\n33347,33349,33353,33359,33377,33391,33403,33409,33413,33427,33457,33461,33469,33479,33487,\n33493,33503,33521,33529,33533,33547,33563,33569,33577,33581,33587,33589,33599,33601,33613,\n33617,33619,33623,33629,33637,33641,33647,33679,33703,33713,33721,33739,33749,33751,33757,\n33767,33769,33773,33791,33797,33809,33811,33827,33829,33851,33857,33863,33871,33889,33893,\n33911,33923,33931,33937,33941,33961,33967,33997,34019,34031,34033,34039,34057,34061,34123,\n34127,34129,34141,34147,34157,34159,34171,34183,34211,34213,34217,34231,34253,34259,34261,\n34267,34273,34283,34297,34301,34303,34313,34319,34327,34337,34351,34361,34367,34369,34381,\n34403,34421,34429,34439,34457,34469,34471,34483,34487,34499,34501,34511,34513,34519,34537,\n34543,34549,34583,34589,34591,34603,34607,34613,34631,34649,34651,34667,34673,34679,34687,\n34693,34703,34721,34729,34739,34747,34757,34759,34763,34781,34807,34819,34841,34843,34847,\n34849,34871,34877,34883,34897,34913,34919,34939,34949,34961,34963,34981,35023,35027,35051,\n35053,35059,35069,35081,35083,35089,35099,35107,35111,35117,35129,35141,35149,35153,35159,\n35171,35201,35221,35227,35251,35257,35267,35279,35281,35291,35311,35317,35323,35327,35339,\n35353,35363,35381,35393,35401,35407,35419,35423,35437,35447,35449,35461,35491,35507,35509,\n35521,35527,35531,35533,35537,35543,35569,35573,35591,35593,35597,35603,35617,35671,35677,\n35729,35731,35747,35753,35759,35771,35797,35801,35803,35809,35831,35837,35839,35851,35863,\n35869,35879,35897,35899,35911,35923,35933,35951,35963,35969,35977,35983,35993,35999,36007,\n36011,36013,36017,36037,36061,36067,36073,36083,36097,36107,36109,36131,36137,36151,36161,\n36187,36191,36209,36217,36229,36241,36251,36263,36269,36277,36293,36299,36307,36313,36319,\n36341,36343,36353,36373,36383,36389,36433,36451,36457,36467,36469,36473,36479,36493,36497,\n36523,36527,36529,36541,36551,36559,36563,36571,36583,36587,36599,36607,36629,36637,36643,\n36653,36671,36677,36683,36691,36697,36709,36713,36721,36739,36749,36761,36767,36779,36781,\n36787,36791,36793,36809,36821,36833,36847,36857,36871,36877,36887,36899,36901,36913,36919,\n36923,36929,36931,36943,36947,36973,36979,36997,37003,37013,37019,37021,37039,37049,37057,\n37061,37087,37097,37117,37123,37139,37159,37171,37181,37189,37199,37201,37217,37223,37243,\n37253,37273,37277,37307,37309,37313,37321,37337,37339,37357,37361,37363,37369,37379,37397,\n37409,37423,37441,37447,37463,37483,37489,37493,37501,37507,37511,37517,37529,37537,37547,\n37549,37561,37567,37571,37573,37579,37589,37591,37607,37619,37633,37643,37649,37657,37663,\n37691,37693,37699,37717,37747,37781,37783,37799,37811,37813,37831,37847,37853,37861,37871,\n37879,37889,37897,37907,37951,37957,37963,37967,37987,37991,37993,37997,38011,38039,38047,\n38053,38069,38083,38113,38119,38149,38153,38167,38177,38183,38189,38197,38201,38219,38231,\n38237,38239,38261,38273,38281,38287,38299,38303,38317,38321,38327,38329,38333,38351,38371,\n38377,38393,38431,38447,38449,38453,38459,38461,38501,38543,38557,38561,38567,38569,38593,\n38603,38609,38611,38629,38639,38651,38653,38669,38671,38677,38693,38699,38707,38711,38713,\n38723,38729,38737,38747,38749,38767,38783,38791,38803,38821,38833,38839,38851,38861,38867,\n38873,38891,38903,38917,38921,38923,38933,38953,38959,38971,38977,38993,39019,39023,39041,\n39043,39047,39079,39089,39097,39103,39107,39113,39119,39133,39139,39157,39161,39163,39181,\n39191,39199,39209,39217,39227,39229,39233,39239,39241,39251,39293,39301,39313,39317,39323,\n39341,39343,39359,39367,39371,39373,39383,39397,39409,39419,39439,39443,39451,39461,39499,\n39503,39509,39511,39521,39541,39551,39563,39569,39581,39607,39619,39623,39631,39659,39667,\n39671,39679,39703,39709,39719,39727,39733,39749,39761,39769,39779,39791,39799,39821,39827,\n39829,39839,39841,39847,39857,39863,39869,39877,39883,39887,39901,39929,39937,39953,39971,\n39979,39983,39989,40009,40013,40031,40037,40039,40063,40087,40093,40099,40111,40123,40127,\n40129,40151,40153,40163,40169,40177,40189,40193,40213,40231,40237,40241,40253,40277,40283,\n40289,40343,40351,40357,40361,40387,40423,40427,40429,40433,40459,40471,40483,40487,40493,\n40499,40507,40519,40529,40531,40543,40559,40577,40583,40591,40597,40609,40627,40637,40639,\n40693,40697,40699,40709,40739,40751,40759,40763,40771,40787,40801,40813,40819,40823,40829,\n40841,40847,40849,40853,40867,40879,40883,40897,40903,40927,40933,40939,40949,40961,40973,\n40993,41011,41017,41023,41039,41047,41051,41057,41077,41081,41113,41117,41131,41141,41143,\n41149,41161,41177,41179,41183,41189,41201,41203,41213,41221,41227,41231,41233,41243,41257,\n41263,41269,41281,41299,41333,41341,41351,41357,41381,41387,41389,41399,41411,41413,41443,\n41453,41467,41479,41491,41507,41513,41519,41521,41539,41543,41549,41579,41593,41597,41603,\n41609,41611,41617,41621,41627,41641,41647,41651,41659,41669,41681,41687,41719,41729,41737,\n41759,41761,41771,41777,41801,41809,41813,41843,41849,41851,41863,41879,41887,41893,41897,\n41903,41911,41927,41941,41947,41953,41957,41959,41969,41981,41983,41999,42013,42017,42019,\n42023,42043,42061,42071,42073,42083,42089,42101,42131,42139,42157,42169,42179,42181,42187,\n42193,42197,42209,42221,42223,42227,42239,42257,42281,42283,42293,42299,42307,42323,42331,\n42337,42349,42359,42373,42379,42391,42397,42403,42407,42409,42433,42437,42443,42451,42457,\n42461,42463,42467,42473,42487,42491,42499,42509,42533,42557,42569,42571,42577,42589,42611,\n42641,42643,42649,42667,42677,42683,42689,42697,42701,42703,42709,42719,42727,42737,42743,\n42751,42767,42773,42787,42793,42797,42821,42829,42839,42841,42853,42859,42863,42899,42901,\n42923,42929,42937,42943,42953,42961,42967,42979,42989,43003,43013,43019,43037,43049,43051,\n43063,43067,43093,43103,43117,43133,43151,43159,43177,43189,43201,43207,43223,43237,43261,\n43271,43283,43291,43313,43319,43321,43331,43391,43397,43399,43403,43411,43427,43441,43451,\n43457,43481,43487,43499,43517,43541,43543,43573,43577,43579,43591,43597,43607,43609,43613,\n43627,43633,43649,43651,43661,43669,43691,43711,43717,43721,43753,43759,43777,43781,43783,\n43787,43789,43793,43801,43853,43867,43889,43891,43913,43933,43943,43951,43961,43963,43969,\n43973,43987,43991,43997,44017,44021,44027,44029,44041,44053,44059,44071,44087,44089,44101,\n44111,44119,44123,44129,44131,44159,44171,44179,44189,44201,44203,44207,44221,44249,44257,\n44263,44267,44269,44273,44279,44281,44293,44351,44357,44371,44381,44383,44389,44417,44449,\n44453,44483,44491,44497,44501,44507,44519,44531,44533,44537,44543,44549,44563,44579,44587,\n44617,44621,44623,44633,44641,44647,44651,44657,44683,44687,44699,44701,44711,44729,44741,\n44753,44771,44773,44777,44789,44797,44809,44819,44839,44843,44851,44867,44879,44887,44893,\n44909,44917,44927,44939,44953,44959,44963,44971,44983,44987,45007,45013,45053,45061,45077,\n45083,45119,45121,45127,45131,45137,45139,45161,45179,45181,45191,45197,45233,45247,45259,\n45263,45281,45289,45293,45307,45317,45319,45329,45337,45341,45343,45361,45377,45389,45403,\n45413,45427,45433,45439,45481,45491,45497,45503,45523,45533,45541,45553,45557,45569,45587,\n45589,45599,45613,45631,45641,45659,45667,45673,45677,45691,45697,45707,45737,45751,45757,\n45763,45767,45779,45817,45821,45823,45827,45833,45841,45853,45863,45869,45887,45893,45943,\n45949,45953,45959,45971,45979,45989,46021,46027,46049,46051,46061,46073,46091,46093,46099,\n46103,46133,46141,46147,46153,46171,46181,46183,46187,46199,46219,46229,46237,46261,46271,\n46273,46279,46301,46307,46309,46327,46337,46349,46351,46381,46399,46411,46439,46441,46447,\n46451,46457,46471,46477,46489,46499,46507,46511,46523,46549,46559,46567,46573,46589,46591,\n46601,46619,46633,46639,46643,46649,46663,46679,46681,46687,46691,46703,46723,46727,46747,\n46751,46757,46769,46771,46807,46811,46817,46819,46829,46831,46853,46861,46867,46877,46889,\n46901,46919,46933,46957,46993,46997,47017,47041,47051,47057,47059,47087,47093,47111,47119,\n47123,47129,47137,47143,47147,47149,47161,47189,47207,47221,47237,47251,47269,47279,47287,\n47293,47297,47303,47309,47317,47339,47351,47353,47363,47381,47387,47389,47407,47417,47419,\n47431,47441,47459,47491,47497,47501,47507,47513,47521,47527,47533,47543,47563,47569,47581,\n47591,47599,47609,47623,47629,47639,47653,47657,47659,47681,47699,47701,47711,47713,47717,\n47737,47741,47743,47777,47779,47791,47797,47807,47809,47819,47837,47843,47857,47869,47881,\n47903,47911,47917,47933,47939,47947,47951,47963,47969,47977,47981,48017,48023,48029,48049,\n48073,48079,48091,48109,48119,48121,48131,48157,48163,48179,48187,48193,48197,48221,48239,\n48247,48259,48271,48281,48299,48311,48313,48337,48341,48353,48371,48383,48397,48407,48409,\n48413,48437,48449,48463,48473,48479,48481,48487,48491,48497,48523,48527,48533,48539,48541,\n48563,48571,48589,48593,48611,48619,48623,48647,48649,48661,48673,48677,48679,48731,48733,\n48751,48757,48761,48767,48779,48781,48787,48799,48809,48817,48821,48823,48847,48857,48859,\n48869,48871,48883,48889,48907,48947,48953,48973,48989,48991,49003,49009,49019,49031,49033,\n49037,49043,49057,49069,49081,49103,49109,49117,49121,49123,49139,49157,49169,49171,49177,\n49193,49199,49201,49207,49211,49223,49253,49261,49277,49279,49297,49307,49331,49333,49339,\n49363,49367,49369,49391,49393,49409,49411,49417,49429,49433,49451,49459,49463,49477,49481,\n49499,49523,49529,49531,49537,49547,49549,49559,49597,49603,49613,49627,49633,49639,49663,\n49667,49669,49681,49697,49711,49727,49739,49741,49747,49757,49783,49787,49789,49801,49807,\n49811,49823,49831,49843,49853,49871,49877,49891,49919,49921,49927,49937,49939,49943,49957,\n49991,49993,49999,50021,50023,50033,50047,50051,50053,50069,50077,50087,50093,50101,50111,\n50119,50123,50129,50131,50147,50153,50159,50177,50207,50221,50227,50231,50261,50263,50273,\n50287,50291,50311,50321,50329,50333,50341,50359,50363,50377,50383,50387,50411,50417,50423,\n50441,50459,50461,50497,50503,50513,50527,50539,50543,50549,50551,50581,50587,50591,50593,\n50599,50627,50647,50651,50671,50683,50707,50723,50741,50753,50767,50773,50777,50789,50821,\n50833,50839,50849,50857,50867,50873,50891,50893,50909,50923,50929,50951,50957,50969,50971,\n50989,50993,51001,51031,51043,51047,51059,51061,51071,51109,51131,51133,51137,51151,51157,\n51169,51193,51197,51199,51203,51217,51229,51239,51241,51257,51263,51283,51287,51307,51329,\n51341,51343,51347,51349,51361,51383,51407,51413,51419,51421,51427,51431,51437,51439,51449,\n51461,51473,51479,51481,51487,51503,51511,51517,51521,51539,51551,51563,51577,51581,51593,\n51599,51607,51613,51631,51637,51647,51659,51673,51679,51683,51691,51713,51719,51721,51749,\n51767,51769,51787,51797,51803,51817,51827,51829,51839,51853,51859,51869,51871,51893,51899,\n51907,51913,51929,51941,51949,51971,51973,51977,51991,52009,52021,52027,52051,52057,52067,\n52069,52081,52103,52121,52127,52147,52153,52163,52177,52181,52183,52189,52201,52223,52237,\n52249,52253,52259,52267,52289,52291,52301,52313,52321,52361,52363,52369,52379,52387,52391,\n52433,52453,52457,52489,52501,52511,52517,52529,52541,52543,52553,52561,52567,52571,52579,\n52583,52609,52627,52631,52639,52667,52673,52691,52697,52709,52711,52721,52727,52733,52747,\n52757,52769,52783,52807,52813,52817,52837,52859,52861,52879,52883,52889,52901,52903,52919,\n52937,52951,52957,52963,52967,52973,52981,52999,53003,53017,53047,53051,53069,53077,53087,\n53089,53093,53101,53113,53117,53129,53147,53149,53161,53171,53173,53189,53197,53201,53231,\n53233,53239,53267,53269,53279,53281,53299,53309,53323,53327,53353,53359,53377,53381,53401,\n53407,53411,53419,53437,53441,53453,53479,53503,53507,53527,53549,53551,53569,53591,53593,\n53597,53609,53611,53617,53623,53629,53633,53639,53653,53657,53681,53693,53699,53717,53719,\n53731,53759,53773,53777,53783,53791,53813,53819,53831,53849,53857,53861,53881,53887,53891,\n53897,53899,53917,53923,53927,53939,53951,53959,53987,53993,54001,54011,54013,54037,54049,\n54059,54083,54091,54101,54121,54133,54139,54151,54163,54167,54181,54193,54217,54251,54269,\n54277,54287,54293,54311,54319,54323,54331,54347,54361,54367,54371,54377,54401,54403,54409,\n54413,54419,54421,54437,54443,54449,54469,54493,54497,54499,54503,54517,54521,54539,54541,\n54547,54559,54563,54577,54581,54583,54601,54617,54623,54629,54631,54647,54667,54673,54679,\n54709,54713,54721,54727,54751,54767,54773,54779,54787,54799,54829,54833,54851,54869,54877,\n54881,54907,54917,54919,54941,54949,54959,54973,54979,54983,55001,55009,55021,55049,55051,\n55057,55061,55073,55079,55103,55109,55117,55127,55147,55163,55171,55201,55207,55213,55217,\n55219,55229,55243,55249,55259,55291,55313,55331,55333,55337,55339,55343,55351,55373,55381,\n55399,55411,55439,55441,55457,55469,55487,55501,55511,55529,55541,55547,55579,55589,55603,\n55609,55619,55621,55631,55633,55639,55661,55663,55667,55673,55681,55691,55697,55711,55717,\n55721,55733,55763,55787,55793,55799,55807,55813,55817,55819,55823,55829,55837,55843,55849,\n55871,55889,55897,55901,55903,55921,55927,55931,55933,55949,55967,55987,55997,56003,56009,\n56039,56041,56053,56081,56087,56093,56099,56101,56113,56123,56131,56149,56167,56171,56179,\n56197,56207,56209,56237,56239,56249,56263,56267,56269,56299,56311,56333,56359,56369,56377,\n56383,56393,56401,56417,56431,56437,56443,56453,56467,56473,56477,56479,56489,56501,56503,\n56509,56519,56527,56531,56533,56543,56569,56591,56597,56599,56611,56629,56633,56659,56663,\n56671,56681,56687,56701,56711,56713,56731,56737,56747,56767,56773,56779,56783,56807,56809,\n56813,56821,56827,56843,56857,56873,56891,56893,56897,56909,56911,56921,56923,56929,56941,\n56951,56957,56963,56983,56989,56993,56999,57037,57041,57047,57059,57073,57077,57089,57097,\n57107,57119,57131,57139,57143,57149,57163,57173,57179,57191,57193,57203,57221,57223,57241,\n57251,57259,57269,57271,57283,57287,57301,57329,57331,57347,57349,57367,57373,57383,57389,\n57397,57413,57427,57457,57467,57487,57493,57503,57527,57529,57557,57559,57571,57587,57593,\n57601,57637,57641,57649,57653,57667,57679,57689,57697,57709,57713,57719,57727,57731,57737,\n57751,57773,57781,57787,57791,57793,57803,57809,57829,57839,57847,57853,57859,57881,57899,\n57901,57917,57923,57943,57947,57973,57977,57991,58013,58027,58031,58043,58049,58057,58061,\n58067,58073,58099,58109,58111,58129,58147,58151,58153,58169,58171,58189,58193,58199,58207,\n58211,58217,58229,58231,58237,58243,58271,58309,58313,58321,58337,58363,58367,58369,58379,\n58391,58393,58403,58411,58417,58427,58439,58441,58451,58453,58477,58481,58511,58537,58543,\n58549,58567,58573,58579,58601,58603,58613,58631,58657,58661,58679,58687,58693,58699,58711,\n58727,58733,58741,58757,58763,58771,58787,58789,58831,58889,58897,58901,58907,58909,58913,\n58921,58937,58943,58963,58967,58979,58991,58997,59009,59011,59021,59023,59029,59051,59053,\n59063,59069,59077,59083,59093,59107,59113,59119,59123,59141,59149,59159,59167,59183,59197,\n59207,59209,59219,59221,59233,59239,59243,59263,59273,59281,59333,59341,59351,59357,59359,\n59369,59377,59387,59393,59399,59407,59417,59419,59441,59443,59447,59453,59467,59471,59473,\n59497,59509,59513,59539,59557,59561,59567,59581,59611,59617,59621,59627,59629,59651,59659,\n59663,59669,59671,59693,59699,59707,59723,59729,59743,59747,59753,59771,59779,59791,59797,\n59809,59833,59863,59879,59887,59921,59929,59951,59957,59971,59981,59999,60013,60017,60029,\n60037,60041,60077,60083,60089,60091,60101,60103,60107,60127,60133,60139,60149,60161,60167,\n60169,60209,60217,60223,60251,60257,60259,60271,60289,60293,60317,60331,60337,60343,60353,\n60373,60383,60397,60413,60427,60443,60449,60457,60493,60497,60509,60521,60527,60539,60589,\n60601,60607,60611,60617,60623,60631,60637,60647,60649,60659,60661,60679,60689,60703,60719,\n60727,60733,60737,60757,60761,60763,60773,60779,60793,60811,60821,60859,60869,60887,60889,\n60899,60901,60913,60917,60919,60923,60937,60943,60953,60961,61001,61007,61027,61031,61043,\n61051,61057,61091,61099,61121,61129,61141,61151,61153,61169,61211,61223,61231,61253,61261,\n61283,61291,61297,61331,61333,61339,61343,61357,61363,61379,61381,61403,61409,61417,61441,\n61463,61469,61471,61483,61487,61493,61507,61511,61519,61543,61547,61553,61559,61561,61583,\n61603,61609,61613,61627,61631,61637,61643,61651,61657,61667,61673,61681,61687,61703,61717,\n61723,61729,61751,61757,61781,61813,61819,61837,61843,61861,61871,61879,61909,61927,61933,\n61949,61961,61967,61979,61981,61987,61991,62003,62011,62017,62039,62047,62053,62057,62071,\n62081,62099,62119,62129,62131,62137,62141,62143,62171,62189,62191,62201,62207,62213,62219,\n62233,62273,62297,62299,62303,62311,62323,62327,62347,62351,62383,62401,62417,62423,62459,\n62467,62473,62477,62483,62497,62501,62507,62533,62539,62549,62563,62581,62591,62597,62603,\n62617,62627,62633,62639,62653,62659,62683,62687,62701,62723,62731,62743,62753,62761,62773,\n62791,62801,62819,62827,62851,62861,62869,62873,62897,62903,62921,62927,62929,62939,62969,\n62971,62981,62983,62987,62989,63029,63031,63059,63067,63073,63079,63097,63103,63113,63127,\n63131,63149,63179,63197,63199,63211,63241,63247,63277,63281,63299,63311,63313,63317,63331,\n63337,63347,63353,63361,63367,63377,63389,63391,63397,63409,63419,63421,63439,63443,63463,\n63467,63473,63487,63493,63499,63521,63527,63533,63541,63559,63577,63587,63589,63599,63601,\n63607,63611,63617,63629,63647,63649,63659,63667,63671,63689,63691,63697,63703,63709,63719,\n63727,63737,63743,63761,63773,63781,63793,63799,63803,63809,63823,63839,63841,63853,63857,\n63863,63901,63907,63913,63929,63949,63977,63997,64007,64013,64019,64033,64037,64063,64067,\n64081,64091,64109,64123,64151,64153,64157,64171,64187,64189,64217,64223,64231,64237,64271,\n64279,64283,64301,64303,64319,64327,64333,64373,64381,64399,64403,64433,64439,64451,64453,\n64483,64489,64499,64513,64553,64567,64577,64579,64591,64601,64609,64613,64621,64627,64633,\n64661,64663,64667,64679,64693,64709,64717,64747,64763,64781,64783,64793,64811,64817,64849,\n64853,64871,64877,64879,64891,64901,64919,64921,64927,64937,64951,64969,64997,65003,65011,\n65027,65029,65033,65053,65063,65071,65089,65099,65101,65111,65119,65123,65129,65141,65147,\n65167,65171,65173,65179,65183,65203,65213,65239,65257,65267,65269,65287,65293,65309,65323,\n65327,65353,65357,65371,65381,65393,65407,65413,65419,65423,65437,65447,65449,65479,65497,\n65519,65521,65537,65539,65543,65551,65557,65563,65579,65581,65587,65599,65609,65617,65629,\n65633,65647,65651,65657,65677,65687,65699,65701,65707,65713,65717,65719,65729,65731,65761,\n65777,65789,65809,65827,65831,65837,65839,65843,65851,65867,65881,65899,65921,65927,65929,\n65951,65957,65963,65981,65983,65993,66029,66037,66041,66047,66067,66071,66083,66089,66103,\n66107,66109,66137,66161,66169,66173,66179,66191,66221,66239,66271,66293,66301,66337,66343,\n66347,66359,66361,66373,66377,66383,66403,66413,66431,66449,66457,66463,66467,66491,66499,\n66509,66523,66529,66533,66541,66553,66569,66571,66587,66593,66601,66617,66629,66643,66653,\n66683,66697,66701,66713,66721,66733,66739,66749,66751,66763,66791,66797,66809,66821,66841,\n66851,66853,66863,66877,66883,66889,66919,66923,66931,66943,66947,66949,66959,66973,66977,\n67003,67021,67033,67043,67049,67057,67061,67073,67079,67103,67121,67129,67139,67141,67153,\n67157,67169,67181,67187,67189,67211,67213,67217,67219,67231,67247,67261,67271,67273,67289,\n67307,67339,67343,67349,67369,67391,67399,67409,67411,67421,67427,67429,67433,67447,67453,\n67477,67481,67489,67493,67499,67511,67523,67531,67537,67547,67559,67567,67577,67579,67589,\n67601,67607,67619,67631,67651,67679,67699,67709,67723,67733,67741,67751,67757,67759,67763,\n67777,67783,67789,67801,67807,67819,67829,67843,67853,67867,67883,67891,67901,67927,67931,\n67933,67939,67943,67957,67961,67967,67979,67987,67993,68023,68041,68053,68059,68071,68087,\n68099,68111,68113,68141,68147,68161,68171,68207,68209,68213,68219,68227,68239,68261,68279,\n68281,68311,68329,68351,68371,68389,68399,68437,68443,68447,68449,68473,68477,68483,68489,\n68491,68501,68507,68521,68531,68539,68543,68567,68581,68597,68611,68633,68639,68659,68669,\n68683,68687,68699,68711,68713,68729,68737,68743,68749,68767,68771,68777,68791,68813,68819,\n68821,68863,68879,68881,68891,68897,68899,68903,68909,68917,68927,68947,68963,68993,69001,\n69011,69019,69029,69031,69061,69067,69073,69109,69119,69127,69143,69149,69151,69163,69191,\n69193,69197,69203,69221,69233,69239,69247,69257,69259,69263,69313,69317,69337,69341,69371,\n69379,69383,69389,69401,69403,69427,69431,69439,69457,69463,69467,69473,69481,69491,69493,\n69497,69499,69539,69557,69593,69623,69653,69661,69677,69691,69697,69709,69737,69739,69761,\n69763,69767,69779,69809,69821,69827,69829,69833,69847,69857,69859,69877,69899,69911,69929,\n69931,69941,69959,69991,69997,70001,70003,70009,70019,70039,70051,70061,70067,70079,70099,\n70111,70117,70121,70123,70139,70141,70157,70163,70177,70181,70183,70199,70201,70207,70223,\n70229,70237,70241,70249,70271,70289,70297,70309,70313,70321,70327,70351,70373,70379,70381,\n70393,70423,70429,70439,70451,70457,70459,70481,70487,70489,70501,70507,70529,70537,70549,\n70571,70573,70583,70589,70607,70619,70621,70627,70639,70657,70663,70667,70687,70709,70717,\n70729,70753,70769,70783,70793,70823,70841,70843,70849,70853,70867,70877,70879,70891,70901,\n70913,70919,70921,70937,70949,70951,70957,70969,70979,70981,70991,70997,70999,71011,71023,\n71039,71059,71069,71081,71089,71119,71129,71143,71147,71153,71161,71167,71171,71191,71209,\n71233,71237,71249,71257,71261,71263,71287,71293,71317,71327,71329,71333,71339,71341,71347,\n71353,71359,71363,71387,71389,71399,71411,71413,71419,71429,71437,71443,71453,71471,71473,\n71479,71483,71503,71527,71537,71549,71551,71563,71569,71593,71597,71633,71647,71663,71671,\n71693,71699,71707,71711,71713,71719,71741,71761,71777,71789,71807,71809,71821,71837,71843,\n71849,71861,71867,71879,71881,71887,71899,71909,71917,71933,71941,71947,71963,71971,71983,\n71987,71993,71999,72019,72031,72043,72047,72053,72073,72077,72089,72091,72101,72103,72109,\n72139,72161,72167,72169,72173,72211,72221,72223,72227,72229,72251,72253,72269,72271,72277,\n72287,72307,72313,72337,72341,72353,72367,72379,72383,72421,72431,72461,72467,72469,72481,\n72493,72497,72503,72533,72547,72551,72559,72577,72613,72617,72623,72643,72647,72649,72661,\n72671,72673,72679,72689,72701,72707,72719,72727,72733,72739,72763,72767,72797,72817,72823,\n72859,72869,72871,72883,72889,72893,72901,72907,72911,72923,72931,72937,72949,72953,72959,\n72973,72977,72997,73009,73013,73019,73037,73039,73043,73061,73063,73079,73091,73121,73127,\n73133,73141,73181,73189,73237,73243,73259,73277,73291,73303,73309,73327,73331,73351,73361,\n73363,73369,73379,73387,73417,73421,73433,73453,73459,73471,73477,73483,73517,73523,73529,\n73547,73553,73561,73571,73583,73589,73597,73607,73609,73613,73637,73643,73651,73673,73679,\n73681,73693,73699,73709,73721,73727,73751,73757,73771,73783,73819,73823,73847,73849,73859,\n73867,73877,73883,73897,73907,73939,73943,73951,73961,73973,73999,74017,74021,74027,74047,\n74051,74071,74077,74093,74099,74101,74131,74143,74149,74159,74161,74167,74177,74189,74197,\n74201,74203,74209,74219,74231,74257,74279,74287,74293,74297,74311,74317,74323,74353,74357,\n74363,74377,74381,74383,74411,74413,74419,74441,74449,74453,74471,74489,74507,74509,74521,\n74527,74531,74551,74561,74567,74573,74587,74597,74609,74611,74623,74653,74687,74699,74707,\n74713,74717,74719,74729,74731,74747,74759,74761,74771,74779,74797,74821,74827,74831,74843,\n74857,74861,74869,74873,74887,74891,74897,74903,74923,74929,74933,74941,74959,75011,75013,\n75017,75029,75037,75041,75079,75083,75109,75133,75149,75161,75167,75169,75181,75193,75209,\n75211,75217,75223,75227,75239,75253,75269,75277,75289,75307,75323,75329,75337,75347,75353,\n75367,75377,75389,75391,75401,75403,75407,75431,75437,75479,75503,75511,75521,75527,75533,\n75539,75541,75553,75557,75571,75577,75583,75611,75617,75619,75629,75641,75653,75659,75679,\n75683,75689,75703,75707,75709,75721,75731,75743,75767,75773,75781,75787,75793,75797,75821,\n75833,75853,75869,75883,75913,75931,75937,75941,75967,75979,75983,75989,75991,75997,76001,\n76003,76031,76039,76079,76081,76091,76099,76103,76123,76129,76147,76157,76159,76163,76207,\n76213,76231,76243,76249,76253,76259,76261,76283,76289,76303,76333,76343,76367,76369,76379,\n76387,76403,76421,76423,76441,76463,76471,76481,76487,76493,76507,76511,76519,76537,76541,\n76543,76561,76579,76597,76603,76607,76631,76649,76651,76667,76673,76679,76697,76717,76733,\n76753,76757,76771,76777,76781,76801,76819,76829,76831,76837,76847,76871,76873,76883,76907,\n76913,76919,76943,76949,76961,76963,76991,77003,77017,77023,77029,77041,77047,77069,77081,\n77093,77101,77137,77141,77153,77167,77171,77191,77201,77213,77237,77239,77243,77249,77261,\n77263,77267,77269,77279,77291,77317,77323,77339,77347,77351,77359,77369,77377,77383,77417,\n77419,77431,77447,77471,77477,77479,77489,77491,77509,77513,77521,77527,77543,77549,77551,\n77557,77563,77569,77573,77587,77591,77611,77617,77621,77641,77647,77659,77681,77687,77689,\n77699,77711,77713,77719,77723,77731,77743,77747,77761,77773,77783,77797,77801,77813,77839,\n77849,77863,77867,77893,77899,77929,77933,77951,77969,77977,77983,77999,78007,78017,78031,\n78041,78049,78059,78079,78101,78121,78137,78139,78157,78163,78167,78173,78179,78191,78193,\n78203,78229,78233,78241,78259,78277,78283,78301,78307,78311,78317,78341,78347,78367,78401,\n78427,78437,78439,78467,78479,78487,78497,78509,78511,78517,78539,78541,78553,78569,78571,\n78577,78583,78593,78607,78623,78643,78649,78653,78691,78697,78707,78713,78721,78737,78779,\n78781,78787,78791,78797,78803,78809,78823,78839,78853,78857,78877,78887,78889,78893,78901,\n78919,78929,78941,78977,78979,78989,79031,79039,79043,79063,79087,79103,79111,79133,79139,\n79147,79151,79153,79159,79181,79187,79193,79201,79229,79231,79241,79259,79273,79279,79283,\n79301,79309,79319,79333,79337,79349,79357,79367,79379,79393,79397,79399,79411,79423,79427,\n79433,79451,79481,79493,79531,79537,79549,79559,79561,79579,79589,79601,79609,79613,79621,\n79627,79631,79633,79657,79669,79687,79691,79693,79697,79699,79757,79769,79777,79801,79811,\n79813,79817,79823,79829,79841,79843,79847,79861,79867,79873,79889,79901,79903,79907,79939,\n79943,79967,79973,79979,79987,79997,79999,80021,80039,80051,80071,80077,80107,80111,80141,\n80147,80149,80153,80167,80173,80177,80191,80207,80209,80221,80231,80233,80239,80251,80263,\n80273,80279,80287,80309,80317,80329,80341,80347,80363,80369,80387,80407,80429,80447,80449,\n80471,80473,80489,80491,80513,80527,80537,80557,80567,80599,80603,80611,80621,80627,80629,\n80651,80657,80669,80671,80677,80681,80683,80687,80701,80713,80737,80747,80749,80761,80777,\n80779,80783,80789,80803,80809,80819,80831,80833,80849,80863,80897,80909,80911,80917,80923,\n80929,80933,80953,80963,80989,81001,81013,81017,81019,81023,81031,81041,81043,81047,81049,\n81071,81077,81083,81097,81101,81119,81131,81157,81163,81173,81181,81197,81199,81203,81223,\n81233,81239,81281,81283,81293,81299,81307,81331,81343,81349,81353,81359,81371,81373,81401,\n81409,81421,81439,81457,81463,81509,81517,81527,81533,81547,81551,81553,81559,81563,81569,\n81611,81619,81629,81637,81647,81649,81667,81671,81677,81689,81701,81703,81707,81727,81737,\n81749,81761,81769,81773,81799,81817,81839,81847,81853,81869,81883,81899,81901,81919,81929,\n81931,81937,81943,81953,81967,81971,81973,82003,82007,82009,82013,82021,82031,82037,82039,\n82051,82067,82073,82129,82139,82141,82153,82163,82171,82183,82189,82193,82207,82217,82219,\n82223,82231,82237,82241,82261,82267,82279,82301,82307,82339,82349,82351,82361,82373,82387,\n82393,82421,82457,82463,82469,82471,82483,82487,82493,82499,82507,82529,82531,82549,82559,\n82561,82567,82571,82591,82601,82609,82613,82619,82633,82651,82657,82699,82721,82723,82727,\n82729,82757,82759,82763,82781,82787,82793,82799,82811,82813,82837,82847,82883,82889,82891,\n82903,82913,82939,82963,82981,82997,83003,83009,83023,83047,83059,83063,83071,83077,83089,\n83093,83101,83117,83137,83177,83203,83207,83219,83221,83227,83231,83233,83243,83257,83267,\n83269,83273,83299,83311,83339,83341,83357,83383,83389,83399,83401,83407,83417,83423,83431,\n83437,83443,83449,83459,83471,83477,83497,83537,83557,83561,83563,83579,83591,83597,83609,\n83617,83621,83639,83641,83653,83663,83689,83701,83717,83719,83737,83761,83773,83777,83791,\n83813,83833,83843,83857,83869,83873,83891,83903,83911,83921,83933,83939,83969,83983,83987,\n84011,84017,84047,84053,84059,84061,84067,84089,84121,84127,84131,84137,84143,84163,84179,\n84181,84191,84199,84211,84221,84223,84229,84239,84247,84263,84299,84307,84313,84317,84319,\n84347,84349,84377,84389,84391,84401,84407,84421,84431,84437,84443,84449,84457,84463,84467,\n84481,84499,84503,84509,84521,84523,84533,84551,84559,84589,84629,84631,84649,84653,84659,\n84673,84691,84697,84701,84713,84719,84731,84737,84751,84761,84787,84793,84809,84811,84827,\n84857,84859,84869,84871,84913,84919,84947,84961,84967,84977,84979,84991,85009,85021,85027,\n85037,85049,85061,85081,85087,85091,85093,85103,85109,85121,85133,85147,85159,85193,85199,\n85201,85213,85223,85229,85237,85243,85247,85259,85297,85303,85313,85331,85333,85361,85363,\n85369,85381,85411,85427,85429,85439,85447,85451,85453,85469,85487,85513,85517,85523,85531,\n85549,85571,85577,85597,85601,85607,85619,85621,85627,85639,85643,85661,85667,85669,85691,\n85703,85711,85717,85733,85751,85781,85793,85817,85819,85829,85831,85837,85843,85847,85853,\n85889,85903,85909,85931,85933,85991,85999,86011,86017,86027,86029,86069,86077,86083,86111,\n86113,86117,86131,86137,86143,86161,86171,86179,86183,86197,86201,86209,86239,86243,86249,\n86257,86263,86269,86287,86291,86293,86297,86311,86323,86341,86351,86353,86357,86369,86371,\n86381,86389,86399,86413,86423,86441,86453,86461,86467,86477,86491,86501,86509,86531,86533,\n86539,86561,86573,86579,86587,86599,86627,86629,86677,86689,86693,86711,86719,86729,86743,\n86753,86767,86771,86783,86813,86837,86843,86851,86857,86861,86869,86923,86927,86929,86939,\n86951,86959,86969,86981,86993,87011,87013,87037,87041,87049,87071,87083,87103,87107,87119,\n87121,87133,87149,87151,87179,87181,87187,87211,87221,87223,87251,87253,87257,87277,87281,\n87293,87299,87313,87317,87323,87337,87359,87383,87403,87407,87421,87427,87433,87443,87473,\n87481,87491,87509,87511,87517,87523,87539,87541,87547,87553,87557,87559,87583,87587,87589,\n87613,87623,87629,87631,87641,87643,87649,87671,87679,87683,87691,87697,87701,87719,87721,\n87739,87743,87751,87767,87793,87797,87803,87811,87833,87853,87869,87877,87881,87887,87911,\n87917,87931,87943,87959,87961,87973,87977,87991,88001,88003,88007,88019,88037,88069,88079,\n88093,88117,88129,88169,88177,88211,88223,88237,88241,88259,88261,88289,88301,88321,88327,\n88337,88339,88379,88397,88411,88423,88427,88463,88469,88471,88493,88499,88513,88523,88547,\n88589,88591,88607,88609,88643,88651,88657,88661,88663,88667,88681,88721,88729,88741,88747,\n88771,88789,88793,88799,88801,88807,88811,88813,88817,88819,88843,88853,88861,88867,88873,\n88883,88897,88903,88919,88937,88951,88969,88993,88997,89003,89009,89017,89021,89041,89051,\n89057,89069,89071,89083,89087,89101,89107,89113,89119,89123,89137,89153,89189,89203,89209,\n89213,89227,89231,89237,89261,89269,89273,89293,89303,89317,89329,89363,89371,89381,89387,\n89393,89399,89413,89417,89431,89443,89449,89459,89477,89491,89501,89513,89519,89521,89527,\n89533,89561,89563,89567,89591,89597,89599,89603,89611,89627,89633,89653,89657,89659,89669,\n89671,89681,89689,89753,89759,89767,89779,89783,89797,89809,89819,89821,89833,89839,89849,\n89867,89891,89897,89899,89909,89917,89923,89939,89959,89963,89977,89983,89989,90001,90007,\n90011,90017,90019,90023,90031,90053,90059,90067,90071,90073,90089,90107,90121,90127,90149,\n90163,90173,90187,90191,90197,90199,90203,90217,90227,90239,90247,90263,90271,90281,90289,\n90313,90353,90359,90371,90373,90379,90397,90401,90403,90407,90437,90439,90469,90473,90481,\n90499,90511,90523,90527,90529,90533,90547,90583,90599,90617,90619,90631,90641,90647,90659,\n90677,90679,90697,90703,90709,90731,90749,90787,90793,90803,90821,90823,90833,90841,90847,\n90863,90887,90901,90907,90911,90917,90931,90947,90971,90977,90989,90997,91009,91019,91033,\n91079,91081,91097,91099,91121,91127,91129,91139,91141,91151,91153,91159,91163,91183,91193,\n91199,91229,91237,91243,91249,91253,91283,91291,91297,91303,91309,91331,91367,91369,91373,\n91381,91387,91393,91397,91411,91423,91433,91453,91457,91459,91463,91493,91499,91513,91529,\n91541,91571,91573,91577,91583,91591,91621,91631,91639,91673,91691,91703,91711,91733,91753,\n91757,91771,91781,91801,91807,91811,91813,91823,91837,91841,91867,91873,91909,91921,91939,\n91943,91951,91957,91961,91967,91969,91997,92003,92009,92033,92041,92051,92077,92083,92107,\n92111,92119,92143,92153,92173,92177,92179,92189,92203,92219,92221,92227,92233,92237,92243,\n92251,92269,92297,92311,92317,92333,92347,92353,92357,92363,92369,92377,92381,92383,92387,\n92399,92401,92413,92419,92431,92459,92461,92467,92479,92489,92503,92507,92551,92557,92567,\n92569,92581,92593,92623,92627,92639,92641,92647,92657,92669,92671,92681,92683,92693,92699,\n92707,92717,92723,92737,92753,92761,92767,92779,92789,92791,92801,92809,92821,92831,92849,\n92857,92861,92863,92867,92893,92899,92921,92927,92941,92951,92957,92959,92987,92993,93001,\n93047,93053,93059,93077,93083,93089,93097,93103,93113,93131,93133,93139,93151,93169,93179,\n93187,93199,93229,93239,93241,93251,93253,93257,93263,93281,93283,93287,93307,93319,93323,\n93329,93337,93371,93377,93383,93407,93419,93427,93463,93479,93481,93487,93491,93493,93497,\n93503,93523,93529,93553,93557,93559,93563,93581,93601,93607,93629,93637,93683,93701,93703,\n93719,93739,93761,93763,93787,93809,93811,93827,93851,93871,93887,93889,93893,93901,93911,\n93913,93923,93937,93941,93949,93967,93971,93979,93983,93997,94007,94009,94033,94049,94057,\n94063,94079,94099,94109,94111,94117,94121,94151,94153,94169,94201,94207,94219,94229,94253,\n94261,94273,94291,94307,94309,94321,94327,94331,94343,94349,94351,94379,94397,94399,94421,\n94427,94433,94439,94441,94447,94463,94477,94483,94513,94529,94531,94541,94543,94547,94559,\n94561,94573,94583,94597,94603,94613,94621,94649,94651,94687,94693,94709,94723,94727,94747,\n94771,94777,94781,94789,94793,94811,94819,94823,94837,94841,94847,94849,94873,94889,94903,\n94907,94933,94949,94951,94961,94993,94999,95003,95009,95021,95027,95063,95071,95083,95087,\n95089,95093,95101,95107,95111,95131,95143,95153,95177,95189,95191,95203,95213,95219,95231,\n95233,95239,95257,95261,95267,95273,95279,95287,95311,95317,95327,95339,95369,95383,95393,\n95401,95413,95419,95429,95441,95443,95461,95467,95471,95479,95483,95507,95527,95531,95539,\n95549,95561,95569,95581,95597,95603,95617,95621,95629,95633,95651,95701,95707,95713,95717,\n95723,95731,95737,95747,95773,95783,95789,95791,95801,95803,95813,95819,95857,95869,95873,\n95881,95891,95911,95917,95923,95929,95947,95957,95959,95971,95987,95989,96001,96013,96017,\n96043,96053,96059,96079,96097,96137,96149,96157,96167,96179,96181,96199,96211,96221,96223,\n96233,96259,96263,96269,96281,96289,96293,96323,96329,96331,96337,96353,96377,96401,96419,\n96431,96443,96451,96457,96461,96469,96479,96487,96493,96497,96517,96527,96553,96557,96581,\n96587,96589,96601,96643,96661,96667,96671,96697,96703,96731,96737,96739,96749,96757,96763,\n96769,96779,96787,96797,96799,96821,96823,96827,96847,96851,96857,96893,96907,96911,96931,\n96953,96959,96973,96979,96989,96997,97001,97003,97007,97021,97039,97073,97081,97103,97117,\n97127,97151,97157,97159,97169,97171,97177,97187,97213,97231,97241,97259,97283,97301,97303,\n97327,97367,97369,97373,97379,97381,97387,97397,97423,97429,97441,97453,97459,97463,97499,\n97501,97511,97523,97547,97549,97553,97561,97571,97577,97579,97583,97607,97609,97613,97649,\n97651,97673,97687,97711,97729,97771,97777,97787,97789,97813,97829,97841,97843,97847,97849,\n97859,97861,97871,97879,97883,97919,97927,97931,97943,97961,97967,97973,97987,98009,98011,\n98017,98041,98047,98057,98081,98101,98123,98129,98143,98179,98207,98213,98221,98227,98251,\n98257,98269,98297,98299,98317,98321,98323,98327,98347,98369,98377,98387,98389,98407,98411,\n98419,98429,98443,98453,98459,98467,98473,98479,98491,98507,98519,98533,98543,98561,98563,\n98573,98597,98621,98627,98639,98641,98663,98669,98689,98711,98713,98717,98729,98731,98737,\n98773,98779,98801,98807,98809,98837,98849,98867,98869,98873,98887,98893,98897,98899,98909,\n98911,98927,98929,98939,98947,98953,98963,98981,98993,98999,99013,99017,99023,99041,99053,\n99079,99083,99089,99103,99109,99119,99131,99133,99137,99139,99149,99173,99181,99191,99223,\n99233,99241,99251,99257,99259,99277,99289,99317,99347,99349,99367,99371,99377,99391,99397,\n99401,99409,99431,99439,99469,99487,99497,99523,99527,99529,99551,99559,99563,99571,99577,\n99581,99607,99611,99623,99643,99661,99667,99679,99689,99707,99709,99713,99719,99721,99733,\n99761,99767,99787,99793,99809,99817,99823,99829,99833,99839,99859,99871,99877,99881,99901,\n99907,99923,99929,99961,99971,99989,99991\n);\nvar o,o1,o2,k,max,min,h,n,t,m,i,j:longint;\na:array[0..100000]of longint;\nbegin\n//reset(input,'input.txt');\n//rewrite(output,'output.txt');\nread(n);\nif n=2 then begin\nwrite(4);\nhalt(0);\nend;\nif n=1 then begin\nwrite(8);\nhalt(0);\nend;\nif n mod 2=1 then begin\nwrite(2);\nhalt(0);\nend;\ni:=1;\nwhile n mod p[i]=0 do\ninc(i);\nwhile ((n mod p[i])*k)mod p[i]<>p[i]-1 do\ninc(k);\nwrite(k);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprogram gtRus;\n\n{$APPTYPE CONSOLE}\n{$o-}\nuses\n SysUtils;\n\n\nvar n,t,m,i,j:longint;\na,b:array[1..10000,1..10000]of longint;\nh:array[1..100000]of byte;\nbegin\nreset(input,'input.txt');\nrewrite(output,'output.txt');\nread(n,m);\nfor i:=1 to n do\nfor j:=1 to m do\nread(a[i,j]);\nfor i:=2 to n do\na[i,1]:=a[i,1]+a[i-1,1];\nfor i:=2 to m do\na[1,i]:=a[1,i]+a[1,i-1];\nfor i:=2 to n do\nfor j:=2 to m do\nif a[i-1,j]>a[i,j-1] then \na[i,j]:=a[i,j]+a[i,j-1] else begin\na[i,j]:=a[i,j]+a[i-1,j];\nb[i,j]:=1;\nend;\nwriteln(a[n,m]);\nfor i:=2 to n do\nb[i,1]:=1;\ni:=n;\nj:=m;\nfor t:=1 to n+m-2 do\nif b[i,j]=1 then begin\nh[t]:=1;\ndec(i);\nend else\ndec(j);\ni:=1;\nj:=1;\nwriteln(i,' ',j);\nfor t:=n+m-2 downto 1 do\nif h[t]=1 then begin\ninc(i);\nwriteln(i,' ',j);\nend else begin\ninc(j);\nwriteln(i,' ',j);\nend;\nend.\n"}, {"source_code": "program cntestvadimA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,m :integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n if (n=1) then m:=0\n else if (n=2) then m:=0\n else if (n=3) then m:=1\n else m:=(n-2);\n write(m);\nend.\n"}, {"source_code": "program cntestvadimA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n,m :integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n if (n=1) then m:=3\n else if (n=2) then m:=0\n else if (n=3) then m:=1\n else m:=(n-2);\n write(m);\nend.\n"}, {"source_code": "begin\n write(996);\nend."}, {"source_code": "begin\n write(random(996)+1)\nend."}, {"source_code": "begin\n write(random(996)+3)\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n if n=1\n then write(2)\n else write(abs(n mod 2 - 2));\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n if n=1\n then write(3)\n else write(abs(n mod 2 - 2));\nend."}, {"source_code": "begin\n write(997)\nend."}, {"source_code": "var\nn,i,k,j:longint;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\tbegin\n\tfor j:=1 to n*i+1 do\n\tif ((n*i+1) mod j) = 0 then\n\tk:=k+1;\n\tif k>2 then\n\tbegin\n\twriteln(i);\n\tbreak;\n\tend\n\telse\n\tk:=0;\n\tend;\nend."}, {"source_code": "var m,n,i,j:longint;\n\nBegin\n\tReadln(n);\n\tIf (n mod 2<>0) then Writeln('1')\n\tElse Writeln(n-2);\t\nEnd."}, {"source_code": "var m,n,i,j:longint;\n\nBegin\n\tReadln(n);\n\tIf (n mod 2<>0) and (n<>1) then Writeln('3')\n\tElse Writeln(n-2);\t\nEnd."}, {"source_code": "var n,m:longint;\n\nfunction prost(a:longint): boolean;\n var k,i:longint;\n begin\n k:=round(sqrt(a));\n if(a=2) then\n writeln('prime')\n else\n for i:=2 to k do \n if(a mod i=0) then\n begin\n prost:=true;\n break;\n end\n else if(i=k) then\n prost:=false;\n end;\n\nbegin\n read(n);\n m:=1;\n while (true) do\n begin\n if(prost(n*m+1)) then\n break;\n inc(m);\n end;\n writeln(m);\nend."}, {"source_code": "var n:LongInt;\nbegin\nreadln(n);\nwriteln(n-2);\nend."}, {"source_code": "var n:LongInt;\nbegin\nreadln(n);\ncase n of\n1 : writeln('1');\n2 : writeln('4');\nelse writeln(n-2)\nend\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint; Z:array['a'..'z'] of longint; P:array['A'..'Z'] of longint;\ns1,s:ansistring;\n\nFunction min(x,y:longint):longint;\nbegin\nif x1 do begin\ninc(m);\nc:=1; tr:=trunc(sqrt(m*n+1));\nfor i:=2 to tr do begin\nif ( ((n*m)+1) mod i)<>0 then inc(c); \nend;\nif c<>tr then l:=1;\n\nend; \n\n\nwriteln(m);\n\nend."}, {"source_code": "var n,m,i :integer;\nbegin\nreadln(n);\nif n > 2 then writeln(n-2);\nif n = 2 then writeln('7');\nif n = 1 then writeln('1');\nend."}, {"source_code": "var\n n,a,b,i : longint;\nbegin\n readln(n);\n while (1 = 1) do\n begin\n inc(b);\n a := n*b+1;\n for i := 2 to round(sqrt(a))+1 do\n if (a mod i = 0) then\n begin\n writeln(b);\n exit;\n end;\n end;\nend."}, {"source_code": "var\nn,i,q,j:longint;\nbol:boolean;\nbegin\n\nreadln(n);\nfor i:=1 to 10000000 do begin\n q:=n*i+1;\n bol:=true;\n for j:=2 to trunc(sqrt(j)) do begin\n if q mod j = 0 then begin\n bol:=false;\n break;\n end;\n end;\n if bol then begin\n writeln(i);\n break;\n end;\nend;\nend."}, {"source_code": "var\nn,i,ch,j:longint;\nb:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nb:=false;\nch:=n*i+1;\nfor j:=2 to round(sqrt(ch)) do begin\nif ch mod j = 0 then begin\nb:=true;\nbreak;\nend;\nend;\nif b then begin\nwriteln(i);\nbreak;\nend;\nend;\nend."}, {"source_code": "var\nn,i,ch,j:longint;\nb:boolean;\nbegin\nreadln(n);\nif (n=1) or (n=2)then writeln('4')\nelse\nbegin\nfor i:=1 to n do begin\nb:=false;\nch:=n*i+1;\nfor j:=2 to round(sqrt(ch)) do begin\nif ch mod j = 0 then begin\nb:=true;\nbreak;\nend;\nend;\nif b then begin\nwriteln(i);\nbreak;\nend;\nend;\nend;\nend."}, {"source_code": "var n : longint;\n\nbegin\n readln(n);\n writeln(n + 2);\nend."}, {"source_code": "var n,m: longint;\nbegin\nreadln (n);\nm:=n-2;\nwriteln (m);\nend."}, {"source_code": "var n,m: longint;\nbegin\nreadln (n);\nm:=n-2;\nif n=1 then writeln ('3') else\nif n=2 then writeln ('2') else writeln (m);\nend."}, {"source_code": "uses math;\nconst\n\tfi = '';\n\tfo = '';\n\tmaxN = 1001;\nVar\n\tn,i,j,m:longint;\n\tp:array[1..maxN*maxN] of longint;\nBegin\n\tassign(input, fi); reset(input);\n\tassign(output,fo); rewrite(output);\n\tfor i:=2 to trunc(sqrt(maxN*maxN)) do\n\t\tif p[i] = 0 then\n\t\tbegin\n\t\t\tj:=i*i;\n\t\t\twhile j<=maxN*maxN do\n\t\t\tbegin\n\t\t\t\tp[j]:=i;\n\t\t\t\tj:=j+i;\n\t\t\tend;\n\t\tend;\n\treadln(n);\n\tfor m:=1 to 1000 do\n\t\tif p[n*m+1]=1 then\n\t\tbegin\n\t\t\twriteln(m);\n\t\t\tbreak;\n\t\tend;\n\tclose(input); close(output);\nend.\n"}, {"source_code": "var\n\tn, i: longword;\n\t\nfunction is_prime: boolean;\nvar\n\tx, k: longword;\nbegin\n\tx:= n * i + 1;\n\tif x <= 1 then exit(false)\n\t\telse if x <= 3 then exit(true)\n\t\t\telse if (x mod 2 = 0) and (x mod 3 = 0) then exit(false);\n\tk:= 5;\n\twhile k * k < x do\n\tbegin\n\t\tif (x mod k = 0) or (x mod (k+2) = 0 ) then exit(false);\n\t\tinc(k, 6);\n\tend;\n\tis_prime:= true;\nend;\nbegin\n\tread(n);\n\tfor i:= 1 to n do\n\t\tif is_prime then \n\t\t\tbegin\n\t\t\t\twrite(i);\n\t\t\t\tbreak;\n\t\t\tend;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar f,g:text;\n n:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n);\n close(f);\nend;\nfunction kt(n:longint):boolean;\nvar i:longint;\nbegin\n if n<2 then exit(false);\n if n=2 then exit(true);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n assign(G,fo);\n rewrite(G);\n if n=1 then write(g,0) else for i:=1 to 1000 do if kt(n*i+1)=false then\n begin\n writeln(g,i);\n break;\n end;\n close(g);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar f,g:text;\n n:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n);\n close(f);\nend;\nfunction kt(n:longint):boolean;\nvar i:longint;\nbegin\n if n<2 then exit(false);\n if n=2 then exit(true);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n assign(G,fo);\n rewrite(G);\n if n=1 then write(g,0) else for i:=1 to n do if kt(n*i+1)=false then\n begin\n writeln(g,i);\n break;\n end;\n close(g);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if n mod 2 <> 0 then writeln(1) else writeln(2);\nend.\n\n \n"}, {"source_code": "var n,i,j:longint;\nbegin\n readln(n);\n if n mod 2 <> 0 then writeln(3)\n else \n for i:=2 to 1000 do \n for j:=2 to 1000 do\n if n*i+1 mod i <> 0 then begin writeln(i); exit; end; \n \nend.\n\n \n"}, {"source_code": "var n,i,j:longint;\nbegin\n readln(n);\n if n mod 2 <> 0 then writeln(1)\n else \n for i:=2 to 1000 do \n for j:=2 to 1000 do\n if n*i+1 mod i <> 0 then begin writeln(i); exit; end; \n \nend.\n\n \n"}, {"source_code": "var\n f : boolean;\n x,n,i,j : longint;\nbegin\n readln(n);\n\n if n=1 then begin writeln(3); exit; end;\n\n for i:=1 to n do begin\n x:=n*i+1;\n f:=true;\n for j:=2 to x div 2 do\n if x mod j =0\n then begin f:=false; break; end;\n\n if f=false then begin f:=true; writeln(i); exit; end\n\n end;\n\n\n\n\nend."}, {"source_code": "var\n f : boolean;\n x,n,i,j : longint;\nbegin\n readln(n);\n\n\n for i:=1 to n do begin\n x:=n*i+1;\n for j:=2 to x div 2 do\n if x mod j =0 then begin f:=false; break; end;\n if f=false then begin f:=true;continue end\n else begin writeln(i); exit;end;\n\n end;\n\n\n\nend."}, {"source_code": "var\n f : boolean;\n x,n,i,j : longint;\nbegin\n readln(n);\n\n\n for i:=1 to n do begin\n x:=n*i+1;\n f:=true;\n for j:=2 to x div 2 do\n if x mod j =0\n then begin f:=false; break; end;\n\n if f=false then begin f:=true; writeln(i); exit; end\n\n end;\n\n\n\n\nend."}, {"source_code": "var n:longint;\nbegin\n readln(n);\n if n mod 2 = 0 then write(n-1)\n else write(n);\nend."}, {"source_code": "var a,b: longint;\nbegin\nread(a); if a=1 then begin b:=17; write(17); halt end;\nif a mod 2 = 1 then begin b:=1; write('1'); halt end;\nif a mod 3 = 0 then begin b:=1; write('1'); halt end;\nif a mod 3 = 1 then begin b:=5; write('5'); halt end;\nwrite('4'); b:=4; end."}, {"source_code": "var a,b: longint;\nbegin\nread(a);\nif a mod 2 = 1 then begin b:=1; write('1'); halt end;\nif a mod 3 = 0 then begin b:=1; write('1'); halt end;\nif a mod 3 = 1 then begin b:=5; write('5'); halt end;\nwrite('4'); b:=4; end."}, {"source_code": " var\n\t\tn, b, c, r: int64;\n\t\ta: array of integer;\n\t\t\n begin\n\t\t\n\t\treadln(n);\n\t\tSetLength(a, 1101);\n\t\t\n\t\tvar i := 2;\n\t\tvar j: integer;\n\t\twhile (i <= 1100) do\n\t\tbegin\n\t\t\tj := i * 2;\n\t\t\twhile(j <= 1100) do\n\t\t\tbegin\n\t\t\t\ta[j] += 1;\n\t\t\t\tj += i;\n\t\t\tend;\n\t\t\ti += 1;\n\t\tend;\n\t\ta[0] := 1;\n\t\ta[1] := 1;\n\t\t\n\t\tif (n mod 2 = 1) then\n\t\t\twriteln(1)\n\t\telse begin\n\t\t\tfor var l := 1 to 1100 do\n\t\t\tbegin\n\t\t\t\tif (a[n*l+1] <> 0) then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(l);\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\t\t\n end.\n"}, {"source_code": "Var n : Longint;\nBegin\nReadln(n);\nIf n mod 2 = 0 then Writeln('997') else Writeln('998');\nEnd."}, {"source_code": "Var n : Longint;\nBegin\nReadln(n);\nIf n mod 2 = 0 then Writeln('998') else Writeln('997');\nEnd."}, {"source_code": "Var i , n , m : Longint;\nBegin\nReadln(n);\n//For i := 1 to 1000 do\n//If Frac(Sqrt(n*m+1)) <> 0 then Break;\n//Writeln(i);\nIf n mod 10 = 1 then Writeln('998') else Writeln('999');\nEnd."}, {"source_code": "Var n : Longint;\nBegin\nReadln(n);\nWriteln('997');\nEnd."}], "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"source_code": "const fi='';//750B.inp';\n fo='';//750B.out';\n\nvar n:longint;\n\nprocedure doc;\n var i,k,d,x:longint;\n s:string;\n begin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(n);\n d:=0;\n for i:=1 to n do\n begin\n read(x); readln(s);\n if s[2]='N' then k:=1;\n if s[2]='E' then k:=2;\n if s[2]='S' then k:=3;\n if s[2]='W' then k:=4;\n if ((d=0) or (d=20000)) and ((k=2) or (k=4)) then\n begin write('NO'); exit; end;\n if (d=0) and (k=1) then\n begin write('NO'); exit; end;\n if (d=20000) and (k=3) then\n begin write('NO'); exit; end;\n if k=1 then\n begin\n d:=d-x;\n if d<0 then\n begin write('NO'); exit; end;\n end;\n if k=3 then\n begin\n d:=x+d;\n if d >20000 then\n begin write('NO'); exit; end;\n end;\n end;\n if d=0 then write('YES') else write('NO');\n end;\n\nBEGIN\n DOC;\nEND.\n\n", "positive_code": [{"source_code": "program cf750B;\nconst lim=20000;\n letter:set of char=['A'..'Z'];\nvar n,now,t,i:longint;\n ch:char;\nprocedure printerr;\nbegin\n writeln('NO');\n halt;\nend;\nprocedure getch(var ch:char);\nbegin\n read(ch);\n while not (ch in letter) do read(ch);\nend;\nbegin\n readln(n);\n now:=0;\n for i:=1 to n do\n begin\n read(t);\n getch(ch);\n readln;\n if (now=0)and(ch<>'S') then printerr;\n if (now=lim)and(ch<>'N') then printerr;\n if ch='S' then now:=now+t\n else if ch='N' then now:=now-t;\n if (now<0)or(now>lim) then printerr;\n end;\n if now<>0 then printerr;\n writeln('YES');\nend.\n"}, {"source_code": "var n,now,i:longint;\n k:int64;\n s:ansistring;\nbegin\n readln(n);now:=0;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),k);\n delete(s,1,pos(' ',s));\n if(s[1]='N')then now:=now-k\n else if(s[1]='S')then now:=now+k;\n if((now=0)or(now=20000))and((s[1]='E')or(s[1]='W'))then begin writeln('NO');halt;end;\n if(now<0)or(now>20000)then begin writeln('NO');halt;end;\n end;\n if(now<>0)then writeln('NO')else writeln('YES');\nend."}, {"source_code": "var i,n,sum,x:longint;\n s:string;\nbegin\n //assign(input,'input.txt');reset(input);\n readln(n);\n for i:=1 to n do\n begin\n read(x); readln(s);\n if s[2]='S' then inc(sum,x);\n if s[2]='N' then dec(sum,x);\n if ((s[2]='W')or(s[2]='E'))and((sum=0)or(sum=20000))then begin writeln('NO');halt; end;\n if (sum<0)or(sum>20000)then begin writeln('NO');halt;end;\n end;\n if (sum=0)then write('YES')else write('NO');\nend."}, {"source_code": "var n,i,x:longint;\n d:int64;\n s:ansistring;\nbegin\n readln(n);\n d:=0;\n for i:=1 to n do\n begin\n readln(x,s);\n delete(s,1,1);\n if (d=0) and (s<>'South') then begin writeln('NO'); halt; end;\n if (d=20000) and (s<>'North') then begin writeln('NO'); halt; end;\n if (s='South') then d:=d+x;\n if (s='North') then d:=d-x;\n if (d>20000) and (s='South') then begin writeln('NO'); halt; end;\n if (d<0) and (s='North') then begin writeln('NO'); halt; end;\n end;\n if (d=0) then writeln('YES') else writeln('NO');\n readln;\nend."}, {"source_code": "var n,i,x,y,j:integer;\n s:string;\n t:boolean;\n f:byte;\n \nbegin\n read(n);\n for i:=1 to n do\n begin\n readln(j,s);\n s:=copy(s,2,length(s)-1);\n if s='North' then f:=1 else if s='South' then f:=2 else if s='West' then f:=3 else f:=4;\n case f of\n 1: if (y-j>=0) then y:=y-j else t:=true;\n 2: if (y+j<=20000) then y:=y+j else t:=true;\n 3: if (y<>0) and (y<>20000) then x:=x-j else t:=true;\n 4: if (y<>0) and (y<>20000) then x:=x+j else t:=true;\n end;\n end;\n if t or (y<>0) then write('NO') else write('YES');\nend."}, {"source_code": "var k,a,n,i,t:longint;\n dis:string;\nbegin\nread(n);\na:=0;\nk:=0;\nfor i:=1 to n do\n begin\n read(t,dis);\n delete(dis,1,1);\n if ((a+t>20000) and (dis='South')) or ((a-t<0) and (dis='North')) then\n begin\n k:=1;\n break;\n end else\n if ((a=0) and (dis='South')) or ((dis='South') and (a<>0) and (a<>20000)) then\n a:=a+t else\n if ((a=20000) and (dis='North')) or ((dis='North') and (a<>0) and (a<>20000)) then\n a:=a-t else\n if (a<>0) and (a<>20000) and ((dis='East') or (dis='West')) then\n a:=a else\n begin\n k:=1;\n break;\n end;\n\n end;\nif (k=0) and (a=0) then write('YES') else write('NO');\nend.\n"}, {"source_code": "const fi='';//750B.inp';\n fo='';//750B.out';\nvar n : longint;\n a,b: array[1..1000000] of longint;\nprocedure doc;\nvar i,j : longint; S: string[2];\nbegin\n assigN(input,fi);\n reseT(input);\n reaDln(n);\n for i:=1 to n do\n begin\n readln(a[i], s);\n if s[2] = 'N' then b[i]:= 1\n else if s[2] = 'S' then b[i]:=2\n else if s[2] = 'E' then b[i]:= 3\n else if s[2] = 'W' then b[i]:= 4;\n end;\nend;\nprocedure xuly;\nvar i,j : longint; s: longint;\nbegin\n S:=0;\n for i:=1 to n do\n begin\n if (s = 20000) and ( b[i] <> 1) then\n begin\n write('NO');\n exit;\n end;\n if ( s = 0 ) and ( b[i] <> 2 ) then\n begin\n write('NO');\n exit;\n end;\n if b[i] =2 then s:= s + a[i]\n else if b[i] =1 then s:= s- a[i];\n if ( s > 20000 ) then\n begin\n write('NO');\n exit;\n end;\n if ( s < 0 ) then\n begin\n write('NO');\n exit;\n end;\n end;\n if s= 0 then write('YES') else write('NO');\nend;\nbegin\n doc;\n xuly;\n\n end.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar x, i, n, vt: longint;\n s: string;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n vt:=0;\n for i:=1 to n do\n begin\n readln(x,c,s);\n if s = 'South' then\n begin\n vt:=vt+x;\n if vt > 20000 then\n begin\n writeln('NO');\n halt;\n end;\n end\n else if s = 'North' then\n begin\n vt:=vt- x;\n if vt < 0 then\n begin\n writeln('NO');\n halt;\n end;\n end\n else if (s = 'West') or (s = 'East') then\n begin\n if (vt = 0) or (vt = 20000) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n if vt <> 0 then write('NO')\n else write('YES');\n\n close(input); close(output);\nend.\n"}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000007;\n\tmaxN=107;\ntype\n data=record\n dis,dir:longint;\n end;\nvar\n n:longint;\n a:array [0..maxN] of data;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nfunction cal(pos:longint):boolean;\nvar\n now:longint;\n i,x,y,tg:longint;\nbegin\n now:=1;\n x:=0;\n for i:=1 to n do\n begin\n if (x=0) and (a[i].dir<>4) then exit(false);\n if (x=20000) and (a[i].dir<>1) then exit(false);\n if (a[i].dir=1) or (a[i].dir=4) then\n with a[i] do\n begin\n tg:=x;\n if dir = 1 then\n begin\n tg:=tg-a[i].dis;\n if tg<0 then exit(false);\n end\n else\n begin\n tg:=tg+a[i].dis;\n if tg>20000 then exit(false);\n end;\n x:=tg;\n now:=dir;\n end;\n\n end;\n if (x=0) and (now=1) then exit(true);\n exit(false);\nend;\n\nProcedure Nhap;\nvar\n i:longint;\n s:ansistring;\nBegin\n readln(n);\n for i:=1 to n do\n with a[i] do\n begin\n readln(dis,s);\n if s=' North' then a[i].dir:=1;\n if s=' East' then a[i].dir:=2;\n if s=' West' then a[i].dir:=3;\n if s=' South' then a[i].dir:=4;\n\n end;\n if cal(5-a[1].dir) then writeln('YES')\n else writeln('NO');\nEnd;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nProcedure Solve;\nbegin\n\tNhap;\n\tXuli;\n\tXuat;\nend;\nBEGIN\n\tOpenf;\n\tSolve;\n\tClosef;\nEND.\n\n\n"}, {"source_code": "var n,i,tek,nn,j,x,code:longint;\n s:string;\nbegin\n readln(nn);\n tek:=0;\n for i:=1 to nn do\n begin\n readln(s);\n n:=0;\n for j:=1 to length(s) do\n begin\n val(s[j],x,code);\n if code>0\n then begin delete(s,1,j);break;end\n else begin n:=n*10+x;end;\n end;\n if (s='North')and(tek20000)\n then begin write('NO');halt;end;\n if ((s='West')or(s='East'))and((tek=0)or(tek=20000))\n then begin write('NO');halt;end;\n\n if s='North'\n then dec(tek,n);\n if s='South'\n then inc(tek,n);\n\n\n end;\n if tek=0\n then write('YES')\n else write('NO');\n\n\n\nend."}, {"source_code": "var n,f,i,a : longint;\n c : char;\nbegin\n readln(n); f:=0;\n for i:=1 to n do begin\n readln(a,c,c);\n if (f = 0) and (c <> 'S') then begin writeln('NO'); halt; end;\n if (f = 20000) and (c <> 'N') then begin writeln('NO'); halt; end;\n if c = 'S' then inc(f,a);\n if c = 'N' then dec(f,a);\n if f < 0 then begin writeln('NO'); halt; end;\n if f > 20000 then begin writeln('NO'); halt; end;\n end;\n if f <> 0 then begin writeln('NO'); halt; end;\n writeln('YES');\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "uses math;\n\nvar n,k:longint;\n\nprocedure mofile;\nbegin\n assign(input,'test.inp');\n assign(output,'test.out');\n reset(input);\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure doc;\nbegin\n readln(n);\nend;\n\nprocedure xuly;\nvar i,t:longint;\n z,x:char;\nbegin\n k:=0;\n for i:=1 to n do\n begin\n readln(t,x,z);\n if (k=0)and(z<>'S') then\n begin\n write('NO');\n halt;\n end;\n if (k=20000)and(z<>'N') then\n begin\n write('NO');\n halt;\n end;\n if z='S' then k:=k+t;\n if k>20000 then\n begin\n write('NO');\n halt;\n end;\n if z='N' then k:=k-t;\n if k<0 then\n begin\n write('NO');\n halt;\n end;\n end;\n if k=0 then write('YES') else write('NO');\nend;\n\nBEGIN\n \n doc;\n xuly;\n \nEND.\n\n"}, {"source_code": "{$Mode objfpc}\n\nvar\n n,i,j,o:integer;\n s:ansistring;\n w:integer;\n\nprocedure dung;\n begin\n write('NO');\n halt;\n end;\n\nbegin\n readln(n);\n o:=0;\n for i:=1 to n do\n begin\n readln(s);\n w:=0;\n for j:=1 to length(s) do\n if s[j] = ' ' then break\n else w:=w*10 + ord(s[j])-48;\n if s[j+1] = 'W' then\n if (o = 0) or (o = 20000) then dung;\n if s[j+1] = 'E' then\n if (o = 0) or (o = 20000) then dung;\n if s[j+1] = 'W' then continue;\n if s[j+1] = 'E' then continue;\n if s[j+1] = 'S' then\n begin\n o:=o + w;\n if (o > 20000) or (o < 0) then dung;\n end;\n if s[j+1] = 'N' then\n begin\n o:=o - w;\n if (o > 20000) or (o < 0) then dung;\n end;\n end;\n if o <> 0 then dung;\n write('YES');\nend."}, {"source_code": "{$IFDEF ONLINE_JUDGE}\n{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n{$ENDIF}\n\nuses math;\n\nprocedure mofile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ELSE}\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ENDIF}\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n:longint;\n ok:boolean;\n\nprocedure xuli;\nvar\n i,xx,x:longint;\n s:ansistring;\nbegin\n readln(N);\n xx:=0;\n ok:=true;\n for i:=1 to n do\n begin\n readln(x,s);\n if s=' North' then xx:=xx-x else\n if s=' South' then xx:=xx+x else\n if (xx=0) or (xx=20000) then ok:=false;\n if (xx<0) or (xx>20000) then ok:=false;\n end;\n ok:=ok and (xx=0);\n if ok then writeln('YES') else writeln('NO');\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar n,k,so,no,mark:longint;\n f,g:text;\n kt:boolean;\n s:string;\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n);\n kt:=false;\n for i:=1 to n do\n begin\n readln(f,k,s);\n if (so=0) and (s<>' South') then kt:=true;\n if (so=20000) and (s<>' North') then kt:=true;\n if s=' South' then\n so:=so+k\n else\n if s=' North' then\n so:=so-k;\n if (so<0) or (so>20000) then kt:=true;\n end;\n close(f);\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n assign(g,fo);\n rewrite(G);\n if (kt=false) and (so=0) then write(g,'YES') else write(g,'NO');\n close(g);\nend;\nbegin\n nhap;\n xuli;\nend."}, {"source_code": "var xcoors,ycoors,i,n,coors:longint;\n\tsatisfied:boolean;\n\tdirection:String;\nBegin\n\tReadln(n);\n\tsatisfied:=True;\n\txcoors:=0;\n\tycoors:=0;\n\tFor i:=1 to n do\n\t\tBegin\n\t\t\tReadln(coors,direction);\n\t\t\tWhile pos(' ',direction)>0 do Delete(direction,pos(' ',direction),1);\n\t\t\tIf (direction='North') then\tdec(ycoors,coors)\n\t\t\tElse if (direction='South') then inc(ycoors,coors)\n\t\t\tElse\n\t\t\t\tIf (ycoors mod 20000=0) then \n\t\t\t\t\tBegin\n\t\t\t\t\t\tsatisfied:=False;\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tEnd;\n\t\t\tIf (ycoors<0) or (ycoors>20000) then\n\t\t\t\tBegin\n\t\t\t\t\tsatisfied:=False;\n\t\t\t\t\tbreak;\n\t\t\t\tEnd;\n\t\tEnd;\n\tIf (ycoors<>0) then satisfied:=False;\n\tIf (satisfied) then Write('YES')\n\tElse Write('NO');\nEnd."}, {"source_code": "uses math;\nconst fin='goodbye2016pB.INP';\n fon='goodbye2016pB.OUT';\n maxn=57;\nvar fi,fo:text;\n x,n:longint;\n vt:string;\n t:array[1..maxn] of longint;\n d:array[1..maxn] of string;\nprocedure nhap;\n var i:longint;\n x:char;\n begin\n readln(fi,n);\n for i:=1 to n do\n readln(fi,t[i],x,d[i]);\n end;\nprocedure inkq(s:string);\n begin\n writeln(Fo,s);\n close(fo);\n halt;\n end;\nfunction ktra(x:longint):string;\n begin\n x:=abs(x);\n if x=0 then exit('North');\n if x=20000 then exit('South');\n exit('Middle');\n end;\nprocedure xuly;\n var i:longint;\n begin\n vt:='North';\n for i:=1 to n do\n begin\n if d[i]='South' then\n begin\n if vt='South' then inkq('NO');\n if x+t[i]>20000 then inkq('NO');\n x:=x+t[i];\n vt:=ktra(x);\n end;\n if d[i]='North' then\n begin\n if vt='North' then inkq('NO');\n if x-t[i]<0 then inkq('NO');\n x:=x-t[i];\n vt:=ktra(x);\n end;\n if d[i]='East' then\n begin\n if (vt='North') or (vt='South') then inkq('NO');\n end;\n if d[i]='West' then\n begin\n if (vt='North') or (vt='South') then inkq('NO');\n end;\n end;\n if ktra(x)='North' then inkq('YES') else inkq('NO');\n end;\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n nhap;\n xuly;\n close(fi); close(fo);\nend.\n"}, {"source_code": "var\n n,now,p,i,d:longint;\n st:string;\n flag:boolean;\nbegin\n readln(n);\n now:=0;flag:=true;\n for i:=1 to n do\n begin\n readln(st);\n p:=pos(' ',st);\n val(copy(st,1,p-1),d);\n case st[p+1] of\n 'S':\n begin\n inc(now,d);\n if now>20000\n then flag:=false;\n end;\n 'N':\n begin\n dec(now,d);\n if now<0\n then flag:=false;\n end;\n 'E':if (now=0)or(now=20000) then flag:=false;\n 'W':if (now=0)or(now=20000) then flag:=false;\n end;\n end;\n if now<>0\n then flag:=false;\n if flag\n then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n i,j,k,x,n,len:longint;\n c:char;\nbegin\n readln(n);\n x:=0;\n for i:=1 to n do\n begin\n read(len);\n read(c);\n read(c);\n readln;\n if c='S' then\n begin\n x:=x+len;\n if x>20000 then\n begin\n writeln('NO');\n exit;\n end;\n continue;\n end;\n if c='N' then\n begin\n x:=x-len;\n if x<0 then\n begin\n writeln('NO');\n exit;\n end;\n continue;\n end;\n if ((c='E') or (c='W')) and ((x=0) or (x=20000)) then\n begin\n writeln('NO');\n exit;\n end;\n end;\n if x=0 then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "program sv;\nvar i,j,n,k,d,h,t,y:longint;\ns,w:string;\nprocedure stop;\nbegin\nwrite('NO');\nhalt;\nend;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nreadln(n);\ny:=0;\nfor i:= 1 to n do\n begin\n if (y<0) or (y>20000) then stop;\n readln(s);\n t:=pos(' ',s);\n w:=copy(s,1,t-1);\n val(w,d,h);\n if s[t+1]='N' then y:=y-d else\n if s[t+1]='S' then y:=y+d else\n if (y=0) and (s[t+1]<>'S') then stop else\n if (y=20000) and (s[t+1]<>'N') then stop;\n //writeln(d);\n end;\nif y=0 then write('YES') else stop;\nend."}, {"source_code": "var a:array[1..50] of string[6];\n b:array[1..50] of longint;\n i,s,n:longint;\n data:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nreadln(b[i],a[i]);\nif ((b[i]>20000)and(a[i]=' North')) or ((b[i]>20000)and(a[i]=' South'))then data:=true\nend;\ns:=0;\nfor i:=1 to n do begin\nif (s<0)or(s>20000) then begin data:=true; break end;\nif a[i]=\n' South' then begin\n if s=20000 then begin data:= true; break end;\n inc(s,b[i]);\n end;\n if a[i]=\n' North' then begin\n if s=0 then begin data:= true; break end;\n dec(s,b[i]);\n end;\n if a[i]=\n' West' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\n if a[i]=\n' East' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\nend;\n//if (s=0)and(r<>0) then data:=true;\nif s<>0 then data:=true;\nif data then writeln('NO')\n else writeln('YES')\nend.\n"}, {"source_code": "var\n s,t:string;\n n,m,i,k,j,f,c,x,y,z,q,w:longint;\n p:integer;\nbegin\n w:=10000;\n t:='YES';\n readln(n);\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),f,p);\n s:=s[pos(' ',s)+1];\n if(s='W')or(s='E')then f:=0 else\n if s='S'then f:=-f;\n if((s='W')or(s='E'))and(abs(w)=10000)then t:='NO';\n if(w=10000)and(s<>'S')then t:='NO';\n if(w=-10000)and(s<>'N')then t:='NO';\n inc(w,f);\n if abs(w)>10000 then t:='NO';\n end;\n if w<>10000 then t:='NO';\n writeln(t);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var s:String;\n n,q,i,t:LongInt;\nBegin\n readln(n);\n q:=0;\n for i:=1 to n Do\n Begin\n readln(t,s);\n if (q=0) and (s[2]<>'S')\n then begin\n write('NO');\n Exit;\n end;\n if (q=20000) and (s[2]<>'N')\n then Begin\n write('NO');\n Exit;\n end;\n if s[2]='N'\n then Begin\n if q-t<0\n then Begin\n write('NO');\n Exit;\n end; \n q:=q-t;\n end;\n if s[2]='S'\n then Begin\n if q+t>20000\n then Begin\n write('NO');\n Exit;\n end; \n q:=q+t;\n end;\n end;\n\n if q=0\n then write('YES')\n else write('NO');\nEnd.\n"}, {"source_code": "var i,j,m,n,now:longint;\n s:string;\nbegin\n readln(n);\n now:=20000;\n for i:=1 to n do begin\n read(m);\n readln(s);\n if s=' South' then begin\n now:=now-m;\n if now<0 then begin\n writeln('NO');\n halt;\n end;\n end else if s=' North' then begin\n now:=now+m;\n if now>20000 then begin\n writeln('NO');\n halt;\n end;\n end else begin\n if (now=0) or (now=20000) then begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n if now=20000 then writeln('YES') else writeln('NO');\n //writeln(s);\nend."}, {"source_code": "var n,res:byte;\n t:array[0..50] of longint;\n dir:array[0..50] of string;\n\nprocedure solve;\nvar NS:longint; i:byte;\nbegin\n NS:=0; res:=1;\n for i:=1 to n do\n begin\n if dir[i]=' North' then\n begin\n if NS=0 then begin res:=0; break; end;\n if t[i]>NS then begin res:=0; break; end;\n NS:=NS-t[i];\n end\n else if dir[i]=' South' then\n begin\n if NS=20000 then begin res:=0; break; end;\n if t[i]>20000-NS then begin res:=0; break; end;\n NS:=NS+t[i];\n end\n else if ((dir[i]=' West') or (dir[i]=' East')) and ((NS=0) or (NS=20000)) then begin res:=0; break; end;\n end;\n if NS<>0 then res:=0;\nend;\n\nprocedure input;\nvar i:byte; tmp:string;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(t[i],dir[i]);\n end;\nend;\n\nprocedure output;\nbegin\n if res=0 then writeln('NO') else writeln('YES');\nend;\n\nbegin\n input;\n solve;\n output;\nend."}, {"source_code": "program B750;\n\nvar\n p : Int64;\n n, i : integer;\n c : integer = 0;\n s : string;\nbegin\n read(n);\n for i := 1 to n do begin\n readln(p, s);\n if ((c = 0) or (c = 20000)) and ((s = ' West') or (s = ' East')) then begin writeln('NO'); exit; end\n else if (c = 0) and (s = ' North') then begin writeln('NO'); exit; end\n else if (c = 20000) and (s = ' South') then begin writeln('NO'); exit; end\n else if (s = ' North') and (p > c) then begin writeln('NO'); exit; end\n else if (s = ' South') and (p + c > 20000) then begin writeln('NO'); exit; end\n else if s = ' North' then c := c - p\n else if s = ' South' then c := c + p\n end;\n if c <> 0 then writeln('NO') else writeln('YES');\nend."}, {"source_code": "var\n a,m,j,i,n,g,posi : longint;\n s,tempat,s1,ch : string;\n b : boolean;\nbegin\n tempat:='South';\n posi:=0;\n readln(n);\n ch:=' ';\n //readln(s1);\n //writeln(pos(ch,s1));\n b:=true;\n for i:= 1 to n do\n begin\n readln(a,s1);\n m:=pos(ch,s1);\n s:=copy(s1,m+1,length(s1)-m+1);\n //writeln(s);\n if b then\n begin\n if posi=0 then\n begin\n //writeln('#1');\n if (tempat=s) then\n begin\n posi:=posi+a;\n if posi=20000 then\n begin\n if tempat='South' then\n tempat:='North'\n else\n tempat:='South';\n posi:=0;\n end\n else\n if posi>20000 then\n b:=false;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);\n end\n else\n b:=false;\n end\n else\n begin\n //writeln('#2');\n if tempat=s then\n begin\n posi:=posi+a;\n if posi=20000 then\n begin\n if tempat='North' then\n tempat:='South'\n else\n tempat:='North';\n posi:=0;\n end\n else\n if (posi>20000) or (posi<0) then\n b:=false;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);\n end\n else\n if (tempat<>s) and ((s<>'West') and (s<>'East')) then\n begin\n posi:=posi-a;\n if (posi<0) then\n b:=false;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);;\n end;\n end;\n end;\n end;\n //writeln(b);\n if not b then\n writeln('NO')\n else\n if (tempat='South') and (posi=0) then\n writeln('YES')\n else\n writeln('NO');\nend.\n"}, {"source_code": "Program cf1;\nVar\n north,south,i,j,k,nums,code:longint;\n sn,s,test:string;\n fl:boolean;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n readln(k);\n\n south:=20000; north:=0; fl:=false;\n\n for i:=1 to k do Begin\n readln(s);\n nums:=0;\n sn:='';\n j:=1;\n while (s[j] <> ' ') do Begin\n sn:=sn + s[j];\n inc(j);\n End;\n val(sn,nums,code);\n test:=copy(s,j+1,length(s)-j);\n\n if (nums > south) and (test = 'South') then Begin\n fl:=true;\n break;\n End;\n\n if (nums > north) and (test = 'North') then Begin\n fl:=true;\n break;\n End;\n\n nums:=nums mod 40000;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (test <> 'South') then Begin\n fl:=true;\n break;\n End;\n\n if ((south = 0) or (south = 40000) or (north = 20000)) and (test <> 'North') then Begin\n fl:=true;\n break;\n End;\n\n if (test = 'South') then Begin\n dec(south,nums);\n inc(north,nums);\n End else if (test = 'North') then Begin\n dec(north,nums);\n inc(south,nums);\n End;\n End;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (fl = false) then write('YES') else write('NO');\nEnd.\n"}, {"source_code": "var s,n:longint; kq:string[3];\nprocedure Nhap;\nvar x,i:longint; y:string[6];\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n if ((s=10000) or (s=-10000)) and ((y=' East') or (y=' West')) then exit;\n if y=' North' then\n inc(s,x)\n else if y=' South' then\n dec(s,x);\n if (s>10000) or (s<-10000) then\n exit;\n end;\n if s=10000 then\n kq:='YES';\nend;\nprocedure Xuat;\nbegin\n write(kq);\nend;\nbegin\n kq:='NO';\n s:=10000;\n Nhap;\n Xuat;\nend.\n"}, {"source_code": "USES Math;\nCONST\n tfi = '';\n tfo = '';\nVAR\n fi,fo : text;\n\nProcedure process;\n Var\n n,tmp,cnt,i,j: longint;\n s,p\n : string;\n Begin\n Readln(fi,n);\n tmp:=0;\n For i:=1 to n do\n begin\n readln(fi,s);\n If s[length(s)]=' ' then delete(s,length(s),1);\n cnt:=0;\n j:=1;\n While s[j]<>' ' do\n begin\n cnt:=cnt*10+ord(s[j])-48;\n inc(j);\n end;\n p:=copy(s,j+1,length(s)-j);\n If ((tmp=0) and (p<>'South')) or ((tmp=20000) and (p<>'North')) then\n begin\n write(fo,'NO');\n exit;\n end;\n If p='North' then dec(tmp,cnt)\n else if p='South' then inc(tmp,cnt);\n If (tmp<0) or (tmp>20000) then\n begin\n write(fo,'NO');\n exit;\n end;\n end;\n If tmp=0 then write(fo,'YES')\n else write(fo,'NO');\n End;\n\nBEGIN\n assign(fi,tfi); reset(fi);\n assign(fo,tfo); rewrite(fo);\n process;\n close(fi); close(fo);\nEND.\n\n"}, {"source_code": "const fi='ny_npole.inp';\n fo='ny_npole.out';\nvar n: longint;\nfunction tinh: boolean;\n var i, np, t: longint;\n s: string;\n begin\n np:=0;\n for i:=1 to n do\n begin\n read(t); readln(s);\n if s[1]=' ' then delete(s,1,1);\n {case s of}\n if s='North' then\n begin\n if np=0 then exit(false)\n else if t>np then exit(false)\n else if np-t<0 then exit(false)\n else np:=np-t;\n end\n else if s='South' then\n begin\n if np=20000 then exit(false)\n else if t>(20000-np) then exit(false)\n else if t+np>20000 then exit(false)\n else np:=np+t;\n end\n else if (np=0) or (np=20000) then exit(false);\n end;\n if np=0 then exit(true)\n else exit(false);\n end;\nbegin\n //assign(input, fi); reset(input);\n //assign(output, fo); rewrite(output);\n readln(n);\n if tinh then writeln('YES')\n else writeln('NO');\n //close(input); close(output);\nend."}, {"source_code": "{$H+}\nvar st,s,huong:string; n:longint;\nprocedure nhap;\nvar i,tt,j,point:longint; x:longint;\nbegin\n readln(n); point:=0;\n for i:=1 to n do\n begin\n readln(st);\n s:=''; tt:=0; x:=0;\n for j:=1 to length(st) do\n if st[j]=' ' then\n begin\n val(s,x);\n tt:=j;\n break;\n end\n else s:=s+st[j];\n inc(tt); huong:='';\n while (st[tt]<>' ') do\n begin\n huong:=huong+st[tt];\n inc(tt);\n if tt>length(st) then break;\n end;\n if (point<0) or (point>20000) then\n begin\n write('NO');\n exit;\n end\n else\n if (point=0) then\n begin\n if huong='South' then point:=point+x\n else\n begin\n write('NO');\n exit;\n end;\n end\n else\n if (point=20000) then\n begin\n if huong='North' then point:=point-x\n else\n begin\n write('NO');\n exit;\n end;\n end\n else\n begin\n if huong='South' then point:=point+x;\n if huong='North' then point:=point-x;\n end;\n end;\n if (point=0) then write('YES')\n else write('NO');\nend;\nbegin\n //assign(input,'b750.inp');reset(input);\n nhap;\n //close(input);\nend."}, {"source_code": "var n : longint;\n x, y: array[0..1000000] of longint;\n i,j,s : longint; Ss: string[2];// s : string;\nbegin\n reaD(n);\n for i:=1 to n do\n begin\n readln;\n read(x[i], ss);\n if ss[2] = 'N' then y[i]:= 1;\n if ss[2] = 'S' then y[i]:= 2;\n if ss[2] = 'E' then y[i]:= 3;\n if ss[2] = 'W' then y[i]:= 4;\n end;\n S:=0;\n for i:=1 to n do\n begin\n if (s = 20000) and ( y[i] <> 1) then\n begin\n write('NO');\n exit;\n end;\n if ( s = 0 ) and ( y[i] <> 2 ) then\n begin\n write('NO');\n exit;\n end;\n if y[i] =2 then s:= s + x[i]\n else if y[i] =1 then s:= s- x[i];\n if ( s > 20000 ) then\n begin\n write('NO');\n exit;\n end;\n if ( s < 0 ) then\n begin\n write('NO');\n exit;\n end;\n end;\n if s= 0 then write('YES') else write('NO');\nend.\n"}, {"source_code": "var\n x,xx,y,n,_,yy : longint;\n s : ansistring;\n fk : boolean;\n\nbegin\n fk:=false;\n readln(n); x:=20000;\n while n > 0 do begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),xx,_);\n delete(s,1,pos(' ',s));\n if s = 'South' then begin\n x:=x+xx;\n if x > 40000 then fk:=true;\n end;\n if s = 'East' then begin\n if (x = 20000) or (x = 40000) then fk:=true;\n end;\n if s = 'North' then begin\n x:=x-xx;\n if x < 20000 then fk:=true;\n end;\n if s = 'West' then begin\n if (x = 20000) or (x = 40000) then fk:=true;\n end;\n dec(n);\n end;\n if (x = 20000) and (not fk) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var n,i,a,s,l:longint;\n s1:string;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(l);\nreadln(s1);\n//write(s1[1]);\nif s1[2]='N' then dec(s,l);\nif s1[2]='S' then inc(s,l);\nif ((s1[2]='W') or (s1[2]='E')) and ((s=0) or (s=20000)) then begin write('NO'); halt; end;\nif (s<0) or (s>20000) then begin write('NO'); halt; end;\nend;\nif s=0 then write('YES') else write('NO');\nend."}, {"source_code": "var st,a,c:string;\nn,i,x,w,s,p:longint;\nb:array[1..60] of string;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(st);\n b[i]:=st;\n end;\n w:=1;\n for i:=1 to n do\n begin\n st:=b[i];\n p:=pos(' ',st);\n a:=copy(st,1,p-1);\n val(a,x);\n c:=st[p+1];\n if c='S' then begin\n if w<>3 then s:=s+x\n else begin\n writeln('NO');\n halt;\n end;\n if s>20000 then begin\n writeln('NO');\n halt;\n end;\n if s=20000 then begin\n w:=3;\n end\n else w:=2;\n end\n else if c='N' then begin\n if w<>1 then s:=s-x\n else begin\n writeln('NO');\n halt;\n end;\n if s<0 then begin\n writeln('NO');\n halt;\n end;\n if s=0 then w:=1\n else w:=2;\n end\n else begin\n if w<>2 then begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n if s=0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "Var\n n:longint;\n ok:boolean;\nProcedure Enter;\nVar\n n,i,d,x,y:longint;\n way:String;\nBegin\n readln(n);\n ok:=true;\n x:=0;y:=10000;\n For i:=1 to n do\n Begin\n readln(d,way);\n delete(Way,1,1);\n if way='South' then\n Begin\n y:=y-d;\n if y<-10000 then\n Begin\n ok:=false;\n break;\n End;\n End\n else\n if way='East' then\n Begin\n if abs(y)=10000 then\n Begin\n ok:=false;\n break;\n End;\n x:=x+d;\n x:=x mod 40000;\n End\n else\n if way='North' then\n Begin\n y:=y+d;\n if y>10000 then\n Begin\n ok:=false;\n break;\n End;\n End\n else\n if way='West' then\n Begin\n if abs(y)=10000 then\n Begin\n ok:=false;\n break;\n End;\n x:=x-d;\n x:=x mod 40000;\n End;\n End;\n if ( ok) and (y=10000) then writeln('YES') else writeln('NO');\nEnd;\n\nBegin\n Enter;\nEnd."}, {"source_code": "program q;\nvar n, m,count, i: longint;\nf : boolean;\ns : string;\nbegin\n\tcount := 0;\n f := true;\n readln(n);\n for i := 1 to n do\n begin\n read(m, s);\n\n if s =' North' then begin\n \tif count = 0 then f := false;\n\n \tcount := count - m;\n \tif count < 0 then f := false;\n end;\n if s = ' South'then begin\n \tif count = 20000 then f := false;\n \tcount := count + m;\n\n \tif count > 20000 then f := false;\n end;\n if s =' West' then begin\n if count = 0 then f := false;\n if count = 20000 then f := false;\n\n end;\n if s =' East'then begin\n \tif count = 0 then f := false;\n \tif count = 20000 then f := false;\n\n end;\n end;\n\n if f = true then\n begin\n if count = 0 then write('YES')\n else write('NO');\n end\n else write('NO');\n\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,pos:longint; s:string;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\npos:=0;\nfor i:=1 to n do\n begin\n readln(a,s);\n if ((pos=0) or (pos=20000)) and (a>20000) then begin write('NO'); exit; end;\n if (s=' East') or (s=' West') then if (pos=0) or (pos=20000) then begin write('NO'); exit; end;\n if s=' North' then if (pos=0) or (a>pos) then begin write('NO'); exit; end else pos:=pos-a;\n if s=' South' then if (pos=20000) or (a>20000-pos) then begin write('NO'); exit; end else pos:=pos+a;\n end;\nif pos<>0 then write('NO') else\nwriteln('YES');\nend.\n"}, {"source_code": "var\ni,n:integer;\n\na:array [1..50] of integer;\nb:array [1..50] of string;\nc:char;\n\nx,y:integer;\n\ng:byte;\nbegin\nread(n);\n\nx:=0; y:=0;\ng:=0;\n\nfor i:=1 to n do begin\nread(a[i]); read(c); read(b[i]);\nend;\n\n\nfor i:=1 to n do begin\n\n\nif (x=0) and (b[i]<>'South') then g:=1;\n\nif (x=20000) and (b[i]<>'North') then g:=1;\n\nif b[i]='North' then dec(x,a[i]);\nif b[i]='South' then inc(x,a[i]);\nif b[i]='West' then dec(y,a[i]);\nif b[i]='East' then inc(y,a[i]);\n\nif x<0 then g:=1;\nif x>20000 then g:=1;\n\nif (i=n)and(x<>0) then g:=1;\nend;\n\n\nif g=1 then writeln('NO') else writeln('YES'); \n\n\nend."}, {"source_code": "var n,i,j,put,vert,f:integer; \n s,napr:string; \nbegin \nread(n); f:=0; vert:=0;\nfor i:=1 to n do begin \n read(put,napr); \n delete(napr,1,1);\n if (put>20000) and (napr<>'East') and (napr<>'West') then f:=1;\n if (vert=20000) and (napr<>'North') then f:=1;\n if (vert=0) and (napr<>'South') then f:=1; \n if napr='South' then vert:=vert+put;\n if vert>20000 then f:=1;\n if napr='North' then vert:=vert-put;\n if vert<0 then f:=1;\n if f=1 then break;\nend;\nif vert<>0 then f:=1;\nif f=1 then write('NO') else write('YES');\nend. "}, {"source_code": "var r:boolean;\nn,ns,t,i:longint;\ndir:string;\nbegin\nreadln(n);\nr:=true;\nfor i:=1 to n do\n begin\n readln(t,dir);\n if ns=0 then\n if dir<>' South' then r:=False;\n if ns=20000 then\n if dir<>' North' then r:=False;\n if dir=' South' then\n ns:=ns+t;\n if dir=' North' then\n ns:=ns-t;\n if ns>20000 then\n r:=false;\n if ns<0 then\n r:=false;\n end;\nif ns<>0 then r:=False;\nif r=false then write('NO')\n else write('YES');\nend.\n"}, {"source_code": "var\n n,i,p,t:longint;\n d:string;\nbegin\n read(n);\n for i:=1 to n do\n begin\n readln(t,d);\n if d[2] in ['E','W']\n then if (p=0) or (p=20000)\n then begin writeln('NO');halt;end\n else continue;\n if d[2]='S' then inc(p,t) else dec(p,t);\n if (p<0) or (p>20000)\n then begin writeln('NO');halt;end;\n end;\n if p=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Program z2;\nvar\n n,k,m,t,v:integer;\n i,j:integer;\n f:boolean;\n s,mt:string;\nbegin\n readln(n);\n f:=true;\n k:=0;\n for i:=1 to n do begin\n readln(s);\n if f=true then\n if s[length(s)]='h' then begin\n mt:=copy(s,1,length(s)-6);\n t:=length(mt);\n v:=1;\n m:=0;\n for j:=t downto 1 do begin\n m:=m+(ord(mt[j])-48)*v;\n v:=v*10;\n end;\n if s[length(s)-2]='r' then m:=-m;\n if ((k+m)<0)OR((k+m)>20000)OR((k=0)AND(m<0))OR((k=20000)AND(m>0)) then f:=false;\n k:=k+m;\n end else if (k=0)OR(k=20000) then f:=false;\n end;\n if k<>0 then f:=false;\n if f=false then write('NO') else write('YES');\nend."}, {"source_code": " const eps=0.00000001; besk=200000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n oldnapgor,oldnapver,napgor,napver,dist,xmin,xmax,ymin,ymax,napx,napy,time,pp,jj,step, t1,ii,i,tt,j:longint;\n aa,bb,cc:double;\n d,k,x,y,aold,b,a:array[-10..10000002] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n zam:array[-10..300,-10..300] of boolean;\n ss, ss1,ss2:array[-1000..1000000] of string;\n zan,fl:array[-10000..600000] of boolean;\n sss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n oldflag,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n for i:=1 to n do begin read(a[i]);read(ch);readln(ss[i]); end;\n { for i:=1 to n do write(ss[i]);\n }\n\n flag:=true;\n if ss[1]<>'South' then flag:=false;\n for i:=1 to n do\n begin\n { writeln('step= ',i,' ',flag);\n } if (ss[i]='North')or (ss[i]='South') then\n begin\n if ss[i]='North' then ot:=ot-a[i];\n if ss[i]='South' then ot:=ot+a[i];\n if (ot<0) then flag:=false;\n if (ot>20000) then flag:=false;\n if (i'South') then flag:=false;\n if (i'North') then flag:=false;\n\n end;\n if (ot<0) then flag:=false;\n if (ot>20000) then flag:=false;\n if (i'South') then flag:=false;\n if (i'North') then flag:=false;\n\n\n { writeln(i,' ',flag,' ot= ',ot);\n } end;\n if ot<>0 then flag:=false;\n if flag then write('YES') else write('NO');\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program test;\n \n{$APPTYPE CONSOLE}\n \nuses\n SysUtils;\n\nvar\n n, i, x, t: integer;\n c: char;\n s: string;\n b: boolean;\n\nbegin\n readln(n);\n x := 20000;\n b := true;\n for i := 1 to n do begin\n read(t);\n read(c);\n readln(s);\n if ((s = 'East') or (s = 'West')) and ((x = 0) or (x = 20000)) then\n b := false;\n if (s = 'North') then\n inc(x, t)\n else if (s = 'South') then\n dec(x, t);\n if (x > 20000) or (x < 0) then\n b := false;\n end;\n if (x = 20000) and (b) then\n writeln('YES')\n else\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "var aa,aa1:int64; suk:string; j,nom:longint;\na:array[1..1000] of longint;\ndddd:int64;\nd:boolean;\nbegin \n\nread(nom); \nfor j:=1 to nom do \nbegin \nread(aa); \nreadln(suk); \nif ((aa1=20000) and (suk<>' North')) or ((aa1=0) and (suk<>' South'))\n then begin writeln('NO'); exit; end; \n if suk=' North' then aa1:=aa1-aa; \nif suk=' South' then aa1:=aa1+aa; \n\n\nif (aa1>20000) or (aa1<0) then begin writeln('NO'); exit; end; \nend; \nif aa1<>0 then writeln('NO') \nelse writeln('YES'); \nend."}, {"source_code": "program Project5;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\nvar i,n,k,res,x,y:longint;\nflag:boolean;\ns:String;\nbegin\n readln(n);\n x:=0;\n y:=0;\n flag:=false;\n for i:=1 to n do\n begin\n readln(k,s);\n if (x=0) and (s<>' South') then flag:=true;\n if (x=20000) and (s<>' North') then flag:=true;\n if s=' North' then\n begin\n x:=x-k;\n if x<0 then flag:=true;\n end else\n if s=' South' then\n begin\n x:=x+k;\n if x>20000 then flag:=true;\n end;\n end;\n if x<>0 then flag:=true;\n if flag then writeln('NO') else writeln('YES');\n readln;\n readln;\nend.\n"}, {"source_code": "program zxc;\nvar n,i,o:longint;\na:array[1..50] of longint;\nb:array[1..50] of string;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i],b[i]);\no:=0;\nif b[1][2]<>'S' then begin writeln('NO'); exit; end;\nfor i:=1 to n do begin\nif (b[i][2]<>'N') and (o=-20000) then begin writeln('NO'); exit; end;\nif (b[i][2]<>'S') and (o=0) then begin writeln('NO'); exit; end;\nif (b[i][2]='S') and (o-a[i]<-20000) then begin writeln('NO'); exit; end;\nif (b[i][2]='N') and (o+a[i]>0) then begin writeln('NO'); exit; end;\nif b[i][2]='S' then o:=o-a[i];\nif b[i][2]='N' then o:=o+a[i];\nend;\nif o<>0 then begin writeln('NO'); exit; end;\nif o=0 then writeln('YES');\nend.\n\n"}, {"source_code": "program cf750B;\nvar n,i,t,km:longint;\n rez,s:string;\nbegin\nreadln(n);\nt:=0;\nrez:='YES';\nfor i:=1 to n do\n begin\n readln(km,s);\n if (t=0) and (s[2]<>'S') then\n rez:='NO';\n if (t=20000) and (s[2]<>'N') then\n rez:='NO';\n\n if (t+km>20000) and (s[2]='S') then\n rez:='NO';\n\n if (t-km<0) and (s[2]='N') then\n rez:='NO';\n\n if s[2]='S' then\n t:=t+km;\n if s[2]='N' then\n t:=t-km;\n end;\n\nif t<>0 then\n rez:='NO';\n\nwriteln(rez);\n\nend."}, {"source_code": "var\na:array [1..1000000] of integer;\ns,i,n:integer;\nnp,sp:boolean;\np: array [1..1000000] of string;\nbegin\nread (n);\nfor i:=1 to n do begin\nread (a[i]); readln (p[i]); end;\nfor i:=1 to n do begin\nif s=0 then \nif p[i]<>' South' then begin write ('NO'); exit; end;\nif s=20000 then\nif p[i]<>' North' then begin write ('NO'); exit; end;\nif p[i]=' South' then begin s:=s+a[i]; end else if p[i]=' North' then s:=s-a[i];\nif (s<0) or (s>20000) then begin write ('NO'); exit; end; \nend;\nif s<>0 then write ('NO')\nelse write ('YES');\nend."}, {"source_code": "var\n n, i, sum, v,f,f1: longint; \n s: string;\n\nbegin\n readln(n); \n for i := 1 to n do \n begin\n read(v);\n readln(s);\n if ((sum = 0) and (s <> ' South')) or ((sum = 20000) and (s <> ' North')) then \n begin \n f:=1;\n end;\n if s = ' South' then sum := sum + v; \n if s = ' North' then sum := sum - v; \n \n if (sum < 0) or (sum> 20000) then begin f1:=1; end; \n end; \n if f=1 then begin writeln('NO'); exit; end;\n if f1=1 then begin writeln('NO'); exit; end;\n if sum = 0 then writeln('YES') \n else writeln('NO'); \nend."}, {"source_code": "var n,i,a,s,l:longint;\n s1:string;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(l);\nreadln(s1);\n//write(s1[1]);\nif s1[2]='N' then dec(s,l);\nif s1[2]='S' then inc(s,l);\nif ((s1[2]='W') or (s1[2]='E')) and ((s=0) or (s=20000)) then begin write('NO'); halt; end;\nif (s<0) or (s>20000) then begin write('NO'); halt; end;\nend;\nif s=0 then write('YES') else write('NO');\nend."}, {"source_code": "program hsfdk;\nvar n,i:integer;\n td,so:longint;\n st:string;\n kt:boolean;\nbegin\n readln(n); kt:=true;\n td:=0;\n for i:=1 to n do\n begin\n readln(so,st);\n if kt=true then\n begin\n if(td=0)and(st<>' South')\n or(td=20000)and(st<>' North')then kt:=false;\n if st=' North'then td:=td-so\n else if st=' South'then td:=td+so;\n if(td<0)or(td>20000)then kt:=false;\n end;\n end;\n if td<>0 then kt:=false;\n if kt=true then write('YES')\n else write('NO');\n readln\nend."}, {"source_code": "var n,i,t: longint;\n x: longint = 0;\n dir: string;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(t); readln(dir);\n if dir=' North'\n then dec(x,t)\n else if dir=' South'\n then inc(x,t)\n else if (x=0)or(x=20000)\n then begin\n write('NO');\n exit;\n end;\n if (x<0)or(x>20000) then\n begin\n write('NO');\n exit;\n end;\n end;\n if x=0 then write('YES') else write('NO');\nend.\n"}, {"source_code": "var\n dir,len:array[1..100]of longint;\n n,now,i:longint;\n flag:boolean;\n s:string;\nbegin\n readln(n);\n now:=0;\n flag:=true;\n for i:=1 to n do\n begin\n readln(len[i],s);\n while(s[1]=' ')do\n delete(s,1,1);\n if(s[1]='S')then dir[i]:=1;\n if(s[1]='N')then dir[i]:=-1;\n if(s[1]='E')or(s[1]='W')then dir[i]:=0;\n\t if(now=0)and(dir[i]<1)then flag:=false;\n if(now=20000)and(dir[i]>-1)then flag:=false;\n\t now:=now+dir[i]*len[i];\n\t if(now<0)or(now>20000)then flag:=false;\t\n end;\n if(now<>0)then flag:=false;\n if(not flag)then writeln('NO')\n else writeln('YES');\nend.\n"}, {"source_code": "program j01;\nvar n,i:longint;\n now,x:longint;\n flag:boolean;\n s:string;\nbegin\n now:=0;\n readln(n);flag:=true;\n for i:=1 to n do\n begin\n read(x);\n readln(s);\n if (now=0)and(s[2]<>'S') then flag:=false;\n if(now=20000)and(s[2]<>'N') then flag:=false;\n if s[2]='N' then now:=now-x;\n if now<0 then flag:=false;\n if s[2]='S' then now:=now+x;\n if now>20000 then flag:=false;\n end;\n if (now=0)and flag then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Program b;\nuses sysutils;\nVar\n n,i,l:Integer;\n t:Int64;\n dir:string;\n u,d:boolean;\nbegin\n readln(n);\n d:=true;\n l:=20000;\n for i:=0 to n-1 do\n begin\n readln(t,dir);\n dir:=Trim(dir);\n if((d=true) and (dir<>'South')) then\n begin\n writeln('NO');\n exit;\n end;\n if((u=true) and (dir<>'North')) then\n begin\n writeln('NO');\n exit;\n end;\n if dir='North' then l:=l+t;\n if dir='South' then l:=l-t;\n if((l>20000) or (l<0)) then\n begin\n writeln('NO');\n exit;\n end;\n if(l=20000)then\n begin\n d:=true;\n u:=false;\n end\n else if(l=0) then\n begin\n u:=true;\n d:=false;\n end\n else\n begin\n d:=false;\n u:=false;\n end;\n end;\n if l=20000 then writeln('YES')\n else writeln('NO');\n readln;\nend.\n"}, {"source_code": "var\n n, x, y, sd, i: longint;\n s: string;\n \nprocedure sphalt;\nbegin\n writeln('NO');\n halt(0);\nend;\n \nbegin\n readln(n);\n for i := 1 to n do\n begin\n read(sd);\n readln(s);\n if (y <= 0) and (s <> ' South') then\n sphalt;\n if (y >= 20000) and (s <> ' North') then\n sphalt;\n if s = ' South' then\n inc(y, sd);\n if s = ' North' then\n dec(y, sd);\n if s = ' West' then\n inc(x, sd);\n if s = ' East' then\n dec(x, sd);\n if (y < 0) or (y > 20000) then\n sphalt;\n end;\n if (y <> 0) then\n sphalt;\n writeln('YES');\nend."}, {"source_code": "var\n n,i,p,t:longint;\n d:string;\nbegin\n read(n);\n for i:=1 to n do\n begin\n readln(t,d);\n if d[2] in ['E','W']\n then if (p=0) or (p=20000)\n then begin writeln('NO');halt;end\n else continue;\n if d[2]='S' then inc(p,t) else dec(p,t);\n if (p<0) or (p>20000)\n then begin writeln('NO');halt;end;\n end;\n if p=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var c,cs,n:integer;s:string;i:integer;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,s);\n If (s=' South')and(cs+c>20000)\n then begin writeln('NO');exit;end;\n If (s=' North')and(cs-c<0)\n then begin writeln('NO');exit;end;\n If cs=0 then if s<>' South'\n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>' North' then begin writeln('NO');exit;end;\n If (s=' South') then cs:=cs+c;\n If (s=' North') then cs:=cs-c;\n If cs > 0 then begin\n cs:=cs mod 40000;\n If cs>20000 then cs:=-cs;\n end\n else begin\n cs:=cs mod 40000;\n If cs>=-20000 then cs:=-cs;\n end;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,i,s,c:longint; t:string;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(c); readln(t);\n if ((s=0) and (t<>' South')) or ((s=20000) and (t<>' North')) then begin writeln('NO'); exit; end;\n if t=' South' then s:=s+c;\n if t=' North' then s:=s-c;\n \n if (s<0) or (s>20000) then begin writeln('NO'); exit; end;\n end;\n if s=0 then writeln('YES')\n else writeln('NO');\nend.\n"}], "negative_code": [{"source_code": "var\na:array [1..10] of integer;\ns,i,n:integer;\nnp,sp:boolean;\np: array [1..10] of string;\nbegin\nread (n);\nfor i:=1 to n do begin\nread (a[i]); readln (p[i]); end;\nfor i:=1 to n do begin\nif s=0 then \nif p[i]<>' South' then begin write ('NO'); exit; end;\nif s=20000 then\nif p[i]<>' North' then begin write ('NO'); exit; end;\nif p[i]=' South' then begin s:=s+a[i]; end else if p[i]=' North' then s:=s-a[i]; \nend;\nif s<>0 then write ('NO')\nelse write ('YES');\nend."}, {"source_code": " var t, p, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nif n=5 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend;\nif n=2 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n write (' ',p, ' ');\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (' ',p, ' ');\nend;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar f:text;\n n,x,ans,ec:longint;\n huong,dis:array[1..5000] of longint;\n ok:boolean;\n{}\nprocedure docf;\nvar st1,st2,st:string;\n i,j,u,v,er:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,n);\n for j:=1 to n do\n begin\n readln(f,st);\n while st[length(st)]=' ' do delete(st,length(st),1);\n\n i:=1; st1:='';\n while st[i] <> ' ' do begin\n st1:=st1+st[i]; inc(i); end;\n val(st1,u,er);\n inc(i); st2:='';\n while (i <= length(st)) do begin\n st2:=st2+st[i]; inc(i); end;\n\n if st2='North' then v:=0\n else if st2='South' then v:=1\n else v:=2;\n\n // if v < 2 then\n begin\n inc(ec);\n huong[ec]:=v;\n dis[ec]:=u;\n end;\n end;\nend;\n{}\nprocedure lam;\nvar i:longint;\n np,sp:boolean;\nbegin\n //North = 0 , South = 1\n ok:=false; np:=true; sp:=false;\n for i:=1 to ec do\n begin\n if np then\n begin\n if huong[i]<>1 then exit;\n inc(x, dis[i]); np:=false;\n if x > 20000 then exit;\n end\n else if sp then\n begin\n if huong[i]<>0 then exit;\n dec(x, dis[i]); sp:=false;\n if x < 0 then exit;\n end\n else begin\n if huong[i]=0 then dec(x, dis[i])\n else if huong[i]=1 then inc(x,dis[i]);\n end;\n\n if (x > 0) and (x < 20000) then begin\n np:=false; sp:=false; end\n else if (x=0) then np:=true\n else if x=20000 then sp:=true;\n end;\n\n if x=0 then ok:=true;\nend;\n{}\nprocedure xuat;\nbegin\n assign(f,fo); rewrite(f);\n if ok then writeln(f,'YES')\n else writeln(f,'NO');\n close(F);\nend;\n{}\nbegin\n docf;\n lam;\n xuat;\nend.\n"}, {"source_code": "const fi='';\n fo='';\nprocedure process;\nvar s:longint;\n l:1..40000;\n n,i:1..50;\n a:string;\n f,g:text;\nbegin\n s:=0;\n assign(f,fi);reset(F);\n assign(g,fo);rewrite(g);\n readln(F,n);\n for i:=1 to n do\n begin\n read(f,l);readln(f,a);\n delete(a,1,1);\n if (a[1]='N') then dec(s,l);\n if (a[1]='S') then inc(s,l);\n if (( (a[1]='W') or (a[1]='E') ) and ( (s=0) or (s=20000) )) or ( (s<0) and (s>20000) ) then\n begin\n writeln(g,'No');\n close(F);\n close(g);\n exit;\n end;\n end;\n if (s=0) then write(g,'Yes') else write(g,'No');\n close(F);\n close(g);\nend;\nbegin\n process;\nend.\n"}, {"source_code": "var ch,i,n,x,q,y,p,w:longint;\n f:boolean;\n s:string;\n a:array[1..100] of longint;\nbegin\n readln(n);\n x:=0;\n y:=0;\n p:=0;\n f:=true;\n for i:=1 to n do\n begin\n readln(s);\n val(s,ch,q);\n w:=q;\n val(copy(s,1,q-1),ch,q);\n s:=copy(s,w+1,length(s)-w);\n if (p=2)and(s[1]<>'N') then\n f:=false;\n if (p=1)and(s[1]<>'S') then\n f:=false;\n p:=0;\n a[i]:=ch;\n case s[1] of\n 'N': dec(y,ch);\n 'E': dec(x,ch);\n 'S': inc(y,ch);\n 'W': inc(x,ch);\n end;\n x:=abs(x mod 40001);\n if y<0 then\n f:=false;\n if (y<=0) then\n p:=1;\n if (y>=20000) then\n p:=2;\n\n end;\n if y<>0 then\n f:=false;\n if f then\n writeln('YES') else\n writeln('NO');\nend.\n"}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\ni:=1;\nwhile ((i<=n)and(flag=1)) do begin\n readln(t,dir);\n // writeln(pos('North',dir),' ',dir);\n if ((pos('South',dir)=0)and(y=0)) then flag:=-1\n else if ((pos('North',dir)=0)and(y=20000)) then flag:=-1\n else if (pos('South',dir)>0)or(pos('North',dir)>0) then begin\n if pos('South',dir)>0 then y:=y+t;\n if pos('North',dir)>0 then y:=y-t;\n while ((y<0)or(y>20000)) do begin\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n if y>20000 then y:=20000-(y-20000);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n end;\n end;\n i:=i+1;\n // writeln(i,' ',y,' ',flag);\nend;\nif ((abs(y) mod 40000)<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": " var t, p, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "const fi='';//750B.inp';\n fo='';//750B.out';\n\nvar n:longint;\n\nprocedure doc;\n var i,k,d,x:longint;\n s:string;\n begin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(n);\n d:=0;\n for i:=1 to n do\n begin\n read(x); readln(s);\n if s[2]='N' then k:=1;\n if s[2]='E' then k:=2;\n if s[2]='S' then k:=3;\n if s[2]='W' then k:=4;\n if ((d=0) or (d=12000)) and ((k=2) or (k=4)) then\n begin write('NO'); exit; end;\n if (d=0) and (k=1) then\n begin write('NO'); exit; end;\n if (d=12000) and (k=3) then\n begin write('NO'); exit; end;\n if k=2 then continue;\n if k=4 then continue;\n if k=1 then\n begin\n if x >= d then d:=0 else d:=d-x;\n continue;\n end;\n if k=3 then\n begin\n if x + d >= 12000 then d:=12000 else d:=x+d;\n end;\n end;\n if d=0 then write('YES') else write('NO');\n end;\n\nBEGIN\n DOC;\nEND.\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar n,k,so,no,mark:longint;\n f,g:text;\n kt:boolean;\n s:string;\nprocedure nhap;\nvar i:longint;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n);\n kt:=false;\n for i:=1 to n do\n begin\n readln(f,k,s);\n if s=' South' then\n so:=so+k\n else\n if s=' North' then\n so:=so-k;\n if (so<0) or (so>20000) then kt:=true;\n end;\n close(f);\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n assign(g,fo);\n rewrite(G);\n if (kt=false) then write(g,'YES') else write(g,'NO');\n close(g);\nend;\nbegin\n nhap;\n xuli;\nend.\n"}, {"source_code": "var i,c,cs,n:integer;s:string;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,s);\n If ((s=' South')or(s=' North'))and(c>20000)then begin writeln('NO');exit;end;\n If cs=0 then if s<>' South'\n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>' North' then begin writeln('NO');exit;end;\n If s=' South' then cs:=cs+c;\n If s=' North' then cs:=cs-c;\n\n If cs mod 40000=0 then cs:=0;\n If cs mod 40000=20000 then cs:=20000;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Program Andronic;\nvar n,i:byte; t:array[1..50]of longword; dir,s:string; a:qword;\nbegin\n readln(n);\n i:=1;\n a:=0;\n s:='YES';\n while (i<=n)and(s<>'NO') do begin\n readln(t[i]);\n readln(dir);\n IF (a=0) and(dir<>'South') then s:='NO';\n IF (a mod 20000=0)and(dir<>'North') then s:='NO';\n IF dir='South' then a:=a+t[i];\n IF dir='North' then a:=a-t[i];\n inc(i);\n IF (i>n)and(a <>0) then s:='NO';\n end;\n writeln(s);\n readln;\nend."}, {"source_code": "var ch,i,n,x,q,y,p,w:longint;\n f:boolean;\n s:string;\nbegin\n readln(n);\n x:=0;\n y:=0;\n p:=0;\n f:=true;\n for i:=1 to n do\n begin\n readln(s);\n val(s,ch,q);\n w:=q;\n val(copy(s,1,q-1),ch,q);\n s:=copy(s,w+1,length(s)-w);\n if (p=2)and(s[1]<>'S') then\n f:=false;\n if (p=1)and(s[1]<>'N') then\n f:=false;\n p:=0;\n case s[1] of\n 'N': dec(y,ch);\n 'E': dec(x,ch);\n 'S': inc(y,ch);\n 'W': inc(x,ch);\n end;\n x:=abs(x mod 40000);\n y:=abs(y mod 20000);\n if (y=0) then\n p:=1;\n if (y=20000) then\n p:=2;\n\n end;\n if y<>0 then\n f:=false;\n if f then\n writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "var\n p,a,b,i,n,j:longint;\n s:Array[1..111]of string;\n k:array[1..111]of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(k[i]);\n readln(s[i]);\n end;\n \n p:=0;\n if (s[1][2]<>'S') then begin writeln('NO');halt;end;\n for i:=1 to n do\n begin\n if (p=0) or (p=20000) then if (s[i][2]='E') or (s[i][2]='W') then begin writeln('NO');halt;end;\n if (s[i][2])='N' then p:=p-k[i] else\n if (s[i][2])='S' then p:=p+k[i];\n if (p<-20000) or (p>20000) then begin writeln('NO');halt;end;\n if (p<0) and (p>-20000) then p:=-p;\n end;\n// writeln(p);\n if p<>0 then writeln('NO') else writeln('YES'); \nend. "}, {"source_code": "var n,i,j,put,vert,f:integer; \n s,napr:string; \nbegin \nread(n); f:=0; vert:=0;\nfor i:=1 to n do begin \n read(put,napr); \n delete(napr,1,1);\n if (put>20000) and (napr<>'East') and (napr<>'West') then f:=1;\n if (vert=20000) and (napr<>'North') then f:=1;\n if (i=1) and (napr<>'South') then f:=1; \n if napr='South' then vert:=vert+put;\n if napr='North' then vert:=vert-put;\n if f=1 then break;\nend;\nif vert<>0 then f:=1;\nif f=1 then write('NO') else write('YES');\nend. "}, {"source_code": "var n,i,t: longint;\n x: longint = 0;\n dir: string;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(t); readln(dir);\n if dir=' North'\n then dec(x,t)\n else if dir=' South'\n then inc(x,t);\n if (x<0)or(x>20000) then\n begin\n write('NO');\n exit;\n end;\n end;\n if x=0 then write('YES') else write('NO');\nend.\n"}, {"source_code": " var t, p, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nif n=5 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend;\nif n=2 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=p+t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n write (' ',p, ' ');\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (' ',p, ' ');\nend;\nend."}, {"source_code": "const\n fi ='';\n fg ='';\nvar n,i,distance:longint;\n c:char;\n x:array[0..51] of longint;\n s:array[0..51] of string;\n f,g:text;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fg);\n rewrite(g);\n readln(f,n);distance :=0;\n For i:=1 to n do\n begin\n read(f,x[i]);read(f,c);s[i] :='';\n While not eoln(f) do\n begin\n read(f,c);s[i] :=s[i] + c;\n end;\n readln(f);\n end;\n For i:=1 to n do\n begin\n If (distance = 0) and (s[i] <> 'South') then\n begin\n writeln(g,'NO');close(g);exit;\n end;\n If (distance = 20000) and (s[i] <> 'North') then\n begin\n writeln(g,'NO');close(g);exit;\n end;\n If (s[i] = 'South') then distance :=distance + x[i]\n else if (s[i] = 'North') then distance :=distance - x[i];\n end;\n If (distance = 0) then writeln(g,'YES')\n else writeln(g,'NO');\n close(f);\n close(g);\nend.\n"}, {"source_code": "var s,n:longint; kq:string[3];\nprocedure Nhap;\nvar x,i:longint; y:string[6];\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(x,y);\n if y=' North' then\n inc(s,x)\n else if y=' South' then\n dec(s,x);\n if (s>20000) or (s<-20000) then\n exit;\n end;\n if s=20000 then\n kq:='YES';\nend;\nprocedure Xuat;\nbegin\n write(kq);\nend;\nbegin\n kq:='NO';\n s:=20000;\n Nhap;\n Xuat;\nend.\n"}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read(t);\n readln (s);\n write (t,s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var n,i,k,m:longint;\n fl:boolean;\n s:string;\nbegin\nreadln(n);\nm:=0;\nfl:=true;\nfor i:=1 to n do\n begin\n read(k);\n readln(s); \n if m = 0 then if s <> ' South' then begin fl:=false; break; end;\n if m = 20000 then if s <> ' North' then begin fl:=false; break; end;\n if s = ' South' then m:=m+k;\n if s = ' North' then m:=m-k;\n if (m<0) and (m>20000) then begin fl:=false; break; end;\n end;\n if fl then if m = 0 then writeln('YES')\n else writeln('NO')\n else writeln('NO');\nend."}, {"source_code": "var\na:array [1..1000000] of integer;\ns,i,n:integer;\nnp,sp:boolean;\np: array [1..1000000] of string;\nbegin\nread (n);\nfor i:=1 to n do begin\nread (a[i]); readln (p[i]); end;\nfor i:=1 to n do begin\nif s=0 then \nif p[i]<>' South' then begin write ('NO'); exit; end;\nif s=20000 then\nif p[i]<>' North' then begin write ('NO'); exit; end;\nif p[i]=' South' then begin s:=s+a[i]; end else if p[i]=' North' then s:=s-a[i]; \nend;\nif s<>0 then write ('NO')\nelse write ('YES');\nend."}, {"source_code": "var i,j,k,l,ms,me,n,f:longint;\nt:array [0..50] of longint;\nd:array [0..50] of string;\ns,sn,se,sw:string;\nbegin\n\nms:=0;\nme:=0;\ns:=' South';\nsn:=' North';\nse:=' East';\nsw:=' West';\nreadln(n);\nfor i:=1 to n do\n read(t[i],d[i]);\n\nif d[n] <> sn then writeln('NO') else\nif d[1] <> s then writeln('NO') else\n begin\n for i:=1 to n do\n begin\n if d[i] = s then\n if ms=20000 then begin f:=1; break; end else\n begin\n ms:=ms+t[i];\n if ms>20000 then\n begin\n f := 1;\n break;\n end;\n end;\n if d[i] = sn then\n if ms=0 then begin f:=1; break; end else\n begin\n ms:=ms-t[i];\n if (ms>20000) and (ms < 0) then\n begin\n f := 1;\n break;\n end;\n end;\n if d[i] = se then begin\n if ms=20000 then begin f:=1; break; end else\n if ms=0 then begin f:=1; break; end else\n me:=me+t[i];\n if me > 20000 then me:=20000-me;\n end;\n if d[i] = sw then begin\n if ms=20000 then begin f:=1; break; end else\n if ms=0 then begin f:=1; break; end else\n me:=me-t[i];\n if me < 0then me:=abs(me);\n end;\n end;\n if f = 1then writeln('NO') else writeln('YES');\n end;\n\n end.\n"}, {"source_code": "Program cf1;\nVar\n north,south,i,j,k,nums,code:longint;\n sn,s,test:string;\n fl:boolean;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n readln(k);\n\n south:=20000; north:=0; fl:=false;\n\n for i:=1 to k do Begin\n readln(s);\n nums:=0;\n sn:='';\n j:=1;\n while (s[j] <> ' ') do Begin\n sn:=sn + s[j];\n inc(j);\n End;\n val(sn,nums,code);\n test:=copy(s,j+1,length(s)-j);\n\n if (nums > 20000) and ((test = 'South') or (test = 'North')) then Begin\n fl:=true;\n break;\n End;\n\n nums:=nums mod 40000;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (test <> 'South') then Begin\n fl:=true;\n break;\n End;\n\n if ((south = 0) or (south = 40000) or (north = 20000)) and (test <> 'North') then Begin\n fl:=true;\n break;\n End;\n\n if (test = 'South') then Begin\n dec(south,nums);\n inc(north,nums);\n End else if (test = 'North') then Begin\n dec(north,nums);\n inc(south,nums);\n End;\n End;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (fl = false) then write('YES') else write('NO');\nEnd.\n"}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\nfor i:=1 to n do begin\n readln(t,dir);\n // writeln(dir);\n if ((dir<>' South')and(y=0)) then flag:=-1\n else if ((dir<>' North')and(y=20000)) then flag:=-1\n else begin\n if (dir=' South') then y:=y+t;\n if (dir=' North') then y:=y-t;\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if y>20000 then y:=20000-(y-20000);\n \n end;\n writeln(y);\nend;\nif (y<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "program hsfdk;\nvar n,i:integer;\n td,so:longint;\n st:string;\n kt:boolean;\nbegin\n readln(n); kt:=true;\n td:=0;\n for i:=1 to n do\n begin\n readln(so,st);\n if kt=true then\n begin\n if(td=0)and(st<>' South')\n or(td=40000)and(st<>' North')then kt:=false;\n if st=' North'then td:=td-so\n else if st=' South'then td:=td+so;\n if(td<0)or(td>40000)then kt:=false;\n end;\n end;\n if td<>0 then kt:=false;\n if kt=true then write('YES')\n else write('NO');\n readln\nend."}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\nfor i:=1 to n do begin\n readln(t,dir);\n \n if ((dir<>' South')and(y=0)) then flag:=-1\n else if ((dir<>' North')and(y=20000)) then flag:=-1\n else begin\n if (dir=' South') then y:=y+t;\n if (dir=' North') then y:=y-t;\n while y>20000 do y:=y-20000;\n while y<0 do y:=y+20000;\n end;\n// writeln(y);\nend;\nif (y<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var t,a1,i,k,n:longint;\n dis:string;\nbegin\nread(n);\na1:=0;\nk:=0;\nfor i:=1 to n do\n begin\n read(t,dis);\n if (a1=0) then\n begin\n if dis='South' then a1:=a1+t;\n end else\n if a1=20000 then\n begin\n if dis='North' then a1:=a1-t;\n end else\n if dis='North' then a1:=a1-t else\n if dis='South' then a1:=a1+t else\n if (dis='West') or (dis='East') then a1:=a1 else\n k:=1;\n end;\nif k=1 then write('NO') else\n if k=0 then\n begin\n if a1>20000 then\n begin\n if a1 mod 20000 = 0 then write('YES') else write('NO');\n end else\n if a1=0 then write('YES') else write('NO');\n end;\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read(t);\n read (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\nfor i:=1 to n do begin\n readln(t,dir);\n // writeln(dir);\n if ((dir<>' South')and(y=0)) then flag:=-1\n else if ((dir<>' North')and(y=20000)) then flag:=-1\n else begin\n if (dir=' South') then y:=y+t;\n if (dir=' North') then y:=y-t;\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if y>20000 then y:=20000-(y-20000);\n \n end;\n writeln(y);\nend;\nif (y<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var n,i,x:longint;\n d:int64;\n s:ansistring;\nbegin\n readln(n);\n d:=0;\n for i:=1 to n do\n begin\n readln(x,s);\n delete(s,1,1);\n if (d=0) and (s<>'South') then begin writeln('NO'); halt; end;\n if (d=20000) and (s<>'North') then begin writeln('NO'); halt; end;\n if (s='South') then d:=d+x;\n if (s='North') then d:=d-x;\n end;\n if (d=0) then writeln('YES') else writeln('NO');\n readln;\nend."}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000007;\n\tmaxN=107;\ntype\n data=record\n dis,dir:longint;\n end;\nvar\n n:longint;\n a:array [0..maxN] of data;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nfunction cal(pos:longint):boolean;\nvar\n now:longint;\n i,x,y:longint;\nbegin\n if (pos<>1) and (pos<>4) then exit(false);\n\n x:=0;\n y:=0;\n for i:=1 to n do\n if a[i].dis<20001 then\n begin\n if a[i].dir=1 then x:=x+a[i].dis;\n if a[i].dir=4 then y:=y+a[i].dis;\n end\n else\n begin\n if (a[i].dis div 20000) mod 2=0 then\n begin\n if a[i].dir=1 then x:=x+a[i].dis mod 20000;\n if a[i].dir=4 then y:=y+a[i].dis mod 20000;\n end\n else\n begin\n if a[i].dir=4 then x:=x+a[i].dis mod 20000;\n if a[i].dir=1 then y:=y+a[i].dis mod 20000;\n end;\n end;\n now:=pos;\n if x<>y then exit(false);\n for i:=1 to n do\n begin\n if (a[i].dir=1) or (a[i].dir=4) then now:=a[i].dir;\n end;\n if now=1 then exit(true);\n exit(false);\nend;\n\nProcedure Nhap;\nvar\n i:longint;\n s:ansistring;\nBegin\n readln(n);\n for i:=1 to n do\n with a[i] do\n begin\n readln(dis,s);\n if s=' North' then a[i].dir:=1;\n if s=' East' then a[i].dir:=2;\n if s=' West' then a[i].dir:=3;\n if s=' South' then a[i].dir:=4;\n\n end;\n if cal(5-a[1].dir) then writeln('YES')\n else writeln('NO');\nEnd;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nProcedure Solve;\nbegin\n\tNhap;\n\tXuli;\n\tXuat;\nend;\nBEGIN\n\tOpenf;\n\tSolve;\n\tClosef;\nEND.\n\n\n"}, {"source_code": "var n,i,j,put,vert,f:integer; \n s,napr:string; \nbegin \nread(n); f:=0; vert:=0;\nfor i:=1 to n do begin \n read(put,napr); \n delete(napr,1,1);\n if (vert=20000) and (napr<>'North') then f:=1;\n if (i=1) and (napr<>'South') then f:=1; \n if napr='South' then vert:=vert+put;\n if napr='North' then vert:=vert-put;\n if f=1 then break;\nend;\nif vert<>0 then f:=1;\nif f=1 then write('NO') else write('YES');\nend. "}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\nfor i:=1 to n do begin\n readln(t,dir);\n // writeln(dir);\n \n if ((pos('South',dir)=0)and(y=0)) then flag:=-1\n else if ((pos('North',dir)=0)and(y=20000)) then flag:=-1\n else if (pos('South',dir)>0)or(pos('North',dir)>0) then begin\n if pos('South',dir)>0 then y:=y+t;\n if pos('North',dir)>0 then y:=y-t;\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if y>20000 then y:=20000-(y-20000);\n \n end;\n // writeln(y);\nend;\nif (y<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "Program cf1;\nVar\n north,south,i,j,k,nums,code:longint;\n sn,s,test:string;\n fl:boolean;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n readln(k);\n\n south:=20000; north:=0; fl:=false;\n\n for i:=1 to k do Begin\n readln(s);\n nums:=0;\n sn:='';\n j:=1;\n while (s[j] <> ' ') do Begin\n sn:=sn + s[j];\n inc(j);\n End;\n val(sn,nums,code);\n test:=copy(s,j+1,length(s)-j);\n\n nums:=nums mod 40000;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (test <> 'South') then Begin\n fl:=true;\n break;\n End;\n\n if ((south = 0) or (south = 40000) or (north = 20000)) and (test <> 'North') then Begin\n fl:=true;\n break;\n End;\n\n if (test = 'South') then Begin\n dec(south,nums);\n inc(north,nums);\n End else if (test = 'North') then Begin\n dec(north,nums);\n inc(south,nums);\n End;\n End;\n\n if ((north = 0) or (north = 40000) or (south = 20000)) and (fl = false) then write('YES') else write('NO');\nEnd.\n"}, {"source_code": "var i,c,cs,n:integer;s:string;a:char;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,a,s);\n If cs=0 then if s<>'South' \n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>'North' then begin writeln('NO');exit;end;\n If s='South' then cs:=cs+c;\n If s='North' then cs:=cs-c;\n \n If cs mod 40000=0 then cs:=0;\n If cs mod 40000=20000 then cs:=20000;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend. \n "}, {"source_code": "var\n n, x, y, sd, i: longint;\n s: string;\n \nprocedure sphalt;\nbegin\n writeln('NO');\n halt(0);\nend;\n \nbegin\n readln(n);\n for i := 1 to n do\n begin\n read(sd);\n readln(s);\n \n if (y <= 0) and (s <> ' South') then\n sphalt;\n if (y >= 20000) and (s <> ' North') then\n sphalt;\n if s = ' South' then\n inc(y, sd);\n if s = ' North' then\n dec(y, sd);\n if s = ' West' then\n inc(x, sd);\n if s = ' East' then\n dec(x, sd);\n \n end;\n if (y <> 0) then\n sphalt;\n writeln('YES');\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "uses math;\nvar\n s,t:string;\n n,m,i,k,j,f,c,x,y,z,q,w,v,g:longint;\n pp:integer;\nbegin\n readln(n);\n v:=10000;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),f,pp);\n f:=f mod 40000;\n // writeln(f);\n if s[pos(' ',s)+1]='N'then inc(v,f)else\n if s[pos(' ',s)+1]='S'then dec(v,f)else\n begin\n if v=-10000 then inc(v,f)else\n if v=10000 then dec(v,f);\n\n end;\n if v>abs(10000)then v:=-(v mod 40000);\n // writeln(v);\n end;\n if v=10000 then writeln('YES')\n else writeln('NO');\nend.\n\n"}, {"source_code": "var n,now,i:longint;\n k:int64;\n s:ansistring;\nbegin\n readln(n);now:=0;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),k);\n delete(s,1,pos(' ',s));\n if(s[1]='N')then now:=now-k\n else if(s[1]='S')then now:=now+k;\n if(now<0)or(now>20000)then begin writeln('NO');halt;end;\n end;\n if(now<>0)then writeln('NO')else writeln('YES');\nend."}, {"source_code": "var k,n,l,d:integer; s:string;\nbegin\n\nreadln(n);\nfor var i:=1 to n do begin\nread(l); readln(s); \nif (k<0) or (k>20000) then d+=1;\nif (k=0) and (s[2]<>'S')then d+=1;\nif (k=20000) and (s[2]<>'N')then d+=1;\nif s[2]='S' then k+=l;\nif s[2]='N' then k-=l; end;\nif d>0 then write('NO') else if k>0 then write('NO') else write('YES');\nend."}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\ni:=1;\nwhile ((i<=n)and(flag=1)) do begin\n readln(t,dir);\n // writeln(pos('North',dir),' ',dir);\n if ((pos('South',dir)=0)and(y=0)) then flag:=-1\n else if ((pos('North',dir)=0)and(y=20000)) then flag:=-1\n else if (pos('South',dir)>0)or(pos('North',dir)>0) then begin\n if pos('South',dir)>0 then y:=y+t;\n if pos('North',dir)>0 then y:=y-t;\n while ((y<0)or(y>20000)) do begin\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n if y>20000 then y:=20000-(y-20000);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n end;\n end;\n \n i:=i+1;\n // writeln(i,' ',y,' ',flag);\nend;\nif ((abs(y) mod 40000)<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var n,i,k,m:longint;\n fl:boolean;\n s:string;\nbegin\nreadln(n);\nm:=0;\nfl:=true;\nfor i:=1 to n do\n begin\n read(k);\n readln(s); \n if m = 0 then if s <> ' South' then begin fl:=false; break; end;\n if m = 20000 then if s <> ' North' then begin fl:=false; break; end;\n if s = ' South' then m:=m+k;\n if s = ' North' then m:=m-k;\n if (m<0) and (m>20000) then begin fl:=false; break; end;\n end;\n if fl then if m = 0 then writeln('YES')\n else writeln('NO')\n else writeln('NO');\nend."}, {"source_code": "var n,res:byte;\n t:array[0..50] of longint;\n dir:array[0..50] of string;\n\nprocedure solve;\nvar NS:longint; i:byte;\nbegin\n NS:=0; res:=0;\n for i:=1 to n do\n begin\n if dir[i]=' North' then\n begin\n if NS=0 then break;\n if t[i]>NS then break;\n NS:=NS-t[i];\n end\n else if dir[i]=' South' then\n begin\n if NS=20000 then break;\n if t[i]>20000-NS then break;\n NS:=NS+t[i];\n end\n else if ((dir[i]=' West') or (dir[i]=' East')) and ((NS=0) or (NS=20000)) then break;\n end;\n if NS=0 then res:=1;\nend;\n\nprocedure input;\nvar i:byte; tmp:string;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n readln(t[i],dir[i]);\n end;\nend;\n\nprocedure output;\nbegin\n if res=0 then writeln('NO') else writeln('YES');\nend;\n\nbegin\n input;\n solve;\n output;\nend."}, {"source_code": "var a:array[1..50] of string[6];\n b:array[1..50] of longint;\n i,s,n:longint;\n data:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do begin\nreadln(b[i],a[i]);\nif ((b[i]>20000)and(a[i]=' North')) or ((b[i]>20000)and(a[i]=' South'))then data:=true\nend;\ns:=0;\nfor i:=1 to n do begin\nif a[i]=\n' South' then begin\n if s=20000 then begin data:= true; break end;\n inc(s,b[i]);\n end;\n if a[i]=\n' North' then begin\n if s=0 then begin data:= true; break end;\n dec(s,b[i]);\n end;\n if a[i]=\n' West' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\n if a[i]=\n' East' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\nend;\n//if (s=0)and(r<>0) then data:=true;\nif s<>0 then data:=true;\nif data then writeln('NO')\n else writeln('YES')\nend.\n"}, {"source_code": "var\n a,m,j,i,n,g,posi : longint;\n s,tempat,s1,ch : string;\n b : boolean;\nbegin\n tempat:='South';\n posi:=0;\n readln(n);\n ch:=' ';\n //readln(s1);\n //writeln(pos(ch,s1));\n b:=true;\n for i:= 1 to n do\n begin\n readln(a,s1);\n m:=pos(ch,s1);\n s:=copy(s1,m+1,length(s1)-m+1);\n //writeln(s);\n if b then\n begin\n if posi=0 then\n begin\n //writeln('#1');\n if (tempat=s) then\n begin\n posi:=posi+a;\n if posi=20000 then\n begin\n tempat:='North';\n posi:=0;\n end\n else\n if posi>20000 then\n b:=false;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);\n end\n else\n b:=false;\n end\n else\n begin\n //writeln('#2');\n if tempat=s then\n begin\n posi:=posi+a;\n if posi=20000 then\n begin\n if tempat='North' then\n tempat:='South'\n else\n tempat:='North';\n posi:=0;\n end\n else\n if posi>20000 then\n b:=false;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);\n end\n else\n if (tempat<>s) and ((s<>'West') and (s<>'East')) then\n begin\n posi:=posi-a;\n //writeln('posi sekarang ',posi);\n //writeln('tempat sekarang ',tempat);;\n end;\n end;\n end;\n end;\n //writeln(b);\n if not b then\n writeln('NO')\n else\n if (tempat='South') and (posi=0) then\n writeln('YES')\n else\n writeln('NO');\nend.\n"}, {"source_code": "Program cf1;\nVar\n north,south,i,j,k,nums,code,east,west:longint;\n sn,s,test:string;\n fl:boolean;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n readln(k);\n\n south:=10000; north:=0; fl:=false; east:=0; west:=0;\n\n for i:=1 to k do Begin\n readln(s);\n nums:=0;\n sn:='';\n j:=1;\n while (s[j] <> ' ') do Begin\n sn:=sn + s[j];\n inc(j);\n End;\n val(sn,nums,code);\n test:=copy(s,j+1,length(s)-j);\n\n nums:=nums mod 40000;\n\n if ((north = 0) or (north = 40000)) and (test <> 'South') then Begin\n fl:=true;\n break;\n End;\n\n if (test = 'South') then Begin\n dec(south,nums);\n inc(north,nums);\n End else if (test = 'North') then Begin\n dec(north,nums);\n inc(south,nums);\n End else if (test = 'East') then Begin\n inc(east);\n End else if (test = 'West') then Begin\n inc(west);\n End;\n End;\n\n if ((north = 0) or (north = 40000)) and (fl = false) and (east-west = 0) then write('YES') else write('NO');\nEnd.\n"}, {"source_code": "Program z2;\nvar\n n,k,m,t,v:integer;\n i,j:integer;\n f:boolean;\n s,mt:string;\nbegin\n readln(n);\n f:=true;\n k:=0;\n for i:=1 to n do begin\n readln(s);\n if f=true then\n if s[length(s)]='h' then begin\n mt:=copy(s,1,length(s)-6);\n t:=length(mt);\n v:=1;\n m:=0;\n for j:=t downto 1 do begin\n m:=m+(ord(mt[j])-48)*v;\n v:=v*10;\n end;\n if s[length(s)-2]='r' then m:=-m;\n if ((k+m)<0)OR((k+m)>40000)OR((k=0)AND(m<0))OR((k=40000)AND(m>0)) then f:=false;\n k:=k+m;\n end else if (k=0)OR(k=40000) then f:=false;\n end;\n if k<>0 then f:=false;\n if f=false then write('NO') else write('YES');\nend."}, {"source_code": "var\n n,m,i,k,x,c:longint;\n s:string;\nbegin\n readln(n);\n m:=0;\n for i:=1 to n do\n begin\n readln(s);\n x:=pos(' ',s);\n val(copy(s,1,x-1),k,c);\n case s[x+1] of\n 'S':begin\n m:=m+k;\n if m>20000 then m:=20000;\n end;\n 'N':begin\n m:=m-k;\n if m<0 then m:=0;\n end;\n end;\n end;\n if m=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar x, i, n, vt: longint;\n s: string;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n vt:=0;\n for i:=1 to n do\n begin\n readln(x,c,s);\n if s = 'South' then\n begin\n vt:=vt+x;\n if vt > 20000 then\n begin\n writeln('NO');\n halt;\n end;\n end\n else if s = 'North' then\n begin\n vt:=vt- x;\n if vt < 0 then\n begin\n writeln('NO');\n halt;\n end;\n end\n else if (s = 'West') or (s = 'North') then\n begin\n if (vt = 0) or (vt = 20000) then\n begin\n writeln('NO');\n halt;\n end;\n end;\n end;\n if vt <> 0 then write('NO')\n else write('YES');\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\nt: array [1..75] of longint;\ndir: array [1..75] of string;\ntemp: boolean;\ne: char;\ni, pos, n: longint;\n\nbegin\n\treadln (n);\n\n\tfor i:= 1 to n do\n\t\treadln (t[i], e, dir[i]);\n\n\ttemp:= true;\n\tpos:=0;\n\tfor i:= 1 to n do\n\tbegin\n\t\tif (temp) then \n\t\tbegin\n\t\t\tif (pos=0) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'South') then\n\t\t\t\ttemp:= false;\n\t\t\tend else if (pos=20000) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'North') then\n\t\t\t\ttemp:= false;\n\t\t\tend else begin\n\t\t\t\tif (dir[i]='South') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos+t[i]>20000) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos+t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend else if (dir[i]='North') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos-t[i]<0) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos-t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\tif (temp) then begin\n\tif (pos=0) then\n\t\ttemp:=true\n\telse temp:= false;\n\tend;\n\n\tif (temp) then\n\t\twriteln ('YES')\n\telse writeln ('NO');\nend."}, {"source_code": "var\n\tA,n,i:longint;\n\ts:string;\n\tres:int64;\nbegin\n\treadln(n);res:=0;\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(a);\n\t\t\treadln(s);\n\t\t\tif (res = 0) and (s<>' North') and (s<>' South') then \n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend\n\t\t\telse \n\t\t\tif (res=20000) and (s<>' North') and (s<>' South') then\n\t\t\t\tbegin\n\t\t\t\t\twrite('NO');\n\t\t\t\t\texit;\n\t\t\t\tend\n\t\t\telse \n\t\t\tif (s = ' South') then res:=res+a\n\t\t\telse\n\t\t\tif (s = ' North') then res:=res-a\n\t\tend;\n\tif res = 0 then write('YES')\n\telse write('NO');\nend."}, {"source_code": " var t, p, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "{var\nt: array [1..75] of longint;\ndir: array [1..75] of string;\ntemp: boolean;\ne: char;\ni, pos, n: longint;\n\nbegin\n\treadln (n);\n\n\tfor i:= 1 to n do\n\t\treadln (t[i], e, dir[i]);\n\n\ttemp:= true;\n\tpos:=0;\n\tfor i:= 1 to n do\n\tbegin\n\t\tif (temp) then \n\t\tbegin\n\t\t\tif (pos=0) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'South') then\n\t\t\t\ttemp:= false;\n\t\t\tend;\n\t\t\tif (pos=20000) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'North') then\n\t\t\t\ttemp:= false;\n\t\t\tend;\n\t\t\tif ((pos>0) and (pos<20000)) then begin\n\t\t\t\tif (dir[i]='South') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos+t[i]>20000) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos+t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend else if (dir[i]='North') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos-t[i]<0) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos-t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\tif (temp) then begin\n\tif (pos=0) then\n\t\ttemp:=true\n\telse temp:= false;\n\tend;\n\n\tif (temp) then\n\t\twriteln ('YES')\n\telse writeln ('NO');\nend.}\n\nvar\nt: array [1..75] of longint;\ndir: array [1..75] of string;\ntemp: boolean;\ne: char;\ni, pos, n: longint;\n\nbegin\n readln (n);\n\n for i:= 1 to n do\n readln (t[i], e, dir[i]);\n\n temp:= true;\n pos:=0;\n for i:= 1 to n do\n begin\n if (temp) then \n begin\n if (pos=0) then\n begin\n if (dir[i]<>'South') then\n temp:= false;\n end;\n if (pos=20000) then\n begin\n if (dir[i]<>'North') then\n temp:= false;\n end;\n\n if ((pos > 0) AND (pos < 20000)) then\n if (dir[i]='South') then\n begin\n pos:=pos+t[i];\n if (pos>20000) then temp:= false;\n end else if (dir[i]='North') then\n begin\n pos:=pos-t[i];\n if (pos<0) then temp:= false;\n end;\n end;\n end;\n if (pos<>0) then temp:= false;\n\n if (temp) then\n writeln ('YES')\n else writeln ('NO');\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read(t);\n read (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var n,f,i,a : longint;\n c : char;\nbegin\n readln(n); f:=0;\n for i:=1 to n do begin\n readln(a,c,c);\n if c = 'S' then inc(f,a);\n if c = 'N' then dec(f,a);\n if f < 0 then begin writeln('NO'); halt; end;\n if f > 20000 then begin writeln('NO'); halt; end;\n end;\n if f <> 0 then begin writeln('NO'); halt; end;\n writeln('YES');\nend."}, {"source_code": "var a1,a2,i,j,n,k:longint;\n t:array[1..55] of longint;\n dis:array[1..55] of string;\n b:string;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(t[i],b);\n delete(b,1,1);\n dis[i]:=b;\n end;\ni:=1;\na1:=0;\na2:=0;\nwhile (i<=n) and (k=0) do\n begin\n if (a1=0) and (dis[i]='South') then\n a1:=a1+t[i] else\n if (a1=20000) and (dis[i]='North')then\n a1:=a1-t[i] else\n if (a1<>0) and (a1<>20000) and (dis[i]='South') then\n a1:=a1+t[i] else\n if (a1<>0) and (a1<>20000) and (dis[i]='North') then\n a1:=a1-t[i] else\n if (a1<>0) and (a1<>20000) and (dis[i]='West') then\n a2:=a2+t[i] else\n if (a1<>0) and (a1<>20000) and (dis[i]='East') then\n a2:=a2-t[i] else\n k:=1;\n inc(i);\n end;\nif (k=0) and (a1=0) then write('Yes') else write('NO');\nend.\n"}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n if (put=20000) and (s<>'North') then x:=3;\n if (put<0) then x:=4;\n if (put>20000) then x:=5;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n write (put);\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (put,' ',x);\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (put,' ',x);\nend."}, {"source_code": " var t, p, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nif n=5 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend;\nif n=2 then begin for i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then p:=t;\n if (i>1) and (s='South') then p:=p+t;\n if (i>1) and (s='North') then p:=p-t;\n if (p<0) then x:=4;\n if (p>20000) then x:=5;\n write (' ',p, ' ');\n end;\nif (p=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend;\n write (' ',p, ' ');\nend."}, {"source_code": "var c,cs,n:int64;s:string;i:integer;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,s);\n If cs=0 then if s<>' South' \n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>' North' then begin writeln('NO');exit;end;\n If s=' South' then cs:=cs+c;\n If s=' North' then cs:=cs-c;\n \n If cs mod 40000=0 then cs:=0;\n If cs mod 40000=20000 then cs:=20000;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend. \n "}, {"source_code": "{$mode objfpc}\n{$coperators on}\nconst\n fi='input.txt';\n fo='output.txt';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nvar n:longint;\nprocedure enter;\nbegin\n readln(n);\nend;\nfunction solve:string;\nvar me,dis,i:longint;\n c,d:char;\nbegin\n me:=0;\n for i:=1 to n do begin\n readln(dis,c,d);\n if (d<>'S') and (d<>'N') then continue;\n if (me=0) and (d<>'S') then exit('NO');\n if (me=20000) and (d<>'N') then exit('NO');\n //dis:=dis mod 40000;\n if (dis>20000) then exit('NO');\n if d='S' then begin\n me+=dis;\n if me>20000 then exit('NO');\n end;\n if d='N' then begin\n me-=dis;\n if me<0 then exit('NO');\n end;\n end;\n if me=0 then exit('YES');\n exit('NO');\nend;\nbegin\n //fileio;\n enter;\n writeln(solve);\nend."}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000007;\n\tmaxN=107;\ntype\n data=record\n dis,dir:longint;\n end;\nvar\n n:longint;\n a:array [0..maxN] of data;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nfunction cal(pos:longint):boolean;\nvar\n now:longint;\n i,x,y,tg:longint;\nbegin\n if (pos<>1) and (pos<>4) then exit(false);\n now:=pos;\n if now=1 then x:=0\n else x:=20000;\n for i:=1 to n do\n begin\n if (a[i].dir=1) or (a[i].dir=4) then\n with a[i] do\n begin\n tg:=x;\n if dir=1 then tg:=max(tg-a[i].dis,0)\n else tg:=min(tg+a[i].dis,20000);\n x:=tg;\n now:=dir;\n end\n else\n begin\n if (x=0) or (x=20000) then exit(false);\n end;\n end;\n if (x=0) and (now=1) then exit(true);\n exit(false);\nend;\n\nProcedure Nhap;\nvar\n i:longint;\n s:ansistring;\nBegin\n readln(n);\n for i:=1 to n do\n with a[i] do\n begin\n readln(dis,s);\n if s=' North' then a[i].dir:=1;\n if s=' East' then a[i].dir:=2;\n if s=' West' then a[i].dir:=3;\n if s=' South' then a[i].dir:=4;\n\n end;\n if cal(5-a[1].dir) then writeln('YES')\n else writeln('NO');\nEnd;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nProcedure Solve;\nbegin\n\tNhap;\n\tXuli;\n\tXuat;\nend;\nBEGIN\n\tOpenf;\n\tSolve;\n\tClosef;\nEND.\n\n\n"}, {"source_code": "var qq:array[0..200000]of longint;\nnn,i,j:longint;\n\nbegin\nrandomize;\nnn:=36000;\nfor i:=1 to nn do qq[i]:=32768*random(32768)+random(32768);\nfor i:=1 to nn-1 do\n for j:=i+1 to nn do\n if qq[i]>qq[j] then\n begin\n qq[0]:=qq[i]; qq[i]:=qq[j]; qq[j]:=qq[0];\n end;\nend."}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\ni:=1;\nwhile ((i<=n)and(flag=1)) do begin\n readln(t,dir);\n // writeln(dir);\n if ((pos('South',dir)=0)and(y=0)) then flag:=-1\n else if ((pos('North',dir)=0)and(y=20000)) then flag:=-1\n else if (pos('South',dir)>0)or(pos('North',dir)>0) then begin\n if pos('South',dir)>0 then y:=y+t;\n if pos('North',dir)>0 then y:=y-t;\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if y>20000 then y:=20000-(y-20000);\n end;\n i:=i+1;\n// writeln(i,' ',y,' ',flag);\nend;\nif (y<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "{var\nt: array [1..75] of longint;\ndir: array [1..75] of string;\ntemp: boolean;\ne: char;\ni, pos, n: longint;\n\nbegin\n\treadln (n);\n\n\tfor i:= 1 to n do\n\t\treadln (t[i], e, dir[i]);\n\n\ttemp:= true;\n\tpos:=0;\n\tfor i:= 1 to n do\n\tbegin\n\t\tif (temp) then \n\t\tbegin\n\t\t\tif (pos=0) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'South') then\n\t\t\t\ttemp:= false;\n\t\t\tend;\n\t\t\tif (pos=20000) then\n\t\t\tbegin\n\t\t\t\tif (dir[i]<>'North') then\n\t\t\t\ttemp:= false;\n\t\t\tend;\n\t\t\tif ((pos>0) and (pos<20000)) then begin\n\t\t\t\tif (dir[i]='South') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos+t[i]>20000) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos+t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend else if (dir[i]='North') then\n\t\t\t\tbegin\n\t\t\t\t\tif (pos-t[i]<0) then\n\t\t\t\t\t\ttemp:= false\n\t\t\t\t\telse begin\n\t\t\t\t\t\tpos:=pos-t[i];\n\t\t\t\t\t\ttemp:= true;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\tif (temp) then begin\n\tif (pos=0) then\n\t\ttemp:=true\n\telse temp:= false;\n\tend;\n\n\tif (temp) then\n\t\twriteln ('YES')\n\telse writeln ('NO');\nend.}\n\nvar\nt: array [1..75] of longint;\ndir: array [1..75] of string;\ntemp: boolean;\ne: char;\ni, pos, n: longint;\n\nbegin\n readln (n);\n\n for i:= 1 to n do\n readln (t[i], e, dir[i]);\n\n temp:= true;\n pos:=0;\n for i:= 1 to n do\n begin\n if (temp) then \n begin\n if (pos=0) then\n begin\n if (dir[i]<>'South') then\n temp:= false;\n end;\n if (pos=20000) then\n begin\n if (dir[i]<>'North') then\n temp:= false;\n end;\n\n if ((pos > 0) AND (pos < 20000)) then\n if (dir[i]='South') then\n begin\n pos:=pos+t[i];\n if (pos>20000) then temp:= false;\n end else if (dir[i]='North') then\n begin\n pos:=pos-t[i];\n if (pos<0) then temp:= false;\n end;\n end;\n end;\n if (pos<>0) then temp:= false;\n\n if (temp) then\n writeln ('YES')\n else writeln ('NO');\nend."}, {"source_code": "var a:array[1..50] of string[6];\n b:array[1..50] of longint;\n i,s,n:longint;\n data:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\nreadln(b[i],a[i]);\ns:=0;\nfor i:=1 to n do begin\nif a[i]=\n' South' then begin\n if s=20000 then begin data:= true; break end;\n inc(s,b[i]);\n end;\n if a[i]=\n' North' then begin\n if s=0 then begin data:= true; break end;\n dec(s,b[i]);\n end;\n if a[i]=\n' West' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\n if a[i]=\n' East' then begin\n if (s=0)or(s=20000) then begin data:= true; break end;\n end;\nend;\n//if (s=0)and(r<>0) then data:=true;\nif s<>0 then data:=true;\nif data then writeln('NO')\n else writeln('YES')\nend.\n"}, {"source_code": "uses math;\nvar\n s,t:string;\n n,m,i,k,j,f,c,x,y,z,q,w,v,g:longint;\n pp:integer;\nbegin\n readln(n);\n v:=10000;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),f,pp);\n f:=f mod 40000;\n // writeln(f);\n if(s[pos(' ',s)+1]='N')and(v=10000)then f:=0;\n if(s[pos(' ',s)+1]='S')and(v=-10000)then f:=0;\n\n if s[pos(' ',s)+1]='N'then inc(v,f)else\n if s[pos(' ',s)+1]='S'then dec(v,f)else\n begin\n if v=-10000 then inc(v,f)else\n if v=10000 then dec(v,f);\n\n end;\n// writeln(v);\n// writeln;\n if abs(v)>abs(10000)then v:=-(v mod 20000);\n// writeln(v);\n end;\n if v=10000 then writeln('YES')\n else writeln('NO');\nend.\n\n"}, {"source_code": "var\n\tA,n,i:longint;\n\ts:string;\n\tres:int64;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(a);\n\t\t\treadln(s);\n\t\t\tif s = ' South' then res:=res+a;\n\t\t\tif s = ' North' then res:=res-a;\n\t\tend;\n\tif res = 0 then write('YES')\n\telse write('NO');\nend."}, {"source_code": "var x,y,i,r,j,n,z,f,f1:longint;\ns:string;\n begin\n // assign(input,'input.txt'); reset(input);\n readln(n);\n x:=10000;y:=0;\n for i:= 1 to n do \n begin\n readln(s);\n j:=1;\n r:=0;\n while s[j]<>' ' do\n begin \n vaL(s[j],z,f);\n r:=r*10+z;\n j:=j+1;\n end;\n if s[j+1]='E' then y:=y+r;\n if s[j+1]='W' then y:=y-r;\n if abs(y)>20000 then f:=1;\n if (x=10000) and(s[j+1]<>'S')and(s[j+1]='N')and(i<>1) then f1:=1;\n if (x=-10000) and(s[j+1]<>'N')and(s[j+1]='S') then f1:=1;\n if (x<>10000)and(s[j+1]='N') then x:=x+r;\n if x>10000 then f1:=1;\n if (x<>-10000)and(s[j+1]='S') then x:=x-r;\n if x<-10000 then f1:=1;\n end;\n if (x=10000)and(f1=0) then writeln('YES')\n else writeln('NO');\n end.\n \n "}, {"source_code": "var n,i,tek:longint;\n s:string;\nbegin\n readln(n);\n tek:=0;\n for i:=1 to n do\n begin\n read(n,s);\n if (s='North')and(tek20000)\n then begin write('NO');halt;end;\n if ((s='West')or(s='East'))and((tek=0)or(tek=20000))\n then begin write('NO');halt;end;\n\n if s='North'\n then dec(tek,n);\n if s='South'\n then inc(tek,n);\n\n \n end;\n if tek=0\n then write('YES')\n else write('NO');\n\n\n\nend."}, {"source_code": "const fi='';\n fo='';\nprocedure process;\nvar s:longint;\n l:1..40000;\n n,i:1..50;\n a:string;\n f,g:text;\nbegin\n s:=0;\n assign(f,fi);reset(F);\n assign(g,fo);rewrite(g);\n readln(F,n);\n for i:=1 to n do\n begin\n read(f,l);readln(f,a);\n delete(a,1,1);\n if (a[1]='N') then dec(s,l);\n if (a[1]='S') then inc(s,l);\n if (( (a[1]='W') or (a[1]='E') ) and ( (s=0) or (s=20000))) or (s<0) or (s>20000) then\n begin\n writeln(g,'No');\n close(F);\n close(g);\n exit;\n end;\n end;\n if (s=0) then write(g,'Yes') else write(g,'No');\n close(F);\n close(g);\nend;\nbegin\n process;\nend.\n"}, {"source_code": "var t,a1,i,k,n:longint;\n dis:string;\nbegin\nread(n);\na1:=0;\nk:=0;\nfor i:=1 to n do\n begin\n read(t,dis);\n delete(dis,1,1);\n if (a1=0) then\n begin\n if dis='South' then a1:=a1+t;\n end else\n if a1=20000 then\n begin\n if dis='North' then a1:=a1-t;\n end else\n if dis='North' then a1:=a1-t else\n if dis='South' then a1:=a1+t else\n if (dis='West') or (dis='East') then a1:=a1 else\n k:=1;\n end;\nif k=1 then write('NO') else\n if k=0 then\n begin\n if a1>20000 then\n begin\n if a1 mod 20000 = 0 then write('YES') else write('NO');\n end else\n if a1=0 then write('YES') else write('NO');\n end;\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "uses math;\nvar\n s,t:string;\n n,m,i,k,j,f,c,x,y,z,q,w,v,g:longint;\n pp:integer;\nbegin\n readln(n);\n v:=10000;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),f,pp);\n f:=f mod 40000;\n if s[pos(' ',s)+1]='N'then inc(v,f)else\n if s[pos(' ',s)+1]='S'then dec(v,f)else\n begin\n if v=-10000 then inc(v,f);\n if v=10000 then dec(v,f);\n end;\n if v>10000 then v:=-(v mod 10000);\n if v<-10000 then v:=-(v mod 10000);\n // writeln(v);\n end;\n if v=10000 then writeln('YES')\n else writeln('NO');\nend.\n\n"}, {"source_code": "Program Andronic;\nvar n,i:byte; t:array[1..50]of longword; dir,s:string; a:qword;\nbegin\n readln(n);\n i:=1;\n a:=0;\n s:='YES';\n while (i<=n)and(s<>'NO') do begin\n readln(t[i]);\n readln(dir);\n IF (a div 40000=0) and(dir<>'South') then s:='NO';\n IF (a div 20000=0)and(dir<>'North') then s:='NO';\n IF dir='South' then a:=a+t[i];\n IF dir='North' then a:=a-t[i];\n inc(i);\n IF (i>n)and(a div 40000<>0) then s:='NO';\n end;\n writeln(s);\n readln;\nend."}, {"source_code": "var qq:array[0..200000]of longint;\nnn,i,j:longint;\n\nbegin\nrandomize;\nnn:=27000;\nfor i:=1 to nn do qq[i]:=32768*random(32768)+random(32768);\nfor i:=1 to nn-1 do\n for j:=i+1 to nn do\n if qq[i]>qq[j] then\n begin\n qq[0]:=qq[i]; qq[i]:=qq[j]; qq[j]:=qq[0];\n end;\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var i,c,cs,n:integer;s:string;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,s);\n If ((s=' South')or(s=' North'))and(c>20000)then writeln('NO');\n If cs=0 then if s<>' South'\n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>' North' then begin writeln('NO');exit;end;\n If s=' South' then cs:=cs+c;\n If s=' North' then cs:=cs-c;\n\n If cs mod 40000=0 then cs:=0;\n If cs mod 40000=20000 then cs:=20000;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var n,i,j,k,t,l,r,d,x,y:longint;\nm:longint;\ndir:string;\nflag: integer;\nbegin\nreadln(n);\nflag:=1;\ny:=0;\ni:=1;\nwhile ((i<=n)and(flag=1)) do begin\n readln(t,dir);\n // writeln(pos('North',dir),' ',dir);\n if ((pos('South',dir)=0)and(y=0)) then flag:=-1\n else if ((pos('North',dir)=0)and(y=20000)) then flag:=-1\n else if (pos('South',dir)>0)or(pos('North',dir)>0) then begin\n if pos('South',dir)>0 then y:=y+t;\n if pos('North',dir)>0 then y:=y-t;\n while ((y<0)or(y>20000)) do begin\n if (y<0) then y:=abs(y);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n if y>20000 then y:=20000-(y-20000);\n while y>=40000 do y:=y-40000;\n if (y<0) then y:=abs(y);\n end;\n end;\n \n i:=i+1;\n // writeln(i,' ',y,' ',flag);\nend;\nif ((abs(y) mod 40000)<>0) then flag:=-1;\nif (flag=-1) then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var t,a1,i,k,n:longint;\n dis:string;\nbegin\nread(n);\na1:=0;\nk:=0;\nfor i:=1 to n do\n begin\n read(t,dis);\n delete(dis,1,1);\n if (a1=0) then\n begin\n if dis='South' then a1:=a1+t;\n end else\n if a1=20000 then\n begin\n if dis='North' then a1:=a1-t;\n end else\n if dis='North' then a1:=a1-t else\n if dis='South' then a1:=a1+t else\n if (dis='West') or (dis='East') then a1:=a1 else\n k:=1;\n end;\nif k=1 then write('NO') else\n if k=0 then\n begin\n if a1>20000 then\n begin\n if a1 mod 20000 = 0 then write('YES') else write('NO');\n end else\n if a1=0 then write('YES') else write('NO');\n end;\nend."}, {"source_code": "{$mode objfpc}\n{$coperators on}\nconst\n fi='input.txt';\n fo='output.txt';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nvar n:longint;\nprocedure enter;\nbegin\n readln(n);\nend;\nfunction solve:string;\nvar me,dis,i:longint;\n c,d:char;\nbegin\n me:=0;\n for i:=1 to n do begin\n readln(dis,c,d);\n if (me=0) and (d<>'S') then exit('NO');\n if (me=20000) and (d<>'N') then exit('NO');\n //dis:=dis mod 40000;\n if dis>20000 then exit('NO');\n if d='S' then begin\n me+=dis;\n if me>20000 then exit('NO');\n end;\n if d='N' then begin\n me-=dis;\n if me<0 then exit('NO');\n end;\n end;\n if me=0 then exit('YES');\n exit('NO');\nend;\nbegin\n //fileio;\n enter;\n writeln(solve);\nend."}, {"source_code": "var n,i,j,put,vert,f,gor:integer; \n s,napr:string; \nbegin \nread(n); f:=0; \nfor i:=1 to n do begin \n read(put,napr); \n delete(napr,1,1);\n if (i=1) and (napr<>'South') then f:=1; \n if napr='South' then vert:=vert+put;\n if napr='North' then vert:=vert-put;\n if napr='West' then gor:=gor-put;\n if napr='East' then gor:=gor+put;\n if f=1 then break;\nend;\nif (vert<>0) or (gor<>0) then f:=1;\nif f=1 then write('NO') else write('YES');\nend. "}, {"source_code": "Program Andronic;\nvar n,i:byte; t:array[1..50]of longword; dir,s:string; a:qword;\nbegin\n readln(n);\n i:=1;\n a:=0;\n s:='YES';\n while (i<=n)and(s<>'NO') do begin\n readln(t[i]);\n readln(dir);\n IF (a div 40000=0) and(dir<>'South') then s:='NO';\n IF (a div 20000=0)and(dir<>'North') then s:='NO';\n IF dir='South' then a:=a+t[i];\n IF dir='North' then a:=a-t[i];\n inc(i);\n IF (i>n)and(a div 40000<>0) then s:='NO';\n end;\n writeln(s);\n readln;\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n if (put=0) and (s<>'South') then x:=2;\n if (put=20000) and (s<>'North') then x:=3;\n if (put<0) then x:=4;\n if (put>20000) then x:=5;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "var k,a,n,i,t:longint;\n dis:string;\nbegin\nread(n);\na:=0;\nk:=0;\nfor i:=1 to n do\n begin\n read(t,dis);\n delete(dis,1,1);\n if ((a=0) and (dis='South')) or ((dis='South') and (a<>0) and (a<>20000)) then\n a:=a+t else\n if ((a=20000) and (dis='North')) or ((dis='North') and (a<>0) and (a<>20000)) then\n a:=a-t else\n if (a<>0) and (a<>20000) and ((dis='East') or (dis='West')) then\n a:=a else\n begin\n k:=1;\n break;\n end;\n a:=a mod 40000;\n end;\nif (k=0) and (a=0) then write('YES') else write('NO');\nend.\n"}, {"source_code": "var ch,i,n,x,q,y,p,w:longint;\n f:boolean;\n s:string;\n a:array[1..100] of longint;\nbegin\n readln(n);\n x:=0;\n y:=0;\n p:=0;\n f:=true;\n for i:=1 to n do\n begin\n readln(s);\n val(s,ch,q);\n w:=q;\n val(copy(s,1,q-1),ch,q);\n s:=copy(s,w+1,length(s)-w);\n if (p=2)and(s[1]<>'S') then\n f:=false;\n if (p=1)and(s[1]<>'N') then\n f:=false;\n p:=0;\n a[i]:=ch;\n case s[1] of\n 'N': dec(y,ch);\n 'E': dec(x,ch);\n 'S': inc(y,ch);\n 'W': inc(x,ch);\n end;\n x:=abs(x mod 40001);\n if y<0 then\n f:=false;\n if (y<0) then\n p:=1;\n if (y>20000) then\n p:=2;\n\n end;\n if y<>0 then\n f:=false;\n if f then\n writeln('YES') else\n writeln('NO');\nend.\n"}, {"source_code": "uses math;\nconst\n\tfin='';\n\tfon='';\n\tmaxC=1000000007;\n\tmaxN=107;\ntype\n data=record\n dis,dir:longint;\n end;\nvar\n n:longint;\n a:array [0..maxN] of data;\n\nProcedure Openf;\nbegin\n\tassign(input,fin); reset(input);\n\tassign(output,fon); rewrite(output);\nend;\n\nProcedure Closef;\nbegin\n\tclose(input);\n\tclose(output);\nEnd;\n\nfunction cal(pos:longint):boolean;\nvar\n now:longint;\n i,x,y:longint;\nbegin\n if (pos<>1) and (pos<>4) then exit(false);\n\n x:=0;\n y:=0;\n now:=pos;\n for i:=1 to n do\n if a[i].dis<20001 then\n begin\n if a[i].dir=1 then x:=x+a[i].dis;\n if a[i].dir=4 then y:=y+a[i].dis;\n now:=a[i].dir;\n end\n else\n begin\n if (a[i].dis div 20000) mod 2=0 then\n begin\n if a[i].dir=1 then x:=x+a[i].dis mod 20000;\n if a[i].dir=4 then y:=y+a[i].dis mod 20000;\n now:=a[i].dir;\n end\n else\n begin\n if a[i].dir=4 then x:=x+a[i].dis mod 20000;\n if a[i].dir=1 then y:=y+a[i].dis mod 20000;\n now:=5-a[i].dir;\n end;\n end;\n if x<>y then exit(false);\n\n if now=1 then exit(true);\n exit(false);\nend;\n\nProcedure Nhap;\nvar\n i:longint;\n s:ansistring;\nBegin\n readln(n);\n for i:=1 to n do\n with a[i] do\n begin\n readln(dis,s);\n if s=' North' then a[i].dir:=1;\n if s=' East' then a[i].dir:=2;\n if s=' West' then a[i].dir:=3;\n if s=' South' then a[i].dir:=4;\n\n end;\n if cal(5-a[1].dir) then writeln('YES')\n else writeln('NO');\nEnd;\n\nProcedure xuli;\nbegin\nend;\n\nProcedure Xuat;\nbegin\nend;\n\nProcedure Solve;\nbegin\n\tNhap;\n\tXuli;\n\tXuat;\nend;\nBEGIN\n\tOpenf;\n\tSolve;\n\tClosef;\nEND.\n\n\n"}, {"source_code": "var a:array[1..50] of string[6];\n b:array[1..50] of longint;\n i,s,p,n,r:longint;\n data:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\nreadln(b[i],a[i]);\ns:=0;\nfor i:=1 to n do begin\nif a[i]=\n' South' then begin\n if s=20000 then begin data:= true; break end;\n inc(s,b[i]);\n end;\n if a[i]=\n' North' then begin\n if s=0 then begin data:= true; break end;\n dec(s,b[i]);\n end;\n if a[i]=\n' West' then begin\n if s=0 then begin data:= true; break end;\n inc(r,b[i]);\n end;\n if a[i]=\n' East' then begin\n if s=0 then begin data:= true; break end;\n dec(r,b[i]);\n end;\nend;\n//if (s=0)and(r<>0) then data:=true;\nif s<>0 then data:=true;\nif data then writeln('NO')\n else writeln('YES')\nend.\n"}, {"source_code": "var k,i, n,s,y,p:integer;\n st, dir:string;\n f:boolean;\nbegin\n readln(n);\n f:=True;\n s:=0;\n for i:=1 to n do\n begin\n readln(st);\n p:=pos(' ',st);\n dir:=copy(st,p+1,length(st)-p);\n Delete(st, p, length(st)-p+1);\n val(st,k,y);\n if (s=0) or (s-40000*(s div 40000)=0) \n then if dir='South' then \n if s+k<=20000 then s:=s+k\n else s:=20000-((s+k) mod 20000)\n else f:=False\n else if (s=20000) or (s-40000*(s div 40000)=20000) \n then if dir='North' then \n if k<=20000 then s:=s-k\n else s:=(s+k) mod 20000\n else f:=False\n else\n if dir='North' then s:=abs(s-(k mod 40000)) \n else if dir='South' \n then if s+k<=20000 then s:=s+k\n else s:=20000-((s+k) mod 20000) \n end;\n if (s-40000*(s div 40000)=0) and (f) then writeln ('YES')\n else writeln('NO') \nend."}, {"source_code": "var c,cs,n:integer;s:string;i:integer;\nbegin\nreadln(n);\ncs:=0;\nFor i:=1 to n do\n begin\n readln(c,s);\n If ((s=' South')or(s=' North'))and(c>20000)\n then writeln('NO');\n If cs=0 then if s<>' South'\n then begin writeln('NO');\n exit;\n end;\n If cs=20000 then if s<>'North' then begin writeln('NO');exit;end;\n If (s=' South') then cs:=cs+c;\n If (s=' North') then cs:=cs-c;\n If cs > 0 then begin\n cs:=cs mod 40000;\n If cs>20000 then cs:=-cs;\n end\n else begin\n cs:=cs mod 40000;\n If cs>-20000 then cs:=-cs;\n end;\n end;\nIf cs=0 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var\n n,now,p,i,d:longint;\n st:string;\n flag:boolean;\nbegin\n readln(n);\n now:=0;flag:=true;\n for i:=1 to n do\n begin\n readln(st);\n p:=pos(' ',st);\n val(copy(st,1,p-1),d);\n case st[p+1] of\n 'S':\n begin\n inc(now,d);\n if d>20000\n then flag:=false;\n end;\n 'N':\n begin\n dec(now,d);\n if d<0\n then flag:=false;\n end;\n 'E':if (now=0)or(now=20000) then flag:=false;\n 'W':if (now=0)or(now=20000) then flag:=false;\n end;\n end;\n if now<>0\n then flag:=false;\n if flag\n then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "uses math;\nvar\n s,t:string;\n n,m,i,k,j,f,c,x,y,z,q,w,v,g:longint;\n pp:integer;\nbegin\n readln(n);\n v:=10000;\n for i:=1 to n do\n begin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),f,pp);\n f:=f mod 40000;\n // writeln(f);\n if(s[pos(' ',s)+1]='N')and(v=10000)then f:=0;\n if(s[pos(' ',s)+1]='S')and(v=-10000)then f:=0;\n\n if s[pos(' ',s)+1]='N'then inc(v,f)else\n if s[pos(' ',s)+1]='S'then dec(v,f)else\n begin\n if v=-10000 then inc(v,f)else\n if v=10000 then dec(v,f);\n\n end;\n// writeln(v);\n// writeln;\n if v<-10000 then v:=-10000;\n if v>10000 then v:=10000;\n// writeln(v);\n end;\n if v=10000 then writeln('YES')\n else writeln('NO');\nend.\n\n"}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n readln (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=2;\n if (put=20000) and (s<>'North') then x:=3;\n if (put<0) then x:=4;\n if (put>20000) then x:=5;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n write (put);\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (put,' ',x);\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=2;\n if (put=20000) and (s<>'North') then x:=3;\n if (put<0) then x:=4;\n if (put>20000) then x:=5;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nwrite (put,' ',x);\nend."}, {"source_code": "program hsfdk;\nvar n,i:integer;\n td,so:longint;\n st:string;\n kt:boolean;\nbegin\n readln(n); kt:=true;\n td:=0;\n for i:=1 to n do\n begin\n readln(so,st);\n if kt=true then\n begin\n if(td=0)and(st<>' South')\n or(td=40000)and(st<>' North')then kt:=false;\n if st=' North'then td:=td-so\n else if st=' South'then td:=td+so;\n if(td<0)or(td>40000)then kt:=false;\n end;\n end;\n if td<>0 then kt:=false;\n if kt=true then write('YES')\n else write('NO');\n readln\nend."}, {"source_code": "var t, put, n, i, x: longint;\ns: string;\nbegin\nreadln (n);\nfor i:=1 to n do \n begin\n read (t);\n readln (s);\n if (i=1) and (s='South') then put:=t;\n if (i=1) and (s<>'South') then x:=1;\n if (put=0) and (s<>'South') then x:=1;\n if (put=20000) and (s<>'North') then x:=1;\n if (put<0) then x:=1;\n if (put>20000) then x:=1;\n if (i>1) and (s='South') then put:=put+t;\n if (i>1) and (s='North') then put:=put-t;\n end;\nif (put=0) and (x=0) then writeln ('YES') else writeln ('NO');\nend."}, {"source_code": "const fi='';\n fo='';\nprocedure process;\nvar s:longint;\n l:1..40000;\n n,i:1..50;\n a:string;\n f,g:text;\nbegin\n s:=0;\n assign(f,fi);reset(F);\n assign(g,fo);rewrite(g);\n readln(F,n);\n for i:=1 to n do\n begin\n read(f,l);readln(f,a);\n delete(a,1,1);\n if (a[1]='N') then dec(s,l);\n if (a[1]='S') then inc(s,l);\n if (( (a[1]='W') or (a[1]='E') ) and ( (s=0) or (s=20000))) or (s<0) or (s>20000) then\n begin\n writeln(g,'No');\n close(F);\n close(g);\n exit;\n end;\n end;\n if (s=0) then write(g,'Yes') else write(g,'No');\n close(F);\n close(g);\nend;\nbegin\n process;\nend.\n"}], "src_uid": "11ac96a9daa97ae1900f123be921e517"} {"source_code": "program D_2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ni,j,n,k,\nstartS,finishS,op:longint;\na:array[0..200010] of longint;\nfunction min(a,b:longint):longint;\nbegin\nif (ba[i-1]) then startS:=i;\n if (a[i]<>a[i+1]) then\n begin\n finishS:=i;\n if (k>0) then begin op:=op+min(k,finishS-startS+1); end;\n end;\n end;\n end;\n writeln(op);\nend.\n ", "positive_code": [{"source_code": "var\n a, b : array [1..200000] of longint;\n i, k, ans, n : longint;\nbegin\n read(n);\n k := 1;\n for i := 1 to n do\n begin\n read(a[i]);\n if a[i] > 0\n then\n begin\n b[k] := a[i];\n inc(k);\n end;\n end;\n for i := 1 to k - 1 do\n if a[i] <> b[i]\n then\n begin\n inc(ans);\n\n end;\n writeln(ans);\nend."}, {"source_code": "program _4;\nvar n, i, s, k, c, a, t: longint;\nprocedure cnt;\nbegin\nif c>k then s:=s+k else s:=s+c;\nend;\nbegin\nreadln(n);\nt:=0;\nfor i:=1 to n do begin\n read(a);\n if a=0 then begin if t<>0 then cnt; t:=0; k:=k+1; continue end;\n if (t<>0) and (a=t) then c:=c+1;\n if (t=0) then begin c:=1; t:=a end;\n if (t<>0) and (a<>t) then begin cnt; t:=a; c:=1; end;\nend;\nif a=0 then begin writeln(s); exit end;\nif (t<>0) and (a=t) then cnt;\nif (t=0) then begin c:=1; t:=a; cnt end;\nif (t<>0) and (a<>t) then begin cnt; t:=a; c:=1; end;\nwriteln(s);\nend.\n"}], "negative_code": [], "src_uid": "9135c7243431debb049f640e9600bc6e"} {"source_code": "var k,r,t:longint;\r\nfunction gcd(a,b:qword):qword;\r\nvar t:qword;\r\n begin\r\n t:=a mod b;\r\n while t<>0 do\r\n begin\r\n t:=b mod a;\r\n b:=a;\r\n a:=t;\r\n end;\r\n gcd:=b;\r\n end;\r\nbegin\r\n read(t);writeln;\r\n for r:=1 to t do\r\n begin\r\n read(k);\r\n writeln(100 div gcd(100,k));\r\n end;\r\nend.", "positive_code": [{"source_code": "uses\r\n Math;\r\n\r\nvar\r\n t, step, k, mn, i, j: longint;\r\n\r\nbegin\r\n readln(t);\r\n for step := 1 to t do begin\r\n readln(k);\r\n \r\n mn := 100;\r\n for i := 1 to 100 do\r\n for j := 0 to 100 do\r\n if (i * 100 div (i + j) = k) and (i * 100 mod (i + j) = 0) and (i + j < mn) then begin\r\n if i + j = 26 then\r\n writeln(i, ' ', j);\r\n mn := i + j;\r\n end; \r\n \r\n writeln(mn); \r\n end;\r\nend."}, {"source_code": " const eps=1e-14;\r\n besk=4000000000000000000; label 55,5,4,1,3,2,44,22;\r\n type\r\n mas=array[-20000..1704060+1] of int64;\r\n integer=longint; zap=record p1,p2,p3:int64; end;\r\n zap1=^zap;\r\n var razm,poss,mm,tip,ppos1,oldtt,ps,pos1,pos2,pred,color,buk,cur,init,res,oldpos,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\r\n sss:array[-1..1000] of string;\r\n ss4,oldss,smin,ss3,ss,ss1,ss2:string;\r\n newaans,aans:zap;\r\n otr1,otr0,d0,d1,d2,vx,vy,ddist,tttt:extended;\r\n pqqq:zap;\r\n gam,al0,otal,al1,al2,acc, disk,prop,bet,al:extended; fl1,fl2,fl:boolean;\r\n dr3,dr1,dr2,pt,ott1,ott2:zap;\r\n pos,time,ost,zz,x:array[-1000..4100000] of int64;\r\n stroka,sss1,sss2:array[-10..1200000] of char;\r\n v3,v1,v2,pointx,pointy,vel,tt0,radius,ote,ddl,dl1,dl2:extended;\r\n dd1,ddpos:array[-2..14,-200..65400] of int64;\r\n kolpotom,pospotom,zx,zy,z,kol,xxx,yyy,invfact,y,ansx,ansy,ugol,xx,yy:array[-1000..4100000] of int64;\r\n mright,pol,dx,dy:array[-100..1850000] of int64;\r\n il,jl,ig,jg,iw,jw,ib,jb,ie,je,ott,posx,posy,p,mnog,ii,jj,ttt,delta,tt1,tt2,sum,left,right,koll,newt,osn,oldot,num,oldt,ll,rr,znmax,aa,ot,t11,t01,t10,t00,opld,nap,t4,kk,dl,iii,jjj,aaa,bbb,ccc,bb,p0,t,xmax,xmin,ymax,ymin,newpos,newdl,len,pp3,ans1,ans2,modul,t0,t1,t2,dloch,koldel,mmax,stepen,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,kool,number,imin,qq,n,m,numpos,down,imax,t3,qq1,qq2,q1,q2,w,p3,p4,pmax,pmax2,p1,p2,hh,pos0,pp,maxot,tmax,nn,n1,q:int64; flag1:boolean;\r\n b1,a1,b,c,a,zzz,fact,stan,a2,invx,invy,place,str,b2,z1,sum1,sum0,d:mas; flag2,flag:boolean; pl:longint;\r\n kkol,i2,j2,ans,tt,sdvig,start,finish,izb, oldmax,newmax,posmax,zapas,razn,oldll,oldrr,ppp,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,ugg,r,ug:int64;\r\n prost,zzan,zann:array[-10..2001001] of boolean;\r\n newzan,zan:array[-1000000..4000000] of boolean;\r\n zanx,marked:array[-1000000..4100000] of boolean;\r\n path,dd,ddnew,dleft,dnomer:array[-1..521,-1..521,0..21] of int64;\r\n ochh,newochh:array[0..4000000] of longint;\r\n first,last,kolnenul,next1,next0,prev1,prev0,newoch,och,lx,a3,b3,predok:array[-20000..4500000] of int64;\r\n ddsum,ddd:array[-400..265200,-1..10] of int64;\r\n sumgor,pole,newpole:array[-100..2300,-100..2300] of char;\r\n newpolest,polest:array[-100..2300,-100..2300] of int64;\r\n polest1:array[-1..11,-10..230,-10..230] of int64;\r\n\r\n\r\n ssan,ssans,bufer:array[-1000..1000000] of char;\r\n cosa,sina,cosb,sinb,rx,ry,px,py,h1,h2,h,l1,l2,otmax,v:int64;\r\n obmen,ch:char;\r\n mmat:array[0..200001,0..9,0..9] of int64;\r\n flagg,fflag,ok,flagg1:boolean;\r\n koled,oldx,oldy,numx,numy,xleft,xright,s,newplace,newstr,next,prev,aold:array[-1000..4200002] of int64;\r\n function srav(i,j:longint):boolean; label 44;\r\n begin\r\n if (a[i]a[j] then begin srav:=false; goto 44; end;\r\n if a[i]=a[j] then if a1[i]=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=fact[jj];\r\n p3:=fact[ii-jj];\r\n t2:=degg(p2,modul-2,modul);\r\n t3:=degg(p3,modul-2,modul);\r\n ot:=((p1*t2) mod modul*t3) mod modul;\r\n bincoef:=ot;\r\n end else bincoef:=0;\r\n end;\r\n\r\n function bincoef1(ii,jj:longint):int64;\r\n var t1,t2,t3,p1,p2,p3,ot:int64;\r\n begin\r\n if ii>=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=invfact[jj];\r\n p3:=invfact[ii-jj];\r\n ot:=((p1*p2) mod modul*p3) mod modul;\r\n bincoef1:=ot;\r\n end else bincoef1:=0;\r\n end;\r\n\r\n procedure pech;\r\n var j,i:longint;\r\n begin\r\n for i:=1 to p do begin for j:=1 to p do if zan[i] then write('*') else write('.'); writeln; end;\r\n writeln;\r\n {writeln('ot= ',ot); }\r\n end;\r\n\r\n function zapr(tip,i,j,aa:int64):int64;\r\nvar ot:longint;\r\n begin if tip=1 then ot:=max(min(a[i],aa),min(a[j],aa+1)) else ot:=min(max(a[i],aa),max(a[j],aa+1)); zapr:=ot; end;\r\n\r\n\r\n\r\nbegin\r\n\r\n { assign (input,'D:\\Projects\\input.txt');reset(input);\r\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\r\n }\r\n\r\n readln(qq);\r\n for stepp:=1 to qq do\r\n begin\r\n read(p);\r\n t:=nod(p,100);\r\n writeln(100 div t);\r\n\r\n end;\r\n\r\n\r\n\r\n 1: close (output);\r\n\r\nend.\r\n\r\n\r\n\r\n"}, {"source_code": "Var\r\n k,t,o,i,j: Longint;\r\nBegin\r\n Readln(t);\r\n For i :=1 To t Do\r\n Begin\r\n Readln(k);\r\n For j := 1 To k Do\r\n If (k Mod j = 0) And (100 Mod j = 0) Then o := j;\r\n Writeln(100 Div o);\r\n End;\r\nEnd.\r\n"}, {"source_code": "Var\r\n k,t: Longint;\r\nFunction gcd(a,b:Longint): Longint;\r\nVar\r\n t: Longint;\r\nBegin\r\n While b <> 0 Do\r\n Begin\r\n t := b;\r\n b := a Mod b;\r\n a := t;\r\n End;\r\n gcd := a\r\nEnd;\r\nBegin\r\n Readln(t);\r\n For t:=1 To t Do\r\n Begin\r\n Readln(k);\r\n Writeln(100 Div gcd(100,k));\r\n End;\r\nEnd.\r\n"}, {"source_code": "Var\r\n a,b,t: Longint;\r\n\r\nFunction gcd(a,b:Longint): Longint;\r\nBegin\r\n If b=0 Then Exit(a);\r\n Exit(gcd(b,a Mod b));\r\nEnd;\r\nBegin\r\n Readln(t);\r\n For t:=1 To t Do\r\n Begin\r\n Readln(a);\r\n Writeln(100 Div gcd(100,a));\r\n End;\r\nEnd.\r\n"}, {"source_code": "var t,j,n,a,b:byte;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do begin\r\n readln(n);\r\n t:=1;\r\n a:=100;\r\n b:=n;\r\n while t<>0 do begin\r\n t:=a mod b;\r\n a:=b;\r\n b:=t;\r\n end;\r\n writeln(100 div a);\r\n end;\r\nend.\r\n"}, {"source_code": "var t,i,a,b,d:integer;\r\nfunction uc(a,b:integer):integer;\r\nvar x,y,t:integer;\r\nbegin\r\n x:=a;y:=b;\r\n t:=y mod x;\r\n while t<>0 do\r\n begin\r\n t:=x mod y;x:=y;y:=t;\r\n end;\r\n uc:=x;\r\nend;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n readln(a);\r\n b:=100-a;\r\n d:=uc(a,b);\r\n writeln(a div d+b div d);\r\n end;\r\nend."}, {"source_code": "var count,k,t:LongInt;\r\n\r\n\r\nprocedure gcd(x,y:longint);\r\nvar i,j:longint;\r\nbegin\r\n if x>y then x:=x-y;\r\n if y>x then y:=y-x;\r\n if x=y then count:=x\r\n else \r\n gcd(x,y);\r\nend;\r\n\r\nprocedure nhapfile;\r\nvar i,j:longint;\r\nbegin\r\n readln(t);\r\n while t<>0 do \r\n begin\r\n readln(k);\r\n if 100 mod k=0 then writeln(100 div k)\r\n else\r\n begin\r\n gcd(k,100);\r\n writeln(100 div count);\r\n end;\r\n dec(t);\r\n end;\r\nend;\r\n\r\nbegin\r\n nhapfile;\r\nend."}, {"source_code": "var a,b,t:longint;\r\nfunction gcd(a,b:longint):longint;\r\nbegin\r\n if b=0 then exit(a);\r\n exit(gcd(b,a mod b));\r\nend;\r\nbegin\r\n readln(t);\r\n for t:=1 to t do\r\n begin\r\n readln(a);\r\n writeln(100 div gcd(100,a));\r\n end;\r\nend."}, {"source_code": "var a,b,t:longint;\r\nfunction gcd(a,b:longint):longint;\r\nbegin\r\n if b=0 then exit(a);\r\n exit(gcd(b,a mod b));\r\nend;\r\nbegin\r\n readln(t);\r\n for t:=1 to t do\r\n begin\r\n readln(a);\r\n writeln(100 div gcd(100,a));\r\n end;\r\nend."}, {"source_code": "Uses wincrt;\r\nVar\r\nc,i,k,m, t:integer;\r\na, b, d, e:boolean;\r\nBegin\r\nReadln(c) ;\r\nFor i:=1 to c do begin\r\nReadln(k) ;\r\nm:=0;\r\nt:=k;\r\nRepeat\r\nm:=m+1; \r\nIf k mod 2=0 then k:=k div 2;\r\nIf k mod 5=0 then k:=k div 5;\r\nUntil m=2;\r\nWriteln((100*k) div t) ;\r\nEnd;\r\nEnd. "}, {"source_code": "var\r\na,t,i:longint;\r\nfunction gcd(x,y:longint):longint;\r\nbegin\r\n if y=0 then exit(x);\r\n exit(gcd(y,x mod y));\r\nend;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n readln(a);\r\n writeln(100 div gcd(100,a));\r\n end;\r\nend."}, {"source_code": "var\r\n t: longint;\r\n\r\nfunction gcd(a, b: longint): longint;\r\nbegin\r\n if (a = 0) then exit(b)\r\n else exit(gcd(b mod a, a));\r\nend;\r\n\r\nprocedure solve;\r\nvar\r\n k, water, magic, g: longint;\r\nbegin\r\n readln(k);\r\n g := gcd(k, 100 - k);\r\n water := (100 - k) div g;\r\n magic := k div g;\r\n writeln(water + magic);\r\nend;\r\n\r\nbegin\r\n readln(t);\r\n while (t > 0) do\r\n begin\r\n solve;\r\n dec(t);\r\n end;\r\nend."}, {"source_code": "var a,b:array[0..200001]of int64;s,k:int64;j,m,q,t,i,n:longint; \r\nPROCEDURE HV(VAR a,b:int64);\r\nVAR tmp:int64;\r\nBEGIN\r\n tmp:=a;a:=b;b:=tmp;\r\nEND;\r\n \r\nPROCEDURE QS(l,r:longint);\r\nVAR i,j,k:longint;\r\nBEGIN\r\n i:=l;j:=r;k:=a[(l+r)div 2];\r\n REPEAT\r\n WHILE a[i]k DO j:=j-1;\r\n IF i<=j THEN\r\n BEGIN\r\n HV(a[i],a[j]);\r\n i:=i+1;j:=j-1;\r\n END;\r\n UNTIL i>j;\r\n IF i0 do\r\n begin\r\n n:=m;m:=i;\r\n i:= n mod m;\r\n end;\r\n writeln(100 div m) \r\n end end\r\nend."}, {"source_code": "var a,b,n,i:int64;\r\not:string;\r\nbegin\r\nread(n);\r\nfor i:=1 to n do \r\n begin\r\n read (a);\r\n b:=100;\r\n while (a>0) and (b>0) do\r\n if a>b then a:=a mod b\r\n else b:=b mod a;\r\n ot := ot +(100 div (a+b))+#10;\r\n end;\r\nwrite(ot);\r\nend."}], "negative_code": [{"source_code": "Var\r\n t,i,k: Integer;\r\nBegin\r\n Readln(t);\r\n For i := 1 To t Do\r\n Begin\r\n Readln(k);\r\n If 100 Mod k = 0 Then Writeln(100 Div k)\r\n Else Writeln(100);\r\n End;\r\nEnd.\r\n"}, {"source_code": "var t,j,n,a,b:byte;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do begin\r\n readln(n);\r\n if (n mod 2 = 1) and (100 mod n <>0) then writeln(100)\r\n else begin\r\n t:=1;\r\n a:=100;\r\n b:=n;\r\n while t<>0 do begin\r\n t:=a mod b;\r\n a:=b;\r\n b:=t;\r\n end;\r\n writeln(100 div a);\r\n\r\n end;\r\n end;\r\nend.\r\n"}, {"source_code": "var t,j,n:byte;\r\nbegin\r\n readln(t);\r\n for j:=1 to t do begin\r\n readln(n);\r\n if 100 mod n = 0 then writeln(100 div n)\r\n else writeln(100);\r\n end;\r\nend."}, {"source_code": "var a:array[1..100] of byte;i,j,t,n:integer;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do readln(a[i]);\r\n for i:=1 to t do\r\n if 100 mod a[i]<>0 then writeln('100')\r\n else writeln(100 div a[i]);\r\n readln;\r\nend.\r\n"}, {"source_code": "var count,k,t:LongInt;\r\n\r\nprocedure nhapfile;\r\nvar i,j:longint;\r\nbegin\r\n readln(t);\r\n while t<>0 do \r\n begin\r\n readln(k);\r\n if 100 mod k<>0 then writeln('100') else writeln(100 div k);\r\n dec(t);\r\n end;\r\nend;\r\n\r\nbegin\r\n nhapfile;\r\nend."}, {"source_code": "var n,i,ot:int64;\r\na:array[1..100] of int64;\r\nbegin\r\nreadln(n);\r\nfor i:=1 to n do read(a[i]);\r\nfor i:=1 to n do\r\n begin\r\n if ((100 mod a[i])=0)then writeln(100 div a[i])\r\n else if ((100 mod(100-a[i]))=0)then writeln (100 div(100-a[i]))\r\n else if (a[i]mod 10 =0)then writeln ('10')\r\n else writeln('100');\r\n end;\r\nend."}], "src_uid": "19a2bcb727510c729efe442a13c2ff7c"} {"source_code": "uses math;\n\nvar i,l,n,pz,pk:longint;\n s:string;\n\n procedure make_step(var x,l:longint);\n begin\n x:=x+l;\n if x=0 then begin x:=2; l:=-l; end else\n if x>n then begin x:=n-1; l:=-l; end;\n end;\n\n procedure go_out(x,y,t:longint);\n begin\n if x=y then\n begin\n writeln('Controller ',t);\n halt;\n end;\n end;\n\n\n begin\n readln(n,pz,pk);\n readln(s);\n if s='to tail' then l:=1 else l:=-1;\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n make_step(pk,l);\n if l=1 then\n begin\n if pk=1 then pz:=n else pz:=1;\n end else\n begin\n if pk=n then pz:=1 else pz:=n;\n end;\n go_out(pk,pz,i);\n end else\n begin\n if l=1 then\n begin\n if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);\n end else\n begin\n if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);\n end;\n go_out(pk,pz,i);\n make_step(pk,l);\n go_out(pk,pz,i);\n end;\n end;\n writeln('Stowaway');\n end.", "positive_code": [{"source_code": "var i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if f then begin\n if s[i]='1' then begin\n m:=1;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend."}, {"source_code": "const fin='';\n fout='';\n\nvar f:text;\n n,x,y,dir,m,res:longint;\n s:string;\n kt:boolean;\n\nprocedure nhap;\nbegin\n assign(f,fin);\n reset(f);\n readln(f,n,y,x);\n readln(f,s);\n if s='to head' then dir:=-1 else dir:=1;\n readln(f,s);\n close(f);\nend;\n\nprocedure run1;\nbegin\n x:=x+dir;\n if x=0 then\n begin\n x:=2;\n dir:=1;\n end\n else if x>n then\n begin\n x:=n-1;\n dir:=-1;\n end;\nend;\n\nprocedure run2(dir:longint);\nbegin\n if (y+dir>=1) and (y+dir<=n) then y:=y+dir;\nend;\n\nprocedure xuly;\nvar i:longint;\nbegin\n m:=length(s);\n kt:=false;\n for i:=1 to m do\n if s[i]='0' then\n begin\n if (y-x)*dir < 0 then run2(-dir) else run2(dir);\n run1;\n if x=y then\n begin\n kt:=true;\n res:=i;\n exit;\n end;\n end\n else\n begin\n run1;\n if dir=-1 then y:=n\n else y:=1;\n end;\nend;\n\nprocedure xuat;\nbegin\n assign(f,fout);\n rewrite(f);\n if kt=false then writeln(f,'Stowaway')\n else writeln(f,'Controller ',res);\n close(f);\nend;\n\nbegin\n nhap;\n xuly;\n xuat;\nend.\n"}, {"source_code": "var n,m,j,i,k,l,z,temp:longint;s,s1:string;\nprocedure xx(f:longint);\n begin\n if (temp=-1) and (k>z) and (z>1) then z:=z+temp else\n if (temp=-1) and (kz) and (z>1) then z:=z-1;\n\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=z then begin writeln('Controller ',f);halt;end;\n end;\nprocedure zz(f:longint);\n begin\n if f=length(s) then begin writeln('Stowaway');halt;end;\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=1 then z:=n else\n if k=n then z:=1 else\n if temp>0 then z:=1 else\n if temp<0 then z:=n;\n end;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(n,z,k);\nreadln(s1);\nif s1='to head' then temp:=-1 else temp:=1;\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='0' then xx(i) else zz(i);\nend.\n"}, {"source_code": "var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if (y=-1)or(k=1) then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend.var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if n-k>k-1 then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend."}, {"source_code": "var n,x,y,g,max,t,i,j:longint;\n s:string;\n\nprocedure tt(x:longint);\nvar k:longint;\n begin\n k:=0;\n if g>0 then begin\n if x>=y then k:=x-y\n else k:=2*n-x-y;\n end\n else begin\n if x<=y then k:=y-x\n else k:=y-1+x-1;\n end;\n if k>max then begin\n max:=k;\n t:=x;\n end;\n end;\n\n begin\n readln(n,x,y);\n readln(s);\n if s[length(s)]='d' then g:=-1\n else g:=1;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if (y=1) then g:=1;\n if (y=n) then g:=-1;\n max:=-1;\n t:=x;\n if s[i]='0' then begin\n y:=y+g;\n\n\n if (x-1>=1) and (x-1<>y-g) and (x-1<>y) then tt(x-1);\n if (x+1<=n) and (x+1<>y-g) and (x+1<>y) then tt(x+1);\n tt(x);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end\n else begin\n y:=y+g;\n\n for j:=1 to n do\n if (j<>y) then tt(j);\n\n x:=t;\n end;\n if x=y then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var\nb:array[1..10000] of char;\nn,m,i,k,l,j,p:longint;\ns:string;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to tail' then p:=1 else p:=0;\ni:=0;\nwhile not eoln do\n begin\n inc(i);\n read(b[i]);\n end;\nif m>k then l:=n\nelse l:=1;\nfor j:=1 to i do\n begin\n if b[j]='0' then\n if p=0 then\n dec(k) else inc(k) else\n begin\n if p=0 then\n dec(k)\n else inc(k);\n if p=0 then l:=n else l:=1;\n end;\n if k=l then begin write('Controller ',j); exit;end;\n if k=n then p:=0;\n if k=1 then p:=1;\n end;\nwrite('Stowaway');\nend.\n"}, {"source_code": "var n,m,k,d,i:integer;\n s:string[202];\nbegin\n readln(n,k,m);\n readln(s);\n if s='to head'then d:=-1\n else d:=1;\n read(s);\n for i:=1to length(s)do\n begin\n if m=1then d:=1;\n if m=n then d:=-1;\n m:=m+d;\n if'0'=s[i]then\n begin\n if(k+d<=n)and(d+k>=1)then k:=k+d;\n end\n else\n begin\n if d=1then k:=1\n else k:=n;\n end;\n if m=k then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n write('Stowaway')\nend."}, {"source_code": "var x,xenemy,incx:LongInt;\ns:ansistring;\nn:LongInt;\ni:LongInt;\nprocedure fail;\nbegin\n writeln('Controller ',i);\n halt;\nend;\n\nbegin\n // assign(input,'C:/input.txt');reset(input);\n readln(n,x,xenemy);\n readln(s);\n if s='to head' then incx:=-1\n else incx:=1;\n readln(s);\n for i:=1 to length(s) do\n if s[i]='0' then\n begin\n if xxenemy then inc(x);\n \n if x=0 then x:=1;\n if x=n+1 then x:=n;\n \n if x=xenemy then fail;\n \n inc(xenemy,incx);\n if xenemy=0 then\n begin\n xenemy:=2;\n incx:=1;\n end\n else\n if xenemy=n+1 then\n begin\n xenemy:=n-1;\n incx:=-1;\n end;\n \n if x=xenemy then fail;\n end\n else\n begin\n inc(xenemy,incx);\n if xenemy=0 then\n begin\n xenemy:=2;\n incx:=1;\n end\n else\n if xenemy=n+1 then\n begin\n xenemy:=n-1;\n incx:=-1;\n end;\n \n if (incx=1)and(xenemy<>1) then x:=1\n else\n if (incx=1) then x:=n;\n \n if (incx=-1)and(xenemy<>n) then x:=n\n else \n if (incx=-1) then x:=1;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "uses math;\nvar\n n,m,k,l,tt:longint;\n s,t:string;\nprocedure nhap;\nbegin\n readln(n,m,k);\n readln(t);\n readln(s);\n l:=length(s);\n if t='to head' then tt:=-1 else tt:=1;\nend;\nprocedure xuly;\nvar\n i:longint;\nbegin\n for i:=1 to l do\n begin\n if s[i]='0' then\n begin\n if tt=-1 then\n begin\n if mk then m:=math.min(n,m+1)\n else m:=math.max(1,m-1);\n end;\n k:=k+tt;\n if k=m then\n begin\n writeln('Controller ',i);\n exit;\n end;\n end\n else\n begin\n k:=k+tt;\n if tt=-1 then\n begin\n if k1 then m:=1 else m:=n;\n end;\n end;\n if (k=1) and (tt=-1) then tt:=1;\n if (k=n) and (tt=1) then tt:=-1;\n end;\n writeln('Stowaway');\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "var n,m,k,min,i,t:integer;\n s,time:string;\n controller: boolean;\nbegin\nRead(n);\nRead(m);\nReadln(k);\nReadln(s);\nreadln(time);\nIf (s='to head') then t:=-1 else t:=1;\nFor i:=1 to length(time)-1 do begin\nIf time[i]='0' then begin\n if ((t=-1) and (k>m)) or ((t=1) and (k1) and (m<>n) then m:=m+t;\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1)\n end\n else if ((t=-1) and (km)) then begin\n If (m<>1) and (m<>n) then m:=m-t;\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1)\n end\nend\nelse begin\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1);\n if ((t=-1) and (k<>n)) or ((t=1) and (k=1)) then m:=n \n else if ((t=1) and (k<>1)) or ((t=-1) and (k=n)) then m:=1\n end;\nIf m=k then begin controller:=true; min:=i;break end\nend;\n If controller then write('Controller ',min) else writeln('Stowaway')\nend."}, {"source_code": "var n,x,y,g,max,t,i,j:longint;\n s:string;\n\nprocedure tt(x:longint);\nvar k:longint;\n begin\n k:=0;\n if g>0 then begin\n if x>=y then k:=x-y\n else k:=2*n-x-y;\n end\n else begin\n if x<=y then k:=y-x\n else k:=y-1+x-1;\n end;\n if k>max then begin\n max:=k;\n t:=x;\n end;\n end;\n\n begin\n readln(n,x,y);\n readln(s);\n if s[length(s)]='d' then g:=-1\n else g:=1;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if (y=1) then g:=1;\n if (y=n) then g:=-1;\n max:=-1;\n t:=x;\n if s[i]='0' then begin\n y:=y+g;\n\n\n if (x-1>=1) and (x-1<>y-g) and (x-1<>y) then tt(x-1);\n if (x+1<=n) and (x+1<>y-g) and (x+1<>y) then tt(x+1);\n tt(x);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end\n else begin\n y:=y+g;\n\n for j:=1 to n do\n if (j<>y) then tt(j);\n\n x:=t;\n end;\n if x=y then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var\n n,thie,wei,ty,sum :longint;\n ch :char;\nfunction getmin(aaa,bbb:longint):longint;\nbegin\n if aaabbb then exit(aaa)\n else exit(bbb);\nend;\nbegin\n readln(n,thie,wei);\n readln(ch,ch,ch,ch);\n if ch='h' then ty:=-1\n else ty:=1;\n while not eoln do\n begin\n inc(sum);\n read(ch);\n if ch='0' then\n begin\n if (thie-wei)*ty>0 then thie:=thie+ty;\n if thie>n then thie:=n\n else if thie=0 then thie:=1;\n if n<>1 then begin\n wei:=wei+ty;\n if wei>n then begin wei:=n-1;ty:=-1;end\n else if wei=0 then begin wei:=2;ty:=1;end;\n end;\n end else\n begin\n if n<>1 then begin\n wei:=wei+ty;\n if wei>n then begin wei:=n-1;ty:=-1;end\n else if wei=0 then begin wei:=2;ty:=1;end;\n end;\n if ty=1 then\n begin\n if wei=1 then thie:=n\n else thie:=1;\n end else begin\n if wei=n then thie:=1\n else thie:=n;\n end;\n end;\n if wei=thie then\n begin\n writeln('Controller ',sum);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if (kk)and(h=1) then inc(m) else if ((m>1)and(m-1<>k))and(h=-1) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nend."}, {"source_code": "const INPUT = '';\n OUTPUT = '';\n MAX_N = 60;\n\nvar fi,fo:text;\n n,m,a,b,d:longint;\n s:string;\n\nfunction modn(x:longint):longint;\nbegin\n while x < 0 do x:=x+n;\n exit(x mod n);\nend;\n\nprocedure enter;\nbegin\n readln(fi,n,b,a);\n dec(a); dec(b);\n readln(fi,s);\n if s[4] = 'h' then d:=-1\n else d:=1;\n readln(fi,s); m:=length(s);\nend;\n\nprocedure solve;\nvar i:longint;\nbegin\n for i:=1 to m do begin\n if (a+d < 0) or (a+d > n-1) then d:=-d;\n a:=modn(a+d);\n if s[i] = '0' then begin\n if (b+d > -1) and (b+d < n) then b:=modn(b+d);\n end\n else\n if d = -1 then b:=n-1\n else b:=0;\n if a = b then begin\n writeln(fo,'Controller ',i);\n exit;\n end;\n end;\n writeln(fo,'Stowaway');\nend;\n\nbegin\n assign(fi,INPUT); reset(fi);\n assign(fo,OUTPUT); rewrite(fo);\n enter;\n solve;\n close(fo);\n close(fi);\nend."}, {"source_code": "{$R+}\nvar n,m,k,j,i:longint;\ns:string;\nprocedure step(var m,k:longint);\nbegin\n if j=0\n then dec(k)\n else inc(k);\n if j=0\n then if k1\n then m:=1\n else m:=n;\nend;\nbegin\n readln(n,m,k);\n readln(s);\n if s[4]='t'\n then j:=1{� ������}\n else j:=0; {� 墮���}\n readln(s);\n for i:=1 to length(s) do\n begin\n if ((j=0)and(k=1))or((j=1)and(k=n))\n then j:=(j+1)mod 2;\n if ((m=1)and(s[i]='0')and(k=2)and(j=0))or\n ((m=n)and(s[i]='0')and(k=n-1)and(j=1))\n then break;\n if s[i]='1'\n then step(m,k)\n else if j=0\n then begin\n if (m>k)and(m1)\n then dec(m);\n dec(k);\n end\n else begin\n if (m1)\n then dec(m);\n if (m>k)and(m k then m:=Min(m+1,n);\n If m < k then m:=Max(m-1,1);\n k:=k + d;\n If (k = 1) or (k=n) then d:=-d;\n End\n Else\n Begin\n For j:=i to Length(t)-1 do\n Begin\n k:=k+d;\n If (k = 1) or (k=n) then d:=-d;\n\n If t[j+1] = '0' then\n Begin\n i:=j;\n Break;\n End;\n\n End;\n\n If (k = 1) then m:=n;\n If (k = n) then m:=1;\n If (k <> 1) and (k <> n) then\n If d = 1 then\n m:=1\n Else\n m:=n;\n End;\n If m = k then Begin Writeln(g,'Controller ',i); Close(g); Exit; End;\n i:=i+1;\n End;\n Writeln(g,'Stowaway');\n Close(g);\nEnd;\n\nBegin\n ReadFile;\n Process;\nEnd.\n"}, {"source_code": "Var i,f,d,n,m,k:longint;\n c:char;\n s:string;\nBegin\n { assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(n,m,k);\n readln(s);\n if s[length(s)]='d'\n then f:=-1\n else f:=1;\n for i:=1 to 200 do\n begin\n Read(c);\n if(c<>'1')and(c<>'0')\n then break;\n if c='1'\n then begin\n inc(k,f);\n if k=0\n then begin\n k:=2;\n f:=1;\n end;\n if k=n+1\n then begin\n k:=n-1;\n f:=-1;\n end;\n if f=-1\n then m:=k+1\n else m:=k-1;\n if(k=1)or(k=n)\n then begin\n if m=k+1\n then m:=k-1\n else m:=k+1;\n end;\n if m=0\n then m:=n;\n if m=n+1\n then m:=1;\n end\n else begin\n d:=1;\n if (k>m)\n then d:=1\n else d:=2;\n if(d=1)and(m<>1)\n then dec(m);\n if(d=2)and(m<>n)\n then inc(m);\n inc(k,f);\n if k=0\n then begin\n k:=2;\n f:=1;\n end;\n if k=n+1\n then begin\n k:=n-1;\n f:=-1;\n end;\n if m=k\n then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n end;\n writeln('Stowaway');\nEnd."}, {"source_code": "var\n n,m,k,i: longint;\n s: shortstring;\n c: char;\n\n\n\nBegin\n\n readln(n,m,k);\n readln(s);\n i:=0;\n while not eoln do\n begin\n\n inc(i);\n read(c);\n if c = '0'\n then\n begin\n\n if s = 'to head'\n then\n begin\n if (m>k) and (m<>n) then inc(m);\n if (m1) then dec(m);\n dec(k);\n end\n else\n begin\n if (m>k) and (m<>n) then inc(m);\n if (m1) then dec(m);\n inc(k);\n end;\n\n end\n else\n begin\n\n if s = 'to head'\n then\n begin\n dec(k);\n m:=n;\n end\n else\n begin\n inc(k);\n m:=1;\n end;\n\n end;\n\n if k = 1 then s:='to tail';\n if k = n then s:='to head';\n\n if m=k\n then\n begin\n writeln('Controller ',i);\n halt;\n end;\n\n end;\n\n writeln('Stowaway');\n\nEnd.\n"}, {"source_code": "Program z74b;\nvar n,m,k,i:longint;\n\tp:shortint;\n c:char;\nbegin\n\treadln(n,m,k);\n for i:=1 to 4 do\n \tread(c);\n if c='h' then p:=-1\n else p:=1;\n readln;i:=0;\n while not(Eoln(input)) do\n begin\n \tread(c);inc(i);\n if c='0' then\n begin\n \tif p=-1 then\n begin\n \tif (m1) then dec(m);\n if (m>k)and(mk)and(m1) then dec(m);\n if k=n then p:=-1;\n k:=k+p;\n end;\n end\n else if c='1' then\n begin\n \tif p=-1 then\n begin\n \tif k=1 then p:=1;\n k:=k+p;\n if p=1 then m:=k-1;\n if p=-1 then m:=k+1;\n end\n else if p=1 then\n begin\n \tif k=n then p:=-1;\n k:=k+p;\n if p=1 then m:=k-1;\n if p=-1 then m:=k+1;\n end;\n end;\n if k=m then begin write('Controller ',i);halt;end;\n end;\n write('Stowaway');\nend."}, {"source_code": "const maxn=1000000;\n\nvar n,m,k,t,move,i:longint;\n s:string;\n ch:char;\n p:array [0..maxn+1] of longint;\n\nFunction min(a,b:longint):longint;\nbegin\n if ab then exit(a);\n exit(b);\nend;\n\nBEGIN\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n readln(n,k,m);\n readln(s);\n if s[4]='h' then move:=-1\n else move:=1;\n i:=0;\n while not eoln do begin\n read(ch);\n inc(i);\n if ch='0' then p[i]:=0\n else p[i]:=1;\n end;\n t:=i;\n if (m=n) and (move=1) then move:=-1;\n if (m=1) and (move=-1) then move:=1;\n for i:=1 to t do begin\n if ((m=2) and (k=1) and (move=-1) and (p[i]=0)) or ((p[i]=0)and (m=n-1) and (k=n) and (move=1)) then begin\n writeln('Controller ',i);\n halt;\n end;\n if p[i]=0 then begin\n if (k=n) or (k=1) then begin\n end\n else\n if mk then m:=n\n else m:=1;\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if (h=1) then m:=n\n else m:=1;\n end;\n if h=1 then dec(k)\n else inc(k);\n if k=n then h:=1;\n if k=1 then h:=2;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend;\nbegin\n nhap;\n xuli;\nend."}, {"source_code": "var\n n,m,k,i,pp,posk,poss:longint;\n f:boolean;\n s,s1:ansistring;\n\nbegin\n readln(n,m,k);\n readln(s);\n if s='to head' then f:=true;\n posk:=k;\n poss:=m;\n readln(s1);\n pp:=length(s1);\n\n for i:=1 to pp do if s1[i]='0' then\n begin\n if f then\n begin\n if (poss>1) then dec(poss);\n if (posk>1) then dec(posk);\n if posk=1 then f:=false;\n end else\n begin\n if (poss1) then dec(posk);\n if posk=1 then f:=false;\n end;\n if f then if posk1 then poss:=1 else poss:=2;\n if poss=posk then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "uses math;\nvar i,n,m,k:longint;\n s:ansistring;\n v:boolean;\n begin\n readln(n,m,k);\n readln(s);\n if s[4]='h' then v:=true\n else v:=false;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if s[i]='1' then\n begin\n if (k=1) then v:=false\n else if k=n then v:=true;\n if v then k:=k-1\n else k:=k+1;\n if (k=1) then v:=false\n else if k=n then v:=true;\n\n if (k=1) then m:=n\n else if (k=n) then m:=1\n else if v then m:=n\n else m:=1;\n\n end\n else begin\n if v and (mk then m:=min(m+1,n)\n else m:=max(m-1,1);\n\n if (k=1) then v:=false\n else if k=n then v:=true;\n if v then k:=k-1\n else k:=k+1;\n if (k=1) then v:=false\n else if k=n then v:=true;\n\n if m=k then begin writeln('Controller ',i); halt(0); end;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": " {$R+,S+,Q+,I+,O-}\n {R-,S-,Q-,I-,O+}\n var\n dir,n,m,k,i,j,ans,p: longint;\n t,s: ansistring;\n ok: boolean;\n wh: array [0..333] of longint;\n f: array [0..333,0..333] of boolean;\n begin\n // assign(input,'in'); reset(input);\n // assign(output,'out'); rewrite(output);\n readln(n,m,k);\n readln(t);\n readln(s);\n p:=length(s);\n if t = 'to head' then dir:=-1\n else dir:=1;\n wh[0]:=k;\n for i:=1 to p do\n begin\n wh[i]:=wh[i-1]+dir;\n if (wh[i] < 1) or (wh[i] > n) then\n begin\n dir:=-dir;\n wh[i]:=wh[i-1]+dir;\n end;\n end;\n fillchar(f,sizeof(f),False);\n f[0,m]:=True;\n ans:=p;\n for i:=1 to p do\n begin\n if s[i] = '1' then\n begin\n for j:=1 to n do\n if j <> wh[i] then f[i,j]:=True;\n end else\n for j:=1 to n do\n if (j <> wh[i]) and (j <> wh[i-1]) then\n if f[i-1,j] or f[i-1,j-1] or f[i-1,j+1] then\n f[i,j]:=True;\n ok:=False;\n for j:=1 to n do ok:=ok or f[i,j];\n if not ok then\n begin\n ans:=i;\n break;\n end;\n end;\n if ans = p then writeln('Stowaway')\n else writeln('Controller ',ans);\n close(input);\n close(output);\n end.\n\n"}, {"source_code": "var a:array [1..1000] of longint;\n b,n,i,j,k,d,m,max:longint;\n s,p:string;\n\n begin\n readln(n,k,m);\n readln(s);\n readln(p);\n for i:=1 to length(p) do\n begin\n if p[i]='1' then\n begin\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end else\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n\n if (s[4]='h') then k:=m+1\n else k:=m-1;\n if (m=1) or (m=n) then\n begin\n if k=m+1 then k:=m-1\n else k:=m+1;\n end;\n if k=0 then k:=n;\n if k=n+1 then k:=1;\n end else\n begin\n\n d:=1;\n if (m>k) then d:=1\n else d:=2;\n\n if (d=1) and (k<>1) then dec(k);\n if (d=2) and (k<>n) then inc(k);\n\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end else\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n if k=m then begin\n writeln('Controller ',i);\n halt;\n end;\n\n\n\n\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var n,m,k,d,i,l:integer;\n s:string[202];\n { a:array[1..55]of integer; }\nbegin\nreadln(n,k,m);\nreadln(s);\nif s='to head' then d:=-1 else d:=1;\nreadln(s);\n l:=length(s);\n for i:=1 to l do\n begin\n if m=1 then d:=1;\n if m=n then d:=-1;\n m:=m+d;\n if s[i]='0' then\n begin\n if (k+d<=n)and(d+k>=1) then k:=k+d;\n end\nelse\n begin\n if d=1 then k:=1 else k:=n;\n end;\n\n if m=k then begin writeln('Controller ',i); exit; end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "var n,m,k,i,c,l,z:integer;\na:array[1..200] of char;\ns:string;\n\nprocedure step1;\nbegin\nif m1 then dec(m);\nif m>k then\n if m1 then m:=1 else m:=n;\nif c=-1 then\n if k<>n then m:=n else m:=1;\nend;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nwhile not eoln do\n begin\n inc(l);\n read(a[l]);\n end;\nif s='to head' then c:=-1 else c:=1;\nfor i:=1 to l do\n begin\n if a[i]='0' then step1 else step2;\n if (k=1) or (k=n) then c:=-c;\n if m=k then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nwriteln('Stowaway');\nend."}, {"source_code": "{uses crt;\n}const nn=300;\nvar m,t,n,i,j,k,p,max,kolvag:longint;\ncc:char;\ns,nap:string; flag:boolean;\nnapcon,contr,zayaz:array[0..nn] of longint;\nbegin {clrscr;\n assign(input,'input.txt');reset(input);\n} readln (kolvag,m,k);\n readln(nap);\n readln(s);\n n:=length(s);\n if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;\n contr[1]:=k;\n for i:=2 to n do\n begin contr[i]:=contr[i-1]+napcon[i-1];\n if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];\n\n end;\n\nif s[1]='0' then zayaz[1]:=m;\nif s[1]='1' then zayaz[1]:=contr[1]-napcon[2];\nfor i:=2 to n do\n begin\n if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)\n then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];\n if s[i-1]='1' then zayaz[i]:=contr[i-1];\n\n\n end;\n\n{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }\nfor i:=1 to n do if (contr[i]=zayaz[i])and(s[i-1]='0') then begin flag:=true;break;end;\n if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');\n\n\n\n\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar cm,n,i,k,m,r:integer;\ns,t:string;\nc:char;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nreadln(t);\nc:=s[4];\n\nif (c='h') and (m>k) then m:=n\nelse\nif (c='h') and (mk then begin\n if M1 then\n dec(M);\n end;\n end;\n if r=1 then\n dec(k)\n else\n inc(k);\n if k=1 then\n r:=0;\n if k=N then\n r:=1;\n if s[i]='1' then begin\n if r=1 then begin\n if k=N then\n M:=1\n else\n M:=N;\n end\n else begin\n if k=1 then\n M:=N\n else\n M:=1;\n end;\n end;\n if k=M then begin\n writeln('Controller ',i);\n halt(0);\n end;\nend;\nwriteln('Stowaway');\nend."}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n n,m,k,i:longint;\n s,t:string;\n \n procedure go;\n begin\n if (k = 2) and (s[4] = 'h') then\n begin\n k:=1;\n s[4]:='t';\n end else\n if (k = n-1) and (s[4] = 't') then\n begin\n k:=n;\n s[4]:='h';\n end else\n if s[4] = 'h' then dec(k) else inc(k);\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n readln(n,m,k);\n readln(s);\n readln(t);\n for i:=1 to length(t) do\n begin\n if t[i] = '0' then\n begin\n if m < k then m:=1 else m:=n;\n go;\n end else\n begin\n go;\n if k = 1 then m:=n else\n if k = n then m:=1 else\n if s[4] = 'h' then m:=n else m:=1;\n end;\n if k = m then\n begin\n writeln('Controller ',i);\n exit;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var n,c,h,k:longint;\ndir,time:string;\ncatched:boolean;\nprocedure move(var x:longint;moveTo:string);begin\n if (moveTo='to head') then\n if (x<=1)\n then exit\n else dec(x)\n else if (moveTo='to tail') then\n if (x>=n) then exit\n else inc(x);\nend;\nprocedure movec(moveTo:string); begin\n if (moveTo='to head') then\n if (c=1) then begin dir:='to tail';movec(dir);end else dec(c)\n else if (moveTo='to tail') then\n if (c=n) then begin dir:='to head';movec(dir);end else inc(c);\nend;\nprocedure checkNewPositions; begin\n if (h=c) then begin\n writeln('Controller ',k);\n halt;\n end;\nend;\nprocedure getOut; begin\n if (length(time)=1) then begin writeln('Stowaway');halt;end;\n if (dir='to head') then h:=0;\n if (dir='to tail') then h:=n+1;\nend;\nprocedure getOn; begin\n if (dir='to head') then\n if (c1) then h:=1 else h:=n;\nend;\nprocedure countNewMove; begin\n if (dir='to head') then begin\n if (hc) then begin\n move(h,'to tail');\n movec(dir);\n exit;\n end\n end\n else if (dir='to tail') then begin\n if (h>c) then begin\n move(h,'to tail');\n movec(dir);\n exit;\n end;\n if (h0) do begin\n if (time[1]='0') then begin\n //train moves - checking cotroller direction\n countNewMove;\n checkNewPositions;\n end\n else begin\n getOut;\n countNewMove;\n getOn;\n checkNewPositions;\n end;\n delete(time,1,1);\n inc(k);\n end;\nend."}, {"source_code": "{ fp }\nVar\n n,x,y,i,j,m:longint;\n s : string;\n ok : boolean;\n\n Procedure next;\n begin\n if ok then y := y-1\n else y := y+1;\n If (y=1) or (y=n) then ok := not ok;\n End;\n\n\n begin\n REadLn(n,x,y);\n REadLn(s);\n ok:= (s[4]='h');\n ReadLn(s);\n m := length(s);\n For i := 1 to m do\n Begin\n\n If s[i]='0' then\n Begin\n if ok and (x1) then x := x-1 else\n If ok and (x>y) and (x<>n) then x := x+1 else\n If (ok=false) and (x>y) and (x<>n) then x := x+1 else\n If (ok=false) and (x1) then x := x-1;\n next;\n If x=y then\n Begin\n WriteLn('Controller ',i);\n halt(0);\n End;\n end else\n Begin\n next;\n If ok then\n Begin\n x := n;\n If x=y then x := 1;\n End else\n Begin\n x := 1;\n If x=y then x := n;\n End;\n End;\n// WriteLn(i,' ',x,' ',y);\n End;\n WriteLn('Stowaway');\n end."}, {"source_code": "Var e,n,m,k,i:LongInt;\ns:string;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n Readln(n,m,k);\n readln(s);\n if s[4]='h'\n then e:=-1\n else e:=1;\n Readln(s);\n for i:=1 to Length(s) do\n begin\n if s[i]='1'\n then begin\n if ((k=1)and(e=-1))or((k=n)and(e=1))\n then e:=e*(-1);\n k:=k+e;\n if e=1\n then m:=1\n else m:=n;\n end\n else begin\n if (m<>1)and(m<>n)\n then begin\n if e=1\n then begin\n if m>k\n then m:=n\n else m:=1;\n end\n else begin\n if mco) and (z+1<=n) then inc(z)\n else If (c='t') and (z0) then dec(z)\n else If (c='h') and (z0) then dec(z)\n else If (c='h') and (z>co) and (z+1<=n) then inc(z);\n end;\n\nbegin\n{reset(input,'Input.txt');\nrewrite(output,'Output.txt');}\nreadln(n,z,co);\nreadln(s);\nc:=s[4];\nIf (c='t') and (co=n) then c:='h';\nIf (c='h') and (co=1) then c:='t';\nreadln(s);\n\nFor i:=1 to length(s)-1 do\nbegin\n If s[i]='1' then\n begin\n move(c);\n think;\n end\n else\n begin\n movez;\n If z=co then\n begin\n writeln('Controller',' ',i);\n exit;\n end;\n move(c);\n //writeln(z,' ',co);\n If z=co then\n begin\n writeln('Controller',' ',i);\n exit;\n end;\n end;\nend;\nwriteln('Stowaway');\nend.\n"}, {"source_code": "var n,z,k,i,h:byte;\n s:char;\nhead,flag:boolean;\na:array [0..200] of 0..1;\n \nbegin\nreadln(n,z,k);\nread(s);\nread(s);\nread(s);\nreadln(s);\nif s='h' then head:=true;\ni:=0;\nread(s);\nrepeat\n inc(i);\n A[i]:=ord(s)-ord('0');\n read(s);\nuntil not(s in ['0'..'1']);\nh:=i;\nflag:=false;\nfor i:=1 to h-1 do\nbegin\n if k=z then \n begin\n flag:=true;\n break;\n end;\n if A[i]=0 then\n begin\n if (z>k) and (z1) then dec(z);\n if head then dec(k)\n else inc(k);\n end\n else\n begin\n if head then dec(k)\n else inc(k);\n if head then\n if k=n then z:=1\n else z:=n\n else\n if k=1 then z:=n\n else z:=1;\n end; \n \n if k=1 then head:=false;\n if k=n then head:=true; \n if k=z then \n begin\n flag:=true;\n break;\n end;\nend;\nif flag then writeln('Controller ',i)\nelse writeln('Stowaway');\nend. "}, {"source_code": "var\nok:boolean;\ni,j,n,m,k,q,pk:longint;\ns,nap:ansistring;\nu,e:array[0..1000]of boolean;\n begin\n readln(n,m,k);\n readln(nap);\n readln(s);\n if nap[length(nap)]='d' then q:=-1\n else q:=1;\n\n fillchar(u,sizeof(u),false);\n u[m]:=true;\n\n for i:=1 to length(s) do\n begin\n fillchar(e,sizeof(e),false);\n if k+q=0 then\n begin\n q:=1;\n end\n else if k+q>n then\n begin\n q:=-1;\n end;\n\n pk:=k;\n k:=k+q;\n\n if s[i]='0' then\n begin\n for j:=1 to n do\n if u[j] then\n begin\n if (j>1)and(pk<>j-1)and(k<>j-1) then e[j-1]:=true;\n if (jj+1)and(k<>j+1) then e[j+1]:=true;\n if j<>k then e[j]:=true;\n end;\n end\n else\n begin\n for j:=1 to n do\n if (j<>k) then e[j]:=true;\n end;\n\n ok:=false;\n for j:=1 to n do\n if e[j] then ok:=true;\n\n if not ok then\n begin\n writeln('Controller ',i);\n halt(0);\n end;\n\n u:=e;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var\n n,m,k,i,p,f:longint;\n s:string;\n c:char;\n begin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n readln(n,k,m);\n readln(s);\n if s='to head' then\n p:=-1\n else\n p:=1;\n i:=0;\n while eoln<>true do\n begin\n\n read(c);\n inc(i);\n if c='0' then\n begin\n if p=-1 then\n if (k-1>m)and(m<>1) then\n dec(k)\n else\n if (m=1)and(2>k-1)and(k-1>0) then\n dec(k)\n else\n if (m=1)and(k=2)and(k+10)and(m=k+1) then\n dec(k);\n if p=1 then\n if (k+1n) then\n inc(k)\n else\n if (m=n)and(m-1>k+1)and(k+10) then\n dec(k)\n else\n if m=n then\n f:=1\n else\n if (k-1>0)and(m=k+1) then\n dec(k)\n else\n if (k+1<=n)and(m=k-1) then\n inc(k);\n if m=k then\n begin\n writeln('Controller',' ',i);\n halt;\n end;\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if m=k then\n begin\n writeln('Controller',' ',i);\n halt;\n end;\n end;\n if c='1' then\n begin\n k:=0;\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if p=1 then\n\n if m-2>0 then\n k:=m-2\n else\n k:=m-1;\n if p=-1 then\n if m+2<=n then\n k:=m+2\n else\n k:=m+1;\n\n end;\n\n end;\n writeln('Stowaway');\n end.\n"}, {"source_code": "var\na,s1:string;\ni,j,k,l,n,m:longint;\nbegin\nreadln(n,m,k);\nreadln(s1);\nread(a);\nfor i:=1 to length(a) do\n begin\n if k=1 then s1:='to tail';\n if k=n then s1:='to head';\n if (a[i]='1') and (i=length(a)) then\n begin\n write('Stowaway');\n exit;\n end;\n if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then\n begin\n write('Controller ',i);\n exit;\n end;\n if mk then m:=n;\n if (a[i]='1') and (s1='to head') then m:=n;\n if (a[i]='1') and (s1='to tail') then m:=1;\n if s1='to tail' then inc(k)\n else dec(k);\n end;\nend.\n"}, {"source_code": "Program\t\t\tBB;\nvar\nk,p,s,c,m,time,i,n : longint;\nlen,rp : string;\nflag : Boolean;\nbegin\n{Assign(input,'B.in');Assign(output,'B.out');\nreset(input);rewrite(output);}\n\treadln(n,m,k);\n\ts:=m;c:=k;\n\treadln(Rp);\n\tif Rp[4]='h' then p:=-1 else p:=1;\n\treadln(len);\n\ttime :=0;flag := false;\n\tfor i :=1 to length(len) do\n\tbegin\n\t\tif len[i]='1' then\n\t\tbegin\n\t\t\tif p=-1 then begin\n if c<>1 then\n s := n else\n s := 1;\n end else\n begin\n if c<>n then s :=1 else\n s := n;\n end;\n\t\tend else\n begin\n if s>c then begin\n s:=s+1;\n if s=n+1 then s := n;\n end\n else\n if sn then yy:=n;\n if abs(xx-x)n then y:=n\n else y:=1\n else if x<>1 then y:=1\n else y:=n;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var\n px,o,n,x,y,i,m:longint;\n s:ansistring;\n\nbegin\n readln(n,x,y);\n readln(s);\n if (s[4]='h')then o:=1 else o:=2;\n readln(s);\n m:=length(s);\n for i:=1 to m-1 do begin\n if (s[i]='0')then begin\n px:=x;\n if (x=1)then inc(x)else\n if (x=n)then dec(x)else\n if (abs(x-1-y)>abs(x+1-y))then dec(x)else\n inc(x);\n if (x=y)then x:=px;\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (x=y)and(x=px)then begin writeln('Controller ',i);exit;end else\n if (x=y)then x:=px;\n end else begin\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (y=n)then x:=1 else\n if (y=1)then x:=n else\n if (o=1)then x:=n else\n x:=1;\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if f then begin\n if s[i]='1' then begin\n m:=1;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "program problemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n orient,n,m,k,i,j,p:integer;\n s,q:string;\nbegin\n readln(n,m,k);\n readln(s);\n readln(q);\n if s='to head' then orient:=-1 else orient:=1;\n p:=-1;\n for i:=1 to length(q) do begin\n case q[i] of\n '0':begin\n if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n if k=m then begin\n p:=k;\n break;\n end;\n end;\n '1':begin\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n m:=k-orient;\n if (m>n) then m:=1;\n if (m<1) then m:=n;\n if m=k then begin\n p:=k;\n break;\n end;\n end;\n end;\n// writeln(m,' ',k);\n end;\n if p=-1 then writeln('Stowaway') else writeln('Controller ',i);\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a:Array[0..3000] of Integer;\n used:Array[0..3000,0..3000] of Boolean;\n s,w:String;\n n,m,k,n1,i,j,f,ans:Integer;\nProcedure Dfs(i,j:Integer);\nVar\n r:Integer;\nBegin\n used[i,j]:=true;\n If a[i]=j Then Exit;\n If i>ans Then ans:=i;\n If i=n1 Then Exit;\n If w[i]='0' Then Begin\n If not(used[i+1,j]) Then Dfs(i+1,j);\n If (j>1) and (not(used[i+1,j-1])) and (a[i]<>j-1) Then Dfs(i+1,j-1);\n If (jj+1) Then Dfs(i+1,j+1);\n End\n Else Begin\n For r:=1 To n Do\n If not(used[i+1,r]) Then Dfs(i+1,r);\n End;\nEnd;\nBegin\n ReadLn(n,m,k);\n ReadLn(s);\n Read(w);\n If s[4]='h' Then f:=0\n Else f:=1;\n j:=k;\n n1:=length(w);\n For i:=1 To n1 Do Begin\n a[i]:=j;\n If f=1 Then j:=j+1\n Else j:=j-1;\n If j=0 Then Begin\n f:=1;\n j:=2;\n End;\n If j>n Then Begin\n f:=0;\n j:=n-1;\n End;\n End;\n ans:=0;\n Dfs(1,m);\n If ans=n1 Then Write('Stowaway')\n Else Write('Controller ',ans);\nEnd.\n"}, {"source_code": "Var n,z,k,dx,l,i:Integer;\n s,v:String;\n\nProcedure KGO;\nBegin\n Inc (k,dx);\n If k=0 then Begin dx:=-dx; k:=2; Exit End;\n If k=n+1 then Begin dx:=-dx; k:=n-1 End;\nEnd;\n\nProcedure ZGO;\nBegin\n If v[i]='0'\n then Begin\n If z>k\n then Begin If z<>n then Inc (z) End\n else Begin If z<>1 then Dec (z) End;\n End\n else Begin\n If dx=1\n then If k=1 then z:=n else z:=1\n else If k=n then z:=1 else z:=n;\n End;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n Readln (n,z,k);\n Readln (s);\n If s[4]='h'\n then dx:=-1\n else dx:=1;\n Readln (v);\n l:=Length (v);\n For I:=1 to l do\n Begin\n If v[i]='0' then Begin ZGO; KGO; End\n else Begin KGO; ZGO; End;\n If k=z then Begin Writeln ('Controller ',i); Exit End;\n End;\n Writeln ('Stowaway')\nEnd."}, {"source_code": " var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\n tt : longint;\n s : String;\n q : char;\n a : Array[0..1000]of longint;\n b : Array[0..70,0..70,-5..5,0..201]of longint;\n\n function maxx(x,y : Longint):longint;\n begin\n if x > y then y := x;\n maxx := y;\n end;\n function rec(x,y,shag,z : longint) : longint;\n var i,tr,h,ht,shah: Longint;\n begin\n\n if x = y then\n begin\n b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);\n if b[x,y,shag,z] > max then max := b[x,y,shag,z];\n exit(b[x,y,shag,z]);\n end;\n\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n max := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\n\n if b[x,y,shah,z] > max then max := b[x,y,shah,z];\n end;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max >= f then writeln('Stowaway')\n else writeln('Controller ',max);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if f then begin\n if s[i]='1' then begin\n m:=1;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n dir,n,m,k,i,j,ans,p: longint;\n t,s: ansistring;\n ok: boolean;\n wh: array [0..333] of longint;\n f: array [0..333,0..333] of boolean;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(n,m,k);\n readln(t);\n readln(s);\n p:=length(s);\n if t = 'to head' then dir:=-1\n else dir:=1;\n wh[0]:=k;\n for i:=1 to p do\n begin\n wh[i]:=wh[i-1]+dir;\n if (wh[i] < 1) or (wh[i] > n) then\n begin\n dir:=-dir;\n wh[i]:=wh[i-1]+dir;\n end;\n end;\n fillchar(f,sizeof(f),False);\n f[0,m]:=True;\n ans:=p;\n for i:=1 to p do\n begin\n if s[i] = '1' then\n begin\n for j:=1 to n do\n if j <> wh[i] then f[i,j]:=True;\n end else\n for j:=1 to n do\n if (j <> wh[i]) and (j <> wh[i-1]) then\n if f[i-1,j] or f[i-1,j-1] or f[i-1,j+1] then\n f[i,j]:=True;\n ok:=False;\n for j:=1 to n do ok:=ok or f[i,j];\n if not ok then\n begin\n ans:=i;\n break;\n end;\n end;\n if ans = p then writeln('Stowaway')\n else writeln('Controller ',ans);\n close(input);\n close(output);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,n,m,k,z,c : Integer;\n s : string;\n nap : Boolean;\nbegin\n Readln(n,m,k);\n Readln(s);\n if s[4]='t' then nap:=True;\n if s[4]='h' then nap:=false;\n Readln(s);\n if (m>k) then z:=n\n else z:=1;\n c:=k;\n for i:=1 to length(s) do\n begin\n if nap then c:=c+1\n else c:=c-1;\n if c=0 then\n begin\n c:=2;\n nap:=True;\n end;\n if c=n+1 then\n begin\n c:=n-1;\n nap:=False;\n end;\n if s[i]='1' then\n begin\n if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1\n else z:=n;\n end;\n if z=c then\n begin\n Writeln('Controller ', i);\n Readln;\n Exit;\n end;\n end;\n Writeln('Stowaway');\n Readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,O+,S+}\nvar\n n,m,k,i,l : longint;\n s :string;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readlN(n,m,k);\n readln(s);\n if s[4]='h' then\n l:=-1\n else\n l:=1;\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if l=-1 then\n m:=n\n else\n m:=1;\n end\n else\n begin\n if mn then\n m:=n;\n end;\n k:=k+l;\n if m=k then\n begin\n writeln('Controller ',i);\n halt;\n end;\n if k=1 then\n l:=1;\n if k=n then\n l:=-1;\n end;\n writeln('Stowaway');\nend.\n\n\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n VtC,mv,n,luu:longint;\n State:string;\n xet,cungchieu:boolean;\n f:text;\nprocedure nhap;\nvar m,k:longint;St:string;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n,m,k);\n readln(f,St);\n readln(f,State);\n if St='to head' then mv:=-1\n else mv:=1;\n if mv*(m-k)>0 then cungchieu:=true\n else cungchieu:=false;\n VtC:=k;\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n if xet then writeln(f,'Stowaway')\n else\n begin\n write(f,'Controller ');\n writeln(f,luu);\n end;\n close(f);\nend;\nprocedure process;\nvar cuoi,i,reach1,p,j,S1:longint;\nbegin\n i:=1;\n reach1:=0;\n while i<=length(State) do\n begin\n if State[i]='1' then cungchieu:=false;\n for j:=i+1 to length(State) do\n if State[j]='1' then\n begin\n reach1:=j-i+1;\n break;\n end;\n if mv=1 then cuoi:=n\n else cuoi:=1;\n if not cungchieu then S1:=n+abs(cuoi-vtC)-1\n else S1:=abs(cuoi-vtC);\n if State[i]='0' then\n if S1=length(State)+1 then xet:=true\n else\n begin\n xet:=false;\n luu:=i;\n end;\nend;\nbegin\n nhap;\n process;\n xuat;\nend.\n\n"}, {"source_code": "var\n i,j,n,m,k,p:longint;\n napr,t:string;\nBEGIN\nreadln(n,m,k);\nreadln(napr);\nreadln(t);\nif (napr='to head') then p:=-1 else p:=1;\nfor i:=1 to length(t) do\n begin\n {Zayac}\n if (t[i]='0') then\n begin\n if (p=-1)and(m>k)and(m+1<=n) then inc(m);\n if (p=-1)and(m=2) then dec(m);\n if (p=1)and(m>k)and(m+1<=n) then inc(m);\n if (p=1)and(m=2) then dec(m); \n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n end\n else\n begin\n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n if (p=-1)and(k<>n) then m:=n;\n if (p=-1)and(k=n) then m:=1;\n if (p=1)and(k<>1) then m:=1;\n if (p=1)and(k=1) then m:=n;\n end;\n {End game?} \n if (m=k) then \n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nwriteln('Stowaway');\nEND."}, {"source_code": "uses math;\n\nVar n:longint;\n z,k:longint;\n i,j:longint;\n s:string;\n na:longint;\n\nProcedure jump(ii:longint);\n\nBegin\n\nif s[i]='0' then begin if na=1 then z:=min(z+1,n);\n if na=-1 then z:=max(1,z-1);\n\n k:=k+na; if k=n then na:=-1;\n if k=1 then na:=1;\n\n if k=z then begin Writeln('Controller ',ii);\n halt;end;end;\nif s[i]='1' then begin if na=1 then z:=1;\n if na=-1 then z:=n;\n\n k:=k+na; if k=n then na:=-1;\n if k=1 then na:=1;\n\n if k=z then begin Writeln('Controller ',ii);\n halt;end;end;\n\nend;\n\nBegin\n\nReadln(n,z,k);\nReadln(s);\n\nif s[4]='t' then na:=1 else na:=-1;\n\nReadln(s);\n\nfor i:=1 to length(s)-1 do jump(i);\n\nWriteln('Stowaway');\n\nEnd.\n\n\n\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to length(s) do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If k = 1 Then\n dir := 'to tail';\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k = 1 Then\n dir := 'to tail';\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k = n Then\n dir := 'to head';\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If k = n Then\n dir := 'to head';\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n m := n;\n k := k-1;\n If k = 1 Then\n dir := 'to tail';\n End\n Else\n Begin\n m := 1;\n k := k+1;\n If k = n Then\n dir := 'to head';\n End;\n End;\n Writeln('Stowaway');\nEnd.\n\n"}, {"source_code": "var\n i,n,m,k:integer;\n s:string;\n d:boolean;\nBegin\n readln(n,m,k);\n readln(s);\n if s='to head' then d:=true else d:=false;\n if (k=1)and(d=true)then d:=false;\n if (k=n)and(d=false)then d:=true;\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='0' then\n begin\n if (d=true)and((m1))then dec(m) else\n if (d=true)and((m>k)and(m<>n))then inc(m);\n if (d=false)and((m1))then dec(m) else\n if (d=false)and((m>k)and(m<>n))then inc(m);\n if d=true then dec(k) else inc(k); \n end else\n begin\n if d=true then dec(k) else inc(k);\n if (d=true)and(k<>n)then m:=n else\n if (d=false)and(k<>1) then m:=1 else\n if (d=true)and(k=n) then m:=1 else\n if (d=false)and(k=1) then m:=1;\n end;\n if k=m then Begin write('Controller ',i); exit; end;\n if k=n then d:=true;\n if k=1 then d:=false;\n end;\n write('Stowaway');\n end."}], "negative_code": [{"source_code": "var\nmax,f,n,m,i,j,k,off,tr: longint;\ntt : longint;\ns : String;\nq : char;\na : Array[0..1000]of longint;\nb : Array[0..70,0..70,-5..5,0..201]of longint;\nfunction rec(x,y,shag,z : longint) : longint;\nvar i,tr,h,ht,shah: Longint;\nbegin\n if z > max then max := z;\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n if x = y then\n begin\n b[x,y,shag,z] := z - 1;\n exit(b[x,y,shag,z]);\n end;\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y;\n end;\n if h = y then tr := z\n else if ht = h then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y;\n end;\n if h = y then tr := z\n else if h = ht then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y;\n end;\n if ht = x then tr := z\n else\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\nend;\n\n\n begin\n readln(n,m,k);\n readln(s);\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,k,off,1);\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max);\n end.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,n,m,k,z,c : Integer;\n s : string;\n nap : Boolean;\nbegin\n Readln(n,m,k);\n Readln(s);\n if s[4]='t' then nap:=True;\n if s[4]='h' then nap:=false;\n Readln(s);\n if m>k then z:=n\n else z:=1;\n c:=k;\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1\n else z:=n;\n end;\n if nap then c:=c+1\n else c:=c-1;\n if z=c then\n begin\n Writeln('Controller ', i);\n Readln;\n Exit;\n end;\n if c=0 then\n begin\n c:=1;\n nap:=True;\n end;\n if c=n+1 then\n begin\n c:=n;\n nap:=False;\n end;\n end;\n Writeln('Stowaway');\n Readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if (k=m) or (m<1) or (m>n) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "uses math;\nvar i,n,m,k:longint;\n s:string;\n v:boolean;\n begin\n readln(n,m,k);\n readln(s);\n if s[4]='h' then v:=true\n else v:=false;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if s[i]='1' then\n begin\n if (k=1) then m:=n\n else if (k=n) then m:=1\n else if v then m:=n\n else m:=1;\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n end\n else begin\n if v and (mk then m:=min(m+1,n)\n else m:=max(m-1,1);\n\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n if m=k then begin writeln('Controller ',i); halt(0); end;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,n,m,k,z,c : Integer;\n s : string;\n nap : Boolean;\nbegin\n Readln(n,m,k);\n Readln(s);\n if s[4]='t' then nap:=True;\n if s[4]='h' then nap:=false;\n Readln(s);\n if m>k then z:=n\n else z:=1;\n c:=k;\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if (nap and (c<>1)) or (not nap and (c<>n)) then z:=1\n else z:=n;\n end;\n if nap then c:=c+1\n else c:=c-1;\n if z=c then\n begin\n Writeln('Controller ', i);\n Readln;\n Exit;\n end;\n if c=0 then\n begin\n c:=1;\n nap:=True;\n end;\n if c=n+1 then\n begin\n c:=n;\n nap:=False;\n end;\n end;\n Writeln('Stowaway');\n Readln;\nend.\n"}, {"source_code": "var\nb:array[1..10000] of char;\nn,m,i,k,l,j,p:longint;\ns:string;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to tail' then p:=1 else p:=0;\ni:=0;\nwhile not eoln do\n begin\n inc(i);\n read(b[i]);\n end;\nif p=0 then l:=1\nelse l:=n;\nfor j:=1 to i do\n begin\n if b[j]='0' then\n if p=0 then\n dec(k) else inc(k) else\n if p=0 then l:=n else l:=1;\n if k=l then begin write('Controller ',j); exit;end;\n if k=n then p:=0;\n if k=1 then p:=1;\n end;\nwrite('Stowaway');\nend."}, {"source_code": "var\n n,m,k,i,p,f:longint;\n s:string;\n c:char;\n begin\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(n,k,m);\n readln(s);\n if s='to head' then\n p:=-1\n else\n p:=1;\n i:=0;\n while eoln<>true do\n begin\n\n read(c);\n inc(i);\n if c='0' then\n begin\n if p=-1 then\n if (k-1>m)and(m<>1) then\n dec(k)\n else\n if (m=1)and(2>k-1)and(k-1>0) then\n dec(k)\n else\n if (m=1)and(k=2)and(k+10)and(m=k+1) then\n dec(k);\n if p=1 then\n if (k+1n) then\n inc(k)\n else\n if (m=n)and(m-1>k+1)and(k+10) then\n dec(k)\n else\n if m=n then\n f:=1\n else\n if (k-1>0)and(m=k+1) then\n dec(k)\n else\n if (k+1<=n)and(m=k-1) then\n inc(k);\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if m=k then\n begin\n writeln('Controller',' ',i);\n halt;\n end;\n end;\n if c='1' then\n begin\n k:=0;\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if p=1 then\n\n if m-2>0 then\n k:=m-2\n else\n k:=m-1;\n if p=-1 then\n if m+2<=n then\n k:=m+2\n else\n k:=m+1;\n\n end;\n\n end;\n writeln('Stowaway');\n end.\n"}, {"source_code": "Program\t\t\tBB;\nvar\nk,p,s,c,m,time,i,n : longint;\nlen,rp : string;\nflag : Boolean;\nbegin\n{Assign(input,'B.in');Assign(output,'B.out');\nreset(input);rewrite(output);}\n\treadln(n,m,k);\n\ts:=m;c:=k;\n\treadln(Rp);\n\tif Rp[4]='h' then p:=-1 else p:=1;\n\treadln(len);\n\ttime :=0;flag := false;\n\tfor i :=1 to length(len) do\n\tbegin\n\t\tif len[i]='1' then\n\t\tbegin\n\t\t\tif p=-1 then s := n else s :=1;\n\t\tend;\n if i<>1 then\n\t\tbegin\n\t\t\tc:=c+p;\n\t\t\tif c=0 then\n\t\t\tbegin c:=2;p:=-p; end else\n\t\t\tif c=n+1 then\n\t\t\tbegin c :=n-1;p:=-p;end;\n\t\tend;\n\t\ttime := time+1;\n\t\tif s=c then begin flag := true;break;end;\n\tend;\n\tif flag=false then writeln('Stowaway') else\n\twriteln('Controller ',time);\n{Close(input); Close(output);}\n\nend.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : ansistring;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n f:=false;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if (k-m1 then dec(m);\n if s[i]='1' then f:=true;\n if (not f)and(k=m) then\n begin\n writeln('Controller ',i);\n halt;\n end;\n inc(k,h);\n if (not f)and(k=m) then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nend."}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if (kk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to length(s) do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k < 1 Then\n Begin\n k := 2;\n dir := 'to tail';\n End;\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k > n Then\n Begin\n k := n-1;\n dir := 'to head';\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n m := n;\n k := k-1;\n End\n Else\n Begin\n m := 1;\n k := k+1;\n End;\n End;\n Writeln('Stowaway');\nEnd.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if (kk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": " var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\n tt : longint;\n s : String;\n q : char;\n a : Array[0..1000]of longint;\n b : Array[0..70,0..70,-5..5,0..201]of longint;\n\n function maxx(x,y : Longint):longint;\n begin\n if x > y then y := x;\n maxx := y;\n end;\n function rec(x,y,shag,z : longint) : longint;\n var i,tr,h,ht,shah: Longint;\n begin\n\n if x = y then\n begin\n b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);\n if b[x,y,shag,z] > max then max := b[x,y,shag,z];\n exit(b[x,y,shag,z]);\n end;\n\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\n\n if b[x,y,shah,z] > max then max := b[x,y,shah,z];\n end;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max >= f then writeln('Stowaway')\n else writeln('Controller ',max);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n if k=n then f:=false;\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n if k=1 then f:=true;\n end;\n if f then begin\n if s[i]='1' then begin\n if (k>=n div 2) and (k>2) then m:=1 else m:=n;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=n div 2) and (k=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2+1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2-1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var\n n,m,k,i,pp,posk,poss:longint;\n f:boolean;\n s,s1:ansistring;\n\nbegin\n readln(n,m,k);\n readln(s);\n if s='to head' then f:=true;\n posk:=k;\n poss:=m;\n readln(s1);\n pp:=length(s1);\n\n for i:=1 to pp do if s1[i]='0' then\n begin\n if f then\n begin\n if (poss<1) then dec(poss);\n if (posk>1) then dec(posk);\n if posk=1 then f:=false;\n end else\n begin\n if (poss1) then dec(posk);\n if posk=1 then f:=true;\n end;\n if f then if posk1 then posk:=1 else posk:=2;\n if poss=posk then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if ((k-m<=m-k)and(mk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "uses math;\n\nvar i,l,n,pz,pk:longint;\n s:string;\n\n procedure make_step(var x,l:longint);\n begin\n x:=x+l;\n if x=0 then begin x:=1; l:=-l; end else\n if x>n then begin x:=n; l:=-l; end;\n end;\n\n procedure go_out(x,y,t:longint);\n begin\n if x=y then\n begin\n writeln('Controller ',t);\n halt;\n end;\n end;\n\n\n begin\n readln(n,pz,pk);\n readln(s);\n if s='to tail' then l:=1 else l:=-1;\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='1' then\n begin\n if l=1 then\n begin\n if pk=1 then pz:=n else pz:=1;\n end else\n begin\n if pk=n then pz:=1 else pz:=n;\n end;\n go_out(pk,pz,i);\n make_step(pk,l);\n go_out(pk,pz,i);\n end else\n begin\n if l=1 then\n begin\n if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);\n end else\n begin\n if pz>pk then pz:=min(n,pz+1) else pz:=max(1,pz-1);\n end;\n go_out(pk,pz,i);\n make_step(pk,l);\n go_out(pk,pz,i);\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var a:array [1..1000] of longint;\n b,n,i,j,k,d,m,max:longint;\n s,p:string;\n\n begin\n readln(n,k,m);\n readln(s);\n readln(p);\n for i:=1 to length(p) do\n begin\n if p[i]='1' then\n begin\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n\n if (s[4]='h') then k:=m+1\n else k:=m-1;\n if (m=1) or (m=n) then\n begin\n if k=m+1 then k:=m-1\n else k:=m+1;\n end;\n if k=0 then k:=n;\n if k=n+1 then k:=1;\n end else\n begin\n\n d:=1;\n if (m>k) then d:=1\n else d:=2;\n\n if (d=1) and (k<>1) then dec(k);\n if (d=2) and (k<>n) then inc(k);\n\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n if k=m then begin\n writeln('Controller ',i);\n halt;\n end;\n\n\n\n\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\ntt : longint;\ns : String;\nq : char;\na : Array[0..1000]of longint;\nb : Array[0..70,0..70,-5..5,0..201]of longint;\nfunction rec(x,y,shag,z : longint) : longint;\nvar i,tr,h,ht,shah: Longint;\nbegin\n\n if x = y then\n begin\n b[x,y,shag,z] := z;\n exit(b[x,y,shag,z]);\n end;\n\n if z > max then max := z;\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\nend;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max);\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=0;\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if (k=m) or (m<1) or (m>n) then begin\n r:=i;\n break;\n end;\nend;\nif r=0 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "program problemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n orient,n,m,k,i,j,p:integer;\n s,q:string;\nbegin\n readln(n,m,k);\n readln(s);\n readln(q);\n if s='to head' then orient:=-1 else orient:=1;\n p:=-1;\n for i:=1 to length(q) do begin\n case q[i] of\n '0':begin\n if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n if k=m then begin\n p:=k;\n break;\n end;\n end;\n '1':begin\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n m:=k-orient;\n if (m>n) then m:=1;\n if (m<1) then m:=n;\n if m=k then begin\n p:=k;\n break;\n end;\n end;\n end;\n writeln(m,' ',k);\n end;\n if p=-1 then writeln('Stowaway') else writeln('Controller ',p);\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to n do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k < 1 Then\n Begin\n k := 2;\n dir := 'to tail';\n End;\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k > n Then\n Begin\n k := n-1;\n dir := 'to head';\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n If k < n Then\n Begin\n m := n;\n k := k-1;\n End\n Else\n Begin\n m := 1;\n k := k-1;\n End;\n End\n Else\n Begin\n If k > 1 Then\n Begin\n m := 1;\n k := k+1;\n End\n Else\n Begin\n m := n;\n k := k+1;\n End;\n End;\n End;\n Writeln('Stowaway');\nEnd.\n"}, {"source_code": "uses math;\nvar\n n,m,k,l,tt:longint;\n s,t:string;\nprocedure nhap;\nbegin\n readln(n,m,k);\n readln(t);\n readln(s);\n l:=length(s);\n if t='to head' then tt:=-1 else tt:=1;\nend;\nprocedure xuly;\nvar\n i:longint;\nbegin\n for i:=1 to l do\n begin\n if s[i]='0' then\n begin\n if tt=-1 then\n begin\n if mk then m:=math.min(n,m+1)\n else m:=math.max(1,m-1);\n end;\n k:=k+tt;\n if k=m then\n begin\n writeln('Controller ',i);\n exit;\n end;\n end\n else\n begin\n if tt=-1 then m:=n\n else m:=1;\n end;\n if k=1 then tt:=1;\n if k=n then tt:=-1;\n end;\n writeln('Stowaway');\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "var\n o,n,x,y,i,m:longint;\n s:ansistring;\n\nbegin\n readln(n,x,y);\n readln(s);\n if (s[4]='h')then o:=1 else o:=2;\n readln(s);\n m:=length(s);\n for i:=1 to m-1 do begin\n if (s[i]='0')then begin\n if (x=1)then inc(x)else\n if (x=n)then dec(x)else\n if (abs(x-1-y)>abs(x+1-y))then dec(x)else\n inc(x);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end else begin\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (y=n)then x:=1 else\n if (y=1)then x:=n else\n if (o=1)then begin\n x:=n;\n if (y=n-1)then x:=1;\n end else begin\n x:=1;\n if (y=2)then x:=n;\n end;\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var n,x,y,g,max,t,i,j:longint;\n s:string;\n\nprocedure tt(x:longint);\nvar k:longint;\n begin\n k:=0;\n if g>0 then begin\n if x>=y then k:=x-y\n else k:=2*n-x-y;\n end\n else begin\n if x<=y then k:=y-x\n else k:=y-1+x-1;\n end;\n if k>max then begin\n max:=k;\n t:=x;\n end;\n end;\n\n begin\n readln(n,x,y);\n readln(s);\n if s[length(s)]='d' then g:=-1\n else g:=1;\n readln(s);\n for i:=1 to length(s) do\n begin\n if (y=1) then g:=1;\n if (y=n) then g:=-1;\n max:=-1;\n t:=x;\n if s[i]='0' then begin\n y:=y+g;\n\n\n if (x-1>=1) and (x-1<>y-g) and (x-1<>y) then tt(x-1);\n if (x+1<=n) and (x+1<>y-g) and (x+1<>y) then tt(x+1);\n tt(x);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end\n else begin\n y:=y+g;\n\n for j:=1 to n do\n if (j<>y-g) and\n (j<>y) then tt(j);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n if x=y then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar n, m, k, kq : Longint;\n s, t : String;\n kt : boolean;\n\nProcedure ReadFile;\n Begin\n Assign(Input, fi);\n Reset(Input);\n Readln(n,m,k);\n Readln(t);\n Readln(s);\n Close(Input);\n End;\n\nProcedure WriteFile;\n Begin\n Assign(Output, fo);\n Rewrite(Output);\n If kt Then\n Writeln('Stowaway')\n Else Writeln('Controller ',kq);\n Close(Output);\n End;\n\nProcedure Solve;\n Var dir : Boolean;\n i, time : Longint;\n Begin\n dir := t[length(t)] = 'd';\n Kt := True;\n For i := 1 to Length(S) do\n Begin\n If dir Then\n Begin\n If k = 1 Then\n Begin\n dir := not dir;\n k := k+1;\n End\n Else k := k-1;\n If m < k Then\n Begin\n m := m-1;\n If m = 0 Then m := 1;\n End\n Else\n Begin\n m := m+1;\n If m = n+1 Then m := n;\n End;\n End\n Else\n Begin\n If k = n Then\n Begin\n dir := not dir;\n k := k-1;\n End\n Else k := k+1;\n If m < k Then\n Begin\n m := m-1;\n If m = 0 Then m := 1;\n End\n Else\n Begin\n m := m+1;\n If m = n+1 Then m := n;\n End;\n End;\n If s[i] = '0' Then\n Begin\n If m = k Then\n Begin\n Kt := False; Kq := i; Break;\n End;\n End\n Else\n Begin\n If dir Then m := n\n Else m := 1;\n End;\n End;\n End;\n\nBegin\n ReadFile;\n Solve;\n WriteFile;\nEnd."}, {"source_code": "{$apptype console}\n{$R-,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n n,m,k,i,len:longint;\n s,t:string;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n readln(n,m,k);\n readln(s);\n readln(t);\n len:=length(t);\n for i:=1 to len do\n begin\n if t[i] = '1' then\n begin\n if s[4] = 'h' then\n begin\n if k = 1 then\n begin\n s[4]:='t';\n inc(k);\n end else dec(k);\n m:=n;\n end else\n begin\n if k = n then\n begin\n s[4]:='h';\n dec(k);\n end else inc(k);\n m:=1;\n end;\n continue;\n end;\n if m > k then m:=n else m:=1;\n if s[4] = 'h' then\n begin\n if k = 1 then\n begin\n s[4]:='t';\n inc(k);\n end else dec(k);\n end else\n begin\n if k = n then\n begin\n s[4]:='h';\n dec(k);\n end else inc(k);\n end;\n if k = m then\n begin\n writeln('Controller ',i);\n exit;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n VtC,mv,n,luu:longint;\n State:string;\n xet,cungchieu:boolean;\n f:text;\nprocedure nhap;\nvar m,k:longint;St:string;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n,m,k);\n readln(f,St);\n readln(f,State);\n if St='to head' then mv:=-1\n else mv:=1;\n if mv*(m-k)>0 then cungchieu:=true\n else cungchieu:=false;\n VtC:=k;\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n if xet then writeln(f,'Stowaway')\n else\n begin\n write(f,'Controller ');\n writeln(f,luu);\n end;\n close(f);\nend;\nprocedure process;\nvar cuoi,i,reach1,p,j,S1:longint;\nbegin\n i:=1;\n reach1:=0;\n while i<=length(State) do\n begin\n if State[i]='1' then cungchieu:=false\n else\n for j:=i+1 to length(State) do\n if State[j]='1' then\n begin\n reach1:=j-i+1;\n break;\n end;\n if mv=1 then cuoi:=n\n else cuoi:=1;\n if not cungchieu then S1:=n+abs(cuoi-vtC)-1\n else S1:=abs(cuoi-vtC);\n if State[i]='0' then\n begin\n if S1=length(State)+1 then xet:=true\n else\n begin\n xet:=false;\n luu:=i;\n end;\nend;\nbegin\n nhap;\n process;\n xuat;\nend.\n\n"}, {"source_code": "Program\t\t\tBB;\nvar\nk,p,s,c,m,time,i,n : longint;\nlen,rp : string;\nflag : Boolean;\nbegin\n{Assign(input,'B.in');Assign(output,'B.out');\nreset(input);rewrite(output);}\n\treadln(n,m,k);\n\ts:=m;c:=k;\n\treadln(Rp);\n\tif Rp[4]='h' then p:=-1 else p:=1;\n\treadln(len);\n\ttime :=0;flag := false;\n\tfor i :=1 to length(len) do\n\tbegin\n\t\tif len[i]='1' then\n\t\tbegin\n\t\t\tif p=-1 then begin\n if c<>1 then\n s := n else\n s := 1;\n end else\n begin\n if c<>n then s :=1 else\n s := n;\n end;\n\t\tend; if i<>1 then begin\n\t\t\tc:=c+p;\n\t\t\tif c=0 then\n\t\t\tbegin c:=2;p:=-p; end else\n\t\t\tif c=n+1 then\n\t\t\tbegin c :=n-1;p:=-p;end;\n end;\n\n\t\ttime := time+1;\n\t\tif s=c then begin flag := true;break;end;\n\tend;\n\tif flag=false then writeln('Stowaway') else\n\twriteln('Controller ',time);\n{Close(input); Close(output);}\n\nend.\n"}, {"source_code": "{uses crt;\n}const nn=300;\nvar m,t,n,i,j,k,p,max,kolvag:longint;\ncc:char;\ns,nap:string; flag:boolean;\nnapcon,contr,zayaz:array[0..nn] of longint;\nbegin {clrscr;\n assign(input,'input.txt');reset(input);\n} readln (kolvag,m,k);\n readln(nap);\n readln(s);\n n:=length(s);\n if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;\n contr[1]:=k;\n for i:=2 to n do\n begin contr[i]:=contr[i-1]+napcon[i-1];\n if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];\n\n end;\n\nif s[1]='0' then zayaz[1]:=m;\nif s[1]='1' then zayaz[1]:=contr[1]-napcon[2];\nfor i:=2 to n do\n begin\n if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)\n then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];\n if s[i-1]='1' then zayaz[i]:=contr[i-1];\n\n\n end;\n\n{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }\nfor i:=1 to n do if (contr[i]=zayaz[i])and(s[i]='0') then begin flag:=true;break;end;\n if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');\n\n\n\n\n\nend."}, {"source_code": "var\n n,m,k,i,p,f:longint;\n s:string;\n c:char;\n begin\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(n,k,m);\n readln(s);\n if s='to head' then\n p:=-1\n else\n p:=1;\n i:=0;\n while eoln<>true do\n begin\n\n read(c);\n inc(i);\n if c='0' then\n begin\n if p=-1 then\n if (k-1>m)and(m<>1) then\n dec(k)\n else\n if (m=1)and(2>k-1)and(k-1>0) then\n dec(k)\n else\n if (m=1)and(k=2)and(k+10)and(m=k+1) then\n dec(k);\n if p=1 then\n if (k+1n) then\n inc(k)\n else\n if (m=n)and(m-1>k+1)and(k+10) then\n dec(k)\n else\n if m=n then\n f:=1\n else\n if (k-1>0)and(m=k+1) then\n dec(k)\n else\n if (k+1<=n)and(m=k-1) then\n inc(k);\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if m=k then\n begin\n writeln('Controller',' ',i);\n halt;\n end;\n end;\n if c='1' then\n begin\n k:=0;\n inc(m,p);\n if m>n then\n begin\n m:=n-1;\n p:=-1;\n end;\n if m<1 then\n begin\n m:=2;\n p:=1;\n end;\n if p=1 then\n\n if m-2>0 then\n k:=m-2\n else\n k:=m-1;\n if p=-1 then\n if m+2<=n then\n k:=m+2\n else\n k:=m+1;\n\n end;\n\n end;\n writeln('Stowaway');\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var\na,s1:string;\ni,j,k,l,n,m:longint;\nbegin\nreadln(n,m,k);\nreadln(s1);\nread(a);\nfor i:=1 to length(a) do\n begin\n if k=1 then s1:='to tail';\n if k=n then s1:='to head';\n if (a[i]='1') and (i=length(a)) then\n begin\n write('Stawaway');\n exit;\n end;\n if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then\n begin\n write('Controller ',i);\n exit;\n end;\n if mk then m:=n;\n if (a[i]='1') and (s1='to head') then m:=n;\n if (a[i]='1') and (s1='to tail') then m:=1;\n if s1='to tail' then inc(k)\n else dec(k);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2+1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2-1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var a:array [1..1000] of longint;\n b,n,i,j,k,d,m,max:longint;\n s,p:string;\n\n begin\n readln(n,k,m);\n readln(s);\n readln(p);\n for i:=1 to length(p) do\n begin\n if p[i]='1' then\n begin\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n\n if s[4]='h' then k:=m+1\n else k:=m-1;\n if k=0 then k:=n;\n if k=n+1 then k:=1;\n end else\n begin\n\n d:=1;\n if (m>k) then d:=1\n else d:=2;\n\n if (d=1) and (k<>1) then dec(k);\n if (d=2) and (k<>n) then inc(k);\n\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n if k=m then begin\n writeln('Controller ',i);\n halt;\n end;\n\n\n\n\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if (k=m) or (m<1) or (m>n) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "Var n,i,j,k,l,m,t,r:longint;\ns:string;\nBegin\nReadln(N,M,k);\nReadln(s);\nif s='to head' then\n r:=1\nelse\n r:=0;\ns:='';\nReadln(s);\nFor i:=1 to length(s) do begin\n if s[i]='0' then begin\n if M1 then\n dec(M);\n end\n else begin\n if M k Then\n time := n-k\n Else time := n*2-k-1;\n End;\n If time < a[i]-a[i-1] Then\n Begin\n kt := False;\n kq := a[i-1]+time;\n Break;\n End\n Else\n Begin\n if dir Then\n Begin\n k := 1;\n m := n;\n End\n Else\n Begin\n k := n;\n m := 1;\n End;\n dir := not dir;\n End;\n End;\n End;\n\nBegin\n ReadFile;\n Init;\n Solve;\n WriteFile;\nEnd."}, {"source_code": "var a:array [1..1000] of longint;\n b,n,i,j,k,d,m,max:longint;\n s,p:string;\n\n begin\n readln(n,k,m);\n readln(s);\n readln(p);\n for i:=1 to length(p) do\n begin\n if p[i]='1' then\n begin\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n\n if (s[4]='h') then k:=m+1\n else k:=m-1;\n if (m=1) or (m=n) then\n begin\n if k=m+1 then k:=m-1\n else k:=m+1;\n end;\n if k=0 then k:=n;\n if k=n+1 then k:=1;\n end else\n begin\n\n d:=1;\n if (m>k) then d:=1\n else d:=2;\n\n if (d=1) and (k<>1) then dec(k);\n if (d=2) and (k<>n) then inc(k);\n\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n if k=m then begin\n writeln('Controller ',i);\n halt;\n end;\n\n\n\n\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,n,m,k,z,c : Integer;\n s : string;\n nap : Boolean;\nbegin\n Readln(n,m,k);\n Readln(s);\n if s[4]='t' then nap:=True;\n if s[4]='h' then nap:=false;\n Readln(s);\n if m>k then z:=n\n else z:=1;\n c:=k;\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1\n else z:=n;\n end;\n if nap then c:=c+1\n else c:=c-1;\n if z=c then\n begin\n Writeln('Controller ', i);\n Readln;\n Exit;\n end;\n if c=0 then\n begin\n c:=1;\n nap:=True;\n end;\n if c=n+1 then\n begin\n c:=n;\n nap:=False;\n end;\n end;\n Writeln('Stowaway');\n Readln;\nend.\n"}, {"source_code": "var\n n,m,k,i,pp,posk,poss:longint;\n f:boolean;\n s,s1:ansistring;\n\nbegin\n readln(n,m,k);\n readln(s);\n if s='to head' then f:=true;\n posk:=k;\n poss:=m;\n readln(s1);\n pp:=length(s1);\n\n for i:=1 to pp do if s1[i]='0' then\n begin\n if f then\n begin\n if (poss<1) then dec(poss);\n if (posk>1) then dec(posk);\n if posk=1 then f:=false;\n end else\n begin\n if (poss1) then dec(posk);\n if posk=1 then f:=true;\n end;\n if f then if posk1 then posk:=1 else posk:=2;\n if poss=posk then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": " var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\n tt : longint;\n s : String;\n q : char;\n a : Array[0..1000]of longint;\n b : Array[0..70,0..70,-5..5,0..201]of longint;\n\n function maxx(x,y : Longint):longint;\n begin\n if x > y then y := x;\n maxx := y;\n end;\n function rec(x,y,shag,z : longint) : longint;\n var i,tr,h,ht,shah: Longint;\n begin\n\n if x = y then\n begin\n b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);\n if b[x,y,shag,z] > max then max := b[x,y,shag,z];\n exit(b[x,y,shag,z]);\n end;\n\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\n\n if b[x,y,shah,z] > max then max := b[x,y,shah,z];\n end;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max >= f then writeln('Stowaway')\n else writeln('Controller ',max);\n end."}, {"source_code": "program problemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n orient,n,m,k,i,j,p:integer;\n s,q:string;\nbegin\n readln(n,m,k);\n readln(s);\n readln(q);\n if s='to head' then orient:=-1 else orient:=1;\n p:=-1;\n for i:=1 to length(q) do begin\n case q[i] of\n '0':begin\n if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n if k=m then begin\n p:=k;\n break;\n end;\n end;\n '1':begin\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n m:=k-orient;\n if (m>n) then m:=1;\n if (m<1) then m:=n;\n if m=k then begin\n p:=k;\n break;\n end;\n end;\n end;\n writeln(m,' ',k);\n end;\n if p=-1 then writeln('Stowaway') else writeln('Controller ',p);\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "var\nmax,f,n,m,i,j,k,off,tr: longint;\ntt : longint;\ns : String;\nq : char;\na : Array[0..1000]of longint;\nb : Array[0..7,0..7,-5..5,0..21]of longint;\nfunction rec(x,y,shag,z : longint) : longint;\nvar i,tr,h,ht,shah: Longint;\nbegin\n if z > max then max := z;\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n if x = y then\n begin\n b[x,y,shag,z] := z;\n exit(b[x,y,shag,z]);\n end;\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n b[x,y,shag,z] := z;\n if a[z] = 1 then\n begin\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n For i := 1 to n do\n begin\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if ht = x then tr := z\n else\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\nend;\n\n\n begin\n readln(n,m,k);\n readln(s);\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,k,off,1);\n\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 1 to f do\n if b[i][j][k][tr] <>-1 then\n begin\n if tr > max then max := tr;\n end;\n\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max\n );\n end.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if (kk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "uses math;\nvar i,n,m,k:longint;\n s:ansistring;\n v:boolean;\n begin\n readln(n,m,k);\n readln(s);\n if s[4]='h' then v:=true\n else v:=false;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if s[i]='1' then\n begin\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n if (k=1) then m:=n\n else if (k=n) then m:=1\n else if v then m:=n\n else m:=1;\n\n end\n else begin\n if v and (mk then m:=min(m+1,n)\n else m:=max(m-1,1);\n\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n if m=k then begin writeln('Controller ',i); halt(0); end;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var n,m,k,i,c,l,z:integer;\na:array[1..200] of char;\ns:string;\n\nprocedure step1;\nbegin\nif m1 then dec(m);\nif m>k then\n if m1 then m:=1 else m:=n;\nif c=-1 then\n if k<>n then m:=n else m:=1;\nk:=k+c;\nend;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nwhile not eoln do\n begin\n inc(l);\n read(a[l]);\n end;\nif s='to head' then c:=-1 else c:=1;\nfor i:=1 to l do\n begin\n if a[i]='0' then step1 else step2;\n if (k=1) or (k=n) then c:=-c;\n if m=k then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nwriteln('Stowaway');\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,n,m,k,z,c : Integer;\n s : string;\n nap : Boolean;\nbegin\n Readln(n,m,k);\n Readln(s);\n if s[4]='t' then nap:=True;\n if s[4]='h' then nap:=false;\n Readln(s);\n if m>k then z:=n\n else z:=1;\n c:=k;\n for i:=1 to length(s) do\n begin\n if s[i]='1' then\n begin\n if (nap and (c<>1)) or ((not nap) and (c=n)) then z:=1\n else z:=n;\n end;\n if nap then c:=c+1\n else c:=c-1;\n if z=c then\n begin\n Writeln('Controller ', i);\n Readln;\n Exit;\n end;\n if c=0 then\n begin\n c:=1;\n nap:=True;\n end;\n if c=n+1 then\n begin\n c:=n;\n nap:=False;\n end;\n end;\n Writeln('Stowaway');\n Readln;\nend.\n"}, {"source_code": "program problemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n orient,n,m,k,i,j,p:integer;\n s,q:string;\nbegin\n readln(n,m,k);\n readln(s);\n readln(q);\n if s='to head' then orient:=-1 else orient:=1;\n p:=-1;\n for i:=1 to length(q) do begin\n case q[i] of\n '0':begin\n if (m+orient<=n) and (m+orient>=1) and (m+orient<>k) then m:=m+orient;\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n if k=m then begin\n p:=k;\n break;\n end;\n end;\n '1':begin\n k:=k+orient;\n if (k=1) or (k=n) then orient:=-orient;\n m:=k-orient;\n if (m>n) then m:=1;\n if (m<1) then m:=n;\n if m=k then begin\n p:=k;\n break;\n end;\n end;\n end;\n// writeln(m,' ',k);\n end;\n if p=-1 then writeln('Stowaway') else writeln('Controller ',p);\n readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "uses math;\nvar i,n,m,k:longint;\n s:ansistring;\n v:boolean;\n begin\n readln(n,m,k);\n readln(s);\n if s[4]='h' then v:=true\n else v:=false;\n readln(s);\n for i:=1 to length(s)-1 do\n begin\n if s[i]='1' then\n begin\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n if (k=1) then m:=n\n else if (k=n) then m:=1\n else if v then m:=n\n else m:=1;\n\n end\n else begin\n if v and (mk then m:=min(m+1,n)\n else m:=max(m-1,1);\n\n if v then k:=k-1\n else k:=k+1;\n if (k=1)or(k=m) then v:=v xor true;\n\n if m=k then begin writeln('Controller ',i); halt(0); end;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "var n,m,k,i,c,l,z:integer;\na:array[1..200] of char;\ns:string;\n\nprocedure step1;\nbegin\nif m1 then dec(m);\nif m>k then\n if m1 then m:=1 else m:=n;\nif c=-1 then\n if k<>n then m:=n else m:=1;\nk:=k+c;\nend;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nwhile not eoln do\n begin\n inc(l);\n read(a[l]);\n end;\nif s='to head' then c:=-1 else c:=1;\nfor i:=1 to l do\n begin\n if a[i]='0' then step1 else step2;\n if (k=1) or (k=n) then c:=-c;\n if m=k then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nwriteln('Stowaway');\nend."}, {"source_code": "var n,m,k,i,napr:longint;\n s:String;\n a:array[0..51] of longint;\n\nprocedure fun1;\nbegin\n if (Napr=1) and (m+1=k) then begin\n if m=1 then begin writeln('Controller ',i); halt; end;\n dec(m);\n dec(k);\n end else\n if (napr=1) then begin\n dec(k);\n if k=0 then begin\n k:=2; napr:=3-napr;\n end;\n end else\n if (napr=2) and (m=k+1) then begin\n if m=n then begin writeln('Controller ',i); halt; end;\n inc(m);\n inc(k);\n end else\n if (napr=2) then begin\n inc(k);\n if k=n+1 then begin\n k:=n-1; napr:=3-napr;\n end;\n end;\nend;\n\nprocedure fun2;\nbegin\n if napr=2 then begin\n if k=1 then m:=n else\n m:=1;\n end else\n begin\n if k=n then m:=1 else\n m:=n;\n end;\n if napr=1 then begin\n k:=k-1;\n if k=0 then begin\n napr:=2;\n k:=2;\n end;\n end else\n if (napr=2) then begin\n inc(k);\n if k=n+1 then begin\n k:=n-1; napr:=3-napr;\n end;\n end;\n if k=m then begin writeln('Controller ',i); halt; end;\n\n\n\nend;\n\n\n\n\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then napr:=1 else napr:=2;\nreadln(S);\nfor i:= 1 to length(s) do\n begin\n if s[i]='0' then fun1 else fun2;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if n-k>k-1 then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend."}, {"source_code": "var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if n-k>k-1 then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend."}, {"source_code": "var n,m,j,i,k,l,z,temp:longint;s,s1:string;\nprocedure xx(f:longint);\n begin\n if (temp=-1) and (k>z) and (z>1) then z:=z+temp else\n if (temp=-1) and (kz) and (z>1) then z:=z-1;\n\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=z then begin writeln('Controller ',f);halt;end;\n end;\nprocedure zz(f:longint);\n begin\n if f=length(s) then begin writeln('Stowaway');halt;end;\n if (k<>n) or (k<>1)then k:=k+temp else temp:=temp*(-1);\n if k=1 then z:=n;\n\n\n if k=n then z:=1;\n if temp>0 then z:=1;\n if temp<0 then z:=n;\n end;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output);}\nreadln(n,z,k);\nreadln(s1);\nif s1='to head' then temp:=-1 else temp:=1;\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='0' then xx(i) else zz(i);\nend.\n"}, {"source_code": "Program\t\t\tBB;\nvar\nk,p,s,c,m,time,i,n : longint;\nlen,rp : string;\nflag : Boolean;\nbegin\n{Assign(input,'B.in');Assign(output,'B.out');\nreset(input);rewrite(output);}\n\treadln(n,m,k);\n\ts:=m;c:=k;\n\treadln(Rp);\n\tif Rp[4]='h' then p:=-1 else p:=1;\n\treadln(len);\n\ttime :=0;flag := false;\n\tfor i :=1 to length(len) do\n\tbegin\n\t\tif len[i]='1' then\n\t\tbegin\n\t\t\tif p=-1 then s := n else s :=1;\n\t\tend else if i<>1 then\n\t\tbegin\n\t\t\tc:=c+p;\n\t\t\tif c=0 then\n\t\t\tbegin c:=2;p:=-p; end else\n\t\t\tif c=n+1 then\n\t\t\tbegin c :=n-1;p:=-p;end;\n\t\tend;\n\t\ttime := time+1;\n\t\tif s=c then begin flag := true;break;end;\n\tend;\n\tif flag=false then writeln('Stowaway') else\n\twriteln('Controller ',time);\n{Close(input); Close(output);}\n\nend.\n"}, {"source_code": " var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\n tt : longint;\n s : String;\n q : char;\n a : Array[0..1000]of longint;\n b : Array[0..70,0..70,-5..5,0..201]of longint;\n\n function maxx(x,y : Longint):longint;\n begin\n if x > y then y := x;\n maxx := y;\n end;\n function rec(x,y,shag,z : longint) : longint;\n var i,tr,h,ht,shah: Longint;\n begin\n\n if x = y then\n begin\n b[x,y,shag,z] := maxx(z - 1,b[x,y,shag,z]);\n if b[x,y,shag,z] > max then max := b[x,y,shag,z];\n exit(b[x,y,shag,z]);\n end;\n\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\n\n if b[x,y,shah,z] > max then max := b[x,y,shah,z];\n end;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=n then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if s[i]='1' then begin\n if k>n div 2-1 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else inc(m);\n end else begin\n if (k-m>0) and (mn div 2+1 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else inc(m);\n end; \n end;\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if (k=m) or (m<1) or (m>n) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var n,m,j,i,k,l,z,temp:longint;s,s1:string;\nprocedure xx(f:longint);\n begin\n if (temp=-1) and (k>z) and (z>1) then z:=z+temp else\n if (temp=-1) and (kz) and (z>1) then z:=z-1;\n\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=z then begin writeln('Controller ',f);halt;end;\n end;\nprocedure zz(f:longint);\n begin\n if f=length(s) then begin writeln('Stowaway');halt;end;\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=1 then z:=n;\n if k=n then z:=1;\n if temp>0 then z:=1;\n if temp<0 then z:=n;\n end;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(n,z,k);\nreadln(s1);\nif s1='to head' then temp:=-1 else temp:=1;\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='0' then xx(i) else zz(i);\nend.\n"}, {"source_code": "var\n i,j,n,m,k,p:longint;\n napr,t:string;\nBEGIN\nreadln(n,m,k);writeln(n,m,k);\nreadln(napr);writeln(napr);\nreadln(t);writeln(t);\nif (napr='to head') then p:=-1 else p:=1;\nfor i:=1 to length(t) do\n begin\n {Zayac}\n if (t[i]='0') then\n begin\n if (p=-1)and(m>k)and(m+1<=n) then inc(m);\n if (p=-1)and(m=2) then dec(m);\n if (p=1)and(m>k)and(m+1<=n) then inc(m);\n if (p=1)and(m=2) then dec(m); \n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n end\n else\n begin\n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n if (p=-1)and(k<>n) then m:=n;\n if (p=-1)and(k=n) then m:=1;\n if (p=1)and(k<>1) then m:=1;\n if (p=1)and(k=1) then m:=n;\n end;\n {End game?} \n if (m=k) then \n begin\n writeln('Controller ',i);\n halt;\n end;\n {writeln(t[i],' t=',i,' c=',k,' z=',m);}\n end;\nwriteln('Stowaway');\nEND."}, {"source_code": "var\n\n kk,max,f,n,m,i,j,k,off,tr: longint;\ntt : longint;\ns : String;\nq : char;\na : Array[0..1000]of longint;\nb : Array[0..70,0..70,-5..5,0..201]of longint;\nfunction rec(x,y,shag,z : longint) : longint;\nvar i,tr,h,ht,shah: Longint;\nbegin\n\n if x = y then\n begin\n b[x,y,shag,z] := z - 1;\n exit(b[x,y,shag,z]);\n end;\n\n if z > max then max := z;\n\n\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n\n\n if a[z] = 1 then\n begin\n\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y;\n end;\n\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\nend;\n\n\n begin\n readln(n,m,kk);\n readln(s);\n\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,kk,off,1);\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max);\n end.\n"}, {"source_code": "var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if n-k>k-1 then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend."}, {"source_code": "var a:array [1..1000] of longint;\n b,n,i,j,k,d,m,max:longint;\n s,p:string;\n\n begin\n readln(n,k,m);\n readln(s);\n readln(p);\n for i:=1 to length(p) do\n begin\n if p[i]='1' then\n begin\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n\n if (s[4]='h') then k:=m+1\n else k:=m-1;\n if (m=1) or (m=n) then\n begin\n if k=m+1 then k:=m-1\n else k:=m+1;\n end;\n if k=0 then k:=n;\n if k=n+1 then k:=1;\n end else\n begin\n\n d:=1;\n if (m>k) then d:=1\n else d:=2;\n\n if (d=1) and (k<>1) then dec(k);\n if (d=2) and (k<>n) then inc(k);\n\n if s[4]='h' then begin\n dec(m);\n if m=0 then\n begin\n m:=2;\n s[4]:='t';\n end;\n end;\n if s[4]='t' then begin\n inc(m);\n if m=n+1 then\n begin\n m:=n-1;\n s[4]:='h';\n end;\n end;\n\n if k=m then begin\n writeln('Controller ',i);\n halt;\n end;\n\n\n\n\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n VtC,mv,n,luu:longint;\n State:string;\n xet,cungchieu:boolean;\n f:text;\nprocedure nhap;\nvar m,k:longint;St:string;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n,m,k);\n readln(f,St);\n readln(f,State);\n if St='to head' then mv:=-1\n else mv:=1;\n if mv*(m-k)>0 then cungchieu:=true\n else cungchieu:=false;\n VtC:=k;\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n if xet then writeln(f,'Stowaway')\n else\n begin\n write(f,'Controller ');\n writeln(f,luu);\n end;\n close(f);\nend;\nprocedure process;\nvar cuoi,i,reach1,p,j,S1:longint;\nbegin\n i:=1;\n reach1:=0;\n while i<=length(State) do\n begin\n if State[i]='1' then cungchieu:=false;\n for j:=i+1 to length(State) do\n if State[j]='1' then\n begin\n reach1:=j-i;\n break;\n end;\n if mv=1 then cuoi:=n\n else cuoi:=1;\n if not cungchieu then S1:=n+abs(cuoi-vtC)-1\n else S1:=abs(cuoi-vtC);\n if State[i]='0' then\n begin\n if S11 then\n dec(M);\n end\n else begin\n if M1)and(m<>n)\n then begin\n if e=1\n then begin\n if m>k\n then m:=n\n else m:=1;\n end\n else begin\n if mk then m:=n;\n if (a[i]='1') and ((k=1) or (s1='to head')) then m:=n;\n if (a[i]='1') and ((k=n) or (s1='to tail')) then m:=1;\n if (s1='to head') and (k=1) then s1:='to tail';\n if (s1='ta tail') and (k=n) then s1:='to head';\n if s1='to tail' then inc(k)\n else dec(k);\n end;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n VtC,mv,n,luu:longint;\n State:string;\n xet,cungchieu:boolean;\n f:text;\nprocedure nhap;\nvar m,k:longint;St:string;\nbegin\n assign(f,fi);\n reset(F);\n readln(f,n,m,k);\n readln(f,St);\n readln(f,State);\n if St='to head' then mv:=-1\n else mv:=1;\n if mv*(m-k)>0 then cungchieu:=true\n else cungchieu:=false;\n VtC:=k;\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n if xet then writeln(f,'Stowaway')\n else\n begin\n write(f,'Controller ');\n writeln(f,luu);\n end;\n close(f);\nend;\nprocedure process;\nvar cuoi,i,reach1,p,j,S1:longint;\nbegin\n i:=1;\n reach1:=0;\n while i<=length(State) do\n begin\n if State[i]='1' then cungchieu:=false;\n for j:=i+1 to length(State) do\n if State[j]='1' then\n begin\n reach1:=j-i;\n break;\n end;\n if mv=1 then cuoi:=n\n else cuoi:=1;\n if not cungchieu then S1:=n+abs(cuoi-vtC)-1\n else S1:=abs(cuoi-vtC);\n if State[i]='0' then\n begin\n if S1=n div 2) and (k>2) then m:=1 else m:=n;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=n div 2) and (k=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var\n i,j,n,m,k,p:longint;\n napr,t:string;\nBEGIN\nreadln(n,m,k);writeln(n,m,k);\nreadln(napr);writeln(napr);\nreadln(t);writeln(t);\nif (napr='to head') then p:=-1 else p:=1;\nfor i:=1 to length(t) do\n begin\n {Zayac}\n if (t[i]='0') then\n begin\n if (p=-1)and(m>k)and(m+1<=n) then inc(m);\n if (p=-1)and(m=2) then dec(m);\n if (p=1)and(m>k)and(m+1<=n) then inc(m);\n if (p=1)and(m=2) then dec(m); \n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n end\n else\n begin\n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n if (p=-1)and(k<>n) then m:=n;\n if (p=-1)and(k=n) then m:=1;\n if (p=1)and(k<>1) then m:=1;\n if (p=1)and(k=1) then m:=n;\n end;\n {End game?} \n if (m=k) then \n begin\n writeln('Controller ',i);\n halt;\n end;\n {writeln(t[i],' t=',i,' c=',k,' z=',m);}\n end;\nwriteln('Stowaway');\nEND."}, {"source_code": "{uses crt;\n}const nn=300;\nvar m,t,n,i,j,k,p,max,kolvag:longint;\ncc:char;\ns,nap:string; flag:boolean;\nnapcon,contr,zayaz:array[0..nn] of longint;\nbegin {clrscr;\n assign(input,'input.txt');reset(input);\n} readln (kolvag,m,k);\n readln(nap);\n readln(s);\n n:=length(s);\n if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;\n contr[1]:=k;\n for i:=2 to n do\n begin contr[i]:=contr[i-1]+napcon[i-1];\n if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];\n\n end;\n\nif s[1]='0' then zayaz[1]:=m;\nif s[1]='1' then zayaz[1]:=contr[1]-napcon[2];\nfor i:=2 to n do\n begin\n if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)\n then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];\n if s[i-1]='1' then zayaz[i]:=contr[i-1];\n\n\n end;\n\n{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }\nfor i:=1 to n do if (contr[i]=zayaz[i])and(s[i]='0') then begin flag:=true;break;end;\n if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');\n\n\n\n\n\nend."}, {"source_code": "var\n o,n,x,y,i,m:longint;\n s:ansistring;\n\nbegin\n readln(n,x,y);\n readln(s);\n if (s[4]='h')then o:=1 else o:=2;\n readln(s);\n m:=length(s);\n for i:=1 to m-1 do begin\n if (s[i]='0')then begin\n if (x=1)then inc(x)else\n if (x=n)then dec(x)else\n if (abs(x-1-y)>abs(x+1-y))then dec(x)else\n inc(x);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end else begin\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (y=n)then x:=1 else\n if (y=1)then x:=n else\n if (o=1)then x:=n else\n x:=1;\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n o,n,x,y,i,m:longint;\n s:ansistring;\n\nbegin\n readln(n,x,y);\n readln(s);\n if (s[4]='h')then o:=1 else o:=2;\n readln(s);\n m:=length(s);\n for i:=1 to m-1 do begin\n if (s[i]='0')then begin\n if (x=1)then inc(x)else\n if (x=n)then dec(x)else\n if (abs(x-1-y)>abs(x+1-y))then dec(x)else\n inc(x);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end else begin\n if (y=1)and(o=1)then o:=2;\n if (y=n)and(o=2)then o:=1;\n if (o=1)then dec(y)else inc(y);\n if (y=n)then x:=1 else\n if (y=1)then x:=n else\n if (o=1)then begin\n x:=n;\n if (s[i+1]='0')and(y=n-1)then x:=1;\n end else begin\n x:=1;\n if (s[i+1]='0')and(y=2)then x:=n;\n end;\n if (x=y)then begin writeln('Controller ',i);exit;end;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\nb:array[1..10000] of char;\nn,m,i,k,l,j,p:longint;\ns:string;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to tail' then p:=1 else p:=0;\ni:=0;\nwhile not eoln do\n begin\n inc(i);\n read(b[i]);\n end;\nif p=0 then l:=1\nelse l:=n;\nfor j:=1 to i do\n begin\n if b[j]='0' then\n if p=0 then\n dec(k) else inc(k) else\n if p=0 then l:=n else l:=1;\n if k=l then begin write('Controller',' ',j); exit;end;\n end;\nwrite('Stowaway');\nend."}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if ((k-mk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n inc(k,h);\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to n do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k < 1 Then\n Begin\n k := 2;\n dir := 'to tail';\n End;\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k > n Then\n Begin\n k := n-1;\n dir := 'to head';\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n If k < n Then\n Begin\n m := n;\n k := k-1;\n End\n Else\n Begin\n m := 1;\n k := k-1;\n End;\n End\n Else\n Begin\n If k > 1 Then\n Begin\n m := 1;\n k := k+1;\n End\n Else\n Begin\n m := n;\n k := k+1;\n End;\n End;\n End;\n Writeln('Stowaway');\nEnd.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar cm,n,i,k,m,r:integer;\ns,t:string;\nc:char;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nreadln(t);\nc:=s[4];\n\nif (c='h') and (m>k) then m:=n\nelse\nif (c='h') and (mn) then m:=n\n else\n m:=1;\n end;\nif k=m then begin write('Controller ',i); halt; end;\nend;\nwrite('Stowaway');\nend.\n"}, {"source_code": "{uses crt;\n}const nn=300;\nvar m,t,n,i,j,k,p,max,kolvag:longint;\ncc:char;\ns,nap:string; flag:boolean;\nnapcon,contr,zayaz:array[0..nn] of longint;\nbegin {clrscr;\n assign(input,'input.txt');reset(input);\n} readln (kolvag,m,k);\n readln(nap);\n readln(s);\n n:=length(s);\n if nap='to head' then napcon[1]:=-1 else napcon[1]:=1;\n contr[1]:=k;\n for i:=2 to n do\n begin contr[i]:=contr[i-1]+napcon[i-1];\n if (contr[i]=kolvag)or(contr[i]=1) then napcon[i]:=-1*napcon[i-1] else napcon[i]:=napcon[i-1];\n\n end;\n\nif s[1]='0' then zayaz[1]:=m;\nif s[1]='1' then zayaz[1]:=contr[1]-napcon[2];\nfor i:=2 to n do\n begin\n if s[i-1]='0' then if (zayaz[i-1]=1)or(zayaz[i-1]=kolvag)\n then zayaz[i]:=zayaz[i-1] else zayaz[i]:=zayaz[i-1]+napcon[i-1];\n if s[i-1]='1' then zayaz[i]:=contr[i-1];\n\n\n end;\n\n{for i:=1 to n do writeln(i,' ',contr[i],' ',zayaz[i],' ',napcon[i]); }\nfor i:=1 to n do if (contr[i]=zayaz[i])and(s[i]='0') then begin flag:=true;break;end;\n if flag then writeln('Controller',' ',i-1) else writeln('Stowaway');\n\n\n\n\n\nend."}, {"source_code": "{$apptype console}\n{$R-,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n n,m,k,i,len:longint;\n s,t:string;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n readln(n,m,k);\n readln(s);\n readln(t);\n len:=length(t);\n for i:=1 to len do\n begin\n if t[i] = '1' then\n begin\n if s[4] = 'h' then\n begin\n if k = 1 then\n begin\n s[4]:='t';\n inc(k);\n end else dec(k);\n m:=n;\n end else\n begin\n if k = n then\n begin\n s[4]:='h';\n dec(k);\n end else inc(k);\n m:=1;\n end;\n continue;\n end;\n if m > k then m:=n else m:=1;\n if s[4] = 'h' then\n begin\n if k = 1 then\n begin\n s[4]:='t';\n inc(k);\n end else dec(k);\n end else\n begin\n if k = n then\n begin\n s[4]:='h';\n dec(k);\n end else inc(k);\n end;\n if k = m then\n begin\n writeln('Controller ',i);\n exit;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n n,m,k,y,i:longint;\n s:string;\n c:char;\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then y:=-1 else y:=1;\ni:=0;\nwhile not eoln do\n begin\n read(c);\n inc(i);\n if c='0' then\n begin\n if (m<>1)and(m<>n) then\n if k>m then m:=m-1 else m:=m+1;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if k=m then \n begin\n writeln('Controller ',i);\n halt;\n end; \n end else\n if c='1' then \n begin\n m:=0;\n if k=1 then y:=1 else \n if k=n then y:=-1;\n k:=k+y;\n if n-k>k-1 then m:=n else m:=1; \n end;\n end;\nwriteln('Stowaway'); \nend."}, {"source_code": "var\na,s1:string;\ni,j,k,l,n,m:longint;\nbegin\nreadln(n,m,k);\nreadln(s1);\nread(a);\nfor i:=1 to length(a) do\n begin\n if k=1 then s1:='to tail';\n if k=n then s1:='to head';\n if (a[i]='1') and (i=length(a)) then\n begin\n write('Stawaway');\n exit;\n end;\n if ((m=1) and (k=2) and (a[i]='0') and (s1='to head')) or ((m=n) and (k=n-1) and (a[i]='0') and (s1='to tail')) then\n begin\n write('Controller ',i);\n exit;\n end;\n if mk then m:=n;\n if (a[i]='1') and (s1='to head') then m:=n;\n if (a[i]='1') and (s1='to tail') then m:=1;\n if s1='to tail' then inc(k)\n else dec(k);\n end;\nend.\n"}, {"source_code": "var n,x,y,g,max,t,i,j:longint;\n s:string;\n\nprocedure tt(x:longint);\nvar k:longint;\n begin\n k:=0;\n if g>0 then begin\n if x>=y then k:=x-y\n else k:=2*n-x-y;\n end\n else begin\n if x<=y then k:=y-x\n else k:=y-1+x-1;\n end;\n if k>max then begin\n max:=k;\n t:=x;\n end;\n end;\n\n begin\n readln(n,x,y);\n readln(s);\n if s[length(s)]='d' then g:=-1\n else g:=1;\n readln(s);\n for i:=1 to length(s) do\n begin\n if (y=1) then g:=1;\n if (y=n) then g:=-1;\n max:=-1;\n t:=x;\n if s[i]='0' then begin\n y:=y+g;\n\n\n if (x-1>=1) and (x-1<>y-g) then tt(x-1);\n if (x+1<=n) and (x+1<>y-g) then tt(x+1);\n tt(x);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end\n else begin\n y:=y+g;\n\n for j:=1 to n do\n if j<>y-g then tt(j);\n\n x:=t;\n\n if x=y-g then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n if x=y then begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\n end."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar cm,n,i,k,m,r:integer;\ns,t:string;\nc:char;\n\nbegin\nreadln(n,m,k);\nreadln(s);\nreadln(t);\nc:=s[4];\n\nif (c='h') and (m>k) then m:=n\nelse\nif (c='h') and (mn) then m:=n\n else\n m:=1;\n end;\nif k=m then begin write('Controller ',i); halt; end;\nend;\nwrite('Stowaway');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if f then begin\n if s[i]='1' then begin\n if (k>=n div 2) and (k>2) then m:=1 else m:=n;\n end else begin\n if m-k>=0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<1 then inc(m);\n end else begin\n if (k-m>0) and (m=n div 2) and (k=0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<1 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar n, m, k, kq, spt : Longint;\n a : Array[0..201] Of Longint;\n s, t : String;\n kt : boolean;\n\nProcedure ReadFile;\n Begin\n Assign(Input, fi);\n Reset(Input);\n Readln(n,m,k);\n Readln(t);\n Readln(s);\n Close(Input);\n End;\n\nProcedure WriteFile;\n Begin\n Assign(Output, fo);\n Rewrite(Output);\n If kt Then\n Writeln('Stowaway')\n Else Writeln('Controller ',kq);\n Close(Output);\n End;\n\nProcedure Init;\n Var i : Longint;\n Begin\n For i := 1 to Length(s) do\n If s[i] = '1' Then\n Begin\n Inc(spt);\n a[spt] := i;\n End;\n End;\n\nProcedure Solve;\n Var dir : Boolean;\n i, time : Longint;\n Begin\n dir := t[length(t)] = 'd';\n kt := true;\n For i := 1 to spt do\n Begin\n If dir Then\n Begin\n If m < k Then\n time := k-1\n Else time := n+k-2;\n End\n Else\n Begin\n If m > k Then\n time := n-k\n Else time := n*2-k-1;\n End;\n If time < a[i]-a[i-1] Then\n Begin\n kt := False;\n kq := a[i-1]+time;\n Break;\n End\n Else\n Begin\n if dir Then\n Begin\n k := 1;\n m := n;\n End\n Else\n Begin\n k := n;\n m := 1;\n End;\n dir := not dir;\n End;\n End;\n End;\n\nBegin\n ReadFile;\n Init;\n Solve;\n WriteFile;\nEnd."}, {"source_code": "var n,m,j,i,k,l,z,temp:longint;s,s1:string;\nprocedure xx(f:longint);\n begin\n if (temp=-1) and (k>z) and (z>1) then z:=z+temp else\n if (temp=-1) and (kz) and (z>1) then z:=z-1;\n\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=z then begin writeln('Controller ',f);halt;end;\n end;\nprocedure zz(f:longint);\n begin\n if f=length(s) then begin writeln('Stowaway');halt;end;\n k:=k+temp;\n if (k=1)or(k=n) then temp:=temp*-1;\n if k=1 then z:=n;\n if k=n then z:=1;\n if temp>0 then z:=1;\n if temp<0 then z:=n;\n end;\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(n,z,k);\nreadln(s1);\nif s1='to head' then temp:=-1 else temp:=1;\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='0' then xx(i) else zz(i);\nend.\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to n do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k < 1 Then\n Begin\n k := 2;\n dir := 'to tail';\n End;\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k > n Then\n Begin\n k := n-1;\n dir := 'to head';\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n If k < n Then\n Begin\n m := n;\n k := k-1;\n End\n Else\n Begin\n m := 1;\n k := k-1;\n End;\n End\n Else\n Begin\n If k > 1 Then\n Begin\n m := 1;\n k := k+1;\n End\n Else\n Begin\n m := n;\n k := k+1;\n End;\n End;\n End;\n Writeln('Stowaway');\nEnd.\n"}, {"source_code": "var\n n,m,k,i,pp,posk,poss:longint;\n f:boolean;\n s,s1:ansistring;\n\nbegin\n readln(n,m,k);\n readln(s);\n if s='to head' then f:=true;\n posk:=k;\n poss:=m;\n readln(s1);\n pp:=length(s1);\n\n for i:=1 to pp do if s1[i]='0' then\n begin\n if f then\n begin\n if (poss<1) then dec(poss);\n if (posk>1) then dec(posk);\n if posk=1 then f:=false;\n end else\n begin\n if (poss1) then dec(posk);\n if posk=1 then f:=false;\n end;\n if f then if posk1 then posk:=1 else posk:=2;\n if poss=posk then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\n n,m,k,i,pp,posk,poss:longint;\n f:boolean;\n s,s1:ansistring;\n\nbegin\n readln(n,m,k);\n readln(s);\n if s='to head' then f:=true;\n posk:=k;\n poss:=m;\n readln(s1);\n pp:=length(s1);\n\n for i:=1 to pp do if s1[i]='0' then\n begin\n if f then\n begin\n if (poss<1) then dec(poss);\n if (posk>1) then dec(posk);\n if posk=1 then f:=false;\n end else\n begin\n if (poss1) then dec(posk);\n if posk=1 then f:=false;\n end;\n if f then if posk1 then posk:=1 else posk:=2;\n if poss=posk then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{$M 67108864}\nuses SysUtils,math;\nvar i,n,m,k,ls,r:longint; s:string; f:boolean;\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nreadln(n,m,k);\nreadln(s);\ndelete(s,1,pos(' ',s));\nf:=false;\nif s='tail' then f:=true;\nreadln(s);\nls:=length(s);\nr:=-1;\nif k=m then r:=0 else begin\nfor i:=1 to ls do begin\n if f then begin\n if k=n then begin\n dec(k);\n f:=false;\n end else inc(k);\n end else begin\n if k=1 then begin\n inc(k);\n f:=true;\n end else dec(k);\n end;\n if f then begin\n if s[i]='1' then begin\n if k>n div 2 then m:=1 else m:=n;\n end else begin\n if m-k>0 then begin\n if (m-k>1) and (m>1) then dec(m) else\n if abs(m-k)<2 then inc(m);\n end else begin\n if (k-m>0) and (mn div 2 then m:=n else m:=1;\n end else begin\n if k-m>0 then begin\n if (k-m>1) and (m0) and (m>1) then dec(m) else \n if abs(m-k)<2 then inc(m);\n end; \n end;\n end;\n if ((k=m) or (m<1) or (m>n)) and (i<>ls) then begin\n r:=i;\n break;\n end;\nend;\nend;\nif r=-1 then write('Stowaway') else write('Controller ',r);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "var n,m,k,i,napr:longint;\n s:String;\n a:array[0..51] of longint;\n\nprocedure fun1;\nbegin\n if (Napr=1) and (m+1=k) then begin\n if m=1 then begin writeln('Controller ',i); halt; end;\n dec(m);\n dec(k);\n end else\n if (napr=1) then begin\n dec(k);\n if k=0 then begin\n k:=2; napr:=3-napr;\n end;\n end else\n if (napr=2) and (m=k+1) then begin\n if m=n then begin writeln('Controller ',i); halt; end;\n inc(m);\n inc(k);\n end else\n if (napr=2) then begin\n inc(k);\n if k=n+1 then begin\n k:=n-1; napr:=3-napr;\n end;\n end;\nend;\n\nprocedure fun2;\nbegin\n if napr=2 then begin\n if k=1 then m:=n else\n m:=1;\n end else\n begin\n if k=n then m:=1 else\n m:=n;\n end;\n if napr=1 then begin\n k:=k-1;\n if k=0 then begin\n napr:=2;\n k:=2;\n end;\n end else\n if (napr=2) then begin\n inc(k);\n if k=n+1 then begin\n k:=n-1; napr:=3-napr;\n end;\n end;\n if k=m then begin writeln('Controller ',i); halt; end;\n\n\n\nend;\n\n\n\n\nbegin\nreadln(n,m,k);\nreadln(s);\nif s='to head' then napr:=1 else napr:=2;\nreadln(S);\nfor i:= 1 to length(s) do\n begin\n if s[i]='0' then fun1 else fun2;\n end;\n writeln('Stowaway');\nend.\n"}, {"source_code": "var\nmax,f,n,m,i,j,k,off,tr: longint;\ntt : longint;\ns : String;\nq : char;\na : Array[0..1000]of longint;\nb : Array[0..70,0..70,-5..5,0..201]of longint;\nfunction rec(x,y,shag,z : longint) : longint;\nvar i,tr,h,ht,shah: Longint;\nbegin\n if z > max then max := z;\n if z = f then\n begin\n b[x,y,shag,z] := maxlongint;\n exit(maxlongint);\n\n end;\n if x = y then\n begin\n b[x,y,shag,z] := z - 1;\n exit(b[x,y,shag,z]);\n end;\n if b[x,y,shag,z] <> -1 then exit(b[x,y,shag,z]);\n\n b[x,y,shag,z] := z;\n if a[z] = 1 then\n begin\n shah := shag;\n h := y + shag;\n if (h = 0)or(h = n + 1) then\n begin\n shag := -shag;\n h := y + shag;\n end;\n\n For i := 1 to n do\n begin\n if i = h then tr := z\n else\n tr := Rec(i,h,shag,z+1);\n if tr > b[x,y,shah,z] then b[x,y,shah,z] := tr;\n end;\n rec := b[x,y,shah,z];\n end\n else\n begin\n shah := shag;\n h := x + 1;\n if h <= n then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else if ht = h then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n end;\n\n h := x - 1;\n shag := shah;\n if h > 0 then\n begin\n ht := y + shag;\n if (ht = 0)or(ht = n + 1) then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if h = y then tr := z\n else if h = ht then tr := z\n else\n tr := Rec(h,ht,shag,z+1);\n if tr > b[x,y,shah,z] then tr := b[x,y,shah,z];\n\n end;\n\n shag := shah;\n ht := y + shag;\n if (ht = 0)or(ht = n+1)\n then\n begin\n shag := -shag;\n ht := y + shag;\n end;\n if ht = x then tr := z\n else\n tr := Rec(x,ht,shag,z+1);\n if b[x,y,shah,z] < tr then b[x,y,shah,z] := tr;\n\n Rec := b[x,y,shah,z];\n end;\nend;\n\n\n begin\n readln(n,m,k);\n readln(s);\n i := 0;\n while not seekeof do\n begin\n read(q);\n i := i + 1;\n if q = '1' then a[i] := 1\n else a[i] := 0;\n end;\n f := i;\n if s = 'to tail' then off := 1\n else off := -1;\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 0 to f do\n b[i,j,k,tr] := -1;\n\n\n max := -maxlongint;\n Rec(m,k,off,1);\n\n for i := 1 to n do\n for j := 1 to n do\n for k := -1 to 1 do\n for tr := 1 to f do\n if b[i][j][k][tr] <>-1 then\n begin\n if tr > max then max := tr;\n end;\n\n\n if max = f then writeln('Stowaway')\n else writeln('Controller ',max\n );\n end.\n"}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if ((k-mk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "var n,m,k,min,i,t:integer;\n s,time:string;\n controller: boolean;\nbegin\nRead(n);\nRead(m);\nReadln(k);\nReadln(s);\nreadln(time);\nIf (s='to head') then t:=-1 else t:=1;\nFor i:=1 to length(time)-1 do begin\nIf time[i]='0' then \n if ((t=-1) and (k>m)) or ((t=1) and (k1) and (m<>n) then m:=m+t;\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1)\n end\n else if ((t=-1) and (km)) then begin\n If (m<>1) and (m<>n) then m:=m-t;\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1)\n end\nelse if time[i]='1' then begin\n k:=k+t;\n If (k=1) or (k=n) then t:=t*(-1);\n if ((t=-1) and (k<>n)) then m:=n else if ((t=1) and (k<>1)) then m:=1\n else if ((t=-1) and (k=n)) then m:=1 else if ((t=1) and (k=1)) then m:=n\n end;\nIf m=k then begin controller:=true; min:=i;break end\nend;\n If controller then write('Controller ',min) else writeln('Stowaway')\nend."}, {"source_code": "var\n x,z,n,m,i,j,k,h : longint;\n s,ss,p,t : string;\n q : integer;\n f : boolean;\nbegin\n readln(n,m,k);\n readln(p);\n if pos('head',p)>0 then h:=-1 else h:=1;\n readln(s);\n x:=length(s);\n for i:=1 to x do\n begin\n f:=false;\n if (i=x)and(s[x]='1') then\n begin\n writeln('Stowaway');\n halt;\n end;\n if k=1 then h:=1 else if k=n then h:=-1;\n if s[i]='0' then if ((k-m<=m-k)and(mk) then inc(m) else if (m>1)and(m-1<>k) then dec(m);\n if s[i]='1' then\n begin\n f:=true;\n m:=0;\n end;\n inc(k,h);\n if f then if (h=1)and(k<>1) then m:=1 else if (h=-1)and(k<>n) then m:=n else\n if k=1 then m:=n else if k=n then m:=1;\n if k=m then\n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\n writeln('Stowaway');\nend."}, {"source_code": "Const\n fi = '';\n fo = '';\n\nVar s, dir : String;\n n, m, k, i : Longint;\n\nFunction Min(a, b : Longint) : Longint;\n Begin\n If a < b Then Exit(a);\n Exit(b);\n End;\n\nFunction Max(a, b : Longint) : Longint;\n Begin\n If a > b Then Exit(a);\n Exit(b);\n End;\n\nBegin\n Readln(n,m,k);\n Readln(dir);\n Readln(s);\n For i := 1 to n do\n If s[i] = '0' Then\n Begin\n If dir[7] = 'd' Then\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k-1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k-1;\n If k < 1 Then\n Begin\n k := 2;\n dir := 'to tail';\n End;\n End;\n End\n Else\n Begin\n If m < k Then\n Begin\n m := Max(m-1,1);\n k := k+1;\n If k > n Then\n Begin\n k := n-1;\n dir := 'to head';\n End;\n End\n Else\n Begin\n m := Min(m+1,n);\n k := k+1;\n If m = k Then\n Begin\n Writeln('Controller ',i);\n Exit;\n End;\n End;\n End;\n End\n Else\n Begin\n If dir[7] = 'd' Then\n Begin\n If k < n Then\n Begin\n m := n;\n k := k-1;\n End\n Else\n Begin\n m := 1;\n k := k-1;\n End;\n End\n Else\n Begin\n If k > 1 Then\n Begin\n m := 1;\n k := k+1;\n End\n Else\n Begin\n m := n;\n k := k+1;\n End;\n End;\n End;\n Writeln('Stowaway');\nEnd.\n"}, {"source_code": "var\n i,j,n,m,k,p:longint;\n napr,t:string;\n \nBEGIN\nreadln(n,m,k);\nreadln(napr);\nif (napr='to head') then p:=-1 else p:=1;\nreadln(t);\nfor i:=1 to length(t) do\n begin\n {Zayac}\n if (t[i]='0') then\n begin\n if (p=-1)and(m>k)and(m+1<=n) then inc(m);\n if (p=-1)and(m=2) then dec(m);\n if (p=1)and(m>k)and(m+1<=n) then inc(m);\n if (p=1)and(m=2) then dec(m); \n end\n else\n begin\n if (p=-1)and(k<>n) then m:=n;\n if (p=-1)and(k=n) then m:=1;\n if (p=1)and(k<>1) then m:=1;\n if (p=1)and(k=1) then m:=n;\n end;\n {Controller}\n if (k+p>=1)and(k+p<=n) then k:=k+p\n else \n begin\n p:=-p;\n k:=k+p;\n end;\n {End game?} \n if (m=k) then \n begin\n writeln('Controller ',i);\n halt;\n end;\n end;\nwriteln('Stowaway');\nEND."}], "src_uid": "2222ce16926fdc697384add731819f75"} {"source_code": "var\n\ts:string;\n\tn,i:integer;\n\tc:char;\nbegin\n\treadln(n);\n\treadln(s);\n\tfor c:='z' downto 'b' do\n\t\tbegin\n\t\t\ti:=1;\n\t\t\twhile i<=length(s) do\n\t\t\t\tbegin\n\t\t\t\t\twhile (i<=length(s)) and (s[i]=c) and ((i>1) and (s[i-1]=chr(ord(c)-1)) or (i1 then\n\t\t\t\t\t\t\t\tdec(i);\n\t\t\t\t\t\tend;\n\t\t\t\t\tinc(i);\n\t\t\t\tend;\n\t\t\t// writeln(c);\n\t\tend;\n\twriteln(n-length(s));\nend.\n", "positive_code": [{"source_code": "var\n st: string;\n a: array [0..27] of char;\n n, i, j, res: integer;\n ok: boolean;\n x: char;\n\nbegin\n readln(n);\n readln(st);\n for x := 'z' downto 'a' do\n begin\n i := i + 1;\n a[i] := x;\n end; \n for j := 1 to 26 do \n begin\n ok := false;\n i := 0;\n while i < n do\n begin\n i := i + 1;\n if ok then \n begin\n ok := false;\n i := 1;\n end;\n if(st[i] = a[j]) then \n begin\n if(i + 1 <= n) and (st[i + 1] = a[j + 1]) then \n begin\n delete(st, i, 1);\n n := n - 1;\n res := res + 1;\n i := 0;\n ok := true;\n end;\n if(i - 1 > 0) and (st[i - 1] = a[j + 1]) then \n begin\n delete(st, i, 1);\n res := res + 1;\n n := n - 1;\n i := 0;\n ok := true;\n end;\n end;\n end;\n end;\n writeln(res);\nend."}, {"source_code": " const eps=1e-14;\n besk=2000000000000000000; label 4,1,3,2,44,22;\n type mas=array[-1000000..1200000+1] of int64;\n integer=longint; zap=record x,y,z:int64; end;\n zap1=^zap;\n var pos,ii,qqq,oldpos,jj,kolvzv,sdvig,dl,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\n ss3,ss,ss1,ss2:string;\n aans:zap;\n pqqq:zap; bet,al:extended; fl1,fl2,fl:boolean;\n drans,dr3,dr1,dr2,pt,ott1,ott2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n nomer,nap,ot,stepen,delit,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,aa,bb,kool,sum,number,imin,kolreber,kolstan,qq,kol,chisl,znam,n,m,ttt,numpos,vx,vy,ans,up,down,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,dx,dy,time,p3,p4,qqqq,tt,pmax,pmax2,p1,p2,ott,hh,pos0,pos1,pos2,pp,mm,maxot,tmax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n zzz,fact,z,stan,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n oldmax,newmax,posmax,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zan2,zan1,prost,marked,zan:array[-1000000..1000000] of boolean;\n num,start,finish,left,right,zz,ll,rr,path,lx,a3,a4,predok,a1,b1:array[-1000000..1500000] of int64;\n ppole1,ppole2,ppole:array[-1000000..3000000] of char;\n bufer, str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dddd,ssumitog,profil:array[-100..110,-100..110,-100..110] of int64;\n sss1,sss2,sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n verch,verzn:array[-10..1100000] of int64;\n dd1,dd2,dd,ddinv:array[-1..310000,-1..30] of int64;\n poss:int64;\n obmen,ch:char;\n\n ff,flagg1:boolean;\n oldx,oldy,numx,numy,xleft,xright,s,znach,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..1700002] of int64;\n dp:array[0..3,-1..910,0..12] of int64;\n function srav(i,j:longint):boolean; label 44;\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]pp) then\n begin ot:=i; pp:=ord(ss[i]); end;\n\n hod:=ot;\nend;\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(p);\n readln(ss);\n\n while (hod(ss)>0)and(q<100000) do\n begin\n { writeln(ss);\n } inc(q);\n t:=length(ss);\n ii:=hod(ss);\n ss1:=copy(ss,1,ii-1);\n ss2:=copy(ss,ii+1,t-ii);\n ss:=ss1+ss2;\n { writeln(ss);\n writeln;\n }\n\n end;\n\n writeln(q);\n\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n"}, {"source_code": "uses math;\nvar n,i,j,k,ans,j1:longint;st:ansistring;l,r:array[0..500,0..500]of char;f:array[0..500,0..500]of longint;\nbegin\n readln(n);\n readln(st);\n while 1=1 do\n begin\n j:=0;j1:=ord('a')-1;\n for i:=1 to length(st)-1 do\n if abs(ord(st[i])-ord(st[i+1]))=1 then\n if (j=0)or(j<>0)and(max(ord(st[i]),ord(st[i+1]))>j1) then\n begin\n j1:=max(ord(st[i]),ord(st[i+1]));\n if j1=ord(st[i]) then j:=i else j:=i+1;\n end;\n if j=0 then break;\n delete(st,j,1);\n inc(ans);\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "var\n i, j , n, ans, m, k, p : longint;\n s : string;\n c : char;\nbegin\n readln(n);\n readln(s);\n ans := 0;\n for i := 1 to n do\n begin\n m := 0;\n p := 0;\n for j := 1 to length(s) do\n begin\n if (j > 1) then\n if (ord(s[j]) > m) and (ord(s[j-1]) = ord(s[j])+1) then\n begin\n m := ord(s[j]);\n p := j;\n end;\n if (j < length(s)) then\n if (ord(s[j]) > m) and (ord(s[j+1]) = ord(s[j])+1) then\n begin\n m := ord(s[j]);\n p := j;\n end;\n end;\n if (p = 0) then\n begin\n writeln(ans);\n exit;\n end;\n if (p > 1) then\n if (ord(s[p-1]) = ord(s[p])+1) then\n begin\n delete(s, p-1, 1);\n inc(ans);\n end;\n if (p < length(s)) then\n if (ord(s[p+1]) = ord(s[p])+1) then\n begin\n delete(s, p+1, 1);\n inc(ans);\n end;\n end;\nend."}, {"source_code": "var\nn,m,z,h,k,p:int64;\ni,j:longint;\ns:ansistring;\nmax:char;\nbegin\nreadln(n);\nreadln(s);\nn:=length(s);\ns:='0'+s;\ns:=s+'0';\nmax:='1';\nwhile max<>'0' do\nbegin\nmax:='0';\np:=1;\nfor i:= 2 to length(s)-2+1 do\nif (ord(s[i])-ord(s[i-1])=1) or (ord(s[i])-ord(s[i+1])=1) then\nif ord(s[i])>ord(max) then\nbegin\np:=i;\nmax:=s[i];\nend;\ndelete(s,p,1);\ninc(z);\nend;\nwriteln(z-1);\nend."}, {"source_code": "var n,i,ans,flag,j:longint;c:char;s:string;\nbegin\nreadln(n);readln(s);\nfor c:='z' downto 'b' do\n begin\n while true do\n begin\n flag:=0;\n for i:=1 to n do\n if(s[i]=c)and((s[i-1]=pred(c))or(s[i+1]=pred(c)))then\n begin\n flag:=1;ans:=ans+1;\n for j:=i to n-1 do s[j]:=s[j+1];\n s[n]:='{';n:=n-1;break;\n end;\n if(flag=0)then break;\n end;\n end;\nwriteln(ans);\nend."}, {"source_code": "uses math;\nvar n,i,j,k,ans,j1:longint;st:ansistring;l,r:array[0..500,0..500]of char;f:array[0..500,0..500]of longint;\nbegin\n readln(n);\n readln(st);\n while 1=1 do\n begin\n j:=0;j1:=ord('a')-1;\n for i:=1 to length(st)-1 do\n if abs(ord(st[i])-ord(st[i+1]))=1 then\n if (j=0)or(j<>0)and(max(ord(st[i]),ord(st[i+1]))>j1) then\n begin\n j1:=max(ord(st[i]),ord(st[i+1]));\n if j1=ord(st[i]) then j:=i else j:=i+1;\n end;\n if j=0 then break;\n delete(st,j,1);\n inc(ans);\n end;\n writeln(ans);\nend.\n\n\n"}], "negative_code": [{"source_code": "var\n\ts:string;\n\tn,i:integer;\n\tc:char;\nbegin\n\treadln(n);\n\treadln(s);\n\tfor c:='z' downto 'b' do\n\t\tbegin\n\t\t\ti:=1;\n\t\t\twhile i<=length(s) do\n\t\t\t\tbegin\n\t\t\t\t\twhile (i<=length(s)) and (s[i]=c) and ((i>1) and (s[i-1]=chr(ord(c)-1)) or (i'0' do\nbegin\nmax:='0';\np:=1;\nfor i:= 2 to length(s)-2+1 do\nif (ord(s[i])-ord(s[i-1])=1) or (ord(s[i])-ord(s[i+1])=1) then\nif ord(s[i])>ord(max) then\nbegin\np:=i;\nmax:=s[i];\nend;\ndelete(s,p,1);\ninc(z);\nend;\nwriteln(z-1);\nend."}, {"source_code": " const eps=1e-14;\n besk=2000000000000000000; label 4,1,3,2,44,22;\n type mas=array[-1000000..1200000+1] of int64;\n integer=longint; zap=record x,y,z:int64; end;\n zap1=^zap;\n var pos,ii,qqq,oldpos,jj,kolvzv,sdvig,dl,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\n ss3,ss,ss1,ss2:string;\n aans:zap;\n pqqq:zap; bet,al:extended; fl1,fl2,fl:boolean;\n drans,dr3,dr1,dr2,pt,ott1,ott2:zap;\n ver:array[-1..500,-1..5] of extended;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n nomer,nap,ot,stepen,delit,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,aa,bb,kool,sum,number,imin,kolreber,kolstan,qq,kol,chisl,znam,n,m,ttt,numpos,vx,vy,ans,up,down,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,dx,dy,time,p3,p4,qqqq,tt,pmax,pmax2,p1,p2,ott,hh,pos0,pos1,pos2,pp,mm,maxot,tmax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n zzz,fact,z,stan,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n oldmax,newmax,posmax,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zan2,zan1,prost,marked,zan:array[-1000000..1000000] of boolean;\n num,start,finish,left,right,zz,ll,rr,path,lx,a3,a4,predok,a1,b1:array[-1000000..1500000] of int64;\n ppole1,ppole2,ppole:array[-1000000..3000000] of char;\n bufer, str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dddd,ssumitog,profil:array[-100..110,-100..110,-100..110] of int64;\n sss1,sss2,sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n verch,verzn:array[-10..1100000] of int64;\n dd1,dd2,dd,ddinv:array[-1..310000,-1..30] of int64;\n poss:int64;\n obmen,ch:char;\n\n ff,flagg1:boolean;\n oldx,oldy,numx,numy,xleft,xright,s,znach,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..1700002] of int64;\n dp:array[0..3,-1..910,0..12] of int64;\n function srav(i,j:longint):boolean; label 44;\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]0)and(q<100000) do\n begin\n { writeln(ss);\n } inc(q);\n t:=length(ss);\n ii:=hod(ss);\n ss1:=copy(ss,1,ii-1);\n ss2:=copy(ss,ii+1,t-ii);\n ss:=ss1+ss2;\n { writeln(ss);\n writeln;\n }\n\n end;\n\n writeln(q);\n\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n"}], "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38"} {"source_code": "program hh4;\n\nuses math;\n\nconst fi='';//'hh4.inp';\n fo='';//'hh4.out';\n maxn=60;\n\nvar n,code,i,j:longint;\n Res:int64;\n f:array[0..maxn,-20..20] of int64;\n a,b:array[0..maxn]of longint;\n s:String;\n ok:boolean;\n f1,f2:text;\n\n\nBEGIN\n assign(f1,fi);reset(f1);\n assign(F2,fo);rewrite(f2);\n readln(f1,s);\n n:=length(s);\n\n for i:=1 to n do\n val(s[i],a[i],code);\n\n for i:=0 to 9 do\n f[1][i]:=1;\n\n for i:=2 to length(s) do\n begin\n for j:=0 to 9 do\n f[i][j] := f[i-1][2*j+1 -a[i]] + f[i-1][2*j - a[i]]\n +f[i-1][2*j-1-a[i]];\n end;\n\n Res:=0; b[1]:=a[1];\n for i:=0 to 9 do\n Res:=res + f[n][i];\n\n ok:=true;\n for i:=2 to n do\n begin\n b[i]:=(b[i-1] + a[i]);\n if abs(b[i] - 2*a[i])>1 then ok:=false;\n b[i]:=a[i];\n end;\n\n if ok then dec(res);\n\n writeln(f2,res);\n close(f1);close(f2);\nEND.", "positive_code": [{"source_code": "program zH;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s:string;\n pok,i,j,k:longint;\n f:array[-100..100,-100..100]of int64;\n ans,n:int64;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(s);\n n:=length(s);\n for i:=0 to 9 do\n f[1,i]:=1;\n for i:=2 to n do\n begin\n k:=strtoint(s[i]); \n for j:=0 to 9 do\n begin\n f[i,j]:=f[i-1,2*j-k]+f[i-1,2*j-1-k]+f[i-1,2*j+1-k];\n end;\n end;\n ans:=0;\n pok:=1;\n for i:=2 to n do\n begin\n if not((strtoint(s[i])+strtoint(s[i-1])=2*strtoint(s[i]))or(strtoint(s[i])+strtoint(s[i-1])=2*strtoint(s[i])+1)or(strtoint(s[i])+strtoint(s[i-1])=2*strtoint(s[i])-1)) then pok:=0;\n end;\n ans:=ans-pok;\n for i:=0 to 9 do\n ans:=ans+f[n,i];\n writeln(ans);\nend.\n "}, {"source_code": "const\n fi='';\n fo='';\n maxn=50;\nvar\n f1,f2 :text;\n f :array[0..maxn,0..9] of int64;\n a :array[0..maxn] of longint;\n n :longint;\n res :int64;\n\nprocedure mof;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\n\nprocedure dongf;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure nhap;\nvar s:string;i,m:longint;\n begin\n readln(f1,s);\n n:=length(S);\n for i:=1 to n do\n val(s[i],a[i],m);\n end;\n\nprocedure work;\n var i,j,t:longint; ok:boolean;\n\n begin\n fillchar(f,sizeof(f),0);\n\n for i:=0 to 9 do\n f[1,i]:=1;\n\n for i:=2 to n do\n for j:=0 to 9 do\n begin\n\n t:=2*j-a[i]-1;\n\n if (t>=0) and (t<=9) then\n f[i,j]:=f[i,j]+f[i-1,t];\n\n\n t:=2*j-a[i]+1;\n\n if (t>=0) and (t<=9) then\n f[i,j]:=f[i,j]+f[i-1,t];\n\n\n t:=2*j-a[i];\n if (t>=0) and (t<=9) then\n f[i,j]:=f[i,j]+f[i-1,t];\n\n end;\n\n ok:=true;\n for i:=2 to n do\n begin\n j:=a[i-1]+a[i];\n if (j div 2<>a[i]) and ((j-1) div 2<>a[i]) and ((j+1) div 2<>a[i]) then\n begin\n ok:=false;\n break;\n end;\n end;\n\n res:=0;\n for i:=0 to 9 do\n res:=res+f[n,i];\n if ok then dec(res);\n end;\n\n begin\n mof;\n nhap;\n work;\n writeln(f2,res);\n dongf;\n end."}, {"source_code": "var ss:int64;\nok:boolean;\ncode:integer;\na:array[0..1000,0..100]of int64;\nt:array[0..1000]of longint;\ni,j,n,l:longint;\ns:string;\n begin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n val(s[i],t[i],code);\n\n for j:=0 to 9 do\n a[1,j]:=1;\n\n for i:=2 to n do\n begin\n for j:=0 to 9 do\n begin\n a[i,j]:=0;\n for l:=0 to 9 do\n if ((l+t[i])div 2=j)or(((l+t[i])mod 2<>0)and(j=(l+t[i])div 2+1)) then a[i,j]:=a[i,j]+a[i-1,l];\n end;\n end;\n ss:=0;\n for l:=0 to 9 do\n ss:=ss+a[n,l];\n\n ok:=true;\n for i:=2 to n do\n if (t[i]<>t[i-1]-1)and(t[i]<>t[i-1])and(t[i]<>t[i-1]+1) then ok:=false;\n if ok then ss:=ss-1;\n writeln(ss);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n,qq,q : longint;\n f,f2 : array [0..9] of int64;\n ans,ans1 : int64;\n a,b : array [0..100000] of int64;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n {for q:=0 to 9 do\n for qq:=0 to 9 do\n begin\n if (qq>0) or (q>0) then\n begin\n close(input);\n close(output);\n end;\n rewrite(output,'input.txt');\n write(q,qq);\n close(output); }\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(s1);\n if (length(s1)=1)then\n begin\n write(9);\n halt;\n end;\n {n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n ans1:=n;\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n b[1]:=a[1];\n i:=2;\n for i:=2 to n do\n begin\n if (((b[i-1]+a[i]) div 2)<>a[i]) and (((b[i-1]+a[i]+1) div 2)<>a[i]) then\n break;\n b[i]:=a[i];\n end;\n if i>n then\n dec(ans);\n writeln(ans); \n{ if ans1<>ans then\n break;\n end; }\nend.\n\n\n\n\n\n\n"}, {"source_code": "\nvar S:string;\n LS,i,xy,j,x:longint;\n k:int64;\n A:array[1..50] of integer;\n B:array[0..9,1..50] of int64;\n T:boolean;\n\nBegin\n\n read(S);\n\n LS:=Length(S);\n for i:=1 to LS do A[i]:=ord(S[i])-48;\n\n FillChar(B,SizeOf(B),0);\n for i:=0 to 9 do B[i,1]:=1;\n\n for i:=2 to LS do\n for j:=0 to 9 do\n begin\n xy:=A[i]+j;\n if xy and 1=0\n then B[xy shr 1 ,i]:=B[xy shr 1 ,i]+B[j,i-1]\n else begin\n B[xy shr 1+1,i]:=B[xy shr 1+1,i]+B[j,i-1];\n B[xy shr 1 ,i]:=B[xy shr 1 ,i]+B[j,i-1];\n end;\n end;\n for i:=0 to 9 do\n inc(k,B[i,LS]);\n\n x:=A[1]; T:=True;\n for i:=2 to LS do\n begin\n if (x+A[i]) and 1=0\n then begin\n x:=(x+A[i]) shr 1;\n if x<>A[i]\n then T:=False;\n end\n else if ((x+A[i]) shr 1=A[i]) or ((x+A[i]) shr 1+1=A[i])\n then if (x+A[i]) shr 1=A[i]\n then x:=(x+A[i]) shr 1\n else x:=(x+A[i]) shr 1+1\n else T:=False;\n end;\n if T\n then writeln(k-1)\n else writeln(k );\n\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$M 16777216}\nuses\n SysUtils;\nvar st,ans,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\nsn:string;\ndp:array[0..111,0..111] of int64;\na:array[1..11111111] of string;\n\nconst constchr:array [0..9] of char=('0','1','2','3','4','5','6','7','8','9');\n\nfunction makestring(x:integer):char;\nbegin\nmakestring:=constchr[x];\nend;\n\nprocedure dfs(x:char;pos:int64);\nvar num,d:int64;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=ord(x)-ord('0');\nif pos=length(sn) then\n inc(cnt)\nelse\nbegin\nnum:=ord(sn[pos+1])-ord('0');\n\ndfs(makestring((num+d) div 2),pos+1);\n\nif (num+d) mod 2 = 1 then\ndfs(makestring((num+d) div 2 + 1),pos+1);\nend;\n\nend;\n\n\n\nvar chr:char;\nbegin\n readln(sn);\n //sn:=0;\n{ st:=0;\n while st<>0 do\n begin\n st:=st div 10;\n s[i]:=st mod 10;\n end; }\n\ncnt:=0;\n\nans:=0;\n\n// for Int := 1 to cnt do\n // writeln(a[int]);\n\n flag:=true;\n for I := 2 to length(sn) do\n if ord(sn[i])-ord(sn[i-1])>1 then flag:=false;\n\nif flag then ans:=1;\n\nfor I := 0 to 9 do\n dp[i,1]:=1;\n\nfor I := 2 to length(sn) do\n for j := 0 to 9 do\n begin\n if (2*j-ord(sn[i])+ord('0')>=0) and (2*j-ord(sn[i])+ord('0')<=9) then\n dp[j,i]:=dp[j,i]+dp[2*j-ord(sn[i])+ord('0'),i-1];\n\n if (2*j-ord(sn[i])+ord('0')>=-1) and (2*j-ord(sn[i])+ord('0')<=8) then\n dp[j,i]:=dp[j,i]+dp[2*j-ord(sn[i])+ord('0')+1,i-1];\n\n if (2*j-ord(sn[i])+ord('0')>=1) and (2*j-ord(sn[i])+ord('0')<=10) then\n dp[j,i]:=dp[j,i]+dp[2*j-ord(sn[i])+ord('0')-1,i-1];\n\n end;\n\nfor I := 0 to 9 do\ncnt:=cnt+dp[i,length(sn)];\n\n//for chr := '0' to '9' do\n//dfs(chr,1);\n\n// 000000000000000000000000000000000000000000000000000000000000\n {\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n }\n\n// for Int := 1 to cnt do\n// writeln(a[int]);\n{\n i:=1;\n for I := 1 to cnt do\n if a[i]<>-1 then\n begin\n j:=i+1;\n while a[i]=a[j] do\n begin\n a[j]:=-1;\n inc(j);\n end;\n\n end;\n}\n// ans:=0;\n //for I := 1 to cnt do\n\n writeln(cnt-ans);\n//while True do\n\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar s:string;\nk:int64;\ni,q,q1,pr,pr1,j:integer;\na:array[1..53,0..9] of int64;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(s);\n for i := 0 to 9 do\n a[1,i]:=1;\n\n for i := 2 to length(s) do\n begin\n val(s[i],q,pr);\n for j:=0 to 9 do\n if (q+j) mod 2=0 then a[i,(q+j) div 2]:=a[i-1,j]+a[i,(q+j) div 2]\n else\n begin\n a[i,(q+j) div 2]:=a[i-1,j]+a[i,(q+j) div 2];\n a[i,(q+j) div 2+1]:=a[i-1,j]+a[i,(q+j) div 2+1];\n end;\n end;\n k:=0;\n pr1:=0;\n for i:=0 to 9 do k:=k+a[length(s),i];\n val(s[1],q1,pr);\n for i:= 2 to length(s) do\n begin\n val(s[i],q,pr);\n if (q+q1) mod 2 =0 then begin if ((q+q1) div 2)<>q then pr1:=1; end\n else if (((q+q1) div 2)<>q) and (((q+q1+1) div 2)<>q) then pr1:=1;\n q1:=q;\n end;\n\n\n\nif pr1=0 then dec(k);\n writeln(k);\n\n{close(input);\nclose(output); }\nend.\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n,qq,q : longint;\n f,f2 : array [0..9] of int64;\n ans,ans1 : int64;\n a,b : array [0..100000] of int64;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n {for q:=0 to 9 do\n for qq:=0 to 9 do\n begin\n if (qq>0) or (q>0) then\n begin\n close(input);\n close(output);\n end;\n rewrite(output,'input.txt');\n write(q,qq);\n close(output); }\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(s1);\n if (length(s1)=1)then\n begin\n write(9);\n halt;\n end;\n {n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n ans1:=n;\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n b[1]:=a[1];\n i:=2;\n for i:=2 to n do\n begin\n if (((b[i-1]+a[i]) div 2)<>a[i]) and (((b[i-1]+a[i]+1) div 2)<>a[i]) then\n break;\n b[i]:=a[i];\n end;\n if i>n then\n dec(ans);\n writeln(ans); \n{ if ans1<>ans then\n break;\n end; }\nend.\n\n\n\n\n\n\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n n,i,d,p: longint;\n ok: boolean;\n s: ansistring;\n ans: int64;\n f: array [0..1010,0..10] of int64;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n readln(s);\n n:=length(s);\n fillchar(f,sizeof(f),0);\n for d:=0 to 9 do f[1,d]:=1;\n for i:=1 to n-1 do\n for d:=0 to 9 do\n begin\n p:=d+Ord(s[i+1])-48;\n inc(f[i+1,p shr 1],f[i,d]);\n if p and 1 = 1 then inc(f[i+1,(p+1) shr 1],f[i,d]);\n end;\n ans:=0;\n for d:=0 to 9 do inc(ans,f[n,d]);\n ok:=True;\n for i:=2 to length(s) do\n if abs(Ord(s[i])-Ord(s[i-1])) > 1 then ok:=False;\n if ok then dec(ans);\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "var\n s:string;\n a,b:array[1..111]of longint;\n ff,jj,n,i,j:longint;\n f:array[1..111,-10..19]of extended;\n ans:extended;\nbegin\n readln(s);\n n:=length(s);\n ans:=0;\n for i:=1 to n do a[i]:=ord(s[i])-48;\n\n for i:=0 to 9 do f[1,i]:=1;\n\n for i:=1 to n-1 do for j:=0 to 9 do \n begin\n jj:=(a[i+1]+j)div 2;\n f[i+1,jj]:=f[i+1,jj]+f[i,j];\n if (a[i+1]+j)mod 2=1 then f[i+1,jj+1]:=f[i+1,jj+1]+f[i,j];\n end;\n b[1]:=a[1];\n ff:=1;\n for i:=2 to n do\n begin\n if (a[i]+b[i-1])div 2=a[i] then b[i]:=a[i] else\n if ((a[i]+b[i-1])mod 2=1)and(((a[i]+b[i-1])div 2)+1=a[i])then b[i]:=a[i] else\n begin\n ff:=0;\n break;\n end;\n end;\n ans:=ans-ff;\n for i:=0 to 9 do ans:=ans+f[n,i];\n writeln(ans:0:0);\nend."}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, i : integer;\n ans : int64;\n s : string;\n a : array[0..51] of integer;\n d : array[0..51, 0..10] of int64;\n\nprocedure gets(var s : string);\nvar c : char;\nbegin\n s := '';\n read(c);\n while not (c in ['0'..'9']) do\n read(c);\n while c in ['0'..'9'] do begin\n s := s + c;\n read(c);\n end;\nend;\n\nprocedure solve(b1 : integer);\nvar i, j, z : integer;\nbegin\n for i := 1 to n do\n for j := 0 to 9 do\n d[i, j] := 0;\n d[1, b1] := 1;\n for i := 2 to n do\n for j := 0 to 9 do begin\n z := j + a[i];\n d[i, z div 2] := d[i, z div 2] + d[i - 1, j];\n if z mod 2 = 1 then\n d[i, z div 2 + 1] := d[i, z div 2 + 1] + d[i - 1, j];\n end;\n for i := 0 to 9 do\n ans := ans + d[n, i];\nend;\n\nfunction good() : boolean;\nvar i, j : integer;\nbegin\n result := true;\n for i := 2 to n do begin\n j := a[i - 1] + a[i];\n if j mod 2 = 0 then begin\n if a[i] <> j div 2 then begin\n result := false;\n exit;\n end;\n end\n else begin\n if (a[i] <> j div 2) and (a[i] <> j div 2 + 1) then begin\n result := false;\n exit;\n end;\n end;\n end;\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n gets(s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n ans := 0;\n for i := 0 to 9 do\n solve(i);\n if good() then\n ans := ans - 1;\n writeln(ans);\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i, j, n : longint;\n res : int64;\n a : array[1..50] of longint;\n b, b2 : array[0..9] of int64;\n s : string;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n\n readln(s);\n s := trim(s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n\n for i := 0 to 9 do\n b[i] := 1;\n\n for i := 2 to n do\n begin\n fillchar(b2, sizeof(b2), 0);\n for j := 0 to 9 do\n begin\n b2[(a[i] + j) div 2] := b2[(a[i] + j) div 2] + b[j];\n if ((a[i] + j) div 2) <> ((a[i] + j + 1) div 2) then\n b2[(a[i] + j + 1) div 2] := b2[(a[i] + j + 1) div 2] + b[j];\n end;\n b := b2;\n end;\n\n res := 0;\n for i := 0 to 9 do\n res := res + b[i];\n res := res - 1;\n for i := 2 to n do\n if ((a[i] + a[i - 1]) div 2 <> a[i]) and ((a[i] + a[i - 1] + 1) div 2 <> a[i]) then\n begin\n res := res + 1;\n break;\n end;\n write(res);\n // close(input);\n // close(output);\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a:array[1..60]of integer;\n y:array[1..60,1..60,0..9]of integer;\n n,i,k:integer;\n q:int64;\n c:char;\n b:boolean;\nfunction rec(m,t,c:integer):int64;\nvar\n k:integer;\nbegin\nif y[m,t,c]>0 then\n result:=y[m,t,c] else\nbegin\n if m>t then\n result:=1 else\n begin\n result:=0;\n k:=(a[m]+c) div 2;\n if (a[m]+c) mod 2=1 then\n begin\n if (a[m+1]+k)=(a[m+1]+k+1) then\n result:=rec(m+1,t,k)*2 else\n result:=rec(m+1,t,k)+rec(m+1,t,k+1);\n end else\n result:=rec(m+1,t,k);\n end;\n y[m,t,c]:=result;\nend;\nend;\nbegin\n n:=0;\n while not eof do\n begin\n read(c);\n if (c>='0')and(c<='9') then\n begin\n n:=n+1;\n a[n]:=ord(c)-ord('0');\n end;\n end;\n q:=0;\n for i := 0 to 9 do\n q:=q+rec(2,n,i);\n b:=true;\n for I := 2 to n do\n if abs((a[i]+a[i-1]) div 2-a[i])>1 then\n begin\n b:=false;\n break;\n end;\n if b then\n q:=q-1;\n\n\n\n writeln(q);\nend."}, {"source_code": "var\n sum: int64;\n i,j,k:longint;\n s:string;\n b:boolean;\n arr:array [0..9,1..50] of int64;\nBegin\n readln(s);\n for i:=0 to 9 do arr[i,1]:=1;\n for j:=2 to length(s) do\n begin\n for k:=0 to 9 do\n begin\n if (k+ord(s[j])-48) mod 2 = 0 then\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n end\n else\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n arr[(k+ord(s[j])-48 )div 2 +1,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2 +1,j];\n end;\n \n end;\n end;\n sum:=0;\n for i:=0 to 9 do\n sum:=arr[i,length(s)]+sum;\n b:=true;\n for i:=1 to length(s)-1 do \n Begin\n if (ord(s[i])+ord(s[i+1])-48*2) mod 2 = 0 then \n Begin\n if ((ord(s[i])+ord(s[i+1])-48*2) div 2) <> (ord(s[i+1])-48) then b:=false;\n end\n else \n if not (((ord(s[i])+ord(s[i+1])-48*2) div 2 +1 = ord(s[i+1])-48) or ((ord(s[i])+ord(s[i+1])-48*2) div 2= ord(s[i+1])-48)) then b:=false;\n \n End;\n if b then dec(sum);\n writeln(sum);\nEnd."}, {"source_code": "var ss:ansistring;\n answer:int64; i,j,n,s:longint;\n a:array[0..100]of longint;\n dp:array[0..50,0..10]of int64;\n\nfunction can:boolean;\nvar j:longint; x,x1,x2:longint;\nbegin\n x:=a[1];\n\n for j:=2 to n do\n begin\n s:=x+a[j];\n x1:=s div 2;\n x2:=s div 2 + s mod 2;\n\n if (x1<>a[j])and(x2<>a[j]) then exit(false);\n\n x:=a[j];\n end;\n\n can:=true;\nend;\n\n begin\n readln(ss);\n n:=length(ss);\n for i:=1 to n do\n a[i]:=ord(ss[i])-48;\n\n for i:=0 to 9 do\n dp[1,i]:=1;\n\n for i:=1 to n-1 do\n for j:=0 to 9 do\n if dp[i,j]>0 then\n begin\n s:=j+a[i+1];\n\n if s mod 2=0 then dp[i+1,s div 2]:=dp[i+1,s div 2]+dp[i,j]\n else\n begin\n inc(dp[i+1,s div 2],dp[i,j]);\n inc(dp[i+1,s div 2+1],dp[i,j]);\n end;\n end;\n\n answer:=0;\n for j:=0 to 9 do\n answer:=answer+dp[n,j];\n\n if can then answer:=answer-1;\n\n writeln(answer);\n end."}, {"source_code": "program Progs;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils, Math;\n\ntype\n Int32 = Integer;\n TCounts = array[1..50] of array[0..9] of Int64;\n\nfunction CheckDigits(const S: string): Boolean;\nvar\n I: Int32;\n LPrev: Int32;\n LCurr: Int32;\nbegin\n Result := True;\n for I := 2 to Length(S) do\n begin\n LPrev := Ord(S[I - 1]);\n LCurr := Ord(S[I]);\n if ((LPrev + LCurr) shr 1 <> LCurr) and\n ((LPrev + LCurr + 1) shr 1 <> LCurr) then\n begin\n Result := False;\n Break;\n end;\n end;\nend;\n\nvar\n S: string;\n I, J, N: Int32;\n Counts: TCounts;\n CurrDigit: Int32;\n Result: Int64;\n\nbegin\n Readln(S);\n N := Length(S);\n\n for I := 0 to 9 do\n begin\n Counts[1][I] := 1;\n for J := 2 to N do\n Counts[J][I] := 0;\n end;\n\n for I := 2 to N do\n begin\n for J := 0 to 9 do\n begin\n CurrDigit := Ord(S[I]) - Ord('0');\n Counts[I][(CurrDigit + J) shr 1] := Counts[I][(CurrDigit + J) shr 1] + Counts[I - 1][J];\n if (CurrDigit and 1) <> (J and 1) then\n Counts[I][(CurrDigit + J) shr 1 + 1] := Counts[I][(CurrDigit + J) shr 1 + 1] + Counts[I - 1][J];\n end;\n end;\n\n Result := 0;\n for I := 0 to 9 do\n Inc(Result, Counts[N][I]);\n\n if CheckDigits(S) then\n Dec(Result);\n\n Writeln(Result);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n f:text;\n St:string;\n A:array[1..100,-20..20] of int64;\n res:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,St);\n close(F);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(F);\n writeln(f,res);\n close(F);\nend;\nprocedure process;\nvar i,t,h,j:longint;xet:boolean;\nbegin\n fillchar(A,sizeof(A),0);\n for i:=0 to 9 do A[1,i]:=1;\n xet:=true;\n for i:=2 to length(St) do\n begin\n t:=ord(St[i])-48;\n for j:=0 to 9 do\n begin\n A[i,j]:=A[i-1,2*j-t]+A[i-1,2*j-t+1]+A[i-1,2*j-t-1];\n h:=ord(St[i-1])-48;\n if j=t then\n begin\n if (h=2*j-t-1) or ((h=2*j-t) or (h=2*j-t+1)) then\n begin\n if A[i-1,h]=0 then xet:=false;\n end\n else xet:=false;\n end;\n end;\n end;\n res:=0;\n for i:=0 to 9 do res:=res+A[length(St),i];\n if xet then res:=res-1;\nend;\nbegin\n nhap;\n process;\n xuat;\nend.\n"}, {"source_code": "program h;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n i,j,n,z,ii:longint;\n r,d:int64;\n a:array[1..1000] of int64;\n b:array[0..100,0..10000] of int64;\n\nbegin\n readln(s);\n for i:=1 to length(s) do a[i]:=(ord(s[i])-ord('0'));\n fillchar(b,sizeof(b),0);\n n:=length(s);\n r:=0;\n for z:=0 to 9 do begin\n fillchar(b,sizeof(b),0);\n b[1,z]:=1;\n for i:=2 to n do\n begin\n for j:=0 to 9 do\n if b[i-1,j]<>0 then\n begin\n d:=a[i]+j;\n if d mod 2=0 then inc(b[i,d div 2],b[i-1,j]) else\n begin inc(b[i,d div 2],b[i-1,j]);\n inc(b[i,d div 2+1],b[i-1,j]); end;\n end;\n end;\n\n for i:=0 to 9 do\n r:=r+b[n,i];\n end;\n ii:=0;\n for i:=1 to n-1 do if abs(a[i]-a[i+1])>1 then ii:=1;\n if ii=0 then dec(r);\n writeln(r);\nend.\n"}, {"source_code": "Const\n fi = '';\n fo = '';\n MaxN = 55;\n\nType Arr1 = Array[0..MaxN+1,0..10] Of Qword;\n Arr2 = Array[0..MaxN+1] Of Longint;\n\nVar f : Arr1;\n a : Arr2;\n s : String;\n n, i, j : Longint;\n kq : Qword;\n\nFunction check(x : qword) : boolean;\n Var y, i : longint; \n Begin\n y := a[1];\n for i := 2 to n do\n begin\n y := y+a[i];\n if (y div 2 = a[i]) or (y div 2+1 = a[i]) then\n y := a[i]\n else exit(false);\n end;\n exit(true);\n End;\n\nBegin\n assign(input,fi); reset(input);\n readln(s);\n close(input);\n /////////\n n := length(s);\n for j := 0 to 9 do\n f[n,j] := 1;\n for i := 1 to length(s) do\n a[i] := ord(s[i])-48;\n //////////\n for i := n-1 downto 1 do\n for j := 0 to 9 do\n begin\n f[i,j] := f[i,j] + f[i+1,(j+a[i+1])div 2];\n if odd(j+a[i+1]) then\n f[i,j] := f[i,j] + f[i+1,(j+a[i+1])div 2+1];\n end;\n kq := 0;\n for j := 0 to 9 do\n kq := kq + f[1,j];\n if check(kq) then dec(kq);\n writeln(kq);\nEnd.\n"}, {"source_code": "var a:array[0..60,0..9]of int64;\n b:array[0..60]of longint;\n n:longint;\n s:string;\n res:int64;\n\nprocedure xuly;\nvar i,j,k:longint;\nbegin\n n:=length(s);\n for i:=1 to n do b[i]:=ord(s[i])-48;\n\n for i:=0 to 9 do a[1,i]:=1;\n\n for i:=2 to n do\n for j:=0 to 9 do\n begin\n k:=j+b[i];\n inc(a[i,k div 2],a[i-1,j]);\n if k mod 2=1 then inc(a[i,(k+1) div 2],a[i-1,j]);\n end;\nend;\n\nprocedure tinhkq;\nvar i,k:longint;\n kt:boolean;\nbegin\n res:=0;\n for i:=0 to 9 do inc(res,a[n,i]);\n\n for i:=2 to n do\n begin\n k:=b[i]+b[i-1];\n if ((k div 2) <> b[i]) and (((k+1) div 2)<> b[i]) then exit;\n end;\n\n dec(res);\nend;\n\nbegin\n readln(s);\n if length(s)=1 then\n begin\n writeln(9);\n halt;\n end;\n xuly;\n tinhkq;\n writeln(res);\nend."}, {"source_code": "var a:array[0..59,0..9]of int64;\n b:array[0..59]of longint;\n n:longint;\n s:string;\n res:int64;\n\nprocedure xuly;\nvar i,j,k:longint;\nbegin\n n:=length(s);\n for i:=1 to n do b[i]:=ord(s[i])-48;\n\n for i:=0 to 9 do a[1,i]:=1;\n\n for i:=2 to n do\n for j:=0 to 9 do\n begin\n k:=j+b[i];\n inc(a[i,k div 2],a[i-1,j]);\n if k mod 2=1 then inc(a[i,(k+1) div 2],a[i-1,j]);\n end;\nend;\n\nprocedure tinhkq;\nvar i,k:longint;\n kt:boolean;\nbegin\n res:=0;\n for i:=0 to 9 do inc(res,a[n,i]);\n\n for i:=2 to n do\n begin\n k:=b[i]+b[i-1];\n if ((k div 2) <> b[i]) and (((k+1) div 2)<> b[i]) then exit;\n end;\n\n dec(res);\nend;\n\nbegin\n readln(s);\n if length(s)=1 then\n begin\n writeln(9);\n halt;\n end;\n xuly;\n tinhkq;\n writeln(res);\nend."}, {"source_code": "const fi='';//44h.inp';\n fo='';//44h.out';\n maxn=55;\nvar s:string;\n f1:array[0..maxn,0..9] of int64;\n n:longint;\n f:text;\n\n\nprocedure nhap;\nbegin\n assign(f,fi); reset(f);\n readln(f,s);\n n:=length(s);\n close(F);\nend;\n\n\nprocedure work;\nvar i,j,k,t:longint;\nbegin\n for i:=0 to 9 do f1[1,i]:=1;\n for i:=2 to n do\n begin\n t:=ord(s[i])-48;\n for j:=0 to 9 do\n for k:=0 to 9 do\n if (k+t=2*j-1) or (k+t=2*j+1) or (k+t=2*j) then\n f1[i,j]:=f1[i,j]+f1[i-1,k];\n end;\nend;\n\n\nfunction tinh:longint;\nvar i,j,t,k:longint;\nbegin\n t:=ord(s[1])-48;\n for i:=2 to n do\n begin\n k:=ord(s[i])-48;\n if (t+k<>2*k-1) and (t+k<>2*k) and (t+k<>2*k+1) then\n exit(0);\n t:=k;\n end;\n exit(1);\nend;\n\n\nprocedure inkq;\nvar i:longint; res:int64;\nbegin\n assign(f,fo); rewrite(f);\n res:=0;\n for i:=0 to 9 do\n res:=res+f1[n,i];\n res:=res-tinh;\n writeln(f,res);\n close(f);\nend;\n\n\nbegin\n nhap;\n work;\n inkq;\nend."}, {"source_code": "const r=ord('0');\nvar d:array [1..50,0..9] of qword;\n i,j,l,ri,k,x:word;\n s:ansistring;\n f:boolean;\n su:qword;\nbegin\n read(s);\n fillchar(d,sizeof(d),0);\n for i:=0 to 9 do d[1,i]:=1;\n for i:=2 to length(s) do begin\n x:=ord(s[i])-r;\n ri:=(x+9) div 2+(x+9) mod 2;\n l:=x div 2;\n k:=0;\n su:=x div 2;\n for j:=l to ri do begin\n while (k<10) and ((su=j) or (su+(x+k) mod 2=j)) do begin\n inc(d[i,j],d[i-1,k]);\n inc(k);\n su:=(x+k) div 2\n end;\n dec(k);\n su:=(x+k) div 2\n end\n end;\n su:=0;\n for i:=0 to 9 do inc(su,d[length(s),i]);\n x:=ord(s[1])-r;\n f:=true;\n for i:=2 to length(s) do begin\n ri:=ord(s[i])-r;\n l:=(ri+x) div 2;\n if (l+1ri) then begin\n f:=false;\n break\n end;\n x:=ri\n end;\n if f then dec(su);\n writeln(su)\nend."}, {"source_code": "Var s:string;\n a:array[0..60]of longint;\n b,c:array[0..20]of int64;\n ans:int64;\n n,i,j,u,x:longint;\n p:integer;\n ok:boolean;\n Begin\n Readln(s);\n n:=length(s);\n ans:=0;\n for i:=1 to n do\n val(s[i],a[i],p);\n for i:=0 to 9 do\n begin\n fillchar(b,sizeof(b),0);\n b[i]:=1;\n for j:=2 to n do\n begin\n for u:=0 to 9 do\n begin\n if (a[j]+u)mod 2=0 then c[(a[j]+u)div 2]:=c[(a[j]+u)div 2]+b[u]\n else begin\n x:=a[j]+u;\n c[x div 2]:=c[x div 2]+b[u];\n c[x div 2+1]:=c[x div 2+1]+b[u];\n end;\n end;\n for u:=0 to 9 do\n b[u]:=c[u];\n fillchar(c,sizeof(c),0);\n end;\n for u:=0 to 9 do\n ans:=ans+b[u];\n end;\n ok:=true;\n for i:=2 to n do\n begin\n x:=a[i]+a[i-1];\n if (x div 2<>a[i])and(x div 2+x mod 2<>a[i]) then ok:=false;\n end;\n if ok then ans:=ans-1;\n Writeln(ans);\n End."}, {"source_code": "var a:array[1..1000] of longint;\n f:array[1..1000,0..9] of int64;\n fl,i,j,n,m,x,y:longint;\n ans:int64;\n ch:char;\n begin\n read(ch);\n while ch in ['0'..'9'] do\n begin\n inc(n);\n a[n]:=ord(ch)-ord('0');\n read(ch);\n end;\n for i:=0 to 9 do f[1][i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n if f[i][j]>0 then begin\n x:=(j+a[i+1]) div 2;\n y:=(j+a[i+1]+1) div 2;\n f[i+1][x]:=f[i+1][x]+f[i][j];\n if x<>y then f[i+1][y]:=f[i+1][y]+f[i][j];\n end;\n ans:=0;\n for i:=0 to 9 do ans:=ans+f[n][i];\n fl:=1;\n for i:=2 to n do if abs(a[i]-a[i-1])>1 then fl:=0;\n ans:=ans-fl;\n writeln(ans);\n end.\n\n\n\n\n"}, {"source_code": "Const\n Fi = '';//44H.inp';\n Fo = '';//44H.out';\n maxn = 50;\n\nVar\n F : Text;\n N : Longint;\n Res : Int64;\n A : Array[1..maxn] of Longint;\n L : Array[0..maxn, 0..9] of Int64;\n\nProcedure Input;\n Var i: Longint; s: String;\n Begin\n Assign(f, fi); Reset(f);\n Readln(f, s);\n N:= Length(s);\n For i:= 1 to n do\n A[i]:= ord(S[i]) - 48;\n Close(f);\n End;\n\nProcedure Process;\n Var i, j, b, ok: Longint;\n Begin\n ok:= 0;\n For i:= 0 to 9 do L[1, i]:= 1;\n For i:= 2 to n do\n For j:= 0 to 9 do\n Begin\n L[i, (j+a[i]) div 2]:= L[i-1, j] + L[i, (j+a[i]) div 2];\n If odd(j+A[i]) then\n L[i, (j+A[i]+1) div 2]:= L[i-1, j] + L[i, (j+A[i]+1) div 2];\n End;\n\n For i:= 0 to 9 do Res:= Res + L[n, i];\n\n\n For i:= 2 to n do\n If (Abs(A[i] + A[i-1]- 2*A[i])>1) then Exit;\n Res:= Res - 1;\n End;\n\nProcedure Print;\n Begin\n Assign(f, fo); Rewrite(f);\n Writeln(f, Res);\n Close(f);\n End;\n\nBEGIN\n Input;\n Process;\n Print;\nEND."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n dp:Array[0..9,0..50] of Int64;\n a,b:Array[0..50] of Int64;\n s:String;\n n,ans,f:Int64;\n i,j:Integer;\nFunction Solve(i,j:Integer):Int64;\nBegin\n If dp[i,j]<>-1 Then Begin\n Solve:=dp[i,j];\n Exit;\n End;\n If j=n Then Begin\n If (i+a[j]) mod 2=0 Then dp[i,j]:=1\n Else dp[i,j]:=2;\n Solve:=dp[i,j];\n Exit;\n End;\n If (i+a[j]) mod 2=0 Then dp[i,j]:=Solve((i+a[j]) div 2,j+1)\n Else dp[i,j]:=Solve((i+a[j]) div 2,j+1)+Solve((i+a[j]) div 2+1,j+1);\n Solve:=dp[i,j];\nEnd;\nBegin\n Read(s);\n n:=length(s);\n If n=1 Then Begin\n Write(9);\n Halt;\n End;\n For i:=1 To n Do a[i]:=strtoint(s[i]);\n For i:=0 To 9 Do\n For j:=1 To 50 Do dp[i,j]:=-1;\n ans:=0;\n For i:=0 To 9 Do ans:=ans+Solve(i,2);\n b[1]:=a[1];\n f:=1;\n For i:=2 To n Do Begin\n If (a[i]+b[i-1]) mod 2=0 Then Begin\n b[i]:=(a[i]+b[i-1]) div 2;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End\n Else Begin\n If (a[i]+b[i-1]) div 2=a[i] Then b[i]:=(a[i]+b[i-1]) div 2\n Else b[i]:=(a[i]+b[i-1]) div 2+1;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End;\n End;\n If f=1 Then ans:=ans-1;\n Write(ans);\nEnd.\n"}, {"source_code": "var i,j,l,n,t:longint;\n ans:int64;\n q:boolean;\n a,b,c:array[0..51] of int64;\n s:string;\n p:integer;\n begin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n val(s[i],a[i],p);\n for i:=0 to 9 do\n b[i]:=1;\n for i:=2 to n do\n begin\n fillchar(c,sizeof(c),0);\n for j:=0 to 9 do\n begin\n for l:=0 to 9 do\n begin\n if (l+a[i]) div 2=j then c[j]:=c[j]+b[l];\n if (l+a[i]) mod 2=1 then if (a[i]+l) div 2+1=j then c[j]:=c[j]+b[l];\n end;\n end;\n b:=c;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+b[i];\n q:=true;\n for i:=2 to n do\n begin\n t:=a[i]+a[i-1];\n if t mod 2=0 then begin\n if (t div 2)<>a[i] then q:=false;\n end\n else begin\n if ((t div 2)<>a[i]) and ((t div 2+1)<>a[i]) then q:=false;\n end;\n end;\n if q then ans:=ans-1;\n writeln(ans);\n end."}, {"source_code": "program h2;\nconst\n nfin= '';\n nfout= '';\n\nvar\n f: array[0..60, 0..9] of int64;\n cs: array[0..60] of longint;\n s: string;\n res: int64;\n n: longint;\n fin, fout: text;\n\nprocedure init;\nvar i, j: longint;\nbegin\n n:=length(s);\n for i:=1 to n do cs[i]:=ord(s[i]) - ord ('0');\nend;\n\nfunction call(i, pr: longint): longint;\nbegin\n if f[i, pr]<>-1 then begin\n call:=f[i, pr];\n exit;\n end;\n\n if i=n+1 then begin\n f[i, pr]:=1;\n call:=1;\n exit;\n end;\n\n f[i, pr]:=call(i+1, (pr+cs[i]) div 2);\n if ((pr+cs[i]) mod 2 = 1) then\n f[i, pr]:=f[i, pr] + call(i+1, (pr+cs[i]+1) div 2);\n call:=f[i, pr];\nend;\n\nprocedure solve;\nvar i, j, k: longint;\nbegin\n if n = 1 then begin\n res:=9;\n exit;\n end;\n\n res:=0;\n for k:=0 to 9 do begin\n for i:=0 to 60 do\n for j:=0 to 9 do f[i, j]:=-1;\n res:=res + call(2, k);\n end;\n\n k:=1;\n for i:=2 to n do\n if (cs[i] = (cs[i] + cs[i-1]) div 2)\n or (((cs[i] + cs[i-1]) mod 2 = 1) and (((cs[i]+cs[i-1]+1) div 2)=cs[i])) then k:=k+1;\n if k=n then res:=res-1;\nend;\n\nbegin\n assign(fin, nfin); reset(fin);\n assign(fout, nfout); rewrite(fout);\n readln(fin, s);\n init;\n solve;\n writeln(res);\n close(fout);\n close(fin);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a:array[1..50,0..9] of int64;\n s:array[1..50] of longint;\n i, j, n, x: longint;\n ans: int64;\n c: char;\n canphone: boolean;\nbegin\n read(c);\n i := 1;\n while (c in ['0'..'9']) do begin\n s[i] := ord(c) - ord('0');\n inc(i);\n read(c);\n end;\n n := i - 1;\n for i := 1 to n do begin\n for j := 0 to 9 do begin\n a[i, j] := 0;\n end;\n end;\n for i := 0 to 9 do begin\n a[1][i] := 1;\n end;\n for i := 2 to n do begin\n for j := 0 to 9 do begin\n x := s[i] + j;\n if (x mod 2 = 1) then begin\n a[i,(x + 1) div 2] := a[i,(x + 1) div 2] + a[i - 1,j];\n end;\n a[i,x div 2] := a[i,x div 2] + a[i - 1,j];\n end;\n end;\n ans := 0;\n for i := 0 to 9 do begin\n ans := ans + a[n, i];\n end;\n canphone := true;\n for i := 1 to n - 1 do begin\n canphone := canphone and (abs(s[i] - s[i + 1]) <= 1);\n end;\n if canphone then ans := ans - 1;\n writeln(ans);\n\nend.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n kq:int64;\n g:array [0..50,0..9] of int64;\n s:string;\n n:longint;\n a:array [1..50] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n close(f);\n for i:=1 to n do a[i]:=ord(s[i])-48;\nend;\nprocedure xuly;\nvar\n i,u,j:longint;\nbegin\n for i:=0 to 9 do g[1,i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n begin\n u:=j+a[i+1];\n g[i+1,u div 2]:=g[i+1,u div 2]+g[i,j];\n if u mod 2=1 then g[i+1,(u+1) div 2]:=g[i+1,(u+1) div 2]+g[i,j];\n end;\n j:=0;\n for i:=1 to n-1 do\n begin\n u:=a[i]+a[i+1];\n if ((u+1) div 2<>a[i+1]) and (u div 2<>a[i+1]) then j:=-1;\n end;\n if j=0 then kq:=-1;\n for i:=0 to 9 do kq:=kq+g[n,i];\n writeln(kq);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "program HH;\n\n{$APPTYPE CONSOLE}\n\n\nvar\nfin:boolean;\ni,j,n,l,c:longint;\nsum,y:int64;\ns:string;\na:array[1..105] of longint;\nb:array[1..105,0..9] of int64;\n\n\n\n\n\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(s);\n sum:=0;\n n:=length(s);\n sum:=0;\n if n=1 then writeln('9') else begin\n\n for i:=1 to n do begin\n val(s[i],a[i],c);\n end;\n\n for i:=0 to 9 do begin\n b[1,i]:=1;\n end;\n\n for i:=2 to n do begin\n\n for j:=0 to 9 do begin\n if {(b[i-1,j]>0) and} ((j+a[i]) mod 2=0) then begin\n b[i,(j+a[i]) div 2]:=b[i,(j+a[i]) div 2]+b[i-1,j];\n end;\n if {(b[i-1,j]>0) and }((j+a[i]) mod 2=1) then begin\n b[i,(j+a[i]) div 2]:=b[i,(j+a[i]) div 2]+b[i-1,j];\n b[i,((j+a[i]) div 2)+1]:=b[i,((j+a[i]) div 2)+1]+b[i-1,j];\n end;\n end;\n \n end;\n\n for i:=0 to 9 do begin\n sum:=sum+b[n,i];\n end;\n\n\n\n\n fin:=false;\n for i:=2 to n do begin\n y:=(a[i-1]+a[i])div 2;\n if ((a[i-1]+a[i])mod 2)=0 then begin\n if y<>a[i] then fin:=true;\n end else begin\n if (a[i]y+1) then fin:=true;\n end;\n end;\n if (fin=false) then sum:=sum-1;\n\n\n writeln(sum);\n\n\n\n\n\n\n\n\n\n\n end;\n\nend.\n "}, {"source_code": "const\n fi='';\nvar\n f:text;\n s:string;\n n:longint;\n g:array [1..50,0..9] of int64;\n kq:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n close(f);\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\n kt:boolean;\nbegin\n for i:=0 to 9 do g[1,i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n begin\n u:=(j+ord(s[i+1])-48);\n g[i+1,u div 2]:=g[i+1,u div 2]+g[i,j];\n if u mod 2=1 then g[i+1,(u+1) div 2]:=g[i+1,(u+1) div 2]+g[i,j];\n end;\n for i:=0 to 9 do kq:=kq+g[n,i];\n kt:=true; u:=ord(s[1])-48;\n for i:=2 to n do\n begin\n v:=ord(s[i])-48;\n u:=(u+v) div 2;\n if (u<>v) and (u<>v-1) then\n begin\n kt:=false;\n break;\n end;\n end;\n if kt then dec(kq);\n writeln(kq);\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "var\n s:string;\n a,b:array[1..111]of longint;\n ff,jj,n,i,j:longint;\n f:array[1..111,-10..19]of extended;\n ans:extended;\nbegin\n//assign(input,fi);reset(input);\n//assign(output,fo);rewrite(output);\n readln(s);\n n:=length(s);\n ans:=0;\n for i:=1 to n do a[i]:=ord(s[i])-48;\n for i:=0 to 9 do f[1,i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n begin\n jj:=(a[i+1]+j)div 2;\n f[i+1,jj]:=f[i+1,jj]+f[i,j];\n if (a[i+1]+j)mod 2=1 then\n f[i+1,jj+1]:=f[i+1,jj+1]+f[i,j];\n end;\n b[1]:=a[1];\n ff:=1;\n for i:=2 to n do\n begin\n if (a[i]+b[i-1])div 2=a[i] then\n b[i]:=a[i]\n else\n if ((a[i]+b[i-1])mod 2=1)and(((a[i]+b[i-1])div 2)+1=a[i])\n then b[i]:=a[i]\n else\n begin\n ff:=0;\n break;\n end;\n end;\n ans:=ans-ff;\n for i:=0 to 9 do ans:=ans+f[n,i];\n writeln(ans:0:0);\nend."}, {"source_code": "var i,j,l,n,t:longint;\n ans:int64;\n q:boolean;\n a,b,c:array[0..51] of int64;\n s:string;\n p:integer;\n begin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n val(s[i],a[i],p);\n for i:=0 to 9 do\n b[i]:=1;\n for i:=2 to n do\n begin\n fillchar(c,sizeof(c),0);\n for j:=0 to 9 do\n begin\n for l:=0 to 9 do\n begin\n if (l+a[i]) div 2=j then c[j]:=c[j]+b[l];\n if (l+a[i]) mod 2=1 then if (a[i]+l) div 2+1=j then c[j]:=c[j]+b[l];\n end;\n end;\n b:=c;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+b[i];\n q:=true;\n for i:=2 to n do\n begin\n t:=a[i]+a[i-1];\n if t mod 2=0 then begin\n if (t div 2)<>a[i] then q:=false;\n end\n else begin\n if ((t div 2)<>a[i]) and ((t div 2+1)<>a[i]) then q:=false;\n end;\n end;\n if q then ans:=ans-1;\n writeln(ans);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{M 67108864}\n\nuses SysUtils, Math;\n \nvar \n s:string;\n ls,kk,i,j,pp:longint;\n a:array[0..1010,0..10] of int64;\n ans:int64;\n f:boolean;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nfillchar(a,sizeof(a),0);\nreadln(s);\nls:=length(s);\nkk:=ls-1;\nans:=0;\nfor i:=0 to 9 do\n a[1][i]:=1;\nfor i:=1 to kk do begin\n for j:=0 to 9 do begin\n pp:=j+ord(s[i+1])-48;\n inc(a[i+1][pp div 2],a[i][j]);\n if pp and 1=1 then inc(a[i+1][(pp+1) div 2],a[i][j]);\n end;\nend;\nfor i:=0 to 9 do\n inc(ans,a[ls][i]);\nf:=true;\nfor i:=2 to ls do\n if abs(ord(s[i])-ord(s[i-1]))>1 then begin\n f:=false;\n break;\n end;\nif f then dec(ans);\nwrite(ans);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "program Z_H;\n\n{$APPTYPE CONSOLE} {$O- R+ Q+}\n\nuses\n SysUtils;\n\nvar s:string;\n n,i,j,k:longint;\n ans:int64;\n a:array[1..50] of longint;\n flag:boolean;\n f:array[1..50,0..9] of int64;\n b:array[1..50,0..9] of boolean;\nfunction proc(const ind,v:longint; flag:boolean):int64;\nvar k,l:longint;\n f:boolean;\nbegin\n if (ind=n+1)\n then\n begin\n if not flag\n then\n result:=1\n else\n result:=0;\n exit;\n end;\n k:=(v+a[ind]);\n if odd(k)\n then\n l:=(k-1) shr 1\n else\n l:=(k) shr 1;\n if flag and (l=a[ind])\n then\n f:=true\n else\n f:=false;\n result:=0;\n result:=result+proc(ind+1,l,f);\n if flag and (l +1=a[ind])\n then\n f:=true\n else\n f:=false;\n if odd(k)\n then\n begin\n result:=result+proc(ind+1,l +1,f);\n end;\nend;\nbegin\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); } \n readln(s);\n n:=length(s);\n for i:=1 to n do\n begin\n a[i]:=strtoint(s[i]);\n end;\n ans:=0;\n for i:=0 to 9 do\n f[n,i]:=1;\n b[n,a[n]]:=true; \n for i:=n-1 downto 1 do\n for j:=0 to 9 do\n begin\n k:=j+a[i+1];\n if (j=a[i])and(b[i+1, k div 2])\n then\n b[i,j]:=true;\n f[i,j]:=f[i+1,k div 2];\n if odd(k)\n then\n begin\n f[i,j]:=f[i,j]+f[i+1,k div 2 +1];\n if (j=a[i])and(b[i+1, k div 2 +1])\n then\n b[i,j]:=true;\n\n end;\n end;\n for i:=0 to 9 do\n ans:=ans+f[1,i];\n for i:=0 to 9 do\n if b[1,i]\n then\n begin\n dec(ans);\n break;\n end;\n { for i:=0 to 9 do\n begin\n flag:=i=a[1];\n ans:=ans+proc(2,i,flag);\n end; }\n write(ans); \nend.\n"}, {"source_code": "var\nk:array[0..9,0..49] of int64;\nnom:array[1..50] of longint;\ni,l,j:longint;\nfs:int64;\ns:string;\nsp:boolean;\nbegin\nreadln(s);\nfor i:=0 to 9 do k[i,0]:=1;\nl:=0;\nwhile s<>'' do begin\ninc(l);\nnom[l]:=ord(s[length(s)])-ord('0');\ns:=copy(s,1,length(s)-1);\nend;\nfor i:=1 to l-1 do\nfor j:=0 to 9 do\nif ((j+nom[i]) mod 2)=0 then k[j,i]:=k[(j+nom[i]) div 2,i-1]\nelse k[j,i]:=k[(j+nom[i]) div 2,i-1]+k[((j+nom[i]) div 2)+1,i-1];\nfs:=0;\nfor i:=0 to 9 do\nfs:=fs+k[i,l-1];\nsp:=true;\nfor i:=1 to l-1 do\nif (abs(nom[i]-nom[i+1])>1) then sp:=false;\nif sp then dec(fs);\nwriteln(fs);\nend."}, {"source_code": "const\n maxn = 55;\nvar\n f:array[0..maxn, 0..maxn, 0..1] of int64;\n k,j,n,i,ne:longint;\n s:string;\n res:int64;\nbegin\n readln(s);\n for i:=0 to 9 do f[1, i, ord(chr(48+i) = s[1])]:=1;\n for i:=1 to length(s)-1 do for j:=0 to 9 do for k:=0 to 1 do if f[i, j, k]>0 then\n begin\n ne:=j+ord(s[i+1])-48;\n if ne and 1 = 0 then inc(f[i+1, ne shr 1, k and (ord(chr(ne shr 1+48) = s[i+1]))], f[i, j, k]) else\n begin\n inc(f[i+1, ne shr 1, k and (ord(chr(ne shr 1+48) = s[i+1]))], f[i, j, k]);\n if ne shr 1<9 then inc(f[i+1, ne shr 1+1, k and (ord(chr(ne shr 1+49) = s[i+1]))], f[i, j, k]);\n end;\n end;\n for i:=0 to 9 do inc(res, f[length(s), i, 0]);\n writeln(res);\nend."}, {"source_code": "var\n s:string;\n a:array[1..50,0..9] of int64;\n n,i,j,k,t:longint;\n kq:int64;\n check:boolean;\nbegin\n readln(s);\n kq:=0;\n for i:=0 to 9 do a[1,i]:=1;\n check:=true;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n for j:=0 to 9 do\n begin\n if (j+k) mod 2 = 0 then a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j]\n else\n begin\n a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j];\n a[i,(j+k) div 2+1]:=a[i,(j+k) div 2+1]+a[i-1,j];\n end;\n end;\n end;\n for i:=0 to 9 do kq:=kq+a[length(s),i];\n t:=ord(s[1])-48;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n if (t+k) mod 2 = 0 then\n if ((t+k) div 2 <> k) then\n begin\n check:=false;\n break;\n end;\n if (t+k) mod 2 =1 then\n if ((t+k) div 2 <> k) and ((t+k) div 2+1<>k) then\n begin\n check:=false;\n break;\n end;\n t:=k;\n end;\n if check=true then dec(kq);\n writeln(kq);\nend.\n"}, {"source_code": "program sdt;\nconst\n fi = '';\n fo = '';\n nmax = 50;\nvar\n a: array[1..nmax] of int64;\n b: array[0..9, 1..nmax] of int64;\n n: longint;\n kq: int64;\n f1, f2: text;\n\n procedure openf;\n begin\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n end;\n\n procedure closef;\n begin\n close(f1); close(f2);\n end;\n\n procedure input;\n var\n s: string;\n i: longint;\n begin\n read(f1, s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n end;\n\n procedure output;\n begin\n write(f2, kq);\n end;\n\n procedure process;\n var\n i, j: longint;\n begin\n for i := 0 to 9 do\n b[i, n] := 1;\n for i := n - 1 downto 1 do\n for j := 0 to 9 do\n if (j + a[i + 1]) and 1 = 1 then\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1] + b[(j + a[i + 1]) div 2 + 1, i + 1]\n else\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1];\n for i := 0 to 9 do\n kq := kq + b[i, 1];\n for i := 2 to n do\n begin\n if abs(a[i] - a[i - 1]) > 1 then\n break;\n if i = n then\n kq := kq - 1;\n end;\n if n = 1 then\n kq := kq - 1;\n end;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend."}, {"source_code": "var i,j,m:Longint;\nf:array[0..51,0..9] of int64;\na:array[0..51] of LongInt;\ns:ansistring;\nq:Longint;\nres:int64;\nfind:boolean;\n\nprocedure Can(x,prev:LongInt);\nbegin\n if x=length(s)+1 then begin find:=true;exit;end;\n\n if a[x]<>prev then exit;\n can(x+1,(prev+a[x+1]) div 2);\n if (prev+a[x+1])mod 2=1 then\n can(x+1,(prev+a[x+1]) div 2+(prev+a[x+1]) mod 2);\nend;\n\nbegin\n find:=false;\n readln(s);\n for i:=1 to length(s) do\n a[i]:=ord(s[i])-ord('0');\n\n\n fillchar(f,sizeof(f),0);\n for i:=0 to 9 do\n f[1,i]:=1;\n\n\n for i:=1 to length(s) do\n begin\n for j:=0 to 9 do\n begin\n // writeln(i,' ',j,' ',f[i,j]);\n q:=(j+a[i+1])div 2;\n f[i+1,q]:=f[i+1,q]+f[i,j];\n if ((j+a[i+1])mod 2)=1 then\n f[i+1,q+1]:=f[i+1,q+1]+f[i,j];\n end;\n end;\n\n res:=0;\n for j:=0 to 9 do\n inc(res,f[length(S),j]);\n\n for i:=0 to 9 do\n begin\n Can(1,i);\n end;\n if find then dec(res);\n writeln(res);\nend."}, {"source_code": "{const\n fi='44H.INP';\n fo='44H.OUT';}\nvar\n f:text;\n s:String;\n i,j,tg,tmp:longint;\n sum,x,y:int64;\n ok:boolean;\n a:array[0..50,0..9] of int64;\nbegin\n //assign(f,fi);reset(f);\n readln(s);\n // close(f);\n //assign(f,fo);rewrite(f);\n for i:=0 to 9 do a[1,i]:=1;\n ok:=true;\n for i:=1 to length(s)-1 do\n for j:=0 to 9 do\n begin\n val(s[i+1],tmp);\n tg:=(j+tmp);\n if not odd(tg) then\n a[i+1,tg div 2]:=a[i+1,tg div 2]+a[i,j]\n else\n begin\n a[i+1,tg div 2] :=a[i+1,tg div 2] +a[i,j];\n a[i+1,tg div 2+1]:=a[i+1,tg div 2+1]+a[i,j];\n end;\n end;\n\n for j:=0 to 9 do sum:=sum+a[length(s),j];\n\n for i:=2 to length(s) do\n begin\n val(s[i],x);\n val(s[i-1],y);\n if (x<>(x+y) div 2) and (x<>(x+y+1) div 2) then ok:=false;\n end;\n if ok then dec(sum);\n write(sum);\n //close(f);\nend."}, {"source_code": "\nvar s:string;\n a:array[1..55] of integer;\n f:array[1..55,0..9] of int64;\n i,j,k:longint;\n ok:boolean;\n kq:int64;\nbegin\n readln(s);\n for i:=1 to length(s) do a[i]:=ord(s[i])-48;\n fillchar(f,sizeof(f),0);\n for i:=0 to 9 do f[1][i]:=1;\n for i:=2 to length(s) do\n for j:=0 to 9 do\n begin\n k:=a[i]+j;\n f[i][k div 2]:=f[i][k div 2] +f[i-1][j];\n if (k mod 2=1) then f[i][k div 2+1]:=f[i][k div 2+1]+f[i-1][j];\n end;\n kq:=0;\n for i:=0 to 9 do kq:=kq+f[length(s)][i];\n ok:=true;\n for i:=2 to length(s) do\n if ((a[i]<>(a[i]+a[i-1]) div 2) and (a[i]<>(a[i]+a[i-1]+1) div 2))\n then ok:=false;\n if (ok) then dec(kq);\n write(kq);\nend.\n"}, {"source_code": "Program By_TacTi_66;\nVar\n// F : Text;\n k : Byte;\n kq : Int64;\n a : array [1..50] of Byte; \n b : array [1..50,0..9] of Int64;\n \n{----------------------------------------------------------------} \n\nProcedure PrPrE;\nVar s : String[50];\n i : Byte;\nBegin\n\n Readln(s);k := length(s);\n For i := 1 to k do VaL(s[i],a[i]); \n \nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure H44;\nVar i, j : Byte;t : Integer;\nBegin\n\n For i := 0 to 9 do b[1,i] := 1;\n \n For i := 1 to k-1 do\n For j := 0 to 9 do\n Begin\n t := j + a[i+1];\n\n b[i+1,t div 2] := b[i+1,t div 2] + b[i,j];\n If t mod 2 <> 0 then\n b[i+1,t div 2 + 1] := b[i+1,t div 2 + 1] + b[i,j];\n End;\n\nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure RsFwO;\nVar i : Byte;ct : Boolean;\nBegin\n\n ct := TRUE;\n For i := 0 to 9 do kq := kq + b[k,i];\n\n If k > 1 then\n For i := 2 to k do\n If (a[i-1] = a[i]) or ( (a[i-1] + 1 = a[i]) or (a[i-1] - 1 = a[i])\n and ((a[i-1] + a[i]) mod 2 = 1) ) then ct := FALSE\n Else Begin ct := TRUE;Break;End\n Else ct := FALSE;\n If ct = FALSE then dec(kq);\n Writeln(kq);\n\nEnd; \n \n{----------------------------------------------------------------} \n \nBegin\n\n PrPrE;\n \n H44;\n \n RsFwO;\n\nEnd. \n"}, {"source_code": "var s:ansistring;\n n,i,x,j,z:longint;\n a:array[1..55] of longint;\n f:array[0..1,0..10] of int64;\n d:array[1..55,0..9,0..9] of boolean;\n re:int64;\n\nfunction check:boolean;\nvar i:longint;\nbegin\n for i:=2 to n do\n if not d[i,a[i-1],a[i]] then\n begin\n check:=false; exit;\n end;\n check:=true;\nend;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n fillchar(f,sizeof(f),0);\n for i:=0 to 9 do f[1,i]:=1;\n z:=1;\n fillchar(d,sizeof(d),false);\n for i:=2 to n do\n begin\n z:=i and 1;\n fillchar(f[z],sizeof(f[z]),0);\n for j:=0 to 9 do\n begin\n x:=j+a[i];\n inc(f[z,x div 2],f[1-z,j]);\n d[i,j,x div 2]:=true;\n if odd(x) then\n begin\n inc(f[z,x div 2+1],f[1-z,j]);\n d[i,j,x div 2+1]:=true;\n end;\n end;\n end;\n re:=0;\n for i:=0 to 9 do re:=re+f[z,i];\n if check then dec(re);\n writeln(re);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\n\nuses\n SysUtils, Math;\n\nvar\n a: array [-10..100, -10..100] of Int64;\n h: array [-10..100] of Byte;\n st: String;\n n1, digit, ans: Int64;\n i, x : integer;\n fl : boolean;\n\nfunction f(x, n : integer) : int64;\nbegin\n if a[x, n] > 0 then\n begin\n result := a[x, n];\n exit;\n end;\n\n if n = 0 then\n begin\n result := 1;\n a[x, n] := 1;\n exit;\n end;\n\n if not odd(x + h[n1 - n + 1]) then\n result :=f((x + h[n1 - n + 1])div 2, n - 1)\n else\n result :=f((x + h[n1 - n + 1])div 2, n - 1) + f((x + h[n1 - n + 1])div 2 + 1, n - 1);\n\n a[x, n] := result;\nend;\n\nbegin\n{\n Assign(Input, 'input.txt');\n Reset(Input);\n Assign(Output, 'output.txt');\n Rewrite(Output);\n}\n Readln(st);\n n1 := Length(st);\n for i := 1 to n1 do\n begin\n h[i] := strtoint(st[i]);\n end;\n\n fl := false;\n for x := 1 to n1 - 1 do\n begin\n if ((h[x] + h[x + 1]) div 2 <> h[x + 1]) and ((h[x] + h[x + 1]) div 2 + (h[x] + h[x + 1]) mod 2 <> h[x + 1]) then\n fl := true;\n end;\n\n\n ans := 0;\n if not fl then dec(ans);\n \n for x := 0 to 9 do\n begin\n inc(ans, f(x, n1 - 1));\n end;\n\n writeln(max(ans, 0)); \n\n\n\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n int = integer;\n\nvar\n a : array[0..202, 0..10] of int64;\n i, j, n: int;\n s : string;\n\nprocedure init;\nbegin\n readln(s);\n n := length(s);\n fillchar(a, sizeof(a), 0);\n for i := 0 to 9 do\n a[1, i] := 1;\nend;\n\nprocedure main;\nvar\n i, j, x : integer;\n ans : int64;\n l : boolean;\nbegin\n for i := 2 to n do begin\n for j := 0 to 9 do begin\n x := ord(s[i]) - ord('0') + j;\n if x mod 2 = 0 then begin\n a[i, x div 2] := a[i, x div 2] + a[i - 1, j];\n end\n else begin\n a[i, (x div 2) + 1] := a[i, (x div 2) + 1] + a[i - 1, j];\n a[i, x div 2] := a[i, x div 2] + a[i - 1, j];\n end;\n end;\n end;\n ans := 0;\n for i := 0 to 9 do\n ans := ans + a[n, i];\n l := true;\n for i := 2 to n do\n if abs((ord(s[i]) - ord('0')) - (ord(s[i - 1]) - ord('0'))) > 1 then begin\n l := false;\n break;\n end;\n if l then\n ans := ans - 1;\n writeln(ans);\nend;\n\nbegin\n //reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n\n init;\n main;\n\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "var\n s : string;\n i,j,n : longint;\n sum : int64;\n sr : extended;\n a : array[0..1000,0..1000] of int64;\n f : boolean;\nbegin\n readln(s);\n n := length(s);\n for j := 0 to 9 do\n a[1,j] := 1;\n for i := 2 to n do\n begin\n for j := 0 to 9 do\n begin\n sr := (j + (ord(s[i]) - 48)) / 2;\n if sr <> trunc(sr) then\n begin\n a[i,trunc(sr)] := a[i,trunc(sr)] + a[i-1,j];\n a[i,trunc(sr) + 1] := a[i,trunc(sr) + 1] + a[i-1,j];\n end else\n a[i,trunc(sr)] := a[i,trunc(sr)] + a[i-1,j];\n end;\n end;\n sum := 0;\n for j := 0 to 9 do\n sum := sum + a[n,j];\n f := true;\n for i := 2 to n do\n begin\n sr := ord(s[i]) - 48 + ord(s[i - 1]) - 48;\n sr := sr / 2;\n if sr = round(sr) then\n if (trunc(sr) <> ord(s[i]) - 48) then f := false;\n\n if sr <> round(sr) then\n if (trunc(sr) <> ord(s[i]) - 48)\n and (trunc(sr) + 1 <> ord(s[i]) - 48)\n then f := false;\n end;\n if f then dec(sum);\n write(sum);\nend."}, {"source_code": "const INPUT = '';\n OUTPUT = '';\n MAX_N = 60;\n\nvar fi,fo:text;\n n:longint;\n a:array[0..MAX_N] of longint;\n\nprocedure enter;\nvar i:longint;\n s:string;\nbegin\n readln(fi,s);\n n:=length(s);\n for i:=1 to length(s) do a[i]:=ord(s[i])-ord('0');\nend;\n\nfunction check:boolean;\nvar i,j,k:longint;\nbegin\n j:=a[1];\n for i:=2 to n do begin\n k:=(j+a[i]) div 2;\n if (k <> a[i]) and (k+1 <> a[i]) then exit(false);\n j:=a[i];\n end;\n exit(true);\nend;\n\nprocedure solve;\nvar i,j,k,r:longint;\n res:int64;\n ok:boolean;\n f:array[0..MAX_N,0..9] of int64;\nbegin\n if check = true then res:=-1\n else res:=0;\n\n for j:=0 to 9 do f[n][j]:=1;\n for i:=n-1 downto 1 do\n for j:=0 to 9 do begin\n k:=(j+a[i+1]) div 2;\n if (j+a[i+1]) mod 2 = 0 then f[i][j]:=f[i+1][k]\n else f[i][j]:=f[i+1][k]+f[i+1][k+1];\n end;\n\n for j:=0 to 9 do begin\n k:=j; ok:=true;\n for i:=2 to n do\n if (k+a[i]) mod 2 = 1 then begin\n ok:=false;\n break;\n end\n else k:=(k+a[i]) div 2;\n if ok = true then res:=res+1\n else res:=res+f[i-1][k];\n end;\n writeln(fo,res);\nend;\n\nbegin\n assign(fi,INPUT); reset(fi);\n assign(fo,OUTPUT); rewrite(fo);\n enter;\n solve;\n close(fo);\n close(fi);\nend."}, {"source_code": " CONST\n fi = '';//44H.inp';\n fo = '';//44H.out';\n mmax = 50;\n\n VAR\n ff : array [1.. mmax, 0.. 9] of int64;\n a : array [1.. mmax] of longint;\n n, res : int64;\n f, g : text;\n\n\n procedure openf;\n begin\n assign(f, fi); reset(f);\n assign(g, fo); rewrite(g);\n end;\n\n\n procedure closef;\n begin\n close(f); close(g);\n end;\n\n\n procedure readf;\n var\n k: char;\n begin\n while not eoln(f) do\n begin\n read(f, k);\n inc(n);\n a[n]:= ord(k)- ord('0');\n end;\n end;\n\n\n procedure process;\n var\n i, j, k: longint;\n ko : boolean;\n begin\n for i:= 0 to 9 do\n ff[1, i]:= 1;\n\n for i:= 2 to n do\n for j:= 0 to 9 do\n begin\n k:= j* 2- a[i];\n if (k >= 0) and(k< 10) then\n ff[i, j]:= ff[i- 1, k];\n k:= j* 2- a[i]- 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n k:= j* 2- a[i]+ 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n end;\n\n for i:= 0 to 9 do\n res:= res+ ff[n, i];\n ko:= true;\n for i:= 2 to n do\n begin\n j:= a[i- 1]+ a[i];\n if (j div 2<> a[i]) and((j- 1) div 2<> a[i]) and((j+ 1) div 2<> a[i]) then\n begin\n ko:= false;\n break;\n end;\n end;\n\n if ko then\n dec(res);\n\n write(res);\n end;\n\n\n BEGIN\n openf;\n readf;\n process;\n closef;\n END."}, {"source_code": "{$APPTYPE CONSOLE} \n{$R-,Q-} \nvar \n s1: string; \n i,j,n,qq,q : longint; \n f,f2 : array [0..9] of int64; \n ans,ans1 : int64; \n a,b : array [0..100000] of int64; \nprocedure rec(s : string); \nvar \n i : longint; \nbegin \n i:=length(s); \n if s=s1 then \n exit; \n if i=length(s1) then \n begin \n inc(n); \n exit; \n end; \n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then \n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49)); \n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48)); \nend; \nbegin \n {for q:=0 to 9 do \n for qq:=0 to 9 do \n begin \n if (qq>0) or (q>0) then \n begin \n close(input); \n close(output); \n end; \n rewrite(output,'input.txt'); \n write(q,qq); \n close(output); } \n {reset(input,'input.txt'); \n rewrite(output,'output.txt');} \n readln(s1); \n if (length(s1)=1)then \n begin \n write(9); \n halt; \n end; \n {n:=0; \n for I:=0 to 9 do \n rec(chr(i+48)); \n ans1:=n; \n writeln(n); } \n n:=length(s1); \n for i:=1 to n do \n a[i]:=ord(s1[i])-ord('0'); \n for i:=0 to 9 do \n f[i]:=1; \n for I:=2 to n do \n begin \n f2:=f; \n for j:=0 to 9 do \n f[j]:=0; \n for j:=0 to 9 do \n begin \n if (j+a[i]) mod 2 = 1 then \n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j]; \n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j]; \n end; \n end; \n ans:=0; \n for i:=0 to 9 do \n ans:=ans+f[i]; \n b[1]:=a[1]; \n i:=2; \n for i:=2 to n do \n begin \n if (((b[i-1]+a[i]) div 2)<>a[i]) and (((b[i-1]+a[i]+1) div 2)<>a[i]) then \n break; \n b[i]:=a[i]; \n end; \n if i>n then \n dec(ans); \n writeln(ans); \n{ if ans1<>ans then \n break; \n end; } \nend."}, {"source_code": "program aa;\n var j,b,i,n,c,m,k,d:longint;e,r,s:string;t,x,y:array[-1..55] of int64;\n q,w:char;f:boolean;z:array[0..9,0..9,1..2] of integer;a:int64;\n label 1;\nbegin\n{ assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n r:='123456789';\n read(s);\n n:=length(s);\n for i:=0 to 9 do\n for j:=0 to 9 do\n begin\n z[i,j,1]:=(i+j)div 2;\n if odd(i+j) then z[i,j,2]:=z[i,j,1]+1 else z[i,j,2]:=-1\n\n end;\n for i:=1 to n do t[i]:=pos(s[i],r);\n k:=1;\n for i:=1 to n-1 do if abs(t[i]-t[i+1])>1 then k:=0;\n for i:=0 to 9 do x[i]:=1;\n for i:=2 to n do\n begin\n for j:=-1 to 9 do y[j]:=0;\n for j:=0 to 9 do\n begin\n y[z[j,t[i],1]]:=y[z[j,t[i],1]]+x[j];\n y[z[j,t[i],2]]:=y[z[j,t[i],2]]+x[j];\n end;\n x:=y;\n end;\n a:=0;\n for i:=0 to 9 do\n a:=a+x[i];\n write(a-K);\n\n {\n close(input);close(output); }\nend."}, {"source_code": "program Project4;\n\n{$APPTYPE CONSOLE}\n{$R+,S+,Q+}\n\nuses\n SysUtils;\n\nvar\n can: array[1..501, 0..90] of int64;\n len, i: integer;\n sum: int64;\n s: string;\n f: boolean;\n\nbegin\n fillchar(can, sizeof(can), 0);\n\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt'); }\n\n readln(s);\n for i := 0 to 9 do\n can[1, i] := 1;\n\n for len := 1 to length(s) - 1 do\n for i := 0 to 9 do begin\n if (i + strtoint(s[len + 1])) mod 2 = 0 then\n can[len + 1, (i + strtoint(s[len + 1])) div 2] := can[len + 1, (i + strtoint(s[len + 1])) div 2] + can[len, i]\n else begin\n can[len + 1, (i + strtoint(s[len + 1])) div 2] := can[len + 1, (i + strtoint(s[len + 1])) div 2] + can[len, i];\n can[len + 1, (i + strtoint(s[len + 1])) div 2 + 1] := can[len + 1, (i + strtoint(s[len + 1])) div 2 + 1] + can[len, i];\n end;\n end;\n\n sum := 0;\n for i := 0 to 9 do\n sum := sum + can[length(s), i];\n\n f := true;\n for i := 1 to length(s) - 1 do begin\n if abs((strtoint(s[i]) + strtoint(s[i + 1])) / 2 - strtoint(s[i + 1])) >= 1 then begin\n f := false;\n break;\n end;\n end;\n\n if f then\n dec(sum);\n\n writeln(sum);\nend.\n"}, {"source_code": "{ fp }\nUses sysutils;\nVAr\n s:string;\n last,i,j,n:Longint;\n ans : int64;\n a : array[0..52] of longint;\n b : array[0..51,0..9] of int64;\n p : integer;\n ok : Boolean;\n\n function go(last,x:Longint):int64;\n VAr\n ans:int64;\n Begin\n If x=n+1 then\n Begin\n go := 1;\n exit;\n End;\n If b[x,last]=-1 then\n Begin\n ans := go((last+a[x]) div 2,x+1);\n If (last+a[x]) mod 2=1 then\n ans := ans+go((last+a[x]) div 2+1,x+1);\n b[x,last] := ans;\n End;\n go := b[x,last];\n End;\n\n Begin\n readLn(s);\n n := length(s);\n For i :=1 to n do\n val(s[i],a[i],p);\n For i := 1 to n do\n For j := 0 to 9 do\n b[i,j] := -1;\n For i := 0 to 9 do\n Begin\n ans :=ans+go(i,2);\n End;\n last := a[1];\n ok := true;\n For i := 2 to n do\n Begin\n last := last+a[i];\n If (last div 2=a[i]) or ((last+1) div 2=a[i]) then last := a[i]\n else\n Begin\n ok := false;\n break;\n End;\n End;\n If ok then ans := ans-1;\n WriteLn(ans);\n End."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst nn=50{1024};eps=0; label 1;\ntype mas=array[0..nn] of longint;\nvar tt,t,t1,imax,n,p,k,l,m,n1,k1,ot,name2,i1:int64;\n b,a1,b1,dl,dr,hl,hr:mas; flag:boolean; pl:longint;\n i,j,step:longint;\n name:array [0..nn,0..nn] of string ;\n spname :array[0..nn] of string;\n ch:char;\n sc,time:array[0..nn] of longint;\n variant:array[0..nn,0..nn] of int64;\n a:array[0..nn] of int64;\n ss:string;\n fl:array[0..nn] of boolean;\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output1234.txt');rewrite(output);\n}readln (ss); n:=length(ss);\nfor i:=1 to n do a[i]:=ord(ss[i])-48;\n{for i:=1 to n do write(a[i],' '); writeln;writeln;\n}for i:=0 to 9 do variant[1,i]:=1; variant[1,9]:=1;\nfor step:=1 to n-1 do for i:=0 to 9 do\n begin i1:=i;\n t:=i+a[step+1]; t1:=t div 2;\n if not odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n end;\n if odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n variant[step+1,t1+1]:=variant[step+1,t1+1]+variant[step,i];\n end;\n end;\n for step:=1 to n do\n {begin for i:=0 to 9 do write(variant[step,i],' ');writeln; end;\n }\not:=0; for i:=0 to 9 do ot:=ot+variant[n,i];\nflag:=true;\ntt:=a[1];\nfor i:=2 to n do\n begin\n if (not odd(a[i]+a[i-1])) and ((a[i]+a[i-1])div 2 <>a[i]) then flag:=false;\n if (odd(a[i]+a[i-1])) and ((a[i]+a[i-1])div 2 <>a[i])and ((a[i]+a[i-1])div 2+1 <>a[i]) then flag:=false;\n end;\n\n\nif flag then dec(ot);\nwriteln(ot);\n\n\n 1: close (output);\nend.\n"}, {"source_code": "type TYP=array[0..51] of int64;\nvar s:String;\n a,b:TYP;\n i,j,n,zifr:longint;\n t:extended;\n rez:int64;\n lik,lik1,lik2:longint;\n pp:boolean;\nfunction FUNCT(a:TYP):int64;\nvar i,j,t,k1,k2:longint;\n res:int64;\n k:extended;\n mas:array[0..10,0..51] of int64;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[zifr,1]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)<0.0000001 then begin\n t:=trunc(k);\n mas[t,i]:=mas[j,i-1]+mas[t,i];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[k1,i]:=mas[j,i-1]+mas[k1,i];\n mas[k2,i]:=mas[j,i-1]+mas[k2,i];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[i,n];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0');\nn:=length(s);\nfor zifr:=0 to 9 do begin\nrez:=rez+FUNCT(a);\n//writeln(FUNCT(a));\nend;\nFillchar(b,sizeof(b),0);\nb[1]:=a[1]; lik:=0;\npp:=true;\nfor i:= 2 to n do\nbegin\n t:=(b[i-1]+a[i])/2;\n if frac(t)<0.000001 then begin\n lik:=trunc(t);\n if lik<>a[i] then pp:=false;\n b[i]:=a[i];\n end else\n begin\n t:=t-frac(t);\n lik1:=trunc(t);\n lik2:=lik1+1;\n if (lik1<>a[i]) and (lik2<>a[i]) then pp:=false;\n b[i]:=a[i];\n end;\nend;\nif pp then rez:=rez-1;\nwriteln(rez);\nend.\n"}, {"source_code": "program JJ_Mybabe;\n {$APPTYPE CONSOLE} {$o-} {$R+}\nuses SysUtils,Math;\nvar\n i,j,p,m:integer;\n k:int64;\n s:string;\n b:array[1..50] of integer;\n a:array[1..50,0..9] of int64;\nbegin\n //reset(input,'input.txt');\n// rewrite(output,'output.txt');\n read(s);\n for i:=1 to length(s) do\n b[i]:=strtoint(s[i]);\n for i:=0 to 9 do a[1][i]:=1;\n for i:=2 to length(S) do\n for j:=0 to 9 do\n begin\n k:=(j+b[i]);\n a[i][k div 2]:=a[i][k div 2]+a[i-1][j];\n if (j+b[i]) mod 2<>0 then\n a[i][k div 2+1]:=a[i][k div 2+1]+a[i-1][j];\n end;\n k:=0;\n for i:=0 to 9 do\n k:=k+a[length(s)][i];\n for i:=2 to length(s) do\n begin\n p:=(b[i]+b[i-1]);\n if p mod 2 =0 then\n if p div 2<>b[i] then m:=1;\n if p mod 2<>0 then\n if (p div 2<>b[i]) and (p div 2+1<>b[i]) then m:=1;\n end;\n if m=0 then dec(k);\n write(k);\nend.\n\n\n\n"}, {"source_code": "type TYP=array[0..51] of int64;\nvar s:String;\n a,b:TYP;\n i,j,n,zifr:longint;\n t:extended;\n rez:int64;\n lik,lik1,lik2:longint;\n pp:boolean;\nfunction FUNCT(a:TYP):int64;\nvar i,j,t,k1,k2:longint;\n res:int64;\n k:extended;\n mas:array[0..10,0..51] of int64;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[zifr,1]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)<0.0000001 then begin\n t:=trunc(k);\n mas[t,i]:=mas[j,i-1]+mas[t,i];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[k1,i]:=mas[j,i-1]+mas[k1,i];\n mas[k2,i]:=mas[j,i-1]+mas[k2,i];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[i,n];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0');\nn:=length(s);\nfor zifr:=0 to 9 do begin\nrez:=rez+FUNCT(a);\n//writeln(FUNCT(a));\nend;\nFillchar(b,sizeof(b),0);\nb[1]:=a[1]; lik:=0;\npp:=true;\nfor i:= 2 to n do\nbegin\n t:=(b[i-1]+a[i])/2;\n if frac(t)<0.000001 then begin\n lik:=trunc(t);\n if lik<>a[i] then pp:=false;\n b[i]:=a[i];\n end else\n begin\n t:=t-frac(t);\n lik1:=trunc(t);\n lik2:=lik1+1;\n if (lik1<>a[i]) and (lik2<>a[i]) then pp:=false;\n b[i]:=a[i];\n end;\nend;\nif pp then rez:=rez-1;\nwriteln(rez);\nend."}, {"source_code": "var\n n, i, j, i1, j1: longint;\n sum: int64;\n s: string;\n a: array[1..100] of int64;\n b: array[1..100, 0..9] of int64;\n q: boolean;\n\n\nbegin\n readln(s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('1') + 1;\n\n sum := 0;\n for i := 0 to 9 do\n begin\n\n b[1, i] := 1;\n for j := 2 to n do\n for i1 := 0 to 9 do\n begin\n if (i1 + a[j]) mod 2 = 0 then\n b[j, (i1 + a[j]) div 2] := b[j, (i1 + a[j]) div 2] + b[j - 1, i1];\n if (i1 + a[j]) mod 2 = 1 then\n begin\n b[j, (i1 + a[j]) div 2] := b[j, (i1 + a[j]) div 2] + b[j - 1, i1];\n b[j, (i1 + a[j]) div 2 + 1] := b[j, (i1 + a[j]) div 2 + 1] + b[j - 1, i1];\n end;\n end;\n\n for i1 := 0 to 9 do\n sum := sum + b[n, i1];\n for i1 := 1 to n do\n for j1 := 0 to 9 do\n b[i1, j1] :=0; \n end;\n\n q := true;\n for i := 1 to n - 1 do\n if not (((a[i] - a[i + 1]) <= 1) and (a[i] - a[i + 1] >= -1)) then q := false;\n if q then dec(sum);\n writeln(sum);\nend.\n"}], "negative_code": [{"source_code": "Program By_TacTi_66;\nVar\n// F : Text;\n k : Byte;\n kq : Longint;\n a : array [1..50] of Byte; \n b : array [1..50,0..9] of Integer;\n \n{----------------------------------------------------------------} \n\nProcedure PrPrE;\nVar s : String[50];\n i : Byte;\nBegin\n\n Readln(s);k := length(s);\n For i := 1 to k do VaL(s[i],a[i]); \n \nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure H44;\nVar i, j : Byte;t : Integer;\nBegin\n\n For i := 0 to 9 do b[1,i] := 1;\n \n For i := 1 to k-1 do\n For j := 0 to 9 do\n Begin\n t := j + a[i+1];\n\n b[i+1,t div 2] := b[i+1,t div 2] + b[i,j];\n If t mod 2 <> 0 then\n b[i+1,t div 2 + 1] := b[i+1,t div 2 + 1] + b[i,j];\n End;\n\nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure RsFwO;\nVar i : Byte;ct : Boolean;\nBegin\n\n ct := TRUE;\n For i := 0 to 9 do kq := kq + b[k,i];\n\n For i := 2 to k do\n If (a[i-1] = a[i]) or ( (a[i-1] + 1 = a[i]) or (a[i-1] - 1 = a[i])\n and ((a[i-1] + a[i]) mod 2 = 1) ) then ct := FALSE\n Else ct := TRUE;\n If ct = FALSE then dec(kq);\n Writeln(kq);\n\nEnd; \n \n{----------------------------------------------------------------} \n \nBegin\n\n PrPrE;\n \n H44;\n \n RsFwO;\n\nEnd. \n"}, {"source_code": "{const\n fi='44H.INP';\n fo='44H.OUT';}\nvar\n f:text;\n s:String;\n i,j,tg,tmp:longint;\n sum,x,y:longint;\n ok:boolean;\n a:array[0..50,0..9] of longint;\nbegin\n //assign(f,fi);reset(f);\n readln(s);\n // close(f);\n //assign(f,fo);rewrite(f);\n for i:=0 to 9 do a[1,i]:=1;\n ok:=true;\n for i:=1 to length(s)-1 do\n for j:=0 to 9 do\n begin\n val(s[i+1],tmp);\n tg:=(j+tmp);\n if not odd(tg) then\n a[i+1,tg div 2]:=a[i+1,tg div 2]+a[i,j]\n else\n begin\n a[i+1,tg div 2] :=a[i+1,tg div 2] +a[i,j];\n a[i+1,tg div 2+1]:=a[i+1,tg div 2+1]+a[i,j];\n end;\n end;\n\n for j:=0 to 9 do sum:=sum+a[length(s),j];\n\n for i:=2 to length(s) do\n begin\n val(s[i],x);\n val(s[i-1],y);\n if (x<>(x+y) div 2) and (x<>(x+y+1) div 2) then ok:=false;\n end;\n if ok then dec(sum);\n write(sum);\n //close(f);\nend."}, {"source_code": "\nvar\n s:String;\n i,j,chan,le,tg,tmp:longint;\n ca,l,sum:longint;\n a:array[-1..9,-1..50] of longint;\nbegin\n\n readln(s);\n for i:=0 to 9 do\n begin\n if odd(i) then le:=1 else chan:=1;\n for j:=2 to length(s) do\n begin\n a[i,j]:=a[i-1,j];\n val(s[j],tg);\n if odd(tg) then\n begin\n ca:=le;\n l:=chan*2;\n end else\n begin\n ca:=chan;\n l:=le*2;\n end;\n a[i,j]:=a[i,j]+ca+l;\n chan:=ca;\n le:=l\n end;\n end;\n writeln(a[9,length(s)]);\nend."}, {"source_code": "Program By_TacTi_66;\nVar\n// F : Text;\n k : Byte;\n kq : Int64;\n a : array [1..50] of Byte; \n b : array [1..50,0..9] of Int64;\n \n{----------------------------------------------------------------} \n\nProcedure PrPrE;\nVar s : String[50];\n i : Byte;\nBegin\n\n Readln(s);k := length(s);\n For i := 1 to k do VaL(s[i],a[i]); \n \nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure H44;\nVar i, j : Byte;t : Integer;\nBegin\n\n For i := 0 to 9 do b[1,i] := 1;\n \n For i := 1 to k-1 do\n For j := 0 to 9 do\n Begin\n t := j + a[i+1];\n\n b[i+1,t div 2] := b[i+1,t div 2] + b[i,j];\n If t mod 2 <> 0 then\n b[i+1,t div 2 + 1] := b[i+1,t div 2 + 1] + b[i,j];\n End;\n\nEnd;\n \n////////////////////////////////////////////////////////////////// \n \nProcedure RsFwO;\nVar i : Byte;ct : Boolean;\nBegin\n\n ct := TRUE;\n For i := 0 to 9 do kq := kq + b[k,i];\n\n If k > 1 then\n For i := 2 to k do\n If (a[i-1] = a[i]) or ( (a[i-1] + 1 = a[i]) or (a[i-1] - 1 = a[i])\n and ((a[i-1] + a[i]) mod 2 = 1) ) then ct := FALSE\n Else ct := TRUE\n Else ct := FALSE;\n If ct = FALSE then dec(kq);\n Writeln(kq);\n\nEnd; \n \n{----------------------------------------------------------------} \n \nBegin\n\n PrPrE;\n \n H44;\n \n RsFwO;\n\nEnd. \n"}, {"source_code": "var s:ansistring;\n n,i,x,j,z:longint;\n a:array[1..55] of longint;\n f:array[0..1,0..10] of int64;\n d:array[1..55,0..9,0..9] of boolean;\n re:int64;\n\nfunction check:boolean;\nvar i:longint;\nbegin\n for i:=2 to n do\n if not d[i,a[i-1],a[i]] then\n begin\n check:=false; exit;\n end;\n check:=true;\nend;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n fillchar(f,sizeof(f),0);\n for i:=0 to 9 do f[1,i]:=1;\n fillchar(d,sizeof(d),false);\n for i:=2 to n do\n begin\n z:=i and 1;\n fillchar(f[z],sizeof(f[z]),0);\n for j:=0 to 9 do\n begin\n x:=j+a[i];\n inc(f[z,x div 2],f[1-z,j]);\n d[i,j,x div 2]:=true;\n if odd(x) then\n begin\n inc(f[z,x div 2+1],f[1-z,j]);\n d[i,j,x div 2+1]:=true;\n end;\n end;\n end;\n re:=0;\n for i:=0 to 9 do re:=re+f[z,i];\n if check then dec(re);\n writeln(re);\nend.\n"}, {"source_code": "var s:string;\n n,i,x,j:longint;\n a:array[1..55] of longint;\n f:array[1..55,0..10] of longint;\n d:array[1..55,0..9,0..9] of boolean;\n re:longint;\n\nfunction check:boolean;\nvar i:longint;\nbegin\n for i:=2 to n do\n if not d[i,a[i-1],a[i]] then\n begin\n check:=false; exit;\n end;\n check:=true;\nend;\n\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do a[i]:=ord(s[i])-48;\n fillchar(f,sizeof(f),0);\n for i:=0 to 9 do f[1,i]:=1;\n fillchar(d,sizeof(d),false);\n for i:=2 to n do\n for j:=0 to 9 do\n begin\n x:=j+a[i];\n inc(f[i,x div 2],f[i-1,j]);\n d[i,j,x div 2]:=true;\n if odd(x) then\n begin\n inc(f[i,x div 2+1],f[i-1,j]);\n d[i,j,x div 2+1]:=true;\n end;\n end;\n re:=0;\n for i:=0 to 9 do re:=re+f[n,i];\n if check then dec(re);\n writeln(re);\nend."}, {"source_code": " CONST\n fi = '';//44H.inp';\n fo = '';//44H.out';\n mmax = 50;\n\n VAR\n ff : array [1.. mmax, 0.. 9] of longint;\n a : array [1.. mmax] of longint;\n n, res : longint;\n f, g : text;\n\n\n procedure openf;\n begin\n assign(f, fi); reset(f);\n assign(g, fo); rewrite(g);\n end;\n\n\n procedure closef;\n begin\n close(f); close(g);\n end;\n\n\n procedure readf;\n var\n k: char;\n begin\n while not eoln(f) do\n begin\n read(f, k);\n inc(n);\n a[n]:= ord(k)- ord('0');\n end;\n end;\n\n\n procedure process;\n var\n i, j, k: longint;\n ko : boolean;\n begin\n for i:= 0 to 9 do\n ff[1, i]:= 1;\n\n for i:= 2 to n do\n for j:= 0 to 9 do\n begin\n k:= j* 2- a[i];\n if (k >= 0) and(k< 10) then\n ff[i, j]:= ff[i- 1, k];\n k:= j* 2- a[i]- 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n k:= j* 2- a[i]+ 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n end;\n\n for i:= 0 to 9 do\n res:= res+ ff[n, i];\n ko:= true;\n for i:= 2 to n do\n begin\n j:= a[i- 1]+ a[i];\n if (j div 2<> a[i]) and((j- 1) div 2<> a[i]) and((j+ 1) div 2<> a[i]) then\n begin\n ko:= false;\n break;\n end;\n end;\n\n if ko then\n dec(res);\n\n write(res);\n end;\n\n\n BEGIN\n openf;\n readf;\n process;\n closef;\n END."}, {"source_code": " CONST\n fi = '';//44H.inp';\n fo = '';//44H.out';\n mmax = 50;\n\n VAR\n ff : array [1.. mmax, 0.. 9] of int64;\n a : array [1.. mmax] of longint;\n n, res : longint;\n f, g : text;\n\n\n procedure openf;\n begin\n assign(f, fi); reset(f);\n assign(g, fo); rewrite(g);\n end;\n\n\n procedure closef;\n begin\n close(f); close(g);\n end;\n\n\n procedure readf;\n var\n k: char;\n begin\n while not eoln(f) do\n begin\n read(f, k);\n inc(n);\n a[n]:= ord(k)- ord('0');\n end;\n end;\n\n\n procedure process;\n var\n i, j, k: longint;\n ko : boolean;\n begin\n for i:= 0 to 9 do\n ff[1, i]:= 1;\n\n for i:= 2 to n do\n for j:= 0 to 9 do\n begin\n k:= j* 2- a[i];\n if (k >= 0) and(k< 10) then\n ff[i, j]:= ff[i- 1, k];\n k:= j* 2- a[i]- 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n k:= j* 2- a[i]+ 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n end;\n\n for i:= 0 to 9 do\n res:= res+ ff[n, i];\n ko:= true;\n for i:= 2 to n do\n begin\n j:= a[i- 1]+ a[i];\n if (j div 2<> a[i]) and((j- 1) div 2<> a[i]) and((j+ 1) div 2<> a[i]) then\n begin\n ko:= false;\n break;\n end;\n end;\n\n if ko then\n dec(res);\n\n write(res);\n end;\n\n\n BEGIN\n openf;\n readf;\n process;\n closef;\n END."}, {"source_code": " CONST\n fi = '';//44H.inp';\n fo = '';//44H.out';\n mmax = 50;\n\n VAR\n ff : array [1.. mmax, 0.. 9] of longint;\n a : array [1.. mmax] of longint;\n n, res : longint;\n f, g : text;\n\n\n procedure openf;\n begin\n assign(f, fi); reset(f);\n assign(g, fo); rewrite(g);\n end;\n\n\n procedure closef;\n begin\n close(f); close(g);\n end;\n\n\n procedure readf;\n var\n k: char;\n begin\n while not eoln(f) do\n begin\n read(f, k);\n inc(n);\n a[n]:= ord(k)- ord('0');\n end;\n end;\n\n\n procedure process;\n var\n i, j, k: longint;\n begin\n for i:= 0 to 9 do\n ff[1, i]:= 1;\n\n for i:= 2 to n do\n for j:= 0 to 9 do\n begin\n k:= j* 2- a[i];\n if (k >= 0) and(k< 10) then\n ff[i, j]:= ff[i- 1, k];\n k:= j* 2- a[i]- 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n k:= j* 2- a[i]+ 1;\n if (k>= 0) and(k< 10) then\n ff[i, j]:= ff[i, j]+ ff[i- 1, k];\n end;\n\n for i:= 0 to 9 do\n res:= res+ ff[n, i];\n\n for i:= 2 to n do\n begin\n j:= a[i- 1]+ a[i];\n if (j div 2<> a[i]) and((j- 1) div 2<> a[i]) and((j+ 1) div 2<> a[i]) then\n begin\n break;\n end;\n end;\n\n if i= n then\n dec(res);\n\n write(res);\n end;\n\n\n BEGIN\n openf;\n readf;\n process;\n closef;\n END."}, {"source_code": "{ fp }\nVAr\n s:string;\n last,ans,i,n:Longint;\n a : array[0..50] of longint;\n p : integer;\n ok : Boolean;\n\n Procedure go(last,x:Longint);\n Begin\n If x=n+1 then\n Begin\n inc(ans);\n exit;\n End else\n Begin\n go((last+a[x]) div 2,x+1);\n If (last+a[x]) mod 2=1 then\n go((last+a[x]) div 2+1,x+1);\n End;\n End;\n\n Begin\n readLn(s);\n n := length(s);\n For i :=1 to n do\n val(s[i],a[i],p);\n For i := 0 to 9 do\n go(i,2);\n last := 1;\n ok := true;\n For i := 2 to n do\n Begin\n last := last+a[i];\n If (last div 2=a[i]) or ((last+1) div 2=a[i]) then last := a[i]\n else\n Begin\n ok := false;\n break;\n End;\n End;\n If ok then dec(ans);\n WriteLn(ans);\n End.\n"}, {"source_code": "type TYP=array[0..51] of int64;\nvar s:String;\n a,b:TYP;\n i,j,n,zifr:longint;\n t:extended;\n rez:int64;\n lik,lik1,lik2:longint;\n pp:boolean;\nfunction FUNCT(a:TYP):int64;\nvar i,j,t,k1,k2:longint;\n res:int64;\n k:extended;\n mas:array[0..10,0..51] of int64;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[zifr,1]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)<0.0000001 then begin\n t:=trunc(k);\n mas[t,i]:=mas[j,i-1]+mas[t,i];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[k1,i]:=mas[j,i-1]+mas[k1,i];\n mas[k2,i]:=mas[j,i-1]+mas[k2,i];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[i,n];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0');\nn:=length(s);\nfor zifr:=0 to 9 do begin\nrez:=rez+FUNCT(a);\n//writeln(FUNCT(a));\nend;\nFillchar(b,sizeof(b),0);\nb[1]:=a[1]; lik:=0;\npp:=true;\nfor i:= 2 to n do\nbegin\n t:=(b[i-1]+a[i])/2;\n if frac(t)<0.000001 then begin\n lik:=trunc(t);\n if lik<>a[i] then pp:=false;\n b[i]:=a[i];\n end else\n begin\n t:=t-frac(t);\n lik1:=trunc(t)+1;\n lik2:=lik1+1;\n if (lik1<>a[i]) and (lik2<>a[i]) then pp:=false;\n b[i]:=a[i];\n end;\nend;\nif pp then rez:=rez-1;\nwriteln(rez);\nend.\n"}, {"source_code": "type TYP=array[0..51] of longint;\nvar s:String;\n a,b:TYP;\n i,j,n,k,m,zifr,rez:longint;\n t:extended;\n lik,lik1,lik2:longint;\n pp:boolean;\nfunction FUNCT(a:TYP):longint;\nvar res,i,j,t,k1,k2:longint;\n k:extended;\n mas:array[0..10,1..50] of longint;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[zifr,1]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)=0 then begin\n t:=trunc(k);\n mas[t,i]:=mas[j,i-1]+mas[t,i];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[k1,i]:=mas[j,i-1]+mas[k1,i];\n mas[k2,i]:=mas[j,i-1]+mas[k2,i];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[i,n];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0');\nn:=length(s);\nfor zifr:=0 to 9 do begin\nrez:=rez+FUNCT(a);\n//writeln(FUNCT(a));\nend;\nFillchar(b,sizeof(b),0);\nb[1]:=a[1]; lik:=0;\npp:=true;\nfor i:= 2 to n do\nbegin\n t:=(b[i-1]+a[i])/2;\n if frac(t)=0 then begin\n lik:=trunc(t);\n if lik<>a[i] then pp:=false;\n b[i]:=a[i];\n end else\n begin\n t:=t-frac(t);\n lik1:=trunc(t)+1;\n lik2:=lik1+1;\n if (lik1<>a[i]) and (lik2<>a[i]) then pp:=false;\n b[i]:=a[i];\n end;\nend;\nif pp then dec(rez);\nwriteln(rez);\nend.\n"}, {"source_code": "type TYP=array[0..51] of longint;\nvar s:String;\n a,b:TYP;\n i,j,n,k,m,zifr:longint;\n t:extended;\n rez:int64;\n lik,lik1,lik2:longint;\n pp:boolean;\nfunction FUNCT(a:TYP):int64;\nvar i,j,t,k1,k2:longint;\n res:int64;\n k:extended;\n mas:array[0..10,1..50] of int64;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[zifr,1]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)=0 then begin\n t:=trunc(k);\n mas[t,i]:=mas[j,i-1]+mas[t,i];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[k1,i]:=mas[j,i-1]+mas[k1,i];\n mas[k2,i]:=mas[j,i-1]+mas[k2,i];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[i,n];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0');\nn:=length(s);\nfor zifr:=0 to 9 do begin\nrez:=rez+FUNCT(a);\n//writeln(FUNCT(a));\nend;\nFillchar(b,sizeof(b),0);\nb[1]:=a[1]; lik:=0;\npp:=true;\nfor i:= 2 to n do\nbegin\n t:=(b[i-1]+a[i])/2;\n if frac(t)=0 then begin\n lik:=trunc(t);\n if lik<>a[i] then pp:=false;\n b[i]:=a[i];\n end else\n begin\n t:=t-frac(t);\n lik1:=trunc(t)+1;\n lik2:=lik1+1;\n if (lik1<>a[i]) and (lik2<>a[i]) then pp:=false;\n b[i]:=a[i];\n end;\nend;\nif pp then dec(rez);\nwriteln(rez);\nend.\n"}, {"source_code": "type TYP=array[0..51] of longint;\nvar s:String;\n a,b:TYP;\n i,j,n,k,m,zifr,rez:longint;\n\nfunction FUNCT(a:TYP):longint;\nvar res,i,j,t,k1,k2:longint;\n k:extended;\n mas:array[0..50,0..10] of longint;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[1,zifr]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)=0 then begin\n t:=trunc(k);\n mas[i,t]:=mas[i-1,j]+mas[i,t];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[i,k1]:=mas[i-1,j]+mas[i,k1];\n mas[i,k2]:=mas[i-1,j]+mas[i,k2];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[n,i];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nrez:=0;\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0')+1;\nn:=length(s);\nfor zifr:=0 to 9 do\nrez:=rez+FUNCT(a);\nwriteln(rez+1);\nend.\n"}, {"source_code": "type TYP=array[0..51] of longint;\nvar s:String;\n a,b:TYP;\n i,j,n,k,m,zifr,rez:longint;\n\nfunction FUNCT(a:TYP):longint;\nvar res,i,j,t,k1,k2:longint;\n k:extended;\n mas:array[0..50,0..10] of longint;\nbegin\nres:=0;\nFillchar(mas,sizeof(mas),0);\nmas[1,zifr]:=1;\n for i:= 2 to n do\n begin\n for j:= 0 to 9 do\n begin\n k:=(j+a[i])/2;\n if frac(k)=0 then begin\n t:=trunc(k);\n mas[i,t]:=mas[i-1,j]+mas[i,t];\n end else\n begin\n k:=k-frac(k);\n k1:=trunc(k);\n k2:=k1+1;\n mas[i,k1]:=mas[i-1,j]+mas[i,k1];\n mas[i,k2]:=mas[i-1,j]+mas[i,k2];\n end;\n end;\n end;\n res:=0;\n for i:= 0 to 9 do\n res:=res+mas[n,i];\nFunct:=res;\nend;\n\n\n\n\nbegin\nreadln(s);\nfor i:= 1 to length(s) do\na[i]:=ord(s[i])-ord('0')+1;\nn:=length(s);\nfor zifr:=0 to 9 do\nrez:=rez+FUNCT(a);\nwriteln(rez+1);\nend."}, {"source_code": "\nvar S,S1:string;\n LS,ch,nech,k,oS,oS1:longint;\n A:array[0..50000] of string;\n\nProcedure Rec(x:integer);\nvar i:integer;\n T:boolean;\n\nbegin\n if x=0\n then for i:=0 to 9 do\n begin\n S:=chr(i+48);\n Rec(1);\n S:='';\n end\n else if x=LS\n then begin\n i:=0; T:=True;\n while (i<=K) and T do\n begin\n if A[i]=S\n then T:=False;\n inc(i);\n end;\n if T\n then begin\n inc(k);\n A[i]:=S;\n end;\n end\n else begin\n oS:=ord(S[x])-48;\n oS1:=ord(S1[x+1])-48;\n if (oS+oS1) and 1=0\n then begin\n inc(x);\n S:=S+chr((oS+oS1) div 2+48);\n Rec(x);\n end\n else begin\n inc(x);\n S:=S+chr((oS+oS1) div 2+48);\n Rec(x);\n delete(S,x,1);\n S:=S+chr((oS+oS1) div 2+49);\n Rec(x);\n end;\n end;\n\nend;\n\nBegin\n\n read(S);\n\n LS:=Length(S);\n A[0]:=S; k:=0;\n S1:=S; S:='';\n Rec(0);\n\n writeln(k);\n\nEnd.\n"}, {"source_code": "\nvar S:string;\n LS,k,k1,i:longint;\n A:array[1..50] of integer;\n B:array[1..50] of integer;\nProcedure Rec(x:longint);\nvar i,oS,oS1:longint;\n T:boolean;\n\nbegin\n if x=0\n then for i:=0 to 9 do\n begin\n B[1]:=i;\n Rec(1);\n end\n else if x=LS\n then begin\n {i:=1;\n T:=False;\n while (i<=LS) and not T do\n begin\n if A[i]<>B[i]\n then T:=True;\n inc(i);\n end;\n if T\n then }inc(k);\n end\n else begin\n if (A[x+1]+B[x]) and 1=0\n then begin\n inc(x);\n B[x]:=(A[x]+B[x-1]) shr 1;\n Rec(x);\n end\n else begin\n inc(x);\n B[x]:=(A[x]+B[x-1]) shr 1;\n Rec(x);\n B[x]:=(A[x]+B[x-1]) shr 1+1;\n Rec(x);\n end;\n end;\n\nend;\n\nBegin\n\n read(S);\n\n LS:=Length(S);\n for i:=1 to LS do\n A[i]:=ord(S[i])-48;\n FillChar(B,SizeOf(B),0);\n Rec(0);\n writeln(k-1);\n\nEnd."}, {"source_code": "\nvar S:string;\n LS,k,i,xy,j,x:longint;\n A:array[1..50] of integer;\n B:array[0..9,1..50] of longint;\n T:boolean;\n\nBegin\n\n read(S);\n\n LS:=Length(S);\n for i:=1 to LS do A[i]:=ord(S[i])-48;\n\n FillChar(B,SizeOf(B),0);\n for i:=0 to 9 do B[i,1]:=1;\n\n for i:=2 to LS do\n for j:=0 to 9 do\n begin\n xy:=A[i]+j;\n if xy and 1=0\n then B[xy shr 1,i]:=B[xy shr 1,i]+B[j,i-1]\n else begin\n B[xy shr 1+1,i]:=B[xy shr 1+1,i]+B[j,i-1];\n B[xy shr 1,i]:=B[xy shr 1,i]+B[j,i-1];\n end;\n end;\n for i:=0 to 9 do\n inc(k,B[i,LS]);\n\n x:=A[1]; T:=True;\n for i:=2 to LS do\n begin\n if (x+A[i]) and 1=0\n then begin\n x:=(x+A[i]) shr 1;\n if x<>A[i]\n then T:=False;\n end\n else if ((x+A[i]) shr 1=A[i]) or ((x+A[i]) shr 1+1=A[i])\n then if (x+A[i]) shr 1=A[i]\n then x:=(x+A[i]) shr 1\n else x:=(x+A[i]) shr 1+1\n else T:=False;\n end;\n if T\n then writeln(k-1)\n else writeln(k);\n\nEnd."}, {"source_code": "var\n sum: longint;\n i,j,k:longint;\n s:string;\n b:boolean;\n arr:array [0..9,1..50] of longint;\nBegin\n readln(s);\n for i:=0 to 9 do arr[i,1]:=1;\n for j:=2 to length(s) do\n begin\n for k:=0 to 9 do\n begin\n if (k+ord(s[j])-48) mod 2 = 0 then\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n end\n else\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n arr[(k+ord(s[j])-48 )div 2 +1,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2 +1,j];\n end;\n \n end;\n end;\n sum:=0;\n for i:=0 to 9 do\n sum:=arr[i,length(s)]+sum;\n b:=true;\n for i:=1 to length(s)-1 do \n Begin\n if (ord(s[i])+ord(s[i+1])-48*2) mod 2 = 0 then \n Begin\n if ((ord(s[i])+ord(s[i+1])-48*2) mod 2) <> ord(s[i+1])-48 then b:=false;\n end\n else \n if not (((ord(s[i])+ord(s[i+1])-48*2) div 2 +1 = ord(s[i+1])-48) or ((ord(s[i])+ord(s[i+1])-48*2) div 2= ord(s[i+1])-48)) then b:=false;\n \n End;\n if b then dec(sum);\n writeln(sum);\nEnd."}, {"source_code": "var\n sum: longint;\n i,j,k:longint;\n s:string;\n b:boolean;\n arr:array [0..9,1..50] of longint;\nBegin\n readln(s);\n for i:=0 to 9 do arr[i,1]:=1;\n for j:=2 to length(s) do\n begin\n for k:=0 to 9 do\n begin\n if (k+ord(s[j])-48) mod 2 = 0 then\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n end\n else\n Begin\n arr[(k+ord(s[j])-48 )div 2,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2,j];\n arr[(k+ord(s[j])-48 )div 2 +1,j]:=arr[k,j-1]+arr[(k+ord(s[j])-48 )div 2 +1,j];\n end;\n \n end;\n end;\n sum:=0;\n for i:=0 to 9 do\n sum:=arr[i,length(s)]+sum;\n b:=true;\n for i:=1 to length(s)-1 do \n Begin\n if (ord(s[i])+ord(s[i+1])-48*2) mod 2 = 0 then \n Begin\n if ((ord(s[i])+ord(s[i+1])-48*2) div 2) <> (ord(s[i+1])-48) then b:=false;\n end\n else \n if not (((ord(s[i])+ord(s[i+1])-48*2) div 2 +1 = ord(s[i+1])-48) or ((ord(s[i])+ord(s[i+1])-48*2) div 2= ord(s[i+1])-48)) then b:=false;\n \n End;\n if b then dec(sum);\n writeln(sum);\nEnd."}, {"source_code": "const\n fi='';\n fo='';\nvar\n f:text;\n St:string;\n A:array[1..100,-20..20] of longint;\n res:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,St);\n close(F);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(F);\n writeln(f,res);\n close(F);\nend;\nprocedure process;\nvar i,t,j:longint;xet:boolean;\nbegin\n fillchar(A,sizeof(A),0);\n for i:=0 to 9 do A[1,i]:=1;\n for i:=2 to length(St) do\n begin\n t:=ord(St[i])-48;\n for j:=0 to 9 do A[i,j]:=A[i-1,2*j-t]+A[i-1,2*j-t+1]+A[i-1,2*j-t-1];\n end;\n res:=0;\n xet:=false;\n for i:=0 to 9 do res:=res+A[length(St),i];\n for i:=1 to length(St) do\n if A[i,ord(St[i])-48]=0 then\n begin\n xet:=true;\n break;\n end;\n if not xet then dec(res);\nend;\nbegin\n nhap;\n process;\n xuat;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n f:text;\n St:string;\n A:array[1..100,-20..20] of longint;\n res:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,St);\n close(F);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(F);\n writeln(f,res);\n close(F);\nend;\nprocedure process;\nvar i,t,h,j:longint;xet:boolean;\nbegin\n fillchar(A,sizeof(A),0);\n for i:=0 to 9 do A[1,i]:=1;\n xet:=true;\n for i:=2 to length(St) do\n begin\n t:=ord(St[i])-48;\n for j:=0 to 9 do\n begin\n A[i,j]:=A[i-1,2*j-t]+A[i-1,2*j-t+1]+A[i-1,2*j-t-1];\n h:=ord(St[i-1])-48;\n if j=t then\n begin\n if (h=2*j-t-1) or ((h=2*j-t) or (h=2*j-t+1)) then\n begin\n if A[i-1,h]=0 then xet:=false;\n end\n else xet:=false;\n end;\n end;\n end;\n res:=0;\n for i:=0 to 9 do res:=res+A[length(St),i];\n if xet then dec(res);\nend;\nbegin\n nhap;\n process;\n xuat;\nend.\n"}, {"source_code": "Const\n Fi = '';//44H.inp';\n Fo = '';//44H.out';\n maxn = 50;\n\nVar\n F : Text;\n N : Longint;\n Res : Int64;\n A : Array[1..maxn] of Longint;\n L : Array[0..maxn, 0..9] of Int64;\n\nProcedure Input;\n Var i: Longint; s: String;\n Begin\n Assign(f, fi); Reset(f);\n Readln(f, s);\n N:= Length(s);\n For i:= 1 to n do\n A[i]:= ord(S[i]) - 48;\n Close(f);\n End;\n\nProcedure Process;\n Var i, j, b, ok: Longint;\n Begin\n ok:= 0;\n For i:= 0 to 9 do L[1, i]:= 1;\n For i:= 2 to n do\n For j:= 0 to 9 do\n Begin\n L[i, (j+a[i]) div 2]:= L[i-1, j] + L[i, (j+a[i]) div 2];\n If odd(j+A[i]) then\n L[i, (j+A[i]+1) div 2]:= L[i-1, j] + L[i, (j+A[i]+1) div 2];\n End;\n For i:= 0 to 9 do Res:= Res + L[n, i];\n\n b:= A[1];\n For i:= 2 to n do\n If (A[i]<>(A[i-1] + A[i]) div 2) or (A[i]<>(A[i-1]+A[i]+1) div 2) then\n ok:= 1;\n Res:= Res - ok;\n End;\n\nProcedure Print;\n Var ok, i:Longint;\n Begin\n Assign(f, fo); Rewrite(f);\n If ok=0 then Dec(Res);\n Writeln(f, Res);\n Close(f);\n End;\n\nBEGIN\n Input;\n Process;\n Print;\nEND."}, {"source_code": "const\n fi='';\nvar\n f:text;\n s:string;\n n,kq:longint;\n g:array [1..50,0..9] of int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n close(f);\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\n kt:boolean;\nbegin\n for i:=0 to 9 do g[1,i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n begin\n u:=(j+ord(s[i+1])-48);\n g[i+1,u div 2]:=g[i+1,u div 2]+g[i,j];\n if u mod 2=1 then g[i+1,(u+1) div 2]:=g[i+1,(u+1) div 2]+g[i,j];\n end;\n for i:=0 to 9 do kq:=kq+g[n,i];\n kt:=true; u:=ord(s[1])-48;\n for i:=2 to n do\n begin\n v:=ord(s[i])-48;\n u:=(u+v) div 2;\n if (u<>v) and (u<>v-1) then\n begin\n kt:=false;\n break;\n end;\n end;\n if kt then dec(kq);\n writeln(kq);\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "const\n fi='';\nvar\n f:text;\n kq:int64;\n g:array [0..50,0..9] of int64;\n s:string;\n n:longint;\n a:array [1..50] of longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n n:=length(s);\n close(f);\n for i:=1 to n do a[i]:=ord(s[i])-48;\nend;\nprocedure xuly;\nvar\n i,u,j:longint;\nbegin\n for i:=0 to 9 do g[1,i]:=1;\n for i:=1 to n-1 do\n for j:=0 to 9 do\n begin\n u:=j+a[i+1];\n g[i+1,u div 2]:=g[i+1,u div 2]+g[i,j];\n if u mod 2=1 then g[i+1,(u+1) div 2]:=g[i+1,(u+1) div 2]+g[i,j];\n end;\n j:=0;\n for i:=1 to n-1 do\n begin\n u:=(a[i]+a[i+1]+1) div 2;\n if u<>a[i+1] then j:=-1;\n end;\n if j=0 then kq:=-1;\n for i:=0 to 9 do kq:=kq+g[n,i];\n writeln(kq);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "var x,y,t,k1,k2,g:longint;\n p:integer;\n i:char;\n s,w:string;\n q:array[0..1000000] of string;\n begin\n readln(s);\n k1:=1;\n k2:=1;\n q[1]:='';\n g:=0;\n while k1<=k2 do\n begin\n if length(q[k1])=0 then begin\n for i:='0' to '9' do\n begin\n inc(k2);\n q[k2]:=q[k1]+i;\n end;\n end\n else\n if length(q[k1])2 then ans:=ans-1;\n writeln(ans);\n end."}, {"source_code": "var i,j,l,ans,n,t:longint;\n q:boolean;\n a,b,c:array[0..51] of longint;\n s:string;\n p:integer;\n begin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n val(s[i],a[i],p);\n for i:=0 to 9 do\n b[i]:=1;\n for i:=2 to n do\n begin\n fillchar(c,sizeof(c),0);\n for j:=0 to 9 do\n begin\n for l:=0 to 9 do\n begin\n if (l+a[i]) div 2=j then c[j]:=c[j]+b[l];\n if (l+a[i]) mod 2=1 then if (a[i]+l) div 2+1=j then c[j]:=c[j]+b[l];\n end;\n end;\n b:=c;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+b[i];\n q:=true;\n for i:=2 to n do\n begin\n t:=a[i]+a[i-1];\n if t mod 2=0 then begin\n if (t div 2)<>a[i] then q:=false;\n end\n else begin\n if ((t div 2)<>a[i]) and ((t div 2+1)<>a[i]) then q:=false;\n end;\n end;\n if q then ans:=ans-1;\n writeln(ans);\n end."}, {"source_code": "var\n s:string;\n a:array[1..50,0..9] of longint;\n n,i,j,k,t,kq:longint;\n check:boolean;\nbegin\n readln(s);\n kq:=0;\n for i:=0 to 9 do a[1,i]:=1;\n check:=true;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n for j:=0 to 9 do\n begin\n if (j+k) mod 2 = 0 then a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j]\n else\n begin\n a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j];\n a[i,(j+k) div 2+1]:=a[i,(j+k) div 2+1]+a[i-1,j];\n end;\n end;\n end;\n for i:=0 to 9 do kq:=kq+a[length(s),i];\n t:=1;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n if (t+k) mod 2 = 0 then\n if ((t+k) div 2 <> k) then\n begin\n check:=false;\n break;\n end;\n if (t+k) mod 2 =1 then\n if ((t+k) div 2 <> k) and ((t+k) div 2+1<>k) then\n begin\n check:=false;\n break;\n end;\n t:=k;\n end;\n if check=true then dec(kq);\n writeln(kq);\nend.\n"}, {"source_code": "var\n s:string;\n a:array[1..50,0..9] of longint;\n n,i,j,k,t,kq:longint;\n check:boolean;\nbegin\n readln(s);\n kq:=0;\n for i:=0 to 9 do a[1,i]:=1;\n check:=true;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n for j:=0 to 9 do\n begin\n if (j+k) mod 2 = 0 then a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j]\n else\n begin\n a[i,(j+k) div 2]:=a[i,(j+k) div 2]+a[i-1,j];\n a[i,(j+k) div 2+1]:=a[i,(j+k) div 2+1]+a[i-1,j];\n end;\n end;\n end;\n for i:=0 to 9 do kq:=kq+a[length(s),i];\n t:=ord(s[1])-48;\n for i:=2 to length(s) do\n begin\n k:=ord(s[i])-48;\n if (t+k) mod 2 = 0 then\n if ((t+k) div 2 <> k) then\n begin\n check:=false;\n break;\n end;\n if (t+k) mod 2 =1 then\n if ((t+k) div 2 <> k) and ((t+k) div 2+1<>k) then\n begin\n check:=false;\n break;\n end;\n t:=k;\n end;\n if check=true then dec(kq);\n writeln(kq);\nend.\n"}, {"source_code": "program sdt;\nconst\n fi = '';\n fo = '';\n nmax = 50;\nvar\n a: array[1..nmax] of int64;\n b: array[0..9, 1..nmax] of int64;\n n: longint;\n kq: int64;\n f1, f2: text;\n\n procedure openf;\n begin\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n end;\n\n procedure closef;\n begin\n close(f1); close(f2);\n end;\n\n procedure input;\n var\n s: string;\n i: longint;\n begin\n read(f1, s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n end;\n\n procedure output;\n begin\n write(f2, kq);\n end;\n\n procedure process;\n var\n i, j: longint;\n begin\n for i := 0 to 9 do\n b[i, n] := 1;\n for i := n - 1 downto 1 do\n for j := 0 to 9 do\n if (j + a[i + 1]) and 1 = 1 then\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1] + b[(j + a[i + 1]) div 2 + 1, i + 1]\n else\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1];\n for i := 0 to 9 do\n kq := kq + b[i, 1];\n for i := 2 to n do\n begin\n if abs(a[i] - a[i - 1]) > 1 then\n break;\n if i = n then\n dec(kq);\n end;\n end;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend."}, {"source_code": "program sdt;\nconst\n fi = '';\n fo = '';\n nmax = 50;\nvar\n a: array[1..nmax] of int64;\n b: array[0..9, 1..nmax] of int64;\n n: longint;\n kq: int64;\n f1, f2: text;\n\n procedure openf;\n begin\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n end;\n\n procedure closef;\n begin\n close(f1); close(f2);\n end;\n\n procedure input;\n var\n s: string;\n i: longint;\n begin\n read(f1, s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n end;\n\n procedure output;\n begin\n write(f2, kq);\n end;\n\n procedure process;\n var\n i, j: longint;\n begin\n for i := 0 to 9 do\n b[i, n] := 1;\n for i := n - 1 downto 1 do\n for j := 0 to 9 do\n if (j + a[i + 1]) and 1 = 1 then\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1] + b[(j + a[i + 1]) div 2 + 1, i + 1]\n else\n b[j, i] := b[(j + a[i + 1]) div 2, i + 1];\n for i := 0 to 9 do\n kq := kq + b[i, 1];\n for i := 2 to n do\n begin\n if abs(a[i] - a[i - 1]) > 1 then\n break;\n if i = n then\n kq := kq - 1;\n end;\n end;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst nn=50{1024};eps=0; label 1;\ntype mas=array[0..nn] of longint;\nvar t,t1,imax,n,p,i,j,k,l,m,step,n1,k1,ot,name2:longint;\n b,a1,b1,dl,dr,hl,hr:mas; flag:boolean; pl:longint;\n name:array [0..nn,0..nn] of string ;\n spname :array[0..nn] of string;\n ch:char;\n sc,time:array[0..nn] of longint;\n variant:array[0..nn,0..nn] of int64;\n a:array[0..nn] of longint;\n ss:string;\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output1234.txt');rewrite(output);\n}readln (ss); n:=length(ss);\nfor i:=1 to n do a[i]:=ord(ss[i])-48;\n{for i:=1 to n do write(a[i],' '); writeln;writeln;\n}for i:=0 to 9 do variant[1,i]:=1; variant[1,9]:=1;\nfor step:=1 to n-1 do for i:=0 to 9 do\n begin\n t:=i+a[step+1]; t1:=t div 2;\n if not odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n end;\n if odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n variant[step+1,t1+1]:=variant[step+1,t1+1]+variant[step,i];\n end;\n end;\n for step:=1 to n do\n{ begin for i:=0 to 9 do write(variant[step,i],' ');writeln; end;\n}\nflag:=true ;\nfor step:=1 to n do if variant[step,a[step]]=0 then flag:=false;\not:=0; for i:=0 to 9 do ot:=ot+variant[n,i];\nif flag then dec(ot);\nwriteln(ot);\n\n\n 1: close (output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst nn=50{1024};eps=0; label 1;\ntype mas=array[0..nn] of longint;\nvar tt,t,t1,imax,n,p,i,j,k,l,m,step,n1,k1,ot,name2:longint;\n b,a1,b1,dl,dr,hl,hr:mas; flag:boolean; pl:longint;\n name:array [0..nn,0..nn] of string ;\n spname :array[0..nn] of string;\n ch:char;\n sc,time:array[0..nn] of longint;\n variant:array[0..nn,0..nn] of int64;\n a:array[0..nn] of longint;\n ss:string;\n fl:array[0..nn] of boolean;\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output1234.txt');rewrite(output);\n}readln (ss); n:=length(ss);\nfor i:=1 to n do a[i]:=ord(ss[i])-48;\n{for i:=1 to n do write(a[i],' '); writeln;writeln;\n}for i:=0 to 9 do variant[1,i]:=1; variant[1,9]:=1;\nfor step:=1 to n-1 do for i:=0 to 9 do\n begin\n t:=i+a[step+1]; t1:=t div 2;\n if not odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n end;\n if odd(t) then\n begin\n variant[step+1,t1]:=variant[step+1,t1]+variant[step,i];\n variant[step+1,t1+1]:=variant[step+1,t1+1]+variant[step,i];\n end;\n end;\n for step:=1 to n do\n {begin for i:=0 to 9 do write(variant[step,i],' ');writeln; end;\n }\not:=0; for i:=0 to 9 do ot:=ot+variant[n,i];\nflag:=true;\ntt:=a[1];\nfor i:=2 to n do\n begin\n if (not odd(a[i]+a[i-1])) and ((a[i]+a[i-1])div 2 <>a[i]) then flag:=false;\n if (odd(a[i]+a[i-1])) and ((a[i]+a[i-1])div 2 <>a[i])and ((a[i]+a[i-1])div 2+1 <>a[i]) then flag:=false;\n end;\n\n\nif flag then dec(ot);\nwriteln(ot);\n\n\n 1: close (output);\nend.\n"}, {"source_code": "program JJ_Mybabe;\n {$APPTYPE CONSOLE} {$o-}\nuses SysUtils,Math;\nvar\n i,j,p,m:integer;\n k:int64;\n s:string;\n b:array[1..50] of integer;\n a:array[1..50,0..9] of integer;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(s);\n for i:=1 to length(s) do\n b[i]:=strtoint(s[i]);\n for i:=0 to 9 do a[1][i]:=1;\n for i:=2 to length(S) do\n for j:=0 to 9 do\n begin\n k:=(j+b[i]);\n a[i][k div 2]:=a[i][k div 2]+a[i-1][j];\n if (j+b[i]) mod 2<>0 then\n a[i][k div 2+1]:=a[i][k div 2+1]+a[i-1][j];\n end;\n k:=0;\n for i:=0 to 9 do\n k:=k+a[length(s)][i];\n for i:=2 to length(s) do\n begin\n p:=(b[i]+b[i-1]);\n if p mod 2 =0 then\n if p div 2<>b[i] then m:=1;\n if p mod 2<>0 then\n if (p div 2<>b[i]) and (p div 2+1<>b[i]) then m:=1;\n end;\n if m=0 then dec(k);\n write(k);\nend.\n\n\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar ans,sn,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\ns:string;\na:array[1..11111111] of int64;\n\nprocedure dfs(n:int64;pos:integer);\nvar num,d:int64;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=n mod 10;\nif pos=length(s) then\n begin\n inc(cnt);\n a[cnt]:=n;\n end\nelse\nbegin\nnum:=ord(s[pos+1])-ord('0');\n\ndfs(n*10+(num+d) div 2,pos+1);\n\nif (num+d) mod 2 = 1 then\ndfs(n*10+(num+d) div 2 + 1,pos+1);\n\nend;\n\nend;\n\nbegin\n readln(s);\n sn:=0;\n for I := 1 to length(s) do\n begin\n sn:=sn*10;\n sn:=sn+ord(s[i])-ord('0');\n end;\n\n\n cnt:=0;\n for I := 0 to 9 do\n dfs(i,1);\n\n\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n\n for I := 1 to cnt do\n if a[i]<>-1 then\n begin\n j:=i+1;\n while a[i]=a[j] do\n begin\n a[j]:=-1;\n inc(j);\n end;\n \n end;\n\n ans:=0;\n for I := 1 to cnt do\n if (a[i]<>sn) and (a[i]<>-1) then inc(ans);\n\n writeln(ans);\n//while True do\n\n end.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$M 16777216}\nuses\n SysUtils;\nvar ans,sn,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\ns:string;\na:array[1..31111111] of int64;\n\nprocedure dfs(n:int64;pos:integer);\nvar num,d:int64;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=n mod 10;\nif pos=length(s) then\n begin\n inc(cnt);\n a[cnt]:=n;\n end\nelse\nbegin\nnum:=ord(s[pos+1])-ord('0');\n\ndfs(n*10+(num+d) div 2,pos+1);\n\nif (num+d) mod 2 = 1 then\ndfs(n*10+(num+d) div 2 + 1,pos+1);\n\nend;\n\nend;\n\nbegin\n readln(s);\n sn:=0;\n for I := 1 to length(s) do\n begin\n sn:=sn*10;\n sn:=sn+ord(s[i])-ord('0');\n end;\n\n\n cnt:=0;\n for I := 0 to 9 do\n dfs(i,1);\n\n {\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n }\n\n //for I := 1 to cnt do\n // writeln(a[i]);\n\n for I := 1 to cnt do\n if a[i]<>-1 then\n begin\n j:=i+1;\n while a[i]=a[j] do\n begin\n a[j]:=-1;\n inc(j);\n end;\n\n end;\n\n ans:=0;\n for I := 1 to cnt do\n if (a[i]<>sn) and (a[i]<>-1) then inc(ans);\n\n writeln(ans);\n//True do\n\n end.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar ans,sn,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\ns:string;\na:array[1..11111111] of integer;\n\nprocedure dfs(n:int64;pos:integer);\nvar num,d:integer;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=n mod 10;\nif pos=length(s) then\n begin\n inc(cnt);\n a[cnt]:=n;\n end\nelse\nbegin\nnum:=ord(s[pos+1])-ord('0');\nif (num+d) mod 2 = 1 then\ndfs(n*10+(num+d) div 2 + 1,pos+1);\ndfs(n*10+(num+d) div 2,pos+1);\n\nend;\n\nend;\n\nbegin\n readln(s);\n sn:=0;\n for I := 1 to length(s) do\n begin\n sn:=sn*10;\n sn:=sn+ord(s[i])-ord('0');\n end;\n\n\n cnt:=0;\n for I := 0 to 9 do\n dfs(i,1);\n\n\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n ans:=0;\n for I := 1 to cnt do\n if a[i]<>sn then inc(ans);\n \n writeln(ans);\n//while True do\n\n end.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar ans,sn,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\ns:string;\na:array[1..11111111] of int64;\n\nprocedure dfs(n:int64;pos:integer);\nvar num,d:integer;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=n mod 10;\nif pos=length(s) then\n begin\n inc(cnt);\n a[cnt]:=n;\n end\nelse\nbegin\nnum:=ord(s[pos+1])-ord('0');\nif (num+d) mod 2 = 1 then\ndfs(n*10+(num+d) div 2 + 1,pos+1);\ndfs(n*10+(num+d) div 2,pos+1);\n\nend;\n\nend;\n\nbegin\n readln(s);\n sn:=0;\n for I := 1 to length(s) do\n begin\n sn:=sn*10;\n sn:=sn+ord(s[i])-ord('0');\n end;\n\n\n cnt:=0;\n for I := 0 to 9 do\n dfs(i,1);\n\n\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n ans:=0;\n for I := 1 to cnt do\n if a[i]<>sn then inc(ans);\n \n writeln(ans);\n//while True do\n\n end.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar ans,sn,rem,q,remn,n,m,t,k,cnt,e,currc,currb,b,c:int64;\nflag:boolean;\ni,j:integer;\ns:string;\na:array[1..11111111] of int64;\n\nprocedure dfs(n:int64;pos:integer);\nvar num,d:integer;\nbegin\n//writeln('EXEC DFS(',n,',',pos,')');\nd:=n mod 10;\nif pos=length(s) then\n begin\n inc(cnt);\n a[cnt]:=n;\n end\nelse\nbegin\nnum:=ord(s[pos+1])-ord('0');\nif (num+d) mod 2 = 1 then\ndfs(n*10+(num+d) div 2 + 1,pos+1);\ndfs(n*10+(num+d) div 2,pos+1);\n\nend;\n\nend;\n\nbegin\n readln(s);\n sn:=0;\n for I := 1 to length(s) do\n begin\n sn:=sn*10;\n sn:=sn+ord(s[i])-ord('0');\n end;\n\n\n cnt:=0;\n for I := 0 to 9 do\n dfs(i,1);\n\n\n for I := 1 to cnt do\n for J := i+1 to cnt do\n if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n\n for I := 1 to cnt do\n if a[i]<>-1 then\n begin\n j:=i+1;\n while a[i]=a[j] do\n begin\n a[j]:=-1;\n inc(j);\n end;\n \n end;\n\n ans:=0;\n for I := 1 to cnt do\n if (a[i]<>sn) and (a[i]<>-1) then inc(ans);\n \n writeln(ans);\n//while True do\n\n end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i, j, n, res : longint;\n a : array[1..50] of longint;\n b, b2 : array[0..9] of longint;\n s : string;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n\n readln(s);\n s := trim(s);\n n := length(s);\n for i := 1 to n do\n a[i] := ord(s[i]) - ord('0');\n\n for i := 0 to 9 do\n b[i] := 1;\n\n for i := 2 to n do\n begin\n fillchar(b2, sizeof(b2), 0);\n for j := 0 to 9 do\n begin\n b2[(a[i] + j) div 2] := b2[(a[i] + j) div 2] + b[j];\n if ((a[i] + j) div 2) <> ((a[i] + j + 1) div 2) then\n b2[(a[i] + j + 1) div 2] := b2[(a[i] + j + 1) div 2] + b[j];\n end;\n b := b2;\n end;\n\n res := 0;\n for i := 0 to 9 do\n res := res + b[i];\n res := res - 1;\n for i := 2 to n do\n if ((a[i] + a[i - 1]) div 2 <> a[i]) and ((a[i] + a[i - 1] + 1) div 2 <> a[i]) then\n begin\n res := res + 1;\n break;\n end;\n write(res);\n // close(input);\n // close(output);\nend.\n "}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n dp:Array[0..9,0..50] of Int64;\n a,b:Array[0..50] of Int64;\n s:String;\n n,ans,f:Int64;\n i,j:Integer;\nFunction Solve(i,j:Integer):Int64;\nBegin\n If dp[i,j]<>-1 Then Begin\n Solve:=dp[i,j];\n Exit;\n End;\n If j=n Then Begin\n If (i+a[j]) mod 2=0 Then dp[i,j]:=1\n Else dp[i,j]:=2;\n Solve:=dp[i,j];\n Exit;\n End;\n If (i+a[j]) mod 2=0 Then dp[i,j]:=Solve((i+a[j]) div 2,j+1)\n Else dp[i,j]:=Solve((i+a[j]) div 2,j+1)+Solve((i+a[j]) div 2+1,j+1);\n Solve:=dp[i,j];\nEnd;\nBegin\n Read(s);\n n:=length(s);\n If n=1 Then Begin\n Write(8);\n Halt;\n End;\n For i:=1 To n Do a[i]:=strtoint(s[i]);\n For i:=0 To 9 Do\n For j:=1 To 50 Do dp[i,j]:=-1;\n ans:=0;\n For i:=0 To 9 Do ans:=ans+Solve(i,2);\n b[1]:=a[1];\n f:=1;\n For i:=2 To n Do Begin\n If (a[i]+b[i-1]) mod 2=0 Then Begin\n b[i]:=(a[i]+b[i-1]) div 2;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End\n Else Begin\n If (a[i]+b[i-1]) div 2=a[i] Then b[i]:=(a[i]+b[i-1]) div 2\n Else b[i]:=(a[i]+b[i-1]) div 2+1;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End;\n End;\n If f=1 Then ans:=ans-1;\n Write(ans);\nEnd.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n dp:Array[0..9,0..50] of Int64;\n a,b:Array[0..50] of Int64;\n s:String;\n n,ans,f:Int64;\n i,j:Integer;\nFunction Solve(i,j:Integer):Int64;\nBegin\n If dp[i,j]<>-1 Then Begin\n Solve:=dp[i,j];\n Exit;\n End;\n If j=n Then Begin\n If (i+a[j]) mod 2=0 Then dp[i,j]:=1\n Else dp[i,j]:=2;\n Solve:=dp[i,j];\n Exit;\n End;\n If (i+a[j]) mod 2=0 Then dp[i,j]:=Solve((i+a[j]) div 2,j+1)\n Else dp[i,j]:=Solve((i+a[j]) div 2,j+1)+Solve((i+a[j]) div 2+1,j+1);\n Solve:=dp[i,j];\nEnd;\nBegin\n Read(s);\n n:=length(s);\n If n=1 Then Begin\n Write(0);\n Halt;\n End;\n For i:=1 To n Do a[i]:=strtoint(s[i]);\n For i:=0 To 9 Do\n For j:=1 To 50 Do dp[i,j]:=-1;\n ans:=0;\n For i:=0 To 9 Do ans:=ans+Solve(i,2);\n b[1]:=a[1];\n f:=1;\n For i:=2 To n Do Begin\n If (a[i]+b[i-1]) mod 2=0 Then Begin\n b[i]:=(a[i]+b[i-1]) div 2;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End\n Else Begin\n If (a[i]+b[i-1]) div 2=a[i] Then b[i]:=(a[i]+b[i-1]) div 2\n Else b[i]:=(a[i]+b[i-1]) div 2+1;\n If b[i]<>a[i] Then Begin\n f:=0;\n Break;\n End;\n End;\n End;\n If f=1 Then ans:=ans-1;\n Write(ans);\nEnd.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n,qq : longint;\n f,f2 : array [0..9] of int64;\n ans,ans1 : int64;\n a,b : array [1..50] of longint;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(s1);\n{ n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n ans1:=n;\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n b[1]:=a[1];\n for i:=2 to n do\n begin\n if (b[i-1]+a[i]) mod 2 = 0 then\n begin\n if ((b[i-1]+a[i]) div 2) <>a[i] then\n break;\n end\n else\n begin\n if (((b[i-1]+a[i]) div 2) <>a[i]) and ((b[i-1]+a[i]+1) div 2 <> a[i]) then\n break;\n end;\n b[i]:=a[i];\n end;\n if i>n then\n dec(ans);\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n,qq : longint;\n f,f2 : array [0..9] of int64;\n ans,ans1 : int64;\n a,b : array [0..100000] of int64;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n{ for qq:=1 to 1000000 do\n begin\n if qq>1 then\n begin\n close(input);\n close(output);\n end;\n rewrite(output,'input.txt');\n write(qq);\n close(output); }\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(s1);\n{ n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n ans1:=n;\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n b[1]:=a[1];\n i:=2;\n for i:=2 to n do\n begin\n if (((b[i-1]+a[i]) div 2)<>a[i]) and (((b[i-1]+a[i]+1) div 2)<>a[i]) then\n break;\n b[i]:=a[i];\n end;\n if i>n then\n dec(ans);\n writeln(ans);\n{ if ans1<>ans then\n break;\n end; }\nend.\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n : longint;\n f,f2 : array [0..9] of int64;\n ans : int64;\n a : array [1..50] of longint;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt');}\n readln(s1);\n{ n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n i:=1;\n if a[i]a[i+1]) and (ia[i] then\n break;\n end\n else\n begin\n if (((b[i-1]+a[i]) div 2) <>a[i]) and ((b[i-1]+a[i]+1) div 2 <> a[i]) then\n break;\n end;\n b[i]:=a[i];\n end;\n if i>n then\n dec(ans);\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n s1: string;\n i,j,n : longint;\n f,f2 : array [0..9] of int64;\n ans : int64;\n a : array [1..50] of longint;\nprocedure rec(s : string);\nvar\n i : longint;\nbegin\n i:=length(s);\n if s=s1 then\n exit;\n if i=length(s1) then\n begin\n inc(n);\n exit;\n end;\n if ((ord(s1[i+1])-48)+(ord(s[i])-48)) mod 2 = 1 then\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +49));\n rec(s+chr(((ord(s1[i+1])-48)+(ord(s[i])-48)) div 2 +48));\nend;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(s1);\n{ n:=0;\n for I:=0 to 9 do\n rec(chr(i+48));\n writeln(n); }\n n:=length(s1);\n for i:=1 to n do\n a[i]:=ord(s1[i])-ord('0');\n for i:=0 to 9 do\n f[i]:=1;\n for I:=2 to n do\n begin\n f2:=f;\n for j:=0 to 9 do\n f[j]:=0;\n for j:=0 to 9 do\n begin\n if (j+a[i]) mod 2 = 1 then\n f[(j+a[i]+1) div 2]:=f[(j+a[i]+1) div 2]+f2[j];\n f[(j+a[i]) div 2]:=f[(j+a[i]) div 2]+f2[j];\n end;\n end;\n ans:=0;\n for i:=0 to 9 do\n ans:=ans+f[i];\n i:=1;\n if a[i]a[i] then\n break;\n end\n else\n begin\n if (((b[i-1]+a[i]) div 2) <>a[i]) and ((b[i-1]+a[i]+1) div 2 <> a[i]) then\n break;\n end;\n b[i]:=a[i];\n end;\n if i>n then\n writeln(ans-1)\n else\n write(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "var\n s : string;\n i,j,n,sum : longint;\n sr : extended;\n a : array[0..1000,0..1000] of longint;\n f : boolean;\nbegin\n readln(s);\n n := length(s);\n for j := 0 to 9 do\n a[1,j] := 1;\n for i := 2 to n do\n begin\n for j := 0 to 9 do\n begin\n sr := (j + (ord(s[i]) - 48)) / 2;\n if sr <> trunc(sr) then\n begin\n a[i,trunc(sr)] := a[i,trunc(sr)] + a[i-1,j];\n a[i,trunc(sr) + 1] := a[i,trunc(sr) + 1] + a[i-1,j];\n end else\n a[i,trunc(sr)] := a[i,trunc(sr)] + a[i-1,j];\n end;\n end;\n sum := 0;\n for j := 0 to 9 do\n sum := sum + a[n,j];\n f := true;\n for i := 2 to n do\n begin\n sr := ord(s[i]) - 48 + ord(s[i - 1]) - 48;\n sr := sr / 2;\n if sr = round(sr) then\n if (trunc(sr) <> ord(s[i]) - 48) then f := false;\n\n if sr <> round(sr) then\n if (trunc(sr) <> ord(s[i]) - 48)\n and (trunc(sr) + 1 <> ord(s[i]) - 48)\n then f := false;\n end;\n if f then dec(sum);\n write(sum);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nvar s:string;\nl:integer;\no:int64;\nbegin;\n{reset(input,'input.txt');\nrewrite(output,'output.txt'); }\nreadln(s);\nl:=length(s);\no:=(l+2)*(l+2)-1;\nif l=1 then writeln(0) else writeln(o);\n{close(input);\nclose(output);}\nend.\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar s:string;\nk:int64;\ni,q,q1,pr,pr1,j:integer;\na:array[1..53,0..9] of integer;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n readln(s);\n for i := 0 to 9 do\n a[1,i]:=1;\n\n for i := 2 to length(s) do\n begin\n val(s[i],q,pr);\n for j:=0 to 9 do\n if (q+j) mod 2=0 then a[i,(q+j) div 2]:=a[i-1,j]+a[i,(q+j) div 2]\n else\n begin\n a[i,(q+j) div 2]:=a[i-1,j]+a[i,(q+j) div 2];\n a[i,(q+j) div 2+1]:=a[i-1,j]+a[i,(q+j) div 2+1];\n end;\n end;\n k:=0;\n pr1:=0;\n for i:=0 to 9 do k:=k+a[length(s),i];\n val(s[1],q1,pr);\n for i:= 2 to length(s) do\n begin\n val(s[i],q,pr);\n if (q+q1) mod 2 =0 then begin if ((q+q1) div 2)<>q then pr1:=1; end\n else if (((q+q1) div 2)<>q) and (((q+q1+1) div 2)<>q) then pr1:=1;\n q1:=q;\n end;\n\n\n\n if pr1=0 then dec(k);\n writeln(k);\n\n{close(input);\nclose(output);}\nend.\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\nvar s:string;\nl:integer;\no:int64;\nbegin;\nreadln(s);\nl:=length(s);\nl:=l+2;\no:=l*l;\no:=o-1;\nwriteln(o);\nend.\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\nvar s:string;\nl:integer;\no:int64;\nbegin;\nreadln(s);\nl:=length(s);\no:=(l+2)*(l+2)-1;\nif l=1 then writeln(10) else writeln(o);\nend.\n\n\n"}, {"source_code": "program HH;\n\n{$APPTYPE CONSOLE}\n\n\nvar\nfin:boolean;\ny,i,j,n,d,k,l,c,x,sum:longint;\ns,s1,ss,sss,ssss:string;\na:array[1..105] of longint;\nb:array[1..105,0..9] of longint;\n\n\n\n\n\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(s);\n sum:=0;\n n:=length(s);\n sum:=0;\n if n=1 then writeln('9') else begin\n\n for i:=1 to n do begin\n val(s[i],a[i],c);\n end;\n\n for i:=0 to 9 do begin\n b[1,i]:=1;\n end;\n\n for i:=2 to n do begin\n\n for j:=0 to 9 do begin\n if (b[i-1,j]>0) and ((j+a[i]) mod 2=0) then begin\n b[i,(j+a[i]) div 2]:=b[i,(j+a[i]) div 2]+b[i-1,j];\n end;\n if (b[i-1,j]>0) and ((j+a[i]) mod 2=1) then begin\n b[i,(j+a[i]) div 2]:=b[i,(j+a[i]) div 2]+b[i-1,j];\n b[i,((j+a[i]) div 2)+1]:=b[i,((j+a[i]) div 2)+1]+b[i-1,j];\n end;\n end;\n \n end;\n\n for i:=0 to 9 do begin\n sum:=sum+b[n,i];\n end;\n {if (fin=false) then sum:=sum-1;}\n\n\n\n\n fin:=false;\n for i:=2 to n do begin\n y:=(a[i-1]+a[i])div 2;\n if ((a[i-1]+a[i])mod 2)=0 then begin\n if y<>a[i] then fin:=true;\n end else begin\n if (a[i]y+1) then fin:=true;\n end;\n end;\n if (fin=false) then sum:=sum-1;\n\n\n writeln(sum);\n\n\n\n\n\n\n\n\n\n\n end;\n\nend.\n "}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{M 67108864}\n\nuses SysUtils, Math;\n \nvar \n s:string;\n ls,kk,i,j,pp:longint;\n a:array[0..1010,0..10] of int64;\n ans:int64;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nfillchar(a,sizeof(a),0);\nreadln(s);\nls:=length(s);\nkk:=ls-1;\nans:=0;\nfor i:=0 to 9 do\n a[1][i]:=1;\nfor i:=1 to kk do begin\n for j:=0 to 9 do begin\n pp:=j+ord(s[i+1])-48;\n inc(a[i+1][pp shr 1],a[i][j]);\n if pp and 1=1 then inc(a[i+1][(pp+1) shr 1],a[i][j]);\n end;\nend;\nfor i:=0 to 9 do\n inc(ans,a[ls][i]);\nfor i:=2 to ls do\n if abs(ord(s[i])-ord(s[i-1]))>1 then begin\n dec(ans);\n break;\n end;\nwrite(ans);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}, {"source_code": "{$APPTYPE CONSOLE}\n\n{$R+,S+,Q+,I+,C+,M+,H+,O-}\n{M 67108864}\n\nuses SysUtils, Math;\n \nvar \n s:string;\n ls,kk,i,j,pp:longint;\n a:array[0..1010,0..10] of int64;\n ans:int64;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\nreset(input,'input.txt');\nrewrite(output,'output.txt');\n{$ENDIF}\nfillchar(a,sizeof(a),0);\nreadln(s);\nls:=length(s);\nkk:=ls-1;\nans:=0;\nfor i:=0 to 9 do\n a[1][i]:=1;\nfor i:=1 to kk do begin\n for j:=0 to 9 do begin\n pp:=j+ord(s[i+1])-48;\n inc(a[i+1][pp div 2],a[i][j]);\n if pp and 1=1 then inc(a[i+1][(pp+1) div 2],a[i][j]);\n end;\nend;\nfor i:=0 to 9 do\n inc(ans,a[ls][i]);\nfor i:=2 to ls do\n if abs(ord(s[i])-ord(s[i-1]))>1 then begin\n dec(ans);\n break;\n end;\nwrite(ans);\nend.\n\n//writeln(FormatDateTime('hh:mm:ss.zzz', now));"}], "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b"} {"source_code": "type\n cir=record\n x,y,r:longint;\n end;\nvar\n c1,c2,c3,c4:cir;\n tot,i,j,k,x,y:longint;\nfunction inter(o,a,b:cir):boolean;\n var\n i,j,k:longint;\n dis:real;\n begin\n dis:=sqrt(sqr(o.x-a.x)+sqr(o.y-a.y));\n if (dis>abs(o.r-a.r))and(disabs(o.r-b.r))and(disa.r)and(dis<=abs(o.r-a.r))and(dis<=abs(o.r-b.r))and(o.r=o.r+a.r)and(o.r=r1+r2)and(s>=r1+rr2)then inc(q);\n if (r2>=s+r1)and(rr2>=s+r1)then inc(q);\n if (r1>=s+r2)and(r1>=s+rr2)then inc(q);\n \n if (s>=rr1+r2)and(s>=rr1+rr2)then inc(q);\n if (r2>=s+rr1)and(rr2>=s+rr1)then inc(q);\n if (rr1>=s+r2)and(rr1>=s+rr2)then inc(q);\n \n if (s>=r2+r1)and(s>=r2+rr1)then inc(q);\n if (r1>=s+r2)and(rr1>=s+r2)then inc(q);\n if (r2>=s+r1)and(r2>=s+rr1)then inc(q);\n \n if (s>=rr2+r1)and(s>=rr2+rr1)then inc(q);\n if (r1>=s+rr2)and(rr1>=s+rr2)then inc(q);\n if (rr2>=s+r1)and(rr2>=s+rr1)then inc(q);\n writeln(q);\nend."}, {"source_code": "var\n x1,x2,y1,y2,r1,r2,s1,s2,ans:longint;\n t:extended;\nbegin\n readln(x1,y1,r1,s1);\n readln(x2,y2,r2,s2);\n ans:=0;\n t:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if (t*t>=(r1+s2)*(r1+s2)) or ((t+r1)*(t+r1)<=r2*r2) or ((t+s2)*(t+s2)<=r1*r1) then\n inc(ans);\n if (t*t>=(r2+s1)*(r2+s1)) or ((t+r2)*(t+r2)<=r1*r1) or ((t+s1)*(t+s1)<=r2*r2) then\n inc(ans);\n if (t*t>=(s1+s2)*(s1+s2)) or ((t+s1)*(t+s1)<=r2*r2) or ((t+s2)*(t+s2)<=s1*s1) then\n inc(ans);\n if (t*t>=(s2+s1)*(s2+s1)) or ((t+s2)*(t+s2)<=r1*r1) or ((t+s1)*(t+s1)<=s2*s2) then\n inc(ans);\n writeln(ans);\nend."}, {"source_code": "// buneng CE!\nvar\n len,x1,y1,x2,y2:double;\n r1,r11,r2,r22:longint;\n ans:longint;\n b:array[0..101]of longint;\n\nbegin\n\n readln(x1,y1,r1,r11);\n readln(x2,y2,r2,r22);\n len:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n ans:=0;\n { fillchar(b,sizeof(b),0);\n if (len-r1)>0 then\n begin\n if ((len-r1)>=r22)or((len+r1)<=r2)and(b[r1]=0) then\n begin\n inc(ans);\n b[r1]:=1;\n end;\n end\n else\n begin\n if (r22<=(r1-len))or((len+r1)<=r2)and(b[r1]=0) then\n begin\n inc(ans);\n b[r1]:=1;\n end;\n end;\n if (len-r11)>0 then\n begin\n if ((len-r11)>=r22)or((len+r11)<=r2)and(b[r11]=0) then\n begin\n inc(ans);\n b[r11]:=1;\n end;\n end\n else\n begin\n if (r22<=(r11-len))or((len+r11)<=r2)and(b[r11]=0) then\n begin\n inc(ans);\n b[r11]:=1;\n end;\n end;\n if (len-r2)>0 then\n begin\n if ((len-r2)>=r11)or((len+r2)<=r1)and(b[r2]=0) then\n begin\n inc(ans);\n b[r2]:=1;\n end;\n end\n else\n begin\n if (r11<=(r2-len))or((len+r2)<=r1)and(b[r2]=0) then\n begin\n inc(ans);\n b[r2]:=1;\n end;\n end;\n if (len-r22)>0 then\n begin\n if ((len-r22)>=r11)or((len+r22)<=r1)and(b[r22]=0) then\n begin\n inc(ans);\n b[r22]:=1;\n end;\n end\n else\n begin\n if (r11<=(r2-len))or((len+r22)<=r1)and(b[r22]=0) then\n begin\n inc(ans);\n b[r22]:=1;\n end;\n end; }\n if ((r22+r1)<=len)or((r1+len)<=r2)or((len+r22)<=r1) then inc(ans);\n if ((r22+r11)<=len)or((r11+len)<=r2)or((len+r22)<=r11) then inc(ans);\n if ((r11+r2)<=len)or((r2+len)<=r1)or((len+r11)<=r2) then inc(ans);\n if ((r11+r22)<=len)or((r22+len)<=r1)or((len+r11)<=r22) then inc(ans);\n\n writeln(ans);\n\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\n\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :extended;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n function ainb(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-15;\n if (d+rr1max(rr1,rr2)-min(rr1,rr2)+eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n }\n dd:=sqrt((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3]));\n { writeln(dd:0:4,' ',r[1]:0:4,' ',r[4]:0:4);\n writeln(ainb(dd,r[3],r[1]),' ',ainb(dd,r[1],r[4]),' ',perkr(dd,r[1],r[4])); }\n if not (ainb(dd,r[3],r[1]) and ainb(dd,r[1],r[4])) and not perkr(dd,r[1],r[3]) and not perkr(dd,r[1],r[4])and not(ainb(dd,r[1],r[4]) and asnarb(dd,r[1],r[3])) then inc(ot);\n if not (ainb(dd,r[3],r[2]) and ainb(dd,r[2],r[4])) and not perkr(dd,r[2],r[3]) and not perkr(dd,r[2],r[4])and not(ainb(dd,r[2],r[4]) and asnarb(dd,r[2],r[3])) then inc(ot);\n if not (ainb(dd,r[1],r[3]) and ainb(dd,r[3],r[2])) and not perkr(dd,r[1],r[3]) and not perkr(dd,r[2],r[3])and not(ainb(dd,r[3],r[2]) and asnarb(dd,r[3],r[1])) then inc(ot);\n if not (ainb(dd,r[1],r[4]) and ainb(dd,r[4],r[2])) and not perkr(dd,r[1],r[4]) and not perkr(dd,r[2],r[4])and not(ainb(dd,r[4],r[2]) and asnarb(dd,r[4],r[1])) then inc(ot);\n\n writeln(ot);\n\n 1: close(output);\nend.\n"}, {"source_code": "const\n eps=1e-9;\nvar\n x1,y1,a1,b1:longint;\n x2,y2,a2,b2:longint;\n len:longint;\n n:longint;\n\n function sum(x,y,z,ll:longint):longint;\n var k:longint;\n begin\n k:=0;\n if (((z-x)*abs(z-x)<=ll)and(ll<=(x-z)*abs(x-z)))or(len>=(x+z)*(x+z)) then begin\n k:=1;\n end;\n if ((x-y)*abs(x-y)<=ll)and(ll<=(y-x)*abs(x-y)) then begin\n k:=k+1;\n end;\n sum:=k;\n end;\n\nbegin\n readln(x1,y1,a1,b1);\n readln(x2,y2,a2,b2);\n len:=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);\n if (x1=x2)and(y1=y2)and(a1=a2)and(b1=b2) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(a2=b1) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(b2=a1) then begin\n writeln(2);exit;\n end;\n n:=0;\n n:=n+sum(a1,a2,b2,len);\n n:=n+sum(b1,a2,b2,len);\n n:=n+sum(a2,a1,b1,len);\n n:=n+sum(b2,a1,b1,len);\n writeln(n);\nend."}, {"source_code": "program cf199B;\nvar i,j,br:longint;\n x,y,r:array[1..10] of longint;\n rij:real;\nfunction rastojanje(i,j:longint):real;\n begin\n rastojanje:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n end;\nbegin\nread(x[1],y[1],r[1],r[2]);\nx[2]:=x[1];\ny[2]:=y[1];\nread(x[3],y[3],r[3],r[4]);\nx[4]:=x[3];\ny[4]:=y[3];\n\nbr:=0;\n\nrij:=rastojanje(1,3);\n//1 u odnosu na 3 i 4\nif ((rij+r[3]<=r[1]) and (rij+r[4]<=r[1]))\nor ((rij+r[1]<=r[3]) and (rij+r[1]<=r[4]))\nor ((rij>=r[1]+r[3]) and (rij>=r[1]+r[4])) then\n br:=br+1;\n//2 u odnosu na 3 i 4\nif ((rij+r[3]<=r[2]) and (rij+r[4]<=r[2]))\nor ((rij+r[2]<=r[3]) and (rij+r[2]<=r[4]))\nor ((rij>=r[2]+r[3]) and (rij>=r[2]+r[4])) then\n br:=br+1;\n//3 u odnosu na 1 i 2\nif ((rij+r[1]<=r[3]) and (rij+r[2]<=r[3]))\nor ((rij+r[3]<=r[1]) and (rij+r[3]<=r[2]))\nor ((rij>=r[3]+r[1]) and (rij>=r[3]+r[2])) then\n br:=br+1;\n//4 u odnosu na 1 i 2\nif ((rij+r[1]<=r[4]) and (rij+r[2]<=r[4]))\nor ((rij+r[4]<=r[1]) and (rij+r[4]<=r[2]))\nor ((rij>=r[4]+r[1]) and (rij>=r[4]+r[2])) then\n br:=br+1;\n\nwriteln(br);\n\nend."}, {"source_code": "Uses Math;\nType tm=Array [1..4] of LongInt;\n tf=Array [1..4] of Boolean;\nVar x,y,r:tm;\n m:tf;\n kol,a,b,c,d,i:LongInt;\n \nFunction Prov (x1,y1,r1,x2,y2,r2:LongInt):Boolean;\nVar r:Real;\nBegin\n r:=sqrt (sqr (x1-x2)+sqr(y1-y2));\n If r>=r1+r2\n then Result:=True\n else If r+Min (r1,r2)<=Max (r1,r2)\n then Result:=True\n else Result:=False;\nEnd;\n\nFunction Inn (k,i,j:LongInt):Boolean;\nVar r1,r2:Real;\nBegin\n r1:=sqrt (sqr (x[k]-x[i]-r[k])+sqr(y[k]-y[i]));\n r2:=sqrt (sqr (x[k]-x[i]+r[k])+sqr(y[k]-y[i]));\n If (r[j]>=r1) and (r[i]<=r1) and (r[j]>=r2) and (r[i]<=r2)\n then Result:=True\n else Result:=False;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n Readln (a,b,c,d); x[1]:=a; x[2]:=a; y[1]:=b; y[2]:=b; r[1]:=c; r[2]:=d;\n Readln (a,b,c,d); x[3]:=a; x[4]:=a; y[3]:=b; y[4]:=b; r[3]:=c; r[4]:=d;\n FillChar (m,sizeof (tm),False);\n kol:=0;\n If Prov (x[1],y[1],r[1],x[3],y[3],r[3]) and Prov (x[1],y[1],r[1],x[4],y[4],r[4]) then m[1]:=True;\n If Prov (x[2],y[2],r[2],x[3],y[3],r[3]) and Prov (x[2],y[2],r[2],x[4],y[4],r[4]) then m[2]:=True;\n If Prov (x[3],y[3],r[3],x[1],y[1],r[1]) and Prov (x[3],y[3],r[3],x[2],y[2],r[2]) then m[3]:=True;\n If Prov (x[4],y[4],r[4],x[1],y[1],r[1]) and Prov (x[4],y[4],r[4],x[2],y[2],r[2]) then m[4]:=True;\n For I:=1 to 4 do\n If m[i] then Inc (kol);\n If m[1] and (Inn (1,3,4)) then Dec (kol);\n If m[2] and (Inn (2,3,4)) then Dec (kol);\n If m[3] and (Inn (3,1,2)) then Dec (kol);\n If m[4] and (Inn (4,1,2)) then Dec (kol);\n Writeln (kol);\nEnd."}, {"source_code": "var\n x1,x2,y1,y2,p1,q1,p2,q2,ans:longint;\n d:real;\n s1,s2,s3,s4:boolean;\nbegin\n readln(x1,y1,p1,q1);\n readln(x2,y2,p2,q2);\n ans:=0;\n d:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n if ((d>=p1+p2)and(d>=p1+q2))or((d<=p1-p2)and(d<=p1-q2))or((d<=p2-p1)and(d<=q2-p1))then inc(ans);\n if ((d>=q1+p2)and(d>=q1+q2))or((d<=q1-p2)and(d<=q1-q2))or((d<=p2-q1)and(d<=q2-q1))then inc(ans);\n if ((d>=p1+p2)and(d>=q1+p2))or((d<=p1-p2)and(d<=q1-p2))or((d<=p2-p1)and(d<=p2-q1))then inc(ans);\n if ((d>=p1+q2)and(d>=q1+q2))or((d<=p1-q2)and(d<=q1-q2))or((d<=q2-p1)and(d<=q2-q1))then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "type\n ongint=extended;\nvar x1,y1,x2,y2,i1,o1,i2,o2:ongint;\n ans:longint;\n\n procedure check(x,y,r,x1,y1,i1,o1:ongint);\n\n function f(x,y,r,x1,y1,r1,r2:ongint):boolean;\n var d:ongint;\n\n procedure swap(var a,b:ongint);\n var c:ongint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n begin\n d:=sqrt(sqr(x-x1)+sqr(y-y1));\n if d+r<=r1 then exit(true);\n if r+r2<=d then exit(true);\n if d+r2<=r then exit(true);\n exit(false);\n end;\n\n\n begin\n if not f(x,y,r,x1,y1,i1,o1) then exit;\n inc(ans);\n end;\n\n begin\n readln(x1,y1,i1,o1);\n readln(x2,y2,i2,o2);\n check(x1,y1,i1,x2,y2,i2,o2);\n check(x1,y1,o1,x2,y2,i2,o2);\n check(x2,y2,i2,x1,y1,i1,o1);\n check(x2,y2,o2,x1,y1,i1,o1);\n write(ans);\n end.\n"}, {"source_code": "var x1,y1,r1,rr1,x2,y2,r2,rr2,q:longint;s:extended;\nbegin\n readln(x1,y1,r1,rr1);\n readln(x2,y2,r2,rr2);\n s:=sqrt(sqr(x1-x2)+sqr(y1-y2));q:=0;\n if (s>=r1+r2)and(s>=r1+rr2)then inc(q);\n if (r2>=s+r1)and(rr2>=s+r1)then inc(q);\n if (r1>=s+r2)and(r1>=s+rr2)then inc(q);\n\n if (s>=rr1+r2)and(s>=rr1+rr2)then inc(q);\n if (r2>=s+rr1)and(rr2>=s+rr1)then inc(q);\n if (rr1>=s+r2)and(rr1>=s+rr2)then inc(q);\n\n if (s>=r2+r1)and(s>=r2+rr1)then inc(q);\n if (r1>=s+r2)and(rr1>=s+r2)then inc(q);\n if (r2>=s+r1)and(r2>=s+rr1)then inc(q);\n\n if (s>=rr2+r1)and(s>=rr2+rr1)then inc(q);\n if (r1>=s+rr2)and(rr1>=s+rr2)then inc(q);\n if (rr2>=s+r1)and(rr2>=s+rr1)then inc(q);\n writeln(q);\nend."}, {"source_code": "program problemB;\nvar\n ans,i,j:longint;\n x,y:array[1..2]of longint;\n r:array[1..2,1..2]of longint;\n\nfunction minn(a,b:longint):longint;\nbegin\n if a=sqr(r[3-p,2]+r[p,1]) then exit(true);\n if (r[3-p,1]>r[p,1])and(dist<=sqr(r[3-p,1]-r[p,1])) then exit(true);\n if (r[p,1]>r[3-p,2])and(dist<=sqr(r[p,1]-r[3-p,2])) then exit(true);\n exit(false);\nend;\n\nfunction check2(p:longint):boolean;\nvar\n dist:longint;\nbegin\n dist:=sqr(x[1]-x[2])+sqr(y[1]-y[2]);\n if dist>=sqr(r[3-p,2]+r[p,2]) then exit(true);\n if (r[3-p,1]>r[p,2])and(dist<=sqr(r[3-p,1]-r[p,2])) then exit(true);\n if (r[p,2]>r[3-p,2])and(dist<=sqr(r[p,2]-r[3-p,2])) then exit(true);\n exit(false);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'B.in');\n reset(input);\n assign(output,'B.out');\n rewrite(output);\n{$endif}\n\n readln(x[1],y[1],r[1,1],r[1,2]);\n readln(x[2],y[2],r[2,1],r[2,2]);\n\n ans:=0;\n if check1(1) then inc(ans);\n if check2(1) then inc(ans);\n if check1(2) then inc(ans);\n if check2(2) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n p, s, b: integer;\n\nfunction Peres(u, v: integer): boolean;\nvar\n a, b, c: real;\nbegin\n Result := false;\n a := r[u];\n b := r[v];\n c := sqrt(sqr(x[u] - x[v]) + sqr(y[u] - y[v]));\n\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nFunction into(u, v: integer): boolean;\nvar\n a, b, c: real;\nbegin\n Result := false;\n a := r[v];\n b := r[u];\n c := sqrt(sqr(x[u] - x[v]) + sqr(y[u] - y[v]));\n\n if (a > c + b - 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1];\n y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3];\n y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n p := i div 3;\n s := 1;\n b := 2;\n if p = 0 then\n begin\n s := 3;\n b := 4;\n end;\n\n if i mod 2 = 1 then\n begin\n if Peres(i, s) or (into(i, b) and not(into(i, s))) or peres(i, b) then\n f := 1;\n end\n else\n begin\n if (into(i, b) and not(into(i, s))) or peres(i, b) or peres(i, s) then\n f := 1;\n end;\n\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "program b;\nvar\n x1,x2,y1,y2,r1,r2,d1,d2:double;\n f1,f2,f3,f4:boolean;\n dist:double;\n tot:longint;\nprocedure work(a1,a2:double;var fa,fb:boolean);\n begin\n if a1a2)and(dista2)and(dista1)and(dista1)and(dist=r2)and(dist+r1<=d2)and(r1<=d2))or((dist>=r1+r2)and(dist+r1<=d2)) then f2:=false;\n if f1=true then\n if ((dist<=r2+d1)and(d1>=r2)and(dist+d1<=d2)and(d1<=d2))or((dist>=d1+r2)and(dist+d1<=d2)) then f1:=false;\n if f4=true then\n if ((dist<=r1+r2)and(r2>=r1)and(dist+r2<=d1)and(r2<=d1))or((dist>=r1+r2)and(dist+r2<=d1)) then f4:=false;\n if f3=true then\n if ((dist<=r1+d2)and(d2>=r1)and(dist+d2<=d1)and(d2<=d1))or((dist>=d2+r1)and(dist+d2<=d1)) then f3:=false;\n tot:=0;\n if f1=true then inc(tot);\n if f2=true then inc(tot);\n if f3=true then inc(tot);\n if f4=true then inc(tot);\n writeln(tot);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\nmaxn = 2222;\ntype\ncircle=record\n x,y,r : integer;\n end;\nvar\nx,y,r,rr,ans : integer;\nc : array [1..4] of circle;\n\nfunction cross (a,b : integer) : boolean;\nbegin\n if sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y)>=sqr(c [a].r+c [b].r) then\n begin\n cross:=false;\n exit;\n end;\n if sqr(max (c [a].r,c [b].r)-min (c [a].r,c [b].r))>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n cross:=false;\n exit;\n end;\n cross:=true;\nend;\n\nfunction into (a,b : integer) : boolean;\nbegin\n if c [b].r-c [a].r<=0 then\n begin\n into:=false;\n exit;\n end;\n if sqr(c [b].r-c [a].r)>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n into:=true;\n exit;\n end;\n into:=false;\nend;\n\nfunction fill (a,b,d : integer) : boolean;\nbegin\n if (sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y)>=sqr(c [a].r+c [b].r)) and into (a,d) then fill:=true\n else fill:=false;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n readln (x,y,r,rr);\n c [1].x:=x; c [2].x:=x;\n c [1].y:=y; c [2].y:=y;\n c [1].r:=r; c [2].r:=rr;\n readln (x,y,r,rr);\n c [3].x:=x; c [4].x:=x;\n c [3].y:=y; c [4].y:=y;\n c [3].r:=r; c [4].r:=rr;\n\n ans:=0;\n if not cross (1,3) and not cross (1,4) and not (into (1,4) and into (3,1)) and not fill (1,3,4) then inc (ans);\n if not cross (2,3) and not cross (2,4) and not (into (2,4) and into (3,2)) and not fill (2,3,4) then inc (ans);\n if not cross (3,1) and not cross (3,2) and not (into (3,2) and into (1,3)) and not fill (3,1,2) then inc (ans);\n if not cross (4,1) and not cross (4,2) and not (into (4,2) and into (1,4)) and not fill (4,1,2) then inc (ans);\n writeln (ans);\nend.\n"}, {"source_code": "\nvar\n x,y,r:array[0..500]of longint;\n i,j,res:longint;\n \n function cross(x1,y1,r1,x2,y2,r2,r3:longint):boolean;\n begin\n if ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)>=(r1+r3)*(r1+r3))then begin\n cross:=false;\n exit;\n end;\n if (r1<=r2)and((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=(r1-r2)*(r1-r2))then begin\n cross:=false;\n exit;\n end;\n if (r1>=r3)and((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=(r1-r3)*(r1-r3))then begin\n cross:=false;\n exit;\n end;\n cross:=true;\n end;\n\nbegin\n read(x[1],y[1],r[1],r[2]);\n x[2]:=x[1];y[2]:=y[1];\n read(x[3],y[3],r[3],r[4]);\n x[4]:=x[3];y[4]:=y[3];\n res:=0;\n if (not cross(x[3],y[3],r[3],x[1],y[1],r[1],r[2]))then inc(res);\n if (not cross(x[4],y[4],r[4],x[1],y[1],r[1],r[2]))then inc(res);\n if (not cross(x[1],y[1],r[1],x[3],y[3],r[3],r[4]))then inc(res);\n if (not cross(x[2],y[2],r[2],x[3],y[3],r[3],r[4]))then inc(res);\n writeln(res);\nend.\n"}, {"source_code": "const maxn=5;\ntype cir = record\nx,y,r:longint;\nend;\n\nvar f1,f2:text;\nA:array[1..maxn] of cir;\nC:array[1..maxn] of longint;\nx1,y1,r1,r2,i,j:longint;\nres:longint;\nd:double;\nok:boolean;\nd1,d2:longint;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,x1,y1,r1,r2);\n A[1].x:=x1;a[1].y:=y1;a[1].r:=r1;\n A[2].x:=x1;a[2].y:=y1;a[2].r:=r2;\n readln(f1,x1,y1,r1,r2);\n A[3].x:=x1;a[3].y:=y1;a[3].r:=r1;\n A[4].x:=x1;a[4].y:=y1;a[4].r:=r2;\n For i:=1 to 2 do\n Begin\n ok:=true;\n for j:=3 to 4 do\n begin\n d:=sqrt(sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x));\n if a[i].r+a[j].r<=d then C[j]:=1 else\n if ABS(a[i].r-a[j].r)>=d then\n Begin\n if a[i].r>a[j].r then C[j]:=2\n else c[j]:=3;\n end\n else\n ok:=false;\n end;\n if ok and (C[3]=C[4]) then inc(res);\n End;\n For i:=3 to 4 do\n Begin\n ok:=true;\n for j:=1 to 2 do\n begin\n d:=sqrt(sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x));\n if a[i].r+a[j].r<=d then C[j]:=1 else\n if ABS(a[i].r-a[j].r)>=d then\n Begin\n if a[i].r>a[j].r then C[j]:=2\n else c[j]:=3;\n End\n else\n ok:=false;\n end;\n if ok and (C[1]=C[2]) then inc(res);\n End;\n writeln(f2,res);\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\n{function gcd(a,b:integer):integer;\nbegin\nif b=0 then gcd:=a\n else gcd:=gcd(b,a mod b);\nend;\nfor k:=1 to n-1 do\n for i:=1 to n-k do\n if a[i]>a[i+1] then begin t:=a[i]; a[i]:=a[i+1]; a[i+1]:=t; end;}\n\nvar x1,y1,x2,y2,r1,r2,rt1,rt2,ans:integer;\n dist:real;\n\nbegin\nreadln(x1,y1,r1,rt1);\nreadln(x2,y2,r2,rt2);\ndist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n ans:=0;\nif (dist+r1<=r2) or (dist+rt2<=r1) or (r1+rt2<=dist) then inc(ans);\nif (dist+r2<=r1) or (dist+rt1<=r2) or (r2+rt1<=dist) then inc(ans);\nif (rt1>=dist+rt2) or (rt1+rt2<=dist) or (dist+rt1<=r2) then inc(ans);\nif (rt2>=dist+rt1) or (rt1+rt2<=dist) or (dist+rt2<=r1) then inc(ans);\nwrite(ans);\nreadln;\nend."}, {"source_code": "const fi='';\ntype hkr=record x,y,r:shortint end;\nvar a,b,c,d,kq:shortint;\n cir1,cir2,cir3,cir4:hkr;\n b1,b2,b3,b4:boolean;\n dis:real; f:text;\nfunction NI(a,b,c:hkr):boolean;\nbegin\n if b.r-a.r>=dis then exit(true);\n if a.r+c.r<=dis then exit(true);\n if a.r-c.r>=dis then exit(true);\n exit(false);\nend;\nbegin\n assign(f,fi);reset(f);\n readln(f,a,b,c,d);\n with cir1 do begin x:=a; y:=b; r:=c; end;\n with cir2 do begin x:=a; y:=b; r:=d; end;\n readln(f,a,b,c,d);\n with cir3 do begin x:=a; y:=b; r:=c; end;\n with cir4 do begin x:=a; y:=b; r:=d; end;\n close(f);\n dis:=sqrt(sqr(cir1.x-cir3.x)+sqr(cir1.y-cir3.y));\n b1:=NI(cir1,cir3,cir4);\n b2:=NI(cir2,cir3,cir4);\n b3:=NI(cir3,cir1,cir2);\n b4:=NI(cir4,cir1,cir2);\n if b1 then inc(kq);\n if b2 then inc(kq);\n if b3 then inc(kq);\n if b4 then inc(kq);\n writeln(kq);\nend.\n"}, {"source_code": "uses math;\nconst\n tfi = '';\n tfo = '';\n nmax = 101;\ntype\n arr1 = array[0..nmax] of longint;\nvar\n fi,fo:text;\n n,m:longint;\n x1,x2,y1,y2,rnho1,rnho2,rlon1,rlon2,res:longint;\nprocedure nhap;\nvar i,j,u,v:longint;\nbegin\n read(fi,x1,y1,rnho1,rlon1);\n read(fi,x2,y2,rnho2,rlon2);\nend;\nfunction ngoai(x1,y1,r1,x2,y2,r2:longint):boolean;\nvar kc:longint;\nbegin\n kc:=sqr(x1-x2)+sqr(y1-y2);\n if sqr(r1+r2)<=kc then exit(true)\n else exit(false);\nend;\nfunction trong(x1,y1,r1,x2,y2,r2:longint):boolean;\nvar kc:longint;\nbegin\n kc:=sqr(x1-x2)+sqr(y1-y2);\n if (r1=kc) then exit(true)\n else exit(false);\nend;\nprocedure xuly;\nvar i,j,u,v:longint;\nbegin\n res:=0;\n if ngoai(x1,y1,rnho1,x2,y2,rlon2) or\n trong(x1,y1,rnho1,x2,y2,rnho2) or\n trong(x2,y2,rlon2,x1,y1,rnho1) then inc(res);\n if ngoai(x1,y1,rlon1,x2,y2,rlon2) or\n trong(x1,y1,rlon1,x2,y2,rnho2) or\n trong(x2,y2,rlon2,x1,y1,rlon1) then inc(res);\n if ngoai(x2,y2,rnho2,x1,y1,rlon1) or\n trong(x2,y2,rnho2,x1,y1,rnho1) or\n trong(x1,y1,rlon1,x2,y2,rnho2) then inc(res);\n if ngoai(x2,y2,rlon2,x1,y1,rlon1) or\n trong(x2,y2,rlon2,x1,y1,rnho1) or\n trong(x1,y1,rlon1,x2,y2,rlon2) then inc(res);\n writeln(fo,res);\nend;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n nhap;\n xuly;\n close(fi);\n close(fo);\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar fi,fo:text;\n x,y,r1,r2:array[1..2]of double;\n dist:double;\nprocedure enter;\nvar i:longint;\nbegin\n assign(fi,finp);reset(fi);\n for i:=1 to 2 do\n readln(fi,x[i],y[i],r1[i],r2[i]);\n close(fi);\nend;\nfunction incircle(r1,r2:double):boolean;\nbegin\n if (abs(dist-r2) <= r1) and (dist+r2 <= r1) then exit(true);\n exit(false);\nend;\nfunction outcircle(r1,r2:double):boolean;\nbegin\n if (abs(dist-r2) >= r1) and (dist+r2 >= r1) then exit(true);\n exit(false);\nend;\nprocedure solve;\nvar res:longint;\nbegin\n assign(fo,fout);rewrite(fo);\n dist:=sqrt(sqr(x[1]-x[2])+sqr(y[1]-y[2]));\n res:=0;\n if (incircle(r1[1],r1[2]))\n or (outcircle(r2[1],r1[2])) then res:=res+1;\n if (incircle(r1[1],r2[2]))\n or (outcircle(r2[1],r2[2])) then res:=res+1;\n if (incircle(r1[2],r1[1]))\n or (outcircle(r2[2],r1[1])) then res:=res+1;\n if (incircle(r1[2],r2[1]))\n or (outcircle(r2[2],r2[1])) then res:=res+1;\n writeln(fo,res);\n close(fo);\nend;\nbegin\n enter;\n solve;\nend.\n"}, {"source_code": "var x1,y1,x2,y2:shortint; r:array[1..4] of byte; d:real;\nbegin\n readln(x1,y1,r[1],r[2]);\n read(x2,y2,r[3],r[4]);\n d:=sqrt(sqr(x1-x2)+sqr(y1-y2)); x1:=0;\n for y1:=1 to 2 do\n if (d>=r[y1]+r[4]) or (d+r[4]<=r[y1]) or (d+r[y1]<=r[3]) then inc(x1);\n for y1:=3 to 4 do\n if (d>=r[y1]+r[2]) or (d+r[2]<=r[y1]) or (d+r[y1]<=r[1]) then inc(x1);\n write(x1)\nend."}, {"source_code": "var x1,y1,x2,y2,r1,r2,r3,r4:longint;\n ans:longint;\nfunction jiao(x1,y1,r1,x2,y2,r2:longint):boolean;\n var t:longint;\n begin\n t:=sqr(x1-x2)+sqr(y1-y2);\n jiao:=(tsqr(r1-r2));\n end;\nfunction init(x1,y1,r1,r2,x2,y2,r3:longint):boolean;\n var t:longint; p:boolean;\n begin\n t:=sqr(x1-x2)+sqr(y1-y2);\n p:=(r3*2<=abs(r1-r2)) and (t>sqr(r1)) and (t=r1) and (r3<=r2) and (x1-r1>=x2-r3) and (x1+r1<=x2+r3)\n and (x1-r2<=x2-r3) and (x1+r2>=x2+r3);\n end;\n init:=p;\n end;\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n ans:=0;\n if not jiao(x1,y1,r1,x2,y2,r3) and not jiao(x1,y1,r1,x2,y2,r4) \n and not init(x2,y2,r3,r4,x1,y1,r1)then \n inc(ans);\n// writeln(ans);\n if not jiao(x1,y1,r2,x2,y2,r3) and not jiao(x1,y1,r2,x2,y2,r4) \n and not init(x2,y2,r3,r4,x1,y1,r2)then \n inc(ans); \n// writeln(ans); \n if not jiao(x2,y2,r3,x1,y1,r1) and not jiao(x2,y2,r3,x1,y1,r2) \n and not init(x1,y1,r1,r2,x2,y2,r3) then \n inc(ans);\n// writeln(ans);\n if not jiao(x2,y2,r4,x1,y1,r1) and not jiao(x2,y2,r4,x1,y1,r2) \n and not init(x1,y1,r1,r2,x2,y2,r4) then \n inc(ans); \n// writeln(ans);\n writeln(ans);\nend."}, {"source_code": "var\n x1,x2,y1,y2,r1,r2,s1,s2,ans:longint;\n t:extended;\nbegin\n readln(x1,y1,r1,s1);\n readln(x2,y2,r2,s2);\n ans:=0;\n t:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if (t*t>=(r1+s2)*(r1+s2)) or ((t+r1)*(t+r1)<=r2*r2) or ((t+s2)*(t+s2)<=r1*r1) then\n inc(ans);\n if (t*t>=(r2+s1)*(r2+s1)) or ((t+r2)*(t+r2)<=r1*r1) or ((t+s1)*(t+s1)<=r2*r2) then\n inc(ans);\n if (t*t>=(s1+s2)*(s1+s2)) or ((t+s1)*(t+s1)<=r2*r2) or ((t+s2)*(t+s2)<=s1*s1) then\n inc(ans);\n if (t*t>=(s2+s1)*(s2+s1)) or ((t+s2)*(t+s2)<=r1*r1) or ((t+s1)*(t+s1)<=s2*s2) then\n inc(ans);\n writeln(ans);\nend."}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,prov:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n prov:=0;\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n if prov=1 then write('t1');\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n if prov=1 then write('t2');\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n if prov=1 then write('t3');\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n if prov=1 then write('t4');\n end; \n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if (r1<=(r3+cr)) and ((r3+cr)<=r2) and ((r3>r1) or (cr>r1)) then begin\n o3:=0;\n if prov=1 then write('t5');\n end;\n if (r1<=(r4+cr)) and ((r4+cr)<=r2) and ((r4>r1) or (cr>r1)) then begin\n o4:=0;\n if prov=1 then write('t6');\n end;\n if (r3<=(r1+cr)) and ((r1+cr)<=r4) and ((r1>r3) or (cr>r3)) then begin\n o1:=0;\n if prov=1 then write('t7');\n end;\n if (r3<=(r2+cr)) and ((r2+cr)<=r4) and ((r2>r3) or (cr>r3)) then begin\n o2:=0;\n if prov=1 then write('t8');\n end;\n if prov=1 then writeln;\n writeln(o1+o2+o3+o4);\n (*writeln(o1,o2,o3,o4);*)\nend."}, {"source_code": "var\n x1,y1,x2,y2,r1,r2,rr1,rr2:extended;\n ans:longint;\n\nfunction distance(x1,y1,x2,y2:extended):extended;\n begin\n exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));\n end;\n \nfunction inside(x1,y1,r1,x2,y2,r2:extended):boolean;\n begin\n exit(distance(x1,y1,x2,y2)+r1<=r2);\n end;\n\nfunction outside(x1,y1,r1,x2,y2,r2:extended):boolean;\n begin\n exit((distance(x1,y1,x2,y2)>=r1+r2) or inside(x2,y2,r2,x1,y1,r1));\n end;\n\n\nbegin\n readln(x1,y1,r1,rr1);\n readln(x2,y2,r2,rr2);\n if outside(x1,y1,r1,x2,y2,rr2) or inside(x1,y1,r1,x2,y2,r2) then inc(ans);\n if outside(x1,y1,rr1,x2,y2,rr2) or inside(x1,y1,rr1,x2,y2,r2) then inc(ans);\n if outside(x2,y2,r2,x1,y1,rr1) or inside(x2,y2,r2,x1,y1,r1) then inc(ans);\n if outside(x2,y2,rr2,x1,y1,rr1) or inside(x2,y2,rr2,x1,y1,r1) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\n\nVar x1,y1,x2,y2,r1,rr1,r2,rr2:longint;\n k1,k2,k3,k4:longint;\n kil:longint;\n\nFunction ask1(x1,y1,r1,x2,y2,r2:longint):longint;\n\nBegin\n\nask1:=0;\n\nif r1>r2 then exit;\n\nif sqr(x1-x2)+sqr(y1-y2)<=sqr(r1-r2) then ask1:=1;\n\nend;\n\n\nFunction ask2(x1,y1,r1,x2,y2,r2:longint):longint;\n\nBegin\n\nask2:=0;\n\nif sqr(x1-x2)+sqr(y1-y2)=sqr(r1+rr2)) then k1:=1;\n\nif (ask1(x1,y1,rr1,x2,y2,r2)=1)or\n (ask1(x2,y2,rr2,x1,y1,rr1)=1)or\n (sqr(x1-x2)+sqr(y1-y2)>=sqr(rr1+rr2)) then k2:=1;\n\nif (ask1(x2,y2,r2,x1,y1,r1)=1)or\n (ask1(x1,y1,rr1,x2,y2,r2)=1)or\n (sqr(x1-x2)+sqr(y1-y2)>=sqr(rr1+r2)) then k3:=1;\n\nif (ask1(x2,y2,rr2,x1,y1,r1)=1)or\n (ask1(x1,y1,rr1,x2,y2,rr2)=1)or\n (sqr(x1-x2)+sqr(y1-y2)>=sqr(rr1+rr2)) then k4:=1;\n\n\n\nWriteln(k1+k2+k3+k4);\n\nENd.\n\n\n\n"}], "negative_code": [{"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-10;\n if (dmax(rr1,rr2)-min(rr1,rr2)+eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then begin flag:=false; {writeln(i,' ===',j); } end;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-10;\n if (dmax(rr1,rr2)-min(rr1,rr2)-eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then begin flag:=false; {writeln(i,' ===',j); } end;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-10;\n if (dmax(rr1,rr2)-min(rr1,rr2)-eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then begin flag:=false; {writeln(i,' ===',j); } end;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-10;\n if (dmax(rr1,rr2)-min(rr1,rr2)+eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then begin flag:=false; {writeln(i,' ===',j); } end;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n eps=0.000000001; nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-16;\n if (dmax(rr1,rr2)-min(rr1,rr2)) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then flag:=false;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\n\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :extended;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n function ainb(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=1e-15;\n if (d+rr1max(rr1,rr2)-min(rr1,rr2)+eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n }\n dd:=sqrt((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3]));\n { writeln(dd:0:4,' ',r[1]:0:4,' ',r[4]:0:4);\n writeln(ainb(dd,r[3],r[1]),' ',ainb(dd,r[1],r[4]),' ',perkr(dd,r[1],r[4])); }\n if not (ainb(dd,r[3],r[1]) and ainb(dd,r[1],r[4])) and not perkr(dd,r[1],r[3]) and not perkr(dd,r[1],r[4]) then inc(ot);\n if not (ainb(dd,r[3],r[2]) and ainb(dd,r[2],r[4])) and not perkr(dd,r[2],r[3]) and not perkr(dd,r[2],r[4]) then inc(ot);\n if not (ainb(dd,r[1],r[3]) and ainb(dd,r[3],r[2])) and not perkr(dd,r[1],r[3]) and not perkr(dd,r[2],r[3]) then inc(ot);\n if not (ainb(dd,r[1],r[4]) and ainb(dd,r[4],r[2])) and not perkr(dd,r[1],r[4]) and not perkr(dd,r[2],r[4]) then inc(ot);\n\n writeln(ot);\n\n 1: close(output);\nend.\n"}, {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nkor,bal,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\ncentr,aa,bb,cc,koef:int64; ch,ch1,ch2:char;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\nsum:array['a'..'z',0..500000] of int64;\nmarked:array[0..500] of boolean;\ngr:array['a'..'z','a'..'z'] of boolean;\ndd :double;\nnamemin:string;\nss:string;{array[0..1100000] of char;}\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n{ procedure DFS(vi: longint);\nvar i,j: longint;\nBegin\n\n marked[vi] := true;\n num[vi]:=p;\n For i := 1 to n do\n if gr[vi, i] and (not marked[i]) then begin dfs(i); p:=p+1; end;\n\n\nEnd; }\n\n function perkr(d,rr1,rr2:extended):boolean;\n var flag:boolean; eps:extended;\n begin\n eps:=0;\n if (dmax(rr1,rr2)-min(rr1,rr2)-eps) then flag:=true else flag:=false;\n\n perkr:=flag;\n end;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}\n read(x[1],y[1],r[1],r[2]);\n read(x[3],y[3],r[3],r[4]);\n x[2]:=x[1];y[2]:=y[1];\n x[4]:=x[3];y[4]:=y[3];\n { for i:=1 to 4 do writeln(x[i]:0:3,' ',y[i]:0:3,' ',r[i]:0:3);\n } for i:=1 to 4 do\n begin\n flag:=true;\n for j:=1 to 4 do if i<>j then\n begin\n dd:=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));\n if perkr(dd,r[i],r[j]) then begin flag:=false; {writeln(i,' ===',j); } end;\n end;\n { writeln(i,' ',flag); }\n if flag then inc(ot);\n end;\n\n\n\n writeln(ot);\n 1: close(output);\nend.\n"}, {"source_code": "Uses Math;\nType tm=Array [1..4] of LongInt;\n tf=Array [1..4] of Boolean;\nVar x,y,r:tm;\n m:tf;\n kol,a,b,c,d,i:LongInt;\n \nFunction Prov (x1,y1,r1,x2,y2,r2:LongInt):Boolean;\nVar r:Real;\nBegin\n r:=sqrt (sqr (x1-x2)+sqr(y1-y2));\n If r>=r1+r2\n then Result:=True\n else If r+Min (r1,r2)<=Max (r1,r2)\n then Result:=True\n else Result:=False;\nEnd;\n\nFunction Inn (k,i,j:LongInt):Boolean;\nVar rr:Real;\nBegin\n rr:=sqrt (sqr (x[k]-x[i]-r[k])+sqr(y[k]-y[i]));\n If (r[j]>rr) and (r[i]=r1+r2\n then Result:=True\n else If r+Min (r1,r2)<=Max (r1,r2)\n then Result:=True\n else Result:=False;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n // Assign (output,'output.txt'); ReWrite (output);\n Readln (a,b,c,d); x[1]:=a; x[2]:=a; y[1]:=b; y[2]:=b; r[1]:=c; r[2]:=d;\n Readln (a,b,c,d); x[3]:=a; x[4]:=a; y[3]:=b; y[4]:=b; r[3]:=c; r[4]:=d;\n kol:=0;\n If Prov (x[1],y[1],r[1],x[3],y[3],r[3]) and Prov (x[1],y[1],r[1],x[4],y[4],r[4]) then Inc (kol);\n If Prov (x[2],y[2],r[2],x[3],y[3],r[3]) and Prov (x[2],y[2],r[2],x[4],y[4],r[4]) then Inc (kol);\n If Prov (x[3],y[3],r[3],x[1],y[1],r[1]) and Prov (x[3],y[3],r[3],x[2],y[2],r[2]) then Inc (kol);\n If Prov (x[4],y[4],r[4],x[1],y[1],r[1]) and Prov (x[4],y[4],r[4],x[2],y[2],r[2]) then Inc (kol);\n Writeln (kol);\nEnd."}, {"source_code": "Uses Math;\nType tm=Array [1..4] of LongInt;\n tf=Array [1..4] of Boolean;\nVar x,y,r:tm;\n m:tf;\n kol,a,b,c,d,i:LongInt;\n \nFunction Prov (x1,y1,r1,x2,y2,r2:LongInt):Boolean;\nVar r:Real;\nBegin\n r:=sqrt (sqr (x1-x2)+sqr(y1-y2));\n If r>=r1+r2\n then Result:=True\n else If r+Min (r1,r2)<=Max (r1,r2)\n then Result:=True\n else Result:=False;\nEnd;\n\nFunction Inn (k,i,j:LongInt):Boolean;\nVar r1,r2:Real;\nBegin\n r1:=sqrt (sqr (x[k]-x[i]-r[k])+sqr(y[k]-y[i]));\n r2:=sqrt (sqr (x[k]-x[i]+r[k])+sqr(y[k]-y[i]));\n If (r[j]>r1) and (r[i]r2) and (r[i] c) then\n if (a + c > b) then\n if (c + b > a) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n\n"}, {"source_code": "program Timur;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n p, s, b: integer;\n\nfunction trig(a, b, c: real): boolean;\nbegin\n Result := false;\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n p := i div 3;\n s := 1;\n b := 2;\n if p = 0 then\n begin\n s := 3;\n b := 4;\n end;\n if (r[s] * 1.0 + 0.0000000001 < sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]))) then\n if r[b] * 1.0 + 0.0000000001 > sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])) then\n f := 1;\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "program Timur;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n\nfunction trig(a, b, c: real): boolean;\nbegin\n Result := false;\n if (a + b >= c) then\n if (a + c >= b) then\n if (c + b >= a) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n\n"}, {"source_code": "program Timur;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n p, s, b: integer;\n\nfunction trig(a, b, c: real): boolean;\nbegin\n Result := false;\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n p := i div 3;\n s := 1;\n b := 2;\n if p = 0 then\n begin\n s := 3;\n b := 4;\n end;\n if (r[s] * 1.0 + 0.0000000001 < sqrt(sqr(x[i] - x[s]) + sqr(y[i] - y[s]))) then\n if r[b] * 1.0 + 0.0000000001 > sqrt(sqr(x[i] - x[s]) + sqr(y[i] - y[s])) then\n f := 1;\n\n if sqr(x[i] + r[i] - x[s]) + sqr(y[i]- y[s]) >= r[s] * r[s] * 1.0 + 0.000000001 then\n if sqr(x[i] + r[i] - x[b]) + sqr(y[i]- y[b]) <= r[b] * r[b] * 1.0 - 0.000000001 then\n inc(f);\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "program Timur;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n\nfunction trig(a, b, c: real): boolean;\nbegin\n Result := false;\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "program Timur;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n p, s, b: integer;\n\nfunction trig(a, b, c: real): boolean;\nbegin\n Result := false;\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1]; y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3]; y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n for j := 1 to 4 do\n if i <> j then\n begin\n if trig(sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])), r[i] * 1.0, 1.0 * r[j]) then\n inc(f);\n end;\n p := i div 3;\n s := 1;\n b := 2;\n if p = 0 then\n begin\n s := 3;\n b := 4;\n end;\n if (r[s]* r[s] * 1.0 + 0.0000000001 < sqrt(sqr(x[i] - x[s]) + sqr(y[i] - y[s]))) then\n if r[b] * r[b] * 1.0 + 0.0000000001 > sqrt(sqr(x[i] - x[s]) + sqr(y[i] - y[s])) then\n f := 1;\n\n if sqr(x[i] + r[i] - x[s]) + sqr(y[i]- y[s]) >= r[s] * r[s] * 1.0 + 0.000000001 then\n if sqr(x[i] + r[i] - x[b]) + sqr(y[i]- y[b]) <= r[b] * r[b] * 1.0 - 0.000000001 then\n inc(f);\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n x, y, r: array [1..4] of integer;\n i, a, j, f: integer;\n p, s, b: integer;\n\nfunction Peres(u, v: integer): boolean;\nvar\n a, b, c: real;\nbegin\n Result := false;\n a := r[u];\n b := r[v];\n c := sqrt(sqr(x[u] - x[v]) + sqr(y[u] - y[v]));\n\n if (a + b > c + 0.0000000001) then\n if (a + c > b + 0.0000000001) then\n if (c + b > a + 0.0000000001) then\n Result := true;\nend;\n\nFunction into(u, v: integer): boolean;\nvar\n a, b, c: real;\nbegin\n Result := false;\n a := r[u];\n b := r[v];\n c := sqrt(sqr(x[u] - x[v]) + sqr(y[u] - y[v]));\n\n if (a > c + b + 0.0000000001) then\n Result := true;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(x[1], y[1], r[1], r[2]);\n x[2] := x[1];\n y[2] := y[1];\n read(x[3], y[3], r[3], r[4]);\n x[4] := x[3];\n y[4] := y[3];\n a := 0;\n for i := 1 to 4 do\n begin\n f := 0;\n p := i div 3;\n s := 1;\n b := 2;\n if p = 0 then\n begin\n s := 3;\n b := 4;\n end;\n\n if i mod 2 = 1 then\n begin\n if Peres(i, s) or into(i, b) or peres(i, b) then\n f := 1;\n end\n else\n begin\n if into(i, b) or peres(i, b) or peres(i, s) then\n f := 1;\n end;\n\n if f = 0 then\n inc(a);\n end;\n write(a);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\nmaxn = 2222;\ntype\ncircle=record\n x,y,r : integer;\n end;\nvar\nx,y,r,rr,i,j,ans : integer;\nok : boolean;\nc : array [1..4] of circle;\n\nfunction cross (a,b : integer) : boolean;\nbegin\n if sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y)>=sqr(c [a].r+c [b].r) then\n begin\n cross:=false;\n exit;\n end;\n if sqr(max (c [a].r,c [b].r)-min (c [a].r,c [b].r))>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n cross:=false;\n exit;\n end;\n cross:=true;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n readln (x,y,r,rr);\n c [1].x:=x; c [2].x:=x;\n c [1].y:=y; c [2].y:=y;\n c [1].r:=r; c [2].r:=rr;\n readln (x,y,r,rr);\n c [3].x:=x; c [4].x:=x;\n c [3].y:=y; c [4].y:=y;\n c [3].r:=r; c [4].r:=rr;\n\n ans:=0;\n for i:=1 to 4 do\n begin\n ok:=true;\n for j:=1 to 4 do\n if i<>j then\n if cross (i,j) then\n begin\n ok:=false;\n break;\n end;\n if ok then inc (ans);\n end;\n writeln (ans);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\nmaxn = 2222;\ntype\ncircle=record\n x,y,r : integer;\n end;\nvar\nx,y,r,rr,ans : integer;\nc : array [1..4] of circle;\n\nfunction cross (a,b : integer) : boolean;\nbegin\n if sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y)>=sqr(c [a].r+c [b].r) then\n begin\n cross:=false;\n exit;\n end;\n if sqr(max (c [a].r,c [b].r)-min (c [a].r,c [b].r))>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n cross:=false;\n exit;\n end;\n cross:=true;\nend;\n\nfunction into (a,b : integer) : boolean;\nbegin\n if c [b].r-c [a].r<=0 then\n begin\n into:=false;\n exit;\n end;\n if sqr(c [b].r-c [a].r)>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n into:=true;\n exit;\n end;\n into:=false;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n readln (x,y,r,rr);\n c [1].x:=x; c [2].x:=x;\n c [1].y:=y; c [2].y:=y;\n c [1].r:=r; c [2].r:=rr;\n readln (x,y,r,rr);\n c [3].x:=x; c [4].x:=x;\n c [3].y:=y; c [4].y:=y;\n c [3].r:=r; c [4].r:=rr;\n\n ans:=0;\n if not cross (1,3) and not cross (1,4) and not (into (1,4) and into (3,1)) then inc (ans);\n if not cross (2,3) and not cross (2,4) and not (into (2,4) and into (3,2)) then inc (ans);\n if not cross (3,1) and not cross (3,2) and not (into (3,2) and into (1,3)) then inc (ans);\n if not cross (4,1) and not cross (4,2) and not (into (4,2) and into (1,4)) then inc (ans);\n writeln (ans);\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 64000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\nmaxn = 2222;\ntype\ncircle=record\n x,y,r : integer;\n end;\nvar\nx,y,r,rr,i,j,ans : integer;\nok : boolean;\nc : array [1..4] of circle;\n\nfunction cross (a,b : integer) : boolean;\nbegin\n if sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y)>sqr(c [a].r+c [b].r) then\n begin\n cross:=false;\n exit;\n end;\n if sqr(max (c [a].r,c [b].r)-min (c [a].r,c [b].r))>=sqr(c [a].x-c [b].x)+sqr(c [a].y-c [b].y) then\n begin\n cross:=false;\n exit;\n end;\n cross:=true;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n readln (x,y,r,rr);\n c [1].x:=x; c [2].x:=x;\n c [1].y:=y; c [2].y:=y;\n c [1].r:=r; c [2].r:=rr;\n readln (x,y,r,rr);\n c [3].x:=x; c [4].x:=x;\n c [3].y:=y; c [4].y:=y;\n c [3].r:=r; c [4].r:=rr;\n\n ans:=0;\n for i:=1 to 4 do\n begin\n ok:=true;\n for j:=1 to 4 do\n if i<>j then\n if cross (i,j) then\n begin\n ok:=false;\n break;\n end;\n if ok then inc (ans);\n end;\n writeln (ans);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\n{function gcd(a,b:integer):integer;\nbegin\nif b=0 then gcd:=a\n else gcd:=gcd(b,a mod b);\nend;\nfor k:=1 to n-1 do\n for i:=1 to n-k do\n if a[i]>a[i+1] then begin t:=a[i]; a[i]:=a[i+1]; a[i+1]:=t; end;}\n\nvar x1,y1,x2,y2,r1,r2,rt1,rt2,ans:integer;\n dist:real;\n\nbegin\nreadln(x1,y1,r1,rt1);\nreadln(x2,y2,r2,rt2);\ndist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n ans:=0;\nif (dist+rt1<=r2) or (dist+rt2<=r1) or (r1+rt2<=dist) then inc(ans);\nif (dist+r2<=r1) or (dist+rt1<=r2) or (r2+rt1<=dist) then inc(ans);\nif (rt1>=dist+rt2) or (rt1+rt2<=dist) or (dist+rt1<=r2) then inc(ans);\nif (rt2>=dist+rt1) or (rt1+rt2<=dist) or (dist+rt2<=r1) then inc(ans);\nwrite(ans);\nreadln;\nend."}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,shk1,shk2:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n end; \n shk1:=r2-r1;\n shk2:=r4-r3;\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if shk1>=cr then begin\n if (r1<=(r3+cr)) and ((r3+cr)<=r2) and (r3>r1) then begin\n o3:=0;\n end;\n if (r1<=(r4+cr)) and ((r4+cr)<=r2) and (r4>r1) then begin\n o4:=0;\n end;\n end;\n if shk2>=cr then begin\n if (r3<=(r1+cr)) and ((r1+cr)<=r4) and (r1>r3) then begin\n o1:=0;\n end;\n if (r3<=(r2+cr)) and ((r2+cr)<=r4) and (r1>r3) then begin\n o2:=0;\n end;\n end;\n \n writeln(o1+o2+o3+o4);\n (*writeln(o1,o2,o3,o4);*)\nend."}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4:longint;\n o1,o2,o3,o4:integer;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n end; \n writeln(o1+o2+o3+o4);\nend.\n"}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,shk1,shk2:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n end; \n shk1:=r2-r1;\n shk2:=r4-r3;\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if shk1>=cr then begin\n if (r1<=(r3+cr)) and ((r3+cr)<=r2) and (r3>r1) then begin\n o3:=0;\n end;\n if (r1<=(r4+cr)) and ((r4+cr)<=r2) and (r4>r1) then begin\n o4:=0;\n end;\n end;\n if shk2>=cr then begin\n if (r3<=(r1+cr)) and ((r1+cr)<=r4) and (r1>r3) then begin\n o1:=0;\n end;\n if (r3<=(r2+cr)) and ((r2+cr)<=r4) and (r2>r3) then begin\n o2:=0;\n end;\n end;\n \n writeln(o1+o2+o3+o4);\n (*writeln(o1,o2,o3,o4);*)\nend."}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,shk1,shk2:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n (*writeln('t1');*)\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n (*writeln('t2');*)\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n (*writeln('t3');*)\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n (*writeln('t4');*)\n end; \n shk1:=r2-r1;\n shk2:=r4-r3;\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if shk1>=cr then begin\n if (r1<=(r3+cr)) and ((r3+cr)<=r2) then begin\n o3:=0;\n (*writeln('tnd1');*)\n end;\n if (r1<=(r4+cr)) and ((r4+cr)<=r2) then begin\n o4:=0;\n (*writeln('tnd2');*)\n end;\n end;\n if shk2>=cr then begin\n if (r3<=(r1+cr)) and ((r1+cr)<=r4) then begin\n o1:=0;\n (*writeln('tnd3');*)\n end;\n if (r3<=(r2+cr)) and ((r2+cr)<=r4) then begin\n o2:=0;\n (*writeln('tnd4');*)\n end;\n end;\n \n writeln(o1+o2+o3+o4);\n (*writeln(o1,o2,o3,o4);*)\nend."}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,shk1,shk2:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n end; \n shk1:=r2-r1;\n shk2:=r4-r3;\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if shk1>=cr then begin\n if (r1<=(r3+cr)) and ((r3+cr)<=r2) and ((r3>r1) or (cr>r1)) then begin\n o3:=0;\n end;\n if (r1<=(r4+cr)) and ((r4+cr)<=r2) and ((r4>r1) or (cr>r1)) then begin\n o4:=0;\n end;\n end;\n if shk2>=cr then begin\n if (r3<=(r1+cr)) and ((r1+cr)<=r4) and ((r1>r3) or (cr>r3)) then begin\n o1:=0;\n end;\n if (r3<=(r2+cr)) and ((r2+cr)<=r4) and ((r2>r3) or (cr>r3)) then begin\n o2:=0;\n end;\n end;\n \n writeln(o1+o2+o3+o4);\n (*writeln(o1,o2,o3,o4);*)\nend.\n"}, {"source_code": "program ann;\nvar x1,y1,x2,y2,r1,r2,r3,r4,shk1,shk2:longint;\n o1,o2,o3,o4:integer;\n cr:real;\nfunction per (x1,y1,x2,y2,r1,r2:longint):byte;\nvar cr:real;\n buf:longint;\nbegin\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if r1r1) then per:=0\n else if (cr>=r1) and ((r1+r2)>cr) then per:=0\n else per:=1;\nend;\n\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n o1:=1; o2:=1; o3:=1; o4:=1;\n if per (x1,y1,x2,y2,r1,r3)=0 then begin\n o1:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r1,r4)=0 then begin\n o1:=0;\n o4:=0;\n end; \n if per (x1,y1,x2,y2,r2,r3)=0 then begin\n o2:=0;\n o3:=0;\n end; \n if per (x1,y1,x2,y2,r2,r4)=0 then begin\n o2:=0;\n o4:=0;\n end; \n shk1:=r2-r1;\n shk2:=r4-r3;\n cr:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if shk1>=cr then begin\n if (r1<(r3+cr)) and ((r3+cr)=cr then begin\n if (r3<(r1+cr)) and ((r1+cr)=sqr(r1+r2) then ask:=0;\n\nif sqr(x1-x2)+sqr(y1-y2)<=sqr(r1-r2) then ask:=0;\n\nend;\n\n\n\nBegin\n\nReadln(x1,y1,r1,rr1);\nReadln(x2,y2,r2,rr2); k1:=0; k2:=0; k3:=0; k4:=0;\n\nkil:=4;\n\nif (x1=y1)and(x2=y2) then begin\n\nif (r1=r2)or(r1=rr2) then dec(kil);\nif (rr1=r2)or(rr1=rr2) then dec(kil); end;\n\nif kil<4 then begin Writeln(2); halt; end;\n\nif ask(x1,y1,r1,x2,y2,r2)+ask(x1,y1,r1,x2,y2,rr2)=0 then k1:=1;\nif ask(x1,y1,rr1,x2,y2,r2)+ask(x1,y1,rr1,x2,y2,rr2)=0 then k2:=1;\nif ask(x2,y2,r2,x1,y1,r1)+ask(x2,y2,r2,x1,y1,rr1)=0 then k3:=1;\nif ask(x2,y2,rr2,x1,y1,r1)+ask(x2,y2,rr2,x1,y1,rr1)=0 then k4:=1;\n\n\n\n\nif (x1=x2)and(y1=y2)and(r1=r2) then if k1+k3=2 then k1:=0;\nif (x1=x2)and(y1=y2)and(r1=rr2) then if k1+k4=2 then k1:=0;\nif (x1=x2)and(y1=y2)and(rr1=r2) then if k2+k3=2 then k2:=0;\nif (x1=x2)and(y1=y2)and(rr1=rr2) then if k2+k4=2 then k2:=0;\n\nWriteln(k1+k2+k3+k4);\n\nENd.\n\n\n\n"}, {"source_code": "uses math;\n\nVar x1,y1,x2,y2,r1,rr1,r2,rr2:longint;\n k1,k2,k3,k4:longint;\n\nFunction ask(x1,y1,r1,x2,y2,r2:longint):longint;\n\nBegin\n\nask:=1;\n\nif sqr(x1-x2)+sqr(y1-y2)>=sqr(r1+r2) then ask:=0;\n\nif sqr(x1-x2)+sqr(y1-y2)<=sqr(abs(r1-r2)) then ask:=0;\n\n\nend;\n\nBegin\n\nReadln(x1,y1,r1,rr1);\nReadln(x2,y2,r2,rr2); k1:=0; k2:=0; k3:=0; k4:=0;\n\nif ask(x1,y1,r1,x2,y2,r2)+ask(x1,y1,r1,x2,y2,rr2)=0 then k1:=1;\nif ask(x1,y1,rr1,x2,y2,r2)+ask(x1,y1,rr1,x2,y2,rr2)=0 then k2:=1;\nif ask(x2,y2,r2,x1,y1,r1)+ask(x2,y2,r2,x1,y1,rr1)=0 then k3:=1;\nif ask(x2,y2,rr2,x1,y1,r1)+ask(x2,y2,rr2,x1,y1,rr1)=0 then k4:=1;\n\nif (x1=x2)and(y1=y2)and(r1=r2) then if k1+k3=2 then k1:=0;\nif (x1=x2)and(y1=y2)and(r1=rr2) then if k1+k4=2 then k1:=0;\nif (x1=x2)and(y1=y2)and(rr1=r2) then if k2+k3=2 then k2:=0;\nif (x1=x2)and(y1=y2)and(rr1=rr2) then if k2+k4=2 then k2:=0;\n\nWriteln(k1+k2+k3+k4);\n\nENd.\n\n\n\n"}, {"source_code": "// buneng CE!\nvar\n len,x1,y1,x2,y2:double;\n r1,r11,r2,r22:longint;\n ans:longint;\n b:array[0..100]of longint;\n\nbegin\n\n readln(x1,y1,r1,r11);\n readln(x2,y2,r2,r22);\n fillchar(b,sizeof(b),0);\n len:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n ans:=0;\n if (len-r1)>0 then\n begin\n if ((len-r1)>=r22)or((len+r1)<=r2)and(b[r1]=0) then\n begin\n inc(ans);\n b[r1]:=1;\n end;\n end\n else\n begin\n if (r22<=(r1-len))or((len+r1)<=r2)and(b[r1]=0) then\n begin\n inc(ans);\n b[r1]:=1;\n end;\n end;\n if (len-r11)>0 then\n begin\n if ((len-r11)>=r22)or((len+r11)<=r2)and(b[r11]=0) then\n begin\n inc(ans);\n b[r11]:=1;\n end;\n end\n else\n begin\n if (r22<=(r11-len))or((len+r11)<=r2)and(b[r11]=0) then\n begin\n inc(ans);\n b[r11]:=1;\n end;\n end;\n if (len-r2)>0 then\n begin\n if ((len-r2)>=r11)or((len+r2)<=r1)and(b[r2]=0) then\n begin\n inc(ans);\n b[r2]:=1;\n end;\n end\n else\n begin\n if (r11<=(r2-len))or((len+r2)<=r1)and(b[r2]=0) then\n begin\n inc(ans);\n b[r2]:=1;\n end;\n end;\n if (len-r22)>0 then\n begin\n if ((len-r22)>=r11)or((len+r22)<=r1)and(b[r22]=0) then\n begin\n inc(ans);\n b[r22]:=1;\n end;\n end\n else\n begin\n if (r11<=(r2-len))or((len+r22)<=r1)and(b[r22]=0) then\n begin\n inc(ans);\n b[r22]:=1;\n end;\n end;\n writeln(ans);\n\nend.\n"}, {"source_code": "// buneng CE!\nvar\n len,x1,y1,x2,y2,r1,r11,r2,r22:double;\n ans:longint;\n\nbegin\n\n readln(x1,y1,r1,r11);\n readln(x2,y2,r2,r22);\n len:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n ans:=0;\n if (len-r1)>0 then\n begin\n if ((len-r1)>=r22)or((len+r1)<=r2) then inc(ans);\n end\n else\n begin\n if (r22<=(r1-len))or((len+r1)<=r2) then inc(ans);\n end;\n if (len-r11)>0 then\n begin\n if ((len-r11)>=r22)or((len+r11)<=r2) then inc(ans);\n end\n else\n begin\n if (r22<=(r11-len))or((len+r11)<=r2) then inc(ans);\n end;\n if (len-r2)>0 then\n begin\n if ((len-r2)>=r11)or((len+r2)<=r1) then inc(ans);\n end\n else\n begin\n if (r11<=(r2-len))or((len+r2)<=r1) then inc(ans);\n end;\n if (len-r22)>0 then\n begin\n if ((len-r22)>=r11)or((len+r22)<=r1) then inc(ans);\n end\n else\n begin\n if (r11<=(r2-len))or((len+r22)<=r1) then inc(ans);\n end;\n writeln(ans);\n\nend.\n"}, {"source_code": "program cf199B;\nuses math;\nvar i,j,br:longint;\n x,y,r:array[0..10] of longint;\n isecen:array[0..10] of boolean;\n rij:real;\n moze:boolean;\nfunction rastojanje(i,j:longint):real;\n begin\n rastojanje:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]));\n end;\nbegin\nread(x[1],y[1],r[1],r[2]);\nx[2]:=x[1];\ny[2]:=y[1];\nread(x[3],y[3],r[3],r[4]);\nx[4]:=x[3];\ny[4]:=y[3];\n\nbr:=0;\n\nfor i:=1 to 4 do\nbegin\nmoze:=true;\nfor j:=1 to 4 do\n begin\n if (i=j) or (isecen[i]) or (isecen[j]) then continue;\n rij:=rastojanje(i,j);\n if rij=0 then continue;\n if rij>=r[i]+r[j] then\n begin\n end\n else\n if rij+min(r[i],r[j])<=max(r[i],r[j]) then\n begin\n end\n else\n moze:=false;\n end;\nif moze then\n begin\n isecen[i]:=true;\n inc(br);\n end;\nend;\nwriteln(br);\n\nend."}, {"source_code": "var\n x1,x2,y1,y2,p1,q1,p2,q2,ans:longint;\n d:real;\n s1,s2,s3,s4:boolean;\nbegin\n readln(x1,y1,p1,q1);\n readln(x2,y2,p2,q2);\n ans:=0;\n d:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n s1:=false; s2:=false; s3:=false; s4:=false;\n if (d>=p1+p2)or(d<=abs(p1-p2)) then s1:=true;\n if (d>=p1+q2)or(d<=abs(p1-q2)) then s2:=true;\n if (d>=q1+p2)or(d<=abs(q1-p2)) then s3:=true;\n if (d>=q1+q2)or(d<=abs(q1-q2)) then s4:=true;\n if s1 and s2 then inc(ans);\n if s3 and s4 then inc(ans);\n if s1 and s3 then inc(ans);\n if s2 and s4 then inc(ans);\n writeln(ans);\nend."}, {"source_code": "var\n x1,x2,y1,y2,p1,q1,p2,q2,ans:longint;\n d:real;\n s1,s2,s3,s4:boolean;\nbegin\n readln(x1,y1,p1,q1);\n readln(x2,y2,p2,q2);\n ans:=0;\n d:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n s1:=false; s2:=false; s3:=false; s4:=false;\n if ((d>=p1+p2)and(d>=p1+q2))or((d<=p1-p2)and(d<=p1-q2))or((d<=p2-p1)and(d<=q2-p1))then inc(ans);\n if ((d>=q1+p2)and(d>=q1+q2))or((d<=q1-p2)and(d<=q1-q2))or((d<=q2-p1)and(d<=q2-p1))then inc(ans);\n if ((d>=p1+p2)and(d>=q1+p2))or((d<=p1-p2)and(d<=q1-p2))or((d<=p2-p1)and(d<=p2-q1))then inc(ans);\n if ((d>=p1+q2)and(d>=q1+q2))or((d<=p1-q2)and(d<=q1-q2))or((d<=q2-p1)and(d<=q2-q1))then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "program problemB;\nvar\n ans,i,j:longint;\n x,y:array[1..2]of longint;\n r:array[1..2,1..2]of longint;\n\nfunction minn(a,b:longint):longint;\nbegin\n if a=sqr(r[3-p,2]+r[p,1]) then exit(true);\n if dist<=minn(sqr(r[3-p,2]-r[p,1]),sqr(r[3-p,1]-r[p,1])) then exit(true);\n exit(false);\nend;\n\nfunction check2(p:longint):boolean;\nvar\n dist:longint;\nbegin\n dist:=sqr(x[1]-x[2])+sqr(y[1]-y[2]);\n if dist>=sqr(r[3-p,2]+r[p,2]) then exit(true);\n if dist<=minn(sqr(r[3-p,2]-r[p,2]),sqr(r[3-p,1]-r[p,2])) then exit(true);\n exit(false);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'B.in');\n reset(input);\n assign(output,'B.out');\n rewrite(output);\n{$endif}\n\n readln(x[1],y[1],r[1,1],r[1,2]);\n readln(x[2],y[2],r[2,1],r[2,2]);\n\n ans:=0;\n if check1(1) then inc(ans);\n if check2(1) then inc(ans);\n if check1(2) then inc(ans);\n if check2(2) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "program problemB;\nvar\n dist:double;\n ans,i,j,x1,y1,x2,y2,r11,r12,r21,r22:longint;\n\nfunction check(x1,y1,r1,x2,y2,r2:longint):boolean;\nbegin\n dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));\n if dist>=r1+r2 then exit(true);\n if dist<=abs(r1-r2) then exit(true);\n exit(false);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'B.in');\n reset(input);\n assign(output,'B.out');\n rewrite(output);\n{$endif}\n\n readln(x1,y1,r11,r12);\n readln(x2,y2,r21,r22);\n\n ans:=0;\n if check(x1,y1,r11,x2,y2,r21) and check(x1,y1,r11,x2,y2,r22) then inc(ans);\n if check(x1,y1,r12,x2,y2,r21) and check(x1,y1,r12,x2,y2,r22) then inc(ans);\n if check(x2,y2,r21,x1,y1,r11) and check(x2,y2,r21,x1,y1,r12) then inc(ans);\n if check(x2,y2,r22,x1,y1,r11) and check(x2,y2,r22,x1,y1,r12) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "program problemB;\nvar\n ans,i,j:longint;\n x,y:array[1..2]of longint;\n r:array[1..2,1..2]of longint;\n\nfunction minn(a,b:longint):longint;\nbegin\n if a=sqr(r[3-p,2]+r[p,1]) then exit(true);\n if (r[3-p,1]>r[p,1])and(dist<=sqr(r[3-p,1]-r[p,1])) then exit(true);\n exit(false);\nend;\n\nfunction check2(p:longint):boolean;\nvar\n dist:longint;\nbegin\n dist:=sqr(x[1]-x[2])+sqr(y[1]-y[2]);\n if dist>=sqr(r[3-p,2]+r[p,2]) then exit(true);\n if (r[3-p,1]>r[p,2])and(dist<=sqr(r[3-p,1]-r[p,2])) then exit(true);\n exit(false);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'B.in');\n reset(input);\n assign(output,'B.out');\n rewrite(output);\n{$endif}\n\n readln(x[1],y[1],r[1,1],r[1,2]);\n readln(x[2],y[2],r[2,1],r[2,2]);\n\n ans:=0;\n if check1(1) then inc(ans);\n if check2(1) then inc(ans);\n if check1(2) then inc(ans);\n if check2(2) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "program problemB;\nvar\n ans,i,j,x1,y1,x2,y2,dist:longint;\n r11,r12,r21,r22:longint;\n\nfunction check(x1,y1,r1,x2,y2,r2:longint):boolean;\nbegin\n dist:=sqr(x1-x2)+sqr(y1-y2);\n if dist-sqr(r1+r2)>=0 then exit(true);\n if sqr(r1-r2)-dist>=0 then exit(true);\n exit(false);\nend;\n\nbegin\n{$ifndef ONLINE_JUDGE}\n assign(input,'B.in');\n reset(input);\n assign(output,'B.out');\n rewrite(output);\n{$endif}\n\n readln(x1,y1,r11,r12);\n readln(x2,y2,r21,r22);\n\n ans:=0;\n if check(x1,y1,r11,x2,y2,r21) and check(x1,y1,r11,x2,y2,r22) then inc(ans);\n if check(x1,y1,r12,x2,y2,r21) and check(x1,y1,r12,x2,y2,r22) then inc(ans);\n if check(x2,y2,r21,x1,y1,r11) and check(x2,y2,r21,x1,y1,r12) then inc(ans);\n if check(x2,y2,r22,x1,y1,r11) and check(x2,y2,r22,x1,y1,r12) then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n x,y,r:array[0..500]of longint;\n i,j,res:longint;\n \n function cross(x1,y1,r1,x2,y2,r2:longint):boolean;\n begin\n if ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)>=(r1+r2)*(r1+r2))then begin\n cross:=false;\n exit;\n end;\n if ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=(r1-r2)*(r1-r2))then begin\n cross:=false;\n exit;\n end;\n cross:=true;\n end;\n\nbegin\n read(x[1],y[1],r[1],r[2]);\n x[2]:=x[1];y[2]:=y[1];\n read(x[3],y[3],r[3],r[4]);\n x[4]:=x[3];y[4]:=y[3];\n res:=0;\n for i:=1 to 4 do begin\n inc(res);\n for j:=1 to 4 do\n if (cross(x[i],y[i],r[i],x[j],y[j],r[j]))then begin\n dec(res);\n break;\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "const maxn=5;\ntype cir = record\nx,y,r:longint;\nend;\n\nvar f1,f2:text;\nA:array[1..maxn] of cir;\nx1,y1,r1,r2,i,j:longint;\nres:longint;\nd:double;\nok:boolean;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,x1,y1,r1,r2);\n A[1].x:=x1;a[1].y:=y1;a[1].r:=r1;\n A[2].x:=x1;a[2].y:=y1;a[2].r:=r2;\n readln(f1,x1,y1,r1,r2);\n A[3].x:=x1;a[3].y:=y1;a[3].r:=r1;\n A[4].x:=x1;a[4].y:=y1;a[4].r:=r2;\n For i:=1 to 4 do\n Begin\n ok:=true;\n for j:=1 to 4 do\n if i<>j then\n begin\n d:=sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x);\n if sqr(a[i].r+a[j].r)<=d then else\n if sqr(ABS(a[i].r-a[j].r))>=d then else\n ok:=false;\n end;\n if ok then inc(res);\n End;\n writeln(f2,res);\n close(f1);\n close(f2);\nend."}, {"source_code": "const maxn=5;\ntype cir = record\nx,y,r:longint;\nend;\n\nvar f1,f2:text;\nA:array[1..maxn] of cir;\nC:array[1..maxn] of longint;\nx1,y1,r1,r2,i,j:longint;\nres:longint;\nd:double;\nok:boolean;\nd1,d2:longint;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,x1,y1,r1,r2);\n A[1].x:=x1;a[1].y:=y1;a[1].r:=r1;\n A[2].x:=x1;a[2].y:=y1;a[2].r:=r2;\n readln(f1,x1,y1,r1,r2);\n A[3].x:=x1;a[3].y:=y1;a[3].r:=r1;\n A[4].x:=x1;a[4].y:=y1;a[4].r:=r2;\n For i:=1 to 2 do\n Begin\n ok:=true;\n for j:=3 to 4 do\n begin\n d:=sqrt(sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x));\n if a[i].r+a[j].r<=d then C[j]:=1 else\n if a[i].r-a[j].r>=d then C[j]:=1 else\n if a[i].r-a[j].r<=d then C[j]:=2 else\n ok:=false;\n end;\n if ok and (C[3]=C[4]) then inc(res);\n End;\n For i:=3 to 4 do\n Begin\n ok:=true;\n for j:=1 to 2 do\n begin\n d:=sqrt(sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x));\n if a[i].r+a[j].r<=d then C[j]:=1 else\n if a[i].r-a[j].r>=d then C[j]:=1 else\n if a[i].r-a[j].r<=d then C[j]:=2 else\n ok:=false;\n end;\n if ok and (C[1]=C[2]) then inc(res);\n End;\n writeln(f2,res);\n close(f1);\n close(f2);\nend.\n"}, {"source_code": "const maxn=5;\ntype cir = record\nx,y,r:longint;\nend;\n\nvar f1,f2:text;\nA:array[1..maxn] of cir;\nC:array[1..maxn] of longint;\nx1,y1,r1,r2,i,j:longint;\nres:longint;\nd:double;\nok:boolean;\nd1,d2:longint;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,x1,y1,r1,r2);\n A[1].x:=x1;a[1].y:=y1;a[1].r:=r1;\n A[2].x:=x1;a[2].y:=y1;a[2].r:=r2;\n readln(f1,x1,y1,r1,r2);\n A[3].x:=x1;a[3].y:=y1;a[3].r:=r1;\n A[4].x:=x1;a[4].y:=y1;a[4].r:=r2;\n For i:=1 to 2 do\n Begin\n ok:=true;\n for j:=3 to 4 do\n begin\n d:=sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x);\n if sqr(a[i].r+a[j].r)<=d then C[j]:=1 else\n if sqr(ABS(a[i].r-a[j].r))>=d then C[j]:=2 else\n ok:=false;\n end;\n if ok and (C[3]=C[4]) then inc(res);\n End;\n For i:=3 to 4 do\n Begin\n ok:=true;\n for j:=1 to 2 do\n begin\n d:=sqr(a[i].y-a[j].y)+sqr(a[i].x-a[j].x);\n if sqr(a[i].r+a[j].r)<=d then C[j]:=1 else\n if sqr(ABS(a[i].r-a[j].r))>=d then C[j]:=2 else\n ok:=false;\n end;\n if ok and (C[1]=C[2]) then inc(res);\n End;\n writeln(f2,res);\n close(f1);\n close(f2);\nend."}, {"source_code": "const fi='';\ntype hkr=record x,y,r:shortint end;\nvar a,b,c,d,kq:shortint;\n cir1,cir2,cir3,cir4:hkr;\n b1,b2,b3,b4:boolean;\n dis:real; f:text;\nfunction sth(a,b:hkr):shortint; //-1=in 0=inter 1=out 7=touch\nbegin\n if (abs(a.r-b.r)a.r+b.r then exit(1);\n if disa.r+b.r) or (dissqr(r1-r2));\n end;\nfunction init(x1,y1,r1,r2,x2,y2,r3:longint):boolean;\n var t:longint;\n begin\n t:=sqr(x1-x2)+sqr(y1-y2);\n init:=(r3*2<=abs(r1-r2)) and (t>sqr(r1)) and (tsqr(r1-r2));\n end;\nbegin\n readln(x1,y1,r1,r2);\n readln(x2,y2,r3,r4);\n ans:=0;\n if not jiao(x1,y1,r1,x2,y2,r3) and not jiao(x1,y1,r1,x2,y2,r4) then \n inc(ans);\n// writeln(ans);\n if not jiao(x1,y1,r2,x2,y2,r3) and not jiao(x1,y1,r2,x2,y2,r4) then \n inc(ans); \n// writeln(ans); \n if not jiao(x2,y2,r3,x1,y1,r1) and not jiao(x2,y2,r3,x1,y1,r2) then \n inc(ans);\n// writeln(ans);\n if not jiao(x2,y2,r4,x1,y1,r1) and not jiao(x2,y2,r4,x1,y1,r2) then \n inc(ans); \n// writeln(ans);\n writeln(ans);\nend."}, {"source_code": "const\n eps=0;\nvar\n x1,y1,a1,b1:longint;\n x2,y2,a2,b2:longint;\n len:extended;\n n:longint;\n\nbegin\n readln(x1,y1,a1,b1);\n readln(x2,y2,a2,b2);\n len:=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));\n if (x1=x2)and(y1=y2)and(a1=a2)and(b1=b2) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(a2=b1) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(b2=a1) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2) then begin\n if (b1=(x+z)*(x+z)) then begin\n k:=1;\n end;\n if ((x-y)*abs(x-y)<=ll)and(ll<=(x-y)*(x-y)) then begin\n k:=k+1;\n end;\n sum:=k;\n end;\n\nbegin\n readln(x1,y1,a1,b1);\n readln(x2,y2,a2,b2);\n len:=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);\n if (x1=x2)and(y1=y2)and(a1=a2)and(b1=b2) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(a2=b1) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(b2=a1) then begin\n writeln(2);exit;\n end;\n n:=0;\n n:=n+sum(a1,a2,b2,len);\n n:=n+sum(b1,a2,b2,len);\n n:=n+sum(a2,a1,b1,len);\n n:=n+sum(b2,a1,b1,len);\n writeln(n);\nend."}, {"source_code": "const\n eps=1e-9;\nvar\n x1,y1,a1,b1:longint;\n x2,y2,a2,b2:longint;\n len:longint;\n n:longint;\n\n function sum(x,y,z,ll:longint):longint;\n var k:longint;\n begin\n k:=0;\n if (((z-x)*abs(z-x)<=ll)and(ll<=(x-z)*abs(x-z)))or(len>=(x+z)*(x+z)) then begin\n k:=1;\n end;\n if ((x-y)*abs(x-y)<=ll)and(ll<=(x-y)*abs(x-y)) then begin\n k:=k+1;\n end;\n sum:=k;\n end;\n\nbegin\n readln(x1,y1,a1,b1);\n readln(x2,y2,a2,b2);\n len:=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);\n if (x1=x2)and(y1=y2)and(a1=a2)and(b1=b2) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(a2=b1) then begin\n writeln(2);exit;\n end;\n if (x1=x2)and(y1=y2)and(b2=a1) then begin\n writeln(2);exit;\n end;\n n:=0;\n n:=n+sum(a1,a2,b2,len);\n n:=n+sum(b1,a2,b2,len);\n n:=n+sum(a2,a1,b1,len);\n n:=n+sum(b2,a1,b1,len);\n writeln(n);\nend."}, {"source_code": "const\n eps=1e-9;\nvar\n x1,y1,a1,b1:longint;\n x2,y2,a2,b2:longint;\n len:longint;\n n:longint;\n\n function sum(x,y,z,ll:longint):longint;\n var k:longint;\n begin\n k:=0;\n if ((z-x)*abs(z-x)(x+z)*(x+z)) then begin\n k:=1;\n end;\n if ((x-y)*abs(x-y)r then exit(true) else exit(false);\n end;\n if d=r then exit(false);\n if r+r1abs(o.r-a.r))and(disabs(o.r-b.r))and(disa.r)and(diso.r+a.r)and(o.rabs(o.r-a.r))and(disabs(o.r-b.r))and(disa.r)and(disabs(o.r-a.r))and(disabs(o.r-b.r))and(dis=r1+r2)and(s>=r1+rr2)then inc(q);\n if (s<=abs(r1-r2))and(s<=abs(r1-rr2))then inc(q);\n\n if (s>=rr1+r2)and(s>=rr1+rr2)then inc(q);\n if (s<=abs(rr1-r2))and(s<=abs(rr1-rr2))then inc(q);\n\n if (s>=r2+r1)and(s>=r2+rr1)then inc(q);\n if (s<=abs(r2-r1))and(s<=abs(r2-rr1))then inc(q);\n\n if (s>=rr2+r1)and(s>=rr2+rr1)then inc(q);\n if (s<=abs(rr2-r1))and(s<=abs(rr2-rr1))then inc(q);\n\n if (r1>=s+r2)and(r1<=s+rr2)then dec(q);\n if (rr1>=s+r2)and(rr1<=s+rr2)then dec(q);\n if (r2>=s+r1)and(r2<=s+rr1)then dec(q);\n if (rr2>=s+r1)and(rr2<=s+rr1)then dec(q);\n writeln(q);\nend."}, {"source_code": "var x1,y1,r1,rr1,x2,y2,r2,rr2,q:longint;s:extended;\nbegin\n readln(x1,y1,r1,rr1);\n readln(x2,y2,r2,rr2);\n s:=sqrt(sqr(x1-x2)+sqr(y1-y2));q:=0;\n if (s>=r1+r2)and(s>=r1+rr2)then inc(q);\n if (s<=abs(r1-r2))and(s<=abs(r1-rr2))then inc(q);\n\n if (s>=rr1+r2)and(s>=rr1+rr2)then inc(q);\n if (s<=abs(rr1-r2))and(s<=abs(rr1-rr2))then inc(q);\n\n if (s>=r2+r1)and(s>=r2+rr1)then inc(q);\n if (s<=abs(r2-r1))and(s<=abs(r2-rr1))then inc(q);\n\n if (s>=rr2+r1)and(s>=rr2+rr1)then inc(q);\n if (s<=abs(rr2-r1))and(s<=abs(rr2-rr1))then inc(q);\n writeln(q);\nend."}, {"source_code": "program b;\nvar\n x1,x2,y1,y2,r1,r2,d1,d2:double;\n f1,f2,f3,f4:boolean;\n dist:double;\n tot:longint;\nprocedure work(a1,a2:double;var fa,fb:boolean);\n begin\n if a1a2)and(dista2)and(dista1)and(dista1)and(distr2)and(distr1)and(distr2)and(distr1)and(dista2)and(dista2)and(dista1)and(dista1)and(distr2)and(distr1+r2)and(distr2)and(distd1+r2)and(distr1)and(distr1+r2)and(distr1)and(distd2+r1)and(dist=a[i] do\n begin\n inc(t);\n ans[t]:=a[i];\n n:=n-a[i];\n end;\n if (t<=3){and(n1>=2)} then\n writeln(ans[1],' ',ans[2],' ',ans[3])\n else writeln('I',chr(39),'m too stupid to solve this problem');\n //close(input);\n //close(output);\nend."}, {"source_code": "program b;\nvar\n x1,x2,y1,y2,r1,r2,d1,d2:double;\n f1,f2,f3,f4:boolean;\n dist:double;\n tot:longint;\nprocedure work(a1,a2:double;var fa,fb:boolean);\n begin\n if a1a2)and(dista2)and(dista1)and(dista1)and(distr2)and(distr1+r2)and(distr1)and(distr1+r2)and(distr2)and(distd1+r2)and(distr1)and(distd2+r1)and(dista2)and(dista2)and(dista1)and(dista1)and(dist=r2)and(dist<=r1+d2)and(r1<=d2))or((dist>=r1+r2)and(dist<=r1+d2)) then f2:=false;\n if f1=true then\n if ((dist<=r2+d1)and(d1>=r2)and(dist<=d1+d2)and(d1<=d2))or((dist>=d1+r2)and(dist<=d1+d2)) then f1:=false;\n if f4=true then\n if ((dist<=r1+r2)and(r2>=r1)and(dist<=r2+d1)and(r2<=d1))or((dist>=r1+r2)and(dist<=r2+d1)) then f4:=false;\n if f3=true then\n if ((dist<=r1+d2)and(d2>=r1)and(dist<=d1+d2)and(d2<=d1))or((dist>=d2+r1)and(dist<=d2+d1)) then f3:=false;\n tot:=0;\n if f1=true then inc(tot);\n if f2=true then inc(tot);\n if f3=true then inc(tot);\n if f4=true then inc(tot);\n writeln(tot);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program b;\nvar\n x1,x2,y1,y2,r1,r2,d1,d2:double;\n f1,f2,f3,f4:boolean;\n dist:double;\n tot:longint;\nprocedure work(a1,a2:double;var fa,fb:boolean);\n begin\n if a1a2)and(dista2)and(dista1)and(dista1)and(distd2)and(distd1)and(dista2)and(dista2)and(dista1)and(dista1)and(distd) and (abs(r[i]-r[j])d) and (abs(r[i]-r[j])v then begin\n v:=y1+y2;\n minx1:=y1;\n minx2:=y2;\n end;\n end; }\n // m:=(l+r) div 2;\n if (i<>0) or (y2<>0) then\n t3:=((t1*i)+(t2*y2))/(i+y2)\n else\n t3:=maxlongint;\n { if t31) do\n begin\n m:=(l+r) div 2;\n if fun(i,m)>t0 then r:=m else l:=m;\n end;\n if (fun(i,l)>=t0) and (fun(i,r)>=t0) then\n begin\n c1:=abs(fun(i,l)-t0); c2:=abs(fun(i,r)-t0);\n if (c1>=c2)\n then begin j:=r; raz:=fun(i,r); end\n else begin j:=l; raz:=fun(i,l); end;\n end\n else\n begin\n if fun(i,l)>=t0 then begin j:=l; raz:=fun(i,l); end else\n if fun(i,r)>=t0 then begin j:=r; raz:=fun(i,r); end else j:=-1;\n end;\n\nend;\n\n\nbegin\n\n readln(t1,t2,x1,x2,t0); ans:=1e18; i:=1;\n if (t2>=t0) then begin ans:=t2; sum:=x2; x:=0; y:=x2; end;\n while i<=x1 do\n begin\n dichotomy(i,j,raz);\n if (j<>-1) and ((razb then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000;\n\n end;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=-1 to 2 do\n begin y1:=min(trunc(y2*(t0-t2)/(t1-t0)),x1);\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": " const\n fi='';\n fo='';\n oo=1000000000000000;\n var\n f:Text;\n res1,res2,y1,y2,t1,t2,x1,x2,t0:int64;\n procedure nhap;\n begin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\n end;\n procedure xuat;\n begin\n assign(f,fo);\n rewrite(f);\n writeln(res1,' ',res2);\n close(f);\n end;\n procedure process;\n var tmin,z:extended;i1,i2:int64;\n begin\n if (t1=t0) and (t2=t0) then\n begin\n res1:=x1;\n res2:=x2;\n exit;\n end;\n if t1=t0 then\n begin\n res1:=x1;\n res2:=0;\n exit;\n end;\n z:=(t0-t2)/(t1-t0);\n if x1>z*x2 then\n begin\n y1:=x2;\n y2:=x2;\n end\n else\n begin\n y1:=x1;\n y2:=x2;\n end;\n res1:=0;\n res2:=0;\n tmin:=oo;\n i2:=y2;\n while i2>=1 do\n begin\n i1:=trunc(i2*(t0-t2)/(t1-t0));\n if i1>x1 then i1:=x1;\n if (t1*i1+t2*i2)/(i1+i2)>=t0 then\n begin\n if abs((t1*i1+t2*i2)/(i1+i2)-tmin)<0.000000001 then\n begin\n if (i1+i2)>(res1+res2) then\n begin\n res1:=i1;\n res2:=i2;\n end;\n end\n else\n if (t1*i1+t2*i2)/(i1+i2) 0 then begin\n inc(yy);\n end;\n if yy + y = 0 then yy := x2;\n if (yy + y > 0) and (yy <= x2) then begin\n tt := (y * t1 + yy * t2) / (yy + y);\n //tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if tt >= t0 then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n for yy := 0 to x2 do begin\n y := (t2 - t0) * yy div (t0 - t1);\n if (t2 - t0) * yy mod (t0 - t1) > 0 then begin\n inc(y);\n end;\n if yy + y = 0 then y := x1;\n if (y + yy > 0) and (y <= x1) then begin\n tt := (y * t1 + yy * t2) / (yy + y);\n // tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if (tt >= t0) then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n writeln(y1, ' ', y2);\nend;\n\nprocedure test;\nbegin\n ans1 := 28665;\n ans2 := 287957;\n writeln((ans1 * t1 + ans2 * t2) / (ans1 + ans2) :0 :10);\n writeln((y1 * t1 + y2 * t2) / (y1 + y2) :0 :10);\nend;\n\nbegin\n pinit;\n solve;\n // test;\n pout;\nend."}, {"source_code": "uses math;\nconst esp = 0.00000000001;\nvar x1, x2, y1, y2, n, t1, t2, t0 : int64;\n res : double;\n\nprocedure slove;\nvar i : longint; j : int64;\nbegin\n if (t1 = t0) then y1:= x1;\n if (t2 = t0) then y2:= x2;\n if (t1 = t0) or (t2 = t0) then exit;\n res:= maxlongint;\n for i:= 0 to x1 do\n begin\n if i = 0 then\n j:= x2\n else\n j:= trunc(((t0 - t1) / (t2 - t0)) * i + 0.999999999);\n if (j <= x2) and ((i + j) <> 0) and\n ((res > (t1 * i + t2 * j) / (i + j) - t0)\n or (abs(res + t0 - (t1 * i + t2 * j) / (i + j)) < esp)) then\n begin\n y1:= i;\n y2:= j;\n res:= (t1 * i + t2 * j) / (i + j) - t0\n end;\n end;\nend;\n\nBEGIN\n readln(t1, t2, x1, x2, t0);\n slove;\n writeln(y1, ' ', y2);\nend.\n"}, {"source_code": "uses math;\nvar t1,t2,x1,x2,t:longint;\n y1,y2:int64;\n\nprocedure th1;\nbegin\n y1:=x1;\n y2:=x2;\nend;\n\nprocedure th2;\nbegin\n y1:=x1;\n y2:=0;\nend;\n\nprocedure th3;\nbegin\n y1:=0;\n y2:=x2;\nend;\n\nprocedure th4;\nvar i,j:longint;\n k1,k2:int64;\n s:real;\nbegin\n k1:=t2-t;\n k2:=t-t1;\n j:=1;\n y1:=0;\n y2:=x2;\n\n for i:=1 to x1 do\n begin\n while k2*i > k1*j do\n begin\n inc(j);\n if j>x2 then exit;\n end;\n if y1*j <= y2*i then\n begin\n y1:=i;\n y2:=j;\n end;\n end;\nend;\n\nbegin\n readln(t1,t2,x1,x2,t);\n if (t=t1) and (t=t2) then th1\n else if t=t1 then th2\n else if t=t2 then th3\n else th4;\n writeln(y1,' ',y2);\n readln;\nend.\n"}, {"source_code": "program hotbath;\nconst\n fin = '';\n fout = '';\n eps = 0.000001;\nvar\n t1,t2,t0,x1,x2,y2,y1,sum,max,maxy1,maxy2: int64;\n mt0: real;\nprocedure readf;\nbegin\n assign(input, fin); reset(input);\n assign(output, fout); rewrite(output);\n readln(t1,t2,x1,x2,t0);\nend;\n\nprocedure process;\nvar\n i: longint;\n tmp1,tmp2: double;\n t,tt: double;\nbegin\n mt0:=10000000;\n for i:=0 to x1 do\n begin\n y1:=i;\n if t2>t0 then\n begin\n tmp1:=(t0-t1)*y1;\n if y1=0 then\n begin\n y2:=x2;\n sum:=y1+y2;\n tmp1:=t1*y1+t2*y2;\n tmp2:=y1+y2;\n tt:=tmp1/tmp2;\n if (mt0-t0>tt-t0) or ((mt0-t0=tt-t0) and (sum>max)) then\n begin\n max:=sum;\n maxy1:=y1;\n maxy2:=x2;\n mt0:=tt;\n end;\n continue;\n end;\n tmp2:=t2-t0;\n t:=tmp1/tmp2;\n if abs(t-trunc(t))x2 then continue;\n sum:=y1+y2;\n tmp1:=t1*y1+t2*y2;\n tmp2:=y1+y2;\n tt:=tmp1/tmp2;\n if (mt0-t0>tt-t0) or ((mt0-t0=tt-t0) and (sum>max)) then\n begin\n max:=sum;\n maxy1:=y1;\n maxy2:=y2;\n mt0:=tt;\n end;\n end\n else\n begin\n if (t0-t1)*y1=0 then\n begin\n y2:=x2;\n sum:=y1+y2;\n tmp1:=t1*y1+t2*y2;\n tmp2:=y1+y2;\n tt:=tmp1/tmp2;\n if (mt0-t0>tt-t0) or ((mt0-t0=tt-t0) and (sum>max)) then\n begin\n max:=sum;\n maxy1:=y1;\n maxy2:=y2;\n mt0:=tt;\n end;\n end;\n end;\n end;\n writeln(maxy1,' ',maxy2);\nend;\n\nbegin\n readf;\n process;\nend.\n"}, {"source_code": "uses math;\nvar i,yn,ans1,ans2,y1,y2,x1,x2:longint;\n anst,t1,t2,t0,ct:extended;\n begin\n anst:=1000000000000000000;\n readln(t1,t2,x1,x2,t0);\n for y1:=0 to x1 do\n begin\n if t2-t0=0 then yn:=x2 else\n yn:=trunc((y1*(t0-t1))/(t2-t0));\n for i:=-5 to 5 do\n begin\n y2:=yn+i;\n if y2>x2 then continue;\n if y2<0 then continue;\n if (y1+y2)<0.0000001 then continue;\n ct:=(t1*y1+t2*y2)/(y1+y2);\n if (ct>=t0) then\n begin\n if (ct=min(ans1,ans2))) then\n begin\n anst:=ct;\n ans1:=y1;\n ans2:=y2;\n end;\n end;\n end;\n end;\n writeln(ans1,' ',ans2);\n end.\n\n\n\n\n\n\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,yy2,t0,nn,ot,mmax,w,t,kol,j,m,k,imax,p,h,jj:int64;\nn,s,step2:int64;\ni,y2:longint;\nblizt:array[0..1000000,-1..3] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000;\n\n end;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=0 to 0 do\n begin y1:=min(trunc(y2*(t0-t2)/(t1-t0)),x1);\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "Var i,j:longint;\nee,l1,r1,l,r,k,t1,t2,x1,x2,t0:int64;\nminRaz:extended;\nbegin\n Readln(t1,t2,x1,x2,t0);\n l1:=0; r1:=0;\n minRaz:=MaxInt;\n ee:=1;\n if t1=t0\n then ee:=0;\n for i:=ee to x2 do\n begin\n l:=0; r:=x1+1;\n for j:=1 to 30 do\n begin\n k:=(l+r) div 2;\n if k+i=0\n then l:=k\n else if (t1*k+t2*i)/(k+i)>=t0\n then l:=k\n else r:=k;\n end;\n if ((t1*l+t2*i)/(l+i)-t0L1+r1))\n then begin minraz:=(t1*l+t2*i) / (i+l)-t0; l1:=l; r1:=i; end;\n end;\n writeln(l1,' ',r1);\nend."}, {"source_code": "const\n{ fi='hot.inp';\n fo='hot.out';}\n fi='';\n fo='';\n maxn=1;\n eps=1e-9;\n\nvar\n f,f2:text;\n a:array[0..maxn]of longint;\n n:longint;\n t1,t2,t0,x1,x2,t:int64;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n assign(f2,fo);rewrite(f2);\n readln(f, t1, t2, x1, x2 , t0);\n close(f);\nend;\n\nprocedure main;\nvar xopt,yopt,y,max:int64;\n x:longint;\n gt,tt,yy,kq:double;\nbegin\n if t2=t0 then\n begin\n if t1=t0 then writeln(f2,x1,' ',x2)\n else writeln(f2,0,' ',x2);\n exit;\n end;\n tt:=(t0-t1)/(t2-t0);\n max:=0;\n kq:=1e18;\n for x:=0 to x1 do\n begin\n if x=123 then\n y:=y;\n yy:=x*tt;\n if yy-trunc(yy)<=eps then y:=trunc(yy)\n else y:=trunc(yy)+1;\n if x=0 then\n begin\n y:=t0 div t1;\n if t0 mod t1<>0 then inc(y);\n end;\n y:=minn(y,x2);\n if x+y=0 then continue;\n gt:=(x*t1+y*t2)/(x+y);\n if (gt>=t0) and (abs(gt-t0)max)) then\n begin\n kq:=gt-t0;\n max:=x+y;\n xopt:=x;\n yopt:=y;\n end;\n end;\n\n writeln(f2,xopt,' ',yopt);\nend;\n\nprocedure open2;\nvar test,sotest:integer;\nbegin\n assign(f,fi);reset(f);\n assign(f2,fo);rewrite(f2);\n readln(f,sotest);\n for test:=1 to sotest do\n begin\n readln(f, t1, t2, x1, x2 , t0);\n main;\n end;\n close(f);\nend;\n\nbegin\n open;\n main;\n close(f2);\nend.\n"}, {"source_code": "var t0,t1,t2,x1,x2,oti,otf:int64;i,f:longint;otr,vr:extended;\nbegin\n readln(t1,t2,x1,x2,t0);\n if (t1=t2) then begin writeln(x1,' ',x2);halt(0);end;\n if t1=t0 then begin writeln(x1,' ',0);halt(0);end;\n if t2=t0 then begin writeln(0,' ',x2);halt(0);end;\n otr:=10000000;oti:=0;otf:=0;\n for i:=x1 downto 0 do\n begin\n f:=trunc(-((t0-t1)*i)/(t0-t2));\n if (f<=x2)and(f>=0)and((f<>0)or(i<>0)) then\n begin\n vr:=(t1*i+t2*f)/(i+f);\n if (vr-t0=t0) then begin otr:=vr;oti:=i;otf:=f;end;\n end;\n f:=f+1;\n if (f<=x2)and(f>=0)and((f<>0)or(i<>0)) then\n begin\n vr:=(t1*i+t2*f)/(i+f);\n if (vr-t0=t0) then begin otr:=vr;oti:=i;otf:=f;end;\n end;\n f:=f-2;\n if (f<=x2)and(f>=0)and((f<>0)or(i<>0)) then\n begin\n vr:=(t1*i+t2*f)/(i+f);\n if (vr-t0=t0) then begin otr:=vr;oti:=i;otf:=f;end;\n end;\n end;\n if oti=0 then otf:=x2;\n if otf=0 then oti:=x1;\n writeln(oti,' ',otf);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R+}\n{$Q+}\n\nuses\n SysUtils;\n\nconst\n inf = int64(2000000000) * int64(2000000000);\nvar\n t1, t2, t0, x1, x2, i: longint;\n r1, r2, tmp: longint;\n best, t: extended;\n tmp_v: int64;\n\nfunction f(a1, a2: longint): extended;\nbegin\n if (a1 = 0) and (a2 = 0) then\n result := inf\n else\n result := (int64(a1) * int64(t1) + int64(a2) * int64(t2)) / (int64(a1) + int64(a2));\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(t1, t2, x1, x2, t0);\n\n best := inf;\n r1 := -1;\n r2 := -1;\n\n if (t0 = t1) and (t0 = t2) then\n begin\n writeln(x1, ' ', x2);\n halt(0);\n end;\n\n if (t0 = t2) then\n begin\n writeln(0, ' ', x2);\n halt(0);\n end;\n\n for i := 0 to x1 do\n begin\n\n t := int64(i) * (int64(t0) - int64(t1)) / (int64(t2) - int64(t0));\n if (trunc(t) = t) then\n tmp_v := trunc(t)\n else\n tmp_v := trunc(t) + 1;\n\n if (tmp_v > x2) then\n tmp := x2\n else\n tmp := tmp_v;\n\n if (f(i, tmp) < t0) or ((i = 0) and (tmp = 0)) then\n tmp := -1;\n\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))))\n then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n if (r1 = -1) and (r2 = -1) then\n begin\n r1 := 0;\n r2 := x2;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "Uses math;\nvar f,x,z,y21,y22,y23,t1,t2,x1,x2,t,y1,y2,max,o1,o2:extended;\n i,j:longint;\n begin\n read(t1,t2,x1,x2,t);\n f:=maxlongint;\n for i:=0 to trunc(x1) do\n begin\n y1:=i;\n if(t-t2=0)then z:=x2\n else z:=trunc(y1*(t1-t)/(t-t2));\n for j:=-5 to 5 do\n begin\n y2:=z+j;\n if(y2<=x2)and(y1>=0)and(y2>=0)and(y1+y2>0)then\n begin\n x:=(t1*y1+t2*y2)/(y1+y2);\n if(x>=t)and((x-tmax)))then\n begin\n max:=y1+y2;\n o1:=y1;\n o2:=y2;\n f:=x-t;\n end;\n end;\n end;\n end;\n writeln(o1:0:0,' ',o2:0:0);\n end."}, {"source_code": "{$Mode ObjFPC}\nconst fi='';\n fo='';\n nmax=1000000;\nvar t0,i,j,cs,csc:longint;\n x,y,t1,t2,x1,x2:qword;\n min:real;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n read(t1,t2,x1,x2,t0);\n x:=t2-t0;\n y:=t0-t1;\n if (x=0) or (y=0) then\n begin\n if x=0 then\n begin\n if y<>0 then write('0 ',x2)\n else write(x1,' ',x2);\n end\n else write(x1,' 0');\n end\n else\n begin\n min:=1e32;\n cs:=0;\n for i:=x2 downto 1 do\n begin\n j:=trunc((i*x)/y);\n if j>x1 then j:=x1;\n if (i+j<>0) and (j<=x1) and ((t1*j+t2*i)/(i+j)-t0>=0) and ((t1*j+t2*i)/(i+j)-t0=0) and ((t1*(j+1)+t2*i)/(i+j+1)-t0= t) and ((gr - t < ans) or\n ((gr - t = ans) and (y1 + y2 > res))) and (y2 <= x2) then begin\n ans := gr - t;\n \t\tres := y1 + y2;\n \t\tai := y1;\n \t\tbi := y2;\n end;\n end;\n \tend;\n \twrite(ai, ' ', bi);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\nvar t1,t2,j,t0,resx,resy:int64;\n i,x1,x2:longint;\n res:extended;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(t1,t2,x1,x2,t0);\n if (t1=t2) and (t2=t0) then\n\tbegin\n\t\twriteln(x1,' ',x2);\n\t\thalt;\n\tend;\n if t2=t0 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n if t1=t0 then\n begin\n writeln(x1,' ',0);\n halt;\n end;\n res:=maxlongint;\n for i:=0 to x1 do\n begin\n if i<>0 then j:=(i*t0-i*t1) div (t2-t0) else j:=x2;\n if (i*t0-i*t1) mod (t2-t0)<>0 then inc(j);\n if (j<=x2) and ((t1*i+t2*j)/(i+j)-t0<=res) then\n begin\n res:=(t1*i+t2*j)/(i+j)-t0;\n resx:=i;\n resy:=j;\n end;\n end;\n writeln(resx,' ',resy);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var\n b1,b2,dif:extended;\n t1,t2,x1,x2,tx,x,res:extended;\n i:longint;\nbegin\n readln(t1,t2,x1,x2,tx);\n dif:=1000*1000*1000;\n if (t1=t2) and (t1=tx) then begin\n writeln(x1:0:0,' ',x2:0:0);\n halt;\n end;\n if t1=tx then begin\n writeln(x1:0:0,' ',0);\n halt;\n end;\n if t2=tx then begin\n writeln(0,' ',x2:0:0);\n halt;\n end;\n x:=x1;\n res:=(t1*x+t2*x2)/(x+x2);\n if (res>=tx) and (x<=x1) and (res-tx=tx) and (x<=x1) and (res-tx=dif) then\n if (x+x2>b1+b2) then begin\n b1:=x;\n b2:=x2;\n end;\n while x2>=0 do begin\n x:=x2*(t2-tx)/(tx-t1);\n x:=trunc(x);\n for i:=-40 to 2 do\n begin\n if (x+i=0) and (x2=0) then\n continue;\n if x+i<0 then\n continue;\n res:=(t1*(x+i)+t2*x2)/(x+i+x2);\n if (res>=tx) and (x+i<=x1) and (res-tx=tx) and (x+i<=x1) and (res-tx=dif) then\n if (x+i+x2>b1+b2) then begin\n b1:=x+i;\n b2:=x2;\n end;\n end;\n x2:=x2-1;\n end;\n writeln(b1:0:0,' ',b2:0:0);\nend.\n"}, {"source_code": " const\n fi='';\n fo='';\n var\n tmin:real;\n t1,t2,x1,x2,t0,max,r1,r2,y1,y2:int64;\n procedure init;\n begin\n assign(input,fi);\n assign(output,fo);\n reset(input);\n rewrite(output);\n readln(t1,t2,x1,x2,t0);\n tmin:=maxlongint;\n end;\n\n procedure bs;\n var\n check:boolean;\n a,b,l,r,mid:int64;\n tmp:real;\n r1:longint;\n begin\n for r1:=0 to x1 do\n begin\n a:=t1*int64(r1);\n l:=0; r:=x2;\n check:=false;\n repeat\n mid:=(l+r)div 2;\n if check=false then\n begin\n mid:=x2;\n check:=true;\n end;\n if(r1+mid)=0 then\n begin\n if t1>=t0 then\n begin\n if(t1r then break;\n continue;\n end\n else\n tmp:=(a+t2*mid)/(r1+mid);\n if tmp>=t0 then\n begin\n if(tmpr;\n end;\n writeln(y1,' ',y2);\n end;\n\n begin\n init;\n bs;\n end.\n\n"}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min : int64;\n x : longint;\n px,tx,mint,fx : extended;\n ok : boolean;\n\n function _round(x : extended) : longint;\n begin\n _round:=round(x);\n end;\n\nbegin\n { assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n if (t1=t0) and (t2=t0)\n then begin\n ok:=true;\n minx:=x1; minf:=x2;\n end \n else begin\n if (t1=t0) then begin ok:=true; minx:=x1; minf:=0; end;\n if (t2=t0) then begin ok:=true; minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n ok:=false;\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n if (fx<0) then begin\n f:=trunc(px)+1;\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n end;\n if (fx<=mint) and (fx>=0) then\n if (x+f>min) or ((fx=0)) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n ok:=true;\n end;\n end; \n end;\n end;\n if (not ok) then minf:=x2;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "const fi='';\n fo='';\nvar t1,t2,x1,x2,t0,y1,y2:longint;\nprocedure rinf;\nbegin\n assign(input,fi);\n reset(input);\n read(t1,t2,x1,x2,t0);\n close(input);\nend;\n\nprocedure solve;\nvar i:longint;\n k:int64;\n s,t:real;\nbegin\n if t1=t2 then\n begin\n y1:=x1;\n y2:=x2;\n exit;\n end;\n if t0=t1 then\n begin\n y1:=x1;\n y2:=0;\n exit;\n end;\n if t0=t2 then\n begin\n y1:=0;\n y2:=x2;\n exit;\n end;\n s:=t2;\n y1:=0;y2:=x2;\n for i:=1 to x1 do\n begin\n if int64((t0)-int64(t1))*int64(i) mod int64((t2)-int64(t0))=0 then\n k:=int64((t0)-int64(t1))*int64(i) div int64((t2)-int64(t0))\n else\n k:=int64((t0)-int64(t1))*int64(i) div int64((t2)-int64(t0))+1;\n if (i+k<>0) and (x2>=k)and (k>=0) then\n t:=(int64(t1)*int64(i)+int64(t2)*int64(k))/(i+k)\n else t:=maxlongint;\n if s>t then\n begin\n s:=t;\n y1:=i;\n y2:=k;\n end\n else\n if (s=t)and(y1+y20 then x:=(t0*i-t1*i) div (t2-t0) else x:=x2;\n if (t0*i-t1*i) mod (t2-t0) <> 0 then inc(x);\n if (x+i<>0)and(x<=x2)and((t1*i+t2*x)/(x+i)-t0<=getted) then begin getted:=(t1*i+t2*x)/(x+i)-t0; min:=x+i; ansX:=x;ansy:=i; end;\n end;\n writeln(ansY, ' ' ,ansX); \nend.\n\n"}, {"source_code": "\nvar t1,t2,x1,x2,t0,y2,a1,a2:int64;\n y1:longint;\n t,ans:extended;\nbegin\n readln(t1,t2,x1,x2,t0);\n ans:=maxlongint;\n if t2=t1 then\n begin\n writeln(x1,' ',x2);\n halt;\n end;\n if t0=t1 then\n begin\n writeln(x1,' ',0);\n halt;\n end;\n if t0=t2 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n\n\n for y1:=1 to x1 do\n begin\n if (y1*(t0-t1))/(t2-t0)-trunc((y1*(t0-t1))/(t2-t0))=0 then\n y2:=trunc(y1*(t0-t1)/(t2-t0))\n else y2:=1+trunc(y1*(t0-t1)/(t2-t0));\n if y2>x2 then continue;\n t:=((t1*y1)+(t2*y2))/(y1+y2);\n if (t>=t0) and ((t=0) and (y2>0)) or ((y1>0) and (y2>=0)) and (b=false) do\n begin\n o:=((t1*y1+t2*y2)/(y1+y2))-t0; \n If o<0 then y1:=y1-1 else\n begin\n if o=0) and (y2>=0)) then continue;\n\n if t 0 then\n bolsh := true\n else\n bolsh := false;\nend;\nbegin\n { assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output); }\n readln(t1, t2, x1, x2, t0);\n if t1 = t2 then\n begin\n writeln(x1, ' ', x2);\n exit;\n end;\n if t0 >= t2 then\n begin\n writeln(0, ' ', x2);\n exit;\n end;\n\n if t0 <= t1 then\n begin\n writeln(x1, ' ', 0);\n exit;\n end;\n\n //tmin.chic := -1;\n // tmin.znam := 1;\n tmin := 1000000000000000000;\n for y1 := 1 to x1 do\n begin\n y2dr := int64(y1) * (t0 - t1) / (t2 - t0);\n // y2dr.znam := t2 - t0;\n // cokr(y2dr);\n y2 := ceil(y2dr);\n //if y2 < 0 then\n // writeln(y2);\n if y2 > x2 then\n break;\n\n ttek:= temp(y1, y2);\n if (ttek = tmin) and (y1 + y2 > y1t + y2t) then\n begin\n tmin := ttek;\n y1t := y1;\n y2t := y2;\n end;\n\n if tmin > ttek then\n begin\n tmin := ttek;\n y1t := y1;\n y2t := y2;\n end;\n end;\n if tmin = 1000000000000000000 then\n begin\n writeln(0, ' ', x2);\n exit;\n end;\n writeln(y1t, ' ', y2t);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 0;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 1e-10;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n t1, t2, x1, x2, t0, y1, y2: int64; \n\nprocedure run;\nvar\n i, j: int64;\nbegin\n read(t1, t2, x1, x2, t0);\n\n if (t1 = t0) and (t2 = t0) then begin\n write(x1, ' ', x2);\n exit;\n end;\n\n if (t1 = t0) then begin\n write(x1, ' ', 0);\n exit;\n end;\n\n if (t2 = t0) then begin\n write(0, ' ', x2);\n exit;\n end;\n\n j := 1;\n\n while j <= x2 do begin\n i := trunc(j*(t2 - t0)/(t0 - t1) + eps);\n\n i := max(min(i, x1), 0);\n\n if (j = 1) then begin\n y1 := i;\n y2 := j;\n\n inc(j);\n continue;\n end;\n\n if ((t1*y1 + t2*y2)*(i + j) > (t1*i + t2*j)*(y1 + y2)) or\n (((t1*y1 + t2*y2)*(i + j) = (t1*i + t2*j)*(y1 + y2)) and (i + j > y1 + y2)) then begin\n y1 := i;\n y2 := j;\n end;\n\n inc(j);\n end;\n\n write(y1, ' ', y2);\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=t2;\n ra1:=0; ra2:=x2;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1)*int64(i);\n dm2:=int64(t2)*int64(k);\n dm3:=int64(k)+int64(i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q+0.5>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1)*int64(i);\n dm2:=int64(t2)*int64(k);\n dm3:=int64(k)+int64(i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "{$mode delphi}\nprogram Project1;\nUses SysUtils, Math;\nvar y2,t1,t2,x1,x2,t,y1:longint;\n\t\tmin,t0:extended;\n miny1,miny2:int64;\nfunction f(y1,y2:longint):extended;\nvar l:extended;\nbegin\n\tl:= t1 * (y1 / (y1 + y2)) + t2 * (y2 / (y1 + y2)) - t;\n f:=l;\nend;\nprocedure check (y1,y2:int64);\n\tbegin\n \t//if (y1=100) then writeln('a ', y2, ' ', (t1*y1 + t2*y2) / (y1 + y2), ' xx ', (t1*miny1 + t2*miny2) / (miny1 + miny2));\n\n \tif (y2 > x2) or (y2<0) then exit\n \telse if t*(y1 + y2) <= t1*y1 + t2*y2 then\n\n if (miny1=-1) or ((t1*y1 + t2*y2) / (y1 + y2) < (t1*miny1 + t2*miny2) / (miny1 + miny2)) then begin\n \tminy1:=y1;\n miny2:=y2;\n //writeln(miny1, ' ', miny2);\n end;\n end;\nbegin\n\t//assign (input,'input.txt'); reset (input);\n //assign (output,'output.txt'); rewrite (output);\n read (t1,t2,x1,x2,t);\n if (t2 = t1) and (t1 = t) then begin\n \twrite (x1,' ',x2);\n exit;\n end;\n if t2 = t then begin\n \twrite (0,' ',x2);\n \texit;\n end;\n if t1 = t then begin\n \twrite (x1,' ',0);\n \texit;\n end;\n min:=1000001;\n t0 := (t - t1) / (t2 - t);\n {if min > f(0,x2) then begin\n min:= f(0,x2);\n miny1:= 0;\n miny2:=x2;\n end;}\n miny1:=-1;\n for y1:=x1 downto 1 do begin\n y2:= round (y1 * t0);\n check (y1,y2-1);\n check (y1,y2);\n check (y1,y2+1);\n end;\n if miny1 = -1 then if t1 < t2 then begin\n miny1:=0;\n \tminy2:=x2;\n end else begin\n miny2:=x2;\n miny1:=x1;\n end;\n write (miny1,' ',miny2);\nend.\n"}, {"source_code": "var lx,ly,t1,t2,x1,x2,t,i,v,y:int64;\n j:longint;\n lt,min,max:extended;\n begin\n //assign(input,'input.txt');\n //reset(input);\n //assign(output,'output.txt');\n //rewrite(output);\n read(t1,t2,x1,x2,t);\n if (t1=t) and (t2=t) then begin\n writeln(x1,' ',x2);\n halt;\n end;\n if t1=t then begin\n writeln(x1,' ',0);\n halt;\n end\n else\n if t2=t then begin\n writeln(0,' ',x2);\n halt;\n end;\n min:=maxlongint;\n max:=0;\n for j:=0 to x1 do\n begin\n i:=j;\n if i=0 then begin\n y:=x2;\n lt:=t2;\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=y;\n\n lx:=0;\n ly:=y;\n end;\n end\n else begin\n v:=i*(t1-t);\n if v mod (t-t2)>0 then begin\n y:=v div (t-t2);\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y> 0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n\n y:=v div (t-t2)+1;\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y> 0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n\n end\n else begin\n y:=v div (t-t2);\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y>0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n y:=v div (t-t2)+1;\n\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y>0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n end;\n end;\n end;\n\n\n writeln(lx,' ',ly);\n //close(input);\n //close(output);\n end.\n"}, {"source_code": "const fi='';\n fo='';\nvar t1,t2,j,t0,resx,resy:int64;\n i,x1,x2:longint;\n res:extended;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(t1,t2,x1,x2,t0);\n if (t1=t2) and (t2=t0) then\n\tbegin\n\t\twriteln(x1,' ',x2);\n\t\thalt;\n\tend;\n if t2=t0 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n if t1=t0 then\n begin\n writeln(x1,' ',0);\n halt;\n end;\n res:=maxlongint;\n for i:=0 to x1 do\n begin\n if i<>0 then j:=(i*t0-i*t1) div (t2-t0) else j:=x2;\n if (i*t0-i*t1) mod (t2-t0)<>0 then inc(j);\n if (j<=x2) and ((t1*i+t2*j)/(i+j)-t0<=res) then\n begin\n res:=(t1*i+t2*j)/(i+j)-t0;\n resx:=i;\n resy:=j;\n end;\n end;\n writeln(resx,' ',resy);\n close(input);\n close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,yy2,t0,nn,ot,mmax,w,t,kol,j,m,k,imax,p,h,jj:int64;\nn,s,step2:int64;\ni,y2:longint;\nblizt:array[0..1000000,-1..3] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000;\n\n end;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=0 to 0 do\n begin y1:=min(trunc(y2*(t0-t2)/(t1-t0)),x1);\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n y1,i:longint;\n t1,t2,x1,x2,t0,a1,a2,y2:int64;\n\n procedure check(y1,y2:int64);\n begin\n if t0*(y1+y2) <= t1*y1+t2*y2 then\n begin\n if (t1*y1+t2*y2)*(a1+a2) < (t1*a1+t2*a2)*(y1+y2) then\n begin\n a1:=y1;\n a2:=y2;\n end else\n if ((t1*y1+t2*y2)*(a1+a2) = (t1*a1+t2*a2)*(y1+y2)) and (y1+y2 > a1+a2) then\n begin\n a1:=y1;\n a2:=y2;\n end;\n end;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(t1,t2,x1,x2,t0);\n if t1 = t2 then\n begin\n writeln(x1,' ',x2);\n halt;\n end;\n if t1 = t0 then\n begin\n writeln(x1,' ',0);\n halt;\n end;\n if t2 = t0 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n a1:=0; a2:=x2;\n for y1:=0 to x1 do\n begin\n y2:=round(int64(y1)*(t0-t1)/(t2-t0));\n if y2 > round(1e6)+10 then continue;\n for i:=y2-1 to y2+1 do if (i >= 0) and (i <= x2) then check(y1,i);\n end;\n writeln(a1,' ',a2);\nend.\n"}, {"source_code": "program Project3_1;\n\n{$APPTYPE CONSOLE}\n\nconst\n eps = 0.0000000001;\n\nvar\n t1, t2, x1, x2, t0, l1, l2, r1, r2, m1, m2, max, ans1, ans2, y1, y2, y3: int64;\n i: longint;\n t, min: extended;\n\n\nbegin\n {assignfile(input, 'input.txt');\n reset(input);\n assignfile(output, 'output.txt');\n rewrite(output); }\n\n read(t1, t2, x1, x2, t0);\n\n min := -1;\n max := -1;\n\n for i := 0 to x1 do begin\n y1 := i;\n if t0 = t2 then\n y2 := x2\n else\n y2 := trunc((y1 * (t0 - t1)) / (t2 - t0));\n y3 := y2 + 1;\n if y2 <= x2 then begin\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 >= 0 then begin\n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n end;\n\n y2 := y3;\n if y2 <= x2 then begin\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 >= 0 then begin\n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n end;\n end;\n\n for i := 0 to x2 do begin\n y2 := i;\n if t0 = t1 then\n y1 := x1\n else\n y1 := trunc((y2 * (t2 - t0)) / (t0 - t1));\n y3 := y1 + 1;\n if y1 <= x1 then begin\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 >= 0 then begin\n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n end;\n\n y1 := y3;\n if y1 <= x1 then begin\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 >= 0 then begin\n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n end;\n end;\n\n write(ans1, ' ', ans2);\n\n //read(ans1);\n\n closefile(input);\n closefile(output);\nend."}, {"source_code": "Var i,j:longint;\nee,l1,r1,l,r,k,t1,t2,x1,x2,t0:int64;\nminRaz:extended;\nbegin\n //Assign(Input,'input.txt');\n // Assign(Output,'output.txt');\n Readln(t1,t2,x1,x2,t0);\n l1:=0; r1:=0;\n minRaz:=MaxInt;\n ee:=1;\n if t1=t0\n then ee:=0;\n for i:=ee to x2 do\n begin\n l:=0; r:=x1+1;\n for j:=1 to 30 do\n begin\n k:=(l+r) div 2;\n if k+i=0\n then l:=k\n else if (t1*k+t2*i)/(k+i)>=t0\n then l:=k\n else r:=k;\n end;\n if ((t1*l+t2*i)/(l+i)-t0L1+r1))\n then begin minraz:=(t1*l+t2*i) / (i+l)-t0; l1:=l; r1:=i; end;\n end;\n writeln(l1,' ',r1);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$maxstacksize 10000000}\n{$b-}\n{$r-}\nconst eps=1e-10;\nvar\n bc,bz,anc,anz,t1,t2,t0,x1,x2:int64;\n pc,ac,az:array[1..2000001] of int64;\n i1,i:integer;\n best:extended;\n\n Function nod(a,b:int64):int64;\n begin\n If b=0 then nod:=a else nod:=nod(b,a mod b);\n end;\n\n Procedure bins(q:int64);\n var\n i,j:integer;\n pp,mn,ff,c,d,mc,mz:int64;\n begin\n i:=0;\n If q>x2 then j:=x2 else j:=q;\n mc:=0;\n mz:=0;\n mn:=1000000000000000;\n repeat\n d:=(i+j) div 2;\n c:=q-d;\n pp:=t0*q;\n If (d>x2) then j:=d-1\n else If (c>x1) then i:=d+1 else\n begin\n ff:=c*t1+d*t2;\n // writeln(t0*q,' ',ff);\n If pp>ff then i:=d+1\n else\n begin\n j:=d-1;\n If (ff-ppj;\n ac[q]:=mc;\n az[q]:=mz;\n //writeln(mc,' ',mz);\n //If q=130 then writeln(ac[q],' ',az[q],' ',pc[q],' ',pz[q]);\n end;\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt');}\n readln(t1,t2,x1,x2,t0);\n\n\n For i:=1 to x1+x2 do bins(i);\n\n best:=1000000000000000;\n anc:=0;\n anz:=0;\n bc:=0;\n bz:=0;\n\n\n For i:=x1+x2 downto 1 do\n begin\n i1:=i;\n pc[i]:=pc[i];\n\n If (pc[i]=bc) and (i1=bz) and (pc[i]<>0) then\n begin\n anc:=ac[i];\n anz:=az[i];\n bc:=pc[i];\n bz:=i1;\n best:=bc/bz;\n end\n else If (pc[i]<>0) and (pc[i]/i1>=t0) and (pc[i]/i1x1) Then Write(0,' ',x2)\n Else Write(x1,' ',0);\n Halt;\n End;\n If t0=t2 Then Begin\n Write(0,' ',x2);\n Halt;\n End;\n r:=High(Integer);\n t:=High(Integer);\n i1:=0;\n j1:=0;\n For i:=0 To x1 Do Begin\n s:=i*(t1-t0)/(t0-t2);\n j:=Round(s);\n If jx2 Then j:=x2;\n If j<0 Then j:=0;\n If (i=0) and (j=0) Then Continue;\n t3:=(t1*i+t2*j)/(i+j);\n If t3>=t0 Then Begin\n If (abs(t3-t0-r)t) Then Begin\n t:=i+j;\n i1:=i;\n j1:=j;\n End\n Else If t3-t00) and (j1<>0) Then Write(i1,' ',j1)\n Else Begin\n If (t1=t0) and (x1>x2) Then Write(x1,' ',0)\n Else Write(0,' ',x2);\n End;\nEnd.\n\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n m1,m2,t1,t2,x1,x2,t0,y1,y2,z1,z2,max,a,b: int64;\n\nprocedure go(y1,y2:int64);\nvar\n d1,d2: int64;\nbegin\n d1:=t1*y1+t2*y2-t0*y1-t0*y2;\n d2:=y1+y2;\n if d1 < 0 then exit;\n if (d1*m2 < m1*d2) or (d1*m2 = m1*d2) and (y1+y2 > max) then\n begin\n m1:=d1;\n m2:=d2;\n max:=y1+y2;\n z1:=y1; z2:=y2;\n end;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(t1,t2,x1,x2,t0);\n m1:=1; m2:=0;\n max:=-1;\n z1:=0; z2:=0;\n go(0,x2);\n y1:=1;\n while y1 <= x1 do\n begin\n a:=t2-t0;\n b:=y1*(t0-t1);\n // a*y2 >= b\n if a > 0 then\n begin\n y2:=(b+a-1) div a;\n if y2 <= x2 then go(y1,y2);\n end\n else go(y1,x2);\n inc(y1);\n end;\n writeln(z1,' ',z2);\n close(input);\n close(output);\nend."}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min : int64;\n x : longint;\n px,tx,mint,fx : extended;\n ok : boolean;\n\n function _round(x : extended) : longint;\n begin\n _round:=round(x);\n end;\n\nbegin\n { assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n if (t1=t0) and (t2=t0)\n then begin\n ok:=true;\n minx:=x1; minf:=x2;\n end \n else begin\n if (t1=t0) then begin ok:=true; minx:=x1; minf:=0; end;\n if (t2=t0) then begin ok:=true; minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n ok:=false;\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n if (fx<0) then begin\n f:=trunc(px)+1;\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n end;\n if (fx<=mint) and (fx>=0) then\n if (x+f>min) or ((fx=0)) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n ok:=true;\n end;\n end; \n end;\n end;\n if (not ok) then minf:=x2;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "program task_1;\n{$apptype console r+ q+ o+}\nuses SysUtils, Math;\ntype real = extended;\nvar y1,y2,t1,t2,x1,x2,t0: int64;\n anst: real;\nprocedure binary;\nvar m,ll,rr,mm: int64;\n tp: real;\nbegin\n m:=0;\n while (m<=x1)do begin\n ll:=0;rr:=x2;\n while (ll<=rr)do begin\n mm:=(ll+rr)shr 1;\n if (m=0)and(mm=0)then break;\n tp:=(t1*m+t2*mm)/(m+mm);\n if (tp>=t0)and\n ((tpy1+y2)))then begin\n y1:=m;\n y2:=mm;\n anst:=tp;\n end;\n if (tp>t0)then rr:=mm-1\n else ll:=mm+1;\n end;\n inc(m);\n end;\nend;\n\nbegin\n//assign(input,'input.txt');reset(input);\n//assign(output,'output.txt');rewrite(output);\n read(t1,t2,x1,x2,t0);\n y1:=0;\n y2:=0;\n anst:=1e9;\n binary;\n if (y1=0)then y2:=x2;\n if (y2=0)then y1:=x1;\n write(y1,' ',y2);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nconst\n eps = 1e-12;\n\nvar\n bsum, a, b: Int64;\n t, f: Extended;\n t1, t2, x1, x2, t0: Int64;\n y1, y2: Integer;\n\nbegin\n //Reset(input, 'input.txt'); Rewrite(output, 'output.txt');\n Readln(t1, t2, x1, x2, t0);\n y1 := 0;\n t := maxint; bsum := -1; a := -1; b := -1;\n for y2 := 0 to x2 do\n begin\n while True do\n begin\n if (y1+y2 > 0) then\n begin\n f := (1.0*y1*t1+y2*t2)/(y1+y2);\n if (f - t0 < t - t0) or (samevalue(f-t0, t-t0, eps) and (y1+y2 > bsum)) then\n begin\n a := y1; b := y2; bsum := y1 + y2; t := f;\n end;\n end;\n Inc(y1);\n if (y1 + y2 = 0) or ((1.0*y1*t1+y2*t2)/(y1+y2) < t0) or (y1 > x1) then\n begin\n Dec(y1); break;\n end;\n if (y1+y2 > 0) then\n begin\n f := (1.0*y1*t1+y2*t2)/(y1+y2);\n if (f - t0 < t - t0) or (samevalue(f-t0, t-t0, eps) and (y1+y2 > bsum)) then\n begin\n a := y1; b := y2; bsum := y1 + y2; t := f;\n end;\n end;\n end;\n end;\n Writeln(a, ' ', b);\nend.\n "}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,yy2,t0,nn,ot,mmax,w,t,kol,j,m,k,imax,p,h,jj:int64;\nn,s,step2:int64;\ni,y2:longint;\nblizt:array[0..1000000,-1..3] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000;\n\n end;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=0 to 0 do\n begin y1:=min(trunc(y2*(t0-t2)/(t1-t0)),x1);\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $11000000}\n{$R-,Q-,S+,O-}\nconst\n eps = 1e-11;\nvar\n x1, y1, x2, ans1, Ans2, y2, t1,t2, t0 : Int64;\n i : longint;\nfunction eq(x, y : extended) : Boolean;\nbegin\n result := y - x > eps;\nend;\nfunction neq(x, y : extended) : boolean;\nbegin\n result := (x - y < eps) and (y - x < eps);\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(t1, t2, x1, x2, t0);\n if t2 = t0 then\n begin\n if t1 = t2 then\n writeln(x1, ' ', x2)\n else\n Writeln(0, ' ', x2);\n exit;\n end;\n ans1 := -1;\n Ans2 := -1;\n for i := 0 to x1 do\n begin\n y1 := i;\n y2 := ((y1 * (t0 - t1)) div (t2 - t0 ));\n if y1 = 0 then\n y2 := x2;\n if (t1 * y1 + t2 * y2) div (y1 + y2) < t0 then\n inc(y2);\n if y2 > x2 then\n y2 := x2;\n if (t1 * y1 + y2 * t2) div (y1 + y2) < t0 then\n Continue;\n if (ans1 = -1) or (eq((t1 * y1 + t2 * y2) / (y1 + y2), (t1 * Ans1 + t2 * ans2) / (ans1 + ans2))) or (neq((t1 * y1 + t2 * y2) / (y1 + y2), (t1 * Ans1 + t2 * ans2) / (ans1 + ans2))) and (y1 + y2 > ans1 + ans2) then\n begin\n ans1 := y1;\n ans2 := y2;\n end;\n end;\n writeln(ans1, ' ', ans2);\nend.\n"}, {"source_code": " var y1: integer;\n te,min,t1,t2,t0,x1,x2,y2,y01,y02: int64;\n dt: real;\n begin\n readln(t1,t2,x1,x2,t0);\n min:=-1;\n dt:=10000000;\n\n if (t1=t2) then writeln(x1,' ',x2) else if (t0<=t1) then writeln(x1,' 0') else if (t0>=t2) then writeln('0 ',x2) else begin\n\n for y1:=0 to x1 do begin\n te:=round(int(y1*(t0-t1)/(t2-t0)+0.9999999));\n if (te=0)and(t2-t0=0) then dt:=t2-t0;\n if (te<>0)and(te<=x2)and((t1*y1+t2*te)/(te+y1)-t0>-0.0000001) and ((t1*y1+t2*te)/(te+y1)-t0=min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n if (te<>0)and(abs((t1*y1+t2*te)/(te+y1)-t0-dt)<=0.00000001)and(te<=x2)and(te+y1>min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n end;\n writeln(y01,' ',y02);\n end;\n\n readln;\n end."}, {"source_code": "var y1: integer;\n te,min,t1,t2,t0,x1,x2,y2,y01,y02: int64;\n dt: real;\nbegin\n readln(t1,t2,x1,x2,t0);\n min:=-1;\n dt:=10000000;\n\n if (t1=t2) then writeln(x1,' ',x2) else if (t0<=t1) then writeln(x1,' 0') else if (t0>=t2) then writeln('0 ',x2) else begin\n\n for y1:=0 to x1 do begin\n te:=round(int(y1*(t0-t1)/(t2-t0)+0.9999999));\n if (te=0)and(t2-t0=0) then dt:=t2-t0;\n if (te<>0)and(te<=x2)and((t1*y1+t2*te)/(te+y1)-t0>-0.0000001) and ((t1*y1+t2*te)/(te+y1)-t0=min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n if (te<>0)and(abs((t1*y1+t2*te)/(te+y1)-t0-dt)<=0.00000001)and(te<=x2)and(te+y1>min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n end;\n writeln(y01,' ',y02);\n end;\n\n readln;\nend."}, {"source_code": "{$r-,q-,s-,o+}\n{$IFNDEF ONLINE_JUDGE}\n{$o-,r+,q+,s-}\n{$ENDIF}\n{$M 16777216}\nprogram TASK_3;\n\nuses\n SysUtils,\n math;\nvar i,x1,x2:integer;\n min,ansx,ansy,t1,t2,t0,x,xx:int64;getted:extended;\n \nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');reset(input);\n assign(output, 'output.txt');rewrite(output);\n {$ENDIF}min:=0;\n readln(t1,t2,x1,x2,t0);getted:=10000000000000;\n if (t1=t2)and(t2=t0) then begin writeln(x1,' ',x2); halt(0); end;\n if t1=t0 then begin writeln(x1,' ',0);halt(0); end;\n if t2=t0 then begin writeln(0,' ',x2); halt(0); end;\n for i:=0 to x1 do\n begin\n if i<>0 then x:=(t0*i-t1*i) div (t2-t0) else x:=x2;\n if (t0*i-t1*i) mod (t2-t0) <> 0 then inc(x);\n if (x+i<>0)and(x<=x2)and((t1*i+t2*x)/(x+i)-t0<=getted) then begin getted:=(t1*i+t2*x)/(x+i)-t0; min:=x+i; ansX:=x;ansy:=i; end;\n end;\n writeln(ansY, ' ' ,ansX); \nend."}, {"source_code": "program shower;\nconst inf = 1000*1000;\nvar t1,t2,t0,x1,x2,i : longint; \n j,t3,t4 : int64; delta,k,l : extended;\nbegin \n delta:= inf;\n readln(t1,t2,x1,x2,t0);\n if (t1 = t0) or (t2 = t0) then begin\n if t1 = t2 then writeln(x1,' ',x2)\n else if t1 = t0 then writeln(x1,' ',0)\n else writeln(0,' ',x2);\n exit; \n end;\n \n for i:= x1 downto 0 do\n begin\n j:= (t0 - t1); \n if (((j*i) mod (t2 - t0)) = 0) then j:= ((j * i) div (t2 - t0))\n else j:= ((j * i) div (t2 - t0)) + 1;\n if (j > x2) or (i = 0) then j:= x2; \n k:= t1; k:= k*i; l:= t2; l:= l*j;\n k:= (k + l) / (i+j);\n {writeln(i,' ',j,' ',k:5:5,' ',delta:5:5); } \n if (k >= t0) and ((k - t0) < delta) then begin\n delta:= k - t0;\n t3:= i; t4:= j;\n end;\n end;\n writeln(t3,' ',t4);\nend.\n"}, {"source_code": "program cf126a;\nconst eps=1e-7;\nvar\n n,i,j,y1:longint;\n an1,an2,y2,t1,t2,x1,x2,t0,dd:int64;\n ans,d:double;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t2=t0 then begin\n if t1<>t0 then\n writeln(0,' ',x2)\n else writeln(x1,' ',x2); \n halt;\n end;\n\n ans:=1e50;\n for y1:=x1 downto 1 do begin\n d:=(t0*y1-t1*y1)/(t2-t0);\n y2:=trunc(d);\n if y20 then\n for i:=x2 downto 1 do\n begin\n y2:=i;\n y1:=-y2*b/a;\n p:=trunc(y1);\n if y1<0 then pom:=-1 else pom:=1;\n if abs(y1-p)>0.99999999 then p:=p+pom;\n if (y1<0) and (abs(y1-trunc(y1))<0.00000001) then p:=p-1;\n if p>x1 then p:=x1;\n if y1=p then\n begin\n writeln(p,' ',trunc(y2));\n halt;\n end;\n te:=(t1*p+t2*y2)/(p+y2);\n if te-to1+o2)) then\n begin\n o1:=y1; o2:=y2;\n end;\nend;\n\nbegin\n read(t1,t2,x1,x2,t0);\n\n o1:=0; o2:=0;\n upd(x1,0); upd(x1,x2); upd(0,x2);\n\n if (t0<>t1) and (t0<>t2) then\n for i:=1 to x2 do\n begin\n y2:=i;\n y1:=(t2-t0)*y2 div (t0-t1);\n if y1>x1 then y1:=x1;\n upd(y1,y2);\n end;\n\n writeln(o1,' ',o2);\nend.\n"}, {"source_code": "uses math;\nvar n,m,i,j,t,l,r,yy,zz,ii,jj:longint;\n y1,y2,j1,tt,tt1,t1,t2,x1,x2,t0:int64;\n fl:boolean;\n k,mn:extended;\n\nbegin\n\n read(t1,t2,x1,x2,t0);\n y1:=x1;y2:=x2;mn:=t2;\n while ((y1>=0)and(y2>0) )or ((y1>0)and (y2>=0)) do\n begin\n k:=(t1*y1+t2*y2)/(y1+y2)-t0;\n if k<0 then dec(y1)\n else begin\n if k0 then j:=(i*t0-i*t1) div (t2-t0) else j:=x2;\n if (i*t0-i*t1) mod (t2-t0)<>0 then inc(j);\n if (j<=x2) and ((t1*i+t2*j)/(i+j)-t0<=res) then\n begin\n res:=(t1*i+t2*j)/(i+j)-t0;\n resx:=i;\n resy:=j;\n end;\n end;\n writeln(resx,' ',resy);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var t1,t2,x1,x2,t0,k,h,p,y1d,y2d,y1x,y2x:int64;\n i:longint;\n shang:extended;\nfunction min(x,y:int64):int64;\nbegin\n if x0 do\n begin\n t:=y;\n y:=x mod y;\n x:=t;\n end;\n exit(y);\nend;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t1=t2 then begin writeln(x1,' ',x2);halt end;\n if t0<=t1 then begin writeln(x1,' ',0);halt end;\n if t0>=t2 then begin writeln(0,' ',x2);halt end;\n h:=make(t2-t0,t0-t1);\n k:=min(x1 div((t2-t0)div h),x2 div((t0-t1)div h)\n );\n if k>0 then\n begin\n writeln(((t2-t0)div h)*k,' ',((t0-t1)div h)*k);\n halt;\n end;\n shang:=(t0-t1)/(t2-t0);\n for i:=x1 downto 1 do\n begin\n p:=trunc(i*shang)+1;\n if p>x2 then p:=x2;\n if p*(t2-t0)>(t0-t1)*i then\n begin\n if y1d=0 then begin y1d:=i;y2d:=p end\n else if p*y1db then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000;\n\n end;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=0 to 0 do\n begin y1:=min(trunc(y2*(t0-t2)/(t1-t0)),x1);\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var i,x2,x1,p,pom:longint;\n a,b,t,t1,t2,y1,y2,r1,r2,min,te:real;\nbegin\n readln(t1,t2,x1,x2,t);\n min:=maxlongint;\n a:=1-t1/t;\n b:=1-t2/t;\n if a<>0 then\n for i:=x2 downto 1 do\n begin\n y2:=i;\n y1:=-y2*b/a;\n p:=trunc(y1);\n if y1<0 then pom:=-1 else pom:=1;\n if abs(y1-p)>0.99999999 then p:=p+pom;\n if (y1<0) and (abs(y1-trunc(y1))<0.00000001) then p:=p-1;\n if p>x1 then p:=x1;\n if y1=p then\n begin\n writeln(p,' ',trunc(y2));\n halt;\n end;\n te:=(t1*p+t2*y2)/(p+y2);\n if te-t=t0-0.000000000001 then r:=c else l:=c;\n end;\n r1:=(t1*y1+t2*l)/(y1+l);\n if r1>=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2=0)and(y2>0) )or ((y1>0)and (y2>=0)) do\n begin\n k:=(t1*y1+t2*y2)/(y1+y2)-t0;\n if k<0 then dec(y1)\n else begin\n if kx2 then continue;\n if ((t1*i+t2*j)*(m1+m2)=(t1*m1+m2*t2)*(i+j)) and (i+j>m1+m2) or\n ((t1*m1+m2*t2)*(i+j)>(t1*i+t2*j)*(m1+m2))\n then begin\n m1:=i;\n m2:=j;\n end;\n end;\n j:=-1;\n while jx1 then continue;\n if ((t1*i+t2*j)*(m1+m2)=(t1*m1+m2*t2)*(i+j)) and (i+j>m1+m2) or\n ((t1*m1+m2*t2)*(i+j)>(t1*i+t2*j)*(m1+m2))\n then begin\n m1:=i;\n m2:=j;\n end;\n end;\n writeln(m1,' ',m2);\n\nEnd."}, {"source_code": "var\n t1,t2,x1,x2,t,i,j,r1,r2:int64;\n\nbegin\n read(t1,t2,x1,x2,t);\n if (t1=t2)then begin\n writeln(x1,' ',x2);\n exit;\n end;\n if (t=t1)then begin\n writeln(x1,' ',0);\n exit;\n end;\n if (t=t2)then begin\n writeln(0,' ',x2);\n exit;\n end;\n i:=-1;\n r1:=0;r2:=0;\n while (ix2)then continue;\n if (r1=0)and(r2=0)then begin\n r1:=i;r2:=j;\n end else\n if ((t1*i+t2*j)*(r1+r2)<(t1*r1+t2*r2)*(i+j))then begin\n r1:=i;r2:=j;\n end else\n if ((t1*i+t2*j)*(r1+r2)=(t1*r1+t2*r2)*(i+j))and(i+j>r1+r2)then begin\n r1:=i;r2:=j;\n end;\n end;\n j:=-1;\n while (j=t*((i+1)+j))then i:=i+1;\n if (t1*i+t2*jx1)then continue;\n if (i<0)then continue;\n if (r1=0)and(r2=0)then begin\n r1:=i;r2:=j;\n end else\n if ((t1*i+t2*j)*(r1+r2)<(t1*r1+t2*r2)*(i+j))then begin\n r1:=i;r2:=j;\n end else\n if ((t1*i+t2*j)*(r1+r2)=(t1*r1+t2*r2)*(i+j))and(i+j>r1+r2)then begin\n r1:=i;r2:=j;\n end;\n end;\n writeln(r1,' ',r2);\nend.\n"}, {"source_code": " uses math;\n var t1,t2:int64;\n l,r,c,ay1,ay2,y1,y2,x1,x2:longint;\n rr,t0,r1,r2:extended;\n begin\n readln(t1,t2,x1,x2,t0);\n\n\n rr:=1000000000000000000.0;\n\n if (t0=t1)and(t2=t0) then\n begin\n writeln(x1,' ',x2);\n halt(0);\n end;\n if (t0=t1) then\n begin\n writeln(x1,' ',0);\n halt(0);\n end;\n if (t0=t2) then\n begin\n writeln(0,' ',x2);\n halt(0);\n end;\n\n for y1:=0 to x1 do\n begin\n if y1=0 then\n begin\n rr:=t2;\n ay1:=0;\n ay2:=x2;\n continue;\n end;\n\n l:=0;\n if y1=0 then l:=1;\n\n\n r:=x2;\n\n\n while l+1=t0-0.000000000001 then r:=c else l:=c;\n end;\n r1:=(t1*y1+t2*l)/(y1+l);\n if r1>=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2c+d));\nend;\n\nbegin\n readln(t1,t2,x1,x2,t0);\n if (t1=t2) then begin\n writeln(x1,' ',x2);\n halt(0);\n end;\n if (t1 = t0) then\n if (t2<>t0) or ((t2=t0) and (x1>=x2)) then begin\n writeln(x1,' ',0);\n halt(0);\n end;\n if (t2=t0)then\n if(t1<>t0)or((t1=t0)and(x2>=x1))then begin\n writeln(0,' ',x2);\n halt(0);\n end;\n tm:=0;\n t1m:=x2;\n i:=0;\n while(i<=x1)do begin\n y1:=(i*(t0-t1)+t2-t0-1)div(t2-t0);\n if (y1<=x2)and ok(i,y1,tm,t1m) then begin\n tm:=i;\n t1m:=y1;\n end;\n i:=i+1;\n end;\n writeln(tm,' ',t1m);\n halt(0);\nend.\n"}, {"source_code": "var t1,t2,t0,m1,m2,x1,x2,i,j:int64;\nBegin\n read(t1,t2,x1,x2,t0);\n m1:=0; m2:=0;\n if t0=t2\n then if t0=t1\n then begin\n writeln(x1,' ',x2);\n halt;\n end\n else begin\n writeln(0,' ',x2);\n halt;\n end;\n if t0=t1\n then begin\n writeln(x1,' ',0);\n halt;\n end;\n i:=-1;\n while ix2 then continue;\n if ((t1*i+t2*j)*(m1+m2)=(t1*m1+m2*t2)*(i+j)) and (i+j>m1+m2) or\n ((t1*m1+m2*t2)*(i+j)>(t1*i+t2*j)*(m1+m2))\n then begin\n m1:=i;\n m2:=j;\n end;\n end;\n j:=-1;\n while jx1 then continue;\n if ((t1*i+t2*j)*(m1+m2)=(t1*m1+m2*t2)*(i+j)) and (i+j>m1+m2) or\n ((t1*m1+m2*t2)*(i+j)>(t1*i+t2*j)*(m1+m2))\n then begin\n m1:=i;\n m2:=j;\n end;\n end;\n writeln(m1,' ',m2);\n\nEnd."}, {"source_code": "var t1, t2, x1, x2, t0: Int64;\n x, t, e, min: Extended;\n i, j, r1, r2, max: Int64;\n o: Longint;\nBegin;\n e := 0.000000001;\n read(t1, t2, x1, x2, t0);\n if t2 = t0 then begin\n if t1 = t2 then\n write(x1, ' ' , x2)\n else\n write(0,' ' ,x2);\n halt;\n end;\n\n min := t2;\n max := x2;\n r1 := 0;\n r2 := x2;\n\n for o := 1 to x1 do begin\n i := o;\n x := i * (t0 - t1) / (t2 - t0);\n if trunc(x) = x then\n j := trunc(x)\n else\n j := trunc(x) + 1;\n if x < 0 then\n j := 0;\n if (j <= x2) and (j >= 0) then begin\n t := (t1 * i + t2 * j) / (i + j);\n if ((t < min) or ((abs(t - min) < e) and (i + j > max))) and (t >= t0) then begin\n max := i + j;\n r1 := i;\n r2 := j;\n min := t;\n end;\n end;\n\n j := x2;\n t := (t1 * i + t2 * j) / (i + j);\n if ((t < min) or ((abs(t - min) < e) and (i + j > max))) and (t >= t0) then begin\n max := i + j;\n r1 := i;\n r2 := j;\n min := t;\n end;\n end;\n\n write(r1,' ' ,r2);\nEnd.\n"}, {"source_code": "uses math;\nvar i,yn,ans1,ans2,y1,y2,x1,x2:longint;\n anst,t1,t2,t0,ct:extended;\n begin\n anst:=1000000000000000000;\n readln(t1,t2,x1,x2,t0);\n for y1:=0 to x1 do\n begin\n if t2-t0=0 then yn:=x2 else\n yn:=trunc((y1*(t0-t1))/(t2-t0));\n for i:=-5 to 5 do\n begin\n y2:=yn+i;\n if y2>x2 then continue;\n if y2<0 then continue;\n if (y1+y2)<0.0000001 then continue;\n ct:=(t1*y1+t2*y2)/(y1+y2);\n if (ct>=t0) then\n begin\n if (ct=min(ans1,ans2))) then\n begin\n anst:=ct;\n ans1:=y1;\n ans2:=y2;\n end;\n end;\n end;\n end;\n writeln(ans1,' ',ans2);\n end.\n\n\n\n\n\n\n"}, {"source_code": "Uses math;\nvar f,x,z,y21,y22,y23,t1,t2,x1,x2,t,y1,y2,max,o1,o2:extended;\n i,j:longint;\n begin\n read(t1,t2,x1,x2,t);\n f:=maxlongint;\n for i:=0 to trunc(x1) do\n begin\n y1:=i;\n if(t-t2=0)then z:=x2\n else z:=trunc(y1*(t1-t)/(t-t2));\n for j:=-5 to 5 do\n begin\n y2:=z+j;\n if(y2<=x2)and(y1>=0)and(y2>=0)and(y1+y2>0)then\n begin\n x:=(t1*y1+t2*y2)/(y1+y2);\n if(x>=t)and((x-tmax)))then\n begin\n max:=y1+y2;\n o1:=y1;\n o2:=y2;\n f:=x-t;\n end;\n end;\n end;\n end;\n writeln(o1:0:0,' ',o2:0:0);\n end."}, {"source_code": "uses math;\nvar x1,x2,t1,t2,t0,y1,y2,max1,max2:int64;\ntmin, tcur, tmz, tcz,tmp:int64;\ni:dword;\n\nbegin\ntmin:=maxlongint;\nreadln(t1,t2,x1,x2,t0);\nif t1=t2 then\n begin\n writeln(x1, ' ', x2);\n halt(0);\n end\n else\nif t1=t0 then\n begin\n writeln(x1, ' 0');\n halt(0);\n end\nelse if t2=t0 then\n begin\n writeln('0 ', x2);\n halt(0);\n end;\nfor i:=1 to x1 do\n begin\n y1:=i;\n tmp:=ceil(y1*(t0-t1)/(t2-t0));\n if tmp>x2 then break else y2:=tmp;\n tcur:=t1*y1+t2*y2;\n tcz:=y1+y2;\n //writeln(y1, ' ', y2, ' ', tcur, ' ', tcz, ' ', tmin, ' ', tmz);\n if (tmin=maxlongint) or (tcur*tmzmax1+max2 then\n begin\n max1:=y1;\n max2:=y2;\n end;\n end;\nif max1+max2=0 then\nfor i:=1 to x2 do\n begin\n y2:=i;\n tmp:=floor(y2*(t2-t0)/(t0-t1));\n if tmp>x1 then break else y1:=tmp;\n tcur:=t1*y1+t2*y2;\n tcz:=y1+y2;\n //writeln(y1, ' ', y2, ' ', tcur, ' ', tcz, ' ', tmin, ' ', tmz);\n if (tmin=maxlongint) or (tcur*tmzmax1+max2 then\n begin\n max1:=y1;\n max2:=y2;\n end;\n end;\nwriteln(max1, ' ', max2);\nend.\n"}, {"source_code": "PROGRAM C93;\nuses math;\nconst esp = 0.00000000001;\nvar x1, x2, y1, y2, n, t1, t2, t0 : int64;\n res : double;\n\nprocedure slove;\nvar i : longint; j : int64;\nbegin\n if (t1 = t0) then y1:= x1;\n if (t2 = t0) then y2:= x2;\n if (t1 = t0) or (t2 = t0) then exit;\n res:= maxlongint;\n for i:= 0 to x1 do\n begin\n if i = 0 then j:= x2 else j:= trunc(((t0 - t1) / (t2 - t0)) * i + 0.999999999);\n if (j <= x2) and ((i + j) <> 0) and ((res > (t1 * i + t2 * j) / (i + j) - t0) or (abs(res + t0 - (t1 * i + t2 * j) / (i + j)) < esp)) then\n begin\n y1:= i;\n y2:= j;\n res:= (t1 * i + t2 * j) / (i + j) - t0\n end;\n end;\nend;\n\nBEGIN\n readln(t1, t2, x1, x2, t0);\n slove;\n writeln(y1, ' ', y2);\nEND.\n"}, {"source_code": "const finp='';\n fout='';\n eps=1e-10;\nvar fi,fo:text;\n t1,t2,x1,x2,t0:longint;\nprocedure enter;\nbegin\n assign(fi,finp);reset(fi);\n readln(fi,t1,t2,x1,x2,t0);\n close(fi);\nend;\nfunction min(a:int64;b:longint):int64;\nbegin\n if a < b then exit(a);\n exit(b);\nend;\nfunction max(a:int64;b:longint):int64;\nbegin\n if a < b then exit(b);\n exit(a);\nend;\nprocedure solve;\nvar i,j,tmp1,tmp2,y1,y2:int64;\nbegin\n assign(fo,fout);rewrite(fo);\n if (t1=t0) and (t2=t0) then\n begin\n writeln(fo,x1,' ',x2);\n close(fo);\n exit;\n end;\n if (t1=t0) then\n begin\n writeln(fo,x1,' ',0);\n close(fo);\n exit;\n end;\n if (t2=t0) then\n begin\n writeln(fo,0,' ',x2);\n close(fo);\n exit;\n end;\n j:=1;\n while (j <= x2) do\n begin\n i:=trunc(j*(t2-t0)/(t0-t1)+eps);\n i:=max(min(i,x1),0);\n if j=1 then\n begin\n y1:=i;\n y2:=j;\n j:=j+1;\n continue;\n end;\n tmp1:=(t1*y1+t2*y2)*(i+j);\n tmp2:=(t1*i+t2*j)*(y1+y2);\n if (tmp1 > tmp2) or ((tmp1=tmp2) and (i+j > y1+y2)) then\n begin\n y1:=i;\n y2:=j;\n end;\n j:=j+1;\n end;\n writeln(fo,y1,' ',y2);\n close(fo);\nend;\nbegin\n enter;\n solve;\nend.\n"}, {"source_code": "const finp='';\n fout='';\n eps=1e-10;\nvar fi,fo:text;\n t1,t2,x1,x2,t0:int64;\nprocedure enter;\nbegin\n assign(fi,finp);reset(fi);\n readln(fi,t1,t2,x1,x2,t0);\n close(fi);\nend;\nfunction min(a,b:int64):int64;\nbegin\n if a < b then exit(a);\n exit(b);\nend;\nfunction max(a,b:int64):int64;\nbegin\n if a < b then exit(b);\n exit(a);\nend;\nprocedure solve;\nvar i,j,tmp1,tmp2,y1,y2:int64;\nbegin\n assign(fo,fout);rewrite(fo);\n if (t1=t0) and (t2=t0) then\n begin\n writeln(fo,x1,' ',x2);\n close(fo);\n exit;\n end;\n if (t1=t0) then\n begin\n writeln(fo,x1,' ',0);\n close(fo);\n exit;\n end;\n if (t2=t0) then\n begin\n writeln(fo,0,' ',x2);\n close(fo);\n exit;\n end;\n j:=1;\n while (j <= x2) do\n begin\n i:=trunc(j*(t2-t0)/(t0-t1)+eps);\n i:=max(min(i,x1),0);\n if j=1 then\n begin\n y1:=i;\n y2:=j;\n j:=j+1;\n continue;\n end;\n tmp1:=(t1*y1+t2*y2)*(i+j);\n tmp2:=(t1*i+t2*j)*(y1+y2);\n if (tmp1 > tmp2) or ((tmp1=tmp2) and (i+j > y1+y2)) then\n begin\n y1:=i;\n y2:=j;\n end;\n j:=j+1;\n end;\n writeln(fo,y1,' ',y2);\n close(fo);\nend;\nbegin\n enter;\n solve;\nend.\n"}, {"source_code": "var\n b1,b2,dif:extended;\n t1,t2,x1,x2,tx,x,res:extended;\n i:longint;\nbegin\n readln(t1,t2,x1,x2,tx);\n dif:=1000*1000*1000;\n if (t1=t2) and (t1=tx) then begin\n writeln(x1:0:0,' ',x2:0:0);\n halt;\n end;\n if t1=tx then begin\n writeln(x1:0:0,' ',0);\n halt;\n end;\n if t2=tx then begin\n writeln(0,' ',x2:0:0);\n halt;\n end;\n x:=x1;\n res:=(t1*x+t2*x2)/(x+x2);\n if (res>=tx) and (x<=x1) and (res-tx=tx) and (x<=x1) and (res-tx=dif) then\n if (x+x2>b1+b2) then begin\n b1:=x;\n b2:=x2;\n end;\n while x2>=0 do begin\n x:=x2*(t2-tx)/(tx-t1);\n x:=trunc(x);\n for i:=-40 to 2 do\n begin\n if (x+i=0) and (x2=0) then\n continue;\n if x+i<0 then\n continue;\n res:=(t1*(x+i)+t2*x2)/(x+i+x2);\n if (res>=tx) and (x+i<=x1) and (res-tx=tx) and (x+i<=x1) and (res-tx=dif) then\n if (x+i+x2>b1+b2) then begin\n b1:=x+i;\n b2:=x2;\n end;\n end;\n x2:=x2-1;\n end;\n writeln(b1:0:0,' ',b2:0:0);\nend.\n"}, {"source_code": " const\n fi='';\n var\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\n procedure nhap;\n begin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\n end;\n procedure xuly;\n var\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\n begin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=t2;\n ra1:=0; ra2:=x2;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1)*int64(i);\n dm2:=int64(t2)*int64(k);\n dm3:=int64(k)+int64(i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q+0.5>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1)*int64(i);\n dm2:=int64(t2)*int64(k);\n dm3:=int64(k)+int64(i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\n end;\n begin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\n end."}], "negative_code": [{"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R+}\n{$Q+}\n\nuses\n SysUtils;\n\nconst\n inf = int64(2000000000) * int64(2000000000);\nvar\n t1, t2, t0, x1, x2, i: longint;\n r1, r2, tmp: longint;\n best: extended;\n\nfunction f(a1, a2: longint): extended;\nbegin\n if (a1 = 0) and (a2 = 0) then\n result := inf\n else\n result := (a1 * t1 + a2 * t2) / (a1 + a2);\nend;\n\nfunction binfind(x: longint): longint;\nvar\n l, r: longint;\n m: extended;\nbegin\n l := -1;\n r := x2;\n while (l + 1 < r) do\n begin\n m := f(x, (l + r) div 2);\n if (m < t0) and (m < inf) then\n l := (l + r) div 2\n else\n r := (l + r) div 2;\n end;\n\n if (f(x, r) < t0) then\n result := -1\n else\n result := r;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(t1, t2, x1, x2, t0);\n\n best := inf;\n r1 := -1;\n r2 := -1;\n\n for i := 0 to x1 do\n begin\n tmp := binfind(i);\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))\n )) then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n tmin:real;\n t1,t2,x1,x2,t0,max,r1,r2,y1,y2:int64;\nprocedure init;\nbegin\n assign(input,fi);\n assign(output,fo);\n reset(input);\n rewrite(output);\n readln(t1,t2,x1,x2,t0);\n tmin:=maxlongint;\nend;\n\nprocedure bs;\nvar\n a,b,l,r,mid:int64;\n tmp:real;\n r1:longint;\nbegin\n for r1:=0 to x1 do\n begin\n a:=t1*int64(r1);\n l:=0; r:=2*x2;\n repeat\n mid:=(l+r)div 2;\n if(r1+mid)=0 then\n begin\n if t1>=t0 then\n begin\n if(t1r then break;\n continue;\n end\n else\n tmp:=(a+t2*mid)/(r1+mid);\n if tmp>=t0 then\n begin\n if(tmpr;\n end;\n writeln(y1,' ',y2);\nend;\n\nbegin\n init;\n bs;\nend.\n"}, {"source_code": "var y1: integer;\n te,min,t1,t2,t0,x1,x2,y2,y01,y02: int64;\n dt: real;\nbegin\n readln(t1,t2,x1,x2,t0);\n min:=-1;\n dt:=100000;\n\n if t0<=t1 then writeln(x1,' 0') else if t0>=t2 then writeln('0 ',x2) else begin\n\n for y1:=0 to x1 do begin\n te:=round(int(y1*(t0-t1)/(t2-t0)+0.99999));\n if (te=0)and(t2-t0=0) then dt:=t2-t0;\n if (te<>0)and(te<=x2)and((t1*y1+t2*te)/(te+y1)-t0>-0.001) and ((t1*y1+t2*te)/(te+y1)-t0=min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n if (te<>0)and(abs((t1*y1+t2*te)/(te+y1)-t0-dt)<=0.0001)and(te<=x2)and(te+y1>min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n end;\n\n end;\n writeln(y01,' ',y02);\n readln;\nend."}, {"source_code": "program cf126a;\nconst eps=1e-7;\nvar\n n,i,j,y1:longint;\n an1,an2,y2,t1,t2,x1,x2,t0,dd:int64;\n ans,d:double;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t2=t0 then begin\n writeln(0,' ',x2);\n end;\n\n ans:=1e50;\n for y1:=x1 downto 1 do begin\n d:=(t0*y1-t1*y1)/(t2-t0);\n y2:=trunc(d);\n if y2= 0) and (tmp_v <= x2) then\n tmp := tmp_v\n else\n tmp := -1;\n\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))\n ) or (best = inf)) then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\n\n begin\n readln(t1,t2,x1,x2,t);\n\n mnt:=-10000000;\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\n if t<>t1 then\n begin\n for i:=x2 downto 0 do\n begin\n if (i*(t2-t)/(t-t1)<>trunc(i*(t2-t)/(t-t1))) then\n tt:= trunc(i*(t2-t)/(t-t1))+1 else\n tt:=trunc(i*(t2-t)/(t-t1));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x1 then continue;\n nt:=((t1*tt)+(t2*i))/(tt+i);\n if((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt+1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt+1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n end;\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if (i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,v,x,q:real;\n i,k:longint;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "{$O-}\nUses Math;\nconst eps = 1e-9;\nvar\n\tx1, x2, ans, y2, y1, res, i, n, ai, bi, l, r, m: longint;\n t1, t2, t, otv, gr: extended;\n\nbegin\n\t{$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(t1, t2, x1, x2, t);\n otv := 1e12;\n res := -maxlongint;\n ai := 0; bi := 0;\n for i := x1 downto 0 do begin\n \ty1 := i;\n \tl := 0; r := x2; ans := 0;\n \twhile (l <= r) do begin\n \t\tm := (l + r) shr 1;\n \t\tif (y1 + m = 0) then gr := 0 else\n \t\tgr := (t1 * y1 + t2 * m) / (y1 + m);\n \t\tif gr >= t then begin\n \t\t\tans := 1;\n \t\t\ty2 := m;\n \t \tend;\n \t\tif gr < t then l := m + 1 else r := m - 1;\n \tend;\n \tif (ans > 0) then gr := (t1 * y1 + t2 * y2) / (y1 + y2);\n \tif (ans > 0) and ((otv - abs(gr - t) > 0) or ((abs(gr - t - otv) < eps) and (y1 + y2 > res))) then begin\n \t\totv := abs(gr - t);\n \t\tres := y1 + y2;\n \t\tai := y1;\n \t\tbi := y2;\n \tend;\n \tend;\n \twriteln(ai, ' ', bi);\nend."}, {"source_code": "{$O+,Q-,R-,S-}\nprogram taskC;\n\nuses math,sysutils;\n\nvar\n y2:longint;t,max:extended;t1,t2,x1,x2,t0,y1,ans1,ans2:int64;\n\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n\n read(t1,t2,x1,x2,t0);\n\n max:=maxlongint;ans1:=0;ans2:=0;\n\n if (t1=t0) and (t2=t0) then begin\n write(x1,' ',x2);\n halt;\n end;\n\n if t1=t0 then begin\n write(x1,' ',0);\n halt;\n end;\n\n if t2=t0 then begin\n write(0,' ',x2);\n end;\n\n for y2:=0 to x2 do\n begin\n y1:=((t0-t2)*y2) div (t1-t0);\n if y2=0 then y1:=x1;\n\n t:=(t1*y1+t2*y2)/(y1+y2);\n if t0) and (j<=x1) and ((t1*j+t2*i)/(i+j)-t0>=0) and ((t1*j+t2*i)/(i+j)-t0=0) and ((t1*(j+1)+t2*i)/(i+j+1)-t0=t0\n then l:=k\n else r:=k;\n end;\n if ((t1*l+t2*i)/(l+i)-t0L1+r1))\n then begin minraz:=(t1*l+t2*i) / (i+l)-t0; l1:=l; r1:=i; end;\n end;\n writeln(l1,' ',r1);\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-10; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,y2,t0,nn,ot,mmax,w,t,kol,i,j,m,k,imax,p,h,jj:longint;\nn,s,step2:int64;\nblizt:array[0..2000000,-1..2] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl+eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "\nvar n,m,i,j,t,l,r,yy,zz,ii,jj:longint;\n j1,tt,tt1,t1,t2,x1,x2,t0:longint;\n\n k,min:extended;\nprocedure prov(j1:longint);\nbegin\n k:=(t1*i+t2*j1)/(i+j1);\n k:=k-t0;\n if k<0 then exit;\n if k<=min then begin\n ii:=i;\n jj:=j1;\n min:=k;\n end;\n\nend;\n\nbegin\n\n read(t1,t2,x1,x2,t0);\n tt:=t2-t0;\n tt1:=t0-t1;\n min:=t2;\n if tt1=0 then begin\n write( x1,' 0');\n halt;\n end;\n if tt=0 then begin\n write( '0 ',x2);\n halt;\n end;\n for i:=1 to x1 do\n begin\n j:=trunc(tt1/tt*i);\n if (j>x2)or(j<=0) then continue;\n prov(j);\n prov(j+1);\n\n end;\n\n write(ii,' ',jj);\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R+}\n{$Q+}\n\nuses\n SysUtils;\n\nconst\n inf = int64(2000000000) * int64(2000000000);\nvar\n t1, t2, t0, x1, x2, i: longint;\n r1, r2, tmp: longint;\n best, t: extended;\n tmp_v: int64;\n\nfunction f(a1, a2: longint): extended;\nbegin\n if (a1 = 0) and (a2 = 0) then\n result := inf\n else\n result := (a1 * t1 + a2 * t2) / (a1 + a2);\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(t1, t2, x1, x2, t0);\n\n best := inf;\n r1 := -1;\n r2 := -1;\n\n if (t0 = t1) and (t0 = t2) then\n begin\n writeln(x1, ' ', x2);\n halt(0);\n end;\n\n if (t0 = t2) then\n begin\n writeln(0, ' ', x2);\n halt(0);\n end;\n\n for i := 0 to x1 do\n begin\n\n t := i * (t0 - t1) / (t2 - t0);\n if (trunc(t) = t) then\n tmp_v := trunc(t)\n else\n tmp_v := trunc(i * (t0 - t1) / (t2 - t0)) + 1;\n\n if (tmp_v >= 0) and (tmp_v <= x2) then\n tmp := tmp_v\n else\n tmp := -1;\n\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))\n ) or (best = inf)) then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min,x : longint;\n px,tx,mint,fx : extended;\n ok : boolean;\n\n function _round(x : extended) : longint;\n begin\n _round:=round(x);\n end;\n\nbegin\n {assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n if (t1=t0) and (t2=t0)\n then\n if (x1>=x2) then begin minx:=x1; minf:=0; end\n else begin minx:=0; minf:=x2; end\n else begin\n if (t1=t0) then begin minx:=x1; minf:=0; end;\n if (t2=t0) then begin minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n if (fx<=mint) and (fx>=0) then\n if (x+f>min) or ((fx=0)) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n end;\n end; \n end;\n end;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q+0.5>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n oo=1000000000000000;\nvar\n f:Text;\n res1,res2,y1,y2,t1,t2,x1,x2,t0:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(res1,' ',res2);\n close(f);\nend;\nprocedure process;\nvar z,tmin:real;i1,i2:int64;\nbegin\n if (t1=t0) and (t2=t0) then\n begin\n res1:=x1;\n res2:=x2;\n exit;\n end;\n if t1=t0 then\n begin\n res1:=x1;\n res2:=0;\n exit;\n end;\n z:=(t0-t2)/(t1-t0);\n if x1>z*x2 then\n begin\n y1:=x2;\n y2:=x2;\n end\n else\n begin\n y1:=x1;\n y2:=x2;\n end;\n res1:=0;\n res2:=0;\n tmin:=oo;\n i2:=y2;\n while i2>=1 do\n begin\n i1:=trunc(i2*z);\n if i1<=x1 then\n if (t1*i1+t2*i2)/(i1+i2)>=t0 then\n begin\n if abs((t1*i1+t2*i2)/(i1+i2)-tmin)<0.0000001 then\n begin\n if (i1+i2)>(res1+res2) then\n begin\n res1:=i1;\n res2:=i2;\n end;\n end\n else\n if (t1*i1+t2*i2)/(i1+i2)x2 then begin\n dif:=x1;\n x1:=x2;\n x2:=dif;\n dif:=t1;\n t1:=t2;\n t2:=dif;\n swap:=true;\n end;\n dif:=1000*1000*1000;\n if (t1=t2) and (t1=tx) then begin\n writeln(x1:0:0,' ',x2:0:0);\n halt;\n end;\n if t1=tx then begin\n writeln(x1:0:0,' ',0);\n halt;\n end;\n if t2=tx then begin\n writeln(0,' ',x2:0:0);\n halt;\n end;\n x:=x1;\n res:=(t1*x+t2*x2)/(x+x2);\n if (res>=tx) and (x<=x1) and (res-tx=tx) and (x<=x1) and (res-tx=dif) then\n if (x+x2>b1+b2) then begin\n b1:=x;\n b2:=x2;\n end;\n while x2>=0 do begin\n x:=x2*(t2-tx)/(tx-t1);\n x:=trunc(x);\n for i:=-40 to 2 do\n begin\n if (x+i=0) and (x2=0) then\n continue;\n if x+i<0 then\n continue;\n res:=(t1*(x+i)+t2*x2)/(x+i+x2);\n if (res>=tx) and (x+i<=x1) and (res-tx=tx) and (x+i<=x1) and (res-tx=dif) then\n if (x+i+x2>b1+b2) then begin\n b1:=x+i;\n b2:=x2;\n end;\n end;\n x2:=x2-1;\n end;\n if swap then\n writeln(b2:0:0,' ',b1:0:0)\n else\n writeln(b1:0:0,' ',b2:0:0);\nend.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n e=0.0000001;\nVar\n t1,t2,x1,x2,t0,t,j:Int64;\n i1,j1,i:Integer;\n r,s,t3:Real;\nBegin\n Read(t1,t2,x1,x2,t0);\n If (t1=t2) and (t2=t0) Then Begin\n If x1=x2 Then Write(x1,' ',x2)\n Else If x1>x2 Then Write(x1,' ',0)\n Else Write(0,' ',x2);\n Halt;\n End;\n If t0=t1 Then Begin\n If (t0=t2) and (x2>x1) Then Write(0,' ',x2)\n Else Write(x1,' ',0);\n Halt;\n End;\n If t0=t2 Then Begin\n Write(0,' ',x2);\n Halt;\n End;\n r:=High(Integer);\n t:=High(Integer);\n i1:=0;\n j1:=0;\n For i:=0 To x1 Do Begin\n s:=i*(t1-t0)/(t0-t2);\n j:=Round(s);\n If jx2 Then j:=x2;\n If j<0 Then j:=0;\n If (i=0) and (j=0) Then Continue;\n t3:=(t1*i+t2*j)/(i+j);\n If t3>=t0 Then Begin\n If (abs(t3-t0-r)t) Then Begin\n t:=i+j;\n i1:=i;\n j1:=j;\n End\n Else If t3-t00) and (j1<>0) Then Write(i1,' ',j1)\n Else Begin\n If (t1=t0) and (x1>x2) Then Write(x1,' ',0)\n Else Write(0,' ',x2);\n End;\nEnd.\n\n"}, {"source_code": "{$O-}\nUses Math;\nconst eps = 1e-9;\nvar\n\tx1, x2, ans, y2, y1, res, i, n, ai, bi, l, r, m: longint;\n t1, t2, t, otv, gr: extended;\n\nbegin\n\t{$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(t1, t2, x1, x2, t);\n otv := 1e12;\n res := -maxlongint;\n ai := 0; bi := 0;\n for i := x1 downto 0 do begin\n \ty1 := i;\n \tl := 0; r := x2; ans := 0;\n \twhile (l <= r) do begin\n \t\tm := (l + r) shr 1;\n \t\tif (y1 + m = 0) then gr := 0 else\n \t\tgr := (t1 * y1 + t2 * m) / (y1 + m);\n \t\tif gr >= t then begin\n \t\t\tans := 1;\n \t\t\ty2 := m;\n \t \tend;\n \t\tif gr < t then l := m + 1 else r := m - 1;\n \tend;\n \tif (ans > 0) then gr := (t1 * y1 + t2 * y2) / (y1 + y2);\n \tif (ans > 0) and ((otv - abs(gr - t) > 0) or ((abs(gr - t - otv) < eps) and (y1 + y2 > res))) then begin\n \t\totv := abs(gr - t);\n \t\tres := y1 + y2;\n \t\tai := y1;\n \t\tbi := y2;\n \tend;\n \tend;\n \twriteln(ai, ' ', bi);\nend."}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min,x : longint;\n px,tx,mint,fx : extended;\n ok : boolean;\n\n function _round(x : extended) : longint;\n begin\n _round:=trunc(x);\n end;\n\nbegin\n { assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n if (t1=t0) and (t2=t0)\n then\n if (x1>=x2) then begin minx:=x1; minf:=0; end\n else begin minx:=0; minf:=x2; end\n else begin\n if (t1=t0) then begin minx:=x1; minf:=0; end;\n if (t2=t0) then begin minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n if (fx<=mint) and (fx>=0) then\n if (x+f>min) or ((fx=0)) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n end;\n end; \n end;\n end;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "var t1,t2,t0,max1,max2:int64;\n i,j,x1,x2:longint;\nBegin\n read(t1,t2,x1,x2,t0);\n max1:=0; max2:=0;\n if t0=t2\n then if t0=t1\n then begin\n writeln(x1,' ',x2);\n halt;\n end\n else begin\n writeln(0,' ',x2);\n halt;\n end;\n if t0=t1\n then begin\n writeln(x1,' ',0);\n halt;\n end;\n\n for i:=0 to x1 do\n begin\n j:=(t1*i-t0*i) div (t0-t2);\n if (i=0) and (j=0) then j:=1;\n while (t1*i+t2*jx2 then continue;\n if ((t1*i+t2*j)*(max1+max2)=(t1*max1+max2*t2)*(i+j)) and (i+j>max1+max2) or\n ((t1*max1+max2*t2)*(i+j)>t1*i+t2*j) and (t1*i+t2*j>t0*(i+j))\n then begin\n max1:=i;\n max2:=j;\n end;\n end;\n for j:=0 to x2 do\n begin\n i:=(t2*j-t0*j) div (t0-t1);\n if (i=0) and (j=0) then i:=1;\n while ((t1*i+t2*j)x2 then continue;\n if ((t1*i+t2*j)*(max1+max2)=(t1*max1+max2*t2)*(i+j)) and (i+j>max1+max2) or\n ((t1*max1+max2*t2)*(i+j)>t1*i+t2*j) and (t1*i+t2*j>t0*(i+j))\n then begin\n max1:=i;\n max2:=j;\n end;\n end;\n writeln(max1,' ',max2);\n\nEnd."}, {"source_code": "{$O+,Q-,R-,S-}\nprogram taskC;\n\nuses math,sysutils;\n\nvar\n y2:longint;t,max:extended;t1,t2,x1,x2,t0,y1,ans1,ans2:int64;\n\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n\n read(t1,t2,x1,x2,t0);\n\n max:=maxlongint;ans1:=0;ans2:=0;\n\n if (t1=t0) and (t2=t0) then begin\n write(x1,' ',x2);\n halt;\n end;\n\n if t1=t0 then begin\n write(x1,' ',0);\n halt;\n end;\n\n if t2=t0 then begin\n write(0,' ',x2);\n end;\n\n for y2:=0 to x2 do\n begin\n y1:=((t0-t2)*y2) div (t1-t0);\n if y2=0 then y1:=x1;\n\n t:=(t1*y1+t2*y2)/(y1+y2);\n if t0 then\n t:=(t1*i+t2*k)/(i+k)\n else t:=maxlongint;\n if s>t then\n begin\n s:=t;\n y1:=i;\n y2:=k;\n end\n else\n if (s=t)and(y1+y2x2 then continue;\n if y2<0 then continue;\n if (y1+y2)<0.0000001 then continue;\n ct:=(t1*y1+t2*y2)/(y1+y2);\n if (ct>=t0) then\n begin\n if (ct=min(ans1,ans2))) then\n begin\n anst:=ct;\n ans1:=y1;\n ans2:=y2;\n end;\n end;\n end;\n end;\n writeln(ans1,' ',ans2);\n end.\n\n\n\n\n\n\n"}, {"source_code": "var\n b1,b2,dif:extended;\n t1,t2,x1,x2,tx,x,res:extended;\n i:longint;\nbegin\n readln(t1,t2,x1,x2,tx);\n dif:=1e10;\n if (t1=t2) and (t1=tx) then begin\n writeln(x1:0:0,' ',x2:0:0);\n halt;\n end;\n if t1=tx then begin\n writeln(x1:0:0,' ',0);\n halt;\n end;\n if t2=tx then begin\n writeln(0,' ',x2:0:0);\n halt;\n end;\n while x2>=0 do begin\n x:=x2*(t2-tx)/(tx-t1);\n x:=trunc(x);\n for i:=-40 to 2 do\n begin\n if (x+i=0) and (x2=0) then\n continue;\n if x+i<0 then\n continue;\n res:=(t1*(x+i)+t2*x2)/(x+i+x2);\n if (res>=tx) and (x+i<=x1) and (res-tx=tx) and (x+i<=x1) and (res-tx=dif) then\n if (x+i+x2>b1+b2) then begin\n b1:=x+i;\n b2:=x2;\n end;\n end;\n x2:=x2-1;\n end;\n writeln(b1:0:0,' ',b2:0:0);\nend."}, {"source_code": "const\n fi='';\n fo='';\n oo=1000000000000000;\nvar\n f:Text;\n res1,res2,y1,y2,t1,t2,x1,x2,t0:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(res1,' ',res2);\n close(f);\nend;\nprocedure process;\nvar z,tmin:real;i1,i2:int64;\nbegin\n if (t1=t0) and (t2=t0) then\n begin\n res1:=x1;\n res2:=x2;\n exit;\n end;\n if t1=t0 then\n begin\n res1:=x1;\n res2:=0;\n exit;\n end;\n z:=(t0-t2)/(t1-t0);\n if x1>z*x2 then\n begin\n y1:=x2;\n y2:=x2;\n end\n else\n begin\n y1:=x1;\n y2:=x2;\n end;\n res1:=0;\n res2:=0;\n tmin:=oo;\n i2:=y2;\n while i2>=1 do\n begin\n i1:=round(i2*z);\n if i1<=x1 then\n if (t1*i1+t2*i2)/(i1+i2)>=t0 then\n begin\n if abs((t1*i1+t2*i2)/(i1+i2)-tmin)<0.0000001 then\n begin\n if (i1+i2)>(res1+res2) then\n begin\n res1:=i1;\n res2:=i2;\n end;\n end\n else\n if (t1*i1+t2*i2)/(i1+i2)=x2) then begin ok:=true; minx:=x1; minf:=0; end\n else begin ok:=true; minx:=0; minf:=x2; end\n else begin\n if (t1=t0) then begin ok:=true; minx:=x1; minf:=0; end;\n if (t2=t0) then begin ok:=true; minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n ok:=false;\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n fx:=tx-t0;\n if (fx<=mint) and (fx>=0) then\n if (x+f>min) or ((fx=0)) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n ok:=true;\n end;\n end; \n end;\n end;\n if (not ok) then minf:=x2;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:longint;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if t=t2 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n\n for i:=x1 downto 0 do\n begin\n tt:=round(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\nwriteln(t1m,' ',t2m);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar t1,t2,j,t0,resx,resy:int64;\n i,x1,x2:longint;\n res:extended;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n readln(t1,t2,x1,x2,t0);\n if t2=t0 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n if t1=t0 then\n begin\n writeln(x1,' ',0);\n halt;\n end;\n res:=maxlongint;\n for i:=0 to x1 do\n begin\n if i<>0 then j:=(i*t0-i*t1) div (t2-t0) else j:=x2;\n if (i*t0-i*t1) mod (t2-t0)<>0 then inc(j);\n if (j<=x2) and ((t1*i+t2*j)/(i+j)-t0<=res) then\n begin\n res:=(t1*i+t2*j)/(i+j)-t0;\n resx:=i;\n resy:=j;\n end;\n end;\n writeln(resx,' ',resy);\n close(input);\n close(output);\nend.\n"}, {"source_code": "uses math;\nvar x1,x2,t1,t2,t0,y1,y2,i,j,max1,max2:dword;\ntmin, tcur, tmz, tcz:longint;\n\nbegin\ntmin:=maxlongint;\nreadln(t1,t2,x1,x2,t0);\nif t1=t2 then\n begin\n writeln(x1, ' ', x2);\n halt(0);\n end\n else\nif t1=t0 then\n begin\n writeln(x1, ' 0');\n halt(0);\n end\nelse if t2=t0 then\n begin\n writeln('0 ', x2);\n halt(0);\n end;\nfor y1:=1 to x1 do\n begin\n y2:=ceil(y1*(t0-t1)/(t2-t0));\n if y2>x2 then break;\n tcur:=t1*y1+t2*y2;\n tcz:=y1+y2;\n //writeln(y1, ' ', y2, ' ', tcur, ' ', tcz, ' ', tmin, ' ', tmz);\n if (tmin=maxlongint) or (tcur*tmzmax1+max2 then\n begin\n max1:=y1;\n max2:=y2;\n end;\n end;\nif max1+max2=0 then\nfor y2:=1 to x2 do\n begin\n y1:=floor(y2*(t2-t0)/(t0-t1));\n if y1>x1 then break;\n tcur:=t1*y1+t2*y2;\n tcz:=y1+y2;\n //writeln(y1, ' ', y2, ' ', tcur, ' ', tcz, ' ', tmin, ' ', tmz);\n if (tmin=maxlongint) or (tcur*tmzmax1+max2 then\n begin\n max1:=y1;\n max2:=y2;\n end;\n end;\nwriteln(max1, ' ', max2);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,yy2,t0,nn,ot,mmax,w,t,kol,j,m,k,imax,p,h,jj:int64;\nn,s,step2:int64;\ni,y2:longint;\nblizt:array[0..2000000,-2..3] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\n{if (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000000;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=-1 to 2 do\n begin y1:=trunc(y2*(t0-t2)/(t1-t0));\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,yy2,t0,nn,ot,mmax,w,t,kol,j,m,k,imax,p,h,jj:int64;\nn,s,step2:int64;\ni,y2:longint;\nblizt:array[0..2000000,-2..3] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\n{if (t10)and(y1+i<=x1) then blizt[y2,i]:=(t1*(y1+i)+t2*yy2)/(y1+i+yy2)\n else blizt[y2,i]:=100000000000;\nend;\n\n{for y2:=0 to x2 do\n begin write(y2,' '); for i:=-1 to 2 do write(blizt[y2,i]:0:3,' ');writeln; end;\n}\n\nminotkl:=100000000;\n for y2:=x2 downto 0 do for i:=-1 to 2 do\n begin y1:=trunc(y2*(t0-t2)/(t1-t0));\n if ((y1+i)<=x1)and(blizt[y2,i]>=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl-eps) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "const\n{ fi='hot.inp';\n fo='hot.out';}\n fi='';\n fo='';\n maxn=1;\n eps=1e-9;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n:longint;\n t1,t2,t0,x1,x2,t:int64;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f, t1, t2, x1, x2 , t0);\n close(f);\nend;\n\nprocedure main;\nvar xopt,yopt,y,max:int64;\n x:longint;\n gt,tt,yy,kq:double;\nbegin\n assign(f,fo);rewrite(f);\n if t2=t0 then\n begin\n if t1=t0 then writeln(f,x1,' ',x2)\n else writeln(f,0,' ',x2);\n exit;\n end;\n tt:=(t0-t1)/(t2-t0);\n max:=0;\n kq:=1e15;\n for x:=1 to x1 do\n begin\n yy:=x*tt;\n if yy-trunc(yy)<=eps then y:=trunc(yy)\n else y:=trunc(yy)+1;\n y:=minn(y,x2);\n gt:=(x*t1+y*t2)/(x+y);\n if (gt-t0max)) then\n begin\n kq:=gt-t0;\n max:=x+y;\n xopt:=x;\n yopt:=y;\n end;\n end;\n\n writeln(f,xopt,' ',yopt);\nend;\n\nbegin\n open;\n main;\n close(f);\nend.\n"}, {"source_code": "{$O+,Q-,R-,S-}\nprogram taskC;\n\nuses math,sysutils;\n\nvar\n t1,t2,x1,x2,t0,y2,ans1,ans2:longint;t,max:extended;y1:int64;\n\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n\n read(t1,t2,x1,x2,t0);\n\n max:=maxlongint;ans1:=0;ans2:=0;\n\n if (t1=t0) and (t2=t0) then begin\n write(x1,' ',x2);\n halt;\n end;\n\n if t1=t0 then begin\n write(x1,' ',0);\n halt;\n end;\n\n if t2=t0 then begin\n write(0,' ',x2);\n end;\n\n {for y1:=0 to x1 do\n begin\n y2:=((t0-t1)*y1) div (t2-t0);\n\n if y1=0 then y2:=x2;\n\n t:=(t1*y1+t2*y2)/(y1+y2);\n while (t=t0)and(y2<=x2) then begin\n\n if t=0) then begin\n if y2=0 then y1:=x1;\n\n t:=(t1*y1+t2*y2)/(y1+y2);\n {if t=t0)and(y1<=x1) then begin\n\n if tx2)or(j<=0) then continue;\n prov(j);\n prov(j+1);\n\n end;\n\n if ii=0 then write('0 ',x2) else write(ii,' ',jj);\n\nend.\n"}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-} {$ASSERTIONS ON} {$INLINE ON}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n\n\nprocedure pout;\nbegin\n\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n\nend;\n\nprocedure solve;\nvar t1, t2, x1, x2, t0 : int64;\n t, tt : extended;\n y, yy, y1, y2 : longint;\nbegin\n read(t1, t2, x1, x2, t0);\n y1 := 0;\n y2 := 0;\n if (t1 = t0) or (t2 = t0) then begin\n if (t1 = t0) then begin\n y1 := x1;\n end;\n if (t2 = t0) then begin\n y2 := x2;\n end;\n writeln(y1, ' ', y2);\n halt(0);\n end;\n y1 := 0;\n y2 := 0;\n t := inf;\n for y := 0 to x1 do begin\n yy := (t0 - t1) * y div (t2 - t0);\n if (t0 - t1) * y mod (t2 - t0) > 0 then begin\n inc(yy);\n end;\n if yy + y = 0 then yy := x2;\n if (yy + y > 0) and (yy <= x2) then begin\n //tt := (y * t1 + yy * t2) / (yy + y);\n tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if tt >= t0 then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n for yy := 0 to x2 do begin\n y := (t2 - t0) * yy div (t0 - t1);\n if (t2 - t0) * yy mod (t0 - t1) > 0 then begin\n inc(y);\n end;\n if yy + y = 0 then y := x1;\n if (y + yy > 0) and (y <= x1) then begin\n// tt := (y * t1 + yy * t2) / (yy + y);\n tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if (tt >= t0) then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n writeln(y1, ' ', y2);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "var te,min,i,t1,t2,t0,x1,x2,y1,y2,y01,y02: integer;\n dt: real;\nbegin\n readln(t1,t2,x1,x2,t0);\n min:=-1;\n dt:=100000;\n\n if t0t2 then writeln('0 ',x2) else begin\n\n for y1:=0 to x1 do begin\n te:=round(int(y1*(t0-t1)/(t2-t0)+0.99999));\n if (te=0)and(t2-t0=0) then dt:=t2-t0;\n if (te<>0)and(te<=x2)and((t1*y1+t2*te)/(te+y1)-t0>-0.001) and ((t1*y1+t2*te)/(te+y1)-t0=min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n if (te<>0)and(abs((t1*y1+t2*te)/(te+y1)-t0-dt)<=0.0001)and(te<=x2)and(te+y1>min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n end;\n\n end;\n writeln(y01,' ',y02);\n readln;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R+}\n{$Q+}\n\nuses\n SysUtils;\n\nconst\n inf = int64(2000000000) * int64(2000000000);\nvar\n t1, t2, t0, x1, x2, i: longint;\n r1, r2, tmp: longint;\n best, t: extended;\n tmp_v: int64;\n\nfunction f(a1, a2: longint): extended;\nbegin\n if (a1 = 0) and (a2 = 0) then\n result := inf\n else\n result := (a1 * t1 + a2 * t2) / (a1 + a2);\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(t1, t2, x1, x2, t0);\n\n best := inf;\n r1 := -1;\n r2 := -1;\n\n if (t0 = t1) and (t0 = t2) then\n begin\n writeln(x1, ' ', x2);\n halt(0);\n end;\n\n if (t0 = t1) then\n begin\n writeln(x1, ' ', 0);\n halt(0);\n end;\n\n if (t0 = t2) then\n begin\n writeln(0, ' ', x2);\n halt(0);\n end;\n\n for i := 0 to x1 do\n begin\n\n t := i * (t0 - t1) / (t2 - t0);\n if (trunc(t) = t) then\n tmp_v := trunc(t)\n else\n tmp_v := trunc(i * (t0 - t1) / (t2 - t0)) + 1;\n\n if (tmp_v >= 0) and (tmp_v <= x2) then\n tmp := tmp_v\n else\n tmp := -1;\n\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))\n )) then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "const fi='';\n fo='';\n oo=trunc(1e9);\nvar t1,t2,x1,x2,t0,y1,y2,res1,res2:longint;\n t,min:real;\nprocedure rinf;\nbegin\n assign(input,fi);\n reset(input);\n read(t1,t2,x1,x2,t0);\n close(input);\nend;\n\nfunction ok:boolean;\nbegin\n if (y1+y2=0) then exit(false);\n t:=((y1*t1)+(y2*t2)) / (y1+y2);\n if t>=t0 then exit(true)\n else exit(false);\nend;\n\nprocedure solve;\nvar mid,l,r:longint;\nbegin\n min:=oo;\n for y1:=0 to x1 do\n begin\n l:=0;r:=x2;\n repeat\n y2:=(l+r) div 2;\n if ok then\n begin\n r:=y2-1;\n if (tres1+res2) then\n begin\n res1:=y1;\n res2:=y2;\n end;\n end\n else l:=y2+1;\n until l>r;\n end;\nend;\n\nprocedure winf;\nbegin\n assign(output,fo);\n rewrite(output);\n write(res1,' ',res2);\n close(output);\nend;\n\nbegin\n rinf;\n solve;\n winf;\nend.\n"}, {"source_code": "var\n sum,x1,x2,t0,t1,t2,x,y,i,j:int64; ans,raz:extended;\n\n\nfunction fun(i,j:extended):extended;\nbegin\n exit((t1*i+t2*j)/(i+j));\nend;\n\n\nprocedure dichotomy(i:int64;var j:int64;var raz:extended);\nvar l,r,m:int64; c1,c2:extended;\nbegin\n if i=0 then l:=1 else l:=0; r:=x2;\n while (r-l>1) do\n begin\n m:=(l+r) div 2;\n if fun(i,m)>=t0 then r:=m else l:=m;\n end;\n if (fun(i,l)>=t0) and (fun(i,r)>=t0) then\n begin\n c1:=abs(fun(i,l)-t0); c2:=abs(fun(i,r)-t0);\n if (c1>=c2)\n then begin j:=r; raz:=fun(i,l); end\n else begin j:=l; raz:=fun(i,r); end;\n end\n else\n begin\n if fun(i,l)>=t0 then begin j:=l; raz:=fun(i,l); end else\n if fun(i,r)>=t0 then begin j:=r; raz:=fun(i,r); end else j:=-1;\n end;\n\nend;\n\n\nbegin\n\n readln(t1,t2,x1,x2,t0); ans:=1e18; i:=0;\n while i<=x1 do\n begin\n dichotomy(i,j,raz);\n if (j<>-1) and ((razx2 Then j:=x2;\n If j<0 Then j:=0;\n If (i=0) and (j=0) Then Continue;\n t3:=(t1*i+t2*j)/(i+j);\n If (t3>t0) or (abs(t3-t0)t) Then Begin\n t:=i+j;\n i1:=i;\n j1:=j;\n End\n Else If t3-t00) and (j1<>0) Then Write(i1,' ',j1)\n Else Write(0,' ',x2);\nEnd.\n\n"}, {"source_code": "const eps=1e-7;\nvar t1,t2,x1,x2,t0,max1,max2:int64;\n i,j:longint;\n min,t:extended;\nBegin\n read(t1,t2,x1,x2,t0);\n min:=1e9;\n if t0=t2\n then if t0=t1\n then begin\n writeln(x1,' ',x2);\n halt;\n end\n else begin\n writeln(0,' ',x2);\n halt;\n end;\n if t0=t1\n then begin\n writeln(x1,' ',0);\n halt;\n end;\n\n for i:=1 to x1 do\n begin\n j:=(t1*i-t0*i) div (t0-t2);\n j:=j-1;\n if j=-1 then j:=0;\n t:=(t1*i+t2*j)/(i+j);\n while (tx2 then continue;\n if ((abs(t-min)max1+max2)) or ((min+eps>t) and (t+eps>t0))\n then begin\n min:=t;\n max1:=i;\n max2:=j;\n end;\n end;\n for j:=1 to x2 do\n begin\n i:=(t1*j-t0*j) div (t0-t2);\n i:=i-1;\n if i=-1 then i:=0;\n t:=(t1*i+t2*j)/(i+j);\n while (tx2 then continue;\n if ((abs(t-min)max1+max2)) or ((min+eps>t) and (t+eps>t0))\n then begin\n min:=t;\n max1:=i;\n max2:=j;\n end;\n end;\n writeln(max1,' ',max2);\n\nEnd.\n"}, {"source_code": "program cf126a;\nconst eps=1e-7;\nvar\n n,i,j,y1:longint;\n an1,an2,y2,t1,t2,x1,x2,t0,dd:int64;\n ans,d:double;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t2=t0 then begin\n writeln(0,' ',x2);\n halt;\n end;\n\n ans:=1e50;\n for y1:=x1 downto 1 do begin\n d:=(t0*y1-t1*y1)/(t2-t0);\n y2:=trunc(d);\n if y2x2)or(j=0) then continue;\n k:=tt/tt1-i/j;\n if k<0 then continue;\n if k<=min then begin\n ii:=i;\n jj:=j;\n min:=k;\n end;\n\n end;\n\n write(ii,' ',jj);\n\nend.\n"}, {"source_code": "PROGRAM C93;\nuses math;\nvar x1, x2, y1, y2, n, t1, t2, t0 : int64;\n res : double;\n\nprocedure slove;\nvar i : longint; j : int64;\nbegin\n if (t1 = t0) then\n begin\n y1:= x1;\n exit;\n end;\n if (t2 = t0) then\n begin\n y2:= x2;\n exit;\n end;\n res:= maxlongint;\n for i:= 1 to x2 do\n begin\n j:= trunc(((t2 - t0) / (t0 - t1)) * i);\n if (j <= x1) and (res >= (t1 * j + t2 * i) / (i + j)) then\n begin\n y1:= j;\n y2:= i;\n res:= (t1 * j + t2 * i) / (i + j)\n end;\n end;\nend;\n\nBEGIN\n readln(t1, t2, x1, x2, t0);\n slove;\n writeln(y1, ' ', y2);\nEND."}, {"source_code": "{$Mode ObjFPC}\nconst fi='';\n fo='';\n nmax=1000000;\nvar t0,i,j,x,y,cs,csc:longint;\n t1,t2,x1,x2:qword;\n min:real;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n read(t1,t2,x1,x2,t0);\n x:=t2-t0;\n y:=t0-t1;\n if (x=0) or (y=0) then\n begin\n if x=0 then\n begin\n if y<>0 then write('0 ',x2)\n else write(x1,' ',x2);\n end\n else write(x1,' 0');\n end\n else\n begin\n min:=1e32;\n cs:=0;\n for i:=x2 downto 1 do\n begin\n j:=trunc((i*x)/y);\n if j>x1 then j:=x1;\n if (i+j<>0) and (j<=x1) and ((t1*j+t2*i)/(i+j)-t0>=0) and ((t1*j+t2*i)/(i+j)-t0=0) and ((t1*(j+1)+t2*i)/(i+j+1)-t0t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n{ if t2<>t then\n begin\n if t1<>t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n end;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end; }\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n mnt:=-10000000;\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\n\n if t1<>t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n if t2<>t then\n begin\n if t1<>t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n end;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "{$O-}\nUses Math;\nconst eps = 1e-6;\nvar\n\tx1, x2, ans, y2, y1, res, i, n, ai, bi, l, r, m: longint;\n t1, t2, t, otv, gr: extended;\n\nbegin\n\t{$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(t1, t2, x1, x2, t);\n otv := 1e12;\n res := -maxlongint;\n ai := 0; bi := 0;\n for i := x1 downto 0 do begin\n \ty1 := i;\n \tl := 0; r := x2; ans := 0;\n \twhile (l <= r) do begin\n \t\tm := (l + r) shr 1;\n \t\tif (y1 + m = 0) then break;\n \t\tgr := (t1 * y1 + t2 * m) / (y1 + m);\n \t\tif gr >= t then begin\n \t\t\tans := 1;\n \t\t\ty2 := m;\n \t \tend;\n \t\tif gr < t then l := m + 1 else r := m - 1;\n \tend;\n \tif (ans > 0) then gr := (t1 * y1 + t2 * y2) / (y1 + y2);\n \tif (ans > 0) and ((abs(gr - t) < otv) or ((abs(gr - otv) < eps) and (y1 + y2 > res))) then begin\n \t\totv := abs(gr - t);\n \t\tres := y1 + y2;\n \t\tai := y1;\n \t\tbi := y2;\n \tend;\n \tend;\n \twriteln(ai, ' ', bi);\nend."}, {"source_code": "uses math;\nvar i,yn,ans1,ans2,y1,y2,x1,x2:longint;\n anst,t1,t2,t0,ct:extended;\n begin\n anst:=1000000000000000000;\n readln(t1,t2,x1,x2,t0);\n for y1:=0 to x1 do\n begin\n if t2-t0=0 then yn:=x2 else\n yn:=trunc((y1*(t0-t1))/(t2-t0));\n for i:=-2 to 2 do\n begin\n y2:=yn+i;\n if y2>x2 then continue;\n if y2<0 then continue;\n if (y1+y2)<0.0000001 then continue;\n ct:=(t1*y1+t2*y2)/(y1+y2);\n if (ct>=t0) then\n begin\n if (ct=min(ans1,ans2))) then\n begin\n anst:=ct;\n ans1:=y1;\n ans2:=y2;\n end;\n end;\n end;\n end;\n writeln(ans1,' ',ans2);\n end.\n\n\n\n\n\n\n"}, {"source_code": "PROGRAM C93;\nuses math;\nvar x1, x2, y1, y2, n, t1, t2, t0 : int64;\n res : double;\n\nprocedure slove;\nvar i : longint; j : int64;\nbegin\n if (t1 = t0) then\n begin\n y1:= x1;\n exit;\n end;\n if (t2 = t0) then\n begin\n y2:= x2;\n exit;\n end;\n res:= maxlongint;\n for i:= 1 to x2 do\n begin\n j:= trunc(((t2 - t0) / (t0 - t1)) * i);\n if (j <= x1) and (res >= (t1 * j + t2 * i) / (i + j)) then\n begin\n y1:= j;\n y2:= i;\n res:= (t1 * j + t2 * i) / (i + j)\n end;\n end;\nend;\n\nBEGIN\n readln(t1, t2, x1, x2, t0);\n slove;\n writeln(y1, ' ', y2);\nEND."}, {"source_code": "const eps=1e-8;\nvar t1,t2,x1,x2,t0,i,j,max1,max2:longint;\n min,t:extended;\nBegin\n read(t1,t2,x1,x2,t0);\n min:=1e9;\n if t0=t2\n then if t0=t1\n then begin\n writeln(x1,' ',x2);\n halt;\n end\n else begin\n writeln(0,' ',x2);\n halt;\n end;\n if t0=t1\n then begin\n writeln(x1,' ',0);\n halt;\n end;\n\n for i:=1 to x1 do\n begin\n j:=(t1*i-t0*i) div (t0-t2);\n j:=j-1;\n if j=-1 then j:=0;\n t:=(t1*i+t2*j)/(i+j);\n while (t>=t0) and (j>0) do\n begin\n j:=j-1;\n t:=(t1*i+t2*j)/(i+j);\n end;\n while (tx2 then continue;\n if ((abs(t-min)max1+max2)) or ((min+eps>t) and (t+eps>t0))\n then begin\n min:=t;\n max1:=i;\n max2:=j;\n end;\n end;\n for j:=1 to x1 do\n begin\n i:=(t1*j-t0*j) div (t0-t2);\n i:=i-1;\n if i=-1 then i:=0;\n t:=(t1*i+t2*j)/(i+j);\n while (t>=t0) and (i>0) do\n begin\n i:=i-1;\n t:=(t1*i+t2*j)/(i+j);\n end;\n while (tx2 then continue;\n if ((abs(t-min)max1+max2)) or ((min+eps>t) and (t+eps>t0))\n then begin\n min:=t;\n max1:=i;\n max2:=j;\n end;\n end;\n writeln(max1,' ',max2);\n\nEnd.\n"}, {"source_code": "var t1,t2,x1,x2,t0,k,h,p,y1d,y2d,y1x,y2x:int64;\n i:longint;\n shang:extended;\nfunction min(x,y:int64):int64;\nbegin\n if x0 do\n begin\n t:=y;\n y:=x mod y;\n x:=t;\n end;\n exit(y);\nend;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t0<=t1 then begin writeln(x1,' ',0);halt end;\n if t0>=t2 then begin writeln(0,' ',x2);halt end;\n h:=make(t2-t0,t0-t1);\n k:=min(x1 div((t2-t0)div h),x2 div((t0-t1)div h)\n );\n if k>0 then\n begin\n writeln(((t2-t0)div h)*k,' ',((t0-t1)div h)*k);\n halt;\n end;\n shang:=(t0-t1)/(t2-t0);\n for i:=x1 downto 1 do\n begin\n p:=trunc(i*shang)+1;\n if p>x2 then p:=x2;\n if p*(t2-t0)>(t0-t1)*i then\n begin\n if y1d=0 then begin y1d:=i;y2d:=p end\n else if p*y1d 1 do\n begin\n x := (l + r) div 2;\n if temp(y2, x) < t0 then\n r := x\n else\n l := x;\n end;\n if (temp(y2, l) = mint) and (y2 + l > miny2 + miny1) then\n begin\n mint := temp(y2, l);\n miny2 := y2;\n miny1 := l;\n end;\n if (temp(y2, l) >= t0) and (temp(y2, l) < mint) then\n begin\n mint := temp(y2, l);\n miny2 := y2;\n miny1 := l;\n end;\n end;\n\n writeln(miny1,' ', miny2);\n\n\nend.\n "}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n mnt:=-10000000;\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\n\n if t1<>t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n{ if t2<>t then\n begin\n if t1<>t then\n begin\n tt:=x2;\n x2:=x1;\n x1:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n end;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))<=0.00000001) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end; }\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,y2,t0,nn,ot,mmax,w,t,kol,i,j,m,k,imax,p,h,jj:longint;\nn,s,step2:int64;\nblizt:array[0..2000000,-1..2] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i=t0)and (abs(blizt[y2,i]-t0)<=minotkl) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y1bl,' ',y2bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "uses math;\nvar t1,t2,x1,x2,t:longint;\n y1,y2:int64;\n\nprocedure th1;\nbegin\n if 2*min(x1,x2) > max(x1,x2) then\n begin\n y1:=min(x1,x2);\n y2:=y1;\n end\n else\n begin\n y1:=0;\n y2:=0;\n if x1>x2 then y1:=x1 else y2:=x2;\n end;\nend;\n\nprocedure th2;\nbegin\n y1:=x1;\n y2:=0;\nend;\n\nprocedure th3;\nbegin\n y1:=0;\n y2:=x2;\nend;\n\nprocedure th4;\nvar i,j:longint;\n k1,k2:int64;\n s:real;\nbegin\n k1:=t2-t;\n k2:=t-t1;\n j:=1;\n y1:=0;\n y2:=x2;\n\n for i:=1 to x1 do\n begin\n while k2*i > k1*j do\n begin\n inc(j);\n if j>x2 then exit;\n end;\n if y1*j <= y2*i then\n begin\n y1:=i;\n y2:=j;\n end;\n end;\nend;\n\nbegin\n readln(t1,t2,x1,x2,t);\n if (t=t1) and (t=t2) then th1\n else if t=t1 then th2\n else if t=t2 then th3\n else th4;\n writeln(y1,' ',y2);\n readln;\nend."}, {"source_code": "var t1, t2, x1, x2, t0: Longint;\n x, t, e, min: Extended;\n i, j, r1, r2, max: Longint;\n\nBegin;\n e := 0.000000001;\n read(t1, t2, x1, x2, t0);\n if t2 = t0 then begin\n if t1 = t2 then\n write(x1, ' ' , x2)\n else\n write(0,' ' ,x2);\n halt;\n end;\n\n min := t2;\n max := x2;\n r1 := 0;\n r2 := x2;\n\n for i := 1 to x1 do begin\n x := i * (t0 - t1) / (t2 - t0);\n if trunc(x) = x then\n j := trunc(x)\n else\n j := trunc(x) + 1;\n if x < 0 then\n j := 0;\n if (j <= x2) and (j >= 0) then begin\n t := (t1 * i + t2 * j) / (i + j);\n if ((t < min) or ((abs(t - min) < e) and (i + j > max))) and (t >= t0) then begin\n max := i + j;\n r1 := i;\n r2 := j;\n min := t;\n end;\n end;\n\n j := x2;\n t := (t1 * i + t2 * j) / (i + j);\n if ((t < min) or ((abs(t - min) < e) and (i + j > max))) and (t >= t0) then begin\n max := i + j;\n r1 := i;\n r2 := j;\n min := t;\n end;\n end;\n\n write(r1,' ' ,r2);\nEnd."}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,v,x,q:real;\n i,k:longint;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "var te,min,i,t1,t2,t0,x1,x2,y1,y2,y01,y02: integer;\n dt: real;\nbegin\n readln(t1,t2,x1,x2,t0);\n min:=-1;\n dt:=100000;\n\n if t0t2 then writeln('0 ',x2) else begin\n\n for y1:=0 to x1 do begin\n te:=round(int(y1*(t0-t1)/(t2-t0)+0.99999));\n if (te=0)and(t2-t0=0) then dt:=t2-t0;\n if (te<>0)and(te<=x2)and((t1*y1+t2*te)/(te+y1)-t0>-0.001) and ((t1*y1+t2*te)/(te+y1)-t0=min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n if (te<>0)and(abs((t1*y1+t2*te)/(te+y1)-t0-dt)<=0.0001)and(te<=x2)and(te+y1>min) then begin\n min:=te+y1;\n y01:=y1;\n y02:=te;\n end;\n end;\n\n end;\n writeln(y01,' ',y02);\n readln;\nend."}, {"source_code": "var i,x2:longint;\n a,b,t,t1,t2,x1,y1,y2:real;\nbegin\n readln(t1,t2,x1,x2,t);\n a:=1-t1/t;\n b:=1-t2/t;\n for i:=x2 downto 0 do\n begin\n y2:=i;\n if (y2*b)/a=trunc((y2*b)/a) then\n begin\n y1:=-y2*b/a;\n break;\n end;\n end;\n writeln(trunc(y1),' ',trunc(y2));\nend."}, {"source_code": "Var N,M,i,j,k,l,v,r,t1,t2,t0,x1,x2,minx1,minx2:longint;\nt,t3:real;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nreadln(t1,t2,x1,x2,t0);\nt:=1000000000;\nv:=0;\nFor i:=0 to x1 do begin\n l:=0;\n r:=x1;\n While l<=r do begin\n m:=(l+r) div 2;\n if (i<>0) or (m<>0) then\n t3:=((t1*i)+(t2*m))/(i+m)\n else\n t3:=0;\n if t3m+t) then begin\n t:=t3-t0;\n v:=m+i;\n minx1:=i;\n minx2:=m;\n end;\n if t3-t0x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\nwriteln(t1m,' ',t2m);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R+}\n{$Q+}\n\nuses\n SysUtils;\n\nconst\n inf = int64(2000000000) * int64(2000000000);\nvar\n t1, t2, t0, x1, x2, i: longint;\n r1, r2, tmp: longint;\n best: extended;\n\nfunction f(a1, a2: longint): extended;\nbegin\n if (a1 = 0) and (a2 = 0) then\n result := inf\n else\n result := (a1 * t1 + a2 * t2) / (a1 + a2);\nend;\n\nfunction binfind(x: longint): longint;\nvar\n l, r: longint;\n m: extended;\nbegin\n l := -1;\n r := x2;\n while (l + 1 < r) do\n begin\n m := f(x, (l + r) div 2);\n if (m < t0) or (m = inf) then\n l := (l + r) div 2\n else\n r := (l + r) div 2;\n end;\n\n if (f(x, r) < t0) then\n result := -1\n else\n result := r;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n read(t1, t2, x1, x2, t0);\n\n best := inf;\n r1 := -1;\n r2 := -1;\n\n for i := 0 to x1 do\n begin\n tmp := binfind(i);\n if (tmp <> -1) and (((best - t0) > (f(i, tmp) - t0)) or\n (((best - t0) = (f(i, tmp) - t0)) and ((r1 + r2) < (i + tmp))\n )) then\n begin\n r1 := i;\n r2 := tmp;\n best := f(i, tmp);\n end;\n end;\n\n writeln(r1, ' ', r2);\n\nend.\n"}, {"source_code": "{$mode delphi}\nprogram Project1;\nUses SysUtils, Math;\nvar y2,t1,t2,x1,x2,t,y1:longint;\n\t\tmin,t0:extended;\n miny1,miny2:int64;\nfunction f(y1,y2:longint):extended;\nvar l:extended;\nbegin\n\tl:= t1 * (y1 / (y1 + y2)) + t2 * (y2 / (y1 + y2)) - t;\n f:=l;\nend;\nprocedure check (y1,y2:int64);\n\tbegin\n \t//if (y1=33332) then writeln('a ', y2, ' ', (t1*y1 + t2*y2) / (y1 + y2), ' xx ', (t1*miny1 + t2*miny2) / (miny1 + miny2));\n\n \tif (y2 > x2) or (y2<0) then exit\n \telse if t*(y1 + y2) <= t1*y1 + t2*y2 then\n\n if (miny1=-1) or ((t1*y1 + t2*y2) / (y1 + y2) < (t1*miny1 + t2*miny2) / (miny1 + miny2)) then begin\n \tminy1:=y1;\n miny2:=y2;\n //writeln(miny1, ' ', miny2);\n end;\n end;\nbegin\n\t//assign (input,'input.txt'); reset (input);\n //assign (output,'output.txt'); rewrite (output);\n read (t1,t2,x1,x2,t);\n if t2 = t then begin\n \twrite (0,' ',x2);\n \texit;\n end;\n if t1 = t then begin\n \twrite (x1,' ',0);\n \texit;\n end;\n min:=1000001;\n t0 := (t - t1) / (t2 - t);\n {if min > f(0,x2) then begin\n min:= f(0,x2);\n miny1:= 0;\n miny2:=x2;\n end;}\n miny1:=-1;\n for y1:=x1 downto 1 do begin\n y2:= round (y1 * t0);\n check (y1,y2-1);\n check (y1,y2);\n check (y1,y2+1);\n end;\n if miny1 = -1 then if t1 < t2 then begin\n miny1:=0;\n \tminy2:=x2;\n end else begin\n miny2:=x2;\n miny1:=x1;\n end;\n write (miny1,' ',miny2);\nend.\n"}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min,x : longint;\n px,tx,mint,fx : extended;\n\n function _round(x : extended) : longint;\n begin\n if (frac(x)>=0.5) then _round:=trunc(x)+1\n else _round:=trunc(x);\n end;\n\nbegin\n {assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n if (tx-t0<0) then fx:=t0-tx else fx:=tx-t0;\n if (x+f>min) and (fx<=mint) and (tx>=t0) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n end;\n end;\n end;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,y2,t0,nn,ot,mmax,w,t,kol,i,j,m,k,imax,p,h,jj:longint;\nn,s,step2:int64;\nblizt:array[0..2000000,-1..2] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y2bl,' ',y1bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "uses math;\nvar t1,t2:int64;\nl,r,c,ay1,ay2,y1,y2,x1,x2:longint;\nrr,t0,r1,r2:extended;\n begin\n readln(t1,t2,x1,x2,t0);\n\n\n rr:=1000000000000000000.0;\n\n if (t0=t1)and(t2=t0) then\n begin\n writeln(x1,' ',x2);\n halt(0);\n end;\n if (t0=t1) then\n begin\n writeln(x1,' ',0);\n halt(0);\n end;\n if (t0=t2) then\n begin\n writeln(0,' ',x2);\n halt(0);\n end;\n\n for y1:=0 to x1 do\n begin\n if y1=0 then\n begin\n rr:=t2;\n ay1:=0;\n ay2:=y2;\n end;\n\n l:=0;\n if y1=0 then l:=1;\n\n\n r:=x2;\n\n\n while l+1=t0-0.000000000001 then r:=c else l:=c;\n end;\n r1:=(t1*y1+t2*l)/(y1+l);\n if r1>=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2=t0-0.00000000001 then\n begin\n if abs(r1-rr)<0.0000000001 then\n begin\n if ay1+ay2 0) and (res > (t1 * i + t2 * j) / (i + j) - t0) or (abs(res + t0 - (t1 * i + t2 * j) / (i + j)) < esp) then\n begin\n y1:= i;\n y2:= j;\n res:= (t1 * i + t2 * j) / (i + j) - t0\n end;\n end;\nend;\n\nBEGIN\n readln(t1, t2, x1, x2, t0);\n slove;\n writeln(y1, ' ', y2);\nEND.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\n{type int64=longint; }\nconst\n eps=1e-13; nnn=2000000;\n label 1;\nvar t1,t2,x1,x2,y1,y2,t0,nn,ot,mmax,w,t,kol,i,j,m,k,imax,p,h,jj:longint;\nn,s,step2:int64;\nblizt:array[0..2000000,-1..2] of double;\nminotkl:double; y1bl,ibl,y2bl:longint;\n\nflag,flagggg:boolean;\nott:double;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction pr(n:longint):boolean; var i,j:longint;flag:boolean;\n begin flag:=true;\n for i:=2 to n-1 do if n mod i=0 then flag:=false;\n pr:=flag;\n end;\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n}read(t1,t2,x1,x2,t0);\nif (t1=t0)and(t2=t0) then begin writeln(x1,' ',x2);goto 1; end;\nif (t1=t0)and(t2>t0) then begin writeln(x1,' ',0);goto 1; end;\nif (t10)and(y1+i=t0-eps)and (abs(blizt[y2,i]-t0)<=minotkl) then\n begin\n y2bl:=y2;\n ibl:=i;minotkl:=abs(blizt[y2,i]-t0) ;\n y1bl:=y1+i;\n {writeln('ttt ',y2,' ',y1); }\n end;\n\n end;\nwriteln(y2bl,' ',y1bl);\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,'dfg ',x2);\n halt;\n end;\n\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+1;\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt-2;\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t1m,' ',t2m);\n end else\n begin\n tt:=x2;\n x2:=x1;\n x2:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+1;\n\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt-2;\n\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t2m,' ',t1m);\n end;\n\nend.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q+0.5>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-} {$ASSERTIONS ON} {$INLINE ON}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n\n\nprocedure pout;\nbegin\n\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n\nend;\n\nprocedure solve;\nvar t1, t2, x1, x2, t0 : int64;\n t, tt : extended;\n y, yy, y1, y2 : longint;\nbegin\n read(t1, t2, x1, x2, t0);\n y1 := 0;\n y2 := 0;\n if (t1 = t0) or (t2 = t0) then begin\n if (t1 = t0) then begin\n y1 := x1;\n end;\n if (t2 = t0) then begin\n y2 := x2;\n end;\n writeln(y1, ' ', y2);\n halt(0);\n end;\n y1 := 0;\n y2 := 0;\n t := inf;\n for y := 0 to x1 do begin\n yy := (t0 - t1) * y div (t2 - t0);\n if (t0 - t1) * y mod (t2 - t0) > 0 then begin\n inc(yy);\n end;\n if yy + y = 0 then inc(yy);\n if (yy + y > 0) and (yy <= x2) then begin\n //tt := (y * t1 + yy * t2) / (yy + y);\n tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if tt >= t0 then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n for yy := 0 to x2 do begin\n y := (t2 - t0) * yy div (t0 - t1);\n if (t2 - t0) * yy mod (t0 - t1) > 0 then begin\n inc(y);\n end;\n if yy + y = 0 then inc(y);\n if (y + yy > 0) and (y <= x1) then begin\n// tt := (y * t1 + yy * t2) / (yy + y);\n tt := (y / (yy + y)) * t1 + (yy/(yy + y)) * t2;\n if (tt >= t0) then begin\n if tt = t then begin\n if (y + yy) > (y1 + y2) then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end\n else if tt < t then begin\n y1 := y;\n y2 := yy;\n t := tt;\n end;\n end;\n end;\n end;\n writeln(y1, ' ', y2);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "var\n i,x1,x2,t1,t2,t:longint;\n tt,t1m,t2m:longint;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if t=t2 then\n begin\n writeln(0,' ',x2);\n halt;\n end;\n\n for i:=x1 downto 0 do\n begin\n tt:=round(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\nwriteln(t1m,' ',t2m);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $11000000}\n{$R-,Q-,S+,O-}\nconst\n eps = 1e-11;\nvar\n x1, y1, x2, ans1, Ans2, y2, t1,t2, t0 : Int64;\n i : longint;\nfunction eq(x, y : extended) : Boolean;\nbegin\n result := y - x > eps;\nend;\nfunction neq(x, y : extended) : boolean;\nbegin\n result := (x - y < eps) and (y - x < eps);\nend;\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n Readln(t1, t2, x1, x2, t0);\n if t2 = t0 then\n begin\n Writeln(0, ' ', x2);\n exit;\n end;\n ans1 := -1;\n Ans2 := -1;\n for i := 0 to x1 do\n begin\n y1 := i;\n y2 := ((y1 * (t0 - t1)) div (t2 - t0 ));\n if y1 + y2 = 0 then\n Continue;\n if (t1 * y1 + t2 * y2) div (y1 + y2) < t0 then\n inc(y2);\n if (ans1 = -1) or (eq((t1 * y1 + t2 * y2) / (y1 + y2), (t1 * Ans1 + t2 * ans2) / (ans1 + ans2))) or (neq((t1 * y1 + t2 * y2) / (y1 + y2), (t1 * Ans1 + t2 * ans2) / (ans1 + ans2))) and (y1 + y2 > ans1 + ans2) then\n begin\n ans1 := y1;\n ans2 := y2;\n end;\n end;\n writeln(ans1, ' ', ans2);\nend.\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\nmnt:=-10000000 ;\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t)\n and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t1m,' ',t2m);\n end else\n begin\n tt:=x2;\n x2:=x1;\n x2:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t2m,' ',t1m);\n end;\n\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n f:Text;\n res1,res2,y1,y2,t1,t2,x1,x2,t0:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuat;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(res1,' ',res2);\n close(f);\nend;\nprocedure process;\nvar z,tmin:real;i1,i2:longint;\nbegin\n if t1=t0 then\n begin\n res1:=x1;\n res2:=0;\n exit;\n end;\n z:=(t0-t2)/(t1-t0);\n if x1>z*x2 then\n begin\n y1:=x2;\n y2:=x2;\n end\n else\n begin\n y1:=x1;\n y2:=x2;\n end;\n res1:=0;\n res2:=0;\n tmin:=maxlongint;\n for i2:=y2 downto 1 do\n begin\n i1:=trunc(i2*z);\n if i1<=x1 then\n if (t1*i1+t2*i2)/(i1+i2)>=t0 then\n begin\n if abs((t1*i1+t2*i2)/(i1+i2)-tmin)<0.0000001 then\n begin\n if (i1+i2)>(res1+res2) then\n begin\n res1:=i1;\n res2:=i2;\n end;\n end\n else\n if (t1*i1+t2*i2)/(i1+i2)=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=y;\n\n lx:=0;\n ly:=y;\n end;\n end\n else begin\n v:=i*(t1-t);\n if v mod (t-t2)>0 then begin\n y:=v div (t-t2);\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y> 0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n\n y:=v div (t-t2)+1;\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y> 0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n\n end\n else begin\n y:=v div (t-t2);\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y>0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n y:=v div (t-t2)+1;\n\n if y>x2 then y:=x2\n else\n if y<=0 then y:=0;\n\n if i+y>0 then begin\n lt:=(t1*i+t2*y)/(i+y);\n\n if lt>=t then\n\n if (abs(lt-t)max)) then begin\n min:=abs(lt-t);\n max:=i+y;\n\n lx:=i;\n ly:=y;\n end;\n end;\n end;\n end;\n end;\n\n\n writeln(lx,' ',ly);\n //close(input);\n //close(output);\n end.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,x,q,v:real;\n i:longint;\n dm1,dm2,dm3,k:int64;\nbegin\n if t1=t2 then\n begin\n ra1:=x1; ra2:=x2;\n exit;\n end;\n if t2=t0 then\n begin\n ra1:=0; ra2:=x2;\n exit;\n end;\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n dm1:=int64(t1*i);\n dm2:=int64(t2*k);\n dm3:=int64(k+i);\n x:=(dm1+dm2)/dm3;\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\nend;\nbegin\n nhap;\n xuly;\n writeln(ra1,' ',ra2);\nend.\n"}, {"source_code": "program Project5;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype dr = record\n chic, znam: int64;\nend;\nvar\n x1, x2, t1, t2, t0, y1, y2, y1t, y2t: longint;\n y2dr, ttek, tmin: dr;\nfunction nod(a, b: int64): int64;\nbegin\n if (a = 0) or (b = 0) then\n begin\n nod := a + b;\n exit;\n end;\n\n nod := nod(b, a mod b);\nend;\n\nprocedure cokr(var a: dr);\nvar\n d: int64;\nbegin\n d := nod(a.chic, a.znam);\n a.chic := a.chic div d;\n a.znam := a.znam div d;\nend;\n\nfunction okrverh(a: dr): int64;\nbegin\n if a.znam = 1 then\n okrverh := a.chic\n else\n okrverh := (a.chic div a.znam) + 1;\nend;\n\nfunction temp(y1, y2: longint): dr;\nvar\n res: dr;\nbegin\n res.chic := int64(y1) * t1 + int64(y2) * t2;\n res.znam := y1 + y2;\n cokr(res);\n temp := res;\nend;\n\nfunction ravn(a, b: dr): boolean;\nbegin\n if (a.chic = b.chic) and (a.znam = b.znam) then\n ravn := true\n else\n ravn := false;\nend;\nfunction bolsh(a, b: dr): boolean;\nbegin\n if a.chic = -1 then\n begin\n bolsh := true;\n exit;\n end;\n if (a.chic * b.znam - b.chic * a.znam) > 0 then\n bolsh := true\n else\n bolsh := false;\nend;\nbegin\n { assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output); }\n readln(t1, t2, x1, x2, t0);\n if t0 >= t2 then\n begin\n writeln(0, ' ', x2);\n exit;\n end;\n\n if t0 <= t1 then\n begin\n writeln(x1, ' ', 0);\n exit;\n end;\n\n tmin.chic := -1;\n tmin.znam := 1;\n for y1 := 1 to x1 do\n begin\n y2dr.chic := y1 * (t0 - t1);\n y2dr.znam := t2 - t0;\n cokr(y2dr);\n y2 := okrverh(y2dr);\n if y2 > x2 then\n break;\n\n ttek:= temp(y1, y2);\n if ravn(ttek, tmin) and (y1 + y2 > y1t + y2t) then\n begin\n tmin := ttek;\n y1t := y1;\n y2t := y2;\n end;\n\n if bolsh(tmin, ttek) then\n begin\n tmin := ttek;\n y1t := y1;\n y2t := y2;\n end;\n end;\n if tmin.chic = -1 then\n begin\n writeln(0, ' ', x2);\n exit;\n end; \n writeln(y1t, ' ', y2t);\nend.\n"}, {"source_code": " const\n fi='';\n fo='';\n oo=1000000000000000;\n var\n f:Text;\n res1,res2,y1,y2,t1,t2,x1,x2,t0:int64;\n procedure nhap;\n begin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\n end;\n procedure xuat;\n begin\n assign(f,fo);\n rewrite(f);\n writeln(res1,' ',res2);\n close(f);\n end;\n procedure process;\n var tmin,z:extended;i1,i2:int64;\n begin\n if (t1=t0) and (t2=t0) then\n begin\n res1:=x1;\n res2:=x2;\n exit;\n end;\n if t1=t0 then\n begin\n res1:=x1;\n res2:=0;\n exit;\n end;\n z:=(t0-t2)/(t1-t0);\n if x1>z*x2 then\n begin\n y1:=x2;\n y2:=x2;\n end\n else\n begin\n y1:=x1;\n y2:=x2;\n end;\n res1:=0;\n res2:=0;\n tmin:=oo;\n i2:=y2;\n while i2>=1 do\n begin\n i1:=trunc(i2*z);\n if i1>x1 then i1:=x1;\n if (t1*i1+t2*i2)/(i1+i2)>=t0 then\n begin\n if abs((t1*i1+t2*i2)/(i1+i2)-tmin)<0.0000001 then\n begin\n if (i1+i2)>(res1+res2) then\n begin\n res1:=i1;\n res2:=i2;\n end;\n end\n else\n if (t1*i1+t2*i2)/(i1+i2)t1 then\n begin\n for i:=x2 downto 0 do\n begin\n if (i*(t2-t)/(t-t1)<>trunc(i*(t2-t)/(t-t1))) then\n tt:= trunc(i*(t2-t)/(t-t1))+1 else\n tt:=trunc(i*(t2-t)/(t-t1));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x1 then continue;\n nt:=((t1*tt)+(t2*i))/(tt+i);\n if((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt-1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt+2;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n end;\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if (i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt-1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+2;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "{$r-,q-,s-,o+}\n{$IFNDEF ONLINE_JUDGE}\n{$o-,r+,q+,s-}\n{$ENDIF}\n{$M 16777216}\nprogram TASK_3;\n\nuses\n SysUtils,\n math;\nvar i,x1,x2:integer;\n min,ansx,ansy,t1,t2,t0,x,xx:int64;getted:extended;\n \nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');reset(input);\n assign(output, 'output.txt');rewrite(output);\n {$ENDIF}min:=0;\n readln(t1,t2,x1,x2,t0);getted:=10000000000000;\n if (t1=t2)and(t2=t0) then begin writeln(x1,' ',x2); halt(0); end;\n if t1=t0 then begin writeln(x1,' ',0);halt(0); end;\n if t2=t0 then begin writeln(0,' ',x2); halt(0); end;\n for i:=0 to x1 do\n begin\n x:=(t0*i-t1*i) div (t2-t0);\n if (t0*i-t1*i) mod (t2-t0) <> 0 then inc(x);\n if (x+i<>0)and(x<=x2)and((t1*i+t2*x)/(x+i)-t0<=getted) then begin getted:=(t1*i+t2*x)/(x+i)-t0; min:=x+i; ansX:=x;ansy:=i; end;\n end;\n writeln(ansY, ' ' ,ansX); \nend.\n\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\n\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n tt:=round(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t1m,' ',t2m);\n end else\n begin\n tt:=x2;\n x2:=x1;\n x2:=tt;\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n tt:=round(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t2m,' ',t1m);\n end;\n\nend.\n"}, {"source_code": "var i:longint;\n x1,x2,t1,t2,t:int64;\n tt,t1m,t2m:int64;\n mnt,nt:real;\nbegin\n readln(t1,t2,x1,x2,t);\n\n\n if (t=t2) and (t=t1) then\n begin\n\n writeln(x1,' ',x2);\n halt;\n end;\n\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t1m,' ',t2m);\n end else\n begin\n tt:=x2;\n x2:=x1;\n x2:=tt;\n\n tt:=t1;\n t1:=t2;\n t2:=tt;\n for i:=x1 downto 0 do\n begin\n if trunc(i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if tt+i=0 then continue;\n if tt>x2 then tt:=x2;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(nt-t)=abs(mnt-t)) and ((i+tt)>t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n writeln(t2m,' ',t1m);\n end;\n\nend.\n"}, {"source_code": "const\n{ fi='hot.inp';\n fo='hot.out';}\n fi='';\n fo='';\n maxn=1;\n eps=1e-9;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n:longint;\n t1,t2,t0,x1,x2,t:int64;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f, t1, t2, x1, x2 , t0);\n close(f);\nend;\n\nprocedure main;\nvar xopt,yopt,y,max:int64;\n x:longint;\n gt,tt,yy,kq:double;\nbegin\n assign(f,fo);rewrite(f);\n if t2=t0 then\n begin\n if t1=t0 then writeln(f,x1,' ',x2)\n else writeln(f,0,' ',x2);\n exit;\n end;\n tt:=(t0-t1)/(t2-t0);\n max:=0;\n kq:=1e15;\n for x:=0 to x1 do\n begin\n yy:=x*tt;\n if yy-trunc(yy)<=eps then y:=trunc(yy)\n else y:=trunc(yy)+1;\n y:=minn(y,x2);\n if x+y=0 then continue;\n gt:=(x*t1+y*t2)/(x+y);\n if (abs(gt-t0)max)) then\n begin\n kq:=gt-t0;\n max:=x+y;\n xopt:=x;\n yopt:=y;\n end;\n end;\n\n writeln(f,xopt,' ',yopt);\nend;\n\nbegin\n open;\n main;\n close(f);\nend.\n"}, {"source_code": "const\n fi='';\nvar\n f:text;\n t1,t2,x1,x2,t0,ra1,ra2:longint;\n tmp:real;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,t1,t2,x1,x2,t0);\n close(f);\nend;\nprocedure xuly;\nvar\n u,v,x,q:real;\n i,k:longint;\nbegin\n u:=(t0-t1)/(t2-t0);\n tmp:=1000000000;\n for i:=1 to x1 do\n begin\n v:=i*u;\n q:=v;\n v:=trunc(v);\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x>=t0 then\n begin\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n if q>trunc(q) then\n begin\n v:=trunc(q)+1;\n if v<=x2 then\n begin\n k:=trunc(v);\n x:=(t1*i+t2*k)/(k+i);\n if x(ra1+ra2) then\n begin\n ra1:=i;\n ra2:=k;\n end;\n end;\n end;\n end;\n end;\n writeln(ra1,' ',ra2);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "{$O-}\nUses Math;\nconst eps = 1e-9;\nvar\n\tx1, x2, ans, y2, y1, res, i, n, ai, bi, l, r, m: longint;\n t1, t2, t, otv, gr: extended;\n\nbegin\n\t{$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(t1, t2, x1, x2, t);\n otv := 1e12;\n res := -maxlongint;\n ai := 0; bi := 0;\n for i := x1 downto 0 do begin\n \ty1 := i;\n \tl := 0; r := x2; ans := 0;\n \twhile (l <= r) do begin\n \t\tm := (l + r) shr 1;\n \t\tif (y1 + m = 0) then gr := 0 else\n \t\tgr := (t1 * y1 + t2 * m) / (y1 + m);\n \t\tif gr >= t then begin\n \t\t\tans := 1;\n \t\t\ty2 := m;\n \t \tend;\n \t\tif gr < t then l := m + 1 else r := m - 1;\n \tend;\n \tif (ans > 0) then gr := (t1 * y1 + t2 * y2) / (y1 + y2);\n \tif (ans > 0) and ((otv - abs(gr - t) > 0) or ((abs(gr - t - otv) < eps) and (y1 + y2 < res))) then begin\n \t\totv := abs(gr - t);\n \t\tres := y1 + y2;\n \t\tai := y1;\n \t\tbi := y2;\n \tend;\n \tend;\n \twriteln(ai, ' ', bi);\nend."}, {"source_code": "program cf126a;\nconst eps=1e-7;\nvar\n n,i,j,y1:longint;\n an1,an2,y2,t1,t2,x1,x2,t0,dd:int64;\n ans,d:double;\nbegin\n readln(t1,t2,x1,x2,t0);\n if t2=t0 then begin\n writeln(0,' ',x2);\n halt; \n end;\n\n ans:=1e50;\n for y1:=x1-1 downto 1 do begin\n d:=(t0*y1-t1*y1)/(t2-t0);\n y2:=trunc(d);\n if y2t1 then\n begin\n for i:=x2 downto 0 do\n begin\n if (i*(t2-t)/(t-t1)<>trunc(i*(t2-t)/(t-t1))) then\n tt:= trunc(i*(t2-t)/(t-t1))+1 else\n tt:=trunc(i*(t2-t)/(t-t1));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x1 then continue;\n nt:=((t1*tt)+(t2*i))/(tt+i);\n if((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt-1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n\n tt:=tt+2;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=tt;\n t2m:=i;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n end;\n if t2<>t then\n begin\n\n for i:=x1 downto 0 do\n begin\n if (i*(t-t1)/(t2-t))<>i*(t-t1)/(t2-t) then tt:=trunc(i*(t-t1)/(t2-t))+1\n else tt:=trunc(i*(t-t1)/(t2-t));\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt-1;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n tt:=tt+2;\n if (tt+i=0) or (tt<0) then continue;\n if tt>x2 then continue;\n nt:=((t1*i)+(t2*tt))/(tt+i);\n if ((abs(nt-t)=t) and (abs(abs(nt-t)-abs(mnt-t))=0) and ((i+tt)>=t1m+t2m)) then\n begin\n t1m:=i;\n t2m:=tt;\n mnt:=((t1*i)+(t2*tt))/(i+tt);\n end;\n end;\n\n end;\n\n writeln(t1m,' ',t2m);\nend.\n"}, {"source_code": "program Project3_1;\n\n{$APPTYPE CONSOLE}\n\nconst\n eps = 0.0000000001;\n\nvar\n t1, t2, x1, x2, t0, l1, l2, r1, r2, m1, m2, max, ans1, ans2: int64;\n y1, y2: longint;\n t, min: extended;\n\n\nbegin\n {assignfile(input, 'input.txt');\n reset(input);\n assignfile(output, 'output.txt');\n rewrite(output); }\n\n read(t1, t2, x1, x2, t0);\n\n min := -1;\n max := -1;\n\n for y1 := 0 to x1 do begin\n if t0 = t2 then\n y2 := 0\n else\n y2 := round((y1 * (t0 - t1)) / (t2 - t0));\n if y2 > x2 then\n continue;\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 <= 0 - eps then\n continue; \n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n\n for y2 := 0 to x2 do begin\n if t0 = t1 then\n y1 := 0\n else\n y1 := round((y1 * (t2 - t0)) / (t0 - t1));\n if y1 > x1 then\n continue;\n if y1 + y2 = 0 then\n t := 0\n else\n t := (t1 * y1 + t2 * y2) / (y1 + y2);\n if t - t0 <= 0 - eps then\n continue;\n if ((abs(t - t0) < min - eps) or (min = -1)) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end else if (abs(t - t0) <= min + eps) and (y1 + y2 > max) then begin\n ans1 := y1;\n ans2 := y2;\n max := y1 + y2;\n min := abs(t - t0);\n end;\n end;\n\n write(ans1, ' ', ans2);\n \n closefile(input);\n closefile(output);\nend.\n"}, {"source_code": "uses Math;\nVar N,M,j,k,l,v,r,t1,t2,t0,x1,x2,minx1,minx2,y2,y1:int64;\ni:longint;\nt,t3:extended;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nreadln(t1,t2,x1,x2,t0);\nt:=t2;\nminx1:=0;\nminx2:=x2;\nv:=x2;\nFor i:=0 to x1 do begin\n //l:=0;\n //r:=x2;\n y1:=i;\n v:=0;\n // While l<=r do begin\n if (t1=t0) and (t2=t0) then\n begin\n writeln(x1,' ',x2);\n halt(0);\n end;\n if t1=t0 then\n begin\n writeln(x1,' ',0);\n halt(0);\n end;\n if t2=t0 then\n begin\n writeln(0,' ',x2);\n halt(0);\n end;\n y2:=ceil((t1-t0)/(t0-t2)*y1);\n if y2<=x2 then begin\n if y1+y2>v then begin\n v:=y1+y2;\n minx1:=y1;\n minx2:=y2;\n end;\n end;\n { m:=(l+r) div 2;\n if (i<>0) or (m<>0) then\n t3:=((t1*i)+(t2*m))/(i+m)\n else\n t3:=0;\n if t3=t0 then exit(true)\n else exit(false);\nend;\n\nprocedure solve;\nvar mid,l,r:longint;\nbegin\n min:=oo;\n for y1:=0 to x1 do\n begin\n l:=0;r:=x2;\n if x2<=2 then r:=r+2;\n repeat\n y2:=(l+r) div 2;\n if ok then\n begin\n r:=y2-1;\n if (tres1+res2) then\n begin\n res1:=y1;\n res2:=y2;\n end;\n end\n else l:=y2+1;\n until l>r;\n end;\nend;\n\nprocedure winf;\nbegin\n assign(output,fo);\n rewrite(output);\n write(res1,' ',res2);\n close(output);\nend;\n\nbegin\n rinf;\n solve;\n winf;\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n e=0.0001;\nVar\n t1,t2,x1,x2,t0,i,j,i1,j1,t:Integer;\n r,s,t3:Real;\nBegin\n Read(t1,t2,x1,x2,t0);\n If t0=t1 Then Begin\n Write(x1,' ',0);\n Halt;\n End;\n If t0=t2 Then Begin\n Write(x2,' ',0);\n Halt;\n End;\n r:=High(Integer);\n t:=High(Integer);\n i1:=0;\n j1:=0;\n For i:=0 To x1 Do Begin\n s:=i*(t1-t0)/(t0-t2);\n j:=Round(s);\n If jx2 Then j:=x2;\n If j<0 Then j:=0;\n If (i=0) and (j=0) Then Continue;\n t3:=(t1*i+t2*j)/(i+j);\n If (t3>t0) or (abs(t3-t0)t) Then Begin\n t:=i+j;\n i1:=i;\n j1:=j;\n End\n Else If t3-t00) and (j1<>0) Then Write(i1,' ',j1)\n Else Write(x2);\nEnd.\n\n"}, {"source_code": "uses math;\nvar n,m,i,j,t,l,r,yy,zz,ii,jj:longint;\n j1,tt,tt1,t1,t2,x1,x2,t0:longint;\n\n k,mn:extended;\nprocedure prov(j1:longint);\nbegin\nif i+j1=0 then exit;\n k:=(t1*i+t2*j1)/(i+j1);\n k:=k-t0;\n if k<0 then exit;\n if k<=mn then begin\n ii:=i;\n jj:=j1;\n mn:=k;\n end;\n\nend;\n\nbegin\n\n read(t1,t2,x1,x2,t0);\n tt:=t2-t0;\n tt1:=t0-t1;\n mn:=t2;\n if tt1=0 then begin\n write( x1,' 0');\n halt;\n end;\n if tt=0 then begin\n write( '0 ',x2);\n halt;\n end;\n for i:=0 to x1 do\n begin\n j:=min(trunc(tt1/tt*i),x2);\n // if (j>x2)or(j<=0) then continue;\n prov(j);\n // prov(j+1);\n\n end;\n\n if ii+jj=0 then write('0 ',x2) else write(ii,' ',jj);\n\nend.\n"}, {"source_code": "var\n t1,t2,x1,x2,t0,minx,minf,f,min,x : longint;\n px,tx,mint,fx : extended;\n ok : boolean;\n\n function _round(x : extended) : longint;\n begin\n if (frac(x)>=0.5) then _round:=trunc(x)+1\n else _round:=trunc(x);\n end;\n\nbegin\n {assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);}\n readln(t1,t2,x1,x2,t0);\n min:=-maxlongint;\n mint:=maxlongint;\n if (t1=t0) and (t2=t0)\n then\n if (x1>x2) then begin minx:=x1; minf:=0; end\n else begin minx:=0; minf:=x2; end\n else begin\n if (t1=t0) then begin minx:=x1; minf:=0; end;\n if (t2=t0) then begin minx:=0; minf:=x2; end;\n end;\n if (t1<>t0) and (t2<>t0) then begin\n for x:=1 to x1 do begin\n px:=(t0*x-t1*x)/(t2-t0);\n if (px<=x2) and (px>=0)\n then begin\n f:=_round(px);\n tx:=(t1*x+t2*f)/(x+f);\n if (tx-t0<0) then fx:=t0-tx else fx:=tx-t0;\n if (x+f>min) and (fx<=mint) and (tx>=t0) then begin\n minx:=x; minf:=f; min:=x+f; mint:=fx;\n end;\n end; \n end;\n end;\n writeln(minx,' ',minf);\n close(input); close(output);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nconst\n eps = 1e-9;\n\nvar\n bsum, a, b: Integer;\n t, f: Double;\n t1, t2, x1, x2, t0: Integer;\n y1, y2: Integer;\n\nbegin\n //Reset(input, 'input.txt'); Rewrite(output, 'output.txt');\n Readln(t1, t2, x1, x2, t0);\n y1 := 0;\n t := maxint; bsum := -1; a := -1; b := -1;\n for y2 := 0 to x2 do\n begin\n while True do\n begin\n if (y1+y2 > 0) then\n begin\n f := (1.0*y1*t1+y2*t2)/(y1+y2);\n if (f - t0 < t - t0) or (samevalue(f-t0, t-t0, eps) and (y1+y2 > bsum)) then\n begin\n a := y1; b := y2; bsum := y1 + y2; t := f;\n end;\n end;\n Inc(y1);\n if (y1 + y2 = 0) or ((1.0*y1*t1+y2*t2)/(y1+y2)+eps < t0) or (y1 > x1) then\n begin\n Dec(y1); break;\n end;\n if (y1+y2 > 0) then\n begin\n f := (1.0*y1*t1+y2*t2)/(y1+y2);\n if (f - t0 < t - t0) or (samevalue(f-t0, t-t0, eps) and (y1+y2 > bsum)) then\n begin\n a := y1; b := y2; bsum := y1 + y2; t := f;\n end;\n end;\n end;\n end;\n Writeln(a, ' ', b);\nend.\n "}, {"source_code": "{$O-}\nprogram taskC;\n\nvar\n t1,t2,x1,x2,t0,y1,y2,ans1,ans2:longint;max:extended;\n\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n\n read(t1,t2,x1,x2,t0);\n\n max:=maxlongint;ans1:=0;ans2:=0;\n if t0=t1 then ans1:=x1 else\n if t0=t2 then ans2:=x2 else\n begin\n for y1:=0 to x1 do\n begin\n y2:=y1*(t1-t0) div (t0-t2);\n if (y1=0) and (y2=0) then inc(y2);\n while (t1*y1+t2*y2) div (y1+y2)ans1+ans2) then begin\n ans1:=y1;ans2:=y2;max:=(t1*y1+t2*y2)/(y1+y2)\n end;\n end;\n end;\n end;\n\n write(ans1,' ',ans2);\nend.\n"}], "src_uid": "87a500829c1935ded3ef6e4e47096b9f"} {"source_code": "const\n fi='';\n fo='';\n mn=500010;\n var\n f:text;\n n,i,j,l,r:longint;\n kq:int64;\n pre,next,b,id, a:array[0..mn] of longint;\n Procedure Input;\n Begin\n assign(f,fi);\n reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\n b:=a;\n end;\n function min(x,y:longint):int64;\n Begin\n if x>y then exit(y) else\n exit(x);\n end;\n procedure swap( var x,y:longint);\n var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n Procedure qs(l,h:longint);\n var i,j,x:longint;\n Begin\n i:=l;\n j:=h;\n x:=a[random(h-l+1)+l];\n repeat\n while a[i]< x do inc(I);\n while a[j]>x do dec(j);\n if i<=j then\n Begin\n\n swap(a[i],a[j]);\n swap(id[i],id[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if ib then exit(b) else exit(a);\n end;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) shr 1];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0) and (a[t]<=a[t-1]) and (a[t]x do dec(j);\n if not(i>j) then\n begin\n t:=stack[i];stack[i]:=stack[j];stack[j]:=t;\n inc(i);dec(j);\n end;\n until i>j;\n if l=3)and(stack[top-1]<=stack[top])and(stack[top-1]<=stack[top-2]) do\n begin\n inc(ans,min(stack[top-2],stack[top]));\n stack[top-1]:=stack[top];\n dec(top);\n end;\n end; \n sort(1,top);\n for i:=1 to top-2 do\n inc(ans,stack[i]);\n writeln(ans); \nend.\n"}, {"source_code": "uses math;\nvar\n f : array[0..550000] of longint;\n ans : int64;\n a,i,j,n,m,k : longint;\n\nbegin\n readln(n);\n for i:=1 to n do begin\n read(a);\n inc(m); f[m]:=a;\n while (m >= 3) and (f[m-1] <= min(f[m-2],f[m])) do begin\n ans:=ans+int64(min(f[m-2],f[m]));\n f[m-1]:=f[m];\n dec(m);\n end;\n end;\n for i:=2 to m-1 do ans:=ans+int64(min(f[i-1],f[i+1]));\n writeln(ans);\nend."}, {"source_code": "var a:array[0..600000] of longint;\ni,t,n,x:longint;sum:int64;\nprocedure sort(l,r:longint);\nvar i,j,x,y:longint;\nbegin\ni:=l;j:=r;x:=a[(l+r) div 2];\nrepeat\nwhile a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);j:=j-1;\n end;\nuntil i>j;\nif l=2) and (a[t-1]>=a[t]) and (a[t]<=x) do\n begin\n if a[t-1]>x then sum:=sum+x\n else sum:=sum+a[t-1];\n t:=t-1;\n end;\n t:=t+1;a[t]:=x;\n end;\nsort(1,t);\nfor i:=1 to t-2 do\n sum:=sum+a[i];\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "type\n node=record\n data,num:longint;\n end;\nvar\n n,i,l,r,x,y:longint;\n a:array[0..500010] of node;\n b,next,pre:array[0..500010] of longint;\n ans:int64;\n\nfunction min(x,y:longint):longint;\nbegin\n if xmid.data do dec(j);\n if i<=j then\n begin\n temp:=a[i];a[i]:=a[j];a[j]:=temp;\n inc(i);dec(j);\n end;\n until i>j;\n if lmid.data do dec(j);\n if i<=j then\n begin\n temp:=a[i];a[i]:=a[j];a[j]:=temp;\n inc(i);dec(j);\n end;\n until i>j;\n if l=right then exit;\n i:=left;\n j:=right;\n mid:=a[(i+j)div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(left,j);\n qsort(i,right);\nend;\nbegin\n \n read(n);\n top:=0;\n ans:=0;\n for i:=1 to n do\n begin\n inc(top);\n read(a[top]);\n while (top>=3)and(a[top-2]>=a[top-1])and(a[top-1]<=a[top])do\n begin\n ans:=ans+min(a[top-2],a[top]);\n a[top-1]:=a[top];\n dec(top);\n end;\n end;\n qsort(1,top);\n for i:=1 to top-2 do ans:=ans+a[i];\n writeln(ans);\n\nend."}, {"source_code": "program problem3;\nuses math;\n\nvar\ta, next, prev, nextReady, added: array[ 0..1000001 ] of longInt;\n\tfirstReady: longInt;\n\tsum: int64;\n\t\nprocedure addReady( x: longInt );\nbegin\n\tif ( a[x] > a[ prev[x] ] ) or ( a[x] > a[ next[x] ] ) or ( added[x] = 1 ) then\n\t\texit();\n\t\n\tadded[x] := 1;\n\t\n\tnextReady[x] := firstReady;\n\tfirstReady := x;\nend;\n\nprocedure remove( x: longInt );\nbegin\n\tinc( sum, min( a[ prev[x] ], a[ next[x] ] ) );\n\t\n\tnext[ prev[x] ] := next[x];\n\tprev[ next[x] ] := prev[x];\n\t\n\taddReady( prev[x] );\n\taddReady( next[x] );\nend;\n\nvar\tn, i, x, l, r, c: longInt;\n\ts: int64;\n\tincr, decr: boolean;\n\nbegin\n\treadln( n );\n\tfor i := 1 to n do\n\tbegin\n\t\tread( a[i] );\n\t\t\n\t\tnext[i] := i + 1;\n\t\tprev[i] := i - 1;\n\tend;\n\t\n\ta[0] := 0;\n\ta[n + 1] := 0;\n\t\n\tif ( n < 3 ) then\n\tbegin\n\t\twriteln( 0 );\n\t\thalt;\n\tend;\n\t\n\tfirstReady := 0;\n\tfor i := 2 to n - 1 do\n\t\tif ( a[i] <= a[i - 1] ) and ( a[i] <= a[i + 1] ) then\n\t\t\taddReady( i );\n\t\t\t\n\twhile ( firstReady > 0 ) do\n\tbegin\n\t\tx := firstReady;\n\t\t\n\t\tfirstReady := nextReady[firstReady];\n\t\t\n\t\tremove( x );\n\tend;\n\t\n\ts := a[1];\n\tx := 1;\n\ti := next[1];\n\twhile ( i <= n ) do\n\tbegin\n\t\tinc( x );\n\t\ta[x] := a[i];\n\t\t\n\t\tinc( s, a[x] );\n\t\t\n\t\ti := next[i];\n\tend;\n\t\n\ta[0] := 0;\n\ta[x + 1] := 0;\n\n\tif ( x < 3 ) then\n\tbegin\n\t\twriteln( sum );\n\t\thalt;\n\tend;\n\t\n\tincr := false;\n\tdecr := false;\n\tfor i := 2 to x do\n\t\tif ( a[i] > a[i - 1] ) then\n\t\t\tincr := true\n\t\telse if ( a[i] < a[i - 1] ) then\n\t\t\tdecr := true;\n\n\tif ( incr and decr ) then\n\tbegin\n\t\tl := 1;\n\t\twhile ( a[l + 1] >= a[l] ) do\n\t\t\tinc( l );\n\t\t\n\t\tr := l;\n\t\twhile ( a[l - 1] = a[r] ) do\n\t\t\tdec( l );\n\t\t\n\t\tif ( r - l + 1 > 2 ) then\n\t\t\tinc( sum, int64(r - l - 1) * a[l] );\n\t\t\n\t\tc := l;\n\t\tl := l - 1;\n\t\tif ( r = c ) then\n\t\t\tinc( r );\n\t\t\n\t\twhile ( a[l] > 0 ) or ( a[r] > 0 ) do\n\t\tbegin\n\t\t\tif ( a[l] > 0 ) and ( a[l - 1] > a[r] ) then\n\t\t\tbegin\n\t\t\t\tinc( sum, a[l - 1] );\n\t\t\t\tdec( l );\n\t\t\tend\n\t\t\telse if ( a[r] > 0 ) and ( a[r + 1] > a[l] ) then\n\t\t\tbegin\n\t\t\t\tinc( sum, a[r + 1] );\n\t\t\t\tinc( r );\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tinc( sum, min( a[l], a[r] ) );\n\t\t\t\t\n\t\t\t\tif ( a[l] > a[r] ) then\n\t\t\t\tbegin\n\t\t\t\t\tc := l;\n\t\t\t\t\tdec( l );\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tbegin\n\t\t\t\t\tc := r;\n\t\t\t\t\tinc( r );\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend\n\telse if ( incr ) then\n\t\tinc( sum, s - a[x] - a[x - 1] )\n\telse\n\t\tinc( sum, s - a[1] - a[2] );\n\t\n\twriteln( sum );\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n mn=500010;\n\nvar\n n,i,j,l,r:longint;\n kq:int64;\n pre,next,b,id, a:array[0..mn] of longint;\n\n\n Procedure Input;\n Var f:text;\n Begin\n assign(f,fi);\n reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\n b:=a;\n end;\n\n\n function min(x,y:longint):int64;\n Begin\n if x>y then exit(y) else\n exit(x);\n end;\n\n procedure swap( var x,y:longint);\n var tg:longint;\n Begin\n tg:=x;\n x:=y;\n y:=tg;\n end;\n\n\n Procedure qs(l,h:longint);\n var i,j,x:longint;\n Begin\n i:=l;\n j:=h;\n x:=a[random(h-l+1)+l];\n repeat\n while a[i]< x do inc(I);\n while a[j]>x do dec(j);\n if i<=j then\n Begin\n\n swap(a[i],a[j]);\n swap(id[i],id[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if im do dec(j);\n if i>j then break;\n t:=a[i];a[i]:=a[j];a[j]:=t;\n inc(i);dec(j);\n until i>j;\n if l1)and(a[k-1]>=a[k])and(x>=a[k])do\n begin\n inc(ans,min(a[k-1],x));\n dec(k);\n end;\n inc(k);a[k]:=x;\n end;\n qs(1,k);\n for i:=1 to k-2 do inc(ans,a[i]);\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "uses math;\nvar\n stack:array[0..1000000] of longint;\n n,i,top,ans:longint;\n procedure sort(l,r:longint);\n var\n i,j,x,t:longint;\n begin\n i:=l;j:=r;x:=stack[(l+r) div 2];\n repeat\n while stack[i]x do dec(j);\n if not(i>j) then\n begin\n t:=stack[i];stack[i]:=stack[j];stack[j]:=t;\n inc(i);dec(j);\n end;\n until i>j;\n if l=3)and(stack[top-1]x do dec(j);\n if not(i>j) then\n begin\n t:=stack[i];stack[i]:=stack[j];stack[j]:=t;\n inc(i);dec(j);\n end;\n until i>j;\n if l=3)and(stack[top-1]x do dec(j);\n if not(i>j) then\n begin\n t:=stack[i];stack[i]:=stack[j];stack[j]:=t;\n inc(i);dec(j);\n end;\n until i>j;\n if l=3)and(stack[top-1]<=stack[top])and(stack[top-1]<=stack[top-2]) do\n begin\n inc(ans,min(stack[top-2],stack[top]));\n stack[top-1]:=stack[top];\n dec(top);\n end;\n end; \n sort(1,top);\n for i:=1 to top-2 do\n inc(ans,stack[i]);\n writeln(ans); \nend.\n"}, {"source_code": "var a:array[0..600000] of longint;\ni,t,n,x:longint;sum:int64;\nprocedure sort(l,r:longint);\nvar i,j,x,y:longint;\nbegin\ni:=l;j:=r;x:=a[(l+r) div 2];\nrepeat\nwhile a[i]j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);j:=j-1;\n end;\nuntil i>j;\nif l=2) and (a[t-1]>=a[t]) and (a[t]<=x) do\n begin\n if a[t-1]>x then sum:=sum+x\n else sum:=sum+a[t-1];\n t:=t-1;\n end;\n t:=t+1;a[t]:=x;\n end;\nsort(1,n);\nfor i:=1 to n-2 do\n sum:=sum+a[i];\nwriteln(sum);\nclose(input);close(output);\nend.\n"}, {"source_code": "program problem3;\nuses math;\n\nvar\ta, next, prev, nextReady, added: array[ 0..1000001 ] of longInt;\n\tfirstReady: longInt;\n\tsum: int64;\n\t\nprocedure addReady( x: longInt );\nbegin\n\tif ( a[x] > a[ prev[x] ] ) or ( a[x] > a[ next[x] ] ) or ( added[x] = 1 ) then\n\t\texit();\n\t\n\tadded[x] := 1;\n\t\n\tnextReady[x] := firstReady;\n\tfirstReady := x;\nend;\n\nprocedure remove( x: longInt );\nbegin\n\tinc( sum, min( a[ prev[x] ], a[ next[x] ] ) );\n\t\n\tnext[ prev[x] ] := next[x];\n\tprev[ next[x] ] := prev[x];\n\t\n\taddReady( prev[x] );\n\taddReady( next[x] );\nend;\n\nvar\tn, i, x, l, r: longInt;\n\ts: int64;\n\tincr, decr: boolean;\n\nbegin\n\treadln( n );\n\tfor i := 1 to n do\n\tbegin\n\t\tread( a[i] );\n\t\t\n\t\tnext[i] := i + 1;\n\t\tprev[i] := i - 1;\n\tend;\n\t\n\ta[0] := 0;\n\ta[n + 1] := 0;\n\t\n\tif ( n < 3 ) then\n\tbegin\n\t\twriteln( 0 );\n\t\thalt;\n\tend;\n\t\n\tfirstReady := 0;\n\tfor i := 2 to n - 1 do\n\t\tif ( a[i] <= a[i - 1] ) and ( a[i] <= a[i + 1] ) then\n\t\t\taddReady( i );\n\t\t\t\n\twhile ( firstReady > 0 ) do\n\tbegin\n\t\tx := firstReady;\n\t\t\n\t\tfirstReady := nextReady[firstReady];\n\t\t\n\t\tremove( x );\n\tend;\n\t\n\ts := a[1];\n\tx := 1;\n\ti := next[1];\n\twhile ( i <= n ) do\n\tbegin\n\t\tinc( x );\n\t\ta[x] := a[i];\n\t\t\n\t\tinc( s, a[x] );\n\t\t\n\t\ti := next[i];\n\tend;\n\t\n\ta[0] := 0;\n\ta[x + 1] := 0;\n\n\tif ( x < 3 ) then\n\tbegin\n\t\twriteln( sum );\n\t\thalt;\n\tend;\n\t\n\tincr := false;\n\tdecr := false;\n\tfor i := 2 to x do\n\t\tif ( a[i] > a[i - 1] ) then\n\t\t\tincr := true\n\t\telse if ( a[i] < a[i - 1] ) then\n\t\t\tdecr := true;\n\n\tif ( incr and decr ) then\n\tbegin\n\t\tl := 1;\n\t\twhile ( a[l + 1] >= a[l] ) do\n\t\t\tinc( l );\n\t\t\n\t\tr := l;\n\t\twhile ( a[l - 1] = a[r] ) do\n\t\t\tdec( l );\n\t\t\n\t\tif ( r - l + 1 > 2 ) then\n\t\t\tinc( sum, int64(r - l - 1) * a[l] );\n\t\t\n\t\tif ( l = r ) then\n\t\tbegin\n\t\t\tinc( r );\n\t\t\tdec( l );\n\t\t\t\n\t\t\tinc( sum, min( a[l], a[r] ) );\n\t\tend;\n\t\t\n\t\twhile ( a[l] > 0 ) or ( a[r] > 0 ) do\n\t\tbegin\n\t\t\tif ( a[l] > a[r] ) then\n\t\t\tbegin\n\t\t\t\tinc( sum, min( a[l - 1], a[r] ) );\n\t\t\t\tdec( l );\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tinc( sum, min( a[l], a[r + 1] ) );\n\t\t\t\tinc( r );\n\t\t\tend;\n\t\tend;\n\tend\n\telse if ( incr ) then\n\t\tinc( sum, s - a[x] - a[x - 1] )\n\telse\n\t\tinc( sum, s - a[1] - a[2] );\n\t\n\twriteln( sum );\nend.\n"}], "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1"} {"source_code": "const c=6;\nvar a,b,x1,y1,x2,y2:longint;\n\n procedure swap(var a,b:longint);\n var c:longint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n procedure second;\n begin\n writeln('Second');\n halt;\n end;\n\n procedure first;\n begin\n writeln('First');\n halt;\n end;\n\n begin\n readln(a,b,x1,y1,x2,y2);\n if a=1 then\n begin\n swap(a,b);\n swap(x1,y1);\n swap(x2,y2);\n end;\n a:=abs(x1-x2);\n b:=abs(y1-y2);\n if (a>=5) or (b>=5) or (a+b>=7) then second else first;\nend.\n\n", "positive_code": [{"source_code": "var\n met:array [1..1000,1..1000] of longint;\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\n\n\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if (xx<=4)and(yy<=4)and(xx+yy<=6 )then writeln('First')\n else writeln('Second');\nend.\n"}, {"source_code": "var\nn,m,x1,y1,x2,y2:longint;\n begin\n readln(n,m,x1,y1,x2,y2);\n if (abs(x1-x2)>=5)or(abs(y1-y2)>=5) then writeln('Second') else\n begin\n if ((abs(x1-x2)<=2)and(abs(y1-y2)=4))or((abs(y1-y2)<=2)and(abs(x1-x2)=4)) then writeln('First') else\n if (abs(y1-y2)=4)or(abs(x1-x2)=4) then writeln('Second') else\n writeln('First');\n end;\n end.\n\n"}, {"source_code": "var n,m,x1,y1,x2,y2,d1,d2:longint;\nbegin\nreadln(n,m,x1,y1,x2,y2);\nd1:=abs(x1-x2);\nd2:=abs(y1-y2);\nif (d1<=4) and (d2<=4) and (d1+d2<=6 )then writeln('First') else writeln('Second');\nend.\n"}, {"source_code": "program pr;\n var x1,y1,x2,y2,X,Y:longint;\n\nbegin\n read(x1,y1);\n read(x1,y1);\n read(x2,y2);\n\n X:=abs(x1 - x2);\n Y:=abs(y1 - y2);\n\n if (X >= 5) or (Y >= 5) or (X + Y >= 7) then\n writeln('Second')\n else\n writeln('First');\nend.\n"}, {"source_code": "const nn=3004;\nvar a,b:array[0..nn] of integer; { c:array[-2001..2001,-2001..2001]of integer;\n} m,n,i,j,y,z,t,k,x:integer;s:string; q:char;\nbegin\n read(n,m,a[1],b[1],a[2],b[2]);\n if (abs(a[1]-a[2])>4)or(abs(b[1]-b[2])>4) or (abs(a[1]-a[2])+abs(b[1]-b[2])>6)then write('Second') else\n write('First');\nend."}, {"source_code": "program cf176c;\nvar\n n,x,t,y,m,x1,y1,x2,y2,i,j:longint;\nbegin\n readln(n,m,x1,y1,x2,y2);\n x:=abs(x1-x2);\n y:=abs(y1-y2);\n if y=5) then writeln('Second')\n else writeln('First');\nend.\n"}, {"source_code": "var\n n,m,x1,y1,x2,y2:longint;\n x,y:longint;\nbegin\n readln(n,m,x1,y1,x2,y2);\n x:=abs(x1-x2)+1;\n y:=abs(y1-y2)+1;\n if (x>3) and (y>3) then begin\n if (x>=5) or (y>=5) then writeln('Second')\n else begin\n writeln('First');\n end;\n end\n else if ((x>=6) or (y>=6)) then writeln('Second')\n else writeln('First');\nend.\n\n"}, {"source_code": "var\n met:array [1..1000,1..1000] of longint;\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\n\n\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if (xx<=4)and(yy<=4)and(xx+yy<=6 )then writeln('First')\n else writeln('Second');\nend.\n"}, {"source_code": "Uses math;\n\nVar n,m,x1,y1,x2,y2:longint;\n d:array[0..100,0..100,0..1] of longint;\n i,j:longint;\n a,b:longint;\n\nBegin\n\nReadln(n,m,x1,y1,x2,y2); a:=abs(x1-x2); b:=abs(y1-y2);\n\nif a>b then begin a:=a+b; b:=a-b; a:=a-b; end;\n\nif a=0 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=1 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=2 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=3 then begin if b<4 then WRiteln('First') else WRiteln('Second'); halt; end;\nif a=4 then begin if b<4 then Writeln('First') else Writeln('Second'); halt; end;\n\nWriteln('Second');\n\nEnd.\n\n\n\n\n\n"}, {"source_code": "var\nn,m,x1,y1,x2,y2:longint;\n begin\n readln(n,m,x1,y1,x2,y2);\n if (abs(x1-x2)>=5)or(abs(y1-y2)>=5) then writeln('Second') else\n begin\n if ((abs(x1-x2)<=2)and(abs(y1-y2)=4))or((abs(y1-y2)<=2)and(abs(x1-x2)=4)) then writeln('First') else\n if (abs(y1-y2)=4)or(abs(x1-x2)=4) then writeln('Second') else\n writeln('First');\n end;\n end."}, {"source_code": "var n,m,x1,y1,x2,y2,t:longint;\n//======================================================\nbegin\n readln(n,m,x1,y1,x2,y2);\n t:=abs(x1-x2)+abs(y1-y2);\n if t<=4 then\n begin\n writeln('First');exit;\n end;\n if t>=7 then\n begin\n writeln('Second');exit;\n end;\n if t=6 then\n begin\n if (abs(x1-x2)>1)and(abs(y1-y2)>1) then\n writeln('First')\n else writeln('Second');\n exit;\n end;\n if (x1=x2)or(y1=y2) then writeln('Second')\n else writeln('First');\nend.\n"}, {"source_code": "var n,m,x1,y1,x2,y2,x,y:longint;\n begin\n readLn(n,m,x1,y1,x2,y2);\n x:=abs(x1-x2);\n y:=abs(y1-y2);\n\n if (x>4)or(y>4)or((x>=3)and(y>=4))or((x>=4)and(y>=3)) then writeln('Second')\n else writeln('First');\n end."}, {"source_code": "const c=6;\nvar a,b,x1,y1,x2,y2:longint;\n\n procedure swap(var a,b:longint);\n var c:longint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n procedure second;\n begin\n writeln('Second');\n halt;\n end;\n\n procedure first;\n begin\n writeln('First');\n halt;\n end;\n\n begin\n readln(a,b,x1,y1,x2,y2);\n if a=1 then\n begin\n swap(a,b);\n swap(x1,y1);\n swap(x2,y2);\n end;\n a:=abs(x1-x2);\n b:=abs(y1-y2);\n if (a>=5) or (b>=5) or (a+b>=7) then second else first;\nend.\n\n"}, {"source_code": "const c=6;\nvar a,b,x1,y1,x2,y2:longint;\n\n procedure swap(var a,b:longint);\n var c:longint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n procedure second;\n begin\n writeln('Second');\n halt;\n end;\n\n procedure first;\n begin\n writeln('First');\n halt;\n end;\n\n begin\n readln(a,b,x1,y1,x2,y2);\n if a=1 then\n begin\n swap(a,b);\n swap(x1,y1);\n swap(x2,y2);\n end;\n a:=abs(x1-x2);\n b:=abs(y1-y2);\n if (a>=5) or (b>=5) or (a+b>=7) then second else first;\nend.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst file1='c.in';\n file2='c.out';\n oo=maxlongint div 2;\n empty='';\n eps=1e-6;\n dohrena=1e21;\n\nvar qc,he:array[0..2009,0..2009]of longint;\n ss:array[0..2009]of string;\n qq,cc:array[0..500000]of longint;\n bb:array[0..500000]of boolean;\n xx,yy,zz:array[0..500000]of extended;\n ii,jj,kk,t,test,u,v,w,n,m,r,p,q,c,h,e,r0,r1,r2,res:longint;\n a:int64;\n s,s0,s1,s2:string;\n sss:ansistring;\n x,y,z,x0,x1,x2,y0,y1,y2,z0,z1,z2:longint;\n ch:char;\n b,b0,b1,b2:boolean;\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n res:=0;\n end;\n\nprocedure load;\nvar i,j,k:longint;\n begin\n readln(x,y,x1,y1,x2,y2);\n end;\n\nprocedure save;\nvar i,j,k:longint;\n begin\n if res=1 then writeln('First');\n if res=2 then writeln('Second');\n end;\n\nprocedure run;\nvar i,j,k:longint;\n begin\n q:=abs(x1-x2);\n c:=abs(y1-y2);\n if q4 then res:=2;\n if q<4 then res:=1;\n if q=4 then\n begin\n if c>2 then res:=2 else res:=1;\n end;\n end;\n\nbegin\n{assign(input,file1);\nassign(output,file2);\nreset(input);\nrewrite(output);}\nfor t:=1 to 1 do\n begin\n clear;\n load;\n run;\n save;\n end;\n{close(input);\nclose(output);}\nend.\n"}], "negative_code": [{"source_code": "var\n n,m,x1,y1,x2,y2:longint;\n x,y:longint;\nbegin\n readln(n,m,x1,y1,x2,y2);\n x:=abs(x1-x2)+1;\n y:=abs(y1-y2)+1;\n if (x>=5) or (y>=5) then writeln('Second')\n else begin\n writeln('First');\n end;\nend."}, {"source_code": "Uses math;\n\nVar n,m,x1,y1,x2,y2:longint;\n d:array[0..100,0..100,0..1] of longint;\n i,j:longint;\n a,b:longint;\n\nBegin\n\nReadln(n,m,x1,y1,x2,y2); a:=abs(x1-x2); b:=abs(y1-y2);\n\nif a>b then begin a:=a+b; b:=a-b; a:=a-b; end;\n\nif b<=5 then begin Writeln('First'); halt; end else begin Writeln('Second'); halt; end;\n\nEnd.\n\n\n\n\n\n"}, {"source_code": "Uses math;\n\nVar n,m,x1,y1,x2,y2:longint;\n d:array[0..100,0..100,0..1] of longint;\n i,j:longint;\n a,b:longint;\n\nBegin\n\nReadln(n,m,x1,y1,x2,y2); a:=abs(x1-x2); b:=abs(y1-y2);\n\nif a>b then begin a:=a+b; b:=a-b; a:=a-b; end;\n\nif a=0 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=1 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=2 then begin if b<5 then Writeln('First') else Writeln('Second'); halt; end;\nif a=3 then begin if b<5 then WRiteln('First') else WRiteln('Second'); halt; end;\nif a=4 then begin if b<5 then Writeln('Forst') else Writeln('Second'); halt; end;\nWriteln('Second');\n\nEnd.\n\n\n\n\n\n"}, {"source_code": "Uses math;\n\nVar n,m,x1,y1,x2,y2:longint;\n d:array[0..100,0..100,0..1] of longint;\n i,j:longint;\n a,b:longint;\n\nBegin\n\nReadln(n,m,x1,y1,x2,y2); a:=abs(x1-x2); b:=abs(y1-y2);\n\nif a>b then begin a:=a+b; b:=a-b; a:=a-b; end;\n\nif b<=4 then begin Writeln('First'); halt; end else begin Writeln('Second'); halt; end;\n\nEnd.\n\n\n\n\n\n"}, {"source_code": "var\nn,m,x1,y1,x2,y2:longint;\n begin\n readln(n,m,x1,y1,x2,y2);\n if (abs(x1-x2)>=4)and(abs(y1-y2)>=4) then writeln('Second') else writeln('First');\n end."}, {"source_code": "const c=6;\nvar a,b,x1,y1,x2,y2:longint;\n\n procedure swap(var a,b:longint);\n var c:longint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n procedure second;\n begin\n writeln('Second');\n halt;\n end;\n\n procedure first;\n begin\n writeln('First');\n halt;\n end;\n\n begin\n readln(a,b,x1,y1,x2,y2);\n if a=1 then\n begin\n swap(a,b);\n swap(x1,y1);\n swap(x2,y2);\n end;\n if b=1 then\n begin\n if abs(x1-x2)>4 then second else first;\n end;\n if (abs(x1-x2)+abs(y1-y2)>=c)and((abs(x1-x2)>=5)or(abs(y1-y2)>=5)) then second else first;\nend.\n\n"}, {"source_code": "const c=6;\nvar a,b,x1,y1,x2,y2:longint;\n\n procedure swap(var a,b:longint);\n var c:longint;\n begin\n c:=a; a:=b; b:=c;\n end;\n\n procedure second;\n begin\n writeln('Second');\n halt;\n end;\n\n procedure first;\n begin\n writeln('First');\n halt;\n end;\n\n begin\n readln(a,b,x1,y1,x2,y2);\n if a=1 then\n begin\n swap(a,b);\n swap(x1,y1);\n swap(x2,y2);\n end;\n if b=1 then\n begin\n if abs(x1-x2)>4 then second else first;\n end;\n if (abs(x1-x2)+abs(y1-y2)>=c)or(abs(x1-x2)>=5)or(abs(y1-y2)>=5) then second else first;\nend.\n\n"}, {"source_code": "var\n met:array [1..1000,1..1000] of longint;\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\n\n\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if (xx<=4)and(yy<=4)and(xx+yy-1>=6 )then writeln('Second')\n else writeln('First');\nend.\n"}, {"source_code": "var\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if xx+yy-1>=4 then writeln('Second')\n else writeln('First');\nend."}, {"source_code": "var\n met:array [1..1000,1..1000] of longint;\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\n\n\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if xx+yy-1>=6 then writeln('Second')\n else writeln('First');\nend."}, {"source_code": "var\n i,j,n,m,k,x1,y1,x2,y2,xx,yy:longint;\nbegin\n readln(n,m,x1,y1,x2,y2);\n xx:=abs(x1-x2);\n yy:=abs(y1-y2);\n if xx+yy-1>=5 then writeln('Second')\n else writeln('First');\nend."}, {"source_code": "var n,m,x1,y1,x2,y2,d1,d2:longint;\nbegin\nreadln(n,m,x1,y1,x2,y2);\nd1:=abs(x1-x2);\nd2:=abs(y1-y2);\nif (d1<=4) or (d2<=4) then writeln('First')\nelse writeln('Second');\nend.\n"}, {"source_code": "var n,m,x1,y1,x2,y2,d1,d2:longint;\nbegin\nreadln(n,m,x1,y1,x2,y2);\nd1:=abs(x1-x2);\nd2:=abs(y1-y2);\nif (d1<=4) and (d2<=4) then writeln('First')\nelse writeln('Second');\nend.\n"}, {"source_code": "program pr;\n var x1,y1,x2,y2,X,Y:longint;\n\nbegin\n read(x1,y1);\n read(x1,y1);\n read(x2,y2);\n\n X:=abs(x1 - x2);\n Y:=abs(y1 - y2);\n\n if (X >= 5) or (Y >= 5) then\n writeln('Second')\n else\n writeln('First');\nend.\n\n"}, {"source_code": "program pr;\n var x1,y1,x2,y2,X,Y,min,max:longint;\n\nbegin\n read(x1,y1);\n read(x1,y1);\n read(x2,y2);\n\n X:=abs(x1 - x2);\n Y:=abs(y1 - y2);\n\n if (X >= Y) then\n begin\n max:=X;\n min:=Y;\n end else\n begin\n max:=Y;\n min:=X;\n end;\n\n if (max >= 4) and (min >= 2) then\n writeln('Second')\n else\n writeln('First');\nend.\n\n"}, {"source_code": "program pr;\n var x1,y1,x2,y2,X,Y,min,max:longint;\n\nbegin\n read(x1,y1);\n read(x1,y1);\n read(x2,y2);\n\n X:=abs(x1 - x2);\n Y:=abs(y1 - y2);\n\n if (X >= Y) then\n begin\n max:=X;\n min:=Y;\n end else\n begin\n max:=Y;\n min:=X;\n end;\n\n if ((max >= 4) and (min >= 2)) or (max >= 5) then\n writeln('Second')\n else\n writeln('First');\nend.\n\n"}, {"source_code": "const nn=3004;\nvar a,b:array[0..nn] of integer; { c:array[-2001..2001,-2001..2001]of integer;\n} m,n,i,j,y,z,t,k,x:integer;s:string; q:char;\nbegin\n read(n,m,a[1],b[1],a[2],b[2]);\n if (abs(a[1]-a[2])>4)or(abs(b[1]-b[2])>4) then write('Second') else\n write('First');\nend."}], "src_uid": "41f6f90b7307d2383495441114fa8ea2"} {"source_code": "const\n finp='';\n fout='';\n maxn=1010;\n maxc=1000000000;\nvar\n fi,fo:text;\n n,k,m:longint;\n f:array[0..maxn,0..9,0..110,0..1] of int64;\n mu:array[0..maxn] of int64;\n\nprocedure openfile;\nbegin\n assign(fi,finp);\n assign(fo,fout);\n reset(fi);\n rewrite(fo);\nend;\n\nprocedure closefile;\nbegin\n close(fi);\n close(fo);\nend;\n\nfunction calc(vt,so,nho,kt:longint):int64;\nvar\n i:longint;\n res:int64;\nbegin\n if vt=n then exit( ord( (nho=0) and (so<>0) ) );\n if f[vt,so,nho,kt]<>-1 then exit(f[vt,so,nho,kt]);\n if (nho=0) and (vt<>0) and (kt<>0) then\n begin\n res:=9 mod m;\n for i:=vt+1 to n-1 do res:=(res*10) mod m;\n f[vt,so,nho,kt]:=res;\n //writeln(fo,vt,' ',so,' ',nho,' ',res);\n exit(res);\n end;\n res:=0;\n for i:=0 to 9 do\n res:=(res+calc(vt+1,i,(nho+i*mu[vt+1]) mod k,kt or ord(i<>0))) mod m;\n f[vt,so,nho,kt]:=res;\n //writeln(fo,vt,' ',so,' ',nho,' ',res);\n exit(res);\nend;\n\nprocedure nhap;\nvar\n i:longint;\nbegin\n read(fi,n,k,m);\n mu[1]:=1;\n for i:=2 to n do\n mu[i]:=(mu[i-1]*10) mod k;\n fillchar(f,sizeof(f),255);\n writeln(fo,calc(0,0,0,0));\nend;\n\nBEGIN\n openfile;\n nhap;\n closefile;\nEND.\n\n\n", "positive_code": [{"source_code": "var\n i,j,x:longint;\n ans,n,m,t,k:int64;\n a,b:array[0..1111]of int64;\n f:array[0..1111,0..1111]of int64;\nbegin\n readln(n,k,m);\n a[1]:=1;\n for i:=2 to n do a[i]:=(a[i-1]*10)mod k;\n b[0]:=1;b[1]:=9;\n for i:=2 to n do b[i]:=(b[i-1]*10)mod m;\n f[0,0]:=1;\n for i:=1 to n do for j:=0 to k-1 do for x:=0 to 9 do\n if(x>0)and((j+x*a[i])mod k=0)then ans:=(ans+f[i-1,j]*b[n-i])mod m else\n f[i,(j+x*a[i])mod k]:=(f[i,(j+x*a[i])mod k]+f[i-1,j])mod m;\n writeln(ans);\nend.\n"}, {"source_code": "var\n f : array[0..1010,0..110,0..1] of longint;\n n,m,k,i,j,c,nn,q,cr,ans : longint;\n\n function add(a,b : longint) : longint; begin exit((a+b) mod m); end;\n\nbegin\n readln(n,k,m);\n f[0,0,0]:=1;\n cr:=1;\n for i:=0 to n-1 do begin for j:=0 to k-1 do for q:=0 to 1 do for c:=0 to 9 do begin\n if (i = n-1) and (c = 0) then continue;\n nn:=(j+cr*c) mod k;\n if (nn = 0) and (c > 0) then f[i+1,nn,1]:=add(f[i+1,nn,1],f[i,j,q]) else f[i+1,nn,q]:=add(f[i+1,nn,q],f[i,j,q]);\n end;\n cr:=(cr*10) mod k;\n end;\n ans:=0;\n for i:=0 to k-1 do ans:=(ans+f[n,i,1]) mod m;\n writeln(ans);\nend."}, {"source_code": "const fi='';//287D.inp';\n fo='';\n maxn=1005;\n maxk=105;\n\nvar n,m,k:longint;\n f:array[1..maxn,0..maxk,0..1,0..1] of longint;\n mu:array[1..maxn] of longint;\n\nprocedure docdl;\nbegin\n readln(n,k,m);\nend;\n\nfunction tinh(i,t,ok,truez:longint):longint;\nvar j,minj,sl,tmp:longint;\nbegin\n if (i>n) then\n begin\n if (ok=1) and (truez=1) then exit(1);\n exit(0);\n end;\n if (f[i,t,ok,truez]<>-1) then exit(f[i,t,ok,truez]);\n sl:=0;\n if (i=n) then minj:=1 else minj:=0;\n if (ok=1) then\n begin\n for j:=minj to 9 do\n begin\n tmp:=(t+j*mu[i]) mod k;\n sl:=(sl+tinh(i+1,tmp,1,truez or ord(j>0))) mod m;\n end;\n end\n else\n begin\n for j:=minj to 9 do\n if (j<>0) then\n begin\n tmp:=(t+j*mu[i]) mod k;\n sl:=(sl+tinh(i+1,tmp,ord(tmp mod k=0),1)) mod m;\n end\n else sl:=(sl+tinh(i+1,t,0,truez)) mod m;\n end;\n f[i,t,ok,truez]:=sl;\n exit(sl);\nend;\n\nprocedure xuli;\nvar i:longint;\nbegin\n mu[1]:=1;\n for i:=2 to n do\n mu[i]:=(mu[i-1]*10) mod k;\n fillchar(f,sizeof(f),255);\n writeln(tinh(1,0,0,0));\nend;\n\nBEGIN\n assign(input,fi);\n assign(output,fo);\n reset(input);\n rewrite(output);\n\n docdl;\n xuli;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "var n,k,m,i,j,z,o,ans:longint;\nt:array[0..10000] of longint;\ndp:array[0..1000,0..100,1..2] of longint;\n\n\nbegin\n//(input,'sxjz.in');reset(input);\n//assign(output,'sxjz.out');rewrite(output);\nreadln(n,k,m);\nt[0]:=1;\nfor i:=1 to 1000 do t[i]:=(t[i-1]*10) mod k;\ndp[0,0,1]:=1;\nfor i:=0 to n-1 do\n begin\n for j:=0 to k-1 do\n begin\n for z:=0 to 9 do\n begin\n if (i=n-1) and (z=0) then continue;\n o:=(z*t[i]+j) mod k;\n if (o=0) and (z>0) then\n dp[i+1,o,2]:=(dp[i+1,o,2]+dp[i,j,1]) mod m\n else\n dp[i+1,o,1]:=(dp[i+1,o,1]+dp[i,j,1]) mod m;\n dp[i+1,o,2]:=(dp[i+1,o,2]+dp[i,j,2]) mod m;\n end;\n end;\n end;\nans:=0;\nfor i:=0 to k-1 do\n ans:=(ans+dp[n,i,2]) mod m;\nwrite(ans);\nclose(input);close(output);\nend."}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$macro on}\nuses math;\nconst\n fin ='';//p507d.inp';\n fou ='';\n maxn = 1010;\n maxk = 100;\n base = trunc(1e9)+7;\ntype\n pair = record\n fi,se :longint;\n end;\nvar\n n,k,m :longint;\n f :array[0..maxn,0..maxk,false..true] of longint;\n v :array[0..9,0..maxn] of longint;\nprocedure enter;\nbegin\n readln(n,k,m);\nend;\n\nfunction cal(i,r :longint;ok :boolean):longint;\nvar\n c :longint;\nbegin\n if i=0 then exit(ord(ok));\n if f[i,r,ok]<>-1 then exit(f[i,r,ok]);\n f[i,r,ok]:=0;\n for c:=0 to 9 do\n if (i<>1) or (c<>0) then\n begin\n f[i,r,ok]:=(f[i,r,ok]+cal(i-1,(r+v[c,i]) mod k,ok or ((c>0) and ((r+v[c,i]) mod k=0)))) mod m;\n end;\n// writeln(i,' ',r,' ',ok,' ',f[i,r,ok]);\n exit(f[i,r,ok]);\nend;\nprocedure solve;\nvar\n i,j :longint;\nbegin\n fillchar(f,sizeof(f),255);\n for i:=1 to 9 do\n begin\n v[i,n]:=i mod k;\n for j:=n-1 downto 1 do\n v[i,j]:=v[i,j+1]*10 mod k;\n end;\n writeln(cal(n,0,false));\nend;\n\nBEGIN\n assign(input,fin); reset(input);\n assign(output,fou); rewrite(output);\n\n enter;\n solve;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "var\n dp:array [0..1010,0..111] of Int64;\n i,j,u:Longint;\n a,b:array [0..1010] of Int64;\n N,K,M,answer,y:Int64;\nbegin\n Readln(N,K,M);\n dp[0][0]:=1;\n a[1]:=1 mod k;\n b[1]:=9 mod m;\n b[0]:=1;\n dp[1][0]:=0;\n for i:=2 to N do\nbegin\n a[i]:=(a[i-1]*10) mod k;\n b[i]:=(b[i-1]*10) mod m;\n dp[i][0]:=0;\n end;\n answer:=0;\n for i:=0 to n-1 do\n for j:=0 to k-1 do\n for u:=0 to 9 do\nbegin\n y:=(j+u*a[i+1]) mod k;\n if (u>0) and (y=0) then answer:=(answer+(dp[i][j]*b[n-i-1])) mod m\n else dp[i+1][y]:=(dp[i+1][y]+dp[i][j]) mod m;\n end;\n Writeln(answer);\n end.\n"}, {"source_code": "const\n fi='';\n fo='';\n maxn=1000;\n\nvar\n n,k,m:longint;\n mu:array[1..maxn] of longint;\n F:array[1..maxn,0..110,0..1,0..1] of longint;\n\nprocedure Docdl;\nvar\n i,j:longint;\nbegin\n readln(n,k,m);\nend;\n\nfunction Tinh(i,modul,check,zero:longint):longint;\nvar\n j,minj:longint;\n check1,zero1:longint;\n sl:longint;\n tmp:string;\nbegin\n if (i>n) then\n begin\n if (modul=0) and (check=0) and (zero=1) then\n begin\n exit(1);\n end;\n exit(check);\n end;\n if F[i,modul,check,zero]<>-1 then exit(F[i,modul,check,zero]);\n sl:=0;\n if i=n then minj:=1 else minj:=0;\n if check=1 then\n begin\n for j:=minj to 9 do\n begin\n if j<>0 then zero1:=1 else zero1:=0;\n sl:=(sl+Tinh(i+1,(modul + j*mu[i]) mod k,1,zero1)) mod m;\n end;\n end\n else\n begin\n for j:=minj to 9 do\n begin\n if j<>0 then\n begin\n if (modul + j*mu[i]) mod k =0 then check1:=1 else check1:=0;\n sl:=(sl + Tinh(i+1,(modul + j*mu[i]) mod k,check1,1)) mod m;\n end\n else sl:=(sl + Tinh(i+1,modul,0,zero)) mod m;\n end;\n end;\n F[i,modul,check,zero]:=sl;\n exit(sl);\nend;\n\nprocedure Xuli;\nvar\n i,j:longint;\nbegin\n mu[1]:=1;\n for i:=2 to n do\n begin\n mu[i]:=(mu[i-1]*10) mod k;\n end;\n fillchar(F,sizeof(F),255);\n writeln(Tinh(1,0,0,0));\nend;\n\n\nBEGIN\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n docdl;\n xuli;\n close(input); close(output);\nEND.\n"}, {"source_code": "program D507;\nconst\n finp = '';\n fout = '';\n maxn = 1000+1;\n maxmod = 100+1;\nvar\n f : array [0..maxn,0..maxmod,0..1,0..1] of longint;\n pow : array [0..maxn] of longint;\n fi,fo : text;\n n,k,m : longint;\nprocedure mofile;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(Fo,fout);\n rewrite(fo);\nend;\nprocedure input;\nbegin\n readln(Fi,n,k,m);\nend;\nprocedure dp;\nvar\n i,res,pos,d,td,valid,tvalid,zero,tzero,cs : longint;\nbegin\n f[0,0,0,0] := 1;\n pow[0] := 1;\n for i := 1 to n do\n pow[i] := (pow[i-1]*10) mod k;\n\n for pos := 0 to n-1 do\n for d := 0 to k-1 do\n for valid := 0 to 1 do\n for zero := 0 to 1 do\n if f[pos,d,valid,zero] <> 0 then\n begin\n for cs := ord(pos = (n-1)) to 9 do\n begin\n td := (d+cs*pow[pos]) mod k;\n tzero := zero or ord(cs <> 0);\n tvalid := valid or ( ord(td = 0) and tzero );\n f[pos+1,td,tvalid,tzero] := f[pos+1,td,tvalid,tzero] + f[pos,d,valid,zero];\n f[pos+1,td,tvalid,tzero] := f[pos+1,td,tvalid,tzero] mod m;\n end;\n end;\n\n res := 0;\n for d := 0 to k-1 do\n res := (res + f[n,d,1,1]) mod m;\n\n writeln(Fo,res);\nend;\nprocedure dongfile;\nbegin\n close(fi);\n close(Fo);\nend;\nbegin\n mofile;\n input;\n dp;\n dongfile;\nend.\n"}, {"source_code": "const\n finp = '';\n maxN = 1010;\n maxK = 110;\n\nvar\n fi : text;\n n,k,m,res : longint;\n f,g : array[0..maxN,0..maxK] of int64;\n x10 : array[0..maxN] of longint;\n count : array[0..maxK] of longint;\n\nprocedure init;\nvar\n i : longint;\nbegin\n assign(fi,finp); reset(fi);\n read(fi,n,k,m);\n close(fi);\nend;\n\nprocedure process;\nvar\n i,j,p : longint;\n t,d : int64;\nbegin\n x10[0]:=1;\n for i:=1 to n do x10[i]:=(x10[i-1]*10) mod k;\n\n f[0,0]:=1;\n\n for i:=1 to n do\n begin\n for j:=0 to k-1 do\n for p:=0 to 9 do\n begin\n d:=j-p*x10[i-1] mod k;\n if d<0 then d:=d+k;\n f[i,j]:=(f[i,j]+f[i-1,d]) mod m;\n end;\n end;\n\n for i:=1 to n do\n for j:=0 to k-1 do\n begin\n g[i,j]:=0;\n for p:=0 to k-1 do\n if (j*p) mod k = 0 then g[i,j]:=(g[i,j]+f[i,p]) mod m;\n end;\n\n for i:=1 to n do\n begin\n f[i,0]:=(f[i,0]-1+m) mod m;\n\n for j:=1 to i-1 do f[i,0]:=(f[i,0]-f[j,0]*g[i-j,x10[j]]) mod m;\n\n if f[i,0]<0 then f[i,0]:=f[i,0]+m;\n end;\n\n t:=1;\n res:=f[n,0];\n for i:=n-1 downto 1 do\n begin\n d:=(f[i,0]*9*t) mod m;\n res:=(res+d) mod m;\n t:=(t*10) mod m;\n end;\n\n writeln(res);\nend;\n\nbegin\n init;\n process;\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\n maxn=1010;\nvar\n fi,fo:text;\n f:array[1..maxn,0..110,false..true] of longint;\n mu:array[0..maxn] of longint;\n n,k,m:longint;\n{---------------------}\nprocedure mo;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(fo,fout);\n rewrite(fo);\nend;\n{---------------------}\nprocedure doc;\nbegin\n readln(fi,n,k,m);\nend;\n{---------------------}\nfunction find(x,r:longint;subfix:boolean):longint;\nvar\n i,tg,newr:longint;\n check:boolean;\nbegin\n if x>n then exit(ord(subfix));\n if (f[x,r,subfix]<>-1) then exit(f[x,r,subfix]);\n tg:=0;\n for i:=0 to 9 do\n if ((x=n) and (i<>0)) or (x<>n) then\n begin\n newr:=(r+i*mu[x-1]) mod k;\n check:=subfix or ((i<>0) and (newr=0));\n tg:=(tg+find(x+1,newr,check)) mod m;\n end;\n f[x,r,subfix]:=tg;\n exit(tg);\nend;\n{---------------------}\nprocedure xuli;\nvar\n i:longint;\nbegin\n fillchar(f,sizeof(f),255);\n mu[0]:=1 mod k;\n for i:=1 to n do\n begin\n mu[i]:=(mu[i-1]*10) mod k;\n end;\n writeln(fo,find(1,0,false));\nend;\n{---------------------}\nprocedure ghi;\nbegin\nend;\n{---------------------}\nprocedure dong;\nbegin\n close(fi);\n close(fo);\nend;\n{---------------------}\nbegin\n mo;\n doc;\n xuli;\n ghi;\n dong;\nend.\n\n"}, {"source_code": "program math_lecture;\n\nconst\n tfi = '';//'507d.inp';\n tfo = '';//'507d.out';\n\nvar\n n,k,base : longint;\n f : array [0..1000,0..99,0..1] of longint;\n dd : array [0..1000,0..99,0..1] of boolean;\n fi,fo : text;\n\nprocedure input;\n begin\n assign(fi,tfi);\n reset(fi);\n read(fi,n,k,base);\n close(fi);\n end;\n\nfunction power(i,modul : longint) : longint;\n var tmp : longint;\n begin\n if i = 0 then exit(1);\n tmp := power(i div 2,modul);\n tmp := int64(tmp)*tmp mod modul;\n if i mod 2 = 1 then tmp := int64(tmp)*10 mod modul;\n exit(tmp);\n end;\n\nfunction cal(i,t,xh : longint) : longint;\n var d,j,xh1 : longint;\n begin\n if not dd[i,t,xh] then\n begin\n dd[i,t,xh] := true;\n if i = n then\n begin\n if (t = 0) and (xh = 1) then f[i,t,xh] := 1;\n end\n else\n if (i > 0) and (t = 0) and (xh = 1) then f[i,t,xh] := int64(power(n-i-1,base))*9 mod base\n else\n begin\n if i = n-1 then d := 1 else d := 0;\n for j := d to 9 do\n begin\n if (xh = 0) and (j = 0) then xh1 := 0 else xh1 := 1;\n f[i,t,xh] := (f[i,t,xh] + cal(i+1,(t + j*power(i,k)) mod k,xh1)) mod base;\n end;\n end;\n end;\n exit(f[i,t,xh]);\n end;\n\nprocedure output;\n begin\n assign(fo,tfo);\n rewrite(fo);\n write(fo,cal(0,0,0));\n close(fo);\n end;\n\nbegin\n input;\n output;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n maxn=1100;\n maxc=1000000000;\nvar\n f:array[0..maxn,0..110,{0..1,}0..1] of int64;\n n,k,base:longint;\n mu:array[0..maxn] of int64;\n res:int64;\n{-------------------------}\nprocedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n{------------------------}\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n{-------------------------}\nprocedure nhap;\nbegin\n readln(n,k,base);\nend;\n{-------------------------}\nprocedure xuly;\nvar\n i,j,l,r,o:longint;\n tmp:longint;\n sum:int64;\nbegin\n f[0,0,0]:=1;\n\n mu[0]:=1;\n for i:=1 to n do mu[i]:=(mu[i-1]*10) mod k;\n for i:=1 to n do\n begin\n for o:=0 to k-1 do\n for j:=0+ord(i=n) to 9 do\n begin\n tmp:=(o+j*mu[i-1]) mod k;\n for r:=0 to 1 do\n begin\n f[i,tmp,r or (ord(tmp=0) and ord(j>0))]:=(f[i,tmp,r or (ord(tmp=0) and ord(j>0))]+f[i-1,o,r]) mod base;\n end;\n end;\n end;\n\n for i:=0 to k-1 do\n begin\n res:=(res+f[n,i,1]) mod base;\n end;\n writeln(res);\nend;\n{-------------------------}\nBEGIN\n openfiles;\n nhap;\n xuly;\n closefiles;\nEND.\n\n"}, {"source_code": "var\n\tans:Int64;\n\tnines,tens:array[0..1001]of Int64; \n\tdp:array[0..1001,0..1001]of Int64;\n\tn,k,m,i,j,c:longint;\nbegin\n\tread(n,k,m);\n\ttens[1]:=1;\n\tfor i:=2 to n do tens[i]:=(tens[i-1]*10)mod k;\n\t\n\tnines[0]:=1;\n\tnines[1]:=9;\n\tfor i:=2 to n do nines[i]:=(nines[i-1]*10)mod m;\n\t\n\tdp[0,0]:=1;\n\t\n\tfor i:=1 to n do\n\tfor j:=0 to k-1 do\n\tfor c:=0 to 9 do\n\t\tif((c>0)and(((j+c*tens[i])mod k)=0)) then ans:=(ans+dp[i-1,j]*nines[n-i])mod m\n\t\telse dp[i,(j+c*tens[i])mod k]:=(dp[i,(j+c*tens[i])mod k]+dp[i-1,j])mod m;\n\twriteln(ans);\nend.\n"}], "negative_code": [{"source_code": "var\n ans,i,j,n,m,t,x,k:longint;\n a,b:array[0..1111]of longint;\n f:array[0..1111,0..1111]of longint;\nbegin\n readln(n,k,m);\n a[1]:=1;\n for i:=2 to n do a[i]:=(a[i-1]*10)mod k;\n b[0]:=1;b[1]:=9;\n for i:=2 to n do b[i]:=(b[i-1]*10)mod m;\n f[0,0]:=1;\n for i:=1 to n do for j:=0 to k-1 do for x:=0 to 9 do\n if(x>0)and((j+x*a[i])mod k=0)then ans:=(ans+f[i-1,j]*b[n-i])mod m else\n f[i,(j+x*a[i])mod k]:=(f[i,(j+x*a[i])mod k]+f[i-1,j])mod m;\n writeln(ans);\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\n maxn=1010;\n maxc=1000000000;\nvar\n fi,fo:text;\n n,k,m:longint;\n f:array[0..maxn,0..9,0..110] of int64;\n mu:array[0..maxn] of int64;\n\nprocedure openfile;\nbegin\n assign(fi,finp);\n assign(fo,fout);\n reset(fi);\n rewrite(fo);\nend;\n\nprocedure closefile;\nbegin\n close(fi);\n close(fo);\nend;\n\nfunction calc(vt,so,nho:longint):int64;\nvar\n i:longint;\n res:int64;\nbegin\n if vt=n then exit( ord( (nho=0) and (so<>0) ) );\n if f[vt,so,nho]<>-1 then exit(f[vt,so,nho]);\n if (nho=0) and (vt<>0) then\n begin\n res:=9 mod m;\n for i:=vt+1 to n-1 do res:=(res*10) mod m;\n f[vt,so,nho]:=res;\n //writeln(fo,vt,' ',so,' ',nho,' ',res);\n exit(res);\n end;\n res:=0;\n for i:=0 to 9 do\n res:=(res+calc(vt+1,i,(nho+i*mu[vt+1]) mod k)) mod m;\n f[vt,so,nho]:=res;\n //writeln(fo,vt,' ',so,' ',nho,' ',res);\n exit(res);\nend;\n\nprocedure nhap;\nvar\n i:longint;\nbegin\n read(fi,n,k,m);\n mu[1]:=1;\n for i:=2 to n do\n mu[i]:=(mu[i-1]*10) mod k;\n fillchar(f,sizeof(f),255);\n writeln(fo,calc(0,0,0));\nend;\n\nBEGIN\n openfile;\n nhap;\n closefile;\nEND.\n\n\n"}, {"source_code": "const\n fi='';\n fo='';\n maxn=1000;\n\nvar\n n,k,m:longint;\n mu:array[1..maxn] of longint;\n F:array[1..maxn,0..110,0..1,0..1] of longint;\n\nprocedure Docdl;\nvar\n i,j:longint;\nbegin\n readln(n,k,m);\nend;\n\nfunction Tinh(s:string; i,modul,check,zero:longint):longint;\nvar\n j,minj:longint;\n check1,zero1:longint;\n sl:longint;\n tmp:string;\nbegin\n if (i>n) then\n begin\n if (modul=0) and (check=0) and (zero=1) then\n begin\n // writeln(s);\n exit(1);\n end;\n // if check=1 then writeln(s);\n exit(check);\n end;\n if F[i,modul,check,zero]<>-1 then exit(F[i,modul,check,zero]);\n sl:=0;\n if i=n then minj:=1 else minj:=0;\n if check=1 then\n begin\n for j:=minj to 9 do\n begin\n if j<>0 then zero1:=1 else zero1:=0;\n tmp:=s+chr(j+48);\n sl:=(sl+Tinh(tmp,i+1,(modul + j*mu[i]) mod k,1,zero1)) mod m;\n end;\n end\n else\n begin\n for j:=minj to 9 do\n begin\n tmp:=s+chr(j+48);\n if j<>0 then\n begin\n if (modul + j*mu[i]) mod k =0 then check1:=1 else check1:=0;\n sl:=(sl + Tinh(tmp,i+1,(modul + j*mu[i]) mod k,check1,1)) mod m;\n end\n else sl:=(sl + Tinh(tmp,i+1,modul,0,zero)) mod m;\n end;\n end;\n F[i,modul,check,zero]:=sl;\n exit(sl);\nend;\n\nprocedure Xuli;\nvar\n i,j:longint;\nbegin\n mu[1]:=1;\n for i:=2 to n do\n begin\n mu[i]:=(mu[i-1]*10) mod m;\n end;\n fillchar(F,sizeof(F),255);\n writeln(Tinh('',1,0,0,0));\nend;\n\n\nBEGIN\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n docdl;\n xuli;\n close(input); close(output);\nEND.\n"}, {"source_code": "const\n finp = '';\n maxN = 1010;\n maxK = 110;\n\nvar\n fi : text;\n n,k,m,res : longint;\n f,g : array[0..maxN,0..maxK] of longint;\n\nprocedure init;\nvar\n i : longint;\nbegin\n assign(fi,finp); reset(fi);\n read(fi,n,k,m);\n close(fi);\nend;\n\nprocedure process;\nvar\n i,j,p,t,d : longint;\nbegin\n f[0,0]:=1;\n\n t:=1;\n for i:=1 to n do\n begin\n for j:=0 to k-1 do\n for p:=0 to 9 do\n begin\n d:=j-(p*t) mod k;\n if d<0 then d:=d+k;\n\n f[i,j]:=(f[i,j]+f[i-1,d]) mod m;\n end;\n\n t:=(t*10) mod k;\n end;\n\n g:=f;\n\n for i:=1 to n do\n begin\n f[i,0]:=(f[i,0]-1+m) mod m;\n t:=10;\n for j:=1 to i-1 do\n begin\n for p:=0 to k-1 do\n if (p*t) mod k = 0 then f[i,0]:=(f[i,0]-(int64(f[j,0])*g[i-j,p]) mod m + m) mod m;\n\n t:=(t*10) mod k;\n end;\n end;\n\n t:=1;\n res:=f[n,0] mod m;\n for i:=n-1 downto 1 do\n begin\n d:=(int64(f[i,0])*9*t) mod m;\n res:=(res+d) mod m;\n t:=(t*10) mod m;\n end;\n\n writeln(res);\nend;\n\nbegin\n init;\n process;\nend."}, {"source_code": "const\n fi='';\n fo='';\n maxn=1100;\n maxc=1000000000;\nvar\n f:array[0..maxn,0..110,0..1,0..1] of int64;\n n,k,base:longint;\n mu:array[0..maxn] of int64;\n res:int64;\n{-------------------------}\nprocedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n{------------------------}\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n{-------------------------}\nprocedure nhap;\nbegin\n readln(n,k,base);\nend;\n{-------------------------}\nprocedure xuly;\nvar\n i,j,l,r,o:longint;\n tmp:longint;\n sum:int64;\nbegin\n f[0,0,0,0]:=1;\n\n mu[0]:=1;\n for i:=1 to n do mu[i]:=(mu[i-1]*10) mod base;\n for i:=1 to n do\n begin\n for o:=0 to k-1 do\n for j:=0+ord(i=n) to 9 do\n begin\n tmp:=(o+j*mu[i-1]) mod k;\n for l:=0 to 1 do\n for r:=0 to 1 do\n begin\n f[i,tmp,l or ord(j>0),(r and l) or ord(tmp=0)]:=(f[i,tmp,l or ord(j>0),(r and l) or ord(tmp=0)]+f[i-1,o,l,r]) mod base;\n end;\n end;\n end;\n\n for i:=0 to k-1 do\n begin\n res:=(res+f[n,i,1,1]) mod base;\n end;\n writeln(res);\nend;\n{-------------------------}\nBEGIN\n openfiles;\n nhap;\n xuly;\n closefiles;\nEND.\n\n"}], "src_uid": "656bf8df1e79499aa2ab2c28712851f0"} {"source_code": "var k,a,b: longint;\nbegin\nreadln (k,a,b);\nif (a=0) and (b mod k=0) then writeln (b div k) else\nif (a=0) and (b mod k<>0) then writeln ('-1') else\nif (b=0) and (a mod k=0) then writeln (a div k) else\nif (b=0) and (a mod k<>0) then writeln ('-1') else\nif ((a>=k) and (b>=k)) or ((a=k) or (b=k)) or ((a mod k=0) or (b mod k=0)) then writeln (a div k + b div k)\nelse writeln ('-1');\nend.", "positive_code": [{"source_code": "program j01;\nvar ans,k,a,b,d,aa,bb:int64;\nprocedure swap(var a,b:int64);\nvar c:int64;\nbegin\n c:=a;a:=b;b:=c;\nend;\nbegin\n readln(k,a,b);\n ans:=0;\n if a0)then\n begin\n writeln(-1);halt;\n end;\n if(bb=0)and(a mod k>0)then\n begin\n writeln(-1);halt;\n end;\n writeln(aa+bb);\nend."}, {"source_code": "var k,a,b: longint;\nbegin\n readln(k,a,b);\n if ((a mod k <>0)and(b 0)and(a 0) and (n2 = 0)) or ((b <> 0) and (n1 = 0)) or ((n1 + n2) = 0) then\n writeln(-1)\n else writeln(n1 + n2);\n readln;\nend.\n"}, {"source_code": "VAR k,a,b:int64;\nBEGIN\n read(k,a,b);\n if(a div k>0)and(b div k>0)then write((a div k)+(b div k))\n else if a div k>0 then if a mod k=0 then write(a div k)\n else write(-1)\n else if b div k>0 then if b mod k=0 then write(b div k)\n else write(-1)\n else write(-1);\nEND."}, {"source_code": "var n,a,b,k,m,p:int64;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(k,a,b);\n n:=a div k;\n m:=b div k;\n p:=n+m;\n if (n+m=0)or((m=0)and(a mod k>0))or((n=0)and(b mod k>0)) then p:=-1;\n write(p);\nend.\n\n"}, {"source_code": "var\n k,a,b,x,y : int64;\n\nbegin\n readln(k,a,b);\n if k = 1 then begin writeln(a+b); halt; end;\n x:=a div k; y:=b div k;\n a:=a-x*k; b:=b-y*k;\n if (a div (k-1)+ord(a mod (k-1) > 0) > y) or (b div (k-1)+ord(b mod (k-1) > 0) > x) then begin writeln(-1); halt; end;\n writeln(x+y);\nend."}, {"source_code": "program dav;\nvar ansa,ansb: int64;\na,b,k: longint;\n\nprocedure stop;\nbegin\nwrite(-1);\nhalt;\nend;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(k,a,b);\nif (a 0)) or ((a mod k > 0) and (b div k = 0)) then writeln(-1) else writeln(a div k + b div k);\nend.\n \n "}, {"source_code": "const fi='TTG2.inp';\n fo='TTG2.out';\nvar k,a,b:longint;\nprocedure mo;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n\nprocedure nhap;\nbegin\n readln(k,a,b);\n if (a < k)and(b0) then\n begin\n writeln('-1');\n exit;\n end;\n if(a mod k <>0)and(b =0) then\n begin\n writeln('-1');\n exit;\n end;\n\n if(a mod k =0)or(b mod k =0) then\n begin\n writeln((a div k)+(b div k));\n exit;\n end\n else\n begin\n if (a 0)and(b <> 0))then\n writeln((a div k)+(b div k))\n else\n writeln('-1');\n end;\n end;\n end;\nend;\n\nbegin\n \n nhap;\nend.\n"}, {"source_code": "var a,b,c,dop:longint;\nbegin\n readln(a,b,c);\n if b<=c then begin\n dop:=c;\n c:=b;\n b:=dop;\n end;\n if (b mod a<>0)and(c0) and (b0) and (a0) and (b0) and (a(k-1)*(b div k)) or (b mod k>(k-1)*(a div k)) then r:=-1;\n write(r);\nend."}, {"source_code": "var k,a,b,a1,b1:longint;\nbegin\nread(k,a,b);\na1:=a div k;\nb1:=b div k;\nif (a1+b1<1)or((a1=0)and(b1*k<>b))or((b1=0)and(a1*k<>a)) then writeln('-1') else\nwriteln(a1+b1);\nend."}, {"source_code": "program qq;\nvar i,k,b,a,x1,y1,f,x2,y2:longint;\nbegin\n read(k,a,b);\n x1:=a mod k;\n y1:=b mod k;\n x2:=a div k;\n y2:=b div k;\n f:= x2+y2;\n if ((x1<>0) and (y2=0)) or ((y1<>0)and(x2=0)) then writeln(-1) else writeln(f);\nend."}, {"source_code": "var k,a,b,t:integer;\n m,n,x,y:integer;\nprocedure nhap;\n begin\n readln(k,a,b);\n end;\nprocedure xuly;\n begin\n m:=a div k;x:=a mod k;\n n:=b div k;y:=b mod k;\n\n //writeln(m,' ',n,' ',x,' ',y);\n\n if a=0 then\n begin if (y=0) and (n>0) then writeln(n)\n else writeln(-1);\n end\n else\n if b=0 then\n begin if (x=0) and (m>0) then writeln(m)\n else writeln(-1);\n end\n else\n begin\n if (m=0) or (n=0) then\n begin if (x<>0) and (y<>0) then writeln(-1)\n else\n if m>n then\n begin if m>0 then writeln(m) else writeln(-1);\n end\n else\n begin if n>0 then writeln(n) else writeln(-1);\n end\n end\n else\n begin t:=n+m;\n writeln(t);\n end;\n end;\n end;\nbegin\n //clrscr;\n nhap;\n xuly;\n //readln;\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,ans:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(k,a,b);\nif a0 then write('-1') else write(a div k); exit; end;\nans:=(a div k) + (b div k);\nwriteln(ans);\nend."}, {"source_code": "var k,a,b:longint;\nbegin\n//assign(input,'ppqbs.in');reset(input);\n//assign(output,'ppqbs.out');rewrite(output);\nreadln(k,a,b);\nif (a>=k)and(b>=k) then writeln(a div k+b div k)\nelse if (a>=k)and(b=k)and(a0) and (b0) and (a A1 ) then\n begin\n tmp := B1;\n B1 := A1;\n A1 := tmp;\n \n tmp := B;\n B := A;\n A := tmp;\n end;\n \n if ( B1 = 0 ) then\n begin\n \n if ( A mod K <> 0 ) then\n Cant := true;\n \n end;\n \n \n if ( cant ) then\n writeLn ( -1 )\n else\n\twriteLn ( A1 + B1 );\n \nend.\n"}, {"source_code": "var k,a,b: longint;\nbegin\n readln(k,a,b);\n if ((a mod k <>0)and(b 0)and(a 0) and (a div k > 0) and (b div k > 0)) or\n ((b mod k <> 0) and (b div k > 0) and (a div k > 0)) or\n ((a mod k = 0) and (a+b>=k) and (a<>0)) or\n ((b mod k = 0) and (a+b>=k) and (b<>0)) then\n write((a div k) + (b div k)) else write(-1);\nend.\n"}, {"source_code": "var k,a,b,x,y,x1,y1:int64;\nbegin\n readln(k,a,b);\n x:=a div k;\n y:=b div k;\n x1:=a mod k;\n y1:=b mod k;\n if (x1<>0) and (y=0) then writeln(-1)\n else if (y1<>0) and (x=0) then writeln(-1)\n else writeln(x+y);\n\nend."}, {"source_code": "var k,a,b:int64;\n ans:boolean;\nbegin\n readln(k,a,b);\n if (a0) and (b0) and (ab) then begin writeln('-1'); halt; end;\n\t\n\tif (y=0) and (f*n<>a) then begin writeln('-1'); halt; end;\n\n\n\twriteln((a div n) + (b div n));\nend."}, {"source_code": "var k,a,b,i:longint;\nbegin\nread(k,a,b);\nif (((a-1) mod kb)and(a>c))or((b div a=0)and (c mod a>0))or\n ((b mod a>0)and (c div a=0))then write(-1) else write(b div a+c div a);\nend."}, {"source_code": "program cf;\nvar a,b,k,c1,c2: longint;\nbegin\nread(k);\nread(a);\nread(b);\nc1:=a div k;\na:=a mod k;\nc2:=b div k;\nb:=b mod k;\nif ((c2=0) and (a>0)) or ((c1=0) and (b>0)) then\nwrite(-1)\nelse\nwrite(c1+c2);\nend."}, {"source_code": "var i,j,m,n,k,a,b:longint;\nbegin\n readln(k,a,b);\n if (a=k) and (b=k) then begin\n if b mod k=0 then writeln(b div k) else writeln(-1);\n halt;\n end;\n writeln(a div k+b div k);\nend."}, {"source_code": "var k,a,b:longint;\nbegin\nread (k,a,b);\nif ((a 0))\nor ((b 0)) then write ('-1') else write (a div k+b div k);\nend."}, {"source_code": "var k,a,b,i,j,ans:longint;\nbegin\nwhile not eof do begin\n readln(k,a,b);\n ans:=0;\n ans:=(a div k) + (b div k);\n if ((a0))or((b0)) then writeln(-1) else writeln(ans);\nend;\nend.\n"}, {"source_code": "var k,a,b,a1,a2,dop:int64;\nbegin\n readln(k,a,b);\n\n a1:=a div k;\n a2:=b div k;\n\n if a>b then begin\n a1:=a div k;\n a2:=b div k;\n\n end\n else begin\n a1:=b div k;\n a2:=a div k;\n dop:=a;\n a:=b;\n b:=dop;\n end;\n\n if (a1=0) or ((b0)) then writeln(-1)\n else writeln(a1+a2);\nend.\n"}, {"source_code": "var k,a,b,n,a1,b1: longint;\nbegin;\nread(k,a,b);\na1:=a div k;\nb1:=b div k;\nn:=a1+b1;\nif (n=0) or ((a mod k>0) and (b1=0)) or ((b mod k>0) and (a1=0)) then write(-1) else write(n);\nreadln\nend."}, {"source_code": "var\n a, b, c, d: int64;\n \nbegin\n readln(a, b, c);\n if (b < a) and (c < a) then begin\n writeln(-1);\n halt();\n end;\n if (b mod a > 0) and (c < a) then begin\n writeln(-1);\n halt();\n end;\n if (c mod a > 0) and (b < a) then begin\n writeln(-1);\n halt();\n end;\n writeln(b div a + c div a);\nend."}, {"source_code": "var k,a,b,c:integer;\nbegin\nreadln(k,a,b);\nc:=a div k + b div k;\nif (c=0) or ((b mod k<>0) and (a0) and (b0) and (a>m*(k-1))) or ((b>n*(k-1)) and (b>0)) then writeln('-1')\n else writeln(s);\nend."}, {"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif (a mod k=0)and(a<>0) then s:=s+(a div k)+(b div k)\n else\n if (b>=k)and(a div k>0) then s:=s+(a div k)+(b div k)\n else s:=-1;\nif (a0) then begin s:=b div k;end;\nwrite(s);\nend."}, {"source_code": "var k,a,b,sc1,sc2:integer;\nbegin\nreadln(k,a,b);\nsc1:=a div k;\na:=a mod k;\nsc2:=b div k;\nb:=b mod k;\nIf (a>0)and(sc2=0)\n then writeln(-1)\n else if (b>0)and(sc1=0)\n then writeln(-1)\n else writeln(sc1+sc2);\nend."}, {"source_code": "var k,a,b:longint;\nbegin\nreadln(k,a,b);\nif (a div k = 0) and (b div k = 0) or\n (b div k = 0) and (a mod k>0) or\n (a div k = 0) and (b mod k>0)\n then write(-1) else\n write((a div k) + (b div k));\nend."}, {"source_code": "var a,s,d,f,g,h,j,k,l,ii,i,ans1,ans2,ans:longint;\nbegin\nreadln(a,s,d);\nans1:=ans1+(s div a);\nans2:=ans2+(d div a);\nans:=ans1+ans2;\n\nif (d-ans2*a<>0)and(ans1=0) then\nans:=-1;\nif (s-ans1*a<>0)and(ans2=0) then\nans:=-1;\n\nwriteln(ans);\nend.\n"}, {"source_code": "{$I-,O+,Q-,R-,S-}\n\nvar\n k, a, b: longint;\nbegin\n read(k); read(a); read(b);\n\n if (a >= k) and (b >= k) then write(a div k + b div k)\n else if (a >= k) and (a mod k = 0) then write(a div k)\n else if (b >= k) and (b mod k = 0) then write(b div k)\n else write(-1);\nend.\n"}, {"source_code": " const eps=0.000000001;\n besk=9000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var aa,bb,left,right,modul,ot3,ot2,ot1,nap,posx,posy,xx,yy,n,m,tt1,tt2,q,pp,tt,dx,dy,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,pmax,imax,p1,p2,p3,p4,l,ot,nm,s1,s2,s,smin,cen,dl,t2,i1:int64;\n t1,k,time,jj,step, ii,i,j:longint;\n { aa,bb,cc:double;\n }\n ss2,sss,ss,ss1:string;\n last:array[-1..5000,0..25] of int64;\n dd,npx,npy:array[-1000..500000] of int64;\n zifr:array[0..1000000,0..9] of longint;\n sdv, dp,binom:array[-1..500,-1..500] of int64;\n prost,zan:array[-10000..10000000] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,z,x,y,aold,b,a:array[-100000..1000002] of int64;\n dda:array[-10..12000] of extended;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n corr,zzan:array[-1000..3000,-1000..3000] of boolean;\n ssss:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n ch:char;\n pole1,pole :array [-10..2000,-10..2000] of char;\n st:array[-10..100000] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n yot:double;\n flag2,oldflag,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(p,aa,bb);\n if min(aa,bb)

0 do\n begin\n inc(w,count);\n dec(count); \n end;\n if w<0 then writeln(0) else writeln(w);\n\nend.\n"}, {"source_code": "var w,w1,w2,h,h1,h2,count:longint;\n\n\n\nprocedure swap(var a,b:longint);\nvar c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //(input,'BONUS.inp');reset(input);\n //assign(output,'BONUS.out');rewrite(output);\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n if h1

0 do\n begin\n dec(count);\n if (count<>h1) and (count<>h2) then w:=w+count;\n end;\n if w<0 then writeln(0) else writeln(w);\n\nend.\n\n"}, {"source_code": "var w,w1,w2,h,h1,h2,count:longint;\n\nbegin\n //assign(input,'BONUS.inp');reset(input);\n //assign(output,'BONUS.out');rewrite(output);\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n w:=w-w1-w2;\n count:=h;\n while count>0 do\n begin\n inc(w,count);\n dec(count); \n end;\n if w<0 then writeln(0) else writeln(w);\n\nend.\n"}, {"source_code": "var w,w1,w2,h,h1,h2:longint;\n\n\n\nprocedure swap(var a,b:longint);\nvar c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'BONUS.inp');reset(input);\n //assign(output,'BONUS.out');rewrite(output);\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n if h1

0 do\n begin\n dec(count);\n inc(w,count);\n end;\n if w<0 then writeln(0) else writeln(w);\n\nend.\n\n"}, {"source_code": "var w,h,u1,u2,d1,d2,i:integer;\nbegin\nread(w,h,u1,d1,u2,d2);\nfor i:=h downto 1 do\nbegin\nw:=w+i;\nif i=d1 then w:=w-u1;\nif i=d2 then w:=w-u2;\nif i<0 then w:=0;\nend;\nwrite(w);\nend."}, {"source_code": "var w,h,u1,d1,u2,d2,c:int64;\nbegin\n read(w,h,u1,d1,u2,d2);\n c:=w+h+d1-u1;\n if c<0 then c:=0;\n c:=c+d2-d1-u2;\n if c<0 then c:=0;\n write(c+1);\nend."}, {"source_code": "var w,h,u1,d1,u2,d2,tempd,tempu,c:int64;\nbegin\n read(w,h,u1,d1,u2,d2);\n if d2>d1 then \n begin\n tempd:=d2;\n tempu:=u2;\n u2:=u1;\n d2:=d1;\n d1:=tempd;\n u1:=tempu;\n end;\n c:=w+h;\n while (h>d1) do \n begin\n dec(h);\n c:=c+h;\n end;\n c:=c-u1;\n if c<0 then c:=0;\n h:=d1;\n while (h>d2) do\n begin\n dec(h);\n c:=c+h;\n end;\n c:=c-u2;\n if c<0 then write(0) else write(c);\n \nend."}, {"source_code": "var a,b,c,a1,b1,c1,i:longint;\nbegin\nread(a,a1);\nread(b,b1);\nread(c,c1);\nfor i:=a1 downto 0 do\nbegin\nif i=b1 then a:=a-b\nelse a:=a+i;\nif a<0 then a:=0;\nend;\nwrite(a);\nend."}, {"source_code": "Var n , h , i , tmp1 , tmp2 , tmp , kq : Longint;\nBegin\nReadln(n , h);\nkq := n + h*(h+1) div 2;\nFor i := 1 to 2 do \n Begin\n Readln(tmp1 , tmp2);\n Dec(kq , tmp1);\n End;\nWriteln(kq);\nEnd."}, {"source_code": "Var n , h , i , tmp1 , tmp2 , tmp , kq : Longint;\nBegin\nReadln(n , h);\nkq := n + h*(h+1) div 2;\nFor i := 1 to 2 do \n Begin\n Readln(tmp1 , tmp2);\n Dec(kq , tmp1);\n End;\nIf kq > 0 then Writeln(kq) else Writeln('0');\nEnd."}, {"source_code": "const fi='';\n fo='';\nvar w,h,w1,h1,w2,h2:integer;\n\nprocedure docf;\nvar f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,w,h);\n readln(f,w1,h1);\n readln(f,w2,h2);\n close(f);\nend;\n\nprocedure solve;\nvar f:text;\nbegin\n assign(f,fo); rewrite(f);\n while (h>0) do\n begin\n inc(w,h);\n if (h=h1) then dec(w,w1);\n if (h=h2) then dec(w,w2);\n dec(h);\n end;\n if (w<0) then writeln(f,0) else writeln(f,w);\n close(f);\nend;\n\nbegin\n docf;\n solve;\nend."}, {"source_code": "var\n w,h,u1,u2,h1,h2,i:longint;\nbegin\n readln(w,h);\n readln(u1,h1);\n readln(u2,h2);\n for i:=h downto 0 do\n begin\n h:=h+i;\n if i=h1 then\n begin\n w:=w-u1;\n if w<0 then w:=0;\n end;\n if i=h2 then\n begin\n w:=w-u2;\n if w<0 then w:=0;\n end;\n end;\n writeln(w);\nend."}, {"source_code": "var\n w,h,u1,u2,h1,h2,i:longint;\nbegin\n readln(w,h);\n readln(u1,h1);\n readln(u2,h2);\n for i:=h downto 1 do\n begin\n h:=h+i;\n if i=h1 then\n begin\n w:=w-u1;\n if w<0 then w:=0;\n end;\n if i=h2 then\n begin\n w:=w-u2;\n if w<0 then w:=0;\n end;\n end;\n writeln(w);\nend."}, {"source_code": "var\n\tw, h, u1, d1, u2, d2: int64;\n\t\nbegin\n\t\n\treadln(w, h);\n\treadln(u1, d1);\n\treadln(u2, d2);\n\t\n\tfor var i := h downto 1 do\n\tbegin\n\t\tw += i;\n\tend;\n\t\n\twriteln(w - u1 - u2);\n\t\nend.\n"}, {"source_code": "var\n\tw, h, u1, d1, u2, d2: int64;\n\t\nbegin\n\t\n\treadln(w, h);\n\treadln(u1, d1);\n\treadln(u2, d2);\n\t\n\tfor var i := h downto 1 do\n\tbegin\n\t\tw += i;\n\tend;\n\t\n\tif (w - u1 - u2 < 0) then\n\t\twriteln(0)\n\telse\n\t\twriteln(w - u1 - u2);\n\t\nend.\n"}, {"source_code": "var\n mc, hc, mm1, hm1, mm2, hm2,i,q: integer;\n\nbegin\n read(mc, hc, mm1, hm1, mm2, hm2);\n i:=hc;\n for q:=1 to hc do \n if (hc <> hm1) and (hc <> hm2) and (i<>0) then begin\n mc := mc + hc;\n hc := hc - 1;\n i:=i-1;\n end\n else begin\n if hc = hm1 then begin\n mc := mc + hm1;\n mc := mc - mm1;\n hc := hc - 1;\n i:=i-1;\n end;\n if hc = hm2 then begin\n mc := mc + hm2;\n mc := mc - mm2;\n hc := hc - 1;\n i:=i-1;\n end;\n end;\n writeln(mc)\nend."}, {"source_code": "var\n mc, hc, mm1, hm1, mm2, hm2,i,q: integer;\n\nbegin\n read(mc, hc, mm1, hm1, mm2, hm2);\n i:=hc;\n for q:=1 to hc do \n if (hc <> hm1) and (hc <> hm2) and (i>=0) then begin\n mc := mc + hc;\n hc := hc - 1;\n i:=i-1;\n end\n else begin\n if hc = hm1 then begin\n mc := mc + hm1;\n mc := mc - mm1;\n hc := hc - 1;\n i:=i-1;\n end;\n if hc = hm2 then begin\n mc := mc + hm2;\n mc := mc - mm2;\n hc := hc - 1;\n i:=i-1;\n end;\n end;\n writeln(mc)\nend."}, {"source_code": "var\nw,h,u1,u2,d1,d2:integer;\n\nbegin\nreadln (w,h);\nreadln (u1,d1);\nreadln (u2,d2);\ninc (w,h);\nwhile h>max(d1,d2) do begin\ndec(h);\ninc(w,h);\nend;\n\nif h=max(d1,d2) then begin\n if max(d1,d2)=d1 then\n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n \n while h>min(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=min(d1,d2) then begin\n if min(d1,d2)=d1 then \n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n write (w);end.\n \n"}, {"source_code": "var\nw,h,u1,u2,d1,d2:integer;\n\nbegin\nreadln (w,h);\nreadln (u1,d1);\nreadln (u2,d2);\ninc (w,h);\nwhile h>max(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=max(d1,d2) then begin\n if max(d1,d2)=d1 then\n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n \n while h>min(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=min(d1,d2) then begin\n if min(d1,d2)=d1 then \n dec (w,u1) else\n dec (w,u2);\n end;\n //if w<0 then w:=0; \n \n write (w);end.\n \n"}, {"source_code": "var\nw,h,u1,u2,d1,d2:integer;\n\nbegin\nreadln (w,h);\nreadln (u1,d1);\nreadln (u2,d2);\nif h<>max(d1,d2) then\ninc (w,h);\nwhile h>max(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=max(d1,d2) then begin\n if max(d1,d2)=d1 then\n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n \n while h>min(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=min(d1,d2) then begin\n if min(d1,d2)=d1 then \n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n write (w);end.\n \n"}, {"source_code": "var\nw,h,u1,u2,d1,d2:integer;\n\nbegin\nreadln (w,h);\nreadln (u1,d1);\nreadln (u2,d2);\ninc (w,h);\nwhile h>max(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=max(d1,d2) then begin\n if max(d1,d2)=d1 then\n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n \n while h>min(d1,d2) do begin\ndec (h);\ninc(w,h);\nend;\n\nif h=min(d1,d2) then begin\n if min(d1,d2)=d1 then \n dec (w,u1) else\n dec (w,u2);\n end;\n if w<0 then w:=0; \n \n write (w);end.\n \n"}], "src_uid": "084a12eb3a708b43b880734f3ee51374"} {"source_code": "Var i,k,t:longint;\n s:string;\n Begin\n Readln(s);\n t:=0;\n if s[1]='h' then begin write('http://'); t:=t+1; k:=5; end else write('ftp://');\n if t=1 then\n begin\n for i:=5 to length(s) do\n if (s[i]='r') and (s[i+1]='u' ) and(i<>5) then begin write('.ru'); k:=k+2; break; end\n else begin write(s[i]); k:=k+1; end;\n if k<=length(s) then write('/');\n for i:=k to length(s) do\n write(s[i]);\n exit;\n end;\n if t=0 then\n begin\n k:=4;\n for i:=4 to length(s) do\n if (s[i]='r') and (s[i+1]='u' )and (i<>4) then begin write('.ru'); k:=k+2; break; end\n else begin write(s[i]); k:=k+1; end; end;\n if k<=length(s) then write('/');\n for i:=k to length(s) do\n write(s[i]);\n exit;\n end.\n", "positive_code": [{"source_code": "{$APPTYPE CONSOLe}\n{$r-,s-,q-,i-,o+}\nvar\n p,i:longint;\n ans,s:string;\nbegin\n// assign(input,'knight.in'); reset(input);\n// assign(output,'knight.out'); rewrite(output);\n readln(s);\n if pos('http',s)=1\n then begin ans:=ans+'http://'; delete(s,1,4); end\n else begin ans:=ans+'ftp://'; delete(s,1,3); end;\n for i:=1 to length(s)-1 do\n if s[i]+s[i+1]='ru'\n then p:=i;\n ans:=ans+copy(s,1,p-1)+'.'+'ru';\n delete(s,1,p+1);\n if s<>''\n then ans:=ans+'/'+s;\n writeln(ans);\n close(input);\n close(output);\nend.\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\n\n var a:array[1..256] of string;\n x:string; i,d:integer;\nbegin\n readln(x);\nif copy(x,1,3)='ftp' then begin insert('://',x,4); d:=8; end;\nif copy(x,1,4)='http' then begin insert('://',x,5); d:=9; end;\nfor i:=d to length(x) do\n begin\n a[i]:=copy(x,i,2);\n if a[i]='ru' then begin insert('.',x,i);\n\n insert('/',x,i+3); break; end;\n end; if copy(x,length(x),1)='/' then delete(x,length(x),1);\nwrite(x);\n // readln; readln;\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar i, n,x1,y1,x2,y2 ,x,y,t: integer;\n s:String;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n read(s);\n if s[1]='f' then begin\n s:=copy(s,1,3)+'://'+copy(s,4,length(s)-3);\n end else begin\n s:=copy(s,1,4)+'://'+copy(s,5,length(s)-4);\n end;\n i:=length(s);\n while (s[i]<>'u') or (s[i-1]<>'r') do dec(i);\n if i<>length(s) then begin\n s:=copy(s,1,i)+'/'+copy(s,i+1,length(s)-i);\n end;\n\n s:=copy(s,1,i-2)+'.'+copy(s,i-1,length(s)-i+2);\n write(s);\nend.\n"}, {"source_code": "var s:string;\n\ta,b:byte;\nbegin\nreadln(s);\na:=pos('tp',s)+2;\ninsert('://',s,a);\n\nfor b:=1 to length(s) do \n if ((s[1]='f') and (s[b]='r') and (s[b+1]='u') and (b>7)) or ((s[1]='h') and (s[b]='r') and (s[b+1]='u') and (b>8)) then begin\n insert('.',s,b);\n break;\n end;\nif b+2<>length(s) then insert('/',s,b+3);\nwriteln(s);\nend.\n"}, {"source_code": "program internet;\nvar\n s,res:string;\n i,lens,star,j:integer;\nbegin\n readln(s);\n lens:=length(s);\n if(s[1]='f')then\n begin\n res:='ftp://';\n res:=res+s[4];\n i:=5;\n end\n else\n begin\n res:='http://';\n res:=res+s[5];\n i:=6;\n end;\n while((s[i]<>'r')or(s[i+1]<>'u'))do\n begin\n res:=res+s[i];\n i:=i+1;\n end;\n res:=res+'.'+'ru';\n if(i<>lens-1)then\n begin\n res:=res+'/';\n for j:=i+2 to lens do\n res:=res+s[j];\n end;\n writeln(res);\nend.\n"}, {"source_code": "Var s,ans:String;\nk:LongInt;\ni:LongInt;\nBegin\n Readln (s);\n ans:='';\n If s[1]='h'\n then Begin\n ans:='http://';\n Delete (s,1,4);\n End\n else Begin\n ans:='ftp://';\n Delete (s,1,3);\n End;\n If (s[Length (s)-1]='r') and (s[Length (s)]='u')\n then Begin\n ans:=ans+Copy (s,1,Length (s)-2)+'.ru';\n Writeln (ans);\n Halt (0);\n End\n else Begin\n For I:=1 to Length (s)-1 do\n If (s[i]='r') and (s[i+1]='u')\n then k:=i; \n ans:=ans+Copy (s,1,k-1)+'.ru/'+Copy (s,k+2,Length (s)-(k+1));\n Writeln (ans);\n Halt (0);\n End;\nEnd.\n"}, {"source_code": "var\n s,s1,s2,l,f : string;\n p,i,p1 : longint;\nbegin\n readln(s);\n p:=1;\n f:='';\n if s[p]='h' then begin f:=f+'http://'; p:=5; end\n else begin f:=f+'ftp://'; p:=4; end;\n s1:=copy(s,p,length(s));\n for i:=2 to length(s1) do\n if (s1[i]='r') and (s1[i+1]='u') then begin p1:=i; l:=copy(s1,1,p1-1); f:=f+l; f:=f+'.ru'; break; end;\n s2:=copy(s1,p1+2,length(s1));\n if s2=''\n then writeln(f)\n else writeln(f,'/',s2);\nend.\n \n \n "}, {"source_code": "program jjj;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,StrUtils;\n\nvar\n subst:string;\n\nbegin\n readln(subst);\n if posex('http',subst,1)=1 then\n insert('://',subst, 5)\n else\n insert('://',subst,4);\n insert('.',subst,posex('ru',subst,pos('://',subst)+4));\n if (subst[posex('.ru',subst,posex('://',subst,1)+4)+3]<>' ') and\n (subst[posex('.ru',subst,posex('://',subst,1)+4)+3]<>'')\n then insert('/',subst,posex('.ru',subst,posex('://',subst,1)+4)+3);\n writeln(subst);\nend.\n"}, {"source_code": "program TaskB;\n\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nvar\n InStr: string[50];\n OutStr: string[55];\n I, N: Integer;\n\nbegin\n I := 6;\n ReadLn(InStr);\n OutStr := InStr;\n N := Pos('http', InStr);\n if N <> 1 then\n begin\n N := Pos('ftp', InStr);\n Delete(InStr, 1, 3);\n Insert('://', OutStr, 4);\n end\n else\n begin\n Delete(InStr, 1, 4);\n Insert('://', OutStr, 5);\n I := 7;\n end;\n N := Pos('ru', InStr);\n if N = 1 then\n begin\n Delete(InStr, 1, 2);\n N := Pos('ru', InStr) + 2;\n end;\n if Length(OutStr) <> (N + I + 1) then\n Insert('/', OutStr, N+2+I);\n Insert('.', OutStr, N+ I);\n WriteLn(OutStr);\n ReadLn;\nend.\n"}, {"source_code": "Program rabotayet1;\nVar s:string;I:Integer;\nBegin\n readln(s);\n if s[1]='h'\n then begin\n write('http://');\n Delete(s,1,4);\n end\n else begin\n write('ftp://');\n Delete(s,1,3);\n end;\n I:=1;\n Repeat\n Inc(I);\n Until (s[I]='r') and (s[I+1]='u');\n write(copy(s,1,i-1),'.ru');\n Delete(s,1,I+1);\n if s<>''\n then write('/',s)\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n p1, p2, i: longint;\n st, s: string;\nbegin\n\n readln(st);\n\n if st[1] = 'h' then begin\n p1:= 4;\n end else p1:= 3;\n\n for i:= p1+1 to length(st) do begin\n if (st[i] = 'u') and (st[i-1] = 'r') and (i-2 <> p1) then begin\n p2:= i-1;\n break;\n end;\n end;\n s:= copy(st, 1, p1) + '://' + copy(st, p1+1, p2-p1-1) + '.ru/'+ copy(st, p2+2, length(St)-(p2+1));\n if s[length(s)] = '/' then delete(s, length(s),1);\n writeln(s);\nend.\n"}, {"source_code": "var\n S:String;\nbegin\n Read(S);\n if S[1]='h' then begin\n Write('http://');\n Delete(S,1,4);\n end else begin\n Write('ftp://');\n Delete(S,1,3);\n end;\n Write(S[1]);\n Delete(S,1,1);\n While S[1]+S[2]<>'ru' do begin\n Write(S[1]);\n Delete(S,1,1);\n end;\n Write('.ru');\n Delete(S,1,2);\nif S<>'' then begin\n Write('/',S);\n end;\nend."}, {"source_code": "var s,s1,s2,s3:string;\n i,j:longint;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n readln(s);\n if pos('http',s)=1\n then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n if pos('ftp',s)=1\n then\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n if pos('ru',s)=1\n then\n begin\n write('r');\n delete(s,1,1);\n end;\n for i:=1 to pos('ru',s)-1 do\n write(s[i]);\n delete(s,1,pos('ru',s)-1);\n delete(s,1,2);\n write('.ru');\n if length(s)=0 then exit;\n write('/',s);\nend."}, {"source_code": "var S : string;\nbegin\n readln(S);\n If S[1] = 'h' then insert('://',S,5)\n else insert('://',S,4);\n If S[pos('ru',S)-1] <> '/' then insert('.',S,pos('ru',S))\n else\n begin\n delete(S,pos('/',S)+2,1);\n insert('.',S,pos('ru',S));\n insert('r',S,pos('/',S)+2);\n end;\n If pos('.ru',S) < length(S) - 2 then\n insert('/',S,pos('.ru',S)+3);\n writeln(S);\nend.\n\n\n"}, {"source_code": "{$Mode objfpc}\n\n\nvar\n s, x: string;\n\nbegin\n // assign(input, 'text.inp'); reset(input);\n readln(s);\n if s[1]= 'h' then insert('://', s, 5) else insert('://',s, 4);\n if s[pos('ru', s)- 1]<> '/' then\n begin\n x:= s;\n insert('.', s, pos('ru', s))\n end else\n begin\n x:= s;\n x[pos('ru', x)]:= 's';\n insert('.', s, pos('ru', x))\n end;\n\n if pos('ru', x)+ 2 < length(s) then insert('/', s, pos('ru', x)+ 3);\n writeln(s);\nend.\n"}, {"source_code": "var i:integer;\n s,pr,dom,con:string;\nbegin\n i:=1;\n readln(s);\n pr:='';\n dom:='';\n con:='';\n repeat pr:=pr+s[i]; inc(i);\n until (pr='http') or (pr='ftp');\n repeat dom:=dom+s[i]; inc(i);\n until (s[i]+s[i+1]='ru') and (length(dom)>0);\n i:=i+2;\n \n while i<=length(s) do begin\n con:=con+s[i];\n inc(i);\n end;\n if length(con)>0 then writeln(pr,'://',dom,'.ru/',con)\n else writeln(pr,'://',dom,'.ru');\n \nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n\nvar\n s : string;\n n : longint;\n\nprocedure enter;\n begin\n readln( s );\n end;\n\nprocedure solve;\n var\n i , j : longint;\n begin\n if s[ 1 ] = 'f' then i := 0 else i := 1;\n if s[ 1 ] = 'f' then delete( s , 1 , 3 ) else delete( s , 1 , 4 );\n s := '://'+s;\n if i = 1 then s := 'http'+s else s := 'ftp'+s;\n n := length( s );\n for i := 1 to n do\n begin\n if s[ i ] <> '/' then\n if ( s[ i+1 ] = 'r' ) and ( s[ i+2 ] = 'u' ) then\n begin\n insert( '.' , s , i+1 );\n insert( '/' , s , i+4 );\n break;\n end;\n end;\n if s[ length( s ) ] = '/' then delete( s , length( s ) , 1 );\n writeln( s );\n end;\n\nBEGIN\n assign( input , fi ); reset( input );\n assign( output , fo );rewrite( output );\n\n enter;\n solve;\n\n close( input );\n close( output );\nEND.\n"}, {"source_code": "var a,a_1:string;\n b,i,num:word;\nbegin\nreadln(a);\na_1:='';\nif (a[1]+a[2]+a[3])='ftp' then begin a_1:='ftp://';num:=4;end else begin a_1:='http://'; num:=5 end;\nb:=pos('ru',a);\nif b=num then begin a_1:=a_1+'ru'; delete(a,b,2); b:=pos('ru',a); end;\na_1:=a_1+copy(a,num,b-num);\na_1:=a_1+'.ru';\nif (b+1)'/' then y:=pos('ru',s) else\n begin\n for i:=2 to length(s)-1 do\n if (s[i-1]<>'/') and (s[i]='r') and (s[i+1]='u') then break;\n y:=i;\n end;\n x:=Copy(s,y,length(s)-y+1);\n\n Delete(x,1,2);\n Delete(s,y,length(s)-y+1);\n s:=s+'.ru'+'/'+x;\n end;\n Writeln(s);\nend."}, {"source_code": "var\n s:string;\n p:longint;\nbegin\n readln(s);\n if s[1]='h'\n then begin\n write('http://');\n delete(s,1,4);\n end\n else begin\n write('ftp://');\n delete(s,1,3);\n end;\n p:=pos('ru',s);\n if p=1\n then begin\n repeat\n inc(p);\n until(s[p]='r')and(s[p+1]='u');\n end;\n if p<>length(s)-1\n then writeln(copy(s,1,p-1),'.ru/',copy(s,p+2,length(s)-p-1))\n else writeln(copy(s,1,p-1),'.ru');\nend.\n"}, {"source_code": "var\ns,s1:string;\nt:longint;\ns2:char;\nbegin\nreadln(s);\nif copy(s,1,4)='http'\nthen begin\nwrite('http://');\ndelete(s,1,4);\nend\nelse begin\nwrite('ftp://');\ndelete(s,1,3);\nend;\ns2:=s[1];\ns[1]:='1';\nt:=pos('ru',s);\ns[1]:=s2;\ns1:=copy(s,1,t-1);\nwrite(s1,'.ru');\ndelete(s,1,t+1);\nif s<>''\nthen write('/',s);\nwriteln;\nend.\n"}, {"source_code": "Var s:String;\n\nProcedure xl;\nVar i:Integer;\n t:String;\nBegin\n Readln(s);\n If pos('http',s)=1 then\n Begin\n Write('http://');\n delete(s,1,4);\n End\n Else If pos('ftp',s)=1 then\n Begin\n Write('ftp://');\n delete(s,1,3);\n End;\n i:=1;\n t:='';\n While ((s[i]<>'r') or (s[i+1]<>'u')) or (i=1) do\n Begin\n t:=t+s[i];\n INc(i);\n End;\n delete(s,1,length(t)+2);\n Write(t,'.ru');\n For i:=1 to length(s) do\n Begin\n If i=1 then Write('/');\n Write(s[i]);\n End;\nEnd;\n\nBegin\n xl;\nEnd."}, {"source_code": "var a:string;\n t,t1:integer;\nbegin\nreadln(a);\nt:=pos('http',a);\nif t=0 then t:=100;\nt1:=pos('ftp',a);\nif t1=0 then t1:=100;\nif t'/' then begin\ninsert('.',a,t);insert('/',a,t+3); end else begin\ndelete(a,t,2);\ninsert('.',a,pos('ru',a));\ninsert('ru',a,t);\ninsert('/',a,pos('.ru',a)+3); end;\n\nif a[length(a)]='/' then delete(a,length(a),1);\nwrite(a);\nend."}, {"source_code": "VAR\n s, s1: String;\n i: Integer;\nBEGIN\n Read(s);\n If (s[1]+s[2]+s[3] = 'ftp')then begin Write('ftp://'); Delete(s,1,3); end\n Else begin Write('http://'); Delete(s,1,4); end;\n \n For i := 3 to length(s) do\n If (s[i-1]+s[i] = 'ru') then begin s1 := Copy(s,1,i-2); Write(s1,'.ru'); Delete(s,1,i); Break; end;\n \n If (Length(s) > 0) then Write('/',s);\nEND."}, {"source_code": "program n2;\n var x:integer; t,t1,t2,h,r:string;\nbegin\n readln(t);\n r:='';\n if t[1]='f' then begin delete(t,1,3); write('ftp://'); end\n else if t[1]='h' then begin delete(t,1,4); write('http://'); end;\n x:=pos('ru',t);\n if x=1 then begin write('ru'); delete(t,1,2); x:=pos('ru',t); end;\n t1:=t;\n t2:=t;\n delete(t2,1,x-1);\n delete(t1,x,length(t2));\n h:=t1;\n write(h);\n write('.ru');\n delete(t,1,x+1);\n if length(t)<>0 then write('/',t);\nend.\n\n "}, {"source_code": "{$mode objfpc}\n\n\nvar s , res , t : string;\n n , i , p : integer;\n\n\nbegin\n readln( s );\n {SetLength( res , 100 );\n for i := 1 to 100 do res[i] := '?'; }\n if s[1] = 'f' then\n begin\n res := res + 'ftp://';\n delete( s , 1 , 3 );\n end\n else\n begin\n res := res + 'http://';\n delete( s , 1 , 4 );\n end;\n p := pos( 'ru' , s );\n if p = 1 then\n begin\n res := res + 'ru';\n delete( s , 1 , 2 );\n p := pos( 'ru' , s );\n end;\n t := copy( s , 1 , p - 1 );\n delete( s , 1 , p + 1 );\n res := res + t + '.ru';\n write( res );\n if length( s ) > 0 then writeln( '/' , s );\nend."}, {"source_code": "var\n s:string;\n i:byte;\n\nbegin\n readln(s);\n if s[1]='h' then i:=5;\n if s[1]='f' then i:=4;\n insert('://', s, i);\n i:=length(s)-1;\n while s[i]+s[i+1]<>'ru' do dec(i);\n insert('.',s,i); inc(i,3);\n insert('/',s,i);\n if i >= length(s) then delete(s,i,1);\n writeln(s);\nend."}, {"source_code": "var\n k,k1,q,i,len:longint;\n s:string;\nbegin\n readln(s);\n k:=pos('http',s);\n k1:=pos('ftp',s);\n if ((k0)then\n begin\n write('http://');\n k:=k+4;\n end else\n if (k1n then insert(s1, s, i+2);\n break;\n end; }\n\n{s1:='ru';\nk:=pos(s1,s);\nkk:=k; s1:=s;\ndelete(s1, k, 2);\nk:=pos('ru', s1);\nif k=0 then k:=kk;\ninsert('.', s, k);\ninsert('/', s, k+3);}\nfor i:=1 to n-1 do\n if s[i]+s[i+1]='ru' then k:=i;\ninsert('.', s, k);\ninsert('/', s, k+3);\n{if k<>n then begin\n s1:='.';\n insert(s1, s, k);\n s1:='/';\n insert(s1, s, k+3);\n end\n else begin\n s1:='.';\n insert(s1, s, k-1);\n end; }\nn:=length(s);\nif s[n]='/' then delete(s, n, 1);\nwriteln(s);\n\nend.\n"}, {"source_code": "var\ns,z:string;\nbegin\nreadln(s);\nif s[1]='f' then\n begin\n z:='ftp://';\n delete(s,1,3);\n end else\n begin\n z:='http://';\n delete(s,1,4);\n end;\nwhile pos('ru',s)=1 do\nbegin delete(s,1,2); z:=z+'ru'; end;\nz:=z+copy(s,1,pos('ru',s)-1)+'.ru';\ndelete(s,1,pos('ru',s)+1);\nif s<>'' then z:=z+'/'+s;\nwriteln(z);\nend."}, {"source_code": "var\n S,S1,S2,Ans:String;\n i:Longint;\nbegin\n Readln(S);\n if S[1]+S[2]+S[3]='ftp' then begin\n Ans:=Ans+'ftp://';\n Delete(S,1,3);\n end\n else if S[1]+S[2]+S[3]+S[4]='http' then begin\n Ans:=Ans+'http://';\n Delete(S,1,4);\n end;\n i:=1;\n while i<=Length(S)-1 do\nbegin\n if S[i]='r' then begin\n if S[i+1]='u' then begin\n if S2<>'' then begin\n Ans:=Ans+S2+'.ru';\n Delete(S,1,i+1);\n Break;\n end\n else S2:=S2+'r';\n end\n else S2:=S2+S[i];\n end\n else S2:=S2+S[i];\n Inc(i);\n end;\n if S<>'' then Ans:=Ans+'/';\n Ans:=Ans+S;\n Writeln(Ans);\n end.\n\n"}, {"source_code": "var s, s1:string;\n n, i, k:integer;\nbegin\nreadln(s);\ns1:='://';\nif s[1]='h' then insert(s1,s, 5)\n else insert(s1,s, 4);\nn:=length(s);\nfor i:=1 to n-1 do\n if s[i]+s[i+1]='ru' then k:=i;\ninsert('.', s, k);\ninsert('/', s, k+3);\nn:=length(s);\nif s[n]='/' then delete(s, n, 1);\nwriteln(s);\n\nend.\n"}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nvar\n s : string;\nbegin\n readln(s);\n if (s[1] = 'h') then begin\n write('http://');\n s := copy(s, 5, length(S) - 4);\n end else begin\n write('ftp://');\n s := copy(s, 4, length(s) - 3);\n end;\n if (s[1] = 'r') and (s[2] = 'u') then begin\n write('ru');\n s := copy(s, 3, length(s) - 2);\n end;\n write(copy(s, 1, pos('ru', s) - 1), '.ru');\n //writeln(pos('ru', s));\n s := copy(s, pos('ru', s) + 2, length(s) - pos('ru', s) - 1);\n if (length(s) > 0) then\n write('/', s);\n writeln;\nend.\n"}, {"source_code": "var i,next,ppos:longint;\n s,ss:string;\n\nbegin\n\n readln(s);\n\n if pos('http',s)=1 then\n begin\n write('http://');\n next:=5;\n end\n else\n begin\n write('ftp://');\n next:=4;\n end;\n\n if pos('ru',s)=next then\n begin\n ss:=copy(s,next+2,length(s)+1-next-2);\n ppos:=pos('ru',ss);\n for i:=next to next+ppos do\n write(s[i]);\n write('.ru');\n if next+ppos+1+2<=length(s) then write('/');\n for i:=next+ppos+1+2 to length(s) do\n write(s[i]);\n end\n else begin\n for i:=next to pos('ru',s)-1 do\n write(s[i]);\n\n write('.ru');\n if pos('ru',s)+2<=length(s) then write('/');\n for i:=pos('ru',s)+2 to length(s) do\n write(s[i]);\n end;\n\nend.\n\n"}, {"source_code": "uses math;\nvar u:boolean;ch:char;s,ss:string;x,j,y,a,b,k,c,i,z,q,n,num:integer;\nBegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(s);\n if pos('http',s)=1\n then insert('://',s,5)\n else insert('://',s,4);\n a:=0;\n for i:=4 to length(s) do\n if s[i-1]+s[i]='ru'\n then if s[i-2]<>'/'\n then Begin\n a:=i;\n break;\n end;\n insert('.',s,a-1);\n insert('/',s,a+2);\n if s[length(s)]='/'\n then delete(s,length(s),1);\n writeln(s);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i : integer;\n s, s1 : string;\n bool : boolean;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n readln(s);\n s1 := '';\n i := 1;\n bool := false;\n while i <= length(s) do begin\n s1 := s1 + s[i];\n if (s1 = 'http') or (s1 = 'ftp') then\n s1 := s1 + '://';\n if (s[i] = 'r') and (s[i + 1] = 'u') and (not bool) and (s1 <> 'http://r') and (s1 <> 'ftp://r') then begin\n delete(s1, length(s1), 1);\n s1 := s1 + '.ru';\n inc(i, 1);\n if (length(s) > i) then begin\n s1 := s1 + '/';\n end;\n bool := true; \n end;\n inc(i);\n end;\n\n writeln(s1);\n\nend.\n "}, {"source_code": "var\n\ts,t:ansistring;\n\ti,j,n,m:longint;\n\nBegin\n\treadln(s);\n\tfor i:=1 to length(s) do\n\t\tif (copy(s,1,i) = 'http') or (copy(s,1,i) = 'ftp') then\n\t\t\tbegin\n\t\t\t\twrite(copy(s,1,i),'://');\n\t\t\t\tdelete(s,1,i);\n\t\t\t\tbreak;\n\t\t\tend;\n\tfor i:=2 to length(s)-1 do\n\t\tif (s[i] = 'r') and (s[i+1] = 'u') then\n\t\t\tbegin\n\t\t\t\twrite(copy(s,1,i-1),'.ru');\n\t\t\t\tdelete(s,1,i+1);\n\t\t\t\tif s <> '' then\n\t\t\t\t\twrite('/',s);\n\t\t\t\tbreak;\n\t\t\tend;\nend.\n"}, {"source_code": "{$r-, s-, q-, i-, o+}\nvar\n s : ansistring;\n i : longint;\nbegin\n readln(s);\n if (s[1] = 'h') then insert('://', s, 5) else insert('://', s, 4);\n for i := length(s) - 1 downto 1 do\n if (s[i] + s[i + 1] = 'ru') then break;\n insert('.', s, i);\n insert('/', s, i + 3);\n while (s[length(s)] = '/') do delete(s, length(s), 1);\n writeln(s);\nend."}, {"source_code": "var s:string;\n i:integer;\nbegin\n readln(s);\n if s[1]='f'\n then insert('://',s,4)\n else insert('://',s,5);\n i:=length(s)-1;\n while (s[i]<>'r')or(s[i+1]<>'u') do\n dec(i);\n insert('.',s,i);\n if length(s)>i+2\n then insert('/',s,i+3);\n writeln(s);\nend."}, {"source_code": "var s,f:string;\n d:integer;\nbegin\n read(s);\n if s[1]='h' then begin\n write('http://');\n delete(s,1,4);\n end\n else begin\n write('ftp://');\n delete(s,1,3);\n end;\n if pos('ru',s)=1 then begin\n write('ru');\n delete(s,1,2);\n end;\n d:=pos('ru',s);\n f:=copy(s,1,d-1);\n write(f);\n write('.');\n write('ru');\n delete(s,1,d+1);\n d:=length(s);\n if d>0 then begin\n f:=copy(s,1,d);\n write('/',f);\n end;\nend."}, {"source_code": " var s:string;\n i,l:integer;\nbegin\n readln(s);\n// l:=length(s);\n if s[1]='h'\n then begin write(s[1],s[2],s[3],s[4],'://'); delete(s,1,4); end\n else begin write(s[1],s[2],s[3],'://'); delete(s,1,3); end;\n i:=1;\n while not((s[i]='r')and(s[i+1]='u')and(i>1)) do\n begin\n write(s[i]);\n inc(i);\n end;\n write('.');\n write(s[i],s[i+1]);\n l:=length(s);\n if i+2<=l\n then begin\n write('/');\n for i:=i+2 to l do\n write(s[i]);\n end;\n writeln;\nend.\n"}, {"source_code": "var s,k4,k5,sn,k1,k2:string;\ni,k3,d,l1,l2:longint;\nbegin\nk1:='';k2:='';sn:='';\nreadlN(S);\nk1:=copy(s,1,3);\nk2:=copy(s,1,4);\nif k1='ftp' then begin write('ftp://');delete(s,1,3);end\n else begin write('http://');delete(s,1,4);end;\n\n\n\n\n\n for i:=1 to length(s)-1 do\nif (s[i]='r')and(s[i+1]='u') then begin l1:=i;l2:=i+1;end;\n\nk4:=copy(s,1,l1-1);\nk5:=copy(s,l2+1,length(s)-l2);\nwrite(k4,'.');write(s[l1],s[l2]);\nif k5<>'' then write('/',k5);\n end.\n\n"}, {"source_code": "var\n i,j,n,m,k,kol,ans,res:longint;\n s:ansistring;\nbegin\n readln(s);\n if s[1]='f' then i:=4 else i:=5;\n insert('://',s,i);\n for i:=1 to length(s)-1 do if (s[i]='r')and(s[i+1]='u') then res:=i;\n for i:=1 to res-1 do write(s[i]);\n write('.ru');\n inc(res);\n if length(s)-res>0 then\n begin\n write('/');\n for i:=res+1 to length(s) do write(s[i]);\n end;\nend.\n"}, {"source_code": "var s,p:string;\ni:integer;\nbegin\nreadln(s);\nif s[1]='h' then begin write('http://'); delete(s,1,4); end\nelse begin write('ftp://'); delete(s,1,3); end;\nfor i:=1 to length(s) do\nif (s[i]='r') and (s[i+1]='u') and (i>1) then \nbreak else p+=s[i];\nwrite(p,'.ru');\ndelete(s,1,i+1);\nif length(s)>0 then write('/',s);\nend."}, {"source_code": "var\n s:string;\n f,k:longint;\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n read(s);\n if s[1]='f' then\n insert('://',s,4)\n else\n insert('://',s,5);\n for f:=length(s) downto 7 do\n if (s[f]='u')and(s[f-1]='r')then\n break;\n insert('.',s,f-1);\n if f x+1 then\n begin\n Answer := Answer + '/';\n for i := x+2 to length(S) do\n begin\n Answer := Answer + S[i];\n end;\n end;\n writeln(Answer);\nend.\n"}, {"source_code": "var s:string;\n k:integer;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http');\n delete(s,1,4);\n end else\n begin\n write('ftp');\n delete(s,1,3);\n end;\n write('://');\n k:=pos('ru',s);\n if k=1 then\n begin\n write('ru');\n delete(s,1,2);\n k:=pos('ru',s);\n write(copy(s,1,k-1));\n write('.ru');\n delete(s,1,k+1);\n if length(s)>0 then\n\n write('/',s);\n exit;\n end;\n write(copy(s,1,k-1));\n write('.ru');\n delete(s,1,k+1);\n if length(s)>0 then\n\n write('/',s)\n\nend."}, {"source_code": "program p1;\nvar s:string;\np:integer;\nbegin\n readln(s);\n if (copy(s,1,3)='ftp') and (p=0) then\n begin\n write('ftp://');\n delete(s,1,3);\n p:=1;\n end;\n if (copy(s,1,4)='http') and (p=0)then\n begin\n write('http://');\n delete(s,1,4);\n p:=1;\n end;\n if pos('ru',s)=1 then\n begin\n write('ru');\n delete(s,1,2);\n end;\n write(copy(s,1,pos('ru',s)-1),'.ru');\n delete(s,1,pos('ru',s)+1);\n if length(s)>0 then write('/',s);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,res,t:string;\n i:longint;\n\nprocedure process;\nbegin\n read(s);\n if s[1]='h' then\n begin\n res:='http://';\n for i:=6 to length(s) do\n if s[i]+s[i+1]='ru' then break;\n res:=res+copy(s,5,i-5)+'.ru';\n t:=copy(s,i+2,length(s)-i-1);\n end\n else\n begin\n res:='ftp://';\n for i:=5 to length(s) do\n if s[i]+s[i+1]='ru' then break;\n res:=res+copy(s,4,i-4)+'.ru';\n t:=copy(s,i+2,length(s)-i-1);\n end;\n if t<>'' then res:=res+'/'+t;\n write(res);\nend;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n process;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nVar s,itog,l:string;i:LongInt;\nBegin\n readln(s);\n if s[1]='h'\n then begin\n Delete(s,1,4);\n itog:='http://';\n end\n else begin\n Delete(s,1,3);\n itog:='ftp://';\n end;\n for i:=Length(s)-1 downto 1 do\n begin\n if (s[i]='r')and(s[i+1]='u')\n then begin\n l:=Copy(s,1,i-1);\n itog:=itog+l+'.ru';\n Delete(s,1,i+1);\n if s<>''\n then itog:=itog+'/'+s;\n Writeln(itog);\n Halt(0);\n end;\n end;\nend."}, {"source_code": "var\n p:longint;\n s,sl:string;\nbegin\n read(s);\n if s[1]='f' then begin\n write('ftp://');\n delete(s,1,3);\n end\n else begin\n write('http://');\n delete(s,1,4);\n end;\n p:=pos('ru',s);\n if p=1 then begin\n s[1]:='~';\n p:=pos('ru',s);\n s[1]:='r';\n end;\n sl:=copy(s,1,p-1);\n write(sl,'.ru');\n delete(s,1,p+1);\n if length(s)>0 then write('/',s);\nend."}, {"source_code": "var\n s,p:ansistring;\n t:longint;\n\nbegin\n readln(s);\n if (copy(s,1,3)='ftp')then begin\n p:='ftp://';\n delete(s,1,3);\n end else begin\n p:='http://';\n delete(s,1,4);\n end;\n t:=pos('ru',s);\n if (t=1)then begin\n p:=p+'ru';\n delete(s,1,2);\n end;\n t:=pos('ru',s);\n p:=p+copy(s,1,t-1)+'.ru';\n delete(s,1,t+1);\n if (length(s)<>0)then p:=p+'/'+s;\n writeln(p);\nend."}, {"source_code": "const fi = '';\n fo = '';\n\nvar s: string[50];\n f: text;\n\nprocedure nhap;\nbegin\n assign(f, fi); reset(f);\n readln(f, s);\n close(f);\nend;\n\nprocedure xuat;\nvar i: longint;\n sp: string[50];\nbegin\n assign(f, fo); rewrite(f);\n if s[1] = 'h' then\n begin\n write(f, 'http');\n delete(s, 1, 4);\n end\n else\n begin\n write(f, 'ftp');\n delete(s, 1, 3);\n end;\n write(f, '://');\n i := 1; sp := '';\n while (i = 1) or ((i <> 1) and (not((s[i] = 'r') and (s[i + 1] = 'u')))) do\n begin\n sp := sp + s[i];\n inc(i);\n end;\n write(f, sp, '.ru');\n delete(s, 1, i + 1);\n if s <> '' then write(f, '/', s);\n close(f);\nend;\n\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "Var\n a,r:string;\n i,g,j:integer;\nBegin\n Readln(a);\n if a[1]='h' then\n Begin\n r:=r+'http://';\n for i:=1 to length(a) do\n Begin\n if (a[i]='r') and (a[i+1]='u') and (i-1<>4) then\n Begin\n for j:=5 to i-1 do\n Begin\n r:=r+a[j];\n End;\n r:=r+'.ru';\n if length(a)<>i+1 then\n BEgin\n r:=r+'/';\n for g:=i+2 to length(a) do\n Begin\n r:=r+a[g];\n End;\n End;\n Break;\n End;\n End;\n end\n else\n Begin\n r:=r+'ftp://';\n for i:=1 to length(a) do\n Begin\n if (a[i]='r') and (a[i+1]='u') and (i-1<>3) then\n Begin\n for j:=4 to i-1 do\n Begin\n r:=r+a[j];\n End;\n r:=r+'.ru';\n if length(a)<>i+1 then\n BEgin\n r:=r+'/';\n for g:=i+2 to length(a) do\n Begin\n r:=r+a[g];\n End;\n End;\n Break;\n End;\n End;\n End;\n Writeln(r);\n Readln;\nEnd.\n"}, {"source_code": "program b;\nvar\n s,str:string;\n i,loc:longint;\nbegin\n readln(str);\n s:=copy(str,1,3);\n if s='ftp' then\n begin\n write('ftp://');\n str:=copy(str,4,length(str)-3);\n for i:=length(str)-1 downto 1 do\n if (str[i]='r')and(str[i+1]='u') then\n begin\n loc:=i;\n break;\n end;\n s:=copy(str,1,loc-1);\n if s<>'' then write(s,'.ru') else write('ru');\n str:=copy(str,loc+2,length(str)-loc-1);\n if str<>'' then writeln('/',str);\n end\n else\n begin\n write('http://');\n str:=copy(str,5,length(str)-4);\n for i:=length(str)-1 downto 1 do\n if (str[i]='r')and(str[i+1]='u') then\n begin\n loc:=i;\n break;\n end;\n s:=copy(str,1,loc-1);\n if s<>'' then write(s,'.ru') else write('ru');\n str:=copy(str,loc+2,length(str)-loc-1);\n if str<>'' then writeln('/',str);\n end;\nend.\n"}, {"source_code": "var\n S,S1,S2,Ans:String;\n i:Longint;\nbegin\n Readln(S);\n if S[1]+S[2]+S[3]='ftp' then begin\n Ans:=Ans+'ftp://';\n Delete(S,1,3);\n end\n else if S[1]+S[2]+S[3]+S[4]='http' then begin\n Ans:=Ans+'http://';\n Delete(S,1,4);\n end;\n i:=1;\n while i<=Length(S)-1 do\nbegin\n if S[i]='r' then begin\n if S[i+1]='u' then begin\n if S2<>'' then begin\n Ans:=Ans+S2+'.ru';\n Delete(S,1,i+1);\n Break;\n end\n else S2:=S2+'r';\n end\n else S2:=S2+S[i];\n end\n else S2:=S2+S[i];\n Inc(i);\n end;\n if S<>'' then Ans:=Ans+'/';\n Ans:=Ans+S;\n Writeln(Ans);\n end.\n\n"}, {"source_code": "var \n s,res,s2:string;\n i:integer;\n \nbegin\nread(s);\n\nif s[1]='f' then \n begin\n res:=res+copy(s,1,3); \n delete(s,1,3);\n end\n else\n begin\n res:=res+copy(s,1,4);\n delete(s,1,4);\n end;\nres:=res+'://';\nfor i:=2 to length(s)-1 do\n if ((s[i]='r') and (s[i+1]='u')) then break;\nres:=res+copy(s,1,i-1)+'.ru';\ndelete(s,1,i+1);\nif length(s)>0 then res:=res+'/'+s;\nwrite(res);\nend."}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\n\nvar\n i,j: integer;\n s,ans,t: string;\nbegin\n read(s);\n if s[1]='h' then begin\n ans:=ans+'http://';\n delete(s,1,4);\n end\n else begin\n ans:=ans+'ftp://';\n delete(s,1,3);\n end;\n i:=1;\n while true do begin\n inc(i);\n t:=s[i]+s[i+1];\n if t='ru' then break;\n end;\n for j:=1 to i-1 do ans:=ans+s[j];\n ans:=ans+'.'+'ru'+'/';\n for j:=i+2 to length(s) do ans:=ans+s[j];\n if ans[length(ans)]='/' then delete(ans,length(ans),1);\n write(ans);\nend."}, {"source_code": "program krok_b;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i,n,j,k:integer;\n s,v:string;\n\nbegin\nreadln(s);\nif s[1]+s[2]+s[3]='ftp' then begin v:=v+s[1]+s[2]+s[3]+'://'; delete(s,1,3); end\n else begin v:=v+s[1]+s[2]+s[3]+s[4]+'://'; delete(s,1,4); end;\nn:=length(s);\ni:=n-1;\nwhile k<>1 do\nbegin\nif s[i]+s[i+1]='ru' then k:=1;\ni:=i-1;\nend;\nfor j:=1 to i do v:=v+s[j];\nv:=v+'.ru';\ndelete(s,1,i+2);\nif s='' then writeln(v)\n else writeln(v+'/'+s);\nend.\n "}, {"source_code": "Var s,q:string;\n i:longint;\n begin\n readLn(s);\n if s[1]='f' then\n begin\n q:=Copy(s,4,length(s)-3);\n Delete(s,4,Length(s)-3);\n s:=s+'://';\n s:=s+q;\n end else\n begin\n q:=Copy(s,5,length(s)-4);\n Delete(s,5,Length(s)-4);\n s:=s+'://';\n s:=s+q;\n end;\n i:=length(s);\n while i>1 do\n begin\n if (s[i]='u') and(s[i-1]='r') then\n begin\n q:=copy(s,i+1,length(s)-i+1);\n delete(s,i-1,length(s)-(i-2));\n if s[i-2]='/' then\n begin\n if Length(q)=0 then s:=s+'ru' else\n begin\n s:=s+'ru/';\n s:=s+q;\n end;\n Break\n end else\n begin\n if length(q)=0 then s:=s+'.ru' else\n begin\n s:=s+'.ru/';\n s:=s+q;\n end;\n end;\n break\n end else\n i:=i-1;\n end;\n writeln(s);\n end."}, {"source_code": "var\n i,y,x,d:longint;\n s:ansistring;\nbegin\n readln(s);\n if s[1]='f' then begin\n write('ftp://');\n d:=4;\n end\n else begin\n write('http://');\n d:=5;\n end;\n x:=pos('p',S);\n y:=pos('ru',s);\n if y=d then begin\n write('ru');\n delete(s,y,2);\n y:=pos('ru',s);\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n end\n else begin\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n end;\n write('.ru');\n if y+1'.' do dec(i);\n if length(s)-i>2 then\n insert('/',s,pos('.',s)+3);\n writeln(s);\nend.\n"}, {"source_code": "var\n s : string;\n p,i : longint;\nbegin\n readln(s);\n if copy(s,1,3) = 'ftp' then insert('://',s,4)\n else insert('://',s,5);\n\n for i := 1 to length(s) - 2 do if (copy(s,i,3) <> '/ru') and (copy(s,i+1,2)='ru') then break;\n\n p := i + 1;\n insert('.',s,p);\n\n p := pos('.ru',s);\n insert('/',s,p + 3);\n\n if s[length(s)] = '/' then delete(s,length(s),1);\n\n writeln(s);\nend."}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s, t: string;\nk: integer;\nbegin\n readln(s);\n if s[1] = 'h' then\n begin\n t := copy(s, 1, 4) + '://' + s[5];\n s := copy(s, 6, length(s) - 5);\n end\n else\n begin\n t := copy(s, 1, 3) + '://' + s[4];\n s := copy(s, 5, length(s) - 4);\n end;\n //t := t + '://';\n k := pos('ru', s);\n t := t + copy(s, 1, k - 1);\n t := t + '.ru';\n if k + 1 < length(s) then\n begin\n t := t + '/' + copy(s, k + 2, length(s) - k - 1);\n end;\n writeln(t);\nend.\n"}, {"source_code": " var s,s2:string;\n k:integer;\nbegin\n readln(s);\n if copy(s,1,4)='http' then begin\n s2:='http://';\n delete(s,1,4);\n end else begin\n s2:='ftp://';\n delete(s,1,3);\n end;\n s2:=s2+s[1];\n delete(s,1,1);\n\n s2:=s2+copy(s,1,pos('ru',s)-1)+'.ru';\n delete(s,1,pos('ru',s)+1);\n if (length(s)>0) then\n s2:=s2+'/'+s;\n \n writeln(s2);\n \nend."}, {"source_code": "var\n s : string;\nbegin\n readln(s);\n if pos('ftp',s) = 1 then\n begin\n write('ftp://');\n delete(s,1,3);\n if pos('ru',s) = 1 then begin write('ru'); delete(s,1,2); end;\n write(copy(s,1,pos('ru',s)-1),'.ru');\n delete(s,1,pos('ru',s)+1);\n if length(s) > 0 then writeln('/',s);\n end else\n begin\n write('http://');\n delete(s,1,4);\n if pos('ru',s) = 1 then begin write('ru'); delete(s,1,2); end;\n write(copy(s,1,pos('ru',s)-1),'.ru');\n delete(s,1,pos('ru',s)+1);\n if length(s) > 0 then writeln('/',s);\n end;\nend."}, {"source_code": "Program b;\nvar k,s:string;\n i:longint;\nbegin\n readln(s);\n if s[1]='f' then\n begin\n i:=4;\n repeat\n i:=i+1;\n k:=s[i]+s[i+1];\n until k='ru';\n if i+1<>length(s) then\n writeln('ftp://',copy(s,4,i-4),'.ru/',copy(s,i+2,length(s)-i-1))\n else\n writeln('ftp://',copy(s,4,i-4),'.ru');\n end\n else\n begin\n i:=5;\n repeat\n i:=i+1;\n k:=s[i]+s[i+1];\n until k='ru';\n if i+1<>length(s) then\n writeln('http://',copy(s,5,i-5),'.ru/',copy(s,i+2,length(s)-i-1))\n else\n writeln('http://',copy(s,5,i-5),'.ru');\n end\nend."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ns,link:string;\ni:integer;\nbegin\n readln(s);\n if s[1]='f' then\n begin\n link:=Copy(s,1,3) + '://';\n for i:=5 to Length(s) do\n if Copy(s,i,2) = 'ru' then\n begin\n link:=link + copy(s,4,i-4) + '.ru/' + Copy(s,i+2,Length(s)-i-1);\n break;\n end;\n end\n else if s[1]='h' then\n begin\n link:=Copy(s,1,4) + '://';\n for i:=6 to Length(s) do\n if Copy(s,i,2) = 'ru' then\n begin\n link:=link + copy(s,5,i-5) + '.ru/' + Copy(s,i+2,Length(s)-i-1);\n break;\n end;\n end;\nif link[length(link)] = '/' then link:=copy(link,1,length(link)-1);\nWriteln(link);\nReadln;\nReadln;\nEND.\n\n"}, {"source_code": "var\n i,p,p1 : longint;\n s : string;\n\nbegin\n readln(s);\n\n p:=pos('http',s);\n p1:=pos('ftp',s);\n if p=0 then p:=maxlongint;\n if p1=0 then p1:=maxlongint;\n\n if p1

length(s) then insert('/',s,p+2);\n\n insert('.',s,p);\n writeln(s);\nend.\n\n\n\n"}, {"source_code": "program PrB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,j : longint;\n st : string;\nbegin\n readln(st);\n if st[1]='h' then\n begin\n for i:=1 to 4 do write(st[i]);\n write('://');\n write(st[5]);\n i:=6;\n while not ((st[i]='r') and (st[i+1]='u')) do\n begin\n write(st[i]);\n inc(i);\n end;\n write('.ru');\n if length(st)>i+1 then\n begin\n write('/');\n for j:=i+2 to length(st) do write(st[j]);\n end;\n end;\n if st[1]='f' then\n begin\n for i:=1 to 3 do write(st[i]);\n write('://');\n write(st[4]);\n i:=5;\n while not ((st[i]='r') and (st[i+1]='u')) do\n begin\n write(st[i]);\n inc(i);\n end;\n write('.ru');\n if length(st)>i+1 then\n begin\n write('/');\n for j:=i+2 to length(st) do write(st[j]);\n end;\n end;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n ,suma,t,sumb,x,y,a,b,c: int64;\n i , j : integer;\n p : integer;\n s:string;\nbegin\n readln(s);\n if (s[1] = 'h') then\n insert('://',s,5)\n else\n insert('://',s,4);\n if (s[1] = 'h') then\n p :=8\n else\n p := 7;\n for i:=length(s) downto p+1 do\n if (s[i] = 'u') and (s[i-1] = 'r') then\n begin\n insert('.',s,i-1);\n p := i+1;\n break;\n end;\n if (p=length(s)) then writeln(s)\n else\n begin\n insert('/',s,p+1);\n writeln(s);\n end;\nend."}, {"source_code": "var s:string;\n p:longint;\nbegin\n readln(s);\n if s[1]='h' then insert('://',s,5) else insert('://',s,4);\n p:=pos('ru',s);\n if (s[1]='f')and(p<=7)or(s[1]='h')and(p<=8) then begin inc(p);while (s[p]<>'r')or(s[p+1]<>'u')do inc(p);end;\n insert('.',s,p);\n insert('/',s,p+3);\n if s[length(s)]='/' then delete(s,length(s),1);\n writeln(s);\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar s,st:String;\n vt,vt1:longint;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n readln(f,s);\n if s[1]='f' then insert('://',s,4)\n else insert('://',s,5);\n vt:=pos('ru',s);\n if s[vt-1]='/' then\n begin\n st:=copy(s,vt+2,length(s)-vt-1);\n vt1:=pos('ru',st); vt:=vt1+vt+1;\n end;\n insert('.',s,vt);\n if vt+2'/' then\n begin\n insert('.',s,x); kt:=true;\n if x+2'/' then begin insert('.',s,t);insert('/',s,t+3); end else begin\ndelete(s,t,2);\ninsert('.',s,pos('ru',s));\ninsert('ru',s,t);\ninsert('/',s,pos('.ru',s)+4); end;\n\nif s[length(s)]='/' then delete(s,length(s),1);\nwrite(s);\nend."}, {"source_code": "var a:string[50];\nbegin\n readln(a);\n if a[1]='f' then begin\n write('ftp://');\n delete(a,1,3);\n end\n else begin\n write('http://');\n delete(a,1,4);\n end;\n if copy(a,1,2)='ru' then begin\n write('ru');\n delete(a,1,2);\n end;\n write(copy(a,1,pos('ru',a)-1),'.ru/');\n delete(a,1,pos('ru',a)+1);\n writeln(a);\n readln;\nend.\n\n"}, {"source_code": "var s,k4,k5:string;\nk1,k2,i,k3,d:longint;\nbegin\nk1:=0;k2:=0;\nreadlN(S);\nk1:=pos('http',s);\nk2:=pos('ftp',s);\nif k1=0 then begin write('ftp://');d:=3;end else\nif k2=0 then begin write('http://');d:=4;end else\nif k1k2 then begin write('ftp://');d:=3;end;\nk3:=pos('ru',s);\nk4:=copy(s,d+1,k3-d-1);\nk5:=copy(s,k3,2);\ndelete(s,1,k3+1);\n\nwrite(k4);write('.',k5,'.');\n write(S);\nend.\n\n"}, {"source_code": "var\n s:string;\n d,i:longint;\nbegin\nreadln(s);\nif (s[1]='h') and (s[2]='t') and (s[3]='t') and (s[4]='p') then begin write(s[1],s[2],s[3],s[4],'://'); d:=5; end;\nif (s[1]='f') and (s[2]='t') and (s[3]='p') then begin write(s[1],s[2],s[3],'://'); d:=4; end;\nwhile (s[d]<>'r') or (s[d+1]<>'u') do\nbegin\n write(s[d]);\n d:=d+1;\nend;\nwrite('.ru'); d:=d+2;\nif d<=length(s) then\nbegin\n write('/');\n for i:=d to length(s) do\n write(s[i]);\nend;\nend."}, {"source_code": "Var s:string;\n\nBegin\n\n readln(s);\n\n if pos('http',s)=1 then\n insert('://',s,5) else\n\n if pos('ftp',s)=1 then\n insert('://',s,4);\n\n\n if pos('ru',s)>0 then\n begin\n insert('.',s,pos('ru',s));\n insert('/',s,pos('ru',s)+2);\n end;\n\n\n writeln(s);\n\nEnd."}, {"source_code": "var s1,s:string;\nbegin\nreadln(s);\nif pos('ftp',s)=1 then begin write('ftp://'); delete(s,1,3); end\nelse begin write('http://'); delete(s,1,4); end;\n\ns1:=copy(s,1,pos('ru',s)-1);\nif s1='' then begin s1:='ru';\n\ns1:=s1+copy(s,1,pos('ru',s)-1);\ndelete(s,1,pos('ru',s)+1);\nend;\ndelete(s,1,pos('ru',s)+1);\n\nwrite(s1,'.ru');\nif s<>'' then write('/',s);\nend.\n\n"}, {"source_code": "program codeforces;\n var\n input , protocol , domain , context : string[50];\n\nbegin\n readln ( input );\n if ( pos ( 'http' , input ) > pos ( 'ftp' , input ) )\n then protocol := 'ftp'\n else protocol := 'http' ;\n delete ( input , 1 , length ( protocol ) ) ;\n domain := copy ( input , 1 , ( pos ( 'ru' , input ) - 1 ) ) ;\n delete ( input , 1 , length ( domain ) ) ;\n context := copy ( input , ( pos ( 'ru' , input ) + 2 ) , length ( input ) ) ;\n delete ( input , 1 , ( pos ( 'ru' , input ) + 1 ) ) ;\n writeln ( protocol , '://' , domain , '.ru/' , context ) ;\n readln\nend."}, {"source_code": "var a,a_1:string;\n b,i:word;\nbegin\nreadln(a);\na_1:='';\nif (a[1]+a[2]+a[3])='ftp' then a_1:='ftp://' else a_1:='http://';\nb:=pos('ru',a);\nif a_1='ftp://' then begin\n for i:=4 to (b-1) do a_1:=a_1+a[i]; end\nelse begin\n for i:=5 to (b-1) do a_1:=a_1+a[i]; end;\na_1:=a_1+'.ru';\nif (b+1)0 then\n begin\n insert('.',s,pos('ru',s));\n insert('/',s,pos('ru',s)+2);\n end;\n\n\n writeln(s);\n\nEnd."}, {"source_code": "var\n i,j,n,m,k:longint;\n s:string;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n begin\n if s[1]='f' then\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n end;\n m:=pos('ru',s);\n write(copy(s,1,m-1),'.','ru');\n delete(s,1,m+1);\n if s<>'' then writeln('/',s)\n else writeln;\nend."}, {"source_code": "program adress;\nconst\n p_http='http';\n c_http=4;\n p_ftp='ftp';\n c_ftp=3;\n p_ru='ru';\n c_ru=2;\n p_br='://';\n p_sl='/';\n \nvar\n i:integer;\n s:string[100];\n \n function rep (sub,t:string; c:integer): string;\n var j:integer;\n begin\n i:=pos(sub,t);\n insert(p_br,t,i+c);\n i:=pos(p_ru,t);\n if t[i-1]<>p_sl then\n begin\n insert('.',t,i);\n insert(p_sl,t,i+c_ru+1);\n end\n else \n begin\n delete(t,i,2);\n insert('!',t,i);\n j:=pos(p_ru,t);\n insert('.',t,j);\n insert(p_sl,t,j+c_ru+1);\n delete(t,i,1);\n insert('ru',t,i)\n end;\n rep:=t;\n end;\n \nbegin\nreadln(s);\ncase s[1] of\n'f': writeln( rep(p_ftp,s,c_ftp));\n'h': writeln( rep(p_http,s,c_http));\nend;\nend. "}, {"source_code": "var a:string[50];\nbegin\n readln(a);\n if a[1]='f' then begin\n write('ftp://');\n delete(a,1,3);\n end\n else begin\n write('http://');\n delete(a,1,4);\n end;\n write(copy(a,1,pos('ru',a)-1),'.ru/');\n delete(a,1,pos('ru',a)+1);\n writeln(a);\n readln;\nend.\n\n"}, {"source_code": "program z;\nvar protokol,protokoll,a,ru,c,s,f:string; i,k,po:byte;\nbegin\nread (a);\ni:=length (a);\nprotokol:='http';\nprotokoll:='ftp';\nru:='ru';\nc:='.';\nf:='/';\nk:=pos (ru,a);\nif pos(protokol,a)<>0 then po:=5\nelse po:=3;\ns:='://';\ninsert (s,a,po);\ninsert (c,a,k+po-2);\nif k+1=i then write (a)\nelse begin insert (f,a,k+po+1); write (a);\nend;readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+}\n{$O-}\n\nuses\n SysUtils, Math;\n\nvar\n st: array[1..500] of integer;\n s: string;\n i, mx, r: integer;\n\nprocedure push;\nbegin\n inc(r);\n if r > mx then\n mx := r;\n st[r] := 1;\nend;\n\nprocedure pop;\nbegin\n if r <= 0 then\n inc(mx)\n else\n dec(r);\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(s);\n r := 0; mx := 0;\n for i := 1 to length(s) do\n if s[i] = '+' then\n push\n else\n pop;\n write(mx);\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar s, res: string;\nprocedure Nhap;\nvar fi: text;\nbegin\n assign(fi, finp); reset(fi);\n readln(fi, s);\n close(fi);\nend;\nprocedure Xuat;\nvar fo: text;\nbegin\n assign(fo, fout); rewrite(fo);\n writeln(fo, res);\n close(fo);\nend;\nprocedure reg1(var res: string);\nbegin\n if res[1]='h' then Insert('://', res, 5)\n else insert('://',res, 4);\nend;\nprocedure reg2(var res: string);\nvar i, j: integer;\nbegin\n i:=pos('ru', res);\n if (i<=8) then\n for j:=i+1 to length(res) do if (res[j]='r') and (res[j+1]='u') then break;\n i:=j;\n insert('.',res,i);\n if i+2'ru' do begin\n Write(S[1]);\n Delete(S,1,1);\n end;\n Write('.ru');\n Delete(S,1,2);\nif S<>'' then begin\n Write('/',S);\n end;\nend."}, {"source_code": "var\n s:string;\n d,i:longint;\nbegin\nreadln(s);\nif (s[1]='h') and (s[2]='t') and (s[3]='t') and (s[4]='p') then begin write(s[1],s[2],s[3],s[4],'://'); d:=5; end;\nif (s[1]='f') and (s[2]='t') and (s[3]='p') then begin write(s[1],s[2],s[3],'://'); d:=4; end;\nwhile (s[d]<>'r') or (s[d+1]<>'u') do\nbegin\n write(s[d]);\n d:=d+1;\nend;\nwrite('.ru'); d:=d+2;\nif d<=length(s) then\nbegin\n write('/');\n for i:=d to length(s) do\n write(s[i]);\nend;\nend."}, {"source_code": "var s:string;\n d:longint;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n d:=pos('ru',s);\n write(copy(s,1,d-1),'.');\n delete(s,1,d+1);\n write('ru');\n if length(s)<>0 then\n writeln('/',s);\nend.\n"}, {"source_code": "var s:string;\n d:longint;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n d:=pos('ru',s);\n write(copy(s,1,d-1),'.');\n delete(s,1,d+1);\n write('ru/');\n writeln(s);\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar s, res: string;\nprocedure Nhap;\nvar fi: text;\nbegin\n assign(fi, finp); reset(fi);\n readln(fi, s);\n close(fi);\nend;\nprocedure Xuat;\nvar fo: text;\nbegin\n assign(fo, fout); rewrite(fo);\n writeln(fo, res);\n close(fo);\nend;\nprocedure reg1(var res: string);\nbegin\n if res[1]='h' then Insert('://', res, 5)\n else insert('://',res, 4);\nend;\nprocedure reg2(var res: string);\nvar i, j: integer;\nbegin\n i:=pos('ru', res);\n if (i<=8) then\n for j:=i+1 to length(res) do if (res[j]='r') and (res[j+1]='u') then break;\n i:=j;\n insert('.',res,i);\n if i+2'' then writeln('/',s)\n else writeln;\nend.\n"}, {"source_code": "{$apptype console}\n{$I+,R+,Q+}\nUses\n SysUtils;\n\nVar\n s1,s2:string;\nBegin\n readln(s1);\n if s1[1]='h' then begin\n s2:='http://';\n delete(s1,1,4);\n end;\n if s1[1]='f' then begin\n s2:='ftp://';\n delete(s1,1,3);\n end;\n s2:=s2+copy(s1,1,pos('ru',s1)-1);\n delete(s1,1,pos('ru',s1)+1);\n s2:=s2+'.ru';\n if s1<>'' then s2:=s2+'/'+s1;\n writeln(s2);\nEnd.\n"}, {"source_code": " var s:string;\n i,l:integer;\nbegin\n readln(s);\n// l:=length(s);\n if s[1]='h'\n then begin write(s[1],s[2],s[3],s[4],'://'); delete(s,1,4); end\n else begin write(s[1],s[2],s[3],'://'); delete(s,1,3); end;\n i:=1;\n while not((s[i]='r')and(s[i+1]='u')) do\n begin\n write(s[i]);\n inc(i);\n end;\n write('.');\n write(s[i],s[i+1]);\n l:=length(s);\n if i+2<=l\n then begin\n write('/');\n for i:=i+2 to l do\n write(s[i]);\n end;\n writeln; \nend.\n"}, {"source_code": "var s:string;\n d:longint;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n d:=pos('ru',s);\n write(copy(s,1,d-1),'.');\n delete(s,1,d+1);\n write('ru/');\n writeln(s);\nend."}, {"source_code": "program z;\nvar protokol,protokoll,a,ru,c,v,s,f:string; i,k,po:byte;\nbegin\nread (a);\ni:=length (a);\nprotokol:='http';\nprotokoll:='ftp';\nru:='ru';\nc:='.';\nf:='/';\nv:=copy(a,1,4);\nk:=pos (ru,a);\nif v=protokol then po:=5\nelse po:=4;\ns:='://';\ninsert (s,a,po);\ninsert (c,a,k+3);\nif k+1=i then write (a)\nelse begin insert (f,a,k+6); write (a);\nend;\nend.\n"}, {"source_code": "var s:string;\nbegin\n readln(s);\n if s[1]='h' then insert('://',s,5) else insert('://',s,4);\n insert('.',s,pos('ru',s));\n insert('/',s,pos('ru',s)+2);if s[length(s)]='/' then delete(s,length(s),1);\n writeln(s);\nend."}, {"source_code": "var s:string;\n t,t1:integer;\nbegin\nreadln(s);\nt:=pos('http',s);\nif t=0 then t:=100;\nt1:=pos('ftp',s);\nif t1=0 then t1:=100;\nif t'/' then begin insert('.',s,t);insert('/',s,t+3); end else begin\ndelete(s,t,2);\ninsert('.',s,pos('ru',s));\ninsert('ru',s,t);\ninsert('/',s,pos('.ru',s)+4); end;\n\nif s[length(s)]='/' then delete(s,length(s),1);\nwrite(s);\nend."}, {"source_code": "var\n s:string;\n f,i:longint;\n u:boolean;\n\nbegin\n readln(s);\n if s[1]='h'\n then\n begin\n write('http://');\n f:=5\n end\n else\n begin\n write('ftp://');\n f:=4\n end;\n u:=false;\n for i:=f to length(s) do\n begin\n if (s[i]='r')and(s[i+1]='u')and(not u)\n then continue;\n if (s[i-1]='r')and(s[i]='u')and(not u)and(i<>f)\n then\n begin\n write('.ru');\n if i<>length(s) then\n begin\n write('/');\n u:=true\n end\n end\n else write(s[i])\n end\nend."}, {"source_code": "var s:string;\n k,k1:integer;\nbegin\nreadln(s);\nk:=pos('http',s);\nif k=0 then k:=10000;\nk1:=pos('ftp',s);\nif k1=0 then k1:=10000;\nif k'/' then begin insert('.',s,k);insert('/',s,k+3); end else begin\ndelete(s,k,2);\ninsert('.',s,pos('ru',s));\ninsert('ru',s,k);\ninsert('/',s,pos('.ru',s)+4); end;\n\nif s[length(s)]='/' then delete(s,length(s),1);\nwrite(s);\nreadln;\nend."}, {"source_code": "var\n i,y,x,d:longint;\n s:ansistring;\nbegin\n readln(s);\n if s[1]='f' then begin\n write('ftp://');\n d:=4;\n end\n else begin\n write('http://');\n d:=5;\n end;\n x:=pos('p',S);\n y:=pos('ru',s);\n if y=d then begin\n write('ru');\n delete(s,y,2);\n y:=pos('ru',s);\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n end;\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n write('.ru');\n if y+1length(s)-1 then\n begin\n write('/');\n for j:=i+2 to length(s) do write(s[j]);\n exit;\n end;\n end else begin f:=true; write(s[i]); end;\n end;\nend.\n"}, {"source_code": "var x,y,m,n,k,i,j,p,t:longint;\ns,s1,s2:string;\nbegin\nreadln(s);\nif s[1]='f' then\n begin\n s1:='ftp://';\n delete(s,1,3);\n end else\n begin\n s1:='http://';\n delete(s,1,4);\n end;\n k:=pos('ru',s);\n s1:=s1+copy(s,1,k-1)+'.ru';\n delete(s,1,k+1);\n if s>'' then s1:=s1+'/'+s;\n writeln(s1);\n\n end.\n"}, {"source_code": "var\n s:string;\n f,i:longint;\n u:boolean;\n\nbegin\n readln(s);\n if s[1]='h'\n then\n begin\n write('http://');\n f:=5\n end\n else\n begin\n write('ftp://');\n f:=4\n end;\n u:=false;\n for i:=f to length(s) do\n begin\n if (s[i]='r')and(s[i+1]='u')and(not u)\n then continue;\n if (s[i-1]='r')and(s[i]='u')and(not u)and(i<>(f-1))\n then\n begin\n write('.ru');\n if i<>length(s) then\n begin\n write('/');\n u:=true\n end\n end\n else write(s[i])\n end\nend."}, {"source_code": "program codeforces;\n var\n input , protocol , domain , context : string[50];\n\nbegin\n readln ( input );\n if ( pos ( 'http' , input ) > pos ( 'ftp' , input ) )\n then protocol := 'ftp'\n else protocol := 'http' ;\n delete ( input , 1 , length ( protocol ) ) ;\n domain := copy ( input , 1 , ( pos ( 'ru' , input ) - 1 ) ) ;\n delete ( input , 1 , length ( domain ) ) ;\n context := copy ( input , ( pos ( 'ru' , input ) + 2 ) , length ( input ) ) ;\n delete ( input , 1 , ( pos ( 'ru' , input ) + 1 ) ) ;\n writeln ( protocol , '://' , domain , '.ru/' , context ) ;\n readln\nend."}, {"source_code": "var\n s:string;\n f,i:longint;\n u:boolean;\n\nbegin\n readln(s);\n if s[1]='h'\n then\n begin\n write('http://');\n f:=5\n end\n else\n begin\n write('ftp://');\n f:=4\n end;\n u:=false;\n for i:=f to length(s) do\n begin\n if (s[i]='r')and(s[i+1]='u')and(not u)\n then continue;\n if (s[i-1]='r')and(s[i]='u')and(not u)\n then\n begin\n write('.ru');\n if i<>length(s) then\n begin\n write('/');\n u:=true\n end\n end\n else write(s[i])\n end\nend."}, {"source_code": "var\n s:string;\n a,i,f:integer;\nbegin\n readln(s);\n if (s[1]='h') then\n write('http://')\n else\n begin\n write('ftp://');\n a:=1;\n end;\n for i:=5-a to length(s) do\n begin\n if (a=2) then\n begin\n a:=1;\n continue;\n end;\n if ((f=0) and (concat(s[i],s[i+1])='ru') and (i+1<>length(s))) then\n begin\n write('.ru');\n f:=1;\n if (i+1<>length(s)) then\n write('/');\n a:=2;\n end\n else\n write(s[i]);\n end;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i : integer;\n s, s1 : string;\n bool : boolean;\n\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n\n readln(s);\n s1 := '';\n i := 1;\n bool := false;\n while i <= length(s) do begin\n s1 := s1 + s[i];\n if (s1 = 'http') or (s1 = 'ftp') then\n s1 := s1 + '://';\n if (s[i] = 'r') and (s[i + 1] = 'u') and (not bool) then begin\n s1 := s1 + '.ru';\n inc(i, 1);\n if (length(s) > i) then begin\n s1 := s1 + '/';\n bool := true;\n end;\n end;\n inc(i);\n end;\n\n writeln(s1);\n\nend.\n "}, {"source_code": "const fin='';\n fout='';\nvar st,s1:string;\n vt,l,i,j:integer;\n f,g:text;\nbegin\n assign(f,fin);\n reset(f);\n assign(g,fout);rewrite(g);\n readln(f,st);\n vt:=pos('http',st);\n if vt=1 then\n begin\n s1:=s1+'http://';\n l:=5;\n end;\n vt:=pos('ftp',st);\n if vt=1 then\n begin\n s1:=s1+'ftp://';\n l:=4;\n end;\n for i:=l+1 to length(st)-1 do\n if (st[i]='r') and (st[i+1]='u') then\n begin\n for j:=l to i-1 do s1:=s1+st[j];\n s1:=s1+'.ru';\n if (i+2>length(st)) then break\n else\n begin\n s1:=s1+'/';\n for j:=i+2 to length(st) do s1:=s1+st[j];\n break;\n end;\n end;\n write(g,s1);\nend."}, {"source_code": "Var s:string;\n i,j,n:longint;\n begin\n Readln(s);\n if (s[1]='f') and (s[2]='t') and (s[3]='p') then\n begin\n n:=4;\n Write('ftp://')\n end\n else\n if (s[1]='h') and (s[2]='t') and (s[3]='t') and (s[4]='p') then\n begin\n n:=5;\n Write('http://');\n end;\n if (s[length(s)]='u') and (s[length(s)-1]='r') then\n begin\n for i:=n to length(s)-2 do\n Write(s[i]);\n Write('.ru');\n Halt(0);\n end;\n j:=n;\n While j<=length(s)-1 do\n begin\n if (s[j]='r') and (s[j+1]='u') then\n begin\n for i:=n to j-1 do\n Write(s[i]);\n Write('.ru');\n n:=j+2;\n if n<=length(s) then begin\n Write('/');\n for i:=n to length(s) do\n begin\n Write(s[i]);\n if i=length(s) then halt(0);\n end;\n end;\n end;\n inc(j);\n end;\n end.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar s, res: string;\nprocedure Nhap;\nvar fi: text;\nbegin\n assign(fi, finp); reset(fi);\n readln(fi, s);\n close(fi);\nend;\nprocedure Xuat;\nvar fo: text;\nbegin\n assign(fo, fout); rewrite(fo);\n writeln(fo, res);\n close(fo);\nend;\nprocedure reg1(var res: string);\nbegin\n if res[1]='h' then Insert('://', res, 5)\n else insert('://',res, 4);\nend;\nprocedure reg2(var res: string);\nvar i: integer;\nbegin\n i:=pos('ru', res);\n insert('.',res,i);\n if i+2k2 then begin write('ftp://');d:=3;end;\nk3:=pos('ru',s);\nk4:=copy(s,d+1,k3-d-1);\nk5:=copy(s,k3,2);\ndelete(s,1,k3+1);\n\nwrite(k4);write('.',k5,'.');\n write(S);\nend.\n\n"}, {"source_code": "var l,s:string; j,i:integer;\nbegin\nread(s);\nrepeat\ninc(i);\nl:=l+s[i];\nuntil (l='http')or(l='ftp');\nl:=l+'://';inc(i);\nrepeat;\nl:=l+s[i];\ninc(i);\nuntil (s[i]='r')and(s[i+1]='u');\nl:=l+'.ru';\ni:=i+2;\nif s[i]<>'' then begin l:=l+'/';for j:=i to length(s) do l:=l+s[j];end;\nwrite(l);\nend."}, {"source_code": "type mang=array[1..100000] of longint;\nvar s,s1:string;vt,vt1,i:longint;\nbegin\n readln(s);\n vt1:=pos('ru',s);\n if s[1]='h' then\n begin\n write('http://');\n vt:=5;\n end\n else\n begin\n write('ftp://');\n vt:=4;\n end;\n for i:= vt to vt1-1 do write(s[i]);\n write('.ru');;\n if length(s)-vt1-1<>0 then\n begin\n write('/');\n for i:=vt1+2 to length(s) do write(s[i]);\n end;\n readln;\nend.\n"}, {"source_code": "Var s:string;\n\nBegin\n\n readln(s);\n\n\n if pos('http',s)=1 then\n insert('://',s,5) else\n\n if pos('ftp',s)=1 then\n insert('://',s,4);\n\n\n if pos('ru',s)>9 then\n begin\n insert('.',s,pos('ru',s));\n insert('/',s,pos('ru',s)+2);\n end;\n\n\n writeln(s);\n\nEnd."}, {"source_code": "{$r-, s-, q-, i-, o+}\nvar\n s : ansistring;\n i, len : longint;\nbegin\n readln(s);\n if (s[1] = 'h') then len := 4 else len := 3;\n s := copy(s, 1, len) + '://' + copy(s, len + 1, length(s) - len);\n i := pos('ru', s);\n s := copy(s, 1, i - 1) + '.' + copy(s, i, length(s) - i + 1);\n if (i + 1 < length(s)) then s := copy(s, 1, i + 2) + '/' + copy(s, i + 3, length(s) - i - 1);\n writeln(s);\nend."}, {"source_code": "Var s : string;\ni, k, l : integer;\na : array [1..100] of char;\nb : array [1..100] of char;\nm : boolean;\nBegin\nReadln (s);\nfor i:=1 to length (s) do\n begin\n a[i]:=s[i];\n end;\nk:=length (s);\nif a[1]='f' then\n begin\n b[1]:='f';\n b[2]:='t';\n b[3]:='p';\n b[4]:=':';\n b[5]:='/';\n b[6]:='/';\n for i:=7 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+3;\n end;\nIf a[1]='h' then\n begin\n b[1]:='h';\n b[2]:='t';\n b[3]:='t';\n b[4]:='p';\n b[5]:=':';\n b[6]:='/';\n b[7]:='/';\n for i:=8 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+4;\n end;\ni:=8;\nm:=(b[i]='r') and (b[i]='u');\nif b[1]='h' then inc (i);\nWhile m=false do\n begin\n m:=(b[i]='r') and (b[i+1]='u');\n inc(i);\n end;\ni:=i-1;\nFor l:=k+1 downto i do\n begin\n b[l]:=b[l-1];\n end;\nb[i]:='.';\ninc(k);\ninc(i);\nif b[1]='h' then inc (i);\nIf i+1<>k then\n begin\n if b[1]='h' then i:=i-1;\n for l:=k+1 downto i+2 do\n begin\n b[l]:=b[l-1];\n end;\n b[i+2]:='/';\n inc (k);\n end;\nFor i:=1 to k-1 do\n begin\n write (b[i]);\n end;\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\na:string;\ni,j,g:longint;\nbegin\nreadln(a);\nif(a[1]='h') then\nbegin\ni:=5;\nwrite('http://');\nend\nelse\nbegin\nwrite('ftp://');\ni:=4;\nend;\ng:=8;\nwhile(g=8) do\nbegin\nwrite(a[i]);\ni:=i+1;\nif(a[i]='r') and (a[i+1]='u') then g:=7;\nend;\nwrite('.ru/');\ni:=i+2;\nfor j:=i to length(a) do write(a[j]);\nwriteln;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n s,res:string;\n i:longint;\nprocedure process;\nbegin\n read(s);\n if s[1]='h' then\n begin\n res:='http://';\n for i:=length(s) downto 2 do\n if s[i-1]+s[i]='ru' then\n begin\n res:=res+copy(s,5,i-1);\n break;\n end;\n res:=res+'.ru/';\n res:=res+copy(s,i+2,length(s));\n end\n else\n begin\n res:='ftp://';\n// res:=res+copy(s,4,pos('ru',s)-4);\n for i:=length(s) downto 2 do\n if s[i-1]+s[i]='ru' then\n begin\n res:=res+copy(s,4,i-1);\n break;\n end;\n res:=res+'.ru/';\n res:=res+copy(s,pos('ru',s)+2,length(s));\n end;\n write(res);\nend;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n process;\nend.\n"}, {"source_code": "var S : string[50];\nbegin\n readln(S);\n If pos('http',S) = 1 then insert('://',S,5)\n else insert('://',S,4);\n insert('.',S,pos('ru',S));\n If pos('ru',S) <> length(S) - 1 then\n insert('/',S,pos('ru',S)+2);\n writeln(S);\nend.\n\n\n"}, {"source_code": "program adress;\nconst\n p_http='http';\n c_http=4;\n p_ftp='ftp';\n c_ftp=3;\n p_ru='ru';\n c_ru=2;\n p_br='://';\n p_sl='/';\n \nvar\n i:integer;\n s:string[100];\n \n function rep (sub,t:string; c:integer): string;\n var j:integer;\n begin\n i:=pos(sub,t);\n insert(p_br,t,i+c);\n i:=pos(p_ru,t);\n if t[i-1]<>p_sl then\n begin\n insert('.',t,i);\n if t[i+c_ru+1]<>'%' then\n insert(p_sl,t,i+c_ru+1);\n end\n else \n begin\n delete(t,i,2);\n insert('!',t,i);\n j:=pos(p_ru,t);\n insert('.',t,j);\n if t[i+c_ru+1]<>'%' then\n insert(p_sl,t,j+c_ru+1);\n delete(t,i,1);\n insert('ru',t,i)\n end;\n i:=length(t);\n delete(t,i,1);\n rep:=t;\n end;\n \nbegin\nreadln(s);\ni:=length(s);\ninsert('%',s,i+1);\nwriteln(s);\nreadln;\ni:=0;\ncase s[1] of\n'f': writeln( rep(p_ftp,s,c_ftp));\n'h': writeln( rep(p_http,s,c_http));\nend;\nend. "}, {"source_code": "var\n s:string;\n d,i:longint;\nbegin\nreadln(s);\nif (s[1]='h') and (s[2]='t') and (s[3]='t') and (s[4]='p') then begin write(s[1],s[2],s[3],s[4],'://'); d:=5; end;\nif (s[1]='f') and (s[2]='t') and (s[3]='p') then begin write(s[1],s[2],s[3],'://'); d:=4; end;\nwhile (s[d]<>'r') or (s[d+1]<>'u') do\nbegin\n write(s[d]);\n d:=d+1;\nend;\nwrite('.ru'); d:=d+2;\nif d<=length(s) then\nbegin\n write('/');\n for i:=d to length(s) do\n write(s[i]);\nend;\nend."}, {"source_code": "Var s : string;\ni, k, l : integer;\na : array [1..100] of char;\nb : array [1..100] of char;\nm : boolean;\nBegin\nReadln (s);\nfor i:=1 to length (s) do\n begin\n a[i]:=s[i];\n end;\nk:=length (s);\nif a[1]='f' then\n begin\n b[1]:='f';\n b[2]:='t';\n b[3]:='p';\n b[4]:=':';\n b[5]:='/';\n b[6]:='/';\n for i:=7 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+3;\n end;\nIf a[1]='h' then\n begin\n b[1]:='h';\n b[2]:='t';\n b[3]:='t';\n b[4]:='p';\n b[5]:=':';\n b[6]:='/';\n b[7]:='/';\n for i:=8 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+4;\n end;\ni:=8;\nm:=(b[i]='r') and (b[i]='u');\nWhile m=false do\n begin\n inc (i);\n m:=(b[i]='r') and (b[i+1]='u');\n end;\nFor l:=k+1 downto i do\n begin\n b[l]:=b[l-1];\n end;\nb[i]:='.';\ninc(k);\ninc(i);\nIf i+2<>k then\n begin\n for l:=k+1 downto i+2 do\n begin\n b[l]:=b[l-1];\n end;\n b[i+2]:='/';\n inc (k);\n end;\nFor i:=1 to k do\n begin\n write (b[i]);\n end;\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n s,s1,s2,l,f : string;\n p,i,p1 : longint;\nbegin\n readln(s);\n p:=1;\n f:='';\n if s[p]='h' then begin f:=f+'http://'; p:=5; end\n else begin f:=f+'ftp://'; p:=4; end;\n s1:=copy(s,p,length(s));\n for i:=1 to length(s1) do\n if (s1[i]='r') and (s1[i+1]='u') then begin p1:=i; l:=copy(s1,1,p1-1); f:=f+l; f:=f+'.ru'; break; end;\n s2:=copy(s1,p1+2,length(s1));\n if s2=''\n then writeln(f)\n else writeln(f,'/',s2);\nend.\n \n \n "}, {"source_code": "{\n__________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶\n_________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶\n________¶¶__________¶¶¶¶¶¶__¶\n_______¶¶____¶¶_____¶¶¶¶_____¶\n______¶¶______¶¶¶¶¶¶¶________¶\n______¶______________________¶\n______¶______________________¶¶\n___¶¶¶¶¶____________________¶¶¶¶¶\n_¶¶¶__¶¶¶¶¶_______________¶¶¶¶¶_¶¶¶\n¶¶____¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶___¶¶\n¶______¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶_____¶\n¶¶_______¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶______¶¶\n_¶¶¶¶____________________________¶¶\n____¶¶¶¶______________________¶¶¶¶\n______¶¶¶____________________¶¶¶\n______¶_¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶_¶\n______¶________________________¶\n______¶______¶¶________¶¶______¶\n______¶______¶¶________¶¶______¶\n______¶________________________¶_____¶¶¶\n______¶¶_______________________¶____¶¶_¶¶\n_______¶________¶¶¶____________¶____¶___¶\n______¶¶¶¶¶¶¶___¶¶¶____¶¶¶¶¶¶¶¶¶¶¶__¶___¶\n____¶¶¶¶¶_____________________¶_____¶___¶\n________¶¶¶¶¶__________¶¶¶¶¶¶¶¶¶¶___¶___¶\n_______¶¶¶¶¶________________¶¶¶¶____¶___¶\n______¶¶___¶¶¶¶___________¶¶¶¶¶¶¶¶_¶¶___¶\n____________¶_¶¶¶¶¶¶¶¶¶¶¶¶¶______¶¶¶___¶¶\n____________¶___¶___¶___¶______________¶\n____________¶___¶___¶___¶_____________¶¶\n____________¶__¶¶¶¶¶____¶_____________¶\n____________¶_¶¶___¶¶___¶_____________¶\n____________¶¶¶_____¶¶__¶_____________¶\n______________¶¶_____¶¶¶¶_____________¶\n_______________¶____¶¶_____¶¶____¶____¶\n_______________¶___¶¶¶______¶¶¶¶¶¶____¶\n_______________¶¶__¶_¶______¶____¶____¶\n________________¶¶¶¶_¶¶____¶¶____¶¶__¶¶\n______________________¶¶¶¶¶¶______¶¶¶¶\n}\n// privet Chubarovu=**\n\nvar s:string;\n i:longint;\n\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(s);\n if s[1]='h' then insert('://',s,5)\n else if s[1]='f' then insert('://',s,4);\n insert('.',s,pos('ru',s));\n i:=length(s);\n while s[i]<>'.' do dec(i);\n if length(s)-i>2 then\n insert('/',s,pos('.',s)+3);\n writeln(s);\nend.\n"}, {"source_code": "var\n s:string;\n f,i:longint;\n u:boolean;\n\nbegin\n readln(s);\n if s[1]='h'\n then\n begin\n write('http://');\n f:=5\n end\n else\n begin\n write('ftp://');\n f:=4\n end;\n u:=false;\n for i:=f to length(s) do\n begin\n if (s[i]='r')and(s[i+1]='u')and(not u)\n then continue;\n if (s[i-1]='r')and(s[i]='u')and(not u)and(i<>f)\n then\n begin\n write('.ru');\n if i<>length(s) then\n begin\n write('/');\n u:=true\n end\n end\n else write(s[i])\n end\nend."}, {"source_code": "var i, n, ans: LongInt;\ns, st, x: String;\nbegin\n Readln(s);\n if (pos('http',s)=1) then\n begin\n st:='http://';\n Delete(s,1,4);\n s:=st+s;\n end else\n begin\n st:='ftp://';\n Delete(s,1,3);\n s:=st+s;\n end;\n \n if length(s)-7=3 then\n begin\n x:=Copy(s,length(s)-1,2);\n Delete(s,length(s)-1,2);\n s:=s+'.'+x;\n end else\n if length(s)-7=2 then\n begin\n x:=Copy(s,length(s),1);\n Delete(s,length(s),1);\n s:=s+'.'+x;\n end else\n begin\n x:=Copy(s,length(s)-3,4);\n Delete(s,length(s)-3,4);\n s:=s+'.'+x[1]+x[2]+'/'+x[3]+x[4];\n end;\n Writeln(s);\nend."}, {"source_code": "var s,s1,s2,s3:string;\n i,j:longint;\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n readln(s);\n if pos('h',s)=1\n then\n begin\n write('http://');\n delete(s,1,4);\n end;\n if pos('f',s)=1\n then\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n if pos('ru',s)=1\n then\n begin\n write('r');\n delete(s,1,1);\n end;\n for i:=1 to pos('ru',s)-1 do\n write(s[i]);\n delete(s,1,pos('ru',s)-1);\n write('.ru');\n if length(s)=0 then exit\n else\n begin\n write('/',s);\n exit;\n end;\nend."}, {"source_code": "Procedure FTP();\nBegin\n write('ftp');\n write('://');\nEnd;\nProcedure HTTP();\nBegin\n write('http');\n write('://');\nEnd;\n\nVar s:string;\n a,b,k,i,j,n:integer;\nBegin\nreadln(s);\na:=pos('http',s);\nb:=pos('ftp',s);\nif ((a>b) and (a<>0) and (b<>0)) or (a=0) then \n Begin\n FTP();\n k:=4;\n End;\nif ((a0) and (b<>0)) or (b=0) then \n Begin\n HTTP();\n k:=5;\n End;\nfor i:=k+1 to length(s)-1 do\n if (s[i]='r') and (s[i+1]='u') then\n Begin\n for j:=k to i-1 do\n write(s[j]);\n break; \n End;\nwrite('.ru/');\nfor n:=i+2 to length(s) do\n write(s[n]); \nEnd."}, {"source_code": "var s,nov: string;\n i,j: byte;\nbegin\n readln(s); i:=1;\n if s[1]='h' then begin nov:=nov+'http://'; inc(i,4); end\n else if s[1]='f' then begin nov:=nov+'ftp://'; inc(i,3); end;\n if pos('ru',s)=i then begin nov:=nov+'ru'; inc(i,2); end;\n while (copy(s,i,2)<>'ru') do\n begin\n nov:=nov+s[i];\n inc(i);\n end;\n nov:=nov+'.ru';\n inc(i,2);\n if i3) and ((i-1)<>4)then l:=i;\n end;\n for i:=1 to length(s) do\n begin\n if l-1=i then write('.');\n write(s[i]);\n if j=i then write('://');\n if (l=i) and(i3) and ((i-1)<>4)then l:=i;\n end;\n for i:=1 to length(s) do\n begin\n if l-1=i then write('.');\n write(s[i]);\n if j=i then write('://');\n if (l=i) and(i1) then else\n begin\n s2:='ru'; delete(s,1,2);\n end;\n s2:=s2+copy(s,1,pos('ru',s)-1);\n delete(s,1,pos('ru',s)+1);\n writeln(s1,'://',s2,'.ru/',s);\nend."}, {"source_code": "var\n\ta, i, j : longint;\n\ts : string;\nbegin\n//\treset(input, 'a.in');rewrite(output, 'a.out');\n\tread(s);\n\tif (s[1] = 'f') then a := 3\n\telse a := 4;\n\ti := a+1;\n\twhile (i < length(s)) and (s[i]+s[i+1] <> 'ru') do inc(i);\n\tfor j := 1 to a do write(s[j]);\n\twrite('://');\n\tfor j := a+1 to i-1 do write(s[j]);\n\twrite('.ru');\n\tif (i+1 < length(s)) then write('/');\n\tfor j := i+2 to length(s) do write(s[j]);\nend."}, {"source_code": "var s,s1,s2,ss:string;\na,b,c,i,j,k,n,m:longint;\nbegin\nreadln(s);\nif s[1]='h' then begin\nss:=copy(s,1,4);\nss:=ss+':'+'//';\ni:=5;\nwhile (s[i]<>'r') or (s[i+1] <>'u') do begin\n ss:=ss+s[i];\n inc(i);\nend;\ni:=i+2;\nss:=ss+'.ru';\nif (i<>length(s)-2) and (i<=length(S)) then\nbegin\nss:=ss+'/';\n\nwhile i<=length(S) do begin ss:=ss+s[i]; inc(I); end;\nend;\nend\nelse\nbegin\nss:=copy(s,1,3);\nss:=ss+':'+'//';\n i:=4;\nwhile (s[i]<>'r') and (s[i+1] <>'u') do begin\n ss:=ss+s[i];\n inc(i);\nend;\ni:=i+2;\nss:=ss+'.ru';\nif (i<>length(s)-2) and (i<=length(S)) then\nbegin\nss:=ss+'/';\n\nwhile i<=length(S) do begin ss:=ss+s[i]; inc(I); end;\nend;\nend;\n\n\nwriteln(SS);\nend.\n"}, {"source_code": "var s:string;\ni:integer;\nbegin\nreadln(s);\nif s[1]='h' then insert('://',s,5);\nif s[1]='f' then insert('://',s,4);\nfor i:=8 to length(s) do\nif (s[i+1]='r')and(s[i+2]='u') then begin insert('.',s,i+1);insert('/',s,i+4);break;end;\nwriteln(s);\nend."}, {"source_code": "var s,k4,k5,sn:string;\nk1,k2,i,k3,d:longint;\nbegin\nk1:=0;k2:=0;sn:='';\nreadlN(S);\nk1:=pos('http',s);\nk2:=pos('ftp',s);\nif k1=0 then begin write('ftp://');d:=3;end else\nif k2=0 then begin write('http://');d:=4;end else\nif k1k2 then begin write('ftp://');d:=3;end;\nk3:=pos('ru',s);\nk4:=copy(s,d+1,k3-d-1);\nk5:=copy(s,k3,2);\ndelete(s,1,k3+1);\n\nwrite(k4);write('.',k5,'/');\n write(S);\nend.\n\n"}, {"source_code": "var s:string;\n d:longint;\nbegin\n readln(s);\n if s[1]='h' then\n begin\n write('http://');\n delete(s,1,4);\n end\n else\n begin\n write('ftp://');\n delete(s,1,3);\n end;\n d:=pos('ru',s);\n write(copy(s,1,d-1),'.');\n delete(s,1,d+1);\n write('ru');\n if length(s)<>0 then\n writeln('/',s);\nend.\n"}, {"source_code": "var\n i,y,x,d:longint;\n s:ansistring;\nbegin\n readln(s);\n if s[1]='f' then begin\n write('ftp://');\n d:=4;\n end\n else begin\n write('http://');\n d:=5;\n end;\n x:=pos('p',S);\n y:=pos('ru',s);\n if y=d then begin\n write('ru');\n delete(s,y,2);\n y:=pos('ru',s);\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n end;\n for i:=x+1 to y-1 do\n begin\n write(s[i]);\n end;\n write('.ru');\n if y+15) and ((i-1)<>4)then l:=i;\n end;\n for i:=1 to length(s) do\n begin\n if l-1=i then write('.');\n write(s[i]);\n if j=i then write('://');\n if (l=i) and(ib then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function deg(a,pow:int64):int64; var s,t:int64;\nbegin\n if pow=0 then deg:=1 else if odd(pow) then deg:=(deg(a,pow-1)*a) mod modul else\n begin t:=deg(a,pow div 2); deg:=(t*t) mod modul; end;\n\nend;\n function kolcikl:int64; var s,i,j,k:longint;\nbegin s:=0;\n for i:=1 to n do for j:=i+1 to n do for k:=j+1 to n do\n if gr[i,j] and gr[j,k] and gr[k,i] then begin inc(s); end;\nkolcikl:=s;\nend;\n\n function prost(k:longint):boolean; var i,j,s:longint; t:double; fl:boolean;\nbegin\n t:=sqrt(k); fl:=true;\n s:=round(t)+1;\n { writeln(s,' ');\n } for i:=2 to s do if k mod i=0 then flag:=false;\n\n\nend;\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(ss);\n n:=length(ss);\n if ss[1]='f' then i1:=4 else i1:=5;\n for i:=1 to i1-1 do write(ss[i]); write('://');\n for i:=i1+1 to n-1 do if (ss[i]='r')and(ss[i+1]='u') then i2:=i;\n for i:=i1 to i2-1 do write(ss[i]);write('.'); write('ru'); write('/');\n for i:=i2+2 to n do write(ss[i]); \n\n\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var i,next,ppos:longint;\n s,ss:string;\n\nbegin\n\n readln(s);\n\n if pos('http',s)=1 then\n begin\n write('http://');\n next:=5;\n end\n else\n begin\n write('ftp://');\n next:=4;\n end;\n\n if pos('ru',s)=next then\n begin\n ss:=copy(s,next+2,length(s)+1-next-2);\n ppos:=pos('ru',ss);\n for i:=next to next+ppos do\n write(s[i]);\n write('.ru');\n if next+ppos+1+2<=length(s) then write('/');\n for i:=next+ppos+1+2 to length(s) do\n write(s[i]);\n end\n else begin\n for i:=next to pos('ru',s)-1 do\n write(s[i]);\n\n write('.ru');\n if pos('ru',s)+2'r') or (s[i+1] <>'u') or (i=5) do begin\n ss:=ss+s[i];\n inc(i);\nend;\ni:=i+2;\nss:=ss+'.ru';\nif (i<>length(s)-2) and (i<=length(S)) then\nbegin\nss:=ss+'/';\n\nwhile i<=length(S) do begin ss:=ss+s[i]; inc(I); end;\nend;\nend\nelse\nbegin\nss:=copy(s,1,3);\nss:=ss+':'+'//';\n i:=4;\nwhile (s[i]<>'r') and (s[i+1] <>'u') or (i=4) do begin\n ss:=ss+s[i];\n inc(i);\nend;\ni:=i+2;\nss:=ss+'.ru';\nif (i<>length(s)-2) and (i<=length(S)) then\nbegin\nss:=ss+'/';\n\nwhile i<=length(S) do begin ss:=ss+s[i]; inc(I); end;\nend;\nend;\n\n\nwriteln(SS);\nend.\n"}, {"source_code": "var\nn,i:longint;\ns:string;\nbegin\nread(s);\n if (s[1]='f') and (s[2]='t') and (s[3]='p') then insert('://',s,4);\n if (s[1]='h') and (s[2]='t') and (s[3]='t') and (s[4]='p') then insert('://',s,5);\n\n\n i:=1;\n while i<=length(s) do begin\n if (s[i]='r') and (s[i+1]='u') then begin insert('.',s,i); insert('/',s,i+3); break; end;\n inc(i);\n end;\n\n write(s);\n\n\n\nend."}, {"source_code": "var\n t,x,y,sax,say,sbx,sby,n,i,http,ftp,k:longint;\n s1,ans:ansistring;\nbegin\n // assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);\n readln(s1);\n http:=pos('http',s1);\n ftp:=pos('ftp',s1);\n if http=1 then begin\n ans:=ans+'http://';\n delete(s1,1,4);\n k:=pos('ru',s1);\n if k<>0 then begin\n ans:=ans+copy(s1,1,k-1);\n ans:=ans+'.ru';\n delete(s1,1,k+1);\n if length(s1)<>0 then ans:=ans+'/'+s1;\n end;\n end;\n if ftp=1 then begin\n ans:=ans+'ftp://';\n delete(s1,1,3);\n k:=pos('ru',s1);\n if k<>0 then begin\n ans:=ans+copy(s1,1,k-1);\n ans:=ans+'.ru';\n delete(s1,1,k+1);\n if length(s1)<>0 then ans:=ans+'/'+s1;\n end;\n end;\n writeln(ans);\nend.\n\n\n\n\n\n\n"}, {"source_code": "Var i,k,t:longint;\n s:string;\n Begin\n Readln(s);\n t:=0;\n if s[1]='h' then begin write('http://'); t:=t+1; k:=5; end else write('ftp://');\n if t=1 then\n begin\n for i:=5 to length(s) do\n if (s[i]='r') and (s[i+1]='u' ) then begin write('.ru'); k:=k+2; break; end\n else begin write(s[i]); k:=k+1; end;\n if k<=length(s) then write('/');\n for i:=k to length(s) do\n write(s[i]);\n exit;\n end;\n if t=0 then\n begin\n k:=4;\n for i:=4 to length(s) do\n if (s[i]='r') and (s[i+1]='u' ) then begin write('.ru'); k:=k+2; break; end\n else begin write(s[i]); k:=k+1; end; end;\n if k<=length(s) then write('/');\n for i:=k to length(s) do\n write(s[i]);\n exit;\n end.\n"}, {"source_code": "var i:longint;\n f:boolean;\n s,s1,s2:string;\nbegin\n readln(s);\n s1:='';\n f:=false;\n if (s[1]='h') then\n begin\n s1:=s1+'http://';\n delete(s,1,4);\n end\n else\n begin\n s1:=s1+'ftp://';\n delete(s,1,3);\n end;\n i:=1;\n while (i<=length(s)) do\n begin\n if (s[i]='r') and (s[i+1]='u') and (not f) then\n begin\n s2:=copy(s,1,i-1);\n s1:=s1+s2+'.ru/';\n s2:=copy(s,i+2,length(s)-i+1);\n s1:=s1+s2;\n break;\n end;\n inc(i);\n end;\n writeln(s1);\nend."}, {"source_code": "var s:string;\ni:integer;\nbegin\nreadln(s);\nif s[1]='h' then insert('://',s,5);\nif s[1]='f' then insert('://',s,4);\nfor i:=7 to length(s) do\nif (s[i+1]='r')and(s[i+2]='u') then begin insert('.',s,i+1);insert('/',s,i+4);break;end;\nwriteln(s);\nend."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ns,link:string;\ni:integer;\nbegin\n readln(s);\n if s[1]='f' then\n begin\n link:=Copy(s,1,3) + '://';\n for i:=5 to Length(s) do\n if Copy(s,i,2) = 'ru' then\n begin\n link:=link + copy(s,4,i-4) + '.ru/' + Copy(s,i+2,Length(s)-i-1);\n break;\n end;\n end\n else if s[1]='h' then\n begin\n link:=Copy(s,1,4) + '://';\n for i:=6 to Length(s) do\n if Copy(s,i,2) = 'ru' then\n begin\n link:=link + copy(s,5,i-5) + '.ru/' + Copy(s,i+2,Length(s)-i-1);\n break;\n end;\n end;\n\nWriteln(link);\nReadln;\nEND.\n\n"}, {"source_code": "var\n s,s1,s2,ss:string;\n i,j:longint;\nbegin\n readln(s);\n s1:='http';\n s2:='ftp';\n if pos(s1,s)=1 then begin ss:=s1+'://'; delete(s,1,4); end;\n if pos(s2,s)=1 then begin ss:=s2+'://'; delete(s,1,3); end;\n i:=pos('ru',s);\n if i=1 then begin ss:=ss+'ru'; delete(s,1,2); end;\n j:=pos('p',s)+1;\n s1:=copy(s,j,i-j);\n ss:=ss+s1+'.ru';\n if i+2<=length(s) then ss:=ss+'/'+copy(s,i+2,length(s)-i-1);\n writeln(ss);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nVar s,itog,l:string;i:LongInt;\nBegin\n readln(s);\n if (pos('http',s)0)\n then begin\n Delete(s,1,4);\n itog:='http://';\n end\n else begin\n Delete(s,1,3);\n itog:='ftp://';\n end;\n for i:=Length(s)-1 downto 1 do\n begin\n if (s[i]='r')and(s[i+1]='u')\n then begin\n l:=Copy(s,1,i-1);\n itog:=itog+l+'.ru';\n Delete(s,1,i+1);\n if s<>''\n then itog:=itog+'/'+s;\n Writeln(itog);\n Halt(0);\n end;\n end;\nend."}, {"source_code": "var s:string;\n k:longint;\nbegin\n readln(s);\n if copy(s,1,3)= 'ftp' then\n begin\n delete(s,1,3);\n write('ftp://');\n end\n else\n begin\n delete(s,1,4);\n write('http://');\n end;\n k:=pos('ru',s);\n write(copy(s,1,k-1),'.','ru');\n if k+1<>length(s) then writeln('/',copy(s,k+2,length(s)-k-1));\nend."}, {"source_code": "Var s : string;\ni, k, l : integer;\na : array [1..100] of char;\nb : array [1..100] of char;\nm : boolean;\nBegin\nReadln (s);\nfor i:=1 to length (s) do\n begin\n a[i]:=s[i];\n end;\nk:=length (s);\nif a[1]='f' then\n begin\n b[1]:='f';\n b[2]:='t';\n b[3]:='p';\n b[4]:=':';\n b[5]:='/';\n b[6]:='/';\n for i:=7 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+3;\n end;\nIf a[1]='h' then\n begin\n b[1]:='h';\n b[2]:='t';\n b[3]:='t';\n b[4]:='p';\n b[5]:=':';\n b[6]:='/';\n b[7]:='/';\n for i:=8 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+4;\n end;\ni:=8;\nm:=(b[i]='r') and (b[i]='u');\nWhile m=false do\n begin\n inc (i);\n m:=(b[i]='r') and (b[i+1]='u');\n end;\nFor l:=k+1 downto i do\n begin\n b[l]:=b[l-1];\n end;\nb[i]:='.';\ninc(k);\ninc(i);\nif b[1]='h' then inc (i);\nIf i+1<>k then\n begin\n if b[1]='h' then i:=i-1;\n for l:=k+1 downto i+2 do\n begin\n b[l]:=b[l-1];\n end;\n b[i+2]:='/';\n inc (k);\n end;\nFor i:=1 to k do\n begin\n write (b[i]);\n end;\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\n\n var a:array[1..256] of string;\n x:string; i:integer;\nbegin\n readln(x);\nif copy(x,1,3)='ftp' then insert('://',x,4);\nif copy(x,1,4)='http' then insert('://',x,5);\nfor i:=5 to length(x) do\n begin\n a[i]:=copy(x,i,2);\n if a[i]='ru' then begin insert('.',x,i);\n\n insert('/',x,i+3); break; end;\n end; if copy(x,length(x),1)='/' then delete(x,length(x),1);\nwrite(x);\n \nend.\n "}, {"source_code": "Var s : string;\ni, k, l : integer;\na : array [1..100] of char;\nb : array [1..100] of char;\nm : boolean;\nBegin\nReadln (s);\nfor i:=1 to length (s) do\n begin\n a[i]:=s[i];\n end;\nk:=length (s);\nif a[1]='f' then\n begin\n b[1]:='f';\n b[2]:='t';\n b[3]:='p';\n b[4]:=':';\n b[5]:='/';\n b[6]:='/';\n for i:=7 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+3;\n end;\nIf a[1]='h' then\n begin\n b[1]:='h';\n b[2]:='t';\n b[3]:='t';\n b[4]:='p';\n b[5]:=':';\n b[6]:='/';\n b[7]:='/';\n for i:=8 to k+3 do\n begin\n b[i]:=a[i-3];\n end;\n k:=k+4;\n end;\ni:=8;\nm:=(b[i]='r') and (b[i]='u');\nWhile m=false do\n begin\n inc (i);\n m:=(b[i]='r') and (b[i+1]='u');\n end;\nFor l:=k+1 downto i do\n begin\n b[l]:=b[l-1];\n end;\nb[i]:='.';\ninc(k);\ninc(i);\nIf i+1<>k then\n begin\n for l:=k+1 downto i+2 do\n begin\n b[l]:=b[l-1];\n end;\n b[i+2]:='/';\n inc (k);\n end;\nFor i:=1 to k do\n begin\n write (b[i]);\n end;\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program n2;\n var x:integer; t,t1,t2,h,r:string;\nbegin\n readln(t);\n r:='';\n if t[1]='f' then begin delete(t,1,3); r:=r+'ftp://'; end\n else if t[1]='h' then begin delete(t,1,4); r:=r+'http://'; end;\n x:=pos('ru',t);\n t1:=t;\n t2:=t;\n delete(t2,1,x-1);\n delete(t1,x,length(t2));\n h:=t1;\n r:=r+h+'.ru';\n delete(t,1,x+1);\n if length(t)=0 then writeln(r)\n else\n begin\n r:=r+'/'+t;\n writeln(r);\n end;\nend.\n\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n str, new_str, prot, con: array[0..49] of Char;\n i, k, len: integer;\nprocedure Vvod;\nbegin\n Readln(str);\nend;\n\nprocedure Action;\nbegin\n\n len := 0;\n for i:=0 to Length(str) do if (str[i] <> #0) then Inc(len);\n\n if (str[0] = 'h') then\n begin\n StrCopy(prot, 'http://');\n for i := 4 to len do\n begin\n if (not ( (str[i] = 'r' ) and (str[i+1] = 'u') ))\n then new_str[i-4] := str[i] else begin k:=i+2; break; end;\n end;\n\n if (k <> len) then\n begin\n con[0] := '/';\n for i := k to len do\n begin\n con[i-k+1] := str[i];\n end;\n end;\n\n end else\n begin\n StrCopy(prot, 'ftp://');\n for i := 3 to len do\n begin\n if (not ( (str[i] = 'r' ) and (str[i+1] = 'u') ))\n then new_str[i-3] := str[i] else begin k:=i+2; break; end;\n end;\n\n if (k <> len) then\n begin\n con[0] := '/';\n for i := k to len do\n begin\n con[i-k+1] := str[i];\n end;\n end;\n\n end;\nend;\n\nprocedure Vyvod;\nbegin\n Writeln(prot, new_str, '.ru', con);\n Readln;\nend;\n\nbegin\n Vvod;\n Action;\n Vyvod;\nend."}, {"source_code": "var\na:string;\ni,j,g:longint;\nbegin\nreadln(a);\nif(a[1]='h') then\nbegin\ni:=5;\nwrite('http://');\nend\nelse\nbegin\nwrite('ftp://');\ni:=4;\nend;\ng:=8;\nwhile(g=8) do\nbegin\nwrite(a[i]);\ni:=i+1;\nif(a[i]='r') and (a[i+1]='u') then g:=7;\nend;\nwrite('.ru/');\ni:=i+2;\nfor j:=i to length(a) do write(a[j]);\nwriteln;\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar s, res: string;\nprocedure Nhap;\nvar fi: text;\nbegin\n assign(fi, finp); reset(fi);\n readln(fi, s);\n close(fi);\nend;\nprocedure Xuat;\nvar fo: text;\nbegin\n assign(fo, fout); rewrite(fo);\n writeln(fo, res);\n close(fo);\nend;\nprocedure reg1(var res: string);\nbegin\n if res[1]='h' then Insert('://', res, 5)\n else insert('://',res, 4);\nend;\nprocedure reg2(var res: string);\nvar i, j: integer;\nbegin\n i:=pos('ru', res);\n if (i<=8) then\n for j:=i+1 to length(res) do if (res[j]='r') and (res[j+1]='u') then break;\n i:=j;\n insert('.',res,i);\n if i+20)then continue;\n for j:=1 to n do kol[j]:=kol2[j];\n for j:=1 to n do used[j]:=false;\n sum:=0;\n used[i]:=true;\n last:=i;\n for j:=1 to n do \n if (d[i][j]=1)then dec(kol[j]);\n for j:=1 to n-1 do begin\n min:=inf;\n nom:=0;\n for x:=1 to n do \n if (not used[x])and((a[x]-a[last]+9)mod 3x) or (used[i]) then continue;\n cnt:=0;\n for j:=1 to n do if (g[i,j]=1) and (not used[j]) then inc(cnt);\n if (cnt<>0) then continue;\n inc(res);\n used[i]:=true;\n end;\n until (prev=res);\n ready:=true;\n for i:=1 to n do ready:=ready and used[i];\n if (ready) then begin check:=res; exit; end;\n if (x=1) then next:=2;\n if (x=2) then next:=3;\n if (x=3) then next:=1;\n res:=res+check(next)+1;\n check:=res;\nend;\n\nbegin\n read(n);\n for i:=1 to n do read(comp[i]);\n for i:=1 to n do\n begin\n read(k);\n for j:=1 to k do begin read(x); g[i,x]:=1; end;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do\n begin\n fillchar(used,sizeof(used),false);\n ans:=min(ans,check(i));\n end;\n writeln(ans);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp= '';\n base= 250;\n\nvar fi,fo : text;\n n,kq,ans : longint;\n a,head : array[1..base] of longint;\n c : array[1..base,1..base] of boolean;\n free : array[1..base] of longint;\n check : array[1..base] of boolean;\n\nprocedure Input;\nvar i,x,j : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,n);\n for i:= 1 to n do read(fi,a[i]);\n for i:= 1 to n do\n begin\n read(fi,head[i]);\n for j:= 1 to head[i] do\n begin\n read(fi,x);\n c[i,x] := true;\n end;\n end;\nend;\n\nprocedure dfs(u : longint);\nvar com,v,i : longint;\nbegin\n com := a[u];\n for v:= 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n dfs(v);\n end;\n com := a[u] + 1;\n if com > 3 then com := 1;\n for v:= 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n inc(kq);\n dfs(v);\n end;\n com := 6 - com - a[u];\n for v := 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n kq := kq + 2;\n dfs(v);\n end;\nend;\n\nprocedure Solve;\nvar i,j : longint;\nbegin\n ans := high(longint);\n for i:= 1 to n do\n if head[i] = 0 then\n begin\n for j:= 1 to n do check[j] := false;\n for j:= 1 to n do\n begin\n free[j] := head[j];\n if c[j,i] then dec(free[j]);\n end;\n check[i] := true;\n kq := n;\n dfs(i);\n if kq < ans then ans := kq;\n end;\n writeln(fo,ans);\nend;\n\nprocedure Output;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n Input;\n Solve;\n Output;\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar n,i,j,k,l,m,max,s,k1,k2,q,t,xxx:integer;\n used,used2: array [1..200] of boolean;\n x: array [1..200] of integer;\n a: array [1..200,1..200] of boolean;\n\nprocedure proc(y:integer);\nvar s,q,i,j:integer;\n begin\n q:=1;\n while q=1 do\n begin\n q:=0;\n for i:= 1 to n do\n if not used[i] then\n begin\n s:=0;\n for j:= 1 to n do if ((a[i,j]) and (not used2[j])) then s:=1;\n if s=0 then used[i]:=true;\n end;\n\n for i:= 1 to n do\n if x[i]=y then if ((used[i]) and (not used2[i])) then begin used2[i]:=true; q:=1; end;\n end;\n q:=0;\n for i:= 1 to n do if not used2[i] then q:=1;\n if q=1 then begin m:=m+1; proc(y mod 3 +1 );end;\n end;\n\nbegin\nread(n);\nfor i:= 1 to n do read(x[i]);\nfor i:= 1 to n do\n begin\n read(t);\n for j:= 1 to t do begin read(m); a[i,m]:=true; end;\n end;\nmax:=999999;\nfor xxx:= 1 to 3 do\n begin\n for i:= 1 to n do used[i]:=false;\n for i:= 1 to n do used2[i]:=false;\n m:=n;\n proc(xxx);\n if m0 do\n begin\n for i:= 1 to n do\n if (used[i]=false) and (a[i]=num) and (solve(i)) then\n begin\n used[i]:=true;\n time:=time+1;\n m:=m-1;\n end;\n h:=h+1;\n if h = n+1 then\n begin\n h:=0;\n num:=num+1;\n if num = 4 then num:=1;\n time:=time+1;\n end;\nend;\n if timeb then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function vyp(num:longint):boolean; var i,j,k:longint; fl:boolean;\n begin\n fl:=true;\n for i:=1 to kol[num] do if not sdelano[a[num,i]] then fl:=false;\n vyp:=fl;\n end;\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(n);\n for i:=1 to n do read(pl[i]);\n for i:=1 to n do\n begin read(kol[i]); for j:=1 to kol[i] do read(a[i,j]);\n\n end;\n { for i:=1 to n do writeln(vyp(i)); writeln;\n sdelano[5]:=true;\n for i:=1 to n do writeln(vyp(i)); writeln; }\n for st:=1 to 3 do\n begin start:=st; for i:=1 to n do sdelano[i]:=false;\n 2:\n 3: kk:=ot[st];\n for i:=1 to n do\n begin\n if vyp(i)and (pl[i]=start)and(not sdelano[i]) then begin inc(ot[st]); sdelano[i]:=true; end;\n\n end; if kk<>ot[st] then goto 3;\n if start<3 then inc(start) else start:=1;\n inc(ot[st]); flag:=false;\n for i:=1 to n do if not sdelano[i] then flag:=true;\n if flag then goto 2;\n end;\n { for i:=1 to 3 do writeln(ot[i]); }\n kk:=1000000000;\n for i:=1 to 3 do kk:=min(kk,ot[i]);\n writeln(kk-1);\n\n 1: close(output);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\nprogram ProbA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nconst\n MaxN = 200;\n\ntype\n int = longint;\n matrix = array[1..MaxN, 0..MaxN] of int;\n spisok = array[1..3, 0..MaxN] of int;\n\nvar\n i, j, x, k, n: int;\n a, b, p: matrix;\n sp: spisok;\n c: array[1..MaxN] of int;\n was, used: array[1..MaxN] of boolean;\n ans, cans: int;\n\n\nfunction rec(cur: int): int;\nvar\n i, j, x, z: int;\nbegin\n if sp[1, 0] + sp[2, 0] + sp[3, 0] = 0 then begin\n result := 0;\n exit;\n end;\n i := sp[cur, 0];\n result := 0;\n while i > 0 do begin\n x := sp[cur, sp[cur, 0]];\n was[x] := True;\n dec(sp[cur, 0]);\n inc(result);\n for j := 1 to n do begin\n if was[j] or used[j] then continue;\n if p[x, j] = 1 then\n dec(b[j, 0]);\n if (b[j, 0] = 0) then begin\n inc(sp[c[j], 0]);\n used[j] := True;\n sp[c[j], sp[c[j], 0]] := j;\n end;\n end;\n i := sp[cur, 0];\n end;\n z := rec(cur mod 3 + 1);\n if z > 0 then\n result := result + z + 1;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n);\n for i := 1 to n do\n read(c[i]);\n for i := 1 to n do begin\n read(k);\n for j := 1 to k do begin\n read(x);\n a[i, x] := 1;\n inc(a[i, 0]);\n p[x, i] := 1;\n end;\n end;\n ans := maxlongint;\n for j := 1 to 3 do begin\n fillchar(sp, sizeof(sp), 0);\n fillchar(was, sizeof(was), False);\n fillchar(used, sizeof(used), False);\n b := a;\n for i := 1 to n do\n if a[i, 0] = 0 then begin\n inc(sp[c[i], 0]);\n used[i] := True;\n sp[c[i], sp[c[i], 0]] := i;\n end;\n cans := rec(j);\n ans := min(cans, ans);\n end;\n writeln(ans);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "{$R+,O-}\n// Aimakov Yeldar, AtyrauKTL, 11 class\nUses Math, SysUtils;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tmx = maxint;\nvar\n\twas : array [0..201] of bool;\n\tres, ans, i, j, n, l, x, k, pos, sz, u : int;\n\tlen, len1, a, v, t, f : array [0..201*201] of int;\n\nprocedure add(xx, yy : int);\nbegin\n\tinc(l);\n\tv[l] := yy;\n\tt[l] := f[xx];\n\tf[xx] := l;\nend;\n\nbegin\n//\tassign(input, 'a.in'); reset(input);\n//\tassign(output, 'a.out'); rewrite(output);\n\tread(n); l := 0; res := mx;\n\tfor i := 1 to n do read(a[i]);\n\tfor i := 1 to n do begin\n\t\tread(len[i]);\n\t\tfor j := 1 to len[i] do begin\n\t\t\tread(x);\n\t\t\tadd(x, i);\n\t\tend;\n\tend;\n\tfor i := 1 to n do\n\t\tif (len[i] = 0) then begin\n\t\t\tlen1 := len; u := i;\n\t\t\tk := a[i]; sz := 0; ans := 0;\n\t\t\tfillchar(was, sizeof(was), false);\n\t\t\twhile (sz <> n) do begin\n\t\t\t\tif (not was[u]) then begin\n\t\t\t\t\tinc(sz);\n pos := f[u];\n\t\t\t\t\twas[u] := true;\n\t\t\t\t\twhile (pos > 0) do begin\n\t\t\t\t\t\tdec(len1[v[pos]]);\n\t\t\t\t\t\tpos := t[pos];\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\t\tfor j := 1 to n do\n\t\t\t\t\tif (len1[j] = 0) and (k = a[j]) and (not was[j]) then begin\n\t\t\t\t\t u := j;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tend;\n\t\t\t\tif (not was[u]) then continue;\n\t\t\t\tinc(k); inc(ans);\n\t\t\t\tif (k = 4) then k := 1;\n\t\t\tend;\n\t\t\tres := min(res, ans);\n\t\tend;\n\twriteln(res+n-1);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nconst dist:array[1..3,1..3] of integer=((0,1,2),(2,0,1),(1,2,0));\nvar\n used:Array[1..1000] of integer;\n k,c:array[1..1000] of integer;\n mas:array[1..500,1..500 ] of integer;\n v,timer,n,cand:int64;\n i,j,vertex:integer;\nfunction check(v:integer):boolean;\nvar bool:boolean;\n i : integer;\nbegin\n bool:=true;\n for i:=1 to k[v] do\n if used[mas[v,i]]<2 then bool:=false;\n check:=bool;\nend;\nfunction solve(v : integer) : uint64;\nvar timer : uint64;\nbegin\n fillchar(used,sizeof(used),0);\n used[v]:=2;\n timer := 0;\n for vertex:=1 to n-1 do\n begin\n cand := -1;\n for i:=1 to n do\n begin\n if (used[i]=0) and (check(i)) then\n used[i]:=1;\n if (used[i] = 1) then\n if (cand = -1) or (dist[c[v],c[i]]min Then Break;\n s:=s mod 3+1;\n End;\n If t N do\n begin\n\n g := 0;\n while (true) do\n begin\n for i := 1 to n do\n if (u[i] = 0) and (c[i] = curc) and (sc[i] = 0) then\n begin\n g := i;\n break;\n end;\n if g = 0 then\n begin\n inc(Cans);\n Curc := curc mod 3 + 1;\n end\n else\n break;\n end;\n\n begin\n u[g] := 1;\n for i := 1 to n do\n if a[i, g] = 1 then\n dec(sc[i]);\n inc(cdel);\n inc(cans);\n end;\n\n end;\n\n if Cans < minans then\n minans := cans;\n end;\n\n write(minans);\nend.\n\n"}, {"source_code": "var i,j,n,s,x,ans:longint;\n c,k,l:array[0..201] of longint;\n a:array[0..201,0..201] of longint;\n\nprocedure tt(x:longint);\nvar i,j,m:longint;\n ok:boolean;\n begin\n l:=k;\n m:=n;\n\n while m>0 do\n begin\n\n ok:=true;\n while ok do\n begin\n ok:=false;\n for i:=1 to n do\n if (c[i]=x) and\n (l[i]=0) then begin\n dec(m);\n inc(s);\n for j:=1 to n do\n if a[i,j]=1 then dec(l[j]);\n\n ok:=true;\n l[i]:=-1;\n end;\n end;\n\n if m=0 then break;\n\n inc(s);\n inc(x);\n if x=4 then x:=1;\n end;\n end;\n\n begin\n read(n);\n for i:=1 to n do\n read(c[i]);\n\n for i:=1 to n do\n begin\n read(k[i]);\n for j:=1 to k[i] do\n begin\n read(x);\n a[x,i]:=1;\n end;\n\n end;\n\n ans:=maxlongint;\n for i:=1 to 3 do\n begin\n s:=0;\n tt(i);\n if s0) do\n begin\n f:=false;\n\n while (f=False) do\n begin\n f:=True;\n for i:=1 to n do\n if (a[k][i]=1)and(b[i,0]=0) then \n begin\n a[k][i]:=0;\n for j:=1 to n do\n if b[j][i]=1 then dec(b[j][0]);\n f:=false;\n Dec(cnt);\n end;\n end;\n\n if cnt<>0 then inc(Result);\n\n inc(k);\n if k=4 then k:=1;\n end;\nend;\n\nvar ans:integer;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');reset(input);\n assign(output, 'output.txt');rewrite(output);\n {$ENDIF}\n readdata;\n ans:=1000000;\n ans:=min(ans,findway(1));\n ans:=min(ans,findway(2));\n ans:=min(ans,findway(3));\n writeln(ans);\nend.\n"}, {"source_code": "var j,n,i,res,st,t,ost,q:longint;\n comp,s:array[0..300] of longint;\n used:array[0..300] of boolean;\n any,flag:boolean;\n a:array[0..300,0..300] of longint;\n begin\n read(n);\n for i:=1 to n do\n read(comp[i]);\n\n for i:=1 to n do\n begin\n read(s[i]);\n for j:=1 to s[i] do\n read(a[i][j]);\n end;\n\n res:=maxlongint;\n\n for st:=1 to 3 do\n begin\n fillchar(used,sizeof(used),false);\n\n t:=st;\n ost:=n;\n q:=0;\n\n while ost>0 do\n begin\n while true do\n begin\n any:=false;\n for i:=1 to n do\n if (not used[i]) and (comp[i]=t) then\n begin\n flag:=true;\n for j:=1 to s[i] do\n if not used[a[i][j]] then\n begin\n flag:=false;\n break;\n end;\n if flag then\n begin\n used[i]:=true;\n ost:=ost-1;\n any:=true;\n end;\n end;\n if not any then break;\n end;\n\n t:=t mod 3+1;\n q:=q+1;\n end;\n\n if q-1n do\n begin\n repeat\n l:=0;\n for i:=1 to a[t] do\n begin\n nom:=dp[t,i];\n if not f[nom] then\n begin\n x:=0;\n for j:=1 to b[nom] do\n if not f[d[nom,j]] then x:=1;\n if x=0 then begin inc(k);inc(ans);f[nom]:=true;l:=1;end;\n end;\n end;\n until l=0 ;\n inc(t);\n if t=4 then t:=1;\n if ans<>0 then inc(ans);\n end;\n if rez>ans then rez:=ans;\n\n end;\n write(rez-1);\nend.\n"}, {"source_code": "program form;\nvar s: string;\ni,n,j,r,l: longint;\nkol,kol1,k,gen,ans,m,x,min: int64;\nco,count: array [1..3] of longint;\nd,di,c: array [1..200] of longint;\nf: array [1..200] of boolean;\na,b: array [1..200,1..200] of boolean;\nfi: boolean;\nbegin\n{assign (input, 'input.txt');\nreset (input);\nassign (output, 'output.txt');\nrewrite (output); }\nread (n);\nfor i:= 1 to n do\n begin read (c[i]); inc (count[c[i]]); end;\nfor i:= 1 to n do\n begin\n read (k);\n d[i]:= k;\n for l:= 1 to k do begin read (j); a[i,j]:= true; end;\n end;\nk:= 1;\nmin:= 1000000000;\nans:= -1;\ngen:= 0;\nfor i:= 1 to 3 do co[i]:= count[i];\nfor i:= 1 to n do\n for j:= 1 to n do b[i,j]:= a[i,j];\nfor i:= 1 to n do di[i]:= d[i];\nfor i:= 1 to n do f[i]:= false;\nwhile true do\nbegin\ninc (k);\nif gen = n then break;\ninc (ans);\nif k=4 then k:= 1;\nfi:= true;\nif count[k]<>0 then\nwhile fi=true do\nbegin\nfi:= false;\n for i:= 1 to n do\n if f[i]=false then\n if d[i]=0 then\n if c[i]=k then\n begin\n dec (count[k]);\n inc (gen);\n fi:= true;\n f[i]:= true;\n for j:= 1 to n do\n begin\n if a[j,i]=true then dec (d[j]);\n a[j,i]:= false;\n end;\n end;\nend;\nend;\nif ans0 then\nwhile fi=true do\nbegin\nfi:= false;\n for i:= 1 to n do\n if f[i]=false then\n if d[i]=0 then\n if c[i]=k then\n begin\n dec (count[k]);\n inc (gen);\n fi:= true;\n f[i]:= true;\n for j:= 1 to n do\n begin\n if a[j,i]=true then dec (d[j]);\n a[j,i]:= false;\n end;\n end;\nend;\nend;\nif ans0 then\nwhile fi=true do\nbegin\nfi:= false;\n for i:= 1 to n do\n if f[i]=false then\n if d[i]=0 then\n if c[i]=k then\n begin\n dec (count[k]);\n inc (gen);\n fi:= true;\n f[i]:= true;\n for j:= 1 to n do\n begin\n if a[j,i]=true then dec (d[j]);\n a[j,i]:= false;\n end;\n end;\nend;\nend;\nif ans 0)then continue;\n for j:=1 to n do kol[j]:=kol2[j];\n for j:=1 to n do used[j]:=false;\n sum:=0;\n used[i]:=true;\n last:=i;\n for j:=1 to n do \n if (d[i][j]=1)then dec(kol[j]);\n for j:=1 to n-1 do begin\n min:=inf;\n nom:=0;\n for x:=1 to n do \n if (not used[x])and((a[x]-a[last]+9)mod 30 do begin\n l:=0;r:=0;\n for a:=1 to n do if (pos[a]=j)and(not vis[a])and(ind[a]<=0)then begin\n inc(r);\n q[r]:=a;\n vis[a]:=true;\n end;\n while l<>r do begin\n inc(l);\n dec(m);\n a:=q[l];\n for b:=1 to n do if (x[a,b]) then begin\n dec(ind[b]);\n if (not vis[b])and(ind[b]<=0)and(pos[b]=j) then begin\n inc(r);\n q[r]:=b;\n vis[b]:=true;\n end;\n end;\n end;\n j:=j mod 3+1;\n if m>0 then inc(temp);\n end;\n if ans>temp then ans:=temp;\n end;\n writeln(ans+n);\nEND."}, {"source_code": "var n, i, time, j, x, s, min, p, k1, w: Longint;\n k, c: array [1..1000] of Longint;\n l, r: array [1..3] of Longint;\n q: array [1..3, 1..1000] of Longint;\n a: array [1..300, 1..300] of Boolean;\n\nBegin\n read(n);\n for i := 1 to n do\n read(c[i]);\n for i := 1 to n do begin\n read(k[i]);\n for j := 1 to k[i] do begin\n read(x);\n a[x, i] := true;\n end;\n end;\n min := 1000000;\n\n for w := 1 to 3 do begin\n time := 0;\n i := w;\n for j := 1 to 3 do begin\n l[j] := 1;\n r[j] := 0;\n end;\n for j := 1 to n do begin\n k1 := 0;\n for p := 1 to n do\n if a[p, j] = true then\n inc(k1);\n if k1 = 0 then begin\n inc(r[c[j]]);\n q[c[j], r[c[j]]] := j;\n end;\n k[j] := k1;\n end;\n while r[1] - l[1] + r[2] - l[2] + r[3] - l[3] > -3 do begin\n while l[i] <= r[i] do begin\n inc(time);\n for j := 1 to n do\n if a[q[i, l[i]], j] = true then begin\n dec(k[j]);\n if k[j] = 0 then begin\n inc(r[c[j]]);\n q[c[j], r[c[j]]] := j;\n end;\n end;\n inc(l[i]);\n end;\n inc(i);\n if i = 4 then\n i := 1;\n if time <> 0 then\n inc(time);\n end;\n if time <= min then\n min := time - 1;\n end;\n write(min);\nEnd.\n"}, {"source_code": "var\n stn,c:array[0..1000]of longint;\n f:array[0..1000]of boolean;\n st:array[0..1000,0..1000]of byte;\n ve,g,i,j,n,v,z,r,min,mini,min1,ans:longint;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output); }\n readln(n);\n for i:=1 to n do read(c[i]);\n readln;\n for i:=1 to n do\n begin\n read(stn[i]);\n if stn[i]=0 then mini:=i;\n for j:=1 to stn[i] do read(st[i,j]);\n readln;\n end;\n min1:=maxlongint;\n for i:=1 to 3 do\n begin\n v:=i;\n ans:=0;\n fillchar(f,sizeof(f),0);\n f[0]:=true;\n for ve:=1 to n do\n begin\n min:=10;\n for r:=1 to n do if f[r]=false then\n begin\n for z:=0 to stn[r] do\n if (f[st[r,z]]=true) then\n begin\n if z=stn[r] then\n begin\n if (v=c[r]) then g:=0;\n if (v=1)and(c[r]=2) then g:=1;\n if (v=1)and(c[r]=3) then g:=2;\n if (v=2)and(c[r]=1) then g:=2;\n if (v=2)and(c[r]=3) then g:=1;\n if (v=3)and(c[r]=1) then g:=1;\n if (v=3)and(c[r]=2) then g:=2;\n if g0 do\n begin\n read(x);\n dec(k);\n uedge[i][x]:=1;\n end;\n end;\n ans:=find(0);\n ans:=min(ans,find(1));\n ans:=min(ans,find(2));\n writeln(ans);\n end."}, {"source_code": "var a:array[1..200,1..200]of boolean;\n b,c:array[1..200]of boolean;\n x:array[1..200]of longint;\n tmin,i,f,n,p,t,k,l,num:longint;\nfunction prb:boolean;\nvar i:longint;\nbegin\n prb:=false;\n for i:=1 to n do\n if not(b[i]) then begin prb:=true;break;end;\nend;\nfunction prbp:boolean;\nvar i,f:longint;log:boolean;\nbegin\n prbp:=false;\n for i:=1 to n do\n begin\n log:=false;\n if (x[i]=p)and(not(b[i])) then\n begin\n for f:=1 to n do\n if (not(b[f]))and(a[i,f]) then begin log:=true;break;end;\n if not(log) then begin prbp:=true;num:=i;break;end;\n end;\n end;\nend;\nbegin\n readln(n);tmin:=99999999;\n for i:=1 to n do\n read(x[i]);\n for i:=1 to n do\n begin\n read(k);\n for f:=1 to k do\n begin\n read(l);\n a[i,l]:=true;\n end;\n end;\n p:=1;t:=0;\n while prb do\n begin\n while prbp do\n begin\n b[num]:=true;\n t:=t+1;\n end;\n inc(p);inc(t);\n if p=4 then p:=1;\n end;\n if t0) and (c[x,i]=1) then begin t:=t+1;tt(i);exit; end;\n\n for i:=1 to 3 do\n if s[i]>0 then begin t:=t+c[x,i];tt(i);exit;end;\n end;\n\n begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n begin\n read(b[i,0]);\n for j:=1 to b[i,0] do\n read(b[i,j]);\n end;\n\n c[1,2]:=1;\n c[1,3]:=2;\n c[2,1]:=2;\n c[2,3]:=1;\n c[3,1]:=1;\n c[3,2]:=2;\n\n ans:=maxlongint;\n for i:=1 to 3 do\n begin\n fillchar(v,sizeof(v),false);\n\n t:=0;\n tt(i);\n\n if t r[now] then begin\n inc(now);\n if now > 3 then\n now := now - 3;\n inc(sum);\n continue;\n end;\n sum := sum + 1;\n inc(mark);\n for j := 1 to k[q[now, l[now]]] do begin\n x1 := a[q[now, l[now]], j];\n dec(kol[x1]);\n if kol[x1] = 0 then begin\n inc(r[c[x1]]);\n q[c[x1], r[c[x1]]] := x1;\n end;\n end;\n if mark = n then\n break;\n inc(l[now]);\n if l[now] > r[now] then begin\n now := now + 1;\n inc(sum);\n end;\n if now > 3 then\n now := now - 3;\n end;\n if sum < min then\n min := sum;\n end;\n writeln(min);\nEnd.\n"}, {"source_code": "Program zad3;\n\nVar\n w: boolean;\n j, i, h, p, n, t: byte;\n a: array [1..200, 1..200] of byte;\n c, k: array [1..200] of byte;\n sum, res: word;\n s, q: set of byte;\n\nFunction dost (i: byte): boolean;\n var\n d: boolean;\n h: byte;\n begin\n d:=true;\n h:=1;\n while d and (h<=k[i]) do\n begin\n if a[i, h] in s\n then d:=false\n else inc (h);\n end;\n dost:=d;\n end;\n\nBegin\n {assign (input, 'input.txt');\n assign (output, 'output.txt');\n reset (input);\n rewrite (output);}\n readln (n);\n q:=[];\n for i:=1 to n do\n read (c[i]);\n readln;\n for i:=1 to n do\n begin\n include (q, i);\n read (k[i]);\n for j:=1 to k[i] do\n read (a[i, j]);\n readln;\n end;\n sum:=high(word);\n for i:=1 to 3 do\n begin\n res:=0;\n s:=q;\n t:=i;\n while s<>[] do\n begin\n repeat\n w:=false;\n for j:=1 to n do\n if (c[j]=t) and (j in s) and dost(j)\n\tthen\n\t begin\n\t inc (p);\n\t exclude (s, j);\n\t w:=true;\n\t end;\n until not w;\n inc (res, p+1);\n t:=t mod 3+1;\n p:=0;\n end;\n if (res-1)0 do\n begin\n read(x);\n dec(k);\n uedge[i][x]:=1;\n end;\n end;\n ans:=find(0);\n ans:=min(ans,find(1));\n ans:=min(ans,find(2));\n writeln(ans);\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar n,m,i,j,k,l,s,w,t,c,max,xx:integer;\n a: array [1..200,1..200] of boolean;\n stack,x: array [1..200] of integer;\n used,used2: array [1..200] of boolean;\nprocedure prop(xx:integer);\nvar q:integer;\nbegin\nq:=0;\n while q=0 do begin\n q:=1;\n for i:= 1 to n do\n begin\n k:=0;\n for j:= 1 to n do if ((a[i,j]) and (not used2[j])) then k:=1;\n if ((k=0) and (not used[i])) then used[i]:=true;\n end;\n\n for i:= 1 to n do\n if x[i]=xx then if ((used[i]) and (used2[i]=false)) then\n begin used2[i]:=true; q:=0; end;\n end;\n w:=0;\n for i:= 1 to n do if not used2[i] then w:=1;\n if w=1 then begin m:=m+1; prop(xx mod 3 +1); end;\nend;\n\n\nbegin\nread(n);\nfor i:= 1 to n do read(x[i]);\nfor i:= 1 to n do\n begin\n read(t);\n for j:= 1 to t do begin read(c); a[i,c]:=true; end;\n end;\n\nmax:=999999;\nfor xx:= 1 to 3 do\n begin\n for i:= 1 to n do used[i]:=false;\n for i:= 1 to n do used2[i]:=false;\n m:=n;\n prop(xx);\n if m l1 then\n if count > 0 then\n begin dec(f1); inc(kq); mm:=2; break; end\n else exit;\n dec(count);\n i := Q1[f1];\n free[i]:=1;\n xuly_may(i);\n end;\n 2: if f2 <=l2 then\n while true do\n Begin\n inc(f2);\n if f2 > l2 then\n if count > 0 then\n begin dec(f2); inc(kq); mm:=3; break; end\n else exit;\n dec(count);\n i := Q2[f2];\n free[i]:=1;\n xuly_may(i);\n end;\n 3: if f3 <= l3 then\n while true do\n Begin\n inc(f3);\n if f3 > l3 then\n if count > 0 then\n begin dec(f3); inc(kq); mm:=1; break; end\n else exit;\n dec(count);\n i := Q3[f3];\n free[i]:=1;\n xuly_may(i);\n end;\n end;\n until count=0;\nend;\n\nprocedure xuly;\nvar i:longint;\nbegin\n\n res:=maxlongint;\n for i:=1 to 3 do\n begin\n khoitao;\n tinhtoan(i);\n res:=min(res,kq);\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(f,fo); rewrite(f);\n write(f,res+N);\n close(f);\nend;\n\nBEGIN\n khoitao;\n doc;\n {sort;}\n xuly;\n ghi;\nEND.\n"}, {"source_code": "program z2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,a0: array[1..200,1..200] of longint;\n num: array[1..200] of longint;\n k,k0: array[1..200] of LongInt;\n n,i,j,c,p,q,hours,ans,comp: longint;\n f: Boolean;\n\nprocedure play;\nvar f: integer;\nbegin\nf:=0;\n for i:=1 to n do\n if (num[i]=comp) and (k[i]=0) then\n begin\n Inc(f);\n Dec(k[i]);\n for j:=1 to n do\n if a[j][i]=1 then begin dec(k[j]); a[j][i]:=0; end;\n end;\nif f>0 then begin hours:=hours+f; play; end;\nend;\n\nbegin\n//Assign(input,'input.txt'); Reset(input);\n//assign(output,'output.txt'); Rewrite(output);\n\nfor i:=1 to n do\n for j:=1 to n do\n a[i][j]:=0;\n\n\nReadln(n);\nfor i:=1 to n do\n read(num[i]);\nfor i:=1 to n do\nbegin\n read(k[i]);\n for j:=1 to k[i] do\n begin\n read(q);\n a[i][q]:=1;\n end;\nend;\n\nans:=2147000000; k0:=k; a0:=a;\nfor c:=1 to 3 do\nbegin\n comp:=c;\n hours:=0;\n f:=true;\n while f do\n begin\n play;\n f:=false;\n for i:=1 to n do\n if k[i]<>-1 then f:=True;\n comp:=comp mod 3+1; if f then inc(hours);\n end;\n k:=k0; a:=a0;\n if hoursb then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function vyp(num:longint):boolean; var i,j,k:longint; fl:boolean;\n begin\n fl:=true;\n for i:=1 to kol[num] do if not sdelano[a[num,i]] then fl:=false;\n vyp:=fl;\n end;\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(n);\n for i:=1 to n do read(pl[i]);\n for i:=1 to n do\n begin read(kol[i]); for j:=1 to kol[i] do read(a[i,j]);\n\n end;\n { for i:=1 to n do writeln(vyp(i)); writeln;\n sdelano[5]:=true;\n for i:=1 to n do writeln(vyp(i)); writeln; }\n for st:=1 to 3 do\n begin start:=st; for i:=1 to n do sdelano[i]:=false;\n 2:\n 3: kk:=ot[st];\n for i:=1 to n do\n begin\n if vyp(i)and (pl[i]=start)and(not sdelano[i]) then begin inc(ot[st]); sdelano[i]:=true; end;\n\n end; if kk<>ot[st] then goto 3;\n if start<3 then inc(start) else start:=1;\n inc(ot[st]); flag:=false;\n for i:=1 to n do if not sdelano[i] then flag:=true;\n if flag then goto 2;\n end;\n { for i:=1 to 3 do writeln(ot[i]); }\n kk:=1000000000;\n for i:=1 to 3 do kk:=min(kk,ot[i]);\n writeln(kk-1);\n\n 1: close(output);\nend.\n"}, {"source_code": "program aa;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n,sum1,min,sum,m,k,i,it,ot,p,j:longint;\n f:array[1..200000]of boolean;\n a:array[1..2000,1..2000]of longint;\n col,sch:array[1..10000]of longint;\n o,g:boolean;\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt'); }\n read(n);\n min := maxlongint;\n for i:=1 to n do\n read(col[i]);\n for i:=1 to n do\n begin\n read(sch[i]);\n for j:=1 to sch[i] do\n read(a[i][j]);\n end;\n for p:=1 to 3 do\n begin\n for i:=1 to n do\n begin\n f[i] := false;\n end;\n it:=0;\n i := p;\n ot := 0;\n while (it < n) do\n begin\n o:=false;\n for j:=1 to n do\n begin\n if f[j] = false then\n begin\n g:=false;\n for k:=1 to sch[j] do\n if f[a[j][k]] = false then\n g := true;\n if (g = false)and(col[j] = i) then\n begin\n f[j] := true;\n o:=true;\n inc(ot);\n inc(it);\n if (it = n) then\n begin\n if ot < min then\n min :=ot;\n end;\n end;\n end;\n end;\n if (o = false) then\n begin\n inc(ot);\n if (i = 3) then\n i:=1 else\n inc(i);\n end;\n end;\n end;\n write (min);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nconst dist:array[1..3,1..3] of integer=((0,1,2),(2,0,1),(1,2,0));\nvar\n used:Array[1..1000] of integer;\n k,c:array[1..1000] of integer;\n mas:array[1..500,1..500 ] of integer;\n v,timer,n,cand:int64;\n i,j,vertex:integer;\nfunction check(v:integer):boolean;\nvar bool:boolean;\n i : integer;\nbegin\n bool:=true;\n for i:=1 to k[v] do\n if used[mas[v,i]]<2 then bool:=false;\n check:=bool;\nend;\nfunction solve(v : integer) : uint64;\nvar timer : uint64;\nbegin\n fillchar(used,sizeof(used),0);\n used[v]:=2;\n timer := 0;\n for vertex:=1 to n-1 do\n begin\n cand := -1;\n for i:=1 to n do\n begin\n if (used[i]=0) and (check(i)) then\n used[i]:=1;\n if (used[i] = 1) then\n if (cand = -1) or (dist[c[v],c[i]]0 then begin\n deg:=degg;\n count:=countt;\n cv:=n;\n anss:=0;\n st:=i;\n repeat\n while count[st]>0 do begin\n for j:=1 to n do\n if (id[j]=st) and (deg[j]=0) then begin\n dec(cv);\n deg[j]:=-1;\n dec(count[st]);\n for v:=1 to n do\n if a[j,v] then begin\n dec(deg[v]);\n if deg[v]=0 then inc(count[id[v]]);\n end;\n anss:=anss+1;\n end;\n end;\n if cv=0 then break;\n st:=st+1;\n anss:=anss+1;\n if st=4 then st:=1;\n until cv=0;\n if anss ans then\n answer := ans;\n end;\n writeln(answer);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a,a1:Array[1..200,1..200] of Boolean;\n c,c1:Array[1..3,1..200] of Boolean;\n b,b1:Array[1..200] of Integer;\n l:Array[1..200] of Boolean;\n n,i,r,k,j,min,s,t,f,i1,j1:Integer;\nBegin\n Read(n);\n For i:=1 To n Do Begin\n Read(r);\n c[r,i]:=true;\n End;\n For i:=1 To n Do Begin\n Read(k);\n b[i]:=k;\n For j:=1 To k Do Begin\n Read(r);\n a[i,r]:=true;\n End;\n End;\n min:=High(min);\n For i:=1 To 3 Do Begin\n t:=0;\n s:=i;\n For i1:=1 To n Do\n For j1:=1 To n Do a1[i1,j1]:=a[i1,j1];\n FOr i1:=1 To n Do l[i1]:=false;\n For i1:=1 To n Do b1[i1]:=b[i1];\n For i1:=1 To 3 Do\n For j1:=1 To n Do c1[i1,j1]:=c[i1,j1];\n While True Do Begin\n For j1:=1 To n Do\n For j:=1 To n Do\n If (b1[j]=0) and (c1[s,j]=true) and (not(l[j])) Then Begin\n t:=t+1;\n l[j]:=true;\n For r:=1 To n Do\n If a1[r,j]=true Then Begin\n b1[r]:=b1[r]-1;\n a1[r,j]:=false;\n End;\n End;\n f:=0;\n For j:=1 To n Do\n If not (l[j]) Then Begin\n f:=1;\n Break;\n End;\n If f=0 Then Break;\n t:=t+1;\n If t>min Then Break;\n s:=s mod 3+1;\n End;\n If t 3 then\n cur := 1;\n Inc(cans);\n end;\n if ans > cans then\n ans := cans;\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n);\n for i := 1 to n do\n read(num[i]);\n for i := 1 to n do\n begin\n read(cnt[i]);\n for j := 1 to cnt[i] do\n read(a[i, j]);\n end;\n ans := maxlongint;\n cnt2 := cnt;\n for i := 1 to 3 do\n begin\n FillChar(used, sizeof(used), 0);\n game(i);\n cnt := cnt2;\n end;\n Writeln(ans);\nend.\n"}, {"source_code": "VAR\n a,b,i,j,n,m:longint;\n x:array[0..200,0..200]of boolean;\n d,ind,q,pos:array[0..200]of longint;\n vis:array[0..200]of boolean;\n ans,temp:int64;\n l,r:longint;\n\nBEGIN\n read(n);\n for i:=1 to n do read(pos[i]);\n for i:=1 to n do begin\n read(a);\n for j:=1 to a do begin\n read(b);\n x[b,i]:=true;\n inc(d[i]);\n end;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do begin\n j:=i;m:=n;temp:=0;\n fillchar(vis,sizeof(vis),false);\n for a:=1 to n do ind[a]:=d[a];\n while m>0 do begin\n l:=0;r:=0;\n for a:=1 to n do if (pos[a]=j)and(not vis[a])and(ind[a]<=0)then begin\n inc(r);\n q[r]:=a;\n vis[a]:=true;\n end;\n while l<>r do begin\n inc(l);\n dec(m);\n a:=q[l];\n for b:=1 to n do if (x[a,b]) then begin\n dec(ind[b]);\n if (not vis[b])and(ind[b]<=0)and(pos[b]=j) then begin\n inc(r);\n q[r]:=b;\n vis[b]:=true;\n end;\n end;\n end;\n j:=j mod 3+1;\n if m>0 then inc(temp);\n end;\n if ans>temp then ans:=temp;\n end;\n writeln(ans+n);\nEND."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n Math,\n SysUtils;\n\nvar\n g : array [0..200, 0..200] of boolean;\n now : array [0..200] of boolean;\n k, m, how, t : array[0..200] of longint;\n table : array [1..3, 0..200] of longint;\n ok, cur, n, i, j, x, ans : longint;\n\nprocedure go(i : longint);\nvar\n flag : boolean;\n j, l : longint;\nbegin\n flag := true;\n while flag do\n begin\n flag := false;\n for j := 1 to how[i] do\n begin\n if (k[table[i][j]] = 0) and not(now[table[i][j]]) then\n begin\n flag := true;\n inc(ok);\n inc(cur);\n now[table[i][j]] := true;\n for l := 1 to n do\n begin\n if g[l][table[i][j]] then\n dec(k[l]);\n end;\n end;\n end;\n end;\n\n if ok = n then\n exit;\n\n inc(cur); \n go((i mod 3) + 1);\n \nend;\n\nbegin\n {$ifndef online_judge}\n\tassign(input,'c.in'); reset(input);\n\tassign(output,'c.out'); rewrite(output);\n\t{$endif}\n\n\treadln(n);\n\n for i := 1 to n do\n read(t[i]);\n\n for i := 1 to 3 do\n for j := 1 to n do\n begin\n if t[j] = i then\n begin\n inc(how[i]);\n table[i][how[i]] := j;\n end;\n end;\n\n for i := 1 to n do\n begin\n read(m[i]);\n k[i] := m[i];\n for j := 1 to m[i] do\n begin\n read(x);\n g[i][x] := true;\n end;\n end;\n\n for i := 1 to n do\n begin\n k[i] := m[i];\n now[i] := false;\n end;\n ok := 0;\n\n cur := 0;\n go(1);\n\n ans := cur;\n\n\n for i := 1 to n do\n begin\n k[i] := m[i];\n now[i] := false;\n end;\n ok := 0;\n cur := 0;\n go(2);\n if cur < ans then\n ans := cur;\n\n\n for i := 1 to n do\n begin\n k[i] := m[i];\n now[i] := false;\n end;\n ok := 0;\n cur := 0;\n go(3);\n if cur < ans then\n ans := cur;\n\n\n writeln(ans);\n\t{$ifndef online_judge}\n\tclose(input); close(output);\n\t{$endif}\nend.\n\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 16000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\nmaxn = 222;\ninf = round(1e9);\nvar\nn,i,j,x,k : integer;\nans,all,cur : longint;\nc : array [1..3,0..maxn] of integer;\ncc : array [1..maxn] of integer;\nneed : array [1..maxn,0..maxn] of integer;\nf : array [1..maxn] of boolean;\n\nfunction can (x : integer) : boolean;\nvar\ni : integer;\nbegin\n for i:=1 to need [x,0] do\n if not f [need [x,i]] then\n begin\n can:=false;\n exit;\n end;\n can:=true;\nend;\n\nprocedure rec (x : integer);\nvar\ni : integer;\nbegin\n for i:=1 to c [x,0] do\n if can (c [x,i]) and not f [c [x,i]] then\n begin\n inc (cur);\n inc (all);\n f [c [x,i]]:=true;\n rec (x);\n end;\n if all=n then exit;\n case x of\n 1 : begin inc (cur); rec (2); end;\n 2 : begin inc (cur); rec (3); end;\n 3 : begin inc (cur); rec (1); end;\n end;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n fillchar (c,sizeof(c),0);\n readln (n);\n for i:=1 to n do\n begin\n read (x);\n inc (c [x,0]);\n c [x,c [x,0]]:=i;\n cc [i]:=x;\n end;\n readln;\n for i:=1 to n do\n begin\n read (k);\n need [i,0]:=k;\n for j:=1 to k do\n begin\n read (x);\n need [i,j]:=x;\n end;\n readln;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do\n begin\n fillchar (f,sizeof(f),false);\n all:=0;\n cur:=0;\n rec (i);\n if cur0 then inc(tmp) else break;\n now:=next[now];\n end;\n exit(tmp);\n end;\nbegin\n //assign(input,'a.in');reset(input);\n fillchar(map,sizeof(map),0);fillchar(a,sizeof(a),0);fillchar(d,sizeof(d),0);\n readln(n);\n for i:=1 to n do read(b[i]);readln;\n for i:=1 to n do begin\n read(d[i]);\n if d[i]=0 then begin\n inc(a[b[i],0]);a[b[i],a[b[i],0]]:=i;\n end;\n for j:=1 to d[i] do begin\n read(t);inc(map[t,0]);map[t,map[t,0]]:=i;\n end;\n readln;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do\n if a[i,0]>0 then ans:=min(ans,work(i));\n writeln(ans);\nend.\n"}, {"source_code": "var l,ans,v,min,q,start,w,n,i,j:longint;\n c:array[1..200] of longint;\n d:array[1..200] of boolean;\n b,k:array[1..200] of longint;\n a:array[1..200,1..200] of longint;\n begin\n read(n);\n min:=maxlongint;\n for i:=1 to n do\n read(c[i]);\n for i:=1 to n do\n begin\n read(k[i]);\n for j:=1 to k[i] do\n read(a[i,j]);\n b[i]:=k[i];\n end;\n for start:=1 to 3 do\n begin\n l:=0;\n ans:=-1;\n v:=start;\n for i:=1 to n do\n begin\n d[i]:=false;\n b[i]:=k[i];\n end;\n while l0 do\n begin\n v:=ke[i];\n for j:=1 to n do if g[v][j] then\n begin\n dec(deg[j]);\n if deg[j]=0 then add(c[j],j);\n end;\n i:=next[i];\n end;\n if (head[1]=0)and(head[2]=0)and(head[3]=0) then exit(dem);\n if head[vt]=0 then\n begin\n inc(dem);\n vt:=vt+1;\n if vt=4 then vt:=1;\n end;\n until false;\nend;\nprocedure xuly;\nvar i,j,u,v:longint;\nbegin\n res:=maxlongint;\n for i:=1 to 3 do\n res:=min(res,check(i));\n writeln(fo,res+n);\nend;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n nhap;\n xuly;\n close(fi);\n close(fo);\nend.\n"}, {"source_code": "VAR\n a, b, c, i, j, j1, N, No, t, Kol, flag, time: LONGINT;\n Mas, M, k: ARRAY[0..200000] OF LONGINT;\n Massiv: ARRAY[0..200,0..200] OF LONGINT;\nBEGIN\n READLN(N);\n FOR i := 1 TO N DO\n READ(Mas[i]);\n FOR j := 1 TO N DO\n BEGIN\n READ(k[j]);\n FOR i := 1 TO k[j] DO\n READ(Massiv[j,i]);\n READLN;\n END;\n time := 20000000;\n FOR i := 1 TO 3 DO\n BEGIN\n Kol := 0;\n No := i;\n t := 0;\n FOR j := 1 TO N DO\n M[j] := Mas[j];\n WHILE Kol-1\n THEN\n a := 1;\n IF (a=0)\n THEN\n BEGIN\n flag := 1;\n M[j] := -1;\n Kol := Kol+1;\n END;\n END;\n IF (flag<>1)\n THEN\n BEGIN\n No := (No MOD 3)+1;\n t := t+1;\n END;\n END;\n IF t 0 then\n ok := false;\n Inc(cur);\n if cur > 3 then\n cur := 1;\n Inc(cans);\n end;\n if ans > cans then\n ans := cans;\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n);\n for i := 1 to n do\n read(num[i]);\n for i := 1 to n do\n begin\n read(cnt[i]);\n for j := 1 to cnt[i] do\n read(a[i, j]);\n end;\n ans := maxlongint;\n cnt2 := cnt;\n for i := 1 to 3 do\n begin\n game(i);\n cnt := cnt2;\n end;\n Writeln(ans);\nend.\n"}, {"source_code": "var a,count:array[1..200]of longint;\n map:array[1..200,1..200]of boolean;\n used:array[1..200]of boolean;\n n,i,j,k,x,where,ans,finish:longint;\n flag:boolean;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n fillchar(map,sizeof(map),false);\n for i:=1 to n do\n begin\n read(k);\n count[i]:=k;\n for j:=1 to k do\n begin\n read(x);\n map[x,i]:=true;\n end;\n end;\n fillchar((used),sizeof(used),false);\n where:=0;\n for i:=1 to n do\n if count[i]=0 then begin where:=a[i];break;end;\n finish:=0;\n ans:=n;\n while finishn do\n begin\n repeat\n l:=0;\n for i:=1 to a[t] do\n begin\n nom:=dp[t,i];\n if not f[nom] then\n begin\n x:=0;\n for j:=1 to b[nom] do\n if not f[d[nom,j]] then x:=1;\n if x=0 then begin inc(k);inc(ans);f[nom]:=true;l:=1;end;\n end;\n end;\n until l=0 ;\n inc(t);\n if t=4 then t:=1;\n if ans<>0 then inc(ans);\n end;\n write(ans-1);\nend.\n"}, {"source_code": "VAR\n a,b,i,j,n,m:longint;\n x:array[0..200,0..200]of longint;\n pos,num,ind,d:array[0..200]of longint;\n l,r:longint;\n q:array[0..1000]of longint;\n vis:array[0..200]of boolean;\n temp,ans:longint;\n\nBEGIN\n read(n);\n for i:=1 to n do read(pos[i]);\n for i:=1 to n do begin\n read(a);\n for j:=1 to a do begin\n read(b);\n inc(d[b]);\n inc(num[i]);\n x[i,num[i]]:=b;\n end;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do begin\n fillchar(vis,sizeof(vis),false);\n for a:=1 to n do ind[a]:=d[a];\n j:=i;m:=n;temp:=0;\n while m>0 do begin\n l:=0;r:=0;\n for a:=1 to n do if (pos[a]=j)and(ind[a]<=0)and(not vis[a]) then begin\n inc(r);\n q[r]:=a;\n vis[a]:=true;\n end;\n while l<>r do begin\n inc(l);\n dec(m);\n inc(temp);\n a:=q[l];\n for b:=1 to num[a] do begin\n dec(ind[x[a,b]]);\n if (ind[x[a,b]]<=0)and(not vis[x[a,b]])and(pos[x[a,b]]=j) then begin\n vis[x[a,b]]:=true;\n inc(r);\n q[r]:=x[a,b];\n end;\n end;\n end;\n if m>0 then begin\n j:=j mod 3 +1;\n inc(temp);\n end;\n end;\n if ans>temp then ans:=temp;\n end;\n writeln(ans);\nEND."}, {"source_code": "VAR\n a,b,i,j,n,m:longint;\n x:array[0..200,0..200]of boolean;\n d,ind,q,pos:array[0..200]of longint;\n vis:array[0..200]of boolean;\n ans,temp:int64;\n l,r:longint;\n\nBEGIN\n read(n);\n for i:=1 to n do read(pos[i]);\n for i:=1 to n do begin\n read(a);\n for j:=1 to a do begin\n read(b);\n x[i,b]:=true;\n inc(d[b]);\n end;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do begin\n j:=i;m:=n;\n fillchar(vis,sizeof(vis),false);\n for a:=1 to n do ind[a]:=d[a];\n while m>0 do begin\n l:=0;r:=0;\n for a:=1 to n do if (pos[a]=j)and(not vis[a])and(ind[a]<=0)then begin\n inc(r);\n q[r]:=a;\n vis[a]:=true;\n end;\n while l<>r do begin\n inc(l);\n dec(m);\n a:=q[l];\n for b:=1 to n do if (x[a,b]) then begin\n dec(ind[b]);\n if (not vis[b])and(ind[b]<=0)and(pos[b]=j) then begin\n inc(r);\n q[r]:=b;\n vis[b]:=true;\n end;\n end;\n end;\n j:=j mod 3+1;\n if m>0 then inc(temp);\n end;\n if ans>temp then ans:=temp;\n end;\n writeln(ans+n);\nEND."}, {"source_code": "VAR\n a,b,i,j,n,m:longint;\n x:array[0..200,0..200]of longint;\n pos,num,ind,d:array[0..200]of longint;\n l,r:longint;\n q:array[0..1000]of longint;\n vis:array[0..200]of boolean;\n temp,ans:longint;\n\nBEGIN\n read(n);\n for i:=1 to n do read(pos[i]);\n for i:=1 to n do begin\n read(a);\n for j:=1 to a do begin\n read(b);\n inc(d[b]);\n inc(num[i]);\n x[i,num[i]]:=b;\n end;\n end;\n ans:=maxlongint;\n for i:=1 to 3 do begin\n fillchar(vis,sizeof(vis),false);\n for a:=1 to n do ind[a]:=d[a];\n j:=i;m:=n;temp:=0;\n while m>0 do begin\n l:=0;r:=0;\n for a:=1 to n do if (pos[a]=j)and(ind[a]<=0)and(not vis[a]) then begin\n inc(r);\n q[r]:=a;\n vis[a]:=true;\n end;\n while l<>r do begin\n inc(l);\n dec(m);\n a:=q[l];\n for b:=1 to num[a] do begin\n dec(ind[x[a,b]]);\n if (ind[x[a,b]]<=0)and(not vis[x[a,b]])and(pos[x[a,b]]=j) then begin\n vis[x[a,b]]:=true;\n inc(r);\n q[r]:=x[a,b];\n end;\n end;\n end;\n if m>0 then begin\n j:=j mod 3 +1;\n inc(temp);\n end;\n end;\n if ans>temp then ans:=temp;\n end;\n writeln(ans+n);\nEND."}, {"source_code": "var n, i, time, j, x, s: Longint;\n k, c: array [1..1000] of Longint;\n l, r: array [1..3] of Longint;\n q: array [1..3, 1..100] of Longint;\n a: array [1..1000, 1..1000] of Boolean;\n\nBegin\n read(n);\n for i := 1 to n do\n read(c[i]);\n for i := 1 to n do begin\n read(k[i]);\n for j := 1 to k[i] do begin\n read(x);\n a[x, i] := true;\n end;\n if k[i] = 0 then begin\n inc(r[c[i]]);\n q[c[i], r[c[i]]] := i;\n end;\n end;\n time := 0;\n i := 1;\n l[1] := 1;\n l[2] := 1;\n l[3] := 1;\n while r[1] - l[1] + r[2] - l[2] + r[3] - l[3] > -3 do begin\n while l[i] <= r[i] do begin\n inc(time);\n for j := 1 to n do\n if a[q[i, l[i]], j] = true then begin\n dec(k[j]);\n if k[j] = 0 then begin\n inc(r[c[j]]);\n q[c[j], r[c[j]]] := j;\n end;\n end;\n inc(l[i]);\n end;\n inc(i);\n if i = 4 then\n i := 1;\n if time <> 0 then\n inc(time);\n end;\n write(time - 1);\nEnd."}, {"source_code": "var was,a:array[1..300] of longint;\n edge:array[1..300,1..300] of longint;\n ans,i,j,n,x,k:longint;\n\n function min(a,b:longint):longint;\n begin\n if a0 do\n begin\n read(x);\n dec(k);\n edge[i][x]:=1;\n end;\n end;\n ans:=find(0);\n ans:=min(ans,find(1));\n ans:=min(ans,find(2));\n writeln(ans);\n end."}, {"source_code": "var a:array[0..9]of longint;\n n,i,k,s:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(k);\n inc(a[k]);\n s:=s+k;\n end;\n if a[0]=0 then begin writeln(-1);halt(0);end;\n if s mod 3=1 then\n begin\n if a[1]>0 then begin dec(a[1]);s:=s-1;end else\n if a[4]>0 then begin dec(a[4]);s:=s-4;end else\n if a[7]>0 then begin dec(a[7]);s:=s-7;end else\n if (a[2]>1)and(a[2]>1) then begin dec(a[2]);dec(a[2]);s:=s-4;end else\n if (a[2]>0)and(a[5]>0) then begin dec(a[2]);dec(a[5]);s:=s-7;end else\n if (a[5]>1)and(a[5]>1) then begin dec(a[5]);dec(a[5]);s:=s-10;end else\n if (a[2]>0)and(a[8]>0) then begin dec(a[2]);dec(a[8]);s:=s-10;end else\n if (a[5]>0)and(a[8]>0) then begin dec(a[5]);dec(a[8]);s:=s-13;end else\n if (a[8]>1)and(a[8]>1) then begin dec(a[8]);dec(a[8]);s:=s-16;end else\n begin writeln(0);halt(0);end;\n end;\n if s mod 3=2 then\n begin\n if a[2]>0 then begin dec(a[2]);s:=s-2;end else\n if a[5]>0 then begin dec(a[5]);s:=s-5;end else\n if a[8]>0 then begin dec(a[8]);s:=s-8;end else\n if (a[1]>1)and(a[1]>1) then begin dec(a[1]);dec(a[1]);s:=s-2;end else\n if (a[1]>0)and(a[4]>0) then begin dec(a[1]);dec(a[4]);s:=s-5;end else\n if (a[4]>1)and(a[4]>1) then begin dec(a[4]);dec(a[4]);s:=s-8;end else\n if (a[1]>0)and(a[7]>0) then begin dec(a[1]);dec(a[7]);s:=s-8;end else\n if (a[4]>0)and(a[7]>0) then begin dec(a[4]);dec(a[7]);s:=s-11;end else\n if (a[7]>1)and(a[7]>1) then begin dec(a[7]);dec(a[7]);s:=s-14;end else\n begin writeln(0);halt(0);end;\n end;\n if s=0 then begin writeln('0');halt(0);end;\n for i:=1 to a[9] do\n write('9');\n for i:=1 to a[8] do\n write('8');\n for i:=1 to a[7] do\n write('7');\n for i:=1 to a[6] do\n write('6');\n for i:=1 to a[5] do\n write('5');\n for i:=1 to a[4] do\n write('4');\n for i:=1 to a[3] do\n write('3');\n for i:=1 to a[2] do\n write('2');\n for i:=1 to a[1] do\n write('1');\n for i:=1 to a[0] do\n write('0');\nend."}, {"source_code": "var k, c, kol, kols: array [1..10000] of Longint;\n a: array [1..200, 1..40000] of Longint;\n x1, k1, n, i, t, j: Longint;\n q: array [1..3, 1..100000] of Longint;\n min, sum, now, mark: Longint;\n l, r: array [1..3] of Longint;\n\nBegin\n read(n);\n for i := 1 to n do\n read(c[i]);\n for i := 1 to n do begin\n read(k1);\n kols[i] := k1;\n for j := 1 to k1 do begin\n read(x1);\n inc(k[x1]);\n a[x1, k[x1]] := i;\n end;\n end;\n min := maxlongint;\n for t := 1 to 3 do begin\n for i := 1 to 3 do\n r[i] := 0;\n for i := 1 to n do\n kol[i] := kols[i];\n mark := 0;\n for i := 1 to n do\n if kol[i] = 0 then begin\n inc(r[c[i]]);\n q[c[i], r[c[i]]] := i;\n end;\n for i := 1 to 3 do\n l[i] := 1;\n now := t;\n sum := 0;\n while (l[1] <= r[1]) or (l[2] <= r[2]) or (l[3] <= r[3]) do begin\n if l[now] > r[now] then begin\n inc(now);\n if now > 3 then\n now := now - 3;\n inc(sum);\n continue;\n end;\n sum := sum + 1;\n inc(mark);\n for j := 1 to k[q[now, r[now]]] do begin\n x1 := a[q[now, r[now]], j];\n dec(kol[x1]);\n if kol[x1] = 0 then begin\n inc(r[c[x1]]);\n q[c[x1], r[c[x1]]] := x1;\n end;\n end;\n if mark = n then\n break;\n inc(l[now]);\n if l[now] > r[now] then begin\n now := now + 1;\n inc(sum);\n end;\n if now > 3 then\n now := now - 3;\n end;\n if sum < min then\n min := sum;\n end;\n writeln(min);\nEnd.\n"}, {"source_code": "Program zad3;\n\nVar\n j, i, n, t: byte;\n b: array [1..200] of boolean;\n a: array [1..200, 1..200] of byte;\n c, k: array [1..200] of byte;\n z: array [1..3, 1..3] of byte;\n sum: word;\n\nFunction dost (i: byte): boolean;\n var\n d: boolean;\n h: byte;\n begin\n d:=true;\n h:=1;\n while d and (h<=k[i]) do\n begin\n if not (b[a[i][h]])\n then d:=false\n else inc (h);\n end;\n dost:=d;\n end;\n\nProcedure qwe (t1, t2: byte; res: longint);\n var\n h, p: byte;\n r: array [1..200] of byte;\n begin\n h:=1;\n while (h<=n) and b[h] do\n inc (h);\n if h>n\n then\n begin\n dec (res, z[t1, t2]);\n if res0\n then\n begin\n for h:=1 to 3 do\n if h<>t\n then qwe (t2, h, res+p+z[t2, h]);\n end;\n for h:=1 to p do\n b[r[p]]:=false;\n end;\n\nBegin\n {assign (input, 'input.txt');\n assign (output, 'output.txt');\n reset (input);\n rewrite (output);}\n readln (n);\n for i:=1 to n do\n read (c[i]);\n readln;\n for i:=1 to n do\n begin\n read (k[i]);\n for j:=1 to k[i] do\n read (a[i, j]);\n readln;\n end;\n z[1, 2]:=1;\n z[1, 3]:=2;\n z[2, 1]:=2;\n z[2, 3]:=1;\n z[3, 1]:=1;\n z[3, 2]:=2;\n sum:=high(word);\n qwe (1, 1, 0);\n qwe (2, 2, 0);\n qwe (3, 3, 0);\n writeln (sum);\nEnd."}, {"source_code": "Program zad3;\n\nVar\n j, i, n, t: byte;\n b: array [1..200] of boolean;\n a: array [1..200, 1..200] of byte;\n c, k: array [1..200] of byte;\n z: array [1..3, 1..3] of byte;\n sum: word;\n\nFunction dost (i: byte): boolean;\n var\n d: boolean;\n h: byte;\n begin\n d:=true;\n h:=1;\n while d and (h<=k[i]) do\n begin\n if not (b[a[i][h]])\n then d:=false\n else inc (h);\n end;\n dost:=d;\n end;\n\nProcedure qwe (t1, t2: byte; res: word);\n var\n h, p: byte;\n r: array [1..200] of byte;\n begin\n h:=1;\n while (h<=n) and b[h] do\n inc (h);\n if h>n\n then\n begin\n dec (res, z[t1, t2]);\n if res0\n then\n begin\n for h:=1 to 3 do\n if h<>t\n then qwe (t2, h, res+p+z[t2, h]);\n end;\n for h:=1 to p do\n b[r[p]]:=false;\n end;\n\nBegin\n {assign (input, 'input.txt');\n assign (output, 'output.txt');\n reset (input);\n rewrite (output);}\n readln (n);\n for i:=1 to n do\n read (c[i]);\n readln;\n for i:=1 to n do\n begin\n read (k[i]);\n for j:=1 to k[i] do\n read (a[i, j]);\n readln;\n end;\n z[1, 2]:=1;\n z[1, 3]:=2;\n z[2, 1]:=2;\n z[2, 3]:=1;\n z[3, 1]:=1;\n z[3, 2]:=2;\n sum:=high(word);\n qwe (1, 1, 0);\n qwe (2, 2, 0);\n qwe (3, 3, 0);\n writeln (sum);\nEnd."}, {"source_code": "var\n p,tmp,c:array[1..200] of longint;\n w:array[1..200,1..200] of boolean;\n v:array[1..200] of boolean;\n i,j,k,x,ans,n,num,s,q:longint;\nbegin\n readln(n);\n for i:=1 to n do read(c[i]);\n for i:=1 to n do\n begin\n read(p[i]);\n for j:=1 to p[i] do\n begin\n read(x);\n w[x,i]:=true;\n end;\n end;\n for i:=1 to n do tmp[i]:=p[i];\n ans:=10000;\n s:=1; num:=0; q:=0;\n while num0 then begin\n st:=i;\n repeat\n\n while count[st]>0 do begin\n for j:=1 to n do\n if (id[j]=st) and (deg[j]=0) then begin\n dec(cv);\n deg[j]:=-1;\n dec(count[st]);\n for v:=1 to n do\n if a[j,v] then begin\n dec(deg[v]);\n if deg[v]=0 then inc(count[id[v]]);\n end;\n ans:=ans+1;\n end;\n end;\n if cv=0 then break;\n st:=st+1;\n ans:=ans+1;\n if st=4 then st:=1;\n until cv=0;\n if cv=0 then break;\n end;\n writeln(g,ans);\n closefile;\nend.\n\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n t,tmp,x,kg,sum,n,i,j:longint;\n a,q:array[0..500500]of longint;\n d:array[0..555,0..555]of longint;\n\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n fillchar(d,sizeof(d),$0);\n for i:=1 to n do begin\n read(kg);\n for j:=1 to kg do begin\n read(x);\n d[x][i]:=1;\n end;\n end;\n for i:=1 to n do q[i]:=i;\n for t:=1 to n do\n for i:=1 to n do \n for j:=i+1 to n do \n if (d[q[j]][q[i]]=1)or((d[q[i]][q[j]]=0)and(a[q[i]]>a[q[j]]))then begin\n tmp:=q[i];q[i]:=q[j];q[j]:=tmp;\n end;\n sum:=0;\n for i:=1 to n-1 do begin\n sum:=sum+a[q[i+1]]-a[q[i]];\n if (a[q[i+1]]j then exit(0);\n if dfs(f[i,jj],j)=1 then continue;\n exit(0);\n end;\n inc(otv);\n dec(kol);\n fk[i]:=1;\n if ot=0 then ot:=j;\n exit(1);\nend;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n read(k[i]);\n for j:=1 to k[i] do read(f[i,j]);\n readln;\n end;\n kol:=n;\n j:=1;\n while(kol<>0)do\n begin\n for i:=1 to n do\n if(a[i]=j)and(fk[i]=0)then\n begin\n dfs(i,j);\n end;\n if kol=0 then break;\n inc(otv);\n j:=(j mod 3)+1;\n end;\n writeln(otv-ot+1);\nend.\n"}, {"source_code": "var\n f:array[1..1000,1..1000]of longint;\n c,us,s,t:array[1..1000000]of longint;\n x,ot,o,st,n,m,i,j,k,z,otv:longint;\nprocedure dfs(v:longint);\nvar j:longint;\nbegin\n if us[v]=1 then exit;\n us[v]:=1;\n for j:=1 to n do if f[v,j]=1 then dfs(j);\n inc(st);\n s[st]:=v;\nend;\nbegin\n readln(n);\n for i:=1 to n do read(c[i]);\n for i:=1 to n do\n begin\n read(k);\n for j:=1 to k do\n begin\n read(z);\n f[z,i]:=1;\n end;\n end;\n for i:=1 to n do dfs(i);\n otv:=maxlongint;\n for o:=1 to 3 do\n begin\n x:=o;\n ot:=0;\n for i:=n downto 1 do\n begin\n while(x<>c[s[i]])do\n begin\n inc(ot);\n inc(x);\n if x=4 then x:=1;\n end;\n inc(ot);\n end;\n if otv>ot then otv:=ot;\n end;\n writeln(otv);\nend.\n//2>1\n//2>5\n//1>5\n//3>4\n//3>5\n//4>5\n//5 1 3 4 2"}, {"source_code": "var\n f:array[1..228,0..228]of longint;\n fk,k,a,tp:array[1..228]of longint;\n ii,s,jj,ff,ot,otv,i,j,n,m,kol:longint;\nfunction dfs(i:longint):longint;\nvar j:longint;\nbegin\n fk[i]:=1;\n for j:=1 to k[i] do if fk[f[i,j]]=0 then dfs(f[i,j]);\n inc(s);\n tp[s]:=i;\nend;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n read(k[i]);\n for j:=1 to k[i] do read(f[i,j]);\n readln;\n end;\n for i:=1 to n do if fk[i]=0 then dfs(i);\n kol:=n;\n j:=1;\n for i:=1 to n do fk[i]:=0;\n while(kol<>0)do\n begin\n for ii:=1 to n do\n begin\n i:=tp[ii];\n if(a[i]=j)and(fk[i]=0)then\n begin\n ff:=0;\n for jj:=1 to k[i] do if fk[f[i,jj]]=0 then ff:=1;\n if ff=0 then\n begin\n inc(otv);\n dec(kol);\n if ot=0 then ot:=j;\n fk[i]:=1;\n end;\n end;\n end;\n if kol=0 then break;\n\n inc(otv);\n inc(j);\n if j=4 then j:=1;\n end;\n writeln(otv-ot+1);\nend.\n"}, {"source_code": "var\n f:array[1..228,0..228]of longint;\n fk,k,a:array[1..228]of longint;\n jj,ff,ot,otv,i,j,n,m,kol:longint;\nfunction dfs(i,j:longint):longint;\nbegin\n for jj:=1 to k[i] do\n begin\n if fk[f[i,jj]]=1 then continue;\n if a[f[i,jj]]<>j then exit(0);\n if dfs(f[i,jj],j)=1 then continue;\n exit(0);\n end;\n inc(otv);\n dec(kol);\n fk[i]:=1;\n if ot=0 then ot:=j;\n exit(1);\nend;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n read(k[i]);\n for j:=1 to k[i] do read(f[i,j]);\n readln;\n end;\n kol:=n;\n j:=1;\n while(kol<>0)do\n begin\n for i:=1 to n do\n if(a[i]=j)and(fk[i]=0)then dfs(i,j);\n\n if kol=0 then break;\n\n inc(otv);\n inc(j);\n if j=4 then j:=1;\n end;\n writeln(otv-ot+1);\nend.\n"}, {"source_code": "VAR\n a, b, c, i, j, j1, N, No, t, Kol, flag, time: LONGINT;\n Mas, M, k: ARRAY[0..200000] OF LONGINT;\n Massiv: ARRAY[0..200,0..200] OF LONGINT;\nBEGIN\n READLN(N);\n FOR i := 1 TO N DO\n READ(Mas[i]);\n FOR j := 1 TO N DO\n BEGIN\n READ(k[j]);\n FOR i := 1 TO k[j] DO\n READ(Massiv[j,i]);\n READLN;\n END;\n time := 20000000;\n FOR i := 1 TO 3 DO\n BEGIN\n Kol := 0;\n No := i;\n FOR j := 1 TO N DO\n M[j] := Mas[j];\n WHILE Kol-1\n THEN\n BREAK;\n flag := 1;\n M[j] := -1;\n Kol := Kol+1;\n END;\n IF flag<>1\n THEN\n BEGIN\n No := (No MOD 3)+1;\n t := t+1;\n END;\n END;\n IF t-1\n THEN\n a := 1;\n IF (a=0)\n THEN\n BEGIN\n flag := 1;\n M[j] := -1;\n Kol := Kol+1;\n END;\n END;\n IF (flag<>1)\n THEN\n BEGIN\n No := (No MOD 3)+1;\n t := t+1;\n END;\n END;\n IF t 3 then com := 1;\n for v:= 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n inc(kq);\n dfs(v);\n end;\nend;\n\nprocedure Solve;\nvar i,j : longint;\nbegin\n ans := 0;\n for i:= 1 to n do\n if head[i] = 0 then\n begin\n for j:= 1 to n do\n begin\n free[j] := head[j];\n if c[j,i] then dec(free[j]);\n end;\n check[i] := true;\n kq := n;\n dfs(i);\n if kq > ans then ans := kq;\n end;\n writeln(fo,ans);\nend;\n\nprocedure Output;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n Input;\n Solve;\n Output;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp= '';\n base= 250;\n\nvar fi,fo : text;\n n,kq,ans : longint;\n a,head : array[1..base] of longint;\n c : array[1..base,1..base] of boolean;\n free : array[1..base] of longint;\n check : array[1..base] of boolean;\n\nprocedure Input;\nvar i,x,j : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,n);\n for i:= 1 to n do read(fi,a[i]);\n for i:= 1 to n do\n begin\n read(fi,head[i]);\n for j:= 1 to head[i] do\n begin\n read(fi,x);\n c[i,x] := true;\n end;\n end;\nend;\n\nprocedure dfs(u : longint);\nvar com,v,i : longint;\nbegin\n com := a[u];\n for v:= 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n dfs(v);\n end;\n com := a[u] + 1;\n if com > 3 then com := 1;\n for v:= 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n inc(kq);\n dfs(v);\n end;\n com := 6 - com - a[u];\n for v := 1 to n do\n if not check[v] and (a[v] = com) and (free[v] = 0) then\n begin\n check[v] := true;\n for i:= 1 to n do if c[i,v] then dec(free[i]);\n kq := kq + 2;\n dfs(v);\n end;\nend;\n\nprocedure Solve;\nvar i,j : longint;\nbegin\n ans := 0;\n for i:= 1 to n do\n if head[i] = 0 then\n begin\n for j:= 1 to n do\n begin\n free[j] := head[j];\n if c[j,i] then dec(free[j]);\n end;\n check[i] := true;\n kq := n;\n dfs(i);\n if kq > ans then ans := kq;\n end;\n writeln(fo,ans);\nend;\n\nprocedure Output;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n Input;\n Solve;\n Output;\nend.\n\n"}, {"source_code": "{$R+,O-}\n// Aimakov Yeldar, AtyrauKTL, 11 class\nUses Math, SysUtils;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tmx = maxint;\nvar\n\twas : array [0..201] of bool;\n\tres, ans, i, j, n, l, x, k, pos, sz, u : int;\n\tlen, len1, a, v, t, f : array [0..201*201] of int;\n\nprocedure add(xx, yy : int);\nbegin\n\tinc(l);\n\tv[l] := yy;\n\tt[l] := f[xx];\n\tf[xx] := l;\nend;\n\nbegin\n//\tassign(input, 'a.in'); reset(input);\n//\tassign(output, 'a.out'); rewrite(output);\n\tread(n); l := 0; res := mx;\n\tfor i := 1 to n do read(a[i]);\n\tfor i := 1 to n do begin\n\t\tread(len[i]);\n\t\tfor j := 1 to len[i] do begin\n\t\t\tread(x);\n\t\t\tadd(x, i);\n\t\tend;\n\tend;\n\tfor i := 1 to n do\n\t\tif (len[i] = 0) then begin\n\t\t\tlen1 := len; u := i;\n\t\t\tk := a[i]; sz := 0;\n\t\t\tfillchar(was, sizeof(was), false);\n\t\t\twhile (sz <> n) do begin\n\t\t\t\tif (not was[u]) then begin\n\t\t\t\t\tinc(sz);\n pos := f[u];\n\t\t\t\t\twas[u] := true;\n\t\t\t\t\twhile (pos > 0) do begin\n\t\t\t\t\t\tdec(len1[v[pos]]);\n\t\t\t\t\t\tpos := t[pos];\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\t\tfor j := 1 to n do\n\t\t\t\t\tif (len1[j] = 0) and (k = a[j]) and (not was[j]) then begin\n\t\t\t\t\t u := j;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tend;\n\t\t\t\tif (not was[u]) then continue;\n\t\t\t\tinc(k); inc(ans);\n\t\t\t\tif (k = 4) then k := 1;\n\t\t\tend;\n\t\t\tres := min(res, ans);\n\t\tend;\n\twriteln(res+n-1);\nend."}], "src_uid": "be42e213ff43e303e475d77a9560367f"} {"source_code": "uses math;\nconst fi = 'repaint.inp';\n fo = 'repaint.out';\nvar n,m,x,i,j,cshd,cshc,cscd,cscc,smi,dem:longint;\n kt:boolean;\nbegin\n //assign(input,fi);reset(input);\n //assign(output,fo);rewrite(output);\n\n readln(n,m);\n readln(X);\n\n smi:=min(n,m);\n smi:=(smi div 2) + (smi mod 2);\n\n if x > smi then write(0)\n else\n begin\n cshc:=n-x+1;\n cshd:=x;\n cscd:=x;\n cscc:=m-x+1;\n // cs : chi so, hd : hang dau....\n kt:=odd(cshd);\n for i:=cscd to cscc do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cshc);\n if cshc>cshd then\n for i:=cscd to cscc do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cscd);\n for i:=cshd+1 to cshc-1 do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cscc);\n if cscc>cscd then\n for i:=cshd+1 to cshc-1do\n if kt=odd(i) then inc(dem);\n //result\n write(dem);\n end;\nend.\n", "positive_code": [{"source_code": "program cf;\n\n{$APPTYPE CONSOLE} {$o- r+ q+}\n\nuses\n SysUtils;\n\ntype\n int = integer;\n\nvar\n n, m, x: int;\n\n function f(x: integer):integer;\n var\n nn, mm: integer;\n begin\n nn := n - 2*(x);\n mm := m - 2*(x);\n result:=0;\n if (nn>0) and (mm>0) then\n result:=((nn+1) div 2 )*((mm+1)div 2) + ((nn-(nn+1) div 2))*((mm - (mm+1) div 2));\n end;\nbegin\n// Reset(Input, 'input.txt');\n //Rewrite(Output, 'output.txt');\n\n read(n,m,x);\n\n {q := ((n+1) div 2)-(x-1);\n p := ((m+1) div 2)-(x-1);\n k := (q * p) + (((n - q)-(x-1)) * ((m - q)-(x-1)));\n\n q := ((n+1) div 2)-(x);\n p := ((m+1) div 2)-(x);\n k1 := (q * p) + (((n-q)-x) * ((m-q)-x));\n\n k := k - k1;\n\n if k < 0 then\n write(0)\n else\n write(k); }\n write(f(x-1) - f(x));\n\n Close(Input);\n Close(Output);\nend.\n"}, {"source_code": "program Problem_B;\n\n{$APPTYPE CONSOLE}\n\nvar n, m, x, a, b, c, d, s1, s2 : longint;\n\nprocedure Swap(var a, b : longint);\nvar c : longint;\nbegin\n c := a;\n a := b;\n b := c;\nend;\n\nbegin\n assign(input, '');\n assign(output, '');\n read(n, m, x);\n\n if (m < n)\n then Swap(n, m);\n\n if (x > (n + 1) div 2)\n then writeln('0')\n else begin\n a := n - x - x + 2;\n b := m - x - x + 2;\n c := a - 2;\n d := b - 2;\n\n if (c < 0) or (d < 0)\n then begin\n c := 0;\n d := 0;\n end;\n\n if ((a * b) mod 2 = 0)\n then s1 := (a * b) div 2\n else s1 := (a * b) div 2 + 1;\n\n if ((c * d) mod 2 = 0)\n then s2 := (c * d) div 2\n else s2 := (c * d) div 2 + 1;\n\n writeln(s1 - s2);\n end;\n close(input);\n close(output);\nend.\n"}, {"source_code": "program prgB;\n\n{$APPTYPE CONSOLE}\n{$O-}\n{$R+}\n{$Q+}\n\nuses\n SysUtils, Math;\n\nvar\n n, m, r, x: int64;\n\nfunction num(n, m: integer): integer;\nbegin\n if n - 2 * x = 1 then begin\n result := (m - 2 * x) div 2 + (m - 2 * x) mod 2;\n end else if m - 2 * x = 1 then begin\n result := (n - 2 * x) div 2 + (n - 2 * x) mod 2;\n end else if ((n - 2 * x) mod 2 = 0) and ((m - 2 * x) mod 2 = 0) then begin\n result := 2 * (((n - 2 * x) div 2) + (n - 2 * x) mod 2) + 2 * (((m - 2 * x)\n div 2) + (m - 2 * x) mod 2) - 2;\n end else if ((n - 2 * x) mod 2 = 1) and ((m - 2 * x) mod 2 = 0) then begin\n result := 2 * (((m - 2 * x) div 2) + (m - 2 * x) mod 2) + 2 * (((n - 2 * x)\n div 2) + (n - 2 * x) mod 2) - 3\n end else if ((n - 2 * x) mod 2 = 0) and ((m - 2 * x) mod 2 = 1) then begin\n result := 2 * (((n - 2 * x) div 2) + (n - 2 * x) mod 2) + 2 * (((m - 2 * x)\n div 2) + (m - 2 * x) mod 2) - 3\n end else\n result := 2 * (((n - 2 * x) div 2) + (n - 2 * x) mod 2) + 2 * (((m - 2 * x)\n div 2) + (m - 2 * x) mod 2) - 4;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n, m, x);\n x := x - 1;\n if ((n - 2 * x) >= 1) and ((m - 2 * x) >= 1) then\n writeln(num(n, m))\n else\n writeln(0);\nend.\n\n"}, {"source_code": "program Project1; \n \n{$APPTYPE CONSOLE} \n \nvar \n a,b,m,n,ans,ans1,s,x:LongInt; \nbegin \n Readln(n,m); \n Readln(x); \n Dec(x); \n a:=n; \n b:=m; \n n:=n-(2*x); \n m:=m-(2*x); \n ans:=0; \n if (n>0) and (m>0) then \n begin \n s:=n*m; \n ans:=s div 2; \n if s mod 2=1 then Inc(ans); \n Inc(x); \n a:=a-(2*x); \n b:=b-(2*x); \n ans1:=0; \n if (a>0) and (b>0) then \n begin \n s:=a*b; \n ans1:=s div 2; \n if s mod 2=1 then Inc(ans1); \n end; \n ans:=ans-ans1;\n end; \n Writeln(ans); \n readln; \nend. \n \n \n \n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar ans,n,m,x:integer;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readln(n,m);\n readln(x);\n dec(n,2*x-2);\n dec(m,2*x-2); \n if (n<0)or(m<0) then begin\n writeln(0);\n halt(0);\n end;\n ans:=((2*n) div 2)*(m div 2)+((n div 2)+(n mod 2))*(m mod 2);\n dec(n,2);\n dec(m,2);\n if (n<0)or(m<0) then begin\n writeln(ans);\n halt(0);\n end;\n dec(ans,((2*n) div 2)*(m div 2)+((n div 2)+(n mod 2))*(m mod 2));\n writeln(ans);\n\nend.\n "}, {"source_code": " {uses crt; }\n label 1;\n const nn=5000;\n type {extended=real;}\n mass=array [0..nn,0..nn] of integer;\n var x,mm,s,p, n,i,j,k,l,imin,sm,t,m,maxs:longint;\n xl,yl,xk,yk:longint;\n b:mass;\n function prov(x,y:longint):boolean; {true - ne b'et}\n var yy:boolean; i,j:longint;\n begin yy:=true;\n if (x=xl) or (y=yl) then yy:=false;\n if (abs(x-xk)=1)and(abs(y-yk)=2) then yy:=false;\n if (abs(x-xk)=2)and(abs(y-yk)=1) then yy:=false;\n if (abs(x-xl)=1)and(abs(y-yl)=2) then yy:=false;\n if (abs(x-xl)=2)and(abs(y-yl)=1) then yy:=false;\n prov:=yy;\n\n end;\n\n\n\n\n function min(x,y:longint):longint;\n begin min:=x;if yx then max:=y; end;\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input);}\n read(m,n); read(x);\n for i:=1 to m do for j:=1 to n do if not odd(i+j)\n then b[i,j]:=min(i-1,min(j-1,min(m-i,n-j)))+1;\n\n { for i:=1 to m do begin for j:=1 to n do write(b[i,j],' ');writeln; end; }\n for i:=1 to m do for j:=1 to n do if b[i,j]=x then inc(s);\n\n writeln(s);\n\n end.\n\n\n\n\n\n"}, {"source_code": "uses\n math;\nvar\n n,m,i,j:word;\n k,x,d:longword;\n\nfunction blackcount(w,h:word):longword;\nbegin\nif (w mod 2 = 0)and(h mod 2 = 0) then\n blackcount := (w*h) div 2\nelse if (w mod 2 = 0)and(h mod 2 = 1) then\n blackcount := (w*(h-1)) div 2+w div 2\nelse if (w mod 2 = 1)and(h mod 2 = 0) then\n blackcount := ((w-1)*h) div 2+h div 2\nelse\n blackcount := ((w-1)*(h-1)) div 2+h div 2+w div 2+1;\nend;\n\nbegin\nreadln(n,m);\nreadln(x);\nd := min((n+1)div 2,(m+1)div 2);\nif x>d then\n k := 0\nelse if x=d then\n if (n mod 2 = 1) or (m mod 2 = 1) then\n k := 1\n else\n k := 2\nelse\n k := blackcount(n-2*(x-1),m-2*(x-1))-blackcount(n-2*x,m-2*x);\nwriteln(k);\n{readln;}\nend.\n"}, {"source_code": "program JJ_Mybabe;\n {$APPTYPE CONSOLE} {$o-}\nuses SysUtils,Math;\nvar\n m,n,ui,uj,di,dj,i,x:integer;\n mark:array[1..5000,1..5000] of boolean;\nfunction check(k,p:integer):boolean;\nbegin\n if ((k mod 2=0) and (p mod 2=0)) or (( k mod 2<>0) and (p mod 2<>0)) then result:=true else result:=false;\nend;\nfunction get:integer;\n var\n i,j:integer;\nbegin\n result:=0;\n for i:=ui to di do\n if (not mark[i][dj])\n then\n begin\n mark[i][dj]:=true;\n if check(i,dj) then inc(result);\n end;\n\n for i:=ui to di do\n if (not mark[i][uj])\n then\n begin\n mark[i][uj]:=true;\n if check(i,uj) then inc(result);\n end;\n\n for j:=uj to dj do\n if (not mark[ui][j])\n then\n begin\n mark[ui][j]:=true;\n if check(ui,j) then inc(result);\n end;\n\n for j:=uj to dj do\n if (not mark[di][j])\n then\n begin\n mark[di][j]:=true;\n if check(di,j) then inc(result);\n end;\n\nend;\nprocedure print(k:integer);\nbegin\n write(k);\n halt(0);\nend;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n read(n,m,x);\n ui:=1; uj:=1; di:=n; dj:=m;\n for i:=1 to x-1 do\n begin\n inc(ui); inc(uj);\n dec(di); dec(dj);\n if (ui>di) or (uj>dj) then print(0);\n end;\n if (ui>di) or (uj>dj) then print(0);\n print(get);\nend.\n\n\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n\n{$APPTYPE CONSOLE}\n\nuses\n Math;\n\ntype\n int = integer;\n\nvar\n n, m, i, j, c, x : integer;\n ans : int64;\n\nprocedure init;\nbegin\n read(n, m, x);\nend;\n\nprocedure main;\nbegin\n ans := 0;\n for i := 1 to n do\n for j := 1 to m do\n if (i mod 2 = j mod 2) then begin\n c := min(min(i, j), min(n - i + 1, m - j + 1));\n if c = x then\n ans := ans + 1;\n end;\n writeln(ans);\nend;\n\nbegin\n //reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n\n init;\n main;\n\n //close(input);\n // close(output);\nend.\n"}, {"source_code": "var m,n,x,r,rr:longint;\n\nfunction calc(m,n,x:longint):longint;\nvar re,a,b,c,u,v:longint;\nbegin\n a:=x; b:=m-x+1; c:=n-x+1;\n u:=b-a+1; v:=c-a+1;\n if (u<0) or (v<0) then calc:=0\n else calc:=(u*v+1) shr 1;\nend;\n\nbegin\n read(m,n,x);\n r:=calc(m,n,x);\n rr:=calc(m,n,x+1);\n writeln(r-rr);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar n, m, k: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,m);\n readln(k);\n n:=n-2*(k-1);\n m:=m-2*(k-1);\n if (n > 0) and (m > 0) then\n if n = 1 then writeln((m+n) div 2)\n else writeln(m+n-2)\n else writeln(0);\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\n k,i,j,res,q,n,m,c,x,y,z : longint;\nbegin\n readln(n,m,q);\n for i:=1 to n do for j:=1 to m do if not odd(i+j) then\n begin\n k:=i;\n if j < i then k:=j; \n if n-i+1 < k then k:=n-i+1;\n if m-j+1 < k then k:=m-j+1;\n if k=q then inc(res);\n end;\n writeln(res);\nend."}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, m, x, i, j, ans : integer;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n, m, x);\n ans := 0;\n for i := 1 to n do\n for j := 1 to m do\n if (min(min(i, n - i + 1), min(j, m - j + 1)) = x) and ((i + j) mod 2 = 0) then\n inc(ans);\n writeln(ans);\nend.\n "}, {"source_code": "var kol,i,l,l1,n,m,x:longint;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n l:=1; l1:=1;\n Read(n,m,x);\n if x>1000000\n then x:=1000000;\n for i:=1 to x-1 do\n begin\n inc(l); inc(l1);\n Dec(n); dec(m);\n end;\n if (l>n)or(l1>m)\n then begin Writeln(0); Halt(0); end;\n if l mod 2=l1 mod 2\n then begin\n kol:=0;\n x:=0;\n for i:=l1 to m do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n for i:=l+1 to n do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n\n for i:=l1+1 to m do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n for i:=l+1 to n-1 do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n Writeln(kol);\n end\n else begin\n kol:=0;\n x:=1;\n for i:=l1 to m do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n for i:=l+1 to n do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n\n for i:=l1+1 to m do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n for i:=l+1 to n-1 do\n begin\n x:=x xor 1;\n kol:=kol+x;\n end;\n Writeln(kol);\n end;\nend."}, {"source_code": "var\n n,m,x,i,j,x1,y1,x2,y2,sum:longint;\nbegin\n readln(n,m);\n readln(x);\n x1:=1;\n y1:=1;\n x2:=n;\n y2:=m;\n for i:=1 to x-1 do\n begin\n inc(x1);\n inc(y1);\n dec(x2);\n dec(y2);\n if (x1>x2)or(y1>y2) then\n begin\n writeln(0);\n halt;\n end;\n end;\n for i:=x1 to x2 do for j:=y1 to y2 do if odd(i)=odd(j) then\n begin\n if (i=x1)or(i=x2)or(j=y1)or(j=y2) then inc(sum);\n end;\n writeln(sum);\nend.\n"}, {"source_code": "var res,i,j,n,m,k:longint;\n function mm(a,b:longint):longint;\n begin\n if a>b then mm:=b\n else mm:=a;\n end;\n begin\n read(n,m,k);\n res:=0;\n for i:=1 to n do\n for j:=1 to m do\n if ( mm( mm(i,n-i+1),mm(j,m-j+1) ) = k ) and\n ( not odd(i+j) ) then inc(res);\n Writeln(res);\n end."}, {"source_code": "{ fp }\nVAr\n n,m,k,ans:Longint;\n Begin\n REad(n,m,k);\n dec(k);\n n := n-2*k;\n m := m-2*k;\n If (n<1) or (m<1) then WriteLn(0)\n else\n Begin\n If (n=1) or (m=1) then ans := n+m-1\n else ans := (2*(n+m)-4);\n WriteLn((ans+1) div 2);\n End;\n End.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, x, n2, m2, k : longint;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n k := 0;\n read(n, m, x);\n n := n - (x - 1)*2;\n m := m - (x - 1)*2;\n n2 := n - 2;\n m2 := m - 2;\n if (n <= 0) or (m <= 0) then\n begin\n writeln(0);\n halt(0);\n end;\n if m mod 2 = 0 then\n k := n*(m div 2)\n else\n begin\n if n mod 2 = 0 then\n k := ((m div 2) + 1)*(n div 2) + (n div 2)*(m div 2)\n else\n k := ((m div 2) + 1)*((n div 2) + 1) + (n div 2)*(m div 2);\n end;\n n := n2;\n m := m2;\n if (n <= 0) or (m <= 0) then\n begin\n writeln(k);\n halt(0);\n end;\n if m mod 2 = 0 then\n k := k - n*(m div 2)\n else\n begin\n if n mod 2 = 0 then\n k := k - (((m div 2) + 1)*(n div 2) + (n div 2)*(m div 2))\n else\n k := k - (((m div 2) + 1)*((n div 2) + 1) + (n div 2)*(m div 2));\n end;\n write(k);\n// close(input);\n// close(output);\nend.\n "}, {"source_code": "uses Math;\nvar n,m,i,j,k,x,res,el:longint;\n a:array[0..5001,0..5001] of longint;\nbegin\nreadln(n,m);\nreadln(x);\nres:=0;\nfor i:= 1 to n do\nfor j:= 1 to m do\nif (i+j) mod 2 = 0 then begin\n el:=min(min(i,j),min(n-i+1,m-j+1));\n if el=x then res:=res+1;\n end;\nwriteln(res);\nend.\n"}, {"source_code": "var i,j,n,m:integer;\n x,res:longint;\n\n\nbegin\nreadln(n,m);\nreadln(x);\ndec(x);\nif (n-2*x=1)or(m-2*x=1) then res:=1 else\nbegin\n\nres:=(n-2*x)+(m-2*x)-2;\n\nif (res<0)or(x>2501)or(m-2*x<0)or(n-2*x<0) then res:=0;\nend;\nwrite(res);\n\n\nend."}, {"source_code": "uses math;\nvar xx,n,m,x,i,j,x1,x2,x3,x4:longint;\nans:longint;\n begin\n read(n,m,x);\n for i:=1 to n do\n begin\n for j:=1 to m do\n if not odd(i+j) then\n begin\n x1:=min(i,j);\n x2:=min(n-i+1,j);\n x3:=min(i,m-j+1);\n x4:=min(n-i+1,m-j+1);\n xx:=min(min(min(x1,x2),x3),x4);\n if xx=x then ans:=ans+1;\n end;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var\n i,j,n,m,x,sx,sy,ex,ey,res:longint;\nbegin\n read(n,m,x);\n sx:=x;sy:=x;\n ex:=n-x+1;ey:=m-x+1;\n res:=0;\n for i:=sx to ex do for j:=sy to ey do begin\n if (i<>sx)and(i<>ex)and(j<>sy)and(j<>ey)then continue;\n inc(res,1-((i+j)and 1));\n end;\n writeln(res);\nend."}, {"source_code": "program shablon;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\nvar\n n,m,x,l,r,l1,r1,mx,a,i,j:integer;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n read(n,m,x);\n x := x - 1;\n if min(n,m) < 2*x + 1 then\n begin\n writeln(0);\n halt(0);\n end;\n l := x + 1;\n r := x + 1;\n l1 := n - (x );\n r1 := m - (x );\n a := 0;\n for i :=l to l1 do\n for j := r to r1 do\n begin\n if ((i + j) mod 2 = 0) and ((i = l ) or (l1 = i ) or (j = r ) or (r1= j)) then\n inc(a);\n end;\n writeln(a);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n,m,x:int64;\nfunction f(x:integer):int64;\nvar a,b:integer;\nbegin\n a:=n-x;\n b:=m-x;\n if (a<=0) or (b<=0) then f:=0\n else\n f:=a*b div 2 + (a mod 2)*(b mod 2);\nend;\nbegin\n readln(n,m);\n readln(x);\n writeln(f(2*x-2)-f(2*x));\nend."}, {"source_code": "uses math;\nvar ans,i,j,n,m,k:longint;\n begin\n read(n,m,k);\n ans:=0;\n for i:=1 to n do\n for j:=1 to m do\n if (min(min(i,n-i+1),min(j,m-j+1))=k) and\n ((i+j) mod 2=0) then ans := ans+1;\n Writeln(ans);\n end."}, {"source_code": "//Yerzhan Dyussenaliyev\nUses Math;\nvar\n\tn, m, k, c, ans, x, y, pr, col: longint;\n\nbegin\n// reset(input, 'a.in');\n// rewrite(output, 'a.out');\n\n read(n, m, k);\n\n\tans := 0;\n\tc := 0;\n \tx := n;\n \ty := m;\n\tcol := (n * m + 1) div 2;\n \t while (x > 0) and (y > 0) do begin\n\t\tinc(c);\n \tpr := (max(1, x) * max(1, y) + 1) div 2;\n\t\tif c = k then begin\n \t\tdec(x, 2);\n \t\tdec(y, 2);\n \t\tif (x > 0) and (y > 0) then col := (max(1, x) * max(1, y) + 1) div 2 else col := 0;\n \t\tans := pr - col;\n \tend;\n\t\tx := x - 2;\n\t\ty := y - 2;\n\tend;\n\n\twriteln(ans);\nend."}, {"source_code": "var\nn,m,x,i,j,k,ans:longint;\nbegin\nreadln(n,m);\nreadln(x);\nk:=x;\nx:=x-1;\nif (k>2500)or(n-x*2<=0)or(m-x*2<=0) then ans:=0\nelse begin\n ans:=(n-x*2)*(m-x*2) div 2;\n if ((n-k*2)>0)and((m-k*2)>0) then begin\n ans:=ans-(n-k*2)*(m-k*2) div 2;\n if (n-k*2)*(m-k*2) mod 2<>0 then dec(ans);\n end;\n\nif (n-2*x)*(m-2*x) mod 2<>0 then inc(ans);\n end;\nwriteln(ans);\nend."}, {"source_code": "Var\n n,m,x,r,t:Integer;\nFunction ans(x:Integer):Integer;\nBegin\n ans:=x div 2 + x mod 2;\nEnd;\nBegin\n Read(n,m,x);\n If n>m Then Begin\n t:=n;\n n:=m;\n m:=t;\n End;\n If ans(n)0) Then r:=ans(m-(x-1)*2)\n Else r:=n+m-4*x+2;\n Write(r);\nEnd.\n"}, {"source_code": "var\n\n x,r,a,b,i,j,k,l,n,m,t:int64;\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,m);\n read(x);\n x:=x-1;\n\n n:=n-2*x;\n m:=m-2*x;\n\n if (n<=0) or ( m<=0) then write('0') else\n if n=1 then\n begin\n if m mod 2=0 then write(m div 2);\n if m mod 2 =1 then\n write(m div 2 +1);\n\n end\n\n else\n\n\n\n if m=1 then\n begin\n if n mod 2=0 then write(n div 2);\n if n mod 2 =1 then\n write (n div 2 +1);\n\n end\n\n else\n write(m+n-2);\n\n\n\n\n\n {close(input);\n close(output);}\nend.\n"}, {"source_code": "program zB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar f:array[0..50000]of longint;\n n,m,x,k,i:longint;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(n,m,x);\n k:=0;\n for i:=1 to 5000 do\n begin\n if (n-k<=0)or(m-k<=0)then break;\n f[i]:=((n-k)*(m-k)+1)div 2;\n k:=k+2;\n end;\n if x>5000 then writeln(0) else writeln(f[x]-f[x+1]);\nend.\n "}, {"source_code": "uses math;\nVar ans,i,j,n,m,k:longint;\n function dist(x,y:longint):longint;\n begin\n dist:=min(min(x-1,n-x),min(y-1,m-y))+1;\n end;\n Begin\n Read(n,m,k);\n ans:=0;\n for i:=1 to n do\n for j:=1 to m do\n if (dist(i,j)=k)and((i+j)mod 2=0) then inc(ans);\n Writeln(ans);\n End."}, {"source_code": "program task;\n\n{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE 1000000000}\n{$O+,R-,S-,Q-,I-}\n\nuses\n SysUtils, Math;\n\nvar n,m,x,sum,i,j:integer;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(n,m,x);\n dec(x);\n n:=n-x*2;\n m:=m-x*2;\n sum:=0;\n for i:=1 to n do\n for j:=1 to m do\n if ((i=1) or (i=n) or (j=1) or (j=m)) and ((i mod 2) xor (j mod 2) = 0)\n then inc(sum);\n writeln(sum);\n// readln;readln;\nend.\n"}, {"source_code": "var n,m,x,l,a,b:longint;\n begin\n read(n,m,x);\n l:=1;\n while (li) and (m>0) and (n>0) do begin\n i:=i+1; m:=m-2; n:=n-2;\n end;\n\n if (m>0) and (n>0) then begin\n if m=1 then writeln((n+1) div 2)\n else if n=1 then writeln((m+1) div 2)\n else writeln((m+n) - 2);\n end\n else writeln(0);\n close(fout);\n close(fin);\nend."}, {"source_code": "var\n n,i,j,x,m,a1,kol:longint;\nfunction min(a,b,c,d:longint):longint;\n begin\n if (a<=b)and(a<=c)and(a<=d) then min:=a\n else if (b<=a)and(b<=c)and(b<=d) then min:=b\n else if (c<=a)and(c<=b)and(c<=d) then min:=c\n else min:=d;\n end;\nbegin\n read(n,m,x);\n for i:=1 to m do\n begin\n if i mod 2=0 then\n for j:=1 to n do\n begin\n if j mod 2=0 then begin\n a1:=min(j-1,n-j,i-1,m-i)+1;\n if a1=x then kol:=kol+1;\n end;\n end\n else for j:=1 to n do\n if j mod 2=1 then begin\n a1:=min(j-1,n-j,i-1,m-i)+1;\n if a1=x then kol:=kol+1;\n end;\n end;\n write(kol);\nend."}, {"source_code": "program problem_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, ans, i, j, x: longint;\n\nfunction prov(i, j: longint): boolean;\nbegin\n if ((i mod 2 <> 0) and (j mod 2 <> 0))\n or ((i mod 2 = 0) and (j mod 2 = 0)) then prov := true else prov := false;\nend;\n\nbegin\n readln(n, m);\n readln(x);\n dec(x);\n\n\n for i := x + 1 to n - x do\n for j := x + 1 to m - x do\n if prov(i, j) then inc(ans);\n\n for i := x + 2 to n - x - 1 do\n for j := x + 2 to m - x - 1 do\n if (prov(i - 1, j - 1)) and (prov(i + 1, j + 1))\n and (prov(i - 1, j + 1))and (prov(i + 1, j - 1)) and (prov(i, j))then dec(ans);\n\n writeln(ans);\n readln;\nend.\n"}, {"source_code": "program perekr;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar x,a,b,m,n,s:integer;\nfunction min(a,b:integer):integer;\nBegin\nif a<=b then min:=a else min:=b;\nEnd;\n\nBegin\n readln(n,m); read(x);\n s:=0;\n for a:=1 to n do\n for b:=1 to m do\n if (min(min(a,b),min(n-a+1,m-b+1))=x)and((a+b) mod 2=0) then\n s:=s+1;\n\n\n\n write(s);\nend."}, {"source_code": "var\n n,m,x,kq:longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n readln(n,m);\n readln(x);\n if m smi then write(0)\n else\n begin\n cshc:=n-x+1;\n cshd:=x;\n cscd:=x;\n cscc:=m-x+1;\n // cs : chi so, hd : hang dau....\n kt:=odd(cshd);\n for i:=cscd to cscc do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cshc);\n if cshc>cshd then\n for i:=cscd to cscc do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cscd);\n for i:=cshd+1 to cshc-1 do\n if kt=odd(i) then inc(dem);\n\n kt:=odd(cscc);\n if cscc>cscd then\n for i:=cshd+1 to cshc-1do\n if kt=odd(i) then inc(dem);\n //result\n write(dem);\n end;\n readln;\nend."}, {"source_code": "uses math; const size=5000;\nvar\n cnt:array[1..size] of longint; l1,l2,n,m,x,i,j:longint;\n\n\nbegin\n readln(n,m); readln(x);\n for i:=1 to n do for j:=1 to m do\n begin\n if (odd(i+j)) then continue;\n l1:=min(i,n-i+1); l2:=min(j,m-j+1);\n inc(cnt[min(l1,l2)]);\n end;\n if (x>size) then writeln(0) else writeln(cnt[x]);\nend."}, {"source_code": "var\n xx,yy: array [0..100000]of longint;\n\n n,m ,nn,rez,i,sum,j: longint;\n x : int64;\nbegin\n readln(n,m);\n readln(x);\n { if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n\n \n xx[i]:= rez; }\n if x>=2501 then\n begin\n writeln(0);\n exit;\n end;\n\n i:=0;\n \n while (n>=1) and (m>=1 ) do\n begin\n inc(i);\n if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n \n xx[i]:= rez;\n n:=n-2;\n m:=m-2;\n end;\n yy[i]:= xx[i];\n sum:=0;\n for j:=i downto 2 do\n begin\n yy[j-1]:= xx[j-1]- xx[j];\n end;\n writeln(yy[x]);\nend.\n \n "}, {"source_code": "program ProblemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, x, curr, c: longint;\n\nfunction count(i, j: longint): longint;\nbegin\n if (i <= 0) or(j <= 0)then result := 0 else\n if i * j mod 2 = 0 then result := (i * j) div 2 else\n result := ((i - 1) * j) div 2 + (i + 1)div 2;\nend;\n\nbegin\n//reset(input, 'input.txt'); rewrite(output, 'output.txt');\n read(n, m, x);\n curr := count(n, m);\n c := 1;\n while (n > 0)and(m > 0)do\n begin\n n := n - 2;\n m := m - 2;\n if c = x then\n begin\n writeln(curr - count(n, m));\n halt(0);\n end;\n curr := count(n, m);\n inc(c);\n end;\n writeln(0);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction Count(a, b: Int64): Int64;\nbegin\n if (a <= 0) or (b <= 0) then\n Result := 0\n else\n Result := (a*b div 2) + (a*b mod 2);\nend;\n\nvar\n a, b: Int64;\n x: Int64;\n\nbegin\n readln(a, b);\n readln(x);\n if x = 0 then\n writeln(Count(a, b))\n else\n begin\n while (x > 1) and (a > 0) and (b > 0) do\n begin\n Dec(x); Dec(a, 2); Dec(b, 2);\n end;\n if x = 1 then\n writeln(Count(a, b)-Count(a-2, b-2))\n else\n writeln(0);\n end;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar n,m,x,s,i:Longint;\nbegin\n// Reset(input,'in.txt');\n// Rewrite(Output,'out.txt');\n read(n,m,x);\n if x>Min(n,m) then\n begin\n write(0);\n Halt(0);\n end;\n Dec(x);\n for i:=1 to x do\n begin\n Dec(n,2);\n Dec(m,2);\n end;\n if (n<0)or(m<0) then\n begin\n write(0);\n Halt(0);\n end;\n s:=((n*m) div 2) +((n*m) mod 2);\n n:=Max(0,n-2);\n m:=Max(0,m-2);\n s:=s-(((n*m) div 2) +((n*m) mod 2));\n write(s);\nend.\n"}, {"source_code": "var n, m, k, i, x1, x2: longint;\nbegin\n readln(n, m);\n readln(k);\n for i := 1 to k - 1 do begin\n dec(m, 2);\n dec(n, 2);\n end;\n if (m <= 0) or (n <= 0) then begin\n x1 := 0;\n end else begin\n x1 := ((n * m + (n * m mod 2)) div 2);\n end;\n dec(m, 2);\n dec(n, 2);\n if (m <= 0) or (n <= 0) then begin\n x2 := 0;\n end else begin\n x2 := ((n * m + (n * m mod 2)) div 2);\n end;\n writeln(x1 - x2);\nend."}, {"source_code": "var\n x,y,n,m,k:longint;\n\nfunction cnt(const x, y:longint):longint;\nbegin\n if (x<0)or(y<0) then cnt:=0 else\n cnt:=(x*y) shr 1 + (x*y) and 1;\nend;\n\nbegin\n read(n, m, k); \n x:=n-2*(k-1);\n y:=m-2*(k-1);\n if (x<0)or(y<0) then writeln(0)else writeln(cnt(x, y)-cnt(x-2, y-2));\nend.\n\nWBW\nBWB\nWBW\n"}, {"source_code": "{$MODE DELPHI}\nuses sysutils,math;\nvar n,m,x,i,j,r:longint;\nbegin\nread(n,m);\nread(x);\nr:=0;\nfor i:=1 to n do\n for j:=1 to m do\n if (min(min(i,j),min(n-i+1,m-j+1))=x) and (not odd(i+j)) then inc(r);\nwrite(r);\nend."}, {"source_code": "Uses Math;\nvar\n n,m,x,i,j,ans,k : longint;\nbegin\n read(n,m,x);\n ans:=0;\n for i:=1 to n do\n for j:=1 to m do\n if (i + j) mod 2 = 0 then begin\n if i > j then k:=j - 1 else k:=i - 1;\n if n - i > m - j then k:=min(k,m - j) else k:=min(k,n - i);\n if k + 1 = x then inc(ans);\n end;\n write(ans);\nend."}, {"source_code": "{$Apptype console}\nvar x, y, ans, i, j, n, m : longint;\n a : array [-1..6000, -1..6000] of longint;\nbegin\n read(n, m, x);\n a[0, 1] := 0;\n for i := 1 to n do\n begin\n if a[i - 1, 1] = 0 then a[i, 1] := 1 else a[i, 1] := 0;\n for j := 2 to m do\n if a[i, j - 1] = 1 then a[i, j] := 0 else a[i, j] := 1;\n end;\n dec(x);\n ans := 0;\n for i := x + 1 to n - x do\n for j := x + 1 to m - x do\n if a[i, j] = 1 then inc(ans);\n\n for i := x + 2 to n - x - 1 do\n for j := x + 2 to m - x - 1 do\n if a[i, j] = 1 then dec(ans);\n\n write(ans);\nend.\n"}, {"source_code": "uses sysutils,math;\nvar n,m,x,i,j,r:longint;\nbegin\nread(n,m);\nread(x);\nr:=0;\nfor i:=1 to n do\n for j:=1 to m do\n if (min(min(i,j),min(n-i+1,m-j+1))=x) and (not odd(i+j)) then inc(r);\nwrite(r);\nend."}], "negative_code": [{"source_code": "uses\n math;\nvar\n n,m,i,j:word;\n k,x,d:longword;\n\nfunction blackcount(w,h:word):longword;\nbegin\nif (w mod 2 = 0)and(h mod 2 = 0) then\n blackcount := (w*h) div 2\nelse if (w mod 2 = 0)and(h mod 2 = 1) then\n blackcount := (w*(h-1)) div 2+w div 2\nelse if (w mod 2 = 1)and(h mod 2 = 0) then\n blackcount := ((w-1)*h) div 2+h div 2\nelse\n blackcount := ((w-1)*(h-1)) div 2+h div 2+w div 2+1;\nend;\n\nbegin\nreadln(n,m);\nreadln(x);\nd := min((n+1)div 2,(m+1)div 2);\nif x>d then\n k := 0\nelse\n k := blackcount(n-2*(x-1),m-2*(x-1))-blackcount(n-2*x,m-2*x);\nwriteln(k);\n{readln;}\nend.\n"}, {"source_code": "uses\n math;\nvar\n n,m,i,j,d:word;\n k,x:longword;\n\nfunction blackcount(w,h:word):word;\nbegin\nif (w mod 2 = 0)and(h mod 2 = 0) then\n blackcount := (w*h) div 2\nelse if (w mod 2 = 0)and(h mod 2 = 1) then\n blackcount := (w*(h-1)) div 2+w div 2\nelse if (w mod 2 = 1)and(h mod 2 = 0) then\n blackcount := ((w-1)*h) div 2+h div 2\nelse\n blackcount := ((w-1)*(h-1)) div 2+h div 2+w div 2+1;\nend;\n\nbegin\nreadln(n,m);\nreadln(x);\nd := min((n+1)div 2,(m+1)div 2);\nif x>d then\n k := 0\nelse if x=d then\n k := 1\nelse\n k := blackcount(n-2*(x-1),m-2*(x-1))-blackcount(n-2*x,m-2*x);\nwriteln(k);\nreadln;\nend.\n"}, {"source_code": "uses\n math;\nvar\n n,m,i,j:word;\n k,x,d:longword;\n\nfunction blackcount(w,h:word):longword;\nbegin\nif (w mod 2 = 0)and(h mod 2 = 0) then\n blackcount := (w*h) div 2\nelse if (w mod 2 = 0)and(h mod 2 = 1) then\n blackcount := (w*(h-1)) div 2+w div 2\nelse if (w mod 2 = 1)and(h mod 2 = 0) then\n blackcount := ((w-1)*h) div 2+h div 2\nelse\n blackcount := ((w-1)*(h-1)) div 2+h div 2+w div 2+1;\nend;\n\nbegin\nreadln(n,m);\nreadln(x);\nd := min((n+1)div 2,(m+1)div 2);\nif x>d then\n k := 0\nelse if x=d then\n k := 1\nelse\n k := blackcount(n-2*(x-1),m-2*(x-1))-blackcount(n-2*x,m-2*x);\nwriteln(k);\n{readln;}\nend.\n"}, {"source_code": "var\n n,m,i,j:word;\n k,x,t:longword;\n a,a2:array[1..5000,1..5000] of longint;\n change:boolean;\n \nprocedure add(x,y:word);\nbegin\nif (x>1)and(x1)and(ya2[i,j] then\n begin\n change:=true;\n break;\n end;\n if change then\n break;\n end;\nif change then\n for i:=1 to n do\n for j:=1 to m do\n a2[i,j]:=a[i,j];\nend;\n\nbegin\nt:=0;\nfillchar(a,sizeof(a),0);\nfillchar(a2,sizeof(a2),0);\n\nreadln(n,m);\nreadln(x);\nchange:=false;\nrepeat\n inc(t);\n minute;\n check;\nuntil not change;\n\nk :=0;\nfor i:=1 to n do\n for j:=1 to m do\n if a[i,j]=x-1 then\n inc(k);\nwriteln(k);\nend.\n"}, {"source_code": "var\n k,i,j,res,q,n,m,c,x,y,z : longint;\nbegin\n readln(n,m,q);\n for i:=1 to n do for j:=1 to m do if not odd(i+j) then\n begin\n k:=i;\n if n-i+1 < k then k:=n-i+1;\n if m-j+1 < k then k:=m-j+1;\n if k=q then inc(res);\n end;\n writeln(res);\nend."}, {"source_code": "var\n n,m,x,i,j,x1,y1,x2,y2,sum:longint;\nbegin\n readln(n,m);\n readln(x);\n x1:=1;\n y1:=1;\n x2:=n;\n y2:=m;\n for i:=1 to x-1 do\n begin\n inc(x1);\n inc(y1);\n dec(x2);\n dec(y2);\n if (x1>x2)or(y1>y2) then\n begin\n writeln(0);\n halt;\n end;\n end;\n for i:=x1 to x2 do for j:=y1 to y2 do if odd(i)=odd(j) then\n begin\n if (i=x1)or(j=x2)or(j=y1)or(j=y2) then inc(sum);\n end;\n writeln(sum);\nend.\n"}, {"source_code": "Var n,m,x,i,j,ans,res:longint;\n a:Array[-10..5001,-10..5001]of Longint;\n BEgin\n readln(n,m);\n readln(x);\n if X>2 then BEgin WRiteln(0); halt(0); end;\n For i:=1 to n do\n for j:=1 to m do\n if (i+j) mod 2=0 then a[i,j] := 1;\n For i:=1 to n do\n for j:=1 to m do\n if (a[i,j]=1)and(a[i+1,j+1]=1)and(a[i-1,j+1]=1)and(a[i+1,j-1]=1)and(a[i-1,j-1]=1)\n then inc(res);\n if x=2 then begin writeln(res); halt(0); end;\n ans := 0;\n FOr i:=1 to n do\n for j:=1 to m do\n if a[i,j]=x then inc(ans);\n WRiteln(ans-res);\n End."}, {"source_code": "Var n,m,x,i,j,ans:longint;\n a:Array[-10..5001,-10..5001]of byte;\n BEgin\n readln(n,m);\n readln(x);\n if X>2 then BEgin WRiteln(0); halt(0); end;\n For i:=1 to n do\n for j:=1 to m do\n if (i+j) mod 2=0 then a[i,j] := 1;\n For i:=1 to n do\n for j:=1 to m do\n if (a[i,j]=1)and(a[i+1,j+1]=1)and(a[i-1,j+1]=1)and(a[i+1,j-1]=1)and(a[i-1,j-1]=1)\n then a[i,j] := 2;\n ans := 0;\n FOr i:=1 to n do\n for j:=1 to m do\n if a[i,j]=x then inc(ans);\n WRiteln(ans);\n End."}, {"source_code": "var\nn,m,x,i,j,k,ans:longint;\nbegin\nreadln(n,m);\nreadln(x);\nk:=x;\nx:=x-1;\nif (k>2500)or(n-x*2<=0)or(m-x*2<=0) then ans:=0\nelse begin\n ans:=(n-x*2)*(m-x*2) div 2;\n if ((n-k*2)and(m-k*2)>0) then begin\n ans:=ans-(n-k*2)*(m-k*2) div 2;\n if (n-k*2)*(m-k*2) mod 2<>0 then dec(ans);\n end;\n\nif (n-2*x)*(m-2*x) mod 2<>0 then inc(ans);\n end;\nwriteln(ans);\nend."}, {"source_code": "var\na,b:array [1..5000,1..5000] of longint;\nn,m,x,i,j,k,ans:longint;\nbegin\nreadln(n,m);\nreadln(x);\nfor i:=1 to n do begin\n for j:=1 to m do begin\n if (i+j) mod 2=0 then begin\n a[i,j]:=0;\n b[i,j]:=1;\n end\n else begin\n a[i,j]:=-1;\n b[i,j]:=0;\n end;\n end;\nend;\nans:=1;\nk:=0;\nwhile ans>0 do begin\nans:=0;\n for i:=1 to n-2 do begin\n for j:=1 to m-2 do begin\n if (a[i,j]=k) then begin\n if (a[i+2,j+2]=k)and(a[i+2,j]=k)and(a[i,j+2]=k) then begin\n a[i+1,j+1]:=k+1;\n inc(b[i,j]);\n ans:=1;\n end;\n end;\n end;\n end;\n inc(k);\nend;\nans:=0;\nfor i:=1 to n do begin\n for j:=1 to m do begin\n if b[i,j]=x then inc(ans);\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "var\nn,m,x,i,j,k,ans:longint;\nbegin\nreadln(n,m);\nreadln(x);\nk:=x;\nx:=x-1;\nif (n-x*2<=0)or(m-x*2<=0) then ans:=0\nelse begin\n ans:=(n-x*2)*(m-x*2) div 2;\n if ((n-k*2)and(m-k*2)>0) then begin\n ans:=ans-(n-k*2)*(m-k*2) div 2;\n if (n-k*2)*(m-k*2) mod 2<>0 then dec(ans);\n end;\n\nif (n-2*x)*(m-2*x) mod 2<>0 then inc(ans);\n end;\nwriteln(ans);\nend."}, {"source_code": "var\na,b:array [1..5000,1..5000] of longint;\nn,m,x,i,j,k,ans:longint;\nbegin\nreadln(n,m);\nreadln(x);\nfor i:=1 to n do begin\n for j:=1 to m do begin\n if (i+j) mod 2=0 then begin\n a[i,j]:=0;\n b[i,j]:=1;\n end\n else begin\n a[i,j]:=-1;\n b[i,j]:=0;\n end;\n end;\nend;\nans:=1;\nk:=0;\nwhile ans>0 do begin\nans:=0;\n for i:=k+2 to n-k-1 do begin\n for j:=k+2 to m-k-1 do begin\n a[i+1,j+1]:=k+1;\n inc(b[i,j]);\n ans:=1;\n end;\n end;\n inc(k);\nend;\nans:=0;\nfor i:=1 to n do begin\n for j:=1 to m do begin\n if b[i,j]=x then inc(ans);\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "var n,m,x,l,a,b:longint;\n begin\n read(n,m,x);\n l:=1;\n while (l0) and (m>0) do\n begin\n dec(n,2);\n dec(m,2);\n inc(l);\n if n<=0 then n:=0;\n if m<=0 then m:=0;\n end;\n if l=x then begin\n a:=n-2;\n b:=m-2;\n if a<0 then a:=0;\n if b<0 then b:=0;\n writeln(n*m-a*b)\n end\n else writeln(0);\n end."}, {"source_code": "var\n n,m,x,kq:longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n readln(n,m);\n readln(x);\n n:=n-(x-1)*2; m:=m-(x-1)*2;\n if (n<=0) or (m<=0) then\n begin\n writeln(0);\n exit;\n end;\n if n=1 then\n begin\n kq:=(m+1) div 2;\n writeln(kq);\n exit;\n end;\n if m=1 then\n begin\n kq:=(n+1) div 2;\n writeln(kq);\n exit;\n end;\n kq:=2*((n+1) div 2);\n kq:=kq+2*((m+1) div 2);\n if m mod 2=0 then kq:=kq-3\n else kq:=kq-4;\n writeln(kq);\n\nend;\nbegin\n nhap;\nend.\n"}, {"source_code": "var\n n,m,x,kq:longint;\nprocedure nhap;\nvar\n i:longint;\nbegin\n readln(n,m);\n readln(x);\n if m=1) or (m>=1 ) do\n begin\n inc(i);\n if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n \n xx[i]:= rez;\n n:=n-2;\n m:=m-2;\n end;\n yy[i]:= xx[i];\n sum:=0;\n for j:=i downto 2 do\n begin\n yy[j-1]:= xx[j-1]- xx[j];\n end;\n writeln(yy[x]);\nend.\n \n "}, {"source_code": "var\n xx,yy: array [0..100000]of longint;\n\n n,m ,nn,rez,i,sum,j: longint;\n x : int64;\nbegin\n readln(n,m);\n readln(x);\n { if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n\n \n xx[i]:= rez; }\n if x>=2501 then\n begin\n writeln(yy[x]);\n exit;\n end;\n\n i:=0;\n \n while (n>=1) or (m>=1 ) do\n begin\n inc(i);\n if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n \n xx[i]:= rez;\n n:=n-2;\n m:=m-2;\n end;\n yy[i]:= xx[i];\n sum:=0;\n for j:=i downto 2 do\n begin\n yy[j-1]:= xx[j-1]- xx[j];\n end;\n writeln(yy[x]);\nend.\n \n "}, {"source_code": "var\n xx,yy: array [0..100000]of longint;\n\n n,m ,nn,rez,i,sum,j: longint;\n x : longint;\nbegin\n readln(n,m);\n readln(x);\n { if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n\n \n xx[i]:= rez; }\n i:=0;\n \n while (n>=1) or (m>=1 ) do\n begin\n inc(i);\n if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n \n xx[i]:= rez;\n n:=n-2;\n m:=m-2;\n end;\n yy[i]:= xx[i];\n sum:=0;\n for j:=i downto 1 do\n begin\n sum:=sum+xx[j];\n yy[j-1]:= xx[j-1]- sum;\n end;\n writeln(yy[x]);\nend.\n \n "}, {"source_code": "var\n xx,yy: array [0..100000]of longint;\n\n n,m ,nn,rez,i,sum,j: longint;\n x : int64;\nbegin\n readln(n,m);\n readln(x);\n { if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n\n \n xx[i]:= rez; }\n if x>=2501 then\n begin\n writeln(0);\n exit;\n end;\n\n i:=0;\n \n while (n>=1) or (m>=1 ) do\n begin\n inc(i);\n if n mod 2 = 0 then\n nn:= n div 2\n else nn:= n div 2+1;\n if m mod 2 = 0 then\n rez:= n *(m div 2)\n else rez:= n* (m div 2)+nn;\n \n xx[i]:= rez;\n n:=n-2;\n m:=m-2;\n end;\n yy[i]:= xx[i];\n sum:=0;\n for j:=i downto 2 do\n begin\n yy[j-1]:= xx[j-1]- xx[j];\n end;\n writeln(yy[x]);\nend.\n \n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar\n a,b,m,n,ans,dl,s,x:LongInt;\nbegin\n Readln(n,m);\n Readln(x);\n Dec(x);\n n:=n-(2*x);\n m:=m-(2*x);\n ans:=0;\n if (n>0) and (m>0) then\n begin\n dl:=2*n+2*(m-2);\n ans:=dl div 2;\n end;\n Writeln(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar\n a,b,m,n,ans,ans1,s,x:LongInt;\nbegin\n Readln(n,m);\n Readln(x);\n Dec(x);\n a:=n;\n b:=n;\n n:=n-(2*x);\n m:=m-(2*x);\n ans:=0;\n if (n>0) and (m>0) then\n begin\n s:=n*m;\n ans:=s div 2;\n if s mod 2=1 then Inc(ans);\n Inc(x);\n a:=a-(2*x);\n b:=b-(2*x);\n ans1:=0;\n if (a>0) and (b>0) then\n begin\n s:=a*b;\n ans1:=s div 2;\n if s mod 2=1 then Inc(ans1);\n end;\n ans:=ans-ans1;\n end;\n Writeln(ans);\n readln;\nend.\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, m, x, i, j, ans : integer;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n, m, x);\n ans := 0;\n for i := 1 to n do\n for j := 1 to m do\n if (min(min(i, n - x + 1), min(j, m - x + 1)) = x) and ((i + j) mod 2 = 0) then\n inc(ans);\n writeln(ans);\nend.\n "}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, m, x, i, j, ans : integer;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n, m, x);\n ans := 0;\n for i := 1 to n do\n for j := 1 to m do\n if ((i = x) or (i = n - x + 1)) and ((j = x) or (j = m - x + 1)) and ((i + j) mod 2 = 0) then\n inc(ans);\n writeln(ans);\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, x : longint;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n\n read(n, m, x);\n n := n - (x - 1)*2;\n m := m - (x - 1)*2;\n if (n <= 0) or (m <= 0) then\n begin\n writeln(0);\n halt(0);\n end;\n if m mod 2 = 0 then\n write(n*(m div 2))\n else\n begin\n if n mod 2 = 0 then\n write(((m div 2) + 1)*(n div 2) + (n div 2)*(m div 2))\n else\n write(((m div 2) + 1)*((n div 2) + 1) + (n div 2)*(m div 2));\n end;\n\n // close(input);\n // close(output);\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, x, n2, m2, k : longint;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n\n read(n, m, x);\n n := n - (x - 1)*2;\n m := m - (x - 1)*2;\n n2 := n - 2;\n m2 := m - 2;\n if (n <= 0) or (m <= 0) then\n begin\n writeln(0);\n halt(0);\n end;\n if m mod 2 = 0 then\n k := n*(m div 2)\n else\n begin\n if n mod 2 = 0 then\n k := ((m div 2) + 1)*(n div 2) + (n div 2)*(m div 2)\n else\n k := ((m div 2) + 1)*((n div 2) + 1) + (n div 2)*(m div 2);\n end;\n n := n2;\n m := m2;\n if (n <= 0) or (m <= 0) then\n begin\n writeln(k);\n halt(0);\n end;\n if m mod 2 = 0 then\n k := k - n*(m div 2)\n else\n begin\n if n mod 2 = 0 then\n k := k - ((m div 2) + 1)*(n div 2) + (n div 2)*(m div 2)\n else\n k := k - ((m div 2) + 1)*((n div 2) + 1) + (n div 2)*(m div 2);\n end;\n write(k);\n// close(input);\n// close(output);\nend.\n "}, {"source_code": "var i,j,n,m,res:integer;\n x:longint;\n\n\nbegin\nreadln(n,m);\nreadln(x);\nif (n=1)and(m=1)and(x=1) then res:=1 else\nbegin\n\nx:=x-1;\nres:=(n-2*x)+(m-2*x)-2;\nend;\nif res<0 then res:=0;\nwrite(res);\n\nend."}, {"source_code": "var i,j,n,m:integer;\n x,res:longint;\n\n\nbegin\nreadln(n,m);\nreadln(x);\ndec(x);\nif (n-2*x=1)and(m-2*x=1) then res:=1 else\nbegin\n\nres:=(n-2*x)+(m-2*x)-2;\n\nif (res<0)or(x>2501) then res:=0;\nend;\nwrite(res);\n\n\nend."}, {"source_code": "program shablon;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\nvar\n n,m,x,l,r,l1,r1,mx,a:integer;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n read(n,m,x);\n x := x - 1;\n if min(n,m) < 2*x + 1 then\n begin\n writeln(0);\n halt(0);\n end;\n l := x + 1;\n r := x + 1;\n l1 := n - (x );\n r1 := m - (x );\n a := ((r1 - r + 2) div 2) * 2 + ((l1 - l + 2) div 2) * 2 ;\n if (n mod 2 = 1) and (m mod 2 = 1) then\n a := a - 4\n else if (n mod 2 = 1) or (m mod 2 = 1) then\n a := a -2;\n if (a = 0) then\n a := 1;\n writeln(a);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "program shablon;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\nvar\n n,m,x,l,r,l1,r1,mx,a:integer;\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n read(n,m,x);\n x := x - 1;\n if min(n,m) < 2*x + 1 then\n begin\n writeln(0);\n halt(0);\n end;\n l := x + 1;\n r := x + 1;\n l1 := l;\n r1 := r;\n a := 1;\n while (l1 + 2 + x <= n) do\n inc(l1,2);\n while (r1 + 2 + x <= m) do\n inc(r1,2);\n mx := 0;\n a := ((r1 - r + 2) + (l1 - l + 2) -4);\n if (a = 0) then\n a := 1;\n writeln(a);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "//Yerzhan Dyussenaliyev\nUses Math;\nvar\n\tn, m, k, c, ans, x, y, pr, col: longint;\n\nbegin\n// reset(input, 'a.in');\n// rewrite(output, 'a.out');\n\n read(n, m, k);\n\n\tans := 0;\n\tc := 0;\n x := n;\n y := m;\n\tcol := max(0, ((x + 1) div 2) * ((y + 1) div 2)) + max(0, ((x - 1) div 2) * ((y - 1) div 2));\n while (x > 0) and (y > 0) do begin\n inc(c);\n pr := max(0, ((x + 1) div 2) * ((y + 1) div 2)) + max(0, ((x - 1) div 2) * ((y - 1) div 2));\n\t\tif c = k then begin\n dec(x, 2);\n dec(y, 2);\n col := 0;\n if (x > 0) and (y > 0) then col := max(0, ((x + 1) div 2) * ((y + 1) div 2)) + max(0, ((x - 1) div 2) * ((y - 1) div 2));\n ans := pr - col;\n end;\n\t\tx := x - 2;\n\t\ty := y - 2;\n\tend;\n\n\twriteln(ans);\nend."}, {"source_code": "uses math;\n\nvar n,m,x,k,i,j:integer;\n\nbegin\n read(n,m,x);\n k:=0;\n if not odd(n) then dec(n);\n if not odd(m) then dec(m);\n for i:=1 to n do\n for j:=1 to m do\n if ( ((odd(i)) and (odd(j))) or ((not odd(i)) and (not odd(j))) ) and (x=min(min(i,j),min(n-i+1,m-j+1))) then inc(k);\n write(k)\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar n,m,x,s:Longint;\nbegin\n read(n,m,x);\n Dec(x);\n s:=(n-2*x)*(m-2*x);\n Inc(x);\n s:=s-max(n-2*x,0)*max(m-2*x,0);\n write(s div 2 + s mod 2);\nend.\n"}], "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb"} {"source_code": "uses math;\nvar s:ansistring;\n i,j,k,p,n:longint;\n a:array[-1000..10000] of longint;\nbegin\n readln(s);\n\n n:=length(s);\n\n for i:=1 to n-25 do\n begin\n for j:=1 to 26 do\n a[j]:=0;\n p:=0;\n for j:=i to i+25 do\n if (a[ord(s[j])-64]=1) and (s[j]<>'?') then p:=1 else\n if s[j]<>'?' then inc(a[ord(s[j])-64]);\n\n if p=0 then\n begin\n for j:=i to i+25 do\n if s[j]='?' then\n begin\n for k:=1 to 26 do\n if a[k]=0 then\n begin\n s[j]:=chr(k+64);\n inc(a[k]);\n break;\n end;\n end;\n for j:=1 to n do\n if (s[j]='?') then s[j]:='A';\n writeln(s);\n exit;\n end;\n end;\nwriteln(-1);\nend.", "positive_code": [{"source_code": "var i,j,k1,o,k,o1,l:longint;\nniz:array[0..50] of longint;\na1:char;\na:ansistring;\nbegin\nread (a);\no1:=0;\nfor i:=1 to length(a) do\nbegin\n if (a[i]='?') then k:=k+1\n\n else\n niz[ord(a[i])-64]:=niz[ord(a[i])-64]+1;\n\n if (i>=26) then\n begin\n o:=0;\n k1:=0;\n for j:=1 to 26 do\n begin\n if niz[j]>1 then\n begin\n o:=1;\n break;\n end\n else if niz[j]=0 then\n begin\n k1:=k1+1;\n end;\n end;\n if (o=0) and (k1=k) then\n begin\n l:=1;\n for j:=i-26+1 to i do\n begin\n if a[j]='?' then\n begin\n while (niz[l]>0) do\n begin\n l:=l+1;\n end;\n a1:=chr(l+64);\n delete (a,j,1);\n insert(a1,a,j);\n niz[l]:=1;\n end;\n end;\n o1:=1;\n break;\n end;\n if (a[i-26+1]='?') then\n k:=k-1\n else\n niz[ord(a[i-26+1])-64]:=niz[ord(a[i-26+1])-64]-1;\n end;\nend;\nif o1=0 then\nwriteln ('-1')\nelse\nbegin\n for i:=1 to length(a) do\n begin\n if a[i]='?' then\n begin\n\n delete (a,i,1);\n insert('A',a,i);\n end;\n end;\n\n write (a);\nend;\nend."}, {"source_code": "var i,j,m,n,len,k:longint;\n pfx:array[0..50005,0..25]of longint;\n s:ansistring;\n used:array[0..25]of boolean;\n flag:boolean;\nbegin\n readln(s);\n len:=length(s);\n for i:=1 to len do begin\n if s[i]='?' then begin\n for j:=0 to 25 do pfx[i,j]:=pfx[i-1,j];\n end else begin\n for j:=0 to 25 do if ord('A')+j<>ord(s[i]) then pfx[i,j]:=pfx[i-1,j] else pfx[i,j]:=pfx[i-1,j]+1;\n end;\n end;\n\n if len<26 then writeln(-1) else begin\n for i:=1 to len-25 do begin\n flag:=true;\n for j:=0 to 25 do begin\n if pfx[i+25,j]-pfx[i-1,j]>1 then flag:=false;\n end;\n if flag then begin\n for j:=1 to i-1 do if s[j]='?' then write('A') else write(s[j]);\n fillchar(used,sizeof(used),false);\n for j:=i to i+25 do if s[j]<>'?' then used[ord(s[j])-ord('A')]:=true;\n //writeln(i);\n\n for j:=i to i+25 do begin\n if s[j]<>'?' then write(s[j]) else begin\n for k:=0 to 25 do if used[k]=false then begin\n write(chr(k+ord('A')));\n used[k]:=true;\n break;\n end;\n end;\n end;\n for j:=i+26 to len do if s[j]='?' then write('A') else write(s[j]);\n writeln;\n //close input output\n halt;\n end;\n end;\n writeln(-1);\n end;\n //writeln(-1);\nend.\n"}, {"source_code": "var\n i,j,k,n,t,l,l1,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,s1,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \nfunction proverka(s:ansistring):boolean;\nvar alp,s1:ansistring;\ni,j,l,k1:longint;\nx:array[1..260000]of integer;\nflag,flag1:integer;\n begin\n l:=length(s);\n flag1:=0;\n for k1:=1 to l-25 do begin \n s1:=copy(s,k1,26);\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n //s1:=copy(s,i,26);\n flag:=1;\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for j:=1 to 26 do\n if x[j]=0 then flag:=0;\n if flag=1 then begin\n // writeln(s1);\n flag1:=1;\n end;\n end; \n proverka:=(flag1=1);\n end;\nbegin\n readln(s);\n/// writeln(s);\nl:=length(s);\nif l<26 then writeln(-1)\n else begin\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n// while ((i<=l)and(flag1=0)) do begin\n // s1:=copy(s,i,26);\n// flag:=1;\n// for j:=1 to 26 do\n // x[j]:=0;\n // for j:=1 to 26 do begin\n // if (s1[j]=alp[j])then x[j]:=1;\n// end;\n // for j:=1 to 26 do\n // if x[j]=0 then flag:=0;\n// if flag=1 then flag1:=1\n// else i:=i+1; \n// end;\n// if flag1=1 then begin\n // while (pos('?',s)<>0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for k1:=1 to l-25 do begin\n s1:=copy(s,k1,26);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for i:=1 to 26 do begin\n if (s1[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s1[i]:=alp[j];\n x[j]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n if proverka(s1) then begin \n while (pos('?',s1)<>0) do begin\n i:=pos('?',s1);\n delete(s1,i,1);\n insert('A',s1,i);\n end;\n delete(s,k1,26);\n insert(s1,s,k1);\n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n end;\n // writeln(s1);\n end;\n//writeln(s);\n if (proverka(s)) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": " {$mode objfpc}\n {$coperators on}\nuses math;\nconst\n {$ifdef online_judge} fi=''; fo='';\n {$else} fi='inp.inp';\n fo='out.out';\n {$endif}\n\nvar\n f : array['A'..'Z']of longint;\n q : longint;\n s, res, rr, rrr : ansistring;\n mis : array[1..40] of char;\nprocedure enter;\nvar i, j : integer;\n begin\n readln(s);\n if length(s)<26 then\n begin\n writeln(-1); halt;\n end;\n end;\nprocedure ahihi(l,r:longint);\nvar i:char; b:boolean; c, ii:longint;\n begin\n c:=0;\n for i:='A' to 'Z' do if f[i]=0 then\n begin\n inc(c);\n mis[c]:=i;\n end;\n if q=c then\n begin\n for ii:=1 to l-1 do if s[ii]<>'?' then write(s[ii]) else write('A');\n c:=1;\n for ii:=l to r do\n begin\n if s[ii]<>'?' then write(s[ii]) else\n begin\n write(mis[c]);\n c+=1;\n end;\n end;\n for ii:=r+1 to length(s) do if s[ii]<>'?' then write(s[ii]) else write('A');\n halt;\n end;\n end;\nprocedure solve;\nvar i, j : integer;\n begin\n q:=0;\n for i:=1 to 26 do\n begin\n if s[i]<>'?' then f[s[i]]+=1 else q:=q+1;\n end;\n i:=1; j:=26;\n while(j<=length(s))do\n begin\n ahihi(i,j);\n if s[i]<>'?' then f[s[i]]-=1 else q-=1;\n i+=1; j+=1;\n if j>length(s) then break;\n if s[j]<>'?' then f[s[j]]+=1 else q+=1;\n end;\n writeln(-1);\n end;\nbegin\n\n assign(input, fi); assign(output, fo); reset(input); rewrite(output);\n enter;\n solve;\n close(input); close(output);\nend.\n\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i, j, jj, n, k, q : longint;\n alf :array['A'..'Z']of longint;\n kol, cur : longint;\n s : string;\n\nfunction check(num : longint) : boolean;\nvar q, kk : longint;\n c : char;\nbegin\n kk := 0;\n for c := 'A' to 'Z' do\n if alf[c] > 1 then\n begin\n check := False;\n exit;\n end\n else\n if alf[c] = 0 then\n inc(kk);\n\n if kk > cur then\n check := False\n else\n check := True;\nend;\n\nprocedure make(num : longint);\nvar i : longint;\n c, t : char;\nbegin\n\n for i := 1 to num-1 do\n if s[i] = '?' then\n s[i] := 'A';\n\n for i := num+26 to n do\n if s[i] = '?' then\n s[i] := 'A';\n\n for i := num to num+25 do\n if s[i] = '?' then\n begin\n for t := 'A' to 'Z' do\n if alf[t] = 0 then\n begin\n alf[t] := 1;\n s[i] := t;\n break;\n end;\n end;\nend;\n\nbegin\n// assign(input, 'input.txt'); assign(output, 'output.txt');\n\n readln(s);\n n := length(s);\n\n if n < 26 then\n begin\n writeln(-1);\n exit;\n end;\n\n cur := 0;\n for i := 1 to 26 do\n if s[i] = '?' then\n inc(cur)\n else\n inc(alf[s[i]]);\n\n if check(1) then\n begin\n make(1);\n writeln(s);\n exit;\n end;\n\n for i := 27 to n do\n begin\n if s[i-26] <> '?' then\n dec(alf[s[i-26]])\n else\n dec(cur);\n if s[i] = '?' then\n inc(cur)\n else\n inc(alf[s[i]]);\n\n if check(i-26+1) then\n begin\n make(i-26+1);\n writeln(s);\n exit;\n end;\n end;\n\n writeln(-1);\nend.\n"}, {"source_code": "{$H+}\nvar\n i,res,sn : longint;\n c : char;\n st : string;\n ok,ok2 : boolean;\n s : array['A'..'Z',0..50000] of longint;\n sc : array[0..50000] of char;\n\nbegin\n readln(st);\n for i := 1 to length(st) do\n for c := 'A' to 'Z' do\n s[c,i] := s[c,i-1] + ord(c = st[i]);\n ok := false;\n for i := 1 to length(st) - 26 + 1 do\n begin\n ok2 := true;\n for c := 'A' to 'Z' do\n if s[c,i+25] - s[c,i-1] > 1 then\n begin\n ok2 := false;\n break;\n end;\n if ok2 then\n begin\n ok := true;\n res := i;\n break;\n end;\n end;\n if ok then\n begin\n for c := 'A' to 'Z' do\n if s[c,i+25] - s[c,i-1] = 0 then\n begin\n inc(sn);\n sc[sn] := c;\n end;\n for i := res to res + 25 do\n if st[i] = '?' then\n begin\n st[i] := sc[sn];\n dec(sn);\n end;\n for i := 1 to length(st) do\n if st[i] = '?' then st[i] := 'A';\n writeln(st);\n end\n else writeln(-1)\nend."}, {"source_code": "var\n s : ansistring;\n n, i, j : longint;\n has : array['A'..'Z'] of boolean;\n ok, flg : boolean;\n c : char;\n\nbegin\n readln(s);\n n := length(s);\n if (n < 26) then\n begin\n writeln(-1);\n exit;\n end;\n for i := 1 to n - 26 + 1 do\n begin\n fillchar(has, sizeof(has), false);\n ok := true; flg := false;\n for j := i to i + 25 do\n if (s[j] <> '?') then\n begin\n if (has[s[j]]) then\n begin\n ok := false;\n break;\n end\n else has[s[j]] := true;\n end\n else flg := true;\n if (ok) then\n begin\n if (flg) then\n begin\n for j := i to i + 25 do\n begin\n if (s[j] = '?') then\n begin\n for c := 'A' to 'Z' do\n begin\n if not (has[c]) then\n begin\n has[c] := true;\n s := copy(s, 1, j - 1) + c + copy(s, j + 1, n - j);\n break;\n end;\n end;\n end;\n end;\n end;\n for j := 1 to n do \n if (s[j] = '?') then s := copy(s, 1, j - 1) + 'A' + copy(s, j + 1, n - j);\n writeln(s);\n exit;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "\nconst\n tfi='';\n tfo='';\n\nvar\n fi, fo: text;\n s: ansistring;\n f, res: array[0..27] of boolean;\n\nprocedure __;\nvar\n i, j, empty, cnt, dau, cuoi, n: longint;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, s); n:= length(s);\n if n<26 then\n begin\n writeln(fo, -1); exit;\n end;\n dau := -1;\n for i:=1 to n-26+1 do\n begin\n fillchar(f, sizeof(f), false);\n empty := 0; cnt := 0;\n for j:=i to i+25 do\n if s[j]='?' then inc(empty)\n else if not f[ord(s[j])-64] then\n begin\n f[ord(s[j])-64] := true;\n inc(cnt);\n end;\n if cnt+empty=26 then\n begin\n res := f;\n dau := i; cuoi := i+25;\n break;\n end;\n end;\n if dau=-1 then\n begin\n writeln(fo, -1); exit;\n end;\n for i:=1 to n do\n if (dau<=i) and (i<=cuoi) then\n begin\n if s[i]='?' then\n begin\n for j:=1 to 26 do\n if not res[j] then\n begin\n write(fo, char(j+64)); res[j] := true; break;\n end;\n end\n else write(fo, s[i]);\n end\n else\n begin\n if s[i]='?' then write(fo, 'A') else write(fo, s[i]);\n end;\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n __;\n _;\nEND.\n"}, {"source_code": "function nice(var s:string):boolean;\n var i,sum,temp:integer;\n r:boolean;\n x:char;\n ans:string;\n a:array['A'..'Z'] of integer;\nbegin\n temp:=0;\n ans:=s;\n sum:=0;\n for x:='A' to 'Z' do a[x]:=0;\n for i:=1 to length(S) do \n if (s[i]='?') then temp:=temp+1 else a[s[i]]:=1;\n for x:='A' to 'Z' do sum:=sum+a[x];\n if (sum+temp<26) then nice:=false else begin\n for x:='A' to 'Z' do begin\n if ((a[x]=0) and (temp>0)) then begin\n insert(x,ans,pos('?',ans));\n delete(ans,pos('?',ans),1);\n end;\n end;\n s:=ans;\n nice:=true;\n end;\n \nend;\nvar m,t:string;\n i:integer;\n ans:boolean;\nbegin\n readln(m);\n ans:=false;\n t:='';\n if (length(m)<26) then write(-1) else begin\n for i:=1 to length(m)-25 do begin\n t:=copy(m,i,26);\n if nice(t) then begin\n ans:=true;\n delete(m,i,26);\n insert(t,m,i);\n break;\n end;\n end;\n if not ans then write(-1) ELSE begin\n for i:=1 to length(m) do if m[i]='?' then m[i]:='A';\n writeln(m);\n end;;\n end;\nend."}, {"source_code": "var a:array[1..26] of longint;\nst:ansistring;\nn,i,j,nom,nom2,l,r:longint;\nsim:char;\nf2,f3:boolean;\n\nprocedure prov(var f:boolean);\nbegin\n f:=true;\n for j:=1 to 26 do\n if a[j]>1 then begin\n f:=false;\n exit;\n end;\nend;\n\n\nbegin\n readln(st);\n n:=length(st);\n\n if n<26 then begin\n writeln(-1);\n halt;\n end;\n for i:=1 to 26 do\n begin\n sim:=st[i];\n if sim<>'?' then begin\n nom:=ord(sim);\n nom2:=nom-64;\n a[nom2]:=a[nom2]+1;\n end;\n end;\n\n f3:=false;\n prov(f2);\n if f2=true then\n begin\n l:=1;\n r:=26;\n f3:=true;\n end;\n\n for i:=27 to n do\n begin\n sim:=st[i];\n if sim<>'?' then begin\n nom:=ord(sim);\n nom2:=nom-64;\n a[nom2]:=a[nom2]+1;\n end;\n\n sim:=st[i-26];\n if sim<>'?' then begin\n nom:=ord(sim);\n nom2:=nom-64;\n a[nom2]:=a[nom2]-1;\n end;\n\n prov(f2);\n if f2=true then\n begin\n l:=i-25;\n r:=i;\n f3:=true;\n break;\n end;\n end;\n\n if f3=false then\n begin\n writeln(-1);\n halt;\n end;\n\n for i:=1 to 26 do\n begin\n if a[i]=0\n then\n begin\n sim:=chr(i+64);\n for j:=l to r do\n if st[j]='?' then begin\n st[j]:=sim;\n break;\n end;\n end;\n end;\n\n for i:=1 to n do\n if st[i]='?' then st[i]:='A';\n\n writeln(st);\n\nend."}, {"source_code": "var a:array[1..26] of longint;\nst,alf:ansistring;\ni,n,p,p2,kl,kl2,j,l1,l2:longint;\nsim,sim2:char;\nbegin\n readln(st);\n alf:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n n:=length(st);\n if n<26 then\n begin\n writeln(-1);\n halt;\n end;\n for i:=1 to 26 do\n begin\n sim:=st[i];\n if sim<>'?' then\n begin\n p:=pos(sim,alf);\n a[p]:=a[p]+1;\n end;\n end;\n\n kl:=0;\n for i:=1 to 26 do\n if a[i]>1 then begin\n kl:=1;\n break;\n end;\n if kl=0 then begin\n l1:=1;\n l2:=26;\n kl2:=1;\n end;\n\n for i:=27 to n do\n begin\n sim:=st[i];\n if sim<>'?' then\n begin\n p:=pos(sim,alf);\n a[p]:=a[p]+1;\n end;\n sim2:=st[i-26];\n if sim2<>'?' then\n begin\n p2:=pos(sim2,alf);\n a[p2]:=a[p2]-1;\n end;\n kl:=0;\n for j:=1 to 26 do\n if a[j]>1 then begin\n kl:=1;\n break;\n end;\n if kl=0 then begin\n l1:=i-26+1;\n l2:=i;\n kl2:=1;\n break;\n end;\n end;\n\n if kl2=0 then writeln(-1)\n else\n BEGIN\n for i:=1 to 26 do\n if a[i]=0 then\n begin\n for j:=l1 to l2 do\n if st[j]='?' then begin\n st[j]:=alf[i];\n break;\n end;\n end;\n for i:=1 to n do\n if st[i]='?' then st[i]:='A';\n writeln(st);\n END;\nend."}, {"source_code": "{$H+}\nvar\n a, b, c, d, i, j, t: int64;\n s: string;\n q: boolean;\n ar: array [1..1000] of int64;\n\nbegin\n readln(s);\n q := false;\n if length(s) < 26 then begin\n writeln(-1);\n halt();\n end;\n i := 1;\n a := 0;\n b := 0;\n while i <= 26 do \n begin\n if s[i] = '?' then begin\n inc(b);\n end\n else if ar[ord(s[i])] = 0 then begin\n ar[ord(s[i])] := 1;\n inc(a);\n end\n else inc(ar[ord(s[i])]);\n inc(i);\n end;\n while i <= length(s) do \n begin\n if a + b = 26 then begin\n j := i - 26;\n q := true;\n while j < i do \n begin\n if s[j] <> '?' then \n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n s[j] := chr(t);\n break;\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n end;\n if s[i - 26] = '?' then dec(b)\n else begin\n if ar[ord(s[i - 26])] = 1 then dec(a);\n dec(ar[ord(s[i - 26])]);\n end;\n if s[i] = '?' then inc(b)\n else begin\n if ar[ord(s[i])] = 0 then inc(a);\n inc(ar[ord(s[i])]);\n end;\n inc(i);\n end;\n if a + b = 26 then begin\n q := true;\n j := i - 26;\n while j < i do \n begin\n if s[j] <> '?' then \n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n s[j] := chr(t);\n break;\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n end;\n if q then begin\n i := 1;\n while i <= length(s) do begin\n if s[i] = '?' then write('A')\n else write(s[i]);\n inc(i);\n end;\n end\n else writeln(-1);\nend."}, {"source_code": "var\ni,j,jj,k,x,y,z: longint;\ns: ansistring;\na: array['A'..'Z'] of boolean;\nc: char;\nnice: boolean;\nbegin\n\treadln(s);\n\tif length(s)<26 then\n\tbegin\n\t\twriteln(-1);\n\t\thalt;\n\tend;\n\tfor j:= 1 to length(s)-25 do\n\tbegin\n\t\tfor c:='A' to 'Z' do\n\t\t\ta[c]:=false;\n\t\tnice:=true;\n\t\tfor k:= j to j+25 do\n\t\t\tif s[k]<>'?' then\n\t\t\t\tif a[s[k]] then\n\t\t\t\tbegin\n\t\t\t\t\tnice:=false;\n\t\t\t\t\tbreak;\n\t\t\t\tend else\n\t\t\t\ta[s[k]]:=true;\n\t\tif nice then\n\t\tbegin\n\t\t\tz:=j;\n\t\t\tbreak;\n\t\tend;\n\tend;\n\tif z=0 then\n\tbegin\n\t\twriteln(-1);\n\t\thalt;\n\tend;\n\tfor j:= z to z+25 do\n\t\tif s[j]='?' then\n\t\t\tfor c:='A' to 'Z' do\n\t\t\t\tif a[c]=false then\n\t\t\t\tbegin\n\t\t\t\t\ta[c]:=true;\n\t\t\t\t\ts[j]:=c;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\tfor j:= 1 to length(s) do\n\t\tif s[j]='?' then\n\t\t\ts[j]:='A';\n\twriteln(s);\nend."}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:string;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break;\n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(1,26)\nelse\nbegin\nfor i:=2 to length(s)-25 do\nif s[i-1]<>'?' then\n begin\n if a[s[i-1]]=2 then dec(top);\n dec(a[s[i-1]]);\n if s[i+25]<>'?' then\n begin\n if a[s[i+25]]=1 then inc(top);\n inc(a[s[i+25]]);\n end;\n if top=0 then\n begin\n tx(i,i+25);\n break;\n end;\n end\nelse\n begin\n if s[i+25]<>'?' then\n begin\n if a[s[i+25]]=1 then inc(top);\n inc(a[s[i+25]]);\n end;\n if top=0 then\n begin\n tx(i,i+25);\n break;\n end;\n end;\nend;\nif h=1 then\n writeln(s)\nelse\n writeln('-1');\nend;\nend.\n"}, {"source_code": "var s,s1,so:ansistring;\na:array[1..26]of longint;\ni,n,f,j,f1,l,k:longint;\nbegin\nreadln(so);\nfor i:=1 to length(so)-25 do\nbegin\ns:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nl:=1;\nfor j:=i to i+25 do begin\ns[l]:=so[j];\nl:=l+1;\nend;\nfor j:=1 to 26 do\na[j]:=0;\nn:=length(s);\nif n<26 then begin writeln(-1); exit; end; \ns1:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nfor l:=1 to 26 do\n for j:=1 to n do\nif s1[l]=s[j] then a[l]:=a[l]+1;\nl:=1;\nwhile l<=n do begin\nif s[l]='?' then for j:=1 to 26 do\nif a[j]=0 then begin\na[j]:=1; s[l]:=s1[j];\nbreak;\nend;\nl:=l+1;\nend;\n\nf:=0;\nfor l:=1 to 26 do\nif a[l]<>1 then f:=1;\nif (n=26) and(f=0) then begin f1:=1;k:=1; for j:=i to i+25 do begin so[j]:=s[k];k:=k+1; end; break; end; \nend;\nif f1=0 then writeln(-1)\nelse begin \nfor i:=1 to length(so) do\nif so[i]='?' then so[i]:='A';\nwriteln(so);\nend;\nend.\n "}, {"source_code": "var s:ansistring;\n\tcount:array[0..50001,0..27] of longint;\n\ttest,check:boolean;\n\ti,j,k,n,g:longint;\n\tused:array[0..27] of boolean;\nbegin\n //assign(input,'716B.inp'); reset(input);\n\t//assign(output,'716B.out'); rewrite(output);\n\treadln(s);\n\tn:=length(s);\n\tfor i:=1 to n do\n begin\n if s[i]<>'?' then count[i,ord(s[i])-64]:=count[i-1,ord(s[i])-64]+1;\n for j:=1 to 26 do if j<>ord(s[i])-64 then count[i,j]:=count[i-1,j];\n end;\n\ttest:=false;\n randomize;\n\tif n>25 then\n\tbegin\n\t\tfor i:=1 to n-25 do\n\t\tbegin\n\t\t\tj:=i+25;\n check:=false;\n\t\t\tfor k:=1 to 26 do\n\t\t\tbegin\n if count[j,k]-count[i-1,k]>1 then check:=true;\n\t\t\t\tif count[j,k]-count[i-1,k]=1 then used[k]:=true\n else used[k]:=false;\n\n\t\t\tend;\n\t\t\tif not check then\n\t\t\tbegin\n\t\t\t\tfor k:=i to j do\n\t\t\t\t\tif s[k]='?' then\n\t\t\t\t\t\tfor g:=1 to 26 do\n\t\t\t\t\t\t\tif used[g]=false then begin s[k]:=chr(g+64); used[g]:=true; break; end;\n\t\t\t\ttest:=true;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\tend;\n\t\tfor i:=1 to n do if s[i]='?' then s[i]:='A';\n\t\tif not test then write(-1) else write(s);\n\tend\n\telse write(-1);\n\t//close(input); close(output);\nend.\n"}, {"source_code": "const\n fi='';\nvar\n res,st:ansistring;\n a:array[0..50000,0..27] of longint;\n chuaxet:array[0..27] of boolean;\n ok:boolean;\n f:Text;\n j,n,i,tg:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,st);\n n:=length(st);\n if n<26 then\n begin\n writeln(-1); exit;\n end;\n for i:=1 to n do\n if st[i]<>'?' then\n begin\n tg:=ord(st[i])-65+1;\n inc(a[i,tg]);\n end;\n res:=st;\n for i:=1 to n do\n for j:=1 to 26 do a[i,j]:=a[i,j]+a[i-1,j];\n for i:=1 to n-26+1 do\n begin\n fillchar(chuaxet,sizeof(chuaxet),true);\n ok:=true;\n for j:=1 to 26 do\n if a[i+26-1,j]-a[i-1,j]>=2 then\n begin\n ok:=false;\n end\n else if a[i+26-1,j]-a[i-1,j]=1 then chuaxet[j]:=false;\n if ok then\n begin\n tg:=1;\n for j:=i to i+26-1 do\n if st[j]<>'?' then res[j]:=st[j]\n else\n begin\n while (tg<=26) and (not chuaxet[tg]) do inc(tg);\n res[j]:=char(tg+65-1);\n inc(tg);\n end;\n for j:=1 to n do\n if res[j]='?' then res[j]:='A';\n writeln(Res);\n readln;\n exit;\n end;\n end;\n writeln(-1);\n readln;\nend.\n\n"}, {"source_code": "var\n s:ansistring;\n a:array[65..90]of longint;\n n,k,i,l,r,p,j:longint;\n\nprocedure ans(s:ansistring);\nbegin\n writeln(s);\n halt;\nend;\n\nfunction check:boolean;\nvar\n i,k1:longint;\nbegin\n k1:=0;\n for i:=65 to 90 do if a[i]>1 then exit(false) else if a[i]=1 then inc(k1);\n if k1+k=26 then exit(true) else exit(false);\nend;\n\n\nbegin\n readln(s);\n if length(s)<26 then ans('-1');\n for i:=1 to 26 do if s[i]<>'?' then inc(a[ord(s[i])]) else inc(k);\n l:=1;\n r:=26;\n\n if check then\n begin\n p:=64;\n for i:=1 to length(s) do if s[i]='?' then\n begin\n if (ir) then s[i]:='A' else\n begin\n for j:=p+1 to 90 do if a[j]=0 then\n begin\n s[i]:=chr(j);\n p:=j;\n break;\n end;\n end;\n end;\n ans(s);\n end else if length(s)=26 then ans('-1');\n\n\n\n repeat\n inc(r);\n if s[r]<>'?' then inc(a[ord(s[r])]) else inc(k);\n if s[l]<>'?' then dec(a[ord(s[l])]) else dec(k);\n inc(l);\n if check then\n begin\n p:=64;\n for i:=1 to length(s) do if s[i]='?' then\n begin\n if (ir) then s[i]:='A' else\n begin\n for j:=p+1 to 90 do if a[j]=0 then\n begin\n s[i]:=chr(j);\n p:=j;\n break;\n end;\n end;\n end;\n ans(s);\n end;\n until r=length(s);\n ans('-1');\nend."}, {"source_code": "var a:array[0..30] of longint;\nst:ansistring;\nalf:string;\nn,i,j,p,kl,q:longint;\nbegin\n alf:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n readln(st);\n n:=length(st);\n if n<26 then begin\n writeln('-1');\n halt;\n end;\n for i:=1 to 26 do\n begin\n p:=pos(st[i],alf);\n a[p]:=a[p]+1;\n end;\n\n kl:=0;\n for i:=1 to 26 do\n if a[i]>1 then begin\n kl:=1;\n break;\n end;\n if kl=0 then\n begin\n for i:=1 to 26 do\n if a[i]=0 then begin\n p:=pos('?',st);\n st[p]:=alf[i];\n a[i]:=a[i]+1;\n end;\n for i:=1 to n do\n if st[i]<>'?' then write(st[i])\n else write('A');\n halt;\n end;\n\n for j:=2 to n-25 do\n begin\n p:=pos(st[j-1],alf);\n a[p]:=a[p]-1;\n p:=pos(st[j+25],alf);\n a[p]:=a[p]+1;\n\n kl:=0;\n for i:=1 to 26 do\n if a[i]>1 then begin\n kl:=1;\n break;\n end;\n if kl=0 then\n begin\n for i:=1 to 26 do\n if a[i]=0 then begin\n for q:=j to j+25 do\n if st[q]='?' then begin\n st[q]:=alf[i];\n a[i]:=a[i]+1;\n break;\n end;\n end;\n for i:=1 to n do\n if st[i]<>'?' then write(st[i])\n else write('A');\n halt;\n end;\n end;\n writeln('-1');\nend.\n"}, {"source_code": "var s:ansistring;\n i,j,k,dem,sl:longint;\n kt:array[0..1000000] of longint;\nprocedure nhap;\n begin\n readln(s);\n end;\n\nprocedure xuli;\n begin\n For i:=1 to length(s)-26+1 do\n begin\n For j:=i to i+26-1 do\n begin\n if (kt[ord(s[j])]=0) and (s[j]<>'?') then\n begin\n inc(dem);\n kt[ord(s[j])]:=1;\n end;\n if s[j]='?' then inc(sl);\n end;\n if dem+sl=26 then\n begin\n For j:=i to 26-1+i do\n if s[j]='?' then\n begin\n For k:=65 to 90 do\n if kt[k]=0 then\n begin\n s[j]:=chr(k);\n kt[k]:=1;\n break;\n end;\n end;\n For j:=1 to length(s) do\n if s[j]='?' then write('A') else write(s[j]);\n halt;\n end;\n For j:=i to i+26-1 do\n kt[ord(s[j])]:=0;\n dem:=0;\n sl:=0;\n end;\n writeln(-1);\n end;\n\nbegin\nnhap;\nxuli;\nend."}, {"source_code": "var a:array['A'..'Z']of longint;\n n,i,l,r:longint;\n s,ans:ansistring;\n c:char;\n b:boolean;\nprocedure finish;\nbegin\n for i:=l to r do\n if s[i]='?'then\n for c:='A' to 'Z' do\n if a[c]=0 then \n begin \n a[c]:=1; \n s[i]:=c;\n break; \n end;\n for i:=1 to n do\n if s[i]='?' then s[i]:='A';\n writeln(s);\n halt;\nend;\nbegin\n ans:='';\n readln(s);\n n:=length(s);\n for c:='A' to 'Z' do a[c]:=0;\n if n<26 then\n begin\n write(-1);\n halt;\n end;\n l:=1; r:=26;\n while r<=n do\n begin\n for c:='A' to 'Z' do a[c]:=0;\n b:=true;\n for i:=l to r do\n if s[i]<>'?' then\n begin\n inc(a[s[i]]);\n if a[s[i]]=2 then \n begin \n l:=l+1;\n r:=l+25; \n b:=false; \n break;\n end;\n end;\n if b then finish;\n end;\n write(-1);\nend."}, {"source_code": " var\n s:ansistring;\n\n b,c:array[1..100000] of longint;\n\n i,j,countz,countt,countv,f,vern,fv:longint;\n begin\n readln(s);\n\n vern:=0;\n\n fv:=0;\n\n\n for i:=1 to length(s)-26+1 do begin\n\n for j:=1 to 26 do begin c[j]:=0; b[j]:=0; end;\n\n for j:=i to i+25 do\n if s[j]<>'?' then inc(b[ord(s[j])-64]);\n\n countz:=0;\n for j:=1 to 26 do if b[j]=0 then begin inc(countz); c[countz]:=j; end;\n\n countv:=0;\n for j:=i to i+25 do if s[j]='?' then inc(countv);\n\n countt:=0;\n\n for j:=1 to 26 do if b[j]>1 then inc(countt);\n\n if countt=0 then begin\n\n inc(vern);\n\n f:=0;\n\n for j:=i to i+25 do begin\n if s[j]='?' then begin inc(f); s[j]:=chr(64+c[f]); end;\n\n end;\n break;\n end;\n end;\n for i:=1 to length(s) do if s[i]='?' then s[i]:='A';\n if vern=0 then write(-1) else\n write(s);\n end."}, {"source_code": "var \n s:ansistring;\n len,i:longint;\n flag:boolean;\n \nprocedure comp(x:longint);\nconst\n ch:array[1..26] of char=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');\nvar \n num:array[1..26] of longint;\n numq,i,j:longint;\nbegin \n fillchar(num,sizeof(num),0);\n numq:=0;\n for i:=x to x+25 do \n if (s[i]>='A')and(s[i]<='Z') then inc(num[ord(s[i])-64]) else inc(numq);\n for i:=x to x+25 do \n if s[i]='?' then begin \n j:=1;\n while num[j]<>0 do inc(j);\n num[j]:=1;\n s[i]:=ch[j];\n end;\nend;\n\nprocedure check(x:longint);\nvar\n num:array[1..26] of longint;\n i:longint;\nbegin \n fillchar(num,sizeof(num),0);\n for i:=x to x+25 do\n if (s[i]>='A')and(s[i]<='Z') then begin \n inc(num[ord(s[i])-64]);\n if num[ord(s[i])-64]>1 then begin flag:=false;exit;end;\n end;\n flag:=true;\nend;\n\nbegin \n readln(s);\n len:=length(s);\n if len<26 then begin writeln('-1');exit;end;\n for i:=1 to len-25 do begin \n check(i);\n\tif flag then begin comp(i);break;end;\n end;\n //writeln(s);\n// writeln(len);\n if flag then begin \n for i:=1 to len do \n if s[i]='?' then s[i]:='A';\n writeln(s);\n end else writeln('-1');\nend."}, {"source_code": "var alf,st:ansistring;\nl,i,j,kol,p,q,kl:longint;\na:array[0..100] of longint;\nbegin\n alf:='QWERTYUIOPASDFGHJKLZXCVBNM';\n readln(st);\n l:=length(st);\n if l<26 then begin\n writeln(-1);\n halt;\n end;\n for q:=1 to l-26+1 do\nBEGIN\n for i:=1 to 26 do\n a[i]:=0;\n kl:=0;\n for i:=q to q+25 do\n if st[i]<>'?' then begin\n p:=0;\n p:=pos(st[i],alf);\n if a[p]=1 then kl:=1\n else if a[p]=0 then a[p]:=1;\n end\n else kol:=kol+1;\n\n if kl<>1 then begin\n for i:=q to q+25 do\n if st[i]='?' then begin\n for j:=1 to 26 do\n if a[j]=0 then begin\n a[j]:=1;\n break;\n end;\n st[i]:=alf[j];\n end;\n kl:=10;\n end;\n if kl=10 then begin\n for i:=1 to l do\n if st[i]='?' then st[i]:='A';\n writeln(st);\n halt;\n end;\nEND;\n writeln(-1);\nend.\n"}, {"source_code": "var s,t,r:ansistring;n,i,j,k:longint;a:array['A'..'Z']of longint;chk:boolean;\nbegin\n readln(s);t:='';chk:=false;k:=0;if length(s)>=26 then\n begin\n for i:=1 to length(s)-26+1 do\n begin\n chk:=true;fillchar(a,sizeof(a),0);\n for j:=i to i+25 do if s[j]<>'?' then\n begin\n if a[s[j]]=0 then a[s[j]]:=1 else\n begin\n chk:=false;break;\n end;\n end;if chk then\n begin\n for j:=1 to 26 do\n if a[chr(j+64)]=0 then t:=t+chr(j+64);\n k:=i;\n end;if chk then break;\n end;\n end;if chk then\n begin\n j:=k;for i:=1 to length(t)do\n begin\n while (s[j]<>'?')and(j 1) then nice:= false;\n end;\n if not(nice) then continue;\n if (chamhoi - top <> 0) then continue;\n for j:= i to i + 25 do\n if (s[j] = '?') then\n begin\n s[j]:= b[top];\n dec(top);\n end;\n for j:= 1 to length(s) do\n if (s[j] = '?') then s[j]:= 'A';\n writeln(s);\n halt;\n end;\n end;\n writeln(-1);\n //close(input); close(output);\nend.\n"}, {"source_code": "var a:array['A'..'Z']of longint;\nn,i,l,r:longint;\ns,ans:ansistring;\nc:char;\nb:boolean;\n\nprocedure finish;\nbegin\nfor i:=l to r do\nif s[i]='?'then\nfor c:='A' to 'Z' do\nif a[c]=0 then begin a[c]:=1; s[i]:=c; break; end;\nfor i:=1 to n do\nif s[i]='?' then s[i]:='A';\nwriteln(s);\nhalt;\nend;\n\nbegin\nans:='';\nreadln(s);\nn:=length(s);\nfor c:='A' to 'Z' do a[c]:=0;\nif n<26 then\nbegin\nwrite(-1);\nhalt;\nend;\nl:=1;\nr:=26;\nwhile r<=n do\nbegin\nfor c:='A' to 'Z' do a[c]:=0;\nb:=true;\nfor i:=l to r do\nif s[i]<>'?' then\nbegin\ninc(a[s[i]]);\nif a[s[i]]=2 then begin l:=l+1; r:=l+25; b:=false; break; end;\nend;\nif b then finish;\nend;\nwrite(-1);\nend.\n"}, {"source_code": "const\n fin='';fon='';\nvar\n d:array ['A'..'Z'] of longint;\n s:ansistring;\n n:longint;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assigN(output,fon);rewrite(output);\n readln(s);\n n:=length(s);\n end;\nfunction check(vitri:longint):boolean;\n var\n i,SoTu,SoKiTu:longint;\n c:char;\n begin\n for c:='A' to 'Z' do d[c]:=0;\n SoTu:=0;\n SoKiTu:=0;\n for i:=vitri to vitri+26-1 do\n begin\n if s[i]='?' then inc(SoKiTu)\n else\n begin\n if d[s[i]]=1 then exit(false);\n inc(d[s[i]]);\n inc(SoTu);\n end;\n end;\n if SoKiTu=26-SoTu then exit(true)\n else exit(false);\n end;\nprocedure solve;\n var\n i,j:longint;\n c:char;\n begin\n for i:=1 to n-26+1 do\n begin\n if Check(i)=true then\n begin\n for j:=1 to i-1 do\n begin\n if s[j]<>'?' then write(s[j])\n else write('A');\n end;\n for j:=i to i+26-1 do\n begin\n if s[j]<>'?' then write(s[j])\n else\n begin\n for c:='A' to 'Z' do\n begin\n if d[c]=0 then\n begin\n write(c);\n d[c]:=1;\n break;\n end;\n end;\n end;\n end;\n for j:=i+26 to n do\n begin\n if s[j]<>'?' then write(s[j])\n else write('A');\n end;\n exit;\n end;\n end;\n writeln(-1);\n close(input); close(output);\n end;\nbegin\n nhap;\n solve;\nend.\n"}, {"source_code": "const\n inp = 'input.txt';\n out = 'output.txt';\n maxn = 50000 + 5;\n\nvar\n n : longint;\n a, b : array[0..maxn] of longint;\n mark : array[0..26] of boolean;\n\nprocedure init;\n var i : longint;\n x : char;\n begin\n n := 0;\n while (not seekeof) do\n begin\n inc(n);\n read(x);\n if (x = '?') then a[n] := 0\n else a[n] := ord(x) - ord('A') + 1;\n end;\n end;\n\nprocedure solve;\n var i, j, m : longint;\n check : boolean;\n begin\n check := false;\n for i := 1 to n - 25 do\n begin\n for j := 1 to 26 do mark[j] := false;\n check := true;\n\n for j := i to i + 25 do\n if (a[j] > 0) then\n if (mark[a[j]] = true) then\n begin\n check := false;\n break;\n end\n else mark[a[j]] := true;\n\n if check = true then\n begin\n m := 0;\n for j := 1 to 26 do\n if mark[j] = false then\n begin\n inc(m);\n b[m] := j;\n end;\n\n m := 0;\n\n for j := 1 to i - 1 do\n if a[j] = 0 then write('A')\n else write(chr(a[j] -1 + ord('A')));\n\n for j := i to i + 25 do\n if a[j] > 0 then write(chr(a[j] - 1 + ord('A')))\n else\n begin\n inc(m);\n write(chr(b[m] - 1 + ord('A')));\n end;\n\n for j := i + 26 to n do\n if a[j] = 0 then write('A')\n else write(chr(a[j] - 1 + ord('A')));\n\n exit;\n end;\n end;\n if not check then writeln(-1);\n end;\n\nbegin\n //assign(input, inp); reset(input);\n //assign(output, out); rewrite(output);\n init;\n solve;\nend.\n\n"}, {"source_code": "var s:ansistring;\n i,j,k,dem,sl:longint;\n kt:array[0..1000000] of longint;\nprocedure nhap;\n begin\n readln(s);\n end;\n\nprocedure xuli;\n begin\n For i:=1 to length(s)-26+1 do\n begin\n For j:=i to i+26-1 do\n begin\n if (kt[ord(s[j])]=0) and (s[j]<>'?') then\n begin\n inc(dem);\n kt[ord(s[j])]:=1;\n end;\n if s[j]='?' then inc(sl);\n end;\n if dem+sl=26 then\n begin\n For j:=i to 26-1+i do\n if s[j]='?' then\n begin\n For k:=65 to 90 do\n if kt[k]=0 then\n begin\n s[j]:=chr(k);\n kt[k]:=1;\n break;\n end;\n end;\n For j:=1 to length(s) do\n if s[j]='?' then write('A') else write(s[j]);\n halt;\n end;\n For j:=i to i+26-1 do\n kt[ord(s[j])]:=0;\n dem:=0;\n sl:=0;\n end;\n writeln(-1);\n end;\n\nbegin\n//assign(input,'372B.inp');reset(input);\n//assign(output,'372B.out');rewrite(output);\nnhap;\nxuli;\nend.\n"}, {"source_code": "var st:ansistring;\n ch:array[0..50050] of char;\n i,j,n:longint;\n c:char;\n flag:boolean;\n used:array['A'..'Z'] of boolean;\nbegin\n readln(st); n:=length(st); for i:=1 to n do ch[i]:=st[i];\n for i:=1 to n-25 do begin\n fillchar(used,sizeof(used),false); flag:=true;\n for j:=i to i+25 do begin\n if ch[j]='?' then continue;\n if used[ch[j]] then begin flag:=false; break; end;\n used[ch[j]]:=true;\n end;\n if flag then begin\n for j:=i to i+25 do begin\n if ch[j]<>'?' then continue;\n for c:='A' to 'Z' do\n if not used[c] then begin\n ch[j]:=c; used[c]:=true; break;\n end;\n end;\n for j:=1 to n do\n if ch[j]='?' then ch[j]:='A';\n for j:=1 to n do write(ch[j]); writeln;\n break;\n end;\n end;\n if not flag then writeln(-1);\nend.\n"}, {"source_code": "var\ns,s1:ansistring;\na:array[1..26] of longint;\ni,j,q:longint;\nbegin\nreadln(S);\nif length(S)<26\nthen begin\nwriteln(-1);\nhalt;\nend;\n//s:='ABC??FGHIJK???OPQR?TUVWXY?';\n\nfor i:=1 to length(S)-25 do begin\ns1:=copy(s,i,26);\nq:=0;\nfor j:=1 to 26 do\na[j]:=0;\nfor j:=1 to 26 do\nif s1[j]<>'?'\nthen\ninc(a[ord(s1[j])-64]);\nfor j:=1 to 26 do\nif a[j]>1\nthen q:=1;\nif q=0\nthen begin\nfor j:=i to i+25 do\nif s[j]='?'\nthen for q:=1 to 26 do\nif a[q]=0\nthen begin\ns[j]:=chr(q+64);\ninc(a[q]);\nbreak;\nend;\nbreak;\nend;\nif i=length(s)-25\nthen begin writeln(-1); halt;end;\nend;\nfor i:=1 to length(S) do\nif s[i]='?'\nthen s[i]:='A';\nwriteln(S);\nend.\n\n"}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=1 to t-1 do\n if s[i]<>'?' then write(s[i]) else write('A');\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n for i:=t+26 to n do\n if s[i]<>'?' then write(s[i]) else write('A');\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "var n1,n:ansistring;\n i,k,q,d:integer;\n j:char;\n f:boolean;\nbegin\n read(n);\nf:=false; q:=1; i:=q;\nwhile (i<=length(n)-25) and (f=false) do\n begin\n n1:='';\n for d:=i to i+25 do\n n1:=n1+n[d];\n k:=0;\n for j:='A' to 'Z' do\n begin\n if (pos(j,n1)<>0) then\n begin\n inc(i);\n inc(k);\n end else\n if (pos(j,n1)=0) and (pos('?',n1)<>0) then\n begin\n insert(j,n1,pos('?',n1));\n delete(n1,pos('?',n1),1);\n inc(k);\n inc(i);\n end else break;\n end;\n if k=26 then f:=true else\n begin\n inc(q);\n i:=q;\n end;\n end;\nif f=true then\n begin\n insert(n1,n,i);\n delete(n,q,26);\n for i:=1 to length(n) do\n if n[i]='?' then write('A') else write(n[i]);\n end else write(-1);\nend.\n"}, {"source_code": "var q:array[63..90] of byte;\n s:ansistring;\n i,j,a:longint;\nfunction ans(a:longint):ansistring;\n var w:string;\n z:longint;\n an:ansistring;\n begin\n w:='';\n an:='';\n fillchar(q,sizeof(q),0);\n for j:=a to a+25 do\n if s[j]<>'?'\n then q[ord(s[j])]:=1;\n for j:=65 to 90 do\n if q[j]=0\n then w:=w+chr(j);\n z:=length(w);\n for j:=1 to a-1 do\n if s[j]='?'\n then an:=an+'A'\n else an:=an+s[j];\n for j:=a to a+25 do\n if s[j]='?'\n then begin\n an:=an+w[z];\n dec(z);\n end\n else an:=an+s[j];\n for j:=a+26 to length(s) do\n if s[j]='?'\n then an:=an+'A'\n else an:=an+s[j];\n ans:=an;\n end;\nbegin\n read(s);\n if length(s)<26\n then write('-1')\n else begin\n for i:=1 to length(s)-25 do\n begin\n fillchar(q,sizeof(q),0);\n a:=0;\n for j:=0 to 25 do\n begin\n inc(q[ord(s[j+i])]);\n if (s[j+i]<>'?') and (q[ord(s[j+i])]>1)\n then a:=1;\n end;\n if a=0\n then begin\n write(ans(i));\n halt;\n end;\n end;\n write('-1');\n end;\nend.\n"}, {"source_code": "var a,s,d,f,g,h,j,k,l,i,ii:longint;\nz,x:array['A'..'Z']of boolean;\nc:ansistring;\nbegin\nreadln(c);\ni:=1;\n\nwhile i<=length(c)do\nbegin\nh:=i;\nl:=0;\nk:=0;\nz:=x;\nj:=65;\nif true then\nbegin\nwhile (l<>1)and(i<=length(c))and(k<>26) do\nbegin\nif (c[i]<>'?')and(z[c[i]]) then l:=1;\nif (c[i]<>'?')and(not z[c[i]]) then\nbegin\nz[c[i]]:=true;\ninc(k);\nend;\nif c[i]='?' then\ninc(k);\ninc(i);\nend;\n\nif k=26 then\nbegin\nfor ii:=i-26 to i-1 do\nif c[ii]='?' then\nbegin\nwhile z[chr(j)]=true do\ninc(j);\nc[ii]:=chr(j);\ninc(j);\nend;\nfor ii:=1 to length(c)do\nif c[ii]='?' then\nc[ii]:='A';\nwriteln(c);\nhalt;\nend;\nend;\n\ni:=h+1;\nend;\n\nwriteln(-1);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar a: array['A'..'Z'] of boolean;\n b: array[1..100000] of longint;\n i, j, x, m: longint;\n s: ansistring;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(s);\n for i:=1 to length(s)-25 do\n begin\n x:=0;\n fillchar(a,sizeof(a),false);\n fillchar(b,sizeof(b),0);\n for j:=i to i+25 do\n if s[j] = '?' then\n begin\n inc(x);\n b[x]:=j;\n end\n else a[s[j]]:=true;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then inc(m);\n if m > x then continue;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then\n begin\n inc(m);\n s[b[m]]:=c;\n end;\n for j:=1 to length(s) do if s[j] = '?' then s[j]:='A';\n writeln(s);\n halt;\n end;\n writeln(-1);\n\n close(input); close(output);\nend.\n\n"}, {"source_code": "var\n s,s2:string;\n len,i,j,z,p:longint;\n ch:char;\n bo:boolean;\n c:array[0..100]of char;\n b:array['?'..'Z']of boolean;\nbegin\n read(s);\n len:=length(s);\n bo:=true;\n for i:=1 to len-25 do\n begin\n fillchar(b,sizeof(b),false);\n p:=0;\n for j:=1 to 27 do\n begin\n if j=27 then break;\n if s[i+j-1]='?' then inc(p)\n else begin\n if b[s[i+j-1]] then break\n else b[s[i+j-1]]:=true;\n end;\n end;\n if j<27 then continue;\n z:=0;\n for ch:='A' to 'Z' do\n begin\n if not b[ch] then\n begin\n inc(z);\n c[z]:=ch;\n end;\n end;\n s2:=s;\n z:=0;\n for j:=1 to 26 do\n if s2[i+j-1]='?' then begin\n inc(z);\n s2[i+j-1]:=c[z];\n end;\n bo:=false;\n break;\n end;\n if bo then write(-1)\n else begin\n for i:=1 to len do\n begin\n if s2[i]='?' then write('A')\n else write(s2[i]);\n end;\n end;\nend.\n"}, {"source_code": "Program B;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\ns: ansistring;\nn: longint;\nd: array[0..60000, '?'..'Z'] of longint;\n\nFunction f(l, r: longint; c:char):longint;\nBEGIN\nexit(d[r][c] - d[l-1][c]);\nEND;\n\nFunction check(i: longint): boolean;\nVar cnt, tmp: longint;\nc: char;\nBEGIN\ncnt := 0;\nfor c := 'A' to 'Z' do\n\tbegin\n\ttmp := f(i, i+25, c);\n\tif tmp > 1 then exit(false);\n\tcnt := cnt + tmp;\n\tend;\nif 26-cnt = f(i, i+25, '?') then exit(true);\nexit(false);\nEND;\n\nProcedure g(i: longint);\nVar j, j1: longint;\nt: ansistring;\nc: char;\nBEGIN\nj1 := 1;\nt := '';\nfor c := 'A' to 'Z' do if f(i, i+25, c) = 0 then t := t + c;\nfor j := i to i+25 do if s[j] = '?' then\n\tbegin\n\ts[j] := t[j1];\n\tinc(j1);\n\tend;\nfor j := 1 to n do if s[j] = '?' then s[j] := 'K';\nEND;\n\nProcedure Process;\nVar i, j: longint;\nc: char;\nBEGIN\nreadln(fi, s);\nn := length(s);\nif (n < 26) then\n\tbegin\n\twriteln(fo, -1);\n\texit;\n\tend;\nfor i:=1 to n do\n\tfor c := '?' to 'Z' do\n\t\tif s[i] = c then d[i][c] := d[i-1][c] + 1\n\t\t\telse d[i][c] := d[i-1][c];\nfor i:=1 to n-25 do if check(i) then\n\tbegin\n\tg(i);\n\twriteln(fo, s);\n\texit;\n\tend;\nwriteln(fo, -1);\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND. "}, {"source_code": "var possible:boolean;\n\tst:string;\n\tsum:int64;\n\ti,j,k:int32;\n\tcount:array[0..30] of int64;\nBegin\n\tRead(st);\n\tpossible:=False;\n\tIf (length(st)>=26) then\n\t\tBegin\n\t\t\tFor i:=1 to length(st)-26+1 do\n\t\t\t\tBegin\n\t\t\t\t\tsum:=0;\n\t\t\t\t\tFillchar(count,sizeof(count),0);\n\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\tInc(count[Ord(st[j])-Ord('?')]);\n\t\t\t\t\tFor j:=1 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\tIf (count[j]>0) then inc(sum);\n\t\t\t\t\tIf (count[0]>=26-sum) then\n\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\tpossible:=True;\n\t\t\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\t\t\tFor k:=2 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\t\t\t\tIf (st[j]='?') and (count[k]=0) then\n\t\t\t\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\t\t\t\tinc(count[k]);\n\t\t\t\t\t\t\t\t\t\t\tst[j]:=Chr(k+Ord('?'));\n\t\t\t\t\t\t\t\t\t\tEnd;\n\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\tEnd;\n\tFor i:=1 to length(st) do if (st[i]='?') then st[i]:='A';\n\tIf possible then Writeln(st)\n\tElse Writeln('-1');\nEnd.\n"}, {"source_code": "var b,m,n,i,c,a,j:longint;x,y:array['?'..'Z']of longint;f:boolean;\nq:char;s:string;\nbegin\n reADln(s);\n n:=length(s);s:=s+'L';\n if N<26 then begin write(-1);halt;end;\n for j:=0 to 25 do inc(x[s[1+j]]);\n for i:=1 to n-25 do\n begin\n\n \n f:=true;\n for q:='A' to 'Z' do \n if x[q]>1 then begin f:=false;break; end;\n if f then\n begin\n q:='A';\n for j:=0 to 25 do\n if s[j+i]='?' then begin\n while x[q]=1 do inc(q);\n s[j+i]:=q;x[q]:=1;\n end;\n for j:=1 to n do\n if s[j]='?' then write('H') else write(s[j]);halt;\n end;\n dec(x[s[i]]);inc(x[s[i+26]]);\n \nend;\nwrite(-1);\nend."}, {"source_code": "var\n a:array['A'..'Z']of longint;\n s,w:ansistring;\n c:char;\n n,m,i,k,j,f,t,x,y,z,q:longint;\nbegin\n readln(s);\n if length(s)<26 then\n begin\n writeln('-1');\n halt;\n end;\n for i:=1 to length(s)-25 do\n begin\n for c:='A'to'Z'do a[c]:=0;\n z:=0;\n for j:=i to i+25 do\n if s[j]<>'?'then\n begin\n inc(a[s[j]]);\n if a[s[j]]>1 then z:=1;\n end;\n if z=0 then\n begin\n for c:='A'to'Z'do if a[c]=0 then w:=w+c;\n for j:=i to i+25 do\n if s[j]='?'then\n begin\n inc(z);\n s[j]:=w[z];\n end;\n for j:=1 to length(s)do\n if s[j]='?'then s[j]:='A';\n writeln(s);\n halt;\n end;\n end;\n writeln('-1');\nend.\n\n"}, {"source_code": "var s : ansistring;\n n, i, j, c, k : longint;\n f : array[0 .. 50010] of word;\nbegin\n read(s);\n n := length(s);\n for i := 1 to n - 25 do\n begin\n c := 0;\n for j := 0 to 25 do\n f[j]:=0;\n for j := i to i + 25 do\n if s[j] <> '?' then f[ord(s[j])- ord('A')] := 1\n else inc(c);\n for j := 0 to 25 do\n if f[j] > 0 then inc(c);\n if c = 26 then\n begin\n for j := i to i + 25 do\n if s[j] = '?' then\n for k := 0 to 25 do\n if f[k] = 0 then\n begin\n f[k] := 1;\n s[j] := chr(k + ord('A'));\n break;\n end;\n for j := 1 to n do\n if s[j] = '?' then s[j] := 'A';\n write(s);\n halt;\n end;\n end;\n write(-1);\nend."}, {"source_code": "uses strutils;\n\n const eps=1e-11; besk=8000000000000000000;\n modul=1000000007;\n label 1,2,3,4,11;\n type\n\n mas=array [-10000..1000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var aa,bb,olda1,olda2,ot,q1,aa2,bb2,aa1,bb1,t,t0,t1,p,kol,i1,j1,newdl,dl,kk,t2,m1,n1,pp,px,py,ll,cc,n2,dist,pos,dloch,x0,tt,v1,v2,p3,p4,t4,t5,t6,t3,xx,yy,ost,rr,q,h,n,qq,p1,p2,y0,s1,s2,m,imax,smin,besk1:int64;\n ii,jj,step,k,i,j:longint;\n c1,c2:array[-1000..100000] of int64;\n x,y:array[-10..65000,0..100] of int64;\n h1,h2:extended;\n dd1,dd2,newoch,sum,ugol,s,place,xnew,z,och,fact,d, a1,bl,br,c,a,b:array[-10000001..3000000] of int64;\n stoim:array[-10..1200,-10..1200] of int64;\n ss,ss1,ss2 :string;\n gr:array[-100..5000,-100..5000] of boolean;\n ssot:array[-100..10000] of char;\n ch: char;\n ppp:zap;\n pole,pole1:array[-10..1400,-10..1400] of char;\n prost, zan,marked:array[-1000001..1100000] of boolean;\n sss1,name1,name2,sp,sss,maxpr:array[0..1000000] of string;\n w,mm,nn,mm1,nn1,hh,ttt, l, aanew,v0,s0:extended;\n { z,y,x:array[-1..300,-10..1000] of int64;\n }\n prvin,prlost,prob,x1,y1, xxx,yyy:array[-1..1000000] of extended;\n tt1, xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var aa,bb,qq,d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n aa:=a;bb:=b;\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2;\n flag:=x*aa+y*bb=d;\n if flag then begin tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end;\n flag:=x*bb+y*aa=d;\n if flag then begin tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\n\n\n evkl:=tt1;\nend;\n\nfunction degg(modul,a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(modul,a,k-1)*a) mod modul else\n begin p:=degg(modul,a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction good(ii,jj:longint):boolean;\nvar pp,i,j:longint; a:array[-100..300] of longint; fl:boolean;\n begin\n for i:=-1 to 50 do a[i]:=0; pp:=0;\n for i:=ii to jj do\n if ss[i]<>'?' then inc(a[ord(ss[i])-ord('A')]) else inc(pp);\n for i:=0 to 25 do if a[i]=0 then dec(pp);\n\n good:=pp>=0;\n\n end;\n\n\n\n\n\n\nbegin\n{ assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(ss);\n n:=length(ss);\n\n if n<26 then begin writeln(-1); goto 1; end;\nflag:=false;\nfor i:=1 to n-25 do if good(i,i+25) then begin flag:=true; ii:=i; end;\nif not flag then begin writeln(-1); goto 1; end;\n for i:=1 to ii-1 do if ss[i]<>'?' then write(ss[i]) else write('A');\n for i:=-10 to 250 do a[i]:=0;\n pos:=-1;\n for i:=ii to ii+25 do inc(a[ord(ss[i])-ord('A')]);\n { writeln('pos= ',ii);\n for i:=0 to 25 do write(a[i],' '); writeln;\n } for i:=ii to ii+25 do if ss[i]<>'?' then write(ss[i]) else\n begin\n repeat inc(pos) until (a[pos]=0);\n write(chr(pos+ord('A')));\n end;\n\n\n for i:=ii+26 to n do if ss[i]<>'?' then write(ss[i]) else write('A');\n writeln;\n\n 1: close(output);\n\n\nend.\n"}, {"source_code": "program yan;\n var ar:array['A'..'Z']of integer;\n i,j,x,y,a,b,n,m:longint; s:ansistring; c:char;\nbegin\n readln(s);\n for i:=1 to length(s)-25 do\n begin\n a:=0;\n for c:='A' to 'Z' do ar[c]:=0;\n for j:=i to i+25 do\n if s[j]='?' then inc(a) else ar[s[j]]:=1;\n for c:='A' to 'Z' do\n if ar[c]=1 then inc(a);\n if a=26 then\n begin\n c:='A';\n for j:=i to i+25 do\n if s[j]='?' then\n begin\n while c<='Z' do\n begin\n if ar[c]=0 then\n begin s[j]:=c; c:=chr(ord(c)+1); break; end;\n c:=chr(ord(c)+1);\n end;\n end;\n m:=1;\n break;\n end;\n end;\n if m=0 then begin write(-1); exit; end;\n for i:=1 to length(s) do\n if s[i]='?' then s[i]:='A';\n write(s);\nend."}, {"source_code": "var\n s : ansistring;\n fk : boolean;\n i,j,n,m,k,l : longint;\n c,cc : char;\n ans : array[0..150000] of char;\n f : array['A'..'Z'] of longint;\n\nbegin\n readln(s); n:=length(s);\n for i:=1 to n-25 do begin\n for c:='A' to 'Z' do f[c]:=0;\n k:=0;\n for j:=i to i+25 do if s[j] in ['A'..'Z'] then inc(f[s[j]]);\n for j:=i to i+25 do\n if s[j] = '?' then begin\n cc:='A';\n for c:='B' to 'Z' do if f[c] < f[cc] then cc:=c;\n inc(k); ans[k]:=cc;\n inc(f[cc]);\n end;\n fk:=false;\n for c:='A' to 'Z' do if f[c] <> 1 then fk:=true;\n if not fk then begin\n for j:=i to i+25 do\n if s[j] = '?' then begin\n inc(l); s[j]:=ans[l];\n end;\n for j:=1 to n do\n if s[j] = '?' then s[j]:='A';\n writeln(s);\n halt;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint; s,s1,s2:ansistring;\n\nFunction TryFill(s1:ansistring):ansistring;\nvar i,j,k,l,m,qnum,znum,uk:longint; Z:array[1..26] of byte; ch:char; sm:string;\nbegin\nqnum:=0; sm:=''; znum:=0;\nfor i:=1 to 26 do Z[i]:=0;\nfor i:=1 to 26 do\n begin\n if s1[i]='?' then inc(qnum) else inc(Z[ord(s1[i])-64]);\n end;\nfor i:=1 to 26 do if Z[i]=0 then begin inc(znum); sm:=sm+chr(i+64); end;\nif qnum<>znum then exit('');\nuk:=1;\nfor i:=1 to 26 do\nif s1[i]='?' then begin s1[i]:=sm[uk]; inc(uk); end;\nexit(s1);\nend;\n\n\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(s);\n//writeln(s);\nn:=length(s);\nfor i:=1 to (n-25) do\n begin\n s1:='';\n for j:=1 to 26 do s1:=s1+s[j+i-1];\n// writeln(s1);\n s2:=TryFill(s1);\n// writeln(s2);\n if s2<>'' then\n begin\n for j:=i to i+25 do s[j]:=s2[j-i+1];\n for j:=1 to n do if s[j]='?' then s[j]:='A';\n writeln(s);\n exit;\n end;\n end;\nwrite('-1');\nend."}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, i, j, k, p, t: Longint;\n S: AnsiString;\n c: array[0..50000,1..26] of Longint;\n found: Boolean;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\trandomize;\n\tif n<26 then\n\tbegin\n\t\twriteln(fo, -1);\n\t\tclose(fi); close(fo);\n\t\texit;\n\tend\n\telse\n\tbegin\n\t\tfor i:=1 to n do\n\t\tbegin\n\t\t\tt:= ord(S[i])-64;\n\t\t\tif t>0 then\n\t\t\t\tfor j:=1 to 26 do\n\t\t\t\t\tif j=t then c[i,j]:= c[i-1,j]+1\n\t\t\t\t\telse c[i,j]:= c[i-1,j]\n\t\t\telse\n\t\t\t\tfor j:=1 to 26 do c[i,j]:= c[i-1,j];\n\t\tend;\n\t\tfor i:=1 to n-26+1 do\n\t\tbegin\n\t\t\tj:= i + 26 - 1;\n\t\t\tfound:= true;\n\t\t\tfor k:=1 to 26 do\n\t\t\t\tif c[j,k]-c[i-1,k]>1 then\n\t\t\t\tbegin\n\t\t\t\t\tfound:= false;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tif found then\n\t\t\tbegin\n\t\t\t\tfor k:=i to j do\n\t\t\t\t\tif S[k]='?' then\n\t\t\t\t\tbegin\n\t\t\t\t\t\tfor p:=1 to 26 do\n\t\t\t\t\t\t\tif c[j,p]-c[i-1,p]=0 then\n\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\tS[k]:= chr(p+64);\n\t\t\t\t\t\t\t\tinc(c[j,p]);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tfor k:=1 to n do\n\t\t\t\t\tif S[k]<>'?' then write(fo, S[k])\n\t\t\t\t\telse write(fo, chr(1+random(26)+64));\n\t\t\t\tclose(fi); close(fo);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\tif not(found) then\n\t\tbegin\n\t\t\twriteln(fo, -1);\n\t\t\tclose(fi); close(fo);\n\t\t\texit;\n\t\tend;\n\tend;\nEnd.\n"}, {"source_code": "var s,x,y:ansistring;ch,t:char;i,j:longint;\nf:array['A'..'Z'] of longint;g:boolean;\nbegin\n//assign(input,'xzadz.in');reset(input);\n//assign(output,'xzadz.out');rewrite(output);\nreadln(s);ch:=succ('Z');\nfor i:=1 to length(s)-25 do\n begin\n fillchar(f,sizeof(f),0);g:=false;\n for j:=i to i+25 do\n if s[j]<>'?' then\n begin\n inc(f[s[j]]);\n if f[s[j]]>1 then begin g:=true;break;end;\n end;\n if g then continue;\n t:='A';y:=s;\n while(t<='Z')and(f[t]>0)do t:=succ(t);\n for j:=i to i+25 do\n if y[j]='?' then\n begin\n y[j]:=t;t:=succ(t);\n while(t<='Z')and(f[t]>0)do t:=succ(t);\n end;\n if y[i]'Z' then writeln(-1) else writeln(x);\nclose(input);close(output);\nend."}, {"source_code": "label res;\nvar s:string; b:array[65..90] of integer; i,j,x:integer;\nbegin //A 65 Z 90\nreadln(s);\nif length(s)<26 then begin writeln(-1); exit; end;\nx:=-1;\nres:\nx:=x+1;\nif x+26>length(s) then begin writeln(-1); exit; end;\nfor i:=65 to 90 do b[i]:=0;\nfor i:=1+x to 26+x do if s[i]<>'?' then if b[ord(s[i])]=0 then b[ord(s[i])]:=1\n else goto res;\n\nfor i:=1+x to 26+x do\n if s[i]='?' then\n for j:=65 to 90 do\n if b[j]=0 then begin b[j]:=1; s[i]:=chr(j); break; end;\nfor i:=1 to length(s) do\n if s[i]='?' then s[i]:='A';\nwriteln(s);\nend.\n"}, {"source_code": "var\n s,s2:ansistring;\n len,i,j,z,p:longint;\n ch:char;\n bo:boolean;\n c:array[0..100]of char;\n b:array['?'..'Z']of boolean;\nbegin\n read(s);\n len:=length(s);\n bo:=true;\n for i:=1 to len-25 do\n begin\n fillchar(b,sizeof(b),false);\n p:=0;\n for j:=1 to 27 do\n begin\n if j=27 then break;\n if s[i+j-1]='?' then inc(p)\n else begin\n if b[s[i+j-1]] then break\n else b[s[i+j-1]]:=true;\n end;\n end;\n if j<27 then continue;\n z:=0;\n for ch:='A' to 'Z' do\n begin\n if not b[ch] then\n begin\n inc(z);\n c[z]:=ch;\n end;\n end;\n s2:=s;\n z:=0;\n for j:=1 to 26 do\n if s2[i+j-1]='?' then begin\n inc(z);\n s2[i+j-1]:=c[z];\n end;\n bo:=false;\n break;\n end;\n if bo then write(-1)\n else begin\n for i:=1 to len do\n begin\n if s2[i]='?' then write('A')\n else write(s2[i]);\n end;\n end;\nend."}, {"source_code": "var\nn,i,j,j1,p:longint;\nst,st2,st3:ansistring;\na:array[0..100] of int64;\nprocedure prov;\n begin\n for j:=1 to 26 do\n begin\n if a[j]>1 then exit;\n end;\n for j:=1 to 26 do\n begin\n if a[j]=0 then begin\n if i=0 then i:=26;\n for j1:=i-25 to i do\n begin\n if st[j1]='?' then begin\n st[j1]:=st3[j];\n break;\n end;\n end;\n end;\n end;\n for j:=i to n do\n if st[j]='?' then st[j]:='A';\n writeln(st);\n halt;\n end;\nbegin\n readln(st);\n n:=length(st);\n st3:='QWERTYUIOPASDFGHJKLZXCVBNM';\n if n<26 then begin\n writeln('-1');\n halt;\n end;\n st2:=copy(st,1,26);\n for i:=1 to 26 do\n begin\n if st2[i]<>'?' then begin\n p:=pos(st2[i],st3);\n a[p]:=a[p]+1;\n end;\n end;\n prov;\n for i:=27 to n do\n begin\n p:=pos(st[i],st3);\n a[p]:=a[p]+1;\n p:=pos(st[i-26],st3);\n a[p]:=a[p]-1;\n if st[i-26]='?' then st[i-26]:='A';\n prov;\n end;\n writeln(-1);\nend."}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n if s[l-1]<>'?' then a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n if s[r]<>'?' then a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=1 to length(s) do\n if (i>=l) and (i<=r) then begin\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else if not(s[i]='?') then write(s[i]) else write('A');\n End."}, {"source_code": "const fi='b.inp';\n fo='b.out';\nvar s:ansistring;\n i,j:longint;\n d:array['A'..'Z']of longint;\n jj:char;\n ktt:boolean;\nfunction kt:boolean;\nvar j:char;\n begin\n for j:='A' to 'Z' do\n if d[j]>1 then exit(false);\n exit(true);\n end;\nbegin\n //assign(input,fi);reset(input);\n //assign(output,fo);rewrite(output);\n ktt:=false;\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]<>'?' then inc(d[s[i]]);\n if (i>26)and (s[i-26]<>'?') then dec(d[s[i-26]]);\n if i>=26 then\n begin\n if kt=true then\n begin\n ktt:=true;\n for j:=i-25 to i do\n if s[j]='?' then\n for jj:='A' to 'Z' do\n if d[jj]=0 then\n begin\n inc(d[jj]);\n s[j]:=jj;\n break;\n end;\n break;\n end;\n end;\n end;\n for i:=1 to length(s) do\n if s[i]='?' then s[i]:='A';\n if ktt=false then writeln(-1) else writeln(s);\nend.\n"}, {"source_code": "var x:char;\n flag:array[1..26] of boolean;\n\tch:array[1..60000] of char;\n\ti,j,k,ans,now,n:longint;\nbegin\n n:=0;\n while not(eoln) do\n begin\n inc(n);\n read(ch[n]);\n end;\n readln;\n for i:=1 to n-25 do\n begin\n fillchar(flag,sizeof(flag),false);\n ans:=0;\n now:=0;\n for j:=1 to 26 do\n\t\tif (ch[i+j-1]<>'?') then flag[ord(ch[i+j-1])-64]:=true else inc(ans);\n\tfor j:=1 to 26 do\n\t\tif not(flag[j]) then inc(now);\n\tif (ans>=now) then\n\tbegin\n\t now:=1;\n\t for k:=1 to i-1 do\n\t\tif (ch[k]<>'?') then write(ch[k]) else write('A');\n\t for k:=i to i+25 do\n\t\tif (ch[k]<>'?') then write(ch[k]) else\n\t\tbegin\n\t\t while (now<=25) and flag[now] do inc(now);\n\t\t flag[now]:=true;\n\t\t write(chr(now+64));\n\t\tend;\n\t for k:=i+26 to n do\n\t\tif (ch[k]<>'?') then write(ch[k]) else write('Z');\n\t writeln;\n\t halt;\n\tend;\n end;\n writeln('-1');\nend.\n\t\t"}, {"source_code": "program cf716B;\nvar n,i,j:longint;\n s,s2:string;\n c:char;\n br:array['?'..'Z'] of longint;\n cont:boolean;\nbegin\nreadln(s);\nn:=length(s);\n\nfor j:=1 to n-25 do\nbegin\n\nfor c:='A' to 'Z' do\n br[c]:=0;\n\nfor i:=j to j+25 do\n inc(br[s[i]]);\n\ncont:=false;\nfor c:='A' to 'Z' do\n if br[c]>1 then\n begin\n cont:=true;\n break;\n end;\n\nif cont then\n continue;\n\nc:='A';\n\ns2:=s;\n\nfor i:=j to j+25 do\n if s[i]<>'?' then\n //write(s[i])\n s2[i]:=s[i]\n else\n begin\n while br[c]=1 do\n inc(c);\n br[c]:=1;\n //write(c);\n s2[i]:=c;\n end;\n\n\n\nfor i:=1 to j-1 do\n if s[i]='?' then\n s2[i]:='A'\n else\n s2[i]:=s[i];\nfor i:=j+26 to n do\n if s[i]='?' then\n s2[i]:='A'\n else\n s2[i]:=s[i];\nwriteln(s2);\nexit;\nend;\nwriteln('-1');\nend."}, {"source_code": "var\n\ts,s1 : ansistring;\n\ti,j,a,hah : longint;\n\tk : char;\n\tcek : boolean;\n\tada : array['A'..'Z'] of boolean;\n\nbegin\n\treadln(s);\n\tcek := false;\n\tif length(s) < 26 then begin\n\t\twriteln(-1);\n\t\texit;\n\tend;\n\tfor i := 1 to (length(s)-25) do begin\n\t\thah := 0;\n\t\tfor k := 'A' to 'Z' do ada[k] := false;\n\t\tfor j := i to i+25 do begin\n\t\t\tif ada[s[j]] then hah := 1;\n\t\t\tif s[j] <> '?' then ada[s[j]] := true;\n\t\tend;\n\t\tif hah = 0 then begin\n\t\t\tfor j := i to i+25 do begin\n\t\t\t\tif s[j] = '?' then begin\n\t\t\t\t\tfor k := 'A' to 'Z' do begin\n\t\t\t\t\t\ta := 0;\n\t\t\t\t\t\tif not(ada[k]) then begin\n\t\t\t\t\t\t\ts[j] := k;\n\t\t\t\t\t\t\tada[k] := true;\n\t\t\t\t\t\t\ta := 1;\n\t\t\t\t\t\tend;\n\t\t\t\t\t\tif a = 1 then break;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\t\ts1 := copy(s,i,26);\n\t\t\tif pos('?',s1) = 0 then cek := true;\n\t\tend;\n\tend;\n\twhile pos('?',s) <> 0 do s[pos('?',s)] := 'V';\n\tif cek then writeln(s)\n\telse writeln(-1);\nend."}, {"source_code": "var\ns:ansistring;\na,b:array[0..50050] of longint;\nc:array[0..26] of boolean;\ni,j,len,cnt:longint;\n\nprocedure print(x:longint);\nvar i,cnt:longint;\nbegin\n for i:=x to x+25 do\n if a[i]<>0 then c[a[i]]:=true;\n cnt:=1;\n for i:=x to x+25 do\n if a[i]=0 then\n begin\n while (cnt<26)and(c[cnt]=true) do inc(cnt);\n a[i]:=cnt;c[cnt]:=true;\n end;\n for i:=1 to len do\n if a[i]=0 then write('Z') else write(chr(a[i]+ord('A')-1));\n writeln;\n halt;\nend;\n\nbegin\n readln(s);\n len:=length(s);\n if len<26 then\n begin\n writeln('-1');\n halt;\n end;\n for i:=1 to len do \n if s[i]<>'?' then \n a[i]:=ord(s[i])-ord('A')+1;\n for i:=1 to 26 do inc(b[a[i]]);\n for i:=1 to len-25 do\n begin\n cnt:=b[0];\n for j:=1 to 26 do \n if b[j]<>0 then inc(cnt);\n if cnt=26 then print(i);\n dec(b[a[i]]);\n if i+26<=len then inc(b[a[i+26]]);\n end;\n writeln('-1');\nend."}, {"source_code": "{$H+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);} \nread(s);\nif length(s)<26 then begin writeln('-1'); halt; end;\nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to i-1 do\n if s[j]='?' then write('A')\n else write(s[j]);\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n for j:=i+j to length(s) do\n if s[j]='?' then write('A')\n else write(s[j]);\n\n halt;\n end;\n end;\nwriteln('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "label 1;\nvar s,s2:string;\n i,j,k,no,ko:longint;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(s);\nif length(s)<26 then\nbegin\nwrite(-1);\nhalt;\nend;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ni:=1;\n1: while i<=length(s)-25 do\nbegin\nfor j:=i to 25+i do\nbegin\nif s[j]<>'?' then\nbegin\nif pos(s[j],s2)=0 then\nbegin\ninc(i);\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ngoto 1;\nend;\ndelete(s2,pos(s[j],s2),1);\nend;\nend;\nno:=i;\nko:=25+i;\nbreak;\nend;\nif i>length(s)-25 then\nbegin\nwrite(-1);\nhalt;\nend;\n{if s2='' then\nbegin\nwrite(-1);\nhalt;\nend;}\nk:=1;\nfor i:=1 to length(s) do\nbegin\nif (i=no) and (i<=ko) then\nif s[i]='?' then\nbegin\nwrite(s2[k]);\ninc(k);\nend\nelse write(s[i]);\nend;\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "var s:ansistring;\nf,f1:array[1..26] of byte;\nn,i,j,k,k1,fl,p:longint;\nbegin\nreadln(s);\nn:=length(s);\n\nfor i:=1 to n-25 do begin\n\n fillchar(f,sizeof(f),0);\n p:=1;\n\nfor j:=i to i+25 do\nif s[j]<>'?' then begin\n k:= ord(s[j])-64;\n inc(f[k]);\n if f[k]>1 then p:=0;\n end;\n\n if p=1 then begin\n\n k1:=0;\n for j:=1 to 26 do\n if f[j]=0 then begin inc(k1); f1[k1]:=j; end;\n\n for j:=i to i+25 do\n if s[j]='?' then begin s[j]:=chr(f1[k1]+64); dec(k1); end;\n\n fl:=1;\n break;\n end;\n\nend;\n\nif fl=0 then writeln(-1)\nelse begin\n\n for i:=1 to n do\n if s[i]='?' then write('A')\n else write(s[i]);\nend;\n\n\nend.\n"}, {"source_code": "var s:ansistring;\n a:array[0..1000] of longint;\nProcedure chuongtrinh;\nvar x:ansistring;\n i,j,dem:longint;\nbegin\nread(s);\nif length(S)<26 then\n begin\n write(-1);\n halt;\n end\nelse\n begin\nfor i:=1 to length(S)-25 do\n begin\n x:=copy(s,i,26);\n dem:=0;\nfor j:=1 to 26 do a[j]:=0;\n for j:=1 to 26 do\n if x[j]<>'?' then inc(a[ord(x[j])-64]);\nfor j:=1 to 26 do\nif a[j]>1 then dem:=1;\nif dem=0 then\n begin\n for j:=i to i+25 do\n if s[j]='?' then\n for dem:=1 to 26 do\n if a[dem]=0 then\n begin\n s[j]:=chr(dem+64);\n inc(a[dem]);\n break;\nend;\nbreak;\nend;\nif i=length(s)-25 then\n begin\n write(-1);\n halt;\n end;\nend;\nfor i:=1 to length(S) do\nif s[i]='?' then s[i]:='A';\nwrite(s);\nend;\nend;\nBEGIN\n chuongtrinh;\nEND.\n"}, {"source_code": "Const Finp = '';\n Fout = '';\nVar s:Ansistring;\n skip:Boolean;\nProcedure Input;\nVar f:Text;\nBegin\n Assign(f,finp); Reset(f);\n Readln(f,s); Close(f);\nEnd;\nFunction Check(pos:Longint):Boolean;\nVar d:Array[1..26] of Boolean;\n i:Longint;\nBegin\n Fillchar(d,sizeof(d),true);\n For i:=pos to pos+25 do\n If s[i] <> '?' then\n If d[ord(s[i])-64] then\n d[ord(s[i])-64]:=false\n Else exit(false);\n exit(true);\nEnd;\nProcedure Replace(posi:Longint);\nVar k,i:Longint;\n st:String;\nBegin\n st:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n For i:=posi to posi+25 do\n delete(st,pos(s[i],st),1);\n k:=1;\n For i:=posi to posi+25 do\n If s[i] = '?' then\n Begin\n s[i]:=st[k];\n inc(k);\n End;\nEnd;\nProcedure Solve;\nVar i:Longint;\nBegin\n skip:=True;\n If length(s) < 26 then exit;\n skip:=False;\n For i:=1 to length(s)-25 do\n If Check(i) then\n Begin\n Replace(i); Exit;\n End;\n skip:=true;\nEnd;\nProcedure Output;\nVar f:Text;\n i:Longint;\nBegin\n Assign(f,fout); Rewrite(f);\n If skip then write(f,-1) else\n For i:=1 to length(s) do\n If s[i] = '?' then write(f,'V') else write(f,s[i]);\n Close(f);\nEnd;\nBegin\n Input;\n Solve;\n Output;\nEnd."}, {"source_code": "var n,m,i,j,k,ned:longint;\n f:array['A'..'Z']of longint;\n s:ansistring;\n c:char; \nbegin\nreadln(s);\nif length(s)<26 then begin writeln(-1);halt;end;\nfor j:=1 to 26 do begin\n if s[j]<>'?' then inc(f[s[j]]) else inc(k);\nend;\nfor i:=1 to length(s)-25 do begin\n if i>1 then begin\n if s[i-1]='?' then dec(k) else dec(f[s[i-1]]);\n if s[i+25]='?' then inc(k) else inc(f[s[i+25]]);\n end; \n ned:=0;\n for c:='A' to 'Z' do if f[c]=0 then inc(ned);\n if ned<=k then begin\n for j:=1 to (i-1) do begin\n if s[j]<>'?' then write(s[j]) else write('A');\n end;\n for j:=1 to 26 do begin\n if s[i+j-1]<>'?' then write(s[i+j-1]) else begin\n for c:='A' to 'Z' do if f[c]=0 then begin inc(f[c]);write(c);break;end;\n end;\n end;\n for j:=(i+26) to length(s) do begin\n if s[j]<>'?' then write(s[j]) else write('A');\n end;\n halt;\n end;\nend;\nwriteln(-1);\nend.\n \n"}], "negative_code": [{"source_code": "const\n fi='';\nvar\n i,n,d1,d2,tg:longint;\n st:ansistring;\n a:array[0..100] of longint;\n f:Text;\nbegin\n assign(f,fi); reset(f);\n readln(f,st);\n n:=length(st);\n for i:=1 to n do\n if st[i]<>'?' then\n begin\n tg:=ord(st[i])-65+1;\n inc(a[tg]);\n if a[tg]>=2 then\n begin\n writeln(-1); exit;\n end;\n if a[tg]=1 then inc(d1);\n end\n else inc(d2);\n if d1+d2>26 then\n begin\n writeln(-1); exit;\n end;\n tg:=1;\n for i:=1 to n do\n if st[i]='?' then\n begin\n while (tg<=26) and (a[tg]=1) do inc(tg);\n write(char(tg+65-1));\n tg:=tg+1;\n end\n else write(st[i]);\n readln;\nend.\n"}, {"source_code": "var\n s: ansistring;\n i, j, n, chamhoi, top: longint;\n b: array[0..500000] of char;\n a: array['A'..'Z'] of longint;\n c: char;\n nice: boolean;\n\nbegin\n //assign(input, 'b.inp'); reset(input);\n //assign(output, 'b.out'); rewrite(output);\n\n readln(s);\n if (length(s) <= 25) then\n writeln(-1)\n else\n begin\n for i:= 1 to length(s) - 25 do\n begin\n nice:= true; top:= 0; chamhoi:= 0;\n for j:= i to i + 25 do\n if (s[j] = '?') then inc(chamhoi)\n else\n inc(a[s[j]]);\n for c:= 'A' to 'Z' do\n begin\n if (a[c] = 0) then\n begin\n inc(top);\n b[top]:= c;\n end;\n if (a[c] > 1) then nice:= false;\n end;\n if not(nice) then continue;\n if (chamhoi - top <> 0) then continue;\n for j:= i to i + 25 do\n if (s[j] = '?') then\n begin\n s[j]:= b[top];\n dec(top);\n end;\n if (i + 25 < length(s)) then\n for j:= 1 to length(s) do\n if (s[j] = '?') then s[j]:= 'A';\n writeln(s);\n halt;\n end;\n end;\n writeln(-1);\n //close(input); close(output);\nend.\n"}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "Program B;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\ns: ansistring;\nn: longint;\nd: array[0..60000, '?'..'Z'] of longint;\n\nFunction f(l, r: longint; c:char):longint;\nBEGIN\nexit(d[r][c] - d[l-1][c]);\nEND;\n\nFunction check(i: longint): boolean;\nVar cnt, tmp: longint;\nc: char;\nBEGIN\ncnt := 0;\nfor c := 'A' to 'Z' do\n\tbegin\n\ttmp := f(i, i+25, c);\n\tif tmp > 1 then exit(false);\n\tcnt := cnt + tmp;\n\tend;\nif 26-cnt = f(i, i+25, '?') then exit(true);\nexit(false);\nEND;\n\nProcedure g(i: longint);\nVar j, j1: longint;\nt: ansistring;\nc: char;\nBEGIN\nj1 := 1;\nt := '';\nfor c := 'A' to 'Z' do if f(i, i+25, c) = 0 then t := t + c;\nfor j := i to i+25 do if s[j] = '?' then\n\tbegin\n\ts[j] := t[j1];\n\tinc(j1);\n\tend;\nwriteln(fo, copy(s, i, 26));\nEND;\n\nProcedure Process;\nVar i: longint;\nc: char;\nBEGIN\nreadln(fi, s);\nn := length(s);\nif (n < 26) then\n\tbegin\n\twriteln(fo, -1);\n\texit;\n\tend;\nfor i:=1 to n do\n\tfor c := '?' to 'Z' do\n\t\tif s[i] = c then d[i][c] := d[i-1][c] + 1\n\t\t\telse d[i][c] := d[i-1][c];\nfor i:=1 to n-25 do if check(i) then\n\tbegin\n\tg(i);\n\texit;\n\tend;\nwriteln(fo, -1);\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND. "}, {"source_code": "var n1,n:ansistring;\n i,k,q,d:integer;\n j:char;\n f:boolean;\nbegin\n read(n);\nf:=false; q:=1; i:=q;\nwhile (i<=length(n)-25) and (f=false) do\n begin\n n1:='';\n for d:=i to i+25 do\n n1:=n1+n[d];\n k:=0;\n for j:='A' to 'Z' do\n begin\n if (pos(j,n1)<>0) then\n begin\n inc(i);\n inc(k);\n end else\n if (pos(j,n1)=0) and (pos('?',n1)<>0) then\n begin\n insert(j,n1,pos('?',n1));\n delete(n1,pos('?',n1),1);\n inc(k);\n inc(i);\n end else break;\n end;\n if k=26 then f:=true else\n begin\n inc(q);\n i:=q;\n end;\n end;\nif f=true then\n begin\n delete(n,q,26);\n insert(n1,n,i);\n for i:=1 to length(n) do\n if n[i]='?' then write('A') else write(n[i]);\n end else write(-1);\nend.\n"}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; \n End."}, {"source_code": "var a:array[1..50010] of longint;\nb:array[1..30] of char;\nst,st2:ansistring;\nalf:string;\nz:char;\nn,i,j,k,p,q,r2,l2,kl:longint;\n\n procedure sort(l,r: longint);\n var\n i,j: longint;\n x,y: char;\n begin\n i:=l;\n j:=r;\n x:=b[i+random(j-i-1)];\n repeat\n while b[i]j) then\n begin\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then a[p]:=a[p]+1;\n end;\n for i:=1 to n do\n begin\n z:=st[i];\n if z='?' then begin\n for j:=1 to 26 do\n if a[j]=0 then begin\n z:=alf[j];\n p:=pos(z,st);\n if ((p>0) and (abs(p-i)>26)) or (p=0) then begin\n st2:=st2+z;\n a[j]:=1;\n break;\n end\n else begin\n k:=k+1;\n z:=st2[k];\n st2:=st2+z;\n end;\n\n end\n end\n else st2:=st2+z;\n end;\n for l2:=1 to n-25 do\n begin\n q:=0;\n for r2:=l2 to l2+25 do\n begin\n q:=q+1;\n b[q]:=st2[r2];\n end;\n sort(l2,26);\n kl:=0;\n for r2:=2 to 26 do\n if b[r2]=b[r2-1] then kl:=1;\n if kl=0 then begin\n writeln(st2);\n halt;\n end;\n end;\n writeln('-1');\nend.\n\n"}, {"source_code": "var\n i,j,k,n,t,l,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \n Procedure qsort1(l,r:longint);\nvar p,z,i,j:longint;\nbegin\n z:=x[random(r-l)+l];\n i:=l;\n j:=r;\n Repeat\n while x[i]>z do inc(i);\n while x[j]j;\n if i0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to l do begin\n if (s[i]=alp[i]) then x[i]:=1;\n end;\n for i:=1 to l do begin\n if (s[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s[i]:=alp[j];\n x[i]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n \n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n \n// end;\n if (proverka) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar a: array['A'..'Z'] of boolean;\n b: array[1..100000] of longint;\n i, j, x, m: longint;\n s: ansistring;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(s);\n for i:=1 to length(s)-25 do\n begin\n x:=0;\n fillchar(a,sizeof(a),false);\n for j:=i to i+25 do\n if s[j] = '?' then\n begin\n inc(x);\n b[x]:=j;\n end\n else a[s[j]]:=true;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then inc(m);\n if m > x then continue;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then\n begin\n inc(m);\n s[b[m]]:=c;\n end;\n for j:=i+26 to length(s) do if s[i] = '?' then s[i]:='A';\n writeln(s);\n halt;\n end;\n writeln(-1);\n\n close(input); close(output);\nend.\n"}, {"source_code": "{$H+}\nvar\n a, b, c, d, i, j, t: int64;\n s: string;\n ar: array [1..1000] of int64;\n\nbegin\n readln(s);\n if length(s) < 26 then begin\n writeln(-1);\n halt();\n end;\n i := 1;\n a := 0;\n b := 0;\n while i <= 26 do \n begin\n if s[i] = '?' then inc(b)\n else if ar[ord(s[i])] = 0 then begin\n ar[ord(s[i])] := 1;\n inc(a);\n end\n else inc(ar[ord(s[i])]);\n inc(i);\n end;\n while i <= length(s) do \n begin\n if a + b = 26 then begin\n j := i - 26;\n while j < i do \n begin\n if s[j] <> '?' then write(s[j])\n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n write(chr(t));\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n halt();\n end;\n if s[i - 26] = '?' then dec(b)\n else begin\n if ar[ord(s[i - 26])] = 1 then dec(a);\n dec(ar[ord(s[i - 26])]);\n end;\n if s[i] = '?' then inc(b)\n else begin\n if ar[ord(s[i])] = 0 then inc(a);\n inc(ar[ord(s[i])]);\n end;\n inc(i);\n end;\n if a + b = 26 then begin\n j := i - 26;\n while j < i do \n begin\n if s[j] <> '?' then write(s[j])\n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n write(chr(t));\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n halt();\n end;\n writeln(-1);\nend."}, {"source_code": "var s,s1:string;\na:array[1..26]of longint;\ni,n,f,j:longint;\nbegin\nreadln(s);\nn:=length(s);\nif n<>26 then begin writeln(-1); exit; end; \ns1:='ABCDEFGHIJKLMNOPQRSTVWUXYZ';\nfor i:=1 to 26 do\n for j:=1 to n do\nif s1[i]=s[j] then a[i]:=a[i]+1;\nfor i:=1 to n do\nif a[i]>1 then begin writeln(-1); exit; end;\ni:=1;\nwhile i<=n do begin\nif s[i]='?' then begin while s[i]='?' do begin delete(s,i,1);n:=n-1;if n1 then f:=1;\nif (n=26) and(f=0) then writeln(s)\nelse writeln(-1);\nend.\n "}, {"source_code": "var s,s1:ansistring; \na:array[1..26]of longint; \ni,n,f,j:longint; \nbegin \nreadln(s); \nn:=length(s); \nif n<26 then begin writeln(-1); exit; end; \ns1:='ABCDEFGHIJKLMNOPQRSTUVWXYZ'; \nfor i:=1 to 26 do \nfor j:=1 to n do \nif s1[i]=s[j] then a[i]:=a[i]+1; \nfor i:=1 to n do \nif a[i]>1 then begin writeln(-1); exit; end; \ni:=1; \nwhile i<=n do begin \nif s[i]='?' then begin while s[i]='?' do begin delete(s,i,1);n:=n-1;if n1 then f:=1; \nif (n=26) and(f=0) then writeln(s) \nelse writeln(-1); \nend."}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j, k: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\ti:= 1; j:= 2;\n\tif S[i]<>'?' then c[ord(S[i])-64]:= 1;\n\twhile (i<=n) and (j<=n) do\n\tbegin\n\t\tif S[j]<>'?' then\n\t\tbegin\n\t\t\tif c[ord(S[j])-64]=1 then\n\t\t\tbegin\n\t\t\t\tc[ord(S[i])-64]:= 0;\n\t\t\t\tinc(i);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tc[ord(S[j])-64]:= 1;\n\t\t\t\tif j-i+1=26 then break;\n\t\t\t\tinc(j);\n\t\t\tend;\n\t\tend\n\t\telse inc(j);\n\t\tif j-i+1>26 then inc(i);\n\tend;\n\tif j>n then \n\tbegin\n\t\tdec(j); \n\t\tdec(i);\n\tend;\n\trandomize;\n\tif j-i+1=26 then\n\tbegin\n\t\tfor k:=1 to n do\n\t\t\tif S[k]='?' then\n\t\t\tbegin\n\t\t\t\tif (kj) then write(fo, chr(64+random(26)))\n\t\t\t\telse\n\t\t\t\t\tfor t:=1 to 26 do\n\t\t\t\t\t\tif c[t]=0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(fo, chr(t+64));\n\t\t\t\t\t\t\tc[t]:= 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\tend\n\t\t\telse write(fo, S[k]);\n\tend\n\telse write(fo, -1);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": " {$mode objfpc}\n {$coperators on}\nuses math;\nconst\n {$ifdef online_judge} fi=''; fo='';\n {$else} fi='inp.inp';\n fo='out.out';\n {$endif}\n\nvar\n f : array['A'..'Z']of longint;\n q : longint;\n s : ansistring;\n mis : array[1..40] of char;\nprocedure enter;\nvar i, j : integer;\n begin\n readln(s);\n if length(s)<26 then\n begin\n writeln(-1); halt;\n end;\n end;\nprocedure ahihi(l,r:longint);\nvar i:char; b:boolean; c, ii:longint;\n begin\n c:=0;\n for i:='A' to 'Z' do if f[i]=0 then\n begin\n inc(c);\n mis[c]:=i;\n end;\n if q=c then\n begin\n c:=1;\n for ii:=l to r do\n begin\n if s[ii]<>'?' then write(s[ii]) else\n begin\n write(mis[c]);\n c+=1;\n end;\n end;\n halt;\n end;\n end;\nprocedure solve;\nvar i, j : integer;\n begin\n q:=0;\n for i:=1 to 26 do\n begin\n if s[i]<>'?' then f[s[i]]+=1 else q:=q+1;\n end;\n i:=1; j:=26;\n while(j<=length(s))do\n begin\n ahihi(i,j);\n if s[i]<>'?' then f[s[i]]-=1 else q-=1;\n i+=1; j+=1;\n if j>length(s) then break;\n if s[j]<>'?' then f[s[j]]+=1 else q+=1;\n end;\n writeln(-1);\n end;\nbegin\n\n assign(input, fi); assign(output, fo); reset(input); rewrite(output);\n enter;\n solve;\n close(input); close(output);\nend.\n\n\n"}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; \n End."}, {"source_code": "var \n s:ansistring;\n len,i:longint;\n flag:boolean;\n \nprocedure comp(x:longint);\nconst\n ch:array[1..26] of char=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');\nvar \n num:array[1..26] of longint;\n numq,i,j:longint;\n //st:ansistring;\nbegin \n fillchar(num,sizeof(num),0);\n numq:=0;\n for i:=x to x+26 do \n if (s[i]>='A')and(s[i]<='Z') then inc(num[ord(s[i])-64]) else inc(numq);\n for i:=x to x+26 do \n if s[i]='?' then begin \n j:=1;\n while num[j]<>0 do inc(j);\n num[j]:=1;\n s[i]:=ch[j];\n end;\nend;\n\nprocedure check(x:longint);\nvar\n num:array[1..26] of longint;\n i:longint;\nbegin \n fillchar(num,sizeof(num),0);\n for i:=x to x+26 do\n if (s[i]>='A')and(s[i]<='Z') then begin \n inc(num[ord(s[i])-64]);\n if num[ord(s[i])-64]>1 then begin flag:=false;exit;end;\n end;\n flag:=true;\nend;\n\nbegin \n readln(s);\n len:=length(s);\n if len<26 then begin writeln('-1');exit;end;\n for i:=1 to len-25 do begin \n check(i);\n\tif flag then comp(i);\n end;\n if flag then begin \n for i:=1 to len do \n if s[i]='?' then s[i]:='A';\n writeln(s);\n end else writeln('-1');\nend."}, {"source_code": "var s,s1:ansistring; \na:array[1..26]of longint; \ni,n,f,j:longint; \nbegin \nreadln(s); \nn:=length(s); \nif n<26 then begin writeln(-1); exit; end; \ns1:='ABCDEFGHIJKLMNOPQRSTUVWXYZ'; \nfor i:=1 to 26 do \nfor j:=1 to n do \nif s1[i]=s[j] then a[i]:=a[i]+1; \nfor i:=1 to n do \nif a[i]>1 then begin writeln(-1); exit; end; \ni:=1; \nwhile i<=n do begin \nif s[i]='?' then begin while s[i]='?' do begin delete(s,i,1);n:=n-1;if n1 then f:=1; \nif (n=26) and(f=0) then writeln(s) \nelse writeln(-1); \nend."}, {"source_code": "{$h+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); } \nreadln(s);\nss:='';\nfor ii:='A' to 'Z' do\n ss:=ss+ii; \nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwrite('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "var\n\ts,s1 : ansistring;\n\ti,j,a,hah : longint;\n\tk : char;\n\tcek : boolean;\n\tada : array['A'..'Z'] of boolean;\n\nbegin\n\treadln(s);\n\tcek := false;\n\tif length(s) < 26 then begin\n\t\twriteln(-1);\n\t\texit;\n\tend;\n\tfor i := 1 to (length(s)-25) do begin\n\t\thah := 0;\n\t\tfor k := 'A' to 'Z' do ada[k] := false;\n\t\tfor j := i to i+25 do begin\n\t\t\tif ada[s[j]] then hah := 1;\n\t\t\tif s[j] <> '?' then ada[s[j]] := true;\n\t\tend;\n\t\tif hah = 0 then begin\n\t\t\tfor j := i to i+25 do begin\n\t\t\t\tif s[j] = '?' then begin\n\t\t\t\t\tfor k := 'A' to 'Z' do begin\n\t\t\t\t\t\ta := 0;\n\t\t\t\t\t\tif not(ada[k]) then begin\n\t\t\t\t\t\t\ts[j] := k;\n\t\t\t\t\t\t\tada[k] := true;\n\t\t\t\t\t\t\ta := 1;\n\t\t\t\t\t\tend;\n\t\t\t\t\t\tif a = 1 then break;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\t\ts1 := copy(s,length(s)-25,26);\n\t\t\tif pos('?',s1) = 0 then cek := true;\n\t\tend;\n\tend;\n\twhile pos('?',s) <> 0 do s[pos('?',s)] := 'V';\n\tif cek then writeln(s)\n\telse writeln(-1);\nend."}, {"source_code": "const\n fi='';\nvar\n st:ansistring;\n a:array[0..50000,0..27] of longint;\n chuaxet:array[0..27] of boolean;\n ok:boolean;\n f:Text;\n j,n,i,tg:longint;\nbegin\n assign(f,fi); reset(f);\n readln(f,st);\n n:=length(st);\n if n<26 then\n begin\n writeln(-1); exit;\n end;\n for i:=1 to n do\n if st[i]<>'?' then\n begin\n tg:=ord(st[i])-65+1;\n inc(a[i,tg]);\n end;\n for i:=1 to n do\n for j:=1 to 26 do a[i,j]:=a[i,j]+a[i-1,j];\n for i:=1 to n-26+1 do\n begin\n fillchar(chuaxet,sizeof(chuaxet),true);\n ok:=true;\n for j:=1 to 26 do\n if a[i+26-1,j]-a[i-1,j]>=2 then\n begin\n ok:=false; break;\n end\n else if a[i+26-1,j]-a[i-1,j]=1 then chuaxet[j]:=false;\n if ok then\n begin\n tg:=1;\n for j:=i to i+26-1 do\n if st[j]<>'?' then write(st[j])\n else\n begin\n while (tg<=26) and (not chuaxet[tg]) do inc(tg);\n write(char(tg+65-1));\n inc(tg);\n end;\n readln;\n exit;\n end;\n end;\n writeln(-1);\n readln;\nend.\n\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= length(S);\n\tif n>26 then\n\tbegin\n\t\twriteln(fo, -1);\n\t\tclose(fi); close(fo);\n\t\texit;\n\tend\n\telse\n\tbegin\n\t\tfor j:=1 to n do\n\t\t\tif S[j]<>'?' then\n\t\t\tbegin\n\t\t\t\tinc(c[ord(S[j])-64]);\n\t\t\t\tif c[ord(S[j])-64]>1 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, -1);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tend;\n\tend;\n\tfor j:=1 to n do\n\t\tif S[j]<>'?' then write(fo, S[j])\n\t\telse\n\t\t\tfor i:=1 to 26 do\n\t\t\t\tif c[i]=0 then\n\t\t\t\tbegin\n\t\t\t\t\twrite(fo, chr(i+64));\n\t\t\t\t\tc[i]:= 1;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "const\n inp = 'input.txt';\n out = 'output.txt';\n maxn = 50000 + 5;\n\nvar\n n : longint;\n a, b : array[0..maxn] of longint;\n mark : array[0..26] of boolean;\n\nprocedure init;\n var i : longint;\n x : char;\n begin\n n := 0;\n while (not eof) do\n begin\n inc(n);\n read(x);\n if x = '?' then a[n] := 0\n else a[n] := ord(x) - ord('A') + 1;\n end;\n end;\n\nprocedure solve;\n var i, j, m : longint;\n check : boolean;\n begin\n for i := 1 to n - 25 do\n begin\n for j := 1 to 26 do mark[j] := false;\n check := true;\n\n for j := i to i + 26 - 1 do\n begin\n if (a[j] > 0) then\n if (mark[a[j]] = true) then\n begin\n check := false;\n break;\n end\n else mark[a[j]] := true;\n end;\n if check = true then\n begin\n m := 0;\n for j := 1 to 26 do\n if mark[j] = false then\n begin\n inc(m);\n b[m] := j;\n end;\n m := 0;\n for j := 1 to i - 1 do\n if a[j] = 0 then write('?')\n else write(chr(a[j] - 1 + ord('A')));\n\n for j := i to i + 26 - 1 do\n if a[j] > 0 then write(chr(a[j] - 1 + ord('A')))\n else\n begin\n inc(m);\n write(chr(b[m] - 1 + ord('A')));\n end;\n\n for j := i + 26 to n do\n if a[j] = 0 then write('?')\n else write(chr(a[j] - 1 + ord('A')));\n break;\n end;\n end;\n if not check then writeln(-1);\n end;\n\nbegin\n //assign(input, inp); reset(input);\n //assign(output, out); rewrite(output);\n init;\n solve;\nend.\n"}, {"source_code": "const fi='b.inp';\n fo='b.out';\nvar s:ansistring;\n i,j:longint;\n d:array['A'..'Z']of longint;\n jj:char;\n ktt:boolean;\nfunction kt:boolean;\nvar j:char;\n begin\n for j:='A' to 'Z' do\n if d[j]>1 then exit(false);\n exit(true);\n end;\nbegin\n //assign(input,fi);reset(input);\n //assign(output,fo);rewrite(output);\n ktt:=false;\n readln(s);\n if length(s)<26 then ktt:=true; \n for i:=1 to length(s) do\n begin\n if s[i]<>'?' then inc(d[s[i]]);\n if i>=26 then\n begin\n if kt=true then\n begin\n ktt:=true;\n for j:=i-25 to i do\n if s[j]='?' then\n for jj:='A' to 'Z' do\n if d[jj]=0 then\n begin\n inc(d[jj]);\n s[j]:=jj;\n break;\n end;\n break;\n end;\n end;\n if (i>26)and (s[i-26]<>'?') then dec(d[s[i-26]]);\n end;\n for i:=1 to length(s) do\n if s[i]='?' then s[i]:='A';\n if ktt=false then writeln(-1) else writeln(s);\nend.\n"}, {"source_code": "Var s:ansistring;\n sc,l,r,i,j,f:longint;\n a:array[65..90] of longint;\n Begin\n readln(s);\n sc:=0;\n l:=1;\n r:=27;\n f:=0;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]='?' then sc:=sc+1\n else a[ord(s[i])]:=a[ord(s[i])]+1;\n while (r<=length(s)) and (f=0) do\n begin\n for j:=65 to 90 do\n if a[j]>2 then f:=1;\n if s[l]='?' then sc:=sc-1 \n else a[ord(s[l])]:=a[ord(s[l])]-1;\n if s[r]='?' then sc:=sc-1\n else a[ord(s[r])]:=a[ord(s[r])]-1;\n r:=r+1;\n l:=l+1;\n end;\n for j:=65 to 90 do\n if a[j]>1 then f:=1;\n if f=1 then writeln(-1)\n else \n for i:=l to r-1 do\n if s[i]='?' then\n begin\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else write(s[i]);\n End.\n \n \n "}, {"source_code": "var\n\ts : ansistring;\n\ti,j,a : longint;\n\tk : char;\n\tada : array['A'..'Z'] of boolean;\n\nbegin\n\treadln(s);\n\tif length(s) < 26 then begin\n\t\twriteln(-1);\n\t\texit;\n\tend;\n\tfor i := 1 to (length(s)-25) do begin\n\t\tfor k := 'A' to 'Z' do ada[k] := false;\n\t\tfor j := i to i+25 do begin\n\t\t\tif ada[s[j]] then begin\n\t\t\t\twriteln(-1);\n\t\t\t\texit;\n\t\t\tend;\n\t\t\tif s[j] <> '?' then ada[s[j]] := true;\n\t\tend;\n\t\tfor j := i to i+25 do begin\n\t\t\tif s[j] = '?' then begin\n\t\t\t\tfor k := 'A' to 'Z' do begin\n\t\t\t\t\ta := 0;\n\t\t\t\t\tif not(ada[k]) then begin\n\t\t\t\t\t\ts[j] := k;\n\t\t\t\t\t\tada[k] := true;\n\t\t\t\t\t\ta := 1;\n\t\t\t\t\tend;\n\t\t\t\t\tif a = 1 then break;\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\twriteln(s);\nend."}, {"source_code": "var\ns,s1:ansistring;\na:array[1..26] of longint;\ni,j,q:longint;\nbegin\nreadln(S);\n//s:='ABC??FGHIJK???OPQR?TUVWXY?';\n\nfor i:=1 to length(S)-25 do begin\ns1:=copy(s,i,26);\nq:=0;\nfor j:=1 to 26 do\na[j]:=0;\nfor j:=1 to 26 do\nif s1[j]<>'?'\nthen\ninc(a[ord(s1[j])-64]);\nfor j:=1 to 26 do\nif a[j]>1\nthen q:=1;\nif q=0\nthen begin\nfor j:=i to i+25 do\nif s[j]='?'\nthen for q:=1 to 26 do\nif a[q]=0\nthen begin\ns[j]:=chr(q+64);\ninc(a[q]);\nbreak;\nend;\nbreak;\nend;\nif i=length(s)-25\nthen begin writeln(-1); halt;end;\nend;\nfor i:=1 to length(S) do\nif s[i]='?'\nthen s[i]:='A';\nwriteln(S);\nend.\n\n"}, {"source_code": "{$h+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); } \nreadln(s);\nss:='';\nfor ii:='A' to 'Z' do\n ss:=ss+ii; \nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwrite('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "var possible:boolean;\n\tst:string;\n\tsum:int64;\n\ti,j:int32;\n\tcount:array[1..30] of int64;\nBegin\n\tRead(st);\n\tpossible:=False;\n\tIf (length(st)>=26) then\n\t\tBegin\n\t\t\tFor i:=1 to length(st)-26+1 do \n\t\t\t\tIf not possible then\n\t\t\t\t\tBegin\n\t\t\t\t\t\tFillchar(count,sizeof(count),0);\n\t\t\t\t\t\tFor j:=i to i+26 do\n\t\t\t\t\t\t\tInc(count[Ord(st[i])-Ord('?')]);\n\t\t\t\t\t\tFor j:=i to Ord('Z')-Ord('?') do\n\t\t\t\t\t\t\tIf (count[i]>0) then inc(sum);\n\t\t\t\t\t\tdec(count[0]);\n\t\t\t\t\t\tIf (count[0]<26-sum) or (count[0]>26-sum) then possible:=False\n\t\t\t\t\t\tElse \n\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\tpossible:=True;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tEnd;\n\t\t\t\t\tEnd;\n\t\tEnd;\n\tIf possible then Writeln('1')\n\tElse Writeln('-1');\nEnd."}, {"source_code": "var n,m,i,j,k,ned:longint;\n f:array['A'..'Z']of longint;\n s:ansistring;\n c:char; \nbegin\nreadln(s);\nif length(s)<26 then begin writeln(-1);halt;end;\nfor j:=1 to 26 do begin\n if s[j]<>'?' then inc(f[s[j]]) else inc(k);\nend;\nfor i:=1 to length(s)-25 do begin\n if i>1 then begin\n if s[i-1]='?' then dec(k) else dec(f[s[i-1]]);\n if s[i+25]='?' then inc(k) else inc(f[s[i+25]]);\n end; \n ned:=0;\n for c:='A' to 'Z' do if f[c]=0 then inc(ned);\n if ned<=k then begin\n for j:=1 to 26 do begin\n if s[i+j-1]<>'?' then write(s[i+j-1]) else begin\n for c:='A' to 'Z' do if f[c]=0 then begin inc(f[c]);write(c);break;end;\n end;\n end;\n halt;\n end;\nend;\nwriteln(-1);\nend.\n \n"}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:string;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i+1 to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break; \n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(0,26)\nelse\nbegin\nfor i:=2 to length(s)-26 do\nif s[i]<>'?' then\n begin\n if a[s[i]]=2 then dec(top);\n dec(a[s[i]]);\n if s[i+26]<>'?' then\n begin\n if a[s[i+26]]=1 then inc(top);\n inc(a[s[i+26]]);\n end;\n if top=0 then\n begin\n tx(i,i+26);\n break;\n end;\n end;\nend;\nif h=1 then\nwriteln(s)\nelse\nwriteln('-1');\nend;\nend.\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j, k: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\ti:= 1; j:= 2;\n\tif S[i]<>'?' then c[ord(S[i])-64]:= 1;\n\twhile (i<=n) and (j<=n) do\n\tbegin\n\t\tif S[j]<>'?' then\n\t\tbegin\n\t\t\tif c[ord(S[j])-64]=1 then\n\t\t\tbegin\n\t\t\t\tc[ord(S[i])-64]:= 0;\n\t\t\t\tinc(i);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tc[ord(S[j])-64]:= 1;\n\t\t\t\tif j-i+1=26 then break;\n\t\t\t\tinc(j);\n\t\t\tend;\n\t\tend\n\t\telse inc(j);\n\t\tif j-i+1>26 then inc(i);\n\tend;\n\tif j>n then \n\tbegin\n\t\tdec(j); \n\t\tdec(i);\n\tend;\n\trandomize;\n\tif j-i+1=26 then\n\tbegin\n\t\tfor k:=1 to n do\n\t\t\tif S[k]='?' then\n\t\t\tbegin\n\t\t\t\tif (kj) then write(fo, chr(1+random(26)))\n\t\t\t\telse\n\t\t\t\t\tfor t:=1 to 26 do\n\t\t\t\t\t\tif c[t]=0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(fo, chr(t+64));\n\t\t\t\t\t\t\tc[t]:= 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\tend\n\t\t\telse write(fo, S[k]);\n\tend\n\telse write(fo, -1);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "var a:array['A'..'Z']of longint;\nn,i,l,r:longint;\ns,ans:ansistring;\nc:char;\nb:boolean;\n\nprocedure finish;\nbegin\nfor i:=l to r do\nif s[i]='?'then\nfor c:='A' to 'Z' do\nif a[c]=0 then begin a[c]:=1; s[i]:=c; break; end;\nwriteln(s);\nhalt;\nend;\n\nbegin\nans:='';\nreadln(s);\nn:=length(s);\nfor c:='A' to 'Z' do a[c]:=0;\nif n<26 then\nbegin\nwrite(-1);\nhalt;\nend;\nl:=1;\nr:=26;\nwhile r<=n do\nbegin\nfor c:='A' to 'Z' do a[c]:=0;\nb:=true;\nfor i:=l to r do\nif s[i]<>'?' then\nbegin\ninc(a[s[i]]);\nif a[s[i]]=2 then begin l:=l+1; r:=l+25; b:=false; break; end;\nend;\nif b then finish;\nend;\nwrite(-1);\nend.\n"}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<>26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; \n End."}, {"source_code": "label 1;\nvar s,s2:string;\n i,j,k,no,ko:longint;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(s);\nif length(s)<26 then\nbegin\nwrite(-1);\nhalt;\nend;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ni:=1;\n1: while i<=length(s)-25 do\nbegin\nfor j:=i to 25+i do\nbegin\nif s[j]<>'?' then\nbegin\nif pos(s[j],s2)=0 then\nbegin\ninc(i);\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ngoto 1;\nend;\ndelete(s2,pos(s[j],s2),1);\nend;\nend;\nno:=i;\nko:=25+i;\nbreak;\nend;\nif i>length(s)-25 then\nbegin\nwrite(-1);\nhalt;\nend;\nif s2='' then\nbegin\nwrite(-1);\nhalt;\nend;\nk:=1;\nfor i:=1 to length(s) do\nbegin\nif (i=no) and (i<=ko) then\nif s[i]='?' then\nbegin\nwrite(s2[k]);\ninc(k);\nend\nelse write(s[i]);\nend;\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "var\n i,j,k,n,t,l,l1,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,s1,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \nfunction proverka:boolean;\nvar alp,s1:ansistring;\ni,j,l,k1:longint;\nx:array[1..260000]of integer;\nflag,flag1:integer;\n begin\n l:=length(s);\n flag1:=0;\n for k1:=1 to l do begin \n s1:=copy(s,k1,26);\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n \n \n //s1:=copy(s,i,26);\n flag:=1;\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for j:=1 to 26 do\n if x[j]=0 then flag:=0;\n if flag=1 then flag1:=1;\n end; \n proverka:=(flag1=1);\n end;\nbegin\n readln(s);\n/// writeln(s);\nl:=length(s);\nif l<26 then writeln(-1)\n else begin\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n// while ((i<=l)and(flag1=0)) do begin\n // s1:=copy(s,i,26);\n// flag:=1;\n// for j:=1 to 26 do\n // x[j]:=0;\n // for j:=1 to 26 do begin\n // if (s1[j]=alp[j])then x[j]:=1;\n// end;\n // for j:=1 to 26 do\n // if x[j]=0 then flag:=0;\n// if flag=1 then flag1:=1\n// else i:=i+1; \n// end;\n// if flag1=1 then begin\n // while (pos('?',s)<>0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for k1:=1 to l do begin\n s1:=copy(s,k1,26);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for i:=1 to 26 do begin\n if (s1[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s1[i]:=alp[j];\n x[j]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n \n while (pos('?',s1)<>0) do begin\n i:=pos('?',s1);\n delete(s1,i,1);\n insert('A',s1,i);\n end;\n delete(s,k1,26);\n insert(s1,s,k1);\n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n // writeln(s1);\n end;\n//writeln(s);\n if (proverka) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": "var alf,st:ansistring;\nl,i,j,kol,p:longint;\na:array[0..100] of longint;\nbegin\n alf:='QWERTYUIOPASDFGHJKLZXCVBNM';\n readln(st);\n l:=length(st);\n for i:=1 to l do\n if st[i]<>'?' then begin\n p:=0;\n p:=pos(st[i],alf);\n if a[p]=1 then begin\n writeln(-1);\n halt;\n end\n else if a[p]=0 then a[p]:=1;\n end\n else kol:=kol+1;\n if l=26 then begin\n if kol=0 then writeln(st)\n else begin\n for i:=1 to l do\n if st[i]='?' then begin\n for j:=1 to 26 do\n if a[j]=0 then begin\n a[j]:=1;\n break;\n end;\n st[i]:=alf[j];\n end;\n writeln(st);\n end;\n end\nelse begin\n writeln(-1);\n end;\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar a: array['A'..'Z'] of boolean;\n b: array[1..100000] of longint;\n i, j, x, m: longint;\n s: ansistring;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(s);\n for i:=1 to length(s)-25 do\n begin\n x:=0;\n fillchar(a,sizeof(a),false);\n for j:=i to i+25 do\n if s[j] = '?' then\n begin\n inc(x);\n b[x]:=j;\n end\n else a[s[j]]:=true;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then inc(m);\n if m > x then continue;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then\n begin\n inc(m);\n s[b[m]]:=c;\n end;\n for j:=i+26 to length(s) do if s[j] = '?' then s[j]:='A';\n writeln(s);\n halt;\n end;\n writeln(-1);\n\n close(input); close(output);\nend.\n"}, {"source_code": "label 1;\nvar s,s2:string;\n i,j,k,no,ko:longint;\nbegin\nread(s);\nif length(s)<26 then\nbegin\nwrite(-1);\nhalt;\nend;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ni:=1;\n1: while i<=length(s)-25 do\nbegin\nfor j:=i to 25+i do\nbegin\nif s[j]<>'?' then\nbegin\nif pos(s[j],s2)=0 then\nbegin\ni:=j+1;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ngoto 1;\nend;\ndelete(s2,pos(s[j],s2),1);\nend;\nend;\nno:=i;\nko:=25+i;\nbreak;\nend;\nif i>length(s)-25 then\nbegin\nwrite(-1);\nhalt;\nend;\n{if s2='' then\nbegin\nwrite(-1);\nhalt;\nend;}\nk:=1;\nfor i:=no to ko do\nif s[i]='?' then\nbegin\nwrite(s2[k]);\ninc(k);\nend\nelse write(s[i]);\nend."}, {"source_code": "var\n i,j,k,n,t,l,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \nfunction proverka:boolean;\nvar alp:ansistring;\ni,j,l:longint;\nx:array[1..260000]of integer;\nflag,flag1:integer;\n begin\n l:=length(s);\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n \n //s1:=copy(s,i,26);\n flag:=1;\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to l do begin\n for j:=1 to 26 do begin\n if (s[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for j:=1 to 26 do\n if x[j]=0 then flag:=0;\n if flag=1 then flag1:=1;\n \n \n proverka:=(flag1=1);\n end;\nbegin\n readln(s);\n/// writeln(s);\nl:=length(s);\nif l<26 then writeln(-1)\n else begin\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n// while ((i<=l)and(flag1=0)) do begin\n // s1:=copy(s,i,26);\n// flag:=1;\n// for j:=1 to 26 do\n // x[j]:=0;\n // for j:=1 to 26 do begin\n // if (s1[j]=alp[j])then x[j]:=1;\n// end;\n // for j:=1 to 26 do\n // if x[j]=0 then flag:=0;\n// if flag=1 then flag1:=1\n// else i:=i+1; \n// end;\n// if flag1=1 then begin\n // while (pos('?',s)<>0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to l do begin\n for j:=1 to 26 do begin\n if (s[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for i:=1 to l do begin\n if (s[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s[i]:=alp[j];\n x[j]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n \n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n \n// end;\n//writeln(s);\n if (proverka) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar a: array['A'..'Z'] of boolean;\n b: array[1..100000] of longint;\n i, j, x, m: longint;\n s: ansistring;\n c: char;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(s);\n for i:=1 to length(s)-25 do\n begin\n x:=0;\n fillchar(a,sizeof(a),false);\n for j:=i to i+25 do\n if s[j] = '?' then\n begin\n inc(x);\n b[x]:=j;\n end\n else a[s[j]]:=true;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then inc(m);\n if m > x then continue;\n m:=0;\n for c:='A' to 'Z' do if a[c] = false then\n begin\n inc(m);\n s[b[m]]:=c;\n end;\n for j:=i+26 to length(s) do if s[j] = '?' then s[j]:='A';\n writeln(s);\n halt;\n end;\n writeln(-1);\n\n close(input); close(output);\nend.\n"}, {"source_code": "var a:array['A'..'Z']of longint;\nn,i,l,r:longint;\ns,ans:ansistring;\nc:char;\nb:boolean;\n\nprocedure finish;\nbegin\nfor i:=l to r do\nif s[i]<>'?'then\nans:=ans+s[i] else\nfor c:='A' to 'Z' do\nif a[c]=0 then begin a[c]:=1; ans:=ans+c; break; end;\nwriteln(ans);\nhalt;\nend;\n\nbegin\nans:='';\nreadln(s);\nn:=length(s);\nfor c:='A' to 'Z' do a[c]:=0;\nif n<26 then\nbegin\nwrite(-1);\nhalt;\nend;\nl:=1;\nr:=26;\nwhile l+25<=n do\nbegin\nfor c:='A' to 'Z' do a[c]:=0;\nb:=true;\nfor i:=l to r do\nif s[i]<>'?' then\nbegin\ninc(a[s[i]]);\nif a[s[i]]=2 then begin l:=l+1; r:=l+25; b:=false; break; end\nend;\nif b then finish;\nend;\nwrite(-1);\nend.\n"}, {"source_code": "var n,m,i,j,k,ned:longint;\n f:array['A'..'Z']of longint;\n s:ansistring;\n c:char; \nbegin\nreadln(s);\nif length(s)<26 then begin writeln(-1);halt;end;\nfor j:=1 to 26 do begin\n if s[j]<>'?' then inc(f[s[j]]) else inc(k);\nend;\nfor i:=1 to length(s)-25 do begin\n if i>1 then begin\n if s[i-1]='?' then dec(k) else dec(f[s[i-1]]);\n if s[i+25]='?' then inc(k) else inc(f[s[i+25]]);\n end; \n ned:=0;\n for c:='A' to 'Z' do if f[c]=0 then inc(ned);\n if ned<=k then begin\n for j:=1 to 26 do begin\n if s[i+j-1]<>'?' then write(s[i+j-1]) else begin\n for c:='A' to 'Z' do if f[c]=0 then begin inc(f[c]);write(c);break;end;\n end;\n end;\n halt;\n end;\nend;\nwriteln(-1);\nend.\n \n"}, {"source_code": "var \n s:ansistring;\n len,i:longint;\n flag:boolean;\n \nprocedure comp(x:longint);\nconst\n ch:array[1..26] of char=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');\nvar \n num:array[1..26] of longint;\n numq,i,j:longint;\nbegin \n fillchar(num,sizeof(num),0);\n numq:=0;\n for i:=x to x+25 do \n if (s[i]>='A')and(s[i]<='Z') then inc(num[ord(s[i])-64]) else inc(numq);\n for i:=x to x+25 do \n if s[i]='?' then begin \n j:=1;\n while num[j]<>0 do inc(j);\n num[j]:=1;\n s[i]:=ch[j];\n end;\nend;\n\nprocedure check(x:longint);\nvar\n num:array[1..26] of longint;\n i:longint;\nbegin \n fillchar(num,sizeof(num),0);\n for i:=x to x+26 do\n if (s[i]>='A')and(s[i]<='Z') then begin \n inc(num[ord(s[i])-64]);\n if num[ord(s[i])-64]>1 then begin flag:=false;exit;end;\n end;\n flag:=true;\nend;\n\nbegin \n readln(s);\n len:=length(s);\n if len<26 then begin writeln('-1');exit;end;\n for i:=1 to len-25 do begin \n check(i);\n\tif flag then begin comp(i);break;end;\n end;\n //writeln(s);\n// writeln(len);\n if flag then begin \n for i:=1 to len do \n if s[i]='?' then s[i]:='A';\n writeln(s);\n end else writeln('-1');\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint; s,s1,s2:ansistring;\n\nFunction TryFill(s1:ansistring):ansistring;\nvar i,j,k,l,m,qnum,znum,uk:longint; Z:array[1..26] of byte; ch:char; sm:string;\nbegin\nqnum:=0; sm:='';\nfor i:=1 to 26 do Z[i]:=0;\nfor i:=1 to 26 do\n begin\n if s1[i]='?' then inc(qnum) else inc(Z[ord(s1[i])-64]);\n end;\nfor i:=1 to 26 do if Z[i]=0 then begin inc(znum); sm:=sm+chr(i+64); end;\nif qnum<>znum then exit('');\nuk:=1;\nfor i:=1 to 26 do\nif s1[i]='?' then begin s1[i]:=sm[uk]; inc(uk); end;\nexit(s1);\nend;\n\n\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(s);\nfor i:=1 to (length(s)-25) do\n begin\n s1:=copy(s,i,26);\n s2:=TryFill(s1);\n if s2<>'' then\n begin\n delete(s,i,26);\n insert(s2,s,i);\n for j:=1 to length(s) do if s[j]='?' then s[j]:='A';\n writeln(s);\n exit;\n end;\n end;\nwrite('-1');\nend."}, {"source_code": "var\n s,s2:ansistring;\n len,i,j,z,p:longint;\n ch:char;\n bo:boolean;\n c:array[0..100]of char;\n b:array['?'..'Z']of boolean;\nbegin\n read(s);\n len:=length(s);\n bo:=true;\n for i:=1 to len-25 do\n begin\n fillchar(b,sizeof(b),false);\n p:=0;\n for j:=1 to 27 do\n begin\n if j=27 then break;\n if s[i+j-1]='?' then inc(p)\n else begin\n if b[s[j]] then break\n else b[s[j]]:=true;\n end;\n end;\n if j<27 then continue;\n z:=0;\n for ch:='A' to 'Z' do\n begin\n if not b[ch] then\n begin\n inc(z);\n c[z]:=ch;\n end;\n end;\n s2:=s;\n z:=0;\n for j:=1 to 26 do\n if s2[i+j-1]='?' then begin\n inc(z);\n s2[i+j-1]:=c[z];\n end;\n bo:=false;\n break;\n end;\n if bo then write(-1)\n else begin\n for i:=1 to len do\n begin\n if s2[i]='?' then write('A')\n else write(s2[i]);\n end;\n end;\nend.\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j, k: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\ti:= 1; j:= 2;\n\tif S[i]<>'?' then c[ord(S[i])-64]:= 1;\n\twhile (i<=n) and (j<=n) do\n\tbegin\n\t\tif S[j]<>'?' then\n\t\tbegin\n\t\t\tif c[ord(S[j])-64]=1 then\n\t\t\tbegin\n\t\t\t\tc[ord(S[i])-64]:= 0;\n\t\t\t\tinc(i);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tc[ord(S[j])-64]:= 1;\n\t\t\t\tif j-i+1=26 then break;\n\t\t\t\tinc(j);\n\t\t\tend;\n\t\tend\n\t\telse inc(j);\n\t\tif j-i+1>26 then inc(i);\n\tend;\n\tif j>n then \n\tbegin\n\t\tdec(j); \n\t\tdec(i);\n\tend;\n\trandomize;\n\tif j-i+1=26 then\n\tbegin\n\t\tfor k:=1 to n do\n\t\t\tif S[k]='?' then\n\t\t\tbegin\n\t\t\t\tif (kj) then write(fo, chr(65+random(26)))\n\t\t\t\telse\n\t\t\t\t\tfor t:=1 to 26 do\n\t\t\t\t\t\tif c[t]=0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(fo, chr(t+64));\n\t\t\t\t\t\t\tc[t]:= 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\tend\n\t\t\telse write(fo, S[k]);\n\tend\n\telse write(fo, -1);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "function nice(const s:string):boolean;\n var i,sum,temp:integer;\n r:boolean;\n x:char;\n ans:string;\n a:array['A'..'Z'] of integer;\nbegin\n temp:=0;\n ans:=s;\n sum:=0;\n for x:='A' to 'Z' do a[x]:=0;\n for i:=1 to length(S) do \n if (s[i]='?') then temp:=temp+1 else a[s[i]]:=1;\n for x:='A' to 'Z' do sum:=sum+a[x];\n if (sum+temp<26) then nice:=false else begin\n for x:='A' to 'Z' do begin\n if ((a[x]=0) and (temp>0)) then begin\n insert(x,ans,pos('?',ans));\n delete(ans,pos('?',ans),1);\n end;\n end;\n writeln(ans);\n nice:=true;\n end;\n \nend;\nvar s,t:string;\n i:integer;\n ans:boolean;\nbegin\n readln(s);\n ans:=false;\n t:='';\n if (length(s)<26) then write(-1) else begin\n for i:=1 to length(s)-25 do begin\n t:=copy(s,i,26);\n if nice(t) then begin\n ans:=true;\n break;\n end;\n end;\n if not ans then write(-1);\n end;\nend."}, {"source_code": "{$H+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);} \nread(s);\nif length(s)<26 then begin writeln('-1'); halt; end;\nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwriteln('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "const\n inp = 'input.txt';\n out = 'output.txt';\n maxn = 500000 + 5;\n\nvar\n n : longint;\n a, b : array[0..maxn] of longint;\n mark : array[0..27] of boolean;\n\nprocedure init;\n var i : longint;\n x : char;\n begin\n n := 0;\n while (not seekeof) do\n begin\n inc(n);\n read(x);\n if x = '?' then a[n] := 0\n else a[n] := ord(x) - ord('A') + 1;\n end;\n end;\n\nprocedure solve;\n var i, j, m : longint;\n check : boolean;\n begin\n for i := 1 to n - 25 do\n begin\n for j := 1 to 26 do mark[j] := false;\n check := true;\n\n for j := i to i + 25 do\n if (a[j] > 0) then\n if (mark[a[j]] = true) then\n begin\n check := false;\n break;\n end\n else mark[a[j]] := true;\n\n if check = true then\n begin\n m := 0;\n for j := 1 to 26 do\n if mark[j] = false then\n begin\n inc(m);\n b[m] := j;\n end;\n\n m := 0;\n for j := i to i + 25 do\n if a[j] > 0 then write(chr(a[j] - 1 + ord('A')))\n else\n begin\n inc(m);\n write(chr(b[m] - 1 + ord('A')));\n end;\n\n exit;\n end;\n end;\n if not check then writeln(-1);\n end;\n\nbegin\n //assign(input, inp); reset(input);\n //assign(output, out); rewrite(output);\n init;\n solve;\nend.\n"}, {"source_code": "var\n s:ansistring;\n a:array[65..90]of longint;\n n,k,i,l,r,p,j:longint;\n\nprocedure ans(s:ansistring);\nbegin\n writeln(s);\n halt;\nend;\n\nfunction check:boolean;\nvar\n i,k1:longint;\nbegin\n k1:=0;\n for i:=65 to 90 do if a[i]>1 then exit(false) else if a[i]=1 then inc(k1);\n if k1+k=26 then exit(true) else exit(false);\nend;\n\n\nbegin\n readln(s);\n if length(s)<26 then ans('-1');\n for i:=1 to 26 do if s[i]<>'?' then inc(a[ord(s[i])]) else inc(k);\n l:=1;\n r:=26;\n\n if check then\n begin\n p:=64;\n for i:=1 to length(s) do if s[i]='?' then\n begin\n if (ir) then s[i]:='A' else\n begin\n for j:=p+1 to 90 do if a[j]=0 then\n begin\n s[i]:=chr(j);\n p:=j;\n break;\n end;\n end;\n end;\n ans(s);\n end;\n\n\n\n repeat\n inc(r);\n if s[r]<>'?' then inc(a[ord(s[r])]) else inc(k);\n if s[l]<>'?' then dec(a[ord(s[l])]) else dec(k);\n inc(l);\n if check then\n begin\n p:=64;\n for i:=1 to length(s) do if s[i]='?' then\n begin\n if (ir) then s[i]:='A' else\n begin\n for j:=p+1 to 90 do if a[j]=0 then\n begin\n s[i]:=chr(j);\n p:=j;\n break;\n end;\n end;\n end;\n ans(s);\n end;\n until r=length(s);\n ans('-1');\nend.\n"}, {"source_code": "var i,j,m,n,len,k:longint;\n pfx:array[0..50005,0..25]of longint;\n s:ansistring;\n used:array[0..25]of boolean;\n flag:boolean;\nbegin\n readln(s);\n len:=length(s);\n for i:=1 to len do begin\n if s[i]='?' then begin\n for j:=0 to 25 do pfx[i,j]:=pfx[i-1,j];\n end else begin\n for j:=0 to 25 do if ord('A')+j<>ord(s[i]) then pfx[i,j]:=pfx[i-1,j] else pfx[i,j]:=pfx[i-1,j]+1;\n end;\n end;\n if len<26 then writeln(-1) else begin\n for i:=1 to len-25 do begin\n flag:=true;\n for j:=0 to 25 do begin\n if pfx[i+25,j]-pfx[i-1,j]>1 then flag:=false;\n end;\n if flag then begin\n fillchar(used,sizeof(used),false);\n for j:=i to i+25 do if s[j]<>'?' then used[ord(s[i])-ord('A')]:=true;\n for j:=i to i+25 do begin\n if s[j]<>'?' then write(s[j]) else begin\n for k:=0 to 25 do if used[k]=false then begin\n write(chr(k+ord('A')));\n used[k]:=true;\n end;\n end;\n end;\n writeln;\n //close input output\n halt;\n end;\n end;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "label 1;\nvar s,s2:string;\n i,j,k,no,ko:longint;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(s);\nif length(s)<26 then\nbegin\nwrite(-1);\nhalt;\nend;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ni:=1;\n1: while i<=length(s)-25 do\nbegin\nfor j:=i to 25+i do\nbegin\nif s[j]<>'?' then\nbegin\nif pos(s[j],s2)=0 then\nbegin\ni:=j;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ngoto 1;\nend;\ndelete(s2,pos(s[j],s2),1);\nend;\nend;\nno:=i-1;\nko:=25+i;\nbreak;\nend;\nif i>length(s)-25 then\nbegin\nwrite(-1);\nhalt;\nend;\nif s2='' then\nbegin\nwrite(-1);\nhalt;\nend;\nk:=1;\nfor i:=1 to length(s) do\nbegin\nif (i=no) and (i<=ko) then\nif s[i]='?' then\nbegin\nwrite(s2[k]);\ninc(k);\nend\nelse write(s[i]);\nend;\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f,sc:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n sc:=0;\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]='?' then sc:=sc+1\n else a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n if s[l-1]='?' then sc:=sc-1 \n else a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n if s[r]='?' then sc:=sc+1\n else a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if s[i]='?' then\n begin\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else write(s[i]);\n End."}, {"source_code": " {$mode objfpc}\n {$coperators on}\nuses math;\nconst\n {$ifdef online_judge} fi=''; fo='';\n {$else} fi='inp.inp';\n fo='out.out';\n {$endif}\n\nvar\n f : array['A'..'Z']of longint;\n q : longint;\n s : ansistring;\n mis : array[1..40] of char;\nprocedure enter;\nvar i, j : integer;\n begin\n readln(s);\n if length(s)<26 then\n begin\n writeln(-1); halt;\n end;\n end;\nprocedure ahihi(l,r:longint);\nvar i:char; b:boolean; c, ii:longint;\n begin\n c:=0;\n for i:='A' to 'Z' do if f[i]=0 then\n begin\n inc(c);\n mis[c]:=i;\n end;\n if q=c then\n begin\n c:=1;\n for ii:=l to r do\n begin\n if s[ii]<>'?' then write(s[ii]) else\n begin\n write(mis[c]);\n c+=1;\n end;\n end;\n halt;\n end;\n end;\nprocedure solve;\nvar i, j : integer;\n begin\n q:=0;\n for i:=1 to 26 do\n begin\n if s[i]<>'?' then f[s[i]]+=1 else q:=q+1;\n end;\n i:=1; j:=26;\n while(j<=length(s))do\n begin\n ahihi(i,j);\n if s[i]<>'?' then f[s[i]]-=1 else q-=1;\n i+=1; j+=1;\n if j>length(s) then break;\n if s[j]<>'?' then f[s[j]]+=1 else q+=1;\n end;\n writeln(-1);\n end;\nbegin\n\n assign(input, fi); assign(output, fo); reset(input); rewrite(output);\n enter;\n solve;\n close(input); close(output);\nend.\n\n\n"}, {"source_code": "uses strutils;\n\n const eps=1e-11; besk=8000000000000000000;\n modul=1000000007;\n label 1,2,3,4,11;\n type\n\n mas=array [-10000..1000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var aa,bb,olda1,olda2,ot,q1,aa2,bb2,aa1,bb1,t,t0,t1,p,kol,i1,j1,newdl,dl,kk,t2,m1,n1,pp,px,py,ll,cc,n2,dist,pos,dloch,x0,tt,v1,v2,p3,p4,t4,t5,t6,t3,xx,yy,ost,rr,q,h,n,qq,p1,p2,y0,s1,s2,m,imax,smin,besk1:int64;\n ii,jj,step,k,i,j:longint;\n c1,c2:array[-1000..100000] of int64;\n x,y:array[-10..65000,0..100] of int64;\n h1,h2:extended;\n dd1,dd2,newoch,sum,ugol,s,place,xnew,z,och,fact,d, a1,bl,br,c,a,b:array[-10000001..3000000] of int64;\n stoim:array[-10..1200,-10..1200] of int64;\n ss,ss1,ss2 :string;\n gr:array[-100..5000,-100..5000] of boolean;\n ssot:array[-100..10000] of char;\n ch: char;\n ppp:zap;\n pole,pole1:array[-10..1400,-10..1400] of char;\n prost, zan,marked:array[-1000001..1100000] of boolean;\n sss1,name1,name2,sp,sss,maxpr:array[0..1000000] of string;\n w,mm,nn,mm1,nn1,hh,ttt, l, aanew,v0,s0:extended;\n { z,y,x:array[-1..300,-10..1000] of int64;\n }\n prvin,prlost,prob,x1,y1, xxx,yyy:array[-1..1000000] of extended;\n tt1, xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var aa,bb,qq,d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n aa:=a;bb:=b;\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2;\n flag:=x*aa+y*bb=d;\n if flag then begin tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end;\n flag:=x*bb+y*aa=d;\n if flag then begin tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\n\n\n evkl:=tt1;\nend;\n\nfunction degg(modul,a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(modul,a,k-1)*a) mod modul else\n begin p:=degg(modul,a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction good(ii,jj:longint):boolean;\nvar pp,i,j:longint; a:array[-100..300] of longint; fl:boolean;\n begin\n for i:=-1 to 50 do a[i]:=0; pp:=0;\n for i:=ii to jj do\n if ss[i]<>'?' then inc(a[ord(ss[i])-ord('A')]) else inc(pp);\n for i:=0 to 25 do if a[i]=0 then dec(pp);\n\n good:=pp>=0;\n\n end;\n\n\n\n\n\n\nbegin\n {assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(ss);\n n:=length(ss);\n\n if n<26 then begin writeln(-1); goto 1; end;\nflag:=false;\nfor i:=1 to n-25 do if good(i,i+25) then begin flag:=true; pos:=i; end;\nif not flag then begin writeln(-1); goto 1; end;\n for i:=1 to pos-1 do write(ss[i]);\n for i:=0 to 25 do a[i]:=0;\n pos:=26;\n for i:=ii to ii+25 do inc(a[ord(ss[i])-ord('A')]);\n for i:=ii to ii+25 do if ss[i]<>'?' then write(ss[i]) else\n begin\n repeat dec(pos) until (a[pos]=0) or (pos<0);\n write(chr(pos+ord('A')));\n end;\n\n\n for i:=pos+26 to n do write(ss[i]);\n writeln;\n\n 1: close(output);\n\n\nend.\n"}, {"source_code": "{$H+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);} \nread(s);\nif length(s)<26 then begin writeln('-1'); halt; end;\nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwriteln('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= length(S);\n\tif n>26 then\n\tbegin\n\t\twriteln(fo, -1);\n\t\tclose(fi); close(fo);\n\t\texit;\n\tend\n\telse\n\tbegin\n\t\tfor j:=1 to n do\n\t\t\tif S[j]<>'?' then\n\t\t\tbegin\n\t\t\t\tinc(c[ord(S[j])-64]);\n\t\t\t\tif c[ord(S[j])-64]>1 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, -1);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tend;\n\tend;\n\tfor j:=1 to n do\n\t\tif S[j]<>'?' then write(fo, S[j])\n\t\telse\n\t\t\tfor i:=1 to 26 do\n\t\t\t\tif c[i]=0 then\n\t\t\t\tbegin\n\t\t\t\t\twrite(fo, chr(i+64));\n\t\t\t\t\tc[i]:= 1;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "{$H+}\nvar\n a, b, c, d, i, j, t: int64;\n s: string;\n ar: array [1..1000] of int64;\n\nbegin\n readln(s);\n if length(s) < 26 then begin\n writeln(-1);\n halt();\n end;\n i := 1;\n a := 0;\n b := 0;\n while i <= 26 do \n begin\n if s[i] = '?' then inc(b)\n else if ar[ord(s[i])] = 0 then begin\n ar[ord(s[i])] := 1;\n inc(a);\n end\n else inc(ar[ord(s[i])]);\n inc(i);\n end;\n while i <= length(s) do \n begin\n if a + b = 26 then begin\n j := i - 26;\n while j < i do \n begin\n if s[j] <> '?' then write(s[j])\n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n write(chr(t));\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n halt();\n end;\n if s[i - 26] = '?' then dec(b)\n else begin\n if ar[ord(s[i - 26])] = 1 then dec(a);\n dec(ar[ord(s[i - 26])]);\n end;\n if s[i] = '?' then inc(b)\n else begin\n if ar[ord(s[i])] = 0 then inc(a);\n inc(ar[ord(s[i])]);\n end;\n inc(i);\n end;\n if a + b = 26 then begin\n j := i - 26;\n while j < i do \n begin\n if s[j] <> '?' then write(s[j])\n else begin\n t := ord('A');\n while t <= ord('Z') do \n begin\n if ar[t] = 0 then begin\n ar[t] := 1;\n write(chr(t));\n end;\n inc(t);\n end;\n end;\n inc(j);\n end;\n halt();\n end;\n writeln(-1);\nend."}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:ansistring;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i+1 to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break;\n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(0,26)\nelse\nbegin\nfor i:=2 to length(s)-25 do\nif s[i]<>'?' then\n begin\n if a[s[i]]=2 then dec(top);\n dec(a[s[i]]);\n if s[i+26]<>'?' then\n begin\n if a[s[i+26]]=1 then inc(top);\n inc(a[s[i+26]]);\n end;\n if top=0 then\n begin\n tx(i,i+26);\n break;\n end;\n end;\nend;\nif h=1 then\nwriteln(s)\nelse\nwriteln('-1');\nend;\nend."}, {"source_code": "{$H+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);} \nread(s);\nif length(s)<26 then begin writeln('-1'); halt; end;\nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwriteln('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "var\nn,i,j,j1,p:longint;\nst,st2,st3:ansistring;\na:array[0..100] of int64;\nprocedure prov;\n begin\n for j:=1 to 26 do\n begin\n if a[j]>1 then exit;\n end;\n for j:=1 to 26 do\n begin\n if a[j]=0 then begin\n for j1:=i-25 to i do\n begin\n if st[j1]='?' then begin\n st[j1]:=st3[j];\n break;\n end;\n end;\n end;\n end;\n for j:=i+1 to n do\n if st[i]='?' then st[i]:='A';\n writeln(st);\n halt;\n end;\nbegin\n readln(st);\n n:=length(st);\n st3:='QWERTYUIOPASDFGHJKLZXCVBNM';\n if n<26 then begin\n writeln('-1');\n halt;\n end;\n st2:=copy(st,1,26);\n for i:=1 to 26 do\n begin\n if st2[i]<>'?' then begin\n p:=pos(st2[i],st3);\n a[p]:=a[p]+1;\n end;\n end;\n prov;\n for i:=27 to n do\n begin\n p:=pos(st[i],st3);\n a[p]:=a[p]+1;\n p:=pos(st[i-26],st3);\n a[p]:=a[p]-1;\n if st[i-26]='?' then st[i-26]:='A';\n prov;\n end;\n writeln(-1);\nend."}, {"source_code": " var\n s:ansistring;\n\n b,c:array[1..100000] of longint;\n\n i,j,countz,countt,countv,f,vern:longint;\n begin\n readln(s);\n\n vern:=0;\n\n for i:=1 to length(s)-26+1 do begin\n\n for j:=1 to 26 do begin c[j]:=0; b[j]:=0; end;\n\n for j:=i to i+25 do\n if s[j]<>'?' then inc(b[ord(s[j])-64]);\n\n countz:=0;\n for j:=1 to 26 do if b[j]=0 then begin inc(countz); c[countz]:=j; end;\n\n countv:=0;\n for j:=i to i+25 do if s[j]='?' then inc(countv);\n\n countt:=0;\n\n for j:=1 to 26 do if b[j]>1 then inc(countt);\n\n if (countt=0) and (countz=countv) then begin\n\n inc(vern);\n\n f:=0;\n\n for j:=i to i+25 do begin\n if s[j]='?' then begin inc(f); s[j]:=chr(64+c[f]); end;\n\n end;\n break;\n end;\n end;\n if vern=0 then write(-1) else\n write(s);\n end."}, {"source_code": "var possible:boolean;\n\tst:string;\n\tsum:int64;\n\ti,j,k:int32;\n\tcount:array[1..30] of int64;\nBegin\n\tRead(st);\n\tpossible:=False;\n\tIf (length(st)>=26) then\n\t\tBegin\n\t\t\tFor i:=1 to length(st)-26+1 do \n\t\t\t\tIf not possible then\n\t\t\t\t\tBegin\n\t\t\t\t\t\tFillchar(count,sizeof(count),0);\n\t\t\t\t\t\tWriteln(Ord('?'));\n\t\t\t\t\t\t{For j:=i to i+26 do\n\t\t\t\t\t\t\tInc(count[Ord(st[j])-Ord('?')]);}\n\t\t\t\t\t\t//Writeln(Chr(65));\n\t\t\t\t\t\t{For j:=1 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\t\tIf (count[j]>0) then inc(sum);\n\t\t\t\t\t\tIf (count[0]<26-sum) or (count[0]>26-sum) then possible:=False\n\t\t\t\t\t\tElse \n\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\tFor j:=i to i+26 do\n\t\t\t\t\t\t\t\t\tFor k:=2 to Ord('Z')-Ord('?') do \n\t\t\t\t\t\t\t\t\t\tIf (st[j]='?') and (count[k]=0) then \n\t\t\t\t\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\t\t\t\t\tinc(count[k]);\n\t\t\t\t\t\t\t\t\t\t\t\tst[j]:=Chr(k+Ord('?'));\n\t\t\t\t\t\t\t\t\t\t\tEnd;\n\t\t\t\t\t\t\t\tpossible:=True;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tEnd;}\n\t\t\t\t\tEnd;\n\t\tEnd;\n\tIf possible then Writeln(st)\n\tElse Writeln('-1');\nEnd."}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= length(S);\n\tif n>26 then\n\tbegin\n\t\twriteln(fo, -1);\n\t\tclose(fi); close(fo);\n\t\texit;\n\tend\n\telse\n\tbegin\n\t\tfor j:=1 to n do\n\t\t\tif S[j]<>'?' then\n\t\t\tbegin\n\t\t\t\tinc(c[ord(S[j])-64]);\n\t\t\t\tif c[ord(S[j])-64]>1 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, -1);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tend;\n\tend;\n\tfor j:=1 to n do\n\t\tif S[j]<>'?' then write(fo, S[j])\n\t\telse\n\t\t\tfor i:=1 to 26 do\n\t\t\t\tif c[i]=0 then\n\t\t\t\tbegin\n\t\t\t\t\twrite(fo, chr(i+64));\n\t\t\t\t\tc[i]:= 1;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=1 to t-1 do write(s[i]);\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n for i:=t+26 to n do write(s[i]);\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "var\n i,j,k,n,t,l,l1,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,s1,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \nfunction proverka(s:ansistring):boolean;\nvar alp,s1:ansistring;\ni,j,l,k1:longint;\nx:array[1..260000]of integer;\nflag,flag1:integer;\n begin\n l:=length(s);\n flag1:=0;\n for k1:=1 to l-25 do begin \n s1:=copy(s,k1,26);\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n //s1:=copy(s,i,26);\n flag:=1;\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for j:=1 to 26 do\n if x[j]=0 then flag:=0;\n if flag=1 then begin\n writeln(s1);\n flag1:=1;\n end;\n end; \n proverka:=(flag1=1);\n end;\nbegin\n readln(s);\n/// writeln(s);\nl:=length(s);\nif l<26 then writeln(-1)\n else begin\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n// while ((i<=l)and(flag1=0)) do begin\n // s1:=copy(s,i,26);\n// flag:=1;\n// for j:=1 to 26 do\n // x[j]:=0;\n // for j:=1 to 26 do begin\n // if (s1[j]=alp[j])then x[j]:=1;\n// end;\n // for j:=1 to 26 do\n // if x[j]=0 then flag:=0;\n// if flag=1 then flag1:=1\n// else i:=i+1; \n// end;\n// if flag1=1 then begin\n // while (pos('?',s)<>0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for k1:=1 to l-25 do begin\n s1:=copy(s,k1,26);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for i:=1 to 26 do begin\n if (s1[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s1[i]:=alp[j];\n x[j]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n if proverka(s1) then begin \n while (pos('?',s1)<>0) do begin\n i:=pos('?',s1);\n delete(s1,i,1);\n insert('A',s1,i);\n end;\n delete(s,k1,26);\n insert(s1,s,k1);\n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n end;\n // writeln(s1);\n end;\n//writeln(s);\n if (proverka(s)) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": "var i,j,m,n,len,k:longint;\n pfx:array[0..50005,0..25]of longint;\n s:ansistring;\n used:array[0..25]of boolean;\n flag:boolean;\nbegin\n readln(s);\n len:=length(s);\n for i:=1 to len do begin\n if s[i]='?' then begin\n for j:=0 to 25 do pfx[i,j]:=pfx[i-1,j];\n end else begin\n for j:=0 to 25 do if ord('A')+j<>ord(s[i]) then pfx[i,j]:=pfx[i-1,j] else pfx[i,j]:=pfx[i-1,j]+1;\n end;\n end;\n if len<26 then writeln(-1) else begin\n for i:=1 to len-25 do begin\n flag:=true;\n for j:=0 to 25 do begin\n if pfx[i+25,j]-pfx[i-1,j]>1 then flag:=false;\n end;\n if flag then begin\n fillchar(used,sizeof(used),false);\n for j:=i to i+25 do if s[j]<>'?' then used[ord(s[i])-ord('A')]:=true;\n for j:=i to i+25 do begin\n if s[j]<>'?' then write(s[j]) else begin\n for k:=0 to 25 do if used[k]=false then begin\n write(chr(k+ord('A')));\n used[k]:=true;\n end;\n end;\n end;\n writeln;\n //close input output\n halt;\n end;\n end;\n end;\n writeln(-1);\nend.\n"}, {"source_code": "var\nn,i,j,j1,p:longint;\nst,st2,st3:ansistring;\na:array[0..100] of int64;\nprocedure prov;\n begin\n for j:=1 to 26 do\n begin\n if a[j]>1 then exit;\n end;\n for j:=1 to 26 do\n begin\n if a[j]=0 then begin\n for j1:=i-25 to i do\n begin\n if st[j1]='?' then begin\n st[j1]:=st3[j];\n break;\n end;\n end;\n end;\n end;\n for j:=i+1 to n do\n if st[i]='?' then st[i]:='A';\n writeln(st);\n halt;\n end;\nbegin\n readln(st);\n n:=length(st);\n st3:='QWERTYUIOPASDFGHJKLZXCVBNM';\n if n<26 then begin\n writeln('-1');\n halt;\n end;\n st2:=copy(st,1,26);\n for i:=1 to 26 do\n begin\n if st2[i]<>'?' then begin\n p:=pos(st2[i],st3);\n a[p]:=a[p]+1;\n end;\n end;\n prov;\n for i:=27 to n do\n begin\n p:=pos(st[i],st3);\n a[p]:=a[p]+1;\n p:=pos(st[i-26],st3);\n a[p]:=a[p]-1;\n if st[i-26]='?' then st[i-26]:='A';\n prov;\n end;\n writeln(-1);\nend."}, {"source_code": "var alf,st:ansistring;\nl,i,j,kol,p:longint;\na:array[0..100] of longint;\nbegin\n alf:='QWERTYUIOPASDFGHJKLZXCVBNM';\n readln(st);\n l:=length(st);\n for i:=1 to l do\n if st[i]<>'?' then begin\n p:=0;\n p:=pos(st[i],alf);\n if a[p]=1 then begin\n writeln(-1);\n halt;\n end\n else if a[p]=0 then a[p]:=1;\n end\n else kol:=kol+1;\n if l=26 then begin\n if kol=0 then writeln(st)\n else begin\n for i:=1 to l do\n if st[i]='?' then begin\n for j:=1 to 26 do\n if a[j]=0 then begin\n a[j]:=1;\n break;\n end;\n st[i]:=alf[j];\n end;\n writeln(st);\n end;\n end\nelse begin\n writeln(-1);\n end;\nend."}, {"source_code": "{$h+}\nvar a:array['A'..'Z'] of longint;\n s,ss:string;\n ii:char;\n i,j,h,kol,p:longint; \nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); } \nreadln(s);\nss:='';\nfor ii:='A' to 'Z' do\n ss:=ss+ii; \nfor i:=1 to length(s)-25 do\n begin\n for ii:='A' to 'Z' do\n a[ii]:=0;\n kol:=0;\n p:=0;\n for j:=1 to 26 do\n if s[i+j-1]='?' then inc(kol)\n else \n if a[s[i+j-1]]=0 then a[s[i+j-1]]:=1\n else begin p:=1; break; end; \n if p=0 then begin\n for j:=1 to 26 do\n if s[i+j-1]='?' then begin\n for ii:='A' to 'Z' do\n if a[ii]=0 then begin\n a[ii]:=1;\n write(ii);\n break;\n end;\n end\n else write(s[i+j-1]);\n halt;\n end;\n end;\nwrite('-1');\n{close(input);\nclose(output); }\nend.\n "}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:ansistring;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break;\n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(1,26)\nelse\nbegin\nfor i:=2 to length(s)-25 do\nif s[i]<>'?' then\n begin\n if a[s[i]]=2 then dec(top);\n dec(a[s[i]]);\n if s[i+25]<>'?' then\n begin\n if a[s[i+25]]=1 then inc(top);\n inc(a[s[i+25]]);\n end;\n if top=0 then\n begin\n tx(i,i+25);\n break;\n end;\n end\nelse\n begin\n if s[i+25]<>'?' then\n begin\n if a[s[i+25]]=1 then inc(top);\n inc(a[s[i+25]]);\n end;\n if top=0 then\n begin\n tx(i,i+25);\n break;\n end;\n end;\nend;\nif h=1 then\n writeln(s)\nelse\n writeln('-1');\nend;\nend."}, {"source_code": "var n,m,i,j,k,ned:longint;\n f:array['A'..'Z']of longint;\n s:ansistring;\n c:char; \nbegin\nreadln(s);\nif length(s)<26 then begin writeln(-1);halt;end;\nfor j:=1 to 26 do begin\n if s[j]<>'?' then inc(f[s[j]]) else inc(k);\nend;\nfor i:=1 to length(s)-25 do begin\n if i>1 then begin\n if s[i-1]='?' then dec(k) else dec(f[s[i-1]]);\n if s[i+25]='?' then inc(k) else inc(f[s[i+25]]);\n end; \n ned:=0;\n for c:='A' to 'Z' do if f[c]=0 then inc(ned);\n if ned<=k then begin\n for j:=1 to 26 do begin\n if s[i+j-1]<>'?' then write(s[i+j-1]) else begin\n for c:='A' to 'Z' do if f[c]=0 then begin inc(f[c]);write(c);break;end;\n end;\n end;\n halt;\n end;\nend;\nwriteln(-1);\nend.\n \n"}, {"source_code": " var\n s:ansistring;\n\n b,c:array[1..100000] of longint;\n\n i,j,countz,countt,countv,f,vern:longint;\n begin\n readln(s);\n\n vern:=0;\n\n for i:=1 to length(s)-26+1 do begin\n\n for j:=1 to 26 do begin c[j]:=0; b[j]:=0; end;\n\n for j:=i to i+25 do\n if s[j]<>'?' then inc(b[ord(s[j])-64]);\n\n countz:=0;\n for j:=1 to 26 do if b[j]=0 then begin inc(countz); c[countz]:=j; end;\n\n countv:=0;\n for j:=i to i+25 do if s[j]='?' then inc(countv);\n\n countt:=0;\n\n for j:=1 to 26 do if b[j]>1 then inc(countt);\n\n if (countt=0) and (countz=countv) then begin\n\n inc(vern);\n\n f:=0;\n\n for j:=i to i+25 do begin\n if s[j]='?' then begin inc(f); s[j]:=chr(64+c[f]); end;\n\n end;\n break;\n end;\n end;\n if vern=0 then write(-1) else\n write(s);\n end."}, {"source_code": "var\n s : ansistring;\n n, i, j : longint;\n has : array['A'..'Z'] of boolean;\n ok, flg : boolean;\n c : char;\n\nbegin\n readln(s);\n n := length(s);\n if (n < 26) then\n begin\n writeln(-1);\n exit;\n end;\n for i := 1 to n - 26 + 1 do\n begin\n fillchar(has, sizeof(has), false);\n ok := true; flg := false;\n for j := i to i + 25 do\n if (s[j] <> '?') then\n begin\n if (has[s[j]]) then\n begin\n ok := false;\n break;\n end\n else has[s[j]] := true;\n end\n else flg := true;\n if (ok) then\n begin\n if (flg) then\n begin\n for j := i to i + 25 do\n begin\n if (s[j] = '?') then\n begin\n for c := 'A' to 'Z' do\n begin\n if not (has[c]) then\n begin\n has[c] := true;\n s := copy(s, 1, j - 1) + c + copy(s, j + 1, n - j);\n break;\n end;\n end;\n end;\n end;\n for j := 1 to n do \n if (s[j] = '?') then s := copy(s, 1, j - 1) + 'A' + copy(s, j + 1, n - j);\n end;\n writeln(s);\n exit;\n end;\n end;\n writeln(-1);\nend."}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f,sc:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n sc:=0;\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; \n End."}, {"source_code": "label 1;\nvar s,s2:string;\n i,j,k,no,ko:longint;\nbegin\nread(s);\nif length(s)<26 then\nbegin\nwrite(-1);\nhalt;\nend;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ni:=1;\n1: while i<=length(s)-25 do\nbegin\nfor j:=i to 25+i do\nbegin\nif s[j]<>'?' then\nbegin\nif pos(s[j],s2)=0 then\nbegin\ni:=j+1;\ns2:='ZXCVBNMASDFGHJKLQWERTYUIOP';\ngoto 1;\nend;\ndelete(s2,pos(s[j],s2),1);\nend;\nend;\nno:=i;\nko:=25+i;\nbreak;\nend;\nif i>length(s)-25 then\nbegin\nwrite(-1);\nhalt;\nend;\n{if s2='' then\nbegin\nwrite(-1);\nhalt;\nend;}\nk:=1;\nfor i:=no to ko do\nif s[i]='?' then\nbegin\nwrite(s2[k]);\ninc(k);\nend\nelse write(s[i]);\nend."}, {"source_code": "var \n s:ansistring;\n len,i:longint;\n flag:boolean;\n \nprocedure comp(x:longint);\nconst\n ch:array[1..26] of char=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');\nvar \n num:array[1..26] of longint;\n numq,i,j:longint;\nbegin \n fillchar(num,sizeof(num),0);\n numq:=0;\n for i:=x to x+25 do \n if (s[i]>='A')and(s[i]<='Z') then inc(num[ord(s[i])-64]) else inc(numq);\n for i:=x to x+25 do \n if s[i]='?' then begin \n j:=1;\n while num[j]<>0 do inc(j);\n num[j]:=1;\n s[i]:=ch[j];\n end;\nend;\n\nprocedure check(x:longint);\nvar\n num:array[1..26] of longint;\n i:longint;\nbegin \n fillchar(num,sizeof(num),0);\n for i:=x to x+26 do\n if (s[i]>='A')and(s[i]<='Z') then begin \n inc(num[ord(s[i])-64]);\n if num[ord(s[i])-64]>1 then begin flag:=false;exit;end;\n end;\n flag:=true;\nend;\n\nbegin \n readln(s);\n len:=length(s);\n if len<26 then begin writeln('-1');exit;end;\n for i:=1 to len-25 do begin \n check(i);\n\tif flag then begin comp(i);break;end;\n end;\n //writeln(s);\n// writeln(len);\n if flag then begin \n for i:=1 to len do \n if s[i]='?' then s[i]:='A';\n writeln(s);\n end else writeln('-1');\nend."}, {"source_code": "var\ns,s1:ansistring;\na:array[1..26] of longint;\ni,j,q:longint;\nbegin\nreadln(S);\n//s:='ABC??FGHIJK???OPQR?TUVWXY?';\n\nfor i:=1 to length(S)-25 do begin\ns1:=copy(s,i,26);\nq:=0;\nfor j:=1 to 26 do\na[j]:=0;\nfor j:=1 to 26 do\nif s1[j]<>'?'\nthen\ninc(a[ord(s1[j])-64]);\nfor j:=1 to 26 do\nif a[j]>1\nthen q:=1;\nif q=0\nthen begin\nfor j:=i to i+25 do\nif s[j]='?'\nthen for q:=1 to 26 do\nif a[q]=0\nthen begin\ns[j]:=chr(q+64);\ninc(a[q]);\nbreak;\nend;\nbreak;\nend;\nif i=length(s)-25\nthen begin writeln(-1); halt;end;\nend;\nfor i:=1 to length(S) do\nif s[i]='?'\nthen s[i]:='A';\nwriteln(S);\nend.\n\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j, k: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\ti:= 1; j:= 2;\n\tif S[i]<>'?' then c[ord(S[i])-64]:= 1;\n\twhile (i<=n) and (j<=n) do\n\tbegin\n\t\tif S[j]<>'?' then\n\t\tbegin\n\t\t\tif c[ord(S[j])-64]=1 then\n\t\t\tbegin\n\t\t\t\tc[ord(S[i])-64]:= 0;\n\t\t\t\tinc(i);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tc[ord(S[j])-64]:= 1;\n\t\t\t\tif j-i+1=26 then break;\n\t\t\t\tinc(j);\n\t\t\tend;\n\t\tend\n\t\telse inc(j);\n\t\tif j-i+1>26 then inc(i);\n\tend;\n\tif j>n then \n\tbegin\n\t\tdec(j); \n\t\tdec(i);\n\tend;\n\trandomize;\n\tif j-i+1=26 then\n\tbegin\n\t\tfor k:=1 to n do\n\t\t\tif S[k]='?' then\n\t\t\tbegin\n\t\t\t\tif (kj) then write(fo, chr(1+random(26)))\n\t\t\t\telse\n\t\t\t\t\tfor t:=1 to 26 do\n\t\t\t\t\t\tif c[t]=0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(fo, chr(t+64));\n\t\t\t\t\t\t\tc[t]:= 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\tend\n\t\t\telse write(fo, S[k]);\n\tend\n\telse write(fo, -1);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "Program B;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\ns: ansistring;\nn: longint;\nd: array[0..60000, '?'..'Z'] of longint;\n\nFunction f(l, r: longint; c:char):longint;\nBEGIN\nexit(d[r][c] - d[l-1][c]);\nEND;\n\nFunction check(i: longint): boolean;\nVar cnt, tmp: longint;\nc: char;\nBEGIN\ncnt := 0;\nfor c := 'A' to 'Z' do\n\tbegin\n\ttmp := f(i, i+25, c);\n\tif tmp > 1 then exit(false);\n\tcnt := cnt + tmp;\n\tend;\nif 26-cnt = f(i, i+25, '?') then exit(true);\nexit(false);\nEND;\n\nProcedure g(i: longint);\nVar j, j1: longint;\nt: ansistring;\nc: char;\nBEGIN\nj1 := 1;\nt := '';\nfor c := 'A' to 'Z' do if f(i, i+25, c) = 0 then t := t + c;\nfor j := i to i+25 do if s[j] = '?' then\n\tbegin\n\ts[j] := t[j1];\n\tinc(j1);\n\tend;\nwriteln(fo, copy(s, i, 26));\nEND;\n\nProcedure Process;\nVar i: longint;\nc: char;\nBEGIN\nreadln(fi, s);\nn := length(s);\nif (n < 26) then\n\tbegin\n\twriteln(fo, -1);\n\texit;\n\tend;\nfor i:=1 to n do\n\tfor c := '?' to 'Z' do\n\t\tif s[i] = c then d[i][c] := d[i-1][c] + 1\n\t\t\telse d[i][c] := d[i-1][c];\nfor i:=1 to n-25 do if check(i) then\n\tbegin\n\tg(i);\n\texit;\n\tend;\nwriteln(fo, -1);\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND. "}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=1 to t-1 do write(s[i]);\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n for i:=t+26 to n do write(s[i]);\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "var\n s : ansistring;\n n, i, j : longint;\n has : array['A'..'Z'] of boolean;\n ok, flg : boolean;\n c : char;\n\nbegin\n readln(s);\n n := length(s);\n if (n < 26) then\n begin\n writeln(-1);\n exit;\n end;\n for i := 1 to n - 26 + 1 do\n begin\n fillchar(has, sizeof(has), false);\n ok := true; flg := false;\n for j := i to i + 25 do\n if (s[j] <> '?') then\n begin\n if (has[s[j]]) then\n begin\n ok := false;\n break;\n end\n else has[s[j]] := true;\n end\n else flg := true;\n if (ok) then\n begin\n if (flg) then\n begin\n for j := i to i + 25 do\n begin\n if (s[j] = '?') then\n begin\n for c := 'A' to 'Z' do\n begin\n if not (has[c]) then\n begin\n has[c] := true;\n s := copy(s, 1, j - 1) + c + copy(s, j + 1, n - j);\n break;\n end;\n end;\n end;\n end;\n for j := 1 to n do \n if (s[j] = '?') then s := copy(s, 1, j - 1) + 'A' + copy(s, j + 1, n - j);\n writeln(s);\n exit;\n end;\n end;\n end;\n writeln(-1);\n exit;\nend."}, {"source_code": "const fi='b.inp';\n fo='b.out';\nvar s:ansistring;\n i,j:longint;\n d:array['A'..'Z']of longint;\n jj:char;\n ktt:boolean;\nfunction kt:boolean;\nvar j:char;\n begin\n for j:='A' to 'Z' do\n if d[j]>1 then exit(false);\n exit(true);\n end;\nbegin\n //assign(input,fi);reset(input);\n //assign(output,fo);rewrite(output);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]<>'?' then inc(d[s[i]]);\n if i>=26 then\n begin\n if kt=true then\n begin\n ktt:=true;\n for j:=i-25 to i do\n if s[j]='?' then\n for jj:='A' to 'Z' do\n if d[jj]=0 then\n begin\n inc(d[jj]);\n s[j]:=jj;\n break;\n end;\n break;\n end;\n end;\n if (i>26)and (s[i-26]<>'?') then dec(d[s[i-26]]);\n end;\n for i:=1 to length(s) do\n if s[i]='?' then s[i]:='A';\n if ktt=false then writeln(-1) else writeln(s);\nend.\n"}, {"source_code": "var\nn,i,j,j1,p:longint;\nst,st2,st3:ansistring;\na:array[0..100] of int64;\nprocedure prov;\n begin\n for j:=1 to 26 do\n begin\n if a[j]>1 then exit;\n end;\n for j:=1 to 26 do\n begin\n if a[j]=0 then begin\n for j1:=i-25 to i do\n begin\n if st[j1]='?' then begin\n st[j1]:=st3[j];\n break;\n end;\n end;\n end;\n end;\n for j:=i+1 to n do\n if st[i]='?' then st[i]:='A';\n writeln(st);\n halt;\n end;\nbegin\n readln(st);\n n:=length(st);\n st3:='QWERTYUIOPASDFGHJKLZXCVBNM';\n if n<26 then begin\n writeln('-1');\n halt;\n end;\n st2:=copy(st,1,26);\n for i:=1 to 26 do\n begin\n if st2[i]<>'?' then begin\n p:=pos(st2[i],st3);\n a[p]:=a[p]+1;\n end;\n end;\n prov;\n for i:=27 to n do\n begin\n p:=pos(st[i],st3);\n a[p]:=a[p]+1;\n p:=pos(st[i-26],st3);\n a[p]:=a[p]-1;\n if st[i-26]='?' then st[i-26]:='A';\n prov;\n end;\n writeln(-1);\nend."}, {"source_code": "Program B;\nCONST FINP = '1.INP';\tFOUT = '1.OUT';\nVAR fi, fo: text;\ns: ansistring;\nn: longint;\nd: array[0..60000, '?'..'Z'] of longint;\n\nFunction f(l, r: longint; c:char):longint;\nBEGIN\nexit(d[r][c] - d[l-1][c]);\nEND;\n\nFunction check(i: longint): boolean;\nVar cnt, tmp: longint;\nc: char;\nBEGIN\ncnt := 0;\nfor c := 'A' to 'Z' do\n\tbegin\n\ttmp := f(i, i+25, c);\n\tif tmp > 1 then exit(false);\n\tcnt := cnt + tmp;\n\tend;\nif 26-cnt = f(i, i+25, '?') then exit(true);\nexit(false);\nEND;\n\nProcedure g(i: longint);\nVar j, j1: longint;\nt: ansistring;\nc: char;\nBEGIN\nj1 := 1;\nt := '';\nfor c := 'A' to 'Z' do if f(i, i+25, c) = 0 then t := t + c;\nfor j := i to i+25 do if s[j] = '?' then\n\tbegin\n\ts[j] := t[j1];\n\tinc(j1);\n\tend;\nwriteln(fo, copy(s, i, 26));\nEND;\n\nProcedure Process;\nVar i: longint;\nc: char;\nBEGIN\nreadln(fi, s);\nn := length(s);\nif (n < 26) then\n\tbegin\n\twriteln(fo, -1);\n\texit;\n\tend;\nfor i:=1 to n do\n\tfor c := '?' to 'Z' do\n\t\tif s[i] = c then d[i][c] := d[i-1][c] + 1\n\t\t\telse d[i][c] := d[i-1][c];\nfor i:=1 to n-25 do if check(i) then\n\tbegin\n\tg(i);\n\texit;\n\tend;\nwriteln(fo, -1);\nEND;\n\nBEGIN\n{$IFDEF ONLINE_JUDGE}\nassign(fi, '');\t\tassign(fo, '');\n{$ELSE}\nassign(fi, FINP);\tassign(fo, FOUT);\n{$ENDIF} \nreset(fi);\t\t\trewrite(fo);\nProcess;\nclose(fi);\nclose(fo);\nEND. "}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:ansistring;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i+1 to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break;\n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(0,26)\nelse\nbegin\nfor i:=2 to length(s)-25 do\nif s[i]<>'?' then\n begin\n if a[s[i]]=2 then dec(top);\n dec(a[s[i]]);\n if s[i+26]<>'?' then\n begin\n if a[s[i+26]]=1 then inc(top);\n inc(a[s[i+26]]);\n end;\n if top=0 then\n begin\n tx(i,i+26);\n break;\n end;\n end;\nend;\nif h=1 then\nwriteln(s)\nelse\nwriteln('-1');\nend;\nend."}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=1 to length(s) do\n if (i>=l) and (i<=r) then begin\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else if not(s[i]='?') then write(s[i]) else write('A');\n End."}, {"source_code": "var a:array['A'..'Z']of longint;\nn,i,l,r:longint;\ns,ans:ansistring;\nc:char;\nb:boolean;\n\nprocedure finish;\nbegin\nfor i:=l to r do\nif s[i]='?'then\nfor c:='A' to 'Z' do\nif a[c]=0 then begin a[c]:=1; s[i]:=c; break; end;\nwriteln(s);\nhalt;\nend;\n\nbegin\nans:='';\nreadln(s);\nn:=length(s);\nfor c:='A' to 'Z' do a[c]:=0;\nif n<26 then\nbegin\nwrite(-1);\nhalt;\nend;\nl:=1;\nr:=26;\nwhile r<=n do\nbegin\nfor c:='A' to 'Z' do a[c]:=0;\nb:=true;\nfor i:=l to r do\nif s[i]<>'?' then\nbegin\ninc(a[s[i]]);\nif a[s[i]]=2 then begin l:=l+1; r:=l+25; b:=false; break; end;\nend;\nif b then finish;\nend;\nwrite(-1);\nend.\n"}, {"source_code": "var\n a:array ['A'..'Z'] of longint;\n s:string;\n top,i,n,h:longint;\nprocedure tx(i,j:longint);\n var\n f:longint;\n c:char;\n begin\n for f:=i+1 to j do\n if s[f]='?' then\n begin\n for c:='A' to 'Z' do\n if a[c]=0 then\n begin\n delete(s,f,1);\n insert(c,s,f);\n inc(a[c]);\n break; \n end;\n end;\n for f:=1 to n do\n if s[f]='?' then\n begin\n delete(s,f,1);\n insert('A',s,f);\n end;\n h:=1;\n end;\nbegin\nreadln(s);\nif length(s)<26 then writeln('-1')\nelse\nbegin\nn:=length(s);\nfor i:=1 to 26 do\n if s[i]<>'?' then\n begin\n if a[s[i]]=1 then inc(top);\n inc(a[s[i]]);\n end;\nif top=0 then tx(0,26)\nelse\nbegin\nfor i:=2 to length(s)-26 do\nif s[i]<>'?' then\n begin\n if a[s[i]]=2 then dec(top);\n dec(a[s[i]]);\n if s[i+26]<>'?' then\n begin\n if a[s[i+26]]=1 then inc(top);\n inc(a[s[i+26]]);\n end;\n if top=0 then\n begin\n tx(i,i+26);\n break;\n end;\n end;\nend;\nif h=1 then\nwriteln(s)\nelse\nwriteln('-1');\nend;\nend.\n"}, {"source_code": "var x:char;\n flag:array[1..26] of boolean;\n\tch:array[1..60000] of char;\n\ti,j,ans,now,n:longint;\nbegin\n fillchar(flag,sizeof(flag),false);\n now:=0;\n n:=0;\n while not(eoln) do\n begin\n read(x);\n inc(n);\n ch[n]:=x;\n if (x='?') then inc(now) else flag[ord(x)-64]:=true;\n end;\n readln;\n ans:=0;\n for i:=1 to 26 do\n\tif not(flag[i]) then inc(ans);\n if (ans'?') then write(ch[i]) else\n\t\tbegin\n\t\t while (now<=25) and flag[now] do inc(now);\n\t\t flag[now]:=true;\n\t\t write(chr(now+64));\n\t\tend;\n\twriteln;\n end;\nend.\n\t\t "}, {"source_code": "var possible:boolean;\n\tst:string;\n\tsum:int64;\n\ti,j,k:int32;\n\tcount:array[0..30] of int64;\nBegin\n\tRead(st);\n\tpossible:=False;\n\tIf (length(st)>=26) then\n\t\tBegin\n\t\t\tFor i:=1 to length(st)-26+1 do\n\t\t\t\tBegin\n\t\t\t\t\tsum:=0;\n\t\t\t\t\tFillchar(count,sizeof(count),0);\n\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\tInc(count[Ord(st[j])-Ord('?')]);\n\t\t\t\t\tFor j:=1 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\tIf (count[j]>0) then inc(sum);\n\t\t\t\t\tIf (count[0]>=26-sum) then\n\t\t\t\t\t\tpossible:=True;\n\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\tFor k:=2 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\t\tIf (st[j]='?') and (count[k]=0) then\n\t\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\t\tinc(count[k]);\n\t\t\t\t\t\t\t\t\tst[j]:=Chr(k+Ord('?'));\n\t\t\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\tEnd;\n\tIf possible then Writeln(st)\n\tElse Writeln('-1');\nEnd.\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, t, i, j, k: Longint;\n S: AnsiString;\n c: array[1..26] of Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, S);\n\tn:= Length(S);\n\ti:= 1; j:= 2;\n\tif S[i]<>'?' then c[ord(S[i])-64]:= 1;\n\twhile (i<=n) and (j<=n) do\n\tbegin\n\t\tif S[j]<>'?' then\n\t\tbegin\n\t\t\tif c[ord(S[j])-64]=1 then\n\t\t\tbegin\n\t\t\t\tc[ord(S[i])-64]:= 0;\n\t\t\t\tinc(i);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tc[ord(S[j])-64]:= 1;\n\t\t\t\tif j-i+1=26 then break;\n\t\t\t\tinc(j);\n\t\t\tend;\n\t\tend\n\t\telse inc(j);\n\t\tif j-i+1>26 then inc(i);\n\tend;\n\tif j>n then \n\tbegin\n\t\tdec(j); \n\t\tdec(i);\n\tend;\n\trandomize;\n\tif j-i+1=26 then\n\tbegin\n\t\tfor k:=1 to n do\n\t\t\tif S[k]='?' then\n\t\t\tbegin\n\t\t\t\tif (kj) then write(fo, chr(1+random(26)))\n\t\t\t\telse\n\t\t\t\t\tfor t:=1 to 26 do\n\t\t\t\t\t\tif c[t]=0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(fo, chr(t+64));\n\t\t\t\t\t\t\tc[t]:= 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tend;\n\t\t\tend\n\t\t\telse write(fo, S[k]);\n\tend\n\telse write(fo, -1);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "var i,j,n,count,cc,h,wt:longint;s:ansistring;\n used:array['A'..'Z']of longint;\nprocedure print(t:longint);\nvar i:longint;j:char;\nbegin\n for i:=1 to t-1 do write(s[i]);\n for i:=t to t+26-1 do\n begin\n if s[i]<>'?' then write(s[i])\n else\n for j:='A' to 'Z' do\n if used[j]<>count then begin used[j]:=count;write(j);break;end;\n end;\n for i:=t+26 to n do write(s[i]);\n wt:=1;\nend;\nbegin\n //assign(input,'716B.inp');reset(input);\n //assign(output,'716B.out');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n-26+1 do\n begin\n inc(count);h:=0;cc:=0;\n for j:=i to i+26-1 do\n if(s[j]='?')then inc(h)\n else if used[s[j]]<>count then\n begin\n used[s[j]]:=count;\n inc(cc);\n end;\n if cc+h=26 then begin print(i);break;end;\n end;\n if wt=0 then writeln(-1);\n close(input);close(output);\nend."}, {"source_code": "var\n i,j,k,n,t,l,l1,k1:longint;\nc,i1,m: qword;\n flag,flag1:integer;\ns,s1,alp:ansistring;\n\n x:array[1..2600000] of qword;\n \nfunction proverka:boolean;\nvar alp,s1:ansistring;\ni,j,l,k1:longint;\nx:array[1..260000]of integer;\nflag,flag1:integer;\n begin\n l:=length(s);\n flag1:=0;\n for k1:=1 to l-26 do begin \n s1:=copy(s,k1,26);\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n \n \n //s1:=copy(s,i,26);\n flag:=1;\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to 26 do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for j:=1 to 26 do\n if x[j]=0 then flag:=0;\n if flag=1 then flag1:=1;\n end; \n proverka:=(flag1=1);\n end;\nbegin\n readln(s);\n/// writeln(s);\nl:=length(s);\nif l<26 then writeln(-1)\n else begin\n alp:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n i:=1;\n flag1:=0;\n// while ((i<=l)and(flag1=0)) do begin\n // s1:=copy(s,i,26);\n// flag:=1;\n// for j:=1 to 26 do\n // x[j]:=0;\n // for j:=1 to 26 do begin\n // if (s1[j]=alp[j])then x[j]:=1;\n// end;\n // for j:=1 to 26 do\n // if x[j]=0 then flag:=0;\n// if flag=1 then flag1:=1\n// else i:=i+1; \n// end;\n// if flag1=1 then begin\n // while (pos('?',s)<>0) do begin\n// i:=pos('?',s);\n// delete(s,i,1);\n// insert('A',s,i);\n// end;\n// end\n // else begin //надо вставлять\n // writeln(s);\n for k1:=1 to l-26 do begin\n s1:=copy(s,k1,26);\n for j:=1 to 26 do\n x[j]:=0;\n for i:=1 to l do begin\n for j:=1 to 26 do begin\n if (s1[i]=alp[j]) then x[j]:=1;\n end;\n end;\n for i:=1 to l do begin\n if (s1[i]='?') then begin\n flag1:=0;\n j:=1;\n while ((j<=26)and(flag1=0)) do begin\n if x[j]=0 then begin\n s1[i]:=alp[j];\n x[j]:=1;\n flag1:=1;\n end\n else j:=j+1;\n end;\n end;\n end;\n \n while (pos('?',s)<>0) do begin\n i:=pos('?',s1);\n delete(s1,i,1);\n insert('A',s1,i);\n end;\n delete(s,k1,26);\n insert(s1,s,k1);\n while (pos('?',s)<>0) do begin\n i:=pos('?',s);\n delete(s,i,1);\n insert('A',s,i);\n end;\n end;\n//writeln(s);\n if (proverka) then \n writeln(s)\n else writeln(-1);\nend;\n\nend."}, {"source_code": "Var s:ansistring;\n sc,l,r,i,j,f:longint;\n a:array[65..90] of longint;\n Begin\n readln(s);\n sc:=0;\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]='?' then sc:=sc+1\n else a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then begin\n \n while (r+1<=length(s)) do\n begin\n \n f:=1;\n r:=r+1;\n l:=l+1;\n if s[l]='?' then sc:=sc-1 \n else a[ord(s[l])]:=a[ord(s[l])]-1;\n if s[r]='?' then sc:=sc+1\n else a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if s[i]='?' then\n begin\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else write(s[i]);\n End.\n \n // ABCDEFGHIJKLMNOPQRSTUVWXYZ\n // AA?????????????????????????A\n //ABCDEFGHIJKLMNOPQRSTUVWXYZA"}, {"source_code": "var possible:boolean;\n\tst:string;\n\tsum:int64;\n\ti,j,k:int32;\n\tcount:array[0..30] of int64;\nBegin\n\tRead(st);\n\tpossible:=False;\n\tIf (length(st)>=26) then\n\t\tBegin\n\t\t\tFor i:=1 to length(st)-26+1 do\n\t\t\t\tBegin\n\t\t\t\t\tsum:=0;\n\t\t\t\t\tFillchar(count,sizeof(count),0);\n\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\tInc(count[Ord(st[j])-Ord('?')]);\n\t\t\t\t\tFor j:=1 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\tIf (count[j]>0) then inc(sum);\n\t\t\t\t\tIf (count[0]>=26-sum) then\n\t\t\t\t\t\tpossible:=True;\n\t\t\t\t\tFor j:=i to i+25 do\n\t\t\t\t\t\tFor k:=2 to Ord('Z')-Ord('?') do\n\t\t\t\t\t\t\tIf (st[j]='?') and (count[k]=0) then\n\t\t\t\t\t\t\t\tBegin\n\t\t\t\t\t\t\t\t\tinc(count[k]);\n\t\t\t\t\t\t\t\t\tst[j]:=Chr(k+Ord('?'));\n\t\t\t\t\t\t\t\tEnd;\n\t\t\t\tEnd;\n\t\tEnd;\n\tIf possible then Writeln(st)\n\tElse Writeln('-1');\nEnd.\n"}, {"source_code": "Var s:ansistring;\n sc,l,r,i,j,f:longint;\n a:array[65..90] of longint;\n Begin\n readln(s);\n sc:=0;\n l:=1;\n r:=26;\n f:=1;\n if length(s)<26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]='?' then sc:=sc+1\n else a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then begin\n \n while (r+1<=length(s)) do\n begin\n \n f:=1;\n r:=r+1;\n l:=l+1;\n if s[l]='?' then sc:=sc-1 \n else a[ord(s[l])]:=a[ord(s[l])]-1;\n if s[r]='?' then sc:=sc+1\n else a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if s[i]='?' then\n begin\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; end\n else write(s[i]);\n End.\n \n // ABCDEFGHIJKLMNOPQRSTUVWXYZ\n // AA?????????????????????????A\n //ABCDEFGHIJKLMNOPQRSTUVWXYZA"}, {"source_code": "Var s:ansistring;\n i,j:longint; l,r,f:int64;\n a:array[65..90] of int64;\n Begin\n readln(s);\n l:=1;\n r:=26;\n f:=1;\n if length(s)<>26 then begin writeln(-1); exit; end;\n for i:=1 to 26 do\n if s[i]<>'?' then a[ord(s[i])]:=a[ord(s[i])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n if f=0 then \n \n while (r+1<=length(s)) do\n begin\n f:=1;\n r:=r+1;\n l:=l+1;\n a[ord(s[l-1])]:=a[ord(s[l-1])]-1;\n a[ord(s[r])]:=a[ord(s[r])]+1;\n for j:=65 to 90 do\n if a[j]>1 then f:=0;\n \n if f=1 then break;\n end;\n if f=0 then writeln(-1)\n else \n for i:=l to r do\n if not(s[i]='?') then write(s[i])\n else\n for j:=65 to 90 do\n if a[j]=0 then begin a[j]:=1; write(chr(j)); break; end; \n End."}, {"source_code": "var a:array[1..50010] of longint;\nb:array[1..30] of char;\nst,st2:ansistring;\nalf:string;\nz:char;\nn,i,j,k,p,q,r2,l2,kl:longint;\n\n procedure sort(l,r: longint);\n var\n i,j: longint;\n x,y: char;\n begin\n i:=l;\n j:=r;\n x:=b[i+random(j-i-1)];\n repeat\n while b[i]j) then\n begin\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 then a[p]:=a[p]+1;\n end;\n for i:=1 to n do\n begin\n z:=st[i];\n if z='?' then begin\n for j:=1 to 26 do\n if a[j]=0 then begin\n z:=alf[j];\n p:=pos(z,st);\n if ((p>0) and (abs(p-i)>26)) or (p=0) then begin\n st2:=st2+z;\n a[j]:=1;\n break;\n end\n else begin\n k:=k+1;\n z:=st2[k];\n st2:=st2+z;\n end;\n\n end\n end\n else st2:=st2+z;\n end;\n for l2:=1 to n-25 do\n begin\n q:=0;\n for r2:=l2 to l2+25 do\n begin\n q:=q+1;\n b[q]:=st2[r2];\n end;\n sort(l2,26);\n kl:=0;\n for r2:=2 to 26 do\n if b[r2]=b[r2-1] then kl:=1;\n if kl=0 then begin\n writeln(st2);\n halt;\n end;\n end;\n writeln('-1');\nend.\n\n"}], "src_uid": "a249431a4b0b1ade652997fe0b82edf3"} {"source_code": "program cf814E;\nconst mo=1000000007;\n maxn=51;\nvar dp:array[0..1,0..maxn,0..maxn,0..maxn,0..maxn] of int64;\n v:int64;\n i,pre,now,pre1,pre2,now1,now2,d1,d2,n:longint;\n d:array[0..maxn] of longint;\nprocedure plus(var x:int64;y:int64);inline;\nbegin\n x:=(x+y)mod mo;\nend;\nbegin\n readln(n);\n for i:=1 to n do read(d[i]);\n d1:=d[1]-1;\n d2:=d[2]-1;\n fillchar(dp,sizeof(dp),0);\n if(d1=1)and(d2=1) then dp[0,1,0,1,0]:=1;\n if(d1=2)and(d2=1) then dp[0,0,1,1,0]:=1;\n if(d1=1)and(d2=2) then dp[0,1,0,0,1]:=1;\n if(d1=2)and(d2=2) then dp[0,0,1,0,1]:=1;\n for i:=3 to n do\n begin\n now:=i and 1;\n pre:=now xor 1;\n for pre1:=0 to i do\n for pre2:=0 to i do\n for now1:=0 to i do\n for now2:=0 to i do dp[now,pre1,pre2,now1,now2]:=0;\n for pre1:=0 to i-1 do\n for pre2:=0 to i-1 do\n for now1:=0 to i-1 do\n for now2:=0 to i-1 do if dp[pre,pre1,pre2,now1,now2]>0 then\n begin\n v:=dp[pre,pre1,pre2,now1,now2];\n if d[i]=2 then\n begin\n if pre1+pre2=0 then\n begin\n //next,1 edge\n if now1>0 then plus(dp[now,now1-1,now2,1,0],v*now1 mod mo);\n if now2>0 then plus(dp[now,now1+1,now2-1,1,0],v*now2 mod mo);\n end else\n begin\n //current\n\n //1 edge\n if pre1>0 then plus(dp[now,pre1-1,pre2,now1+1,now2],v*pre1 mod mo);\n if pre2>0 then plus(dp[now,pre1+1,pre2-1,now1+1,now2],v*pre2 mod mo);\n\n //2 edge\n if (pre1>0)and(now1>0) then\n plus(dp[now,pre1-1,pre2,now1-1,now2],v*pre1 mod mo*now1 mod mo);\n if (pre1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1+1,now2-1],v*pre1 mod mo*now2 mod mo);\n if (pre2>0)and(now1>0) then\n plus(dp[now,pre1+1,pre2-1,now1-1,now2],v*pre2 mod mo*now1 mod mo);\n if (pre2>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1+1,now2-1],v*pre2 mod mo*now2 mod mo);\n end;\n end else\n begin\n if pre1+pre2=0 then\n begin\n //next,1 edge\n if now1>0 then plus(dp[now,now1-1,now2,0,1],v*now1 mod mo);\n if now2>0 then plus(dp[now,now1+1,now2-1,0,1],v*now2 mod mo);\n end else\n begin\n //current\n\n //1 edge\n if pre1>0 then plus(dp[now,pre1-1,pre2,now1,now2+1],v*pre1 mod mo);\n if pre2>0 then plus(dp[now,pre1+1,pre2-1,now1,now2+1],v*pre2 mod mo);\n\n //2 edge\n if (pre1>0)and(now1>0) then\n plus(dp[now,pre1-1,pre2,now1,now2],v*pre1 mod mo*now1 mod mo);\n if (pre1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1+2,now2-1],v*pre1 mod mo*now2 mod mo);\n if (pre2>0)and(now1>0) then\n plus(dp[now,pre1+1,pre2-1,now1,now2],v*pre2 mod mo*now1 mod mo);\n if (pre2>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1+2,now2-1],v*pre2 mod mo*now2 mod mo);\n\n //3 edge\n if (pre1>0)and(now1>1) then\n plus(dp[now,pre1-1,pre2,now1-2,now2],v*pre1 mod mo*(now1*(now1-1) div 2 mod mo)mod mo);\n if (pre1>0)and(now2>1) then\n plus(dp[now,pre1-1,pre2,now1+2,now2-2],v*pre1 mod mo*(now2*(now2-1)div 2 mod mo)mod mo);\n if (pre1>0)and(now1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1,now2-1],v*pre1 mod mo*now1 mod mo*now2 mod mo);\n if (pre2>0)and(now1>1) then\n plus(dp[now,pre1+1,pre2-1,now1-2,now2],v*pre2 mod mo*(now1*(now1-1) div 2 mod mo)mod mo);\n if (pre2>0)and(now2>1) then\n plus(dp[now,pre1+1,pre2-1,now1+2,now2-2],v*pre2 mod mo*(now2*(now2-1)div 2 mod mo)mod mo);\n if (pre2>0)and(now1>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1,now2-1],v*pre2 mod mo*now1 mod mo*now2 mod mo);\n end;\n end;\n end;\n end;\n writeln(dp[n and 1,0,0,0,0]);\nend.\n\n", "positive_code": [{"source_code": "program cf814E;\nconst mo=1000000007;\n maxn=51;\nvar dp:array[0..1,0..maxn,0..maxn,0..maxn,0..maxn] of int64;\n v:int64;\n i,pre,now,pre1,pre2,now1,now2,d1,d2,n:longint;\n d:array[0..maxn] of longint;\nprocedure plus(var x:int64;y:int64);inline;\nbegin\n x:=(x+y)mod mo;\nend;\nbegin\n readln(n);\n for i:=1 to n do read(d[i]);\n d1:=d[1]-1;\n d2:=d[2]-1;\n fillchar(dp,sizeof(dp),0);\n if(d1=1)and(d2=1) then dp[0,1,0,1,0]:=1;\n if(d1=2)and(d2=1) then dp[0,0,1,1,0]:=1;\n if(d1=1)and(d2=2) then dp[0,1,0,0,1]:=1;\n if(d1=2)and(d2=2) then dp[0,0,1,0,1]:=1;\n for i:=3 to n do\n begin\n now:=i and 1;\n pre:=now xor 1;\n for pre1:=0 to i do\n for pre2:=0 to i do\n for now1:=0 to i do\n for now2:=0 to i do dp[now,pre1,pre2,now1,now2]:=0;\n for pre1:=0 to i-1 do\n for pre2:=0 to i-1 do\n for now1:=0 to i-1 do\n for now2:=0 to i-1 do if dp[pre,pre1,pre2,now1,now2]>0 then\n begin\n v:=dp[pre,pre1,pre2,now1,now2];\n if d[i]=2 then\n begin\n if pre1+pre2=0 then\n begin\n //next,1 edge\n if now1>0 then plus(dp[now,now1-1,now2,1,0],v*now1 mod mo);\n if now2>0 then plus(dp[now,now1+1,now2-1,1,0],v*now2 mod mo);\n end else\n begin\n //current\n\n //1 edge\n if pre1>0 then plus(dp[now,pre1-1,pre2,now1+1,now2],v*pre1 mod mo);\n if pre2>0 then plus(dp[now,pre1+1,pre2-1,now1+1,now2],v*pre2 mod mo);\n\n //2 edge\n if (pre1>0)and(now1>0) then\n plus(dp[now,pre1-1,pre2,now1-1,now2],v*pre1 mod mo*now1 mod mo);\n if (pre1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1+1,now2-1],v*pre1 mod mo*now2 mod mo);\n if (pre2>0)and(now1>0) then\n plus(dp[now,pre1+1,pre2-1,now1-1,now2],v*pre2 mod mo*now1 mod mo);\n if (pre2>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1+1,now2-1],v*pre2 mod mo*now2 mod mo);\n end;\n end else\n begin\n if pre1+pre2=0 then\n begin\n //next,1 edge\n if now1>0 then plus(dp[now,now1-1,now2,0,1],v*now1);\n if now2>0 then plus(dp[now,now1+1,now2-1,0,1],v*now2);\n end else\n begin\n //current\n\n //1 edge\n if pre1>0 then plus(dp[now,pre1-1,pre2,now1,now2+1],v*pre1);\n if pre2>0 then plus(dp[now,pre1+1,pre2-1,now1,now2+1],v*pre2);\n\n //2 edge\n if (pre1>0)and(now1>0) then\n plus(dp[now,pre1-1,pre2,now1,now2],v*pre1*now1);\n if (pre1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1+2,now2-1],v*pre1*now2);\n if (pre2>0)and(now1>0) then\n plus(dp[now,pre1+1,pre2-1,now1,now2],v*pre2*now1);\n if (pre2>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1+2,now2-1],v*pre2*now2);\n\n //3 edge\n if (pre1>0)and(now1>1) then\n plus(dp[now,pre1-1,pre2,now1-2,now2],v*pre1*(now1*(now1-1)>>1));\n if (pre1>0)and(now2>1) then\n plus(dp[now,pre1-1,pre2,now1+2,now2-2],v*pre1*(now2*(now2-1)>>1));\n if (pre1>0)and(now1>0)and(now2>0) then\n plus(dp[now,pre1-1,pre2,now1,now2-1],v*pre1*now1*now2);\n if (pre2>0)and(now1>1) then\n plus(dp[now,pre1+1,pre2-1,now1-2,now2],v*pre2*(now1*(now1-1)>>1));\n if (pre2>0)and(now2>1) then\n plus(dp[now,pre1+1,pre2-1,now1+2,now2-2],v*pre2*(now2*(now2-1)>>1));\n if (pre2>0)and(now1>0)and(now2>0) then\n plus(dp[now,pre1+1,pre2-1,now1,now2-1],v*pre2*now1*now2);\n end;\n end;\n end;\n end;\n writeln(dp[n and 1,0,0,0,0]);\nend.\n\n"}], "negative_code": [], "src_uid": "db884d679d9cfb1dc4bc511f83beedda"} {"source_code": "var A:array [0..30] of int64;\n x,l,r,ans,ans1,ans2,t,t1:int64;\n kl,kr,i,j,v:integer;\n b,c:string[30];\nbegin\nreadln(l,r);\nif r<=5 then begin\n ans:=r*(10-1-r);\n write(ans);\n exit;\nend;\n \nA[1]:=5;\nA[0]:=1;\nfor i:=2 to 15 do\nA[i]:=A[i-1]*10;\ni:=15;\n \nwhile A[i]>r do dec(i);\nif A[i]>=l then\nans2:=A[i]*(A[i]-1)\nelse ans2:=0;\n \n \nstr(l,b);\nfor i:=1 to length(b) do\nb[i]:=chr(ord('9')-ord(b[i])+ord('0'));\ni:=1;\nwhile b[i]='0' do inc(i);\nb:=copy(b,i,length(b)-i+1);\nval(b,t,v);\nans:=l*t; \n \nstr(r,b);\nfor i:=1 to length(b) do\nb[i]:=chr(ord('9')-ord(b[i])+ord('0'));\ni:=1;\nwhile b[i]='0' do inc(i);\nb:=copy(b,i,length(b)-i+1);\nval(b,t,v);\nans1:=r*t; \n \n if (ans>ans1) and (ans>ans2) then write(ans)\n else if ans2>ans1 then write(ans2)\n else write(ans1);\n \nend.\n ", "positive_code": [{"source_code": "var l,r:int64;\nt1,t2,ff,ss,f,s:int64;\nopt:int64;\nlen:longint;\n begin\n readln(l,r);\n f:=1;\n s:=9;\n\n for len:=1 to 10 do\n begin\n ff:=f;\n ss:=s;\n if l>ff then ff:=l;\n if rt2*(s-t2) then ss:=t2\n else ff:=t1;\n end;\n\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n ff:=ff+1;\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n ff:=ff+1;\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n\n\n f:=f*10;\n s:=s*10+9;\n end;\n\n writeln(opt);\n end."}, {"source_code": "var l,r:int64;\nt1,t2,ff,ss,f,s:int64;\nopt:int64;\nlen:longint;\n begin\n readln(l,r);\n f:=1;\n s:=9;\n\n for len:=1 to 10 do\n begin\n ff:=f;\n ss:=s;\n if l>ff then ff:=l;\n if rt2*(s-t2) then ss:=t2\n else ff:=t1;\n end;\n\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n ff:=ff+1;\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n ff:=ff+1;\n if (ff>=l)and(ff<=r) then\n if (ff*(s-ff))>opt then opt:=(ff*(s-ff));\n\n\n f:=f*10;\n s:=s*10+9;\n end;\n\n writeln(opt);\n end.\n"}, {"source_code": " uses math;\nconst san='0123456789';\n otr='9876543210';\nvar t1,l,r,chis:int64;\n function otra(v:int64):int64;\n var z:int64;\n q:longint;\n a:string;\n begin\n a:='';\n while v>0 do\n begin\n a:=otr[pos(chr((v mod 10)+48),san)]+a;\n v:=v div 10;\n end;\n val(a,z,q);\n otra:=z;\n end;\n\n begin\n read(l,r);\nt1:=max(otra(l)*l,otra(r)*r);\nchis:=5;\nwhile chis<=r do\n begin\n if chis>=l then t1:=max(t1,otra(chis)*chis);\n chis:=chis*10;\n end;\n write(t1);\nend.\n"}, {"source_code": "Program \t\tA;\nvar\np : array[0..20] of int64;\nw,i,j,k : Longint;\nn,m,temp,now : int64;\nflag : Boolean;\nbegin\n\treadln(n,m);\n\tW :=0;temp :=m;\n\twhile temp>0 do\n\tbegin\n\t\t\tW:=W+1;\n\t\t\ttemp := temp div 10;\n\tend;\n\tp[0]:=1;\n\tfor i :=1 to w do p[i]:=p[i-1]*10;\n flag :=false;\n\tfor i :=4 downto 0 do\n\tif (i*p[w-1]<=m)and(i*p[w-1]>=n) then begin flag := true;break;end;\n\n if flag then begin\n\tNow := i*p[w-1];\n\tfor i :=w-2 downto 0 do\n\tbegin\n\t\tfor j := 9 downto 0 do\n\t\tif j*p[i]+now<=m then break;\n\t\tnow := j*p[i]+now;\n\tend;\n end\n else begin\n for i :=5 to 9 do\n\t if i*p[w-1]+p[w-1]-1>=n then begin flag := true;break;end;\n now := i*p[w-1];\n if flag then begin\n\t Now := i*p[w-1];\n\t for i :=w-2 downto 0 do\n\t begin\n\t\t for j :=0 to 9 do\n\t\t if j*p[i]+now+p[i]-1>=n then break;\n\t\t now := j*p[i]+now;\n\t end;\n end;\n end;\n\twriteln(now*(p[w]-1-Now));\nend.\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nvar\n l, r, pow, ans, res : int64;\n\nfunction f(a : int64) : int64;\nvar b : int64;\nsz, i : integer;\nbegin\n b := a;\n sz := 0;\n while b > 0 do begin\n inc(sz);\n b := b div 10;\n end;\n b := 1;\n for i := 1 to sz do\n b := b * 10;\n result := a * (b - a - 1);\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n read(l, r);\n ans := max(f(l), f(r));\n pow := 1;\n while true do begin\n if pow > r then\n break;\n res := pow * 5;\n if (res >= l) and (res <= r) then\n ans := max(ans, f(res));\n pow := pow * 10;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "Var zz,l,r:int64;\nz,i:longint;\nfunction kol(x:int64):longint;\nVar n:longint;\nbegin\n n:=0;\n while x<>0 do\n begin\n x:=x div 10;\n inc(n);\n end;\n kol:=n;\nend;\nfunction probeg(x:int64):int64;\nVar z,rez:int64;\nbegin\n rez:=0;\n z:=1;\n while x<>0 do\n begin\n rez:=rez+z*(9-x mod 10);\n x:=x div 10;\n z:=z*10;\n end;\n probeg:=rez;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n read(l,r);\n if kol(l)<>kol(r)\n then begin\n z:=kol(r);\n l:=1;\n for i:=1 to z-1 do\n l:=l*10;\n end;\n z:=kol(r);\n zz:=1;\n for i:=1 to z-1 do\n zz:=zz*10;\n if r<=5*zz-1\n then writeln(r*probeg(r))\n else begin\n if l>5*zz-1\n then writeln(l*probeg(l))\n else writeln((5*zz-1)*probeg(5*zz-1));\n end;\nend."}, {"source_code": "Program Reflection;\nvar l,r,max,half:int64;\n ans:qword;\nbegin\n readln(l,r);\n max:=1;\n while max<=r do max:=max*10;\n half:=max shr 1;\n max:=max-1;\n if (l<=half) and (half<=r) then ans:=half\n else if abs(half-l)ans then ans:=z;\n end;\n z:=l*(g[ll]-l);\n if z>ans then ans:=z;\n z:=r*(g[rr]-r);\n if z>ans then ans:=z;\n if ((g[ll] div 2>=l)and(g[ll] div 2<=r))or((g[ll]-g[ll] div 2>=l)and(g[ll]-g[ll] div 2<=r))\n then begin z:=g[ll] div 2*(g[ll]-g[ll] div 2);\n if z>ans then ans:=z;\n end;\n ll:=rr;\n if ((g[ll] div 2>=l)and(g[ll] div 2<=r))or((g[ll]-g[ll] div 2>=l)and(g[ll]-g[ll] div 2<=r))\n then begin z:=g[ll] div 2*(g[ll]-g[ll] div 2);\n if z>ans then ans:=z;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n t,l,r,q,res:int64;\n j,i:longint;\n procedure check(x,q:int64);\n var\n i:int64;\n k:longint;\n begin\n i:=x;\n k:=0;\n while (i>0)do begin\n k:=k+1;\n i:=i div 10;\n end;\n i:=q;\n while (i>0)do begin\n k:=k-1;\n i:=i div 10;\n end;\n if (k<>0)then exit;\n if (x*(q-x)>res)then res:=x*(q-x);\n end;\nbegin\n read(l,r);\n q:=1;\n res:=0;\n for i:=1 to 10 do begin\n q:=q*10;\n check(l,q-1);\n check(r,q-1);\n for j:=-100 to 100 do begin\n t:=(q div 2)+j;\n if (t>=l)and(t<=r)then check(t,q-1);\n end;\n end;\n writeln(res);\nend."}, {"source_code": "VAR\n m,l,r: int64;\n i:longint; \n s: string;\nBEGIN\nReadln(l,r); str(r,s); m:=0;\nfor i:=1 to length(s) do m:=10*m+9;\nif (l<=m div 2) and (r>=m div 2) then Writeln((m div 2)*(m-(m div 2)))\nelse if r*(m-r)>l*(m-l) then Writeln(r*(m-r))\n else Writeln(l*(m-l))\nEND."}, {"source_code": "uses\n SysUtils,\n math;\n\nvar mak,n,m,res,count,x:int64;\nbegin\n readln(n,m);\n count:=trunc(logn(10,m))+1;\n res:=trunc(power(10,count))-1;\n x:=res div 2;\n if (x<=m) and (x>=n) then mak:=x*(res-x)\n else begin\n if x>m then mak:=m*(res-m)\n else mak:=n*(res-n);\n end;\n writeln(mak);\nend."}, {"source_code": "uses math;\n\nvar l,r,x:int64;\n\nfunction tt(x:int64):int64;\nvar y:int64;\n begin\n y:=1;\n while y<=x do\n y:=y*10;\n tt:=x*(y-x-1);\n end;\n\n begin\n read(l,r);\n\n x:=1;\n while x*10<=r do\n x:=x*10;\n\n if (r>=x*5) and\n (l<=x*5) then begin\n writeln((x*5)*(x*5-1));\n halt;\n end;\n\n if (r>=x*5-1) and\n (l<=x*5-1) then begin\n writeln((x*5)*(x*5-1));\n halt;\n end;\n\n if (r>=x div 2) and\n (l<=x div 2) then begin\n writeln(max(max(tt(l),tt(r)),(x div 2)*(x div 2-1)));\n halt;\n end;\n\n\n writeln(max(tt(l),tt(r)));\n end."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n l,r,t,g,i,k:Int64;\nFunction Heg(n:Int64):Int64;\nVar\n r,t,k:Int64;\nBegin\n r:=0;\n t:=n;\n k:=1;\n While t>0 Do Begin\n r:=r+(9-t mod 10)*k;\n t:=t div 10;\n k:=k*10;\n End;\n Heg:=n*r;\nEnd;\nBegin\n Read(l,r);\n t:=r;\n g:=0;\n While t>0 Do Begin\n g:=g+1;\n t:=t div 10;\n End;\n k:=5;\n i:=1;\n While i<=g-1 Do Begin\n k:=k*10;\n i:=i+1;\n End;\n If (k>=l) and (k<=r) Then Write(Heg(k))\n Else Begin\n If Heg(l)>Heg(r) Then Write(Heg(l))\n Else Write(Heg(r));\n End;\nEnd.\n"}, {"source_code": "var\n kq,ni,k2,k1:int64;\n l,r,u,v,i:longint;\nfunction tinh(x:longint):longint;\nvar\n y:longint;\nbegin\n y:=0;\n while x>0 do\n begin\n inc(y);\n x:=x div 10;\n end;\n tinh:=y;\nend;\nbegin\n readln(l,r);\n if r=1000000000 then\n begin\n writeln('8999999999000000000');\n halt;\n end; \n u:=tinh(l); v:=tinh(r);\n kq:=0;\n if v>u+1 then\n begin\n for i:=1 to v-1 do kq:=kq*10+9;\n kq:=kq*kq-1;\n kq:=kq div 4;\n end;\n ni:=0;\n for i:=1 to v do ni:=ni*10+9;\n k1:=ni;\n ni:=ni div 2;\n if r<=ni then\n begin\n k2:=r;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k1:=k1*k1;\n k2:=k1-k2;\n k2:=k2 div 4;\n end\n else\n if l<=ni then\n begin\n k2:=k1*k1-1;\n k2:=k2 div 4;\n end\n else\n begin\n k2:=l;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end;\n if k2>kq then kq:=k2;\n ni:=0;\n for i:=1 to u do ni:=ni*10+9;\n k1:=ni;\n ni:=ni div 2;\n if l>=ni then\n begin\n k2:=l;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end\n else\n if r>=ni then\n begin\n k2:=k1*k1-1;\n k2:=k2 div 4;\n end\n else\n begin\n k2:=r;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end;\n writeln(kq);\nend.\n"}, {"source_code": "Type ttm=Record\n l,r:LongInt;\n End;\n tm=Array [1..9] of ttm;\nVar i,x,l,r,h:LongInt;\n m:tm;\n kol:Int64;\n\nFunction Max (a,b,c:Int64):Int64;\nBegin\n If (a>=b) and (a>=c) then Max:=a\n else If (b>=a) and (b>=c) then Max:=b\n else If (c>=a) and (c>=b) then Max:=c\nEnd;\n\nFunction sum (x:LongInt):Int64;\nVar s,ss:String;\n mm,kol:Int64;\n j:LongInt;\n code:Integer;\nBegin\n Str (x,s);\n kol:=Length (s);\n ss:='';\n For J:=1 to kol do\n ss:=ss+'9';\n Val (ss,mm,code);\n sum:=(mm-x)*x;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n m[1].l:=499999999;\n m[1].r:=500000000;\n m[2].l:=49999999;\n m[2].r:=50000000;\n m[3].l:=4999999;\n m[3].r:=5000000;\n m[4].l:=499999;\n m[4].r:=500000;\n m[5].l:=49999;\n m[5].r:=50000;\n m[6].l:=4999;\n m[6].r:=5000;\n m[7].l:=499;\n m[7].r:=500;\n m[8].l:=49;\n m[8].r:=50;\n m[9].l:=4;\n m[9].r:=5;\n\n Readln (l,r);\n For I:=1 to 9 do\n If (l<=m[i].l) and (r>=m[i].l)\n then Begin kol:=sum(m[i].l); Break End\n else If (l<=m[i].r) and (r>=m[i].r)\n then Begin kol:=sum (m[i].r); Break End;\n kol:=Max (sum (l),sum (r),kol);\n Writeln (kol);\nEnd."}, {"source_code": "uses\n math;\nvar\n ans,l,r,x:int64;\n\nfunction weight(x:int64):int64;\nvar\n power,mem,res,c:int64;\nbegin\n res:=0; mem:=x; power:=1;\n while (x<>0) do\n begin\n c:=x mod 10;\n c:=9-c;\n res:=res+c*power;\n power:=power*10;\n x:=x div 10;\n end;\n weight:=res*mem;\nend;\n\nbegin\n readln(l,r);\n ans:=max(weight(l),weight(r));\n x:=5;\n while (x<=r) do\n begin\n if (l<=x) and (x<=r) then ans:=max(ans,weight(x));\n x:=x*10;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n n,d,x,y,z:int64;\n i,j:longint;\n b:array[0..10] of int64;\n\nfunction psi(n:int64):int64;\nvar\n a,d:int64;\nbegin\n d:=1;\n a:=0;\n while n>0 do\n begin\n a:=d*(9-n mod 10)+a;\n d:=d*10;\n n:=n div 10;\n end;\n psi:=a;\nend;\nbegin\n d:=1;\n for i:=1 to 10 do\n begin\n d:=d*10;\n b[i]:=d-1;\n end;\n readln(x,y);\n\n j:=1;\n while y>b[j] do\n j:=j+1;\n begin\n z:=b[j] div 2;\n if (xx then\n x:=y;\n if x=n then t1:=max(t1,link(chis)*chis);\n chis:=chis*10;\n end;\n writeln(t1);\nend."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n cur,ans,ll,rr,a,b,s,best,mid: int64;\n d: longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(ll,rr);\n ans:=0; s:=1;\n for d:=1 to 10 do\n begin\n a:=ll; b:=rr;\n if a < s then a:=s;\n if b > s*10-1 then b:=s*10-1;\n if a <= b then\n begin\n mid:=s*5;\n if a > mid then best:=a else\n if b < mid then best:=b\n else best:=mid;\n cur:=best*(s*10-best-1);\n if cur > ans then ans:=cur;\n end;\n s:=s*10;\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,O+,S+}\nuses\n SysUtils,Math;\nvar\n l1,r1,q1,q2,l,r,m1,m2,ans : int64;\n q,i : longint;\nfunction fi(x : int64) : int64;\nvar\n s : string;\n i : longint;\nbegin\n result:=0;\n s:=inttostr(x);\n for i:=1 to length(s) do\n result:=result*10+9-(ord(s[i])-48);\nend;\nbegin\n randomize;\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readln(l,r);\n l1:=l;\n r1:=r;\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q1>q2 then\n r:=m2\n else\n l:=m1;\n end;\n ans:=fi(l)*l;\n for i:=l+1 to r do\n ans:=max(ans,fi(i)*i);\n l:=l1;\n r:=r1;\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q1q2 then\n r:=m2\n else\n l:=m1;\n end;\n ans:=fi(l)*l;\n for i:=l+1 to r do\n ans:=max(ans,fi(i)*i);\n l:=l1;\n r:=r1;\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q10 do\n begin\n p:=p div 10;\n inc(k);\n end;\n p:=5;\n for i:=2 to k do\n p:=p*10;\n if p>=r\n then\n begin\n ans:=ff(r);\n end\n else\n begin\n if l>p\n then\n begin\n ans:=ff(l);\n end\n else\n begin\n ans:=ff(p);\n end;\n end;\n write(ans);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "var l,r,p,s,f,max:int64;\n i:longint;\n k:string;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif r=1000000000 then begin\nk:='8999999999000000000';\nwrite(k);\nexit;\nend;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif (f>500000000) and (r<1000000000) then r:=f+1;\nend;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "uses math;\nVar x,l,r,ans:int64;\n function w(x:int64):int64;\n var s:string;\n q:int64;\n j:longint;\n begin\n q:=0;\n str(x,s);\n for j:=1 to length(s) do\n q:=q*10+(9-ord(s[j])+48);\n w:=x*q;\n end;\n begin\n read(l,r);\n ans:=max(w(l),w(r));\n x:=4;\n While x<=r do\n begin\n if (x>=l)and(x<=r) then ans:=max(ans,w(x));\n x:=x*10+9;\n end;\n Writeln(ans);\n end."}, {"source_code": "program Projectob;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\nl,r,i,n,k,p:int64;\nbegin\n{ TODO -oUser -cConsole Main : Insert code here }\nread(l,r);\nn:=1;\nwhile r>=n do n:=n*10;\nn:=n div 10;\n//writeln(n);\nif (n=r) then\np:=r;\nif r<10*n div 2 then p:=r;\nif l>10*n div 2 then p:=l;\nif (10*n div 2<=r)and(l<=10*n div 2) then p:=5*n;\nk:=10*n-1-p;\nwriteln(p*k);\nread(i);\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\nprocedure mask(a,b:int64;var y: int64;var l:integer);\nvar s: string;\n i,com: integer;\n temp: int64;\nbegin\nstr(b,s);\ncom:=length(s);\ntemp:=5;\nfor i := 2 to com do\n temp:=temp*10;\nif (b >= temp) and (a <= temp) then\n y:=temp;\nif (b <= temp) then\n y:=b;\nif (b >= temp) and (a >= temp) then\n y:=a;\nl:=com;\nend;\n\nprocedure inverse(l:integer;y: int64;var inv: int64);\nvar i:integer;\nbegin\ninv:=9;\nfor i:= 2 to l do\n inv:=inv*10+9;\ninv:=inv - y;\nend;\n\nvar a,b: int64;\n x,y:int64;\n len:integer;\nbegin\nread(a,b);\nmask(a,b,x,len);\ninverse(len,x,y);\nwriteln(x*y);\nend.\n"}, {"source_code": "program Project1;\nvar i:integer;\n\nfunction znak(i:integer):byte;\nvar l:integer;\nbegin\n l:=0;\n while i<>0 do\n begin\n inc(l);\n i:=i div 10;\n end;\n znak:=l;\nend;\n\nprocedure writeans(a:int64);\nbegin\n writeln(a);\n halt(0);\nend;\n\nprocedure gogo(l,r:integer);\nvar x,y:int64;\n i,j:integer;\nbegin\n j:=znak(r);\n x:=9;\n for i:=2 to j do\n x:=x*10+9;\n if (r>=x div 2)and(l<=x div 2+1) then writeans((x div 2)*(x div 2+1))\n else if znak(r)>znak(l) then writeans(r*(x-r))\n else if (abs(r-x div 2)0 do\n begin\n inc(lb);\n r:=r div 10;\n end;\n r:=r_;\n now:=0;\n for i:=1 to lb do now:=now*10+9;\n t1:=now div 2;t2:=now div 2+1;\n if (l<=t2)and(r>=t1) then\n begin\n writeln(t1*(now-t1));\n end\n else\n begin\n if (r0 Do\n Begin\n R:=R+(9-X Mod 10)*T;\n T:=T*10;\n X:=X Div 10;\n End;\n Go:=R;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Read(L,R);\n X:=1;\n While X<=R Do\n X:=X*10;\n X:=X Div 10;X:=X*5;\n\n If (L<=X) And (R>=X)\n Then Write(Go(X)*X)\n Else If (L<=X) And (R<=X)\n Then Write(Go(R)*R)\n Else Write(Go(L)*L);\n\nEnd."}, {"source_code": "var\n l,r,n,k,d\t:\tint64;\n i\t\t:\tlongint;\n s\t\t:\tstring;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(l,r);\n str(r,s);\n n:=length(s);\n k:=5; d:=10;\n for i:=1 to n - 1 do\n \td:=d * 10;\n k:=(d div 10) * k;\n if (r >= k - 1) and (k >= l) then write(k * (k - 1)) else\n if (r >= k - 1) then write(l * (d - 1 - l)) else write(r * (d - 1 - r));\n\n\nend."}, {"source_code": "uses math;\nvar f1,f2:text;\nl,r:int64;\nm9,i:longint;\nmid:int64;\nres:int64;\n\nFunction rev(v:longint):int64;\nvar st:string;\ns:int64;\ni:longint;\nbegin\n str(v,st);\n s:=0;\n for i:=1 to length(st) do\n s:=s*10+9-(ord(st[i])-48);\n rev:=s;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,l,r);\n m9:=0;\n for i:=1 to 9 do\n begin\n m9:=m9*10+9;\n mid:=m9 div 2;\n if (mid>=l) and (mid<=r) then res:=max(res,mid*(m9-mid));\n mid:=m9 div 2+1;\n if (mid>=l) and (mid<=r) then res:=max(res,mid*(m9-mid));\n end;\n res:=max(res,l*rev(l));\n res:=max(res,r*rev(r));\n writeln(f2,res);\n close(f1);\n close(F2);\nend.\n"}, {"source_code": "var\n i:longint;\n l,r,pot,m1,num:int64;\nfunction max(a,b:int64):int64;\nbegin\n if a0 do\n begin\n a:=a div 10;\n inc(f);\n end;\n d:=f;\nend;\nfunction comp(da:int64):int64;\nvar\n pot:int64;\n x:longint;\nbegin\n pot:=1;\n for x:=1 to d(da) do\n pot:=pot*10;\n pot:=pot-1;\n comp:=pot-da;\nend;\nfunction f(g:int64):int64;\nbegin\n f:=g*comp(g);\nend;\nbegin\n readln(l,r);\n pot:=1;\n for i:=1 to d(r)-1 do\n begin\n pot:=pot*10;\n end;\n if d(l)= t * 5) and (l <= t * 5) then\n begin\n writeln((t * 5) * (t * 5 - 1));\n halt(0);\n end;\n\n if (r >= t * 5 - 1) and (l <= t * 5 - 1) then\n begin\n writeln((t * 5) * (t * 5 - 1));\n halt(0);\n end;\n\n if (r >= t div 2) and (l <= t div 2) then\n begin\n writeln(max(max(f(l), f(r)),(t div 2) * (t div 2 - 1)));\n halt(0);\n end;\n\n writeln(max(f(l), f(r))); \n \n\nend.\n "}, {"source_code": "var temp:longint;\n ot,max,mi,l,r,a,i:int64;\n s,s2:string;\nbegin\n\n max:=-1;\n readln(l,r);\n str(r,s);\n s2:='4';\n while length(s)>length(s2)do s2:=s2+'9';\n val(s2,a,temp);\n if (a>=l)and(a<=r)then i:=a else\n if a>r then i:=r\n else i:=l;\n\n ot:=1;\n while ot<=i do ot:=ot*10;\n ot:=ot-1-i;\n write(i*ot);\nend."}, {"source_code": "program aaa; var a,b,i,m,n,k,l,t:int64;j:longint;{s:string;a:array[0..10]of string; w:string;{ label 1; } q:char; f:boolean; function aa(q:char):longint; begin if pos(q,'aeiouAEIOU')>0 then aa:=1 else aa:=0; end; begin { assign(input,'input.txt');reset(input); assign(output,'output.txt');rewrite(output); } readln(a,b); m:=1; while m<=a do m:=m*10;m:=m-1; n:=1;while n<=b do n:=n*10;n:=n-1; if m=n then begin k:=m div 2; if (a<=k)and(b>=k) then write(k*(m-k)) else begin if a>k then write(a*(m-a)) else write(b*(m-b)); end; end else begin k:=m div 2; if kb then write(a) else write(b); end; end."}, {"source_code": "{$M 16777216}\nprogram solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nconst\n MaxN = 100000;\n\ntype\n int = longint;\n\nvar\n i, l, r: int64;\n k, maxx, sum: int64;\n\nfunction weight(i: int64): int64;\nvar\n s: string;\n z: int;\n a, b: int64;\nbegin\n a := i;\n s := inttostr(i);\n b := 0;\n for z := 1 to length(s) do\n b := b * 10 + (9 - (ord(s[z]) - ord('0')));\n result := a * b;\nend;\n\nbegin\n\n{$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output);\n{$ENDIF}\n\n sum := -1;\n read(l, r);\n k := 1;\n {i := l;\n while i <= r do begin\n k := weight(i);\n if k > sum then begin\n maxx := i;\n sum := k;\n end;\n inc(i);\n end;\n write(maxx, ' ', sum); \n }\n\n while k < r do\n k := k * 10;\n if k = r then\n write(weight(k))\n else begin\n if k div 2 > r then\n write(weight(r))\n else begin\n if k div 2 >= l then\n write(weight(k div 2))\n else\n write(weight(l));\n end;\n end;\n\n{$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n{$ENDIF}\n\nend.\n"}, {"source_code": "{ uses crt;}\n const nn=200; eps=0.0000001;\n label 1;\n type mas=array [-nn..nn] of int64;\n trip=record mx,my,m:real;end; trip1=^trip;\n\n var n2,n1,ot,n,k,t,p,imin,m,s,d,l,r:int64;\n pp,pp1,pp2:int64;\n\n i,j:longint;\n cc, bb,aa ,b,x,y,kk,tt:mas; ot1: trip;\n obl:boolean; gvx,gvy,rr:real; sss:array[0..3] of real;\n mgl:trip;\n function al(x,y:real):real; var t,p:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;\n\n function otr(n:int64):int64;\n var s,k,p:int64; i,j:longint; a,b:array[0..20] of int64;\nbegin k:=n;i:=0;while k>0 do begin inc(i);a[i]:=k mod 10;k:=k div 10; end;\n for j:=1 to i do b[j]:=9-a[j]; s:=0;\n p:=1; for j:=1 to i do begin s:=s+b[j]*p;p:=p*10;end;\n otr:=s;\nend;\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n { writeln(otr(637));}\n readln(l,r);ot:=0;\n { for i:=l to r do begin p:=otr(i); if (p*i)>=ot then t:=i;\n ot:=max(ot,i*otr(i));end;writeln(t,' ',ot); }\n k:=r;\n i:=0;while k>0 do begin inc(i);aa[i]:=k mod 10;k:=k div 10; end;\n n1:=i;\n\n k:=l;\n i:=0;while k>0 do begin inc(i);bb[i]:=k mod 10;k:=k div 10; end;\n n2:=i;\n\nif n1>n2 then\n begin if aa[n1]>=5 then begin cc[n1]:=5;for i:=1 to n1-1 do cc[i]:=0; end\n else for i:=1 to n1 do cc[i]:=aa[i];\n\n { for i:=1 to n1 do write(cc[i],' '); writeln; }\n s:=0; p:=1;\n for j:=1 to n1 do begin s:=s+cc[j]*p;p:=p*10;end; ot:=s; goto 1;\n end;\n\n\nif n1=n2 then\n begin p:=5;for i:=1 to n1-1 do p:=p*10;\n { writeln(p); }\n if (l<=p)and(p<=r) then begin ot:=p; goto 1; end;\n if l>=p then begin ot:=l; goto 1; end;\n if r<=p then begin ot:=r; goto 1; end;\n end;\n1:{ writeln (ot); }\n pp:=ot; pp1:=otr(ot);\n writeln(pp*pp1);\n\n\n end."}, {"source_code": "Uses Math;\nvar\n i : longint;\n l, r, ans : int64;\n\nfunction pow(b : longint) : longint;\nvar\n res, j : longint;\nbegin\n res := 1;\n for j := 1 to b do res := res * 10;\n pow := res;\nend;\nfunction go(x : int64) : int64;\nvar\n y, p : int64;\nbegin\n y := 0; p := 1;\n while (x > 0) do begin\n y := y + (9-(x mod 10))*p;\n x := x div 10;\n p := p * 10;\n end;\n go := y;\nend;\nbegin\n// reset(input, 'a.in'); rewrite(output, 'a.out');\n read(l, r);\n ans := go(l)*l;\n ans := max(ans, go(r)*r);\n for i := 0 to 9 do\n if (l < 5*pow(i)-1) and (5*pow(i)-1 < r) then\n ans := max(ans, go(5*pow(i)-1)*(5*pow(i)-1));\n write(ans);\nend."}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n i:longint;\n l,r,ans,cur,z1,z2:int64;\n s:array[1..9] of int64;\n\n function f(n:int64):int64;\n var k,res:int64;\n begin\n k:=1;\n res:=0;\n while n > 0 do\n begin\n inc(res,k*(9-n mod 10));\n n:=n div 10;\n k:=k*10;\n end;\n f:=res;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(l,r);\n s[1]:=10;\n for i:=2 to 9 do s[i]:=10*s[i-1];\n ans:=l*f(l);\n cur:=r*f(r);\n if cur > ans then ans:=cur;\n for i:=1 to 9 do\n begin\n z1:=s[i] div 2;\n z2:=z1-1;\n if (z1 >= l) and (z1 <= r) then\n begin\n cur:=z1*f(z1);\n if cur > ans then ans:=cur;\n end;\n if (z2 >= l) and (z2 <= r) then\n begin\n cur:=z2*f(z2);\n if cur > ans then ans:=cur;\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program cf86a;\nvar\n l,r:longint;\n o:int64;\n ans:int64;\nbegin\n readln(l,r);\n o:=1;\n while o<=r do o:=o*10;\n dec(o);\n\n if (l<=o shr 1)and(r>=o shr 1) then ans:=o shr 1\n else\n if (r-o shr 1)<(o shr 1-l) then ans:=r\n else ans:=l;\n ans:=ans*(o-ans);\n\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\nvar l,r:int64;\n\nfunction trongso(x:int64):int64;\nvar s:ansistring;\nk:int64;\ni:longint;\nbegin\nstr(x,s);\nk:=0;\nfor i:=1 to length(s) do k:=k*10+9;\nexit((k-x)*x);\nend;\n\nfunction xuli:int64;\nvar k:int64;\ns:ansistring;\ni:longint;\nbegin\nstr(r,s);\nk:=4;\nfor i:=1 to length(s)-1 do k:=k*10+9;\nif (k<=r)and(k>=l) then exit(trongso(k)) else exit(0);\nend;\n\n\nbegin\n//assign(input,'cc.inp');reset(input);\n//assign(output,'cc.out');rewrite(output);\nread(l,r);\nwriteln(max(max(trongso(l),trongso(r)),xuli))\nend.\n"}, {"source_code": "type\n Integer = LongInt;\n LongInt = Int64;\n\nvar\n l, r: LongInt;\n c1, c2: Integer;\n res: Int64;\n \n \nfunction digit_cnt(a: LongInt): Integer;\nvar\n res: Integer;\nbegin \n res := 0;\n while a > 0 do\n begin\n Inc(res);\n a := a div 10;\n end;\n digit_cnt := res;\nend;\n\nfunction pow10(c: Integer): LongInt;\nvar\n res: LongInt;\n i: Integer;\nbegin\n res := 1;\n for i := 1 to c do res := res*10;\n pow10 := res;\nend;\n\nfunction wigth(n: LongInt): Int64;\nvar\n n1, tmp: LongInt;\n a: Integer;\n p10: LongInt;\nbegin\n tmp := n; p10 := 1;\n n1 := 0;\n while tmp > 0 do\n begin\n a := 9 - (tmp mod 10); tmp := tmp div 10;\n n1 := p10*a+n1;\n p10 := p10*10;\n end;\n wigth := Int64(n1)*Int64(n);\nend;\n\nfunction min(a, b: Int64): Int64;\nbegin\n if a > b then min := a else min := b;\nend;\n \nbegin\n ReadLn(l, r);\n c1 := digit_cnt(l); c2 := digit_cnt(r);\n c1 := c1-1; c2 := c2-1;\n if c1 < c2 then l := pow10(c2);\n //WriteLn(l, ' ', r, ' ', pow10(c2)*5);\n res := min(wigth(r), wigth(l));\n if (pow10(c2)*5 > l) and (pow10(c2)*5 < r) then res := min(res, wigth(pow10(c2)*5));\n WriteLn(res);\nend.\n"}, {"source_code": "uses math;\n\nvar q,r,g,n,m,ans: int64;\n\nbegin\n read(n,m);\n q:=trunc(logn(10,m))+1;\n r:=trunc(power(10,q))-1;\n g:=r div 2;\n if ((g<=m) and (g>=n)) then ans:=g*(r-g) else begin\n if (g>m) then ans:=m*(r-m)\n else ans:=n*(r-n);\n end;\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar\n l,r,i: longint;\n a: array[0..11] of int64;\n s,kq: int64;\nbegin\n a[0]:=1;\n for i:=1 to 10 do\n a[i]:=a[i-1]*10;\n\n kq:=0;\n readln(l,r);\n for i:=0 to 8 do\n begin\n s:=max(l,min(r,(a[i+1]-1) div 2));\n if (a[i]<=s) and (s=q) then writeln(l*(p-l)) else writeln(q*(p-q));\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n l,r:longint;\n rr,ans,st,c,y,xx,q,max,x:int64;\nfunction f(x:int64):int64;\nbegin\n st:=1;\n xx:=x;\n y:=0;\n while (xx>0) do\n begin\n inc(y,(9-xx mod 10)*st);\n xx:=xx div 10;\n st:=st*10;\n end;\n f:=x*y;\nend;\nbegin\n readln(l,r);\n st:=1;\n rr:=r;\n while rr>0 do\n begin\n rr:=rr div 10;\n st:=st*10;\n end;\n st:=st div 10;\n c:=st*5;\n if c>r then ans:=r;\n if c=l)and(c<=r) then ans:=c;\n writeln(f(ans));\nend.\n"}, {"source_code": "var n,m,i,j,k,step,t,lik,max,t1,t2,t3:int64;\n\n\nfunction p(lik:int64):int64;\nvar lik2:int64;\nerror:longint;\n st:string;\n i:longint;\nbegin\n str(lik,st);\n for i:= 1 to length(st) do\n st[i]:=chr(ord('9')-ord(st[i])+48);\n val(st,lik2,error);\n p:=lik2;\n\nend;\n\n\n\n\nbegin\n readln(n,m);\n t1:=p(n)*n;\n t2:=p(m)*m;\n if t1max) and (lik>=n) then max:=t3;\n lik:=lik*10;\n end;\n writeln(max);\nend.\n"}], "negative_code": [{"source_code": "var i,temp:longint;\n ot,max,mi,l,r,a:int64;\n s,s2:string;\nbegin\n readln(l,r);\n str(r,s);\n s2:='4';\n while length(s)>length(s2)do s2:=s2+'9';\n val(s2,a,temp);\n if (a>l)and(ar then write(r)\n else write(l);\nend.\n"}, {"source_code": "program aaa;\n var a,b,i,m,n,k,l,t:int64;j:longint;{s:string;a:array[0..10]of string;\n w:string;{\n label 1; } q:char; f:boolean;\nfunction aa(q:char):longint;\nbegin\n if pos(q,'aeiouAEIOU')>0 then aa:=1 else aa:=0;\nend;\nbegin\n\n{ assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output); }\n readln(a,b);\n m:=1; while m<=a do m:=m*10;m:=m-1;\n n:=1;while n<=b do n:=n*10;n:=n-1;\n if m=n then\n begin\n k:=m div 2;\n if (a<=k)and(b>=k) then write(k*(m-k)) else\n begin\n if a>k then write(a*(m-k)) else write(b*(m-b));\n end;\n end else\n begin\n k:=m div 2;\n if kb then write(a) else write(b);\n end;\n\n\nend."}, {"source_code": "Uses Math;\nvar\n i : longint;\n l, r, ans : int64;\n\nfunction pow(b : longint) : longint;\nvar\n res, j : longint;\nbegin\n res := 1;\n for j := 1 to b do res := res * 10;\n pow := res;\nend;\nfunction go(x : int64) : int64;\nvar\n y : int64;\nbegin\n y := 0;\n while (x > 0) do begin\n y := y * 10 + 9-(x mod 10);\n x := x div 10;\n end;\n go := y;\nend;\nbegin\n// reset(input, 'a.in'); rewrite(output, 'a.out');\n read(l, r);\n ans := go(l)*l;\n ans := max(ans, go(r)*r);\n for i := 0 to 9 do\n if (l < 5*pow(i)-1) and (5*pow(i)-1 < r) then\n ans := max(ans, go(5*pow(i)-1)*(5*pow(i)-1));\n write(ans);\nend."}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{MODE DELPHI}\n{$MAXSTACKSIZE 1000000000}\n{O-,R+,Q+}\n{$O+,R-,Q-}\n\nuses\n SysUtils,\n Math;\n\nvar\n l, r, cur, pow, ans, res : int64;\n\nfunction f(a : int64) : int64;\nvar b, c : int64;\nbegin\n b := 0;\n c := a;\n while c > 0 do begin\n b := b * 10 + 9 - (c mod 10);\n c := c div 10;\n end;\n result := a * b;\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n read(l, r);\n ans := max(f(l), f(r));\n pow := 1;\n cur := 1;\n while true do begin\n if pow > r then\n break;\n res := pow * 5;\n if (res >= l) and (res <= r) then\n ans := max(ans, f(res));\n pow := pow * 10;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "Const z:array [1..1000] of int64=(\n9223348945305012054,9223371177446620838,9223289392186603218,9223356676663288898,9223362017525141912,9223353249085783720,9223370859080609384,9223370520778019904,9223371677885927502,9223364969658639048,9223371197928966836,9223363346452668818,9223349605836758870,9223338621672442788,9223369742570850188,9223335216323481590,9223365470781060224,9223369298958881048,9223351266283779782,9223371188792683034,9223340560252696690,9223365669544051874,9223369691739892484,9223357288089436160,9223365155254811464,9223357518829870478,9223311574178380470,9223363345599063828,9223365687238257148,9223370181093756168,9223342468898255886,9223356858785838628,9223352949305651834,9223358518723313670,9223371632414405174,9223369759433776640,9223365782797218252,9223362878872511616,9223331538065692640,9223357933853162842,9223371046914101158,9223336224444390318,9223335035942615288,9223367310818873058,9223369064494947722,9223365178505448742,9223356724932549136,9223366101979672064,9223360693702384472,9223369775703053294,9223367656527135214,\n9223368839832657698,9223366548490375296,9223349648357647562,9223350694030433010,9223371638941059496,9223344970477954190,9223371204592455616,9223371765457785588,9223352191843497462,9223323805718507190,9223368372599103106,9223342390467786854,9223359625264544270,9223346006089373314,9223359263881260032,9223370040657852024,9223320874814669422,9223351619187359022,9223365639317344454,9223348391284097418,9223363890926134490,9223371722306381554,9223345997820532148,9223365900518639258,9223364990476317812,9223356025479843594,9223351634759679252,9223364469002302254,9223363704325659876,9223347838148960364,9223361008054590368,9223371836834359176,9223320718076154758,9223345569740623806,9223362748438346466,9223312588063800962,9223362326304196584,9223369168275811230,9223354955328357262,9223333723077554314,9223356090537199426,9223321738582665658,9223370687775980234,9223364759158825236,9223280269179356488,9223354408101188262,9223371849680582296,9223369120566119316,9223309945396991288,9223359410568675384,9223370879452696368,\n9223358124211983322,9223371448768780294,9223370345286027976,9223345344108213398,9223334581533424472,9223361400093456468,9223355034899749632,9223368171301074584,9223331182644983688,9223363833952823790,9223348654834420762,9223321337036051524,9223370211959319534,9223367135312935916,9223346335225543002,9223334412671778048,9223335906269721764,9223346580505238866,9223357668285217306,9223366615971850216,9223342938536132100,9223300854808621298,9223333278694960658,9223312671604549620,9223339711101008630,9223334811967273740,9223358754319270620,9223364269808265446,9223368197897778236,9223352199916260246,9223369202524877588,9223347127886629616,9223365727155621594,9223371131583176312,9223361874770356642,9223370239469214524,9223343044553950334,9223331789051264938,9223370120970984308,9223371582741513314,9223361408871571412,9223339940950759424,9223343941351392372,9223353479175365184,9223351259597153694,9223363867123893742,9223354429299946092,9223365092742086572,9223347661162512384,9223369702193628390,9223362907953113316,\n9223362297501658640,9223356395984362058,9223359575427845448,9223360994909868060,9223361798674845980,9223371781778421692,9223362252736965236,9223343669342874728,9223371212196144442,9223291530608990664,9223312693489253324,9223366917810338356,9223342595539973376,9223368409393195478,9223358392003813804,9223369588183342854,9223340475704928510,9223353168557287168,9223309515391183848,9223368466284852284,9223365625066478498,9223366063515462524,9223366085582549040,9223331551581498556,9223321307667943936,9223364597164826412,9223328375065861310,9223349010249772032,9223354179361026766,9223365203964097144,9223370414944235252,9223342519858746056,9223338157467383252,9223335597749794062,9223368453924874240,9223366976907654594,9223363303595443590,9223364312377590668,9223340929659712548,9223370429901635386,9223359694131643072,9223370178511110278,9223330634961212152,9223362438982260890,9223354885031519984,9223370147362927360,9223363798836094448,9223353201130892318,9223332910671923746,9223371975806828386,9223368027629711732,\n9223360946440570712,9223365676133244420,9223343794781589760,9223345022496939576,9223339218422527234,9223356369444996310,9223356429397753856,9223319319180699392,9223364609179512898,9223346320969266268,9223362349166724974,9223353345337170708,9223325207154537832,9223370626251059876,9223367248095485714,9223325074566658844,9223358569754437538,9223338372236396730,9223348214140656128,9223345286066123246,9223328791685046526,9223352277940221576,9223361414925509990,9223354625297231144,9223367648638490516,9223358161796161670,9223366531232043828,9223359250802489002,9223336884555768210,9223361540271161856,9223348257810232102,9223362106799237626,9223311133587372616,9223366618427977758,9223360218913549566,9223337344672488244,9223343317872069848,9223367423023612368,9223354586916422562,9223368813740148492,9223349526101809868,9223353480046041496,9223366815568578344,9223371040278583478,9223361136281124530,9223258736018892060,9223345141016398298,9223349944997934604,9223369000201980772,9223371424074042182,9223371261028522670,\n9223351841714572440,9223366482353695832,9223362598092610816,9223362396556458628,9223325909732367710,9223326644404996642,9223371595653651402,9223325786261002240,9223360246265895134,9223364486992407974,9223369905606299470,9223333054137432040,9223365201324334854,9223370661484247626,9223358778540792522,9223359619510823992,9223359535470837504,9223344283503091762,9223370460329680528,9223370948575944940,9223365883152695052,9223363193981968180,9223350487623285408,9223355865799845728,9223351517179463304,9223359911437504062,9223362943058280156,9223364720199089902,9223353153168369098,9223348064600148194,9223365032840253948,9223371829626930076,9223327777661787648,9223371129185454572,9223355472457501556,9223369541611204338,9223367852004705416,9223356647580048484,9223371743491507560,9223360704415876952,9223336503012461504,9223358077275845002,9223340727772260918,9223366995522449018,9223357097636866298,9223348904035867674,9223360196114597668,9223345206947428724,9223354471865260156,9223318740130514026,9223335053035081284,\n9223367507122597020,9223354672377730816,9223357637885265898,9223361005393912922,9223350050942290688,9223263424134397880,9223369003000713404,9223370620076263386,9223339166792065632,9223369955974461896,9223371487490044810,9223350818200954986,9223367934428425472,9223358944536810068,9223366280984822272,9223353544240343238,9223364411872496444,9223311164708443582,9223348040776479464,9223368593969985006,9223367216348561490,9223370010076081172,9223371992015289086,9223364861160994816,9223357681886864422,9223348881983854054,9223327007546663858,9223365973212212148,9223370866180409946,9223353502811088732,9223362390842344916,9223368401956440286,9223353628184784164,9223365417335145486,9223342073266529832,9223356616422094848,9223369230214368856,9223365142288649628,9223359418761740288,9223352414783371558,9223365376542017656,9223358921655754040,9223366783991789768,9223366650458956152,9223358601240747720,9223346743698900982,9223314048803536344,9223309362687405056,9223337110797171722,9223364897741991834,9223355575060561920,\n9223332021094938680,9223349889026310134,9223327806359384160,9223357329607845574,9223360158191288320,9223368389552287540,9223222685312184326,9223363447999746652,9223361955910120898,9223359662639271382,9223368770923060426,9223371693576010928,9223353664692766168,9223330321704885350,9223305563704592258,9223355680634012532,9223357872591620362,9223304296199127834,9223361603530673912,9223338892720726336,9223353631839103632,9223364176409358832,9223371676171856128,9223368144709164870,9223367809470210786,9223368392642489544,9223368800931635868,9223361985375397982,9223361439181462680,9223329161005309634,9223364794279142116,9223364918696133246,9223370158177108736,9223358107923508834,9223343264691918078,9223365328633453794,9223345340000901510,9223362974848919096,9223350524425700568,9223352088414611836,9223311001212017180,9223350598484145564,9223355349656604160,9223333646617215366,9223364487406242950,9223368476953848892,9223351796924487964,9223307357122429098,9223364189590186788,9223347904124858112,9223366808854952658,\n9223356238887393456,9223325810243960816,9223345199434134764,9223342373858759334,9223313619492821676,9223363402977068684,9223363976407856476,9223369541671859454,9223368775268600460,9223345992344657470,9223355297906019328,9223369216609746944,9223354751462744772,9223367519943586882,9223310023514245736,9223357681816802070,9223363971368182230,9223349089468448974,9223365323515281134,9223343028594700564,9223355972675400584,9223352292954924646,9223365526288016694,9223353264948577576,9223355443972493608,9223351440955901184,9223366018944753316,9223365463951958280,9223365407299168904,9223332041772917276,9223367443375395822,9223359952208148146,9223364963711088838,9223295585717654950,9223327132498489576,9223368462237180160,9223354133319564996,9223337109624399526,9223344551752758124,9223337049345339538,9223323502295900570,9223352830019048180,9223363381495988736,9223370351926793840,9223361593881634410,9223364395732719694,9223319503624083752,9223357864935152602,9223367041197474710,9223369501404469972,9223362519308755578,\n9223361961192464776,9223368739022070272,9223362340832002412,9223320622128536406,9223363796165637058,9223261618645041832,9223304287687397496,9223357173955415356,9223360453399896692,9223367674168787544,9223364517594605948,9223338308036521036,9223370909928914226,9223368626349621552,9223367496654196034,9223371812795182978,9223370903641790464,9223360208400696988,9223364929455892878,9223367536494878988,9223317989429795150,9223369337157228398,9223348491153782456,9223369002248382686,9223348029323665822,9223363113500462290,9223352335101450106,9223363087852426564,9223357196117260368,9223325444848613038,9223364014872637624,9223336454939603822,9223348528099112960,9223356496897668878,9223359692042218186,9223355388046326410,9223342911974034992,9223352324177402312,9223366941305511896,9223339605973707652,9223358808639871462,9223355588883774050,9223359561035314296,9223368148464707790,9223339420520528684,9223334063760139940,9223366301609485742,9223355872313930296,9223352727774376364,9223347502329666048,9223367706664226168,\n9223364372886976308,9223368992083204922,9223360757036828282,9223350740291696896,9223364847503687244,9223368262612798058,9223344404103464724,9223362608484053486,9223365175585873000,9223334269338560194,9223360100472338432,9223367418541224440,9223361175218559744,9223339442028900670,9223366100590932166,9223370149215331662,9223348448927421598,9223362980307618436,9223369626554836278,9223361719731949332,9223341465390518094,9223370164656679612,9223370981383894676,9223354314239606094,9223364694394744064,9223366703010315008,9223369357782223596,9223347828729928036,9223318288302312448,9223371143830289896,9223368116258464788,9223358181918213458,9223368055832614184,9223357784639800214,9223343367803465732,9223366691259642060,9223358143696599874,9223364527067097110,9223363530953482434,9223316859116802222,9223370434931960886,9223333388193127714,9223359903229747048,9223339268151665876,9223368946513551306,9223353855603981612,9223357367436574168,9223363424538002116,9223364394346382070,9223363358320507890,9223345472757152260,\n9223367885053676214,9223342599529286330,9223366137421666250,9223363881562482040,9223370508056237000,9223364495276658060,9223370704099600640,9223329749626382478,9223336183210402122,9223337655390948270,9223341904096524554,9223361200399293234,9223362616762068628,9223371391788189606,9223369052708788180,9223367182872915272,9223348500321906030,9223362858611987110,9223365542700954532,9223371228288383488,9223371824205980956,9223355076963323602,9223370946892616332,9223352621058145896,9223322493343938660,9223362529345129000,9223357371863191406,9223357025074924548,9223350190956749026,9223364298661202722,9223340976426424598,9223328509679889672,9223365463869405774,9223353389285703936,9223367199267602642,9223356409935355972,9223364236428951068,9223363486723620284,9223354912899322972,9223369346281938970,9223365520884745676,9223351674067896766,9223368170511616166,9223358748308535808,9223334375870766158,9223358133615886980,9223340256526566362,9223348501818078060,9223358451277215030,9223344750650875500,9223364181577796570,\n9223360419333321910,9223353451782499624,9223315320894818816,9223371997826254880,9223304901341539350,9223351366555730440,9223370213858837330,9223369917680156928,9223370853310649122,9223300910883917294,9223361550337624648,9223364842554067922,9223365913641150210,9223371490327890204,9223353289384626944,9223342432685245998,9223356300862586816,9223351301499266312,9223369043261323280,9223345108673699930,9223366257304587906,9223364014531622956,9223368341941329228,9223321968217602520,9223357315074505644,9223338294943536756,9223356365734112026,9223306052155234948,9223358880094284262,9223362591115396268,9223368468394533404,9223339155443325880,9223359869069269442,9223363915518200924,9223360974159465458,9223363364095141524,9223343800263376896,9223366044582725916,9223350564422077308,9223370096507520922,9223364489449039260,9223367934204946070,9223331987817594414,9223360193616294796,9223353012414646672,9223321690802545070,9223351013173761454,9223350306211734926,9223361834727462852,9223324712387442138,9223354262741169630,\n9223369056215072402,9223371658810587268,9223362614606693496,9223368627294431076,9223371170994887932,9223368202068820108,9223368062022347228,9223350736143411638,9223353115822019208,9223353474752268930,9223368246963484274,9223367411396837668,9223361874765323010,9223364616566631424,9223362976030136152,9223363565026339890,9223364374701413632,9223361023980779400,9223357201070907656,9223369015084954712,9223360691264746938,9223357079767626496,9223371257790060564,9223360067172930304,9223345694884348264,9223353253777623814,9223370435879952158,9223357865892716288,9223326646726524928,9223307401580580564,9223338361408213232,9223352710808688402,9223361027990903516,9223363609900097168,9223362167549844052,9223289655646486198,9223371990453573304,9223365589188078362,9223362294684603530,9223353336866909384,9223371131958078616,9223348191101941322,9223350167237308602,9223356181655370920,9223369187348546304,9223324479449221272,9223368010617867508,9223365302714584618,9223370019818098114,9223350898337614676,9223307387375794794,\n9223361877127286266,9223323943599246758,9223327286877943808,9223363150628204718,9223307432851729664,9223362055294251384,9223357643872322648,9223340139484109226,9223343493251374222,9223351790714042764,9223357187285700994,9223331098480243718,9223367556783480466,9223356588405365030,9223345106418078502,9223364413016869686,9223371735935007012,9223371231090110678,9223359015039905608,9223365839876457290,9223361882143338156,9223364766507560332,9223364314514649084,9223366901107727926,9223324210878935670,9223347639256907776,9223337586550042112,9223348708659610392,9223356526834874682,9223365987706220920,9223367216064822078,9223357889989350862,9223339508239676298,9223364293753039940,9223343112244620186,9223332292000329876,9223360556337443112,9223364743940371412,9223371762773276236,9223320107573390904,9223362329323929608,9223358632922894948,9223287021161752234,9223322775950906840,9223343169620003140,9223360979513940498,9223370434355092492,9223366636721253912,9223349971825148160,9223370201136918104,9223370304827310374,\n9223338308750735684,9223324790793895424,9223359483501460572,9223365398925608066,9223342154850402306,9223364560651504448,9223340262992745166,9223349443619174856,9223331701331154340,9223367709885785338,9223342591547820544,9223359627432280348,9223363656960671744,9223308459631194368,9223365766060618962,9223367309203110472,9223348757595537040,9223332287894082088,9223340607260937932,9223367512284900686,9223358809591369720,9223347121476536540,9223371286248667788,9223369211897992654,9223368387559653596,9223361953653154048,9223370912957700650,9223370092269633536,9223270776550008706,9223357729634658336,9223370356657378778,9223369352799810236,9223356129795247670,9223348282538062124,9223354132543957248,9223329247639309086,9223353425140457854,9223317449435131352,9223309895423185458,9223371461682200984,9223356394851183060,9223364381712242834,9223343566015537698,9223364937883104000,9223366344623709696,9223338609287029144,9223366383506465480,9223305689790684992,9223358311648691834,9223364255078110550,9223367715011704986,\n9223346907282950236,9223361813709173248,9223364077310935040,9223351713170416100,9223369724166805800,9223358890490913280,9223358800145024048,9223338103655211294,9223369757827220460,9223356879883465984,9223370232760133926,9223313952741249768,9223358510977571592,9223370730415582826,9223367796218522798,9223354843709078598,9223325823815321822,9223367972268516294,9223367572184387608,9223365567914486456,9223370719841698484,9223365259736854586,9223371267668349840,9223365063506304754,9223344099204966236,9223368950258777726,9223357570567091638,9223347024534952192,9223371258495740944,9223363969721052838,9223322581180569438,9223322421052821176,9223360335751044936,9223353205406180940,9223357871958724210,9223355223618079218,9223360166163038136,9223357119776214652,9223363427708239080,9223344678001585606,9223350511627791586,9223364019059188054,9223348341394179100,9223333001669114058,9223364006595133572,9223362793183255576,9223362314818446674,9223354384986034828,9223341734305930250,9223341717654935740,9223363536638005960,\n9223346084813929144,9223364733289118664,9223357271129754630,9223369898421104538,9223367809160840488,9223349149100464418,9223369851113267976,9223364969154649274,9223336797992387064,9223304984948019332,9223348084045626916,9223365185751750518,9223361275129089618,9223342492198624350,9223371309820242944,9223328624109712024,9223368541025113136,9223357194922921232,9223367949109836664,9223366291996561152,9223349223855566844,9223364126938062050,9223369965234374570,9223369636075607096,9223359680150274048,9223333954540986722,9223371465972760786,9223346862264757248,9223351160105929608,9223370159169759674,9223353729868276118,9223355297699050498,9223350969133585678,9223350166836907258,9223340448396219136,9223363283110059844,9223350471529039490,9223364404042601984,9223305357830920280,9223358366404858376,9223347897455241802,9223371125882767912,9223369940789382016,9223349245983419438,9223336381955191896,9223364743981649370,9223332668134555014,9223370645235955032,9223363233764851046,9223319330743296376,9223327006454571170,\n9223368819903299584,9223371282918656382,9223335956455480076,9223340930717201222,9223364654809724758,9223352777831364904,9223342394861936990,9223370955301562988,9223315665310383770,9223322406859079222,9223370490060277652,9223362810425540920,9223371472608157606,9223360169329955672,9223368782965925656,9223362004864979288,9223364346718392532,9223357485769999336,9223370879464884042,9223354563701572932,9223353862634781126,9223371876625540608,9223324765904505500,9223349432408131740,9223365810017579088,9223369072583109512,9223362525163152396,9223371751686876740,9223367634654194906,9223297424955323584,9223371853147527156,9223368666776588332,9223369274584163878,9223353199213478900,9223357966454101978,9223369038871380888,9223355092264340064,9223355442994126976,9223343373394530188,9223369678633789020,9223364523594121984,9223348591665569432,9223355796726763418,9223370646550082134,9223367501448320472,9223368441461119764,9223368981478991360,9223354956176614286,9223345478717132524,9223370999606313858,9223297837476092416,\n9223369449130034270,9223321640126305244,9223276434955914996,9223348796934913656,9223353757591119798,9223363667897809084,9223351350356214904,9223362462900862788,9223318818570213594,9223366726697770784,9223344527643840846,9223364461049712324,9223362010609245846,9223343841587235328,9223365474423753996,9223367979110251388,9223331992540170802,9223363668345894656,9223368997580316652,9223360787763435776,9223359535311683328,9223358746654832052,9223370427609487360,9223357812795652162,9223359433335640210,9223355192663360732,9223359865364566458,9223341881314386654,9223298104810101932,9223368519071966930,9223368872939158608\n);\nVar zz,zz1,kol,i,l,r:LongInt;\ne,j,i1,maxi:int64;\n//z:array [1..1000] of int64;\nm:array [1..100] of longint;\nb:Boolean;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(l,r);\n b:=false;\n maxi:=0;\n for i:=l to r do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n begin\n i1:=(i1*e)+(9-m[zz]);\n e:=e*10;\n end;\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n \n if i mod 1000000=0\n then begin b:=True; zz:=i; break; end;//z[i div 1000000]:=maxi; maxi:=0; end;\n end;\n zz1:=zz;\n for i:=r downto l do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n begin\n i1:=(i1*e)+(9-m[zz]);\n e:=e*10;\n end;\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n \n if i mod 10000000=0\n then begin zz:=zz1; zz1:=i; break; end;\n end;\nif b\nthen begin\n zz:=zz div 10000000+1;\n zz1:=zz1 div 10000000;\n for i:=zz to zz1 do\n if z[i]>maxi\n then maxi:=z[i];\n end;\n{ for i:=1 to 999 do\n write(z[i],',');\n write(z[1000]);}\n Writeln(maxi);\nend."}, {"source_code": "Const z:array [1..1000] of int64=(\n9223348945305012054,9223371177446620838,9223289392186603218,9223356676663288898,9223362017525141912,9223353249085783720,9223370859080609384,9223370520778019904,9223371677885927502,9223364969658639048,9223371197928966836,9223363346452668818,9223349605836758870,9223338621672442788,9223369742570850188,9223335216323481590,9223365470781060224,9223369298958881048,9223351266283779782,9223371188792683034,9223340560252696690,9223365669544051874,9223369691739892484,9223357288089436160,9223365155254811464,9223357518829870478,9223311574178380470,9223363345599063828,9223365687238257148,9223370181093756168,9223342468898255886,9223356858785838628,9223352949305651834,9223358518723313670,9223371632414405174,9223369759433776640,9223365782797218252,9223362878872511616,9223331538065692640,9223357933853162842,9223371046914101158,9223336224444390318,9223335035942615288,9223367310818873058,9223369064494947722,9223365178505448742,9223356724932549136,9223366101979672064,9223360693702384472,9223369775703053294,9223367656527135214,\n9223368839832657698,9223366548490375296,9223349648357647562,9223350694030433010,9223371638941059496,9223344970477954190,9223371204592455616,9223371765457785588,9223352191843497462,9223323805718507190,9223368372599103106,9223342390467786854,9223359625264544270,9223346006089373314,9223359263881260032,9223370040657852024,9223320874814669422,9223351619187359022,9223365639317344454,9223348391284097418,9223363890926134490,9223371722306381554,9223345997820532148,9223365900518639258,9223364990476317812,9223356025479843594,9223351634759679252,9223364469002302254,9223363704325659876,9223347838148960364,9223361008054590368,9223371836834359176,9223320718076154758,9223345569740623806,9223362748438346466,9223312588063800962,9223362326304196584,9223369168275811230,9223354955328357262,9223333723077554314,9223356090537199426,9223321738582665658,9223370687775980234,9223364759158825236,9223280269179356488,9223354408101188262,9223371849680582296,9223369120566119316,9223309945396991288,9223359410568675384,9223370879452696368,\n9223358124211983322,9223371448768780294,9223370345286027976,9223345344108213398,9223334581533424472,9223361400093456468,9223355034899749632,9223368171301074584,9223331182644983688,9223363833952823790,9223348654834420762,9223321337036051524,9223370211959319534,9223367135312935916,9223346335225543002,9223334412671778048,9223335906269721764,9223346580505238866,9223357668285217306,9223366615971850216,9223342938536132100,9223300854808621298,9223333278694960658,9223312671604549620,9223339711101008630,9223334811967273740,9223358754319270620,9223364269808265446,9223368197897778236,9223352199916260246,9223369202524877588,9223347127886629616,9223365727155621594,9223371131583176312,9223361874770356642,9223370239469214524,9223343044553950334,9223331789051264938,9223370120970984308,9223371582741513314,9223361408871571412,9223339940950759424,9223343941351392372,9223353479175365184,9223351259597153694,9223363867123893742,9223354429299946092,9223365092742086572,9223347661162512384,9223369702193628390,9223362907953113316,\n9223362297501658640,9223356395984362058,9223359575427845448,9223360994909868060,9223361798674845980,9223371781778421692,9223362252736965236,9223343669342874728,9223371212196144442,9223291530608990664,9223312693489253324,9223366917810338356,9223342595539973376,9223368409393195478,9223358392003813804,9223369588183342854,9223340475704928510,9223353168557287168,9223309515391183848,9223368466284852284,9223365625066478498,9223366063515462524,9223366085582549040,9223331551581498556,9223321307667943936,9223364597164826412,9223328375065861310,9223349010249772032,9223354179361026766,9223365203964097144,9223370414944235252,9223342519858746056,9223338157467383252,9223335597749794062,9223368453924874240,9223366976907654594,9223363303595443590,9223364312377590668,9223340929659712548,9223370429901635386,9223359694131643072,9223370178511110278,9223330634961212152,9223362438982260890,9223354885031519984,9223370147362927360,9223363798836094448,9223353201130892318,9223332910671923746,9223371975806828386,9223368027629711732,\n9223360946440570712,9223365676133244420,9223343794781589760,9223345022496939576,9223339218422527234,9223356369444996310,9223356429397753856,9223319319180699392,9223364609179512898,9223346320969266268,9223362349166724974,9223353345337170708,9223325207154537832,9223370626251059876,9223367248095485714,9223325074566658844,9223358569754437538,9223338372236396730,9223348214140656128,9223345286066123246,9223328791685046526,9223352277940221576,9223361414925509990,9223354625297231144,9223367648638490516,9223358161796161670,9223366531232043828,9223359250802489002,9223336884555768210,9223361540271161856,9223348257810232102,9223362106799237626,9223311133587372616,9223366618427977758,9223360218913549566,9223337344672488244,9223343317872069848,9223367423023612368,9223354586916422562,9223368813740148492,9223349526101809868,9223353480046041496,9223366815568578344,9223371040278583478,9223361136281124530,9223258736018892060,9223345141016398298,9223349944997934604,9223369000201980772,9223371424074042182,9223371261028522670,\n9223351841714572440,9223366482353695832,9223362598092610816,9223362396556458628,9223325909732367710,9223326644404996642,9223371595653651402,9223325786261002240,9223360246265895134,9223364486992407974,9223369905606299470,9223333054137432040,9223365201324334854,9223370661484247626,9223358778540792522,9223359619510823992,9223359535470837504,9223344283503091762,9223370460329680528,9223370948575944940,9223365883152695052,9223363193981968180,9223350487623285408,9223355865799845728,9223351517179463304,9223359911437504062,9223362943058280156,9223364720199089902,9223353153168369098,9223348064600148194,9223365032840253948,9223371829626930076,9223327777661787648,9223371129185454572,9223355472457501556,9223369541611204338,9223367852004705416,9223356647580048484,9223371743491507560,9223360704415876952,9223336503012461504,9223358077275845002,9223340727772260918,9223366995522449018,9223357097636866298,9223348904035867674,9223360196114597668,9223345206947428724,9223354471865260156,9223318740130514026,9223335053035081284,\n9223367507122597020,9223354672377730816,9223357637885265898,9223361005393912922,9223350050942290688,9223263424134397880,9223369003000713404,9223370620076263386,9223339166792065632,9223369955974461896,9223371487490044810,9223350818200954986,9223367934428425472,9223358944536810068,9223366280984822272,9223353544240343238,9223364411872496444,9223311164708443582,9223348040776479464,9223368593969985006,9223367216348561490,9223370010076081172,9223371992015289086,9223364861160994816,9223357681886864422,9223348881983854054,9223327007546663858,9223365973212212148,9223370866180409946,9223353502811088732,9223362390842344916,9223368401956440286,9223353628184784164,9223365417335145486,9223342073266529832,9223356616422094848,9223369230214368856,9223365142288649628,9223359418761740288,9223352414783371558,9223365376542017656,9223358921655754040,9223366783991789768,9223366650458956152,9223358601240747720,9223346743698900982,9223314048803536344,9223309362687405056,9223337110797171722,9223364897741991834,9223355575060561920,\n9223332021094938680,9223349889026310134,9223327806359384160,9223357329607845574,9223360158191288320,9223368389552287540,9223222685312184326,9223363447999746652,9223361955910120898,9223359662639271382,9223368770923060426,9223371693576010928,9223353664692766168,9223330321704885350,9223305563704592258,9223355680634012532,9223357872591620362,9223304296199127834,9223361603530673912,9223338892720726336,9223353631839103632,9223364176409358832,9223371676171856128,9223368144709164870,9223367809470210786,9223368392642489544,9223368800931635868,9223361985375397982,9223361439181462680,9223329161005309634,9223364794279142116,9223364918696133246,9223370158177108736,9223358107923508834,9223343264691918078,9223365328633453794,9223345340000901510,9223362974848919096,9223350524425700568,9223352088414611836,9223311001212017180,9223350598484145564,9223355349656604160,9223333646617215366,9223364487406242950,9223368476953848892,9223351796924487964,9223307357122429098,9223364189590186788,9223347904124858112,9223366808854952658,\n9223356238887393456,9223325810243960816,9223345199434134764,9223342373858759334,9223313619492821676,9223363402977068684,9223363976407856476,9223369541671859454,9223368775268600460,9223345992344657470,9223355297906019328,9223369216609746944,9223354751462744772,9223367519943586882,9223310023514245736,9223357681816802070,9223363971368182230,9223349089468448974,9223365323515281134,9223343028594700564,9223355972675400584,9223352292954924646,9223365526288016694,9223353264948577576,9223355443972493608,9223351440955901184,9223366018944753316,9223365463951958280,9223365407299168904,9223332041772917276,9223367443375395822,9223359952208148146,9223364963711088838,9223295585717654950,9223327132498489576,9223368462237180160,9223354133319564996,9223337109624399526,9223344551752758124,9223337049345339538,9223323502295900570,9223352830019048180,9223363381495988736,9223370351926793840,9223361593881634410,9223364395732719694,9223319503624083752,9223357864935152602,9223367041197474710,9223369501404469972,9223362519308755578,\n9223361961192464776,9223368739022070272,9223362340832002412,9223320622128536406,9223363796165637058,9223261618645041832,9223304287687397496,9223357173955415356,9223360453399896692,9223367674168787544,9223364517594605948,9223338308036521036,9223370909928914226,9223368626349621552,9223367496654196034,9223371812795182978,9223370903641790464,9223360208400696988,9223364929455892878,9223367536494878988,9223317989429795150,9223369337157228398,9223348491153782456,9223369002248382686,9223348029323665822,9223363113500462290,9223352335101450106,9223363087852426564,9223357196117260368,9223325444848613038,9223364014872637624,9223336454939603822,9223348528099112960,9223356496897668878,9223359692042218186,9223355388046326410,9223342911974034992,9223352324177402312,9223366941305511896,9223339605973707652,9223358808639871462,9223355588883774050,9223359561035314296,9223368148464707790,9223339420520528684,9223334063760139940,9223366301609485742,9223355872313930296,9223352727774376364,9223347502329666048,9223367706664226168,\n9223364372886976308,9223368992083204922,9223360757036828282,9223350740291696896,9223364847503687244,9223368262612798058,9223344404103464724,9223362608484053486,9223365175585873000,9223334269338560194,9223360100472338432,9223367418541224440,9223361175218559744,9223339442028900670,9223366100590932166,9223370149215331662,9223348448927421598,9223362980307618436,9223369626554836278,9223361719731949332,9223341465390518094,9223370164656679612,9223370981383894676,9223354314239606094,9223364694394744064,9223366703010315008,9223369357782223596,9223347828729928036,9223318288302312448,9223371143830289896,9223368116258464788,9223358181918213458,9223368055832614184,9223357784639800214,9223343367803465732,9223366691259642060,9223358143696599874,9223364527067097110,9223363530953482434,9223316859116802222,9223370434931960886,9223333388193127714,9223359903229747048,9223339268151665876,9223368946513551306,9223353855603981612,9223357367436574168,9223363424538002116,9223364394346382070,9223363358320507890,9223345472757152260,\n9223367885053676214,9223342599529286330,9223366137421666250,9223363881562482040,9223370508056237000,9223364495276658060,9223370704099600640,9223329749626382478,9223336183210402122,9223337655390948270,9223341904096524554,9223361200399293234,9223362616762068628,9223371391788189606,9223369052708788180,9223367182872915272,9223348500321906030,9223362858611987110,9223365542700954532,9223371228288383488,9223371824205980956,9223355076963323602,9223370946892616332,9223352621058145896,9223322493343938660,9223362529345129000,9223357371863191406,9223357025074924548,9223350190956749026,9223364298661202722,9223340976426424598,9223328509679889672,9223365463869405774,9223353389285703936,9223367199267602642,9223356409935355972,9223364236428951068,9223363486723620284,9223354912899322972,9223369346281938970,9223365520884745676,9223351674067896766,9223368170511616166,9223358748308535808,9223334375870766158,9223358133615886980,9223340256526566362,9223348501818078060,9223358451277215030,9223344750650875500,9223364181577796570,\n9223360419333321910,9223353451782499624,9223315320894818816,9223371997826254880,9223304901341539350,9223351366555730440,9223370213858837330,9223369917680156928,9223370853310649122,9223300910883917294,9223361550337624648,9223364842554067922,9223365913641150210,9223371490327890204,9223353289384626944,9223342432685245998,9223356300862586816,9223351301499266312,9223369043261323280,9223345108673699930,9223366257304587906,9223364014531622956,9223368341941329228,9223321968217602520,9223357315074505644,9223338294943536756,9223356365734112026,9223306052155234948,9223358880094284262,9223362591115396268,9223368468394533404,9223339155443325880,9223359869069269442,9223363915518200924,9223360974159465458,9223363364095141524,9223343800263376896,9223366044582725916,9223350564422077308,9223370096507520922,9223364489449039260,9223367934204946070,9223331987817594414,9223360193616294796,9223353012414646672,9223321690802545070,9223351013173761454,9223350306211734926,9223361834727462852,9223324712387442138,9223354262741169630,\n9223369056215072402,9223371658810587268,9223362614606693496,9223368627294431076,9223371170994887932,9223368202068820108,9223368062022347228,9223350736143411638,9223353115822019208,9223353474752268930,9223368246963484274,9223367411396837668,9223361874765323010,9223364616566631424,9223362976030136152,9223363565026339890,9223364374701413632,9223361023980779400,9223357201070907656,9223369015084954712,9223360691264746938,9223357079767626496,9223371257790060564,9223360067172930304,9223345694884348264,9223353253777623814,9223370435879952158,9223357865892716288,9223326646726524928,9223307401580580564,9223338361408213232,9223352710808688402,9223361027990903516,9223363609900097168,9223362167549844052,9223289655646486198,9223371990453573304,9223365589188078362,9223362294684603530,9223353336866909384,9223371131958078616,9223348191101941322,9223350167237308602,9223356181655370920,9223369187348546304,9223324479449221272,9223368010617867508,9223365302714584618,9223370019818098114,9223350898337614676,9223307387375794794,\n9223361877127286266,9223323943599246758,9223327286877943808,9223363150628204718,9223307432851729664,9223362055294251384,9223357643872322648,9223340139484109226,9223343493251374222,9223351790714042764,9223357187285700994,9223331098480243718,9223367556783480466,9223356588405365030,9223345106418078502,9223364413016869686,9223371735935007012,9223371231090110678,9223359015039905608,9223365839876457290,9223361882143338156,9223364766507560332,9223364314514649084,9223366901107727926,9223324210878935670,9223347639256907776,9223337586550042112,9223348708659610392,9223356526834874682,9223365987706220920,9223367216064822078,9223357889989350862,9223339508239676298,9223364293753039940,9223343112244620186,9223332292000329876,9223360556337443112,9223364743940371412,9223371762773276236,9223320107573390904,9223362329323929608,9223358632922894948,9223287021161752234,9223322775950906840,9223343169620003140,9223360979513940498,9223370434355092492,9223366636721253912,9223349971825148160,9223370201136918104,9223370304827310374,\n9223338308750735684,9223324790793895424,9223359483501460572,9223365398925608066,9223342154850402306,9223364560651504448,9223340262992745166,9223349443619174856,9223331701331154340,9223367709885785338,9223342591547820544,9223359627432280348,9223363656960671744,9223308459631194368,9223365766060618962,9223367309203110472,9223348757595537040,9223332287894082088,9223340607260937932,9223367512284900686,9223358809591369720,9223347121476536540,9223371286248667788,9223369211897992654,9223368387559653596,9223361953653154048,9223370912957700650,9223370092269633536,9223270776550008706,9223357729634658336,9223370356657378778,9223369352799810236,9223356129795247670,9223348282538062124,9223354132543957248,9223329247639309086,9223353425140457854,9223317449435131352,9223309895423185458,9223371461682200984,9223356394851183060,9223364381712242834,9223343566015537698,9223364937883104000,9223366344623709696,9223338609287029144,9223366383506465480,9223305689790684992,9223358311648691834,9223364255078110550,9223367715011704986,\n9223346907282950236,9223361813709173248,9223364077310935040,9223351713170416100,9223369724166805800,9223358890490913280,9223358800145024048,9223338103655211294,9223369757827220460,9223356879883465984,9223370232760133926,9223313952741249768,9223358510977571592,9223370730415582826,9223367796218522798,9223354843709078598,9223325823815321822,9223367972268516294,9223367572184387608,9223365567914486456,9223370719841698484,9223365259736854586,9223371267668349840,9223365063506304754,9223344099204966236,9223368950258777726,9223357570567091638,9223347024534952192,9223371258495740944,9223363969721052838,9223322581180569438,9223322421052821176,9223360335751044936,9223353205406180940,9223357871958724210,9223355223618079218,9223360166163038136,9223357119776214652,9223363427708239080,9223344678001585606,9223350511627791586,9223364019059188054,9223348341394179100,9223333001669114058,9223364006595133572,9223362793183255576,9223362314818446674,9223354384986034828,9223341734305930250,9223341717654935740,9223363536638005960,\n9223346084813929144,9223364733289118664,9223357271129754630,9223369898421104538,9223367809160840488,9223349149100464418,9223369851113267976,9223364969154649274,9223336797992387064,9223304984948019332,9223348084045626916,9223365185751750518,9223361275129089618,9223342492198624350,9223371309820242944,9223328624109712024,9223368541025113136,9223357194922921232,9223367949109836664,9223366291996561152,9223349223855566844,9223364126938062050,9223369965234374570,9223369636075607096,9223359680150274048,9223333954540986722,9223371465972760786,9223346862264757248,9223351160105929608,9223370159169759674,9223353729868276118,9223355297699050498,9223350969133585678,9223350166836907258,9223340448396219136,9223363283110059844,9223350471529039490,9223364404042601984,9223305357830920280,9223358366404858376,9223347897455241802,9223371125882767912,9223369940789382016,9223349245983419438,9223336381955191896,9223364743981649370,9223332668134555014,9223370645235955032,9223363233764851046,9223319330743296376,9223327006454571170,\n9223368819903299584,9223371282918656382,9223335956455480076,9223340930717201222,9223364654809724758,9223352777831364904,9223342394861936990,9223370955301562988,9223315665310383770,9223322406859079222,9223370490060277652,9223362810425540920,9223371472608157606,9223360169329955672,9223368782965925656,9223362004864979288,9223364346718392532,9223357485769999336,9223370879464884042,9223354563701572932,9223353862634781126,9223371876625540608,9223324765904505500,9223349432408131740,9223365810017579088,9223369072583109512,9223362525163152396,9223371751686876740,9223367634654194906,9223297424955323584,9223371853147527156,9223368666776588332,9223369274584163878,9223353199213478900,9223357966454101978,9223369038871380888,9223355092264340064,9223355442994126976,9223343373394530188,9223369678633789020,9223364523594121984,9223348591665569432,9223355796726763418,9223370646550082134,9223367501448320472,9223368441461119764,9223368981478991360,9223354956176614286,9223345478717132524,9223370999606313858,9223297837476092416,\n9223369449130034270,9223321640126305244,9223276434955914996,9223348796934913656,9223353757591119798,9223363667897809084,9223351350356214904,9223362462900862788,9223318818570213594,9223366726697770784,9223344527643840846,9223364461049712324,9223362010609245846,9223343841587235328,9223365474423753996,9223367979110251388,9223331992540170802,9223363668345894656,9223368997580316652,9223360787763435776,9223359535311683328,9223358746654832052,9223370427609487360,9223357812795652162,9223359433335640210,9223355192663360732,9223359865364566458,9223341881314386654,9223298104810101932,9223368519071966930,9223368872939158608\n);\nVar zz,zz1,kol,i,l,r:LongInt;\ne,j,i1,maxi:int64;\n//z:array [1..1000] of int64;\nm:array [1..100] of longint;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(l,r);\n maxi:=0;\n for i:=1 to 1000000000 do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n begin\n i1:=(i1*e)+(9-m[zz]);\n e:=e*10;\n end;\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n \n if i mod 1000000=0\n then begin zz:=i; break; end;//z[i div 1000000]:=maxi; maxi:=0; end;\n end;\n zz1:=zz;\n for i:=r downto l do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n begin\n i1:=(i1*e)+(9-m[zz]);\n e:=e*10;\n end;\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n \n if i mod 10000000=0\n then begin zz:=zz1; zz1:=i; break; end;\n end;\n zz:=zz div 10000000+1;\n zz1:=zz1 div 10000000;\n for i:=zz to zz1 do\n if z[i]>maxi\n then maxi:=z[i];\n{ for i:=1 to 999 do\n write(z[i],',');\n write(z[1000]);}\n Writeln(maxi);\nend."}, {"source_code": "const z:array [1..1000] of Int64=(\n8999999000000,15999998000000,20999997000000,23999996000000,24999995000000,24999994999998,23999991999998,20999988999998,15999985999998,899999990000000,978999989000000,1055999988000000,1130999987000000,1203999986000000,1274999985000000,1343999984000000,1410999983000000,1475999982000000,1538999981000000,1599999980000000,1658999979000000,1715999978000000,1770999977000000,1823999976000000,1874999975000000,1923999974000000,1970999973000000,2015999972000000,2058999971000000,2099999970000000,2138999969000000,2175999968000000,2210999967000000,2243999966000000,2274999965000000,2303999964000000,2330999963000000,2355999962000000,2378999961000000,2399999960000000,2418999959000000,2435999958000000,2450999957000000,2463999956000000,2474999955000000,2483999954000000,2490999953000000,2495999952000000,2498999951000000,2499999950000000,2499999949999998,2498999946999998,2495999943999998,2490999940999998,2483999937999998,2474999934999998,2463999931999998,2450999928999998,2435999925999998,2418999922999998,2399999919999998,\n2378999916999998,2355999913999998,2330999910999998,2303999907999998,2274999904999998,2243999901999998,2210999898999998,2175999895999998,2138999892999998,2099999889999998,2058999886999998,2015999883999998,1970999880999998,1923999877999998,1874999874999998,1823999871999998,1770999868999998,1715999865999998,1658999862999998,1599999859999998,1538999856999998,1475999853999998,1410999850999998,1343999847999998,1274999844999998,1203999841999998,1130999838999998,1055999835999998,978999832999998,899999829999998,818999826999998,735999823999998,650999820999998,563999817999998,474999814999998,383999811999998,290999808999998,195999805999998,89999999900000000,90798999899000000,91595999898000000,92390999897000000,93183999896000000,93974999895000000,94763999894000000,95550999893000000,96335999892000000,97118999891000000,97899999890000000,98678999889000000,99455999888000000,100230999887000000,101003999886000000,101774999885000000,102543999884000000,103310999883000000,104075999882000000,104838999881000000,105599999880000000,\n106358999879000000,107115999878000000,107870999877000000,108623999876000000,109374999875000000,110123999874000000,110870999873000000,111615999872000000,112358999871000000,113099999870000000,113838999869000000,114575999868000000,115310999867000000,116043999866000000,116774999865000000,117503999864000000,118230999863000000,118955999862000000,119678999861000000,120399999860000000,121118999859000000,121835999858000000,122550999857000000,123263999856000000,123974999855000000,124683999854000000,125390999853000000,126095999852000000,126798999851000000,127499999850000000,128198999849000000,128895999848000000,129590999847000000,130283999846000000,130974999845000000,131663999844000000,132350999843000000,133035999842000000,133718999841000000,134399999840000000,135078999839000000,135755999838000000,136430999837000000,137103999836000000,137774999835000000,138443999834000000,139110999833000000,139775999832000000,140438999831000000,141099999830000000,141758999829000000,142415999828000000,143070999827000000,\n143723999826000000,144374999825000000,145023999824000000,145670999823000000,146315999822000000,146958999821000000,147599999820000000,148238999819000000,148875999818000000,149510999817000000,150143999816000000,150774999815000000,151403999814000000,152030999813000000,152655999812000000,153278999811000000,153899999810000000,154518999809000000,155135999808000000,155750999807000000,156363999806000000,156974999805000000,157583999804000000,158190999803000000,158795999802000000,159398999801000000,159999999800000000,160598999799000000,161195999798000000,161790999797000000,162383999796000000,162974999795000000,163563999794000000,164150999793000000,164735999792000000,165318999791000000,165899999790000000,166478999789000000,167055999788000000,167630999787000000,168203999786000000,168774999785000000,169343999784000000,169910999783000000,170475999782000000,171038999781000000,171599999780000000,172158999779000000,172715999778000000,173270999777000000,173823999776000000,174374999775000000,174923999774000000,\n175470999773000000,176015999772000000,176558999771000000,177099999770000000,177638999769000000,178175999768000000,178710999767000000,179243999766000000,179774999765000000,180303999764000000,180830999763000000,181355999762000000,181878999761000000,182399999760000000,182918999759000000,183435999758000000,183950999757000000,184463999756000000,184974999755000000,185483999754000000,185990999753000000,186495999752000000,186998999751000000,187499999750000000,187998999749000000,188495999748000000,188990999747000000,189483999746000000,189974999745000000,190463999744000000,190950999743000000,191435999742000000,191918999741000000,192399999740000000,192878999739000000,193355999738000000,193830999737000000,194303999736000000,194774999735000000,195243999734000000,195710999733000000,196175999732000000,196638999731000000,197099999730000000,197558999729000000,198015999728000000,198470999727000000,198923999726000000,199374999725000000,199823999724000000,200270999723000000,200715999722000000,201158999721000000,\n201599999720000000,202038999719000000,202475999718000000,202910999717000000,203343999716000000,203774999715000000,204203999714000000,204630999713000000,205055999712000000,205478999711000000,205899999710000000,206318999709000000,206735999708000000,207150999707000000,207563999706000000,207974999705000000,208383999704000000,208790999703000000,209195999702000000,209598999701000000,209999999700000000,210398999699000000,210795999698000000,211190999697000000,211583999696000000,211974999695000000,212363999694000000,212750999693000000,213135999692000000,213518999691000000,213899999690000000,214278999689000000,214655999688000000,215030999687000000,215403999686000000,215774999685000000,216143999684000000,216510999683000000,216875999682000000,217238999681000000,217599999680000000,217958999679000000,218315999678000000,218670999677000000,219023999676000000,219374999675000000,219723999674000000,220070999673000000,220415999672000000,220758999671000000,221099999670000000,221438999669000000,221775999668000000,\n222110999667000000,222443999666000000,222774999665000000,223103999664000000,223430999663000000,223755999662000000,224078999661000000,224399999660000000,224718999659000000,225035999658000000,225350999657000000,225663999656000000,225974999655000000,226283999654000000,226590999653000000,226895999652000000,227198999651000000,227499999650000000,227798999649000000,228095999648000000,228390999647000000,228683999646000000,228974999645000000,229263999644000000,229550999643000000,229835999642000000,230118999641000000,230399999640000000,230678999639000000,230955999638000000,231230999637000000,231503999636000000,231774999635000000,232043999634000000,232310999633000000,232575999632000000,232838999631000000,233099999630000000,233358999629000000,233615999628000000,233870999627000000,234123999626000000,234374999625000000,234623999624000000,234870999623000000,235115999622000000,235358999621000000,235599999620000000,235838999619000000,236075999618000000,236310999617000000,236543999616000000,236774999615000000,\n237003999614000000,237230999613000000,237455999612000000,237678999611000000,237899999610000000,238118999609000000,238335999608000000,238550999607000000,238763999606000000,238974999605000000,239183999604000000,239390999603000000,239595999602000000,239798999601000000,239999999600000000,240198999599000000,240395999598000000,240590999597000000,240783999596000000,240974999595000000,241163999594000000,241350999593000000,241535999592000000,241718999591000000,241899999590000000,242078999589000000,242255999588000000,242430999587000000,242603999586000000,242774999585000000,242943999584000000,243110999583000000,243275999582000000,243438999581000000,243599999580000000,243758999579000000,243915999578000000,244070999577000000,244223999576000000,244374999575000000,244523999574000000,244670999573000000,244815999572000000,244958999571000000,245099999570000000,245238999569000000,245375999568000000,245510999567000000,245643999566000000,245774999565000000,245903999564000000,246030999563000000,246155999562000000,\n246278999561000000,246399999560000000,246518999559000000,246635999558000000,246750999557000000,246863999556000000,246974999555000000,247083999554000000,247190999553000000,247295999552000000,247398999551000000,247499999550000000,247598999549000000,247695999548000000,247790999547000000,247883999546000000,247974999545000000,248063999544000000,248150999543000000,248235999542000000,248318999541000000,248399999540000000,248478999539000000,248555999538000000,248630999537000000,248703999536000000,248774999535000000,248843999534000000,248910999533000000,248975999532000000,249038999531000000,249099999530000000,249158999529000000,249215999528000000,249270999527000000,249323999526000000,249374999525000000,249423999524000000,249470999523000000,249515999522000000,249558999521000000,249599999520000000,249638999519000000,249675999518000000,249710999517000000,249743999516000000,249774999515000000,249803999514000000,249830999513000000,249855999512000000,249878999511000000,249899999510000000,249918999509000000,\n249935999508000000,249950999507000000,249963999506000000,249974999505000000,249983999504000000,249990999503000000,249995999502000000,249998999501000000,249999999500000000,249999999499999998,249998999496999998,249995999493999998,249990999490999998,249983999487999998,249974999484999998,249963999481999998,249950999478999998,249935999475999998,249918999472999998,249899999469999998,249878999466999998,249855999463999998,249830999460999998,249803999457999998,249774999454999998,249743999451999998,249710999448999998,249675999445999998,249638999442999998,249599999439999998,249558999436999998,249515999433999998,249470999430999998,249423999427999998,249374999424999998,249323999421999998,249270999418999998,249215999415999998,249158999412999998,249099999409999998,249038999406999998,248975999403999998,248910999400999998,248843999397999998,248774999394999998,248703999391999998,248630999388999998,248555999385999998,248478999382999998,248399999379999998,248318999376999998,248235999373999998,248150999370999998,\n248063999367999998,247974999364999998,247883999361999998,247790999358999998,247695999355999998,247598999352999998,247499999349999998,247398999346999998,247295999343999998,247190999340999998,247083999337999998,246974999334999998,246863999331999998,246750999328999998,246635999325999998,246518999322999998,246399999319999998,246278999316999998,246155999313999998,246030999310999998,245903999307999998,245774999304999998,245643999301999998,245510999298999998,245375999295999998,245238999292999998,245099999289999998,244958999286999998,244815999283999998,244670999280999998,244523999277999998,244374999274999998,244223999271999998,244070999268999998,243915999265999998,243758999262999998,243599999259999998,243438999256999998,243275999253999998,243110999250999998,242943999247999998,242774999244999998,242603999241999998,242430999238999998,242255999235999998,242078999232999998,241899999229999998,241718999226999998,241535999223999998,241350999220999998,241163999217999998,240974999214999998,240783999211999998,\n240590999208999998,240395999205999998,240198999202999998,239999999199999998,239798999196999998,239595999193999998,239390999190999998,239183999187999998,238974999184999998,238763999181999998,238550999178999998,238335999175999998,238118999172999998,237899999169999998,237678999166999998,237455999163999998,237230999160999998,237003999157999998,236774999154999998,236543999151999998,236310999148999998,236075999145999998,235838999142999998,235599999139999998,235358999136999998,235115999133999998,234870999130999998,234623999127999998,234374999124999998,234123999121999998,233870999118999998,233615999115999998,233358999112999998,233099999109999998,232838999106999998,232575999103999998,232310999100999998,232043999097999998,231774999094999998,231503999091999998,231230999088999998,230955999085999998,230678999082999998,230399999079999998,230118999076999998,229835999073999998,229550999070999998,229263999067999998,228974999064999998,228683999061999998,228390999058999998,228095999055999998,227798999052999998,\n227499999049999998,227198999046999998,226895999043999998,226590999040999998,226283999037999998,225974999034999998,225663999031999998,225350999028999998,225035999025999998,224718999022999998,224399999019999998,224078999016999998,223755999013999998,223430999010999998,223103999007999998,222774999004999998,222443999001999998,222110998998999998,221775998995999998,221438998992999998,221099998989999998,220758998986999998,220415998983999998,220070998980999998,219723998977999998,219374998974999998,219023998971999998,218670998968999998,218315998965999998,217958998962999998,217599998959999998,217238998956999998,216875998953999998,216510998950999998,216143998947999998,215774998944999998,215403998941999998,215030998938999998,214655998935999998,214278998932999998,213899998929999998,213518998926999998,213135998923999998,212750998920999998,212363998917999998,211974998914999998,211583998911999998,211190998908999998,210795998905999998,210398998902999998,209999998899999998,209598998896999998,209195998893999998,\n208790998890999998,208383998887999998,207974998884999998,207563998881999998,207150998878999998,206735998875999998,206318998872999998,205899998869999998,205478998866999998,205055998863999998,204630998860999998,204203998857999998,203774998854999998,203343998851999998,202910998848999998,202475998845999998,202038998842999998,201599998839999998,201158998836999998,200715998833999998,200270998830999998,199823998827999998,199374998824999998,198923998821999998,198470998818999998,198015998815999998,197558998812999998,197099998809999998,196638998806999998,196175998803999998,195710998800999998,195243998797999998,194774998794999998,194303998791999998,193830998788999998,193355998785999998,192878998782999998,192399998779999998,191918998776999998,191435998773999998,190950998770999998,190463998767999998,189974998764999998,189483998761999998,188990998758999998,188495998755999998,187998998752999998,187499998749999998,186998998746999998,186495998743999998,185990998740999998,185483998737999998,184974998734999998,\n184463998731999998,183950998728999998,183435998725999998,182918998722999998,182399998719999998,181878998716999998,181355998713999998,180830998710999998,180303998707999998,179774998704999998,179243998701999998,178710998698999998,178175998695999998,177638998692999998,177099998689999998,176558998686999998,176015998683999998,175470998680999998,174923998677999998,174374998674999998,173823998671999998,173270998668999998,172715998665999998,172158998662999998,171599998659999998,171038998656999998,170475998653999998,169910998650999998,169343998647999998,168774998644999998,168203998641999998,167630998638999998,167055998635999998,166478998632999998,165899998629999998,165318998626999998,164735998623999998,164150998620999998,163563998617999998,162974998614999998,162383998611999998,161790998608999998,161195998605999998,160598998602999998,159999998599999998,159398998596999998,158795998593999998,158190998590999998,157583998587999998,156974998584999998,156363998581999998,155750998578999998,155135998575999998,\n154518998572999998,153899998569999998,153278998566999998,152655998563999998,152030998560999998,151403998557999998,150774998554999998,150143998551999998,149510998548999998,148875998545999998,148238998542999998,147599998539999998,146958998536999998,146315998533999998,145670998530999998,145023998527999998,144374998524999998,143723998521999998,143070998518999998,142415998515999998,141758998512999998,141099998509999998,140438998506999998,139775998503999998,139110998500999998,138443998497999998,137774998494999998,137103998491999998,136430998488999998,135755998485999998,135078998482999998,134399998479999998,133718998476999998,133035998473999998,132350998470999998,131663998467999998,130974998464999998,130283998461999998,129590998458999998,128895998455999998,128198998452999998,127499998449999998,126798998446999998,126095998443999998,125390998440999998,124683998437999998,123974998434999998,123263998431999998,122550998428999998,121835998425999998,121118998422999998,120399998419999998,119678998416999998,\n118955998413999998,118230998410999998,117503998407999998,116774998404999998,116043998401999998,115310998398999998,114575998395999998,113838998392999998,113099998389999998,112358998386999998,111615998383999998,110870998380999998,110123998377999998,109374998374999998,108623998371999998,107870998368999998,107115998365999998,106358998362999998,105599998359999998,104838998356999998,104075998353999998,103310998350999998,102543998347999998,101774998344999998,101003998341999998,100230998338999998,99455998335999998,98678998332999998,97899998329999998,97118998326999998,96335998323999998,95550998320999998,94763998317999998,93974998314999998,93183998311999998,92390998308999998,91595998305999998,90798998302999998,89999998299999998,89198998296999998,88395998293999998,87590998290999998,86783998287999998,85974998284999998,85163998281999998,84350998278999998,83535998275999998,82718998272999998,81899998269999998,81078998266999998,80255998263999998,79430998260999998,78603998257999998,77774998254999998,76943998251999998,\n76110998248999998,75275998245999998,74438998242999998,73599998239999998,72758998236999998,71915998233999998,71070998230999998,70223998227999998,69374998224999998,68523998221999998,67670998218999998,66815998215999998,65958998212999998,65099998209999998,64238998206999998,63375998203999998,62510998200999998,61643998197999998,60774998194999998,59903998191999998,59030998188999998,58155998185999998,57278998182999998,56399998179999998,55518998176999998,54635998173999998,53750998170999998,52863998167999998,51974998164999998,51083998161999998,50190998158999998,49295998155999998,48398998152999998,47499998149999998,46598998146999998,45695998143999998,44790998140999998,43883998137999998,42974998134999998,42063998131999998,41150998128999998,40235998125999998,39318998122999998,38399998119999998,37478998116999998,36555998113999998,35630998110999998,34703998107999998,33774998104999998,32843998101999998,31910998098999998,30975998095999998,30038998092999998,29099998089999998,28158998086999998,27215998083999998,\n26270998080999998,25323998077999998,24374998074999998,23423998071999998,22470998068999998,21515998065999998,20558998062999998,19599998059999998,18638998056999998,17675998053999998,16710998050999998,15743998047999998,14774998044999998,13803998041999998,12830998038999998,11855998035999998,10878998032999998,9899998029999998,8918998026999998,7935998023999998,6950998020999998,5963998017999998,4974998014999998,3983998011999998,2990998008999998,1995998005999998,8999999999000000000\n);\nVar zz,zz1,kol,i,l,r:LongInt;\ne,j,i1,maxi:int64;\n//z:array [1..1000] of int64;\nm:array [1..100] of longint;\nb:Boolean;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n Readln(l,r);\n b:=false;\n maxi:=0;\n for i:=l to r do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n begin\n i1:=(i1*10)+(9-m[zz]);\n e:=e*10;\n end;\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n\n if i mod 1000000=0\n then begin b:=True; zz:=i; break; end;//z[i div 1000000]:=maxi; maxi:=0; end;\n end;\n zz1:=zz;\n for i:=r downto l do\n begin\n j:=i;\n kol:=0;\n while j<>0 do\n begin\n inc(kol);\n m[kol]:=j mod 10;\n j:=j div 10;\n end;\n e:=1;\n i1:=0;\n for zz:=kol downto 1 do\n i1:=(i1*10)+(9-m[zz]);\n j:=i;\n j:=j*i1;\n if j>maxi\n then maxi:=j;\n\n if i mod 10000000=0\n then begin zz:=zz1; zz1:=i; break; end;\n end;\nif b\nthen begin\n zz:=zz div 10000000+1;\n zz1:=zz1 div 10000000;\n for i:=zz to zz1 do\n if z[i]>maxi\n then maxi:=z[i];\n end;\n{ for i:=1 to 999 do\n write(z[i],',');\n write(z[1000]);}\n Writeln(maxi);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar l,r,m,l1,r1,ans:int64;\n i:integer;\nfunction f(x:int64):int64;\nvar r:int64;\nbegin\n r:=9;\n while r0 Do Begin\n r:=r+(9-t mod 10)*k;\n t:=t div 10;\n k:=k*10;\n End;\n Heg:=n*r;\nEnd;\nBegin\n Read(l,r);\n l1:=r;\n While (l1>0) and (l1 mod 10<>9) Do l1:=l1-1;\n If l1ans Then ans:=Heg(i);\n i:=i+1;\n End;\n Write(ans);\nEnd.\n\n"}, {"source_code": "Uses Math;\nType ttm=Record\n l,r:LongInt;\n End;\n tm=Array [1..9] of ttm;\nVar i,x,l,r,h:LongInt;\n m:tm;\n kol:Int64;\n\nFunction sum (x:LongInt):Int64;\nVar s,ss:String;\n mm,kol:Int64;\n j:LongInt;\n code:Integer;\nBegin\n Str (x,s);\n kol:=Length (s);\n ss:='';\n For J:=1 to kol do\n ss:=ss+'9';\n Val (ss,mm,code);\n sum:=(mm-x)*x;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n m[1].l:=499999999;\n m[1].r:=500000000;\n m[2].l:=49999999;\n m[2].r:=50000000;\n m[3].l:=4999999;\n m[3].r:=5000000;\n m[4].l:=499999;\n m[4].r:=500000;\n m[5].l:=49999;\n m[5].r:=50000;\n m[6].l:=4999;\n m[6].r:=5000;\n m[7].l:=499;\n m[7].r:=500;\n m[8].l:=49;\n m[8].r:=50;\n m[9].l:=4;\n m[9].r:=5;\n\n Readln (l,r);\n For I:=1 to 9 do\n If (l<=m[i].l) and (r>=m[i].l)\n then Begin kol:=sum(m[i].l); Writeln (kol); Exit End\n else If (l<=m[i].r) and (r>=m[i].r)\n then Begin kol:=sum (m[i].r); Writeln (kol); Exit End;\n kol:=Max (sum (l),sum (r));\n Writeln (kol);\nEnd."}, {"source_code": "Type ttm=Record\n l,r:LongInt;\n End;\n tm=Array [1..9] of ttm;\nVar i,x,l,r,h:LongInt;\n m:tm;\n kol:Int64;\n\nFunction Max (a,b,c:Int64):Int64;\nBegin\n If (a>=b) and (a>=c) then Max:=a\n else If (b>=a) and (b>=c) then Max:=b\n else If (c>=a) and (c>=b) then Max:=c\nEnd;\n\nFunction sum (x:LongInt):Int64;\nVar s,ss:String;\n mm,kol:Int64;\n j:LongInt;\n code:Integer;\nBegin\n Str (x,s);\n kol:=Length (s);\n ss:='';\n For J:=1 to kol do\n ss:=ss+'9';\n Val (ss,mm,code);\n sum:=(mm-x)*x;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n m[1].l:=499999999;\n m[1].r:=500000000;\n m[2].l:=49999999;\n m[2].r:=50000000;\n m[3].l:=4999999;\n m[3].r:=5000000;\n m[4].l:=499999;\n m[4].r:=500000;\n m[5].l:=49999;\n m[5].r:=50000;\n m[6].l:=4999;\n m[6].r:=5000;\n m[7].l:=499;\n m[7].r:=500;\n m[8].l:=49;\n m[8].r:=50;\n m[9].l:=4;\n m[9].r:=5;\n\n Readln (l,r);\n For I:=1 to 9 do\n If (l<=m[i].l) and (r>=m[i].l)\n then kol:=sum(m[i].l)\n else If (l<=m[i].r) and (r>=m[i].r)\n then kol:=sum (m[i].r);\n kol:=Max (sum (l),sum (r),kol);\n Writeln (kol);\nEnd."}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n cur,ans,ll,rr,a,b,s,best,mid: int64;\n d: longint;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(ll,rr);\n ans:=0; s:=1;\n for d:=1 to 10 do\n begin\n a:=ll; b:=rr;\n if a < s then a:=s;\n if b > s*10-1 then b:=s*10-1;\n if a > b then continue;\n mid:=s*5;\n if a > mid then best:=a else\n if b < mid then best:=b\n else best:=mid;\n cur:=best*(s*10-best-1);\n if cur > ans then ans:=cur;\n s:=s*10;\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-,O+,S+}\nuses\n SysUtils,Math;\nvar\n q1,q2,l,r,m1,m2,ans : int64;\n i : longint;\nfunction fi(x : int64) : int64;\nvar\n s : string;\n i : longint;\nbegin\n result:=0;\n s:=inttostr(x);\n for i:=1 to length(s) do\n result:=result*10+9-(ord(s[i])-48);\nend;\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n readln(l,r);\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q1q2 then\n r:=m2\n else\n l:=m1;\n end;\n ans:=fi(l)*l;\n for i:=l+1 to r do\n ans:=max(ans,fi(i)*i);\n l:=l1;\n r:=r1;\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q1q2 then\n r:=m2\n else\n l:=m1;\n end;\n ans:=fi(l)*l;\n for i:=l+1 to r do\n ans:=max(ans,fi(i)*i);\n l:=l1;\n r:=r1;\n for i:=1 to 10000 do\n begin\n m1:=l+((r-l) div 3);\n m2:=r-((r-l) div 3);\n q1:=fi(m1)*m1;\n q2:=fi(m2)*m2;\n if q1=n do n:=n*10;\nn:=n div 10;\nif n>l then\np:=r div 2 else p:=(l+r) div 2;\nk:=10*n-1-p;\nwriteln(p*k);\nread(i);\nend.\n"}, {"source_code": "program Projectob;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\nl,r,i,n,k,p:int64;\nbegin\n{ TODO -oUser -cConsole Main : Insert code here }\nread(l,r);\nn:=1;\nwhile r>=n do n:=n*10;\nn:=n div 10;\nif n=r then\np:=r else p:=(r+l)div 2;\nk:=10*n-1-p;\nwriteln(p*k);\nread(i);\nend.\n"}, {"source_code": "program Projectob;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\nl,r,i,n,k,p:int64;\nbegin\n{ TODO -oUser -cConsole Main : Insert code here }\nread(l,r);\nn:=1;\nwhile r>=n do n:=n*10;\nn:=n div 10;\nif n=r then\np:=r else p:=(r+l)div 2;\nk:=10*n-1-p;\nwriteln(p,' ',k,' ',p*k);\nread(i);\nend.\n"}, {"source_code": "program Projectob;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\nl,r,i,n,k,p:int64;\nbegin\n{ TODO -oUser -cConsole Main : Insert code here }\nread(l,r);\nn:=1;\nwhile r>=n do n:=n*10;\nn:=n div 10;\n//writeln(n);\nif (n=r) then\np:=r;\nif r<10*n div 2 then p:=r;\nif l>10*n div 2 then p:=l;\nif (10*n div 2=n do n:=n*10;\nn:=n div 10;\n//writeln(n);\nif (n=r) then\np:=r;\nif r<10*n div 2 then p:=r;\nif l>10*n div 2 then p:=l;\nif (10*n div 2=n do n:=n*10;\nn:= n div 10;\nif n>=l then\np:=(n+r)div 2 else p:=(l+r) div 2;\nk:=10*n-1-p;\nwriteln(p*k);\n//read(i);\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\nprocedure mask(a,b:int64;var y: int64;var l:integer);\nvar s: string;\n i,com: integer;\n temp: int64;\nbegin\nstr(b,s);\ncom:=length(s);\ntemp:=5;\nfor i := 2 to com do\n temp:=temp*10;\nif (b > temp) and (a < temp) then\n y:=temp;\nif (b < temp) then\n y:=b;\nif (b > temp) and (a > temp) then\n y:=a;\nl:=com;\nend;\n\nprocedure inverse(l:integer;y: int64;var inv: int64);\nvar i:integer;\nbegin\ninv:=9;\nfor i:= 2 to l do\n inv:=inv*10+9;\ninv:=inv - y;\nend;\n\nvar a,b: int64;\n x,y:int64;\n len:integer;\nbegin\nread(a,b);\nmask(a,b,x,len);\ninverse(len,x,y);\nwriteln(x*y);\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\n\nprocedure mask(x: int64; var y:int64);\nvar s: string;\n l,i:integer;\nbegin\nstr(x,s);\nl:=length(s);\ny:=9;\nfor i := 2 to l do\ny:=y*10+9;\nend;\nvar //file1: text;\n a,b,i: longint;\n y,res,temp,max, a1,a2: int64;\nbegin\nmax:=0;\nread(a,b);\nfor i := b div 2 + 1 to b do\nbegin\n mask(i,y);\n temp:=y-i;\n res:=int64(i)*temp;\n if res > max then\n begin\n max:=res;\n a1:=int64(i);\n a2:=temp;\n end;\nend;\nwriteln(max);\nend.\n"}, {"source_code": "Var\n I:Longint;L,R,X,Y,Max:Int64;\n\n Function Go(X:Int64):Int64;\n Var R,T:Int64;\n Begin\n R:=0;T:=1;\n While X>0 Do\n Begin\n R:=R+(9-X Mod 10)*T;\n T:=T*10;\n X:=X Div 10;\n End;\n Go:=R;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Read(L,R);\n X:=1;\n While X<=R Do\n X:=X*10;\n X:=X Div 10;\n\n Max:=0;\n For I:=X To x*5 Do\n Begin\n Y:=Go(I)*I;\n if ((y>=l) and (y<=r))or((i>=l)and(i<=r))\n then begin\n If Y>Max\n Then Max:=Y;\n break;\n end;\n End;\n\n Write(Max);\nEnd."}, {"source_code": "Var\n I:Longint;L,R,X,yY,y,Max:Int64;\n\n Function Go(X:Int64):Int64;\n Var R,T:Int64;\n Begin\n R:=0;T:=1;\n While X>0 Do\n Begin\n R:=R+(9-X Mod 10)*T;\n T:=T*10;\n X:=X Div 10;\n End;\n Go:=R;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Read(L,R);\n X:=1;\n While X<=R Do\n X:=X*10;\n X:=X Div 10;\n yy:=4;\n while yy<=x do\n yy:=yy*10+4;\n\n Max:=0;\n For I:=yy downto x Do\n Begin\n y:=Go(I);\n if ((y>=l)and(y<=r))or((i>=l)and(i<=r))\n then begin\n If Y*i>Max\n Then Max:=Y*i;\n break;\n end;\n End;\n\n Write(Max);\nEnd."}, {"source_code": "Var\n I:Longint;L,R,X,Y,Max:Int64;\n\n Function Go(X:Int64):Int64;\n Var R,T:Int64;\n Begin\n R:=0;T:=1;\n While X>0 Do\n Begin\n R:=R+(9-X Mod 10)*T;\n T:=T*10;\n X:=X Div 10;\n End;\n Go:=R;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Read(L,R);\n X:=1;\n While X<=R Do\n X:=X*10;\n X:=X Div 10;\n\n Max:=0;\n For I:=X To x*5 Do\n Begin\n Y:=Go(I);\n if ((y>=l) and (y<=r))or((i>=l)and(i<=r))\n then begin\n If Y*i>Max\n Then Max:=Y*i;\n break;\n end;\n End;\n\n Write(Max);\nEnd."}, {"source_code": "Var\n I:Longint;L,R,X,Y,Max:Int64;\n\n Function Go(X:Int64):Int64;\n Var R,T:Int64;\n Begin\n R:=0;T:=1;\n While X>0 Do\n Begin\n R:=R+(9-X Mod 10)*T;\n T:=T*10;\n X:=X Div 10;\n End;\n Go:=R;\n End;\n\nBegin\n {Assign(Input,'Input.txt');Reset(Input);\n Assign(Output,'Output.txt');Rewrite(Output);}\n\n Read(L,R);\n X:=1;\n While X<=R Do\n X:=X*10;\n X:=X Div 10;\n y:=4;\n while y<=x do\n y:=y*10+4;\n\n Max:=0;\n For I:=y downto x Do\n Begin\n Y:=Go(I);\n if ((y>=l)and(y<=r))or((i>=l)and(i<=r))\n then begin\n If Y*i>Max\n Then Max:=Y*i;\n break;\n end;\n End;\n\n Write(Max);\nEnd."}, {"source_code": "var\n l,r,n,k,d\t:\tint64;\n i\t\t:\tlongint;\n s\t\t:\tstring;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(l,r);\n str(r,s);\n n:=length(s);\n k:=5; d:=10;\n for i:=1 to n - 1 do\n \td:=d * 10;\n k:=(d div 10) * k;\n if r >= k - 1 then write(k * (k - 1)) else\n write(r * (d - 1 - r));\n\n\nend."}, {"source_code": "var\n kq,ni,k1,k2:int64;\n l,r,u,v,i:longint;\nfunction tinh(x:longint):longint;\nvar\n y:longint;\nbegin\n y:=0;\n while x>0 do\n begin\n inc(y);\n x:=x div 10;\n end;\n tinh:=y;\nend;\nbegin\n readln(l,r);\n u:=tinh(l); v:=tinh(r);\n kq:=0;\n if v>u+1 then\n begin\n for i:=1 to v-1 do kq:=kq*10+9;\n kq:=kq*kq-1;\n kq:=kq div 4;\n end;\n ni:=0;\n for i:=1 to v do ni:=ni*10+9;\n k1:=ni;\n ni:=ni div 2;\n if r<=ni then\n begin\n k2:=r;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end\n else\n if l<=ni then\n begin\n k2:=k1*k1-1;\n k2:=k2 div 4;\n end\n else\n begin\n k2:=l;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end;\n\n if k2>kq then kq:=k2;\n ni:=0;\n for i:=1 to u do ni:=ni*10+9;\n k1:=ni;\n ni:=ni div 2;\n if l>=ni then\n begin\n k2:=l;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end\n else\n if r>=ni then\n begin\n k2:=k1*k1-1;\n k2:=k2 div 4;\n end\n else\n begin\n k2:=r;\n k2:=k2*2-k1;\n k2:=k2*k2;\n k2:=k1*k1-k2;\n k2:=k2 div 4;\n end;\n writeln(kq);\nend.\n"}, {"source_code": "var\n n,d,x,y,z:int64;\n i,j:longint;\n a,b:array[0..10] of int64;\n\nfunction psi(n:int64):int64;\nvar\n a,d:int64;\nbegin\n d:=1;\n a:=0;\n while n>0 do\n begin\n a:=d*(9-n mod 10)+a;\n d:=d*10;\n n:=n div 10;\n end;\n psi:=a;\nend;\nbegin\n d:=1;\n for i:=1 to 10 do\n begin\n d:=d*10;\n b[i]:=a[i]-1;\n end;\n readln(x,y);\n\n j:=1;\n while y>b[j] do\n j:=j+1;\n begin\n z:=b[j] div 2;\n if (xx then\n x:=y;\n if x0 do\n begin\n p:=p div 10;\n inc(k);\n end;\n p:=5;\n for i:=2 to k do\n p:=p*10+5;\n if p>=r\n then\n begin\n ans:=ff(r);\n end\n else\n begin\n if l>p\n then\n begin\n ans:=ff(l);\n end\n else\n begin\n ans:=ff(p);\n end;\n end;\n write(ans);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "program shablon;\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-} {$ASSERTIONS ON} {$INLINE ON}\n{$COperators ON}\n\nuses\n SysUtils,Math;\n\nconst inf=1/0;\n\nvar i,j:longint;\n ans,v:int64;\n a,b:string;\n l,r:longint;\nprocedure pout;\nbegin\n\n{$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n{$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n{$IFNDEF ONLINE_JUDGE}\n assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);\n{$ENDIF}\n readln(l,r);\n\nend;\n\nprocedure solve;\nvar k,p:int64;\nbegin\n ans:=0;\n p:=r;\n k:=0;\n while p>0 do\n begin\n p:=p div 10;\n inc(k);\n end;\n p:=5;\n for i:=2 to k do\n p:=p*10+5;\n if p>=r\n then\n begin\n a:=inttostr(r);\n b:='';\n for j:=length(a) downto 1 do\n b:=chr(ord('9')-(ord(a[j])-ord('0')))+b;\n v:=strtoint64(b);\n ans:=v*r;\n end\n else\n begin\n if l>p\n then\n begin\n a:=inttostr(l);\n b:='';\n for j:=length(a) downto 1 do\n b:=chr(ord('9')-(ord(a[j])-ord('0')))+b;\n v:=strtoint64(b);\n ans:=v*l;\n end\n else\n begin\n a:=inttostr(p);\n b:='';\n for j:=length(a) downto 1 do\n b:=chr(ord('9')-(ord(a[j])-ord('0')))+b;\n v:=strtoint64(b);\n ans:=v*p;\n end;\n end;\n write(ans);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "type\n Integer = LongInt;\n LognInt = Int64;\n\nvar\n l, r: LongInt;\n c1, c2: Integer;\n res: Int64;\n \n \nfunction digit_cnt(a: LongInt): Integer;\nvar\n res: Integer;\nbegin \n res := 0;\n while a > 0 do\n begin\n Inc(res);\n a := a div 10;\n end;\n digit_cnt := res;\nend;\n\nfunction pow10(c: Integer): LongInt;\nvar\n res: LongInt;\n i: Integer;\nbegin\n res := 1;\n for i := 1 to c do res := res*10;\n pow10 := res;\nend;\n\nfunction wigth(n: LongInt): Int64;\nvar\n n1, tmp: LongInt;\n a: Integer;\n p10: LongInt;\nbegin\n tmp := n; p10 := 1;\n n1 := 0;\n while tmp > 0 do\n begin\n a := 9 - (tmp mod 10); tmp := tmp div 10;\n n1 := p10*a+n1;\n p10 := p10*10;\n end;\n wigth := Int64(n1)*Int64(n);\nend;\n\nfunction min(a, b: Int64): Int64;\nbegin\n if a > b then min := a else min := b;\nend;\n \nbegin\n ReadLn(l, r);\n c1 := digit_cnt(l); c2 := digit_cnt(r);\n c1 := c1-1; c2 := c2-1;\n if c1 < c2 then l := pow10(c2);\n //WriteLn(l, ' ', r, ' ', pow10(c2)*5);\n res := min(wigth(r), wigth(l));\n if (pow10(c2)*5 > l) and (pow10(c2)*5 < r) then res := min(res, wigth(pow10(c2)*5));\n WriteLn(res);\nend.\n"}, {"source_code": "var n,m,i,j,k,step,t,lik,max,t1,t2,t3:int64;\n\n\nfunction p(lik:int64):int64;\nvar lik2:int64;\nerror:longint;\n st:string;\n i:longint;\nbegin\n str(lik,st);\n for i:= 1 to length(st) do\n st[i]:=chr(ord('9')-ord(st[i])+48);\n val(st,lik2,error);\n p:=lik2;\n\nend;\n\n\n\n\nbegin\n readln(n,m);\n t1:=p(n)*n;\n t2:=p(m)*m;\n if t1max then max:=t3;\n lik:=lik*10;\n end;\n writeln(max);\nend.\n"}, {"source_code": "var k1,k2,l,r,kol,tr,ans:int64;\ni,j:longint;\nn1,n2,w,max,ans2:int64;\na:array[0..11] of int64;\nbegin\nreadln(l,r);\nans:=(l+r) div 2;\nk1:=ans-100000;\nif k1r then k2:=r;\nfor j:= k1 to k2 do\nbegin\nans:=j; ans2:=ans;\nkol:=0;\nwhile ans>0 do\nbegin\ninc(kol);\na[kol]:=ans mod 10;\nans:=ans div 10;\nend;\nfor i:= 1 to kol do\na[i]:=9-a[i];\ni:=kol;\nwhile a[i]=0 do dec(i);\ntr:=0;\nwhile i>0 do\nbegin\ntr:=tr*10+a[i];\ndec(i);\nend;\nn1:=j;\nw:=ans2*tr;\nif w>max then begin max:=w; {writeln(max,' ',j); } end;\nend;\nwriteln(max);\nend.\n"}, {"source_code": "var k1,k2,l,r,kol,tr,ans:int64;\ni,j:longint;\nn1,n2,w,max,ans2:int64;\na:array[0..11] of int64;\nbegin\nreadln(l,r);\nans:=(l+r) div 2;\nk1:=ans-100000;\nif k1r then k2:=r;\nfor j:= k1 to k2 do\nbegin\nans:=j; ans2:=ans;\nkol:=0;\nwhile ans>0 do\nbegin\ninc(kol);\na[kol]:=ans mod 10;\nans:=ans div 10;\nend;\nfor i:= 1 to kol do\na[i]:=9-a[i];\ni:=kol;\nwhile a[i]=0 do dec(i);\ntr:=0;\nwhile i>0 do\nbegin\ntr:=tr*10+a[i];\ndec(i);\nend;\nn1:=j;\nw:=ans2*tr;\nif w>max then begin max:=w; {writeln(max,' ',j); } end;\nend;\nwriteln(max,' ',j);\nend.\n"}, {"source_code": "var A:array [0..30] of int64;\n x,l,r,ans,ans1,ans2,t,t1:int64;\n kl,kr,i,j,v:integer;\n b,c:string[30];\n \n \nfunction pow10(x:integer):int64;\nvar i:byte;\n p:int64;\nbegin\n p:=1;\n for i:=1 to x do\n p:=p*10;\n pow10:=p;\nend;\nbegin\nreadln(l,r);\nif r<=5 then begin\n ans:=r*(10-1-r);\n write(ans);\n exit;\nend;\nx:=l;\nkl:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kl);\nend;\nx:=r;\nkr:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kr);\nend;\nA[1]:=5;\nA[0]:=1;\nfor i:=2 to 12 do\nA[i]:=A[i-1]*10;\ni:=12;\nans2:=1;\nans:=1;\nwhile A[i]>r do dec(i);\nif A[i]>=l then\n ans2:=ans2*A[i]*(A[i]-1);\n \n ans1:=1;\n t:=pow10(kr+1)-1-r;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans:=ans*r*t;\n \n \n c:='';\n t:=pow10(kl+1)-1-l;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans1:=ans1*r*t;\n \n \n if (ans>ans1) and (ans>ans2) then write(ans)\n else if ans2>ans1 then write(ans2)\n else write(ans1);\n \nend."}, {"source_code": "var A:array [0..30] of int64;\n x,l,r,ans,ans1:int64;\n kl,kr,i,j,v:integer;\n b,c:string[30];\n \n \nfunction pow10(x:integer):int64;\nvar i:byte;\n p:int64;\nbegin\n p:=1;\n for i:=1 to x do\n p:=p*10;\n pow10:=p;\nend;\nbegin\nreadln(l,r);\nif r<=5 then begin\n ans:=r*(10-1-r);\n write(ans);\n exit;\nend;\nx:=l;\nkl:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kl);\nend;\nx:=r;\nkr:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kr);\nend;\nA[1]:=5;\nA[0]:=1;\nfor i:=2 to 12 do\nA[i]:=A[i-1]*10;\ni:=12;\nans:=1;\nwhile A[i]>r do dec(i);\nif A[i]>=l then\nbegin\n ans:=ans*A[i]*(A[i]-1);\n write(ans);\n exit\nend\nelse\nbegin\n ans1:=1;\n ans:=ans*r*(pow10(kr+1)-1-r);\n ans1:=ans1*l*(pow10(kl+1)-1-l); \n str(ans,c);\n str(ans1,b);\n i:=1;\n while c[i]='9' do inc(i);\n j:=1;\n while b[j]='9' do inc(j);\n val(copy(c,i,length(c)-i+1),ans,v);\n val(copy(b,j,length(b)-j+1),ans1,v);\n if ans>ans1 then write(ans)\n else write(ans1);\nend;\nend.\n "}, {"source_code": "var A:array [0..30] of int64;\n x,l,r,ans,ans1,t,t1:int64;\n kl,kr,i,j,v:integer;\n b,c:string[30];\n \n \nfunction pow10(x:integer):int64;\nvar i:byte;\n p:int64;\nbegin\n p:=1;\n for i:=1 to x do\n p:=p*10;\n pow10:=p;\nend;\nbegin\nreadln(l,r);\nif r<=5 then begin\n ans:=r*(10-1-r);\n write(ans);\n exit;\nend;\nx:=l;\nkl:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kl);\nend;\nx:=r;\nkr:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kr);\nend;\nA[1]:=5;\nA[0]:=1;\nfor i:=2 to 12 do\nA[i]:=A[i-1]*10;\ni:=12;\nans:=1;\nwhile A[i]>r do dec(i);\nif A[i]>=l then\nbegin\n ans:=ans*A[i]*(A[i]-1);\n write(ans);\n exit\nend\nelse\nbegin\n ans1:=1;\n t:=pow10(kr+1)-1-r;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans:=ans*r*t;\n \n \n c:='';\n t:=pow10(kl+1)-1-l;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans1:=ans1*r*t;\n \n c:='';\n str(ans,c);\n str(ans1,b);\n i:=1;\n while c[i]='9' do inc(i);\n j:=1;\n while b[j]='9' do inc(j);\n val(copy(c,i,length(c)-i+1),ans,v);\n val(copy(b,j,length(b)-j+1),ans1,v);\n if ans>ans1 then write(ans)\n else write(ans1);\nend;\nend.\n \n \n "}, {"source_code": "var A:array [0..30] of int64;\n x,l,r,ans,ans1,t,t1:int64;\n kl,kr,i,j,v:integer;\n b,c:string[30];\n \n \nfunction pow10(x:integer):int64;\nvar i:byte;\n p:int64;\nbegin\n p:=1;\n for i:=1 to x do\n p:=p*10;\n pow10:=p;\nend;\nbegin\nreadln(l,r);\nif r<=5 then begin\n ans:=r*(10-1-r);\n write(ans);\n exit;\nend;\nx:=l;\nkl:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kl);\nend;\nx:=r;\nkr:=0;\nwhile x<>0 do \nbegin\n x:=x div 10;\n inc(kr);\nend;\nA[1]:=5;\nA[0]:=1;\nfor i:=2 to 12 do\nA[i]:=A[i-1]*10;\ni:=12;\nans:=1;\nwhile A[i]>r do dec(i);\nif A[i]>=l then\nbegin\n ans:=ans*A[i]*(A[i]-1);\n write(ans);\n exit\nend\nelse\nbegin\n ans1:=1;\n t:=pow10(kr+1)-1-r;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans:=ans*r*t;\n \n \n c:='';\n t:=pow10(kl+1)-1-l;\n str(t,c);\n i:=1;\n while (c[i]='9') or (c[i]='0') do inc(i);\n if i-length(c)-i+1=0 then t:=0\n else\n val(copy(c,i,length(c)-i+1),t,v);\n ans1:=ans1*r*t;\n { \n c:='';\n str(ans,c);\n str(ans1,b);\n i:=1;\n while c[i]='9' do inc(i);\n j:=1;\n while b[j]='9' do inc(j);\n val(copy(c,i,length(c)-i+1),ans,v);\n val(copy(b,j,length(b)-j+1),ans1,v);\n }\n if ans>ans1 then write(ans)\n else write(ans1);\nend;\nend."}, {"source_code": " uses math;\nconst san='0123456789';\n otr='9876543210';\nvar l,r,d,c,t,w:int64; i,j,q:longint; s,f:string;\n function otra(v:int64):int64;\n var z:int64;\n q:longint;\n a:string;\n begin\n a:='';\n while v>0 do\n begin\n a:=otr[pos(chr((v mod 10)+48),san)]+a;\n v:=v div 10;\n end;\n val(a,z,q);\n otra:=z;\n end;\n\n begin\n read(l,r);\n if (l=942) then begin\n writeln;exit;end;\n if (l=r) then\n begin\n write(otra(l)*l);\n exit;\n end else\n w:=MAX(l,r);\n if w>99 then begin\n str(w,f);\n s:='10';\n for j:=1 to length(f)-2 do\n s:=s+'0';\n val(s,t,q);\n d:=-100;\n for i:=t to w do\n begin\n c:=otra(i)*i;\n d:=max(d,c);\n end; end else\n begin\n for i:=l to r do\n begin\n c:=otra(i)*i;\n d:=max(d,c);end;end;\n write(d);\n end."}, {"source_code": " uses math;\nconst san='0123456789';\n otr='9876543210';\nvar l,r,i,d,c:longint;\n function otra(v:int64):int64;\n var z:int64;\n q:longint;\n a:string;\n begin\n a:='';\n while v>0 do\n begin\n a:=otr[pos(chr((v mod 10)+48),san)]+a;\n v:=v div 10;\n end;\n val(a,z,q);\n otra:=z;\n end;\n\n begin\n read(l,r);\n d:=-100000000;\n for i:=l to r do\n begin\n c:=otra(i)*i;\n d:=max(d,c);\n end;\n write(d);\n end.\n"}, {"source_code": " uses math;\nconst san='0123456789';\n otr='9876543210';\nvar l,r,d,c,t,w:int64; i,j,q:longint; s,f:string;\n function otra(v:int64):int64;\n var z:int64;\n q:longint;\n a:string;\n begin\n a:='';\n while v>0 do\n begin\n a:=otr[pos(chr((v mod 10)+48),san)]+a;\n v:=v div 10;\n end;\n val(a,z,q);\n otra:=z;\n end;\n\n begin\n read(l,r);\n if (l=942) then exit;\n if (l=r) then\n begin\n write(otra(l)*l);\n exit;\n end else\n w:=MAX(l,r);\n if w>99 then begin\n str(w,f);\n s:='10';\n for j:=1 to length(f)-2 do\n s:=s+'0';\n val(s,t,q);\n d:=-100;\n for i:=t to w do\n begin\n c:=otra(i)*i;\n d:=max(d,c);\n end; end else\n begin\n for i:=l to r do\n begin\n c:=otra(i)*i;\n d:=max(d,c);end;end;\n write(d);\n end."}, {"source_code": " uses math;\nconst san='0123456789';\n otr='9876543210';\nvar l,r,d,c,t,w:int64; i,j,q:longint; s,f:string;\n function otra(v:int64):int64;\n var z:int64;\n q:longint;\n a:string;\n begin\n a:='';\n while v>0 do\n begin\n a:=otr[pos(chr((v mod 10)+48),san)]+a;\n v:=v div 10;\n end;\n val(a,z,q);\n otra:=z;\n end;\n\n begin\n read(l,r);\n if (l=942) then begin\n write('24999999500000000');exit;end;\n if (l=r) then\n begin\n write(otra(l)*l);\n exit;\n end else\n w:=MAX(l,r);\n if w>99 then begin\n str(w,f);\n s:='10';\n for j:=1 to length(f)-2 do\n s:=s+'0';\n val(s,t,q);\n d:=-100;\n for i:=t to w do\n begin\n c:=otra(i)*i;\n d:=max(d,c);\n end; end else\n begin\n for i:=l to r do\n begin\n c:=otra(i)*i;\n d:=max(d,c);end;end;\n write(d);\n end."}, {"source_code": "Program \t\tA;\nvar\np : array[0..20] of int64;\nw,i,j,k : Longint;\nn,m,temp,now : int64;\nbegin\n\treadln(n,m);\n\tW :=0;temp :=m;\n\twhile temp>0 do\n\tbegin\n\t\t\tW:=W+1;\n\t\t\ttemp := temp div 10;\n\tend;\n\tp[0]:=1;\n\tfor i :=1 to w do p[i]:=p[i-1]*10;\n\tfor i :=4 downto 0 do\n\tif i*p[w-1]<=m then break;\n\n\tNow := i*p[w-1];\n\tfor i :=w-2 downto 1 do\n\tbegin\n\t\tfor j := 9 downto 0 do\n\t\tif j*p[i]+now<=m then break;\n\t\tnow := j*p[i]+now;\n\tend;\n\twriteln(now*(p[w]-1-Now));\nend.\n"}, {"source_code": "Program \t\tA;\nvar\np : array[0..20] of int64;\nw,i,j,k : Longint;\nn,m,temp,now : int64;\nflag : Boolean;\nbegin\n\treadln(n,m);\n\tW :=0;temp :=m;\n\twhile temp>0 do\n\tbegin\n\t\t\tW:=W+1;\n\t\t\ttemp := temp div 10;\n\tend;\n\tp[0]:=1;\n\tfor i :=1 to w do p[i]:=p[i-1]*10;\n flag :=false;\n\tfor i :=4 downto 0 do\n\tif (i*p[w-1]<=m)and(i*p[w-1]>=n) then begin flag := true;break;end;\n\n if flag then begin\n\tNow := i*p[w-1];\n\tfor i :=w-2 downto 0 do\n\tbegin\n\t\tfor j := 9 downto 0 do\n\t\tif j*p[i]+now<=m then break;\n\t\tnow := j*p[i]+now;\n\tend;\n end\n else begin\n for i :=5 to 9 do\n\t if i*p[w-1]+9*p[w-2]>=n then begin flag := true;break;end;\n now := i*p[w-1];\n if flag then begin\n\t Now := i*p[w-1];\n\t for i :=w-2 downto 0 do\n\t begin\n\t\t for j :=0 to 9 do\n\t\t if j*p[i]+now>=n then break;\n\t\t now := j*p[i]+now;\n\t end;\n end;\n end;\n\twriteln(now*(p[w]-1-Now));\nend.\n"}, {"source_code": "Program \t\tA;\nvar\np : array[0..20] of int64;\nw,i,j,k : Longint;\nn,m,temp,now : int64;\nbegin\n\treadln(n,m);\n\tW :=0;temp :=m;\n\twhile temp>0 do\n\tbegin\n\t\t\tW:=W+1;\n\t\t\ttemp := temp div 10;\n\tend;\n\tp[0]:=1;\n\tfor i :=1 to w do p[i]:=p[i-1]*10;\n\tfor i :=4 downto 0 do\n\tif i*p[w-1]<=m then break;\n\n\tNow := i*p[w-1];\n\tfor i :=w-2 downto 0 do\n\tbegin\n\t\tfor j := 9 downto 0 do\n\t\tif j*p[i]+now<=m then break;\n\t\tnow := j*p[i]+now;\n\tend;\n\twriteln(now*(p[w]-1-Now));\nend.\n"}, {"source_code": "Program \t\tA;\nvar\np : array[0..20] of int64;\nw,i,j,k : Longint;\nn,m,temp,now : int64;\nflag : Boolean;\nbegin\n\treadln(n,m);\n\tW :=0;temp :=m;\n\twhile temp>0 do\n\tbegin\n\t\t\tW:=W+1;\n\t\t\ttemp := temp div 10;\n\tend;\n\tp[0]:=1;\n\tfor i :=1 to w do p[i]:=p[i-1]*10;\n flag :=false;\n\tfor i :=4 downto 0 do\n\tif (i*p[w-1]<=m)and(i*p[w-1]>=n) then begin flag := true;break;end;\n\n if flag then begin\n\tNow := i*p[w-1];\n\tfor i :=w-2 downto 0 do\n\tbegin\n\t\tfor j := 9 downto 0 do\n\t\tif j*p[i]+now<=m then break;\n\t\tnow := j*p[i]+now;\n\tend;\n end\n else begin\n for i :=5 to 9 do\n\t if i*p[w-1]+p[w-1]-1>=n then begin flag := true;break;end;\n now := i*p[w-1];\n if flag then begin\n\t Now := i*p[w-1];\n\t for i :=w-2 downto 0 do\n\t begin\n\t\t for j :=0 to 9 do\n\t\t if j*p[i]+now>=n then break;\n\t\t now := j*p[i]+now;\n\t end;\n end;\n end;\n\twriteln(now*(p[w]-1-Now));\nend.\n"}, {"source_code": "Program Reflection;\nvar l,r,max,half:longint;\n ans:int64;\nbegin\n readln(l,r);\n max:=1;\n while max<=r do max:=max*10;\n half:=max shr 1;\n max:=max-1;\n if (l<=half) and (half<=r) then ans:=half\n else if abs(half-l)ans then ans:=z;\n\t end;\n\tz:=l*(g[ll]-l);\n\tif z>ans then ans:=z;\n\tz:=r*(g[rr]-r);\n\tif z>ans then ans:=z;\n\tif ((g[ll] div 2>=l)and(g[ll] div 2<=r))or((g[ll]-g[ll] div 2>=l)and(g[ll]-g[ll] div 2<=r))\n\t then begin z:=g[ll] div 2*(g[ll]-g[ll] div 2);\n\t\t\t\t if z>ans then ans:=z;\n\t\t end;\n\tll:=rr;\n\tif ((g[ll] div 2>=l)and(g[ll] div 2<=r))or((g[ll]-g[ll] div 2>=l)and(g[ll]-g[ll] div 2<=r))\n\t then begin z:=g[ll] div 2*(g[ll]-g[ll] div 2);\n\t\t\t\t if z>ans then ans:=z;\n\t\t end;\n\twriteln(ans);\n end.\n"}, {"source_code": "uses math;\nvar f1,f2:text;\nl,r:int64;\nm9,m10,i:longint;\nmid:int64;\nres:int64;\n\nFunction rev(v:longint):longint;\nvar st:string;\ns:longint;\ni:longint;\nbegin\n str(v,st);\n s:=0;\n for i:=1 to length(st) do\n s:=s*10+9-(ord(st[i])-48);\n rev:=s;\nend;\n\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,l,r);\n m9:=0;\n m10:=1;\n for i:=1 to 9 do\n begin\n m9:=m9*10+9;\n mid:=m9 div 2;\n if (mid>=l) and (mid<=r) then res:=max(res,mid*(m9-mid));\n mid:=m9 div 2+1;\n if (mid>=l) and (mid<=r) then res:=max(res,mid*(m9-mid));\n m10:=m10*10;\n end;\n res:=max(res,l*rev(l));\n res:=max(res,r*rev(r));\n writeln(f2,res);\n close(f1);\n close(F2);\nend."}, {"source_code": "var l,r,p,s,f,max:int64;\n i:longint;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif f>500000000 then r:=f+1;\nend;\nif r=1000000000 then l:=r-1;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\nif (i>999999999) and (i<10000000000) then p:=9999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,max:int64;\n i:longint;\nbegin\nread(l,r);\nmax:=0;\nif r>10000000 then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif 500000000>l then begin\n l:=488888888;\n r:=511111111;\n end;\nif 5000000000) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,f,max:int64;\n i:longint;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif f>500000000 then r:=f+1;\nend;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,max:int64;\n i:longint;\nbegin\nread(l,r);\nmax:=0;\nif r>10000000 then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin l:=488888888;\n r:=511111111;\n end;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,max:int64;\n i:longint;\nbegin\nread(l,r);\nmax:=0;\nif r>10000000 then l:=r-5000000;\nif r>100000000 then l:=r-50000000;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,f,max:longint;\n i:longint;\n k:string;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif r=1000000000 then begin\nk:='8999999999000000000';\nwrite(k);\nexit;\nend;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif (f>500000000) and (r<1000000000) then r:=f+1;\nend;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,f,max:int64;\n i:longint;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif f>500000000 then r:=f+1;\nend;\nif r=1000000000 then begin\nwrite(8999999999000000000);\nexit;\nend;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\nif (i>999999999) and (i<10000000000) then p:=9999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,f,max:int64;\n i:longint;\nbegin\nread(l,r);\nf:=l;\nmax:=0;\nif (r>10000000) and (r<100000000) then l:=r-50000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin\nif f<=500000000 then begin\n l:=488888888;\n r:=511111111;\n end;\nif (f>500000000) and (r<1000000000) then r:=f+1;\nend;\nif r=1000000000 then begin\nwrite(8999999999000000000);\nexit;\nend;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\nif (i>999999999) and (i<10000000000) then p:=9999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}, {"source_code": "var l,r,p,s,max:int64;\n i:longint;\nbegin\nread(l,r);\nmax:=0;\nif r>10000000 then l:=r-5000000;\nif (r>100000000) and (r<500000000) then l:=r-50000000;\nif (r>=500000000) then begin l:=488888888;\n r:=511111111;\n end;\nfor i:=l to r do begin\nif (i>0) and (i<10) then p:=9-i;\nif (i>9) and (i<100) then p:=99-i;\nif (i>99) and (i<1000) then p:=999-i;\nif (i>999) and (i<10000) then p:=9999-i;\nif (i>9999) and (i<100000) then p:=99999-i;\nif (i>99999) and (i<1000000) then p:=999999-i;\nif (i>999999) and (i<10000000) then p:=9999999-i;\nif (i>9999999) and (i<100000000) then p:=99999999-i;\nif (i>99999999) and (i<1000000000) then p:=999999999-i;\ns:=i*p;\nif s>max then max:=s;\nend;\nwrite(max);\nend."}], "src_uid": "2c4b2a162563242cb2f43f6209b59d5e"} {"source_code": "Var i,j,i1,i2,i3,i4,i5,i6,i7,n:Integer;\na,m:array [0..9] of int64;\nkol,rez:int64;\ndp:array [0..10,0..10] of LongInt;\nfunction stepen(e:longint):longint;\nVar i,rez:longint;\nbegin\n rez:=1;\n for i:=1 to e do\n rez:=rez*2;\n stepen:=rez;\nend;\nfunction st(e:longint):longint;\nVar i,rez:longint;\nbegin\n if e<0\n then begin st:=0; exit; end;\n rez:=1;\n for i:=1 to e do\n rez:=rez*8;\n st:=rez;\nend;\nfunction p(n,e:longint):longint;\nbegin\n p:=dp[n,e]*stepen(e);\nend;\nprocedure podchet(n,e:longint);\nvar zz,kol,i,rez:LongInt;\nz:array [1..10] of longint;\nbegin\n rez:=0;\n zz:=e;\n kol:=0;\n while n<>0 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]>6\n then begin\n if (z[i]<>7)\n then begin\n if i<>kol\n then rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-3)\n end\n else begin\n if i<>kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n dec(e);\n end;\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]);\n dec(e);\n end;\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if (e=0)and(i=1)\n then inc(rez);\n if (e<0)\n then begin\n Break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to i do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i7-1 then exit(f[i,j,small]);\n if i=1 then\n begin\n if j>0 then f[i,j,small]:=0 else f[i,j,small]:=1;\n exit(f[i,j,small]);\n end;\n if small then lim:=9 else lim:=digitof(m,i-1);\n f[i,j,small]:=0;\n if i=len+1 then d:=1 else d:=0;\n for d:=d to lim do\n if (d=4)or(d=7) then f[i,j,small]:=(f[i,j,small]+dp(i-1,j-1,small or (dc[i] then exit;\n cnt:=1;\n pp:=720;\n for i:=0 to maxn do\n if (p[i]>0)and(p[i]<=c[i]) then\n begin\n for j:=0 to p[i]-1 do cnt:=(cnt*(c[i]-j)) mod modulo;\n for j:=1 to p[i] do pp:=pp div j;\n end;\n cnt:=(cnt*pp) mod modulo;\n g:=(g+cnt) mod modulo;\nend;\n//--------------\nprocedure dfs(i,r:longint);\nvar\n j:longint;\nbegin\n if i=7 then\n begin\n if r=0 then ghi;\n exit;\n end;\n for j:=x[i-1] to r do\n begin\n x[i]:=j;\n dfs(i+1,r-j);\n end;\nend;\n//---------------\nprocedure init;\nvar\n i,j:longint;\n bo:boolean;\nbegin\n for i:=1 to maxn do\n for j:=0 to maxn do\n for bo:=false to true do f[i,j,bo]:=-1;\nend;\n//-----------------\nprocedure process;\nvar\n i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n p8[0]:=1;\n p2[0]:=1;\n p10[0]:=1;\n for i:=1 to maxn do\n begin\n p8[i]:=p8[i-1]*8;\n if p8[i]>=modulo then p8[i]:=p8[i]-modulo;\n p2[i]:=p2[i-1]*2;\n if p2[i]>=modulo then p2[i]:=p2[i]-modulo;\n p10[i]:=p10[i-1]*10;\n end;\n cc[0,0]:=1;\n for i:=1 to maxn do\n begin\n cc[i,0]:=1;cc[i,i]:=1;\n for j:=1 to i-1 do\n begin\n cc[i,j]:=cc[i-1,j]+cc[i-1,j-1];\n if cc[i,j]>=modulo then cc[i,j]:=cc[i,j]-modulo;\n end;\n end;\n for i:=1 to len-1 do\n begin\n c[0]:=c[0]+7*p8[i-1];\n c[i]:=c[i]+p2[i];\n for j:=1 to i-1 do\n begin\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j]) mod modulo)*((7*p8[i-j-1]) mod modulo)) mod modulo) mod modulo;\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j-1]) mod modulo)*p8[i-j]) mod modulo) mod modulo;\n end;\n end;\n for i:=0 to len do\n begin\n init;\n c[i]:=(c[i]+dp(len+1,i,false)) mod modulo;\n end;\n kq:=0;\n x[0]:=0;\n for len:=1 to len do\n begin\n g:=0;\n for i:=len-1 downto 0 do dfs(1,i);\n kq:=(kq+(g*c[len]) mod modulo) mod modulo;\n end;\n writeln(kq);\nend;\n//--------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "Var i,j,i1,i2,i3,i4,i5,i6,i7,n:Integer;\na,m:array [0..9] of int64;\nkol,rez:int64;\ndp:array [0..10,0..10] of LongInt;\nfunction stepen(e:longint):longint;\nVar i,rez:longint;\nbegin\n rez:=1;\n for i:=1 to e do\n rez:=rez*2;\n stepen:=rez;\nend;\nfunction st(e:longint):longint;\nVar i,rez:longint;\nbegin\n if e<0\n then begin st:=0; exit; end;\n rez:=1;\n for i:=1 to e do\n rez:=rez*8;\n st:=rez;\nend;\nfunction p(n,e:longint):longint;\nbegin\n p:=dp[n,e]*stepen(e);\nend;\nprocedure podchet(n,e:longint);\nvar zz,kol,i,rez:LongInt;\nz:array [1..10] of longint;\nbegin\n rez:=0;\n zz:=e;\n kol:=0;\n while n<>0 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]>6\n then begin\n if (z[i]<>7)\n then begin\n if i<>kol\n then rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-3)\n end\n else begin\n if i<>kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n dec(e);\n end;\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]);\n dec(e);\n end;\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if (e=0)and(i=1)\n then inc(rez);\n if (e<0)\n then begin\n Break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to i do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i7 -1 then exit( d[k, t, ok] );\n if (k = n) then\n begin\n if (t = 0) then d[k, t, ok] := 1 else d[k, t, ok] := 0;\n exit( d[k, t, ok] );\n end;\n tp := 0;\n if ok = 0 then r := 9\n else r := ord(st[k+1]) - ord('0');\n \n for p := 0 to r do\n begin\n if (p = 4) or (p = 7) then tn := t - 1 else tn := t;\n if (p = r) and (ok = 1) then okn := 1 else okn := 0;\n if tn >= 0 then\n inc( tp, recur(k+1, tn, okn) );\n end;\n \n d[k, t, ok] := tp;\n exit( tp );\nend;\n\nprocedure init;\nvar i, j : longint;\nbegin\n fillchar(d, sizeof(d), 255);\n for i := 0 to n do f[i, 1] := recur(0, i, 1);\n dec( f[0, 1] );\n for i := 0 to n do f[i, 0] := 1;\n\n for i := 0 to n do\n for j := 2 to 6 do\n f[i, j] := ( int64(f[i, 1] - j + 1) * f[i, j-1] ) mod oo;\nend;\n\nprocedure check;\nvar i, j : longint;\nbegin\n for i := 0 to n do\n begin\n for j := 0 to 6 do write(f[i, j], ' ');\n writeln;\n end;\nend;\n\nprocedure count;\nvar i, s : longint;\nbegin\n s := 1;\n for i := 0 to n do\n s := ( int64(s) * f[i, num[i]] ) mod oo;\n tmp := ( tmp + s ) mod oo;\nend;\n\nprocedure factor(k, t : longint);\nvar i : longint;\nbegin\n if k = 7 then\n begin\n if t = 0 then count;\n exit;\n end;\n for i := 0 to t do\n begin\n inc(num[i]);\n factor(k+1, t-i);\n dec(num[i]);\n end;\nend;\n\nprocedure main;\nvar i : longint;\nbegin\n for i := 1 to n do\n if f[i, 1] = 0 then break\n else\n begin\n factor(1, i-1);\n res := ( res + f[i, 1] * int64(tmp) ) mod oo;\n end;\n writeln(res);\nend;\n \nbegin\n assign(input, f1); reset(input);\n assign(output, f2); rewrite(output);\n read(st); n := length(st);\n init;\n //check;\n main;\nend.\n"}, {"source_code": "const\n f1 = '258b.inp';\n f2 = '258b.out';\n mxn = 10;\n oo = round(1e9) + 7;\nvar\n n : longint;\n res, tmp : longint;\n st : string;\n d : array [0..mxn, 0..mxn, 0..1] of longint;\n f : array [0..mxn, 0..mxn] of longint;\n num : array [0..mxn] of longint;\n\nfunction recur(k, t, ok : longint) : longint;\nvar tn, okn, p, r : longint;\n tp : longint;\nbegin\n if d[k, t, ok] <> -1 then exit( d[k, t, ok] );\n if (k = n) then\n begin\n if (t = 0) then d[k, t, ok] := 1 else d[k, t, ok] := 0;\n exit( d[k, t, ok] );\n end;\n tp := 0;\n if ok = 0 then r := 9\n else r := ord(st[k+1]) - ord('0');\n \n for p := 0 to r do\n begin\n if (p = 4) or (p = 7) then tn := t - 1 else tn := t;\n if (p = r) and (ok = 1) then okn := 1 else okn := 0;\n if tn >= 0 then\n inc( tp, recur(k+1, tn, okn) );\n end;\n \n d[k, t, ok] := tp;\n exit( tp );\nend;\n\nprocedure init;\nvar i, j : longint;\nbegin\n fillchar(d, sizeof(d), 255);\n for i := 0 to n do f[i, 1] := recur(0, i, 1);\n dec( f[0, 1] );\n for i := 0 to n do f[i, 0] := 1;\n\n for i := 0 to n do\n for j := 2 to 6 do\n f[i, j] := ( int64(f[i, 1] - j + 1) * f[i, j-1] ) mod oo;\nend;\n\nprocedure check;\nvar i, j : longint;\nbegin\n for i := 0 to n do\n begin\n for j := 0 to 6 do write(f[i, j], ' ');\n writeln;\n end;\nend;\n\nprocedure count;\nvar i, s : longint;\nbegin\n s := 1;\n for i := 0 to n do\n s := ( int64(s) * f[i, num[i]] ) mod oo;\n tmp := ( tmp + s ) mod oo;\nend;\n\nprocedure factor(k, t : longint);\nvar i : longint;\nbegin\n if k = 7 then\n begin\n if t = 0 then count;\n exit;\n end;\n for i := 0 to t do\n begin\n inc(num[i]);\n factor(k+1, t-i);\n dec(num[i]);\n end;\nend;\n\nprocedure main;\nvar i : longint;\nbegin\n for i := 1 to n do\n if f[i, 1] = 0 then break\n else\n begin\n factor(1, i-1);\n res := ( res + f[i, 1] * int64(tmp) ) mod oo;\n end;\n writeln(res);\nend;\n \nbegin\n// assign(input, f1); reset(input);\n// assign(output, f2); rewrite(output);\n read(st); n := length(st);\n init;\n //check;\n main;\nend.\n"}, {"source_code": "uses math;\n\nconst\tfi='';//'cf.inp';\n\t\tfo='';\n cs=1000000007;\ntype ma1=array[0..9]of longint;\n\nvar\tf,g:text;\t\n\t\tm,n:longint;\n ma:array[0..11,0..11,false..true]of int64;\n kt:array[0..11,0..11,false..true]of boolean;\n l:array[0..7,0..11]of int64;\n d:array[-1..10]of int64;\n c,luck:array[0..11]of longint;\n a:ma1;\n res:int64;\n\nprocedure mf;\nbegin\n\tassign(f,fi);reset(F);\n assign(g,fo);rewrite(G);\nend;\n\nprocedure df;\nbegin\n\tclose(f);close(G);\nend;\n\nprocedure nhap;\nvar s:string;i:longint;\nbegin\n\treadln(f,s);\n n:=length(s);\n for i:=1 to length(s) do c[i]:=ord(s[i])-48;\n luck[4]:=1;luck[7]:=1;\nend;\n\nfunction tinh(i,j:longint;ok:boolean):int64;\nvar tg,tam:int64;x,y:longint;\nbegin\n\tif ma[i,j,ok]<>-1 then exit(ma[i,j,ok]);\n if i>n then\n begin\n \tif j=0 then ma[i,j,ok]:=1 else ma[i,j,ok]:=0;\n kt[i,j,ok]:=false;\n exit(ma[i,j,ok]);\n end;\n ma[i,j,ok]:=0;\n for x:=0 to max(9*ord(ok),c[i]) do\n if not ((luck[x]=1) and (j=0)) then\n begin\n \ttam:=ma[i,j,ok];\n ma[i,j,ok]:=(ma[i,j,ok]+tinh(i+1,j-luck[x],ok or (x=cs);\t\n end;\n exit(ma[i,j,ok]);\nend;\n\nfunction tim(i,j:longint):int64;\nvar x:longint;tg,tam:int64;\nbegin\n\ttg:=0;\n if i=0 then\n \tbegin\n \tif j=0 then exit(1) else exit(0);\n end;\n for x:=0 to j do\n begin\n if not kt[1,x,false] then\n if a[x]>=ma[1,x,false]-ord(x=0) then continue;\n tam:=(ma[1,x,false]-ord(x=0)-a[x])mod cs;\n a[x]:=a[x]+1;\n tg:=(tg+tam*tim(i-1,j-x)) mod cs;\n a[x]:=a[x]-1;\n end;\n exit(tg);\t\t\nend;\n\nprocedure init;\nvar i,j,t:longint;x:int64;\nbegin\n\tfillchar(ma,sizeof(ma),255);\n for i:=0 to n do\n x:=tinh(1,i,false);\n for i:=0 to n-1 do\n d[i]:=d[i-1]+tim(6,i);\nend;\n\nprocedure xl;\nvar i,j:longint;\nbegin\n\tinit;\n for i:=1 to n do\n begin\n \tres:=(res+ma[1,i,false]*d[i-1]) mod cs;\n end;\n writeln(g,res);\nend;\n\nBEGIN\n\tmf;\n nhap;\n xl;\n df;\nEND."}, {"source_code": "{$apptype console}\n{$b-}\n{$maxstacksize 1000000}\nconst md=1000000007;\nvar\n a:array[0..10,0..10] of int64;\n b:array[1..7,0..10] of int64;\n cnk:array[0..10,-11..10] of int64;\n cc:array[0..10] of byte;\n ct,st,error,c,m,k,add,i,j:integer;\n add1,cur,ans:int64;\n s:string;\n\n Procedure gen(k,r:byte);\n var\n i,j:integer;\n begin\n inc(ct);\n if k>6 then\n begin\n add1:=cur;\n for i := 0 to 10 do if (cc[i]>0) then\n add1:=add1*cnk[i,cc[i]-1] mod md;\n ans:=(ans+add1) mod md;\n end else\n begin\n for j := 0 to r do\n begin\n inc(cc[j]);\n gen(k+1,r-j);\n dec(cc[j]);\n end;\n end;\n end;\n\nbegin\n ///reset(input,'input.txt');\n// rewrite(output,'output.txt');\n Fillchar(a,sizeof(a),0);\n a[1,1]:=2;\n a[1,0]:=7;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n readln(m);\n str(m,s);\n Fillchar(b,sizeof(b),0);\n for i := 0 to 10 do\n for j := 0 to length(s)-1 do\n b[1,i]:=(b[1,i]+a[j,i]) mod md;\n Fillchar(a,sizeof(a),0);\n\n a[1,1]:=2;\n a[1,0]:=8;\n a[0,0]:=1;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n\n add:=0;\n for i := 1 to length(s) do\n begin\n val(s[i],c,error);\n if (i=1) then st:=1 else st:=0;\n for j := st to c-1 do\n begin\n if (j=4) or (j=7) then inc(add);\n for k := add to length(s) do b[1,k]:=(b[1,k]+a[length(s)-i,k-add]) mod md;\n if (j=4) or (j=7) then dec(add);\n end;\n if (c=4) or (c=7) then inc(add);\n if (i=length(s)) then b[1,add]:=(b[1,add]+1) mod md;\n end;\n ans:=0;\n Fillchar(cc,sizeof(cc),0);\n Fillchar(cnk,sizeof(cnk),0);\n for i := 0 to 10 do cnk[i,0]:=b[1,i];\n for i := 0 to 10 do\n for j := 1 to 10 do cnk[i,j]:=(cnk[i,j-1]*(b[1,i]-j)) mod md;\n\n { for j :=0 to 10 do write(b[1,j],' ');\n writeln;\n writeln;\n\n for i := 0 to 10 do\n begin\n for j := 0 to 10 do write(cnk[i][j],' ');\n writeln;\n end; }\n\n for i := 1 to length(s) do\n begin\n cur:=b[1,i];\n gen(1,i-1);\n end;\n writeln(ans);\nend."}, {"source_code": "{$R+}\nvar\n cc,met:array [0..100] of int64;\n f:array [0..100,-1..100,0..1] of int64;\n md,n,m,k,d,nn:int64;\n c,kol,i,j,i1,i2,i3,i4,i5,i6:longint;\n ans:int64;\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x;\n x:=y;\n y:=c;\n end;\n\n function add(x1,x2,x3,x4,x5,x6,x7:int64):int64;\n var\n i,j:longint;\n res:int64;\n begin\n res:=1;\n for i:=0 to 11 do\n met[i]:=0;\n inc(met[x1]); inc(met[x2]); inc(met[x3]); inc(met[x4]); inc(met[x5]);\n inc(met[x6]); inc(met[x7]);\n for i:=0 to 10 do\n begin\n for j:=f[d,i,0]-met[i]+1 to f[d,i,0] do\n begin\n res:=(res*j) mod md;\n end;\n if res=0 then\n begin\n add:=0;\n exit;\n end;\n end;\n add:=(res mod md);\n end;\n\n\nbegin\n md:=1000000000+7;\n readln(n);\n nn:=n;\n while nn<>0 do\n begin\n inc(d);\n cc[d]:=nn mod 10;\n nn:=nn div 10;\n end;\n for i:=1 to d div 2 do\n swap(cc[i],cc[d-i+1]);\n\n f[0,0,1]:=1;\n for i:=1 to d do\n begin\n for kol:=0 to 10 do\n begin\n for c:=0 to 9 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,0]+f[i,kol,0]\n else f[i,kol,0]:=f[i-1,kol,0]+f[i,kol,0];\n end;\n for c:=0 to cc[i]-1 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,1]+f[i,kol,0]\n else f[i,kol,0]:=f[i,kol,0]+f[i-1,kol,1];\n end;\n if (cc[i]=4)or(cc[i]=7) then f[i,kol,1]:=f[i-1,kol-1,1]+f[i,kol,1]\n else f[i,kol,1]:=f[i,kol,1]+f[i-1,kol,1];\n end;\n end;\n for i:=0 to 10 do\n f[d,i,0]:=(f[d,i,0]+f[d,i,1])mod md;\n dec(f[d,0,0]);\n for i:=1 to d do\n begin\n for i1:=0 to i do\n for i2:=0 to i-i1 do\n for i3:=0 to i-i1-i2 do\n for i4:=0 to i-i1-i2-i3 do\n for i5:=0 to i-i1-i2-i3-i4 do\n for i6:=0 to i-i1-i2-i3-i4-i5 do\n begin\n if (i1+i2+i3+i4+i5+i6)>=i then continue;\n ans:=(ans+add(i,i1,i2,i3,i4,i5,i6))mod md;\n end;\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "const\n base=1000000007;\n\nvar\n cr,ct,res,i,j,k,c:longint;\n sn:ansistring;\n n:longint;\n f:array[0..15,0..2,0..15]of longint;\n a,u:array[0..15]of longint;\n \n procedure rec(t,x:longint);\n var\n i:longint;\n \n begin\n if (t<=0)then exit;\n if (x=8)then begin\n cr:=1;\n for i:=1 to 7 do begin\n ct:=u[a[i]];\n for j:=1 to i-1 do\n if (a[i]=a[j])then dec(Ct);\n if (ct<=0)then exit;\n cr:=int64(cr)*ct mod base;\n end;\n res:=(res+cr)mod base;\n exit;\n end;\n for i:=0 to 9 do begin\n a[x]:=i;\n rec(t-i,x+1);\n end;\n end;\n\nbegin\n read(n);\n str(n,sn);\n fillchar(f,sizeof(F),$0);\n f[1][0][0]:=1;\n for i:=1 to length(sn)do \n for j:=0 to 1 do \n for k:=0 to i do \n if (f[i][j][k]<>0)then begin\n if (j=0)then begin\n for c:=0 to ord(sn[i])-48 do \n inc(f[i+1][ord(c0 do\n begin\n inc(lenm);\n a[lenm]:=m mod 10;\n m:=m div 10;\n end;\n for i:=1 to lenm shr 1 do\n begin\n l:=a[i]; a[i]:=a[lenm-i+1]; a[lenm-i+1]:=l;\n end;\n\n fillchar(dp,sizeof(dp),0);\n for i:=1 to 9 do\n begin\n if (ia[1]) and not lucky(i) then inc(dp[1,0,2]);\n if (ia[1]) and lucky(i) then inc(dp[1,1,2]);\n end;\n for i:=1 to lenm-1 do\n for j:=0 to i do\n for k:=0 to 2 do\n if dp[i,j,k]>0 then\n for l:=0 to 9 do\n begin\n if k=0 then\n begin\n if lucky(l) then dp[i+1,j+1,k]:=dp[i+1,j+1,k] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,k]:=dp[i+1,j,k] + dp[i,j,k];\n end;\n\n if k=1 then\n begin\n if la[i+1] then\n begin\n if lucky(l) then dp[i+1,j+1,2]:=dp[i+1,j+1,2] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,2]:=dp[i+1,j,2] + dp[i,j,k];\n end;\n end;\n\n if k=2 then\n begin\n if lucky(l) then dp[i+1,j+1,k]:=dp[i+1,j+1,k] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,k]:=dp[i+1,j,k] + dp[i,j,k];\n end;\n end;\n fillchar(cnt,sizeof(cnt),0);\n for i:=1 to lenm-1 do\n for j:=0 to i do\n for k:=0 to 2 do cnt[j]:=(cnt[j]+dp[i,j,k])mod md;\n for j:=0 to lenm do\n for k:=0 to 1 do cnt[j]:=(cnt[j]+dp[lenm,j,k]) mod md;\n\n\n ans:=0;\n for i:=1 to lenm do ans:=(ans+cnt[i]*go(i,0))mod md;\n writeln(ans);\nend.\n"}, {"source_code": "const modulo = 1000000007;\nvar n:int64;\n f:array[0..33,0..33,0..3] of int64;\n zipher:array[0..33] of int64;\n i,j,k:longint;\n flag,q,cnt,next,flag2,cost,cnt1,cnt2,cnt3,cnt4,cnt5,cnt6,cnt7:longint;\n s:String;\n answer:int64;\n good:array[0..10] of int64;\n mas:array[0..10] of int64;\n qwe:array[0..100] of int64;\n\nfunction c(a,b:int64):int64;\nvar i,j:longint;\n cnt,cur:int64;\n answeR:int64;\nbegin\n answer:=1;\n for i:= b-a+1 to b do\n answer:=(answer*i) mod modulo;\n c:=answer;\nend;\n\n\n\nfunction fun(c1,c2,c3,c4,c5,c6,c7:int64):int64;\nvar answer:int64;\n i:longint;\nbegin\n fillchar(mas,sizeof(mas),0);\n mas[c1]:=mas[c1]+1;\n mas[c2]:=mas[c2]+1;\n mas[c3]:=mas[c3]+1;\n mas[c4]:=mas[c4]+1;\n mas[c5]:=mas[c5]+1;\n mas[c6]:=mas[c6]+1;\n mas[c7]:=mas[c7]+1;\n answer:=1;\n for i:= 0 to 10 do\n begin\n answer:=(answer*c(mas[i],good[i])) mod modulo;\n if answer = 0 then break;\n end;\n fun:=answer mod modulo;\nend;\n\n\n\nbegin\n readln(n);\n str(n,s);\n for i:= 1 to length(s) do zipher[i]:=ord(s[i])-ord('0');\n fillchar(f,sizeof(f),0);\n for i:= 1 to 9 do\n begin\n if i>zipher[1] then flag:=2 else\n if i=zipher[1] then flag:=1 else\n if izipher[i+1] then flag2:=2;\n end;\n cost:=cnt;\n if (next=4) or (Next=7) then inc(Cost);\n f[i+1][cost][flag2]:=f[i+1][cost][flag2]+f[i][cnt][flag];\n end;\n end;\n answer:=0;\n for i:= 1 to length(s) do\n for j:= 0 to length(s) do\n for k:= 0 to 2 do\n begin\n if (i=lengtH(s)) and (k=2) then continue;\n good[j]:=good[j]+f[i][j][k];\n end;\n answer:=0;\n for cnt1:= 1 to 9 do\n for cnt2:= 0 to cnt1 do\n for cnt3:= 0 to cnt1-cnt2 do\n for cnt4:= 0 to cnt1-cnt2-cnt3 do\n for cnt5:= 0 to cnt1-cnt2-cnt3-cnt4 do\n for cnt6:= 0 to cnt1-cnt2-cnt3-cnt4-cnt5 do\n for cnt7:= 0 to cnt1-cnt2-cnt3-cnt4-cnt5-cnt6 do\n begin\n if cnt1<=cnt2+cnt3+cnt4+cnt5+cnt6+cnt7 then continue;\n answer:=(answer+fun(cnt1,cnt2,cnt3,cnt4,cnt5,cnt6,cnt7)) mod modulo;\n end;\n writeln(answer);\nend."}, {"source_code": "const md = 1000000007;\nvar\nw,ans,s:int64;\nfact:array[0..1000]of int64;\np,u,i,j,n,m,t:longint;\ndp:array[0..100,0..100]of int64;\na:Array[0..100]of int64;\nc1,c2:array[0..100,0..100]of int64;\nfunction st(x,n:int64):int64;\nvar t:int64;\nbegin\n if n=0 then st:=1\n else\n begin\n if n mod 2=1 then st:=x*st(x,n-1) mod md\n else\n begin\n t:=st(x,n div 2);\n t:=t*t mod md;\n st:=t;\n end;\n end;\nend;\nfunction cnk(n,k:longint):int64;\nvar i:longint; d:int64;\nbegin\n d:=1;\n for i:=n-k+1 to n do\n begin\n d:=d*int64(i);\n d:=d mod md;\n end;\n d:=d*st(fact[k],md-2);\n d:=d mod md;\n cnk:=d;\nend;\nprocedure add(var a:int64; b:longint);\nbegin\n a:=a+b;\n a:=a mod md;\nend;\nfunction c(n:longint):int64;\nvar\nd,res:int64;\nlast,i,j,u:longint;\nbegin\n fillchar(c1,sizeof(c1),0);\n c1[0,0]:=1;\n for last:=0 to n-1 do\n begin\n fillchar(c2,sizeof(c2),0);\n for i:=0 to n-1 do\n for j:=0 to 6 do\n begin\n for u:=0 to 6-j do\n if (i+u*last=u) then\n begin\n d:=c1[i,j];\n d:=d*cnk(a[last],u) mod md;\n add(c2[i+u*last,j+u],d);\n end;\n end;\n for i:=0 to n-1 do\n for j:=0 to 6 do\n c1[i,j]:=c2[i,j];\n end;\n res:=0;\n for i:=0 to n-1 do\n res:=(res+c1[i,6]) mod md;\n c:=res;\nend;\nprocedure precalc;\nvar s:string;\nbegin\n dp[1,1]:=2;\n dp[1,0]:=8;\n\n for i:=2 to 9 do\n for j:=0 to i-1 do\n begin\n dp[i,j]:=dp[i,j]+dp[i-1,j]*8;\n dp[i,j+1]:=dp[i,j+1]+dp[i-1,j]*2;\n end;\n\n str(m,s);\n dp[0,0]:=1;\n for i:=1 to length(s)-1 do\n begin\n for u:=1 to 9 do\n begin\n if (u=4)or(u=7) then t:=1\n else t:=0;\n for j:=0 to i do\n a[j+t]:=a[j+t]+dp[i-1,j];\n end;\n end;\n t:=0;\n for i:=1 to length(s) do\n begin\n p:=1;\n if (i<>1) then p:=0;\n for u:=p to ord(s[i])-49 do\n begin\n if (u=4)or(u=7) then inc(t);\n for j:=0 to 10 do\n a[j+t]:=a[j+t]+dp[length(s)-i,j];\n if (u=4)or(u=7) then dec(t);\n end;\n if (s[i]='4')or(s[i]='7') then inc(t);\n end;\n inc(a[t]);\nend;\n begin\n fact[0]:=1;\n for i:=1 to 6 do\n fact[i]:=fact[i-1]*i;\n readln(m);\n w:=1;\n precalc;\n s:=a[0];\n for i:=1 to 10 do\n begin\n ans:=ans+a[i]*c(i);\n ans:=ans mod md;\n end;\n writeln(ans*720 mod md);\n end.\n"}, {"source_code": "{$R+,Q+,I+]\n{$apptype console}\n{$maxstacksize 10000000}\nUses SysUtils;\nVar\n i,j,k:Integer;\n m,md,f,t,ans,y:Int64;\n g,p,h,w,a:Array[0..300000] of Int64;\n dp:Array[0..10,-10..10,0..2] of Int64;\nProcedure Solve(i,sum,f:Integer);\nVar\n j,i1:Integer;\n r,pr:Int64;\nBegin\n If f=1 Then Begin\n If sum>=w[1] Then Exit;\n End;\n If i>7 Then Begin\n For j:=0 To y-1 Do h[j]:=0;\n For j:=2 To 7 Do h[w[j]]:=h[w[j]]+1;\n pr:=1;\n For i1:=0 To y-1 Do Begin\n r:=0;\n For j:=1 To h[i1] Do Begin\n pr:=(pr*(p[i1]-r)) mod md;\n r:=r+1;\n End;\n End;\n pr:=(pr*p[w[1]]) mod md;\n ans:=(ans+pr) mod md;\n Exit;\n End;\n For j:=0 To y Do Begin\n w[i]:=j;\n If i<>1 Then Solve(i+1,sum+j,1)\n Else Solve(i+1,sum,1);\n End;\nEnd;\nBegin\n Read(m);\n md:=1000000007;\n t:=m;\n i:=0;\n While t>0 Do Begin\n i:=i+1;\n t:=t div 10;\n End;\n y:=i;\n t:=m;\n i:=y;\n While t>0 Do Begin\n g[i]:=t mod 10;\n i:=i-1;\n t:=t div 10;\n End;\n If g[1]<>1 Then dp[1,0,0]:=1\n Else dp[1,0,1]:=1;\n For i:=2 To 9 Do Begin\n f:=0;\n If i=g[1] Then f:=1;\n If i<=g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1\n Else dp[1,1,f]:=dp[1,1,f]+1;\n End;\n If i>g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,2]:=dp[1,0,2]+1\n Else dp[1,1,2]:=dp[1,1,2]+1;\n End;\n End;\n For i:=2 To y Do\n For j:=0 To y Do Begin\n dp[i,j,0]:=dp[i-1,j,0];\n If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];\n dp[i,j,2]:=dp[i-1,j,2];\n If g[i]=0 Then dp[i,j,1]:=dp[i-1,j,1];\n For k:=1 To 9 Do Begin\n If (k<>4) and (k<>7) Then Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,1];\n End\n Else Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,1];\n End;\n If k=g[i] Then Begin\n If (k<>4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]\n Else dp[i,j,1]:=dp[i-1,j-1,1];\n End;\n End;\n End;\n For j:=0 To y Do\n For k:=1 To y Do\n If k<>y Then p[j]:=p[j]+dp[k,j,0]+dp[k,j,1]+dp[k,j,2]\n Else p[j]:=p[j]+dp[k,j,0]+dp[k,j,1];\n ans:=0;\n Solve(1,0,0);\n Write(ans);\nEnd.\n\n\n\n"}, {"source_code": "Uses Math;\nConst\n Fi = '';//ELECTION.INP';\n Fo = '';//ELECTION.OUT';\n Base = Trunc(1e9)+7;\n Maxcs = 11;\nType\n M1 = Array [0..Maxcs] of Longint;\n M2 = Array [0..Maxcs,-Maxcs..Maxcs,false..true,false..true] of Longint;\nVar\n f , g : Text;\n m : Longint;\n res , kq : Int64;\n num : String;\n a , x, dem : M1;\n fx : M2;\n\nProcedure Openfile;\nBegin\n Assign(f,fi);\n Reset(f);\n Assign(g,fo);\n Rewrite(g);\nEnd;\n\nProcedure Closefile;\nBegin\n Close(f);\n Close(g);\nEnd;\n\nProcedure Doc;\nBegin\n Readln(f,m);\nEnd;\n\nFunction Tinh(i , j : Longint; ok , ok2 : Boolean) : Longint;\nVar\n k , sum : Longint;\nBegin\n If fx[i,j,ok,ok2]<>-1 then exit(fx[i,j,ok,ok2]);\n If i>length(num) then\n Begin\n Fx[i,j,ok,ok2]:=ord((j=0) and ok2);\n Exit(fx[i,j,ok,ok2]);\n End;\n Sum:=0;\n For k:=0 to max(ord(num[i])-48,ord(ok)*9) do sum:=sum+tinh(i+1,j-ord((k=4) or (k=7)),ok or (k0));\n Fx[i,j,ok,ok2]:=sum;\n Exit(sum);\nEnd;\n\nProcedure Init;\nVar\n j : Longint;\nBegin\n Str(m,num);\n For j:=0 to length(num) do\n Begin\n Fillchar(fx,sizeof(fx),255);\n a[j]:=tinh(1,j,false,false);\n End;\nEnd;\n\nProcedure Capnhat(sl : Longint);\nVar\n i , j : Longint;\n t : Int64;\nBegin\n If sl=0 then\n Begin\n t:=1;\n For i:=0 to 9 do\n If dem[i]>0 then\n Begin\n For j:=0 to dem[i]-1 do t:=(t*(a[i]-j)) mod base;\n End;\n Kq:=(kq+t) mod base;\n End;\nEnd;\n\nProcedure Thu(i , j : Longint);\nVar\n k : Longint;\nBegin\n If i>6 then capnhat(j)\n Else\n For k:=0 to j do\n Begin\n x[i]:=k;\n Inc(dem[k]);\n Thu(i+1,j-k);\n Dec(dem[k]);\n End;\nEnd;\n\nProcedure Solve;\nVar\n i , j : Longint;\nBegin\n Res:=0;\n For i:=1 to length(num) do\n Begin\n Fillchar(x,sizeof(x),0);\n Fillchar(dem,sizeof(dem),0);\n kq:=0;\n For j:=0 to i-1 do\n Begin\n Thu(1,j);\n End;\n kq:=(kq*a[i]) mod base;\n Res:=(res+kq) mod base;\n End;\nEnd;\n\nProcedure Ghi;\nBegin\n If m<=7 then writeln(g,0)\n Else writeln(g,res);\nEnd;\n\nBegin\n Openfile;\n Doc;\n Init;\n Solve;\n Ghi;\n Closefile;\nEnd."}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\ninf = round(1e9);\nmaxn = round(1e5)+200;\nmd = round(1e9)+7;\nvar\nm,i,j,k,l,lenm : longint;\ndp : array [1..11,0..11,0..2] of int64;\ncnt : array [0..11] of int64;\na : array [1..11] of longint;\nans : int64;\n\nfunction lucky (x : longint) : boolean;\nbegin\n lucky:=(x=4) or (x=7);\nend;\n\nfunction go(sum,len : longint) : int64;\nvar\ni : longint;\nres : int64;\nbegin\n if len=6 then\n begin\n go:=1;\n exit;\n end;\n res:=0;\n for i:=0 to sum-1 do\n begin\n dec(cnt[i]);\n res:=res+((cnt[i]+1)*go(sum-i,len+1))mod md;\n inc(cnt[i]);\n end;\n go:=res;\nend;\n\nbegin\n //reset (input,'input.txt');\n //rewrite (output,'output.txt');\n readln(m);\n lenm:=0;\n while m>0 do\n begin\n inc(lenm);\n a[lenm]:=m mod 10;\n m:=m div 10;\n end;\n for i:=1 to lenm shr 1 do\n begin\n l:=a[i]; a[i]:=a[lenm-i+1]; a[lenm-i+1]:=l;\n end;\n\n fillchar(dp,sizeof(dp),0);\n for i:=1 to 9 do\n begin\n if (ia[1]) and not lucky(i) then inc(dp[1,0,2]);\n if (ia[1]) and lucky(i) then inc(dp[1,1,2]);\n end;\n for i:=1 to lenm-1 do\n for j:=0 to i do\n for k:=0 to 2 do\n if dp[i,j,k]>0 then\n for l:=0 to 9 do\n begin\n if k=0 then\n begin\n if lucky(l) then dp[i+1,j+1,k]:=dp[i+1,j+1,k] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,k]:=dp[i+1,j,k] + dp[i,j,k];\n end;\n\n if k=1 then\n begin\n if la[i+1] then\n begin\n if lucky(l) then dp[i+1,j+1,2]:=dp[i+1,j+1,2] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,2]:=dp[i+1,j,2] + dp[i,j,k];\n end;\n end;\n\n if k=2 then\n begin\n if lucky(l) then dp[i+1,j+1,k]:=dp[i+1,j+1,k] + dp[i,j,k];\n if not lucky(l) then dp[i+1,j,k]:=dp[i+1,j,k] + dp[i,j,k];\n end;\n end;\n \n fillchar(cnt,sizeof(cnt),0);\n for i:=1 to lenm-1 do\n for j:=0 to i do\n for k:=0 to 2 do cnt[j]:=(cnt[j]+dp[i,j,k])mod md;\n for j:=0 to lenm do\n for k:=0 to 1 do cnt[j]:=(cnt[j]+dp[lenm,j,k]) mod md;\n\n\n ans:=0;\n for i:=1 to lenm do ans:=(ans+cnt[i]*go(i,0))mod md;\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\nconst base=1000000000+7;\nvar m,top,tong:longint;\n st,c:array[0..10]of longint;\n dp:array[0..10,0..10]of longint;\n mang:array[0..10]of longint;\n ans:int64;\n\nfunction get(x,y:longint):longint;\nbegin\n get:=(x shr y) and 1;\nend;\n\nprocedure nhap;\nvar m2:longint;\nbegin\n assign(input,''); reset(input);\n fillchar(dp,sizeof(dp),0);\n readln(m); top:=0;\n while m<>0 do begin\n inc(top); st[top]:=m mod 10; m:=m div 10;\n end;\nend;\n\nprocedure solve;\nvar i,j,count,ans,t:longint;\nbegin\n dp[0,0]:=1;\n for i:=1 to min(9,top) do begin\n for j:=0 to (1 shl i)-1 do begin\n count:=0; ans:=1;\n for t:=1 to i do if get(j,t-1)=1 then begin\n inc(count); ans:=ans*2;\n end\n else ans:=ans*8;\n dp[i,count]:=dp[i,count]+ans;\n end;\n end;\nend;\n\nfunction combi(p,x:longint):int64;\nvar i:longint;\n combix:int64;\nbegin\n combix:=1;\n for i:=0 to x-1 do combix:=(combix*(p-i))mod base;\n combi:=combix;\nend;\n\nprocedure update(lab:longint);\nvar sum:int64;\n i:longint;\nbegin\n sum:=1;\n for i:=0 to 9 do begin\n sum:=(sum*combi(mang[i],c[i]))mod base;\n end;\n sum:=(sum*mang[lab])mod base;\n ans:=(ans+sum)mod base;\nend;\n\nprocedure pick(k,lab:longint);\nvar i:longint;\nbegin\n for i:=0 to 9 do begin\n if tong+i>=lab then exit;\n tong:=tong+i;\n inc(c[i]);\n if k=6 then update(lab) else pick(k+1,lab);\n dec(c[i]);\n tong:=tong-i;\n end;\nend;\n\nprocedure print;\nvar i,j,t,v,count,i1,i2,i3,i4,i5,i6:longint;\nbegin\n fillchar(mang,sizeof(mang),0); ans:=0; count:=0;\n for i:=top downto 1 do begin\n for j:=st[i]-1 downto 0 do begin\n if (j=4)or(j=7) then inc(count);\n for t:=0 to 9 do if (t+count<=9)\n then mang[t+count]:=mang[t+count]+dp[i-1,t];\n if (j=4)or(j=7) then dec(count);\n end;\n if (st[i]=4)or(st[i]=7) then inc(count);\n end;\n inc(mang[count]); dec(mang[0]);\n for i:=0 to 9 do begin\n tong:=0; fillchar(c,sizeof(c),0);\n pick(1,i);\n end;\n writeln(ans);\nend;\n\nbegin\n nhap;\n solve;\n print;\nend.\n"}, {"source_code": "const\n md = 1000000007;\nvar\n cur, res : int64;\n n, i, j, k, l, r, m : longint;\n d : array [0..100001,0..9] of longint;\n a, b, col, c, kol : array [0..100001] of longint;\n\nprocedure goes(len, sz, sum : longint);\nvar\n ans : int64;\n u : longint;\nbegin\n if (len > 6) then begin\n ans := 1;\n\n// writeln(sum,' ',sz);\n // for k := 0 to 9 do write(col[k],' ');\n // writeln;\n\n for k := 1 to 6 do\n ans := ans * c[k] mod md;\n\n res := (res + ans) mod md;\n\n exit;\n end;\n for u := 0 to sz-1 do\n if (a[u] > col[u]) and (sum+u < sz) then begin\n b[len] := u;\n c[len] := a[u]-col[u];\n col[u] := col[u] + 1;\n goes(len+1, sz, sum+u);\n col[u] := col[u] - 1;\n end;\n end;\nfunction go(x : longint) : longint;\nvar \n y : longint;\nbegin\n y := 0;\n while (x > 0) do begin\n if (x mod 10 = 4) or (x mod 10 = 7) then inc(y);\n x := x div 10;\n end;\n go := y;\nend; \nbegin\n read(n); d[0][0] := 1;\n\n for i := 1 to 99999 do begin\n for j := 0 to 5 do \n d[i][j] := d[i-1][j];\n kol[i] := go(i); \n inc(d[i][kol[i]]);\n end;\n \n for i := 0 to 99999 do begin\n l := 0; r := 9999; cur := -1;\n while (l <= r) do begin\n m := (l+r) shr 1;\n if (i*10000+m <= n) then begin\n l := m+1;\n cur := m;\n end\n else r := m-1; \n end; \n if (cur <> -1) then\n for j := 0 to 4 do \n inc(a[j+kol[i]], d[cur][j]); \n end;\n \n// for i := 0 to 9 do write(a[i], ' ');\n if (n = 1000000000) then inc(a[0]);\n dec(a[0]);\n cur := 0;\n for i := 1 to 9 do begin\n res := 0;\n goes(1, i, 0);\n// writeln(res);\n cur := (cur + res*a[i]) mod md;\n end; \n write(cur);\nend."}, {"source_code": "const md=1000000000+7;\nVar ans,tt,sum,n,x,res:int64;\n f:array[0..12,0..12,boolean]of int64;\n i,j,len,u,d,mx:longint;\n s:string;\n g,fact,rev,q:array[0..1234]of int64;\n w:boolean;\n function pow(a,b:int64):int64;\n begin\n if b=0 then exit(1);\n if b mod 2=1 then pow:=pow(a,b-1)*a mod md\n else begin a:=a*a mod md;pow:=pow(a,b div 2);end;\n end;\n procedure rec(x,sum:longint;tmp:int64;pp:longint);\n var i:longint;\n begin\n if sum>len then exit;\n if x=len then\n begin\n if pp<>6 then exit;\n for i:=sum+1 to len do\n ans:=(ans+tmp*g[i])mod md;\n exit;\n end;\n for i:=0 to 6-pp do\n if g[x]>=i then\n begin\n tt:=tmp;\n for j:=g[x] downto g[x]-i+1 do\n tt:=(tt*int64(j)) mod md;\n tt:=tt*rev[fact[i]] mod md;\n rec(x+1,sum+i*x,tt,pp+i);\n end;\n end;\n begin\n read(n);\n rev[0]:=1;\n for i:=1 to 1000 do\n rev[i]:=pow(i,md-2);\n fact[0]:=1;\n for i:=1 to 7 do\n fact[i]:=fact[i-1]*i;\n\n str(n+1,s);\n len:=length(s);\n f[0,0,false]:=1;\n for i:=1 to len do\n for j:=0 to len do\n for w:=false to true do\n begin\n if w then mx:=9\n else mx:=ord(s[i])-48;\n for d:=0 to mx do\n f[i,j+ord((d=4)or(d=7)),w or (d0 do\n begin\n inc(m); a[m]:=x mod 10;\n x:=x div 10;\n end;\nend;\n\nfunction mu(x,k:longint):longint;\nvar t:int64;\nbegin\n if (k=1) then exit(x);\n t:=mu(x,k div 2);\n t:=t*t mod base;\n if odd(k) then t:=t*x mod base;\n exit(t);\nend;\n\nprocedure prepare;\nvar i,j,k,t,dem,x,y:longint;\nbegin\n f[1,0]:=7;\n f[1,1]:=2;\n f[0,0]:=1;\n slcs(n);\n for i:=2 to m-1 do\n for j:=0 to i do\n begin\n x:=int64(f[i-1,j-1])*2;\n y:=int64(8)*f[i-1,j];\n f[i,j]:=x+y;\n n:=n;\n end;\n for i:=1 to m-1 do\n for j:=0 to i do s[j]:=s[j]+f[i,j];\n dem:=0;\n for i:=m downto 1 do\n begin\n if i=m then x:=1 else x:=0;\n for j:=x to a[i]-1 do\n if (j=4) or (j=7) then\n begin\n for k:=dem+1 to 9 do\n for t:=0 to i-1 do s[k]:=s[k]+f[t,k-dem-1];\n end else\n begin\n for k:=dem to 9 do //s[k]:=s[k]+f[i-1,k-dem];\n for t:=0 to i-1 do s[k]:=s[k]+f[t,k-dem];\n end;\n if (a[i]=4) or (a[i]=7) then inc(dem);\n end;\n inc(s[dem]);\n gt[0]:=1; val[0]:=1;\n for i:=1 to 6 do gt[i]:=int64(gt[i-1])*i mod base;\n for i:=1 to 6 do val[i]:=mu(gt[i],base-2);\nend;\n\nfunction c(n,k:longint):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=n-k+1 to n do s:=int64(s)*i mod base;\n s:=int64(s)*val[k] mod base;\n exit(s);\nend;\n\nprocedure update(x:longint);\nvar i,j:longint;\nbegin\n j:=0;\n for i:=0 to x-1 do j:=j+a[i];\n if (j<>6) then exit;\n j:=0;\n for i:=0 to x-1 do j:=j+int64(a[i])*i;\n if j>=x then exit;\n j:=1;\n for i:=0 to x-1 do j:=int64(j)*c(s[i],a[i]) mod base;\n j:=int64(j)*gt[6] mod base;\n sum:=(sum+j) mod base;\nend;\n\nprocedure trying(i,x,k:longint);\nvar j:longint;\nbegin\n if (i>x-1) then\n begin\n update(x);\n exit;\n end;\n //if i=0 then k:=6 else k:=x-1;\n for j:=0 to k do\n begin\n a[i]:=j;\n trying(i+1,x,k-j);\n a[i]:=0;\n end;\nend;\n\nprocedure lam(x:longint);\nvar i,j,k:longint;\nbegin\n sum:=0;\n trying(0,x,6);\n kq:=(kq+int64(s[x])*sum mod base) mod base\nend;\n\nprocedure process;\nvar i:longint;\nbegin\n for i:=1 to m do\n if s[i]>0 then lam(i);\n writeln(kq);\nend;\n\nprocedure check;\nvar i,j,dem:longint;\nbegin\n for i:=0 to m do write(s[i],' '); writeln;\n fillchar(s,sizeof(s),0);\n for i:=1 to n do\n begin\n j:=i; dem:=0;\n while j>0 do\n begin\n if (j mod 10=4) or (j mod 10=7) then inc(dem);\n j:=j div 10;\n end;\n inc(s[dem]);\n //if dem=0 then writeln('g',' ',i);\n end;\n for i:=0 to m do write(s[i],' '); writeln;\nend;\n\nBEGIN\n openfile;\n enter;\n prepare;\n process;\n //check;\n closefile;\nEND."}, {"source_code": "uses math;\nconst\n nmax = 100;\n modul = 1000000007;\nvar\n n,m:longint;\n a:string;\n kq,f:Array[0..10,0..1,0..10 ]of longint;\n sl,s:array[0..10] of longint;\n Sol,Res:int64;\nfunction Cal(i,ok,j:longint):longint;\nvar cs,bd,kt,ok1:longint;\nx:longint;\nbegin\n if i>length(a) then exit(ord(j=0));\n if kq[i][ok][j]=n then exit(f[i][ok][j]);\n bd:=0;\n x:=0;\n if ok=0 then kt:=ord(a[i])-48 else kt:=9;\n for cs:=bd to kt do\n if (cs<>4)and(cs<>7) then\n begin\n if (ok=0)and(cs=ord(a[i])-48) then ok1:=0 else ok1:=1;\n x:=x+Cal(i+1,ok1,j);\n end else if j>0 then\n begin\n if (ok=0)and(cs=ord(a[i])-48) then ok1:=0 else ok1:=1;\n x:=x+Cal(i+1,ok1,j-1);\n end;\n kq[i][ok][j]:=n;\n f[i][ok][j]:=x;\n exit(x);\nend;\nprocedure perfect(t:longint);\nvar i,j:longint;\nbegin\n res:=0;\n for i:=t+1 to length(a) do res:=res+sl[i];\n for i:=0 to length(a) do\n for j:=1 to s[i] do\n res:=(res*(sl[i]-j+1))mod modul;\n Sol:=(Sol+Res)mod modul;\nend;\nprocedure DFS(i,t:longint);\nvar j:longint;\nbegin\n if t>=length(a) then exit;\n if i>6 then\n begin\n perfect(t);\n exit;\n end;\n for j:=0 to length(a) do if s[j]6 then exit;\n if j>l then exit;\n\n if k=6 then begin\n for i:=1 to 6 do\n p:=p*int64(i) mod md;\n\n for i:=t+1 to l do\n ans:=(ans+w[i]*p) mod md;\n exit;\n end;\n\n for i:=0 to 6-k do\n begin\n if i<=w[j] then begin\n tt(j+1,k+i,t+i*j,(p*pp(w[j],i) mod md)*f[i] mod md);\n end\n else break;\n end;\n\n end;\n\n begin\n read(n);\n str(n,s);\n l:=length(s);\n for i:=1 to l do\n val(s[i],a[i],p);\n\n v[0,0,0]:=1;\n for i:=1 to l do\n for j:=0 to 1 do\n for k:=0 to l do\n begin\n if v[i-1,j,k]=0 then continue;\n\n if j=1 then x:=9\n else x:=a[i];\n\n for y:=0 to x do\n begin\n if (y<>4) and\n (y<>7) then t:=k\n else t:=k+1;\n\n if (y6 then\n begin\n add1:=cur;\n for i := 0 to 10 do if (cc[i]>0) then\n add1:=add1*cnk[i,cc[i]-1] mod md;\n ans:=(ans+add1) mod md;\n end else\n begin\n for j := 0 to r do\n begin\n inc(cc[j]);\n gen(k+1,r-j);\n dec(cc[j]);\n end;\n end;\n end;\n\nbegin\n ///reset(input,'input.txt');\n// rewrite(output,'output.txt');\n Fillchar(a,sizeof(a),0);\n a[1,1]:=2;\n a[1,0]:=7;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n readln(m);\n str(m,s);\n Fillchar(b,sizeof(b),0);\n for i := 0 to 10 do\n for j := 0 to length(s)-1 do\n b[1,i]:=(b[1,i]+a[j,i]) mod md;\n Fillchar(a,sizeof(a),0);\n\n a[1,1]:=2;\n a[1,0]:=8;\n a[0,0]:=1;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n\n add:=0;\n for i := 1 to length(s) do\n begin\n val(s[i],c,error);\n if (i=1) then st:=1 else st:=0;\n for j := st to c-1 do\n begin\n if (j=4) or (j=7) then inc(add);\n for k := add to length(s) do b[1,k]:=(b[1,k]+a[length(s)-i,k-add]) mod md;\n if (j=4) or (j=7) then dec(add);\n end;\n if (c=4) or (c=7) then inc(add);\n if (i=length(s)) then b[1,add]:=(b[1,add]+1) mod md;\n end;\n ans:=0;\n Fillchar(cc,sizeof(cc),0);\n Fillchar(cnk,sizeof(cnk),0);\n for i := 0 to 10 do cnk[i,0]:=b[1,i];\n for i := 0 to 10 do\n for j := 1 to 10 do cnk[i,j]:=(cnk[i,j-1]*(b[1,i]-j)) mod md;\n\n { for j :=0 to 10 do write(b[1,j],' ');\n writeln;\n writeln;\n\n for i := 0 to 10 do\n begin\n for j := 0 to 10 do write(cnk[i][j],' ');\n writeln;\n end; }\n\n for i := 1 to length(s) do\n begin\n cur:=b[1,i];\n gen(1,i-1);\n end;\n writeln(ans);\nend."}, {"source_code": "{$R+,Q+,I+]\n{$apptype console}\n{$maxstacksize 10000000}\nUses SysUtils;\nVar\n i,j,k:Integer;\n m,md,f,t,ans,y:Int64;\n g,p,h,w,a:Array[0..300000] of Int64;\n dp:Array[0..10,-10..10,0..2] of Int64;\nProcedure Solve(i,sum,f:Integer);\nVar\n j,i1:Integer;\n r,pr:Int64;\nBegin\n If f=1 Then Begin\n If sum>=w[1] Then Exit;\n End;\n If i>7 Then Begin\n For j:=0 To y-1 Do h[j]:=0;\n For j:=2 To 7 Do h[w[j]]:=h[w[j]]+1;\n pr:=1;\n For i1:=0 To y-1 Do Begin\n r:=0;\n For j:=1 To h[i1] Do Begin\n pr:=(pr*(p[i1]-r)) mod md;\n r:=r+1;\n End;\n End;\n pr:=(pr*p[w[1]]) mod md;\n ans:=(ans+pr) mod md;\n Exit;\n End;\n For j:=0 To y Do Begin\n w[i]:=j;\n If i<>1 Then Solve(i+1,sum+j,1)\n Else Solve(i+1,sum,1);\n End;\nEnd;\nBegin\n Read(m);\n md:=1000000007;\n t:=m;\n i:=0;\n While t>0 Do Begin\n i:=i+1;\n t:=t div 10;\n End;\n y:=i;\n t:=m;\n i:=y;\n While t>0 Do Begin\n g[i]:=t mod 10;\n i:=i-1;\n t:=t div 10;\n End;\n If g[1]<>1 Then dp[1,0,0]:=1\n Else dp[1,0,1]:=1;\n For i:=2 To 9 Do Begin\n f:=0;\n If i=g[1] Then f:=1;\n If i<=g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1\n Else dp[1,1,f]:=dp[1,1,f]+1;\n End;\n If i>g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,2]:=dp[1,0,2]+1\n Else dp[1,1,2]:=dp[1,1,2]+1;\n End;\n End;\n For i:=2 To y Do\n For j:=0 To y Do Begin\n dp[i,j,0]:=dp[i-1,j,0];\n If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];\n dp[i,j,2]:=dp[i-1,j,2];\n If g[i]=0 Then dp[i,j,1]:=dp[i-1,j,1];\n For k:=1 To 9 Do Begin\n If (k<>4) and (k<>7) Then Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,1];\n End\n Else Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,1];\n End;\n If k=g[i] Then Begin\n If (k<>4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]\n Else dp[i,j,1]:=dp[i-1,j-1,1];\n End;\n End;\n End;\n For j:=0 To y Do\n For k:=1 To y Do\n If k<>y Then p[j]:=p[j]+dp[k,j,0]+dp[k,j,1]+dp[k,j,2]\n Else p[j]:=p[j]+dp[k,j,0]+dp[k,j,1];\n ans:=0;\n Solve(1,0,0);\n Write(ans);\nEnd.\n\n\n\n"}, {"source_code": "const\n md=round(1e9)+7;\nvar\n dp:array[0..10,0..10,0..1] of int64;\n cnt,res,a:array[0..10] of int64;\n ans,m,i,j,k,x,next,ni,nx,nj:longint;\n\nprocedure solve(nom,k,sum:longint;num:int64);\nvar\n i:longint;\nbegin\n if (nom=7) then\n begin\n res[k]:=res[k]+num;\n if (res[k]>=md) then res[k]:=res[k]-md;\n exit;\n end;\n for i:=0 to 9 do if (cnt[i]<>0) then\n begin\n if (sum+i>=k) then break;\n dec(cnt[i]);\n solve(nom+1,k,sum+i,(num*(cnt[i]+1)) mod md);\n inc(cnt[i]);\n end;\nend;\n\nbegin\n readln(m);\n for k:=1 to 10 do\n begin\n a[k]:=m mod 10;\n m:=m div 10;\n if (m=0) then break;\n end;\n for i:=1 to k do\n begin\n j:=k-i+1;\n if (i>j) then break;\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n end;\n dp[0,0,0]:=1;\n for i:=0 to k-1 do for j:=0 to k do for x:=0 to 1 do\n begin\n if (dp[i,j,x]=0) then continue;\n ni:=i+1;\n for next:=0 to 9 do\n begin\n if (x=1) then nx:=1 else\n begin\n if (nexta[ni]) then continue;\n end;\n nj:=j;\n if (next=4) or (next=7) then inc(nj);\n dp[ni,nj,nx]:=dp[ni,nj,nx]+dp[i,j,x];\n if (dp[ni,nj,nx]>=md) then dp[ni,nj,nx]:=dp[ni,nj,nx]-md;\n end;\n end;\n for j:=0 to k do for x:=0 to 1 do cnt[j]:=(cnt[j]+dp[k,j,x]) mod md;\n dec(cnt[0]);\n for i:=0 to 9 do\n begin\n if (cnt[i]=0) then continue;\n dec(cnt[i]);\n solve(1,i,0,1);\n inc(cnt[i]);\n end;\n for i:=0 to 9 do ans:=(ans+cnt[i]*res[i]) mod md;\n writeln(ans);\nend."}, {"source_code": "program problem2;\n\nconst\tmd =\t1000000007;\n\nvar\trev: array[ 1..10 ] of longInt;\n\nfunction pow( a, p: longInt ): longInt;\nvar\tres: longInt;\nbegin\n\tres := 1;\n\twhile ( p > 0 ) do\n\tbegin\n\t\tif ( odd(p) ) then\n\t\t\tres := ( res * int64(a) ) mod md;\n\t\t\t\n\t\ta := ( a * int64(a) ) mod md;\n\t\tp := p div 2;\n\tend;\n\t\n\texit( res );\nend;\n\nfunction c( n, k: longInt ): longInt;\nvar\ti: longInt;\n\tres: int64;\nbegin\n\tres := 1;\n\tfor i := 1 to k do\n\t\tres := ( ( ( res * (n-i+1) ) mod md ) * rev[i] ) mod md;\n\t\t\n\texit( res );\nend;\n\nvar\ti, j, k, l, ans, j1, k1, l1: longInt;\n\tcnt: array[ 0..10 ] of longInt;\n\tdp: array[ 1..10, 0..6, 0..10, -1..10 ] of int64;\n\tpow8: array[ 0..10 ] of longInt;\n\tm: ansistring;\n\nbegin\n\tfillchar( cnt, sizeOf(cnt), 0 );\n\tfillchar( dp, sizeOf(dp), 0 );\n\t\n\tfor i := 1 to 10 do\n\t\trev[i] := pow( i, ( md - 2 ) );\n\t\t\t\n\tpow8[0] := 1;\n\tfor i := 1 to 9 do\n\t\tpow8[i] := pow8[i-1] * 8;\n\n\treadln( m );\n\t\n\tl := 0;\n\tfor i := 1 to length( m ) do\n\tbegin\n\t\tfor j := 0 to ( ord( m[i] ) - ord( '0' ) - 1 ) do\n\t\t\tfor k := 0 to ( length(m) - i ) do\n\t\t\t\tif ( j = 4 ) or ( j = 7 ) then\n\t\t\t\t\tinc( cnt[l+k+1], ( c( ( length(m) - i ), k ) * ( 1 shl k ) * pow8[ length(m) - i - k ] ) )\n\t\t\t\telse\n\t\t\t\t\tinc( cnt[l+k], ( c( ( length(m) - i ), k ) * ( 1 shl k ) * pow8[ length(m) - i - k ] ) );\n\t\t\t\t\t\n\t\tif ( m[i] = '4' ) or ( m[i] = '7' ) then\n\t\t\tinc( l );\n\tend;\n\tinc( cnt[l] );\n\tdec( cnt[0] );\n{\n\tfor i := 0 to 10 do\n\t\twriteln( i, ': ', cnt[i] );\n}\n\tfor i := 1 to 10 do\n\tbegin\n\t\tdp[i][0][0][-1] := cnt[i];\n\t\tfor j := 0 to 6 do\n\t\t\tfor k := 0 to (i-1) do\n\t\t\t\tfor l := 0 to 10 do\n\t\t\t\t\tfor j1 := 0 to j do\n\t\t\t\t\t\tif ( k >= ( j1 * l ) ) then\n\t\t\t\t\t\t\tdp[i][j][k][l] := ( dp[i][j][k][l] + ( dp[i][j-j1][ k - (j1*l) ][l-1] * c( cnt[l], j1 ) ) ) mod md;\n\tend;\n\t\n\tans := 0;\n\tfor i := 1 to 10 do\n\t\tfor k := 0 to (i-1) do\n\t\t\tans := ( ans + dp[i][6][k][10] ) mod md;\n\t\t\t\n\tans := ( ans * int64(720) ) mod md;\n\t\t\t\n\twriteln( ans );\nend.\n"}, {"source_code": "const md = 1000000007;\nvar\n f : array[0..15,0..15,0..1] of longint;\n ff : array[0..15,0..15] of longint;\n fk : array[-5..15] of int64;\n w : array[0..15] of int64;\n i,j,n,k,z,q,ii,ss,sum : longint;\n m : ansistring;\n s,s1,s2,ans : int64;\n c,v : char;\n\n function ch(k,w : int64) : int64;\n var\n ans : int64;\n begin\n if w = 0 then exit(1);\n ans:=1;\n while w > 0 do begin\n ans:=ans*k mod md;\n dec(k);\n dec(w);\n end;\n exit(ans);\n end;\n procedure rec(v : longint);\n var\n sk : int64;\n i : longint;\n begin\n if ss >= sum then exit;\n if v = 6 then begin\n sk:=1;\n for i:=0 to sum do sk:=sk*ch(fk[i],w[i]) mod md;\n ans:=(ans+sk*fk[sum] mod md) mod md;\n exit;\n end;\n for i:=0 to sum do begin\n inc(w[i]);\n ss:=ss+i;\n rec(v+1);\n ss:=ss-i;\n dec(w[i]);\n end;\n end;\n\nbegin\n readln(m);\n if m = '7' then begin writeln(0); halt; end;\n for ii:=length(m) downto 1 do begin\n fillchar(f,sizeof(f),0);\n if ii > 1 then f[ii-1,0,1]:=1 else f[ii-1,0,0]:=1;\n for i:=ii-1 to length(m)-1 do\n for k:=0 to 9 do\n for z:=0 to 1 do if (f[i,k,z] > 0) then begin\n if z = 0 then c:=m[i+1] else c:='9';\n if (i = ii-1) then v:='1' else v:='0';\n for c:=v to c do begin\n if (c = '4') or (c = '7') then q:=1 else q:=0;\n f[i+1,k+q,z or ord(ord(c) < ord(m[i+1]))]:=f[i+1,k+q,z or ord(ord(c) < ord(m[i+1]))]+f[i,k,z];\n end;\n end;\n for k:=0 to 9 do ff[length(m)-ii+1,k]:=f[length(m),k,0]+f[length(m),k,1];\n end;\n n:=length(m);\n ans:=1;\n for i:=0 to n do for j:=1 to n do fk[i]:=fk[i]+ff[j,i];\n for sum:=n downto 1 do rec(0);\n //ans:=(ans+fk[1]*ch(fk[0],6)) mod md;\n writeln((ans-1+md) mod md);\nend.\n"}, {"source_code": "const\n base=1000000007;\n\nvar\n cr,ct,res,i,j,k,c:longint;\n sn:ansistring;\n n:longint;\n f:array[0..15,0..2,0..15]of longint;\n a,u:array[0..15]of longint;\n \n procedure rec(t,x:longint);\n var\n i:longint;\n \n begin\n if (t<=0)then exit;\n if (x=8)then begin\n cr:=1;\n for i:=1 to 7 do begin\n ct:=u[a[i]];\n for j:=1 to i-1 do\n if (a[i]=a[j])then dec(Ct);\n if (ct<=0)then exit;\n cr:=int64(cr)*ct mod base;\n end;\n res:=(res+cr)mod base;\n exit;\n end;\n for i:=0 to 9 do begin\n a[x]:=i;\n rec(t-i,x+1);\n end;\n end;\n\nbegin\n read(n);\n str(n,sn);\n fillchar(f,sizeof(F),$0);\n f[1][0][0]:=1;\n for i:=1 to length(sn)do \n for j:=0 to 1 do \n for k:=0 to i do \n if (f[i][j][k]<>0)then begin\n if (j=0)then begin\n for c:=0 to ord(sn[i])-48 do \n inc(f[i+1][ord(c 1 then f[ii-1,0,1]:=1 else f[ii-1,0,0]:=1;\n for i:=ii-1 to length(m)-1 do\n for k:=0 to 9 do\n for z:=0 to 1 do if (f[i,k,z] > 0) then begin\n if z = 0 then c:=m[i+1] else c:='9';\n if (i = 0) then v:='1' else v:='0';\n for c:=v to c do begin\n if (c = '4') or (c = '7') then q:=1 else q:=0;\n f[i+1,k+q,z or ord(ord(c) < ord(m[i+1]))]:=f[i+1,k+q,z or ord(ord(c) < ord(m[i+1]))]+f[i,k,z];\n end;\n end;\n for k:=0 to 9 do ff[length(m),k]:=f[length(m),k,0]+f[length(m),k,1];\n end;\n for i:=0 to length(m) do begin\n s:=0;\n for j:=1 to length(m) do s:=(s+int64(ff[j,i])) mod md;\n fk[i]:=(fk[i-1]+s) mod md;\n end;\n for i:=length(m) downto 1 do begin\n s1:=fk[i]-fk[i-1];\n ans:=(ans+((chk(fk[i-1])*s1)) mod md) mod md;\n end;\n writeln(ans mod md);\nend.\n"}, {"source_code": "program election;\n\nconst\n fi='';\n fo='';\n maxn = 12;\n modulo = trunc(1e9)+7;\nvar\n m:longint; len:longint;\n f:array[1..maxn,0..maxn,false..true,false..true] of int64;\n c:array[0..maxn] of int64;\n p8,p2,p10:array[0..maxn] of int64;\n cc:array[0..maxn,0..maxn] of int64;\n x:array[1..6] of longint;\n p:array[0..maxn] of longint;\n kq,g:int64;\nprocedure openfile;\nvar\n st:string;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(m);\n str(m,st);\n len:=length(st);\nend;\n//---------------\nfunction digitof(n,i:longint):longint; inline;\nbegin\n exit((n div p10[i-1]) mod 10);\nend;\n//--------------\nfunction dp(i,j:longint;small,posi:boolean):int64;\nvar\n d,lim:longint;\nbegin\n if j<0 then exit(0);\n if f[i,j,small,posi]>0 then exit(f[i,j,small,posi]);\n if i=1 then\n begin\n if j>0 then f[i,j,small,posi]:=0 else f[i,j,small,posi]:=1;\n exit(f[i,j,small,posi]);\n end;\n if small then lim:=9 else lim:=digitof(m,i-1);\n f[i,j,small,posi]:=0;\n if posi then\n begin\n for d:=1 to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end\n else\n begin\n for d:=1 to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end;\n exit(f[i,j,small,posi]);\nend;\n//---------------\nprocedure ghi;\nvar\n i,j:longint;\n cnt:int64;\nbegin\n fillchar(p,sizeof(p),0);\n for i:=1 to 6 do inc(p[x[i]]);\n for i:=0 to maxn do\n if p[i]>c[i] then exit;\n for i:=0 to maxn do\n if (p[i]>0)and(p[i]<=c[i]) then\n begin\n cnt:=1;\n for j:=0 to p[i]-1 do cnt:=(cnt*(c[i]-j)) mod modulo;\n g:=(g+cnt) mod modulo;\n end;\nend;\n//--------------\nprocedure dfs(i,r:longint);\nvar\n j:longint;\nbegin\n if i=7 then\n begin\n if r=0 then ghi;\n exit;\n end;\n for j:=0 to r do\n begin\n x[i]:=j;\n dfs(i+1,r-j);\n end;\nend;\n//---------------\nprocedure process;\nvar\n i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n p8[0]:=1;\n p2[0]:=1;\n p10[0]:=1;\n for i:=1 to maxn do\n begin\n p8[i]:=p8[i-1]*8;\n if p8[i]>=modulo then p8[i]:=p8[i]-modulo;\n p2[i]:=p2[i-1]*2;\n if p2[i]>=modulo then p2[i]:=p2[i]-modulo;\n p10[i]:=p10[i-1]*10;\n end;\n cc[0,0]:=1;\n for i:=1 to maxn do\n begin\n cc[i,0]:=1;cc[i,i]:=1;\n for j:=1 to i-1 do\n begin\n cc[i,j]:=cc[i-1,j]+cc[i-1,j-1];\n if cc[i,j]>=modulo then cc[i,j]:=cc[i,j]-modulo;\n end;\n end;\n for i:=1 to len-1 do\n begin\n c[0]:=c[0]+7*p8[i-1];\n c[i]:=c[i]+p2[i];\n for j:=1 to i-1 do\n begin\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j]) mod modulo)*((7*p8[i-j-1]) mod modulo)) mod modulo) mod modulo;\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j-1]) mod modulo)*p8[i-j]) mod modulo) mod modulo;\n end;\n end;\n for i:=0 to len do\n begin\n fillchar(f,sizeof(f),0);\n c[i]:=(c[i]+dp(len+1,i,false,false)) mod modulo;\n end;\n fillchar(x,sizeof(x),0);\n kq:=0;\n for len:=1 to len do\n begin\n g:=0;\n for i:=len-1 downto 0 do dfs(1,i);\n kq:=(kq+(g*c[len]) mod modulo) mod modulo;\n end;\n writeln(kq);\nend;\n//--------------\nBEGIN\n openfile;\n process;\nEND.\n"}, {"source_code": "program election;\n\nconst\n fi='';\n fo='';\n maxn = 12;\n modulo = trunc(1e9)+7;\nvar\n m:longint; len:longint;\n f:array[1..maxn,0..maxn,false..true,false..true] of int64;\n c:array[0..maxn] of int64;\n p8,p2,p10:array[0..maxn] of int64;\n cc:array[0..maxn,0..maxn] of int64;\n x:array[1..6] of longint;\n p:array[0..maxn] of longint;\n kq,g:int64;\nprocedure openfile;\nvar\n st:string;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(m);\n str(m,st);\n len:=length(st);\nend;\n//---------------\nfunction digitof(n,i:longint):longint; inline;\nbegin\n exit((n div p10[i-1]) mod 10);\nend;\n//--------------\nfunction dp(i,j:longint;small,posi:boolean):int64;\nvar\n d,lim:longint;\nbegin\n if j<0 then exit(0);\n if f[i,j,small,posi]>0 then exit(f[i,j,small,posi]);\n if i=1 then\n begin\n if j>0 then f[i,j,small,posi]:=0 else f[i,j,small,posi]:=1;\n exit(f[i,j,small,posi]);\n end;\n if small then lim:=9 else lim:=digitof(m,i-1);\n f[i,j,small,posi]:=0;\n if posi then\n begin\n for d:=0 to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end\n else\n begin\n if i=2 then d:=1 else d:=0;\n for d:=d to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end;\n exit(f[i,j,small,posi]);\nend;\n//---------------\nprocedure ghi;\nvar\n i,j:longint;\n cnt:int64;\nbegin\n fillchar(p,sizeof(p),0);\n for i:=1 to 6 do inc(p[x[i]]);\n for i:=0 to maxn do\n if p[i]>c[i] then exit;\n for i:=0 to maxn do\n if (p[i]>0)and(p[i]<=c[i]) then\n begin\n cnt:=1;\n for j:=0 to p[i]-1 do cnt:=(cnt*(c[i]-j)) mod modulo;\n g:=(g+cnt) mod modulo;\n end;\nend;\n//--------------\nprocedure dfs(i,r:longint);\nvar\n j:longint;\nbegin\n if i=7 then\n begin\n if r=0 then ghi;\n exit;\n end;\n for j:=0 to r do\n begin\n x[i]:=j;\n dfs(i+1,r-j);\n end;\nend;\n//---------------\nprocedure process;\nvar\n i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n p8[0]:=1;\n p2[0]:=1;\n p10[0]:=1;\n for i:=1 to maxn do\n begin\n p8[i]:=p8[i-1]*8;\n if p8[i]>=modulo then p8[i]:=p8[i]-modulo;\n p2[i]:=p2[i-1]*2;\n if p2[i]>=modulo then p2[i]:=p2[i]-modulo;\n p10[i]:=p10[i-1]*10;\n end;\n cc[0,0]:=1;\n for i:=1 to maxn do\n begin\n cc[i,0]:=1;cc[i,i]:=1;\n for j:=1 to i-1 do\n begin\n cc[i,j]:=cc[i-1,j]+cc[i-1,j-1];\n if cc[i,j]>=modulo then cc[i,j]:=cc[i,j]-modulo;\n end;\n end;\n for i:=1 to len-1 do\n begin\n c[0]:=c[0]+7*p8[i-1];\n c[i]:=c[i]+p2[i];\n for j:=1 to i-1 do\n begin\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j]) mod modulo)*((7*p8[i-j-1]) mod modulo)) mod modulo) mod modulo;\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j-1]) mod modulo)*p8[i-j]) mod modulo) mod modulo;\n end;\n end;\n for i:=0 to len do\n begin\n fillchar(f,sizeof(f),0);\n c[i]:=(c[i]+dp(3,i,false,false)) mod modulo;\n end;\n fillchar(x,sizeof(x),0);\n kq:=0;\n for len:=1 to len do\n begin\n g:=0;\n for i:=len-1 downto 0 do dfs(1,i);\n kq:=(kq+(g*c[len]) mod modulo) mod modulo;\n end;\n writeln(kq);\nend;\n//--------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "program election;\n\nconst\n fi='';\n fo='';\n maxn = 12;\n modulo = trunc(1e9)+7;\nvar\n m:longint; len:longint;\n f:array[1..maxn,0..maxn,false..true] of int64;\n c:array[0..maxn] of int64;\n p8,p2,p10:array[0..maxn] of int64;\n cc:array[0..maxn,0..maxn] of int64;\n x:array[0..6] of longint;\n p:array[0..maxn] of longint;\n kq,g:int64;\nprocedure openfile;\nvar\n st:string;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(m);\n str(m,st);\n len:=length(st);\nend;\n//---------------\nfunction digitof(n,i:longint):longint; inline;\nbegin\n exit((n div p10[i-1]) mod 10);\nend;\n//--------------\nfunction dp(i,j:longint;small:boolean):int64;\nvar\n d,lim:longint;\nbegin\n if j<0 then exit(0);\n if f[i,j,small]>0 then exit(f[i,j,small]);\n if i=1 then\n begin\n if j>0 then f[i,j,small]:=0 else f[i,j,small]:=1;\n exit(f[i,j,small]);\n end;\n if small then lim:=9 else lim:=digitof(m,i-1);\n f[i,j,small]:=0;\n if i=len+1 then d:=1 else d:=0;\n for d:=d to lim do\n if (d=4)or(d=7) then f[i,j,small]:=(f[i,j,small]+dp(i-1,j-1,small or (dc[i] then exit;\n cnt:=1;\n for i:=0 to maxn do\n if (p[i]>0)and(p[i]<=c[i]) then\n begin\n for j:=0 to p[i]-1 do cnt:=(cnt*(c[i]-j)) mod modulo;\n for j:=1 to p[i] do cnt:=cnt div j;\n end;\n cnt:=(cnt*720) mod modulo;\n g:=(g+cnt) mod modulo;\nend;\n//--------------\nprocedure dfs(i,r:longint);\nvar\n j:longint;\nbegin\n if i=7 then\n begin\n if r=0 then ghi;\n exit;\n end;\n for j:=x[i-1] to r do\n begin\n x[i]:=j;\n dfs(i+1,r-j);\n end;\nend;\n//---------------\nprocedure process;\nvar\n i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n p8[0]:=1;\n p2[0]:=1;\n p10[0]:=1;\n for i:=1 to maxn do\n begin\n p8[i]:=p8[i-1]*8;\n if p8[i]>=modulo then p8[i]:=p8[i]-modulo;\n p2[i]:=p2[i-1]*2;\n if p2[i]>=modulo then p2[i]:=p2[i]-modulo;\n p10[i]:=p10[i-1]*10;\n end;\n cc[0,0]:=1;\n for i:=1 to maxn do\n begin\n cc[i,0]:=1;cc[i,i]:=1;\n for j:=1 to i-1 do\n begin\n cc[i,j]:=cc[i-1,j]+cc[i-1,j-1];\n if cc[i,j]>=modulo then cc[i,j]:=cc[i,j]-modulo;\n end;\n end;\n for i:=1 to len-1 do\n begin\n c[0]:=c[0]+7*p8[i-1];\n c[i]:=c[i]+p2[i];\n for j:=1 to i-1 do\n begin\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j]) mod modulo)*((7*p8[i-j-1]) mod modulo)) mod modulo) mod modulo;\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j-1]) mod modulo)*p8[i-j]) mod modulo) mod modulo;\n end;\n end;\n for i:=0 to len do\n begin\n fillchar(f,sizeof(f),0);\n c[i]:=(c[i]+dp(len+1,i,false)) mod modulo;\n end;\n kq:=0;\n x[0]:=0;\n for len:=1 to len do\n begin\n g:=0;\n for i:=len-1 downto 0 do dfs(1,i);\n kq:=(kq+(g*c[len]) mod modulo) mod modulo;\n end;\n writeln(kq);\nend;\n//--------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "program election;\n\nconst\n fi='';\n fo='';\n maxn = 12;\n modulo = trunc(1e9)+7;\nvar\n m:longint; len:longint;\n f:array[1..maxn,0..maxn,false..true,false..true] of int64;\n c:array[0..maxn] of int64;\n p8,p2,p10:array[0..maxn] of int64;\n cc:array[0..maxn,0..maxn] of int64;\n x:array[1..6] of longint;\n p:array[0..maxn] of longint;\n kq,g:int64;\nprocedure openfile;\nvar\n st:string;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(m);\n str(m,st);\n len:=length(st);\nend;\n//---------------\nfunction digitof(n,i:longint):longint; inline;\nbegin\n exit((n div p10[i-1]) mod 10);\nend;\n//--------------\nfunction dp(i,j:longint;small,posi:boolean):int64;\nvar\n d,lim:longint;\nbegin\n if j<0 then exit(0);\n if f[i,j,small,posi]>0 then exit(f[i,j,small,posi]);\n if i=1 then\n begin\n if j>0 then f[i,j,small,posi]:=0 else f[i,j,small,posi]:=1;\n exit(f[i,j,small,posi]);\n end;\n if small then lim:=9 else lim:=digitof(m,i-1);\n f[i,j,small,posi]:=0;\n if posi then\n begin\n for d:=1 to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end\n else\n begin\n for d:=1 to lim do\n if (d=4)or(d=7) then f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j-1,small or (d0))) mod modulo\n else f[i,j,small,posi]:=(f[i,j,small,posi]+dp(i-1,j,small or (d0))) mod modulo;\n end;\n exit(f[i,j,small,posi]);\nend;\n//---------------\nprocedure ghi;\nvar\n i,j:longint;\n cnt:int64;\nbegin\n fillchar(p,sizeof(p),0);\n for i:=1 to 6 do inc(p[x[i]]);\n for i:=0 to maxn do\n if p[i]>c[i] then exit;\n for i:=0 to maxn do\n if (p[i]>0)and(p[i]<=c[i]) then\n begin\n cnt:=1;\n for j:=0 to p[i]-1 do cnt:=(cnt*(c[i]-j)) mod modulo;\n g:=(g+cnt) mod modulo;\n end;\nend;\n//--------------\nprocedure dfs(i,r:longint);\nvar\n j:longint;\nbegin\n if i=7 then\n begin\n if r=0 then ghi;\n exit;\n end;\n for j:=0 to r do\n begin\n x[i]:=j;\n dfs(i+1,r-j);\n end;\nend;\n//---------------\nprocedure process;\nvar\n i,j:longint;\nbegin\n fillchar(c,sizeof(c),0);\n p8[0]:=1;\n p2[0]:=1;\n p10[0]:=1;\n for i:=1 to maxn do\n begin\n p8[i]:=p8[i-1]*8;\n if p8[i]>=modulo then p8[i]:=p8[i]-modulo;\n p2[i]:=p2[i-1]*2;\n if p2[i]>=modulo then p2[i]:=p2[i]-modulo;\n p10[i]:=p10[i-1]*10;\n end;\n cc[0,0]:=1;\n for i:=1 to maxn do\n begin\n cc[i,0]:=1;cc[i,i]:=1;\n for j:=1 to i-1 do\n begin\n cc[i,j]:=cc[i-1,j]+cc[i-1,j-1];\n if cc[i,j]>=modulo then cc[i,j]:=cc[i,j]-modulo;\n end;\n end;\n for i:=1 to len-1 do\n begin\n c[0]:=c[0]+7*p8[i-1];\n c[i]:=c[i]+p2[i];\n for j:=1 to i-1 do\n begin\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j]) mod modulo)*((7*p8[i-j-1]) mod modulo)) mod modulo) mod modulo;\n c[j]:=(c[j]+(((p2[j]*cc[i-1,j-1]) mod modulo)*p8[i-j]) mod modulo) mod modulo;\n end;\n end;\n for i:=0 to len do\n begin\n fillchar(f,sizeof(f),0);\n c[i]:=(c[i]+dp(len+1,i,false,false)) mod modulo;\n end;\n fillchar(x,sizeof(x),0);\n kq:=0;\n for len:=1 to len do\n begin\n g:=0;\n for i:=len-1 downto 0 do dfs(1,i);\n kq:=(kq+(g*c[len]) mod modulo) mod modulo;\n end;\n writeln(kq);\nend;\n//--------------\nBEGIN\n openfile;\n process;\nEND."}, {"source_code": "const\n md = 1000000007;\nvar\n cur, res : int64;\n n, i, j, k, l, r, m : longint;\n d : array [0..10001,0..9] of longint;\n a, b, col, c, kol : array [0..10001] of longint;\n\nprocedure goes(len, sz, sum : longint);\nvar\n ans : int64;\n u : longint;\nbegin\n if (len > 6) then begin\n ans := 1;\n\n// writeln(sum,' ',sz);\n // for k := 0 to 9 do write(col[k],' ');\n // writeln;\n\n for k := 1 to 6 do\n ans := ans * c[k] mod md;\n\n res := (res + ans) mod md;\n\n exit;\n end;\n for u := 0 to sz-1 do\n if (a[u] > col[u]) and (sum+u < sz) then begin\n b[len] := u;\n c[len] := a[u]-col[u];\n col[u] := col[u] + 1;\n goes(len+1, sz, sum+u);\n col[u] := col[u] - 1;\n end;\n end;\nfunction go(x : longint) : longint;\nvar \n y : longint;\nbegin\n y := 0;\n while (x > 0) do begin\n if (x mod 10 = 4) or (x mod 10 = 7) then inc(y);\n x := x div 10;\n end;\n go := y;\nend; \nbegin\n read(n); d[0][0] := 1;\n\n for i := 1 to 9999 do begin\n for j := 0 to 4 do \n d[i][j] := d[i-1][j];\n kol[i] := go(i); \n inc(d[i][kol[i]]);\n end;\n \n for i := 0 to 9999 do begin\n l := 0; r := 9999; cur := -1;\n while (l <= r) do begin\n m := (l+r) shr 1;\n if (i*10000+m <= n) then begin\n l := m+1;\n cur := m;\n end\n else r := m-1; \n end; \n if (cur <> -1) then\n for j := 0 to 4 do \n inc(a[j+kol[i]], d[cur][j]); \n end;\n \n// for i := 0 to 9 do write(a[i], ' ');\n if (n = 1000000000) then inc(a[0]);\n dec(a[0]);\n cur := 0;\n for i := 1 to 9 do begin\n res := 0;\n goes(1, i, 0);\n// writeln(res);\n cur := (cur + res*a[i]) mod md;\n end; \n\n write(cur);\nend."}, {"source_code": "Var i,j,i1,i2,i3,i4,i5,i6,i7,n:Integer;\na,m:array [0..9] of int64;\nkol,rez:int64;\ndp:array [0..10,0..10] of LongInt;\nfunction stepen(e:longint):longint;\nVar i,rez:longint;\nbegin\n rez:=1;\n for i:=1 to e do\n rez:=rez*2;\n stepen:=rez;\nend;\nfunction st(e:longint):longint;\nVar i,rez:longint;\nbegin\n rez:=1;\n for i:=1 to e do\n rez:=rez*8;\n st:=rez;\nend;\nfunction p(n,e:longint):longint;\nbegin\n p:=dp[n,e]*stepen(e);\nend;\nprocedure podchet(n,e:longint);\nvar zz,kol,i,rez:LongInt;\nz:array [1..10] of longint;\nbegin\n rez:=0;\n zz:=e;\n kol:=0;\n while n<>0 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then rez:=rez+2*p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-2);\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then rez:=rez+p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n dec(e);\n end\n else begin\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n end;\n if e<0\n then begin inc(rez); break; end;\n end;\n m[zz]:=rez;\nend;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e);\n for i:=kol downto 1 do\n begin\n if z[i]>4\n then begin\n rez:=rez+2*p(kol-1,e-1);\n dec(e);\n end\n else begin\n rez:=rez+dp[kol-1,e-1];\n dec(e);\n end;\n if e=0\n then break;\n end;\n m[zz]:=rez;\nend;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then begin\n if i<>kol\n then inc(z[i]);\n\n rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end;\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then Inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n end \n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n dec(e);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if e<0\n then begin\n{ if i=1\n then inc(rez);}\n Break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n //Assign(input,'input.txt');\n //Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then begin\n rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n if i<>kol\n then inc(z[i]);\n end\n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end;\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then Inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n end \n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n dec(e);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if e<0\n then begin{ inc(rez);} break; end;\n end;\n m[zz]:=rez;\nend;\nbegin\n //Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>4\n then begin\n if (z[i]<>7)or(i=1)\n then rez:=rez+2*p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-2);\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then rez:=rez+p(i-1,e-1)*st(i-2-e)+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n dec(e);\n end\n else begin\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n end;\n if e<0\n then begin inc(rez); break; end;\n end;\n m[zz]:=rez;\nend;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)\n then begin\n if i<>kol\n then rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-3)\n end\n else begin\n if i<>kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n dec(e);\n end;\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]);\n dec(e);\n end;\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if e=0\n then Inc(rez);\n if (e<=0)\n then begin\n{ if i=1\n then inc(rez);}\n Break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n// Assign(input,'input.txt');\n// Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to i do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)\n then begin\n if i<>kol\n then rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-3)\n end\n else begin\n if i<>kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n dec(e);\n end;\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]);\n dec(e);\n end;\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if (i=1)and(e=0)\n then Inc(rez);\n if (e<0)\n then begin\n{ if i=1\n then inc(rez);}\n Break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to i do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then begin\n if i<>kol\n then inc(z[i]);\n\n rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end\n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end;\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then Inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n end \n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n dec(e);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if e<0\n then begin\n{ if i=1\n then inc(rez);}\n break;\n end;\n end;\n m[zz]:=rez;\nend;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2)\n else begin\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end;\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n dec(e);\n end\n else begin\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n end;\n if e<0\n then begin inc(rez); break; end;\n end;\n m[zz]:=rez;\nend;\nbegin\n // Assign(input,'input.txt');\n // Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i70 do\n begin\n inc(kol);\n z[kol]:=n mod 10;\n n:=n div 10;\n end;\n rez:=rez+p(kol-1,e)*st(kol-e-1);\n for i:=kol downto 1 do\n begin\n if z[i]=0\n then Continue;\n if z[i]>6\n then begin\n if (z[i]<>7)or(i=1)\n then begin\n rez:=rez+2*p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-2);\n if i<>kol\n then inc(z[i]);\n end\n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1));\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-2);\n end;\n dec(e);\n end\n else begin\n if (z[i]>3)\n then begin\n if (z[i]<>4)or(i=1)\n then begin\n if i<>kol\n then Inc(z[i]);\n rez:=rez+p(i-1,e-1)*st(i-1-(e-1))+p(i-1,e)*st(i-e-1)*(z[i]-1)\n end \n else begin\n if i<>kol\n then inc(z[i]);\n rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1);\n end;\n dec(e);\n end\n else begin\n if i=kol\n then rez:=rez+p(i-1,e)*st(i-e-1)*(z[i]-1)\n else rez:=rez+p(i-1,e)*st(i-e-1)*(z[i])\n end;\n end;\n if e<0\n then begin inc(rez); break; end;\n end;\n m[zz]:=rez;\nend;\nbegin\n //Assign(input,'input.txt');\n //Assign(output,'output.txt');\n readln(n);\n dp[0,0]:=1;\n for i:=1 to 9 do\n begin\n dp[i,0]:=1;\n for j:=1 to 9 do\n dp[i,j]:=dp[i-1,j-1]+dp[i-1,j];\n end;\n for i:=1 to 9 do\n podchet(n,i);\n m[0]:=n-m[1]-m[2]-m[3]-m[4]-m[5]-m[6]-m[7]-m[8]-m[9];\n rez:=0;\n for i1:=1 to 9 do\n begin\n for i2:=0 to 9 do\n for i3:=0 to 9 do\n for i4:=0 to 9 do\n for i5:=0 to 9 do\n for i6:=0 to 9 do\n for i7:=0 to 9 do\n begin\n if i2+i3+i4+i5+i6+i7 -1 then exit( d[k, t, ok] );\n if (k = n) then\n begin\n if (t = 0) then d[k, t, ok] := 1 else d[k, t, ok] := 0;\n exit( d[k, t, ok] );\n end;\n tp := 0;\n if ok = 0 then r := 9\n else r := ord(st[k+1]) - ord('0');\n \n for p := 0 to r do\n begin\n if (p = 4) or (p = 7) then tn := t - 1 else tn := t;\n if (p = r) and (ok = 1) then okn := 1 else okn := 0;\n if tn >= 0 then\n inc( tp, recur(k+1, tn, okn) );\n end;\n \n d[k, t, ok] := tp;\n exit( tp );\nend;\n\nprocedure init;\nvar i, j : longint;\nbegin\n fillchar(d, sizeof(d), 255);\n for i := 0 to n do f[i, 1] := recur(0, i, 1);\n dec( f[0, 1] );\n for i := 0 to n do f[i, 0] := 1;\n\n for i := 0 to n do\n for j := 2 to 6 do\n f[i, j] := ( int64(f[i, 1] - j + 1) * f[i, j-1] ) mod oo;\nend;\n\nprocedure check;\nvar i, j : longint;\nbegin\n for i := 0 to n do\n begin\n for j := 0 to 6 do write(f[i, j], ' ');\n writeln;\n end;\nend;\n\nprocedure count;\nvar i, s : longint;\nbegin\n s := 1;\n for i := 0 to n do\n s := ( int64(s) * f[i, num[i]] ) mod oo;\n tmp := tmp + s;\nend;\n\nprocedure factor(k, t : longint);\nvar i : longint;\nbegin\n if k = 7 then\n begin\n if t = 0 then count;\n exit;\n end;\n for i := 0 to t do\n begin\n inc(num[i]);\n factor(k+1, t-i);\n dec(num[i]);\n end;\nend;\n\nprocedure main;\nvar i : longint;\nbegin\n for i := 1 to n do\n if f[i, 1] = 0 then break\n else\n begin\n factor(1, i-1);\n res := ( res + f[i, 1] * int64(tmp) ) mod oo;\n end;\n writeln(res);\nend;\n \nbegin\n// assign(input, f1); reset(input);\n// assign(output, f2); rewrite(output);\n read(st); n := length(st);\n init;\n //check;\n main;\nend.\n"}, {"source_code": "{$R+}\nvar\n cc,met:array [0..10] of int64;\n f:array [0..10,-1..10,0..1] of int64;\n md,i,j,n,m,k,i1,i2,i3,i4,i5,i6,d,nn,kol,c:longint;\n ans:int64;\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x;\n x:=y;\n y:=c;\n end;\n\n function add(x1,x2,x3,x4,x5,x6,x7:longint):int64;\n var\n i:longint;\n res:int64;\n begin\n res:=1;\n for i:=0 to 10 do\n met[i]:=0;\n inc(met[x1]); inc(met[x2]); inc(met[x3]); inc(met[x4]); inc(met[x5]);\n inc(met[x6]); inc(met[x7]);\n for i:=0 to 9 do\n begin\n for j:=f[d,i,0]-met[i]+1to f[d,i,0] do\n begin\n res:=(res*j) mod md;\n end;\n if res=0 then exit(0);\n end;\n exit(res mod md);\n end;\n\n\nbegin\n md:=1000000000+7;\n readln(n);\n nn:=n;\n while nn<>0 do\n begin\n inc(d);\n cc[d]:=nn mod 10;\n nn:=nn div 10;\n end;\n for i:=1 to d div 2 do\n swap(cc[i],cc[d-i+1]);\n\n f[0,0,1]:=1;\n for i:=1 to d do\n begin\n for kol:=0 to 10 do\n begin\n for c:=0 to 9 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,0]+f[i,kol,0]\n else f[i,kol,0]:=f[i-1,kol,0]+f[i,kol,0];\n end;\n for c:=0 to cc[i]-1 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,1]+f[i,kol,0]\n else f[i,kol,0]:=f[i,kol,0]+f[i-1,kol,1];\n end;\n if (cc[i]=4)or(cc[i]=7) then f[i,kol,1]:=f[i-1,kol-1,1]+f[i,kol,1]\n else f[i,kol,1]:=f[i,kol,1]+f[i-1,kol,1];\n end;\n end;\n for i:=0 to 10 do\n f[d,i,0]:=f[d,i,0]+f[d,i,1];\n dec(f[d,0,0]);\n for i:=1 to d do\n begin\n for i1:=0 to i do\n for i2:=0 to i-i1 do\n for i3:=0 to i-i1-i2 do\n for i4:=0 to i-i1-i2-i3 do\n for i5:=0 to i-i1-i2-i3-i4 do\n for i6:=0 to i-i1-i2-i3-i4-i5 do\n begin\n if (i1+i2+i3+i4+i5+i6)>=i then continue;\n ans:=(ans+add(i,i1,i2,i3,i4,i5,i6))mod md;\n end;\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "{$R+}\nvar\n cc,met:array [0..100] of int64;\n f:array [0..100,-1..100,0..1] of int64;\n md,n,m,k,d,nn:int64;\n c,kol,i,j,i1,i2,i3,i4,i5,i6:longint;\n ans:int64;\n\n procedure swap(var x,y:int64);\n var\n c:longint;\n begin\n c:=x;\n x:=y;\n y:=c;\n end;\n\n function add(x1,x2,x3,x4,x5,x6,x7:int64):int64;\n var\n i,j:longint;\n res:int64;\n begin\n res:=1;\n for i:=0 to 11 do\n met[i]:=0;\n inc(met[x1]); inc(met[x2]); inc(met[x3]); inc(met[x4]); inc(met[x5]);\n inc(met[x6]); inc(met[x7]);\n for i:=0 to 9 do\n begin\n for j:=f[d,i,0]-met[i]+1 to f[d,i,0] do\n begin\n res:=(res*j) mod md;\n end;\n if res=0 then\n begin\n add:=0;\n exit;\n end;\n end;\n add:=(res mod md);\n end;\n\n\nbegin\n md:=1000000000+7;\n readln(n);\n nn:=n;\n while nn<>0 do\n begin\n inc(d);\n cc[d]:=nn mod 10;\n nn:=nn div 10;\n end;\n for i:=1 to d div 2 do\n swap(cc[i],cc[d-i+1]);\n\n f[0,0,1]:=1;\n for i:=1 to d do\n begin\n for kol:=0 to 10 do\n begin\n for c:=0 to 9 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,0]+f[i,kol,0]\n else f[i,kol,0]:=f[i-1,kol,0]+f[i,kol,0];\n end;\n for c:=0 to cc[i]-1 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,1]+f[i,kol,0]\n else f[i,kol,0]:=f[i,kol,0]+f[i-1,kol,1];\n end;\n if (cc[i]=4)or(cc[i]=7) then f[i,kol,1]:=f[i-1,kol-1,1]+f[i,kol,1]\n else f[i,kol,1]:=f[i,kol,1]+f[i-1,kol,1];\n end;\n end;\n for i:=0 to 10 do\n f[d,i,0]:=(f[d,i,0]+f[d,i,1])mod md;\n dec(f[d,0,0]);\n for i:=1 to d do\n begin\n for i1:=0 to i do\n for i2:=0 to i-i1 do\n for i3:=0 to i-i1-i2 do\n for i4:=0 to i-i1-i2-i3 do\n for i5:=0 to i-i1-i2-i3-i4 do\n for i6:=0 to i-i1-i2-i3-i4-i5 do\n begin\n if (i1+i2+i3+i4+i5+i6)>=i then continue;\n ans:=(ans+add(i,i1,i2,i3,i4,i5,i6))mod md;\n end;\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "var\n cc,met:array [0..10] of longint;\n f:array [0..10,-1..10,0..1] of longint;\n md,i,j,n,m,k,ans,i1,i2,i3,i4,i5,i6,d,nn,kol,c:longint;\n\n procedure swap(var x,y:longint);\n var\n c:longint;\n begin\n c:=x;\n x:=y;\n y:=c;\n end;\n\n function add(x1,x2,x3,x4,x5,x6,x7:longint):int64;\n var\n i:longint;\n res:int64;\n begin\n res:=1;\n for i:=0 to 10 do\n met[i]:=0;\n inc(met[x1]); inc(met[x2]); inc(met[x3]); inc(met[x4]); inc(met[x5]);\n inc(met[x6]); inc(met[x7]);\n for i:=0 to 9 do\n begin\n for j:=f[d,i,0]-met[i]+1to f[d,i,0] do\n begin\n res:=res*j mod md;\n end;\n if res=0 then exit(0);\n end;\n exit(res);\n end;\n\n\nbegin\n md:=1000000000+7;\n readln(n);\n nn:=n;\n while nn<>0 do\n begin\n inc(d);\n cc[d]:=nn mod 10;\n nn:=nn div 10;\n end;\n for i:=1 to d div 2 do\n swap(cc[i],cc[d-i+1]);\n\n f[0,0,1]:=1;\n for i:=1 to d do\n begin\n for kol:=0 to 10 do\n begin\n for c:=0 to 9 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,0]+f[i,kol,0]\n else f[i,kol,0]:=f[i-1,kol,0]+f[i,kol,0];\n end;\n for c:=0 to cc[i]-1 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,1]+f[i,kol,0]\n else f[i,kol,0]:=f[i,kol,0]+f[i-1,kol,1];\n end;\n if (cc[i]=4)or(cc[i]=7) then f[i,kol,1]:=f[i-1,kol-1,1]+f[i,kol,1]\n else f[i,kol,1]:=f[i,kol,1]+f[i-1,kol,1];\n end;\n end;\n for i:=0 to 10 do\n f[d,i,0]:=f[d,i,0]+f[d,i,1];\n dec(f[d,0,0]);\n for i:=1 to d do\n begin\n for i1:=0 to i do\n for i2:=0 to i-i1 do\n for i3:=0 to i-i1-i2 do\n for i4:=0 to i-i1-i2-i3 do\n for i5:=0 to i-i1-i2-i3-i4 do\n for i6:=0 to i-i1-i2-i3-i4-i5 do\n begin\n if (i1+i2+i3+i4+i5+i6)>=i then continue;\n ans:=(ans+add(i,i1,i2,i3,i4,i5,i6))mod md;\n end;\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "var\n cc,met:array [0..10] of longint;\n f:array [0..10,-1..10,0..1] of longint;\n md,i,j,n,m,k,i1,i2,i3,i4,i5,i6,d,nn,kol,c:longint;\n ans:int64;\n\n procedure swap(var x,y:longint);\n var\n c:longint;\n begin\n c:=x;\n x:=y;\n y:=c;\n end;\n\n function add(x1,x2,x3,x4,x5,x6,x7:longint):int64;\n var\n i:longint;\n res:int64;\n begin\n res:=1;\n for i:=0 to 10 do\n met[i]:=0;\n inc(met[x1]); inc(met[x2]); inc(met[x3]); inc(met[x4]); inc(met[x5]);\n inc(met[x6]); inc(met[x7]);\n for i:=0 to 9 do\n begin\n for j:=f[d,i,0]-met[i]+1to f[d,i,0] do\n begin\n res:=res*j mod md;\n end;\n if res=0 then exit(0);\n end;\n exit(res);\n end;\n\n\nbegin\n md:=1000000000+7;\n readln(n);\n nn:=n;\n while nn<>0 do\n begin\n inc(d);\n cc[d]:=nn mod 10;\n nn:=nn div 10;\n end;\n for i:=1 to d div 2 do\n swap(cc[i],cc[d-i+1]);\n\n f[0,0,1]:=1;\n for i:=1 to d do\n begin\n for kol:=0 to 10 do\n begin\n for c:=0 to 9 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,0]+f[i,kol,0]\n else f[i,kol,0]:=f[i-1,kol,0]+f[i,kol,0];\n end;\n for c:=0 to cc[i]-1 do\n begin\n if (c=4)or(c=7) then f[i,kol,0]:=f[i-1,kol-1,1]+f[i,kol,0]\n else f[i,kol,0]:=f[i,kol,0]+f[i-1,kol,1];\n end;\n if (cc[i]=4)or(cc[i]=7) then f[i,kol,1]:=f[i-1,kol-1,1]+f[i,kol,1]\n else f[i,kol,1]:=f[i,kol,1]+f[i-1,kol,1];\n end;\n end;\n for i:=0 to 10 do\n f[d,i,0]:=f[d,i,0]+f[d,i,1];\n dec(f[d,0,0]);\n for i:=1 to d do\n begin\n for i1:=0 to i do\n for i2:=0 to i-i1 do\n for i3:=0 to i-i1-i2 do\n for i4:=0 to i-i1-i2-i3 do\n for i5:=0 to i-i1-i2-i3-i4 do\n for i6:=0 to i-i1-i2-i3-i4-i5 do\n begin\n if (i1+i2+i3+i4+i5+i6)>=i then continue;\n ans:=(ans+add(i,i1,i2,i3,i4,i5,i6))mod md;\n end;\n end;\n writeln(ans);\nend.\n\n\n"}, {"source_code": "const md = 1000000007;\nvar\nw,ans,s:int64;\nfact:array[0..1000]of int64;\np,u,i,j,n,m,t:longint;\ndp:array[0..100,0..100]of int64;\na:Array[0..100]of int64;\nc1,c2:array[0..100,0..100]of int64;\nfunction st(x,n:int64):int64;\nvar t:int64;\nbegin\n if n=0 then st:=1\n else\n begin\n if n mod 2=1 then st:=x*st(x,n-1) mod md\n else\n begin\n t:=st(x,n div 2);\n t:=t*t mod md;\n st:=t;\n end;\n end;\nend;\nfunction cnk(n,k:longint):int64;\nvar i:longint; d:int64;\nbegin\n d:=1;\n for i:=n-k+1 to n do\n begin\n d:=d*int64(i);\n d:=d mod md;\n end;\n d:=d*st(fact[k],md-2);\n d:=d mod md;\n cnk:=d;\nend;\nprocedure add(var a:int64; b:longint);\nbegin\n a:=a+b;\n if a>=md then a:=a-md;\nend;\nfunction c(n:longint):int64;\nvar\nd,res:int64;\nlast,i,j,u:longint;\nbegin\n c1[0,0]:=1;\n for last:=0 to n-1 do\n begin\n fillchar(c2,sizeof(c2),0);\n for i:=0 to n-1 do\n for j:=0 to 6 do\n begin\n add(c2[i,j],c1[i,j]);\n for u:=1 to 6-j do\n if (i+u*last=u) then\n begin\n d:=c1[i,j];\n d:=d*cnk(a[last],u) mod md;\n add(c2[i+u*last,j+u],d);\n end;\n end;\n for i:=0 to n-1 do\n for j:=0 to 6 do\n c1[i,j]:=c2[i,j];\n end;\n res:=0;\n for i:=0 to n-1 do\n res:=(res+c1[i,6]) mod md;\n c:=res;\nend;\nprocedure precalc;\nvar s:string;\nbegin\n dp[1,1]:=2;\n dp[1,0]:=8;\n\n for i:=2 to 9 do\n for j:=0 to i-1 do\n begin\n dp[i,j]:=dp[i,j]+dp[i-1,j]*8;\n dp[i,j+1]:=dp[i,j+1]+dp[i-1,j]*2;\n end;\n\n str(m,s);\n dp[0,0]:=1;\n for i:=1 to length(s)-1 do\n begin\n for u:=1 to 9 do\n begin\n if (u=4)or(u=7) then t:=1\n else t:=0;\n for j:=0 to i do\n a[j+t]:=a[j+t]+dp[i-1,j];\n end;\n end;\n t:=0;\n for i:=1 to length(s) do\n begin\n p:=1;\n if (i<>1) then p:=0;\n for u:=p to ord(s[i])-49 do\n begin\n if (u=4)or(u=7) then inc(t);\n for j:=0 to 10 do\n a[j+t]:=a[j+t]+dp[length(s)-i,j];\n if (u=4)or(u=7) then dec(t);\n end;\n if (s[i]='4')or(s[i]='7') then inc(t);\n end;\n inc(a[t]);\nend;\n begin\n fact[0]:=1;\n for i:=1 to 6 do\n fact[i]:=fact[i-1]*i;\n readln(m);\n w:=1;\n precalc;\n s:=a[0];\n for i:=1 to 10 do\n begin\n ans:=ans+a[i]*c(i);\n ans:=ans mod md;\n end;\n writeln(ans*720 mod md);\n end.\n"}, {"source_code": "const md = 1000000007;\nvar\nw,ans,s:int64;\np,u,i,j,n,m,t:longint;\ndp:array[0..100,0..100]of int64;\na:Array[0..100]of int64;\nfunction st(x,n:int64):int64;\nvar t:int64;\nbegin\n if n=0 then st:=1\n else\n begin\n if n mod 2=1 then st:=x*st(x,n-1) mod md\n else\n begin\n t:=st(x,n div 2);\n t:=t*t mod md;\n st:=t;\n end;\n end;\nend;\nfunction c(n,k:longint):int64;\nvar d:int64;\n i:longint;\nbegin\n d:=1;\n for i:=n-k+1 to n do\n d:=d*int64(i) mod md;\n d:=d*w mod md;\n c:=d;\nend;\nprocedure precalc;\nvar s:string;\nbegin\n dp[1,1]:=2;\n dp[1,0]:=8;\n\n for i:=2 to 9 do\n for j:=0 to i-1 do\n begin\n dp[i,j]:=dp[i,j]+dp[i-1,j]*8;\n dp[i,j+1]:=dp[i,j+1]+dp[i-1,j]*2;\n end;\n\n str(m,s);\n dp[0,0]:=1;\n for i:=1 to length(s)-1 do\n begin\n for u:=1 to 9 do\n begin\n if (u=4)or(u=7) then t:=1\n else t:=0;\n for j:=0 to i do\n a[j+t]:=a[j+t]+dp[i-1,j];\n end;\n end;\n t:=0;\n for i:=1 to length(s) do\n begin\n p:=1;\n if (i<>1) then p:=0;\n for u:=p to ord(s[i])-49 do\n begin\n if (u=4)or(u=7) then inc(t);\n for j:=0 to 10 do\n a[j+t]:=a[j+t]+dp[length(s)-i,j];\n if (u=4)or(u=7) then dec(t);\n end;\n if (s[i]='4')or(s[i]='7') then inc(t);\n end;\n inc(a[t]);\nend;\n begin\n readln(m);\n w:=1;\n precalc;\n s:=a[0];\n for i:=1 to 10 do\n begin\n ans:=ans+a[i]*c(s,6);\n ans:=ans mod md;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "Uses Math;\nConst\n Fi = '';//ELECTION.INP';\n Fo = '';//ELECTION.OUT';\n Base = Trunc(1e9)+7;\n Maxcs = 11;\nType\n M1 = Array [0..Maxcs] of Longint;\n M2 = Array [0..Maxcs,-Maxcs..Maxcs,false..true,false..true] of Longint;\nVar\n f , g : Text;\n m : Longint;\n res , kq : Int64;\n num : String;\n a , x, dem : M1;\n fx : M2;\n\nProcedure Openfile;\nBegin\n Assign(f,fi);\n Reset(f);\n Assign(g,fo);\n Rewrite(g);\nEnd;\n\nProcedure Closefile;\nBegin\n Close(f);\n Close(g);\nEnd;\n\nProcedure Doc;\nBegin\n Readln(f,m);\nEnd;\n\nFunction Tinh(i , j : Longint; ok , ok2 : Boolean) : Longint;\nVar\n k , sum : Longint;\nBegin\n If fx[i,j,ok,ok2]<>-1 then exit(fx[i,j,ok,ok2]);\n If i>length(num) then\n Begin\n Fx[i,j,ok,ok2]:=ord((j=0) and ok2);\n Exit(fx[i,j,ok,ok2]);\n End;\n Sum:=0;\n For k:=0 to max(ord(num[i])-48,ord(ok)*9) do sum:=sum+tinh(i+1,j-ord((k=4) or (k=7)),ok or (k0));\n Fx[i,j,ok,ok2]:=sum;\n Exit(sum);\nEnd;\n\nProcedure Init;\nVar\n j : Longint;\nBegin\n Str(m,num);\n For j:=0 to length(num) do\n Begin\n Fillchar(fx,sizeof(fx),255);\n a[j]:=tinh(1,j,false,false);\n End;\nEnd;\n\nProcedure Capnhat;\nVar\n i , j : Longint;\n t : Int64;\nBegin\n t:=1;\n For i:=0 to 9 do\n If dem[i]>0 then\n Begin\n For j:=0 to dem[i]-1 do t:=(t*(a[i]-j)) mod base;\n End;\n Kq:=(kq+t) mod base;\nEnd;\n\nProcedure Thu(i , j : Longint);\nVar\n k : Longint;\nBegin\n For k:=0 to j do\n Begin\n Inc(dem[k]);\n If i<6 then thu(i+1,j-k)\n Else capnhat;\n Dec(dem[k]);\n End;\nEnd;\n\nProcedure Solve;\nVar\n i , j : Longint;\nBegin\n Res:=0;\n For i:=1 to length(num) do\n Begin\n //Fillchar(x,sizeof(x),0);\n Fillchar(dem,sizeof(dem),0);\n kq:=0;\n For j:=0 to i-1 do thu(i,j);\n kq:=(kq*a[i]) mod base;\n Res:=(res+kq) mod base;\n End;\nEnd;\n\nProcedure Ghi;\nBegin\n If m<=7 then writeln(g,0)\n Else writeln(g,res);\nEnd;\n\nBegin\n Openfile;\n Doc;\n Init;\n Solve;\n Ghi;\n Closefile;\nEnd."}, {"source_code": "uses math;\nconst base=1000000000+7;\nvar m,top,tong:longint;\n st,c:array[0..10]of longint;\n dp:array[0..10,0..10]of longint;\n mang:array[0..10]of longint;\n ans:int64;\n\nfunction get(x,y:longint):longint;\nbegin\n get:=(x shr y) and 1;\nend;\n\nprocedure nhap;\nvar m2:longint;\nbegin\n assign(input,''); reset(input);\n fillchar(dp,sizeof(dp),0);\n readln(m); top:=0;\n while m<>0 do begin\n inc(top); st[top]:=m mod 10; m:=m div 10;\n end;\nend;\n\nprocedure solve;\nvar i,j,count,ans,t:longint;\nbegin\n dp[0,0]:=1;\n for i:=1 to min(9,top) do begin\n for j:=0 to (1 shl i)-1 do begin\n count:=0; ans:=1;\n for t:=1 to i do if get(j,t-1)=1 then begin\n inc(count); ans:=ans*2;\n end\n else ans:=ans*8;\n dp[i,count]:=dp[i,count]+ans;\n end;\n end;\nend;\n\nfunction combi(p,x:longint):int64;\nvar i:longint;\n combix:int64;\nbegin\n combix:=1;\n for i:=0 to x-1 do combix:=(combix*(p-i))mod base;\n combi:=combix;\nend;\n\nprocedure update(lab:longint);\nvar sum:int64;\n i:longint;\nbegin\n sum:=1;\n for i:=0 to 9 do begin\n sum:=sum*combi(mang[i],c[i]);\n end;\n sum:=sum*mang[lab];\n ans:=ans+sum;\nend;\n\nprocedure pick(k,lab:longint);\nvar i:longint;\nbegin\n for i:=0 to 9 do begin\n if tong+i>=lab then exit;\n tong:=tong+i;\n inc(c[i]);\n if k=6 then update(lab) else pick(k+1,lab);\n dec(c[i]);\n tong:=tong-i;\n end;\nend;\n\nprocedure print;\nvar i,j,t,v,count,i1,i2,i3,i4,i5,i6:longint;\nbegin\n fillchar(mang,sizeof(mang),0); ans:=0; count:=0;\n for i:=top downto 1 do begin\n for j:=st[i]-1 downto 0 do begin\n if (j=4)or(j=7) then inc(count);\n for t:=0 to 9 do if (t+count<=9)\n then mang[t+count]:=mang[t+count]+dp[i-1,t];\n if (j=4)or(j=7) then dec(count);\n end;\n if (st[i]=4)or(st[i]=7) then inc(count);\n end;\n inc(mang[count]); dec(mang[0]);\n for i:=0 to 9 do begin\n tong:=0; fillchar(c,sizeof(c),0);\n pick(1,i);\n end;\n writeln(ans);\nend;\n\nbegin\n nhap;\n solve;\n print;\nend.\n"}, {"source_code": "uses math;\nconst base=1000000000+7;\nvar m,top:longint;\n st:array[1..10]of longint;\n dp:array[0..10,0..10]of longint;\n mang:array[0..10]of longint;\n\nfunction get(x,y:longint):longint;\nbegin\n get:=(x shr y) and 1;\nend;\n\nprocedure nhap;\nvar m2:longint;\nbegin\n assign(input,''); reset(input);\n fillchar(dp,sizeof(dp),0);\n readln(m); top:=0;\n while m<>0 do begin\n inc(top); st[top]:=m mod 10; m:=m div 10;\n end;\nend;\n\nprocedure solve;\nvar i,j,count,ans,t:longint;\nbegin\n dp[0,0]:=1;\n for i:=1 to min(9,top) do begin\n for j:=0 to (1 shl i)-1 do begin\n count:=0; ans:=1;\n for t:=1 to i do if get(j,t-1)=1 then begin\n inc(count); ans:=ans*2;\n end\n else ans:=ans*8;\n dp[i,count]:=dp[i,count]+ans;\n end;\n end;\nend;\n\nfunction combi(p:longint):int64;\nvar i:longint;\n combix:int64;\nbegin\n combix:=1;\n for i:=0 to 5 do combix:=(combix*(p-i))mod base;\n combi:=combix;\nend;\n\nprocedure print;\nvar ans,i,j,t,v,sum,count:longint;\nbegin\n fillchar(mang,sizeof(mang),0); ans:=0; count:=0;\n for i:=top downto 1 do begin\n for j:=st[i]-1 downto 0 do begin\n if (j=4)or(j=7) then inc(count);\n for t:=0 to 9 do if (t+count<=9)\n then mang[t+count]:=mang[t+count]+dp[i-1,t];\n if (j=4)or(j=7) then dec(count);\n end;\n if (st[i]=4)or(st[i]=7) then inc(count);\n end;\n inc(mang[count]); dec(mang[0]);\n for i:=0 to 9 do begin\n sum:=0;\n for j:=0 to i-1 do sum:=sum+mang[j];\n ans:=(ans+(combi(sum)*mang[i])mod base)mod base;\n end;\n writeln(ans);\nend;\n\nbegin\n nhap;\n solve;\n print;\nend.\n"}, {"source_code": "const md=1000000000+7;\nVar ans,sum,n,x,res:int64;\n f:array[0..12,0..12,boolean]of int64;\n i,j,len,u,d,mx:longint;\n s:string;\n w:boolean;\n{ function pow(a,b:int64):int64;\n begin\n if b=0 then exit(1);\n if b mod 2=1 then pow:=pow(a,b-1)*a mod md\n else begin a:=a*a mod md;pow:=pow(a,b div 2);end;\n end;\n } begin\n read(n);\n str(n+1,s);\n len:=length(s);\n f[0,0,false]:=1;\n for i:=1 to len do\n for j:=0 to len do\n for w:=false to true do\n begin\n if w then mx:=9\n else mx:=ord(s[i])-48;\n for d:=0 to mx do\n f[i,j+ord((d=4)or(d=7)),w or (d0 then\n begin\n res:=1;\n for j:=sum downto sum-5 do\n res:=res*int64(j) mod md;\n end else res:=0;\n ans:=(ans+res*x)mod md;\n sum:=sum+x;\n end;\n Writeln(ans);\n end."}, {"source_code": "const md=1000000000+7;\nVar ans,sum,n,x,res:int64;\n f:array[0..12,0..12,boolean]of int64;\n i,j,len,u,d,mx:longint;\n s:string;\n g,fact,rev,q:array[0..1234]of int64;\n w:boolean;\n function pow(a,b:int64):int64;\n begin\n if b=0 then exit(1);\n if b mod 2=1 then pow:=pow(a,b-1)*a mod md\n else begin a:=a*a mod md;pow:=pow(a,b div 2);end;\n end;\n\n procedure rec(x,sum:longint;tmp:int64);\n var i:longint;\n begin\n if sum>=len then exit;\n if x=7 then\n begin\n for i:=0 to len do\n tmp:=tmp*rev[fact[q[i]]] mod md;\n for i:=sum+1 to len do\n ans:=(ans+tmp*g[i])mod md;\n exit;\n end;\n for i:=0 to len-1 do\n if g[i]>0 then\n begin\n dec(g[i]);\n inc(q[i]);\n rec(x+1,sum+i,tmp*g[i] mod md);\n inc(g[i]);\n dec(q[i]);\n end;\n end;\n begin\n read(n);\n rev[0]:=1;\n for i:=1 to 1000 do\n rev[i]:=pow(i,md-2);\n fact[0]:=1;\n for i:=1 to 7 do\n fact[i]:=fact[i-1]*i;\n str(n+1,s);\n len:=length(s);\n f[0,0,false]:=1;\n for i:=1 to len do\n for j:=0 to len do\n for w:=false to true do\n begin\n if w then mx:=9\n else mx:=ord(s[i])-48;\n for d:=0 to mx do\n f[i,j+ord((d=4)or(d=7)),w or (d5 then\n begin\n res:=1;\n for j:=sum downto sum-5 do\n res:=res*int64(j) mod md;\n end else res:=0;\n ans:=(ans+res*x)mod md;\n sum:=sum+x;\n end;\n Writeln(ans);\n end."}, {"source_code": "const\n finp='';//258B.inp';\n fout='';//258B.out';\n base=1000000007;\n\nvar\n fi,fo:text;\n f:array[0..10,-1..10] of longint;\n a,s,gt,val:array[0..10] of longint;\n m,n,sum,kq:longint;\n\nprocedure openfile;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(fo,fout);\n rewrite(fo);\nend;\n\nprocedure closefile;\nbegin\n close(fi);\n close(fo);\nend;\n\nprocedure enter;\nbegin\n readln(fi,n);\nend;\n\nprocedure slcs(x:longint);\nbegin\n m:=0;\n while x>0 do\n begin\n inc(m); a[m]:=x mod 10;\n x:=x div 10;\n end;\nend;\n\nfunction mu(x,k:longint):longint;\nvar t:int64;\nbegin\n if (k=1) then exit(x);\n t:=mu(x,k div 2);\n t:=t*t mod base;\n if odd(k) then t:=t*x mod base;\n exit(t);\nend;\n\nprocedure prepare;\nvar i,j,k,dem,x,y:longint;\nbegin\n f[1,0]:=7;\n f[1,1]:=2;\n f[0,0]:=1;\n slcs(n);\n for i:=2 to m do\n for j:=0 to i do\n begin\n x:=int64(f[i-1,j-1])*2;\n y:=int64(8)*f[i-1,j];\n f[i,j]:=x+y;\n n:=n;\n end;\n for i:=1 to m-1 do\n for j:=0 to i do s[j]:=s[j]+f[i,j];\n dem:=0;\n for i:=m downto 1 do\n begin\n for j:=1 to a[i]-1 do\n if (j=4) or (j=7) then\n begin\n for k:=dem+1 to 9 do s[k]:=s[k]+f[m-i,k-dem-1];\n end else\n begin\n for k:=dem to 9 do s[k]:=s[k]+f[m-i,k-dem];\n end;\n if (a[i]=4) or (a[i]=7) then inc(dem);\n end;\n inc(s[dem]);\n gt[0]:=1; val[0]:=1;\n for i:=1 to 6 do gt[i]:=int64(gt[i-1])*i mod base;\n for i:=1 to 6 do val[i]:=mu(gt[i],base-2);\nend;\n\nfunction c(n,k:longint):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=n-k+1 to n do s:=int64(s)*i mod base;\n s:=int64(s)*val[k] mod base;\n exit(s);\nend;\n\nprocedure update(x:longint);\nvar i,j:longint;\nbegin\n j:=0;\n for i:=0 to x-1 do j:=j+a[i];\n if (j<>6) then exit;\n if (j-a[0]>=x) then exit;\n j:=1;\n for i:=0 to x-1 do j:=int64(j)*c(s[i],a[i]) mod base;\n j:=int64(j)*gt[6] mod base;\n sum:=(sum+j) mod base\nend;\n\nprocedure trying(i,x:longint);\nvar j,k:longint;\nbegin\n if (i>x-1) then\n begin\n update(x);\n exit;\n end;\n if i=0 then k:=6 else k:=x-1;\n for j:=0 to k do\n begin\n a[i]:=j;\n trying(i+1,x);\n a[i]:=0;\n end;\nend;\n\nprocedure lam(x:longint);\nvar i,j,k:longint;\nbegin\n sum:=0;\n trying(0,x);\n kq:=(kq+int64(s[x])*sum mod base) mod base\nend;\n\nprocedure process;\nvar i:longint;\nbegin\n for i:=1 to m do\n if s[i]>0 then lam(i);\n writeln(kq);\nend;\n\nBEGIN\n openfile;\n enter;\n prepare;\n process;\n closefile;\nEND."}, {"source_code": "const\n finp='';//258B.inp';\n fout='';//258B.out';\n base=1000000007;\n\nvar\n fi,fo:text;\n f:array[0..10,-1..10] of int64;\n a,s,gt,val:array[0..10] of longint;\n m,n,sum,kq:longint;\n\nprocedure openfile;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(fo,fout);\n rewrite(fo);\nend;\n\nprocedure closefile;\nbegin\n close(fi);\n close(fo);\nend;\n\nprocedure enter;\nbegin\n readln(fi,n);\nend;\n\nprocedure slcs(x:longint);\nbegin\n m:=0;\n while x>0 do\n begin\n inc(m); a[m]:=x mod 10;\n x:=x div 10;\n end;\nend;\n\nfunction mu(x,k:longint):longint;\nvar t:int64;\nbegin\n if (k=1) then exit(x);\n t:=mu(x,k div 2);\n t:=t*t mod base;\n if odd(k) then t:=t*x mod base;\n exit(t);\nend;\n\nprocedure prepare;\nvar i,j,k,dem,x,y:longint;\nbegin\n f[1,0]:=7;\n f[1,1]:=2;\n f[0,0]:=1;\n slcs(n);\n for i:=2 to m-1 do\n for j:=0 to i do\n begin\n x:=int64(f[i-1,j-1])*2;\n y:=int64(8)*f[i-1,j];\n f[i,j]:=x+y;\n n:=n;\n end;\n for i:=1 to m-1 do\n for j:=0 to i do s[j]:=s[j]+f[i,j];\n dem:=0; f[1,0]:=8;\n for i:=m downto 1 do\n begin\n if i=m then x:=1 else x:=0;\n for j:=x to a[i]-1 do\n if (j=4) or (j=7) then\n begin\n for k:=dem+1 to 9 do s[k]:=s[k]+f[i-1,k-dem-1];\n end else\n begin\n for k:=dem to 9 do s[k]:=s[k]+f[i-1,k-dem];\n end;\n if (a[i]=4) or (a[i]=7) then inc(dem);\n end;\n inc(s[dem]);\n gt[0]:=1; val[0]:=1;\n for i:=1 to 6 do gt[i]:=int64(gt[i-1])*i mod base;\n for i:=1 to 6 do val[i]:=mu(gt[i],base-2);\nend;\n\nfunction c(n,k:longint):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=n-k+1 to n do s:=int64(s)*i mod base;\n s:=int64(s)*val[k] mod base;\n exit(s);\nend;\n\nprocedure update(x:longint);\nvar i,j:longint;\nbegin\n j:=0;\n for i:=0 to x-1 do j:=j+a[i];\n if (j<>6) then exit;\n if (j-a[0]>=x) then exit;\n j:=1;\n for i:=0 to x-1 do j:=int64(j)*c(s[i],a[i]) mod base;\n j:=int64(j)*gt[6] mod base;\n sum:=(sum+j) mod base;\nend;\n\nprocedure trying(i,x,k:longint);\nvar j:longint;\nbegin\n if (i>x-1) then\n begin\n update(x);\n exit;\n end;\n //if i=0 then k:=6 else k:=x-1;\n for j:=0 to k do\n begin\n a[i]:=j;\n trying(i+1,x,k-j);\n a[i]:=0;\n end;\nend;\n\nprocedure lam(x:longint);\nvar i,j,k:longint;\nbegin\n sum:=0;\n trying(0,x,6);\n kq:=(kq+int64(s[x])*sum mod base) mod base\nend;\n\nprocedure process;\nvar i:longint;\nbegin\n for i:=1 to m do\n if s[i]>0 then lam(i);\n writeln(kq);\nend;\n\nprocedure check;\nvar i,j,dem:longint;\nbegin\n for i:=0 to m do write(s[i],' '); writeln;\n fillchar(s,sizeof(s),0);\n for i:=1 to n do\n begin\n j:=i; dem:=0;\n while j>0 do\n begin\n if (j mod 10=4) or (j mod 10=7) then inc(dem);\n j:=j div 10;\n end;\n inc(s[dem]);\n //if dem=0 then writeln('g',' ',i);\n end;\n for i:=0 to m do write(s[i],' '); writeln;\nend;\n\nBEGIN\n openfile;\n enter;\n prepare;\n process;\n //check;\n closefile;\nEND."}, {"source_code": "const\n finp='';//258B.inp';\n fout='';//258B.out';\n base=1000000007;\n\nvar\n fi,fo:text;\n f:array[0..10,-1..10] of int64;\n a,s,gt,val:array[0..10] of longint;\n m,n,sum,kq:longint;\n\nprocedure openfile;\nbegin\n assign(fi,finp);\n reset(fi);\n assign(fo,fout);\n rewrite(fo);\nend;\n\nprocedure closefile;\nbegin\n close(fi);\n close(fo);\nend;\n\nprocedure enter;\nbegin\n readln(fi,n);\nend;\n\nprocedure slcs(x:longint);\nbegin\n m:=0;\n while x>0 do\n begin\n inc(m); a[m]:=x mod 10;\n x:=x div 10;\n end;\nend;\n\nfunction mu(x,k:longint):longint;\nvar t:int64;\nbegin\n if (k=1) then exit(x);\n t:=mu(x,k div 2);\n t:=t*t mod base;\n if odd(k) then t:=t*x mod base;\n exit(t);\nend;\n\nprocedure prepare;\nvar i,j,k,t,dem,x,y:longint;\nbegin\n f[1,0]:=7;\n f[1,1]:=2;\n f[0,0]:=1;\n slcs(n);\n for i:=2 to m-1 do\n for j:=0 to i do\n begin\n x:=int64(f[i-1,j-1])*2;\n y:=int64(8)*f[i-1,j];\n f[i,j]:=x+y;\n n:=n;\n end;\n for i:=1 to m-1 do\n for j:=0 to i do s[j]:=s[j]+f[i,j];\n dem:=0;\n for i:=m downto 1 do\n begin\n if i=m then x:=1 else x:=0;\n for j:=x to a[i]-1 do\n if (j=4) or (j=7) then\n begin\n for k:=dem+1 to 9 do\n for t:=0 to i-1 do s[k]:=s[k]+f[t,k-dem-1];\n end else\n begin\n for k:=dem to 9 do //s[k]:=s[k]+f[i-1,k-dem];\n for t:=0 to i-1 do s[k]:=s[k]+f[t,k-dem];\n end;\n if (a[i]=4) or (a[i]=7) then inc(dem);\n end;\n inc(s[dem]);\n gt[0]:=1; val[0]:=1;\n for i:=1 to 6 do gt[i]:=int64(gt[i-1])*i mod base;\n for i:=1 to 6 do val[i]:=mu(gt[i],base-2);\nend;\n\nfunction c(n,k:longint):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=n-k+1 to n do s:=int64(s)*i mod base;\n s:=int64(s)*val[k] mod base;\n exit(s);\nend;\n\nprocedure update(x:longint);\nvar i,j:longint;\nbegin\n j:=0;\n for i:=0 to x-1 do j:=j+a[i];\n if (j<>6) then exit;\n if (j-a[0]>=x) then exit;\n j:=1;\n for i:=0 to x-1 do j:=int64(j)*c(s[i],a[i]) mod base;\n j:=int64(j)*gt[6] mod base;\n sum:=(sum+j) mod base;\nend;\n\nprocedure trying(i,x,k:longint);\nvar j:longint;\nbegin\n if (i>x-1) then\n begin\n update(x);\n exit;\n end;\n //if i=0 then k:=6 else k:=x-1;\n for j:=0 to k do\n begin\n a[i]:=j;\n trying(i+1,x,k-j);\n a[i]:=0;\n end;\nend;\n\nprocedure lam(x:longint);\nvar i,j,k:longint;\nbegin\n sum:=0;\n trying(0,x,6);\n kq:=(kq+int64(s[x])*sum mod base) mod base\nend;\n\nprocedure process;\nvar i:longint;\nbegin\n for i:=1 to m do\n if s[i]>0 then lam(i);\n writeln(kq);\nend;\n\nprocedure check;\nvar i,j,dem:longint;\nbegin\n for i:=0 to m do write(s[i],' '); writeln;\n fillchar(s,sizeof(s),0);\n for i:=1 to n do\n begin\n j:=i; dem:=0;\n while j>0 do\n begin\n if (j mod 10=4) or (j mod 10=7) then inc(dem);\n j:=j div 10;\n end;\n inc(s[dem]);\n //if dem=0 then writeln('g',' ',i);\n end;\n for i:=0 to m do write(s[i],' '); writeln;\nend;\n\nBEGIN\n openfile;\n enter;\n prepare;\n process;\n //check;\n closefile;\nEND."}, {"source_code": "const md:int64=1000000007;\n\nvar s:string;\n p:integer;\n ans,t:int64;\n i,j,k,l,n,x,y,i1,i2,i3,i4,i5,i6:longint;\n a,u,w:array[0..21] of int64;\n v,f:array[0..21,0..21,0..21] of int64;\n\nfunction tt(x:int64):int64;\nvar s:int64;\n i:longint;\n begin\n s:=1;\n for i:=x-5 to x do\n s:=s*int64(i) mod md;\n tt:=s;\n end;\n\n begin\n read(n);\n str(n,s);\n l:=length(s);\n for i:=1 to l do\n val(s[i],a[i],p);\n\n v[0,1,0]:=1;\n for i:=1 to l do\n for j:=0 to 1 do\n for k:=0 to l do\n begin\n if v[i-1,j,k]=0 then continue;\n\n if j=0 then x:=9\n else x:=a[i];\n\n for y:=0 to x do\n begin\n if (y=0) and (i=1) then continue;\n\n if (y=4) or\n (y=7) then t:=k+1\n else t:=k;\n\n if (j=0) or\n ((j=1) and (yl) then continue;\n\n u[i1+i2+i3+i4+i5+i6]:=w[i1];\n if (i1<>i2) then inc(u[i1+i2+i3+i4+i5+i6],w[i2]);\n if (i1<>i3) and\n (i2<>i3) then inc(u[i1+i2+i3+i4+i5+i6],w[i3]);\n if (i1<>i4) and\n (i2<>i4) and\n (i3<>i4) then inc(u[i1+i2+i3+i4+i5+i6],w[i4]);\n if (i1<>i5) and\n (i2<>i5) and\n (i3<>i5) and\n (i4<>i5) then inc(u[i1+i2+i3+i4+i5+i6],w[i5]);\n\n if (i1<>i6) and\n (i2<>i6) and\n (i3<>i6) and\n (i4<>i6) and\n (i5<>i6) then inc(u[i1+i2+i3+i4+i5+i6],w[i6]);\n\n\n end;\n\n ans:=0;\n for i:=1 to l do\n begin\n t:=w[i];\n for k:=0 to j-1 do\n ans:=(ans+t*tt(u[k])) mod md;\n end;\n\n writeln(ans);\n end."}, {"source_code": "const md:int64=1000000007;\n\nvar s:string;\n p:integer;\n ans,t:int64;\n i,j,k,l,n,x,y:longint;\n a,w:array[0..21] of int64;\n lw:array[0..21] of boolean;\n v,f:array[0..21,0..21,0..21] of int64;\n\nfunction tt(x:int64):int64;\nvar s:int64;\n i:longint;\n begin\n s:=1;\n for i:=x-5 to x do\n s:=s*int64(i) mod md;\n tt:=s;\n end;\n\n begin\n read(n);\n str(n,s);\n l:=length(s);\n for i:=1 to l do\n val(s[i],a[i],p);\n\n v[0,1,0]:=1;\n for i:=1 to l do\n for j:=0 to 1 do\n for k:=0 to l do\n begin\n if v[i-1,j,k]=0 then continue;\n\n if j=0 then x:=9\n else x:=a[i];\n\n for y:=0 to x do\n begin\n\n if (y=4) or\n (y=7) then t:=k+1\n else t:=k;\n\n if (j=0) or\n ((j=1) and (yl) then continue;\n\n t:=0;\n if (i1=i1) then inc(t);\n if (i1=i2) then inc(t);\n if (i1=i3) then inc(t);\n if (i1=i4) then inc(t);\n if (i1=i5) then inc(t);\n if (i1=i6) then inc(t);\n if t>w[i1] then continue;\n\n t:=0;\n if (i2=i1) then inc(t);\n if (i2=i2) then inc(t);\n if (i2=i3) then inc(t);\n if (i2=i4) then inc(t);\n if (i2=i5) then inc(t);\n if (i2=i6) then inc(t);\n if t>w[i2] then continue;\n\n t:=0;\n if (i3=i1) then inc(t);\n if (i3=i2) then inc(t);\n if (i3=i3) then inc(t);\n if (i3=i4) then inc(t);\n if (i3=i5) then inc(t);\n if (i3=i6) then inc(t);\n if t>w[i3] then continue;\n\n t:=0;\n if (i4=i1) then inc(t);\n if (i4=i2) then inc(t);\n if (i4=i3) then inc(t);\n if (i4=i4) then inc(t);\n if (i4=i5) then inc(t);\n if (i4=i6) then inc(t);\n if t>w[i4] then continue;\n\n t:=0;\n if (i5=i1) then inc(t);\n if (i5=i2) then inc(t);\n if (i5=i3) then inc(t);\n if (i5=i4) then inc(t);\n if (i5=i5) then inc(t);\n if (i5=i6) then inc(t);\n if t>w[i5] then continue;\n\n t:=0;\n if (i6=i1) then inc(t);\n if (i6=i2) then inc(t);\n if (i6=i3) then inc(t);\n if (i6=i4) then inc(t);\n if (i6=i5) then inc(t);\n if (i6=i6) then inc(t);\n if t>w[i6] then continue;\n\n u[i1+i2+i3+i4+i5+i6]:=w[i1];\n\n\n\n if (i1<>i2) then inc(u[i1+i2+i3+i4+i5+i6],w[i2]);\n\n if (i1<>i3) and\n (i2<>i3) then inc(u[i1+i2+i3+i4+i5+i6],w[i3]);\n\n if (i1<>i4) and\n (i2<>i4) and\n (i3<>i4) then inc(u[i1+i2+i3+i4+i5+i6],w[i4]);\n\n if (i1<>i5) and\n (i2<>i5) and\n (i3<>i5) and\n (i4<>i5) then inc(u[i1+i2+i3+i4+i5+i6],w[i5]);\n\n if (i1<>i6) and\n (i2<>i6) and\n (i3<>i6) and\n (i4<>i6) and\n (i5<>i6) then inc(u[i1+i2+i3+i4+i5+i6],w[i6]);\n\n\n end;\n\n ans:=0;\n for i:=1 to l do\n begin\n t:=w[i];\n for k:=0 to j-1 do\n ans:=(ans+t*tt(u[k])) mod md;\n end;\n\n writeln(ans);\n end."}, {"source_code": "{$apptype console}\n{$b-}\n{$maxstacksize 1000000}\nconst md=1000000007;\nvar\n a:array[0..10,0..10] of int64;\n b:array[1..7,0..10] of int64;\n cnk:array[0..10,-11..10] of int64;\n cc:array[0..10] of byte;\n ct,st,error,c,m,k,add,i,j:integer;\n add1,cur,ans:int64;\n s:string;\n\n Procedure gen(k,r:byte);\n var\n i,j:integer;\n begin\n inc(ct);\n if k>6 then\n begin\n add1:=cur;\n // for i := 0 to 10 do write(cc[i],'! ');\n // writeln;\n for i := 0 to 10 do if (cc[i]>0) then\n add1:=add1*cnk[i,cc[i]-1];\n ans:=(ans+add1) mod md;\n end else\n begin\n for j := 0 to r do\n begin\n inc(cc[j]);\n gen(k+1,r-j);\n dec(cc[j]);\n end;\n end;\n end;\n\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n Fillchar(a,sizeof(a),0);\n a[1,1]:=2;\n a[1,0]:=7;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n readln(m);\n str(m,s);\n Fillchar(b,sizeof(b),0);\n for i := 0 to 10 do\n for j := 0 to length(s)-1 do\n b[1,i]:=(b[1,i]+a[j,i]) mod md;\n Fillchar(a,sizeof(a),0);\n\n a[1,1]:=2;\n a[1,0]:=8;\n a[0,0]:=1;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n\n add:=0;\n for i := 1 to length(s) do\n begin\n val(s[i],c,error);\n if (i=1) then st:=1 else st:=0;\n for j := st to c-1 do\n begin\n if (j=4) or (j=7) then inc(add);\n for k := add to length(s) do b[1,k]:=(b[1,k]+a[length(s)-i,k-add]) mod md;\n if (j=4) or (j=7) then dec(add);\n end;\n if (c=4) or (c=7) then inc(add);\n if (i=length(s)) then b[1,add]:=(b[1,add]+1) mod md;\n end;\n ans:=0;\n Fillchar(cc,sizeof(cc),0);\n Fillchar(cnk,sizeof(cnk),0);\n for i := 0 to 10 do cnk[i,0]:=b[1,i];\n for i := 0 to 10 do\n for j := 1 to 10 do cnk[i,j]:=(cnk[i,j-1]*(b[1,i]-j)) mod md;\n\n { for j :=0 to 10 do write(b[1,j],' ');\n writeln;\n writeln;\n\n for i := 0 to 10 do\n begin\n for j := 0 to 10 do write(cnk[i][j],' ');\n writeln;\n end; }\n\n for i := 1 to length(s) do\n begin\n cur:=b[1,i];\n gen(1,i-1);\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "{$apptype console}\n{$b-}\n{$maxstacksize 1000000}\nconst md=1000000007;\nvar\n a:array[0..10,0..10] of int64;\n b:array[1..7,0..10] of int64;\n cnk:array[0..10,-11..10] of int64;\n cc:array[0..10] of byte;\n ct,st,error,c,m,k,add,i,j:integer;\n add1,cur,ans:int64;\n s:string;\n\n Procedure gen(k,r:byte);\n var\n i,j:integer;\n begin\n inc(ct);\n if k>6 then\n begin\n add1:=cur;\n for i := 0 to 10 do if (cc[i]>0) then\n add1:=add1*cnk[i,cc[i]-1];\n ans:=(ans+add1) mod md;\n end else\n begin\n for j := 0 to r do\n begin\n inc(cc[j]);\n gen(k+1,r-j);\n dec(cc[r]);\n end;\n end;\n end;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Fillchar(a,sizeof(a),0);\n a[1,1]:=2;\n a[1,0]:=7;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n readln(m);\n str(m,s);\n Fillchar(b,sizeof(b),0);\n for i := 0 to 10 do\n for j := 0 to length(s)-1 do\n b[1,i]:=(b[1,i]+a[j,i]) mod md;\n Fillchar(a,sizeof(a),0);\n\n a[1,1]:=2;\n a[1,0]:=8;\n a[0,0]:=1;\n for i := 2 to 10 do\n for j :=0 to i do\n for k := 0 to 9 do\n begin\n if (k=4) or (k=7) then add:=1 else add:=0;\n a[i,j]:=a[i,j]+a[i-1,j-add];\n end;\n\n add:=0;\n for i := 1 to length(s) do\n begin\n val(s[i],c,error);\n if (i=1) then st:=1 else st:=0;\n for j := st to c-1 do\n begin\n if (j=4) or (j=7) then inc(add);\n for k := add to length(s) do b[1,k]:=(b[1,k]+a[length(s)-i,k-add]) mod md;\n if (j=4) or (j=7) then dec(add);\n end;\n if (c=4) or (c=7) then inc(add);\n if (i=length(s)) then b[1,add]:=(b[1,add]+1) mod md;\n end;\n ans:=0;\n Fillchar(cc,sizeof(cc),0);\n Fillchar(cnk,sizeof(cnk),0);\n for i := 0 to 10 do cnk[i,0]:=b[1,i];\n for i := 0 to 10 do\n for j := 1 to 10 do cnk[i,j]:=(cnk[i,j-1]*(b[1,i]-j)) mod md;\n\n for i := 1 to length(s) do\n begin\n cur:=b[1,i];\n gen(1,i-1);\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "{$R+,Q+,I+]\n{$apptype console}\n{$maxstacksize 10000000}\nUses SysUtils;\nVar\n i,j,k,n:Integer;\n m,md,f,t,ans,y,r,k1:Int64;\n g,p,h,w,l,a:Array[0..300000] of Int64;\n dp:Array[0..10,-10..10,0..2] of Int64;\nProcedure Solve(i,sum:Integer);\nVar\n j,i1:Integer;\n r,pr:Int64;\nBegin\n If sum>=y Then Exit;\n If i>6 Then Begin\n For j:=0 To y-1 Do h[j]:=0;\n For j:=1 To 6 Do h[w[j]]:=h[w[j]]+1;\n pr:=1;\n For i1:=0 To y-1 Do Begin\n r:=0;\n For j:=1 To h[i1] Do Begin\n pr:=(pr*(p[i1]-r)) mod md;\n r:=r+1;\n End;\n l[sum]:=(l[sum]+pr) mod md;\n End;\n Exit;\n End;\n For j:=0 To y-1 Do Begin\n w[i]:=j;\n Solve(i+1,sum+j);\n End;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>m Then Exit;\n n:=n+1;\n a[n]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(m);\n md:=1000000007;\n t:=m;\n i:=0;\n While t>0 Do Begin\n i:=i+1;\n t:=t div 10;\n End;\n y:=i;\n t:=m;\n i:=y;\n While t>0 Do Begin\n g[i]:=t mod 10;\n i:=i-1;\n t:=t div 10;\n End;\n If g[1]<>1 Then dp[1,0,0]:=1\n Else dp[1,0,1]:=1;\n For i:=2 To 9 Do Begin\n f:=0;\n If i=g[1] Then f:=1;\n If i<=g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1\n Else dp[1,1,f]:=dp[1,1,f]+1;\n End;\n If i>g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,2]:=dp[1,0,2]+1\n Else dp[1,1,2]:=dp[1,1,2]+1;\n End;\n End;\n For i:=2 To y Do\n For j:=0 To y Do Begin\n dp[i,j,0]:=dp[i-1,j,0];\n If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];\n dp[i,j,2]:=dp[i-1,j,2];\n If g[i]=0 Then dp[i,j,1]:=dp[i-1,j,1];\n For k:=1 To 9 Do Begin\n If (k<>4) and (k<>7) Then Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,1];\n End\n Else Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,1];\n End;\n If k=g[i] Then Begin\n If (k<>4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]\n Else dp[i,j,1]:=dp[i-1,j-1,1];\n End;\n End;\n End;\n For j:=0 To y Do\n For k:=1 To y Do\n If k<>y Then p[j]:=p[j]+dp[k,j,0]+dp[k,j,1]+dp[k,j,2]\n Else p[j]:=p[j]+dp[k,j,0]+dp[k,j,1];\n ans:=0;\n Solve(1,0);\n n:=0;\n Get(4);\n Get(7);\n k1:=0;\n For i:=1 To 20 Do Begin\n t:=i;\n r:=0;\n While t>0 Do Begin\n If (t mod 10=4) or (t mod 10=7) Then r:=r+1;\n t:=t div 10;\n End;\n If r=1 Then k1:=k1+1;\n End;\n For i:=1 To n Do Begin\n t:=a[i];\n r:=0;\n While t>0 Do Begin\n If (t mod 10=4) or (t mod 10=7) Then r:=r+1;\n t:=t div 10;\n End;\n For j:=0 To r-1 Do ans:=(ans+l[j]) mod md;\n End;\n Write(ans);\nEnd.\n\n\n\n"}, {"source_code": "{$R+,Q+,I+]\n{$apptype console}\n{$maxstacksize 10000000}\nUses SysUtils;\nVar\n i,j,k,n:Integer;\n m,md,f,t,ans,y,r:Int64;\n g,p,h,w,l,a:Array[0..300000] of Int64;\n dp:Array[0..10,-10..10,0..1] of Int64;\nProcedure Solve(i,sum:Integer);\nVar\n j,i1:Integer;\n r,pr:Int64;\nBegin\n If sum>=y Then Exit;\n If i>6 Then Begin\n For j:=0 To y-1 Do h[j]:=0;\n For j:=1 To 6 Do h[w[j]]:=h[w[j]]+1;\n pr:=1;\n For i1:=0 To y-1 Do Begin\n r:=0;\n For j:=1 To h[i1] Do Begin\n pr:=(pr*(p[i1]-r)) mod md;\n r:=r+1;\n End;\n l[sum]:=(l[sum]+pr) mod md;\n End;\n Exit;\n End;\n For j:=0 To y-1 Do Begin\n w[i]:=j;\n Solve(i+1,sum+j);\n End;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>m Then Exit;\n n:=n+1;\n a[n]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(m);\n md:=1000000007;\n t:=m;\n i:=0;\n While t>0 Do Begin\n i:=i+1;\n t:=t div 10;\n End;\n y:=i;\n t:=m;\n i:=y;\n While t>0 Do Begin\n g[i]:=t mod 10;\n i:=i-1;\n t:=t div 10;\n End;\n If g[1]<>1 Then dp[1,0,0]:=1\n Else dp[1,0,1]:=1;\n For i:=2 To g[1] Do Begin\n f:=0;\n If i=g[1] Then f:=1;\n If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1\n Else dp[1,1,f]:=dp[1,1,f]+1;\n End;\n For i:=2 To y Do\n For j:=0 To y Do Begin\n dp[i,j,0]:=dp[i-1,j,0];\n If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];\n For k:=1 To 9 Do Begin\n If (k<>4) and (k<>7) Then Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];\n If k4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]\n Else dp[i,j,1]:=dp[i-1,j-1,1];\n End;\n End;\n End;\n For j:=0 To y Do p[j]:=dp[y,j,0]+dp[y,j,1];\n ans:=0;\n Solve(1,0);\n n:=0;\n Get(4);\n Get(7);\n For i:=1 To n Do Begin\n t:=a[i];\n r:=0;\n While t>0 Do Begin\n If (t mod 10=4) or (t mod 10=7) Then r:=r+1;\n t:=t div 10;\n End;\n For j:=0 To r-1 Do ans:=(ans+l[j]) mod md;\n End;\n Write(ans);\nEnd.\n\n\n\n"}, {"source_code": "{$R+,Q+,I+]\n{$apptype console}\n{$maxstacksize 10000000}\nUses SysUtils;\nVar\n i,j,k,n:Integer;\n m,md,f,t,ans,y,r,k1:Int64;\n g,p,h,w,l,a:Array[0..300000] of Int64;\n dp:Array[0..10,-10..10,0..2] of Int64;\nProcedure Solve(i,sum:Integer);\nVar\n j,i1:Integer;\n r,pr:Int64;\nBegin\n If sum>=y Then Exit;\n If i>6 Then Begin\n For j:=0 To y-1 Do h[j]:=0;\n For j:=1 To 6 Do h[w[j]]:=h[w[j]]+1;\n pr:=1;\n For i1:=0 To y-1 Do Begin\n r:=0;\n For j:=1 To h[i1] Do Begin\n pr:=(pr*(p[i1]-r)) mod md;\n r:=r+1;\n End;\n End;\n l[sum]:=(l[sum]+pr) mod md;\n Exit;\n End;\n For j:=0 To y-1 Do Begin\n w[i]:=j;\n Solve(i+1,sum+j);\n End;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>m Then Exit;\n n:=n+1;\n a[n]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(m);\n md:=1000000007;\n t:=m;\n i:=0;\n While t>0 Do Begin\n i:=i+1;\n t:=t div 10;\n End;\n y:=i;\n t:=m;\n i:=y;\n While t>0 Do Begin\n g[i]:=t mod 10;\n i:=i-1;\n t:=t div 10;\n End;\n If g[1]<>1 Then dp[1,0,0]:=1\n Else dp[1,0,1]:=1;\n For i:=2 To 9 Do Begin\n f:=0;\n If i=g[1] Then f:=1;\n If i<=g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1\n Else dp[1,1,f]:=dp[1,1,f]+1;\n End;\n If i>g[1] Then Begin\n If (i<>4) and (i<>7) Then dp[1,0,2]:=dp[1,0,2]+1\n Else dp[1,1,2]:=dp[1,1,2]+1;\n End;\n End;\n For i:=2 To y Do\n For j:=0 To y Do Begin\n dp[i,j,0]:=dp[i-1,j,0];\n If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];\n dp[i,j,2]:=dp[i-1,j,2];\n If g[i]=0 Then dp[i,j,1]:=dp[i-1,j,1];\n For k:=1 To 9 Do Begin\n If (k<>4) and (k<>7) Then Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,1];\n End\n Else Begin\n dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,0];\n If kg[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,1];\n End;\n If k=g[i] Then Begin\n If (k<>4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]\n Else dp[i,j,1]:=dp[i-1,j-1,1];\n End;\n End;\n End;\n For j:=0 To y Do\n For k:=1 To y Do\n If k<>y Then p[j]:=p[j]+dp[k,j,0]+dp[k,j,1]+dp[k,j,2]\n Else p[j]:=p[j]+dp[k,j,0]+dp[k,j,1];\n ans:=0;\n Solve(1,0);\n n:=0;\n Get(4);\n Get(7);\n k1:=0;\n For i:=1 To m Do Begin\n t:=i;\n r:=0;\n While t>0 Do Begin\n If (t mod 10=4) or (t mod 10=7) Then r:=r+1;\n t:=t div 10;\n End;\n If r=4 Then k1:=k1+1;\n End;\n For i:=1 To n Do Begin\n t:=a[i];\n r:=0;\n While t>0 Do Begin\n If (t mod 10=4) or (t mod 10=7) Then r:=r+1;\n t:=t div 10;\n End;\n For j:=0 To r-1 Do ans:=(ans+l[j]) mod md;\n End;\n Write(ans);\nEnd.\n\n\n\n"}], "src_uid": "656ed7b1b80de84d65a253e5d14d62a9"} {"source_code": "var\n n, k, a, b : 0..2000000000;\n res, t : qword;\n //fin : text;\n label 1;\nbegin\n //assign(fin, 'inp.txt'); reset(fin);\n read(n, k, a, b);\n //close(fin);\n \n res := 0;\n \n if k = 1 then\n begin\n\t res := qword(qword(n - 1) * a);\n\t n := 1;\n\tend;\n \n while n > 1 do\n begin\n\t while ((n mod k <> 0) or (k = 1)) and (n > 1) do\n\t begin\n\t\t if (k * 2 > n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword(qword(n - k) * a);\n\t\t\t n := k;\n\t\t\tend\n\t\t else if (k * 2 < n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword(qword(n - qword((n div k) * k)) * a);\n\t\t\t n := qword((qword(n div k)) * k);\n\t\t\tend\n\t\t else if n < k then\n\t\t begin\n\t\t\t res := res + qword(qword(n - 1) * a);\n\t\t\t n := 1;\n\t\t\tend;\n\t\tend;\n\t\t\n\t 1:\n\t if (k <> 1) and (n mod k = 0) and (b > qword(qword(n - (n div k)) * a)) then\n\t begin\n\t\t res := res + qword(qword(n - (n div k)) * a);\n\t\t n := n div k;\n\t\t goto 1;\n\t\tend\n\t else if k <> 1 then\n\t begin\n\t\t while n mod k = 0 do\n\t begin\n\t\t\t if b > qword(qword(n - (n div k)) * a) then break;\n\t\t n := n div k;\n\t\t res := res + b;\n\t\t end;\n\t\tend;\n\tend;\n \n writeln(res);\nend.", "positive_code": [{"source_code": "var n,m,n1,n2,sum:int64;\nbegin\n//assign(input,'dshj.in');reset(input);\n//assign(output,'dshj.out');rewrite(output);\nreadln(n);\nreadln(m);\nreadln(n1);\nreadln(n2);\nif m=1 then begin writeln((n-1)*n1);close(input);close(output);halt;end;\nwhile n>1 do\n begin\n if n0 then sum:=sum+(n mod m)*n1;\n n:=n div m*m;\n if (n-n div m)*n1= k) do\nBegin\n\nmin:=min + a*((n mod k));\nn:=n - (n mod k);\nif (a*(n - (n div k)) < b) then min:=min + a*(n - (n div k)) else min:=min + b;\nn:=n div k;\n\nend;\n\nmin:=min + a*((n mod k) - 1);\n\nend;\n\nWriteln(min);\n\nReadln;\nEND."}, {"source_code": "var n,k,x,y,s:int64;\nbegin\n//assign(input,'dshj.in');reset(input);\n//assign(output,'dshj.out');rewrite(output);\nreadln(n);\nreadln(k);\nreadln(x);\nreadln(y);\nif k=1 then\n begin\n writeln((n-1)*x);\n close(input);close(output);\n halt;\n end;\nwhile n>=k do\n begin\n if n mod k=0 then\n if y<(n-n div k)*x then s:=s+y\n else s:=s+(n-n div k)*x\n else\n if y+n mod k*x<(n-n div k)*x then s:=s+y+n mod k*x\n else s:=s+(n-n div k)*x;\n n:=n div k;\n end;\nwriteln(s+(n-1)*x);\nclose(input);close(output);\nend.\n"}, {"source_code": "Var N,K,A,B,i,j,c : int64;\n\nBegin\n //assign(input,'input.txt'); reset(input);\n read(N,K,A,B);\n i:=N;\n if(k>1) then begin\n while(i<>1) do begin\n if(i mod K=0) then begin\n if(B>(i - (i div K))*A) then begin //���� ������ �� ������� N-(N div K) -- ���������� �������� ���������\n c:=c+(i - (i div K))*A;\n end else begin\n c:=c+B;\n end;\n i:=i div k;\n end else begin\n if(i>k) then begin\n c:=c+(i mod K)*A;\n i:=i-(i mod K);\n end else begin\n c:=c+(i-1)*A;\n i:=1;\n end;\n end;\n end; \n write(c);\n end else write((N-1)*A);\nend."}, {"source_code": "var\n n, k, a, b, ans, temp : int64;\nbegin\n read(n);\n read(k);\n read(a);\n read(b);\n // writeln(n, ' ', k, ' ', a, ' ', b);\n if k = 1\n then\n begin\n writeln(a * (n - 1));\n halt;\n end;\n while n > 1 do\n begin\n while n mod k = 0 do\n begin\n temp := n div k;\n if (n - temp) * a >= b\n then\n begin\n ans := ans + b;\n n := temp;\n end\n else\n begin\n ans := ans + ((n - 1) * a);\n n := 1;\n end;\n end;\n\n ans := ans + (a * (n mod k));\n n := n - (n mod k);\n if n = 0\n then ans := ans - a;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\nn,k,a,b,c:int64;\nw:int64;\nbegin\nread(n,k,a,b); w:=0;\nif k=1 then begin write(a*(n-1)); exit; end;\nwhile (n div k >0) and (n<>1) do begin\n w:=w+(n mod k)*a;\n n:=n-(n mod k);\n if bb then inc(ans,b)\n else\n inc(ans,a*(n-p));\n n:=p;\nend\nelse\n if n mod k <>0 then begin\n q:=n mod k;\n if n-q>=1 then begin\n ans:=ans+q*a;\n n:=n-q;\n end\n else begin\n ans:=ans+a*(n-1);\n n:=1;\n end;\n end;\nend;\nwriteln(Ans);\nend;\nend."}, {"source_code": "var\nn,k,a,b,c:int64;\nw:int64;\nbegin\nreadln(n,k,a,b);\nw:=0;\nif k=1 then begin write(a*(n-1)); exit; end;\nwhile (n div k >0) and (n<>1) do begin\n w:=w+(n mod k)*a;\n n:=n-(n mod k);\n if b1 do begin\nd := n div k;\ne:= n mod k;\nif (e = 0) then begin\nif (((n-(d))*a)>=b) then begin n:=d; c:=c+b; end\nelse begin c:=(c+a*(n-1)); n:=1; end;\nend\nelse begin n:=n-e; c:=c+a*e; end;\nend;\n\nwriteln(c);\n\n\nend.\n\n{\nelse begin n:=n-e; c:=c+a*e; end;\n\nelse begin n:=1; c:=c+a*(n-1); end;\n}"}, {"source_code": "var n,k,a,b,res,dx,dxp:int64;\n i,j:longint;\n\nbegin\nread(n,k,a,b);\nif k=1 then\n begin\n res:=(n-1)*A;\n writeln(res);\n end;\n \nif k>=2 then\n begin\n res:=0;\n while n <> 1 do\n begin\n if n mod k = 0 then\n begin\n dx:= n-(n div k);\n dxp:= dx * a;\n res += min(dxp,b);\n n := n div k;\n end\n else\n begin\n res += (n mod k)*a;\n n:=n - (n mod k);\n end;\n if n=0 then begin res:=res - a; n:=1; end; \n end;\n \n \n writeln(res);\n end;\n \nend."}, {"source_code": "var n,k,a,b:int64; s:int64;\nbegin\n readln(n,k,a,b);\n s:=0;\n while n>1 do\n if (k>1)and(n mod k=0)and(b<(n-n div k)*a)then\n begin\n s:=s+b;\n n:=n div k;\n end\n else\n if n mod k=0 then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n if n<=k then\n begin\n s:=s+(n mod k-1)*a;\n n:=n-n mod k;\n end\n else\n begin\n s:=s+(n mod k)*a;\n n:=n-n mod k;\n end;\n writeln(s);\nend."}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1,besk:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dot,dd:array[-10..1002,-1..1000] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp,kk,aa,bb); q:=0;ot:=0;\n if kk=1 then begin writeln((pp-1)*aa); goto 1; end;\n x[0]:=pp;\n if x[q]>kk then\n repeat\n begin\n inc(q);\n if x[q-1] mod kk=0 then x[q]:=x[q-1] div kk else x[q]:=x[q-1]-(x[q-1] mod kk);\n\n\n end;\n until (x[q]<=kk) or (q>100);\n\n inc(q); x[q]:=1;\n { for i:=0 to q do write(x[i],' '); writeln;\n } for i:=1 to q do\n begin\n if x[i-1] mod kk=0 then\n begin\n { writeln((x[i-1]-x[i])*aa,' <> ',bb);\n } p:=min(abs(x[i-1]-x[i])*aa,bb);\n end else\n begin\n p:=(x[i-1]-x[i])*aa;\n end;\n ot:=ot+p;\n\n\n end;\n\n writeln(ot);\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "program z2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,k,a,b,x:int64;\n money:int64;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n readln(k);\n readln(a);\n readln(b);\n x:=n;\n money:=0;\n if k=1 then money:=a*(x-1)\n else\n begin\n while x<>1 do\n begin\n if x>=k then\n begin\n if x mod k<>0 then\n begin\n money:=money+(x mod k)*a;\n x:=x-(x mod k);\n end\n else\n begin\n if (x-(x div k))*a>b\n then money:=money+b\n else money:=money+(x-(x div k))*a;\n x:=x div k;\n end;\n end\n else\n begin\n money:=money+(x-1)*a;\n x:=1;\n end;\n end; \n end;\n writeln(money);\nend.\n"}, {"source_code": "program CODEFORCES;\n\nvar\n n, k, a, b, x, d, y, c ,res:qword;\n //inp:text;\nbegin\n //assign(inp,'INPUT.txt');\n //reset(inp);\n Read({inp,}n, k, a, b);\n x := n;\n if k = 1 then begin\n x:=1;\n res:=(n-1)*a;\n end;\n while (x <> 1) do\n begin\n d := x mod k;\n if d = 0 then\n begin\n y := x div k;\n c := (x - y) * a;\n if b <= c then\n Inc(res, b)\n else\n Inc(res, c);\n x := y;\n end\n else\n begin\n if x >= k then\n begin\n x := x - d;\n Inc(res, d * a);\n end\n else\n begin\n x := 1;\n Inc(res, (d - 1) * a);\n end;\n end;\n end;\n Write(res);\nend."}, {"source_code": "Program urh1;\nVar i,y,x,k,n,a,b,s:int64;\nBegin\nReadln(n,k,a,b);\nWhile n>1 do\nbegin\nIf (k<>1) and (n mod k=0) and (b<(n-n div k)*a) Then\nbegin\n s:=s+b;\n n:=n div k;\nend\n else\n If (n mod k=0) Then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n If (n>k) Then\n begin s:=s+a*(n mod k);n:=n-n mod k end\n else\n begin s:=s+a*(n-1);n:=1 end\nend;\nWriteln(s);\nend."}, {"source_code": "var\nw,n,k,a,b,c:int64;\nbegin\nread(n,k,a,b); w:=0;\nif (k=1) then begin write(a*(n-1)); exit; end;\nwhile (n div k >0) and (n<>1) do begin\n w:=w+(n mod k)*a;\n n:=n-(n mod k);\n if b0) and (n<>1) do begin\n w:=w+(n mod k)*a;\n n:=n-(n mod k);\n if b1 do\nbegin\nIf (k<>1) and (n mod k=0) and (b<(n-n div k)*a) Then\nbegin\n s:=s+b;\n n:=n div k;\nend\n else\n If (n mod k=0) Then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n If (n>k) Then\n begin s:=s+a*(n mod k);n:=n-n mod k end\n else\n begin s:=s+a*(n-1);n:=n-n mod k end\nend;\nWriteln(s);\nend."}, {"source_code": "var\n n, k, a, b, x, s: int64;\nbegin\n read(n, k, a, b);\n if k=1 then begin write(a*(n-1));halt;end;\n x := n;\n \n while x <> 1 do\n begin\n if x mod k = 0 then begin\n if b < a * (x - x div k) then begin s := s + b;x := x div k; end \n else begin s := s + a * (x - x div k);x := x div k; end; end\n else begin s := s + a * (x mod k);x := x - x mod k;if x<1 then begin s:=s-a*(1-x);x:=1;end; end;\n end;\n write(s);\n \nend."}, {"source_code": "Program z1;\nvar n,k,a,b:int64;\n s:int64;\nbegin\nreadln(n);\nreadln(k);\nreadln(a);\nread(b);\nif k=1 then begin s:=(n-1)*A;n:=1;end;\nwhile n>1 do\nbegin\nif n mod k<>0 then if nb) then\n begin\n n:=n div k;\n sum:=sum+b;\n end\n else\n begin\n if n mod k=0 then\n begin\n sum:=sum+(n-1)*a;\n break;\n end;\n sum:=sum+a*(n mod k);\n n:=n-n mod k;\n end;\n end;\nwriteln(sum);\nclose(input);close(output);\nend."}, {"source_code": "var n,m,x,y,s:int64;\nbegin\n//assign(input,'dshj.in');reset(input);\n//assign(output,'dshj.out');rewrite(output);\nreadln(n);\nreadln(m);\nreadln(x);\nreadln(y);\nif m=1 then\n begin\n writeln((n-1)*x);\n close(input);close(output);halt;\n end\nelse\n if n=1 then\n begin\n writeln(0);\n close(input);close(output);halt;\n end;\ns:=n mod m*x;\nn:=n-n mod m;\nwhile n<>1 do\n begin\n if n1 do\n if (k>1)and(n mod k=0)and(b<(n-n div k)*a)then\n begin\n s:=s+b;\n n:=n div k;\n end\n else\n if n mod k=0 then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n if n-n mod k=0 then\n begin\n s:=s+(n mod k-1)*a;\n n:=n-n mod k;\n end\n else\n begin\n s:=s+(n mod k)*a;\n n:=n-n mod k;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var n,x,a,b,sum,z:int64;\n\nbegin\n//assign(input,'dshj.in');reset(input);\n//assign(output,'dshj.out');rewrite(output);\nreadln(n);\nreadln(x);\nreadln(a);\nreadln(b);\nif x=1 then\n write((n-1)*a)\nelse\n begin\n while n>=x do\n begin\n z:=n mod x;\n sum:=sum+z*a;\n n:=n-z;\n if b<(n-(n div x))*a then\n sum:=sum+b\n else\n sum:=sum+(n-(n div x))*a;\n n:=n div x;\n end;\n write(sum+(n-1)*a);\n end;\nclose(input);\nclose(output);\nend."}, {"source_code": "var a,b,c,d,e,s:int64;\nbegin\n//assign(input,'dshj.in');reset(input);\n//assign(output,'dshj.out');rewrite(output);\nreadln(a,b,c,d);\nif b=1 then s:=(a-1)*c else\nwhile a<>1 do\n begin\n if a(a-a div b)*c then s:=s+(a-a div b)*c else s:=s+d;\n a:=a div b;\n end;\nwriteln(s);\nclose(input);close(output);\nend."}], "negative_code": [{"source_code": "Program ILoveYou;\nVAR n,k,a,b,s,sum:int64;\nBegin\n\nReadln(n);\nReadln(k);\nReadln(a);\nReadln(b);\n\nif (k > 1) then\nbegin\n\nwhile (n > 1) do\nBegin\n\nif (n > k) then\nBegin\n\nif (n mod k = 0) then\nBegin\n\nif (b < a*(n - (n mod k))) then Begin sum:=sum + b; n:=n div k; end else Begin sum:=sum + a*(n - (n mod k)); n:=n - (n mod k); end;\n\nend else Begin sum:=sum + a*(n mod k); n:=n - (n mod k); end;\n\nend else Begin\n\nif (n = k) then\nBegin\n\nif (b < (a)*(n - 1)) then sum:=sum + b else sum:=sum + (a)*((n) - 1);\nn:=1;\n\nend else\nBegin\nsum:=sum + (a)*((n) - 1);\nn:=1;\nend;\n\nend;\n\nend;\n\nend else sum:=n*a;\n\nWriteln(sum);\n\nReadln;\nEND."}, {"source_code": "Program ILoveYou;\nVAR n,k,a,b,s,sum:int64;\nBegin\n\nReadln(n);\nReadln(k);\nReadln(a);\nReadln(b);\nwhile (n > 1) do\nBegin\n\nif (n mod k = 0) then\nBegin\n\nif (b < a*(n - (n div k))) then Begin sum:=sum + b; n:=n div k; end else Begin sum:=sum + a; n:=n - 1; end;\n\nend else Begin sum:=sum + a*(n mod k); n:=n - (n mod k); end;\n\n\nend;\n\nWriteln(sum);\n\nReadln;\nEND."}, {"source_code": "Var N,K,A,B,i,j,c : int64;\n\nBegin\n read(N,K,A,B);\n i:=N;\n {while(i<>1) do begin\n if(i mod K=0) then begin\n if(B>(i - (i div K))*A) then begin //���� ������ �� ������� N-(N div K) -- ���������� �������� ���������\n c:=c+(i - (i div K))*A;\n end else begin\n c:=c+B;\n end;\n i:=i div k;\n end else begin\n i:=i-1;\n c:=c+A;\n end;\n end; \n write(c);}\n \n if(N=9) then write(6)\n else if(N=5) then write(8)\n else if(N=19) then write(12);\nend."}, {"source_code": "var \nmin, max, a,b,c,d,i,l,t,y,u,e,r,j,g,n,k:longint;\nbegin\nread(n,k,a,b);\nc:=0;\nwhile n<>1 do begin\nd := n div k;\ne:= n mod k;\nif (e = 0) then begin\nif (((n-(d))*a)>=b) then begin n:=d; c:=c+b; end\nelse begin c:=(c+a*(n-1)); n:=1; end;\nend\nelse begin n:=n-e; c:=c+a*e; end;\nend;\n\nwriteln(c);\n\n\nend.\n\n{\nelse begin n:=n-e; c:=c+a*e; end;\n\nelse begin n:=1; c:=c+a*(n-1); end;\n}"}, {"source_code": "var \nmin, max, a,b,c,d,i,l,t,y,u,e,r,j,g,n,k:longint;\nbegin\nread(n,k,a,b);\nc:=0;\nwhile n<>1 do begin\nd := n div k;\nif (n mod k = 0) then begin\nif (((n-(d))*a)>=b) then begin n:=d; c:=c+b; end\nelse begin n:=1; c:=c+a*(n-1); end;\nend\nelse begin dec(n); c:=c+a; end;\n\nend;\nwriteln(c);\n\n\nend."}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1,besk:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dot,dd:array[-10..1002,-1..1000] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp,kk,aa,bb); q:=0;ot:=0;\n if kk=1 then begin writeln((pp-1)*aa); goto 1; end;\n while pp>0 do\n begin\n inc(q);\n x[q]:=pp;\n a[q]:=pp mod kk;\n y[q]:=pp div kk;\n pp:=pp div kk;\n\n end;\n\n{for i:=1 to q do writeln(a[i],' ',x[i],' ',y[i]);\n} for i:=1 to q-1 do\n begin\n ot:=ot+(a[i])*aa;\n p1:=(x[i]-x[i+1])*aa;\n p2:=bb;\n { writeln(p1,' <> ',p2);\n } ot:=ot+min(p1,p2);\n { writeln('i= ',i,' ot= ',ot);\n }\n\n\n end;\n\n { writeln('ot= ',ot);\n }\n ot:=ot+aa*(x[q]-1);\n\n writeln(ot);\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1,besk:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dot,dd:array[-10..1002,-1..1000] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp,kk,aa,bb); q:=0;ot:=0;\n if kk=1 then begin writeln((pp-1)*aa); goto 1; end;\n x[0]:=pp;\n repeat\n begin\n inc(q);\n if x[q-1] mod kk=0 then x[q]:=x[q-1] div kk else x[q]:=x[q-1]-(x[q-1] mod kk);\n\n\n end;\n until (x[q]<=kk) or (q>100);\n\n inc(q); x[q]:=1;\n { for i:=0 to q do write(x[i],' '); writeln;\n } for i:=1 to q do\n begin\n if x[i-1] mod kk=0 then\n begin\n { writeln((x[i-1]-x[i])*aa,' <> ',bb);\n } p:=min(abs(x[i-1]-x[i])*aa,bb);\n end else\n begin\n p:=(x[i-1]-x[i])*aa;\n end;\n ot:=ot+p;\n\n\n end;\n\n writeln(ot);\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n int64=longint;\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1,besk:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dot,dd:array[-10..1002,-1..1000] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp,kk,aa,bb); q:=0;ot:=0;\n if kk=1 then begin writeln((pp-1)*aa); goto 1; end;\n while pp>0 do\n begin\n inc(q);\n x[q]:=pp;\n a[q]:=pp mod kk;\n y[q]:=pp div kk;\n pp:=pp div kk;\n\n end;\n\n{for i:=1 to q do writeln(a[i],' ',x[i],' ',y[i]);\n} for i:=1 to q-1 do\n begin\n ot:=ot+(a[i])*aa;\n p1:=(x[i]-x[i+1])*aa;\n p2:=bb;\n { writeln(p1,' <> ',p2);\n } ot:=ot+min(p1,p2);\n { writeln('i= ',i,' ot= ',ot);\n }\n\n\n end;\n\n { writeln('ot= ',ot);\n }\n ot:=ot+aa*(x[q]-1);\n\n writeln(ot);\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": " const eps=0.00000001; besk1=200000008; nn=200000; modul=1000000007;\n label 1,2,3,4;\n type real=double; {string=ansistring;}\n mas=array [-10..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var p1ch,p1zn,p2ch,p2zn,p3ch,p3zn,t2,t1,kk,jj,wogr,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,p1,p2,p3,p4,t,ot,nm,n,s1,s2,m,s,smin,cen,dl,i1,besk:int64;\n step, k,i,j:longint;\n ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n ll,rr, aa,bb,cc:int64;\n d,dnew, left2,right2, left1,right1,pos1,pos2,l,r,c,zz,z,y,x,aold,b,a:array[-10..2000000] of int64;\n dot,dd:array[-10..1002,-1..1000] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss1,sss:string;\n prost,zan,fl:array[-100..1000000] of boolean;\n ss1,ss2,ss:string;ch:char;\n pole :array [-10..2010,-10..2010] of char;\n maxpr:array[0..nn] of string;\n ss1p1,ss1p2,ss2p1,ss2p2:array[0..nn] of string;\n x1,y1,xx,yy,x0,y0,ott,v0,v1,s0,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n xxx,yyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function summ(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=t1 div tt mod modul;\n t2:=t2 div tt mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n summ:=@ott;\n end;\n\n function prod(xx,yy:zap):zap1;\nvar t1,t2,tt:int64; ott:zap;\n begin\n t1:=(xx.p1*yy.p1) mod modul;\n t2:=(xx.p2*yy.p2) mod modul;\n tt:=nod(t1,t2);\n t1:=(t1 div tt) mod modul;\n t2:=(t2 div tt) mod modul;\n ott.p1:=t1; ott.p2:=t2;\n\n prod:=@ott;\n end;\n\n\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp,kk,aa,bb); q:=0;ot:=0;\n if kk=1 then begin writeln((pp-1)*aa); goto 1; end;\n while pp>0 do\n begin\n inc(q);\n x[q]:=pp;\n a[q]:=pp mod kk;\n y[q]:=pp div kk;\n pp:=pp div kk;\n\n end;\n\n{for i:=1 to q do writeln(a[i],' ',x[i],' ',y[i]);\n} for i:=1 to q-1 do\n begin\n ot:=ot+(a[i])*aa;\n p1:=(x[i]-x[i+1])*aa;\n p2:=bb;\n { writeln(p1,' <> ',p2);\n } ot:=ot+min(p1,p2);\n { writeln('i= ',i,' ot= ',ot);\n }\n\n\n end;\n\n { writeln('ot= ',ot);\n }\n ot:=ot+aa*(x[q]-1);\n\n writeln(min(ot,(x[1]-1)*aa));\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "program z2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,k,a,b,x,i:longint;\n money:int64;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n readln(k);\n readln(a);\n readln(b);\n x:=n;\n money:=0;\n while x<>1 do\n begin\n if x>=k then\n begin\n if x mod k<>0 then\n begin\n money:=money+(x mod k)*a;\n x:=x-(x mod k);\n end\n else\n begin\n if (x-(x div k))*a>b\n then money:=money+b\n else money:=money+(x-(x div k))*a;\n x:=x div k;\n end;\n end\n else\n begin\n money:=money+(x-1)*a;\n x:=1;\n end;\n end;\n writeln(money);\nend.\n"}, {"source_code": "Program urh1;\nVar i,y,x,k,n,a,b,s:Longint;\nBegin\nReadln(n,k,a,b);\nWhile n>1 do\nbegin\nIf (k<>1) and (n mod k=0) and (b<(n-n div k)*a) Then\nbegin\n s:=s+b;\n n:=n div k;\nend\n else\n If (n mod k=0) Then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n If (n>k) Then\n begin s:=s+a*(n mod k);n:=n-n mod k end\n else\n begin s:=s+a*(n-1);n:=n-n mod k end\nend;\nWriteln(s);\nend."}, {"source_code": "Program urh1;\nVar i,y,x,k,n,a,b:Longint;\nBegin\nReadln(n,k,a,b);\nWhile n>1 do\nbegin\nIf (k<>1) and (n mod k=0) Then\nbegin\n y:=y+b;\n n:=n div 2;\nend\nelse\nIf (n mod k<>0) Then\nbegin\n x:=x+a;\n n:=n-1;\nend;\nend;\ni:=x+y;\nWriteln(i);\nend.\n\n"}, {"source_code": "var\n n, k, a, b, ans, temp : int64;\nbegin\n read(n);\n read(k);\n read(a);\n read(b);\n if k = 1\n then\n begin\n writeln(a * (n - 1));\n halt;\n end;\n while n > 1 do\n begin\n while n mod k = 0 do\n begin\n temp := n div k;\n if (n - temp) * a >= b\n then\n begin\n ans := ans + b;\n n := temp;\n end\n else\n begin\n ans := ans + ((n - 1) * a);\n n := temp;\n end;\n end;\n\n ans := ans + (a * (n mod k));\n n := n - (n mod k);\n if n = 0\n then ans := ans - a;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n n, k, a, b, ans, temp : int64;\nbegin\n read(n);\n read(k);\n read(a);\n read(b);\n writeln(n, ' ', k, ' ', a, ' ', b);\n if k = 1\n then\n begin\n writeln(a * (n - 1));\n halt;\n end;\n while n > 1 do\n begin\n while n mod k = 0 do\n begin\n temp := n div k;\n if (n - temp) * a >= b\n then\n begin\n ans := ans + b;\n n := temp;\n end\n else\n begin\n ans := ans + ((n - 1) * a);\n n := 1;\n end;\n end;\n\n ans := ans + (a * (n mod k));\n n := n - (n mod k);\n if n = 0\n then ans := ans - a;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n n, k, a, b, ans, temp : longint;\nbegin\n read(n);\n read(k);\n read(a);\n read(b);\n while n > 1 do\n begin\n if n mod k = 0\n then\n begin\n temp := n div k;\n if (n - temp) * a >= b\n then\n begin\n ans := ans + b;\n n := temp;\n end\n else\n begin\n ans := ans + ((n - temp) * a);\n n := temp;\n end;\n end\n else\n begin\n ans := ans + (a * (n mod k));\n n := n - (n mod k);\n if n = 0\n then ans := ans - a;\n end;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var n,k,A,B,w:integer;\nbegin\nreadln(n,k,A,B);\nw:=0;\nif k=1 then begin write(a*(n-1)); exit; end;\nwhile (n div k >0) and (n<>1) do begin\n w:=w+(n mod k)*a;\n n:=n-(n mod k);\n if b 1 do\n begin\n\t while (n mod k <> 0) and (n > 1) do\n\t begin\n\t\t if (k * 2 > n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword((n - k) * a);\n\t\t\t n := k;\n\t\t\tend\n\t\t else if (k * 2 < n) and (n > k) then\n\t\t begin\n\t\t\t t := k;\n\t\t\t while (t + k < n) do t := t + k;\n\t\t\t res := res + qword((n - t) * a);\n\t\t\t n := t;\n\t\t\tend\n\t\t else if n < k then\n\t\t begin\n\t\t\t res := res + qword((n - 1) * a);\n\t\t\t n := 1;\n\t\t\tend;\n\t\tend;\n\t\t\n\t 1:\n\t if (n mod k = 0) and (b > (n - (n div k)) * a) then\n\t begin\n\t\t res := qword((n - (n div k)) * a);\n\t\t n := n div k;\n\t\t goto 1;\n\t\tend\n\t else\n\t begin\n\t\t while n mod k = 0 do\n\t begin\n\t\t n := n div k;\n\t\t res := res + b;\n\t\t end;\n\t\tend;\n\tend;\n \n writeln(res);\nend."}, {"source_code": "var\n n, k, a, b : 0..2000000000;\n res, t : qword;\n //fin : text;\n label 1;\nbegin\n //assign(fin, 'inp.txt'); reset(fin);\n read(n, k, a, b);\n //close(fin);\n \n res := 0;\n \n if k = 1 then\n begin\n\t res := qword(qword(n - 1) * a);\n\t n := 1;\n\tend;\n \n while n > 1 do\n begin\n\t while ((n mod k <> 0) or (k = 1)) and (n > 1) do\n\t begin\n\t\t if (k * 2 > n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword(qword(n - k) * a);\n\t\t\t n := k;\n\t\t\tend\n\t\t else if (k * 2 < n) and (n > k) then\n\t\t begin{\n\t\t\t t := k;\n\t\t\t while (t + k < n) do t := t + k;\n\t\t\t res := res + qword(qword(n - t) * a);\n\t\t\t n := t;}\n\t\t\t \n\t\t\t while k * 2 < n do begin\n\t\t\t n := qword(n div k);\n\t\t\t res := res + qword(qword(n - (n div k)) * a);\n\t\t\t end;\n\t\t\t \n\t\t\tend\n\t\t else if n < k then\n\t\t begin\n\t\t\t res := res + qword(qword(n - 1) * a);\n\t\t\t n := 1;\n\t\t\tend;\n\t\tend;\n\t\t\n\t 1:\n\t if (k <> 1) and (n mod k = 0) and (b > qword(qword(n - (n div k)) * a)) then\n\t begin\n\t\t res := res + qword(qword(n - (n div k)) * a);\n\t\t n := n div k;\n\t\t goto 1;\n\t\tend\n\t else if k <> 1 then\n\t begin\n\t\t while n mod k = 0 do\n\t begin\n\t\t n := n div k;\n\t\t res := res + b;\n\t\t end;\n\t\tend;\n\tend;\n \n writeln(res);\nend."}, {"source_code": "var\n n, k, a, b : 0..2000000000;\n res, t : qword;\n //fin : text;\n label 1;\nbegin\n //assign(fin, 'inp.txt'); reset(fin);\n read(n, k, a, b);\n //close(fin);\n \n res := 0;\n \n if k = 1 then\n begin\n\t res := qword(qword(n - 1) * a);\n\t n := 1;\n\tend;\n \n while n > 1 do\n begin\n\t while ((n mod k <> 0) or (k = 1)) and (n > 1) do\n\t begin\n\t\t if (k * 2 > n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword(qword(n - k) * a);\n\t\t\t n := k;\n\t\t\tend\n\t\t else if (k * 2 < n) and (n > k) then\n\t\t begin\n\t\t\t t := k;\n\t\t\t while (t + k < n) do t := t + k;\n\t\t\t res := res + qword(qword(n - t) * a);\n\t\t\t n := t;\n\t\t\tend\n\t\t else if n < k then\n\t\t begin\n\t\t\t res := res + qword(qword(n - 1) * a);\n\t\t\t n := 1;\n\t\t\tend;\n\t\tend;\n\t\t\n\t 1:\n\t if (k <> 1) and (n mod k = 0) and (b > (n - (n div k)) * a) then\n\t begin\n\t\t res := qword(qword(n - (n div k)) * a);\n\t\t n := n div k;\n\t\t goto 1;\n\t\tend\n\t else if k <> 1 then\n\t begin\n\t\t while n mod k = 0 do\n\t begin\n\t\t n := n div k;\n\t\t res := res + b;\n\t\t end;\n\t\tend;\n\tend;\n \n writeln(res);\nend."}, {"source_code": "var\n n, k, a, b : 0..2000000000;\n res, t : qword;\n //fin : text;\n label 1;\nbegin\n //assign(fin, 'inp.txt'); reset(fin);\n read(n, k, a, b);\n //close(fin);\n \n res := 0;\n \n if k = 1 then\n begin\n\t res := qword(qword(n - 1) * a);\n\t n := 1;\n\tend;\n \n while n > 1 do\n begin\n\t while ((n mod k <> 0) or (k = 1)) and (n > 1) do\n\t begin\n\t\t if (k * 2 > n) and (n > k) then\n\t\t begin\n\t\t\t res := res + qword(qword(n - k) * a);\n\t\t\t n := k;\n\t\t\tend\n\t\t else if (k * 2 < n) and (n > k) then\n\t\t begin{\n\t\t\t t := k;\n\t\t\t while (t + k < n) do t := t + k;\n\t\t\t res := res + qword(qword(n - t) * a);\n\t\t\t n := t;}\n\t\t\t \n\t\t\t res := res + qword(qword(n - qword((n div k) * k)) * a);\n\t\t\t n := qword((qword(n div k)) * k);\n\t\t\t \n\t\t\tend\n\t\t else if n < k then\n\t\t begin\n\t\t\t res := res + qword(qword(n - 1) * a);\n\t\t\t n := 1;\n\t\t\tend;\n\t\tend;\n\t\t\n\t 1:\n\t if (k <> 1) and (n mod k = 0) and (b > qword(qword(n - (n div k)) * a)) then\n\t begin\n\t\t res := res + qword(qword(n - (n div k)) * a);\n\t\t n := n div k;\n\t\t goto 1;\n\t\tend\n\t else if k <> 1 then\n\t begin\n\t\t while n mod k = 0 do\n\t begin\n\t\t n := n div k;\n\t\t res := res + b;\n\t\t end;\n\t\tend;\n\tend;\n \n writeln(res);\nend."}, {"source_code": "var n,k,a,b:int64; s:int64;\nbegin\n readln(n,k,a,b);\n s:=0;\n while n>1 do\n if (k>1)and(n mod k=0)and(b<(n-n div k)*a)then\n begin\n s:=s+b;\n n:=n div k;\n end\n else\n if n mod k=0 then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n {if n-n mod k=0 then\n begin\n s:=s+(n mod k-1)*a;\n n:=n-n mod k;\n end\n else }\n begin\n s:=s+(n mod k)*a;\n n:=n-n mod k;\n end;\n writeln(s);\nend.\n"}, {"source_code": "program CODEFORCES;\n\nvar\n n, k, a, b, x, d, y, c, res: cardinal;\nbegin\n Read(n, k, a, b);\n x := n;\n while (x <> 1) do\n begin\n d := x mod k;\n if d = 0 then\n begin\n y := x div k;\n c := (x - y) * a;\n if b <= c then\n Inc(res, b)\n else\n Inc(res, c);\n x := y;\n end\n else\n begin\n if x >= k then\n begin\n x := x - d;\n Inc(res, d * a);\n end\n else\n begin\n x := 1;\n Inc(res, (d - 1) * a);\n end;\n end;\n end;\n Write(res);\nend."}, {"source_code": "program CODEFORCES;\n\nvar\n n, k, a, b, x, d, y, c: cardinal; res:qword;\nbegin\n Read(n, k, a, b);\n x := n;\n while (x <> 1) do\n begin\n d := x mod k;\n if d = 0 then\n begin\n y := x div k;\n c := (x - y) * a;\n if b <= c then\n Inc(res, b)\n else\n Inc(res, c);\n x := y;\n end\n else\n begin\n if x >= k then\n begin\n x := x - d;\n Inc(res, d * a);\n end\n else\n begin\n x := 1;\n Inc(res, (d - 1) * a);\n end;\n end;\n end;\n Write(res);\nend."}, {"source_code": "var m,n,k,a,b,c,S1,S2:int64;\nbegin\nreadln(n);\nreadln(k);\nreadln(a);\nreadln(b);\nif k=1 then begin write(a*(n-1)); exit; end;\nm:=n;\nS2:=(n-1)*a;\nwhile m>1 do\n begin\n if (m mod k=0) and (m>1) then\n begin\n m:=m div k;\n S1:=S1+b;\n end;\n if (m mod k>0) and (m>1) then\n begin\n c:=m mod k;\n S1:=S1+c*a;\n m:=m-c;\n end;\n if m<1 then\n S1:=S1-a;\n if S1>S2 then break;\n end;\nif S1>S2 then write(S2)\n else write(S1);\nend."}, {"source_code": "var\n n, k, a, b, x, s: longint;\n\nbegin\n read(n, k, a, b);\n x := n;\n \n while x <> 1 do\n begin\n if x mod k = 0 then begin\n if b < a * (x - x div k) then begin s := s + b;x := x div k; end \n else begin s := s + a * (x - x div k);x := x div k; end; end\n else begin s := s + a * (x mod k);x := x - x mod k;if x=0 then begin x:=1;s:=s-a;end; end;\n end;\n write(s);\n \nend."}, {"source_code": "Program z1;\nvar n,k,a,b:longint;\n s:int64;\nbegin\nreadln(n);\nreadln(k);\nreadln(a);\nread(b);\nwhile n>1 do\nbegin\nif n mod k<>0 then if n1 do\nbegin\nif n mod k<>0 then if n1 do\n if (k>1)and(n mod k=0)and(b<(n-n div k)*a)then\n begin\n s:=s+b;\n n:=n div k;\n end\n else\n if n mod k=0 then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n if n-n mod k=0 then\n begin\n s:=s+(n mod k-1)*a;\n n:=n-n mod k;\n end\n else\n begin\n s:=s+(n mod k)*a;\n n:=n-n mod k;\n end;\n writeln(s);\nend.\n"}, {"source_code": "var n,k,a,b:int64; s:int64;\nbegin\n readln(n,k,a,b);\n s:=0;\n while n>1 do\n if (k>1)and(n mod k=0)and(b<(n-n div k)*a)then\n begin\n s:=s+b;\n n:=n div k;\n end\n else\n if n mod k=0 then\n begin\n s:=s+(n-1)*a;\n n:=1;\n end\n else\n { if n-n mod k=0 then\n begin\n s:=s+(n mod k-1)*a;\n n:=n-n mod k;\n end\n else }\n begin\n s:=s+(n mod k)*a;\n n:=n-n mod k;\n end;\n writeln(s);\nend."}], "src_uid": "f838fae7c98bf51cfa0b9bd158650b10"} {"source_code": "Program D_D;\nconst eps=1e-12;\nvar i : longint;\n\tp,n,sum,h : Extended;\n st,k,l,r,Mid : longint;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n\tp:=p*6;\n\tst:=0;\n\twhile sqr(st*1.5+4)+sqr(0.5*sqrt(3)*(st mod 2))<=n*n do\n st :=st+1;\n\n sum:=0;\n for k := st downto 1 do\n begin\n l:=0;\n if k mod 2=0 then r := (k-2) div 2 else\n r := k div 2;\n while l=sqr(h)+sqr((k-1)*1.5+4) then\n l := Mid else r :=Mid-1;\n\n end;\n if k mod 2=0 then l := l*2+2 else\n l:=l*2+1;\n sum := sum+l;\n end;\n\tsum:=sum*6+p+1;\n\twriteln(sum:0:0);\n\nend.\n", "positive_code": [{"source_code": "var\n i,j : longint;\n\n r,\n kq : int64;\nfunction kc(i,j : int64) : int64;\n begin\n if i and 1 = 1 then begin\n i := (i+1) >> 1;\n if j >= i then\n kc := ( sqr(3*i-1) + 3*sqr(j) ) << 2\n else\n kc := sqr(6*i-1) + 3*sqr(j << 1 -1);\n end\n else begin\n i := i >> 1;\n if j >= i then\n kc := sqr(6*i+1) + 3*sqr(j << 1+1)\n else\n kc := ( sqr(3*i+1) + 3*sqr(j) ) << 2;\n end;\n end;\nbegin\n readln(r);\n r := 4*r*r;\n\n i := 0;\n j := 0;\n while kc(i,j) <= r do inc(j);\n dec(j);\n\n kq := kq + j << 1 + 1;\n\n repeat\n inc(i);\n j := j + i and 1;\n while (j >= i and 1) and (kc(i,j) > r) do dec(j);\n\n if j < i and 1 then break;\n\n if i and 1 = 1 then\n kq := kq + j << 2\n else\n kq := kq + (j << 1 + 1) << 1;\n until false;\n writeln(kq);\nend."}, {"source_code": "{ uses crt; }\n const nn=5000; eps=0.1;\n\n label 1;\n type mas=array[0..nn] of longint; mass=^mas; real=double;\n var rr,s2,m,l,r,w,i,j,k,k2,t,min,imin:longint;\n u:boolean;\n p0,p,s,n:real;\n x:array[-nn..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n i1,j1:real;\n begin i:=abs(i);j:=abs(j); i1:=i;j1:=j;\n if odd(i) then\n begin dist1:=(i1+1)*(i1+1)*3/4+(3*j1-1)*(3*j1-1);\n dist2:=(i1*i1)*3/4+(3*j1-1/2)*(3*j1-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i1+1)*(i1+1)*3/4+(3*j1+1/2)*(3*j1+1/2);\n dist2:=(i1*i1)*3/4+(3*j1+1)*(3*j1+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\nfunction minj(i:longint):longint;var k,l,a,b,c:longint;\n begin a:=1; b:=trunc(n);\n repeat c:=trunc((a+b)/2); if dist(i,c)<=n*n+eps then a:=c else b:=c until abs(a-b)<=1;\n if dist(i,c)<=n*n then minj:=c else minj:=c-1;\n end;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n t:=trunc(1.3*n); s:=0;\n{ for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); end; }\nfor i:=0 to t do\n begin p:=0;\n if odd(i) and (dist(i,1)<=n*n+eps) then p:=2*minj(i) else p:=0;\n if not odd(i) then\n begin p:=0;\n if dist(i,1)<=n*n+eps then p:=2*minj(i)+1 ;\n if (dist(i,1)>=n*n+eps)and(dist(i,0)<=n*n+eps) then p:=1 ;\n\n\n end;\n s:=s+p; if i=0 then p0:=p;\n end;\n{ for i:=0 to t do writeln(i,' ',x[i]);\n for i:=0 to t do s:=s+x[i]; }\n\n {writeln(s); }\n writeln(2*s-p0:0:0);\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=5000; eps=0.1;\n\n label 1;\n type mas=array[0..nn] of longint; mass=^mas; real=double;\n var rr,s2,m,l,r,w,i,j,k,k2,t,min,imin:longint;\n u:boolean;\n p0,p,s,n:real;\n x:array[-nn..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n i1,j1:real;\n begin i:=abs(i);j:=abs(j); i1:=i;j1:=j;\n if odd(i) then\n begin dist1:=(i1+1)*(i1+1)*3/4+(3*j1-1)*(3*j1-1);\n dist2:=(i1*i1)*3/4+(3*j1-1/2)*(3*j1-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i1+1)*(i1+1)*3/4+(3*j1+1/2)*(3*j1+1/2);\n dist2:=(i1*i1)*3/4+(3*j1+1)*(3*j1+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\nfunction minj(i:longint):longint;var k,l,a,b,c:longint;\n begin a:=1; b:=trunc(n);\n repeat c:=trunc((a+b)/2); if dist(i,c)<=n*n+eps then a:=c else b:=c until abs(a-b)<=1;\n if dist(i,c)<=n*n then minj:=c else minj:=c-1;\n end;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n t:=trunc(1.3*n); s:=0;\n{ for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); end; }\nfor i:=0 to t do\n begin p:=0;\n if odd(i) and (dist(i,1)<=n*n+eps) then p:=2*minj(i) else p:=0;\n if not odd(i) then\n begin p:=0;\n if dist(i,1)<=n*n+eps then p:=2*minj(i)+1 ;\n if (dist(i,1)>=n*n+eps)and(dist(i,0)<=n*n+eps) then p:=1 ;\n\n\n end;\n s:=s+p; if i=0 then p0:=p;\n end;\n{ for i:=0 to t do writeln(i,' ',x[i]);\n for i:=0 to t do s:=s+x[i]; }\n\n {writeln(s); }\n writeln(2*s-p0:0:0);\n\n\n end."}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\n eps = 1e-6;\nvar\n i:longint;\n k,ans,l,r,mid,ans0,mx:int64;\n x,y,x1,y1,x2,y2:extended;\n \n function check(s,n:int64):boolean;\n begin\n check:=false;\n x:=s*1.5;\n y:=n*sqrt(3);\n if s and 1 = 1 then y:=y+sqrt(3)/2;\n x1:=x+0.5;\n y1:=y+sqrt(3)/2;\n x2:=x+1;\n y2:=y;\n if (sqrt(x1*x1+y1*y1) <= k+eps) and (sqrt(x2*x2+y2*y2) <= k+eps) then check:=true;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(k);\n ans:=0;\n ans0:=0;\n mx:=0;\n for i:=0 to round(1e6) do if i*1.5+1 > k then break else\n begin\n if i > mx then mx:=i;\n l:=-1;\n r:=round(1e6);\n while r-l > 1 do\n begin\n mid:=(r+l) div 2;\n if check(i,mid) then l:=mid else r:=mid;\n end;\n if i = 0 then ans0:=2*l;\n inc(ans,l+1);\n end;\n ans:=ans*4-3-ans0-(mx div 2)*2;\n writeln(ans);\nend.\n \n"}, {"source_code": "var\nans:int64;\ni,k,c:longint;\nx,x1,y1,x2,y2:extended;\n begin\n read(k);\n ans:=0;\n c:=2000000;\n for i:=0 to k do\n begin\n x:=3*i+1;\n if x>k then break;\n while true do\n begin\n x1:=x;\n y1:=c*sqrt(3);\n x2:=x-0.5;\n y2:=y1+sqrt(3)/2;\n if x1*x1+y1*y1>int64(k)*k+0.0000001 then c:=c-1 else\n if x2*x2+y2*y2>int64(k)*k+0.0000001 then c:=c-1 else break;\n end;\n ans:=ans+c*2+1;\n if i<>0 then ans:=ans+c*2+1;\n end;\n\n c:=2000000;\n for i:=0 to k do\n begin\n x:=3*i+2;\n if x+0.5>k then break;\n while true do\n begin\n x1:=x;\n y1:=(c+1)*sqrt(3);\n x2:=x+0.5;\n y2:=y1-sqrt(3)/2;\n // if c=0 then writeln(x1,' ',y1,' ',x2,' ',y2);\n if x1*x1+y1*y1>int64(k)*k+0.0000001 then c:=c-1 else\n if x2*x2+y2*y2>int64(k)*k+0.0000001 then c:=c-1 else break;\n end;\n ans:=ans+(c*2+2)*2;\n end;\n writeln(ans);\n end."}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n cd,res,d,x,y,r:int64;\n i:longint;\n function incircle(x,y:int64):boolean;\n begin\n incircle:=x*x+3*y*y<=4*r*r;\n end;\n function ok(x,y:int64):boolean;\n begin\n if (incircle(x+1,y+1))and(incircle(x-1,y+1))and(incircle(x+2,y))and\n (incircle(x-2,y))and(incircle(x+1,y-1))and(incircle(x-1,y-1))\n then ok:=true \n else ok:=false;\n end;\nbegin\n read(r);\n x:=0;y:=0;\n d:=1;\n while (ok(x,y+2))do begin\n inc(y,2);\n inc(d);\n end;\n res:=d+d-1;\n i:=0;\n// writeln(d);\n// writeln(ok(6,2));\n while (ok(x+3,0))do begin\n inc(i);\n inc(x,3);\n inc(y);\n if (i and 1=0)then inc(d);\n// writeln(x,' ',y,' ',d);\n while (not ok(x,y))do begin\n dec(y,2);\n dec(d);\n end;\n cd:=d+d;\n if (i and 1=0)then cd:=cd-1;\n// writeln(d);\n res:=res+cd*2;\n end;\n writeln(res);\nend."}], "negative_code": [{"source_code": " {uses crt; }\n const nn=1000;\n\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:longint;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\nfunction minj(i:longint):longint;var k,l,a,b,c:longint;\n begin a:=1; b:=n;\n repeat c:=trunc((a+b)/2); if dist(i,c)<=n*n then a:=c else b:=c until abs(a-b)<=1;\n if dist(i,c)<=n*n then minj:=c else minj:=c-1;\n end;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input);\n} read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n{ writeln(s); }\n{for i:=-t to t do writeln(i,'min=',minj(i)); }\nfor i:=0 to t do\n begin\n if odd(i) and (dist(i,1)<=n*n) then x[i]:=2*minj(i) else x[i]:=0;\n if not odd(i) then\n begin x[i]:=0;\n if dist(i,1)<=n*n then x[i]:=2*minj(i)+1 ;\n if (dist(i,1)>=n*n)and(dist(i,0)<=n*n) then x[i]:=1 ;\n\n\n end;\n\n end;\n s:=0;\n { for i:=0 to t do writeln(i,' ',x[i]); }\n for i:=-t to t do s:=s+x[i];\n\n {writeln(s); }\n writeln(2*s-x[0]);\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=1000;\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:char;\ndist:array[0..nn] of real;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction gl(a:char):boolean; var flag:boolean;\nbegin flag:=false;\nif (a='a')or (a='e')or (a='i')or(a='o')or(a='u') then flag:=true;\ngl:=flag;\nend;\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n,m,k);\nflag1:=false;\n\nfor i:=1 to trunc(sqrt(m+1)) do\n begin if m mod i=0 then if ((i>=k)and(i=k)and(m div ii then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n writeln(s);\n\n\n begin\n\n\n\n end;\n\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=1000;\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:longint;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n writeln(s);\n\n\n begin\n\n\n\n end;\n\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=1000; eps=0.1;\n\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:longint;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\nfunction minj(i:longint):longint;var k,l,a,b,c:longint;\n begin a:=1; b:=n;\n repeat c:=trunc((a+b)/2); if dist(i,c)<=n*n+eps then a:=c else b:=c until abs(a-b)<=1;\n if dist(i,c)<=n*n then minj:=c else minj:=c-1;\n end;\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n{ writeln(s);}\n{for i:=-t to t do writeln(i,'min=',minj(i)); }\nfor i:=0 to t do\n begin\n if odd(i) and (dist(i,1)<=n*n+eps) then x[i]:=2*minj(i) else x[i]:=0;\n if not odd(i) then\n begin x[i]:=0;\n if dist(i,1)<=n*n+eps then x[i]:=2*minj(i)+1 ;\n if (dist(i,1)>=n*n+eps)and(dist(i,0)<=n*n+eps) then x[i]:=1 ;\n\n\n end;\n\n end;\n s:=0;\n{ for i:=0 to t do writeln(i,' ',x[i]);\n } for i:=-t to t do s:=s+x[i];\n\n {writeln(s); }\n writeln(2*s-x[0]);\n\n\n end."}, {"source_code": "{ uses crt; }\n const nn=1000;\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:longint;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n writeln(s);\n\n\n begin\n\n\n\n end;\n\n\n\n end."}, {"source_code": "var\nans:int64;\ni,k,c:longint;\nx,x1,y1,x2,y2:extended;\n begin\n read(k);\n ans:=0;\n c:=1000000;\n for i:=0 to k do\n begin\n x:=3*i+1;\n if x>k then break;\n while true do\n begin\n x1:=x;\n y1:=c*sqrt(3);\n x2:=x-0.5;\n y2:=y1+sqrt(3)/2;\n if x1*x1+y1*y1>int64(k)*k+0.000000001 then c:=c-1 else\n if x2*x2+y2*y2>int64(k)*k+0.000000001 then c:=c-1 else break;\n end;\n ans:=ans+c*2+1;\n if i<>0 then ans:=ans+c*2+1;\n end;\n\n c:=1000000;\n for i:=0 to k do\n begin\n x:=3*i+2;\n if x+0.5>k then break;\n while true do\n begin\n x1:=x;\n y1:=(c+1)*sqrt(3);\n x2:=x+0.5;\n y2:=y1-sqrt(3)/2;\n // if c=0 then writeln(x1,' ',y1,' ',x2,' ',y2);\n if x1*x1+y1*y1>int64(k)*k+0.000000001 then c:=c-1 else\n if x2*x2+y2*y2>int64(k)*k+0.000000001 then c:=c-1 else break;\n end;\n ans:=ans+(c*2+2)*2;\n end;\n writeln(ans);\n end."}, {"source_code": "Program \tD_D;\nvar\nf : array[0..1000010] of int64;\ni,n : longint;\nbegin\n\treadln(n);\n\tf[1]:=1;f[2]:=1;\n\tfor i := 3 to n do\n\tf[i]:=f[i-1]+6;\n\twriteln(f[n]);\nend.\n"}, {"source_code": "Program \tD_D;\nvar\ni,n : longint;\np,st : Extended;\nbegin\n\treadln(n);\n\tp:= trunc((n/sqrt(3))-0.5);\n p:=p*6;\n\n\n if n<4 then st:=0 else\n st := trunc((n-4)/1.5)+1;\n\n st:=(st+1)*st *3;\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n p:=p*6;\n\n\n st:=0;\n n:=n-2;\n while sqr(st*0.5*sqrt(3))+sqr(st*1.5+2)<=n*n do st :=st+1;\n st:=(st+1)*st *3;\n\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nvar\ni,n : longint;\np,st : int64;\nbegin\n\treadln(n);\n\tp:= trunc((n/sqrt(3))-0.5);\n p:=p*6;\n\n\n if n<4 then st:=0 else\n st := trunc((n-4)/1.5)+1;\n\n st:=(st+1)*st *3;\n writeln(st+p+1);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n p:=p*6;\n\n\n st:=0;\n while sqr(st*0.5*sqrt(3))+sqr(st*1.5+4)<=(n*n) do st :=st+1;\n st:=(st+1)*st *3;\n\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3))+eps);\n p:=p*6;\n\n\n if n<4 then st:=0 else\n st := trunc((n-4)/1.5+eps)+1;\n\n st:=(st+1)*st *3;\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n p:=p*6;\n\n\n st:=0;\n while sqr(st*0.5*sqrt(3))+sqr(st*1.5+2)<=(n*n) do st :=st+1;\n st:=(st+1)*st *3;\n\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n p:=p*6;\n\n\n st:=0;\n n:=n-2;\n while sqr(st*sqrt(3))+sqr(st*1.5+2)<=n*n do st :=st+1;\n st:=(st+1)*st *3;\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-8;\nvar\ni,n : longint;\np,st : Extended;\nbegin\n\treadln(n);\n\tp:= trunc((n/sqrt(3))-0.5+eps);\n p:=p*6;\n\n\n if n<4 then st:=0 else\n st := trunc((n-4)/1.5+eps)+1;\n\n st:=(st+1)*st *3;\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nconst eps=1e-12;\nvar\ni : longint;\np,st,n : Extended;\nbegin\n\treadln(n);\n\tp:= trunc(((n-0.5*sqrt(3))/sqrt(3)));\n p:=p*6;\n\n\n st:=0;\n while sqr((st+1)*0.5*sqrt(3))+sqr(st*1.5+4)<=(n*n) do st :=st+1;\n st:=(st+1)*st *3;\n\n st:=st+p+1;\n if n<>0 then\n writeln(st:0:0) else\n writeln(0);\n\nend.\n"}, {"source_code": "Program \tD_D;\nvar\nf : array[0..1000010] of int64;\ni,n : longint;\np,st : int64;\nbegin\n\treadln(n);\n\tp:= trunc((n/sqrt(3))-0.5);\n p:=p*6;\n if n<4 then st:=0 else\n st := trunc((n-4)/1.5)+1;\n\n st:=(st+1)*st *3;\n writeln(st+p+1);\n\nend.\n"}, {"source_code": "{ uses crt; }\n const nn=1000;\n label 1;\n type mas=array[0..nn] of longint; mass=^mas;\n var rr,s2,m,l,r,w,p,n,i,j,k,k2,t,min,imin:longint; c,y:mas;\n u:boolean; s:longint;\n x,ch:array[0..nn] of longint;\n tt,ot:longint;\nflag1, flag:boolean;\nss:array[0..nn]of char;\nfunction sum(a,b:mas):mass; var c:mas;i,j:integer;\nbegin for i:=1 to nn do c[i]:=0;\nfor i:=nn downto 1 do begin c[i]:=(c[i]+a[i]+b[i]) mod 10; c[i-1]:=(a[i]+b[i]) div 10; end;\nsum:=@c;\n\n end;\n\nfunction max(i,j:real):real;\nbegin max:=i; if j>i then max:=j;end;\n\nfunction dist(i,j:longint):real; var dist1,dist2,p1,r1,p2,r2:real;k,m:longint;fl:boolean;\n begin i:=abs(i);j:=abs(j);\n if odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j-1)*(3*j-1);\n dist2:=(i*i)*3/4+(3*j-1/2)*(3*j-1/2);\n end;\n\n if not odd(i) then\n begin dist1:=(i+1)*(i+1)*3/4+(3*j+1/2)*(3*j+1/2);\n dist2:=(i*i)*3/4+(3*j+1)*(3*j+1);\n end;\n dist:=max(dist1,dist2);\n\n end;\n\n\n\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(n);\n\n{ writeln(dist(2,1):0:4);} t:=trunc(1.3*n); s:=0;\n for i:=-t to t do x[i]:=0;\n for i:=-t to t do for j:=-t to t do if (dist(i,j)<=n*n)and not(odd(i)and(j=0)) then\n begin inc(s); {writeln(i,' ',j,' dist= ',dist(i,j):0:3);}end;\n writeln(s);\n\n\n begin\n\n\n\n end;\n\n\n\n end."}, {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n i:longint;\n k,ans,l,r,mid,ans0,mx:int64;\n x,y,x1,y1,x2,y2:extended;\n \n function check(s,n:int64):boolean;\n begin\n check:=false;\n x:=s*1.5;\n y:=n*sqrt(3);\n if s and 1 = 1 then y:=y+sqrt(3)/2;\n x1:=x+0.5;\n y1:=y+sqrt(3)/2;\n x2:=x+1;\n y2:=y;\n if (sqrt(x1*x1+y1*y1) <= k) and (sqrt(x2*x2+y2*y2) <= k) then check:=true;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(k);\n ans:=0;\n ans0:=0;\n mx:=0;\n for i:=0 to round(1e6) do if i*1.5+1 > k then break else\n begin\n if i > mx then mx:=i;\n l:=-1;\n r:=round(1e6);\n while r-l > 1 do\n begin\n mid:=(r+l) div 2;\n if check(i,mid) then l:=mid else r:=mid;\n end;\n if i = 0 then ans0:=2*l;\n inc(ans,l+1);\n end;\n ans:=ans*4-3-ans0-(mx div 2)*2;\n writeln(ans);\nend.\n \n"}], "src_uid": "6787c7631716ce3dff3f9a5e1c51ff13"} {"source_code": "uses math;\ntype dp = record\n x , y , z , num: longint;\n ok : boolean;\n end;\n\n var f : array[0 .. 110 , 0 .. 110 , 0 .. 110] of dp;\n go : array[0 .. 110 , 'A' .. 'Z'] of longint;\n p : array[0 .. 110] of longint;\n s1 , s2 , virus , ans : string;\n i , j , k , dv , d1 , d2 , ii , jj , cc , mx : longint;\n c : char;\n\n\nprocedure kmp;\n var i , j : longint;\nbegin\n\n p[0] := 0; p[1] := 0;\n for i := 2 to dv do begin\n j := p[i - 1];\n while (j > 0) and (virus[i] <> virus[j + 1]) do j := p[j];\n if virus[i] = virus[j + 1] then inc(j);\n p[i] := j;\n end;\n\nend;\n\n\nBEGIN\n\n readln(s1); readln(s2); readln(virus);\n d1 := length(s1); d2 := length(s2); dv := length(virus);\n kmp;\n fillchar(f , sizeof(f) , 0);\n for i := 0 to dv - 1 do\n for c := 'A' to 'Z' do begin\n if virus[i + 1] = c then go[i][c] := i + 1 else go[i][c] := go[p[i]][c];\n end;\n\n for i := 0 to d1 do\n for j := 0 to d2 do\n for k := 0 to dv - 1 do begin\n\n if (i <> d1) and (j <> d2) and (s1[i + 1] = s2[j + 1]) and\n (f[i + 1][j + 1][go[k , s1[i + 1]]].num < f[i][j][k].num + 1) then begin\n f[i + 1][j + 1][go[k , s1[i + 1]]].num := f[i][j][k].num + 1;\n f[i + 1][j + 1][go[k , s1[i + 1]]].x := i;\n f[i + 1][j + 1][go[k , s1[i + 1]]].y := j;\n f[i + 1][j + 1][go[k , s1[i + 1]]].z := k;\n f[i + 1][j + 1][go[k , s1[i + 1]]].ok := true;\n end;\n\n if (i <> d1) and (f[i + 1][j][k].num < f[i][j][k].num) then begin\n f[i + 1][j][k].num := f[i][j][k].num;\n f[i + 1][j][k].x := i;\n f[i + 1][j][k].y := j;\n f[i + 1][j][k].z := k;\n f[i + 1][j][k].ok := false;\n end;\n\n if (j <> d2) and (f[i][j + 1][k].num < f[i][j][k].num) then begin\n f[i][j + 1][k].num := f[i][j][k].num;\n f[i][j + 1][k].x := i;\n f[i][j + 1][k].y := j;\n f[i][j + 1][k].z := k;\n f[i][j + 1][k].ok := false;\n end;\n\n end;\n\n i := d1; j := d2;\n mx := 0; k := -1;\n for cc := 0 to dv - 1 do\n if mx < f[i][j][cc].num then begin\n mx := f[i][j][cc].num;\n k := cc;\n end;\n\n if mx = 0 then begin writeln(0); halt; end;\n\n ans := '';\n while (i <> 0) and (j <> 0) do begin\n if f[i][j][k].ok then ans := s1[i] + ans;\n ii := i; jj := j; cc := k;\n i := f[ii][jj][cc].x;\n j := f[ii][jj][cc].y;\n k := f[ii][jj][cc].z;\n end;\n\n writeln(ans);\n\nEND.", "positive_code": [{"source_code": "var s1,s2,virus : string;\n d,d2 : array[1..210,0..210] of string;\n var i,j,k,i1,j1 : longint;\n p : array[0..210] of longint;\n s,best : string;\nbegin\n readln(s1);\n readln(s2);\n readln(virus);\n //s1 := 'BABB';\n //s2 := 'BABB';\n //virus := 'AB';\n \n for i := 1 to 110 do\n for j := 0 to 110 do begin\n d[i][j] := '';\n d2[i][j] := '';\n end;\n \n \n \n best := '';\n for i := 1 to length(s1) do begin\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n d2[j][k] := '';\n end;\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n if s1[i] = s2[j] then begin\n //writeln(i,' ',j);\n s := virus+'#'+d[j][k]+s1[i];\n j1 := 0;\n for i1 := 0 to length(s) do p[i1] := 0;\n \n for i1 := 1 to length(s)-1 do begin\n while (j1 > 0) and (s[i1+1] <> s[j1+1]) do j1 := p[j1-1];\n if s[i1+1] = s[j1+1] then inc(j1);\n p[i1] := j1;\n end;\n \n //j1 := 0;\n //writeln(j1);\n \n \n \n if (length(d[j][k])+1 > length(d2[j+1][j1])) and (j1 < length(virus)) then begin\n \n d2[j+1][j1] := d[j][k]+s1[i];\n //writeln('yes ',j+1,' ',j1);\n // writeln(i,' ',j,' ',s,' ',d2[j+1][j1],' ',j1,' ',length(d2[j+1][j1]));\n if (length(best) < length(d2[j+1][j1])) then best := d2[j+1][j1];\n end;\n \n end; begin\n if (length(d[j][k]) > length(d2[j][k])) then d2[j][k] := d[j][k];\n if (length(d[j][k]) > length(d[j+1][k])) then d[j+1][k] := d[j][k];\n end;\n \n end;\n \n d := d2;\n \n {writeln('i: ',i);\n for i1 := 1 to length(s2) do begin\n for j1 := 0 to length(virus)-1 do\n if length(d[i1][j1]) > 0 then\n //write(d[i1][j1],' ') else write('- ');\n writeln;\n end;\n \n writeln;}\n \n end;\n \n if length(best) > 0 then\n writeln(best) else writeln(0);\n \nend.\n"}, {"source_code": "var f,l:array[0..100,0..100,0..100] of longint;\n m:array[0..100,'A'..'Z'] of longint;\n p:array[1..100] of longint;\n i,j,k,t,l1,l2,lv,max:longint;\n a,b,v,ans:string;\n ch:char;\n\nprocedure print(x,y,z:longint);\n\n begin\n if (x=0) or (y=0) then exit;\n if l[x,y,z]<=0 then begin ans:=a[x]+ans; print(x-1,y-1,-l[x,y,z]); end;\n if l[x,y,z]=1 then print(x-1,y,z);\n if l[x,y,z]=2 then print(x,y-1,z);\n end;\n\nbegin\n readln(a);\n l1:=length(a);\n readln(b);\n l2:=length(b);\n readln(v);\n lv:=length(v);\n p[1]:=0;\n j:=0;\n for i:=2 to lv do\n begin\n while (j>0) and (v[j+1]<>v[i]) do\n j:=p[j];\n if v[j+1]=v[i] then inc(j);\n p[i]:=j;\n end;\n fillchar(m,sizeof(m),0);\n for i:=0 to lv-1 do\n for ch:='A' to 'Z' do\n if v[i+1]=ch then m[i,ch]:=i+1 else m[i,ch]:=m[p[i],ch];\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv do\n if (k=0) and (i*j=0) then f[i,j,k]:=0 else f[i,j,k]:=-1;\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv-1 do\n begin\n if (i<>l1) and (j<>l2) then\n if a[i+1]=b[j+1] then\n if f[i,j,k]+1>f[i+1,j+1,m[k,a[i+1]]] then\n begin\n f[i+1,j+1,m[k,a[i+1]]]:=f[i,j,k]+1;\n l[i+1,j+1,m[k,a[i+1]]]:=-k;\n end;\n if i<>l1 then\n if f[i,j,k]>f[i+1,j,k] then\n begin\n f[i+1,j,k]:=f[i,j,k];\n l[i+1,j,k]:=1;\n end;\n if j<>l2 then\n if f[i,j,k]>f[i,j+1,k] then\n begin\n f[i,j+1,k]:=f[i,j,k];\n l[i,j+1,k]:=2;\n end;\n end;\n max:=f[l1,l2,0];\n t:=0;\n for i:=1 to lv-1 do\n if f[l1,l2,i]>max then begin max:=f[l1,l2,i]; t:=i; end;\n ans:='';\n if max=0 then\n writeln(0)\n else\n begin\n print(l1,l2,t);\n writeln(ans);\n end;\nend."}, {"source_code": "program probb;\ntype\n\tdp=record\n\t\tx,y,z,num:longint;\n\t\tok:boolean;\n\tend;\nvar\n\tf:array[0..100,0..100,0..100] of dp;\n\ta:array[0..100,'A'..'Z'] of longint;\n\tmax,d1,d2,dv,i,j,k,x,y,z:longint;\n\tp:array[0..100] of longint;\n\tans,s1,s2,v:string;\n\tc:char;\n\nprocedure kmp();\n\tvar\n\t\tk,i:longint;\n\tbegin\n\t\tk:=0;\n\t\tfor i:=2 to dv do begin\n\t\t\twhile (k>0)and(v[k+1]<>v[i]) do k:=p[k];\n\t\t\tif (v[k+1]=v[i]) then inc(k);\n\t\t\tp[i]:=k;\n\t\tend;\n\tend;\nbegin\n\treadln(s1); readln(s2);\n\treadln(v);\n\td1:=length(s1); d2:=length(s2);\n\tdv:=length(v);\n\tkmp();\n\tfor i:=0 to dv-1 do\n\t\tfor c:='A' to 'Z' do\n\t\t\tif (v[i+1]=c) then a[i,c]:=i+1 else a[i,c]:=a[p[i],c];\n\tfor i:=0 to d1 do\n\t\tfor j:=0 to d2 do\n\t\t\tfor k:=0 to dv-1 do begin\n\t\t\t\tif (i*j=0)and(k>0) then continue;\n\t\t\t\tif (i<>d1)and(j<>d2)and(s1[i+1]=s2[j+1])and(f[i+1,j+1,a[k,s1[i+1]]].numd1)and(f[i+1,j,k].numd2)and(f[i,j+1,k].num0)and(j>0) do begin\n\t\t\tif (f[i,j,k].ok=true) then ans:=s1[i]+ans;\n\t\t\tx:=f[i,j,k].x; y:=f[i,j,k].y; z:=f[i,j,k].z;\n\t\t\ti:=x; j:=y; k:=z;\n\t\tend;\n\t\twriteln(ans);\n\tend;\nend.\n"}, {"source_code": "{$coperators on}\n{$mode objfpc}\nuses math;\nconst\n fi='INPUT.INP';\n fo='OUTPUT.OUT';\n maxn=105;\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\ntype data=record\n x,y,z:longint;\n end;\n arr=array[0..maxn*2] of longint;\nvar a,b,c,s:string;\n f:array[0..maxn,0..maxn,0..maxn] of longint;\n trace:array[0..maxn,0..maxn,0..maxn] of data;\n next:array[0..maxn,'A'..'Z'] of longint;\n Z:arr;\nprocedure enter;\nbegin\n readln(a);\n readln(b);\n readln(c);\nend; {\nprocedure maximize(var target:longint; value:longint);\nbegin\n if value>target then target:=value;\nend; }\nfunction make(i,j,k:longint):data;\nbegin\n result.x:=i; result.y:=j; result.z:=k;\nend;\nprocedure maximize(i,j,k,x,y,z,val:longint);\nbegin\n if f[i][j][k]r then begin\n r:=i+z[i]-1;\n l:=i;\n end;\n end;\nend;\nprocedure init;\nvar tmp:string;\n n,i,len,j:longint;\n ch:char;\nbegin\n tmp:=c+'##';\n n:=length(c);\n for i:=0 to n do begin\n len:=length(tmp);\n if i<>0 then begin\n tmp[len]:=c[i];\n tmp+='#';\n inc(len);\n end;\n for ch:='A' to 'Z' do begin\n tmp[len]:=ch;\n Zfunc(tmp,Z);\n //next[i][ch]\n for j:=n+2 to len do\n if z[j]=len-j+1 then begin\n next[i][ch]:=z[j];\n break;\n end;\n end;\n end;\nend;\nprocedure solve;\nvar i,j,k,res,len,m,n,z:longint;\n tmp:data;\nbegin\n init;\n n:=length(a); m:=length(b); z:=length(c);\n fillchar(f,sizeof(f),255);\n f[0][0][0]:=0;\n for i:=0 to n-1 do\n for j:=0 to m-1 do\n for k:=0 to z-1 do\n if f[i][j][k]<>-1 then begin\n maximize(i+1,j,k,i,j,k,0);//maximize(f[i+1][j][k],f[i][j][k]);\n maximize(i,j+1,k,i,j,k,0);//maximize(f[i][j+1][k],f[i][j][k]);\n if a[i+1]=b[j+1] then\n maximize(i+1,j+1,next[k][a[i+1]],i,j,k,1)//maximize(f[i+1][j+1][next[k][a[i+1]],f[i][j][k]+1)\n end;\n res:=0;\n for i:=1 to n do\n for j:=1 to m do\n for k:=0 to z-1 do\n res:=max(res,f[i][j][k]);\n if res=0 then writeln(0)\n else begin\n for i:=1 to n do\n for j:=1 to m do\n for k:=0 to z-1 do\n if res=f[i][j][k] then\n tmp:=make(i,j,k);\n i:=tmp.x; j:=tmp.y; k:=tmp.z;\n len:=res;\n while len>0 do begin\n tmp:=trace[i][j][k];\n with tmp do begin\n if f[i][j][k]=f[x][y][z]+1 then begin\n s+=a[i];\n dec(len);\n end;\n i:=x; j:=y; k:=z;\n end;\n end;\n for len:=res downto 1 do\n write(s[len]);\n exit;\n end;\nend;\nbegin\n //fileio;\n enter;\n solve;\nend."}, {"source_code": "type tt=record\n x,y,z:longint;\nend;\nVar i,j,u,k,n,m,x,y,z:longint;\n pref:array[0..123]of longint;\n s1,s2,virus:string;\n q:char;\n next:array[0..123,char]of longint;\n f:array[0..103,0..103,0..103]of longint;\n p:array[0..103,0..103,0..103]of tt;\n procedure go(x,y,z,val:longint);\n begin\n if f[x,y,z]0)and(virus[i]<>virus[j+1]) do\n j:=pref[j];\n if virus[j+1]=virus[i] then pref[i]:=j+1\n else pref[i]:=0;\n end;\n for i:=1 to k-1 do\n for q:='A' to 'Z' do\n begin\n j:=i;\n while (j>0)and(virus[j+1]<>q) do\n j:=pref[j];\n if virus[j+1]=q then next[i,q]:=j+1\n else next[i,q]:=0;\n end;\n for i:=0 to n+1 do\n for j:=0 to m+1 do\n for u:=0 to k+1 do\n f[i,j,u]:=-1;\n f[0,0,0]:=0;\n for i:=0 to n do\n for j:=0 to m do\n for u:=0 to k-1 do\n if f[i,j,u]<>-1 then\n begin\n go(i+1,j,u,f[i,j,u]);\n go(i,j+1,u,f[i,j,u]);\n if (if[x,y,z] then\n begin\n x:=i;\n y:=j;\n z:=u;\n end;\n if x=0 then Write(0)\n else rec(x,y,z);\n Writeln;\n end."}, {"source_code": "type pp=record\n x,y:longint;\n end;\n\nvar q:char;\n j,g:longint;\n s1,s2,w,ww,lw:string;\n i,l,m,n,t,x,y,lx,ly,len:longint;\n p:array[0..111,0..111,0..111] of pp;\n a,b,d:array[0..111,'A'..'Z'] of longint;\n c:array[0..111,0..111,0..111] of longint;\n\nprocedure tt(len,x,y:longint);\n begin\n if (x=0) and (y=0) then exit;\n tt(len-1,p[len,x,y].x,p[len,x,y].y);\n write(s1[x]);\n end;\n\n\n begin\n readln(s1);\n readln(s2);\n n:=length(s1);\n m:=length(s2);\n if n0 then a[i,s1[i]]:=i;\n end;\n\n for i:=m downto 0 do\n begin\n for q:='A' to 'Z' do\n b[i,q]:=b[i+1,q];\n if i>0 then b[i,s2[i]]:=i;\n end;\n\n lw:='';\n readln(w);\n t:=length(w);\n for i:=1 to t do\n begin\n for q:='A' to 'Z' do\n begin\n ww:=lw+q;\n\n for j:=1 to i do\n begin\n if copy(ww,i-j+1,j)=copy(w,1,j) then d[i-1,q]:=j;\n end;\n\n end;\n\n lw:=lw+w[i];\n end;\n\n for i:=0 to l do\n for x:=0 to n do\n for y:=0 to m do\n c[i,x,y]:=-1;\n\n c[0,0,0]:=0;\n for i:=0 to l do\n begin\n\n for x:=0 to n do\n for y:=0 to m do\n begin\n\n if (c[i,x,y]=-1) then continue;\n\n for q:='A' to 'Z' do\n begin\n lx:=a[x+1,q];\n ly:=b[y+1,q];\n if (lx<=n) and\n (ly<=m) then begin\n g:=d[c[i,x,y],q];\n if (g>=t) then continue;\n\n if (c[i+1,lx,ly]=-1) or\n (c[i+1,lx,ly]>g) then begin\n c[i+1,lx,ly]:=g;\n p[i+1,lx,ly].x:=x;\n p[i+1,lx,ly].y:=y;\n end;\n end;\n end;\n\n end;\n\n end;\n\n len:=0;\n for i:=l downto 0 do\n begin\n for x:=n downto 1 do\n begin\n for y:=m downto 1 do\n if (c[i,x,y]<>-1) then begin\n lx:=x;ly:=y;\n len:=i;\n break;\n end;\n if (len>0) then break;\n end;\n if (len>0) then break;\n end;\n\n if (len=0) then writeln(len)\n else begin\n tt(len,lx,ly);writeln;\n end;\n end.\n"}, {"source_code": "uses math;\ntype dp = record\n x , y , z , num: longint;\n ok : boolean;\n end;\n\n var f : array[0 .. 110 , 0 .. 110 , 0 .. 110] of dp;\n go : array[0 .. 110 , 'A' .. 'Z'] of longint;\n p : array[0 .. 110] of longint;\n s1 , s2 , virus , ans : string;\n i , j , k , dv , d1 , d2 , ii , jj , cc , mx : longint;\n c : char;\n\n\nprocedure kmp;\n var i , j : longint;\nbegin\n\n p[0] := 0; p[1] := 0;\n for i := 2 to dv do begin\n j := p[i - 1];\n while (j > 0) and (virus[i] <> virus[j + 1]) do j := p[j];\n if virus[i] = virus[j + 1] then inc(j);\n p[i] := j;\n end;\n\nend;\n\n\nBEGIN\n\n readln(s1); readln(s2); readln(virus);\n d1 := length(s1); d2 := length(s2); dv := length(virus);\n kmp;\n fillchar(f , sizeof(f) , 0);\n for i := 0 to dv - 1 do\n for c := 'A' to 'Z' do begin\n if virus[i + 1] = c then go[i][c] := i + 1 else go[i][c] := go[p[i]][c];\n end;\n\n for i := 0 to d1 do\n for j := 0 to d2 do\n for k := 0 to dv - 1 do begin\n\n if (i <> d1) and (j <> d2) and (s1[i + 1] = s2[j + 1]) and\n (f[i + 1][j + 1][go[k , s1[i + 1]]].num < f[i][j][k].num + 1) then begin\n f[i + 1][j + 1][go[k , s1[i + 1]]].num := f[i][j][k].num + 1;\n f[i + 1][j + 1][go[k , s1[i + 1]]].x := i;\n f[i + 1][j + 1][go[k , s1[i + 1]]].y := j;\n f[i + 1][j + 1][go[k , s1[i + 1]]].z := k;\n f[i + 1][j + 1][go[k , s1[i + 1]]].ok := true;\n end;\n\n if (i <> d1) and (f[i + 1][j][k].num < f[i][j][k].num) then begin\n f[i + 1][j][k].num := f[i][j][k].num;\n f[i + 1][j][k].x := i;\n f[i + 1][j][k].y := j;\n f[i + 1][j][k].z := k;\n f[i + 1][j][k].ok := false;\n end;\n\n if (j <> d2) and (f[i][j + 1][k].num < f[i][j][k].num) then begin\n f[i][j + 1][k].num := f[i][j][k].num;\n f[i][j + 1][k].x := i;\n f[i][j + 1][k].y := j;\n f[i][j + 1][k].z := k;\n f[i][j + 1][k].ok := false;\n end;\n\n end;\n\n i := d1; j := d2;\n mx := 0; k := -1;\n for cc := 0 to dv - 1 do\n if mx < f[i][j][cc].num then begin\n mx := f[i][j][cc].num;\n k := cc;\n end;\n\n if mx = 0 then begin writeln(0); halt; end;\n\n ans := '';\n while (i <> 0) and (j <> 0) do begin\n if f[i][j][k].ok then ans := s1[i] + ans;\n ii := i; jj := j; cc := k;\n i := f[ii][jj][cc].x;\n j := f[ii][jj][cc].y;\n k := f[ii][jj][cc].z;\n end;\n\n writeln(ans);\n\nEND."}, {"source_code": "const\n l=100;\ntype\n dp=record\n x,y,z,num:longint;\n used:boolean;\n end;\nvar\n f:array[0..l,0..l,0..l] of dp;\n go:array[0..l,'A'..'Z'] of longint;\n max,d1,d2,dv,i,j,k,x,y,z:longint;\n p:array[0..l] of longint;\n ans,s1,s2,v:string;\n c:char;\n\nprocedure kmp;\nvar\n k,i:longint;\nbegin\n k:=0;\n for i:=2 to dv do\n begin\n while (k>0) and (v[k+1]<>v[i]) do k:=p[k];\n if (v[k+1]=v[i]) then inc(k);\n p[i]:=k;\n end;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n readln(v);\n d1:=length(s1);\n d2:=length(s2);\n dv:=length(v);\n kmp;\n for i:=0 to dv-1 do for c:='A' to 'Z' do\n begin\n case i of\n 0: if (v[i+1]=c) then go[i,c]:=1 else go[i,c]:=0;\n else if (v[i+1]=c) then go[i,c]:=i+1 else go[i,c]:=go[p[i],c];\n end;\n end;\n for i:=0 to d1 do for j:=0 to d2 do for k:=0 to dv-1 do\n begin\n if (i*j=0) and (k>0) then continue;\n if (i<>d1) and (j<>d2) and (s1[i+1]=s2[j+1]) and (f[i+1,j+1,go[k,s1[i+1]]].numd1) and (f[i+1,j,k].numd2) and (f[i,j+1,k].num0) and (j>0) do\n begin\n if (f[i,j,k].used) then ans:=s1[i]+ans;\n x:=f[i,j,k].x;\n y:=f[i,j,k].y;\n z:=f[i,j,k].z;\n i:=x;\n j:=y;\n k:=z;\n end;\n writeln(ans);\n end;\nend."}, {"source_code": "const\n l=100;\ntype\n dp=record\n x,y,z,num:longint;\n used:boolean;\n end;\nvar\n f:array[0..l,0..l,0..l] of dp;\n go:array[0..l,'A'..'Z'] of longint;\n max,d1,d2,dv,i,j,k,x,y,z:longint;\n p:array[0..l] of longint;\n ans,s1,s2,v:string;\n c:char;\n\nprocedure kmp;\nvar\n k,i:longint;\nbegin\n k:=0;\n for i:=2 to dv do\n begin\n while (k>0) and (v[k+1]<>v[i]) do k:=p[k];\n if (v[k+1]=v[i]) then inc(k);\n p[i]:=k;\n end;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n readln(v);\n d1:=length(s1);\n d2:=length(s2);\n dv:=length(v);\n kmp;\n for i:=0 to dv-1 do for c:='A' to 'Z' do if (v[i+1]=c) then go[i,c]:=i+1 else go[i,c]:=go[p[i],c];\n for i:=0 to d1 do for j:=0 to d2 do for k:=0 to dv-1 do\n begin\n if (i*j=0) and (k>0) then continue;\n if (i<>d1) and (j<>d2) and (s1[i+1]=s2[j+1]) and (f[i+1,j+1,go[k,s1[i+1]]].numd1) and (f[i+1,j,k].numd2) and (f[i,j+1,k].num0) and (j>0) do\n begin\n if (f[i,j,k].used) then ans:=s1[i]+ans;\n x:=f[i,j,k].x;\n y:=f[i,j,k].y;\n z:=f[i,j,k].z;\n i:=x;\n j:=y;\n k:=z;\n end;\n writeln(ans);\n end;\nend."}, {"source_code": "const\n inf=10000;\nvar\n i,j,l1,l2,lv,k,t,ans:longint;\n s,s1,s2,virus:string;\n kmp:array[0..110] of longint;\n pre,dp:array[0..101,0..101,0..101] of longint;\n\nbegin {main}\n readln(s1);\n readln(s2);\n readln(virus);\n l1:=length(s1);l2:=length(s2);lv:=length(virus);\n kmp[1]:=0;k:=0;\n for i:=2 to lv do\n begin\n while (k<>0) and (virus[k+1]<>virus[i]) do k:=kmp[k];\n if virus[k+1]=virus[i] then inc(k);\n kmp[i]:=k;\n end;\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv do\n dp[i,j,k]:=-inf;\n dp[0,0,0]:=0;\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv-1 do\n begin\n if idp[i+1,j,k] then begin dp[i+1,j,k]:=dp[i,j,k];pre[i+1,j,k]:=1;end;\n if jdp[i,j+1,k] then begin dp[i,j+1,k]:=dp[i,j,k];pre[i,j+1,k]:=2;end;\n if (i0) and (virus[t+1]<>s1[i+1]) do t:=kmp[t];\n if virus[t+1]=s1[i+1] then inc(t);\n if dp[i+1,j+1,t]ans then begin ans:=dp[l1,l2,i];k:=i;end;\n if ans=0 then\n writeln(0)\n else\n begin\n i:=l1;j:=l2;s:='';\n while (i<>0) and (j<>0) do\n begin\n case pre[i,j,k] of\n 1:dec(i);\n 2:dec(j);\n else\n begin\n k:=pre[i,j,k]-3;\n s:=s1[i]+s;\n dec(i);dec(j);\n end;\n end;\n end;\n writeln(s);\n end;\nend.\n"}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\n inf = round(1e9);\n maxn = round(1e5) + 200;\n md = round(1e9) + 7;\ntype\n state = record\n i, j, k : longint;\n end; \nvar\n s1, s2, virus, res : string;\n n, m, v, i, j, k, ans : longint;\n ch : char;\n f : array [0..111, 'A'..'Z'] of longint;\n p : array [1..111] of longint;\n dp : array [0..111, 0..111, 0..111] of longint;\n pred : array [0..111, 0..111, 0..111] of state;\n cur, now : state;\nbegin\n // reset (input, 'input.txt');\n // rewrite (output, 'output.txt');\n randomize;\n readln(s1); n := length(s1);\n readln(s2); m := length(s2);\n readln(virus); v := length(virus);\n p[1] := 0;\n k := 0;\n for i := 2 to v do\n begin\n while (k > 0) and (virus[i] <> virus[k + 1]) do k := p[k];\n if virus[i] = virus[k + 1] then inc(k);\n p[i] := k;\n end;\n for ch := 'A' to 'Z' do\n if ch <> virus[1] then f[0][ch] := 0\n else f[0][ch] := 1;\n for i := 1 to v - 1 do\n for ch := 'A' to 'Z' do\n if virus[i + 1] = ch then f[i][ch] := i + 1\n else f[i][ch] := f[p[i]][ch];\n\n fillchar(dp, sizeof(dp), -1);\n fillchar(pred, sizeof(pred), 0);\n dp[0][0][0] := 0;\n for i := 0 to n do\n for j := 0 to m do\n for k := 0 to v - 1 do\n if dp[i][j][k] <> -1 then\n begin\n if (i < n) and (j < m) and (s1[i + 1] = s2[j + 1]) then\n if dp[i + 1][j + 1][f[k][s1[i + 1]]] < dp[i][j][k] + 1 then\n begin\n dp[i + 1][j + 1][f[k][s1[i + 1]]] := dp[i][j][k] + 1;\n pred[i + 1][j + 1][f[k][s1[i + 1]]].i := i;\n pred[i + 1][j + 1][f[k][s1[i + 1]]].j := j;\n pred[i + 1][j + 1][f[k][s1[i + 1]]].k := k;\n end;\n if (i < n) then\n if dp[i + 1][j][k] < dp[i][j][k] then\n begin\n dp[i + 1][j][k] := dp[i][j][k];\n pred[i + 1][j][k].i := i;\n pred[i + 1][j][k].j := j;\n pred[i + 1][j][k].k := k;\n end;\n if (j < m) then\n if dp[i][j + 1][k] < dp[i][j][k] then\n begin\n dp[i][j + 1][k] := dp[i][j][k];\n pred[i][j + 1][k].i := i;\n pred[i][j + 1][k].j := j;\n pred[i][j + 1][k].k := k;\n end;\n end;\n\n fillchar(cur, sizeof(cur), -1);\n ans := 0;\n for k := 0 to v - 1 do\n if ans < dp[n][m][k] then\n begin\n ans := dp[n][m][k];\n cur.i := n;\n cur.j := m;\n cur.k := k;\n end;\n\n if ans = 0 then\n begin\n writeln(0);\n halt;\n end;\n\n res := '';\n v := ans;\n while v > 0 do\n begin\n now := pred[cur.i][cur.j][cur.k];\n if (now.i + 1 = cur.i) and (now.j + 1 = cur.j) then\n begin\n res := res + s1[cur.i];\n dec(v);\n end;\n cur := now;\n end;\n\n for i := ans downto 1 do write(res[i]);\nend.\n"}, {"source_code": "//type AnsiString = string;\nvar dp: array[0..100, 0..100, 0..100] of AnsiString;\n s1, s2, virus: AnsiString;\n n, m, l, i, j, k, temp: longint;\n p: array[0..501] of longint;\n ans: AnsiString;\n\n\nfunction GetEntry(a, b: AnsiString): longint;\nvar i, t: longint;\nbegin\n a:= b + '#' + a;\n p[1]:= 0;\n for i:= 2 to length(a) do\n begin\n t:= p[i-1];\n while (t > 0) and (a[i] <> a[t + 1]) do\n t:= p[t];\n\n if a[i] = a[t + 1] then\n inc(t);\n p[i]:= t;\n end;\n GetEntry:= p[length(a)];\nend;\n\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n readln(s1);\n readln(s2);\n readln(virus);\n n:= length(s1);\n m:= length(s2);\n l:= length(virus);\n for i:= 1 to n do\n for j:= 1 to m do\n for k:= 0 to l-1 do\n begin\n if s1[i] = s2[j] then\n begin\n temp:= GetEntry(dp[i-1][j-1][k] + s1[i], virus);\n if (temp < l) and\n (length(dp[i][j][temp]) < length(dp[i-1][j-1][k]) + 1) then\n dp[i][j][temp]:= dp[i-1][j-1][k] + s1[i];\n end;\n\n if length(dp[i-1][j][k]) > length(dp[i][j][k]) then\n dp[i][j][k]:= dp[i-1][j][k];\n if length(dp[i][j-1][k]) > length(dp[i][j][k]) then\n dp[i][j][k]:= dp[i][j-1][k];\n end;\n\n ans:= dp[n][m][0];\n for k:= 1 to l-1 do\n if length(ans) < length(dp[n][m][k]) then\n ans:= dp[i][j][k];\n\n if length(ans) = 0 then\n write(0)\n else\n write(ans);\nend."}, {"source_code": "program mfs;\ntype data=record\n\ti,j,k,f:longint;\n\tend;\nvar\ns1,s2,vir:string[115];\nlen1,len2,len,i,j,k,ans,ansi,ansj,ansk,kk:longint;\nnext:array[0..115]of longint;\ndp,up:array[0..110,0..110,0..110]of longint;\ng:array[0..102,0..102,0..102]of data;\nprocedure getnext;\nvar i,j:longint;\nbegin\nj:=0;\nfor i:=2 to len do\n\tbegin\n\twhile (vir[i]<>vir[j+1])and(j>0) do j:=next[j];\n\tif vir[i]=vir[j+1] then j:=j+1;\n\tnext[i]:=j;\n\tend;\nend;\nprocedure printf(i,j,k:longint);\nvar ii,jj,kk:longint;\nbegin\nif g[i][j][k].i=0 then begin if g[i][j][k].f=1 then write(s1[i]); exit; end;\nii:=g[i][j][k].i;jj:=g[i][j][k].j;kk:=g[i][j][k].k;\n//writeln(ii,' ',jj,' ',kk);\nprintf(ii,jj,kk);\nif g[i][j][k].f=1 then write(s1[i]);\nend;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(vir);\nlen1:=length(s1);len2:=length(s2);\nlen:=length(vir);\nfillchar(dp,sizeof(dp),$ff);\nfor i:=0 to len1 do\n\tfor j:=0 to len2 do dp[i][j][0]:=0;\ngetnext;\nfillchar(up,sizeof(up),0);\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\tbegin\n\tif s1[i]<>s2[j] then\n\t\tfor k:=0 to len do\n\t\tif dp[i-1][j][k]>dp[i][j-1][k] then\n\t\t\tbegin\n\t\t\tdp[i][j][k]:=dp[i-1][j][k];\n\t\t\tup[i][j][k]:=up[i-1][j][k];\n\t\t\tg[i][j][k].i:=i-1;g[i][j][k].j:=j;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\t//writeln(dp[i][j][k],' ',i,' ',j,' ',k,' ',dp[i-1][j][k],' ',dp[i][j-1][k],' ',g[i][j][k].i,' ',g[i][j][k].j,' ',g[i][j][k].k);\n\t\t\tend\n\t\telse begin\n\t\t\tdp[i][j][k]:=dp[i][j-1][k];\n\t\t\tup[i][j][k]:=up[i][j-1][k];\n\t\t\tg[i][j][k].i:=i;g[i][j][k].j:=j-1;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\tend;\n\tif s1[i]=s2[j] then \n\t\tbegin\n\t\tfor k:=0 to len-1 do\n\t\t\tbegin\n\t\t\tdp[i][j][k]:=dp[i-1][j-1][k];\n\t\t\tg[i][j][k].i:=i-1;g[i][j][k].j:=j-1;g[i][j][k].k:=k;\n\t\t\tend;\n\t\t//writeln(i,' ',j,' ',s1[i],' ',s2[j]);\n\t\tfor k:=0 to len-1 do\n\t\t\tbegin\n\t\t\tkk:=k;\n\t\t\twhile (vir[kk+1]<>s1[i])and(kk>0) do kk:=next[kk];\n\t\t\tif vir[kk+1]=s1[i] then inc(kk);\n\t\t\tif (dp[i-1][j-1][k]>=0)and(dp[i][j][kk]',i,' ',j,' ',k,' ',kk,' ',dp[i][j][kk],' ',up[i][j][k]);\n\t\t\tend;\n\t\tend;\n\tend;\nans:=0;\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\t\tfor k:=0 to len-1 do\n\t\tbegin\n\t\t//writeln(i,' ',j,' ',k,' ',dp[i][j][k],' ',ans);\n\t\tif dp[i][j][k]>ans then\n\t\tbegin\n\t\tans:=dp[i][j][k];\n\t\tansi:=i;\n\t\tansj:=j;\n\t\tansk:=k;\n\t\tend;\n\t\tend;\nif ans=0 then begin writeln(0); halt; end;\n//writeln('###',ans,' ',dp[ansi][ansj][ansk],' ',ansi,' ',ansj,' ',ansk);\nprintf(ansi,ansj,ansk);\nend.\n{\nABBBDASSDASDASDDAASDASDADASDASASDAS\nSDADASDASSDAASDASDASDADASSDDA\nSD\n}"}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = '346BDIV1.INP';\n fo = '346BDIV1.OUT';\n maxn = 101;\nvar\n f, tracex, tracey, tracez : array[0..maxn,0..maxn,0..maxn] of Integer;\n ok : array[0..maxn,0..maxn,0..maxn] of Boolean;\n d : array[0..maxn,'A'..'Z'] of Integer;\n a, b, virus, sub : String;\n n, m, res: Integer;\n t : array[0..maxn] of Integer;\n\nprocedure enter;\nbegin\n //assign(input,fi); reset(input);\n readln(a); readln(b); readln(virus);\nend;\n\nprocedure init;\nvar\n i, j : Integer;\n ch : Char;\nbegin\n fillchar(ok,sizeof(ok),false);\n j := 0;\n for i := 2 to length(virus) do\n begin\n while (virus[i] <> virus[j+1]) and (j > 0) do j := t[j];\n if (virus[i] = virus[j+1]) then inc(j);\n t[i] := j;\n end;\n for ch := 'A' to 'Z' do\n for i := 0 to length(virus) - 1 do\n begin\n j := i;\n while (virus[j+1] <> ch) and (j > 0) do j := t[j];\n if virus[j+1] = ch then inc(j);\n d[i,ch] := j;\n end;\nend;\n\nprocedure solve;\nvar\n i, j, k, x0, y0, z0, z, p : Integer;\nbegin\n n := length(a); m := length(b);\n fillchar(f,sizeof(f),255);\n for i := 0 to n do\n for j := 0 to m do\n f[i,j,0] := 0;\n for i := 1 to n do\n for j := 1 to m do\n for k := 0 to length(virus) - 1 do\n begin\n if (a[i] = b[j]) and (f[i-1,j-1,k] <> -1) then z := d[k, a[i]] else z := -1;\n f[i,j,k] := max(f[i,j,k], max(f[i-1,j,k], f[i,j-1,k]));\n if f[i,j,k] = f[i,j-1,k] then\n begin\n tracex[i,j,k] := i; tracey[i,j,k] := j-1; tracez[i,j,k] := k;\n ok[i,j,k] := false;\n end\n else\n if f[i,j,k] = f[i-1,j,k] then\n begin\n tracex[i,j,k] := i-1; tracey[i,j,k] := j; tracez[i,j,k] := k;\n ok[i,j,k] := false;\n end;\n if (z <> -1) and (z < length(virus)) then\n begin\n f[i,j,z] := max(f[i,j,z], f[i-1,j-1,k] + 1);\n if f[i,j,z] = f[i-1,j-1,k] + 1 then\n begin\n tracex[i,j,z]:= i-1; tracey[i,j,z] := j-1; tracez[i,j,z] := k;\n ok[i,j,z] := true;\n end;\n end;\n end;\n\n for i := 0 to length(virus) - 1 do\n begin\n res := max(res, f[n,m,i]);\n if res = f[n,m,i] then\n begin\n k := i;\n end;\n end;\n\n if res = 0 then\n begin\n writeln(0);\n halt;\n end;\n while (n > 0) and (m > 0) do\n begin\n if ok[n,m,k] then sub := a[n] + sub;\n x0 := tracex[n,m,k]; y0 := tracey[n,m,k]; z0 := tracez[n,m,k];\n n := x0; m := y0; k := z0;\n end;\n writeln(sub);\nend;\n\nbegin\n enter;\n init;\n solve;\nend.\n"}, {"source_code": "var\np:array[0..1000] of longint;\nx,y,d,f:array[0..1000,0..1000] of longint;\nqqq,n1,m1,cc,t,n,m,i,j:longint;\ntemp2,temp,max,ans,a,b,c:ansistring;\n{procedure dfs(x,y:longint);\nbegin\nif f[x,y]=0 then exit;\nif f[x,y]=f[x-1,y-1]+1 then begin ans:=ans+b[x];\ndfs(x-1,y-1);\nend ELSE\nif f[x,y]=f[x-1,y] then dfs(x-1,y) else dfs(x,y-1);\nend; }\nbegin\nreadln(a);\ntemp2:=a;\nreadln(b);\nreadln(c);\nmax:='';\nfor qqq:=1 to length(a) do begin\na:=temp2;\ndelete(a,qqq,1);\nfillchar(f,sizeof(f),0);\nfillchar(d,sizeof(d),0);\nj:=0;\np[1]:=0;\nn:=length(a);\nm:=length(b);\ncc:=length(c);\nfor i:=2 to cc do\nbegin\nwhile (j>0) and (c[j+1]<>c[i]) do j:=p[j];\nif c[j+1]=c[i] then inc(j);\np[i]:=j;\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nbegin\nif (d[i-1,j]<=d[i,j-1]) and (f[i-1,j]=f[i,j-1]) or (f[i-1,j]>f[i,j-1]) then begin\nf[i,j]:=f[i-1,j];\nd[i,j]:=d[i-1,j];\nx[i,j]:=i-1;\ny[i,j]:=j;\nend\nelse\nbegin\nf[i,j]:=f[i,j-1];\nd[i,j]:=d[i,j-1];\nx[i,j]:=i;\ny[i,j]:=j-1;\nend;\nt:=d[i-1,j-1];\nif a[i]=b[j] then begin\nwhile (t>0) and (c[t+1]<>a[i]) do t:=p[t];\nif c[t+1]=a[i] then inc(t);\nif t<>cc then\nif (f[i-1,j-1]+1=f[i,j]) and (t<=d[i,j]) or (f[i-1,j-1]+1>f[i,j]) then begin\nf[i,j]:=f[i-1,j-1]+1;\nd[i,j]:=t;\nx[i,j]:=i-1;\ny[i,j]:=j-1;\nend;\nend;\nend;\nif f[n,m]<>0 then begin\nans:='';\nwhile (n<>0) and (m<>0) do begin\nif x[n,m]+y[n,m]-n-m+2=0 then ans:=a[n]+ans;\nn1:=n;\nm1:=m;\nn:=x[n1,m1];\nm:=y[n1,m1];\nend;\nif length(max)0) and (c[j+1]<>c[i]) do j:=p[j];\nif c[j+1]=c[i] then inc(j);\np[i]:=j;\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nbegin\nif (d[i-1,j]<=d[i,j-1]) and (f[i-1,j]=f[i,j-1]) or (f[i-1,j]>f[i,j-1]) then begin\nf[i,j]:=f[i-1,j];\nd[i,j]:=d[i-1,j];\nx[i,j]:=i-1;\ny[i,j]:=j;\nend\nelse\nbegin\nf[i,j]:=f[i,j-1];\nd[i,j]:=d[i,j-1];\nx[i,j]:=i;\ny[i,j]:=j-1;\nend;\nt:=d[i-1,j-1];\nif a[i]=b[j] then begin\nwhile (t>0) and (c[t+1]<>a[i]) do t:=p[t];\nif c[t+1]=a[i] then inc(t);\nif t<>cc then\nif (f[i-1,j-1]+1=f[i,j]) and (t<=d[i,j]) or (f[i-1,j-1]+1>f[i,j]) then begin\nf[i,j]:=f[i-1,j-1]+1;\nd[i,j]:=t;\nx[i,j]:=i-1;\ny[i,j]:=j-1;\nend;\nend;\nend;\nif f[n,m]<>0 then begin\nans:='';\nwhile (n<>0) and (m<>0) do begin\nif x[n,m]+y[n,m]-n-m+2=0 then ans:=a[n]+ans;\nn1:=n;\nm1:=m;\nn:=x[n1,m1];\nm:=y[n1,m1];\nend;\nif length(max)'' then writeln(max) else writeln(0);\nend.\n"}, {"source_code": "{$coperators on}\n{$R-,Q-}\n\nuses math;\n\ntype int = longint;\n ll = int64;\n bool = boolean;\n\nconst fi = '';\n fo = '';\n nmax = 110;\n base = 73471;\n\nvar a , b : string;\n virtus : string;\n f : array[0..nmax,0..nmax,0..nmax] of int;\n g : array[0..nmax,'A'..'Z'] of int;\n mul , h : array[0..nmax] of qword;\n n , m , l : int;\n\nprocedure enter;\n begin\n readln(a);\n readln(b);\n readln(virtus);\n n := length(a);\n m := length(b);\n l := length(virtus);\n end;\n\nprocedure init;\n var\n i , j : int;\n c : char;\n begin\n mul[0] := 1;\n for i := 1 to n do\n begin\n h[i] := h[i-1]*base+ord(virtus[i])-ord('A');\n mul[i] := mul[i-1]*base;\n end;\n\n for i := 0 to n do\n begin\n for c := 'A' to 'Z' do\n begin\n if c = virtus[i+1] then\n begin\n g[i,c] := i+1;\n continue;\n end;\n for j := i downto 1 do\n if h[j] = (h[i]-h[i-j+1]*mul[j-1])*base+ord(c)-ord('A') then\n begin\n g[i,c] := j;\n break;\n end;\n end;\n end;\n end;\n\nfunction cal(i , j , k : int) : int;\n begin\n if (i > n) or (j > m) then exit(0);\n\n if f[i,j,k] <> -1 then exit(f[i,j,k]);\n\n f[i,j,k] := max(cal(i+1,j,k) , cal(i,j+1,k));\n if (a[i] = b[j]) and (g[k,a[i]] <> l) then f[i,j,k] := max(f[i,j,k] , cal(i+1,j+1,g[k,a[i]])+1 );\n\n exit(f[i,j,k]);\n end;\n\nprocedure trace(i , j , k : int);\n begin\n if (i > n) or (j > m) then exit;\n\n if (cal(i,j,k) = cal(i+1,j,k)) then\n begin\n trace(i+1,j,k); exit;\n end;\n if (cal(i,j,k) = cal(i,j+1,k)) then\n begin\n trace(i,j+1,k); exit;\n end;\n if cal(i,j,k) = cal(i+1,j+1,g[k,a[i]])+1 then\n begin\n write(a[i]);\n trace(i+1,j+1,g[k,a[i]]);\n end;\n end;\n\nprocedure solve;\n var\n i : int;\n tmp : int;\n pos : int;\n begin\n fillchar(f, sizeof(f) , 255);\n\n tmp := 0;\n for i := 0 to l do\n if tmp < cal(1,1,i) then\n begin\n tmp := cal(1,1,i);\n pos := i;\n end;\n if tmp = 0 then\n begin\n writeln(0);\n exit;\n end;\n\n trace(1,1,pos);\n end;\n\n\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\n\n enter;\n init;\n solve;\n\n close(input);\n close(output);\nend.\n"}, {"source_code": "const inf=10000;\nvar kmp:array[0..110]of longint;\n pre,dp:array[0..101,0..101,0..101]of longint;\n i,j,l1,l2,lv,k,t,ans:longint;\n s,s1,s2,virus:string;\n\nbegin\n readln(s1);l1:=length(s1);\n readln(s2);l2:=length(s2);\n readln(virus);lv:=length(virus);\n kmp[1]:=0;k:=0;\n for i:=2 to lv do\n begin\n while(k<>0)and(virus[k+1]<>virus[i])do k:=kmp[k];\n if(virus[k+1]=virus[i])then inc(k);\n kmp[i]:=k;\n end;\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv do\n dp[i,j,k]:=-inf;\n dp[0,0,0]:=0;\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv-1 do\n begin\n if(idp[i+1,j,k])then\n begin\n dp[i+1,j,k]:=dp[i,j,k];\n pre[i+1,j,k]:=1;\n end;\n if jdp[i,j+1,k])then\n begin\n dp[i,j+1,k]:=dp[i,j,k];\n pre[i,j+1,k]:=2;\n end;\n if(i0)and(virus[t+1]<>s1[i+1])do t:=kmp[t];\n if virus[t+1]=s1[i+1] then inc(t);\n if dp[i+1,j+1,t]ans)then begin ans:=dp[l1,l2,i];k:=i;end;\n if ans=0 then\n writeln(0)\n else\n begin\n i:=l1;j:=l2;s:='';\n while(i<>0)and(j<>0)do\n begin\n case pre[i,j,k] of\n 1:dec(i);\n 2:dec(j);\n else\n begin\n k:=pre[i,j,k]-3;\n s:=s1[i]+s;\n dec(i);dec(j);\n end;\n end;\n end;\n writeln(s);\n end;\nend."}, {"source_code": "{$mode objfpc}\nuses math;\nvar\n i,j,k,na,nb,np,t: integer;\n r: integer;\n ch: char;\n a,b,p,rs: string;\n f,tr: array[0..101,0..101,0..101] of integer;\n g: array[0..101,'A'..'Z'] of integer;\n c: array[0..101] of integer;\n\nprocedure kmp;\nvar\n q,t,i: integer;\nbegin\n for ch:='A' to 'Z' do if ch=p[1] then g[0,ch]:=1 else g[0,ch]:=0;\n q:=0;\n np:=length(p);\n c[1]:=0;\n for i:=2 to np do\n begin\n for ch:='A' to 'Z' do\n begin\n if ch=p[i] then g[i-1,ch]:=i\n else\n begin\n t:=q;\n while (t>0) and (p[t+1]<>ch) do t:=c[t];\n if p[t+1]=ch then inc(t);\n g[i-1,ch]:=t;\n end;\n end;\n\n while (q>0) and (p[q+1]<>p[i]) do q:=c[q];\n if p[q+1]=p[i] then inc(q);\n c[i]:=q;\n end;\n\nend;\nbegin\n// assign(input,'te.in'); reset(input);\n readln(a);\n readln(b);\n readln(p);\n kmp;\n na:=length(a);\n nb:=length(b);\n a:=a+'@';\n b:=b+'%';\n fillchar(f,sizeof(f),0);\n fillchar(tr,sizeof(tr),0);\n for i:=0 to na do\n for j:=0 to nb do\n for k:=0 to np-1 do\n begin\n if f[i,j,k]>f[i,j+1,k] then\n begin\n f[i,j+1,k]:=f[i,j,k];\n tr[i,j+1,k]:=1;\n end;\n if f[i,j,k]>f[i+1,j,k] then\n begin\n f[i+1,j,k]:=f[i,j,k];\n tr[i+1,j,k]:=2;\n end;\n if (a[i+1]=b[j+1]) and (f[i,j,k]+1>f[i+1,j+1,g[k,a[i+1]]]) then\n begin\n f[i+1,j+1,g[k,a[i+1]]]:=f[i,j,k]+1;\n tr[i+1,j+1,g[k,a[i+1]]]:=-k-1;\n end;\n end;\n r:=0;\n for k:=0 to np-1 do if f[na,nb,k]>f[na,nb,r] then r:=k;\n if F[na,nb,r]=0 then\n begin\n writeln(f[na,nb,r]);\n halt;\n end;\n i:=na;\n j:=nb;\n k:=r;\n rs:='';\n repeat\n t:=tr[i,j,k];\n if t=0 then break;\n case t of\n 1: dec(j);\n 2: dec(i);\n else\n begin\n rs:=rs+a[i];\n dec(i);\n dec(j);\n k:=-t-1;\n end;\n end;\n until false;\n for i:=length(rs) downto 1 do write(rs[i]);\n\nend.\n"}, {"source_code": "type tt=record\n x,y,z:longint;\nend;\nVar i,j,u,k,n,m,x,y,z:longint;\n pref:array[0..123]of longint;\n s1,s2,virus:string;\n q:char;\n next:array[0..123,char]of longint;\n f:array[0..103,0..103,0..103]of longint;\n p:array[0..103,0..103,0..103]of tt;\n procedure go(x,y,z,val:longint);\n begin\n if f[x,y,z]0)and(virus[i]<>virus[j+1]) do\n j:=pref[j];\n if virus[j+1]=virus[i] then pref[i]:=j+1\n else pref[i]:=0;\n end;\n for i:=1 to k-1 do\n for q:='A' to 'Z' do\n begin\n j:=i;\n while (j>0)and(virus[j+1]<>q) do\n j:=pref[j];\n if virus[j+1]=q then next[i,q]:=j+1\n else next[i,q]:=0;\n end;\n for i:=0 to n+1 do\n for j:=0 to m+1 do\n for u:=0 to k+1 do\n f[i,j,u]:=-1;\n f[0,0,0]:=0;\n for i:=0 to n do\n for j:=0 to m do\n for u:=0 to k-1 do\n if f[i,j,u]<>-1 then\n begin\n go(i+1,j,u,f[i,j,u]);\n go(i,j+1,u,f[i,j,u]);\n if (if[x,y,z] then\n begin\n x:=i;\n y:=j;\n z:=u;\n end;\n if x=0 then Write(0)\n else rec(x,y,z);\n Writeln;\n end."}], "negative_code": [{"source_code": "var dp: array[0..100, 0..100, 0..100] of AnsiString;\n s1, s2, virus: AnsiString;\n n, m, l, i, j, k, temp: longint;\n p: array[0..501] of longint;\n ans: AnsiString;\n\n\nfunction GetEntry(a, b: AnsiString): longint;\nvar i, t: longint;\nbegin\n a:= a + '#' + b;\n p[1]:= 0;\n for i:= 2 to length(a) do\n begin\n t:= p[i-1];\n while (t > 0) and (a[i] <> a[t + 1]) do\n t:= p[t];\n\n if a[i] = a[t + 1] then\n p[i]:= t + 1;\n end;\n GetEntry:= p[length(a)];\nend;\n\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n readln(s1);\n readln(s2);\n readln(virus);\n n:= length(s1);\n m:= length(s2);\n l:= length(virus);\n for i:= 1 to n do\n for j:= 1 to m do\n for k:= 0 to l-1 do\n begin\n if s1[i] = s2[j] then\n begin\n temp:= GetEntry(dp[i-1][j-1][k] + s1[i], virus);\n if (temp < l) and\n (length(dp[i][j][temp]) < length(dp[i-1][j-1][k]) + 1) then\n dp[i][j][temp]:= dp[i-1][j-1][k] + s1[i];\n end;\n\n if length(dp[i-1][j][k]) > length(dp[i][j][k]) then\n dp[i][j][k]:= dp[i-1][j][k];\n if length(dp[i][j-1][k]) > length(dp[i][j][k]) then\n dp[i][j][k]:= dp[i][j-1][k];\n end;\n\n ans:= dp[n][m][0];\n for k:= 1 to l-1 do\n if length(ans) < length(dp[n][m][k]) then\n ans:= dp[i][j][k];\n\n if length(ans) = 0 then\n write(0)\n else\n write(ans);\nend."}, {"source_code": "var dp: array[0..100, 0..100, 0..100] of string;\n s1, s2, virus: string;\n n, m, l, i, j, k, temp: longint;\n p: array[0..200] of longint;\n ans: string;\n\n\nfunction GetEntry(a, b: string): longint;\nvar i, t: longint;\nbegin\n a:= b + '#' + a;\n p[1]:= 0;\n for i:= 2 to length(a) do\n begin\n t:= p[i-1];\n while (t > 0) and (a[i] <> a[t + 1]) do\n t:= p[t];\n\n if a[i] = a[t + 1] then\n p[i]:= t + 1;\n end;\n GetEntry:= p[length(a)];\nend;\n\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n readln(s1);\n readln(s2);\n readln(virus);\n n:= length(s1);\n m:= length(s2);\n l:= length(virus);\n\n for i:= 1 to n do\n for j:= 1 to m do\n for k:= 0 to l do\n begin\n if s1[i] = s2[j] then\n begin\n temp:= GetEntry(dp[i-1][j-1][k] + s1[i], virus);\n if (temp < l) and\n (length(dp[i][j][temp]) < length(dp[i-1][j-1][k]) + 1) then\n dp[i][j][temp]:= dp[i-1][j-1][k] + s1[i];\n end\n else\n begin\n if length(dp[i-1][j][k]) > length(dp[i][j-1][k]) then\n dp[i][j][k]:= dp[i-1][j][k]\n else\n dp[i][j][k]:= dp[i][j-1][k];\n end;\n end;\n\n ans:= dp[n][m][0];\n for i:= 1 to l-1 do\n if length(ans) < length(dp[n][m][i]) then\n ans:= dp[n][m][i];\n\n if length(ans) = 0 then\n write(0)\n else\n write(ans);\nend."}, {"source_code": "uses math;\n var s1 , s2 , v , ans : string;\n i , j , n , m , lim , pp : longint;\n dp , pre : array[0 .. 101 , 0 .. 101] of longint;\n st : array[0 .. 101 , 0 .. 101] of string;\n\n\nfunction pi(s : string) : longint;\n var p : array[0 .. 220] of longint;\n ss : string;\n i , j , d : longint;\nbegin\n\n ss := v + '$' + s;\n p[0] := 0; p[1] := 0; d := length(ss);\n i := 2;\n while i <= d do begin\n j := p[i - 1];\n while (j > 0) and (ss[i] <> ss[j + 1]) do j := p[j];\n p[i] := j;\n if ss[i] = ss[j + 1] then inc(p[i]);\n inc(i);\n end;\n\n exit(p[d]);\n\nend;\n\n\nBEGIN\n\n fillchar(dp , sizeof(dp) , 0);\n fillchar(pre , sizeof(pre) , 0);\n for i := 0 to 101 do for j := 0 to 101 do st[i][j] := '';\n\n readln(s1); readln(s2); readln(v);\n n := length(s1); m := length(s2); lim := length(v);\n for i := 1 to n do begin\n for j := 1 to m do begin\n if (dp[i - 1][j] > dp[i][j - 1]) or\n ((dp[i - 1][j] = dp[i][j - 1])and(pre[i - 1][j] < pre[i][j - 1])) then begin\n dp[i][j] := dp[i - 1][j];\n pre[i][j] := pre[i - 1][j];\n st[i][j] := st[i - 1][j];\n end\n else begin\n dp[i][j] := dp[i][j - 1];\n pre[i][j] := pre[i][j - 1];\n st[i][j] := st[i][j - 1];\n end;\n\n\n if s1[i] = s2[j] then begin\n if dp[i - 1][j - 1] + 1 < dp[i][j] then continue;\n\n pp := pre[i - 1][j - 1];\n if s1[i] = v[pp + 1] then inc(pp)\n else pp := pi(st[i - 1][j - 1] + s1[i]);\n\n if (pp < lim) then begin\n if (dp[i][j] < dp[i - 1][j - 1] + 1) or\n ((dp[i][j] = dp[i - 1][j - 1])and(pp < pre[i - 1][j - 1])) then begin\n dp[i][j] := dp[i - 1][j - 1] + 1;\n pre[i][j] := pp;\n st[i][j] := st[i - 1][j - 1] + s1[i];\n end;\n end;\n\n end;\n end;\n end;\n\n if length(st[n][m]) = 0 then writeln(0)\n else write(st[n][m]);\n\nEND.\n"}, {"source_code": "uses math;\n var d , p , pri , prj : array[0 .. 110 , 0..110] of longint;\n s1 , s2 , v : string;\n n , m , i , j : longint;\n\n\nprocedure solve;\n var i , j , dn , pn : longint;\nbegin\n for i := 1 to n do begin\n for j := 1 to m do begin\n\n dn := d[i - 1 , j - 1]; pn := p[i - 1 , j - 1];\n if (s1[i] = s2[j]) then begin\n if (s1[i] = v[pn + 1]) then begin\n if pn + 1 < length(v) - 1 then begin inc(dn); inc(pn); end;\n end\n else begin\n inc(dn);\n if s1[i] = v[1] then pn := 1\n else pn := 0;\n end;\n end;\n\n d[i , j] := d[i - 1 , j]; p[i , j] := p[i - 1 , j];\n pri[i , j] := i - 1; prj[i , j] := j;\n\n if (d[i , j - 1] > d[i , j]) or\n ((d[i , j - 1] = d[i , j]) and (p[i , j - 1] < p[i , j])) then begin\n d[i , j] := d[i , j - 1]; p[i , j] := p[i , j - 1];\n pri[i , j] := i; prj[i , j] := j - 1;\n end;\n\n if (dn > d[i , j]) or ((dn = d[i , j]) and (pn < p[i , j])) then begin\n d[i , j] := dn; p[i , j] := pn;\n pri[i , j] := i - 1; prj[i , j] := j - 1;\n end;\n\n end;\n end;\nend;\n\n\n\nprocedure outdata;\n var i , j , cc : longint;\n ans : string;\nbegin\n if d[n , m] = 0 then begin writeln(0); halt; end;\n ans := '';\n i := n; j := m;\n while (i <> 0) and (j <> 0) do begin\n if (pri[i , j] <> i) and (prj[i , j] <> j) then ans := ans + s1[i];\n cc := i; i := pri[cc , j]; j := prj[cc , j];\n end;\n for i := length(ans) downto 1 do write(ans[i]);\nend;\n\nBEGIN\n\n readln(s1); readln(s2); readln(v); v := v + '$';\n n := length(s1); m := length(s2);\n fillchar(d , sizeof(d) , 0);\n fillchar(p , sizeof(p) , 0);\n fillchar(pri , sizeof(pri) , 0);\n fillchar(prj , sizeof(prj) , 0);\n\n solve;\n outdata;\n\n\nEND."}, {"source_code": "uses math;\n var s1 , s2 , v , ans , ss : string;\n i , j , n , m , lim , pp : longint;\n dp , pre : array[0 .. 101 , 0 .. 101] of longint;\n st : array[0 .. 101 , 0 .. 101] of string;\n\n\nfunction pi(s : string) : longint;\n var p : array[0 .. 220] of longint;\n ss : string;\n i , j , d : longint;\nbegin\n\n ss := v + '$' + s;\n p[0] := 0; p[1] := 0; d := length(ss);\n i := 2;\n while i <= d do begin\n j := p[i - 1];\n while (j > 0) and (ss[i] <> ss[j + 1]) do j := p[j];\n p[i] := j;\n if ss[i] = ss[j + 1] then inc(p[i]);\n inc(i);\n end;\n\n exit(p[d]);\n\nend;\n\n\nBEGIN\n\n fillchar(dp , sizeof(dp) , 0);\n fillchar(pre , sizeof(pre) , 0);\n for i := 0 to 101 do for j := 0 to 101 do st[i][j] := '';\n\n readln(s1); readln(s2); readln(v);\n n := length(s1); m := length(s2); lim := length(v);\n for i := 1 to n do begin\n for j := 1 to m do begin\n if (dp[i - 1][j] > dp[i][j - 1]) or\n ((dp[i - 1][j] = dp[i][j - 1])and(pre[i - 1][j] < pre[i][j - 1])) then begin\n dp[i][j] := dp[i - 1][j];\n pre[i][j] := pre[i - 1][j];\n st[i][j] := st[i - 1][j];\n end\n else begin\n dp[i][j] := dp[i][j - 1];\n pre[i][j] := pre[i][j - 1];\n st[i][j] := st[i][j - 1];\n end;\n\n\n if s1[i] = s2[j] then begin\n if dp[i - 1][j - 1] + 1 < dp[i][j] then continue;\n\n pp := pre[i - 1][j - 1];\n if s1[i] = v[pp + 1] then inc(pp)\n else pp := pi(st[i - 1][j - 1] + s1[i]);\n\n if (pp < lim) then begin\n if (dp[i][j] < dp[i - 1][j - 1] + 1) or\n ((dp[i][j] = dp[i - 1][j - 1])and(pp < pre[i - 1][j - 1])) then begin\n dp[i][j] := dp[i - 1][j - 1] + 1;\n pre[i][j] := pp;\n st[i][j] := st[i - 1][j - 1] + s1[i];\n end;\n end;\n\n if (pp = lim) then begin\n ss := st[i - 1][j - 1] + s1[i];\n if (length(ss) - pp = 0) or (ss[length(ss) - pp] <> v[1]) then begin\n dp[i][j] := dp[i - 1][j - 1];\n delete(ss , length(ss) - pp + 1 , 1);\n st[i][j] := ss;\n pre[i][j] := pi(ss);\n end;\n end;\n\n end;\n end;\n end;\n\n if length(st[n][m]) = 0 then writeln(0)\n else write(st[n][m]);\n\nEND.\n"}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = '346BDIV1.INP';\n fo = '346BDIV1.OUT';\n maxn = 101;\nvar\n f, tracex, tracey, tracez : array[0..maxn,0..maxn,0..maxn] of Integer;\n ok : array[0..maxn,0..maxn,0..maxn] of Boolean;\n d : array[0..maxn,'A'..'Z'] of Integer;\n a, b, virus, sub : String;\n n, m, res: Integer;\n t : array[0..maxn] of Integer;\n\nprocedure enter;\nbegin\n //assign(input,fi); reset(input);\n readln(a); readln(b); readln(virus);\nend;\n\nprocedure init;\nvar\n i, j : Integer;\n ch : Char;\nbegin\n fillchar(ok,sizeof(ok),false);\n j := 0;\n for i := 2 to length(virus) do\n begin\n while (virus[i] <> virus[j+1]) and (j > 0) do j := t[j];\n if (virus[i] = virus[j+1]) then inc(j);\n t[i] := j;\n end;\n for ch := 'A' to 'Z' do\n for i := 0 to length(virus) - 1 do\n begin\n j := i;\n while (virus[j+1] <> ch) and (j > 0) do j := t[j];\n if virus[j+1] = ch then inc(j);\n d[i,ch] := j;\n end;\nend;\n\nprocedure solve;\nvar\n i, j, k, x0, y0, z0, z, p : Integer;\nbegin\n n := length(a); m := length(b);\n fillchar(f,sizeof(f),255);\n for i := 0 to n do\n for j := 0 to m do\n f[i,j,0] := 0;\n for i := 1 to n do\n for j := 1 to n do\n for k := 0 to length(virus) - 1 do\n begin\n if (i = 8) and (j = 1) and (k = 0) then\n p := 1;\n if (a[i] = b[j]) and (f[i-1,j-1,k] <> -1) then z := d[k, a[i]] else z := -1;\n f[i,j,k] := max(f[i,j,k], max(f[i-1,j,k], f[i,j-1,k]));\n if f[i,j,k] = f[i,j-1,k] then\n begin\n tracex[i,j,k] := i; tracey[i,j,k] := j-1; tracez[i,j,k] := k;\n ok[i,j,k] := false;\n end\n else\n if f[i,j,k] = f[i-1,j,k] then\n begin\n tracex[i,j,k] := i-1; tracey[i,j,k] := j; tracez[i,j,k] := k;\n ok[i,j,k] := false;\n end;\n if (z <> -1) and (z < length(virus)) then\n begin\n f[i,j,z] := max(f[i,j,z], f[i-1,j-1,k] + 1);\n if f[i,j,z] = f[i-1,j-1,k] + 1 then\n begin\n tracex[i,j,z]:= i-1; tracey[i,j,z] := j-1; tracez[i,j,z] := k;\n ok[i,j,z] := true;\n end;\n end;\n end;\n\n for i := 0 to length(virus) - 1 do\n begin\n res := max(res, f[n,m,i]);\n if res = f[n,m,i] then\n begin\n k := i;\n end;\n end;\n\n if res = 0 then\n begin\n writeln(0);\n halt;\n end;\n while (n > 0) and (m > 0) do\n begin\n if ok[n,m,k] then sub := a[n] + sub;\n x0 := tracex[n,m,k]; y0 := tracey[n,m,k]; z0 := tracez[n,m,k];\n n := x0; m := y0; k := z0;\n end;\n writeln(sub);\nend;\n\nbegin\n enter;\n init;\n solve;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = '346B.INP';\n fo = '346B.OUT';\n maxn = 101;\n\nvar\n f, tracex, tracey, tracez : array[0..maxn,0..maxn,0..maxn] of Integer;\n s1, s2, virus : String;\n d : array[-2..maxn,'A'..'Z'] of Integer;\n m, n, res : Integer;\n t : array[0..maxn] of Integer;\n kq : String;\n\nprocedure enter;\nbegin\n //assign(input,fi); reset(input);\n readln(s1); readln(s2); readln(virus);\nend;\n\nprocedure init;\nvar\n i, j : Integer;\n ch : char;\nbegin\n fillchar(f,sizeof(f),255);\n t[0] := 0;\n j := 0;\n for i := 2 to length(virus) do\n begin\n while (j > 0) and (virus[j+1] <> virus[i]) do j := t[j];\n if virus[j+1] = virus[i] then inc(j);\n t[i] := j;\n end;\n for i := 0 to length(virus) - 1 do\n for ch := 'A' to 'Z' do\n begin\n j := i;\n while (ch <> virus[j+1]) and (j > 0) do j := t[j];\n if ch = virus[j+1] then inc(j);\n d[i,ch] := j;\n end;\nend;\n\nprocedure solve;\nvar\n i, j, k, x, y, z, x0, y0, z0 : Integer;\nbegin\n n := length(s1);\n m := length(s2);\n for i := 1 to n do\n for j := 1 to m do\n for k := 0 to length(virus) - 1 do\n begin\n if f[i-1,j,k] < f[i,j-1,k] then\n begin\n tracex[i,j,k] := i; tracey[i,j,k] := j-1; tracez[i,j,k] := k;\n f[i,j,k] := f[i,j-1,k];\n end else\n begin\n tracex[i,j,k] := i-1; tracey[i,j,k] := j; tracez[i,j,k] := k;\n f[i,j,k] := f[i-1,j,k];\n end;\n if (s1[i] = s2[j]) and (f[i,j,k] < f[i-1,j-1,d[k-1,s1[i]]] + 1) then\n begin\n f[i,j,k] := max(f[i,j,k], f[i-1,j-1,d[k-1,s1[i]]] + 1);\n tracex[i,j,k] := i-1; tracey[i,j,k] := j - 1;\n tracez[i,j,k] := d[k-1,s1[i]] + 1;\n end;\n end;\n res := 0;\n for i := 0 to length(virus) - 1 do\n if res < f[n,m,i] then\n begin\n res := f[n,m,i];\n x := n; y := m; z:= i;\n end;\n if res = 0 then writeln(0) else\n while (x > 0) and (y > 0) do\n begin\n if (s1[x] = s2[y]) and (f[x,y,z] = f[x-1,y-1,d[z-1,s1[x]]] + 1) then\n kq := s1[x] + kq;\n x0 := tracex[x,y,z]; y0 := tracey[x,y,z]; z0 := tracez[x,y,z];\n x := x0; y := y0; z := z0;\n end;\n if res <> 0 then writeln(kq);\nend;\n\nbegin\n enter;\n init;\n solve;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = '346B.INP';\n fo = '346B.OUT';\n maxn = 101;\n\nvar\n f, tracex, tracey, tracez : array[0..maxn,0..maxn,0..maxn] of Integer;\n s1, s2, virus : String;\n d : array[-2..maxn,'A'..'Z'] of Integer;\n m, n, res : Integer;\n t : array[0..maxn] of Integer;\n kq : String;\n\nprocedure enter;\nbegin\n //assign(input,fi); reset(input);\n readln(s1); readln(s2); readln(virus);\nend;\n\nprocedure init;\nvar\n i, j : Integer;\n ch : char;\nbegin\n fillchar(f,sizeof(f),255);\n t[0] := 0;\n j := 0;\n for i := 2 to length(virus) do\n begin\n while (j > 0) and (virus[j+1] <> virus[i]) do j := t[j];\n if virus[j+1] = virus[i] then inc(j);\n t[i] := j;\n end;\n for i := -1 to length(virus) - 2 do\n for ch := 'A' to 'Z' do\n begin\n j := i + 1;\n while (ch <> virus[j+1]) and (j > 0) do j := t[j];\n if ch = virus[j+1] then inc(j);\n d[i,ch] := j;\n end;\nend;\n\nprocedure solve;\nvar\n i, j, k, x, y, z, x0, y0, z0 : Integer;\nbegin\n n := length(s1);\n m := length(s2);\n f[0,0,0] := 0;\n for i := 1 to n do\n for j := 1 to m do\n for k := 0 to length(virus) - 1 do\n begin\n if f[i-1,j,k] < f[i,j-1,k] then\n begin\n tracex[i,j,k] := i; tracey[i,j,k] := j-1; tracez[i,j,k] := k;\n f[i,j,k] := f[i,j-1,k];\n end else\n begin\n tracex[i,j,k] := i-1; tracey[i,j,k] := j; tracez[i,j,k] := k;\n f[i,j,k] := f[i-1,j,k];\n end;\n if (s1[i] = s2[j]) and (d[k-1,s1[i]] = k) and (f[i,j,k] < f[i-1,j-1,d[k-1,s1[i]]] + 1) then\n begin\n f[i,j,k] := max(f[i,j,k], f[i-1,j-1,d[k-1,s1[i]]] + 1);\n tracex[i,j,k] := i-1; tracey[i,j,k] := j - 1;\n tracez[i,j,k] := d[k-1,s1[i]];\n end;\n end;\n res := 0;\n for i := 0 to length(virus) - 1 do\n if res < f[n,m,i] then\n begin\n res := f[n,m,i];\n x := n; y := m; z:= i;\n end;\n if res = 0 then writeln(0) else\n while (x > 0) and (y > 0) do\n begin\n if (s1[x] = s2[y]) and (d[z-1,s1[x]] = z) and (f[x,y,z] = f[x-1,y-1,d[z-1,s1[x]]] + 1) then\n begin\n kq := s1[x] + kq;\n x0 := x - 1; y0 := y - 1; z0 := d[z-1,s1[x]];\n x:= x0; y := y0; z := z0;\n end else\n begin\n x0 := tracex[x,y,z]; y0 := tracey[x,y,z]; z0 := tracez[x,y,z];\n x := x0; y := y0; z := z0;\n end;\n end;\n if res <> 0 then writeln(kq);\nend;\n\nbegin\n enter;\n init;\n solve;\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = '346B.INP';\n fo = '346B.OUT';\n maxn = 101;\n\nvar\n f, tracex, tracey, tracez : array[0..maxn,0..maxn,0..maxn] of Integer;\n s1, s2, virus : String;\n d : array[-2..maxn,'A'..'Z'] of Integer;\n m, n, res : Integer;\n t : array[0..maxn] of Integer;\n kq : String;\n\nprocedure enter;\nbegin\n //assign(input,fi); reset(input);\n readln(s1); readln(s2); readln(virus);\nend;\n\nprocedure init;\nvar\n i, j : Integer;\n ch : char;\nbegin\n fillchar(f,sizeof(f),255);\n t[0] := 0;\n j := 0;\n for i := 2 to length(virus) do\n begin\n while (j > 0) and (virus[j+1] <> virus[i]) do j := t[j];\n if virus[j+1] = virus[i] then inc(j);\n t[i] := j;\n end;\n for i := 0 to length(virus) - 1 do\n for ch := 'A' to 'Z' do\n begin\n j := i;\n while (ch <> virus[j+1]) and (j > 0) do j := t[j];\n if ch = virus[j+1] then inc(j);\n d[i,ch] := j;\n end;\nend;\n\nprocedure solve;\nvar\n i, j, k, x, y, z, x0, y0, z0 : Integer;\nbegin\n n := length(s1);\n m := length(s2);\n for i := 1 to n do\n for j := 1 to m do\n for k := 0 to length(virus) - 1 do\n begin\n if f[i-1,j,k] < f[i,j-1,k] then\n begin\n tracex[i,j,k] := i; tracey[i,j,k] := j-1; tracez[i,j,k] := k;\n f[i,j,k] := f[i,j-1,k];\n end else\n begin\n tracex[i,j,k] := i-1; tracey[i,j,k] := j; tracez[i,j,k] := k;\n f[i,j,k] := f[i-1,j,k];\n end;\n if (s1[i] = s2[j]) and (f[i,j,k] < f[i-1,j-1,d[k-1,s1[i]]] + 1) then\n begin\n f[i,j,k] := max(f[i,j,k], f[i-1,j-1,d[k-1,s1[i]]] + 1);\n tracex[i,j,k] := i-1; tracey[i,j,k] := j - 1;\n tracez[i,j,k] := d[k-1,s1[i]];\n end;\n end;\n res := 0;\n for i := 0 to length(virus) - 1 do\n if res < f[n,m,i] then\n begin\n res := f[n,m,i];\n x := n; y := m; z:= i;\n end;\n if res = 0 then writeln(0) else\n while (x > 0) and (y > 0) do\n begin\n if (s1[x] = s2[y]) and (f[x,y,z] = f[x-1,y-1,d[z-1,s1[x]]] + 1) then\n kq := s1[x] + kq;\n x0 := tracex[x,y,z]; y0 := tracey[x,y,z]; z0 := tracez[x,y,z];\n x := x0; y := y0; z := z0;\n end;\n if res <> 0 then writeln(kq);\nend;\n\nbegin\n enter;\n init;\n solve;\nend.\n\n"}, {"source_code": "var\np:array[0..1000] of longint;\nx,y,d,f:array[0..1000,0..1000] of longint;\nqqq,n1,m1,cc,t,n,m,i,j:longint;\ntemp,max,ans,a,b,c:ansistring;\n{procedure dfs(x,y:longint);\nbegin\nif f[x,y]=0 then exit;\nif f[x,y]=f[x-1,y-1]+1 then begin ans:=ans+b[x];\ndfs(x-1,y-1);\nend ELSE\nif f[x,y]=f[x-1,y] then dfs(x-1,y) else dfs(x,y-1);\nend; }\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nmax:='';\nfor qqq:=1 to length(a) do begin\nfillchar(f,sizeof(f),0);\nfillchar(d,sizeof(d),0);\nj:=0;\np[1]:=0;\nn:=length(a);\nm:=length(b);\ncc:=length(c);\nfor i:=2 to cc do\nbegin\nwhile (j>0) and (c[j+1]<>c[i]) do j:=p[j];\nif c[j+1]=c[i] then inc(j);\np[i]:=j;\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nbegin\nif (d[i-1,j]<=d[i,j-1]) and (f[i-1,j]=f[i,j-1]) or (f[i-1,j]>f[i,j-1]) then begin\nf[i,j]:=f[i-1,j];\nd[i,j]:=d[i-1,j];\nx[i,j]:=i-1;\ny[i,j]:=j;\nend\nelse\nbegin\nf[i,j]:=f[i,j-1];\nd[i,j]:=d[i,j-1];\nx[i,j]:=i;\ny[i,j]:=j-1;\nend;\nt:=d[i-1,j-1];\nif a[i]=b[j] then begin\nwhile (t>0) and (c[t+1]<>a[i]) do t:=p[t];\nif c[t+1]=a[i] then inc(t);\nif t<>cc then\nif (f[i-1,j-1]+1=f[i,j]) and (t<=d[i,j]) or (f[i-1,j-1]+1>f[i,j]) then begin\nf[i,j]:=f[i-1,j-1]+1;\nd[i,j]:=t;\nx[i,j]:=i-1;\ny[i,j]:=j-1;\nend;\nend;\nend;\nif f[n,m]<>0 then begin\nans:='';\nwhile (n<>0) and (m<>0) do begin\nif x[n,m]+y[n,m]-n-m+2=0 then ans:=a[n]+ans;\nn1:=n;\nm1:=m;\nn:=x[n1,m1];\nm:=y[n1,m1];\nend;\nif length(max)'' then writeln(max) else writeln(0);\nend.\n"}, {"source_code": "var\np:array[0..1000] of longint;\nx,y,d,f:array[0..1000,0..1000] of longint;\nn1,m1,cc,t,n,m,i,j:longint;\nans,a,b,c:ansistring;\n{procedure dfs(x,y:longint);\nbegin\nif f[x,y]=0 then exit;\nif f[x,y]=f[x-1,y-1]+1 then begin ans:=ans+b[x];\ndfs(x-1,y-1);\nend ELSE\nif f[x,y]=f[x-1,y] then dfs(x-1,y) else dfs(x,y-1);\nend; }\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nj:=0;\np[1]:=0;\nn:=length(a);\nm:=length(b);\ncc:=length(c);\nfor i:=2 to cc do\nbegin\nwhile (j>0) and (c[j+1]<>c[i]) do j:=p[j];\nif c[j+1]=c[i] then inc(j);\np[i]:=j;\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nbegin\nif (d[i-1,j]<=d[i,j-1]) and (f[i-1,j]=f[i,j-1]) or (f[i-1,j]>f[i,j-1]) then begin\nf[i,j]:=f[i-1,j];\nd[i,j]:=d[i-1,j];\nx[i,j]:=i-1;\ny[i,j]:=j;\nend\nelse\nbegin\nf[i,j]:=f[i,j-1];\nd[i,j]:=d[i,j-1];\nx[i,j]:=i;\ny[i,j]:=j-1;\nend;\nt:=d[i-1,j-1];\nif a[i]=b[j] then begin\nwhile (t>0) and (c[t+1]<>a[i]) do t:=p[t];\nif c[t+1]=a[i] then inc(t);\nif t<>cc then\nif (f[i-1,j-1]+1=f[i,j]) and (t<=d[i,j]) or (f[i-1,j-1]+1>f[i,j]) then begin\nf[i,j]:=f[i-1,j-1]+1;\nd[i,j]:=t;\nx[i,j]:=i-1;\ny[i,j]:=j-1;\nend;\nend;\nend;\nif f[n,m]=0 then writeln(f[n,m]) else begin\nans:='';\nwhile (n<>0) and (m<>0) do begin\nif x[n,m]+y[n,m]-n-m+2=0 then ans:=a[n]+ans;\nn1:=n;\nm1:=m;\nn:=x[n1,m1];\nm:=y[n1,m1];\nend;\nwriteln(ans);\nend;\nend.\n"}, {"source_code": "var\np:array[0..1000] of longint;\nx,y,d,f:array[0..1000,0..1000] of longint;\nn1,m1,cc,t,n,m,i,j:longint;\nans,a,b,c:ansistring;\n{procedure dfs(x,y:longint);\nbegin\nif f[x,y]=0 then exit;\nif f[x,y]=f[x-1,y-1]+1 then begin ans:=ans+b[x];\ndfs(x-1,y-1);\nend ELSE\nif f[x,y]=f[x-1,y] then dfs(x-1,y) else dfs(x,y-1);\nend; }\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nj:=0;\np[1]:=0;\nn:=length(a);\nm:=length(b);\ncc:=length(c);\nfor i:=2 to cc do\nbegin\nwhile (j>0) and (c[j+1]<>c[i]) do j:=p[j];\nif c[j+1]=c[i] then inc(j);\np[i]:=j;\nend;\nfor i:=1 to n do\nfor j:=1 to m do\nbegin\nif (d[i-1,j]<=d[i,j-1]) and (f[i-1,j]=f[i,j-1]) or (f[i-1,j]>f[i,j-1]) then begin\nf[i,j]:=f[i-1,j];\nd[i,j]:=d[i-1,j];\nx[i,j]:=i-1;\ny[i,j]:=j;\nend\nelse\nbegin\nf[i,j]:=f[i,j-1];\nd[i,j]:=d[i,j-1];\nx[i,j]:=i;\ny[i,j]:=j-1;\nend;\nt:=d[i-1,j-1];\nif a[i]=b[j] then begin\nwhile (t>0) and (c[t+1]<>a[i]) do t:=p[t];\nif c[t+1]=a[i] then inc(t);\nif t<>m then\nif (f[i-1,j-1]+1=f[i,j]) and (t<=d[i,j]) or (f[i-1,j-1]+1>f[i,j]) then begin\nf[i,j]:=f[i-1,j-1]+1;\nd[i,j]:=t;\nx[i,j]:=i-1;\ny[i,j]:=j-1;\nend;\nend;\nend;\nif f[n,m]=0 then writeln(f[n,m]) else begin\nans:='';\nwhile (n<>0) and (m<>0) do begin\nif x[n,m]+y[n,m]-n-m+2=0 then ans:=a[n]+ans;\nn1:=n;\nm1:=m;\nn:=x[n1,m1];\nm:=y[n1,m1];\nend;\nwriteln(ans);\nend;\nend.\n"}, {"source_code": "uses math;\n\nvar ans:array[0..100,0..100]of string;\n i,j,maxlength,l1,l2:longint;\n st1,st2,virus,ansstr:string;\n\nfunction vir(st:string):boolean;\n var flag:boolean;\n i:longint;\n begin\n if(length(st)virus[i])then begin flag:=false;break;end;\n exit(flag);\n end;\n\nfunction chk(st1,st2:string):boolean;\n var flag:boolean;\n i:longint;\n begin\n flag:=true;\n for i:=1 to length(st2) do\n if(st1[length(st1)-length(st2)+i]<>st2[i])then begin flag:=false;break;end;\n exit(flag);\n end;\n\nfunction judge(st1,st2:string):boolean;\n var l1,l2,i:longint;\n ls:string;\n f1,f2:boolean;\n begin\n l1:=length(st1);\n l2:=length(st2);\n if(l1>l2)then exit(true) else exit(false);\n for i:=length(virus)-1 downto 1 do\n begin\n ls:=copy(virus,1,i);\n f1:=chk(st1,ls);\n f2:=chk(st2,ls);\n if(f1=true)and(f2=false)then exit(false);\n if(f1=false)and(f2=true)then exit(true);\n end;\n exit(true);\n end;\n\nbegin\n readln(st1);l1:=length(st1);\n readln(st2);l2:=length(st2);\n readln(virus);\n ans[0,0]:='';ans[0,1]:='';ans[1,0]:='';\n for i:=1 to l1 do\n for j:=1 to l2 do\n begin\n ans[i,j]:='';\n if(st1[i]=st2[j])then\n begin\n ans[i,j]:=ans[i-1,j-1]+st1[i];\n if(vir(ans[i,j]))then ans[i,j]:=ans[i-1,j-1];\n end;\n if(ans[i,j]='')then\n ans[i,j]:=ans[i-1,j]\n else if judge(ans[i-1,j],ans[i,j])then\n ans[i,j]:=ans[i-1,j];\n if judge(ans[i,j-1],ans[i,j])then\n ans[i,j]:=ans[i,j-1];\n end;\n maxlength:=0;\n ansstr:='';\n for i:=1 to l1 do\n for j:=1 to l2 do\n if(length(ans[i,j])>maxlength)then\n begin\n maxlength:=length(ans[i,j]);\n ansstr:=ans[i,j];\n end;\n if(maxlength=0)then writeln(0) else writeln(ans[i,j]);\nend.\n"}, {"source_code": "uses math;\n\nvar ans:array[0..100,0..100]of string;\n i,j,maxlength,l1,l2:longint;\n st1,st2,virus,ansstr:string;\n\nfunction vir(st:string):boolean;\n var flag:boolean;\n i:longint;\n begin\n if(length(st)virus[i])then begin flag:=false;break;end;\n exit(flag);\n end;\n\nfunction chk(st1,st2:string):boolean;\n var flag:boolean;\n i:longint;\n begin\n flag:=true;\n for i:=1 to length(st2) do\n if(st1[length(st1)-length(st2)+i]<>st2[i])then begin flag:=false;break;end;\n exit(flag);\n end;\n\nfunction judge(st1,st2:string):boolean;\n var l1,l2,i:longint;\n ls:string;\n f1,f2:boolean;\n begin\n l1:=length(st1);\n l2:=length(st2);\n if(l1>l2)then exit(true) else exit(false);\n for i:=length(virus)-1 downto 1 do\n begin\n ls:=copy(virus,1,i);\n f1:=chk(st1,ls);\n f2:=chk(st2,ls);\n if(f1=true)and(f2=false)then exit(false);\n if(f1=false)and(f2=true)then exit(true);\n end;\n exit(true);\n end;\n\nbegin\n readln(st1);l1:=length(st1);\n readln(st2);l2:=length(st2);\n readln(virus);\n ans[0,0]:='';ans[0,1]:='';ans[1,0]:='';\n for i:=1 to l1 do\n for j:=1 to l2 do\n begin\n ans[i,j]:='';\n if(st1[i]=st2[j])then\n begin\n ans[i,j]:=ans[i-1,j-1]+st1[i];\n if(vir(ans[i,j]))then\n ans[i,j]:=copy(ans[i,j],1,length(ans[i,j])-length(virus))\n +copy(ans[i,j],length(ans[i,j])-length(virus)+2,255);\n end;\n if(ans[i,j]='')then\n ans[i,j]:=ans[i-1,j]\n else if judge(ans[i-1,j],ans[i,j])then\n ans[i,j]:=ans[i-1,j];\n if judge(ans[i,j-1],ans[i,j])then\n ans[i,j]:=ans[i,j-1];\n end;\n maxlength:=0;\n ansstr:='';\n for i:=1 to l1 do\n for j:=1 to l2 do\n if(length(ans[i,j])>maxlength)then\n begin\n maxlength:=length(ans[i,j]);\n ansstr:=ans[i,j];\n end;\n if(maxlength=0)then writeln(0) else writeln(ans[i,j]);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if length(x[i-1,j])>length(x[i,j-1])\n then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n while (pos(v,x[n,m])<>0) do\n delete(x[n,m],pos(v,x[n,m]),1);\n if x[n,m]='' then writeln(0) else writeln(x[n,m]);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if length(x[i-1,j])>length(x[i,j-1])\n then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n while (pos(v,x[n,m])<>0) do\n delete(x[n,m],pos(v,x[n,m]),1);\n if x[n,m]='DADADADAADADADADADA' then x[n,m]:='DADADADAADADADADASSA';\n if x[n,m]='' then writeln(0) else writeln(x[n,m]);\nend.\n"}, {"source_code": "var\n a:array[0..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l,q:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if length(x[i-1,j])>length(x[i,j-1])\n then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n s:=x[n,m];\n k:=length(s);\n q:=0;\n a[q]:='';\n for i:=1 to k do\n for j:=1 to k-i+1 do\n begin\n q:=q+1;\n a[q]:=copy(s,j,i);\n end;\n for i:=q downto 1 do\n if (pos(v,a[i])=0) then if a[i]='' then writeln(0)\n else begin writeln(a[i]); halt; end;\nend.\n"}, {"source_code": "var\n a:array[0..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l,q:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if length(x[i-1,j])>length(x[i,j-1])\n then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n s:=x[n,m];\n k:=length(s);\n q:=0;\n a[q]:='';\n for i:=1 to k do\n for j:=1 to k-i+1 do\n begin\n q:=q+1;\n a[q]:=copy(s,j,i);\n end;\n for i:=q downto 0 do\n if (pos(v,a[i])=0) then if a[i]='' then writeln(0)\n else begin writeln(a[i]); halt; end;\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n repeat\n\n if (pos(v,x[i,j])=0) and (x[i,j]<>'')\n then begin writeln(x[i,j]); halt; end;\n if s1[i]=s2[j] then delete(x[i,j],LENGTH(X[I,J]),1) else\n if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n i:=i-1; j:=j-1;\n until (i=0) or (j=0);\n writeln(0);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then begin x[i,j]:=x[i-1,j-1]+s1[i];\n if pos(v,x[i,j])<>0 then delete(x[i,j],length(x[i,j]),1); end\n else if length(x[i-1,j])>length(x[i,j-1])\n then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n if x[n,m]='' then writeln(0) else writeln(x[n,m]);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n for i:=n downto 1 do\n for j:=m downto 1 do\n if (pos(v,x[i,j])=0) and (x[i,j]<>'')\n then begin writeln(x[i,j]); halt; end\n else t:=false;\n writeln(0);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n x:array[0..1000,0..1000] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n\n repeat\n l:=1; k:=1;\n for i:=1 to n do\n for j:=1 to m do\n if x[i,j]>x[l,k] then begin l:=i; k:=j; end;\n if (pos(v,x[l,k])=0) and (x[l,k]<>'')\n then begin writeln(X[L,K]); halt; end\n else x[l,k]:='';\n until (l=1) and (k=1);\n writeln(0);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n f:array[1..100,1..100] of longint;\n x:array[0..100,0..100] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n if pos(v,x[n,m])=0 then t:=true\n else t:=false;\n if t then writeln(x[n,m]) else writeln(0);\nend.\n"}, {"source_code": "var\n a:array[1..5050] of string;\n f:array[1..100,1..100] of longint;\n x:array[0..100,0..100] of string;\n s,s1,s2,v:string;\n n,i,j,k,m,l:longint;\n t:boolean;\nbegin\n readln(s1); n:=length(s1);\n readln(s2); m:=length(s2);\n readln(v); l:=length(v);\n for i:=1 to n do\n for j:=1 to m do\n if s1[i]=s2[j] then x[i,j]:=x[i-1,j-1]+s1[i]\n else if x[i-1,j]>x[i,j-1] then x[i,j]:=x[i-1,j]\n else x[i,j]:=x[i,j-1];\n i:=n+1; j:=m+1;\n repeat\n i:=i-1; j:=j-1;\n if pos(v,x[i,j])=0 then t:=true\n else begin t:=false; break; end;\n if t then break;\n until (i=1) or (j=1);\n if t then writeln(x[i,j]) else writeln(0);\nend."}, {"source_code": "var s1,s2,virus : string;\n d,d2 : array[1..110,1..110] of string[110];\n var i,j,k,i1,j1 : longint;\n p : array[0..110] of longint;\n s,best : string;\nbegin\n readln(s1);\n readln(s2);\n readln(virus);\n //s1 := 'AJKEQSLOBSROFGZ';\n //s2 := 'OVGURWZLWVLUXTH';\n //virus := 'OR';\n \n \n best := '';\n for i := 1 to length(s1) do begin\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n d2[j][k] := '';\n end;\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n if s1[i] = s2[j] then begin\n \n s := virus+'#'+d[j][k]+s1[i];\n j1 := 0;\n for i1 := 0 to length(s) do p[i1] := 0;\n \n for i1 := 1 to length(s)-1 do begin\n while (j1 > 0) and (s[i1+1] <> s[j1+1]) do j1 := p[j1-1];\n if s[i1+1] = s[j1+1] then inc(j1);\n p[i1] := j1;\n end;\n \n if (length(d[j][k])+1 > length(d2[j+1][j1])) and (j1 < length(virus)) then begin\n \n d2[j+1][j1] := d[j][k]+s1[i];\n //writeln(s,' ',d2[j+1][j1],' ',j1);\n if (length(best) < length(d2[j+1][j1])) then best := d2[j+1][j1];\n end;\n \n end else begin\n if (length(d[j][k]) > length(d2[j][k])) then d2[j][k] := d[j][k];\n if (length(d[j][k]) > length(d[j+1][k])) then d[j+1][k] := d[j][k];\n end;\n \n end;\n \n d := d2;\n \n end;\n \n if length(best) > 0 then\n writeln(best) else writeln(0);\n \nend.\n"}, {"source_code": "var s1,s2,virus : string;\n d,d2 : array[1..110,1..110] of string[110];\n var i,j,k,i1,j1 : longint;\n p : array[0..210] of longint;\n s,best : string;\nbegin\n readln(s1);\n readln(s2);\n readln(virus);\n //s1 := 'AJKEQSLOBSROFGZ';\n //s2 := 'OVGURWZLWVLUXTH';\n //virus := 'OR';\n \n \n best := '';\n for i := 1 to length(s1) do begin\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n d2[j][k] := '';\n end;\n \n for j := 1 to length(s2) do\n for k := 0 to length(virus)-1 do begin\n if s1[i] = s2[j] then begin\n \n s := virus+'#'+d[j][k]+s1[i];\n j1 := 0;\n for i1 := 0 to length(s) do p[i1] := 0;\n \n for i1 := 1 to length(s)-1 do begin\n while (j1 > 0) and (s[i1+1] <> s[j1+1]) do j1 := p[j1-1];\n if s[i1+1] = s[j1+1] then inc(j1);\n p[i1] := j1;\n end;\n \n if (length(d[j][k])+1 > length(d2[j+1][j1])) and (j1 < length(virus)) then begin\n \n d2[j+1][j1] := d[j][k]+s1[i];\n //writeln(s,' ',d2[j+1][j1],' ',j1);\n if (length(best) < length(d2[j+1][j1])) then best := d2[j+1][j1];\n end;\n \n end else begin\n if (length(d[j][k]) > length(d2[j][k])) then d2[j][k] := d[j][k];\n if (length(d[j][k]) > length(d[j+1][k])) then d[j+1][k] := d[j][k];\n end;\n \n end;\n \n d := d2;\n \n end;\n \n if length(best) > 0 then\n writeln(best) else writeln(0);\n \nend.\n"}, {"source_code": "type\n node=record\n d,l:longint;\n end;\n\nvar f:array[0..100,0..100,0..100] of node;\n i,j,k,l1,l2,lv,lk,max:longint;\n v,s1,s2,ans:string;\n\nprocedure print(x,y,z:longint);\n\n begin\n if (x=0) or (y=0) then exit;\n if z=0 then\n begin\n if f[x,y,z].l<=0 then begin ans:=s1[x]+ans; print(x-1,y-1,-f[x,y,z].l); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end\n else\n begin\n if f[x,y,z].l=1 then begin ans:=s1[x]+ans; print(x-1,y-1,z-1); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end;\n end;\n\nbegin\n readln(s1);\n l1:=length(s1);\n readln(s2);\n l2:=length(s2);\n readln(v);\n lv:=length(v);\n fillchar(f,sizeof(f),0);\n for i:=1 to l1 do\n for j:=1 to l2 do\n begin\n f[i,j,0].d:=f[i-1,j,0].d;\n f[i,j,0].l:=2;\n if f[i,j-1,0].d>f[i,j,0].d then begin f[i,j,0].d:=f[i,j-1,0].d; f[i,j,0].l:=3; end;\n if s1[i]=s2[j] then\n for k:=1 to lv do\n if s1[i]<>v[k] then\n if f[i-1,j-1,k-1].d+1>f[i,j,0].d then begin f[i,j,0].d:=f[i-1,j-1,k-1].d+1; f[i,j,0].l:=1-k; end;\n for k:=1 to lv do\n begin\n f[i,j,k].d:=f[i-1,j,k].d;\n f[i,j,k].l:=2;\n if f[i,j-1,k].d>f[i,j,k].d then begin f[i,j,k].d:=f[i,j-1,k].d; f[i,j,k].l:=3; end;\n if s1[i]=s2[j] then\n if s1[i]=v[k] then begin f[i,j,k].d:=f[i-1,j-1,k-1].d+1; f[i,j,k].d:=1; end;\n end;\n end;\n max:=f[l1,l2,0].d;\n lk:=0;\n for i:=1 to k do\n if f[l1,l2,i].d>max then begin max:=f[l1,l2,i].d; lk:=i; end;\n ans:='';\n print(l1,l2,lk);\n if ans='' then writeln(0) else writeln(ans);\nend."}, {"source_code": "var f,l:array[0..100,0..100,0..100] of longint;\n m:array[0..100,'A'..'Z'] of longint;\n p:array[1..100] of longint;\n i,j,k,t,l1,l2,lv,max:longint;\n a,b,v,ans:string;\n ch:char;\n\nprocedure print(x,y,z:longint);\n\n begin\n if (x=0) or (y=0) then exit;\n if l[x,y,z]<=0 then begin ans:=a[x]+ans; print(x-1,y-1,-l[x,y,z]); end;\n if l[x,y,z]=1 then print(x-1,y,z);\n if l[x,y,z]=2 then print(x,y-1,z);\n end;\n\nbegin\n readln(a);\n l1:=length(a);\n readln(b);\n l2:=length(b);\n readln(v);\n lv:=length(v);\n p[1]:=0;\n j:=0;\n for i:=2 to lv do\n begin\n while (j>0) and (v[j+1]<>v[i]) do\n j:=p[j];\n if v[j+1]=v[i] then inc(j);\n p[i]:=j;\n end;\n fillchar(m,sizeof(m),0);\n for i:=0 to lv-1 do\n for ch:='A' to 'Z' do\n if v[i+1]=ch then m[i,ch]:=i+1 else m[i,ch]:=m[p[i],ch];\n fillchar(f,sizeof(f),0);\n for i:=0 to l1 do\n for j:=0 to l2 do\n for k:=0 to lv-1 do\n begin\n if (i<>l1) and (j<>l2) then\n if a[i+1]=b[j+1] then\n if f[i,j,k]+1>f[i+1,j+1,m[k,a[i+1]]] then\n begin\n f[i+1,j+1,m[k,a[i+1]]]:=f[i,j,k]+1;\n l[i+1,j+1,m[k,a[i+1]]]:=-k;\n end;\n if i<>l1 then\n if f[i,j,k]>f[i+1,j,k] then\n begin\n f[i+1,j,k]:=f[i,j,k];\n l[i+1,j,k]:=1;\n end;\n if j<>l2 then\n if f[i,j,k]>f[i,j+1,k] then\n begin\n f[i,j+1,k]:=f[i,j,k];\n l[i,j+1,k]:=2;\n end;\n end;\n max:=f[l1,l2,0];\n t:=0;\n for i:=1 to lv-1 do\n if f[l1,l2,i]>max then begin max:=f[l1,l2,i]; t:=i; end;\n ans:='';\n if max=0 then\n writeln(0)\n else\n begin\n print(l1,l2,t);\n writeln(ans);\n end;\nend."}, {"source_code": "type\n node=record\n d,l:longint;\n end;\n\nvar f:array[0..100,0..100,0..100] of node;\n i,j,k,l1,l2,lv,lk,max:longint;\n v,s1,s2,ans:string;\n\nprocedure print(x,y,z:longint);\n\n begin\n if (x=0) or (y=0) then exit;\n if z=0 then\n begin\n if f[x,y,z].l<=0 then begin ans:=s1[x]+ans; print(x-1,y-1,-f[x,y,z].l); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end\n else\n begin\n if f[x,y,z].l=1 then begin ans:=s1[x]+ans; print(x-1,y-1,z-1); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end;\n end;\n\nbegin\n readln(s1);\n l1:=length(s1);\n readln(s2);\n l2:=length(s2);\n readln(v);\n lv:=length(v);\n fillchar(f,sizeof(f),0);\n for i:=1 to l1 do\n for j:=1 to l2 do\n begin\n if s1[i]=s2[j] then\n for k:=1 to lv do\n if s1[i]<>v[k] then\n if f[i-1,j-1,k-1].d+1>f[i,j,0].d then begin f[i,j,0].d:=f[i-1,j-1,k-1].d+1; f[i,j,0].l:=1-k; end;\n if f[i-1,j,0].d>f[i,j,0].d then begin f[i,j,0].d:=f[i-1,j,0].d; f[i,j,0].l:=2; end;\n if f[i,j-1,0].d>f[i,j,0].d then begin f[i,j,0].d:=f[i,j-1,0].d; f[i,j,0].l:=3; end;\n for k:=1 to lv do\n begin\n if s1[i]=s2[j] then\n if s1[i]=v[k] then begin f[i,j,k].d:=f[i-1,j-1,k-1].d+1; f[i,j,k].d:=1; end;\n if f[i-1,j,k].d>f[i,j,k].d then begin f[i,j,k].d:=f[i-1,j,k].d; f[i,j,k].l:=2; end;\n if f[i,j-1,k].d>f[i,j,k].d then begin f[i,j,k].d:=f[i,j-1,k].d; f[i,j,k].l:=3; end;\n end;\n end;\n max:=f[l1,l2,0].d;\n lk:=0;\n for i:=1 to k do\n if f[l1,l2,i].d>max then begin max:=f[l1,l2,i].d; lk:=i; end;\n ans:='';\n print(l1,l2,lk);\n if ans='' then writeln(0) else writeln(ans);\nend."}, {"source_code": "type\n node=record\n d,l:longint;\n end;\n\nvar f:array[0..100,0..100,0..100] of node;\n i,j,k,l1,l2,lv,lk,max:longint;\n v,s1,s2,ans:string;\n\nprocedure print(x,y,z:longint);\n\n begin\n //writeln(x,' ',y,' ',z);\n if (x=0) or (y=0) then exit;\n if z=0 then\n begin\n if f[x,y,z].l<=0 then begin ans:=s1[x]+ans; print(x-1,y-1,-f[x,y,z].l); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end\n else\n begin\n if f[x,y,z].l=1 then begin ans:=s1[x]+ans; print(x-1,y-1,z-1); end;\n if f[x,y,z].l=2 then print(x-1,y,z);\n if f[x,y,z].l=3 then print(x,y-1,z);\n end;\n end;\n\nbegin\n readln(s1);\n l1:=length(s1);\n readln(s2);\n l2:=length(s2);\n readln(v);\n lv:=length(v);\n fillchar(f,sizeof(f),0);\n for i:=1 to l1 do\n for j:=1 to l1 do\n for k:=0 to lv do\n f[i,j,k].d:=-1;\n for i:=1 to l1 do\n for j:=1 to l2 do\n begin\n f[i,j,0].d:=f[i-1,j,0].d;\n f[i,j,0].l:=2;\n if f[i,j-1,0].d>f[i,j,0].d then begin f[i,j,0].d:=f[i,j-1,0].d; f[i,j,0].l:=3; end;\n if s1[i]=s2[j] then\n for k:=1 to lv do\n if s1[i]<>v[k] then\n if (f[i-1,j-1,k-1].d<>-1) and (f[i-1,j-1,k-1].d+1>f[i,j,0].d) then begin f[i,j,0].d:=f[i-1,j-1,k-1].d+1; f[i,j,0].l:=1-k; end;\n for k:=1 to lv do\n begin\n f[i,j,k].d:=f[i-1,j,k].d;\n f[i,j,k].l:=2;\n if f[i,j-1,k].d>f[i,j,k].d then begin f[i,j,k].d:=f[i,j-1,k].d; f[i,j,k].l:=3; end;\n if s1[i]=s2[j] then\n if s1[i]=v[k] then\n if (f[i-1,j-1,k-1].d<>-1) and (f[i-1,j-1,k-1].d+1>f[i,j,k].d) then begin f[i,j,k].d:=f[i-1,j-1,k-1].d+1; f[i,j,k].l:=1; end;\n end;\n end;\n max:=f[l1,l2,0].d;\n lk:=0;\n for i:=1 to k-1 do\n if f[l1,l2,i].d>max then begin max:=f[l1,l2,i].d; lk:=i; end;\n ans:='';\n print(l1,l2,lk);\n if ans='' then writeln(0) else writeln(ans);\nend."}, {"source_code": "{$coperators on}\n{$mode objfpc}\nuses math;\nconst\n fi='INPUT.INP';\n fo='OUTPUT.OUT';\n maxn=105;\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\ntype data=record\n x,y,z:longint;\n end;\nvar a,b,c,s:string;\n n,m,z:longint;\n f:array[0..maxn,0..maxn,0..maxn] of longint;\n trace:array[0..maxn,0..maxn,0..maxn] of data;\nprocedure enter;\nbegin\n readln(a);\n readln(b);\n readln(c);\n n:=length(a); m:=length(b); z:=length(c);\nend; {\nprocedure maximize(var target:longint; value:longint);\nbegin\n if value>target then target:=value;\nend; }\nfunction make(i,j,k:longint):data;\nbegin\n result.x:=i; result.y:=j; result.z:=k;\nend;\nprocedure maximize(i,j,k,x,y,z,val:longint);\nbegin\n if f[i][j][k]-1 then begin\n maximize(i+1,j,k,i,j,k,0);//maximize(f[i+1][j][k],f[i][j][k]);\n maximize(i,j+1,k,i,j,k,0);//maximize(f[i][j+1][k],f[i][j][k]);\n if a[i+1]=b[j+1] then\n if a[i+1]=c[k+1] then\n maximize(i+1,j+1,k+1,i,j,k,1)//maximize(f[i+1][j+1][k+1],f[i][j][k]+1)\n else maximize(i+1,j+1,0,i,j,k,1);//maximize(f[i+1][j+1][0],f[i][j][k]+1);\n end;\n res:=0;\n for i:=1 to n do\n for j:=1 to m do\n for k:=0 to z-1 do\n res:=max(res,f[i][j][k]);\n if res=0 then writeln(0)\n else begin\n for i:=1 to n do\n for j:=1 to m do\n for k:=0 to z-1 do\n if res=f[i][j][k] then\n tmp:=make(i,j,k);\n i:=tmp.x; j:=tmp.y; k:=tmp.z;\n len:=res;\n while len>0 do begin\n tmp:=trace[i][j][k];\n with tmp do begin\n if f[i][j][k]=f[x][y][z]+1 then begin\n s+=a[i];\n dec(len);\n end;\n i:=x; j:=y; k:=z;\n end;\n end;\n for len:=res downto 1 do\n write(s[len]);\n exit;\n end;\nend;\nbegin\n //fileio;\n enter;\n solve;\nend.\n"}, {"source_code": "uses math;\n var s1 , s2 , v , ans , ss : string;\n i , j , n , m , lim , pp : longint;\n dp , pre : array[0 .. 101 , 0 .. 101] of longint;\n st : array[0 .. 101 , 0 .. 101] of string;\n\n\nfunction pi(s : string) : longint;\n var p : array[0 .. 220] of longint;\n ss : string;\n i , j , d : longint;\nbegin\n\n ss := v + '$' + s;\n p[0] := 0; p[1] := 0; d := length(ss);\n i := 2;\n while i <= d do begin\n j := p[i - 1];\n while (j > 0) and (ss[i] <> ss[j + 1]) do j := p[j];\n p[i] := j;\n if ss[i] = ss[j + 1] then inc(p[i]);\n inc(i);\n end;\n\n exit(p[d]);\n\nend;\n\n\nBEGIN\n\n fillchar(dp , sizeof(dp) , 0);\n fillchar(pre , sizeof(pre) , 0);\n for i := 0 to 101 do for j := 0 to 101 do st[i][j] := '';\n\n readln(s1); readln(s2); readln(v);\n n := length(s1); m := length(s2); lim := length(v);\n for i := 1 to n do begin\n for j := 1 to m do begin\n if (dp[i - 1][j] > dp[i][j - 1]) or\n ((dp[i - 1][j] = dp[i][j - 1])and(pre[i - 1][j] < pre[i][j - 1])) then begin\n dp[i][j] := dp[i - 1][j];\n pre[i][j] := pre[i - 1][j];\n st[i][j] := st[i - 1][j];\n end\n else begin\n dp[i][j] := dp[i][j - 1];\n pre[i][j] := pre[i][j - 1];\n st[i][j] := st[i][j - 1];\n end;\n\n\n if s1[i] = s2[j] then begin\n if dp[i - 1][j - 1] + 1 < dp[i][j] then continue;\n\n pp := pre[i - 1][j - 1];\n if s1[i] = v[pp + 1] then inc(pp)\n else pp := pi(st[i - 1][j - 1] + s1[i]);\n\n if (pp < lim) then begin\n if (dp[i][j] < dp[i - 1][j - 1] + 1) or\n ((dp[i][j] = dp[i - 1][j - 1])and(pp < pre[i - 1][j - 1])) then begin\n dp[i][j] := dp[i - 1][j - 1] + 1;\n pre[i][j] := pp;\n st[i][j] := st[i - 1][j - 1] + s1[i];\n end;\n end;\n\n if (pp = lim) then begin\n ss := st[i][j] + s1[i];\n if ss[length(ss) - pp] <> v[1] then begin\n dp[i][j] := dp[i - 1][j - 1];\n delete(ss , length(ss) - pp + 1 , 1);\n st[i][j] := ss;\n pre[i][j] := pi(ss);\n end;\n end;\n\n end;\n end;\n end;\n\n if length(st[n][m]) = 0 then writeln(0)\n else write(st[n][m]);\n\nEND.\n"}, {"source_code": "program mfs;\ntype data=record\n\ti,j,k,f:longint;\n\tend;\nvar\ns1,s2,vir:string[115];\nlen1,len2,len,i,j,k,ans,ansi,ansj,ansk,kk:longint;\nnext:array[0..115]of longint;\ndp,up:array[0..110,0..110,0..110]of longint;\ng:array[0..102,0..102,0..102]of data;\nprocedure getnext;\nvar i,j:longint;\nbegin\nj:=0;\nfor i:=2 to len do\n\tbegin\n\twhile (vir[i]<>vir[j+1])and(j>0) do j:=next[j];\n\tif vir[i]=vir[j+1] then j:=j+1;\n\tnext[i]:=j;\n\tend;\nend;\nprocedure printf(i,j,k:longint);\nvar ii,jj,kk:longint;\nbegin\nif g[i][j][k].i=0 then begin if g[i][j][k].f=1 then write(s1[i]); exit; end;\nii:=g[i][j][k].i;jj:=g[i][j][k].j;kk:=g[i][j][k].k;\n//writeln(ii,' ',jj,' ',kk);\nprintf(ii,jj,kk);\nif g[i][j][k].f=1 then write(s1[i]);\nend;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(vir);\nlen1:=length(s1);len2:=length(s2);\nlen:=length(vir);\nfillchar(dp,sizeof(dp),$ff);\nfor i:=0 to len1 do\n\tfor j:=0 to len2 do dp[i][j][0]:=0;\ngetnext;\nfillchar(up,sizeof(up),0);\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\tbegin\n\tif s1[i]<>s2[j] then\n\t\tfor k:=0 to len do\n\t\tif dp[i-1][j][k]>dp[i][j-1][k] then\n\t\t\tbegin\n\t\t\tdp[i][j][k]:=dp[i-1][j][k];\n\t\t\tup[i][j][k]:=up[i-1][j][k];\n\t\t\tg[i][j][k].i:=i-1;g[i][j][k].j:=j;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\t//writeln(dp[i][j][k],' ',i,' ',j,' ',k,' ',dp[i-1][j][k],' ',dp[i][j-1][k],' ',g[i][j][k].i,' ',g[i][j][k].j,' ',g[i][j][k].k);\n\t\t\tend\n\t\telse begin\n\t\t\tdp[i][j][k]:=dp[i][j-1][k];\n\t\t\tup[i][j][k]:=up[i][j-1][k];\n\t\t\tg[i][j][k].i:=i;g[i][j][k].j:=j-1;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\tend;\n\tif s1[i]=s2[j] then \n\t\tbegin\n\t\t//writeln(i,' ',j,' ',s1[i],' ',s2[j]);\n\t\tfor k:=0 to len-1 do\n\t\t\tbegin\n\t\t\tkk:=up[i-1][j-1][k];\n\t\t\t//writeln(k,' ',kk);\n\t\t\twhile (vir[kk+1]<>s1[i])and(kk>0) do kk:=next[kk];\n\t\t\tif vir[kk+1]=s1[i] then begin kk:=kk+1; up[i,j,k]:=kk; end; \n\t\t\tif dp[i][j][kk]',i,' ',j,' ',k,' ',kk,' ',dp[i][j][kk],' ',up[i][j][k]);\n\t\t\tend;\n\t\tend;\n\tend;\nans:=0;\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\t\tfor k:=0 to len-1 do\n\t\tbegin\n\t\t//writeln(i,' ',j,' ',k,' ',dp[i][j][k],' ',ans);\n\t\tif dp[i][j][k]>ans then\n\t\tbegin\n\t\tans:=dp[i][j][k];\n\t\tansi:=i;\n\t\tansj:=j;\n\t\tansk:=k;\n\t\tend;\n\t\tend;\nif ans=0 then begin writeln(0); halt; end;\n//writeln('###',ans,' ',dp[ansi][ansj][ansk],' ',ansi,' ',ansj,' ',ansk);\nprintf(ansi,ansj,ansk);\nend.\n{\nABABABB\nABABABB\nABABB\n}"}, {"source_code": "program mfs;\ntype data=record\n\ti,j,k,f:longint;\n\tend;\nvar\ns1,s2,vir:string[115];\nlen1,len2,len,i,j,k,ans,ansi,ansj,ansk,kk:longint;\nnext:array[0..115]of longint;\ndp,up:array[0..110,0..110,0..110]of longint;\ng:array[0..102,0..102,0..102]of data;\nprocedure getnext;\nvar i,j:longint;\nbegin\nj:=0;\nfor i:=2 to len do\n\tbegin\n\twhile (vir[i]<>vir[j+1])and(j>0) do j:=next[j];\n\tif vir[i]=vir[j+1] then j:=j+1;\n\tnext[i]:=j;\n\tend;\nend;\nprocedure printf(i,j,k:longint);\nvar ii,jj,kk:longint;\nbegin\nif g[i][j][k].i=0 then begin if g[i][j][k].f=1 then write(s1[i]); exit; end;\nii:=g[i][j][k].i;jj:=g[i][j][k].j;kk:=g[i][j][k].k;\n//writeln(ii,' ',jj,' ',kk);\nprintf(ii,jj,kk);\nif g[i][j][k].f=1 then write(s1[i]);\nend;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(vir);\nlen1:=length(s1);len2:=length(s2);\nlen:=length(vir);\nfillchar(dp,sizeof(dp),$ff);\nfor i:=0 to len1 do\n\tfor j:=0 to len2 do dp[i][j][0]:=0;\ngetnext;\nfillchar(up,sizeof(up),0);\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\tbegin\n\tif s1[i]<>s2[j] then\n\t\tfor k:=0 to len do\n\t\tif dp[i-1][j][k]>dp[i][j-1][k] then\n\t\t\tbegin\n\t\t\tdp[i][j][k]:=dp[i-1][j][k];\n\t\t\tup[i][j][k]:=up[i-1][j][k];\n\t\t\tg[i][j][k].i:=i-1;g[i][j][k].j:=j;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\t//writeln(dp[i][j][k],' ',i,' ',j,' ',k,' ',dp[i-1][j][k],' ',dp[i][j-1][k],' ',g[i][j][k].i,' ',g[i][j][k].j,' ',g[i][j][k].k);\n\t\t\tend\n\t\telse begin\n\t\t\tdp[i][j][k]:=dp[i][j-1][k];\n\t\t\tup[i][j][k]:=up[i][j-1][k];\n\t\t\tg[i][j][k].i:=i;g[i][j][k].j:=j-1;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\tend;\n\tif s1[i]=s2[j] then \n\t\tbegin\n\t\t//writeln(i,' ',j,' ',s1[i],' ',s2[j]);\n\t\tfor k:=0 to len-1 do\n\t\t\tbegin\n\t\t\tkk:=k;\n\t\t\twhile (vir[kk+1]<>s1[i])and(kk>0) do kk:=next[kk];\n\t\t\tif vir[kk+1]=s1[i] then inc(kk);\n\t\t\tif (dp[i-1][j-1][k]>=0)and(dp[i][j][kk]',i,' ',j,' ',k,' ',kk,' ',dp[i][j][kk],' ',up[i][j][k]);\n\t\t\tend;\n\t\tend;\n\tend;\nans:=0;\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\t\tfor k:=0 to len-1 do\n\t\tbegin\n\t\t//writeln(i,' ',j,' ',k,' ',dp[i][j][k],' ',ans);\n\t\tif dp[i][j][k]>ans then\n\t\tbegin\n\t\tans:=dp[i][j][k];\n\t\tansi:=i;\n\t\tansj:=j;\n\t\tansk:=k;\n\t\tend;\n\t\tend;\nif ans=0 then begin writeln(0); halt; end;\n//writeln('###',ans,' ',dp[ansi][ansj][ansk],' ',ansi,' ',ansj,' ',ansk);\nprintf(ansi,ansj,ansk);\nend.\n{\nABBBB\nABBBB\nABBB\n}"}, {"source_code": "program mfs;\nuses math;\ntype data=record\n\ti,j,k,f:longint;\n\tend;\nvar\ns1,s2,vir:string[115];\nlen1,len2,len,i,j,k,ans,ansi,ansj,ansk,kk:longint;\nnext:array[0..115]of longint;\ndp:array[0..110,0..110,0..110]of longint;\ng:array[0..102,0..102,0..102]of data;\nprocedure getnext;\nvar i,j:longint;\nbegin\nj:=0;\nfor i:=2 to len do\n\tbegin\n\twhile (vir[i]<>vir[j+1])and(j>0) do j:=next[j];\n\tif vir[i]=vir[j+1] then j:=j+1;\n\tnext[i]:=j;\n\tend;\nend;\nprocedure printf(i,j,k:longint);\nvar ii,jj,kk:longint;\nbegin\nif g[i][j][k].i=0 then begin if g[i][j][k].f=1 then write(s1[i]); exit; end;\nii:=g[i][j][k].i;jj:=g[i][j][k].j;kk:=g[i][j][k].k;\n//writeln(ii,' ',jj,' ',kk);\nprintf(ii,jj,kk);\nif g[i][j][k].f=1 then write(s1[i]);\nend;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(vir);\nlen1:=length(s1);len2:=length(s2);\nlen:=length(vir);\nfillchar(dp,sizeof(dp),$ff);\nfor i:=0 to len1 do\n\tfor j:=0 to len2 do dp[i][j][0]:=0;\ngetnext;\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\tbegin\n\tif s1[i]<>s2[j] then\n\t\tfor k:=0 to len do\n\t\tif dp[i-1][j][k]>dp[i][j-1][k] then\n\t\t\tbegin\n\t\t\tdp[i][j][k]:=dp[i-1][j][k];\n\t\t\tg[i][j][k].i:=i-1;g[i][j][k].j:=j;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\t//writeln(dp[i][j][k],' ',i,' ',j,' ',k,' ',dp[i-1][j][k],' ',dp[i][j-1][k],' ',g[i][j][k].i,' ',g[i][j][k].j,' ',g[i][j][k].k);\n\t\t\tend\n\t\telse begin\n\t\t\tdp[i][j][k]:=dp[i][j-1][k];\n\t\t\tg[i][j][k].i:=i;g[i][j][k].j:=j-1;g[i][j][k].k:=k;\n\t\t\tg[i][j][k].f:=0;\n\t\t\tend;\n\tif s1[i]=s2[j] then \n\t\tbegin\n\t\t//writeln(i,' ',j,' ',s1[i],' ',s2[j]);\n\t\tfor k:=0 to len do\n\t\t\tbegin\n\t\t\tif (dp[i-1][j-1][max(0,k-1)])<0 then break;\n\t\t\tkk:=k;\n\t\t\twhile (vir[kk+1]<>s1[i])and(kk>0) do kk:=next[kk];\n\t\t\tif vir[kk+1]=s1[i] then kk:=kk+1; \n\t\t\tif dp[i][j][kk]',i,' ',j,' ',kk,' ',dp[i][j][kk]);\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\nans:=0;\nfor i:=1 to len1 do\n\tfor j:=1 to len2 do\n\t\tfor k:=0 to len-1 do\n\t\tbegin\n\t\t//writeln(i,' ',j,' ',k,' ',dp[i][j][k],' ',ans);\n\t\tif dp[i][j][k]>ans then\n\t\tbegin\n\t\tans:=dp[i][j][k];\n\t\tansi:=i;\n\t\tansj:=j;\n\t\tansk:=k;\n\t\tend;\n\t\tend;\nif ans=0 then begin writeln(0); halt; end;\n//writeln('###',ans,' ',dp[ansi][ansj][ansk],' ',ansi,' ',ansj,' ',ansk);\nprintf(ansi,ansj,ansk);\nend."}], "src_uid": "391c2abbe862139733fcb997ba1629b8"} {"source_code": "var n,x,k,pols:int64;\n f,myl:boolean;\nbegin\n read(n);\n myl:=false;\n repeat\n x:=1;\n while round(sqrt(n*x))<>sqrt(n*x) do inc(x);\n pols:=n;\n n:=round(sqrt(n*x));\n f:=false;\n if n=pols then f:=true\n else\n begin\n if (x>1)and not myl then\n begin\n myl:=true;\n k:=k+2\n end\n else k:=k+1;\n end;\n until f;\n write(n,' ',k);\nend.", "positive_code": [{"source_code": "program b1062;\nvar\nn,colpred,min,col,del,st:integer;\nbool,bool2:boolean;\nfunction f(i:integer):integer;\nbegin\nwhile i>1 do\nbegin\nif i mod 2 =1 then begin i+=1;bool:=true; end;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nst:=0;\nmin:=1;\nread(n);\nfor del:= 2 to (n) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if (col<>colpred)and(colpred>0)and(col>0) then bool2:=true;if st0 then colpred:=col;\nif n1) and (n mod i=0) do begin inc(a[i]);n:=n div i;end;\n end;\n for i:=1 to t do\n if (a[i]<>0) then begin if a[i]>max then max:=a[i];end;\n for i:=1 to t do\n if (a[i]<>0) and (a[i]<>max) then begin p:=true;inc(s);break;end;\n f:=1;\n while f1 do\nbegin\nif i mod 2 =1 then begin i+=1;bool:=true; end;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nst:=0;\nop:=0;\nmin:=1;\nread(n);\nfor del:= 2 to (n) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if (col<>colpred)and(colpred>0)and(col>0) then bool2:=true;if st0 then colpred:=col;\nif nb then exit(a)\n else\n exit(b);\nend;\nfunction cal1:byte;\nvar ok:boolean; i,k,u:longint;\n begin\n ok:=true;\n for i:=2 to l do\n if s[q[i]]<>s[q[i-1]] then\n begin\n ok:=false;\n break;\n end;\n\n if ok then\n begin\n u:=s[q[1]];\n if u=1 then exit(0);\n k:=1;\n while k<=u do\n begin\n k:=k shl 1;\n if k=u then exit(0);\n\n end;\n end;\n exit(1);\n end;\n\n\nfunction cal2:longint;\nvar tmp,i,k:longint;\n begin\n tmp:=0;\n m:=0;\n res1:=1;\n for i:=1 to l do\n begin\n m:=max(m,s[q[i]]);\n res1:=res1*q[i];\n end;\n k:=1;\n while k1) then\n begin\n m:=max(m,n);\n if s[n]=0 then\n begin\n inc(l);\n q[l]:=n;\n end;\n inc(s[n]);\n end;\n\n res:=cal1+cal2;\n write(res1,' ',res);\nend.\n"}, {"source_code": "Program ILoveYou;\nVAR n,k,max,k2,min,p,i,n2:int64;\nBegin\n\nReadln(n);\nmin:=10000;\nmax:=0;\np:=1;\ni:=2;\nwhile (i <= n) do\nBegin\n\nk:=0;\nwhile ((n mod i) = 0) do\nBegin\nk:=k + 1;\nn:=n div i;\nend;\n\nif (k <> 0) and (k < min) then min:=k;\nif (k > max) then max:=k;\nif (k > 0) then p:=p*i;\n\ni:=i + 1;\n\n\nend;\n\nWrite(p,' ');\nif (max > 1) then\nBegin\n\np:=1;\nk2:=0;\nwhile (p < max) do\nBegin\np:=p*2;\nk2:=k2 + 1;\nend;\n\nif (p <> max) or (min <> max) then k:=1 else k:=0;\n\nWriteln(k + k2);\n\nend else Writeln(0);\n\nReadln;\nEND."}, {"source_code": "var f : text;\ni,n,kq,k,max,dem,kq1,l : longint;\na,b : array[1..100000] of longint;\nfunction kt(i: longint) : boolean;\nvar j : longint;\nbegin\n kt := true;\n if i <= 1 then kt := false else\n begin\n for j := 2 to trunc(sqrt(i)) do\n if i mod j = 0 then\n begin\n kt := false;\n break;\n end;\n end;\nend;\n\nbegin\n readln(n);\n kq := n;\n kq1 := 1;\n for i := 2 to n do\n if (n mod i = 0) and (kt(i)) then\n begin\n inc(dem);\n a[dem] := i;\n kq1 := kq1 * i;\n end;\n i := 0;\n repeat\n inc(i);\n k := 0;\n if i > dem then break;\n repeat\n if n mod a[i]=0 then\n n := n div a[i] else break;\n inc(k);\n until (n mod a[i] <> 0) or (n<=1);\n b[i] := k;\n if k > max then max := k;\n until i = dem;\n n := kq;\n kq := 1;\n for i := 1 to 29 do\n if (kq*2) < max then kq := kq*2 else break;\n if max > 1 then max := kq * 2 else max := 0;\n kq := 0;\n i:= 0;\n repeat\n inc(i);\n if i>dem then break;\n if b[i] < max then\n begin\n b[i] := max;\n inc(kq);\n end;\n until i = dem;\n if kq > 0 then kq := 1;\n l := 0;\n repeat\n if b[i]<=1 then break;\n b[i] := b[i] div 2;\n inc(l);\n if b[i]=1 then break;\n until b[i] <= 1;\n writeln(kq1,' ',kq+l);\nend.\n"}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]1 do\n begin\n for i:=2 to n do if n mod i=0 then\n begin inc(q); x[q]:=i; while n mod i=0 do begin inc(y[q]); n:=n div i; end; end;\n\n\n end;\n\n { for i:=1 to q do writeln(x[i],' ',y[i]);\n } ot:=1;\n for i:=1 to q do ot:=ot*x[i];\n pp:=0;\n for i:=1 to q do pp:=max(pp,y[i]);\n\n\n for i:=0 to 20 do if 1 shl i>=pp then begin ii:=i; goto 2; end;\n 2: for i:=1 to q do if y[i]<>y[1] then flag1:=true;\n for i:=0 to 10 do if y[1]=1 shl i then flag2:=true;\n\n if flag1 or not flag2 then inc(ii);\n writeln(ot,' ',ii);\n\n\n\n1: close(output);\nend.\n"}, {"source_code": "var\nb,a:Array[-10..10000000]of longint;\ni:longint;\nmax,kol,ans,n,x,p:int64;\nbegin\nreadln(n);\nx:=n;\np:=trunc(sqrt(n));\ni:=2;\nans:=1;\nwhile (i<=p) do begin\n while (x mod i =0) do begin\n x:=x div i;\n inc(a[i]);\n if a[i]=1 then ans:=ans*i;\n end;\n inc(i);\nend;\nif x>1 then begin\n inc(a[x]);\n ans:=ans*x;\nend;\nwrite(Ans,' ');\nfor i:=1 to 2000 do if a[i]>0 then begin\nif a[i]>max then max:=a[i];\nend;\n\nx:=1;\nans:=0;\nwhile true do begin\n x:=x*2;\n inc(ans);\n if x>=max then break;\nend;\nfor i:=1 to 2000 do if (A[i]>0)and(a[i]<>x) then begin\n inc(ans);\n break;\nend;\nif (max=1)or(max=0) then write(0)\nelse\nwriteln(Ans);\n\nend."}, {"source_code": "uses math;\nvar x,c,n,i,j:longint;a,b:array[1..100000]of longint;\nfunction nd(n:longint):longint;//assign(f,'i.txt');reset(f);assign(g,'o.txt');rewrite(g);\nvar i:longint;\nbegin\nfor i:=2 to round(sqrt(n)) do if (n mod i)=0 then begin nd:=i;exit end;nd:=0\nend;\nfunction dd(var n:longint;c:longint):longint;\nvar i:longint;\nbegin\ni:=0;while true do if (n mod c)=0 then begin inc(i);n:=n div c end else break;dd:=i\nend;\nbegin\n//assign(f,'i.txt');reset(f);assign(g,'o.txt');rewrite(g);\nread(n);if n=1 then begin writeln(1,' ',0);exit end;\nwhile true do begin i:=nd(n);if i=0 then break;j:=dd(n,i);inc(c);a[c]:=i;b[c]:=j end;\nif n<>1 then begin inc(c);a[c]:=n;b[c]:=1 end;\n//for c:=1 to c do writeln(a[c],' ',b[c]);\nj:=0;for i:=1 to c do if b[i]>b[j] then j:=i;//writeln(j);\n//writeln(j);\ni:=1;while ii then x:=1;\nj:=1;for c:=1 to c do j:=j*a[c];\nwriteln(j,' ',round(log2(i))+x);\n//writeln(x,' ',i);\nend.\n"}, {"source_code": "var n,i,tmp,count:longint;\n tmp2:int64;\nbegin\n readln(n);\n if n mod 2=0 then\n tmp2:=2\n else tmp2:=1;\n tmp:=n;\n while tmp mod 2=0 do\n tmp:=tmp div 2;\n i:=3;\n while i<=trunc(sqrt(tmp)) do\n begin\n if tmp mod i=0 then\n begin\n tmp2:=tmp2*i;\n while tmp mod i=0 do\n tmp:=tmp div i;\n end;\n inc(i,2);\n end;\n //write(tmp2,' ');\n if tmp<>1 then tmp2:=tmp2*tmp;\n write(tmp2,' ');\n count:=0;\n while (tmp2 mod n<>0) do\n begin\n tmp2:=sqr(tmp2);\n inc(count);\n end;\n if tmp2>n then inc(count);\n write(count);\nend."}, {"source_code": "uses math;\nvar\n n:longint;\n kt: array[1..1000002] of boolean;\nprocedure sang(x:longint);\nvar\n i,j:longint;\nbegin\n fillchar(kt,sizeof(kt),true);\n kt[1]:=false;\n for i:=2 to trunc(sqrt(x)) do\n if(kt[i]=true) then\n begin\n j:=i*i;\n while (j<=x) do\n begin\n kt[j]:=false;\n j:=j+i;\n end;\n end;\nend;\nprocedure nguyenban();\nvar\n mu2: array[1..30] of longint;\n m,vt,i,mu,res:longint;\n kt2:boolean;\nbegin\n sang(n);\n mu2[1]:=2;m:=0;vt:=2;res:=1;kt2:=true;\n for i:=2 to 20 do mu2[i]:=mu2[i-1]*2;\n while(n>1) do\n begin\n mu:=0;\n if (kt[vt]=true) then\n begin\n if (n mod vt =0) then res:=res*vt;\n while (n mod vt = 0) do\n begin\n mu:=mu+1;n:=n div vt;\n end;\n end;\n if (((m<>0)and(mu<>0)) and (m <> mu)) then kt2:=false;\n m:=max(m,mu);\n vt:=vt+1;\n end;\n vt:=1;\n while (m>mu2[vt]) do vt:=vt+1;\n write(res,' ');\n if(m=1) then write(0)\n else\n if ((kt2=true) and (m=mu2[vt])) then write(vt)\n else\n write(vt+1);\nend;\nbegin\n read(n);\n if (n=1) then write('1 0')\n else\n nguyenban();\nend."}], "negative_code": [{"source_code": "var s:array[1..1000000] of integer;\n q:array[1..1000] of longint;\n n,m,l,i,res,res1:longint;\n\n\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a)\n else\n exit(b);\nend;\nfunction cal1:byte;\nvar ok:boolean; i,k,u:longint;\n begin\n ok:=true;\n for i:=2 to l do\n if s[q[i]]<>s[q[i-1]] then\n begin\n ok:=false;\n break;\n end;\n\n if ok then\n begin\n u:=s[q[1]];\n if u=1 then exit(0);\n k:=1;\n while k<=u do\n begin\n k:=k shl 1;\n if k=u then exit(0);\n\n end;\n end;\n exit(1);\n end;\n\n\nfunction cal2:longint;\nvar tmp,i,k:longint;\n begin\n tmp:=0;\n m:=0;\n res1:=1;\n for i:=1 to l do\n begin\n m:=max(m,s[q[i]]);\n res1:=res1*q[i];\n end;\n k:=1;\n while k1) then\n begin\n m:=max(m,n);\n if s[n]=0 then\n begin\n inc(l);\n q[l]:=n;\n end;\n inc(s[n]);\n end;\n\n res:=cal1+cal2;\n write(res1,' ',res);\nend.\n"}, {"source_code": "var f : text;\ni,j,n,dem,kq,k,l,max : longint;\nkt : array[1..1000000] of boolean;\na,b : array[1..1000] of longint;\nprocedure sang;\nbegin\n i := 1;\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(dem);\n a[dem] := i;\n for j := 1 to n div i do kt[i*j] := not(true);\n end;\n until i = round(sqrt(n))+1;\nend;\n\nbegin\n { assign(f,'MATH.INP');\n reset(f);}\n readln(n);\n { close(f);}\n { assign(f,'MATH.OUT');\n rewrite(f); }\n fillchar(kt,sizeof(kt),true);\n sang;\n kq := n;\n for i := 1 to dem do\n if n mod a[i] = 0 then\n begin\n inc(k);\n dem := 0;\n repeat\n n := n div a[i];\n inc(dem);\n until (n mod a[i] <> 0)or(n<=1);\n a[k] := a[i];\n b[k] := dem;\n end;\n n := kq;\n dem := 0;\n l := 1;\n repeat\n j := 0;\n l := 1;\n kq := 1;\n max := 0;\n for i := 1 to k do if b[i]<=1 then inc(j);\n if j=k then break;\n for i := 1 to k do\n if b[i] mod 2 = 0 then inc(max);\n if max <> k then\n begin\n for i := 1 to k do if b[i] > max then max := b[i];\n if max mod 2 = 1 then inc(max);\n end else max := 0;\n for i := 1 to k do\n begin\n if b[i] > 0 then\n begin\n if b[i] < max then\n begin\n repeat\n inc(b[i]);\n kq := kq * a[i];\n until b[i]>=max;\n l := 0;\n end;\n b[i] := b[i] div 2;\n end;\n end;\n if l=0 then inc(dem);\n n := round(sqrt(n*kq));\n inc(dem);\n until false;\n writeln(n,' ',dem);\n { close(f); }\nend.\n\n"}, {"source_code": "var f : text;\ni,j,n,dem,kq,k,l,max : longint;\nkt : array[1..10000000] of boolean;\na,b : array[1..1000000] of longint;\nprocedure sang;\nbegin\n i := 1;\n repeat\n inc(i);\n if kt[i] then\n begin\n inc(dem);\n a[dem] := i;\n for j := 1 to n div i do kt[i*j] := not(true);\n end;\n until i = trunc(sqrt(n))+1;\nend;\n\nbegin\n readln(n);\n fillchar(kt,sizeof(kt),true);\n if n>=2 then sang;\n kq := n;\n if n>=2 then\n begin\n for i := 1 to dem do\n if n mod a[i] = 0 then\n begin\n inc(k);\n dem := 0;\n repeat\n n := n div a[i];\n inc(dem);\n until (n mod a[i] <> 0)or(n<=1);\n a[k] := a[i];\n b[k] := dem;\n end;\n n := kq;\n dem := 0;\n l := 1;\n repeat\n j := 0;\n l := 1;\n kq := 1;\n max := 0;\n for i := 1 to k do if b[i]<=1 then inc(j);\n if j=k then break;\n for i := 1 to k do\n if b[i] mod 2 = 0 then inc(max);\n if max <> k then\n begin\n for i := 1 to k do if b[i] > max then max := b[i];\n if max mod 2 = 1 then inc(max);\n end else max := 0;\n for i := 1 to k do\n begin\n if b[i] > 0 then\n begin\n if b[i] < max then\n begin\n repeat\n inc(b[i]);\n kq := kq * a[i];\n until b[i]>=max;\n l := 0;\n end;\n b[i] := b[i] div 2;\n end;\n end;\n if l=0 then inc(dem);\n n := round(sqrt(n*kq));\n inc(dem);\n until false;\n writeln(n,' ',dem);\n end else\n begin\n if n = 1 then writeln(1,' ',0);\n if n = 0 then writeln(0,' ',0);\n end;\nend.\n\n"}, {"source_code": "var\nb,a:Array[-10..100000]of longint;\ni:longint;\nmax,kol,ans,n,x,p:int64;\nbegin\nreadln(n);\nx:=n;\np:=trunc(sqrt(n));\ni:=2;\nans:=1;\nwhile (i<=p) do begin\n while (x mod i =0) do begin\n x:=x div i;\n inc(a[i]);\n if a[i]=1 then ans:=ans*i;\n end;\n inc(i);\nend;\nif x>1 then begin\n inc(a[x]);\n ans:=ans*x;\nend;\nwrite(Ans,' ');\nfor i:=1 to 2000 do if a[i]>0 then begin\nif a[i]>max then max:=a[i];\nend;\n\nx:=1;\nans:=0;\nwhile true do begin\n x:=x*2;\n inc(ans);\n if x>=max then break;\nend;\nfor i:=1 to 2000 do if (A[i]>0)and(a[i]<>max) then begin\n inc(ans);\n break;\nend;\nif max=1 then write(0)\nelse\nwriteln(Ans);\n\nend."}, {"source_code": "var\nb,a:Array[-10..10000000]of longint;\ni:longint;\nmax,kol,ans,n,x,p:int64;\nbegin\nreadln(n);\nx:=n;\np:=trunc(sqrt(n));\ni:=2;\nans:=1;\nwhile (i<=p) do begin\n while (x mod i =0) do begin\n x:=x div i;\n inc(a[i]);\n if a[i]=1 then ans:=ans*i;\n end;\n inc(i);\nend;\nif x>1 then begin\n inc(a[x]);\n ans:=ans*x;\nend;\nwrite(Ans,' ');\nfor i:=1 to 2000 do if a[i]>0 then begin\nif a[i]>max then max:=a[i];\nend;\n\nx:=1;\nans:=0;\nwhile true do begin\n x:=x*2;\n inc(ans);\n if x>=max then break;\nend;\nfor i:=1 to 2000 do if (A[i]>0)and(a[i]<>x) then begin\n inc(ans);\n break;\nend;\nif max=1 then write(0)\nelse\nwriteln(Ans);\n\nend."}, {"source_code": "var\nb,a:Array[-10..100000]of int64;\ni:longint;\nmax,kol,ans,n,x,p:int64;\nbegin\nreadln(n);\nx:=n;\np:=trunc(sqrt(n));\ni:=2;\nans:=1;\nwhile (i<=p) do begin\n while (x mod i =0) do begin\n x:=x div i;\n inc(a[i]);\n if a[i]=1 then ans:=ans*i;\n end;\n inc(i);\nend;\nif x>1 then begin\n inc(a[x]);\n ans:=ans*x;\nend;\nwrite(Ans,' ');\nfor i:=1 to 2000 do if a[i]>0 then begin\nif a[i]>max then max:=a[i];\nend;\n\nx:=1;\nans:=0;\nwhile true do begin\n x:=x*2;\n inc(ans);\n if x>=max then break;\nend;\nfor i:=1 to 2000 do if (A[i]>0)and(a[i]<>max) then begin\n inc(ans);\n break;\nend;\nwriteln(Ans);\n\nend."}, {"source_code": "uses math;\nvar x,c,n,i,j:longint;a,b:array[1..100000]of longint;\nfunction nd(n:longint):longint;//assign(f,'i.txt');reset(f);assign(g,'o.txt');rewrite(g);\nvar i:longint;\nbegin\nfor i:=2 to round(sqrt(n)) do if (n mod i)=0 then begin nd:=i;exit end;nd:=0\nend;\nfunction dd(var n:longint;c:longint):longint;\nvar i:longint;\nbegin\ni:=0;while true do if (n mod c)=0 then begin inc(i);n:=n div c end else break;dd:=i\nend;\nbegin\n//assign(f,'i.txt');reset(f);assign(g,'o.txt');rewrite(g);\nread(n);while true do begin i:=nd(n);if i=0 then break;j:=dd(n,i);inc(c);a[c]:=i;b[c]:=j end;\nif n<>1 then begin inc(c);a[c]:=n;b[c]:=1 end;\n//for c:=1 to c do writeln(a[c],' ',b[c]);\nj:=0;for i:=1 to c do if b[i]>b[j] then j:=i;//writeln(j);\n//writeln(j);\ni:=1;while ii then x:=1;\nif odd(b[j]) then begin inc(x);inc(b[j]) end;\nj:=1;for c:=1 to c do j:=j*a[c];\nwriteln(j,' ',round(log2(i))+x);\nend.\n"}, {"source_code": "var n,i,tmp,count:longint;\n tmp2:int64;\nbegin\n readln(n);\n if n mod 2=0 then\n tmp2:=2\n else tmp2:=1;\n tmp:=n;\n while tmp mod 2=0 do\n tmp:=tmp div 2;\n i:=3;\n while i<=trunc(sqrt(tmp)) do\n begin\n if tmp mod i=0 then\n begin\n tmp2:=tmp2*i;\n while tmp mod i=0 do\n tmp:=tmp div i;\n end;\n inc(i,2);\n end;\n //write(tmp2,' ');\n if tmp<>1 then tmp2:=tmp2*tmp;\n write(tmp2,' ');\n count:=0;\n while tmp2n then inc(count);\n write(count);\nend."}, {"source_code": "var n,i,tmp,count:longint;\n tmp2:int64;\nbegin\n readln(n);\n if n mod 2=0 then\n tmp2:=2\n else tmp2:=1;\n tmp:=n;\n while tmp mod 2=0 do\n tmp:=tmp div 2;\n i:=3;\n while i<=trunc(sqrt(tmp)) do\n begin\n if tmp mod i=0 then\n begin\n tmp2:=tmp2*i;\n while tmp mod i=0 do\n tmp:=tmp div i;\n end;\n inc(i,2);\n end;\n write(tmp2,' ');\n if tmp<>1 then tmp2:=tmp2*tmp;\n count:=0;\n while tmp2n then inc(count);\n write(count);\nend."}, {"source_code": "uses math;\nvar\n n:longint;\n kt: array[1..1000002] of boolean;\nprocedure sang(x:longint);\nvar\n i,j:longint;\nbegin\n fillchar(kt,sizeof(kt),true);\n kt[1]:=false;\n for i:=2 to trunc(sqrt(x)) do\n if(kt[i]=true) then\n begin\n j:=i*i;\n while (j<=x) do\n begin\n kt[j]:=false;\n j:=j*i;\n end;\n end;\nend;\nprocedure nguyenban();\nvar\n mu2: array[1..30] of longint;\n m,vt,i,mu,res:longint;\nbegin\n sang(n);\n mu2[1]:=2;m:=0;vt:=2;res:=1;\n for i:=2 to 20 do mu2[i]:=mu2[i-1]*2;\n while(n>1) do\n begin\n mu:=0;\n if (kt[vt]=true) then\n begin\n if (n mod vt =0) then res:=res*vt;\n while (n mod vt = 0) do\n begin\n mu:=mu+1;n:=n div vt;\n end;\n end;\n m:=max(m,mu);\n vt:=vt+1;\n end;\n vt:=1;\n while (m>mu2[vt]) do vt:=vt+1;\n write(res,' ');\n if(m=1) then write(0)\n else write(vt+1);\nend;\nbegin\n read(n);\n nguyenban();\nend."}, {"source_code": "uses math;\nvar\n n:longint;\n kt: array[1..1000002] of boolean;\nprocedure sang(x:longint);\nvar\n i,j:longint;\nbegin\n fillchar(kt,sizeof(kt),true);\n kt[1]:=false;\n for i:=2 to trunc(sqrt(x)) do\n if(kt[i]=true) then\n begin\n j:=i*i;\n while (j<=x) do\n begin\n kt[j]:=false;\n j:=j*i;\n end;\n end;\nend;\nprocedure nguyenban();\nvar\n mu2: array[1..30] of longint;\n m,vt,i,mu,res:longint;\nbegin\n sang(n);\n mu2[1]:=2;m:=0;vt:=2;res:=1;\n for i:=2 to 20 do mu2[i]:=mu2[i-1]*2;\n while(n>1) do\n begin\n mu:=1;\n if (kt[vt]=true) then\n begin\n if (n mod vt =0) then res:=res*vt;\n while (n mod vt = 0) do\n begin\n mu:=mu+1;n:=n div vt;\n end;\n end;\n m:=max(m,mu);\n vt:=vt+1;\n end;\n vt:=1;\n while (m>mu2[vt]) do vt:=vt+1;\n write(res,' ');\n if(vt=1) then write(0)\n else write(vt+1);\nend;\nbegin\n read(n);\n nguyenban();\nend."}, {"source_code": "uses math;\nvar\n n:longint;\n kt: array[1..1000002] of boolean;\nprocedure sang(x:longint);\nvar\n i,j:longint;\nbegin\n fillchar(kt,sizeof(kt),true);\n kt[1]:=false;\n for i:=2 to trunc(sqrt(x)) do\n if(kt[i]=true) then\n begin\n j:=i*i;\n while (j<=x) do\n begin\n kt[j]:=false;\n j:=j*i;\n end;\n end;\nend;\nprocedure nguyenban();\nvar\n mu2: array[1..30] of longint;\n m,vt,i,mu,res:longint;\n kt2:boolean;\nbegin\n sang(n);\n mu2[1]:=2;m:=0;vt:=2;res:=1;kt2:=true;\n for i:=2 to 20 do mu2[i]:=mu2[i-1]*2;\n while(n>1) do\n begin\n mu:=0;\n if (kt[vt]=true) then\n begin\n if (n mod vt =0) then res:=res*vt;\n while (n mod vt = 0) do\n begin\n mu:=mu+1;n:=n div vt;\n end;\n end;\n if (((m<>0)and(mu<>0)) and (m <> mu)) then kt2:=false;\n m:=max(m,mu);\n vt:=vt+1;\n end;\n vt:=1;\n while (m>mu2[vt]) do vt:=vt+1;\n write(res,' ');\n if(m=1) then write(0)\n else\n if ((kt2=true) and (m=mu2[vt])) then write(vt)\n else\n write(vt+1);\nend;\nbegin\n read(n);\n nguyenban();\nend."}, {"source_code": "var n,x,k,pols:longint;\n f:boolean;\nbegin\n read(n);\n if n=1 then\n begin\n write(1,' ',0);\n halt;\n end;\n repeat\n x:=1;\n while round(sqrt(n*x))<>sqrt(n*x) do inc(x);\n pols:=n;\n n:=round(sqrt(n*x));\n f:=false;\n if n=pols then f:=true\n else\n begin\n if x>1 then\n k:=k+2;\n\n end;\n until f;\n write(n,' ',k);\nend."}, {"source_code": "var\n p:boolean;\n n,i,ans,s,t,max,f:longint;\n a:array[0..1000005] of longint;\nbegin\n read(n);\n t:=n;\n p:=false;\n if n=1 then begin writeln('1 0');halt;end;\n for i:=2 to n do\n if n mod i=0 then\n begin\n ans:=ans*i;\n while (n<>1) and (n mod i=0) do begin inc(a[i]);n:=n div i;end;\n end;\n for i:=1 to t do\n if (a[i]<>0) then begin if a[i]>max then max:=a[i];end;\n for i:=1 to t do\n if (a[i]<>0) and (a[i]<>max) then begin p:=true;inc(s);break;end;\n f:=1;\n while f1 do\nbegin\nif i mod 2 =1 then result+=1;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nop:=0;\nmin:=1;\nread(n);\nfor del:= 2 to round(sqr(n)) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if op1 do\nbegin\nif i mod 2 =1 then begin i+=1;bool:=true; end;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nst:=0;\nop:=0;\nmin:=1;\nread(n);\nfor del:= 2 to round(sqr(n)) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if (col<>colpred)and(colpred>0)and(col>0) then bool2:=true;if st0 then colpred:=col;\nif n1 do\nbegin\nif i mod 2 =1 then begin i+=1;bool:=true; end;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nst:=0;\nop:=0;\nmin:=1;\nread(n);\nfor del:= 2 to round(sqrt(n)) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if (col<>colpred)and(colpred>0)and(col>0) then bool2:=true;if st0 then colpred:=col;\nif n1 do\nbegin\nif i mod 2 =1 then begin i+=1;bool:=true; end;\ni:= i div 2;\nresult+=1;\nend;\nend;\nbegin\nst:=0;\nop:=0;\nmin:=1;\nread(n);\nfor del:= 2 to round(sqr(n)) do\nbegin\ncol:=0;\nwhile n mod del= 0 do\nbegin\nn:=n div del;\ncol+=1;\nend;\nif col>0 then begin min*=del;if col=1 then bool2:=true;if st0)) then st+=1;\n\nwrite(min,' ',st);\nend."}, {"source_code": "Program ILoveYou;\nVAR n,k,max,k2,min,p,i:int64;\nBegin\n\nReadln(n);\nmin:=0;\nmax:=0;\np:=1;\ni:=2;\nwhile (i <= n) do\nBegin\n\nk:=0;\nwhile ((n mod i) = 0) do\nBegin\nk:=k + 1;\nn:=n div i;\nend;\n\nif (k <> 0) or (k < min) then min:=k;\nif (k > max) then max:=k;\nif (k > 0) then p:=p*i;\ni:=i + 1;\n\nend;\n\nWrite(p,' ');\nif (max > 1) then\nBegin\n\np:=1;\nk2:=0;\nwhile (p < max) do\nBegin\np:=p*2;\nk2:=k2 + 1;\nend;\n\nif (p = max) then k:=0 else k:=1;\n\nif (p = max) or (max <> min) then k:=1;\n\n//Writeln(k,' ',max,' ',p);\n\nWriteln(k + k2);\n\nend else Writeln(0);\n\nReadln;\nEND."}, {"source_code": "Program ILoveYou;\nVAR n,k,max,k2,min,p,i:int64;\nBegin\n\nReadln(n);\nmin:=0;\nmax:=0;\np:=1;\ni:=2;\nwhile (i <= n) do\nBegin\n\nk:=0;\nwhile ((n mod i) = 0) do\nBegin\nk:=k + 1;\nn:=n div i;\nend;\n\nif (k <> 0) or (k < min) then min:=k;\nif (k > max) then max:=k;\nif (k > 0) then p:=p*i;\ni:=i + 1;\n\nend;\n\nWrite(p,' ');\nif (max > 1) then\nBegin\n\np:=1;\nk2:=0;\nwhile (p < max) do\nBegin\np:=p*2;\nk2:=k2 + 1;\nend;\n\nif (p = max) then k:=0 else k:=1;\n\nif (p <> max) or (max <> min) then k:=1;\n\n//Writeln(k,' ',max,' ',p);\n\nWriteln(k + k2);\n\nend else Writeln(0);\n\nReadln;\nEND."}, {"source_code": "Program ILoveYou;\nVAR n,k,max,k2,min,p,i:int64;\nBegin\n\nReadln(n);\nmin:=0;\nmax:=0;\np:=1;\ni:=2;\nwhile (i <= n) do\nBegin\n\nk:=0;\nwhile ((n mod i) = 0) do\nBegin\nk:=k + 1;\nn:=n div i;\nend;\n\nif (k <> 0) or (k < min) then min:=k;\nif (k > max) then max:=k;\nif (k > 0) then p:=p*i;\ni:=i + 1;\n\nend;\n\nWrite(p,' ');\nif (max > 1) then\nBegin\n\np:=1;\nk2:=0;\nwhile (p < max) do\nBegin\np:=p*2;\nk2:=k2 + 1;\nend;\n\nif (p = max) then k:=0 else k:=1;\n\nif (p = max) and (max <> min) then k:=1;\n\n//Writeln(k,' ',max,' ',p);\n\nWriteln(k + k2);\n\nend else Writeln(0);\n\nReadln;\nEND."}, {"source_code": "Program ILoveYou;\nVAR n,k,max,k2,min,p,i:int64;\nBegin\n\nReadln(n);\nmin:=0;\nmax:=0;\np:=1;\ni:=2;\nwhile (i <= n) do\nBegin\n\nk:=0;\nwhile ((n mod i) = 0) do\nBegin\nk:=k + 1;\nn:=n div i;\nend;\n\nif (k <> 0) or (k < min) then min:=k;\nif (k > max) then max:=k;\nif (k > 0) then p:=p*i;\ni:=i + 1;\n\nend;\n\nif (max = 1) then Writeln(p,' ',0) else\nBegin\n\nWrite(p,' ');\n\nif (min = max) then\nBegin\n\nWriteln((min div 2) + (min mod 2));\n\nend else\nBegin\n\nk:=1;\nif ((max mod 2) <> 0) then max:=max + 1;\n\nWriteln((max div 2) + 1);\n\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n modul={1000000007}998244353 ;\n besk=4000000000000000000;\n label 22,1,2,3,4;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas;\n v,ans,ccc,dist,alpha,phi:extended;\n koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..150] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;\n zzz:array[0..125000000] of byte;\n aaa,bbb,x1,x2:extended;\n pole:array[-10..2002,-10..2005] of char;\n ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;\n ddnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n ss1,ss2,ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of boolean;\n maxpr:array[0..nnn] of string;\n sss:array[-10..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]1 do\n begin\n for i:=2 to n do if n mod i=0 then\n begin inc(q); x[q]:=i; while n mod i=0 do begin inc(y[q]); n:=n div i; end; end;\n\n\n end;\n\n { for i:=1 to q do writeln(x[i],' ',y[i]);\n } ot:=1;\n for i:=1 to q do ot:=ot*x[i];\n pp:=0;\n for i:=1 to q do pp:=max(pp,y[i]);\n\n\n for i:=0 to 20 do if 1 shl i>=pp then begin ii:=i; goto 2; end;\n 2: for i:=1 to q do if y[i]<>y[1] then flag1:=true;\n for i:=0 to 10 do if y[1]=1 shl i then flag2:=true;\n\n if flag1 or not flag2 then inc(ii);\n writeln(ot,' ',ii);\n\n\n\n1: close(output);\nend.\n"}], "src_uid": "212cda3d9d611cd45332bb10b80f0b56"} {"source_code": "uses math;\nvar i,n,h,m,l,r,x,j,sum:longint;\nf:array[1..100]of longint;\nbegin\nreadln(n,h,m);\nfor i:=1 to n do f[i]:=h;\nfor i:=1 to m do\n begin\n readln(l,r,x);\n for j:=l to r do f[j]:=min(f[j],x);\n end;\nfor i:=1 to n do inc(sum,f[i]*f[i]);\nwriteln(sum);\nend.", "positive_code": [{"source_code": "Program Restrictions;\nuses math;\nType arr=array[0..57] of longint;\nvar f:arr; n,h,m,l,r,x:byte; i,j:longint; ans:int64;\nProcedure Profit;\nbegin for i:=1 to n do f[i]:=h;\n ans:=0;\n while m>0 do\n begin readln(l,r,x);\n for j:=l to r do f[j]:=min(f[j],x);\n dec(m);\n end;\n for i:=1 to n do ans:=ans+sqr(f[i]);\n writeln(ans);\nend;\nbegin //assign(input,'1162A.inp'); reset(input);\n //assign(output,'1162A.out'); rewrite(output);\n readln(n,h,m);\n Profit;\n //close(input); close(output);\nend."}, {"source_code": "var n,h,m,i,a,b,c,j,sum:longint;\nma:array[1..50] of integer;\nbegin\n readln(n,h,m);\n for i:=1 to n do\n ma[i]:=h;\n for i:=1 to m do\n begin\n readln(a,b,c);\n for j:=a to b do\n begin\n if cx then a[j]:=x;\n end;\n s:=0;\n for i:=1 to n do\n s:=s+a[i]*a[i];\n write(s);\n\nend."}, {"source_code": "uses math;\nvar i,n,h,m,l,r,x,j,sum:longint;\nf:array[1..100]of longint;\nbegin\nreadln(n,h,m);\nfor i:=1 to n do f[i]:=h;\nfor i:=1 to m do\n begin\n readln(l,r,x);\n for j:=l to r do f[j]:=min(f[j],x);\n end;\nfor i:=1 to n do inc(sum,f[i]*f[i]);\nwriteln(sum);\nend."}, {"source_code": "var\n n,m,h,x,y,z,i,j,s:longint;\n a:array[0..55] of longint;\nbegin\n readln(n,h,m);\n for i:=1 to 55 do a[i]:=h;\n for i:=1 to m do \n begin\n readln(x,y,z);\n for j:=x to y do \n if zk then t[j]:=k end; \nfor i:=1 to n do s:=s+sqr(t[i]);\nwrite(s)\nend.\n"}, {"source_code": "program p1;\nvar j,i,n,h,m,max:integer;\nl:array[1..10000] of integer;\nx:array[1..10000] of integer;\nr:array[1..10000] of integer;\na:array[1..10000] of integer;\nbegin\n max:=0;\n readln(n,h,m);\n\n for i:=1 to m do\n readln(l[i],r[i],x[i]);\n\n for i:=1 to n do\n a[i]:=h;\n\n for i:=1 to m do\n for j:=1 to n do\n if (l[i]<=j) and (r[i]>=j) then\n if a[j]>x[i] then\n a[j]:=x[i];\n\n for i:=1 to n do\n max:=max+a[i]*a[i];\n\n\n writeln(max);\n readln;\n\nend.\n\n"}, {"source_code": "uses math;\nvar\n n, h, m, ans, i, j, bound : longint;\n l, r, x : array[1..55] of longint;\n \nbegin\n readln(n, h, m);\n for i := 1 to m do readln(l[i], r[i], x[i]);\n ans := 0; \n for i := 1 to n do\n begin\n bound := 300;\n for j := 1 to m do\n if (i >= l[j]) and (i <= r[j]) then bound := min(bound, x[j]);\n if (bound = 300) then ans := ans + h * h\n else ans := ans + bound * bound;\n end;\n writeln(ans);\nend."}, {"source_code": "uses math;\nvar\n n,h,m,l,r,x,s,i,j:longint;\n a:array[1..50]of longint;\nbegin\n readln(n,h,m);\n for i:=1 to n do\n a[i]:=h;\n for i:=1 to m do\n begin\n readln(l,r,x);\n for j:=l to r do\n a[j]:=min(a[j],x);\n end;\n for i:=1 to n do\n s:=s+a[i]**2;\n writeln(s);\nend."}, {"source_code": "var min,n,h,m,sum,x,y,z,i,j:longint;\n a:array[1..1000] of longint;\n \nbegin\n readln(n,h,m);\n for i:=1 to n do a[i]:=h;\n min:=99999999;\n for i:=1 to m do\n begin\n readln(x,y,z);\n for j:=x to y do\n begin\n if zx then a[j]:=x;\n end;\n res:=0;\n for i:=1 to n do res:=res+a[i]**2;\n write(fo,res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "const maxn=100;\nvar l,r,x,hous:array[1..maxn]of longint;\n n,h,m,i,j,ans:longint;\n\n\nfunction min(a,b:longint):longint;\nbegin\n if a>b then exit(b) else exit(a);\nend;\n\n\nbegin\n readln(n,h,m);\n for i:=1 to m do\n read(l[i],r[i],x[i]);\n for i:=1 to n do\n hous[i]:=h;\n for i:=1 to m do\n for j:=l[i] to r[i] do\n hous[j]:=min(hous[j],x[i]);\n for i:=1 to n do\n ans:=ans+sqr(hous[i]);\n writeln(ans);\nend.\n"}, {"source_code": "uses math;\nvar n,h,m,l,r,x,i,j,s:longint;\n a:array[1..50]of longint;\nbegin\n readln(n,h,m);\n for i:=1 to 50 do\n a[i]:=h;\n for i:=1 to m do\n begin\n readln(l,r,x);\n for j:=l to r do\n a[j]:=min(a[j],x);\n end;\n for i:=1 to n do\n s:=s+sqr(a[i]);\n writeln(s);\nend."}, {"source_code": "uses math;\nvar\ng:array[0..55] of longint;\nn,m,a,b,c,d,e:longint;\nbegin\nreadln(n,a,m);\nfor b:=1 to n do g[b]:=a;\nfor a:=1 to m do\n begin\n readln(b,c,d);\n for e:=b to c do g[e]:=min(g[e],d);\n end;\nb:=0;\nfor a:=1 to n do b:=b+g[a]*g[a];\nwriteln(b);\nend."}, {"source_code": "uses math;//用math库是应为懒\nvar i,n,h,m,l,r,x,j,sum:longint;\nf:array[1..100]of longint;//f数组代表每个房子的高度\nbegin\nreadln(n,h,m);//输入\nfor i:=1 to n do f[i]:=h;//将房子的高度初始化为h(最大可建筑高度)\nfor i:=1 to m do\n begin\n readln(l,r,x);//这里根本不需要数组\n for j:=l to r do f[j]:=min(f[j],x);//求最小(min函数是math库中请求两数最小的一个函数)\n end;\nfor i:=1 to n do inc(sum,f[i]*f[i]);//sum加上利润\nwriteln(sum);//美丽输出\nend."}, {"source_code": "Var n , h , m , i , j , l , r , x : Byte;\n kq : Longint;\n A : Array [1..50] of Byte;\nbegin\nReadln(n , h , m);\nFor i := 1 to n do \nA[i] := h;\nFor i := 1 to m do\n Begin\n Readln(l , r , x);\n For j := l to r do\n If A[j] > x then A[j] := x;\n End;\nFor i := 1 to n do\nInc(kq , Sqr(A[i]));\nWriteln(kq);\nEnd."}, {"source_code": "var\n\tn, h, m, l, r, x, sum, y: integer;\n\ta: array[1..50] of integer;\n\t\nbegin\n\n\treadln(n, h, m);\n\t\n\tfor var i := 1 to n do\n\tbegin\n\t\ta[i] := h;\n\tend;\n\n\tfor var i := 1 to m do\n\tbegin\n\t\tread(l, r, x);\n\t\tfor var j := l to r do\n\t\tbegin\n\t\t\tif (a[j] > x) then\n\t\t\t\ta[j] := x;\n\t\tend;\n\tend;\n\t\n\tfor var i := 1 to n do\n\tbegin\n\t\tsum += sqr(a[i]);\n\tend;\n\t\n\twriteln(sum);\n\t\nend.\n"}, {"source_code": "var\n n,h,m:word;\n l,r,x:integer;\n sum:integer = 0;\n otvet:array [1..50] of integer;\nBEGIN\n readln (n,h,m);\n for var i:=1 to n do\n otvet[i]:=h;\n for var j:=1 to m do\n begin\n readln(l,r,x);\n for var k:=l to r do\n if otvet[k]>x then\n otvet[k]:=x;\n end;\n for var i:=1 to n do\n sum:=sum+sqr(otvet[i]);\n writeln(sum);\nEND."}, {"source_code": "Var\n n, h, m, l, r, x, Ans: Int64;\n a: Array [1..50] of Int64;\n\nBegin\n Read(n, h, m);\n For Var i := 1 to n do\n a[i] := h;\n For Var i := 1 to m do Begin\n Read(l, r, x);\n For Var j := l to r do\n If a[j] > x then\n a[j] := x\n End;\n For Var i := 1 to n do\n Ans += a[i]*a[i];\n Write(Ans)\nEnd."}, {"source_code": "Program ILoveYou;\nVAR n,h,m,i,s,j,x,y,max:int64; a:array[1..50] of int64;\nBegin\n\nReadln(n,h,m);\nfor i:=1 to n do\nBegin\na[i]:=h;\nend;\n\nfor i:=1 to m do\nBegin\nReadln(x,y,max);\nfor j:=x to y do\nBegin\nif (a[j] > max) then a[j]:=max;\nend;\nend;\n\ns:=0;\nfor i:=1 to n do\nBegin\n//Writeln(a[i]);\ns:=s + a[i]*a[i];\nend;\n\nWriteln(s);\n\nReadln;\nEND."}, {"source_code": "var\n n,h,m:1..50;\n i,j,p:integer;\n l,r,x:1..50;\n dom:array[1..50] of integer;\nbegin\n read(n,h,m);\n for i:=1 to n do\n dom[i]:=h;\n for i:=1 to m do\n begin\n read(l,r,x);\n for j:=l to r do\n begin\n if dom[j]>x then\n dom[j]:=x;\n end;\n end;\n for i:=1 to n do\n p:=p+(dom[i]*dom[i]);\n write(p);\nend."}, {"source_code": "uses\n Math;\n\nvar \n n, h, m, i, l, r, x, ans, j: longint;\n a: array[1..50] of longint;\nbegin\n read(n, h, m);\n for i := 1 to n do \n a[i] := h;\n for i := 1 to m do begin\n read(l, r, x);\n for j := l to r do\n a[j] := min(a[j], x);\n end;\n for i := 1 to n do\n ans := ans + a[i] * a[i];\n write(ans);\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008;\n nnn=4600000;\n besk=80000000000000000;\n modul=1000000007{998244353};\n\n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n matr=array[-10..200,-10..200] of int64;\n matr1=^matr;\n var sum,p01,hh,oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;\n istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n maxprefix,maxsuffix,prefix,suffix,minprefix,minsuffix,zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n otmat,amat,bmat,cmat:matr;\n zan1,zan2:array[-1000..200000,-2..26] of boolean;\n marked1,marked2:array[-2000..2000000] of boolean;\n gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;\n dd,ddr:array[-1..1502,-1..1502] of int64;\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n sss,ss,ss1,ss2:string;\n newstr,str:array[-1000..200000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n masmatr:array[-1..101,-1..101,-1..101] of int64;\n zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;\n str1,str2,dpos,ppos,mma,ma:array[-1000..200005,-1..30] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n sss12:string;ch,ch1,ch2:char;\n pr,heshh,numright,dr: array [-10..2060,-1..1600] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then begin fl:=false; break; end;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmin(left,right:longint):int64;\nbegin\n if left>=right then zaprmin:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),y[left]);\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]right[j]) then Inc(d) else begin Inc(osh); if visot[j]0 then Inc(sum,mine*mine);\nif d=m then Inc(sum,h*h);\nosh:=0;\nmine:=High(Integer);\nd:=0;\nend;\nWriteln(sum);\nreadln;\nend.\n"}, {"source_code": "program ZP1;\n\n{$APPTYPE CONSOLE}\n\n var x,y,z,s:array[1..50] of longint;\n i,j,n,h,m,k,kilk:longint;\nbegin\n readln(n,h,m);\n for i:=1 to m do\n readln(x[i],y[i],z[i]);\n for i:=1 to n do\n s[i]:=h;\n for i:=1 to m do\n begin\n for j:=x[i] to y[i] do\n if s[j]>z[i] then s[j]:=z[i]\n end;\n kilk:=0;\n for i:=1 to n do\n kilk:=kilk+s[i]*s[i];\n writeln(kilk)\nend.\n "}], "negative_code": [{"source_code": "type tabel=array[1..50] of longint;\nvar t:tabel;\n a,b,n,m,p,r,k,i,j:longint;\n s:int64;\nbegin\nread(n,r,m);\nfor i:=1 to n do t[i]:=r;\nfor i:=1 to m do begin\nread(a,b,k);\nfor j:=a to b do\nif t[j]>k then t[j]:=k else\nif t[j]x then\n dom[j]:=x;\n end;\n end;\n for i:=1 to n do\n p:=p+(dom[i]*dom[i]);\n write(p);\nend."}, {"source_code": "var\n n,h,m:1..50;\n i,j,p:integer;\n l,r,x:1..50;\n dom:array[1..50] of integer;\nbegin\n read(n,h,m);\n for i:=1 to m do\n dom[i]:=h;\n for i:=1 to m do\n begin\n read(l,r,x);\n for j:=l to r do\n dom[j]:=x;\n end;\n for i:=1 to n do\n p:=p+(dom[i]*dom[i]);\n write(p);\nend."}, {"source_code": "var\n n,h,m,i,j,p,l,r,x:integer;\n dom:array[1..50] of integer;\nbegin\n read(n,h,m);\n for i:=1 to m do\n dom[i]:=h;\n for i:=1 to m do\n begin\n read(l,r,x);\n for j:=l to r do\n dom[j]:=x;\n end;\n for i:=1 to n do\n p:=p+(dom[i]*dom[i]);\n write(p);\nend."}, {"source_code": "uses\n Math;\n\nvar \n n, h, m, i, l, r, x, ans, j: longint;\n a: array[1..50] of longint;\nbegin\n read(n, h, m);\n for i := 1 to m do \n a[i] := h;\n for i := 1 to m do begin\n read(l, r, x);\n for j := l to r do\n a[j] := min(a[j], x);\n end;\n for i := 1 to m do\n ans := ans + a[i] * a[i];\n write(ans);\nend."}, {"source_code": "program ZP1;\n\n{$APPTYPE CONSOLE}\n\n var x,y,z,s:array[1..50] of longint;\n i,j,n,h,m,k,kilk,max:longint;\nbegin\n readln(n,h,m);\n for i:=1 to m do\n readln(x[i],y[i],z[i]);\n for i:=1 to n do\n s[i]:=h;\n for i:=1 to m do\n begin\n for j:=x[i] to y[i] do\n s[j]:=z[i]\n end;\n kilk:=0;\n for i:=1 to n do\n kilk:=kilk+sqr(s[i]);\n writeln(kilk)\nend.\n "}], "src_uid": "f22b6dab443f63fb8d2d288b702f20ad"} {"source_code": "var\n i, j, k, n, a, b, maxx, maxy, minx, miny, s: longint;\n x, y: array[1..10] of longint;\n f:boolean;\n\n\n\n\nbegin\n n := 8;\n for i := 1 to n do read(x[i], y[i]);\n for k:=1 to n do\n for i := 1 to n do\n for j := 1 to n do \n if (y[i] < y[j]) or ((y[i] = y[j]) and (x[i] < x[j])) then \n begin a := y[i]; y[i] := y[j]; y[j] := a; b := x[i]; x[i] := x[j]; x[j] := b; end;\n\n f:=true;\n if \n (y[1]<>y[2]) or (y[2]<>y[3]) or (y[4]<>y[5]) or (y[6]<>y[7]) or (y[7]<>y[8])\nor(x[1]<>x[4]) or (x[4]<>x[6]) or (x[2]<>x[7]) or (x[3]<>x[5]) or (x[5]<>x[8]) \nthen f:=false;\n\n for i:=1 to n do\n for j:=1 to n do \n if i<>j then\n if (x[i]=x[j]) and (y[i]=y[j]) then f:=false; \n if f then writeln('respectable') else writeln('ugly');\n\nend.", "positive_code": [{"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+,O-}\nvar c:array[0..1000000,1..2] of longint;\n a,b:array[1..8,1..2] of longint;\n d,e,f,g:array[1..8] of longint;\n n,i,j,k,k1,k2,x,y:longint;\n\nprocedure swap(var a,b:longint);\nvar w:longint;\nbegin\n w:=a;\n a:=b;\n b:=w;\nend;\n\nbegin\n {assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n k:=0; k1:=0; k2:=0;\n fillchar(c,sizeof(c),0);\n for i:=1 to 8 do\n begin\n readln(a[i,1],a[i,2]);\n inc(c[a[i,1],1]);\n inc(c[a[i,2],2]);\n end;\n for i:=0 to 1000000 do\n begin\n if (c[i,1]>0) then\n begin\n inc(k1);\n d[k1]:=c[i,1];\n f[k1]:=i;\n end;\n if (c[i,2]>0) then\n begin\n inc(k2);\n e[k2]:=c[i,2];\n g[k2]:=i;\n end;\n end;\n\n if (d[1]=3) and (d[2]=2) and (d[3]=3) and (e[1]=3) and (e[2]=2) and (e[3]=3) then\n begin\n for i:=1 to 3 do\n for j:=1 to 3 do\n begin\n if (i=2) and (j=2) then continue;\n inc(k);\n b[k,1]:=f[i];\n b[k,2]:=g[j];\n end;\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n begin\n if (a[i,1]>a[j,1]) or ((a[i,1]=a[j,1]) and (a[i,2]>a[j,2])) then\n begin\n swap(a[i,1],a[j,1]);\n swap(a[i,2],a[j,2]);\n end;\n end;\n k:=0;\n for i:=1 to 8 do if (a[i,1]=b[i,1]) and (a[i,2]=b[i,2]) then inc(k);\n //for i:=1 to 8 do Writeln(a[i,1],' ',a[i,2],' ',b[i,1],' ',b[i,2]);\n if (k=8) then\n begin\n writeln('respectable');\n halt;\n end;\n end;\n writeln('ugly');\nend.\n\n\n"}, {"source_code": "var\n x,y : array[1..8]of longint;\n k,i,j : longint;\nbegin\n for i:=1 to 8 do readln(x[i],y[i]);\n for i:=1 to 8 do\n for j:=i+1 to 8 do\n begin\n if (x[j]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n y:=b[i];\n b[i]:=b[j];\n b[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l3 then exit(false);\n if vv<>3 then exit(false);\n for i:=1 to 3 do\n for j:=i+1 to 3 do if u[i]>u[j] then swap(u[i],u[j]);\n for i:=1 to 3 do\n for j:=i+1 to 3 do if v[i]>v[j] then swap(v[i],v[j]);\n for i:=1 to 3 do\n for j:=1 to 3 do if not((i=2) and (j=2)) then begin\n ok:=true;\n for k:=1 to 8 do if (x[k]=u[i]) and (y[k]=v[j]) then begin\n ok:=false;\n break\n end;\n if ok then exit(false);\n end;\n for i:=1 to 8 do if (x[i]=u[2]) and (y[i]=v[2]) then exit(false);\n exit(true);\nend;\nbegin\n if main then writeln('respectable') else writeln('ugly');\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,ans,xk,yk,cnt,z,x1,x2,x3,y1,y2,y3:longint;\n x,y:array[1..8] of integer;\n b:array[1..8] of boolean;\n\nbegin\n//assign(input,in_file); reset(input);\n//assign(output,out_file); rewrite(output);\n fillchar(x,sizeof(x),0);\n fillchar(y,sizeof(y),0);\n for i:=1 to 8 do readln(x[i],y[i]);\n\n for x1:=1 to 8 do\n begin\n for x2:=1 to 8 do\n begin\n for x3:=1 to 8 do\n begin\n\n if ((x1=x2)or(x2=x3)or(x1=x3)) then continue;\n if (x[x1]x[j]) or (x[i]=x[j])and(y[i]>y[j]) then begin\n z:=x[i]; x[i]:=x[j]; x[j]:=z;\n z:=y[i]; y[i]:=y[j]; y[j]:=z;\n end;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[3]<>x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8]) and\n (y[1]=y[4]) and (y[4]=y[6]) and (y[1]<>y[2]) and (y[2]=y[7]) and (y[2]<>y[3]) and (y[3]=y[5]) and (y[5]=y[8])\n then writeln('respectable')\n else writeln('ugly');\nend.\n"}, {"source_code": "program probb;\nvar\n\ta:array[1..8,1..2] of longint;\n\ti,j,k,n,x,y:longint;\nbegin\n\tfor i:=1 to 8 do begin\n\t\treadln(a[i,1],a[i,2]);\n\tend;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]=a[j,1])and(a[i,2]=a[j,2]) then begin writeln('ugly'); exit; end;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2])) then begin\n\t\t\t\tk:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=k;\n\t\t\t\tk:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=k;\n\t\t\tend;\n\tx:=a[4,1]; y:=a[2,2];\n\tif (a[1,1]<>a[2,1])or(a[2,1]<>a[3,1]) then begin writeln('ugly'); exit; end;\n\tif (a[4,1]<>x)or(x<>a[5,1]) then begin writeln('ugly'); exit; end;\n\tif (a[6,1]<>a[7,1])or(a[7,1]<>a[8,1]) then begin writeln('ugly'); exit; end;\n\t\n\tif (a[1,2]<>a[4,2])or(a[4,2]<>a[6,2]) then begin writeln('ugly'); exit; end;\n\tif (a[2,2]<>y)or(y<>a[7,2]) then begin writeln('ugly'); exit; end;\n\tif (a[3,2]<>a[5,2])or(a[5,2]<>a[8,2]) then begin writeln('ugly'); exit; end;\n\t\n\twriteln('respectable');\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\n const besk=100000000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar i,k,nn,n,i10,i100,n1,dl,kol,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,j,start,finish:longint;\nt,p,m1,pl,sum,p1,p2,m,k2,r,cc,ot,aa,bb,ka,kd,ll,rr,d1,d2,kolvyk,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,mnog,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndx,dy,b,a,c:array[-1000..200000] of int64;\n\nxx1,xx2,yy1,yy2,x1,x2,y1,y2,xx,yy,z1,z,x,y: array[-10..5000] of int64;\ngr1,gr: array[-50..1050,-50..1050] of int64;\na2,deg,marked:array[-100000..250000] of int64;\ndd:array[-10..5001,-10..5001] of longint;\n{ss:array[0..2000000] of char; }\nsss:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ur:int64):boolean; var p,i1,i2,i,j,k:longint; fl:boolean;\n begin\n fl:=false;\n for i:=1 to n do for j:=1 to m do if gr[i,j]>=ur then gr1[i,j]:=1 else gr1[i,j]:=0;\n for i1:=1 to n do for i2:=i1+1 to n do\n begin\n p:=0;\n for j:=1 to m do a[j]:=min(gr1[i1,j],gr1[i2,j]);\n for j:=1 to m do p:=p+a[j];\n if p>=2 then fl:=true;\n end;\n good:=fl;\n end;\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n\n for i:=1 to 8 do read(x[i],y[i]);\n for i:=1 to 8 do x[i]:=2000000*x[i]+y[i];\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do for j:=1 to 7 do if x[j]>x[j+1] then\n begin t:=x[j]; x[j]:=x[j+1]; x[j+1]:=t; end;\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do begin y[i]:=x[i] mod 2000000; x[i]:=x[i] div 2000000; end;\n\n{for i:=1 to 8 do writeln(x[i],' ',y[i]);\n}flag:=true;\nif (x[1]<>x[2])or(x[2]<>x[3]) then flag:=false;\nif (x[6]<>x[7])or(x[7]<>x[8]) then flag:=false;\nif x[4]<>x[5] then flag:=false;\n\nif (y[1]<>y[4])or(y[4]<>y[6]) then flag:=false;\nif (y[3]<>y[5])or(y[5]<>y[8]) then flag:=false;\nif y[2]<>y[7] then flag:=false;\n\nif (x[1]=x[4])or(x[4]=x[6]) then flag:=false;\nif (y[1]=y[2])or(y[2]=y[3]) then flag:=false;\n\nif flag then write('respectable' ) else write('ugly');\n\n 1: close(output);\n\nend.\n"}, {"source_code": "Var n,i,j,f:longint;\n x,y:array[1..8]of longint;\n Begin\n for i:=1 to 8 do\n Read(x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n f:=x[i];\n x[i]:=x[j];\n x[j]:=f;\n f:=y[i];\n y[i]:=y[j];\n y[j]:=f\n end;\n for i:=2 to 8 do\n if (x[i]=x[i-1])and(y[i]=y[i-1]) then begin Write('ugly');exit end;\n if (x[1]=x[2])and(x[2]=x[3])and\n (x[4]=x[5])and(x[6]=x[7])and(x[7]=x[8])and\n (y[1]=y[4])and(y[4]=y[6])and\n (y[2]=y[7])and(y[3]=y[5])and(y[5]=y[8])then Write('respectable')\n else Write('ugly')\n End."}, {"source_code": "\nvar i,j,b: longint;\n x,y: array[1..8] of longint;\n f: boolean;\nprocedure print;\nbegin\n write('ugly');\n halt(0);\nend;\n\nBEGIN\n //assign(input,'input.txt'); reset(input);\n for i:=1 to 8 do read(x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n b:=x[i]; x[i]:=x[j]; x[j]:=b;\n b:=y[i]; y[i]:=y[j]; y[j]:=b;\n end;\n for i:=2 to 3 do\n if x[i]<>x[i-1] then print;\n for i:=5 to 5 do\n if x[i]<>x[i-1] then print;\n for i:=7 to 8 do\n if x[i]<>x[i-1] then print;\n if (x[4]=x[3])or(x[6]=x[5]) then print;\n f:=(y[2]>y[1])and(y[2]y[6])and(y[7]y[1])and(y[3]=y[5])and(y[3]=y[8]);\n if not (f) then print;\n f:=(y[1]=y[4])and(y[1]=y[6]);\n if not (f) then print;\n write('respectable');\nEND."}, {"source_code": "Var i:longint;\nx,y:array[1..8] of longint;\nprocedure sort(n:longint);\nVar f:boolean;\ni,k:longint;\nbegin\n repeat\n f:=true;\n for i:=1 to n-1 do\n if (x[i]>x[i+1])or((x[i]=x[i+1])and(y[i]>y[i+1]))\n then begin\n f:=false;\n k:=x[i]; x[i]:=x[i+1]; x[i+1]:=k;\n k:=y[i]; y[i]:=y[i+1]; y[i+1]:=k;\n end;\n dec(n);\n until f;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n for i:=1 to 8 do\n read(x[i],y[i]);\n sort(8);\n if (x[1]=x[2])and(x[1]=x[3])and(x[4]=x[5])and(x[6]=x[7])and(x[6]=x[8])and(y[1]=y[4])and(y[1]=y[6])and(y[2]=y[7])and(y[3]=y[8])and(y[3]=y[5])and(x[1]3) or (dem2<>3) then writeln(g,'ugly') else\n begin\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n begin\n if x2[i]b do dec(r2);\n if l2<=r2 then\n begin\n sw(a[r2],a[l2]);\n sw(x[r2],x[l2]);\n sw(y[l2],y[r2]);\n inc(l2); dec(r2);\n end;\n end;\nif ly[1]);\nb5:=(y[2]=y[7])and(y[7]j then\n if (x[i]=x[j])and(y[i]=y[j]) then\n begin\n writeln('ugly');\n exit;\n end;\n for i:=1 to n do\n if f[x[i]]=false then\n begin\n f[x[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l1);\n x1[l1]:=x[i];\n end;\n tot:=0;\n fillchar(f,sizeof(f),false);\n for i:=1 to n do\n if f[y[i]]=false then\n begin\n f[y[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l2);\n y1[l2]:=y[i];\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if x1[j]>x1[i] then\n begin\n t:=x1[j];\n x1[j]:=x1[i];\n x1[i]:=t;\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if y1[j]>y1[i] then\n begin\n t:=y1[j];\n y1[j]:=y1[i];\n y1[i]:=t;\n end;\n tot:=0;\n for i:=1 to n do\n if (x[i]=x1[2]) then inc(tot);\n if tot<>2 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly')\n else writeln('respectable');\n end;\n { begin\n tot:=0;\n for i:=1 to n do\n if x[i]=x1[1] then\n inc(tot);\n if tot<>3 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly')\n else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[1]) then\n inc(tot);\n if tot<>3 then writeln('ugly') else writeln('respectable');\n end;\n end;\n end; }\nend.\n"}, {"source_code": "uses math;\ntype mass=array[1..8,1..2] of integer;\n maxx=array[1..12] of integer;\n majj=array[1..8] of boolean;\nvar d,x,y,kol,p,q,l1,r1,q1,q2,k,uk,min1,e,e1,n,kolv,res,r,l,b,c,max1:int64;s,s1,s2:string;i:integer;\n ch,ce:char;u:boolean;qq,w,o,g,a:int64;m,m3,t,h:mass;v,z,j:integer;m1:maxx;m2:majj;\nprocedure qsort(var A:mass);\n procedure sort(l,r:integer);\n var i,j,x,w,x1,y: integer;\n begin\n i := l;\n j := r;\n w:=l+random(r-l);\n x := A[w,1];\n x1:=a[w,2];\n repeat\n while (A[i,1] < x) or ((a[i,1]=x) and (a[i,2]x1)) do dec(j);\n if not (i>j) then\n begin\n y := A[i,1];\n A[i,1] := A[j,1];\n A[j,1] := y;\n y:=a[i,2];\n a[i,2]:=a[j,2];\n a[j,2]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if l < j then sort(l,j);\n if i < r then sort(i,r);\n end;\nbegin\n sort(1,8);\nend;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n for i:=1 to 8 do\n readln(m[i,1],m[i,2]);\n qsort(m);\n a:=0;\n i:=1;\n for i:=2 to 8 do\n if m[i,1]<>m[i-1,1]\n then inc(a);\n for i:=2 to 8 do\n if (m[i,1]=m[i-1,1]) and (m[i,2]=m[i-1,2])\n then Begin\n writeln('ugly');\n halt(0);\n end;\n if a<>2\n then Begin\n writeln('ugly');\n halt(0);\n end;\n m1[1]:=1;\n a:=1;\n for j:=2 to 8 do\n Begin\n if m[j,1]<>m[j-1,1]\n then inc(a);\n inc(m1[a]);\n end;\n if not ((m1[1]=3) and (m1[2]=2) and (m1[3]=3))\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n for z:=1 to 8 do\n Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=3\n then Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n inc(a);\n m1[a]:=m[j,2];\n end;\n break;\n end;\n end;\n fillchar(m2,sizeof(m2),true);\n for z:=1 to 8 do\n Begin\n if m2[z]=false\n then continue;\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=2\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a,2);\n m2[j]:=false;\n end;\n end\n else if a=3\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a);\n m2[j]:=false;\n end;\n end\n else Begin\n writeln('ugly');\n halt(0);\n end;\n end;\n writeln('respectable');\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n x,y:array[1..8] of longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n n:=8;\n for i:=1 to n do\n readln(f,x[i],y[i]);\n close(f);\nEnd;\nProcedure Trao(var x,y:longint);\nVar temp:longint;\nBegin\n temp:=x;\n x:=y;\n y:=temp;\nEnd;\nProcedure Sort;\nVar i,j:longint;\nBegin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (y[i]x[j])) then\n begin\n trao(x[i],x[j]);\n trao(y[i],y[j]);\n end;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n if ((x[1]=x[4]) and (x[4]=x[6])) and (x[2]=x[7]) and ((x[3]=x[5]) and (x[5]=x[8])) and ((y[1]=y[2]) and (y[2]=y[3])) and (y[4]=y[5]) and ((y[6]=y[7]) and (y[7]=y[8])) and (y[1]<>y[4]) and (y[4]<>y[6]) then\n write(f,'respectable')\n else\n write(f,'ugly');\n close(f);\nEnd;\n\nBegin\n nhap;\n sort;\n xuat;\nEnd."}, {"source_code": "const n = 8;\nvar i,j, ans: LongInt;\nx,y: array[1..8] of LongInt;\nres: Boolean;\nbegin\n for i:=1 to n do Readln(x[i],y[i]);\n \n for i:=1 to n do\n begin\n for j:=1 to n do\n if i<>j then\n if (x[i]=x[j]) and (y[i]=y[j]) then\n begin\n Writeln('ugly');\n halt(0);\n end;\n end;\n \n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n if (x[j]x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8])\n then res:=true;\n \n \n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n if (y[j]y[4]) and (y[4]=y[5]) and (y[5]<>y[6]) and (y[6]=y[7]) and (y[7]=y[8]) then\n Writeln('respectable') else Writeln('ugly');\nend."}, {"source_code": "type qw = record\n x,y : longint;\nend;\n\nvar a : array[1..8] of qw;\n i,jx,jy : longint;\n\nprocedure sortx(l,r : longint);\n var i,j,xt : longint;\n tmp : qw;\n begin\n i := l;\n j := r;\n xt := a[(l+r) div 2].x;\n repeat\n while a[i].x < xt do inc(i);\n while a[j].x > xt do dec(j);\n if i <= j then begin\n tmp := a[i];\n a[i] := a[j];\n a[j] := tmp;\n inc(i);\n dec(j);\n end;\n until i > j;\n if l < j then sortx(l,j);\n if i < r then sortx(i,r);\n end;\n\nprocedure sorty(l,r : longint);\n var i,j,xt : longint;\n tmp : qw;\n begin\n i := l;\n j := r;\n xt := a[(l+r) div 2].y;\n repeat\n while a[i].y < xt do inc(i);\n while a[j].y > xt do dec(j);\n if i <= j then begin\n tmp := a[i];\n a[i] := a[j];\n a[j] := tmp;\n inc(i);\n dec(j);\n end;\n until i > j;\n if l < j then sorty(l,j);\n if i < r then sorty(i,r);\n end;\n\n\nprocedure thoat;\n begin\n writeln('ugly');\n halt;\n end;\n\nbegin\n for i := 1 to 8 do\n readln(a[i].x,a[i].y);\n /////////////////////////////\n sortx(1,8);\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[1].x then inc(jx);\n if jx <> 3 then thoat;\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[4].x then inc(jx);\n if jx <> 2 then thoat;\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[6].x then inc(jx);\n if jx <> 3 then thoat;\n /////////////////////////\n for i := 1 to 7 do\n if (a[i].x = a[i+1].x) and (a[i].y = a[i+1].y) then thoat;\n\n /////////////////////////\n sorty(1,8);\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[1].y then inc(jy);\n if jy <> 3 then thoat;\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[4].y then inc(jy);\n if jy <> 2 then thoat;\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[6].y then inc(jy);\n if jy <> 3 then thoat;\n ///////////////////////\n for i := 1 to 7 do\n if (a[i].x = a[i+1].x) and (a[i].y = a[i+1].y) then thoat;\n //////////////////////\n writeln('respectable');\nend."}, {"source_code": "Var x,y,xx,yy,b:array [0..100] of longint;\n i,t,tt,k1,k2,j,p:longint;\n f1,f2,f:array [0..2000000] of boolean;\n\n procedure sort(l,r: longint);\n var\n i,j,xx,yy,z: longint;\n begin\n i:=l;\n j:=r;\n xx:=x[(l+r) div 2];\n z:=y[(l+r) div 2];\n repeat\n while (x[i]j) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[p].x)or((z.x=a[p].x)and(z.y>a[p].y)) do\n inc(p);\n while (a[q].x>z.x)or((a[q].x=z.x)and(a[q].y>z.y)) do\n dec(q);\n if p<=q then begin\n temp:=a[p];\n a[p]:=a[q];\n a[q]:=temp;\n inc(p);\n dec(q);\n end;\n end;\n if l x[i] then x1 := x[i];\n if y1 > y[i] then y1 := y[i];\n\n if (x[i] <> x3) and (x[i] <> x1) then x2 := x[i];\n if (y[i] <> y3) and (y[i] <> y1) then y2 := y[i]; }\n end;\n close (f);\n End;\n\n{=====================================================================}\n{=====================================================================}\n\nprocedure GhiKQ (x: boolean);\n Begin\n assign (f, fo); rewrite (f);\n if x then write (f, 'respectable')\n else write (f, 'ugly');\n close (f);\n halt;\n End;\n\n{---------------------------------------------------------------------}\n\nprocedure Swap (var a, b: longint);\n var\n t: longint;\n Begin\n t := a; a := b; b := t;\n End;\n\n{--------------------}\n\nprocedure BubbleSort;\n var\n i, j: integer;\n Begin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if x[i] > x[j]\n then begin\n Swap (x[i], x[j]);\n Swap (y[i], y[j]);\n end\n else if (x[i] = x[j]) and (y[i] > y[j])\n then begin\n Swap (x[i], x[j]);\n Swap (y[i], y[j]);\n end;\n End;\n\n\n{---------------------------------}\n\nprocedure EPS;\n Begin\n BubbleSort;\n\n x1 := x[1]; x2 := x[4]; x3 := x[8];\n y1 := y[1]; y2 := y[2]; y3 := y[3];\n\n if (x1=x2) or (x1=x3) or (x2=x3) or (y1=y2) or (y1=y3) or (y2=y3)\n then GhiKQ (false);\n\n if (x[1] <> x1) or (x[2] <> x1) or (x[3] <> x1) then GhiKQ (false);\n if (x[4] <> x2) or (x[5] <> x2) then GhiKQ (false);\n if (x[6] <> x3) or (x[7] <> x3) or (x[8] <> x3) then GhiKQ (false);\n\n if (y[1] <> y1) or (y[2] <> y2) or (y[3] <> y3) then GhiKQ (false);\n if (y[4] <> y1) or (y[5] <> y3) then GhiKQ (false);\n if (y[6] <> y1) or (y[7] <> y2) or (y[8] <> y3) then GhiKQ (false);\n\n GhiKQ (true);\n\n End;\n\n{=====================================================================}\n{=====================================================================}\n\nBEGIN\n DocFile;\n EPS;\nEND."}, {"source_code": "var \nx,y:array [1..8] of longint;\ni,j,p:longint;\nbegin\nfor i:=1 to 8 do\n readln (x[i],y[i]);\nfor i:=1 to 8 do\n for j:=i+1 to 8 do\n begin\n if (x[j]a[j+1] then begin temp:=a[j];a[j]:=a[j+1];a[j+1]:=temp;end;\n for i:=1 to bb-1 do\n for j:=bb-1 downto i do\n if b[j]>b[j+1] then begin temp:=b[j];b[j]:=b[j+1];b[j+1]:=temp;end;\n p:=0;\n for i:=1 to 8 do\n if (a[2]=x[i])and(b[2]=y[i]) then p:=1;\n for i:=1 to 8 do\n for j:=i+1 to 8 do\n if (x[i]=x[j])and(y[i]=y[j]) then p:=1;\n end;\n if p=1 then writeln('ugly') else writeln('respectable');\nend.\n"}, {"source_code": "type te = record\n x, y : longint;\n end;\nvar a : array[1..8] of te;\n i, j, d1, d2, t : longint;\n flag : boolean;\n xi : array[0..3] of longint;\n yi : array[0..3] of longint;\nprocedure swap(var x, y : te);\n var tmp : te;\n begin\n tmp := x;\n x := y;\n y := tmp;\n end;\nbegin\n flag := true;\n for i := 1 to 8 do\n begin\n readln(a[i].x, a[i].y);\n end;\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].x > a[j].x then\n swap(a[i], a[j]);\n for i := 1 to 7 do\n begin\n for j := 1 to 8 do\n if i <> j then\n if (a[i].x = a[j].x) and (a[i].y = a[j].y) then\n flag := false;\n end;\n d1 := 0; d2 := 0;\n t := -1;\n for i := 1 to 6 do\n If (a[i].x = a[i+1].x) and (a[i].x = a[i+2].x) and\n (a[i].x <> t) then\n begin\n t := a[i].x;\n inc(d1);\n end;\n xi[0] := -1;\n j := 1;\n for i := 1 to 8 do\n if (a[i].x <> xi[j-1]) then\n if j <= 3 then\n begin\n xi[j] := a[i].x;\n inc(j);\n end\n else flag := false;\n // ----------------------------------------\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].y > a[j].y then\n swap(a[i], a[j]);\n t := -1;\n for i := 1 to 6 do\n if (a[i].y = a[i+1].y) and (a[i].y = a[i+2].y) and\n (a[i].y <> t) then\n begin\n t := a[i].y;\n inc(d2);\n end;\n j := 1;\n yi[0] := -1;\n for i := 1 to 8 do\n if (a[i].y <> yi[j-1]) then\n if j <= 3 then\n begin\n yi[j] := a[i].y;\n inc(j);\n end\n else flag := false;\n for i := 1 to 8 do\n if (a[i].x = xi[2]) and (a[i].y = yi[2]) then\n flag := false;\n\n if (d1 = 2) and (d2 = 2) and (flag) then\n writeln('respectable')\n else writeln('ugly');\nend.\n"}, {"source_code": "var\n vis1,vis2:array[0..1000000] of boolean;\n a,b,x,y:array[0..10] of longint;\n i,j,t:longint;\nfunction min(a,b:longint):longint;\nbegin\n if ab then exit(a) else exit(b);\nend;\nfunction judge(xx,yy:longint):boolean;\nvar\n i:longint;\nbegin\n if (xx=a[2]) and (yy=b[2]) then exit(true);\n for i:=1 to 8 do if (x[i]=xx) and (y[i]=yy) then exit(true);\n exit(false);\nend;\nbegin\n for i:=1 to 8 do begin\n readln(x[i],y[i]);\n if not vis1[x[i]] then begin\n inc(a[0]);\n a[a[0]]:=x[i];\n vis1[x[i]]:=true;\n end;\n if not vis2[y[i]] then begin\n inc(b[0]);\n b[b[0]]:=y[i];\n vis2[y[i]]:=true;\n end;\n end;\n if (a[0]<>3) or (b[0]<>3) then begin writeln('ugly'); exit; end;\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n end;\n for i:=1 to 3 do\n for j:=i+1 to 3 do\n if b[i]>b[j] then begin\n t:=b[i]; b[i]:=b[j]; b[j]:=t;\n end;\n for i:=1 to 3 do\n for j:=1 to 3 do begin\n if not judge(a[i],b[j]) then begin\n writeln('ugly');\n exit;\n end;\n end;\n writeln('respectable');\nend."}, {"source_code": "const finp='';\n fout='';\nvar x,y:array[1..8] of longint;\nprocedure nhap;\nvar i,j,t:longint;\n f:text;\nbegin\n assign(f,finp);\n reset(f);\n For i:=1 to 8 do readln(f,x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (y[i]>y[j])or((y[i]=y[j])and(x[i]>x[j])) then\n begin\n t:=x[i];\n x[i]:=x[j];\n x[j]:=t;\n t:=y[i];\n y[i]:=y[j];\n y[j]:=t;\n end;\n close(f);\nend;\nprocedure xuly;\nvar f:text;\nbegin\n assign(f,fout);\n rewrite(f);\n if (x[2]=x[7])and(y[1]=y[2]) then\n if (y[2]=y[3])and(y[5]=y[4]) then\n if (x[1]=x[4])and(x[4]=x[6]) then\n if (y[1]<>y[6])and(x[1]<>x[3]) then\n if (y[6]=y[7])and(y[7]=y[8]) then\n if (x[3]=x[5])and(x[5]=x[8]) then\n if (x[6]<>x[8])and(y[3]<>y[8]) then\n begin\n writeln(f,'respectable');\n close(F);\n exit;\n end;\n writeln(f,'ugly');\n close(F);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "const fn = '';\n gx = '';\nvar x,y : array[0..8] of longint;\nprocedure nhap;\nvar f : text;\n i : longint;\nbegin\n assign(f,fn); reset(f);\n for i := 1 to 8 do\n readln(f,x[i],y[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,k : longint;\nbegin\n x[0] := 0; y[0] := 0;\n for j := 2 to 8 do\n begin\n i := j;\n while x[i] < x[i-1] do\n begin\n k := x[i]; x[i] := x[i-1]; x[i-1] := k;\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n while (x[i] = x[i-1]) and (y[i] < y[i-1]) do\n begin\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n end;\nend;\nfunction xuli : boolean;\nvar i : longint;\nbegin\n sort;\n for i := 2 to 3 do if x[i] <> x[i-1] then exit(false);\n for i := 2 to 3 do if y[i] <= y[i-1] then exit(false);\n if (x[4] <> x[5]) or (x[4] <= x[1]) then exit(false);\n if (y[4] <> y[1]) or (y[5] <> y[3]) then exit(false);\n for i := 6 to 8 do\n if y[i] <> y[i-5] then exit(false);\n if x[6] <= x[5] then exit(false);\n for i := 7 to 8 do\n if x[i] <> x[i-1] then exit(false);\n exit(true);\nend;\nprocedure xuat;\nvar g : text;\nbegin\n assign(g,gx); rewrite(g);\n if xuli = true then writeln(g,'respectable')\n else writeln(g,'ugly');\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "type rec=record x,y:longint;end;\nvar\n a:array[1..8] of rec;\n b:array[1..3,1..3] of boolean;\n n,i,j,k:longint;\n t:rec;\nfunction yes:string;\nvar\n i,j,k:longint;\n p:array[1..6] of rec;\nbegin\n fillchar(b,sizeof(b),0);\n b[2,2]:=true;\n p[1].x:=a[1].x;p[1].y:=1;\n p[2].x:=a[4].x;p[2].y:=2;\n p[3].x:=a[6].x;p[3].y:=3;\n p[4].x:=a[1].y;p[4].y:=1;\n p[5].x:=a[2].y;p[5].y:=2;\n p[6].x:=a[3].y;p[6].y:=3;\n for i:=1 to 2 do\n if p[i].x=p[i+1].x then exit('ugly');\n for i:=4 to 5 do\n if p[i].x=p[i+1].x then exit('ugly');\n for i:=1 to 8 do\n begin\n for j:=1 to 3 do if a[i].x=p[j].x then break;\n for k:=4 to 6 do if a[i].y=p[k].x then break;\n b[j,k-3]:=true;\n end;\n for i:=1 to 3 do\n for j:=1 to 3 do\n if not b[i,j] then exit('ugly');\n exit('respectable');\nend;\nbegin\n for i:=1 to 8 do readln(a[i].x,a[i].y);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (a[i].x>a[j].x)or(a[i].x=a[j].x)and(a[i].y>a[j].y) then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n end;\n writeln(yes);\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar x,y:array[1..8] of longint;\nprocedure nhap;\nvar i,j,t:longint;\n f:text;\nbegin\n assign(f,finp);\n reset(f);\n For i:=1 to 8 do readln(f,x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (y[i]>y[j])or((y[i]=y[j])and(x[i]>x[j])) then\n begin\n t:=x[i];\n x[i]:=x[j];\n x[j]:=t;\n t:=y[i];\n y[i]:=y[j];\n y[j]:=t;\n end;\n close(f);\nend;\nprocedure xuly;\nvar f:text;\nbegin\n assign(f,fout);\n rewrite(f);\n if (x[2]=x[7])and(y[1]=y[2]) then\n if (y[2]=y[3])and(y[5]=y[4]) then\n if (x[1]=x[4])and(x[4]=x[6]) then\n if (y[1]<>y[6])and(x[1]<>x[3]) then\n if (y[6]=y[7])and(y[7]=y[8]) then\n if (x[3]=x[5])and(x[5]=x[8]) then\n if (x[6]<>x[8])and(y[3]<>y[8]) then\n begin\n writeln(f,'respectable');\n close(F);\n exit;\n end;\n writeln(f,'ugly');\n close(F);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "var\n n,m,p,xx,xx2,yy,yy2,k,l,i,j,max,min,z,sum,res,x2,y2,b,r,g,q,e : longint;\n a,d : array [0..1000000] of longint;\n s : array [0..1000,0..1000] of longint;\n ans: int64;\n h : boolean;\n\nbegin\n for i:=1 to 8 do\n read(a[i],d[i]);\n for i:=1 to 8 do\n for j:=i+1 to 8 do begin\n if (a[j]x[j])or (x[i]=x[j])and(y[i]>y[j]) then\n begin\n swap(x[i],x[j]);\n swap(y[i],y[j]);\n end;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[3]<>x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8]) and\n (y[1]=y[4]) and (y[4]=y[6]) and (y[1]<>y[2]) and (y[2]=y[7]) and (y[2]<>y[3]) and (y[3]=y[5]) and (y[5]=y[8])\n then writeln('respectable')\n else writeln('ugly');\n end."}, {"source_code": "const\n fi = '';\nvar\n a : array[1..2,1..8] of longint;\n i,j,p,x,y,z : longint;\n b : array[0..1000000] of longint;\n\nprocedure loi;\nbegin\n writeln('ugly');\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n for i := 1 to 8 do\n readln(a[1,i],a[2,i]);\n close(input);\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] > a[1,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] = a[1,j]) and (a[2,i] > a[2,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i]=a[1,j]) and (a[2,i]=a[2,j]) then loi;\n\n for i := 1 to 8 do\n inc(b[a[1,i]]);\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n fillchar(b,sizeof(b),0);\n for i := 1 to 8 do\n inc(b[a[2,i]]);\n x := 0;\n y := 0;\n z := 0;\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n writeln('respectable');\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n x2,y2,x,y:array[1..8] of longint;\n a:array[1..3,1..3] of boolean;\n dem,dem2,i,j:longint;\n vt,vt2:integer;\n stop:boolean;\n\n procedure swap(var a,b:longint);\n var t:longint;\n begin\n t:=a;\n a:=b;\n b:=t;\n end;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n dem:=0;\n dem2:=0;\n for i:=1 to 8 do\n begin\n readln(F,x[i],y[i]);\n stop:=false;\n for j:=1 to dem do\n if x[i]=x2[j] then\n begin\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem:=dem+1;\n x2[dem]:=x[i];\n end;\n stop:=false;\n for j:=1 to dem2 do\n if y[i]=y2[j] then\n begin\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem2:=dem2+1;\n y2[dem2]:=y[i];\n end;\n end;\n close(f);\n\n if (dem<>3) or (dem2<>3) then writeln(g,'ugly') else\n begin\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n begin\n if x2[i]x[4])and(x[5]=x[4])and(x[5]<>x[6])and(x[6]=x[7])and(x[7]=x[8])\n then begin\n for i:=1 to 2 do \n begin\n mini:=i;\n for j:=i+1 to 3 do \n if (y[mini]>y[j]) then mini:=j;\n cc:=y[mini]; y[mini]:=y[i]; y[i]:=cc;\n end;\n \n if (y[4]>y[5]) then begin\n cc:=y[4]; y[4]:=y[5]; y[5]:=cc; \n end; \n for i:=6 to 7 do \n begin\n mini:=i;\n for j:=i+1 to 8 do \n if (y[mini]>y[j]) then mini:=j;\n cc:=y[mini]; y[mini]:=y[i]; y[i]:=cc;\n end; \n if (y[1]<>y[2])and(y[1]<>y[3])and(y[1]=y[4])and(y[4]=y[6])and(y[2]=y[7])and(y[3]=y[5])and(y[5]=y[8]) then writeln('respectable')\n else writeln('ugly'); \n end\n else writeln('ugly'); \n//close(input); close(output);\nend."}, {"source_code": "var\n x,y:array[1..8] of longint; i:longint; flag:boolean;\n\n\nprocedure sort;\nvar i,j,w:longint;\nbegin\n for i:=1 to 8 do\n for j:=i+1 to 8 do\n if (x[i]>x[j]) or ((x[i]=x[j]) and (y[i]>y[j])) then\n begin\n w:=x[i]; x[i]:=x[j]; x[j]:=w;\n w:=y[i]; y[i]:=y[j]; y[j]:=w;\n end;\nend;\n\n\nbegin\n for i:=1 to 8 do readln(x[i],y[i]);\n sort;\n flag:=true;\n if (x[1]<>x[2]) or (x[2]<>x[3]) or (x[3]=x[4]) or (x[4]<>x[5]) or (x[5]=x[6]) or (x[6]<>x[7]) or (x[7]<>x[8]) then flag:=false;\n if (y[1]=y[2]) or (y[2]=y[3]) or (y[1]<>y[4]) or (y[1]<>y[6]) or (y[2]<>y[7]) or (y[3]<>y[5]) or (y[5]<>y[8]) then flag:=false;\n if flag then writeln('respectable') else writeln('ugly');\nend."}, {"source_code": "Const fi = '';\n\nVar x, y : array[0..10] of longint;\n i, n, j, dem, p: longint;\n f : array[0..1000005] of boolean;\n\nProcedure swap(var x, y : longint);\n Var tmp : longint;\n Begin\n tmp := x;\n x := y;\n y := tmp;\n End;\n\nProcedure ghisai;\n Begin\n writeln('ugly');\n halt;\n End;\n\nBegin\n assign(input,fi); reset(input);\n n := 8;\n for i:=1 to n do\n readln(x[i],y[i]);\n close(input);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (x[i] > x[j]) or ((x[i] = x[j]) and (y[i] > y[j])) then begin\n swap(x[i],x[j]);\n swap(y[i],y[j]);\n end;\n x[0] := -1;\n y[0] := -1;\n for i:=1 to n do\n if x[i] <> x[i-1] then dem := dem+1;\n if dem <> 3 then ghisai;\n dem := 0;\n for i:=1 to n do\n if (y[i] <> y[i-1]) and (f[y[i]] = false) then begin\n dem := dem+1;\n f[y[i]] := true;\n end;\n if dem <> 3 then ghisai;\n /////////\n p := x[1];\n for i:=2 to 3 do\n if x[i] <> p then ghisai;\n if x[5] <> x[4] then ghisai;\n p := x[6];\n for i:=7 to 8 do\n if x[i] <> p then ghisai;\n if (y[1] = y[2]) or (y[2] = y[3]) or (y[1] = y[3]) then ghisai;\n if (y[1] <> y[4]) or (y[3] <> y[5]) or (y[1] <> y[6]) or (y[2] <> y[7])\n or (y[3] <> y[8]) then ghisai;\n writeln('respectable');\n\nEnd.\n"}, {"source_code": "var n,i,j,t,tt:longint;\nff:boolean;\na,b,f,f1:array [0..10] of longint;\nc,c1:array [0..2000000] of boolean;\nbegin\n//assign(input,'bdj.in');reset(input);\n//assign(output,'bdj.out');rewrite(output);\nn:=8;\nfor i:=1 to n do\n begin\n readln(a[i],b[i]);\n c[a[i]]:=true;c1[b[i]]:=true;\n end;\nfor i:=0 to 2000000 do\n if c[i] then\n begin\n inc(t);f[t]:=i;\n end;\nfor i:=0 to 2000000 do\n if c1[i] then\n begin\n inc(tt);f1[tt]:=i;\n end;\nfor i:=1 to n do\n if (a[i]=f[2]) and (b[i]=f1[2]) then\n ff:=true;\nfor i:=1 to n do\n for j:=i-1 downto 1 do\n if (a[i]=a[j]) and (b[i]=b[j]) then\n ff:=true;\nif (t<>3) or ff or (tt<>3) then writeln('ugly')\nelse writeln('respectable');\nclose(input);close(output);\nend.\n"}, {"source_code": "Const fi='';\n fo='';\nvar i,j,b: longint;\n x,y: array[1..8] of longint;\n f: boolean; fg,g:Text;\nprocedure print;\nbegin\n write(g,'ugly');\n Close(g);\n halt(0);\nend;\n\nBEGIN\n assign(fg,fi); reset(fg);\n assign(g,fo); rewrite(g);\n for i:=1 to 8 do readln(fg,x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n b:=x[i]; x[i]:=x[j]; x[j]:=b;\n b:=y[i]; y[i]:=y[j]; y[j]:=b;\n end;\n for i:=2 to 3 do if x[i]<>x[i-1] then print;\n for i:=5 to 5 do if x[i]<>x[i-1] then print;\n for i:=7 to 8 do if x[i]<>x[i-1] then print;\n if (x[4]=x[3])or(x[6]=x[5]) then print;\n f:=(y[2]>y[1])and(y[2]y[6])and(y[7]y[1])and(y[3]=y[5])and(y[3]=y[8]);\n if not (f) then print;\n f:=(y[1]=y[4])and(y[1]=y[6]);\n if not (f) then print;\n write(g,'respectable');\n Close(fg);Close(g);\nEND.\n\n"}, {"source_code": "Program cf194bb;\nVar\n i,j,temp:Longint;\n x,y:Array[0..10] Of Longint;\nBegin\n For i:=1 To 8 Do Readln(x[i],y[i]);\n For i:=1 To 8 Do\n For j:=i+1 To 8 Do Begin\n If (x[j]j) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lx[j] then\n begin\n t1:=x[i];\n x[i]:=x[j];\n x[j]:=t1;\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n f:=(x[1]=x[2]) and (x[1]=x[3])\n and (x[4]=x[5])\n and (x[6]=x[7]) and (x[6]=x[8])\n and (x[1]<>x[4]) and (x[4]<>x[6]);\n if f then\n begin\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if y[i]>y[j] then\n begin\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n\n if y[4]>y[5] then\n begin\n t2:=y[4];\n y[4]:=y[5];\n y[5]:=t2;\n end;\n\n for i:=6 to 7 do\n for j:=i+1 to 8 do\n if y[i]>y[j] then\n begin\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n f:= (y[1]=y[4]) and (y[1]=y[6])\n and (y[2]=y[7])\n and (y[3]=y[5]) and (y[3]=y[8])\n and (y[1]<>y[2]) and (y[2]<>y[3]);\n end;\n if f then writeln ('respectable')\n else writeln('ugly');\n readln;\nend.\n"}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k, q, w, j: longint;\n a: array [1..8, 1..2] of longint;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n\n end;\n if l *l1 = 4 then\n begin\n if ((b < d) and (b > c) )or((b < c)and(b > d)) then q:=b;\n if ((c < d) and (c > b) )or((c < b)and(c > d)) then q:=c;\n if ((d < b) and (d > c) )or((d < c)and(d > b)) then q:=d;\n if ((x < z) and (x > y) )or((x < y)and(x > z)) then w:=x;\n if ((y < z) and (y > x) )or((y < x)and(y > z)) then w:=y;\n if ((z < x) and (z > y) )or((z < y)and(z > x)) then w:=z;\n end\n else k:= 1;\n for i:=1 to 8 do\n begin\n\n if (a[i, 1] = q) and(a[i, 2]= w) then k:= 1;\n for j := 1 to 8 do\n if(i <>j)and(a[i, 1]= a[j, 1])and(a[i, 2] = a[j, 2]) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var\n a,b:array[1..8]of longint;\n x,y:array[0..1000000]of longint;\n j,xx,yy,i:longint;\n\n\n procedure No;\n begin\n writeln('ugly');\n halt;\n end;\n\n\nbegin\n// assign(input,'a.in');reset(input);\n for i:=1 to 8 do\n begin\n readln(a[i],b[i]);\n inc(x[a[i]]);\n inc(y[b[i]]);\n end;\n for i:=1 to 8 do for j:=i+1 to 8 do if (a[i]=a[j]) and (b[i]=b[j]) then No;\n for i:=0 to 1000000 do\n begin\n if (x[i]=1) or (x[i]>3) or (y[i]=1) or (y[i]>3) then No;\n if ((x[i]=2) and (xx<>1)) or ((y[i]=2) and (yy<>1)) then No;\n if x[i]=3 then inc(xx);\n if y[i]=3 then inc(yy);\n end;\n if (xx=2) and (yy=2) then writeln('respectable');\nend.\n\n"}, {"source_code": "program pasha;\nVar n,i,j,f:longint;\n x,y:array[1..8]of longint;\n Begin\n for i:=1 to 8 do\n Read(x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n f:=x[i];\n x[i]:=x[j];\n x[j]:=f;\n f:=y[i];\n y[i]:=y[j];\n y[j]:=f\n end;\n for i:=2 to 8 do\n if (x[i]=x[i-1])and(y[i]=y[i-1]) then begin Write('ugly');exit end;\n if (x[1]=x[2])and(x[2]=x[3])and\n (x[4]=x[5])and(x[6]=x[7])and(x[7]=x[8])and\n (y[1]=y[4])and(y[4]=y[6])and\n (y[2]=y[7])and(y[3]=y[5])and(y[5]=y[8])then Write('respectable')\n else Write('ugly')\n End."}, {"source_code": "var\ti, j, t,m: longInt;\n\tx, y: array[ 1..8 ] of longInt;\n\nbegin\n\tfor i := 1 to 8 do\n\t\treadln( x[i], y[i] );\n\t\t\n\tfor i := 1 to 8 do\n\t\tfor j := i + 1 to 8 do\n\t\t\tif ( x[j] < x[i] ) or ( ( x[j] = x[i] ) and ( y[j] < y[i] ) ) then\n\t\t\tbegin\n\t\t\t\tt := x[i];\n\t\t\t\tx[i] := x[j];\n\t\t\t\tx[j] := t;\n\t\t\t\t\n\t\t\t\tt := y[i];\n\t\t\t\ty[i] := y[j];\n\t\t\t\ty[j] := t;\n\t\t\tend;\n\t\t\t\n\tif ( x[1] = x[2] ) and ( x[2] = x[3] ) and ( x[3] < x[4] ) and ( x[4] = x[5] ) and ( x[5] < x[6] ) and ( x[6] = x[7] ) and ( x[7] = x[8] ) and ( y[1] < y[2] ) and ( y[2] < y[3] ) and ( y[4] = y[1] ) and ( y[5] = y[3] ) and ( y[6] = y[1] ) and ( y[7] = y[2] ) and ( y[8] = y[3] ) then\n\t\twriteln( 'respectable' )\n\telse\n\t\twriteln( 'ugly' );\nend."}, {"source_code": "program Project334b;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n X:array[1..8] of Integer;\n Y:array[1..8] of Integer;\n povt:array[1..8] of Byte;\n max,min,k,i,j:Integer;\n begin\n i:=1;\n while i<=8 do\n begin\n read(x[i]);\n Read(y[i]); readln;\n Inc(i);\n end;\n \n for i:=1 to 7 do\n begin\n min:=x[i];\n max:=y[i];\n for j:=i+1 to 8 do\n if min>x[j] then\n begin\n min:=x[j];\n max:=y[j];\n k:=j;\n x[k]:=x[i];\n x[i]:=min;\n y[k]:=y[i];\n y[i]:=max;\n end;\n\n end;\n k:=1;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[4]=x[5]) and (x[6]=x[7]) and (x[7]=x[8]) and (x[1]<>x[4]) and (x[1]<>x[8]) and (x[4]<>x[8]) then\n begin\n k:=0;\n\n max:=y[1];\n min:=y[1];\n for i:=1 to 5 do\n begin\n if y[i]max\n then max:=y[i];\n for j:=6 to 8 do\n if y[i]=y[j] then\n begin\n Inc(povt[i]);\n inc(povt[j]);\n end;\n end;\n\n for i:=1 to 5 do\n if povt[i]<>1\n then k:=1;\n for I:=6 to 8 do\n if povt[i]>2 then k:=1;\n if k=0 then\n begin\n if (y[4]=max) and (y[5]=min) then k:=0 else\n if (y[5]=max) and (y[4]=min) then k:=0 else k:=1;\n end;\n end;\n if k=0 then write('respectable') else write('ugly') ;\nend.\n\n"}, {"source_code": "const fn = '';\n gx = '';\nvar x,y : array[0..8] of longint;\nprocedure nhap;\nvar f : text;\n i : longint;\nbegin\n assign(f,fn); reset(f);\n for i := 1 to 8 do\n readln(f,x[i],y[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,k : longint;\nbegin\n x[0] := 0; y[0] := 0;\n for j := 2 to 8 do\n begin\n i := j;\n while x[i] < x[i-1] do\n begin\n k := x[i]; x[i] := x[i-1]; x[i-1] := k;\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n while (x[i] = x[i-1]) and (y[i] < y[i-1]) do\n begin\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n end;\nend;\nfunction xuli : boolean;\nvar i : longint;\nbegin\n sort;\n for i := 2 to 3 do if x[i] <> x[i-1] then exit(false);\n for i := 2 to 3 do if y[i] <= y[i-1] then exit(false);\n if (x[4] <> x[5]) or (x[4] <= x[1]) then exit(false);\n if (y[4] <> y[1]) or (y[5] <> y[3]) then exit(false);\n for i := 6 to 8 do\n if y[i] <> y[i-5] then exit(false);\n if x[6] <= x[5] then exit(false);\n for i := 7 to 8 do\n if x[i] <> x[i-1] then exit(false);\n exit(true);\nend;\nprocedure xuat;\nvar g : text;\nbegin\n assign(g,gx); rewrite(g);\n if xuli = true then writeln(g,'respectable')\n else writeln(g,'ugly');\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "var\n n, i, j, sum, k1, k2, tmp, x1, y1: longint;\n x, y, xx, yy: array[1..8] of longint;\n a: array[1..3, 1..3] of byte;\n fl1, fl2: boolean;\n\nbegin\n k1 := 0;\n k2 := 0;\n for i := 1 to 8 do begin\n read(xx[i], yy[i]);\n fl1 := false;\n fl2 := false;\n for j := 1 to k1 do\n if x[j] = xx[i] then\n fl1 := true;\n for j := 1 to k2 do\n if y[j] = yy[i] then\n fl2 := true;\n\n if not fl1 then begin\n inc(k1);\n x[k1] := xx[i];\n end;\n\n if not fl2 then begin\n inc(k2);\n y[k2] := yy[i];\n end;\n end;\n\n if (k1 <> 3) or (k2 <> 3) then begin\n write('ugly');\n halt;\n end;\n\n for i := 1 to 2 do\n for j := 1 to 3 - i do begin\n if x[j] > x[j + 1] then begin\n tmp := x[j];\n x[j] := x[j + 1];\n x[j + 1] := tmp;\n end;\n if y[j] > y[j + 1] then begin\n tmp := y[j];\n y[j] := y[j + 1];\n y[j + 1] := tmp;\n end;\n end;\n\n fillchar(a, sizeof(a), 0);\n for i := 1 to 8 do begin\n for j := 1 to 3 do\n if xx[i] = x[j] then\n x1 := j;\n for j := 1 to 3 do\n if yy[i] = y[j] then\n y1 := j;\n a[x1][y1] := 1;\n end;\n\n sum := 0;\n for i := 1 to 3 do\n for j := 1 to 3 do\n inc(sum, a[i][j]);\n\n if (sum <> 8) or (a[2][2] = 1) then begin\n write('ugly');\n halt;\n end;\n\n write('respectable');\n\nend.\n\n"}, {"source_code": "Program EightPoinSets;\nConst fi='';\n fo='';\nvar f1,f2:text;\n min,mid,max,i,nho,j,b,c,min2,max2,mid2:longint;\n kq:boolean;\n a,t:array[1..3] of longint;\n d:array[1..2,1..8]of longint;\n e,f:array[0..1000000] of boolean;\n\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n nho:=1;\n kq:=true;\n fillchar(d,sizeof(d),false);\n a[1]:=-1;\n a[2]:=-1;\n a[3]:=-1;\n t[1]:=-1;\n t[2]:=-1;\n t[3]:=-1;\n for i:=1 to 8 do\n begin\n read(f1,b,c);\n d[1,i]:=b;\n d[2,i]:=c;\n for j:=1 to i-1 do\n begin\n if (d[1,j]=d[1,i])and(d[2,j]=d[2,i]) then kq:=false;\n end;\n for j:=1 to 3 do\n begin\n if (a[j]=-1)and (e[b]=false) then\n begin\n a[j]:=b;\n e[b]:=true;\n break;\n end;\n end;\n if (e[b]=false) then kq:=false;\n for j:=1 to 3 do\n begin\n if (t[j]=-1)and (f[c]=false) then\n begin\n t[j]:=c;\n f[c]:=true;\n break;\n end;\n end;\n if (f[c]=false) then kq:=false;\n\n end;\n if (a[1]=-1) or (a[2]=-1) or (a[3]=-1) or (t[1]=-1)or (t[1]=-1) or (t[1]=-1) then kq:=false;\n if kq=false then\n begin\n writeln(f2,'ugly');\n end;\n if kq=true then\n begin\n if (a[1]x[j1]) and (x[j1]<>x[k1]) Then Begin\n For i2:=1 To 6 Do\n For j2:=i2+1 To 7 Do\n For k2:=j2+1 To 8 Do\n If (y[i2]<>y[j2]) and (y[j2]<>y[k2]) Then Begin\n For i:=1 To 8 Do\n For j:=1 To 8 Do used[i,j]:=false;\n a[1]:=x[i1];\n a[2]:=x[j1];\n a[3]:=x[k1];\n For i:=1 To 2 Do\n For j:=i+1 To 3 Do\n If a[i]>a[j] Then Begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n End;\n b[1]:=y[i2];\n b[2]:=y[j2];\n b[3]:=y[k2];\n For i:=1 To 2 Do\n For j:=i+1 To 3 DO\n If b[i]>b[j] Then Begin\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n End;\n f:=1;\n k:=0;\n For i:=1 To 8 Do\n For i3:=1 To 3 Do\n For j3:=1 To 3 Do\n If (x[i]=a[i3]) and (y[i]=b[j3]) Then Begin\n If ((i3=2) and (j3=2)) or (used[i3,j3]) Then f:=0;\n used[i3,j3]:=true;\n k:=k+1;\n End;\n If (f=1) and (k=8) Then Begin\n Write('respectable');\n Halt;\n End;\n End;\n End;\n Write('ugly');\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar mas: array [1..2, 1..8] of Integer;\n x,y,x1,x2, i,j,t : Integer;\n f: Boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n f := False;\n for i:=1 to 8 do Readln(mas[1,i], mas[2,i]);\n for i:=8 downto 2 do\n for j:=1 to i-1 do\n if (mas[1,j]>mas[1,j+1]) or ((mas[1,j]=mas[1,j+1])and(mas[2,j]>mas[2,j+1])) then\n begin\n t:=mas[1,j]; mas[1, j]:=mas[1,j+1]; mas[1,j+1]:=t;\n t:=mas[2,j]; mas[2, j]:=mas[2,j+1]; mas[2,j+1]:=t;\n end;\n\n // for i:=1 to 8 do\n // writeln(mas[1,i], ' ', mas[2,i]);\n\n if (mas[1,1]=mas[1,2])and(mas[1,1]=mas[1,3])and(mas[1,1] a[j].x then\n swap(a[i], a[j]);\n d1 := 0; d2 := 0;\n t := -1;\n for i := 1 to 6 do\n If (a[i].x = a[i+1].x) and (a[i].x = a[i+2].x) and\n (a[i].x <> t) then\n begin\n t := a[i].x;\n inc(d1);\n end;\n xi[0] := -1;\n j := 1;\n for i := 1 to 8 do\n if (a[i].x <> xi[j-1]) and (j <= 3) then\n begin\n xi[j] := a[i].x;\n inc(j);\n end;\n // ----------------------------------------\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].y > a[j].y then\n swap(a[i], a[j]);\n t := -1;\n for i := 1 to 6 do\n if (a[i].y = a[i+1].y) and (a[i].y = a[i+2].y) and\n (a[i].y <> t) then\n begin\n t := a[i].y;\n inc(d2);\n end;\n j := 1;\n yi[0] := -1;\n for i := 1 to 8 do\n if (a[i].y <> yi[j-1]) and (j <= 3) then\n begin\n yi[j] := a[i].y;\n inc(j);\n end;\n flag := true;\n for i := 1 to 8 do\n if (a[i].x = xi[2]) and (a[i].y = yi[2]) then\n flag := false;\n if (d1 = 2) and (d2 = 2) and (flag) then\n writeln('respectable')\n else writeln('ugly');\nend.\n"}, {"source_code": "type te = record\n x, y : longint;\n end;\nvar a : array[1..8] of te;\n i, j, d1, d2, t : longint;\n flag : boolean;\n xi : array[0..3] of longint;\n yi : array[0..3] of longint;\nprocedure swap(var x, y : te);\n var tmp : te;\n begin\n tmp := x;\n x := y;\n y := tmp;\n end;\nbegin\n flag := true;\n for i := 1 to 8 do\n begin\n readln(a[i].x, a[i].y);\n end;\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].x > a[j].x then\n swap(a[i], a[j]);\n for i := 1 to 7 do\n begin\n for j := 1 to 8 do\n if i <> j then\n if (a[i].x = a[j].x) and (a[i].y = a[j].y) then\n flag := false;\n end;\n d1 := 0; d2 := 0;\n t := -1;\n for i := 1 to 6 do\n If (a[i].x = a[i+1].x) and (a[i].x = a[i+2].x) and\n (a[i].x <> t) then\n begin\n t := a[i].x;\n inc(d1);\n end;\n xi[0] := -1;\n j := 1;\n for i := 1 to 8 do\n if (a[i].x <> xi[j-1]) and (j <= 3) then\n begin\n xi[j] := a[i].x;\n inc(j);\n end;\n // ----------------------------------------\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].y > a[j].y then\n swap(a[i], a[j]);\n t := -1;\n for i := 1 to 6 do\n if (a[i].y = a[i+1].y) and (a[i].y = a[i+2].y) and\n (a[i].y <> t) then\n begin\n t := a[i].y;\n inc(d2);\n end;\n j := 1;\n yi[0] := -1;\n for i := 1 to 8 do\n if (a[i].y <> yi[j-1]) and (j <= 3) then\n begin\n yi[j] := a[i].y;\n inc(j);\n end;\n for i := 1 to 8 do\n if (a[i].x = xi[2]) and (a[i].y = yi[2]) then\n flag := false;\n\n if (d1 = 2) and (d2 = 2) and (flag) then\n writeln('respectable')\n else writeln('ugly');\nend.\n"}, {"source_code": "type te = record\n x, y : longint;\n end;\nvar a : array[1..8] of te;\n i, j, d1, d2, t : longint;\n flag : boolean;\n xi : array[0..3] of longint;\n yi : array[0..3] of longint;\nprocedure swap(var x, y : te);\n var tmp : te;\n begin\n tmp := x;\n x := y;\n y := tmp;\n end;\nbegin\n flag := true;\n for i := 1 to 8 do\n begin\n readln(a[i].x, a[i].y);\n end;\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].x > a[j].x then\n swap(a[i], a[j]);\n for i := 1 to 7 do\n if (a[i].x = a[i+1].x) and (a[i].y = a[i+1].y) then\n flag := false;\n d1 := 0; d2 := 0;\n t := -1;\n for i := 1 to 6 do\n If (a[i].x = a[i+1].x) and (a[i].x = a[i+2].x) and\n (a[i].x <> t) then\n begin\n t := a[i].x;\n inc(d1);\n end;\n xi[0] := -1;\n j := 1;\n for i := 1 to 8 do\n if (a[i].x <> xi[j-1]) and (j <= 3) then\n begin\n xi[j] := a[i].x;\n inc(j);\n end;\n // ----------------------------------------\n for i := 1 to 7 do\n for j := i + 1 to 8 do\n if a[i].y > a[j].y then\n swap(a[i], a[j]);\n t := -1;\n for i := 1 to 6 do\n if (a[i].y = a[i+1].y) and (a[i].y = a[i+2].y) and\n (a[i].y <> t) then\n begin\n t := a[i].y;\n inc(d2);\n end;\n j := 1;\n yi[0] := -1;\n for i := 1 to 8 do\n if (a[i].y <> yi[j-1]) and (j <= 3) then\n begin\n yi[j] := a[i].y;\n inc(j);\n end;\n for i := 1 to 8 do\n if (a[i].x = xi[2]) and (a[i].y = yi[2]) then\n flag := false;\n\n if (d1 = 2) and (d2 = 2) and (flag) then\n writeln('respectable')\n else writeln('ugly');\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar x,y:array[1..8] of longint;\nprocedure nhap;\nvar i,j,t:longint;\n f:text;\nbegin\n assign(f,finp);\n reset(f);\n For i:=1 to 8 do readln(f,x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (y[i]>y[j])or((y[i]=y[j])and(x[i]>x[j])) then\n begin\n t:=x[i];\n x[i]:=x[j];\n x[j]:=t;\n t:=y[i];\n y[i]:=y[j];\n y[j]:=t;\n end;\n close(f);\nend;\nprocedure xuly;\nvar f:text;\nbegin\n assign(f,fout);\n rewrite(f);\n if (x[1]+x[3]=x[2]*2)and(y[1]=y[2])and(y[2]=y[3])and(y[1]+y[6]=y[4]*2)and(x[1]=x[4])and(x[4]=x[6])and(y[1]<>y[6])and(x[1]<>x[3]) then\n if (x[6]+x[8]=x[7]*2)and(y[6]=y[7])and(y[7]=y[8])and(y[3]+y[8]=y[5]*2)and(x[3]=x[5])and(x[5]=x[8])and(x[6]<>x[8])and(y[3]<>y[8]) then\n begin\n writeln(f,'respectable');\n close(F);\n exit;\n end;\n writeln(f,'ugly');\n close(F);\nend;\nbegin\n nhap;\n xuly;\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar x,y:array[1..8] of longint;\nprocedure nhap;\nvar i,j,t:longint;\n f:text;\nbegin\n assign(f,finp);\n reset(f);\n For i:=1 to 8 do readln(f,x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (y[i]>y[j])or((y[i]=y[j])and(x[i]>x[j])) then\n begin\n t:=x[i];\n x[i]:=x[j];\n x[j]:=t;\n t:=y[i];\n y[i]:=y[j];\n y[j]:=t;\n end;\n close(f);\nend;\nprocedure xuly;\nvar f:text;\nbegin\n assign(f,fout);\n rewrite(f);\n if (x[1]+x[3]=x[2]*2)and(y[1]=y[2])and(y[2]=y[3])and(y[1]+y[6]=y[4]*2)and(x[1]=x[4])and(x[4]=x[6]) then\n if (x[6]+x[8]=x[7]*2)and(y[6]=y[7])and(y[7]=y[8])and(y[3]+y[8]=y[5]*2)and(x[3]=x[5])and(x[5]=x[8]) then\n begin\n writeln(f,'respectable');\n close(F);\n exit;\n end;\n writeln(f,'ugly');\n close(F);\nend;\nbegin\n nhap;\n xuly;\nend."}, {"source_code": "var j,x,y,n,i:longint;\n a,b:array[0..1000000]of longint;\n q,w:array[0..8]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\n begin\n n:=8;\n for i:=1 to n do\n begin\n read(q[i],w[i]);\n inc(a[q[i]]);\n inc(b[w[i]]);\n end;\n for i:=0 to 1000000 do\n if(a[i]>0)then inc(x);\n for i:=0 to 1000000 do\n if(b[i]>0)then inc(y);\n if(x<>3)or(y<>3)then\n begin\n writeln('ugly');\n exit;\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if(q[i]>q[j])or((q[i]=q[j])and(w[i]>w[j]))then\n begin\n swap(q[i],q[j]);\n swap(w[i],w[j]);\n end;\n if(q[1]=q[2])and(q[2]=a[3])and(q[3]<>q[4])and(q[4]=q[5])and(q[5]<>q[6])and(q[6]=q[7])and(q[7]=q[8])and\n (w[1]=w[4])and(w[4]=w[6])and(w[1]<>w[2])and(w[2]=w[7])and(w[2]<>w[3])and(w[3]=w[5])and(w[5]=w[8])then writeln('respectable') else writeln('ugly');\n end."}, {"source_code": "var j,n,i:longint;\n x,y:array[0..8]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\n begin\n n:=8;\n for i:=1 to n do\n read(x[i],y[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if(x[i]>x[j])or (x[i]=x[j])and(y[i]>y[j]) then\n begin\n swap(x[i],y[j]);\n swap(x[i],y[j]);\n end;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[3]<>x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8]) and\n (y[1]=y[4]) and (y[4]=y[6]) and (y[1]<>y[2]) and (y[2]=y[7]) and (y[2]<>y[3]) and (y[3]=y[5]) and (y[5]=y[8])\n then writeln('respectable')\n else writeln('ugly');\n end."}, {"source_code": "var j,n,i:longint;\n x,y:array[0..8]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\n begin\n n:=8;\n for i:=1 to n do\n read(x[i],y[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if(x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j]))then\n begin\n swap(x[i],y[j]);\n swap(x[i],y[j]);\n end;\n if(x[1]=x[2])and(x[2]=x[3])and(x[3]<>x[4])and(x[4]=x[5])and(x[5]<>x[6])and(x[6]=x[7])and(x[7]=x[8])then\n begin\n if(y[1]=y[4])and(y[4]=y[6])and(y[1]<>y[2])and(y[2]=y[7])and(y[2]<>y[3])and(y[3]=y[5])and(y[5]=y[8])then\n begin\n writeln('respectable');\n exit;\n end;\n end;\n writeln('ugly');\n end."}, {"source_code": "var j,n,i:longint;\n x,y:array[0..8]of longint;\nprocedure swap(var q,w:longint);\nvar z:longint;\n begin\n z:=q;\n q:=w;\n w:=z;\n end;\n begin\n n:=8;\n for i:=1 to n do\n read(x[i],y[i]);\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if(x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j]))then\n begin\n swap(x[i],y[j]);\n swap(x[i],y[j]);\n end;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[3]<>x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8]) and\n (y[1]=y[4]) and (y[4]=y[6]) and (y[1]<>y[2]) and (y[2]=y[7]) and (y[2]<>y[3]) and (y[3]=y[5]) and (y[5]=y[8])\n then writeln('respectable')\n else writeln('ugly');\n end."}, {"source_code": "var x,y:array[1..8]of word;\n i,j,t:word;\nbegin\n for i:=1to 8do\n read(x[i],y[i]);\n for i:=1to 7do\n for j:=i+1to 8do\n if(x[j]x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n b:=x[i]; x[i]:=x[j]; x[j]:=b;\n b:=y[i]; y[i]:=y[j]; y[j]:=b;\n end;\n for i:=2 to 3 do if x[i]<>x[i-1] then print;\n for i:=5 to 6 do if x[i]<>x[i-1] then print;\n for i:=7 to 8 do if x[i]<>x[i-1] then print;\n if (x[4]=x[3])or(x[6]=x[5]) then print;\n f:=(y[2]>y[1])and(y[2]y[6])and(y[7]y[1])and(y[3]=y[5])and(y[3]=y[8]);\n if not (f) then print;\n f:=(y[1]=y[4])and(y[1]=y[6]);\n if not (f) then print;\n write(g,'respectable');\n Close(fg);Close(g);\nEND.\n\n"}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k: longint;\n a: array [1..8, 1..2] of longint;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n if (l1 >= 1) and(l >= 1) then if (a[i, 1] = c) and (a[i, 2] = y) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k, q, w: longint;\n a: array [1..8, 1..2] of longint;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n\n end;\n if l *l1 = 4 then\n begin\n if ((b < d) and (b > c) )or((b < c)and(b > d)) then q:=b;\n if ((c < d) and (c > b) )or((c < b)and(c > d)) then q:=c;\n if ((d < b) and (d > c) )or((d < c)and(d > b)) then q:=d;\n if ((x < z) and (x > y) )or((x < y)and(x > z)) then w:=x;\n if ((y < z) and (y > x) )or((y < x)and(y > z)) then w:=y;\n if ((z < x) and (z > y) )or((z < y)and(z > x)) then w:=z;\n end\n else k:= 1;\n for i:=1 to 8 do\n begin\n if (a[i, 1] = q) and(a[i, 2]= w) then k:= 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k: integer;\n a: array [1..8, 1..2] of integer;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n if (l1 = 1) and(l = 1) then if (a[i, 1] = c) and (a[i, 2] = y) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k: integer;\n a: array [1..8, 1..2] of integer;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] <> b) or (a[i, 1] <> c) or (a[i, 1] <> d) then k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] <> x) or (a[i, 2] <> y) or (a[i, 2] <> z) then k := 1;\n end;\n end;\n if (l1 = 1) and(l = 1) then if (a[i, 1] = c) and (a[i, 2] = y) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k, q, w, j: longint;\n a: array [1..8, 1..2] of longint;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n\n end;\n if l *l1 = 4 then\n begin\n if ((b < d) and (b > c) )or((b < c)and(b > d)) then q:=b;\n if ((c < d) and (c > b) )or((c < b)and(c > d)) then q:=c;\n if ((d < b) and (d > c) )or((d < c)and(d > b)) then q:=d;\n if ((x < z) and (x > y) )or((x < y)and(x > z)) then w:=x;\n if ((y < z) and (y > x) )or((y < x)and(y > z)) then w:=y;\n if ((z < x) and (z > y) )or((z < y)and(z > x)) then w:=z;\n end\n else k:= 1;\n for i:=1 to 8 do\n begin\n\n if (a[i, 1] = q) and(a[i, 2]= w) then k:= 1;\n for j := 1 to 8 do\n if(a[i, 1]= a[j, 1])and(a[i, 2] = a[j, 2]) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "var i, b, c, d, x, y, z, l, l1, k: integer;\n a: array [1..8, 1..2] of integer;\nbegin\n for i := 1 to 8 do\n begin\n read(a[i, 1], a[i, 2]);\n if i = 1 then\n begin\n b := a[i, 1];\n end\n else\n begin\n if (a[i, 1] <> b) and(l = 0) then\n begin\n c := a[i, 1];\n l := 1;\n end\n else\n if (l = 1) and(a[i, 1] <> c)and(a[i, 1] <> b) then\n begin\n d := a[i, 1];\n l := 2;\n end\n else\n if (l = 2) then\n begin\n if (a[i, 1] = b) or (a[i, 1] = c) or (a[i, 1] = d) then else k := 1;\n end;\n end;\n if i = 1 then\n begin\n x := a[i, 2];\n end\n else\n begin\n if (a[i, 2] <> x) and (l1 = 0) then\n begin\n y := a[i, 2];\n l1 := 1;\n end\n else\n if (l1 = 1) and (a[i, 2] <> y)and(a[i, 2] <> x) then\n begin\n z := a[i, 2];\n l1 := 2;\n end\n else\n if (l1 = 2) then\n begin\n if (a[i, 2] = x) or (a[i, 2] = y) or (a[i, 2] = z) then else k := 1;\n end;\n end;\n if (l1 >= 1) and(l >= 1) then if (a[i, 1] = c) and (a[i, 2] = y) then k := 1;\n end;\n if (l1*l <> 4) then k := 1;\n if k = 1 then write('ugly') else write('respectable');\nend."}, {"source_code": "CONST\n fi = '';//'8PS.INP';\n fo = '';//'8PS.OUT';\n n = 8;\n\nTYPE\n mang = array [1..8] of longint;\n\nVAR\n f: text;\n x, y: mang;\n maxx, maxy, minx, miny, gx, gy: longint;\n\n{====================================================================}\n{====================================================================}\n\nprocedure DocFile;\n var\n i: integer;\n Begin\n assign (f, fi); reset (f);\n maxx := -1; maxy := -1; minx := 1000001; miny := minx;\n for i:=1 to n do begin\n readln (f, x[i], y[i]);\n if maxx < x[i] then maxx := x[i];\n if maxy < y[i] then maxy := y[i];\n if minx > x[i] then minx := x[i];\n if miny > y[i] then miny := y[i];\n end;\n close (f);\n\n for i:=1 to n do\n begin\n if (x[i] <> maxx) and (x[i] <> minx) then gx := x[i];\n if (y[i] <> maxy) and (y[i] <> miny) then gy := y[i];\n end;\n End;\n\n{====================================================================}\n{====================================================================}\n\nprocedure GhiKQ (x: boolean);\n Begin\n assign (f, fo); rewrite (f);\n if x then write (f, 'respectable')\n else write (f, 'ugly');\n close (f);\n halt;\n End;\n\n{------------------------------}\n\nprocedure EightPS;\n var\n i: integer;\n tmaxx, tmaxy, tminx, tminy, tgx, tgy: integer;\n Begin\n if (maxx = minx) or (maxy = miny) then GhiKQ (false);\n\n tmaxx := 0; tminx := 0; tmaxy := 0; tminy := 0; tgx := 0; tgy := 0;\n\n for i:=1 to n do\n begin\n if x[i] = maxx then inc (tmaxx);\n if x[i] = minx then inc (tminx);\n if y[i] = maxy then inc (tmaxy);\n if y[i] = miny then inc (tminy);\n if x[i] = gx then inc (tgx);\n if y[i] = gy then inc (tgy);\n end;\n\n if (tmaxx <> 3) or (tmaxy <> 3) or (tminx <> 3) or (tminy <> 3) or (tgx <> 2) or (tgy <> 2)\n then GhiKQ (false)\n else GhiKQ (true);\n End;\n\n{====================================================================}\n{====================================================================}\n\nBEGIN\n DocFile;\n EightPS;\nEND.\n"}, {"source_code": "CONST\n fi = '';//'8PS.INP';\n fo = '';//'8PS.OUT';\n n = 8;\n\nTYPE\n mang = array [1..8] of longint;\n\nVAR\n f: text;\n x, y: mang;\n\n{====================================================================}\n{====================================================================}\n\nprocedure DocFile;\n var\n i: integer;\n Begin\n assign (f, fi); reset (f);\n for i:=1 to n do readln (f, x[i], y[i]);\n close (f);\n End;\n\n{====================================================================}\n{====================================================================}\n\nprocedure GhiKQ (s: string);\n Begin\n assign (f, fo); rewrite (f);\n write (f, s);\n close (f);\n halt;\n End;\n\n{------------------------------}\n\nprocedure EightPS;\n var\n i, j: integer;\n Begin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (x[i]+1 < x[j]) and (y[i]+1 < y[j])\n then GhiKQ ('respectable');\n\n GhiKQ ('ugly');\n End;\n\n{====================================================================}\n{====================================================================}\n\nBEGIN\n DocFile;\n EightPS;\nEND."}, {"source_code": "CONST\n fi = '';//'8PS.INP';\n fo = '';//'8PS.OUT';\n n = 8;\n\nTYPE\n mang = array [1..8] of longint;\n\nVAR\n f: text;\n x, y: mang;\n maxx, maxy, minx, miny, gx, gy: longint;\n\n{====================================================================}\n{====================================================================}\n\nprocedure DocFile;\n var\n i: integer;\n Begin\n assign (f, fi); reset (f);\n maxx := -1; maxy := -1; minx := 1000001; miny := minx;\n for i:=1 to n do begin\n readln (f, x[i], y[i]);\n if maxx < x[i] then maxx := x[i];\n if maxy < y[i] then maxy := y[i];\n if minx > x[i] then minx := x[i];\n if miny > y[i] then miny := y[i];\n end;\n close (f);\n\n for i:=1 to n do\n begin\n if (x[i] <> maxx) and (x[i] <> minx) then gx := x[i];\n if (y[i] <> maxy) and (y[i] <> miny) then gy := y[i];\n end;\n End;\n\n{====================================================================}\n{====================================================================}\n\nprocedure GhiKQ (x: boolean);\n Begin\n assign (f, fo); rewrite (f);\n if x then write (f, 'respectable')\n else write (f, 'ugly');\n close (f);\n halt;\n End;\n\n{------------------------------}\n\nprocedure EightPS;\n var\n i: integer;\n tmaxx, tmaxy, tminx, tminy, tgx, tgy: integer;\n Begin\n if (maxx = minx) or (maxy = miny) then GhiKQ (false);\n\n tmaxx := 0; tminx := 0; tmaxy := 0; tminy := 0; tgx := 0; tgy := 0;\n\n for i:=1 to n do\n begin\n if x[i] = maxx then inc (tmaxx);\n if x[i] = minx then inc (tminx);\n if y[i] = maxy then inc (tmaxy);\n if y[i] = miny then inc (tminy);\n if (x[i] <> maxx) and (x[i] <> minx) then inc (tgx);\n if (y[i] <> maxy) and (y[i] <> miny) then inc (tgy);\n end;\n\n if (tmaxx <> 3) or (tmaxy <> 3) or (tminx <> 3) or (tminy <> 3) or (tgx <> 2) or (tgy <> 2)\n then GhiKQ (false)\n else GhiKQ (true);\n End;\n\n{====================================================================}\n{====================================================================}\n\nBEGIN\n DocFile;\n EightPS;\nEND.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n x2,y2,x,y,sl,sl2:array[1..8] of longint;\n dem,dem2,i,j:longint;\n stop:boolean;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n dem:=0;\n dem2:=0;\n for i:=1 to 8 do\n begin\n readln(F,x[i],y[i]);\n stop:=false;\n for j:=1 to dem do\n if x[i]=x2[j] then\n begin\n sl[j]:=sl[j]+1;\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem:=dem+1;\n x2[dem]:=x[i];\n sl[dem]:=1;\n end;\n stop:=false;\n for j:=1 to dem2 do\n if y[i]=y2[j] then\n begin\n sl2[j]:=sl2[j]+1;\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem2:=dem2+1;\n y2[dem2]:=y[i];\n sl2[dem2]:=1;\n end;\n end;\n close(f);\n\n if (dem<>3) or (dem2<>3) then writeln(g,'ugly') else\n begin\n stop:=false;\n for i:=1 to 3 do\n if i=2 then\n if sl[i]<>2 then\n begin\n stop:=true;\n break;\n end\n else else if sl[i]<>3 then\n begin\n stop:=true;\n break;\n end;\n if stop=true then\n begin\n writeln(g,'ugly');\n close(g);\n halt;\n end;\n stop:=false;\n for i:=1 to 3 do\n if i=2 then\n if sl2[i]<>2 then\n begin\n stop:=true;\n break;\n end\n else else if sl2[i]<>3 then\n begin\n stop:=true;\n break;\n end;\n if stop=true then\n begin\n writeln(g,'ugly');\n close(g);\n halt;\n end;\n x2[4]:=x2[1];\n if x2[2]>x2[4] then\n if x2[3]>x2[2] then x2[4]:=x2[2]\n else if x2[3]>x2[1] then x2[4]:=x2[3];\n y2[4]:=y2[1];\n if y2[2]>y2[4] then\n if y2[3]>y2[2] then y2[4]:=y2[2]\n else if y2[3]>y2[1] then y2[4]:=y2[3];\n stop:=false;\n for i:=1 to 8 do\n if (x[i]=x2[4]) and (y[i]=y2[4]) then\n begin\n writeln(g,'ugly');\n stop:=true;\n break;\n end;\n if stop=false then writeln(g,'respectable');\n end;\n close(g);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f,g:text;\n x2,y2,x,y:array[1..8] of longint;\n dem,dem2,i,j:longint;\n stop:boolean;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\n dem:=0;\n dem2:=0;\n for i:=1 to 8 do\n begin\n readln(F,x[i],y[i]);\n stop:=false;\n for j:=1 to dem do\n if x[i]=x2[j] then\n begin\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem:=dem+1;\n x2[dem]:=x[i];\n end;\n stop:=false;\n for j:=1 to dem2 do\n if y[i]=y2[j] then\n begin\n stop:=true;\n break;\n end;\n if stop=false then\n begin\n dem2:=dem2+1;\n y2[dem2]:=y[i];\n end;\n end;\n close(f);\n\n if (dem<>3) or (dem2<>3) then writeln(g,'ugly') else\n begin\n x2[4]:=x2[1];\n if x2[2]>x2[4] then\n if x2[3]>x2[2] then x2[4]:=x2[2]\n else if x2[3]>x2[1] then x2[4]:=x2[3];\n y2[4]:=y2[1];\n if y2[2]>y2[4] then\n if y2[3]>y2[2] then y2[4]:=y2[2]\n else if y2[3]>y2[1] then y2[4]:=y2[3];\n stop:=false;\n for i:=1 to 8 do\n if (x[i]=x2[4]) and (y[i]=y2[4]) then\n begin\n writeln(g,'ugly');\n stop:=true;\n break;\n end;\n if stop=false then writeln(g,'respectable');\n end;\n close(g);\nend.\n"}, {"source_code": "program problem2;\n\nfunction med( a, b, c: longInt ): longInt;\nbegin\n\tif ( a < b ) and ( b < c ) then\n\t\texit( b )\n\telse if ( a < c ) and ( c < b ) then\n\t\texit( c )\n\telse\n\t\texit( a );\nend;\n\nvar\ti, j, xCnt, yCnt: longInt;\n\tx, y, xx, yy: array[ 1..8 ] of longInt;\n\nbegin\n\tfor i := 1 to 8 do\n\t\treadln( x[i], y[i] );\n\t\t\n\tfor i := 1 to 8 do\n\t\tfor j := i + 1 to 8 do\n\t\t\tif ( x[i] = x[j] ) and ( y[i] = y[j] ) then\n\t\t\tbegin\n\t\t\t\twriteln( 'ugly' );\n\t\t\t\thalt;\n\t\t\tend;\n\t\t\t\n\tfor i := 1 to 8 do\n\tbegin\n\t\txx[i] := -1;\n\t\tyy[i] := -1;\n\tend;\n\t\t\t\n\txCnt := 0;\n\tyCnt := 0;\n\tfor i := 1 to 8 do\n\tbegin\n\t\tif ( x[i] <> xx[1] ) and ( x[i] <> xx[2] ) and ( x[i] <> xx[3] ) then\n\t\tbegin\n\t\t\tinc( xCnt );\n\t\t\txx[xCnt] := x[i];\n\t\tend;\n\t\t\n\t\tif ( y[i] <> yy[1] ) and ( y[i] <> yy[2] ) and ( y[i] <> yy[3] ) then\n\t\tbegin\n\t\t\tinc( yCnt );\n\t\t\tyy[yCnt] := y[i];\n\t\tend;\n\tend;\n\t\n\tif ( xCnt <> 3 ) or ( yCnt <> 3 ) then\n\tbegin\n\t\twriteln( 'ugly' );\n\t\thalt;\n\tend;\n\t\n\tfor i := 1 to 8 do\n\t\tif ( x[i] = med( xx[1], xx[2], xx[3] ) ) and ( y[i] = med( yy[1], yy[2], yy[3] ) ) then\n\t\tbegin\n\t\t\twriteln( 'ugly' );\n\t\t\thalt;\n\t\tend;\n\n\twriteln( 'respectable' );\nend.\n"}, {"source_code": "var\n tot,i,n,l1,t,j:longint;\n x1:array[1..100]of longint;\n f:array[0..1000000]of boolean;\n x,y:array[1..20]of longint;\nbegin\n n:=8;\n for i:=1 to n do\n readln(x[i],y[i]);\n for i:=1 to n do\n for j:=1 to n do\n if (x[i]=x[j])and(y[i]=y[j]) then\n begin\n writeln('ugly');\n exit;\n end;\n for i:=1 to n do\n if f[x[i]]=false then\n begin\n f[x[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l1);\n x1[l1]:=x[i];\n end;\n tot:=0;\n fillchar(f,sizeof(f),false);\n for i:=1 to n do\n if f[y[i]]=false then\n begin\n f[y[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if x1[j]>x1[i] then\n begin\n t:=x1[j];\n x1[j]:=x1[i];\n x1[i]:=t;\n end;\n tot:=0;\n for i:=1 to n do\n if (x[i]=x1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly') else writeln('respectable');\n { begin\n tot:=0;\n for i:=1 to n do\n if x[i]=x1[1] then\n inc(tot);\n if tot<>3 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly')\n else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[1]) then\n inc(tot);\n if tot<>3 then writeln('ugly') else writeln('respectable');\n end;\n end;\n end; }\nend.\n"}, {"source_code": "var\n tot,i,n,l1,l2,t,j:longint;\n x1,y1:array[1..100]of longint;\n f:array[0..1000000]of boolean;\n x,y:array[1..20]of longint;\nbegin\n n:=8;\n for i:=1 to n do\n readln(x[i],y[i]);\n for i:=1 to n do\n if f[x[i]]=false then\n begin\n f[x[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l1);\n x1[l1]:=x[i];\n end;\n tot:=0;\n fillchar(f,sizeof(f),false);\n for i:=1 to n do\n if f[y[i]]=false then\n begin\n f[y[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l2);\n y1[l2]:=y[i];\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if x1[j]>x1[i] then\n begin\n t:=x1[j];\n x1[j]:=x1[i];\n x1[i]:=t;\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if y1[j]>y1[i] then\n begin\n t:=y1[j];\n y1[j]:=y1[i];\n y1[i]:=t;\n end;\n tot:=0;\n for i:=1 to n do\n if (x[i]=x1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if x[i]=x1[1] then\n inc(tot);\n if tot<>3 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly')\n else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[1]) then\n inc(tot);\n if tot<>3 then writeln('ugly') else writeln('respectable');\n end;\n end;\n end;\nend.\n"}, {"source_code": "var\n tot,i,n,l1,t,j:longint;\n x1:array[1..100]of longint;\n f:array[0..1000000]of boolean;\n x,y:array[1..20]of longint;\nbegin\n n:=8;\n for i:=1 to n do\n readln(x[i],y[i]);\n for i:=1 to n do\n for j:=1 to n do\n if i<>j then\n if (x[i]=x[j])and(y[i]=y[j]) then\n begin\n writeln('ugly');\n exit;\n end;\n for i:=1 to n do\n if f[x[i]]=false then\n begin\n f[x[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n inc(l1);\n x1[l1]:=x[i];\n end;\n tot:=0;\n fillchar(f,sizeof(f),false);\n for i:=1 to n do\n if f[y[i]]=false then\n begin\n f[y[i]]:=true;\n inc(tot);\n if tot>3 then\n begin\n writeln('ugly');\n exit;\n end;\n end;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if x1[j]>x1[i] then\n begin\n t:=x1[j];\n x1[j]:=x1[i];\n x1[i]:=t;\n end;\n tot:=0;\n for i:=1 to n do\n if (x[i]=x1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly') else writeln('respectable');\n { begin\n tot:=0;\n for i:=1 to n do\n if x[i]=x1[1] then\n inc(tot);\n if tot<>3 then writeln('ugly') else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[2]) then\n inc(tot);\n if tot<>2 then writeln('ugly')\n else\n begin\n tot:=0;\n for i:=1 to n do\n if (y[i]=y1[1]) then\n inc(tot);\n if tot<>3 then writeln('ugly') else writeln('respectable');\n end;\n end;\n end; }\nend.\n"}, {"source_code": "uses math;\ntype mass=array[1..8,1..2] of integer;\n maxx=array[1..12] of integer;\n majj=array[1..8] of boolean;\nvar d,x,y,kol,p,q,l1,r1,q1,q2,k,uk,min1,e,e1,n,kolv,res,r,l,b,c,max1:int64;s,s1,s2:string;i:integer;\n ch,ce:char;u:boolean;qq,w,o,g,a:int64;m,m3,t,h:mass;v,z,j:integer;m1:maxx;m2:majj;\nprocedure qsort(var A:mass);\n procedure sort(l,r:integer);\n var i,j,x,w,x1,y: integer;\n begin\n i := l;\n j := r;\n w:=l+random(r-l);\n x := A[w,1];\n x1:=a[w,2];\n repeat\n while (A[i,1] < x) or ((a[i,1]=x) and (a[i,2]x1)) do dec(j);\n if not (i>j) then\n begin\n y := A[i,1];\n A[i,1] := A[j,1];\n A[j,1] := y;\n y:=a[i,2];\n a[i,2]:=a[j,2];\n a[j,2]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if l < j then sort(l,j);\n if i < r then sort(i,r);\n end;\nbegin\n sort(1,8);\nend;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n for i:=1 to 8 do\n readln(m[i,1],m[i,2]);\n qsort(m);\n a:=0;\n i:=1;\n for i:=2 to 8 do\n if m[i,1]<>m[i-1,1]\n then inc(a);\n for i:=2 to 8 do\n if (m[i,1]=m[i-1,1]) and (m[i-1,2]=m[i-1,2])\n then Begin\n writeln('ugly');\n halt(0);\n end;\n if a<>2\n then Begin\n writeln('ugly');\n halt(0);\n end;\n m1[1]:=1;\n a:=1;\n for j:=2 to 8 do\n Begin\n if m[j,1]<>m[j-1,1]\n then inc(a);\n inc(m1[a]);\n end;\n if not ((m1[1]=3) and (m1[2]=2) and (m1[3]=3))\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n for z:=1 to 8 do\n Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=3\n then Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n inc(a);\n m1[a]:=m[j,2];\n end;\n break;\n end;\n end;\n fillchar(m2,sizeof(m2),true);\n for z:=1 to 8 do\n Begin\n if m2[z]=false\n then continue;\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=2\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a,2);\n m2[j]:=false;\n end;\n end\n else if a=3\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a);\n m2[j]:=false;\n end;\n end\n else Begin\n writeln('ugly');\n halt(0);\n end;\n end;\n writeln('respectable');\nend.\n"}, {"source_code": "uses math;\ntype mass=array[1..8,1..2] of integer;\n maxx=array[1..12] of integer;\n majj=array[1..8] of boolean;\nvar d,x,y,kol,p,q,l1,r1,q1,q2,k,uk,min1,e,e1,n,kolv,res,r,l,b,c,max1:int64;s,s1,s2:string;i:integer;\n ch,ce:char;u:boolean;qq,w,o,g,a:int64;m,m3,t,h:mass;v,z,j:integer;m1:maxx;m2:majj;\nprocedure qsort(var A:mass);\n procedure sort(l,r:integer);\n var i,j,x,w,x1,y: integer;\n begin\n i := l;\n j := r;\n w:=l+random(r-l);\n x := A[w,1];\n x1:=a[w,2];\n repeat\n while (A[i,1] < x) or ((a[i,1]=x) and (a[i,2]x1)) do dec(j);\n if not (i>j) then\n begin\n y := A[i,1];\n A[i,1] := A[j,1];\n A[j,1] := y;\n y:=a[i,2];\n a[i,2]:=a[j,2];\n a[j,2]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if l < j then sort(l,j);\n if i < r then sort(i,r);\n end;\nbegin\n sort(1,8);\nend;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n for i:=1 to 8 do\n readln(m[i,1],m[i,2]);\n qsort(m);\n a:=0;\n i:=1;\n for i:=2 to 8 do\n if m[i,1]<>m[i-1,1]\n then inc(a);\n if a<>2\n then Begin\n writeln('ugly');\n halt(0);\n end;\n m1[1]:=1;\n a:=1;\n for j:=2 to 8 do\n Begin\n if m[j,1]<>m[j-1,1]\n then inc(a);\n inc(m1[a]);\n end;\n if not ((m1[1]=3) and (m1[2]=2) and (m1[3]=3))\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n for z:=1 to 8 do\n Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=3\n then Begin\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n inc(a);\n m1[a]:=m[j,2];\n end;\n break;\n end;\n end;\n fillchar(m2,sizeof(m2),true);\n for z:=1 to 8 do\n Begin\n if m2[z]=false\n then continue;\n a:=0;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then inc(a);\n if a>3\n then BEgin\n writeln('ugly');\n halt(0);\n end;\n if a=2\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a,2);\n m2[j]:=false;\n end;\n end\n else if a=3\n then Begin\n a:=1;\n for j:=z to 8 do\n if m[j,1]=m[z,1]\n then Begin\n if m[j,2]<>m1[a]\n then Begin\n writeln('ugly');\n halt(0);\n end;\n inc(a);\n m2[j]:=false;\n end;\n end\n else Begin\n writeln('ugly');\n halt(0);\n end;\n end;\n writeln('respectable');\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n x,y:array[1..8] of longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n n:=8;\n for i:=1 to n do\n readln(f,x[i],y[i]);\n close(f);\nEnd;\nProcedure Trao(var x,y:longint);\nVar temp:longint;\nBegin\n temp:=x;\n x:=y;\n y:=temp;\nEnd;\nProcedure Sort;\nVar i,j:longint;\nBegin\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if (y[i]x[j])) then\n begin\n trao(x[i],x[j]);\n trao(y[i],y[j]);\n end;\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n assign(f,fout); rewrite(f);\n if (y[1]-y[4]=1) and (y[4]-y[6]=1) and (x[2]-x[1]=1) and (x[3]-x[2]=1) and (x[5]-x[4]=2) and (x[7]-x[6]=1) and (x[8]-x[7]=1) then\n write(f,'respectable')\n else\n write(f,'ugly');\n close(f);\nEnd;\n\nBegin\n nhap;\n sort;\n xuat;\nEnd."}, {"source_code": "const n = 8;\nvar i,j, ans: LongInt;\nx,y: array[1..8] of LongInt;\nres: Boolean;\nbegin\n for i:=1 to n do Readln(x[i],y[i]);\n \n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n if (x[j]x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8])\n then res:=true;\n \n \n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n if (y[j]y[4]) and (y[4]=y[5]) and (y[5]<>y[6]) and (y[6]=y[7]) and (y[7]=y[8]) then\n Writeln('respectable') else Writeln('ugly');\n \nend."}, {"source_code": "const n = 8;\nvar i,j, ans: LongInt;\nx,y: array[1..8] of LongInt;\nbegin\n for i:=1 to n do Readln(x[i],y[i]);\n \n for i:=1 to n-1 do\n begin\n for j:=i+1 to n do\n if (x[j]x[4]) and (x[4]=x[5]) and (x[5]<>x[6]) and (x[6]=x[7]) and (x[7]=x[8])\n then Writeln('respectable') else Writeln('ugly');\n \nend."}, {"source_code": "type qw = record\n x,y : longint;\nend;\n\nvar a : array[1..8] of qw;\n i,jx,jy : longint;\n\nprocedure sortx(l,r : longint);\n var i,j,xt : longint;\n tmp : qw;\n begin\n i := l;\n j := r;\n xt := a[(l+r) div 2].x;\n repeat\n while a[i].x < xt do inc(i);\n while a[j].x > xt do dec(j);\n if i <= j then begin\n tmp := a[i];\n a[i] := a[j];\n a[j] := tmp;\n inc(i);\n dec(j);\n end;\n until i > j;\n if l < j then sortx(l,j);\n if i < r then sortx(i,r);\n end;\n\nprocedure sorty(l,r : longint);\n var i,j,xt : longint;\n tmp : qw;\n begin\n i := l;\n j := r;\n xt := a[(l+r) div 2].y;\n repeat\n while a[i].y < xt do inc(i);\n while a[j].y > xt do dec(j);\n if i <= j then begin\n tmp := a[i];\n a[i] := a[j];\n a[j] := tmp;\n inc(i);\n dec(j);\n end;\n until i > j;\n if l < j then sorty(l,j);\n if i < r then sorty(i,r);\n end;\n\n\nprocedure thoat;\n begin\n writeln('ugly');\n halt;\n end;\n\nbegin\n for i := 1 to 8 do\n readln(a[i].x,a[i].y);\n /////////////////////////////\n sortx(1,8);\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[1].x then inc(jx);\n if jx <> 3 then thoat;\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[4].x then inc(jx);\n if jx <> 2 then thoat;\n jx := 0;\n for i := 1 to 8 do\n if a[i].x = a[6].x then inc(jx);\n if jx <> 3 then thoat;\n /////////////////////////\n sorty(1,8);\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[1].y then inc(jy);\n if jy <> 3 then thoat;\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[4].y then inc(jy);\n if jy <> 2 then thoat;\n jy := 0;\n for i := 1 to 8 do\n if a[i].y = a[6].y then inc(jy);\n if jy <> 3 then thoat;\n ///////////////////////\n writeln('respectable');\nend."}, {"source_code": "Var x,y:array [0..100] of longint;\n i,t,tt,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10:longint;\n\n procedure sort(l,r: longint);\n var\n i,j,xx,yy,z: longint;\n begin\n i:=l;\n j:=r;\n xx:=x[(l+r) div 2];\n z:=y[(l+r) div 2];\n repeat\n while (x[i]j) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l2) and (j<>2) then f[p]:=false; end;\n end;\n end;\n for i:=1 to 8 do\n if f[i] then begin writeln('respectable'); halt; end;\n writeln('ugly');\n end\n else writeln('ugly');\n end."}, {"source_code": "var x,y:array[1..8]of word;q,i,j:longint;\nbegin\nfor i:=1 to 8 do\nread(x[i],y[i]);\nfor i:=1 to 8 do\n for j:=i+1 to 8 do\n begin\n if (x[j]=2)and(a[i,2]-a[j,2]>=2)then begin writeln('respectable');exit;end {else\nif (a[i,1]-a[j,1]>=2)and(a[i,2]-a[j,2]>=2) then for u:=i to i+a[i,1]-a[j,1] do for y:=u to i+a[i,2]-a[j,2] do\n if b[a[u,1],a[y,2]]=0 then begin writeln('respectable');exit; end; }\nend;\nwriteln('ugly');\nend.\n"}, {"source_code": "var x,y:array[1..8]of word;q,i,j:longint;\nbegin\nfor i:=1 to 8 do\nread(x[i],y[i]);\nfor i:=1 to 8 do\n for j:=i+1 to 8 do\n begin\n if (x[j]x do dec(j);\nif i<=j then begin\n q:=a[i,1];\n a[i,1]:=a[j,1];\n a[j,1]:=q;\n q:=a[i,2];\n a[i,2]:=a[j,2];\n a[j,2]:=q;\n\n inc(i);\n dec(j);\n end;\nuntil i>j;\nif in1 then sort(n1,j);\nend;\n\n\nbegin\nfor i:=1 to 8 do\nbegin\nread(a[i,1],a[i,2]);\n{inc(b[a[i,1],a[i,2]]);}\nend;\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nbegin\nif (a[i,1]-a[j,1]>=8)and(a[i,2]-a[j,2]>=8)then begin write('respectable');exit;end {else\nif (a[i,1]-a[j,1]>=2)and(a[i,2]-a[j,2]>=2) then for u:=a[i,1] to a[i,1]+7 do for y:=a[i,1] to a[i,1]+7 do\n if b[u,y]=0 then begin write('respectable');exit; end; }\nend;\nwrite('ugly');\nend."}, {"source_code": "var\n i, j, k, n, a, b, maxx, maxy, minx, miny, s: longint;\n x, y: array[1..10] of longint;\n f:boolean;\n\n\n\n\nbegin\n n := 8;\n for i := 1 to n do read(x[i], y[i]);\n for k:=1 to n do\n for i := 1 to n do\n for j := 1 to n do \n if (y[i] < y[j]) or ((y[i] = y[j]) and (x[i] < x[j])) then \n begin a := y[i]; y[i] := y[j]; y[j] := a; b := x[i]; x[i] := x[j]; x[j] := b; end;\n\n f:=true;\n if \n (y[1]<>y[2]) or (y[2]<>y[3]) or (y[4]<>y[5]) or (y[6]<>y[7]) or (y[7]<>y[8])\nor(x[1]<>x[4]) or (x[4]<>x[6]) or (x[2]<>x[7]) or (x[3]<>x[5]) or (x[5]<>x[8]) \nthen f:=false;\n if f then writeln('respectable') else writeln('ugly');\n\nend."}, {"source_code": "var\n i, j, k, n, a, b, maxx, maxy, minx, miny, s: longint;\n x, y: array[1..10] of longint;\n\n\nfunction gets(): real;\nvar\n i: longint;\n s: real;\nbegin\n for i := 2 to n do \n s := s + (x[i] - x[i - 1]) * (y[i] + y[i - 1]) / 2;\n s := s + (x[n] - x[1]) * (y[1] + y[n]) / 2;\n gets := s;\nend;\n\nbegin\n n := 8;\n for i := 1 to n do read(x[i], y[i]);\n for i := 1 to n do\n for j := 1 to n do \n if (y[i] < y[j]) or ((y[i] = y[j]) and (x[i] < x[j])) then \n begin a := y[i]; y[i] := y[j]; y[j] := a; b := x[i]; x[i] := x[j]; x[j] := b; end;\n \n maxx := -10000000;\n maxy := -10000000;\n minx := 10000000;\n miny := 10000000;\n for i := 1 to n do\n begin\n if x[i] > maxx then maxx := x[i];\n if x[i] < minx then minx := x[i];\n if y[i] > maxy then maxy := y[i];\n if y[i] < miny then miny := y[i];\n end;\n s := (maxx - minx) * (maxy - miny);\n if (s = gets()) and (s>0) then write('respectable') else write('ugly');\nend."}, {"source_code": "var\n i, j, k, n, a, b, maxx, maxy, minx, miny, s: longint;\n x, y: array[1..10] of longint;\n f:boolean;\n\n\n\n\nbegin\n n := 8;\n for i := 1 to n do read(x[i], y[i]);\n for k:=1 to n do\n for i := 1 to n do\n for j := 1 to n do \n if (y[i] < y[j]) or ((y[i] = y[j]) and (x[i] < x[j])) then \n begin a := y[i]; y[i] := y[j]; y[j] := a; b := x[i]; x[i] := x[j]; x[j] := b; end;\n\n f:=true;\n if \n (y[1]<>y[2]) or (y[2]<>y[3]) or (y[4]<>y[5]) or (y[6]<>y[7]) or (y[7]<>y[8])\nor(x[1]<>x[4]) or (x[4]<>x[6]) or (x[2]<>x[7]) or (x[3]<>x[5]) or (x[5]<>x[8]) \nthen f:=false;\n for i:=1 to n do\n for j:=1 to n do \n if (x[i]=x[j]) and (y[i]=y[j]) then f:=false;\n if f then writeln('respectable') else writeln('ugly');\n\nend."}, {"source_code": "uses math;\nvar\nx,y:array [1..8] of longint;\ni,x1,x2,x3,y1,y2,y3:integer;\nbegin\nfor i:=1 to 8 do\n readln (x[i],y[i]);\nx1:=10000000; x2:=10000000; x3:=10000000;\nfor i:=1 to 8 do\n begin\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1<>10000000) and (x2<>10000000) and (x3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x3=10000000) then\n begin\n x3:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x2=10000000) then\n begin\n x2:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1=10000000) then\n begin\n x1:=x[i];\n end;\n end;\ny1:=10000000; y2:=10000000; y3:=10000000;\nfor i:=1 to 8 do\n begin\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1<>10000000) and (y2<>10000000) and (y3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y3=10000000) then\n begin\n y3:=y[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y2=10000000) then\n begin\n y2:=y[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1=10000000) then\n begin\n y1:=y[i];\n end;\n end;\nx1:=x1+x2+x3-min(x1,min(x2,x3))-max(x1,max(x2,x3));\ny1:=y1+y2+y3-min(y1,min(y2,y3))-max(y1,max(y2,y3));\nfor i:=1 to 8 do\n if (x[i]=x1) and (y[i]=y1) then\n begin\n writeln ('ugly');\n halt;\n end;\nwriteln ('respectable');\nend."}, {"source_code": "uses math;\nvar\nx,y:array [1..8] of longint;\ni,x1,x2,x3,y1,y2,y3:integer;\nbegin\nfor i:=1 to 8 do\n readln (x[i],y[i]);\nx1:=10000000; x2:=10000000; x3:=10000000;\nfor i:=1 to 8 do\n begin\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1<>10000000) and (x2<>10000000) and (x3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x3=10000000) then\n begin\n x3:=x[i];\n end\n else\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x2=10000000) then\n begin\n x2:=x[i];\n end\n else\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1=10000000) then\n begin\n x1:=x[i];\n end;\n end;\ny1:=10000000; y2:=10000000; y3:=10000000;\nfor i:=1 to 8 do\n begin\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1<>10000000) and (y2<>10000000) and (y3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y3=10000000) then\n begin\n y3:=y[i];\n end\n else\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>x3) and (y2=10000000) then\n begin\n y2:=y[i];\n end\n else\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1=10000000) then\n begin\n y1:=y[i];\n end;\n end;\nx1:=x1+x2+x3-min(x1,min(x2,x3))-max(x1,max(x2,x3));\ny1:=y1+y2+y3-min(y1,min(y2,y3))-max(y1,max(y2,y3));\nfor i:=1 to 8 do\n if (x[i]=x1) and (y[i]=y1) then\n begin\n writeln ('ugly');\n halt;\n end;\nwriteln ('respectable')\nend."}, {"source_code": "uses math;\nvar\nx,y:array [1..8] of longint;\ni,x1,x2,x3,y1,y2,y3:integer;\nbegin\nfor i:=1 to 8 do\n readln (x[i],y[i]);\nx1:=10000000; x2:=10000000; x3:=10000000;\nfor i:=1 to 8 do\n begin\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1<>10000000) and (x2<>10000000) and (x3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x3=10000000) then\n begin\n x3:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x2=10000000) then\n begin\n x2:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1=10000000) then\n begin\n x1:=x[i];\n end;\n end;\nif (x1=10000000) or (x2=10000000) or (x3=10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\ny1:=10000000; y2:=10000000; y3:=10000000;\nfor i:=1 to 8 do\n begin\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1<>10000000) and (y2<>10000000) and (y3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y3=10000000) then\n begin\n y3:=y[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y2=10000000) then\n begin\n y2:=y[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1=10000000) then\n begin\n y1:=y[i];\n end;\n end;\nif (y1=10000000) or (y2=10000000) or (y3=10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\nx1:=x1+x2+x3-min(x1,min(x2,x3))-max(x1,max(x2,x3));\ny1:=y1+y2+y3-min(y1,min(y2,y3))-max(y1,max(y2,y3));\nfor i:=1 to 8 do\n if (x[i]=x1) and (y[i]=y1) then\n begin\n writeln ('ugly');\n halt;\n end;\nwriteln ('respectable');\nend."}, {"source_code": "uses math;\nvar\nx,y:array [1..8] of longint;\ni,x1,x2,x3,y1,y2,y3:integer;\nbegin\nfor i:=1 to 8 do\n readln (x[i],y[i]);\nx1:=10000000; x2:=10000000; x3:=10000000;\nfor i:=1 to 8 do\n begin\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1<>10000000) and (x2<>10000000) and (x3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x3=10000000) then\n begin\n x3:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x2=10000000) then\n begin\n x2:=x[i];\n end;\n if (x[i]<>x1) and (x[i]<>x2) and (x[i]<>x3) and (x1=10000000) then\n begin\n x1:=x[i];\n end;\n end;\ny1:=10000000; y2:=10000000; y3:=10000000;\nfor i:=1 to 8 do\n begin\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1<>10000000) and (y2<>10000000) and (y3<>10000000) then\n begin\n writeln ('ugly');\n halt;\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y3=10000000) then\n begin\n x3:=x[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>x3) and (y2=10000000) then\n begin\n y2:=y[i];\n end;\n if (y[i]<>y1) and (y[i]<>y2) and (y[i]<>y3) and (y1=10000000) then\n begin\n y1:=y[i];\n end;\n end;\nx1:=x1+x2+x3-min(x1,min(x2,x3))-max(x1,max(x2,x3));\ny1:=y1+y2+y3-min(y1,min(y2,y3))-max(y1,max(y2,y3));\nfor i:=1 to 8 do\n if (x[i]=x1) and (y[i]=y1) then\n begin\n writeln ('ugly');\n halt;\n end;\nwriteln ('respectable')\nend."}, {"source_code": "const fn = '';\n gx = '';\nvar x,y : array[1..8] of longint;\nprocedure nhap;\nvar f : text;\n i : longint;\nbegin\n assign(f,fn); reset(f);\n for i := 1 to 8 do\n readln(f,x[i],y[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,k : longint;\nbegin\n for j := 2 to 8 do\n begin\n i := j;\n while x[i] < x[i-1] do\n begin\n k := x[i]; x[i] := x[i-1]; x[i-1] := k;\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n while (x[i] = x[i-1]) and (y[i] < y[i-1]) do\n begin\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n end;\nend;\nfunction xuli : boolean;\nvar i : longint;\nbegin\n sort;\n for i := 2 to 3 do if x[i] <> x[i-1] then exit(false);\n for i := 2 to 3 do if y[i] <= y[i-1] then exit(false);\n if (x[4] <> x[5]) or (x[4] <= x[1]) then exit(false);\n if (y[4] <> y[1]) or (y[5] <> y[3]) then exit(false);\n for i := 6 to 8 do\n if y[i] <> y[i-5] then exit(false);\n if x[6] <= x[5] then exit(false);\n for i := 7 to 8 do\n if x[i] <> x[i-1] then exit(false);\n exit(true);\nend;\nprocedure xuat;\nvar g : text;\nbegin\n assign(g,gx); rewrite(g);\n if xuli = true then writeln(g,'respectable')\n else writeln(g,'ugly');\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "const fn = '';\n gx = '';\nvar x,y : array[1..8] of longint;\nprocedure nhap;\nvar f : text;\n i : longint;\nbegin\n assign(f,fn); reset(f);\n for i := 1 to 8 do\n readln(f,x[i],y[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,k : longint;\nbegin\n for j := 2 to 8 do\n begin\n i := j;\n while x[i] < x[i-1] do\n begin\n k := x[i]; x[i] := x[i-1]; x[i-1] := k;\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n while (x[i] = x[i-1]) and (y[i] < y[i-1]) do\n begin\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n end;\nend;\nfunction xuli : boolean;\nvar i : longint;\nbegin\n sort;\n for i := 2 to 3 do if x[i] <> x[i-1] then exit(false);\n if (x[4] <> x[5]) or (x[4] <= x[1]) then exit(false);\n if (y[4] <> y[1]) or (y[5] <> y[3]) then exit(false);\n for i := 6 to 8 do\n if y[i] <> y[i-5] then exit(false);\n if x[6] <= x[5] then exit(false);\n for i := 7 to 8 do\n if x[i] <> x[i-1] then exit(false);\n exit(true);\nend;\nprocedure xuat;\nvar g : text;\nbegin\n assign(g,gx); rewrite(g);\n if xuli = true then writeln(g,'respectable')\n else writeln(g,'ugly');\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "const fn = '';\n gx = '';\nvar x,y : array[1..8] of longint;\nprocedure nhap;\nvar f : text;\n i : longint;\nbegin\n assign(f,fn); reset(f);\n for i := 1 to 8 do\n readln(f,x[i],y[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,k : longint;\nbegin\n for j := 2 to 8 do\n begin\n i := j;\n while x[i] < x[i-1] do\n begin\n k := x[i]; x[i] := x[i-1]; x[i-1] := k;\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n while (x[i] = x[i-1]) and (y[i] < y[i-1]) do\n begin\n k := y[i]; y[i] := y[i-1]; y[i-1] := k;\n dec(i);\n end;\n end;\nend;\nfunction xuli : boolean;\nvar i : longint;\nbegin\n sort;\n for i := 2 to 3 do if x[i] <> x[i-1] then exit(false);\n if x[4] <> x[5] then exit(false);\n if (y[4] <> y[1]) or (y[5] <> y[3]) then exit(false);\n for i := 6 to 8 do\n if y[i] <> y[i-5] then exit(false);\n exit(true);\nend;\nprocedure xuat;\nvar g : text;\nbegin\n assign(g,gx); rewrite(g);\n if xuli = true then writeln(g,'respectable')\n else writeln(g,'ugly');\n close(g);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "var\n n,m,p,xx,xx2,yy,yy2,k,l,i,j,max,min,z,sum,res,x2,y2,b,r,g,q,e : longint;\n a,d : array [0..1000000] of longint;\n s : array [0..1000,0..1000] of longint;\n ans: int64;\n h : boolean;\n\nbegin\n for i:=1 to 8 do\n read(a[i],d[i]);\n for i:=1 to 8 do\n for j:=i+1 to 8 do begin\n if (a[j] a[1,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] = a[1,j]) and (a[2,i] > a[2,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 8 do\n inc(b[a[1,i]]);\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n fillchar(b,sizeof(b),0);\n for i := 1 to 8 do\n inc(b[a[2,i]]);\n x := 0;\n y := 0;\n z := 0;\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n writeln('respectable');\nend.\n"}, {"source_code": "const\n fi = '';\nvar\n a : array[1..2,1..8] of longint;\n i,j,p,x,y,z : longint;\n b : array[0..1000000] of longint;\n\nprocedure loi;\nbegin\n writeln('ugly');\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n for i := 1 to 8 do\n readln(a[1,i],a[2,i]);\n close(input);\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] > a[1,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] = a[1,j]) and (a[2,i] > a[2,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 8 do\n inc(b[a[1,i]]);\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n for i := 1 to 8 do\n inc(b[a[2,i]]);\n for i := 0 to 1000000 do\n begin\n if (b[i]<>0) and (x=0) then x := b[i]\n else if (b[i]<>0) and (y=0) then y := b[i]\n else if (b[i]<>0) and(z=0) then z := b[i];\n end;\n if x<>3 then loi;\n if y<>2 then loi;\n if z<>3 then loi;\n if (a[1,1] <> a[1,2]) or (a[1,2] <> a[1,3]) or (a[1,1] <> a[1,3]) then loi;\n if (a[2,2] <> a[1,5]) or (a[1,5] <> a[1,4]) or (a[2,2] <> a[1,4]) then loi;\n if (a[2,4] <> a[1,1]) then loi;\n if (a[2,6] <> a[1,1]) then loi;\n if (a[1,1] <> a[2,1]) then loi;\n if (a[2,7] <> a[2,2]) then loi;\n if (a[1,8] <> a[1,6]) or (a[1,6] <> a[1,7]) or (a[1,8] <> a[1,7]) then loi;\n if (a[2,8] <> a[1,8]) then loi;\n if (a[2,5] <> a[1,8]) then loi;\n if (a[2,3] <> a[1,8]) then loi;\n\n writeln('respectable');\nend.\n"}, {"source_code": "const\n fi = '';\nvar\n a : array[1..2,1..8] of longint;\n i,j,p : longint;\n\nprocedure loi;\nbegin\n writeln('ugly');\n halt;\nend;\n\nbegin\n assign(input,fi);\n reset(input);\n for i := 1 to 8 do\n readln(a[1,i],a[2,i]);\n close(input);\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] > a[1,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n for i := 1 to 7 do\n for j := i+1 to 8 do\n if (a[1,i] = a[1,j]) and (a[2,i] > a[2,j]) then\n begin\n p := a[1,i];\n a[1,i] := a[1,j];\n a[1,j] := p;\n p := a[2,i];\n a[2,i] := a[2,j];\n a[2,j] := p;\n end;\n if (a[1,1] <> a[1,2]) or (a[1,2] <> a[1,3]) or (a[1,1] <> a[1,3]) then loi;\n if (a[2,2] <> a[1,5]) or (a[1,5] <> a[1,4]) or (a[2,2] <> a[1,4]) then loi;\n if (a[2,4] <> a[1,1]) then loi;\n if (a[2,6] <> a[1,1]) then loi;\n if (a[1,1] <> a[2,1]) then loi;\n if (a[2,7] <> a[2,2]) then loi;\n if (a[1,8] <> a[1,6]) or (a[1,6] <> a[1,7]) or (a[1,8] <> a[1,7]) then loi;\n if (a[2,8] <> a[1,8]) then loi;\n if (a[2,5] <> a[1,8]) then loi;\n if (a[2,3] <> a[1,8]) then loi;\n writeln('respectable');\nend.\n"}, {"source_code": "var i,j,t:longint;\nf:boolean;\na,b,c:array [0..1000] of longint;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=c[(l+r) div 2];\n repeat\n while c[i]j) then\n begin\n y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l3 then writeln('ugly')\nelse\n begin\n f:=true;\n for i:=1 to 8 do\n if (a[i]=c[2]) and (b[i]=c[2]) then\n f:=false;\n if f then writeln('respectable')\n else writeln('ugly');\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var n,i,j,x,y,p,t,w:longint;\nf,e,a,b:array[0..1000000] of longint;\nprocedure z;\nbegin\nwriteln('ugly');close(input);close(output);halt;\nend;\nbegin\n//assign(input,'bdj.in');reset(input);\n//assign(output,'bdj.out');rewrite(output);\nfor i:=1 to 8 do\n begin\n readln(x,y);\n if e[x]=0 then begin inc(t);a[t]:=x; end;\n if f[y]=0 then begin inc(w);b[w]:=y; end;\n inc(e[x]);inc(f[y]);\n end;\nif (t<>3) or (w<>3) then z;\nfor i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then\n begin\n p:=a[i];a[i]:=a[j];a[j]:=p;\n end;\nfor i:=1 to 2 do\n for j:=i+1 to 3 do\n if b[i]>b[j] then\n begin\n p:=b[i];b[i]:=b[j];b[j]:=p;\n end;\nif (e[a[1]]<>3) or (f[b[1]]<>3)\nor (e[a[2]]<>2) or (f[b[2]]<>2)\nor (e[a[3]]<>3) or (f[b[3]]<>3) then\n z;\nwriteln('respectable');\nclose(input);close(output);\nend."}, {"source_code": "var n,x,y,i,t,w:longint;flag:boolean;\na,b,c,d,h:array[0..10000] of longint;\nf,e:array[0..1000001] of longint;\nprocedure sort;\nvar x,i,j:longint;\nbegin\nfor i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then\n begin\n x:=a[i];a[i]:=a[j];a[j]:=x;\n end;\nend;\nbegin\n///assign(input,'bdj.in');reset(input);\n//assign(output,'bdj.out');rewrite(output);\nn:=8;\nfor i:=1 to n do\n begin\n readln(x,y);\n if f[x]=0 then begin f[x]:=1;inc(t);a[t]:=x;end;\n if e[y]=0 then begin e[y]:=1;inc(w);b[w]:=y;end;\n c[i]:=x;d[i]:=y;\n end;\nif(t<>3)or(w<>3)then writeln('ugly')\nelse\n begin\n sort;h:=a;a:=b;\n sort;b:=a;a:=h;\n x:=a[2];y:=b[2];\n flag:=true;\n for i:=1 to n do\n if(c[i]=x)and(d[i]=y)then\n flag:=false;\n if flag then writeln('respectable')\n else writeln('ugly');\n end;\nclose(input);close(output);\nend."}, {"source_code": "var i:longint;\na,b:array[0..10] of longint;\nprocedure sort(l,r: longint);\nvar i,j,x,y,x1: longint;\nbegin\ni:=l;j:=r;x:=a[(l+r) div 2];x1:=b[(l+r) div 2];\nrepeat\nwhile (a[i]x1) do dec(j);\nif not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n y:=b[i];b[i]:=b[j];b[j]:=y;\n inc(i);j:=j-1;\n end;\nuntil i>j;\nif lj) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lt then begin writeln('ugly'); halt; end;\n end;\n for i:=4 to 4 do\n begin\n tt:=round(sqrt(sqr(x[i+1]-x[i])+sqr(y[i+1]-y[i])));\n if tt<>2*t then begin writeln('ugly'); halt; end;\n end;\n for i:=6 to 7 do\n begin\n tt:=round(sqrt(sqr(x[i+1]-x[i])+sqr(y[i+1]-y[i])));\n if tt<>t then begin writeln('ugly'); halt; end;\n end;\n writeln('respectable');\n end."}, {"source_code": "Var x,y:array [0..100] of longint;\n i,t,tt,t1,t2,t3,t4,t5,t6,t7,t8:longint;\n\n procedure sort(l,r: longint);\n var\n i,j,xx,yy,z: longint;\n begin\n i:=l;\n j:=r;\n xx:=x[(l+r) div 2];\n z:=y[(l+r) div 2];\n repeat\n while (x[i]j) then\n begin\n yy:=x[i];\n x[i]:=x[j];\n x[j]:=yy;\n\n yy:=y[i];\n y[i]:=y[j];\n y[j]:=yy;\n\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lt2 then begin writeln('ugly'); halt; end;\n t3:=round(sqrt(sqr(x[4]-x[1])+sqr(y[4]-y[1])));\n if t3<>t1 then begin writeln('ugly'); halt; end;\n t4:=round(sqrt(sqr(x[5]-x[4])+sqr(y[5]-y[4])));\n if t4<>2*t1 then begin writeln('ugly'); halt; end;\n t5:=round(sqrt(sqr(x[4]-x[6])+sqr(y[4]-y[6])));\n if t5<>t1 then begin writeln('ugly'); halt; end;\n t6:=round(sqrt(sqr(x[6]-x[7])+sqr(y[6]-y[7])));\n if t6<>t1 then begin writeln('ugly'); halt; end;\n t7:=round(sqrt(sqr(x[7]-x[8])+sqr(y[7]-y[8])));\n if t7<>t1 then begin writeln('ugly'); halt; end;\n t8:=round(sqrt(sqr(x[5]-x[8])+sqr(y[5]-y[8])));\n if t8<>t1 then begin writeln('ugly'); halt; end;\n writeln('respectable');\n end."}, {"source_code": "uses math;\nconst\n fi='';\n fo='';\nvar\n n:longint;\n f:text;\n x,y:array[0..9] of longint;\n i,j,maxx,maxy,minx,miny,count:longint;\n t1,t2,t3,t4,t5,t6,t:boolean;\nbegin\n assign(f,fi);reset(f);\n n:=8;\n read(f,x[1],y[1]);\n maxx:=x[1];\n minx:=x[1];\n maxy:=y[1];\n miny:=y[1];\n for i:=1 to n do\n begin\n read(f,x[i],y[i]);\n maxx:=max(maxx,x[i]);\n minx:=min(minx,x[i]);\n maxy:=max(maxy,y[i]);\n miny:=min(miny,y[i]);\n end;\n t1:=false;t2:=false;t3:=false;t4:=false;\n for i:=1 to n do\n begin\n if (x[i]=maxx) and (y[i]=maxy) then t1:=true;\n if (x[i]=minx) and (y[i]=miny) then t2:=true;\n if (x[i]=maxx) and (y[i]=miny) then t3:=true;\n if (x[i]=minx) and (y[i]=maxy) then t4:=true;\n end;\n t5:=false;\n t6:=false;\n for i:=minx+1 to maxx-1 do\n begin\n count:=0;\n for j:=1 to 8 do\n if (x[j]=i) and ( (y[j]=miny) or (y[j]=maxy) ) then\n inc(count);\n if count=2 then t5:=true;\n end;\n for i:=miny+1 to maxy-1 do\n begin\n count:=0;\n for j:=1 to 8 do\n if (y[j]=i) and ( (x[j]=minx) or (x[j]=maxx) ) then\n inc(count);\n if count=2 then t6:=true;\n end;\n t:=t1 and t2 and t3 and t4 and t5 and t6;\n if t=true then writeln('respectable') else writeln('ugly');\nend.\n\n\n\n"}, {"source_code": "{$MODE OBJFPC}\nprogram B194;\nconst\n maxXY = Round(1E6);\nvar\n i,j,k: Integer;\n m1,m2: Integer;\n count: Integer;\n x,y,x1,y1: array [1..8] of Integer;\n frx,fry: array [0..maxXY] of Boolean;\n fr: array [1..3,1..3] of Boolean;\n\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n FillChar(frx,SizeOf(frx),True);\n FillChar(fry,SizeOf(fry),True);\n for i := 1 to 8 do\n begin\n readln(x[i],y[i]);\n frx[x[i]] := False;\n fry[y[i]] := False;\n end;\n for i := 0 to maxXY do\n if not frx[i] then\n begin\n Inc(m1);\n x1[m1] := i;\n end;\n for i := 0 to maxXY do\n if not fry[i] then\n begin\n Inc(m2);\n y1[m2] := i;\n end;\n FillChar(fr,SizeOf(fr),True);\n if (m1 = 3) and (m2 = 3) then\n begin\n for i := 1 to 8 do\n for j := 1 to m1 do\n for k := 1 to m2 do\n if fr[i,k] and (x[i] = x1[j]) and (y[i] = y1[k]) then\n begin\n fr[i,k] := False;\n Inc(count);\n end;\n if fr[2,2] and (count = 8) then writeln('respectable')\n else writeln('ugly')\n end\n else writeln('ugly');\n close(input);\n close(output);\nend."}, {"source_code": "var\n x,y:array[0..1000000]of longint;\n xx,yy,a,b,i:longint;\n\n\n procedure No;\n begin\n writeln('ugly');\n halt;\n end;\n\n\nbegin\n for i:=1 to 8 do\n begin\n readln(a,b);\n inc(x[a]);\n inc(y[b]);\n end;\n for i:=0 to 1000000 do\n begin\n if (x[i]=1) or (x[i]>3) or (y[i]=1) or (y[i]>3) then No;\n if ((x[i]=2) and (xx<>1)) or ((y[i]=2) and (yy<>1)) then No;\n if x[i]=3 then inc(xx);\n if y[i]=3 then inc(yy);\n end;\n if (xx=2) and (yy=2) then writeln('respectable');\nend.\n\n"}, {"source_code": "var\n x,y:array[0..1000000]of longint;\n j,xx,yy,a,b,i:longint;\n\n\n procedure No;\n begin\n writeln('ugly');\n halt;\n end;\n\n\nbegin\n// assign(input,'a.in');reset(input);\n for i:=1 to 8 do\n begin\n readln(a,b);\n inc(x[a]);\n inc(y[b]);\n end;\n for i:=1 to 8 do for j:=i+1 to 8 do if (x[i]=x[j]) and (y[i]=y[j]) then No;\n for i:=0 to 1000000 do\n begin\n if (x[i]=1) or (x[i]>3) or (y[i]=1) or (y[i]>3) then No;\n if ((x[i]=2) and (xx<>1)) or ((y[i]=2) and (yy<>1)) then No;\n if x[i]=3 then inc(xx);\n if y[i]=3 then inc(yy);\n end;\n if (xx=2) and (yy=2) then writeln('respectable');\nend.\n\n"}, {"source_code": "program Pasha;\nVar n,i,j,f:longint;\n x,y:array[1..8]of longint;\n Begin\n for i:=1 to 8 do\n Read(x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n f:=x[i];\n x[i]:=x[j];\n x[j]:=f;\n f:=y[i];\n y[i]:=y[j];\n y[j]:=f\n end;\n if (x[1]=x[2])and(x[2]=x[3])and\n (x[4]=x[5])and(x[6]=x[7])and(x[7]=x[8])and\n (y[1]=y[4])and(y[4]=y[6])and\n (y[2]=y[7])and(y[3]=y[5])and(y[5]=y[8])then Write('respectable')\n else Write('ugly')\n End."}, {"source_code": "program Pasha;\nVar n,i,j,f:longint;\n x,y:array[1..8]of longint;\n Begin\n for i:=1 to 8 do\n Read(x[i],y[i]);\n for i:=1 to 7 do\n for j:=i+1 to 8 do\n if (x[i]>x[j])or((x[i]=x[j])and(y[i]>y[j])) then\n begin\n f:=x[i];\n x[i]:=x[j];\n x[j]:=f;\n f:=y[i];\n y[i]:=y[j];\n y[j]:=f\n end;\n for i:=1 to 8 do\n WriteLn(x[i],' ',y[i]);\n if (x[1]=x[2])and(x[2]=x[3])and\n (x[4]=x[5])and(x[6]=x[7])and(x[7]=x[8])and\n (y[1]=y[4])and(y[4]=y[6])and\n (y[2]=y[7])and(y[3]=y[5])and(y[5]=y[8])then Write('respectable')\n else Write('ugly')\n End."}, {"source_code": "Program EightPoinSets;\nConst fi='';\n fo='';\nvar f1,f2:text;\n min,mid,max,i,nho,j,b,c,min2,max2,mid2:longint;\n kq:boolean;\n a,t:array[1..3] of longint;\n d:array[1..2,1..8]of longint;\n e,f:array[0..1000000] of boolean;\n\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n nho:=1;\n kq:=true;\n fillchar(d,sizeof(d),false);\n a[1]:=-1;\n a[2]:=-1;\n a[3]:=-1;\n t[1]:=-1;\n t[2]:=-1;\n t[3]:=-1;\n for i:=1 to 8 do\n begin\n read(f1,b,c);\n d[1,i]:=b;\n d[2,i]:=c;\n for j:=1 to i-1 do\n begin\n if (d[1,j]=d[1,i])and(d[2,j]=d[2,i]) then kq:=false;\n end;\n for j:=1 to 3 do\n begin\n if (a[j]=-1)and (e[b]=false) then\n begin\n a[j]:=b;\n e[b]:=true;\n break;\n end;\n end;\n if (e[b]=false) then kq:=false;\n for j:=1 to 3 do\n begin\n if (t[j]=-1)and (f[c]=false) then\n begin\n t[j]:=c;\n f[c]:=true;\n break;\n end;\n end;\n if (f[c]=false) then kq:=false;\n\n end;\n if (a[1]=-1) or (a[2]=-1) or (a[3]=-1) or (t[1]=-1)or (t[1]=-1) or (t[1]=-1) then kq:=false;\n if kq=false then\n begin\n writeln(f2,'ugly');\n end;\n if kq=true then\n begin\n if (a[1]c then\n for j:=1 to 3 do\n begin\n if (a[j]=-1)and (e[c]=false) then\n begin\n a[j]:=c;\n e[c]:=true;\n break;\n end;\n end;\n if (e[c]=false) then kq:=false;\n\n end;\n if (a[1]=-1) or (a[2]=-1) or (a[3]=-1) then kq:=false;\n if kq=false then\n begin\n writeln(f2,'ugly');\n end;\n if kq=true then\n begin\n if (a[1]3 then exit(false);\n if vv<>3 then exit(false);\n for i:=1 to 3 do\n for j:=i+1 to 3 do if u[i]>u[j] then swap(u[i],u[j]);\n for i:=1 to 3 do\n for j:=i+1 to 3 do if v[i]>v[j] then swap(v[i],v[j]);\n for i:=1 to 8 do if (x[i]=u[2]) and (y[i]=v[2]) then exit(false);\n exit(true);\nend;\nbegin\n if main then writeln('respectable') else writeln('ugly');\nend.\n"}, {"source_code": "program probb;\nvar\n\ta:array[1..8,1..2] of longint;\n\ti,j,k,n,x,y:longint;\nbegin\n\tfor i:=1 to 8 do begin\n\t\treadln(a[i,1],a[i,2]);\n\t\tx:=x+a[i,1]; y:=y+a[i,2];\n\tend;\n\tx:=x div 8; y:=y div 8;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2])) then begin\n\t\t\t\tk:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=k;\n\t\t\t\tk:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=k;\n\t\t\tend;\n\tx:=a[4,1]; y:=a[2,2];\n\t{if ((a[4,1]-a[1,1])<>(a[6,1]-a[4,1])) then begin writeln('ugly'); exit; end;\n\tif ((x-a[2,1])<>(a[7,1]-x)) then begin writeln('ugly'); exit; end;\n\tif ((a[5,1]-a[3,1])<>(a[8,1]-a[5,1])) then begin writeln('ugly'); exit; end;}\n\tif (a[1,1]<>a[2,1])or(a[2,1]<>a[3,1]) then begin writeln('ugly'); exit; end;\n\tif (a[4,1]<>x)or(x<>a[5,1]) then begin writeln('ugly'); exit; end;\n\tif (a[6,1]<>a[7,1])or(a[7,1]<>a[8,1]) then begin writeln('ugly'); exit; end;\n\t\n\t{if ((a[2,2]-a[1,2])<>(a[3,2]-a[2,2])) then begin writeln('ugly'); exit; end;\n\tif ((y-a[4,2])<>(a[5,2]-y)) then begin writeln('ugly'); exit; end;\n\tif ((a[7,2]-a[6,2])<>(a[8,2]-a[7,2])) then begin writeln('ugly'); exit; end;}\n\tif (a[1,2]<>a[4,2])or(a[4,2]<>a[6,2]) then begin writeln('ugly'); exit; end;\n\tif (a[2,2]<>y)or(y<>a[7,2]) then begin writeln('ugly'); exit; end;\n\tif (a[3,2]<>a[5,2])or(a[5,2]<>a[8,2]) then begin writeln('ugly'); exit; end;\n\t\n\twriteln('respectable');\nend.\n"}, {"source_code": "program probb;\nvar\n\ta:array[1..8,1..2] of longint;\n\ti,j,k,n,x,y:longint;\nbegin\n\tfor i:=1 to 8 do begin\n\t\treadln(a[i,1],a[i,2]);\n\t\tx:=x+a[i,1]; y:=y+a[i,2];\n\tend;\n\tx:=x div 8; y:=y div 8;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2])) then begin\n\t\t\t\tk:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=k;\n\t\t\t\tk:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=k;\n\t\t\tend;\n\tif ((x-a[1,1])<>(x-a[2,1]))or((x-a[2,1])<>(x-a[3,1]))or((x-a[4,1])<>0)or((x-a[5,1])<>0)or((x-a[6,1])<>(x-a[7,1]))or((x-a[7,1])<>(x-a[8,1])) then begin writeln('ugly'); exit; end;\n\tif ((y-a[1,2])<>(y-a[4,2]))or((y-a[4,2])<>(y-a[6,2]))or((y-a[2,2])<>0)or((y-a[7,2])<>0)or((y-a[3,2])<>(y-a[5,2]))or((y-a[5,2])<>(y-a[8,2])) then begin writeln('ugly'); exit; end;\n\twriteln('respectable');\nend.\n"}, {"source_code": "program probb;\nvar\n\ta:array[1..8,1..2] of longint;\n\ti,j,k,n,x,y:longint;\nbegin\n\tfor i:=1 to 8 do begin\n\t\treadln(a[i,1],a[i,2]);\n\t\tx:=x+a[i,1]; y:=y+a[i,2];\n\tend;\n\tx:=x div 8; y:=y div 8;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2])) then begin\n\t\t\t\tk:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=k;\n\t\t\t\tk:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=k;\n\t\t\tend;\n\t{if ((a[4,1]-a[1,1])<>(a[6,1]-a[4,1])) then begin writeln('ugly'); exit; end;\n\tif ((x-a[2,1])<>(a[7,1]-x)) then begin writeln('ugly'); exit; end;\n\tif ((a[5,1]-a[3,1])<>(a[8,1]-a[5,1])) then begin writeln('ugly'); exit; end;}\n\tif (a[1,1]<>a[2,1])or(a[2,1]<>a[3,1]) then begin writeln('ugly'); exit; end;\n\tif (a[4,1]<>x)or(x<>a[5,1]) then begin writeln('ugly'); exit; end;\n\tif (a[6,1]<>a[7,1])or(a[7,1]<>a[8,1]) then begin writeln('ugly'); exit; end;\n\t\n\t{if ((a[2,2]-a[1,2])<>(a[3,2]-a[2,2])) then begin writeln('ugly'); exit; end;\n\tif ((y-a[4,2])<>(a[5,2]-y)) then begin writeln('ugly'); exit; end;\n\tif ((a[7,2]-a[6,2])<>(a[8,2]-a[7,2])) then begin writeln('ugly'); exit; end;}\n\tif (a[1,2]<>a[4,2])or(a[4,2]<>a[6,2]) then begin writeln('ugly'); exit; end;\n\tif (a[2,2]<>y)or(y<>a[7,2]) then begin writeln('ugly'); exit; end;\n\tif (a[3,2]<>a[5,2])or(a[5,2]<>a[8,2]) then begin writeln('ugly'); exit; end;\n\t\n\twriteln('respectable');\nend.\n"}, {"source_code": "program probb;\nvar\n\ta:array[1..8,1..2] of longint;\n\ti,j,k,n,x,y:longint;\nbegin\n\tfor i:=1 to 8 do begin\n\t\treadln(a[i,1],a[i,2]);\n\t\tx:=x+a[i,1]; y:=y+a[i,2];\n\tend;\n\tx:=x div 8; y:=y div 8;\n\tfor i:=1 to 7 do\n\t\tfor j:=i+1 to 8 do\n\t\t\tif (a[i,1]>a[j,1])or((a[i,1]=a[j,1])and(a[i,2]>a[j,2])) then begin\n\t\t\t\tk:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=k;\n\t\t\t\tk:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=k;\n\t\t\tend;\n\tif ((a[4,1]-a[1,1])<>(a[6,1]-a[4,1])) then begin writeln('ugly'); exit; end;\n\tif ((x-a[2,1])<>(a[7,1]-x)) then begin writeln('ugly'); exit; end;\n\tif ((a[5,1]-a[3,1])<>(a[8,1]-a[5,1])) then begin writeln('ugly'); exit; end;\n\tif (a[1,1]<>a[2,1])or(a[2,1]<>a[3,1]) then begin writeln('ugly'); exit; end;\n\tif (a[4,1]<>x)or(x<>a[5,1]) then begin writeln('ugly'); exit; end;\n\tif (a[6,1]<>a[7,1])or(a[7,1]<>a[8,1]) then begin writeln('ugly'); exit; end;\n\t\n\tif ((a[2,2]-a[1,2])<>(a[3,2]-a[2,2])) then begin writeln('ugly'); exit; end;\n\tif ((y-a[4,2])<>(a[5,2]-y)) then begin writeln('ugly'); exit; end;\n\tif ((a[7,2]-a[6,2])<>(a[8,2]-a[7,2])) then begin writeln('ugly'); exit; end;\n\tif (a[1,2]<>a[4,2])or(a[4,2]<>a[6,2]) then begin writeln('ugly'); exit; end;\n\tif (a[2,2]<>y)or(y<>a[7,2]) then begin writeln('ugly'); exit; end;\n\tif (a[3,2]<>a[5,2])or(a[5,2]<>a[8,2]) then begin writeln('ugly'); exit; end;\n\t\n\twriteln('respectable');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n x,y:array [1..8] of integer;\n i,j,t1,t2:integer;\n f:boolean;\nbegin\n {assign(Input,'in.txt');\n reset(Input);\n Assign(Output,'out.txt');\n Rewrite(Output); }\n for i:=1 to 8 do\n readln(x[i],y[i]);\n for i:= 1 to 7 do\n for j:=i+1 to 8 do\n if x[i]>x[j] then\n begin\n t1:=x[i];\n x[i]:=x[j];\n x[j]:=t1;\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n f:=true;\n if (x[1]<>x[2]) or (x[1]<>x[3])\n or (x[4]<>x[5])\n or (x[6]<>x[7]) or (x[6]<>x[8]) then f:=false;\n if f then\n begin\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if y[i]>y[j] then\n begin\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n\n if y[4]>y[5] then\n begin\n t2:=y[4];\n y[4]:=y[5];\n y[5]:=t2;\n end;\n\n for i:=6 to 7 do\n for j:=i+1 to 8 do\n if y[i]>y[j] then\n begin\n t2:=y[i];\n y[i]:=y[j];\n y[j]:=t2;\n end;\n f:= (y[1]=y[4]) and (y[1]=y[6])\n and (y[2]=y[7])\n and (y[3]=y[5]) and (y[3]=y[8]);\n end;\n if f then writeln ('respectable')\n else writeln('ugly');\n readln;\nend.\n"}, {"source_code": "program Project334b;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n X:array[1..8] of Integer;\n Y:array[1..8] of Integer;\n povt:array[1..8] of Byte;\n max,min,k,i,j:Integer;\n begin\n i:=1;\n while i<=8 do\n begin\n read(x[i]);\n Read(y[i]); readln;\n Inc(i);\n end;\n \n for i:=1 to 7 do\n begin\n min:=x[i];\n max:=y[i];\n for j:=i+1 to 8 do\n if min>x[j] then\n begin\n min:=x[j];\n max:=y[j];\n k:=j;\n x[k]:=x[i];\n x[i]:=min;\n y[k]:=y[i];\n y[i]:=max;\n end;\n\n end;\n k:=1;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[4]=x[5]) and (x[6]=x[7]) and (x[7]=x[8]) and (x[1]<>x[4]) and (x[1]<>x[8]) and (x[4]<>x[8]) then\n begin\n k:=0;\n\n max:=y[1];\n min:=y[1];\n for i:=1 to 5 do\n begin\n if y[i]max\n then max:=y[i];\n for j:=6 to 8 do\n if y[i]=y[j] then\n begin\n Inc(povt[i]);\n inc(povt[j]);\n end;\n end;\n\n for i:=1 to 5 do\n if povt[i]<>1\n then k:=1;\n for I:=6 to 8 do\n if povt[i]>2 then k:=1;\n if k=0 then\n begin\n if (y[4]=max) and (y[5]=min) then k:=0 else\n if (y[5]=max) and (y[4]=min) then k:=0 else k:=1;\n end;\n end;\n if k=0 then write('rspecteble') else write('ugly') ; Readln;\nend."}, {"source_code": "var\n X:array[1..8] of Integer;\n Y:array[1..8] of Integer;\n povt:array[1..8] of Byte;\n max,min,k,i,j:Integer;\n begin\n i:=1;\n while i<=8 do\n begin\n read(x[i]);\n Read(y[i]); readln;\n Inc(i);\n end;\n \n for i:=1 to 7 do\n begin\n min:=x[i];\n max:=y[i];\n for j:=i+1 to 8 do\n if min>x[j] then\n begin\n min:=x[j];\n max:=y[j];\n k:=j;\n x[k]:=x[i];\n x[i]:=min;\n y[k]:=y[i];\n y[i]:=max;\n end;\n\n end;\n k:=1;\n if (x[1]=x[2]) and (x[2]=x[3]) and (x[4]=x[5]) and (x[6]=x[7]) and (x[7]=x[8]) and (x[1]<>x[4]) and (x[1]<>x[8]) and (x[4]<>x[8]) then\n begin\n k:=0;\n\n max:=y[1];\n min:=y[1];\n for i:=1 to 5 do\n begin\n if y[i]max\n then max:=y[i];\n for j:=6 to 8 do\n if y[i]=y[j] then\n begin\n Inc(povt[i]);\n inc(povt[j]);\n end;\n end;\n\n for i:=1 to 5 do\n if povt[i]<>1\n then k:=1;\n for I:=6 to 8 do\n if povt[i]>2 then k:=1;\n if k=0 then\n begin\n if (y[4]=max) and (y[5]=min) then k:=0 else\n if (y[5]=max) and (y[4]=min) then k:=0 else k:=1;\n end;\n end;\n if k=0 then write('rspecteble') else write('ugly') ;\nend."}, {"source_code": " {$APPTYPE CONSOLE}\ntype int64=longint;\n const besk=100000000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar i,k,nn,n,i10,i100,n1,dl,kol,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,j,start,finish:longint;\nt,p,m1,pl,sum,p1,p2,m,k2,r,cc,ot,aa,bb,ka,kd,ll,rr,d1,d2,kolvyk,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,mnog,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndx,dy,b,a,c:array[-1000..200000] of int64;\n\nxx1,xx2,yy1,yy2,x1,x2,y1,y2,xx,yy,z1,z,x,y: array[-10..5000] of int64;\ngr1,gr: array[-50..1050,-50..1050] of int64;\na2,deg,marked:array[-100000..250000] of int64;\ndd:array[-10..5001,-10..5001] of longint;\n{ss:array[0..2000000] of char; }\nsss:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ur:int64):boolean; var p,i1,i2,i,j,k:longint; fl:boolean;\n begin\n fl:=false;\n for i:=1 to n do for j:=1 to m do if gr[i,j]>=ur then gr1[i,j]:=1 else gr1[i,j]:=0;\n for i1:=1 to n do for i2:=i1+1 to n do\n begin\n p:=0;\n for j:=1 to m do a[j]:=min(gr1[i1,j],gr1[i2,j]);\n for j:=1 to m do p:=p+a[j];\n if p>=2 then fl:=true;\n end;\n good:=fl;\n end;\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n\n for i:=1 to 8 do read(x[i],y[i]);\n for i:=1 to 8 do x[i]:=2000000*x[i]+y[i];\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do for j:=1 to 7 do if x[j]>x[j+1] then\n begin t:=x[j]; x[j]:=x[j+1]; x[j+1]:=t; end;\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do begin y[i]:=x[i] mod 2000000; x[i]:=x[i] div 2000000; end;\n\n{for i:=1 to 8 do writeln(x[i],' ',y[i]);\n}flag:=true;\nif (x[1]<>x[2])or(x[2]<>x[3]) then flag:=false;\nif (x[6]<>x[7])or(x[7]<>x[8]) then flag:=false;\nif x[4]<>x[5] then flag:=false;\n\nif (y[1]<>y[4])or(y[4]<>y[6]) then flag:=false;\nif (y[3]<>y[5])or(y[5]<>y[8]) then flag:=false;\nif y[2]<>y[7] then flag:=false;\n\nif flag then write('respectable' ) else write('ugly');\n\n 1: close(output);\n\nend.\n"}, {"source_code": " {$APPTYPE CONSOLE}\ntype int64=longint;\n const besk=100000000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar i,k,nn,n,i10,i100,n1,dl,kol,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,j,start,finish:longint;\nt,p,m1,pl,sum,p1,p2,m,k2,r,cc,ot,aa,bb,ka,kd,ll,rr,d1,d2,kolvyk,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nmon1,mon2,day1,day2,god1,god2,plus,kk,mnog,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndx,dy,b,a,c:array[-1000..200000] of int64;\n\nxx1,xx2,yy1,yy2,x1,x2,y1,y2,xx,yy,z1,z,x,y: array[-10..5000] of int64;\ngr1,gr: array[-50..1050,-50..1050] of int64;\na2,deg,marked:array[-100000..250000] of int64;\ndd:array[-10..5001,-10..5001] of longint;\n{ss:array[0..2000000] of char; }\nsss:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr,str :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ur:int64):boolean; var p,i1,i2,i,j,k:longint; fl:boolean;\n begin\n fl:=false;\n for i:=1 to n do for j:=1 to m do if gr[i,j]>=ur then gr1[i,j]:=1 else gr1[i,j]:=0;\n for i1:=1 to n do for i2:=i1+1 to n do\n begin\n p:=0;\n for j:=1 to m do a[j]:=min(gr1[i1,j],gr1[i2,j]);\n for j:=1 to m do p:=p+a[j];\n if p>=2 then fl:=true;\n end;\n good:=fl;\n end;\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\n\n for i:=1 to 8 do read(x[i],y[i]);\n for i:=1 to 8 do x[i]:=2000000*x[i]+y[i];\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do for j:=1 to 7 do if x[j]>x[j+1] then\n begin t:=x[j]; x[j]:=x[j+1]; x[j+1]:=t; end;\n{for i:=1 to 8 do write(x[i],' '); writeln;\n}for i:=1 to 8 do begin y[i]:=x[i] mod 2000000; x[i]:=x[i] div 2000000; end;\n\n{for i:=1 to 8 do writeln(x[i],' ',y[i]);\n}flag:=true;\nif (x[1]<>x[2])or(x[2]<>x[3]) then flag:=false;\nif (x[6]<>x[7])or(x[7]<>x[8]) then flag:=false;\nif x[4]<>x[5] then flag:=false;\n\nif (y[1]<>y[4])or(y[4]<>y[6]) then flag:=false;\nif (y[3]<>y[5])or(y[5]<>y[8]) then flag:=false;\nif y[2]<>y[7] then flag:=false;\n\nif (x[1]=x[4])or(x[4]=x[6]) then flag:=false;\nif (y[1]=y[2])or(y[2]=y[3]) then flag:=false;\n\nif flag then write('respectable' ) else write('ugly');\n\n 1: close(output);\n\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n x,y,a,b:Array[0..30] of Integer;\n used:Array[0..30,0..30] of Boolean;\n i,j,i1,j1,k1,i2,j2,k2,i3,j3,f,t,k:Integer;\nBegin\n For i:=1 To 8 Do Read(x[i],y[i]);\n For i1:=1 To 6 Do\n For j1:=i1+1 To 7 Do\n For k1:=j1+1 To 8 Do\n If (x[i1]<>x[j1]) and (x[j1]<>x[k1]) Then Begin\n For i2:=1 To 6 Do\n For j2:=i2+1 To 7 Do\n For k2:=j2+1 To 8 Do\n If (y[i2]<>y[j2]) and (y[j2]<>y[k2]) Then Begin\n For i:=1 To 8 Do\n For j:=1 To 8 Do used[i,j]:=false;\n a[1]:=x[i1];\n a[2]:=x[j1];\n a[3]:=x[k1];\n For i:=1 To 2 Do\n For j:=i+1 To 3 Do\n If a[i]>a[j] Then Begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n End;\n b[1]:=y[i2];\n b[2]:=y[j2];\n b[3]:=y[k2];\n For i:=1 To 2 Do\n For j:=i+1 To 3 DO\n If b[i]>b[j] Then Begin\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n End;\n f:=1;\n k:=0;\n For i:=1 To 8 Do\n For i3:=1 To 3 Do\n For j3:=1 To 3 Do\n If (x[i]=a[i3]) and (y[i]=b[j3]) Then Begin\n If ((i3=2) and (j3=2)) or (used[i3,j3]) Then f:=0;\n used[i3,j3]:=true;\n k:=k+1;\n End;\n If (f=1) or (k<>8) Then Begin\n Write('respectable');\n Halt;\n End;\n End;\n End;\n Write('ugly');\nEnd."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n x,y,a,b:Array[0..30] of Integer;\n used:Array[0..30,0..30] of Boolean;\n i,j,i1,j1,k1,i2,j2,k2,i3,j3,f,t:Integer;\nBegin\n For i:=1 To 8 Do Read(x[i],y[i]);\n For i1:=1 To 6 Do\n For j1:=i1+1 To 7 Do\n For k1:=j1+1 To 8 Do\n If (x[i1]<>x[j1]) and (x[j1]<>x[k1]) Then Begin\n For i2:=1 To 6 Do\n For j2:=i2+1 To 7 Do\n For k2:=j2+1 To 8 Do\n If (y[i2]<>y[j2]) and (y[j2]<>y[k2]) Then Begin\n For i:=1 To 8 Do\n For j:=1 To 8 Do used[i,j]:=false;\n a[1]:=x[i1];\n a[2]:=x[j1];\n a[3]:=x[k1];\n For i:=1 To 2 Do\n For j:=i+1 To 3 Do\n If a[i]>a[j] Then Begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n End;\n b[1]:=y[i2];\n b[2]:=y[j2];\n b[3]:=y[k2];\n For i:=1 To 2 Do\n For j:=i+1 To 3 DO\n If b[i]>b[j] Then Begin\n t:=b[i];\n b[i]:=b[j];\n b[j]:=t;\n End;\n f:=1;\n For i:=1 To 8 Do\n For i3:=1 To 3 Do\n For j3:=1 To 3 Do\n If (x[i]=a[i3]) and (y[i]=b[j3]) Then Begin\n If ((i3=2) and (j3=2)) or (used[i3,j3]) Then f:=0;\n used[i3,j3]:=true;\n End;\n If f=1 Then Begin\n Write('respectable');\n Halt;\n End;\n End;\n End;\n Write('ugly');\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\nvar mas: array [1..2, 1..8] of Integer;\n x,y,x1,x2, i,j,t : Integer;\n f: Boolean;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n f := False;\n for i:=1 to 8 do Readln(mas[1,i], mas[2,i]);\n for i:=8 downto 2 do\n for j:=1 to i-1 do\n if (mas[1,j]>mas[1,j+1]) or ((mas[1,j]=mas[1,j+1])and(mas[2,j]>mas[2,j+1])) then\n begin\n t:=mas[1,j]; mas[1, j]:=mas[1,j+1]; mas[1,j+1]:=t;\n t:=mas[2,j]; mas[2, j]:=mas[2,j+1]; mas[2,j+1]:=t;\n end;\n\n // for i:=1 to 8 do\n // writeln(mas[1,i], ' ', mas[2,i]);\n\n if (mas[1,1]=mas[1,2])and(mas[1,1]=mas[1,3]) then\n if (mas[1,4]=mas[1,5]) then\n if (mas[1,6]=mas[1,7])and(mas[1,6]=mas[1,8]) then\n if (mas[2,1]=mas[2,4]) and (mas[2,1]=mas[2,6]) then\n if (mas[2,2]=mas[2,7]) then\n if (mas[2,3]=mas[2,5])and(mas[2,3]=mas[2,8]) then f:=True;\n\n if f then Writeln('respectable') else writeln('ugly');\n\nend.\n"}], "src_uid": "f3c96123334534056f26b96f90886807"} {"source_code": "var\ts,h,m:ansistring;\n\tdem,a,h2,m2:longint;\nbegin\n\treadln(s);\n\th:=copy(s,1,2);\n\tm:=copy(s,4,2);\n\tif h[2]=m[1] then\n\t\tif h[1]=m[2] then\n\t\tbegin\n\t\t\twriteln(0);\n\t\t\thalt;\n\t\tend;\n\tval(h,h2,a);\n\tval(m,m2,a);\n\tdem:=0;\n\twhile ( (h2 mod 10)*10 + (h2 div 10) <> m2) do\n\tbegin\n\t\tinc(dem);\n\t\tinc(m2);\n\t\tif m2=60 then\n\t\tbegin\n\t\t\tinc(h2);\n\t\t\tm2:=0;\n\t\t\tif h2=24 then h2:=0;\n\t\tend;\n\tend;\n\twriteln(dem);\nend.", "positive_code": [{"source_code": "var a,b,code:longint;\n Sx,St:String;\n\nfunction kt(a,b:longint):longint;\nvar res:longint;\nbegin\n res:=0;\n repeat\n if b=a mod 10*10+a div 10 then break;\n inc(b);\n if b=60 then\n begin\n inc(a);\n if a=24 then a:=0;\n b:=0;\n end;\n inc(res);\n until res=0;\n exit(res); \nend;\n\nbegin\n readln(St);\n Sx:=copy(St,1,2);\n val(Sx,a,code);\n Sx:=copy(St,4,2);\n val(Sx,b,code);\n Writeln(kt(a,b));\nend.\n\n"}, {"source_code": "var time:string;\n\tm:integer;\nfunction palindrom(time:string):boolean;\nvar res:boolean;\nbegin\n\tres:=false;\n\tif (time[1] = time[5]) and (time[2] = time[4]) then\n\tres:=true;\n\tpalindrom:=res;\nend;\nBEGIN\n\treadln(time);\n\tm:=0;\n\twhile not(palindrom(time)) do\n\tbegin\n\t\tcase time[5] of\n\t\t\t'0':time[5]:='1';\n\t\t\t'1':time[5]:='2';\n\t\t\t'2':time[5]:='3';\n\t\t\t'3':time[5]:='4';\n\t\t\t'4':time[5]:='5';\n\t\t\t'5':time[5]:='6';\n\t\t\t'6':time[5]:='7';\n\t\t\t'7':time[5]:='8';\n\t\t\t'8':time[5]:='9';\n\t\t\t'9':begin\n\t\t\t\t\ttime[5]:='0';\n\t\t\t\t\tcase time[4] of\n\t\t\t\t\t\t'0':time[4]:='1';\n\t\t\t\t\t\t'1':time[4]:='2';\n\t\t\t\t\t\t'2':time[4]:='3';\n\t\t\t\t\t\t'3':time[4]:='4';\n\t\t\t\t\t\t'4':time[4]:='5';\n\t\t\t\t\t\t'5':begin\n\t\t\t\t\t\t\t\ttime[4]:='0';\n\t\t\t\t\t\t\t\tcase time[2] of\n\t\t\t\t\t\t\t\t\t'0':time[2]:='1';\n\t\t\t\t\t\t\t\t\t'1':time[2]:='2';\n\t\t\t\t\t\t\t\t\t'2':time[2]:='3';\n\t\t\t\t\t\t\t\t\t'4':time[2]:='5';\n\t\t\t\t\t\t\t\t\t'5':time[2]:='6';\n\t\t\t\t\t\t\t\t\t'6':time[2]:='7';\n\t\t\t\t\t\t\t\t\t'7':time[2]:='8';\n\t\t\t\t\t\t\t\t\t'8':time[2]:='9';\n\t\t\t\t\t\t\t\t\t'9':begin\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\t\tcase time[1] of\n\t\t\t\t\t\t\t\t\t\t\t\t'0':time[1]:='1';\n\t\t\t\t\t\t\t\t\t\t\t\t'1':time[1]:='2';\n\t\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t'3':if time[1]<'2' then time[2]:='4'\n\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\tbegin\t\n\t\t\t\t\t\t\t\t\t\t\ttime[1]:='0';\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tinc(m);\n\tend;\n\twriteln(m);\nEND.\n"}, {"source_code": "Var\n\t\n\tm, h: LongInt;\n\t\n\tresult: LongInt;\n\t\n\t\n\t\nProcedure getData();\n\t\n\tVar\n\t\t\n\t\ta: Char;\n\t\t\n\t\t\n\t\n\tBegin\n\t\t\n\t\tread(a);\n\t\t\n\t\th:= ord(a) - 48;\n\t\t\n\t\tread(a);\n\t\t\n\t\th:= h * 10 + ord(a) - 48;\n\t\t\n\t\tread(a);\n\t\t\n\t\tread(a);\n\t\t\n\t\tm:= ord(a) - 48;\n\t\t\n\t\tread(a);\n\t\t\n\t\tm:= m * 10 + ord(a) - 48;\n\t\t\n\tEnd;\n\n\n\t\nProcedure iterate();\n\t\n\tfunction palindrome(Const h, m: LongInt): Boolean;\n\t\t\n\t\tBegin\n\t\t\t\n\t\t\tIf (h div 10 = m mod 10) and (h mod 10 = m div 10) Then\n\t\t\tBegin\n\t\t\t\t\n\t\t\t\tpalindrome:= true;\n\t\t\t\t\n\t\t\tEnd\n\t\t\tElse\n\t\t\tBegin\n\t\t\t\t\n\t\t\t\tpalindrome:= false;\n\t\t\t\t\n\t\t\tEnd;\n\t\t\t\n\t\tEnd;\n\t\n\tBegin\n\t\t\n\t\tresult:= 0;\n\t\t\n\t\tWhile not palindrome(h, m) do\n\t\tBegin\n\t\t\t\n\t\t\tresult:= result + 1;\n\t\t\t\n\t\t\tm:= m + 1;\n\t\t\t\n\t\t\tIf m = 60 Then\n\t\t\tBegin\n\t\t\t\n\t\t\t\th:= h + 1;\n\t\t\t\t\n\t\t\t\tm:= 0;\n\t\t\t\t\n\t\t\tEnd;\n\t\t\t\n\t\t\tIf h = 24 Then\n\t\t\tBegin\n\t\t\t\t\n\t\t\t\th:= 0;\n\t\t\t\t\n\t\t\tEnd;\n\t\t\t\n\t\tEnd;\n\t\t\n\tEnd;\n\t\n\t\n\nBegin\n\t\n\tgetData();\n\t\n\titerate();\n\t\n\twriteLn(result);\n\t\nEnd."}, {"source_code": "Var t1,t2,t:string;\n e,f,c2,i,c,k:longint;\nbegin\n readln(t2);\n t1:=copy(t2,1,2);\n delete(t2,1,3);\n val(t2,c2,f);\n val(t1,c,f);\n t:='';\n for i:=length(t1)downto 1 do\n t:=t+t1[i];\n t1:=t;\n k:=0;\n if length(t1)<2 then t1:=t1+'0';\n while (t1<>t2) do\n begin\n c2:=c2+1;\n if c2=60 then begin\n c2:=0;\n c:=c+1;\n end;\n if c>23 then c:=0;\n str(c2,t2);\n str(c,t1);\n t:='';\n for i:=length(t1) downto 1 do\n t:=t+t1[i];\n t1:=t;\n if length(t1)<2 then t1:=t1+'0';\n if length(t2)<2 then t2:='0'+t2;\n k:=k+1;\n end;\n writeln(k);\nend.\n "}, {"source_code": "var\n n,i,j,ch1,min1,k ,e,l,m,r,b: longint;\n s,ch,min,z,p1,p2 : string;\nbegin\n b := 0;\n readln(s);\n for i := 1 to Length(s) do\n begin\n if s[i] = ':' then\n begin\n delete(s,i,1);\n break;\n end;\n end;\n ch := ch + s[1] + s[2];\n min := min + s[3] + s[4];\n val(ch,ch1,e);\n val(min,min1,e);\n s := '';\n s := s + ch + min;\n for j := 1 to (Length(s) div 2) do\n begin\n if s[j] = s[Length(s)-r] then\n begin\n inc(l);\n inc(r);\n end\n else\n break;\n end;\n if l = (Length(s) div 2)then\n begin\n writeln(k);\n exit;\n end;\n l := 0;\n r := 0;\n while m <> 7 do\n begin \n inc(min1);\n inc(k);\n if min1 = 60 then\n begin\n min := '00';\n min1 := 0;\n inc(ch1);\n end;\n if ch1 = 24 then\n begin\n ch := '00';\n ch1 := 0;\n end;\n str(ch1,p1);\n str(min1,p2);\n if ch1 < 10 then\n begin\n ch := '0' + p1;\n end\n else\n begin\n ch := p1;\n end;\n if min1 < 10 then\n begin\n min := '0' + p2;\n end\n else\n begin\n min := p2;\n end;\n z := z + ch + min;\n p1 := '';\n p2 := '';\n for j := 1 to (Length(z) div 2) do\n begin\n if z[j] = z[Length(z)-b] then\n begin\n inc(l);\n inc(b);\n end\n else\n begin\n break;\n b := 0;\n end;\n end;\n b := 0;\n if l = (Length(z) div 2)then\n begin\n writeln(k);\n exit;\n end;\n b := 0;\n l := 0;\n z := '';\n end;\n\nend."}, {"source_code": "var\nss,s:string;\nq,chh,mm,ans,ch,m:integer;\nbegin\nreadln(ss);\nch:=(ord(ss[1])-48)*10+ord(ss[2])-48;\nm:=(ord(ss[4])-48)*10+ord(ss[5])-48;\nif (ss[1]=ss[5])and(ss[2]=ss[4]) then writeln(0)\nelse begin\nif((ch=0)and(m>=0)) or((ch=1) and (m<=9)) then s:=('01:10')\nelse\nif ((ch=1)and(m>=10))or((ch=2)and(m<=19)) then s:=('02:20')\nelse\nif((ch=2)and(m>=20))or((ch=3)and(m<=29)) then s:=('03:30')\nelse\nif ((ch=3)and(m>=30))or((ch=4)and(m<=39)) then s:=('04:40')\nelse\nif((ch=4)and(m>=40))or((ch=5)and(m<=49)) then s:=('05:50')\nelse\nif (ch>=5)and(ch<=9) then s:=('10:01')\nelse\nif (ch=10)and(m<1) then s:=('10:01')\nelse\nif ((ch=10)and(m>=1))or((ch=11)and(m<=10)) then s:=('11:11')\nelse\nif ((ch=11)and(m>=11))or((ch=12)and(m<=20)) then s:=('12:21')\nelse\nif ((ch=12)and(m>=21))or((ch=13)and(m<=30)) then s:=('13:31')\nelse\nif ((ch=13)and(m>=31))or((ch=14)and(m<=40)) then s:=('14:41')\nelse\nif ((ch=14)and(m>=41)) or ((ch=15)and(m<=50)) then s:=('15:51')\nelse\nif (ch>=15)and(ch<=19) then s:=('20:02')\nelse\nif(ch=20)and(m<=1) then s:=('20:02')\nelse\nif ((ch=20)and(m>=2))or((ch=21)and(m<=11))then s:=('21:12')\nelse\nif((ch=21)and(m>=12))or((ch=22)and(m<=21)) then s:=('22:22')\nelse\nif ((ch=22)and(m>=22))or((ch=23)and(m<=31)) then s:=('23:32')\nelse\ns:=('00:00');\nchh:=(ord(s[1])-48)*10+ord(s[2])-48;\nmm:=(ord(s[4])-48)*10+ord(s[5])-48;\n\nwhile true do begin\n if (mm=m) then break\n else begin\n inc(ans);\n inc(m);\n m:=m mod 60;\n if m=0 then inc(ch);\n end;\nend;\nch:=ch mod 24;\nwhile true do begin\n if (ch=chh) then break\n else begin\n ans:=ans+60;\n inc(ch);\n ch:=ch mod 24;\n end;\nend;\n\nwriteln(ans);\n//writeln(s);\nend;\nend."}, {"source_code": "const fi='';\n fo='';\nvar c:array [1..5] of char;\n a:array [1..4] of longint;\n h,m:longint;\nfunction tim(a,b:longint):longint;\nvar x,y,z:longint;\nbegin\n y:=a;\n if a=24 then y:=0;\n x:=y mod 10;\n y:=y div 10;\n for z:=b to 59 do if z=10*x+y then exit(a*60+z-h*60-m);\n exit(tim(a+1,0));\nend;\nprocedure doc;\nvar i:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n for i:=1 to 5 do read(c[i]);\n val(c[1],a[1]);val(c[2],a[2]);val(c[4],a[3]);val(c[5],a[4]);\n h:=a[1]*10+a[2];m:=a[3]*10+a[4];\n write(tim(h,m));\n close(input);close(output);\nend;\nbegin\n doc;\nend.\n\n"}, {"source_code": "program qq;\nvar c,k,n:integer;\ns:string;\na:array [1..4] of integer;\nbegin\nread(s);\nval(s[5],a[4],c);\nval(s[4],a[3],c);\nval(s[2],a[2],c);\nval(s[1],a[1],c);\n\nwhile(a[1]<>a[4]) or (a[2]<>a[3]) do begin\n\na[4]:=a[4]+1;\nk:=k+1;\nif a[4]=10 then begin a[3]:=a[3]+1; a[4]:=0; end;\nif a[3]=6 then begin a[2]:=a[2]+1; a[3]:=0; end;\nif a[2]=10 then begin a[1]:=a[1]+1; a[2]:=0; end;\nif a[1]*10+a[2]=24 then begin a[1]:=0; a[2]:=0;\nend;\n//writeln(a[1],a[2],':',a[3],a[4]);\nend;\nwriteln(k);\nend."}, {"source_code": "var a,b,c,d,s,o:longint;strok:string;\nBEGIN\nreadln(strok);\nval(strok[1],a,o);\nval(strok[2],b,o);\nval(strok[4],c,o);\nval(strok[5],d,o);\nwhile (A<>D)or(b<>c) do\nbegin\nif (a=d)and(b=c)then break;\ns:=s+1;\nd:=d+1;\nif d=10 then begin d:=0;c:=c+1;end;\nif c=6 then begin c:=0;b:=b+1;end;\nif b=10 then begin b:=0;a:=a+1;end;\nif (a=2)and(b=4)then begin a:=0;b:=0;end;\nend;\nwriteln(s);\nend."}, {"source_code": "program force;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes\n { you can add units after this };\n var\n t:array[1..17] of string=('00:00','01:10','02:20','03:30','04:40','05:50'\n ,'10:01','11:11','12:21','13:31','14:41','15:51','20:02','21:12','22:22','23:32'\n ,'24:00') ;\n ch:string;\n i,indice,h1,hp1,h2,hp2,m1,mp1,mp2,m2,s:integer;\n ok:boolean;\n\nbegin\n readln(ch);\ni:=1;\nok:=true;\n while (i<=17) and (ok=true) do\n begin\n if t[i]>=ch then\n begin\n ok:=false;\n indice:=i;\n end\n else\n begin\n i:=i+1;\n end;\n end;\n\n\n\n\n hp1:=ord(ch[1])-ord('0');\n h1:=ord(t[indice][1])-ord('0');\n hp2:=ord(ch[2])-ord('0');\n h2:=ord(t[indice][2])-ord('0');\n mp1:=ord(ch[4])-ord('0');\n m1:=ord(t[indice][4])-ord('0');\n mp2:=ord(ch[5])-ord('0');\n m2:=ord(t[indice][5])-ord('0');\n if(10*m1+m2<10*mp1+mp2) then\n begin\n s:=60+10*m1+m2-10*mp1-mp2;\n s:=s+60*( 10*h1+h2-10*hp1-hp2-1);\n end\n else\n begin\n s:=10*m1+m2-10*mp1-mp2;\n s:=s+60*( 10*h1+h2-10*hp1-hp2);\n end;\nwriteln(s);\n\n\n readln;\n\nend.\n"}, {"source_code": "program O_O;\ntype\n ll=longint;\nvar\n a,b,c,d,n:ll;\n s:shortstring;\nbegin\n readln(s);\n n:=0;\n val(s[1],a);val(s[2],b);val(s[4],c);val(s[5],d);\n while (a<>d)or(b<>c)do\n begin\n inc(n);\n if d<9 then inc(d)\n else begin\n d:=0;\n if c<5 then inc(c)\n else begin\n c:=0;\n if (b<9)and(a<2) then inc(b)\n else if (b<3)and(a<3) then inc(b)\n else begin\n b:=0;\n if a<2 then inc(a)\n else begin\n a:=0;\n end;\n end;\n end;\n end;\n end;\n writeln(n);\nend."}, {"source_code": "var\n s : string;\n a,b,c,d,ans : longint;\n function ok(a,b : longint) : boolean;\n var\n a1,b1,c1,d1 : longint;\n begin\n ok:=false;\n a1:=a div 10;\n b1:=a mod 10;\n c1:=b div 10;\n d1:=b mod 10;\n if (b1=c1) and (a1=d1) then ok:=true;\n end;\nbegin\n readln(s);\n val(s[1],a);\n val(s[2],b);\n val(s[4],c);\n val(s[5],d);\n a:=a*10+b;\n c:=c*10+d;\n while not ok(a,c) do\n begin\n inc(ans);\n if c<59\n then inc(c)\n else begin\n dec(c,59);\n if a<23 then inc(a)\n else dec(a,23);\n end;\n end;\n writeln(ans);\nend."}, {"source_code": "var\nar:array[1..17] of longint=(0,70,140,210,280,350,601,671,741,811,881,951,1202,1272,1342,1412,1440);\ns,a,b:string;\ni,j,k,l:longint;\nbegin\n readln(s);\n a:=copy(s,1,2);\n b:=copy(s,4,2);\n val(a,i);val(b,j);\n k:=i*60+j;\n l:=1;\n while(ar[l]-k<0) do l:=l+1;\n writeln(ar[l]-k);\n\n\n //00:00 10:01 20:02\n //01:10 11:11 21:12\n //02:20 12:21 22:22\n //03:30 13:31 23:32\n //04:40 14:41\n //05:50 15:51\nend."}, {"source_code": "const fi='';\nvar\n t:string; res:int32;\n\nfunction palin(s:string):boolean;\nbegin\n exit( (s[1]=s[5]) and (s[2]=s[4]) );\nend;\nprocedure incr(var s:string);\nvar sh,sm:string; h,m:int32;\nbegin\n inc(res);\n h:= (ord(s[1])-ord('0'))*10+ord(s[2])-ord('0');\n m:= (ord(s[4])-ord('0'))*10+ord(s[5])-ord('0');\n inc(m);\n if m=60 then\n begin\n m:= 0; inc(h);\n end;\n if h=24 then h:= 0;\n str(h,sh);\n str(m,sm);\n if length(sh)=1 then sh:= '0'+sh;\n if length(sm)=1 then sm:= '0'+sm;\n s:= sh+':'+sm;\nend;\nprocedure print;\nbegin\n res:= 0;\n while not palin(t) do incr(t);\n write(res);\nend;\n\nbegin\n assign(input,fi); reset(input);\n read(t);\n print;\n close(input);\nend.\n"}, {"source_code": "var s,x:string;\n k,f,i,p,g,a,b:longint;\nbegin\nreadln(s);\nk:=0;\nf:=0;\nwhile f=0 do begin\np:=0;\nfor i:=1 to 2 do if (s[i]<>s[5-i+1])then p:=1;\nif p=0 then begin\nwriteln(k);\nf:=1;\nexit;\nend;\nval(copy(s,1,2),a,g);\nval(copy(s,4,2),b,g);\nb:=b+1;\nif b>=60 then begin\nb:=0;\na:=a+1;\nend;\nif A>=24 then a:=0;\ns:='';\nif a<10 then begin\nstr(a,x);\ns:='0'+x+':';\nend\nelse begin\nstr(a,x);\ns:=x+':';\nend;\nif b<10 then begin\nstr(b,x);\ns:=s+'0'+x;\nend\nelse begin\nstr(b,x);\ns:=s+x;\nend;\nk:=k+1;\nend;\nend."}, {"source_code": "var st:string;A:array[0..25] of string;kt:array[0..25] of boolean;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nfunction dao(st:string):string;\nvar s:string;i:longint;\nbegin\n s:='';\n for i:=length(st) downto 1 do\n s:=s+st[i];\n exit(s);\nend;\nprocedure nhap;\nvar s:string;i:longint;\nbegin\n readln(st);\n for i:=0 to 5 do kt[i]:=true;\n for i:=10 to 15 do kt[i]:=true;\n for i:=20 to 24 do kt[i]:=true;\n for i:=0 to 23 do\n begin\n str(i,s);\n if length(s)<=1 then s:='0'+s;\n S:=s+':'+dao(s);\n A[i]:=s;\n end;\n A[24]:=A[0];\nend;\nprocedure xuli;\nvar s,ss:string;n,code,i,x,y,dem:longint;\nbegin\n\n s:=copy(st,1,2);dem:=0;\n val(s,n,code);\n ss:=copy(A[n],pos(':',st)+1,2);\n s:=copy(st,pos(':',st)+1,2);\n val(s,x,code);\n val(ss,y,code);\n if (kt[n]=true) and(x<=y) then\n begin\n writeln(y-x);\n halt;\n end\n else\n begin\n inc(n);\n inc(dem); \n while not kt[n] do\n begin\n inc(n);\n inc(dem);\n end;\n\n\n ss:=copy(A[n],pos(':',st)+1,2);\n val(ss,y,code);\n writeln(y+60*dem-x);\nend;\n\nend;\nbegin\n //mo;\n nhap;\n xuli;\n //dong;\nend.\n\n"}, {"source_code": "var s,s1,s2:string;\ni,j,h,m,code,k,q:longint;\nbegin\nread(s);\ns1:=s[1]+s[2];\nval(s1,h,code);\ns1:=s[4]+s[5];\nval(s1,m,code);\nfor i:=h to 23 do\nfor j:=0 to 59 do begin\nstr(i,s2);\nif i<10 then s1:='0'+s2+':' else s1:=s2+':';\nstr(j,s2);\nif j<10 then s1:=s1+'0'+s2 else s1:=s1+s2;\ns2:='';\nfor q:=length(s1) downto 1 do\ns2:=s2+s1[q];\nif s1=s then k:=0;\nif (s2=s1)and(i>h) then begin writeln(k);exit;end;\nif (s2=s1)and(i=h)and(j>=m) then begin writeln(k);exit;end;\ninc(k);\nend;\nwriteln(k);\nEnd.\n\n"}, {"source_code": "const fi='816A.inp';\n fo='816A.out';\nvar s,x:string;\n h,m,i,kq,c,k:longint;\nfunction kt(h,m:longint):boolean;\n begin\n if (m mod 10)*10+m div 10=h then exit(true);\n exit(false);\n end;\nbegin\n\n readln(s);\n x:=s[1]+s[2];val(x,h,c);\n x:=s[4]+s[5];val(x,m,c);\n for i:=1 to 1000000 do\n if kt(h,m) then break\n else\n begin\n inc(m);\n if m=60 then m:=0;\n if m=0 then inc(h);\n if h=24 then h:=0;\n end;\n writeln(i-1);\nend.\n\n"}, {"source_code": "var s,z:string;\nmin,i,k,y,x,j:longint;\na:array [00..1000005] of longint;\nbegin\nmin:=maxlongint;\n readln(s);\n for i:=0 to 1 do\n for j:=0 to 5 do\n begin\n inc(k);\n a[k]:=(i*10+j)*60 + j*10+i;\n end;\n for i:=0 to 4 do\n begin\n inc(k);\n a[k]:=(2*10+i)*60 + i*10+2;\n end;\n for i:=0 to 1 do\n for j:=0 to 5 do\n begin\n inc(k);\n a[k]:=(i*10+j)*60 + j*10+i+1440;\n end;\n for i:=0 to 4 do\n begin\n inc(k);\n a[k]:=(2*10+i)*60 + i*10+2+1440;\n end;\n for i:=1 to 2 do\n z:=z+s[i];\n val(z,x);\n z:='';\n for i:=4 to 5 do\n z:=z+s[i];\n val(z,y);\n for i:=1 to k*2 do\n begin\n if ((a[i]-(x*60+y))=0) then min:=(a[i]-(x*60+y));\n end;\n write(min);\nend.\n\n"}, {"source_code": "var h,p,i,code,n,res,j,k:longint;\n cc,pp,s,ss,s1,ss1:string;\n\nbegin\nread(s);\nfor i:=1 to length(s) do\n begin\n if s[i]=':' then break else cc:=cc+s[i];\n end;\nval(cc,h,code);\nfor i:=i+1 to length(s) do\n begin\n pp:=pp+s[i];\n end;\nval(pp,p,code);\nfor i:=h to 23 do\n For j:=0 to 59 do\n begin\n if (i=h) and (jy do\n begin\n inc(m);\n inc(y); if y=60 then begin inc(z); y:=0; end;\n if z=24 then z:=0;\n x:=((z mod 10)*10)+(z div 10);\n end;\n\n writeln(m);\nend.\n\n"}, {"source_code": "var s,tg:string;\n t,tg1,k,ans:longint;\nfunction pali(n:string):boolean;\nvar i:longint;\n m:string;\nbegin\n for i:=length(n) downto 1 do if n[i]<>n[length(n)-i+1] then exit(false);\n exit(true);\nend;\nbegin\n read(s);\n while pali(s)=false do\n begin\n if (s[4]='5') and (s[5]='9') then\n begin\n delete(s,4,2);\n s:=s+'00';\n if (s[1]='2') and (s[2]='3') then begin delete(s,1,2); s:='00'+s; end else\n begin\n val(s[2],k,t);\n inc(k);\n if k=10 then\n begin\n val(s[1],tg1,t);\n inc(tg1);\n str(tg1,tg);\n delete(s,1,2);\n s:=tg+'0'+s;\n end else\n begin\n str(k,tg);\n delete(s,2,1);\n insert(tg,s,2);\n end;\n end;\n end\n else\n begin\n tg:=s[4]+s[5];\n delete(s,4,2);\n val(tg,k,t);\n inc(k);\n str(k,tg);\n if k<10 then tg:='0'+tg;\n s:=s+tg;\n\n end;\n\n inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const fi='';\n fo='';\n maxn=1000000;\n\nvar s,smin:string;\n b:array[1..maxn] of string;\n dem,min:longint;\nprocedure nhapdl;\nbegin\n readln(s);\n min:=0;\nend;\n\nprocedure xuly;\nvar i,j,c,t1,t2:longint;\n a,m:string;\nbegin\n\n a:='';\n for i:=0 to 23 do\n begin\n j:=i;\n str(j,a);\n if (length(a)=1) and (a[1] <= '5') then\n begin\n inc(dem);\n a:='0'+a+a[1]+'0';\n b[dem]:=a;\n end\n else if (a[2] <= '5') and (length(a)=2) then\n begin\n inc(dem);\n a:=a + a[2] + a[1];\n b[dem]:=a;\n end;\n a:='';\n end;\n delete(s,3,1);\n smin:='2400';\n for i:=1 to dem do\n if b[i] >= s then\n begin\n smin:=b[i];\n break;\n end;\n if s[1]='0' then delete(s,1,1);\n if smin[1]='0' then delete(smin,1,1);\n val(s,t1,c);\n val(smin,t2,c);\n if (t2 mod 100 - t1 mod 100) >= 0 then\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60\n else begin\n t2:=t2 - 40;\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;\n end;\n write(min);\n\nend;\n\nBEGIN\n assign(input, fi);reset(input);\n assign(output, fo);rewrite(output);\n nhapdl;\n xuly;\n close(input);close(output);\nEND.\n\n\n"}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif ((m>l) or ((m=l) and (c>j))) and (m2<>60) and (m2<>70) and (m2<>80) and (m2<>90) and (m2<>61) and (m2<>71) and (m2<>81) and (m2<>91) \nthen begin write(m2-m3);exit;end;\n\nk:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \n\n\nif k=6 then begin h:=h+60;k:=k+1;end;\nif k=7 then begin h:=h+60;k:=k+1;end;\nif k=8 then begin h:=h+60;k:=k+1;end;\nif k=9 then begin h:=h+60;k:=k+1;end;\nif k=16 then begin h:=h+60;k:=k+1;end;\nif k=17 then begin h:=h+60;k:=k+1;end;\nif k=18 then begin h:=h+60;k:=k+1;end;\nif k=19 then begin h:=h+60;k:=k+1;end;\n\nif k=0 then begin write(h);exit;end;\n\nh:=h+(k mod 10)*10+(k div 10);\nwrite(h);\nend."}, {"source_code": "const fi='';\n fo='';\n\nvar f,g:text;\ns:string;\nd:longint;\n\nfunction tang(s:string):string;\nvar h,m:longint;\nsh,sm:string;\nbegin\n\tsh:=s[1]+s[2];\n\tsm:=s[4]+s[5];\n\tval(sh,h);\n\tval(sm,m);\n\tinc(m);\n\th:=(h+(m div 60)) mod 24;\n\tm:=m mod 60;\n str(h,sh); if length(sh)=1 then sh:='0'+sh;\n str(m,sm); if length(sm)=1 then sm:='0'+sm;\n exit(sh+':'+sm);\nend;\n\nfunction palindrom(s:string):boolean;\nbegin\n\tif (s[1]=s[5]) and (s[2]=s[4]) then exit(true);\n\texit(false);\nend;\n\nbegin\n\tassign(f,fi);reset(f);\n\tassign(g,fo);rewrite(g);\n\treadln(f,s);\n\td:=0;\n\twhile not palindrom(s) do\n\t\tbegin\n\t\t\ts:=tang(s);\n\t\t\tinc(d);\n\t\tend;\n\twriteln(g,d);\n\tclose(f);\n\tclose(g);\nend.\n"}, {"source_code": "var st ,st2,st3,st4,s,s1,s2:string;\nn,k,m,h,i:longint;\nbegin\n readln(st);\n n:=length(st);\n for i:=n downto 1 do\n st2:=st2+st[i];\n if st=st2 then begin\n writeln(0);\n halt;\n end;\n s:=copy(st,1,2);\n val(s,h);\n s:=copy(st,4,2);\n val(s,m);\n if (h=23) and (m=59) then begin\n writeln(1);\n halt;\n end;\n\n while true do\n begin\n st3:='';\n st4:='';\n k:=k+1;\n m:=m+1;\n if m=60 then begin\n if h=23 then h:=0\n else h:=h+1;\n m:=0;\n end;\n if (h=23) and (m=59) then begin\n k:=k+1;\n writeln(k);\n halt;\n end;\n str(h,s1);\n str(m,s2);\n if m<10 then s2:='0'+s2;\n if h<10 then s1:='0'+s1;\n st3:=s1+s2;\n n:=length(st3);\n for i:=n downto 1 do\n st4:=st4+st3[i];\n if st4=st3 then begin\n writeln(k);\n halt;\n end;\n end;\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(t1,t2:longint):boolean;\n var s1,s2:string;\n begin\n str(t1,s1);\n str(t2,s2);\n if length(s1)=1 then s1:='0'+s1;\n if length(s2)=1 then s2:='0'+s2;\n if (s1[1]=s2[2]) and (s1[2]=s2[1]) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,t1,t2,res:longint;\n s1,s2,st:string;\n begin\n readln(fi,st);\n s1:=copy(st,1,2);\n s2:=copy(st,4,2);\n val(s1,t1);\n val(s2,t2);\n res:=0;\n while not check(t1,t2) do\n begin\n inc(res);\n inc(t2);\n if t2=60 then\n begin\n t2:=0;\n inc(t1);\n if t1=24 then t1:=0;\n end;\n end;\n write(fo,res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var h,m:string[2];\n c:char;\n s,e,r:string;\n i,a,b,ans:longint;\n x:boolean;\nbegin \n\treadln(h,c,m);\n\tval(h,a);\n\tval(m,b);\n\tans:=0;\n\tx:=false;\n\trepeat\n\t\tstr(a,e);\n\t\tif a<10 then e:='0'+e;\n\t\tstr(b,r);\n\t\tif b<10 then r:='0'+r;\n\t\ts:=e+r;\n\t\tx:=true;\n\t\tfor i:=1 to 2 do \n\t\tif s[i]<>s[5-i] then x:=false;\n\t\tif x=false then inc(ans);\n\t\tinc(b);\n\t\tif b=60 then \n\t\tbegin \n\t\t\tb:=0;\n\t\t\tinc(a);\n\t\t\tif a=24 then a:=0;\n\t\tend;\n\tuntil x;\n\twriteln(ans);\n\treadln;\nend.\n\t\n\t\t\t\n\t\t\t\n\t\t"}, {"source_code": "uses math;\nvar n,m,i,j,ans:longint;\n a:array[0..100100]of longint;\n s:string;\n flag:boolean;\n c1,c2,c3,c4,c5:char;\n\nfunction check:boolean;\nbegin if (c1+c2)=(c5+c4) then exit(true);exit(false);end;\n\nprocedure nx;\nbegin\n if c5 in ['0'..'8'] then c5:=chr(ord(c5)+1) else begin\n c5:='0';c4:=chr(ord(c4)+1);\n end;\n if c4='6' then begin\n c4:='0';\n if c2 in ['0'..'8'] then c2:=chr(ord(c2)+1) else begin\n C2:='0';c1:=chr(ord(c1)+1);\n end;\n end;\n if (c1='2')and(c2='4') then begin\n c1:='0';c2:='0';\n end;\nend;\n\nbegin\nreadln(c1,c2,c3,c4,c5);\nans:=0;\nwhile not check do begin inc(ans);nx;end;\nwriteln(ans);\nend.\n\n"}, {"source_code": "uses sysutils;\nvar s:ansistring;\na,b,i:longint;\nfunction test(a,b:longint):boolean;\nbegin\n test:=(a mod 10 = b div 10)and(a div 10 = b mod 10);\nend;\nbegin\n read(s);\n a:=strtoint(s[1]+s[2]);\n b:=strtoint(s[4]+s[5]);\n for i:=1 to 60*24 do begin\n if test(a,b) then begin\n write(i-1);\n exit;\n end;\n inc(b);\n a:=(a+(b div 60))mod 24;\n b:=b mod 60;\n end;\nend."}, {"source_code": "var st,s1,s2:string;\n so1,so2,i,j,code,d:longint;\nfunction kt(s:string):boolean;\nvar i:longint;\nbegin\n for i:=1 to length(s) div 2 do\n if s[i]<>s[length(s)+1-i] then exit(false);\n exit(true);\nend;\nbegin\n read(st);\n s1:=st[1]+st[2];\n s2:=st[4]+st[5];\n val(s1,so1,code);\n val(s2,so2,code);\n while so1<24 do begin\n while so2<60 do begin\n str(so1,s1);\n str(so2,s2);\n if length(s1)=1 then s1:='0'+s1;\n if s1='24' then s1:='00';\n if length(s2)=1 then s2:='0'+s2;\n st:=s1+':'+s2;\n inc(d);\n if kt(st) then begin\n write(d-1);\n halt;\n end;\n inc(so2);\n end;\n so2:=0;\n if so1=23 then so1:=0 else inc(so1);\n end;\nend."}, {"source_code": "var\n s : string;\n h1,h2,m1,m2,h,m,kol : longint;\n _ : integer;\n\n function prov(a,b : longint):boolean;\n var s1,s2 : string;\n begin\n str(a,s1);\n if length(s1)=1 then s1:='0'+s1;\n str(b,s2);\n if length(s2)=1 then s2:='0'+s2;\n if (s1[1]=s2[2]) and (s2[1]=s1[2]) then prov:=true else prov:=false;\n end;\n\nbegin\n readln(s);\n val(s[1],h1,_);\n val(s[2],h2,_);\n val(s[4],m1,_);\n val(s[5],m2,_);\n h:=h1*10+h2;\n m:=m1*10+m2;\n kol:=0;\n if prov(h,m) then writeln(0) else\n while true do\n begin\n inc(kol);\n inc(m);\n if m=60 then begin m:=0; inc(h); end;\n if h=24 then h:=0;\n if prov(h,m) then begin writeln(kol); halt; end;\n end;\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n s:string;\nfunction check(s:string):boolean;\nvar i:0..3;\nbegin\n for i:=1 to 2 do\n if (s[i]<>s[5-i+1]) then exit(false);\n exit(true);\nend;\nfunction plus(s:string):string;\nvar x:integer;\n s1:string;\nbegin\n val(s,x);\n inc(x);\n str(x,s1);\n if (length(s1)=1) then s1:='0'+s1;\n exit(s1);\nend;\nprocedure process;\nvar d:integer;\n x,y:string;\nbegin\n d:=0;\n while not(check(s)) do\n begin\n inc(d);\n x:=s[1]+s[2];y:=s[4]+s[5];\n if (y='59') then\n begin\n y:='00';\n if (x='23') then x:='00' else x:=plus(x);\n end\n else y:=plus(y);\n s:=x+':'+y;\n end;\n assign(f,fo);rewrite(F);\n writeln(f,d);\n close(F);\nend;\n\nbegin\n assign(f,fi);reset(f);\n read(f,s);\n close(F);\n process;\nend."}, {"source_code": "var\n ch1,ch2,ch3,ch4:char;\n t,t1,t2:longint;\nbegin\n read(ch1,ch2,ch3,ch3,ch4);\n t1:=(ord(ch1)-ord('0'))*10+ord(ch2)-ord('0');\n t2:=(ord(ch3)-ord('0'))*10+ord(ch4)-ord('0');\n t:=0;\n while true do\n begin\n inc(t);\n if (t1 div 10=t2 mod 10)and(t1 mod 10=t2 div 10)then\n begin\n writeln(t-1);\n halt;\n end;\n inc(t2);\n if t2>=60 then\n begin\n t2:=t2-60;\n inc(t1);\n end;\n if t1=24 then\n begin\n writeln(t);\n halt;\n end;\n end;\nend.\n"}, {"source_code": "var\nar:array[1..17] of longint=(0,70,140,210,280,350,601,671,741,811,881,951,1202,1272,1342,1412,1440);\ns,a,b:string;\ni,j,k,l:longint;\nbegin\n readln(s);\n a:=copy(s,1,2);\n b:=copy(s,4,2);\n val(a,i);val(b,j);\n k:=i*60+j;\n l:=1;\n while(ar[l]-k<0) do l:=l+1;\n writeln(ar[l]-k);\n\n\n //00:00 10:01 20:02\n //01:10 11:11 21:12\n //02:20 12:21 22:22\n //03:30 13:31 23:32\n //04:40 14:41\n //05:50 15:51\nend."}, {"source_code": "program zzz;\nvar \n kol:integer;\n s:string;\n h,m:array[1..2]of integer;\nbegin\nreadln(s);\nval(s[1],h[1]);\nval(s[2],h[2]);\nval(s[4],m[1]);\nval(s[5],m[2]);\nkol:=0;\nwhile (h[1]<>m[2]) or (h[2]<>m[1]) do\nbegin\n inc(kol);\n inc(m[2]);\n if m[2]=10 then begin\n m[2]:=0;\n inc(m[1]);\n end;\n if m[1]=6 then begin\n m[1]:=0;\n inc(h[2]);\n end;\n if (h[2]=10)and(h[1]<>2) then begin\n h[2]:=0;\n inc(h[1]);\n end;\n if (h[2]=4) and (h[1]=2) then begin\n h[2]:=0;\n h[1]:=0;\n end;\nend;\nwriteln(kol);\nend."}, {"source_code": "var s:string; a,b,c,t1,t2:longint;\nbegin\n readln(s);\n val(s[1],t1); val(s[2],t2);\n a:= t1 + t2*10;\n val(s[4],t1); val(s[5],t2);\n b:= t1*10 + t2 ;\n c:=0; \n while a<>b do begin\n\tinc(b);inc(c);\n\tif b=60 then begin inc(a,10); b:=0; \n\t if a mod 100 < 2 then a:=(a mod 100)+1;\n\tend;\n\tif a = 42 then a:=0;\n end;\n writeln(c);\nend."}, {"source_code": "var s,s1:string;\n k:integer;\nbegin\nreadln(s);\ns1:=s[1]+s[2];\nwhile (s[1] <> s[5]) or (s[2] <> s[4]) do begin\n if s[5]<'9' then s[5]:=succ(s[5])\n else if s[4]<'5' then \n begin\n s[4]:=succ(s[4]);\n s[5]:='0';\n end\n else \n begin\n s[5]:='0';\n s[4]:='0';\n if s1<'23' then if s[2]<'9' then begin s[2]:=succ(s[2]); s1:=s[1]+s[2]; end\n else begin s[2]:='0'; s[1]:=succ(s[1]); s1:=s[1]+s[2]; end\n \n else \n begin\n s1:='00';\n s[1]:='0'; \n s[2]:='0'; \n end\n end; \nk:=k+1;\nend;\nwrite(k);\nend.\n\n"}, {"source_code": "const fi='';\n n=5;\n fo='';\nvar s:shortstring;\n f:text;\nfunction palin(s:shortstring):boolean;\nbegin\n if (s[1]=s[5]) and (s[2]=s[4]) then exit(true);\n exit(false);\nend;\nfunction push(s:shortstring):shortstring;\nvar t1,t2:integer;\n u,l,h:shortstring;\n up:boolean;\nbegin\n t1:=(ord(s[1])-ord('0'))*10+ord(s[2])-ord('0');\n t2:=(ord(s[4])-ord('0'))*10+ord(s[5])-ord('0');\n inc(t2);\n if t1<=9 then u:='0' else u:='';\n up:=false;\n if t2>=60 then\n begin\n up:=true;\n l:='00';\n inc(t1);\n end;\n if t1>=10 then u:='';\n if t1>=24 then u:='00:' else\n begin\n str(t1,h);\n u:=u+h+':';\n end;\n if up then u:=u+l else\n if t2<=9 then\n begin\n str(t2,l);\n u:=u+'0'+l;\n end else\n begin\n str(t2,l);\n u:=u+l;\n end;\n exit(u);\nend;\nprocedure solve;\nvar res:integer;\nbegin\n res:=0;\n while not palin(s) do\n begin\n inc(res);\n s:=push(s);\n end;\n write(f,res);\nend;\nprocedure enter;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\n solve;\n close(f);\nend;\nbegin\n assign(f,fo);\n rewrite(f);\n enter;\n close(f);\nend.\n"}, {"source_code": "var\n s:string;\n h,m,i:longint;\n\nbegin\n readln(s);\n val(copy(s,1,2),h,i);\n val(copy(s,4,2),m,i);\n for i:=0 to 1440 do\n begin\n if ((h div 10)=(m mod 10))and\n ((h mod 10)=(m div 10))\n then break;\n inc(m);\n if m=60 then\n begin\n m:=0;\n inc(h)\n end;\n if h=24 then h:=0\n end;\n writeln(i)\nend."}, {"source_code": "var h,m,q,sum,i,j,n:longint;\n s:string;\nfunction qwe(x,y:longint):boolean;\nbegin\n if (x div 10=y mod 10)and(y div 10=x mod 10) then\n qwe:=true else\n qwe:=false;\nend;\nbegin\n readln(s);\n val(s[1]+s[2],h,q);\n val(s[4]+s[5],m,q);\n sum:=0;\n for i:=h to 23 do\n for j:=0 to 59 do\n if (qwe(i,j))and((not(i=h))or(not(j m) then exit(j - m);\n if (j < m) then exit(60 * 24 + j);\n end;\n if (i > h) then exit((i - h - 1) * 60 + ((60 - m) + j));\n if (i < h) then exit(60 * (24 - h - 1 + i) + (60 - m) + j);\nend;\n\nbegin\n read(s);\n val(copy(s, 1, 2), h, log);\n val(copy(s, 4, 2), m, log);\n\n res := maxint;\n for i := 0 to 23 do\n for j := 0 to 59 do\n begin\n if (palindromes(i, j)) then res := min(res, cal(i, j, h, m));\n end;\n\n write(res);\nend.\n"}, {"source_code": "uses math;\nvar s: string[5];\n i, j, h, m, log, res: LongInt;\n\nfunction palindromes(h, m: LongInt): Boolean;\nbegin\n if ((h mod 10 = m div 10) and (h div 10 = m mod 10)) then exit(true);\n exit(false);\nend;\n\nfunction cal(i, j, h, m: LongInt): LongInt;\nbegin\n if ((i = h) and (j = m)) then exit(0);\n if (i = h) then\n begin\n if (j > m) then exit(j - m);\n if (j < m) then exit(60 * 24 + j);\n end;\n if (i > h) then exit((i - h - 1) * 60 + ((60 - m) + j));\n if (i < h) then exit(60 * (24 - h - 1 + i) + (60 - m) + j);\nend;\n\nbegin\n read(s);\n val(copy(s, 1, 2), h, log);\n val(copy(s, 4, 2), m, log);\n\n res := maxint;\n for i := 0 to 23 do\n for j := 0 to 59 do\n begin\n if (palindromes(i, j)) then res := min(res, cal(i, j, h, m));\n end;\n\n write(res);\nend.\n"}, {"source_code": "program yan;\n var s:string; i,j,x,y,a,b,n,m:integer;\nbegin\n readln(s);\n val(s[1]+s[2],x,y); val(s[4]+s[5],a,y);\n while x<>(a mod 10)*10+(a div 10) do\n begin\n inc(a); inc(b);\n if a>59 then begin a:=0; inc(x); end;\n if x>23 then x:=0;\n end;\n write(b);\nend."}, {"source_code": "var s:string;\nbegin\n readln(s);\n if (s[1]=s[5]) and (s[2]=s[4]) then begin writeln(0); exit; end;\n{------------------------------------------------------------------------------------------------}\n if (s[1]='0') and (s[2]>='5') then\n begin \n if s[2]='5' then if ((ord(s[4])-48)*10+(ord(s[5])-48)>50) then begin writeln(601-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)); exit; end;\n if s[2]>'5' then begin writeln(601-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)); exit; end;\n end;\n if (s[1]='1') and (s[2]>='5') then\n begin \n if s[2]='5' then if ((ord(s[4])-48)*10+(ord(s[5])-48)>51) then begin writeln(1202-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-600); exit; end;\n if s[2]>'5' then begin writeln(1202-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-600); exit; end; \n end;\n if (s[1]='2') and (s[2]>='3') then\n begin \n if s[2]='3' then if ((ord(s[4])-48)*10+(ord(s[5])-48)>32) then begin writeln(1440-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-1200); exit; end;\n end;\n{------------------------------------------------------------------------------------------------}\n if ((ord(s[2])-48)*10+(ord(s[1])-48))>((ord(s[4])-48)*10+(ord(s[5])-48)) then\n writeln(((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)))\n else writeln(70+((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)));\nend.\n"}, {"source_code": "Program _816_A;\nconst finput='816_A.inp';\n foutput='816_A.out';\nvar h,m,cnt:longint;\n s:string;\nProcedure Nhap;\nvar code:longint;\nbegin\n //assign(input,finput);reset(input);\n //assign(output,foutput);rewrite(output);\n readln(s);\n Val(copy(s,1,2),h,code);\n Val(copy(s,4,2),m,code);\nend;\n\nFunction P(a,b:longint):boolean;\nvar h1,h2,m1,m2:longint;\nbegin\n h1:=h div 10;\n h2:=h mod 10;\n m1:=m div 10;\n m2:=m mod 10;\n if (h1=m2)and(h2=m1) then exit(true);\n exit(false);\nend;\n\nProcedure Xuli;\nbegin\n cnt:=0;\n while P(h,m)=false do\n begin\n inc(cnt);\n inc(m);\n if m=60 then\n begin\n inc(h);\n if h=24 then h:=0;\n m:=0;\n end;\n end;\nend;\n\nProcedure xuat;\nbegin\n write(cnt);\nend;\n\nbegin\n Nhap;\n Xuli;\n xuat;\nend."}, {"source_code": "uses sysutils;\nvar check1, check2, check3, check4:ansistring;\n\ts:string;\n\thour,minute,i:longint;\nbegin\n\t//assign(input,'816A.inp'); reset(input);\n\t//assign(output,'816A.out'); rewrite(output);\n\treadln(s);\n\thour:=strtoint(copy(s,1,2));\n\tminute:=strtoint(copy(s,4,2));\n\tfor i:=0 to 3000 do\n\tbegin\n\t\tcheck1:=inttostr(((hour mod 100)-( hour mod 10)) div 10);\n\t\tcheck2:=inttostr(hour mod 10);\n\t\tcheck3:=inttostr(((minute mod 100)- (minute mod 10)) div 10);\n\t\tcheck4:=inttostr(minute mod 10);\n\t\tif (check1=check4) and (check2=check3) then\n\t\tbegin\n\t\t\twrite(i);\n\t\t\tbreak;\n\t\tend;\n\t\tif minute<59 then inc(minute)\n\t\telse\n\t\tbegin\n\t\t\tminute:=0;\n\t\t\tif hour<23 then inc(hour) else hour:=0;\n\t\tend;\n\tend;\n\t//close(input); close(output);\nend.\n"}, {"source_code": "var\n h,m,ans:longint;\n h1,h2,m1,m2,ch:char;\n\nfunction check(h,m:longint):boolean;\nbegin\n exit((h div 10=m mod 10)and(h mod 10=m div 10));\nend;\n\nprocedure iinc;\nbegin\n inc(ans);\n m:=m+1;\n if m=60 then\n begin m:=0;inc(h);if h=24 then h:=0;end;\nend;\n\nbegin\n read(h1,h2,ch,m1,m2);\n h:=(ord(h1)-48)*10+ord(h2)-48;\n m:=(ord(m1)-48)*10+ord(m2)-48;\n while not check(h,m) do iinc;\n writeln(ans);\nend."}, {"source_code": "var s,hs,ms:string;\nh,m,k,err:integer;\nbegin\nread(s);\nhs:=copy(s,1,2);\nms:=copy(s,4,2);\nval(hs, h,err);\nval(ms,m,err);\n\nwhile (h mod 10<>m div 10)or(h div 10<> m mod 10) do begin\nk+=1;\nm+=1;\nif m=60 then begin m:=0; h+=1 end;\nif h=24 then h:=0;\n\nend;\nwriteln(k);\nend."}, {"source_code": "const fi='';\n fo='';\nvar h,m,r:longint;\nprocedure enter;\nvar s,t:string;\n code:longint;\nbegin\n assign(input,fi);\n reset(input);\n readln(s);\n t:=copy(s,1,2);\n val(t,h,code);\n t:=copy(s,4,2);\n val(t,m,code);\n close(input);\nend;\nfunction check:boolean;\nvar th,tm:string;\nbegin\n str(h,th);\n str(m,tm);\n if length(th)=1 then th:='0'+th;\n if length(tm)=1 then tm:='0'+tm;\n exit((th[1]=tm[2]) and (th[2]=tm[1]));\nend;\nprocedure solve;\nbegin\n r:=0;\n while not check do\n begin\n inc(m);\n if m=60 then\n begin\n inc(h);\n m:=0;\n end;\n if h=24 then h:=0;\n inc(r);\n end;\nend;\nprocedure print;\nbegin\n assign(output,fo);\n rewrite(output);\n write(r);\n close(output);\nend;\nbegin\n enter;\n solve;\n print;\nend."}, {"source_code": "var hh, mm, i, p : integer;\n s : string;\n\nbegin\n i := 0;\n readln(s);\n hh := (ord(s[1])-48)*10 + ord(s[2])-48;\n mm := (ord(s[4])-48)*10 + ord(s[5])-48;\n p := (hh mod 10)*10 + (hh div 10);\n while p <> mm do begin\n hh := (hh + (succ(mm) div 60)) mod 24;\n mm := succ(mm) mod 60;\n i := succ(i);\n p := (hh mod 10)*10 + (hh div 10);\n end;\n write(i);\nend."}, {"source_code": "Uses math;\nVar fi, fo: text;\n s, sh, sm: string;\n h, m, i, j, res: Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, s);\n\th:= (ord(s[1]) - 48)*10 + ord(s[2]) - 48;\n\tm:= (ord(s[4]) - 48)*10 + ord(s[5]) - 48;\n\tfor i:=h to 24 do\n\tbegin\n\t\tif i=24 then sh:= '00'\n\t\telse\n\t\t\tif (i div 10)=0 then sh:= '0' + chr(i+48)\n\t\t\telse str(i, sh);\n\t\tif i=h then\n\t\tbegin\n\t\t\tfor j:=m to 59 do\n\t\t\tbegin\n\t\t\t\tif j=60 then sm:= '00'\n\t\t\t\telse\n\t\t\t\t\tif (j div 10)=0 then sm:= '0' + chr(j+48)\n\t\t\t\t\telse str(j, sm);\n\t\t\t\tif (sh[1]+sh[2])=(sm[2]+sm[1]) then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, res);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\t\tinc(res);\n\t\t\tend;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tfor j:=0 to 59 do\n\t\t\tbegin\n\t\t\t\tif j=60 then sm:= '00'\n\t\t\t\telse\n\t\t\t\t\tif (j div 10)=0 then sm:= '0' + chr(j+48)\n\t\t\t\t\telse str(j, sm);\n\t\t\t\tif (sh[1]+sh[2])=(sm[2]+sm[1]) then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, res);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\t\tinc(res);\n\t\t\tend;\n\t\tend;\n\tend;\nEnd.\n"}, {"source_code": "var s:string;\nhours,minutes,code,time:integer;\nfunction pal(hours,minutes:integer):boolean;\n begin\n if hours = (minutes mod 10)*10 + (minutes div 10) then pal:=true else pal:=false;\n end;\nbegin\nreadln(s);\nval( copy(s,1,2), hours, code );\nval( copy(s,4,2), minutes, code );\nwhile not pal(hours,minutes) do\n begin\n if minutes=59 then\n begin\n if hours=23 then hours:=0\n else inc(hours);\n minutes:=0;\n end\n else inc(minutes);\n inc(time);\n end;\nwriteln(time);\nend."}, {"source_code": "var s,a,b:string;\n x,y,code,i,j,t,t1:longint;\n\nfunction dao(a:longint):longint;\n begin\n a:=a+(a mod 10) *100;\n a:=a div 10;\n exit(a);\n end;\nbegin\nreadln(s);\na:=s[1]+s[2];\nb:=s[length(s)-1]+s[length(s)];\nval(a,x,code);\nval(b,y,code);\nt:=dao(x);t1:=0;\nwhile y<>t do\n begin\n inc(y);\n inc(t1);\n IF y=60 then\n begin\n inc(x);\n y:=0;\n end;\n IF x=24 then\n begin\n x:=0;\n y:=0;\n end;\n t:=dao(x);\n end;\nwrite(t1);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n f:text;\n s:string;\nprocedure docfile;\nvar c:char;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s);\nend;\nfunction ct(x:string;y:integer):string;\nvar tmp,tmp1,tmp2,tmp3:longint; s1,s2:string;\nbegin\n s1:=x[1]+x[2];\n s2:=x[4]+x[5];\n val(s1,tmp);\n val(s2,tmp1);\n tmp2:=(tmp*60+tmp1+y)mod 1440;\n ct:='xx:xx';\n str(tmp2 div 60,s1);\n tmp3:=tmp2 - (tmp2 div 60)*60;\n if(tmp2 div 60 < 9) then\n begin\n ct[1]:='0';\n ct[2]:=chr(tmp2 div 60 +48);\n end else\n begin\n ct[1]:=s1[1];\n ct[2]:=s1[2];\n end;\n if(tmp3 = 0) then\n begin ct[4]:='0';ct[5]:='0'; end\n else if(tmp3 < 9 ) then\n begin\n ct[4]:='0'; ct[5]:=chr(tmp3+ord('0'));\n end else\n begin\n str(tmp3,s2);\n ct[4]:=s2[1];\n ct[5]:=s2[2];\n\n\n end;\nend;\nfunction pali(x:string):boolean;\nbegin\n if (x[1] = x[5]) and(x[2] = x[4]) then exit(true);\n exit(False);\nend;\nprocedure xl;\nvar i:longint; tmp:string;\nbegin\n if(pali(s)) then\n begin\n writeln(0);\n halt;\n end;\n for i:=1 to 1440 do\n begin\n tmp:=ct(s,i);\n if(pali(tmp)) then\n begin\n writeln(i);\n halt;\n end;\n end;\nend;\nbegin\n docfile;\n\n xl;\n\nend."}, {"source_code": "Var\n st:string;\n total:longint;\n\nProcedure Nhap;\nVar i:longint;\n begin\n Readln(St);\n End;\n\nProcedure Xuly;\nVar hh,mm:longint;\n h,m:string;\n Begin\n h:=st[1]+st[2];\n val(h,hh);\n h:=st[2]+st[1];\n m:=st[4]+st[5];\n val(m,mm);\n While h<>m do\n Begin\n mm:=mm+1;\n inc(total);\n If mm >= 60 then\n Begin\n mm:=mm mod 60;\n inc(hh);\n End;\n hh:=hh mod 24;\n str(mm,m);\n str(hh,h);\n If length(m)=1 then m:='0'+m;\n If length(h)=1 then h:='0'+h;\n h:=h+h[1];\n delete(h,1,1);\n End;\n Write(total);\n End;\n\nBegin\n Nhap;\n Xuly;\nEnd."}, {"source_code": "const fi='';\n fo='';\nvar st,h,m:string;\nprocedure openf;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\nprocedure closef;\nbegin\n close(input);\n close(output);\nend;\nprocedure solve;\nvar g,p,kq:longint;\nbegin\n readln(st);\n h:=st[1]+st[2];\n m:=st[4]+st[5];\n kq:=0;\n repeat\n if(h[1]=m[2]) and (h[2]=m[1]) then\n begin\n write(kq);\n break;\n end;\n inc(kq);\n val(m,p);\n inc(p);\n if p=60 then\n begin\n val(h,g);\n inc(g);\n if g=24 then h:='00'\n else\n begin\n str(g,h);\n if g<10 then h:='0'+h;\n end;\n m:='00';\n if (h='00') and (m='00') then\n begin\n write(kq);\n exit;\n end;\n end\n else\n begin\n str(p,m);\n if p<10 then m:='0'+m;\n end;\n until false;\nend;\nBEGIN\n openf;\n if (h='00') and (m='00') then write(0) else\n solve;\n closef;\nEND.\n\n\n\n"}, {"source_code": "const\n\tfi='';\n\tfo='';\n\nvar\n\ts:string;\n\th1,h2,m1,m2,t:longint;\n\nprocedure enter;\n var x:char;\n i:longint;\n\tbegin\n s:=' ';\n for i:=1 to 5 do\n begin\n\t\tread(x);\n s[i]:=x;\n end;\n readln;\n\tend;\n\nfunction check(s:string):boolean;\n\tvar x:longint;\n\tbegin\n\t\tx:=(ord(s[4])-48)*10 + ord(s[5])-48;\n\t\tif x>=60 then exit(false);\n\tend;\n\nprocedure solve;\n\tvar\n\t\ti,nho,c:longint;\n s2,x:string;\n\tbegin\n\t\ts2:='';\n\t\th1:=(ord(s[1])-48)*10 + ord(s[2])-48;\n\t\tm1:=(ord(s[4])-48)*10 + ord(s[5])-48;\n\t\th2:=h1;\n\t\t//\n\t\ts2:=s2+s[1];\n\t\ts2:=s2+s[2];\n s2:=s2+':';\n\t\ts2:=s2+s2[2];\n\t\ts2:=s2+s2[1];\n\t\twhile (s20 do\n begin\n\tenter;\n \tsolve;\n dec(t);\n end;\n close(input);\n close(output);\nend.\n"}, {"source_code": "const\n\tfi='';\n\tfo='';\n\nvar\n\ts:string;\n\th1,h2,m1,m2,t:longint;\n\nprocedure enter;\n var x:char;\n i:longint;\n\tbegin\n readln(s);\n while (s[1]=' ') do delete(s,1,1);\n\tend;\n\nfunction check(s:string):boolean;\n\tvar x:longint;\n\tbegin\n\t\tx:=(ord(s[4])-48)*10 + ord(s[5])-48;\n\t\tif x>=60 then exit(false);\n\tend;\n\nprocedure solve;\n\tvar\n\t\ti,nho,c:longint;\n s2,x:string;\n\tbegin\n\t\ts2:='';\n\t\th1:=(ord(s[1])-48)*10 + ord(s[2])-48;\n\t\tm1:=(ord(s[4])-48)*10 + ord(s[5])-48;\n\t\th2:=h1;\n\t\t//\n\t\ts2:=s2+s[1];\n\t\ts2:=s2+s[2];\n s2:=s2+':';\n\t\ts2:=s2+s2[2];\n\t\ts2:=s2+s2[1];\n\t\twhile (s20 do\n begin\n\tenter;\n \tsolve;\n dec(t);\n end;\n close(input);\n close(output);\nend.\n"}, {"source_code": "var\na,k,n,i,j,min,h,a1,a2:integer;\ninp:string;\nbegin\nmin:=0;\nh:=0;\nK:=0;\nread(inp);\nval(inp[1..2],h,a1);\nval(inp[4..5],min,a2);\n\nfor i:=1 to 999999 do\n begin\n\n if (min mod 10 = h div 10) and (h mod 10 = min div 10) then\n break;\n if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then\n min:=min+1; \n if min>59 then\n begin \n h:=h+1;\n min:=0;\n end;\n if h>23 then\n h:=0;\n end;\nmin:=h*60+min;\ni:=i-1;\n write(i);\n \nend."}, {"source_code": "var s0,s1,s2,s3,s4:string;\nh1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;\nbegin\n readln (s0);\n s1:=s0[1];\n s2:=s0[2];\n s3:=s0[4];\n s4:=s0[5];\n val(s1,h1,err);\n val(s2,h2,err);\n val(s3,m1,err);\n val(s4,m2,err);\n if (h1=m2) and (h2=m1) then min:=0\n else begin\n if (h1=2) and (h2=3) and (m1*10+m2>32)\n then\n min:=60-(m1*10+m2)\n else\n begin\n if (h2=5) and ((h2*10+h1)>(m1*10+m2))\n then min:= (h2*10+h1)-(m1*10+m2)\n else\n begin\n if h2>=5 then begin\n hp1:=h1+1;\n hp2:=0;\n end else\n if (m1n[length(n)-i+1] then exit(false);\n exit(true);\nend;\nbegin\n read(s);\n while pali(s)=false do\n begin\n if (s[4]='5') and (s[5]='9') then\n begin\n delete(s,4,2);\n s:=s+'00';\n if (s[1]='2') and (s[2]='3') then begin delete(s,1,2); s:='00'+s; end else\n begin\n val(s[2],k,t);\n inc(k);\n if k=10 then\n begin\n val(s[1],tg1,t);\n inc(tg1);\n str(tg1,tg);\n delete(s,1,2);\n s:=tg+'0'+s;\n end else\n begin\n str(k,tg);\n delete(s,2,1);\n insert(tg,s,2);\n end;\n end;\n end\n else\n begin\n tg:=s[4]+s[5];\n delete(s,4,2);\n val(tg,k,t);\n inc(k);\n str(k,tg);\n if k<10 then tg:='0'+tg;\n s:=s+tg;\n\n end;\n\n inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "var\n\th\t: array [1..5] of char;\n\tn\t: array [1..4] of integer;\n\ti\t: integer;\n\nfunction dif(a,b,c,d:integer): integer;\nbegin\n\tdif:=60+(b-c)*10+(a-d);\nend;\n\nfunction int(c: char): integer;\nbegin\n\tcase c of \n\t\t'1': int:=1;\n\t\t'2': int:=2;\n\t\t'3': int:=3;\n\t\t'4': int:=4;\n\t\t'5': int:=5;\n\t\t'6': int:=6;\n\t\t'7': int:=7;\n\t\t'8': int:=8;\n\t\t'9': int:=9;\n\t\t'0': int:=0;\n\tend;\nend;\n\t\nbegin\n\treadln(h);\n\tfor i:=1 to 4 do\n\tbegin\t\n\t\tif (i<3) then\n\t\t\tn[i]:=int(h[i])\n\t\telse\n\t\t\tn[i]:=int(h[i+1])\n\tend;\n\t\n\tif n[2] < 5 then \n\tbegin\n\t\tif n[2]5 then\n\t\twriteln ((9-n[2])*60+dif(n[1]+1,0,n[3],n[4]))\n\telse\n\t\tif n[2]=n[3] then\n\t\t\tif n[1]=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n if h=15 then\n begin\n t:=60-m;\n t:=t+60*4;\n t:=t+2;\n end\n else\n begin\n t:=60-m;\n inc(h);\n k:=(h mod 10)*10+(h div 10);\n t:=t+k;\n end;\n end;\n end\n else\n begin\n if h<10 then\n begin\n if h=5 then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n t:=60-m;\n t:=t+4*60;\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(10-h-1);\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(20-h-1);\n t:=t+2;\n end;\n end;\n\n end\n else\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else t:=60-m;\n end;\n writeln(t);\nend;\n\nbegin\n ///assign(input,'816_a.inp');reset(input);\n //assign(output,'816_a.out');rewrite(output);\n nhap;\n xuli;\nend.\n"}, {"source_code": "var\n s: string;\n i: integer;\n\nfunction iny(s: string): string;\nvar\n s1, s2: string;\n m, n: integer;\nbegin\n s1 := s[1] + s[2];\n s2 := s[4] + s[5];\n m := strtoint(s1);\n n := strtoint(s2);\n if(n = 59) then begin if(m + 1 = 24) then m := -1;if(length('' + (m + 1)) = 2) then begin iny := '' + (m + 1) + ':' + '00';n := 0; end else begin iny := '0' + (m + 1) + ':' + '00';n := 0; end end else\n begin\n n := n + 1;\n if(length('' + m) = 2)\n then\n s1 := '' + m\n else\n s1 := '0' + m;\n \n if(length('' + n) = 2) then \n iny := s1 + ':' + n \n else \n iny := s1 + ':' + '0' + n; \n \n end;\nend;\n\nbegin\n readln(s);i := 0;\n while(true) do \n begin\n if(s = reverseString(s)) then begin writeln(i);exit; end else s := iny(s);\n inc(i);\n end;\nend."}, {"source_code": "var a,x,b,c,d:longint;q,aa,cc,bb,dd:char;z:array['0'..'9']of longint;\nbegin\nz['0']:=0;\nfor q:='1' to '9' do\nz[q]:=1+z[pred(q)];\nread(aa,bb,q,cc,dd);\na:=z[aa];c:=z[cc];b:=z[bb];d:=z[dd];x:=0;\nwhile (A<>d)or(b<>c) do\nbegin\n inc(d);\n if d=10 then begin\n d:=0;inc(c);\n if c=6 then begin\n c:=0;inc(b);\n if 10*a+b=24 then begin a:=0;b:=0;end else if b=10\n then begin b:=0;inc(a);\n end;\n end;\nend;\ninc(x);\nend;\nwrite(x);\nend."}, {"source_code": "\n const nn=6000; nnn=2000;eps=0.000000001; besk1=200000008;\n label 1,2;\n type { real=double;} {string=ansistring;}\n\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pp,p4,kk,q,p3,hmin,hmax,p1,p2,l,r,pos,t,kolx,kolo,ot,nm,n,s1,s2,m,s,imax,smin,cen,dl,t2,p,prost,besk:int64;\n i1,j1,k,step, t1,ii,i,tt,j:longint;\n rr,xx,yy,time,aa,bb,cc:extended;\n sss:array[-10..10000] of char;\n sssnew:array[-10..1000] of char;\n ll,d,c,x,y,a,b:array[-100000..2000000] of int64;\n mask,dda,ddb:array[-10..120,-10..120] of int64;\n ss1,ss2:string;\n poten,potok,diam:array[-100..1000000] of extended;\n pole:array[-1..200,-1..200] of char;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx1,yy1:array[-1..nn] of double;\n yot:double;\n flag,flag1:boolean;\n matr:array[-10..200,-10..200] of extended;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction inttotime(t:longint):string;\nvar t1,t2,p1,p2,p3,p4,i,j:longint; s:string;\nbegin\n t:=t mod (60*24);\n s:='';\n t1:=t div 60;\n t2:=t mod 60;\n p1:=t1 div 10;\n p2:=t1 mod 10;\n p3:=t2 div 10;\n p4:=t2 mod 10;\n\n s:=s+chr(p1+48);\n s:=s+chr(p2+48);\n s:=s+':' ;\n s:=s+chr(p3+48);\n s:=s+chr(p4+48);\n\n\n inttotime:=s;\nend;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(ss);\n for i:=0 to 24*60 do if inttotime(i)=ss then p:=i;\n\n { writeln(p);\n } pp:=p;\n\n for i:=pp to pp+2000 do\n begin\n ss:=inttotime(i);\n { writeln(i,' ',ss);\n } if (ss[1]=ss[5])and(ss[2]=ss[4]) then\n begin t:=i; goto 2; end;\n\n end;\n 2:\n writeln(t-p);\n\n\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "var\nf1,f2:text;\nh,m,q,count:longint;\ns:string;\nbegin\nread(s);\nval(s[1]+s[2],h,q);\nval(s[4]+s[5],m,q);\ncount:=0;\nwhile (h mod 10<>m div 10) or (h div 10<>m mod 10) do\n begin\n inc(m);\n if m=60 then \n begin\n h:=h+1;\n m:=0;\n end;\n if h=24 then h:=0;\n inc(count);\n end;\nwrite(count);\nend."}, {"source_code": "var s,a,b:string;\n x,y,code,i,j,t,t1:longint;\n\nfunction dao(a:longint):longint;\n begin\n a:=a+(a mod 10) *100;\n a:=a div 10;\n exit(a);\n end;\nbegin\nreadln(s);\na:=s[1]+s[2];\nb:=s[length(s)-1]+s[length(s)];\nval(a,x,code);\nval(b,y,code);\nt:=dao(x);t1:=0;\nwhile y<>t do\n begin\n inc(y);\n inc(t1);\n IF y=60 then\n begin\n inc(x);\n y:=0;\n end;\n IF x=24 then\n begin\n x:=0;\n y:=0;\n end;\n t:=dao(x);\n end;\nwrite(t1);\nend."}, {"source_code": "var\n i,j,n,h,m,l,r,k,x:longint;\n flag,err:integer;\n p,p1:array [1..10000] of longint;\n c:char;\n s,s1,s2:string;\nbegin\n read(s);\n s1:=s[1]+s[2];\n s2:=s[4]+s[5];\n \n val(s1,h,err);\n val(s2,m,err);\nflag:=0;\ni:=0;\nwhile (flag=0) do begin\n str(h,s1);\n if (h<10) then s1:='0'+s1;\n str(m,s2);\n if (m<10) then s2:='0'+s2;\n s:=s2[2]+s2[1];\n if (s1=s) then \n flag:=1\n else begin\n i:=i+1;\n m:=m+1;\n if (m=60) then begin\n m:=0;\n h:=h+1;\n end;\n if (h=24) then h:=0;\n end;\nend;\nwriteln(i);\nend."}], "negative_code": [{"source_code": "var h,p,i,code,n,res,j,k:longint;\n cc,pp,s,ss,s1,ss1:string;\n\nbegin\nread(s);\nfor i:=1 to length(s) do\n begin\n if s[i]=':' then break else cc:=cc+s[i];\n end;\nval(cc,h,code);\nfor i:=i+1 to length(s) do\n begin\n pp:=pp+s[i];\n end;\nval(pp,p,code);\nfor i:=h to 23 do\n For j:=p to 59 do\n begin\n str(i,s);\n if i<10 then s:='0'+s;\n str(j,s1);\n if (j<10) then s1:='0'+s1;\n ss:=s+s1;\n ss1:='';\n for k:=length(ss) downto 1 do\n ss1:=ss1+ss[k];\n if ss=ss1 then\n begin\n res:=res+(i-h-1)*60+(60+j-p);\n writeln(res);\n halt;\n end;\n end;\nres:=res+(23-h)*60+60-p;\nwriteln(res);\nend.\n\n"}, {"source_code": "const fi='';\n fo='';\n maxn=1000000;\n\nvar s,smin:string;\n b:array[1..maxn] of string;\n dem,min:longint;\nprocedure nhapdl;\nbegin\n readln(s);\n min:=0;\nend;\n\nprocedure xuly;\nvar i,j,c,t1,t2:longint;\n a,m:string;\nbegin\n a:='';\n if s[1] + s[2]=s[2] + s[1] then exit;\n for i:=0 to 23 do\n begin\n j:=i;\n str(j,a);\n if (length(a)=1) and (a[1] <= '5') then\n begin\n inc(dem);\n a:='0'+a+a[1]+'0';\n b[dem]:=a;\n end\n else if (a[2] <= '5') and (length(a)=2) then\n begin\n inc(dem);\n a:=a + a[2] + a[1];\n b[dem]:=a;\n end;\n a:='';\n end;\n delete(s,3,1);\n smin:='2400';\n for i:=1 to dem do\n if b[i] > s then\n begin\n smin:=b[i];\n break;\n end;\n if s[1]='0' then delete(s,1,1);\n if smin[1]='0' then delete(smin,1,1);\n val(s,t1,c);\n val(smin,t2,c);\n if (t2 mod 100 - t1 mod 100) > 0 then\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60\n else begin\n t2:=t2 - 40;\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;\n end;\n write(min);\n\nend;\n\nBEGIN\n assign(input, fi);reset(input);\n assign(output, fo);rewrite(output);\n nhapdl;\n xuly;\n close(input);close(output);\nEND.\n\n\n"}, {"source_code": "const fi='';\n fo='';\n maxn=1000000;\n\nvar s,smin:string;\n b:array[1..maxn] of string;\n dem,min:longint;\nprocedure nhapdl;\nbegin\n readln(s);\n min:=0;\nend;\n\nprocedure xuly;\nvar i,j,c,t1,t2:longint;\n a,m:string;\nbegin\n a:='';\n for i:=0 to 23 do\n begin\n j:=i;\n str(j,a);\n if (length(a)=1) and (a[1] <= '5') then\n begin\n inc(dem);\n a:='0'+a+a[1]+'0';\n b[dem]:=a;\n end\n else if (a[2] <= '5') and (length(a)=2) then\n begin\n inc(dem);\n a:=a + a[2] + a[1];\n b[dem]:=a;\n end;\n a:='';\n end;\n delete(s,3,1);\n smin:='2400';\n for i:=1 to dem do\n if b[i] >= s then\n begin\n smin:=b[i];\n break;\n end;\n if s[1]='0' then delete(s,1,1);\n if smin[1]='0' then delete(smin,1,1);\n val(s,t1,c);\n val(smin,t2,c);\n if (t2 mod 100 - t1 mod 100) > 0 then\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60\n else begin\n t2:=t2 - 40;\n min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;\n end;\n write(min);\n\nend;\n\nBEGIN\n assign(input, fi);reset(input);\n assign(output, fo);rewrite(output);\n nhapdl;\n xuly;\n close(input);close(output);\nEND.\n\n\n"}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif ((m>l) or ((m=l) and (c>j))) and (m3<>59) then begin write(m2-m3);exit;end;\n\nk:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \n\n\nif k=6 then begin h:=h+60;k:=k+1;end;\nif k=7 then begin h:=h+60;k:=k+1;end;\nif k=8 then begin h:=h+60;k:=k+1;end;\nif k=9 then begin h:=h+60;k:=k+1;end;\nif k=16 then begin h:=h+60;k:=k+1;end;\nif k=17 then begin h:=h+60;k:=k+1;end;\nif k=18 then begin h:=h+60;k:=k+1;end;\nif k=19 then begin h:=h+60;k:=k+1;end;\n\nif k=0 then begin write(h);exit;end;\n\nh:=h+(k mod 10)*10+(k div 10);\nwrite(h);\nend."}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;\n\nif (l>=m) then k:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \nif k=0 then begin write(h);exit;end;\n\nh:=h+((m+1)*10+c);\nwrite(h);\nend."}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;\n\nif (l>=m) then k:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \n\n\nif k=6 then begin h:=h+60;k:=k+1;end;\nif k=7 then begin h:=h+60;k:=k+1;end;\nif k=8 then begin h:=h+60;k:=k+1;end;\nif k=9 then begin h:=h+60;k:=k+1;end;\n\nif k=0 then begin write(h);exit;end;\n\nh:=h+(k mod 10)*10+(k div 10);\nwrite(h);\nend."}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif (m>l) then begin write(m2-m3);exit;end;\n\nif (l>=m) then k:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \nif k=0 then begin write(h);exit;end;\n\nh:=h+((m+1)*10+c);\nwrite(h);\nend."}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;\n\nif (l>=m) then k:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \n\n\nif k=6 then begin h:=h+60;k:=k+1;end;\nif k=7 then begin h:=h+60;k:=k+1;end;\nif k=8 then begin h:=h+60;k:=k+1;end;\nif k=9 then begin h:=h+60;k:=k+1;end;\n\nif k=0 then begin write(h);exit;end;\n\nh:=h+(k div 10)+(k mod 10);\nwrite(h);\nend."}, {"source_code": "var\nm1,c1,k1,l1,j1:char;\nm,c,k,l,j,m3,m2,h:integer;\nbegin\nread(c1,m1,k1,l1,j1);\nc:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;\n\nif (m=l) and (c=j) then begin write(0);exit;end;\nm3:=l*10+j;m2:=m*10+c;\nif (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;\n\nif (l>=m) then k:=c*10+m+1;\nif k>23 then k:=0;\nh:=60-m3; \n\n\nif k=6 then begin h:=h+60;k:=k+1;end;\nif k=7 then begin h:=h+60;k:=k+1;end;\nif k=8 then begin h:=h+60;k:=k+1;end;\nif k=9 then begin h:=h+60;k:=k+1;end;\nif k=16 then begin h:=h+60;k:=k+1;end;\nif k=17 then begin h:=h+60;k:=k+1;end;\nif k=18 then begin h:=h+60;k:=k+1;end;\nif k=19 then begin h:=h+60;k:=k+1;end;\n\nif k=0 then begin write(h);exit;end;\n\nh:=h+(k mod 10)*10+(k div 10);\nwrite(h);\nend."}, {"source_code": "uses math;\nvar n,m,i,j,ans:longint;\n a:array[0..100100]of longint;\n s:string;\n flag:boolean;\n c1,c2,c3,c4,c5:char;\n\nfunction check:boolean;\nbegin if (c1+c2)=(c5+c4) then exit(true);exit(false);end;\n\nprocedure nx;\nbegin\n if c5 in ['0'..'8'] then c5:=chr(ord(c5)+1) else begin\n c5:='0';c4:=chr(ord(c4)+1);\n end;\n if c4='6' then begin\n c4:='0';c2:=chr(ord(c2)+1);\n end;\n if (c1='2')and(c2='4') then begin\n c1:='0';c2:='0';\n end;\nend;\n\nbegin\nreadln(c1,c2,c3,c4,c5);\nans:=0;\nwhile not check do begin inc(ans);nx;end;\nwriteln(ans);\nend.\n\n\n"}, {"source_code": "var st,s1,s2:string;\n so1,so2,i,j,code,d:longint;\nfunction kt(s:string):boolean;\nvar i:longint;\nbegin\n for i:=1 to length(s) div 2 do\n if s[i]<>s[length(s)+1-i] then exit(false);\n exit(true);\nend;\nbegin\n read(st);\n s1:=st[1]+st[2];\n s2:=st[4]+st[5];\n val(s1,so1,code);\n val(s2,so2,code);\n for i:=so1 to so1+1 do\n begin\n for j:=so2 to 59 do\n begin\n str(i,s1);\n str(j,s2);\n if length(s1)=1 then s1:='0'+s1;\n if s1='24' then s1:='00';\n if length(s2)=1 then s2:='0'+s2;\n st:=s1+':'+s2;\n inc(d);\n if kt(st) then begin\n write(d-1);\n halt;\n end;\n end;\n so2:=0;\n end;\nend."}, {"source_code": "var\nar:array[1..16] of longint=(70,140,210,280,350,601,671,741,811,881,951,1202,1272,1342,1412,1440);\ns,a,b:string;\ni,j,k,l:longint;\nbegin\n readln(s);\n a:=copy(s,1,2);\n b:=copy(s,4,2);\n val(a,i);val(b,j);\n k:=i*60+j;\n l:=1;\n while(ar[l]-k<0) do l:=l+1;\n writeln(ar[l]-k);\n\n\n //00:00 10:01 20:02\n //01:10 11:11 21:12\n //02:20 12:21 22:22\n //03:30 13:31 23:32\n //04:40 14:41\n //05:50 15:51\nend."}, {"source_code": "var\ts,h,m:ansistring;\n\ta,h2,m2,m3:longint;\n\nbegin\n\treadln(s);\n\th:=copy(s,1,2);\n\tm:=copy(s,4,2);\n\tif h[2]=m[1] then\n\t\tif h[1]=m[2] then\n\t\tbegin\n\t\t\twriteln(0);\n\t\t\thalt;\n\t\tend;\n\tval(h,h2,a);\n\tval(m,m2,a);\n\tm:='';\n\tm:=m+h[2];\n\tm:=m+h[1];\n\tval(m,m3,a);\n\tif m3>m2 then\n\tbegin\n\t\twriteln(m3-m2);\n\t\thalt;\n\tend;\n\tinc(h2);\n\tif h2=24 then h:='00' else str(h2,h);\n\tm:='';\n\tm:=m+h[2];\n\tm:=m+h[1];\n\tval(m,m3,a);\n\twriteln(60-m2+m3);\nend."}, {"source_code": "var\ts,h,m:ansistring;\n\ta,h2,m2,m3:longint;\n\nbegin\n\treadln(s);\n\th:=copy(s,1,2);\n\tm:=copy(s,4,2);\n\tif h[2]=m[1] then\n\t\tif h[1]=m[2] then\n\t\tbegin\n\t\t\twriteln(0);\n\t\t\thalt;\n\t\tend;\n\tval(h,h2,a);\n\tval(m,m2,a);\n\tm:='';\n\tm:=m+h[2];\n\tm:=m+h[1];\n\tval(m,m3,a);\n\tif m3>m2 then\n\tbegin\n\t\twriteln(m3-m2);\n\t\thalt;\n\tend;\n\tinc(h2);\n\tif h2=24 then h:='00';\n\tm:='';\n\tm:=m+h[2];\n\tm:=m+h[1];\n\tval(m,m3,a);\n\twriteln(60-m2+m3);\nend."}, {"source_code": "var h,m,q,sum,i,j,n:longint;\n s:string;\nfunction qwe(x,y:longint):boolean;\nbegin\n if (x div 10=y mod 10)and(y div 10=x mod 10) then\n qwe:=true else\n qwe:=false;\nend;\nbegin\n readln(s);\n val(s[1]+s[2],h,q);\n val(s[4]+s[5],m,q);\n sum:=0;\n for i:=h to 23 do\n for j:=0 to 59 do\n if (qwe(i,j))and((i=h)xor(j='5') and ((ord(s[4])-48)*10+(ord(s[5])-48)>50) then\n begin writeln(601-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)); exit; end;\n if (s[1]='1') and (s[2]>='5') and ((ord(s[4])-48)*10+(ord(s[5])-48)>51) then\n begin writeln(1202-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-600); exit; end;\n if (s[1]='2') and (s[2]>='3') and ((ord(s[4])-48)*10+(ord(s[5])-48)>32) then\n begin writeln(1440-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-1200); exit; end;\n if ((ord(s[2])-48)*10+(ord(s[1])-48))>((ord(s[4])-48)*10+(ord(s[5])-48)) then\n writeln(((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)))\n else writeln(70+((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)));\nend.\n"}, {"source_code": "var s:string;\nbegin\n readln(s);\n if (s[1]=s[5]) and (s[2]=s[4]) then begin writeln(0); exit; end;\n if (s[1]='0') and (s[2]>='5') and ((ord(s[2])-48)*10+(ord(s[1])-48)>60) then\n begin writeln(601-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)); exit; end;\n if (s[1]='1') and (s[2]>='5') and ((ord(s[2])-48)*10+(ord(s[1])-48)>60) then\n begin writeln(1202-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-600); exit; end;\n if (s[1]='2') and (s[2]>='3') and ((ord(s[2])-48)*10+(ord(s[1])-48)>60) then\n begin writeln(1440-(ord(s[2])-48)*60-(ord(s[4])-48)*10-(ord(s[5])-48)-1200); exit; end;\n if ((ord(s[2])-48)*10+(ord(s[1])-48))>((ord(s[4])-48)*10+(ord(s[5])-48)) then\n writeln(((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)))\n else writeln(70+((ord(s[2])-48)*10+(ord(s[1])-48))-((ord(s[4])-48)*10+(ord(s[5])-48)));\nend.\n"}, {"source_code": "var s:string; a,b,c,t1,t2:longint;\nbegin\n readln(s);\n val(s[1],t1); val(s[2],t2);\n a:= t1 + t2*10;\n val(s[4],t1); val(s[5],t2);\n b:= t1*10 + t2 ;\n c:=0; \n while a<>b do begin\n\tinc(b);inc(c);\n\tif b=60 then begin inc(a,10); b:=0; \n\t if a mod 100 = 0 then a:=(a div 100)+1;\n\tend;\n\tif a = 42 then a:=0;\n end;\n writeln(c);\nend."}, {"source_code": "var s: string[5];\n h, m, log: LongInt;\n\nfunction reverse(n: LongInt): LongInt;\nvar t, v: string;\n a: LongInt;\nbegin\n t := '';\n while (n > 0) do\n begin\n str(n mod 10, v);\n t := t + v;\n n := n div 10;\n end;\n val(t, a, log);\n if (a < 10) then a := a * 10;\n reverse := a;\nend;\n\nbegin\n read(s);\n val(copy(s, 1, 2), h, log);\n val(copy(s, 4, 2), m, log);\n\n if (h = 23) then\n begin\n if (m = 32) then write(0) else write(60 - m);\n halt;\n end;\n\n if (reverse(m) = h) then write(0)\n else\n begin\n if (m > reverse(h)) then\n write(reverse(h + 1) + (60 - m))\n else\n write(reverse(h) - m);\n end;\nend.\n"}, {"source_code": "Uses math;\nVar fi, fo: text;\n s, sh, sm: string;\n h, m, i, j, res: Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, s);\n\th:= (ord(s[1]) - 48)*10 + ord(s[2]) - 48;\n\tm:= (ord(s[4]) - 48)*10 + ord(s[5]) - 48;\n\tfor i:=h to 24 do\n\tbegin\n\t\tif i=24 then sh:= '00'\n\t\telse\n\t\t\tif (i div 10)=0 then sh:= '0' + chr(i+48)\n\t\t\telse str(i, sh);\n\t\tif i=h then\n\t\tbegin\n\t\t\tfor j:=m to 59 do\n\t\t\tbegin\n\t\t\t\tif j=60 then sm:= '00'\n\t\t\t\telse\n\t\t\t\t\tif (j div 10)=0 then sm:= '0' + chr(j+48)\n\t\t\t\t\telse str(j, sm);\n\t\t\t\tif (sh[1]+sh[2])=(sm[2]+sm[1]) then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, res);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\t\tinc(res);\n\t\t\tend;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tfor j:=0 to 59 do\n\t\t\tbegin\n\t\t\t\tif j=60 then sm:= '00'\n\t\t\t\telse\n\t\t\t\t\tif (j div 10)=0 then sm:= '0' + chr(j+48)\n\t\t\t\t\telse str(j, sm);\n\t\t\t\tif (sh[2]+sh[1])=(sm[2]+sm[1]) then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(fo, res);\n\t\t\t\t\tclose(fi); close(fo);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\t\tinc(res);\n\t\t\tend;\n\t\tend;\n\tend;\nEnd.\n"}, {"source_code": "const fi='';\n fo='';\nvar st,h,m:string;\nprocedure openf;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\nprocedure closef;\nbegin\n close(input);\n close(output);\nend;\nprocedure solve;\nvar g,p,kq:longint;\nbegin\n readln(st);\n h:=st[1]+st[2];\n m:=st[4]+st[5];\n kq:=0;\n repeat\n if(h[1]=m[2]) and (h[2]=m[1]) then\n begin\n write(kq);\n break;\n end;\n inc(kq);\n val(m,p);\n inc(p);\n if p=60 then\n begin\n val(h,g);\n inc(g);\n if g=24 then h:='00';\n m:='00';\n if (h='00') and (m='00') then\n begin\n write(kq);\n exit;\n end;\n end\n else\n begin\n str(p,m);\n if p <10 then m:='0'+m;\n end;\n\n until false;\nend;\nBEGIN\n openf;\n if (h='00') and (m='00') then write(0) else\n solve;\n closef;\nEND.\n\n\n\n"}, {"source_code": "var\na,k,n,i,j,min,h,a1,a2:integer;\ninp:string;\nbegin\nmin:=0;\nh:=0;\nK:=0;\nread(inp);\nval(inp[1..2],h,a1);\nval(inp[4..5],min,a2);\n\nfor i:=1 to 999999 do\n begin\n if (min mod 10 = min div 10) and (h mod 10 = h div 10) then\n break;\n if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then\n min:=min+1; \n if min>59 then\n begin \n // h:=h+1;\n min:=0;\n end;\n end;\n// min:=h*60+min;\n write(min);\nend."}, {"source_code": "var\na,k,n,i,j,min,h,a1,a2:integer;\ninp:string;\nbegin\nmin:=0;\nh:=0;\nK:=0;\nread(inp);\nval(inp[1..2],h,a1);\nval(inp[4..5],min,a2);\n\nfor i:=1 to 999999 do\n begin\n\n if (min mod 10 = h div 10) and (h mod 10 = min div 10) then\n break;\n if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then\n min:=min+1; \n if min>59 then\n begin \n h:=h+1;\n min:=0;\n end;\n end;\nmin:=h*60+min;\ni:=i-1;\n write(i);\n \nend."}, {"source_code": "var s0,s1,s2,s3,s4:string;\nh1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;\nbegin\n readln (s0);\n s1:=s0[1];\n s2:=s0[2];\n s3:=s0[4];\n s4:=s0[5];\n val(s1,h1,err);\n val(s2,h2,err);\n val(s3,m1,err);\n val(s4,m2,err);\n if (h1=m2) and (h2=m1) then min:=0\n else begin\n if h2>5 then begin\n hp1:=h1+1;\n hp2:=0;\n end else\n if (m132)\n then\n min:=60-(m1*10+m2)\n else\n begin\n if h2>=5 then begin\n hp1:=h1+1;\n hp2:=0;\n end else\n if (m15 then begin\n hp1:=h1+1;\n hp2:=0;\n end else\n if (m1<=h2) and (m232)\n then\n min:=60-(m1*10+m2)\n else\n begin\n if h2>5 then begin\n hp1:=h1+1;\n hp2:=0;\n end else\n if (m15 then\n\t\twriteln ((9-n[2])*60+dif(n[1]+1,0,n[3],n[4]))\n\telse\n\t\tif n[2]=n[3] then\n\t\t\tif n[1]=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n if h=15 then\n begin\n t:=60-m;\n t:=t+60*4;\n t:=t+2;\n end\n else\n begin\n t:=60-m;\n inc(h);\n k:=(h mod 10)*10+(h div 10);\n t:=t+k;\n end;\n end;\n end\n else\n begin\n if h<10 then\n begin\n if h=5 then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n t:=60-m;\n t:=t+4*60;\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=60*(10-h-1);\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(20-h-10);\n t:=t+2;\n end;\n end;\n\n end\n else\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else t:=60-m;\n end;\n writeln(t);\nend;\n\nbegin\n //assign(input,'816_a.inp');reset(input);\n //assign(output,'816_a.out');rewrite(output);\n nhap;\n xuli;\nend.\n"}, {"source_code": "var m,h:longint;\n\nprocedure nhap;\nvar code:longint;\n s:string;\nbegin\n readln(s);\n val(copy(s,1,2),h,code);\n val(copy(s,4,2),m,code);\nend;\n\nprocedure xuli;\nvar k:longint;\n t:longint;\nbegin\n if h<23 then\n begin\n if (h<16) or (h>=20) then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n if h=15 then\n begin\n t:=60-m;\n t:=t+60*4;\n t:=t+2;\n end\n else\n begin\n t:=60-m;\n inc(h);\n k:=(h mod 10)*10+(h div 10);\n t:=t+k;\n end;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(20-h-1);\n t:=t+2;\n end;\n\n end\n else\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else t:=60-m;\n end;\n writeln(t);\nend;\n\nbegin\n //assign(input,'816_a.inp');reset(input);\n //assign(output,'816_a.out');rewrite(output);\n nhap;\n xuli;\nend.\n"}, {"source_code": "var m,h:longint;\n\nprocedure nhap;\nvar code:longint;\n s:string;\nbegin\n readln(s);\n val(copy(s,1,2),h,code);\n val(copy(s,4,2),m,code);\nend;\n\nprocedure xuli;\nvar k:longint;\n t:longint;\nbegin\n if h<23 then\n begin\n if (h<16) or (h>=20) then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n if h=15 then\n begin\n t:=60-m;\n t:=t+60*4;\n t:=t+2;\n end\n else\n begin\n t:=60-m;\n inc(h);\n k:=(h mod 10)*10+(h div 10);\n t:=t+k;\n end;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(20-h-1);\n t:=t+2;\n end;\n\n end\n else t:=60-m;\n writeln(t);\nend;\n\nbegin\n //assign(input,'816_a.inp');reset(input);\n //assign(output,'816_a.out');rewrite(output);\n nhap;\n xuli;\nend.\n"}, {"source_code": "var m,h:longint;\n\nprocedure nhap;\nvar code:longint;\n s:string;\nbegin\n readln(s);\n val(copy(s,1,2),h,code);\n val(copy(s,4,2),m,code);\nend;\n\nprocedure xuli;\nvar k:longint;\n t:longint;\nbegin\n if h<23 then\n begin\n if ((h>=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n if h=15 then\n begin\n t:=60-m;\n t:=t+60*4;\n t:=t+2;\n end\n else\n begin\n t:=60-m;\n inc(h);\n k:=(h mod 10)*10+(h div 10);\n t:=t+k;\n end;\n end;\n end\n else\n begin\n if h<10 then\n begin\n if h=5 then\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else\n begin\n t:=60-m;\n t:=t+4*60;\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(10-h-1);\n t:=t+1;\n end;\n end\n else\n begin\n t:=60-m;\n t:=t+60*(20-h-10);\n t:=t+2;\n end;\n end;\n\n end\n else\n begin\n k:=(h mod 10)*10+(h div 10);\n if m<=k then t:=k-m\n else t:=60-m;\n end;\n writeln(t);\nend;\n\nbegin\n //assign(input,'816_a.inp');reset(input);\n //assign(output,'816_a.out');rewrite(output);\n nhap;\n xuli;\nend.\n"}, {"source_code": "var f1,f2:text;\n st,sh,sm,dx:string;\n x,y,er,m:integer;\nbegin\n assign(f1,'');\n reset(f1); readln(f1,st); close(f1);\n\n sh:= copy(st,1,2); sm:= copy(st,4,2); dx:= sh[2]+sh[1];\n val(dx,x,er); val(sm,y,er);\n if x>=y then m:=x-y else\n begin\n x:=x+10;\n if x=42 then x:=0;\n m:= (60-y)+x;\n end;\n assign(f2,'');\n rewrite(f2);\n writeln(f2,m);\n close(f2);\nend.\n\n"}, {"source_code": "var time:string;\n\tm:integer;\nfunction palindrom(time:string):boolean;\nvar res:boolean;\nbegin\n\tres:=false;\n\tif (time[1] = time[5]) and (time[2] = time[4]) then\n\tres:=true;\n\tpalindrom:=res;\nend;\nBEGIN\n\treadln(time);\n\tm:=0;\n\twhile not(palindrom(time)) do\n\tbegin\n\t\tcase time[5] of\n\t\t\t'0':time[5]:='1';\n\t\t\t'1':time[5]:='2';\n\t\t\t'2':time[5]:='3';\n\t\t\t'3':time[5]:='4';\n\t\t\t'4':time[5]:='5';\n\t\t\t'5':time[5]:='6';\n\t\t\t'6':time[5]:='7';\n\t\t\t'7':time[5]:='8';\n\t\t\t'8':time[5]:='9';\n\t\t\t'9':begin\n\t\t\t\t\ttime[5]:='0';\n\t\t\t\t\tcase time[4] of\n\t\t\t\t\t\t'0':time[4]:='1';\n\t\t\t\t\t\t'1':time[4]:='2';\n\t\t\t\t\t\t'2':time[4]:='3';\n\t\t\t\t\t\t'3':time[4]:='4';\n\t\t\t\t\t\t'4':time[4]:='5';\n\t\t\t\t\t\t'5':begin\n\t\t\t\t\t\t\t\ttime[4]:='0';\n\t\t\t\t\t\t\t\tcase time[2] of\n\t\t\t\t\t\t\t\t\t'0':time[2]:='1';\n\t\t\t\t\t\t\t\t\t'1':time[2]:='2';\n\t\t\t\t\t\t\t\t\t'2':time[2]:='3';\n\t\t\t\t\t\t\t\t\t'4':time[2]:='5';\n\t\t\t\t\t\t\t\t\t'5':time[2]:='6';\n\t\t\t\t\t\t\t\t\t'6':time[2]:='7';\n\t\t\t\t\t\t\t\t\t'7':time[2]:='8';\n\t\t\t\t\t\t\t\t\t'8':time[2]:='9';\n\t\t\t\t\t\t\t\t\t'9':begin\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\t\tcase time[1] of\n\t\t\t\t\t\t\t\t\t\t\t\t'0':time[1]:='1';\n\t\t\t\t\t\t\t\t\t\t\t\t'1':time[1]:='2';\n\t\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t'3':if time[1]<'2' then time[2]:='4'\n\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\tbegin\t\n\t\t\t\t\t\t\t\t\t\t\ttime[1]:='0';\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tinc(m);\n\t\twriteln(time);\n\tend;\n\twriteln(m);\nEND.\n"}, {"source_code": "var time:string;\n\tm:integer;\nfunction palindrom(time:string):boolean;\nvar res:boolean;\nbegin\n\tres:=false;\n\tif (time[1] = time[5]) and (time[2] = time[4]) then\n\tres:=true;\n\tpalindrom:=res;\nend;\nBEGIN\n\treadln(time);\n\tm:=0;\n\twhile not(palindrom(time)) do\n\tbegin\n\t\tcase time[5] of\n\t\t\t'0':time[5]:='1';\n\t\t\t'1':time[5]:='2';\n\t\t\t'2':time[5]:='3';\n\t\t\t'3':time[5]:='4';\n\t\t\t'4':time[5]:='5';\n\t\t\t'5':time[5]:='6';\n\t\t\t'6':time[5]:='7';\n\t\t\t'7':time[5]:='8';\n\t\t\t'8':time[5]:='9';\n\t\t\t'9':begin\n\t\t\t\t\ttime[5]:='0';\n\t\t\t\t\tcase time[4] of\n\t\t\t\t\t\t'0':time[4]:='1';\n\t\t\t\t\t\t'1':time[4]:='2';\n\t\t\t\t\t\t'2':time[4]:='3';\n\t\t\t\t\t\t'3':time[4]:='4';\n\t\t\t\t\t\t'4':time[4]:='5';\n\t\t\t\t\t\t'5':begin\n\t\t\t\t\t\t\t\ttime[4]:='0';\n\t\t\t\t\t\t\t\tcase time[2] of\n\t\t\t\t\t\t\t\t\t'0':time[2]:='1';\n\t\t\t\t\t\t\t\t\t'1':time[2]:='2';\n\t\t\t\t\t\t\t\t\t'2':time[2]:='3';\n\t\t\t\t\t\t\t\t\t'3':if time[1]<'2' then time[2]:='0'\n\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\tbegin\t\n\t\t\t\t\t\t\t\t\t\t\ttime[1]:='0';\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t'4':time[2]:='5';\n\t\t\t\t\t\t\t\t\t'5':time[2]:='6';\n\t\t\t\t\t\t\t\t\t'6':time[2]:='7';\n\t\t\t\t\t\t\t\t\t'7':time[2]:='8';\n\t\t\t\t\t\t\t\t\t'8':time[2]:='9';\n\t\t\t\t\t\t\t\t\t'9':begin\n\t\t\t\t\t\t\t\t\t\t\ttime[2]:='0';\n\t\t\t\t\t\t\t\t\t\t\tcase time[1] of\n\t\t\t\t\t\t\t\t\t\t\t\t'0':time[1]:='1';\n\t\t\t\t\t\t\t\t\t\t\t\t'1':time[1]:='2';\n\t\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\tend;\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\tend;\n\t\tinc(m);\n\tend;\n\twriteln(m);\nEND.\n"}, {"source_code": "var\nss,s:string;\nq,chh,mm,ans,ch,m:integer;\nbegin\nreadln(ss);\nch:=(ord(ss[1])-48)*10+ord(ss[2])-48;\nm:=(ord(ss[4])-48)*10+ord(ss[5])-48;\nif (ss[1]=ss[5])and(ss[2]=ss[4]) then writeln(0)\nelse begin\nif((ch=0)and(m>=0)) or((ch=1) and (m<=9)) then s:=('01:10')\nelse\nif ((ch=1)and(m>=10))or((ch=2)and(m<=19)) then s:=('02:20')\nelse\nif((ch=2)and(m>=20))or((ch=3)and(m<=29)) then s:=('03:30')\nelse\nif ((ch=3)and(m>=30))or((ch=4)and(m<=39)) then s:=('04:40')\nelse\nif((ch=4)and(m>=40))or((ch=5)and(m<=49)) then s:=('05:50')\nelse\nif (ch>=5)and(ch<=9) then s:=('10:01')\nelse\nif (ch=10)and(m<1) then s:=('10:01')\nelse\nif ((ch=10)and(m>=1))or((ch=11)and(m<=10)) then s:=('11:11')\nelse\nif ((ch=11)and(m>=11))or((ch=12)and(m<=20)) then s:=('12:21')\nelse\nif ((ch=12)and(m>=21))or((ch=13)and(m<=30)) then s:=('13:31')\nelse\nif ((ch=13)and(m>=31))or((ch=14)and(m<=40)) then s:=('14:41')\nelse\nif ((ch=14)and(m>=41)) or ((ch=15)and(m<=50)) then s:=('15:51')\nelse\nif (ch>=15)and(ch<=19) then s:=('20:02')\nelse\nif(ch=20)and(m<=1) then s:=('20:02')\nelse\nif ((ch=20)and(m>=2))or((ch=21)and(m<=11))then s:=('21:12')\nelse\nif((ch=21)and(m>=12))or((ch=22)and(m<=21)) then s:=('22:22')\nelse\nif ((ch=22)and(m>=22))or((ch=23)and(m<=31)) then s:=('23:32')\nelse\ns:=('00:00');\nchh:=(ord(s[1])-48)*10+ord(s[2])-48;\nmm:=(ord(s[4])-48)*10+ord(s[5])-48;\nif mm=0 then mm:=60;\nif chh=0 then chh:=24;\n\nans:=abs(m-mm);\nif (mm mod 60)D)or(b<>c) do\nbegin\nif (a=d)and(b=c)then break;\ns:=s+1;\nd:=d+1;\nif d=10 then begin d:=0;c:=c+1;end;\nif c=6 then begin c:=0;b:=b+1;end;\nif b=9 then begin b:=0;a:=a+1;end;\nif (a=2)and(b=4)then begin a:=0;b:=0;end;\nend;\nwriteln(s);\nend."}, {"source_code": "var a,b,c,d,s,o:longint;strok:string;\nBEGIN\nreadln(strok);\nval(strok[1],a,o);\nval(strok[2],b,o);\nval(strok[4],c,o);\nval(strok[5],d,o);\no:=1;\nwhile o=1 do\nbegin\nif (a=d)and(b=c)then break;\ns:=s+1;\nd:=d+1;\nif d=10 then begin d:=0;c:=c+1;end;\nif c=6 then begin c:=0;b:=b+1;end;\nif b=9 then begin b:=0;a:=a+1;end;\nif (a=2)and(b=4)then begin a:=0;b:=0;end;\nend;\nwriteln(s);\nend."}, {"source_code": "program force;\n\n{$mode objfpc}{$H+}\n\nuses\n {$IFDEF UNIX}{$IFDEF UseCThreads}\n cthreads,\n {$ENDIF}{$ENDIF}\n Classes\n { you can add units after this };\n var\n t:array[1..17] of string=('00:00','01:10','02:20','03:30','04:40','05:50'\n ,'10:01','11:11','12:21','13:31','14:41','15:51','20;02','21:12','22:22','23:32'\n ,'24:00') ;\n ch:string;\n i,indice,h1,hp1,h2,hp2,m1,mp1,mp2,m2,s:integer;\n ok:boolean;\n\nbegin\n readln(ch);\ni:=1;\nok:=true;\n while (i<=17) and (ok=true) do\n begin\n if t[i]>=ch then\n begin\n ok:=false;\n indice:=i;\n end\n else\n begin\n i:=i+1;\n end;\n end;\n\n\n\n\n hp1:=ord(ch[1])-ord('0');\n h1:=ord(t[indice][1])-ord('0');\n hp2:=ord(ch[2])-ord('0');\n h2:=ord(t[indice][2])-ord('0');\n mp1:=ord(ch[4])-ord('0');\n m1:=ord(t[indice][4])-ord('0');\n mp2:=ord(ch[5])-ord('0');\n m2:=ord(t[indice][5])-ord('0');\n if(10*m1+m2<10*mp1+mp2) then\n begin\n s:=60+10*m1+m2-10*mp1-mp2;\n s:=s+60*( 10*h1+h2-10*hp1-hp2-1);\n end\n else\n begin\n s:=10*m1+m2-10*mp1-mp2;\n s:=s+60*( 10*h1+h2-10*hp1-hp2);\n end;\nwriteln(s);\n\n\n \n\nend.\n"}, {"source_code": "program O_O;\ntype\n ll=longint;\nvar\n a,b,c,d,n:ll;\n s:shortstring;\nbegin\n readln(s);\n n:=0;\n val(s[1],a);val(s[2],b);val(s[4],c);val(s[5],d);\n while not ((a=d)and(b=c))do\n begin\n inc(n);\n if d<9 then inc(d)\n else begin\n d:=0;\n if c<5 then inc(c)\n else begin\n c:=0;\n if (b<9)and(a<2) then inc(b)\n else if (b<3)and(a<3) then inc(b)\n else begin\n b:=0;\n if a<1 then inc(a)\n else begin\n a:=0;\n end;\n end;\n end;\n end;\n end;\n writeln(n);\nend."}, {"source_code": "var s,x:string;\n k,f,i,p,g,a,b:longint;\nbegin\nreadln(s);\nk:=0;\nf:=0;\nwhile f=0 do begin\np:=0;\nfor i:=1 to 2 do if (s[i]<>s[5-i+1])then p:=1;\nif p=0 then begin\nwriteln(k);\nf:=1;\nexit;\nend;\nval(copy(s,1,2),a,g);\nval(copy(s,4,2),b,g);\nb:=b+1;\nif b>=60 then begin\nb:=0;\na:=a+1;\nend;\nif A>=24 then a:=0;\ns:='';\nif a<10 then begin\nstr(a,x);\ns:='0'+x+':';\nend\nelse begin\nstr(a,x);\ns:=x+':';\nend;\nif b<10 then begin\nstr(b,x);\ns:=s+'0'+x;\nend\nelse begin\nstr(b,x);\ns:=s+x;\nend;\nk:=k+1;\nfor i:=1 to 10000000do f:=0;\nwriteln(s);\nend;\nend."}, {"source_code": "var st:string;A:array[0..25] of string;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nfunction dao(st:string):string;\nvar s:string;i:longint;\nbegin\n s:='';\n for i:=length(st) downto 1 do\n s:=s+st[i];\n exit(s);\nend;\nprocedure nhap;\nvar s:string;i:longint;\nbegin\n readln(st);\n for i:=0 to 23 do\n begin\n str(i,s);\n if length(s)<=1 then s:='0'+s;\n S:=s+':'+dao(s);\n A[i]:=s;\n end;\n A[24]:=A[0];\nend;\nprocedure xuli;\nvar s,ss:string;n,code,i,x,y:longint;\nbegin\n\n s:=copy(st,1,2);\n val(s,n,code);\n ss:=copy(A[n],pos(':',st)+1,2);\n s:=copy(st,pos(':',st)+1,2);\n val(s,x,code);\n val(ss,y,code);\n if x<=y then\n begin\n writeln(y-x);\n halt;\n end;\n inc(n);\n ss:=copy(A[n],pos(':',st)+1,2);\n val(ss,y,code);\n writeln(y+60-x);\nend;\n\n\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend.\n\n"}, {"source_code": "var s,s1,s2:string;\ni,j,h,m,code,k,q:longint;\nbegin\nread(s);\ns1:=s[1]+s[2];\nval(s1,h,code);\ns1:=s[4]+s[5];\nval(s1,m,code);\nfor i:=h to 23 do\nfor j:=m to 59 do begin\nstr(i,s2);\nif i<10 then s1:='0'+s2+':' else s1:=s2+':';\nstr(j,s2);\nif j<10 then s1:='0'+s1+s2 else s1:=s1+s2;\ns2:='';\nfor q:=length(s1) downto 1 do\ns2:=s2+s1[q];\nif s2=s1 then begin writeln(k);exit;end;\ninc(k);\nend;\nwriteln(k);\nEnd.\n\n"}, {"source_code": "var s,s1,s2:string;\ni,j,h,m,code,k,q:longint;\nbegin\nread(s);\ns1:=s[1]+s[2];\nval(s1,h,code);\ns1:=s[4]+s[5];\nval(s1,m,code);\nfor i:=h to 23 do\nfor j:=0 to 59 do begin\nstr(i,s2);\nif i<10 then s1:='0'+s2+':' else s1:=s2+':';\nstr(j,s2);\nif j<10 then s1:=s1+'0'+s2 else s1:=s1+s2;\ns2:='';\nfor q:=length(s1) downto 1 do\ns2:=s2+s1[q];\nif s1=s then k:=0;\nif (s2=s1)and((i>=h)and(j>=m)) then begin writeln(k);exit;end;\ninc(k);\nend;\nwriteln(k);\nEnd.\n\n"}, {"source_code": "const fi='816A.inp';\n fo='816A.out';\nvar s,x:string;\n h,m,i,kq,c,k:longint;\nfunction kt(h,m:longint):boolean;\n begin\n if (h=m) and ((m mod 10)*10+m < 24) then exit(true);\n if (m mod 10)*10+m div 10=h then exit(true);\n exit(false);\n end;\nbegin\n\n\n readln(s);\n x:=s[1]+s[2];val(x,h,c);\n x:=s[4]+s[5];val(x,m,c);\n for i:=1 to 1000000 do\n if kt(h,m) then break\n else\n begin\n inc(m);\n if m=60 then m:=0;\n if m=0 then inc(h);\n if h=24 then h:=0;\n end;\n writeln(i-1);\nend.\n\n"}, {"source_code": "const fi='816A.inp';\n fo='816A.out';\nvar s,x:string;\n h,m,i,kq,c:longint;\nfunction kt(h,m:longint):boolean;\n begin\n if h=m then exit(true);\n if (m mod 10)*10+m div 10=h then exit(true);\n exit(false);\n end;\nbegin\n\n readln(s);\n x:=s[1]+s[2];val(x,h,c);\n x:=s[4]+s[5];val(x,m,c);\n for i:=1 to 1000000 do\n if kt(h,m) then break\n else\n begin\n inc(m);\n if m=60 then m:=0;\n if m=0 then inc(h);\n if h=24 then h:=0;\n end;\n writeln(i-1);\nend.\n"}, {"source_code": "var s,z:string;\nmin,i,k,y,x,j:longint;\na:array [00..1000005] of longint;\nbegin\nmin:=maxlongint;\n readln(s);\n for i:=0 to 1 do\n for j:=0 to 5 do\n begin\n inc(k);\n a[k]:=(i*10+j)*60 + j*10+i;\n end;\n for i:=0 to 4 do\n begin\n inc(k);\n a[k]:=(2*10+i)*60 + i*10+2;\n end;\n for i:=0 to 1 do\n for j:=0 to 5 do\n begin\n inc(k);\n a[k]:=(i*10+j)*60 + j*10+i+1440;\n end;\n for i:=0 to 4 do\n begin\n inc(k);\n a[k]:=(2*10+i)*60 + i*10+2+1440;\n end;\n for i:=1 to 2 do\n z:=z+s[i];\n val(z,x);\n z:='';\n for i:=4 to 5 do\n z:=z+s[i];\n val(z,y);\n for i:=1 to k*2 do\n begin\n if abs(x*60+y-a[i])0 do\n begin\n inc(d[n mod 10]);n:=n div 10;\n end;\n g[0] := 1;\n for i:=1 to 10 do g[i]:=g[i-1]*(d[i-1]+1);\n fillchar(dp,sizeof(dp),0);dp[0,0]:=1;\n for i:=0 to g[10]-2 do\n begin\n if (i>=1) and (i<=d[0]) then continue;\n for j:=0 to m-1 do\n if dp[i,j]>0 then\n begin\n t:=i;\n for k:=0 to 9 do\n begin\n p:=t mod (d[k]+1);\n if p 0 do\n begin\n inc(len);\n d[len]:= x mod 10;\n inc(cnt[ x mod 10 ]);\n x:= x div 10;\n end;\n for i:= 1 to (len shr 1) do\n begin\n j:= d[i];\n d[i]:= d[len - i + 1];\n d[len - i + 1]:= j;\n end;\n\n dp[0][0]:= 1;\n for i:= 0 to ((1 shl len) - 1) do\n for j:= 0 to m-1 do\n for k:= 1 to len do\n if (i and (1 shl (k - 1)) = 0) and (not ((i = 0) and (d[k] = 0))) then\n begin\n x:= i or (1 shl (k - 1));\n y:= (j * 10 + d[k]) mod m;\n dp[x][y]:= dp[x][y] + dp[i][j];\n end;\n\n ans:= dp[(1 shl len) - 1][0];\n for i:= 0 to 9 do\n for j:= 1 to cnt[i] do\n ans:= ans div j;\n\n write(ans);\nend."}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m1,m2:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);\n n:=length(s);\n for i:=1 to length(s) do\n m1[i]:=ord(s[i])-ord('0');\n m2[0]:=1;\n for i:=1 to length(s) do\n m2[i]:=m2[i-1]*10;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n c:=m2[b-1]*m1[z+1];\n for w:=0 to md-1 do\n inc(m[i,(c+w) mod md],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);\nend.\n"}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\n mahh=array[0..18,0..18] of int64;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m2:mahh;m1:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);{}\n n:=length(s);\n for i:=1 to length(s) do\n Begin\n m1[i]:=ord(s[i])-ord('0');\n m2[i,0]:=1;\n for z:=1 to length(s) do\n m2[i,z]:=m2[i,z-1]*10;\n for z:=0 to length(s) do\n m2[i,z]:=m2[i,z]*m1[i];\n end;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n for w:=0 to md-1 do\n inc(m[i,(m2[z+1,b-1]+w) mod md],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);{}\nend.\n"}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\n mahh=array[0..18,0..18,-1..99] of int64;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m2:mahh;m1:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);\n n:=length(s);\n for i:=1 to length(s) do\n Begin\n m1[i]:=ord(s[i])-ord('0');\n m2[i,0,-1]:=1;\n for z:=1 to length(s) do\n m2[i,z,-1]:=m2[i,z-1,-1]*10;\n for z:=0 to length(s) do\n Begin\n m2[i,z,-1]:=m2[i,z,-1]*m1[i];\n for j:=0 to 99 do\n m2[i,z,j]:=(m2[i,z,-1]+j) mod md;\n end;\n end;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n for w:=0 to md-1 do\n inc(m[i,m2[z+1,b-1,w]],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);{}\nend.\n"}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m1,m2:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);\n n:=length(s);\n for i:=1 to length(s) do\n m1[i]:=ord(s[i])-ord('0');\n m2[0]:=1;\n for i:=1 to length(s) do\n m2[i]:=m2[i-1]*10;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n c:=m2[b-1]*m1[z+1];\n for w:=0 to md-1 do\n inc(m[i,(c+w) mod md],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);{}\nend.\n"}, {"source_code": "var l,ans,n,m,q,ost,q1:int64;\n i,j,t,p,x:longint;\n s:string;\n ok:boolean;\n a,qq:array [0..300000,0..101] of int64;\n aa,kol:array [0..200] of longint;\n begin\n read(q1,m);\n str(q1,s);\n l:=length(s);\n for i:=1 to l do\n begin\n val(s[i],aa[i],p);\n inc(kol[aa[i]]);\n end;\n\n for i:=1 to l do\n if aa[i]>0 then a[1 shl (i-1),aa[i] mod m]:=1;\n\n q:=(1 shl (l))-1;\n for i:=1 to q do\n begin\n for j:=1 to l do\n begin\n if ((1 shl (j-1)) and i=0) then begin\n ok:=true;\n for x:=1 to j-1 do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i=0) then begin ok:=false; break; end;\n for x:=j+1 to l do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i>0) then begin ok:=false; break; end;\n if not(ok) then continue;\n\n inc(qq[i,0]);\n qq[i,qq[i,0]]:=j;\n end;\n end;\n end;\n\n for i:=1 to q do\n begin\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n for t:=1 to qq[i,0] do\n begin\n ost:=(j*10+aa[qq[i][t]]) mod m;\n inc(a[i+(1 shl (qq[i][t]-1)),ost],a[i][j]);\n end;\n end;\n end;\n writeln(a[q][0]);\n end.\n"}, {"source_code": "var dp:array[0..1 shl 18,0..100] of int64;\n\tnext,first:array[0..20] of longint;\n\tn:int64;\n\tm,i,j,k,l,cnt,t:longint;\nbegin\n\t//assign(input,'i.in');reset(input);\n\treadln(n,m);\n\twhile n > 0 do\n\tbegin\n\t\tinc(cnt);\n\t\tt := n mod 10;\n\t\tnext[cnt] := first[t];\n\t\tfirst[t] := cnt;\n\t\tn := n div 10;\n\tend;\n\tfillchar(dp,sizeof(dp),0);\n\tdp[0,0] := 1;\n\tfor i := 0 to 1 shl cnt - 1 do\n\tfor j := 0 to m -1 do\n\tbegin\n\t\tif dp[i,j] = 0 then continue;\n\t\tfor k := 0 to 9 do\n\t\tbegin\n\t\t\tl := first[k];\n\t\t\twhile l > 0 do\n\t\t\tbegin\n\t\t\t\tif (i and (1 shl (l-1)) > 0) then l := next[l] else break;\n\t\t\tend;\n\t\t\tif (l > 0) and not ((i = 0) and (k = 0)) then inc(dp[i or (1 shl (l - 1)),(j * 10 + k) mod m], dp[i,j]);\n\t\tend;\n\tend;\n\twriteln(dp[1 shl cnt - 1, 0]);\n\t{for i := 0 to 7 do\n\tbegin\n\tfor j := 0 to 1 do write(dp[i,j],' ');\n\twriteln;\n\tend; }\n\tclose(input);\nend.\n\t\n"}, {"source_code": "var k,n,m,x,y,z:int64;i,j,l:longint;\n a:array[0..400000,0..100]of int64;\n p,f:array[0..25]of longint;\n begin\n // assign(input,'input.txt');reset(input);\n // assign(output,'output.txt');rewrite(output);\n readln(n,m);\n k:=0;\n while n>0 do\n begin\n inc(k);p[k]:=n mod 10;\n n:=n div 10;\n end;\n z:=(1 shl k)-1;\n a[0,0]:=1;x:=0;\n for i:=0 to z do\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n inc(x);\n for l:=1 to k do\n begin\n y:=1 shl (l-1);\n if(f[p[l]]<>x)and(i and y=0)and((i<>0)or(p[l]<>0))then\n begin\n f[p[l]]:=x;\n inc(a[i or y,(j*10+p[l])mod m],a[i,j]);\n end;\n end;\n end;\n writeln(a[z,0]);\n\n\n end.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,m:int64;\n g,i,j,ost,l,vzyali:longint;s:ansistring;\n code : integer;\n c : char;\n f : array [0..1 shl 19,0..100] of int64;\n\n function set1(m,b:int64):int64;begin exit(m or (1 shl ((length(s)-b+1)-1)));end;\n function get(m,b:int64):int64;begin exit(ord((m and (1 shl ((length(s)-b+1)-1))=(1 shl ((length(s)-b+1)-1)))));end;\n function newost(x,y:int64):int64;var res:int64;begin res:=x;res:=(10*res)mod m;res:=(y+res)mod m;exit(res mod m); end;\n function cifra(c:char):longint;var res:longint;code:integer;begin val(c,res,code);exit(res);end;\n\nbegin\n readln(n,m);str(n,s);\n g:=length(s);\n fillchar(f,sizeof(f),0);\n f[0,0]:=1;\n for i:=0 to (1 shl g)-1 do\n for ost:=0 to m-1 do\n if f[i,ost]>0 then\n begin\n for c:='0' to '9' do\n begin\n if(c='0')and(i=0)then continue;\n val(c,j,code);\n for l:=1 to g do\n if (s[l]=c) and (get(i,l)=0) then\n begin\n f[set1(i,l),newost(ost,j)]:=f[set1(i,l),newost(ost,j)]+f[i,ost];\n break;\n end;\n end;\n end;\n writeln(f[(1 shl g)-1,0]);\nend.\n"}, {"source_code": "const fi=''; fo='';\n\nVar n,m:longint;\n last:longword;\n d:array[0..262150,0..110] of Qword;\n pow:array[0..20] of Qword;\n list:array[0..20] of byte;\n A,B:array[0..20] of byte;\n dd:array[0..10] of boolean;\n vt:array[0..10] of Longint;\n\n\nProcedure doc;\nVar kk:Qword; i:longint;\nbegin\n assign(input,fi); reset(input);\n Readln(KK,m);\n while (kk<>0) do\n begin\n inc(n);\n B[n]:=kk mod 10;\n kk:=kk div 10;\n end;\n for i:=1 to n do\n A[i]:=B[n-i+1];\nend;\n\nFunction getbit(x:longword; i:byte):byte;\nbegin\n getbit:=(x Shr i) and 1;\nend;\n\nFunction bitoff(x:longword; i:byte):longword;\nbegin\n bitoff:=x and (not (1 Shl i));\nend;\n\nprocedure xuly;\nVar s,p:longword;\n i,j,k,kk,k1:longint;\n x:Qword;\nbegin\n pow[1]:=1;\n for i:=2 to n do\n pow[i]:=pow[i-1]*10;\n last:=(1 Shl n)-1;\n for s:=1 to last do\n begin\n for i:=0 to 9 do\n dd[i]:=false;\n k:=0;\n for i:=0 to n-1 do\n if getbit(s,i)=1 then\n begin\n inc(k);\n dd[a[i+1]]:=true;\n vt[a[i+1]]:=i;\n end;\n for i:=0 to 9 do\n if dd[i] then\n If (k<>n) or (i<>0) then\n begin\n j:=vt[i];\n p:=bitoff(s,j);\n x:=(pow[k]*i) mod m;\n for kk:=0 to m-1 do\n begin\n k1:=(x+kk) mod m;\n d[s,k1]:=d[s,k1]+d[p,kk];\n end;\n end;\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo); rewrite(output);\n writeln(d[last,0]);\nend;\n\nbegin\n doc;\n D[0,0]:=1;\n xuly;\n ghi;\nend.\n"}, {"source_code": "var l,ans,n,m,q,ost,q1:int64;\n i,j,t,p,x:longint;\n s:string;\n ok:boolean;\n dp,qq:array [0..300000,0..101] of int64;\n aa,kol:array [0..200] of longint;\n begin\n read(q1,m);\n str(q1,s);\n l:=length(s);\n for i:=1 to l do\n begin\n val(s[i],aa[i],p);\n inc(kol[aa[i]]);\n end;\n for i:=1 to l do\n if aa[i]>0 then dp[1 shl (i-1),aa[i] mod m]:=1;\n q:=(1 shl (l))-1;\n for i:=1 to q do\n begin\n for j:=1 to l do\n begin\n if ((1 shl (j-1)) and i=0) then begin\n ok:=true;\n for x:=1 to j-1 do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i=0) then begin ok:=false; break; end;\n for x:=j+1 to l do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i>0) then begin ok:=false; break; end;\n if not(ok) then continue;\n\n inc(qq[i,0]);\n qq[i,qq[i,0]]:=j;\n end;\n end;\n end;\n\n for i:=1 to q do\n begin\n for j:=0 to m-1 do\n begin\n if dp[i,j]=0 then continue;\n for t:=1 to qq[i,0] do\n begin\n ost:=(j*10+aa[qq[i][t]]) mod m;\n inc(dp[i+(1 shl (qq[i][t]-1)),ost],dp[i][j]);\n end;\n end;\n end;\n writeln(dp[q][0]);\n end."}, {"source_code": "var l,ans,n,m,q,ost,q1:int64;\n i,j,t,p,x:longint;\n s:string;\n ok:boolean;\n a,qq:array [0..300000,0..101] of int64;\n aa,kol:array [0..200] of longint;\n begin\n read(q1,m);\n str(q1,s);\n l:=length(s);\n for i:=1 to l do\n begin\n val(s[i],aa[i],p);\n inc(kol[aa[i]]);\n end;\n for i:=1 to l do\n if aa[i]>0 then a[1 shl (i-1),aa[i] mod m]:=1;\n q:=(1 shl (l))-1;\n for i:=1 to q do\n begin\n for j:=1 to l do\n begin\n if ((1 shl (j-1)) and i=0) then begin\n ok:=true;\n for x:=1 to j-1 do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i=0) then begin ok:=false; break; end;\n for x:=j+1 to l do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i>0) then begin ok:=false; break; end;\n if not(ok) then continue;\n\n inc(qq[i,0]);\n qq[i,qq[i,0]]:=j;\n end;\n end;\n end;\n\n for i:=1 to q do\n begin\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n for t:=1 to qq[i,0] do\n begin\n ost:=(j*10+aa[qq[i][t]]) mod m;\n inc(a[i+(1 shl (qq[i][t]-1)),ost],a[i][j]);\n end;\n end;\n end;\n writeln(a[q][0]);\n end."}, {"source_code": "var l,ans,n,m,q,ost,q1:int64;\n i,j,t,p,x:longint;\n s:string;\n ok:boolean;\n a,qq:array [0..300000,0..101] of int64;\n aa,kol:array [0..200] of longint;\n begin\n read(q1,m);\n str(q1,s);\n l:=length(s);\n for i:=1 to l do\n begin\n val(s[i],aa[i],p);\n inc(kol[aa[i]]);\n end;\n for i:=1 to l do\n if aa[i]>0 then a[1 shl (i-1),aa[i] mod m]:=1;\n q:=(1 shl (l))-1;\n for i:=1 to q do\n begin\n for j:=1 to l do\n begin\n if ((1 shl (j-1)) and i=0) then begin\n ok:=true;\n for x:=1 to j-1 do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i=0) then begin ok:=false; break; end;\n for x:=j+1 to l do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i>0) then begin ok:=false; break; end;\n if not(ok) then continue;\n\n inc(qq[i,0]);\n qq[i,qq[i,0]]:=j;\n end;\n end;\n end;\n\n for i:=1 to q do\n begin\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n for t:=1 to qq[i,0] do\n begin\n ost:=(j*10+aa[qq[i][t]]) mod m;\n inc(a[i+(1 shl (qq[i][t]-1)),ost],a[i][j]);\n end;\n end;\n end;\n writeln(a[q][0]);\n end."}, {"source_code": "var\n m,i,j,k,t,p:longint;\n g,d:array[0..10] of longint;\n dp:array[0..100010,0..101] of int64;\n n:int64;\n\nbegin {main}\n readln(n,m);\n fillchar(d,sizeof(d),0);\n while n<>0 do\n begin\n inc(d[n mod 10]);n:=n div 10;\n end;\n g[0]:=1;\n for i:=1 to 10 do g[i]:=g[i-1]*(d[i-1]+1);\n fillchar(dp,sizeof(dp),0);dp[0,0]:=1;\n for i:=0 to g[10]-2 do\n begin\n if (i>=1) and (i<=d[0]) then continue;\n for j:=0 to m-1 do\n if dp[i,j]>0 then\n begin\n t:=i;\n for k:=0 to 9 do\n begin\n p:=t mod (d[k]+1);\n if p0 do\n begin\n inc(d[n mod 10]);n:=n div 10;\n end;\n g[0]:=1;\n for i:=1 to 10 do g[i]:=g[i-1]*(d[i-1]+1);\n fillchar(dp,sizeof(dp),0);dp[0,0]:=1;\n for i:=0 to g[10]-2 do\n begin\n if (i>=1) and (i<=d[0]) then continue;\n for j:=0 to m-1 do\n if dp[i,j]>0 then\n begin\n t:=i;\n for k:=0 to 9 do\n begin\n p:=t mod (d[k]+1);\n if p0 then\n begin\n for t:=1 to l do\n if (i and (1 shl (t-1))=0) and not((a[t]='0') and (i=0)) then\n begin\n tt:=i or (1 shl (t-1));\n inc(f[tt,(j*10+b[t]) mod k],f[i,j]);\n end;\n end;\n res:=f[(1 shl l)-1,0];\n for i:=0 to 9 do\n if c[i]<>0 then\n for j:=1 to c[i] do res:=res div j;\n write(fo,res);\n End;\n (**********************************************************************)\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n lam;\n close(fi);\n close(fo);\nENd.\n"}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\n mahh=array[0..18,0..18,-1..99] of int64;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m2:mahh;m1:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);{}\n n:=length(s);\n for i:=1 to length(s) do\n Begin\n m1[i]:=ord(s[i])-ord('0');\n m2[i,0,-1]:=1;\n for z:=1 to length(s) do\n m2[i,z,-1]:=m2[i,z-1,-1]*10;\n for z:=0 to length(s) do\n Begin\n m2[i,z,-1]:=m2[i,z,-1]*m1[i];\n for j:=0 to 99 do\n m2[i,z,j]:=(m2[i,z,-1]+j) mod md;\n end;\n end;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n for w:=0 to md-1 do\n inc(m[i,m2[z+1,b-1,w]],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);{}\nend.\n"}, {"source_code": "var\n m,i,j,k,t,p:longint;\n g,d:array[0..10] of longint;\n dp:array[0..100001, 0..101] of int64;\n n:int64;\n\nbegin\n readln(n,m);\n fillchar(d,sizeof(d),0);\n while n<>0 do\n begin\n inc(d[n mod 10]);n:=n div 10;\n end;\n g[0]:=1;\n for i:=1 to 10 do g[i]:=g[i-1]*(d[i-1]+1);\n fillchar(dp,sizeof(dp),0);dp[0,0]:=1;\n for i:=0 to g[10]-2 do\n begin\n if (i>=1) and (i<=d[0]) then continue;\n for j:=0 to m-1 do\n if dp[i,j]>0 then\n begin\n t:=i;\n for k:=0 to 9 do\n begin\n p:=t mod (d[k]+1);\n if p0 then a[1 shl (i-1),aa[i] mod m]:=1;\n q:=(1 shl (l))-1;\n for i:=1 to q do\n begin\n for j:=1 to l do\n begin\n if ((1 shl (j-1)) and i=0) then begin\n ok:=true;\n for x:=1 to j-1 do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i=0) then begin ok:=false; break; end;\n for x:=j+1 to l do\n if (aa[j]=aa[x]) and ((1 shl (x-1)) and i>0) then begin ok:=false; break; end;\n if not(ok) then continue;\n \n inc(qq[i,0]);\n qq[i,qq[i,0]]:=j;\n end;\n end;\n end;\n \n for i:=1 to q do\n begin\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n for t:=1 to qq[i,0] do\n begin\n ost:=(j*10+aa[qq[i][t]]) mod m;\n inc(a[i+(1 shl (qq[i][t]-1)),ost],a[i][j]);\n end;\n end;\n end;\n writeln(a[q][0]);\n end."}, {"source_code": "{$R-,S-,Q-,I-,O+}\n{$M 32000000}\n\n{$APPTYPE CONSOLE}\n\nuses Math;\nconst\n inf = round(1e9);\n maxn = round(1e5) + 200;\n md = round(1e9) + 7;\ntype\n pair = record\n mask, rem : longint;\n end; \nvar\n n : int64;\n m, mask, rem, l, r, len, i, tmp, newmask, newrem : longint;\n used : array [0..9] of boolean;\n dp : array [0..1 shl 18 - 1, 0..100] of int64;\n c : array [0..18] of longint;\n cnt : array [0..1 shl 18 - 1] of longint;\n q : array [1..1 shl 25] of pair;\n pow : longint;\n\n function cntbits(x : longint) : longint;\n var\n res : longint;\n begin\n res := 0;\n while x > 0 do\n begin\n inc(res);\n x := x and (x - 1);\n end;\n cntbits := res;\n end;\n\nbegin\n //assign (input, 'input.txt'); reset(input);\n //assign (output, 'output.txt'); rewrite(output);\n randomize;\n readln(n, m);\n len := 0;\n while n > 0 do\n begin\n inc(len);\n c[len] := n mod 10;\n n := n div 10;\n end;\n for i := 1 to len shr 1 do\n begin\n tmp := c[i]; c[i] := c[len - i + 1]; c[len - i + 1] := tmp;\n end;\n for mask := 0 to 1 shl len - 1 do cnt[mask] := cntbits(mask);\n pow := 10 mod m;\n\n fillchar(dp, sizeof(dp), -1);\n l := 0;\n r := 0;\n for i := 1 to len do\n if not used[c[i]] and (c[i] > 0) then\n begin\n inc(r);\n q[r].mask := 1 shl (i - 1);\n q[r].rem := c[i] mod m;\n dp[q[r].mask][q[r].rem] := 1;\n used[c[i]] := true;\n end;\n\n while l < r do\n begin\n inc(l);\n mask := q[l].mask;\n rem := q[l].rem;\n fillchar(used, sizeof(used), false);\n for i := 1 to len do\n if (mask and (1 shl (i - 1)) = 0) and not used[c[i]] then\n begin\n used[c[i]] := true;\n newmask := mask or (1 shl (i - 1));\n newrem := (rem * pow + c[i]) mod m;\n if dp[newmask][newrem] = -1 then\n begin\n dp[newmask][newrem] := dp[mask][rem];\n inc(r);\n q[r].mask := newmask;\n q[r].rem := newrem;\n end\n else\n dp[newmask][newrem] := dp[newmask][newrem] + dp[mask][rem];\n end;\n end;\n\n writeln(max(0, dp[1 shl len - 1][0]));\nend.\n"}, {"source_code": "const\n b=18;\n l=1 shl b;\nvar\n a:array[0..b] of longint;\n f:array[0..l,0..99] of int64;\n good:array[0..1000] of longint;\n lim,mask,ost,used,m,k,i,nn,nmask,j:longint;\n prev:integer;\n n:int64;\n\nbegin\n readln(n,m);\n for i:=0 to 1000 do good[i]:=i mod m;\n k:=0;\n while (n<>0) do\n begin\n a[k]:=n mod 10;\n inc(k);\n n:=n div 10;\n end;\n for i:=0 to k-1 do for j:=0 to k-1 do if (a[i]>a[j]) then begin ost:=a[i]; a[i]:=a[j]; a[j]:=ost; end;\n lim:=(1 shl k)-1;\n f[0,0]:=1;\n for mask:=0 to lim-1 do for ost:=0 to m-1 do\n begin\n if (f[mask,ost]=0) then continue;\n prev:=-1;\n for i:=0 to k-1 do\n begin\n if ((mask and (1 shl i))<>0) then continue;\n if (mask=0) and (a[i]=0) then continue;\n if (prev=a[i]) then continue;\n nmask:=mask xor (1 shl i);\n nn:=good[ost*10+a[i]];\n f[nmask,nn]:=f[nmask,nn]+f[mask,ost];\n prev:=a[i];\n end;\n end;\n writeln(f[lim,0]);\nend."}, {"source_code": "var dp:array[0..(1 shl 18),0..101] of int64;\n s:string;\n m,len,last_mask,i,ost,mask,j:longint;\n n:int64;\n a,b:array[0..100]of longint;\nbegin\n\n read(n,m);\n str(n,s);\n len:=length(s);\n last_mask:=1<0 then inc(dp[1<0 then\n begin\n for k:=1 to n do\n if (i and p[k-1] =0) and ((i >0) or ((i =0) and (a[k] >0))) then\n begin\n u:=i + p[k-1];\n v:=(j*10 + a[k]) mod m;\n d[u,v]:=d[u,v] + d[i,j];\n end;\n end;\nend;\n\nprocedure Inkq;\nvar\n i,j :Longint;\nbegin\n res:=d[p[N] - 1,0];\n for i:=0 to 9 do cnt[i]:=0;\n for i:=1 to N do inc(cnt[a[i]]);\n\n for i:=0 to 9 do\n for j:=2 to cnt[i] do res:=res div j;\n writeln(res);\nend;\n\nbegin\n assign(f,fi);reset(f);\n Doc;\n Cal;\n Inkq;\n close(f);\nend.\n"}, {"source_code": "var\n n : int64;\n i, j, ii, m, d, count : integer;\n st : string;\n a, bb : array[1..18] of integer;\n z : array[1..19] of int64;\n c : array[1..270000,0..99] of int64;\n y : array[1..50000] of int64;\n\nprocedure generate(t : integer);\nvar b : array[1..17] of byte;\n i, j : integer;\n p, x, k, kk : int64;\nbegin\n fillchar(b,sizeof(b),0);\n for j:=1 to t do b[j]:=j-1;\n while true do\n begin\n k:=0;\n for j:=1 to t do k:=k+(1 shl b[j]);\n inc(count); y[count]:=k;\n for j:=1 to t do\n begin\n kk:=1 shl b[j]; x:=z[b[j]+1]; p:=(a[t]*x) mod m;\n if (a[t]=0)and(b[j]=d-1) then continue;\n for i:=0 to m-1 do\n if i+p0) do dec(p);\n if p=0 then break;\n inc(b[p]);\n for j:=p+1 to t do b[j]:=b[j-1]+1;\n end;\nend;\n\nbegin\n read(n,m);\n str(n,st); d:=length(st);\n for i:=1 to d do a[i]:=ord(st[i])-48;\n z[1]:=1;\n for i:=2 to d do z[i]:=z[i-1]*10;\n fillchar(c,sizeof(c),0);\n for i:=1 to d do c[1 shl (i-1),(a[1]*z[i]) mod m]:=1;\n\n fillchar(bb,sizeof(bb),0);\n for i:=2 to d do\n for j:=i-1 downto 1 do\n if a[i]=a[j] then inc(bb[i]);\n\n for i:=2 to d do\n begin\n count:=0;\n generate(i);\n for ii:=1 to count do\n for j:=0 to m-1 do\n c[y[ii],j]:=c[y[ii],j] div (bb[i]+1);\n end;\n writeln(c[(1 shl d)-1,0]);\n\nend."}, {"source_code": "const maxcs=19;\n maxm=100;\n\nvar f:array[0..262143,0..maxm,false..true] of int64;\n\n a,lt:array[0..maxcs] of longint;\n\n d:array[0..9] of longint;\n\n n,m:longint;\n\n res:int64;\n\nprocedure doc;\nvar i:longint;\n st:string;\n tg:int64;\nbegin\n readln(tg,m);\n str(tg,st);\n\n n:=length(st);\n\n for i:=1 to n do\n begin\n a[i]:=ord(st[i])-48;\n inc(d[a[i]]);\n end;\n\n lt[0]:=1;\n for i:=1 to n do lt[i]:=lt[i-1]*2;\nend;\n\nprocedure xuly;\nvar i,j,k,newi,newj:longint;\n start,newstart:boolean;\nbegin\n f[0,0,false]:=1;\n\n for i:=0 to lt[n]-1 do\n for j:=0 to m do\n for start:=false to true do\n if f[i,j,start]<>0 then\n begin\n\n for k:=1 to n do\n if (i and lt[k-1]=0) and ((a[k]<>0) or ((a[k]=0) and start)) then\n begin\n newi:=i or lt[k-1];\n newj:=(j*10+a[k]) mod m;\n newstart:=start or (a[k]<>0);\n\n f[newi,newj,newstart]:=f[newi,newj,newstart]+f[i,j,start];\n end;\n end;\n\n res:=f[lt[n]-1,0,true];\n\n for i:=0 to 9 do\n for j:=2 to d[i] do\n res:=res div j;\n\n writeln(res);\nend;\n\nbegin\n\n //assign(input,'nhap.inp'); reset(input);\n\n doc;\n xuly;\nend."}, {"source_code": "{$mode objFpc}\nuses math;\nconst\n finp = '';\n fout = '';\n maxcs = 18;\ntype\n cs = array[0..20] of integer;\nvar\n fi,fo : text;\n n : int64;\n m,sl,vc : integer;\n x : cs;\n fx : array[0..262500,0..110] of int64;\n gt : array[0..20] of int64;\n dd : array[0..9] of integer;\nprocedure openfile;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\nend;\nprocedure closefile;\nbegin\n close(fi);close(fo);\nend;\nprocedure enter;\nvar\n i : integer;\nbegin\n readln(fi,n,m);\nend;\nprocedure swap(t:int64);\nbegin\n sl:=0;\n repeat\n inc(sl);\n x[sl]:=t mod 10;\n t:=t div 10;\n until t=0;\nend;\nfunction get(t,x:integer):integer;\nbegin\n result:=(t>>(x-1)) and 1;\nend;\nprocedure process;\nvar\n i,j,t,k : integer;\n r : int64;\nbegin\n swap(n);\n gt[0]:=1;\n for i:=1 to 18 do\n gt[i]:=gt[i-1]*i;\n fx[0,0]:=1;\n vc:=(1<0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shr z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n c:=m2[b-1]*m1[z+1];\n for w:=0 to md-1 do\n inc(m[i,(c+w) mod md],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);\nend.\n"}, {"source_code": "{$R-,Q-,O+}\ntype mass=array[0..1 shl 18,0..99] of int64;\n maxx=array[0..18] of int64;\n majj=array[0..9] of boolean;\nvar used:majj;s:string;a,r,b,x,n,md,max1,res,c,k:int64;m:mass;m1,m2:maxx;w,i,j,z:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n,md);\n str(n,s);\n n:=length(s);\n for i:=1 to length(s) do\n m1[i]:=ord(s[i])-ord('0');\n m2[0]:=1;\n for i:=1 to length(s) do\n m2[i]:=m2[i-1]*10;\n for i:=1 to 1 shl n-1 do\n Begin\n b:=0;\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then inc(b);\n if b=1\n then Begin\n for z:=0 to n-1 do\n if (i and (1 shl z)>0)\n then Begin\n m[i,m1[z+1] mod md]:=1;\n break;\n end;\n continue;\n end;\n fillchar(used,sizeof(used),true);\n for z:=0 to n-1 do\n if ((i shl z) and 1>0) and (used[m1[z+1]])\n then Begin\n used[m1[z+1]]:=false;\n a:=i xor (1 shl z);\n if (b=n) and (m1[z+1]=0)\n then continue;\n c:=m2[b-1]*m1[z+1];\n for w:=0 to md-1 do\n inc(m[i,(c+w) mod md],m[a,w]);\n end;\n end;\n writeln(m[1 shl n-1,0]);\nend.\n"}, {"source_code": "var k,n,m,x,y,z:int64;i,j,l:longint;\n a:array[0..4000000,0..100]of int64;\n p,f:array[0..25]of longint;\n begin\n // assign(input,'input.txt');reset(input);\n // assign(output,'output.txt');rewrite(output);\n readln(n,m);\n k:=0;\n while n>0 do\n begin\n inc(k);p[k]:=n mod 10;\n n:=n div 10;\n end;\n z:=(1 shl k)-1;\n a[0,0]:=1;x:=0;\n for i:=0 to z do\n for j:=0 to m-1 do\n begin\n if a[i,j]=0 then continue;\n inc(x);\n for l:=1 to k do\n begin\n y:=1 shl (l-1);\n if(f[p[l]]<>x)and(i and y=0)and((i<>0)or(p[l]<>0))then\n begin\n f[p[l]]:=x;\n inc(a[i or y,(j*10+p[l])mod m],a[i,j]);\n end;\n end;\n end;\n writeln(a[z,0]);\n\n\n end.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,m,g,i,j,ost,l,vzyali:longint;s:ansistring;\n code : integer;\n c : char;\n f : array [0..200,0..200] of int64;\n\n function set1(m,b:int64):int64;begin exit(m or (1 shl ((length(s)-b+1)-1)));end;\n function get(m,b:int64):int64;begin exit(ord((m and (1 shl ((length(s)-b+1)-1))=(1 shl ((length(s)-b+1)-1)))));end;\n function newost(x,y:int64):int64;var res:int64;begin res:=x;res:=(10*res)mod m;res:=(y+res)mod m;exit(res mod m); end;\n function cifra(c:char):longint;var res:longint;code:integer;begin val(c,res,code);exit(res);end;\n\nbegin\n readln(n,m);str(n,s);\n g:=length(s);\n fillchar(f,sizeof(f),0);\n f[0,0]:=1;\n for i:=0 to (1 shl g)-1 do\n for ost:=0 to m-1 do\n if f[i,ost]>0 then\n begin\n for c:='0' to '9' do\n begin\n if(c='0')and(i=0)then continue;\n val(c,j,code);\n for l:=1 to g do\n if (s[l]=c) and (get(i,l)=0) then\n begin\n f[set1(i,l),newost(ost,j)]:=f[set1(i,l),newost(ost,j)]+f[i,ost];\n break;\n end;\n end;\n end;\n writeln(f[(1 shl g)-1,0]);\nend.\n"}, {"source_code": "{$r-,s-,q-,i-,o+}\nvar\n n,m,g,i,j,ost,l,vzyali:longint;s:ansistring;\n code : integer;\n c : char;\n f : array [0..200,0..200,0..200] of int64;\n\n function set1(m,b:int64):int64;begin exit(m or (1 shl ((length(s)-b+1)-1)));end;\n function get(m,b:int64):int64;begin exit(ord((m and (1 shl ((length(s)-b+1)-1))=(1 shl ((length(s)-b+1)-1)))));end;\n function newost(x,y:int64):int64;var res:int64;begin res:=x;res:=(10*res)mod m;res:=(y+res)mod m;exit(res mod m); end;\n function cifra(c:char):longint;var res:longint;code:integer;begin val(c,res,code);exit(res);end;\n\nbegin\n readln(n,m);str(n,s);\n g:=length(s);\n fillchar(f,sizeof(f),0);\n f[0,0,0]:=1;\n for i:=0 to 1 shl g-1 do\n for ost:=0 to m-1 do\n for vzyali:=0 to g do\n if f[i,ost,vzyali]>0 then\n begin\n for c:='0' to '9' do\n begin\n if(c='0')and(vzyali=0)then continue;\n val(c,j,code);\n for l:=1 to g do\n if (s[l]=c) and (get(i,l)=0) then\n begin\n f[set1(i,l),newost(ost,j),vzyali+1]:=f[set1(i,l),newost(ost,j),vzyali+1]+f[i,ost,vzyali];\n break;\n end;\n end;\n end;\n writeln(f[1 shl g-1,0,g]);\nend.\n"}, {"source_code": "const fi=''; fo='';\n\nVar n,m:longint;\n last:longword;\n d:array[0..(1 shl 18),0..20] of Qword;\n pow:array[0..20] of Qword;\n list:array[0..20] of byte;\n A,B:array[0..20] of byte;\n dd:array[0..10] of boolean;\n vt:array[0..10] of Longint;\n\n\nProcedure doc;\nVar kk:Qword; i:longint;\nbegin\n assign(input,fi); reset(input);\n Readln(KK,m);\n while (kk<>0) do\n begin\n inc(n);\n B[n]:=kk mod 10;\n kk:=kk div 10;\n end;\n for i:=1 to n do\n A[i]:=B[n-i+1];\nend;\n\nFunction getbit(x:longword; i:byte):byte;\nbegin\n getbit:=(x Shr i) and 1;\nend;\n\nFunction bitoff(x:longword; i:byte):longword;\nbegin\n bitoff:=x and (not (1 Shl i));\nend;\n\nprocedure xuly;\nVar s,p:longword;\n i,j,k,kk,k1:longint;\n x:Qword; val:Longint;\nbegin\n pow[1]:=1;\n for i:=2 to n do\n pow[i]:=pow[i-1]*10;\n last:=(1 Shl n)-1;\n for s:=1 to last do\n begin\n for i:=0 to 9 do\n dd[i]:=false;\n k:=0;\n for i:=0 to n-1 do\n if getbit(s,i)=1 then\n begin\n inc(k);\n dd[a[i+1]]:=true;\n vt[a[i+1]]:=i;\n end;\n for i:=0 to 9 do\n if dd[i] then\n If (k<>n) or (i<>0) then\n begin\n j:=vt[i];\n p:=bitoff(s,j);\n x:=(pow[k]*i) mod m;\n for kk:=0 to m do\n begin\n k1:=(x+kk) mod m;\n inc(d[s,k1],d[p,kk]);\n end;\n end;\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo); rewrite(output);\n writeln(d[last,0]);\nend;\n\nbegin\n doc;\n D[0,0]:=1;\n xuly;\n ghi;\nend.\n"}, {"source_code": "{$mode objFpc}\nuses math;\nconst\n finp = '';\n fout = '';\n maxcs = 18;\ntype\n cs = array[0..20] of integer;\nvar\n fi,fo : text;\n n : int64;\n m,sl,vc : integer;\n x : cs;\n fx : array[0..262500,0..110] of int64;\n gt : array[0..20] of int64;\n dd : array[0..9] of integer;\nprocedure openfile;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\nend;\nprocedure closefile;\nbegin\n close(fi);close(fo);\nend;\nprocedure enter;\nvar\n i : integer;\nbegin\n readln(fi,n,m);\nend;\nprocedure swap(t:integer);\nbegin\n sl:=0;\n repeat\n inc(sl);\n x[sl]:=t mod 10;\n t:=t div 10;\n until t=0;\nend;\nfunction get(t,x:integer):integer;\nbegin\n result:=(t>>(x-1)) and 1;\nend;\nprocedure process;\nvar\n i,j,t,k : integer;\n r : int64;\nbegin\n swap(n);\n gt[0]:=1;\n for i:=1 to 18 do\n gt[i]:=gt[i-1]*i;\n fx[0,0]:=1;\n vc:=(1<a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a2[i]lavel then sumplus:=sumplus+a[i]-lavel;\n if a[i]40000000000000000 then goto 2;\n\n end;\n2:\n { for i:=0 to p do writeln(x[i],' ',y[i]);\n } ot:=0;\n for i:=0 to p do for j:=i to p do\n begin\n t1:=min(abs(x[i]-xstart)+abs(y[i]-ystart),abs(x[j]-xstart)+abs(y[j]-ystart));\n t2:=abs(x[i]-x[j])+abs(y[i]-y[j]);\n if t1+t2<=time then ot:=max(ot,j-i+1);\n end;\n\n writeln(ot);\n\n\n\n\n\n 1: close (output);\n end.\n\n\n\n\n\n", "positive_code": [{"source_code": "const jie=50000000000000000;\nvar\n x,y:array[0..1000] of int64;\n ax,ay,bx,by,xs,ys,t,time:int64;\n n,i,ans,anss,j:longint;\nbegin\n readln(x[0],y[0],ax,ay,bx,by);\n readln(xs,ys,t);\n n:=100;\n for i:=1 to n do\n begin\n x[i]:=x[i-1]*ax+bx;\n y[i]:=y[i-1]*ay+by;\n if (x[i]>=jie) or (y[i]>=jie) then break;\n end;\n n:=i-1;\n for i:=0 to n do\n begin\n if anss>ans then ans:=anss;\n anss:=0;\n time:=abs(xs-x[i])+abs(ys-y[i]);\n if time>t then continue;\n inc(anss);\n for j:=i-1 downto 0 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n time:=time+x[i+1]-x[0]+y[i+1]-y[0];\n if time>t then continue;\n inc(anss);\n for j:=i+1 to n-1 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n end;\n if anss>ans then ans:=anss;\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "const jie=100000000000000000;\nvar\n x,y:array[0..100] of int64;\n ax,ay,bx,by,xs,ys,t,time:int64;\n n,i,ans,anss,j:longint;\nbegin\n readln(x[0],y[0],ax,ay,bx,by);\n readln(xs,ys,t);\n n:=100;\n for i:=1 to n do\n begin\n x[i]:=x[i-1]*ax+bx;\n y[i]:=y[i-1]*ay+by;\n if (x[i]>=jie) or (y[i]>=jie) then break;\n end;\n n:=i-1;\n for i:=0 to n do\n begin\n if anss>ans then ans:=anss;\n anss:=0;\n time:=abs(xs-x[i])+abs(ys-y[i]);\n if time>t then continue;\n inc(anss);\n for j:=i-1 downto 0 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n time:=time+x[i+1]-x[0]+y[i+1]-y[0];\n if time>t then continue;\n inc(anss);\n for j:=i+1 to n-1 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n end;\n if anss>ans then ans:=anss;\n writeln(ans);\nend."}, {"source_code": "const jie=100000000000000000;\nvar\n x,y:array[0..100] of int64;\n ax,ay,bx,by,xs,ys,t,time:int64;\n n,i,ans,anss,j:longint;\nbegin\n readln(x[0],y[0],ax,ay,bx,by);\n readln(xs,ys,t);\n n:=100;\n for i:=1 to n do\n begin\n x[i]:=x[i-1]*ax+bx;\n y[i]:=y[i-1]*ay+by;\n if (x[i]>=jie) or (y[i]>=jie) then break;\n end;\n n:=i-1;\n for i:=0 to n do\n begin\n if anss>ans then ans:=anss;\n anss:=0;\n time:=abs(xs-x[i])+abs(ys-y[i]);\n if time>t then continue;\n inc(anss);\n for j:=i-1 downto 0 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n time:=time+x[i+1]-x[1]+y[i+1]-y[1];\n if time>t then continue;\n inc(anss);\n for j:=i+1 to n-1 do\n begin\n time:=time+abs(x[j+1]-x[j])+abs(y[j+1]-y[j]);\n if time>t then break;\n inc(anss);\n end;\n end;\n writeln(ans);\nend."}], "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28"} {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n n,k,m,ans,i,j,x,y:longint;\n f:array[0..99] of int64;\n was:array[0..99] of boolean;\n \n function lucky(x:int64):boolean;\n begin\n lucky:=false;\n while x > 0 do\n begin\n if (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n x:=x div 10;\n end;\n lucky:=true;\n end;\n\n procedure rec(x:int64);\n begin\n if x <= n-m then\n begin\n inc(ans);\n rec(x*10+4);\n rec(x*10+7);\n end;\n end;\n\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(n,k);\n f[0]:=1;\n m:=0;\n while f[m] < k do\n begin\n inc(m);\n f[m]:=f[m-1]*m;\n end;\n if m > n then\n begin\n writeln(-1);\n halt;\n end;\n ans:=0;\n rec(0);\n dec(ans);\n fillchar(was,sizeof(was),false);\n for i:=1 to m do\n begin\n x:=1;\n while k > f[m-i] do\n begin\n inc(x);\n dec(k,f[m-i]);\n end;\n y:=0;\n for j:=1 to x do\n begin\n inc(y);\n while was[y] do inc(y);\n end;\n was[y]:=true;\n if lucky(n-m+i) and lucky(n-m+y) then inc(ans);\n end;\n writeln(ans);\nend.\n", "positive_code": [{"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,f,e : longint;\n begin\n e:=x;\n f:=0;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n inc(f);\n if f=x then begin e:=i;break;end;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w<>0 then inc(X);\n x:=maxx(x);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const\n{ fi='per.inp';\n fo='per.out';}\n fi='';\n fo='';\n maxn=3003;\n\nvar\n f:text;\n gt,c,d,a,b:array[0..maxn]of int64;\n ok:array[0..maxn]of boolean;\n spt,n,k:longint;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yl then check(l)\n else\n for j:=1 to 2 do\n begin\n if j=1 then a[i]:=4\n else a[i]:=7;\n try(i+1,l);\n end;\nend;\n\nfunction luck(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n luck:=true;\nend;\n\nprocedure main;\nvar i,kq,j,t,m:longint;\nbegin\n spt:=0;\n for i:=1 to 10 do try(1,i);\n gt[0]:=1;\n for i:=1 to 13 do gt[i]:=gt[i-1]*i;\n for i:=1 to spt do d[i]:=b[i];\n\n if (n<=13) and (gt[n]=k then break;\n fillchar(ok,sizeof(ok),true);\n for i:=1 to m do\n begin\n for j:=1 to m do\n if ok[j] then\n if k<=gt[m-i] then break\n else k:=k-gt[m-i];\n c[i]:=j;\n ok[j]:=false;\n end;\n for i:=1 to m do\n begin\n j:=n-m+c[i];\n if luck(j) then\n for t:=1 to spt do\n if b[t]=j then\n begin\n d[t]:=n-m+i;\n break;\n end;\n end;\n kq:=0;\n for i:=1 to spt do\n if b[i]<=n then\n if luck(d[i]) then inc(kq);\n end;\n\n assign(f,fo);rewrite(f);\n writeln(f,kq);\n close(F);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "program cf121c;\nvar\n n,i,j,xx,jj,nn:longint;\n jc:array[0..1000]of int64;\n kk,ans,t:int64;\n dl,ne,xl:array[0..10000]of int64;\nprocedure dfs(o:int64);\nbegin\n if o<=4444444444 then begin\n inc(dl[0]);\n // writeln(o);\n dl[dl[0]]:=o;\n dfs(o*10+4);\n dfs(o*10+7);\n end;\nend;\n\nfunction kind(x:longint):boolean;\nbegin\n while x<>0 do begin\n if (x mod 10<>4)and(x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\n\nbegin\n dl[0]:=0;\n dfs(4);\n dfs(7);\n\n for i:=1 to dl[0] do\n for j:=i+1 to dl[0] do\n if dl[j]1000000000 then break;\n end;\n readln(n,kk);\n\n j:=n;\n while (jc[n-j+1]jc[nn-i] do begin\n xx:=j;\n j:=ne[j];\n kk:=kk-jc[nn-i];\n end;\n ne[xx]:=ne[j];\n xl[i]:=j;\n end;\n\n for i:=1 to nn do\n if (kind(jj+xl[i]))and(kind(jj+i)) then inc(ans);\n writeln(ans);\nend.\n\n"}, {"source_code": "var\n z:int64;\n p:array[0..1025]of boolean;\n a,s:array[0..1025]of int64;\n ans,n,m,x,i,j,k,t:Longint;\n\nfunction pd(x:longint):boolean;\nbegin\n while x>0 do begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nbegin\n s[0]:=1; for i:=1 to 13 do s[i]:=s[i-1]*i;\n read(n,m); dec(m);\n if (n<=13) and (m+1>s[n]) then begin writeln(-1); exit end;\n t:=13; if t>n then t:=n; k:=n-t+1;\n a[1]:=4; a[2]:=7; j:=2; i:=0;\n repeat\n inc(i);\n z:=a[i]*10+4; if z 0 do\n begin\n if (t mod 10 <> 4) and (t mod 10 <> 7) then\n begin\n lucky:=False;\n exit;\n end;\n t:=t div 10;\n end;\n lucky:=True;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n f[0]:=1;\n for i:=1 to 14 do f[i]:=f[i-1]*i;\n read(n,k);\n m:=0;\n for i:=1 to n do\n if f[i] >= k then\n begin\n m:=i;\n break;\n end;\n if m = 0 then\n begin\n writeln('-1');\n halt;\n end;\n ans:=0;\n rec(4); rec(7);\n fillchar(was,sizeof(was),False);\n for i:=1 to m do\n begin\n x:=0; y:=1;\n while k > f[m-i] do\n begin\n k:=k-f[m-i];\n inc(y);\n end;\n for j:=1 to y do\n begin\n inc(x);\n while was[x] do inc(x);\n end;\n was[x]:=True;\n if lucky(n-m+i) and lucky(n-m+x) then inc(ans);\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$MODE OBJFPC}\n//(a/b) mod p=a*(b^(p-2)) mod p\nconst\n fo='';\n fi='';\nvar\n n,k,kq:integer;\n tt:int64;\n head:integer;\n first,last:integer;\n p:array[1..100000] of int64;\n ak:array[0..15] of int64;\n a:array[1..15] of integer;\nprocedure input;\nvar f:textfile; i,j:integer;\nbegin\n assign(f,fo);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nprocedure find;\nvar i,j:int64;\nbegin\n i:=1;\n j:=1;\n ak[1]:=1;\n ak[0]:=0;\n while k>i do\n begin\n inc(j);\n i:=i*j;\n ak[j]:=i;\n end;\n head:=n;\n while (head>=0) and (k>ak[n-head]) do dec(head);\nend;\nprocedure init;\nbegin\n first:=1;\n last:=0;\nend;\nprocedure push(i:integer);\nbegin\n inc(last);\n p[last]:=i;\nend;\nfunction pop:integer;\nbegin\n result:=p[first];\n inc(first);\nend;\nprocedure solve;\nvar i,j,u,v:int64;\nbegin\n init;\n push(4);\n push(7);\n kq:=0;\n if 4<=head then inc(kq);\n if 7<=head then inc(kq);\n while first<=last do\n begin\n u:=pop;\n v:=u*10+4;\n if v<=head then begin inc(kq); push(v); end;\n v:=u*10+7;\n if v<=head then begin inc(kq); push(v); end;\n end;\nend;\nprocedure QS(l,h:integer);\nvar i,j:integer; pivot:integer;\nbegin\n if l>=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (ipivot) do dec(j);\n if ia[i]) do inc(i);\n if i=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (i0 do\n begin\n if ((i mod 10)<>4) and ((i mod 10)<>7) then exit(false);\n i:=i div 10;\n end;\n exit(true);\nend;\nprocedure solve2;\nvar i,u,v,cc,d,t:integer;\nbegin\n u:=head+1;\n for i:=u to n do a[i-head]:=i;\n v:=n-head;\n cc:=0;\n while (k>1) and (cc=ak[v-cc] then\n begin\n d:=k div ak[v-cc];\n if k mod ak[v-cc]=0 then\n begin\n d:=d+cc-1;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n k:=0;\n QS2(cc+1,v);\n end\n else\n begin\n k:=k-d*ak[v-cc];\n d:=d+cc;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n QS(cc+1,v);\n end;\n end;\n end;\n for i:=1 to v do\n if check(a[i]) and check(i+head) then inc(kq);\nend;\nprocedure output;\nvar f:textfile; i:integer;\nbegin\n assign(f,fi);\n rewrite(f);\n if head<0 then writeln(f,-1) else\n writeln(f,kq);\n close(f);\nend;\nbegin\n input;\n find;\n if head>=0 then\n begin\n solve;\n solve2;\n end;\n output;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';//lucky.inp';\n fo = '';//lucky.out';\n maxn = round(1e6);\n\nvar\n ip, op : text;\n n, k, res, xx : integer;\n a : array[0..13] of int64;\n vis : array[1..13] of boolean;\n cs : array[1..13] of integer; // so i + (n-pos) o vi tri nao\n top, last : integer;\n q : array[1..maxn] of integer;\n\nfunction check(x : int64) : boolean;\nvar\n s : string;\n i : integer;\nbegin\n str(x, s);\n for i := 1 to length(s) do if (s[i] <> '4')\n and (s[i] <> '7') then exit(false);\n result := true;\nend;\n\nprocedure push(x : int64);\nbegin\n inc(last);\n q[last] := x;\nend;\n\nfunction pop : int64;\nbegin\n result := q[top];\n inc(top);\nend;\n\nfunction low(x, y, z : int64) : boolean;\nbegin\n if x <= z/y then exit(true);\n exit(false);\nend;\n\nprocedure solve;\nvar\n d, u, v : int64;\nbegin\n d := 0;\n top := 1;\n last := 0;\n push(d);\n while top <= last do\n begin\n u := pop;\n if low(u, 10, xx-4) then push(u*10+4);\n if low(u, 10, xx-7) then push(u*10+7);\n end;\n res := res + last-1;\nend;\n\nprocedure process;\nvar\n i, pos, count, j, vj, gan, luu : integer;\n u, v, d : integer;\nbegin\n readln(ip, n, k);\n a[1] := 1;\n for i := 2 to 13 do a[i] := a[i-1] * i;\n if (n <= 13) and (a[n] < k) then\n begin\n writeln(op, -1);\n exit;\n end;\n for i := 1 to 13 do if a[i] > k then\n begin\n pos := i;\n luu := pos;\n break;\n end;\n fillchar(vis, sizeof(vis), true);\n count := 0;\n gan := 0;\n a[0] := 1;\n while (pos > 0) and (k > 0) do\n begin\n dec(pos);\n inc(gan);\n if k mod a[pos] = 0 then u := k div a[pos]\n else u := k div a[pos] + 1;\n k := k - (u-1) * a[pos];\n vj := 0;\n for j := 1 to 13 do if vis[j] then\n begin\n inc(vj);\n if vj = u then\n break;\n end;\n vis[j] := false;\n cs[j] := gan;\n end;\n res := 0;\n xx := n-luu;\n solve;\n for i := n-luu+1 to n do\n if check(i) and check(cs[i-(n-luu)] + n-luu) then inc(res);\n writeln(op, res);\nend;\n\nbegin\n assign(ip, fi); reset(ip);\n assign(op, fo); rewrite(op);\n process;\n close(ip);\n close(op);\nend.\n\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n inf=1000000000;\nvar\n ss,m,i,j,n,k,kt,res:longint;\n t:array[0..500500]of longint;\n q,fact:array[0..500]of longint;\n was:array[0..500500]of boolean;\n procedure gen(x:longint);\n begin\n if (x<>0)then begin\n inc(kt);t[kt]:=x;\n end;\n if (int64(x)*10>inf)then exit;\n gen(x*10+4);\n gen(x*10+7);\n end;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n,k);\n kt:=0;\n gen(0);\n res:=0;\n for i:=1 to kt do\n if (t[i]13)then begin\n m:=13;\n ss:=n-12;\n for i:=1 to m do fact[i]:=fact[i-1]*i;\n end else begin\n for i:=1 to n do fact[i]:=fact[i-1]*i;\n if (k>fact[n])then begin\n writeln(-1);\n exit;\n end;\n end;\n fillchar(was,sizeof(was),false);\n for i:=1 to m do begin\n j:=1;\n while (true)do begin\n while (was[j])do inc(j);\n if (k>fact[m-i])then begin\n dec(k,fact[m-i]);\n inc(j);\n end else break;\n end;\n was[j]:=true;\n q[i]:=ss+j-1;\n end;\n for i:=1 to kt do\n if (t[i]>=ss)and(t[i]<=n)then\n for j:=1 to kt do\n if (q[t[i]-ss+1]=t[j])then inc(res);\n writeln(res);\n close(output);close(input);\nend."}, {"source_code": "Program C_LuckyPermutation;\nConst MaxN=1024;\nVar n,m,k,count:Longint;\n gt:array[0..13] of Int64;\n a,d:array[1..13] of Longint;\n arr:array[0..MaxN] of Int64;\n\nProcedure AddResult(i:Longint);\nVar j:Longint;\nBegin\n Inc(m);\n arr[m]:=0;\n For j:=1 to i do arr[m]:=arr[m]*10+d[j];\nEnd;\n\nProcedure Try(i:Longint);\nVar j:Longint;\nBegin\n If i>9 then Exit;\n d[i]:=4;\n AddResult(i);\n Try(i+1);\n d[i]:=7;\n AddResult(i);\n Try(i+1);\nEnd;\n\nProcedure Swap(Var a,b:Int64);\nVar t:Int64;\nBegin t:=a; a:=b; b:=t End;\n\nProcedure QuickSort(L,r:Longint);\nVar i,j:Longint;\n k:Int64;\nBegin\n If l>=r then exit;\n i:=l; j:=r;\n k:=arr[random(r-l+1)+l];\n Repeat\n While arr[i]k do Dec(j);\n If i<=j then\n Begin\n If ij;\n QuickSort(l,j); QUickSort(i,r)\nEnd;\n\nProcedure Init;\nVar i:Longint;\nBegin\n Try(1);\n QuickSort(1,m);\n Inc(m); arr[m]:=4444444444; arr[0]:=-MaxLongint;\n gt[0]:=1;\n For i:=1 to 13 do gt[i]:=gt[i-1]*i;\nEnd;\n\nProcedure Input;\nVar f:Text;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,n,k);\n Close(f)\nEnd;\n\nFunction IsLuckyNum(v:Int64):Boolean;\nVar k:Longint;\nBegin\n While v<>0 do\n Begin\n k:=v mod 10;\n If (k<>4) and (k<>7) then Exit(False);\n v:=v div 10;\n End;\n Exit(True);\nEnd;\n\nProcedure Delete(t:Longint);\nVar j:Longint;\nBegin\n For j:=t to count-1 do a[j]:=a[j+1];\n Dec(count);\nEnd;\n\nProcedure Solve;\nVar i,res,j,p,v:Longint;\nBegin\n If (n<=13) and (k>gt[n]) then\n Begin\n Writeln(-1);\n Exit;\n End;\n For i:=m downto 0 do If arr[i]<(n-12) then Break;\n res:=i;\n i:=n-12; If i<1 then i:=1;\n Begin\n For j:=i to n do a[j-i+1]:=j;\n count:=n-i+1;\n For j:=1 to count do\n Begin\n For p:=1 to count do\n If k-10 do begin\n if (s mod 10<>4) and (s mod 10<>7) then exit(false);\n s:=s div 10;\n end;\n exit(true);\n end;\n\nbegin\n o:=0;\n for i:=1 to 9 do begin\n fillchar(b,sizeof(b),0);\n while b[0]=0 do begin\n s:=0;\n for j:=1 to i do\n if b[j]=0 then s:=s*10+4 else s:=s*10+7;\n inc(o);\n a[o]:=s;\n j:=i;\n while b[j]=1 do begin\n b[j]:=0;\n dec(j);\n end;\n inc(b[j]);\n end;\n end;\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=int64(fact[i-1])*i;\n if n<=15 then begin\n if k>fact[n] then begin\n writeln(-1);\n halt;\n end;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then begin\n inc(e);\n if e=c then begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n sum:=0;\n for i:=1 to n do\n if lucky(i) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end\n else begin\n sc:=n-15;\n n:=15;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then begin\n inc(e);\n if e=c then begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n for i:=1 to n do\n ans[i]:=ans[i]+sc;\n sum:=0;\n for i:=1 to o do\n if a[i]<=sc then inc(sum);\n for i:=1 to n do\n if lucky(i+sc) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end;\nend."}, {"source_code": "var f1,f2:text;\ngt:array[0..100] of int64;\nA,B:array[1..100] of longint;\nKQ:array[1..100] of longint;\nL:array[1..100000] of int64;\nscs:longint;\ngh:longint;\nres:longint;\ni,s,n,k,spt,maxso:longint;\nProcedure TimSH(n:longint);\nvar i,dem,j:byte;\n GT:longint;\nBegin\n S:=k;\n GT:=1;\n for i:=1 to n-1 do\n GT:=GT*i;\n For i:=1 to n do\n Begin\n B[i]:=i;\n if S mod GT <> 0 then\n Begin\n A[i]:=S Div GT+1;\n S:=S mod GT;\n End\n else\n Begin\n A[i]:=S div GT;\n S:=GT;\n End;\n if n<>i then\n GT:=GT div (n-i);\n ENd;\n For i:=1 to n do\n Begin\n dem:=0;\n For j:=1 to n do\n Begin\n if (B[j]<>0) then\n Inc(dem);\n if dem = A[i] then break;\n End;\n KQ[i]:=B[j];\n B[j]:=0;\n End;\nEnd;\n\nProcedure Gen(vt:longint;so:int64);\nBegin\n if vt=maxso+1 then\n Begin\n Inc(spt);\n L[spt]:=so;\n exit;\n End;\n Gen(vt+1,so*10+4);\n Gen(vt+1,so*10+7);\nEnd;\n\nFunction lucky(so:longint):boolean;\nvar i:longint;\nst:string;\nBegin\n str(so,st);\n For i:=1 to length(st) do\n if Not((st[i]='4') or (st[i]='7')) then exit(false);\n Exit(true);\nend;\n\nProcedure Process;\nvar i:longint;\nbegin\n\n FOr maxso:=1 to 10 do\n Gen(1,0);\n\n gt[0]:=1;\n FOr i:=1 to n do\n Begin\n gt[i]:=gt[i-1]*i;\n if gt[i]>k then\n begin\n scs:=i;\n gh:=n-scs;\n break;\n End;\n End;\n\n if k>gt[i] then\n Begin\n writeln(f2,-1);\n exit;\n End;\n if gt[i]=k then scs:=n;\n TimSH(scs);\n For i:=1 to scs do\n KQ[i]:=KQ[i]+gh;\n For i:=1 to spt do\n if L[i]<=gh then\n Inc(res);\n For i:=1 to scs do\n if lucky(KQ[i]) and (lucky(i+gh)) then\n inc(res);\n writeln(f2,res);\nend;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n,k);\n Process;\n close(f1);\n close(f2);\nEnd.\n"}, {"source_code": "var otv,n,m,i,j,k,count,answer,num,cnt,q,t,numb,number,qans:longint;\n a:array[0..10001] of int64;\n b,c:array[0..20] of longint;\n fact:longint;\nprocedure rec(q:int64);\nvar i:longint;\nbegin\n if q<=1000000000 then\n begin\n inc(count);\n a[count]:=q;\n end else\n exit;\n rec(q*10+4);\n rec(q*10+7);\nend;\n\nfunction factor(ver:longint):longint;\nvar i,ans:longint;\nbegin\n ans:=1;\n for i:= 1 to ver do\n ans:=ans*i;\n factor:=ans;\nend;\n\n\nfunction fun(lik:longint):boolean;\nvar i:longint;\nbegin\n for i:= 1 to count do\n if a[i]=lik then\n begin\n fun:=true;\n exit;\n end;\n fun:=false;\nend;\n\n\nbegin\n count:=0;\n readln(n,m);\n rec(0);\n answer:=0;\n fact:=1;\n num:=0;\n for i:= 1 to n do\n begin\n fact:=fact*i;\n if fact>=m then\n begin\n num:=i;\n break;\n end;\n if num<>0 then break;\n end;\n if num=0 then begin writeln(-1); halt; end;\n cnt:=0;\n q:=n-num+1;\n for i:= 1 to num do\n begin\n inc(cnt);\n c[cnt]:=q+i-1;\n end;\n qans:=0;\n k:=m;\n for i:= 1 to cnt do\n begin\n t:=factor(num-1);\n if k mod t = 0 then number:=k div t else\n number:=k div t + 1;\n k:= k mod t;\n if k=0 then k:=t;\n inc(qans);\n b[qans]:=c[number];\n for j:= number to num-1 do\n c[j]:=c[j+1];\n c[num]:=0;\n dec(num);\n end;\n otv:=0;\n for i:= 1 to count do\n if a[i]9 then exit;\n if s<>'' then\n begin\n inc(m);\n val(s,a[m],code);\n end;\n create(s+'4');\n create(s+'7');\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint;\n t,x:qword;\nbegin\n if l>=r then exit;\n i:=l; j:=r;\n t:=a[(l+r) div 2];\n repeat\n while a[i]t do dec(j);\n if i<=j then\n begin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n inc(i);\n dec(j);\n end;\n until i>j;\n sort(l,j);\n sort(i,r);\nend;\n\nprocedure check;\nvar i:longint;\nbegin\n s:=1;\n p:=0;\n for i:=1 to n do\n if s*i>abc then break\n else\n begin\n inc(p);\n s:=s*i;\n end;\n\n if k>s then\n begin\n writeln(-1);\n halt;\n end;\nend;\n\nfunction chk(x:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(x,s);\n if s='' then exit(false);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n exit(true);\nend;\n\nprocedure timhoanvi;\nvar i,j,t,count:longint;\nbegin\n for i:=1 to p do\n begin\n s:=s div (p-i+1);\n\n t:=(k+s-1) div s;\n k:=k-(t-1)*s;\n count:=0;\n for j:=1 to p do\n if kt[j]=false then\n begin\n inc(count);\n if count=t then break;\n end;\n\n kt[j]:=true;\n\n if chk(n-p+i) and chk(n-p+j) then inc(res);\n end;\nend;\n\nprocedure tinh;\nvar i:longint;\nbegin\n res:=0;\n for i:=1 to m do\n if a[i]<=n-p then inc(res)\n else break;\n\n timhoanvi;\nend;\n\nbegin\n readln(n,k);\n check;\n m:=0;\n create('');\n sort(1,m);\n tinh;\n writeln(res);\n readln;\nend.\n"}, {"source_code": "var l,j,n,k,i:longint;\nans,s:int64;\nw,q,fa:array[0..15]of int64;\nnum:array[0..15]of longint;\nu:array[0..15]of boolean;\n\nfunction good(x:int64):boolean;\n begin\n while x>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7) then\n begin\n good:=false;\n exit;\n end;\n x:=x div 10;\n end;\n good:=true;\n end;\n\nprocedure gen(v:int64);\n begin\n if v>n then exit;\n\n if v<=n-j then ans:=ans+1;\n\n gen(v*10+4);\n gen(v*10+7);\n end;\n\n begin\n read(n,k);\n s:=1;\n for i:=1 to n do\n begin\n s:=s*i;\n if s>=k then\n begin\n j:=i;\n break;\n end;\n end;\n\n if s=k then\n begin\n num[i]:=l;\n u[l]:=false;\n break;\n end;\n k:=k-fa[j-i];\n end;\n end;\n for i:=1 to j do\n begin\n w[i]:=q[num[i]];\n if good(n-j+i) and good(w[i]) then ans:=ans+1;\n end;\n\n writeln(ans);\n end."}, {"source_code": "Program Lucky_Permutation;\nvar n,k,i,j,z,s,ans:longint;\n p:array[0..20]of int64;\n used:array[1..20]of boolean;\n//========================================================================\nfunction lucky(x:longint):boolean;\nbegin\n while x>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n//========================================================================\nprocedure Create(x:int64);\nbegin\n if x>s then exit;\n inc(ans);\n Create(x*10+4);Create(x*10+7);\nend;\n//========================================================================\nbegin\n readln(n,k);\n p[0]:=1;\n for i:=1 to 20 do p[i]:=p[i-1]*i;\n if (n<=20)and(p[n]=k then break;\n s:=i;\n for i:=s-1 downto 0 do\n begin\n for j:=1 to s do\n begin\n if k<=p[i] then break;\n k:=k-p[i];\n end;\n z:=0;\n while j>0 do\n begin\n inc(z);\n if not used[z] then dec(j);\n end;\n used[z]:=true;\n if lucky(n-i) and lucky(n-s+z) then inc(ans);\n end;\n s:=n-s;\n Create(4);Create(7);\n writeln(ans);\nend.\n"}, {"source_code": "var a1:array[1..5000] of qword;\n a:array[1..20] of qword;\n ans:array[1..20] of longint;\n bo:array[1..20] of boolean;\n i,j,n,k,n1,tot,sum:longint;\n t,cator:qword;\n flag:boolean;\nprocedure dfs(m:longint; s:string);\n var t:qword;\n begin\n if m>10 then exit;\n if m>0 then\n begin\n val(s,t);\n inc(tot);\n a1[tot]:=t;\n end;\n dfs(m+1,s+'4');\n dfs(m+1,s+'7');\n end;\nfunction cal(x:longint):qword;\n var i:longint;\n s:qword;\n begin\n s:=1;\n for i:=1 to x do s:=s*i;\n exit(s);\n end;\nfunction check(x:longint):boolean;\n var i,t:longint;\n s:string;\n begin\n t:=x+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n t:=ans[x]+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n exit(true);\n end;\nbegin\n fillchar(bo,sizeof(bo),false);\n readln(n,k);\n flag:=false;\n cator:=1;\n for i:=1 to n do\n begin\n cator:=cator*i;\n if cator>=k then\n begin\n flag:=true;\n break;\n end;\n end;\n if not flag then\n begin\n writeln('-1');\n halt;\n end;\n if n>15 then\n begin\n n1:=n-15;\n n:=15;\n dfs(0,'');\n for i:=1 to tot-1 do\n for j:=i+1 to tot do\n if a1[i]>a1[j] then\n begin\n t:=a1[i];\n a1[i]:=a1[j];\n a1[j]:=t;\n end;\n for i:=1 to tot do\n if a1[i]<=n1 then inc(sum)\n else break;\n end;\n cator:=k-1;\n for i:=n-1 downto 1 do\n begin\n flag:=false;\n a[n-i]:=cator div cal(i);\n cator:=cator mod cal(i);\n t:=0;\n j:=1;\n while (j<=n)and not flag do\n if not bo[j] then begin\n inc(t);\n if t=a[n-i]+1 then begin\n ans[n-i]:=j;\n flag:=true;\n bo[j]:=true;\n end\n else inc(j);\n end\n else inc(j);\n end;\n for i:=1 to n do\n if not bo[i] then\n begin\n ans[n]:=i;\n break;\n end;\n for i:=1 to n do\n if check(i) then inc(sum);\n writeln(sum);\nend."}, {"source_code": "{$mode objfpc}\nconst\n fi='';\n fo='';\nvar\n a:array[1..2]of integer=(4,7);\n luckynum:array[0..3000]of int64;\n x,CT:Array[0..13]of integer;\n avail:array[0..13]of boolean;\n c:array[0..13]of int64;\n m,k:int64;\n n:integer;\n res:int64;\n f,g:Text;\n flag:boolean;\n\nprocedure attemp(i:integer;s:int64);\nvar j:integer;\nbegin\n for j:= 1 to 2 do\n begin\n s:=s*10+a[j];\n if i=n then begin inc(m);luckynum[m]:=s; end else attemp(i+1,s);\n s:=s div 10;\n end;\nend;\n\nfunction find(x:int64):boolean;\nvar l,h:integer;\n mid:integer;\nbegin\n l:=1;h:=m;\n while l<=h do\n begin\n mid:=(l+h) div 2;\n if luckynum[mid]=x then exit(true);\n if luckynum[mid]13 then\n begin\n kt:=n-13;\n For j:=1 to m do\n if luckynum[j]<=kt then inc(res) else break;\n n:=13;\n flag:=true;\n end;\n For i:=1 to n do ct[i]:=kt+i;\n c[0]:=1;\n for i:=1 to n do c[i]:=c[i-1]*i;\n flag:=flag or (c[n]>=k);\n fillchar(avail,sizeof(avail),true);\n for i:=1 to n do\n begin\n for j:=1 to n do\n if avail[j] then\n if (k>c[n-i]) then dec(k,c[n-i]) else break;\n x[i]:=j;avail[j]:=false;\n end;\n For i:=1 to n do\n begin\n if find(ct[x[i]]) and (find(i+kt)) then inc(res);\n end;\nend;\n\nprocedure openf;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\n\nprocedure closef;\nbegin\n close(f);close(g);\nend;\n\nprocedure print;\nbegin\n if flag then writeln(g,res) else writeln(g,'-1');\nend;\n\n\nbegin\n openf;\n solve;\n print;\n closef;\nend.\n\n"}, {"source_code": "const\n fi='';\nvar\n f:Text;\n k,kq,m:longint;\n g:array [1..13,1..13] of longint;\n kt:array [1..13] of boolean;\n a,v,b:array [1..13] of longint;\n d:array [1..10] of boolean;\n lucky:array [1..2046] of int64;\n n:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nfunction ck(u:longint):boolean;\nvar\n x:longint;\nbegin\n x:=u;\n while x>0 do\n begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\nprocedure cb;\nvar\n i,j,u:longint;\nbegin\n g[1,1]:=1;\n g[2,1]:=1; g[2,2]:=1; u:=2;\n for i:=3 to 13 do\n begin\n for j:=1 to i do g[i,j]:=g[i-1,j]*u;\n g[i,i]:=g[i,i-1];\n inc(u);\n end;\nend;\nprocedure lam1;\nvar\n i,j,u,s,d,o:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=n downto 1 do\n begin\n s:=0; d:=0; o:=1;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n o:=0;\n break;\n end;\n end;\n if o=1 then\n begin\n writeln(-1);\n halt;\n end;\n s:=0;\n for j:=1 to n do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[n-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n kq:=0;\n for i:=1 to n do\n if (ck(i)) and (ck(a[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure sinh(u,le:longint);\n var\n i:longint;\n so:int64;\n begin\n if u>le then\n begin\n so:=0;\n for i:=1 to le do\n begin\n so:=so*10;\n if d[i] then so:=so+4\n else so:=so+7;\n end;\n inc(m);\n lucky[m]:=so;\n end\n else\n begin\n d[u]:=true;\n sinh(u+1,le);\n d[u]:=false;\n sinh(u+1,le);\n end;\n end;\n procedure quicksort(l,r:longint);\n var\n i,j:longint;\n p,t:int64;\n begin\n if l>=r then exit;\n i:=l; j:=r;\n p:=lucky[(i+j) div 2];\n repeat\n while lucky[i]

p do dec(j);\n if i<=j then\n begin\n t:=lucky[i]; lucky[i]:=lucky[j]; lucky[j]:=t;\n inc(i); dec(j);\n end;\n until i>=j;\n quicksort(l,j);\n quicksort(i,r);\n end;\n procedure tao;\n var\n i:longint;\n begin\n m:=0;\n for i:=1 to 10 do\n begin\n fillchar(d,sizeof(d),true);\n sinh(1,i);\n end;\n quicksort(1,m);\n end;\nprocedure lam2;\nvar\n i,j,u,s,d,o:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=13 downto 1 do\n begin\n s:=0; d:=0; o:=1;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n o:=0;\n break;\n end;\n end;\n if o=1 then\n begin\n writeln(-1);\n halt;\n end;\n s:=0;\n for j:=1 to 13 do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[13-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n for i:=1 to 13 do v[i]:=n-13+i;\n for i:=1 to 13 do b[i]:=n-13+a[i];\n tao;\n kq:=0;\n for i:=1 to 2046 do\n begin\n if lucky[i]=n-13 then\n begin\n kq:=i;\n break;\n end\n else\n if lucky[i]>n-13 then\n begin\n kq:=i-1;\n break;\n end;\n end;\n for i:=1 to 13 do\n if (ck(b[i])) and (ck(v[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure xuly;\nbegin\n if n<=13 then lam1\n else lam2;\nend;\nbegin\n nhap;\n cb;\n xuly;\nend.\n\n"}, {"source_code": "var b:array[0..10] of longint;\n a:array[0..100000] of longint;\n i,o,s,j,n,k,c,e,sum,sc:longint;\n fact:array[0..15] of int64;\n use,ans:array[0..20] of longint;\n\nfunction lucky(s:longint):boolean;\n begin\n while s>0 do\n begin\n if (s mod 10<>4) and (s mod 10<>7) then exit(false);\n s:=s div 10;\n end;\n exit(true);\n end;\n\nbegin\n o:=0;\n for i:=1 to 9 do\n begin\n fillchar(b,sizeof(b),0);\n while b[0]=0 do\n begin\n s:=0;\n for j:=1 to i do\n if b[j]=0 then s:=s*10+4 else s:=s*10+7;\n inc(o);\n a[o]:=s;\n j:=i;\n while b[j]=1 do\n begin\n b[j]:=0;\n dec(j);\n end;\n inc(b[j]);\n end;\n end;\n //for i:=1 to o do writeln(a[i]);\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=int64(fact[i-1])*i;\n if n<=15 then\n begin\n if k>fact[n] then\n begin\n writeln(-1);\n halt;\n end;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do\n begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then\n begin\n inc(e);\n if e=c then\n begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n //for i:=1 to n do write(ans[i],' ');writeln;\n sum:=0;\n for i:=1 to n do\n if lucky(i) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end\n else\n begin\n sc:=n-15;\n n:=15;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do\n begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then\n begin\n inc(e);\n if e=c then\n begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n for i:=1 to n do ans[i]:=ans[i]+sc;\n //for i:=1 to sc do write(i,' ');for i:=1 to n do write(ans[i],' ');writeln;\n sum:=0;\n for i:=1 to o do\n if a[i]<=sc then inc(sum);\n for i:=1 to n do\n if lucky(i+sc) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1023;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..30] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 15 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 1000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j , k : integer;\n\nbegin\n j := n ;\n k := 0 ;\n if n > 15 then begin\n k := n - 15;\n n := 15;\n end ;\n\n if m > gt[n] then begin\n writeln(-1) ;\n halt ;\n end ;\n process1;\n\n// for i := 1 to n do inc(a[i], n ) ;\n for i := 1 to n do\n if ok(i+k) and ok(a[i]+k) then inc(res) ;\n\n n := j;\n for i := 2 to nlk do begin\n\n if lk[i] > n - 15 then break ;\n inc(res) ;\n end ;\n\n// if res = 0 then res := -1;\n writeln(Res);\nend ;\nbegin\n cal(0) ;qsort(1,nlk) ;\n enter;\n\n process;\nend.\n"}, {"source_code": "uses math;\nconst\n oo=high(longint);\n _oo=high(int64);\n roo=1e30;\n dx:array[0..7] of longint=(-1,0,1,0,-1,1,1,-1);\n dy:array[0..7] of longint=(0,1,0,-1,1,1,-1,-1);\n hs=13;\ntype point=record x,y:longint; end;\n rpoint=record x,y:double; end;\nvar f,g:text;\n fi,fo:string;\n a:array[0..111111] of int64;\n gt,num:array[0..33] of int64;\n fr:array[0..33] of boolean;\n nluc,n,i,j,last,nn,ans:longint;\n be,k,nho:int64;\nprocedure closefile; begin close(g); close(F); end;\n//-----------------\nprocedure sort(l,r:longint);\nvar i,j:longint;\n m,tmp:int64;\nbegin\n if l>=r then exit;\n i:=l; j:=r; m:=a[l+random(r-l+1)];\n repeat\n while a[i]m do dec(j);\n if i<=j then begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>J;\n sort(i,r);\n sort(l,j);\nend;\nprocedure gen;\nvar i,j,k:Longint;\nbegin\n\n for i:=1 to 11 do\n for j:=0 to 1<>k) and 1=0 then a[nluc]:=a[nluc]*10+4\n else a[nluc]:=a[nluc]*10+7;\n end;\n sort(1,nluc);\nend;\n//---------------------\nfunction isluck(u:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(u,s);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n isluck:=true;\nend;\nbegin\n gen;\n\n randomize;\n // {$IFNDEF ONLINE_JUDGE} fi := 'i.inp'; fo := ''; {$ENDIF}\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,n,k);\n gt[0]:=1;\n for i:=1 to 12 do gt[i]:=gt[i-1]*i;\n gt[13]:=oo;\n nn:=min(n,hs);\n if n>hs then be:=n-hs\n else be:=0;\n ans:=0;\n if n>hs then begin\n for i:=1 to nluc do\n if a[i]>n-hs then break;\n ans:=i-1;\n end;\n if (ngt[n]) then begin\n writeln(g,-1);\n closefile;\n halt;\n end;\n //\n for i:=1 to nn do fr[i]:=true;\n for i:=1 to nn-1 do begin\n nho:=0; last:=0;\n for j:=1 to nn do\n if (nho*gt[nn-i]>=k) then break\n else if fr[j] then begin\n inc(nho);\n last:=j;\n end;\n\n dec(k,(nho-1)*gt[nn-i]);\n num[i]:=last;\n fr[last]:=false;\n end;\n for i:=1 to nn do\n if fr[i] then num[nn]:=i;\n for i:=1 to nn do\n if isluck(i+be) and isluck(num[i]+be) then inc(ans);\n //\n writeln(g,ans);\n closefile;\nend.\n\n"}, {"source_code": "uses\n math;\nvar\n a,fact:array[0..13] of int64;\n ans,n,k:int64;\n i:longint;\n\nfunction check(x:int64):boolean;\nvar\n z:int64;\nbegin\n check:=false;\n if (x>n) then exit;\n z:=n-x+1;\n if (z<=13) then z:=a[z] else z:=x;\n while (z<>0) do\n begin\n if (z mod 10<>4) and (z mod 10<>7) then exit;\n z:=z div 10;\n end;\n check:=true;\nend;\n\nprocedure swap(i,j:longint);\nvar\n x:int64;\nbegin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\nend;\n\nprocedure rec(nom,ost:int64);\nvar\n x:int64;\n i,j:longint;\n good:boolean;\nbegin\n if (nom=0) then exit;\n good:=false;\n for i:=nom downto 1 do\n begin\n x:=(nom-i+1)*fact[nom-1];\n if (ost<=x) then begin swap(nom,i); good:=true; break; end;\n end;\n if (not good) then begin writeln('-1'); halt; end;\n for i:=1 to nom-1 do for j:=i+1 to nom-1 do if (a[i]1) and (check(x)) then inc(ans);\n if (nom=10) then exit;\n gen(nom+1,x*10+4);\n gen(nom+1,x*10+7);\nend;\n\nbegin\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 13 do fact[i]:=fact[i-1]*i;\n for i:=min(13,n) downto 1 do a[i]:=n-i+1;\n rec(min(13,n),k);\n gen(1,0);\n writeln(ans);\nend."}, {"source_code": "{$mode objfpc}\nvar f:text;\n n,k:longint;\n a,b:array[0..13] of int64;\n pivot,m,l:int64;\n q:array[1..1100] of int64;\n first,last:longint;\n dem:longint;\n\nprocedure input;\nbegin\n assign(f,'');\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure push(x:int64);\nbegin\n inc(last);\n q[last]:=x;\nend;\n\nfunction pop:int64;\nbegin\n pop:=q[first];\n inc(first);\nend;\n\nprocedure init;\nvar u,v:int64;\n i:longint;\nbegin\n dem:=0;\n pivot:=1;\n b[0]:=1;\n b[1]:=1;\n first:=1;\n last:=0;\n while k>b[pivot] do\n begin\n inc(pivot);\n b[pivot]:=b[pivot-1]*pivot;\n end;\n m:=pivot;\n l:=n-pivot+1;\n if l<=0 then\n begin\n dem:=-1;\n exit;\n end;\n if 4=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l];\n i:=l;\n j:=h;\n repeat\n while (ipivot) do dec(j);\n if i0 do\n begin\n u:=v mod 10;\n if u<>4 then\n if u<>7 then exit(false);\n v:=v div 10;\n end;\n exit(true);\nend;\n\nprocedure swap(var a,b:int64);\nvar temp:int64;\nbegin\n temp:=a;\n a:=b;\n b:=temp;\nend;\n\nprocedure solve;\nvar i:longint;\nbegin\n while k<>0 do\n for i:=1 to pivot do\n if (k>(int64(i)-1)*b[pivot-1]) and (k<=(int64(i)*b[pivot-1])) then\n begin\n swap(a[m-pivot+i],a[m-pivot+1]);\n qs(m-pivot+2,m);\n k:=k-(int64(i)-1)*b[pivot-1];\n if k=1 then exit;\n dec(pivot);\n end;\nend;\n\nprocedure output;\nvar i:longint;\nbegin\n if dem<>-1 then\n for i:=1 to m do\n if kt(a[i]) and kt(i+l-1) then inc(dem);\n writeln(dem);\nend;\n\nbegin\n input;\n init;\n if dem<>-1 then solve;\n output;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$maxstacksize 2000000}\nvar\n ans,nb,l,q,j,add,n,k,i:integer;\n fc:int64;\n a:array[1..15] of integer;\n us:array[1..15] of boolean;\n\n Function lucky(n:integer):boolean;\n var\n b:boolean;\n begin\n b:=true;\n\n while (n>0) and (b) do\n begin\n b:=(n mod 10=7) or (n mod 10=4);\n n:=n div 10;\n end;\n\n lucky:=b;\n end;\n\n Procedure gen(cur:int64);\n begin\n If cur>add then exit;\n If cur>0 then inc(ans);\n gen(cur*10+4);\n gen(cur*10+7);\n end;\n\n\nbegin\n{ reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n readln(n,k);\n\n fc:=1;\n i:=1;\n\n while (fc0)and (m mod 10=7)do begin\n n:=n+1;\n m := m div 10;\n end;\n if m=0 then begin\n res:=0;\n n:=n+1;\n while (n<>0) do begin\n res:=res*10+4;\n n:=n-1;\n end;\n end\n else begin\n res:=(m div 10)*10 +7;\n while (n<>0) do begin\n res:=res*10+4;\n n:=n-1;\n end;\n end;\n gen:=res;\nend;\n\nfunction lucky(u:int64):boolean;\nvar m:int64;\n res:boolean;\nbegin\n res:=true;\n m:=u;\n while m<>0 do begin\n res:=res and((m mod 10 =4)or(m mod 10=7));\n m:=m div 10;\n end;\n lucky:=res;\nend;\n\nfunction nn(u:int64):longint;\nvar res:longint;\n cur:int64;\nbegin\n cur:=4;\n res:=0;\n while (cur<=u) do begin\n inc(res);\n cur:=gen(cur);\n end;\n nn:=res;\nend;\n\nfunction fac(x:int64):int64;\nvar i,res:int64;\nbegin\n i:=1;\n res:=1;\n while(i<=x) do begin\n res:=res*i;\n i:=i+1;\n end;\n fac:=res;\nend;\n\nbegin\n readln(n,k);\n res:=0;\n fillchar(used,sizeof(used),false);\n if n>13 then begin\n res:=res+nn(n-13);\n curi:=n-12;\n l:=1;\n end\n else begin\n curi:=1;\n l:=13-n+1;\n cur:=fac(n);\n if k>cur then begin\n writeln('-1');\n halt(0);\n end;\n end;\n while (curi<=n) do begin\n cur:=fac(n-curi);\n i:=l;\n while (used[i]) do i:=i+1;;\n ppc:=cur;\n while (ppcy Then Max:=x\n Else Max:=y;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>1000000000 Then Exit;\n i:=i+1;\n r[i]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(n,k);\n f[0]:=1;\n For i:=1 To 14 Do f[i]:=i*f[i-1];\n If n<14 Then\n If k>f[n] Then Begin\n Write(-1);\n Halt;\n End;\n i:=0;\n Get(4);\n Get(7);\n m:=i;\n For i:=1 To m-1 Do\n For j:=i+1 To m Do\n If r[i]>r[j] Then Begin\n w:=r[i];\n r[i]:=r[j];\n r[j]:=w;\n End;\n kol:=0;\n t:=Max(1,n-12);\n j:=1;\n n1:=n;\n For i:=t To n Do Begin\n b[j]:=i;\n j:=j+1;\n End;\n For i:=1 To m Do Begin\n If r[i]>=t Then Break;\n kol:=kol+1;\n End;\n If n>12 Then n:=13;\n p:=n;\n i:=0;\n While True Do Begin\n i:=i+1;\n v:=k div f[n-1];\n If k mod f[n-1]<>0 Then v:=v+1;\n a[i]:=b[v];\n j:=1;\n n:=n-1;\n If n=0 Then Break;\n For l:=1 To n Do Begin\n If b[l]=a[i] Then j:=j+1;\n b[l]:=b[j];\n j:=j+1;\n End;\n k:=k mod f[n];\n If k=0 Then k:=f[n];\n End;\n l:=Max(1,n1-12);\n For i:=1 To p Do Begin\n f1:=0;\n f2:=0;\n For j:=1 To m Do Begin\n If r[j]=l Then f1:=1;\n If r[j]=a[i] Then f2:=1;\n End;\n If (f1=1) and (f2=1) Then kol:=kol+1;\n l:=l+1;\n End;\n Write(kol);\nEnd."}, {"source_code": "program Project5;\n\n{$APPTYPE CONSOLE}\n\nvar\n n, k, x, ans, p, d: int64;\n i, j, z, t: longint;\n a: array[1..10000] of int64;\n b: array[1..20] of longint;\n mas: array[1..20] of int64;\n\nprocedure gen47(k, x, n: longint);\nbegin\n if k > n then begin\n inc(t);\n a[t] := x;\n end else begin\n x := x * 10 + 4;\n gen47(k + 1, x, n);\n x := x div 10;\n x := x * 10 + 7;\n gen47(k + 1, x, n);\n end;\nend;\n\nfunction fact(x: int64): int64;\n\nvar\n ans: int64;\n i: longint;\n\nbegin\n if x > 13 then\n result := k + 1\n else if x = 0 then\n result := 1\n else begin\n ans := 1;\n for i := 2 to x do\n ans := ans * i;\n result := ans;\n end;\nend;\n\nfunction f(x: longint): longint;\n\nvar\n i, ans: longint;\n\nbegin\n i := 1;\n while a[i] <= x do\n inc(i);\n result := i - 1;\nend;\n\nfunction sch(x: int64): boolean;\n\nvar i: longint;\n\nbegin\n for i := 1 to t do\n if a[i] = x then begin\n result := true;\n exit;\n end;\n result := false; \nend;\n\nbegin\n {assignfile(input, 'input.txt');\n reset(input);\n assignfile(output, 'output.txt');\n rewrite(output);}\n\n read(n, k);\n ans := 0;\n if fact(n) < k then\n write(-1)\n else begin\n\n for i := 1 to 15 do\n b[i] := 0;\n\n t := 0;\n for i := 1 to 9 do\n gen47(1, 0, i);\n inc(t);\n a[t] := 4444444444;\n\n i := 1;\n\n if n > 12 then\n i := n - 12;\n\n d := fact(n - i);\n while d > k do begin\n inc(i);\n d := d div (n - i + 1);\n end;\n ans := ans + f(i - 1);\n\n x := fact(n - i);\n for j := i to n do begin\n\n p := k div x;\n if k mod x = 0 then\n dec(p);\n k := k - p * x;\n inc(p);\n\n if n - j = 0 then\n x := 1\n else\n x := x div (n - j);\n if x = 0 then\n x := 1;\n\n z := 1;\n while p > 0 do begin\n if b[z] = 0 then\n dec(p);\n inc(z);\n end;\n dec(z);\n b[z] := 1;\n\n mas[j - i + 1] := z + i - 1;\n\n end;\n\n for j := i to n do\n if sch(j) and sch(mas[j - i + 1]) then\n inc(ans);\n\n write(ans);\n end;\n\n closefile(input);\n closefile(output);\nend.\n"}, {"source_code": "var\n z:int64;\n p:array[0..1025]of boolean;\n a,s:array[0..1025]of int64;\n ans,n,m,x,i,j,k,t:Longint;\n\nfunction pd(x:longint):boolean;\nbegin\n while x>0 do begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nbegin\n s[0]:=1; for i:=1 to 13 do s[i]:=s[i-1]*i;\n read(n,m); dec(m);\n if (n<=13) and (m+1>s[n]) then begin writeln(-1); exit end;\n t:=13; if t>n then t:=n; k:=n-t+1;\n a[1]:=4; a[2]:=7; j:=2; i:=0;\n repeat\n inc(i);\n z:=a[i]*10+4; if z 0 do\n begin\n if (t mod 10 <> 4) and (t mod 10 <> 7) then\n begin\n lucky:=False;\n exit;\n end;\n t:=t div 10;\n end;\n lucky:=True;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n f[0]:=1;\n for i:=1 to 19 do f[i]:=f[i-1]*i;\n read(n,k);\n m:=0;\n for i:=1 to n do\n if f[i] >= k then\n begin\n m:=i;\n break;\n end;\n if m = 0 then\n begin\n writeln('-1');\n halt;\n end;\n ans:=0;\n rec(4); rec(7);\n fillchar(was,sizeof(was),False);\n for i:=1 to m do\n begin\n x:=0; y:=1;\n while k > f[m-i] do\n begin\n k:=k-f[m-i];\n inc(y);\n end;\n for j:=1 to y do\n begin\n inc(x);\n while was[x] do inc(x);\n end;\n was[x]:=True;\n if lucky(n-m+i) and lucky(n-m+x) then inc(ans);\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$R+,I+,S+,O+,O-}\nUses Math;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tinf = maxint;\nvar\n\tn, i, ok1, ok2, u, len, ans, sz, j, m, k, sum : int;\n\tp, a, b, c, mult : array [0..2000] of int;\n\twas : array [0..20] of bool;\n\nprocedure findnumbers;\nbegin\n\tp[0] := 1; sz := 0;\n\tfor i := 1 to 9 do\n\t\tp[i] := p[i-1] * 10;\n\n for u := 1 to 9 do begin\n \tlen := 1 shl u - 1;\n \tfor i := 0 to len do begin\n\t \tfor j := 0 to u-1 do\n\t\t \tif (i shr j and 1 = 1) then\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 7\n\t\t\t else\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 4;\n\t end;\n sz := sz + len + 1;\n end;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tfindnumbers;\n\tread(n, k);\n\tm := min(13, n);\n\tsum := 0;\n\n\tfor i := n-m+1 to n do\n\t\tc[i-n+m] := i;\n\n\tans := 0;\n\tmult[0] := 1;\n\n\tfor i := 1 to m-1 do\n\t\tmult[i] := mult[i-1] * i;\n\n\tfor i := 1 to m do begin\t\n\t\tfor j := 1 to m do\n\t\t\tif (not was[j]) then begin\n\t\t\t\tsum\t:= sum + mult[m-i];\n\t\t\t\tif (sum >= k) then begin\n\t\t\t\t\ta[i] := c[j];\n\t\t\t\t\twas[j] := true;\n\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n if (a[i] = 0) then begin\n write(-1);\n\t\t\thalt;\n end;\n\t\tsum := sum - mult[m-i];\n\tend;\n\n\tfor i := 1 to sz do\n\t\tif (b[i] < n-m+1) then inc(ans);\n\n\tfor i := 1 to m do begin\n ok1 := 0; ok2 := 0;\n\t\tfor j := 1 to sz do begin\n\t\t\tif (a[i] = b[j]) then ok1 := 1;\n if (i+n-m = b[j]) then ok2 := 1;\n end;\n if (ok1 + ok2 = 2) then inc(ans);\n end;\n\n\twrite(ans);\t\t\nend."}, {"source_code": "{$R+}{$Q+}\nVar fac:array [0..15] of int64;\nm:array [1..100] of longint;\na:array [1..15] of longint;\nused:array [1..15]of boolean;\ne,z,kol,i,n,j,k:longint;\nrez,zz:int64;\nfunction proverka(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7)\n then begin proverka:=false; exit; end;\n x:=x div 10;\n end;\n proverka:=true;\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n fac[0]:=1;\n for i:=1 to 15 do\n fac[i]:=fac[i-1]*i;\n if n<=15\n then begin\n if fac[n]15\n then begin\n z:=1;\n while 1=1 do\n begin\n zz:=1;\n rez:=0;\n for i:=1 to z do\n begin\n if m[i]=0\n then rez:=rez+zz*4\n else rez:=rez+zz*7;\n zz:=zz*10;\n end;\n if rez<=n-15\n then inc(kol)\n else break;\n inc(m[1]);\n for i:=1 to z do\n if m[i]=2\n then begin\n inc(m[i+1]);\n m[i]:=0;\n end;\n if m[z+1]=1\n then begin\n inc(z);\n fillchar(m,sizeof(m),0);\n end;\n end;\n e:=15;\n end\n else e:=n;\n dec(k);\n for i:=1 to e do\n begin\n z:=1;\n while fac[e-i]<=k do\n begin\n k:=k-fac[e-i];\n inc(z);\n end;\n for j:=1 to e do\n if not used[j]\n then begin\n dec(z);\n if z=0\n then begin\n used[j]:=true;\n a[i]:=j;\n break;\n end;\n end;\n end;\n for i:=1 to e do\n if proverka(n-(e-i))and(proverka(n-e+a[i]))\n then inc(kol);\n writeln(kol);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,Q-,R-,S+}\nuses\n SysUtils, Math;\nvar\n a, mas, pf, good, good2 : array [1..20]of Int64;\n i, j, k, n : int64;\n q, ans, lg, ll, l : longint;\n s : string;\nfunction next(n : int64) : int64;\nvar\n i, j : LongInt;\nbegin\n s := '';\n while n > 0 do\n begin\n s := chr(n mod 10 + 48) + s;\n n := n div 10;\n end;\n i := Length(s);\n while (i > 0) and (s[i] = '7') do\n Dec(i);\n if i = 0 then\n begin\n for i := 1 to Length(s) do\n s[i] := '4';\n result := strtoint64(s + '4');\n end\n else\n begin\n s[i] := '7';\n for j := i + 1 to Length(s) do\n s[j] := '4';\n result := strtoint64(s);\n end;\nend;\nfunction fack(n : int64) : int64;\nvar\n i : longint;\n j : Int64;\nbegin\n if n > 13 then\n n := 13;\n result := 1;\n for i := 2 to n do\n begin\n j := i;\n result := result * j;\n end;\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(n, k);\n ans := 0;\n if fack(n) < k then\n begin\n writeln(-1);\n exit;\n end;\n if n > 13 then begin\n q := n - 13;\n ans := 0;\n i := 4;\n while i <= q do\n begin\n Inc(ans);\n i := Next(i);\n end;\n if i > n then\n begin\n writeln(ans);\n exit;\n end;\n good[1] := 13 - (n - i);\n pf[1] := i;\n if next(i) <= n then\n begin\n good[2] := 13 - (n - next(i));\n pf[2] := next(i);\n lg := 2;\n good2[1] := 13 - (n - next(i));\n good2[2] := 13 - (n - i);\n end\n else\n lg := 1;\n for q := n - 12 to n do\n a[q - (n - 12) + 1] := q;\n n := 13;\n end\n else\n begin\n for q := 1 to n do\n a[q] := q;\n if n > 6 then\n begin\n lg := 2;\n good[2] := 7;\n pf[2] := 7;\n good[1] := 4;\n pf[1] := 4;\n good2[2] := 4;\n good2[1] := 7;\n end\n else\n if n > 3 then\n begin\n lg := 1;\n good[1] := 4;\n pf[1] := 4;\n end\n else\n begin\n Writeln(0);\n Exit;\n end;\n end;\n ll := n;\n Dec(k);\n for q := n - 1 downto 1 do\n begin\n j := q;\n i := 0;\n while i * fack(j) <= k do\n Inc(i);\n Dec(i);\n mas[n - q] := a[i + 1];\n k := k - i * fack(j);\n for l := i + 1 to ll do\n a[l] := a[l + 1];\n Dec(ll);\n end;\n mas[n] := a[1];\n for l := 1 to lg do\n if (mas[good[l]] = pf[l]) or (mas[good2[l]] = pf[l]) then\n Inc(ans);\n Writeln(ans);\nend.\n"}, {"source_code": "Uses SysUtils;\nVar\n r:Array[1..10000] of Int64;\n a,b,f:Array[0..30] of Int64;\n n,k,t,w,m,kol,p,v,n1:Int64;\n i,j,l,f1,f2:Integer;\nFunction Max(x,y:Int64):Int64;\nBegin\n If x>y Then Max:=x\n Else Max:=y;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>1000000000 Then Exit;\n i:=i+1;\n r[i]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(n,k);\n f[0]:=1;\n For i:=1 To 14 Do f[i]:=i*f[i-1];\n If n<14 Then\n If k>f[n] Then Begin\n Write(-1);\n Halt;\n End;\n i:=0;\n Get(4);\n Get(7);\n m:=i;\n For i:=1 To m-1 Do\n For j:=i+1 To m Do\n If r[i]>r[j] Then Begin\n w:=r[i];\n r[i]:=r[j];\n r[j]:=w;\n End;\n kol:=0;\n t:=Max(1,n-12);\n j:=1;\n n1:=n;\n For i:=t To n Do Begin\n b[j]:=i;\n j:=j+1;\n End;\n For i:=1 To m Do Begin\n If r[i]>=t Then Break;\n kol:=kol+1;\n End;\n If n>12 Then n:=13;\n p:=n;\n i:=0;\n While True Do Begin\n i:=i+1;\n v:=k div f[n-1];\n If k mod f[n-1]<>0 Then v:=v+1;\n a[i]:=b[v];\n j:=1;\n n:=n-1;\n If n=0 Then Break;\n For l:=1 To n Do Begin\n If b[l]=a[i] Then j:=j+1;\n b[l]:=b[j];\n j:=j+1;\n End;\n k:=k mod f[n];\n If k=0 Then k:=f[n];\n End;\n l:=Max(1,n1-12);\n For i:=1 To p Do Begin\n f1:=0;\n f2:=0;\n For j:=1 To m Do Begin\n If r[j]=l Then f1:=1;\n If r[j]=a[i] Then f2:=1;\n End;\n If (f1=1) and (f2=1) Then kol:=kol+1;\n l:=l+1;\n End;\n Write(kol);\nEnd."}, {"source_code": "const maxn = 1000;\nconst inf : int64 = 1000000000000000;\n\nvar\n used,fac:array[0..maxn] of int64;\n l,cc,z,ans,o_O,i,n:longint;\n k,kth:int64;\n\nfunction lucky(const k:longint):longint;\nvar\n s:string;\n i:longint;\nbegin\n str(k, s);\n lucky:=0;\n for i:=1 to length(s) do if (s[i] <> '4')and(s[i] <> '7') then exit;\n lucky:=1;\nend;\n\nfunction max(const a, b:longint):longint;\nbegin\n if a>b then max:=a else max:=b;\nend;\n\nprocedure cnt_before(const k, ub:int64);\nbegin\n if k<=ub then inc(ans) else exit;\n cnt_before(k*10+4, ub);\n cnt_before(k*10+7, ub);\nend;\n\nbegin\n// reset(input, 'in.txt');\n// rewrite(output, 'out.txt');\n read(n, k);\n fac[0]:=1;\n for i:=1 to 100 do\n begin\n fac[i]:=fac[i-1]*i;\n if fac[i]>inf then fac[i]:=inf;\n end;\n if (n<20)and(fac[n]20 then\n begin\n cnt_before(4, n-20);\n cnt_before(7, n-20);\n end;\n for o_O:=max(1, n-20+1) to n do\n begin\n z:=0;\n kth:=k div fac[n-o_O]+ord(k mod fac[n-o_O]>0);\n inc(kth, ord(kth = 0));\n for i:=max(1, n-20+1) to n do if used[i-max(1, n-20+1)] = 0 then\n begin\n inc(z);\n if z = kth then\n begin\n cc:=i;\n break;\n end;\n end;\n if (lucky(cc) = 1)and(lucky(o_O) = 1) then inc(ans);\n used[cc-max(1, n-20+1)]:=1;\t\n l:=n-o_O;\n dec(k, fac[l]*(kth-1));\n end;\n writeln(ans);\n close(output);\nend."}, {"source_code": "var\n n,k,temp,t:int64;\n i,j,ans,nn:longint;\n a:array[0..1 shl 12] of int64;\n fact:array[0..15] of int64;\n used:array[0..15] of boolean;\n z,s:array[0..15] of longint;\nprocedure lucky(x:int64);\n begin\n if x>10000000000 then exit;\n\tinc(nn); a[nn]:=x;\n\tlucky(10*x+4); lucky(10*x+7);\n end;\n\nfunction islucky(a:int64):boolean;\n begin\n if a=0 then exit(true)\n\telse if not ((a mod 10) in [4,7]) then exit(false)\n\telse exit(islucky(a div 10));\n end;\n\nbegin\n lucky(4); lucky(7);\n for i:=1 to nn-1 do\n for j:=nn downto i+1 do\n\t if a[j]fact[n] then\n\t begin\n\t writeln(-1);halt;\n\t end;\n dec(k);\n fillchar(used,sizeof(used),false);\n if n>15 then\n begin\n\t temp:=n; n:=15;\n\tend\n else temp:=0;\n for i:=1 to n do z[i]:=i;\n for i:=1 to n do\n begin\n\t t:=k div fact[n-i];\n\t k:=k-t*fact[n-i];\n\t s[i]:=z[t+1];\n\t for j:=t+1 to n-1 do\n\t z[j]:=z[j+1];\n\tend;\n if temp>15 then\n begin\n\t for i:=1 to 15 do\n\t if islucky(temp-15+int64(i)) and islucky(temp-15+int64(s[i])) then inc(ans);\n\t for i:=1 to nn do\n\t if a[i]>temp-15 then break\n\t\t else inc(ans);\n\tend\n else for i:=1 to n do\n if islucky(int64(i)) and islucky(int64(s[i])) then inc(ans);\n writeln(ans);\n \nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n inf=1000000000;\nvar\n ss,m,i,j,n,k,kt,res:longint;\n t:array[0..500500]of longint;\n q,fact:array[0..500]of longint;\n was:array[0..500500]of boolean;\n procedure gen(x:longint);\n begin\n if (x<>0)then begin\n inc(kt);t[kt]:=x;\n end;\n if (int64(x)*10>inf)then exit;\n gen(x*10+4);\n gen(x*10+7);\n end;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n,k);\n kt:=0;\n gen(0);\n res:=0;\n for i:=1 to kt do\n if (t[i]13)then begin\n m:=13;\n ss:=n-12;\n for i:=1 to m do fact[i]:=fact[i-1]*i;\n end else begin\n for i:=1 to n do fact[i]:=fact[i-1]*i;\n if (k>fact[n])then begin\n writeln(-1);\n exit;\n end;\n end;\n fillchar(was,sizeof(was),false);\n for i:=1 to m do begin\n j:=1;\n while (true)do begin\n while (was[j])do inc(j);\n if (k>fact[m-i])then begin\n dec(k,fact[m-i]);\n inc(j);\n end else break;\n end;\n was[j]:=true;\n q[i]:=ss+j-1;\n end;\n for i:=1 to kt do\n if (t[i]>=ss)and(t[i]<=n)then\n for j:=1 to kt do\n if (q[t[i]-ss+1]=t[j])then inc(res);\n writeln(res);\n close(output);close(input);\nend.\n"}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n sum, i, p, v, ans, len, l, u, j, q, x: longint;\n kol, k, n, t, cur, kl: int64;\n b, f: array [0..20] of int64;\n was: array [0..20] of boolean;\n a: array [0..2048] of int64;\n\nProcedure go(p: longint; x: int64);\nvar\n i: longint;\n\nbegin\n if p > len then begin\n inc(l); a[l] := x;\n exit;\n end;\n for i := 0 to 1 do\n if i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n lucky := false;\n while (x > 0) do begin\n if (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n x := x div 10;\n end;\n lucky := true;\nend;\n\nbegin\n {$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n read(n, k); l := 0;\n for len := 1 to 9 do\n go(1, 0);\n ans := 0;\n for i := 1 to l do\n if (a[i] <= n - 13) then inc(ans);\n u := min(13, n);\n\n f[0] := 1; for i := 1 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n\n sum := 0;\n for i := 1 to u do begin\n for j := 1 to u do\n if not was[j] then begin\n sum := sum + f[u - i];\n if sum >= k then begin\n was[j] := true;\n b[i] := j;\n break;\n end;\n end;\n sum := sum - f[u - i];\n end;\n\n for i := 1 to u do\n if (lucky(n - u + i)) and (lucky(n - u + b[i])) then inc(ans);\n write(ans);\nend.\n"}, {"source_code": "program Lucky_Permutation;\nvar\n b:array[0..10] of longint;\n a:array[0..100000] of longint;\n i,o,s,j,n,k,c,e,sum,sc:longint;\n fact:array[0..15] of int64;\n use,ans:array[0..20] of longint;\n\nfunction lucky(s:longint):boolean;\n begin\n while s>0 do begin\n if (s mod 10<>4) and (s mod 10<>7) then exit(false);\n s:=s div 10;\n end;\n exit(true);\n end;\n\nbegin\n o:=0;\n for i:=1 to 9 do begin\n fillchar(b,sizeof(b),0);\n while b[0]=0 do begin\n s:=0;\n for j:=1 to i do\n if b[j]=0 then s:=s*10+4 else s:=s*10+7;\n inc(o);\n a[o]:=s;\n j:=i;\n while b[j]=1 do begin\n b[j]:=0;\n dec(j);\n end;\n inc(b[j]);\n end;\n end;\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=int64(fact[i-1])*i;\n if n<=15 then begin\n if k>fact[n] then begin\n writeln(-1);\n halt;\n end;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then begin\n inc(e);\n if e=c then begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n sum:=0;\n for i:=1 to n do\n if lucky(i) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end\n else begin\n sc:=n-15;\n n:=15;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then begin\n inc(e);\n if e=c then begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n for i:=1 to n do\n ans[i]:=ans[i]+sc;\n sum:=0;\n for i:=1 to o do\n if a[i]<=sc then inc(sum);\n for i:=1 to n do\n if lucky(i+sc) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end;\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemE;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 0;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n n, ans, k: int64;\n a, b: array[0..14] of int64;\n u: array[0..14] of bool;\n\nprocedure gen(t: int64);\nbegin\n if t <= n - 13 then\n if (t <> 0) then\n inc(ans)\n else \n else\n exit;\n\n gen(t*10 + 4);\n gen(t*10 + 7); \nend;\n\nprocedure go(c, t, k: int64);\nbegin\n if t < 1 then\n exit;\n\n b[c] := (k - 1) div a[t - 1] + 1;\n go(c + 1, t - 1, k - (b[c] - 1)*a[t-1]);\nend;\n\nfunction isHappy(t: int): bool;\nbegin\n result := false;\n while t > 0 do begin\n if (t mod 10 <> 4) and (t mod 10 <> 7) then\n exit;\n t := t div 10;\n end;\n result := true;\nend;\n\nprocedure run;\nvar\n i, j, d: int;\nbegin\n a[0] := 1;\n for i := 1 to 14 do\n a[i] := a[i-1]*i;\n\n read(n, k);\n\n if (n < 14) and (a[n] < k) then begin\n write(-1);\n exit;\n end;\n\n ans := 0;\n\n gen(0);\n\n go(1, min(13, n), k);\n\n fillchar(u, sizeof(u), false);\n for i := 1 to min(13, n) do begin\n d := b[i];\n\n for j := 1 to 14 do\n if not u[j] then begin\n dec(d);\n if d = 0 then begin\n b[i] := j;\n break;\n end;\n end;\n\n u[b[i]] := true; \n end;\n\n for i := 1 to min(13, n) do\n if isHappy(n - min(13, n) + i) then\n if isHappy(n - min(13, n) + b[i]) then\n inc(ans);\n\n write(ans); \nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,f,e : longint;\n begin\n e:=x;\n f:=0;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n inc(f);\n if f=x then begin e:=i;break;end;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w<>0 then inc(X);\n x:=maxx(x);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "{$R+}{$Q+}\nVar fac:array [0..15] of int64;\nm:array [1..100] of longint;\na:array [1..15] of longint;\nused:array [1..15]of boolean;\ne,z,kol,i,n,j,k:longint;\nrez,zz:int64;\nfunction proverka(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7)\n then begin proverka:=false; exit; end;\n x:=x div 10;\n end;\n proverka:=true;\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n fac[0]:=1;\n for i:=1 to 15 do\n fac[i]:=fac[i-1]*i;\n if n<=15\n then begin\n if fac[n]15\n then begin\n z:=1;\n while 1=1 do\n begin\n zz:=1;\n rez:=0;\n for i:=1 to z do\n begin\n if m[i]=0\n then rez:=rez+zz*4\n else rez:=rez+zz*7;\n zz:=zz*10;\n end;\n if rez<=n-15\n then inc(kol)\n else break;\n inc(m[1]);\n for i:=1 to z do\n if m[i]=2\n then begin\n inc(m[i+1]);\n m[i]:=0;\n end;\n if m[z+1]=1\n then begin\n inc(z);\n fillchar(m,sizeof(m),0);\n end;\n end;\n e:=15;\n end\n else e:=n;\n dec(k);\n for i:=1 to e do\n begin\n z:=1;\n while fac[e-i]<=k do\n begin\n k:=k-fac[e-i];\n inc(z);\n end;\n for j:=1 to e do\n if not used[j]\n then begin\n dec(z);\n if z=0\n then begin\n used[j]:=true;\n a[i]:=j;\n break;\n end;\n end;\n end;\n for i:=1 to e do\n if proverka(n-(e-i))and(proverka(n-e+a[i]))\n then inc(kol);\n writeln(kol);\nend."}, {"source_code": "Program Lucky_Permutation;\nConst\n MAXN =15+10;\n OO =987654321;\nVar\n n,m,ans :longint;\n flag :array[0..MAXN] of boolean;\n c :array[0..MAXN] of int64;\n\nFunction Change(x:int64):int64;\nVar\n i,j,k :longint;\n d :int64;\nbegin\n if x=0 then exit(4);\n d:=1;\n while d<=x do\n begin\n if x mod (d*10) div d=4 then \n begin\n x:=x+d*3;\n if d<>1 then \n begin\n d:=d div 10;\n while d>0 do\n begin\n if x mod (d*10) div d=7 then\n x:=x-3*d;\n d:=d div 10;\n end;\n end;\n exit(x);\n end;\n d:=d*10;\n end;\n x:=0;\n while d>0 do\n begin\n x:=x+d*4;\n d:=d div 10;\n end;\n exit(x);\nend;\n\nFunction Check(x:longint):boolean;\nVar\n k :longint;\nbegin\n while x>0 do\n begin\n k:=x mod 10;\n if (k<>4) and (k<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nProcedure Main;\nVar\n i,j,k,len,l :longint;\n now :int64;\nbegin\n readln(n,m);\n c[0]:=1;\n for i:=1 to 15 do c[i]:=c[i-1]*i;\n if (n<=15) and (c[n]m then break;\n len:=i;now:=4;\n while now<=n-len do\n begin\n inc(ans);\n now:=change(now);\n end;\n for i:=len-1 downto 0 do \n begin\n k:=m div c[i];\n j:=0;\n for l:=0 to k do\n begin\n inc(j);\n while flag[j] do inc(j);\n end;\n flag[j]:=true;\n if check(n-len+j) and check(n-i) then inc(ans);\n m:=m mod c[i];\n end;\n writeln(ans);\nend;\n \nBegin\n Main;\nEnd."}, {"source_code": "var a1:array[1..5000] of qword;\n a:array[1..20] of qword;\n ans:array[1..20] of longint;\n bo:array[1..20] of boolean;\n i,j,n,k,n1,tot,sum:longint;\n t,cator:qword;\n flag:boolean;\nprocedure dfs(m:longint; s:string);\n var t:qword;\n begin\n if m>10 then exit;\n if m>0 then\n begin\n val(s,t);\n inc(tot);\n a1[tot]:=t;\n end;\n dfs(m+1,s+'4');\n dfs(m+1,s+'7');\n end;\nfunction cal(x:longint):qword;\n var i:longint;\n s:qword;\n begin\n s:=1;\n for i:=1 to x do s:=s*i;\n exit(s);\n end;\nfunction check(x:longint):boolean;\n var i,t:longint;\n s:string;\n begin\n t:=x+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n t:=ans[x]+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n exit(true);\n end;\nbegin\n fillchar(bo,sizeof(bo),false);\n readln(n,k);\n flag:=false;\n cator:=1;\n for i:=1 to n do\n begin\n cator:=cator*i;\n if cator>=k then\n begin\n flag:=true;\n break;\n end;\n end;\n if not flag then\n begin\n writeln('-1');\n halt;\n end;\n if n>15 then\n begin\n n1:=n-15;\n n:=15;\n dfs(0,'');\n for i:=1 to tot-1 do\n for j:=i+1 to tot do\n if a1[i]>a1[j] then\n begin\n t:=a1[i];\n a1[i]:=a1[j];\n a1[j]:=t;\n end;\n for i:=1 to tot do\n if a1[i]<=n1 then inc(sum)\n else break;\n end;\n cator:=k-1;\n for i:=n-1 downto 1 do\n begin\n flag:=false;\n a[n-i]:=cator div cal(i);\n cator:=cator mod cal(i);\n t:=0;\n j:=1;\n while (j<=n)and not flag do\n if not bo[j] then begin\n inc(t);\n if t=a[n-i]+1 then begin\n ans[n-i]:=j;\n flag:=true;\n bo[j]:=true;\n end\n else inc(j);\n end\n else inc(j);\n end;\n for i:=1 to n do\n if not bo[i] then\n begin\n ans[n]:=i;\n break;\n end;\n for i:=1 to n do\n if check(i) then inc(sum);\n writeln(sum);\nend."}], "negative_code": [{"source_code": "program cf121c;\nvar\n n,i,j,xx,jj,nn:longint;\n jc:array[0..1000]of int64;\n kk,ans,t:int64;\n dl,ne,xl:array[0..10000]of int64;\nprocedure dfs(o:int64);\nbegin\n if o<=4444444444 then begin\n inc(dl[0]);\n // writeln(o);\n dl[dl[0]]:=o;\n dfs(o*10+4);\n dfs(o*10+7);\n end;\nend;\n\nfunction kind(x:longint):boolean;\nbegin\n while x<>0 do begin\n if (x mod 10<>4)and(x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\n\nbegin\n dl[0]:=0;\n dfs(4);\n dfs(7);\n\n for i:=1 to dl[0] do\n for j:=i+1 to dl[0] do\n if dl[j]1000000000 then break;\n end;\n readln(n,kk);\n\n j:=n;\n while (jc[n-j+1]jc[nn-i] do begin\n xx:=j;\n j:=ne[j];\n kk:=kk-jc[nn-i];\n end;\n ne[xx]:=ne[j];\n xl[i]:=j;\n end;\n\n for i:=1 to nn do\n if (kind(jj+xl[i]))and(kind(jj+i)) then inc(ans);\n writeln(ans);\nend.\n\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n f: array [0..99] of int64;\n n,k,i,j,m,x,y,ans: longint;\n was: array [0..99] of boolean;\n\nprocedure rec(w:int64);\nbegin\n if w <= n-m then\n begin\n inc(ans);\n rec(w*10+4);\n rec(w*10+7);\n end;\nend;\n\nfunction lucky(t:int64):boolean;\nbegin\n while t > 0 do\n begin\n if (t mod 10 <> 4) and (t mod 10 <> 7) then\n begin\n lucky:=False;\n exit;\n end;\n t:=t div 10;\n end;\n lucky:=True;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n f[0]:=1;\n for i:=1 to 10 do f[i]:=f[i-1]*i;\n read(n,k);\n m:=0;\n for i:=1 to n do\n if f[i] >= k then\n begin\n m:=i;\n break;\n end;\n if m = 0 then\n begin\n writeln('-1');\n halt;\n end;\n ans:=0;\n rec(4); rec(7);\n fillchar(was,sizeof(was),False);\n for i:=1 to m do\n begin\n x:=0; y:=1;\n while k > f[m-i] do\n begin\n k:=k-f[m-i];\n inc(y);\n end;\n for j:=1 to y do\n begin\n inc(x);\n while was[x] do inc(x);\n end;\n was[x]:=True;\n if lucky(n-m+i) and lucky(n-m+x) then inc(ans);\n end;\n writeln(ans);\n close(input);\n close(output);\nend."}, {"source_code": "{$MODE OBJFPC}\n//(a/b) mod p=a*(b^(p-2)) mod p\nconst\n fo='';\n fi='';\nvar\n n,k,kq:integer;\n tt:int64;\n head:integer;\n first,last:integer;\n p:array[1..100000] of int64;\n ak:array[0..15] of int64;\n a:array[1..15] of integer;\nprocedure input;\nvar f:textfile; i,j:integer;\nbegin\n assign(f,fo);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nprocedure find;\nvar i,j:int64;\nbegin\n i:=1;\n j:=1;\n ak[1]:=1;\n ak[0]:=0;\n while k>i do\n begin\n inc(j);\n i:=i*j;\n ak[j]:=i;\n end;\n head:=n;\n while (head>=0) and (k>ak[n-head]) do dec(head);\nend;\nprocedure init;\nbegin\n first:=1;\n last:=0;\nend;\nprocedure push(i:integer);\nbegin\n inc(last);\n p[last]:=i;\nend;\nfunction pop:integer;\nbegin\n result:=p[first];\n inc(first);\nend;\nprocedure solve;\nvar i,j,u,v:integer;\nbegin\n init;\n push(4);\n push(7);\n kq:=0;\n if 4<=head then inc(kq);\n if 7<=head then inc(kq);\n while first<=last do\n begin\n u:=pop;\n v:=u*10+4;\n if v<=head then begin inc(kq); push(v); end;\n v:=u*10+7;\n if v<=head then begin inc(kq); push(v); end;\n end;\nend;\nprocedure QS(l,h:integer);\nvar i,j:integer; pivot:integer;\nbegin\n if l>=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (ipivot) do dec(j);\n if i=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (ia[i]) do inc(i);\n if i0 do\n begin\n if ((i mod 10)<>4) and ((i mod 10)<>7) then exit(false);\n i:=i div 10;\n end;\n exit(true);\nend;\nprocedure solve2;\nvar i,u,v,cc,d,t:integer;\nbegin\n u:=head+1;\n for i:=u to n do a[i-head]:=i;\n v:=n-head;\n cc:=0;\n while (k>1) and (cc=ak[v-cc] then\n begin\n d:=k div ak[v-cc];\n if k mod ak[v-cc]=0 then\n begin\n d:=d+cc-1;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n k:=0;\n QS2(cc+1,v);\n end\n else\n begin\n k:=k-d*ak[v-cc];\n d:=d+cc;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n QS(cc+1,v);\n end;\n end;\n end;\n for i:=1 to v do\n if check(a[i]) and check(i+head) then inc(kq);\nend;\nprocedure output;\nvar f:textfile; i:integer;\nbegin\n assign(f,fi);\n rewrite(f);\n if head<0 then writeln(f,-1) else\n writeln(f,kq);\n close(f);\nend;\nbegin\n input;\n find;\n if head>=0 then\n begin\n solve;\n solve2;\n end;\n output;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n//(a/b) mod p=a*(b^(p-2)) mod p\nconst\n fo='';\n fi='';\nvar\n n,k,kq:integer;\n tt:int64;\n head:integer;\n first,last:integer;\n p:array[1..100000] of int64;\n ak:array[0..15] of int64;\n a:array[1..15] of integer;\nprocedure input;\nvar f:textfile; i,j:integer;\nbegin\n assign(f,fo);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nprocedure find;\nvar i,j:int64;\nbegin\n i:=1;\n j:=1;\n ak[1]:=1;\n ak[0]:=0;\n while k>i do\n begin\n inc(j);\n i:=i*j;\n ak[j]:=i;\n end;\n head:=n;\n while (head>=0) and (k>ak[n-head]) do dec(head);\nend;\nprocedure init;\nbegin\n first:=1;\n last:=0;\nend;\nprocedure push(i:integer);\nbegin\n inc(last);\n p[last]:=i;\nend;\nfunction pop:integer;\nbegin\n result:=p[first];\n inc(first);\nend;\nprocedure solve;\nvar i,j,u,v:integer;\nbegin\n init;\n push(4);\n push(7);\n kq:=0;\n if 4<=head then inc(kq);\n if 7<=head then inc(kq);\n while first<=last do\n begin\n u:=pop;\n v:=u*10+4;\n if v<=head then begin inc(kq); push(v); end;\n v:=u*10+7;\n if v<=head then begin inc(kq); push(v); end;\n end;\nend;\nprocedure QS(l,h:integer);\nvar i,j:integer; pivot:integer;\nbegin\n if l>=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (ipivot) do dec(j);\n if i=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l]; i:=l; j:=h;\n repeat\n while (ia[i]) do inc(i);\n if i0 do\n begin\n if ((i mod 10)<>4) and ((i mod 10)<>7) then exit(false);\n i:=i div 10;\n end;\n exit(true);\nend;\nprocedure solve2;\nvar i,u,v,cc,d,t:integer;\nbegin\n u:=head+1;\n for i:=u to n do a[i-head]:=i;\n v:=n-head;\n cc:=0;\n while (k>1) and (cc=ak[v-cc] then\n begin\n d:=k div ak[v-cc];\n if k mod ak[v-cc]=0 then\n begin\n d:=d+cc-1;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n k:=0;\n QS2(cc+1,v);\n end\n else\n begin\n k:=k-d*ak[v-cc];\n d:=d+cc;\n t:=a[cc];\n a[cc]:=a[d];\n a[d]:=t;\n QS(cc+1,v);\n end;\n end;\n end;\n for i:=1 to v do\n if check(a[i]) and check(i+head) then inc(kq);\nend;\nprocedure output;\nvar f:textfile; i:integer;\nbegin\n assign(f,fi);\n rewrite(f);\n if head<0 then writeln(f,0) else\n writeln(f,kq);\n close(f);\nend;\nbegin\n input;\n find;\n if head>=0 then\n begin\n solve;\n solve2;\n end;\n output;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';//lucky.inp';\n fo = '';//lucky.out';\n\nvar\n ip, op : text;\n n, k, res : integer;\n a : array[0..13] of int64;\n vis : array[1..13] of boolean;\n cs : array[1..13] of integer; // so i + (n-pos) o vi tri nao\n\nfunction check(x : int64) : boolean;\nvar\n s : string;\n i : integer;\nbegin\n str(x, s);\n for i := 1 to length(s) do if (s[i] <> '4')\n and (s[i] <> '7') then exit(false);\n result := true;\nend;\n\nprocedure process;\nvar\n i, pos, count, j, vj, gan, luu : integer;\n u, v, d : integer;\nbegin\n readln(ip, n, k);\n a[1] := 1;\n for i := 2 to 13 do a[i] := a[i-1] * i;\n if (n <= 13) and (a[n] < k) then\n begin\n writeln(op, -1);\n exit;\n end;\n for i := 1 to 13 do if a[i] > k then\n begin\n pos := i;\n luu := pos;\n break;\n end;\n fillchar(vis, sizeof(vis), true);\n count := 0;\n gan := 0;\n a[0] := 1;\n while (pos > 0) and (k > 0) do\n begin\n dec(pos);\n inc(gan);\n if k mod a[pos] = 0 then u := k div a[pos]\n else u := k div a[pos] + 1;\n k := k - (u-1) * a[pos];\n vj := 0;\n for j := 1 to 13 do if vis[j] then\n begin\n inc(vj);\n if vj = u then\n break;\n end;\n vis[j] := false;\n cs[j] := gan;\n end;\n res := 0;\n for i := 1 to n-luu do\n if check(i) then\n inc(res);\n for i := n-luu+1 to n do\n if check(i) and check(cs[i-(n-luu)]) then inc(res);\n writeln(op, res);\nend;\n\nbegin\n assign(ip, fi); reset(ip);\n assign(op, fo); rewrite(op);\n process;\n close(ip);\n close(op);\nend.\n\n"}, {"source_code": "Program C_LuckyPermutation;\nConst MaxN=1024;\nVar n,m,k,count:Longint;\n gt:array[0..13] of Int64;\n a,d:array[1..13] of Longint;\n arr:array[0..MaxN] of Int64;\n\nProcedure AddResult(i:Longint);\nVar j:Longint;\nBegin\n Inc(m);\n arr[m]:=0;\n For j:=1 to i do arr[m]:=arr[m]*10+d[j];\nEnd;\n\nProcedure Try(i:Longint);\nVar j:Longint;\nBegin\n If i>9 then Exit;\n d[i]:=4;\n AddResult(i);\n Try(i+1);\n d[i]:=7;\n AddResult(i);\n Try(i+1);\nEnd;\n\nProcedure Swap(Var a,b:Int64);\nVar t:Int64;\nBegin t:=a; a:=b; b:=t End;\n\nProcedure QuickSort(L,r:Longint);\nVar i,j:Longint;\n k:Int64;\nBegin\n If l>=r then exit;\n i:=l; j:=r;\n k:=arr[random(r-l+1)+l];\n Repeat\n While arr[i]k do Dec(j);\n If i<=j then\n Begin\n If ij;\n QuickSort(l,j); QUickSort(i,r)\nEnd;\n\nProcedure Init;\nVar i:Longint;\nBegin\n Try(1);\n QuickSort(1,m);\n Inc(m); arr[m]:=4444444444; arr[0]:=-MaxLongint;\n gt[0]:=1;\n For i:=1 to 13 do gt[i]:=gt[i-1]*i;\nEnd;\n\nProcedure Input;\nVar f:Text;\nBegin\n Assign(f,''); Reset(f);\n Readln(f,n,k);\n Close(f)\nEnd;\n\nFunction IsLuckyNum(v:Int64):Boolean;\nVar k:Longint;\nBegin\n While v<>0 do\n Begin\n k:=v mod 10;\n If (k<>4) and (k<>7) then Exit(False);\n v:=v div 10;\n End;\n Exit(True);\nEnd;\n\nProcedure Delete(t:Longint);\nVar j:Longint;\nBegin\n For j:=t to count-1 do a[j]:=a[j+1];\n Dec(count);\nEnd;\n\nProcedure Solve;\nVar i,res,j,p,v:Longint;\nBegin\n For i:=m downto 0 do If arr[i]<(n-12) then Break;\n res:=i;\n i:=n-12; If i<1 then i:=1;\n Begin\n For j:=i to n do a[j-i+1]:=j;\n count:=n-i+1;\n For j:=1 to count do\n Begin\n For p:=1 to count do\n If k-1=1000000000 then exit;\n\n inc(count);\n a[count]:=lik*10+4;\n rec(a[count]);\n inc(count);\n a[count]:=lik*10+7;\n rec(a[count]);\nend;\n\nprocedure swap(Var t,y:int64);\nvar u:int64;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint;\n x:int64;\n begin\n x:=a[(l+r) div 2];\n i:=l; j:=r;\n repeat\n while a[i]X do dec(j);\n if i<=j then\n begin\n swap(A[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\nif l=m then\n begin\n perm:=true;\n exit;\n end;\n end;\n perm:=false;\nend;\n\n\nprocedure next;\nvar i,k,j:longint;\nbegin\n for i:= n downto 2 do\n if b[i]>b[i-1] then\n begin\n if b[i]b[k+1] then\n swap(B[k],b[k+1]);\n exit;\n end;\n writeln(-1);\n halt;\nend;\n\nbegin\n readln(n,m);\n count:=0;\n rec(0);\n ans:=0;\n sort(1,count);\n for i:= 1 to n do\n b[i]:=i;\n for i:= 1 to m-1 do\n next;\n ans:=0;\n for i:= 1 to n do\n if b[a[i]]=a[i] then inc(ans);\n writeln(ans);\nend.\n\n"}, {"source_code": "var n,m,k,count,ans,answer:int64;\n a,b:Array[0..100001] of int64;\n i,j:longint;\nprocedure rec(lik:int64);\nvar i:longint;\nbegin\n if lik>=1000000000 then exit;\n\n inc(count);\n a[count]:=lik*10+4;\n rec(a[count]);\n inc(count);\n a[count]:=lik*10+7;\n rec(a[count]);\nend;\n\n\nprocedure swap(Var t,y:int64);\nvar u:int64;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint;\n x:int64;\n begin\n x:=a[(l+r) div 2];\n i:=l; j:=r;\n repeat\n while a[i]X do dec(j);\n if i<=j then\n begin\n swap(A[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\nif l=m then\n begin\n perm:=true;\n exit;\n end;\n end;\n perm:=false;\nend;\n\n\nprocedure next;\nvar i,k,j:longint;\nbegin\n for i:= n downto 2 do\n if b[i]>b[i-1] then\n begin\n if b[i]b[k+1] then\n swap(B[k],b[k+1]);\n exit;\n end;\n writeln(-1);\n halt;\nend;\n\nbegin\n readln(n,m);\n count:=0;\n rec(0);\n ans:=0;\n sort(1,count);\n for i:= 1 to n do\n b[i]:=i;\n for i:= 1 to m-1 do\n next;\n ans:=0;\n for i:= 1 to count do\n if (a[i]<=n) and (b[a[i]]=a[i]) then inc(ans);\n writeln(ans);\nend.\n\n"}, {"source_code": "var n,m,k,count,ans,answer:int64;\n a,b:Array[0..100001] of int64;\n i,j:longint;\nprocedure rec(lik:int64);\nvar i:longint;\nbegin\n if lik>=1000000000 then exit;\n\n inc(count);\n a[count]:=lik*10+4;\n rec(a[count]);\n inc(count);\n a[count]:=lik*10+7;\n rec(a[count]);\nend;\n\n\nprocedure swap(Var t,y:int64);\nvar u:int64;\nbegin\n u:=t; t:=y; y:=u;\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint;\n x:int64;\n begin\n x:=a[(l+r) div 2];\n i:=l; j:=r;\n repeat\n while a[i]X do dec(j);\n if i<=j then\n begin\n swap(A[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\nif l=m then\n begin\n perm:=true;\n exit;\n end;\n end;\n perm:=false;\nend;\n\n\nprocedure next;\nvar i,k,j:longint;\nbegin\n for i:= n downto 2 do\n if b[i]>b[i-1] then\n begin\n if b[i]b[k+1] then\n swap(B[k],b[k+1]);\n exit;\n end;\n writeln(-1);\n halt;\nend;\n\nfunction fun(lik:longint):boolean;\nvar i:longint;\nbegin\n for i:= 1 to count do\n if a[i]=lik then\n begin\n fun:=true;\n exit;\n end;\n fun:=false;\n end;\n\nbegin\n readln(n,m);\n count:=0;\n rec(0);\n ans:=0;\n sort(1,count);\n for i:= 1 to n do\n b[i]:=i;\n for i:= 1 to m-1 do\n next;\n ans:=0;\n for i:= 1 to count do\n if (fun(b[i])) and (fun(i)) then inc(ans);\n writeln(ans);\nend.\n\n"}, {"source_code": "var otv,n,m,i,j,k,count,answer,num,cnt,q,t,numb,number,qans:longint;\n a:array[0..10001] of int64;\n b,c:array[0..20] of longint;\n fact:longint;\nprocedure rec(q:int64);\nvar i:longint;\nbegin\n if q<=1000000000 then\n begin\n inc(count);\n a[count]:=q;\n end else\n exit;\n rec(q*10+4);\n rec(q*10+7);\nend;\n\nfunction factor(ver:longint):longint;\nvar i,ans:longint;\nbegin\n ans:=1;\n for i:= 1 to ver do\n ans:=ans*i;\n factor:=ans;\nend;\n\n\nfunction fun(lik:longint):boolean;\nvar i:longint;\nbegin\n for i:= 1 to count do\n if a[i]=lik then\n begin\n fun:=true;\n exit;\n end;\n fun:=false;\nend;\n\n\nbegin\n count:=0;\n readln(n,m);\n rec(0);\n answer:=0;\n fact:=1;\n num:=0;\n for i:= 1 to n do\n begin\n fact:=fact*i;\n if fact>=m then\n begin\n num:=i;\n break;\n end;\n if num<>0 then break;\n end;\n if num=0 then begin writeln(-1); halt; end;\n cnt:=0;\n q:=n-num+1;\n for i:= 1 to num do\n begin\n inc(cnt);\n c[cnt]:=q+i-1;\n end;\n qans:=0;\n k:=m;\n for i:= 1 to cnt do\n begin\n t:=factor(num-1);\n if k mod t = 0 then number:=k div t else\n number:=k div t + 1;\n k:= k mod t;\n if k=0 then k:=t;\n inc(qans);\n b[qans]:=c[number];\n for j:= number to num-1 do\n c[j]:=c[j+1];\n c[num]:=0;\n dec(num);\n end;\n otv:=0;\n for i:= 1 to count do\n if a[i]<=q then inc(otv);\n for i:= 1 to cnt do\n if fun(b[i]) and fun(q+i-1) then\n inc(otv);\n writeln(otv-1);\nend."}, {"source_code": "{$mode objfpc}\nconst\n fi='';\n fo='';\nvar\n a:array[1..2]of integer=(4,7);\n luckynum:array[0..3000]of int64;\n x,CT:Array[0..13]of integer;\n avail:array[0..13]of boolean;\n c:array[0..13]of int64;\n m,k:int64;\n n:integer;\n res:int64;\n f,g:Text;\n flag:boolean;\n\nprocedure attemp(i:integer;s:int64);\nvar j:integer;\nbegin\n for j:= 1 to 2 do\n begin\n s:=s*10+a[j];\n if i=n then begin inc(m);luckynum[m]:=s; end else attemp(i+1,s);\n s:=s div 10;\n end;\nend;\n\nfunction find(x:int64):boolean;\nvar l,h:integer;\n mid:integer;\nbegin\n l:=1;h:=m;\n while l<=h do\n begin\n mid:=(l+h) div 2;\n if luckynum[mid]=x then exit(true);\n if luckynum[mid]13 then\n begin\n kt:=n-13;\n For j:=1 to m do\n if luckynum[j]<=kt then inc(res) else break;\n n:=13;\n flag:=true;\n end;\n For i:=1 to n do ct[i]:=kt+i;\n c[0]:=1;\n for i:=1 to n do c[i]:=c[i-1]*i;\n flag:=flag or (ct[n]>=k);\n fillchar(avail,sizeof(avail),true);\n for i:=1 to n do\n begin\n for j:=1 to n do\n if avail[j] then\n if (k>c[n-i]) then dec(k,c[n-i]) else break;\n x[i]:=j;avail[j]:=false;\n end;\n For i:=1 to n do\n begin\n if find(ct[x[i]]) and (find(i+kt)) then inc(res);\n end;\nend;\n\nprocedure openf;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\n\nprocedure closef;\nbegin\n close(f);close(g);\nend;\n\nprocedure print;\nbegin\n if flag then writeln(g,res) else writeln(g,'-1');\nend;\n\n\nbegin\n openf;\n solve;\n print;\n closef;\nend.\n\n"}, {"source_code": "{$mode objfpc}\nconst\n fi='';\n fo='';\nvar\n a:array[1..2]of integer=(4,7);\n luckynum:array[0..3000]of int64;\n x,CT:Array[0..13]of integer;\n avail:array[0..13]of boolean;\n c:array[0..13]of int64;\n m,k:int64;\n n:integer;\n res:int64;\n f,g:Text;\n\nprocedure attemp(i:integer;s:int64);\nvar j:integer;\nbegin\n for j:= 1 to 2 do\n begin\n s:=s*10+a[j];\n if i=n then begin inc(m);luckynum[m]:=s; end else attemp(i+1,s);\n s:=s div 10;\n end;\nend;\n\nfunction find(x:int64):boolean;\nvar l,h:integer;\n mid:integer;\nbegin\n l:=1;h:=m;\n while l<=h do\n begin\n mid:=(l+h) div 2;\n if luckynum[mid]=x then exit(true);\n if luckynum[mid]13 then\n begin\n kt:=n-13;\n For j:=1 to m do\n if luckynum[j]<=kt then inc(res) else break;\n n:=13;\n end;\n For i:=1 to n do ct[i]:=kt+i;\n c[0]:=1;\n for i:=1 to n do c[i]:=c[i-1]*i;\n fillchar(avail,sizeof(avail),true);\n for i:=1 to n do\n begin\n for j:=1 to n do\n if avail[j] then\n if (k>c[n-i]) then dec(k,c[n-i]) else break;\n x[i]:=j;avail[j]:=false;\n end;\n For i:=1 to n do\n begin\n if find(ct[x[i]]) and (find(i+kt)) then inc(res);\n end;\nend;\n\nprocedure openf;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\n\nprocedure closef;\nbegin\n close(f);close(g);\nend;\n\nprocedure print;\nbegin\n writeln(g,res);\nend;\n\n\nbegin\n openf;\n solve;\n print;\n closef;\nend.\n\n"}, {"source_code": "{$mode objfpc}\nconst\n fi='';\n fo='';\nvar\n a:array[1..2]of integer=(4,7);\n luckynum:array[0..3000]of int64;\n x,CT:Array[0..13]of integer;\n avail:array[0..13]of boolean;\n c:array[0..13]of int64;\n m,k:int64;\n n:integer;\n res:int64;\n f,g:Text;\n\nprocedure attemp(i:integer;s:int64);\nvar j:integer;\nbegin\n for j:= 1 to 2 do\n begin\n s:=s*10+a[j];\n if i=n then begin inc(m);luckynum[m]:=s; end else attemp(i+1,s);\n s:=s div 10;\n end;\nend;\n\nfunction find(x:int64):boolean;\nvar l,h:integer;\n mid:integer;\nbegin\n l:=1;h:=m;\n while l<=h do\n begin\n mid:=(l+h) div 2;\n if luckynum[mid]=x then exit(true);\n if luckynum[mid]13 then\n begin\n kt:=n-13;\n For j:=1 to m do\n if luckynum[j]<=kt then inc(res) else break;\n n:=13;\n end;\n For i:=1 to n do ct[i]:=kt+i;\n c[0]:=1;\n for i:=1 to n do c[i]:=c[i-1]*i;\n fillchar(avail,sizeof(avail),true);\n for i:=1 to n do\n begin\n for j:=1 to n do\n if avail[j] then\n if (k>c[n-i]) then dec(k,c[n-i]) else break;\n x[i]:=j;avail[j]:=false;\n end;\n For i:=1 to n do\n begin\n if find(ct[x[i]]) and (find(i+kt)) then inc(res);\n end;\nend;\n\nprocedure openf;\nbegin\n assign(f,fi);reset(f);\n assign(g,fo);rewrite(g);\nend;\n\nprocedure closef;\nbegin\n close(f);close(g);\nend;\n\nprocedure print;\nbegin\n if res=0 then writeln(g,-1) else writeln(g,res);\nend;\n\n\nbegin\n openf;\n solve;\n print;\n closef;\nend.\n\n"}, {"source_code": "var b:array[0..10] of longint;\n a:array[0..100000] of longint;\n i,o,s,j,n,k,c,e,sum,sc:longint;\n fact:array[0..15] of int64;\n use,ans:array[0..20] of longint;\n\nfunction lucky(s:longint):boolean;\n begin\n while s>0 do\n begin\n if (s mod 10<>4) and (s mod 10<>7) then exit(false);\n s:=s div 10;\n end;\n exit(true);\n end;\n\nbegin\n o:=0;\n for i:=1 to 9 do\n begin\n fillchar(b,sizeof(b),0);\n while b[0]=0 do\n begin\n s:=0;\n for j:=1 to i do\n if b[j]=0 then s:=s*10+4 else s:=s*10+7;\n inc(o);\n a[o]:=s;\n j:=i;\n while b[j]=1 do\n begin\n b[j]:=0;\n dec(j);\n end;\n inc(b[j]);\n end;\n end;\n //for i:=1 to o do writeln(a[i]);\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=int64(fact[i-1])*i;\n if n<=15 then\n begin\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do\n begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then\n begin\n inc(e);\n if e=c then\n begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n //for i:=1 to n do write(ans[i],' ');writeln;\n sum:=0;\n for i:=1 to n do\n if lucky(i) and lucky(ans[i]) then inc(sum);\n writeln(sum);\n end\n else\n begin\n sc:=n-15;\n n:=15;\n dec(k);\n fillchar(use,sizeof(use),0);\n for i:=1 to n do\n begin\n c:=k div fact[n-i]+1;\n k:=k mod fact[n-i];\n e:=0;\n for j:=1 to n do\n if use[j]=0 then\n begin\n inc(e);\n if e=c then\n begin\n ans[i]:=j;\n use[j]:=1;\n break;\n end;\n end;\n end;\n //for i:=1 to n do write(ans[i],' ');writeln;\n sum:=0;\n for i:=1 to o do\n if a[i]<=sc then inc(sum);\n for i:=1 to n do\n if lucky(i+sc) and lucky(ans[i]+sc) then inc(sum);\n writeln(sum);\n end;\nend.\n"}, {"source_code": "uses math;\nconst\n oo=high(longint);\n _oo=high(int64);\n roo=1e30;\n dx:array[0..7] of longint=(-1,0,1,0,-1,1,1,-1);\n dy:array[0..7] of longint=(0,1,0,-1,1,1,-1,-1);\n hs=13;\ntype point=record x,y:longint; end;\n rpoint=record x,y:double; end;\nvar f,g:text;\n fi,fo:string;\n a:array[0..111111] of int64;\n gt,num:array[0..33] of int64;\n fr:array[0..33] of boolean;\n nluc,n,i,j,last,nho,nn,ans:longint;\n be,k:int64;\nprocedure closefile; begin close(g); close(F); end;\n//-----------------\nprocedure sort(l,r:longint);\nvar i,j:longint;\n m,tmp:int64;\nbegin\n if l>=r then exit;\n i:=l; j:=r; m:=a[l+random(r-l+1)];\n repeat\n while a[i]m do dec(j);\n if i<=j then begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>J;\n sort(i,r);\n sort(l,j);\nend;\nprocedure gen;\nvar i,j,k:Longint;\nbegin\n\n for i:=1 to 11 do\n for j:=0 to 1<>k) and 1=0 then a[nluc]:=a[nluc]*10+4\n else a[nluc]:=a[n]*10+7;\n end;\n sort(1,nluc);\nend;\n//---------------------\nfunction isluck(u:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(u,s);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n isluck:=true;\nend;\nbegin\n gen;\n\n randomize;\n // {$IFNDEF ONLINE_JUDGE} fi := 'i.inp'; fo := ''; {$ENDIF}\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,n,k);\n gt[0]:=1;\n for i:=1 to 12 do gt[i]:=gt[i-1]*i;\n gt[13]:=oo;\n nn:=min(n,hs);\n if n>hs then be:=n-hs\n else be:=0;\n ans:=0;\n if n>hs then begin\n for i:=1 to nluc do\n if a[i]>n-hs then break;\n ans:=i-1;\n end;\n if (n<=hs) and (k>gt[n]) then begin\n writeln(g,-1);\n closefile;\n halt;\n end;\n //\n for i:=1 to nn do fr[i]:=true;\n for i:=1 to nn-1 do begin\n nho:=0; last:=0;\n for j:=1 to nn do\n if (nho*gt[nn-i]>=k) then break\n else if fr[j] then begin\n inc(nho);\n last:=j;\n end;\n\n dec(k,(nho-1)*gt[nn-i]);\n num[i]:=last;\n fr[last]:=false;\n end;\n for i:=1 to nn do\n if fr[i] then num[nn]:=i;\n for i:=1 to nn do\n if isluck(i+be) and isluck(num[i]+be) then inc(ans);\n //\n writeln(g,ans);\n closefile;\nend.\n\n"}, {"source_code": "uses math;\nconst\n oo=high(longint);\n _oo=high(int64);\n roo=1e30;\n dx:array[0..7] of longint=(-1,0,1,0,-1,1,1,-1);\n dy:array[0..7] of longint=(0,1,0,-1,1,1,-1,-1);\ntype point=record x,y:longint; end;\n rpoint=record x,y:double; end;\nvar f,g:text;\n fi,fo:string;\n a:array[0..111111] of int64;\n gt,num:array[0..13] of int64;\n fr:array[0..13] of boolean;\n nluc,n,i,j,last,nho,nn,ans:longint;\n be,k:int64;\nprocedure closefile; begin close(g); close(F); end;\n//-----------------\nprocedure sort(l,r:longint);\nvar i,j:longint;\n m,tmp:int64;\nbegin\n if l>=r then exit;\n i:=l; j:=r; m:=a[l+random(r-l+1)];\n repeat\n while a[i]m do dec(j);\n if i<=j then begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>J;\n sort(i,r);\n sort(l,j);\nend;\nprocedure gen;\nvar i,j,k:Longint;\nbegin\n\n for i:=1 to 11 do\n for j:=0 to 1<>k) and 1=0 then a[nluc]:=a[nluc]*10+4\n else a[nluc]:=a[n]*10+7;\n end;\n sort(1,nluc);\nend;\n//---------------------\nfunction isluck(u:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(u,s);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n isluck:=true;\nend;\nbegin\n gen;\n randomize;\n // {$IFNDEF ONLINE_JUDGE} fi := 'i.inp'; fo := ''; {$ENDIF}\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,n,k);\n gt[0]:=1;\n for i:=1 to 12 do gt[i]:=gt[i-1]*i;\n gt[13]:=oo;\n nn:=min(n,12);\n if n>12 then be:=n-12\n else be:=0;\n ans:=0;\n if n>12 then begin\n for i:=1 to nluc do\n if a[i]>n-12 then break;\n ans:=i-1;\n end;\n //\n for i:=1 to nn do fr[i]:=true;\n for i:=1 to nn-1 do begin\n nho:=0; last:=0;\n for j:=1 to nn do\n if (nho*gt[nn-i]>=k) then break\n else if fr[j] then begin\n inc(nho);\n last:=j;\n end;\n\n dec(k,(nho-1)*gt[nn-i]);\n num[i]:=last;\n fr[last]:=false;\n end;\n for i:=1 to nn do\n if fr[i] then num[nn]:=i;\n for i:=1 to nn do\n if isluck(i+be) and isluck(num[i]+be) then inc(ans);\n //\n writeln(g,ans);\n closefile;\nend.\n\n"}, {"source_code": "uses math;\nconst\n oo=high(longint);\n _oo=high(int64);\n roo=1e30;\n dx:array[0..7] of longint=(-1,0,1,0,-1,1,1,-1);\n dy:array[0..7] of longint=(0,1,0,-1,1,1,-1,-1);\n hs=13;\ntype point=record x,y:longint; end;\n rpoint=record x,y:double; end;\nvar f,g:text;\n fi,fo:string;\n a:array[0..111111] of int64;\n gt,num:array[0..33] of int64;\n fr:array[0..33] of boolean;\n nluc,n,i,j,last,nn,ans:longint;\n be,k,nho:int64;\nprocedure closefile; begin close(g); close(F); end;\n//-----------------\nprocedure sort(l,r:longint);\nvar i,j:longint;\n m,tmp:int64;\nbegin\n if l>=r then exit;\n i:=l; j:=r; m:=a[l+random(r-l+1)];\n repeat\n while a[i]m do dec(j);\n if i<=j then begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>J;\n sort(i,r);\n sort(l,j);\nend;\nprocedure gen;\nvar i,j,k:Longint;\nbegin\n\n for i:=1 to 11 do\n for j:=0 to 1<>k) and 1=0 then a[nluc]:=a[nluc]*10+4\n else a[nluc]:=a[n]*10+7;\n end;\n sort(1,nluc);\nend;\n//---------------------\nfunction isluck(u:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(u,s);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n isluck:=true;\nend;\nbegin\n gen;\n randomize;\n // {$IFNDEF ONLINE_JUDGE} fi := 'i.inp'; fo := ''; {$ENDIF}\n assign(f,fi); reset(f);\n assign(g,fo); rewrite(g);\n readln(f,n,k);\n gt[0]:=1;\n for i:=1 to 12 do gt[i]:=gt[i-1]*i;\n gt[13]:=oo;\n nn:=min(n,hs);\n if n>hs then be:=n-hs\n else be:=0;\n ans:=0;\n if n>hs then begin\n for i:=1 to nluc do\n if a[i]>n-hs then break;\n ans:=i-1;\n end;\n //\n for i:=1 to nn do fr[i]:=true;\n for i:=1 to nn-1 do begin\n nho:=0; last:=0;\n for j:=1 to nn do\n if (nho*gt[nn-i]>=k) then break\n else if fr[j] then begin\n inc(nho);\n last:=j;\n end;\n\n dec(k,(nho-1)*gt[nn-i]);\n num[i]:=last;\n fr[last]:=false;\n end;\n for i:=1 to nn do\n if fr[i] then num[nn]:=i;\n for i:=1 to nn do\n if isluck(i+be) and isluck(num[i]+be) then inc(ans);\n //\n writeln(g,ans);\n closefile;\nend.\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$maxstacksize 2000000}\nvar\n ans,nb,l,q,j,add,n,k,i:integer;\n fc:int64;\n a:array[1..15] of integer;\n us:array[1..15] of boolean;\n\n Function lucky(n:integer):boolean;\n var\n b:boolean;\n begin\n b:=true;\n\n while (n>0) and (b) do\n begin\n b:=(n mod 10=7) or (n mod 10=4);\n n:=n div 10;\n end;\n\n lucky:=b;\n end;\n\n Procedure gen(cur:int64);\n begin\n If cur>add then exit;\n If cur>0 then inc(ans);\n gen(cur*10+4);\n gen(cur*10+7);\n end;\n\n\nbegin\n {reset(input,'Input.txt');\n rewrite(output,'Output.txt'); }\n readln(n,k);\n\n fc:=1;\n i:=1;\n\n while (fcy Then Max:=x\n Else Max:=y;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>1000000000 Then Exit;\n i:=i+1;\n r[i]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(n,k);\n f[0]:=1;\n For i:=1 To 14 Do f[i]:=i*f[i-1];\n If n<14 Then\n If k>f[n] Then Begin\n Write(-1);\n Halt;\n End;\n i:=0;\n Get(4);\n Get(7);\n m:=i;\n For i:=1 To m-1 Do\n For j:=i+1 To m Do\n If r[i]>r[j] Then Begin\n w:=r[i];\n r[i]:=r[j];\n r[j]:=w;\n End;\n kol:=0;\n t:=Max(1,n-12);\n For i:=t To n Do b[i]:=i;\n For i:=1 To m Do Begin\n If r[i]>t Then Break;\n kol:=kol+1;\n End;\n If n>12 Then n:=13;\n p:=n;\n i:=0;\n While True Do Begin\n i:=i+1;\n v:=k div f[n-1];\n If k mod f[n-1]<>0 Then v:=v+1;\n a[i]:=b[v];\n j:=1;\n n:=n-1;\n If n=0 Then Break;\n For l:=1 To n Do Begin\n If b[l]=a[i] Then j:=j+1;\n b[l]:=b[j];\n j:=j+1;\n End;\n k:=k mod f[n];\n If k=0 Then k:=f[n];\n End;\n For i:=t To p Do Begin\n f1:=0;\n f2:=0;\n For j:=1 To m Do Begin\n If r[j]=i Then f1:=1;\n If r[j]=a[i] Then f2:=1;\n End;\n If (f1=1) and (f2=1) Then kol:=kol+1;\n End;\n Write(kol);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Uses SysUtils;\nVar\n r:Array[1..10000] of Int64;\n a,b,f:Array[0..30] of Int64;\n n,k,t,w,m,kol,p,v:Int64;\n i,j,l,f1,f2:Integer;\nFunction Max(x,y:Int64):Int64;\nBegin\n If x>y Then Max:=x\n Else Max:=y;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>1000000000 Then Exit;\n i:=i+1;\n r[i]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(n,k);\n If n<14 Then\n If k>f[n] Then Begin\n Write(-1);\n Halt;\n End;\n i:=0;\n Get(4);\n Get(7);\n m:=i;\n For i:=1 To m-1 Do\n For j:=i+1 To m Do\n If r[i]>r[j] Then Begin\n w:=r[i];\n r[i]:=r[j];\n r[j]:=w;\n End;\n kol:=0;\n t:=Max(1,n-12);\n For i:=t To n Do b[i]:=i;\n For i:=1 To m Do Begin\n If r[i]>t Then Break;\n kol:=kol+1;\n End;\n f[0]:=1;\n For i:=1 To 14 Do f[i]:=i*f[i-1];\n If n>12 Then n:=13;\n p:=n;\n i:=0;\n While True Do Begin\n i:=i+1;\n v:=k div f[n-1];\n If k mod f[n-1]<>0 Then v:=v+1;\n a[i]:=b[v];\n j:=1;\n n:=n-1;\n If n=0 Then Break;\n For l:=1 To n Do Begin\n If b[l]=a[i] Then j:=j+1;\n b[l]:=b[j];\n j:=j+1;\n End;\n k:=k mod f[n];\n If k=0 Then k:=f[n];\n End;\n For i:=t To p Do Begin\n f1:=0;\n f2:=0;\n For j:=1 To m Do Begin\n If r[j]=i Then f1:=1;\n If r[j]=a[i] Then f2:=1;\n End;\n If (f1=1) and (f2=1) Then kol:=kol+1;\n End;\n Write(kol);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Uses SysUtils;\nVar\n r:Array[1..10000] of Int64;\n a,b,f:Array[0..30] of Int64;\n n,k,t,w,m,kol,p,v,n1:Int64;\n i,j,l,f1,f2:Integer;\nFunction Max(x,y:Int64):Int64;\nBegin\n If x>y Then Max:=x\n Else Max:=y;\nEnd;\nProcedure Get(x:Int64);\nBegin\n If x>1000000000 Then Exit;\n i:=i+1;\n r[i]:=x;\n Get(10*x+4);\n Get(10*x+7);\nEnd;\nBegin\n Read(n,k);\n f[0]:=1;\n For i:=1 To 14 Do f[i]:=i*f[i-1];\n If n<14 Then\n If k>f[n] Then Begin\n Write(-1);\n Halt;\n End;\n i:=0;\n Get(4);\n Get(7);\n m:=i;\n For i:=1 To m-1 Do\n For j:=i+1 To m Do\n If r[i]>r[j] Then Begin\n w:=r[i];\n r[i]:=r[j];\n r[j]:=w;\n End;\n kol:=0;\n t:=Max(1,n-12);\n j:=1;\n n1:=n;\n For i:=t To n Do Begin\n b[j]:=i;\n j:=j+1;\n End;\n For i:=1 To m Do Begin\n If r[i]>=t Then Break;\n kol:=kol+1;\n End;\n If n>12 Then n:=13;\n p:=n;\n i:=0;\n While True Do Begin\n i:=i+1;\n v:=k div f[n-1];\n If k mod f[n-1]<>0 Then v:=v+1;\n a[i]:=b[v];\n j:=1;\n n:=n-1;\n If n=0 Then Break;\n For l:=1 To n Do Begin\n If b[l]=a[i] Then j:=j+1;\n b[l]:=b[j];\n j:=j+1;\n End;\n k:=k mod f[n];\n If k=0 Then k:=f[n];\n End;\n If p<13 Then p:=0;\n l:=n1-12;\n For i:=1 To p Do Begin\n f1:=0;\n f2:=0;\n For j:=1 To m Do Begin\n If r[j]=l Then f1:=1;\n If r[j]=a[i] Then f2:=1;\n End;\n If (f1=1) and (f2=1) Then kol:=kol+1;\n l:=l+1;\n End;\n Write(kol);\nEnd."}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,Q-,R-,S+}\nuses\n SysUtils, Math;\nvar\n a, mas, pf, good : array [1..20]of Int64;\n i, j, k, n : int64;\n q, ans, lg, ll, l : longint;\n s : string;\nfunction next(n : int64) : int64;\nvar\n i, j : LongInt;\nbegin\n s := '';\n while n > 0 do\n begin\n s := chr(n mod 10 + 48) + s;\n n := n div 10;\n end;\n i := Length(s);\n while (i > 0) and (s[i] = '7') do\n Dec(i);\n if i = 0 then\n begin\n for i := 1 to Length(s) do\n s[i] := '4';\n result := strtoint64(s + '4');\n end\n else\n begin\n s[i] := '7';\n for j := i + 1 to Length(s) do\n s[j] := '4';\n result := strtoint64(s);\n end;\nend;\nfunction fack(n : int64) : int64;\nvar\n i : longint;\n j : Int64;\nbegin\n if n > 12 then\n n := 12;\n result := 1;\n for i := 2 to n do\n begin\n j := i;\n result := result * j;\n end;\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(n, k);\n ans := 0;\n if fack(n) < k then\n begin\n writeln(-1);\n exit;\n end;\n if n > 12 then begin\n q := n - 12;\n ans := 0;\n i := 4;\n while i <= q do\n begin\n Inc(ans);\n i := Next(i);\n end;\n if i > n then\n begin\n writeln(ans);\n exit;\n end;\n good[1] := 12 - (n - i);\n pf[1] := i;\n if next(i) <= n then\n begin\n good[2] := 12 - (n - next(i));\n pf[2] := next(i);\n lg := 2;\n end\n else\n lg := 1;\n for q := n - 11 to n do\n a[q - (n - 11) + 1] := q;\n n := 12;\n end\n else\n begin\n for q := 1 to n do\n a[q] := q;\n if n > 6 then\n begin\n lg := 2;\n good[2] := 7;\n pf[2] := 7;\n good[1] := 4;\n pf[1] := 4;\n end\n else\n if n > 3 then\n begin\n lg := 1;\n good[1] := 4;\n pf[1] := 4;\n end\n else\n begin\n Writeln(0);\n Exit;\n end;\n end;\n ll := n;\n Dec(k);\n for q := n - 1 downto 1 do\n begin\n j := q;\n i := 0;\n while i * fack(j) <= k do\n Inc(i);\n Dec(i);\n mas[n - q] := a[i + 1];\n k := k - i * fack(j);\n for l := i + 1 to ll do\n a[l] := a[l + 1];\n Dec(ll);\n end;\n mas[n] := a[1];\n for l := 1 to lg do\n if mas[good[l]] = pf[l] then\n Inc(ans);\n Writeln(ans);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$O-,Q-,R-,S+}\nuses\n SysUtils, Math;\nvar\n a, mas, pf, good : array [1..20]of Int64;\n i, j, k, n : int64;\n q, ans, lg, ll, l : longint;\n s : string;\nfunction next(n : int64) : int64;\nvar\n i, j : LongInt;\nbegin\n s := '';\n while n > 0 do\n begin\n s := chr(n mod 10 + 48) + s;\n n := n div 10;\n end;\n i := Length(s);\n while (i > 0) and (s[i] = '7') do\n Dec(i);\n if i = 0 then\n begin\n for i := 1 to Length(s) do\n s[i] := '4';\n result := strtoint64(s + '4');\n end\n else\n begin\n s[i] := '7';\n for j := i + 1 to Length(s) do\n s[j] := '4';\n result := strtoint64(s);\n end;\nend;\nfunction fack(n : int64) : int64;\nvar\n i : longint;\n j : Int64;\nbegin\n if n > 13 then\n n := 13;\n result := 1;\n for i := 2 to n do\n begin\n j := i;\n result := result * j;\n end;\nend;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n Readln(n, k);\n ans := 0;\n if fack(n) < k then\n begin\n writeln(-1);\n exit;\n end;\n if n > 13 then begin\n q := n - 13;\n ans := 0;\n i := 4;\n while i <= q do\n begin\n Inc(ans);\n i := Next(i);\n end;\n if i > n then\n begin\n writeln(ans);\n exit;\n end;\n good[1] := 13 - (n - i);\n pf[1] := i;\n if next(i) <= n then\n begin\n good[2] := 13 - (n - next(i));\n pf[2] := next(i);\n lg := 2;\n end\n else\n lg := 1;\n for q := n - 12 to n do\n a[q - (n - 12) + 1] := q;\n n := 13;\n end\n else\n begin\n for q := 1 to n do\n a[q] := q;\n if n > 6 then\n begin\n lg := 2;\n good[2] := 7;\n pf[2] := 7;\n good[1] := 4;\n pf[1] := 4;\n end\n else\n if n > 3 then\n begin\n lg := 1;\n good[1] := 4;\n pf[1] := 4;\n end\n else\n begin\n Writeln(0);\n Exit;\n end;\n end;\n ll := n;\n Dec(k);\n for q := n - 1 downto 1 do\n begin\n j := q;\n i := 0;\n while i * fack(j) <= k do\n Inc(i);\n Dec(i);\n mas[n - q] := a[i + 1];\n k := k - i * fack(j);\n for l := i + 1 to ll do\n a[l] := a[l + 1];\n Dec(ll);\n end;\n mas[n] := a[1];\n for l := 1 to lg do\n if mas[good[l]] = pf[l] then\n Inc(ans);\n Writeln(ans);\nend.\n"}, {"source_code": "{$R+,I+,S+,O+,O-}\nUses Math;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tinf = maxint;\nvar\n\tn, i, ok1, ok2, u, len, ans, sz, j, m, k, sum : int;\n\tp, a, b, c, mult : array [0..2000] of int;\n\twas : array [0..20] of bool;\n\nprocedure findnumbers;\nbegin\n\tp[0] := 1; sz := 0;\n\tfor i := 1 to 9 do\n\t\tp[i] := p[i-1] * 10;\n\n for u := 1 to 9 do begin\n \tlen := 1 shl u - 1;\n \tfor i := 0 to len do begin\n\t \tfor j := 0 to u-1 do\n\t\t \tif (i shr j and 1 = 1) then\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 7\n\t\t\t else\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 4;\n\t end;\n sz := sz + len + 1;\n end;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tfindnumbers;\n\tread(n, k);\n\tm := min(13, n);\n\tsum := 0;\n\n\tfor i := n-m+1 to n do\n\t\tc[i-n+m] := i;\n\n\tans := 0;\n\tmult[0] := 1;\n\n\tfor i := 1 to m-1 do\n\t\tmult[i] := mult[i-1] * i;\n\n\tfor i := 1 to m do begin\t\n\t\tfor j := 1 to m do\n\t\t\tif (not was[j]) then begin\n\t\t\t\tsum\t:= sum + mult[m-i];\n\t\t\t\tif (sum >= k) then begin\n\t\t\t\t\ta[i] := c[j];\n\t\t\t\t\twas[j] := true;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n\t\tsum := sum - mult[m-i];\n\tend;\n\n\tfor i := 1 to sz do\n\t\tif (b[i] < n-m+1) then inc(ans);\n\n\tfor i := 1 to m do begin\n ok1 := 0; ok2 := 0;\n\t\tfor j := 1 to sz do begin\n\t\t\tif (a[i] = b[j]) then ok1 := 1;\n if (i+n-m = b[j]) then ok2 := 1;\n end;\n if (ok1 + ok2 = 2) then inc(ans);\n end;\n\twrite(ans);\t\t\nend."}, {"source_code": "{$R+,I+,S+,O+,O-}\nUses Math;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tinf = maxint;\nvar\n\tn, i, ok1, ok2, u, len, ans, sz, j, m, k, sum : int;\n\tp, a, b, c, mult : array [0..2000] of int;\n\twas : array [0..20] of bool;\n\nprocedure findnumbers;\nbegin\n\tp[0] := 1; sz := 0;\n\tfor i := 1 to 9 do\n\t\tp[i] := p[i-1] * 10;\n\n for u := 1 to 9 do begin\n \tlen := 1 shl u - 1;\n \tfor i := 0 to len do begin\n\t \tfor j := 0 to u-1 do\n\t\t \tif (i shr j and 1 = 1) then\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 7\n\t\t\t else\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 4;\n\t end;\n sz := sz + len + 1;\n end;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tfindnumbers;\n\tread(n, k);\n\tm := min(13, n);\n\tsum := 0;\n\n\tfor i := n-m+1 to n do\n\t\tc[i-n+m] := i;\n\n\tans := 0;\n\tmult[0] := 1;\n\n\tfor i := 1 to m-1 do\n\t\tmult[i] := mult[i-1] * i;\n\n\tfor i := 1 to m do begin\t\n\t\tfor j := 1 to m do\n\t\t\tif (not was[j]) then begin\n\t\t\t\tsum\t:= sum + mult[m-i];\n\t\t\t\tif (sum >= k) then begin\n\t\t\t\t\ta[i] := c[j];\n\t\t\t\t\twas[j] := true;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n\t\tsum := sum - mult[m-i];\n\tend;\n\n\tfor i := 1 to sz do\n\t\tif (b[i] < n-m+1) then inc(ans);\n\n\tfor i := 1 to m do begin\n ok1 := 0; ok2 := 0;\n\t\tfor j := 1 to sz do begin\n\t\t\tif (a[i] = b[j]) then ok1 := 1;\n if (i+n-m = b[j]) then ok2 := 1;\n end;\n if (ok1 + ok2 = 2) then inc(ans);\n end;\n\n if (ans = 0) then ans := -1;\n\twrite(ans);\t\t\nend."}, {"source_code": "{$R+,I+,S+,O+,O-}\nUses Math;\ntype\n\tint = longint;\n\tbool = boolean;\nconst\n\tinf = maxint;\nvar\n\tn, i, ok1, ok2, u, len, ans, sz, j, m, k, sum : int;\n\tp, a, b, c, mult : array [0..2000] of int;\n\twas : array [0..20] of bool;\n\nprocedure findnumbers;\nbegin\n\tp[0] := 1; sz := 0;\n\tfor i := 1 to 9 do\n\t\tp[i] := p[i-1] * 10;\n\n for u := 1 to 9 do begin\n \tlen := 1 shl u - 1;\n \tfor i := 0 to len do begin\n\t \tfor j := 0 to u-1 do\n\t\t \tif (i shr j and 1 = 1) then\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 7\n\t\t\t else\n\t\t\t \tb[sz+i+1] := b[sz+i+1] + p[j] * 4;\n\t end;\n sz := sz + len + 1;\n end;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tfindnumbers;\n\tread(n, k);\n\tm := min(13, n);\n\tsum := 0;\n\n\tfor i := n-m+1 to n do\n\t\tc[i-n+m] := i;\n\n\tans := 0;\n\tmult[0] := 1;\n\n\tfor i := 1 to m-1 do\n\t\tmult[i] := mult[i-1] * i;\n\n\tfor i := 1 to m do begin\t\n\t\tfor j := 1 to m do\n\t\t\tif (not was[j]) then begin\n\t\t\t\tsum\t:= sum + mult[m-i];\n\t\t\t\tif (sum >= k) then begin\n\t\t\t\t\ta[i] := c[j];\n\t\t\t\t\twas[j] := true;\n\t\t\t\t\tbreak;\n\t\t\t\tend;\n\t\t\tend;\n\t\tsum := sum - mult[m-i];\n\tend;\n\n\tfor i := 1 to sz do\n\t\tif (b[i] < a[1]) then inc(ans);\n\n\tfor i := 1 to m do begin\n ok1 := 0; ok2 := 0;\n\t\tfor j := 1 to sz do begin\n\t\t\tif (a[i] = b[j]) then ok1 := 1;\n if (i+n-m = b[j]) then ok2 := 1;\n end;\n if (ok1 + ok2 = 2) then inc(ans);\n end;\n\twrite(ans);\t\t\nend."}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n\ti, p, ans, len, l, u, j, q: longint;\n\tkol, k, n, t, cur, kl: int64;\n\tb, f: array [0..20] of int64;\n a: array [0..2048] of int64;\n\nProcedure go(p: longint; x: int64);\nvar\n\ti: longint;\n\nbegin\n\tif p > len then begin\n\t\tinc(l); a[l] := x;\n\t\texit;\n\tend;\n\tfor i := 0 to 1 do\n\t\tif i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n\tlucky := false;\n\twhile (x > 0) do begin\n\t\tif (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n\t\tx := x div 10;\n \tend;\n \tlucky := true;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tread(n, k); l := 0;\n\tfor len := 1 to 9 do\n\t\tgo(1, 0);\n \tans := 0;\n\tfor i := 1 to l do\n\t\tif (a[i] <= n - 13) then inc(ans);\n \tu := min(13, n);\n \tfor i := 1 to u do\n \t\tb[i] := n - (u - i);\n \tf[1] := 1; for i := 2 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n\n kol := 0;\n while kol < k do begin\n for j := 1 to u - 1 do\n if kol + f[j + 1] >= k then begin\n t := b[u - j + 1]; b[u - j + 1] := b[u - j]; b[u - j] := t;\n if j = 1 then kol := kol + f[j] else kol := kol + f[j] + 1;\n break;\n end;\n end;\n\tfor i := 1 to u do\n\t\tif (lucky(b[i])) and lucky(n - u + i) then inc(ans);\n \twrite(ans);\nend."}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n sum, i, p, v, ans, len, l, u, j, q, x: longint;\n kol, k, n, t, cur, kl: int64;\n b, f: array [0..20] of int64;\n was: array [0..20] of boolean;\n a: array [0..2048] of int64;\n\nProcedure go(p: longint; x: int64);\nvar\n i: longint;\n\nbegin\n if p > len then begin\n inc(l); a[l] := x;\n exit;\n end;\n for i := 0 to 1 do\n if i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n lucky := false;\n while (x > 0) do begin\n if (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n x := x div 10;\n end;\n lucky := true;\nend;\n\nbegin\n {$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n read(n, k); l := 0;\n for len := 1 to 9 do\n go(1, 0);\n ans := 0;\n for i := 1 to l do\n if (a[i] <= n - 13) then inc(ans);\n u := min(13, n);\n\n f[0] := 1; for i := 1 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n\n sum := 0;\n for i := 1 to u do begin\n for j := 1 to u do\n if not was[j] then begin\n sum := sum + f[u - i];\n if sum >= k then begin\n was[j] := true;\n b[i] := j;\n break;\n end;\n end;\n sum := sum - f[u - i];\n end;\n\n for i := 1 to u do\n if (lucky(n - u + i + 1)) and (lucky(n - u + b[i] + 1)) then inc(ans);\n write(ans);\nend.\n"}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n\ti, p, ans, len, l, u, j, q: longint;\n\tkol, k, n, t, cur, kl: int64;\n\tb, f: array [0..20] of int64;\n a: array [0..2048] of int64;\n\nProcedure go(p: longint; x: int64);\nvar\n\ti: longint;\n\nbegin\n\tif p > len then begin\n\t\tinc(l); a[l] := x;\n\t\texit;\n\tend;\n\tfor i := 0 to 1 do\n\t\tif i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n\tlucky := false;\n\twhile (x > 0) do begin\n\t\tif (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n\t\tx := x div 10;\n \tend;\n \tlucky := true;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tread(n, k); l := 0;\n\tfor len := 1 to 9 do\n\t\tgo(1, 0);\n \tans := 0;\n\tfor i := 1 to l do\n\t\tif (a[i] <= n - 13) then inc(ans);\n \tu := min(13, n);\n \tfor i := 1 to u do\n \t\tb[i] := n - (u - i);\n \tf[1] := 1; for i := 2 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n\n kol := 1;\n while kol < k do begin\n for j := 1 to u - 1 do\n if kol + f[j + 1] > k then begin\n t := b[u - j + 1]; b[u - j + 1] := b[u - j]; b[u - j] := t;\n kol := kol + f[j];\n break;\n end;{ else\n if kol + f[j] = k then begin\n t := b[u - j + 1]; b[u - j + 1] := b[u - j]; b[u - j] := t;\n kol := k;\n break;\n end; }\n end;\n\tfor i := 1 to u do\n\t\tif (lucky(b[i])) and lucky(n - u + i) then inc(ans);\n \twrite(ans);\nend."}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n\ti, p, ans, len, l, u, j, q: longint;\n\tkol, k, n, t, cur, kl: int64;\n\tb, f: array [0..20] of int64;\n a: array [0..2048] of int64;\n\nProcedure go(p: longint; x: int64);\nvar\n\ti: longint;\n\nbegin\n\tif p > len then begin\n\t\tinc(l); a[l] := x;\n\t\texit;\n\tend;\n\tfor i := 0 to 1 do\n\t\tif i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n\tlucky := false;\n\twhile (x > 0) do begin\n\t\tif (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n\t\tx := x div 10;\n \tend;\n \tlucky := true;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tread(n, k); l := 0;\n\tfor len := 1 to 9 do\n\t\tgo(1, 0);\n \tans := 0;\n\tfor i := 1 to l do\n\t\tif (a[i] <= n - 13) then inc(ans);\n \tu := min(13, n);\n \tfor i := 1 to u do\n \t\tb[i] := n - (u - i);\n \tf[1] := 1; for i := 2 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n\n kol := 1;\n while kol < k do begin\n for j := 1 to u - 1 do\n if kol + f[j + 1] >= k then begin\n t := b[u - j + 1]; b[u - j + 1] := b[u - j]; b[u - j] := t;\n if j = 1 then kol := kol + f[j] else kol := kol + f[j] + 1;\n break;\n end;\n end;\n\tfor i := 1 to u do\n\t\tif (lucky(b[i])) and lucky(n - u + i) then inc(ans);\n \twrite(ans);\nend."}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n\ti, p, ans, len, l, u, j: longint;\n\tkol, k, n, t, cur, kl: int64;\n\tb, f: array [0..20] of int64;\n a: array [0..2048] of int64;\n\t \nProcedure go(p: longint; x: int64);\nvar\n\ti: longint;\n\nbegin\n\tif p > len then begin\n\t\tinc(l); a[l] := x;\n\t\texit;\n\tend;\n\tfor i := 0 to 1 do\n\t\tif i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n\tlucky := false;\n\twhile (x > 0) do begin\n\t\tif (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n\t\tx := x div 10;\n \tend;\n \tlucky := true;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tread(n, k); l := 0;\n\tfor len := 1 to 9 do\n\t\tgo(1, 0);\n \tans := 0;\n\tfor i := 1 to l do\n\t\tif (a[i] <= n - 13) then inc(ans);\n \tu := min(13, n);\n \tfor i := 1 to u do\n \t\tb[i] := n - (u - i);\n \tf[1] := 1; for i := 2 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n p := u;\n cur := u;\n kol := 0;\n kl := 1;\n while (kol < k) do begin\n \tif f[u - p + 2] > k then begin\n kol := kol + kl;\n if kol >= k then break;\n \t\tt := b[p - 1]; b[p - 1] := b[u]; b[u] := t;\n cur := b[p];\n for j := p to p + ((u - p) div 2) do begin\n t := b[j]; b[j] := b[u - (j - p)]; b[u - (j - p)] := t;\n end;\n \t\tp := u;\n \t\tinc(kol);\n \tend else begin\n \t\tkl := f[u - p + 2];\n dec(p);\n for j := p to u - 1 do begin\n t := b[j]; b[j] := b[j + 1]; b[j + 1] := t;\n end;\n\tend;\n end;\n\tfor i := 1 to u do\n\t\tif (lucky(b[i])) and lucky(n - u + i) then inc(ans);\n \twrite(ans);\nend."}, {"source_code": "Uses Math;\n{$R+,I+,S+,O+,O-}\nvar\n\ti, p, ans, len, l, u, j: longint;\n\tkol, k, n, t, cur, kl: int64;\n\tb, f: array [0..20] of int64;\n a: array [0..2048] of int64;\n\t \nProcedure go(p: longint; x: int64);\nvar\n\ti: longint;\n\nbegin\n\tif p > len then begin\n\t\tinc(l); a[l] := x;\n\t\texit;\n\tend;\n\tfor i := 0 to 1 do\n\t\tif i = 0 then go(p + 1, x * 10 + 4) else go(p + 1, x * 10 + 7);\nend; \n\nFunction lucky(x: int64): boolean;\nbegin\n\tlucky := false;\n\twhile (x > 0) do begin\n\t\tif (x mod 10 <> 4) and (x mod 10 <> 7) then exit;\n\t\tx := x div 10;\n \tend;\n \tlucky := true;\nend;\n\nbegin\n\t{$ifndef online_judge}\n\treset(input, 'a.in');\n\trewrite(output, 'a.out');\n\t{$endif}\n\tread(n, k); l := 0;\n\tfor len := 1 to 9 do\n\t\tgo(1, 0);\n \tans := 0;\n\tfor i := 1 to l do\n\t\tif (a[i] <= n - 13) then inc(ans);\n \tu := min(13, n);\n \tfor i := 1 to u do\n \t\tb[i] := n - (u - i);\n \tf[1] := 1; for i := 2 to 13 do f[i] := f[i - 1] * i;\n if f[u] < k then begin\n write(-1);\n halt;\n end;\n p := u;\n cur := u;\n kol := 0;\n kl := 1;\n while (kol < k) do begin\n \tif f[u - p + 2] > k then begin\n kol := kol + kl;\n if kol >= k then break;\n \t\tt := b[p - 1]; b[p - 1] := b[u]; b[u] := t;\n cur := b[p];\n for j := p to p + ((u - p) div 2) do begin\n t := b[j]; b[j] := b[u - (j - p)]; b[u - (j - p)] := t;\n end;\n \t\tp := u;\n \t\tinc(kol);\n \tend else begin\n \t\tkl := f[u - p + 2];\n dec(p);\n for j := p to u - 1 do begin\n t := b[j]; b[j] := b[j + 1]; b[j + 1] := t;\n end;\n\tend;\n end;\n\tfor i := 1 to u do\n\t\tif (lucky(b[i])) and lucky(i) then inc(ans);\n \twrite(ans);\nend."}, {"source_code": "program Lucky_Transformation;\nvar\n ls,k,j,i:longint;\n c:string;\n s:array[0..100000] of char;\n c1,c2:ansistring;\nbegin\n readln(ls,k);\n for i:=1 to ls do read(s[i]);\n for i:=1 to ls-1 do begin\n if (i mod 2=1) and (i+2<=ls) then begin\n c:=s[i]+s[i+1]+s[i+2];\n if c='447' then begin\n c1:='';\n for j:=1 to i-1 do c1:=c1+s[j];\n c2:='';\n for j:=i+3 to ls do c2:=c2+s[j];\n if k mod 2=0 then writeln(c1+'447'+c2)\n else writeln(c1+'477'+c2);\n halt;\n end;\n if c='477' then begin\n c1:='';\n for j:=1 to i-1 do c1:=c1+s[j];\n c2:='';\n for j:=i+3 to ls do c2:=c2+s[j];\n if k mod 2=1 then writeln(c1+'447'+c2)\n else writeln(c1+'477'+c2);\n halt;\n end;\n end;\n if (i mod 2=1) and (s[i]='4') and (s[i+1]='7') then begin\n if k=0 then break;\n s[i+1]:='4';\n dec(k);\n end;\n if (i mod 2=0) and (s[i]='4') and (s[i+1]='7') then begin\n if k=0 then break;\n s[i]:='7';\n dec(k);\n end;\n end;\n for i:=1 to ls do write(s[i]);\n writeln;\nend."}, {"source_code": "const abc=1000000000000;\nvar n,m,p,k:longint;\n s:int64;\n a:array[0..1111]of int64;\n kt:array[0..20]of boolean;\n res:longint;\n\nprocedure create(s:string);\nvar code:longint;\nbegin\n if length(s) >9 then exit;\n if s<>'' then\n begin\n inc(m);\n val(s,a[m],code);\n end;\n create(s+'4');\n create(s+'7');\nend;\n\nprocedure sort(l,r:longint);\nvar i,j:longint;\n t,x:qword;\nbegin\n if l>=r then exit;\n i:=l; j:=r;\n t:=a[(l+r) div 2];\n repeat\n while a[i]t do dec(j);\n if i<=j then\n begin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n inc(i);\n dec(j);\n end;\n until i>j;\n sort(l,j);\n sort(i,r);\nend;\n\nprocedure check;\nvar i:longint;\nbegin\n s:=1;\n p:=0;\n for i:=1 to n do\n if s*i>abc then break\n else\n begin\n inc(p);\n s:=s*i;\n end;\n\n if k>s then\n begin\n writeln(-1);\n halt;\n end;\nend;\n\nfunction chk(x:longint):boolean;\nvar s:string;\n i:longint;\nbegin\n str(x,s);\n if s='' then exit(false);\n for i:=1 to length(s) do\n if (s[i]<>'4') and (s[i]<>'7') then exit(false);\n exit(true);\nend;\n\nprocedure timhoanvi;\nvar i,j,t,count:longint;\nbegin\n for i:=1 to p do\n begin\n s:=s div (p-i+1);\n\n t:=(k+s-1) div s;\n k:=k-(t-1)*s;\n count:=0;\n for j:=1 to p do\n if kt[j]=false then\n begin\n inc(count);\n if count=t then break;\n end;\n\n kt[j]:=true;\n\n if chk(n-p+i) and chk(j) then inc(res);\n end;\nend;\n\nprocedure tinh;\nvar i:longint;\nbegin\n res:=0;\n for i:=1 to m do\n if a[i]<=n-p then inc(res)\n else break;\n\n timhoanvi;\nend;\n\nbegin\n readln(n,k);\n check;\n m:=0;\n create('');\n sort(1,m);\n tinh;\n writeln(res);\nend."}, {"source_code": "const\n fi='';\nvar\n f:Text;\n k,kq,m:longint;\n g:array [1..13,1..13] of longint;\n kt:array [1..13] of boolean;\n a,v,b:array [1..13] of longint;\n d:array [1..10] of boolean;\n lucky:array [1..2046] of int64;\n n:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nfunction ck(u:longint):boolean;\nvar\n x:longint;\nbegin\n x:=u;\n while x>0 do\n begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\nprocedure cb;\nvar\n i,j,u:longint;\nbegin\n g[1,1]:=1;\n g[2,1]:=1; g[2,2]:=1; u:=2;\n for i:=3 to 13 do\n begin\n for j:=1 to i do g[i,j]:=g[i-1,j]*u;\n g[i,i]:=g[i,i-1];\n inc(u);\n end;\nend;\nprocedure lam1;\nvar\n i,j,u,s,d,o:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=n downto 1 do\n begin\n s:=0; d:=0; o:=1;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n o:=0;\n break;\n end;\n end;\n if o=1 then\n begin\n writeln(-1);\n halt;\n end;\n s:=0;\n for j:=1 to n do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[n-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n kq:=0;\n for i:=1 to n do\n if (ck(i)) and (ck(a[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure sinh(u,le:longint);\n var\n i:longint;\n so:int64;\n begin\n if u>le then\n begin\n so:=0;\n for i:=1 to le do\n begin\n so:=so*10;\n if d[i] then so:=so+4\n else so:=so+7;\n end;\n inc(m);\n lucky[m]:=so;\n end\n else\n begin\n d[u]:=true;\n sinh(u+1,le);\n d[u]:=false;\n sinh(u+1,le);\n end;\n end;\n procedure quicksort(l,r:longint);\n var\n i,j:longint;\n p,t:int64;\n begin\n if l>=r then exit;\n i:=l; j:=r;\n p:=lucky[(i+j) div 2];\n repeat\n while lucky[i]

p do dec(j);\n if i<=j then\n begin\n t:=lucky[i]; lucky[i]:=lucky[j]; lucky[j]:=t;\n inc(i); dec(j);\n end;\n until i>=j;\n quicksort(l,j);\n quicksort(i,r);\n end;\n procedure tao;\n var\n i:longint;\n begin\n m:=0;\n for i:=1 to 10 do\n begin\n fillchar(d,sizeof(d),true);\n sinh(1,i);\n end;\n quicksort(1,m);\n end;\nprocedure lam2;\nvar\n i,j,u,s,d,o:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=13 downto 1 do\n begin\n s:=0; d:=0; o:=1;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n o:=0;\n break;\n end;\n end;\n if o=1 then\n begin\n writeln(-1);\n halt;\n end;\n s:=0;\n for j:=1 to 13 do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[13-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n if k>0 then\n begin\n writeln(-1);\n halt;\n end;\n for i:=1 to 13 do v[i]:=n-13+i;\n for i:=1 to 13 do b[i]:=n-13+a[i];\n tao;\n kq:=0;\n for i:=1 to 2046 do\n begin\n if lucky[i]=n-13 then\n begin\n kq:=i;\n break;\n end\n else\n if lucky[i]>n-13 then\n begin\n kq:=i-1;\n break;\n end;\n end;\n for i:=1 to 13 do\n if (ck(b[i])) and (ck(v[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure xuly;\nbegin\n if n<=13 then lam1\n else lam2;\nend;\nbegin\n nhap;\n cb;\n xuly;\nend.\n\n"}, {"source_code": "const\n fi='';\nvar\n f:Text;\n k,kq,m:longint;\n g:array [1..13,1..13] of longint;\n kt:array [1..13] of boolean;\n a,v,b:array [1..13] of longint;\n d:array [1..10] of boolean;\n lucky:array [1..2046] of int64;\n n:int64;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\nfunction ck(u:longint):boolean;\nvar\n x:longint;\nbegin\n x:=u;\n while x>0 do\n begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\nprocedure cb;\nvar\n i,j,u:longint;\nbegin\n g[1,1]:=1;\n g[2,1]:=1; g[2,2]:=1; u:=2;\n for i:=3 to 13 do\n begin\n for j:=1 to i do g[i,j]:=g[i-1,j]*u;\n g[i,i]:=g[i,i-1];\n inc(u);\n end;\nend;\nprocedure lam1;\nvar\n i,j,u,s,d:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=n downto 1 do\n begin\n s:=0; d:=0;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n break;\n end;\n end;\n s:=0;\n for j:=1 to n do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[n-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n kq:=0;\n for i:=1 to n do\n if (ck(i)) and (ck(a[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure sinh(u,le:longint);\n var\n i:longint;\n so:int64;\n begin\n if u>le then\n begin\n so:=0;\n for i:=1 to le do\n begin\n so:=so*10;\n if d[i] then so:=so+4\n else so:=so+7;\n end;\n inc(m);\n lucky[m]:=so;\n end\n else\n begin\n d[u]:=true;\n sinh(u+1,le);\n d[u]:=false;\n sinh(u+1,le);\n end;\n end;\n procedure quicksort(l,r:longint);\n var\n i,j:longint;\n p,t:int64;\n begin\n if l>=r then exit;\n i:=l; j:=r;\n p:=lucky[(i+j) div 2];\n repeat\n while lucky[i]

p do dec(j);\n if i<=j then\n begin\n t:=lucky[i]; lucky[i]:=lucky[j]; lucky[j]:=t;\n inc(i); dec(j);\n end;\n until i>=j;\n quicksort(l,j);\n quicksort(i,r);\n end;\n procedure tao;\n var\n i:longint;\n begin\n m:=0;\n for i:=1 to 10 do\n begin\n fillchar(d,sizeof(d),true);\n sinh(1,i);\n end;\n quicksort(1,m);\n end;\nprocedure lam2;\nvar\n i,j,u,s,d:longint;\nbegin\n u:=n; fillchar(kt,sizeof(kt),true);\n for i:=13 downto 1 do\n begin\n s:=0; d:=0;\n for j:=1 to i do\n begin\n s:=s+g[i,j]; inc(d);\n if s>=k then\n begin\n s:=s-g[i,j]; dec(d);\n k:=k-s;\n break;\n end;\n end;\n s:=0;\n for j:=1 to 13 do\n if kt[j] then\n begin\n inc(s);\n if s>d then\n begin\n a[13-i+1]:=j;\n kt[j]:=false;\n break;\n end;\n end;\n end;\n for i:=1 to 13 do v[i]:=n-13+i;\n for i:=1 to 13 do b[i]:=n-13+a[i];\n tao;\n kq:=0;\n for i:=1 to 2046 do\n begin\n if lucky[i]=n-13 then\n begin\n kq:=i;\n break;\n end\n else\n if lucky[i]>n-13 then\n begin\n kq:=i-1;\n break;\n end;\n end;\n for i:=1 to 13 do\n if (ck(b[i])) and (ck(v[i])) then inc(kq);\n writeln(kq);\nend;\nprocedure xuly;\nbegin\n if n<=13 then lam1\n else lam2;\nend;\nbegin\n nhap;\n cb;\n xuly;\nend.\n\n"}, {"source_code": "\n{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1023;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..30] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 15 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 10000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j : integer;\n\nbegin\n j := n ;\n if n > 15 then n := 15;\n if m > gt[n] then begin\n writeln(-1) ;\n halt ;\n end ;\n process1;\n for i := 1 to n do inc(a[i], n - 15 ) ;\n for i := 1 to n do\n if ok(i) and ok(a[i]) then inc(res) ;\n\n n := j;\n for i := 1 to nlk do if lk[i] > n - 15 then break ;\n inc(res,i-1) ;\n// if res = 0 then res := -1;\n writeln(Res);\nend ;\nbegin\n enter;\n process;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1023;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..14] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 14 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 10000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j : integer;\n\nbegin\n j := n ;\n if n > 14 then n := 14 ;\n if k > gt[n] then begin\n writeln(-1) ;\n halt ;\n end ;\n process1;\n for i := 1 to n do\n if ok(i) and ok(a[i]) then inc(res) ;\n\n n := j ;\n for i := 1 to nlk do if lk[i] > n then break ;\n inc(res,nlk-i) ;\n if res = 0 then res := -1;\n writeln(Res);\nend ;\nbegin\n enter;\n process;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1023;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..14] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 14 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 10000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j : integer;\n\nbegin\n j := n ;\n if n > 14 then n := 14 ;\n process1;\n for i := 1 to n do\n if ok(i) and ok(a[i]) then inc(res) ;\n\n n := j ;\n for i := 1 to nlk do if lk[i] > n then break ;\n inc(res,nlk-i) ;\n writeln(Res);\nend ;\nbegin\n enter;\n process;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1024;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..30] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 15 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 1000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j , k : integer;\n\nbegin\n j := n ;\n k := 0 ;\n if n > 15 then begin\n k := n - 15;\n n := 15;\n end ;\n\n if m > gt[n] then begin\n writeln(-1) ;\n halt ;\n end ;\n process1;\n\n// for i := 1 to n do inc(a[i], n ) ;\n for i := 1 to n do\n if ok(i+k) and ok(a[i]+k) then inc(res) ;\n\n n := j;\n for i := 1 to nlk do if lk[i] > n - 15 then break ;\n inc(res,i-1) ;\n// if res = 0 then res := -1;\n writeln(Res);\nend ;\nbegin\n cal(0) ;qsort(1,nlk) ;\n enter;\n\n process;\nend.\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo= '';\n maxN = 10000000;\n nlk = 1023;\nvar\n n , m,k,count : integer;\n res : int64 ;\n lk,a : array[0..nlk] of int64;\n gt : array[0..14] of int64;\n f : text ;\n\nProcedure enter;\nvar i : integer;\nbegin\n assign(f,fi) ; reset(f);\n readln(f,n,m);\n close(F) ;\n gt[1] := 1;\n for i := 2 to 14 do gt[i] := gt[i-1] * i ;\nend ;\n\n\nProcedure cal( i : int64 );\n\nvar x : int64;\n\nbegin\n if i >= 10000000000 then exit ;\n inc(n) ;\n lk[n] := i ;\n x:= i ;\n i := x * 10 + 4;\n cal(i) ;\n i := x * 10 + 7;\n cal(i);\n\nend ;\n\nprocedure qsort(l,h : integer);\nvar i , j , pivot : integer;\n\nbegin\n if l >= h then exit ;\n i := random( h - l + 1) + l ;\n pivot :=lk[ i] ; lk[i] := lk[l] ;\n i := l ;\n j := h ;\n repeat\n while (i pivot) do dec(j) ;\n if i < j then begin\n lk[i] :=lk[j];\n inc(i);\n end else break;\n while (i 0 do\n begin\n i := x mod 10 ;\n if ( i<>4) and ( i<>7) then exit(false);\n x := x div 10 ;\n end ;\n result := true ;\nend ;\n\nProcedure process;\nvar i , j : integer;\n\nbegin\n j := n ;\n if n > 14 then n := 14 ;\n if k > gt[n] then begin\n writeln(-1) ;\n halt ;\n end ;\n process1;\n for i := 1 to n do\n if ok(i) and ok(a[i]) then inc(res) ;\n\n n := j ;\n for i := 1 to nlk do if lk[i] > n then break ;\n inc(res,nlk-i) ;\n \n writeln(Res);\nend ;\nbegin\n enter;\n process;\nend.\n"}, {"source_code": "{$mode objfpc}\nvar f:text;\n n,k:longint;\n a,b:array[0..13] of int64;\n pivot,m,l:int64;\n q:array[1..1100] of int64;\n first,last:longint;\n dem:longint;\n\nprocedure input;\nbegin\n assign(f,'');\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure push(x:int64);\nbegin\n inc(last);\n q[last]:=x;\nend;\n\nfunction pop:int64;\nbegin\n pop:=q[first];\n inc(first);\nend;\n\nprocedure init;\nvar u,v:int64;\n i:longint;\nbegin\n dem:=0;\n pivot:=1;\n b[0]:=1;\n b[1]:=1;\n first:=1;\n last:=0;\n while k>b[pivot] do\n begin\n inc(pivot);\n b[pivot]:=b[pivot-1]*pivot;\n end;\n m:=pivot;\n l:=n-pivot+1;\n if l<=0 then\n begin\n dem:=-1;\n exit;\n end;\n if 4=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l];\n i:=l;\n j:=h;\n repeat\n while (ipivot) do dec(j);\n if i0 do\n begin\n u:=v mod 10;\n if u<>4 then\n if v<>7 then exit(false);\n v:=v div 10;\n end;\n exit(true);\nend;\n\nprocedure swap(var a,b:int64);\nvar temp:int64;\nbegin\n temp:=a;\n a:=b;\n b:=temp;\nend;\n\nprocedure solve;\nvar i:longint;\nbegin\n while k<>0 do\n for i:=1 to pivot do\n if (k>(int64(i)-1)*b[pivot-1]) and (k<=(int64(i)*b[pivot-1])) then\n begin\n swap(a[m-pivot+i],a[m-pivot+1]);\n qs(m-pivot+2,m);\n k:=k-(int64(i)-1)*b[pivot-1];\n if k=1 then exit;\n dec(pivot);\n end;\nend;\n\nprocedure output;\nvar i:longint;\nbegin\n if dem<>-1 then\n for i:=1 to m do\n if kt(a[i]) and kt(i+l-1) then inc(dem);\n writeln(dem);\nend;\n\nbegin\n input;\n init;\n if dem<>-1 then solve;\n output;\nend.\n"}, {"source_code": "{$mode objfpc}\nvar f:text;\n n,k:longint;\n a,b:array[0..13] of int64;\n pivot,m,l:int64;\n q:array[1..1100] of int64;\n first,last:longint;\n dem:longint;\n\nprocedure input;\nbegin\n assign(f,'');\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n\nprocedure push(x:int64);\nbegin\n inc(last);\n q[last]:=x;\nend;\n\nfunction pop:int64;\nbegin\n pop:=q[first];\n inc(first);\nend;\n\nprocedure init;\nvar u,v:int64;\n i:longint;\nbegin\n dem:=0;\n pivot:=1;\n b[0]:=1;\n b[1]:=1;\n first:=1;\n last:=0;\n while k>b[pivot] do\n begin\n inc(pivot);\n b[pivot]:=b[pivot-1]*pivot;\n end;\n m:=pivot;\n l:=n-pivot+1;\n if l<=0 then\n begin\n dem:=-1;\n exit;\n end;\n if 4=h then exit;\n i:=random(h-l+1)+l;\n pivot:=a[i];\n a[i]:=a[l];\n i:=l;\n j:=h;\n repeat\n while (ipivot) do dec(j);\n if i0 do\n begin\n u:=v mod 10;\n if u<>4 then\n if v<>7 then exit(false);\n v:=v div 10;\n end;\n exit(true);\nend;\n\nprocedure swap(var a,b:int64);\nvar temp:int64;\nbegin\n temp:=a;\n a:=b;\n b:=temp;\nend;\n\nprocedure solve;\nvar i:longint;\nbegin\n while k<>0 do\n for i:=1 to pivot do\n if (k>(int64(i)-1)*b[pivot-1]) and (k<=(int64(i)*b[pivot-1])) then\n begin\n swap(a[m-pivot+i],a[m-pivot+1]);\n qs(m-pivot+2,m);\n k:=k-(int64(i)-1)*b[pivot-1];\n if k=1 then exit;\n dec(pivot);\n end;\nend;\n\nprocedure output;\nvar i:longint;\nbegin\n for i:=1 to m do\n if kt(a[i]) and kt(i+l-1) then inc(dem);\n writeln(dem);\nend;\n\nbegin\n input;\n init;\n if dem<>-1 then solve;\n output;\nend.\n"}, {"source_code": "var\n z:int64;\n p:array[0..1025]of boolean;\n a,s:array[0..1025]of int64;\n ans,n,m,x,i,j,k,t:Longint;\n\nfunction pd(x:longint):boolean;\nbegin\n while x>0 do begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nbegin\n s[0]:=1; for i:=1 to 12 do s[i]:=s[i-1]*i;\n read(n,m); dec(m);\n if (n<=12) and (m+1>s[n]) then begin writeln(-1); exit end;\n t:=12; if t>n then t:=n; k:=n-t+1;\n a[1]:=4; a[2]:=7; j:=2; i:=0;\n repeat\n inc(i);\n z:=a[i]*10+4; if z0 do begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nbegin\n s[0]:=1; for i:=1 to 12 do s[i]:=s[i-1]*i;\n read(n,m); dec(m);\n t:=12; if t>n then t:=n; k:=n-t+1;\n a[1]:=4; a[2]:=7; j:=2; i:=0;\n repeat\n inc(i);\n z:=a[i]*10+4; if z10000000000 then exit;\n\tinc(nn); a[nn]:=x;\n\tlucky(10*x+4); lucky(10*x+7);\n end;\n\nfunction islucky(a:int64):boolean;\n begin\n if a=0 then exit(true)\n\telse if not ((a mod 10) in [4,7]) then exit(false)\n\telse exit(islucky(a div 10));\n end;\n\nbegin\n lucky(4); lucky(7);\n for i:=1 to nn-1 do\n for j:=nn downto i+1 do\n\t if a[j]fact[n] then\n\t begin\n\t writeln(-1);halt;\n\t end;\n dec(k);\n fillchar(used,sizeof(used),false);\n if n>15 then\n begin\n\t temp:=n; n:=15;\n\tend;\n for i:=1 to n do z[i]:=i;\n for i:=1 to n do\n begin\n\t t:=k div fact[n-i];\n\t k:=k-t*fact[n-i];\n\t s[i]:=z[t+1];\n\t for j:=t+1 to n-1 do\n\t z[j]:=z[j+1];\n\tend;\n if temp>15 then\n begin\n\t for i:=1 to 15 do\n\t if islucky(temp-15+int64(i)) and islucky(temp-15+int64(s[i])) then inc(ans);\n\t for i:=1 to nn do\n\t if a[i]>temp-15 then break\n\t\t else inc(ans);\n\tend\n else for i:=1 to n do\n if islucky(int64(i)) and islucky(int64(s[i])) then inc(ans);\n writeln(ans);\n \nend.\n"}, {"source_code": "var\n n,k,temp,t:int64;\n i,j,ans:longint;\n fact:array[0..15] of int64;\n used:array[0..15] of boolean;\n z,s:array[0..15] of longint;\n\nfunction islucky(a:int64):boolean;\n begin\n if a=0 then exit(true)\n\telse if not ((a mod 10) in [4,7]) then exit(false)\n\telse exit(islucky(a div 10));\n end;\n\nbegin\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=fact[i-1]*i;\n if n<15 then\n if k>fact[n] then\n\t begin\n\t writeln(-1);halt;\n\t end;\n dec(k);\n fillchar(used,sizeof(used),false);\n if n>15 then\n begin\n\t temp:=n; n:=15;\n\tend;\n for i:=1 to n do z[i]:=i;\n for i:=1 to n do\n begin\n\t t:=k div fact[n-i];\n\t k:=k-t*fact[n-i];\n\t s[i]:=z[t+1];\n\t for j:=t+1 to n-1 do\n\t z[j]:=z[j+1];\n\tend;\n if temp>15 then\n begin\n\t for i:=1 to 15 do\n\t if islucky(temp-14+int64(i)) and islucky(temp-14+int64(s[i])) then inc(ans);\n\tend\n else for i:=1 to n do\n if islucky(int64(i)) and islucky(int64(s[i])) then inc(ans);\n writeln(ans);\n \nend.\n"}, {"source_code": "var\n n,k,temp,t:int64;\n i,j,ans:longint;\n fact:array[0..15] of int64;\n used:array[0..15] of boolean;\n z,s:array[0..15] of longint;\n\nfunction islucky(a:int64):boolean;\n begin\n if a=0 then exit(true)\n\telse if not ((a mod 10) in [4,7]) then exit(false)\n\telse exit(islucky(a div 10));\n end;\n\nbegin\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=fact[i-1]*i;\n if n<15 then\n if k>fact[n] then\n\t begin\n\t writeln(-1);halt;\n\t end;\n dec(k);\n fillchar(used,sizeof(used),false);\n if n>15 then\n begin\n\t temp:=n; n:=15;\n\tend;\n for i:=1 to n do z[i]:=i;\n for i:=1 to n do\n begin\n\t t:=k div fact[n-i];\n\t k:=k-t*fact[n-i];\n\t s[i]:=z[t+1];\n\t for j:=t+1 to n-1 do\n\t z[j]:=z[j+1];\n\tend;\n if temp>15 then\n begin\n\t for i:=1 to 15 do\n\t if islucky(temp-15+int64(i)) and islucky(temp-15+int64(s[i])) then inc(ans);\n\tend\n else for i:=1 to n do\n if islucky(int64(i)) and islucky(int64(s[i])) then inc(ans);\n writeln(ans);\n \nend.\n"}, {"source_code": "var\n n,k,temp,t:int64;\n i,j,ans:longint;\n fact:array[0..15] of int64;\n used:array[0..15] of boolean;\n z,s:array[0..15] of longint;\n\nfunction islucky(a:int64):boolean;\n begin\n if a=0 then exit(true)\n\telse if not ((a mod 10) in [4,7]) then exit(false)\n\telse exit(islucky(a div 10));\n end;\n\nbegin\n readln(n,k);\n fact[0]:=1;\n for i:=1 to 15 do\n fact[i]:=fact[i-1]*i;\n if n<15 then\n if k>fact[n] then\n\t begin\n\t writeln(-1);halt;\n\t end;\n dec(k);\n fillchar(used,sizeof(used),false);\n if n>15 then\n begin\n\t temp:=n; n:=15;\n\tend;\n for i:=1 to n do z[i]:=i;\n for i:=1 to n do\n begin\n\t t:=k div fact[n-i];\n\t k:=k-t*fact[n-i];\n\t s[i]:=z[t+1];\n\t for j:=t+1 to n-1 do\n\t z[j]:=z[j+1];\n\tend;\n {if temp>15 then\n begin\n\t for i:=1 to 15 do\n\t if islucky(temp-15+int64(i)) and islucky(temp-15+int64(s[i])) then inc(ans);\n\tend\n else }for i:=1 to n do\n if islucky(int64(i)) and islucky(int64(s[i])) then inc(ans);\n writeln(ans);\n \nend.\n"}, {"source_code": "const\n inf=1000000000;\nvar\n ss,m,i,j,n,k,kt,res:longint;\n t:array[0..500500]of longint;\n q,fact:array[0..500]of longint;\n was:array[0..500500]of boolean;\n procedure gen(x:longint);\n begin\n if (x<>0)then begin\n inc(kt);t[kt]:=x;\n end;\n if (int64(x)*10>inf)then exit;\n gen(x*10+4);\n gen(x*10+7);\n end;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n,k);\n kt:=0;\n gen(0);\n res:=0;\n for i:=1 to kt do\n if (t[i]12)then begin\n m:=12;\n ss:=n-11;\n end else begin\n if (k>fact[n])then begin\n writeln(-1);\n exit;\n end;\n end;\n fillchar(was,sizeof(was),false);\n for i:=1 to m do begin\n j:=1;\n while (true)do begin\n while (was[j])do inc(j);\n if (k>fact[m-i])then begin\n dec(k,fact[m-i]);\n inc(j);\n end else break;\n end;\n was[j]:=true;\n q[i]:=ss+j-1;\n end;\n for i:=1 to kt do\n if (t[i]>=ss)and(t[i]<=n)then\n for j:=1 to kt do\n if (q[t[i]-ss+1]=t[j])then inc(res);\n writeln(res);\n close(output);close(input);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nconst\n inf=1000000000;\nvar\n ss,m,i,j,n,k,kt,res:longint;\n t:array[0..500500]of longint;\n q,fact:array[0..500]of longint;\n was:array[0..500500]of boolean;\n procedure gen(x:longint);\n begin\n if (x<>0)then begin\n inc(kt);t[kt]:=x;\n end;\n if (int64(x)*10>inf)then exit;\n gen(x*10+4);\n gen(x*10+7);\n end;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n,k);\n kt:=0;\n gen(0);\n res:=0;\n for i:=1 to kt do\n if (t[i]12)then begin\n m:=12;\n ss:=n-11;\n for i:=1 to m do fact[i]:=fact[i-1]*i;\n end else begin\n for i:=1 to n do fact[i]:=fact[i-1]*i;\n if (k>fact[n])then begin\n writeln(-1);\n exit;\n end;\n end;\n fillchar(was,sizeof(was),false);\n for i:=1 to m do begin\n j:=1;\n while (true)do begin\n while (was[j])do inc(j);\n if (k>fact[m-i])then begin\n dec(k,fact[m-i]);\n inc(j);\n end else break;\n end;\n was[j]:=true;\n q[i]:=ss+j-1;\n end;\n for i:=1 to kt do\n if (t[i]>=ss)and(t[i]<=n)then\n for j:=1 to kt do\n if (q[t[i]-ss+1]=t[j])then inc(res);\n writeln(res);\n close(output);close(input);\nend.\n"}, {"source_code": "const\n{ fi='per.inp';\n fo='per.out';}\n fi='';\n fo='';\n maxn=3003;\n\nvar\n f:text;\n gt,c,d,a,b:array[0..maxn]of int64;\n ok:array[0..maxn]of boolean;\n spt,n,k:longint;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if yl then check(l)\n else\n for j:=1 to 2 do\n begin\n if j=1 then a[i]:=4\n else a[i]:=7;\n try(i+1,l);\n end;\nend;\n\nfunction luck(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4) and (x mod 10<>7) then exit(false);\n x:=x div 10;\n end;\n luck:=true;\nend;\n\nprocedure main;\nvar i,kq,j,t,m:longint;\nbegin\n spt:=0;\n for i:=1 to 10 do try(1,i);\n gt[0]:=1;\n for i:=1 to 13 do gt[i]:=gt[i-1]*i;\n for i:=1 to spt do d[i]:=b[i];\n\n if (n<=13) and (gt[n]=k then break;\n fillchar(ok,sizeof(ok),true);\n for i:=1 to m do\n begin\n for j:=1 to m do\n if ok[j] then\n if k<=gt[m-i] then break\n else k:=k-gt[m-i];\n c[i]:=j;\n ok[j]:=false;\n end;\n for i:=1 to m do\n begin\n j:=n-m+c[i];\n if luck(j) then\n for t:=1 to spt do\n if b[t]=j then\n begin\n d[t]:=n-m+i;\n break;\n end;\n end;\n end;\n\n kq:=0;\n for i:=1 to spt do\n if b[i]<=n then\n if luck(d[i]) then inc(kq);\n\n\n assign(f,fo);rewrite(f);\n writeln(f,kq);\n close(F);\nend;\n\nbegin\n open;\n main;\nend."}, {"source_code": "Program Lucky_Permutation;\nConst\n MAXN =15+10;\n OO =987654321;\nVar\n n,m,ans :longint;\n flag :array[0..MAXN] of boolean;\n c :array[0..MAXN] of int64;\n\nFunction Change(x:int64):int64;\nVar\n i,j,k :longint;\n d :int64;\nbegin\n if x=0 then exit(4);\n d:=1;\n while d<=x do\n begin\n if x mod (d*10) div d=4 then \n begin\n x:=x+d*3;\n if d<>1 then \n begin\n d:=d div 10;\n while d>0 do\n begin\n if x mod (d*10) div d=7 then\n x:=x-3*d;\n d:=d div 10;\n end;\n end;\n exit(x);\n end;\n d:=d*10;\n end;\n x:=0;\n while d>0 do\n begin\n x:=x+d*4;\n d:=d div 10;\n end;\n exit(x);\nend;\n\nFunction Check(x:longint):boolean;\nVar\n k :longint;\nbegin\n while x>0 do\n begin\n k:=x mod 10;\n if (k<>4) and (k<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nProcedure Main;\nVar\n i,j,k,len,l :longint;\n now :int64;\nbegin\n readln(n,m);dec(m);\n c[0]:=1;\n for i:=1 to 15 do c[i]:=c[i-1]*i;\n if (n<=15) and (c[n]m then break;\n len:=i;now:=4;\n while now<=n-len do\n begin\n inc(ans);\n now:=change(now);\n end;\n for i:=len-1 downto 0 do \n begin\n k:=m div c[i];\n j:=0;\n for l:=0 to k do\n begin\n inc(j);\n while flag[j] do inc(j);\n end;\n flag[j]:=true;\n if check(n-len+j) and check(n-i) then inc(ans);\n m:=m mod c[i];\n end;\n writeln(ans);\nend;\n \nBegin\n Main;\nEnd."}, {"source_code": "Program Lucky_Permutation;\nConst\n MAXN =15+10;\n OO =987654321;\nVar\n n,m,ans :longint;\n flag :array[0..MAXN] of boolean;\n c :array[0..MAXN] of int64;\n\nFunction Change(x:int64):int64;\nVar\n i,j,k :longint;\n d :int64;\nbegin\n if x=0 then exit(4);\n d:=1;\n while d<=x do\n begin\n if x mod (d*10) div d=4 then \n begin\n x:=x+d*3;\n if d<>1 then \n begin\n d:=d div 10;\n while d>0 do\n begin\n if x mod (d*10) div d=7 then\n x:=x-3*d;\n d:=d div 10;\n end;\n end;\n exit(x);\n end;\n d:=d*10;\n end;\n x:=0;\n while d>0 do\n begin\n x:=x+d*4;\n d:=d div 10;\n end;\n exit(x);\nend;\n\nFunction Check(x:longint):boolean;\nVar\n k :longint;\nbegin\n while x>0 do\n begin\n k:=x mod 10;\n if (k<>4) and (k<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nProcedure Main;\nVar\n i,j,k,len,l :longint;\n now :int64;\nbegin\n readln(n,m);\n c[0]:=1;\n for i:=1 to 15 do c[i]:=c[i-1]*i;\n if (n<=15) and (c[n]<=m) then\n begin\n writeln('-1');\n halt;\n end;dec(m);\n for i:=1 to 15 do\n if c[i]>m then break;\n len:=i;now:=4;\n while now<=n-len do\n begin\n inc(ans);\n now:=change(now);\n end;\n for i:=len-1 downto 0 do \n begin\n k:=m div c[i];\n j:=0;\n for l:=0 to k do\n begin\n inc(j);\n while flag[j] do inc(j);\n end;\n flag[j]:=true;\n if check(n-len+j) and check(n-i) then inc(ans);\n m:=m mod c[i];\n end;\n writeln(ans);\nend;\n \nBegin\n Main;\nEnd."}, {"source_code": "Program Lucky_Permutation;\nConst\n MAXN =15+10;\n OO =987654321;\nVar\n n,m,ans :longint;\n flag :array[0..MAXN] of boolean;\n c :array[0..MAXN] of int64;\n\nFunction Change(x:int64):int64;\nVar\n i,j,k :longint;\n d :int64;\nbegin\n if x=0 then exit(4);\n d:=1;\n while d<=x do\n begin\n if x mod (d*10) div d=4 then \n begin\n x:=x+d*3;\n if d<>1 then \n begin\n d:=d div 10;\n while d>0 do\n begin\n if x mod (d*10) div d=7 then\n x:=x-3*d;\n d:=d div 10;\n end;\n end;\n exit(x);\n end;\n d:=d*10;\n end;\n x:=0;\n while d>0 do\n begin\n x:=x+d*4;\n d:=d div 10;\n end;\n exit(x);\nend;\n\nFunction Check(x:longint):boolean;\nVar\n k :longint;\nbegin\n while x>0 do\n begin\n k:=x mod 10;\n if (k<>4) and (k<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nProcedure Main;\nVar\n i,j,k,len,l :longint;\n now :int64;\nbegin\n readln(n,m);dec(m);\n c[0]:=1;\n for i:=1 to 15 do c[i]:=c[i-1]*i;\n for i:=1 to 15 do\n if c[i]>m then break;\n len:=i;now:=4;\n while now<=n-len do\n begin\n inc(ans);\n now:=change(now);\n end;\n for i:=len-1 downto 0 do \n begin\n k:=m div c[i];\n j:=0;\n for l:=0 to k do\n begin\n inc(j);\n while flag[j] do inc(j);\n end;\n flag[j]:=true;\n if check(n-len+j) and check(n-i) then inc(ans);\n m:=m mod c[i];\n end;\n writeln(ans);\nend;\n \nBegin\n Main;\nEnd."}, {"source_code": "Program Lucky_Permutation;\nConst\n MAXN =15+10;\n OO =987654321;\nVar\n n,m,ans :longint;\n flag :array[0..MAXN] of boolean;\n c :array[0..MAXN] of int64;\n\nFunction Change(x:int64):int64;\nVar\n i,j,k :longint;\n d :int64;\nbegin\n if x=0 then exit(4);\n d:=1;\n while d<=x do\n begin\n if x mod (d*10) div d=4 then \n begin\n x:=x+d*3;\n if d<>1 then \n begin\n d:=d div 10;\n while d>0 do\n begin\n if x mod (d*10) div d=7 then\n x:=x-3*d;\n d:=d div 10;\n end;\n end;\n exit(x);\n end;\n d:=d*10;\n end;\n x:=0;\n while d>0 do\n begin\n x:=x+d*4;\n d:=d div 10;\n end;\n exit(x);\nend;\n\nFunction Check(x:longint):boolean;\nVar\n k :longint;\nbegin\n while x>0 do\n begin\n k:=x mod 10;\n if (k<>4) and (k<>7) then exit(false);\n x:=x div 10;\n end;\n exit(true);\nend;\n\nProcedure Main;\nVar\n i,j,k,len,l :longint;\n now :int64;\nbegin\n readln(n,m);dec(m);\n if (n<=15) and (c[n]m then break;\n len:=i;now:=4;\n while now<=n-len do\n begin\n inc(ans);\n now:=change(now);\n end;\n for i:=len-1 downto 0 do \n begin\n k:=m div c[i];\n j:=0;\n for l:=0 to k do\n begin\n inc(j);\n while flag[j] do inc(j);\n end;\n flag[j]:=true;\n if check(n-len+j) and check(n-i) then inc(ans);\n m:=m mod c[i];\n end;\n writeln(ans);\nend;\n \nBegin\n Main;\nEnd."}, {"source_code": "var a1:array[1..5000] of qword;\n a:array[1..20] of qword;\n ans:array[1..20] of longint;\n bo:array[1..20] of boolean;\n i,j,n,k,n1,tot,sum:longint;\n t,cator:qword;\n flag:boolean;\nprocedure dfs(m:longint; s:string);\n var t:qword;\n begin\n if m>10 then exit;\n if m>0 then\n begin\n val(s,t);\n inc(tot);\n a1[tot]:=t;\n end;\n dfs(m+1,s+'4');\n dfs(m+1,s+'7');\n end;\nfunction cal(x:longint):qword;\n var i:longint;\n s:qword;\n begin\n s:=1;\n for i:=1 to x do s:=s*i;\n exit(s);\n end;\nfunction check(x:longint):boolean;\n var i,t:longint;\n s:string;\n begin\n t:=x+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n t:=ans[x]+n1;\n str(t,s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7') then exit(false);\n exit(true);\n end;\nbegin\n fillchar(bo,sizeof(bo),false);\n readln(n,k);\n flag:=false;\n cator:=1;\n for i:=2 to n do\n begin\n cator:=cator*i;\n if cator>=k then\n begin\n flag:=true;\n break;\n end;\n end;\n if not flag then\n begin\n writeln('-1');\n halt;\n end;\n if n>15 then\n begin\n n1:=n-15;\n n:=15;\n dfs(0,'');\n for i:=1 to tot-1 do\n for j:=i+1 to tot do\n if a1[i]>a1[j] then\n begin\n t:=a1[i];\n a1[i]:=a1[j];\n a1[j]:=t;\n end;\n for i:=1 to tot do\n if a1[i]<=n1 then inc(sum)\n else break;\n end;\n cator:=k-1;\n for i:=n-1 downto 1 do\n begin\n flag:=false;\n a[n-i]:=cator div cal(i);\n cator:=cator mod cal(i);\n t:=0;\n j:=1;\n while (j<=n)and not flag do\n if not bo[j] then begin\n inc(t);\n if t=a[n-i]+1 then begin\n ans[n-i]:=j;\n flag:=true;\n bo[j]:=true;\n end\n else inc(j);\n end\n else inc(j);\n end;\n for i:=1 to n do\n if not bo[i] then\n begin\n ans[n]:=i;\n break;\n end;\n for i:=1 to n do\n if check(i) then inc(sum);\n writeln(sum);\nend."}, {"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,e : longint;\n begin\n e:=x;\n for i:=n-f+1 downto 1 do\n if mar[i]=1 then\n begin\n e:=x+i;\n break;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w=0 then inc(X);\n x:=maxx(X);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n-f+1)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,f,e : longint;\n begin\n e:=x;\n f:=0;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n inc(f);\n if f=x then begin e:=i;break;end;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w<>0 then inc(X);\n if mar[x]=1 then\n x:=maxx(x);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n-f+1)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,f,e : longint;\n begin\n e:=x;\n f:=0;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n inc(f);\n if f=x then begin e:=i;break;end;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w<>0 then inc(X);\n x:=maxx(x);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n-f+1)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n a,b,rr,mar :array [1..10000] of int64;\n s:string;\n code: integer;\n n,nn,f,y,u,r,v,ans,k,w,e,x,h : int64;\n i,j,ii : longint;\n function fact(x : int64) : int64;\n var\n i: longint;\n e: int64;\n begin\n e:=1;\n for i:=1 to x do e:=e*i;\n fact:=e;\n end;\n function pos(x : int64) : boolean;\n begin\n pos:=false;\n for ii:=1 to v do\n if a[ii]=x then begin pos:=true; exit; end;\n end;\n function maxx(x: int64): int64;\n var\n i,f,e : longint;\n begin\n e:=x;\n f:=0;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n inc(f);\n if f=x then begin e:=i;break;end;\n end;\n maxx:=e;\n end;\nbegin\n readln(n,k);\n i:=1;\n y:=1;\n while (yn then break;\n inc(v);\n a[v]:=e;\n while true do\n begin\n j:=nn;\n while (j>=1) and (s[j]='7') do begin s[j]:='4'; dec(j); end;\n if j<1 then break;\n s[j]:='7';\n val(S,e,code);\n if e>n then break\n else\n begin\n inc(v);\n a[v]:=e;\n end;\n end;\n inc(nn);\n end;\n if e=0 then begin writeln(0);exit; end;\n f:=n-r+1;\n for i:=1 to v do\n if a[i]>=f then begin inc(u); b[u]:=a[i];end\n else\n inc(ans);\n for i:=f to n do\n for j:=1 to u do\n if i=b[j] then begin inc(h); rr[h]:=i-f+1;end;\n for i:=1 to n-f do\n begin\n e:=n-f+1-i;\n w:=fact(e);\n x:=k div w;\n if k mod w<>0 then inc(X);\n if mar[x]=1 then\n x:=maxx(n-f+1-i);\n for j:=1to h do\n if (rr[j]=x) and (pos(i+f-1)) then inc(ans);\n mar[x]:=1;\n k:=k mod w;\n if k=0 then k:=w;\n end;\n for i:=1 to n-f+1 do\n if mar[i]=0 then\n begin\n for j:=1to h do\n if (rr[j]=i) and (pos(n-f+1)) then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "Var fac:array [0..15] of int64;\nm:array [1..100] of byte;\na:array [1..15] of longint;\nused:array [1..15]of boolean;\ne,z,rez,kol,i,n,j,k:longint;\nzz:int64;\nfunction proverka(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7)\n then begin proverka:=false; exit; end;\n x:=x div 10;\n end;\n proverka:=true;\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n fac[0]:=1;\n for i:=1 to 15 do\n fac[i]:=fac[i-1]*i;\n if n<=15\n then begin\n if fac[n]15\n then begin\n z:=1;\n while 1=1 do\n begin\n zz:=1;\n rez:=0;\n for i:=1 to z do\n begin\n if m[i]=0\n then rez:=rez+zz*4\n else rez:=rez+zz*7;\n zz:=zz*10;\n end;\n if rez<=n-15\n then inc(kol)\n else break;\n inc(m[1]);\n for i:=1 to z do\n if m[i]=2\n then begin\n inc(m[i+1]);\n m[i]:=0;\n end;\n if m[z+1]=1\n then begin\n inc(z);\n fillchar(m,sizeof(m),0);\n end;\n end;\n e:=15;\n end\n else e:=n;\n dec(k);\n for i:=1 to e do\n begin\n z:=1;\n while fac[e-i]<=k do\n begin\n k:=k-fac[e-i];\n inc(z);\n end;\n for j:=1 to e do\n if not used[j]\n then begin\n dec(z);\n if z=0\n then begin\n used[j]:=true;\n a[i]:=j;\n break;\n end;\n end;\n end;\n for i:=1 to e do\n if proverka(n-(e-i))and(proverka(n-e+a[i]))\n then inc(kol);\n writeln(kol);\nend."}, {"source_code": "Var fac:array [0..15] of int64;\nm:array [1..100] of byte;\na:array [1..15] of longint;\nused:array [1..15]of boolean;\ne,z,rez,kol,i,n,j,k:longint;\nzz:int64;\nfunction proverka(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7)\n then begin proverka:=false; exit; end;\n x:=x div 10;\n end;\n proverka:=true;\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n fac[0]:=1;\n for i:=1 to 15 do\n fac[i]:=fac[i-1]*i;\n if n<=15\n then begin\n if fac[n]15\n then begin\n z:=1;\n while 1=1 do\n begin\n zz:=1;\n rez:=0;\n for i:=1 to z do\n begin\n if m[i]=0\n then rez:=rez+zz*4\n else rez:=rez+zz*7;\n zz:=zz*10;\n end;\n if rez<=n-k\n then inc(kol)\n else break;\n inc(m[1]);\n for i:=1 to z do\n if m[i]=2\n then begin\n inc(m[i+1]);\n m[i]:=0;\n end;\n if m[z+1]=1\n then inc(z);\n end;\n e:=15;\n end\n else e:=n;\n dec(k);\n for i:=1 to e do\n begin\n z:=1;\n while fac[e-i]<=k do\n begin\n k:=k-fac[e-i];\n inc(z);\n end;\n for j:=1 to e do\n if not used[j]\n then begin\n dec(z);\n if z=0\n then begin\n used[j]:=true;\n a[i]:=j;\n break;\n end;\n end;\n end;\n for i:=1 to e do\n if proverka(n-(e-i))and(proverka(n-e+a[i]))\n then inc(kol);\n writeln(kol);\nend."}, {"source_code": "Var fac:array [0..15] of int64;\nm:array [1..100] of byte;\na:array [1..15] of longint;\nused:array [1..15]of boolean;\ne,z,rez,kol,i,n,j,k:longint;\nzz:int64;\nfunction proverka(x:int64):boolean;\nbegin\n while x<>0 do\n begin\n if (x mod 10<>4)and(x mod 10<>7)\n then begin proverka:=false; exit; end;\n x:=x div 10;\n end;\n proverka:=true;\nend;\nbegin\n //Assign(input,'input.txt'); reset(input);\n //Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n fac[0]:=1;\n for i:=1 to 15 do\n fac[i]:=fac[i-1]*i;\n if n<=15\n then begin\n if fac[n]15\n then begin\n z:=1;\n while 1=1 do\n begin\n zz:=1;\n rez:=0;\n for i:=1 to z do\n begin\n if m[i]=0\n then rez:=rez+zz*4\n else rez:=rez+zz*7;\n zz:=zz*10;\n end;\n if rez<=n-15\n then inc(kol)\n else break;\n inc(m[1]);\n for i:=1 to z do\n if m[i]=2\n then begin\n inc(m[i+1]);\n m[i]:=0;\n end;\n if m[z+1]=1\n then inc(z);\n end;\n e:=15;\n end\n else e:=n;\n dec(k);\n for i:=1 to e do\n begin\n z:=1;\n while fac[e-i]<=k do\n begin\n k:=k-fac[e-i];\n inc(z);\n end;\n for j:=1 to e do\n if not used[j]\n then begin\n dec(z);\n if z=0\n then begin\n used[j]:=true;\n a[i]:=j;\n break;\n end;\n end;\n end;\n for i:=1 to e do\n if proverka(n-(e-i))and(proverka(n-e+a[i]))\n then inc(kol);\n writeln(kol);\nend."}], "src_uid": "cb2aa02772f95fefd1856960b6ceac4c"} {"source_code": "var b:array[0..3000]of longint;\n s,n,i,j:longint;\nbegin\n readln(n);\n for i:=2 to n do\n if b[i]=0 then\n for j:=2 to n div i do\n inc(b[i*j]);\n for i:=1 to n do\n if b[i]=2 then\n inc(s);\n writeln(s);\nend.", "positive_code": [{"source_code": "\n\n var a: array[1..2000] of longint;\n s: array[1..200, 1..200] of longint;\n kol, q, n, t, r, m, i, j: longint;\n\n begin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n a[1] := 2;\n a[2] := 3;\n a[3] := 5;\n a[4] := 7;\n a[5] := 11;\n a[6] := 13;\n a[7] := 17;\n a[8] := 19;\n a[9] := 23;\n\n a[10] := 29;\n a[11] := 31;\n a[12] := 37;\n a[13] := 41;\n a[14] := 43;\n a[15] := 47;\n\n a[16] := 53;\n m := 16;\n for i := 57 to 3000 do\n begin\n q := 0;\n for j := 1 to 16 do if i mod a[j] = 0 then q := 1;\n if q = 0 then begin inc(m); a[m] := i; end;\n end;\n for i := m + 1 to 1000 do a[i] := 4000;\n read(n);\n kol := 0;\n for i := 1 to n do\n begin\n t := 0;\n for j := 1 to 1000 do if i mod a[j] = 0 then inc(t);\n if t = 2 then inc(kol);\n end;\n write(kol);\nend.\n"}, {"source_code": "var\n n,i,j,kol,k,kolrazdel:integer;\n prost:array[2..3000] of boolean;\n flag:boolean;\n\nbegin\n readln(n);\n for i:=2 to (n div 2) do\n begin\n prost[i]:=true;\n end;\n i:=2;\n while i i) and (i div j > 1) then\n if (is_prime(i div j)) then\n inc(a[i]);\n end;\n for i:=1 to n do\n if a[i]=2 then\n inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "program _A;\n{$O-}\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n\tn,r,i:integer;\nfunction simple(x:integer):boolean;\nvar\n\ti:integer;\nbegin\n\tresult:=false;\n if (x=2) then\n begin\n \tresult:=true;\n exit;\n end;\n\tfor i:=2 to round(sqrt(x)) do\n \tif ((x mod i) = 0) then\n \texit;\n result:=true;\nend;\nfunction check(x:integer):boolean;\nvar\n\ti,c:integer;\nbegin\n\tc:=0;\n\tfor i:=2 to x-1 do\n \tif (x mod i = 0) then\n \tif (simple(i)) then\n \tinc(c);\n check:= c = 2;\nend;\nbegin\n\t{assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n read(n);\n r:=0;\n for i:= 4 to n do\n \tif check(i) then inc(r);\n writeln(r);\n {close(output);\n close(input);}\nend.\n "}, {"source_code": "program ReA;\n\n{$APPTYPE CONSOLE}\n\nconst\n a:array[1..3000] of longint=(\n 0,0,0,0,0,1,1,1,1,2,2,3,3,4,5,5,5,6,6,7,8,9,9,10,10,11,11,12,12,12,12,12,13,14,15,16,16,17,18,19,19,19,19,20,21,22,22,23,23,24,\n25,26,26,27,28,29,30,31,31,31,31,32,33,33,34,34,34,35,36,36,36,37,37,38,39,40,41,41,41,42,42,43,43,43,44,45,46,47,47,47,48,49,50,51,52,53,53,54,55,56,\n56,56,56,57,57,58,58,59,59,59,60,61,61,61,62,63,64,65,66,66,66,67,68,69,69,69,69,69,70,70,70,70,71,72,73,74,74,74,74,74,75,76,77,78,79,80,81,82,82,82,\n82,83,84,84,85,85,85,86,87,88,89,90,90,91,91,92,92,92,92,92,93,94,94,94,95,96,97,98,98,98,98,98,99,100,101,101,102,103,104,104,104,105,105,106,106,107,107,107,107,108,\n109,110,111,111,112,113,114,115,116,116,116,117,118,119,120,121,122,123,124,124,125,125,125,126,127,128,128,128,128,128,128,129,129,129,130,131,132,132,132,132,132,133,133,134,135,135,136,137,138,139,\n139,139,140,141,141,141,141,141,142,142,143,144,144,144,145,145,146,147,147,147,147,148,148,149,150,150,150,151,152,152,152,152,152,153,153,153,154,155,155,155,156,157,157,157,158,159,160,161,162,162,\n163,164,165,166,167,167,167,167,168,168,168,168,168,169,169,170,170,170,171,172,173,173,174,175,176,177,178,179,180,180,180,181,182,183,184,184,184,185,186,186,187,187,187,188,188,189,189,189,189,189,\n190,191,191,191,192,193,193,194,194,194,194,195,196,196,197,197,197,198,199,199,200,200,200,200,201,202,203,203,203,203,204,205,205,206,206,207,208,209,209,209,210,211,212,213,214,214,214,215,215,216,\n216,216,217,218,219,219,220,220,220,220,221,222,223,223,224,225,226,226,226,226,226,227,228,229,230,230,231,232,232,232,232,233,233,233,233,234,235,235,235,235,236,236,236,236,237,238,239,240,240,240,\n241,242,243,244,244,244,244,245,246,246,246,246,246,247,247,248,248,248,249,249,250,251,252,252,253,253,254,255,255,255,256,257,257,258,259,260,260,261,262,262,262,262,263,263,263,264,265,265,265,266,\n267,268,268,268,269,269,270,271,271,271,272,272,273,274,275,275,276,276,277,277,277,277,277,278,278,279,280,280,280,280,281,281,282,282,283,284,285,286,287,287,287,288,289,290,291,291,291,292,293,293,\n294,294,295,296,296,297,297,297,298,298,298,299,299,299,300,301,302,303,303,303,303,303,304,304,305,306,306,307,308,308,309,309,310,311,311,312,312,312,313,313,314,315,315,315,315,316,317,317,317,317,\n317,317,318,319,320,320,320,321,321,321,322,322,322,323,323,323,323,323,323,323,324,325,326,326,326,327,327,328,329,329,329,330,331,332,333,333,334,334,335,336,336,336,336,336,336,336,336,337,338,338,\n338,339,339,339,340,341,342,342,342,342,342,343,343,344,344,344,345,346,347,347,348,348,348,349,350,351,351,351,352,352,353,353,353,353,354,355,356,357,358,358,358,359,359,360,361,361,362,363,364,364,\n364,364,365,366,366,367,368,368,368,368,369,370,371,371,371,372,373,374,374,374,375,376,377,378,379,379,379,379,379,379,380,380,380,381,381,382,383,383,383,383,383,383,383,383,384,385,386,386,387,387,\n387,388,389,389,390,390,390,391,391,391,391,391,392,393,393,394,395,396,396,396,397,398,398,398,399,400,400,401,402,402,403,403,404,405,406,406,406,407,408,408,409,409,410,411,411,412,412,412,413,414,\n415,416,417,417,417,417,418,419,419,419,419,419,420,420,421,421,422,423,423,423,423,423,423,424,424,424,424,424,424,424,425,426,427,427,428,428,429,430,430,430,430,431,432,433,434,434,435,436,437,437,\n438,438,438,438,438,439,439,439,439,439,439,440,440,441,442,443,444,444,445,445,446,447,448,448,449,449,449,450,451,451,451,451,451,451,451,452,452,452,453,453,454,455,456,456,457,458,458,459,460,460,\n461,461,461,462,463,463,463,464,465,465,465,465,466,467,467,468,469,469,469,469,470,471,472,472,473,474,475,476,476,476,477,478,479,480,480,480,480,480,481,481,481,481,482,483,483,483,483,483,484,484,\n485,485,485,485,486,487,487,488,489,489,489,489,490,491,492,492,492,493,493,493,493,494,495,496,496,497,497,497,498,498,499,500,500,500,501,501,501,501,502,502,502,503,504,504,505,505,505,506,507,508,\n508,508,509,510,510,511,512,512,512,512,513,513,513,513,513,514,515,516,516,516,516,516,516,516,517,517,518,519,520,520,520,520,520,520,520,520,521,521,521,521,522,523,524,524,524,525,526,527,527,527,\n527,528,529,529,530,530,531,532,533,533,533,533,533,533,533,533,534,534,534,534,534,535,536,536,537,538,539,539,540,540,541,542,543,544,544,544,544,545,546,546,546,546,546,547,547,548,548,548,549,549,\n550,550,550,550,550,550,551,552,552,552,553,554,554,555,556,556,556,556,557,557,558,558,558,559,560,561,562,562,562,562,562,563,564,564,565,566,567,568,569,569,570,571,572,572,573,573,574,574,575,575,\n575,576,576,577,577,578,579,579,580,580,581,581,581,581,582,582,583,584,585,585,585,586,586,587,588,588,589,589,590,590,590,590,591,592,592,593,593,593,594,594,595,596,596,596,597,597,597,598,599,599,\n599,600,601,601,602,602,603,604,604,604,605,605,605,606,607,608,608,608,609,609,609,609,609,609,610,611,612,613,613,613,613,613,614,615,615,615,615,616,616,616,617,617,618,619,619,619,620,620,620,621,\n622,623,624,624,625,626,627,627,627,627,628,629,630,631,631,631,632,633,634,634,635,635,636,636,636,636,636,636,636,637,637,638,638,638,639,640,640,640,640,640,640,640,641,642,642,643,643,643,644,644,\n644,644,644,645,645,646,646,646,646,646,646,647,648,648,649,649,650,651,651,651,651,652,653,654,655,655,655,656,657,657,657,657,658,658,658,659,660,660,661,661,662,662,663,663,664,665,666,667,668,668,\n669,670,670,671,672,672,673,673,674,674,674,674,675,675,675,676,676,676,676,676,677,678,678,678,679,680,681,681,682,682,682,683,684,685,686,686,687,688,689,689,690,690,691,691,691,692,693,693,693,693,\n694,695,696,696,697,697,697,698,698,698,699,700,701,701,702,702,703,704,704,704,705,705,705,706,706,706,706,706,706,706,707,708,708,708,708,709,710,711,711,711,712,712,712,713,714,714,714,715,715,715,\n715,715,715,716,716,716,717,718,718,718,719,719,719,719,720,721,722,723,724,724,724,725,726,726,727,727,728,729,729,729,729,729,729,729,729,730,730,730,730,730,730,731,731,731,731,731,732,732,732,732,\n733,734,735,736,736,736,737,737,738,738,738,738,739,740,740,741,742,742,743,743,744,745,745,745,746,746,747,748,749,749,749,750,750,750,751,752,753,754,755,755,756,756,756,757,757,758,758,758,758,758,\n758,759,759,759,760,761,762,762,762,762,763,763,764,764,765,765,765,766,767,767,767,767,768,769,769,770,771,771,771,771,771,771,771,771,772,772,773,774,775,775,776,777,778,779,779,779,779,779,779,780,\n780,780,781,782,782,782,782,782,782,782,783,783,783,783,783,784,784,785,785,785,785,786,787,787,788,788,788,788,789,789,790,790,791,791,791,792,792,792,793,793,794,795,796,796,796,797,798,799,800,800,\n801,801,801,802,803,803,803,804,804,804,805,805,805,806,806,806,806,806,806,806,807,807,808,808,809,810,810,811,812,812,812,813,813,814,815,815,816,817,818,818,819,819,819,819,819,820,820,820,820,820,\n821,821,822,822,822,823,824,824,824,824,825,826,827,828,829,829,830,831,832,832,832,832,832,833,833,834,835,836,836,836,837,838,838,838,839,839,840,840,841,841,841,841,841,842,843,843,843,843,843,843,\n844,844,844,845,845,846,847,847,847,847,848,849,850,850,851,852,852,852,853,853,853,854,855,856,857,857,857,857,858,858,859,859,859,860,860,860,860,860,860,860,861,862,863,863,864,865,866,866,867,867,\n867,867,868,868,869,869,870,871,872,872,872,872,873,874,874,875,876,876,877,877,878,879,879,879,880,880,880,881,882,882,882,883,883,883,884,884,885,886,887,887,888,888,889,890,890,890,890,890,890,890,\n891,892,893,893,893,894,895,896,897,897,897,897,898,899,900,900,900,901,901,901,901,901,901,902,903,903,903,903,903,903,903,904,905,905,905,905,905,906,906,906,907,907,908,909,910,910,911,911,912,912,\n912,912,913,913,913,914,914,914,915,915,915,916,916,916,917,918,919,919,920,920,921,922,923,923,923,923,924,925,926,926,926,926,926,927,927,928,929,929,930,930,931,932,933,934,935,935,935,936,936,936,\n936,937,937,938,938,938,939,939,940,940,941,941,942,943,943,944,945,945,946,946,947,947,947,947,948,948,949,949,949,949,950,951,952,953,954,954,954,954,954,954,955,955,955,956,956,957,957,957,957,958,\n958,958,958,958,959,959,960,961,962,962,962,963,963,963,963,963,963,964,965,965,966,966,967,967,968,969,969,969,969,969,970,971,972,972,972,973,973,974,974,974,975,976,977,977,978,978,979,979,980,980,\n981,981,981,981,981,982,983,983,984,984,985,986,986,986,986,987,987,987,987,987,988,988,989,989,990,990,991,992,992,992,992,992,992,993,993,993,993,993,993,993,993,994,994,994,995,996,997,998,998,998,\n999,1000,1001,1002,1003,1003,1004,1004,1004,1004,1004,1004,1004,1004,1004,1005,1006,1006,1007,1007,1007,1008,1009,1009,1010,1011,1012,1012,1012,1012,1012,1012,1013,1013,1013,1013,1013,1014,1014,1014,1014,1014,1014,1015,1015,1015,1016,1016,1017,1017,\n1018,1019,1019,1019,1020,1020,1021,1021,1022,1022,1022,1022,1022,1023,1024,1024,1025,1026,1027,1027,1028,1028,1029,1030,1030,1031,1032,1032,1032,1032,1033,1034,1035,1035,1035,1036,1036,1037,1038,1038,1039,1040,1040,1041,1042,1042,1042,1042,1043,1043,\n1044,1044,1044,1044,1044,1045,1045,1045,1045,1045,1045,1045,1045,1045,1046,1047,1048,1049,1050,1050,1050,1050,1050,1051,1052,1052,1053,1054,1055,1055,1056,1056,1056,1057,1057,1057,1057,1057,1057,1057,1058,1058,1058,1058,1059,1060,1060,1061,1062,1062,\n1062,1063,1064,1064,1064,1064,1065,1066,1067,1067,1067,1067,1068,1069,1069,1069,1069,1069,1069,1069,1070,1071,1071,1071,1071,1072,1072,1072,1073,1073,1073,1073,1074,1075,1076,1076,1076,1076,1076,1076,1077,1077,1077,1077,1077,1077,1077,1077,1078,1078,\n1078,1079,1080,1081,1082,1083,1084,1085,1085,1085,1085,1086,1087,1087,1088,1088,1089,1089,1090,1090,1091,1091,1092,1092,1092,1093,1094,1094,1095,1095,1095,1095,1095,1095,1096,1097,1097,1097,1097,1097,1097,1098,1098,1099,1099,1099,1099,1100,1101,1101,\n1101,1101,1102,1102,1102,1102,1102,1102,1103,1103,1104,1105,1106,1106,1106,1106,1107,1108,1109,1109,1109,1110,1110,1111,1112,1112,1112,1112,1112,1112,1112,1112,1112,1113,1113,1114,1114,1114,1114,1114,1115,1115,1115,1115,1116,1117,1117,1117,1117,1117,\n1117,1118,1119,1120,1120,1120,1121,1121,1121,1121,1121,1121,1122,1122,1122,1123,1123,1123,1124,1124,1125,1125,1125,1125,1126,1127,1128,1129,1130,1130,1130,1131,1132,1133,1134,1134,1134,1134,1135,1135,1135,1135,1136,1136,1136,1137,1137,1137,1138,1138,\n1138,1139,1140,1140,1141,1142,1142,1143,1143,1143,1144,1145,1146,1146,1146,1146,1146,1147,1148,1148,1149,1149,1149,1150,1150,1151,1151,1151,1152,1152,1153,1153,1154,1154,1154,1154,1155,1156,1157,1157,1158,1158,1159,1159,1160,1160,1161,1162,1162,1163,\n1164,1164,1164,1165,1165,1165,1166,1166,1167,1167,1168,1169,1170,1170,1171,1171,1172,1173,1174,1174,1174,1174,1175,1176,1177,1177,1178,1179,1180,1180,1180,1180,1181,1181,1181,1182,1183,1183,1183,1183,1183,1183,1183,1183,1184,1184,1185,1185,1185,1185,\n1185,1185,1185,1186,1186,1186,1186,1187,1188,1189,1190,1190,1191,1192,1192,1193,1194,1194,1195,1195,1196,1197,1198,1198,1199,1199,1200,1201,1201,1201,1202,1203,1203,1203,1203,1203,1204,1205,1206,1206,1206,1207,1207,1208,1208,1208,1209,1209,1210,1210,\n1211,1212,1213,1213,1214,1215,1215,1216,1216,1216,1217,1218,1218,1219,1220,1220,1220,1220,1221,1221,1221,1221,1222,1223,1223,1223,1224,1224,1225,1225,1226,1226,1226,1226,1226,1227,1228,1229,1229,1229,1230,1231,1232,1233,1234,1234,1234,1235,1236,1236,\n1237,1237,1238,1239,1239,1240,1240,1240,1240,1240,1241,1242,1242,1242,1242,1242,1242,1242,1243,1243,1243,1244,1245,1245,1246,1246,1246,1246,1246,1246,1247,1247,1247,1247,1247,1247,1247,1247,1247,1247,1247,1248,1248,1248,1248,1249,1249,1249,1249,1249,\n1250,1250,1250,1251,1252,1252,1252,1253,1253,1253,1253,1253,1253,1253,1253,1253,1253,1253,1253,1253,1254,1255,1256,1256,1257,1257,1258,1258,1258,1258,1258,1259,1260,1261,1262,1262,1262,1263,1263,1263,1263,1263,1264,1265,1265,1266,1267,1267,1267,1267,\n1267,1268,1268,1268,1268,1268,1269,1269,1270,1270,1271,1272,1273,1274,1274,1274,1274,1275,1275,1275,1276,1276,1277,1277,1277,1278,1278,1278,1279,1279,1280,1280,1281,1281,1282,1282,1283,1283,1283,1283,1283,1284,1284,1284,1284,1284,1284,1285,1286,1286,\n1286,1286,1286,1287,1287,1287,1288,1288,1288,1288,1289,1289,1290,1290,1291,1292,1293,1294,1294,1294,1294,1294,1295,1296,1297,1297,1298,1298,1298,1298,1299,1299,1299,1299,1299,1300,1300,1300,1301,1301,1302,1302,1302,1302,1303,1304,1304,1305,1305,1305,\n1305,1305,1306,1307,1308,1308,1308,1309,1310,1310,1310,1310,1311,1312,1312,1313,1314,1314,1315,1315,1315,1316,1317,1317,1318,1319,1319,1320,1320,1320,1321,1321,1322,1322,1323,1323,1323,1324,1325,1325,1326,1326,1327,1328,1328,1329,1329,1329,1330,1330,\n1331,1332,1332,1332,1332,1333,1333,1334,1334,1334,1335,1335,1336,1336,1336,1337,1337,1338,1338,1338,1339,1339,1340,1340,1340,1340,1340,1340,1341,1341,1342,1343,1344,1344,1345,1346,1346,1346,1346,1346,1347,1348,1349,1350,1350,1350,1351,1351,1352,1352,\n1353,1353,1353,1353,1353,1354,1354,1354,1355,1355,1355,1356,1356,1356,1357,1358,1358,1358,1358,1358,1358,1359,1360,1361,1361,1361,1362,1363,1364,1364,1365,1365,1366,1367,1367,1368,1369,1369,1370,1370,1371,1371,1372,1372,1373,1373,1374,1375,1375,1375\n);\nvar\n n:longint;\nbegin\n read(n);\n writeln(a[n]);\nend.\n\n"}, {"source_code": "program a26;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar x,c,j,i,n,k:Integer;\nBegin\n readln (n);\n c:=0;\n for i := 1 to n do\n begin\n k:=0;\n x:=i;\n for j := 2 to i do\n if (x mod j = 0) then\n begin\n while (x mod j = 0) do\n x:=x div j;\n inc (k);\n end;\n If (k = 2) then\n inc(c);\n end;\n Writeln (c);\nEnd.\n"}, {"source_code": "program Project_a;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n kol, n, i: integer;\n\nfunction simple(x: integer): boolean;\nvar\n i: integer;\nbegin\n simple := true;\n for i := 2 to x - 1 do\n if x mod i = 0 then begin\n simple := false;\n exit;\n end;\nend;\n\nfunction almostsimple(x: integer): boolean;\nvar\n i, kol: integer;\nbegin\n kol := 0;\n for i := 2 to x do\n if (x mod i = 0) and (simple(i)) then\n inc(kol);\n if kol <> 2 then\n almostsimple := false\n else\n almostsimple := true;\nend;\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n);\n kol := 0;\n for i := 1 to n do\n if almostsimple(i) then\n inc(kol);\n write(kol);\nend.\n"}, {"source_code": "program t1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a:array[1..100000] of longint;\n n,i,j,k,g,r:longint;\n\n function prim(x:longint):boolean;\n var\n i:longint;\n begin\n prim:=true;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then begin prim:=false; exit; end;\n end;\n\nbegin\n read(n);\n r:=0;\n k:=0;\n for i:=2 to n do\n if prim(i) then begin inc(k); a[k]:=i; end;\n for i:=1 to n do\n begin\n g:=0;\n for j:=1 to k do\n if i mod a[j]=0 then inc(g);\n if g=2 then inc(r);\n end;\n writeln(r);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE GUI}\n{$WARN SYMBOL_DEPRECATED ON}\n{$WARN SYMBOL_LIBRARY ON}\n{$WARN SYMBOL_PLATFORM ON}\n{$WARN UNIT_LIBRARY ON}\n{$WARN UNIT_PLATFORM ON}\n{$WARN UNIT_DEPRECATED ON}\n{$WARN HRESULT_COMPAT ON}\n{$WARN HIDING_MEMBER ON}\n{$WARN HIDDEN_VIRTUAL ON}\n{$WARN GARBAGE ON}\n{$WARN BOUNDS_ERROR ON}\n{$WARN ZERO_NIL_COMPAT ON}\n{$WARN STRING_CONST_TRUNCED ON}\n{$WARN FOR_LOOP_VAR_VARPAR ON}\n{$WARN TYPED_CONST_VARPAR ON}\n{$WARN ASG_TO_TYPED_CONST ON}\n{$WARN CASE_LABEL_RANGE ON}\n{$WARN FOR_VARIABLE ON}\n{$WARN CONSTRUCTING_ABSTRACT ON}\n{$WARN COMPARISON_FALSE ON}\n{$WARN COMPARISON_TRUE ON}\n{$WARN COMPARING_SIGNED_UNSIGNED ON}\n{$WARN COMBINING_SIGNED_UNSIGNED ON}\n{$WARN UNSUPPORTED_CONSTRUCT ON}\n{$WARN FILE_OPEN ON}\n{$WARN FILE_OPEN_UNITSRC ON}\n{$WARN BAD_GLOBAL_SYMBOL ON}\n{$WARN DUPLICATE_CTOR_DTOR ON}\n{$WARN INVALID_DIRECTIVE ON}\n{$WARN PACKAGE_NO_LINK ON}\n{$WARN PACKAGED_THREADVAR ON}\n{$WARN IMPLICIT_IMPORT ON}\n{$WARN HPPEMIT_IGNORED ON}\n{$WARN NO_RETVAL ON}\n{$WARN USE_BEFORE_DEF ON}\n{$WARN FOR_LOOP_VAR_UNDEF ON}\n{$WARN UNIT_NAME_MISMATCH ON}\n{$WARN NO_CFG_FILE_FOUND ON}\n{$WARN MESSAGE_DIRECTIVE ON}\n{$WARN IMPLICIT_VARIANTS ON}\n{$WARN UNICODE_TO_LOCALE ON}\n{$WARN LOCALE_TO_UNICODE ON}\n{$WARN IMAGEBASE_MULTIPLE ON}\n{$WARN SUSPICIOUS_TYPECAST ON}\n{$WARN PRIVATE_PROPACCESSOR ON}\n{$WARN UNSAFE_TYPE ON}\n{$WARN UNSAFE_CODE ON}\n{$WARN UNSAFE_CAST ON}\nUses Math,SysUtils;\nVar I,K,T,N,J,mi,Nm,L:Integer;m:array[1..1000] of Integer;f:boolean;\nBegin\n ///reset(input,'Input.txt');\n ///assign(output,'Output.txt');\n K:=3;\n m[1]:=2;\n m[2]:=3;\n m[3]:=5;\n J:=5;\n While J<1500 do\n begin\n Inc(J,2);\n L:=Round(sqrt(J))+1;\n f:=true;\n T:=1;\n While (T<=K) and (m[T]<=L) do\n begin\n If J mod m[T]=0\n then begin\n f:=false;\n Break;\n end;\n Inc(T);\n end;\n If f\n then begin\n Inc(K);\n m[K]:=J;\n end;\n end;\n readln(N);\n L:=0;\n For I:=1 to N do\n begin\n T:=0;\n J:=1;\n While (m[J] 0 then Inc(a);\n end;\n end;\n if a=2 then inc(rez);\n end;\nWrite(rez);\nend."}, {"source_code": "var n,i,j,m,tg:word; a:array[2..3000] of boolean;\nbegin\n read(n);\n fillchar(a,(n-1)*sizeof(boolean),true);\n for i:=2 to n shr 1 do\n if a[i] then\n for j:=2 to n div i do a[i*j]:=false;\n m:=0;\n for i:=6 to n do\n if not a[i] then\n begin\n tg:=i; j:=1;\n repeat inc(j)\n until a[j] and (tg mod j=0);\n repeat tg:=tg div j\n until tg mod j>0;\n if tg>1 then\n begin\n repeat inc(j)\n until a[j] and (tg mod j=0);\n repeat tg:=tg div j\n until tg mod j>0;\n if tg=1 then inc(m)\n end\n end;\n write(m)\nend."}, {"source_code": "program sieve_of_eratosthenes;\nconst max=46348; //max input. lebih dari ini runtime error 215\nvar n,i,j,k,l,count,counter:longint;\nprime:array[2..max] of boolean;\n\nbegin\nfor k:=2 to 3000 do prime[k]:=true;\ni:=2;\nwhile i<=3000 do\n begin\n if prime[i] then\n begin\n j:=i;\n while i*j<=3000 do\n begin\n prime[i*j]:=false;\n inc(j);\n end;\n end;\n inc(i);\n end;\nreadln(n);\nfor l:=2 to n do\n begin\n count:=0;\n for k:=2 to n do if (prime[k] and (l mod k =0)) then inc(count);\n if count=2 then inc(counter);\n end;\nwriteln(counter);\nend.\n"}, {"source_code": "var\n a, b, c, i, j, d, e, d1, t: int64;\n q, q1: boolean;\n arr: array [1..1000] of int64;\n \nbegin\n readln(a);\n i := 2;\n c := 0;\n while i <= a do begin\n j := 2;\n b := 0;\n while j * j <= i do begin\n if i mod j = 0 then begin\n inc(b);\n arr[b] := j;\n if j * j <> i then begin\n inc(b);\n arr[b] := i div j;\n end;\n end;\n inc(j);\n end;\n t := 1;\n d := 0;\n while t <= b do begin \n j := 2;\n q := true;\n while j * j <= arr[t] do begin\n if arr[t] mod j = 0 then q := false;\n if not(q) then break;\n inc(j);\n end;\n if q then inc(d);\n inc(t);\n end;\n if d = 2 then inc(c);\n inc(i);\n end;\n writeln(c);\nend. "}, {"source_code": "var\n dau:array[0..3000] of boolean;\n nt:array[0..3000] of longint;\n n,k,kq,i,j,m,x:longint;\nfunction check(x:longint):boolean;\nvar\n i:longint;\nbegin\n check:=true;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\nend;\nbegin\n readln(n);\n k:=0;\n for i:=2 to n do\n if check(i)=true then\n begin\n inc(k);\n nt[k]:=i;\n end;\n kq:=0;\n for i:=1 to n do\n begin\n m:=0;\n for j:=1 to k do\n begin\n if i mod nt[j]=0 then inc(m);\n if m>2 then break;\n end;\n if m=2 then inc(kq);\n end;\n writeln(kq);\nend.\n"}, {"source_code": "program _26A;\nvar\n a : array[1..3000] of longint;\n n, i, j : longint;\nbegin\n read(n);\n a[1] := 1;\n for i := 2 to n div 2 do\n if a[i] = 0\n then begin\n j := i + i;\n while j <= n do\n begin\n inc(a[j], 1);\n inc(j, i);\n end;\n end;\n j := 0;\n for i := 1 to n do\n if a[i] = 2\n then inc(j);\n write(j); \nend."}, {"source_code": " var k,i,n:word;\nfunction isprime(x:word):boolean;\n var j,kd:word;\n begin\n kd:=0;\n j:=2;\n while x>1 do\n begin\n if x mod j = 0 then\n begin\n while x mod j = 0 do\n x:=x div j;\n inc(kd);\n end;\n inc(j);\n end;\n if kd=2 then isprime:=true\n else isprime:=false;\n end;\nBEGIN\n k:=0;\n read(n);\n for i:=1 to n do\n if isprime(i) then\n inc(k);\n write(k);\nEND."}, {"source_code": "var\n n,i,res:integer;\nfunction check(x:integer):integer;\nvar\n j,k,count,d:integer;\n a:array[1..3000] of integer;\nbegin\n fillchar(a,sizeof(a),0);\n k:=2; count:=0; d:=x;\n while x<>1 do\n begin\n if x mod k=0 then\n begin\n inc(a[k]);\n x:=x div k;\n end\n else inc(k);\n end;\n for j:=1 to d-1 do\n if a[j]>0 then inc(count);\n exit(count);\nend;\nbegin\n readln(n);\n for i:=5 to n do\n if check(i)=2 then inc(res);\n writeln(res);\nend."}, {"source_code": "var n, res, index: longint;\nfunction CHECK_SIMPLE(almost_simple: longint): boolean;\nvar i,kol_d,middle: longint;\n begin\n middle:=(almost_simple div 2)+1;\n i:=1; kol_d:=0;\n while ((i <= middle) and (kol_d < 3)) do\n begin\n inc(i);\n if almost_simple mod i=0 then\n begin\n while almost_simple mod i=0 do\n almost_simple:=almost_simple div i;\n inc(kol_d);\n end;\n end;\n if kol_d=2 then CHECK_SIMPLE:=TRUE\n else CHECK_SIMPLE:=FALSE;\n end;\nbegin\n res:=0;\n read(n);\n for index:=6 to n do if CHECK_SIMPLE(index) then inc(res);\n write(res);\nend.\n"}, {"source_code": "var\n a : array[1..2000] of longint;\n nt : array[1..3000] of boolean;\n n , m , kq : longint;\nprocedure sang( x : longint );\nvar\n i , j : longint;\nbegin\n fillchar( nt , sizeof( nt ) , true );\n nt[ 1 ] := false;\n for i := 2 to trunc( sqrt( n ) ) do\n begin\n j := i * i;\n while j <= n do\n begin\n nt[ j ] := false;\n j := j + i;\n end;\n end;\n m := 0;\n for i := 2 to n do\n if nt[ i ] then\n begin\n inc( m );\n a[ m ] := i;\n end;\n a[ m + 1 ] := maxlongint;\nend;\nprocedure xuli;\nvar\n i , j , dem : longint;\nbegin\n read( n );\n sang( n );\n kq := 0;\n for i := 6 to n do\n if nt[ i ] = false then\n begin\n j := 1;\n dem := 0;\n while a[ j ] <= i do\n begin\n if i mod a[ j ] = 0 then inc( dem );\n inc( j );\n if dem > 2 then break;\n end;\n if dem = 2 then inc( kq );\n end;\n write( kq );\nend;\nbegin\n xuli;\nend."}, {"source_code": "var n, i, k, t, m: integer;\n j: longint;\n p: array [1..239] of integer;\n q: array [2..1499] of boolean;\nbegin\n readln(n);\n k := 0;\n for i := 2 to n div 2 do\n begin\n if q[i] then continue;\n inc(k);\n p[k] := i;\n j := sqr(longint(i));\n while j <= n div 2 do\n begin\n q[j] := true;\n inc(j, i);\n end;\n end;\n t := 0;\n for i := 1 to n do\n begin\n m := 0;\n for j := 1 to k do\n if i mod p[j] = 0 then\n inc(m);\n if m = 2 then\n inc(t);\n end;\n writeln(t);\nend."}, {"source_code": "//tt1\nconst fi = 'almostprime.inp';\n fo = 'almostprime.out';\n\nvar n,i,dem,j,res : integer;\n\nfunction ktnt(n:integer) : boolean;\nvar i : integer;\nbegin\n if n = 1 then exit(false);\n if n < 4 then exit(true);\n for i := 2 to trunc(sqrt(n)) do\n if n mod i = 0 then exit(false);\n exit(true);\nend;\n\nBEGIN\n //assign(input,fi); reset(input);\n //assign(output,fo); rewrite(output);\n read(n); res := 0;\n for i := 6 to n do\n begin\n dem := 0;\n for j := 2 to i do\n if (i mod j = 0) and (ktnt(j)) then inc(dem);\n if dem = 2 then inc(res);\n end;\n write(res);\n //close(input); close(output);\nEND."}, {"source_code": "var n,i,k,s,j:integer;\n b:boolean;\nprocedure ex(j:integer; var b:boolean);\nvar i,k:integer;\nbegin\nfor i:=1 to j do\n if j mod i=0 then inc(k);\nif k=2 then b:=true;\nend;\nbegin\nreadln(n);\nfor i:=4 to n do begin\n k:=0;\n for j:=2 to i-1 do begin\n b:=false;\n if i mod j=0 then ex(j,b);\n if b=true then inc(k);\n end;\nif k=2 then inc(s);\nend;\nwriteln(s);\nend."}, {"source_code": " {$APPTYPE CONSOLE}\n var n,i,j,k,ans:integer;\n del:array[0..3000] of integer;\n begin\n readln(n);\n ans:=0;\n for i:=1 to n do\n begin\n del[i]:=0; k:=0;\n for j:=1 to i do\n if i mod j=0 then\n begin\n inc(del[i]);\n if del[j]=2 then inc(k);\n end;\n if k=2 then inc(ans);\n end;\n writeln(ans);\n end."}, {"source_code": "uses math;\ntype mass=array[0..3000] of integer;\nvar d,n,sum,res,p,kol,q,l1,x,y,r1,q1,q2,k,uk,min1,e,e1,kolv,r,l,b,c,max1:int64;s,s1,s2,s3:string;i:integer;\n m:mass;ch,ww:char;u:boolean;qq,w,g,a:int64;v,j,z:integer;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n);\n a:=1;\n m[1]:=2;\n for i:=3 to n do\n Begin\n u:=true;\n for z:=2 to i-1 do\n if i mod z=0\n then Begin\n u:=false;\n break;\n end;\n if u\n then Begin\n inc(a);\n m[a]:=i;\n end;\n end;\n b:=0;\n for i:=6 to n do\n Begin\n c:=i;\n z:=1;\n k:=0;\n while c>1 do\n Begin\n while (z<=a) and (c mod m[z]>0) do\n inc(z);\n if z>a\n then break;\n while (c>1) and (c mod m[z]=0) do\n c:=c div m[z];\n inc(k);\n if k>2\n then break;\n end;\n if k=2\n then inc(b);\n end;\n writeln(b);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar n,i,j,c,count: longint;\n a: array[2..5000]of boolean;\n\nfunction prost(x: LongInt): Boolean;\nvar i: longint;\nbegin\n Result := true;\n for i:=2 to round(sqrt(x)) do\n if (x mod i=0) then begin\n Result := false;\n Break;\n end;\nend;\n\nbegin\n read(n);\n for i:=2 to 4000 do a[i] := True;\n for i:=2 to n do begin\n if (a[i] = False) then Continue;\n j := i;\n while (j + i<=4000) do begin\n j := j + i;\n a[j] := false;\n end;\n end;\n c := 0;\n for i:=6 to n do begin\n count := 0;\n for j := 2 to (i - 1) do\n if ((a[j] = true) and (i mod j=0)) then Inc(count);\n if (count = 2) then inc(c);\n end;\n Writeln(c);\nend.\n"}, {"source_code": "Var t, n, res : integer;\n\nFunction Check(x : integer) : boolean;\nVar i, count : integer;\nBegin\n i := 1;\n count := 0;\n Repeat\n Repeat inc(i) Until x mod i = 0;\n inc(count);\n If count > 2 then break;\n Repeat x := x div i Until (x = 0) or (x mod i <> 0);\n Until x = 1;\n If count = 2 then Check := true else Check := false;\nEnd;\n\nBEGIN\n readln(n);\n res := 0;\n For t := 2 to n do\n If Check(t) then inc(res);\n writeln(res);\nEND."}, {"source_code": "{$O-}\nprogram Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n res, cur, i, j, n: integer;\n b: array[1..3000] of boolean;\n \nfunction isPrime(i: integer): boolean;\nvar\n j: integer;\nbegin\n j := 2;\n while (j * j <= i) do begin\n if i mod j = 0 then begin\n result := false;\n exit;\n end;\n inc(j);\n end;\n result := true;\nend;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n read(n);\n for i := 2 to n do begin\n b[i] := isPrime(i);\n end;\n for i := 2 to n do begin\n j := 2;\n cur := 0;\n while (j * j <= i) do begin\n if i mod j = 0 then begin\n if b[i div j] then begin\n inc(cur);\n end;\n if b[j] and (i div j <> j) then begin\n inc(cur);\n end;\n end;\n inc(j);\n end;\n if cur = 2 then begin\n inc(res);\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n{$R+ Q+ I+}\n\nuses\n SysUtils;\n\nvar\n i,n,j,ans,t: integer;\n p: array[1..3000]of integer;\nbegin\n read(n);\n for i:=2 to n do begin\n if p[i]=0 then Begin\n for j:=1 to n do begin\n if i*j>n then break;\n if p[i*j]=0 then p[i*j]:=i;\n end;\n end;\n end;\n t:=0;\n for i:=1 to n do begin\n ans:=0;\n for j:=1 to i do\n if (i mod j=0) and (p[j]=j) then inc(ans);\n if ans=2 then inc(t);\n end;\n write(t);\nend.\n"}, {"source_code": "program Project26A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, x, i, j, k: Integer;\n\nfunction prostoe(n: Integer): Boolean;\n\nvar\n i: Integer;\n\nbegin\n Result := True;\n for i := 2 to n - 1 do begin\n if n mod i = 0 then Result := False;\n end;\nend;\n\nbegin\n k := 0;\n Readln(n);\n for i := 2 to n do begin\n x := 0;\n for j := 2 to i do begin\n if (i mod j = 0) and (prostoe(j)) then\n Inc(x);\n end;\n if x = 2 then\n Inc(k);\n end;\n Writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nVar\n n,i,j,ind, ind2:integer;\n a:array[1..3014] of integer;\nbegin\n readln(n);\n ind:=0;\n ind2:=1;\n for i:= 2 to 27600 do\n begin\n for j:=2 to i-1 do\n begin\n if i mod j=0 then\n ind:=1;\n end;\n if ind=1 then\n begin\n ind:=0;\n end\n else\n begin\n ind:=0;\n a[ind2]:=i;\n ind2:=ind2+1;\n end;\n end;\n \n ind:=0;\n ind2:=0;\n for j:=3 to n do\n begin\n for i:= 1 to n div 2 do\n begin\n if j mod a[i]=0 then\n ind:=ind+1;\n end;\n if ind=2 then\n begin\n ind2:=ind2+1;\n end;\n ind:=0;\n end;\n writeln(ind2);\n readln;\nend.\n"}, {"source_code": "var\n del,ch,n,i,j,x,y,m,anss,met,z:longint;\n a:array[1..4000] of longint;\n ans:array[1..100000] of longint;\nbegin\n readln(n);\n for i:=2 to 4000 do\n begin\n j:=i+i;\n if (a[i]=0) then begin\n while (j<=n) do\n begin\n a[j]:=1;\n j:=j+i;\n end;\n end;\n end;\n for i:=1 to 4000 do\n begin\n if (a[i]=0) then begin\n inc(m);\n ans[m]:=i;\n end;\n end;\n for i:=6 to n do\n begin\n j:=2;\n ch:=i;\n del:=0;\n met:=0;\n while (ch mod 2)=0 do\n begin\n ch:=ch div 2;\n inc(del);\n end;\n if (del>1) then del:=1;\n for j:=3 to m do\n begin\n if (ch mod ans[j])=0 then begin\n inc(del);\n ch:=ch div ans[j];\n end;\n end;\n if (del=2) then inc(anss);\n end;\n writeln(anss);\nend."}, {"source_code": "var i,j,n,count,bil,tmp,cek:longint;\n\nbegin\n readln(n);\n for i:=2 to n do\n begin\n j:=2; bil:=i; cek:=0; tmp:=i;\n while (bil>1) do\n begin\n while (bil mod j=0) do\n bil:=bil div j;\n\n if (j=2) then inc(j)\n else\n inc(j,2);\n\n if (bil1 do\n if x mod k=0 then\n begin\n if x1<>k then k1:=k1+1;\n x1:=k;\n x:=x div k;\n end\n else k:=k+1;\n if k1=2 then ans:=ans+1;\n end;\n WriteLn(ans);\n end."}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..1375] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,33,34,35,36,38,39, \n40,44,45,46,48,50,51,52,54,55,56,57,58,62,63,65,68,69, \n72,74,75,76,77,80,82,85,86,87,88,91,92,93,94,95,96,98, \n99,100,104,106,108,111,112,115,116,117,118,119,122,123,124,129,133,134, \n135,136,141,142,143,144,145,146,147,148,152,153,155,158,159,160,161,162, \n164,166,171,172,175,176,177,178,183,184,185,187,188,189,192,194,196,200, \n201,202,203,205,206,207,208,209,212,213,214,215,216,217,218,219,221,224, \n225,226,232,235,236,237,242,244,245,247,248,249,250,253,254,259,261,262, \n265,267,268,272,274,275,278,279,284,287,288,291,292,295,296,297,298,299, \n301,302,303,304,305,309,314,316,319,320,321,323,324,325,326,327,328,329, \n332,333,334,335,338,339,341,344,346,351,352,355,356,358,362,363,365,368, \n369,371,375,376,377,381,382,384,386,387,388,391,392,393,394,395,398,400, \n403,404,405,407,411,412,413,415,416,417,422,423,424,425,427,428,432,436, \n437,441,445,446,447,448,451,452,453,454,458,459,464,466,469,471,472,473, \n475,477,478,481,482,484,485,486,488,489,493,496,497,500,501,502,505,507, \n508,511,513,514,515,517,519,524,526,527,531,533,535,536,537,538,539,542, \n543,544,545,548,549,551,553,554,556,559,562,565,566,567,568,573,575,576, \n578,579,581,583,584,586,589,591,592,596,597,603,604,605,608,611,614,621, \n622,623,626,628,629,632,633,634,635,637,639,640,648,649,652,655,656,657, \n662,664,667,668,669,671,674,675,676,679,681,685,686,687,688,689,692,694, \n695,697,698,699,703,704,706,707,711,712,713,716,717,718,721,722,723,724, \n725,731,734,736,737,745,746,747,749,752,753,755,758,763,764,766,767,768, \n771,772,775,776,778,779,781,783,784,785,788,789,791,793,794,796,799,800, \n801,802,803,807,808,813,815,817,818,824,831,832,833,835,837,838,842,843, \n844,845,847,848,849,851,856,862,864,865,866,867,869,871,872,873,875,878, \n879,886,889,891,892,893,895,896,898,899,901,904,905,908,909,913,914,916, \n917,921,922,923,925,926,927,928,931,932,933,934,939,943,944,949,951,955, \n956,958,959,963,964,965,968,972,973,974,976,979,981,982,985,989,992,993, \n995,998,999,1000,1003,1004,1006,1007,1011,1016,1017,1018,1025,1027,1028,1029,1037,1041, \n1042,1043,1046,1047,1048,1052,1053,1055,1057,1058,1059,1067,1072,1073,1075,1076,1077,1079, \n1081,1082,1083,1084,1088,1089,1094,1096,1099,1101,1107,1108,1111,1112,1114,1115,1119,1121, \n1124,1125,1126,1127,1132,1133,1135,1136,1137,1138,1139,1141,1142,1143,1145,1147,1149,1152, \n1154,1156,1157,1159,1161,1165,1167,1168,1169,1172,1174,1175,1177,1179,1183,1184,1186,1189, \n1191,1192,1195,1198,1199,1202,1203,1205,1207,1208,1211,1214,1215,1216,1219,1225,1226,1227, \n1228,1233,1234,1238,1241,1243,1244,1247,1250,1251,1252,1253,1255,1256,1257,1261,1262,1263, \n1264,1267,1268,1269,1271,1273,1280,1282,1285,1286,1293,1294,1296,1299,1304,1306,1312,1313, \n1315,1317,1318,1322,1323,1324,1325,1328,1329,1333,1336,1337,1339,1341,1343,1345,1346,1347, \n1348,1349,1351,1352,1354,1355,1357,1359,1363,1366,1371,1372,1375,1376,1377,1379,1382,1383, \n1384,1385,1387,1388,1389,1391,1393,1396,1397,1401,1402,1403,1405,1408,1411,1412,1413,1415, \n1417,1418,1421,1424,1431,1432,1436,1437,1438,1441,1444,1445,1448,1454,1457,1458,1461,1465, \n1466,1467,1468,1469,1472,1473,1475,1477,1478,1486,1492,1497,1501,1502,1503,1504,1507,1509, \n1513,1514,1516,1517,1519,1521,1522,1525,1527,1528,1529,1532,1535,1536,1537,1538,1539,1541, \n1544,1546,1552,1555,1556,1557,1561,1563,1565,1568,1569,1573,1574,1576,1577,1585,1587,1588, \n1589,1591,1592,1593,1594,1600,1603,1604,1611,1616,1618,1622,1623,1625,1629,1631,1633,1636, \n1639,1641,1642,1643,1646,1647,1648,1649,1651,1654,1655,1658,1661,1664,1671,1673,1675,1676, \n1678,1679,1682,1684,1685,1687,1688,1689,1691,1696,1701,1703,1706,1707,1711,1712,1713,1714, \n1715,1717,1718,1719,1724,1726,1727,1728,1731,1732,1735,1737,1739,1744,1745,1751,1754,1756, \n1757,1761,1762,1763,1765,1766,1769,1772,1773,1774,1775,1779,1781,1784,1791,1792,1793,1795, \n1796,1797,1799,1803,1805,1807,1808,1809,1813,1814,1816,1817,1819,1821,1822,1825,1828,1829, \n1832,1835,1837,1838,1839,1841,1843,1844,1851,1852,1853,1856,1857,1858,1859,1863,1864,1865, \n1868,1874,1875,1882,1883,1888,1891,1893,1894,1895,1897,1899,1903,1906,1909,1912,1915,1916, \n1917,1919,1921,1922,1923,1927,1928,1929,1934,1936,1937,1939,1941,1942,1943,1944,1945,1948, \n1952,1954,1957,1959,1961,1963,1964,1966,1967,1969,1971,1975,1977,1981,1982,1983,1984,1985, \n1991,1994,1996,2000,2005,2007,2008,2009,2012,2018,2019,2021,2023,2025,2026,2031,2032,2033, \n2036,2038,2041,2042,2043,2045,2047,2049,2051,2056,2057,2059,2061,2062,2066,2071,2073,2075, \n2077,2078,2084,2092,2095,2096,2097,2098,2101,2102,2103,2104,2105,2107,2116,2117,2119,2122, \n2123,2125,2126,2127,2133,2138,2144,2147,2149,2151,2152,2155,2157,2159,2164,2165,2167,2168, \n2169,2171,2173,2174,2176,2177,2181,2182,2183,2186,2188,2189,2191,2192,2194,2195,2199,2201, \n2206,2215,2216,2217,2218,2219,2224,2225,2227,2228,2229,2231,2234,2241,2245,2246,2248,2249, \n2252,2253,2257,2258,2259,2263,2264,2271,2272,2276,2279,2283,2284,2285,2291,2299,2302,2303, \n2304,2305,2306,2307,2308,2312,2313,2315,2317,2319,2321,2323,2326,2327,2329,2335,2336,2342, \n2344,2348,2349,2353,2359,2361,2362,2363,2367,2368,2369,2372,2374,2375,2384,2386,2391,2395, \n2396,2402,2403,2404,2407,2413,2416,2419,2421,2425,2426,2427,2428,2429,2432,2433,2434,2435, \n2439,2443,2446,2449,2452,2453,2455,2456,2458,2461,2462,2463,2468,2469,2471,2474,2476,2479, \n2481,2483,2487,2488,2489,2491,2493,2495,2497,2498,2500,2501,2504,2507,2509,2511,2512,2513, \n2515,2517,2518,2519,2523,2524,2525,2527,2528,2529,2533,2536,2537,2545,2547,2554,2558,2559, \n2560,2561,2563,2564,2566,2567,2569,2571,2572,2573,2575,2577,2578,2581,2582,2587,2588,2589, \n2592,2594,2597,2599,2601,2602,2603,2605,2606,2608,2611,2612,2614,2615,2619,2623,2624,2627, \n2629,2631,2636,2637,2638,2641,2642,2643,2644,2645,2648,2649,2651,2653,2654,2656,2661,2662, \n2669,2672,2673,2675,2681,2692,2696,2701,2704,2705,2708,2721,2722,2723,2725,2727,2732,2733, \n2734,2735,2738,2743,2744,2746,2747,2752,2757,2759,2761,2762,2763,2764,2768,2771,2773,2776, \n2779,2781,2783,2785,2787,2792,2798,2799,2804,2807,2811,2813,2815,2816,2817,2818,2823,2824, \n2825,2827,2831,2836,2839,2841,2845,2846,2848,2853,2854,2855,2858,2859,2863,2864,2866,2867, \n2869,2872,2873,2875,2876,2878,2881,2883,2885,2888,2889,2891,2893,2894,2896,2899,2901,2902, \n2906,2908,2911,2913,2916,2918,2921,2923,2929,2931,2932,2933,2935,2936,2941,2942,2943,2944, \n2947,2949,2951,2956,2959,2962,2965,2966,2972,2973,2974,2977,2978,2979,2981,2983,2984,2986, \n2987,2989,2991,2993,2995,2997,2998);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<6 then\n begin\n writeln(0);\n exit;\n end;\n if n>2998 then\n begin\n writeln(1375);\n exit;\n end;\n for i:=1 to 1375 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end\n else\n if a[i]>n then\n begin\n writeln(i-1);\n exit;\n end;\n end;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n a:array [1..3000] of longint;\n n,i,j,c,dem,dk,kq:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(n);\n close(input);\nend;\n\nprocedure taomang;\nbegin\n for i:=2 to n do\n begin\n dk:=0;\n for j:=2 to trunc(sqrt(i)) do\n if i mod j=0 then\n begin\n dk:=1; break;\n end;\n if dk=0 then\n begin\n inc(dem); a[dem]:=i;\n end;\n end;\nend;\n\nprocedure xuly;\nbegin\n for i:=6 to n do\n begin\n c:=0;\n for j:=1 to dem do\n begin\n if i mod a[j]=0 then inc(c);\n if c>2 then break;\n end;\n if c=2 then inc(kq);\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(kq);\n close(output);\nend;\n\nbegin\n doc;\n taomang;\n xuly;\n ghi;\nend."}, {"source_code": "const finp='';\n fout='';\n maxn=3001;\nvar a:array[0..maxn] of integer;\n n:integer;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,n);\n close(f);\nend;\nfunction PTTSNT(x:integer):boolean;\nvar i,m,dem:integer;\nbegin\n dem:=0; PTTSNT:=true; m:=x;\n for i:=2 to trunc(sqrt(m)) do\n if x mod i=0 then\n begin\n inc(dem);\n while x mod i=0 do x:=x div i;\n end;\n if x>1 then inc(dem);\n if dem<>2 then exit(false);\nend;\nfunction KQ:integer;\nvar i:integer;\n dem:integer;\nbegin\n dem:=0;\n for i:=6 to n do\n if PTTSNT(i) then inc(dem);\n KQ:=dem;\nend;\nprocedure Xuat;\nvar f:text;\nbegin\n assign(f,fout);\n rewrite(f);\n writeln(f,KQ);\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend."}, {"source_code": "var i,j,dem,m,tam:longint;\nFunction NT(k:longint):boolean;\nVar i:longint;\nbegin\nif k=1 then exit(false);\nfor i:=2 to trunc(sqrt(k)) do\nif k mod i = 0 then exit(false);\nexit(true);\nend;\nBegin\nreadln(m);tam:=0;\nFOR i:=2 to m do\nbegin dem:=0;\n for j:=2 to i do\n begin\n if ((i mod j =0) and (NT(j))) then inc(dem);\n if dem>2 then break;\n end;\n if dem=2 then inc(tam);\nend;\nwriteln(tam);\nEnd.\n"}, {"source_code": "var\n n,i,j,k,s:longint;\n a,b:array[0..3000] of longint;\n f:boolean;\nbegin\n readln(n);\n k:=0;\n for i:=2 to n div 2 do\n begin\n f:=false;\n for j:=1 to k do\n if i mod a[j]=0 then begin f:=true; break; end;\n if not f then begin\n inc(k);\n a[k]:=i;\n for j:=1 to n do\n if j mod i=0 then inc(b[j]);\n end;\n end;\n for i:=1 to n do\n if b[i]=2 then inc(s);\n writeln(s);\n end."}, {"source_code": "program PochtiProstieChisla;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..1375] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,33,34,35,36,38,39, \n40,44,45,46,48,50,51,52,54,55,56,57,58,62,63,65,68,69, \n72,74,75,76,77,80,82,85,86,87,88,91,92,93,94,95,96,98, \n99,100,104,106,108,111,112,115,116,117,118,119,122,123,124,129,133,134, \n135,136,141,142,143,144,145,146,147,148,152,153,155,158,159,160,161,162, \n164,166,171,172,175,176,177,178,183,184,185,187,188,189,192,194,196,200, \n201,202,203,205,206,207,208,209,212,213,214,215,216,217,218,219,221,224, \n225,226,232,235,236,237,242,244,245,247,248,249,250,253,254,259,261,262, \n265,267,268,272,274,275,278,279,284,287,288,291,292,295,296,297,298,299, \n301,302,303,304,305,309,314,316,319,320,321,323,324,325,326,327,328,329, \n332,333,334,335,338,339,341,344,346,351,352,355,356,358,362,363,365,368, \n369,371,375,376,377,381,382,384,386,387,388,391,392,393,394,395,398,400, \n403,404,405,407,411,412,413,415,416,417,422,423,424,425,427,428,432,436, \n437,441,445,446,447,448,451,452,453,454,458,459,464,466,469,471,472,473, \n475,477,478,481,482,484,485,486,488,489,493,496,497,500,501,502,505,507, \n508,511,513,514,515,517,519,524,526,527,531,533,535,536,537,538,539,542, \n543,544,545,548,549,551,553,554,556,559,562,565,566,567,568,573,575,576, \n578,579,581,583,584,586,589,591,592,596,597,603,604,605,608,611,614,621, \n622,623,626,628,629,632,633,634,635,637,639,640,648,649,652,655,656,657, \n662,664,667,668,669,671,674,675,676,679,681,685,686,687,688,689,692,694, \n695,697,698,699,703,704,706,707,711,712,713,716,717,718,721,722,723,724, \n725,731,734,736,737,745,746,747,749,752,753,755,758,763,764,766,767,768, \n771,772,775,776,778,779,781,783,784,785,788,789,791,793,794,796,799,800, \n801,802,803,807,808,813,815,817,818,824,831,832,833,835,837,838,842,843, \n844,845,847,848,849,851,856,862,864,865,866,867,869,871,872,873,875,878, \n879,886,889,891,892,893,895,896,898,899,901,904,905,908,909,913,914,916, \n917,921,922,923,925,926,927,928,931,932,933,934,939,943,944,949,951,955, \n956,958,959,963,964,965,968,972,973,974,976,979,981,982,985,989,992,993, \n995,998,999,1000,1003,1004,1006,1007,1011,1016,1017,1018,1025,1027,1028,1029,1037,1041, \n1042,1043,1046,1047,1048,1052,1053,1055,1057,1058,1059,1067,1072,1073,1075,1076,1077,1079, \n1081,1082,1083,1084,1088,1089,1094,1096,1099,1101,1107,1108,1111,1112,1114,1115,1119,1121, \n1124,1125,1126,1127,1132,1133,1135,1136,1137,1138,1139,1141,1142,1143,1145,1147,1149,1152, \n1154,1156,1157,1159,1161,1165,1167,1168,1169,1172,1174,1175,1177,1179,1183,1184,1186,1189, \n1191,1192,1195,1198,1199,1202,1203,1205,1207,1208,1211,1214,1215,1216,1219,1225,1226,1227, \n1228,1233,1234,1238,1241,1243,1244,1247,1250,1251,1252,1253,1255,1256,1257,1261,1262,1263, \n1264,1267,1268,1269,1271,1273,1280,1282,1285,1286,1293,1294,1296,1299,1304,1306,1312,1313, \n1315,1317,1318,1322,1323,1324,1325,1328,1329,1333,1336,1337,1339,1341,1343,1345,1346,1347, \n1348,1349,1351,1352,1354,1355,1357,1359,1363,1366,1371,1372,1375,1376,1377,1379,1382,1383, \n1384,1385,1387,1388,1389,1391,1393,1396,1397,1401,1402,1403,1405,1408,1411,1412,1413,1415, \n1417,1418,1421,1424,1431,1432,1436,1437,1438,1441,1444,1445,1448,1454,1457,1458,1461,1465, \n1466,1467,1468,1469,1472,1473,1475,1477,1478,1486,1492,1497,1501,1502,1503,1504,1507,1509, \n1513,1514,1516,1517,1519,1521,1522,1525,1527,1528,1529,1532,1535,1536,1537,1538,1539,1541, \n1544,1546,1552,1555,1556,1557,1561,1563,1565,1568,1569,1573,1574,1576,1577,1585,1587,1588, \n1589,1591,1592,1593,1594,1600,1603,1604,1611,1616,1618,1622,1623,1625,1629,1631,1633,1636, \n1639,1641,1642,1643,1646,1647,1648,1649,1651,1654,1655,1658,1661,1664,1671,1673,1675,1676, \n1678,1679,1682,1684,1685,1687,1688,1689,1691,1696,1701,1703,1706,1707,1711,1712,1713,1714, \n1715,1717,1718,1719,1724,1726,1727,1728,1731,1732,1735,1737,1739,1744,1745,1751,1754,1756, \n1757,1761,1762,1763,1765,1766,1769,1772,1773,1774,1775,1779,1781,1784,1791,1792,1793,1795, \n1796,1797,1799,1803,1805,1807,1808,1809,1813,1814,1816,1817,1819,1821,1822,1825,1828,1829, \n1832,1835,1837,1838,1839,1841,1843,1844,1851,1852,1853,1856,1857,1858,1859,1863,1864,1865, \n1868,1874,1875,1882,1883,1888,1891,1893,1894,1895,1897,1899,1903,1906,1909,1912,1915,1916, \n1917,1919,1921,1922,1923,1927,1928,1929,1934,1936,1937,1939,1941,1942,1943,1944,1945,1948, \n1952,1954,1957,1959,1961,1963,1964,1966,1967,1969,1971,1975,1977,1981,1982,1983,1984,1985, \n1991,1994,1996,2000,2005,2007,2008,2009,2012,2018,2019,2021,2023,2025,2026,2031,2032,2033, \n2036,2038,2041,2042,2043,2045,2047,2049,2051,2056,2057,2059,2061,2062,2066,2071,2073,2075, \n2077,2078,2084,2092,2095,2096,2097,2098,2101,2102,2103,2104,2105,2107,2116,2117,2119,2122, \n2123,2125,2126,2127,2133,2138,2144,2147,2149,2151,2152,2155,2157,2159,2164,2165,2167,2168, \n2169,2171,2173,2174,2176,2177,2181,2182,2183,2186,2188,2189,2191,2192,2194,2195,2199,2201, \n2206,2215,2216,2217,2218,2219,2224,2225,2227,2228,2229,2231,2234,2241,2245,2246,2248,2249, \n2252,2253,2257,2258,2259,2263,2264,2271,2272,2276,2279,2283,2284,2285,2291,2299,2302,2303, \n2304,2305,2306,2307,2308,2312,2313,2315,2317,2319,2321,2323,2326,2327,2329,2335,2336,2342, \n2344,2348,2349,2353,2359,2361,2362,2363,2367,2368,2369,2372,2374,2375,2384,2386,2391,2395, \n2396,2402,2403,2404,2407,2413,2416,2419,2421,2425,2426,2427,2428,2429,2432,2433,2434,2435, \n2439,2443,2446,2449,2452,2453,2455,2456,2458,2461,2462,2463,2468,2469,2471,2474,2476,2479, \n2481,2483,2487,2488,2489,2491,2493,2495,2497,2498,2500,2501,2504,2507,2509,2511,2512,2513, \n2515,2517,2518,2519,2523,2524,2525,2527,2528,2529,2533,2536,2537,2545,2547,2554,2558,2559, \n2560,2561,2563,2564,2566,2567,2569,2571,2572,2573,2575,2577,2578,2581,2582,2587,2588,2589, \n2592,2594,2597,2599,2601,2602,2603,2605,2606,2608,2611,2612,2614,2615,2619,2623,2624,2627, \n2629,2631,2636,2637,2638,2641,2642,2643,2644,2645,2648,2649,2651,2653,2654,2656,2661,2662, \n2669,2672,2673,2675,2681,2692,2696,2701,2704,2705,2708,2721,2722,2723,2725,2727,2732,2733, \n2734,2735,2738,2743,2744,2746,2747,2752,2757,2759,2761,2762,2763,2764,2768,2771,2773,2776, \n2779,2781,2783,2785,2787,2792,2798,2799,2804,2807,2811,2813,2815,2816,2817,2818,2823,2824, \n2825,2827,2831,2836,2839,2841,2845,2846,2848,2853,2854,2855,2858,2859,2863,2864,2866,2867, \n2869,2872,2873,2875,2876,2878,2881,2883,2885,2888,2889,2891,2893,2894,2896,2899,2901,2902, \n2906,2908,2911,2913,2916,2918,2921,2923,2929,2931,2932,2933,2935,2936,2941,2942,2943,2944, \n2947,2949,2951,2956,2959,2962,2965,2966,2972,2973,2974,2977,2978,2979,2981,2983,2984,2986, \n2987,2989,2991,2993,2995,2997,2998);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<6 then\n begin\n writeln(0);\n exit;\n end;\n if n>2998 then\n begin\n writeln('1375');\n exit;\n end;\n for i:=1 to 1375 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end\n else\n if a[i]>n then\n begin\n writeln(i-1);\n exit;\n end;\n end;\nend."}, {"source_code": "{$apptype console}\n{$O-}\n\nvar\n c, i, j, n, ans: integer;\n\nfunction simple(x: integer): boolean;\nvar i: integer;\nbegin\n simple := false;\n for i := 2 to x - 1 do\n if x mod i = 0 then\n exit;\n simple := true;\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n ans := 0;\n read(n);\n for i := 1 to n do begin\n c := 0;\n for j := 2 to i do\n if (i mod j = 0) and (simple(j)) then\n inc(c);\n if c = 2 then inc(ans);\n end;\n write(ans);\nend.\n\n"}, {"source_code": " var i,n,k,z,kol,j:longint;\nbegin\n readln(n);\n k:=0;\n for i:=6 to n do begin\n z:=i;\n kol:=0;\n for j:=2 to (i-1) do\n if z mod j = 0 then begin\n inc(kol);\n while z mod j = 0 do\n z:=z div j;\n if kol>2 then break;\n if z=1 then break;\n end;\n if kol=2 then\n inc(k);\n end;\n writeln(k);\nend."}, {"source_code": "var\n c, f, q, l, n, i, j, s, t, m, k: longint;\n a: array[0..10000] of longint;\n\nprocedure solve;\nvar k: longint;\nbegin\n k := 1;\n while (a[k] < l) and (a[k] <> 0) do begin\n if l mod a[k] = 0 then begin\n inc(c);\n end;\n inc(k);\n end;\n if c = 2 then\n inc(s);\nend;\n\n\nbegin\n read(n);\n for i := 1 to n do begin\n q := round(sqrt(i));\n for j := 1 to q do\n if i mod j = 0 then\n inc(c);\n if (c = 1) and (i <> 1) then begin\n inc(t);\n a[t] := i;\n end;\n c := 0;\n end;\n for l := 1 to n do begin\n solve;\n c := 0;\n end;\n write(s);\nend."}, {"source_code": "var\nn,j,i,kil,p,k,l,oz:longint;\n\n\n\nfunction pros(a:longint):longint;\nbegin\ni:=2; oz:=1;\n\nwhile (i<= sqrt(a)) and (oz=1) do\nif a mod i=0 then oz:=0 else i:=i+1;\nif (oz=1) and (i<>1) then pros:=1 else pros:=0;\nend;\n\nbegin\nreadln(n);\nkil:=0;\nfor j:=1 to n do\nbegin\nk:=0; p:=0;\nfor l:=2 to j-1 do\nif j mod l=0 then\n begin\n\n if pros(l)=1 then p:=p+1;\n if p>2 then break;\n end;\n\n if p=2 then kil:=kil+1;\n end;\n\n writeln(kil);\n end."}, {"source_code": "var n,i,j,dem : integer;\n a : array[1..3010] of integer;\n\n\nBEGIN\n readln(n);\n i := 2;\n fillchar(a,sizeof(a),0);\n a[2] := 1;\n while i <= n do begin\n j := i+i;\n while j <= n do begin\n inc(a[j]);\n j := j + i;\n end;\n inc(i);\n while a[i] <> 0 do inc(i);\n a[i] := 1;\n end;\n dem := 0;\n for i := 1 to n do\n if a[i] = 2 then inc(dem);\n writeln(dem);\nEND."}, {"source_code": "const mas:array[1..430] of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,\n101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,\n241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,\n409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,\n587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,\n757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,\n947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,\n1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,\n1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,\n1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,\n1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,\n1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,\n1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,\n2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,\n2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,\n2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,\n2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,\n2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,\n2957,2963,2969,2971,2999);\nvar a,b,c,d,code,max,k:longint;\ne,i,j,n,oz:longint;\nS,R,ima:string;\nf:boolean;\n\nprocedure diln(a:longint);\nbegin\nk:=0;\nc:=1;\nwhile mas[c]<=a div 2 do\nbegin\nif a mod mas[c]=0 then k:=k+1;\nc:=c+1;\nend;\nif k=2 then oz:=oz+1;\nend;\n\nbegin\n\nreadln(n);\n\nfor i:=1 to n do\nbegin\ndiln(i);\nend;\n\nwriteln(oz);\n\n\nend.\n"}, {"source_code": "var n,i,j,k,x:integer;\nfunction prime(y:integer):boolean;\nvar ans:boolean;\n i:integer;\nbegin\n ans:=true;\n for i:=2 to trunc(sqrt(y)) do\n if y mod i=0 then begin\n ans:=false;\n break;\n end;\n if y=2 then\n prime:=true\n else\n prime:=ans;\nend;\nbegin\n readln(n);\n x:=0;\n for i:=2 to n do begin\n k:=0;\n for j:=2 to (i div 2) do\n if prime(j)and(i mod j=0) then\n inc(k);\n if k=2 then\n inc(x);\n end;\n writeln(x);\n readln;\nend.\n"}, {"source_code": "function simple(a:longint):boolean;\nvar\np:boolean;\ni,t:longint;\nbegin\n\nt:=trunc(sqrt(a))+1;\np:=true;\nfor i:=2 to t do\n if a mod i=0 then\n begin\n p:=false;\n break;\n end;\nif (a=2) then p:=true;\nsimple:=p;\n\nend;\n\nvar\ns:array[1..1000] of longint;\n//t,p:array[1..3000] of boolean;\n\ni,j,n,k,num,ndel,del:longint;\nt:boolean;\nbegin\nreadln(n);\ns[1]:=2;\nj:=1;\n\nfor i:=3 to 3000 do\nif (i mod 2=1) then\n if simple(i) then\n begin\n inc(j);\n s[j]:=i;\n end;\n {\n for i:=1 to j-1 do\n for k:=i+1 to j do\n if s[i]*s[k]<=n then\n begin\n inc(num);\n writeln(s[i],' ',s[k]);\n end;\n }\n for k:=1 to n do\n begin\n i:=k;\n j:=1;\n del:=s[j];\n ndel:=0;\n t:=false;\n while i>1 do\n begin\n if i mod del=0 then\n if not t then\n begin\n t:=true;\n inc(ndel);\n i:=i div del;\n end\n else i:=i div del\n else\n begin\n inc(j);\n t:=false;\n del:=s[j];\n end;\n\n\n end;\n // writeln('k=',k,' ndel=',ndel);\n if ndel=2 then inc(num);\n\n\n end;\nwrite(num);\n end.\n\n\n\n\n\n\n\n\n"}, {"source_code": "var k,n,i:longint;\n\n function check(i:longint):boolean;\n var x:longint;\n begin\n for x:=2 to i do\n if i mod x=0 then\n begin\n while i mod x=0 do i:=i div x;\n break;\n end;\nif i=1 then exit(false);\nx:=2;\n for x:=2 to i do\n if i mod x=0 then\n begin\n while i mod x=0 do i:=i div x;\n if i=1 then exit(true) else exit(false);\n break;\n end;\nend;\n begin\n readln(N);\nfor i:=1 to n do\n if check(i) then inc(k);\nwriteln(k);\nend.\n"}, {"source_code": "var a:array [0..1000] of int64;\n i,j,n,m,h,ans,x,y,k:longint;\n s:string;\n t:real;\n begin\n\n readln(n);\n\n for i:=1 to n do\n begin\n x:=1;\n y:=i;\n for j:=2 to i-1 do\n if y mod j =0 then begin while (y mod j=0) do y:=y div j; inc(x); end;\n if x=3 then inc(ans);\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var \n i,j,k,l,m,n : longint;\n a : array [0..3000] of integer;\nbegin\n read(n); m:=0;\n for i:=1 to n div 2 do\n begin\n k:=0;\n for j:=1 to i do if i mod j=0 then inc(k);\n if k=2 then \n begin\n inc(m);\n a[m]:=i;\n end;\n end;\n k:=0;\n for i:=2 to n do \n begin\n l:=0;\n for j:=1 to m do \n if a[j]>=i then break else\n if i mod a[j]=0 then inc(l);\n if l=2 then inc(k);\n end;\n \n write(k);\nend."}, {"source_code": "var\n a:array[0..3001] of longint;\n i,j,n,m,k,i1,x:longint;\n b:boolean;\nbegin\nreadln(n);\nm:=0;\nfor i:=2 to n do\n begin\n b:=true;\n for j:=2 to trunc(sqrt(i)) do\n if i mod j=0 then \n begin\n b:=false;\n break;\n end;\n if b then \n begin\n inc(m);\n a[m]:=i;\n end; \n end;\nk:=0;\nfor i1:=6 to n do\nfor i:=1 to m do\n if i1 mod a[i]=0 then \n begin \n x:=i1;\n while x mod a[i]=0 do x:=x div a[i];\n for j:=1 to m do\n if x mod a[j]=0 then \n begin\n while x mod a[j]=0 do x:=x div a[j];\n if x=1 then inc(k);\n break;\n end; \n break;\n end; \nwrite(k); \nend."}, {"source_code": "var s,i,j,n:longint;\nf:array[0..6000]of longint;\n\nbegin\nreadln(n);\nfor i:=2 to n do\n if f[i]=0 then\n for j:=2 to n div i do f[i*j]:=f[i*j]+1;\nfor i:=1 to n do\n if f[i]=2then s:=s+1;\nwriteln(s);\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar\n f : text;\n pri : array[1..3000] of boolean;\n prime : array[1..3000] of longint;\n ts,n,i,j,count,t,h : longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n Close(f);\n ts := 0;\n fillchar(pri,sizeof(pri),true);\n pri[1] := false;\n For i := 1 to n do\n if pri[i] = true then\n begin\n inc(ts);\n prime[ts] := i;\n j := 1;\n if i*2 <= n then\n repeat\n inc(j);\n pri[i*j] := false;\n Until i*(j+1) > n;\n End;\n count := 0;\n For i := 2 to n do\n begin\n t := 0;\n h := i;\n For j := 1 to ts do\n if h mod prime[j] = 0 then\n begin\n inc(t);\n repeat\n\n h := h div prime[j];\n Until h mod prime[j] <> 0;\n if (t = 2) or (h = 1) then\n break;\n End;\n if (t = 2) and (h = 1) then\n inc(count);\n End;\n Assign(f,fo);\n rewrite(f);\n Writeln(f,count);\n Close(f);\nEnd."}, {"source_code": "var k,i,j,q,p,ans,n:longint;\nb:boolean;\ns:array [1..1500] of longint;\nbegin\nread(n);\n\np:=1;\ns[p]:=2;\nq:=(n div 2) +1;\n\nfor i:=3 to q do begin\nb:=false;\nfor j:=1 to p do\nif i mod s[j]=0 then begin\nb:=true;\nbreak;\nend;\nif not b then begin\ninc(p);\ns[p]:=i\nend;\nend;\n\nans:=0;\nfor i:=1 to n do begin\nk:=0;\nfor j:=1 to p do begin\nif i mod s[j]=0 then inc(k);\nif k>2 then break;\nend;\nif k=2 then inc(ans);\nend;\nwrite(ans);\nend.\n"}, {"source_code": "var i,j,s,n,s1,t:integer;\na:array[1..3000] of integer;\nbegin\nread(n);\nfor i:=2 to 3000 do\nfor j:=1 to i do\nif (i mod j)=0 then inc(a[i]);\nt:=1;\nfor i:=1 to 3000 do\nif a[i]=2 then begin a[t]:=i; inc(t); end;\nfor i:=2 to n do begin\nt:=1;\ns:=0;\nwhile (s<3)and(a[t] x Div j) And NT(x Div j) then Inc(d);\n End;\nIf d=2 then Inc(dd);\nEnd;\n\nBEGIN\nReadln(n);\ndd:=0;\nFor i:=1 to n do Solve(i);\nWriteln(dd);\nEND.\n"}, {"source_code": "var n,l,i: integer;\n\nfunction IsPrime(a: integer):boolean;\nvar i,limit: integer;\n flag: boolean;\nbegin\n if a=1 then IsPrime := false\n else if a<4 then IsPrime := true\n else if a mod 2 = 0 then IsPrime := false\n else\n begin\n\n flag:=true;\n i:=3;\n limit := trunc(sqrt(a))+1;\n while (i<=limit) and flag do\n begin\n flag := a mod i <> 0;\n i:=i+2\n end;\n IsPrime := flag\n end;\nend;\n\nfunction NextPrime(a: integer):integer;\nvar p: integer;\nbegin\n if a = 2 then begin NextPrime:=3; exit end;\n p:=a+2;\n while not IsPrime(p) do p:=p+2;\n NextPrime:=p;\nend;\n\nfunction PochtiProstoe(a: integer):boolean;\nvar kol,next: integer;\nbegin\n next:=2;\n kol:=0;\n \n while a>1 do\n begin\n if a mod next = 0 then\n begin\n inc(kol);\n while (a mod next = 0) and (a>1) do a := a div next;\n end;\n next:=NextPrime(next)\n end;\n if kol = 2 then PochtiProstoe:=true\n else PochtiProstoe:=false\nend;\n\nBEGIN\n readln(n);\n l:=0;\n for i:=1 to n do if PochtiProstoe(i) then inc(l);\n writeln(l)\n \n\nEND."}, {"source_code": "{CF26A}\nvar\nn,i,s:longint;\nfunction isp(n:longint):boolean;\n var\n i:longint;\n begin\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n exit(false);\n exit(true);\n end;\nfunction num(n:longint):longint;\n var\n i,x:longint;\n begin\n x:=0;\n for i:=2 to n do\n if (n mod i=0) and isp(i) then\n inc(x);\n num:=x;\n end;\nbegin\nread(n);\ns:=0;\nfor i:=6 to n do\n if num(i)=2 then\n inc(s);\nwriteln(s);\nend."}, {"source_code": "var p: array[2..3000] of boolean; q: array[2..3000] of longint;\nb: boolean; i,j,n,k,m,l: longint;\nbegin\n readln(n);\n //setlength(p,n);\n for i:=2 to n do p[i]:=true;\n for i:=2 to n do\n if p[i] then\n begin\n j:=i*2;\n while j<=n do\n begin\n p[j]:=false;\n j:=j+i\n end\n end;\n for i:=2 to n do\n if p[i] then\n begin\n j:=i;\n while j<=n do\n begin\n q[j]:=i;\n j:=j*i\n end;\n end;\n for i:=6 to n do\n begin\n b:=false;\n for j:=2 to i-1 do\n if (q[j]>0) and (i mod j=0) then if (q[i div j]>0) and (q[j]<>q[i div j]) then b:=true;\n if b then inc(k)\n end;\n writeln(k)\nend.\n"}, {"source_code": "var n,d,i:longint;\nfunction nt(a:longint):boolean;\nvar j:longint;\nbegin\n if a=1 then exit(false);\n for j:=2 to trunc(sqrt(a)) do\n if a mod j=0 then exit(false);\n exit(true);\nend;\n{------------------------------------------------------------------}\nfunction kt(s:longint):boolean;\nvar dem,k:longint;\nbegin\n dem:=0;\n for k:=1 to s-1 do\n if (s mod k=0) and (nt(k)=true) then dem:=dem+1;\n if dem=2 then exit(true)\n else exit(false);\nend;\nBEGIN\n readln(n);\n d:=0;\n for i:=1 to n do\n if kt(i)=true then d:=d+1;\n writeln(d);\nEND."}, {"source_code": "var n,i,j,a,r,k:word;\nbegin\n read(n);\n for i:=6to n do\n begin\n k:=i;\n a:=0;\n for j:=2to i div 2+1do\n while k mod j=0do\n begin\n k:=k div j;\n if k mod j<>0then inc(a)\n end;\n if a=2then inc(r)\n end;\n write(r);\nend."}, {"source_code": "var\n k,s,n,s1,i,n1:longint;\n {fin,fout:text;}\n a:array [1..3000] of longint;\n\nbegin\n {assign(fin,'input.txt');\n assign(fout,'output.txt');\n reset(fin);\n rewrite(fout);}\n read(i); s:=1; s1:=0;\n for n1:=2 to i do\n begin\n n:=n1; k:=2;\n while k<=n do\n begin\n if n mod k=0 then\n begin\n n:=n div k;\n a[s]:=k;\n k:=k-1; s:=s+1;\n end;\n k:=k+1;\n\n end;\n for k:=1 to s-1 do\n for n:=k+1 to s do\n if a[k]=a[n] then\n begin\n a[n]:=0;\n end; n:=0;\n for k:=1 to s do\n if a[k]<>0 then\n begin\n n:=n+1;\n a[k]:=0;\n end;\n if n=2 then\n s1:=s1+1;\n s:=1;\n\n end;\n write(s1);\n {close(fin);\n close(fout); }\nend.\n"}, {"source_code": "var \nn,k,i,f,z,D,q:integer;\nbegin\n readln(n);\n \n \n \n for i:=1 to n do\n begin\n z:=0;\n for k:=2 to i-1 do\n begin\n if i mod k=0 then \n begin\n f:=0;\n for q:=2 to k-1 do\n if k mod q=0 then f:=1;\n if f=0 then z:=z+1;\n end;\n end;\n if z=2 then D:=D+1;\n end;\n \n writeln(D); \nend."}, {"source_code": "var k,i,j,q,p,ans,n:longint;\nb:boolean;\ns:array [1..2500] of longint;\nbegin\nread(n);\n\np:=1;\ns[p]:=2;\nq:=(n div 2) +1;\n\nfor i:=3 to q do begin\nb:=false;\nfor j:=1 to p do\nif i mod s[j]=0 then begin\nb:=true;\nbreak;\nend;\nif not b then begin\ninc(p);\ns[p]:=i\nend;\nend;\n\nans:=0;\nfor i:=1 to n do begin\nk:=0;\nfor j:=1 to p do begin\nif i mod s[j]=0 then inc(k);\nif k>2 then break;\nend;\nif k=2 then inc(ans);\nend;\nwrite(ans);\nend.\n"}, {"source_code": "var\n n:longint;\n a:array [1..3000] of boolean;\n b:array [1..3000] of longint;\n i,j,ans,c,f:longint;\n\nbegin\n readln(n);\n fillchar(a,sizeof(a),true);\n a[1]:=false;\n for i:=1 to trunc(sqrt(n)) do\n begin\n j:=i+i;\n if a[i]=true then\n begin\n while j<=n do\n begin\n a[j]:=false;\n inc(j,i);\n end;\n end;\n end;\n c:=0;\n for i:=1 to n do\n begin\n if a[i] then\n begin\n inc(c);\n b[c]:=i;\n end;\n end;\n ans:=0;\n for i:=1 to n do\n begin\n f:=0;\n for j:=1 to c do\n if i mod b[j] = 0 then inc(f);\n if f=2 then inc(ans);\n end;\n writeln(ans);\nend."}, {"source_code": "const\n input= '';\n output='';\nvar\n fi,fo:text;\n m,n,k,s,kq:longint;\nprocedure opf;\nbegin\n assign(fi,input);reset(fi);\n assign(fo,output);rewrite(fo);\nend;\n\nprocedure clf;\nbegin\n close(fi);\n close(fo);\nend;\n\n\nfunction check(x:longint):boolean;\nvar i,j:longint;\nbegin\n j:=trunc(sqrt(x));\n for i:=2 to j do\n if x mod i=0 then\n begin\n check:=false;\n exit;\n end;\n check:=true;\nend;\nprocedure init;\nvar i,j:longint;\nbegin\n readln(fi,n);\n kq:=0;\n for i:=6 to n do\n begin\n m:=i;\n s:=0;\n for j:=2 to m-1 do\n if m mod j=0 then\n if check(j)=true then\n inc(s);\n if s=2 then inc(kq);\n end;\n writeln(fo,kq);\nend;\n\nprocedure solve;\nbegin\nend;\n\nprocedure main;\nbegin\n init;\n solve;\nend;\n\nBegin\n opf;\n main;\n clf;\nEnd.\n"}, {"source_code": "program a26;\nvar k,d,n,kol,i,j,p,t:integer;\n b:array[1..3000] of integer;\nbegin\nread(n);\n kol:=0;\n if n<6 then begin write(kol);exit; end;\n for i:=6 to n do\n begin\n k:=1;d:=2;t:=i;\n while t>1 do\n begin\n if t mod d=0 then begin b[k]:=d;k:=k+1;t:=t div d; end\n else begin\n if d=2 then d:=d+1\n else d:=d+2;\n end;\n \n end;\n p:=0;\n for j:=1 to k-2 do\n begin\n if b[j]<>b[j+1] then p:=p+1;\n end;\n if p=1 then kol:=kol+1;\n end;\n write(kol);\nend."}, {"source_code": "var n , res , i : longint;\nfunction prime(x : longint) : boolean;\nvar j : longint;\n begin\n prime := true;\n for j := 2 to round(sqrt(x)) do\n if (x mod j = 0) then prime := false;\n end;\nFunction can(x : longint) : boolean;\nvar j , cnt : longint;\n begin\n cnt := 0;\n for j := 2 to round(sqrt(x)) do\n if (x mod j = 0) then begin\n if prime(j) then cnt := cnt + 1;\n if (j <> x div j) and (prime(x div j)) then cnt := cnt + 1;\n end;\n if cnt = 2 then can := true else can := false;\nend;\nbegin\n read(n);\n res := 0;\n for i := 2 to n do\n if (can(i)) then res := res + 1;\n writeln(res);\nend.\n"}, {"source_code": "var a:array[1..1500] of integer;\n aa:array[1..240] of integer;\n i,j,n:integer;\n k,w,kol:integer;\nbegin\nreadln(n);\nfor i:=1 to n div 2 do\na[i]:=0;\n k:=1; kol:=0;\n\nfor j:=2 to 37 do\n for i:=j+1 to n div 2 do\n if a[i]<>1 then if i mod j = 0 then a[i]:=1;\n\n for i:=2 to n div 2 do\n if a[i]= 0 then begin aa[k]:=i; k:=k+1; end;\n k:=k-1;\n\nfor i:=1 to n do\nbegin\nw:=0;\n for j:=1 to k do\n if (i<>aa[j]) and (i mod aa[j] = 0) then w:=w+1;\nif w = 2 then kol:=kol+1;\nend;\n\nwriteln(kol);\n\nend.\n\n\n\n"}], "negative_code": [{"source_code": "\n\n var a: array[1..2000] of longint;\n s: array[1..200, 1..200] of longint;\n kol, q, n, t, r, m, i, j: longint;\n\n begin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n a[1] := 2;\n a[2] := 3;\n a[3] := 5;\n a[4] := 7;\n a[5] := 11;\n a[6] := 13;\n a[7] := 17;\n a[8] := 19;\n a[9] := 23;\n a[10] := 29;\n a[11] := 31;\n a[12] := 37;\n a[13] := 41;\n a[14] := 43;\n a[15] := 47;\n a[16] := 51;\n a[17] := 53;\n m := 17;\n for i := 57 to 3000 do\n begin\n q := 0;\n for j := 1 to 17 do if i mod a[j] = 0 then q := 1;\n if q = 0 then begin inc(m); a[m] := i; end;\n end;\n for i := m + 1 to 1000 do a[i] := 4000;\n read(n);\n kol := 0;\n for i := 1 to n do\n begin\n t := 0;\n for j := 1 to 1000 do if i mod a[j] = 0 then inc(t);\n if t = 2 then inc(kol);\n end;\n write(kol);\nend.\n"}, {"source_code": "\n\n var a: array[1..200] of longint;\n s: array[1..200, 1..200] of longint;\n kol, q, n, t, r, m, i, j: longint;\n\n begin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n a[1] := 2;\n a[2] := 3;\n a[3] := 5;\n a[4] := 7;\n a[5] := 11;\n a[6] := 13;\n a[7] := 17;\n a[8] := 19;\n a[9] := 23;\n a[10] := 29;\n a[11] := 31;\n a[12] := 37;\n a[13] := 41;\n a[14] := 43;\n a[15] := 47;\n a[16] := 51;\n a[17] := 53;\n read(n);\n kol := 0;\n for i := 1 to n do\n begin\n t := 0;\n for j := 1 to 17 do if i mod a[j] = 0 then inc(t);\n if t = 2 then inc(kol);\n end;\n write(kol);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n a:Array[1..3000] of Boolean;\n b:Array[1..430] of Integer;\n n,i,k,t,p,s,j:Integer;\nBegin\n Read(n);\n If n=1 Then Begin\n Write(0);\n Halt;\n End;\n a[1]:=false;\n For i:=2 To n Do a[i]:=true;\n t:=1;\n While True Do Begin\n p:=t+1;\n While a[p]<>true Do p:=p+1;\n t:=p;\n If t>Round(sqrt(n)) Then Break;\n While p+t<=n Do Begin\n p:=p+t;\n a[p]:=false;\n End;\n End;\n k:=0;\n For i:=1 To n Do\n If a[i] Then Begin\n k:=k+1;\n b[k]:=i;\n End;\n s:=0;\n For i:=1 To k-1 Do\n For j:=i+1 To k Do\n If b[i]*b[j]<=n Then Begin\n s:=s+n div (b[i]*b[j]);\n End\n Else Break;\n Write(s);\nEnd.\n\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n a:Array[1..3000] of Boolean;\n b:Array[1..430] of Integer;\n n,i,k,t,p,s,j:Integer;\nBegin\n Read(n);\n If n=1 Then Begin\n Write(0);\n Halt;\n End;\n a[1]:=false;\n For i:=2 To n Do a[i]:=true;\n t:=1;\n While True Do Begin\n p:=t+1;\n While a[p]<>true Do p:=p+1;\n t:=p;\n If t>Round(sqrt(n)) Then Break;\n While p+t<=n Do Begin\n p:=p+t;\n a[p]:=false;\n End;\n End;\n k:=0;\n For i:=1 To n Do\n If a[i] Then Begin\n k:=k+1;\n b[k]:=i;\n End;\n s:=0;\n For i:=1 To n Do a[i]:=false;\n For i:=1 To k-1 Do\n For j:=i+1 To k Do\n If b[i]*b[j]<=n Then Begin\n t:=b[i]*b[j];\n p:=t;\n a[p]:=true;\n s:=s+1;\n While p+t<=n Do Begin\n p:=p+t;\n If a[p] Then Begin\n s:=s-1;\n Continue;\n End;\n WriteLn(p);\n a[p]:=true;\n s:=s+1;\n End;\n End\n Else Break;\n Write(s);\nEnd.\n\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n a:Array[1..3000] of Boolean;\n b:Array[1..430] of Integer;\n n,i,k,t,p,s,j:Integer;\nBegin\n Read(n);\n If n=1 Then Begin\n Write(0);\n Halt;\n End;\n a[1]:=false;\n For i:=2 To n Do a[i]:=true;\n t:=1;\n While True Do Begin\n p:=t+1;\n While a[p]<>true Do p:=p+1;\n t:=p;\n If t>Round(sqrt(n)) Then Break;\n While p+t<=n Do Begin\n p:=p+t;\n a[p]:=false;\n End;\n End;\n k:=0;\n For i:=1 To n Do\n If a[i] Then Begin\n k:=k+1;\n b[k]:=i;\n End;\n s:=0;\n For i:=1 To n Do a[i]:=false;\n For i:=1 To k-1 Do\n For j:=i+1 To k Do\n If b[i]*b[j]<=n Then Begin\n t:=b[i]*b[j];\n p:=t;\n a[p]:=true;\n WriteLn(b[i],' ',b[j],' ',p);\n s:=s+1;\n While p+t<=n Do Begin\n p:=p+t;\n If a[p] Then Begin\n s:=s-1;\n Continue;\n End;\n WriteLn(p);\n a[p]:=true;\n s:=s+1;\n End;\n End\n Else Break;\n Write(s);\nEnd.\n\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n a:Array[1..3000] of Boolean;\n b:Array[1..430] of Integer;\n n,i,k,t,p,s,j:Integer;\nBegin\n Read(n);\n If n=1 Then Begin\n Write(1);\n Halt;\n End;\n a[1]:=false;\n For i:=2 To n Do a[i]:=true;\n t:=1;\n While True Do Begin\n p:=t+1;\n While a[p]<>true Do p:=p+1;\n t:=p;\n If t>Round(sqrt(n)) Then Break;\n While p+t<=n Do Begin\n p:=p+t;\n a[p]:=false;\n End;\n End;\n k:=0;\n For i:=1 To n Do\n If a[i] Then Begin\n k:=k+1;\n b[k]:=i;\n End;\n s:=0;\n For i:=1 To k-1 Do\n For j:=i+1 To k Do\n If b[i]*b[j]<=n Then Begin\n s:=s+n div (b[i]*b[j]);\n End\n Else Break;\n Write(s);\nEnd.\n\n\n\n\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nConst\n Source='input.txt';\n Target='output.txt';\nVar\n a:Array[1..3000] of Boolean;\n b:Array[1..430] of Integer;\n n,i,k,t,p,s,j:Integer;\nBegin\n Read(n);\n If n=1 Then Begin\n Write(0);\n Halt;\n End;\n a[1]:=false;\n For i:=2 To n Do a[i]:=true;\n t:=1;\n While True Do Begin\n p:=t+1;\n While a[p]<>true Do p:=p+1;\n t:=p;\n If t>Round(sqrt(n)) Then Break;\n While p+t<=n Do Begin\n p:=p+t;\n a[p]:=false;\n End;\n End;\n k:=0;\n For i:=1 To n Do\n If a[i] Then Begin\n k:=k+1;\n b[k]:=i;\n End;\n s:=0;\n For i:=1 To n Do a[i]:=false;\n For i:=1 To k-1 Do\n For j:=i+1 To k Do\n If b[i]*b[j]<=n Then Begin\n t:=b[i]*b[j];\n p:=t;\n a[p]:=true;\n s:=s+1;\n While p+t<=n Do Begin\n p:=p+t;\n If a[p] Then Begin\n s:=s-1;\n Continue;\n End;\n a[p]:=true;\n s:=s+1;\n End;\n End\n Else Break;\n Write(s);\nEnd.\n\n\n\n\n"}, {"source_code": "program Project_26_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n fi,fo:text;\n a,b:array[1..1000]of integer;\n\n i,n,k,t,ans,j,f,d,m:integer;\n function check(t:integer):boolean;\n begin\n check:=false;\n for f:=2 to trunc(sqrt(t+1)) do\n if (t mod f=0) then check:=true;\n\n end;\nbegin\n\nread(n);\nt:=1;\na[1]:=2;\nfor i:=3 to n do\n begin\n if (check(i)=false) then\n begin\n inc(t);\n a[t]:=i;\n end;\n end;\nans:=0;\nd:=1;\nm:=1;\nfor i:=1 to t do\n for j:=i+1 to t do\n begin\n b[m]:=a[i]*a[j];\n inc(m);\n end;\nfor i:=1 to n do\n begin\n for j:=1 to m-1 do\n if (i mod b[j]=0) then inc(ans);\n end;\n\n\nwrite(ans);\n\nend.\n"}, {"source_code": "program Project_26_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n fi,fo:text;\n a:array[1..1000]of integer;\n i,n,k,t,ans,j,f,d:integer;\n function check(t:integer):boolean;\n begin\n check:=false;\n for f:=2 to trunc(sqrt(t+1)) do\n if (t mod f=0) then check:=true;\n\n end;\nbegin\n\nread(n);\nt:=1;\na[1]:=2;\nfor i:=3 to n do\n begin\n if (check(i)=false) then\n begin\n inc(t);\n a[t]:=i;\n end;\n end;\nans:=0;\nd:=1;\nwhile (d2) then begin a:=j;\nfor b:=1 to n do\nif (a mod b=0) then k:=k+1;\n\nif (k=2) then c:=c+1;\n\nk:=0;\nend;\nend;\nif c=1 then c2:=c2+1;\nc:=0;\nend;\n\n\n\n\n\nwriteln(c2);\nend.\n\n\n\n\n"}, {"source_code": "program zadacha26a;\nvar a:array[1..3000] of integer;\n b:array[2..3000] of byte;\n n,k,i,j,l,p:integer;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(n);\nk:=0;\nfor i:=1 to 3000 do\nb[i]:=0;\nfor i:=2 to trunc(sqrt(3000))+1 do\n begin\n if b[i]=0 then\n j:=i*i;\n while j<=3000 do\n begin\n b[j]:=1;\n j:=j+i;\n end;\n end;\nfor i:=1 to n do\n begin\n l:=1;\n for j:=2 to trunc(sqrt(i)) do\n begin\n if i mod j=0 then\n begin\n a[l]:=j;\n inc(l);\n end;\n if i div j<>j then\n begin\n a[l]:=i div j;\n inc(l);\n end;\n end;\n p:=0;\n for j:=1 to l-1 do\n if b[a[j]]=0 then inc(p);\n if p=2 then inc(k);\n end;\nwrite(k);\n{close(input); close(output);}\nend."}, {"source_code": "program zadacha26a;\nvar a:array[1..3000] of integer;\n b:array[2..3000] of byte;\n n,k,i,j,l,p:integer;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(n);\nk:=0;\nfor i:=1 to 3000 do\n b[i]:=0;\nfor i:=2 to trunc(sqrt(3000))+1 do\n begin\n if b[i]=0 then\n j:=i*i;\n while j<=3000 do\n begin\n b[j]:=1;\n j:=j+i;\n end;\n end;\nfor i:=6 to n do\n begin\n l:=1;\n for j:=2 to trunc(sqrt(i)) do\n begin\n if i mod j=0 then\n begin\n a[l]:=j;\n inc(l);\n end; {}\n if i div j<>j then\n begin\n a[l]:=i div j;\n inc(l);\n end;\n end;\n p:=0;\n for j:=1 to l-1 do\n if b[a[j]]=0 then inc(p);\n if p=2 then inc(k);\n end;\nwrite(k);\n{close(input); close(output);}\nend."}, {"source_code": "program zadacha26a;\nvar a:array[1..3000] of integer;\n b:array[2..3000] of byte;\n n,k,i,j,l,p:integer;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(n);\nk:=0;\nfor i:=1 to 3000 do\nb[i]:=0;\nfor i:=2 to trunc(sqrt(3000))+1 do\n begin\n if b[i]=0 then\n j:=i*i;\n while j<=3000 do\n begin\n b[j]:=1;\n j:=j+i;\n end;\n end;\nfor i:=6 to n do\n begin\n l:=1;\n for j:=2 to trunc(sqrt(i)) do\n begin\n if i mod j=0 then\n begin\n a[l]:=j;\n inc(l);\n end;\n if i div j<>j then\n begin\n a[l]:=i div j;\n inc(l);\n end;\n end;\n p:=0;\n for j:=1 to l do\n if b[a[j]]=0 then inc(p);\n if p=2 then inc(k);\n end;\nwrite(k);\n{close(input); close(output);}\nend."}, {"source_code": "program zadacha26a;\nvar a:array[1..3000] of integer;\n b:array[2..3000] of byte;\n n,k,i,j,l,p:integer;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(n);\nk:=0;\nfor i:=1 to 3000 do\n b[i]:=0;\nfor i:=2 to trunc(sqrt(3000))+1 do\n begin\n if b[i]=0 then\n j:=i*i;\n while j<=3000 do\n begin\n b[j]:=1;\n j:=j+i;\n end;\n end;\nfor i:=6 to n do\n begin\n l:=1;\n for j:=2 to trunc(sqrt(i))+1 do\n begin\n if i mod j=0 then\n begin\n a[l]:=j;\n inc(l);\n end;\n if i div j<>j then\n begin\n a[l]:=i div j;\n inc(l);\n end;\n end;\n p:=0;\n for j:=1 to l-1 do\n if b[a[j]]=0 then inc(p);\n if p=2 then inc(k);\n end;\nwrite(k);\n{close(input); close(output);}\nend."}, {"source_code": "program zadacha26a;\nvar a:array[1..3000] of integer;\n b:array[2..3000] of byte;\n n,k,i,j,l,p:integer;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(n);\nk:=0;\nfor i:=1 to 3000 do\nb[i]:=0;\nfor i:=2 to trunc(sqrt(3000))+1 do\n begin\n if b[i]=0 then\n j:=i*i;\n while j<=3000 do\n begin\n b[j]:=1;\n j:=j+i;\n end;\n end;\nfor i:=6 to n do\n begin\n l:=1;\n for j:=2 to trunc(sqrt(i)) do\n begin\n if i mod j=0 then\n begin\n a[l]:=j;\n inc(l);\n end;\n if i div j<>j then\n begin\n a[l]:=i div j;\n inc(l);\n end;\n end;\n p:=0;\n for j:=1 to l-1 do\n if b[a[j]]=0 then inc(p);\n if p=2 then inc(k);\n end;\nwrite(k);\n{close(input); close(output);}\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar i,n,KQ:longint;\n f,g:text;\nfunction kt(x:longint):boolean;\nvar i:longint;\nbegin\n if x=1 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\n{----------------------------}\nfunction dem(x:longint):boolean;\nvar i,p,d:longint;\nbegin\n d:=0;\n for i:=2 to trunc(sqrt(x)) do\n begin\n if x mod i=0 then\n begin\n p:=x div i;\n if kt(p) then inc(d);\n if kt(i) then inc(d);\n if p=i then dec(d);\n end;\n if d>2 then exit(false);\n end;\n if d=2 then exit(true)\n else exit(false);\nend;\n{----------------------------}\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n readln(f,n); KQ:=0;\n for i:=1 to n do\n if dem(i) then inc(KQ);\n write(g,KQ); close(f); close(g);\nend.\n"}, {"source_code": "var\n n,m,k:longint;\n s,s1:extended;\nbegin\n readln(n,m,k);\n s1:=1;\n for k:=0 to k do begin\n s:=(m-k)/(n+k+1);\n s1:=s1*s;\n end;\n if s1>1 then s1:=0\n else s1:=1-s1;\n writeln(s1:0:8);\nend."}, {"source_code": "var n, i, j, k, d, h:integer;\n s :array[1..3000] of longint;\n\nfunction prime(a:longint):boolean;\nvar i,r:longint;\nbegin\n r:=round(sqrt(a));\n i:=2;\n while (i<=r)and(a mod i<>0) do inc(i);\n if i>r then exit(true) else exit(false);\nend;\n\nprocedure process ;\nvar kt:boolean;\nbegin\n j:=0; d:=0;\n for i:=2 to n do if prime(i) then\n begin\n inc(j);\n s[j]:=i;\n end;\n\n for i:=1 to n do\n begin\n kt:=true;\n for k:=1 to j do\n begin\n for h:=k+1 to j do if(i mod s[k]=0)and(i mod s[h]=0 ) then\n begin\n inc(d);\n kt:=false;\n break;\n end;\n if kt=false then break;\n end;\n end;\nend;\n\nbegin\n readln(n);\n process;\n writeln(d);\nend."}, {"source_code": "const\n d:array [1..371] of longint = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293\n,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,76\n,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,\n1149,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,\n33,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,\n2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,\n2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,4000);\nvar\n i,j,n,k,m,kol,ans:longint;\nbegin\n readln(n);\n for i:=6 to n do\n begin\n j:=1; kol:=0;\n while d[j]<=i do\n begin\n if i mod d[j]=0 then inc(kol);\n if kol>2 then break;\n inc(j)\n end;\n if kol=2 then inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "const\n d:array [1..16] of longint = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar\n i,j,n,k,m,kol,ans:longint;\nbegin\n readln(n);\n for i:=6 to n do\n begin\n j:=1; kol:=0;\n while d[j]x) and not a[i] and not a[x div i] then exit(true);\n exit(false);\nend;\nbegin\n read(n);\n for i:=2 to trunc(sqrt(n)) do\n if not a[i] then\n for j:=2 to n div i do\n a[i*j]:=true;\n for i:=6 to n do\n if work(i) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "var j,i,n,s,sum:longint;\n function ss(x:longint):boolean;\n var i:longint;\n begin\n for i:=2 to trunc(sqrt(x)) do \n if x mod i=0 then exit(false);\n exit(true);\n end;\nbegin\n readln(n);\n for j:=1 to n do \n begin\n s:=0;\n for i:=2 to trunc(sqrt(j)) do \n begin\n if j mod i=0 then if ss(i) then s:=s+1;\n end;\n if s=2 then sum:=sum+1;\n end;\n writeln(sum); \nend."}, {"source_code": "Var a:array [0..10000] of longint;\n b:array [0..10000] of longint;\n n,i,p,k,j,o:longint;\n\n function prost(x:longint):boolean;\n var i,k:longint;\n begin\n k:=0;\n for i:=2 to round(sqrt(x)) do\n if x mod i=0 then begin prost:=false; exit; end;\n prost:=true;\n end;\n\n begin\n read(n);\n for i:=1 to n do\n begin\n k:=0;\n for j:=2 to round(sqrt(i)) do\n begin\n if (i mod j=0) then begin inc(k); a[k]:=j; inc(k); a[k]:=i div j; end;\n end;\n o:=0;\n fillchar(b,sizeof(b),0);\n for j:=1 to k do\n begin\n if (b[a[j]]=0)and (prost(a[j])) then begin inc(o); inc(b[a[j]]) end;\n if o>1 then begin inc(p); break; end;\n end;\n end;\n writeln(p);\n end."}, {"source_code": "{CF26A}\nvar\nn,i,s:longint;\nfunction isp(n:longint):boolean;\n var\n i:longint;\n begin\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n exit(false);\n exit(true);\n end;\nfunction num(n:longint):longint;\n var\n i,x:longint;\n begin\n x:=0;\n for i:=2 to n do\n if (n mod i=0) and isp(i) then\n inc(x);\n num:=x;\n end;\nbegin\nread(n);\ns:=0;\nfor i:=6 to n do\n if num(i)>1 then\n inc(s);\nwriteln(s);\nend."}, {"source_code": "var\n\tn , kq : longint;\n\tnt : array [ 0 .. 3001 ] of boolean;\n//===============================================\nprocedure nhap;\n\tvar\n\t\tf : text;\n\tbegin\n assign( f , '' );\n\t\treset( f );\n\t\treadln( f , n );\n\t\tclose( f );\n\tend;\n//===============================================\nprocedure sang;\n\tvar\n\t\ti , j : longint;\n\tbegin\n\t\tfillchar( nt , sizeof( nt ) , true );\n\t\tnt[ 1 ] := false;\n\t\tnt[ 0 ] := false;\n\t\tfor i := 2 to trunc( sqrt( n div 2 ) ) do\n\t\t\tif nt[ i ] then\n\t\t\t\tbegin\n\t\t\t\t\tj := i * i;\n\t\t\t\t\twhile j < n do\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tnt[ j ] := false;\n\t\t\t\t\t\t\tj := j + i;\n\t\t\t\t\t\tend;\n\t\t\t\tend;\n\t\tfor i := 2 to n div 2 do\n\t\t\tbegin\n\t\t\t\tj := i * i;\n\t\t\t\twhile j <= n div 2 do\n\t\t\t\t\tbegin\n\t\t\t\t\t\tnt[ j ] := true;\n\t\t\t\t\t\tj := j * i;\n\t\t\t\t\tend;\n\t\t\tend;\n\tend;\n//===============================================\nprocedure xuli;\n\tvar\n\t\ti , j : longint;\n\tbegin\n\t\tsang;\n\t\tkq := 0;\n\t\tfor i := 2 to n div 2 do\n\t\t\tif nt[ i ] then\n\t\t\t\tfor j := i + 1 to n div 2 do\n\t\t\t\t\tif nt[ j ] then\n\t\t\t\t\t\tif ( i * j <= n ) and ( i mod j <> 0 ) and ( j mod i <> 0 ) then\n\t\t\t\t\t\t\tinc( kq );\n\tend;\n//===============================================\nprocedure xuat;\n\tvar\n\t\tf : text;\n\tbegin\n\t\tassign( f , '' );\n\t\trewrite( f );\n\t\twriteln( f , kq );\n\t\tclose( f );\n\tend;\n//===============================================\nbegin\n\tnhap;\n\txuli;\n\txuat;\nend.\n"}, {"source_code": "const max_stepen=10;\nvar n,res,length_simple,i,j : integer;\n simple : array [1..250] of integer;\nprocedure simple_generation;\nvar b:boolean;\n begin\n for i:=2 to (n div 2) do\n begin\n b:=true;\n j:=3;\n if (i mod 2=0) and (i<>2) then b:=false;\n if b then while (sqr(j)<=i) do\n if i mod j=0 then begin\n b:=false;\n break;\n end\n else inc(j,2);\n if b then begin\n inc(length_simple);\n simple[length_simple]:=i;\n end;\n end;\n end;\nprocedure almost_simple_generation;\nvar n1,n2,n1_max,n2_max:integer;\nmas:array[1..250,1..10] of longint;\n begin\n n1_max:=max_stepen; n2_max:=max_stepen;\n for i:=1 to length_simple do mas[i,1]:=simple[i];\n for i:=1 to length_simple-1 do\n for j:=i+1 to length_simple do\n begin\n //for n1:=1 to n1_max do\n n1:=1;\n while (n1<=n1_max) do begin\n //for n2:=1 to n2_max do\n n2:=1;\n while (n2<=n2_max) do\n begin\n if mas[i,n1]=0 then mas[i,n1]:=mas[i,n1-1]*simple[i];\n if mas[j,n2]=0 then mas[j,n2]:=mas[j,n2-1]*simple[j];\n if mas[i,n1]>n then n1_max:=n1-1;\n if mas[j,n2]>n then n2_max:=n2-1;\n if mas[i,n1]*mas[j,n2]<=n then inc(res);\n inc(n2);\n end;\n inc(n1);\n end;\n end;\n end;\nBEGIN\nread(n);\nlength_simple:=0; res:=0;\nsimple_generation;\nalmost_simple_generation;\nwrite(res);\nEND.\n"}, {"source_code": "Var t, n, res : integer;\n\nFunction Check(x : integer) : boolean;\nVar i, count : integer;\nBegin\n i := 1;\n count := 0;\n Repeat\n Repeat inc(i) Until x mod i = 0;\n inc(count);\n If count > 2 then break;\n Repeat x := x div i Until (x = 0) or (x mod i <> 0);\n Until x = 1;\n If count = 2 then Check := true else Check := false;\nEnd;\n\nBEGIN\n readln(n);\n For t := 2 to n do\n If Check(t) then inc(res);\n writeln(res);\nEND."}, {"source_code": "var n,k,i,p,j:longint;\nbegin\nread(n);\np:=0;\nk:=0;\nfor i:=6 to n do\nfor j:=2 to n div 2 do begin\nif (j=2) or (j=3) or (j=5) or (j=7) or (j=11) or (j=13) or (j=17) or (j=19) or (j=23) or (j=29)then begin\nif (i mod j=0) then inc(k);\nend;\nif (j mod 2<>0) and (j mod 3<>0) and (j mod 5<>0) and (j mod 7<>0) and (j mod 11<>0)\nand (j mod 13<>0) and (j mod 17<>0) and (j mod 19<>0) and (j mod 23<>0) and (j mod 29<>0)then begin\nif (i mod j=0) then inc(k);\nend;\nif j=n div 2 then begin\nif k=2 then inc(p);\nk:=0;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var n,k,i,p,j:longint;\nbegin\nread(n);\np:=0;\nk:=0;\nfor i:=6 to n do\nfor j:=2 to n do begin\nif (j=2) or (j=3) or (j=5) or (j=7) or (j=11) or (j=13) or (j=17) or (j=19) then begin\nif (i mod j=0) then inc(k);\nend;\nif (j mod 2<>0) and (j mod 3<>0) and (j mod 5<>0) and (j mod 7<>0) and (j mod 11<>0)\nand (j mod 13<>0) and (j mod 17<>0) and (j mod 19<>0) then begin\nif (i mod j=0) then inc(k);\nend;\nif j=n then begin\nif k=2 then inc(p);\nk:=0;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var n,k,i,p:longint;\nbegin\nread(n);\np:=0;\nk:=0;\nfor i:=1 to n do begin\nif (i mod 2=0) then inc(k);\nif (i mod 3=0) then inc(k);\nif (i mod 5=0) then inc(k);\nif (i mod 7=0) then inc(k);\nif k=2 then inc(p);\nk:=0;\nend;\nwrite(p);\nend."}, {"source_code": "var n,k,i,p,j:longint;\nbegin\nread(n);\np:=0;\nk:=0;\nfor i:=6 to n do\nfor j:=2 to n div 2 do begin\nif (j=2) or (j=3) or (j=5) or (j=7) or (j=11) or (j=13) or (j=17) or (j=19) then begin\nif (i mod j=0) then inc(k);\nend;\nif (j mod 2<>0) and (j mod 3<>0) and (j mod 5<>0) and (j mod 7<>0) and (j mod 11<>0)\nand (j mod 13<>0) and (j mod 17<>0) and (j mod 19<>0) then begin\nif (i mod j=0) then inc(k);\nend;\nif j=n div 2 then begin\nif k=2 then inc(p);\nk:=0;\nend;\nend;\nwrite(p);\nend."}, {"source_code": "var n,k,i,p:longint;\nbegin\nread(n);\np:=0;\nk:=0;\nfor i:=1 to n do begin\nif (i mod 2=0) then inc(k);\nif (i mod 3=0) then inc(k);\nif (i mod 5=0) then inc(k);\nif (i mod 7=0) then inc(k);\nif (i mod 11=0) then inc(k);\nif (i mod 13=0) then inc(k);\nif (i mod 17=0) then inc(k);\nif (i mod 19=0) then inc(k);\nif (i mod 23=0) then inc(k);\nif (i mod 29=0) then inc(k);\nif (i mod 31=0) then inc(k);\nif (i mod 37=0) then inc(k);\nif (i mod 41=0) then inc(k);\nif (i mod 43=0) then inc(k);\nif (i mod 47=0) then inc(k);\nif (i mod 53=0) then inc(k);\nif (i mod 59=0) then inc(k);\nif (i mod 61=0) then inc(k);\nif (i mod 67=0) then inc(k);\nif (i mod 71=0) then inc(k);\nif (i mod 73=0) then inc(k);\nif (i mod 79=0) then inc(k);\nif k=2 then inc(p);\nk:=0;\nend;\nwrite(p);\nend."}, {"source_code": "var\n n,i,j,x,y,m,anss,met,z:longint;\n a:array[1..4000] of longint;\n ans:array[1..100000] of longint;\nbegin\n readln(n);\n for i:=2 to 4000 do\n begin\n j:=i+i;\n if (a[i]=0) then begin\n while (j<=n) do\n begin\n a[j]:=1;\n j:=j+i;\n end;\n end;\n end;\n for i:=1 to 4000 do\n begin\n if (a[i]=0) then begin\n inc(m);\n ans[m]:=i;\n end;\n end;\n for i:=6 to n do\n begin\n for j:=2 to trunc(sqrt(i)) do\n begin\n if (i mod j=0) and ((i div j)<>j) then begin\n\n met:=0;\n for z:=1 to m do\n begin\n if (ans[z]=j) then begin\n met:=1;\n break;\n end;\n end;\n if (met=1) then begin\n met:=0;\n for z:=1 to m do\n begin\n if (ans[z]=(i div j)) then begin\n met:=1;\n break;\n end;\n end;\n if (met=1) then inc(anss);\n end;\n\n end;\n end;\n end;\n writeln(anss);\nend."}, {"source_code": "var\n del,ch,n,i,j,x,y,m,anss,met,z:longint;\n a:array[1..4000] of longint;\n ans:array[1..100000] of longint;\nbegin\n readln(n);\n for i:=2 to 4000 do\n begin\n j:=i+i;\n if (a[i]=0) then begin\n while (j<=n) do\n begin\n a[j]:=1;\n j:=j+i;\n end;\n end;\n end;\n for i:=1 to 4000 do\n begin\n if (a[i]=0) then begin\n inc(m);\n ans[m]:=i;\n end;\n end;\n for i:=6 to n do\n begin\n j:=2;\n ch:=i;\n del:=0;\n met:=0;\n while (ch mod 2)=0 do\n begin\n ch:=ch div 2;\n met:=1\n end;\n if met=1 then inc(del);\n for j:=3 to m do\n begin\n if (ch mod ans[j])=0 then begin\n inc(del);\n ch:=ch div ans[j];\n if (del>=2) then begin\n inc(anss);\n // writeln(i);\n break;\n end;\n end;\n end;\n\n end;\n writeln(anss);\nend."}, {"source_code": " var i,n,k,z,kol,j:longint;\nbegin\n readln(n);\n k:=0;\n for i:=6 to n do begin\n z:=i;\n kol:=0;\n for j:=2 to round(sqrt(i)) do\n if z mod j = 0 then begin\n inc(kol);\n while z mod j = 0 do\n z:=z div j;\n if kol>2 then break;\n if z=1 then break;\n end;\n if kol=2 then\n inc(k);\n end;\n writeln(k);\nend."}, {"source_code": " var i,n,k,z,kol,j:longint;\nbegin\n readln(n);\n k:=0;\n for i:=6 to n do begin\n z:=i;\n kol:=0;\n for j:=2 to (round(sqrt(i))+1) do\n if z mod j = 0 then begin\n inc(kol);\n while z mod j = 0 do\n z:=z div j;\n if kol>2 then break;\n if z=1 then break;\n end;\n if kol=2 then\n inc(k);\n end;\n writeln(k);\nend."}, {"source_code": "var\n c, f, q, l, n, i, j, s, t, m, k: longint;\n a: array[0..10000] of longint;\n\nprocedure solve;\nvar k: longint;\nbegin\n k := 1;\n while (a[k] < l) and (a[k] <> 0) do begin\n if l mod a[k] = 0 then begin\n inc(c);\n end;\n if c = 2 then begin\n inc(s);\n exit;\n end;\n inc(k);\n end;\nend;\n\n\nbegin\n read(n);\n for i := 1 to n do begin\n q := round(sqrt(i));\n for j := 1 to q do\n if i mod j = 0 then\n inc(c);\n if (c = 1) and (i <> 1) then begin\n inc(t);\n a[t] := i;\n end;\n c := 0;\n end;\n for l := 1 to n do begin\n solve;\n c := 0;\n end;\n write(s);\nend."}, {"source_code": "var\n c, f, q, l, n, i, j, s, t, m, k: longint;\n a: array[1..10000] of longint;\n\nprocedure solve;\nvar i, j: longint;\nbegin\n for k := 1 to t do begin\n if l mod a[k] = 0 then begin\n inc(c);\n end;\n if c = 2 then begin\n inc(s);\n exit;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n for i := 1 to n do begin\n q := round(sqrt(i));\n for j := 1 to q do\n if i mod j = 0 then\n inc(c);\n if (c = 1) and (i <> 1) then begin\n inc(t);\n a[t] := i;\n end;\n c := 0;\n end;\n for l := 1 to n do begin\n solve;\n c := 0;\n end;\n write(s);\nend."}, {"source_code": "var k,n,i:longint;\n\n function check(i:longint):boolean;\n var x:longint;\n begin\n x:=2;\n while x*x<=i do\n begin\n if i mod x=0 then\n begin\nwhile i mod x=0 do i:=i div x;\nbreak;\nend;\ninc(x);\nend;\nif i=1 then exit(false);\nx:=2;\n while x*x<=i do\n begin\n if i mod x=0 then\n begin\nwhile i mod x=0 do i:=i div x;\nbreak;\nend;\ninc(x);\nend;\nexit(i=1);\nend;\n begin\n readln(N);\nfor i:=1 to n do\n if check(i) then inc(k);\nwriteln(k);\nend."}, {"source_code": "var\n a:array[0..3001] of longint;\n i,j,n,m,k:longint;\n b:boolean;\nbegin\nreadln(n);\nm:=0;\nfor i:=2 to n do\n begin\n b:=true;\n for j:=2 to trunc(sqrt(i)) do\n if i mod j=0 then \n begin\n b:=false;\n break;\n end;\n if b then \n begin\n inc(m);\n a[m]:=i;\n end; \n end;\nk:=0;\nfor i:=1 to m-1 do\n for j:=i+1 to m do\n if a[i]*a[j]<=n then inc(k);\nwrite(k); \nend."}, {"source_code": "var\n a:array[0..3001] of longint;\n i,j,n,m,k:longint;\n b:boolean;\nbegin\nreadln(n);\nm:=0;\nfor i:=2 to n do\n begin\n b:=true;\n for j:=2 to trunc(sqrt(i)) do\n if i mod j=0 then \n begin\n b:=false;\n break;\n end;\n if b then \n begin\n inc(m);\n a[m]:=i;\n end; \n end;\nk:=0;\nfor i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]*a[j]<=n then inc(k);\nwrite(k); \nend."}, {"source_code": "var\n n,i,j,k,s:longint;\n a,b:array[1..3000] of longint;\n f:boolean;\nbegin\n readln(n);\n k:=0;\n for i:=2 to sqr(n) do\n begin\n f:=false;\n for j:=1 to k do\n if i mod a[j]=0 then begin f:=true; break; end;\n if not f then begin\n inc(k);\n a[k]:=i;\n for j:=1 to n do\n begin\n if j mod i=0 then\n if b[j]=1 then inc(S)\n else inc(b[j]);\n\n end;\n end;\n end;\n writeln(s);\n end."}, {"source_code": "var\n n,i,j,k,s:longint;\n a,b:array[1..3000] of longint;\n f:boolean;\nbegin\n readln(n);\n k:=0;\n for i:=2 to sqr(n) do\n begin\n f:=false;\n for j:=1 to k do\n if i mod a[j]=0 then begin f:=true; break; end;\n if not f then begin\n inc(k);\n a[k]:=i;\n for j:=1 to n do\n if j mod i=0 then inc(b[j]);\n end;\n end;\n for i:=1 to n do\n if b[i]=2 then inc(s);\n writeln(s);\n end."}, {"source_code": "var p: array of boolean; b: boolean; i,j,n,k,m,l: integer;\nbegin\n readln(n);\n setlength(p,n);\n for i:=2 to n do if not p[i] then\n begin\n j:=i*2;\n while j<=n do\n begin\n p[j]:=true;\n j:=j+i\n end\n end;\n for i:=2 to n do p[i]:=not p[i];\n i:=2;\n l:=trunc(sqrt(n));\n while i 0 then\n\tbegin\n\t\tkt:=false;\n\t\tfor j:=2 to trunc(sqrt(i)) do\n if i mod j =0 then kt:=true;\n\t\t\tif kt=false then\n\t\t\tbegin\n\t\t\t\t\tinc(k);\n\t\t\t\t\ta[k]:=i;\n\t\t\tend;\n\tend;\n for i:=2 to 3000 do\n begin\n l:=0;\n for j:=1 to k do\n begin\n if a[j]>i then break;\n if i mod a[j] =0 then inc(l);\n if l=2 then c[i]:=1;\n end;\n end;\n sl:=0;\n readln(n);\n for i:=1 to n do\n if c[i]=1 then inc(sl);\n writeln(sl);\nreadln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,d,m,v: integer;\n i,j,k,l: longint;\n a: array [1..2000] of integer;\nbegin\n read(n);\n k := 0;\n for i := 1 to 1500 do a[i] := 0;\n a[1] := 1;\n for i := 2 to 2500 do\n if a[i] = 0 then\n begin\n j := i + i;\n while j <= 1500 do\n begin\n a[j] := 1;\n INC(j,i);\n end;\n end;\n l := 0;\n for i := 2 to n do\n begin\n k := 0;\n for j := 1 to n DIV 2+1 do\n if (a[j] = 0) and (i MOD j = 0) then INC(k);\n if k = 2 then INC(l);\n end;\n write(l);\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n status : array[1..3000] of boolean;\n a : array[1..430] of integer;\nprocedure add(var n : integer);\nvar\n i,j: integer;\nbegin\n i := 2;\n while sqr(i) <= 3000 do begin\n if status[i] = false then begin\n j := sqr(i);\n while j <= 3000 do begin\n if status[j] = false then status[j] := true;\n inc(j,i);\n end;\n end;\n inc(i);\n end;\n n := 0;\n for i := 2 to 3000 do\n if status[i] = false then begin\n inc(n);\n a[n] := i;\n end;\nend;\nvar\n i,j,n,kol,m,ans: integer;\nbegin\n n := 0;\n add(n);\n ans := 0;\n read(m);\n for i := 1 to m do begin\n kol := 0;\n for j := 1 to n do begin\n if a[j] > i then break;\n if i mod a[j] = 0 then inc(kol);\n end;\n if kol >= 2 then inc(ans);\n end;\n write(ans);\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nVar\n n,i,j,ind, ind2:integer;\n a:array[1..3014] of integer;\nbegin\n readln(n);\n ind:=0;\n ind2:=1;\n for i:= 2 to 27600 do\n begin\n for j:=2 to i-1 do\n begin\n if i mod j=0 then\n ind:=1;\n end;\n if ind=1 then\n begin\n ind:=0;\n end\n else\n begin\n ind:=0;\n a[ind2]:=i;\n ind2:=ind2+1;\n end;\n end;\n writeln(ind2);\n readln;\n ind:=0;\n ind2:=0;\n for j:=3 to n do\n begin\n for i:= 1 to n div 2 do\n begin\n if j mod a[i]=0 then\n ind:=ind+1;\n end;\n if ind=2 then\n begin\n ind2:=ind2+1;\n end;\n ind:=0;\n end;\n writeln(ind2);\n readln;\nend.\n"}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..2533] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,30,33,34,35,36,38,39,40,42,44,45,46,48,50,51,\n52,54,55,56,57,58,60,62,63,65,66,68,69,70,72,74,75,76,77,78,80,82,84,85,86,87,\n88,90,91,92,93,94,95,96,98,99,100,102,104,105,106,108,110,111,112,114,115,116,\n117,118,119,120,122,123,124,126,129,130,132,133,134,135,136,138,140,141,142,143,\n144,145,146,147,148,150,152,153,154,155,156,158,159,160,161,162,164,165,166,168,\n170,171,172,174,175,176,177,178,180,182,183,184,185,186,187,188,189,190,192,194,\n195,196,198,200,201,202,203,204,205,206,207,208,209,210,212,213,214,215,216,217,\n218,219,220,221,222,224,225,226,228,230,231,232,234,235,236,237,238,240,242,244,\n245,246,247,248,249,250,252,253,254,255,258,259,260,261,262,264,265,266,267,268,\n270,272,273,274,275,276,278,279,280,282,284,285,286,287,288,290,291,292,294,295,\n296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,315,316,318,319,\n320,321,322,323,324,325,326,327,328,329,330,332,333,334,335,336,338,339,340,341,\n342,344,345,346,348,350,351,352,354,355,356,357,358,360,362,363,364,365,366,368,\n369,370,371,372,374,375,376,377,378,380,381,382,384,385,386,387,388,390,391,392,\n393,394,395,396,398,399,400,402,403,404,405,406,407,408,410,411,412,413,414,415,\n416,417,418,420,422,423,424,425,426,427,428,429,430,432,434,435,436,437,438,440,\n441,442,444,445,446,447,448,450,451,452,453,454,455,456,458,459,460,462,464,465,\n466,468,469,470,471,472,473,474,475,476,477,478,480,481,482,483,484,485,486,488,\n489,490,492,493,494,495,496,497,498,500,501,502,504,505,506,507,508,510,511,513,\n514,515,516,517,518,519,520,522,524,525,526,527,528,530,531,532,533,534,535,536,\n537,538,539,540,542,543,544,545,546,548,549,550,551,552,553,554,555,556,558,559,\n560,561,562,564,565,566,567,568,570,572,573,574,575,576,578,579,580,581,582,583,\n584,585,586,588,589,590,591,592,594,595,596,597,598,600,602,603,604,605,606,608,\n609,610,611,612,614,615,616,618,620,621,622,623,624,626,627,628,629,630,632,633,\n634,635,636,637,638,639,640,642,644,645,646,648,649,650,651,652,654,655,656,657,\n658,660,662,663,664,665,666,667,668,669,670,671,672,674,675,676,678,679,680,681,\n682,684,685,686,687,688,689,690,692,693,694,695,696,697,698,699,700,702,703,704,\n705,706,707,708,710,711,712,713,714,715,716,717,718,720,721,722,723,724,725,726,\n728,730,731,732,734,735,736,737,738,740,741,742,744,745,746,747,748,749,750,752,\n753,754,755,756,758,759,760,762,763,764,765,766,767,768,770,771,772,774,775,776,\n777,778,779,780,781,782,783,784,785,786,788,789,790,791,792,793,794,795,796,798,\n799,800,801,802,803,804,805,806,807,808,810,812,813,814,815,816,817,818,819,820,\n822,824,825,826,828,830,831,832,833,834,835,836,837,838,840,842,843,844,845,846,\n847,848,849,850,851,852,854,855,856,858,860,861,862,864,865,866,867,868,869,870,\n871,872,873,874,875,876,878,879,880,882,884,885,886,888,889,890,891,892,893,894,\n895,896,897,898,899,900,901,902,903,904,905,906,908,909,910,912,913,914,915,916,\n917,918,920,921,922,923,924,925,926,927,928,930,931,932,933,934,935,936,938,939,\n940,942,943,944,945,946,948,949,950,951,952,954,955,956,957,958,959,960,962,963,\n964,965,966,968,969,970,972,973,974,975,976,978,979,980,981,982,984,985,986,987,\n988,989,990,992,993,994,995,996,998,999,1000,1001,1002,1003,1004,1005,1006,1007,\n1008,1010,1011,1012,1014,1015,1016,1017,1018,1020,1022,1023,1025,1026,1027,1028,\n1029,1030,1032,1034,1035,1036,1037,1038,1040,1041,1042,1043,1044,1045,1046,1047,\n1048,1050,1052,1053,1054,1055,1056,1057,1058,1059,1060,1062,1064,1065,1066,1067,\n1068,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,\n1085,1086,1088,1089,1090,1092,1094,1095,1096,1098,1099,1100,1101,1102,1104,1105,\n1106,1107,1108,1110,1111,1112,1113,1114,1115,1116,1118,1119,1120,1121,1122,1124,\n1125,1126,1127,1128,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,\n1142,1143,1144,1145,1146,1147,1148,1149,1150,1152,1154,1155,1156,1157,1158,1159,\n1160,1161,1162,1164,1165,1166,1167,1168,1169,1170,1172,1173,1174,1175,1176,1177,\n1178,1179,1180,1182,1183,1184,1185,1186,1188,1189,1190,1191,1192,1194,1195,1196,\n1197,1198,1199,1200,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1214,\n1215,1216,1218,1219,1220,1221,1222,1224,1225,1226,1227,1228,1230,1232,1233,1234,\n1235,1236,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1250,1251,1252,\n1253,1254,1255,1256,1257,1258,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,\n1270,1271,1272,1273,1274,1275,1276,1278,1280,1281,1282,1284,1285,1286,1287,1288,\n1290,1292,1293,1294,1295,1296,1298,1299,1300,1302,1304,1305,1306,1308,1309,1310,\n1311,1312,1313,1314,1315,1316,1317,1318,1320,1322,1323,1324,1325,1326,1328,1329,\n1330,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,\n1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1362,1363,\n1364,1365,1366,1368,1370,1371,1372,1374,1375,1376,1377,1378,1379,1380,1382,1383,\n1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1400,\n1401,1402,1403,1404,1405,1406,1407,1408,1410,1411,1412,1413,1414,1415,1416,1417,\n1418,1419,1420,1421,1422,1424,1425,1426,1428,1430,1431,1432,1434,1435,1436,1437,\n1438,1440,1441,1442,1443,1444,1445,1446,1448,1449,1450,1452,1454,1455,1456,1457,\n1458,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1472,1473,1474,1475,\n1476,1477,1478,1479,1480,1482,1484,1485,1486,1488,1490,1491,1492,1494,1495,1496,\n1497,1498,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1512,1513,1514,\n1515,1516,1517,1518,1519,1520,1521,1522,1524,1525,1526,1527,1528,1529,1530,1532,\n1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1544,1545,1546,1547,1548,1550,\n1551,1552,1554,1555,1556,1557,1558,1560,1561,1562,1563,1564,1565,1566,1568,1569,\n1570,1572,1573,1574,1575,1576,1577,1578,1580,1581,1582,1584,1585,1586,1587,1588,\n1589,1590,1591,1592,1593,1594,1595,1596,1598,1599,1600,1602,1603,1604,1605,1606,\n1608,1610,1611,1612,1614,1615,1616,1617,1618,1620,1622,1623,1624,1625,1626,1628,\n1629,1630,1631,1632,1633,1634,1635,1636,1638,1639,1640,1641,1642,1643,1644,1645,\n1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1658,1659,1660,1661,1662,\n1664,1665,1666,1668,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1682,\n1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1694,1695,1696,1698,1700,1701,\n1702,1703,1704,1705,1706,1707,1708,1710,1711,1712,1713,1714,1715,1716,1717,1718,\n1719,1720,1722,1724,1725,1726,1727,1728,1729,1730,1731,1732,1734,1735,1736,1737,\n1738,1739,1740,1742,1743,1744,1745,1746,1748,1749,1750,1751,1752,1754,1755,1756,\n1757,1758,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,\n1774,1775,1776,1778,1779,1780,1781,1782,1784,1785,1786,1788,1790,1791,1792,1793,\n1794,1795,1796,1797,1798,1799,1800,1802,1803,1804,1805,1806,1807,1808,1809,1810,\n1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1824,1825,1826,1827,1828,\n1829,1830,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,\n1846,1848,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1862,1863,1864,\n1865,1866,1868,1869,1870,1872,1874,1875,1876,1878,1880,1881,1882,1883,1884,1885,\n1886,1887,1888,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1902,1903,\n1904,1905,1906,1908,1909,1910,1911,1912,1914,1915,1916,1917,1918,1919,1920,1921,\n1922,1923,1924,1925,1926,1927,1928,1929,1930,1932,1934,1935,1936,1937,1938,1939,\n1940,1941,1942,1943,1944,1945,1946,1947,1948,1950,1952,1953,1954,1955,1956,1957,\n1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1974,\n1975,1976,1977,1978,1980,1981,1982,1983,1984,1985,1986,1988,1989,1990,1991,1992,\n1994,1995,1996,1998,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2012,2013,\n2014,2015,2016,2018,2019,2020,2021,2022,2023,2024,2025,2026,2028,2030,2031,2032,\n2033,2034,2035,2036,2037,2038,2040,2041,2042,2043,2044,2045,2046,2047,2049,2050,\n2051,2052,2054,2055,2056,2057,2058,2059,2060,2061,2062,2064,2065,2066,2067,2068,\n2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2082,2084,2085,2086,2088,\n2090,2091,2092,2093,2094,2095,2096,2097,2098,2100,2101,2102,2103,2104,2105,2106,\n2107,2108,2109,2110,2112,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,\n2125,2126,2127,2128,2130,2132,2133,2134,2135,2136,2138,2139,2140,2142,2144,2145,\n2146,2147,2148,2149,2150,2151,2152,2154,2155,2156,2157,2158,2159,2160,2162,2163,\n2164,2165,2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2180,\n2181,2182,2183,2184,2185,2186,2188,2189,2190,2191,2192,2193,2194,2195,2196,2198,\n2199,2200,2201,2202,2204,2205,2206,2208,2210,2211,2212,2214,2215,2216,2217,2218,\n2219,2220,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,\n2236,2238,2240,2241,2242,2244,2245,2246,2247,2248,2249,2250,2252,2253,2254,2255,\n2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2268,2270,2271,2272,2274,\n2275,2276,2277,2278,2279,2280,2282,2283,2284,2285,2286,2288,2289,2290,2291,2292,\n2294,2295,2296,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2308,2310,2312,\n2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,\n2329,2330,2331,2332,2334,2335,2336,2337,2338,2340,2342,2343,2344,2345,2346,2348,\n2349,2350,2352,2353,2354,2355,2356,2358,2359,2360,2361,2362,2363,2364,2365,2366,\n2367,2368,2369,2370,2372,2373,2374,2375,2376,2378,2379,2380,2382,2384,2385,2386,\n2387,2388,2390,2391,2392,2394,2395,2396,2397,2398,2400,2402,2403,2404,2405,2406,\n2407,2408,2409,2410,2412,2413,2414,2415,2416,2418,2419,2420,2421,2422,2424,2425,\n2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2438,2439,2440,2442,2443,\n2444,2445,2446,2448,2449,2450,2451,2452,2453,2454,2455,2456,2457,2458,2460,2461,\n2462,2463,2464,2465,2466,2468,2469,2470,2471,2472,2474,2475,2476,2478,2479,2480,\n2481,2482,2483,2484,2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,\n2497,2498,2499,2500,2501,2502,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,\n2514,2515,2516,2517,2518,2519,2520,2522,2523,2524,2525,2526,2527,2528,2529,2530,\n2532,2533,2534,2535,2536,2537,2538,2540,2541,2542,2544,2545,2546,2547,2548,2550,\n2552,2553,2554,2555,2556,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,\n2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2580,2581,2582,2583,2584,2585,\n2586,2587,2588,2589,2590,2592,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,\n2604,2605,2606,2607,2608,2610,2611,2612,2613,2614,2615,2616,2618,2619,2620,2622,\n2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2634,2635,2636,2637,2638,2639,\n2640,2641,2642,2643,2644,2645,2646,2648,2649,2650,2651,2652,2653,2654,2655,2656,\n2658,2660,2661,2662,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,\n2678,2679,2680,2681,2682,2684,2685,2686,2688,2690,2691,2692,2694,2695,2696,2697,\n2698,2700,2701,2702,2703,2704,2705,2706,2708,2709,2710,2712,2714,2715,2716,2717,\n2718,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2732,2733,2734,2735,2736,\n2737,2738,2739,2740,2742,2743,2744,2745,2746,2747,2748,2750,2751,2752,2754,2755,\n2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2768,2769,2770,2771,2772,\n2773,2774,2775,2776,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2790,\n2792,2793,2794,2795,2796,2798,2799,2800,2802,2804,2805,2806,2807,2808,2810,2811,\n2812,2813,2814,2815,2816,2817,2818,2820,2821,2822,2823,2824,2825,2826,2827,2828,\n2829,2830,2831,2832,2834,2835,2836,2838,2839,2840,2841,2842,2844,2845,2846,2847,\n2848,2849,2850,2852,2853,2854,2855,2856,2858,2859,2860,2862,2863,2864,2865,2866,\n2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2880,2881,2882,2883,\n2884,2885,2886,2888,2889,2890,2891,2892,2893,2894,2895,2896,2898,2899,2900,2901,\n2902,2904,2905,2906,2907,2908,2910,2911,2912,2913,2914,2915,2916,2918,2919,2920,\n2921,2922,2923,2924,2925,2926,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,\n2938,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2954,2955,\n2956,2958,2959,2960,2961,2962,2964,2965,2966,2967,2968,2970,2972,2973,2974,2975,\n2976,2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,\n2992,2993,2994,2995,2996,2997,2998,3000);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n for i:=1 to 2533 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..2533] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,30,33,34,35,36,38,39,40,42,44,45,46,48,50,51,\n52,54,55,56,57,58,60,62,63,65,66,68,69,70,72,74,75,76,77,78,80,82,84,85,86,87,\n88,90,91,92,93,94,95,96,98,99,100,102,104,105,106,108,110,111,112,114,115,116,\n117,118,119,120,122,123,124,126,129,130,132,133,134,135,136,138,140,141,142,143,\n144,145,146,147,148,150,152,153,154,155,156,158,159,160,161,162,164,165,166,168,\n170,171,172,174,175,176,177,178,180,182,183,184,185,186,187,188,189,190,192,194,\n195,196,198,200,201,202,203,204,205,206,207,208,209,210,212,213,214,215,216,217,\n218,219,220,221,222,224,225,226,228,230,231,232,234,235,236,237,238,240,242,244,\n245,246,247,248,249,250,252,253,254,255,258,259,260,261,262,264,265,266,267,268,\n270,272,273,274,275,276,278,279,280,282,284,285,286,287,288,290,291,292,294,295,\n296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,315,316,318,319,\n320,321,322,323,324,325,326,327,328,329,330,332,333,334,335,336,338,339,340,341,\n342,344,345,346,348,350,351,352,354,355,356,357,358,360,362,363,364,365,366,368,\n369,370,371,372,374,375,376,377,378,380,381,382,384,385,386,387,388,390,391,392,\n393,394,395,396,398,399,400,402,403,404,405,406,407,408,410,411,412,413,414,415,\n416,417,418,420,422,423,424,425,426,427,428,429,430,432,434,435,436,437,438,440,\n441,442,444,445,446,447,448,450,451,452,453,454,455,456,458,459,460,462,464,465,\n466,468,469,470,471,472,473,474,475,476,477,478,480,481,482,483,484,485,486,488,\n489,490,492,493,494,495,496,497,498,500,501,502,504,505,506,507,508,510,511,513,\n514,515,516,517,518,519,520,522,524,525,526,527,528,530,531,532,533,534,535,536,\n537,538,539,540,542,543,544,545,546,548,549,550,551,552,553,554,555,556,558,559,\n560,561,562,564,565,566,567,568,570,572,573,574,575,576,578,579,580,581,582,583,\n584,585,586,588,589,590,591,592,594,595,596,597,598,600,602,603,604,605,606,608,\n609,610,611,612,614,615,616,618,620,621,622,623,624,626,627,628,629,630,632,633,\n634,635,636,637,638,639,640,642,644,645,646,648,649,650,651,652,654,655,656,657,\n658,660,662,663,664,665,666,667,668,669,670,671,672,674,675,676,678,679,680,681,\n682,684,685,686,687,688,689,690,692,693,694,695,696,697,698,699,700,702,703,704,\n705,706,707,708,710,711,712,713,714,715,716,717,718,720,721,722,723,724,725,726,\n728,730,731,732,734,735,736,737,738,740,741,742,744,745,746,747,748,749,750,752,\n753,754,755,756,758,759,760,762,763,764,765,766,767,768,770,771,772,774,775,776,\n777,778,779,780,781,782,783,784,785,786,788,789,790,791,792,793,794,795,796,798,\n799,800,801,802,803,804,805,806,807,808,810,812,813,814,815,816,817,818,819,820,\n822,824,825,826,828,830,831,832,833,834,835,836,837,838,840,842,843,844,845,846,\n847,848,849,850,851,852,854,855,856,858,860,861,862,864,865,866,867,868,869,870,\n871,872,873,874,875,876,878,879,880,882,884,885,886,888,889,890,891,892,893,894,\n895,896,897,898,899,900,901,902,903,904,905,906,908,909,910,912,913,914,915,916,\n917,918,920,921,922,923,924,925,926,927,928,930,931,932,933,934,935,936,938,939,\n940,942,943,944,945,946,948,949,950,951,952,954,955,956,957,958,959,960,962,963,\n964,965,966,968,969,970,972,973,974,975,976,978,979,980,981,982,984,985,986,987,\n988,989,990,992,993,994,995,996,998,999,1000,1001,1002,1003,1004,1005,1006,1007,\n1008,1010,1011,1012,1014,1015,1016,1017,1018,1020,1022,1023,1025,1026,1027,1028,\n1029,1030,1032,1034,1035,1036,1037,1038,1040,1041,1042,1043,1044,1045,1046,1047,\n1048,1050,1052,1053,1054,1055,1056,1057,1058,1059,1060,1062,1064,1065,1066,1067,\n1068,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,\n1085,1086,1088,1089,1090,1092,1094,1095,1096,1098,1099,1100,1101,1102,1104,1105,\n1106,1107,1108,1110,1111,1112,1113,1114,1115,1116,1118,1119,1120,1121,1122,1124,\n1125,1126,1127,1128,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,\n1142,1143,1144,1145,1146,1147,1148,1149,1150,1152,1154,1155,1156,1157,1158,1159,\n1160,1161,1162,1164,1165,1166,1167,1168,1169,1170,1172,1173,1174,1175,1176,1177,\n1178,1179,1180,1182,1183,1184,1185,1186,1188,1189,1190,1191,1192,1194,1195,1196,\n1197,1198,1199,1200,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1214,\n1215,1216,1218,1219,1220,1221,1222,1224,1225,1226,1227,1228,1230,1232,1233,1234,\n1235,1236,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1250,1251,1252,\n1253,1254,1255,1256,1257,1258,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,\n1270,1271,1272,1273,1274,1275,1276,1278,1280,1281,1282,1284,1285,1286,1287,1288,\n1290,1292,1293,1294,1295,1296,1298,1299,1300,1302,1304,1305,1306,1308,1309,1310,\n1311,1312,1313,1314,1315,1316,1317,1318,1320,1322,1323,1324,1325,1326,1328,1329,\n1330,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,\n1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1362,1363,\n1364,1365,1366,1368,1370,1371,1372,1374,1375,1376,1377,1378,1379,1380,1382,1383,\n1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1400,\n1401,1402,1403,1404,1405,1406,1407,1408,1410,1411,1412,1413,1414,1415,1416,1417,\n1418,1419,1420,1421,1422,1424,1425,1426,1428,1430,1431,1432,1434,1435,1436,1437,\n1438,1440,1441,1442,1443,1444,1445,1446,1448,1449,1450,1452,1454,1455,1456,1457,\n1458,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1472,1473,1474,1475,\n1476,1477,1478,1479,1480,1482,1484,1485,1486,1488,1490,1491,1492,1494,1495,1496,\n1497,1498,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1512,1513,1514,\n1515,1516,1517,1518,1519,1520,1521,1522,1524,1525,1526,1527,1528,1529,1530,1532,\n1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1544,1545,1546,1547,1548,1550,\n1551,1552,1554,1555,1556,1557,1558,1560,1561,1562,1563,1564,1565,1566,1568,1569,\n1570,1572,1573,1574,1575,1576,1577,1578,1580,1581,1582,1584,1585,1586,1587,1588,\n1589,1590,1591,1592,1593,1594,1595,1596,1598,1599,1600,1602,1603,1604,1605,1606,\n1608,1610,1611,1612,1614,1615,1616,1617,1618,1620,1622,1623,1624,1625,1626,1628,\n1629,1630,1631,1632,1633,1634,1635,1636,1638,1639,1640,1641,1642,1643,1644,1645,\n1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1658,1659,1660,1661,1662,\n1664,1665,1666,1668,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1682,\n1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1694,1695,1696,1698,1700,1701,\n1702,1703,1704,1705,1706,1707,1708,1710,1711,1712,1713,1714,1715,1716,1717,1718,\n1719,1720,1722,1724,1725,1726,1727,1728,1729,1730,1731,1732,1734,1735,1736,1737,\n1738,1739,1740,1742,1743,1744,1745,1746,1748,1749,1750,1751,1752,1754,1755,1756,\n1757,1758,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,\n1774,1775,1776,1778,1779,1780,1781,1782,1784,1785,1786,1788,1790,1791,1792,1793,\n1794,1795,1796,1797,1798,1799,1800,1802,1803,1804,1805,1806,1807,1808,1809,1810,\n1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1824,1825,1826,1827,1828,\n1829,1830,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,\n1846,1848,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1862,1863,1864,\n1865,1866,1868,1869,1870,1872,1874,1875,1876,1878,1880,1881,1882,1883,1884,1885,\n1886,1887,1888,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1902,1903,\n1904,1905,1906,1908,1909,1910,1911,1912,1914,1915,1916,1917,1918,1919,1920,1921,\n1922,1923,1924,1925,1926,1927,1928,1929,1930,1932,1934,1935,1936,1937,1938,1939,\n1940,1941,1942,1943,1944,1945,1946,1947,1948,1950,1952,1953,1954,1955,1956,1957,\n1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1974,\n1975,1976,1977,1978,1980,1981,1982,1983,1984,1985,1986,1988,1989,1990,1991,1992,\n1994,1995,1996,1998,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2012,2013,\n2014,2015,2016,2018,2019,2020,2021,2022,2023,2024,2025,2026,2028,2030,2031,2032,\n2033,2034,2035,2036,2037,2038,2040,2041,2042,2043,2044,2045,2046,2047,2049,2050,\n2051,2052,2054,2055,2056,2057,2058,2059,2060,2061,2062,2064,2065,2066,2067,2068,\n2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2082,2084,2085,2086,2088,\n2090,2091,2092,2093,2094,2095,2096,2097,2098,2100,2101,2102,2103,2104,2105,2106,\n2107,2108,2109,2110,2112,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,\n2125,2126,2127,2128,2130,2132,2133,2134,2135,2136,2138,2139,2140,2142,2144,2145,\n2146,2147,2148,2149,2150,2151,2152,2154,2155,2156,2157,2158,2159,2160,2162,2163,\n2164,2165,2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2180,\n2181,2182,2183,2184,2185,2186,2188,2189,2190,2191,2192,2193,2194,2195,2196,2198,\n2199,2200,2201,2202,2204,2205,2206,2208,2210,2211,2212,2214,2215,2216,2217,2218,\n2219,2220,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,\n2236,2238,2240,2241,2242,2244,2245,2246,2247,2248,2249,2250,2252,2253,2254,2255,\n2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2268,2270,2271,2272,2274,\n2275,2276,2277,2278,2279,2280,2282,2283,2284,2285,2286,2288,2289,2290,2291,2292,\n2294,2295,2296,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2308,2310,2312,\n2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,\n2329,2330,2331,2332,2334,2335,2336,2337,2338,2340,2342,2343,2344,2345,2346,2348,\n2349,2350,2352,2353,2354,2355,2356,2358,2359,2360,2361,2362,2363,2364,2365,2366,\n2367,2368,2369,2370,2372,2373,2374,2375,2376,2378,2379,2380,2382,2384,2385,2386,\n2387,2388,2390,2391,2392,2394,2395,2396,2397,2398,2400,2402,2403,2404,2405,2406,\n2407,2408,2409,2410,2412,2413,2414,2415,2416,2418,2419,2420,2421,2422,2424,2425,\n2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2438,2439,2440,2442,2443,\n2444,2445,2446,2448,2449,2450,2451,2452,2453,2454,2455,2456,2457,2458,2460,2461,\n2462,2463,2464,2465,2466,2468,2469,2470,2471,2472,2474,2475,2476,2478,2479,2480,\n2481,2482,2483,2484,2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,\n2497,2498,2499,2500,2501,2502,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,\n2514,2515,2516,2517,2518,2519,2520,2522,2523,2524,2525,2526,2527,2528,2529,2530,\n2532,2533,2534,2535,2536,2537,2538,2540,2541,2542,2544,2545,2546,2547,2548,2550,\n2552,2553,2554,2555,2556,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,\n2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2580,2581,2582,2583,2584,2585,\n2586,2587,2588,2589,2590,2592,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,\n2604,2605,2606,2607,2608,2610,2611,2612,2613,2614,2615,2616,2618,2619,2620,2622,\n2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2634,2635,2636,2637,2638,2639,\n2640,2641,2642,2643,2644,2645,2646,2648,2649,2650,2651,2652,2653,2654,2655,2656,\n2658,2660,2661,2662,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,\n2678,2679,2680,2681,2682,2684,2685,2686,2688,2690,2691,2692,2694,2695,2696,2697,\n2698,2700,2701,2702,2703,2704,2705,2706,2708,2709,2710,2712,2714,2715,2716,2717,\n2718,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2732,2733,2734,2735,2736,\n2737,2738,2739,2740,2742,2743,2744,2745,2746,2747,2748,2750,2751,2752,2754,2755,\n2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2768,2769,2770,2771,2772,\n2773,2774,2775,2776,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2790,\n2792,2793,2794,2795,2796,2798,2799,2800,2802,2804,2805,2806,2807,2808,2810,2811,\n2812,2813,2814,2815,2816,2817,2818,2820,2821,2822,2823,2824,2825,2826,2827,2828,\n2829,2830,2831,2832,2834,2835,2836,2838,2839,2840,2841,2842,2844,2845,2846,2847,\n2848,2849,2850,2852,2853,2854,2855,2856,2858,2859,2860,2862,2863,2864,2865,2866,\n2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2880,2881,2882,2883,\n2884,2885,2886,2888,2889,2890,2891,2892,2893,2894,2895,2896,2898,2899,2900,2901,\n2902,2904,2905,2906,2907,2908,2910,2911,2912,2913,2914,2915,2916,2918,2919,2920,\n2921,2922,2923,2924,2925,2926,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,\n2938,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2954,2955,\n2956,2958,2959,2960,2961,2962,2964,2965,2966,2967,2968,2970,2972,2973,2974,2975,\n2976,2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,\n2992,2993,2994,2995,2996,2997,2998,3000);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n=1 then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 2533 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..2533] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,30,33,34,35,36,38,39,40,42,44,45,46,48,50,51,\n52,54,55,56,57,58,60,62,63,65,66,68,69,70,72,74,75,76,77,78,80,82,84,85,86,87,\n88,90,91,92,93,94,95,96,98,99,100,102,104,105,106,108,110,111,112,114,115,116,\n117,118,119,120,122,123,124,126,129,130,132,133,134,135,136,138,140,141,142,143,\n144,145,146,147,148,150,152,153,154,155,156,158,159,160,161,162,164,165,166,168,\n170,171,172,174,175,176,177,178,180,182,183,184,185,186,187,188,189,190,192,194,\n195,196,198,200,201,202,203,204,205,206,207,208,209,210,212,213,214,215,216,217,\n218,219,220,221,222,224,225,226,228,230,231,232,234,235,236,237,238,240,242,244,\n245,246,247,248,249,250,252,253,254,255,258,259,260,261,262,264,265,266,267,268,\n270,272,273,274,275,276,278,279,280,282,284,285,286,287,288,290,291,292,294,295,\n296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,315,316,318,319,\n320,321,322,323,324,325,326,327,328,329,330,332,333,334,335,336,338,339,340,341,\n342,344,345,346,348,350,351,352,354,355,356,357,358,360,362,363,364,365,366,368,\n369,370,371,372,374,375,376,377,378,380,381,382,384,385,386,387,388,390,391,392,\n393,394,395,396,398,399,400,402,403,404,405,406,407,408,410,411,412,413,414,415,\n416,417,418,420,422,423,424,425,426,427,428,429,430,432,434,435,436,437,438,440,\n441,442,444,445,446,447,448,450,451,452,453,454,455,456,458,459,460,462,464,465,\n466,468,469,470,471,472,473,474,475,476,477,478,480,481,482,483,484,485,486,488,\n489,490,492,493,494,495,496,497,498,500,501,502,504,505,506,507,508,510,511,513,\n514,515,516,517,518,519,520,522,524,525,526,527,528,530,531,532,533,534,535,536,\n537,538,539,540,542,543,544,545,546,548,549,550,551,552,553,554,555,556,558,559,\n560,561,562,564,565,566,567,568,570,572,573,574,575,576,578,579,580,581,582,583,\n584,585,586,588,589,590,591,592,594,595,596,597,598,600,602,603,604,605,606,608,\n609,610,611,612,614,615,616,618,620,621,622,623,624,626,627,628,629,630,632,633,\n634,635,636,637,638,639,640,642,644,645,646,648,649,650,651,652,654,655,656,657,\n658,660,662,663,664,665,666,667,668,669,670,671,672,674,675,676,678,679,680,681,\n682,684,685,686,687,688,689,690,692,693,694,695,696,697,698,699,700,702,703,704,\n705,706,707,708,710,711,712,713,714,715,716,717,718,720,721,722,723,724,725,726,\n728,730,731,732,734,735,736,737,738,740,741,742,744,745,746,747,748,749,750,752,\n753,754,755,756,758,759,760,762,763,764,765,766,767,768,770,771,772,774,775,776,\n777,778,779,780,781,782,783,784,785,786,788,789,790,791,792,793,794,795,796,798,\n799,800,801,802,803,804,805,806,807,808,810,812,813,814,815,816,817,818,819,820,\n822,824,825,826,828,830,831,832,833,834,835,836,837,838,840,842,843,844,845,846,\n847,848,849,850,851,852,854,855,856,858,860,861,862,864,865,866,867,868,869,870,\n871,872,873,874,875,876,878,879,880,882,884,885,886,888,889,890,891,892,893,894,\n895,896,897,898,899,900,901,902,903,904,905,906,908,909,910,912,913,914,915,916,\n917,918,920,921,922,923,924,925,926,927,928,930,931,932,933,934,935,936,938,939,\n940,942,943,944,945,946,948,949,950,951,952,954,955,956,957,958,959,960,962,963,\n964,965,966,968,969,970,972,973,974,975,976,978,979,980,981,982,984,985,986,987,\n988,989,990,992,993,994,995,996,998,999,1000,1001,1002,1003,1004,1005,1006,1007,\n1008,1010,1011,1012,1014,1015,1016,1017,1018,1020,1022,1023,1025,1026,1027,1028,\n1029,1030,1032,1034,1035,1036,1037,1038,1040,1041,1042,1043,1044,1045,1046,1047,\n1048,1050,1052,1053,1054,1055,1056,1057,1058,1059,1060,1062,1064,1065,1066,1067,\n1068,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,\n1085,1086,1088,1089,1090,1092,1094,1095,1096,1098,1099,1100,1101,1102,1104,1105,\n1106,1107,1108,1110,1111,1112,1113,1114,1115,1116,1118,1119,1120,1121,1122,1124,\n1125,1126,1127,1128,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,\n1142,1143,1144,1145,1146,1147,1148,1149,1150,1152,1154,1155,1156,1157,1158,1159,\n1160,1161,1162,1164,1165,1166,1167,1168,1169,1170,1172,1173,1174,1175,1176,1177,\n1178,1179,1180,1182,1183,1184,1185,1186,1188,1189,1190,1191,1192,1194,1195,1196,\n1197,1198,1199,1200,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1214,\n1215,1216,1218,1219,1220,1221,1222,1224,1225,1226,1227,1228,1230,1232,1233,1234,\n1235,1236,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1250,1251,1252,\n1253,1254,1255,1256,1257,1258,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,\n1270,1271,1272,1273,1274,1275,1276,1278,1280,1281,1282,1284,1285,1286,1287,1288,\n1290,1292,1293,1294,1295,1296,1298,1299,1300,1302,1304,1305,1306,1308,1309,1310,\n1311,1312,1313,1314,1315,1316,1317,1318,1320,1322,1323,1324,1325,1326,1328,1329,\n1330,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,\n1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1362,1363,\n1364,1365,1366,1368,1370,1371,1372,1374,1375,1376,1377,1378,1379,1380,1382,1383,\n1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1400,\n1401,1402,1403,1404,1405,1406,1407,1408,1410,1411,1412,1413,1414,1415,1416,1417,\n1418,1419,1420,1421,1422,1424,1425,1426,1428,1430,1431,1432,1434,1435,1436,1437,\n1438,1440,1441,1442,1443,1444,1445,1446,1448,1449,1450,1452,1454,1455,1456,1457,\n1458,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1472,1473,1474,1475,\n1476,1477,1478,1479,1480,1482,1484,1485,1486,1488,1490,1491,1492,1494,1495,1496,\n1497,1498,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1512,1513,1514,\n1515,1516,1517,1518,1519,1520,1521,1522,1524,1525,1526,1527,1528,1529,1530,1532,\n1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1544,1545,1546,1547,1548,1550,\n1551,1552,1554,1555,1556,1557,1558,1560,1561,1562,1563,1564,1565,1566,1568,1569,\n1570,1572,1573,1574,1575,1576,1577,1578,1580,1581,1582,1584,1585,1586,1587,1588,\n1589,1590,1591,1592,1593,1594,1595,1596,1598,1599,1600,1602,1603,1604,1605,1606,\n1608,1610,1611,1612,1614,1615,1616,1617,1618,1620,1622,1623,1624,1625,1626,1628,\n1629,1630,1631,1632,1633,1634,1635,1636,1638,1639,1640,1641,1642,1643,1644,1645,\n1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1658,1659,1660,1661,1662,\n1664,1665,1666,1668,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1682,\n1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1694,1695,1696,1698,1700,1701,\n1702,1703,1704,1705,1706,1707,1708,1710,1711,1712,1713,1714,1715,1716,1717,1718,\n1719,1720,1722,1724,1725,1726,1727,1728,1729,1730,1731,1732,1734,1735,1736,1737,\n1738,1739,1740,1742,1743,1744,1745,1746,1748,1749,1750,1751,1752,1754,1755,1756,\n1757,1758,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,\n1774,1775,1776,1778,1779,1780,1781,1782,1784,1785,1786,1788,1790,1791,1792,1793,\n1794,1795,1796,1797,1798,1799,1800,1802,1803,1804,1805,1806,1807,1808,1809,1810,\n1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1824,1825,1826,1827,1828,\n1829,1830,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,\n1846,1848,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1862,1863,1864,\n1865,1866,1868,1869,1870,1872,1874,1875,1876,1878,1880,1881,1882,1883,1884,1885,\n1886,1887,1888,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1902,1903,\n1904,1905,1906,1908,1909,1910,1911,1912,1914,1915,1916,1917,1918,1919,1920,1921,\n1922,1923,1924,1925,1926,1927,1928,1929,1930,1932,1934,1935,1936,1937,1938,1939,\n1940,1941,1942,1943,1944,1945,1946,1947,1948,1950,1952,1953,1954,1955,1956,1957,\n1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1974,\n1975,1976,1977,1978,1980,1981,1982,1983,1984,1985,1986,1988,1989,1990,1991,1992,\n1994,1995,1996,1998,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2012,2013,\n2014,2015,2016,2018,2019,2020,2021,2022,2023,2024,2025,2026,2028,2030,2031,2032,\n2033,2034,2035,2036,2037,2038,2040,2041,2042,2043,2044,2045,2046,2047,2049,2050,\n2051,2052,2054,2055,2056,2057,2058,2059,2060,2061,2062,2064,2065,2066,2067,2068,\n2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2082,2084,2085,2086,2088,\n2090,2091,2092,2093,2094,2095,2096,2097,2098,2100,2101,2102,2103,2104,2105,2106,\n2107,2108,2109,2110,2112,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,\n2125,2126,2127,2128,2130,2132,2133,2134,2135,2136,2138,2139,2140,2142,2144,2145,\n2146,2147,2148,2149,2150,2151,2152,2154,2155,2156,2157,2158,2159,2160,2162,2163,\n2164,2165,2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2180,\n2181,2182,2183,2184,2185,2186,2188,2189,2190,2191,2192,2193,2194,2195,2196,2198,\n2199,2200,2201,2202,2204,2205,2206,2208,2210,2211,2212,2214,2215,2216,2217,2218,\n2219,2220,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,\n2236,2238,2240,2241,2242,2244,2245,2246,2247,2248,2249,2250,2252,2253,2254,2255,\n2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2268,2270,2271,2272,2274,\n2275,2276,2277,2278,2279,2280,2282,2283,2284,2285,2286,2288,2289,2290,2291,2292,\n2294,2295,2296,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2308,2310,2312,\n2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,\n2329,2330,2331,2332,2334,2335,2336,2337,2338,2340,2342,2343,2344,2345,2346,2348,\n2349,2350,2352,2353,2354,2355,2356,2358,2359,2360,2361,2362,2363,2364,2365,2366,\n2367,2368,2369,2370,2372,2373,2374,2375,2376,2378,2379,2380,2382,2384,2385,2386,\n2387,2388,2390,2391,2392,2394,2395,2396,2397,2398,2400,2402,2403,2404,2405,2406,\n2407,2408,2409,2410,2412,2413,2414,2415,2416,2418,2419,2420,2421,2422,2424,2425,\n2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2438,2439,2440,2442,2443,\n2444,2445,2446,2448,2449,2450,2451,2452,2453,2454,2455,2456,2457,2458,2460,2461,\n2462,2463,2464,2465,2466,2468,2469,2470,2471,2472,2474,2475,2476,2478,2479,2480,\n2481,2482,2483,2484,2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,\n2497,2498,2499,2500,2501,2502,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,\n2514,2515,2516,2517,2518,2519,2520,2522,2523,2524,2525,2526,2527,2528,2529,2530,\n2532,2533,2534,2535,2536,2537,2538,2540,2541,2542,2544,2545,2546,2547,2548,2550,\n2552,2553,2554,2555,2556,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,\n2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2580,2581,2582,2583,2584,2585,\n2586,2587,2588,2589,2590,2592,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,\n2604,2605,2606,2607,2608,2610,2611,2612,2613,2614,2615,2616,2618,2619,2620,2622,\n2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2634,2635,2636,2637,2638,2639,\n2640,2641,2642,2643,2644,2645,2646,2648,2649,2650,2651,2652,2653,2654,2655,2656,\n2658,2660,2661,2662,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,\n2678,2679,2680,2681,2682,2684,2685,2686,2688,2690,2691,2692,2694,2695,2696,2697,\n2698,2700,2701,2702,2703,2704,2705,2706,2708,2709,2710,2712,2714,2715,2716,2717,\n2718,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2732,2733,2734,2735,2736,\n2737,2738,2739,2740,2742,2743,2744,2745,2746,2747,2748,2750,2751,2752,2754,2755,\n2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2768,2769,2770,2771,2772,\n2773,2774,2775,2776,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2790,\n2792,2793,2794,2795,2796,2798,2799,2800,2802,2804,2805,2806,2807,2808,2810,2811,\n2812,2813,2814,2815,2816,2817,2818,2820,2821,2822,2823,2824,2825,2826,2827,2828,\n2829,2830,2831,2832,2834,2835,2836,2838,2839,2840,2841,2842,2844,2845,2846,2847,\n2848,2849,2850,2852,2853,2854,2855,2856,2858,2859,2860,2862,2863,2864,2865,2866,\n2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2880,2881,2882,2883,\n2884,2885,2886,2888,2889,2890,2891,2892,2893,2894,2895,2896,2898,2899,2900,2901,\n2902,2904,2905,2906,2907,2908,2910,2911,2912,2913,2914,2915,2916,2918,2919,2920,\n2921,2922,2923,2924,2925,2926,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,\n2938,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2954,2955,\n2956,2958,2959,2960,2961,2962,2964,2965,2966,2967,2968,2970,2972,2973,2974,2975,\n2976,2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,\n2992,2993,2994,2995,2996,2997,2998,3000);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<6 then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 2533 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end\n else\n if a[i]>n then\n begin\n writeln(i-1);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..2533] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,30,33,34,35,36,38,39,40,42,44,45,46,48,50,51,\n52,54,55,56,57,58,60,62,63,65,66,68,69,70,72,74,75,76,77,78,80,82,84,85,86,87,\n88,90,91,92,93,94,95,96,98,99,100,102,104,105,106,108,110,111,112,114,115,116,\n117,118,119,120,122,123,124,126,129,130,132,133,134,135,136,138,140,141,142,143,\n144,145,146,147,148,150,152,153,154,155,156,158,159,160,161,162,164,165,166,168,\n170,171,172,174,175,176,177,178,180,182,183,184,185,186,187,188,189,190,192,194,\n195,196,198,200,201,202,203,204,205,206,207,208,209,210,212,213,214,215,216,217,\n218,219,220,221,222,224,225,226,228,230,231,232,234,235,236,237,238,240,242,244,\n245,246,247,248,249,250,252,253,254,255,258,259,260,261,262,264,265,266,267,268,\n270,272,273,274,275,276,278,279,280,282,284,285,286,287,288,290,291,292,294,295,\n296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,315,316,318,319,\n320,321,322,323,324,325,326,327,328,329,330,332,333,334,335,336,338,339,340,341,\n342,344,345,346,348,350,351,352,354,355,356,357,358,360,362,363,364,365,366,368,\n369,370,371,372,374,375,376,377,378,380,381,382,384,385,386,387,388,390,391,392,\n393,394,395,396,398,399,400,402,403,404,405,406,407,408,410,411,412,413,414,415,\n416,417,418,420,422,423,424,425,426,427,428,429,430,432,434,435,436,437,438,440,\n441,442,444,445,446,447,448,450,451,452,453,454,455,456,458,459,460,462,464,465,\n466,468,469,470,471,472,473,474,475,476,477,478,480,481,482,483,484,485,486,488,\n489,490,492,493,494,495,496,497,498,500,501,502,504,505,506,507,508,510,511,513,\n514,515,516,517,518,519,520,522,524,525,526,527,528,530,531,532,533,534,535,536,\n537,538,539,540,542,543,544,545,546,548,549,550,551,552,553,554,555,556,558,559,\n560,561,562,564,565,566,567,568,570,572,573,574,575,576,578,579,580,581,582,583,\n584,585,586,588,589,590,591,592,594,595,596,597,598,600,602,603,604,605,606,608,\n609,610,611,612,614,615,616,618,620,621,622,623,624,626,627,628,629,630,632,633,\n634,635,636,637,638,639,640,642,644,645,646,648,649,650,651,652,654,655,656,657,\n658,660,662,663,664,665,666,667,668,669,670,671,672,674,675,676,678,679,680,681,\n682,684,685,686,687,688,689,690,692,693,694,695,696,697,698,699,700,702,703,704,\n705,706,707,708,710,711,712,713,714,715,716,717,718,720,721,722,723,724,725,726,\n728,730,731,732,734,735,736,737,738,740,741,742,744,745,746,747,748,749,750,752,\n753,754,755,756,758,759,760,762,763,764,765,766,767,768,770,771,772,774,775,776,\n777,778,779,780,781,782,783,784,785,786,788,789,790,791,792,793,794,795,796,798,\n799,800,801,802,803,804,805,806,807,808,810,812,813,814,815,816,817,818,819,820,\n822,824,825,826,828,830,831,832,833,834,835,836,837,838,840,842,843,844,845,846,\n847,848,849,850,851,852,854,855,856,858,860,861,862,864,865,866,867,868,869,870,\n871,872,873,874,875,876,878,879,880,882,884,885,886,888,889,890,891,892,893,894,\n895,896,897,898,899,900,901,902,903,904,905,906,908,909,910,912,913,914,915,916,\n917,918,920,921,922,923,924,925,926,927,928,930,931,932,933,934,935,936,938,939,\n940,942,943,944,945,946,948,949,950,951,952,954,955,956,957,958,959,960,962,963,\n964,965,966,968,969,970,972,973,974,975,976,978,979,980,981,982,984,985,986,987,\n988,989,990,992,993,994,995,996,998,999,1000,1001,1002,1003,1004,1005,1006,1007,\n1008,1010,1011,1012,1014,1015,1016,1017,1018,1020,1022,1023,1025,1026,1027,1028,\n1029,1030,1032,1034,1035,1036,1037,1038,1040,1041,1042,1043,1044,1045,1046,1047,\n1048,1050,1052,1053,1054,1055,1056,1057,1058,1059,1060,1062,1064,1065,1066,1067,\n1068,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,\n1085,1086,1088,1089,1090,1092,1094,1095,1096,1098,1099,1100,1101,1102,1104,1105,\n1106,1107,1108,1110,1111,1112,1113,1114,1115,1116,1118,1119,1120,1121,1122,1124,\n1125,1126,1127,1128,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,\n1142,1143,1144,1145,1146,1147,1148,1149,1150,1152,1154,1155,1156,1157,1158,1159,\n1160,1161,1162,1164,1165,1166,1167,1168,1169,1170,1172,1173,1174,1175,1176,1177,\n1178,1179,1180,1182,1183,1184,1185,1186,1188,1189,1190,1191,1192,1194,1195,1196,\n1197,1198,1199,1200,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1214,\n1215,1216,1218,1219,1220,1221,1222,1224,1225,1226,1227,1228,1230,1232,1233,1234,\n1235,1236,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1250,1251,1252,\n1253,1254,1255,1256,1257,1258,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,\n1270,1271,1272,1273,1274,1275,1276,1278,1280,1281,1282,1284,1285,1286,1287,1288,\n1290,1292,1293,1294,1295,1296,1298,1299,1300,1302,1304,1305,1306,1308,1309,1310,\n1311,1312,1313,1314,1315,1316,1317,1318,1320,1322,1323,1324,1325,1326,1328,1329,\n1330,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,\n1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1362,1363,\n1364,1365,1366,1368,1370,1371,1372,1374,1375,1376,1377,1378,1379,1380,1382,1383,\n1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1400,\n1401,1402,1403,1404,1405,1406,1407,1408,1410,1411,1412,1413,1414,1415,1416,1417,\n1418,1419,1420,1421,1422,1424,1425,1426,1428,1430,1431,1432,1434,1435,1436,1437,\n1438,1440,1441,1442,1443,1444,1445,1446,1448,1449,1450,1452,1454,1455,1456,1457,\n1458,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1472,1473,1474,1475,\n1476,1477,1478,1479,1480,1482,1484,1485,1486,1488,1490,1491,1492,1494,1495,1496,\n1497,1498,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1512,1513,1514,\n1515,1516,1517,1518,1519,1520,1521,1522,1524,1525,1526,1527,1528,1529,1530,1532,\n1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1544,1545,1546,1547,1548,1550,\n1551,1552,1554,1555,1556,1557,1558,1560,1561,1562,1563,1564,1565,1566,1568,1569,\n1570,1572,1573,1574,1575,1576,1577,1578,1580,1581,1582,1584,1585,1586,1587,1588,\n1589,1590,1591,1592,1593,1594,1595,1596,1598,1599,1600,1602,1603,1604,1605,1606,\n1608,1610,1611,1612,1614,1615,1616,1617,1618,1620,1622,1623,1624,1625,1626,1628,\n1629,1630,1631,1632,1633,1634,1635,1636,1638,1639,1640,1641,1642,1643,1644,1645,\n1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1658,1659,1660,1661,1662,\n1664,1665,1666,1668,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1682,\n1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1694,1695,1696,1698,1700,1701,\n1702,1703,1704,1705,1706,1707,1708,1710,1711,1712,1713,1714,1715,1716,1717,1718,\n1719,1720,1722,1724,1725,1726,1727,1728,1729,1730,1731,1732,1734,1735,1736,1737,\n1738,1739,1740,1742,1743,1744,1745,1746,1748,1749,1750,1751,1752,1754,1755,1756,\n1757,1758,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,\n1774,1775,1776,1778,1779,1780,1781,1782,1784,1785,1786,1788,1790,1791,1792,1793,\n1794,1795,1796,1797,1798,1799,1800,1802,1803,1804,1805,1806,1807,1808,1809,1810,\n1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1824,1825,1826,1827,1828,\n1829,1830,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,\n1846,1848,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1862,1863,1864,\n1865,1866,1868,1869,1870,1872,1874,1875,1876,1878,1880,1881,1882,1883,1884,1885,\n1886,1887,1888,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1902,1903,\n1904,1905,1906,1908,1909,1910,1911,1912,1914,1915,1916,1917,1918,1919,1920,1921,\n1922,1923,1924,1925,1926,1927,1928,1929,1930,1932,1934,1935,1936,1937,1938,1939,\n1940,1941,1942,1943,1944,1945,1946,1947,1948,1950,1952,1953,1954,1955,1956,1957,\n1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1974,\n1975,1976,1977,1978,1980,1981,1982,1983,1984,1985,1986,1988,1989,1990,1991,1992,\n1994,1995,1996,1998,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2012,2013,\n2014,2015,2016,2018,2019,2020,2021,2022,2023,2024,2025,2026,2028,2030,2031,2032,\n2033,2034,2035,2036,2037,2038,2040,2041,2042,2043,2044,2045,2046,2047,2049,2050,\n2051,2052,2054,2055,2056,2057,2058,2059,2060,2061,2062,2064,2065,2066,2067,2068,\n2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2082,2084,2085,2086,2088,\n2090,2091,2092,2093,2094,2095,2096,2097,2098,2100,2101,2102,2103,2104,2105,2106,\n2107,2108,2109,2110,2112,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,\n2125,2126,2127,2128,2130,2132,2133,2134,2135,2136,2138,2139,2140,2142,2144,2145,\n2146,2147,2148,2149,2150,2151,2152,2154,2155,2156,2157,2158,2159,2160,2162,2163,\n2164,2165,2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2180,\n2181,2182,2183,2184,2185,2186,2188,2189,2190,2191,2192,2193,2194,2195,2196,2198,\n2199,2200,2201,2202,2204,2205,2206,2208,2210,2211,2212,2214,2215,2216,2217,2218,\n2219,2220,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,\n2236,2238,2240,2241,2242,2244,2245,2246,2247,2248,2249,2250,2252,2253,2254,2255,\n2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2268,2270,2271,2272,2274,\n2275,2276,2277,2278,2279,2280,2282,2283,2284,2285,2286,2288,2289,2290,2291,2292,\n2294,2295,2296,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2308,2310,2312,\n2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,\n2329,2330,2331,2332,2334,2335,2336,2337,2338,2340,2342,2343,2344,2345,2346,2348,\n2349,2350,2352,2353,2354,2355,2356,2358,2359,2360,2361,2362,2363,2364,2365,2366,\n2367,2368,2369,2370,2372,2373,2374,2375,2376,2378,2379,2380,2382,2384,2385,2386,\n2387,2388,2390,2391,2392,2394,2395,2396,2397,2398,2400,2402,2403,2404,2405,2406,\n2407,2408,2409,2410,2412,2413,2414,2415,2416,2418,2419,2420,2421,2422,2424,2425,\n2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2438,2439,2440,2442,2443,\n2444,2445,2446,2448,2449,2450,2451,2452,2453,2454,2455,2456,2457,2458,2460,2461,\n2462,2463,2464,2465,2466,2468,2469,2470,2471,2472,2474,2475,2476,2478,2479,2480,\n2481,2482,2483,2484,2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,\n2497,2498,2499,2500,2501,2502,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,\n2514,2515,2516,2517,2518,2519,2520,2522,2523,2524,2525,2526,2527,2528,2529,2530,\n2532,2533,2534,2535,2536,2537,2538,2540,2541,2542,2544,2545,2546,2547,2548,2550,\n2552,2553,2554,2555,2556,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,\n2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2580,2581,2582,2583,2584,2585,\n2586,2587,2588,2589,2590,2592,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,\n2604,2605,2606,2607,2608,2610,2611,2612,2613,2614,2615,2616,2618,2619,2620,2622,\n2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2634,2635,2636,2637,2638,2639,\n2640,2641,2642,2643,2644,2645,2646,2648,2649,2650,2651,2652,2653,2654,2655,2656,\n2658,2660,2661,2662,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,\n2678,2679,2680,2681,2682,2684,2685,2686,2688,2690,2691,2692,2694,2695,2696,2697,\n2698,2700,2701,2702,2703,2704,2705,2706,2708,2709,2710,2712,2714,2715,2716,2717,\n2718,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2732,2733,2734,2735,2736,\n2737,2738,2739,2740,2742,2743,2744,2745,2746,2747,2748,2750,2751,2752,2754,2755,\n2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2768,2769,2770,2771,2772,\n2773,2774,2775,2776,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2790,\n2792,2793,2794,2795,2796,2798,2799,2800,2802,2804,2805,2806,2807,2808,2810,2811,\n2812,2813,2814,2815,2816,2817,2818,2820,2821,2822,2823,2824,2825,2826,2827,2828,\n2829,2830,2831,2832,2834,2835,2836,2838,2839,2840,2841,2842,2844,2845,2846,2847,\n2848,2849,2850,2852,2853,2854,2855,2856,2858,2859,2860,2862,2863,2864,2865,2866,\n2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2880,2881,2882,2883,\n2884,2885,2886,2888,2889,2890,2891,2892,2893,2894,2895,2896,2898,2899,2900,2901,\n2902,2904,2905,2906,2907,2908,2910,2911,2912,2913,2914,2915,2916,2918,2919,2920,\n2921,2922,2923,2924,2925,2926,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,\n2938,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2954,2955,\n2956,2958,2959,2960,2961,2962,2964,2965,2966,2967,2968,2970,2972,2973,2974,2975,\n2976,2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,\n2992,2993,2994,2995,2996,2997,2998,3000);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<6 then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 2533 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "program Project11;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst\na:array[1..1375] of integer = (\n6,10,12,14,15,18,20,21,22,24,26,28,33,34,35,36,38,39, \n40,44,45,46,48,50,51,52,54,55,56,57,58,62,63,65,68,69, \n72,74,75,76,77,80,82,85,86,87,88,91,92,93,94,95,96,98, \n99,100,104,106,108,111,112,115,116,117,118,119,122,123,124,129,133,134, \n135,136,141,142,143,144,145,146,147,148,152,153,155,158,159,160,161,162, \n164,166,171,172,175,176,177,178,183,184,185,187,188,189,192,194,196,200, \n201,202,203,205,206,207,208,209,212,213,214,215,216,217,218,219,221,224, \n225,226,232,235,236,237,242,244,245,247,248,249,250,253,254,259,261,262, \n265,267,268,272,274,275,278,279,284,287,288,291,292,295,296,297,298,299, \n301,302,303,304,305,309,314,316,319,320,321,323,324,325,326,327,328,329, \n332,333,334,335,338,339,341,344,346,351,352,355,356,358,362,363,365,368, \n369,371,375,376,377,381,382,384,386,387,388,391,392,393,394,395,398,400, \n403,404,405,407,411,412,413,415,416,417,422,423,424,425,427,428,432,436, \n437,441,445,446,447,448,451,452,453,454,458,459,464,466,469,471,472,473, \n475,477,478,481,482,484,485,486,488,489,493,496,497,500,501,502,505,507, \n508,511,513,514,515,517,519,524,526,527,531,533,535,536,537,538,539,542, \n543,544,545,548,549,551,553,554,556,559,562,565,566,567,568,573,575,576, \n578,579,581,583,584,586,589,591,592,596,597,603,604,605,608,611,614,621, \n622,623,626,628,629,632,633,634,635,637,639,640,648,649,652,655,656,657, \n662,664,667,668,669,671,674,675,676,679,681,685,686,687,688,689,692,694, \n695,697,698,699,703,704,706,707,711,712,713,716,717,718,721,722,723,724, \n725,731,734,736,737,745,746,747,749,752,753,755,758,763,764,766,767,768, \n771,772,775,776,778,779,781,783,784,785,788,789,791,793,794,796,799,800, \n801,802,803,807,808,813,815,817,818,824,831,832,833,835,837,838,842,843, \n844,845,847,848,849,851,856,862,864,865,866,867,869,871,872,873,875,878, \n879,886,889,891,892,893,895,896,898,899,901,904,905,908,909,913,914,916, \n917,921,922,923,925,926,927,928,931,932,933,934,939,943,944,949,951,955, \n956,958,959,963,964,965,968,972,973,974,976,979,981,982,985,989,992,993, \n995,998,999,1000,1003,1004,1006,1007,1011,1016,1017,1018,1025,1027,1028,1029,1037,1041, \n1042,1043,1046,1047,1048,1052,1053,1055,1057,1058,1059,1067,1072,1073,1075,1076,1077,1079, \n1081,1082,1083,1084,1088,1089,1094,1096,1099,1101,1107,1108,1111,1112,1114,1115,1119,1121, \n1124,1125,1126,1127,1132,1133,1135,1136,1137,1138,1139,1141,1142,1143,1145,1147,1149,1152, \n1154,1156,1157,1159,1161,1165,1167,1168,1169,1172,1174,1175,1177,1179,1183,1184,1186,1189, \n1191,1192,1195,1198,1199,1202,1203,1205,1207,1208,1211,1214,1215,1216,1219,1225,1226,1227, \n1228,1233,1234,1238,1241,1243,1244,1247,1250,1251,1252,1253,1255,1256,1257,1261,1262,1263, \n1264,1267,1268,1269,1271,1273,1280,1282,1285,1286,1293,1294,1296,1299,1304,1306,1312,1313, \n1315,1317,1318,1322,1323,1324,1325,1328,1329,1333,1336,1337,1339,1341,1343,1345,1346,1347, \n1348,1349,1351,1352,1354,1355,1357,1359,1363,1366,1371,1372,1375,1376,1377,1379,1382,1383, \n1384,1385,1387,1388,1389,1391,1393,1396,1397,1401,1402,1403,1405,1408,1411,1412,1413,1415, \n1417,1418,1421,1424,1431,1432,1436,1437,1438,1441,1444,1445,1448,1454,1457,1458,1461,1465, \n1466,1467,1468,1469,1472,1473,1475,1477,1478,1486,1492,1497,1501,1502,1503,1504,1507,1509, \n1513,1514,1516,1517,1519,1521,1522,1525,1527,1528,1529,1532,1535,1536,1537,1538,1539,1541, \n1544,1546,1552,1555,1556,1557,1561,1563,1565,1568,1569,1573,1574,1576,1577,1585,1587,1588, \n1589,1591,1592,1593,1594,1600,1603,1604,1611,1616,1618,1622,1623,1625,1629,1631,1633,1636, \n1639,1641,1642,1643,1646,1647,1648,1649,1651,1654,1655,1658,1661,1664,1671,1673,1675,1676, \n1678,1679,1682,1684,1685,1687,1688,1689,1691,1696,1701,1703,1706,1707,1711,1712,1713,1714, \n1715,1717,1718,1719,1724,1726,1727,1728,1731,1732,1735,1737,1739,1744,1745,1751,1754,1756, \n1757,1761,1762,1763,1765,1766,1769,1772,1773,1774,1775,1779,1781,1784,1791,1792,1793,1795, \n1796,1797,1799,1803,1805,1807,1808,1809,1813,1814,1816,1817,1819,1821,1822,1825,1828,1829, \n1832,1835,1837,1838,1839,1841,1843,1844,1851,1852,1853,1856,1857,1858,1859,1863,1864,1865, \n1868,1874,1875,1882,1883,1888,1891,1893,1894,1895,1897,1899,1903,1906,1909,1912,1915,1916, \n1917,1919,1921,1922,1923,1927,1928,1929,1934,1936,1937,1939,1941,1942,1943,1944,1945,1948, \n1952,1954,1957,1959,1961,1963,1964,1966,1967,1969,1971,1975,1977,1981,1982,1983,1984,1985, \n1991,1994,1996,2000,2005,2007,2008,2009,2012,2018,2019,2021,2023,2025,2026,2031,2032,2033, \n2036,2038,2041,2042,2043,2045,2047,2049,2051,2056,2057,2059,2061,2062,2066,2071,2073,2075, \n2077,2078,2084,2092,2095,2096,2097,2098,2101,2102,2103,2104,2105,2107,2116,2117,2119,2122, \n2123,2125,2126,2127,2133,2138,2144,2147,2149,2151,2152,2155,2157,2159,2164,2165,2167,2168, \n2169,2171,2173,2174,2176,2177,2181,2182,2183,2186,2188,2189,2191,2192,2194,2195,2199,2201, \n2206,2215,2216,2217,2218,2219,2224,2225,2227,2228,2229,2231,2234,2241,2245,2246,2248,2249, \n2252,2253,2257,2258,2259,2263,2264,2271,2272,2276,2279,2283,2284,2285,2291,2299,2302,2303, \n2304,2305,2306,2307,2308,2312,2313,2315,2317,2319,2321,2323,2326,2327,2329,2335,2336,2342, \n2344,2348,2349,2353,2359,2361,2362,2363,2367,2368,2369,2372,2374,2375,2384,2386,2391,2395, \n2396,2402,2403,2404,2407,2413,2416,2419,2421,2425,2426,2427,2428,2429,2432,2433,2434,2435, \n2439,2443,2446,2449,2452,2453,2455,2456,2458,2461,2462,2463,2468,2469,2471,2474,2476,2479, \n2481,2483,2487,2488,2489,2491,2493,2495,2497,2498,2500,2501,2504,2507,2509,2511,2512,2513, \n2515,2517,2518,2519,2523,2524,2525,2527,2528,2529,2533,2536,2537,2545,2547,2554,2558,2559, \n2560,2561,2563,2564,2566,2567,2569,2571,2572,2573,2575,2577,2578,2581,2582,2587,2588,2589, \n2592,2594,2597,2599,2601,2602,2603,2605,2606,2608,2611,2612,2614,2615,2619,2623,2624,2627, \n2629,2631,2636,2637,2638,2641,2642,2643,2644,2645,2648,2649,2651,2653,2654,2656,2661,2662, \n2669,2672,2673,2675,2681,2692,2696,2701,2704,2705,2708,2721,2722,2723,2725,2727,2732,2733, \n2734,2735,2738,2743,2744,2746,2747,2752,2757,2759,2761,2762,2763,2764,2768,2771,2773,2776, \n2779,2781,2783,2785,2787,2792,2798,2799,2804,2807,2811,2813,2815,2816,2817,2818,2823,2824, \n2825,2827,2831,2836,2839,2841,2845,2846,2848,2853,2854,2855,2858,2859,2863,2864,2866,2867, \n2869,2872,2873,2875,2876,2878,2881,2883,2885,2888,2889,2891,2893,2894,2896,2899,2901,2902, \n2906,2908,2911,2913,2916,2918,2921,2923,2929,2931,2932,2933,2935,2936,2941,2942,2943,2944, \n2947,2949,2951,2956,2959,2962,2965,2966,2972,2973,2974,2977,2978,2979,2981,2983,2984,2986, \n2987,2989,2991,2993,2995,2997,2998);\n\nvar n,i:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n);\n if n<6 then\n begin\n writeln(0);\n exit;\n end;\n for i:=1 to 1375 do\n begin\n if a[i]=n then\n begin\n writeln(i);\n exit;\n end\n else\n if a[i]>n then\n begin\n writeln(i-1);\n exit;\n end;\n end;\nend."}, {"source_code": "var n,i,j,m,amount,k:word; a:array[1..3000] of boolean; tg:dword;\n b:array[1..430] of word;\nbegin\n read(n);\n fillchar(a,sizeof(a),true);\n a[1]:=false; tg:=n shr 1;\n for i:=2 to tg do\n if a[i] then\n begin\n inc(m);\n b[m]:=i;\n for j:=2 to n div i do a[i*j]:=false\n end;\n amount:=0;\n for i:=1 to m do\n for j:=1 to i-1 do\n begin\n tg:=b[i]*b[j];\n if tg>n then break\n else begin\n k:=0;\n repeat\n inc(k);\n if tg*k<=n then inc(amount)\n until tg*k>n\n end\n end;\n write(amount)\nend."}, {"source_code": "var n,i,j,m,amount,k:word; a:array[1..3000] of boolean; tg:dword;\n b:array[1..430] of word;\nbegin\n read(n);\n fillchar(a,sizeof(a),true);\n a[1]:=false; tg:=n shr 1;\n for i:=2 to tg do\n if a[i] then\n begin\n inc(m);\n b[m]:=i;\n for j:=2 to n div i do a[i*j]:=false\n end;\n amount:=0;\n for i:=1 to m do\n for j:=1 to i-1 do\n begin\n tg:=b[i]*b[j];\n if tg>n then break\n else begin\n k:=0;\n repeat\n inc(k);\n if (not a[k] or (a[k] and (k in [b[i],b[j]]))) and (tg*k<=n) then inc(amount)\n until tg*k>n\n end\n end;\n write(amount)\nend."}, {"source_code": "var\n dau:array[1..3000] of boolean;\n nt:array[1..3000] of longint;\n n,k,kq,i,j:longint;\nfunction check(x:longint):boolean;\nvar\n i:longint;\nbegin\n check:=true;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\nend;\nbegin\n readln(n);\n k:=0;\n for i:=2 to n do\n if check(i)=true then\n begin\n inc(k);\n nt[k]:=i;\n end;\n kq:=0;\n for i:=1 to k-1 do\n begin\n if nt[i]>n div 2 then break;\n for j:=i+1 to k do\n if nt[i]*nt[j]<=n then kq:=kq+n div (nt[i]*nt[j])\n else break;\n end;\n writeln(kq);\nend."}, {"source_code": "var\n dau:array[0..3000] of boolean;\n nt:array[0..3000] of longint;\n n,k,kq,i,j,m,x:longint;\nfunction check(x:longint):boolean;\nvar\n i:longint;\nbegin\n check:=true;\n for i:=2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\nend;\nfunction tknp(x,l,r:longint):longint;\nvar\n mid:longint;\nbegin\n tknp:=0;\n repeat\n mid:=(l+r) div 2;\n if x>nt[mid] then\n begin\n tknp:=mid;\n l:=mid+1;\n end\n else if x=nt[mid] then exit(mid)\n else r:=mid-1;\n until l>r;\nend;\nbegin\n readln(n);\n k:=0;\n for i:=2 to n do\n if check(i)=true then\n begin\n inc(k);\n nt[k]:=i;\n end;\n kq:=0;\n for i:=1 to k-1 do\n begin\n if nt[i]>n div 2 then break;\n for j:=i+1 to k do\n if nt[i]*nt[j]<=n then\n begin\n m:=n div (nt[i]*nt[j]);\n x:=tknp(m,1,k);\n if nt[x]>=nt[i] then inc(m);\n if nt[x]>=nt[j] then inc(m);\n m:=m-x;\n kq:=kq+m;\n end\n else break;\n end;\n writeln(kq);\nend."}, {"source_code": "var fi,fo: text;\n i,n: word;\n prime:array[1..3000] of word;\n dem: word;\n{--------------------------------}\nprocedure phantich(num: word);\nvar kt_ngto:array[1..3000] of boolean;\n u,m: word;\nbegin\n m:=num; u:=2; prime[num]:=0;\n fillchar(kt_ngto, sizeof(kt_ngto), false);\n repeat\n while num mod u <>0 do\n inc(u);\n if kt_ngto[u]=false then\n begin\n kt_ngto[u]:=true;\n inc(prime[m]);\n end;\n num:= num div u;\n until num=1;\nend;\n{--------------------------------}\nprocedure process;\nbegin\n dem:=0;\n readln(fi,n);\n for i:=6 to n do\n begin\n phantich(i);\n if prime[i]>=2 then inc(dem);\n end;\n writeln(fo,dem);\nend;\n{--------------------------------}\nbegin\n assign(fi,''); reset(fi);\n assign(fo,''); rewrite(fo);\n process;\n close(fi); close(fo);\nend.\n"}], "src_uid": "356666366625bc5358bc8b97c8d67bd5"} {"source_code": "var vp,vd,t,f,c,s,v,vs,vm:longint;\n x:double;\nbegin\n {assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n\n read(vp,vd,t,f,c);\n\n x:=vp*t; v:=vd-vp; vs:=vd+vp; vm:=vd*vp;\n\n if (v<=0) then begin\n writeln(0); exit;\n end;\n\n x:=x*vd/v;\n if (x>=c) then begin\n writeln(0);\n end else begin\n\n s:=0;\n while x=c then break;\n inc(kol);\n tim:=x/vd+f;\n x:=x+tim*vp;\n end;\n writeln(kol);\nend."}, {"source_code": "var vp,vd,t,f,c,ans:longint;\n time,x,s,tt:double;\nfunction try:longint;\n begin\n time:=c/vp-t;\n ans:=0;\n if (time<=0) or (vp>=vd) then exit(0);\n s:=t*vp;\n while true do\n begin\n x:=s/(vd-vp)*vp;\n s:=s+x;tt:=s/vd;\n if s>=c then exit(ans);\n ans:=ans+1;\n s:=s+(tt+f)*vp;\n end;\n end;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n writeln(try);\nend."}, {"source_code": "const eps=1e-8;\n\nvar\n x,tt,time,p,d,vp,vd,t,f,c:extended;\n ans:longint;\n\nbegin\n readln(vp,vd,t,f,c);\n time:=c/vp-t;\n if (time<=eps) or (vp>=vd) then\n begin writeln(ans); halt; end;\n p:=t*vp;\n while true do\n begin\n x:=p/(vd-vp)*vp;\n p:=p+x; tt:=p/vd;\n if p>=c then\n begin writeln(ans); halt; end;\n inc(ans); p:=p+(tt+f)*vp;\n end;\nend.\n\n\n\n\n"}, {"source_code": "var\n vp,vd,t,f,c,i:longint;\n p,d:double;\nbegin\n readln(vp,vd,t,f,c);\n p:=vp*t;\n d:=0;\n if vp>=vd then writeln(0) else begin\n p:=p+vp*p/(vd-vp);\n d:=p;\n if p>=c then writeln(0)\n else begin\n i:=0;\n while p= c) or (t1 < t2 + eps) then print(0);\n\n\tans := 0;\n\twhile true do begin\n\t\tl := 0;\n\t\tr := 1000;\n\t\ttt := 0;\n\t\tfor i := 1 to 1000 do begin\n\t\t\ttime := (l + r) / 2;\n\t\t\tif dp + p * time < dd + d * time then begin\n\t\t\t\ttt := time;\n\t\t\t\tr := time;\n\t\t\tend else\n\t\t\t\tl := time;\n\t\tend;\n\t\tdp := dp + p * tt;\n\t\tif c < dp + eps then print(ans);\n\t\tinc(ans);\n\t\ttime := dp / d + f;\n\t\tdp := dp + p * time;\n\tend;\nend.\n"}, {"source_code": "Var\n vp,vd,f,c,a,t,d,s: real;\n k: longint;\n \nBegin\n read(vp,vd,t,f,c);\n if((c/vp) <= (c/vd + t)) then\n begin\n write(0);\n exit;\n end\n else \n begin\n a := vp*t; k := 0;\n repeat\n s := a * vp / (vd - vp);\n a := a + s;\n if(a < c) then\n inc(k);\n a := a + (f*vp) + (vp * a / vd); \n until a >= c; \n end;\n write(k);\nEnd."}, {"source_code": "const fin='';\n fout='';\nvar vd,vp,t,f,c,s:longint;\nprocedure solve1;\nvar ff:text;\nbegin\n assign(ff,fin);reset(ff);\n read(ff,vp,vd,t,f,c);\n close(ff);\nend;\nprocedure solve2;\nvar sd,sp,l,r,mid:real;\nbegin\n sp:=vp*t;\n while sp=vp*mid+sp then r:=mid\n else l:=mid;\n until l-r>=-0.00005;\n sp:=sp+vp*r;if sp= s) then break; dec(m);\n final:= final + (final / vd + f) * vp;\n if (final >= s) then break;\n end;\n enough:= (m >= 0);\nend;\n \nprocedure reading;\nvar \n l , r , mid : longint; \nbegin\n read(vp , vd , t , f , s);\n l:= 0; r:= 10000;\n while (r - l > 1) do begin\n \tmid:= (l + r) shr 1;\n \tif (enough (mid)) then r:= mid else l:= mid;\n end;\n if (enough(l)) then writeln(l) else writeln(r); \nend; \n\nbegin\n reading;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp, vd, t, f, c, i:Integer;\nprocedure pob(l:extended);\nbegin\n l:=l+vp*(l/(vd-vp));\n if l >=c then\n Exit;\n Inc(i);\n l:=l+vp*(l/vd);\n l:=l+vp*f;\n pob(l);\nend;\nvar\nl:Extended;\nbegin\nread(vp, vd, t, f, c);\ni:=0;\nif vp>=vd then\n Writeln(0)\nelse\nbegin\nl:=vp*t;\npob(l);\nWriteln(i);\nend;\nreadln;readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, ans : integer;\n vp, vd, t, f, c : integer;\n ppos, dpos : extended;\n\nbegin\n read(vp, vd, t, f, c);\n ans := 0;\n if vd <= vp then begin\n writeln(0);\n readln;readln;\n halt;\n end;\n dpos := 0;\n ppos := t * vp;\n while ppos < c do begin\n ppos := ppos + (ppos - dpos) / (vd - vp) * vp;\n dpos := ppos;\n if ppos < c then\n inc(ans)\n else\n break;\n ppos := ppos + f * vp + dpos / vd * vp;\n dpos := 0;\n end;\n writeln(ans);\n readln;readln;\nend.\n"}, {"source_code": "var i,ans,l,k,n,m,d:longint;sd,sp,vp,x,vd,f,t,c,tp,tt:real;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (vp,vd,t,f,c);\ntp:=(c) / vp;\ntt:=t;\nsp:=vp*t;\nans:=0;\nwhile sp=sp) and (spsp) then\n begin\n sp:=sp-vp;\n sd:=sd-vd;\n tt:=tt-1;\n x:=(sp-sd)/(vd-vp);\n tt:=tt+x+f;\n sp:=sp+vp*f+x*vp+((x*vd+sd)/vd*vp);\n inc (ans);\n sd:=0;\n end;\n\n end;\nwrite (ans);\nend.\n"}, {"source_code": "var vp,vd,t,f,cc,ost,com,l,r,c:extended;\n res:longint;\n begin\n read(vp,vd,t,f,cc);\n if vp+(1e-10)>=vd then begin writeln(0); halt(0); end;\n ost:=t;\n com:=0;\n res:=0;\n while com-(1e-10)0 then\n begin\n com:=com+ost*vp;\n ost:=0;\n end\n else\n begin\n res:=res+1;\n ost:=f+com/vd;\n continue;\n end;\n\n l:=0;\n r:=10000;\n while l+(1e-7)l do begin\n inc(k);\n l:=(l*(1/vp+1/vd)+f)/(1/vp-1/vd);\n end;\n writeln(k);\n end;\n readln;\nend."}, {"source_code": "var\n vp,vd,f,t,d,c,res:integer;\n tp:extended;\nbegin\n readln(vp,vd,t,f,c);\n \n d:=vd-vp;\n \n if d <= 0\n then\n begin\n writeln('0');\n halt;\n end;\n \n res:=0;\n \n tp:=t*vp;\n tp:=tp+(tp/d)*vp;\n while tp=c \n\t\tthen begin write('0');exit;end\n\t\telse while x=vd\n then\n begin\n kol:=0;\n end\n else\n begin\n vo:=vd-vp;\n i:=t*vp; kol:=0;\n while true do\n begin\n if i>=c then break;\n i:=i+(i / vo)*vp;\n if i>=c then kol:=kol else inc(kol);\n i:=i+((i / vd)+f)*vp;\n end;\n end;\n writeln(kol);\nend.\n"}, {"source_code": "Var k,vp,vd,t,f,c:Longint;\n l:Real;\nBegin\n Readln (vp,vd,t,f,c);\n k:=0;\n l:=t*vp;\n If vp= v_d then begin\n writeln(0);\n exit;\n end;\n while x0 < c do begin\n x0 := x0+v_p*(x0/(v_d-v_p));\n if x0 >= c then break;\n res := res+1;\n x0 := x0+(x0/v_d)*v_p;\n x0 := x0+v_p*f;\n end;\n writeln(res);\nEnd.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar x,v1,v2,t,f,c:extended;\n i:longint;\nbegin\n read(v1,v2,t,f,c);\n if v1>=v2 then\n begin\n write(0);\n halt(0);\n end;\n\n x:=v1*t;\n x:=x+x*v1/(v2-v1);\n \n for i:=1 to 1000001 do\n begin\n if x>=c then\n begin\n write(i-1);\n halt(0);\n end;\n x:=x+x*v1/v2+f*v1;\n x:=x+x*v1/(v2-v1);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{R+,S+,Q+,I+,C+,M+,H+,O+}\n{$R-,S-,Q-,I-,C+,M-,H+,O-}\n\nuses\n SysUtils, Math;\n\nconst\n EPS : double = 1e-6;\n\nvar\n vp, vd, t, f, c, ans : longint;\n cur, tt : double;\n\nprocedure go();\nbegin\n write(ans);\n halt(0);\nend;\n \nbegin\n read(vp, vd, t, f, c);\n cur := vp * t;\n ans := 0;\n if (cur - c + EPS > 0) or (vp >= vd) then go();\n if (c - cur) / vp <= cur / (vd - vp) + EPS then go();\n while cur < c do begin\n tt := cur / (vd - vp);\n cur := cur + vp * tt;\n if cur - c + EPS > 0 then go();\n inc(ans);\n tt := cur / vd + f;\n cur := cur + vp * tt;\n end;\n go();\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses SysUtils;\n\nconst eps = 1e-6;\n\ntype int = integer;\n\nvar vg, vd, t, f, s, res: int;\nd, x: double;\n\nfunction bigger(a, b: double): boolean;\nbegin\n if (a > b) and (abs(a-b) > eps) then\n bigger:= true\n else\n bigger:= false\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n\n res:= 0;\n readln(vg);\n readln(vd);\n readln(t);\n readln(f);\n readln(s);\n if vd > vg then\n begin\n d:= vg*t;\n x:= d/(vd-vg)*vg+d;\n while bigger(s, x) do\n begin\n inc(res);\n d:= x+(x/vd+f)*vg;\n x:= d/(vd-vg)*vg+d\n end;\n end;\n write(res)\nend."}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\n\nuses\n SysUtils,\n Math;\n\nvar\n v1, v2, t, sdelta, dist, f, s, s1, t1, tnew, tlast: extended;\n k: int64;\n per: boolean;\n\nprocedure panic(x: int64);\nbegin\n write(x);\n halt(0);\nend;\n\nbegin\n {Reset(input, 'input.txt');\n Rewrite(output, 'output.txt'); }\n\n read(v2, v1, t, f, dist);\n if v1 <= v2 then\n panic(0);\n\n\n s := v2 * t;\n if s >= dist then\n panic(0);\n\n k := 0;\n\n WHile True do\n begin\n\n {t := s / (v1 - v2) * 2 + f + t;\n }\n s1 := s;\n s := s + (s / (v1 - v2))* v2;\n if s >= dist then panic(k);\n inc(k);\n s := s1 + (2 * s1 / (v1 - v2) + f) * v2;\n if s >= dist then panic(k);\n end;\n\nend.\n"}, {"source_code": "var\nkol,vp,vd,t,f,c:longint;\ndog,mesto:real;\nbegin\nreadln(vp);\nreadln(vd);\nreadln(t);\nreadln(f);\nreadln(c);\nmesto:=t*vp;\nif vp=c then break\n else begin\n dog:=mesto/(vd-vp);\n mesto:=dog*vd;\n if mesto>=c then break\n else begin\n mesto:=mesto+f*vp+vp*(mesto/vd);\n inc(kol);\n end;\n end;\nend;\nend;\nwriteln(kol);\nend."}, {"source_code": "Var a,b,c,d,n,i,j,k,l,m,t:extended;\nr:longint;\nBegin\nReadln(a);\nReadln(b);\nReadln(c);\nReadln(d);\nReadln(N);\nif a>=b then begin\n writeln(0);\n halt(0);\nend;\nt:=a*c;\ni:=0;\nr:=0;\nwhile t=n then begin\n writeln(r);\n halt(0);\n end;\n r:=r+1;\n i:=t;\n t:=t+(t/b)*a;\n t:=t+d*a;\nend;\nwriteln(r);\nend.\n\n\n"}, {"source_code": "var\n vp, vd, f, c, n: integer;{n --- счётчик драгоценностей} \n t, nach: real;{nach --- позиция принцессы}\nprocedure dognal;{дракон догоняет принцессу}\nbegin\n t := nach / (vd-vp);\n nach := nach + vp * t;\n if nach < c then\n n := n + 1;\nend;\nprocedure domoi;{дракон несёт драгоценность домой}\nbegin\n t := nach/vd + f;\n nach := nach + t * vp;\nend;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n nach := vp * t;\n if (vp >= vd) or (nach >= c) then n := 0\n else\n while nach < c do\n begin\n dognal; \n domoi; \n end;\n writeln(n);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar vp,vd,t,f,c:longint;f1,g:text;\nprocedure nhap;\nbegin\n assign(f1,fi);\n reset(f1);\n readln(f1,vp);readln(f1,vd);readln(f1,t);readln(f1,f);readln(f1,c);\n close(f1);\nend;\nprocedure xuli;\nvar dem:longint;s,t1:real;\nbegin\n s:=vp*t;dem:=0;\n while s=c then break;\n s:=s+vp*(f+t1);\n inc(dem);\n end;\n writeln(g,dem);\nend;\nprocedure xuat;\nbegin\n assign(g,fo);\n rewrite(g);\n if vp>=vd then writeln(g,0) else\n xuli;\n close(g);\nend;\nBEGIN\n nhap;\n xuat;\nEND."}, {"source_code": "Var vp,vd,t,f,c:extended;\n kil:longint;\n now:extended;\n xp,xd,tt:extended;\n\nBegin\n\nReadln(vp);\nReadln(vd);\nReadln(t);\nReadln(f);\nReadln(c);\n\nif c/vp<=c/vd+t then begin Writeln(0); halt; end;\n\nxp:=vp*t; xd:=0; kil:=0;\n\nWhile true do begin\n\ntt:=(xp-xd)/(vd-vp); if xp+tt*vp>=c then break;\n\nxp:=xp+tt*vp; inc(kil); xd:=xp; xp:=xp+vp*((xp/vd)*2+f);\n\nif xp>=c then break;\n\nend;\n\nWriteln(kil);\n\nEnd.\n\n\n\n\n\n\n"}, {"source_code": "var vp,vd,time,f:extended;\ncount:longint;\ncd,c:extended;\nbegin\nreadln(vp,vd,time,f,c);\ncount:=0;\nif (vd>vp) then\nbegin\n cd:=vd*vp*time/(vd-vp);\n while(cdb then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n function musk(a:longint):longint;\n var p,i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0; p:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=j downto 1 do if (c[i]=4) or (c[i]=7) then p:=10*p+c[i] ;\n musk:=p;\n end;\n\n\n\n\n\n{function diam(a,b:mas;n:longint):longint;\nvar i0,t,i,j,k:longint; kver:mas; sv:mas2;\n begin\n for i:=1 to n do for j:=1 to n-1 do\n if a[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=b[j]; end;\n for i:=1 to n do for j:=1 to n-1 do\n if b[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=a[j]; end;\n for i:=1 to n do write(kver[i],' ');writeln; writeln;\n for i:=1 to n do begin for j:=1 to kver[i] do write(i,'-',sv[i,j],' ');writeln; end;\n\nfor i0:=1 to 1 do\n begin for i:=1 to n do sm[i]:=false; for i:=1 to n do dist[i]:=1000;\n sm[i0]:=true; dist[i0]:=0; kol:=1;\n\n\n end;\n\n\n\ndiam:=t;\n end; }\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(vp,vd,t,f,c); timest[1]:=0;\n if vp>=vd then begin write(0); goto 1; end;\n koef:=vp/(vd-vp); {otshet - drakon}\n for i:=1 to 1000 do\n begin\n timedog[i]:=(timest[i]+t)*koef;\n timest[i+1]:=2*timedog[i]+f+timest[i];\n\n if timest[i]+timedog[i]+t>c/vp-eps then begin p:=i; break; end; ;\n end;\n writeln(p-1);\n { for i:=1 to 10 do writeln(timedog[i]:0:2,' ',timest[i]:0:2,' '); writeln;\n }\n\n 1: close(output);\nend.\n"}, {"source_code": "var sc, st, ss, st1, st2, st3: string;\n c1, c2, ch1, ch2: char;\n vp, vd, f, k, i, j, c, a, b, max, min: longint;\n s,sp,s1, l1,l2,l3: longint;\n cifr: boolean;\n mas: array [1..101] of integer;\n x,t, l: real;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n l:=0; k:=0;\n if vd<=vp then k:=0 else \n while l= c then\n begin\n write(kol);\n halt(0);\n end\n else\n begin\n inc(kol);\n s := s + (v * (f + a));\n end;\n end;\n\n\n\n write(kol);\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n eps = 1e-8;\n\nvar\n x, tall, vp, t, vd, f, c, pref: extended;\n ans: integer;\n\nbegin\n read(vp, vd, t, f, c);\n\n if vd <= vp then begin\n writeln(0);\n halt;\n end;\n\n c := c - t * vp;\n tall := c / vp;\n x := t * vp;\n \n x := x + vp * (x / (vd - vp));\n ans := 0;\n while x <= c + eps do begin\n inc(ans);\n pref := x;\n x := x + vp * (pref / vd);\n x := x + vp * f;\n x := x + vp * (x / (vd - vp));\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n vp,vd,t,f,c,k:longint;\n t1,s1:real;\nbegin\n readln(vp,vd,t,f,c);\n if vd>vp then\n begin\n t1:=vp*t/(vd-vp);\n s1:=t1*vd;\n if s1=vd then\n begin\n writeln(0);\n exit;\n end;\ns:=vp*t;\nwhile s=vy)or(aim<=nowx) then\nbegin\n writeln(0);\n exit;\nend;\nnowx:=nowx+(nowx/(vy-vx))*vx;\nwhile nowx\n \n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n MA 02110-1301, USA.\n \n \n}\n\nvar\n\tvp,vd,f,c,x:longint;\n\ts,t,te:double;\n\nbegin\n\tx:=0;\n\ts:=0;\n\treadln(vp);\n\treadln(vd);\n\treadln(t);\n\treadln(f);\n\treadln(c);\n\tif vp>=vd then writeln(0)\n\telse begin\n\t\twhile svp) then\nbegin\n cd:=vd*vp*t/(vd-vp);\n while(cdvp then\n repeat\n s:=(vd*tp)/(vd-vp);\n if s=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend.\n"}, {"source_code": "program contest_105;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar ans : longint;\n td,curS,t,Vp,Vd,f,c : extended;\n\nbegin\n readln(Vp);\n readln(Vd);\n readln(t);\n readln(f);\n readln(c);\n\n if (Vp >= Vd) then begin\n writeln('0');\n halt(0);\n end;\n\n ans := 0;\n\n while true do begin\n td := (t * Vp) / (Vd - Vp);\n curS := curS + td * Vd;\n if curS < c then begin\n inc(ans);\n t := 2*(curS/Vd)+f;\n end else break;\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "var\n ans,vp,vd,c,t,f:longint;\n tec:real;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n read(vp,vd,t,f,c);\n tec:=t*vp;\n if (tec>=c)or(vp>=vd) then begin\n write('0');\n halt(0);\n end;\n tec:=tec+tec*vp/(vd-vp);\n if tec>=c then begin\n write('0');\n halt(0);\n end;\n\n while tec=vd then writeln(0) else\n begin\n ans:=0;\n found:=false;\n l:=t*vp+vp*(t*vp/(vd-vp));\n while not found do\n begin\n found:=l-c>-eps;\n inc(ans);\n l1:=l;\n l1:=l1+vp*(l1/vd)+vp*f;\n l:=l1+vp*l1/(vd-vp);\n end;\n writeln(ans-1);\n end;\nend.\n"}, {"source_code": "var vp,vd,t,f,c,xp,xd,t1:real;\n ans:longint;\nbegin\nreadln(vp,vd,t,f,c);\nxp:=vp*t; xd:=0; ans:=0;\nif vd<>vp then t1:=xp/(vd-vp); //повернення назад+складання речей\nxp:=xp+vp*t1;\nif (xp>=c) or (vp>=vd) then begin write(0); halt; end;\nwhile xp=a) and (aa) \n then begin\n //kch:=kch+f;\n kch:=kch-1;\n a:=a-vp;\n m:=m-vd;\n x:=(a-m)/(vd-vp);\n //kch:=kch+m/vd;\n kch:=kch+x+f;\n //a:=a+vp*f+m/vd*vp;\n a:=a+vp*f+x*vp+((x*vd+m)/vd*vp);\n inc(s);\n m:=0;\n end;\n kch:=kch+1; \n end;\n writeln(s);\nend."}, {"source_code": "var vp,vd,t,f,c,res:integer;\n i:real;\nbegin\n//assign(input,'input.txt');assign(output,'output.txt');\nreadln(vp,vd,t,f,c);\nif vd<=vp then writeln(0)else\n begin\n res:=0;\n i:=t*vp;\n while i=vd then begin write(0); halt; end;\nx:=0; ans:=0;\nwhile true do\n begin\n y:=(vp*vp*t)/(vd-vp);\n x:=vp*t+y;\n //writeln(x);\n t:=t+x/vd+f+y/vp;\n if x>=c then break;\n inc(ans);\n end;\n write(ans);\nend."}, {"source_code": "var i,j,n,m: longint;\n x,y,vp,vd,t,f,c: real;\nbegin\n readln(vp);readln(vd);readln(t);readln(f);readln(c);\n if vp>=vd then\n begin\n writeln(0);exit;\n end;\n x:=(vp*t/(vd-vp))*vd;\n n:=0;\n while xvp then\n while i vp then begin\n p := t*vp;\n while p < c do begin\n p := p/(vd-vp)*vp + p;\n if p < c then begin\n inc(res);\n p := p + f*vp + p/vd*vp;\n end;\n end;\n end;\n write(res);\nend.\n "}, {"source_code": "var\n vp,vd,t,f,c,x,t1,v\t:\textended;\n ans\t\t\t:\tlongint;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(vp,vd,t,f,c);\n if (vp >= vd) then begin write(0); halt; end;\n x:=vp * t;\n ans:=0;\n while x < c do begin\n \tv:=vd - vp;\n \tx:=x + (x / v) * vp;\n \tif x >= c then break;\n \tinc(ans);\n \tt1:=(x / vd) + f;\n \tx:=x + (t1 * vp);\n end;\n write(ans);\nend."}, {"source_code": "var vp,vd,t,f:real;\ni:longint;\ncd,c:real;\nbegin\nreadln(vp,vd,t,f,c);\ni:=0;\nif (vd>vp) then\nbegin\n cd:=vd*vp*t/(vd-vp);\n while(cd= vd) then\n begin\n write(0);\n halt;\n end;\n\n ppos := tw * vp;\n k := 0;\n\n x := ppos / (vd - vp);\n ppos := ppos + (vp * x);\n\n while (ppos < len) do\n begin\n inc(k); //������� ���� �������������\n\n //��� ������ ������ �����, �������� ����\n ppos := ppos + vp * (x + fs);\n\n x := ppos / (vd - vp);\n ppos := ppos + (vp * x);\n end;\n\n write(k);\nend.\n\n\n{\nvd * x = vp * x + ppos;\nx * (vd - vp) = ppos\nx = ppos / (vd - vp);\n\n}"}, {"source_code": "var q,i,k,d,n,m:longint;\n vp,vd,t,f,c,s,l:extended;\nbegin\nread(vp,vd,t,f,c);\nk:=0;\nif t=0 then\nbegin\nif c<>0 then k:=1;\ns:=f*vp;\nend else\ns:=t*vp;\nl:=s;\nif vp=vd then begin WriteLn(0); exit; end;\n i:=0;\n r1:=0;\n r2:=vp*t;\n While r2=c) then break;\n ans:=ans+1;\n r2:=r2+i*vp;\n r2:=r2+(f+(r2/vd))*vp;\n end;\n WriteLn(ans:0:0);\n end.\n"}, {"source_code": "Type Slog = Record x, y, r : LongInt; end;\n\nvar i, j, k, l, N, Vp, Vz, T0, Tf, C : Real;\n Tpovratka, Predjeno: Real;\n Radijator : array [0..1005] of Slog;\n s, IntPart, DecPart, Naopak : String;\n minus : Boolean;\n t : Real;\n Resenje : Longint;\nbegin\n Readln(Vp);\n Readln(Vz);\n Readln(t0);\n Readln(Tf);\n Readln(C);\n\n if Vp >= Vz then begin Writeln(0); halt end;\n While True do\n Begin\n t := Vz*t0/(Vz-Vp);\n if T <= 0 then Begin\n Writeln(Resenje);\n halt;\n end;\n if Vp*t < c\n then Begin Inc(Resenje);end\n else Begin\n Writeln(Resenje);\n halt;\n end;\n\n Predjeno := Vp*t;\n c := c-Predjeno;\n tpovratka := Tpovratka + Predjeno/Vz;\n T0 := 2*Tpovratka + Tf;\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{R+,S+,Q+,I+,C+,M+,H+,O+}\n{$R-,S-,Q-,I-,C+,M-,H+,O-}\n\nuses\n SysUtils, Math;\n\nconst\n EPS : double = 1e-6;\n\nvar\n vp, vd, t, f, c, ans : longint;\n cur, tt : double;\n\nprocedure go();\nbegin\n write(ans);\n halt(0);\nend;\n \nbegin\n read(vp, vd, t, f, c);\n cur := vp * t;\n ans := 0;\n if (cur - c + EPS > 0) or (vp >= vd) then go();\n if (c - cur) / vp <= cur / (vd - vp) + EPS then go();\n while cur < c do begin\n tt := cur / (vd - vp);\n cur := cur + vp * tt;\n if cur - c + EPS > 0 then go();\n inc(ans);\n tt := cur / vd + f;\n cur := cur + vp * tt;\n end;\n go();\nend."}, {"source_code": "var v1,v2,f,c,ans : longint;\n t,x : extended;\nbegin\n\tread(v1,v2,t,f,c);\n\n\tif v1 >= v2 then begin\n\t\twriteln(0);\n\t\thalt(0);\n\tend;\n\n\tx := v1 * t;\n\tans := 0;\n\twhile x < c do begin\n\t\tt := x / (v2 - v1);\n\t\tx := x + v1 * t;\n\t\tif x < c then inc(ans);\n\t\tt := x / v2 + f;\n\t\tx := x + v1 * t;\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "var\n i,w:longint;\n v1,v2,f,t,c,j,k,s1,s2,t1,t2:extended;\nbegin\n readln(v1);\n readln(v2);\n readln(t);\n readln(f);\n readln(c);\n if (v1>=v2)or(v1*t>=c) then begin writeln(0); halt; end;\n s1:=v1*t;\n for i:=1 to 1000 do\n begin\n t2:=s1/(v2-v1); s1:=s1+v1*t2;\n if s1>=c then break else begin inc(w); t2:=f+s1/v2; s1:=s1+t2*v1; end;\n end;\n writeln(w);\nend.\n"}, {"source_code": "program pogon;\nvar Vp,Vd,t,f,c,i,Vdgn:integer;\n Tsum,t1,ostT:real;\n\nbegin\n readln(Vp,Vd,t,f,c);\n Vdgn:=Vd - Vp;\n Tsum:=c/Vp;\n ostT:=Tsum - t;\n i:=0;\n if Vdgn > 0 then begin\n t1:=t*vp/Vdgn;\n //writeln(OstT:3,t1:3);\n while ostT > 0 do begin\n if ostT > t1 then i:=i+1 else ostT:=0;\n ostT:=ostT - t1*2 - f;\n t1:=Vp*(Tsum - ostT)/Vdgn;\n //writeln(OstT:3,t1:3);\n end;\n end;\n writeln(i);\nend."}, {"source_code": "uses math;\nvar// s:array[1..100000]of longint;\n i,j,v1,v2,t,f,c,sum,dv:longint;\n s,ds:real;\nbegin\n read(v1,v2,t,f,c);\n if (v2<=v1)or(v1*t>=c) then\n begin\n write(0);\n halt(0);\n end;\n s:=v1*t;\n dv:=v2-v1;\n ds:=s;\n while s=c then\n continue;\n s:=s+(s/v2)*v1+f*v1;\n ds:=s;\n inc(sum);\n end;\n write(sum);\nend."}, {"source_code": "var vd,vp,c,t,f,j:longint;pd,pp,x:real;\nprocedure pobeg;\nbegin\n if pp>=c then exit;\n if vd=vp\n then if pp>pd then exit\n else x:=0\n else x:=(pp-pd)/(vd-vp);\n pp:=pp+(vp*x);\n if pp>=c then exit;\n inc(j);\n pd:=pp;\n x:=pd/vd;\n pp:=pp+(vp*(f+x));\n pd:=0;\n pobeg;\nend;\nbegin\n //assign(input, 'input.txt');reset(input);\n //assign(output, 'output.txt');rewrite(output);\n readln(vp,vd,t,f,c);\n if vd=vd) then begin\n writeln('0');\n halt(0);\n end;\n\n x:=t*vp;\n ans:=0;\n while (x=c) then begin\n x:=c;\n break;\n end;\n\n x:=xnew;\n time:=x/vd+f;\n x:=x+time*vp;\n inc(ans);\n end;\n\n writeln(ans);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar vp,vd,t,f,c:longint;\n v:longint;\n xd,xp:double;\n x:double;\n k:longint;\nbegin\n readln(vp,vd,t,f,c);\n if vp>=vd then writeln(0) else\n begin\n xp:=vp*t;\n xd:=0;\n while xp=c then break;\n inc(k);\n s:=s+ch*vp;\n s:=s+f*vp;\n end;\n end;\n writeln(k);\nend."}, {"source_code": "var vp,vd,t,f,c,i,k,n:longint;\n ch,s:extended;\nbegin\n read(vp,vd,t,f,c);\n k:=0;\n if vp=c then break;\n inc(k);\n s:=s+ch*vp;\n s:=s+f*vp;\n end;\n end;\n writeln(k);\nend."}, {"source_code": "var\nl,t2,c,i,j,k,t1,v1,v2,t,f:extended;\nn:longint;\nbegin\nread(v1,v2,t,f,c);\nt1:=0; l:=v1*t;\n //writeln(l:0:0);\nif v2>v1 then while l c then dec(n);\n t1:= l/(v2-v1);\nif v2*t1>=c then dec(n);\n l:=v2*t1+v1*(t1+f);\n// writeln(l:0:0);\n end;\n\nwriteln(n);\nend."}, {"source_code": "var v1,v2,v3,f1,f2,c:integer;\n i,k:integer;\n t,s:real;\nbegin\nread(v1,v2,f1,f2,c);\nv3:=v2-v1;\nif v3<=0 then begin writeln(0);halt end;\ns:=f1*v1;\nk:=0;\nwhile s=c then\n begin writeln(k); halt; end\n else\n begin\n s:=s+v1*t;\n if s=vd then begin write(0);halt;end;\n if vp*t>=c then begin write(0);halt;end;\n sp:=vp*t;\n while true do begin\n t1:=(sp)/(vd-vp);\n if t1*vp+sp>=c then break;\n sp:=sp+vp*t1;\n t2:=sp/vd+f;\n sp:=sp+vp*t2;\n inc(kol);\n if t2*vp+sp>=c then break;\n end;\n write(kol);\n end.\n\n\n\n"}, {"source_code": "Var vp,vd,t,f,i:longint;\n s1,s2,c:real;\nbegin\nReadln(vp);\nReadln(vd);\nReadln(t);\nReadln(f);\nReadln(c);\ni:=0;\ns1:=vp*t;\nIf vd>vp then begin\ns2:=(s1*vp)/(vd-vp);\nWhile s1+s2tt-eps then break;\n inc(ans);\n tmp:=tmp+(tmp*vp)/vd+f;\n end;\n Writeln(ans);\n end."}, {"source_code": "const\n eps=1e-9;\n\nvar\n tt,vp,vd,t,f,c,x:extended;\n ans:longint;\n\nbegin\n read(vp,vd,t,f,c);\n x:=0;\n ans:=0;\n while (true)do begin\n x:=x+vp*t;\n if (x-c>-eps)then break;\n if (vp-vd>-eps)then break;\n //x+vp*tt=vd*tt\n tt:=x/(vd-vp);\n x:=x+tt*vp;\n if (x-c>-eps)then break;\n inc(ans);\n t:=f+x/vd;\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var t2,t,t1,s,c,vp,vd:extended;\n an:longint;\n begin\n readln(vp,vd,t,t1,c);\n s:=t*vp;\n if (s>=c) or (vd<=vp) then begin writeln(0); halt; end;\n an:=0;\n while s=c then break;\n inc(an);\n t2:=t1+s/vd;\n s:=s+t2*vp;\n end;\n writeln(an);\nend.\n"}, {"source_code": "Var ans,z,a,b,t,f,c,p,d:extended;\n begin\n read(a,b,t,f,c);\n p:=t*a;\n z:=a;\n while true do\n begin\n p:=p+a;\n d:=d+b;\n if d>p then d:=d-(d-p);\n if p>=c then break;\n if p<=d then\n begin\n ans:=ans+1;\n p:=p+a*((d/b)+f);\n d:=0;\n end;\n end;\n if (c/10=b)and(b<>1) then ans:=b+b/2+2\n else\n if (ans/2=7) then ans:=ans+1;\n write(ans:0:0);\n end."}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n{$define Bool:=Boolean}\n\nvar\n\tv1, v2, delay, spend, dis, i: Long;\n x1, x2, t: Real;\n\nbegin\n\tr(V1, v2, delay, spend, dis);\n\tif v1 >= v2 then\n begin\n \tWriteln(0);\n exit;\n end;\n x1 := v1 * delay;\n while x1 < dis do\n begin\n \tt := (x1 - x2) / (v2 - v1);\n x2 := x2 + v2 * t;\n x1 := x1 + v1 * t;\n //Writeln(x1 = x2);\n if x2 < dis then\n begin\n\t Inc(i);\n //Writeln(x1:0:2, ' ', x2:0:2, ' ', t:0:2);\n end;\n x1 := x1 + (spend + x2 / v2) * v1;\n x2 := 0;\n end;\n Writeln(i);\nend.\n"}], "negative_code": [{"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp, vd, t, f, s, d, pu, nod, a, b, r: extended;\nbegin\n readln(vp, vd, t, f, d);\n if vp >= vd then\n begin\n writeln(0);\n halt;\n end;\n nod := vd / vp;\n pu := t * vp;\n s := 0;\n while pu < d do\n begin\n pu := pu * nod * vp;\n if pu >= d then\n break;\n a := pu / vd;\n a := a + f;\n pu := pu + (vp * a);\n s := s + 1;\n end;\n writeln(s:1:0);\n readln;\nend."}, {"source_code": "var vp,vd,t,f,c,s,v:longint;\n x:double;\nbegin\n {assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n\n read(vp,vd,t,f,c);\n\n x:=vp*t; v:=vd-vp;\n\n if (v<=0) then begin\n writeln(0); exit;\n end;\n\n x:=x*vd/v;\n if (x>=c) or (v<=0) then begin\n writeln(0);\n end else begin\n\n s:=0;\n while x=c then break;\n s:=s+vp*(f)+t1;\n inc(dem);\n end;\n writeln(g,dem);\nend;\nprocedure xuat;\nbegin\n assign(g,fo);\n rewrite(g);\n xuli;\n close(g);\nend;\nBEGIN\n nhap;\n xuat;\nEND."}, {"source_code": "Type Slog = Record x, y, r : LongInt; end;\n\nvar i, j, k, l, N, Vp, Vz, T0, Tf, C : Real;\n Tpovratka, Predjeno: Real;\n Radijator : array [0..1005] of Slog;\n s, IntPart, DecPart, Naopak : String;\n minus : Boolean;\n t : Real;\n Resenje : Longint;\nbegin\n Readln(Vp);\n Readln(Vz);\n Readln(t0);\n Readln(Tf);\n Readln(C);\n\n While True do\n Begin\n t := Vz*t0/(Vz-Vp);\n if T <= 0 then Begin\n Writeln(Resenje);\n halt;\n end;\n if Vp*t < c\n then Begin Inc(Resenje); Writeln(Vp*t); end\n else Begin\n Writeln(Resenje);\n halt;\n end;\n\n Predjeno := Vp*t;\n c := c-Predjeno;\n tpovratka := Tpovratka + Predjeno/Vz;\n T0 := 2*Tpovratka + Tf;\n Writeln(T0);\n end;\nend.\n"}, {"source_code": "var i,ans,l,k,n,m,d:longint;sd,sp,vp,vd,f,t,c,tp,tt:real;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (vp,vd,t,f,c);\ntp:=(c) / vp;\ntt:=t;\nsp:=vp*t;\nans:=0;\nwhile tt=sp) and (tt=vp*mid+sp then r:=mid\n else l:=mid;\n until l+1>=r;\n sp:=sp+vp*r; if sp=x then begin\n inc(ans);\n p:=1;\n x:=x+f*vp;\n p:=d div vd;\n x:=x+p*vp;\n\n d:=0;\n end else begin\n x:=x+vp;\n d:=d+vd;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n vp, vd, c, d, t, f, dr, pr: Integer;\nbegin\n read(vp, vd, t, f, c);\n d := 0;\n dr := 0;\n pr := t * vp;\n while pr < c do begin\n if (dr + vd) > (pr + vp) then begin\n pr := pr + ((dr div vd) + f) * vp;\n dr := 0;\n inc(d);\n end else begin\n dr := dr + vd;\n pr := pr + vp;\n end;\n end;\n write(d);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar vp,vd,ff,t,c,tmp:integer;\nfunction count(a,b:integer):integer;\nbegin\n tmp:=a div b;\n if a mod b>0 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,kq,sd,sp:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n repeat\n l:=tp; r:=c+vp;\n repeat\n mid:=(l+r)div 2;\n if mid=tp then l:=mid+1 else\n begin\n sd:=count(mid,vd);\n sp:=count(mid-tp,vd);\n if sd>=sp then r:=mid else l:=mid+1;\n end;\n until l>=r;\n tp:=r+(r div vd)+ff;\n if tp>=c then break else inc(kq);\n until false;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend."}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n vp, vd, c, d, t, f, dr, pr: Integer;\nbegin\n read(vp, vd, t, f, c);\n d := 0;\n dr := 0;\n pr := t * vp;\n while pr < c do begin\n if (dr + vd) > (pr + vp) then begin\n pr := pr + ((dr div vd) + f) * vp;\n dr := 0;\n inc(d);\n end else begin\n dr := dr + vd;\n pr := pr + vp;\n end;\n end;\n write(d);\nend.\n"}, {"source_code": "program GRIG;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n v, w, t, f, c, a, s, kol: integer;\n\n\nbegin\n\n readln(v, w, t, f, c);\n a := c div v;\n\n s := v * t;\n kol := 0;\n\n if w < v then\n begin\n write(0);\n halt(0);\n end;\n\n if w = v then\n begin\n write(0);\n halt(0);\n end;\n\n while s < c do\n begin\n a := s div (w - v);\n s := s + (v * a);\n if s >= c then\n begin\n write(kol);\n halt(0);\n end\n else\n begin\n inc(kol);\n s := s + v * f + v * a;\n end;\n end;\n\n\n\n write(kol);\n\nend."}, {"source_code": "var vp, vd, t, f, c, b: longint;\n m, tx, p, x: extended;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n p := t * vp;\n if vp >= vd then\n begin\n writeln(0);\n exit;\n end;\n x := 0.00000000001;\n b := 0;\n while p + x < c do\n begin\n m := p / (vd - vp);\n m := m * vd;\n if m + x < c then\n begin\n inc(b);\n tx := p / (vd - vp);\n p := p + tx * 2 * p + f * p;\n end\n else\n break;\n end;\n writeln(b);\nend."}, {"source_code": "Var min,vp,vp1,vd1,x3,x4,x1,x2,vd,t,f,c:LongInt;\n begin\n ReadLn(vp,vd,t,f,c);\n x1:=vp*t;\n x2:=0;\n While 2=2 do\n begin\n t:=t+1;\n x2:=x2+vd;\n x1:=x1+vp;\n if x2>x1 then x2:=x2-(x2-x1);\n if x1>=c then begin Break; end;\n if x2>=x1 then begin min:=min+1; x1:=x1+(vp*((f)+((x2) div vd))); x2:=0; end;\n end;\n WriteLn(min);\n end.\n"}, {"source_code": "var\n vp,vd,t,f,c,cd : extended;\n x : longint;\n\nbegin\n readln(vp,vd,t,f,c);\n if vp < vd then begin\n cd:=t*vp/(vd-vp)*vd;\n while cd < c do begin\n cd:=cd+vd*(vd-vp)*(2*cd/vd+f);\n inc(x);\n end;\n end;\n writeln(x);\nend."}, {"source_code": "program CF105A;\nvar\n vp,vd,t,f,c,i,res: longint; p,d: extended;\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n read(vp,vd,t,f,c);\n p := t*vp;\n d := 0;\n if vp >= vd then\n begin\n write('0');\n exit;\n end; \n\n res := 0;\n while p < c do \n if ((d + vd) > (p+vp)) and ((p+(p-d)/(vd-vp)*vp) < c) then\n begin\n inc(res);\n p := p+(p-d)/(vd-vp)*vp + f*vp + ((p+(p-d)/(vd-vp)*vp)*2)/vd*vp; \n end else\n begin\n p := p + vp;\n d := d + vd;\n end;\n\n write(res);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar vp,vd,ff,t,c,tmp:integer;\nfunction count(a,b:integer):integer;\nbegin\n tmp:=a div b;\n if a mod b>0 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,sd,sp:real;\n kq:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n if vd>vp then\n repeat\n l:=tp+1; r:=c+vp;\n repeat\n mid:=(l+r)/2;\n sd:=mid/vd; sp:=(mid-tp)/vp;\n if sp>=sd then r:=mid else l:=mid;\n until l+0.001>=r;\n if r=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend.\n"}, {"source_code": "var\n vp,vd,tt,f,c:integer;\n ans:longint;\n t: real;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n t:=tt*vp;\n ans:=0;\n if (t>=c) or (vd<=vp) then ans:=0\n else\n while t/(vd-vp) < (c-t)/vp do\n begin\n ans := ans + 1;\n t := t + vp*(t/(vd-vp));\n t := t + vp*(t/vd);\n t := t + vp*f;\n end;\n writeln(ans-1);\nend."}, {"source_code": "var vd,vp,pd,pp,c,t,f,j,x:longint;\nprocedure pobeg;\nbegin\n if pp>=c then exit;\n x:=(pp-pd)div(vd-vp);\n pp:=pp+vp*x;\n if pp>=c then exit;\n inc(j);\n pd:=pd+x*vd;\n x:=pd div vd;\n pp:=pp+vp*(f+x);\n pd:=0;\n pobeg;\nend;\nbegin\n //assign(input, 'input.txt');reset(input);\n //assign(output, 'output.txt');rewrite(output);\n readln(vp,vd,t,f,c);\n j:=0;\n pd:=0;\n pp:=t*vp;\n pobeg;\n writeln(j);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp,vd,t,f,c,i,p,d:extended;\n r:integer;\n time,add:extended;\n\nbegin\n read(vp,vd,t,f,c);\n p := t * vp;\n d := 0;\n r := 0;\n time := 0;\n while (p=p) and (p=v2) then\n begin\n if (v1=v2)and(t=0) then\n begin\n writeln(1);\n exit;\n end;\n writeln(0);\n exit;\n end;\n s:=v1*t;\n tt:=n/v1; t1:=t;\n while tt>t1 do\n begin\n t:=s/(v2-v1);\n if t+t1>=tt then break;\n s:=s+t*v1;\n t:=s/v2+f;\n s:=s+t*s;\n t1:=t1+t;\n inc(ans);\n end;\n writeln(ans);\nend;\n\nbegin\n main;\nend."}, {"source_code": "var vp,vd,t,f,c,z:longint; x,y,td,s2,s1:real;\nbegin\nreadln(vp);\nreadln(vd);\nreadln(t);\nreadln(f);\nreadln(c);\nz:=0;\nif vp=vd then write(0) else \nbegin\ns1:=vp*t;\nx:=s1/(vd-vp);\ns2:=vd*x;\ny:=t+x;\ninc(z);\nwhile s2=c then break;\n if p<=d then begin inc(ans); p:=p+a*((d div b)+f); d:=0; end;\n end;\n write(ans);\n end."}, {"source_code": "var\n\nans,vp,vd,t,f,c:longint;\nras,x,y:real;\nbegin\nreadln(vp);\nreadln(vd);\nreadln(t);\nreadln(f);\nreadln(c);\nx:=vp*t;\ny:=0;\nif (x>=c)or(vp=vd) then writeln(0)\nelse begin\n while true do begin\n ras:=(x-y)/abs(vp-vd);\n x:=x+ras;\n if x>=c then break\n else begin\n inc(ans);\n x:=x+ras/vp+f/vp;\n\n\n// writeln(x);\n end;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "Var z,a,b,t,f,c,p,d:extended;\n ans:longint;\n begin\n read(a,b,t,f,c);\n if (a=1)and(b=100)and(t=1)and(f=1)and(c=1000) then\n begin\n writeln(152);\n exit;\n end;\n p:=t*a;\n z:=a;\n while true do\n begin\n p:=p+a;\n d:=d+b;\n if d>p then d:=d-(d-p);\n if p>=c then break;\n if p<=d then\n begin\n inc(ans);\n p:=p+a*((d/b)+f);\n d:=0;\n end;\n end;\n if ans div 2=7 then write(ans+1);\n end."}, {"source_code": "Var z,a,b,t,f,c,p,ans,d:Longint;\n begin\n read(a,b,t,f,c);\n p:=t*a;\n z:=a;\n while p=vp*mid+sp then r:=mid\n else l:=mid;\n until l+1>=r;\n sp:=sp+vp*r;if sp=c) then break;\n pt:=pt+2*(x/vd)+f;\n pc:=vp*pt;\n inc(ans);\n end;\n writeln(ans);\n // readln;\nend.\n"}, {"source_code": "var\np,x,vp,vd,t,f,c,d,ans:longint;\nbegin\nreadln(vp,vd,t,f,c);\nx:=vp*t;\nd:=0;\nwhile x=x then begin\n inc(ans);\n p:=1;\n x:=x+f*vp;\n p:=d div vd;\n x:=x+p*vp;\n\n d:=0;\n end else begin\n x:=x+vp;\n d:=d+vd;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "var sc, st, ss, st1, st2, st3: string;\n c1, c2, ch1, ch2: char;\n vp, vd, f, k, i, j, c, a, b, max, min: longint;\n s,sp,s1, l1,l2,l3: longint;\n cifr: boolean;\n mas: array [1..101] of integer;\n x,t, l: real;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n l:=0; k:=0;\n if vd=vp then k:=0 else \n while l= vd then begin write(0); halt; end;\n\tx := 0; time := time + t; ans := 0;\n while time < c / vp do begin\n \tx := vp * time;\n \tt1 := x / (vd - vp);\n \tif time + t1 < c then inc(ans);\n \ttime := time + t1;\n \tx := vp * time;\n \ttime := time + (x / vd) + f;\n \tend;\n \twrite(ans);\nend."}, {"source_code": "program run_away;\nvar vp,vd,t,f,c,res,i : longint;\n sp,sd : double;\nbegin\n //assign(input,'input.txt'); reset(input);\n readln(vp,vd,t,f,c);\n if vd = vp then begin\n writeln(0); exit;\n end;\n res:= 0; sp:= vp*t; sd:= 0;\n while true do begin\n sd:= vd * (sp / (vd-vp));\n //writeln('sd ',sd:0:2);\n if sd >= c then break\n else begin\n inc(res);\n sp:= sd + ((sd / vd) + f)*vp;\n sd:= 0;\n //writeln(sp);\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar vp,vd,ff,t,c,tmp:integer;\nfunction count(a,b:integer):integer;\nbegin\n tmp:=a div b;\n if a mod b>0 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,sd,sp:real;\n kq:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n if vd>vp then\n repeat\n l:=tp+1; r:=c+vp;\n repeat\n mid:=(l+r)/2;\n sd:=mid/vd; sp:=(mid-tp)/vp;\n if sp>=sd then r:=mid else l:=mid;\n until l+0.1>=r;\n if r=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,i,a,b,k:integer;\n ah:array[0..10000] of integer;\n bh:array[0..10000] of integer;\n x,t:extended;\n vp,vd,c,ans,f:integer;\nbegin\n\nread(vp,vd,t,f,c);\nx:=0; ans:=0;\nwhile true do\n begin\n x:=vp*t+((vp*t)/vd)/(1/vp-1/vd);\n t:=t+f+x/vd+((vp*t)/vd)/(1/vp-1/vd);\n writeln(x);\n if x>=c then break;\n inc(ans);\n end;\n write(ans);\nend."}, {"source_code": "var\np,x,vp,vd,t,f,c,d,ans:longint;\nbegin\nreadln(vp,vd,t,f,c);\nx:=vp*t;\nd:=0;\nwhile x=x then begin\n p:=1;\n x:=x+f*vp;\n p:=d div vd;\n x:=x+p*vp;\n inc(ans);\n d:=0;\n end else begin\n x:=x+vp;\n d:=d+vd;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "var vd,vp,pd,pp,c,t,f,j,x:longint;\nprocedure pobeg;\nbegin\n if pp>=c then exit;\n x:=(pp-pd)div(vd-vp);\n pp:=pp+vp*x;\n if pp>=c then exit;\n inc(j);\n pd:=pd+x*vd;\n x:=pd div vd;\n pp:=pp+vp*(f+x);\n pd:=0;\n pobeg;\nend;\nbegin\n //assign(input, 'input.txt');reset(input);\n //assign(output, 'output.txt');rewrite(output);\n readln(vp,vd,t,f,c);\n j:=0;\n pd:=0;\n pp:=t*vp;\n pobeg;\n writeln(j);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp,vd,t,f,c,i,p,d:extended;\n r:integer;\n time,add:extended;\n\nbegin\n read(vp,vd,t,f,c);\n p := t * vp;\n d := 0;\n r := 0;\n time := 0;\n while (p=p) and (p=c then break;\n inc(ans);\n end;\n write(ans);\nend."}, {"source_code": "program pobeg;\n\nvar\n vp, vd, f, c, n: integer;\n \n t, nach: real;\n\nprocedure dognal;{������ �������� ���������}\nbegin\n t := nach / (vd - vp);\n nach := nach + vp * t;\n if nach < c then\n n := n + 1;\nend;\n\nprocedure domoi;{������ ���� ������������� �����}\nbegin\n t := vd / nach + f;\n nach := nach + t * vp;\nend;\n\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n nach := vp * t;\n if (vp >= vd) or (nach >= c) then n := 0\n else\n while nach < c do\n begin\n dognal;\n \n domoi;\n \n end;\n \n writeln(n);\nend."}, {"source_code": "var vp,vd,t,f,cc,ost,tec,l,r,c:extended;\n ans:longint;\n begin\n read(vp,vd,t,f,cc);\n if vp+(1e-10)>=vd then begin writeln(0); halt(0); end;\n ost:=t;\n tec:=0;\n while tec-(1e-10)0 then begin\n tec:=tec+ost*vp;\n ost:=0;\n end\n else begin\n inc(ans);\n ost:=f+tec/vd;\n end;\n\n l:=0;\n r:=10000;\n while l+(1e-7)=c then\n begin writeln(ans); halt; end;\n while true do\n begin\n d:=d+vd; p:=p+vp;\n if p>=c then\n begin writeln(ans); halt; end;\n if d>=p then\n begin\n inc(ans);\n p:=p+vp*(f+d div vd); d:=0;\n end;\n end;\nend.\n\n\n\n\n"}, {"source_code": "const fin='';\n fout='';\nvar vd,vp,t,f,c,s:longint;\nprocedure solve1;\nvar ff:text;\nbegin\n assign(ff,fin);reset(ff);\n read(ff,vp,vd,t,f,c);\n close(ff);\nend;\nprocedure solve2;\nvar sd,sp,l,r,mid:longint;\nbegin\n sp:=vp*t;\n while sp=vp*mid+sp then r:=mid\n else l:=mid;\n until l+1>=r;\n sp:=sp+vp*r; if spt then begin\n pd:=pd+vd*dir;\n if pd < 0 then begin pd:=pd*(-1); dir:=dir*(-1); end;\n if pd = 0 then td:=0;\n end;\n if pd>=pp then begin\n t:=f;\n dir:=dir*(-1);\n if pp=c)or(vp=vd) then writeln(0)\nelse begin\n while true do begin\n ras:=(x-y)/abs(vp-vd);\n x:=x+ras;\n if x>=c then break\n else begin\n inc(ans);\n x:=x+vp/ras+vp/f;\n\n\n// writeln(x);\n end;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp, vd, t, f, c, v, ap, ans: integer;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n readln(vp, vd, t, f, c);\n ap := t * vp;\n v := vd - vp;\n ans := 0;\n while ap < c do\n begin\n ap := ap + vp * ap div v;\n if ap >= c then\n begin\n writeln(ans);\n halt;\n end;\n inc(ans);\n ap := ap + vp * (ap div vd + f);\n end;\n writeln(ans);\n //close(input); close(output);\nend.\n"}, {"source_code": "program run_away;\nvar vp,vd,t,f,c,res,i : longint;\n sp,sd : double;\nbegin\n //assign(input,'input.txt'); reset(input);\n readln(vp,vd,t,f,c);\n if vd = vp then begin\n writeln(0); exit;\n end;\n res:= 0; sp:= vp*t; sd:= 0;\n while true do begin\n sd:= vd * (sp / (vd-vp));\n //writeln('sd ',sd:0:2);\n if sd >= c then break\n else begin\n inc(res);\n sp:= sd + ((sd / vd) + f)*vp;\n sd:= 0;\n //writeln(sp);\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "program CF105A;\nvar\n vp,vd,t,f,c,i,res: longint; p,d: extended;\nbegin\n{ assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n read(vp,vd,t,f,c);\n p := t*vp;\n d := 0;\n if vp >= vd then\n begin\n write('0');\n exit;\n end; \n\n res := 0;\n while p < c do \n if ((p+vp) < c) and ((d + vd) > (p+vp)) then\n begin\n inc(res);\n p := p+(p-d)/(vd-vp)*vp + f*vp + (p+(p-d)/(vd-vp)*vp*2)/vd*vp; \n end else\n begin\n p := p + vp;\n d := d + vd;\n end;\n\n write(res);\nend.\n"}, {"source_code": "program contest_105;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar ans : longint;\n td,curS,t,Vp,Vd,f,c : extended;\n\nbegin\n readln(Vp);\n readln(Vd);\n readln(t);\n readln(f);\n readln(c);\n\n if (Vp >= Vd) then begin\n writeln('0');\n halt(0);\n end;\n\n ans := 0;\n\n while true do begin\n td := (t * Vp) / (Vd - Vp);\n curS := curS + td * Vd;\n if curS < c then begin\n inc(ans);\n t := 2*td+f;\n end else break;\n end;\n\n writeln(ans);\n\nend.\n"}, {"source_code": "Var z,a,b,t,f,c,p,ans,d:Longint;\n begin\n read(a,b,t,f,c);\n p:=t*a;\n z:=a;\n while 1=1 do\n begin\n p:=p+a;\n d:=d+b;\n if d>p then d:=d-(d-p);\n if p>=c then break;\n if p<=d then begin inc(ans); p:=p+a*((d div b)+f); d:=0; end;\n end;\n write(ans);\n end."}, {"source_code": "program p2;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\nuses math;\n\nvar\n i,vp,vd,t,f,c,pp,pd,s:integer;\n vn:boolean;\nbegin\n readln(vp,vd,t,f,c);\n vn:=true;\n pp:=0;\n pd:=0;\n s:=0;\n for i := 1 to ceil(c/vp) do\n begin\n pp:=vp*i;\n if i>t then begin\n if vn then\n pd:=pd+vd else pd:=pd-vd;\n if pd>=pp then begin vn:=false; if i<>ceil(c/vp) then inc(s); end;\n if pd=0 then begin t:=i+f-1; vn:=true; end;\n end;\n\n end;\n write(s);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp, vd, t, f, s, d, pu, nod, a, b, r: extended;\nbegin\n readln(vp, vd, t, f, d);\n nod := vd / vp;\n pu := t * vp;\n s := 0;\n while pu < d do\n begin\n pu := pu * nod * vp;\n writeln(pu:1:0);\n if pu >= d then\n break;\n a := pu / vd;\n a := a + f;\n pu := pu + (vp * a);\n s := s + 1;\n end;\n writeln(s:1:0);\n readln;\nend."}, {"source_code": "Var\n vp,vd,f,c,i,k,a,t,d,s: longint;\n \nBegin\n read(vp,vd,t,f,c);\n if((c/vp) <= (c/vd + t)) then\n begin\n write(0);\n exit;\n end\n else \n begin\n a := vp*t; k := 0;\n repeat\n s := trunc(a * vp / (vd - vp));\n a := a + s;\n if(a < c) then\n inc(k);\n a := a + (f*vp) + (vp * trunc(a / vd)); \n until a >= c; \n end;\n write(k);\nEnd."}, {"source_code": "program pobeg;\n\nvar\n vp, vd, f, c, n: integer;\n \n t,nach:real;\nprocedure dognal;\nbegin\n t:=nach/(vd-vp);\n nach:=nach+vp*t;\n n:=n+1;\nend;\nprocedure domoi;\nbegin\nt:=vd/nach+f;\nnach:=nach+t*vp;\nend;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n nach := vp * t;\n if vp>=vd then n:=0\n else\n while nach=c then n:=n-1;\n end;\n \n writeln(n);\nend."}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n\n\nuses math;\n\nvar\n V1, V2, Delay, Spend, Dis, Count, X, Y, Mode, i: LongInt;\n\nbegin\n\tread(V1, V2, Delay, Spend, Dis);\n x := Delay * V1;\n i := 1;\n while (i <= Min(V1, V2)) do\n begin\n \tInc(i);\n if V1 mod i = 0 then\n \tif V2 mod i = 0 then\n begin\n \tV1 := V1 div i;\n V2 := V2 div i;\n i := 1;\n end;\n end;\n while x < Dis do\n begin\n \t//Wln(X, ' ', Y);\n Inc(X, V1);\n Inc(Y, V2);\n if x < Dis then\n \tbegin\n if Y >= X then\n begin\n \tV2 := -V2;\n Inc(Count);\n end;\n end\n else\n \tbreak;\n if Y <= 0 then\n begin\n \tY := 0;\n \tInc(X, V1 * Spend);\n V2 := -V2;\n end;\n end;\n Writeln(Count);\nend.\n"}, {"source_code": "var n,d,l,f,t,p,c:longint;\n r:extended;\nbegin\n readln(p);\n readln(d);\n readln(t);\n readln(f);\n readln(c);\n r:=p*t;\n if (r>=c) or (p-d=0) then write(l)\n else\n begin\n while (r=c) then break;\n r:=r+(((r/d)+f)*p);\n inc(l);\n end;\n write(l);\n end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vp, vd, t, f, s, d, pu, nod, a, b, r: extended;\nbegin\n readln(vp, vd, t, f, d);\n nod := vd / vp;\n pu := t * vp;\n s := 0;\n while pu < d do\n begin\n pu := pu * nod * vp;\n if pu >= d then\n break;\n a := pu / vd;\n a := a + f;\n pu := pu + (vp * a);\n s := s + 1;\n end;\n writeln(s:1:0);\n readln;\nend."}, {"source_code": "var vp,vd,t,f,c,res:integer;\n i:real;\nbegin\n//assign(input,'input.txt');assign(output,'output.txt');\nreadln(vp,vd,t,f,c);\nif vd<=vp then writeln(0)else\n begin\n res:=0;\n i:=t*vp;\n while i= c then break\n else begin\n inc(res);\n sp:= sd + ((sd / vd) + f)*vp;\n sd:= 0;\n //writeln(sp);\n end;\n end;\n writeln(res);\nend.\n"}, {"source_code": "var\n i,vp,vd,t,f,c:real;\n k:integer;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n i:=t*vp;\n k:=0;\n if vd>vp then\n while i=c then\n begin writeln(k); halt; end\n else\n begin\n s:=s+v1*(t+s/v2+f2);\n if s=c then break;\n\nnow:=now+tt; xp:=xp+tt*vp; inc(kil);\n\nxd:=xp; tt:=(vd/xp)*2+f; xp:=xp+tt*vp; now:=now+tt; end;\n\nWriteln(kil);\n\nEnd.\n\n\n\n\n\n\n"}, {"source_code": "var\nans,aim,cost,i,j,k,n,m,nowx,nowy,vx,vy:longint;\nbegin\nreadln(vx);\nreadln(vy);\nreadln(i);\nnowx:=vx*i; nowy:=0;\nreadln(cost);\nreadln(aim);\nif (vx>=vy)or(aim<=nowx) then\nbegin\n writeln(0);\n exit;\nend;\nwhile nowx=nowy do\n begin\n inc(nowx,vx);\n inc(nowy,vy);\n if (nowx>=aim)and(nowx>=nowy)then\n begin\n writeln(ans);\n exit;\n end;\n end;\n// writeln(nowx,' ',nowy);\n dec(nowx,vx);\n dec(nowy,vy);\n inc(ans);\n// writeln(nowx,' ',nowy);\n if nowy mod vy<>0 then\n begin\n nowx:=nowx+((nowy div vy)+1)*vx+vx*cost;\n nowy:=((nowy div vy)+1)*vy-nowy;\n end\n else\n begin\n// writeln(nowx,' ',nowy);\n nowx:=nowx+(nowy div vy)*vx+vx*cost;\n nowy:=0;\n end;\n end;\nwriteln(ans);\nend."}, {"source_code": "program pobeg;\n\nvar\n vp, vd, f, c, n: integer;\n \n t,nach:real;\nprocedure dognal;\nbegin\n t:=nach/(vd-vp);\n nach:=nach+vp*t;\n n:=n+1;\nend;\nprocedure domoi;\nbegin\nt:=vd/nach+f;\nnach:=nach+t*vp;\nend;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n nach := vp * t;\n if vp>=vd then n:=0\n else\n while nach=c then n:=n-1;\n end;\n \n writeln(n);\nend."}, {"source_code": "const fi='';\n fo='';\nvar vp,vd,ff,t,c,tmp:integer;\nfunction count(a,b:integer):integer;\nbegin\n tmp:=a div b;\n if a mod b>0 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,sd,sp:real;\n kq:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n if vd>vp then\n repeat\n l:=tp+1; r:=c+vp;\n repeat\n mid:=(l+r)/2;\n sd:=mid/vd; sp:=(mid-tp)/vp;\n if sp>=sd then r:=mid else l:=mid;\n until l+0.001>=r;\n if r=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend.\n"}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n\n\nuses math;\n\nvar\n V1, V2, Delay, Spend, Dis, X, Y, Mode, i, V0: Real;\n\tCount: LongInt;\n b: Boolean;\n\nbegin\n\tread(V1, V2, Delay, Spend, Dis);\n V1 := V1 / 1000;\n V2 := V2 / 1000;\n V0 := V2;\n x := Delay * V1;\n i := 1;\n b := true;\n\t{while (i <= Min(V1, V2)) do\n begin\n \tInc(i);\n if V1 mod i = 0 then\n \tif V2 mod i = 0 then\n begin\n \tV1 := V1 div i;\n V2 := V2 div i;\n i := 1;\n end;\n end;}\n i := 0;\n while x < Dis do\n begin\n \t//Wln(X, ' ', Y);\n X := X + V1;\n Y := Y + V2;\n if x < Dis then\n \tbegin\n if Y = X then\n begin\n \tV2 := -V2;\n Inc(Count);\n end;\n end\n else\n \tbreak;\n if b then\n if Y <= 0 then\n begin\n \tY := V2 * (Spend - 0);\n V2 := -V2;\n b := false;\n end\n \telse\n \tb := true;\n end;\n Writeln(Count);\nend.\n"}, {"source_code": "program ProjectB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n vd,vp,f,c,rez:integer;\n tz,t,tp,s:extended;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\nreadln(vp);\nreadln(vd);\nreadln(t);\nreadln(f);\nreadln(c);\ntz:=c/vp;\nif vp=vd then\n begin\n writeln(0);\n exit;\n end;\ns:=vp*t;\nwhile s=vd)or (nach>=c) then n:=0\n else\n while nach=c then n:=n-1;\n domoi;\n \n end;\n \n writeln(n);\nend."}, {"source_code": "var vp,vd,t,f,cc,ost,tec,l,r,c:extended;\n ans:longint;\n begin\n read(vp,vd,t,f,cc);\n if vp+(1e-10)>=vd then begin writeln(0); halt(0); end;\n ost:=t;\n tec:=0;\n while tec-(1e-10)0 then begin\n tec:=tec+ost*vp;\n ost:=0;\n end\n else begin\n inc(ans);\n ost:=f+tec/vd;\n end;\n\n l:=0;\n r:=10000;\n while l+(1e-7)=vp*mid+sp then r:=mid\n else l:=mid;\n until l+1>=r;\n sp:=sp+vp*r; if sp=c then break;\n inc(ans);\n end;\n write(ans);\nend."}, {"source_code": "Var min,vp,vp1,vd1,x3,x4,x1,x2,vd,t,f,c:LongInt;\n begin\n ReadLn(vp,vd,t,f,c);\n x1:=vp*t;\n x2:=0;\n While 2=2 do\n begin\n t:=t+1;\n x2:=x2+vd;\n x1:=x1+vp;\n if x1>=c then begin Break; end;\n if x2>=x1 then begin min:=min+1; x1:=x1+(vp*((x2 div t)+f)); x2:=0; end;\n end;\n WriteLn(min);\n end.\n"}, {"source_code": "Var z,a,b,t,f,c,p,ans,d:Longint;\n begin\n read(a,b,t,f,c);\n p:=t*a;\n z:=a;\n while 2=2 do\n begin\n p:=p+a;\n d:=d+b;\n if d>c then d:=d-(d-c);\n if p>=c then break;\n if p<=d then begin inc(ans); p:=p+a*((d div b)+f); d:=0; end;\n end;\n write(ans);\n end."}, {"source_code": "var i,ans,l,k,n,m,d:longint;sd,sp,vp,vd,f,t,c,tp,tt:real;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (vp,vd,t,f,c);\ntp:=(c) / vp;\ntt:=t;\nsp:=vp*t;\nans:=0;\nwhile tt=sp) and (tt=q)and(q0\n then\n x:=x+vd;\n q:=q+(f+x div vd)*vp;\n x:=0;\n end;\n end;\n writeln(ans);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var c,t,f,vd,vp:integer;\n ans:int64;\nfunction p(kol:integer):boolean;\nvar x,tim:real;\nbegin\nx:=t*vp;\nwhile x=c then break;\n dec(kol);\n tim:=f+x/vd;\n x:=x+vp*tim;\nend;\nif kol>=0 then p:=true else p:=false;\nend;\n var m,l,r:integer;\nbegin\nreadln(vp,vd,t,f,c);\nif vp=vd then begin writeln(0);halt;end;\nl:=1;\nr:=100000;\nwhile l=a)and(kch= d then\n break;\n a := pu / vd;\n a := a + f;\n pu := pu + (vp * a);\n s := s + 1;\n end;\n writeln(s:1:0);\n readln;\nend."}, {"source_code": "var vp,vd,t,f,c,z:longint; x,y,td,s2,s1:real;\nbegin\nreadln(vp);\nreadln(vd);\nreadln(t);\nreadln(f);\nreadln(c);\nz:=0;\nif vp=vd then write(0) else \nbegin\ns1:=vp*t;\nx:=s1/(vd-vp);\ns2:=vd*x;\ny:=t+x;\ninc(z);\nwhile s20 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,kq,sd,sp:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n if vd>vp then\n repeat\n l:=tp+1; r:=c+vp;\n repeat\n mid:=(l+r)div 2;\n sd:=count(mid,vd);\n sp:=count(mid-tp,vp);\n if sp>=sd then r:=mid else l:=mid+1;\n until l>=r;\n if r=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend."}, {"source_code": "Type Slog = Record x, y, r : LongInt; end;\n\nvar i, j, k, l, N, Vp, Vz, T0, Tf, C : Real;\n Tpovratka, Predjeno: Real;\n Radijator : array [0..1005] of Slog;\n s, IntPart, DecPart, Naopak : String;\n minus : Boolean;\n t : Real;\n Resenje : Longint;\nbegin\n Readln(Vp);\n Readln(Vz);\n Readln(t0);\n Readln(Tf);\n Readln(C);\n\n While True do\n Begin\n t := Vz*t0/(Vz-Vp);\n if T <= 0 then Begin\n Writeln(Resenje);\n halt;\n end;\n if Vp*t < c\n then Begin Inc(Resenje); end\n else Begin\n Writeln(Resenje);\n halt;\n end;\n\n Predjeno := Vp*t;\n c := c-Predjeno;\n tpovratka := Tpovratka + Predjeno/Vz;\n T0 := 2*Tpovratka + Tf;\n Writeln(T0);\n end;\nend.\n"}, {"source_code": "var\n\tvp, vd, t, f, c, x, time, t1: extended;\n\tans: longint;\n\nbegin\n //\treset(input, 'b.in');\n //\trewrite(output, 'b.out');\n\treadln(vp, vd, t, f, c);\n\tif vp >= vd then begin write(0); halt; end;\n\tx := 0; time := time + t; ans := 0;\n while time < c / vp do begin\n \tx := vp * time;\n \tt1 := x / (vd - vp);\n \tif time + t1 < c then inc(ans);\n \ttime := time + t1;\n \tx := vp * time;\n \ttime := time + (x / vd) + f;\n \tend;\n \twrite(ans);\nend."}, {"source_code": "var vp, vd, t, f, c, b: longint;\n m, tx, p, x: extended;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n p := t * vp;\n if vp >= vd then\n begin\n writeln(0);\n exit;\n end;\n x := 0.00000000001;\n b := 0;\n while p + x < c do\n begin\n m := p / (vd - vp);\n m := m * vd;\n if m + x < c then\n begin\n inc(b);\n tx := p / (vd - vp);\n p := p + tx * 2 * p + f * p;\n end\n else\n break;\n end;\n writeln(b);\nend."}, {"source_code": "Var vp,vd,t,f,c,r1,r2,i,ans,t1:extended;\n begin\n Read(vp,vd,t,f,c);\n if vp<=vd then begin WriteLn(0); exit; end;\n i:=0;\n r1:=0;\n r2:=vp*t;\n While r2=c) then break;\n ans:=ans+1;\n r2:=r2+i*vp;\n r2:=r2+(f+(r2/vd))*vp;\n end;\n WriteLn(ans:0:0);\n end.\n"}, {"source_code": "var\n a,b:array[1..100000] of longint;\n s1,l,i,j,n,m,k,d,ans:longint;\n vp,vd,t,f,c,tt,s,t1:real;\nbegin\n tt:=0;\n read(vp,vd,t,f,c);\n if vp>=vd then write(0) else\n begin\n k:=0;\n t1:=t;\n while true do\n begin\n tt:=vp*t1/(vd-vp);\n s:=tt*vp+t1;\n if s=N then begin\n writeln(r);\n halt(0);\n end;\n end;\n if t>=n then begin\n writeln(r);\n halt(0);\n end;\n inc(r);\n t:=t+(t div b)+d;\n if t>=n then begin\n writeln(r);\n halt(0);\n end;\nend;\nwriteln(r);\nend.\n\n\n"}, {"source_code": "var\nans,aim,cost,i,j,k,n,m,nowx,nowy,vx,vy:longint;\nbegin\nreadln(vx);\nreadln(vy);\nreadln(i);\nnowx:=vx*i; nowy:=0;\nreadln(cost);\nreadln(aim);\nif (vx>vy)or(aim<=nowx) then\nbegin\n writeln(0);\n exit;\nend;\nwhile (nowx=nowy do\n begin\n if (nowx>=aim)and(nowx>=nowy)then\n begin\n writeln(ans);\n exit;\n end;\n inc(nowx,vx);\n inc(nowy,vy);\n if (nowx>=aim)and(nowx>=nowy)then\n begin\n writeln(ans);\n exit;\n end;\n end;\n dec(nowx,vx);\n dec(nowy,vy);\n inc(ans);\n nowx:=nowx+(nowy div vy)*vx*2+vx*cost;\n end;\nwriteln(ans);\nend."}, {"source_code": "program pobeg;\n\nvar\n vp, vd, f, c, n: integer;\n \n t,nach:real;\nprocedure dognal;\nbegin\n t:=nach/(vd-vp);\n nach:=nach+vp*t;\n n:=n+1;\nend;\nprocedure domoi;\n\nbegin\nt:=vd/nach+f;\nnach:=nach+t*vp;\nend;\nbegin\n readln(vp);\n readln(vd);\n readln(t);\n readln(f);\n readln(c);\n nach := vp * t;\n while nach= c then break;\n res := res+1;\n x0 := x0+(x0/v_d)*v_p;\n x0 := x0+v_p*f;\n end;\n writeln(res);\nEnd.\n"}, {"source_code": "var\np,x,vp,vd,t,f,c,d,ans:longint;\nbegin\nreadln(vp,vd,t,f,c);\nx:=vp*t;\nd:=0;\nwhile x=x then begin\n inc(ans);\n p:=1;\n x:=x+f*vp;\n p:=d div vd;\n if p=0 then d:=vd div d;\n if p=0 then p:=1;\n x:=x+p*vp;\n\n d:=0;\n end else begin\n x:=x+vp;\n d:=d+vd;\n end;\nend;\nwriteln(ans);\nend."}, {"source_code": "{$MACRO ON}\n{$define W:=write}\n{$define Wln:=Writeln}\n{$define R:=read}\n{$define Rln:=Readln}\n{$define Wh:=while}\n{$define arr:=array}\n{$define str:=string}\n{$define Int:=Integer}\n{$define Long:=LongInt}\n{$define Ansi:=AnsiString}\n\n\nuses math;\n\nvar\n V1, V2, Delay, Spend, Dis, Count, X, Y, Mode, i: LongInt;\n\nbegin\n\tread(V1, V2, Delay, Spend, Dis);\n x := Delay * V1;\n i := 1;\n while (i <= Min(V1, V2)) do\n begin\n \tInc(i);\n if V1 mod i = 0 then\n \tif V2 mod i = 0 then\n begin\n \tV1 := V1 div i;\n V2 := V2 div i;\n i := 1;\n end;\n end;\n while x < Dis do\n begin\n Inc(X, V1);\n Inc(Y, V2);\n if x < Dis then\n if Y >= X then\n begin\n \tV2 := -V2;\n Inc(Count);\n end\n else\n \tbreak;\n if Y <= 0 then\n begin\n \tY := 0;\n \tInc(X, V1 * Spend);\n V2 := -V2;\n end;\n end;\n Writeln(Count);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar vp,vd,ff,t,c,tmp:integer;\nfunction count(a,b:integer):integer;\nbegin\n tmp:=a div b;\n if a mod b>0 then inc(tmp);\n exit(tmp);\nend;\nprocedure all;\nvar f:text;\n l,r,mid,tp,kq,sd,sp:integer;\nbegin\n assign(f,fi);reset(f);\n readln(f,vp);readln(f,vd);readln(f,t);readln(f,ff);readln(f,c);\n close(f);\n tp:=t*vp; kq:=0;\n if vd>vp then\n repeat\n l:=tp+1; r:=c+vp;\n repeat\n mid:=(l+r)div 2;\n sd:=count(mid,vd);\n sp:=count(mid-tp,vp);\n if sp>=sd then r:=mid else l:=mid+1;\n until l>=r;\n if r=c;\n assign(f,fo);rewrite(f);write(f,kq);close(f);\nend;\nbegin\n all;\nend."}, {"source_code": "var\n a,b:array[1..100000] of longint;\n s1,l,i,j,n,m,k,d,ans:longint;\n vp,vd,t,f,c,tt,s,t1:real;\nbegin\n tt:=0;\n read(vp,vd,t,f,c);\n if vp>=vd then write(0) else\n begin\n k:=0;\n t1:=t;\n while true do\n begin\n tt:=vp*t1/(vd-vp);\n s:=tt*vp+t1;\n if s= c; \n end;\n write(k);\nEnd."}, {"source_code": "var v,d,t,f,c,k,s,i,p:integer;\nbegin\nreadln(v);\nreadln(d);\nreadln(t);\nreadln(f);\nreadln(c);\nk:=v*t;\nfor i:=1 to 1000 do begin\nk:=k+v;\ns:=s+d;\nif (s=k) and (k<>c) then begin\n inc(p);\n while s>0 do begin\n s:=s-d;\n k:=k+v;\n end;\n if s<0 then s:=0;\n k:=k+(v*f);\n end;\nif k>=c then begin\nwrite(p);\nbreak;\nend;\nend;\nend."}, {"source_code": " var\n vp,vd,t,f,c,q,p,k,x,ans:longint;\n begin\n read(vp,vd,t,f,c);\n q:=t*vp;\n k:=0;\n x:=0;\n while q=q)and(q=vd then begin writeln(0); exit; end;\n time:=c/vp;\n t1:=(vp*t)/(vd-vp)+t;\n if t1>time then begin writeln(0); exit; end else begin time:=time-t1; res:=1; dis:=vp*t1; end;\n While time>0 do\n begin\n dis:=dis+(f+dis/vd)*vp;\n t2:=dis/(vd-vp);\n time:=time-t2-f;\n dis:=dis+t2*vp;\n inc(res);\n end;\n dec(res);\n writeln(res);\nend.\n"}], "src_uid": "c9c03666278acec35f0e273691fe0fff"} {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,i,dem,min:longint;\n A,B:array[-69..10000000] of longint;\n(*===============================*)\nBEGIN\nassign(f,fi);\nreset(f);\nreadln(f,n);\nclose(f);\n(*===============================*)\nassign(f,fo);\nrewrite(f);\nfor i:=1 to n do\n if n mod i=0 then\n begin\n inc(dem);\n A[dem]:=i;\n end;\nfor i:=1 to dem do B[i]:=A[i]-(n div A[i]);\nmin:=maxlongint;\nfor i:=1 to dem do if (B[i]>=0) and (B[i]=i then begin\n if (n div i - i )<=min then begin\n min:=n div i - i;\n ind:=i;\n end;\n end;\n end;\nend;\nwriteln(ind,' ',n div ind);\nend."}, {"source_code": "var n,i,j:longint;\nbegin\nreadln(n);\ni:=trunc(sqrt(n));\nwhile (i>0) do\nbegin\nif n mod i=0 then begin writeln(i,' ',n div i);break end;\ni:=i-1;\nend;\nend."}, {"source_code": "var n,a:longint;\nbegin\nreadln(n);\na:=trunc(sqrt(n));\nwhile n mod a<>0 do\n a:=a-1;\nwrite(a,' ',n div a);\nreadln\nend.\n"}, {"source_code": "var t,z,i,n,k: longint;\n a: array [1..1000] of longint;\n b: array [1..300] of longint;\nbegin\nz:=0;\nreadln (k);\nif k=2 then writeln ('1 2') else\nif k=1 then writeln ('1 1') else\nbegin\nwhile z*zx-i then\n begin\n a:=i;\n b:=x;\n end;\n end;\n end;\n writeln(a,' ',b);\nEND."}, {"source_code": "var\nn,min,a,i,otv,otv1:longint;\nbegin\nreadln(n);\nmin:=1000000;\na:=n;\nfor i:=1 to n do begin\nif n mod i = 0 then begin\na:=n div i;\nif (i<=a) and ((a-i) b1 - a1 then \n begin\n x:=b1 - a1;\n a:=a1;\n b:=b1;\n end;\n end;\n write(a,' ',b);\nend."}, {"source_code": "Var\n N,i,a,b :Longint;\nBEGIN\n Readln(N);\n For i := Trunc(Sqrt(N)) downto 1 do\n If N mod i=0 then\n Begin\n a := i; b := n div i; break;\n End;\n Writeln(a,' ',b);\nEND.\n"}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n for i:=trunc(sqrt(n)) downto 1 do if n mod i=0 then begin writeln(i,' ',n div i);exit;end;\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n n : integer;\n min,vt,i : integer;\nBEGIN\n readln(n);\n min:= trunc(1e6);\n for i:=1 to trunc(sqrt(n)) do\n if (n mod i = 0) then\n begin\n if abs((n div i) - i) < min then\n begin\n min:= abs((n div i) - i);\n vt:= i;\n end;\n end;\n write(vt,' ',n div vt);\nEND."}, {"source_code": "Program abc;\nvar a,i,b,c,min1,min2,otv: integer;\nbegin\nread(a);\notv:=a;\nfor i:=1 to a do\nbegin\nif a mod i=0 then\nbegin\nif abs((a div i)-i)<=otv then\nbegin\notv:=abs((a div i)-i);\nmin1:=a div i;\nmin2:=i;\nend;\nend;\nend;\nif min1>min2 then writeln(min2,' ',min1);\nif min2>min1 then writeln(min1,' ',min2);\nif min2=min1 then writeln(min1,' ',min2);\n\nend."}, {"source_code": "Var n,i,pr:int64;\nBegin\n readln(n);\n i:=1;\n while i*i0 do\n dec(i);\n write(i,' ',n div i);\n close(input); close(output);\n end;\nbegin\n nhap;\n solve;\nend.\n"}, {"source_code": "program mon; //http://codeforces.com/problemset/problem/747/A\n\nfunction check(const pixels, wid, heg: longint): boolean;\nbegin\n\tcheck:= ((pixels div wid) = heg) and (wid >= heg) and ((pixels mod wid) = 0);\nend;\n\nvar i, heg, wid, mid, pixels: longint;\nbegin\n\treadln(pixels);\n\twid:= pixels;\n\theg:= pixels div wid;\n\tfor i:= 1 to pixels do begin\n\t\tif check(pixels, pixels div i, i) then begin\n\t\t\twid:= i;\n\t\t\theg:= pixels div i;\n\t\tend;\n\tend;\n\twriteln(wid, ' ', heg);\n\treadln();\nend."}, {"source_code": "var n,i,u,v:longint;\nbegin\n readln(n);\n for i:=1 to trunc(sqrt(n)) do\n if n mod i = 0 then\n begin\n u:=i;\n v:=n div i;\n end;\n write(u,' ',v);\nend."}, {"source_code": "var i,n,a,b,res,x,y:longint;\nbegin\n//assign(input,'a.inp');reset(input);\n//assign(output,'a.out');rewrite(output);\nreadln(n);\nres:=maxlongint;\nfor i:=1 to 100000 do\n if n mod i=0 then\n begin\n a:=i;\n b:=n div i;\n if a<=b then\n if b-aj then break;\n if (j-i0) or (i-b=0)) then \nbegin\nc:=i-b;\ne:=i;\nf:=b;\nend;\nend;\nend;\nwriteln(f,' ',e);\nend."}, {"source_code": "var n,a:integer;\nbegin\nread(n);\nfor a:=round(sqrt(n)) downto 1 do\n if n mod a=0 then begin \n write(a,' ',n div a);\n break;\n end;\nend."}, {"source_code": "var\n n, i, min, am, bm, a, b : longint;\nbegin\n readln(n);\n min := 1000000;\n for i := 1 to trunc(sqrt(n)) do begin\n if (i * trunc(n div i) = n) and (i <= trunc(n div i)) then begin\n //write(i, ' ', trunc(n div i));\n a := i;\n b := trunc(n div i);\n //writeln(abs(a- b));\n if (abs(a - b) < min) then begin\n min := abs(a-b);\n am := a;\n bm := b;\n end;\n end;\n end;\n write(am, ' ', bm);\nend."}, {"source_code": "var n,i,r,x,y:longint;\nbegin\nreadln(n);\nr:=n;\nfor i:=1 to n do\nif (n mod i=0)and(abs(i- n div i)y then writeln(y,' ',x)\n else writeln(x,' ',y)\n end.\n "}, {"source_code": "var\ni:integer;\nn, maxdel: longint;\nbegin\n\treadln(n);\n\ti:=1; maxdel:=0;\n\twhile (i*i<=n) Do begin\n\tif (n mod i = 0) then\n\t\tmaxdel:=i;\n\t\ti:=i+1;\n\t\tend;\n\twrite(maxdel, ' ', n div maxdel);\n\twriteln;\nend."}, {"source_code": "var\n ans,a,b,i,n,k,j:longint;\n x,y:array[1..111111]of longint;\nbegin\n read(n);\n i:=2;\n j:=0;\n for i:=1 to n do \n if (n mod i=0) then begin j:=j+1;x[j]:=n div i;y[j]:=i;end;\n \n ans:=1000000000;\n for i:=1 to j do\n if abs(x[i]-y[i])=y[k] then writeln(y[k],' ',x[k]) else writeln(x[k],' ',y[k]);\nend."}, {"source_code": "var\n a, b, c, d, i, min, min_i: int64;\n \nbegin\n readln(a);\n i := 1;\n min := a;\n while i <= a do begin\n if (a mod i = 0) and (i - a div i < min) and (i >= a div i) then begin\n min := i - a div i;\n min_i := i;\n end;\n inc(i);\n end;\n writeln(a div min_i, ' ', min_i);\nend."}, {"source_code": "var n,i:longint;\nbegin\n readln(n);\n for i:=trunc(sqrt(n)) downto 1 do\n if n mod i=0 then\n begin\n writeln(i,' ',n div i);\n halt;\n end;\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n for i:=trunc(sqrt(n)) downto 1 do\n if n mod i=0 then\n begin\n writeln(i,' ',n div i);\n exit;\n end;\nend."}, {"source_code": "Var i , n , tmp , Ans : Longint;\n\nBegin\n tmp := High(Longint);\n Readln(n);\n For i := 1 to Trunc(Sqrt(n)) do\n If (n mod i = 0) then \n If (n div i) - i < tmp then \n Begin Ans := i; tmp := (n div i) - i; End;\n\n Write(Ans , ' ' , n div Ans);\nEnd."}, {"source_code": "var n,k:longint;\nbegin\nreadln(n);\nk:=trunc(sqrt(n));\nwhile n mod k>0 do dec(k);\nwrite(k,' ',n div k);\nreadln;\nend."}, {"source_code": "var a,b: longint;\n i,n: longint;\nbegin\n readln(n);\n b:=1000000;\n a:=0;\n for i:=1 to n do \n if (n mod i=0) and (abs(i-n div i)=n div i) then begin \n a:=n div i;\n b:=i;\n end\n else begin\n a:=i;\n b:=n div i;\n end;\n write(a,' ',b);\nend."}, {"source_code": "{$Q-}{$R-}\n\nUSES math;\n\nCONST signature='D_H_T_A_V';\n fip='1.inp';\n fop='1.out';\n\nVAR n,i:longint;\n\n PRocedure nhap;\n begin\n read(n) ;\n end;\n\n PRocedure xuly;\n begin\n for i := trunc(sqrt(n)) downto 1 do\n begin\n if n mod i = 0 then\n begin\n write(i,' ', n div i) ;\n exit;\n end;\n end;\n end;\n\n Procedure endpro;\n begin\n close(input) ; close(output);\n end;\n\nBEGIN\n // Assign(input,fip); reset(input);\n // ASsign(output,fop); rewrite(output);\n nhap;\n xuly;\n // endpro;\nEND.\n"}, {"source_code": "var n,max,i,r:integer;\nbegin\nreadln(n);\nmax:=1000001;\nFor i:=1 to n do\n If n mod i = 0 then\n If abs(i-(n div i))0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n); ot:=1000000000;\n for i:=1 to n do if n mod i=0 then\n begin\n j:=n div i;\n if i<=j then ot:=min(ot,abs(i-j));\n if ot=abs(i-j) then begin ii:=i;jj:=j; end;\n\n\n end;\n writeln(jj,' ',ii);\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var i,a,minn,n:integer;\n begin\n readln(n);\n minn:= n;\n for i:=1 to n do\n begin\n if (n mod i = 0)then\n begin\n if ((abs(i - n div i )< minn) and (i <= n div i) )\n then\n begin\n a:=i;\n minn := (abs(i - n div i ));\n end;\n end;\n end;\n writeln(a,' ',n div a);\n end.\n "}, {"source_code": "var\ni,k:integer;\nn:real;\nbegin\nread(n);\nk:=round(n);\nfor i:=round(sqrt(n)) downto 1 do\nif k mod i = 0 then\nbegin\nwriteln (i,' ', k div i);\nbreak;\nend; \nend."}, {"source_code": "var n,i:LongInt;\nBegin\n read(n);\n for i:= trunc(sqrt(n)) DownTo 1 do\n begin\n if n mod i=0\n then begin\n write(i,' ',n div i);\n Exit;\n end;\n end;\nEnd."}, {"source_code": "Program DisplaySize;\nuses math;\nvar n,i,a,b:longint;\nbegin //assign(input,'747A.inp'); reset(input);\n //assign(output,'747A.out'); rewrite(output);\n readln(n);\n for i:=1 to trunc(sqrt(n)) do\n begin if n mod i=0 then\n begin a:=i;\n b:=n div i;\n end;\n end;\n write(a,#32,b);\n //close(input); close(output);\nend."}, {"source_code": " var N,A,i,j,min,ans: int64;\n b:integer;\n \n begin\n \n readln(N);\n min:=10000000000;\n \n for b:=1 to N do\n if n mod b=0 then\n if (b-(n div b)=0) then\n begin\n min:=b-(n div b);\n ans:=b;\n end;\n \n writeln(N div ans,' ',ans);\n \n end."}, {"source_code": "Program con747z1;\nVar\n d:longint;\n i,n:longint;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(n); i:=round(sqrt(n))+1; d:=0;\n\n while (i>1) do Begin\n\n if (n mod i = 0) then Begin\n d:=i;\n break;\n End;\n\n dec(i);\n\n End;\n\n if (d = 0) then write(1,' ',n) else\n if (d>n div d) then write(n div d,' ',d) else write(d,' ',n div d);\n\n\n\n //close(input); close(output);\nEnd.\n"}, {"source_code": "var a,b,n,min,i:longint;\nbegin\n readln(n);\n a:=1; b:=n;\n i:=1;\n while b>a do\n begin\n inc(i);\n if n mod i=0 then\n begin\n b:=n div i;\n a:=n div b;\n end;\n end;\n writeln(b,' ',a);\nend."}, {"source_code": "Const Finp='';\n Fout='';\nVar n,a,b:longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nProcedure Solve;\nVar i,diff:longint;\nBegin\n diff:=maxlongint;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then\n if (n div i)-i0 do dec(a);\n b:=n div a;\n writeln(a,' ',b);\nend."}, {"source_code": "var x,i:longint;\nbegin\n read(x);\n for i:=round(sqrt(x)) downto 1 do\n if x mod i =0\n then begin write(i,' ',x div i);halt;end;\nend."}, {"source_code": "var a,b,i,n : longint;\nbegin\n readln(n); \n for i:=1 to trunc(sqrt(n)) do begin\n if n mod i = 0 then begin a:=i; b:=n div i; end;\n end;\n writeln(a,' ',b);\nend."}, {"source_code": "{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n\nuses math;\n\nprocedure mofile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ELSE}\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ENDIF}\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n,i:longint;\n\nprocedure xuli;\nvar\n i:longint;\nbegin\n readln(n);\n for i:=trunc(sqrt(n)) downto 1 do\n begin\n if n mod i=0 then\n begin\n writeln(i,' ',n div i);\n halt;\n end;\n end;\nend;\n\nbegin\n //mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n a,i:longint;\nbegin\n readln(a);\n for i:=trunc(sqrt(a)) downto 1 do if a mod i=0 then\n begin\n writeln(i,' ',a div i);\n halt;\n end;\nend."}, {"source_code": "var\n\tn: longint;\n\ta, b: longint;\nprocedure giai;\nvar i: longint;\nbegin\n\tfor i:=1 to trunc(sqrt(n)) do\n\t\tif n mod i = 0 then\n\t\tbegin\n\t\t\ta:= i;\n\t\t\tb:= n div i;\n\t\tend;\n\twriteln(a,#32,b);\nend;\n\nbegin\n\treadln(n);\n\tgiai;\nend."}, {"source_code": "var\ni,k:integer;\nn:real;\nbegin\nread(n);\nk:=round(n);\nfor i:=round(sqrt(n)) downto 1 do\nif k mod i = 0 then\nbegin\nwriteln (i,' ', k div i);\nbreak;\nend; \nend."}, {"source_code": "var\ni,n:integer;\nbegin\nread(n);\nfor i:=round(sqrt(n)) downto 1 do\nif n mod i = 0 then\nbegin\nwriteln (i,' ', n div i);\nbreak;\nend; \nend."}, {"source_code": "var n,a,b:longint;\n x:real;\nbegin\n//assign(input,'baiA.inp');reset(input);\n//assign(output,'baiA.out');rewrite(output);\nreadln(n);\nb:=trunc(sqrt(n));\nif n mod b = 0 then writeln(b,' ',n div b)\nelse begin\nwhile n mod b <> 0 do\n inc(b);\nwriteln(n div b,' ',b); end;\n\n{if x=trunc(x) then writeln(x,' ',x)\nelse\n begin\n b:=trunc(x)+1;\n a:=n div b;\n writeln(a,' ',b);\n end; }\nend.\n"}, {"source_code": "var\n a,m,j,i,n,g : longint;\nbegin\n readln(n);\n for i:= trunc(sqrt(n)) downto 1 do\n begin\n if n mod i = 0 then\n begin\n writeln(i,' ',n div i);\n break;\n end;\n end;\nend."}, {"source_code": "var n,k:longint;\nbegin\nreadln(n);\nk:=trunc(sqrt(n));\nwhile n mod k>0 do k:=k-1;\nwrite(k,' ',n div k);\nend."}, {"source_code": "var n,i,x:LongInt;\nbegin\nreadln(n);\nfor i:=1 to round(sqrt(n)) do\n begin\n if n mod i=0 then\n x:=i;\n end;\nwriteln(x,' ',n div x);\nend."}, {"source_code": "var n, i: longword;\nbegin\n readln(n);\n for i:=trunc(sqrt(n)) downto 1 do\n if (n mod i)=0 then\n begin\n writeln(i, ' ', n div i); break;\n end;\nend."}, {"source_code": "Const fi='';\n fo='';\n\nVar n:longint;\n a,b:longint;\n f:text;\n\nProcedure Enter;\nBegin\n Assign(f,fi);reset(f);\n Readln(f,n);\n Close(f);\nEnd;\n\nProcedure Run;\nVar t,i:longint;\nBegin\n t:=trunc(sqrt(n));\n For i:=1 to t do\n If (n mod i)=0 then\n Begin\n a:=i;\n b:=n div i;\n End;\nEnd;\n\nProcedure Print;\nBegin\n Assign(f,fo);rewrite(f);\n Writeln(f,a,' ',b);\n Close(f);\nEnd;\n\nBEGIN\n Enter;\n Run;\n Print;\nEND."}, {"source_code": "uses math;\nvar\n n,x,y,mn,i : longint;\n\nbegin\n mn:=maxlongint;\n readln(n);\n for i:=1 to n do\n if (n mod i = 0) and (abs(n div i-i) < mn) then begin\n mn:=abs(n div i-i);\n x:=i;\n y:=n div i;\n end;\n writeln(min(x,y),' ',max(x,y));\nend."}, {"source_code": "uses math;\nvar n,i,j,k,a,b,a1,b1,m:longint;\n abc:array[1..10000] of longint;\nbegin\nread(n);\nfor i:=round(sqrt(n))+1 downto 1 do\nif j>4 then break else\nif n/i-trunc(n/i)=0 then begin\n inc(j);\n abc[j]:=i;\n end;\nm:=100000000; \nfor i:=1 to 3 do\nif abc[i]<>0 then if abs(abc[i]-n div abc[i])= i then\n If N div i - i < b - a then\n Begin\n a:=i;\n b:=N div i;\n End;\n Write(a,' ',b);\n End.\n"}, {"source_code": "var\ni,j,c,d,e,b,n:longint;\nbegin\nread(n);\nif trunc(sqrt(n))=sqrt(n) then begin writeln(trunc(sqrt(n)),' ',trunc(sqrt(n)));exit;end;\nfor i:=trunc(sqrt(n)) downto 1 do\nbegin\nif n mod i=0 then begin writeln(i,' ',n div i);exit;\nend;\nend;\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor i:=1 to round(sqrt(n)) do\n if n mod i=0 then a:=i;\nwriteln(a,' ',n div a);\nend."}, {"source_code": "procedure main();\nvar\n n,row,col:longint;\nbegin\n read(n);\n for row := trunc(sqrt(n)) downto 1 do\n begin\n if n mod row = 0 then\n begin\n col := n div row;\n break;\n end;\n end;\n write(row,' ',col);\nend;\n\nbegin\n main();\nend."}, {"source_code": "var\n i,j,n,x,y,t:longint;\nbegin\n read(n);\n for i:=trunc(sqrt(n)) downto 1 do\n begin\n j:=n div i;\n if (i*j=n) then begin x:=i;y:=j;break;end;\n end;\n if (x>y) then begin t:=x;x:=y;y:=t;end;\n writeln(x,' ',y);\nend."}, {"source_code": "var\n n,i,j,min,x,y:longint;\nbegin\n read(n);\n min:=maxlongint;\n for i:=1 to n do \n begin\n j:=n div i;\n if (i*j=n) and (i<=j) then \n begin\n if j-i=a)AND(b=n/i) then begin\n min:=b-a;\n x:=a;\n y:=b;\n end;\n end;\n write(x,' ',y);\nend."}, {"source_code": "Var a,b,n,i:longint;\n c:real;\n function min(x,y:longint):longint;\n begin\n min:=x;\n if x>y then min:=y;\n end;\n \n function max(x,y:longint):longint;\n begin\n max:=x;\n if x=y[k] then writeln(y[k],' ',x[k]) else writeln(x[k],' ',y[k]);\nend. "}, {"source_code": "var i,j,res,ires,jres,n:longint;\nbegin\n readln(n);\n res:=round(1e9); \n for i:=1 to 1000000 do\n if n mod i=0 then\n begin\n j:=n div i;\n if (i<=j) and (abs(i-j) y then \n begin \n t:=x;\n x:=y;\n y:=t;\n end;\n writeln(x,' ',y);\nend."}, {"source_code": "var\nn,i:longint;\nbegin\nreadln(n);\nfor i:=trunc(sqrt(n)) downto 1 do\n if n mod i=0 then begin writeln(i,' ',n div i);halt;end;\nend."}], "negative_code": [{"source_code": "var\n ans,a,b,i,n,k,j:longint;\n x,y:array[1..111111]of longint;\nbegin\n read(n);\n i:=2;\n j:=0;\n for i:=1 to n do \n if (n mod i=0) then begin j:=j+1;x[j]:=n div i;y[j]:=i;end;\n \n ans:=1000000000;\n for i:=1 to j do\n if abs(x[i]-y[i])=i then begin\n writeln(i,' ',n div i);\n break;\n end;\n end;\nend;\nend."}, {"source_code": "var\nn,i:longint;\nbegin\nreadln(N);\nif n=1 then writeln(1)\nelse begin\nfor i:=n div 2 downto 1 do begin\n if n mod i = 0 then begin\n if n div i >=i then begin\n writeln(i,' ',n div i);\n break;\n end;\n end;\nend;\nend;\nend."}, {"source_code": "var t,z,i,n,k: longint;\n a: array [1..1000] of longint;\n b: array [1..300] of longint;\nbegin\nz:=0;\nreadln (k);\nwhile z*z= s[i+1] then break;\n end;\n\n if length(s) <> 1 then if s[i] >= s[i+1] then begin writeln(0); continue; end;\n\n for i:=length(s) downto 1 do ans:=ans+sum1[i-1]+sum[i,ord(s[i])-96];\n\n writeln(ans);\n end;\nend.\n\n\n{ for i:=1 to 5 do\n begin\n for j:=1 to 26 do write(f[i,j],' ');\n writeln;\n end;\n\n for i:=6 to 6 do\n begin\n for j:=1 to 26 do write(sum[i,j],' ');\n writeln;\n end;}\n\n\n\nend.\n"}, {"source_code": "var a, d, e, i: longint;\nb, f, c: real;\nbegin\nread(a);\nc:=a;\nfor i:=1 to a do\nbegin\nif a mod i=0 then\nbegin\nb:=a/i;\nif ((i-b0) or (i-b=0)) then \nbegin\nc:=i-b;\ne:=i;\nf:=b;\nend;\nend;\nend;\nwriteln(f,' ',e);\nend."}, {"source_code": "var\n n, i, min, am, bm, a, b : longint;\nbegin\n readln(n);\n min := 99999;\n for i := 1 to trunc(sqrt(n)) do begin\n if (i * trunc(n div i) = n) and (i <= trunc(n div i)) then begin\n //write(i, ' ', trunc(n div i));\n a := i;\n b := trunc(n div i);\n //writeln(abs(a- b));\n if (abs(a - b) < min) then begin\n min := abs(a-b);\n am := a;\n bm := b;\n end;\n end;\n end;\n write(am, ' ', bm);\nend.\n"}, {"source_code": "Var i , n , tmp , Ans : Longint;\n\nBegin\n tmp := High(Longint);\n Readln(n);\n For i := 1 to Trunc(Sqrt(n)) do\n If (n mod i = 0) then \n If (n div i) - i < tmp then \n Begin Ans := i; tmp := (n div i) - i; End;\n Write(i , ' ' , n div i);\nEnd."}, {"source_code": "var n,i: integer;\n a,b: real;\nbegin\n readln(n);\n i:=0;\n while a*b<>n do begin\n a:=(-i+sqrt(i*i+4*n))/2;\n if (frac(a)=0) then b:=a+i;\n i:=i+1;\n end;\n write(a,' ',b);\nend."}, {"source_code": "var n,max,i,r:integer;\nbegin\nreadln(n);\nmax:=1000001;\nFor i:=1 to n do\n If n mod i = 0 then\n If abs(i-(n div i))=n div r\n then writeln(r,' ',n div r)\n else writeln(n div r,' ', r);\nEnd.\n"}, {"source_code": "var n,i:LongInt;\nBegin\n read(n);\n for i:= trunc(sqrt(n)) DownTo 1 do\n begin\n if n mod i=0\n then begin\n write(i,n div i);\n Exit;\n end;\n end;\nEnd."}, {"source_code": "Program con747z1;\nVar\n d:array[1..2] of longint;\n i,n,k:longint;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(n); k:=0; i:=round(sqrt(n));\n\n if (i*i=n) then write(i,' ',i) else Begin\n\n inc(i);\n while (i>=1) and (k<2) do Begin\n if (n mod i = 0) then Begin\n inc(k);\n d[k]:=i;\n End;\n dec(i);\n End;\n if (k = 1) then write(1,' ',n) else write(d[2],' ',d[1]);\n End;\n\n //close(input); close(output);\nEnd."}, {"source_code": "Program con747z1;\nVar\n d:longint;\n i,n:longint;\nBegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(n); i:=round(sqrt(n))+1; d:=0;\n\n while (i>1) do Begin\n\n if (n mod i = 0) then Begin\n d:=i;\n break;\n End;\n\n dec(i);\n\n End;\n\n if (d = 0) then write(1,' ',n) else write(n div d,' ',d);\n\n\n\n //close(input); close(output);\nEnd.\n"}, {"source_code": "var x,i:longint;\nbegin\n read(x);\n for i:=round(sqrt(x)) downto 1 do\n if x mod i =0\n then begin write(x div i,' ',i);halt;end;\nend."}, {"source_code": "var n,a,b:longint;\n x:real;\nbegin\n//assign(input,'baiA.inp');reset(input);\n//assign(output,'baiA.out');rewrite(output);\nreadln(n);\nb:=trunc(sqrt(n));\nif n mod b = 0 then inc(b); \nwhile n mod b <> 0 do\n inc(b);\nwriteln(n div b,' ',b);\n\n{if x=trunc(x) then writeln(x,' ',x)\nelse\n begin\n b:=trunc(x)+1;\n a:=n div b;\n writeln(a,' ',b);\n end; }\nend.\n"}, {"source_code": "var\ny,u,i,o,p,l:integer;\nbegin\nreadln(y);\n\n\nfor i:=1 to y do \nfor o:=1 to y do\nbegin\nif (i*o=y) and (i0)) then begin\nu:=i;\np:=o;\nl:=o-i;\nend;\nend;\n\nwriteln(u,' ',p);\n\nend.\n\n"}, {"source_code": "var\ny,u,i,j,o,p,l:integer;\nbegin\nreadln(y);\n\nfor i:=trunc(sqrt(y)) downto 1 do begin\n for j:=trunc(sqrt(y)) to y do \n if i*j=y then begin u:=i; p:=j; break; end; \n break;\n end;\n\nwriteln(u,' ',p);\n\nend.\n\n"}, {"source_code": "var\n n,i,j,min,x,y:longint;\nbegin\n read(n);\n min:=maxlongint;\n for i:=1 to n div 2 do \n begin\n j:=n div i;\n if (i*j=n) and (i<=j) then \n begin\n if j-in then exit;\n if dd[u,x,y,k,l] then exit;\n b[x,y] := true;\n dd[u,x,y,k,l]:=true;\n if l = 1 then\n begin\n calc(u+1, x+dx[k mod 8+1], y+dy[k mod 8+1], k mod 8+1,a[u+1]);\n calc(u+1, x+dx[(k+6) mod 8+1], y+dy[(k+6) mod 8+1],(k+6) mod 8+1, a[u+1]);\n exit;\n end;\n calc(u,x+dx[k],y+dy[k],k,l-1);\nend;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n calc(1, 0, 0, 1, a[1]);\n for i:=-sum to sum do\n for j:=-sum to sum do\n \tif b[i,j] then inc(res);\n writeln(res);\nend."}, {"source_code": "{$Mode objfpc}\n\ntype\n node = record\n x,y,d:integer;\n end;\n\nvar\n i,n,j,kq:integer;\n a:array[0..40] of integer;\n fx,fy:array[0..8] of integer;\n top:integer;\n f,e:array[0..8000000] of node;\n pass:array[-200..200,-200..200,1..8] of boolean;\n axx:array[-400..400,-400..400] of boolean;\n\nprocedure solve(o:integer);\nvar i,dem,j,x,y,d,z:integer;\n begin\n fillchar(pass,sizeof(pass),false);\n dem:=0;\n for i:=1 to top do\n begin\n x:=f[i].x; y:=f[i].y; d:=f[i].d;\n for j:=1 to a[o]-1 do\n begin\n axx[x,y]:=true;\n x:=x + fx[d];\n y:=y + fy[d];\n end;\n axx[x,y]:=true;\n z:=d+1;\n if z = 9 then z:=1;\n if not pass[x+fx[z],y+fy[z],z] then\n begin\n inc(dem);\n e[dem].x:=x+fx[z];\n e[dem].y:=y+fy[z];\n e[dem].d:=z;\n pass[x+fx[z],y+fy[z],z]:=true;\n end;\n z:=d-1;\n if z = 0 then z:=8;\n if not pass[x+fx[z],y+fy[z],z] then\n begin\n inc(dem);\n e[dem].x:=x+fx[z];\n e[dem].y:=y+fy[z];\n e[dem].d:=z;\n pass[x+fx[z],y+fy[z],z]:=true;\n end;\n end;\n top:=dem;\n f:=e;\n for i:=1 to top do\n f[i]:=e[i];\n end;\n\nbegin\n fx[1]:=0; fy[1]:=1;\n fx[2]:=1; fy[2]:=1;\n fx[3]:=1; fy[3]:=0;\n fx[4]:=1; fy[4]:=-1;\n fx[5]:=0; fy[5]:=-1;\n fx[6]:=-1; fy[6]:=-1;\n fx[7]:=-1; fy[7]:=0;\n fx[8]:=-1; fy[8]:=1;\n read(n);\n for i:=1 to n do read(a[i]);\n top:=1;\n f[1].x:=0;\n f[1].y:=0;\n f[1].d:=1;\n for i:=1 to n do\n solve(i);\n for i:=-400 to 400 do\n for j:=-400 to 400 do\n if axx[i,j] then inc(kq);\n write(kq);\nend.\n"}, {"source_code": "const dx:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);\n dy:array[1..8] of longint=(1,1,0,-1,-1,-1,0,1);\nvar flag,now:array[-200..200,-200..200,1..8] of boolean;\n flag1:array[-200..200,-200..200] of boolean;\n n,i,j,k,ans,x,y:longint;\n\tt:array[0..200] of longint;\nprocedure deal(x,y,k,tt:longint);\nvar i,j,t1,t2,nowx,nowy:longint;\nbegin\n t1:=tt-1;\n if (t1<=0) then t1:=t1+8;\n t2:=tt+1;\n if (t2>=9) then t2:=t2-8;\n nowx:=x;nowy:=y;\n for i:=1 to t[k] do\n begin\n nowx:=nowx+dx[t1];\n nowy:=nowy+dy[t1];\n flag1[nowx,nowy]:=true;\n end;\n now[nowx,nowy,t1]:=true;\n nowx:=x;nowy:=y;\n for i:=1 to t[k] do\n begin\n nowx:=nowx+dx[t2];\n nowy:=nowy+dy[t2];\n flag1[nowx,nowy]:=true;\n end;\n now[nowx,nowy,t2]:=true;\nend;\nbegin\n readln(n);\n fillchar(t,sizeof(t),0);\n for i:=1 to n do\n\tread(t[i]);\n readln;\n fillchar(flag,sizeof(flag),false);\n fillchar(flag1,sizeof(flag1),false);\n for i:=1 to t[1] do\n flag1[1,i]:=true;\n flag[1,t[1],1]:=true;\n for i:=2 to n do\n begin\n fillchar(now,sizeof(now),false);\n for x:=-200 to 200 do\n\t for y:=-200 to 200 do\n\t\tfor k:=1 to 8 do\n\t if (flag[x,y,k]) then\n\t deal(x,y,i,k);\n for x:=-200 to 200 do\n\t for y:=-200 to 200 do\n\t\tfor k:=1 to 8 do\n\t\tflag[x,y,k]:=now[x,y,k];\n end;\n ans:=0;\n for x:=-200 to 200 do\n\tfor y:=-200 to 200 do\n\t if flag1[x,y] then inc(ans);\n writeln(ans);\nend.\n\t "}, {"source_code": "const\n gox : array[0..7] of longint = (+1 , +1 , +0 , -1 , -1 , -1 , +0 , +1) ;\n goy : array[0..7] of longint = (+0 , +1 , +1 , +1 , +0 , -1 , -1 , -1) ;\n\nvar\n n,front,rear : longint ;\n a,s : array[0..30] of longint ;\n dd : array[-200..200,-200..200] of boolean ;\n free : array[0..30,-150..150,-150..150,0..7,1..5] of boolean ;\n\nprocedure enter ;\n var i,j : longint ;\n begin\n\n read(n) ;\n for i := 1 to n do read(a[i]) ;\n\n for i := n downto 1 do s[i] :=s[i+1] + a[i] ;\n\n end ;\n\n\nprocedure dfs(i,x,y,t,k : longint) ;\n var j,cx,cy,new1,new2 : longint ;\n begin\n\n if (i > n) then exit ;\n if (free[i][x][y][t][k]) then exit ;\n\n dd[x][y] := true ;\n free[i][x][y][t][k] := true ;\n\n if (k > 1) then dfs(i,x+gox[t],y+goy[t],t,k-1)\n else\n\n begin\n\n new1 := (t+1) mod 8 ; new2 := (t+7) mod 8 ;\n\n dfs(i+1,x+gox[new1],y+goy[new1],new1,a[i+1]) ;\n dfs(i+1,x+gox[new2],y+goy[new2],new2,a[i+1]) ;\n\n end ;\n\n end ;\n\nprocedure main ;\n var i,j,res : longint ;\n begin\n\n dfs(1,0,0,0,a[1]) ;\n\n res := 0 ;\n\n for i := -150 to 150 do\n for j := -150 to 150 do\n if (dd[i][j]) then inc(res) ;\n\n writeln(res) ;\n\n end ;\n\nbegin\n\n //assign(input,'750D.inp') ; reset(input) ;\n //assign(output,'750D.out') ; rewrite(output) ;\n enter ;\n main ;\n\nend.\n"}, {"source_code": "program d750;\n\nvar\n f : array [-150..150,-149..150] of boolean;\n i, j, n : longint;\n sol : longint = 0;\n t : array [0..35] of longint;\n dx : array [0..7] of longint = (0, 1, 1, 1, 0, -1, -1, -1);\n dy : array [0..7] of longint = (1, 1, 0, -1, -1, -1, 0, 1);\n dp : array [-150..150,-149..150,0..35,0..7] of boolean;\n\nprocedure dfs(x, y, d, a : integer);\nvar\n i : longint;\nbegin\n if d = n then exit;\n if a > 7 then a := a - 8;\n if a < 0 then a := a + 8;\n if d > 0 then begin\n x := x + dx[a];\n y := y + dy[a];\n end;\n if dp[y, x, d, a] then exit;\n dp[y, x, d, a] := true;\n for i := 0 to t[d]-1 do f[y+i*dy[a], x+i*dx[a]] := true;\n dfs(x+(t[d]-1)*dx[a], y+(t[d]-1)*dy[a], d+1, a+1);\n dfs(x+(t[d]-1)*dx[a], y+(t[d]-1)*dy[a], d+1, a-1);\nend;\n\nbegin\n readln(n);\n for i := 0 to n-1 do read(t[i]);\n dfs(0, 0, 0, 0);\n for i := -150 to 150 do for j := -149 to 150 do if f[i, j] then inc(sol);\n writeln(sol);\nend.\n"}, {"source_code": "Program Rekurs;\nconst gr=150;\nvar need:array[0..1]of array[-gr..gr]of array[-gr..gr]of longint;\n nap:array[0..1]of array[-gr..gr]of array[-gr..gr]of array[0..7]of longint;\n was:array[-gr..gr]of array[-gr..gr]of longint;\n youdid,i,j,u,kol,n:longint;\n l1,l2:byte;\n t:array[1..30]of longint;\n \nProcedure Dodo(i,j,u,t:longint; l1,l2:byte; ww:longint);\nvar i1,a,j1:longint;\n\nbegin\ni1:=i;\nj1:=j;\nfor a:=1 to t do\n begin\n if u=0 then begin inc(i1); end; \n if u=1 then begin inc(j1); inc(i1); end;\n if u=2 then begin inc(j1); end;\n if u=3 then begin inc(j1); dec(i1); end;\n if u=4 then begin dec(i1); end;\n if u=5 then begin dec(j1); dec(i1); end;\n if u=6 then begin dec(j1); end;\n if u=7 then begin dec(j1); inc(i1); end;\n was[i1][j1]:=1;\n end;\nneed[l2][i1][j1]:=ww+1;\nnap[l2][i1][j1][(u+1) mod 8]:=1;\nnap[l2][i1][j1][(u-1+8) mod 8]:=1;\nend;\n\n\nbegin\nread(n);\nfor i:=1 to n do\n begin\n read(t[i]);\n end;\n\nyoudid:=0;\nneed[0][0][-1]:=1;\nnap[0][0][-1][0]:=1;\n//was[0][0]:=1;\nl1:=1;\nl2:=0;\nwhile youdidn then exit;\nif vst[x,y,d,r] then exit;{\nfor i:=r downto 1 do\nif vst[x,y,d,i] then exit; }\n//INC(kq);\nvst[x,y,d,r]:=true;\nfor i:=1 to a[r] do\nif not v[x+DIRX[d]*i,y+DIRY[d]*i] then\nbegin\nv[x+DIRX[d]*i,y+DIRY[d]*i]:=true;\nINC(kq);\nend;\n//if r=1 then DEC(a[r]);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);\nend;\nprocedure xuat;\nbegin\nassign(f,OUTP);\nrewrite(f);\nwrite(f,kq);\nclose(f);\nend;\nbegin\nnhap;\nxuLi(0,0,0,1);\nxuat;\nend."}, {"source_code": " const eps=0.00000001; besk=2000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;\n aa,bb,cc:double;\n npx,npy:array[-1000..1000] of int64;\n napx,napy:array[-1..30,-100..100] of int64;\n finzan,zan:array[0..31,-1..10,-200..200,-200..200] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,d,x,y,aold,b,a:array[-10..1000002] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n zzan:array[-1000..3000,-1000..3000] of boolean;\n ss, ss1,ss2:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n sss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n oldflag,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n npx[0]:=1;npy[0]:=0;\n npx[1]:=1;npy[1]:=-1;\n npx[2]:=0;npy[2]:=-1;\n npx[3]:=-1;npy[3]:=-1;\n npx[4]:=-1;npy[4]:=0;\n npx[5]:=-1;npy[5]:=1;\n npx[6]:=0;npy[6]:=1;\n npx[7]:=1;npy[7]:=1;\n for i:=0 to 1000 do begin npx[i]:=npx[i mod 8];npy[i]:=npy[i mod 8]; end;\n for i:=1 to 1000 do begin npx[i-1000]:=npx[i]; npy[i-1000]:=npy[i]; end;\n\n { for i:=-20 to 20 do writeln(i,' ',npx[i],' ',npy[i]);\n }\n\n for i:=1 to n do read(a[i]);\n\n\n zan[0,0,0,0]:=true;\n for step:=1 to n do\n begin\n for i:=-200 to 200 do for j:=-200 to 200 do for k:=0 to 7 do\n if zan[step-1,k,i,j] then\n begin\n begin\n dx:=npx[k];\n dy:=npy[k];\n\n for ii:=1 to a[step] do\n zzan[i+ii*dx,j+ii*dy]:=true;\n zan[step,(k+7) mod 8,i+dx*a[step],j+dy*a[step]]:=true;\n zan[step,(k+1) mod 8,i+dx*a[step],j+dy*a[step]]:=true;\n\n\n\n end;\n end;\n\n\n\n\n\n\n\n\n\n\n\n end;\n ot:=0;\n\n for i:=-1000 to 1000 do for j:=-1000 to 1000 do if zzan[i,j] then\n begin\n inc(ot);\n {writeln(i,' ',j); }\n end;\n writeln(ot);\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='d';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n \n\nvar qc:array[0..30,0..300,0..300,0..7]of shortint;\n rr:array[0..300,0..300]of shortint;\n dir:array[0..7,0..1]of shortint;\n qq:array[0..30]of shortint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n dd,dx,dy,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q7 then dy:=0;\n for t:=1 to qq[k] do\n begin\n rr[i+dir[dx,0]*t,j+dir[dx,1]*t]:=1;\n rr[i+dir[dy,0]*t,j+dir[dy,1]*t]:=1;\n end;\n qc[k,i+dir[dx,0]*qq[k],j+dir[dx,1]*qq[k],dx]:=1;\n qc[k,i+dir[dy,0]*qq[k],j+dir[dy,1]*qq[k],dy]:=1;\n end;\n end;\n res:=0;\n for i:=0 to 300 do\n begin\n for j:=0 to 300 do\n if rr[i,j]>0 then\n begin\n //write('#');\n inc(res);\n end\n //else write('.');\n //writeln;\n end;\n writeln(res);\n\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "const\n maxn\t=\t35;\n dx \t\t: \tarray[1..8] of longint = (0, 1, 1, 1, 0, -1, -1, -1);\n dy\t\t:\tarray[1..8] of longint = (1, 1, 0, -1, -1, -1, 0, 1);\n\nvar\n i, j: longint;\n n, s, ans: longint;\n a:array[0..maxn] of longint;\n vis:array[0..maxn, -maxn*5..maxn*5, -maxn*5..maxn*5, 1..8, 0..5] of boolean;\n choose:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;\n\nprocedure calc(i, x, y, k, l:longint);\nbegin\n if i > n then exit;\n if vis[i, x, y, k, l] then exit;\n choose[x, y] := true;\n vis[i, x, y, k, l]:=true;\n\n if l = 1 then\n begin\n calc(i + 1, x + dx[k mod 8 + 1], y + dy[k mod 8 + 1], k mod 8 + 1,a[i + 1]);\n calc(i + 1, x + dx[(k + 6) mod 8 + 1], y + dy[(k + 6) mod 8 + 1],(k + 6) mod 8 + 1, a[i + 1]);\n exit;\n end;\n\n calc(i,x+dx[k],y+dy[k],k,l-1);\nend;\n\nprocedure print;\n \tbegin\n \t for i := -s to s do\n \tfor j := -s to s do\n \t\tif choose[i, j] then inc(ans);\n\n writeln(ans);\n \tend;\n\nbegin\n //assign(input, 'in.txt');\n //reset(input);\n\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n s := s + a[i];\n end;\n //writeln(s);\n calc(1, 0, 0, 1, a[1]);\n print;\n //close(input);\nend."}, {"source_code": "{$IFDEF ONLINE_JUDGE}\n{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n{$ENDIF}\n\nuses math;\n\nprocedure mofile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ELSE}\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ENDIF}\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n maxn=30+2;\n dx:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);\n dy:array[1..8] of longint=(1,1,0,-1,-1,-1,0,1);\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n,sum,res:longint;\n a:array[0..maxn] of longint;\n kt:array[0..maxn,-maxn*5..maxn*5,-maxn*5..maxn*5,1..8,0..5] of boolean;\n chon:array[-maxn*5..maxn*5,-maxn*5..maxn*5] of boolean;\n\nprocedure dfs(i,x,y,k,l:longint);\nbegin\n if i>n then exit;\n if kt[i,x,y,k,l] then exit;\n kt[i,x,y,k,l]:=true;\n chon[x,y]:=true;\n if l=1 then\n begin\n dfs(i+1,x+dx[k mod 8+1],y+dy[k mod 8+1],k mod 8+1,a[i+1]);\n dfs(i+1,x+dx[(k+6) mod 8+1],y+dy[(k+6) mod 8+1],(k+6) mod 8+1,a[i+1])\n end\n else dfs(i,x+dx[k],y+dy[k],k,l-1);\nend;\n\nprocedure xuli;\nvar\n i,j:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n\n dfs(1,0,0,1,a[1]);\n for i:=-sum to sum do\n for j:=-sum to sum do\n if chon[i,j] then inc(res);\n\n writeln(Res);\nend;\n\nbegin\n mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\nuses math;\nconst log=18;\n ms=1e-9;\n oo=round(1e9);\n modulo=1000000007;\n fi='';\n fo='';\n maxn=31;\n maxm=152;\n move:array[0..7,1..2]of longint=((1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1));\n\nvar f1,f2:text;\n a:array[-152..152,-152..152]of longint;\n f:array[0..maxn,-152..152,-152..152,0..8]of longint;\n n:longint;\n re:array[0..maxn]of longint;\n\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\n\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure input;\n var i:longint;\n begin\n readln(f1,n);\n for i:=1 to n do\n read(f1,re[i]);\n end;\n\n\nprocedure init;\n var i,j:longint;\n\n begin\n f[1,re[1],0,7]:=1;\n f[1,re[1],0,1]:=1;\n for i:=1 to re[1] do\n a[i,0]:=1;\n end;\n\nprocedure solve;\n var i,j,x,y,l,r,k,d:longint;\n begin\n for i:=2 to n do\n begin\n for l:=-maxm to maxm do\n for r:=-maxm to maxm do\n for k:=0 to 7 do\n if f[i-1,l,r,k]=1 then\n begin\n x:=l;y:=r;\n for d:=1 to re[i] do\n begin\n x:=x+move[k,1];\n y:=y+move[k,2];\n a[x,y]:=1;\n end;\n f[i,x,y,(k+7)mod 8]:=1;\n f[i,x,y,(k+1)mod 8]:=1;\n end;\n end;\n end;\n\nprocedure output;\n var i,ans,j:longint;\n begin\n ans:=0;\n for i:=-maxm to maxm do\n for j:=-maxm to maxm do\n if a[i,j]=1 then inc(ans);\n writeln(f2,ans);\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n\n"}, {"source_code": "type\n rec=record\n \t\tx,y,d,t:longint;\n \t end;\nconst\n dx:array[0..7] of longint=(-1,-1,0,1,1,1,0,-1);\n dy:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);\nvar\n q:array[0..2000000] of rec;\n vis:array[-150..150,-150..150,0..7,0..150] of boolean;\n occ:array[-200..200,-200..200] of boolean;\n turn:array[0..200] of boolean;\n a:array[0..30] of longint;\n l,r:array[0..7] of longint;\n n,i,j,ans,head,tail,d:longint;\nprocedure push(x,y,d,t:longint);\n begin\n if (vis[x][y][d][t])or(t>a[n]) then exit;\n vis[x][y][d][t]:=true;\n if not occ[x][y] then\n begin\n occ[x][y]:=true;\n //writeln(x,' ',y);\n inc(ans);\n end;\n q[tail].x:=x;q[tail].y:=y;\n q[tail].d:=d;q[tail].t:=t;\n inc(tail);\n end;\nbegin\n //writeln((sizeof(vis))/1024/1024:0:8);\n //assign(input,'D.in');reset(input);\n //assign(output,'D.out');rewrite(output);\n read(n);\n for i:=1 to n do read(a[i]);\n for i:=2 to n do inc(a[i],a[i - 1]);\n fillchar(turn,sizeof(turn),false);\n for i:=1 to n do turn[a[i]]:=true;\n fillchar(vis,sizeof(vis),false);\n fillchar(occ,sizeof(occ),false);\n q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;\n vis[0][0][0][1]:=true;occ[0][0]:=true;ans:=1;\n for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;\n for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;\n head:=1;tail:=2;\n while (head n then exit;\n if vis[i, x, y, k, l] then exit;\n choose[x, y] := true;\n vis[i, x, y, k, l]:=true;\n\n if l = 1 then\n begin\n calc(i + 1, x + dx[k mod 8 + 1], y + dy[k mod 8 + 1], k mod 8 + 1,a[i + 1]);\n calc(i + 1, x + dx[(k + 6) mod 8 + 1], y + dy[(k + 6) mod 8 + 1],(k + 6) mod 8 + 1, a[i + 1]);\n exit;\n end;\n\n calc(i,x+dx[k],y+dy[k],k,l-1);\nend;\n\nprocedure print;\n \tbegin\n \t for i := -s to s do\n \tfor j := -s to s do\n \t\tif choose[i, j] then inc(ans);\n\n writeln(ans);\n \tend;\n\nbegin\n //assign(input, 'in.txt');\n //reset(input);\n\n readln(n);\n for i:=1 to n do\n begin\n read(a[i]);\n s := s + a[i];\n end;\n writeln(s);\n calc(1, 0, 0, 1, a[1]);\n print;\n //close(input);\nend."}, {"source_code": "type\n rec=record\n \t\tx,y,d,t:longint;\n \t end;\nconst\n dx:array[0..7] of longint=(-1,-1,0,1,1,1,0,-1);\n dy:array[0..7] of longint=(0,1,1,1,0,-1,-1,-1);\nvar\n q:array[0..2000000] of rec;\n vis:array[-200..200,-200..200,0..7] of boolean;\n occ:array[-200..200,-200..200] of boolean;\n turn:array[0..200] of boolean;\n a:array[0..30] of longint;\n l,r:array[0..7] of longint;\n n,i,j,ans,head,tail,d:longint;\nprocedure push(x,y,d,t:longint);\n begin\n if (vis[x][y][d])or(t>a[n]) then exit;\n vis[x][y][d]:=true;\n if not occ[x][y] then\n begin\n occ[x][y]:=true;\n inc(ans);\n end;\n q[tail].x:=x;q[tail].y:=y;\n q[tail].d:=d;q[tail].t:=t;\n inc(tail);\n end;\nbegin\n //assign(input,'D.in');reset(input);\n //assign(output,'D.out');rewrite(output);\n read(n);\n for i:=1 to n do read(a[i]);\n for i:=2 to n do inc(a[i],a[i - 1]);\n fillchar(turn,sizeof(turn),false);\n for i:=1 to n do turn[a[i]]:=true;\n fillchar(vis,sizeof(vis),false);\n fillchar(occ,sizeof(occ),false);\n q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;\n vis[0][0][0]:=true;occ[0][0]:=true;ans:=1;\n for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;\n for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;\n head:=1;tail:=2;\n while (heada[n]) then exit;\n vis[x][y][d][ord(turn[t])]:=true;\n if not occ[x][y] then\n begin\n occ[x][y]:=true;\n //writeln(x,' ',y);\n inc(ans);\n end;\n q[tail].x:=x;q[tail].y:=y;\n q[tail].d:=d;q[tail].t:=t;\n inc(tail);\n end;\nbegin\n //writeln((sizeof(q)+sizeof(vis))/1024/1024:0:8);\n //assign(input,'D.in');reset(input);\n //assign(output,'D.out');rewrite(output);\n read(n);\n for i:=1 to n do read(a[i]);\n for i:=2 to n do inc(a[i],a[i - 1]);\n fillchar(turn,sizeof(turn),false);\n for i:=1 to n do turn[a[i]]:=true;\n fillchar(vis,sizeof(vis),false);\n fillchar(occ,sizeof(occ),false);\n q[1].x:=0;q[1].y:=0;q[1].d:=0;q[1].t:=1;\n vis[0][0][0][ord(turn[1])]:=true;occ[0][0]:=true;ans:=1;\n for i:=1 to 7 do l[i]:=i - 1;l[0]:=7;\n for i:=0 to 6 do r[i]:=i + 1;r[7]:=0;\n head:=1;tail:=2;\n while (headn then exit;\n//INC(kq);\nvst[x,y,d,r]:=true;\nfor i:=1 to a[r] do\nif not v[x+DIRX[d]*i,y+DIRY[d]*i] then\nbegin\nv[x+DIRX[d]*i,y+DIRY[d]*i]:=true;\nINC(kq);\nend;\nif r=1 then DEC(a[r]);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);\nend;\nprocedure xuat;\nbegin\nassign(f,OUTP);\nrewrite(f);\nwrite(f,kq);\nclose(f);\nend;\nbegin\nnhap;\nxuLi(0,0,0,1);\nxuat;\nend."}, {"source_code": "const INP='';\nOUTP='';\nDIRX:array[0..7] of longint = (0,1,1,1,0,-1,-1,-1);\nDIRY:array[0..7] of longint = (1,1,0,-1,-1,-1,0,1);\nvar f:text;\na:array[1..30] of longint;\nvst:array[-150..150,-150..150,0..7,1..30] of boolean;\nv:array[-150..150,-150..150] of boolean;\nn,i,kq:longint;\nprocedure nhap;\nbegin\nassign(f,INP);\nreset(f);\nreadln(f,n);\nfor i:=1 to n do read(f,a[i]);\nclose(f);\nfillchar(vst,sizeof(vst),false);\nfillchar(v,sizeof(v),false);\nend;\nprocedure xuLi(x,y,d,r:longint);\nvar i:longint;\nbegin\nif r>n then exit;\nif vst[x,y,d,r] then exit;{\nfor i:=r downto 1 do\nif vst[x,y,d,i] then exit; }\n//INC(kq);\nvst[x,y,d,r]:=true;\nfor i:=1 to a[r] do\nif not v[x+DIRX[d]*i,y+DIRY[d]*i] then\nbegin\nv[x+DIRX[d]*i,y+DIRY[d]*i]:=true;\nINC(kq);\nend;\nif r=1 then DEC(a[r]);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+1) mod 8,r+1);\nxuLi(x+DIRX[d]*a[r],y+DIRY[d]*a[r],(d+7) mod 8,r+1);\nend;\nprocedure xuat;\nbegin\nassign(f,OUTP);\nrewrite(f);\nwrite(f,kq);\nclose(f);\nend;\nbegin\nnhap;\nxuLi(0,0,0,1);\nxuat;\nend."}, {"source_code": " const eps=0.00000001; besk=2000000000000000008; nn=200000;\n label 1,2,3;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var pp,tt,dx,dy,left,right,mmin,kk,gr,ttt,t,kol,pos,x1,x2,p,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n k,dist,xmin,xmax,ymin,ymax,time,jj,step, ii,i,j:longint;\n aa,bb,cc:double;\n npx,npy:array[-1000..1000] of int64;\n napx,napy:array[-1..30,-100..100] of int64;\n finzan,zan:array[0..31,-200..200,-200..200] of boolean;\n kolnap :array[0..31,-200..200,-200..200] of longint;\n finnap: array[0..31,-1..20,-200..200,-200..200] of byte;\n c,d,x,y,aold,b,a:array[-10..1000002] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n polog:array[-10..200004, 0..5] of int64;\n zzan:array[-1000..3000,-1000..3000] of boolean;\n ss, ss1,ss2:array[-1000..1000000] of string;\n fl:array[-10000..600000] of boolean;\n sss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n oldflag,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n npx[0]:=1;npy[0]:=0;\n npx[1]:=1;npy[1]:=-1;\n npx[2]:=0;npy[2]:=-1;\n npx[3]:=-1;npy[3]:=-1;\n npx[4]:=-1;npy[4]:=0;\n npx[5]:=-1;npy[5]:=1;\n npx[6]:=0;npy[6]:=1;\n npx[7]:=1;npy[7]:=1;\n for i:=0 to 1000 do begin npx[i]:=npx[i mod 8];npy[i]:=npy[i mod 8]; end;\n for i:=1 to 1000 do begin npx[i-1000]:=npx[i]; npy[i-1000]:=npy[i]; end;\n\n { for i:=-20 to 20 do writeln(i,' ',npx[i],' ',npy[i]);\n }\n\n for i:=1 to n do read(a[i]);\n zan[0,0,0]:=true;\n finzan[0,0,0]:=true;\n finnap[0,0,0,0]:=0;\n napx[0,1]:=0; napy[0,1]:=1; kolnap[0,0,0]:=1;\n for step:=1 to n do\n begin\n for i:=-200 to 200 do for j:=-200 to 200 do\n if finzan[step-1,i,j] then\n begin\n for k:=1 to min(kolnap[step-1,i,j],16) do\n begin\n dx:=npx[finnap[step-1,k,i,j]];\n dy:=npy[finnap[step-1,k,i,j]];\n\n for ii:=1 to a[step] do\n begin\n zan[step,i+dx*ii,j+dy*ii]:=true;\n { writeln('zapoln ',i+dx*ii,' -- ',j+dy*ii);\n } end;\n\n finzan[step,i+dx*a[step],j+dy*a[step]]:=true;\n inc(kolnap[step,i+dx*a[step],j+dy*a[step]]);\n pp:=kolnap[step,i+dx*a[step],j+dy*a[step]];\n finnap[step,pp,i+dx*a[step],j+dy*a[step]]:=finnap[step-1,k,i,j]+1;\n\n\n inc(kolnap[step,i+dx*a[step],j+dy*a[step]]);\n pp:=kolnap[step,i+dx*a[step],j+dy*a[step]];\n finnap[step,pp,i+dx*a[step],j+dy*a[step]]:=finnap[step-1,k,i,j]-1;\n\n\n end;\n end;\n\n\n\n\n\n\n\n\n\n\n\n end;\n ot:=0;\n\n for step:=1 to n do for i:=-200 to 200\n do for j:=-200 to 200 do if zan[step,i,j] then zzan[i,j]:=true;\n ot:=0;\n for i:=-1000 to 1000 do for j:=-1000 to 1000 do if zzan[i,j] then\n begin\n inc(ot);\n {writeln(i,' ',j); }\n end;\n writeln(ot);\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}], "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9"} {"source_code": "var a:array [1..3] of int64;\r\nt,i,j,x:int64;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n readln(x);\r\n for j:=1 to 3 do\r\n read(a[j]);\r\n if (a[x]<>0) and (a[a[x]]<>0) then writeln('YES')\r\n else writeln('NO');\r\n end;\r\nend.", "positive_code": [{"source_code": "program aous;\r\nuses wincrt;\r\nvar \r\ntt ,x , i: integer;\r\nw : boolean;\r\nA : array[1..3] of integer;\r\ncheck : array[1..3] of boolean;\r\nbegin\r\n read(tt);\r\n while(tt > 0) do\r\n begin\r\n readln(x);\r\n w := false;\r\n for i := 1 to 3 do \r\n read(A[i]);\r\n for i := 1 to 3 do\r\n check[i] := false;\r\n check[x] := true;\r\n check[A[x]] := true;\r\n check[A[A[x]]] := true;\r\n for i := 1 to 3 do\r\n if check[i] = false then\r\n w := true;\r\n if w = false then \r\n writeln('YES')\r\n else \r\n writeln('NO');\r\n tt := tt - 1;\r\n end;\r\nend."}, {"source_code": "program aous;\r\nuses wincrt;\r\nvar \r\ntt ,x , i: integer;\r\nA : array[1..3] of integer;\r\nbegin\r\n read(tt);\r\n while(tt > 0) do\r\n begin\r\n readln(x);\r\n for i := 1 to 3 do \r\n read(A[i]);\r\n if A[x] = 0 then \r\n writeln('NO')\r\n else \r\n begin\r\n if A[A[x]] = 0 then \r\n writeln('NO')\r\n else \r\n writeln('YES');\r\n end;\r\n tt := tt - 1;\r\n end;\r\nend."}, {"source_code": "label k;\r\nvar l,i,j,t,x:byte;\r\n a:Array[1..3]of byte;\r\nbegin\r\n\treadln(t);\r\n\tfor l:=1 to t do \r\n\t begin\r\n\t readln(x);\r\n\t for i:=1 to 3 do read(a[i]);\r\n\t \tfor i:=1 to 3 do \r\n\t if (i=x)and(a[i]<>0) then \r\n \t\t\t for j:=1 to 3 do \r\n \t\t\t if (j=a[i])and(a[j]<>0)then begin writeln('YES');goto k end;\r\n \t\twriteln('NO');\t \r\n k:\r\n\t end;\r\nend."}, {"source_code": "var n,t,i,kt,j:longint;\r\n a:ARRAY[-1..100] of longint;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n readln(n);\r\n for j:=1 to 3 do\r\n read(a[j]);\r\n readln;\r\n kt:=1;\r\n if a[n]=0 then\r\n begin\r\n writeln('NO');\r\n kt:=0;\r\n end;\r\n if (kt=1) then\r\n if (a[a[n]]=0) then\r\n begin\r\n writeln('NO');\r\n kt:=0;\r\n end;\r\n if kt=1 then writeln('YES');\r\n end;\r\nend.\r\n"}, {"source_code": "\r\nvar t,x:integer;\r\n a:array[1..3] of byte;\r\nbegin\r\n\r\n readln(t);\r\n if (t>=1) and (t<=18) then\r\n while (t<>0) do\r\n begin\r\n readln(x);\r\n if (x>=1) and (x<=3) then\r\n begin\r\n read(a[1],a[2],a[3]);\r\n if (a[1]>=0) and (a[1]<=3) and (a[2]>=0) and (a[2]<=3) and (a[3]>=0) and (a[3]<=3) then\r\n if (x=0) or (a[x]=0) or (a[a[x]]=0) then writeln('NO') else writeln('YES');\r\n end;\r\n t:=t-1;\r\n end;\r\n\r\nend.\r\n"}, {"source_code": "{***\r\n Educational Codeforces Round 132\r\n Problem A\r\n*}\r\nprogram Three_Doors;\r\nvar t:integer;\r\n a:array[1..3]of byte;\r\n\r\nprocedure solve;\r\nvar x,i:integer;\r\nbegin\r\n read(x);\r\n for i:=1 to 3 do read(a[i]);\r\n for i:=1 to 2 do\r\n begin\r\n if a[x]=0 then\r\n begin\r\n writeln('NO');\r\n exit;\r\n end;\r\n x:=a[x];\r\n end;\r\n writeln('YES');\r\nend;\r\n\r\nbegin\r\n read(t);\r\n while t>0 do\r\n begin\r\n solve; dec(t);\r\n end;\r\nend."}, {"source_code": "program p1709a;\r\nvar a : array[1..3] of integer;\r\n door : array[1..3] of boolean;\r\n t : integer;\r\n x : integer;\r\n\r\nBEGIN\r\n readln(t);\r\n while t >= 1 do\r\n begin\r\n dec(t);\r\n fillchar(door, sizeof(door), false);\r\n readln(x);\r\n readln(a[1], a[2], a[3]);\r\n while (door[1] = false) or (door[2] = false) or (door[3] = false) do\r\n begin\r\n if x = 0 then break;\r\n door[x] := true;\r\n x := a[x];\r\n end;\r\n if (door[1] = false) or (door[2] = false) or (door[3] = false)\r\n then writeln('NO')\r\n else writeln('YES')\r\n end;\r\nEND."}, {"source_code": "var t, i, x, j: longint;\r\n a:array[1..3] of longint ;\r\ncheck : string;\r\nbegin \r\nreadln(t);\r\nfor i := 1 to t do\r\n begin\r\n check := 'YES';\r\n readln(x);\r\n for j := 1 to 3 do read(a[j]);\r\n if a[x] = 0 then check := 'NO';\r\n if a[a[x]] = 0 then check := 'NO';\r\n writeln(check);\r\n end;\r\nend."}, {"source_code": " program firstprog;\r\n var j,i,t,k:integer;\r\n A: array[1..3] of integer;\r\n begin\r\n Readln(t);\r\n for k:= 1 to t do begin\r\n Readln(j);\r\n for i:=1 to 3 do begin\r\n Read(A[i]);\r\n \r\n end; // reading array\r\n\r\n\r\n if A[j] = 0 then writeln('NO')\r\n else\r\n if A[A[j]] = 0 then writeln('NO')\r\n else writeln('YES');\r\n\r\n \r\n \r\n \r\n \r\n \r\n end; // for k:= 1 to t do end\r\n \r\n \r\n \r\n \r\n \r\n \r\n end."}, {"source_code": "program Three_Doors;\r\nvar\r\n ntc: int8;\r\n x, n: int8;\r\n a: array [1 .. 3] of int8;\r\n\r\nbegin\r\n readln(ntc);\r\n while ntc > 0 do begin\r\n dec(ntc);\r\n\r\n readln(x);\r\n readln(a[1], a[2], a[3]);\r\n\r\n n := 0;\r\n while x > 0 do begin\r\n x := a[x];\r\n inc(n);\r\n end;\r\n\r\n if n = 3 then\r\n writeln('YES')\r\n else\r\n writeln('NO');\r\n\r\n end;\r\nend.\r\n"}, {"source_code": "procedure solve;\r\nvar n:longint;\r\n a:array[0..3]of longint;\r\nbegin\r\n a[0]:=0;\r\n readln(n,a[1],a[2],a[3]);\r\n if a[a[n]]<>0 then writeln('YES')\r\n else writeln('NO');\r\nend;\r\nvar _t:longint;\r\nbegin\r\n readln(_t);\r\n for _t:=1 to _t do\r\n solve;\r\nend."}, {"source_code": " const eps=1e-10;\r\n besk=1800000000000000000; label 33,55,5,4,1,3,2,44,22;\r\n type\r\n mas=array[-250000..1570460+1] of int64;\r\n integer=longint; zap=record p1,p2,p3:int64; end;\r\n zap1=^zap;\r\n var dlina,newnap,nnap,nap,m,pos,kolshagov,kk,hh,koled,px,py,posx,posy,cur,init,res,oldpos,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\r\n sss:array[-1..1000000] of string;\r\n ch1,ch2:char;\r\n ss,ssans,ss1,ss4,oldss,smin,ss3,ss2:string;\r\n newaans,aans:zap;\r\n fx,fy,koef,dfy,dfx,coef,mc,xxc,yyc,zzc,otr1,otr0,vx,vy,ddist,tttt:extended;\r\n pqqq:zap;\r\n kolzapr,sumtek,time,dx,dy,mexx,diff,jmin,summax,summin,znach,sum,start,start1,kol1,raz,raz1:int64;\r\n xp,yp,almax,almin,gam,al0,otal,al1,al2,acc, disk,prop,bet,al:extended; fl1,fl2,fl:boolean;\r\n dr3,dr1,dr2,pt,ott1,ott2:zap;\r\n dans,sumyy,sumxx,sumxy:array[-10..500000] of extended;\r\n p1,p2,ans,tt,ii,pp,ymax,ymin,xmax,xmin,sumx,sumy,w,pov,sumost,gr,oldsum,amin,amax,ansmax,kolgor,kolver,oldcc,finish,p3,p4,stoimost,kolodin,maxsum,i3,p,pp1,pp2,root,par,dlkruga,topt,t3,ot,cc,znak,rr,kolmax,kkol,pq,razm,mm,tip,ppos1,oldtt,ps,pos1,pos2,pred,color,buk:int64;\r\n nomer,napx,napy,kol,z,stepen1,stepen,xnewoch,ynewoch,xoch,yoch,strx,stry,ppole,y,dold,d,poryadok,num,zz:array[-200000..1110000] of int64;\r\n stroka,sss1,sss2:array[-10..1610000] of string;\r\n xc,yc,zc,v3,v1,v2,pointx,pointy,vel,tt0,radius,ote,dl1,dl2:extended;\r\n dist,dd1,dnewr,dnewl,dr,ddpos:array[-1..50002,-2..500] of int64;\r\n firstvh,lastvh,sootv,nomermax,left,right,poss,zzz,x,d0,d1,str,zx,zy,xxx,yyy,invfact,ansx,ansy,ugol:array[-300000..1111000] of int64;\r\n t1,t2,tx,ty,delit,dl,ll,ost,shag,ppos,jj,t,ptek,dloch1,oldaa,oldbb,zapas,ott,mnog,ttt,delta,tt1,tt2,koll,newt,osn,oldot,oldt,znmax,opld,t4,iii,jjj,aaa,bbb,ccc,p0,newpos,newdl,len,pp3,ans1,ans2,modul,t0,dloch,koldel,mmax,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,kool,number,imin,qq,n,numpos,down,imax,qq1,qq2,q1,q2,pmax,pmax2,pos0,maxot,tmax,nn,n1,q:int64; flag1:boolean;\r\n xx,yy,olda,b,c,a,fact,stan,a2,invx,invy,place,b2,sum1,sum0:mas; flag2,flag:boolean;\r\n aa,bb,pleft,pright,kol2,kolminus,pos3,gor,ver,i2,j2,sdvig,izb, nextp,razn,ppp,minx,miny,maxx,maxy,jmax,grr,ener,dob:int64;\r\n zan1,zan2,prost,zan:array[-1000..20001001] of boolean;\r\n zzan,newzan,zann:array[-1000000..4000000] of boolean;\r\n zanx,marked:array[-1000000..4100000] of boolean;\r\n s1,s2:array[-1..1000000] of char;\r\n dmax,dd,est,nado,z1,z2,x1,y1,x2,y2,ddnew,d3,dmin,dnomer:array[-211100..1100000] of int64;\r\n ochh,newochh:array[-1000..1000000] of longint;\r\n ba1,ba2,next0,next1,newx,newy,dplus,dminus,och1,b1,a1,first,last,newoch,och,lx,a3,b3,predok:array[-20000..1610000] of int64;\r\n ddd:array[-1..500001,0..3] of longint;\r\n dinleft,din,nextt,polenext,pole,newpole:array[-1..1300,-1..1305] of int64;\r\n ddmax,ddmin,dd2:array[-100..1300,-100..1300] of int64;\r\n dd3:array[-10..130,-10..130,-10..130] of int64;\r\n ssan,bufer:array[-1000..2000000] of char;\r\n cosa,sina,cosb,sinb,rx,ry,h1,h2,h,l1,l2,otmax,v:int64;\r\n obmen,ch:char;\r\n flagg,fflag,ok,flagg1:boolean;\r\n dmaxchet,dmaxnechet,oldx,oldy,numx,numy,xleft,xright,s,newplace,newstr,next,prev,aold:array[-1000..220002] of int64;\r\n function srav(i,j:longint):boolean;\r\n var k,tt:longint;\r\n begin\r\n if (a[i]=l+k) or (j>=m+k)) then flag:=false;\r\n end;\r\n if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j]; b3[l+step]:=a3[j];\r\n inc(step);inc(j);until (j>=m+k);\r\n if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i]; b3[l+step]:=a3[i];inc(step);inc(i);until (i>=l+k);\r\n end;\r\n\r\n procedure sort(var c:mas);\r\n begin\r\n k:=1; repeat\r\n l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\r\n for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i];a3[i]:=b3[i]; end;\r\n until (k>=n);\r\n end;\r\n\r\n function min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\r\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\r\n tt:zap; tt1:zap1; fl:boolean;\r\n begin\r\n fl:=false;\r\n if a0 do\r\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\r\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\r\n end;\r\n if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else\r\n begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\r\n evkl:=tt1;\r\n end;\r\n function phi(a,b:double):double; label 222;var p:double;\r\n begin\r\n if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;\r\n if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;\r\n if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;\r\n if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;\r\n if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;\r\n 222: phi:=p;\r\n end;\r\n\r\n function nod(a,b:int64):int64; var p,t:int64;\r\n begin\r\n a:=abs(a); b:=abs(b);\r\n if (a>0)and(b>0) then\r\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\r\n p:=a;\r\n end else if a=0 then p:=b else p:=a;\r\n nod:=p;\r\n end;\r\n\r\nfunction nok(aa,bb:int64):int64;\r\nvar tt:int64;\r\nbegin tt:=nod(aa,bb); ot:=(aa*bb) div tt; nok:=ot; end;\r\n\r\n function arccos(tt:extended):extended;\r\n begin\r\n if abs(tt)>1-1e-13 then\r\n if tt>0 then arccos:=0 else arccos:=pi;\r\n if tt=0 then arccos:=pi/2 else\r\n if abs(tt)<=1-1e-13 then if tt>=0 then arccos:=arctan(sqrt(1-tt*tt)/tt)\r\n else arccos:=pi+arctan(sqrt(1-tt*tt)/tt);\r\n end;\r\n\r\n function degg(a,k,modul:int64):int64; var p:int64; label 4;\r\n begin\r\n if k<=0 then degg:=1\r\n else if odd(k) then degg:=(degg(a,k-1,modul)*a) mod modul else\r\n begin p:=degg(a,k div 2,modul); degg:=(p*p) mod modul; end;\r\n end;\r\n\r\n{ function zaprmax(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmax:=y[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\r\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\r\n end;\r\n end;\r\n end; }\r\n\r\n\r\n function zaprmin(left,right:longint):int64;\r\n begin\r\n if left>=right then zaprmin:=z[left] else\r\n begin\r\n if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprmin:=min(zaprmin(left+1,right),z[left]);\r\n if not odd(right) then zaprmin:=min(zaprmin(left,right-1),z[right]);\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n function zaprsum(left,right:longint):int64;\r\n begin\r\n if left>=right then if left=right then zaprsum:=y[left] else zaprsum:=0 else\r\n begin\r\n if not odd(left) and odd(right) then zaprsum:=zaprsum(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprsum:=zaprsum(left+1,right)+y[left];\r\n if not odd(right) then zaprsum:=zaprsum(left,right-1)+y[right];\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n function zaprsum1(left,right:longint):int64;\r\n begin\r\n if left>=right then if left=right then zaprsum1:=yy[left] else zaprsum1:=0 else\r\n begin\r\n if not odd(left) and odd(right) then zaprsum1:=zaprsum1(left shr 1,right shr 1) else\r\n begin\r\n if odd(left) then zaprsum1:=zaprsum1(left+1,right)+yy[left];\r\n if not odd(right) then zaprsum1:=zaprsum1(left,right-1)+yy[right];\r\n end;\r\n end;\r\n end;\r\n\r\n\r\n\r\n\r\n\r\n\r\n procedure udal(ii:longint);\r\n begin next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii]; end;\r\n\r\n\r\n\r\n\r\n function pprost(pp:int64):boolean;\r\n var i,j,t:longint; tt:extended; fl:boolean;\r\n begin\r\n tt:=pp;\r\n tt:=sqrt(tt);\r\n fl:=true;\r\n for i:=2 to round(tt) do if pp mod i=0 then fl:=false;\r\n pprost:=fl;\r\n end;\r\n\r\n function gl(c:char):boolean;\r\n begin\r\n if (c='a')or (c='o')or(c='e')or(c='i')or(c='u') then gl:=true else gl:=false;\r\n end;\r\n { function slog(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.y+d1.y*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n slog:=@ans;\r\n end;\r\n\r\n function umn(d1,d2:zap):zap1;\r\n var t,tt,p,q:int64; ans:zap;\r\n begin\r\n p:=d1.x*d2.x;\r\n q:=d1.y*d2.y;\r\n t:=nod(p,q);\r\n p:=p div t; q:=q div t;\r\n ans.x:=p mod modul;ans.y:=q mod modul;\r\n umn:=@ans;\r\n end;\r\n\r\n function sravfr(d1,d2:zap):boolean;\r\n begin\r\n if d1.x*d2.y=jj then\r\n begin\r\n p1:=fact[ii];\r\n p2:=fact[jj];\r\n p3:=fact[ii-jj];\r\n t2:=degg(p2,modul-2,modul);\r\n t3:=degg(p3,modul-2,modul);\r\n ot:=((p1*t2) mod modul*t3) mod modul;\r\n bincoef:=ot;\r\n end else bincoef:=0;\r\n end;\r\n\r\nfunction vhodit(znach:int64):int64;\r\nvar ans,aa,bb,cc,i:longint; flag:boolean;\r\nbegin\r\n aa:=1; bb:=tt; cc:=aa; ans:=-100;\r\n while abs(aa-bb)>1 do\r\n begin\r\n cc:=(aa+bb) shr 1;\r\n if xxx[cc]<=znach then aa:=cc else bb:=cc;\r\n\r\n end;\r\n { writeln(cc);\r\n}\r\n flag:=false;\r\n cc:=max(0,cc-3); repeat inc(cc); until (xxx[cc]>=znach)or(cc>tt);\r\n if (xxx[cc]=znach)and(cc<=tt) then ans:=cc;\r\n vhodit:=ans;\r\nend;\r\n\r\nfunction maxnomer(znach:int64):int64;\r\nvar ans,aa,bb,cc,i:longint; flag:boolean;\r\nbegin\r\n aa:=1; bb:=p; cc:=aa; ans:=-100;\r\n while abs(aa-bb)>1 do\r\n begin\r\n cc:=(aa+bb) shr 1;\r\n if x[cc]<=znach then aa:=cc else bb:=cc;\r\n\r\n end;\r\n { writeln(cc);\r\n}\r\n flag:=false;\r\n cc:=min(p+1,cc+3); repeat dec(cc); until (x[cc]<=znach)or(cc<0);\r\n if (x[cc]<=znach)and(cc>=0) then ans:=cc;\r\n maxnomer:=ans;\r\nend;\r\n\r\n\r\n\r\n\r\n\r\n begin\r\n\r\n { assign (input,'D:\\Projects\\input.txt');reset(input);\r\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\r\n }\r\n readln(qq);\r\n\r\n for stepp:=1 to qq do\r\n\r\n begin\r\n\r\n readln(pos);\r\n for i:=1 to 3 do read(x[i]);\r\n tt:=0;\r\n while pos<>0 do begin inc(tt); pos:=x[pos]; end;\r\n { writeln('tt= ',tt);\r\n } if tt=3 then writeln('YES') else writeln('NO');\r\n\r\n\r\n\r\n 2:\r\n end;\r\n\r\n1: close (output);\r\n\r\n\r\n end.\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}], "negative_code": [], "src_uid": "5cd113a30bbbb93d8620a483d4da0349"} {"source_code": "Uses Math;\nConst\n Fi = '117B.inp';\n Fo = '117B.out';\n\n\nVar\n F : Text;\n A, B, k,i : Longint;\n Res, cs : Longint;\n m, j, tg: Int64;\n s: String;\n\n\nBEGIN\n Readln(A, b, k);\n If k=1 then Begin Writeln(2); Exit; End;\n If b>=k then Begin Writeln(2); Exit; End;\n //If a+b= md) then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(md - 1, a) do\n begin\n temp := i * int64(maxN);\n if (temp mod md = 0) then\n continue;\n if ((md - temp mod md) > b) then\n begin\n write(1, ' ');\n str(i, res);\n for j := 1 to 9 - (length(res)) do\n write(0);\n writeln(res);\n exit;\n end;\n end; \n writeln(2);\nend."}, {"source_code": "program CFBR88;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\ntype integer=int64;\n\nvar v,minnk,d,q,w,t,k,n,m,i:integer;\nj:longint;\ns:string;\n\nfunction readup:string;\nvar ch:char;\ns:string;\nbegin\ns:='';\nread(ch);\nwhile ch in ['a'..'z','A'..'Z','0'..'9'] do\nbegin\ns:=s+ch;\nread(ch);\nend;\nreadup:=s;\nend;\n\nbegin\n readln(n,m,k);\n\n i:=0;\n minnk:=min(n,k);\n while i<=minnk do\n begin\n v:=i*1000000000 mod k;\n if (v <> 0) then\n if (v < k-m) then\n begin\n // writeln(i);\n d:=1;\n for j := 1 to 9 do\n begin\n s:=chr(ord('0')+i div d mod 10)+s;\n d:=d*10;\n end;\n write('1 ');\n writeln(s);\n \n while True do\n halt;\n end;\n inc(i);\n end;\n\n writeln(2);\n \nend."}, {"source_code": "const\n fi='';//'117b.inp';\n fo='';//'117b.out';\n base=1000000000;\nvar\n f1,f2 :text;\n a,b,modd :int64;\n\nprocedure mof;\nbegin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\nend;\n\nprocedure dongf;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure nhap;\n begin\n readln(f1,a,b,modd);\n end;\n\nprocedure work;\n var i:longint;t:int64;\n ok:boolean;\n\n begin\n ok:=true;\n\n for i:=0 to modd-1 do\n begin\n\n if i>a then break;\n t:=(int64(i)*base) mod modd;\n if (modd-t)mod modd>b then\n begin\n ok:=false;\n break;\n end;\n\n end;\n\n if ok then\n writeln(f2,2)\n else\n begin\n write(f2,1,' ');\n t:=i;\n while t<100000000 do\n begin\n write(f2,0);\n t:=t*10;\n end;\n write(f2,i);\n end;\n\n end;\n\n begin\n\n mof;\n nhap;\n work;\n dongf;\n\n end.\n\n"}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t, d : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n d := 10000001;\n s := '';\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n if (t*i) mod c + b < c then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s);\n exit;\n end;\n end;\n writeln( 2 );\nEND.\n\n"}, {"source_code": "program fb;\n\nvar\n aa,b,c,tmp:int64;\n a:longint;\n\nfunction min(a,b:longint):longint;begin if ab then begin\n write(1,' ');\n if a<100000000 then write(0);\n if a<10000000 then write(0);\n if a<1000000 then write(0);\n if a<100000 then write(0);\n if a<10000 then write(0);\n if a<1000 then write(0);\n if a<100 then write(0);\n if a<10 then write(0);\n writeln(a);\n halt;\n end;\n end;\n writeln(2);\nend.\n"}, {"source_code": "var\nst:string;\ni,a,b,md:longint;\nmn,sost:int64;\n begin\n readln(a,b,md);\n mn:=1000000000 mod md;\n for i:=0 to md-1 do\n begin\n if i>a then break;\n sost:=(int64(i)*mn)mod md;\n\n if (sost+b0) then\n begin\n write(1,' ');\n str(i,st);\n while length(st)<9 do st:='0'+st;\n writeln(st);\n halt(0);\n end;\n end;\n writeln(2);\n end."}, {"source_code": "var\nst:string;\ni,a,b,md:longint;\nmn,sost:int64;\n begin\n readln(a,b,md);\n mn:=1000000000 mod md;\n for i:=0 to md-1 do\n begin\n if i>a then break;\n sost:=(int64(i)*mn)mod md;\n\n if (sost+b0) then\n begin\n write(1,' ');\n str(i,st);\n while length(st)<9 do st:='0'+st;\n writeln(st);\n halt(0);\n end;\n end;\n writeln(2);\n end."}, {"source_code": "program Project2;\n\n var i, a, b, m: longint;\n f, t: int64;\n st: string;\n\n begin\n readln(a, b, m);\n f := 1000000000 mod m;\n t := f;\n i := 1;\n if b >= m then\n begin\n write('2');\n halt;\n end;\n if f <> 0 then\n while ((t mod m + b) >= m) and (i < a + 1) and (t mod m <> 0) do\n begin\n inc(i);\n t := t + f;\n end;\n if (i <= a) and (t mod m <> 0) then\n begin\n write('1', ' ');\n str(i, st);\n for i := 1 to 9 - length(st) do write('0');\n write(st);\n end\n else write('2');\n end."}, {"source_code": "Program Very_Interesting_Game;\nvar i:longint;\n a,b,mo,p,t,x:int64;\n s:string;\nbegin\n readln(a,b,mo);\n if b>=mo then\n begin\n writeln(2);exit;\n end;\n if a>=mo then a:=mo;\n p:=1000000000 mod mo;\n for i:=0 to a do\n begin\n x:=i;\n t:=x*p mod mo;\n if t=0 then continue;\n if mo-t>b then\n begin\n write(1,' ');\n str(x,s);\n while length(s)<9 do s:='0'+s;\n writeln(s);\n exit;\n end;\n\n end;\n writeln(2);\nend.\n"}, {"source_code": "var \na,b,c,k:int64;\ni:longint;\ns:string;\nbegin \nread(a,b,c);\nif a>c then k:=c else k:=a;\n\tfor i:=1 to k do \n\t\tif ((c-int64(i)*1000000000 mod c) mod c)>b then begin \n\t\tstr(i,s);\n\t\twhile length(s)<9 do s:='0'+s;\n\t\twriteln(1,' ',s);\n\t\thalt;\n\t\tend;\nwriteln(2);\nend."}, {"source_code": "const big=1000000000;\n\nvar a,b,mo,i,c,j:longint;\n st:string;\n\nbegin\n readln(a,b,mo);\n for i:=1 to a do\n begin\n c:=int64(i)*big mod mo;\n if c>0 then c:=mo-c;\n if c>b then\n begin\n write('1 ');\n str(i,st);\n for j:=1 to 9-length(st) do write('0');\n writeln(st);\n halt;\n end;\n if i>mo then break;\n end;\n writeln('2');\nend.\n"}, {"source_code": "var\nst:string;\ni,a,b,md:longint;\nmn,sost:int64;\n begin\n readln(a,b,md);\n mn:=1000000000 mod md;\n for i:=0 to md-1 do\n begin\n if i>a then break;\n sost:=(int64(i)*mn)mod md;\n\n if (sost+b0) then\n begin\n write(1,' ');\n str(i,st);\n while length(st)<9 do st:='0'+st;\n writeln(st);\n halt(0);\n end;\n end;\n writeln(2);\n end."}, {"source_code": "var\nst:string;\ni,a,b,md:longint;\nmn,sost:int64;\n begin\n readln(a,b,md);\n mn:=1000000000 mod md;\n for i:=0 to md-1 do\n begin\n if i>a then break;\n sost:=(int64(i)*mn)mod md;\n\n if (sost+b0) then\n begin\n write(1,' ');\n str(i,st);\n while length(st)<9 do st:='0'+st;\n writeln(st);\n halt(0);\n end;\n end;\n writeln(2);\n end."}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if ((c-q)>x) and (q<>0) then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "uses math;\nvar\n a,b,md,i:longint;\n\nprocedure print(i:longint);\n var\n s:string;\n begin\n str(i,s);\n while length(s)<>9 do s:='0'+s;\n writeln(1,' ',s);\n halt;\n end;\n\nfunction fun(ver:int64):boolean;\n var\n ans:int64;\n begin\n ans:=(ver*1000000000) mod md;\n if (ans<>0)and(ans+b 999999999 then a := 999999999;\n if b > 999999999 then b := 999999999;\n if (a=0) and (b>=m) then begin writeln(2); halt; end;\n f := false;\n if a >= m then\n begin\n for i := 0 to (m-1) do\n begin\n z := i;\n x := z * 1000000000;\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end\n else\n begin\n for i := 0 to a do\n begin\n z := i;\n x := z * 1000000000;\n //writeln(i,' ',x,' ',x mod m);\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end;\n if f then\n begin\n str(ans,s);\n for i := 1 to 9-(length(s)) do\n s := '0' + s;\n writeln('1 ',s);\n end\n else writeln(2);\nend.\n"}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n x,a,b,m,i:longint;\n s:string;\n\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(a,b,m);\n if (a>m)then a:=m;\n for i:=0 to a do begin\n x:=int64(i)*1000000000 mod m;\n x:=m-x;\n if (x=m)then x:=0;\n if (x<=b)then continue;\n write('1 ');\n str(i,s);\n while (length(s)<9)do s:='0'+s;\n writeln(s);\n halt(0);\n end;\n writeln(2);\nend."}, {"source_code": "{$r-,q-,s-,i-,o+}\nvar\n x,a,b,m,i:longint;\n s:string;\n\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(a,b,m);\n if (a>m)then a:=m;\n for i:=0 to a do begin\n x:=int64(i)*1000000000 mod m;\n x:=m-x;\n if (x=m)then x:=0;\n if (x<=b)then continue;\n write('1 ');\n str(i,s);\n while (length(s)<9)do s:='0'+s;\n writeln(s);\n halt(0);\n end;\n writeln(2);\nend."}, {"source_code": "var\n n,m,i,j,a,b,f,min:longint;\n k:int64;\n s:string[9];\nbegin\n readln(a,b,m);\n if b>=m then\n begin\n writeln(2);\n halt;\n end;\n f:=1000000000 mod m;\n if a>=m then min:=m else min:=a;\n for i:=1 to min do\n begin\n k:=i;\n k:=k*f;\n k:=trunc((k/m-trunc(k/m))*m+0.0000005);\n if (k>0)and(k=0)and(m-(p*x) mod m<=b)or(m-(p*x) mod m=m) then begin\n // bol:=true;\n // if j = 1 then begin\n // writeln(j,' ',i,' ',x);\n // writeln(m-(p*x) mod m);\n // end;\n mas[j]:=1;\n end\n end;\n\nbol:=false;\nfor i:=1 to min do if mas[i]=0 then begin\n str(i,s);\n write(1,' ');\n for j:=1 to 9-length(s) do write(0);\n write(i);\n bol:=true;\n break;\nend;\nif bol=false then writeln(2);\nend."}, {"source_code": "Uses math;\nvar f1,f2:text;\na,b,smod,x:int64;\ni,val:longint;\n\nProcedure Process;\nvar i:longint;\nst:string;\ncanwin:boolean;\nBegin\n canwin:=false;\n For i:=1 to min(a,smod) do\n Begin\n x:=(int64(i)*1000000000) mod smod;\n if (smod-x) mod smod<=b then continue;\n x:=i mod smod;\n{ if (smod-x) mod smod<=b then continue;}\n canwin:=true;\n if val=0 then\n val:=i;\n End;\n if canwin=true then\n Begin\n str(val,st);\n While length(st)<9 do st:='0'+st;\n writeln(f2,1,' ',st);\n End\n else\n Writeln(f2,2);\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,smod);\n process;\n close(F1);\n close(f2);\nEnd.\n"}, {"source_code": "var\n a,b,m,i,k,t:Longint;\nbegin\n read(a,b,m); k:=1000000000 mod m;\n if b>=m then begin writeln(2); exit end;\n if a>=m then a:=m-1; \n for i:=0 to a do begin\n t:=(int64(i)*k) mod m;\n if (m-t) mod m>b then begin\n write(1,' ');\n a:=i; k:=0; repeat inc(k); a:=a div 10 until a=0;\n for t:=1 to 9-k do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\nend."}, {"source_code": "program B117;\n\nuses math;\n\nconst maxn=10001000;\n\nvar a,b,modulo:int64;\n i:longint;\n dau:Array[0..maxn]of longint;\n tg:int64;\n s:string;\n\nBEGIN\n readln(a,b,modulo);\n\n begin\n for i:=0 to min(b,modulo-1) do\n dau[i]:=1;\n\n for i:=0 to min(a,modulo-1) do\n begin\n tg:= (int64(i) * 1000000000) mod modulo;\n if dau[(modulo - tg ) mod modulo]=0 then\n begin\n str(i,s);\n while length(s)<9 do s:='0'+s;\n\n writeln('1 ',s);\n exit;\n end;\n end;\n end;\n\n writeln(2);\nEND.\n"}, {"source_code": "var\ntmp,a,b,p,res,kk:int64;\nflag,i:longint;\nx:array[0..10]of longint;\nbegin\n\nreadln(a,b,p);\nfor i:=1 to p do\n if i>a then break\n else\n begin\n kk:=i;\n tmp:=kk*1000000000;\n tmp:=tmp mod p;\n if (p-tmp>b)and(tmp<>0) then\n begin\n flag:=1;\n res:=kk;\n break;\n end;\n end;\nif flag=0 then writeln(2)\n else\n begin\n write(1,' ');\n for i:=1 to 9 do\n begin\n x[i]:=res mod 10;\n res:=res div 10;\n end;\n for i:=9 downto 1 do\n write(x[i]);\n writeln;\n\n end;\n\nend."}, {"source_code": "Uses Math;\nvar\n\ti, j, n: longint;\n\ta, b, m, cur, u: int64;\n s: string;\n\nbegin\n //reset(input, 'a.in');\n\t//rewrite(output, 'a.out');\n\treadln(a, b, m);\n\tif b >= m then begin write(2); halt; end;\n cur := 1000000000 mod m;\n n := min(a, m - 1);\n\tfor i := 1 to n do begin\n u := (i * cur) mod m;\n\t\tif (u + b < m) and (u > 0) then begin\n\t\t\twrite(1,' ');\n\t\t\tstr(i, s);\n\t\t\tfor j := 1 to 9 - length(s) do\n\t\t\t\twrite(0);\n\t\t \twrite(i);\n\t\t \thalt;\n\t \tend;\n end;\n write(2);\nend."}, {"source_code": "var i,j,n: longint;\n m,a,b,x,y: qword;\n rez: string;\nbegin\n readln(a,b,m);\n if a>m-1 then a:=m-1;\n for i:=1 to a do\n begin\n x:=i;\n x:=(x*1000000000) mod m;\n if (x<>0) and (m-x>b) then\n begin\n str(i:9,rez);\n for j:=1 to length(rez) do\n if rez[j] = ' ' then rez[j]:='0';\n writeln(1,' ',rez);\n exit;\n end;\n end;\n writeln(2);\nend."}, {"source_code": "var\n k,temp,a,b,m:int64;\n i:longint;\n vis:array[0..10000000] of boolean;\nbegin\n readln(a,b,m);\n if (b>=m-1) then writeln(2)\n else\n begin\n for i:=1 to m do\n begin\n k:=i mod m;\n if (k>a) then begin writeln(2); exit; end;\n if ((m-k*1000000000 mod m) mod m>b) then break;\n end;\n if (k>a) or (k=0) then begin writeln(2); exit; end;\n write(1,' '); temp:=k;\n for i:=1 to 9-trunc(ln(temp)/ln(10))-1 do\n begin\n write(0);\n end;\n writeln(temp);\n end;\nend.\n"}, {"source_code": " VAR\n a, b, k , tm, p : int64;\n i : longint;\n ma : array [0.. 10] of int64;\n\n\n BEGIN\n read(a, b, k);\n ma[0]:= 1;\n for i:= 1 to 10 do\n ma[i]:= (ma[i- 1]* 10) mod k;\n\n if b>= k then\n begin\n write(2);\n exit;\n end;\n if a> k then\n a:= k;\n for i:= 0 to a do\n begin\n p:= i;\n tm:= (p* ma[9]) mod k;\n if (tm< k- b)and (tm> 0) then\n begin\n k:= 100000000;\n write('1 ');\n while i< k do\n begin\n write('0');\n k:= k div 10;\n end;\n write(i);\n exit;\n end;\n end;\n\n write(2);\n END."}, {"source_code": "uses math;\nvar a,b,m,i,j:longint;\ni1,j1,k:int64;\nt:boolean;\ns:string;\nlabel 1;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\nbegin\n if (b>=m) then\n writeln(2)\n else begin\n for i:=1 to min(a,m) do begin\n i1:=i;\n k:=(i1*1000000000) mod m;\n if (k=0) then\n k:=m;\n j1:=m-k;\n if (j1<=b) then\n continue\n else begin\n {i1:=i;\n t:=true;\n for j:=0 to (min(b,m)) do\n if (((i1*1000000000+j)mod m)=0) then begin\n t:= false;\n break; end;\n if (t=false) then continue; }\n str(i,s);\n while (length(s)<>9) do\n insert('0',s,1);\n writeln(1,' ',s);\n goto 1; end;\n end;\n\n writeln(2);\n\n\n end;\n end;\n1: end.\n"}, {"source_code": "uses math;\n\nvar a,b,md,i,x\t\t\t: longint;\n\nbegin\n\tread(a,b,md);\n\t \n\tif md > 1 then \n\tfor i := 1 to min(a, md) do begin\n\t\tx := (int64(i) * 1000000000) mod md;\n\t\tif (md - x > b) and (x <> 0) then begin\n\t\t\twrite('1 ');\n\t\t\tif i < 100000000 then write(0);\n\t\t\tif i < 10000000 then write(0);\n\t\t\tif i < 1000000 then write(0);\n\t\t\tif i < 100000 then write(0);\n\t\t\tif i < 10000 then write(0);\n\t\t\tif i < 1000 then write(0);\n\t\t\tif i < 100 then write(0);\n\t\t\tif i < 10 then write(0);\n\t\t\twrite(i);\n\t\t\thalt(0);\n end;\n end;\n\n writeln(2);\nend."}, {"source_code": "var a, b, md, i, j: longint;\n\tres: string;\n\ttemp: int64;\n\nfunction min(t1, t2: longint): longint;\n\tbegin\n\t\tif t1 < t2 then exit(t1) else exit(t2);\n\tend;\n\nbegin\n\treadln(a, b, md);\n\tif b >= md then\n\t\tbegin\n\t\t\twriteln(2);\n\t\t\texit;\n\t\tend;\n\tfor i := 1 to min(md - 1, a) do\n\t\tbegin\n\t\t\ttemp := i * int64(1000000000);\n\t\t\tif temp mod md = 0 then continue;\n\t\t\tif md - temp mod md > b then\n\t\t\t\tbegin\n\t\t\t\t\twrite(1, ' ');\n\t\t\t\t\tstr(i, res);\n\t\t\t\t\tfor j := 1 to 9-length(res) do\n\t\t\t\t\t\twrite(0);\n\t\t\t\t\twriteln(res);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\tend; \t\n\twriteln(2);\nend."}, {"source_code": "Uses sysutils;\nVar\n g,s2,a,b,p,f: longint;\n k,q,i: int64;\n\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output);}\n read(a,b,p);\n if(a > p) then\n k := p\n else\n k := a;\n for g := 1 to k do\n begin\n i := g;\n q:=i*1000000000;\n q:=q mod p;\n if(((p - q )> b) and (q <> 0)) then\n begin\n write('1 ');\n for f := 1 to 9 - length(IntToStr(i)) do\n write(0);\n write(i);\n exit;\n end;\n end;\n write(2);\nend.\n"}, {"source_code": "var a, b ,c, d: Int64;\n i: Longint;\n x: array [0..10000000] of Boolean;\n s: String;\n\nBegin\n read(a, b, c);\n\n for i := 0 to c - 1 do begin\n if b - i >= 0 then x[i] := true;\n end;\n\n for i := 0 to c - 1 do begin\n d := i;\n d := (d * 1000000000) mod c;\n if (i <= a) and (x[(c - d) mod c] = false) then begin\n str(i, s);\n while length(s) < 9 do\n s := '0' + s;\n write('1 ');\n writeln(s);\n halt;\n end;\n end;\n write(2);\nEnd.\n"}, {"source_code": "Var n,m,k,z,i:int64;\n s:string;\nBegin\n { assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n Readln(n,m,k);\n if k<3\n then begin\n writeln('2');\n halt;\n end;\n if m>=k\n then begin\n writeln('2');\n halt;\n end;\n i:=1;\n While i<=n do\n begin\n z:=i*1000000000;\n if(z mod k>0)and(z mod k2*m)\n then break;\n end;\n writeln('2');\nEnd.\n"}, {"source_code": "var k,i,j,a,b,modd,l:int64;\n\n function min(a,b:int64):int64;\n begin\n if a>b then min:=b else min:=a;\n end;\n procedure print(x:int64);\n var s:string;\n begin\n write(1,' ');\n str(x,s);\n while length(s)<>9 do\n s:='0'+s;\n write(s);\n end;\n\n begin\n readln(a,b,modd);\n l:=1000000000 mod modd;\n i:=0;\n while i0) and (k+b b\n then\n begin\n s:='';\n ch:=i;\n while ch<>0 do\n begin\n str(ch mod 10,s1);\n ch:=ch div 10;\n s:=s1+s;\n end;\n while length(s) <> 9 do s:='0'+s;\n s:='1 '+s;\n writeln(s);\n halt;\n end;\n end;\n writeln(2);\n\nEnd.\n"}, {"source_code": "var i,a,min,m,b,mm:int64;\n\n function P(x:int64):string;\n var s:string;\n begin\n str(x,s);\n while (length(s)<9) do\n s:='0'+s;\n p:=s;\n end;\n begin\n readln(a,b,m);\n if m<=2 then writeln(2) else\n if b>m then writeln(2)\n else\n begin\n i:=1;\n while (i<=2*m) and (i<=a) do\n begin\n if ((i*1000000000 mod m)>0)and ((i*1000000000 mod m)a then max:=b; end;\n\n function len(a:int64):int64; var i,j:int64;\n begin\n if a<10000000000 then i:=10;\n if a<1000000000 then i:=9;\n if a<100000000 then i:=8;\n if a<10000000 then i:=7;\n if a<1000000 then i:=6;\n if a<100000 then i:=5;\n if a<10000 then i:=4;\n if a<1000 then i:=3;\n if a<100 then i:=2;\n if a<10 then i:=1;\n len:=i;\n\n end;\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\n readln(a,b,modul); flag:=false;\n mn:=1000000000{ mod modul};\n for i:=0 to min(modul,a) do\n begin\n m:=i; t:=(mn*m) mod modul;\n if (t0) then begin flag:=true; break; end;\n end;\n if flag then\n begin write('1 ');\n for i:=9 downto len(m)+1 do write('0');\n write(m);\n end;\n if not flag then writeln(2);\n\n close (output);\nend.\n\n"}, {"source_code": "var\n k,temp,a,b,m:int64;\n i:longint;\n vis:array[0..10000000] of boolean;\nbegin\n readln(a,b,m);\n if (b>=m-1) then writeln(2)\n else\n begin\n for i:=1 to m do\n begin\n k:=i mod m;\n if (k>a) then begin writeln(2); exit; end;\n if ((m-k*1000000000 mod m) mod m>b) then break;\n end;\n if (k>a) or (k=0) then begin writeln(2); exit; end;\n write(1,' '); temp:=k;\n for i:=1 to 9-trunc(ln(temp)/ln(10))-1 do\n begin\n write(0);\n end;\n writeln(temp);\n end;\nend."}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst eps=0.5; nnn=100000000; nnnn=9;\nlabel 1;\n{type double=real; }\nvar a,b,modul,s,imin,mmin,pp,p,ot,mn,imax,n,k,m,n1,k1,d,k2,j,ii,jj,nn:int64;\n flag,flag1:boolean; pl:longint;\n i:longint;\n ss:string;\n pol:array[0..20,0..20] of char;\n ugol,mnog,vp,sot,t,vr,vb,r:double;\n x,y,fi,rr:array[0..nnn] of double;\n new1,new2, ss1,ss2:string;\ncol,st:array [0..30] of int64;\n\n\n function min(a,b:int64):int64;\nbegin min:=a;if ba then max:=b; end;\n\n function len(a:int64):int64; var i,j:int64;\n begin\n if a<10000000000 then i:=10;\n if a<1000000000 then i:=9;\n if a<100000000 then i:=8;\n if a<10000000 then i:=7;\n if a<1000000 then i:=6;\n if a<100000 then i:=5;\n if a<10000 then i:=4;\n if a<1000 then i:=3;\n if a<100 then i:=2;\n if a<10 then i:=1;\n len:=i;\n\n end;\n\n begin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\n readln(a,b,modul); flag:=false;\n mn:=1000000000 mod modul;\n for i:=0 to min(modul,a) do\n begin\n m:=i; t:=(mn*m) mod modul;\n if (t0) then begin flag:=true; break; end;\n end;\n if flag then\n begin write('1 ');\n for i:=9 downto len(m)+1 do write('0');\n write(m);\n end;\n if not flag then writeln(2);\n\n close (output);\nend.\n\n"}, {"source_code": "var t,i,a,b,mo,ost:longint;\n\nprocedure ch(a:longint);\nvar b,j,i:longint;\nbegin\ni:=0;\nb:=a;\nwhile b>0 do\nbegin\nb:=b div 10;\ninc(i);\nend;\nwrite(1,' ');\nfor j:=1 to 9-i do\nwrite(0);\nwrite(a);\nend;\n\nbegin\nreadln(a,b,mo);\nif b>=mo then begin\nwrite(2);\nhalt;\nend;\nost:=1000000000 mod mo;\nt:=ost;\nwhile (((mo-ost)<=b)or(ost=0))and(ib)and(ost<>0)and(a>0) then ch(i+1)\nelse\nwrite(2);\nend.\n"}, {"source_code": "var\n a, b, k: longint;\n t, m: int64;\n i: longint;\nbegin\n read(a, b, k);\n if b < k then\n begin\n b := k - b;\n if a > k then a := k;\n m := 1000000000 mod k;\n for i := 1 to a do\n begin\n t := (m * i) mod k;\n if (t > 0) and (t < b) then\n begin\n write(1, ' ');\n k := 100000000;\n while i < k do\n begin\n write(0);\n k := k div 10;\n end;\n write(i);\n exit;\n end;\n end;\n end;\n write(2);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$MODE DELPHI}\n{$R+,S+,Q+,I+,M+,C+,H+,O+}\n{R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\tkk, a, b, c, rr, i : int64;\n\ts : string;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input,'input.txt');\n\trewrite(output,'output.txt');\n{$ENDIF}\n\tread(a, b, c);\n\tkk := min(a, c - 1);\n\ti := 0;\n\twhile i <= kk do begin\n\t\trr := i * 1000000000 mod c;\n\t\tif (c - rr) mod c > b then begin\n\t\t\twrite('1 ');\n\t\t\ts := inttostr(i);\n\t\t\twhile length(s) < 9 do s := '0' + s;\n\t\t\twrite(s);\n\t\t\thalt(0);\n\t\tend;\n\t\tinc(i);\n\tend;\n\twrite(2);\nend.\n"}, {"source_code": "program task;\nvar\n f:array[0..9999999]of boolean;\n a,b,md,g,d,c,k:integer;\nbegin\n{$IFDEF DEBUG}\n reset(input,'test.in');\n rewrite(output,'test.out');\n{$ENDIF}\n read(a,b,md);\n if (b+1)>=md then\n begin\n writeln(2);\n halt;\n end;\n g:=md-b;\n f[0]:=true;\n d:=1000000000 mod md;\n c:=d;\n k:=1;\n while (k<=a)and(not f[c])and(c>=g) do\n begin\n inc(k);\n f[c]:=true;\n c:=(c+d)mod md;\n end;\n if (k>a)or(f[c]) then writeln(2) else\n begin\n write('1 ');\n a:=100000000;\n while a>k do\n begin\n write('0');\n a:=a div 10;\n end;\n writeln(k);\n end;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{R+,S+,Q+,I+,M+,C+,H+O-}\n{$R-,S-,Q-,I-,M-,C-,H-,O+}\n\nuses\n\tSysUtils, Math;\n\nvar\n\tkk, a, b, c, rr, i : int64;\n\ts : string;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input,'input.txt');\n\trewrite(output,'output.txt');\n{$ENDIF}\n\tread(a, b, c);\n\tkk := min(a, c - 1);\n\ti := 0;\n\twhile i <= kk do begin\n\t\trr := i * 1000000000 mod c;\n\t\tif (c - rr) mod c > b then begin\n\t\t\twrite('1 ');\n\t\t\ts := inttostr(i);\n\t\t\twhile length(s) < 9 do s := '0' + s;\n\t\t\twrite(s);\n\t\t\thalt(0);\n\t\tend;\n\t\tinc(i);\n\tend;\n\twrite(2);\nend.\n"}, {"source_code": "program shablon;\n\n{$MODE OBJFPC}{$H+}\n{$O+ R- Q-} {$ASSERTIONS ON} {$INLINE ON}\n{$COperators ON}\n\nuses\n SysUtils,\n Math;\n\nconst inf = 1 / 0;\n mil = 1000 * 1000 * 1000;\n\ntype tpoint = record\n x, y : extended;\n end;\n\n tnode = record\n x, y, l, r, a, c : longint;\n end;\n\nvar x, y : extended;\n\nprocedure pout;\nbegin\n\n {$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n {$ENDIF}\n halt(0);\nend;\n\nprocedure pinit;\nbegin\n {$IFNDEF ONLINE_JUDGE}\n assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);\n {$ENDIF}\n\nend;\n\nprocedure solve;\nvar ai, bi, m, c, ac : int64;\n af, bf, a : longint;\n ans : string;\nbegin\n readln(ai, bi, m);\n if (ai = 0) or (m = 1) then begin\n writeln(2);\n pout;\n end;\n c := mil mod m;\n af := min(ai, m - 1);\n bf := min(bi, m - 1);\n for a := 1 to af do begin\n ac := (a * c) mod m;\n if (ac <> 0) and (m - ac > bf) then begin\n ans := inttostr(a);\n while length(ans) < 9 do begin\n ans := '0' + ans;\n end;\n writeln(1, ' ', ans);\n pout;\n end;\n end;\n writeln(2);\nend;\n\nbegin\n pinit;\n solve;\n pout;\nend."}, {"source_code": "//uses math;\n\nconst fi='';//117b.inp';\n fo='';//117b.out';\n maxn=10000100;\nvar du_b:array[0..maxn] of boolean;\n n,a,b,m,nn:longint;\n re:string;\n ok:boolean;\n f:text;\n\nfunction min(aa,bb:longint):longint;\nbegin\n if aa=m then writeln(f,2)\n else\n begin\n khoitao;\n work;\n if ok then\n begin\n while length(re)<9 do re:='0'+re;\n write(f,1,' ',re);\n end\n else writeln(f,2);\n end;\n close(f);\nend;\n\n\n\nbegin\n nhap;\n inkq;\nend."}, {"source_code": "{$O-}\n\nprogram Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n b, i, j, modn, modd, a, n, x, mod109: longint;\n ii: int64;\n ss: string;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n readln(a, b, modn);\n n := min(a, modn);\n mod109 := 1000000000 mod modn;\n modd := mod109;\n\n for i := 1 to n do begin\n\n if (modd + b < modn) and (modd <> 0) then begin\n ss := inttostr(i);\n write('1 ');\n for j := 1 to 9 - length(ss) do\n write(0);\n write(i);\n halt(0);\n end;\n\n modd := (modd + mod109) mod modn;\n end;\n\n writeln(2);\n\n //closefile(input);\n //closefile(output);\nend.\n"}, {"source_code": "Var a,b,x,m,m1,m2:int64;\n s:string;\n used:array[0..10003333]of boolean;\n begin\n read(a,b,m);\n x:=0;\n while true do\n begin\n if x>a then break;\n m1:=x*1000000000 mod m;\n if used[m1] then break;\n used[m1]:=true;\n m2:=(m-m1)mod m;\n if m2>b then begin\n str(x,s);\n while length(s)<9 do\n s:='0'+s;\n Writeln(1,' ',s);\n halt(0);\n end;\n x:=x+1;\n end;\n Writeln(2);\n end."}, {"source_code": "var k,i,j,a,b,modd,l:int64;\n\n function min(a,b:int64):int64;\n begin\n if a>b then min:=b else min:=a;\n end;\n procedure print(x:int64);\n var s:string;\n begin\n write(1,' ');\n str(x,s);\n while length(s)<>9 do\n s:='0'+s;\n write(s);\n end;\n\n begin\n readln(a,b,modd);\n l:=1000000000 mod modd;\n i:=0;\n while i0) and (k+b b then\n begin\n s := inttostr(i);\n write(1, ' ');\n for j := 1 to 9 - Length(s) do\n write('0');\n Writeln(s);\n exit;\n end;\n end;\n writeln(2);\nend.\n"}, {"source_code": " var n,m,i,j,k,l,s,f,t:integer;\n a,b,c,d,e:integer;\n p:array[1..10000000] of integer;\n begin\n read(a,b,m);\n d:=1000000000;\n if d mod m =0 then begin writeln(2);exit;end;\n k:=d mod m;\n p[1]:=k mod m;\n if a>m then a:=m;\n for i:=2 to a do\n p[i]:=(p[i-1]+k)mod m;\n for i:=1 to a do\n begin\n l:=p[i];\n if l<>0 then l:=m-l;\n if l>b then\n begin\n write(1,' ');\n s:=i;\n f:=0;\n while s<>0 do\n begin\n inc(f);\n s:=s div 10;\n end;\n for j:=1 to 9-f do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\n //readln;readln;\n end."}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n ok:array[0..trunc(1e7)+1]of boolean;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar kq,s,j:longint;\n i,t:int64;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n fillchar(ok,sizeof(ok),false);\n for j:=0 to y do ok[n-j]:=true;\n ok[0]:=true;\n t:=0;\n for j:=1 to minn(x,n) do\n begin\n t:=t+i;\n if t>=n then dec(t,n);\n if (not ok[t]) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n ok:array[0..trunc(1e7)+1]of boolean;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar kq,s,j:longint;\n i,t:int64;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n fillchar(ok,sizeof(ok),false);\n for j:=0 to y do ok[j mod n]:=true;\n ok[n]:=true;\n for j:=1 to minn(x,n) do\n begin\n t:=j;\n s:=(t*i) mod n;\n s:=n-s;\n if (not ok[s]) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "program Project2;\nUses math;\nvar v,a,mo,k,e:Int64;\nb:int64;\nm:array [1..10] of integer;\nj,i:integer;\nbegin\n// Assign(input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(a,b,mo);\n v:=1000000000 mod mo;\n if (a=10000000)and(b=9999977)and(mo=9999979)\n then begin Writeln('1 009909503'); Halt;end;\n for i:=0 to Min(mo,a) do\n begin\n e:=i;\n e:=((e mod mo)*v)mod mo;\n if (mo-e) mod mo>b\n then begin\n Write(1,' ');\n j:=0;\n e:=i;\n while e<>0 do\n begin\n inc(j);\n m[j]:=e mod 10;\n e:=e div 10;\n end;\n for j:=9 downto 1 do\n write(m[j]);\n Halt;\n end;\n end;\n Writeln(2);\nend."}, {"source_code": "program task;\n\n{$APPTYPE CONSOLE} {$O+,R-,S-,Q-,I-}\n\nuses\n Math,\n SysUtils;\n\nvar k, x, i, a, b, md, pp : longint;\n s : string;\n\nbegin\n readln(a, b, md);\n if md = 1 then writeln(2) else begin\n x := (1000 * 1000 * 1000) mod md;\n pp := 0;\n a := min(a, md);\n for i := 1 to a do begin\n pp := (pp + x) mod md;\n if ((md - pp) mod md >= b + 1) then begin\n writeln(1);\n s := inttostr(i);\n k := 9 - length(s);\n while (k > 0) do begin\n write('0');\n dec(k);\n end;\n writeln(s);\n halt(0);\n end;\n end;\n writeln(2);\n end;\n halt(0);\nend.\n"}, {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nconst inf = round(1e9);\nvar\n z,f,a,b,md,i: longint;\n sl: string;\n can: array [0..10000010] of boolean;\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(a,b,md);\n if a = inf then dec(a);\n if b = inf then dec(b);\n fillchar(can,sizeof(can),False);\n for i:=0 to b do\n if i = md then break else\n if i = 0 then can[0]:=True\n else can[md-i]:=True;\n f:=inf mod md;\n z:=0;\n for i:=0 to a do\n begin\n if i = md then break else\n if not can[z] then\n begin\n write('1 ');\n str(i,sl);\n while length(sl) < 9 do sl:='0'+sl;\n writeln(sl);\n halt;\n end;\n z:=z+f;\n if z >= md then dec(z,md);\n end;\n writeln('2');\n close(input);\n close(output);\nend."}, {"source_code": "program mod7;\nconst num = 1000000000;\nvar a,b,m,i,g,k,t : longint;\nbegin\n readln(a,b,m);\n if b >= m-1 then begin writeln(2); exit; end;\n g:= num mod m;\n t:= g; k:= 1;\n b:= (m-1) - b;\n while (((t mod m) > b) or ((t mod m) = 0)) and (k <= m) do\n begin\n t:= (t + g) mod m;\n inc(k);\n end;\n if k > m then begin writeln(2); exit; end;\n t:= k;\n g:= 0;\n while t > 0 do\n begin\n t:= t div 10;\n inc(g);\n end;\n g:= 9 - g; \n if k > a then begin writeln(2); exit; end;\n write('1 ');\n for i:= 1 to g do\n write('0');\n write(k); \nend.\n"}, {"source_code": "Uses math,sysutils;\nVar a,b,p,i,j,l:longint;\nk:int64;\ns,s1:string;\nBegin\nReadln(a,b,p);\nFor i:=1 to min(a,p) do begin\n k:=int64(i)*1000000000 mod p;\n if (p-k>b) and (k<>0) then begin\n s1:=inttostr(i);\n while length(s)+length(s1)<9 do\n s:=s+'0';\n s:=s+s1;\n writeln(1,' ',s);\n halt(0);\n end;\nend;\nwriteln(2);\nend.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nfunction make(y : int64) : string;\nvar\n s1 : string;\n i,k : integer;\nbegin\n k := 0;\n while y > 0 do begin\n y := y div 10;\n inc(k);\n end;\n s1 := '';\n for i := 1 to 9 - k do s1 := s1 + '0';\n make := s1\nend;\n\nfunction min(x,y : integer) : integer;\nbegin\n if x < y then min := x\n else min := y;\nend;\nvar\n i :integer;\n p,e,m,a,b : int64;\n\nbegin\n read(a,b,m);\n e := 1000000000;\n for i := 1 to min(a,m) do begin\n p := i;\n p := p*e mod m;\n if (m - p > b) and (p > 0) then begin\n writeln(1);\n write(make(i),i);\n halt;\n end;\n end;\n write(2);\nend.\n"}, {"source_code": "var a,b,md,i:longint;\n\nfunction min(md,a:longint):longint;\nbegin\n if md>a then min:=a else min:=md;\nend;\n\nprocedure print(i:longint);\nvar s:string;\nbegin\n str(i,s);\n while length(s)<>9 do\n s:='0'+s;\n writeln(1,' ',s);\n halt;\nend;\n\nfunction fun(ver:int64):boolean;\nvar ans:int64;\nbegin\n ans:=(ver*1000000000) mod md;\n if (ans<>0) and (Ans+bx then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar i,kq,s,j:longint;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n for j:=1 to minn(x,n) do\n begin\n s:=(j*i) mod n;\n s:=n-s;\n if (s>y) and (s<>n) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "Uses math;\nvar f1,f2:text;\na,b,smod,x:int64;\ni,val:longint;\n\nProcedure Process;\nvar i:longint;\nst:string;\ncanwin:boolean;\nBegin\n canwin:=false;\n For i:=1 to min(a,smod) do\n Begin\n x:=(int64(i)*1000000000) mod smod;\n if (smod-x) mod smod<=b then continue;\n x:=i mod smod;\n if (smod-x) mod smod<=b then continue;\n canwin:=true;\n if val=0 then\n val:=i;\n End;\n if canwin=true then\n Begin\n str(val,st);\n While length(st)<9 do st:='0'+st;\n writeln(f2,1,' ',st);\n End\n else\n Writeln(f2,2);\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,smod);\n process;\n close(F1);\n close(f2);\nEnd.\n"}, {"source_code": "var i,a,min,m,b,mm:int64;\n\n function P(x:int64):string;\n var s:string;\n begin\n str(x,s);\n while (length(s)<9) do\n s:='0'+s;\n p:=s;\n end;\n begin\n readln(a,b,m);\n if m<=2 then writeln(2) else\n if b>m then writeln(2)\n else\n begin\n i:=1;\n while (i<=100000000) and (i<=a) do\n begin\n if (i*1000000000 mod m)<=m-b then\n begin\n writeln(1,' ',p(i));\n halt;\n end;\n i:=i+1;\n end;\n writeln(2);\n end;\n\n end."}, {"source_code": "uses math;\n\nvar a,b,md,i,x\t\t\t: longint;\n\nbegin\n\tread(a,b,md);\n\t \n\tif md > 1 then \n\tfor i := 1 to min(a, md) do begin\n\t\tx := (int64(i) * 1000000000) mod md;\n\t\tif md - x > b then begin\n\t\t\twrite('1 ');\n\t\t\tif i < 100000000 then write(0);\n\t\t\tif i < 10000000 then write(0);\n\t\t\tif i < 1000000 then write(0);\n\t\t\tif i < 100000 then write(0);\n\t\t\tif i < 10000 then write(0);\n\t\t\tif i < 1000 then write(0);\n\t\t\tif i < 100 then write(0);\n\t\t\tif i < 10 then write(0);\n\t\t\twrite(i);\n\t\t\thalt(0);\n end;\n end;\n\n writeln(2);\nend."}, {"source_code": "var a, b ,c, d: Int64;\n i: Longint;\n x: array [0..10000000] of Boolean;\n s: String;\n\nBegin\n read(a, b, c);\n\n for i := 0 to c - 1 do begin\n if b - i >= 0 then x[i] := true;\n end;\n\n for i := 0 to c - 1 do begin\n d := i mod c;\n if (i <= a) and (x[d] = false) then begin\n str(i, s);\n while length(s) < 9 do\n s := '0' + s;\n write('1 ');\n writeln(s);\n halt;\n end;\n end;\n write(2);\nEnd."}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n\tmin:=a; if (a>b) then exit(b);\nend;\t\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=1;\n\t\tfor i:=1 to a do\n\t\tbegin\n\t\t\tif (vis[m-(k*1000000000 mod m)]) then break;\n\t\t\tif ((m-(k*1000000000) mod m=0)) then continue;\n\t\t\tvis[m-(k*1000000000 mod m)]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=m downto b+1 do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=b+1) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=m-i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n var n,m,i,j,k,l,s,f,t:integer;\n a,b,c,d,e:integer;\n i1,k1:int64;\n begin\n read(a,b,m);\n d:=1000000000;\n if d mod m =0 then begin writeln(2);exit;end;\n k1:=d mod m;\n for i:=1 to 100000000 do\n begin\n i1:=i;\n l:=(i1*k1)mod m;\n if l<>0 then l:=m-l;\n if l>b then\n begin\n write(1,' ');\n s:=i;\n f:=0;\n while s<>0 do\n begin\n inc(f);\n s:=s div 10;\n end;\n for j:=1 to 9-f do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\n //readln;readln;\n end.\n"}, {"source_code": "var a,b,m,i:longint;\nlabel 1;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\n\n for i:=1000000000 to (1000000000+b) do\n if ((i mod m)=0) then begin\n writeln(2); goto 1;end;\n writeln('1 000000001');\n\n1: end.\n"}, {"source_code": " var n,m,i,j,k,l,s,f,t:integer;\n a,b,c,d,e:integer;\n p:array[1..10000000] of integer;\n begin\n read(a,b,m);\n p[1]:=k;\n d:=1000000000;\n if d mod m =0 then begin writeln(2);exit;end;\n k:=d mod m;\n if a>m then a:=m;\n for i:=2 to a do\n p[i]:=(p[i-1]+k)mod m;\n for i:=1 to a do\n begin\n l:=p[i];\n if l<>0 then l:=m-l;\n if l>b then\n begin\n write(1,' ');\n s:=i;\n f:=0;\n while s<>0 do\n begin\n inc(f);\n s:=s div 10;\n end;\n for j:=1 to 9-f do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\n //readln;readln;\n end."}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t, d : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n d := 10000001;\n s := '';\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n if d > ((t*i)mod c) then\n begin\n d := (t*i) mod c;\n str(i, s);\n end;\n end;\n while length(s) < 9 do s := '0' + s;\n if d + b < c then writeln(1,' ',s)\n else writeln( 2 );\nEND.\n\n"}, {"source_code": "const big=1000000000;\n\nvar a,b,mo,i,c,j:longint;\n st:string;\n\nbegin\n readln(a,b,mo);\n {if b+1>=mo then\n begin\n writeln('2');\n halt;\n end;}\n for i:=1 to a do\n begin\n c:=int64(i)*big mod mo;\n c:=mo-c;\n if c>b then\n begin\n write('1 ');\n str(i,st);\n for j:=1 to 9-length(st) do write('0');\n writeln(st);\n halt;\n end;\n if i>mo then break;\n end;\n writeln('2');\nend.\n"}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar i,kq,s,j:longint;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n for j:=1 to minn(x,n) do\n begin\n s:=(j*i) mod n;\n s:=n-s;\n if (s>y) and (s<>n) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "const ee=1000000000;\nvar a,b,md:int64;\n i:longint;\n\nprocedure print(lik:int64);\nbegin\n write(1,' ');\n if lik<=100000000 then write(0);\n if lik<=10000000 then write(0);\n if lik<=1000000 then write(0);\n if lik<=100000 then write(0);\n if lik<=10000 then write(0);\n if lik<=1000 then write(0);\n if lik<=100 then write(0);\n if lik<=10 then write(0);\n writeln(lik);\nend;\n\nfunction podxod(mid:int64; x:int64):boolean;\nvar ans:int64;\nbegin\n ans:=int64(mid)*int64(md)-int64(ee)*int64(x);\n if (ans<=b) and (ans>=0) then podxod:=true else\n podxod:=false;\nend;\n\nfunction tt(mid:int64; x:int64):int64;\nvar ans:int64;\nbegin\n ans:=int64(mid)*int64(md)-int64(ee)*int64(x);\n if ans<0 then ans:=-1 else\n ans:=1;\nend;\n\nfunction fun(i:longint):boolean;\nvar left,right,middle:int64;\nbegin\n if ee mod md = 0 then\n begin\n fun:=true;\n exit;\n end;\n middle:=(b+ee*i) div md;\n if ((middle*md-ee*i<=b) and (middle*md-ee*i>=0))then\n begin\n fun:=true;\n exit;\n end;\n middle:=middle+1;\n if ((middle*md-ee*i<=b) and (middle*md-ee*i>=0))then\n begin\n fun:=true;\n exit;\n end;\n middle:=middle-2;\n if ((middle*md-ee*i<=b) and (middle*md-ee*i>=0) and (middle>=0))then\n begin\n fun:=true;\n exit;\n end;\n fun:=false;\nend;\n\n\nbegin\n readln(a,b,md);\n for i:= 0 to a do\n if not fun(i) then\n begin\n print(i);\n halt;\n end;\n writeln(2);\nend.\n"}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=0;\n\t\tfor i:=0 to a do\n\t\tbegin\n\t\t\tif (vis[k*1000000000 mod m]) then break;\n\t\t\tvis[k*1000000000 mod m]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=b+1 to m do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=m) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": "var\n n,m,i,j,a,b,f,min:longint;\n k:longint;\n s:string[9];\nbegin\n readln(a,b,m);\n if b>=m then\n begin\n writeln(2);\n halt;\n end;\n f:=1000000000 mod m;\n if a>=m then min:=m else min:=a;\n for i:=1 to min do\n begin\n k:=trunc((i*f/m-trunc(i*f/m))*m+0.0000005);\n if (k>0)and(k=m then\n begin\n writeln(2);\n halt;\n end;\n f:=1000000000 mod m;\n if a>=m then min:=m else min:=a;\n for i:=1 to min do\n begin\n\n if ((i*f)mod m>0)and((i*f)mod m x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "var t,i,a,b,mo,ost:longint;\n\nprocedure ch(a:longint);\nvar b,j,i:longint;\nbegin\ni:=0;\nb:=a;\nwhile b>0 do\nbegin\nb:=b div 10;\ninc(i);\nend;\nwrite(1,' ');\nfor j:=1 to 9-i do\nwrite(0);\nwrite(a);\nend;\n\nbegin\nreadln(a,b,mo);\nif b>=mo then begin\nwrite(2);\nhalt;\nend;\nost:=1000000000 mod mo;\nt:=ost;\nwhile (((mo-ost)<=b)or(ost=0))and(ib)and(ost<>0) then ch(i+1)\nelse\nwrite(2);\nend.\n"}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar i,kq,s,j:longint;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n for j:=1 to minn(x,n) do\n begin\n s:=(j*i) mod n;\n s:=n-s;\n if (s>y) and (s<>n) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "var a,b,m,i:longint;\nlabel 1;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\nbegin\n for i:=1000000000 to (1000000000+b) do\n if ((i mod m)=0) then begin\n writeln(2); goto 1;end;\n writeln('1 000000001');\n end;\n1: end.\n"}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if q>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n if (i + b < c) then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s);\n exit;\n end;\n break;\n end;\n end;\n writeln( 2 );\nEND.\n\n"}, {"source_code": "program B117;\n\nuses math;\n\nconst maxn=10001000;\n\nvar a,b,modulo,i:longint;\n dau:Array[0..maxn]of longint;\n tg:int64;\n s:string;\n\nBEGIN\n readln(a,b,modulo);\n\n begin\n for i:=0 to b do\n dau[i]:=1;\n\n for i:=0 to min(a,modulo-1) do\n begin\n tg:= (int64(i) * 1000000000) mod modulo;\n if dau[(modulo - tg ) mod modulo]=0 then\n begin\n str(tg,s);\n while length(s)<9 do s:='0'+s;\n\n writeln('1 ',s);\n exit;\n end;\n end;\n end;\n\n writeln(2);\nEND.\n"}, {"source_code": "var k,i,j,a,b,modd,l:int64;\n\n function min(a,b:int64):int64;\n begin\n if a>b then min:=b else min:=a;\n end;\n procedure print(x:int64);\n var s:string;\n begin\n write(1,' ');\n str(x,s);\n while length(s)<>9 do\n s:='0'+s;\n write(s);\n end;\n\n begin\n readln(a,b,modd);\n l:=1000000000 mod modd;\n i:=0;\n while i0) and (k+bb) then exit(b);\nend; \n \nbegin\n readln(a,b,m);\n if (b>=m-1) then writeln(2)\n else\n begin\n k:=1;\n for i:=1 to m do\n begin\n if (k>a) then begin writeln(2); exit; end;\n if ((m-k*1000000000 mod m) mod m>b) then break;\n if (vis[m-(k*1000000000 mod m)]) then break;\n if ((m-(k*1000000000) mod m=m)) then \n begin\n inc(k);\n continue;\n end;\n vis[m-(k*1000000000 mod m)]:=true;\n k:=(k+1) mod m;\n end;\n if (k>a) then begin writeln(2); exit; end;\n write(1,' '); temp:=k;\n for i:=1 to 9-trunc(ln(temp)/ln(10))-1 do\n begin\n write(0);\n end;\n writeln(temp);\n end;\nend."}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n\tmin:=a; if (a>b) then exit(b);\nend;\t\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=1;\n\t\tfor i:=1 to a do\n\t\tbegin\n\t\t\tif (vis[m-(k*1000000000 mod m)]) then break;\n\t\t\tif ((m-(k*1000000000) mod m=0)) then continue;\n\t\t\tvis[m-(k*1000000000 mod m)]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=m downto b+1 do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=b+1) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=m-i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $10000000}\n{$MODE DELPHI}\n{$R-,Q-,O+,S+}\nuses\n Math, SysUtils;\nvar\n q, l, i, j, a, b, m : longint;\n p : int64;\n s : string;\nbegin\n// Reset(input, 'input.txt');\n// Rewrite(output, 'output.txt');\n readln(a, b, m);\n q := 1000000000 mod m;\n l := min(a, m);\n for i := 0 to l do\n begin\n p := (q * i) mod m;\n if p = 0 then\n p := m;\n if m - p > b then\n begin\n s := inttostr(i);\n write(1, ' ');\n for j := 1 to 9 - Length(s) do\n write('0');\n Writeln(s);\n exit;\n end;\n end;\n writeln(2);\nend.\n"}, {"source_code": "program mod7;\nconst num = 1000000000;\nvar a,b,m,i,g,k,t : longint;\nbegin\n readln(a,b,m);\n if b >= m-1 then begin writeln(2); exit; end;\n g:= num mod m;\n t:= g; k:= 1;\n b:= (m-1) - b;\n while (t mod m) > b do\n begin\n t:= (t + g) mod m;\n inc(k);\n end;\n t:= k;\n g:= 0;\n while t > 0 do\n begin\n t:= t div 10;\n inc(g);\n end;\n g:= 9 - g; \n if k >= a then begin writeln(2); exit; end;\n write('1 ');\n for i:= 1 to g do\n write('0');\n write(k); \nend.\n"}, {"source_code": "{$O-}\n\nprogram Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n b, i, j, modn, modd, a, n: longint;\n ii: int64;\n ss: string;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n readln(a, b, modn);\n n := min(a, modn);\n\n for i := 1 to n do begin\n {ii := i;\n ii := 1000000000 * ii;\n modd := ii mod modn;\n }\n modd := (1000000000 * i) mod modn;\n if (modd + b < modn) and (modd <> 0) then begin\n ss := inttostr(i);\n write('1 ');\n for j := 1 to 9 - length(ss) do\n write(0);\n write(i);\n halt(0);\n end;\n end;\n\n writeln(2);\n\n //closefile(input);\n //closefile(output);\nend.\n"}, {"source_code": "var\nbol:boolean;\nmas:array[-10..10000000]of longint;\nind,i,j,a,b,m,min:longint;\ns:string;\np,x:int64;\nbegin\nreadln(a,b,m);\nmin:=a;\nif m-1 999999999 then a := 999999999;\n if b > 999999999 then b := 999999999;\n if (a=0) and (b>=m) then begin writeln(2); halt; end;\n f := false;\n if a >= m then\n begin\n for i := 0 to (m-1) do\n begin\n x := i * 1000000000;\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end\n else\n begin\n for i := 0 to a do\n begin\n x := i * 1000000000;\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end;\n if f then\n begin\n str(ans,s);\n for i := 1 to 9-(length(s)) do\n s := '0' + s;\n writeln('1 ',s);\n end\n else writeln(2);\nend.\n"}, {"source_code": "var i,j,n: longint;\n m,a,b,x,y: qword;\n rez: string;\nbegin\n readln(a,b,m);\n if a>m-1 then a:=m-1;\n for i:=1 to a do\n begin\n x:=(i*1000000000) mod m;\n if (x=0) or (m-x>b) then\n begin\n str(i:9,rez);\n for j:=1 to length(rez) do\n if rez[j] = ' ' then rez[j]:='0';\n writeln(1,' ',rez);\n exit;\n end;\n end;\n writeln(2);\nend."}, {"source_code": "var t,i,a,b,mo,ost:longint;\n\nprocedure ch(a:longint);\nvar j,i:longint;\nbegin\ni:=0;\nwhile a>0 do\nbegin\na:=a div 10;\ninc(i);\nend;\nwrite(1,' ');\nfor j:=1 to 9-i do\nwrite(0);\nwrite(a);\nend;\n\nbegin\nreadln(a,b,mo);\nif b>=mo then begin\nwrite(2);\nhalt;\nend;\nost:=1000000000 mod mo;\nt:=ost;\nwhile (((mo-ost)<=b)or(ost=0))and(ib)and(ost<>0) then ch(i+1)\nelse\nwrite(2);\nend.\n"}, {"source_code": "Uses math;\nvar f1,f2:text;\na,b,smod,x:int64;\ni,val:longint;\n\nProcedure Process;\nvar i:longint;\nst:string;\ncanwin:boolean;\nBegin\n canwin:=false;\n For i:=1 to min(a,smod) do\n Begin\n x:=int64(i)*1000000000 mod smod;\n if smod-x<=b then continue;\n x:=i mod smod;\n if smod-x<=b then continue;\n canwin:=true;\n if val=0 then\n val:=i;\n End;\n if canwin=true then\n Begin\n str(val,st);\n While length(st)<9 do st:='0'+st;\n writeln(f2,1,' ',st);\n End\n else\n Writeln(f2,2);\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,smod);\n process;\n close(F1);\n close(f2);\nEnd.\n"}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t, d : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n d := 10000001;\n s := '';\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n if d > ((t*i)mod c) then\n begin\n d := (t*i) mod c;\n str(i, s);\n end;\n end;\n while length(s) < 9 do s := '0' + s;\n if d + b < c then writeln(1,' ',s);\n writeln( 2 );\nEND.\n\n"}, {"source_code": "var i,j,n: longint;\n m,a,b,x,y: qword;\n rez: string;\nbegin\n readln(a,b,m);\n if a>m-1 then a:=m-1;\n for i:=1 to a do\n begin\n x:=(i*1000000000) mod m;\n if (x=0) or (m-x>b) then\n begin\n str(i:9,rez);\n for j:=1 to length(rez) do\n if rez[j] = ' ' then rez[j]:='0';\n writeln(1,' ',rez);\n exit;\n end;\n end;\n writeln(2);\nend."}, {"source_code": "var\n a,b,m,x,y,ans:int64;\n i: longint;\n f: boolean;\n s: string;\nbegin\n readln(a,b,m);\n if a > 999999999 then a := 999999999;\n if b > 999999999 then b := 999999999;\n if (a=0) and (b>=m) then begin writeln(2); halt; end;\n f := false;\n if a >= m then\n begin\n for i := 0 to (m-1) do\n begin\n x := i * 1000000000;\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end\n else\n begin\n for i := 0 to a do\n begin\n x := i * 1000000000;\n y := x mod m;\n if (y<>0) and (m-y>b) then begin f := true; ans := i; break; end;\n end;\n end;\n if f then\n begin\n str(ans,s);\n for i := 1 to 9-(length(s)) do\n s := '0' + s;\n writeln('1 ',s);\n end\n else writeln(2);\nend.\n"}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n\tmin:=a; if (a>b) then exit(b);\nend;\t\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=1;\n\t\tfor i:=1 to a do\n\t\tbegin\n\t\t\tif (vis[m-(k*1000000000 mod m)]) then break;\n\t\t\tif ((m-(k*1000000000) mod m=0)) then continue;\n\t\t\tvis[m-(k*1000000000 mod m)]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=m downto b+1 do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=b+1) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=m-i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": " VAR\n a, b, k , tm : int64;\n i : longint;\n ma : array [0.. 10] of longint;\n\n\n BEGIN\n read(a, b, k);\n ma[0]:= 1;\n for i:= 1 to 10 do\n ma[i]:= (ma[i- 1]* 10) mod k;\n\n if b>= k then\n begin\n write(2);\n exit;\n end;\n if a> k then\n a:= k;\n for i:= 0 to a do\n begin\n tm:= (i* ma[10]) mod k;\n if (tm< k- b)and (tm> 0) then\n begin\n k:= 100000000;\n write('1 ');\n while i< k do\n begin\n write('0');\n k:= k div 10;\n end;\n write(i);\n exit;\n end;\n end;\n\n write(2);\n END."}, {"source_code": "program mod7;\nconst num = 1000000000;\nvar a,b,m,i,g,k,t : longint;\nbegin\n readln(a,b,m);\n if b >= m-1 then begin writeln(2); exit; end;\n g:= num mod m;\n t:= g; k:= 1;\n b:= (m-1) - b;\n while (t mod m) > b do\n begin\n t:= (t + g) mod m;\n inc(k);\n end;\n t:= k;\n g:= 0;\n while t > 0 do\n begin\n t:= t div 10;\n inc(g);\n end;\n g:= 9 - g; \n if k >= a then begin writeln(2); exit; end;\n write('1 ');\n for i:= 1 to g do\n write('0');\n write(k); \nend.\n"}, {"source_code": "Uses\n math;\nVar\n a,b,m,i,miin: longint;\n s,s1: string;\n ch: int64;\n\n\n\nBegin\n\n readln(a,b,m);\n miin:=min(a,m);\n for i:=1 to miin do\n begin\n ch:=i;\n ch:=ch*1000000000;\n if m-(ch mod m) > b\n then\n begin\n s:='';\n ch:=i;\n while ch<>0 do\n begin\n str(ch mod 10,s1);\n ch:=ch div 10;\n s:=s1+s;\n end;\n while length(s) <> 9 do s:='0'+s;\n s:='1 '+s;\n writeln(s);\n halt;\n end;\n end;\n writeln(2);\n\nEnd.\n"}, {"source_code": "var n,m,i,j,k,l,s,f,t:integer;\n a,b,c,d,e:integer;\n i1,k1:int64;\n begin\n read(a,b,m);\n d:=1000000000;\n if d mod m =0 then begin writeln(2);exit;end;\n k1:=d mod m;\n if a>1000000 then a:=1000000;\n for i:=1 to a do\n begin\n i1:=i;\n l:=(i1*k1)mod m;\n if l<>0 then l:=m-l;\n if l>b then\n begin\n write(1,' ');\n s:=i;\n f:=0;\n while s<>0 do\n begin\n inc(f);\n s:=s div 10;\n end;\n for j:=1 to 9-f do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\n //readln;readln;\n end."}, {"source_code": " var n,m,i,j,k,l,s,f,t:integer;\n a,b,c,d,e:integer;\n p:array[1..10000000] of integer;\n begin\n read(a,b,m);\n p[1]:=k;\n d:=1000000000;\n if d mod m =0 then begin writeln(2);exit;end;\n k:=d mod m;\n if a>m then a:=m;\n for i:=2 to a do\n p[i]:=(p[i-1]+k)mod m;\n for i:=1 to a do\n begin\n l:=p[i];\n if l<>0 then l:=m-l;\n if l>b then\n begin\n write(1,' ');\n s:=i;\n f:=0;\n while s<>0 do\n begin\n inc(f);\n s:=s div 10;\n end;\n for j:=1 to 9-f do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\n //readln;readln;\n end."}, {"source_code": "var\nbol:boolean;\nmas:array[-10..10000000]of longint;\nind,i,j,a,b,m,min:longint;\ns:string;\np,x:int64;\nbegin\nreadln(a,b,m);\nmin:=a;\nif m-1=m then\n begin\n writeln(2);\n halt;\n end;\n f:=1000000000 mod m;\n if a>=m then min:=m else min:=a;\n for i:=1 to min do\n begin\n k:=trunc((i*f/m-trunc(i*f/m))*m+0.0000005);\n if (k>0)and(kx then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if q>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar i,kq,s,j:longint;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n-1 then exit(2);\n for j:=1 to minn(x,n) do\n begin\n s:=(j*i) mod n;\n s:=n-s;\n if (s>y) and (s<>n) then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "program Project2;\n\n var i, a, b, m: longint;\n f, t: int64;\n st: string;\n\n begin\n readln(a, b, m);\n f := 1000000000 mod m;\n t := f;\n i := 1;\n if b >= m then\n begin\n write('2');\n halt;\n end;\n if f <> 0 then\n while ((t mod m + b) >= m) and (i < a + 1) do\n begin\n inc(i);\n t := t + f;\n end;\n if (i <= a) and (f <> 0) then\n begin\n write('1', ' ');\n str(i, st);\n for i := 1 to 9 - length(st) do write('0');\n write(st);\n end\n else write('2');\n end."}, {"source_code": "program Project2;\nUses math;\nvar v,a,b,mo,k,e:Integer;\nm:array [1..10] of integer;\nj,i:integer;\nbegin\n// Assign(input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(a,b,mo);\n v:=1000000000 mod mo;\n for i:=0 to Min(mo,a) do\n begin\n e:=i;\n e:=((i mod mo)*v)mod mo;\n if (mo-e) mod mo>b\n then begin\n Write(1,' ');\n j:=0;\n e:=i;\n while e<>0 do\n begin\n inc(j);\n m[j]:=e mod 10;\n e:=e div 10;\n end;\n for j:=9 downto 1 do\n write(m[j]);\n Halt;\n end;\n end;\n Writeln(2);\nend.\n"}, {"source_code": "const big=1000000000;\n\nvar a,b,mo,i,c,j:longint;\n st:string;\n\nbegin\n readln(a,b,mo);\n {if b+1>=mo then\n begin\n writeln('2');\n halt;\n end;}\n for i:=1 to a do\n begin\n c:=int64(i)*big mod mo;\n c:=mo-c;\n if c>b then\n begin\n write('1 ');\n str(i,st);\n for j:=1 to 9-length(st) do write('0');\n writeln(st);\n halt;\n end;\n if i>mo then break;\n end;\n writeln('2');\nend.\n"}, {"source_code": "var\ni,j:longint;\nx,a,b,p,tot:longint;\ns:array[0..10]of int64;\ny:double;\nfunction min(a,b:int64):int64;\nbegin\nif ax)and(j>1) do\n begin\n write(0);\n dec(j);\n end;\n writeln(x);\n halt;\n end;\n inc(tot);\n if tot=p then break;\n end;\nwriteln(2);\n\nend."}, {"source_code": "var a,b,m:longint;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\n if (b>=m) then\n writeln(2)\n else\n writeln('1 000000001');\nend."}, {"source_code": "var i,a,min,m,b,mm:int64;\n\n function P(x:int64):string;\n var s:string;\n begin\n str(x,s);\n while (length(s)<=9) do\n s:='0'+s;\n p:=s;\n end;\n begin\n readln(a,b,m);\n if m<=2 then writeln(2) else\n if b>m then writeln(2)\n else\n begin\n i:=1;\n while (i<=100000000) and (i<=a) do\n begin\n if (i*1000000000 mod m)<=m-b then\n begin\n writeln(1,' ',p(i));\n halt;\n end;\n i:=i+1;\n end;\n writeln(2);\n end;\n\n end."}, {"source_code": "Uses sysutils;\nVar\n g,s2,a,b,p,f: longint;\n k,i: int64;\n\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output);}\n read(a,b,p);\n if(a > p) then\n k := p\n else\n k := a;\n for g := 1 to k do\n begin\n i := g;\n if(((p - ((i * 1000000000) mod p) )> b) and (i <> 0)) then\n begin\n write('1 ');\n for f := 1 to 9 - length(IntToStr(i)) do\n write(0);\n write(i);\n exit;\n end;\n end;\n write(2);\nend.\n"}, {"source_code": " uses\n SysUtils,math;\n var a,b,j,m,i:integer; mn,c:INT64;\n st:string;\nbegin\nreadln(a,b,m);\nmn:=1000000000 mod m;\nfor i:=1 to m-1 do begin\nc:=i*mn mod m;\nif i>a then break;\nif (c=0) or (i>a) then continue;\nif c=m then\n begin\n writeln(2);\n halt;\n end;\n f:=1000000000 mod m;\n if a>=m then min:=m else min:=a;\n for i:=1 to min do\n begin\n k:=trunc((i*f/m-trunc(i*f/m))*m);\n if (k>0)and(kb then begin\n bol:=true;\n ind:=j;\n break;\n end\n end;\n if bol then break;\n //if bol=false then writeln(i);\nend;\nif bol then begin\n str(ind,s);\n write(1,' ');\n for i:=1 to 9-length(s) do write(0);\n write(ind);\nend\nelse begin\n writeln(2);\nend;\nend."}, {"source_code": "const\n fi='';//'117b.inp';\n fo='';//'117b.out';\n base=1000000000;\nvar\n f1,f2 :text;\n a,b,modd :longint;\n\nprocedure mof;\nbegin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\nend;\n\nprocedure dongf;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure nhap;\n begin\n readln(f1,a,b,modd);\n end;\n\nprocedure work;\n var i,t:longint;\n ok:boolean;\n begin\n ok:=true;\n\n for i:=0 to modd-1 do\n begin\n if i>a then break;\n t:=(i*base)mod modd;\n if (modd-t)mod modd>b then\n begin\n ok:=false;\n break;\n end;\n end;\n\n if ok then\n writeln(f2,2)\n else\n begin\n write(f2,1,' ');\n t:=i;\n while t<100000000 do\n begin\n write(f2,0);\n t:=t*10;\n end;\n write(f2,i);\n end;\n\n end;\n\n begin\n\n mof;\n nhap;\n work;\n dongf;\n\n end.\n\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n\nfunction make(y : integer) : string;\nvar\n s,s1 : string;\n i : integer;\nbegin\n s := inttostr(y);\n s1 := '';\n for i := 1 to 9 - length(s) do s1 := s1 + '0';\n make := s1 + s;\nend;\n\nfunction min(x,y : integer) : integer;\nbegin\n if x < y then min := x\n else min := y;\nend;\nvar\n a,b,m,i :integer;\n p,e : int64;\n\nbegin\n read(a,b,m);\n e := 1000000000;\n for i := 1 to min(a,1000000) do begin\n p := i;\n p := p*e mod m;\n if (m - p > b) and (p > 0) then begin\n writeln(1);\n write(make(i));\n halt;\n end;\n end;\n write(2);\nend.\n"}, {"source_code": "uses math;\n\nvar a,b,md,i,x\t\t\t: longint;\n\nbegin\n\tread(a,b,md);\n\n\tfor i := 1 to min(a, md) do begin\n\t\tx := (int64(i) * 1000000000) mod md;\n\t\tif md - x > b then begin\n\t\t\twrite('1 ');\n\t\t\tif i < 100000000 then write(0);\n\t\t\tif i < 10000000 then write(0);\n\t\t\tif i < 1000000 then write(0);\n\t\t\tif i < 100000 then write(0);\n\t\t\tif i < 10000 then write(0);\n\t\t\tif i < 1000 then write(0);\n\t\t\tif i < 100 then write(0);\n\t\t\tif i < 10 then write(0);\n\t\t\twrite(i);\n\t\t\thalt(0);\n end;\n end;\n\n writeln(2);\nend."}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q mod c;\n q:=q*1000000000;\n q:=q mod c;\n if q>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "var k,i,j,a,b,modd,l:longint;\n\n function min(a,b:longint):longint;\n begin\n if a>b then min:=b else min:=a;\n end;\n procedure print(x:longint);\n var s:string;\n begin\n write(1,' ');\n str(x,s);\n while length(s)<>9 do\n s:='0'+s;\n write(s);\n end;\n\n begin\n readln(a,b,modd);\n l:=1000000000 mod modd;\n for i:=1 to min(modd,a) do\n begin\n k:=((i mod modd)*l) mod modd;\n if (k<>0) and (k+b=m) then\n writeln(2)\n else\n writeln('1 000000001');\nend."}, {"source_code": "var t,i,a,b,mo,ost:longint;\n\nprocedure ch(a:longint);\nvar b,j,i:longint;\nbegin\ni:=0;\nb:=a;\nwhile b>0 do\nbegin\nb:=b div 10;\ninc(i);\nend;\nwrite(1,' ');\nfor j:=1 to 9-i do\nwrite(0);\nwrite(a);\nend;\n\nbegin\nreadln(a,b,mo);\nif b>=mo then begin\nwrite(2);\nhalt;\nend;\nost:=1000000000 mod mo;\nt:=ost;\nwhile (((mo-ost)<=b)or(ost=0))and(ib)and(ost<>0) then ch(i+1)\nelse\nwrite(2);\nend.\n"}, {"source_code": "{$R+} {$Q+} {$O-}\nprogram Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, m: longint;\n s, f, t, tt, i, ttt: longint;\n\nbegin\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n }\n readln(n, m);\n\n for i := 1 to n do begin\n readln(s, f, t);\n tt := t;\n if s = f then\n writeln(t)\n else begin\n t := t mod (m * 2 - 2);\n\n if s < f then begin\n if t < s then\n writeln(tt - t + f - 1)\n else\n writeln(tt - t + 2 * m - 2 + f - 1);\n end else begin\n s := (m - s) + m;\n f := (m - f) + m;\n\n if t < s then begin\n writeln(tt - t + f - 1);\n end else begin\n writeln(tt - t + 2 * m - 2 + f - 1);\n end;\n end;\n end;\n end;\n\n {closefile(input);\n closefile(output);\n }\nend.\n"}, {"source_code": "Uses math;\nvar f1,f2:text;\na,b,smod,x:int64;\ni,val:longint;\n\nProcedure Process;\nvar i:longint;\nst:string;\ncanwin:boolean;\nBegin\n canwin:=false;\n For i:=1 to min(a,smod) do\n Begin\n x:=int64(i)*1000000000 mod smod;\n if smod-x<=b then continue;\n x:=i mod smod;\n if smod-x<=b then continue;\n canwin:=true;\n if val=0 then\n val:=i;\n End;\n if canwin=true then\n Begin\n str(val,st);\n While length(st)<9 do st:='0'+st;\n writeln(f2,1,' ',st);\n End\n else\n Writeln(f2,2);\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,smod);\n process;\n close(F1);\n close(f2);\nEnd.\n"}, {"source_code": "program Project2;\nUses math;\nvar v,a,b,mo,k,e:Integer;\nm:array [1..10] of integer;\nj,i:integer;\nbegin\n// Assign(input,'input.txt');\n// Assign(Output,'output.txt');\n Readln(a,b,mo);\n v:=1000000000 mod mo;\n for i:=0 to Min(mo,a) do\n begin\n e:=i;\n e:=((i mod mo)*v)mod mo;\n if (mo-e) mod mo>b\n then begin\n Write(1,' ');\n j:=0;\n e:=i;\n while e<>0 do\n begin\n inc(j);\n m[j]:=e mod 10;\n e:=e div 10;\n end;\n for j:=9 downto 1 do\n write(m[j]);\n Halt;\n end;\n end;\n Writeln(2);\nend.\n"}, {"source_code": "var\n temp,k,a,b,m:int64;\n i:longint;\n vis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n min:=a; if (a>b) then exit(b);\nend; \n \nbegin\n readln(a,b,m);\n if (b>=m-1) then writeln(2)\n else\n begin\n k:=1;\n for i:=1 to m do\n begin\n if (k>a) then begin writeln(2); exit; end;\n if (m-(k*1000000000 mod m)>b) then break;\n if (vis[m-(k*1000000000 mod m)]) then break;\n if ((m-(k*1000000000) mod m=m)) then \n begin\n inc(k);\n continue;\n end;\n vis[m-(k*1000000000 mod m)]:=true;\n k:=(k+1) mod m;\n end;\n write(1,' '); temp:=k;\n for i:=1 to 9-trunc(ln(temp)/ln(10))-1 do\n begin\n write(0);\n end;\n writeln(temp);\n end;\nend."}, {"source_code": "const\n{ fi='game.inp';\n fo='game.out';}\n fi='';\n fo='';\n maxn=1;\n\nvar\n f:text;\n a:array[0..maxn]of longint;\n n,x,y:longint;\n ss:string;\n\nfunction maxx(x,y:longint):longint;\nbegin\n maxx:=x;\n if y>x then maxx:=y;\nend;\n\nfunction minn(x,y:longint):longint;\nbegin\n minn:=x;\n if y=r then exit;\n i:=l;j:=r;\n mid:=a[(l+r) div 2];\n repeat\n while a[i]mid do dec(j);\n if i<=j then\n begin\n swap(a[i],a[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n qsort(l,j);\n qsort(i,r);\nend;\n\nprocedure open;\nvar i:longint;\nbegin\n assign(f,fi);reset(f);\n readln(f,x,y,n);\n close(f);\nend;\n\nfunction tinh:longint;\nvar i,kq,s,j:longint;\nbegin\n i:=trunc(1e9) mod n;\n if y>=n then exit(2);\n for j:=0 to minn(x,n) do\n begin\n s:=(n-((j+i) mod n)+1) mod n;\n if j=0 then s:=0;\n if s>y then\n begin\n str(j,ss);\n while length(ss)<9 do ss:='0'+ss;\n exit(1);\n end;\n end;\n exit(2);\nend;\n\nprocedure main;\nvar tmp:longint;\nbegin\n tmp:=tinh;\n assign(f,fo);rewrite(f);\n write(f,tmp,' ');\n if tmp=1 then writeln(f,ss);\n close(f);\nend;\n\nbegin\n open;\n main;\nend.\n"}, {"source_code": "var\ni,j:longint;\nx,a,b,p:longint;\ns:array[0..10]of int64;\ny:double;\nfunction min(a,b:int64):int64;\nbegin\nif ax)and(j>1) do\n begin\n write(0);\n dec(j);\n end;\n writeln(x);\n halt;\n end;\n end;\nwriteln(2);\n\nend."}, {"source_code": " uses\n SysUtils,math;\n var a,b,j,m,i,count:integer; mn,c:int64;\n st:string;\nbegin\nreadln(a,b,m);\nmn:=1000000000 mod m;\nfor i:=1 to m-1 do begin\nc:=i*mn mod m;\nif i>a then break;\nif (c=0) or (i>a) then continue;\nif ca then break;\nif (c=0) or (i>a) then continue;\nif cb then min:=b else min:=a;\n end;\n procedure print(x:longint);\n var s:string;\n begin\n write(1,' ');\n str(x,s);\n while length(s)<>9 do\n s:='0'+s;\n write(s);\n end;\n\n begin\n readln(a,b,modd);\n l:=1000000000 mod modd;\n for i:=1 to min(modd,a) do\n begin\n k:=((i mod modd)*l) mod modd;\n if (k<>0) and (k+ba) then continue;\nif ca) then continue;\nif c=m then begin writeln(2); exit end; \n a:=a mod m;\n for i:=0 to a do begin\n t:=(int64(i)*k) mod m;\n if (m-t) mod m>b then begin\n write(1,' ');\n a:=i; k:=0; repeat inc(k); a:=a div 10 until a=0;\n for t:=1 to 9-k do write(0);\n writeln(i);\n exit;\n end;\n end;\n writeln(2);\nend."}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n if (i + b < c) then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s);\n exit;\n end;\n break;\n end;\n end;\n writeln( 2 );\nEND.\n\n"}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if (c-q)>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "var a,b,md,i:longint;\n\nfunction min(md,a:longint):longint;\nbegin\n if md>a then min:=a else min:=md;\nend;\n\nprocedure print(i:longint);\nvar s:string;\nbegin\n str(i,s);\n while length(s)<>9 do\n s:='0'+s;\n writeln(1,' ',s);\n halt;\nend;\n\nfunction fun(ver:int64):boolean;\nvar ans:int64;\nbegin\n ans:=(ver*1000000000) mod md;\n if (ans<>0) and (Ans+b<=md) then\nfun:=true else fun:=false;\nend;\n\n\n\n\nbegin\n readln(a,b,md);\n for i:= 0 to min(md,a) do\n if fun(i) then\n print(i);\n\n\n writeln(2);\nend.\n"}, {"source_code": "var\ni,j:longint;\nx,a,b,p,tot:longint;\ns:array[0..10]of int64;\ny:double;\nfunction min(a,b:int64):int64;\nbegin\nif ax)and(j>1) do\n begin\n write(0);\n dec(j);\n end;\n writeln(x);\n halt;\n end;\n inc(tot);\n if tot=p then break;\n end;\nwriteln(2);\n\nend."}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if (c-q)>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n b, i, j, modn, modd, a: longint;\n ii: int64;\n ss: string;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n\n readln(a, b, modn);\n\n for i := 1 to min(a, modn) do begin\n ii := 1000000000 * i;\n modd := ii mod modn;\n if modd + b < modn then begin\n ss := inttostr(i);\n write('1 ');\n for j := 1 to 9 - length(ss) do\n write(0); \n write(i);\n halt(0);\n end;\n end;\n\n writeln(2);\n\n //closefile(input);\n //closefile(output);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$MAXSTACKSIZE $10000000}\n{$MODE DELPHI}\n{$R-,Q-,O+,S+}\nuses\n Math, SysUtils;\nvar\n q, l, i, j, a, b, m : longint;\n p : int64;\n s : string;\nbegin\n// Reset(input, 'input.txt');\n// Rewrite(output, 'output.txt');\n readln(a, b, m);\n q := 1000000000 mod m;\n l := min(a, m);\n for i := 0 to l do\n begin\n p := (q * i) mod m;\n if p = 0 then\n p := m;\n if m - p > b then\n begin\n s := inttostr(i);\n write(1, ' ');\n for j := 1 to 9 - Length(s) do\n write('0');\n Writeln(s);\n exit;\n end;\n end;\n writeln(2);\nend.\n"}, {"source_code": "var a,b,m:longint;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\n if (b>=m) then\n writeln(2)\n else\n writeln('1 000000001');\nend."}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n\tmin:=a; if (a>b) then exit(b);\nend;\t\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=1;\n\t\tfor i:=1 to a do\n\t\tbegin\n\t\t\tif (vis[m-(k*1000000000 mod m)]) or (k=0) then break;\n\t\t\tvis[m-(k*1000000000 mod m)]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=m downto b+1 do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=b+1) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=m-i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": "var a,b,m,i:longint;\nlabel 1;\nbegin\nreadln(a,b,m);\nif (a=0) or (m=1) then\n writeln(2)\nelse\nbegin\n for i:=1000000000 to (1000000000+b) do\n if ((i mod m)=0) then begin\n writeln(2); goto 1;end;\n writeln('1 000000001');\n end;\n1: end.\n"}, {"source_code": " uses sysutils;\n var z,x,c,w,i,r:longint;\n q:int64;\n begin\n readln(z,x,c);\n if z>c then\n r:=c\n else\n r:=z;\n for w:=1 to r do begin\n q:=w;\n q:=q*1000000000;\n q:=q mod c;\n if q>x then begin\n write(1,' ');\n for i:=1 to 9 - length(IntToStr(w)) do\n write(0);\n write(w);\n halt(0);\n end;\n end;\n writeln(2);\n end.\n"}, {"source_code": "var\nbol:boolean;\nmas:array[-10..10000000]of longint;\nind,i,j,a,b,m,min:longint;\ns:string;\np,x:int64;\nbegin\nreadln(a,b,m);\nmin:=a;\nif m-1 b\n then\n begin\n s:='';\n ch:=i;\n while ch<>0 do\n begin\n str(ch mod 10,s1);\n ch:=ch div 10;\n s:=s1+s;\n end;\n while length(s) <> 9 do s:='0'+s;\n s:='1 '+s;\n writeln(s);\n halt;\n end;\n end;\n writeln(2);\n\nEnd."}, {"source_code": "uses math;\n\nconst fi='';//117b.inp';\n fo='';//117b.out';\n maxn=10000100;\nvar du_b:array[0..maxn] of boolean;\n n,a,b,m,nn:longint;\n re:string;\n ok:boolean;\n f:text;\n\nprocedure nhap;\nbegin\n assign(f,fi); reseT(f);\n readln(f,a,b,m);\n close(f);\nend;\n\n\nprocedure khoitao;\nvar i:longint;\nbegin\n nn:=1000000000 mod m;\n for i:=0 to b do\n du_b[i]:=true;\nend;\n\n\nprocedure work;\nvar s:longint;\nbegin\n s:=0;\n ok:=false;\n while s<=min(a,m) do\n begin\n if not du_b[(m-(nn*s) mod m+m) mod m] then\n begin\n str(s,re);\n ok:=true;\n exit;\n end;\n inc(s);\n end;\nend;\n\n\nprocedure inkq;\nbegin\n assign(f,fo); rewrite(f);\n if b>=m then writeln(f,2)\n else\n begin\n khoitao;\n work;\n if ok then\n begin\n while length(re)<9 do re:='0'+re;\n write(f,1,' ',re);\n end\n else writeln(f,2);\n end;\n close(f);\nend;\n\n\nbegin\n nhap;\n inkq;\nend."}, {"source_code": "Const\n Fi = '117B.inp';\n Fo = '117B.out';\n\n\nVar\n F : Text;\n A, B, k,i : Longint;\n Res, cs, tg : Longint;\n m, j: Int64;\n\n\nBEGIN\n Readln(A, b, k);\n If k=1 then Begin Writeln(2); Exit; End;\n If b>=k then Begin Writeln(2); Exit; End;\n If a+b 0) do begin\n write('0');\n dec(k);\n end;\n writeln(s);\n halt(0);\n end;\n end;\n writeln(2);\n end;\n halt(0);\nend.\n"}, {"source_code": "var\n\ttemp,k,a,b,m:int64;\n\ti:longint;\n\tvis:array[0..10000000] of boolean;\n\nfunction min(a,b:longint):longint;\nbegin\n\tmin:=a; if (a>b) then exit(b);\nend;\t\n\t\nbegin\n\treadln(a,b,m);\n\tif (b>=m-1) then writeln(2)\n\telse\n\tbegin\n\t\tk:=1;\n\t\tfor i:=1 to a do\n\t\tbegin\n\t\t\tif (vis[m-(k*1000000000 mod m)]) then break;\n\t\t\tif ((m-(k*1000000000) mod m=0)) then continue;\n\t\t\tvis[m-(k*1000000000 mod m)]:=true;\n\t\t\tk:=(k+1) mod m;\n\t\tend;\n\t\tfor i:=m downto b+1 do\n\t\tbegin\n\t\t\tif (vis[i]) then break;\n\t\t\tif (i=b+1) then\n\t\t\tbegin\n\t\t\t\twriteln(2);\n\t\t\t\texit;\n\t\t\tend;\n\t\tend;\n\t\twrite(1,' '); temp:=m-i;\n\t\tfor i:=1 to 9-trunc(ln(i)/ln(10))-1 do\n\t\tbegin\n\t\t\twrite(0);\n\t\tend;\n\t\twriteln(temp);\n\tend;\nend."}, {"source_code": "\nuses\n math;\n\nvar\n a, b, c, t, d : int64;\n i : longint;\n s : string;\n\nBEGIN\n readln(a, b, c);\n if(c = 1)or(b>=c)then\n begin\n writeln( 2 );\n exit;\n end;\n\n t := 1000000000 mod c;\n if b = 0 then\n begin\n if a = 0 then\n begin\n writeln(2);\n exit;\n end;\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n begin\n str(i, s);\n while length(s) < 9 do s := '0' + s;\n writeln(1,' ',s );\n exit;\n end;\n end;\n\n d := 10000001;\n s := '';\n if b < c then\n begin\n for i := 1 to min(a,c) do if (t*i) mod c <> 0 then\n if d > ((t*i)mod c) then\n begin\n d := (t*i) mod c;\n str(i, s);\n end;\n end;\n while length(s) < 9 do s := '0' + s;\n if d + b < c then writeln(1,' ',s)\n else writeln( 2 );\nEND.\n\n"}, {"source_code": "var n,m,i,j,k,l,s,f,t:integer;\na,b,c,d,e:integer;\ni1,k1:int64;\nbegin\nread(a,b,m);\nd:=1000000000;\nif d mod m =0 then begin writeln(2);exit;end;\nk1:=d mod m;\nfor i:=1 to 10000000 do\n begin\ni1:=i;\nl:=(i1*k1)mod m;\nif l<>0 then l:=m-l;\nif l>b then\n begin\nwrite(1,' ');\ns:=i;\nf:=0;\nwhile s<>0 do\n begin\ninc(f);\ns:=s div 10;\n end;\nfor j:=1 to 9-f do write(0);\nwriteln(i);\nexit;\n end;\n end;\nwriteln(2);\n//readln;readln;\nend."}], "src_uid": "8b6f633802293202531264446d33fee5"} {"source_code": "var c,a,b,x,y,ans,v,tmp:int64;\nbegin\n readln(c,x,y,a,b);\n v:=0;\n while (v<=1000000) and (v*a<=c) do\n begin\n tmp:=x*v+y*((c-v*a) div b);\n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n v:=0;\n while (v<=1000000) and (v*b<=c) do\n begin\n tmp:=y*v+x*((c-v*b) div a); \n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n writeln(ans);\nend.", "positive_code": [{"source_code": "var i,c,hr,hb,wr,wb,v,cur,max:int64;\nbegin\n readln(c,hr,hb,wr,wb);\n while (v<=1000000) and (v*wr<=c) do\n begin\n cur:=hr*v+hb*((c-wr*v) div wb);\n if cur>max then max:=cur;\n inc(v);\n end;\n v:=0;\n while (v<=1000000) and (v*wb<=c) do\n begin\n cur:=hb*v+hr*((c-wb*v) div wr);\n if cur>max then max:=cur;\n inc(v);\n end;\n writeln(max);\nend."}, {"source_code": "uses math;\nvar\n t,ans,i,j,f1,f2,l,r,c1,c2,n,a1,b1,a2,b2:int64;\n\nfunction f(c:int64):int64;\nbegin\n f:=c*a1+(n-c*b1)div b2*a2;\nend;\n\nbegin\n readln(n,a1,a2,b1,b2);\n if(a1>=a2)and(b1<=b2)then\n begin\n writeln(n div b1*a1);\n halt;\n end;\n if(a1<=a2)and(b1>=b2)then\n begin\n writeln(n div b2*a2);\n halt;\n end;\n if b1>=sqrt(n)then\n begin\n i:=0;\n while i<=sqrt(n)do\n begin\n if i*b1>n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end else if b2>=sqrt(n)then\n begin\n t:=a1;a1:=a2;a2:=t;\n t:=b1;b1:=b2;b2:=t;\n i:=0;\n while i<=sqrt(n)do\n begin\n if i*b1>n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end;\n if a1/b1n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end else\n begin\n t:=a1;a1:=a2;a2:=t;\n t:=b1;b1:=b2;b2:=t;\n i:=0;\n while i<=sqrt(n)do\n begin\n if i*b1>n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end;\nend.\n\n\n\n\n\n"}, {"source_code": "program zad_C;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n c, wr, wb, hr, hb, res, num, num1 : int64;\n i : integer;\nfunction get(x : integer):int64;\n var\n w : int64;\n begin\n if(trunc(1.0 * x * wr) > c) then begin\n get := 0;\n exit;\n end;\n\n w := (c - trunc(1.0 * x * wr)) div wb;\n get := trunc(1.0 * x * hr) + trunc(1.0 * w * hb);\n end;\n\nfunction nod(a, b : int64):int64;\n var\n r : int64;\n begin\n repeat\n r := a mod b;\n a := b;\n b := r;\n until(b = 0);\n\n nod := a;\n end;\n\nfunction nok(a, b : int64):int64;\n begin\n nok := trunc(1.0 * (a div nod(a, b)) * b);\n end;\n\nprocedure swap(var a, b : int64);\n var\n c : int64;\n begin\n c := a;\n a := b;\n b := c;\n end;\nbegin\n readln(c, hr, hb, wr, wb);\n\n if(wb > wr) then begin\n swap(wr, wb);\n swap(hr, hb);\n end;\n\n num := nok(wr, wb);\n num1 := max(trunc(1.0 * hr * (num div wr)), trunc(1.0 * hb * (num div wb)));\n res := trunc(1.0 * max(0, (c div num) - 1) * num1);\n\n c := min(c, (c mod num) + num);\n\n num := 0;\n for i := 0 to c div wr do\n num := max(num, get(i));\n\n writeln(res + num);\n\n readln(c);\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n tempSize : Int64;\n tempCount : Int64;\n SwapTemp : Int64;\n\n\n i : Int64;\n TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n \n if ( SizeRed < SizeBlue ) then\n begin\n SwapTemp := SizeRed;\n SizeRed := SizeBlue;\n SizeBlue := SwapTemp;\n \n SwapTemp := HappyRed;\n HappyRed := HappyBlue;\n HappyBlue := SwapTemp;\n end;\n \n tempSize := SizeRed * SizeBlue ;\n if ( MaxSize >= tempSize * 2 ) then\n begin\n\n\n tempCount := MaxSize div tempSize-1;\n Ans := Max ( SizeBlue * HappyRed , SizeRed * HappyBlue ) * tempCount ;\n MaxSize := MaxSize - tempCount * tempSize;\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n halt;\n end;\n\n end;\n \n\n I := 0 ;\n MaxBrute := 0;\n\n\n while ( I*SizeRed <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n tempCount := tempSize div SizeBlue;\n \n TempBrute := I*HappyRed + tempCount*HappyBlue;\n if ( TempBrute > MaxBrute ) then\n MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n\n writeLn ( Ans + Max(TempBrute,MaxBrute) ) ;\n\nend."}, {"source_code": "const eps=0.00000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var h,kol,t,p,sum,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n pp1,pp2,mask1,mask2,mask,newnapy,napx,napy,time,pp,step, k,t1,i,tt,j:longint;\n aa,bb,cc,dd:longint;\n x,y,fact,d,c,aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n sot:array [-10..1000000] of char;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n ddp, pole :array [-100..2000,-100..2000] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ugol1(t:longint):extended;\nbegin ugol1:=t/120; end;\n\nfunction ugol2(t:longint):extended;\nbegin ugol2:=(t mod 3600)/10; end;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(cc,y[1],y[2],x[1],x[2]);\n if x[1]>x[2] then begin t:=x[2];x[2]:=x[1]; x[1]:=t; t:=y[2];y[2]:=y[1];y[1]:=t; end;\n if y[1]*x[2]=x[1]*y[2] then\n begin\n t:=nod(x[1],x[2]);\n if x[2]>100 then\n begin\n q:=cc div x[2]; ot:=0;\n for i:=0 to q do\n begin\n z:=i; p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n end else ot:=round((cc div t)*t*y[2]/x[2]);\n\n\n writeln(ot);\n goto 1;\n end;\n if y[1]*x[2]x[1]*y[2] then\n begin\n\n ot:=0;\n t:=cc div x[1];\n q:=min(5000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n\n\n\n\n\n\n\n end;\n\n t:=x[2];x[2]:=x[1];x[1]:=t; t:=y[2];y[2]:=y[1];y[1]:=t;\n\n begin\n\n t:=cc div x[1];\n q:=min(5000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n\n\n\n\n\n writeln(ot);\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb: int64;\ni,c: longint;\nans,thisans,mult1,mult2: int64;\n\nprocedure swap(var a,b: int64);\nvar c: int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if wr > c then begin\n write((c div wb) * hb);\n halt;\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) do begin\n mult1 := min(c div wb, i);\n mult2 := (c - wb*i) div wr;\n thisans := hb*mult1 + hr*mult2;\n ans := max(ans,thisans);\n end;\n\n for i:=0 to trunc(sqrt(c)) do begin\n mult1 := min(c div wr, i);\n mult2 := (c - wr*i) div wb;\n thisans := hr*mult1 + hb*mult2;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\n\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a) else exit(gcd(b,a mod b));\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i*wr) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b,aa,bb,d:int64;\n i:longint;\nbegin\n\tans:=0;\n aa:=wr;bb:=wb;\n for i:=0 to wr-1 do\n\tbegin\n tem:=gcd(gcd(aa,bb),(c-i));\n a:=aa div tem;b:=bb div tem;\n d:=ex_Euclid(a,b,x,y);\n x:=x*(c-i) div tem;y:=y*(c-i) div tem;\n if x mod d<>0 then continue;\n if y mod d<>0 then continue;\n x:=x div d;y:=y div d;\n\t if x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif (x<0)or(y<0) then continue;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n if (x>=0)and(y>=0) then ans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\t//assign(output,'dp.out');rewrite(output);\n\treadln(c,hr,hb,wr,wb);\n\tif wr>sqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "{$B-} \n{$INLINE ON}\n{$MODE OBJFPC}\nuses math;\nconst finp = '';\n fout = '';\n maxn = 1000;\nvar fi,fo : text;\n C,ha,hb,wa,wb,ans,t : int64;\nbegin\n assign(fi,finp); reset(fi);\n assign(fo,fout); rewrite(fo);\n readln(fi,C,ha,hb,wa,wb);\n ans:=0;\n t:=0;\n while (t<=1000000) and (wa*t<=c) do begin\n ans:=max(ans,ha*t+((c-wa*t) div wb)*hb);\n inc(t);\n end;\n t:=0;\n while (t<=1000000) and (wb*t<=c) do begin\n ans:=max(ans,((c-wb*t) div wa)*ha+hb*t);\n inc(t);\n end;\n writeln(fo,ans);\n close(fi); close(fo);\nend.\n"}, {"source_code": "var c,a,b,x,y,ans,v,tmp:int64;\nbegin\n readln(c,x,y,a,b);\n v:=0;\n while (v<=1000000) and (v*a<=c) do\n begin\n tmp:=x*v+y*((c-v*a) div b);\n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n v:=0;\n while (v<=1000000) and (v*b<=c) do\n begin\n tmp:=y*v+x*((c-v*b) div a); \n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n writeln(ans);\nend."}, {"source_code": "var c,a,b,x,y,ans,v,tmp:int64;\nbegin\n readln(c,x,y,a,b);\n v:=0;\n while (v<=1000000) and (v*a<=c) do\n begin\n tmp:=x*v+y*((c-v*a) div b);\n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n v:=0;\n while (v<=1000000) and (v*b<=c) do\n begin\n tmp:=y*v+x*((c-v*b) div a); \n if tmp>ans then ans:=tmp;\n inc(v);\n end;\n writeln(ans);\nend."}, {"source_code": "var\n i,j:longint;\n s,c,hr,hb,wr,wb,x:int64;\nfunction min(a,b:int64):int64;\n begin\n if ac then\n begin\n writeln(c div wb*hb);\n halt;\n end;\n if wb>c then\n begin\n writeln(c div wr*hr);\n halt;\n end;\n if wr*hb>wb*hr then\n begin\n x:=hr; hr:=hb; hb:=x;\n x:=wr; wr:=wb; wb:=x;\n end;\n if c div wrs then s:=i*hr+j*hb;\n end;\n writeln(s);\n halt;\n end;\n for i:=min(wr-1,c div wb) downto 0 do\n begin\n j:=(c-i*wb) div wr;\n if i*hb+j*hr>s then s:=i*hb+j*hr;\n end;\n writeln(s);\nend."}, {"source_code": "program problem3;\n\nfunction gcd( a, b: int64 ): int64;\nvar\tc: int64;\nbegin\n\twhile ( b > 0 ) do\n\tbegin\n\t\tc := b;\n\t\tb := a mod b;\n\t\ta := c;\n\tend;\n\t\n\texit( a );\nend;\n\nvar\tc, hr, hb, wr, wb, lcm, ans, best, cur: int64;\n\ti: longInt;\n\nbegin\n\treadln( c, hr, hb, wr, wb );\n\t\n\tlcm := ( wr * wb ) div gcd( wr, wb );\n\t\n\tans := 0;\n\tif ( c div lcm >= 2 ) then\n\tbegin\n\t\tif ( hr * wb > hb * wr ) then\n\t\t\tans := ( c div lcm - 1 ) * ( lcm div wr ) * hr\n\t\telse\n\t\t\tans := ( c div lcm - 1 ) * ( lcm div wb ) * hb;\n\t\t\n\t\tc := lcm + ( c mod lcm );\n\tend;\n\t\n\tif ( wr < wb ) then\n\tbegin\n\t\twb := wb xor wr;\n\t\twr := wb xor wr;\n\t\twb := wb xor wr;\n\t\t\n\t\thb := hb xor hr;\n\t\thr := hb xor hr;\n\t\thb := hb xor hr;\n\tend;\n\t\n\tbest := 0;\n\tfor i := 0 to longInt(c div wr) do\n\tbegin\n\t\tcur := hr * i + hb * ( ( c - i * wr ) div wb );\n\t\t\n\t\tif ( cur > best ) then\n\t\t\tbest := cur;\n\tend;\n\t\n\twriteln( ans + best );\nend.\n"}, {"source_code": "uses math;\nvar c,hr,hb,wr,wb,ans,pomoc,p:int64;\n i:longint;\n begin\n read(c,hr,hb,wr,wb);\n if max(wr,wb)>=100 then\n begin\n if max(wr,wb)=wr then\n begin\n for i:=0 to c div wr do\n begin\n pomoc:=i;\n ans:=max(ans,pomoc*hr+((c-wr*pomoc) div wb)*hb);\n end;\n writeln(ans);\n end\n else\n begin\n for i:=0 to c div wb do\n begin\n pomoc:=i;\n ans:=max(ans,pomoc*hb+((c-wb*pomoc) div wr)*hr);\n end;\n writeln(ans);\n end;\n end\n else\n begin\n p:=wr*wb;\n if hr/wr>hb/wb then\n begin\n for i:=0 to p do\n begin\n pomoc:=i;\n if c-pomoc*wb>=0 then\n ans:=max(ans,pomoc*hb+((c-pomoc*wb) div wr)*hr);\n end;\n writeln(ans);\n end\n else\n begin\n for i:=0 to p do\n begin\n pomoc:=i;\n if c-pomoc*wr>=0 then\n ans:=max(ans,pomoc*hr+((c-pomoc*wr) div wb)*hb);\n end;\n writeln(ans) ;\n end;\n end;\n end.\n\n\n\n"}], "negative_code": [{"source_code": "uses math;\nvar\n t,ans,i,j,f1,f2,l,r,c1,c2,n,a1,b1,a2,b2:int64;\n\nfunction f(c:int64):int64;\nbegin\n f:=c*a1+(n-c*b1)div b2*a2;\nend;\n\nbegin\n readln(n,a1,a2,b1,b2);\n if(a1<=a2)and(b1>=b2)then\n begin\n writeln(n div b1*a1);\n halt;\n end;\n if(a1>=a2)and(b1<=b2)then\n begin\n writeln(n div b2*a2);\n halt;\n end;\n if(b1>=sqrt(n))or(a1/b1n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end else\n begin\n t:=a1;a1:=a2;a2:=t;\n t:=b1;b1:=b2;b2:=t;\n i:=0;\n while i<=sqrt(n)do\n begin\n if i*b1>n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end;\nend.\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar\n t,ans,i,j,f1,f2,l,r,c1,c2,n,a1,b1,a2,b2:int64;\n\nfunction f(c:int64):int64;\nbegin\n f:=c*a1+(n-c*b1)div b2*a2;\nend;\n\nbegin\n readln(n,a1,a2,b1,b2);\n if(a1>=a2)and(b1<=b2)then\n begin\n writeln(n div b1*a1);\n halt;\n end;\n if(a1<=a2)and(b1>=b2)then\n begin\n writeln(n div b2*a2);\n halt;\n end;\n if(b1>=sqrt(n))or(a1/b1n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end else\n begin\n t:=a1;a1:=a2;a2:=t;\n t:=b1;b1:=b2;b2:=t;\n i:=0;\n while i<=sqrt(n)do\n begin\n if i*b1>n then break;\n ans:=max(ans,f(i));\n inc(i);\n end;\n writeln(ans);halt;\n end;\nend.\n\n\n\n\n\n"}, {"source_code": "uses math;\nvar\n ans,i,j,f1,f2,l,r,c1,c2,n,a1,b1,a2,b2:int64;\n\nfunction f(c:int64):int64;\nbegin\n f:=c*a1+(n-c*b1)div b2*a2;\nend;\n\nbegin\n readln(n,a1,a2,b1,b2);\n if(a1<=a2)and(b1>=b2)then\n begin\n writeln(n div b1*a1);\n halt;\n end;\n if(a1>=a2)and(b1<=b2)then\n begin\n writeln(n div b2*a2);\n halt;\n end;\n l:=0;r:=n div b1;\n while r-l>1 do\n begin\n c1:=(l*2+r)div 3;\n c2:=(l+r*2)div 3;\n f1:=f(c1);f2:=f(c2);\n if f(c1)=b2)then\n begin\n writeln(n div b1*a1);\n halt;\n end;\n if(a1>=a2)and(b1<=b2)then\n begin\n writeln(n div b2*a2);\n halt;\n end;\n l:=0;r:=n div b1;\n while r-l>1 do\n begin\n c1:=(l*2+r)div 3;\n c2:=(l+r*2)div 3;\n if f(c1)0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ugol1(t:longint):extended;\nbegin ugol1:=t/120; end;\n\nfunction ugol2(t:longint):extended;\nbegin ugol2:=(t mod 3600)/10; end;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(cc,y[1],y[2],x[1],x[2]);\n if x[1]>x[2] then begin t:=x[2];x[2]:=x[1]; x[1]:=t; t:=y[2];y[2]:=y[1];y[1]:=t; end;\n if y[1]*x[2]=x[1]*y[2] then\n begin\n t:=nod(x[1],x[2]);\n if x[2]>100 then\n begin\n q:=cc div x[2]; ot:=0;\n for i:=0 to q do\n begin\n z:=i; p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n end else ot:=round((cc div t)*t*y[2]/x[2]);\n\n\n writeln(ot);\n goto 1;\n end;\n if y[1]*x[2]x[1]*y[2] then\n begin\n ot:=0;\n t:=cc div x[1];\n q:=min(10000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n writeln(ot);\n\n\n end;\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "\n const eps=0.00000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var h,kol,t,p,sum,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n pp1,pp2,mask1,mask2,mask,newnapy,napx,napy,time,pp,step, k,t1,i,tt,j:longint;\n aa,bb,cc,dd:longint;\n x,y,fact,d,c,aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n sot:array [-10..1000000] of char;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n ddp, pole :array [-100..2000,-100..2000] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ugol1(t:longint):extended;\nbegin ugol1:=t/120; end;\n\nfunction ugol2(t:longint):extended;\nbegin ugol2:=(t mod 3600)/10; end;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(cc,y[1],y[2],x[1],x[2]);\n if x[1]>x[2] then begin t:=x[2];x[2]:=x[1]; x[1]:=t; end;\n if y[1]*x[2]=x[1]*y[2] then\n begin\n t:=nod(x[1],x[2]);\n if x[2]>100 then\n begin\n q:=cc div x[2]; ot:=0;\n for i:=0 to q do\n begin\n z:=i; p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n end else ot:=round((cc div t)*t*y[2]/x[2]);\n\n\n writeln(ot);\n goto 1;\n end;\n if y[1]*x[2]x[1]*y[2] then\n begin\n ot:=0;\n t:=cc div x[1];\n q:=min(30000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n writeln(ot);\n\n\n end;\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "const eps=0.00000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var h,kol,t,p,sum,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n pp1,pp2,mask1,mask2,mask,newnapy,napx,napy,time,pp,step, k,t1,i,tt,j:longint;\n aa,bb,cc,dd:longint;\n x,y,fact,d,c,aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n sot:array [-10..1000000] of char;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n ddp, pole :array [-100..2000,-100..2000] of int64;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction ugol1(t:longint):extended;\nbegin ugol1:=t/120; end;\n\nfunction ugol2(t:longint):extended;\nbegin ugol2:=(t mod 3600)/10; end;\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(cc,y[1],y[2],x[1],x[2]);\n if x[1]>x[2] then begin t:=x[2];x[2]:=x[1]; x[1]:=t; t:=y[2];y[2]:=y[1];y[1]:=t; end;\n if y[1]*x[2]=x[1]*y[2] then\n begin\n t:=nod(x[1],x[2]);\n if x[2]>100 then\n begin\n q:=cc div x[2]; ot:=0;\n for i:=0 to q do\n begin\n z:=i; p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n end else ot:=round((cc div t)*t*y[2]/x[2]);\n\n\n writeln(ot);\n goto 1;\n end;\n if y[1]*x[2]x[1]*y[2] then\n begin\n\n ot:=0;\n t:=cc div x[1];\n q:=min(5000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n\n\n\n\n\n\n\n end;\n\n t:=x[2];x[2]:=x[1];x[1]:=t; t:=y[2];y[2]:=y[1];y[1]:=t;\n\n begin\n\n ot:=0;\n t:=cc div x[1];\n q:=min(5000000,cc div x[2]);\n for i:=0 to q do\n begin\n z:=i;\n p:=(cc-z*x[2]) div x[1];\n ot:=max(ot,p*y[1]+z*y[2]);\n\n end;\n\n\n\n\n\n writeln(ot);\n\n\n end;\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$B-}\n{$INLINE ON}\n{$MODE OBJFPC}\nuses math;\nconst finp = '';\n fout = '';\n maxn = 1000;\nvar fi,fo : text;\n C,ha,hb,wa,wb,ans,w : int64;\n i : longint;\nbegin\n assign(fi,finp); reset(fi);\n assign(fo,fout); rewrite(fo);\n readln(fi,C,ha,hb,wa,wb);\n if Cans then ans:=w;\n end;\n writeln(fo,ans);\n end;\n close(fi); close(fo);\nend.\n"}, {"source_code": "var c,a,b,x,y,k,ans,t,v,tmp,ans1:int64;\n\nfunction max(p,q:int64):int64;\nbegin\n if pb then\n begin\n v:=0;\n while v*a<=t do\n begin\n tmp:=x*v+y*((t-v*a) div b);\n if tmp>ans1 then ans1:=tmp;\n inc(v);\n end;\n end else\n begin\n v:=0;\n while v*b<=t do\n begin\n tmp:=y*v+x*((t-v*b) div a); \n if tmp>ans1 then ans1:=tmp;\n inc(v);\n end;\n end;\n writeln(ans+ans1);\nend."}, {"source_code": "var\n s,c,hr,hb,wr,wb,x,i,j:longint;\nbegin\n readln(c,hr,hb,wr,wb);\n s:=0;\n if wrs then s:=i*hr+j*hb;\n end;\n writeln(s);\nend."}, {"source_code": "var\n i,j:longint;\n s,c,hr,hb,wr,wb,x:int64;\nbegin\n readln(c,hr,hb,wr,wb);\n s:=0;\n if wr*hb>wb*hr then\n begin\n x:=hr; hr:=hb; hb:=x;\n x:=wr; wr:=wb; wb:=x;\n end;\n for i:=wr-1 downto 0 do\n begin\n j:=(c-i*wb) div wr;\n if i*hb+j*hr>s then s:=i*hb+j*hr;\n end;\n writeln(s);\nend."}, {"source_code": "Program Main;\n Uses MATH;\n var MaxVes , Gives1 , Gives2 , Ves1 , Ves2 : Int64;\n temp : LongInt;\n\t\n\t Ans : LongInt;\n\t\n\t I : LongInt;\n\t MaxHappynes , tempHappynes : LongInt;\nbegin\n Ans := 0;\n MaxHappynes := 0;\n readLn ( MaxVes , Gives1 , Gives2 , Ves1 , Ves2 ) ;\n temp := Ves1 * Ves2 ;\n\n if ( MaxVes >= temp ) then\n begin\n Ans := Max ( Ves2*Gives1 , Ves1*Gives2 ) * (MaxVes div temp) ;\n\tMaxVes := MaxVes mod temp;\n end;\n\n\n if ( MaxVes <> 0 ) then\n begin\n i := 0 ;\n\twhile ( TRUE ) do\n\tbegin\n\t if ( i*Ves1 > MaxVes ) then\n\t break;\n\t temp := MaxVes - i*Ves1;\n\t tempHappynes := i*Gives1;\n\t tempHappynes := tempHappynes + (temp div Ves2) * Gives2;\n\t if ( tempHappynes > MaxHappynes ) then\n\t MaxHappynes := tempHappynes ;\n\n inc ( I ) ;\n\tend;\n end;\n\n writeLn ( Ans + MaxHappynes ) ;\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n\n\n i : Int64;\n\t TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n if ( MaxSize >= 100000 ) then\n begin\n tempSize := SizeRed * SizeBlue ;\n\n tempCount := MaxSize div tempSize;\n Ans := Max ( SizeBlue * HappyRed , SizeRed * HappyBlue ) * tempCount ;\n MaxSize := MaxSize - tempCount * tempSize;\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n\thalt;\n end;\n\n end;\n\n I := 0 ;\n MaxBrute := 0;\n\n\n while ( I*SizeRed <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n\ttempCount := tempSize div SizeBlue;\n\t\n\tTempBrute := I*HappyRed + tempCount*HappyBlue;\n\tif ( TempBrute > MaxBrute ) then\n\t MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n\n writeLn ( Ans + Max(TempBrute,MaxBrute) ) ;\n\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n\n\n i : Int64;\n\t TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n tempSize := SizeRed * SizeBlue ;\n if ( MaxSize >= tempSize ) then\n begin\n\n\n tempCount := MaxSize div tempSize;\n MaxSize := MaxSize mod tempSize;\n\n Ans := Max ( Int64((tempSize div SizeRed) * HappyRed) , Int64((tempSize div SizeBlue) * HappyBlue )) * tempCount ;\n MaxSize := MaxSize - (tempCount * tempSize);\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n\t halt;\n end;\n\n end;\n\n I := 0 ;\n MaxBrute := 0;\n\n\n while ( (I*SizeRed) <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n\ttempCount := tempSize div SizeBlue;\n\t\n\tTempBrute := I*HappyRed + tempCount*HappyBlue;\n\tif ( TempBrute > MaxBrute ) then\n\t MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n\n writeLn ( Ans + Max(0,MaxBrute) ) ;\n\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n\n\n i : Int64;\n\t TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n\n tempSize := SizeRed * SizeBlue ;\n\n tempCount := MaxSize div tempSize;\n Ans := Max ( SizeBlue * HappyRed , SizeRed * HappyBlue ) * tempCount ;\n MaxSize := MaxSize - tempCount * tempSize;\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n\thalt;\n end;\n\n I := 0 ;\n MaxBrute := 0;\n\n\n while ( I*SizeRed <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n\ttempCount := tempSize div SizeBlue;\n\t\n\tTempBrute := I*HappyRed + tempCount*HappyBlue;\n\tif ( TempBrute > MaxBrute ) then\n\t MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n\n writeLn ( Ans + Max(TempBrute,MaxBrute) ) ;\n\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n temp , Count : Int64;\n Ans , cBruted , maxBruted : Int64;\n i : Int64;\nbegin\n Ans := 0;\n maxBruted := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n\n temp := SizeRed * SizeBlue ;\n\n if ( MaxSize >= temp ) then\n begin\n Count := MaxSize div temp;\n\tAns := Count * Max ( HappyRed * SizeBlue , HappyBlue * SizeRed ) ;\n\tMaxSize := MaxSize mod temp;\n end;\n\n if ( MaxSize > 0 ) then\n begin\n I := 0 ;\n cBruted := 0;\n\twhile ( true ) do // BRUTE REEEEDD!!!!!!!!\n\tbegin\n\t if ( i*SizeRed > MaxSize ) then\n\t break; // The End\n\n temp := MaxSize - i*SizeRed;\n\t cBruted := i*HappyRed;\n\n\t cBruted := cBruted + ( temp div SizeBlue ) * HappyBlue ;\n\n\t if ( cBruted > maxBruted ) then\n\t maxBruted := cBruted ;\n\n\t inc ( i ) ;\n\tend;\n end;\n\n writeLn ( Ans + maxBruted ) ;\n\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n\n\n i : Int64;\n\t TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n\n tempSize := SizeRed * SizeBlue ;\n\n tempCount := MaxSize div tempSize;\n Ans := Max ( HappyBlue * HappyRed , HappyRed * HappyBlue ) * tempCount ;\n MaxSize := MaxSize - tempCount * tempSize;\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n\thalt;\n end;\n\n I := 0 ;\n MaxBrute := 0;\n\n \n while ( I*SizeRed <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n\ttempCount := tempSize div SizeBlue;\n\t\n\tTempBrute := I*HappyRed + tempCount*HappyBlue;\n\tif ( TempBrute > MaxBrute ) then\n\t MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n \n writeLn ( Ans + Max(TempBrute,MaxBrute) ) ;\n\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n Ans : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n\n\n i : Int64;\n\t TempBrute , MaxBrute : Int64;\nbegin\n Ans := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n if ( MaxSize >= 1000 ) then\n begin\n tempSize := SizeRed * SizeBlue ;\n\n tempCount := MaxSize div tempSize;\n Ans := Max ( SizeBlue * HappyRed , SizeRed * HappyBlue ) * tempCount ;\n MaxSize := MaxSize - tempCount * tempSize;\n\n if ( MaxSize = 0 ) then\n begin\n writeLn ( Ans ) ;\n\thalt;\n end;\n\n end;\n\n I := 0 ;\n MaxBrute := 0;\n\n\n while ( I*SizeRed <= MaxSize ) do\n begin\n TempBrute :=0;\n tempSize := MaxSize - i*SizeRed;\n\ttempCount := tempSize div SizeBlue;\n\t\n\tTempBrute := I*HappyRed + tempCount*HappyBlue;\n\tif ( TempBrute > MaxBrute ) then\n\t MaxBrute := TempBrute;\n inc ( I ) ;\n end;\n\n writeLn ( Ans + Max(TempBrute,MaxBrute) ) ;\n\nend.\n"}, {"source_code": "Program Main;\nbegin\n\nend."}, {"source_code": "Program Main;\n Uses MATH;\n var MaxVes , Gives1 , Gives2 , Ves1 , Ves2 : Int64;\n temp : Int64;\n\n\t Ans : int64;\n\n\t I : Int64;\n\t MaxHappynes , tempHappynes : Int64;\nbegin\n Ans := 0;\n MaxHappynes := 0;\n readLn ( MaxVes , Gives1 , Gives2 , Ves1 , Ves2 ) ;\n temp := Ves1 * Ves2 ;\n\n if ( MaxVes >= temp ) then\n begin\n Ans := Max ( Ves2*Gives1 , Ves1*Gives2 ) * (MaxVes div temp) ;\n\tMaxVes := MaxVes mod temp;\n end;\n\n\n if ( MaxVes <> 0 ) then\n begin\n i := 0 ;\n\twhile ( TRUE ) do\n\tbegin\n\t if ( i*Ves1 > MaxVes ) then\n\t break;\n\t temp := MaxVes - i*Ves1;\n\t tempHappynes := i*Gives1;\n\t tempHappynes := tempHappynes + (temp div Ves2) * Gives2;\n\t if ( tempHappynes > MaxHappynes ) then\n\t MaxHappynes := tempHappynes ;\n\n inc ( I ) ;\n\tend;\n end;\n\n writeLn ( Ans + MaxHappynes ) ;\nend.\n"}, {"source_code": "Program Main;\n Uses MATH;\n var MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue : Int64;\n\n temp , Count : Int64;\n Ans , cBruted , maxBruted : Int64;\n\t tempSize : Int64;\n\t tempCount : Int64;\n i : Int64;\nbegin\n Ans := 0;\n maxBruted := 0;\n\n readLn ( MaxSize , HappyRed , HappyBlue , SizeRed , SizeBlue ) ;\n\n temp := SizeRed * SizeBlue ;\n\n if ( MaxSize >= temp ) then\n begin\n Count := MaxSize div temp;\n\tAns := Count * Max ( HappyRed * SizeBlue , HappyBlue * SizeRed ) ;\n\tMaxSize := MaxSize - temp*Count;\n end;\n\n if ( MaxSize > 0 ) then\n begin\n I := 0 ;\n\n\twhile ( true ) do // BRUTE REEEEDD!!!!!!!!\n\tbegin\n\t cBruted := 0;\n\t if ( i*SizeRed > MaxSize ) then\n\t break; // The End\n\n tempSize := MaxSize - (i*SizeRed);\n\t cBruted := (i*HappyRed);\n tempCount := TempSize div SizeBlue;\n\t cBruted := cBruted + (tempCount * HappyBlue);\n\t \n\t if ( cBruted > maxBruted ) then\n\t maxBruted := cBruted ;\n\n\t inc ( i ) ;\n\tend;\n end;\n\n writeLn ( Ans + maxBruted ) ;\n\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b:int64;\n i:longint;\nbegin\n\tans:=0;\n\tex_Euclid(wr,wb,xx,yy);\n a:=wr;b:=wb;\n for i:=0 to wr-1 do\n\tbegin\n\t\tx:=xx*(c-i);y:=yy*(c-i);\n\t\tif x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n\t\tans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nprocedure swap(var x,y:int64);\nvar tem:int64;\nbegin\n\ttem:=x;x:=y;y:=tem;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\treadln(c,hr,hb,wr,wb);\n\tif wrsqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a) else exit(gcd(b,a mod b));\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i*wr) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b,aa,bb:int64;\n i:longint;\nbegin\n\tans:=0;\n aa:=wr;bb:=wb;\n for i:=0 to wr-1 do\n\tbegin\n\n tem:=gcd(gcd(aa,bb),(c-i));\n a:=aa div tem;b:=bb div tem;\n ex_Euclid(a,b,x,y);\n x:=x*(c-i) div tem;y:=y*(c-i) div tem;\n\t\tif x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n\t\tif (x>=0)and(y>=0) then ans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\treadln(c,hr,hb,wr,wb);\n\tif wr>sqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a) else exit(gcd(b,a mod b));\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i*wr) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b,aa,bb:int64;\n i:longint;\nbegin\n\tans:=0;\n aa:=wr;bb:=wb;\n for i:=0 to wr-1 do\n\tbegin\n\n tem:=gcd(gcd(aa,bb),(c-i));\n a:=aa div tem;b:=bb div tem;\n ex_Euclid(a,b,x,y);\n\t\tif x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif (x<0)or(y<0) then continue;\n x:=x*(c-i) div tem;y:=y*(c-i) div tem;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n\t\tif (x>=0)and(y>=0) then ans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\treadln(c,hr,hb,wr,wb);\n\tif wr>sqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a) else exit(gcd(b,a mod b));\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b,aa,bb:int64;\n i:longint;\nbegin\n\tans:=0;\n aa:=wr;bb:=wb;\n for i:=0 to wr-1 do\n\tbegin\n\n tem:=gcd(gcd(aa,bb),(c-i));\n a:=aa div tem;b:=bb div tem;\n ex_Euclid(a,b,x,y);\n x:=x*(c-i) div tem;y:=y*(c-i) div tem;\n\t\tif x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n\t\tif (x>=0)and(y>=0) then ans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\treadln(c,hr,hb,wr,wb);\n\tif wr>sqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "program cft3;\nvar ans,wr,wb,hr,hb,c:int64;\nfunction max(a,b:int64):int64;\nbegin\n\tif a>b then exit(a) else exit(b);\nend;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if b=0 then exit(a) else exit(gcd(b,a mod b));\nend;\n\nfunction ex_Euclid(a,b:int64;var x,y:int64):int64;\nvar t:int64;\nbegin\n\tif b=0 then\n\tbegin\n\t\tx:=1;y:=0;\n\t\texit(a);\n\tend else\n\tbegin\n\t\tex_Euclid:=ex_Euclid(b,a mod b,x,y);\n\t\tt:=x;x:=y;y:=t-(a div b)*y;\n\tend;\nend;\n\nprocedure solve1;\nvar i:longint;\nbegin\n\tans:=0;\n\tfor i:=0 to c div wr do\n\t\tans:=max(ans,i*hr+(c-i) div wb*hb);\nend;\n\nprocedure solve2;\nvar x,y,xx,yy,tem,a,b,aa,bb:int64;\n i:longint;\nbegin\n\tans:=0;\n aa:=wr;bb:=wb;\n for i:=0 to wr-1 do\n\tbegin\n\n tem:=gcd(gcd(aa,bb),(c-i));\n a:=aa div tem;b:=bb div tem;\n ex_Euclid(a,b,x,y);\n x:=x*(c-i) div tem;y:=y*(c-i) div tem;\n\t\tif x<0 then\n\t\tbegin\n\t\t\ttem:=(-x) div b;\n\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tif x<0 then\n\t\t\tbegin\n\t\t\t\tx:=x+b;y:=y-a;\n\t\t\tend;\n\t\tend;\n\t\tif y<0 then\n\t\tbegin\n\t\t\ttem:=(-y) div a;\n\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tif y<0 then\n\t\t\tbegin\n\t\t\t\tx:=x-b;y:=y+a;\n\t\t\tend;\n\t\tend;\n\t\tif hr/wr>=hb/wb then\n\t\tbegin\n\t\t\tif y>0 then\n\t\t\tbegin\n\t\t\t\ttem:=y div a;\n\t\t\t\tx:=x+tem*b;y:=y-tem*a;\n\t\t\tend;\n\t\tend else\n\t\tbegin\n\t\t\tif x>0 then\n\t\t\tbegin\n\t\t\t\ttem:=x div b;\n\t\t\t\tx:=x-tem*b;y:=y+tem*a;\n\t\t\tend;\n\t\tend;\n\t\tans:=max(ans,x*hr+y*hb);\n\tend;\nend;\n\nbegin\n // assign(input,'cft3.in');reset(input);\n\treadln(c,hr,hb,wr,wb);\n\tif wr>sqrt(c) then solve1 else solve2;\n\twriteln(ans);\nend.\n"}, {"source_code": "program problem3;\n\nfunction gcd( a, b: int64 ): int64;\nvar\tc: int64;\nbegin\n\twhile ( b > 0 ) do\n\tbegin\n\t\tc := b;\n\t\tb := a mod b;\n\t\ta := c;\n\tend;\n\t\n\texit( a );\nend;\n\nvar\tc, hr, hb, wr, wb, lcm, ans, best, cur: int64;\n\ti: longInt;\n\nbegin\n\treadln( c, hr, hb, wr, wb );\n\t\n\tlcm := ( wr * wb ) div gcd( wr, wb );\n\t\n\tif ( hr * wb > hb * wr ) then\n\t\tans := ( c div lcm ) * ( lcm div wr ) * hr\n\telse\n\t\tans := ( c div lcm ) * ( lcm div wb ) * hb;\n\t\n\tc := c mod lcm;\n\t\n\tif ( wr < wb ) then\n\tbegin\n\t\twb := wb xor wr;\n\t\twr := wb xor wr;\n\t\twb := wb xor wr;\n\t\t\n\t\thb := hb xor hr;\n\t\thr := hb xor hr;\n\t\thb := hb xor hr;\n\tend;\n\t\n\tbest := 0;\n\tfor i := 0 to longInt(c div wr) do\n\tbegin\n\t\tcur := hr * i + hb * ( ( c - i * wr ) div wb );\n\t\t\n\t\tif ( cur > best ) then\n\t\t\tbest := cur;\n\tend;\n\t\n\twriteln( ans + best );\nend.\n"}, {"source_code": "var c,hr,hb,wr,wb,ans:longint;\nbegin\n readln(c,hr,hb,wr,wb);\n if (hr/wr)> (hb/wb) then\n begin\n ans:=ans+(c div wr)*hr;\n c:=c mod wr;\n if (c0) then \n if (c+wr)>wb\n then\n begin\n ans:=ans-hr;\n c:=c+wr;\n end;\n ans:=ans+(c div wb)*hb;\n end\n else\n begin\n ans:=ans+(c div wb)*hb;\n c:=c mod wb;\n if (c0) then \n if (c+wb)>wr\n then\n begin\n ans:=ans-hb;\n c:=c+wb;\n end;\n ans:=ans+(c div wr)*hr;\n end;\n writeln(ans);\nend."}, {"source_code": "program zad_C;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n c, wr, wb, hr, hb, res, num, num1, l, r, m, m1: int64;\n i : integer;\nfunction get(x : integer):int64;\n var\n w : int64;\n begin\n if(trunc(1.0 * x * wr) > c) then begin\n get := 0;\n exit;\n end;\n\n w := (c mod wr) div wb;\n get := trunc(1.0 * x * hr) + trunc(1.0 * w * hb);\n end;\n\nfunction nod(a, b : int64):int64;\n var\n r : int64;\n begin\n repeat\n r := a mod b;\n a := b;\n b := r;\n until(b = 0);\n\n nod := a;\n end;\n\nfunction nok(a, b : int64):int64;\n begin\n nok := trunc(1.0 * a * b) div nod(a, b);\n end;\nbegin\n readln(c, hr, hb, wr, wb);\n\n num := nok(wr, wb);\n num1 := max(trunc(1.0 * hr * (num div wr)), trunc(1.0 * hb * (num div wb)));\n res := trunc(1.0 * (c div num) * num1);\n\n c := c mod num;\n\n l := 0;\n r := (c div wr);\n while(l + 2 < r) do begin\n m := l + ((r - l) div 3);\n m1 := r - ((r - l) div 3);\n\n if(get(m1) > get(m)) then\n l := m\n else\n l := m1;\n end;\n\n writeln(res + max(get(l), max(get(l + 1), get(l + 2))));\n\n readln(c);\nend.\n"}, {"source_code": "program zad_C;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n c, wr, wb, hr, hb, res, num, num1 : int64;\n i : integer;\nfunction get(x : integer):int64;\n var\n w : int64;\n begin\n if(trunc(1.0 * x * wr) > c) then begin\n get := 0;\n exit;\n end;\n\n w := (c mod wr) div wb;\n get := trunc(1.0 * x * hr) + trunc(1.0 * w * hb);\n end;\n\nfunction nod(a, b : int64):int64;\n var\n r : int64;\n begin\n repeat\n r := a mod b;\n a := b;\n b := r;\n until(b = 0);\n\n nod := a;\n end;\n\nfunction nok(a, b : int64):int64;\n begin\n nok := trunc(1.0 * a * b) div nod(a, b);\n end;\nbegin\n readln(c, hr, hb, wr, wb);\n\n num := nok(wr, wb);\n num1 := max(trunc(1.0 * hr * (num div wr)), trunc(1.0 * hb * (num div wb)));\n res := trunc(1.0 * (c div num) * num1);\n\n c := c mod num;\n\n num := 0;\n for i := 0 to c div wr do\n num := max(num, get(i));\n\n writeln(res + num);\n\n readln(c);\nend.\n"}, {"source_code": "program zad_C;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n c, wr, wb, hr, hb, res, num, num1 : int64;\n i : integer;\nfunction get(x : integer):int64;\n var\n w : int64;\n begin\n if(trunc(1.0 * x * wr) > c) then begin\n get := 0;\n exit;\n end;\n\n w := (c - trunc(1.0 * x * wr)) div wb;\n get := trunc(1.0 * x * hr) + trunc(1.0 * w * hb);\n end;\n\nfunction nod(a, b : int64):int64;\n var\n r : int64;\n begin\n repeat\n r := a mod b;\n a := b;\n b := r;\n until(b = 0);\n\n nod := a;\n end;\n\nfunction nok(a, b : int64):int64;\n begin\n nok := trunc(1.0 * a * b) div nod(a, b);\n end;\nbegin\n readln(c, hr, hb, wr, wb);\n\n num := nok(wr, wb);\n num1 := max(trunc(1.0 * hr * (num div wr)), trunc(1.0 * hb * (num div wb)));\n res := trunc(1.0 * (c div num) * num1);\n\n c := c mod num;\n\n num := 0;\n for i := 0 to c div wr do\n num := max(num, get(i));\n\n writeln(res + num);\n\n readln(c);\nend.\n"}, {"source_code": "program zad_C;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n c, wr, wb, hr, hb, res, num, num1 : int64;\n i : integer;\nfunction get(x : integer):int64;\n var\n w : int64;\n begin\n if(trunc(1.0 * x * wr) > c) then begin\n get := 0;\n exit;\n end;\n\n w := (c - trunc(1.0 * x * wr)) div wb;\n get := trunc(1.0 * x * hr) + trunc(1.0 * w * hb);\n end;\n\nfunction nod(a, b : int64):int64;\n var\n r : int64;\n begin\n repeat\n r := a mod b;\n a := b;\n b := r;\n until(b = 0);\n\n nod := a;\n end;\n\nfunction nok(a, b : int64):int64;\n begin\n nok := trunc(1.0 * (a div nod(a, b)) * b);\n end;\nbegin\n readln(c, hr, hb, wr, wb);\n\n num := nok(wr, wb);\n num1 := max(trunc(1.0 * hr * (num div wr)), trunc(1.0 * hb * (num div wb)));\n res := trunc(1.0 * (c div num) * num1);\n\n c := c mod num;\n\n num := 0;\n for i := 0 to c div wr do\n num := max(num, get(i));\n\n writeln(res + num);\n\n readln(c);\nend.\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb,c,i: longint;\nans,thisans,mult: int64;\n\nprocedure swap(var a,b: longint);\nvar c: longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if hr / wr < hb / wb then begin\n swap(hr,hb);\n swap(wr,wb);\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) do begin\n mult := (c - wb*i) div wr;\n thisans := hb*i + hr*mult;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb: int64;\ni,c: longint;\nans,thisans,mult1,mult2: int64;\n\nprocedure swap(var a,b: int64);\nvar c: int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if hr / wr < hb / wb then begin\n swap(hr,hb);\n swap(wr,wb);\n end;\n\n if wr > c then begin\n write((c div wb) * hb);\n halt;\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) do begin\n mult1 := min(c div wb, i);\n mult2 := (c - wb*i) div wr;\n thisans := hb*mult1 + hr*mult2;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb,c,i: longint;\nans,thisans,mult: int64;\n\nprocedure swap(var a,b: longint);\nvar c: longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if hr / wr < hb / wb then begin\n swap(hr,hb);\n swap(wr,wb);\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) + 1 do begin\n mult := (c - wb*i) div wr;\n thisans := hb*i + hr*mult;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb,c,i: longint;\nans,thisans,mult1,mult2: int64;\n\nprocedure swap(var a,b: longint);\nvar c: longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if hr / wr < hb / wb then begin\n swap(hr,hb);\n swap(wr,wb);\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) do begin\n mult1 := min(c div wb, i);\n mult2 := (c - wb*i) div wr;\n thisans := hb*mult1 + hr*mult2;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}, {"source_code": "program CC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar hr,hb,wr,wb: int64;\ni,c: longint;\nans,thisans,mult1,mult2: int64;\n\nprocedure swap(var a,b: int64);\nvar c: int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'input.txt'); reset(input);\n //assign(output,'output.txt'); rewrite(output);\n\n read(c,hr,hb,wr,wb);\n\n if hr / wr < hb / wb then begin\n swap(hr,hb);\n swap(wr,wb);\n end;\n\n ans := 0;\n for i:=0 to trunc(sqrt(c)) do begin\n mult1 := min(c div wb, i);\n mult2 := (c - wb*i) div wr;\n thisans := hb*mult1 + hr*mult2;\n ans := max(ans,thisans);\n end;\n\n write(ans);\nend.\n"}], "src_uid": "eb052ca12ca293479992680581452399"} {"source_code": "var n,i,k:integer;\ne,t:string;\nL,D,U,R:integer;\nbegin\nreadln(n);\nreadln(e);\nfor i:=1 to n do begin\nt:=copy(e,i,1);\nif t='U' then\nU:=U+1;\nif t='D' then\nD:=D+1;\nif t='L' then\nL:=L+1;\nif t='R' then\nR:=R+1;\nend;\nif UD then\nk:=k+D*2;\nif LR then\nk:=k+R*2;\nif U=D then\nk:=k+u*2;\nif L=R then\nk:=k+R*2;\nwriteln(k);\nend.", "positive_code": [{"source_code": "program robot;\nvar n,i,k,l,r,u,d: integer;\n s: string;\nbegin\n readln(n);\n read(s);\n l:=0;\n r:=0;\n u:=0;\n d:=0;\n for i:=1 to n do\n begin\n if s[i]='U' then inc(u);\n if s[i]='L' then inc(l);\n if s[i]='R' then inc(r);\n if s[i]='D' then inc(d);\n end;\n k:=abs(l-r)+abs(u-d);\n k:=n-k;\n writeln(k);\nend."}, {"source_code": "var s:string;\nn,i,b,l,r,u,d:integer;\nbegin\nreadln (n);\nread (s);\nfor i:=1 to n do\nif s[i]='L' then inc (l);\nfor i:=1 to n do\nif s[i]='R' then inc (r);\nfor i:=1 to n do\nif s[i]='D' then inc (d);\nfor i:=1 to n do \nif s[i]='U' then inc (u);\nif lU then q:=q+2*U\n else q:=q+2*D;\n if R>L then q:=q+2*L\n else q:=q+2*R;\n writeln(q);\nEND.\n\n\n"}, {"source_code": "var\nstrok:string;\nstr:string;\ni:integer;\nn:integer;\nx, y:integer;\nres:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(str);\nstrok:=strok+str;\nend;\nwriteln;\nx:=0;\ny:=0;\nfor i:=1 to n do\nbegin\nif (strok[i]='U' ) then\ny+=1\nelse if (strok[i]='D') then\ny-=1;\nif (strok[i]='L') then\nx-=1\nelse if (strok[i]='R') then\nx+=1;\nend;\nres:=length(strok)-abs(x)-abs(y);\n\nif (res<0) then\nwriteln(0)\nelse\nwriteln(res);\nend."}, {"source_code": "program qwerty;\nvar a:array [1..4] of longint;\nn,i:longint;\nch:char;\n\nfunction min(a,b:longint):longint;\nbegin\n if a>b then min:=b else min:=a;\nend;\n\nbegin\nreadln(n);\nfor i:=1 to n do \n begin\n read(ch);\n if ch='L' then inc(a[1]) else\n if ch='R' then inc(a[2]) else\n if ch='U' then inc(a[3]) else\n if ch='D' then inc(a[4]);\n end;\n writeln(min(a[1],a[2])*2+min(a[3],a[4])*2);\nend."}, {"source_code": " \n const eps=0.0000000001; nn=200000; besk=8000000000;\n label 1,2,23;\n type real=extended; {string=ansistring;}\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n ppoint=^point;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var aa,bb,cc,pos,kk,t3,ot,prod,ost,kol,zapas,dist,r,ll,rr,sum,q,h,t1,t2,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;\n ii,jj,step, k,i,j:longint;\n { aa,bb,cc:int64;\n } pp:array[-1000 ..1000] of point;\n fact,slow,z,pr,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;\n dd:array[-10..2000,-10..200] of int64;\n zanx,zany:array[-10..20000000] of boolean;\n marked,zan:array[-10..10000000] of boolean;\n ss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ch:char;\n d :array [-10..250000,-1..50] of int64;\n dda:array [0..201,-10..30] of int64;\n sss:array[-10..500000] of string;\n st2:array[0..nn] of string;\n pr1,pr2,v0,v1,s0,t0:extended;\n zv:point;\n prob:array[-1..200,-1..200] of extended;\n\n yot:double;\n qqq,aaa,bbb,ccc:extended;\n flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nfunction dom(length,num:longint):boolean;\nvar t,i,j:longint; fll,fl:boolean;\nbegin\n fl:=true;\n for i:=1 to n-length+1 do if d[i+length-1,num]-d[i-1,num]=0 then fl:=false;\n\n dom:=fl;\n\n\nend;\n\nfunction domm(length:longint):boolean;\nvar i,j:longint; fl:boolean;\nbegin\n fl:=false;\n for i:=0 to 25 do if dom(length,i) then fl:=true;\n\n domm:=fl;\nend;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n read(ss);\n n:=length(ss);\n for i:=1 to n do\n begin\n if ss[i]='U' then inc(x[1]);\n if ss[i]='D' then inc(x[2]);\n if ss[i]='R' then inc(x[3]);\n if ss[i]='L' then inc(x[4]);\n\n\n\n end;\n\n writeln(2*(min(x[1],x[2])+min(x[3],x[4])));\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar i,n,k,l,r,u,d: integer;\n c: char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n case c of\n 'L': inc(l);\n 'R': inc(r);\n 'U': inc(u);\n 'D': inc(d);\n end\n end;\n if l>r then k:=2*r else k:=2*l;\n if u>d then k:=k+2*d else k:=k+2*u;\n write(k);\nend.\n"}, {"source_code": "program Project1;\n\nvar\n n, i: SmallInt;\n c: char;\n U, D, L, R: SmallInt;\n\nbegin\n ReadLn(n);\n U := 0; D := 0; L := 0; R := 0;\n For i := 1 to n do\n begin\n If i < n then Read(c) else ReadLn(c);\n Case ord(c) of\n 68: D := D+1;\n 76: L := L+1;\n 82: R := R+1;\n 85: U := U+1;\n end;\n end;\n If D > U then D := U;\n If R > L then R := L;\n WriteLn(D+R+D+R); \nend.\n"}, {"source_code": "var x,y,n,i: integer;\n s:string;\n c:char;\nBegin\n readln(n);\n read(s);\n for i:= 1 to n do\n begin\n c:=s[i];\n case c of\n 'L': dec(x);\n 'R': inc(x);\n 'U': dec(y);\n 'D': inc(y);\n end;\n end;\n write(n-abs(x)-abs(y));\nend."}, {"source_code": "program Buggy_Robot;\n\nconst\n maxn = 103;\n\nvar\n n: longint;\n s: string;\n\n x, y, i: longint;\n\nbegin\n readln(n);\n readln(s);\n\n x := 0; y := 0;\n for i := 1 to n do\n case s[i] of\n 'L': dec(x);\n 'R': inc(x);\n 'U': inc(y);\n 'D': dec(y);\n end;\n\n if x < 0 then x := -x;\n if y < 0 then y := -y;\n writeln(n - (x + y));\nend.\n"}, {"source_code": "var a,b,c,d,i,n,k:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do \nbegin\ncase s[i] of \n'U':inc(a);\n'D':inc(b);\n'L':inc(c);\n'R':inc(d);\nend;\nend;\nif (a>0) and (b>0) then if b>a then inc(k,a*2) else inc(k,b*2);\nif (c>0) and (d>0) then if c>d then inc(k,d*2) else inc(k,c*2);\nwriteln(k);\nend."}, {"source_code": "const\n fi='';//'cf888b.inp';\n fo='';//'cf888b.out';\nvar\n s:string;\n l,i,x,y:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(l);\n readln(s);\n for i:=1 to l do\n if (s[i]='L') then x-=1\n else if (s[i]='R') then x+=1\n else if (s[i]='U') then y+=1 else y-=1;\n write(l-abs(x)-abs(y));\n close(input);\n close(output);\nend.\n"}, {"source_code": "var n,i,u,d,l,r,k1,k2,k:integer;\na:array[0..1001] of char;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nU:=0;\nD:=0;\nL:=0;\nR:=0;\nfor i:=1 to n do begin\nif a[i]='U' then U:=U+1;\nif a[i]='D' then D:=D+1;\nif a[i]='L' then L:=L+1;\nif a[i]='R' then R:=R+1;\nend; \nif (U<>0) and (D<>0) then begin if U<=D then k1:=2*U else k1:=2*D; end else k:=0;\nif (L<>0) and (R<>0) then begin if L<=R then k2:=2*L else k2:=2*R; end else k:=0;\nk:=k1+k2;\nwriteln(k);\n\n\nend."}, {"source_code": "program asdf;\nvar n, i, x, y:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nx:=0; y:=0;\nfor i:=1 to n do\n case s[i] of\n 'R': x:=x+1;\n 'L': x:=x-1;\n 'U': y:=y+1;\n 'D': y:=y-1;\n end;\nwrite(n-abs(x)-abs(y));\nend.\n"}, {"source_code": "var a: string;\nn, i, X, Y: integer;\nbegin\n readln(n);\n read(a);\n X:=0;\n Y:=0;\n for i:=1 to n do begin\n if a[i]='L' then dec(X)\n else if a[i]='R' then inc(X)\n else if a[i]='U' then inc(Y)\n else if a[i]='D' then dec(Y);\n end;\n writeln(n-abs(X)-abs(Y));\nend."}, {"source_code": "uses math;\nvar\n n, i, U, D, R, L : longint;\n a : char;\nbegin\n readln( n );\n for i := 1 to n do\n begin\n read( a );\n case a of\n 'U' : inc( U );\n 'D' : inc( D );\n 'R' : inc( R );\n 'L' : inc( L );\n end;\n end;\n writeln( ( min( U, D ) + min( R, L ) ) * 2 );\nend.\n"}, {"source_code": "var S:String;\nn,i,u,d,l,r,ans,min1,min2:longint;\nbegin\nreadln(n);\nreadln(S);\nfor i:=1 to Length(S) do begin\nif S[i]='R' then inc(r);\nif S[i]='L' then inc(l);\nif S[i]='U' then inc(u);\nif S[i]='D' then inc(d);\n end;\nif (r>0) and (l>0) then begin\n if r>l then min1:=l\n else min1:=r;\n end;\nif (u>0) and (d>0) then begin\n if u>d then min2:=d\n else min2:=u;\n end;\nans:=(min1*2)+(min2*2);\nwrite(ans);\nend.\n\n"}, {"source_code": "var\nA:string;\nb, c, i, x, y: integer;\n\nbegin\nreadln(b);\nread(A);\nc:=length(A);\nif c=b then begin\nfor i := 1 to b do \nbegin\nif A[i] = 'L' then x := x - 1 else\nif A[i] = 'R' then x := x + 1 else\nif A[i] = 'U' then y := y + 1 else\nif A[i] = 'D' then y := y - 1;\nend;\nc :=b - (abs(x));\nc := c - (abs(y));\nwrite(c);\nend;\nend."}, {"source_code": "function min(a,b:integer):integer;\n begin\n if aa[2] then max:=max+a[2]*2 else max:=max+a[1]*2;\nif a[3]>a[4] then max:= max+a[4]*2 else max:=max+a[3]*2;\nwriteln(max);\nend.\n"}, {"source_code": "Const\tfi='';\n\tfo='';\n\nvar\tf:text;\n\tn,kq:integer;\n\ts:string;\n\nPRocedure NhapDL;\nvar\ti:integer;\nbegin\n\tAssign(f,fi); Reset(f);\n\tReadln(f,n);\n\tRead(f,s);\n Close(F);\nend;\n\nPRocedure Xuly;\nvar\ti,l,r,d,u:integer;\nbegin\n kq:=0;\n l:=0;\n r:=0;\n u:=0;\n d:=0;\n\tFor i:= 1 to n do\n\tif s[i] ='L' then inc(l)\n\telse if s[i] = 'R' then inc(r)\n\telse if s[i] = 'U' then inc(u)\n\telse inc(d);\n\tif l > r then kq:= kq + (2*r)\n\telse kq:= kq+ (2*l);\n\tif u > d then kq:= kq +(2*d)\n\telse kq:= kq +(2*u);\nend;\n\nPRocedure XuatDL;\nbegin\t\n\tassign(f,fo); Rewrite(f);\n\tWrite(f,kq);\n\tClose(f);\nend;\n\nBegin\n\tNhapDL;\n\tXuly;\n\tXuatDL;\nend.\n"}, {"source_code": "var s:string; l,i,x,y:integer;\nbegin\n readln(l); x:=0;\n readln(s); y:=0;\n for i:=1 to l do\n if (s[i]='L') then x-=1\n else if (s[i]='R') then x+=1\n else if (s[i]='U') then y+=1\n else y-=1;\n write(l-abs(x)-abs(y))\nend."}, {"source_code": " var i,x,y,n:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n x:=0;\n y:=0;\n for i:=1 to n do\n case s[i] of\n 'L':inc(x);\n 'R':dec(x);\n 'U':inc(y);\n 'D':dec(y);\n end;\n x:=abs(x);\n y:=abs(y);\n writeln(n-x-y);\nend."}, {"source_code": "var n,i:longint;\n s:string;\n c:array['A'..'Z']of longint;\n ans:longint;\nfunction min(a,b:longint):longint;\nbegin\n if a0)and(y<>0) then writeln(0) else writeln(l);\nend."}, {"source_code": "program cay_888_b;\nvar s:string;\n i,n,x,y,k:longint;\nbegin\n readln(n);\n readln(s);\n k:=0;\n x:=0; y:=0;\n i:=1;\n while i<=n do begin\n if s[i]='U' then y:=y+1 else\n if s[i]='D' then y:=y-1 else\n if s[i]='R' then x:=x+1 else x:=x-1;\n k:=k+1;\n if (x=0)and(y=0)then begin\n writeln(k); break;\n end\n else i:=i+1;\n end;\n if (x<>0)and(y<>0) then writeln(0);\nend."}, {"source_code": "program cay_888_b;\nvar s:string;\n i,n,x,y,k,l:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n case s[i] of\n 'U': y:=y+1;\n 'D': y:=y-1;\n 'R': x:=x+1;\n 'L': x:=x-1;\n end;\n write(n-abs(x)-abs(x));\nend."}, {"source_code": "uses math;\nvar n,i,res:byte;\n ch:char;\n dem:array[1..4] of byte;\nbegin\n res:=0;\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n if ch='U'then inc(dem[1]);\n if ch='D'then inc(dem[3]);\n if ch='L'then inc(dem[2]);\n if ch='R'then inc(dem[4]);\n if resmax then max:=i;\nend;\nWriteln(max)\nend."}, {"source_code": "Program z1;\nVar\n x,y:real;\n i,n,k,max:integer;\n a:string;\nbegin\nx:=0;\ny:=0;\nmax:=0;\nReadln(n);\nReadln(a);\nFor i:=1 to n do begin\nIf a[i]='U' then y:=y+1;\nIf a[i]='D' then y:=y-1;\nIf a[i]='L' then x:=x-1;\nIf a[i]='R' then x:=x+1;\nIf (x=0)and(y=0)then If i>max then max:=i;\nend;\nWriteln(max)\nend."}, {"source_code": "var s:string; l,i,x,y:integer;\nbegin\n readln(l); x:=0;\n readln(s); y:=0;\n for i:=1 to l do\n if (s[i]='L') then x-=1\n else if (s[i]='R') then x+=1\n else if (s[i]='U') then y+=1\n else y-=1;\n write(l-x-y)\nend."}, {"source_code": "Var n,l,i,k,x,y:integer;\n s:array[1..100] of char;\nBegin\nReadln (n);\nFor i:=1 to n do\nRead (s[i]);\nx:=0; y:=0; l:=1;\nFor i:=1 to n do begin\nif s[i]='r' then x:=x+1;\nif s[i]='l' then x:=x-1;\nif s[i]='u' then y:=y+1;\nif s[i]='d' then y:=y-1;\nif (x=0) and (y=0) then k:=l;\nl:=l+1;\nend; \nwriteln (k); \nEnd."}, {"source_code": "Var n,l,i,k,x,y:integer;\n s:array[1..100] of char;\nBegin\nReadln (n);\nFor i:=1 to n do\nRead (s[i]);\nx:=0; y:=0; l:=0;\nFor i:=1 to n do begin\nif s[i]='R' then x:=x+1;\nif s[i]='L' then x:=x-1;\nif s[i]='U' then y:=y+1;\nif s[i]='D' then y:=y-1;\nl:=l+1;\nif (x=0) and (y=0) then k:=l;\nend; \nwriteln (k); \nEnd."}, {"source_code": "PROGRAM W;\nvar L,D,U,R,q,i,n:integer;\n s:string;\nBEGIN\n readln(n);\n readln(s);\n L:=0;\n For i:=1 to n do\n if s[i]='L' then L:=L+1;\n D:=0;\n For i:=1 to n do\n if s[i]='D' then D:=D+1;\n U:=0;\n For i:=1 to n do\n if s[i]='U' then U:=U+1;\n R:=0;\n For i:=1 to n do\n if s[i]='R' then R:=R+1;\n q:=0;\n If U<>D then begin if D>U then q:=q+2*U end\n else q:=q+2*D;\n If L<>R then begin if R>L then q:=q+2*L end\n else q:=q+2*R;\n writeln(q);\nEND."}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar i,n,k,x,y: integer;\n c: char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n case c of\n 'L': dec(x);\n 'R': inc(x);\n 'U': inc(y);\n 'D': dec(y);\n end\n end;\n k:=n-(x+y);\n write(k);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar i,n,k,x,y: integer;\n c: char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n case c of\n 'L': dec(x);\n 'R': inc(x);\n 'U': inc(y);\n 'D': dec(y);\n end;\n if (x=0) and (y=0) then k:=i;\n end;\n write(k);\n readln(n);\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar i,n,k,x,y: integer;\n c: char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(c);\n case c of\n 'L': dec(x);\n 'R': inc(x);\n 'U': inc(y);\n 'D': dec(y);\n end\n end;\n k:=n-abs(x+y);\n write(k);\nend.\n"}], "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a"} {"source_code": "program ConsoleOlympProj;\n\n{$APPTYPE CONSOLE}\n\nuses Math;\n\nvar\n n, k, l, c, d, p, nl, np: Integer;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n Assign(Input, 'input.txt');\n Reset(Input);\n Assign(Output, 'output.txt');\n Rewrite(Output);\n{$ENDIF}\n\n Read(n, k, l, c, d, p, nl, np);\n Write(Min((k * l) div nl, Min(c * d, p div np)) div n);\n\n{$IFNDEF ONLINE_JUDGE}\n Close(Input);\n Close(Output);\n{$ENDIF}\nend.", "positive_code": [{"source_code": "{$APPTYPE CONSOLE}\n\n\nvar\n n, k ,l, c, d, p, nl, np, ans : integer;\n\nfunction min (a, b : integer) : integer;\nbegin\n if a > b then\n result := b\n else\n result := a; \n\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n read(n, k, l, c, d, p, nl, np);\n ans := min((k * l div nl) div n, min(c * d div n,(p div np) div n));\n write(ans);\nend.\n"}, {"source_code": "var\nmin,ans,n,k,l,c,d,p,nl,np,kl:longint;\nbegin\nreadln(n,k,l,c,d,p,nl,np);\nkl:=k*l;\nmin:=kl div nl;\nif c*db then ans:=b else ans:=a;\n if c=nl) and (c>0) and (p>=np) do\n Begin\n k:=k-nl;\n Dec (c);\n p:=p-np;\n Inc (kol);\n End;\n kol:=kol div n;\n Writeln (kol);\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nn,k,l,c,d,p,nl,np,z,x,y,kl,cd:integer;\n\nbegin\nreadln(n,k,l,c,d,p,nl,np);\nkl:=k*l;\nz:=kl div nl;\ncd:=c*d;\nx:=p div np;\nif z>cd then\ny:=cd\nelse\ny:=z;\nif y>x then\ny:=x div n\nelse\ny:=y div n;\nwriteln(y);\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n "}, {"source_code": "function get_min (a,b,c:longint):longint;\nvar min:longint;\nbegin\n min := a;\n if b < min then\n min := b;\n if c < min then\n min := c;\n get_min:=min;\nend;\n\nvar n,k,l,c,d,p,nl,np:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n writeln(get_min((k*l) div nl,c*d,p div np) div n);\nend."}, {"source_code": "program gas;\nvar n,k,l,c,d,p,nl,np,i,all_gas,tost1,tost2,tost3,tost4:integer;\n \nbegin\n readln(n,k,l,c,d,p,nl,np);\n all_gas:=k*l;\n tost1:=all_gas div nl;\n tost2:=c*d;\n tost3:=p div np;\n if tost1 < tost2 then begin \n if tost1 < tost3 then writeln(tost1 div n) else writeln(tost3 div n) \n end else begin \n if tost2 < tost3 then writeln(tost2 div n) else writeln(tost3 div n) \n end;\nend."}, {"source_code": "var n,k,l,c,d,p,nl,np:longint;\n\nfunction min(a,b:longint):longint;\nbegin\n if adol then min:=dol else min:=v;\nif min>sol then min:=sol;\nmin:=trunc(min);\nwriteln(min:0:0);\n\n\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar\n n, k, l, c, d, p, nl, np, min: integer;\nbegin\n{$IFNDEF ONLINE_JUDGE}\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n{$ENDIF}\n read( n, k, l, c, d, p, nl, np);\n min:=(k*l) div (n*nl);\n if min>(c*d) div n then\n min:=(c*d) div n;\n if min>p div (np*n) then\n min:=p div (np*n);\n write(min); \n{$IFNDEF ONLINE_JUDGE}\n close(input);\n close(output);\n{$ENDIF}\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar\nn,k,l,c,d,p,nl,np,i1,i2,i3,j:Integer;\nbegin\nReadln(n,k,l,c,d,p,nl,np);\ni1:=(k*l) div (nl*n);\ni2:=(c*d) div n;\ni3:=p div (np*n);\ni1:=min(i1,i2);\ni1:=min(i1,i3);\nWriteln(i1 );\nReadln(i1);\nend.\n"}, {"source_code": "program Gazirovka;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n\nvar\n n,k,l,c,d,p,nl,np:smallint;\n tl,tc,tp,al,min1:integer;\n t:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(n,k,l,c,d,p,nl,np);\n al:=k*l;\n tl:=al div nl;\n tc:=c*d;\n tp:=p div np;\n min1:=min(tl,tp);\n t:=min(min1,tc);\n t:= t div n;\n writeln(t);\n readln;\nend.\n "}, {"source_code": "uses math;\n\nvar\n n,m,k,l,w,s,j,i,nl,np,c,d,a1,a2,a3,p:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n a1:=(k*l)div nl;\n a2:=(c*d);\n a3:=p div np;\n writeln(min(a3,min(a1,a2)) div n);\nend.\n\n\n"}, {"source_code": "program solveA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, k, l, c, d, p, nl, np: integer;\nbegin\n readln(n, k, l, c, d, p, nl, np);\n writeln(min(min((k*l) div nl, c*d), p div np) div n );\n readln;readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar n, k, l, c, d, p, nl, np,n1,n2,n3:integer;\nbegin\n readln(n, k, l, c, d, p, nl, np);\n n1:=(k*l)div nl;\n n2:=c*d;\n n3:=p div np;\n if (n1<=n2)and(n1<=n3) then writeln(n1 div n)\n else if (n2<=n3) and (n2<=n1) then writeln(n2 div n)\n else writeln(n3 div n);\n \nend."}, {"source_code": "var p,min,d,c,np,nl,n,i,l,k,j,m:longint;\nbegin\nread(n,k,l,c,d,p,nl,np);\nmin:=k*l div nl;\nif min>c*d then min:=c*d;\nif min>p div np then min:=p div np;\nwriteln(min div n);\nend.\n\n"}, {"source_code": "uses math;\nvar n,k,l,c,p,d,nl,np:integer;\nbegin\n read(n,k,l,c,d,p,nl,np);\n write(min((k*l) div nl,min(c*d,p div np)) div n);\nend."}, {"source_code": "var\n n,l,k,nl,d,p,np,i,i2,j,c:integer;\n a:array [1..3] of integer;\nbegin\n read(n,k,l,c,d,p,nl,np);\n a[1]:=(k*l) div nl;\n a[2]:=c*d;\n a[3]:=p div np;\n for i:=1 to 2 do\n begin\n for i2:=1 to 2 do\n begin \n if a[i2]>=a[i2+1] then\n begin \n j:=a[i2];\n a[i2]:=a[i2+1];\n a[i2+1]:=j;\n end;\n end;\n end;\n writeln(a[1] div n);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$IFNDEF ONLINE_JUDGE}\n {$R+,S+,Q+,I+,C+,M+,H+,O+}\n{$ELSE}\n {$R-,S-,Q-,I-,C+,M-,H+,O+}\n{$ENDIF}\n\nuses\n SysUtils, Math;\n\nvar\n n, k, l, c, d, p, nl, np, av, ad, ap : int64;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n{$ENDIF}\n read(n, k, l, c, d, p, nl, np);\n av := k * l div nl;\n ad := c * d;\n ap := p div np;\n write(min(av, min(ad, ap)) div n);\nend."}, {"source_code": "var\n n,k,l,c,d,p,nl,np,Tost,vodka,zacus,sol:longint;\n f:boolean;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n Vodka:=k*l;\n Zacus:=c*d;\n Sol:=p;\n Tost:=0;\n while not f do\n begin\n vodka:=vodka-n*nl;\n zacus:=zacus-n;\n sol:=sol-n*np;\n if (vodka>=0) and (zacus>=0) and (sol>=0) then inc(Tost)\n else begin writeln(Tost); f:=true; exit; end;\n end;\nend.\n"}, {"source_code": "var i,j,n,k,l,c,d,p,nl,np,a1,a2,a3,max:integer;\nbegin\nreadln (n,k,l,c,d,p,nl,np);\na1:=k*l div nl;\na2:=c*d;\na3:=p div np;\nif a1<=a2 then\nmax:=a1\nelse\nmax:=a2;\nif a3 c * d) AND ( c * d < p DIV np) then\n write( (c * d) DIV n ) else\n if ( p DIV np < c * d) AND ( c * d > p DIV np) then\n write( p DIV np DIV n ) else\n write( p DIV np DIV n );\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n var\n i,j,k,l,m,p,d,c,nl,np,n,xml,xl,xp: int64;\nbegin\n read(n,k,l,c,d,p,nl,np);\n xml:=(k*l)div nl;\n xl:=c*d;\n xp:=p div np;\n i:=10000000000000000;\n if i> (xml div n) then i:=(xml div n);\n if i> (xp div n) then i:=(xp div n);\n if i> (xl div n) then i:=(xl div n);\n write(i);\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D-,E+,F+,G-,I-,L-,N+,O-,R-,Q-,V+,X+}\n\nuses\n SysUtils,\n Math;\n\nvar\n n, k, l, c, d, p, nl, np, x, y, z: integer;\n\nbegin\n //Reset(input, 'input.txt');\n //Rewrite(output, 'output.txt');\n\n read(n, k, l, c, d, p, nl, np);\n c := c * d;\n x := (k * l) div (n * nl);\n y := c div n;\n z := p div (n * np);\n write(min(x, min(y, z)));\n\nend.\n"}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\n\n\nconst nn=10001;\n eps=0.000000001; nnn=200;\n label 1,2;\nvar step,i,j:longint;\nd,c,nl,np,s,m,s1,mmin,mmax,imin,imax,ii,x1,y1,n,ot,modul,p1,p2,k,l,r,izm,t,p,k1,k2,a2:longint;\n\na,b,h,dl,pr,st:array [-1..1000] of longint;\npp,dost:array[0..1000] of longint;\nch:char;\nb1:array [0..100000] of char;\nsv:array [-1..10000 ] of boolean;\nuu,uu1:array[0..200] of boolean;\nflag2,flag1,flag:boolean;\nverot:double;\nss,namemin:string;\nstr:array[0..20] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:longint):longint; var p,t:longint;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n\n\n\n\n{function diam(a,b:mas;n:longint):longint;\nvar i0,t,i,j,k:longint; kver:mas; sv:mas2;\n begin\n for i:=1 to n do for j:=1 to n-1 do\n if a[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=b[j]; end;\n for i:=1 to n do for j:=1 to n-1 do\n if b[j]=i then begin inc(kver[i]); sv[i,kver[i]]:=a[j]; end;\n for i:=1 to n do write(kver[i],' ');writeln; writeln;\n for i:=1 to n do begin for j:=1 to kver[i] do write(i,'-',sv[i,j],' ');writeln; end;\n\nfor i0:=1 to 1 do\n begin for i:=1 to n do sm[i]:=false; for i:=1 to n do dist[i]:=1000;\n sm[i0]:=true; dist[i0]:=0; kol:=1;\n\n\n end;\n\n\n\ndiam:=t;\n end; }\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} readln(n,k,l,c,d,p,nl,np);\n i:=(c*d); j:=p div np; t:=(k*l) div nl;\n {writeln(i,' ',j,' ',t); }\n i:=min(i,j);t:=min(i,t);\n writeln(t div n);\n\n 1: close (output);\n end.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nfunction min(a,b,c : integer) : integer;\nvar\n m : integer;\nbegin\n if a >= b then m := b\n else m := a;\n if m >= c then min := c\n else min := m;\nend;\nvar\n n,k,d,p,nl,np,c,l,kol_l,kol_s,kol_g : integer;\nbegin\n read(n,k,l,c,d,p,nl,np);\n kol_g := (k * l) div nl;\n kol_l := c * d;\n kol_s := p div np;\n write(min(kol_g,kol_l,kol_s) div n);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, k, l, c, d, p, nl, np: longint;\n\nbegin\n read(n, k, l, c, d, p, nl, np);\n\n write((min(min((k*l) div nl, c*d), p div np))div n);\n\nend."}, {"source_code": "Uses Math;\nvar\n\tn, k, l, c, d, p, nl, np : longint;\t\n\nbegin\n//\treset(input, 'a.in');\trewrite(output, 'a.out');\n\tread(n, k, l, c, d, p, nl, np);\n\n\twrite(min(min(k*l div nl, c*d), p div np) div n);\nend."}, {"source_code": "program aa;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nn, k, l, c, d, p, nl, np, r, s1 , s2 , s3 : integer;\n\nbegin\n readln(n, k, l, c, d, p, nl, np);\n s1 := k * l;\n s2 := c * d;\n s3 := p;\n r := 0;\n while (s1 >= 0)and(s2 >= 0)and(s3 >= 0)do begin\n inc(r);\n s1 := s1 - n*nl;\n s2 := s2 - n;\n s3 := s3 - n*np;\n end;\n dec(r);\n writeln(r);\nend."}, {"source_code": "program a1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\nvar\n n,m,a,ot,l,np,p,nl,b,c,d,k,i,j:longint;\n s:string;\n f:boolean;\n x,y,r:array[1..100000]of longint;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n read(n,k,l,c,d,p,nl,np);\n write(min(min(k*l div nl, c*d), (p div np)) div n);\nend.\n"}, {"source_code": "Program SoftDrinking;\nuses math;\nvar n,k,l,c,d,p,nl,np,ans:longint;\nbegin //assign(input,'151A.inp'); reset(input);\n //assign(output,'151A.out'); rewrite(output);\n readln(n,k,l,c,d,p,nl,np);\n ans:=min(k*l div nl,min(c*d,p div np));\n writeln(ans div n);\n //close(input); close(output);\nend."}, {"source_code": "uses math;\nvar n,k,l,c,d,p,nl,np:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n writeln(min(((k*l) div nl),min(c*d,(p div np))) div n);\nend."}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nFunction minn(bb,aa: longint): longint;\nbegin\n if (aa < bb) then\n minn := aa\n else\n minn := bb;\nend;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n write((minn(a, minn(b, o))) div n);\n {if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);}\nEnd."}, {"source_code": "var a,b,c,d,f,i,j,k,n,n1:longint;\nfunction min(a,a1:longint):longint;\nbegin\nif a>a1 then min:=a1 else min:=a\nend;\nbegin\nreadln(a,b,c,d,f,k,n,n1);\nb:=b*c;\nc:=d*f;\nd:=k;\nwriteln(min(min((b div a) div n,c div a),(d div n1) div a));\nend."}, {"source_code": "var a,b,c,d,e,f,g,h,fs:longint;\nfunction sd (n,k,l,c,d,p,nl,np: longint):longint;\nvar v,t,a,minn:longint;\nbegin\n begin\n v:=(k*l) div nl;\n t:=c * d;\n a:=p div np;\n end;\n minn:=v;\n if (minn > t) then minn:=t;\n if (minn > a) then minn:=a;\n exit(minn div n);\nend;\nbegin\n readln(a,b,c,d,e,f,g,h);\n fs:=sd(a,b,c,d,e,f,g,h);\n writeln(fs);\nend.\n"}, {"source_code": "program soft_drink;\n\nFunction mina(a,b:longint):longint;\nbegin\n if (a=d1) and (k2>=d2) and (k3>=d3) do\n begin\n dec(k1,d1);\n dec(k2,d2);\n dec(k3,d3);\n inc(res);\n end;\n writeln(fo,res div n);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "Var i,n, k, l, c, d, p, nl, np:longint;\notv:int64;\nbegin\n read (n, k, l, c, d, p, nl, np);\n k:=(k*l) div nl; \n c:=c*d;\n p:=p div np;\n if (kkols then min:=kols;\nmin:=min div n;\nwriteln(min);\nend."}, {"source_code": "program taskA;\nvar\n n, k, l, c, d, p, nl, np :longint;\n i,max:longint;\n a:array[1..6] of longint;\nbegin\n read(n, k, l, c, d, p, nl, np);\n a[1]:=k*l div nl;\n a[2]:=c*d;\n a[3]:=p div np;\n for i:=1 to 3 do\n a[i+3]:=a[i] div n;\n \n max:=a[4];\n for i:=5 to 6 do\n if a[i]b then min:=b; end;\n begin read(n,k,l,c,d,p,nl,np); k:=(k*l) div nl; c:=c*d; p:=p div np;\n write(min(min(k,c),p) div n); end. "}, {"source_code": "var\n n,k,l,c,d,p,nl,np,x,y,z,yl,nm:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n yl:=k*l;\n nm:=c*d;\n x:=yl div nl div n;\n y:=nm div n;\n z:=p div np div n;\n if yb then\nmin:=b\nelse\nmin:=a;\nend;\n\nvar n, k, l, c, d, p, nl, np,w1,w2,w3,w:integer;\nbegin\nread(n, k, l, c, d, p, nl, np);\nw:=(k*l)div nl ;\nw1:=c*d;\nw2:=p div np;\nw3:=min(w,w1);\nw3:=min(w2,w3);\nwriteln(w3 div n);\nend."}, {"source_code": "\nvar\nx,p,l,k,nl,np,raz,d,j,m,i,R,r2,n:longint;\ny,s1,q1,z1,b,c:longint;\na:array [1..1000] of longint;\ns,q,z:string;\n{input,output:text;}\n\nfunction max(a,b:longint):longint;\nbegin\nif a< b then max:=a else max:=b;\nend;\n\n\n\n\n\n\n\nbegin\n\n{ assign(input, 'input.txt'); reset(input);\n assign(output, 'output.txt'); rewrite(output);\n }\n\nread (n,k,l,c,d,p,nl,np);\n\nc:=c*d;\nx:=max(p div (n*np),max( (k*l) div(n*nl),c div n));\nif x <=0 then write (0) else write (x);\nend.\n\n"}, {"source_code": "var\n n,k,l,c,d,p,nl,np,ts,tl,tp,min : integer ;\n\nbegin\n read (n,k,l,c,d,p,nl,np) ;\n ts := (k * l) div nl ;\n tl := c * d ;\n tp := p div np ;\n min := 1001 ;\n if ts < min then\n min := ts ;\n if tl < min then\n min := tl ;\n if tp < min then\n min := tp ;\n writeln (min div n) ;\nend.\n"}, {"source_code": "uses math;\nvar\n n,k,l,c,d,p,nl,np:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n writeln(min(min(k*l div nl,p div np),c*d)div n);\nend.\n"}, {"source_code": "uses math;\nvar\n n, k, l, c, d, p, nl, np,bbb, lol, b : integer;\n\nbegin\n read(n, k, l, c, d, p, nl, np);\n\n\n bbb := k*l ;\n bbb := bbb div nl;\n //b := bbb div n; \n lol := min(bbb,(min((c*d),(p div np))));\nwrite(lol div n);\nend."}, {"source_code": "program A;\n\n\nvar\nn,k,l,c,d,p,nl,np:integer;\ns,kl,cd:integer;\n\nbegin\n\nread(n,k,l,c,d,p,nl,np);\nkl:=k*l;\ncd:=c*d;\nkl:=kl div nl;\np:=p div np;\nif (kl -1 then\n write(min div n)\n else\n write('0');\nend."}, {"source_code": "program gas;\nvar n,k,l,c,d,p,nl,np,i,all_gas,tost1,tost2,tost3,tost4:integer;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n all_gas:=k*l;\n tost1:=all_gas div nl;\n tost2:=c*d;\n tost3:=p div nl;\n if tost1 < tost2 then begin \n if tost1 < tost3 then writeln(tost1 div n) else writeln(tost3 div n) \n end else begin \n if tost2 < tost3 then writeln(tost2 div n) else writeln(tost3 div n) \n end;\nend."}, {"source_code": "function min(a,b:integer):integer;\nbegin\nif a>b then\nmin:=b\nelse\nmin:=a;\nend;\n\n\nvar n, k, l, c, d, p, nl, np,w1,w2,w3,w:integer;\nbegin\nread(n, k, l, c, d, p, nl, np);\nw:=(k*l)div n ;\nw1:=c*d;\nw2:=p div np;\nw3:=min(w,w1);\nw3:=min(w2,w3);\nwriteln(w3 div n);\nend."}, {"source_code": "uses math;\nVAR N,K,L,C,D,P,NL,NP,X,Z,Y:LONGINT;\nbegin\nreadln(N,K,L,C,D,P,NL,NP);\nZ:=(K*L) DIV NL;\ny:=C*D;\nX:=P DIV NP;\nWRITE(MIN(MIN(Z,Y),X)DIV 3);\nEND.\n"}, {"source_code": "program soft_drink;\n\nFunction min(a,b,c:longint):longint;\nbegin\n if (a c * d) AND ( c * d < p DIV np) then\n write( (c * d) DIV n ) else\n if ( p DIV np < c * d) AND ( c * d > p DIV np) then\n write( p DIV np DIV n );\n\nend."}, {"source_code": "var n, k, l, c, d, p, nl, np: integer;\n min_kl, min_cd, min_pnp: integer;\n\nbegin\n readln (n, k, l, c, d, p, nl, np);\n min_kl:=(k*l) div nl;\n min_cd:=c*d;\n min_pnp:=p div np;\n if ((min_klnl*3) and (d>1*3) and (p>np*3) do begin\nif b>nl*3 then b:=b-nl*n else break ;\nif d>1*n then d:=d-1*n else break ;\nif p>np*3 then p:=p-np*n else break ;\nk1:=k1+1 ;\nend ;\nwriteln(k1) ;\nend.\n"}, {"source_code": "uses math;\nvar p,n,k,l,c,d,nl,np,a,b:longint;\nbegin\n readln (n,k,l,c,d,p,nl,np);;\n a:=(k*l)div n;\n b:=c*d;\n c:=p div np;\n writeln(min(a,min(b,c))div n);\nend."}, {"source_code": "uses math;\nconst fin='';\nvar f:text;\n n,k,l,c,d,p,nl,np,t,el,es:longint;\nbegin\n assign(f,fin); reset(f);\n read(f,n,k,l,c,d,p,nl,np);\n t:=(k*l div n);\n el:=c*d; es:=p div np;\n write(min(min(t,el),es) div n);\nend."}, {"source_code": "var i,n,k, l, c, d, p, nl,s,np,g,otv:longint;\nfunction mini(a,b,c:longint):longint;\nvar min:longint;\nbegin\nif a 0) and (lg > 0) and (sl > 0) do\n begin\n inc(r);\n lg:= lg - nl*n;\n sl:= sl - np*n;\n dl:= dl - n\n end;\n write(r-1)\nend."}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);\nEnd."}, {"source_code": "var\n min,x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;\n a:array[1..3] of longint;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n} readln(n,k,l,c,d,p,nl,np);\n min:=1000;\n t:=(k*l) div n;\n la:=c*d;\n s:=p div np;\n x1:=t div n;\n x2:=la div n;\n x3:=s div n;\n a[1]:=x1; a[2]:=x2; a[3]:=x3;\n for i:=1 to 3 do if a[i] -1 then\n write(min div n)\n else\n write('0');\nend."}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);\nEnd."}, {"source_code": "var\n x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n} readln(n,k,l,c,d,p,nl,np);\n t:=(k*l) div n;\n la:=c*d;\n s:=p div np;\n x1:=t div n;\n x2:=la div n;\n x3:=s div n;\n if (x1<=x2) and (x1<=x3)then writeln(x1) else\n if (x2<=x3) and (x2<=x1)then writeln(x2) else\n if (x3<=x2) and (x3<=x1)then writeln(x3);\nend.\n\n\n\n"}, {"source_code": "uses math;\nvar cn,v1,v2,n,k,l,c,d,p,nl,np:integer;\nbegin\nread(n,k,l,c,d,p,nl,np);\nv1:=k*l; v2:=c*d;\nwrite(min(min(v1 div nl,v2),p div np)div n);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar\n a,b,c,d,e,m,g,h,kq:longint;\n f:text;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,a,b,c,d,e,m,g,h);\n close(f);\nend;\nfunction min(i,j,k:longint):longint;\nbegin\n if (i0)and(dl>0)and(p>0) then\n else begin\n writeln(i);\n break;\n end\nend;\nend."}, {"source_code": "var\ni,n,k,l,c,d,p,nl,np,ob,dl:longint;\nbegin\nreadln(n,k,l,c,d,p,nl,np);\nob:=l*k;\ndl:=c*d;\n\nfor i:=0 to 1000000 do begin\n ob:=ob-n*nl;\n dec(dl,n);\n dec(p,n*np);\n if (ob>0)and(dl>0)and(p>0) then\n else begin\n writeln(i);\n break;\n end\nend;\nend."}, {"source_code": "var\n n,k,l,c,d,p,nl,np,Tost,vodka,zacus,sol:longint;\n f:boolean;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n Vodka:=k*l;\n Zacus:=c*d;\n Sol:=p;\n Tost:=0;\n while not f do\n begin\n vodka:=vodka-n*nl;\n zacus:=zacus-n;\n sol:=sol-n*np;\n if (vodka>0) and (zacus>0) and (sol>0) then inc(Tost)\n else begin writeln(Tost); f:=true; exit; end;\n end;\nend."}, {"source_code": "var\n n, k, l, c, d, p, nl, np,a1,a2,a3,ot:longint;\n o:boolean;\n\n\nbegin\n o:=True;\n read(n);\n read(k);\n read(l);\n read(c);\n read(d);\n read(p);\n read(nl);\n read(np);\n \n\n k:=k*l;\n if (nl=0) or (np=0) or (d=0) then o:=False;\n if k div nlsol then min:=sol;\n if min>laim then min:=laim\n else m:=gaz div 3;\n m:=min div n;\nwriteln(m);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n var\n i,j,k,l,m,p,d,c,nl,np,n,xml,xl,xp: int64;\nbegin\n read(n,k,l,c,d,p,nl,np);\n xml:=(k*l)div n;\n xl:=c*d;\n xp:=p div np;\n i:=10000000000000000;\n if i> (xl div n) then i:=(xl div n);\n if i> (xml div n) then i:=(xml div n);\n if i> (xp div n) then i:=(xp div n);\n\n write(i);\n \nend."}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);\nEnd."}, {"source_code": "var\n min,x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;\n a:array[1..3] of longint;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n} readln(n,k,l,c,d,p,nl,np);\n min:=1000;\n t:=(k*l) div n;\n la:=c*d;\n s:=p div np;\n x1:=t div n;\n x2:=la div n;\n x3:=s div n;\n a[1]:=x1; a[2]:=x2; a[3]:=x3;\n for i:=1 to 3 do if a[i] -1 then\n write(min div n)\n else\n write('0');\nend."}, {"source_code": "var\n y,i,j,n,m,k,z,t,x,s,min,l,c,d,p,nl,np:longint;\nbegin\n readln(n,k,l,c,d,p,nl,np);\n x:=l*k;\n y:=c*d;\n z:=p;\n while 0=0 do\n begin\n if(x<=0)or(y<=0)or(z<=0)then\n begin\n writeln(t-1);\n halt;\n end;\n dec(x,nl*n);\n dec(y,n);\n dec(z,np*n);\n inc(t);\n end;\nend.\n\n"}, {"source_code": "var w,n,m,r,p,t,k,y,x,f,d,min:longint;\nbegin\nreadln(n,m,p,r,t,k,y,x);\nmin:=1000;\nf:=(m*p)div n;\nw:=(p*r);\nd:=k div x;\nif min>f then min:=f;\nif min>t then min:=w;\nif min>d then min:=d;\nwrite(min/3:0:0);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n var\n a,b,c,d,i,j,n,k,l,p,nl,np,tost,v,tos,sol:Int64;\nbegin\n readln (n, k, l, c, d, p, nl, np);\n v:=k*l div n DIV N;\n tos:=c*d div n;\n sol:=p div np DIV n;\n j:=min(v,tos) ; a:=min(j,sol);\nWriteln (a);\n \nend.\n"}, {"source_code": "var n,k,j,c,d,p,nj,np,min,tg,tl,ts: integer;\nbegin\nreadln (n,k,j,c,d,p,nj,np);\ntg:=(k*j) div nj ;\ntl:=(c*d);\nts:=(p) div np ;\nif ((ts -1 then\n write(min div n)\n else\n write('0');\nend."}, {"source_code": "var n,k,j,c,d,p,nj,np,min,tg,tl,ts: integer;\nbegin\nreadln (n,k,j,c,d,p,nj,np);\ntg:=(k*j) div nj ;\ntl:=(c*d);\nts:=(p) div np ;\nif ((ts=n) and (la div i>=n) and (s div i>=n) then\n if i>max then max:=i;\n end;\n writeln(max);\nend.\n\n\n\n"}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);\nEnd."}, {"source_code": "program soft_drink;\n\nFunction min(a,b,c:longint):longint;\nbegin\n if (adol then min:=dol else min:=v;\nif min>sol then min:=sol;\nmin:=trunc(min);\nwriteln(min:0:0);\n\n\n\nend."}, {"source_code": "var\n x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n} readln(n,k,l,c,d,p,nl,np);\n t:=(k*l) div n;\n la:=c*d;\n s:=p div np;\n x1:=t div n;\n x2:=la div n;\n x3:=s div n;\n if (x1<=x2) and (x1<=x3)then writeln(x1) else\n if (x2<=x3) and (x2<=x1)then writeln(x2) else\n if (x3<=x2) and (x3<=x1)then writeln(x3);\nend.\n\n\n\n"}, {"source_code": "program aleksa;\nvar n,i,j,br,sum,sum2,sum3,res,min:Longint;\n niz:array[1..100] of Integer; \n s:String;\nbegin\n for i:=1 to 8 do read(niz[i]);\n sum:=niz[2]*niz[3] div niz[7];\n min:=sum;\n sum2:=niz[4]*niz[5];\n if sum2nl*3) and (d>1*3) and (p>np*3) do begin\nif b>nl*3 then b:=b-nl*n else break ;\nif d>1*n then d:=d-1*n else break ;\nif p>np*3 then p:=p-np*n else break ;\nk1:=k1+1 ;\nend ;\nwriteln(k1) ;\nend.\n"}, {"source_code": "Var\n n,k,l,p,c,d,nl,np,a,b,o: longint;\n \nBegin\n read(n,k,l,c,d,p,nl,np);\n a := ((k*l) div nl);\n b := (p div np);\n o := (c*d);\n if((a < b)and(a < o)) then\n begin\n write(a div n);\n exit;\n end;\n if((b < a)and(b < o)) then\n begin\n write(b div n);\n exit;\n end;\n if((o < b)and(o < a)) then\n begin\n write(o div n);\n exit;\n end;\n if((a = b)and(b = c)) then\n begin\n write(a div n);\n exit; \n end;\n write(0);\nEnd."}, {"source_code": "program contest107;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar n, k, l, c, d, p, nl, np,ll,laim,sol,ans : longint;\n\nfunction min (a,b,c : longint) : longint;\nbegin\n if (a < b) and (a < c) then\n min := a;\n if (b < a) and (b < c) then\n min := b;\n if (c < b) and (c < a) then\n min := c;\n\nend;\n\nbegin\n// reset(input,'input.txt');\n// rewrite(output,'output.txt');\n\n readln(n, k, l, c, d, p, nl, np);\n ll := (k * l) div nl;\n laim := c * d;\n sol := p div np;\n ans := min(ll,sol,laim) div n;\n writeln(ans);\n\n\n \nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,l,m,p,d,c,nl,np,n,xml,xl: integer;\nbegin\n read(n,k,l,c,d,p,nl,np);\n xml:=k*l div n;\n xl:=c*d;\n i:=100000000;\n if i> xl div n then i:=xl div n;\n if i> xml div n then i:=xml div n;\n if i> p div n then i:=p div n;\n\n write(i);\n \nend.\n"}, {"source_code": "uses math;\nVAR N,K,L,C,D,P,NL,NP,X,Z,Y:LONGINT;\nbegin\nreadln(N,K,L,C,D,P,NL,NP);\nZ:=(K*L) DIV NL;\ny:=C*D;\nX:=P DIV NP;\nWRITE(MIN(MIN(Z,Y),X)DIV 3);\nEND.\n"}, {"source_code": "VAr a,b,c,d,l,lp,mp,n,i,j,k,p,nl,np,k1 : longint ;\nbegin\nreadln(n,k,l,c,d,p,nl,np) ;\nb:=l*k ;\nwhile (b>=nl*n) and (d>=1*n) and (p>=np*n) do begin\nif b>=nl*n then b:=b-nl*n else break ;\nif d>=1*n then d:=d-1*n else break ;\nif p>=np*n then p:=p-np*n else break ;\nk1:=k1+1 ;\nend ;\nwriteln(k1) ;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar\nn,k,l,c,d,p,nl,np,i1,i2,i3,j:Integer;\nbegin\nReadln(n,k,l,c,d,p,nl,np);\ni1:=k*l div nl;\ni2:=c*d div n;\ni3:=p div n;\ni1:=min(i1,i2);\ni1:=min(i1,i3);\nWriteln(i1 div n);\nReadln(i1);\nend.\n"}, {"source_code": "program soft_drink;\n\nFunction min(a,b,c:longint):longint;\nbegin\n if (ah then min:=h;\n end; \n write(min div n);\nend. "}, {"source_code": "const\n fi='';\n fo='';\nvar\n n,k,l,c,d,p,nl,np,kq:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(n,k,l,c,d,p,nl,np);\n close(input);\nend;\n\nfunction tinh(x,y,z:longint; var min:longint):longint;\nbegin\n if x>y then min:=y else min:=x;\n if min>z then min:=z;\nend;\n\nprocedure xuly;\nbegin\n tinh((k*l) div n,c*d,p div np,kq);\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(kq div 3);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n k1:Int64;\n n,k,l,c,d,p,Ln,pn:Integer;\nbegin\n Readln(n,k,l,c,d,p,ln,pn);\n k1:=999999999;\n if (k*l)div(ln*n)h then min:=h;\n end; \n write(min div n);\nend. "}], "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1"} {"source_code": "var a,b,c:array[1..1000000] of int64;\n i,j,k:longint;\n m,m1,n,l,p:int64;\n s1,s2:ansistring;\n q:char;\n\n\n procedure rec(x,y,z:longint);\n begin\n z:=z+y;\n if x=length(s2) then begin\n inc(m1);\n if z=k then inc(m);\n exit;\n end;\n if s2[x+1]='?' then begin\n rec(x+1,-1,z);\n rec(x+1,1,z);\n end;\n if s2[x+1]='+' then begin\n rec(x+1,1,z);\n end;\n if s2[x+1]='-' then rec(x+1,-1,z);\n end;\n\n\n Begin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do if s1[i]='+' then inc(k) else dec(k);\n if s2[1]='?' then begin rec(1,1,0); rec(1,-1,0); end;\n if s2[1]='-' then rec(1,-1,0);\n if s2[1]='+' then rec(1,1,0);\n write(m/m1:0:10);\n end.", "positive_code": [{"source_code": "program codeforces_476B;\ntype niz=array[1..10] of integer;\nvar s1,s2:string;\n a:niz;\n i,j,br,br2,br3,p1,p2,p3:integer;\nfunction brojanje (var a:niz;n:integer):integer;\n var i,j:integer;\n begin\n i:=n;\n while (i>0) and (a[i]=1) do i:=i-1;\n if (i=0) then brojanje:=0\n else\n begin\n brojanje:=1;\n a[i]:=1;\n for j:=i+1 to n do a[j]:=0;\n end;\n end;\nbegin\n readln (s1);\n readln (s2);\n p1:=0;\n for i:=1 to length (s1) do\n if (s1[i]='+') then p1:=p1+1\n else p1:=p1-1;\n br:=0;\n p2:=0;\n for i:=1 to length (s2) do\n begin\n if (s2[i]='+') then p2:=p2+1\n else if (s2[i]='-') then p2:=p2-1\n else br:=br+1;\n end;\n for i:=1 to br do a[i]:=0;\n br2:=1;\n repeat\n p3:=0;\n for i:=1 to br do\n if (a[i]=1) then p3:=p3+1\n else p3:=p3-1;\n if (p2+p3=p1) then br3:=br3+1;\n br2:=br2+1;\n until (brojanje (a,br)=0);\n br2:=br2-1;\n writeln (br3/br2:2:12);\nend.\n"}, {"source_code": "//Balsa Knezevic\n//codeforces.com\n{Data su dva stringa iste duzine.Prvi string sastavljen je iz\n+ i -. Plus povecava njegovu koordinatu za 1, minus smanjuje.\nDrugi string se sastoji iz +,- i ?. Kolike su sanse\nda zamenom ? sa + ili - dobijemo istu krajnju poziciju kao\nu prvom stringu.}\nuses math;\nvar s1,s2:ansistring;\nk,p,q,step,znk,pok1,pok2,l,plus,minus,o,brojac,sol:int64;\ng:array[-1000..10000] of integer;\n\ni:longint;\nbegin\n readln(S1);\n readln(s2);\n\n for i:=1 to length(S1) do begin\n if (s1[i]='+') then inc(pok1) else dec(pok1);\n end;\n\n for i:=1 to length(s2) do begin\n if (s2[i]='+') then inc(pok2) else\n if (S2[i]='-') then dec(pok2) else\n inc(znk);\n end;\n\n //writeln(pok1,' ',pok2,' ',znk);\n\n if (pok1=pok2) and(znk=0) then begin\n writeln(1/1:0:12);\n exit;\n end;\n {\n if (pok1=pok2) and(znk mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n\n\n\n\n\n\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)>znk) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)<=znk) and\n (abs(znk-abs(pok1-pok2)) mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;}\n\n if (pok1<>pok2) and (abs(pok1-pok2)=znk)\n then begin\n step:=1;\n for i:=1 to znk do step:=step*2;\n writeln(1/step:0:12);\n exit;\n end;\n\n i:=znk;\n while i>0 do\nbegin\nif g[znk]=0 then g[znk]:=1\nelse\nbegin\ni:=znk;\nwhile g[i]=1 do\nbegin\ng[i]:=0;\ni:=i-1;\nend;\ng[i]:=1;\nend;\nif i>0 then\nbegin\nbrojac:=0;\nfor i:=1 to znk do begin\n if g[i]=1 then inc(brojac) else dec(brojac);\n end;\n if brojac+pok2=pok1 then inc(sol);\n\nend;\nend;\n step:=1;\nfor i:=1 to znk do step:=step*2;\nwriteln(sol/step:0:12);\n\n\nend.\n"}, {"source_code": "var cases,res:longint;\n st1,st2,st3:string;\n a:array[1..10] of longint;\n des,tmp,tmp1:longint;\n t:boolean;\n i,n:longint;\n\nprocedure check(x:string);\nvar i,tmp:longint;\nbegin\n tmp:=0;\n for i:=1 to length(x) do\n begin\n if x[i] = '-' then dec(tmp)\n else inc(tmp);\n end;\n if tmp=des then inc(res);\nend;\n\nprocedure attempt(i:longint);\nvar j:longint;\nbegin\n for j:=1 to 2 do\n begin\n if j =1 then st3[a[i]]:='+'\n else st3[a[i]]:='-';\n if i=tmp1 then check(st3)\n else attempt(i+1);\n end;\nend;\n\nbegin\n readln(st1);\n readln(st2);\n st3:=st2;\n des:=0;\n tmp:=0;\n n:=length(st2);\n for i:=1 to length(st1) do\n begin\n if st1[i] = '-' then dec(des)\n else inc(des);\n end;\n\n t:=false;\n tmp1:=0;\n for i:=1 to length(st2) do\n begin\n if st2[i]='?' then\n begin\n t:=true;\n\n inc(tmp1);\n a[tmp1]:=i;\n end\n else\n if st2[i]='-' then dec(tmp)\n else inc(tmp);\n end;\n cases:=1;\n for i:=1 to tmp1 do\n cases:=cases*2;\n\n if t=false then\n begin\n if tmp=des then write(1.00000000000:0:12)\n else write(0.00000000000:0:12);\n exit;\n end;\n\n attempt(1);\n if res=0 then write(res*1.000000000000:0:12)\n else write(res/cases:0:12);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K: Longint;\n\nbegin\n readln(a);\n readln(b);\n if a = '+++' then\n if b = '??-' then\n begin\n writeln('0.000000000000');\n halt;\n end;\n\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n\n if l = 0 then\n begin\n if n = m then writeln('1.000000000000');\n if n <> m then writeln('0.000000000000');\n halt;\n end;\n t1 := (n - m + l) div 2;\n t2 := l - t1;\n s := 1;\n for i := t1 + 1 to t1 + t2 do s := s * i;\n for i := 1 to t2 do s := s div i;\n\n\n K := 1;\n for i := 1 to l do\n begin\n K := K * 2;\n end;\n r := s / K;\n writeln(r:1:12);\n readln;\n\nend.\n"}, {"source_code": "uses math;\nvar s1,s2:ansistring;\nk,p,q,step,znk,pok1,pok2,l,plus,minus,o,brojac,sol:int64;\ng:array[-1000..10000] of integer;\n\ni:longint;\nbegin\n readln(S1);\n readln(s2);\n\n for i:=1 to length(S1) do begin\n if (s1[i]='+') then inc(pok1) else dec(pok1);\n end;\n\n for i:=1 to length(s2) do begin\n if (s2[i]='+') then inc(pok2) else\n if (S2[i]='-') then dec(pok2) else\n inc(znk);\n end;\n\n //writeln(pok1,' ',pok2,' ',znk);\n\n if (pok1=pok2) and(znk=0) then begin\n writeln(1/1:0:12);\n exit;\n end;\n\n if (pok1=pok2) and(znk mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n\n\n\n\n\n\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)>znk) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)<=znk) and\n (abs(znk-abs(pok1-pok2)) mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n if (pok1<>pok2) and (abs(pok1-pok2)=znk)\n then begin\n step:=1;\n for i:=1 to znk do step:=step*2;\n writeln(1/step:0:12);\n exit;\n end;\n i:=znk;\n while i>0 do\nbegin\nif g[znk]=0 then g[znk]:=1\nelse\nbegin\ni:=znk;\nwhile g[i]=1 do\nbegin\ng[i]:=0;\ni:=i-1;\nend;\ng[i]:=1;\nend;\nif i>0 then\nbegin\nbrojac:=0;\nfor i:=1 to znk do begin\n if g[i]=1 then inc(brojac) else dec(brojac);\n end;\n if brojac+pok2=pok1 then inc(sol);\n\nend;\nend;\n step:=1;\nfor i:=1 to znk do step:=step*2;\nwriteln(sol/step:0:12);\n\n\nend."}, {"source_code": "var\nss,s:string;\ni:longint;\n\np,q,qq,nez,x,otr,plus,kol:int64;\nbegin\nreadln(s);\nreadln(ss);\nfor i:=1 to length(s) do if s[i]='+' then inc(plus)\nelse\ninc(otr);\n\nfor i:=1 to length(ss) do begin\n if ss[i]='+' then dec(plus);\n if ss[i]='-' then dec(otr);\n if ss[i]='?' then inc(nez);\nend;\nx:=1;\nfor i:=1 to nez do x:=x*2;\n\nif (plus<0)or(otr<0) then writeln(0)\nelse begin\np:=1;\nfor i:=plus+1 to nez do p:=p*i;\nq:=1;\nfor i:=1 to (nez-plus) do q:=q*i;\nqq:=round(p/q);\nwriteln(qq/x:0:11);\nend;\nend."}, {"source_code": "\nprogram B467;\nvar\n s1, s2: string;\n p1, p2, i: longint;\n mauso, tuso: real;\n free: array[1..11] of boolean;\n\nprocedure check;\nvar i: longint;\n\nbegin\n// writeln(free[1]);\n// writeln(s2);\n p2 := 0;\n // code goes here\n for i := 1 to length(s2) do\n if s2[i] = '+' then inc(p2) else dec(p2);\n mauso := mauso + 1;\n if p2 = p1 then tuso := tuso+1;\nend;\n\nprocedure Ttry(i: longint);\nvar j: longint;\nbegin\n if i-1 = length(s1) then check\n else begin\n for j := 0 to 1 do begin\n if free[i] then begin\n if j = 0 then s2[i] := '-'\n else s2[i] := '+'\n end;\n Ttry(i+1)\n end;\n end;\nend;\nbegin\n readln(s1);\n readln(s2);\n if s2 = '?' then begin writeln(0.500000); exit; end;\n fillchar(free, sizeof(free), FALSE);\n for i := 1 to length(s1) do\n if s1[i] = '+' then inc(p1) else dec(p1);\n for i := 1 to length(s2) do\n if s2[i] = '?' then free[i] := true;\n Ttry(1);\n\n writeln((tuso/mauso):0:9);\n readln\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar a:array [1..10] of integer;\n x,y:string; pos,dem,tam,thoa:longint;\n f:text;\nprocedure nhap;\nvar i,j:longint;\nbegin\n pos:=0; dem:=0; tam:=0; thoa:=0;\n assign(f,fi); reset(f);\n readln(f,x);\n for i:=1 to length(x) do\n if (x[i]='+') then inc(pos) else dec(pos);\n readln(f,y);\n for j:=1 to length(y) do\n if (y[j]='?') then inc(dem)\n else if (y[j]='+') then inc(tam) else dec(tam);\n close(f);\nend;\nprocedure count(b:longint);\nvar sum,i,j:longint;\nbegin\n for i:=0 to 1 do\n begin\n a[b]:=i;\n if (b=dem) then\n begin\n sum:=0;\n for j:=1 to dem do\n if (a[j]=0) then inc(sum) else dec(sum);\n if (tam+sum=pos) then inc(thoa);\n end else count(b+1);\n end;\nend;\nprocedure xuat;\nvar kq:real; i,k,mu:longint;\nbegin\n assign(f,fo); rewrite(f);\n if (dem=0) then if (tam=pos) then\n begin\n writeln(f,1);\n close(f);exit;\n end else\n begin\n writeln(f,0);\n close(f); exit;\n end;\n count(1); mu:=1;\n for i:=1 to dem do mu:=mu*2;\n kq:=thoa/mu;\n writeln(f,kq:0:1000000000);\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "var\nss,s:string;\ni:longint;\n\np,q,qq,nez,x,otr,plus,kol:int64;\nbegin\nreadln(s);\nreadln(ss);\nfor i:=1 to length(s) do if s[i]='+' then inc(plus)\nelse\ninc(otr);\n\nfor i:=1 to length(ss) do begin\n if ss[i]='+' then dec(plus);\n if ss[i]='-' then dec(otr);\n if ss[i]='?' then inc(nez);\nend;\nx:=1;\nfor i:=1 to nez do x:=x*2;\n\nif (plus<0)or(otr<0) then writeln(0)\nelse begin\np:=1;\nfor i:=plus+1 to nez do p:=p*i;\nq:=1;\nfor i:=1 to (nez-plus) do q:=q*i;\nqq:=round(p/q);\nwriteln(qq/x:0:11);\nend;\nend."}, {"source_code": "var i,n,m,x,y,z,v:integer; s:string; r:real;\nprocedure rec(a,b:integer);\nbegin\n if b=z\n then begin\n inc(v);\n if a=y\n then inc(m);\n end\n else begin\n Rec(a+1,b+1);\n Rec(a-1,b+1);\n end;\nend;\nbegin\n// reset(input,'input.txt');\n// assign(output,'output.txt');\n readln(s);\n n:=length(s);\n x:=0;\n y:=0;\n m:=0;\n v:=0;\n for i:=1 to n do\n begin\n if s[i]='+'\n then inc(x)\n else dec(x);\n end;\n readln(s);\n for i:=1 to n do\n begin\n if s[i]='?'\n then inc(z)\n else if s[i]='+'\n then inc(y)\n else dec(y);\n end;\n y:=abs(x-y);\n if z>0 then Rec(0,0)\n else if y=0\n then begin\n write(1);\n halt(0);\n end\n else begin\n write(0);\n halt(0);\n end;\n r:=m/v;\n Write(r:0:9);\nend."}, {"source_code": "Var s,s1:string;p,i,kol,kolp:longint;\nProcedure rec(ps,tk:longint);\nBegin\n if ps=length(s1)+1 then\n begin\n inc(kol);\n if tk=p then\n inc(kolp);\n exit;\n end;\n if s1[ps]='?' then\n begin\n rec(ps+1,tk+1);\n rec(ps+1,tk-1);\n end\n else\n if s1[ps]='+' then\n rec(ps+1,tk+1)\n else\n rec(ps+1,tk-1);\nend;\nbegin\n// assign(input,'input.txt');assign(Output,'output.txt');\n readln(s);\n p:=0;\n for i:=1 to length(s) do\n if s[i]='+' then\n inc(p)\n else\n dec(p);\n readln(s1);\n kol:=0;kolp:=0;\n rec(1,0);\n writeln(kolp/kol:0:10);\nend."}, {"source_code": "var\n s,s1:string;\n f:array[-1..2000,-1..2000]of extended;\n n,m,i,j,sp,sm,s1m,s1p:longint;\nfunction rec(i,j:longint):longint;\nbegin\n if i+j=n then\n begin\n if(i=sp-s1p)and(j=sm-s1m)then rec:=1 else rec:=0;\n exit;\n end;\n rec:=rec(i+1,j)+rec(i,j+1);\nend;\nbegin\n readln(s);\n readln(s1);\n for i:=1to length(s)do if s[i]='+'then inc(sp)else inc(sm);\n for i:=1to length(s1)do\n if s1[i]='+'then inc(s1p)else if s1[i]='-'then inc(s1m)else inc(n);\n writeln((rec(0,0)/(1 shl n)):0:10);\nend.\n"}, {"source_code": "var a,a1:string;\n b:array[1..100]of LongInt;\n i:LongInt;\n norm,gg,vop,use,prav:LongINt;\n\nprocedure rec(x,sum:LongInt);\nBegin\n if(x=vop+1)then begin inc(use); if(sum=norm)then inc(prav); exit; end;\n rec(x+1,sum-1);\n rec(x+1,sum+1);\nEnd;\n\nBegin\n ReadLn(a);\n for i:=1 to length(a)do\n if(a[i]='+')then inc(norm)\n else dec(norm);\n ReadlN(a1);\n for i:=1 to length(a1)do\n if(a1[i]='+')then inc(gg)\n else if(a1[i]='-')then dec(gg)\n else inc(vop);\n rec(1,gg);\n\n Write((prav/use):0:15);\nEnd."}, {"source_code": "var f1:text;x,m,i,dem,k,l,w:integer;s1,s2:string;\nprocedure dq(j,h:integer);\nbegin\n if j>length(s2) then begin if h=x then inc(dem);inc(l);exit;end;\n if s2[j]='+' then begin inc(h,1);dq(j+1,h);end else\n if s2[j]='-' then begin dec(h,1);dq(j+1,h);end else\n begin\n dq(j+1,h+1);\n dq(j+1,h-1);\n end;\nend;\nbegin\n assign(f1,'');reset(f1);\n readln(f1,s1);\n readln(f1,s2);\n x:=0;m:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(x,1) else dec(x,1);\n w:=0;\n for i:=1 to length(s2) do\n if s2[i]='?' then inc(m,1) else\n if s2[i]='+' then inc(w,1) else\n dec(w,1);\n if m=0 then\n begin\n if w=x then write('1.000000000000')\n else write('0.000000000000');\n halt;\n end;\n k:=0;dem:=0;l:=0;\n for i:=1 to length(s2) do\n if s2[i]='+' then inc(k,1) else\n if s2[i]='-' then dec(k,1) else\n begin dq(i,k);break;end;\n write(dem/l:1:12);\nend.\n"}, {"source_code": "var\n i, c, c2, q, ans:longint;\n s1, s2:string;\nprocedure search(k, s:int64);\nbegin\n if k=q+1 then\n begin\n if s=c then inc(ans);\n exit;\n end;\n search(k+1, s+1);\n search(k+1, s-1);\nend;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(c) else dec(c);\n for i:=1 to length(s2) do\n case s2[i] of\n '?':inc(q);\n '+':inc(c2) \n else dec(c2);\n end;\n search(1, c2);\n writeln(ans/(1 shl q):0:9);\nend."}, {"source_code": "\nvar s,st:string;\n i,j,n,k,dem1,dem2,d,dem3,dem4:longint;\n kq:real;\nfunction C(v,u:longint):real;\n var x,y:longint;\n begin\n x:=1; y:=1;\n for j:=u downto u-v+1 do\n x:=x*j;\n for j:=1 to v do\n y:=y*j;\n C:=x div y;\n end;\nbegin\n readln(s);\n readln(st);\n dem1:=0;dem2:=0; dem3:=0; dem4:=0; n:=0;\n for i:=1 to length(st) do\n begin\n if s[i]='+' then inc(dem1);\n if s[i]='-' then inc(dem2);\n end;\n for i:=1 to length(s) do\n begin\n if st[i]='?' then inc(n);\n if st[i]='+' then inc(dem3);\n if st[i]='-' then inc(dem4);\n end;\n kq:=0;\n if (dem4>dem2) or (dem3>dem1) then write(kq:0:10)\n else\n begin\n k:=dem2-dem4;\n if dem1-dem3>k then k:=dem1-dem3;\n write(C(k,n)/(1 shl n):0:10);\n\n\n end;\nend.\n"}, {"source_code": "const\n tfi='';\n tfo='';\n\nvar\n fi,fo:text;\n v,d,s:longint;\n a,b:string;\n\nprocedure tryy(i,u:longint);\n var j:longint;\n begin\n if i=length(b)+1 then\n begin\n inc(s);\n if u=v then inc(d);\n exit;\n end;\n if b[i]='+' then tryy(i+1,u+1);\n if b[i]='-' then tryy(i+1,u-1);\n if b[i]='?' then\n begin\n tryy(i+1,u+1);\n tryy(i+1,u-1);\n end;\n end;\n\n\nprocedure xuli;\n var x:extended;\n i:longint;\n begin\n readln(fi,a);\n readln(fi,b);\n for i:=1 to length(a) do if a[i]='+' then inc(v) else dec(v);\n s:=0;\n d:=0;\n tryy(1,0);\n if s=0 then writeln(fo,0)\n else\n begin\n x:=d/s;\n writeln(fo,x:12:12);\n end;\n end;\n\n\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var s1,s2:String;\n sum1,sum2,s,h,a,b,i:Longint;\nFunction Tohop(a,b:Longint):Longint;\n Var t,i:Longint;\n Begin\n t:=1;\n For i:=a+1 to b do t:=t*i;\n For i:=2 to (b-a) do t:=t div i;\n Exit(t);\n End;\nBEGIN\n// Assign(input,'test.inp'); Reset(input);\n// Assign(output,'test.out'); Rewrite(output);\n Readln(S1);Readln(s2); sum1:=0; sum2:=0; s:=0;\n For i:=1 to length(s1) do\n If S1[i] = '+' then Inc(sum1) Else Dec(sum1);\n For i:=1 to length(s2) do\n Case S2[i] of\n '+' : Inc(sum2);\n '-' : Dec(sum2);\n '?' : Inc(s);\n End;\n If (s = 0) then\n If (sum1 = sum2) then Writeln('1.000000000000')\n Else Writeln('0.000000000000')\n Else\n Begin\n h:=sum1-sum2;\n a:=(s+h) div 2;\n b:=(s-h) div 2;\n If (a<0)or(b<0) then Writeln('0.000000000000')\n Else\n Writeln(Tohop(a,a+b)/(1 shl s):0:12);\n End;\nEND."}, {"source_code": "var s,s1:string;res,res1,p,i,ans,ukupno,poz:longint;\n begin\n readln(s);\n readln(s1);\n for i:=1 to length(s1) do\n If s1[i]='?' then inc(p) else\n If s1[i]='-' then dec(res) else inc(res);\n for i:=1 to length(s) do\n If s[i]='+' then inc(res1) else dec(res1);\n If p=0 then\n begin\n If res=res1 then writeln(1.00000000000) else writeln(0.00000000000);\n exit;\n end\n else\n begin\n ukupno:=1;\n for i:=1 to p do\n ukupno:=ukupno*2;\n If (p-abs(res-res1)<0) or ((p-abs(res-res1)) mod 2<>0) then writeln(0.00000000000) else\n begin\n poz:=(p-abs(res-res1)) div 2;\n If poz=0 then writeln(1/ukupno) else\n begin\n ans:=1;\n for i:=1 to poz do\n ans:=ans*(p-i+1);\n for i:=1 to poz do\n ans:=ans div i;\n\n writeln(ans/ukupno);\n end;\n end;\n end;\n end.\n\n"}, {"source_code": "var s1,s2:string;\n i,j,n,len,mov,anspos,finpos,dis,m:longint;\n ans,c:real;\n\nbegin\n readln(s1);\n readln(s2);\n n:=length(s1);\n \n for i:=1 to n do\n if s1[i] = '+' then inc(anspos)\n else dec(anspos);\n \n for i:=1 to n do \n if s2[i] = '?' then inc(mov)\n else if s2[i] = '+' then inc(finpos)\n else dec(finpos);\n \n dis:=anspos-finpos;\n \n if ((dis+mov) mod 2 <> 0) and (mov< abs(dis))\n then ans:=0\n else\n begin\n m:=(mov+abs(dis)) div 2;\n c:=1;\n for i:=0 to m-1 do \n c:= c* (mov-i);\n for i:=2 to m do\n c:= c/i;\n ans:=c / (1 shl mov); \n end;\n writeln(ans);\nend."}, {"source_code": "Program CFDreamoonAndWifi;\ntype vector=array[0..10000] of char;\nvar i, n, r1, r2, v, c:integer;\n a, b:vector;\n yes:boolean;\nprocedure Compara(r2, r1:integer);\nbegin\n if r2=r1 then\n begin\n c:=c+1;\n end\nend;\nprocedure Citire;\nvar l, m:integer;\nbegin\n l:=0;\n a[0]:='+';\n while a[l] in ['+', '-', '?'] do\n begin\n l:=l+1;\n read(a[l]);\n end;\n n:=l-1;\n for m:=1 to n do\n b[m]:='X'\nend;\nprocedure AfisareMem;\nvar l:integer;\nbegin\n for l:=1 to n do\n begin\n if b[l]='X' then b[l]:=a[l];\n end;\n v:=v+1;\nend;\nprocedure Calcul(b:vector);\nvar k, r:integer;\nbegin\n r:=0;\n for k:=1 to n do\n if b[k]='-' then r:=r+1;\n r:=n-r-r;\n r1:=r;\n if yes then\n Compara(r2, r1);\nend;\nprocedure GenCod(j:integer);\nbegin\n if j>n then\n begin\n AfisareMem;\n Calcul(b);\n end\n else\n begin\n if a[j]='?' then\n begin\n b[j]:='+';\n GenCod(j+1);\n end;\n if a[j]='?' then\n b[j]:='-';\n GenCod(j+1);\n end;\nend;\n\nbegin\n yes:=false;\n c:=0;\n v:=0;\n Citire;\n GenCod(1);\n r2:=r1;\n readln;\n yes:=true;\n v:=0;\n Citire;\n GenCod(1);\n writeln(c/v:1:12);\n readln;\n readln\nend.\n"}, {"source_code": "program pro476B;\nvar dem,dung,tatca:longint;\n s1,s2:string;\n kq:real;\n d:array[1..2] of char;\n x:array[1..100] of char;\n{---------------------------------}\nprocedure doc;\nbegin\n readln(s1);\n readln(s2);\nend;\n{---------------------------------}\nprocedure ghi;\nbegin\n write(kq:0:9);\nend;\n{---------------------------------}\nprocedure xetnghiem;\nvar i,k,tong1,tong2,p:longint;\n s3:string;\nbegin\n s3:=s2;\n tong1:=0;tong2:=0;\n for i:=1 to dem do\n begin\n p:=pos('?',s3);\n delete(s3,p,1);\n insert(x[i],s3,p);\n end;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(tong1) else dec(tong1);\n for i:=1 to length(s3) do\n if s3[i]='+' then inc(tong2) else dec(tong2);\n if tong1=tong2 then\n begin\n inc(dung);\n inc(tatca);\n end else inc(tatca);\nend;\n{---------------------------------}\nprocedure dequy(i:longint);\nvar j:longint;\nbegin\n for j:=1 to 2 do\n begin\n x[i]:=d[j];\n if i=dem then xetnghiem else dequy(i+1);\n end;\nend;\n{-----------------------------------}\nprocedure xuli;\nvar i:longint;\nbegin\n dem:=0;\n for i:=1 to length(s2) do if s2[i]='?' then inc(dem);\n if dem=0 then xetnghiem else dequy(1);\n kq:=dung/tatca;\nend;\n{---------------------------------}\nbegin\n doc;\n d[1]:='+';\n d[2]:='-';\n xuli;\n ghi;\nend.\n"}, {"source_code": "const Fi='';\nvar inp:text;\n s1,s2:string;\n i,s,dem,dem1,tar,n:longint;\nprocedure doc;\nbegin\n assign(inp,Fi);reset(inp);\n readln(inp,s1);\n readln(inp,s2);\n close(inp);\nend;\nprocedure try1(i:longint);\nvar j:longint;\nbegin\n if s2[i]='?' then\n for j:=0 to 1 do\n begin\n if j=0 then inc(s);\n if j=1 then dec(s);\n if i=n then\n begin\n inc(dem);\n if s=tar then inc(dem1);\n end else try1(i+1);\n if j=0 then dec(s);\n if j=1 then inc(s);\n end\n else\n begin\n if s2[i]='+' then inc(s);\n if s2[i]='-' then dec(s);\n if i=n then\n begin\n inc(dem);\n if s=tar then inc(dem1);\n end else try1(i+1);\n if s2[i]='+' then dec(s);\n if s2[i]='-' then inc(s);\n end;\n\nend;\nprocedure main;\nbegin\n n:=length(s1);\n dem:=0;dem1:=0;s:=0;tar:=0;\n for i:=1 to n do\n begin\n if s1[i]='+' then inc(tar);\n if s1[i]='-' then dec(tar);\n end;\n try1(1);\n writeln(dem1/dem:0:12);\nend;\nbegin\n doc;\n main;\nend."}, {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//476B.INP';\n Fo='';//476B.OUT';\nVar s1,s2:String;\n a,Gt:Array[0..11] of Longint;\n F:Array[-11..11,0..11] of Real;\n C:Array[0..11,0..11] of Longint;\n COunt1,Count2,Count:Longint;\n\nProcedure Init;\nVar j,i:Longint;\nBegin\n a[1]:=2;\n For i:=2 to 11 do\n a[i]:=a[i-1]*2;\n Gt[0]:=1;\n For i:=1 to 10 do\n Gt[i]:=Gt[i-1]*i;\n\n For i:=1 to 10 do\n For j:=i downto 0 do\n C[j,i]:=(Gt[i] div (Gt[i-j]*Gt[j]));\n C[0,0]:=0;\n\n For i:=10 downto 0 do\n For j:=1 to 10 do\n If j0 then\n Begin\n F[i,j]:=0;\n F[-i,j]:=0;\n End\n Else\n Begin\n F[i,j]:=C[(j-i) div 2,j]/a[j];\n F[-i,j]:=F[i,j];\n End;\nEnd;\n\nProcedure Enter;\nVar i:Longint;\nBegin\n Readln(s1);\n Readln(s2);\nEnd;\n\nProcedure Main;\nVar j,i:Longint;\nBegin\n Init;\n COunt1:=0;\n Count2:=0;\n COunt:=0;\n For i:=1 to length(s1) do\n Begin\n Case s1[i] of\n '+':Inc(Count1);\n '-':Dec(Count1);\n End;\n Case s2[i] of\n '+':Inc(Count2);\n '-':Dec(Count2);\n '?':Inc(Count);\n End;\n End;\n If (COunt=0) and (COunt1=COunt2) then\n Writeln(1.0:0:12)\n Else\n If (Count=0) or (Count1-Count2>10) then Writeln('0.000000000000')\n Else\n If F[Count1-COunt2,Count]=0 then\n Writeln('0.000000000000')\n Else\n Writeln(F[Count1-Count2,Count]:0:12);\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n Main;\n\n Close(Input);\n Close(Output);\nEND.\n"}, {"source_code": "program zzzz;\nvar s1,s2:string;\n n1,n2,i,j,nv,k:integer;\n ans,x,t:real;\n a:array[0..10] of longint;\nbegin\n readln(s1);\n readln(s2);\n if pos('?',s2)=0 then\n begin\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then inc(n1)\n else dec(n1);\n if s2[i]='+' then inc(n2)\n else dec(n2);\n\n end;\n if n1=n2 then begin write(1); halt; end\n else begin write(0); halt; end;\n\n\n\n end;\n\n\n\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then inc(n1)\n else dec(n1);\n if s2[i]='+' then inc(n2)\n else if s2[i]='-' then dec(n2)\n else inc(nv);\n end;\n if abs(n2-n1)>nv then begin write(0); halt; end;\n a[1]:=1; a[0]:=1;\n for i:=2 to 10 do\n a[i]:=a[i-1]*i;\n // write(n1,' ',n2);\n n1:=(nv-abs(n1-n2)) div 2;\n // if n1=0 then\n // n1:=nv div 2;\n k:=1;\n for i:=1 to nv do\n k:=k*2;\n x:=a[nv]/(a[n1]*a[nv-n1]);\n ans:=x/k;\n write(ans:0:10);\n //write(nv,' ',n1);\n\nend.\n"}, {"source_code": "var s1,s2:string;\n d,i,k,t,ii,k1,k0:longint;\n dd:real;\nbegin\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s1) do\n if s1[i]='+' then inc(k) else dec(k);\nfor i:=1 to length(s1) do\n if s2[i]='+' then dec(k) else\n if s2[i]='-' then inc(k) else inc(t);\nif abs(k)>t then write(0.000000000) else\n begin\n d:=1;\n for i:=1 to t do\n d:=d*2;\n for i:=0 to d-1 do\n begin\n ii:=i;\n k1:=0;\n k0:=0;\n while ii>0 do\n begin\n if odd(ii) then inc(k1);\n ii:=ii div 2;\n end;\n k0:=t-k1;\n if k0*-1+k1 = k then dd:=dd+1;\n end;\n write(dd/d:0:12);\n end;\nend."}, {"source_code": "var\n s1,s2:ansistring;\n sum1,sum2,c,dem,hieu:longint;\n\nfunction tohop(k,n:longint):longint;\nvar tu,mau1,mau2,i:longint;\nbegin\n tu:=1;\n for i:=1 to n do tu:=tu*i;\n mau1:=1;\n for i:=1 to k do mau1:=mau1*i;\n mau2:=1;\n for i:=1 to n-k do mau2:=mau2*i;\n exit(tu div (mau1*mau2));\nend;\n\nprocedure nhapdem;\nvar l,i,j:longint;\nbegin\n sum1:=0; sum2:=0; dem:=0;\n readln(s1); readln(s2);\n l:=length(s1);\n for i:=1 to l do\n begin\n if s1[i]='+' then inc(sum1)\n else dec(sum1);\n end;\n for j:=1 to l do\n begin\n if s2[j]='+' then inc(sum2);\n if s2[j]='-' then dec(sum2);\n if s2[j]='?' then inc(dem);\n end;\n hieu:=sum1-sum2;\nend;\n\nfunction xuli:real;\nvar kq:real; i,plus,minus,sth:longint;\nbegin\n sth:=1;\n for i:=1 to dem do sth:=sth*2;\n if (dem=0) and (hieu=0) then exit(1);\n if (dem=0) and (hieu<>0) then exit(0);\n if (dem>0 ) then\n begin\n if (abs(dem-hieu) mod 2 =0) and (abs(dem+hieu) mod 2 = 0) then\n begin\n plus:=(dem+hieu) div 2;\n minus:=(dem-hieu) div 2;\n if minus=0 then exit(1/sth);\n kq:=tohop(plus,dem)/sth;\n exit(kq);\n end\n else exit(0);\n end\n else exit(0);\nend;\n\nbegin\n nhapdem;\n writeln(xuli);\nend."}, {"source_code": "var S1,S2:string;\n a,b,c:longint;\n i:longint;\n kq:longint;\n temp:real;\n\nfunction gt(r:longint):longint;\nvar i:longint;\n t:int64;\nbegin\n t:=1;\n for i:=1 to r do t:=t*i;\n exit(t);\nend;\n\nfunction Tinh(c,a:longint):longint;\nvar i:longint;\nbegin\n kq:=1;\n for i:=1 to a do kq:=kq*(c-i+1);\n kq:=kq div gt(a);\nend;\n\nbegin\n readln(S1);\n readln(S2);\n a:=0;\n b:=0;\n c:=0;\n for i:=1 to length(S1) do\n begin\n if S1[i]='+' then inc(a);\n if S1[i]='-' then inc(b);\n end;\n for i:=1 to length(S2) do\n begin\n if S2[i]='+' then dec(a);\n if S2[i]='-' then dec(b);\n if S2[i]='?' then inc(c);\n end;\n temp:=0;\n if (a<0) or (b<0) or (a+b<>c) then\n begin\n writeln(temp:0:12);\n exit;\n end\n else\n writeln(Tinh(c,a)/(1 SHL c):0:12);\nend.\n"}, {"source_code": "var s1,s2: string;\n n,a1,i,b1,a2,b2,c: longint;\n r: real;\nfunction gt(k: longint) : int64;\nvar i: longint;\n n: int64;\nbegin\n n:=1;\n for i:=1 to k do n:=n*i;\n exit(n);\nend;\nfunction nCr(n,r: longint) : int64;\nvar i: longint;\n kq: int64;\nbegin\n kq:=1;\n for i:=1 to r do kq:=kq*(n-i+1);\n kq:=kq div gt(r);\nend;\n\nbegin\n readln(s1);\n readln(s2);\n n:= length(s1);\n a1:=0;a2:=0;b1:=0;b2:=0;c:=0;\n for i:=1 to n do\n begin\n if (s1[i] = '+') then inc(a1)\n else if s1[i]='-' then inc(b1);\n if (s2[i] = '+') then inc(a2)\n else if s2[i]='-' then inc(b2)\n else inc(c);\n end;\n if (a1c) then\n begin\n r:=0;\n write(r:0:12);\n\n end else\n write(nCr(c,a1-a2) / (1 SHL c):0:12);\nend."}, {"source_code": "var\n s1,s2,tg:string;\n n,m,i,j,count,cont,xx:longint;\n res:extended;\n x,dd:array[1..10] of longint;\nprocedure perfect;\nvar i,t:longint;\nbegin\n t:=0;\n for i:=1 to n do\n if x[i]=1 then t:=t+1 else t:=t-1;\n if t=cont then inc(count);\nend;\nprocedure try1(i:longint);\nvar j:longint;\nbegin\n if i=n+1 then\n begin\n perfect;\n exit;\n end;\n for j:=0 to 1 do\n begin\n x[i]:=j;\n try1(i+1);\n end;\nend;\nbegin\n readln(s1);\n readln(s2);\n i:=1; \n while not false do\n begin\n m:=0;\n if s2[i] <> '?' then\n begin\n for j:=1 to length(s1) do\n if s2[i]=s1[j] then\n begin\n delete(s2,i,1);\n delete(s1,j,1);\n m:=1;\n break;\n end;\n if m=0 then break;\n end\n else inc(i);\n if length(s2)=0 then break;\n end;\n if length(s2)=0 then\n begin\n res:=1;\n writeln(res:0:12);\n halt;\n end;\n for i:=1 to length(s2) do\n if s2[i] <> '?' then\n begin\n res:=0;\n writeln(res:0:12);\n halt;\n end;\n n:=length(s1); m:= length(s2);\n for i:=1 to n do\n if s1[i]='+' then inc(cont) else dec(cont);\n try1(1);\n xx:=1;\n for i:=1 to m do xx:=2*xx;\n writeln((count / xx):0:12);\nend.\n"}, {"source_code": "{$COPERATORS ON}\n\nVAR i,j,p : integer;\n s : string;\n a,b : array [-11..11] of double;\n\nBEGIN\n readln(s);\n \n p := 0;\n for i := 1 to length(s) do\n if s[i] = '+' then\n p += 1\n else\n p -= 1;\n \n for i := -11 to 11 do\n a[i] := 0;\n a[0] := 1;\n \n readln(s);\n for i := 1 to length(s) do\n if s[i] = '+' then\n for j := 10 downto -10 do\n a[j] := a[j-1]\n else if s[i] = '-' then\n for j := -10 to 10 do\n a[j] := a[j+1]\n else begin\n for j := -10 to 10 do\n b[j] := (a[j-1] + a[j+1])/2;\n for j := -10 to 10 do\n a[j] := b[j]\n end;\n \n writeln(a[p]:0:9)\nEND."}, {"source_code": "var\n\tdata:array [0..15] of boolean;\n\ti,j,n:longint; points1,points2:longint; prob:real;\n\ts1,s2:string; Ndata:longint; pangkat:longint; tot:longint; temp:longint;\n\nprocedure cekpangkat (x:longint);\nvar\n\ti,j:longint;\nbegin\n\ti:=1;\n\twhile x > 0 do\n\t\tbegin\n\t\t\tif x mod 2 <> 0 then data[i]:=true else data[i]:=false;\n\t\t\tx:=x div 2;\n\t\t\ti:=i+1;\n\t\tend;\nend;\n\nbegin\n\treadln (s1);\n\treadln (s2);\n\tpoints1:=0;\n\tpoints2:=0;\n\tfor i:=1 to length (s1) do\n\t\tbegin\n\t\t\tif s1[i]='+' then points1:=points1+1;\n\t\t\tif s1[i]='-' then points1:=points1-1;\n\t\tend;\n\tfor i:=1 to length (s2) do\n\t\tbegin\n\t\t\tif s2[i]='+' then points2:=points2+1;\n\t\t\tif s2[i]='-' then points2:=points2-1;\n\t\t\tif s2[i]='?' then Ndata:=Ndata+1;\n\t\tend;\n\tpangkat:=1;\n\t\tif Ndata <> 0 then begin\n\t\tfor i:=2 to Ndata+1 do\n\t\t\tbegin\t\n\t\t\t\tpangkat:=pangkat*2;\n\t\t\tend;\n\t\tfor i:=1 to pangkat do\n\t\t\tbegin\n\t\t\t\tfor j:=1 to Ndata do data[j]:=false;\n\t\t\t\tcekpangkat (i);\n\t\t\t\ttemp:=points2;\n\t\t\t\tfor j:=1 to Ndata do\n\t\t\t\t\tbegin\n\t\t\t\t\t\tif data[j] = false then temp:=temp-1 else temp:=temp+1;\n\t\t\t\t\tend;\n\t\t\t\tif temp = points1 then tot:=tot+1;\n\t\t\tend;\n\t\tprob:=tot/pangkat;\n\t\twriteln (prob:0:12);\n\t\tend\n\telse\n\t\tbegin\n\t\t\tif points1<> points2 then prob:=0 else prob:=1;\n\t\t\twriteln (prob:0:12);\n\t\tend\nend.\t\n\n"}, {"source_code": "const {fi='checking.inp';\n fo='checking.out';}\n d:array[1..2]of integer=(-1,1);\nvar s1,s2:string;\n p,po,dem:integer;\n cnt:longint;\n{------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend; }\n{------------------------------}\n{procedure closefiles;\nbegin\n close(input);close(output);\nend;}\n{-------------------------}\nprocedure stdin;\nbegin\n readln(s1);\n readln(s2);\nend;\n{------------------------------------}\nprocedure backtrack(x:longint);\nvar i:longint;\nbegin\n if (x=0) and (po=p) then inc(cnt);\n for i:=1 to 2 do\n begin\n inc(po,d[i]);\n if (x>0) then backtrack(x-1);\n dec(po,d[i]);\n end;\n\nend;\n{-------------------------------}\nfunction lt(y:integer):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=1 to y do s:=s*2;\n exit(s);\nend;\n{-------------------------------}\nprocedure process;\nvar kq:real;\n i:longint;\nbegin\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(p) else dec(p);\n\n for i:=1 to length(s2) do\n begin\n if s2[i]='+' then inc(po)\n else if s2[i]='-' then dec(po);\n if s2[i]='?' then inc(dem);\n end;\n\n if (dem<>0)then\n begin\n backtrack(dem);\n kq:=cnt/lt(dem);\n end\n else if (po=p)then kq:=1;\n\n writeln(kq);\n\nend;\n{---------------------------------}\nBEGIN\n { openfiles; }\n stdin;\n process;\n { closefiles;}\nEND.\n"}, {"source_code": "var s2,s1:string;\ni,dem,dem1,c,x,y:longint;\n{----------------}\nfunction gt(x:Longint):int64;\nbegin\n if x<=1 then gt:=1\n else gt:=gt(x-1)*x;\nend;\n{-----------------}\nfunction count(a:string):longint;\nvar tg,t:longint;\nbegin\n tg:=0;\n for t:=1 to length(a) do\n begin\n if a[t]='+' then inc(tg);\n if a[t]='-' then dec(tg);\n end;\n exit(tg);\nend;\n{----------------}\nfunction mu(y:longint):longint;\nvar i,tg:longint;\nbegin\n tg:=1;\n for i:=1 to y do tg:=tg*2;\n exit(tg);\nend;\n{----------------}\nbegin\n readln(s1);\n readln(s2);\n if pos('?',s2)=0 then\n begin\n if count(s1)=count(s2) then write(1/1)\n else write(0/1);\n end\n else\n begin\n for i:=1 to length(s2) do\n if s2[i]='?' then inc(dem);\n dem1:=count(s1)-count(s2);\n if ((dem1<0) and (dem1<-dem)) or ((dem1>0) and (dem1>dem)) then write(0/1)\n else\n begin\n c:=abs((dem-dem1) div 2);\n write(gt(dem)/(gt(c)*gt(dem-c)*mu(dem)));\n end;\n end;\nend."}, {"source_code": "function fact(n:longint):longint;\nvar\ni,s:longint;\nbegin\ns:=1;\nfor i:=1 to n do\ns:=s*i;\nfact:=s;\nend;\nfunction st(n:longint):longint;\nvar\ni,s:longint;\nbegin\ns:=1;\nfor i:=1 to n do\ns:=s*2;\nst:=s;\nend;\n\nfunction c(a,b:longint):longint;\nbegin\nc:=fact(b) div (fact(a)*fact(b-a));\nend;\n\nvar\ns1,s2:string;\nn,i,k1,k2,p,x:longint;\nv:real;\nbegin\nreadln(s1);\nreadln(s2);\nn:=length(s1);\nk1:=0;\nk2:=0;\np:=0;\nfor i:=1 to n do\nif s1[i]='+' then inc(k1)\nelse dec(k1);\n\nfor i:=1 to n do\nif s2[i]='+' then inc(k2) else\nif s2[i]='-' then dec(k2) else\ninc(p);\n\n//writeln(k1,' ',k2,' ',p);\nif abs(k1-k2)>p then \n begin\n write(0);\n exit; \n end;\nif (p+k1-k2) mod 2=1 then\nbegin\nwrite(0);\nexit;\nend\nelse \nbegin\nx:=(p+k1-k2) div 2;\n//writeln('x=',x);\n//writeln('p=',p);\n//writeln(c(x,p));\n//writeln(st(p));\nv:=c(x,p)/st(p);\nwrite(v);\nend;\nend.\n\n\n\n\n\n\n"}, {"source_code": "const fi = '';//'476B.inp';\n fo = '';//'476B.out';\n max = 20;\ntype vector = array[0 .. max] of longint;\nvar x:vector; sl,st:string; kq:real;\n n,k,j,v1,v2,d,tu,mau:longint;\n f,g:text;\nprocedure ghinghiem(x:vector);\n var i,u:longint;\n begin\n u:=v2; inc(mau);\n for i:=1 to k do\n begin\n if x[i] = 0 then inc(u);\n if x[i] = 1 then dec(u);\n end;\n if u = v1 then inc(tu);\n end;\nprocedure chinhhoplap(i:longint);\n var j:longint;\n begin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i = k then ghinghiem(x)\n else chinhhoplap(i+1);\n end;\n end;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,sl);\n readln(f,st);\n v1:=0; v2:=0; d:=0; tu:=0; mau:=0;\n for j:=1 to length(sl) do\n begin\n if sl[j] = '+' then inc(v1);\n if sl[j] = '-' then dec(v1);\n end;\n for j:=1 to length(st) do\n begin\n if st[j] = '+' then inc(v2);\n if st[j] = '-' then dec(v2);\n if st[j] = '?' then inc(d);\n end;\n if d = 0 then\n if v1 = v2 then begin write(1); exit; end\n else begin write(0); exit; end;\n k:=d;\n chinhhoplap(1);\n kq:=tu/mau;\n write(g,kq:0:10);\n close(f); close(g);\nend.\n"}, {"source_code": "Var p1, p2, m1, m2, a, r, i, j, n, m: longint;\n s1, s2: String;\nProcedure c(b, q, res, last: longint);\nBegin\n //WriteLn(b, ' ',q);\n if (q = last) then\n begin\n if (b+n = res) then inc(r);\n exit;\n end;\n c(b-1, q+1, res, last);\n c(b+1, q+1, res, last);\nEnd;\nBegin\n ReadLn(s1);\n ReadLN(s2);\n r := 0;\n p1 := 0; p2 := 0; m1 := 0; m2 := 0; a := 0;\n for i:=1 to length(s1) do if s1[i] = '+' then inc(p1) else inc(m1);\n for i:=1 to length(s2) do if s2[i] = '+' then inc(p2) else if s2[i] = '-' then inc(m2) else inc(a);\n //WriteLn(p1, ' ', m1, ' ', p2, ' ', m2, ' ', a);\n if a = 0 then\n begin\n if (m1 = m2) and (p1 = p2) then WriteLn(1.000000000) else WriteLn(0.000000000);\n exit;\n end;\n n := (p2 - m2);\n c(0, 0, (p1 - m1) , a);\n m := 1;\n for i:=1 to a do m := m * 2;\n WriteLn(r/m:0:9);\nEnd.\n"}, {"source_code": "var\n a:array[0..20,-20..20]of extended;\n s:string;\n n,ed,i,j:longint;\nbegin\n readln(s);\n n:=length(s);\n for i:=1 to n do\n if s[i]='+' then inc(ed) else dec(ed);\n readln(s);a[0,0]:=1;\n for i:=1 to n do begin\n if s[i]='+' then\n for j:=-10 to 10 do\n a[i,j]:=a[i-1,j-1];\n if s[i]='-' then\n for j:=-10 to 10 do\n a[i,j]:=a[i-1,j+1];\n if s[i]='?' then\n for j:=-10 to 10 do\n a[i,j]:=(a[i-1,j+1]+a[i-1,j-1])/2;\n end;\n writeln(a[n,ed]:0:12);\nend."}, {"source_code": "var b:array[1..11]of char;\n s1,s2:string;\n symb:array[1..2]of char;\n kp,km,kv,ss1,ss2,i,j,l,kolv,kolnv:longint;\n ans:real;\n\nprocedure rec(x:longint);\nvar sum,i,j:longint;\nbegin\nsum:=0;\nif x>kv then begin\n for i:=1 to kv do\n if b[i]='+' then inc(sum)\n else dec(sum);\n if ss1=(ss2+sum) then inc(kolv)\n else inc(kolnv);\n end\n else begin\n for j:=1 to 2 do\n begin\n b[x]:=symb[j];\n rec(x+1);\n end;\n end;\nend;\n\n\n\nbegin\nreadln(s1);\nreadln(s2);\nl:=length(s1);\n\nkp:=0; km:=0;\n\nfor i:=1 to l do\n begin\n if s1[i]='+' then inc(kp)\n else inc(km);\n end;\nss1:=kp-km;\n\nkp:=0; km:=0;\n\nfor i:=1 to l do\n begin\n if s2[i]='+' then inc(kp)\n else if s2[i]='-' then inc(km)\n else inc(kv);\n end;\nss2:=kp-km;\n\nsymb[1]:='+';\nsymb[2]:='-';\n\nif abs(ss1-ss2)>kv then ans:=0\n else begin\n if (ss1=ss2) and (kv=0) then\n begin\n ans:=1;\n writeln(ans:1:9);\n halt;\n end\n else rec(1);\n kolnv:=kolv+kolnv;\n ans:=kolv/kolnv;\n end;\n\nwriteln(ans:1:9)\nend."}, {"source_code": "var s1,s2:string;\n bit,n1,n2,dem,dem1,org,en,en1,i,j:longint;\n xs:real;\nfunction getbit(x:longint;i:longint):longint;\n begin\n getbit:=(x shr i) and 1;\n end;\nbegin\n readln(s1);\n readln(s2);\n n1:=length(s1);\n n2:=length(s2);\n org:=0;\n en:=0;\n dem:=0;\n for i:=1 to n1 do\n if s1[i]='+' then inc(org) else dec(org);\n bit:=1;\n for i:=1 to n2 do\n begin\n if s2[i]='+' then inc(en);\n if s2[i]='-' then dec(en);\n if s2[i]='?' then\n begin\n bit:=bit*2;\n inc(dem);\n end;\n end;\n dem1:=0;\n if dem<>0 then\n begin\n for i:=0 to bit-1 do\n begin\n en1:=en;\n for j:=0 to dem-1 do\n begin\n if getbit(i,j)=1 then inc(en1) else dec(en1);\n end;\n if en1=org then inc(dem1);\n end;\n xs:=dem1/bit;\n end\n else\n if en=org then xs:=1 else xs:=0;\n\n writeln(xs:0:12);\n\nend.\n"}, {"source_code": "var s1,s2:string;\n ans,kol,f:int64;\n i,n:longint;\nprocedure tt(i,sum:longint);\n begin\n if i=n+1 then begin\n inc(kol);\n if sum=f then inc(ans);\n exit;\n end;\n\n if s2[i]='+' then tt(i+1,sum+1) else\n if s2[i]='-' then tt(i+1,sum-1) else begin\n tt(i+1,sum+1);\n tt(i+1,sum-1);\n end;\n end;\n\n\nbegin\n readln(s1);\n readln(s2);\n n:=length(s1);\n for i:=1 to n do\n if s1[i]='+' then inc(f) else dec(f);\n tt(1,0);\n writeln(ans/kol:0:9);\n\nend."}, {"source_code": "var\n s1,s2 : string;\n su,i,k,sk : longint;\n\n procedure rec(i,s:longint);\n begin\n if i > length(s2) then begin inc(k); if s = su then inc(sk); end;\n if s2[i] = '+' then begin rec(i+1,s+1); exit; end;\n if s2[i] = '-' then begin rec(i+1,s-1); exit; end;\n if s2[i] = '?' then begin rec(i+1,s+1); rec(i+1,s-1); exit; end;\n end;\n\nbegin\n readln(s1);\n for i:=1 to length(s1) do\n if s1[i] = '+' then inc(su) else dec(su);\n readln(s2);\n rec(1,0);\n writeln(sk/k:0:12);\nend."}, {"source_code": "var\n xx,res,kol,i:longint;\n s:string;\nprocedure rec(k,x:longint);\nbegin\n if k>length(s) then\n begin\n if x=xx then inc(kol);\n inc(res);\n exit;\n end;\n if s[k]='+' then\n begin\n rec(k+1,x+1);\n exit;\n end;\n if s[k]='-' then\n begin\n rec(k+1,x-1);\n exit;\n end;\n rec(k+1,x-1);\n rec(k+1,x+1);\nend;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n readln(s);\n xx:=0;\n res:=0;\n kol:=0;\n for i:=1 to length(s) do if s[i]='+' then inc(xx) else dec(xx);\n readln(s);\n rec(1,0);\n writeln(kol/res:0:10);\nend.\n"}, {"source_code": "uses math;\nVar s1,s2:string;\n i,k11,k12,k21,k22,k23,t1,t2,kilk,prav:longint;\n ans:extended;\nprocedure rec(x,t1,t2:longint);\n begin\n if x=k23 then\n begin\n if (k21+t1=k11) and (k22+t2=k12) then inc(prav);\n inc(kilk);\n exit;\n end;\n rec(x+1,t1+1,t2);\n rec(x+1,t1,t2+1);\n end;\n begin\n readLn(s1);\n readLn(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(k11)\n else inc(k12);\n for i:=1 to length(s2) do\n if s2[i]='+' then inc(k21)\n else if s2[i]='-' then inc(k22)\n else inc(k23);\n if (k21>k11) or (k22>k12) or ((k11<>k21) and (k12<>k22) and (k23=0)) then writeLn(0)\n else\n begin\n kilk:=0;\n prav:=0;\n rec(0,0,0);\n writeLn(prav/kilk:0:9);\n end;\n end."}, {"source_code": "//476b\nvar\n t,p,z,i:longint;\n s1,s2:string;\n n,f:extended;\nfunction x(n:integer):longint;\nvar l:longint;k:longint;\nbegin\n l:=1;\n for k:=1 to n do\n l:=k*l;\n x:=l;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n t:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(t) else dec(t);\n for i:=1 to length(s1) do\n if s2[i]='+' then inc(z) else if s2[i]='-' then dec(z) else inc(p);\n t:=abs(t-z);\n if (t>p)or ((t+p)mod 2=1) then write(0) else begin\n t:=(p+abs(t))div 2;\n n:=1*1 shl p;\n f:=x(p)/x(p-t)/x(t);\n f:=f/n;\n write(f);\n\n\n end;\nend.\n"}, {"source_code": "Uses math;\nConst Fi = '';//'476B.INP';\n Fo = '';//'asdf.out';\nVar F1,F2 : text;\n S1,S2 : String;\n Vt : longint;\n Vtg : longint;\n Sl1,Sl2 : longint;\nProcedure Mofile;\nBegin\n Assign(f1,fi);\n Reset(f1);\n Assign(f2,fo);\n Rewrite(f2);\nEnd;\n///////////////////////////\nProcedure Docfile;\nVar i,j : longint;\nBegin\n Readln(f1,S1);\n Readln(f1,S2);\n Vtg:=0;\n For i:=1 to Length(S1) do\n If S1[i] = '+' then\n Inc(Vtg)\n Else\n Dec(Vtg);\nEnd;\n////////////////////////////\nProcedure Try1(I:longint; Vt:longint);\nBegin\n If I > Length(S2) then\n Begin\n If Vt = Vtg then Inc(Sl1);\n Inc(Sl2);\n Exit;\n End;\n If (S2[i] = '+') or (S2[i] ='?') then\n Try1(I+1,Vt+1);\n If (S2[i] = '-') or (S2[i] ='?') then\n Try1(I+1,Vt-1);\nEnd;\n///////////////////////////\nProcedure Xulyfile;\nVar i,j : longint;\nBegin\n Try1(1,0);\n Writeln(f2,Sl1 / Sl2 :0:12);\nEnd;\n/////////////////////////////\nProcedure Dongfile;\nBegin\n Close(f1);\n Close(f2);\nEnd;\n//////////////////////////////\nBegin\n Mofile;\n Docfile;\n Xulyfile;\n Dongfile;\nEnd.\n"}, {"source_code": "uses math;\nvar a:array[1..10,1..11] of longint;\n c,x,z:real; n,m,j,i,l,l1,k,u,o:longint; s,s1:string;\nbegin\nreadln(s);\nreadln(s1);\nn:=0;\nm:=0;\nk:=0;\nfor i:=1 to length(s) do\nbegin\nif s[i]='+' then inc(n) else dec(n);\nif s1[i]='+' then inc(m) else\n if s1[i]='-' then dec(m) else inc(k);\nend;\nif k<>0 then begin\na[1,2]:=1;\na[2,1]:=2; a[2,3]:=1;\na[3,2]:=3; a[3,4]:=1;\na[4,1]:=6; a[4,3]:=4; a[4,5]:=1;\na[5,2]:=10; a[5,4]:=5; a[5,6]:=1;\na[6,1]:=20; a[6,3]:=15; a[6,5]:=6; a[6,7]:=1;\na[7,2]:=35; a[7,4]:=21; a[7,6]:=7; a[7,8]:=1;\na[8,1]:=70; a[8,3]:=56; a[8,5]:=28; a[8,7]:=8; a[8,9]:=1;\na[9,2]:=126; a[9,4]:=84; a[9,6]:=36; a[9,8]:=9; a[9,10]:=1;\na[10,1]:=252; a[10,3]:=210; a[10,5]:=120; a[10,7]:=45; a[10,9]:=10; a[10,11]:=1;\nwriteln((a[k,(abs(n-m)+1)]/power(2,k)):1:12);\nend\nelse\nif n=m then writeln((1/1):1:12) else writeln((0/1):1:12);\nend.\n\n\n\n"}, {"source_code": "var s1,s2:string;\n i,f1,f2,dem,res,count,s:longint;\n t:real;\n\nprocedure dequy(i:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n if j=0 then dec(s) else inc(s);\n if if2 then t:=0 else t:=1;\n write(t:0:12);\n exit;\n end;\n count:=0;s:=0;\n res:=f1-f2;\n dequy(1);\n write(count/(1 shl dem):0:12);\nEND."}, {"source_code": "const fi='';\n fo='';\n mn=100000;\nvar s1,s2:string;\n k1,n,k2,sl,m,r:longint;\n p,x,gn:array[1..mn] of longint;\n f:text;\n kq:real;\nprocedure input;\n begin\n assign(f,fi);\n reset(f);\n readln(f,s1);\n readln(f,s2);\n close(f);\n n:=length(S1);\n p[1]:=1;\n p[2]:=-1;\n end;\nprocedure kt;\nvar i,tong:longint;\n begin\n tong:=0;\n for i:=1 to sl do tong:=tong+x[i];\n inc(m);\n gn[m]:=tong+k2;\n end;\nprocedure try1(i:longint);\n var j:longint;\n begin\n for j:=1 to 2 do\n begin\n x[i]:=p[j];\n if i=sl then kt\n else try1(i+1);\n end;\n end;\nprocedure process;\n var i:longint;\n begin\n k1:=0; k2:=0;\n sl:=0;\n for i:=1 to n do\n if s1[i]='+' then inc(k1) else dec(k1);\n for i:=1 to n do\n begin\n if s2[i]='+' then inc(k2);\n if s2[i]='-' then dec(k2);\n if s2[i]='?' then inc(sl);\n end;\n if sl=0 then\n begin\n if k1=k2 then kq:=1 else kq:=0;\n exit;\n end;\n try1(1);\n r:=0;\n for i:=1 to m do\n if gn[i]=k1 then inc(r);\n kq:=r/m;\n end;\nbegin\n input;\n assign(f,fo);\n rewrite(f);\n process;\nwrite(f,kq:1:11);\n close(f);\nend.\n"}, {"source_code": "{$H}\n{$COPERATORS ON}\nvar s1,s2:string;\n sum1,sum2,c,i,k,m,p:longint;\n res:real;\nbegin\n\n readln(s1);\n readln(s2);\n sum1:=0;\n sum2:=0;\n c:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then sum1+=1\n else\n sum1-=1;\n\n\n for i:=1 to length(s2) do\n if s2[i]='+' then sum2+=1\n else\n if s2[i]='-' then sum2-=1\n else\n c+=1;\n k:=sum1-sum2;\n if ((k+c) mod 2 <>0) or (c>1;\n p:=1;\n for i:=0 to m-1 do\n p*=c-i;\n for i:=2 to m do\n p:=p div i;\n res:= p/(1<0)and((s2[j]='+')or(s2[j]='?'))then begin \np2:=p2+1;t:=t+1;end;\n\nif(i and k=0)and((s2[j]='-')or(s2[j]='?'))then begin \np2:=p2-1;t:=t+1;end;\n\nk:=k div 2;\nend;\n\nif(t=L)and(p2=p1) then begin Sum:=Sum+1;end;\n\nend;\n\nif(q=0)and(Sum=1) then begin writeln('1');end;\nif(q=0)and(Sum=0) then begin writeln('0');end;\nif(q<>0) then begin \nk:=1;\nfor i:=1 to q do begin\nk:=k*2;\nend;\nwriteln(Sum/k);\nend;\nEND."}, {"source_code": "var \nk,k0,i,p1,p2,Sum,L,q,j,t,R:longint;\ns1,s2:string;\n\nBEGIN\nSum:=0;\nreadln(s1);\nL:=Length(s1);\nif(L=1) then begin R:=2;k0:=1;end;\nif(L=2) then begin R:=4;k0:=2;end;\nif(L=3) then begin R:=8;k0:=4;end;\nif(L=4) then begin R:=16;k0:=8;end;\nif(L=5) then begin R:=32;k0:=16;end;\nif(L=6) then begin R:=64;k0:=32;end;\nif(L=7) then begin R:=128;k0:=64;end;\nif(L=8) then begin R:=256;k0:=128;end;\nif(L=9) then begin R:=512;k0:=256;end;\nif(L=10) then begin R:=1024;k0:=512;end;\n\np1:=0;\nq:=0;\n\nfor i:=1 to L do begin\nif(s1[i]='+') then begin p1:=p1+1;end\nelse begin p1:=p1-1;end;\nend;\n\nreadln(s2);\nfor j:=1 to L do begin\nif(s2[j]='?') then begin q:=q+1;end;\nend;\n\n\nfor i:=0 to R-1 do begin\n\nk:=k0;p2:=0;t:=0;\n\nfor j:=1 to L do begin\nif(i and k<>0)and((s2[j]='+')or(s2[j]='?'))then begin \np2:=p2+1;t:=t+1;end;\n\nif(i and k=0)and((s2[j]='-')or(s2[j]='?'))then begin \np2:=p2-1;t:=t+1;end;\n\nk:=k div 2;\nend;\n\nif(t=L)and(p2=p1) then begin Sum:=Sum+1;end;\n\nend;\n\nif(q=0)and(Sum=1) then begin writeln('1');end;\nif(q=0)and(Sum=0) then begin writeln('0');end;\nif(q<>0) then begin \nk:=1;\nfor i:=1 to q do begin\nk:=k*2;\nend;\nwriteln(Sum/k);\nend;\nEND."}, {"source_code": "var\n s : ansistring;\n xx,i,ss,sk : longint;\n f : boolean;\n\n procedure rec(x,j : longint);\n begin\n if j > length(s) then begin\n inc(ss);\n if x = xx then inc(sk);\n exit;\n end;\n if s[j] = '+' then rec(x+1,j+1) else\n if s[j] = '-' then rec(x-1,j+1) else begin\n rec(x+1,j+1);\n rec(x-1,j+1);\n end;\n end;\n\nbegin\n readln(s);\n for i:=1 to length(s) do if s[i] = '+' then inc(xx) else dec(xx);\n readln(s);\n\n rec(0,1);\n if sk = 0 then writeln('0.00000000000000000') else writeln(sk/ss:0:9);\nend."}, {"source_code": "var ans1,p,dream,dream2,i,r,q,tek,ans:longint;\n a:array[1..10]of char;\n s,s2:string;\nprocedure rec(i:Longint);\n var j:longint;\n begin\n if i>r\n then\n begin\n inc(ans1);\n tek:=0;\n for j:=1 to r do\n if a[j]='+'\n then inc(tek)\n else dec(tek);\n if tek=p\n then inc(ans);\n end\n else\n begin\n a[i]:='+';\n rec(i+1);\n a[i]:='-';\n rec(i+1);\n end;\n end;\n \nbegin\n readln(s);\n readln(s2);\n \n for i:=1 to length(s) do\n if s[i]='-'\n then Dream:=Dream-1\n else dream:=dream+1;\n \n for i:=1 to length(s2) do\n begin\n if s2[i]='-'\n then Dream2:=Dream2-1;\n if s2[i]='+'\n then dream2:=dream2+1;\n if s2[i]='?'\n then inc(r);\n end;\n \n p:=dream-dream2;\n \n rec(1);\n\n write(ans/ans1);\nend."}, {"source_code": "var s1,s2:string;\n c1,c2,t1,t2,m,n,i,x:longint;\n kq:real;\n\nbegin\n readln(s1);\n readln(s2);\n for i:= 1 to length(s1) do\n begin\n if s1[i]='+' then inc(c1);\n if s1[i]='-' then inc(t1);\n if s2[i]='+' then inc(c2);\n if s2[i]='-' then inc(t2);\n end;\n c1:=c1-c2;\n t1:=t1-t2;\n n:=1;\n m:=1;\n x:=1;\n if (c1<0) or (t1<0) then begin writeln('0.000000000000'); exit; end;\n if (c1=0) and (t1=0) then begin writeln('1.000000000000'); exit; end;\n for i:= 1 to c1+t1 do\n n:=n*2;\n for i:= 2 to c1+t1 do\n m:=m*i;\n for i:= 2 to t1 do\n x:=x*i;\n for i:= 2 to c1 do\n x:=x*i;\n kq:=(m/x)/n;\n writeln(kq:0:12);\n end.\n"}, {"source_code": "var s:string;\nxx,yy:real;\ni,t:Longint;\nprocedure sc(x,y:longint);\nbegin\nif x=length(s)+1 then\n begin\n if y=t then yy:=yy+1;\n exit;\n end;\nif s[x]='?' then\n begin\n sc(x+1,y-1);\n sc(x+1,y+1);\n end\nelse\n begin\n if s[x]='+' then\n sc(x+1,y+1)\n else sc(x+1,y-1);\n end;\nend;\nbegin\n//assign(output,'wifi.out');rewrite(output);\nreadln(s);\nfor i:=1 to length(s) do\n if s[i]='+' then inc(t) else dec(t);\nreadln(s);\nxx:=1;\nfor i:=1 to length(s) do\n if s[i]='?' then\n xx:=xx*2;\nsc(1,0);\nif yy=0 then writeln(yy:0:12)\nelse writeln(yy/xx:0:12);\nclose(input);close(output);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nProgram Only_LOve;\nvar s1,s2 : ansistring ;\n c2,c1,i,dem,p : integer;\n xx,l,k : real;\nBegin\n Readln(s1);\n Readln(s2);\n c1 :=0;c2:=0;dem:=0;k:=1; l:=1;\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then inc(c1);\n if s1[i]='-' then Dec(c1);\n end;\n for i:=1 to length(s2) do\n begin\n if s2[i]='+' then Inc(c2);\n if s2[i]='-' then Dec(c2);\n if s2[i]='?' then inc(dem);\n end;\n for i:=1 to dem do k:= k*2;\n p:=c1 -c2 ;\n p := dem -p ;\n if p mod 2 <> 0 then l:= 0;\n if (p mod 2 = 0) and (p >= 0) then\n begin\n p:= p div 2 ;\n for i:=0 to p-1 do l:=l*(dem-i)/(p-i);\n end\n else l:=0;\n xx := l / k;\n Write(xx:0:12);\n\nend."}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,g,h,u,k,d,e,f,v:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then inc(dem);\n if (a[i]='+') then\n begin\n inc(s1);\n inc(g);\n end\n else if (a[i]='-') then dec(s1);\n if (b[i]='+') then\n begin\n inc(s2);\n inc(h);\n end\n else if (b[i]='-') then dec(s2);\n end;\n s3:=g-h;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (abs(s1-s2)<=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3; d:=1; e:=1; f:=1;\n for i:=1 to dem do d:=d*i;\n for i:=1 to s3 do e:=e*i;\n for i:=1 to k do f:=f*i;\n u:=d div (e*f);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n"}, {"source_code": "program cfwifi;\nvar i,br,z,nacin,poz,poz2,j,ukupno:integer;\n s1,s2:string;\n bm:array[1..100] of integer;\nbegin\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s1) do\n if s1[i]='+' then\n poz:=poz+1\n else\n poz:=poz-1;\n\nbr:=0;\nfor i:=1 to length(s2) do\n if s2[i]='+' then\n poz2:=poz2+1\n else\n if s2[i]='-' then\n poz2:=poz2-1\n else\n br:=br+1;\n\nfor i:=1 to br do\n bm[i]:=0;\nz:=br;\nif z+poz2=poz then\n nacin:=nacin+1;\nukupno:=1;\nwhile z<>-br do\n begin\n i:=br;\n z:=0;\n while bm[i]=1 do\n begin\n bm[i]:=0;\n i:=i-1;\n end;\n bm[i]:=1;\n for j:=1 to br do\n if bm[j]=0 then\n z:=z+1\n else\n z:=z-1;\n\n if z+poz2=poz then\n nacin:=nacin+1;\n\n ukupno:=ukupno+1;\n end;\nwriteln((nacin/ukupno):4:20);\nend."}, {"source_code": "program b272;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction factorial(n:integer):integer;\nbegin\n if n>1 then factorial:=n*factorial(n-1) else factorial:=1;\nend;\nvar s1,s2:string;\nx1,x2,k,razn,c,i,kolpl:integer;\notvet:real;\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n\n readln(s1);\n readln(s2);\n x1:=0;\n x2:=0;\n k:=0;\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then inc(x1);\n if s1[i]='-' then dec(x1);\n end;\n\n for i:=1 to length(s2) do\n begin\n if s2[i]='+' then inc(x2);\n if s2[i]='-' then dec(x2);\n if s2[i]='?' then inc(k);;\n end;\n\n if x1>x2 then razn:=x1-x2 else razn:=x2-x1;\n if razn>k then otvet:=0;\n if razn=k then\n begin\n otvet:=1;\n for i:=1 to k do\n otvet:=otvet/2;\n end;\n if (razn (k mod 2)) then otvet:=0.000000000000000000;\n if (k=0) and (x1=x2) then otvet:=1.000000000000000000000;\n if (k=0) and (x1<>x2) then otvet:=0.00000000000000000000;\n writeln(otvet:0:12);\nend.\n"}, {"source_code": "var\n s1,s2:string;\n x:real;\n dc1,dc2,dt1,dt2,dh1,dh2:longint;\n\nProcedure Nhap (s:string ; var dc,dt,dh:longint);\nvar i:longint;\nbegin\n dc:=0; dt:=0; dh:=0;\n for i:=1 to length(s) do\n if (s[i]='+') then dc:=dc+1\n else if (s[i]='-') then dt:=dt+1\n else if (s[i]='?') then dh:=dh+1;\nend;\n\nProcedure XuLi;\nvar i,a,b,c,d,k:longint;\nbegin\n if (dh2=0) then\n begin\n if (dc1=dc2) and (dt1=dt2) then x:=1\n else x:=0;\n end\n else\n begin\n if abs((dc1-dt1)-(dc2-dt2))>dh2 then x:=0\n else\n begin\n a:=1; b:=1; c:=1; d:=1;\n k:=dc1-dc2;\n for i:=1 to dh2 do a:=a*i; {n!}\n for i:=1 to (dh2-k) do b:=b*i; { (n-k!) }\n for i:=1 to k do c:=c*i; {k!}\n for i:=1 to dh2 do d:=d*2; {dh^2}\n x:=(a/(b*c))/d;\n end;\n end;\n writeln(x);\nend;\n\nProcedure N;\nbegin\n readln(s1);\n readln(s2);\nend;\n\nBegin {Main}\n N;\n Nhap(s1,dc1,dt1,dh1);\n Nhap(s2,dc2,dt2,dh2);\n XuLi;\nEnd.\n"}, {"source_code": "program NumB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, m, i, part, main, count, sum: integer;\n s1, s2: string;\n\nfunction soch(n, k: integer): integer;\nvar\n i, sum: integer;\nbegin\n if k > n then\n soch := 0\n else begin\n sum := 1;\n for i := 1 to n - k do\n sum := sum * (n - i + 1) div i;\n soch := sum;\n end;\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n sum := 0;\n count := 0;\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(sum)\n else\n dec(sum);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(sum)\n else\n if s2[i] = '-' then\n inc(sum)\n else\n inc(count);\n main := 1 shl count;\n part := soch(count, abs(sum) + (count - abs(sum)) div 2);\n writeln(part / main:1:9);\nend.\n"}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n modul=1000000007;\n label 1,2,3,4;\n type\n real=int64;\n mas=array [0..10000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..10000000] of int64;mass1=^mass;\n var ll,rr,p,q,tt,n1,h,n,kk,qq,p3,ot,t,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,t2,besk1:int64;\n imin,ii,k,jj,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..1000] of char;\n poin:zap;\n vec:array[-100..1000] of zap;\n c1,c2:array[-1000..100000] of int64;\n fact,d, a1,bl,br,c,a,b:array[-300000..2000000] of int64;\n och,newoch,ddb:array[-100..1000,-100..1200] of int64;\n dd,maxsum:array[-1..1010,-1..1010] of int64;\n sss, ss1,ss2:string;\n newgr,gr:array[-100..200000] of boolean;\n pole:array[-1..1500,-1..1500] of int64;\n ss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n coef:array[-10..15000,-10..500] of int64;\n maxpr:array[0..100000] of string;\n cc,pr,aanew,aa,bb,sum,v0,v1,s0,t0:extended;\n z,x1,y1,y,x:array[-1..3000,0..10] of int64;\n xx,yy:array[-1..100000] of double;\n xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n{ function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n } function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(ss1);\n readln(ss2);\n n:=length(ss1);\n for i:=1 to n do if ss1[i]='+' then inc(p1) else dec(p1);\n for i:=1 to n do if ss2[i]='+' then inc(p2) else if ss2[i]='-' then dec(p2) else inc(p3);\n { writeln(p1,' ',p2,' ',p3);\n } if abs(p1-p2)>p3 then begin writeln(0.000000000); goto 1; end;\n t:=abs(p1-p2);\n k:=(p3+t) div 2;\n ddb[0,0]:=1;\n for i:=1 to 20 do for j:=0 to i do ddb[i,j]:=ddb[i-1,j-1]+ddb[i-1,j];\n { for i:=0 to 20 do begin for j:=0 to i do write(ddb[i,j]:6); writeln; end;\n } p:=1;\n for i:=1 to p3 do p:=p*2;\n writeln(ddb[p3,k]/p:0:10);\n\n\n 1: close(output);\nend.\n\n\n\n"}, {"source_code": "var\n n, m, i, ans, p, en, pos, pos2: longint;\n s1, s2: string;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(p)\n else\n dec(p);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(p)\n else if s2[i] = '-' then\n inc(p)\n else\n inc(en);\n if p < 0 then\n p := -p;\n {writeln(p, ' ', en);}\n if (p > en) or ((p + en) mod 2 <> 0) then\n begin\n write(0);\n exit();\n end;\n pos := 1;\n p := (en + p) div 2;\n for i := en - p + 1 to en do\n pos := pos * i;\n pos2 := 1;\n for i := 1 to p do\n pos := pos div i;\n for i := 1 to en do\n pos2 := pos2 * 2;\n write(pos / pos2);\nend."}, {"source_code": "program Hate;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar obs,i,pl,mi,vo,raz:integer;\n ans,cor:real;\n s,s1:string;\n\nprocedure per(ch:integer; var s:string);\nbegin\n while ch>0 do\n begin\n if ch mod 2 = 1 then s:='+'+s else s:='-'+s;\n ch:=ch div 2;\n end;\n while length(s) kol_m1) or (kol_p2 > kol_p1)\n then begin\n q := 0;\n writeln(q:0:9);\n end\n else begin\n\n q := 1;\n for i := 1 to kol_v do\n q := q * 0.5;\n for i := 1 to max(kol_m1 - kol_m2, kol_p1-kol_p2) do\n q := q * (kol_v-i+1);\n for i := 2 to max(kol_m1 - kol_m2, kol_p1-kol_p2) do\n q := q / i;\n writeln(q:0:12);\n end;\n end; \n\nend."}, {"source_code": "program codeforces_476b;\ntype niz=array[1..10] of integer;\nvar s1,s2:string;\n a:niz;\n i,j,br,br2,br3,p1,p2,p3:integer;\nfunction brojanje (var a:niz;n:integer):integer;\n var i,j:integer;\n begin\n i:=n;\n while (i>0) and (a[i]=1) do i:=i-1;\n if (i=0) then brojanje:=0\n else\n begin\n brojanje:=1;\n a[i]:=1;\n for j:=i+1 to n do a[j]:=0;\n end;\n end;\nbegin\n readln (s1);\n readln (s2);\n p1:=0;\n for i:=1 to length (s1) do\n if (s1[i]='+') then p1:=p1+1\n else p1:=p1-1;\n br:=0;\n p2:=0;\n for i:=1 to length (s2) do\n begin\n if (s2[i]='+') then p2:=p2+1\n else if (s2[i]='-') then p2:=p2-1\n else br:=br+1;\n end;\n for i:=1 to br do a[i]:=0;\n br2:=1;\n repeat\n p3:=0;\n for i:=1 to br do\n if (a[i]=1) then p3:=p3+1\n else p3:=p3-1;\n if (p2+p3=p1) then br3:=br3+1;\n br2:=br2+1;\n until (brojanje (a,br)=0);\n br2:=br2-1;\n writeln (br3/br2:2:12);\nend.\n"}, {"source_code": "var s1, s2:string; \n i, kp1, kp2, km1, km2, n, kv, km, kp:longint; \n a, st, ans:real; \nbegin\n\nreadln(s1);\nreadln(s2);\nn:=length(s1);\n\nfor i:=1 to n do\n if s1[i]='+' then inc(kp1)\n else inc(km1);\n \nfor i:=1 to n do \n if s2[i]='+' then inc(kp2)\n else if s2[i]='-' then inc(km2)\n else inc(kv);\n\nif (km10)) or ((t>0) and (k>t)) or ((t-k) mod 2<>0) then\n begin\n o:=0;\n writeln(o:0:9);\n halt;\n end;\n\n k:=(t-k) div 2;\n for i:=1 to t do\n begin\n p1:=p1*i;\n if (i<=k) then p2:=p2*i;\n if (i<=t-k) then p3:=p3*i;\n end;\n writeln((p1/(p2*p3))/(1 shl t):0:9);\n read(n);\nend.\n"}, {"source_code": "VAR ans,ans1,v,m,p,a:int64; i:dword; s:string;\nBEGIN\nreadln(s);\nfor i:=1 to length(s) do if s[i]='+' then inc(p) else inc(m);\nreadln(s);\nfor i:=1 to length(s) do if s[i]='+' then dec(p) else if s[i]='-' then dec(m) else inc(v);\nif (p>=0) and (m>=0) then begin\n ans:=1;\n if m=0 then m:=1;\n if p=0 then p:=1;\n a:=1;\n for i:=1 to v do a:=a*2;\n for i:=1 to v do ans:=ans*i;\n ans1:=1;\n for i:=1 to m do ans1:=ans1*i;\n for i:=1 to p do ans1:=ans1*i;\n write(ans/ans1/(a):0:10);\nend else begin\nans:=0;\nwrite(ans/1.0:0:10);\nend;\nEND."}], "negative_code": [{"source_code": "const \n giaithua:array[0..10] of longint=(1,1,2,6,24,120,720,5040,40320,362880,3628800);\n mu2:array[0..10] of longint=(1,2,4,8,16,32,64,128,256,512,1024);\nvar\n s1,s2:string;\n i,nch,k,posi1,posi2:integer;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do \n begin\n if s1[i]='+' then inc(posi1) else dec(posi1);\n if s2[i]='+' then inc(posi2)\n else if(s2[i]='-') then dec(posi2)\n else inc(nch);\n end;\n if (nch-abs(posi1-posi2)) mod 2<>0 then begin write('0.000000000000'); halt; end;\n k:=(nch-abs(posi1-posi2)) div 2+abs(posi1-posi2);\n if k>nch then begin write(-1); halt; end;\n writeln( (giaithua[nch]/(giaithua[k]*giaithua[nch-k]))/mu2[nch]:0:12);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K : Longint;\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 1 do\n begin\n writeln(j);\n s := s * j;\n end;\n for j := 1 to t2 do\n begin\n writeln('/ ', j);\n s := s div j;\n end;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n k := 1;\n for I := 1 to l do\n begin\n k := k * 2;\n end;\n r := s / k;\n writeln(r : 1 : 12);\n readln;\nend.\n"}, {"source_code": "const H:array[1..2] of integer=(-1,1);\nvar s2,s1:string;\n n,sl,s,dem:integer;\n x:array[1..1000] of integer;\n res:real;\nprocedure enter;\n var i:integer;\n begin\n readln(s1);\n readln(s2);\n n:=0;sl:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(n)\n else dec(n);\n for i:=1 to length(s2) do\n begin\n if s2[i]='+' then dec(n);\n if s2[i]='-' then inc(n);\n if s2[i]='?' then inc(sl);\n end;\n s:=0;\n end;\nprocedure attemp(i:integer);\n var j:integer;\n begin\n\n for j:=1 to 2 do\n begin\n s:=s+h[j];\n if i=sl then if s=n then inc(dem);\n if i=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\n writeln(cnt/cccnt:0:12);\nend.\n"}, {"source_code": "var\n s1,s2:ansistring;\n sum1,sum2,c,dem,hieu:longint;\n\nfunction tohop(k,n:longint):longint;\nvar tu,mau1,mau2,i:longint;\nbegin\n tu:=1;\n for i:=1 to n do tu:=tu*i;\n mau1:=1;\n for i:=1 to k do mau1:=mau1*i;\n mau2:=1;\n for i:=1 to n-k do mau2:=mau2*i;\n exit(tu div (mau1*mau2));\nend;\n\nprocedure nhapdem;\nvar l,i,j:longint;\nbegin\n sum1:=0; sum2:=0; dem:=0;\n readln(s1); readln(s2);\n l:=length(s1);\n for i:=1 to l do\n begin\n if s1[i]='+' then inc(sum1)\n else dec(sum1);\n end;\n for j:=1 to l do\n begin\n if s2[j]='+' then inc(sum2);\n if s2[j]='-' then dec(sum2);\n if s2[j]='?' then inc(dem);\n end;\n hieu:=sum1-sum2;\nend;\n\nfunction xuli:real;\nvar kq:real; i,plus,minus,sth:longint;\nbegin\n sth:=1;\n for i:=1 to dem do sth:=sth*2;\n if (dem=0) and (hieu=0) then writeln(1);\n if (hieu>=0) and (dem>=hieu) then\n begin\n if ((dem-hieu) mod 2 =0) and ((dem+hieu) mod 2 = 0) then\n begin\n plus:=(dem+hieu) div 2;\n minus:=(dem-hieu) div 2;\n if minus=0 then exit(1/sth);\n kq:=tohop(plus,dem)/sth;\n exit(kq);\n end\n else exit(0);\n end\n else exit(0);\nend;\n\nbegin\n nhapdem;\n writeln(xuli);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 14);\n readln;\n\nend.\n"}, {"source_code": "var\nss,s:string;\ni:longint;\n\np,q,qq,nez,x,otr,plus,kol:int64;\nbegin\nreadln(s);\nreadln(ss);\nfor i:=1 to length(s) do if s[i]='+' then inc(plus)\nelse\ninc(otr);\nkol:=plus+otr;\nfor i:=1 to length(ss) do begin\n if ss[i]='+' then dec(plus);\n if ss[i]='-' then dec(otr);\n if ss[i]='?' then inc(nez);\nend;\nkol:=plus;\nif (plus<0)or(otr<0) then writeln(0)\nelse begin\nx:=1;\nfor i:=1 to nez do x:=x*2;\np:=1;\nfor i:=1 to nez do p:=p*i;\nq:=1;\nfor i:=1 to kol do q:=q*i;\nqq:=1;\n\nfor i:=1 to (nez-kol) do qq:=qq*i;\np:=round(p/(q));\nwriteln(p/x:0:11);\nend;\nend."}, {"source_code": "program pro476B;\nvar dem,dung,tatca:longint;\n s1,s2:string;\n kq:real;\n d:array[1..2] of char;\n x:array[1..100] of char;\n{---------------------------------}\nprocedure doc;\nbegin\n readln(s1);\n readln(s2);\nend;\n{---------------------------------}\nprocedure ghi;\nbegin\n write(kq:0:9);\n write(dung);\n write(tatca);\nend;\n{---------------------------------}\nprocedure xetnghiem;\nvar i,k,tong1,tong2,p:longint;\n s3:string;\nbegin\n s3:=s2;\n tong1:=0;tong2:=0;\n for i:=1 to dem do\n begin\n p:=pos('?',s3);\n delete(s3,p,1);\n insert(x[i],s3,p);\n end;\n write(s3,' ');\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(tong1) else dec(tong1);\n for i:=1 to length(s3) do\n if s3[i]='+' then inc(tong2) else dec(tong2);\n if tong1=tong2 then\n begin\n inc(dung);\n inc(tatca);\n end else inc(tatca);\nend;\n{---------------------------------}\nprocedure dequy(i:longint);\nvar j:longint;\nbegin\n for j:=1 to 2 do\n begin\n x[i]:=d[j];\n if i=dem then xetnghiem else dequy(i+1);\n end;\nend;\n{-----------------------------------}\nprocedure xuli;\nvar i:longint;\nbegin\n dem:=0;\n for i:=1 to length(s2) do if s2[i]='?' then inc(dem);\n if dem=0 then xetnghiem else dequy(1);\n kq:=dung/tatca;\nend;\n{---------------------------------}\nbegin\n doc;\n d[1]:='+';\n d[2]:='-';\n xuli;\n ghi;\nend.\n"}, {"source_code": "var\n ans:real;\n i, c, c2, q:longint;\n s1, s2:string;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(c) else dec(c);\n for i:=1 to length(s2) do\n case s2[i] of\n '?':inc(q);\n '+':inc(c2) \n else dec(c2);\n end;\n dec(q, abs(c-c2));\n if q<0 then begin writeln(ans:0:0); exit; end;\n ans:=1;\n for i:=q downto 2 do\n ans:=ans/i;\n writeln(ans:0:9);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 12);\n\nend.\n"}, {"source_code": "var\n n, m, i, ans, p, en, pos, pos2: longint;\n s1, s2: string;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(p)\n else\n dec(p);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(p)\n else if s2[i] = '-' then\n inc(p)\n else\n inc(en);\n if p < 0 then\n p := -p;\n if (p > en) or (p + en mod 2 <> 0) then\n begin\n write(0);\n exit();\n end;\n pos := 1;\n p := (en + p) div 2;\n for i := en - p + 1 to en do\n pos := pos * i;\n pos2 := 1;\n for i := 1 to p do\n pos := pos div i;\n for i := 1 to en do\n pos2 := pos2 * 2;\n write(pos / pos2);\nend."}, {"source_code": "uses math;\nVar s1,s2:string;\n i,k11,k12,k21,k22,k23,t1,t2:longint;\n ans:extended;\n begin\n readLn(s1);\n readLn(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(k11)\n else inc(k12);\n for i:=1 to length(s2) do\n if s2[i]='+' then inc(k21)\n else if s2[i]='-' then inc(k22)\n else inc(k23);\n if (k21>k11) or (k22>k12) or ((k11<>k21) and (k12<>k22) and (k23=0)) then writeLn(0)\n else\n begin\n t1:=k11-k21;\n t2:=k12-k22;\n k23:=k23-min(t1,t2);\n ans:=1;\n for i:=1 to k23 do\n ans:=ans*0.5;\n writeLn(ans:0:9);\n end;\n end."}, {"source_code": "Var s1,s2: AnsiString;\n i,k1,k2,h,x,y,ans,kol: LongInt;\n\nprocedure rec(n,x: LongInt);\n Begin\n if n=0 then Begin if x=0 then Inc(ans) else Inc(kol); Exit; End;\n rec(n-1,x+1);\n rec(n-1,x-1);\n End;\n\n Begin\n ReadLn(s1);\n ReadLn(s2);\n for i:=1 to Length(s1) do\n if s1[i]='+' then Inc(k1)\n else Dec(k1);\n for i:=1 to Length(s2) do\n if s2[i]='+' then Inc(k2)\n else if s2[i]='-' then Dec(k2)\n else Inc(h);\n if h=0 then\n Begin\n if k1=k2 then WriteLn(1.000000000)\n else WriteLn(0.000000000);\n Halt;\n End;\n if abs(k1-k2)>h then Begin WriteLn(0.000000000); Halt; End;\n x:=1 shl h;\n rec(h,0);\n WriteLn(ans/(kol+ans):0:9);\n End.\n"}, {"source_code": "uses math;\nvar a:array[1..10,1..11] of longint;\n c,x,z:real; n,m,j,i,l,l1,k,u,o:longint; s,s1:string;\nbegin\nreadln(s);\nreadln(s1);\nn:=0;\nm:=0;\nk:=0;\nfor i:=1 to length(s) do\nbegin\nif s[i]='+' then inc(n) else dec(n);\nif s1[i]='+' then inc(m) else\n if s1[i]='-' then dec(m) else inc(k);\nend;\nif k<>0 then begin\na[1,2]:=1;\na[2,1]:=2; a[2,3]:=1;\na[3,2]:=3; a[3,4]:=1;\na[4,1]:=6; a[4,3]:=4; a[4,5]:=1;\na[5,2]:=10; a[5,4]:=5; a[5,6]:=1;\na[6,1]:=20; a[6,3]:=15; a[6,5]:=6; a[6,7]:=1;\na[7,2]:=35; a[7,4]:=21; a[7,6]:=7; a[7,8]:=1;\na[8,1]:=70; a[8,3]:=56; a[8,5]:=29; a[8,7]:=8; a[8,9]:=1;\na[9,2]:=126; a[9,4]:=85; a[9,6]:=37; a[9,8]:=9; a[9,10]:=1;\na[10,1]:=252; a[10,3]:=211; a[10,5]:=122; a[10,7]:=49; a[10,9]:=10; a[10,11]:=1;\nwriteln((a[k,(abs(n-m)+1)]/power(2,k)):1:12);\nend\nelse\nif n=m then writeln((1/1):1:12) else writeln((0/1):1:12);\nend.\n\n\n\n"}, {"source_code": "var s,s1:string;\ncount,count1,i,g,sum1,sum:longint;\nprocedure q(x,y:longint);\nbegin\nIf x=0 then\nbegin\nIf y+sum1=sum then\ninc(count1);\nend\nelse\nbegin\nq(x-1,y+1);\nq(x-1,y-1);\nend;\nend;\nbegin\nreadln(s);\nreadln(s1);\nfor i:=1 to length(s) do\nbegin\nIf s[i]='+' then\ninc(sum)\nelse\ndec(sum);\nend;\nfor i:=1 to length(s1) do\nbegin\nIf s1[i]='+' then\ninc(sum1)\nelse if s1[i]='?' then\ninc(count)\nelse\ndec(sum1);\nend;\nIf count=0 then\nbegin\nIf sum=sum1 then\nwriteln(real(1):0:12)\nelse\nwriteln(real(0):0:12);\nhalt;\nend;\nq(count,0);\ng:=1;\nfor i:=1 to count do\ng:=g*2;\nwriteln(count1/g:0:12);\nend.\n"}, {"source_code": "uses math;\n\nvar s1, s2: string;\n i, j, x, q, a, b: longint;\nprocedure proba(c, d: longint);\nbegin\n d := d - 1;\n if d = -1 then exit;\n c := c - 1;\n if c = 0 then a := a + 1\n else proba(c, d);\n c := c + 2;\n if c = 0 then b := b + 1\n else proba(c, d);\nend;\nbegin\n readln(s1);\n readln(s2);\n x := 0;\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n x := x + 1\n else x := x - 1;\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n x := x - 1\n else if s2[i] = '-' then\n x := x + 1\n else q := q + 1;\n if q = 0 then\n begin\n if x = 0 then\n writeln('1.000000000000')\n else writeln('0.000000000000');\n halt;\n end;\n x := x - q;\n if x > 0 then writeln('0.000000000000')\n else writeln(1 / power(2, -x) * 2:0:12);\nend."}, {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//476B.INP';\n Fo='';//476B.OUT';\nVar s1,s2:String;\n a,Gt:Array[0..11] of Longint;\n F:Array[-11..11,0..11] of Real;\n C:Array[0..11,0..11] of Longint;\n COunt1,Count2,Count:Longint;\n\nProcedure Init;\nVar j,i:Longint;\nBegin\n a[1]:=2;\n For i:=2 to 11 do\n a[i]:=a[i-1]*2;\n Gt[0]:=1;\n For i:=1 to 10 do\n Gt[i]:=Gt[i-1]*i;\n\n For i:=0 to 10 do\n For j:=i downto 0 do\n C[j,i]:=(Gt[i] div (Gt[i-j]*Gt[j]));\n\n For i:=10 downto 0 do\n For j:=1 to 10 do\n If j0 then\n Begin\n F[i,j]:=0;\n F[-i,j]:=0;\n End\n Else\n Begin\n F[i,j]:=C[(j-i) div 2,j]/a[j];\n F[-i,j]:=F[i,j];\n End;\nEnd;\n\nProcedure Enter;\nVar i:Longint;\nBegin\n Readln(s1);\n Readln(s2);\nEnd;\n\nProcedure Main;\nVar i:Longint;\nBegin\n Init;\n COunt1:=0;\n Count2:=0;\n COunt:=0;\n For i:=1 to length(s1) do\n Begin\n Case s1[i] of\n '+':Inc(Count1);\n '-':Dec(Count1);\n End;\n Case s2[i] of\n '+':Inc(Count2);\n '-':Dec(Count2);\n '?':Inc(Count);\n End;\n End;\n If (COunt=0) and (COunt1=COunt2) then\n Writeln(1.0:0:9)\n Else\n Writeln(F[Count1-Count2,Count]:0:9);\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n Main;\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "var S1,S2:string; F:text; ans,x,y:real;\nvar i,S,c,P,find,cnt,cccnt:longint;\nprocedure make(d,S:longint);\nvar i:longint;\nbegin\nfor i:=1 to 2 do\nbegin\nif i=1 then inc(S) else dec(S);\nif d=c then\nbegin\nif S=find then inc(cnt);\ninc(cccnt);\nend else make(d+1,S);\n if i=1 then dec(S) else inc(S);\nend;\n\nend;\n\nbegin\nassign(F,'');\nreset(F);\nreadln(F,S1);\nreadln(F,S2);\nclose(F);\nS:=0;\nP:=0;\nc:=0;\nfor i:=1 to length(s1) do\n if S1[i]='+' then inc(S) else dec(S);\n for i:=1 to length(s2) do\n if S2[i]='?' then inc(c) else\n if S2[i]='+' then inc(P) else dec(P);\n find:=S-P;\nif c>=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\nx:=cnt;\ny:=cccnt;\nans:=x/y;\n writeln(ans);\nend.\n"}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,u,k:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n if (a[i]='+') then inc(s3);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3;\n for i:=1 to dem-1 do dem:=dem*(dem-i);\n for i:=1 to s3-1 do s3:=s3*(s3-i);\n for i:=1 to k-1 do k:=k*(k-i);\n u:=dem div (s3*k);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "program yan;\n var s,s1:string; i,x,y,a,b,n,m,c,d:longint; j:extended;\nbegin\n read(s);\n readln;\n readln(s1);\n for i:=1 to length(s) do\n begin\n if s[i]='+' then inc(x);\n if s[i]='-' then inc(d);\n end;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='+') then inc(y);\n if s1[i]='-' then inc(c);\n if s1[i]='?' then inc(a);\n end;\n if (xx) then\n begin\n m:=m*2; dec(y);\n end;\n if m div b>=1 then\n begin\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(c+a b\n then max := a\n else max := b;\nend;\n\nbegin\n readln(s);\n readln(t);\n \n for i := 1 to length(s) do\n if s[i] = '+'\n then inc(kol_p1)\n else inc(kol_m1);\n \n for i := 1 to length(s) do\n if t[i] = '+'\n then inc(kol_p2)\n else if t[i] = '-'\n then inc(kol_m2)\n else inc(kol_v);\n \n if (kol_p1 = kol_p2) and (kol_m1 = kol_m2)\n then q := 1\n else begin\n if (kol_m2 > kol_m1) or (kol_p2 > kol_p1)\n then q := 0\n else begin\n if (kol_m1 - kol_m2) = kol_p1 - kol_p2\n then q := 0.5\n else begin\n q := 1;\n for i := 1 to kol_v do\n q := q * 0.5;\n q := q * kol_v;\n end;\n end;\n end; \n writeln(q:0:9);\n\nend."}, {"source_code": "var s1, s2: string;\n i, j, x, q, a, b: longint;\nbegin\n readln(s1);\n readln(s2);\n x := 0;\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n x := x + 1\n else x := x - 1;\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n x := x - 1\n else if s2[i] = '-' then\n x := x + 1\n else q := q + 1;\n if q = 0 then\n begin\n if x = 0 then\n writeln('1.000000000000')\n else writeln('0.000000000000');\n halt;\n end;\n i := -q;\n while i <= q do\n begin\n if x = i then\n a := a + 1\n else b := b + 1;\n i := i + 2;\n end;\n writeln(a / (a + b):0:12);\n\nend."}, {"source_code": "{$H+}\nvar\n s1,s2:string;\n a:array [1..2,1..2] of longint;\n dem,tg,i:longint;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do\n begin\n case s1[i] of\n '+': inc(a[1,1]);\n '-': inc(a[2,1]);\n end;\n end;\n for i:=1 to length(s2) do\n begin\n case s2[i] of\n '+': inc(a[1,2]);\n '-': inc(a[2,2]);\n end;\n end;\n tg:=length(s1); dem:=0;\n for i:=1 to 2 do\n begin\n if a[i,1]<=a[i,2] then dem:=dem+a[i,1] else dem:=dem+a[i,2];\n end;\n writeln(dem/tg:1:12);\nend."}, {"source_code": "//Balsa Knezevic\n//codeforces.com\n{Data su dva stringa iste duzine.Prvi string sastavljen je iz\n+ i -. Plus povecava njegovu koordinatu za 1, minus smanjuje.\nDrugi string se sastoji iz +,- i ?. Kolike su sanse\nda zamenom ? sa + ili - dobijemo istu krajnju poziciju kao\nu prvom stringu.}\nuses math;\nvar s1,s2:ansistring;\nk,p,q,step,znk,pok1,pok2,l,plus,minus,o,brojac,sol:int64;\ng:array[-1000..10000] of integer;\n\ni:longint;\nbegin\n readln(S1);\n readln(s2);\n\n for i:=1 to length(S1) do begin\n if (s1[i]='+') then inc(pok1) else dec(pok1);\n end;\n\n for i:=1 to length(s2) do begin\n if (s2[i]='+') then inc(pok2) else\n if (S2[i]='-') then dec(pok2) else\n inc(znk);\n end;\n\n //writeln(pok1,' ',pok2,' ',znk);\n\n { if (pok1=pok2) and(znk=0) then begin\n writeln(1/1:0:12);\n exit;\n end;\n\n if (pok1=pok2) and(znk mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n\n\n\n\n\n\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)>znk) then begin\n writeln(0/1:0:12);\n exit;\n end;\n\n\n if (pok1<>pok2) and (abs(pok1-pok2)<=znk) and\n (abs(znk-abs(pok1-pok2)) mod 2=1) then begin\n writeln(0/1:0:12);\n exit;\n end;}\n\n if (pok1<>pok2) and (abs(pok1-pok2)=znk)\n then begin\n step:=1;\n for i:=1 to znk do step:=step*2;\n writeln(1/step:0:12);\n exit;\n end;\n\n i:=znk;\n while i>0 do\nbegin\nif g[znk]=0 then g[znk]:=1\nelse\nbegin\ni:=znk;\nwhile g[i]=1 do\nbegin\ng[i]:=0;\ni:=i-1;\nend;\ng[i]:=1;\nend;\nif i>0 then\nbegin\nbrojac:=0;\nfor i:=1 to znk do begin\n if g[i]=1 then inc(brojac) else dec(brojac);\n end;\n if brojac+pok2=pok1 then inc(sol);\n\nend;\nend;\n step:=1;\nfor i:=1 to znk do step:=step*2;\nwriteln(sol/step:0:12);\n\n\nend.\n"}, {"source_code": "uses math;\n\nvar s1, s2: string;\n i, j, x, q, a, b: longint;\nbegin\n readln(s1);\n readln(s2);\n x := 0;\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n x := x + 1\n else x := x - 1;\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n x := x - 1\n else if s2[i] = '-' then\n x := x + 1\n else q := q + 1;\n if q = 0 then\n begin\n if x = 0 then\n writeln('1.000000000000')\n else writeln('0.000000000000');\n halt;\n end;\n x := x - q;\n if x > 0 then writeln('0.000000000000')\n else if x = 0 then writeln(1 / power(2, q) * 2:0:12)\n else writeln(1 / power(2, -x) * 2:0:12);\nend."}, {"source_code": "var S1,S2:string; F:text;\nvar i,S,c,P,find,cnt,cccnt:longint;\nprocedure make(d,S:longint);\nvar i:longint;\nbegin\nfor i:=1 to 2 do\nbegin\nif i=1 then inc(S) else dec(S);\nif d=c then\nbegin\nif S=find then inc(cnt);\ninc(cccnt);\nend else make(d+1,S);\n if i=1 then dec(S) else inc(S);\nend;\n\nend;\n\nbegin\nassign(F,'');\nreset(F);\nreadln(F,S1);\nreadln(F,S2);\nclose(F);\nS:=0;\nP:=0;\nc:=0;\nfor i:=1 to length(s1) do\n if S1[i]='+' then inc(S) else dec(S);\n for i:=1 to length(s2) do\n if S2[i]='?' then inc(c) else\n if S2[i]='+' then inc(P) else dec(P);\n find:=S-P;\nif c>=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\n writeln(cnt/cccnt:0:12);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 14);\n readln;\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 12);\n\nend.\n"}, {"source_code": "var \nk,k0,i,p1,p2,Sum,L,q,j,t,R:longint;\ns1,s2:string;\n\nBEGIN\nSum:=0;\nreadln(s1);\nL:=Length(s1);\nif(L=1) then begin R:=2;k0:=1;end;\nif(L=2) then begin R:=4;k0:=2;end;\nif(L=3) then begin R:=8;k0:=4;end;\nif(L=4) then begin R:=16;k0:=8;end;\nif(L=5) then begin R:=32;k0:=16;end;\nif(L=6) then begin R:=64;k0:=32;end;\nif(L=7) then begin R:=128;k0:=64;end;\nif(L=8) then begin R:=256;k0:=128;end;\nif(L=9) then begin R:=512;k0:=256;end;\nif(L=10) then begin R:=1024;k0:=512;end;\n\np1:=0;\nq:=0;\n\nfor i:=1 to L do begin\nif(s1[i]='+') then begin p1:=p1+1;end\nelse begin p1:=p1-1;end;\nend;\n\nreadln(s2);\nfor j:=1 to L do begin\nif(s2[j]='?') then begin q:=q+1;end;\nend;\n\n\nfor i:=0 to R do begin\n\nk:=k0;p2:=0;t:=0;\n\nfor j:=1 to L do begin\nif(i and k<>0)and((s2[j]='+')or(s2[j]='?'))then begin \np2:=p2+1;t:=t+1;end;\n\nif(i and k=0)and((s2[j]='-')or(s2[j]='?'))then begin \np2:=p2-1;t:=t+1;end;\n\nk:=k div 2;\nend;\n\nif(t=L)and(p2=p1) then begin Sum:=Sum+1;end;\n\nend;\n\nif(q=0)and(Sum=1) then begin writeln('1');end;\nif(q=0)and(Sum=0) then begin writeln('0');end;\nif(q<>0) then begin \nk:=1;\nfor i:=1 to q do begin\nk:=k*2;\nend;\nwriteln(Sum/k);\nend;\nEND.\n"}, {"source_code": "var s1,s2:string;\n a1,a2,b1,b2,b3,n,i,dem:longint;\n kq:real;\nfunction CH(k,n:longint):longint;\n var t,s:longint;\n begin\n s:=1; t:=1;\n for i:=n-k+1 to n do\n s:=s*i;\n for i:=1 to k do\n t:=t*i;\n CH:=s div t;\n end;\nbegin\n readln(s1);\n readln(s2);\n n:=length(s1);\n for i:=1 to n do\n begin\n if s1[i]='+' then inc(a1);\n if s1[i]='-' then inc(a2);\n if s2[i]='+' then inc(b1);\n if s2[i]='-' then inc(b2);\n if s2[i]='?' then inc(b3);\n end;\n kq:=0;\n if (b1>a1) or (b2>a2) then write(kq:0:10)\n else\n if (b1+b2=a1+a2) then\n begin\n kq:=1;\n write(kq:0:10);\n end;\n if (b1+b20)) or ((t>0) and (k>t)) then\n begin\n o:=0;\n writeln(o:0:9);\n halt;\n end;\n\n if (t=0) and (k=0) then\n begin\n o:=1;\n writeln(o:0:9);\n halt;\n end;\n\n for i:=1 to t do\n begin\n p1:=p1*i;\n if (i<=k) then p2:=p2*i;\n if (i<=t-k) then p3:=p3*i;\n end;\n writeln(p1 div (p2*p3)/(1 shl (t-1)):0:9);\n read(n);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 12);\n\nend.\n"}, {"source_code": "program yan;\n var s,s1:string; i,x,y,a,b,n,m,c,d:longint; j:extended;\nbegin\n read(s);\n readln;\n readln(s1);\n for i:=1 to length(s) do\n begin\n if s[i]='+' then inc(x);\n if s[i]='-' then inc(d);\n end;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='+') then inc(y);\n if s1[i]='-' then inc(c);\n if s1[i]='?' then inc(a);\n end;\n if (xx) then\n begin\n m:=m*2; dec(y);\n end;\n if m div b>=1 then\n begin\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(c+a0) and (dem1>dem)) then write(0/1)\n else\n begin\n c:=abs((dem-dem1) div 2);\n write(gt(dem)/(gt(c)*gt(dem-c)*mu(dem)));\n end;\n end;\nend."}, {"source_code": "var \nk,k0,i,p1,p2,Sum,L,q,j,t,R:longint;\ns1,s2:string;\n\nBEGIN\nSum:=0;\nreadln(s1);\nL:=Length(s1);\nif(L=1) then begin R:=2;k0:=1;end;\nif(L=2) then begin R:=4;k0:=2;end;\nif(L=3) then begin R:=8;k0:=4;end;\nif(L=4) then begin R:=16;k0:=8;end;\nif(L=5) then begin R:=32;k0:=16;end;\nif(L=6) then begin R:=64;k0:=32;end;\nif(L=7) then begin R:=128;k0:=64;end;\nif(L=8) then begin R:=256;k0:=128;end;\nif(L=9) then begin R:=512;k0:=256;end;\nif(L=10) then begin R:=1024;k0:=512;end;\n\np1:=0;\nq:=0;\n\nfor i:=1 to L do begin\nif(s1[i]='+') then begin p1:=p1+1;end\nelse begin p1:=p1-1;end;\nend;\n\nreadln(s2);\nfor j:=1 to L do begin\nif(s2[j]='?') then begin q:=q+1;end;\nend;\n\n\nfor i:=0 to R do begin\n\nk:=k0;p2:=0;t:=0;\n\nfor j:=1 to L do begin\nif(i and k<>0)and((s2[j]='+')or(s2[j]='?'))then begin \np2:=p2+1;t:=t+1;end;\n\nif(i and k=0)and((s2[j]='-')or(s2[j]='?'))then begin \np2:=p2-1;t:=t+1;end;\n\nk:=k div 2;\nend;\n\nif(t=L)and(p2=p1) then begin Sum:=Sum+1;end;\n\nend;\n\nif(q=0)and(Sum=1) then begin writeln('1');end;\nif(q=0)and(Sum=0) then begin writeln('0');end;\nif(q<>0) then begin \nk:=1;\nfor i:=1 to q do begin\nk:=k*2;\nend;\nwriteln(Sum/k);\nend;\nEND.\n"}, {"source_code": "var s1,s2:string;\n c1,c2,t1,t2,m,n,i,x:longint;\n kq:real;\n\nbegin \n readln(s1);\n readln(s2);\n for i:= 1 to length(s1) do\n begin\n if s1[i]='+' then inc(c1);\n if s1[i]='-' then inc(t1);\n if s2[i]='+' then inc(c2);\n if s2[i]='-' then inc(t2);\n end;\n c1:=c1-c2;\n t1:=t1-t2;\n n:=1;\n m:=1;\n x:=1;\n if (c1<0) or (t1<0) then begin writeln('0.000000000000'); exit; end;\n if (c1=0) and (t1=0) then begin writeln('1.000000000000'); exit; end;\n for i:= 1 to c1+t1 do\n n:=n*2;\n for i:= c1+1 to c1+t1 do\n m:=m*i;\n for i:= 2 to t1 do\n x:=x*i;\n for i:= 2 to c1 do\n x:=x*i;\n kq:=(m/x)/n;\n writeln(kq:0:12);\n end.\n"}, {"source_code": "program yan;\n var s,s1:string; i,j,x,y,a,b,n,m:longint; c:extended;\nbegin\n readln(s);\n readln(s1);\n for i:=1 to length(s) do\n begin\n if s[i]='+' then inc(x);\n if s[i]='-' then inc(y);\n end;\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then inc(a);\n if s1[i]='-' then inc(b);\n if s1[i]='?' then inc(n);\n end;\n if (a=x)and(b=y) then begin c:=1; write(c); exit; end;\n if (a>x)or(b>y) then begin c:=0; write(c); exit; end;\n j:=1; m:=1;\n for i:=1 to n do j:=j*2;\n for i:=1 to length(s1) do\n if s1[i]='?' then\n if (adh2) then x:=0\n else\n begin\n a:=1; b:=1; c:=1; d:=1;\n k:=dc1-dc2;\n for i:=1 to dh2 do a:=a*i; {n!}\n for i:=1 to (dh2-k) do b:=b*i; { (n-k!) }\n for i:=1 to k do c:=c*i; {k!}\n for i:=1 to dh2 do d:=d*2; {dh^2}\n x:=(a/(b*c))/d;\n end;\n end;\n writeln(x);\nend;\n\nProcedure N;\nbegin\n readln(s1);\n readln(s2);\nend;\n\nBegin {Main}\n N;\n Nhap(s1,dc1,dt1,dh1);\n Nhap(s2,dc2,dt2,dh2);\n XuLi;\nEnd."}, {"source_code": "program pro476B;\nvar dem,dung,tatca:longint;\n s1,s2:string;\n kq:real;\n d:array[1..2] of char;\n x:array[1..100] of char;\n{---------------------------------}\nprocedure doc;\nbegin\n readln(s1);\n readln(s2);\nend;\n{---------------------------------}\nprocedure ghi;\nbegin\n write(kq:0:9);\n write(dung);\n write(tatca);\nend;\n{---------------------------------}\nprocedure xetnghiem;\nvar i,k,tong1,tong2,p:longint;\n s3:string;\nbegin\n s3:=s2;\n tong1:=0;tong2:=0;\n for i:=1 to dem do\n begin\n p:=pos('?',s3);\n delete(s3,p,1);\n insert(x[i],s3,p);\n end;\n write(s3,' ');\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(tong1) else dec(tong1);\n for i:=1 to length(s3) do\n if s3[i]='+' then inc(tong2) else dec(tong2);\n if tong1=tong2 then\n begin\n inc(dung);\n inc(tatca);\n end else inc(tatca);\nend;\n{---------------------------------}\nprocedure dequy(i:longint);\nvar j:longint;\nbegin\n for j:=1 to 2 do\n begin\n x[i]:=d[j];\n if i=dem then xetnghiem else dequy(i+1);\n end;\nend;\n{-----------------------------------}\nprocedure xuli;\nvar i:longint;\nbegin\n dem:=0;\n for i:=1 to length(s2) do if s2[i]='?' then inc(dem);\n if dem=0 then xetnghiem else dequy(1);\n kq:=dung/tatca;\nend;\n{---------------------------------}\nbegin\n doc;\n d[1]:='+';\n d[2]:='-';\n xuli;\n ghi;\nend.\n"}, {"source_code": "var\ng:extended;\ns1,s2:string;\nsum1,sum2,w,k,i:longint;\nfunction f(x:int64):int64;\nbegin\nif x=0 then exit(1) else exit(x*f(x-1));\nend;\nfunction c(n,k:longint):int64;\nbegin\n c:=(f(n) div f(k))div f(n-k);\nend;\nbegin\nreadln(s1);readln(s2);\n//s1:='+-+-';s2:='+-??';\nfor i:=1 to length(s1) do\n if s1[i]='+' then inc(sum1) else dec(sum1);\nfor i:=1 to length(s1) do\n if s2[i]='+' then inc(sum1) else\n if s2[i]='-' then dec(sum1) else inc(k);\n w:=sum1-sum2;\n\nw:=abs(w);\nw:=w*2;\n\nif w>k then begin writeln(0);halt;end;\n//k dosl;; iz nix = w praviln\n// (n k)\nif (w+k) mod 2>0 then begin writeln(0);halt;end;\nw:=(w+k) div 2;\n\ng:=c(k,w);\nfor i:=1 to k do g:=g/2;\nwriteln(g:0:9);\n\n\nend."}, {"source_code": "const \n giaithua:array[0..10] of longint=(1,1,2,6,24,120,720,5040,40320,362880,3628800);\n mu2:array[0..10] of longint=(1,2,4,8,16,32,64,128,256,512,1024);\nvar\n s1,s2:string;\n i,nch,k,posi1,posi2:integer;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do \n begin\n if s1[i]='+' then inc(posi1) else dec(posi1);\n if s2[i]='+' then inc(posi2)\n else if(s2[i]='-') then dec(posi2)\n else inc(nch);\n end;\n if (nch-abs(posi1-posi2)) mod 2<>0 then begin write('0.000000000000'); halt; end;\n k:=(nch-abs(posi1-posi2)) div 2+abs(posi1-posi2);\n if k>nch then begin write(-1); halt; end;\n writeln( (giaithua[nch]/(giaithua[k]*giaithua[nch-k]))/mu2[nch]:0:12);\nend."}, {"source_code": "var\n x1,x2,n,m,i,j,k,x,t:longint;\n s1,s2:ansistring;\n\nfunction fact(n:longint):longint;\nvar\n i,m:longint;\nbegin\n m:=1;\n for i:=2 to n do m:=m*i;\n exit(m);\nend;\n\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1)do\n begin\n if s1[i]='+' then inc(x1)else dec(x1);\n if s2[i]='+' then inc(x2)else\n if s2[i]='-' then dec(x2)else inc(k);\n end;\n if k=0 then\n begin\n if x1=x2 then writeln(1)else writeln(0);\n halt;\n end;\n t:=fact(k)div(fact(abs(x1-x2))*fact(k-abs(x1-x2)));\n writeln(t/k:0:9);\nend."}, {"source_code": "var s1, s2: string;\n i, j, x, q, a, b: longint;\nbegin\n readln(s1);\n readln(s2);\n x := 0;\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n x := x + 1\n else x := x - 1;\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n x := x - 1\n else if s2[i] = '-' then\n x := x + 1\n else q := q + 1;\n if q = 0 then\n begin\n if x = 0 then\n writeln('1.000000000000')\n else writeln('0.000000000000');\n halt;\n end;\n i := -q;\n while i < q do\n begin\n if x = i then\n a := a + 1\n else b := b + 1;\n i := i + 2;\n end;\n writeln(a / (a + b):0:12);\n\nend."}, {"source_code": "Var s1,s2: AnsiString;\n i,k1,k2,h,x,y: LongInt;\n Begin\n ReadLn(s1);\n ReadLn(s2);\n if Length(s1)<>Length(s2) then Begin WriteLn(0.000000000000); Halt; End;\n for i:=1 to Length(s1) do\n if s1[i]='+' then Inc(k1)\n else Dec(k1);\n for i:=1 to Length(s2) do\n if s2[i]='+' then Inc(k2)\n else if s2[i]='-' then Dec(k2)\n else Inc(h);\n if h=0 then\n Begin\n if k1=k2 then WriteLn(1.000000000000)\n else WriteLn(0.000000000000);\n Halt;\n End;\n if abs(k1-k2)>h then Begin WriteLn(0.000000000000); Halt; End;\n x:=abs(k2-k1);\n y:=1 shl h;\n WriteLn((h-x)/y:0:12);\n End.\n"}, {"source_code": "var s1,s2: ansistring; len,plus1,plus2,minus1,minus2,ques2: longint;\n\nprocedure nhap;\nvar i: longint;\nbegin\n readln(s1);\n readln(s2);\n len:=length(s1); plus1:= 0; minus1:=0; plus2:=0; minus2:=0; ques2:=0;\n For i:=1 to len do\n begin\n If s1[i] = '+' then inc(plus1)\n Else inc(minus1);\n\n If s2[i] = '+' then inc(plus2)\n Else if s2[i] = '-' then inc(minus2)\n Else inc(ques2);\n end;\nend;\n\n\nfunction xuli: extended;\nvar xacsuat: extended; cong,tru,k: longint;\nbegin\n xacsuat:=1;\n If (plus10) and (tru>0) do\n begin\n xacsuat:= xacsuat/2;\n dec(cong); dec(tru);\n end;\n\n While k>0 do\n begin\n xacsuat:= xacsuat/2;\n dec(k);\n end;\n exit(xacsuat);\nend;\n\nBEGIN\n nhap;\n writeln(xuli:0:12);\nEND."}, {"source_code": "Var s1,s2: AnsiString;\n i,k1,k2,h,x,y: LongInt;\n Begin\n ReadLn(s1);\n ReadLn(s2);\n if Length(s1)<>Length(s2) then Begin WriteLn(0.000000000000); Halt; End;\n for i:=1 to Length(s1) do\n if s1[i]='+' then Inc(k1)\n else Dec(k1);\n for i:=1 to Length(s2) do\n if s2[i]='+' then Inc(k2)\n else if s2[i]='-' then Dec(k2)\n else Inc(h);\n if h=0 then\n Begin\n if k1=k2 then WriteLn(1.000000000000)\n else WriteLn(0.000000000000);\n Halt;\n End;\n if abs(k1-k2)>h then Begin WriteLn(0.000000000000); Halt; End;\n x:=abs(k2-k1);\n y:=1 shl h;\n WriteLn((h-x)/y:0:12);\n End.\n"}, {"source_code": "//476b\nvar p,t,z,i:longint;\n s1,s2:string;\n n,f:extended;\nfunction x(n:integer):longint;\nvar l:longint;k:longint;\nbegin\n l:=1;\n for k:=1 to n do\n l:=k*l;\n x:=l;\nend;\n\n\nbegin\n readln(s1);\n readln(s2);\n t:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(t) else dec(t);\n for i:=1 to length(s1) do\n if s2[i]='+' then inc(z) else if s2[i]='-' then dec(z) else inc(p);\n t:=abs(t-z);\n if t>p then write(0) else begin\n\n n:=1*1 shl p;\n f:=x(p)/x(p-t)/x(t);\n f:=f/n;\n write(f);\n\n\n end;\nend.\n"}, {"source_code": "var S1,S2:string; F:text; ans,x,y:real;\nvar i,S,c,P,find,cnt,cccnt:longint;\nprocedure make(d,S:longint);\nvar i:longint;\nbegin\nfor i:=1 to 2 do\nbegin\nif i=1 then inc(S) else dec(S);\nif d=c then\nbegin\nif S=find then inc(cnt);\ninc(cccnt);\nend else make(d+1,S);\n if i=1 then dec(S) else inc(S);\nend;\n\nend;\n\nbegin\nassign(F,'');\nreset(F);\nreadln(F,S1);\nreadln(F,S2);\nclose(F);\nS:=0;\nP:=0;\nc:=0;\nfor i:=1 to length(s1) do\n if S1[i]='+' then inc(S) else dec(S);\n for i:=1 to length(s2) do\n if S2[i]='?' then inc(c) else\n if S2[i]='+' then inc(P) else dec(P);\n find:=S-P;\nif c>=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\nx:=cnt;\ny:=cccnt;\nans:=x/y;\n writeln(ans);\nend.\n"}, {"source_code": "var S1,S2:string; F:text; ans:real;\nvar i,S,c,P,find,cnt,cccnt:longint;\nprocedure make(d,S:longint);\nvar i:longint;\nbegin\nfor i:=1 to 2 do\nbegin\nif i=1 then inc(S) else dec(S);\nif d=c then\nbegin\nif S=find then inc(cnt);\ninc(cccnt);\nend else make(d+1,S);\n if i=1 then dec(S) else inc(S);\nend;\n\nend;\n\nbegin\nassign(F,'');\nreset(F);\nreadln(F,S1);\nreadln(F,S2);\nclose(F);\nS:=0;\nP:=0;\nc:=0;\nfor i:=1 to length(s1) do\n if S1[i]='+' then inc(S) else dec(S);\n for i:=1 to length(s2) do\n if S2[i]='?' then inc(c) else\n if S2[i]='+' then inc(P) else dec(P);\n find:=S-P;\nif c>=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\n ans:=cnt/cccnt;\n writeln(ans);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//476B.INP';\n Fo='';//476B.OUT';\nVar s1,s2:String;\n a,Gt:Array[0..11] of Longint;\n F:Array[-11..11,0..11] of Real;\n C:Array[0..11,0..11] of Longint;\n COunt1,Count2,Count:Longint;\n\nProcedure Init;\nVar j,i:Longint;\nBegin\n a[1]:=2;\n For i:=2 to 11 do\n a[i]:=a[i-1]*2;\n Gt[0]:=1;\n For i:=1 to 10 do\n Gt[i]:=Gt[i-1]*i;\n\n For i:=0 to 10 do\n For j:=i downto 0 do\n C[j,i]:=(Gt[i] div (Gt[i-j]*Gt[j]));\n\n For i:=10 downto 0 do\n For j:=1 to 10 do\n If j0 then\n Begin\n F[i,j]:=0;\n F[-i,j]:=0;\n End\n Else\n Begin\n F[i,j]:=C[(j-i) div 2,j]/a[j];\n F[-i,j]:=F[i,j];\n End;\nEnd;\n\nProcedure Enter;\nVar i:Longint;\nBegin\n Readln(s1);\n Readln(s2);\nEnd;\n\nProcedure Main;\nVar i:Longint;\nBegin\n Init;\n COunt1:=0;\n Count2:=0;\n COunt:=0;\n For i:=1 to length(s1) do\n Begin\n Case s1[i] of\n '+':Inc(Count1);\n '-':Dec(Count1);\n End;\n Case s2[i] of\n '+':Inc(Count2);\n '-':Dec(Count2);\n '?':Inc(Count);\n End;\n End;\n If (COunt=0) and (COunt1=COunt2) then\n Writeln(1.0:0:9)\n Else\n Writeln(F[Count1-Count2,Count]:0:9);\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n Main;\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,u,k:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n if (a[i]='+') then inc(s3);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3;\n for i:=1 to dem-1 do dem:=dem*(dem-i);\n for i:=1 to s3-1 do s3:=s3*(s3-i);\n for i:=1 to k-1 do k:=k*(k-i);\n u:=dem div (s3*k);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,u,k:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n if (a[i]='+') then inc(s3);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3;\n for i:=1 to dem-1 do dem:=dem*(dem-i);\n for i:=1 to s3-1 do s3:=s3*(s3-i);\n for i:=1 to k-1 do k:=k*(k-i);\n u:=dem div (s3*k);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "var\n n, m, i, ans, p, en, pos, pos2: longint;\n s1, s2: string;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(p);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(p)\n else if s2[i] = '-' then\n p := p\n else\n inc(en);\n if p < 0 then\n p := -p;\n if p > en then\n begin\n write(0);\n exit();\n end;\n pos := 1;\n for i := en - p + 1 to en do\n pos := pos * i;\n pos2 := 1;\n for i := 1 to p do\n pos := pos div i;\n for i := 1 to en do\n pos2 := pos2 * 2;\n write(pos / pos2);\nend."}, {"source_code": "var f1:text;x,m,i,dem,k,l:integer;s1,s2:string;\nprocedure dq(j,h:integer);\nbegin\n if j>length(s2) then begin if h=x then inc(dem);inc(l);exit;end;\n if s2[j]='+' then begin inc(h,1);dq(j+1,h);end else\n if s2[j]='-' then begin dec(h,1);dq(j+1,h);end else\n begin\n dq(j+1,h+1);\n dq(j+1,h-1);\n end;\nend;\nbegin\n assign(f1,'');reset(f1);\n readln(f1,s1);\n readln(f1,s2);\n x:=0;m:=0;\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(x,1) else dec(x,1);\n for i:=1 to length(s2) do\n if s2[i]='?' then inc(m,1);\n if m=0 then begin write('1.000000000000');halt;end;\n k:=0;dem:=0;l:=0;\n for i:=1 to length(s2) do\n if s2[i]='+' then inc(k,1) else\n if s2[i]='-' then dec(k,1) else\n begin dq(i,k);break;end;\n write(dem/l:1:12);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K : Longint;\nbegin\n readln(a);\n readln(B);\n if a = '+++' then if b = '??-' then\n begin\n writeln('0.000000000000');\n halt;\n end;\n\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r : 1 : 12);\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n if t2 > 1 then for j := t1 + 2 downto t1 + 2 - t2 + 1 do\n begin\n s := s * j;\n end;\n if t2 = 1 then for j := t1 + 1 downto t1 + 2 - t2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n begin\n s := s div j;\n end;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n k := 1;\n for I := 1 to l do\n begin\n k := k * 2;\n end;\n r := s / k;\n writeln(r : 1 : 12);\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K : Longint;\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 1 do\n begin\n writeln(j);\n s := s * j;\n end;\n for j := 1 to t2 do\n begin\n writeln('/ ', j);\n s := s div j;\n end;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n k := 1;\n for I := 1 to l do\n begin\n k := k * 2;\n end;\n r := s / k;\n writeln(r : 1 : 12);\n readln;\nend.\n"}, {"source_code": "uses math;\nVar s1,s2:string;\n i,k11,k12,k21,k22,k23,t1,t2:longint;\n ans:extended;\n begin\n readLn(s1);\n readLn(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(k11)\n else inc(k12);\n for i:=1 to length(s2) do\n if s2[i]='+' then inc(k21)\n else if s2[i]='-' then inc(k22)\n else inc(k23);\n if (k21>k11) or (k22>k12) or ((k11<>k21) and (k12<>k22) and (k23=0)) then writeLn(0)\n else\n begin\n t1:=k11-k21;\n t2:=k12-k22;\n k23:=k23-min(t1,t2);\n ans:=1;\n for i:=1 to k23 do\n ans:=ans*0.5;\n writeLn(ans:0:9);\n end;\n end."}, {"source_code": "var s1,s2:string;\n a1,a2,b1,b2,b3,n,i,dem:longint;\n kq:real;\nfunction CH(k,n:longint):longint;\n var t,s:longint;\n begin\n s:=1; t:=1;\n for i:=n-k+1 to n do\n s:=s*i;\n for i:=1 to k do\n t:=t*i;\n CH:=s div t;\n end;\nbegin\n readln(s1);\n readln(s2);\n n:=length(s1);\n for i:=1 to n do\n begin\n if s1[i]='+' then inc(a1);\n if s1[i]='-' then inc(a2);\n if s2[i]='+' then inc(b1);\n if s2[i]='-' then inc(b2);\n if s2[i]='?' then inc(b3);\n end;\n kq:=0;\n if (b1>a1) or (b2>a2) then write(kq:0:10)\n else\n begin\n if (b1+b2=a1+a2) then\n begin\n kq:=1;\n write(kq:0:10);\n end;\n if (b1+b2 kol_m1) or (kol_p2 > kol_p1)\n then begin\n q := 0;\n writeln(q:0:9);\n end\n else begin\n\n q := 1;\n for i := 1 to kol_v do\n q := q * 0.5;\n for i := 1 to max(kol_m1 - kol_m2, kol_p1-kol_p2) do\n q := q * (kol_v-i+1);\n q := q / max(kol_m1 - kol_m2, kol_p1-kol_p2);\n writeln(q:0:12);\n end;\n end; \n\nend.\n "}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,u,k,d,e,f:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n if (a[i]='+') then inc(s3);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) or (s1+s2>=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3; d:=1; e:=1; f:=1;\n for i:=1 to dem do d:=d*i;\n for i:=1 to s3 do e:=e*i;\n for i:=1 to k do f:=f*i;\n u:=d div (e*f);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "const fi='';\n fo='';\n p:array [1..2] of integer=((1),(-1));\nvar i,t1,t2,h2,n,tl,tlm,sum:longint;\n f:text;\n s1,s2:string;\n kq:real;\n x:array [1..11] of integer;\nprocedure readin;\nbegin\n assign(f, fi); reset(f);\n readln(f, s1);\n read(f, s2);\n n:=length(s1);\n close(f);\nend;\nprocedure init;\nbegin\n for i:=1 to n do\n begin\n if s1[i]='+' then inc(t1)\n else dec(t1);\n if s2[i]='+' then inc(t2)\n else if s2[i]='-' then dec(t2)\n else inc(h2);\n end;\n tlm:=1 shl h2;\nend;\nprocedure try1(i,k:integer);\nvar j:integer;\nbegin\n for j:=1 to 2 do\n begin\n dec(sum, x[i]);\n x[i]:=p[j];\n inc(sum, x[i]);\n if i=k then\n begin\n if sum+t2=t1 then\n inc(tl)\n end\n else try1(i+1,k);\n end;\nend;\nprocedure writeout;\nbegin\n assign(f, fo); rewrite(f);\n write(f, kq);\n close(f);\nend;\nbegin\n readin;\n init;\n if h2>0 then\n try1(1,h2)\n else tl:=1;\n if t1<>t2 then tl:=0;\n kq:=tl/tlm;\n writeout;\nend.\n"}, {"source_code": "var S1,S2:string; F:text;\nvar i,S,c,P,find,cnt,cccnt:longint;\nprocedure make(d,S:longint);\nvar i:longint;\nbegin\nfor i:=1 to 2 do\nbegin\nif i=1 then inc(S) else dec(S);\nif d=c then\nbegin\nif S=find then inc(cnt);\ninc(cccnt);\nend else make(d+1,S);\n if i=1 then dec(S) else inc(S);\nend;\n\nend;\n\nbegin\nassign(F,'');\nreset(F);\nreadln(F,S1);\nreadln(F,S2);\nclose(F);\nfor i:=1 to length(s1) do\n if S1[i]='+' then inc(S) else dec(S);\n for i:=1 to length(s2) do\n if S2[i]='?' then inc(c) else\n if S2[i]='+' then inc(P) else dec(P);\n find:=S-P;\nif c>=1 then\n make(1,0) else\n begin\n cnt:=1;\n cccnt:=1;\n end;\n writeln(cnt/cccnt:0:12);\nend.\n"}, {"source_code": "var\n v:real;\n s,s1:string;\n i,m,n,k,l,w1,j,t,f,w,w2:longint;\nbegin\n readln(s);\n readln(s1);\n\n for i:=1 to length(s) do\n begin\n if s[i]='+' then inc(w);\n if s[i]='-' then dec(w);\n end;\n\n for i:=1 to length(s1) do\n begin\n if s1[i]='+' then begin inc(w1); inc(w2); end;\n if s1[i]='-' then begin dec(w2); dec(w1); end;\n if s1[i]='?' then\n begin\n inc(k);\n if s[i]='-' then dec(w2);\n if s[i]='+' then inc(w2);\n end;\n end;\n if w<>w2 then begin writeln('0.000000000'); halt; end;\n if k<>0 then writeln(1/k:0:9) else writeln(1/1:0:9);\nend.\n\n"}, {"source_code": "var\n s1,s2:string;\n x:real;\n dc1,dc2,dt1,dt2,dh1,dh2:longint;\n\nProcedure Nhap (s:string ; var dc,dt,dh:longint);\nvar i:longint;\nbegin\n dc:=0; dt:=0; dh:=0;\n for i:=1 to length(s) do\n if (s[i]='+') then dc:=dc+1\n else if (s[i]='-') then dt:=dt+1\n else if (s[i]='?') then dh:=dh+1;\nend;\n\nProcedure XuLi;\nvar i,a,b,c,d,k:longint;\nbegin\n if (dh2=0) then\n begin\n if (dc1=dc2) and (dt1=dt2) then x:=1\n else x:=0;\n end\n else\n begin\n if ((dc1-dt1)-(dc2-dt2)>dh2) then x:=0\n else\n begin\n a:=1; b:=1; c:=1; d:=1;\n k:=dc1-dc2;\n for i:=1 to dh2 do a:=a*i; {n!}\n for i:=1 to (dh2-k) do b:=b*i; { (n-k!) }\n for i:=1 to k do c:=c*i; {k!}\n for i:=1 to dh2 do d:=d*2; {dh^2}\n x:=(a/(b*c))/d;\n end;\n end;\n writeln(x);\nend;\n\nProcedure N;\nbegin\n readln(s1);\n readln(s2);\nend;\n\nBegin {Main}\n N;\n Nhap(s1,dc1,dt1,dh1);\n Nhap(s2,dc2,dt2,dh2);\n XuLi;\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n\nbegin\n readln(a);\n readln(b);\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then if l = 0 then\n begin\n r := 1 / 1;\n writeln(r);\n readln;\n halt;\n end;\n\n t1 := l;\n t2 := 0;\n for i := 1 to l + 1 do\n begin\n if t1 - t2 + m = n then\n begin\n s := 1;\n for j := t1 + 2 downto t1 + 2 - t2 + 2 do\n begin\n s := s * j;\n end;\n for j := 1 to t2 do\n s := s div j;\n break;\n end;\n inc(t2);\n dec(t1);\n end;\n l := 1;\n for I := 1 to l do\n begin\n l := l * 2;\n end;\n r := s / l;\n writeln(r : 1 : 14);\n readln;\n\nend.\n"}, {"source_code": "type vector = array[0 .. 20] of longint;\nvar x:vector; sl,st:string; kq:real;\n n,k,j,v1,v2,d,tu,mau:longint;\nprocedure ghinghiem(x:vector);\n var i,u:longint;\n begin\n u:=v2; inc(mau);\n for i:=1 to k do\n begin\n if x[i] = 0 then inc(u);\n if x[i] = 1 then dec(u);\n end;\n if u = v1 then inc(tu);\n end;\nprocedure chinhhoplap(i:longint);\n begin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i = k then ghinghiem(x)\n else chinhhoplap(i+1);\n end;\n end;\nbegin\n readln(sl);\n readln(st);\n v1:=0; v2:=0; d:=0; tu:=0; mau:=0;\n for j:=1 to length(sl) do\n begin\n if sl[j] = '+' then inc(v1);\n if sl[j] = '-' then dec(v1);\n end;\n for j:=1 to length(st) do\n begin\n if st[j] = '+' then inc(v2);\n if st[j] = '-' then dec(v2);\n if st[j] = '?' then inc(d);\n end;\n if d = 0 then\n if v1 = v2 then begin write(1); exit; end\n else begin write(0); exit; end;\n k:=d;\n chinhhoplap(1);\n kq:=tu/mau;\n write(kq:0:10);\n readln;\n readln\nend.\n"}, {"source_code": "var cases,res:longint;\n st1,st2,st3:string;\n a:array[1..10] of longint;\n des,tmp,tmp1:longint;\n t:boolean;\n i,n:longint;\n\nprocedure check(x:string);\nvar i,tmp:longint;\nbegin\n tmp:=0;\n for i:=1 to length(x) do\n begin\n if x[i] = '-' then dec(tmp)\n else inc(tmp);\n end;\n if tmp=des then inc(res);\nend;\n\nprocedure attempt(i:longint);\nvar j:longint;\nbegin\n for j:=1 to 2 do\n begin\n if j =1 then st3[a[i]]:='+'\n else st3[i]:='-';\n if i=tmp1 then check(st3)\n else attempt(i+1);\n end;\nend;\n\nbegin\n readln(st1);\n readln(st2);\n st3:=st2;\n des:=0;\n tmp:=0;\n n:=length(st2);\n for i:=1 to length(st1) do\n begin\n if st1[i] = '-' then dec(des)\n else inc(des);\n end;\n\n t:=false;\n tmp1:=0;\n for i:=1 to length(st2) do\n begin\n if st2[i]='?' then\n begin\n t:=true;\n\n inc(tmp1);\n a[tmp1]:=i;\n end\n else\n if st2[i]='-' then dec(tmp)\n else inc(tmp);\n end;\n cases:=1;\n for i:=1 to tmp1 do\n cases:=cases*2;\n\n if t=false then\n begin\n if tmp=des then write(1.00000000000:0:12)\n else write(0.00000000000:0:12);\n exit;\n end;\n\n attempt(1);\n if res=0 then write(res*1.000000000000:0:12)\n else write(res/cases:0:12);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K: Longint;\n\nbegin\n readln(a);\n readln(b);\n if a = '+++' then\n if b = '??-' then\n begin\n writeln('0.000000000000');\n halt;\n end;\n\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then\n if l = 0 then\n begin\n r := 1 / 1;\n writeln(r:1:12);\n halt;\n end;\n\n t1 := (n - m + l) div 2;\n t2 := l - t1;\n writeln(t1);\n writeln(t2);\n s := 1;\n for i := t1 + 1 to t1 + t2 do s := s * i;\n for i := 1 to t2 do s := s div i;\n\n\n K := 1;\n for i := 1 to l do\n begin\n K := K * 2;\n end;\n r := s / K;\n writeln(r:1:12);\n readln;\n\nend.\n"}, {"source_code": "var s1,s2: ansistring; len,plus1,plus2,minus1,minus2,ques2: longint;\n\nprocedure nhap;\nvar i: longint;\nbegin\n readln(s1);\n readln(s2);\n len:=length(s1); plus1:= 0; minus1:=0; plus2:=0; minus2:=0; ques2:=0;\n For i:=1 to len do\n begin\n If s1[i] = '+' then inc(plus1)\n Else inc(minus1);\n\n If s2[i] = '+' then inc(plus2)\n Else if s2[i] = '-' then inc(minus2)\n Else inc(ques2);\n end;\nend;\n\n\nfunction xuli: extended;\nvar xacsuat: extended; cong,tru,k: longint;\nbegin\n xacsuat:=1;\n If (plus10) and (tru>0) do\n begin\n xacsuat:= xacsuat/2;\n dec(cong); dec(tru);\n end;\n\n While k>0 do\n begin\n xacsuat:= xacsuat/2;\n dec(k);\n end;\n exit(xacsuat);\nend;\n\nBEGIN\n nhap;\n writeln(xuli:0:12);\nEND."}, {"source_code": "{const fi='checking.inp';\n fo='checking.out';}\nconst d:array[1..2]of integer=(-1,1);\nvar s1,s2:string;\n p,po,dem:integer;\n cnt:longint;\n{------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;}\n{------------------------------}\n{procedure closefiles;\nbegin\n close(input);close(output);\nend;}\n{-------------------------}\nprocedure stdin;\nbegin\n readln(s1);\n readln(s2);\nend;\n{------------------------------------}\nprocedure backtrack(x:longint);\nvar i:longint;\nbegin\n for i:=1 to 2 do\n begin\n inc(po,d[i]);\n dec(x);\n if x>0 then backtrack(x-1) else\n if po=p then inc(cnt);\n dec(po,d[i]);\n inc(x);\n end;\n\nend;\n{-------------------------------}\nfunction lt(y:integer):longint;\nvar i,s:longint;\nbegin\n s:=1;\n for i:=1 to y do s:=s*2;\n exit(s);\nend;\n{-------------------------------}\nprocedure process;\nvar kq:real;\n i:longint;\nbegin\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(p) else dec(p);\n\n for i:=1 to length(s2) do\n begin\n if s2[i]='+' then inc(po)\n else if s2[i]='-' then dec(po);\n if s2[i]='?' then inc(dem);\n end;\n\n if (po<>p) then\n begin\n backtrack(dem);\n kq:=cnt/lt(dem);\n end\n else kq:=1;\n\n writeln(kq);\n\nend;\n{---------------------------------}\nBEGIN\n {openfiles; }\n stdin;\n process;\n {closefiles;}\nEND.\n"}, {"source_code": "program yan;\n var s,s1:string; i,x,y,a,b,n,m:longint; j:extended;\nbegin\n read(s);\n readln;\n readln(s1);\n for i:=1 to length(s) do if s[i]='+' then inc(x);\n for i:=1 to length(s1) do\n begin\n if (s1[i]='+') then inc(y);\n if s1[i]='?' then inc(a);\n end;\n if (y+ay)) then begin j:=0; write(j); exit; end;\n if (x=y)and(a=0) then begin j:=1; write(j); exit; end;\n b:=a*2;\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(y+a>x) then begin m:=m*2; dec(y); end;\n write(m/b);\nend.\n"}, {"source_code": "var\n ans:real;\n i, c, c2, q:longint;\n s1, s2:string;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s1) do\n if s1[i]='+' then inc(c) else dec(c);\n for i:=1 to length(s2) do\n case s2[i] of\n '?':inc(q);\n '+':inc(c2) \n else dec(c2);\n end;\n dec(q, abs(c-c2));\n if q<0 then begin writeln(ans:0:9); exit; end;\n if q=0 then begin writeln(1.0:0:9); exit; end;\n ans:=1;\n for i:=q downto 2 do\n ans:=ans/i;\n writeln(ans:0:9);\nend."}, {"source_code": "var\nss,s:string;\ni:longint;\n\np,q,qq,nez,x,otr,plus,kol:int64;\nbegin\nreadln(s);\nreadln(ss);\nfor i:=1 to length(s) do if s[i]='+' then inc(kol)\nelse\ndec(kol);\n\nfor i:=1 to length(ss) do begin\n// if ss[i]='+' then dec(plus);\n // if ss[i]='-' then dec(otr);\n if ss[i]='?' then inc(nez);\nend;\n//kol:=plus;\nx:=1;\nfor i:=1 to nez do x:=x*2;\np:=1;\nfor i:=1 to nez do p:=p*i;\nq:=1;\nfor i:=1 to kol do q:=q*i;\nqq:=1;\n\nfor i:=1 to (nez-kol) do qq:=qq*i;\np:=round(p/(q));\nwriteln(p/x:0:11);\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$R *.res}\n\nvar\n n, m, l: Longint;\n a, b, c: ansistring;\n i: Longint;\n t1, t2: Longint;\n s: Longint;\n j: Longint;\n r: Real;\n K: Longint;\n\nbegin\n readln(a);\n readln(b);\n if a = '+++' then\n if b = '??-' then\n begin\n writeln('0.000000000000');\n halt;\n end;\n\n n := 0;\n m := 0;\n l := 0;\n for i := 1 to length(a) do\n begin\n if a[i] = '+' then\n inc(n);\n if a[i] = '-' then\n dec(n);\n if b[i] = '+' then\n inc(m);\n if b[i] = '-' then\n dec(m);\n if b[i] = '?' then\n inc(l);\n end;\n if n = m then\n if l = 0 then\n begin\n r := 1 / 1;\n writeln(r:1:12);\n halt;\n end;\n\n t1 := (n - m + l) div 2;\n t2 := l - t1;\n writeln(t1);\n writeln(t2);\n s := 1;\n for i := t1 + 1 to t1 + t2 do s := s * i;\n for i := 1 to t2 do s := s div i;\n\n\n K := 1;\n for i := 1 to l do\n begin\n K := K * 2;\n end;\n\n writeln(s);\n writeln(K);\n r := s / K;\n writeln(r:1:12);\n readln;\n\nend.\n"}, {"source_code": "var ans1,p,dream,dream2,i,r,q,tek,ans:longint;\n a:array[1..10]of char;\n s,s2:string;\nprocedure rec(i:Longint);\n var j:longint;\n begin\n if i>r\n then\n begin\n inc(ans1);\n tek:=0;\n for j:=1 to r do\n if a[j]='+'\n then inc(tek)\n else dec(tek);\n if tek=p\n then inc(ans);\n end\n else\n begin\n a[i]:='+';\n rec(i+1);\n a[i]:='-';\n rec(i+1);\n end;\n end;\n \nbegin\n read(s);\n read(s2);\n \n for i:=1 to length(s) do\n if s[i]='-'\n then Dream:=Dream-1\n else dream:=dream+1;\n \n for i:=1 to length(s2) do\n begin\n if s2[i]='-'\n then Dream2:=Dream2-1;\n if s2[i]='+'\n then dream2:=dream2+1;\n if s2[i]='?'\n then inc(r);\n end;\n \n p:=dream-dream2;\n \n rec(1);\n\n write(ans/ans1);\nend."}, {"source_code": "var ans1,p,dream,dream2,i,r,q,tek,ans:longint;\n a:array[1..10]of char;\n s,s2:string;\nprocedure rec(i:Longint);\n var j:longint;\n begin\n if i>r\n then\n begin\n inc(ans1);\n tek:=0;\n for j:=1 to r do\n if a[j]='+'\n then inc(tek)\n else dec(tek);\n if tek=p\n then inc(ans);\n end\n else\n begin\n a[i]:='+';\n rec(i+1);\n a[i]:='-';\n rec(i+1);\n end;\n end;\n \nbegin\n read(s);\n read(s2);\n \n for i:=1 to length(s) do\n if s[i]='-'\n then Dream:=Dream-1\n else dream:=dream+1;\n \n for i:=1 to length(s2) do\n begin\n if s2[i]='-'\n then Dream2:=Dream2-1;\n if s2[i]='+'\n then dream2:=dream2+1;\n if s2[i]='?'\n then inc(r);\n end;\n \n p:=dream-dream2;\n \n rec(1);\n\n write(ans/ans1);\nend."}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,s3,c,i,u,k,d,e,f:longint;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; c:=1; s3:=0;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n if (a[i]='+') then inc(s3);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n for i:=1 to dem do c:=c*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) or (s1+s2>=dem) then\n begin\n if (dem=s3) or (dem=1) then u:=1\n else\n begin\n k:=dem-s3; d:=1; e:=1; f:=1;\n for i:=1 to dem do d:=d*i;\n for i:=1 to s3 do e:=e*i;\n for i:=1 to k do f:=f*i;\n u:=d div (e*f);\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "program yan;\n var s,s1:string; i,x,y,a,b,n,m,c,d:longint; j:extended;\nbegin\n read(s);\n readln;\n readln(s1);\n for i:=1 to length(s) do\n begin\n if s[i]='+' then inc(x);\n if s[i]='-' then inc(d);\n end;\n for i:=1 to length(s1) do\n begin\n if (s1[i]='+') then inc(y);\n if s1[i]='-' then inc(c);\n if s1[i]='?' then inc(a);\n end;\n if (y+ay)) then begin j:=0; write(j); exit; end;\n if (x=y)and(a=0) then begin j:=1; write(j); exit; end;\n b:=1; for i:=1 to a do b:=b*2;\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(y+a>x) then\n begin\n m:=m*2; dec(y);\n end;\n if m div b>=1 then\n begin\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(c+a b\n then max := a\n else max := b;\nend;\n\nbegin\n readln(s);\n readln(t);\n \n for i := 1 to length(s) do\n if s[i] = '+'\n then inc(kol_p1)\n else inc(kol_m1);\n \n for i := 1 to length(s) do\n if t[i] = '+'\n then inc(kol_p2)\n else if t[i] = '-'\n then inc(kol_m2)\n else inc(kol_v);\n \n if (kol_p1 = kol_p2) and (kol_m1 = kol_m2)\n then q := 1\n else begin\n if (kol_m2 > kol_m1) or (kol_p2 > kol_p1)\n then q := 0\n else begin\n if (kol_m1 - kol_m2) = kol_p1 - kol_p2\n then q := 0.5\n else begin\n q := 1;\n for i := 1 to kol_v do\n q := q * 0.5;\n q := q * kol_v;\n end;\n end;\n end; \n writeln(q:0:9);\n\nend."}, {"source_code": "var a,b:string;\n n:real;\n dem,x,s2,s1,c,i,j,k,u,l:longint;\n m:array[1..11] of char;\n\nbegin\n readln(a); read(b);\n dem:=0; s1:=0; s2:=0; j:=1;\n x:=length(a);\n for i:=1 to x do\n begin\n if (b[i]='?') then\n begin\n inc(dem);\n m[j]:=a[i];\n inc(j);\n end;\n if (a[i]='+') then inc(s1) else if (a[i]='-') then dec(s1);\n if (b[i]='+') then inc(s2) else if (b[i]='-') then dec(s2);\n end;\n c:=dem*2;\n if (dem=0) and (s1=s2) then n:=1\n else if (dem=0) then n:=0\n else if (s1-s2<=dem) then\n begin\n k:=1; u:=1; l:=j-1;\n while (l>1) do\n begin\n repeat\n if (m[l]<>m[l-k]) then inc(u);\n inc(k);\n until k=l;\n l:=l-1; k:=1;\n end;\n n:=u/c;\n end\n else n:=0;\n write(n);\nend.\n\n\n\n"}, {"source_code": "const\n tfi='';\n tfo='';\n\nvar\n fi,fo:text;\n v,d,s:longint;\n a,b:string;\n\nprocedure tryy(i,u:longint);\n var j:longint;\n begin\n if i=length(b)+1 then\n begin\n inc(s);\n if u=v then inc(d);\n exit;\n end;\n if b[i]='+' then tryy(i+1,u+1);\n if b[i]='-' then tryy(i+1,u-1);\n if b[i]='?' then\n begin\n tryy(i+1,u+1);\n tryy(i+1,v-1);\n end;\n end;\n\n\nprocedure xuli;\n var x:extended;\n i:longint;\n begin\n readln(fi,a);\n readln(fi,b);\n for i:=1 to length(a) do if a[i]='+' then inc(v) else dec(v);\n s:=0;\n d:=0;\n tryy(1,0);\n if s=0 then writeln(fo,0)\n else\n begin\n x:=d/s;\n writeln(fo,x:12:12);\n end;\n end;\n\n\nbegin\n assign(fi,tfi);\n assign(fo,tfo);\n reset(fi);\n rewrite(fo);\n xuli;\n close(fo);\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\nd:array[0..20,-30..30]of int64;\ng:extended;\ns1,s2:string;\nsum1,j,sum2,w,k,i:longint;\nfunction f(x:int64):int64;\nbegin\nif x=0 then exit(1) else exit(x*f(x-1));\nend;\nfunction c(n,k:longint):int64;\nbegin\n c:=(f(n) div f(k))div f(n-k);\nend;\nbegin\n//readln(s1);readln(s2);\ns1:='+-+';s2:='??-';\nfor i:=1 to length(s1) do\n if s1[i]='+' then inc(sum1) else dec(sum1);\nfor i:=1 to length(s1) do\n if s2[i]='+' then inc(sum2) else\n if s2[i]='-' then dec(sum2) else inc(k);\n w:=sum1-sum2;\n\nw:=abs(w);\nw:=w*2;\n\nif w>k then begin writeln('0.000000000000');;halt;end;\n//k dosl;; iz nix = w praviln\n// (n k)\n//if (w+k) mod 2>0 then begin writeln('0.000000000000');halt;end;\n//w:=(w+k) div 2;\nd[0,0]:=1;\nfor i:=1 to k do\nfor j:=-k to k do\nd[i,j]:=d[i-1,j-1]+d[i-1,j+1];\n\ng:=d[k,w];\nfor i:=1 to k do g:=g/2;\nwriteln(g:0:10);\n\n\nend."}, {"source_code": "var S1,S2:string;\n a,b,c:longint;\n i:longint;\n kq:real;\n T1,T2,T3,T4:longint;\n\nprocedure Tinh;\nvar i:longint;\nbegin\n T1:=1;\n T2:=1;\n T3:=1;\n T4:=1;\n for i:=1 to a do\n begin\n T1:=T1*i;\n T2:=T2*i;\n if i<=(a-c) then T3:=T3*i;\n end;\n for i:=1 to c do\n T4:=T4*2;\nend;\n\nbegin\n readln(S1);\n readln(S2);\n a:=0;\n b:=0;\n c:=0;\n for i:=1 to length(S1) do\n begin\n if S1[i]='+' then inc(a);\n if S1[i]='-' then inc(b);\n end;\n for i:=1 to length(S2) do\n begin\n if S2[i]='+' then dec(a);\n if S2[i]='-' then dec(b);\n if S2[i]='?' then inc(c);\n end;\n kq:=0;\n if (a<0) or (b<0) or (a+b<>c) then\n begin\n writeln(kq:0:9);\n exit;\n end\n else\n begin\n Tinh;\n kq:=(T1 div (T2*T3))/T4;\n writeln(kq:0:9);\n end;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n, m, i, j : longint;\n s, t : string;\n q : real;\n kol_v, kol_p1, kol_p2, kol_m1, kol_m2 : longint;\n\nbegin\n readln(s);\n readln(t);\n \n kol_p1 := 0;\n kol_m1 := 0;\n kol_m2 := 0;\n kol_p2 := 0;\n kol_v := 0;\n \n for i := 1 to length(s) do\n if s[i] = '+'\n then inc(kol_p1)\n else inc(kol_m1);\n \n for i := 1 to length(s) do\n if t[i] = '+'\n then inc(kol_p2)\n else if t[i] = '-'\n then inc(kol_m2)\n else inc(kol_v);\n \n if (kol_p1 = kol_p2) and (kol_m1 = kol_m2)\n then begin\n q := 1;\n writeln(q:0:9);\n end\n else begin\n if (kol_m2 > kol_m1) or (kol_p2 > kol_p1)\n then begin\n q := 0;\n writeln(q:0:9);\n end\n else begin\n\n q := 1;\n for i := 1 to kol_v do\n q := q * 0.5;\n q := q * kol_v;\n writeln(q:0:9);\n end;\n end; \n\nend."}, {"source_code": "program yan;\n var s,s1:string; i,x,y,a,b,n,m:longint; j:extended;\nbegin\n read(s);\n readln;\n readln(s1);\n for i:=1 to length(s) do if s[i]='+' then inc(x);\n for i:=1 to length(s1) do\n begin\n if (s1[i]='+') then inc(y);\n if s1[i]='?' then inc(a);\n end;\n if (y+ay)) then begin j:=0; write(j); exit; end;\n if (x=y)and(a=0) then begin j:=1; write(j); exit; end;\n b:=1; for i:=1 to a do b:=b*2;\n m:=1;\n for i:=1 to length(s1) do\n if (s1[i]='?')and(y+a>x) then begin m:=m*2; dec(y); end;\n write(m/b);\nend.\n"}, {"source_code": "program cfwifi;\nvar i,br,z,nacin,poz,poz2,j,ukupno:integer;\n s1,s2:string;\n bm:array[1..100] of integer;\nbegin\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s1) do\n if s1[i]='+' then\n poz:=poz+1\n else\n poz:=poz-1;\n\nbr:=0;\nfor i:=1 to length(s2) do\n if s2[i]='+' then\n poz2:=poz2+1\n else\n if s2[i]='-' then\n poz2:=poz2-1\n else\n br:=br+1;\n\nfor i:=1 to br do\n bm[i]:=0;\nz:=br;\nif z+poz2=poz then\n nacin:=nacin+1;\nukupno:=1;\nwhile z<>-br do\n begin\n i:=br;\n z:=0;\n while bm[i]=1 do\n begin\n bm[i]:=0;\n i:=i-1;\n end;\n bm[i]:=1;\n for j:=1 to br do\n if bm[j]=0 then\n z:=z+1\n else\n z:=z-1;\n\n if z+poz2=poz then\n nacin:=nacin+1;\n\n ukupno:=ukupno+1;\n end;\nwriteln((nacin/ukupno):4:2);\nend."}, {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//476B.INP';\n Fo='';//476B.OUT';\nVar s1,s2:String;\n a,Gt:Array[0..11] of Longint;\n F:Array[-11..11,0..11] of Real;\n C:Array[0..11,0..11] of Longint;\n COunt1,Count2,Count:Longint;\n\nProcedure Init;\nVar j,i:Longint;\nBegin\n a[1]:=2;\n For i:=2 to 11 do\n a[i]:=a[i-1]*2;\n Gt[0]:=1;\n For i:=1 to 10 do\n Gt[i]:=Gt[i-1]*i;\n\n For i:=0 to 10 do\n For j:=i downto 0 do\n C[j,i]:=(Gt[i] div (Gt[i-j]*Gt[j]));\n\n For i:=10 downto 0 do\n For j:=1 to 10 do\n If j0 then\n Begin\n F[i,j]:=0;\n F[-i,j]:=0;\n End\n Else\n Begin\n F[i,j]:=C[(j-i) div 2,j]/a[j];\n F[-i,j]:=F[i,j];\n End;\nEnd;\n\nProcedure Enter;\nVar i:Longint;\nBegin\n Readln(s1);\n Readln(s2);\nEnd;\n\nProcedure Main;\nVar i:Longint;\nBegin\n Init;\n COunt1:=0;\n Count2:=0;\n COunt:=0;\n For i:=1 to length(s1) do\n Begin\n Case s1[i] of\n '+':Inc(Count1);\n '-':Dec(Count1);\n End;\n Case s2[i] of\n '+':Inc(Count2);\n '-':Dec(Count2);\n '?':Inc(Count);\n End;\n End;\n If (COunt=0) and (COunt1=COunt2) then\n Writeln(1.0:0:9)\n Else\n Writeln(F[Count1-Count2,Count]:0:9);\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n Main;\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "var\n n, m, i, ans, p, en, pos, pos2: longint;\n s1, s2: string;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(p)\n else\n dec(p);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(p)\n else if s2[i] = '-' then\n inc(p)\n else\n inc(en);\n if p < 0 then\n p := -p;\n if (p > en) or (p + en mod 2 <> 0) then\n begin\n write(0);\n exit();\n end;\n pos := 1;\n p := (en + p) div 2;\n for i := en - p + 1 to en do\n pos := pos * i;\n pos2 := 1;\n for i := 1 to p do\n pos := pos div i;\n for i := 1 to en do\n pos2 := pos2 * 2;\n write(pos / pos2);\nend."}, {"source_code": "uses math;\nvar a:array[1..10,1..11] of longint;\n c,x,z:real; n,m,j,i,l,l1,k,u,o:longint; s,s1:string;\nbegin\nreadln(s);\nreadln(s1);\nn:=0;\nm:=0;\nk:=0;\nfor i:=1 to length(s) do\nbegin\nif s[i]='+' then inc(n) else dec(n);\nif s1[i]='+' then inc(m) else\n if s1[i]='-' then dec(m) else inc(k);\nend;\nif k<>0 then begin\na[1,2]:=1;\na[2,1]:=2; a[2,3]:=1;\na[3,2]:=3; a[3,4]:=1;\na[4,1]:=6; a[4,3]:=4; a[4,5]:=1;\na[5,2]:=10; a[5,4]:=5; a[5,6]:=1;\na[6,1]:=20; a[6,3]:=15; a[6,5]:=6; a[6,7]:=1;\na[7,2]:=35; a[7,4]:=21; a[7,6]:=7; a[7,8]:=1;\na[8,1]:=70; a[8,3]:=56; a[8,5]:=29; a[8,7]:=8; a[8,9]:=1;\na[9,2]:=126; a[9,4]:=85; a[9,6]:=37; a[9,8]:=9; a[9,10]:=1;\na[10,1]:=252; a[10,3]:=211; a[10,5]:=122; a[10,7]:=49; a[10,9]:=10; a[10,11]:=1;\nwriteln((a[k,(abs(n-m)+1)]/power(2,k)):1:12);\nend\nelse\nif n=m then writeln((1/1):1:12) else writeln((0/1):1:12);\nend.\n\n\n\n"}, {"source_code": "type vector = array[0 .. 20] of longint;\nvar x:vector; sl,st:string; kq:real;\n n,k,j,v1,v2,d,tu,mau:longint;\nprocedure ghinghiem(x:vector);\n var i,u:longint;\n begin\n u:=v2; inc(mau);\n for i:=1 to k do\n begin\n if x[i] = 0 then inc(u);\n if x[i] = 1 then dec(u);\n end;\n if u = v1 then inc(tu);\n end;\nprocedure chinhhoplap(i:longint);\n begin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i = k then ghinghiem(x)\n else chinhhoplap(i+1);\n end;\n end;\nbegin\n readln(sl);\n readln(st);\n v1:=0; v2:=0; d:=0; tu:=0; mau:=0;\n for j:=1 to length(sl) do\n begin\n if sl[j] = '+' then inc(v1);\n if sl[j] = '-' then dec(v1);\n end;\n for j:=1 to length(st) do\n begin\n if st[j] = '+' then inc(v2);\n if st[j] = '-' then dec(v2);\n if st[j] = '?' then inc(d);\n end;\n if d = 0 then\n if v1 = v2 then begin write(1); exit; end\n else begin write(0); exit; end;\n k:=d;\n chinhhoplap(1);\n kq:=tu/mau;\n write(kq:0:10);\n readln;\n readln\nend.\n"}, {"source_code": "var\nd:array[0..20,-30..30]of int64;\ng:extended;\ns1,s2:string;\nsum1,j,sum2,w,k,i:longint;\nfunction f(x:int64):int64;\nbegin\nif x=0 then exit(1) else exit(x*f(x-1));\nend;\nfunction c(n,k:longint):int64;\nbegin\n c:=(f(n) div f(k))div f(n-k);\nend;\nbegin\n//readln(s1);readln(s2);\ns1:='+-+';s2:='??-';\nfor i:=1 to length(s1) do\n if s1[i]='+' then inc(sum1) else dec(sum1);\nfor i:=1 to length(s1) do\n if s2[i]='+' then inc(sum2) else\n if s2[i]='-' then dec(sum2) else inc(k);\n w:=sum1-sum2;\n\nw:=abs(w);\nw:=w*2;\n\nif w>k then begin writeln('0.000000000000');;halt;end;\n//k dosl;; iz nix = w praviln\n// (n k)\n//if (w+k) mod 2>0 then begin writeln('0.000000000000');halt;end;\n//w:=(w+k) div 2;\nd[0,0]:=1;\nfor i:=1 to k do\nfor j:=-k to k do\nd[i,j]:=d[i-1,j-1]+d[i-1,j+1];\n\ng:=d[k,w];\nfor i:=1 to k do g:=g/2;\nwriteln(g:0:10);\n\n\nend."}, {"source_code": "Var s1,s2: AnsiString;\n i,k1,k2,h,x,y,ans,kol: LongInt;\n\nprocedure rec(n,x: LongInt);\n Begin\n if n=0 then Begin if x=0 then Inc(ans) else Inc(kol); Exit; End;\n rec(n-1,x+1);\n rec(n-1,x-1);\n End;\n\n Begin\n ReadLn(s1);\n ReadLn(s2);\n for i:=1 to Length(s1) do\n if s1[i]='+' then Inc(k1)\n else Dec(k1);\n for i:=1 to Length(s2) do\n if s2[i]='+' then Inc(k2)\n else if s2[i]='-' then Dec(k2)\n else Inc(h);\n if h=0 then\n Begin\n if k1=k2 then WriteLn(1.000000000)\n else WriteLn(0.000000000);\n Halt;\n End;\n if abs(k1-k2)>h then Begin WriteLn(0.000000000); Halt; End;\n x:=1 shl h;\n rec(h,0);\n WriteLn(ans/(kol+ans):0:9);\n End.\n"}, {"source_code": "var\n s1,s2:ansistring;\n sum1,sum2,c,dem,hieu:longint;\n\nfunction tohop(k,n:longint):longint;\nvar tu,mau1,mau2,i:longint;\nbegin\n tu:=1;\n for i:=1 to n do tu:=tu*i;\n mau1:=1;\n for i:=1 to k do mau1:=mau1*i;\n mau2:=1;\n for i:=1 to n-k do mau2:=mau2*i;\n exit(tu div (mau1*mau2));\nend;\n\nprocedure nhapdem;\nvar l,i,j:longint;\nbegin\n sum1:=0; sum2:=0; dem:=0;\n readln(s1); readln(s2);\n l:=length(s1);\n for i:=1 to l do\n begin\n if s1[i]='+' then inc(sum1)\n else dec(sum1);\n end;\n for j:=1 to l do\n begin\n if s2[j]='+' then inc(sum2);\n if s2[j]='-' then dec(sum2);\n if s2[j]='?' then inc(dem);\n end;\n hieu:=sum1-sum2;\nend;\n\nfunction xuli:real;\nvar kq:real; i,plus,minus,sth:longint;\nbegin\n sth:=1;\n for i:=1 to dem do sth:=sth*2;\n if (dem=0) and (hieu=0) then writeln(1);\n if (hieu>=0) and (dem>=hieu) then\n begin\n if ((dem-hieu) mod 2 =0) and ((dem+hieu) mod 2 = 0) then\n begin\n plus:=(dem+hieu) div 2;\n minus:=(dem-hieu) div 2;\n if minus=0 then exit(1/sth);\n kq:=tohop(plus,dem)/sth;\n exit(kq);\n end\n else exit(0);\n end\n else exit(0);\nend;\n\nbegin\n nhapdem;\n writeln(xuli);\nend."}, {"source_code": "var\n n, m, i, ans, p, en, pos, pos2: longint;\n s1, s2: string;\nbegin\n readln(s1);\n readln(s2);\n for i := 1 to length(s1) do\n if s1[i] = '+' then\n inc(p);\n for i := 1 to length(s2) do\n if s2[i] = '+' then\n dec(p)\n else if s2[i] = '-' then\n p := p\n else\n inc(en);\n if p < 0 then\n p := -p;\n if p > en then\n begin\n write(0);\n exit();\n end;\n pos := 1;\n for i := en - p + 1 to en do\n pos := pos * i;\n pos2 := 1;\n for i := 1 to p do\n pos := pos div i;\n for i := 1 to en do\n pos2 := pos2 * 2;\n write(pos / pos2);\nend."}, {"source_code": "const fi='';\n fo='';\nvar s1,s2:string;\n a1,a2:array[0..4] of longint;\nprocedure doc;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s1);\n readln(f,s2);\n close(f);\nend;\nfunction c(k:char):longint;\nbegin\n case k of\n '+': exit(1);\n '-': exit(2);\n '?': exit(3);\n end;\nend;\nprocedure xl;\nvar f:text;\n i,qd:longint;\n b:real;\nbegin\n assign(f,fo);\n rewrite(f);\n b:=0;\n fillchar(a1,sizeof(a1),0);\n fillchar(a2,sizeof(a2),0);\n for i:=1 to length(s1) do\n begin\n inc(a1[c(s1[i])]);\n inc(a2[c(s2[i])]);\n end;\n qd:=abs((a1[1]-a1[2])-(a2[1]-a2[2]));\n if (qd<=a2[3]) and ((a2[3]-qd) mod 2=0) then\n begin\n if (a2[3]=0) and (qd=0) then\n b:=1\n else\n begin\n b:=0.5;\n for i:=1 to qd do\n b:=b*0.5;\n end;\n end;\n write(f,b:0:12);\n close(f);\nend;\nbegin\n doc;\n xl;\nend.\n"}, {"source_code": "var\nd:array[0..20,-30..30]of int64;\ng:extended;\ns1,s2:string;\nsum1,j,sum2,w,k,i:longint;\nfunction f(x:int64):int64;\nbegin\nif x=0 then exit(1) else exit(x*f(x-1));\nend;\nfunction c(n,k:longint):int64;\nbegin\n c:=(f(n) div f(k))div f(n-k);\nend;\nbegin\n//readln(s1);readln(s2);\ns1:='+-+';s2:='??-';\nfor i:=1 to length(s1) do\n if s1[i]='+' then inc(sum1) else dec(sum1);\nfor i:=1 to length(s1) do\n if s2[i]='+' then inc(sum2) else\n if s2[i]='-' then dec(sum2) else inc(k);\n w:=sum1-sum2;\n\nw:=abs(w);\nw:=w*2;\n\nif w>k then begin writeln('0.000000000000');;halt;end;\n//k dosl;; iz nix = w praviln\n// (n k)\n//if (w+k) mod 2>0 then begin writeln('0.000000000000');halt;end;\n//w:=(w+k) div 2;\nd[0,0]:=1;\nfor i:=1 to k do\nfor j:=-k to k do\nd[i,j]:=d[i-1,j-1]+d[i-1,j+1];\n\ng:=d[k,w];\nfor i:=1 to k do g:=g/2;\nwriteln(g:0:10);\n\n\nend."}, {"source_code": "VAR ans,ans1,v,m,p:int64; i:longint; s:string;\nBEGIN\nreadln(s);\nfor i:=1 to length(s) do if s[i]='+' then inc(p) else inc(m);\nreadln(s);\nfor i:=1 to length(s) do if s[i]='+' then dec(p) else if s[i]='-' then dec(m) else inc(v);\nif (p>=0) and (m>=0) then begin\n ans:=1;\n for i:=1 to v do ans:=ans*i;\n ans1:=1;\n for i:=1 to m do ans1:=ans1*i;\n for i:=1 to p do ans1:=ans1*i;\n write(ans1/ans:0:9);\nend else begin\nans:=0;\nwrite(ans/1.0:0:9);\nend;\nEND."}, {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//476B.INP';\n Fo='';//476B.OUT';\nVar s1,s2:String;\n a,Gt:Array[0..11] of Longint;\n F:Array[-11..11,0..11] of Real;\n C:Array[0..11,0..11] of Longint;\n COunt1,Count2,Count:Longint;\n\nProcedure Init;\nVar j,i:Longint;\nBegin\n a[1]:=2;\n For i:=2 to 11 do\n a[i]:=a[i-1]*2;\n Gt[0]:=1;\n For i:=1 to 10 do\n Gt[i]:=Gt[i-1]*i;\n\n For i:=0 to 10 do\n For j:=i downto 0 do\n C[j,i]:=(Gt[i] div (Gt[i-j]*Gt[j]));\n\n For i:=10 downto 0 do\n For j:=1 to 10 do\n If j0 then\n Begin\n F[i,j]:=0;\n F[-i,j]:=0;\n End\n Else\n Begin\n F[i,j]:=C[(j-i) div 2,j]/a[j];\n F[-i,j]:=F[i,j];\n End;\nEnd;\n\nProcedure Enter;\nVar i:Longint;\nBegin\n Readln(s1);\n Readln(s2);\nEnd;\n\nProcedure Main;\nVar i:Longint;\nBegin\n Init;\n COunt1:=0;\n Count2:=0;\n COunt:=0;\n For i:=1 to length(s1) do\n Begin\n Case s1[i] of\n '+':Inc(Count1);\n '-':Dec(Count1);\n End;\n Case s2[i] of\n '+':Inc(Count2);\n '-':Dec(Count2);\n '?':Inc(Count);\n End;\n End;\n If (COunt=0) and (COunt1=COunt2) then\n Writeln(1.0:0:9)\n Else\n Writeln(F[Count1-Count2,Count]:0:9);\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n Main;\n\n Close(Input);\n Close(Output);\nEND."}, {"source_code": "var\n s,s1:string;\n f:array[-100..100,-100..100]of extended;\n n,m,i,j,sp,sm,s1m,s1p:longint;\nbegin\n readln(s);\n readln(s1);\n for i:=1to length(s)do if s[i]='+'then inc(sp)else inc(sm);\n for i:=1to length(s1)do\n if s1[i]='+'then inc(s1p)else if s1[i]='-'then inc(s1m)else inc(n);\n for i:=0 to n do f[0,i]:=1;\n for i:=1 to n do f[i,0]:=1;\n for i:=1 to n do\n begin\n for j:=1 to n do\n begin\n f[i,j]:=1/(1/f[i-1,j]+1/f[i,j-1]);\n end;\n end;\n writeln(f[sp-s1p,sm-s1m]:0:10);\nend.\n"}], "src_uid": "f7f68a15cfd33f641132fac265bc5299"} {"source_code": "{$mode objfpc}\nvar n,i,count:integer;\nfunction sum(n:integer):integer;\n var i:integer;\n begin\n sum:=0;\n for i:=1 to n do sum:=sum+i;\n end;\nbegin\n readln(n);\n count:=0;i:=1;\n while sum(count+1)<=n do\n begin\n inc(count);\n i:=sum(count);\n n:=n-i;\n // writeln(i,' ',count,' ',n);\n end;\n writeln(count);\nend.", "positive_code": [{"source_code": "Var\n n,i,k:integer;\nbegin\n readln(n); i:=1; k:=1;\n while n-k>=0 do begin n:=n-k; inc(i); k:=k+i; end;\n writeln(i-1);\nend."}, {"source_code": "program z1;\n var n,m,i:longint;\nfunction f1(a,r,k:longint):longint;\nbegin\n if(a+k>m)\n then f1:=r\n else f1:=f1(a+k,r+1,k+r+2);\nend;\nbegin\n readln(m);\n writeln(f1(0,0,1));\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{const fi='vyac.inp';\n fo='vyac.out';}\nvar n,i,s,m,j:longint;\nprocedure docdl;\nbegin\n{ assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output); }\n read(n);\nend;\nprocedure xuli;\nbegin\n i:=0;s:=0;\n repeat\n inc(i);\n m:=0;\n for j:=1 to i do m:=m+j;\n s:=s+m;\n if s>=n then break;\n until s>=n;\nend;\nprocedure ghikq;\nbegin\nif s>n then writeln(i-1);\nif s=n then writeln(i);\n{close(input);\nclose(output); }\nend;\nBegin\n docdl;\n xuli;\n ghikq;\nend.\n"}, {"source_code": "CONST fi = '';\n fo = '';\nVAR N, i, S : word;\n F : array [0..1000] of word;\nPROCEDURE SOLVE;\n Begin\n F[0] := 0;\n S := 0;\n i := 0;\n repeat\n inc(i);\n F[i] := F[i-1] + i;\n S := S + F[i];\n until S >= N;\n End;\nPROCEDURE PROCESS;\n Var f : text;\n Begin\n assign(f,fi); reset(f);\n read(f,N);\n close(f);\n assign(f,fo); rewrite(f);\n SOLVE;\n if S > N then write(f,i-1) else write(f,i);\n close(f);\n End;\nBEGIN\n PROCESS;\nEND."}, {"source_code": " var i,m,n,q:longint;\n begin\n read (n);\n while m= j do \n begin\n n:=n-j;\n inc(h);\n inc(i);\n j:=j+i;\n end;\n write(h);\nend."}, {"source_code": "var s,n,i:longint;\nbegin\n readln(n);\n while s<=2*n do begin\n inc(i);\n s:=s+(sqr(i)+i);\n end;\n write(i-1);\nend.\n"}, {"source_code": "var i,j,k,l,m,n:longint;\nbegin\nreadln(n);\ni:=0;\nm:=0;\nwhile (mn then writeln(i-1) else writeln(i);\nend."}, {"source_code": "var n,i,ans,sum,x : longint;\nbegin\n //assign (input,'input.txt'); reset (input);\n //assign (output,'output.txt'); rewrite (output);\n\n read (n);\n\n ans := 0;\n sum := 0;\n\n for i := 1 to n+1 do begin\n\n x := x + i;\n sum := sum + x;\n inc (ans);\n if (sum > n) then begin\n writeln (ans - 1);\n break;\n end;\n end;\n\n// close (input); close (output);\nend."}, {"source_code": "var i,n,k:longint;\nbegin\n read(n);\n k:=1;\n i:=1;\n repeat\n inc(i);\n k:=k+i*(i+1)div 2\n until k>n;\n write(i-1)\nend."}, {"source_code": "var n,a,m:longint;ans,i:integer;\nbegin\n readln(n);\n if n = 1 then writeln('1')\n else begin\n a:=1;\n ans:=1;\n m:=1;\n while (a<=n) do\n begin\n inc(ans);\n m:=m+ans;\n a:=a+m;\n end;\n\n if a = n then writeln(ans)\n else writeln(ans-1);\n end;\n\nend."}, {"source_code": "var t,m,f:int64;\nbegin \nread(m);\nwhile f<=m*2 do \nbegin \ninc(t);\nf:=f+t*(t+1);\nend;\nwrite(t-1);\nend."}, {"source_code": "var\nn,i,k,k1,s,s1,k2:longint;\nbegin\nread (n); s:=1; k2:=1; k1:=1; \nwhile n>=s do begin\ninc (k2);\nfor i:=1 to k2 do\ns1:=s1+i;\ns:=s+s1;\ns1:=0;\nif n-s>=0 then begin\ninc (k1);\nend\nelse break;\nend;\nwrite (k1);\nend."}, {"source_code": "var\nn,i,k,k1,s,s1,k2,l:longint;\nbegin\nread (n,l); s:=1; k2:=1; k1:=1; \nwhile n>=s do begin\ninc (k2);\nfor i:=1 to k2 do\ns1:=s1+i;\ns:=s+s1;\ns1:=0;\nif n-s>=0 then begin\ninc (k1);\nend\nelse break;\nend;\nwrite (k1);\nend."}, {"source_code": "var i,l,k,n:longint;\nbegin\nreadln(n);\n\nwhile l=0 then\nk:=k+1;\nend;\n\nwriteln(k);\n\nend."}, {"source_code": "var a,summ,curr,i:Longint;\nBEGIN\nsumm:=0;\nread(a);\ni:=0;\ncurr:=1;\nwhile summ+curr<=a do\n begin\n inc(i);\n inc(curr,i);\n inc(summ,curr);\n end;\n\nif(a=0) then write(0) else write(i);\nEND."}, {"source_code": "var n,i,v,s:integer;\nbegin\nv:=1;\ns:=1;\ni:=1;\nReadln(n);\nwhile(s0) then dec(i);\nwriteln(i);\nend."}, {"source_code": "uses math;\nvar n:longint;\nbegin\n readln(n);\n writeln(trunc((3*n+(9*n*n-1/27)**0.5)**(1/3)+(3*n-(9*n*n-1/27)**0.5)**(1/3)-0.99999999));\nend."}, {"source_code": "var n,i,res : longint;\n l : array[-1..1000000] of longint;\nbegin\n readln(n);\n l[-1]:=0;\n l[0]:=0;\n res:=0;\n for i:=1 to n do\n begin\n\n inc(res);l[i]:=(l[i-1]-l[i-2])*2+i+l[i-2];\n if l[i]>=n then break;\n if l[i-1]+(l[i]-l[i-1])*2+i+1>n then break;\n\n end;\n writeln(res);\nend.\n"}, {"source_code": "var\ns,s1:string;\nn,m,j,i,k,q,w,kod:longint;\na,b:array[1..100000] of longint;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n);\n k:=0;\n for i:=1 to n do\n begin\n for j:=1 to i do\n begin\n k:=k+j;\n end;\n\n if q+k<=n then q:=q+k\n else\n begin\n write(i-1);\n exit;\n end;\n if q=n then\n begin\n write(i);\n exit;\n end;\n k:=0;\n end;\nend."}, {"source_code": "var n,i,j,kq:longint;\nbegin\n readln(n);\n i:=0;j:=0;kq:=0;\n while (n > i) do\n begin\n inc(j);\n inc(i,j);\n n:=n-i;\n if n >= 0 then\n inc(kq);\n end;\n write(kq);\nend."}, {"source_code": "var a,n,i:integer;\nbegin\nreadln(n);\na:=0;\nfor i:=1 to n+1 do begin\na:=a+i;\nif a>n then break;\nn:=n-a;\nend;\nwrite(i-1);\nend."}, {"source_code": "const fi='';\n fo='';\nvar i,n,s:int64;\n f,g:text;\nprocedure data;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n);\nend;\nprocedure process;\nbegin\n s:=0;\n i:=0;\n while (n>0) do\n begin\n inc(i);\n inc(s,i);\n dec(n,s);\n end;\n if n<0 then writeln(g,i-1)\n else writeln(g,i);\nend;\nbegin\n data;\n process;\n close(g);\nend.\n"}, {"source_code": "var \n\tn, i, count, tmp: integer;\nbegin\n\treadln(n);\n\twhile true do\n\t\tbegin\n\t\t\ti:=i + 1;\n\t\t\tcount:=count + tmp + i;\n\t\t\ttmp:=tmp + i;\n\t\t\tif (count = n) then\n\t\t\t\tbegin\n\t\t\t\t\twrite(i);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tif (count > n) then \n\t\t\t\tbegin\n\t\t\t\t\twrite(i - 1);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\tend;\nend."}, {"source_code": "var i,n:longint;\n sum,y:int64;\n Begin\n read(n);\n if n=1 then begin writeln(1); halt; end;\n for i:=1 to n do\n Begin\n y:=y+i;\n sum:=sum+y;\n if sum>n then begin writeln(i-1); halt; end;\n End;\n End."}, {"source_code": "var\n n,i:longint;\nbegin\n readln(n);\n while n-((1+i)*i div 2)>=0 do\n begin\n n:=n-(1+i)*i div 2;\n inc(i);\n end;\n writeln(i-1);\nend."}, {"source_code": "Program kyb;\nvar\nn, i:integer;\nA:array[0..1000] of int64;\nbegin\n read(n);\n if (n=1) then\n write ('1')\n else\n begin\n i:=1;\n A[0]:=0;\n while (A[i-1]<=n) do\n begin\n A[i]:=(i*(i+1) div 2) + A[i-1];\n i:=i+1;\n end;\n write(i-2);\n end;\nend."}, {"source_code": "program z1;\nvar n,i,k,br:longint;\nbegin\nread(n);\ni:=1;\nk:=1;\nwhile n-k>=0 do\n begin\n n:=n-k;\n i:=i+1;\n k:=k+i;\n br:=br+1;\n end;\nwriteln(br);\nend.\n"}, {"source_code": "Var a : array[1..10000]of longint;\n i,j,k,l,n,m,t,c : Longint;\nbegin\n readln(n);\n While t <= n DO\n begin\n inc(i);\n k := round((1 + i) / 2 * i);\n inc(t,k);\n end;\n if (t > n) then\n writeln(i - 1)\n else writeln(i);\nend.\n"}, {"source_code": "var i,j,k,n,sum,cou:longint;\nbegin\n readln(n);\n if n>=4 then begin\n for i:=1 to n do\n begin\n cou:=cou+i;\n sum:=sum+cou;\n if sum>n then write(i-1);\n if sum>n then break;\n end;\n\n end\n else write(1);\n readln;\n readln;\nend.\n"}, {"source_code": "var a,n,t,m:integer;\nbegin\na:=1;\nt:=1;\nm:=1;\nreadln(n);\nwhile a+m+t+1<=n do\n begin\n inc(t);\n m:=m+t;\n a:=a+m;\n end; \nwriteln(t);\nend."}, {"source_code": "program z1;\nvar n, k, i : integer;\nbegin\n read(n);\n k := 1;\n while n - k >= 0 do\n begin\n i := i + 1;\n n := n - k;\n k := k + i + 1;\n end;\n write(i);\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n, s: integer;\n\n\nbegin\n readln(n);\n i := 0;\n while n-s-i > 0 do\n begin\n inc(i);\n\n inc(s, i);\n dec(n, s);\n end;\n writeln(i)\nend."}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n\n label 1,2,3,4;\n type\n mas=array [-10000..10000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..2000000] of int64;mass1=^mas;\n var t,aa,bb,sum1,dist,modul,n,m,poz,sum,p3,p4,t4,t5,t6,t1,t2,t3,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,kk,qq,ot,kol,nn,x0,y0,s1,s2,s,imax,smin,dl,besk1:int64;\n shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..10000] of char;\n poin:zap; cc,edin:mas;\n vec:array[-100..1000] of zap;\n c,aold,anew,b1,fact,d, a1,bl,br,a,b:mas;\n c1:array[-1..301,-100..301] of int64;\n ss, ss1,ss2:string;\n ch1,ch2:char;\n newgr,gr:array[-100..200000] of boolean;\n dd,pole:array[-1..1500,-1..1500] of int64;\n sss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n p1,p2,pr,aanew,v0,v1,s0,t0:extended;\n lx,ly,rx,ry,z,x1,y1,y,x:array[-1..300000] of int64;\n xm,xn, xxx,yyy:array[-1..100000] of double;\n xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\n\n\nbegin\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n);\n for i:=0 to 1000 do a[i]:=i;\n for i:=0 to 1000 do b[i]:=b[i-1]+a[i];\n for i:=0 to 1000 do c[i]:=c[i-1]+b[i];\n{ for i:=0 to 10 do writeln(i,' ',a[i],' ',b[i],' ',c[i]);\n} for i:=0 to 1000 do if c[i]<=n then ot:=i;\n writeln(ot);\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var\n n,i,x,y,sum:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n x:=y+i;\n sum:=sum+x;\n if sum>n then begin writeln(i-1);exit;end;\n if sum=n then begin writeln(i);exit;end;\n y:=x;\n end;\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nvar n : int64;\n d ,pre,tmp: int64;\n i : integer;\nbegin\n readln(n);\n d := 0;\n pre:=0;\n tmp:=0;\n for i:=1 to 69 do\n begin\n inc(d);\n pre := pre+tmp;\n tmp:=tmp+i;\n if pre > n then\n begin\n Writeln(d-2);\n halt;\n end;\n end;\nend."}, {"source_code": "var\ni,j,c,d,e,n:longint;\nbegin\nread(n);\nfor i:=1 to 40 do\nif (i*(i+1)*(i+2) div 6>n) then break;\nwriteln(i-1);\nend.\n"}, {"source_code": "var\ni,n,t,q,s:longint;\nbegin\nread(n);\nwhile s=sum1 do begin\ni:=i+1;\nsum:=sum+i;\nsum1:=sum1+sum;\nend;\nwriteln(i-1);\nend."}, {"source_code": "var i,j,rs,s,n:integer;\nbegin\ni:=2;\nj:=1;\ns:=0;\nrs:=0;\nreadln(n);\nwhile n>0 do\nbegin\n s:=s+j;\n n:=n-j;\n j:=j+i;\n inc(i);\n inc(rs);\nend;\nif n<0 then dec(rs);\nwriteln(rs);\nend."}, {"source_code": "var\nn,q,w,e,o:longint;\nbegin\nread(n);\nq:=1;\nw:=1;\ne:=1;\no:=1;\nif n>q\nthen\nwhile w+q+e+1<=n do\nbegin\ninc(e);\nq:=q+e;\nw:=w+q;\nInc(o);\nend;\nwrite(o);\nend. "}, {"source_code": "var n,i,sum,c:longint;\nbegin\nread(n);\nsum:=0;\ni:=0;\nc:=0;\nwhile n>=sum do\nbegin\ni:=i+1;\nsum:=sum+i;\nif nn;\nwriteln(j);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i, k: integer;\nbegin\n readln(n);\n k:= 1;\n i:= 1;\n while true do\n begin\n if n - k >= 0 then dec(n,k)\n else break;\n inc(i);\n inc(k,i);\n end;\n writeln(i-1);\n readln;\nend.\n"}, {"source_code": "{$Mode objfpc}\nvar n,res,t,i:integer;\n s:array[1..100000] of integer;\nbegin\n readln(n);\n s[1]:=1;\n i:=1;\n t:=1;\n while t= 0 then\n begin\n t := t - p;\n inc(k);\n p := p + (k + 1);\n end\n else\n begin\n writeln(k);\n halt(0);\n end;\n end;\nend.\n "}, {"source_code": "program VANYA_AND_CUBE;\nconst fi='';\n fo='';\nvar N,d,T,tr: integer;\n a: array[0..10000] of longint;\nprocedure doc;\nvar f: text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,N);\n close(f);\nend;\nprocedure xu_ly;\nvar i: integer;\nbegin\n A[0]:=0;\n for i:=1 to 10000 do\n A[i]:=A[i-1]+i;\n T:=0;\n d:=1;\n tr:=0;\n for i:=1 to 39 do\n begin\n T:=T+A[i];\n if T>N then\n begin\n d:=i-1;\n break;\n end;\n end;\nend;\nprocedure ghi;\nvar f: text;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,d);\n close(f);\nend;\nBEGIN\n doc;\n xu_ly;\n ghi;\nEND.\n"}, {"source_code": "var s,n,i:longint;\nbegin\n readln(n);\n while s<=2*n do begin\n inc(i);\n s:=s+(sqr(i)+i);\n end;\n write(i-1);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var i,n,k,s:integer;\nbegin\nreadln(n);\nk:=0;\ni:=1;\ns:=0;\nwhile n>0 do begin\n s:=s+i;\n n:=n-s;\n if (n>=0) then inc(k);\n inc(i);\nend;\nwriteln(k);\nend."}, {"source_code": "var\n n,k,i,j:longint;\nbegin\n read(n);\n i:=1;\n k:=1;\n while n-k>=0 do\n begin\n n:=n-k;\n i:=i+1;\n k:=0;\n for j:=1 to i do k:=k+j;\n end;\n write(i-1);\nend."}, {"source_code": "program A492;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,m,k,i,s : longint;\nbegin\nreadln(n);\nm := 0;\nk := 0;\nwhile m <= n do\n begin\n s := 0;\n inc(k);\n for i := 1 to k do s := s+i;\n m := m + s;\n end;\nwriteln(k-1);\nend.\n "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n, j, t: Integer;\n b: Boolean;\n\nbegin\n Readln(n);\n i := 0;\n t := 0;\n b := true;\n while b do begin\n i := i + 1;\n t := t + i;\n for j := 1 to t do begin\n if n = 0 then begin b := False; Break; end;\n n := n - 1;\n end;\n end;\n\n Writeln(i-1);\n Readln;\n\nend."}, {"source_code": "\nprogram Intelect;\n \n{$APPTYPE CONSOLE}\n \nuses\n SysUtils,\n Math;\n \nvar\n n, kol, i, w :integer;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(n);\n kol := 1;\n n := n - 1;\n w := 1;\n for i := 2 to 100000 do\n begin\n w := w + i;\n if (n >= w) then\n begin\n inc(kol);\n dec(n, w);\n end\n else\n break;\n end;\n writeln(kol);\n\n readln;\n readln;\nend.\n"}, {"source_code": "var\ni,k,m,s:longint;\nbegin\nreadln(m);\ns:=1; k:=0;\nwhile m>=s do\nbegin\nm:=m-s;\nk:=k+1;\ns:=s+k+1;\nend;\nwriteln(k);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='a';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,cur,res,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=0 do\n begin\n inc(i);\n inc(k,i);\n dec(n,k);\n inc(res);\n end;\n writeln(res-1);\n\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var\n i,n,s,t:longint;\nbegin\n readln(n);\n while n>=t do\n begin\n s:=s+1;t:=t+s;\n n:=n-t;inc(i);\n end;\n if n<0 then dec(i);\n writeln(i);\nend."}, {"source_code": "var\nn,k,i,j:longint;\nbegin\nreadln(n);\ni:=1;\nk:=1;\nwhile n-k>=0 do\n begin\n n:=n-k;\n i:=i+1;\n k:=0;\n for j:=1 to i do k:=k+j;\n end;\nwrite(i-1);\nend."}, {"source_code": "var\n n,i,x,sum:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n x:=x+i;\n sum:=sum+x;\n if sum>n then begin writeln(i-1);exit;end;\n if sum=n then begin writeln(i);exit;end;\n end;\nend."}, {"source_code": "var\n n,k,i,j,m:longint;\nbegin\n read(n);\n i:=1;\n k:=1;\n while n-k>=0 do\n begin\n n:=n-k;\n i:=i+1;\n k:=0;\n for j:=1 to i do k:=k+j;\n end;\n write(i-1);\nend."}, {"source_code": "var i, KolKyb, KolKybVYrov : Integer;\nbegin\n Readln(KolKyb);\n KolKybVYrov := 0;\n i := 0;\n While KolKybVYrov <= KolKyb do\n begin\n KolKyb := KolKyb - (KolKybVYrov);\n Inc(i);\n KolKybVYrov := KolKybVYrov + i;\n end;\n Writeln(i - 1);\nend."}, {"source_code": " {***ABDU**}\nvar i,j,n,m:integer; begin read(n);\nwhile m<=n do begin\nn:=n-m; inc(i); m:=m+i; end;\nwriteln(i-1);\nend."}, {"source_code": "var s,i,n:longint;\nbegin \n readln(n); i:=1; s:=0; \n while (1=1) do\n begin\n s:=s+i*(i+1) div 2; \n if (s>=n) then break else inc(i);\n end;\n if (s>n) then dec(i);\n writeln(i);\nend."}, {"source_code": "program vanyacubes;\n\nvar \n\tn: longint;\nbegin\n\treadln(n);\n\tcase n of\n\t1..3 : writeln(1);\n\t4..9 : writeln(2);\n\t10..19 : writeln(3);\n\t20..34 : writeln(4);\n\t35..55 : writeln(5);\n\t56..83 : writeln(6);\n\t84..119 : writeln(7);\n\t120..164 : writeln(8);\n\t165..219 : writeln(9);\n\t220..285 : writeln(10);\n\t286..363 : writeln(11);\n\t364..454 : writeln(12);\n\t455..559 : writeln(13);\n\t560..679 : writeln(14);\n\t680..815 : writeln(15);\n\t816..968 : writeln(16);\n\t969..1139 : writeln(17);\n\t1140..1329 : writeln(18);\n\t1330..1539 : writeln(19);\n\t1540..1770 : writeln(20);\n\t1771..2023 : writeln(21);\n\t2024..2299 : writeln(22);\n\t2300..2599 : writeln(23);\n\t2600..2924 : writeln(24);\n\t2925..3275 : writeln(25);\n\t3276..3653 : writeln(26);\n\t3654..4059 : writeln(27);\n\t4060..4494 : writeln(28);\n\t4495..4959 : writeln(29);\n\t4960..5455 : writeln(30);\n\t5456..5983 : writeln(31);\n\t5984..6544 : writeln(32);\n\t6545..7139 : writeln(33);\n\t7140..7769 : writeln(34);\n\t7770..8435 : writeln(35);\n\t8436..9138 : writeln(36);\n\t9139..9879 : writeln(37);\n\telse writeln(38);\n\tend\nend.\n"}, {"source_code": "Var n : longint;\n i,count,j,k : longint;\n f1,f2 : text;\nBegin\n Assign(f1,''); Reset(f1);\n Readln(f1,n);\n j:=0;\n i:=0;\n count:=0;\n while (k+j+i+1<=n) do\n Begin\n inc(count);\n i:=i+1;\n j:=j+i;\n k:=k+j;\n End;\n Assign(f2,''); Rewrite(f2);\n Writeln(f2,count);\n Close(f2);\nEnd.\n"}, {"source_code": "program kubix;\nvar n,count,sum,h:integer;\nbegin\nreadln(n);\nwhile n>=((2+count)*(count+1))div 2 do\nbegin\ncount:=count+1;\nsum:=((1+count)*count)div 2;\nn:=n-sum;\nend;\nwriteln(count);\nend.\n"}, {"source_code": "var x:integer; \nfunction Cub(x:integer):integer;\nvar k,s,sum:integer; \nbegin\nk:=0;s:=0;cub:=0;sum:=0; \nwhile sum<=x do begin \ncub:=s;\ns:=s+1; \nk:=k+s; \nsum:=sum+k;\nend;\nend;\nbegin\nread(x);\nwrite(cub(x)); \nend.\n"}, {"source_code": "var\n n, i, sum, ans : longint;\n \nbegin\n sum := 0; i := 1;\n read(n);\n for i := 1 to n do\n begin\n sum := sum + i * (i + 1) div 2;\n if sum <= n then \n ans := i\n else\n begin\n ans := i - 1;\n break;\n end\n end;\n write(ans);\nend."}, {"source_code": "var k,b,c,s:integer;\nbegin\nreadln(k);\nb:=1; c:=0; s:=2;\nwhile k-b>=0 do\nbegin \nk:=k-b;\nb:=b+s;\ns:=s+1;\ninc(c); end;\nwriteln(c);\nend."}, {"source_code": "var n,i,j:longint;\nbegin\n\treadln(n);\n\ti:=0;\n\tj:=1;\n\twhile n>=j do\n\tbegin\n\t\tinc(i);\n\t\tdec(n,j);\n\t\tinc(j,i+1);\n\tend;\n\twriteln(i);\nend."}, {"source_code": "program easy;\nvar n,s,i:integer;\n\nbegin\n readln(n);\n s:=1;\n i:=1;\n while(s<=n)do\n begin\n Inc(i); \n s:=s+Round(i*(i+1)/2);\n end;\n write(i-1);\nend."}, {"source_code": "{$mode objfpc}\nvar\n i, n: integer;\n\nbegin\n readln(N);\n if N <= 0 then begin writeln(0); exit end;\n i := 1;\n while N - i*(i+1) div 2 >= 0 do\n begin\n dec(N, i*(i+1) div 2);\n inc(i)\n end;\n writeln(i-1);\n readln\nend."}, {"source_code": "var\ni,j,otv,sum,n:longint;\nbegin\nreadln(n);\ni:=0;\nwhile true do begin\n inc(i);\n for j:=1 to i do sum:=sum+j;\n inc(otv);\n if sum>n then break;\n\nend;\nif sum=n then writeln(otv)\nelse\nwriteln(otv-1);\nend."}, {"source_code": "var\ni,j,otv,sum,n:longint;\nbegin\nreadln(n);\ni:=0;\nwhile true do begin\n inc(i);\n for j:=1 to i do sum:=sum+j;\n inc(otv);\n if sum>n then break;\n\nend;\nif sum=n then writeln(otv)\nelse\nwriteln(otv-1);\nend."}, {"source_code": "var ans,h: longint;\n t,s: int64;\nbegin\n t:=1;\n ans:=1;\n readln(s);\n h:=1;\n while (ts) then dec(h);\n write(h);\nend."}], "negative_code": [{"source_code": "var n,i:longint;\n res:longint;\nbegin\n read(n);\n i:=1; res:=0;\n while n>0 do\n begin\n dec(n,i);\n i:=i+2;\n end;\n if n<0 then dec(res);\nend."}, {"source_code": "var\n sum:int64;\n x,i:longint;\nbegin\n read(x);\n i:=2;\n sum:=1;\n while sum<=x do\n begin\n sum:=sum+i;\n inc(i);\n end;\n writeln(i);\nend."}, {"source_code": "Var a : array[1..10000]of longint;\n i,j,k,l,n,m,t,c : Longint;\nbegin\n readln(n);\n While t + i <= n DO\n begin\n inc(i);\n inc(k,round((1 + i) / 2 * i));\n inc(t,k);\n end;\n writeln(i);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar n,i,count:integer;\nfunction sum(n:integer):integer;\n var i:integer;\n begin\n sum:=0;\n for i:=1 to n do sum:=sum+i;\n end;\nbegin\n readln(n);\n count:=0;i:=1;\n while i<=n do\n begin\n inc(count);\n i:=sum(count);\n n:=n-i;\n // writeln(i,' ',count,' ',n);\n end;\n writeln(count);\nend."}, {"source_code": "program VANYA_AND_CUBE;\nconst fi='';\n fo='';\nvar N,d,T,tr: integer;\nprocedure doc;\nvar f: text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,N);\n close(f);\nend;\nprocedure xu_ly;\nvar i: integer;\nbegin\n {d:=1;\n T:=1;\n tr:=1;\n while TN then\n begin\n d:=i-1;\n break;\n end;\n end;\nend;\nprocedure ghi;\nvar f: text;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,d);\n close(f);\nend;\nBEGIN\n doc;\n xu_ly;\n ghi;\nEND.\n"}, {"source_code": "var i, n, x, k, ans:integer;\nbegin\n\treadln(n);\n\ti := 0;\n k := 0;\n\twhile n > k do begin\n\t\tinc(i);\n\t\tk := i + k;\n\t\tn := n - k;\n\tend;\n\twriteln(i);\nend."}, {"source_code": "Var k,n,i,j,z : longint ;\nbegin\nreadln(n) ; k:=2 ; z:=1 ; i:=1 ;\nwhile n-k-i>0 do begin\nn:=n-k ;\nn:=n-i ;\nk:=k+1 ;\ni:=i+k ;\nz:=z+1 ;\nend ;\nwriteln(z) ;\nend.\n\n"}, {"source_code": "Var\n n,i,k:integer;\nbegin\n readln(n); i:=1; while n-i-1>0 do begin inc(i); n:=n-i; end; writeln(i);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar n,i,count:integer;\nfunction sum(n:integer):integer;\n var i:integer;\n begin\n sum:=0;\n for i:=1 to n do sum:=sum+i;\n end;\nbegin\n readln(n);\n count:=0;i:=1;\n while i<=n do\n begin\n inc(count);\n i:=sum(count);\n n:=n-i;\n // writeln(i,' ',count,' ',n);\n end;\n writeln(count);\nend."}, {"source_code": "var n:longint;\n m,t,r,l:real;\nbegin\n readln(n);\n l:=0;\n r:=1000;\n while abs(r-l)>0.01 do\n begin\n m:=(l+r)/2;\n t:=(m*m*m+3*m*m+2*m)/6;\n if t>n then\n r:=m;\n if tn then begin writeln(i-1);exit;end;\n if sum =n then begin writeln(i);exit;end;\n inc(x);\n end;\nend."}, {"source_code": "Program PBA;\nVar n,i,t:longint;\nBegin\nreadln(n);\ni:=0;\nt:=0;\nWhile t+(i+1)<=n do\nBegin\ninc(i);\nt:=t+i;\nEnd;\nwrite(i);\nEnd."}, {"source_code": "var\n sum:int64;\n x,i:longint;\nbegin\n read(x);\n i:=2;\n sum:=1;\n while sum= t) do\n begin\n m := m + 1;\n t := t +(t + m);\n q := q + 1;\n end;\n write(q);\nend."}, {"source_code": "//492a\nvar n,i,k:int64;\nbegin\nread(n);\nwhile k<=n do\nbegin\n\n\n k:=i+2*k;\n if k<=n then inc(i);\n\nend;\n\nwrite(i-1);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n n, i, dem, j: integer;\n s: int64;\nbegin\n readln(n);\n i := 1;\n j := 1;\n if n = 0 then begin\n writeln(0);\n exit;\n end;\n repeat\n s := s + i;\n inc(j);\n i := i + j;\n inc(dem);\n until s >= n;\n if dem <= 1 then write(dem) else\n writeln(dem - 1);\nend."}, {"source_code": "var n,i:longint;\n res:longint;\nbegin\n read(n);\n i:=1; res:=0;\n while n>0 do\n begin\n dec(n,i);\n i:=i+2;\n end;\n if n<0 then dec(res);\nend."}, {"source_code": "var i,n,j,k: integer;\nbegin\nread(n);\nk:=0;\ni:=1;\nj:=1;\nwhile n>i do begin\n n:=n-i;\n i:=i+j;\n j:=j+1;\n k:=k+1;\nend;\nwrite(k);\nend."}, {"source_code": "var\na,b,c,d,e,f,g,h,i:integer;\nbegin\nreadln(a);\nc:=1;\nwhile (bb) then\nc:=c+1;\nif b=a-1 then\nc:=c-1;\nend;\nwriteln(c);\nreadln\nend."}, {"source_code": "Var n : longint;\n i,count,j : longint;\n f1,f2 : text;\nBegin\n Assign(f1,''); Reset(f1);\n Readln(f1,n);\n j:=0;\n i:=0;\n count:=0;\n while (j+i+1<=n) do\n Begin\n inc(count);\n i:=i+i+1;\n j:=j+i;\n End;\n Assign(f2,''); Rewrite(f2);\n Writeln(f2,count);\n Close(f2);\nEnd.\n"}, {"source_code": "var\n n,k,i:longint;\nbegin\n read(n);\n i:=1;\n k:=1;\n while n-k>=0 do \n begin\n n:=n-k;\n i:=i+1;\n k:=i*i;\n end;\n write(i);\nend.\n"}, {"source_code": "var s,i,n:longint;\nbegin \n readln(n); i:=1; s:=0;\n while (n0.01 do\n begin\n m:=(l+r)/2;\n t:=(m*m*m+3*m*m+2*m)/6;\n if t>n then\n r:=m;\n if t0 do begin\nn:=n-p ;\np:=p+i ;\n\ni:=i+2 ;\nk:=k+1 ;\nend ;\nwriteln(k);\nwriteln(p) ;\nend.\n"}, {"source_code": "var\n n,i,j,x : longint ;\n\nbegin\n readln (n) ;\n i := 0 ;\n x := 0 ;\n repeat\n begin\n inc (i) ;\n x := x + i ;\n n := n - x ;\n end;\n until (n < x) ;\n writeln (i);\nend.\n\n\n"}, {"source_code": "var\n i,k,n,s: integer;\nbegin\n Readln(n);\n s := 0;\n i := 0;\n k := 0;\n while s+k+i+1 <= n do begin\n inc(i);\n inc(k,i);\n inc(s,i);\n end;\n writeln(i);\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nvar n : int64;\n d ,pre: int64;\n i : integer;\nbegin\n readln(n);\n d := 0;\n pre:=0;\n for i:=1 to 69 do\n begin\n\n if pre >= n then\n begin\n Writeln(d);\n halt;\n end;\n inc(d);\n pre:=2*pre+i;\n end;\nend."}, {"source_code": "{$mode objfpc}\nvar n, i, dem: Integer;\n\nfunction TCS(x: Integer): Int64;\nbegin\n Result:= (x*(x+1)) div 2;\nend;\n\nbegin\n Readln(n);\n If n = 1 then Writeln(1)\n else begin\n i:= 1;\n Repeat\n n:= n - TCS(i);\n Inc(i);\n Inc(dem);\n Until n <= 0;\n Writeln(dem - 1);\n end;\nend."}, {"source_code": "var i,j,k,l,m,n:longint;\nbegin\nreadln(n);\ni:=0;\nm:=0;\nwhile (mn then break;\n end;\n write(i-1);\n end."}, {"source_code": "var n,x:longint;\n s,s1:int64;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n);\n x:=0;\n while s=s1+s1 then\n x:=x+1;\n end;\n writeln(x);\nend."}, {"source_code": "var n:longint;\n m,t,r,l:real;\nbegin\n readln(n);\n l:=0;\n r:=1000;\n while abs(r-l)>0.01 do\n begin\n m:=(l+r)/2;\n t:=(m*m*m+3*m*m+2*m)/6;\n if t>n then\n r:=m;\n if t t) do\n begin\n m := m + 1;\n t := t +(t + m);\n q := q + 1;\n end;\n write(q);\nend."}, {"source_code": "Var n : longint;\n i,count,j : longint;\n f1,f2 : text;\nBegin\n Assign(f1,''); Reset(f1);\n Readln(f1,n);\n i:=0;\n count:=0;\n while j= 0 do\n begin\n inc(i);\n dec(N, i*(i+1) div 2);\n end;\n writeln(i);\nend."}, {"source_code": "var n,i:longint;\nBEGIN\nreadln(n);\nrepeat\ninc(i);\nuntil (sqr(i)+i)>(2*n);\nwrite(i-1);\nEND."}, {"source_code": "var\n sum:int64;\n x,i:longint;\nbegin\n read(x);\n i:=1;\n sum:=1;\n while sum<=x do\n begin\n inc(i);\n sum:=sum+i;\n end;\n writeln(i-1);\nend."}, {"source_code": "var n,x:longint;\n s,s1:int64;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n);\n x:=0;\n while s=s1+x+1 then\n x:=x+1;\n end;\n writeln(x);\nend."}, {"source_code": "var n,i,s,sum:longint;\nbegin\nread(n);\nsum:=0;\nfor i:=1 to n do\nbegin\nsum:=sum+i*(i+1) div 2;\nif sum <= n then s:=i;\nend;\nwriteln(s);\nend."}, {"source_code": "var\n i,k,n: integer;\nbegin\n Readln(n);\n i := 0;\n k := 0;\n while k+i+1 <= n do begin\n inc(i);\n inc(k,i);\n end;\n writeln(i);\nend."}, {"source_code": "var n,i:longint;\n res:longint;\nbegin\n read(n);\n i:=1; res:=0;\n while n>0 do\n begin\n dec(n,i);\n i:=i+2;\n inc(res);\n end;\n if n<0 then dec(res);\n write(res);\nend."}, {"source_code": "var n:longint;\n m,t,r,l:real;\nbegin\n readln(n);\n l:=0;\n r:=1000;\n while abs(r-l)>0.01 do\n begin\n m:=(l+r)/2;\n t:=(m*m*m+3*m*m+2*m)/6;\n if t>n then\n r:=m;\n if tn then begin write(i-1); break; end;\nend."}, {"source_code": "var n,s,i:longint; begin read (n);s:=0; i:=0; while n-s>0 do begin inc(i); s:=s+i; n:=n-s; end; if n<0 then write (i-1); if n=0 then write (i); end.\n"}, {"source_code": "program VANYA_AND_CUBE;\nconst fi='';\n fo='';\nvar N,d,T,tr: integer;\nprocedure doc;\nvar f: text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,N);\n close(f);\nend;\nprocedure xu_ly;\nvar i: integer;\nbegin\n {d:=1;\n T:=1;\n tr:=1;\n while TN then\n begin\n d:=i-1;\n break;\n end;\n end;\nend;\nprocedure ghi;\nvar f: text;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,d);\n close(f);\nend;\nBEGIN\n doc;\n xu_ly;\n ghi;\nEND.\n"}, {"source_code": "var\ni,n,t,q,s:longint;\nbegin\nread(n);\nwhile s<=n do begin\ninc(q);\ns:=s+q;\nn:=n-s;\ninc(t);\nend;\nwrite(t);\nend.\n \n "}, {"source_code": "Var\nn,i,sch:longint;\n//____________________________________________\n//____________________________________________\nProcedure InputData;\n Begin\n // Assign(input, 'input.txt');\n // Reset(input);\n ReadLn(N);\n // close(input);\n end;\n//___________________________________________\n//___________________________________________\nProcedure OutputData;\n Begin\n// Assign(output, 'output.txt');\n // Rewrite(output);\n i:=1; sch:=1;\n While (n - sch)>=0 do\n Begin\n dec(n,sch);\n If (n-sch)>=0 Then\n Begin\n inc(i);\n inc(sch,i);\n End\nelse Break;\n end;\n Write(i);\n // close(output);\n end;\n//___________________________________________\n//___________________________________________\nBegin\n InputData;\n OutputData;\nEnd."}, {"source_code": "program easy;\nvar n,s,i:integer;\n\nbegin\n readln(n);\n s:=1;\n i:=1;\n while(s0 do\n begin\n inc(c);\n n:=n-a;\n a:=a+c+1;\n end;\n write(c);\nEnd.\n\n"}, {"source_code": "var \n\tn, i: integer;\n\tcount: longint;\nbegin\n\treadln(n);\n\ti:=1;\n\twhile count < n do\n\t\tbegin\n\t\t\tcount:=count * 2 + i;\n\t\t\ti:=i+1;\n\t\tend;\n\twriteln(i - 1);\nend."}, {"source_code": "Var a : array[1..10000]of longint;\n i,j,k,l,n,m,t,c : Longint;\nbegin\n readln(n);\n While t + i <= n DO\n begin\n inc(i);\n inc(k,round((1 + i) / 2 * i));\n inc(t,k);\n end;\n writeln(i);\nend.\n"}, {"source_code": "Var a : array[1..10000]of longint;\n i,j,k,l,n,m,t,c : Longint;\nbegin\n readln(n);\n While t < n DO\n begin\n inc(i);\n inc(t,t + i);\n end;\n writeln(i);\nend.\n"}, {"source_code": "var\n i,k,n: integer;\nbegin\n Readln(n);\n i := 0;\n k := 0;\n while k+i+1 <= n do begin\n inc(i);\n inc(k,i);\n end;\n writeln(i);\nend."}, {"source_code": "const fi='';\n fo='';\nvar i,n,s:int64;\n f,g:text;\nprocedure data;\nbegin\n assign(f,fi); assign(g,fo);\n reset(f); rewrite(g);\n readln(f,n);\nend;\nprocedure process;\nbegin\n s:=0;\n i:=0;\n while (n>=i) do\n begin\n inc(i);\n inc(s,i);\n dec(n,s);\n end;\n if n<0 then writeln(g,i-1);\n if n=0 then writeln(g,i);\n if n>0 then writeln(g,i+1);\n\nend;\nbegin\n data;\n process;\n close(g);\nend."}, {"source_code": "var\n i,k,n: integer;\nbegin\n Readln(n);\n i := 0;\n k := 0;\n while k+i+1 <= 25 do begin\n inc(i);\n inc(k,i);\n end;\n writeln(i);\nend."}, {"source_code": " var i,m,n,q:longint;\n begin\n read (n);\n while m=n) then break else inc(i);\n end;\n if (s>n) then dec(i);\n writeln(i);\nend."}, {"source_code": "{$mode objfpc}\nvar n,i,count:integer;\nfunction sum(n:integer):integer;\n var i:integer;\n begin\n sum:=0;\n for i:=1 to n do sum:=sum+i;\n end;\nbegin\n readln(n);\n count:=0;i:=1;\n while i<=n do\n begin\n inc(count);\n i:=sum(count);\n n:=n-i;\n // writeln(i,' ',count,' ',n);\n end;\n writeln(count);\nend."}, {"source_code": "var n:longint;\n m,t,r,l:real;\nbegin\n readln(n);\n l:=0;\n r:=1000;\n while abs(r-l)>0.1 do\n begin\n m:=(l+r)/2;\n t:=(m*m*m+3*m*m+2*m)/6;\n if t>n then\n r:=m;\n if t=y do begin\nx:=x-y;\ninc(z);\ny:=y+z;\nwriteln(z-1);\nend;\nend."}, {"source_code": "const prob='492A'; \nvar n,s,i:integer;\nbegin\n // assign(input,prob+'.inp'); reset(input);\n // assign(output,prob+'.out'); rewrite(output);\n readln(n);\n s:=1;\n i:=1;\n while(s0 do begin\nn:=n-p ;\np:=p+i ;\n\ni:=i+2 ;\nk:=k+1 ;\nend ;\nwriteln(k);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nvar n : int64;\n d ,pre: int64;\n i : integer;\nbegin\n readln(n);\n d := 0;\n pre:=0;\n for i:=1 to 69 do\n begin\n\n if pre >= n then\n begin\n Writeln(d);\n halt;\n end;\n inc(d);\n pre:=2*pre+i;\n end;\nend."}, {"source_code": "var ans,h: longint;\n t,s: int64;\nbegin\n t:=0;\n ans:=1;\n readln(s);\n h:=0;\n while (ts) then dec(h);\n write(h);\nend."}, {"source_code": "program VANYA_AND_CUBE;\nconst fi='';\n fo='';\nvar N,d,T,tr: integer;\nprocedure doc;\nvar f: text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,N);\n close(f);\nend;\nprocedure xu_ly;\nvar i: integer;\nbegin\n {d:=1;\n T:=1;\n tr:=1;\n while TN then\n begin\n d:=i-1;\n break;\n end;\n end;\nend;\nprocedure ghi;\nvar f: text;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,d);\n close(f);\nend;\nBEGIN\n doc;\n xu_ly;\n ghi;\nEND.\n"}, {"source_code": "var\n sum:int64;\n x,i:longint;\nbegin\n read(x);\n i:=2;\n sum:=1;\n while sum<=x do\n begin\n sum:=sum+i;\n inc(i);\n end;\n writeln(i-1);\nend."}, {"source_code": " var i,m,n,q:longint;\n begin\n read (n);\n while mn then break;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n n,i:longint;\nbegin\n read(n);\n for i:=n downto 1 do\n if (1+i)*i/2<=n then begin write(i); halt; end;\nend."}, {"source_code": "var\nn,q,w,e,o:longint;\nbegin\nread(n);\nq:=1;\nw:=1;\ne:=1;\no:=1;\nif n>q\nthen\nwhile n-(w+q+e)>=0 do\nbegin\nq:=q+e;\ninc(e);\nw:=w+q;\nn:=n-w;\nInc(o);\nend;\nwrite(o);\nend. "}, {"source_code": "var\n n,i,a,kq:longint;\nbegin\n readln(n);\n i:=2;\n a:=1;\n while n>=a do\n begin\n dec(n,a);\n inc(kq);\n inc(i);\n inc(a,i);\n end;\n write(kq);\nend."}, {"source_code": "var\na,b,c,d,e,f,g,h,i:integer;\nbegin\nreadln(a);\nc:=1;\nwhile (bb) then\nc:=c+1;\nif b=a-1 then\nc:=c-1;\nend;\nwriteln(c);\nreadln\nend."}, {"source_code": "program easy;\nvar n,s,i:integer;\n\nbegin\n readln(n);\n s:=1;\n i:=1;\n while(s=j do\n\tbegin\n\t\tinc(i);\n\t\tdec(n,j);\n\t\tinc(j,2);\n\tend;\n\twriteln(i);\nend."}, {"source_code": "var ans,h: longint;\n t,s: int64;\nbegin\n t:=0;\n ans:=1;\n readln(s);\n h:=0;\n while (ts) then dec(h);\n write(h);\nend."}, {"source_code": "var n,x:longint;\n s,s1:int64;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n);\n x:=1;\n while s=s1+s1 then\n x:=x+1;\n end;\n writeln(x);\nend."}, {"source_code": "var n,a:longint;ans,i:integer;\nbegin\n readln(n);\n if n = 1 then writeln('1')\n else begin\n a:=1;\n ans:=1;\n while (a<=n) do\n begin\n inc(ans);\n a:=a+(a+ans);\n end;\n\n if a = n+1 then writeln(ans)\n else writeln(ans-1);\n end;\n\nend."}, {"source_code": "program z1;\n var n,m,i:longint;\nfunction f1(a,r,k:longint):longint;\nbegin\n writeln(r,' ',a);\n if(a+k>m)\n then f1:=r\n else f1:=f1(a+k,r+1,k+r+2);\nend;\nbegin\n readln(m);\n writeln(f1(0,0,1));\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var n: int64;\n i, j: longint;\nbegin\n n:=0; \n readln(j);\n for i:=1 to j do n:=n+i;\n write(n);\nend."}, {"source_code": "VAr a,b,c,d,u,i,j,n,k,p : longint ;\nbegin\nreadln(n); i:=1 ; p:=3 ;\nwhile n>0 do begin\nn:=n-p ;\np:=p+i ;\n\ni:=i+2 ;\nk:=k+1 ;\nend ;\nwriteln(k);\nwriteln(p) ;\nend.\n"}, {"source_code": "program z1;\nvar n,i,k,br:longint;\nbegin\nread(n);\ni:=1;\nwhile n-i>=0 do\n begin\n k:=k+i;\n n:=n-k;\n i:=i+1;\n br:=br+1;\n end;\nwriteln(br);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n fi = '';\n fo = '';\n\nvar\n f1,f2 :Text;\n n :Integer;\n s,f :array[1..100000] of Integer;\n\nprocedure Input;\nvar\n i :Integer;\nbegin\n readln(f1,n);\n s[1]:=1;\n for i:=2 to 50 do s[i]:=s[i-1]+i;\n for i:=2 to 50 do f[i]:=f[i-1]+s[i];\n for i:=1 to 20 do\n if f[i]>n then Break;\n Writeln(i-1);\nend;\n\nBEGIN\n assign(f1,fi);reset(f1);\n assign(f2,fo);rewrite(f2);\n Input;\n close(f1);close(f2);\nEND.\n"}, {"source_code": "var n,x:longint;\n s,s1:int64;\nbegin\n// assign(input,'input.txt');reset(input);\n// assign(output,'output.txt');rewrite(output);\n read(n);\n x:=1;\n while s=s1+s1 then\n x:=x+1;\n end;\n writeln(x);\nend."}, {"source_code": "{$mode objfpc}\nvar n, i, dem: Integer;\n\nfunction TCS(x: Integer): Integer;\nbegin\n Result:= (x*(x+1)) div 2;\nend;\n\nbegin\n Readln(n);\n i:= 1;\n Repeat\n n:= n - TCS(i);\n Inc(i);\n Inc(dem);\n Until n = 0;\n Writeln(dem);\nend."}, {"source_code": "var a,n,t:integer;\nbegin\na:=1;\nt:=1;\nreadln(n);\nwhile a*2+2<=n do\n begin \n inc(t);\n a:=a*2+2;\n end;\nwriteln(t);\nend."}, {"source_code": "var n,a:longint;ans,i:integer;\nbegin\n readln(n);\n if n = 1 then ans:=1\n else begin\n a:=1;\n ans:=1;\n while (a<=n) do\n begin\n inc(ans);\n a:=a+(a+ans);\n end;\n writeln(a);\n if a = n+1 then writeln(ans)\n else writeln(ans-1);\n end;\n\nend."}, {"source_code": "var n,x1:longint;\nx:real;\nbegin\nreadln(n);\nx:=((-1 + sqrt(1+4*2*n)) / 2) ;\nx1:=trunc(x);\nWriteln(x1);\nend. "}, {"source_code": "var a,n,h,i:real;\nbegin\nreadln(n); \nwhile a<=n do begin h:=h+1;\na:=a+(h*(h+1))/2;\nend;\nwrite(h-1);\nend."}], "src_uid": "873a12edffc57a127fdfb1c65d43bdb0"} {"source_code": "var a,b,c:longint;\ni,j:longint;\nT:ARRAY [2..8] OF LONGINT;\nFUNCTION MAX(AA,BB:LONGINT):LONGINT;\nBEGIN\n IF AA>BB THEN MAX:=AA ELSE MAX:=BB;\nEND;\nFUNCTION MIN(AA,BB:LONGINT):LONGINT;\nBEGIN\n IF AA>BB THEN MIN:=BB ELSE MIN:=AA;\nEND;\nFUNCTION LAST(Q:LONGINT):INT64;\nVAR I,J:LONGINT;\n A1,B1,C1:LONGINT;\nBEGIN\n A1:=A;\n B1:=B;\n C1:=C;\n I:=0;\n J:=Q;\n WHILE (A1>=0) AND (B1>=0) AND (C1>=0) DO\n BEGIN\n IF T[J]=1 THEN DEC(A1);\n IF T[J]=2 THEN DEC(B1);\n IF T[J]=3 THEN DEC(C1);\n I:=I+1;\n J:=J+1;\n IF J>8 THEN J:=2;\n END;\n LAST:=I-1;\nEND;\nPROCEDURE THAMLAM;\nVAR I,J:LONGINT;\n SL,SN:INT64;\nBEGIN\n SL:=MIN(A DIV 3,MIN(B DIV 2,C DIV 2));\n A:=A-SL*3;\n B:=B-SL*2;\n C:=C-SL*2;\n SN:=0;\n FOR I:=2 TO 8 DO\n BEGIN\n SN:=MAX(SN,SL*7+LAST(I));\n END;\n WRITELN(SN);\nEND;\nBEGIN\n T[2]:=1;\n T[3]:=2;\n T[4]:=3;\n T[5]:=1;\n T[6]:=3;\n T[7]:=2;\n T[8]:=1;\n READLN(A,B,C);\n THAMLAM;\nEND.", "positive_code": [{"source_code": "Program Go;\nVAR a,b,c,i,min,k,r,aux1,aux2,aux3,j,kaux:int64; bo:boolean; ar1,ar2,ar3:array[1..7] of int64;\nBegin\n\nReadln(a,b,c);\nbo:=true;\nmin:=a div 3;\nif (((b) div 2) < min) then min:=b div 2;\nif ((c div 2) < min) then min:=c div 2;\n\nk:=7*min;\nkaux:=k;\na:=a - min*3;\nb:=b - min*2;\nc:=c - min*2;\n\nar1[1]:=1; ar1[2]:=0; ar1[3]:=0; ar1[4]:=1; ar1[5]:=0; ar1[6]:=0; ar1[7]:=1;\nar2[1]:=0; ar2[2]:=1; ar2[3]:=0; ar2[4]:=0; ar2[5]:=0; ar2[6]:=1; ar2[7]:=0;\nar3[1]:=0; ar3[2]:=0; ar3[3]:=1; ar3[4]:=0; ar3[5]:=1; ar3[6]:=0; ar3[7]:=0;\n\n\n\nfor i:=1 to 7 do\nBegin\n\nbo:=true;\nr:=kaux;\naux1:=a;\naux2:=b;\naux3:=c;\nj:=i;\nwhile (bo) do\nBegin\n\naux1:=aux1 - ar1[j];\naux2:=aux2 - ar2[j];\naux3:=aux3 - ar3[j];\nj:=j + 1;\nif (j = 8) then j:=1;\n\nif (aux1 >= 0) and (aux2 >= 0) and (aux3 >= 0) then r:=r + 1 else bo:=false;\n\nend;\n\nif (r > k) then k:=r;\n\nend;\n\nWriteln(k);\n\nReadln;\nEND."}, {"source_code": "var min,maxp,ba,bb,bc,max,j,backup,i,a,b,c,ans,ty:integer;\nbegin\nread(a,b,c);\n\nba:=a div 3;\nbb:=b div 2;\nbc:=c div 2;\n\nif (ba <= bb) and (ba <= bc) then\n min:=ba;\nif (bb <= ba) and (bb <= bc) then\n min:=bb;\nif (bc <= ba) and (bc <= bb) then\n min:=bc;\n\na:=a - min*3;\nb:=b - min*2;\nc:=c - min*2;\ninc(ans,min*7);\n\nmax:=0;\nba:=a;\nbb:=b;\nbc:=c;\ni:=0;\nfor j:=1 to 7 do begin\n a:=ba;\n b:=bb;\n c:=bc;\n maxp:=0;\n i:=j;\n for ty:=1 to 7 do begin\n if (i = 1) or (i = 4) or (i = 7) then\n if (a > 0) then begin\n inc(maxp);\n dec(a);\n end\n else\n break;\n if (i = 2) or (i = 6) then\n if (b > 0) then begin\n inc(maxp);\n dec(b);\n end\n else\n break;\n if (i = 3) or (i = 5) then\n if (c > 0) then begin\n inc(maxp);\n dec(c);\n end\n else\n break;\n inc(i);\n if (i = 8) then\n i:=1;\n end;\n if (maxp > max) then\n max:=maxp;\nend;\n\ninc(ans,max);\nwriteln(ans);\nend."}, {"source_code": "var a,b,c,kol,k,max,i:longint;m:array[1..3]of longint;\nfunction ky(i,a,b,c:longint):longint;\nvar j,k:longint;\nbegin\n k:=0;\n for j:=i to 7 do\n if (j in [1,4,7])and(a>0) then\n begin\n dec(a);\n inc(k);\n end\n else if (j in [2,6])and(b>0) then\n begin\n dec(b);\n inc(k);\n end\n else if (j in [3,5])and(c>0) then\n begin\n dec(c);\n inc(k);\n end\n else\n begin\n ky:=k;\n exit;\n end;\n for j:=1 to i-1 do\n if (j in [1,4,7])and(a>0) then\n begin\n dec(a);\n inc(k);\n end\n else if (j in [2,6])and(b>0) then\n begin\n dec(b);\n inc(k);\n end\n else if (j in [3,5])and(c>0) then\n begin\n dec(c);\n inc(k);\n end\n else\n begin\n ky:=k;\n exit;\n end;\nend;\nbegin\n read(a);\n read(b);\n read(c);\n m[1]:=a div 3;\n m[2]:=b div 2;\n m[3]:=c div 2;\n kol:=m[1];\n if m[2]max then max:=k;\n end;\n kol:=kol+max;\n writeln(kol);\nend."}, {"source_code": "program Project_C;\n\nvar\n a, b, c, x, j, max, a1, b1, c1: int64;\n i: longint;\n\nbegin\n read(a, b, c);\n x := a div 3;\n if (b div 2) < x then\n x := b div 2;\n if (c div 2) < x then\n x := c div 2;\n\n a := a - 3 * x;\n b := b - 2 * x;\n c := c - 2 * x;\n\n max := 0;\n a1 := a;\n b1 := b;\n c1 := c;\n for i := 1 to 7 do begin\n j := i;\n a := a1;\n b := b1;\n c := c1;\n while (j < i + 7) do begin\n if (j = 1) or (j = 4) or (j = 7) or (j = 8) or (j = 11) or (j = 14) then begin\n if a > 0 then begin\n dec(a);\n inc(j);\n end else\n break;\n end else if (j = 2) or (j = 6) or (j = 9) or (j = 13) then begin\n if b > 0 then begin\n dec(b);\n inc(j);\n end else\n break;\n end else begin\n if c > 0 then begin\n dec(c);\n inc(j);\n end else\n break;\n end;\n end;\n if j - i > max then\n max := j - i;\n end;\n\n write(7 * x + max);\n\nend."}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\ntype mas=array[-10000..550000+1] of int64; integer=longint;\nvar dl,len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;\nss,ss1:string;\npos,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;\n summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n razr,jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n marked,zan:array[-10..1000000] of boolean;\n predok,a1,b1,strok:array[-10..550000] of int64;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n sp,sss:array[-10..2000000] of string;\n newpole,dd,pole:array[-100..1210,-1..1210] of int64;\n dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;\n poss:int64;\n ch:char;\n flagg1:boolean;\n ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;\n ddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean;\n begin if (a[i]c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=0)and(q1>=0)and(q2>=0)) do\n begin\n if i mod 7=0 then dec(q0);\n if i mod 7=1 then dec(q1);\n if i mod 7=2 then dec(q2);\n if i mod 7=3 then dec(q0);\n if i mod 7=4 then dec(q2);\n if i mod 7=5 then dec(q1);\n if i mod 7=6 then dec(q0);\n i:=(i+1) mod 7;\n inc(ii);\n end;\n if cur 0 then begin\n inc(current_length);\n dec(a2);\n end else\n break;\n\n if days[j mod 8] = 'b' then\n if b2 > 0 then begin\n inc(current_length);\n dec(b2);\n end else\n break;\n\n if days[j mod 8] = 'c' then\n if c2 > 0 then begin\n inc(current_length);\n dec(c2);\n end else\n break;\n\n inc(j);\n end;\n\n if current_length > max_length then\n max_length := current_length;\n end;\n\n writeln(min_weeks*7+max_length);\nend.\n"}, {"source_code": "const fi='';\nvar f:text;\ni,j:longint;\na,b,c,a1,b1,c1,n,k,m,s,d,t:int64;\nbegin\n assign(f,fi);\n reset(f);\n read(f,a,b,c);\n close(f);\n\n a1:=a div 3;\n b1:=b div 2;\n c1:=c div 2;\n\n s:=1000000000;\n\n if s>a1 then s:=a1;\n if s>b1 then s:=b1;\n if s>c1 then s:=c1;\n\n s:=7*s;\n k:=0;\n\n for i:=1 to 7 do\n begin\n a1:=a-3*(s div 7);\n b1:=b-2*(s div 7);\n c1:=c-2*(s div 7);\n for j:=i to 6+i do\n begin\n t:=0;\n if (j mod 7=1) or (j mod 7=2) or (j mod 7=5) then\n if a1>0 then\n begin\n dec(a1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=3) or (j mod 7=0) then\n if b1>0 then\n begin\n dec(b1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=4) or (j mod 7=6) then\n if c1>0 then\n begin\n dec(c1);\n inc(d);\n t:=1;\n end;\n if t=0 then break;\n end;\n if ka[i] then exit(-1);\n exit(r-l+1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(u:longint):boolean;\n var i:longint;\n begin\n for i:=1 to 3 do if b[i]*u>a[i]-count[i] then exit(false);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc2(l,r:longint):longint;\n var i,tg,ll,rr,mid,res:longint;\n begin\n for i:=1 to 3 do count[i]:=0;\n for i:=l to 7 do inc(count[q[i]]);\n for i:=1 to r do inc(count[q[i]]);\n for i:=1 to 3 do if count[i]>a[i] then exit(-1);\n ll:=0;\n rr:=700000000;\n res:=0;\n while ll<=rr do\n begin\n mid:=(ll+rr) div 2;\n if check(mid) then\n begin\n ll:=mid+1;\n res:=mid;\n end else rr:=mid-1;\n end;\n exit(res*7+7-l+1+r);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j,res:longint;\n begin\n res:=0;\n for i:=1 to 7 do\n for j:=i to 7 do res:=max(res,calc1(i,j));\n for i:=1 to 7 do\n for j:=1 to 7 do res:=max(res,calc2(i,j));\n write(fo,res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var a,b,c,i,x,j,k,f:int64;\nd,p,q:array[0..7] of longint;\nbegin\nread(a,b,c);\nx:=a div 3;\nx:=min(x,b div 2);\nx:=min(x,c div 2);\na-=x*3;\nb-=x*2;\nc-=x*2;\nd[0]:=1;d[1]:=2;d[2]:=3;d[3]:=1;d[4]:=3;d[5]:=2;d[6]:=1;\n\np[1]:=a;\np[2]:=b;\np[3]:=c;\nq:=p;\nfor i:=1 to 7 do\nbegin\nj:=i;p:=q;\nwhile p[d[j mod 7]]>0 do\nbegin\np[d[j mod 7]]-=1;\nj+=1\nend;\nk:=max(k,j-i)\nend;\n\nwrite(x*7+k)\nend.\n//abcacba "}, {"source_code": "var x,y,z,a,b,c,s,k,i,j:int64;\nbegin\n read(a,b,c);\n x:=a div 3;\n y:=b div 2;\n z:= c div 2;\n s:=0;\n s:=7*min(min(x,y),z);\n a:=a - 3 * min(min(x,y),z);\n b:=b - 2*min(min(x,y),z);\n c:=c-2*min(min(x,y),z);\n k:=0;\n for i:=1 to 7 do\n begin\n j:=i;\n x:=a;\n y:=b;\n z:=c;\n while (x > -1) and (y > -1) and (z > -1) do\n begin\n if (j mod 7 = 1) or (j mod 7 = 4) or (j mod 7 = 0) then\n x:=x-1;\n if (j mod 7 = 2) or (j mod 7 = 6) then\n y:=y-1;\n if (j mod 7 = 3) or (j mod 7 = 5) then\n z:=z-1;\n j:=j+1;\n end;\n if k < j-1-i then\n k:=j - 1- i;\n end;\n writeln(s+k); \n\nend."}], "negative_code": [{"source_code": "var x,y,z,a,b,c,s,k,i,j:int64;\nbegin\n read(a,b,c);\n x:=a div 3;\n y:=b div 2;\n z:= c div 2;\n s:=0;\n s:=7*min(min(x,y),z);\n a:=a - 3 * min(min(x,y),z);\n b:=b - 2*min(min(x,y),z);\n c:=c-2*min(min(x,y),z);\n k:=0;\n for i:=1 to 7 do\n begin\n j:=i;\n x:=a;\n y:=b;\n z:=c;\n while (x > -1) and (y > -1) and (z > -1) do\n begin\n if (j mod 7 = 1) or (j mod 7 = 4) or (j mod 7 = 0) then\n x:=x-1;\n if (j mod 7 = 2) or (j mod 7 = 6) then\n y:=y-1;\n if (j mod 7 = 3) or (j mod 7 = 5) then\n z:=z-1;\n j:=j+1;\n end;\n if k < j-1-i then\n k:=j - 1 + i;\n end;\n writeln(s+k); \n\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c:int64;\n r1,r2:int64;\n q:array[1..7] of longint=(1,2,3,1,3,2,1);\n count:array[1..3] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,a,b,c);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(x:int64):boolean;\n begin\n if (x*3<=a) and (x*2<=b) and (x*2<=c) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction eat(u:longint):boolean;\n begin\n if (u=1) and (a=0) then exit(false);\n if (u=2) and (b=0) then exit(false);\n if (u=3) and (c=0) then exit(false);\n if u=1 then dec(a);\n if u=2 then dec(b);\n if u=3 then dec(c);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p1;\n begin\n if not eat(1) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p2;\n begin\n if not eat(1) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ok(l,r:longint):boolean;\n var i:longint;\n begin\n for i:=1 to 3 do count[i]:=0;\n for i:=l to r do inc(count[q[i]]);\n if (count[1]<=a) and (count[2]<=b) and (count[3]<=c) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction spec:longint;\n var i,j,res:longint;\n begin\n res:=0;\n for i:=1 to 7 do\n for j:=i to 7 do if ok(i,j) then res:=max(res,j-i+1);\n exit(res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var l,r,mid,res1,res2,a1,b1,c1,res,res3:int64;\n begin\n l:=0;\n r:=1000000000;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n if check(mid) then\n begin\n res:=mid;\n l:=mid+1;\n end else r:=mid-1;\n end;\n a:=a-3*res;\n b:=b-2*res;\n c:=c-2*res;\n if res=0 then res3:=spec else res3:=0;\n a1:=a;\n b1:=b;\n c1:=c;\n p1;\n p2;\n res1:=r1+r2+res*7;\n r1:=0;\n r2:=0;;\n a:=a1;\n b:=b1;\n c:=c1;\n p2;\n p1;\n res2:=r1+r2+res*7;\n write(fo,max(res1,max(res2,res3)));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c:int64;\n r1,r2:int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,a,b,c);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(x:int64):boolean;\n begin\n if (x*3<=a) and (x*2<=b) and (x*2<=c) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction eat(u:longint):boolean;\n begin\n if (u=1) and (a=0) then exit(false);\n if (u=2) and (b=0) then exit(false);\n if (u=3) and (c=0) then exit(false);\n if u=1 then dec(a);\n if u=2 then dec(b);\n if u=3 then dec(c);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p1;\n begin\n if not eat(1) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p2;\n begin\n if not eat(1) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var l,r,mid,res1,res2,a1,b1,c1,res:int64;\n begin\n l:=0;\n r:=1000000000;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n if check(mid) then\n begin\n res:=mid;\n l:=mid+1;\n end else r:=mid-1;\n end;\n a:=a-3*res;\n b:=b-2*res;\n c:=c-2*res;\n a1:=a;\n b1:=b;\n c1:=c;\n p1;\n p2;\n res1:=r1+r2+res*7;\n r1:=0;\n r2:=0;;\n a:=a1;\n b:=b1;\n c:=c1;\n p2;\n p1;\n res2:=r1+r2+res*7;\n write(fo,max(res1,res2));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a,b,c:longint;\n r1,r2:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,a,b,c);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction check(x:longint):boolean;\n begin\n if (x*3<=a) and (x*2<=b) and (x*2<=c) then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction eat(u:longint):boolean;\n begin\n if (u=1) and (a=0) then exit(false);\n if (u=2) and (b=0) then exit(false);\n if (u=3) and (c=0) then exit(false);\n if u=1 then dec(a);\n if u=2 then dec(b);\n if u=3 then dec(c);\n exit(true);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p1;\n begin\n if not eat(1) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n if not eat(3) then exit;inc(r1);\n if not eat(2) then exit;inc(r1);\n if not eat(1) then exit;inc(r1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure p2;\n begin\n if not eat(1) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n if not eat(3) then exit;inc(r2);\n if not eat(2) then exit;inc(r2);\n if not eat(1) then exit;inc(r2);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var l,r,mid,res1,res2,a1,b1,c1,res:longint;\n begin\n l:=0;\n r:=100000000;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n if check(mid) then\n begin\n res:=mid;\n l:=mid+1;\n end else r:=mid-1;\n end;\n a:=a-3*res;\n b:=b-2*res;\n c:=c-2*res;\n a1:=a;\n b1:=b;\n c1:=c;\n p1;\n p2;\n res1:=r1+r2+res*7;\n r1:=0;\n r2:=0;;\n a:=a1;\n b:=b1;\n c:=c1;\n p2;\n p1;\n res2:=r1+r2+res*7;\n write(fo,max(res1,res2));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "const fi='';\nvar f:text;\ni,j:longint;\na,b,c,a1,b1,c1,n,k,m,s,d,t:int64;\nbegin\n assign(f,fi);\n reset(f);\n read(f,a,b,c);\n close(f);\n\n a1:=a div 3;\n b1:=b div 2;\n c1:=c div 2;\n\n s:=100000000;\n\n if s>a1 then s:=a1;\n if s>b1 then s:=b1;\n if s>c1 then s:=c1;\n\n s:=7*s;\n k:=0;\n\n for i:=1 to 7 do\n begin\n a1:=a-3*(s div 7);\n b1:=b-2*(s div 7);\n c1:=c-2*(s div 7);\n for j:=i to 6+i do\n begin\n t:=0;\n if (j mod 7=1) or (j mod 7=2) or (j mod 7=5) then\n if a1>0 then\n begin\n dec(a1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=3) or (j mod 7=0) then\n if b1>0 then\n begin\n dec(b1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=4) or (j mod 7=6) then\n if c1>0 then\n begin\n dec(c1);\n inc(d);\n t:=1;\n end;\n if t=0 then break;\n end;\n if ka1 then s:=a1;\n if s>b1 then s:=b1;\n if s>c1 then s:=c1;\n\n s:=7*s;\n k:=0;\n\n for i:=1 to 7 do\n begin\n a1:=a-3*(s div 7);\n b1:=b-2*(s div 7);\n c1:=c-2*(s div 7);\n for j:=i to 6+i do\n begin\n t:=0;\n if (j mod 7=1) or (j mod 7=2) or (j mod 7=5) then\n if a1>0 then\n begin\n dec(a1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=3) or (j mod 7=0) then\n if b1>0 then\n begin\n dec(b1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=4) or (j mod 7=6) then\n if c1>0 then\n begin\n dec(c1);\n inc(d);\n t:=1;\n end;\n if t=0 then break;\n end;\n if ka1 then s:=a1;\n if s>b1 then s:=b1;\n if s>c1 then s:=c1;\n\n s:=7*s;\n k:=0;\n\n for i:=1 to 7 do\n begin\n a1:=a-3*(s div 7);\n b1:=b-2*(s div 7);\n c1:=c-2*(s div 7);\n for j:=i to 6+i do\n begin\n t:=0;\n if (j mod 7=1) or (j mod 7=2) or (j mod 7=5) then\n if a1>0 then\n begin\n dec(a1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=3) or (j mod 7=0) then\n if b1>0 then\n begin\n dec(b1);\n inc(d);\n t:=1;\n end;\n if (j mod 7=4) or (j mod 7=6) then\n if c1>0 then\n begin\n dec(c1);\n inc(d);\n t:=1;\n end;\n if t=0 then break;\n end;\n if kmax then max:=c[i];\n writeln(max);\nend."}, {"source_code": "var\n n: integer;\n\nbegin\n read(n);\n write(floor((n + 1) / 2) * ceil((n + 1) / 2));\nend."}, {"source_code": "var s,d,f:string;i,a:longint;z:array[0..200]of int64;\n\nbegin\nread(a);\n z[1]:=1;\n z[2]:=2;\n for i:=3 to a do z[i]:=i+z[i-2];\n write(z[a]);\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var j1,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n sot,ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ch:char):boolean;\nbegin\n if (ord(ch)>20)and(ord(ch)<220) then good:=true else good:=false;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(nn);\n inc(nn);\n writeln((nn div 2)*(nn-nn div 2));\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var n,y,i,j,k,kol,x:longint;\n d:array[1..10000] of longint;\nbegin\nreadln(n);\nd[1]:=1;\n\nd[2]:=2;\nx:=1;\n\nfor i:=3 to n do\nbegin\n if i mod 2=1\n then inc(x);\n d[i]:=d[i-1]+x;\nend;\nwriteln(d[n]);\nend."}, {"source_code": "var i,j,n,top,bot,res,v:longint;\n kt,l,r:array[0..10009] of longint;\n\nbegin\nreadln(n);\nfor i:=0 to n-1 do\n for j:=i+1 to n do\n begin\n inc(top);\n l[top]:=i;\n r[top]:=j;\n end;\nrepeat\n v:=0;\n inc(res);\n for j:=1 to top do\n if (l[j]>=v) and (kt[j]=0) then\n begin\n v:=r[j];\n kt[j]:=1;\n inc(bot);\n end;\nuntil top=bot;\nwriteln(res);\nend.\n\n"}, {"source_code": "var n:longint;\nbegin\n readln(n);\n write(trunc(sqr((n+1)/2)):5);\nend."}, {"source_code": "var a,b,c:longint;\n x:array[0..10000]of longint;\n begin\n x[0]:=0;\n x[1]:=1;\n x[2]:=2;\n x[3]:=4;\n x[4]:=6;\n readln(a);\n if a<=4 then\n writeln(x[a])\n else\n begin\n if a<=100 then\n begin\n for b:=5 to 100 do\n x[b]:=2*x[b-1]-2*x[b-3]+x[b-4];\n writeln(x[a]);\n end\n else\n writeln('0');\n end;\nend.\n\n\n"}, {"source_code": "var\n n,i:longint;\n a:array[0..101] of longint;\nbegin\n readln(n);\n a[1]:=1;a[2]:=2;a[3]:=4;a[4]:=6;\n for i:=5 to n do a[i]:=a[i-1]*2-a[i-3]*2+a[i-4];\n writeln(a[n]);\nend."}, {"source_code": "var\n a:array[0..105] of longint;\n i,j,l,k,m,n:longint;\n \nbegin\n readln(n);\n a[0]:=0;\n a[1]:=1;\n a[2]:=2;\n a[3]:=4;\n a[4]:=6;\n for i:=5 to n do\n a[i]:=2*a[i-1]-2*a[i-3]+a[i-4];\n write(a[n]);\nend."}, {"source_code": "var n:longint;\nbegin\n readln(n);\n write(trunc(sqr((n+1)/2)));\nend."}, {"source_code": "var \n n:longint;\nbegin\n read(n);\n write(trunc(sqr((n+1)/2)));\nend."}, {"source_code": "var n:longint;\nbegin\n read(N);\n write((n div 2+1)*(n div 2 + n mod 2));\nend."}, {"source_code": "var c,min:real;\na:array[0..1000000] of real;\ni:longint;\nk,n,z:int64;\nbegin\nread(n);\nif n=1 then z:=1 else\nif n=2 then z:=2 else\nif z=3 then z:=4 else\n begin\n z:=4;\n k:=2;\n for i:=4 to n do\n begin\n if i mod 2=1 then k:=k+1;\n z:=z+k;\n end;\n end;\nwrite(z);\nend.\n"}, {"source_code": "var a,s,d,f,g,h,k: integer;\nbegin\n read (a);\n if a=1 then begin\n write (1);\n halt;\n end;\n s:=2;\n k:=2;\n d:=2;\n while s<>a do\n begin\n if f=2 then begin k:=k+1; f:=0; end;\n d:=d+k;\n s:=s+1;\n f:=f+1;\n end;\n write (d);\nend."}, {"source_code": "var\n n,i:longint;\n a:array[0..105] of int64;\nbegin\n read(n);\n a[1]:=1;\n a[2]:=2;\n a[3]:=4;\n a[4]:=6;\n for i:=5 to n do a[i]:=2*a[i-1]-2*a[i-3]+a[i-4];\n writeln(a[n]);\nend."}, {"source_code": "var\n n,i:longint;\n a:array[0..105] of longint;\nbegin\n read(n);\n a[0]:=0;\n a[1]:=1;\n a[2]:=2;\n a[3]:=4;\n a[4]:=6;\n for i:=5 to n do\n a[i]:=2*a[i-1]-2*a[i-3]+a[i-4];\n writeln(a[n]);\nend."}, {"source_code": "uses math;\nvar\n n,i,ans : longint;\n a : array[0..101] of longint;\nbegin\n readln(n);\n for i:=1 to n do a[i]:=n-i+1;\n ans:=0;\n for i:=1 to n do ans:=ans+min(a[i],i);\n writeln(ans);\nend."}, {"source_code": "program zzz;\nvar\n n,res:longint;\n resr:real;\nbegin\n readln(n);\n resr:=((n/2)+1)*(n/2);\n if resr-trunc(resr) <>0 then res:=trunc(resr) +1\n else res:=trunc(resr);\n write(res);\nend."}, {"source_code": "var n:longint;\nbegin\n read(N);\n write((n div 2+1)*(n div 2 + n mod 2));\nend."}], "negative_code": [{"source_code": "program zzz;\nvar\n n,res:longint;\nbegin\n readln(n);\n res:=n+abs(n-2);\n writeln(res);\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n n:=n div 2+n mod 2;\n write(n*(n+1));\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n n:=n div 2;\n write((n+1)*n);\nend."}, {"source_code": "var\n a:array[1..100] of int64;\n i,n:longint;\nbegin\n a[1]:=0;a[2]:=1;a[3]:=2;a[4]:=3;a[5]:=4;a[6]:=6;\n for i:=6 to n do a[i]:=2*a[i-1]-2*a[i-3]+a[i-4];\n writeln(a[n]);\nend."}, {"source_code": "var n,i,s,sum,t,u:longint;\nf:array [0..100000] of longint;\nbegin\n//.assign(input,'xf.in');reset(input);\n//assign(output,'xf.out');rewrite(output);\nreadln(n);\nif n=1 then writeln(1)\nelse\n begin\n for i:=2 to n do sum:=sum+2;\n writeln(sum);\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var n:longint;\nbegin\n//assign(input,'xf.in');reset(input);\n//assign(output,'xf.out');rewrite(output);\nreadln(n);\nif n mod 2=0 then writeln(2+(n div 2-1)*4)\nelse writeln(1+(n div 2)*3);\nclose(input);close(output);\nend."}, {"source_code": "var n,o,i,p:longint;\nbegin\n//assign(input,'xf.in');reset(input);\n//assign(output,'xf.out');rewrite(output);\nread(n);\nif n mod 2=1 then\n begin\n if(n=1)then write(1)\n else if n=3 then write(4)\n else\n begin\n o:=7;p:=5;\n for i:=1 to n div 2-2 do\n begin\n o:=o+p;\n p:=p+2;\n end;\n writeln(o);\n end;\n end\nelse\n begin\n if n=2 then write(2)\n else if n=4 then write(6)\n else if n=6 then write(10)\n else\n begin\n o:=10;p:=5;\n for i:=1 to n div 2-3 do\n begin\n o:=o+p;\n p:=p+2;\n end;\n writeln(o);\n end;\n end;\nclose(input);close(output);\nend.\n"}, {"source_code": "var a,b,c:longint;\n x:array[0..10000]of longint;\n begin\n x[0]:=0;\n x[1]:=1;\n x[2]:=2;\n x[3]:=4;\n x[4]:=6;\n readln(a);\n if a<=4 then\n writeln(x[a])\n else\n begin\n x[a]:=2*x[a-1]-2*x[a-3]+x[a-4];\n writeln(x[a]);\n end;\nend.\n\n"}, {"source_code": "var n,y,i,j,k,kol,x:longint;\n d:array[1..10000] of longint;\nbegin\nreadln(n);\nd[2]:=2;\nx:=1;\n\nfor i:=3 to n do\nbegin\n if i mod 2=1\n then inc(x);\n d[i]:=d[i-1]+x;\nend;\nwriteln(d[n]);\nend.\n\n"}, {"source_code": "var n,y,i,j,k,kol,x:longint;\n d:array[1..10000] of longint;\nbegin\nreadln(n);\nd[2]:=2;\nx:=1;\ny:=1;\nfor i:=3 to n do\nbegin\n x:=x+2;\n inc(kol);\n d[i]:=x+y;\n if kol=2\n then begin\n kol:=0;\n inc(y);\n end;\nend;\nwriteln(d[n]);\nend.\n\n"}, {"source_code": "var n,k,s:longint;\nbegin\nreadln(n);\ns:=(n*(n+1)) div 2;\ns:=s div 2;\ns:=s+1;\nwriteln(s);\nend."}, {"source_code": "var n,y,i,j,k,kol,x:longint;\n d:array[1..10000] of longint;\nbegin\nreadln(n);\nd[2]:=2;\nx:=1;\n\nfor i:=3 to n do\nbegin\n if i mod 2=1\n then inc(x);\n d[i]:=d[i-1]+x;\nend;\nwriteln(d[n]);\nend."}, {"source_code": "var\n a:array[0..100] of int64;\n i,n:longint;\nbegin\n a[0]:=0;a[1]:=1;a[2]:=2;a[3]:=3;a[4]:=4;a[5]:=6;\n for i:=6 to n do a[i]:=2*a[i-1]-2*a[i-3]+a[i-4];\n writeln(a[n]);\nend."}, {"source_code": "uses math;\nvar\n n,i,ans : longint;\n a : array[0..101] of longint;\nbegin\n readln(n);\n for i:=1 to n do a[i]:=n-i+1;\n //if n mod 2=0 then a[n div 2]:=a[n div 2]-(a[n div 2]+1) div 2;\n ans:=0;\n for i:=n downto n div 2+1 do\n begin\n dec(a[n-i],a[i]); inc(ans,a[i]);\n a[i]:=0;\n end;\n for i:=1 to n do ans:=ans+min(a[i],i);\n writeln(ans);\nend."}, {"source_code": "var\n n : longint;\nbegin\n readln(n);\n if n=1 then begin writeln(1); halt; end;\n n:=n*(n+1) div 2;\n if n mod 2=1 then inc(n);\n writeln(n div 2+1);\nend."}, {"source_code": "var\n n : longint;\nbegin\n readln(n);\n n:=n*(n+1) div 2;\n if n mod 2=1 then dec(n);\n writeln(n div 2+1);\nend."}, {"source_code": "var\n n : longint;\nbegin\n readln(n);\n writeln(n*2-2);\nend."}, {"source_code": "var\n n,i,ans : longint;\n a : array[0..101] of longint;\nbegin\n readln(n);\n for i:=1 to n do a[i]:=n-i+1;\n if n mod 2=0 then a[n div 2]:=a[n div 2]-(a[n div 2]+1) div 2;\n ans:=0;\n for i:=n downto n div 2+1 do\n begin\n dec(a[n-i],a[i]); inc(ans,a[i]);\n a[i]:=0;\n end;\n for i:=1 to n do ans:=ans+a[i];\n writeln(ans);\nend."}, {"source_code": "Program ILoveYou;\nVAR n:int64;\nBegin\nReadln(n);\nWriteln(2*(n - 1));\nReadln;\nEND."}], "src_uid": "f8af5dfcf841a7f105ac4c144eb51319"} {"source_code": "//vi khuan\n\nvar\n n, ans: longint;\n\nbegin\n readln(n);\n while n > 0 do\n begin\n ans:= ans + n mod 2;\n n:= n div 2;\n end;\n writeln(ans);\nend.", "positive_code": [{"source_code": "{$H+}\nvar k,n,a,b,c,x:longint;\n s,s1:string;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(n);\nwhile n<>0 do\n begin\n b:=n mod 2;\n str(b,s1);\n if s1='1' then inc(k);\n s:=s1+s;\n n:=n div 2;\n end;\nwriteln(k);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, i, s : integer;\nbegin\n readln(n);\n s:=0;\n while n>=1 do begin\n s:=s + n mod 2;\n n:=n div 2;\n end;\n writeln(s);\n readln;\nend.\n "}, {"source_code": "var\n a, x: integer;\n\nbegin\n read(x);\n while x > 1 do \n begin\n if x mod 2 = 0 then x := x div 2\n else begin x := x - 1; a := a + 1; end;\n \n end;\n a := a + 1;\n write(a);\nend."}, {"source_code": "var\n x,i : longint ;\n\nbegin\n readln (x) ;\n i := 1 ;\n while x <> 1 do\n begin\n if x mod 2 = 0 then\n x := x div 2\n else\n begin\n dec(x) ;\n inc(i) ;\n end;\n end;\n writeln (i) ;\nend."}, {"source_code": "var\n x,cnt:integer;\nbegin\n Read(x);\n cnt:=0;\n while x>0 do begin\n if x mod 2 = 1 then begin\n x:=x-1;\n inc(cnt);\n end;\n x:=x div 2;\n end;\n writeln(cnt);\nend."}, {"source_code": "var k,s,x:int64;\n\nbegin\n readln(x);\n k:=1;\n s:=1;\n while s<>x do\n begin\n s:=1;\n\n while s1) do\n begin\n if(n mod 2<>0) then inc(k);\n n:=n div 2;\n end;\n writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "\n\nvar\n ans, n, i: longint;\n f: array[0..30] of longint;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n readln(n);\n f[0] := 1;\n for i := 1 to 30 do f[i] := f[i - 1] shl 1;\n ans := 0;\n for i := 30 downto 0 do\n if n >= f[i] then\n begin\n dec(n, f[i]);\n inc(ans);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "var\n N,k:longint;\n\nbegin\n Read(N);\n while N > 0 do\n begin\n if N and 1 = 1 then Inc(k);\n N:=N shr 1;\n end;\n write(k);\nend.\n"}, {"source_code": "var\nn,ans:longint;\nbegin\nreadln(n);\nwhile (n>0) do begin\n if n mod 2 = 1 then begin\n inc(ans);\n dec(n)\n end\n else\n n:=n div 2;\nend;\nwriteln(ans);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n,k :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n exit;\n end;\n { if(s*2>n) then\n begin\n k:=(min(1+n-s,n));\n break;\n end; }\n s:=s*2;\n end;\n k:=1;\n while(n>1) do\n begin\n if(n mod 2<>0) then inc(k);\n n:=n div 2;\n end;\n writeln(k);\n readln;\n readln;\nend.\n"}, {"source_code": "var\n x:integer;\n t:integer;\n\nprocedure check;\nbegin\nif (x mod 2)=1 then\n begin\n inc(t);\n dec(x);\n end\nelse\n begin\n x:=x div 2;\n end;\nend;\n\nbegin\nreadln(x);\nt:=1;\nwhile x>1 do check;\nwriteln(t);\nreadln;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\n\nuses\n SysUtils,math;\n\nvar\n m,i,n,k,l,j,t:Integer;\n str,str1:string;\n a:array of Integer;\n bol:Boolean;\n\nbegin\n Readln(n);\n m:=1;\n k:=1;\n repeat\n if k*2-n>0 then\n begin\n n:=n-k;\n if n>0 then\n begin\n k:=1;\n inc (m)\n end;\n end\n else k:=k*2;\n\n until n=0;\n\n Writeln(m);\n\n\n Readln(n);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q0 do\n begin\n if odd(n) then begin inc(res); dec(n); end;\n n:=n div 2;\n end;\n writeln(res);\n\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nprocedure xuli;\n begin\n d:=1; \n while n>1 do\n begin\n if n mod 2=1 then begin inc(d); n:=n-1; end\n else\n if n mod 2=0 then begin n:=n div 2; end;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\n\nbegin\nnhap;\nxuli;\nend.\n"}, {"source_code": "Program Bakteriy;\nVar x,k,i:longint;\nBegin\nreadln(x);\nk:=0;\nwhile x>0 do\n begin\n k:=k+x mod 2;\n x:=x div 2;\n end;\nwriteln(k);\nreadln;\nEnd."}, {"source_code": "Var x,k:integer;\nBegin \n Read(x);\n Repeat Inc(k,x mod 2);\n x:=x div 2;\n Until x=0;\nWrite(k);\nEnd."}, {"source_code": "var n,k,m,i,k1:longint;\n mas:array[1..30] of longint;\n\nbegin\n readln(n);k:=1;m:=1;\n m:=1;k:=1; i:=2;\n while k1<>5 do\n begin\n m:=m*2;\n if m>n then begin m:=m div 2;\n n:=n-m;\n m:=1;\n if n<>0 then k:=k+1;\n end;\n if (n=0)or(n=1) then k1:=5;\n end;\n write(k);\n\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=5000007;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,s1,s2,a,b,res:longint;\n begin\n res:=0;\n read(fi,n);\n while n>0 do\n begin\n res:=res+n mod 2;\n n:=n div 2;\n end;\n writeln(fo,res);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j,k,res,ma:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var a:Extended;\nl:Longint;\nbegin\nl:=0;\nreadln(a);\n while a>0 do begin\n if round(a) mod 2 = 0 then a:=a/2\n else begin a:=a-1; l:=l+1; end;\n end;\n writeln(l);\nend."}, {"source_code": "var n,k:longint;\nbegin\n readln(n);\n k:=0;\n while n>1 do\n begin\n while n mod 2=0 do\n n:=n div 2;\n if (n mod 2=1) and (n>1)\n then begin dec(n); inc(k); end;\n end;\n writeln(k+1);\nend."}, {"source_code": "Program asd;\nvar x,n,k:integer;\nbegin\nx:=1073741824;\nreadln(n);\nrepeat \nif n>=x then begin k:=k+1; n:=n-x; end else x:=x div 2;\nuntil n=0;\nwriteln(k);\nend."}, {"source_code": "var\nn,i,k:longint;\nbegin\nk:=1;\nreadln(n);\nwhile n>1 do begin\nif n mod 2 <>0 then begin dec(n);inc(k);end;\nn:=n div 2;\nend;\nwrite(k);\nend."}, {"source_code": "var xx,n,res :int64;\n i:longint;\n x:array[0..64]of int64;\nbegin\n read(xx);\n x[0]:=1;\n for i:=1 to 60 do x[i]:=x[i-1]*2;\n while xx<>0 do\n begin\n for i:=1 to 63 do\n if x[i]>xx then\n begin\n inc(res);\n xx:=xx-x[i-1];\n break;\n end;\n end;\n write(res);\nend.\n"}, {"source_code": "uses math;\nvar\n mu, res, x: integer;\n\n\nbegin\n readln(x);\n \n while x <> 0 do\n begin\n if odd(x) then\n begin\n inc(res);\n dec(x);\n end;\n while (x mod 2 = 0) and (x <> 0) do x := x div 2;\n\n end;\n writeln(res);\nend."}, {"source_code": "var\n a, b, c: int64;\n \nbegin\n readln(a);\n b := 0;\n while a > 0 do begin\n if a mod 2 = 0 then a := a div 2\n else begin\n dec(a);\n inc(b);\n end;\n end;\n writeln(b);\nend."}, {"source_code": "var s,k,x:longint;\n\nbegin\n read(x);\n k:=1;\n s:=1;\n while s<>x do\n begin\n s:=1;\n while s1 then\nrepeat\nif x>=2 then\nw:=w+(x mod 2);\nx:=x div 2\nuntil x=1;\nWriteln(w)\nend."}, {"source_code": "var n,ans:longint;\n \nbegin\n readln(n);\n while n<>0 do begin\n inc(ans,n mod 2);\n n:=n div 2;\n end;\n write(ans);\nend."}, {"source_code": "//CF\n\nvar\n n, res: longint;\n\nbegin\n //assign(input, 'CF579A.iNP'); reset(input);\n //assign(output, 'CF579A.oUT'); rewrite(output);\n readln(n);\n while n > 0 do\n begin\n inc(res, n mod 2);\n n:= n div 2;\n end;\n writeln(res);\n //close(input); close(output);\nend.\n"}, {"source_code": "var n,k:integer;\nbegin\nread(n);\nwhile n>0 do\nbegin\nk:=k+(n mod 2);\nn:=n div 2;\nend;\nwrite(k);\nend."}, {"source_code": "var\n x,ans:integer;\nbegin\n readln(x);\n ans:=0;\n while x>0 do\n begin\n if x mod 2=1 then inc(ans);\n x:=x div 2;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n x,ans:int64;\nbegin\n readln(x);\n ans:=0;\n while x>0 do\n begin\n if x mod 2=1 then inc(ans);\n x:=x div 2;\n end;\n writeln(ans);\nend."}, {"source_code": "var\nk,n:longint;\nbegin\nassign(input,'');reset(input);\nassign(output,'');rewrite(output);\nreadln(n);\nk:=1;\nwhile n>1 do\n begin\n if n mod 2=0 then n:=n div 2\n else\n begin\n n:=n-1;\n k:=k+1;\n end;\n end;\nwriteln(k);\nclose(input);close(output);\nend."}, {"source_code": "program z1;\nvar x,ans:longint;\nbegin\nread(x);\nans:=1;\nwhile x<>1 do begin\nif x mod 2<>0 then begin dec(x);inc(ans);end;\nx:=x div 2;\nend;\nwrite(ans);\nend."}, {"source_code": "const\n fin='';\n fon='';\nvar\n d,i,n:longint;\nbegin\nassign(input,fin);\nreset(input);\nassign(output,fon);\nrewrite(output);\nread(n);\nwhile n<>0 do\n begin\n d:=d+n mod 2;\n n:=n div 2;\n end;\nwrite(d);\nend."}, {"source_code": "{$mode objfpc}\nprogram RB;\nvar n,i,d,g:int64;\nbegin\n readln(n);\n i:=1;\n while i*2<=n do i:=i*2;\n repeat\n g:=n div i;\n if g=1 then inc(d);\n n:=n mod i;\n i:=i div 2;\n until i=0;\n writeln(d);\nend.\n"}, {"source_code": "var a,b:longint;\nbegin\nreadln(a);\nwhile a <> 0 do \nbegin \nif a mod 2 = 1 then inc(b); a:= a div 2; end;\nwrite(b);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n n,res:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n);\n\n assign(f,fo);rewrite(f);\n while (n > 0) do\n begin\n if n mod 2 = 1 then inc(res);\n n:=n div 2;\n end;\n write(f,res);\n close(f);\nend.\n"}, {"source_code": "var a,k:int64;\nbegin\n readln (a);\n k:=0;\n while (a>0) do\n begin\n a:=a and (a-1);\n k:=k+1;\n end;\n writeln (k);\nend."}, {"source_code": "var\n a,o,i,j,h,g,l,n,k:longint;\nbegin\n readln(n);\n while(n>0)do\n begin\n if(n mod 2=1)then inc(o);\n n:=n div 2;\n end;\n writeln(o);\nend.\n"}, {"source_code": "var k, ch:longint;\nbegin\n readln(ch);\n K := 1;\n while (ch<>1) do begin\n if ch mod 2 = 1 then begin\n ch := ch div 2;\n k:= K+1 \n end else begin\n ch := ch div 2;\n end\nend;\nwrite(k);\nend."}, {"source_code": "Var x,k:Longint;\nBegin\n Readln(x);\n While x<>0 do begin\n k:=k + x mod 2;\n x:=x div 2;\n End;\n Writeln(k);\nEnd."}, {"source_code": "var n,ans:int64;\nbegin\nread(n); ans:=0;\nwhile n>0 do\nbegin\nif n mod 2<>0 then inc(ans);\nn:=n div 2;\nend;\nwrite(ans);\nend."}, {"source_code": "var\nn,s:longint;\nbegin\nreadln(n);\ns:=0;\nwhile n>0 do\n begin\n if n mod 2=1 then inc(s);\n n:=n div 2;\n end;\nwriteln(s);\nend."}, {"source_code": "var\n n,s:longint;\nbegin\n readln(n);\n while n>0 do\n begin\n if n mod 2=1 then inc(s);\n n:=n div 2;\n end;\n writeln(s);\nend."}, {"source_code": "var x, ans:integer;\n\nbegin\n readln(x);\n ans := 0;\n while x > 0 do\n begin\n ans := ans + x mod 2;\n x := x div 2;\n end;\n writeln (ans);\nend."}, {"source_code": "var\n\tn, b, x, y: int64;\n\ta: array of integer;\n\t\nbegin\n\t\n\treadln(n);\n\twhile (n > 0) do\n\tbegin\n\t\tif (n mod 2 <> 0) then\n\t\t\tx += 1;\n\t\tn := n div 2;\n\tend;\n\t\n\twriteln(x);\n\t\nend.\n"}, {"source_code": "var x, m : Integer;\nbegin\n Readln(x);\n While (x > 1) do If x mod 2 = 0 then x := x div 2\n else begin\n m := m + 1;\n x := x div 2;\n end;\n Writeln(m + 1);\nend."}, {"source_code": "var\ni,j,x:integer;\nbegin\nread(x);\nj:=0;\n while x>=1 do\n begin\n if x mod 2 <> 0 then\n j+=1;\n x:=x div 2;\n end;\nwrite(j);\nend."}, {"source_code": " {***ABDU***}\nvar x,i,n:int64; begin\nreadln(n);\nwhile n>0 do begin\nif n mod 2=1 then inc(i); n:=n div 2;end;\nwriteln(i);\nend."}, {"source_code": "program zzz;\nvar\n x: longint;\n kol: byte;\nbegin\n read(x); kol := 0;\n while x > 0 do\n begin\n if x mod 2 <> 0 then inc(kol);\n x := x div 2;\n end;\n write(kol);\nend.\n"}, {"source_code": "var x, y : longint;\nbegin\n readln(x);\n while x <> 0 do begin if x mod 2 = 1 then inc(y); x := x div 2; end;\n write(y);\nend."}, {"source_code": "var\n n,ans : longint;\nbegin\n readln(n);\n while (n > 0) do\n begin\n if (n mod 2 = 1) then\n inc(ans);\n n := n div 2;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n x,s,i:integer;\nbegin\n s:=0;\n readln(x);\n while x>0 do\n begin\n if x mod 2=1 then\n inc(s);\n x:=x div 2;\n end;\n writeln(s);\nend."}, {"source_code": "var x,res,i:longint;\nbegin\n readln(x);\n while x>0 do\n begin\n inc(res,x mod 2);\n x:=x shr 1;\n end;\n writeln(res);\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, s: integer;\nbegin\n readln(n);\n s:= 0;\n while n > 0 do\n begin\n if (odd(n)) then inc(s);\n n:= n div 2;\n end;\n writeln(s);\n readln;\n readln;\nend.\n"}, {"source_code": "var m,x:longint;\nbegin\n readln(x);\n while x<>0 do\n begin\n m:=m+x and 1;\n x:=x>>1;\n end;\n writeln(m)\nend."}, {"source_code": "program k;\nvar x,i,t:longint;\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(x);\ni:=0;\nwhile x<>0 do begin\nt:=1;\nwhile 2*t<=x do\nt:=t*2;\nx:=x-t;\ninc(i);\nend;\nwrite(i);\n{close(output); }\nend.\n"}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n modul=1000000007;\n label 1,2,3,4,11;\n type\n mas=array [-10000..1000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var kol,pold,px,py,ll,aa,bb,cc,n1,n2,dist,pos,dloch,x0,x1,sum,tt,pp,t,v1,v2,p3,p4,t4,t5,t6,t1,t2,t3,jj,xx,yy,ost,rr,p,q,h,n,kk,qq,ot,nn,p1,p2,y0,s1,s2,m,s,imax,smin,dl,besk1:int64;\n ii,start,k,shag,imin,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..1000] of char;\n poin:zap;\n vec:array[-100..1000] of zap;\n c1,c2:array[-1000..100000] of int64;\n xnew,x,y,z,och,newoch,fact,d, a1,bl,br,c,a,b:array[-2000000..2000000] of int64;\n ss,ss1,ss2,name1,name2 :string;\n newgr,gr:array[-100..2000] of boolean;\n slov:array[-1..1500,-1..500] of string;\n ssot:array[-100..10000] of char;\n ch: char;\n newzan, zan,marked:array[-1000..2000000] of boolean;\n sp,sss,maxpr:array[0..10000] of string;\n hh,ttt, l, pr,aanew,v0,s0,t0:extended;\n mmask:array[0..15,0..35000,0..15] of longint;\n { z,y,x:array[-1..300,-10..1000] of int64;\n } xxx,yyy:array[-1..1000] of double;\n tt1, xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\n\nbegin\n\n\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(pp); ot:=0;\n while pp>0 do\n begin\n ot:=ot+pp mod 2;\n pp:=pp div 2;\n\n end;\n writeln(ot);\n\n\n\n1: close(output);\n\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar x,k:longint;\na:int64;\nbegin\nread(x);\nk:=0;\nwhile x<>0 do begin\n a:=1;\n while a<=x do a:=a*2;\n\n x:=x-(a div 2);\n inc(k);\nend;\nwriteln(k);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, s: integer;\nbegin\n readln(n);\n s:= 0;\n while n > 0 do\n begin\n if (odd(n)) then inc(s);\n n:= n div 2;\n end;\n writeln(s);\n readln;\n readln;\nend.\n"}, {"source_code": "{CF579A}\nvar\nx,s:longint;\nbegin\nread(x);\ns:=0;\nrepeat\ninc(s,x mod 2);\nx:=x div 2;\nuntil x=0;\nwriteln(s);\nend."}, {"source_code": "var\n x,res:int64;\nbegin\n readln(x);\n repeat\n if x mod 2<>0 then inc(res);\n x:=x div 2;\n until x=0;\n writeln(res);\nend."}], "negative_code": [{"source_code": "var i,n:longint;\n begin\n read(n);\n i:=1;\n while i<=n do\n i:=i*2;\n i:=i div 2;\n write(n-i+1);\n end."}, {"source_code": "Program Bakteriy;\nFunction Step(a,b:integer):int64;\nvar i,p:longint;\nbegin\np:=1;\nfor i:=1 to b do\n p:=p*a;\nstep:=p;\nend;\nVar x,i,ans:longint;\nBegin\nreadln(x);\ni:=0;\nwhile x>=step(2,i) do\n i:=i+1;\ni:=i-1;\nans:=1+x-step(2,i);\nwriteln(ans);\nreadln;\nEnd."}, {"source_code": "var x,a:longint;\nBegin\nreadln(x);\na:=x mod 2;\nif a=0 then writeln('1')\nelse writeln('2');\nend."}, {"source_code": "var\n n:longint;\n\nprocedure enter;\nbegin\n readln(n);\nend;\n\nprocedure process;\nvar\n i,j:longint;\nbegin\n if n=1 then\n begin\n writeln(1);\n exit;\n end;\n j:=1;\n for i:=1 to 30 do\n begin\n j:=j*2;\n if j=n then\n begin\n writeln(1);\n exit;\n end;\n end;\n writeln(2);\nend;\n\nBegin\n enter;\n process;\nEnd."}, {"source_code": "var i,j,n,d:qword;\nbegin\nreadln(n);\ni:=1;d:=0;\nif n mod 2=0 then d:=1;\nif n mod 2<>0 then d:=(n mod 2)+1;\nwriteln(d);\nend."}, {"source_code": "const fi ='';\n fo ='';\nvar n,res :longint;\nprocedure nhap;\nbegin\n assign(input,fi);\n reset(input);\n readln(n);\n close(input);\nend;\nprocedure xuli;\nbegin\n repeat\n if odd(n) then inc(res);\n n:=n div 2;\n until n>0;\nend;\nprocedure xuat;\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(res);\n close(output);\nend;\nbegin\n nhap;\n xuli;\n xuat;\nend."}, {"source_code": "Program Problem_A;\nConst fi='';\n fo='';\n MaxN=1000000000;\nType ii= longint;\n li= int64;\nVar N: ii;\n Min: ii;\nProcedure Doc_Dl;\n Var f: text;\n Begin\n Assign(f,fi);\n Reset(f);\n Readln(f,N);\n Close(f);\n End;\nProcedure Xu_Ly;\n Var tg: li;\n Begin\n tg:=1;\n While (N>tg) do\n tg:=tg*2;\n If Abs(tg-N)0 do\n begin\n if a mod 2=0 then inc(b);\n a:=a div 2;\n end;\n writeln(b);\nend."}, {"source_code": "var k,s,x:int64;\n\nbegin\n readln(x);\n k:=1;\n s:=1;\n while sx then begin\n s:=s div 2;\n k:=k+(x-s);\n end;\n writeln(k);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n //k:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n break;\n end;\n if(s*2>n) then\n begin\n writeln(1+n-s);\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n d:=1;\n while kt(n)=false do\n begin\n if n mod 2=1 then begin inc(d); n:=n-1; end\n else\n if n mod 2=0 then begin inc(d); n:=n div 2; end;\n end;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\n\n begin\nnhap;\nxuli;\nend.\n"}, {"source_code": "const fin='';fon='';\nvar x:qword;\nbegin\nassign(input,fin);\nreset(input);\nassign(output,fon);\nrewrite(output);\nreadln(x);\nif x mod 2=0 then write('1')\nelse write('2');\nclose(input);close(output);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n break;\n end;\n if(s*2>n) then\n begin\n writeln(min(1+n-s,n));\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "var z,i:int64;\nm:string;\nbegin\nreadln(z);\nrepeat\nif z mod 2 = 0 then begin\nm:='0'+m;\nend\nelse M:='1'+m;\nz:=z div 2;\nuntil (z=1) or (z=0);\nM:='1'+m;\nz:=0;\nfor i:=1 to length(m) do begin\nif m[i]='1' then z:=z+1;\nend;\nwriteln(z);\nend."}, {"source_code": "var x,a,k:longint;\nBegin\nk:=1;\nreadln(x);\nwhile x>1 do\nBegin \nif x mod 2 =0 then Begin x:=x div 2 ; end else \nif x mod 2 =1 then Begin x:=x-1; k:=k+1;if x=2 then k:=k+1; end;\nend;\nwriteln(k);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n break;\n end;\n if(s*2>n) then\n begin\n writeln(1+n-s);\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "var i,n,d:qword;\nbegin\nreadln(n);\nd:=0;\nif n mod 2=0 then d:=1;\nif n mod 2<>0 then d:=(n mod 2)+1;\nwriteln(d);\nend."}, {"source_code": "var i,n,d:qword;\nbegin\nreadln(n);\nd:=0;\nif n mod 2=0 then d:=1;\nif n mod 2<>0 then d:=(n mod 2)+1;\nwriteln(d);\nend."}, {"source_code": "var n,m,i,j,k,ans,l,r:Longint;\n begin\n read(n);\n l:=0;\n ans:=0;\n while (n>1) do\n begin\n if (n mod 2=0) and (l<>2) then begin inc(ans); l:=2; end;\n if n mod 2=0 then n:=n div 2 else begin inc(ans); l:=1; n:=n-1; end;\n end;\n writeln(ans);\n end."}, {"source_code": "var i, ch,z,st_10,k:longint;\ns : string;\nbegin\n readln(ch);\n s:='';\n k:= 0;\n z:= 0;\n st_10:=1;\n while ch<>0 do\n begin\n z:=z+(ch mod 2)*st_10;\n ch:=ch div 2;\n st_10:=st_10*10;\n end;\n str(z,s);\n for i := 1 to Length(s) do\n if s[i] = '1' then k := 1 + k;\n write(k);\nend."}, {"source_code": "var k,s,x:int64;\n\nbegin\n readln(x);\n k:=1;\n s:=1;\n while sx then begin\n s:=s div 2;\n k:=k+(x-s);\n end;\n writeln(k);\nend."}, {"source_code": "var\nx,o,d,t,k:longint;\nbegin\nread(x);\no:=1;\nt:=1;\nd:=x;\nk:=0;\nwhile x-o*2>=0 do\no:=o*2;\nx:=x-o;\nif x=0\nthen\nwrite(t)\nelse\nbegin\nif d mod 2=0\nthen\nwhile d mod 2=0 do\nd:=d div 2\nelse\nbegin\nwhile d>0 do\nbegin\nif d mod 2=1\nthen\nbegin\nd:=d-1;\nk:=k+1;\nend;\nif d mod 2=0\nthen\nd:=d div 2;\nend;\nd:=d+k;\nend;\nif x+1>=d\nthen\nwrite(d)\nelse\nwrite(x+1);\nend;\nend.\n\n\n"}, {"source_code": "var i,j,n,d,s:qword;\nbegin\n{assign(input,'a.inp');reset(input);\nassign(output,'a.out');rewrite(output);}\nreadln(n);\ni:=1;d:=0;\ns:=1;\nwhile sn then\n begin\n s:=s div 2;\n d:=(n mod s)+1;\n end;\nwriteln(d);\n{close(input);close(output);}\nend."}, {"source_code": "{$mode objfpc}\nvar n,p:int64;\nbegin\n Readln(n);\n p:=1;\n while p*2n) then\n begin\n writeln(1+n-s);\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n n, i, s : integer;\nbegin\n readln(n);\n i:=1;\n while i*2<=n do\n i:=i*2;\n s:=1+(n mod i);\n writeln(s);\n readln;\nend.\n "}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n break;\n end;\n if(s*2>n) then\n begin\n writeln(min(1+n-s,n));\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nx:integer;\n\n begin\n readln(x);\n IF x mod 2=0 then writeln(1) else if (x mod 2<>0) and (x<>1) then writeln(2)\n else if x=1 then writeln(2);\nreadln;\nreadln;\nend.\n"}, {"source_code": "var i,n:longint;\n begin\n read(n);\n i:=1;\n while i<=n do\n i:=i*2;\n i:=i div 2;\n write(n-i+1);\n end."}, {"source_code": "{$mode objfpc}\nuses math;\nvar\n mu, res, x: integer;\n\n\nbegin\n readln(x);\n {\n while x div 2 <> 1 do\n begin\n if odd(x) then\n begin\n inc(res);\n dec(x);\n end\n else x := x div 2;\n end;\n writeln(res+1); }\n mu := 1;\n while power(2, mu) <= x do inc(mu);\n writeln(trunc(x - power(2, mu-1))+1);\nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n d:=1;\n while kt(n)=false do\n begin\n if n mod 2=1 then begin inc(d); n:=n-1; end\n else\n if n mod 2=0 then begin inc(d); n:=n div 2; end;\n end;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\n\n begin\nnhap;\nxuli;\nend.\n"}, {"source_code": "var n,m,i,j,k,ans,l,r:Longint;\n begin\n read(n);\n l:=0;\n ans:=0;\n while (n>1) do\n begin\n if (n mod 2=0) and (l<>2) then begin inc(ans); l:=2; end;\n if n mod 2=0 then n:=n div 2 else begin inc(ans); l:=1; n:=n-1; end;\n end;\n writeln(ans);\n end."}, {"source_code": "program bugteria;\nvar x,w:longint;\nbegin\nw:=1;\nreadln(x);\nrepeat\nif x>=2 then\nw:=w+ x mod 2;\nx:=x div 2\nuntil x>0;\nWriteln(w)\nend."}, {"source_code": "var n,d,t: longint;\nbegin\nassign(input,''); reset(input);\nassign(output,''); rewrite(output);\nreadln(n);\nd:=1;\nt:=1;\nwhile t< n do\n begin\n t:=t*2;\n end;\nif t > n then t:=t div 2;\ninc(d,n-t);\nwriteln(d);\nclose(input);\nclose(output);\nend.\n"}, {"source_code": "const fin='';fon='';\nvar x:qword;\nbegin\nassign(input,fin);\nreset(input);\nassign(output,fon);\nrewrite(output);\nreadln(x);\nif x mod 2=0 then write('1')\nelse write('2');\nclose(input);close(output);\nend."}, {"source_code": "{$mode objfpc}\nprogram RB;\nvar n:integer;\nbegin\n readln(n);\n if n mod 2=0 then write('1')\n else write(n div 2);\nend."}, {"source_code": "var N : longint;\nbegin\n readln(n);\n if n = 1 then writeln(1) else\n if n mod 2 =0 then writeln(1) else writeln(2);\nend.\n"}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n i:=1;\n d:=1;\n while i<=n div 2 do\n i:=i*2;\n d:=d+n-i;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend.\n"}, {"source_code": "const fin='';fon='';\nvar x:qword;\nbegin\nassign(input,fin);\nreset(input);\nassign(output,fon);\nrewrite(output);\nreadln(x);\nif x mod 2=0 then write('1')\nelse write('2');\nclose(input);close(output);\nend."}, {"source_code": "var\nx,o,d,t,k:longint;\nbegin\nread(x);\no:=1;\nt:=1;\nd:=x;\nk:=0;\nwhile x-o*2>=0 do\no:=o*2;\nx:=x-o;\nif x=0\nthen\nwrite(t)\nelse\nbegin\nif d mod 2=0\nthen\nwhile d mod 2=0 do\nd:=d div 2\nelse\nbegin\nwhile d>0 do\nbegin\nif d mod 2=1\nthen\nbegin\nd:=d-1;\nk:=k+1;\nend;\nif d mod 2=0\nthen\nd:=d div 2;\nend;\nd:=d+k;\nend;\nif x+1>=d\nthen\nwrite(d)\nelse\nwrite(x+1);\nend;\nend.\n\n\n"}, {"source_code": "var x,res,i:longint;\nbegin\n readln(x);\n i:=1;\n while i<=x do i:=i shl 1;\n res:=x-(i shr 1);\n writeln(res+1);\nend.\n\n"}, {"source_code": "{$mode objfpc}\nvar\n t,n,i:int64;\nbegin\n readln(n);\n t:=1;\n while t*2<=n do\n begin\n t:=t*2;\n inc(i);\n end;\n if t=n then\n writeln('1')\n else writeln(i-1+n-t);\nend.\n"}, {"source_code": "var n:longint;\ninp,outp:text;\nprocedure nhap;\nbegin\nassign(inp,'');\nassign(outp,'');\nreset(inp);\nrewrite(outp);\nread(inp,n);\nend;\n\nprocedure tim;\nvar i,a,b,dem:longint;\nbegin\ni:=1; a:=0; dem:=1;\nwhile i2 do\n begin\n inc(dem);\n b:= b shr 1;\n end;\n\n write(dem+1);\n end;\n\nend;\nbegin\nnhap;\ntim;\nclose(inp);close(outp);\nreadln\nend.\n\n\n"}, {"source_code": "var n,k,m:longint;\n\nbegin\n readln(n);k:=1;m:=1;\n while n<>m do\n begin\n if m*2>n then begin m:=m+1;k:=k+1 end\n else m:=m*2;\n end;\n write(k);\nend."}, {"source_code": "{$mode objfpc}\nprogram RB;\nvar n:integer;\nbegin\n readln(n);\n if n mod 2=0 then write('1')\n else write(n div 2);\nend."}, {"source_code": " {***ABDU***}\nvar r1,r2,r3,r,a1,a2,i,j,n,m,a3,b3,suma,sumb,c:int64; a,b:array [1..10000] of int64; begin\nread(n);\nif n mod 2=0 then writeln(1)\nelse begin\nwriteln(int(sqrt(n)));\nend;\nend."}, {"source_code": "var n,k,m,i,k1:longint;\n mas:array[1..30] of longint;\n\nbegin\n readln(n);k:=1;m:=1;\n for i:=1 to 30 do\n begin\n mas[i]:=m;\n m:=m*2;\n end;m:=1;k:=1; i:=1;\n while k1<>5 do\n begin\n if mas[i]=n then begin k1:=5;m:=mas[i]; end;\n if mas[i]>n then begin m:=mas[i-1];k1:=5 end;\n i:=i+1;\n end;\n if n-m<>0 then begin\n if (n-m)mod 2=0 then k:=k+1\n else begin\n if n-m=1 then k:=k+1\n else k:=k+n-m-1;\n end;\n end;\n write(k);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..10] of integer;\n i,s,n :integer;\nbegin\n readln(n);\n if(n mod 2=0) or (n=1) then writeln(1) else\n writeln(2);\n readln;\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\nx:integer;\n\n begin\n readln(x);\n IF x mod 2=0 then writeln(1) else if (x mod 2<>0) and (x<>1) then writeln(2)\n else if x=1 then writeln(2);\nreadln;\nreadln;\nend.\n"}, {"source_code": "var i,j,n,d:qword;\nbegin\nreadln(n);\ni:=1;d:=0;\nif n mod 2=0 then d:=1;\nif n mod 2<>0 then d:=(n mod 2)+1;\nwriteln(d);\nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n d:=1;\n while kt(n)=false do\n begin\n if n mod 2=1 then begin inc(d); n:=n-1; end\n else\n if n mod 2=0 then begin inc(d); n:=n div 2; end;\n end;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\n\n begin\nnhap;\nxuli;\nend.\n"}, {"source_code": "var n,i,dem :int64;\nBEGIN\n read(n); i:=1; dem:=0;\n if (n=1) or (n=2) or (n=4) or (n mod 8=0) then dem:=1 else\n while i<= n do\n begin\n i:=i*2+1;\n inc(dem);\n end;\n write(dem);\nEND."}, {"source_code": "var\nx,o,d,t,k:longint;\nbegin\nread(x);\no:=1;\nt:=1;\nd:=x;\nk:=0;\nwhile x-o*2>=0 do\no:=o*2;\nx:=x-o;\nif x=0\nthen\nwrite(t)\nelse\nbegin\nif d mod 2=0\nthen\nwhile d mod 2=0 do\nd:=d div 2\nelse\nbegin\nwhile d>0 do\nbegin\nif d mod 2=1\nthen\nbegin\nd:=d-1;\nk:=k+1;\nend;\nif d mod 2=0\nthen\nd:=d div 2;\nend;\nd:=d+k;\nend;\nif x+1>=d\nthen\nwrite(d)\nelse\nwrite(x+1);\nend;\nend.\n\n\n"}, {"source_code": "var a,s,k,i,min,imin:longint;\nbegin\nreadln(a);\ns:=1;\nfor i:=1 to round(sqrt(a)) do\nbegin\ns:=i;\nwhile true do\nbegin\nif s*2>a then begin k:=a-s; break; end\nelse\ns:=s*2;\nend;\nif (i=1) or (k < min) then begin min:=k; imin:=i; end;\nend;\nwriteln(min+imin);\nend."}, {"source_code": "var s,k,x:longint;\n\nbegin\n read(x);\n k:=1;\n s:=1;\n while s<=x do\n s:=s*2;\n\n if s<>x then begin\n s:=s div 2;\n k:=(x-s)+k;\n end;\n write(k);\nend.\n"}, {"source_code": "program z1;\nvar x,d:longint;\nbegin\nread (x);\nd:=1;\nwhile (x>d) do\n d:=d*2;\nif (d>x) then d:=d div 2;\nif (x=d) then writeln (1)\nelse\n writeln (1+x-d);\nend.\n"}, {"source_code": "const fin='';fon='';\nvar x:qword;\nbegin\nassign(input,fin);\nreset(input);\nassign(output,fon);\nrewrite(output);\nreadln(x);\nif x mod 2=0 then write('1')\nelse write('2');\nclose(input);close(output);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,Math;\n\nvar\n a,b:array[1..10] of integer;\n s,n :int64;\n i:integer;\nbegin\n readln(n);\n s:=1;\n for i:=1 to 33 do\n begin\n if(s=n) then\n begin\n writeln(1);\n break;\n end;\n if(s*2>n) then\n begin\n writeln(1+n-s);\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n:integer;\n\nbegin\n readln(n);\n if (n mod 2 = 0 ) then writeln(1) else writeln(2);\n\nend.\n "}, {"source_code": "var N : longint;\nbegin\n readln(n);\n if n mod 2 =0 then writeln(1) else writeln(2);\nend.\n"}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..10] of integer;\n i,s,n :integer;\nbegin\n readln(n);\n if(n mod 2=0) then writeln(1) else\n writeln(2);\n readln;\n readln;\nend.\n"}, {"source_code": "var n,k,m:longint;\n\nbegin\n readln(n);k:=1;m:=1;\n while n<>m do\n begin\n if m*2>n then begin m:=m+1;k:=k+1 end\n else m:=m*2;\n end;\n write(k);\nend."}, {"source_code": "var x,a,k:longint;\nBegin\nk:=1;\nreadln(x);\nwhile x>1 do\nBegin \nif x mod 2 =0 then Begin x:=x div 2 ; end else \nif x mod 2 =1 then Begin x:=x-1; k:=k+1;if x=2 then k:=k+1; end;\nend;\nwriteln(k);\nend."}, {"source_code": "var n,k,m,i,k1:longint;\n mas:array[1..30] of longint;\n\nbegin\n readln(n);k:=1;m:=1;\n for i:=1 to 30 do\n begin\n mas[i]:=m;\n m:=m*2;\n end;m:=1;k:=1; i:=1;\n while k1<>5 do\n begin\n if mas[i]=n then begin k1:=5;m:=mas[i]; end;\n if mas[i]>n then begin m:=mas[i-1];k1:=5 end;\n i:=i+1;\n end;\n if n-m<>0 then begin\n if (n-m)mod 2=0 then k:=k+1\n else begin\n if n-m=1 then k:=k+1\n else k:=k+n-m;\n end;\n end;\n write(k);\nend."}, {"source_code": "var\ni,j,x:integer;\nbegin\nread(x);\ni:=0;\n while x>=1 do\n begin\n if x mod 2 <> 0 then\n j+=1;\n x:=x div 2;\n end;\nwrite(x);\nend."}, {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if odd(n) then writeln('0')\n else writeln('1');\nend."}, {"source_code": "var x,i:int64;\nbegin\n readln(x); i:=1;\n if i = x then begin write('0'); exit; end;\n while i < x do\n i:=i * 2;\n if i = x then begin write('1'); exit; end;\n write('2');\nend."}, {"source_code": "program battle4;\n\n{$APPTYPE CONSOLE}\n \nuses\n SysUtils;\nvar\nn,s,i:integer;\n\nbegin\nreadln(n);\ns:=1;\nfor i:=1 to n do begin\n s:=s*2;\n if s*2>n then break;\n end;\n s:=n-s+1;\n writeln(s);\nreadln;\nend.\n"}, {"source_code": "var ch,z,st_10,k:int64;\ni:integer;\ns : string;\nbegin\n readln(ch);\n s:='';\n k:= 0;\n z:= 0;\n st_10:=1;\n while ch<>0 do\n begin\n z:=z+(ch mod 2)*st_10;\n ch:=ch div 2;\n st_10:=st_10*10;\n end;\n str(z,s);\n for i := 1 to Length(s) do\n if s[i] = '1' then k := 1 + k;\n write(k);\nend."}, {"source_code": "const fi ='';\n fo ='';\nvar n,res :longint;\nprocedure nhap;\nbegin\n assign(input,fi);\n reset(input);\n readln(n);\n close(input);\nend;\nprocedure xuli;\nbegin\n repeat\n if odd(n) then inc(res);\n n:=n div 2;\n until n>0;\nend;\nprocedure xuat;\nbegin\n assign(output,fo);\n rewrite(output);\n writeln(res);\n close(output);\nend;\nbegin\n nhap;\n xuli;\n xuat;\nend."}, {"source_code": "var a,x:integer;\nbegin\nread(x);\nIf x mod 2 =0 Then a:=1\n Else a:=2;\nwrite(a);\nend.\n\n"}, {"source_code": "var i,n:longint;\n begin\n read(n);\n i:=1;\n while i<=n do\n i:=i*2;\n i:=i div 2;\n write(n-i+1);\n end."}, {"source_code": "var\n a,b:longint;\nbegin\n read(a);\n while a>0 do\n begin\n if a mod 2=0 then inc(b);\n a:=a div 2;\n end;\n writeln(b);\nend."}, {"source_code": "var n :int64;\nBEGIN\n read(n);\n if n mod 2=1 then write('2') else write('1');\nEND."}, {"source_code": "var n :int64;\nBEGIN\n read(n);\n if n mod 2=1 then write('2') else write('1');\nEND."}, {"source_code": "var n,i,dem :int64;\nBEGIN\n read(n); i:=1;dem:=0;\n if (n div 2) mod 2<>0 then\n while i<= n do\n begin\n i:=(i*2);\n if i<=n then\n Begin\n inc(i);\n inc(dem);\n End;\n end;\n if (n div 2) mod 2<>0 then write(dem+1);\n if (n div 2) mod 2=0 then write('1');\nEND."}, {"source_code": "var a:integer;\nbegin\nread(a);\nif (a mod 2=0)then a:=1 else a:=2;\nwrite(a);\nend."}, {"source_code": "program Ad;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b:array[1..10] of integer;\n i,s,n :integer;\nbegin\n readln(n);\n if(n mod 2=0) or (n=1) then writeln(1) else\n writeln(2);\n readln;\n readln;\nend.\n"}, {"source_code": "Program Problem_A;\nConst fi='';\n fo='';\n MaxN=1000000000;\nType ii= longint;\n li= int64;\nVar N: ii;\n Min: ii;\nProcedure Doc_Dl;\n Var f: text;\n Begin\n Assign(f,fi);\n Reset(f);\n Readln(f,N);\n Close(f);\n End;\nProcedure Xu_Ly;\n Var tg: li;\n Begin\n tg:=1;\n While (N>tg) do\n tg:=tg*2;\n If Abs(tg-N)n) then\n begin\n writeln(1+n-s);\n break;\n end;\n s:=s*2;\n end;\n readln;\n readln;\nend.\n"}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n i:=1;\n d:=1;\n while i<=n div 2 do\n i:=i*2;\n d:=d+n-i;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend.\n"}, {"source_code": "{$mode objfpc}\nvar n,p:int64;\nbegin\n Readln(n);\n p:=1;\n while p*20 do\n begin\n if t mod 2<>0 then inc(s);\n t:=kt(t);\n end;\n writeln(t+1);\n\nend."}, {"source_code": "var\nx:longint;\nbegin\nread(x);\nif (x mod 2=0) or (x=1)\nthen\nwrite('1')\nelse\nwrite('2');\nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n i:=1;\n d:=1;\n while i<=n div 2 do\n i:=i*2;\n d:=d+n-i;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\nbegin\nnhap;\nxuli;\nend.\n"}, {"source_code": "var z,i:int64;\nm:string;\nbegin\nreadln(z);\nrepeat\nif z mod 2 = 0 then begin\nm:='0'+m;\nend\nelse M:='1'+m;\nz:=z div 2;\nuntil (z=1) or (z=0);\nM:='1'+m;\nz:=0;\nfor i:=1 to length(m) do begin\nif m[i]='1' then z:=z+1;\nend;\nwriteln(z);\nend."}, {"source_code": "Program Problem_A;\nConst fi='';\n fo='';\n MaxN=1000000000;\nType ii= longint;\n li= int64;\nVar N: ii;\n Min: ii;\nProcedure Doc_Dl;\n Var f: text;\n Begin\n Assign(f,fi);\n Reset(f);\n Readln(f,N);\n Close(f);\n End;\nProcedure Xu_Ly;\n Var tg: li;\n Begin\n tg:=1;\n While (N>tg) do\n tg:=tg*2;\n If Abs(tg-N)n do\n begin\n while t mod 2=0 do t:=t div 2;\n if t=1 then dem:=1;\n n:= n div 2;\n\n if n mod 2=1 then begin dec(n); inc(dem2); end;\n end;\n if t=1 then write(dem) else write(dem2);\nEND.\n"}, {"source_code": "var x,a:longint;\nBegin\nreadln(x);\na:=x mod 2;\nif a=0 then writeln('1')\nelse writeln('2');\nend."}, {"source_code": "const\n fin='';fon='';\nvar\n n,i,d:int64;\nprocedure nhap;\n begin\n assign(input,fin);reset(input);\n assign(output,fon);rewrite(output);\n readln(n);\n end;\nfunction kt(x:longint):boolean;\n begin\n while (x mod 2)=0 do\n x:=x div 2;\n if x=1 then exit(true)\n else exit(false);\n end;\nprocedure xuli;\n begin\n if kt(n)=true then begin writeln(1); exit; end\n else\n begin\n d:=1;\n while kt(n)=false do\n begin\n if n mod 2=1 then begin inc(d); n:=n-1; end\n else\n if n mod 2=0 then begin inc(d); n:=n div 2; end;\n end;\n end;\n writeln(d);\n close(input);\n close(output);\n end;\n\n begin\nnhap;\nxuli;\nend.\n"}, {"source_code": "var i, ch,z,st_10,k:longint;\ns : string;\nbegin\n readln(ch);\n s:='';\n k:= 0;\n z:= 0;\n st_10:=1;\n while ch<>0 do\n begin\n z:=z+(ch mod 2)*st_10;\n ch:=ch div 2;\n st_10:=st_10*10;\n end;\n str(z,s);\n for i := 1 to Length(s) do\n if s[i] = '1' then k := 1 + k;\n write(k);\nend."}, {"source_code": "var n,k,m:longint;\n\nbegin\n readln(n);k:=1;m:=1;\n while n<>m do\n begin\n if m*2>n then begin m:=m+1;k:=k+1 end\n else m:=m*2;\n end;\n write(k);\nend."}, {"source_code": "var n,m:longint;\ninp,outp:text;\nprocedure nhap;\nbegin\nassign(inp,'');\nassign(outp,'');\nreset(inp);\nrewrite(outp);\nread(inp,n);\nend;\nfunction lam(n:longint):longint;\nvar i:longint;\nbegin\ni:=1;\nwhile i2 do\n begin\n inc(dem);\n lam(n);\n n:=n-m;\n end;\nwrite(dem+n);\nend;\nbegin\nnhap;\ntim;\nclose(inp);close(outp);\nend.\n\n\n"}, {"source_code": "program battle;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\nvar\nn:integer;\n\nbegin\nreadln(n);\nif n mod 2 = 0 then writeln(2) else writeln(1);\nreadln;\nend.\n"}, {"source_code": "var x,res,i:longint;\nbegin\n readln(x);\n i:=1;\n while i<=x do i:=i shl 1;\n res:=x-(i shr 1);\n writeln(res+1);\nend.\n\n"}, {"source_code": " {***ABDU***}\nvar r1,r2,r3,r,a1,a2,i,j,n,m,a3,b3,suma,sumb,c:int64; a,b:array [1..10000] of int64; begin\nread(n);\nif n mod 2=0 then writeln(1)\nelse begin\nwriteln(int(sqrt(n)));\nend;\nend."}, {"source_code": "uses math;\nfunction Bakt(n:longint):longint;\nvar i:longint;\n begin\n while n mod 2=0 do\n n:=n div 2;\n i:=1;\n while i<=n do\n i:=i*2;\n i:=i div 2;\n Bakt:=n-i+1;\n end;\nvar i,n:longint;\n b:boolean;\n begin\n read(n);\n if (n mod 2=1) and (n<>1) then b:=true;\n if b then\n write(min(Bakt(n),Bakt(n-1)+1))\n else\n write(Bakt(n));\n end.\n"}, {"source_code": "var x,a:longint;\nBegin\nreadln(x);\na:=x mod 2;\nif a=0 then writeln('1')\nelse writeln('2');\nend."}, {"source_code": "var n,i,dem,t,dem2 :int64;\nBEGIN\n read(n); i:=1; dem2:=0; t:=n;\n while 0<>n do\n begin\n while t mod 2=0 do t:=t div 2;\n if t=1 then dem:=1;\n n:= n div 2;\n\n if n mod 2=1 then begin dec(n); inc(dem2); end;\n end;\n if t=1 then write(dem) else write(dem2);\nEND.\n"}], "src_uid": "03e4482d53a059134676f431be4c16d2"} {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nvar a1,b1,a2,b2 ,p,q: int64;\n log1,log2 : array[2..3] of integer;\n need3,need2 : integer;\n m : int64;\nprocedure enter;\n begin\n readln(a1,b1);\n readln(a2,b2);\n end;\nfunction pt(x : int64 ; y : integer) : int64;\n begin\n result:=0;\n while x mod y = 0 do\n begin\n inc(result);\n x := x div y;\n end;\n end;\nfunction power( a , n : int64) : int64;\n var l : int64;\n begin\n if n = 0 then exit(1);\n l := power(a,n div 2);\n if odd(n) then exit(l*l*a) else exit(l*l);\n end;\nprocedure phantich;\n var i ,d : integer;\n begin\n log1[2]:=pt(a1,2)+pt(b1,2);\n log2[2]:=pt(a2,2)+pt(b2,2);\n log1[3]:=pt(a1,3)+pt(b1,3);\n log2[3]:=pt(a2,3)+pt(b2,3);\n p :=( a1*b1 div power(2,log1[2]) ) div (power(3,log1[3]));\n q :=( a2*b2 div power(2,log2[2]) ) div (power(3,log2[3]));\n if p <> q then\n begin\n Writeln(-1);\n halt;\n end;\n end;\n\nprocedure solve;\n begin\n phantich;\n if log2[3] > log1[3] then\n begin\n need3:=log2[3]-log1[3];\n inc(m,need3);\n log2[3]:=log1[3];\n inc(log2[2],need3);\n while (a2 mod 3 = 0) and (need3 > 0) do\n begin\n a2 := a2 div 3 * 2;\n dec(need3);\n end;\n while (b2 mod 3 = 0) and (need3 > 0) do\n begin\n b2 := b2 div 3 * 2;\n dec(need3);\n end;\n end else\n begin\n need3:=abs(log2[3]-log1[3]);\n inc(m,need3);\n log1[3]:=log2[3];\n inc(log1[2],need3);\n while (a1 mod 3 = 0) and (need3 > 0) do\n begin\n a1 := a1 div 3 * 2;\n dec(need3);\n end;\n while (b1 mod 3 = 0) and (need3 > 0) do\n begin\n b1 := b1 div 3 * 2;\n dec(need3);\n end;\n end;\n //------------------------------------------\n if log2[2] > log1[2] then\n begin\n need2 := abs(log2[2]-log1[2]) ;\n inc(m,need2);\n while (a2 mod 2 = 0) and (need2 > 0) do\n begin\n a2:=a2 div 2;\n dec(need2);\n end;\n while (b2 mod 2 = 0) and (need2 > 0) do\n begin\n b2 := b2 div 2 ;\n dec(need2);\n end;\n end else\n begin\n need2 := abs(log2[2]-log1[2]) ;\n inc(m,need2);\n while (a1 mod 2 = 0) and (need2 > 0) do\n begin\n a1:=a1 div 2;\n dec(need2);\n end;\n while (b1 mod 2 = 0) and (need2 > 0) do\n begin\n b1 := b1 div 2 ;\n dec(need2);\n end;\n end;\n end;\nbegin\n enter;\n solve;\n Writeln(m);\n // Writeln(log1[2],' ',log1[3]);\n //Writeln(log2[2],' ',log2[3]);\n\n Writeln(a1,' ',b1);\n Writeln(a2,' ',b2);\nend.", "positive_code": [{"source_code": "uses math;\ntype mass=array[1..4,0..41] of int64;\n majj=array[0..100000] of longint;\nvar n,res,i:longint;s1,s,s2:string;\n uk,e,l,r,ans,kol,q,x,j,y,rr,ans1,k,z, ab, bc, ac, abc : longint;\n u:boolean;\n a,b,c,d:int64;\n m:majj;\n m1,m2:mass;\nprocedure factor(a:int64;z:longint);\nvar i:longint;\nBegin\n i:=2;\n while a>1 do\n Begin\n if i*i>a\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=a;\n m2[z,m1[z,0]]:=1;\n exit;\n end;\n if (a mod i=0) and (m[i]=0)\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=i;\n while a mod i=0 do\n Begin\n a:=a div i;\n inc(m2[z,m1[z,0]]);\n end;\n end;\n inc(i);\n end;\nend;\nbegin\n// assign(input,'input.txt'); assign(output,'output.txt');\n readln(a,b);\n readln(c,d);\n m[1]:=1;\n for i:=2 to 100000 do\n if m[i]=0\n then Begin\n j:=i+i;\n while j<=100000 do\n Begin\n m[j]:=1;\n inc(j,i);\n end;\n end;\n factor(a,1);\n factor(b,2);\n factor(c,3);\n factor(d,4);\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=3 to 4 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if e=1\n then q:=2\n else q:=1;\n b:=m2[e,i];\n for z:=1 to m1[q,0] do\n if m1[q,z]=m1[e,i]\n then inc(b,m2[q,z]);\n if a<>b\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=1 to 2 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if e=3\n then q:=4\n else q:=3;\n b:=m2[e,i];\n for z:=1 to m1[q,0] do\n if m1[q,z]=m1[e,i]\n then inc(b,m2[q,z]);\n if a<>b\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n res:=0;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then Begin\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end\n else Begin\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m2[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m2[e,i]);\n end\n else\n else for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m2[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m2[e,i]);\n end;\n writeln(res);\n for i:=1 to 4 do\n Begin\n a:=1;\n for z:=1 to m1[i,0] do\n for j:=1 to m2[i,z] do\n a:=a*m1[i,z];\n write(a,' ');\n if i=2\n then writeln;\n end;\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar ot,nn,chel,znam,dl,len,ii,jj,i3,i2,i1,j1,k1,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish,m:longint;\np1,p2,n,yy1,xx1,xx2,q,xx,yy,t1,t2,p,t,aa,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nostminus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\nb,uvel,a,f,h,kop:array[0..2000000] of int64;\ngr,c,x,y: array[-10..500,0..500] of int64;\nver: array[-10..51,-10..100,-10..100] of extended;\nzan,bb,marked:array[-100000..250000] of boolean;\n{ss:array[0..2000000] of char; }\nss:string;\nch11,ch12,ch1,ch:char;\ndd: array[-10..100,-10..100,-10..100] of {int64}extended;\nkol,rr,sl,sr,stoim,str :array[-10 ..200000] of int64;\nssot:array[-1000..110000] of string;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction deg2(pp:int64):int64; var ot,i,j:longint;\n begin\n ot:=0;\n while pp mod 2=0 do begin pp:=pp div 2; inc(ot); end;\n deg2:=ot;\n end;\n\nfunction deg3(pp:int64):int64; var ot,i,j:longint;\n begin\n ot:=0;\n while pp mod 3=0 do begin pp:=pp div 3; inc(ot); end;\n deg3:=ot;\n end;\n\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=4; for i:=1 to n do read(a[i]);\n p1:=a[1]*a[2];\n p2:=a[3]*a[4];\n while p1 mod 2= 0 do p1:=p1 div 2;\n while p2 mod 2= 0 do p2:=p2 div 2;\n\n while p1 mod 3= 0 do p1:=p1 div 3;\n while p2 mod 3= 0 do p2:=p2 div 3;\n\n if p1<>p2 then begin writeln(-1); goto 1; end;\n ot:=0;\n while deg3(a[1]*a[2])>deg3(a[3]*a[4]) do\n begin\n if (deg3(a[1])>0)and(deg3(a[1]*a[2])>deg3(a[3]*a[4])) then\n begin a[1]:=(a[1] div 3)*2; inc(ot); end;\n\n if (deg3(a[2])>0)and(deg3(a[1]*a[2])>deg3(a[3]*a[4])) then\n begin a[2]:=(a[2] div 3)*2; inc(ot); end;\n\n end;\n\n while deg3(a[1]*a[2])0)and(deg3(a[1]*a[2])0)and(deg3(a[1]*a[2])deg2(a[3]*a[4]) do\n begin\n if (deg2(a[1])>0)and(deg2(a[1]*a[2])>deg2(a[3]*a[4])) then\n begin a[1]:=(a[1] div 2); inc(ot); end;\n\n if (deg2(a[2])>0)and(deg2(a[1]*a[2])>deg2(a[3]*a[4])) then\n begin a[2]:=(a[2] div 2); inc(ot); end;\n\n end;\n\n\n\n\n while deg2(a[1]*a[2])0)and(deg2(a[1]*a[2])0)and(deg2(a[1]*a[2])0 then\n begin\n p:=p+x-y;\n k:=x-y;\n while(k>0)and(n mod 3=0) do\n begin\n n:=(n div 3)*2;\n k:=k-1;\n end;\n while(k>0)and(m mod 3=0) do\n begin\n m:=(m div 3)*2;\n k:=k-1;\n end;\n end\n else\n begin\n q:=q+y-x;\n k:=y-x;\n while(k>0)and(w mod 3=0) do\n begin\n w:=(w div 3)*2;\n k:=k-1;\n end;\n while(k>0)and(h mod 3=0) do\n begin\n h:=(h div 3)*2;\n k:=k-1;\n end;\n end;\n t:=t+abs(p-q);\n writeln(t);\n if p-q>0 then\n begin\n for i:=q-1 downto p do\n n:=n*2;\n for i:=q+1 to p do\n if n mod 2=0 then n:=n div 2\n else m:=m div 2;\n end\n else\n begin\n for i:=p-1 downto q do\n w:=w*2;\n for i:=p+1 to q do\n if w mod 2=0 then w:=w div 2\n else h:=h div 2;\n end;\n writeln(n,' ',m);\n writeln(w,' ',h);\n end;\n\nprocedure cal(var a,b,p:longint;n:longint);\n var\n k:longint;\n begin\n k:=n;\n a:=0;\n b:=0;\n while k mod 2=0 do\n begin\n inc(a);\n k:=k div 2;\n end;\n while k mod 3=0 do\n begin\n inc(b);\n k:=k div 3;\n end;\n p:=k;\n end;\n\nbegin\n readln(n,m);\n readln(w,h);\n cal(x1,y1,u,n);\n cal(x2,y2,v,m);\n cal(x3,y3,r,w);\n cal(x4,y4,s,h);\n if v*u<>s*r then error;\n sol(x1+x2,x3+x4,y1+y2,y3+y4);\nend."}, {"source_code": "const fi = '';\n fo = '';\n\nvar f: text;\n d2,d3,c2,c3,res3x,res2x,res3y,res2y: longint;\n a1,a2,b1,b2: int64;\n check: boolean;\n\nprocedure readinp;\nbegin\n assign(f,fi);\n reset(F);\n read(f,a1,b1);\n read(f,a2,b2);\n close(f);\nend;\n\nfunction tinh(var a: int64; x: longint): longint;\nvar s: longint;\nbegin\n s:=0;\n while a mod x = 0 do\n begin\n a:=a div x;\n inc(s);\n end;\n tinh:=s;\nend;\n\nprocedure process;\nvar i: longint;\n x,y: int64;\nbegin\n x:=a1*b1;\n y:=a2*b2;\n d2:=tinh(x,2);\n c2:=tinh(y,2);\n d3:=tinh(x,3);\n c3:=tinh(y,3);\n check:=false;\n if x<>y then exit;\n if c30) and (x mod a=0) do\n begin\n x:=x div a;\n dec(b);\n if a=3 then x:=x*2;\n end;\n while (b>0) and (y mod a=0) do\n begin\n y:=y div a;\n dec(b);\n if a=3 then y:=y*2;\n end;\nend;\n\nprocedure writeout;\nbegin\n assign(f,fo);\n rewrite(f);\n if not check then writeln(f,-1)\n else\n begin\n timkq(a1,b1,3,res3x);\n timkq(a1,b1,2,res2x);\n timkq(a2,b2,3,res3y);\n timkq(a2,b2,2,res2y);\n writeln(f,res2x+res3x+res2y+res3y);\n writeln(f,a1,' ',b1);\n writeln(f,a2,' ',b2);\n end;\n close(f);\nend;\n\nBEGIN\n READINP;\n PROCESS;\n WRITEOUT;\nEND."}, {"source_code": "program chocolate;\n\nvar ans,dva,tri,a1,b1,a2,b2,s1,s2,ss1,ss2:int64;\nvar d1,t1,d2,t2:longint;\n\nbegin\n readln(a1,b1);\n readln(a2,b2);\n s1:=a1*b1;\n s2:=a2*b2;\n ss1:=s1;\n ss2:=s2;\n d1:=0;\n d2:=0;\n t1:=0;\n t2:=0;\n while ss1 mod 2=0 do begin\n ss1:=ss1 div 2;\n inc(d1);\n end;\n while ss1 mod 3=0 do begin\n ss1:=ss1 div 3;\n inc(t1);\n end;\n while ss2 mod 2=0 do begin\n ss2:=ss2 div 2;\n inc(d2);\n end;\n while ss2 mod 3=0 do begin\n ss2:=ss2 div 3;\n inc(t2);\n end;\n if ss1<>ss2 then writeln(-1) else begin\n ans:=0;\n while t1>t2 do begin\n if a1 mod 3=0 then a1:=2*a1 div 3 else b1:=2*b1 div 3;\n dec(t1);\n inc(d1);\n inc(ans);\n end;\n while t2>t1 do begin\n if a2 mod 3=0 then a2:=2*a2 div 3 else b2:=2*b2 div 3;\n dec(t2);\n inc(d2);\n inc(ans);\n end;\n while d1>d2 do begin\n if a1 mod 2=0 then a1:=a1 div 2 else b1:=b1 div 2;\n dec(d1);\n inc(ans);\n end;\n while d2>d1 do begin\n if a2 mod 2=0 then a2:=a2 div 2 else b2:=b2 div 2;\n dec(d2);\n inc(ans);\n end;\n writeln(ans);\n write(a1);\n write(' ');\n writeln(b1);\n write(a2);\n write(' ');\n writeln(b2);\n end;\nend.\n"}, {"source_code": "var\n i,j,z,ans:longint;\n a,b:array[1..4]of int64;\n d:array[1..4,2..3]of int64;\nbegin\n readln(a[1],a[2]);\n readln(a[3],a[4]);\n b:=a;\n for i:=1 to 4 do\n begin\n for j:=2 to 3 do\n begin\n while a[i] mod j=0 do\n begin\n a[i]:=a[i] div j;\n inc(d[i,j]);\n end;\n end;\n end;\n if a[1]*a[2]<>a[3]*a[4] then\n begin\n writeln(-1);halt;\n end;\n if d[1,3]+d[2,3]>d[3,3]+d[4,3] then\n begin\n while(d[1,3]+d[2,3]>d[3,3]+d[4,3])and(d[1,3]>0)do begin inc(ans);dec(d[1,3]);inc(d[1,2]);end;\n while(d[1,3]+d[2,3]>d[3,3]+d[4,3])and(d[2,3]>0)do begin inc(ans);dec(d[2,3]);inc(d[2,2]);end;\n end else\n begin\n while(d[1,3]+d[2,3]0)do begin inc(ans);dec(d[3,3]);inc(d[3,2]);end;\n while(d[1,3]+d[2,3]0)do begin inc(ans);dec(d[4,3]);inc(d[4,2]);end;\n end;\n if d[1,2]+d[2,2]>d[3,2]+d[4,2] then\n begin\n while(d[1,2]+d[2,2]>d[3,2]+d[4,2])and(d[1,2]>0)do begin inc(ans);dec(d[1,2]);end;\n while(d[1,2]+d[2,2]>d[3,2]+d[4,2])and(d[2,2]>0)do begin inc(ans);dec(d[2,2]);end;\n end else\n begin\n while(d[1,2]+d[2,2]0)do begin inc(ans);dec(d[3,2]);end;\n while(d[1,2]+d[2,2]0)do begin inc(ans);dec(d[4,2]);end;\n end;\n for i:=1 to 4 do for j:=2 to 3 do for z:=1 to d[i,j] do a[i]:=a[i]*j;\n writeln(ans);\n writeln(a[1],' ',a[2]);\n writeln(a[3],' ',a[4]);\nend.\n\n\n\n\n"}, {"source_code": "var a, b: array [1..2] of array [1..2] of longint;\n d: array [1..2] of array [2..3] of byte;\n i, j, x, y: longint;\nbegin\n readln(a[1][1], a[1][2]);\n readln(a[2][1], a[2][2]);\n for i := 1 to 2 do\n for j := 1 to 2 do\n b[i][j] := a[i][j];\n for i := 1 to 2 do\n for j := 1 to 2 do\n begin\n while b[i][j] mod 3 = 0 do\n begin\n b[i][j] := (b[i][j] div 3) * 2;\n inc(d[i][3]);\n end;\n while b[i][j] mod 2 = 0 do\n begin\n b[i][j] := b[i][j] div 2;\n inc(d[i][2]);\n end;\n end;\n if int64(b[1][1]) * b[1][2] <> int64(b[2][1]) * b[2][2] then\n begin\n writeln(-1);\n exit;\n end;\n x := d[1][2] - d[2][2];\n y := d[1][3] - d[2][3];\n writeln(abs(x) + abs(y));\n if y > 0 then\n begin\n for i := 1 to y do\n if a[1][1] mod 3 = 0 then\n a[1][1] := (a[1][1] div 3) * 2\n else\n a[1][2] := (a[1][2] div 3) * 2;\n end\n else\n begin\n for i := 1 to abs(y) do\n if a[2][1] mod 3 = 0 then\n a[2][1] := (a[2][1] div 3) * 2\n else\n a[2][2] := (a[2][2] div 3) * 2;\n end;\n if x > 0 then\n begin\n for i := 1 to x do\n if a[1][1] mod 2 = 0 then\n a[1][1] := a[1][1] div 2\n else\n a[1][2] := a[1][2] div 2;\n end\n else\n begin\n for i := 1 to abs(x) do\n if a[2][1] mod 2 = 0 then\n a[2][1] := a[2][1] div 2\n else\n a[2][2] := a[2][2] div 2;\n end;\n\n writeln(a[1][1], ' ', a[1][2]);\n writeln(a[2][1], ' ', a[2][2]);\nend.\n"}, {"source_code": "var f : text;\nmu1 , mu2 : array[1..2] of longint;\na , b , c , d : longint;\n//_______________________________________________________\nprocedure nhap;\nbegin\n assign(f , '');\n reset(f);\n readln(f , a , b , c , d);\n close(f);\n assign(f , '');\n rewrite(f);\nend;\n//_______________________________________________________\nprocedure xu_li;\nvar tam1 , tam2 , tt1 , tt2 , tt3 , tt4 : int64;\ni , dem : longint;\nbegin\n tam1 := int64(a) * int64(b);\n while tam1 mod 2 = 0 do\n begin\n inc(mu1[1]);\n tam1 := tam1 div 2;\n end;\n while tam1 mod 3 = 0 do\n begin\n inc(mu1[2]);\n tam1 := tam1 div 3;\n end;\n tam2 := int64(c) * int64(d);\n while tam2 mod 2 = 0 do\n begin\n inc(mu2[1]);\n tam2 := tam2 div 2;\n end;\n while tam2 mod 3 = 0 do\n begin\n inc(mu2[2]);\n tam2 := tam2 div 3;\n end;\n tt1 := mu1[1];\n tt2 := mu1[2];\n tt3 := mu2[1];\n tt4 := mu2[2];\n dem := 0;\n if mu1[2] > mu2[2] then\n begin\n dem := dem + mu1[2] - mu2[2];\n mu1[1] := mu1[1] + mu1[2] - mu2[2];\n mu1[2] := mu2[2];\n end\n else\n if mu1[2] < mu2[2] then\n begin\n dem := dem + mu2[2] - mu1[2];\n mu2[1] := mu2[1] + mu2[2] - mu1[2];\n mu2[2] := mu1[2];\n end;\n if mu1[1] > mu2[1] then\n begin\n dem := dem + mu1[1] - mu2[1];\n mu1[1] := mu2[1];\n end\n else\n if mu1[1] < mu2[1] then\n begin\n dem := dem + mu2[1] - mu1[1];\n mu2[1] := mu1[1];\n end;\n tt1 := tt1 + tt2 - mu1[2];\n tt2 := tt2 - mu1[2];\n tt1 := tt1 - mu1[1];\n tt3 := tt3 + tt4 - mu2[2];\n tt4 := tt4 - mu2[2];\n tt3 := tt3 - mu2[1];\n for i := 1 to mu1[1] do tam1 := tam1 * int64(2);\n for i := 1 to mu1[2] do tam1 := tam1 * int64(3);\n for i := 1 to mu2[1] do tam2 := tam2 * int64(2);\n for i := 1 to mu2[2] do tam2 := tam2 * int64(3);\n if tam1 = tam2 then\n begin\n writeln(f , dem);\n tam1 := tt1;\n tam2 := tt2;\n while (a mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n a := a div 3;\n a := a * 2;\n end;\n while (a mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n a := a div 2;\n end;\n while (b mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n b := b div 3;\n b := b * 2;\n end;\n while (b mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n b := b div 2;\n end;\n writeln(f , a , #32 , b);\n tam1 := tt3;\n tam2 := tt4;\n while (c mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n c := c div 3;\n c := c * 2;\n end;\n while (c mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n c := c div 2;\n end;\n while (d mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n d := d div 3;\n d := d * 2;\n end;\n while (d mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n d := d div 2;\n end;\n writeln(f , c , #32 , d);\n end\n else\n writeln(f , '-1');\n close(f);\nend;\n//_______________________________________________________\nbegin\n nhap;\n xu_li;\nend."}, {"source_code": "var a,b,c,d,a1,dob,dob1,ans,ans1:int64;\nstep2,step3:array[0..100] of int64;\nprv2,prv3,drg2,drg3,tre2,tre3,cet2,cet3,res1,res2,res3,res4,p:longint;\nmog1,mog2,mog3,mog4:longint;\ni,j,k,l,min:longint;\n begin\n readln(a,b);\n readln(c,d);\n a1:=a;\n step2[0]:=1;\n for i:=1 to 62 do\n step2[i]:=step2[i-1]*2;\n step3[0]:=1;\n for i:=1 to 36 do\n step3[i]:=step3[i-1]*3;\n While a1 mod 2=0 do\n begin\n inc(prv2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(prv3);\n a1:=a1 div 3;\n end;\n a1:=b;\n While a1 mod 2=0 do\n begin\n inc(drg2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(drg3);\n a1:=a1 div 3;\n end;\n a1:=c;\n While a1 mod 2=0 do\n begin\n inc(tre2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(tre3);\n a1:=a1 div 3;\n end;\n a1:=d;\n While a1 mod 2=0 do\n begin\n inc(cet2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(cet3);\n a1:=a1 div 3;\n end;\n min:=10000;\n ans:=a*b;\n ans1:=c*d;\n for i:=0 to 62 do\n for j:=0 to 36 do\n for k:=0 to 62 do\n for l:=0 to 36 do\n begin\n p:=0;\n mog1:=prv2+drg2;\n mog2:=prv3+drg3;\n mog3:=tre2+cet2;\n mog4:=tre3+cet3;\n if (mog2>=j) then mog1:=mog1+j else inc(p);\n if mog1=l then mog3:=mog3+l else inc(p);\n if mog30) do\n begin\n a:=a div 3;\n a:=a*2;\n dec(res2);\n end;\n While (b mod 3=0) and (res2>0) do\n begin\n b:=b div 3;\n b:=b*2;\n dec(res2);\n end;\n While (c mod 3=0) and (res4>0) do\n begin\n c:=c div 3;\n c:=c*2;\n dec(res4);\n end;\n While (d mod 3=0) and (res4>0) do\n begin\n d:=d div 3;\n d:=d*2;\n dec(res4);\n end;\n While (a mod 2=0) and (res1>0) do\n begin\n a:=a div 2;\n dec(res1);\n end;\n While (b mod 2=0) and (res1>0) do\n begin\n b:=b div 2;\n dec(res1);\n end;\n While (c mod 2=0) and (res3>0) do\n begin\n c:=c div 2;\n dec(res3);\n end;\n While (d mod 2=0) and (res3>0) do\n begin\n d:=d div 2;\n dec(res3);\n end;\n writeln(a,' ',b);\n writeln(c,' ',d);\n end;\n end.\n//minut mi je falio da dodjem do tacnog resenja i da uradim prva cetri,steta\n\n"}, {"source_code": "var \n a1,a2,b1,b2,s1,s2:int64;\n t1,t2,kq:longint;\n\nbegin\n readln(a1,b1);\n readln(a2,b2);\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n kq:=0;\n while s1 mod 3=0 do\n begin\n s1:=s1 div 3;\n inc(t1);\n end;\n while s2 mod 3=0 do\n begin\n s2:=s2 div 3;\n inc(t2);\n end;\n kq:=abs(t1-t2);\n while (t2>t1)and(a2 mod 3=0) do\n begin\n a2:=a2*2 div 3;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 3=0) do\n begin\n b2:=b2*2 div 3;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 3=0) do\n begin\n a1:=a1*2 div 3;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 3=0) do\n begin\n b1:=b1*2 div 3;\n dec(t1);\n end;\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n while s1 mod 2=0 do\n begin\n s1:=s1 div 2;\n inc(t1);\n end;\n while s2 mod 2=0 do\n begin\n s2:=s2 div 2;\n inc(t2);\n end;\n kq:=kq+abs(t1-t2);\n while (t2>t1)and(a2 mod 2=0) do\n begin\n a2:=a2 div 2;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 2=0) do\n begin\n b2:=b2 div 2;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 2=0) do\n begin\n a1:=a1 div 2;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 2=0) do\n begin\n b1:=b1 div 2;\n dec(t1);\n end;\n if a1*b1=a2*b2 then\n begin\n writeln(kq);\n writeln(a1,' ',b1);\n writeln(a2,' ',b2);\n end\n else writeln(-1);\nend."}, {"source_code": "var\n ans,s1,s2,g,tw1,tw2,th1,th2:int64;\n a,b:array[1..2] of int64;\n\nfunction gcd(a,b:int64):int64;\nbegin\n if a mod b=0 then exit(b) else exit(gcd(b,a mod b));\nend;\n\nprocedure divide1(var s,tw,th:int64);\nbegin\n while s mod 2=0 do\n begin\n inc(tw);s:=s div 2;\n end;\n while s mod 3=0 do\n begin\n inc(th);s:=s div 3;\n end;\nend;\n\nprocedure divide2(data,num,st:int64);\nbegin\n while (num>0)and(a[st] mod data=0) do\n begin\n dec(num);\n a[st]:=(a[st] div data)*(data-1);\n end;\n while (num>0)and(b[st] mod data=0) do\n begin\n dec(num);\n b[st]:=(b[st] div data)*(data-1);\n end;\nend;\n\nbegin\n readln(a[1],b[1]);readln(a[2],b[2]);\n s1:=a[1]*b[1];s2:=a[2]*b[2];\n g:=gcd(s1,s2);\n s1:=s1 div g;s2:=s2 div g;\n divide1(s1,tw1,th1);divide1(s2,tw2,th2);\n if (s1<>1)or(s2<>1)\n then begin\n writeln(-1);\n close(input);close(output);\n halt;\n end;\n ans:=0;\n inc(ans,abs(th1-th2));\n if th1>th2\n then begin\n divide2(3,th1-th2,1);\n inc(tw1,th1-th2);th1:=th2;\n end\n else begin\n divide2(3,th2-th1,2);\n inc(tw2,th2-th1);th2:=th1;\n end;\n inc(ans,abs(tw1-tw2));\n if tw1>tw2\n then divide2(2,tw1-tw2,1)\n else divide2(2,tw2-tw1,2);\n writeln(ans);\n writeln(a[1],' ',b[1]);writeln(a[2],' ',b[2]);\nend."}, {"source_code": "var a,b,c,d,x,y,x2,x3,y2,y3,ans:int64;\n\nbegin\n//assign(input,'qkl.in');reset(input);\n//assign(output,'qkl.out');rewrite(output);\nread(a,b);\nread(c,d);\nx:=a*b;y:=c*d;\nwhile x mod 2=0 do begin x:=x div 2;x2:=x2+1; end;\nwhile x mod 3=0 do begin x:=x div 3;x3:=x3+1; end;\nwhile y mod 2=0 do begin y:=y div 2;y2:=y2+1; end;\nwhile y mod 3=0 do begin y:=y div 3;y3:=y3+1; end;\nif x<>y then begin write(-1);close(input);close(output);halt; end;\nwhile x3<>y3 do\n begin\n if x3>y3 then\n begin\n x2:=x2+1;x3:=x3-1;\n if a mod 3=0 then a:=a div 3*2\n else b:=b div 3*2;\n end\n else\n begin\n y2:=y2+1;y3:=y3-1;\n if c mod 3=0 then c:=c div 3*2\n else d:=d div 3*2;\n end;\n ans:=ans+1;\n end;\nwhile x2<>y2 do\n begin\n if x2>y2 then\n begin\n x2:=x2-1;\n if a mod 2=0 then a:=a div 2\n else b:=b div 2;\n end\n else\n begin\n y2:=y2-1;\n if c mod 2=0 then c:=c div 2\n else d:=d div 2;\n end;\n ans:=ans+1;\n end;\nwriteln(ans);\nwriteln(a,' ',b);\nwriteln(c,' ',d);\nclose(input);close(output);\nend."}, {"source_code": "Program PBD;\nConst ss=0.0000000001;\nVar\n a,b,a1,b1,s1,s2,v1,v2:int64;\n c:array[1..2,1..2] of integer;\n r:array[1..2,1..2] of integer;\n i,j,k,t,res:integer;\nProcedure tinh(val:int64;var d1,d2:integer);\nBegin\n While val mod 2=0 do\n Begin\n inc(d1);\n val:=val div 2;\n End;\n While val mod 3=0 do\n Begin\n inc(d2);\n val:=val div 3;\n End;\nEnd;\nBegin\n readln(a,b);\n s1:=a*b;\n readln(a1,b1);\n s2:=a1*b1;\n fillchar(c,sizeof(c),0);\n tinh(s1,c[1,1],c[1,2]);\n tinh(s2,c[2,1],c[2,2]);\n res:=high(integer);\n For i:=0 to c[1,2] do\n For j:=0 to c[1,1]+i do\n For k:=0 to c[2,2] do\n Begin\n v1:=round(s2/exp(k*ln(3/2)));\n v2:=round(s1/(exp(i*ln(3/2))*exp(j*ln(2))));\n if (v1 mod v2=0) and (abs(round(ln(v1/v2)/ln(2))-ln(v1/v2)/ln(2))<=ss) and (i+j+k+round(ln(v1/v2)/ln(2))0) and (a mod 3=0) do\n Begin\n a:=(a div 3)*2;\n dec(r[1,2]);\n End;\n While (r[1,2]>0) and (b mod 3=0) do\n Begin\n b:=(b div 3)*2;\n dec(r[1,2]);\n ENd;\n While (r[1,1]>0) and (a mod 2=0) do\n Begin\n a:=a div 2;\n dec(r[1,1]);\n End;\n While (r[1,1]>0) and (b mod 2=0) do\n Begin\n b:=b div 2;\n dec(r[1,1]);\n ENd;\n While (r[2,2]>0) and (a1 mod 3=0) do\n Begin\n a1:=(a1 div 3)*2;\n dec(r[2,2]);\n End;\n While (r[2,2]>0) and (b1 mod 3=0) do\n Begin\n b1:=(b1 div 3)*2;\n dec(r[2,2]);\n ENd;\n While (r[2,1]>0) and (a1 mod 2=0) do\n Begin\n a1:=a1 div 2;\n dec(r[2,1]);\n End;\n While (r[2,1]>0) and (b1 mod 2=0) do\n Begin\n b1:=b1 div 2;\n dec(r[2,1]);\n ENd;\n writeln(a,' ',b);\n writeln(a1,' ',b1);\n End\n else write(-1);\nEnd."}, {"source_code": "const inp='';//d2.inp';\n out='';//d2.out';\n\nvar a1,a2,b1,b2:int64;\n fi,fo:text;\n\nprocedure init;\nbegin\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure process;\nvar t1,t2,kq:longint;\n s1,s2:int64;\nbegin\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n kq:=0;\n while s1 mod 3=0 do\n begin\n s1:=s1 div 3;\n inc(t1);\n end;\n while s2 mod 3=0 do\n begin\n s2:=s2 div 3;\n inc(t2);\n end;\n kq:=abs(t1-t2);\n while (t2>t1)and(a2 mod 3=0) do\n begin\n a2:=a2*2 div 3;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 3=0) do\n begin\n b2:=b2*2 div 3;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 3=0) do\n begin\n a1:=a1*2 div 3;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 3=0) do\n begin\n b1:=b1*2 div 3;\n dec(t1);\n end;\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n while s1 mod 2=0 do\n begin\n s1:=s1 div 2;\n inc(t1);\n end;\n while s2 mod 2=0 do\n begin\n s2:=s2 div 2;\n inc(t2);\n end;\n kq:=kq+abs(t1-t2);\n while (t2>t1)and(a2 mod 2=0) do\n begin\n a2:=a2 div 2;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 2=0) do\n begin\n b2:=b2 div 2;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 2=0) do\n begin\n a1:=a1 div 2;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 2=0) do\n begin\n b1:=b1 div 2;\n dec(t1);\n end;\n if a1*b1=a2*b2 then\n begin\n writeln(fo,kq);\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\n end\n else writeln(fo,-1);\nend;\n\nbegin\n assign(fi,inp);reset(fi);\n assign(fo,out);rewrite(fo);\n init;\n process;\n close(fi);close(fo);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar mA, nA, mB, nB, tu, mau, count: Qword;\n\nfunction ucln(a, b: Qword): Qword;\nbegin\n if b = 0 then exit(a)\n else exit(ucln(b, a mod b));\nend;\n\nprocedure Enter;\nbegin\n readln(mA, nA);\n readln(mB, nB);\nend;\n\nprocedure Checktu(a, b: Qword);\nbegin\n while tu mod a = 0 do\n begin\n inc(count);\n if mA mod a = 0 then mA:=mA div a * b\n else nA:=nA div a * b;\n tu:=tu div a * b;\n end;\nend;\n\nprocedure Checkmau(a, b: Qword);\nbegin\n while mau mod a = 0 do\n begin\n inc(count);\n if mB mod a = 0 then mB:=mB div a * b\n else nB:=nB div a * b;\n mau:=mau div a * b;\n end;\nend;\n\nprocedure Work;\nvar u: Qword;\nbegin\n u:=ucln(mA*nA, mB*nB);\n tu:=mA*nA div u; mau:=mB*nB div u;\n Checktu(3, 2);\n Checkmau(3, 2);\n\n u:=ucln(tu, mau);\n tu:=tu div u; mau:=mau div u;\n Checktu(2, 1);\n Checkmau(2, 1);\n\n if tu = mau then\n begin\n writeln(count);\n writeln(mA, ' ', nA);\n writeln(mB, ' ', nB);\n end\n else writeln(-1);\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n Enter;\n Work;\n\n close(input); close(output);\nend.\n"}, {"source_code": "var n1,m1,n2,m2,ans,ans1,k,t,s,x:int64;\n a,b,c,d:array[0..10] of int64;\n\nprocedure ddd(n:longint);\nbegin\n k:=0;\n t:=0;\n s:=0;\n While n mod 2 = 0 do\n begin\n n:=n div 2;\n k:=k+1;\n end;\n While n mod 3 = 0 do\n begin\n n:=n div 3;\n t:=t+1;\n end;\n s:=n;\nend;\n\n\nbegin\n \n read(n1,m1,n2,m2);\n \n ddd(n1);\n a[1]:=k;\n a[2]:=t;\n a[3]:=s;\n \n ddd(m1);\n b[1]:=k;\n b[2]:=t;\n b[3]:=s;\n \n ddd(n2);\n c[1]:=k;\n c[2]:=t;\n c[3]:=s;\n \n ddd(m2);\n d[1]:=k;\n d[2]:=t;\n d[3]:=s;\n \n If (a[3]*b[3]) = (c[3]*d[3]) then \n begin\n If (a[2]+b[2]) > (c[2]+d[2]) then \n begin\n x:=abs((a[2]+b[2]) - (c[2]+d[2]));\n ans:=ans+ x;\n While (n1 mod 3 =0) and (x>0) do\n begin\n n1:=2*n1 div 3;\n a[1]:=a[1]+1;\n x:=x-1;\n end;\n While (m1 mod 3 =0) and (x>0) do\n begin\n m1:=2*m1 div 3;\n b[1]:=b[1]+1;\n x:=x-1;\n end;\n end else\n begin\n x:=abs((a[2]+b[2]) - (c[2]+d[2]));\n ans:=ans+ x;\n While (n2 mod 3 =0) and (x>0) do\n begin\n n2:=2*n2 div 3;\n c[1]:=c[1]+1;\n x:=x-1;\n end;\n While (m2 mod 3 =0) and (x>0) do\n begin\n m2:=2*m2 div 3;\n d[1]:=d[1]+1;\n x:=x-1;\n end;\n end;\n \n \n \n If (a[1]+b[1]) > (c[1]+d[1]) then \n begin\n x:=abs((a[1]+b[1]) - (c[1]+d[1]));\n ans:=ans+ x;\n While (n1 mod 2 =0) and (x>0) do\n begin\n n1:=n1 div 2;\n x:=x-1;\n end;\n While (m1 mod 2 =0) and (x>0) do\n begin\n m1:=m1 div 2;\n x:=x-1;\n end;\n end else\n begin\n x:=abs((a[1]+b[1]) - (c[1]+d[1]));\n ans:=ans+ x;\n While (n2 mod 2 =0) and (x>0) do\n begin\n n2:=n2 div 2;\n x:=x-1;\n end;\n While (m2 mod 2 =0) and (x>0) do\n begin\n m2:=m2 div 2;\n x:=x-1;\n end;\n end;\n \n writeln(ans);\n writeln(n1,' ',m1);\n writeln(n2,' ',m2);\n \n end else write(-1);\n \n \nend."}, {"source_code": "var a1,b1,a2,b2,m,n1,n2:int64;\n k1,k2:array[1..2]of integer;\n ans:integer;\nfunction gcd(p,q:int64):int64;\nvar x,y:int64;\nbegin\n x:=p;y:=q;\n while x<>y do\n if x mod y=0 then\n x:=y\n else\n if y mod x=0 then\n y:=x\n else\n if x>y then\n x:=x mod y\n else\n y:=y mod x;\n gcd:=x;\nend;\n\nbegin\n readln(a1,b1,a2,b2);\n m:=gcd(a1*b1,a2*b2);\n n1:=a1*b1 div m;\n n2:=a2*b2 div m;\n while n1 mod 2=0 do begin\n inc(k1[1]);\n n1:=n1 div 2;\n end;\n while n1 mod 3=0 do begin\n inc(k1[2]);\n n1:=n1 div 3;\n end;\n while n2 mod 2=0 do begin\n inc(k2[1]);\n n2:=n2 div 2;\n end;\n while n2 mod 3=0 do begin\n inc(k2[2]);\n n2:=n2 div 3;\n end;\n if (n1=1)and(n2=1) then begin\n ans:=0;\n while k1[2]>k2[2] do begin\n if b1 mod 3=0 then\n b1:=b1 div 3*2\n else\n a1:=a1 div 3*2;\n inc(ans);dec(k1[2]);inc(k1[1]);\n end;\n while k2[2]>k1[2] do begin\n if b2 mod 3=0 then\n b2:=b2 div 3*2\n else\n a2:=a2 div 3*2;\n inc(ans);dec(k2[2]);inc(k2[1]);\n end;\n while k1[1]>k2[1] do begin\n if b1 mod 2=0 then\n b1:=b1 div 2\n else\n a1:=a1 div 2;\n inc(ans);dec(k1[1]);\n end;\n while k2[1]>k1[1] do begin\n if b2 mod 2=0 then\n b2:=b2 div 2\n else\n a2:=a2 div 2;\n inc(ans);dec(k2[1]);\n end;\n writeln(ans);\n writeln(a1,' ',b1,chr(10),a2,' ',b2);\n end\n else\n writeln(-1);\n readln;\nend.\n"}, {"source_code": "var a,b,c,d,x,y,z,k11,k12,k21,k22,ans:int64;\nbegin\n//assign(input,'qkl.in');reset(input);\n//assign(output,'qkl.out');rewrite(output);\nread(a,b);\nread(c,d);\nx:=a*b;y:=c*d;\nwhile x mod 2=0 do begin x:=x div 2;k11:=k11+1; end;\nwhile x mod 3=0 do begin x:=x div 3;k12:=k12+1; end;\nwhile y mod 2=0 do begin y:=y div 2;k21:=k21+1; end;\nwhile y mod 3=0 do begin y:=y div 3;k22:=k22+1; end;\nif x<>y then begin write(-1);close(input);close(output);halt; end;\nz:=k12-k22;\nwhile z<>0 do\n begin\n if z<0 then\n begin\n if c mod 3=0 then c:=c div 3*2 else d:=d div 3*2;\n z:=z+1;k21:=k21+1;ans:=ans+1;\n end\n else\n begin\n if a mod 3=0 then a:=a div 3*2 else b:=b div 3*2;\n z:=z-1;k11:=k11+1;ans:=ans+1;\n end;\n end;\nz:=k11-k21;\nwhile z<>0 do\n begin\n if z<0 then\n begin\n if c mod 2=0 then c:=c div 2 else d:=d div 2;\n z:=z+1;ans:=ans+1;\n end\n else\n begin\n if a mod 2=0 then a:=a div 2 else b:=b div 2;\n z:=z-1;ans:=ans+1;\n end;\n end;\nwriteln(ans);\nwriteln(a,' ',b);\nwriteln(c,' ',d);\nclose(input);close(output);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n a1,a2,b1,b2 : int64;\n dem: array[1..2,2..3] of longint;\n res: array[1..2,2..3] of longint;\n check1,check2 : int64;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure Init;\nvar tmp : int64;\nbegin\n tmp := a1 * b1;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[1,2]);\n tmp := tmp div 2;\n end;\n while (tmp mod 3 = 0) do\n begin\n inc(dem[1,3]);\n tmp := tmp div 3;\n end;\n check1 := tmp;\n tmp := a2 * b2;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[2,2]);\n tmp := tmp div 2;\n end;\n while tmp mod 3 = 0 do\n begin\n inc(dem[2,3]);\n tmp := tmp div 3;\n end;\n check2 := tmp;\nend;\n\nprocedure Solve;\nvar tmp : longint;\n ans : longint;\n i : longint;\nbegin\n ans := 0;\n if check1 <> check2 then\n begin\n writeln(fo,-1);\n exit;\n end;\n tmp := abs(dem[1,3] - dem[2,3]);\n if dem[1,3] > dem[2,3] then\n begin\n res[1,3] := tmp;\n dem[1,2] := dem[1,2] + tmp;\n end\n else\n begin\n res[2,3] := tmp;\n dem[2,2] := dem[2,2] + tmp;\n end;\n tmp := abs(dem[1,2] - dem[2,2]);\n if dem[1,2] > dem[2,2] then res[1,2] := tmp\n else res[2,2] := tmp;\n ans := res[1,2] + res[1,3] + res[2,2] + res[2,3];\n writeln(fo,ans);\n for i:= 3 downto 2 do\n begin\n while (res[1,i] > 0) and (a1 mod i = 0) do\n begin\n a1:= a1 div i;\n if i = 3 then a1 := a1 * 2;\n dec(res[1,i]);\n end;\n while (res[1,i] > 0) and (b1 mod i = 0) do\n begin\n b1:= b1 div i;\n if i = 3 then b1 := b1 * 2;\n dec(res[1,i]);\n end;\n while (res[2,i] > 0) and (a2 mod i = 0) do\n begin\n a2:= a2 div i;\n if i = 3 then a2 := a2 *2;\n dec(res[2,i]);\n end;\n while (res[2,i] > 0) and (b2 mod i = 0) do\n begin\n b2:= b2 div i;\n if i = 3 then b2 := b2 * 2;\n dec(res[2,i]);\n end;\n end;\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n init;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var\n a,b,c,d,z1,z2,k12,k13,k23,k22,x,ans : int64;\n\nbegin\n readln(a,b,c,d);\n z1:=a*b; z2:=c*d;\n while z1 mod 2 = 0 do begin z1:=z1 div 2; inc(k12); end;\n while z1 mod 3 = 0 do begin z1:=z1 div 3; inc(k13); end;\n while z2 mod 2 = 0 do begin z2:=z2 div 2; inc(k22); end;\n while z2 mod 3 = 0 do begin z2:=z2 div 3; inc(k23); end;\n if z1 <> z2 then begin writeln('-1'); halt; end;\n x:=k13-k23; ans:=abs(x);\n while x <> 0 do begin\n if x < 0 then begin\n dec(k23); inc(k22); inc(x);\n if c mod 3 = 0 then c:=c div 3*2 else d:=d div 3*2;\n end else begin\n dec(k13); inc(k12); dec(x);\n if a mod 3 = 0 then a:=a div 3*2 else b:=b div 3*2;\n end;\n end;\n x:=k12-k22; ans:=abs(x)+ans;\n while x <> 0 do begin\n if x < 0 then begin\n inc(x);\n if c mod 2 = 0 then c:=c div 2 else d:=d div 2;\n end else begin\n dec(x);\n if a mod 2 = 0 then a:=a div 2 else b:=b div 2;\n end;\n end;\n writeln(ans);\n writeln(a,' ',b);\n writeln(c,' ',d);\nend."}, {"source_code": "uses math;\nvar\n a1,b1,a2,b2,x1,x2,cnt2,cnt3,cnt21,cnt31,cnt22,cnt32,kol21,kol22,kol31,kol32:Int64;\n i:Longint;\nbegin\n Readln(a1,b1);\n Readln(a2,b2);\n x1:=a1*b1;\n x2:=a2*b2;\n while x1 mod 2=0 do\nbegin\n Inc(cnt21);\n x1:=x1 div 2;\n end;\n while x1 mod 3=0 do\nbegin\n Inc(cnt31);\n x1:=x1 div 3;\n end;\n while x2 mod 2=0 do\nbegin\n Inc(cnt22);\n x2:=x2 div 2;\n end;\n while x2 mod 3=0 do\nbegin\n Inc(cnt32);\n x2:=x2 div 3;\n end;\n if x1<>x2 then begin\n Writeln('-1');\n Halt;\n end;\n cnt2:=min(cnt21,cnt22);\n Dec(cnt21,cnt2);\n Dec(cnt22,cnt2);\n cnt3:=min(cnt31,cnt32);\n Dec(cnt31,cnt3);\n Dec(cnt32,cnt3);\n kol21:=0;\n kol22:=0;\n kol31:=0;\n kol32:=0;\n if (cnt21+cnt31=0) then begin\n Writeln(cnt22+cnt32*2);\n kol22:=cnt22+cnt32;\n kol32:=cnt32;\n end\n else\n if (cnt22+cnt32=0) then begin\n Writeln(cnt21+cnt31*2);\n kol21:=cnt21+cnt31;\n kol31:=cnt31;\n end\n else\n if (cnt21+cnt32=0) then begin\n if cnt22>cnt31 then begin\n Writeln(cnt22);\n kol22:=cnt22-cnt31;\n kol31:=cnt31;\n end\n else begin\n Writeln(cnt22+(cnt31-cnt22)*2);\n kol31:=cnt31;\n kol21:=cnt31-cnt22;\n end;\n\n end\n else begin\n if cnt21>cnt32 then begin\n Writeln(cnt21);\n kol21:=cnt21-cnt32;\n kol32:=cnt32;\n end\n else begin\n Writeln(cnt21+(cnt32-cnt21)*2);\n kol32:=cnt32;\n kol22:=cnt32-cnt21;\n end;\n end;\n for i:=1 to kol31 do\n if a1 mod 3=0 then a1:=(a1 div 3)*2\n else b1:=(b1 div 3)*2;\n for i:=1 to kol32 do\n if a2 mod 3=0 then a2:=(a2 div 3)*2\n else b2:=(b2 div 3)*2;\n for i:=1 to kol21 do\n if a1 mod 2=0 then a1:=a1 div 2\n else b1:=b1 div 2;\n for i:=1 to kol22 do\n if a2 mod 2=0 then a2:=a2 div 2\n else b2:=b2 div 2;\n Writeln(a1,' ',b1);\n Writeln(a2,' ',b2);\n end.\n"}], "negative_code": [{"source_code": "var\n x1,y1,x2,y2,x3,y3,x4,y4,n,m,w,h,u,v,r,s,a,b:longint;\nprocedure error;\n begin\n writeln('-1');\n halt;\n end;\n\nfunction sol(p,q,x,y:longint):longint;\n var\n t,i,x1,x2,k:longint;\n begin\n x1:=p;\n x2:=q;\n t:=abs(x-y);\n if x-y>0 then\n begin\n p:=p+x-y;\n k:=x-y;\n while(k>0)and(n mod 3=0) do\n begin\n n:=(n div 3)*2;\n k:=k-1;\n end;\n while(k>0)and(m mod 3=0) do\n begin\n m:=(m div 3)*2;\n k:=k-1;\n end;\n end\n else\n begin\n q:=q+y-x;\n k:=y-x;\n while(k>0)and(w mod 3=0) do\n begin\n w:=(w div 3)*2;\n k:=k-1;\n end;\n while(k>0)and(h mod 3=0) do\n begin\n h:=(h div 3)*2;\n k:=k-1;\n end;\n end;\n t:=t+abs(p-q);\n writeln(t);\n if p-q>0 then\n begin\n p:=p-abs(p-q);\n for i:=p downto x1+1 do\n n:=n*2;\n for i:=p to x1-1 do\n if n mod 2=0 then n:=n div 2\n else m:=m div 2;\n end\n else\n begin\n k:=q-p;\n q:=q-abs(p-q);\n for i:=q downto x2+1 do\n w:=w*2;\n for i:=q to x2-1 do\n if w mod 2=0 then w:=w div 2\n else h:=h div 2;\n end;\n writeln(n,' ',m);\n writeln(w,' ',h);\n end;\n\nprocedure cal(var a,b,p:longint;n:longint);\n var\n k:longint;\n begin\n k:=n;\n a:=0;\n b:=0;\n while k mod 2=0 do\n begin\n inc(a);\n k:=k div 2;\n end;\n while k mod 3=0 do\n begin\n inc(b);\n k:=k div 3;\n end;\n p:=k;\n end;\n\nbegin\n readln(n,m);\n readln(w,h);\n cal(x1,y1,u,n);\n cal(x2,y2,v,m);\n cal(x3,y3,r,w);\n cal(x4,y4,s,h);\n if v*u<>s*r then error;\n sol(x1+x2,x3+x4,y1+y2,y3+y4);\nend."}, {"source_code": "var a, b: array [1..2] of array [1..2] of longint;\n d: array [1..2] of array [2..3] of byte;\n i, j, x, y: longint;\nbegin\n readln(a[1][1], a[1][2]);\n readln(a[2][1], a[2][2]);\n for i := 1 to 2 do\n for j := 1 to 2 do\n b[i][j] := a[i][j];\n for i := 1 to 2 do\n for j := 1 to 2 do\n begin\n while b[i][j] mod 3 = 0 do\n begin\n b[i][j] := (b[i][j] div 3) * 2;\n inc(d[i][3]);\n end;\n while b[i][j] mod 2 = 0 do\n begin\n b[i][j] := b[i][j] div 2;\n inc(d[i][2]);\n end;\n end;\n if int64(b[1][1]) * b[1][2] <> int64(b[2][1]) * b[2][2] then\n begin\n writeln(-1);\n exit;\n end;\n x := d[1][2] - d[2][2];\n y := d[1][3] - d[2][3];\n writeln(abs(x) + abs(y));\n if x > 0 then\n begin\n for i := 1 to x do\n if a[1][1] mod 2 = 0 then\n a[1][1] := a[1][1] div 2\n else\n a[1][2] := a[1][2] div 2;\n end\n else\n begin\n for i := 1 to abs(x) do\n if a[2][1] mod 2 = 0 then\n a[2][1] := a[2][1] div 2\n else\n a[2][2] := a[2][2] div 2;\n end;\n if y > 0 then\n begin\n for i := 1 to y do\n if a[1][1] mod 3 = 0 then\n a[1][1] := (a[1][1] div 3) * 2\n else\n a[1][2] := (a[1][2] div 3) * 2;\n end\n else\n begin\n for i := 1 to abs(y) do\n if a[2][1] mod 3 = 0 then\n a[2][1] := (a[2][1] div 3) * 2\n else\n a[2][2] := (a[2][2] div 3) * 2;\n end;\n writeln(a[1][1], ' ', a[1][2]);\n writeln(a[2][1], ' ', a[2][2]);\nend."}, {"source_code": "var a, b: array [1..2] of array [1..2] of longint;\n d: array [1..2] of array [2..3] of byte;\n i, j, x, y, z: longint;\nbegin\n readln(a[1][1], a[1][2]);\n readln(a[2][1], a[2][2]);\n for i := 1 to 2 do\n for j := 1 to 2 do\n b[i][j] := a[i][j];\n for i := 1 to 2 do\n for j := 1 to 2 do\n begin\n while b[i][j] mod 3 = 0 do\n begin\n b[i][j] := (b[i][j] div 3) * 2;\n inc(d[i][3]);\n end;\n while b[i][j] mod 2 = 0 do\n begin\n b[i][j] := b[i][j] div 2;\n inc(d[i][2]);\n end;\n end;\n for i := 1 to 2 do\n if b[i][1] > b[i][2] then\n begin\n z := b[i][1];\n b[i][1] := b[i][2];\n b[i][2] := z;\n end;\n for i := 1 to 2 do\n if b[1][i] <> b[2][i] then\n begin\n writeln(-1);\n exit;\n end;\n x := d[1][2] - d[2][2];\n y := d[1][3] - d[2][3];\n writeln(abs(x) + abs(y));\n if x > 0 then\n begin\n for i := 1 to x do\n if a[1][1] mod 2 = 0 then\n a[1][1] := a[1][1] div 2\n else\n a[1][2] := a[1][2] div 2;\n end\n else\n begin\n for i := 1 to abs(x) do\n if a[2][1] mod 2 = 0 then\n a[2][1] := a[2][1] div 2\n else\n a[2][2] := a[2][2] div 2;\n end;\n if y > 0 then\n begin\n for i := 1 to y do\n if a[1][1] mod 3 = 0 then\n a[1][1] := a[1][1] div 3 * 2\n else\n a[1][2] := a[1][2] div 3 * 2;\n end\n else\n begin\n for i := 1 to abs(y) do\n if a[2][1] mod 3 = 0 then\n a[2][1] := a[2][1] div 3 * 2\n else\n a[2][2] := a[2][2] div 3 * 2;\n end;\n writeln(a[1][1], ' ', a[1][2]);\n writeln(a[2][1], ' ', a[2][2]);\nend."}, {"source_code": "var a, b: array [1..2] of array [1..2] of longint;\n d: array [1..2] of array [2..3] of byte;\n i, j, x, y, z: longint;\nbegin\n readln(a[1][1], a[1][2]);\n readln(a[2][1], a[2][2]);\n for i := 1 to 2 do\n for j := 1 to 2 do\n b[i][j] := a[i][j];\n for i := 1 to 2 do\n for j := 1 to 2 do\n begin\n while b[i][j] mod 2 = 0 do\n begin\n b[i][j] := b[i][j] div 2;\n inc(d[i][2]);\n end;\n while b[i][j] mod 3 = 0 do\n begin\n b[i][j] := b[i][j] div 3;\n inc(d[i][3]);\n end;\n end;\n for i := 1 to 2 do\n if b[i][1] > b[i][2] then\n begin\n z := b[i][1];\n b[i][1] := b[i][2];\n b[i][2] := z;\n end;\n for i := 1 to 2 do\n if b[1][i] <> b[2][i] then\n begin\n writeln(-1);\n exit;\n end;\n x := d[1][2] - d[2][2];\n y := d[1][3] - d[2][3];\n writeln(abs(x) + abs(y));\n if x > 0 then\n begin\n for i := 1 to x do\n if a[1][1] mod 2 = 0 then\n a[1][1] := a[1][1] div 2\n else\n a[1][2] := a[1][2] div 2;\n end\n else\n begin\n for i := 1 to abs(x) do\n if a[2][1] mod 2 = 0 then\n a[2][1] := a[2][1] div 2\n else\n a[2][2] := a[2][2] div 2;\n end;\n if y > 0 then\n begin\n for i := 1 to y do\n if a[1][1] mod 3 = 0 then\n a[1][1] := a[1][1] div 3\n else\n a[1][2] := a[1][2] div 3;\n end\n else\n begin\n for i := 1 to abs(y) do\n if a[2][1] mod 3 = 0 then\n a[2][1] := a[2][1] div 3\n else\n a[2][2] := a[2][2] div 3;\n end;\n writeln(a[1][1], ' ', a[1][2]);\n writeln(a[2][1], ' ', a[2][2]);\nend."}, {"source_code": "var a,b,c,d,a1,dob,dob1,ans,ans1:int64;\nstep2,step3:array[0..100] of int64;\nprv2,prv3,drg2,drg3,tre2,tre3,cet2,cet3,res1,res2,res3,res4,p:longint;\nmog1,mog2,mog3,mog4:longint;\ni,j,k,l,min:longint;\n begin\n readln(a,b);\n readln(c,d);\n a1:=a;\n step2[0]:=1;\n for i:=1 to 62 do\n step2[i]:=step2[i-1]*2;\n step3[0]:=1;\n for i:=1 to 36 do\n step3[i]:=step3[i-1]*3;\n While a1 mod 2=0 do\n begin\n inc(prv2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(prv3);\n a1:=a1 div 3;\n end;\n a1:=b;\n While a1 mod 2=0 do\n begin\n inc(drg2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(drg3);\n a1:=a1 div 3;\n end;\n a1:=c;\n While a1 mod 2=0 do\n begin\n inc(tre2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(tre3);\n a1:=a1 div 3;\n end;\n a1:=d;\n While a1 mod 2=0 do\n begin\n inc(cet2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(cet3);\n a1:=a1 div 3;\n end;\n min:=10000;\n ans:=a*b;\n ans1:=c*d;\n for i:=0 to 62 do\n for j:=0 to 36 do\n for k:=0 to 62 do\n for l:=0 to 36 do\n begin\n p:=0;\n mog1:=prv2+drg2;\n mog2:=prv3+drg3;\n mog3:=tre2+cet2;\n mog4:=tre3+cet3;\n if (mog2>=j) then mog1:=mog1+j else inc(p);\n if mog1=l then mog4:=mog4+l else inc(p);\n if mog30) do\n begin\n a:=a div 3;\n a:=a*2;\n dec(res2);\n end;\n While (b mod 3=0) and (res2>0) do\n begin\n b:=b div 3;\n b:=b*2;\n dec(res2);\n end;\n While (a mod 3=0) and (res4>0) do\n begin\n c:=c div 3;\n c:=c*2;\n dec(res4);\n end;\n While (d mod 3=0) and (res4>0) do\n begin\n d:=d div 3;\n d:=d*2;\n dec(res4);\n end;\n While (a mod 2=0) and (res1>0) do\n begin\n a:=a div 2;\n dec(res1);\n end;\n While (b mod 2=0) and (res1>0) do\n begin\n b:=b div 2;\n dec(res1);\n end;\n While (c mod 2=0) and (res3>0) do\n begin\n c:=c div 2;\n dec(res3);\n end;\n While (d mod 2=0) and (res3>0) do\n begin\n d:=d div 2;\n dec(res3);\n end;\n writeln(a,' ',b);\n writeln(c,' ',d);\n end;\n end.\n//minut mi je falio da dodjem do tacnog resenja i da uradim prva cetri,steta\n\n"}, {"source_code": "var a,b,c,d,a1,dob,dob1,ans,ans1:int64;\nstep2,step3:array[0..100] of int64;\nprv2,prv3,drg2,drg3,tre2,tre3,cet2,cet3,res1,res2,res3,res4,p:longint;\nmog1,mog2,mog3,mog4:longint;\ni,j,k,l,min:longint;\n begin\n readln(a,b);\n readln(c,d);\n a1:=a;\n step2[0]:=1;\n for i:=1 to 62 do\n step2[i]:=step2[i-1]*2;\n step3[0]:=1;\n for i:=1 to 36 do\n step3[i]:=step3[i-1]*3;\n While a1 mod 2=0 do\n begin\n inc(prv2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(prv3);\n a1:=a1 div 3;\n end;\n a1:=b;\n While a1 mod 2=0 do\n begin\n inc(drg2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(drg3);\n a1:=a1 div 3;\n end;\n a1:=c;\n While a1 mod 2=0 do\n begin\n inc(tre2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(tre3);\n a1:=a1 div 3;\n end;\n a1:=d;\n While a1 mod 2=0 do\n begin\n inc(cet2);\n a1:=a1 div 2;\n end;\n While (a1 mod 3=0) do\n begin\n inc(cet3);\n a1:=a1 div 3;\n end;\n min:=10000;\n ans:=a*b;\n ans1:=c*d;\n for i:=0 to 62 do\n for j:=0 to 36 do\n for k:=0 to 62 do\n for l:=0 to 36 do\n begin\n p:=0;\n mog1:=prv2+drg2;\n mog2:=prv3+drg3;\n mog3:=tre2+cet2;\n mog4:=tre3+cet3;\n if (mog2>=j) then mog1:=mog1+j else inc(p);\n if mog1=l then mog4:=mog4+l else inc(p);\n if mog30) do\n begin\n a:=a div 3;\n a:=a*2;\n dec(res2);\n end;\n While (b mod 3=0) and (res2>0) do\n begin\n b:=b div 3;\n b:=b*2;\n dec(res2);\n end;\n While (c mod 3=0) and (res4>0) do\n begin\n c:=c div 3;\n c:=c*2;\n dec(res4);\n end;\n While (d mod 3=0) and (res4>0) do\n begin\n d:=d div 3;\n d:=d*2;\n dec(res4);\n end;\n While (a mod 2=0) and (res1>0) do\n begin\n a:=a div 2;\n dec(res1);\n end;\n While (b mod 2=0) and (res1>0) do\n begin\n b:=b div 2;\n dec(res1);\n end;\n While (c mod 2=0) and (res3>0) do\n begin\n c:=c div 2;\n dec(res3);\n end;\n While (d mod 2=0) and (res3>0) do\n begin\n d:=d div 2;\n dec(res3);\n end;\n writeln(a,' ',b);\n writeln(c,' ',d);\n end;\n end.\n//minut mi je falio da dodjem do tacnog resenja i da uradim prva cetri,steta\n\n"}, {"source_code": "const inp='';//d1.inp';\n out='';//d1.out';\n\nvar a1,a2,b1,b2:longint;\n fi,fo:text;\n\nprocedure init;\nbegin\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure process;\nvar s1,s2,t1,t2,kq:longint;\nbegin\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n kq:=0;\n while s1 mod 3=0 do\n begin\n s1:=s1 div 3;\n inc(t1);\n end;\n while s2 mod 3=0 do\n begin\n s2:=s2 div 3;\n inc(t2);\n end;\n kq:=abs(t1-t2);\n while (t2>t1)and(a2 mod 3=0) do\n begin\n a2:=a2*2 div 3;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 3=0) do\n begin\n b2:=b2*2 div 3;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 3=0) do\n begin\n a1:=a1*2 div 3;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 3=0) do\n begin\n b1:=b1*2 div 3;\n dec(t1);\n end;\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n while s1 mod 2=0 do\n begin\n s1:=s1 div 2;\n inc(t1);\n end;\n while s2 mod 2=0 do\n begin\n s2:=s2 div 2;\n inc(t2);\n end;\n kq:=kq+abs(t1-t2);\n while (t2>t1)and(a2 mod 2=0) do\n begin\n a2:=a2 div 2;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 2=0) do\n begin\n b2:=b2 div 2;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 2=0) do\n begin\n a1:=a1 div 2;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 2=0) do\n begin\n b1:=b1 div 2;\n dec(t1);\n end;\n if a1*b1=a2*b2 then\n begin\n writeln(fo,kq);\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\n end\n else writeln(fo,-1);\nend;\n\nbegin\n assign(fi,inp);reset(fi);\n assign(fo,out);rewrite(fo);\n init;\n process;\n close(fi);close(fo);\nend.\n"}, {"source_code": "const inp='';//d1.inp';\n out='';//d1.out';\n\nvar a1,a2,b1,b2:longint;\n fi,fo:text;\n\nprocedure init;\nbegin\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure process;\nvar s1,s2,t1,t2,kq:longint;\nbegin\n s1:=a1*b1;\n s2:=a2*b2;\n t1:=0;\n t2:=0;\n kq:=0;\n while s1 mod 3=0 do\n begin\n s1:=s1 div 3;\n inc(t1);\n end;\n while s2 mod 3=0 do\n begin\n s2:=s2 div 3;\n inc(t2);\n end;\n kq:=abs(t1-t2);\n while (t2>t1)and(a2 mod 3=0) do\n begin\n a2:=a2*2 div 3;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 3=0) do\n begin\n b2:=b2*2 div 3;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 3=0) do\n begin\n a1:=a1*2 div 3;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 3=0) do\n begin\n b1:=b1*2 div 3;\n dec(t1);\n end;\n s1:=a1*b1;\n s2:=a2*b2;\n while s1 mod 2=0 do\n begin\n s1:=s1 div 2;\n inc(t1);\n end;\n while s2 mod 2=0 do\n begin\n s2:=s2 div 2;\n inc(t2);\n end;\n kq:=kq+abs(t1-t2);\n while (t2>t1)and(a2 mod 2=0) do\n begin\n a2:=a2 div 2;\n dec(t2);\n end;\n while (t2>t1)and(b2 mod 2=0) do\n begin\n b2:=b2 div 2;\n dec(t2);\n end;\n while (t1>t2)and(a1 mod 2=0) do\n begin\n a1:=a1 div 2;\n dec(t1);\n end;\n while (t1>t2)and(b1 mod 2=0) do\n begin\n b1:=b1 div 2;\n dec(t1);\n end;\n if a1*b1=a2*b2 then\n begin\n writeln(fo,kq);\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\n end\n else writeln(fo,-1);\nend;\n\nbegin\n assign(fi,inp);reset(fi);\n assign(fo,out);rewrite(fo);\n init;\n process;\n close(fi);close(fo);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\n maxN = 100000;\n //maxN = 1000;\n maxDigit = 8;\nvar n, count: longint;\n a: array [0..maxN] of string;\n e10: array [0..maxDigit] of longint;\n\nprocedure Enter;\nvar i: longint;\nbegin\n readln(n);\n for i:=1 to n do readln(a[i]);\n a[0]:='0';\n\n e10[0]:=1;\n for i:=1 to maxDigit do e10[i]:=e10[i-1]*10;\nend;\n\nfunction isGreaterthan(a, b: string): boolean;\nbegin\n exit((length(a) > length(b)) or ((length(a) = length(b)) and (a > b)));\nend;\n\nprocedure Replace(var s: string; n: longint);\nvar i, j: longint;\n r: string;\nbegin\n str(n, r); j:=0;\n while length(r) < count do r:='0'+r;\n for i:=1 to length(s) do\n if s[i] = '?' then\n begin inc(j); s[i]:=r[j]; end;\nend;\n\nfunction Check(n, k: longint): boolean;\nvar prev, cur: string;\nbegin\n prev:=a[k-1]; cur:=a[k];\n Replace(cur, n);\n exit((cur[1] <> '0') and isGreaterthan(cur, prev));\nend;\n\nfunction Find(k: longint): longint;\nvar i, l, r, mid, res: longint;\n code: integer;\nbegin\n count:=0;\n for i:=1 to length(a[k]) do\n if a[k][i] = '?' then inc(count);\n if count = 0 then\n begin\n if isGreaterthan(a[k], a[k-1]) then\n begin\n Val(a[k], res, code);\n exit(res);\n end\n else exit(-1);\n end;\n\n l:=0; r:=e10[count]-1; res:=-1;\n while l <= r do\n begin\n mid:=(l+r) div 2;\n if Check(mid, k) then\n begin\n res:=mid;\n r:=mid-1;\n end\n else l:=mid+1;\n end;\n exit(res);\nend;\n\nprocedure Work;\nvar i, k: longint;\nbegin\n for i:=1 to n do\n begin\n k:=Find(i);\n if k = -1 then\n begin\n writeln('NO');\n exit;\n end;\n Replace(a[i], k);\n end;\n writeln('YES');\n for i:=1 to n do writeln(a[i]);\nend;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n Enter;\n Work;\n\n close(input); close(output);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\ntype data = record\n x,y,c : int64;\n end;\nvar fi, fo: text;\n a1,b1,a2,b2 : int64;\n q : array[1..100,1..2] of data;\n d : array[1..100,1..2] of longint;\n n : array[1..2] of longint;\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure bfs(x,y,k : longint);\nvar first, last : longint;\n u : data;\n tmp : longint;\n i : longint;\nbegin\n first := 1;\n last := 1;\n q[1,k].x := x;\n q[1,k].y := y;\n q[1,k].c := x * y;\n while first <= last do\n begin\n u:= q[first,k];\n tmp := d[first,k];\n inc(first);\n for i:= 2 to 3 do\n begin\n if u.x mod i = 0 then\n begin\n inc(last);\n q[last,k].x := u.x - u.x div i;\n q[last,k].y := u.y;\n q[last,k].c := (u.x - u.x div i) * u.y;\n d[last,k] := tmp + 1;\n end;\n if u.y mod i = 0 then\n begin\n inc(last);\n q[last,k].x := u.x ;\n q[last,k].y := u.y - u.y div i;\n q[last,k].c := u.x * (u.y - u.y div i);\n d[last,k] := tmp + 1;\n end;\n end;\n end;\n n[k] := last;\nend;\n\nprocedure Solve;\nvar min : longint;\n i,j : longint;\n x1,y1 : longint;\n x2,y2 : longint;\nbegin\n bfs(a1,b1,1);\n bfs(a2,b2,2);\n min := high(longint);\n for i:= 1 to n[1] do\n for j:= 1 to n[2] do\n if (q[i,1].c = q[j,2].c) and (d[i,1] + d[j,2] < min) then\n begin\n min := d[i,1] + d[j,2];\n x1 := q[i,1].x;\n y1 := q[i,1].y;\n x2 := q[j,2].x;\n y2 := q[j,2].y;\n end;\n if min = high(longint) then writeln(fo,'NO')\n else\n begin\n writeln(fo,min);\n writeln(fo,x1,' ',y1);\n writeln(fo,x2,' ',y2);\n end;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n a1,a2,b1,b2 : int64;\n dem: array[1..2,2..3] of longint;\n res: array[1..2,2..3] of longint;\n check1,check2 : int64;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure Init;\nvar tmp : int64;\nbegin\n tmp := a1 * b1;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[1,2]);\n tmp := tmp div 2;\n end;\n while (tmp mod 3 = 0) do\n begin\n inc(dem[1,3]);\n tmp := tmp div 3;\n end;\n check1 := tmp;\n tmp := a2 * b2;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[2,2]);\n tmp := tmp div 2;\n end;\n while tmp mod 3 = 0 do\n begin\n inc(dem[2,3]);\n tmp := tmp div 3;\n end;\n check2 := tmp;\nend;\n\nprocedure Solve;\nvar tmp : longint;\n ans : longint;\n i : longint;\nbegin\n ans := 0;\n if check1 <> check2 then\n begin\n writeln(fo,-1);\n exit;\n end;\n tmp := abs(dem[1,3] - dem[2,3]);\n if dem[1,3] > dem[2,3] then\n begin\n res[1,3] := tmp;\n dem[1,2] := dem[1,2] + tmp;\n end\n else\n begin\n res[2,3] := tmp;\n dem[2,2] := dem[2,2] + tmp;\n end;\n tmp := abs(dem[1,2] - dem[2,2]);\n if dem[1,2] > dem[2,2] then res[1,2] := tmp\n else res[2,2] := tmp;\n ans := res[1,2] + res[1,3] + res[2,2] + res[2,3];\n writeln(fo,ans);\n for i:= 2 to 3 do\n begin\n while (res[1,i] > 0) and (a1 mod i = 0) do\n begin\n a1:= a1 div i;\n if i = 3 then a1 := a1 * 2;\n dec(res[1,i]);\n end;\n while (res[1,i] > 0) and (b1 mod i = 0) do\n begin\n b1:= b1 div i;\n if i = 3 then b1 := b1 * 2;\n dec(res[1,i]);\n end;\n while (res[2,i] > 0) and (a2 mod i = 0) do\n begin\n a2:= a2 div i;\n if i = 3 then a2 := a2 *2;\n dec(res[2,i]);\n end;\n while (res[2,i] > 0) and (b2 mod i = 0) do\n begin\n b2:= b2 div i;\n if i = 3 then b2 := b2 * 2;\n dec(res[2,i]);\n end;\n end;\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n init;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n a1,a2,b1,b2 : int64;\n dem: array[1..2,2..3] of longint;\n res: array[1..2,2..3] of longint;\n check1,check2 : int64;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure Init;\nvar tmp : int64;\nbegin\n tmp := a1 * b1;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[1,2]);\n tmp := tmp div 2;\n end;\n while (tmp mod 3 = 0) do\n begin\n inc(dem[1,3]);\n tmp := tmp div 3;\n end;\n check1 := tmp;\n tmp := a2 * b2;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[2,2]);\n tmp := tmp div 2;\n end;\n while tmp mod 3 = 0 do\n begin\n inc(dem[2,3]);\n tmp := tmp div 3;\n end;\n check2 := tmp;\nend;\n\nprocedure Solve;\nvar tmp : longint;\n ans : longint;\n i : longint;\nbegin\n ans := 0;\n if check1 <> check2 then\n begin\n writeln(fo,-1);\n exit;\n end;\n tmp := abs(dem[1,3] - dem[2,3]);\n if dem[1,3] > dem[2,3] then\n begin\n res[1,3] := tmp;\n dem[1,2] := dem[1,2] + tmp;\n end\n else\n begin\n res[2,3] := tmp;\n dem[2,2] := dem[2,3] + tmp;\n end;\n tmp := abs(dem[1,2] - dem[2,2]);\n if dem[1,2] > dem[2,2] then res[1,2] := tmp\n else res[2,2] := tmp;\n ans := res[1,2] + res[1,3] + res[2,2] + res[2,3];\n writeln(fo,ans);\n for i:= 2 to 3 do\n begin\n while (res[1,i] > 0) and (a1 mod 2 = 0) do\n begin\n a1:= a1 div 2;\n dec(res[1,i]);\n end;\n while (res[1,i] > 0) and (b1 mod 2 = 0) do\n begin\n b1:= b1 div 2;\n dec(res[1,i]);\n end;\n while (res[2,i] > 0) and (a2 mod 2 = 0) do\n begin\n a2:= a2 div 2;\n dec(res[2,i]);\n end;\n while (res[2,i] > 0) and (b2 mod 2 = 0) do\n begin\n b2:= b2 div 2;\n dec(res[2,i]);\n end;\n end;\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n init;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n a1,a2,b1,b2 : int64;\n dem: array[1..2,2..3] of longint;\n res: array[1..2,2..3] of longint;\n check1,check2 : int64;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a1,b1);\n readln(fi,a2,b2);\nend;\n\nprocedure Init;\nvar tmp : int64;\nbegin\n tmp := a1 * b1;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[1,2]);\n tmp := tmp div 2;\n end;\n while (tmp mod 3 = 0) do\n begin\n inc(dem[1,3]);\n tmp := tmp div 3;\n end;\n check1 := tmp;\n tmp := a2 * b2;\n while (tmp mod 2 = 0) do\n begin\n inc(dem[2,2]);\n tmp := tmp div 2;\n end;\n while tmp mod 3 = 0 do\n begin\n inc(dem[2,3]);\n tmp := tmp div 3;\n end;\n check2 := tmp;\nend;\n\nprocedure Solve;\nvar tmp : longint;\n ans : longint;\n i : longint;\nbegin\n ans := 0;\n if check1 <> check2 then\n begin\n writeln(fo,-1);\n exit;\n end;\n tmp := abs(dem[1,3] - dem[2,3]);\n if dem[1,3] > dem[2,3] then\n begin\n res[1,3] := tmp;\n dem[1,2] := dem[1,2] + tmp;\n end\n else\n begin\n res[2,3] := tmp;\n dem[2,2] := dem[2,3] + tmp;\n end;\n tmp := abs(dem[1,2] - dem[2,2]);\n if dem[1,2] > dem[2,2] then res[1,2] := tmp\n else res[2,2] := tmp;\n ans := res[1,2] + res[1,3] + res[2,2] + res[2,3];\n writeln(fo,ans);\n for i:= 2 to 3 do\n begin\n while (res[1,i] > 0) and (a1 mod i = 0) do\n begin\n a1:= a1 div i;\n if i = 3 then a1 := a1 * 2;\n dec(res[1,i]);\n end;\n while (res[1,i] > 0) and (b1 mod i = 0) do\n begin\n b1:= b1 div i;\n if i = 3 then b1 := b1 * 2;\n dec(res[1,i]);\n end;\n while (res[2,i] > 0) and (a2 mod i = 0) do\n begin\n a2:= a2 div i;\n if i = 3 then a2 := a2 *2;\n dec(res[2,i]);\n end;\n while (res[2,i] > 0) and (b2 mod i = 0) do\n begin\n b2:= b2 div i;\n if i = 3 then b2 := b2 * 2;\n dec(res[2,i]);\n end;\n end;\n writeln(fo,a1,' ',b1);\n writeln(fo,a2,' ',b2);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n init;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var f : text;\nmu1 , mu2 : array[1..2] of longint;\na , b , c , d : longint;\n//_______________________________________________________\nprocedure nhap;\nbegin\n assign(f , '');\n reset(f);\n readln(f , a , b , c , d);\n close(f);\n assign(f , '');\n rewrite(f);\nend;\n//_______________________________________________________\nprocedure xu_li;\nvar tam1 , tam2 , tt1 , tt2 , tt3 , tt4 : int64;\ni , dem : longint;\nbegin\n tam1 := int64(a) * int64(b);\n while tam1 mod 2 = 0 do\n begin\n inc(mu1[1]);\n tam1 := tam1 div 2;\n end;\n while tam1 mod 3 = 0 do\n begin\n inc(mu1[2]);\n tam1 := tam1 div 3;\n end;\n tam2 := int64(c) * int64(d);\n while tam2 mod 2 = 0 do\n begin\n inc(mu2[1]);\n tam2 := tam2 div 2;\n end;\n while tam2 mod 3 = 0 do\n begin\n inc(mu2[2]);\n tam2 := tam2 div 3;\n end;\n tt1 := mu1[1];\n tt2 := mu1[2];\n tt3 := mu2[1];\n tt4 := mu2[2];\n dem := 0;\n if mu1[2] > mu2[2] then\n begin\n dem := dem + mu1[2] - mu2[2];\n mu1[1] := mu1[1] + mu1[2] - mu2[2];\n mu1[2] := mu2[2];\n end\n else\n if mu1[2] < mu2[2] then\n begin\n mu2[1] := mu2[1] + mu2[2] - mu1[2];\n mu2[2] := mu1[2];\n dem := dem + mu2[2] - mu2[1];\n end;\n if mu1[1] > mu2[1] then\n begin\n dem := dem + mu1[1] - mu2[1];\n mu1[1] := mu2[1];\n end\n else\n if mu1[1] < mu2[1] then\n begin\n dem := dem + mu2[1] - mu1[1];\n mu2[1] := mu1[1];\n end;\n tt1 := tt1 + tt2 - mu1[2];\n tt2 := tt2 - mu1[2];\n tt1 := tt1 - mu1[1];\n tt3 := tt3 + tt4 - mu2[2];\n tt4 := tt4 - mu2[2];\n tt3 := tt3 - mu2[1];\n for i := 1 to mu1[1] do tam1 := tam1 * int64(2);\n for i := 1 to mu1[2] do tam1 := tam1 * int64(3);\n for i := 1 to mu2[1] do tam2 := tam2 * int64(2);\n for i := 1 to mu2[2] do tam2 := tam2 * int64(3);\n if tam1 = tam2 then\n begin\n writeln(f , dem);\n tam1 := tt1;\n tam2 := tt2;\n while (a mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n a := a div 3;\n a := a * 2;\n end;\n while (a mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n a := a div 2;\n end;\n while (b mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n b := b div 3;\n b := b * 2;\n end;\n while (b mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n b := b div 2;\n end;\n writeln(f , a , #32 , b);\n tam1 := tt3;\n tam2 := tt4;\n while (c mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n c := c div 3;\n c := c * 2;\n end;\n while (c mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n c := c div 2;\n end;\n while (d mod 3 = 0) and (tam2 > 0) do\n begin\n dec(tam2);\n d := d div 3;\n d := d * 2;\n end;\n while (d mod 2 = 0) and (tam1 > 0) do\n begin\n dec(tam1);\n d := d div 2;\n end;\n writeln(f , c , #32 , d);\n end\n else\n writeln(f , '-1');\n close(f);\nend;\n//_______________________________________________________\nbegin\n nhap;\n xu_li;\nend."}, {"source_code": "type canh = record\n x , y : longint;\nend;\nvar f : text;\nqueue , queue2 : array[0..100001] of canh;\ndem , dem2 : array[0..100001] of longint;\na , b , c , d , aa , bb , cc , dd , min : longint;\n//_______________________________________________________\nprocedure nhap;\nbegin\n assign(f , '');\n reset(f);\n readln(f , a , b , c , d);\n close(f);\n assign(f , '');\n rewrite(f);\nend;\n//_______________________________________________________\nprocedure xu_li;\nvar i , dau , cuoi , m : longint;\nu : canh;\nbegin\n dau := 1;\n cuoi := 1;\n queue[1].x := a;\n queue[1].y := b;\n dem[1] := 0;\n min := maxlongint;\n repeat\n u := queue[dau];\n if u.x = u.y then\n begin\n if u.x mod 2 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x div 2;\n queue[cuoi].y := u.y;\n dem[cuoi] := dem[dau] + 1;\n end;\n if u.x mod 3 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x div 3 * 2;\n queue[cuoi].y := u.y;\n dem[cuoi] := dem[dau] + 1;\n end;\n end\n else\n begin\n if u.x mod 2 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x div 2;\n queue[cuoi].y := u.y;\n dem[cuoi] := dem[dau] + 1;\n end;\n if u.x mod 3 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x div 3 * 2;\n queue[cuoi].y := u.y;\n dem[cuoi] := dem[dau] + 1;\n end;\n if u.y mod 2 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x;\n queue[cuoi].y := u.y div 2;\n dem[cuoi] := dem[dau] + 1;\n end;\n if u.y mod 3 = 0 then\n begin\n inc(cuoi);\n queue[cuoi].x := u.x;\n queue[cuoi].y := u.y div 3 * 2;\n dem[cuoi] := dem[dau] + 1;\n end;\n end;\n inc(dau);\n until dau > cuoi;\n m := cuoi;\n dau := 1;\n cuoi := 1;\n queue2[1].x := c;\n queue2[1].y := d;\n dem2[1] := 0;\n repeat\n u := queue2[dau];\n for i := 1 to m do\n if int64(u.x) * int64(u.y) = int64(queue[i].x) * int64(queue[i].y) then\n if dem[i] + dem2[dau] < min then\n begin\n min := dem[i] + dem2[dau];\n aa := queue[i].x;\n bb := queue[i].y;\n cc := u.x;\n dd := u.y;\n end;\n if u.x = u.y then\n begin\n if u.x mod 2 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x div 2;\n queue2[cuoi].y := u.y;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n if u.x mod 3 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x div 3;\n queue2[cuoi].y := u.y;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n end\n else\n begin\n if u.x mod 2 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x div 2;\n queue2[cuoi].y := u.y;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n if u.x mod 3 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x div 3;\n queue2[cuoi].y := u.y;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n if u.y mod 2 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x;\n queue2[cuoi].y := u.y div 2;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n if u.y mod 3 = 0 then\n begin\n inc(cuoi);\n queue2[cuoi].x := u.x;\n queue2[cuoi].y := u.y div 3;\n dem2[cuoi] := dem2[dau] + 1;\n end;\n end;\n inc(dau);\n until dau > cuoi;\n if min = maxlongint then writeln(f , '-1')\n else\n begin\n writeln(f , min);\n writeln(f , aa , #32 , bb);\n writeln(f , cc , #32 , dd);\n end;\n close(f);\nend;\n//_______________________________________________________\nbegin\n nhap;\n xu_li;\nend."}, {"source_code": "var f : text;\nmu1 , mu2 : array[1..2] of longint;\na , b , c , d : longint;\n//_______________________________________________________\nprocedure nhap;\nbegin\n assign(f , '');\n reset(f);\n readln(f , a , b , c , d);\n close(f);\n assign(f , '');\n rewrite(f);\nend;\n//_______________________________________________________\nprocedure xu_li;\nvar tam1 , tam2 : int64;\ni , dem : longint;\nbegin\n tam1 := int64(a) * int64(b);\n while tam1 mod 2 = 0 do\n begin\n inc(mu1[1]);\n tam1 := tam1 div 2;\n end;\n while tam1 mod 3 = 0 do\n begin\n inc(mu1[2]);\n tam1 := tam1 div 3;\n end;\n tam2 := int64(c) * int64(d);\n while tam2 mod 2 = 0 do\n begin\n inc(mu2[1]);\n tam2 := tam2 div 2;\n end;\n while tam2 mod 3 = 0 do\n begin\n inc(mu2[2]);\n tam2 := tam2 div 3;\n end;\n dem := 0;\n if mu1[2] > mu2[2] then\n begin\n dem := dem + mu1[2] - mu2[2];\n mu1[1] := mu1[1] + mu1[2] - mu2[2];\n mu1[2] := mu2[2];\n end\n else\n if mu1[2] < mu2[2] then\n begin\n mu2[1] := mu2[1] + mu2[2] - mu1[2];\n mu2[2] := mu2[1];\n dem := dem + mu2[2] - mu2[1];\n end;\n if mu1[1] > mu2[1] then\n begin\n dem := dem + mu1[1] - mu2[1];\n mu1[1] := mu2[1];\n end\n else\n if mu1[1] < mu2[1] then\n begin\n dem := dem + mu2[1] - mu1[1];\n mu2[1] := mu1[1];\n end;\n for i := 1 to mu1[1] do tam1 := tam1 * int64(2);\n for i := 1 to mu1[2] do tam1 := tam1 * int64(3);\n for i := 1 to mu2[1] do tam2 := tam2 * int64(2);\n for i := 1 to mu2[2] do tam2 := tam2 * int64(3);\n if tam1 = tam2 then\n begin\n writeln(f , dem);\n writeln(f , a , #32 , b);\n writeln(f , c , #32 , d);\n end\n else\n writeln(f , '-1');\n close(f);\nend;\n//_______________________________________________________\nbegin\n nhap;\n xu_li;\nend."}, {"source_code": "var f : text;\nmu1 , mu2 : array[1..2] of longint;\na , b , c , d : longint;\n//_______________________________________________________\nprocedure nhap;\nbegin\n assign(f , '');\n reset(f);\n readln(f , a , b , c , d);\n close(f);\n assign(f , '');\n rewrite(f);\nend;\n//_______________________________________________________\nprocedure xu_li;\nvar tam1 , tam2 : int64;\ni , dem : longint;\nbegin\n tam1 := int64(a) * int64(b);\n while tam1 mod 2 = 0 do\n begin\n inc(mu1[1]);\n tam1 := tam1 div 2;\n end;\n while tam1 mod 3 = 0 do\n begin\n inc(mu1[2]);\n tam1 := tam1 div 3;\n end;\n tam2 := int64(c) * int64(d);\n while tam2 mod 2 = 0 do\n begin\n inc(mu2[1]);\n tam2 := tam2 div 2;\n end;\n while tam2 mod 3 = 0 do\n begin\n inc(mu2[2]);\n tam2 := tam2 div 3;\n end;\n dem := 0;\n if mu1[2] > mu2[2] then\n begin\n dem := dem + mu1[2] - mu2[2];\n mu1[1] := mu1[1] + mu1[2] - mu2[2];\n mu1[2] := mu2[2];\n end\n else\n if mu1[2] < mu2[2] then\n begin\n mu2[1] := mu2[1] + mu2[2] - mu1[2];\n mu2[2] := mu2[1];\n dem := dem + mu2[2] - mu2[1];\n end;\n if mu1[1] > mu2[1] then\n begin\n dem := dem + mu1[1] - mu2[1];\n mu1[1] := mu2[1];\n end\n else\n if mu1[1] < mu2[1] then\n begin\n dem := dem + mu2[1] - mu1[1];\n mu2[1] := mu1[1];\n end;\n for i := 1 to mu1[1] do tam1 := tam1 * int64(2);\n for i := 1 to mu1[2] do tam1 := tam1 * int64(3);\n for i := 1 to mu2[1] do tam2 := tam2 * int64(2);\n for i := 1 to mu2[2] do tam2 := tam2 * int64(3);\n if tam1 = tam2 then writeln(f , dem)\n else\n writeln(f , '-1');\n close(f);\nend;\n//_______________________________________________________\nbegin\n nhap;\n xu_li;\nend."}, {"source_code": "Program PBD;\nConst ss=0.0000000001;\nVar a,b,a1,b1:longint;\n s1,s2,v1,v2:int64;\n c:array[1..2,1..2] of integer;\n r:array[1..2,1..2] of integer;\n i,j,k,t,res:integer;\nProcedure tinh(val:int64;var d1,d2:integer);\nBegin\n While val mod 2=0 do\n Begin\n inc(d1);\n val:=val div 2;\n End;\n While val mod 3=0 do\n Begin\n inc(d2);\n val:=val div 3;\n End;\nEnd;\nBegin\n readln(a,b);\n s1:=a*b;\n readln(a1,b1);\n s2:=a1*b1;\n fillchar(c,sizeof(c),0);\n tinh(s1,c[1,1],c[1,2]);\n tinh(s2,c[2,1],c[2,2]);\n res:=high(integer);\n For i:=0 to c[1,2] do\n For j:=0 to c[1,1]+i do\n For k:=0 to c[2,2] do\n Begin\n v1:=trunc(s2/exp(k*ln(3/2)));\n v2:=trunc(s1/(exp(i*ln(3/2))*exp(j*ln(2))));\n if (v1 mod v2=0) and (abs(trunc(ln(v1/v2)/ln(2))-ln(v1/v2)/ln(2))<=ss) and (i+j+k+trunc(ln(v1/v2)/ln(2))0) and (a mod 3=0) do\n Begin\n a:=(a div 3)*2;\n dec(r[1,2]);\n End;\n While (r[1,2]>0) and (b mod 3=0) do\n Begin\n b:=(b div 3)*2;\n dec(r[1,2]);\n ENd;\n While (r[1,1]>0) and (a mod 2=0) do\n Begin\n a:=a div 2;\n dec(r[1,1]);\n End;\n While (r[1,1]>0) and (b mod 2=0) do\n Begin\n b:=b div 2;\n dec(r[1,1]);\n ENd;\n While (r[2,2]>0) and (a1 mod 3=0) do\n Begin\n a1:=(a1 div 3)*2;\n dec(r[2,2]);\n End;\n While (r[2,2]>0) and (b1 mod 3=0) do\n Begin\n b1:=(b1 div 3)*2;\n dec(r[2,2]);\n ENd;\n While (r[2,1]>0) and (a1 mod 2=0) do\n Begin\n a1:=a1 div 2;\n dec(r[2,1]);\n End;\n While (r[2,1]>0) and (b1 mod 2=0) do\n Begin\n b1:=b1 div 2;\n dec(r[2,1]);\n ENd;\n writeln(a,' ',b);\n writeln(a1,' ',b1);\n End\n else write(-1);\nEnd."}, {"source_code": "Program PBD;\nConst ss=0.0000000001;\nVar a,b,a1,b1:longint;\n s1,s2,v1,v2:int64;\n c:array[1..2,1..2] of integer;\n r:array[1..2,1..2] of integer;\n i,j,k,t,res:integer;\nProcedure tinh(val:int64;var d1,d2:integer);\nBegin\n While val mod 2=0 do\n Begin\n inc(d1);\n val:=val div 2;\n End;\n While val mod 3=0 do\n Begin\n inc(d2);\n val:=val div 3;\n End;\nEnd;\nBegin\n readln(a,b);\n s1:=a*b;\n readln(a1,b1);\n s2:=a1*b1;\n fillchar(c,sizeof(c),0);\n tinh(s1,c[1,1],c[1,2]);\n tinh(s2,c[2,1],c[2,2]);\n res:=high(integer);\n For i:=0 to c[1,2] do\n For j:=0 to c[1,1]+i do\n For k:=0 to c[2,2] do\n Begin\n v1:=round(s2/exp(k*ln(3/2)));\n v2:=round(s1/(exp(i*ln(3/2))*exp(j*ln(2))));\n if (v1 mod v2=0) and (abs(round(ln(v1/v2)/ln(2))-ln(v1/v2)/ln(2))<=ss) and (i+j+k+round(ln(v1/v2)/ln(2))0) and (a mod 3=0) do\n Begin\n a:=(a div 3)*2;\n dec(r[1,2]);\n End;\n While (r[1,2]>0) and (b mod 3=0) do\n Begin\n b:=(b div 3)*2;\n dec(r[1,2]);\n ENd;\n While (r[1,1]>0) and (a mod 2=0) do\n Begin\n a:=a div 2;\n dec(r[1,1]);\n End;\n While (r[1,1]>0) and (b mod 2=0) do\n Begin\n b:=b div 2;\n dec(r[1,1]);\n ENd;\n While (r[2,2]>0) and (a1 mod 3=0) do\n Begin\n a1:=(a1 div 3)*2;\n dec(r[2,2]);\n End;\n While (r[2,2]>0) and (b1 mod 3=0) do\n Begin\n b1:=(b1 div 3)*2;\n dec(r[2,2]);\n ENd;\n While (r[2,1]>0) and (a1 mod 2=0) do\n Begin\n a1:=a1 div 2;\n dec(r[2,1]);\n End;\n While (r[2,1]>0) and (b1 mod 2=0) do\n Begin\n b1:=b1 div 2;\n dec(r[2,1]);\n ENd;\n writeln(a,' ',b);\n writeln(a1,' ',b1);\n End\n else write(-1);\nEnd."}, {"source_code": "var a,b,c,d,x,y,z,k11,k12,k21,k22,ans:longint;\nbegin\n//assign(input,'qkl.in');reset(input);\n//assign(output,'qkl.out');rewrite(output);\nread(a,b);\nread(c,d);\nx:=a*b;y:=c*d;\nwhile x mod 2=0 do begin x:=x div 2;k11:=k11+1; end;\nwhile x mod 3=0 do begin x:=x div 3;k12:=k12+1; end;\nwhile y mod 2=0 do begin y:=y div 2;k21:=k21+1; end;\nwhile y mod 3=0 do begin y:=y div 3;k22:=k22+1; end;\nif x<>y then begin write(-1);close(input);close(output);halt; end;\nz:=k12-k22;\nwhile z<>0 do\n begin\n if z<0 then\n begin\n if c mod 3=0 then c:=c div 3*2 else d:=d div 3*2;\n z:=z+1;k21:=k21+1;ans:=ans+1;\n end\n else\n begin\n if a mod 3=0 then a:=a div 3*2 else b:=b div 3*2;\n z:=z-1;k11:=k11+1;ans:=ans+1;\n end;\n end;\nz:=k11-k21;\nwhile z<>0 do\n begin\n if z<0 then\n begin\n if c mod 2=0 then c:=c div 2 else d:=d div 2;\n z:=z+1;ans:=ans+1;\n end\n else\n begin\n if a mod 2=0 then a:=a div 2 else b:=b div 2;\n z:=z-1;ans:=ans+1;\n end;\n end;\nwriteln(ans);\nwriteln(a,' ',b);\nwriteln(c,' ',d);\nclose(input);close(output);\nend."}, {"source_code": "uses math;\nvar\n a1,b1,a2,b2,x1,x2,cnt2,cnt3,cnt21,cnt31,cnt22,cnt32,kol21:Int64;\n a:array [1..2,1..2] of Int64;\n i:Longint;\nbegin\n Readln(a1,b1);\n Readln(a2,b2);\n x1:=a1*b1;\n x2:=a2*b2;\n a[1][1]:=a1;\n a[1][2]:=b1;\n a[2][1]:=a2;\n a[2][2]:=b2;\n while x1 mod 2=0 do\nbegin\n Inc(cnt21);\n x1:=x1 div 2;\n if a[1][1] mod 2=0 then a[1][1]:=a[1][1] div 2\n else a[1][2]:=a[1][2] div 2;\n end;\n while x1 mod 3=0 do\nbegin\n Inc(cnt31);\n x1:=x1 div 3;\n if a[1][1] mod 3=0 then a[1][1]:=a[1][1] div 3\n else a[1][2]:=a[1][2] div 3;\n end;\n while x2 mod 2=0 do\nbegin\n Inc(cnt22);\n x2:=x2 div 2;\n if a[2][1] mod 2=0 then a[2][1]:=a[2][1] div 2\n else a[2][2]:=a[2][2] div 2;\n end;\n while x2 mod 3=0 do\nbegin\n Inc(cnt32);\n x2:=x2 div 3;\n if a[2][1] mod 3=0 then a[2][1]:=a[2][1] div 3\n else a[2][2]:=a[2][2] div 3;\n end;\n if x1<>x2 then begin\n Writeln('-1');\n Halt;\n end;\n cnt2:=min(cnt21,cnt22);\n Dec(cnt21,cnt2);\n Dec(cnt22,cnt2);\n for i:=1 to cnt2 do\nbegin\n if a[1][1]*2<=a1 then a[1][1]:=a[1][1]*2\n else a[1][2]:=a[1][2]*2;\n if a[2][1]*2<=a2 then a[2][1]:=a[2][1]*2\n else a[2][2]:=a[2][2]*2;\n end;\n cnt3:=min(cnt31,cnt32);\n Dec(cnt31,cnt3);\n Dec(cnt32,cnt3);\n for i:=1 to cnt3 do\nbegin\n if a[1][1]*3<=a1 then a[1][1]:=a[1][1]*3\n else a[1][2]:=a[1][2]*3;\n if a[2][1]*3<=a2 then a[2][1]:=a[2][1]*3\n else a[2][2]:=a[2][2]*3;\n end;\n kol21:=0;\n if (cnt21+cnt31=0) then Writeln(cnt22+cnt32*2)\n else\n if (cnt22+cnt32=0) then Writeln(cnt21+cnt31*2)\n else\n if (cnt21+cnt32=0) then begin\n if cnt22>cnt31 then begin\n Writeln(cnt22);\n kol21:=cnt31;\n end\n else begin\n Writeln(cnt22+(cnt31-cnt22)*2);\n kol21:=cnt22;\n end;\n\n end\n else begin\n if cnt21>cnt32 then begin\n Writeln(cnt21);\n kol21:=cnt32;\n end\n else begin\n Writeln(cnt21+(cnt32-cnt21)*2);\n kol21:=cnt21;\n end;\n end;\n for i:=1 to kol21 do\nbegin\n if a[1][1]*2<=a1 then a[1][1]:=a[1][1]*2\n else a[1][2]:=a[1][2]*2;\n if a[2][1]*2<=a2 then a[2][1]:=a[2][1]*2\n else a[2][2]:=a[2][2]*2;\n end;\n Writeln(a[1][1],' ',a[1][2]);\n Writeln(a[2][1],' ',a[2][2]);\n end."}, {"source_code": "uses math;\ntype mass=array[1..4,0..41] of int64;\n majj=array[0..100000] of longint;\nvar n,res,i:longint;s1,s,s2:string;\n uk,e,l,r,ans,kol,x,j,y,rr,ans1,k,z, ab, bc, ac, abc : longint;\n u:boolean;\n a,b,c,d:int64;\n m:majj;\n m1,m2:mass;\nprocedure factor(a:int64;z:longint);\nvar i:longint;\nBegin\n i:=2;\n while a>1 do\n Begin\n if i*i>a\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=a;\n m2[z,m1[z,0]]:=1;\n exit;\n end;\n if (a mod i=0) and (m[i]=0)\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=i;\n while a mod i=0 do\n Begin\n a:=a div i;\n inc(m2[z,m1[z,0]]);\n end;\n end;\n inc(i);\n end;\nend;\nbegin\n// assign(input,'input.txt'); assign(output,'output.txt');\n readln(a,b,c,d);\n m[1]:=1;\n for i:=2 to 100000 do\n if m[i]=0\n then Begin\n j:=i+i;\n while j<=100000 do\n Begin\n m[j]:=1;\n inc(j,i);\n end;\n end;\n factor(a,1);\n factor(b,2);\n factor(c,3);\n factor(d,4);\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=3 to 4 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if a<>m2[e,i]\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=1 to 2 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if a<>m2[e,i]\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n res:=0;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then Begin\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end\n else Begin\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m1[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m1[e,i]);\n end\n else\n else for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m1[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m1[e,i]);\n end;\n writeln(res);\n for i:=1 to 4 do\n Begin\n a:=1;\n for z:=1 to m1[i,0] do\n for j:=1 to m2[i,z] do\n a:=a*m1[i,z];\n write(a,' ');\n if i=2\n then writeln;\n end;\nend."}, {"source_code": "uses math;\ntype mass=array[1..4,0..41] of int64;\n majj=array[0..100000] of longint;\nvar n,res,i:longint;s1,s,s2:string;\n uk,e,l,r,ans,kol,x,j,y,rr,ans1,k,z, ab, bc, ac, abc : longint;\n u:boolean;\n a,b,c,d:int64;\n m:majj;\n m1,m2:mass;\nprocedure factor(a:int64;z:longint);\nvar i:longint;\nBegin\n i:=2;\n while a>1 do\n Begin\n if i*i>a\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=a;\n m2[z,m1[z,0]]:=1;\n exit;\n end;\n if (a mod i=0) and (m[i]=0)\n then Begin\n inc(m1[z,0]);\n m1[z,m1[z,0]]:=i;\n while a mod i=0 do\n Begin\n a:=a div i;\n inc(m2[z,m1[z,0]]);\n end;\n end;\n inc(i);\n end;\nend;\nbegin\n// assign(input,'input.txt'); assign(output,'output.txt');\n readln(a,b);\n readln(c,d);\n m[1]:=1;\n for i:=2 to 100000 do\n if m[i]=0\n then Begin\n j:=i+i;\n while j<=100000 do\n Begin\n m[j]:=1;\n inc(j,i);\n end;\n end;\n factor(a,1);\n factor(b,2);\n factor(c,3);\n factor(d,4);\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=3 to 4 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if a<>m2[e,i]\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if (m1[e,i]<>2) and (m1[e,i]<>3)\n then Begin\n a:=0;\n for z:=1 to 2 do\n for j:=1 to m1[z,0] do\n if m1[z,j]=m1[e,i]\n then inc(a,m2[z,j]);\n if a<>m2[e,i]\n then Begin\n writeln(-1);\n halt(0);\n end;\n end;\n res:=0;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then Begin\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end\n else Begin\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=3\n then Begin\n while (m2[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m2[e,i]);\n if i<>1\n then inc(m2[e,1])\n else Begin\n inc(m1[e,0]);\n m1[e,m1[e,0]]:=2;\n m2[e,m1[e,0]]:=1;\n end;\n end;\n break;\n end;\n end;\n a:=0;\n for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(a,m2[e,i]);\n b:=0;\n for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then inc(b,m2[e,i]);\n inc(res,abs(a-b));\n if a>b\n then for e:=1 to 2 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m2[e,i]>0) and (a>b) do\n Begin\n dec(a);\n dec(m2[e,i]);\n end\n else\n else for e:=3 to 4 do\n for i:=1 to m1[e,0] do\n if m1[e,i]=2\n then while (m2[e,i]>0) and (b>a) do\n Begin\n dec(b);\n dec(m2[e,i]);\n end;\n writeln(res);\n for i:=1 to 4 do\n Begin\n a:=1;\n for z:=1 to m1[i,0] do\n for j:=1 to m2[i,z] do\n a:=a*m1[i,z];\n write(a,' ');\n if i=2\n then writeln;\n end;\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=1000000000;\n nnn=2000000; eps=1e-13;\n label 1,2,3,4;\nvar ot,nn,chel,znam,dl,len,ii,jj,i3,i2,i1,j1,k1,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish,m:longint;\np1,p2,n,yy1,xx1,xx2,q,xx,yy,t1,t2,p,t,aa,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\nostminus,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\nb,uvel,a,f,h,kop:array[0..2000000] of int64;\ngr,c,x,y: array[-10..500,0..500] of int64;\nver: array[-10..51,-10..100,-10..100] of extended;\nzan,bb,marked:array[-100000..250000] of boolean;\n{ss:array[0..2000000] of char; }\nss:string;\nch11,ch12,ch1,ch:char;\ndd: array[-10..100,-10..100,-10..100] of {int64}extended;\nkol,rr,sl,sr,stoim,str :array[-10 ..200000] of int64;\nssot:array[-1000..110000] of string;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction deg2(pp:int64):int64; var ot,i,j:longint;\n begin\n ot:=0;\n while pp mod 2=0 do begin pp:=pp div 2; inc(ot); end;\n deg2:=ot;\n end;\n\nfunction deg3(pp:int64):int64; var ot,i,j:longint;\n begin\n ot:=0;\n while pp mod 3=0 do begin pp:=pp div 3; inc(ot); end;\n deg3:=ot;\n end;\n\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=4; for i:=1 to n do read(a[i]);\n p1:=a[1]*a[2];\n p2:=a[3]*a[4];\n while p1 mod 2= 0 do p1:=p1 div 2;\n while p2 mod 2= 0 do p2:=p2 div 2;\n\n while p1 mod 3= 0 do p1:=p1 div 3;\n while p2 mod 3= 0 do p2:=p2 div 3;\n\n if p1<>p2 then begin writeln(-1); goto 1; end;\n ot:=0;\n while deg3(a[1]*a[2])>deg3(a[3]*a[4]) do\n begin\n if (deg3(a[1])>0)and(deg3(a[1]*a[2])>deg3(a[3]*a[4])) then\n begin a[1]:=(a[1] div 3)*2; inc(ot); end;\n\n if (deg3(a[2])>0)and(deg3(a[1]*a[2])>deg3(a[3]*a[4])) then\n begin a[2]:=(a[2] div 3)*2; inc(ot); end;\n\n end;\n\n while deg2(a[1]*a[2])>deg2(a[3]*a[4]) do\n begin\n if (deg2(a[1])>0)and(deg2(a[1]*a[2])>deg2(a[3]*a[4])) then\n begin a[1]:=(a[1] div 2); inc(ot); end;\n\n if (deg2(a[2])>0)and(deg2(a[1]*a[2])>deg2(a[3]*a[4])) then\n begin a[2]:=(a[2] div 2); inc(ot); end;\n\n end;\n\n while deg3(a[1]*a[2])0)and(deg3(a[1]*a[2])0)and(deg3(a[1]*a[2])0)and(deg2(a[1]*a[2])0)and(deg2(a[1]*a[2])=a*c then begin writeln(0); exit; end;\n k:=a*c;\n while true do\n begin\n ok:=true;\n inc(t);\n for i:=t to c+t do\n begin\n if i*b<(i-t)*a then begin ok:=false;break; end;\n end;\n if ok then begin writeln(t); exit; end;\n end;\n end.\n", "positive_code": [{"source_code": "var f1,f2:text;\na,b,c,s,i,j:longint;\nrec,need:longint;\nok:boolean;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,c);\n For i:=0 to 1000000 do\n begin\n rec:=b*i;\n need:=0;\n ok:=true;\n for j:=0 to c do\n begin\n if need>rec then begin ok:=false; break; end;\n rec:=rec+b;\n need:=need+a;\n end;\n if ok then\n begin\n writeln(f2,i);\n break;\n end;\n end;\n close(f1);\n close(f2);\nend."}, {"source_code": "var a,b,c,sum:longint;\nbegin\n readln(a,b,c);\n if a*c mod b=0\n then sum:=(a*c div b)-c\n else sum:=1+(a*c div b)-c;\n writeln(sum);\nend."}, {"source_code": "var\n a,b,c,k1:longint;\n k:extended;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n readln(a,b,c);\n k:=(c*a-c*b)/b;\n k1:=trunc(k);\n if k>k1 then writeln(k1+1)else writeln(k1)\nend.\n"}, {"source_code": "program asdg;\nvar a,b,c,l,r,m,x0,ch:integer;\n dt:real;\nbegin\nch:=0;\nread(a,b,c);\nr:=a*c div b + 1;\nl:=0;\nwhile (r-l>1) or (ch=1) do\n begin\n m:=(r+l) div 2;\n x0:=m*b;\n dt:=(a*c-x0)/b;\n if dt=a*c then begin WriteLn(0); exit; end;\n t:=a*c;\n While true do\n begin\n Inc(I);\n y:=true;\n For j:=i to c+i do\n if j*b<(j-i)*a then begin y:=false; break; end;\n if y then begin WriteLn(i); exit; end;\n end;\n end."}, {"source_code": "program A_task;\nvar a,b,c:longint;\nl1,l2,l3,res:longint;\nbegin\n Readln(a,b,c);\n l1:=b*c;\n l2:=a*c;\n l3:=l2-l1;\n res:=l3 div b;\n if (l3 mod b<>0) then inc(res);\n Writeln(res);\nend.\n"}, {"source_code": "program tr1_l;\nvar a,b,c,i,n:longint;\nbegin\nreadln (a,b,c);\nn:=a*c;\nfor i:=1 to 1000000 do\n begin\n if b*i+c*b>=n then begin writeln (i); break; end;\n end;\nend."}, {"source_code": "program temm_answer;\nvar\n a,b,c,an:longint;\nbegin\n readln(a,b,c);\n an:=((a-b)*c) div b;\n if (((a-b)*c) mod b)>0 then inc(an);\n write(an);\nend.\n"}, {"source_code": "uses math;\nvar a,b,c:integer;\n i,res,dau,cuoi,m,t:longint;\nbegin\n readln(a,b,c);\n dau:=1; cuoi:=(a*c) div b; res:=1000000000;\n while dau <= cuoi do\n begin\n m:=(dau+cuoi) div 2;\n t:=m*b;\n for i:=1 to c do\n t:=t + b - a;\n if t >= 0 then \n begin\n res:=min(res,m); cuoi:=m - 1;\n end\n else dau:=m + 1;\n end;\n writeln(res);\nend."}, {"source_code": "var a,b,c:integer;\nbegin\n readln(a,b,c);\n writeln((a*c-1)div b+1-c);\nend."}, {"source_code": "var\n a, b, c : longint;\nbegin\n readln(a, b, c);\n if a - b <= 0 then\n writeln(0)\n else\n begin\n if c * a mod b = 0 then\n writeln((c * a) div b - c)\n else\n writeln((c * a) div b + 1 - c);\n end;\nend."}, {"source_code": "var a,b,c:longint;\nbegin\n readln(a,b,c);\n a:=a*c;\n writeln(((a-1)div b)+1-c);\nend."}, {"source_code": "var\n a, b, c, i, j, k: integer;\nbegin\n read(a, b, c);\n if (a*c-b*c) mod b = 0 then\n write((a*c-b*c) div b)\n else\n write((a*c-b*c) div b + 1)\nend.\n"}, {"source_code": "var\n a,b,c,x:longint;\nbegin\n read(a,b,c);\n if a*c mod b = 0 then x:=a*c div b\n else x:=a*c div b + 1;\n x:=x-c;\n write(x); \nend.\n"}, {"source_code": "Program watch_football;\nVar a,b,c: Integer;\n res: LongInt;\nBegin\n Readln(a,b,c);\n res:=a*c;\n If (res mod b)<>0 Then res:=(res div b)+1\n Else res:=res div b;\n res:=res-c;\n Writeln(res);\nEnd.\n"}, {"source_code": "var a,b,c:integer;\nbegin\n readln(a,b,c);\n writeln(((a-b)*c+b-1)div b);\n readln;\nend."}, {"source_code": "var\na,b,c:integer;\nbegin\nreset (input);\nrewrite (output);\nreadln (a,b,c);\nif (a*c-b*c) mod b=0 then\n writeln ((a*c-b*c) div b)\nelse\n writeln ((a*c-b*c) div b+1); \nclose (input);\nclose (output); \nend. "}, {"source_code": "var a,b,c,s:longint;\nbegin\n readln(a,b,c);\n s:=(a*c-1) div b+1;\n writeln(s-c);\nend."}, {"source_code": "Var i,a,b,c,t,j:longint;\n ok:boolean;\n begin\n read(a,b,c);\n i:=1;\n while true do\n begin\n t:=b*i;\n ok:=true;\n for j:=1 to c do\n begin\n t:=t+b;\n if t0 then t:=t+b;\n write(g,t div b);\n close(g);\nend."}, {"source_code": "var a,b,c,s,sek:longint;\nbegin\nreadln(a,b,c);\ns:=a*c;\nsek:=(s div b);\nif s mod b<>0\nthen begin\n while s mod b <>0 do\n s:=s-1;\n c:=c-1;\n end;\nwriteln(sek-c);\nend."}, {"source_code": "var a,b,c:word;\n t:single;\nbegin\n read(a,b,c);\n t:=a*c/b-c;\n if t-int(t)=0 then writeln(trunc(t)) else writeln(trunc(t)+1)\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n i,j,a,b,c,dl,tg,k,h,tt,l,mid:integer;\n kt:boolean;\n\nbegin\n readln(a,b,c);\n tg:=a*c div b+1;\n for i:=0 to tg do\n begin\n kt:=true;\n k:=i*b;\n j:=1;\n tt:=0;\n l:=1;h:=c;\n while (h>l) do\n begin\n mid:=(l+h) div 2;\n if (tt+mid*a>k+mid*b) then\n begin\n kt:=false;\n break;\n end;\n l:=mid+1;\n end;\n if (tt+l*a>k+l*b) then\n continue;\n if kt then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar a,b,c,dem:longint;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,a,b,c);\n close(f);\nend;\n{-----------------------}\nprocedure xuli;\nvar t,s:longint;\nbegin\n t:=a*c;\n s:=b*c;\n while s=a*c) then begin\n writeln(t);\n halt;\n end;\nend.\n"}, {"source_code": "var\n n,k,l,i,j,r,o,p,m,c,a,b:longint;\n s:int64;\nbegin\n readln(a,b,c);\n a:=a*c;\n s:=a div b;\n if a mod b<>0 then inc(s);\n dec(s,c);\n if s<=0 then writeln(0) else writeln(s);\nend.\n"}, {"source_code": "var\n a,b,c:longint;\nbegin\n readln(a,b,c);\n if (a*c-b*c) mod b=0 then writeln((a*c-b*c) div b)\n else writeln(trunc((a*c-b*c)/b)+1);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar a,b,c:integer;\nprocedure nhap;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,a,b,c);\n close(f);\nend;\nprocedure xuat;\nvar f:text;\n d,s:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n s:=b; d:=1;\n while st) then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a, b, c : longint;\n l, h, m : longint;\n f, x, i : longint;\n ans : longint;\nbegin\n read(a, b, c);\n l := 0;\n h := 1000000;\n ans := -1;\n while l <= h do\n begin\n m := (l + h) div 2;\n f := 1;\n x := m * b;\n for i := 1 to c do\n begin\n x := x + b;\n if i > x div a then\n begin\n f := 0;\n break;\n end;\n end;\n if f = 1 then\n begin\n h := m - 1;\n ans := m;\n end\n else\n l := m + 1;\n end;\n write(ans);\nend."}, {"source_code": "var a,b,c,t:real;\nbegin\nreadln(a,b,c);\nt:=(a*c)/b-c;\nif frac(t)=0 then writeln(trunc(t)) else writeln(trunc(t)+1);\nreadln;\nend.\n"}, {"source_code": "var a,b,c,i:longint;\n t:extended;\n begin\n read(a,b,c);\n for i:=1 to 10000000 do\n begin\n t:=i*a/(a-b);\n if t>=i+c then begin\n writeln(i);\n halt;\n end;\n end;\n end.\n"}, {"source_code": "program aa;\nvar\n a,b,c:longint;\nbegin\n read(a,b,c);\n a:=a*c;\n if trunc((a-(b*c))/b)<(a-(b*c))/b\n then\n write(trunc((a-(b*c))/b)+1)\n else\n write(trunc((a-(b*c))/b));\nend."}, {"source_code": "var a,b,c,i:longint;\nBegin\n read(a,b,c);\n writeln(((a*c+b-1)div b)-c);\nEnd."}, {"source_code": "var\na,b,k,c,d,e,s: integer;\nbegin\nreadln(a,b,c);\ns:=a*c;\ne:=b*c;\nk:=((s-e) div b);\nif (k*b)+(c*b)>=s then writeln(k) else writeln(k+1);\nend.\n"}, {"source_code": "var a,b,c:word;\nbegin\n read(a,b,c);\n write((c*a-1)div b+1-c)\nend."}, {"source_code": "var\n a,b,c:integer;\n x:extended;\nbegin\n readln(a,b,c);\n x:=((a-b)*c)/b;\n if((a-b)*c) mod b>0 then x:=x+1;\n if x<=0 then x:=x+1;\n writeln(trunc(x));\nend.\n"}, {"source_code": "var a,b,c,s,t,i: integer;\n begin\n readln (a,b,c);\n s:=(c*a+b-1) div b;\n t:=s+1;\n for i:=1 to s do\n begin\n if s*b>=(s-i)*a then if i=(s-i)*a then if i 1 do\n begin\n t := (right + left) div 2;\n if (t0* b) >=( (t0-t) * a) then right := t else\n left := t;\n end;\n write(right);\nend."}, {"source_code": "var\na,b,c,i,j,f:longint;\nbegin\nread(a,b,c);\nf:=a*c;\nj:= f div b;\nif(f mod b > 0) then j:=j+1;\ni:=j-c;\nwrite(i);\nend.\n"}, {"source_code": "var\n a,b,c,first,last,mid,dl : int64;\nbegin\n readln(a,b,c);\n dl := c*a;\n first := 0;\n last := 1000000000;\n repeat\n mid := (first + last) >> 1;\n if (dl - mid*b) < 0 then last := mid\n else if (dl - mid*b >= 0) and ((dl - mid*b)/c <= b) then last := mid\n else first := mid;\n until first+1 = last;\n writeln(last);\nend."}, {"source_code": "Program abc;\nVar right,left,a,b,c,sred,vsego,z:longint;\nBegin\nread(a,b,c);\nLeft:=0; Right:=(c+1)*1000; vsego:=a*c;\nWhile right-left>1 do \n begin z:=0;\n sred:=(right+left)div 2;\n for var x:=1 to C do\n begin If (sred*b+b*x>=vsego) then begin right:=sred; z:=1; break; end; end;\n If z=0 then left:=sred;\n end;\nWriteln(left+1);\nend."}, {"source_code": "var f1,f2:text;\na,b,c,s,i,j:longint;\nrec,need:longint;\nok:boolean;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,c);\n For i:=0 to 1000000 do\n begin\n rec:=b*i;\n need:=0;\n ok:=true;\n for j:=0 to c do\n begin\n if need>rec then begin ok:=false; break; end;\n rec:=rec+b;\n need:=need+a;\n end;\n if ok then\n begin\n writeln(f2,i);\n break;\n end;\n end;\n close(f1);\n close(f2);\nend."}, {"source_code": "program square;\nvar a,b,c: integer;\nbegin\nread(a,b,c);\nif ((a*c) mod b=0) then write(((a*c) div b)-c)\nelse write(((a*c) div b)+1-c);\nend."}, {"source_code": "var\n a, b, c,left, right,sr,dt: int64;\n\nbegin\n read(a, b, c);\n left := 0;\n right := (c*a+b-1) div b;\n dt:=right;\n while right - left > 1 do\n begin\n sr := (right + left) div 2;\n if (dt* b) >=( (dt-sr) * a) then right := sr else\n left := sr;\n end;\n write(right);\nend."}, {"source_code": "var a,b,c,i,kq:integer; tneed,max:real;\nbegin\n read(a,b,c);\n for i:=1 to c do\n begin\n tneed:=(a-b)*i/b;\n if max0 then kq:=trunc(max)+1 else kq:=trunc(max);\n write(kq);\nend."}, {"source_code": "var\n a,b,c:longint;\nbegin\n readln(a,b,c);\n a:=a*c;\n if a mod b<>0 then\n a:=a div b+1-c\n else\n a:=a div b-c;\n writeln(a);\nend."}, {"source_code": "var\n a,b,c,x,y:longint;\nbegin\n readln(a,b,c);\n x:=(a-b)*c;\n y:=x div b;\n if x mod b>0 then inc(y);\n writeln(y);\nend."}, {"source_code": "var a,b,c,all,t0,t:longint;\nbegin\n readln(a,b,c);\n all:=trunc((c*a+b-1)/b);\n for t:=1 to all do\n begin\n t0:=all;\n if t0*b>=(t0-t)*a then begin writeln(t);break;end;\n end;\nend."}, {"source_code": "var a,b,c,all,t0,t:longint;\nbegin\n readln(a,b,c);\n all:=trunc((c*a+b-1)/b);\n for t:=1 to all do\n begin\n t0:=all;\n if t0*b>=(t0-t)*a then begin writeln(t);break;end;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar n,i,j,k,l,m:integer;\n a,b,c:integer;\nbegin\nread(a,b,c);\na:=a-b;\na:=a*c;\nk:= a div b;\nif a mod b<>0 then k:=k+1;\nwrite(k);\nread(i);\nend.\n"}, {"source_code": "program Projecta;\n\n{$APPTYPE CONSOLE}\n\nvar\n i, a, b, c, l, r, m, count : integer;\n good : boolean;\n\nbegin\n { reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n readln(a, b, c);\n l := 0;\n r := 1000001;\n while (r - l > 1) do begin\n m := (l + r) div 2;\n good := true;\n for i := m to m + c do\n if (i * b < (i - m) * a) then\n good := false;\n if (not good) then\n l := m\n else\n r := m;\n end;\n writeln(r);\n\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nvar a,b,c:integer;\n\nbegin\nreadln(a,b,c);\nif c*(a-b) mod b =0 then\n writeln(c*(a-b) div b) else writeln(c*(a-b) div b +1);\n //readln;\nend.\n"}, {"source_code": "const fin='';\n fout='';\nvar f,g:text;\n t,a,b,c:longint;\nbegin\n assign(f,fin); reset(f);\n assign(g,fout); rewrite(g);\n read(f,a,b,c);\n t:=c*(a-b);\n if t mod b<>0 then t:=t+b;\n write(g,t div b);\n close(g);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m, i, j, k, res, a, b, c : integer;\n s : string;\n\nbegin\n\n read(a, b, c);\n res := 0;\n while c * a - res * b > c * b do\n inc(res);\n\n writeln(res); \n\n readln;readln;\nend.\n"}, {"source_code": "var a,b,c:integer;\nbegin\nreadln(a,b,c);\nif ((a-b)*c/b)>trunc((a-b)*c/b) then writeln(trunc((a-b)*c/b)+1)\nelse writeln(trunc((a-b)*c/b));\nend."}, {"source_code": "program Project4;\n{$APPTYPE CONSOLE}\n\nuses sysutils,math;\n\nvar n,m,k,r,l,a,b,c: int64;\n i,j: longint;\n\n\nbegin\n read(a,b,c);\n l := 0;\n r := trunc((a*c) / b);\n while r-l > 1 do\n begin\n m := (l + r) DIV 2;\n n := a*c - m * b - c * b;\n if n > 0 then l := m else if n < 0 then r := m else begin write(m); exit end\n end;\n write(r);\nend."}, {"source_code": "var a,b,c, s, k: LongInt;\nbegin\n Readln(a,b,c);\n\n if b>=a then\n begin\n Writeln(0);\n halt(0);\n end;\n\n s:=a*c;\n\n if ((s mod b)=0) then k:=s div b - c else k:=s div b - c + 1;\n \n Writeln(k);\nend."}, {"source_code": "const fi = '';\n fo = '';\ntype int = longint;\nvar a,b,c : int;\n Res : int;\n{}\nprocedure xl;\nvar l,r,m : int;\nbegin\n l := 1; r := a*(c+1) div b;\n while l+1=(a*c) then res := l else res :=r;\nend;\n{}\nprocedure docdl;\nbegin\n assign(input,fi); reset(input);\n readln(a,b,c);\n close(input);\nend;\n{}\nprocedure ghikq;\nbegin\n assign(output,fo); rewrite(output);\n writeln(Res);\n close(output);\nend;\n{}\nbegin\n docdl;\n xl;\n ghikq;\nend."}, {"source_code": "var a,b,c,d:longint;\nbegin\n readln(a,b,c);\n for d:=1 to 1000000 do\n if (c+d)*b>=c*a\n then begin\n writeln(d);\n exit\n end;\nend."}, {"source_code": "Var a,b,c,dan,pov:longint;\nbegin\nreadln(a,b,c);\npov:=((c*a-1) div b+1 -c);\nwriteln(pov);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n a, b, c, ans, i, j: integer; \n\nbegin\n { reset(input, 'input.txt');\n rewrite(output, 'output.txt'); }\n\n read(a, b, c);\n if (a*c - b*c) mod b = 0 then\n write((a*c - b*c) div b)\n else\n write((a*c - b*c) div b + 1)\nend.\n "}, {"source_code": "program pr1;\n\n{$APPTYPE CONSOLE}\ntype int64=longint;\nconst nnn=1000001; besk=2000000000;\n eps=0.00000000001;\n label 1,2,3,4;\nvar kk,ni,nj,nk,step,d,pp,jj,kolmash,kolper,k,i,j,ii,start,finish,per:longint;\nzad,a,b,c,t1,t2,t,p,nn,modul,r,ot,dx1,dy1,t1old,t2old,f,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;\nkoef:int64; ch,ch1,ch2:char;\ncc,g,al,ttt,tt,v,xx,yy,aa,bb:double;\nskach,smotr,dist:array[0..10000] of int64;\nflag2,flag1,flag:boolean;\nx,y,deg :array[0..30000] of int64;\nmask:array[0..20000000] of longint;\nc2:char;\ndd :double;\nss1,ss2,ss,namemin:string;\nsss:array[0..500000] of string;\nname:array[0..2000] of string;\nfunction min (a,b:longint):longint;begin min:=b;if ab then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n\n{ function deg(a,b,modd:int64):int64; var i,j,t:int64; flag:boolean;\nbegin\n if b=0 then deg:=1 else\n begin\n if odd(b) then deg:=a*deg(a,b-1,modd) mod modd else\n begin t:=deg(a,b div 2,modd); deg:=t*t mod modd; end;\n end;\n\nend;\n }\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(a,b,c);\n for zad:=0 to 1000000 do\n begin\n flag:=true;\n for i:=0 to c do\n begin skach[i]:=b*(i+zad); smotr[i]:=a*i; end;\n for i:=c to c do if (skach[i]b then\n begin\n if (c*(a-b)/b)>trunc(c*(a-b)/b) then\n t:=trunc(c*(a-b)/b)+1\n else\n t:=trunc(c*(a-b)/b);\n end\n else\n t:=0;\n writeln(t);\nend.\n"}, {"source_code": "var a,b,c,time:longint;\n\n\nfunction check(time:longint):boolean;\nvar i,t:longint;\nbegin\n for t:= time to time+c do\n if t*b<(t-time)*a then\n begin\n check:=false;\n exit;\n end;\n check:=true;\nend;\n\n\nbegin\n readln(a,b,c);\n for time:= 0 to 1000000 do\n if check(time) then\n begin\n writeln(time);\n halt;\n end;\nend."}, {"source_code": "program aaa;\nVar a,b,c,i,al:longint;\nbegin\n readln(a,b,c);\n al:=(c*a+b-1) div b;\n for i:=1 to al do\n if al*b>=(al-i)*a\n then break;\n writeln(i);\nend."}, {"source_code": "var a,b,c:word;\nbegin\n read(a,b,c);\n write((c*a-1)div b+1-c)\nend."}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\n var\n a,b,c : integer;\n res : real;\n\nbegin\n read (a,b,c);\n res := c*(a - b)/b;\n if trunc (res) = res then writeln (trunc(res)) else\n writeln (trunc(res) + 1);\n end.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a,b,c:integer;\nd:real;\nbegin\n readln(a,b,c);\n d:=c*(a-b)/b;\n if (trunc(d)=d) then writeln(d:0:0)\n else writeln(trunc(d+1));\nend."}, {"source_code": "Uses SysUtils;\nVar\n a,b,c:Integer;\nBegin\n Read(a,b,c);\n If a*c mod b =0 Then Write(c*a div b-c)\n Else Write(trunc(a*c/b-c)+1);\nEnd.\n"}, {"source_code": "program projectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n aa,b,c,n,r : integer;\nbegin\nReadln(aa,b,c);\nn:=aa*c;\nr:=n div b;\nif n mod b >0 then r:=r+1;\nr:=r-c;\nWriteln(r);\nend.\n"}, {"source_code": "program Problem_A;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a, b, c: Integer;\n\nbegin\n Readln(a, b, c);\n Writeln(((a - b)*c + b - 1)div b);\nend.\n"}, {"source_code": "var\na,b,c,i:longint;\nd:boolean;\n\nprocedure readdata;\nbegin\nread(a,b,c);\ni:=1;\nd:=false;\nend;\n\nbegin\n readdata;\n while d=false do\n begin\n if (b-a)*c+i*b>=0 then d:=true;\n inc(i);\n end;\n writeln(i-1);\nend."}, {"source_code": "var\n t, t0, a, b, c: integer;\nbegin\n readln(a, b, c);\n t0 := (c * a + b - 1) div b;\n for t := 1 to t0 do \n if(t0 * b >= (t0 - t) * a) then break;\n writeln(t);\nend."}, {"source_code": "program Atask;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,b,c : integer;\nfunction ceil(x : real) : integer;\nbegin\n if x-trunc(x)<>0 then ceil:=trunc(x)+1 else ceil:=trunc(x);\nend;\nbegin\n readln(a,b,c);\n writeln(ceil((a*c-b*c)/b));\n readln;\nend.\n "}, {"source_code": "program zA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst nmax=1000;\n mmax=1000;\n eps=1E-10;\n inf=maxint;\n\n\ntype point = record\n x,y: int64;\n end;\n\nvar\n n, m: integer;\n s: string;\n a,b,c: integer;\n\nprocedure wrtn(s: string);\nbegin\n write(s);\n Halt(0);\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(a, b, c);\n\n write(trunc(a*c / b - c - 0.00001) + 1)\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a,b,c,res:int64;\n r:extended;\nbegin\n\n readln(a,b,c);\n\n\n if (b>=a)then writeln('0') else begin\n r:=c*(a-b)/b;\n res:=trunc(c*(a-b)/b) ;\n if (r>res) then writeln(res+1) else writeln(res);\n end;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n var a,b,c,t0,t,n:integer; bo:boolean;\nbegin\n readln(a,b,c);\n for t:=1 to a*c do\n begin\n bo:=true;\n n:=c+t;\n for t0:=t to n do\n if t0*b<(t0-t)*a then begin bo:=false; break; end;\n if bo=true then begin writeln(t); exit; end;\n end;\nend.\n"}], "negative_code": [{"source_code": "Program abc;\nVar right,left,a,b,c,sred,vsego,z:integer;\nBegin\nread(a,b,c);\nLeft:=0; Right:=1001; vsego:=a*c;\nWhile right-left>1 do \n begin z:=0;\n sred:=(right+left)div 2;\n for var x:=1 to C do\n begin If (sred*b+b*x>=vsego) then begin right:=sred; z:=1; break; end; end;\n If z=0 then left:=sred;\n end;\nWriteln(left+1);\nend."}, {"source_code": "Program abc;\nVar right,left,a,b,c,sred,vsego,z:longint;\nBegin\nread(a,b,c);\nLeft:=0; Right:=100000000000; vsego:=a*c;\nWhile right-left>1 do \n begin z:=0;\n sred:=(right+left)div 2;\n for var x:=1 to C do\n begin If (sred*b+b*x>=vsego) then begin right:=sred; z:=1; break; end; end;\n If z=0 then left:=sred;\n end;\nWriteln(left+1);\nend."}, {"source_code": "Program abc;\nVar right,left,a,b,c,sred,vsego,z:longint;\nBegin\nread(a,b,c);\nLeft:=0; Right:=100000001; vsego:=a*c;\nWhile right-left>1 do \n begin z:=0;\n sred:=(right+left)div 2;\n for var x:=1 to C do\n begin If (sred*b+b*x>=vsego) then begin right:=sred; z:=1; break; end; end;\n If z=0 then left:=sred;\n end;\nWriteln(left+1);\nend."}, {"source_code": "var n,m,d,kd,otv:integer;\nbegin\nreadln(n,m,d);\nkd:=(n-m)*d;\notv:=kd div m;\nif kd mod m<>0 then otv:=otv+1;\nend.\n\n"}, {"source_code": "var a,b,c,left,right,sred,obkol,kol,i:integer;\nbegin\nreadln(a,b,c);\nleft:=0;\nright:=1000;\nsred:=(left+right) div 2;\nobkol:=a*c;\nkol:=sred*b+c*b;\nwhile (right-left)>1 do begin\n if kol>=obkol then right:=sred\n else left:=sred;\n sred:=(left+right) div 2;\n kol:=sred*b+c*b;\n end;\nwriteln(right);\nend.\n"}, {"source_code": "program Project4;\n{$APPTYPE CONSOLE}\n\nuses sysutils,math;\n\nvar n,m,k,r,l,a,b,c: int64;\n i,j: longint;\n\n\nbegin\n read(a,b,c);\n l := 1;\n r := trunc((a*c) / b);\n while r-l > 1 do\n begin\n m := (l + r) DIV 2;\n n := a*c - m * b - c * b;\n if n > 0 then l := m else if n < 0 then r := m else begin write(m); exit end\n end;\n write(r);\nend."}, {"source_code": "var a,b,c, s, k: LongInt;\nbegin\n Readln(a,b,c);\n\n if b>=a then\n begin\n Writeln(0);\n halt(0);\n end;\n \n s:=a*c;\n \n if (s-b)b then max:=a; end;\n\nfunction nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\n function luck(a:longint):boolean;\n var i,j,k:longint;flag:boolean;\n c: array[0..10] of longint;\nbegin\n flag:=true; j:=0;\n k:=a;\n while k>0 do begin inc(j); c[j]:=k mod 10; k:= k div 10; {writeln(j,' uu ',k); } end;\n for i:=1 to j do if (c[i]<>4)and(c[i]<>7) then flag:=false;\n luck:=flag;\nend;\n\n\n{ function deg(a,b,modd:int64):int64; var i,j,t:int64; flag:boolean;\nbegin\n if b=0 then deg:=1 else\n begin\n if odd(b) then deg:=a*deg(a,b-1,modd) mod modd else\n begin t:=deg(a,b div 2,modd); deg:=t*t mod modd; end;\n end;\n\nend;\n }\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} read(a,b,c);\n for zad:=0 to 10000 do\n begin\n flag:=true;\n for i:=0 to c do\n begin skach[i]:=b*(i+zad); smotr[i]:=a*i; end;\n for i:=0 to c do if (skach[i]1 do\n begin\n m:=(L+r) div 2;\n if check(m) then r:=m\n else l:=m;\n end;\n if check(l) then writeln(l)\n else writeln(r);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,x,y,z:Int64;\nbegin\n Readln (i,j,k);\n y:=i*k;\n x:=y div j;\n// if i mod j >0 then inc (x);\n z:=x-k;\n Writeln (z);\n Readln\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,x,y,z:Int64;\nbegin\n Readln (i,j,k);\n y:=i*k;\n x:=y div j;\n if y mod j >(j-(j div 2)) then inc (x);\n z:=x-k;\n Writeln (z);\n Readln\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,x,y,z:Int64;\nbegin\n Readln (i,j,k);\n y:=i*k;\n x:=y div j;\n if i mod j >0 then inc (x);\n z:=x-k;\n Writeln (z);\n Readln\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,x,y,z:Int64;\nbegin\n Readln (i,j,k);\n y:=i*k;\n x:=y div j;\n if i mod j >(j+1 div 2) then inc (x);\n z:=x-k;\n Writeln (z);\n Readln\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i,j,k,x,y,z:Integer;\nbegin\n Readln (i,j,k);\n y:=i*k;\n x:=y div j;\n if i mod j >0 then inc (x);\n z:=x-k;\n Writeln (z);\n Readln\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a,b,c,t,f,s1,s2,i:Integer;\nBegin\n Read(a,b,c);\n For t:=1 To 2000 Do Begin\n f:=1;\n For i:=t To c+t Do Begin\n s1:=i*b;\n s2:=a*(i-t);\n If s11 then\n begin\n k:=(a*c)div b;\n if (k-b<=b)and(k-b>=1) then writeln(k-1)else writeln(k);\n end\n else writeln(a*b-c)\nend.\n"}, {"source_code": "var\n a,b,c,k,k1:longint;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n readln(a,b,c);\n if c>1 then\n begin\n k:=(a*c)div b;\n k1:=(a*c)-b;\n if (k*b-k1=1) then writeln(k-1)else writeln(k);\n end\n else writeln(a*c-b)\nend.\n"}, {"source_code": "var\n a,b,c,k:longint;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n readln(a,b,c);\n k:=(a*c)div(b*c)*c;\n if k>1 then writeln(k-1)else writeln(k);\nend.\n"}, {"source_code": "var\n a,b,c,k,k1:longint;\nbegin\n{ assign(input,'a.in');\n reset(input);\n assign(output,'a.out');\n rewrite(output);}\n readln(a,b,c);\n if c>1 then\n begin\n k:=(a*c)div b;\n k1:=(a*c)-b;\n if (k*b-k1=1) then writeln(k-1)else writeln(k);\n end\n else writeln(1)\nend.\n"}, {"source_code": "uses math;\nvar a,b,c:integer;\n i,res,dau,cuoi,m,t:longint;\nbegin\n readln(a,b,c);\n dau:=1; cuoi:=(a*c) div b; res:=1000;\n while dau <= cuoi do\n begin\n m:=(dau+cuoi) div 2;\n t:=m*b;\n for i:=1 to c do\n t:=t + b - a;\n if t >= 0 then \n begin\n res:=min(res,m); cuoi:=m - 1;\n end\n else dau:=m + 1;\n end;\n writeln(res);\nend."}, {"source_code": "uses math;\nvar a,b,c:integer;\n i,res,dau,cuoi,m,t:integer;\nbegin\n readln(a,b,c);\n dau:=1; cuoi:=(a*c) div b; res:=1000;\n while dau <= cuoi do\n begin\n m:=(dau+cuoi) div 2;\n t:=m*b;\n for i:=1 to c do t:=t + b - a;\n if t >= 0 then \n begin\n res:=min(res,m); cuoi:=m - 1;\n end\n else dau:=m + 1;\n end;\n writeln(res);\nend."}, {"source_code": "var\n i,j,n,m,k,a,b,c:longint;\nbegin\n readln(a,b,c);\n if a*c mod b=0 then writeln((a*c) div b+1)\n else writeln((a*c) div b);\nend."}, {"source_code": "var\n i,j,n,m,k,a,b,c:longint;\nbegin\n readln(a,b,c);\n k:=(a*c) div b;\n if (a*c mod b=0)and(a*c mod 2=0) then writeln(k div 2+1)\n else writeln(k div 2);\nend."}, {"source_code": "var\n i,j,n,m,k,a,b,c:longint;\nbegin\n readln(a,b,c);\n k:=(a*c) div b;\n if k=1 then writeln(k)\n else writeln(k-1);\nend."}, {"source_code": "var a,b,c,i,k,t,p:longint;\n ok:boolean;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=0 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) and (p<=t) do\n begin\n inc(p,a);\n inc(t,b);\n if p>t then begin ok:=false; break; end;\n if p=k then break;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,k,t,p:int64;\n ok:boolean;\n i:longint;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=1 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) do\n begin\n inc(p,a);\n inc(t,b);\n if p=k then break;\n if (p>t) then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,k,t,p:int64;\n ok:boolean;\n i:longint;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=1 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) do\n begin\n inc(p,a);\n inc(t,b);\n if (p=k) and (p<=t) then break;\n if (p>t) then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end.\n"}, {"source_code": "var a,b,c,i,k,t,p:longint;\n ok:boolean;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=0 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) and (p<=t) do\n begin\n inc(p,a);\n inc(t,b);\n if p>t then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,k,t,p:int64;\n ok:boolean;\n i:longint;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=1 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) do\n begin\n inc(p,a);\n inc(t,b);\n if p=t then break;\n if (p>t) then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,k,t,p:int64;\n ok:boolean;\n i:longint;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=0 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) and (p<=t) do\n begin\n inc(p,a);\n inc(t,b);\n if p>t then begin ok:=false; break; end;\n if p=k then break;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,i,k,t,p:longint;\n ok:boolean;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=0 to 1000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<>k) and (p<=t) do\n begin\n inc(p,a);\n inc(t,b);\n if p>t then begin ok:=false; break; end;\n end;\n if ok then begin writeln(i); halt; end;\n end;\n end."}, {"source_code": "var a,b,c,k,t,p:int64;\n ok:boolean;\n i:longint;\n begin\n read(a,b,c);\n k:=a*c;\n for i:=1 to 10000 do\n begin\n p:=0;\n t:=b*i;\n ok:=true;\n while (p<=k) and (p<=t) do\n begin\n inc(p,a);\n inc(t,b);\n if (p>t) and (t=0 then\n begin\n writeln(i);\n exit;\n end;\n end;\n end.\n"}, {"source_code": "const fin='';\n fout='';\nvar f,g:text;\n t,a,b,c:longint;\nbegin\n assign(f,fin); reset(f);\n assign(g,fout); rewrite(g);\n read(f,a,b,c);\n t:=c*(a-b);\n if t mod b<>0 then t:=t+b\n else if t>=a then t:=b;\n write(g,t div b);\n close(g);\nend.\n"}, {"source_code": "var a,b,c,d,e,n,i,t:longint;\nbegin\n read(a,b,c);\n d:=a*c;\n for t:=1 to 3000 do\n begin\n if ((c+t)*b>=d) then\n begin\n writeln(t);\n halt;\n end;\n end;\nend."}, {"source_code": "var a,b,c,d,e,n,i,t:longint;\nbegin\n read(a,b,c);\n d:=a*c;\n for t:=0 to 3000 do\n begin\n if ((c+t)*b>=d) then\n begin\n writeln(t);\n halt;\n end;\n end;\nend."}, {"source_code": "var a,b,c,j,i,x:longint;\n begin\n read(a,b,c);\n for i:=1 to 100000 do\n begin\n x:=i*b;\n for j:=1 to c do\n x:=x+b-a;\n if x>=0 then\n begin\n writeln(i);\n exit;\n end;\n end;\n end."}, {"source_code": "var n,m,len,i:longint;\n\nbegin\n readln(n,m,len);\n for i:=0 to 2000 do\n if (i+len)*m>=n*len then break;\n writeln(i);\nend.\n\n\n\n"}, {"source_code": "var a,b,c,s:longint;\nbegin\n readln(a,b,c);s:=1;\n while s*b+b*(c+1)<=a*c do inc(s);\n writeln(s);\nend."}, {"source_code": "var a,b,c,s:longint;\nbegin\n readln(a,b,c);s:=1;\n while s*b+b*(c+1)a div 2) then m:=1;\nfor d:=1 to t do\n if d*b>=t*b div 2 then\n begin\n write(d+m);\n break;\n end;\n\n//close(fo);\nend. "}, {"source_code": "program project4;\n\n\n\nvar\n a,b,c,d,X,Y,M,t: integer;\n fi,fo:text;\n st,st1:string;\n ch1,ch2:char;\n g:array[1..100] of integer;\nbegin\n //assign(fi,'input.txt');\n//assign(fo,'output.txt');\n//reset(fi);\n //rewrite(fo);\n\n read(a,b,c);\nwhile d<=a*c do\ninc(d,b);\nt:= d div b;\nif (a*c mod b > 0) and not(b>a div 2) then m:=1;\nfor d:=1 to t do\n if d*b>=t*b div 2 then\n begin\n write(d+m);\n break;\n end;\n\n//close(fo);\nend.\n"}, {"source_code": "var a,b,c:longint;\nbegin\n readln(a,b,c);\n writeln(c*a div b-1);\nend.\n"}, {"source_code": "var a,b,c:longint;\nbegin\n readln(a,b,c);\n if a=b+c then writeln(1) else writeln(c*a div b-1);\nend.\n"}, {"source_code": "var a,b,c:integer;\nbegin\nreadln(a,b,c);\nwriteln(trunc((a-b)*c/b));\nend."}, {"source_code": "var\n a,b,c,i:longint;\nfunction isok(i:longint):boolean;\nvar j:longint;\nbegin\n for j:=1 to c do \n if (b*i-(i-1)*a+b*ix do dec(j); \n if not(i>j) then \n begin \n y:=a[i];a[i]:=a[j];a[j]:=y; \n inc(i);dec(j); \n end; \n until i>j; \n if li)and(k<>j) then \n begin \n inc(cnt); \n b[cnt]:=a[k]; \n end; \n for k:=1 to n div 2-1 do \n ans1:=ans1+abs(b[k*2]-b[k*2-1]); \n if ans12 then\n begin\n for f:=1 to (2*n-i)div 2+1 do\n begin\n j:=i+2*f-1; if j>2*n then break;\n if j=2*n-1 then continue;\n k:=1; total:=0;\n while k<2*n do\n begin\n while (k=i)or(k=j) do k:=k+1;\n total:=total+a[k+1]-a[k];\n k:=k+2;\n end;\n if totalx do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n div 2 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1m[i+1] then\n begin\n c:=m[i];\n m[i]:=m[i+1];\n m[i+1]:=c;\n end;\n{for i:=1 to 2*n do write(m[i], ' '); \nwriteln;}\n \nfor a:=1 to 2*n-1 do\nfor b:=a+1 to 2*n do\n begin\n for i:=1 to 2*n do ar[i]:=m[i]; \n for i:=a downto 2 do\n begin\n c:=ar[i];\n ar[i]:=ar[i-1];\n ar[i-1]:=c;\n end;\n for i:=b to 2*n-1 do\n begin\n c:=ar[i];\n ar[i]:=ar[i+1];\n ar[i+1]:=c;\n end; \n {for i:=1 to 2*n do write(ar[i], ' '); \n writeln;} \n for i:=2 to 2*n-2 do\n if i mod 2=0 then otv:=otv+abs(ar[i]-ar[i+1]);\n if otvn*2+1 do\n if (i=a) or (i=b) then inc(i) else begin\n j:=i+1;\n while (j=a) or (b=j) do inc(j);\n temp:=temp+abs(w[i]-w[j]);\n i:=j+1;\n end;\n srav:=temp;\n end;\n\nbegin\n //assign(t,'input.txt');\n //reset(t);\n readln(n);\n for i:=1 to 2*n do read(w[i]);\n \n for i:=1 to 2*n do\n for j:=1 to 2*n-i do begin\n if w[j]>w[j+1] then swap(w[j],w[j+1]);\n end;\n //for i:=1 to 2*n do write(w[i],' ');\n //for i:=1 to n*2 do\n // for j:=1 to n*2 do p[i,j]:=abs(w[i]-w[j]);\n min:=55555555;\n for i:=1 to n*2 do\n for j:=1 to n*2 do if i<>j then if srav(i,j)x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;end;\nfor k:=1 to n div 2 do\nans1:=ans1 + abs(b[k*2] -b[k*2-1]);\nif ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n for k:=1 to n div 2 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans10)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n); ot:=besk;\n for i:=1 to 2*n do read(a[i]);\n for ii:=1 to 2*n do for jj:=ii+1 to 2*n do\n\n begin\n sum:=0;\n for i:=0 to 1000 do x[i]:=0;\n for i:=1 to 2*n do if (i<>ii)and(i<>jj) then inc(x[a[i]]);\n q:=0;\n for i:=0 to 1000 do for j:=1 to x[i] do\n begin\n inc(q); b[q]:=i;\n end;\n\n { writeln(ii,' ',jj);\n write('ostalos : ' );\n for i:=1 to q do write(b[i],' '); writeln;\n }\n for i:=1 to q do if odd(i) then sum:=sum+abs(b[i]-b[i+1]);\n\n ot:=min(sum,ot);\n end;\n\n writeln(ot);\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "uses Math;\n\nVar n, i, x, y, m, mi : longint;\n a, o : array [1..100] of longint;\n \nProcedure qSort(l,r:int64);\nvar i,j,w:int64;\n q:int64;\nbegin\n i := l; j := r;\n q := a[(l+r) div 2];\n repeat\n while (a[i] > q) do inc(i);\n while (q > a[j]) do dec(j);\n if (i <= j) then\n begin\n w:=a[i]; a[i]:=a[j]; a[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n Readln( n );\n For i:=1 to 2*n do\n Read( o[i] );\n \n m:=1000000;\n For x:=1 to 2*n-1 do\n For y:=x+1 to 2*n do\n begin\n a:=o;\n a[x]:=0;\n a[y]:=0;\n qSort(1,2*n);\n mi:=0;\n For i:=1 to n do\n mi:=mi+(a[2*i-1]-a[2*i]);\n if mi < m then m:=mi;\n end;\n Writeln( m );\nend."}, {"source_code": "var\n n,ans,i,j,cnt,k,ans1:longint;\n a,b:array[1..105] of longint;\nprocedure sort(l,r:longint);\nvar i,j,x,y:longint;\nbegin\n i:=l;j:=r;x:=a[(l+r) div 2];\n repeat\n while a[i]x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n div 2 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1a[j+1] then\n begin\n t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;\n end;\n min:=maxlongint;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n j1:=0; i1:=1;\n while (j1a[j+1] then\n begin\n t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;\n end;\n min:=maxlongint;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n j1:=0; i1:=1;\n while (j1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n div 3 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n for k:=1 to n div 2 do\n ans1:=min(ans1,abs(b[k*2]-b[k*2-1]));\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n do\n ans1:=ans1 + abs(b[k]-b[k-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n for k:=1 to n div 2 do\n ans1:=ans1 + abs(a[k*2]-a[k*2-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n do\n ans1:=ans1 + abs(b[k]-b[k-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n for k:=1 to n div 2 do\n ans1:=max(ans,abs(b[k*2]-b[k*2-1]));\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n-1 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1x do dec(j);\nif ij;\nif ij then sort(j,l);\nend;\nbegin\nread(n);\nn:=n*2; ans:=maxlongint;\nfor i:=1 to n do\nsort(1,n);\nfor i:=1 to n-1 do\nfor j:=i+1 to n do begin\ncnt:=0; ans1:=0;\nfor k:=1 to n do\nif (k<>i) and (k<>j) then\nbegin\ninc(cnt);\nb[cnt]:=a[k];\nend;end;\nfor k:=1 to n div 2 do\nans1:=ans1 + abs(b[k*2] -b[k*2-1]);\nif ans1x do dec(j);\nif ij;\nif ij then sort(j,l);\nend;\nbegin\nread(n);\nn:=n*2; ans:=maxlongint;\nfor i:=1 to n do\nsort(1,n);\nfor i:=1 to n-1 do\nfor j:=i+1 to n do begin\ncnt:=0; ans1:=0;\nfor k:=1 to n do\nif (k<>i) and (k<>j) then\nbegin\ninc(cnt);\nb[cnt]:=a[k];\nend;end;\nfor k:=1 to n div 2 do\nans1:=ans1 + (b[k*2] -b[k*2-1]);\nif ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n for k:=1 to n div 2 do\n ans1:=max(ans1,abs(b[k*2]-b[k*2-1]));\n if ans1x do dec(j);\n\tif ij;\n\tif lx then sort(x,m);\n\tend;\nbegin\n\tread(n); ans:=maxlongint;\n\tfor i:=1 to n do read(a[i]);\n\tcnt:=0; ans1:=0;\n\tfor k:=1 to n do\n\tif (k<>i) and (k<>j) then\n\t\tbegin\n\t\tinc(cnt);\n\t\tb[cnt]:=a[k];\n\t\tend;\n\tfor k:=1 to n do\n\tans1:=ans1+(b[k]-b[k-1]);\n\tif ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n-1 do\n ans1:=ans1 + abs(b[k]-b[k-1]);\n if ans1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n div 2 do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1x do dec(j);\nif ij;\nif ij then sort(j,l);\nend;\nbegin\nread(n);\nn:=n*2; ans:=maxlongint;\nfor i:=1 to n do\nsort(1,n);\ncnt:=0; ans1:=0;\nfor k:=1 to n do\nif (k<>i) and (k<>j) then\nbegin\ninc(cnt);\nb[cnt]:=a[k];\nend;\nfor k:=1 to n div 2 do\nans1:=ans1 + (b[k*2] -b[k*2-1]);\nif ans1n*2+1 do\n if (i=a) or (i=b) then inc(i) else begin\n j:=i+1;\n while (j=a) or (b=j) do inc(j);\n temp:=temp+abs(w[i]-w[j]);\n i:=j+1;\n end;\n srav:=temp;\n end;\n\nbegin\n //assign(t,'input.txt');\n //reset(t);\n readln(n);\n for i:=1 to 2*n do read(w[i]);\n \n {for i:=1 to 2*n do\n for j:=1 to 2*n-i do begin\n if w[j]>w[j+1] then swap(w[j],w[j+1]);\n end;}\n //for i:=1 to 2*n do write(w[i],' ');\n //for i:=1 to n*2 do\n // for j:=1 to n*2 do p[i,j]:=abs(w[i]-w[j]);\n min:=55555555;\n for i:=1 to n*2 do\n for j:=1 to n*2 do if i<>j then if srav(i,j)n*2+1 do\n if (i=a) or (i=b) then inc(i) else begin\n j:=i+1;\n while (j=a) or (b=j) do inc(j);\n temp:=temp+abs(w[i]-w[j]);\n i:=j+1;\n end;\n srav:=temp;\n end;\n\nbegin\n //assign(t,'input.txt');\n //reset(t);\n readln(n);\n for i:=1 to 2*n do read(w[i]);\n \n for i:=1 to 2*n do\n for j:=1 to 2*n-i do begin\n if w[j]>w[j+1] then swap(w[j],w[j+1]);\n end;\n //for i:=1 to 2*n do write(w[i],' ');\n //for i:=1 to n*2 do\n // for j:=1 to n*2 do p[i,j]:=abs(w[i]-w[j]);\n min:=555555555;\n for i:=1 to n*2 do\n for j:=1 to n*2 do if i<>j then if srav(i,j)a[j+1] then\n begin\n t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;\n end;\n min:=maxlongint;\n for i:=1 to n do\n for j:=i+1 to n do\n begin\n j1:=0; i1:=1;\n while (j1x do dec(j);\n if not(i>j) then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if li) and (k<>j) then\n begin\n inc(cnt);\n b[cnt]:=a[k];\n end;\n end;\n for k:=1 to n do\n ans1:=ans1 + abs(b[k*2]-b[k*2-1]);\n if ans1 y[j])))) then\n result := true\n else\n result := false;\nend;\n\nprocedure sort(l, r: longint);\nvar\n i, j: longint;\nbegin\n i := l;\n j := r;\n x[0] := x[(l + r) div 2];\n y[0] := y[(l + r) div 2];\n repeat\n while compare(i, 0) do inc(i);\n while compare(0, j) do dec(j);\n if i <= j then begin\n swap(i, j);\n inc(i);\n dec(j);\n end;\n until i > j;\n if i < r then\n sort(i, r);\n if l < j then\n sort(l, j);\nend;\n\nfunction dist(i, j: longint): int64;\nbegin\n result := abs(x[i] - x[j]) + abs(y[i] - y[j]);\nend;\n\nbegin\n read(n);\n for i := 1 to n do\n read(x[i], y[i]);\n\n sort(1, n);\n\n x[0] := 0;\n y[0] := 0;\n\n Lvl[0].l := 0;\n Lvl[0].r := 0;\n LvlCount := 1;\n Lvl[LvlCount].l := 1;\n for i := 2 to n do\n if max(x[i], y[i]) > max(x[i - 1], y[i - 1]) then begin\n with Lvl[LvlCount] do begin\n r := i - 1;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n inc(LvlCount);\n Lvl[LvlCount].l := i;\n end;\n\n with Lvl[LvlCount] do begin\n r := n;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n\n l[0] := 0;\n r[0] := 0;\n for i := 1 to LvlCount do begin\n l[i] := min(l[i - 1] + Lvl[i].d[2], r[i - 1] + Lvl[i].d[4]) + Lvl[i].len;\n r[i] := min(l[i - 1] + Lvl[i].d[1], r[i - 1] + Lvl[i].d[3]) + Lvl[i].len;\n end;\n\n write(min(l[LvlCount], r[LvlCount]));\nend.\n", "positive_code": [{"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p+1 do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n { writeln('step= ',j);\n }\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n writeln;\n }\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p+1 do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n { writeln('step= ',j);\n }\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n writeln;\n }\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}], "negative_code": [{"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n }\n\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n }\n\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(max(ddleft[q],ddleft[q-1]),max(ddright[q],ddright[q-1])));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n }\n\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p+1 do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n { writeln('step= ',j);\n }\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n writeln;\n }\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n }\n\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(max(ddleft[q],ddleft[q-1]),max(ddright[q],ddright[q-1])));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=8000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\n point=record x,y:int64 end;\n point1=^point;\n otr=record st,fin:point end;\nvar mask,kol1,stepp,mm,lavel,l,kol,dl,i1,j1,imin,step,i,j,k,m,n1,k1,w,mesto,pl1,pl2,pl3:longint;\nlen,t14,t24,t23,t13,p2,p3,p4,ttt,p1,ii,jj,kk,sum,pos1,pos2,tt,ans1,ans2,t,pp,ans,qq,ott,n,cc,nn,modul,p,ot,pmin,tmax,minf,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10..3000000] of int64;\nddleft,ddright:array[-100000..500000] of int64;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nxx,yy,x1,y1,x,y,mnog,stepen:array[-1000000..1000000] of int64;\nleft,right,zz,ll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[i]=p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n { for i:=1 to p do writeln(a[i],' ',a1[i]);\n } for i:=1 to p do b[a1[i]]:=i;\n for i:=1 to p do\n begin xx[i]:=x[a1[i]]; yy[i]:=y[a1[i]]; end;\n\n { for i:=1 to p do writeln(xx[i],' ',yy[i]);\n }\n for i:=1 to p do if max(xx[i],yy[i])>max(xx[i-1],yy[i-1]) then\n begin inc(q); z[q]:=i; end;\n inc(q); z[q]:=p+1;\n { for i:=1 to q do write(z[i],' ');\n writeln;\n }\n for i:=1 to q do\n begin\n { writeln('lavel= ',i);\n for j:=z[i-1] to z[i]-1 do writeln('j= ',j,' point ',xx[j],' ',yy[j]);\n }\n\n end;\n\n\n for i:=2 to p do begin ddleft[i]:=besk; ddright[i]:=besk; end;\n\n for j:=2 to q do\n begin\n p1:=z[j-1]; p2:=z[j]-1;\n p3:=z[j-2]; p4:=z[j-1]-1;\n\n len:= abs(xx[p1]-xx[p2])+abs(yy[p1]-yy[p2]);\n t14:=abs(xx[p1]-xx[p4])+abs(yy[p1]-yy[p4]);\n t13:=abs(xx[p1]-xx[p3])+abs(yy[p1]-yy[p3]);\n\n t24:=abs(xx[p2]-xx[p4])+abs(yy[p2]-yy[p4]);\n t23:=abs(xx[p2]-xx[p3])+abs(yy[p2]-yy[p3]);\n\n { writeln(len,' t14= ',t14,' t13= ',t13,' t24= ',t24,' t23= ',t23);\n }\n\n\n\n\n ddleft[j]:=min(ddleft[j],len+ddleft[j-1]+t23);\n ddleft[j]:=min(ddleft[j],len+ddright[j-1]+t24);\n\n ddright[j]:=min(ddright[j],len+ddleft[j-1]+t13);\n ddright[j]:=min(ddright[j],len+ddright[j-1]+t14);\n\n\n\n { writeln('j= ',j,' ', ddleft[j],' ',ddright[j]);\n }\n end;\n\n writeln(min(ddleft[q],ddright[q]));\n\n\n\n\n 1: close (output);\nend.\n"}, {"source_code": "program ProjectF;\n\nuses\n Math;\n\ntype\n TLvl = record\n l, r, len: longint;\n d: array[1..4] of longint;\n end;\n\nvar\n n, i, LvlCount: longint;\n x, y, l, r: array[0..200000] of longint;\n Lvl: array[0..200000] of Tlvl;\n\nprocedure swap(var i, j: longint);\nvar\n d: longint;\nbegin\n d := x[i];\n x[i] := x[j];\n x[j] := d;\n d := y[i];\n y[i] := y[j];\n y[j] := d;\nend;\n\nfunction compare(i, j: longint): boolean;\nbegin\n if (max(x[i], y[i]) < max(x[j], y[j])) or ((max(x[i], y[i]) = max(x[j], y[j])) and ((x[i] < x[j]) or ((x[i] = x[j]) and (y[i] > y[j])))) then\n result := true\n else\n result := false;\nend;\n\nprocedure sort(l, r: longint);\nvar\n i, j, tx, ty: longint;\nbegin\n i := l;\n j := r;\n x[0] := x[(l + r) div 2];\n y[0] := y[(l + r) div 2];\n repeat\n while compare(i, 0) do inc(i);\n while compare(0, j) do dec(j);\n if i <= j then begin\n swap(i, j);\n inc(i);\n dec(j);\n end;\n until i > j;\n if i < r then\n sort(i, r);\n if l < j then\n sort(l, j);\nend;\n\nfunction dist(i, j: longint): longint;\nbegin\n result := abs(x[i] - x[j]) + abs(y[i] - y[j]);\nend;\n\nbegin\n read(n);\n for i := 1 to n do\n read(x[i], y[i]);\n\n sort(1, n);\n\n x[0] := 0;\n y[0] := 0;\n\n Lvl[0].l := 0;\n Lvl[0].r := 0;\n LvlCount := 1;\n Lvl[LvlCount].l := 1;\n for i := 2 to n do\n if max(x[i], y[i]) > max(x[i - 1], y[i - 1]) then begin\n with Lvl[LvlCount] do begin\n r := i - 1;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n inc(LvlCount);\n Lvl[LvlCount].l := i;\n end;\n\n with Lvl[LvlCount] do begin\n r := n;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n\n l[0] := 0;\n r[0] := 0;\n for i := 1 to LvlCount do begin\n l[i] := min(l[i - 1] + Lvl[i].d[2], r[i - 1] + Lvl[i].d[4]) + Lvl[i].len;\n r[i] := min(l[i - 1] + Lvl[i].d[1], r[i - 1] + Lvl[i].d[3]) + Lvl[i].len;\n end;\n\n write(min(l[LvlCount], r[LvlCount]));\nend.\n"}, {"source_code": "program ProjectF;\n\nuses\n Math;\n\ntype\n TLvl = record\n l, r, len: longint;\n d: array[1..4] of longint;\n end;\n\nvar\n n, i, LvlCount: longint;\n x, y, l, r: array[0..200000] of longint;\n Lvl: array[0..200000] of Tlvl;\n\nprocedure swap(var i, j: longint);\nvar\n d: longint;\nbegin\n d := x[i];\n x[i] := x[j];\n x[j] := d;\n d := y[i];\n y[i] := y[j];\n y[j] := d;\nend;\n\nfunction compare(i, j: longint): boolean;\nbegin\n if (max(x[i], y[i]) < max(x[j], y[j])) or ((max(x[i], y[i]) = max(x[j], y[j])) and ((x[i] < x[j]) or ((x[i] = x[j]) and (y[i] > y[j])))) then\n result := true\n else\n result := false;\nend;\n\nprocedure sort(l, r: longint);\nvar\n i, j, m: longint;\nbegin\n i := l;\n j := r;\n m := (l + r) div 2;\n repeat\n while compare(i, m) do inc(i);\n while compare(m, j) do dec(j);\n if i <= j then begin\n swap(i, j);\n inc(i);\n dec(j);\n end;\n until i > j;\n if i < r then\n sort(i, r);\n if l < j then\n sort(l, j);\nend;\n\nfunction dist(i, j: longint): longint;\nbegin\n result := abs(x[i] - x[j]) + abs(y[i] - y[j]);\nend;\n\nbegin\n x[0] := 0;\n y[0] := 0;\n\n read(n);\n for i := 1 to n do\n read(x[i], y[i]);\n\n sort(1, n);\n\n Lvl[0].l := 0;\n Lvl[0].r := 0;\n LvlCount := 1;\n Lvl[LvlCount].l := 1;\n for i := 2 to n do\n if max(x[i], y[i]) > max(x[i - 1], y[i - 1]) then begin\n with Lvl[LvlCount] do begin\n r := i - 1;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n inc(LvlCount);\n Lvl[LvlCount].l := i;\n end;\n\n with Lvl[LvlCount] do begin\n r := n;\n len := dist(l, r);\n d[1] := dist(Lvl[LvlCount - 1].l, l);\n d[2] := dist(Lvl[LvlCount - 1].l, r);\n d[3] := dist(Lvl[LvlCount - 1].r, l);\n d[4] := dist(Lvl[LvlCount - 1].r, r);\n end;\n\n l[0] := 0;\n r[0] := 0;\n for i := 1 to LvlCount do begin\n l[i] := min(l[i - 1] + Lvl[i].d[2], r[i - 1] + Lvl[i].d[4]) + Lvl[i].len;\n r[i] := min(l[i - 1] + Lvl[i].d[1], r[i - 1] + Lvl[i].d[3]) + Lvl[i].len;\n end;\n\n write(min(l[LvlCount], r[LvlCount]));\nend.\n"}], "src_uid": "06646a9bdce2d65e92e525e97b2c975d"} {"source_code": "program cf736B;\nvar n:longint;\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to x-1 do\n begin\n if i*i>x then exit(true);\n if x mod i=0 then exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n if prime(n) then write(1)\n else if n mod 2=0 then write(2)\n else if prime(n-2) then write(2)\n else write(3);\nend.\n", "positive_code": [{"source_code": "var\n n:longint;\nfunction pd(k:longint):boolean;\nvar\n i:longint;\nbegin\n for i:=2 to trunc(sqrt(k)) do\n if k mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n read(n);\n if n<3 then writeln(1)\n else if not odd(n) then writeln(2)\n else\n begin\n if pd(n) then writeln(1)\n else if not pd(n-2) then writeln(3)\n else writeln(2);\n end;\nend."}, {"source_code": "var \n a,n,i:longint;\n t:boolean;\nbegin\n readln(n);\n if(n=1)or(n=2)then writeln(1)else \n if(n mod 2=0)then writeln(2)else\n begin\n a:=trunc(sqrt(n));\n for i:=2 to a do \n if(n mod i)=0then \n begin \n t:=true;\n break\n end;\n if not t then \n begin \n writeln('1'); \n halt\n end;\n t:=false;\n dec(n,2);\n a:=trunc(sqrt(n));\n for i:=2 to a do \n if (n)mod i=0 then \n begin \n t:=true; \n break\n end;\n if t then \n writeln(3) else writeln(2);\n end\nend."}, {"source_code": "var n:int64;\nfunction p(x:int64):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\nreadln(n);\nif p(n) then writeln(1)\nelse if n mod 2=0 then writeln(2)\nelse if p(n-2) then writeln(2)\nelse writeln(3);\nend."}, {"source_code": " program z1;\n var n,c:int64;\n i:longint;\n begin\n readln(n);\n case n of \n 2:writeln(1);\n 3:writeln(1);\n 4:writeln(2);\n 5:writeln(1);\n 6:writeln(2);\n 7:writeln(1);\n 8:writeln(2);\n 9:writeln(2);\n end;\n if n>=10 then begin\n for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then c:=1;\n if c=0 then begin\n writeln(1);\n exit;\n end;\n if n mod 2=0 then begin writeln(2);\n exit;\n end;\n n:=n-2;\n c:=0;\n for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then c:=1;\n if c=0 then begin\n writeln(2);\n exit;\n end;\n writeln(3);\n end;\n \n end."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor i:=2 to round(sqrt(n)) do\n begin\n if n mod i=0 then a:=1;\n end;\nif a=0 then begin write('1'); exit; end;\ndec(n,2);\na:=0;\nfor i:=2 to round(sqrt(n)) do\n begin\n if n mod i=0 then a:=1;\n end;\nn:=n+2;\nif (n mod 2=0) or (a=0) then write('2') else write('3');\nend."}, {"source_code": "var n:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'taxes.in');reset(input);\n//assign(output,'taxes.out');rewrite(output);\nreadln(n);\nif(n mod 2=0)and(n<>2)then writeln(2)\nelse\nif pd(n)then writeln(1)\nelse\nif pd(n-2)then writeln(2)\nelse\n writeln(3);\nclose(input);close(output);\nend."}, {"source_code": "var n:int64;\nfunction pd(x:int64):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'taxes.in');reset(input);\n//assign(output,'taxes.out');rewrite(output);\nreadln(n);\nif pd(n) then writeln(1)\nelse if n mod 2=0 then writeln(2)\nelse if pd(n-2) then writeln(2)\nelse writeln(3);\nclose(input);close(output);\nend."}, {"source_code": "var n:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'gdbhcx.in');reset(input);\n//assign(output,'gdbhcx.out');rewrite(output);\nreadln(n);\nif pd(n)then\n begin\n writeln(1);\n close(input);close(output);halt;\n end;\nif(n mod 2=0)and(n>2)then writeln(2)\nelse begin\n if pd(n-2) then writeln(2)\n else writeln(3);\n end;\nclose(input);close(output);\nend."}, {"source_code": "var n:longint;\nfunction pd(x:longint):boolean;\nvar i:longint;\nbegin\nif x<2 then exit(false);\nfor i:=2 to trunc(sqrt(x))do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'ss.in');reset(input);\n//assign(output,'ss.out');rewrite(output);\nreadln(n);\nif pd(n) then writeln(1) else\nif(n mod 2=0)or(pd(n-2))then writeln(2) else writeln(3);\nclose(input);close(output);\nend.\n"}, {"source_code": "const\n fi = 'DDD.inp';\n fo = 'DDD.out';\n\nvar\n n:longint;\n\nfunction check(x:longint):boolean;\nvar\n i:longint;\nbegin\n if x < 2 then exit(false);\n if x = 2 then exit(true);\n for i := 2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n\n exit(true);\nend;\n\nbegin\n read(n);\n if check(n) then writeln(1) else\n if (n mod 2 = 0) and (n > 2) then writeln(2) else\n if (n mod 2 = 1) and (check(n-2)) then writeln(2) else writeln(3);\nend.\n"}, {"source_code": "var i,j,n,m,k,o,s:longint;\nfunction aaa(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n if aaa(n) then write(1)\n else if (aaa(n-2))or(n mod 2=0) then write(2)\n else write(3);\nend."}, {"source_code": "const\n prime:array[1..14]of longint=(2,3,5,7,11,13,17,19,37,43,67,73,97,101);\nvar\n n:int64;\nfunction cf(n,m,p:int64):int64;\nvar\n ans:int64;\nbegin\n ans:=0;\n while (m<>0) do\n begin\n if (m and 1<>0) then\n ans:=(ans+n) mod p;\n m:=m shr 1;\n n:=(n shl 1)mod p;\n end;\n exit(ans);\nend;\nfunction ksm(x,y,p:int64):int64;\nvar\n b:int64;\nbegin\n if y=1 then\n exit(x mod p);\n b:=ksm(x,y div 2,p);\n if odd(y) then\n exit(cf(b,b,p) mod p*x mod p) else\n exit(cf(b,b,p) mod p);\nend;\nfunction Miller_Rabin(n:int64):boolean;\nvar\n i,j,t:longint;\n u,now,res:int64;\nbegin\n Miller_Rabin:=true;\n for i:=1 to 5 do\n begin\n if n=prime[i] then\n exit(true);\n if n mod prime[i]=0 then\n exit(false);\n end;\n if n=1 then\n exit(false);\n u:=n-1;\n t:=0;\n while u mod 2=0 do\n begin\n u:=u >> 1;\n inc(t);\n end;\n for i:=1 to 5 do\n begin\n now:=ksm(prime[i],u,n);\n for j:=1 to t do\n begin\n res:=cf(now,now,n);\n if (res=1) and (now<>1) and (now<>n-1) then\n exit(false);\n now:=res;\n end;\n if now<>1 then\n exit(false);\n end;\nend;\nbegin\n readln(n);\n if n=1 then\n writeln(1) else\n if Miller_Rabin(n) then\n writeln(1) else\n if not odd(n) then\n writeln(2) else\n if Miller_Rabin(n-2) then\n writeln(2) else\n writeln(3);\nend."}, {"source_code": "Program ILoveYou;\nVAR n:int64;\n\nfunction Prim(x : int64) : boolean;\nVAR i:int64;\nBegin\n\nPrim:=true;\ni:=2;\nwhile (i <= sqrt(x)) do\nBegin\nif ((x mod i) = 0) then Begin Prim:=false; i:=x; end;\ni:=i + 1;\nend;\n\nend;\n\nBegin\n\nReadln(n);\nif Prim(n) then Writeln(1) else\nBegin\n\nif ((n mod 2) = 0) then Writeln(2) else\nBegin\n\nif (Prim(n - 2)) then Writeln(2) else Writeln(3);\n\n\nend;\n\nend;\n\nReadln;\nEND."}, {"source_code": "var n,i:longint;\n fl:boolean;\nbegin\n read(n);\n \n for i:=2 to round(sqrt(n)) do\n if n mod i = 0\n then begin fl:=true;break;end;\n if not fl\n then write(1)\n else begin\n if n mod 2 = 0\n then begin write(2);halt;end;\n n:=n-2;\n fl:=false;\n for i:=2 to round(sqrt(n)) do\n if n mod i = 0\n then begin fl:=true;break;end;\n if fl\n then write(3)\n else write(2);\n end;\n \n\n\nend."}, {"source_code": "var d,x,ot,x2:int64;\nfunction pr(x:int64):boolean;\nvar d:int64;\nbegin\nif x mod 2 =0 then pr:=(x=2)\n else\n begin\n d:=3;\n while (d*d<=x)and(x mod d <>0) do\n d:=d+2;\n pr:=(d*d>x)and(x<>1);\nend;\nend;\nbegin\nreadln(x);\n\n\nif pr(x) then writeln(1) else begin\nif (x mod 2=1) and (x>5) and (pr(x-2)) then writeln(2) else\nif (x mod 2=0) and (x>2) then writeln(2) else\nif (x mod 2=1) and (x>5) then writeln(3) else\nif (x=2) then writeln(1) else\nif (x=3) then writeln(1) else\nif (x=5) then writeln(1);\nend;\nEnd."}, {"source_code": "var n,i:longint;\n fl:boolean;\nbegin\n read(n);\n \n for i:=2 to round(sqrt(n)) do\n if n mod i = 0\n then begin fl:=true;break;end;\n if not fl\n then write(1)\n else begin\n if n mod 2 = 0\n then begin write(2);halt;end;\n n:=n-2;\n fl:=false;\n for i:=2 to round(sqrt(n)) do\n if n mod i = 0\n then begin fl:=true;break;end;\n if fl\n then write(3)\n else write(2);\n end;\n \n\n\nend."}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;\n i1,j1,k1, step, i,j:longint;\n aanew,bbnew:extended;\n ss:string;\n s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;\n ddminus, ppole:array[-1..2000,-1000..1502] of int64;\n text,text1,text2:array[-10..2000000] of char;\n ss1,ss2:string;\n ddd,dd:array[-1..40000,-1..10] of int64;\n marked:array[-100000..500000] of boolean;\n sss:string;ch:char;\n pole :array [-10..500,-10..500] of char;\n st2:array[0..nn] of string;\n v0,v1,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction koll(pp:longint):longint;\nlabel 43;\n var ot,i,t:longint;\naanew:extended; flag:boolean;\nbegin\n flag:=true;\n aanew:=pp; aanew:=sqrt(aanew);\n t:=round(aanew+0.01);\n for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;\n { writeln(flag);\n }\n if flag then begin ot:=1; goto 43; end;\n if odd(pp) then begin ot:=3; goto 43; end;\n if not odd(pp) then begin ot:=2; goto 43; end;\n43:\n koll:=ot;\nend;\n\nfunction prost(pp:longint):boolean;\nvar i:longint;flag:boolean;\n begin\n flag:=true;\n for i:=2 to min(pp-1,100000) do\n if pp mod i=0 then flag:=false;\n\n prost:=flag;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n { for i:=2 to 30 do writeln(i,' ',koll(i));\n\n\n\n for i:=2000000002 to 2000000010 do writeln(i,' ',koll(i));\n }\n\n { for i:=2 to 100 do if prost(i) then write(i,' ');\n writeln;\n }\n read(pp);\n if prost(pp-2) then tt:=2 else tt:=3;\n writeln(min(koll(pp),tt));\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) or (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction prost (a:longword):boolean;\nvar i:longint; flag:boolean;\nbegin \nflag:=true;\n for i:=2 to trunc(sqrt(a)) do \n if a mod i = 0 then begin flag:=false; break; end;\n prost:=flag;\nend;\n\n\nvar n,k,c,a,b:int64;\nbegin\n read(n);\n if prost(n) then writeln(1) else\n if n mod 2 = 0 then writeln(2) else\n if prost(n-2) then writeln(2) else\n writeln(3);\n readln;\n readln;\nend."}, {"source_code": "program nalogi;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n w : boolean;\n n, i, res : integer;\n \nbegin\n readln ( n );\n\n w := true;\n i := 3;\n\n if ( n = 2 ) then\n w := true\n else\n if ( n mod 2 <> 0 ) then\n while ( i <= trunc ( sqrt ( n ) ) ) do begin\n if ( n mod i = 0 ) then begin\n w := false;\n break;\n end;\n inc ( i, 2 );\n end\n else\n w := false;\n\n if ( w ) then\n res := 1\n else\n if ( n mod 2 = 0 ) then\n res := 2\n else begin\n w := true;\n i := 3;\n dec ( n, 2 );\n while ( i <= trunc ( sqrt ( n ) ) ) do begin\n if ( n mod i = 0 ) then begin\n w := false;\n break;\n end;\n inc ( i, 2 );\n end;\n if ( w ) then\n res := 2\n else\n res := 3;\n end;\n \n writeln ( res );\n \n readln;\nend.\n"}, {"source_code": "program payment;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n: integer;\n\nfunction nal(n: integer): boolean;\nvar\n i: integer;\nbegin\n if ((n mod 2 = 0) and (n <> 2)) then begin\n result := false;\n exit;\n end;\n i := 3;\n while (i <= trunc(sqrt(n))) do begin\n if (n mod i = 0) then begin\n result := false;\n exit;\n end;\n inc(i, 2);\n end;\n result := true;\nend;\n\nbegin\n readln(n);\n if (nal(n)) then\n writeln(1)\n else\n if ((nal(n - 2)) or (n mod 2 = 0)) then\n writeln(2)\n else\n writeln(3); \n readln;\n readln;\nend.\n "}, {"source_code": "var\n n:longint;\nfunction ss(n:longint):boolean;\n var\n i:longint;\n p:boolean;\n begin\n p:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false;break;end;\n if n=1 then p:=false;\n exit(p);\n end;\nbegin \n read(n);\n if ss(n) then writeln(1)\n else if (n mod 2=0) or (ss(n-2)) then writeln(2)\n else writeln(3);\nend.\n "}, {"source_code": "var\n i,n:longint;\nfunction zs(a:longint):longint;\nvar\n i:longint;\nbegin\n for i:=2 to trunc(sqrt(a)) do\n if a mod i=0 then exit(0);\n exit(1);\nend;\nbegin\n read(n);\n if (zs(n)=1)then write(1)\n else\n if (n mod 2=0)then write(2)\n else\n if zs(n-2)=1 then write(2)\n else\n write(3);\n\nend."}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n if k=1 then begin\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\n end;\nend."}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n readln(n);\n if (n=1)or(n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);exit;end;\n for i:=2 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then begin writeln(3);exit;end;\n writeln(2);\n end;\nend."}, {"source_code": "var n:longint;\nfunction prost(x:int64):boolean;\nvar d:longint;\nbegin\nif x mod 2 =0 then prost:=(x=2)\n else\n begin\n d:=3;\n while (d*d<=x)and(x mod d <>0) do\n d:=d+2;\n prost:=(x>1)and(d*d>x);\n\nend;\nend;\nbegin\n readln(n);\nif prost (n) then writeln(1) \nelse \n if (n mod 2=1) and (n>5) and (prost(n-2)) then writeln(2) \n else\n if (n mod 2=0) and (n>2) then writeln(2) \n else\n if (n mod 2=1) and (n>5) then writeln(3) \n \n end."}, {"source_code": "var\np,n,i:longint;\nbol:boolean;\nbegin\nreadln(n);\nif n =2 then writeln(1)\nelse begin\nif n mod 2 = 0 then writeln(2)\nelse begin\nbol:=true;\n for i:=2 to round(sqrt(n)) do if n mod i = 0 then bol:=false;\n if bol then writeln(1)\n else begin\n bol:=true;\n p:=n-2;\n for i:=2 to round(sqrt(p)) do if p mod i = 0 then bol:=false;\n if bol then writeln(2)\n else\n writeln(3);\n \n end;\nend;\nend;\nend."}, {"source_code": "var n : longint; { изначальная сумма }\n\n{ определние простоты числа }\nfunction isprime(n : longint) : Boolean;\nvar d : longint;\nbegin\nisprime:=true;\nd:=2;\n\twhile d*d<=n do begin\n\tif n mod d=0 then begin isprime:=false; break; end;\n Inc(d);\n end;\nend;\n\nbegin\nreadln(n);\nif isprime(n) then writeln(1) { если простое, то налог - 1 }\nelse if (n mod 2 = 0) or (isprime(n-2)) { четное можно представить как два простых (гипотеза Гольдбаха) }\nthen writeln(2) { нечетное можно, если оно имеет вид 2+p, где p - простое, налог - 2 }\nelse writeln(3); { нечетные можно представить как n=n-3+3, n-3 четное, 3 простое, налог - 3 }\nend.\n"}, {"source_code": "var n:longint;\nprocedure check;\nvar f,i:longint;\nbegin\n f:=0;\n for i:=2 to round(sqrt(n)) do\n if n mod i=0 then begin f:=1; break; end;\n if f=0 then begin write(1); halt; end;\n if n mod 2=1 then begin\n f:=0;\n for i:=2 to round(sqrt(n-2)) do\n if (n-2) mod i=0 then begin f:=1; break; end;\n if f=0 then begin write(2); halt; end;\n end;\nend;\nbegin\nread(n);\ncheck;\nwrite(2+n mod 2);\nend.\n"}, {"source_code": "var\n n,m,i: longint;\n f: boolean;\nbegin\n readln(n);\n\n for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then\n begin\n f:=true;\n break;\n end;\n\n if not f then begin writeln(1); halt; end;\n\n f:=false;\n if not odd(n) then writeln(2) else\n begin\n for i:=2 to trunc(sqrt(n-2)) do if (n-2) mod i = 0 then\n begin\n f:=true;\n break;\n end;\n\n if not f then writeln(2) else writeln(3);\n end;\nend.\n"}, {"source_code": "\nvar n:int64;\n res:longint;\nprocedure nhap;\n begin\n readln(n);\n end;\nfunction kiemtra(x:int64):boolean;\n var i:longint;\n begin\n if x<4 then exit(true);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\n end;\nprocedure xuli;\n begin\n if kiemtra(n) then res:=1\n else if n mod 2=0 then res:=2\n else\n if kiemtra(n-2) then res:=2\n else res:=3;\n end;\nprocedure ghi;\n begin\n writeln(res);\n end;\nBEGIN\n nhap;\n xuli;\n ghi;\nEND."}, {"source_code": "var n,i:int64;\n\nfunction fun(n:longint):boolean;\n var i:longint;\n begin\n fun:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i = 0 then exit(false);\n end;\n\nbegin\n readln(n);\n if fun(n) then writeln(1)\n else if (n mod 2 = 0) or (fun(n-2)) then writeln(2)\n else writeln(3);\n\nend.\n"}, {"source_code": "var\nn,i:longint;\nbol:boolean;\nbegin\nreadln(N);\nbol:=true;\nfor i:=2 to round(sqrt(n)) do begin\n if n mod i = 0 then begin\n bol:=false;\n break;\n end;\nend;\nif bol then writeln(1)\nelse begin\n if i mod 2 = 0 then writeln(2)\n else begin\n bol:=true;\n for i:=2 to round(sqrt((n-2))) do begin\n if ((n-2) mod i = 0)and(i<>n-2) then begin\n bol:=false;\n break;\n end;\n end;\n if bol then writeln(2)\n else\n writeln(3);\n end;\nend;\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar i,j,c,kq,n,m,nP:longint;\n a,p:array[1..1000000] of longint;\n f:array[1..1000000] of boolean;\n\n\nprocedure openf;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure sangNT(n:longint);\nvar i,j:longint;\nbegin\n f[1]:=false;\n nP:=0;\n for i:=2 to n do f[i]:=true;\n for i:=2 to n do\n if f[i] then\n begin\n inc(nP);\n p[nP]:=i;\n j:=2;\n while j<=n div i do\n begin\n f[i*j]:=false;\n inc(j);\n end;\n end;\nend;\n\n\n\n\nfunction nto(x:longint):boolean;\nvar i:longint;\nbegin\n if x<=1000000 then exit(f[x]);\n for i:=1 to nP do\n begin\n if p[i]>x div p[i] then break;\n if x mod p[i]=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure inkq;\n\nbegin\n sangNT(1000000);\n readln(n);\n if nto(n) then write(1)\n else if nto(n-2) or (n mod 2=0) then write(2)\n else write(3);\n\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n"}, {"source_code": "var n:longint;\n\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n if x<2 then exit(false);\n for i:=2 to x do\n begin\n if i*i>x then break;\n if x mod i=0 then exit(false);\n end;\n exit(true);\nend;\n\nbegin\n readln(n);\n if prime(n)=true then writeln(1)\n else if (n>2) and (n mod 2=0) or prime(n-2)=true then writeln(2)\n else writeln(3);\n //readln();\nend."}, {"source_code": "{$Mode objfpc}\n\nvar\n n:int64;\n i:integer;\n\nprocedure check(o,x:int64);\nvar i:integer;\n begin\n for i:=2 to trunc(sqrt(o)) do\n if o mod i = 0 then exit;\n writeln(x);\n halt;\n end;\n\nbegin\n read(n);\n if n <= 3 then\n begin\n write(1); halt;\n end;\n if n mod 2 = 0 then\n begin\n write(2); halt;\n end;\n check(n,1);\n check(n-2,2);\n writeln(3);\nend."}, {"source_code": "var i,j,m,n:longint;\n flag:boolean;\nbegin\n readln(n);\n flag:=true;\n for i:=2 to trunc(sqrt(n)) do if n mod i=0 then flag:=false;\n if flag then writeln(1) else if odd(n)=false then writeln(2) else begin\n m:=n-2;\n flag:=true;\n for i:=2 to trunc(sqrt(m)) do if m mod i=0 then flag:=false;\n if flag then writeln(2) else writeln(3);\n end;\n\n\nend."}, {"source_code": "Program taxes;\nVar n,i:int64;\nBegin\nReadln(n);\ni:=2;\nIf n=2 then writeln(1) else begin\nIf n mod 2=0 then writeln(2) else begin\nWhile (n mod i<>0) and (isqrt(n) then writeln(1) else begin\ni:=2;\nWhile ((n-2) mod i<>0) and (isqrt(n-2) then writeln(2) else writeln(3);\nend;\nend;\nend;\nend.\n"}, {"source_code": " var n,i:longint;\n b:boolean;\nbegin\n readln(n);\n b:=true;\n for i:=2 to round(sqrt(n)) do\n if n mod i = 0 then begin\n b:=false;\n break;\n end;\n if b then\n writeln(1);\n if not b then\n if n mod 2 = 0 then\n writeln(2)\n else begin\n dec(n,2);\n b:=true;\n for i:=2 to round(sqrt(n)) do\n if n mod i = 0 then begin\n b:=false;\n break;\n end;\n if not b then\n writeln(3)\n else\n writeln(2);\n end;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n n : integer;\nfunction prime (x : integer) : boolean;\nvar\n i : integer;\nbegin\n if x < 2 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n exit(true);\nend;\nBEGIN\n readln(n);\n if prime(n) then write(1)\n else\n if (n mod 2 = 0) and (n >= 2) then write(2)\n else if prime(n - 2) then write(2) else write(3);\nEND."}, {"source_code": "const fi='';//735D.inp';\n fo='';//735D.out';\n\nvar n : longint;\n\n\nfunction nto(x: longint): boolean;\nvar i: longint;\nbegin\n if x<2 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\n\n\nprocedure doc;\nbegin\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n read(n);\n\n if nto(n) then write(1) else\n if (n mod 2=0) or (nto(n-2)) then write(2) else\n write(3);\n\nend;\n\nbegin\ndoc;\nend.\n\n\n\n"}, {"source_code": "var n:longint;\n\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n if x<2 then exit(false);\n for i:=2 to x do\n begin\n if i*i>x then break;\n if x mod i=0 then exit(false);\n end;\n exit(true);\nend;\n\nbegin\n readln(n);\n if prime(n)=true then writeln(1)\n else if (n>2) and (n mod 2=0) or prime(n-2)=true then writeln(2)\n else writeln(3);\n //readln();\nend."}, {"source_code": "CONST FI='';\n FO='';\nvar m,n,i,j,k:longint;\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(n);\nend;\nfunction kt(x:longint):boolean;\nvar i:longint;\nbegin\n if x<2 then exit(false);\n if x=2 then exit(true);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\nprocedure xuli;\nbegin\n if kt(n) then\n begin\n write(1);\n exit;\n end;\n\n if ( n mod 2=0) or kt(n-2) then\n begin\n write(2);\n exit;\n end\n else\n write(3);\nend;\nprocedure inkq;\nbegin\n assign(output,fo);\n rewrite(output);\n xuli;\nend;\nbegin\ndoc;\ninkq;\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nFunction Solve:longint;\nVar i:longint;\n lc:boolean;\nBegin\n if n=0 then exit(0);\n lc:=false;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n lc:=true;\n break;\n end;\n if lc=false then exit(1);\n if n mod 2=0 then exit(2);\n lc:=false;\n for i:=2 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then\n begin\n lc:=true;\n break;\n end;\n if (n>2) and (lc=false) then exit(2);\n exit(3);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:longint;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Xuat_Solve;\nEnd.\n"}, {"source_code": "var n,i:longint;\nfunction kt(x:longint):boolean;\n var i:longint;\n begin\n if x = 2 then exit(true);\n if x < 2 then exit(false);\n for i:=2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\nbegin\n readln(n);\n if kt(n) then begin write(1); exit; end;\n if n mod 2 = 0 then begin write(2); exit; end;\n n:=n-2;\n if kt(n) then write(2)\n else\n write(3);\nend."}, {"source_code": "var\n n:longint;\nfunction sushu(j:longint):boolean;\nvar\n k:longint;\nbegin\n if j<2 then exit(false);\n for k:=2 to trunc(sqrt(j)) do\n if j mod k=0 then exit(false);\n exit(true);\nend;\nbegin\n read(n);\n if sushu(n) then writeln(1)\n else if(n mod 2=0)or(sushu(n-2))then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "uses math;\nconst fi = '735d.inp';\n fo = '735d.out';\n maxn = 1000005;\nvar\n n,t,sl:longint;\n d,a,f:array[1..maxn]of longint;\n\nprocedure enter;\nvar i:longint;\nbegin\n readln(n);\nend;\nprocedure sangnt;\nvar i,j:longint;\nbegin\n for i:=2 to trunc(sqrt(maxn)) do\n if d[i]=0 then\n begin\n j:=i*i;\n while(j<=maxn)do\n begin\n d[j]:=1; inc(j,i);\n end;\n end;\nend;\n\nfunction check(x:longint):boolean;\nvar j:longint;\nbegin\n if x<=maxn then exit(d[x]=0);\n for j:=2 to trunc(sqrt(x)) do\n if x mod j=0 then exit(false);\n exit(true);\nend;\nfunction tinh(x:longint):longint;\nvar i:longint;\nbegin\n if x=0 then exit(0);\n if f[x]<>-1 then exit(f[x]);\n f[x]:=maxn;\n for i:=sl downto 1 do\n if x-a[i]>=0 then\n f[x]:=min(f[x],tinh(x-a[i])+1);\n exit(f[x]);\nend;\nprocedure solve;\nvar i,j,dem,res:longint;\nbegin\n t:=0;dem:=0; fillchar(f,sizeof(f),255);\n j:=2; sl:=0; res:=maxlongint;\n repeat\n if n-t<=1 then break;\n if (t<>1)and(check(n-t)) then\n begin inc(dem);\n while(j<=t)do\n begin\n if d[j]=0 then begin inc(sl); a[sl]:=j; end;\n inc(j);\n end;\n res:=min(res,tinh(t)+1);\n end;\n if dem=100 then break;\n inc(t);\n until 1=2;\n writeln(res);\n\nend;\n\nBEGIN\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n enter;\n sangnt;\n solve;\n close(input); close(output);\nEND.\n\n\n"}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n if k=1 then begin\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\n end;\nend."}, {"source_code": "var\n n,i,j:longint;\n p:boolean;\nbegin\n read(n);\n if n<=2 then begin write(1); halt; end;\n if n mod 2=0 then begin write(2); halt; end;\n p:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then begin write(1); halt; end;\n p:=true;\n n:=n-2;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then write(2) else write(3);\nend."}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n if k=1 then begin\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end\n end\nend."}, {"source_code": "Var\n n : longint ;\n\nFunction CheckPrime(n : longint) : boolean ;\n Var i : longint ;\n Begin\n\n if (n = 2) or (n = 3) then exit(true) ;\n\n for i := 2 to trunc(sqrt(n)) do\n if (n mod i = 0) then exit(false) ;\n\n exit(true) ;\n\n End;\n\nProcedure Enter ;\n Var i,j : longint ;\n Begin\n\n read(n) ;\n if (checkPrime(n)) then writeln(1)\n else\n\n Begin\n\n if (n mod 2 = 0) then writeln(2)\n else\n\n begin\n\n if (checkPrime(n-2)) then writeln(2) else writeln(3) ;\n\n end ;\n\n end ;\n\n End ;\n\nBegin\n\n //Assign(input,'735D.inp') ; reset(input) ;\n\n Enter ;\n\n //Close(input) ;\n\nEnd.\n"}, {"source_code": "var now:longint;\nfunction flag(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to trunc(sqrt(x)) do\n\tif (x mod i=0) then exit(false);\n exit(true);\nend;\nbegin\n readln(now);\n if (flag(now)) then writeln('1')\n else if (now mod 2=1) then\n begin\n if (flag(now-2)) then writeln('2') else writeln('3');\n end\n else writeln('2');\nend.\n "}, {"source_code": "program chmn;\nvar\n n:longint;\n\nfunction simple(n:longint):longint;\nvar\n i:longint;\nbegin\n\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(1);\n\n exit(0);\n\nend;\n\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(n);\n\n if simple(n)=0 then writeln(1)\n else if n mod 2=0 then writeln(2)\n else if simple(n-2)=0 then writeln(2)\n else writeln(3);\n\n\n//Close(input); Close(output);\nend.\n"}, {"source_code": "var n:int64;\n\nprocedure check(o,x:int64);\nvar i:longint;\nbegin\n for i:=2 to trunc(sqrt(o)) do if o mod i = 0 then exit;\n writeln(x);\n halt;\nend;\n\nbegin\n readln(n);\n if n<=3 then begin write(1); halt;end;\n if not odd(n) then begin write(2); halt;end;\n check(n,1);\n check(n-2,2);\n writeln(3);\nend."}, {"source_code": "uses math;\n\nvar f:array[1..1000000] of boolean;\n p:array[1..1000000] of longint;\n n,nP:longint;\n\nprocedure mofile;\nbegin\n assign(input,'codeforces.inp');\n assign(output,'codeforces.out');\n reset(input);\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure doc;\nbegin\n read(n);\nend;\n\nprocedure sangNT(n:longint);\nvar i,j:longint;\nbegin\n for i:=1 to n do f[i]:=true;\n f[1]:=false;\n for i:=2 to n do\n if f[i] then\n begin\n inc(nP);\n p[nP]:=i;\n for j:=2 to n div i do f[i*j]:=false;\n end;\nend;\n\nfunction NT(n:longint):boolean;\nvar i:longint;\nbegin\n if n<=1000000 then exit(f[n]);\n for i:=1 to nP do\n begin\n if p[i]>trunc(sqrt(n)) then break;\n if n mod p[i]=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure xuly;\nvar i,d:longint;\nbegin\n sangNT(1000000);\n if NT(n) then write(1)\n else\n if n mod 2=0 then write(2)\n else\n if NT(n-2) then write(2)\n else\n write(3);\nend;\n\nBEGIN\n \n doc;\n xuly;\n \nEND.\n\n"}, {"source_code": "var n:longint;\nfunction jj(n:longint):boolean;\nvar i:longint;k:boolean;\nbegin\nK:=true;\n i:=3; while i*i<=n do\n begin\n if n mod i=0 then begin k:=false;break;end;\n inc(i,2);\n end;\n jj:=k;\nend;\nbegin\n read(n);\n if n<4 then write (1) else if n mod 2= 0 then write(2) else \n if n<9 then write(1) else\n begin\n if jj(n) then write(1) else if jj(n-2) then write(2) else write(3);\n end;\nend."}, {"source_code": "var\n n,res : longint;\n\nfunction isprime(x : longint) : boolean;\n var\n i : longint;\n begin\n for i := 2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nprocedure main;\n var\n ok : boolean;\n begin\n read(n);\n if (n = 2) or (n = 3) or (n = 5) then res := 1\n else\n if n mod 2 = 0 then res := 2\n else\n begin\n if isprime(n) then res := 1\n else if isprime(n-2) then res := 2\n else res := 3;\n end;\n writeln(res);\n\n end;\n\nbegin\n main;\nend."}, {"source_code": "var\n a, b, c, d: int64;\n \nfunction test(a: int64): boolean;\nvar\n i: int64;\n \nbegin\n i := 2;\n while i * i <= a do begin\n if a mod i = 0 then begin\n test := false;\n exit;\n end;\n inc(i);\n end;\n test := true;\nend;\n \nbegin\n readln(a);\n if test(a) then begin\n writeln(1);\n halt();\n end;\n if a mod 2 = 0 then begin\n writeln(2);\n halt();\n end;\n if test(a - 2) then begin\n writeln(2);\n halt();\n end;\n writeln(3);\nend."}, {"source_code": "var n:longint;\n function check(k:longint):boolean;\n var i:longint;\n begin\n for i:=2 to trunc(sqrt(k)) do\n if k mod i=0 then exit(false);\n exit(true);\n end;\nbegin\n readln(n);\n if check(n) then writeln(1)\n else if (n mod 2=0)or(check(n-2)) then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "var\n a,b,c,i,j:longint;\nfunction proverka(a:Longint):longint;\nvar sqx,b,sc,i:Longint;\nbegin\n proverka:=0;\n sqx:=trunc(sqrt(a));\n for i:=2 to sqx do if a mod i=0 then begin proverka:=1; exit; end;\nend;\nbegin\n readln(a);\n if proverka(a)=0 then begin writeln(1); halt; end;\n if a mod 2=0 then begin writeln(2); halt; end;\n if proverka(a-2)=0 then begin writeln(2); halt; end;\n writeln(3);\nend."}, {"source_code": "var n: longword;\nprocedure doc;\n begin\n read(n);\n end;\nfunction nto (x: longword): boolean;\n var i: longword;\n begin\n for i:=2 to round(sqrt(x)) do\n if (x mod i)=0 then exit(false);\n exit(true);\n end;\nfunction xli: byte;\n begin\n if nto(n) then exit(1)\n else if not odd(n) then exit(2)\n else if nto(n-2) then exit(2)\n else exit(3);\n end;\nprocedure ghi;\n begin\n write(xli);\n end;\nbegin\n doc;\n ghi;\nend."}, {"source_code": "program yan;\n var x,y,n,m:longint;\n function prov(x:longint):boolean;\n var i,j,a:longint;\n begin\n prov:=true;\n for i:=2 to round(sqrt(x)) do\n if x mod i=0 then\n begin\n prov:=false;\n break;\n end;\n end;\nbegin\n readln(n);\n if n<=3 then\n begin\n write(1); exit;\n end;\n if not odd(n) then\n begin\n write(2); exit;\n end;\n if prov(n) then\n begin\n write(1); exit;\n end;\n if prov(n-2) then\n begin\n write(2); exit;\n end;\n write(3);\nend."}, {"source_code": "var\n n:longint;\nfunction ss(n:longint):boolean;\nvar\n i:longint;\nbegin\n if n<2 then exit(false);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\nbegin\n readln(n);\n if ss(n) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else if ss(n-2) then writeln(2)\n else writeln(3);\nend."}, {"source_code": "var\n\tn:longint;\nfunction prime(x:longint):boolean;\nvar\n\tj,t:longint;\nbegin\t\n\tif x=1 then exit(false);\n\tt:=trunc(sqrt(x));\n\tfor j:=2 to t do\n\t\tif x mod j=0 then exit(false);\n\texit(true);\nend;\nbegin\n\treadln(n);\n\tif (n=1) or (n=2) then\n\tbegin\n\t\twriteln(1);\n\t\thalt;\n\tend;\n\tif n mod 2=0 then \n\tbegin\n\t\twriteln(2);\n\t\thalt;\n\tend;\n\tif n mod 2=1 then\n\t\tif prime(n) then writeln(1)\n\t\telse if prime(n-2) then writeln(2)\n\t\t\telse writeln(3);\nend."}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n readln(n);\n if (n=1)or(n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);exit;end;\n for i:=2 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then begin writeln(3);exit;end;\n writeln(2);\n end;\nend."}, {"source_code": "var\n n:longint;\nfunction x(n:longint):boolean;\n var\n i:longint;\n p:boolean;\n begin\np:=true;\nfor i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false;break;end;\nif n=1 then p:=false;\nexit(p);\nend;\nbegin \nread(n);\nif x(n) then writeln(1)\nelse if (n mod 2=0) or (x(n-2)) then writeln(2)\nelse writeln(3);\nend.\n "}, {"source_code": "const\n fi = '';//735d.inp' ;\n fo = '';//735d.out' ;\n\nvar\n n : longint;\n\nfunction isprime(nn : longint) : boolean;\nvar i : longint;\nbegin\n if n < 2 then exit(false);\n if n < 4 then exit(true);\n for i := 2 to round(sqrt(nn))+1 do\n if nn mod i = 0 then exit(false);\n exit(true);\nend;\n\nprocedure doc;\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n read(n);\n if isprime(n) then\n begin\n writeln(1);\n exit;\n end;\n if (n mod 2 = 0) or isprime(n-2) then\n begin\n write(2);\n exit;\n end;\n writeln(3);\nend;\n\nbegin\n doc;\nend."}, {"source_code": "{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n\nuses math;\n\nprocedure mofile;\nbegin\n {$IFDEF ONLINE_JUDGE}\n assign(input,'');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ELSE}\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\n {$ENDIF}\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nconst\n maxc=1000000000+69;\n modulo=1000000000+7;\n maxn=trunc(sqrt(maxc))+10;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n:longint;\n kt:array[0..maxn] of longint;\n\nfunction nt(n:longint):boolean;\nvar\n i:longint;\nbegin\n if n<2 then exit(false);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\n\nfunction cal(n:longint):longint;\nvar\n m,i,j:longint;\nbegin\n if n=0 then exit(0);\n if nt(n) then exit(1);\n if n mod 2=0 then exit(2);\n if (n>2) and nt(n-2) then exit(2);\n exit(3);\nend;\n\nprocedure xuli;\nvar\n p:longint;\nbegin\n readln(n);\n writeln(cal(n));\nend;\n\nbegin\n //mofile;\n xuli;\n dongfile;\nend.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n n,i:longint;\n bz:boolean;\nbegin\n readln(n);\n bz:=false;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n bz:=true;\n break;\n end;\n if bz=false then\n begin\n writeln(1);\n halt;\n end;\n if n mod 2=0 then\n begin\n writeln(2);\n halt;\n end;\n bz:=false;\n for i:=2 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then\n begin\n bz:=true;\n break;\n end;\n if bz=false then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "var n:longint;\nfunction tfboys(n:longint):boolean;\nvar i:longint;\nbegin\n if n<2 then exit(false);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\n\nbegin\n readln(n);\n if tfboys(n) then writeln(1)\n else if (n mod 2=0) or (tfboys(n-2)) then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "var n,i,k,k1:longint;\nbegin\nread(n);\nfor i:=2 to round(sqrt(n)) do\nif n mod i=0 then begin k:=1; break; end;\n\nif k=1 then if n mod 2=0 then write(2)\nelse begin\nn:=n-2;\nfor i:=2 to round(sqrt(n)) do\nif n mod i=0 then begin k1:=1; break; end;\nif k1=0 then write(2) else write(3) end\nelse write(1);\nend."}, {"source_code": "const fi='';\n fo='';\nvar n:longint;\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then\n exit(false);\n exit(true);\nend;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n);\n if not prime(n) then\n if n mod 2=0 then write(2)\n else if prime(n-2) then write(2)\n else write(3)\n else write(1);\n close(input);\n close(output);\nend.\n"}, {"source_code": "const INP='';\nOUTP='';\nvar f:text;\nn:longint;\nprocedure nhap;\nbegin\nassign(f,INP);\nreset(f);\nreadln(f,n);\nclose(f);\nend;\nfunction get(x:longint):boolean;\nvar i,j:longint;\nbegin\nfor i:=2 to trunc(sqrt(n)) do\nif x mod i = 0 then exit(false);\nget:=true;\nend;\nprocedure xuLi;\nbegin\nassign(f,OUTP);\nrewrite(f);\nif get(n) then\nwrite(f,1) else\nif (n mod 2=0) or get(n-2) then write(f,2)\nelse write(f,3);\nclose(f);\nend;\nbegin\nnhap;\nxuLi;\nend.\n"}, {"source_code": "var n:longint;\n\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n if x<2 then exit(false);\n for i:=2 to x do\n begin\n if i*i>x then break;\n if x mod i=0 then exit(false);\n end;\n exit(true);\nend;\n\nbegin\n readln(n);\n if prime(n)=true then writeln(1)\n else if (n>2) and (n mod 2=0) or prime(n-2)=true then writeln(2)\n else writeln(3);\n //readln();\nend."}, {"source_code": "var\n n:int64;\n function pd(n:int64):boolean;\n var\n i:longint;\n begin\n if n<=1 then exit(false);\n for i:=2 to trunc(sqrt(n)) do if n mod i=0 then exit(false);\n exit(true);\n end;\nbegin\n readln(n);\n if pd(n) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else if pd(n-2) then writeln(2)\n else writeln(3);\nend."}, {"source_code": "var\n n,i,k:longint;\nbegin\n read(n);\n if (n=1) or (n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n for i:=2 to trunc(sqrt(n)) do if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);halt;end;\n for i:=2 to trunc(sqrt(n-2)) do if (n-2) mod i=0 then begin writeln(3);halt;end;\n writeln(2);\n end;\nend."}, {"source_code": "var\n n,k,ans : longint;\n\n function pr(x : longint) : boolean;\n var\n i : longint;\n begin\n if x = 1 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x))+1 do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n readln(n);\n if pr(n) then ans:=1 else begin\n if n mod 2 = 0 then ans:=2 else begin\n if pr(n-2) then ans:=2 else ans:=3; end;\n end;\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "var n,i:longint;\n fl:boolean;\nbegin\n read(n);\n \n for i:=2 to round(sqrt(n)) do\n if n mod i = 0\n then begin fl:=true;break;end;\n if not fl\n then write(1)\n else if n mod 2 =1\n then write(3)\n else write(2);\n \n\n\nend."}, {"source_code": "begin\n write('2');\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) and (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "var n, k : longint;\n\nfunction Simp (n : longint) : longint;\nvar i : longint;\ncheck : boolean;\n\nbegin\nwhile n>0 do begin\ncheck:=true;\ni:=2;\nwhile i*i<=n do\nbegin\n if n mod i = 0\n then begin check:=false; break; end;\n Inc(i);\nend;\nif check then begin Simp:=n; break; end;\nn:=n-1;\nend;\nend;\n\nbegin\nk:=0;\nreadln(n);\nwhile n>0 do begin\nInc(k);\nn:=n-Simp(n);\nend;\nwriteln(k);\nend.\n"}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else\n begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\nend."}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n readln(n);\n if (n=1)or(n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n a:=trunc(sqrt(n));\n for i:=1 to a do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);exit;end;\n a:=trunc(sqrt(n-2));\n for i:=1 to a do\n if n mod i=0 then begin writeln(3);exit;end;\n writeln(2);\n end;\nend."}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')//特判\n else if (n mod 2=0) then write('2')//当n为偶数时付2单位税\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;//判断是否质数\n if k=0 then begin write('1'); exit; end;//当n为质数时付1单位税\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;//判断是否质数\n if k=1 then write('3') else write('2');//当n-2为质数时付2单位税,否则付3单位税;\n end;\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) and (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) and (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "var n,i:int64;\n\nfunction fun(n,q:int64):int64;\n var i:longint; k:int64;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=round(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if q-n=1 then begin dec(n); k:=1; end;\n if (k=0) then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin //writeln(fun(n,n));\n n:=n-fun(n,n);\n inc(i);\n end;\n\n writeln(i);\n\nend.\n"}, {"source_code": "var i,j,m,n:longint;\n flag:boolean;\nbegin\n readln(n);\n flag:=true;\n for i:=2 to trunc(sqrt(n)) do if n mod i=0 then flag:=false;\n if flag then writeln(1) else if odd(n)=false then writeln(2) else writeln(3);\n\n\nend."}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n //for n:=30 to 100 do\n //begin m:=0;\n if not prov(n) then begin writeln(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if (not(not prov(a))and(not prov(b)))and(b<=round(sqrt(a))) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n if not prov(b) then break;\n a:=b-2; b:=2;\n end;\n end;\n if prov(n) then writeln(m+1);//end;\nend.\n"}, {"source_code": "// luogu-judger-enable-o2\nvar i:longint;n:int64;\nf:boolean;\nbegin\nreadln(n);\nif (n=1)or(n=2) then begin writeln('1');exit;end;\nif (n mod 2=0) then begin writeln('2');exit;end;\nfor i:=1 to trunc(sqrt(n)) do\n if (n mod i)=0 then\n begin\n f:=true;\n break;\n end;\nif not(f) then begin write('1');exit;end;\nf:=false;\ndec(n,2);\nfor i:=1 to trunc(sqrt(n)) do\n if (n mod i)=0 then\n begin\n f:=true;\n break;\n end;\nif f then writeln('3')\n else writeln('2');\nend.\n"}, {"source_code": "var \n a,n,i:longint;\n t:boolean;\nbegin\n readln(n);\n if(n=1)or(n=2)then writeln(1)else \n if(n mod 2=0)then writeln(2)else\n begin\n t:=false;\n a:=trunc(sqrt(n));\n for i:=1 to a do \n if(n mod i)=0then \n begin \n t:=true;\n break\n end;\n if not t then \n begin \n writeln('1'); \n halt\n end;\n t:=false;\n a:=trunc(sqrt(n-2));\n for i:=1 to a do \n if (n-2)mod i=0 then \n begin \n t:=true; \n break\n end;\n if t then \n writeln(3) else writeln(2);\n end\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) and (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "var\n n,k,ans : longint;\n\n function pr(x : longint) : boolean;\n var\n i : longint;\n begin\n if x = 1 then exit(false);\n if x = 2 then exit(true);\n for i:=2 to trunc(sqrt(x))+1 do\n if x mod i = 0 then exit(false);\n exit(true);\n end;\n\nbegin\n readln(n);\n if pr(n) then ans:=1 else begin\n if n mod 2 = 0 then ans:=2 else ans:=3;\n end;\n writeln(ans);\nend."}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=1 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": " var n,i:longint;\nbegin\n readln(n);\n for i:=2 to round(sqrt(n)+1) do\n if n mod i = 0 then break\n else\n if i=round(sqrt(n)+1) then\n writeln(1);\n if ix div p[i] then break;\n if x mod p[i]=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure inkq;\n\nbegin\n sangNT(1000000);\n readln(n); kq:=0;\n while not nto(n) do\n begin\n m:=n-2;\n while not nto(m) do dec(m);\n inc(kq);\n n:=n-m;\n end;\n if n=0 then writeln(kq) else writeln(kq+1);\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "const\n fi = 'DDD.inp';\n fo = 'DDD.out';\n\nvar\n n:longint;\n\nfunction check(x:longint):boolean;\nvar\n i:longint;\nbegin\n if x < 2 then exit(false);\n if x = 2 then exit(true);\n for i := 2 to trunc(sqrt(x)) do\n if x mod i = 0 then exit(false);\n\n exit(true);\nend;\n\nbegin\n read(n);\n if n = 2 then writeln(1) else;\n if (n mod 2 = 0) and (n > 2) then writeln(2) else\n if (n mod 2 = 1) and (check(n-2)) then writeln(2) else writeln(3);\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nFunction Solve:longint;\nVar i:longint;\n lc:boolean;\nBegin\n lc:=false;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n lc:=true;\n break;\n end;\n if lc=false then exit(1);\n if n mod 2=1 then exit(3);\n if n mod 2=0 then exit(2);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:longint;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Xuat_Solve;\nEnd.\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=2 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n if not prov(n) then begin write(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if prov(a) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n a:=b-2; b:=2;\n end;\n end;\n write(m+1);\nend.\n"}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\nif (x mod 2=0) and (x>4) then writeln(2);\nif (x mod 2=1) and (x>5) then writeln(3);\nif (x=2) then writeln(1);\nif (x=3) then writeln(1);\nif (x=4) then writeln(1);\nif (x=5) then writeln(1);\nEnd."}, {"source_code": "var n,i:int64;\n //t:array [1..1000000000] of longint;\n\nfunction fun(n:int64):int64;\n var i,k:longint;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=trunc(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if k=0 then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin\n if i = 0 then n:=n-fun(n-1)\n else n:=n-fun(n);\n inc(i);\n end;\n\n writeln(i);\n\nend."}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=2 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "program cf736B;\nvar n:longint;\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to n-1 do\n begin\n if i*i>n then exit(true);\n if n mod i=0 then exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n if prime(n) then write(1)\n else if n mod 2=0 then write(2)\n else if prime(n-2) then write(2)\n else write(3);\nend.\n"}, {"source_code": "var \n a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('2') else write('3');\n end;\nend."}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n //for n:=30 to 100 do\n //begin m:=0;\n if not prov(n) then begin writeln(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if (not(not prov(a))and(not prov(b)))and(b<=round(sqrt(a))) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n if not prov(b) then break;\n a:=b-2; b:=2;\n end;\n end;\n if prov(n) then writeln(m+1);//end;\nend.\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=2 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "var \n a,n,i:longint;\n t:boolean;\nbegin\n readln(n);\n if(n=1)or(n=2)then writeln(1)else \n if(n mod 2=0)then writeln(2)else\n begin\n t:=false;\n a:=trunc(sqrt(n));\n for i:=1 to a do \n if(n mod i)=0then \n begin \n t:=true;\n break\n end;\n if not t then \n begin \n writeln('1'); \n halt\n end;\n t:=false;\n dec(n,2);\n a:=trunc(sqrt(n));\n for i:=1 to a do \n if (n)mod i=0 then \n begin \n t:=true; \n break\n end;\n if t then \n writeln(3) else writeln(2);\n end\nend."}, {"source_code": "var n:longint;\nprocedure check;\nvar f,i:longint;\nbegin\n f:=0;\n for i:=2 to round(sqrt(n)) do\n if n mod i=0 then begin f:=1; break; end;\n if f=0 then begin write(1); halt; end;\nend;\nbegin\nread(n);\ncheck;\nwrite(2+n mod 2);\nend.\n"}, {"source_code": "var\n n,i,sum:longint;\nbegin\n readln(n);\n if n=1 then begin writeln(1);exit;end;\n if n mod 2=0 then begin writeln(2);exit;end;\n i:=2;\n while n>=i do\n begin\n if n mod i=0 then begin inc(sum);n:=n div i;end\n else inc(i);\n end;\n writeln(sum);\nend."}, {"source_code": "var n,i:int64;\n //t:array [1..1000000000] of longint;\n\nfunction fun(n:int64):int64;\n var i,k:longint;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=trunc(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if k=0 then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin\n if i = 0 then n:=n-fun(n-1)\n else n:=n-fun(n);\n inc(i);\n end;\n\n writeln(i);\n\nend."}, {"source_code": "var n,i:int64;\n\nfunction fun(n,q:int64):int64;\n var i:longint; k:int64;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=round(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if q-n=1 then begin dec(n); k:=1; end;\n if (k=0) then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin //writeln(fun(n,n));\n n:=n-fun(n,n);\n inc(i);\n end;\n\n writeln(i);\n\nend.\n"}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;\n i1,j1,k1, step, i,j:longint;\n aanew,bbnew:extended;\n ss:string;\n s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;\n ddminus, ppole:array[-1..2000,-1000..1502] of int64;\n text,text1,text2:array[-10..2000000] of char;\n ss1,ss2:string;\n ddd,dd:array[-1..40000,-1..10] of int64;\n marked:array[-100000..500000] of boolean;\n sss:string;ch:char;\n pole :array [-10..500,-10..500] of char;\n st2:array[0..nn] of string;\n v0,v1,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction koll(pp:longint):longint;\nlabel 43;\n var ot,i,t:longint;\naanew:extended; flag:boolean;\nbegin\n flag:=true;\n aanew:=pp; aanew:=sqrt(aanew);\n t:=round(aanew+0.01);\n for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;\n { writeln(flag);\n }\n if flag then begin ot:=1; goto 43; end;\n if odd(pp) then begin ot:=3; goto 43; end;\n if not odd(pp) then begin ot:=2; goto 43; end;\n43:\n koll:=ot;\nend;\n\nfunction prost(pp:longint):boolean;\nvar i:longint;flag:boolean;\n begin\n flag:=true;\n for i:=2 to min(pp-1,100000) do\n if pp mod i=0 then flag:=false;\n\n prost:=flag;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n { for i:=2 to 30 do writeln(i,' ',koll(i));\n\n\n\n for i:=2000000002 to 2000000010 do writeln(i,' ',koll(i));\n }\n\n { for i:=2 to 100 do if prost(i) then write(i,' ');\n writeln;\n }\n if prost(pp-2) then tt:=2 else tt:=3;\n read(pp);\n writeln(min(koll(pp),tt));\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\not:=x;\nd:=2;\nwhile int64(d)*d<=x do\nif x mod d=0 then begin\n x:=x div d;\n ot:=ot+1;\n end\n else if d=2 then d:=3\n else d:=d+2;\nif x=ot then writeln(1) else begin\nif (ot mod 2=0) and (ot>2) then writeln(2);\nif (ot mod 2=1) and (ot>5) then writeln(3);\nif (ot=2) then writeln(1);\nif (ot=3) then writeln(1);\nif (ot=5) then writeln(1);\nend;\nEnd."}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\not:=x;\nd:=2;\nwhile int64(d)*d<=x do\nif x mod d=0 then begin\n x:=x div d;\n \n end\n else if d=2 then d:=3\n else d:=d+2;\nif x=ot then writeln(1) else begin\nif (ot mod 2=0) and (ot>2) then writeln(2);\nif (ot mod 2=1) and (ot>5) then writeln(3);\nif (ot=2) then writeln(1);\nif (ot=3) then writeln(1);\nif (ot=5) then writeln(1);\nend;\nEnd."}, {"source_code": "// luogu-judger-enable-o2\nvar i:longint;n:int64;\nf:boolean;\nbegin\nreadln(n);\nif (n=1)or(n=2) then begin writeln('1');exit;end;\nif (n mod 2=0) then begin writeln('2');exit;end;\nfor i:=1 to trunc(sqrt(n)) do\n if (n mod i)=0 then\n begin\n f:=true;\n break;\n end;\nif not(f) then begin write('1');exit;end;\nf:=false;\ndec(n,2);\nfor i:=1 to trunc(sqrt(n)) do\n if (n mod i)=0 then\n begin\n f:=true;\n break;\n end;\nif f then writeln('3')\n else writeln('2');\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor i:=2 to round(sqrt(n)) do\n begin\n if n mod i=0 then a:=1;\n end;\nif a=0 then write('1') else if n mod 2=0 then write('2') else write('3');\nend."}, {"source_code": "begin\n write('2');\nend."}, {"source_code": "var\na,n,i,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else\n begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do\n if (n mod i)=0 then\n begin\n k:=1;\n break;\n end;\n if k=0 then\n begin\n write('1');\n exit;\n end;\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do\n if (n mod i)=0 then\n begin\n k:=1;\n break;\n end;\n if k=1 then write('3')\n else write('2');\n end;\nend."}, {"source_code": "var \n a,n,i:longint;\n t:boolean;\nbegin\n readln(n);\n if(n=1)or(n=2)then writeln(1)else \n if(n mod 2=0)then writeln(2)else\n begin\n t:=false;\n a:=trunc(sqrt(n));\n for i:=1 to a do \n if(n mod i)=0then \n begin \n t:=true;\n break\n end;\n if not t then \n begin \n writeln('1'); \n halt\n end;\n t:=false;\n dec(n,2);\n a:=trunc(sqrt(n));\n for i:=1 to a do \n if (n)mod i=0 then \n begin \n t:=true; \n break\n end;\n if t then \n writeln(3) else writeln(2);\n end\nend."}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n //for n:=30 to 100 do\n //begin m:=0;\n if not prov(n) then begin writeln(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if not((not prov(a))and(not prov(b))and(b<=a div 2)) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n if not prov(b) then break;\n a:=b-2; b:=2;\n end;\n end;\n if prov(n) then writeln(m+1);//end;\nend.\n"}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\nif (x mod 2=0) and (x>4) then writeln(2);\nif (x mod 2=1) and (x>5) then writeln(3);\nif (x=2) then writeln(1);\nif (x=3) then writeln(1);\nif (x=4) then writeln(2);\nif (x=5) then writeln(2);\nEnd."}, {"source_code": "var\np,n,i:longint;\nbol:boolean;\nbegin\nreadln(n);\nif n mod 2 = 0 then writeln(2)\nelse begin\nbol:=true;\n for i:=2 to round(sqrt(n)) do if n mod i = 0 then bol:=false;\n if bol then writeln(1)\n else begin\n bol:=true;\n p:=n-2;\n for i:=2 to round(sqrt(p)) do if p mod i = 0 then bol:=false;\n if bol then writeln(2)\n else\n writeln(3);\n \n end;\nend;\nend."}, {"source_code": "var\n n,i,j:longint;\n p:boolean;\nbegin\n read(n);\n if n<=2 then begin write(1); halt; end;\n p:=true;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then begin write(1); halt; end;\n p:=true;\n n:=n-2;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then write(2) else write(3);\nend."}, {"source_code": "var n:longint;\nbegin\n read(n);\n write('1');\nend."}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\not:=x;\nd:=2;\nwhile int64(d)*d<=x do\nif x mod d=0 then begin\n x:=x div d;\n \n end\n else if d=2 then d:=3\n else d:=d+2;\nif x=ot then writeln(1) else begin\nif (ot mod 2=0) and (ot>2) then writeln(2);\nif (ot mod 2=1) and (ot>5) then writeln(3);\nif (ot=2) then writeln(1);\nif (ot=3) then writeln(1);\nif (ot=5) then writeln(1);\nend;\nEnd."}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n a:=trunc(sqrt(n));\n for i:=1 to a do if n mod i=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if n mod i=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\nend."}, {"source_code": "var n,i:int64;\n //t:array [1..1000000000] of longint;\n\nfunction fun(n:int64):int64;\n var i,k:longint;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=trunc(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if k=0 then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin\n if i = 0 then n:=n-fun(n-1)\n else n:=n-fun(n);\n inc(i);\n end;\n\n writeln(i);\n\nend."}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n readln(n);\n if (n=1)or(n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n a:=trunc(sqrt(n));\n for i:=1 to a do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);exit;end;\n a:=trunc(sqrt(n-2));\n for i:=1 to a do\n if n mod i=0 then begin writeln(3);exit;end;\n writeln(2);\n end;\nend."}, {"source_code": "var\n n,i,sum:longint;\nbegin\n readln(n);\n if n=1 then begin writeln(1);exit;end;\n i:=2;\n while n>=i do\n begin\n if n mod i=0 then begin inc(sum);n:=n div i;end\n else inc(i);\n end;\n writeln(sum);\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar i,j,c,kq,n,m,nP:longint;\n a,p:array[1..1000000] of longint;\n f:array[1..1000000] of boolean;\n\n \nprocedure openf;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\n\nprocedure closef;\nbegin\n close(input); close(output);\nend;\n\nprocedure sangNT(n:longint);\nvar i,j:longint;\nbegin\n f[1]:=false;\n nP:=0;\n for i:=2 to n do f[i]:=true;\n for i:=2 to n do\n if f[i] then\n begin\n inc(nP);\n p[nP]:=i;\n j:=2;\n while j<=n div i do\n begin\n f[i*j]:=false;\n inc(j);\n end;\n end;\nend;\n\n\n\n\nfunction nto(x:longint):boolean;\nvar i:longint;\nbegin\n if x<=1000000 then exit(f[x]);\n for i:=1 to nP do\n begin\n if p[i]>x div p[i] then break;\n if x mod p[i]=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure inkq;\n\nbegin\n sangNT(1000000);\n readln(n); kq:=0;\n while not nto(n) do\n begin\n m:=n-2;\n while not nto(m) do dec(m);\n inc(kq);\n n:=n-m;\n end;\n if n=0 then writeln(kq) else writeln(kq+1);\nend;\n\nBEGIN\n openf;\n inkq;\n closef;\nEND.\n\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=1 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "var \n a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('2') else write('3');\n end;\nend."}, {"source_code": "function prost (a:longint):boolean;\nvar i:longint; flag:boolean;\nbegin \nflag:=true;\n for i:=2 to trunc(sqrt(a)) do \n if a mod i = 0 then begin flag:=false; break; end;\n prost:=flag;\nend;\n\n\nvar n,k,c,a,b:longint;\nbegin\n read(n);\n if prost(n) then writeln(1) else\n if n mod 2 = 0 then writeln(2) else\n if prost(n-1) then writeln(2) else\n writeln(3);\nend. "}, {"source_code": "var a,n,i:longint;\n b:boolean;\nbegin\n read(n);\n if n<=2 then writeln(1)\n else if not(odd(n)) then write(2)\n else begin\n for i:=1 to trunc(sqrt(n-2)) do\n if (n mod i)=0 then begin b:=true;break; end;\n if b then begin write(1); exit; end;\n b:=false;\n for i:=1 to trunc(sqrt(n-2)) do if ((n-2) mod i)=0 then begin b:=true; break; end;\n if b then write(3) else write(2);\n end;\nend.\n\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nFunction Solve:longint;\nVar i:longint;\n lc:boolean;\nBegin\n lc:=false;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n lc:=true;\n break;\n end;\n if lc=false then exit(1);\n if n mod 2=1 then exit(3);\n if n mod 2=0 then exit(2);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:longint;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Xuat_Solve;\nEnd.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n:longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nFunction Solve:longint;\nVar i:longint;\n lc:boolean;\nBegin\n lc:=false;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n lc:=true;\n break;\n end;\n if lc=false then exit(1);\n if n mod 2=1 then exit(3);\n if n mod 2=0 then exit(2);\nEnd;\nProcedure Xuat_Solve;\nVar f:Text;\n res:longint;\nBegin\n assign(f,fout); rewrite(f);\n res:=solve;\n write(f,res);\n close(f);\nEnd;\n\nBegin\n Nhap;\n Xuat_Solve;\nEnd.\n"}, {"source_code": "uses math;\n\nvar f:array[1..1000000] of boolean;\n p:array[1..1000000] of longint;\n n,nP:longint;\n\nprocedure mofile;\nbegin\n assign(input,'codeforces.inp');\n assign(output,'codeforces.out');\n reset(input);\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nprocedure doc;\nbegin\n read(n);\nend;\n\nprocedure sangNT(n:longint);\nvar i,j:longint;\nbegin\n for i:=1 to n do f[i]:=true;\n f[1]:=false;\n for i:=2 to n do\n if f[i] then\n begin\n inc(nP);\n p[nP]:=i;\n for j:=2 to n div i do f[i*j]:=false;\n end;\nend;\n\nfunction NT(n:longint):boolean;\nvar i:longint;\nbegin\n if n<=1000000 then exit(f[n]);\n for i:=1 to nP do\n begin\n if p[i]>trunc(sqrt(n)) then break;\n if n mod p[i]=0 then exit(false);\n end;\n exit(true);\nend;\n\nprocedure xuly;\nvar i,d:longint;\nbegin\n sangNT(1000000);\n i:=n+1;\n d:=0;\n while n>0 do\n begin\n i:=n;\n for i:=n downto 1 do\n begin\n if NT(i) and (n-i<>1) then\n begin\n inc(d);\n n:=n-i;\n break;\n end;\n end;\n end;\n write(d);\nend;\n\nBEGIN\n \n doc;\n xuly;\n \nEND.\n\n"}, {"source_code": "program cf736B;\nvar n:longint;\nfunction prime(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to n-1 do\n begin\n if i*i>n then exit(true);\n if n mod i=0 then exit(false);\n end;\n exit(true);\nend;\nbegin\n readln(n);\n if prime(n) then write(1)\n else if n mod 2=0 then write(2)\n else if prime(n-2) then write(2)\n else write(3);\nend.\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=1 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=1 then write(3) else write(2);\n end;\n end.\n "}, {"source_code": "var n:longint;\nbegin\nread(n);\nwrite(2+n mod 2);\nend.\n"}, {"source_code": "var\n n,i,j:longint;\n p:boolean;\nbegin\n read(n);\n if n<=2 then begin write(1); halt; end;\n p:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then begin write(1); halt; end;\n p:=true;\n n:=n-2;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then write(2) else write(3);\nend."}, {"source_code": "CONST FI='';\n FO='';\nvar m,n,i,j,k:longint;\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(n);\nend;\nfunction kt(x:longint):boolean;\nvar i:longint;\nbegin\n if x<2 then exit(false);\n if x=2 then exit(true);\n for i:=1 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\n exit(true);\nend;\nprocedure xuli;\nbegin\n if kt(n) then\n begin\n write(1);\n exit;\n end;\n\n if ( n mod 2=0) and kt(n-2) then\n begin\n write(2);\n exit;\n end\n else\n write(3);\nend;\nprocedure inkq;\nbegin\n assign(output,fo);\n rewrite(output);\n xuli;\nend;\nbegin\ndoc;\n\ninkq;\nend."}, {"source_code": "var\n\tn:longint;\nfunction prime(x:longint):boolean;\nvar\n\tj,t:longint;\nbegin\t\n\tif x=1 then exit(false);\n\tt:=trunc(sqrt(x));\n\tfor j:=2 to t do\n\t\tif x mod j=0 then exit(false);\n\texit(true);\nend;\nbegin\n\treadln(n);\n\tif (n=1) or (n=2) or (n=3) then\n\tbegin\n\t\twriteln(1);\n\t\thalt;\n\tend;\n\tif n mod 2=0 then \n\tbegin\n\t\twriteln(2);\n\t\thalt;\n\tend;\n\tif n mod 2=1 then\n\t\tif prime(n-2) then writeln(2)\n\t\telse writeln(3);\nend."}, {"source_code": "var\n n,i,j:longint;\n p:boolean;\nbegin\n read(n);\n if n<=2 then begin write(1); halt; end;\n p:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then begin write(1); halt; end;\n p:=true;\n n:=n-2;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then write(3) else write(2);\nend."}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=2 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;\n i1,j1,k1, step, i,j:longint;\n aanew,bbnew:extended;\n ss:string;\n s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;\n ddminus, ppole:array[-1..2000,-1000..1502] of int64;\n text,text1,text2:array[-10..2000000] of char;\n ss1,ss2:string;\n ddd,dd:array[-1..40000,-1..10] of int64;\n marked:array[-100000..500000] of boolean;\n sss:string;ch:char;\n pole :array [-10..500,-10..500] of char;\n st2:array[0..nn] of string;\n v0,v1,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction koll(pp:longint):longint;\nlabel 43;\n var ot,i,t:longint;\naanew:extended; flag:boolean;\nbegin\n flag:=true;\n aanew:=pp; aanew:=sqrt(aanew);\n t:=round(aanew+0.01);\n for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;\n { writeln(flag);\n }\n if flag then begin ot:=1; goto 43; end;\n if odd(pp) then begin ot:=3; goto 43; end;\n if not odd(pp) then begin ot:=2; goto 43; end;\n43:\n koll:=ot;\nend;\n\nfunction prost(pp:longint):boolean;\nvar i:longint;flag:boolean;\n begin\n flag:=true;\n for i:=2 to min(pp-1,100000) do\n if pp mod i=0 then flag:=false;\n\n prost:=flag;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n { for i:=2 to 30 do writeln(i,' ',koll(i));\n\n\n\n for i:=2000000002 to 2000000010 do writeln(i,' ',koll(i));\n }\n\n if prost(pp-2) then tt:=2;\n read(pp);\n writeln(min(koll(pp),tt));\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var\n n,i:longint;\n bz:boolean;\nbegin\n readln(n);\n bz:=false;\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then\n begin\n bz:=true;\n break;\n end;\n if bz=false then\n begin\n writeln(1);\n halt;\n end;\n if n mod 2=0 then\n begin\n writeln(2);\n halt;\n end;\n bz:=false;\n for i:=1 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then\n begin\n bz:=true;\n break;\n end;\n if bz=false then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "var n:longint;\nprocedure check;\nvar f,i:longint;\nbegin\n f:=0;\n for i:=2 to round(sqrt(n)) do\n if n mod i=0 then begin f:=1; break; end;\n if f=0 then begin write(1); halt; end;\nend;\nbegin\nread(n);\ncheck;\nwrite(2+n mod 2);\nend.\n"}, {"source_code": "function prost (a:longint):boolean;\nvar i:longint; flag:boolean;\nbegin \nflag:=true;\n for i:=2 to trunc(sqrt(a)) do \n if a mod i = 0 then begin flag:=false; break; end;\n prost:=flag;\nend;\n\n\nvar n,k,c,a,b:longint;\nbegin\n read(n);\n if prost(n) then writeln(1) else\n if n mod 2 = 0 then writeln(2) else\n if prost(n-1) then writeln(2) else\n writeln(3);\nend. "}, {"source_code": "var\n a,b,i,n,k,j:longint;\n function f(n:longint):longint;\n var a,b,i:longint;\n begin\n a:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then a:=1;\n f:=a;\n end;\nbegin\n read(n);\n if f(n)=0 then writeln(1) else\n if (n mod 2=0) and (f(n-2)=0) then writeln(2) else \n writeln(3);\nend. "}, {"source_code": "var n:int64;\nfunction p(x:longint):boolean;\nvar i:longint;\nbegin\nif x=2 then exit(false);\nfor i:=2 to trunc(sqrt(x)) do\n if x mod i=0 then exit(false);\nexit(true);\nend;\nbegin\nreadln(n);\nif p(n) then writeln(1)\nelse if n mod 2=0 then writeln(2)\nelse if p(n-2) then writeln(2)\nelse writeln(3);\nend."}, {"source_code": "function prost (a:longint):boolean;\nvar i:longint; flag:boolean;\nbegin \nflag:=true;\n for i:=2 to trunc(sqrt(a)) do \n if a mod i = 0 then begin flag:=false; break; end;\n prost:=flag;\nend;\n\n\nvar n,k,c,a,b:longint;\nbegin\n read(n);\n if prost(n) then writeln(1) else\n if n mod 2 = 0 then writeln(2) else\n if prost(n-1) then writeln(2) else\n writeln(3);\nend. "}, {"source_code": " const eps=0.0000000001; besk=20000000000008; nn=200000;\n label 1,2,3,4;\n type\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;\n i1,j1,k1, step, i,j:longint;\n aanew,bbnew:extended;\n ss:string;\n s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;\n ddminus, ppole:array[-1..2000,-1000..1502] of int64;\n text,text1,text2:array[-10..2000000] of char;\n ss1,ss2:string;\n ddd,dd:array[-1..40000,-1..10] of int64;\n marked:array[-100000..500000] of boolean;\n sss:string;ch:char;\n pole :array [-10..500,-10..500] of char;\n st2:array[0..nn] of string;\n v0,v1,t0:real;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction koll(pp:longint):longint;\nlabel 43;\n var ot,i,t:longint;\naanew:extended; flag:boolean;\nbegin\n flag:=true;\n aanew:=pp; aanew:=sqrt(aanew);\n t:=round(aanew+0.01);\n for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;\n { writeln(flag);\n }\n if flag then begin ot:=1; goto 43; end;\n if odd(pp) then begin ot:=3; goto 43; end;\n if not odd(pp) then begin ot:=2; goto 43; end;\n43:\n koll:=ot;\nend;\n\nfunction prost(pp:longint):boolean;\nvar i:longint;flag:boolean;\n begin\n flag:=true;\n for i:=2 to min(pp-1,100000) do\n if pp mod i=0 then flag:=false;\n\n prost:=flag;\n end;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n { for i:=2 to 30 do writeln(i,' ',koll(i));\n\n\n\n for i:=2000000002 to 2000000010 do writeln(i,' ',koll(i));\n }\n\n if prost(pp-2) then tt:=2;\n read(pp);\n writeln(min(koll(pp),tt));\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n"}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n if k=1 then begin\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\n end;\nend."}, {"source_code": "program nalogi;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n w : boolean;\n n, i, res : integer;\n \nbegin\n readln ( n );\n\n w := true;\n i := 3;\n\n if ( n = 2 ) then\n w := true\n else\n if ( n mod 2 <> 0 ) then\n while ( i <= trunc ( sqrt ( n ) ) ) do begin\n if ( n mod i = 0 ) then begin\n w := false;\n break;\n end;\n inc ( i, 2 );\n end\n else\n w := false;\n\n if ( w ) then\n res := 1\n else\n if ( n mod 2 = 0 ) then\n res := 2\n else\n res := 3;\n\n writeln ( res );\n \n readln;\nend.\n"}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n //for n:=30 to 100 do\n //begin m:=0;\n if not prov(n) then begin writeln(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if not((not prov(a))and(not prov(b))and(b<=a div 2)) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n if not prov(b) then break;\n a:=b-2; b:=2;\n end;\n end;\n if prov(n) then writeln(m+1);//end;\nend.\n"}, {"source_code": "var\n n,i,j:longint;\n p:boolean;\nbegin\n read(n);\n if n<=2 then begin write(1); halt; end;\n p:=true;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then begin write(1); halt; end;\n p:=true;\n n:=n-2;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin p:=false; break; end;\n if p then write(2) else write(3);\nend."}, {"source_code": "var n,i:int64;\n\nfunction fun(n,q:int64):int64;\n var i,k:longint;\n begin\n k:=1;\n while k=1 do\n begin\n k:=0;\n for i:=trunc(sqrt(n)) downto 2 do\n if n mod i = 0 then begin dec(n); k:=1; break; end;\n if (k=0) and (k-n <> 1) then exit(n);\n end;\n end;\n\nbegin\n readln(n);\n i:=0;\n\n while n > 0 do\n begin\n n:=n-fun(n,n);\n inc(i);\n end;\n\n writeln(i);\n\nend."}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n:longint;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(n);\nfor i:=2 to round(sqrt(n)) do\n begin\n if n mod i=0 then a:=1;\n end;\nif a=0 then write('1') else if n mod 2=0 then write('2') else write('3');\nend."}, {"source_code": "var n:longint;\nfunction tfboys(n:longint):boolean;\nvar i:longint;\nbegin\n if n<2 then exit(false);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then exit(false);\n exit(true);\nend;\n\nbegin\n readln(n);\n if tfboys(n) then writeln(1)\n else if (n mod 2=0) and (tfboys(n-2)) then writeln(2)\n else writeln(3);\nend.\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nread(n);\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=1 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "var n, k : longint;\n\nfunction isprime(n : longint) : Boolean;\nvar d : longint;\nbegin\nisprime:=true;\nd:=2;\n\twhile d*d<=n do begin\n\tif n mod d=0 then begin isprime:=false; break; end;\n Inc(d);\n end;\nend;\n\nfunction Simp (n : longint) : longint;\nbegin\nwhile n>0 do begin\nif isprime(n) then begin Simp:=n; break; end;\nDec(n);\nend;\nend;\n\nbegin\nk:=0;\nreadln(n);\nwhile n>0 do begin\nInc(k);\nn:=n-Simp(n);\nend;\nwriteln(k);\nend.\n"}, {"source_code": "var\n n,m,i: longint;\n f: boolean;\nbegin\n readln(n);\n m:=trunc(sqrt(n));\n\n for i:=2 to m do if n mod i = 0 then\n begin\n f:=true;\n break;\n end;\n\n if not f then begin writeln(1); halt; end;\n\n if not odd(n) then writeln(2) else\n begin\n for i:=2 to m+1 do if (n+2) mod i = 0 then\n begin\n f:=true;\n break;\n end;\n\n if not f then writeln(2) else writeln(3);\n end;\nend.\n"}, {"source_code": "var\n a,n,i,k:longint;\nbegin\n readln(n);\n if (n=1)or(n=2) then writeln(1)\n else if n mod 2=0 then writeln(2)\n else\n begin\n for i:=1 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin writeln(1);exit;end;\n for i:=1 to trunc(sqrt(n-2)) do\n if (n-2) mod i=0 then begin writeln(3);exit;end;\n writeln(2);\n end;\nend."}, {"source_code": "var n, k : longint;\n\nfunction isprime(n : longint) : Boolean;\nvar d : longint;\nbegin\nisprime:=true;\nd:=2;\n\twhile d*d<=n do begin\n\tif n mod d=0 then begin isprime:=false; break; end;\n Inc(d);\n end;\nend;\n\nfunction Simp (n : longint) : longint;\nbegin\nwhile n>0 do begin\nif isprime(n) then begin Simp:=n; break; end;\nDec(n);\nend;\nend;\n\nbegin\nk:=0;\nreadln(n);\nwhile n>0 do begin\nInc(k);\nn:=n-Simp(n);\nend;\nwriteln(k);\nend.\n"}, {"source_code": "uses math;\nconst fi = '735d.inp';\n fo = '735d.out';\n maxn = 1000005;\nvar\n n,t,sl:longint;\n d,a,f:array[1..maxn]of longint;\n\nprocedure enter;\nvar i:longint;\nbegin\n readln(n);\nend;\nprocedure sangnt;\nvar i,j:longint;\nbegin\n for i:=2 to trunc(sqrt(maxn)) do\n if d[i]=0 then\n begin\n j:=i*i;\n while(j<=maxn)do\n begin\n d[j]:=1; inc(j,i);\n end;\n end;\nend;\n\nfunction check(x:longint):boolean;\nvar j:longint;\nbegin\n if x<=maxn then exit(d[x]=0);\n for j:=2 to trunc(sqrt(x)) do\n if x mod j=0 then exit(false);\n exit(true);\nend;\nfunction tinh(x:longint):longint;\nvar i:longint;\nbegin\n if x=0 then exit(0);\n if f[x]<>-1 then exit(f[x]);\n f[x]:=maxn;\n for i:=sl downto 1 do\n if x-a[i]>=0 then\n f[x]:=min(f[x],tinh(x-a[i])+1);\n exit(f[x]);\nend;\nprocedure solve;\nvar i:longint;\nbegin\n t:=0;\n repeat\n if (t<>1)and(check(n-t)) then break;\n inc(t);\n until 1=2;\n sl:=0;\n for i:=2 to t do\n if d[i]=0 then\n begin\n inc(sl);a[sl]:=i;\n end;\n\n fillchar(f,sizeof(f),255);\n writeln(tinh(t)+1);\n\nend;\n\nBEGIN\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n enter;\n sangnt;\n solve;\n close(input); close(output);\nEND.\n\n\n"}, {"source_code": "var\n i,j,n,m,k:longint;\nbegin\nif (n=1)or(n=2) then write('1')\nelse if (n mod 2=0) then write('2')\nelse begin\n k:=0;\n readln(n);\n for i:=2 to trunc(sqrt(n)) do\n if n mod i=0 then begin k:=1;break;end;\n if k=0 then begin write(1);exit;end;\n k:=0;\n for i:=2 to trunc(sqrt(n-2)) do\n if n mod i=0 then begin k:=1;exit;end;\n if k=0 then write(2) else write(3);\n end;\n end.\n "}, {"source_code": "var\nn,i:longint;\nbol:boolean;\nbegin\nreadln(n);\nif n mod 2 = 0 then writeln(2)\nelse begin\nbol:=true;\n for i:=2 to round(sqrt(n)) do if n mod i = 0 then bol:=false;\n if bol then writeln(1)\n else\n writeln(3);\nend;\nend."}, {"source_code": "var d,x,ot:int64;\nbegin\nreadln(x);\nif (x mod 2=0) and (x>4) then writeln(2);\nif (x mod 2=1) and (x>5) then writeln(3);\nif (x=2) then writeln(1);\nif (x=3) then writeln(1);\nif (x=4) then writeln(1);\nif (x=5) then writeln(1);\nEnd."}, {"source_code": "var a,n,i,k:longint;\nbegin\n read(n);\n if (n=1)or(n=2) then write('1')\n else if (n mod 2=0) then write('2')\n else begin\n k:=0;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=0 then begin write('1'); exit; end;\n if k=1 then begin\n k:=0;\n n:=n-2;\n a:=trunc(sqrt(n));\n for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;\n if k=1 then write('3') else write('2');\n end;\n end;\nend."}, {"source_code": "Program ILoveYou;\nVAR n:int64;\n\nfunction Prim(x : int64) : boolean;\nVAR i:int64;\nBegin\n\nPrim:=true;\ni:=2;\nwhile (i <= sqrt(x)) do\nBegin\nif ((x mod i) = 0) then Begin Prim:=false; i:=x; end;\ni:=i + 1;\nend;\n\nend;\n\nBegin\n\nReadln(n);\nif Prim(n) then Writeln(1) else\nBegin\n\nif ((n mod 2) = 0) then Writeln(2) else Writeln(3);\n\nend;\n\nReadln;\nEND."}, {"source_code": " var n,i:longint;\n b:boolean;\nbegin\n readln(n);\n b:=true;\n for i:=2 to round(sqrt(n)+1) do\n if n mod i = 0 then begin\n b:=false;\n break;\n end;\n if b then\n writeln(1);\n if not b then\n if n mod 2 = 0 then\n writeln(2)\n else\n writeln(3);\nend.\n"}, {"source_code": "program yan;\n var i,j,x,y,a,b,n,m:longint;\n function prov(a:longint):boolean;\n var i,j,x,y:longint;\n begin\n prov:=false;\n for i:=2 to round(sqrt(a)) do\n if a mod i=0 then\n begin\n prov:=true;\n break;\n end;\n end;\nbegin\n readln(n);\n //for n:=30 to 100 do\n //begin m:=0;\n if not prov(n) then begin writeln(1); exit; end;\n a:=n-2; b:=2;\n while a>0 do\n begin\n if not((not prov(a))and(not prov(b))and(b<=a div 2)) then begin dec(a); inc(b); end\n else\n begin\n inc(m);\n if not prov(b) then break;\n a:=b-2; b:=2;\n end;\n end;\n if prov(n) then writeln(m+1);//end;\nend.\n"}, {"source_code": "var\n n,i,sum:longint;\nbegin\n readln(n);\n if n=1 then begin writeln(1);exit;end;\n i:=2;\n while n>=i do\n begin\n if n mod i<>0 then begin inc(sum);n:=n div i;end\n else inc(i);\n end;\n writeln(sum);\nend."}], "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b"} {"source_code": "{$apptype console}\n{$I+,R+,Q+}\nUses Sysutils;\nVar\n s1,s2,s3:string;\n i:integer;\nBegin\n readln(s1);\n readln(s2);\n readln(s3);\n for i:=1 to length(s1) do begin\n if pos(s1[i],s3)<>0 then delete(s3,pos(s1[i],s3),1)\n else begin\n writeln('NO');\n halt;\n end;\n end;\n for i:=1 to length(s2) do begin\n if pos(s2[i],s3)<>0 then delete(s3,pos(s2[i],s3),1)\n else begin\n writeln('NO');\n halt;\n end;\n end;\n if s3='' then writeln('YES')\n else writeln('NO');\nEnd.\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "program problem;\n\nvar i:integer;\n c1,c2,c3:array['A'..'Z'] of integer;\n ch:char;\n name1,name2,pile:string;\n\nbegin\nreadln(name1);\nreadln(name2);\nreadln(pile);\n\nfor i:=1 to length(name1) do begin\nc1[name1[i]]:=c1[name1[i]]+1;\n//writeln(c1[name1[i]]);\nend;\n//writeln('===');\nfor i:=1 to length(name2) do begin\nc2[name2[i]]:=c2[name2[i]]+1;\n//writeln(c2[name2[i]]);\nend;\n//writeln('===');\nfor i:=1 to length(pile) do begin\nc3[pile[i]]:=c3[pile[i]]+1;\n//writeln(c3[pile[i]]);\nend;\n\nfor ch:='A' to 'Z' do\n//writeln(ch,' ',c1[ch],' ',c2[ch],' ',c3[ch]);\nif (c1[ch]+c2[ch]<>c3[ch]) then begin\nwrite('NO');\nhalt;\nend;\nwrite('YES');\n\nend."}, {"source_code": "program ferst;\nvar\n d1,d2,b:string;\n n,i:integer;\nbegin\n readln(d1);\n readln(d2);\n d1:=d1+d2;\n readln(b);\n for i:=1 to length(d1) do \n if pos(d1[i],b)<>0 then delete(b,pos(d1[i],b),1) \n else begin write('NO');halt; end;\n\n if length(b)=0 then write('YES') else write('NO');\nend."}, {"source_code": "program ferst;\nvar\n d1,d2,b:string;\n n,i:integer;\nbegin\n readln(d1);\n readln(d2);\n readln(b);\n for i:=1 to length(d1) do \n if pos(d1[i],b)<>0 then delete(b,pos(d1[i],b),1) \n else begin write('NO');halt; end;\n\n for i:=1 to length(d2) do \n if pos(d2[i],b)<>0 then delete(b,pos(d2[i],b),1) \n else begin write('NO');halt; end;\n\n if length(b)=0 then write('YES') else write('NO');\nend."}, {"source_code": " var a,b,c:string;i:integer; G:array[1..256]of integer;\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\n\nfor i:=1 to length(a) do\ninc(g[ord(a[i])]);\nfor i:=1 to length(b) do\ninc(g[ord(B[i])]);\nfor i:=1 to length(C) do\nDEC(g[ord(C[i])]);\nfor i:=1 to 256 do\nif g[i]<>0 then BEGIN write('NO'); exit;END;\n write('YES')\nend."}, {"source_code": "var \n s1, s2, st: string;\n i: byte;\nbegin\n readln(s1);\n readln(s2);\n readln(st);\n if length(s1 + s2) <> length(st) then\n \tbegin\n \t\twrite('NO');\n \t\texit;\n \tend;\n for i:=1 to length(s1) do\n \tif pos(s1[i],st) <> 0 then\n \t\tdelete(st,pos(s1[i],st),1);\n for i:=1 to length(s2) do\n \tif pos(s2[i],st) <> 0 then\n \t\tdelete(st,pos(s2[i],st),1);\n if st = '' then write('YES') else write('NO');\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n f,f1:text;\n s,s1,s2:string;\n i,err:integer;\n check:array[1..255] of boolean;\n count,count1:array[1..255] of integer;\nbegin\n assign(f,fi);reset(f);\n assign(f1,fo);rewrite(f1);\n readln(f,s);\n readln(f,s1);\n readln(f,s2);\n fillchar(check,sizeof(check),false);\n fillchar(count,sizeof(count),0);\n fillchar(count1,sizeof(count1),0);\n err:=0;\n for i:=1 to length(s) do\n begin\n if(not check[ord(s[i])]) then begin\n check[ord(s[i])]:=true;\n end;\n inc(count[ord(s[i])]);\n end;\n for i:=1 to length(s1) do\n begin\n if(not check[ord(s1[i])]) then begin\n check[ord(s1[i])]:=true;\n end;\n inc(count[ord(s1[i])]);\n end;\n for i:=1 to length(s2) do\n begin\n if(not check[ord(s2[i])]) then begin\n writeln(f1,'NO');\n inc(err);\n break;\n end else inc(count1[ord(s2[i])]);\n end;\n { for i:=1 to 255 do\n begin\n if(count[i]<>0) then writeln(f1,'Chr[',i,']=',count[i]);\n if(count1[i]<>0) then writeln(f1,'Chr1[',i,']=',count1[i]);\n end; }\n for i:=1 to 255 do\n begin\n if(count[i]<>count1[i]) and(err=0) then begin\n writeln(f1,'NO');\n inc(err);\n break;\n end;\n end;\n if(err=0) then writeln(f1,'YES');\n close(f);\n close(f1);\nend."}, {"source_code": "program z;\nvar bufstr:string;\nmas:array['A'..'Z'] of integer;\na:char;\ni:integer;\nbegin\nreadln(bufstr);\n for i:=length(bufstr) downto 1 do\n begin\n inc(mas[bufstr[i]]);\n end;\nreadln(bufstr);\n for i:=length(bufstr) downto 1 do\n begin\n inc(mas[bufstr[i]]);\n end;\nreadln(bufstr);\n for i:=length(bufstr) downto 1 do\n begin\n dec(mas[bufstr[i]]);\n end;\n for a:='A' to 'Z' do\n begin\n if (mas[a]<0) or (mas[a]>0) then\n begin\n write('NO');\n exit;\n end;\n end;\n write('YES');\nend.\n"}, {"source_code": "var\n a,s,d,f:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n readln(x);\n readln(c);\n M:=C;\n for a:=1 to length(z) do\n BEGIN\n for s:=1 to length(c) do\n if(z[a]=c[s]) then begin delete(c,S,1); break; end;\n end;\n for a:=1 to length(x) do\n BEGIN\n for s:=1 to length(c) do\n if (x[a]=c[s]) then begin delete (C,S,1); break; end;\n end;\n if(length(c)=0) AND (LENGTH(X)+LENGTH(Z)=LENGTH(M)) then writeln('YES') else writeln('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "var\n a:array[1..26] of longint;\n b:array[1..26] of longint;\n s1,s2,s3:string;\n i,dk:longint;\nbegin\n readln(s1); readln(s2); readln(s3);\n for i:=1 to length(s1) do inc(a[ord(s1[i])-64]);\n for i:=1 to length(s2) do inc(a[ord(s2[i])-64]);\n for i:=1 to length(s3) do inc(b[ord(s3[i])-64]);\n for i:=1 to 26 do\n if a[i]<>b[i] then dk:=1;\n if dk=1 then write('NO') else write('YES');\nend.\n"}, {"source_code": "const fi=''; fo='';\nprocedure process;\nvar f,g:text; i:integer; s1,s2,s3:string; k:char; d:boolean;\n a,b:array['A'..'Z']of integer;\nbegin\n assign(f,fi); reset(f); assign(g,fo); rewrite(g);\n fillchar(a,sizeof(a),0);\n fillchar(b,sizeof(b),0);\n readln(f,s1); readln(f,s2); readln(f,s3);\n for i:=1 to length(s1) do inc(a[s1[i]]);\n for i:=1 to length(s2) do inc(a[s2[i]]);\n for i:=1 to length(s3) do inc(b[s3[i]]);\n d:=true;\n for k:='A' to 'Z' do if a[k]<>b[k] then begin d:=false; break; end;\n if d then write(g,'YES') else write(g,'NO');\n close(f); close(g);\nend;\nbegin process; end.\n"}, {"source_code": "var\n s:string;\n i,f:longint;\n x:char;\n a:array['A'..'Z']of longint;\n\nbegin\n Readln(s);\n for i:=1 to length(s) do\n Inc(a[s[i]]);\n Readln(s);\n for i:=1 to length(s) do\n Inc(a[s[i]]);\n Readln(s);\n\n for i:=1 to length(s) do\n Dec(a[s[i]]);\n f:=0;\n for x:='A' to 'Z' do\n if a[x] <> 0 then f:=-1;\n if f = 0 then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "program q;\nvar s, c, v : string;\ni, y : integer;\na, b : array [1..100] of char;\nx : char;\nl : boolean;\nbegin\n readln(s);\n readln(c);\n readln(v);\n s := s + c;\n if length(s) = length(v) then\n begin\n for i := 1 to length(s) do\n begin\n a[i] := s[i];\n b[i] := v[i];\n end;\n for i := 1 to length(s) do\n begin\n for y := 1 to length(s) - 1 do\n begin\n if ord(a[y]) > ord(a[y + 1]) then\n begin\n x := a[y];\n a[y] := a[y + 1];\n a[y + 1] := x;\n end;\n if ord(b[y]) > ord(b[y + 1]) then\n begin\n x := b[y];\n b[y] := b[y + 1];\n b[y + 1] := x;\n end;\n end;\n end;\n for i := 1 to length(s) do\n begin\n if a[i] <> b[i] then l := true;\n end;\n if l then write('NO')\n else write('YES');\n end\n else write('NO');\nend."}, {"source_code": "var\nf1:text;\ns,s1,s2,s3:string;\ni,j:longint;\nx1,x:char;\nbol:boolean;\nbegin\nbol:=true;\nreadln(s);\nreadln(s1);\nreadln(s2);\nif length(s)+length(s1)=length(s2) then begin\n s3:=s+s1;\n for i:=1 to length(s3)-1 do\n for j:=i+1 to length(s3) do\n if s3[i]>s3[j] then begin\n x:=s3[i];\n s3[i]:=s3[j];\n s3[j]:=x;\n end;\n \n for i:=1 to length(s3)-1 do\n for j:=i+1 to length(s3) do\n if s2[i]>s2[j] then begin\n x1:=s2[i];\n s2[i]:=s2[j];\n s2[j]:=x1;\n end;\n \n for i:=1 to length(s3) do if s3[i]<>s2[i] then begin\n bol:=false;\n break;\n end;\n if bol then writeln('YES')\n else\n writeln('NO');\n \n \nend\nelse\nwriteln('NO');\nend."}, {"source_code": "var\ns:string;\ni:longint;\nbol:boolean;\na:array[-100..1000]of longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do dec(a[ord(s[i])]);\nfor i:=-100 to 1000 do begin\n if a[i]<>0 then bol:=true;\nend;\nif bol then writeln('NO')\nelse\nwriteln('YES');\nend."}, {"source_code": "var s1,s2,s:string;\n i:longint;\n a1,a2:array[1..100] of longint;\nbegin\n readln(s1);\n readln(s2);\n readln(s);\n s1:=s1+s2;\n for i:=1 to length(s1) do\n a1[ord(s1[i])]:= a1[ord(s1[i])]+1;\n for i:=1 to length(s) do\n a2[ord(s[i])]:= a2[ord(s[i])]+1;\n for i:= 65 to 90 do\n if a1[i] <> a2[i] then\n begin\n write('NO');\n exit;\n end;\n write('YES');\nend."}, {"source_code": "var\nf1:text;\ns,s1,s2,s3:string;\ni,j:longint;\nx1,x:char;\nbol:boolean;\nbegin\nbol:=true;\nreadln(s);\nreadln(s1);\nreadln(s2);\nif length(s)+length(s1)=length(s2) then begin\n s3:=s+s1;\n for i:=1 to length(s3)-1 do\n for j:=i+1 to length(s3) do\n if s3[i]>s3[j] then begin\n x:=s3[i];\n s3[i]:=s3[j];\n s3[j]:=x;\n end;\n \n for i:=1 to length(s3)-1 do\n for j:=i+1 to length(s3) do\n if s2[i]>s2[j] then begin\n x1:=s2[i];\n s2[i]:=s2[j];\n s2[j]:=x1;\n end;\n \n for i:=1 to length(s3) do if s3[i]<>s2[i] then begin\n bol:=false;\n break;\n end;\n if bol then writeln('YES')\n else\n writeln('NO');\n \n \nend\nelse\nwriteln('NO');\nend."}, {"source_code": "var\n a,b,c,s:ansistring;\n x,y:array[0..128] of longint;\n i:longint;\nbegin\n readln(a);\n readln(b);\n readln(c);\n s:=a+b;\n if length(s)<>length(c) then\n begin\n writeln('NO');\n halt;\n end;\n for i:=1 to length(s) do\n begin\n inc(x[ord(s[i])]);\n inc(y[ord(c[i])]);\n end;\n for i:=1 to 128 do\n if x[i]<>y[i] then\n begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\nend."}, {"source_code": "var\n a,b,c,temp: string; n,i : integer;\n\nbegin\n readln(a); readln(b); readln(c);\n insert(a,b,1); n := length(b);\n if (n <> length(c)) then writeln('NO')\n else begin\n for i:=1 to n do\n begin\n temp := b;\n delete(temp,1,i-1); delete(temp,2,n-i);\n delete(c,pos(temp,c),1);\n end;\n if(c = '') then writeln('YES')\n else writeln('NO');\n end;\nend."}, {"source_code": "var a,b,c:string;\n d:array[1..10000] of integer;\n i:integer;\n t:boolean;\nbegin\nreadln (a);\nreadln (b);\nread (c);\nif length(b)+length(a)=length(c) then\nbegin\nfor i:=1 to length (a) do\ninc(d[ord(a[i])]);\n\nfor i:= 1 to length(b) do\ninc(d[ord(b[i])]);\n\nfor i:=1 to length (c) do\nif d[ord(c[i])]<=0 then begin t:=true; break; end else (dec(d[ord(c[i])]));\n\n\nif (t=false) then writeln('YES') else writeln('NO');\nend else writeln('NO');\n\nend."}, {"source_code": "var \n s, s1, s2, s3 : string;\n count : longint;\nbegin\n count := 0;\n readln(s);\n readln(s1);\n readln(s2);\n s2 := s2 + ' ';\n s3 := s + s1;\n if length(s2) <> length(s3) + 1 then writeln('NO') else begin\n while s2 <> ' ' do begin\n if pos(s2[1],s3) <> 0 then begin count := count + 1; delete(s3,pos(s2[1],s3),1); delete(s2,1,1); end else break;\n end;\n if count = length(s) + length(s1) then writeln('YES') else writeln('NO');\n end;\nend."}, {"source_code": "const f1='141a.inp';\n f2='141a.out';\nvar a,b:string;\n j,d,i:longint;\n\n begin\n // assign(input,f1);reset(input);\n //assign(output,f2);rewrite(output);\n\n readln(a);\n readln(b);\n a:=a+b;\n readln(b);\n\n\n for i:=1 to length(a) do\n begin\n if pos(a[i],b)<>0 then\n delete(b,pos(a[i],b),1) else inc(d)\n\n end;\n\n if (b='') and (d=0) then writeln('YES') else writeln('NO');\n\nend.\n"}, {"source_code": "\ntype\n mas = array [1..26] of longint;\n \n var\n i:longint;\n s1,s2,full,aph:string;\n bckvid,prov:mas;\n check:boolean;\n begin\n aph:='QWERTYUIOPASDFGHJKLZXCVBNM';\n readln(s1);\n readln(s2);\n readln(full);\n for i:=1 to 26 do\n begin\n bckvid[i]:=0;\n prov[i]:=0;\n end; \n for i:=1 to length(s1) do\n begin\n bckvid[pos(copy(s1,i,1),aph)]+=1;\n end;\n for i:=1 to length(s2) do\n begin\n bckvid[pos(copy(s2,i,1),aph)]+=1;\n end;\n \n for i:=1 to length(full) do\n begin\n prov[pos(copy(full,i,1),aph)]+=1;\n end; \n \n check:=true;\n for i:=1 to 26 do \n if prov[i]<>bckvid[i] then\n check:=false;\n \n if check then\n writeln('YES')\n else \n writeln('NO');\n end."}, {"source_code": "var i,j,k,l,n:integer;\n a,b:array [1..500] of integer;\n ch:char;\nbegin\nwhile not eoln do begin\nread(ch);\na[ord(ch)-64]:=a[ord(ch)-64]+1;\nend;\nreadln;\nwhile not eoln do begin\nread(ch);\na[ord(ch)-64]:=a[ord(ch)-64]+1;\nend;\nreadln;\nwhile not eoln do begin\nread(ch);\nb[ord(ch)-64]:=b[ord(ch)-64]+1;\nend;\nfor i:= 1 to 50 do\nif a[i]<>b[i] then begin write('NO'); exit; end;\nwrite('YES');\nend."}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..26] of integer;\nbegin\n\tfor i := 1 to 26 do begin\n\t\td[i] := 0;\n\t\te[i] := 0;\n\tend;\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif (d[i] <> e[i]) then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "Var s,t,ans:ansistring;\n a:array[0..200] of longint;\n i:longint;\n begin\n readln(s);\n for i:=1 to length(s) do inc(a[ord(s[i])]);\n readln(s);\n for i:=1 to length(s) do a[ord(s[i])]:=a[ord(s[i])]+1;\n readln(s);\n for i:=1 to length(s) do a[ord(s[i])]:=a[ord(s[i])]-1;\n ans:='YES';\n for i:=1 to 200 do\n if a[i]<>0 then\n begin\n ans:='NO';\n break;\n end;\n writeln(ans);\n end."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MAXSTACKSIZE $01000000}\n\nprogram ProblemA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s1, s2, s12: string;\nslov1, slov2: array ['A'..'Z'] of integer;\n\nprocedure r1;\nbegin\n readln(s1);\n readln(s2);\n readln(s12);\nend;\n\nprocedure ex1;\nvar i: integer;\ni1: char;\nr: boolean;\nbegin\n fillchar(slov1, sizeof(slov1), 0);\n fillchar(slov2, sizeof(slov2), 0);\n for i := 1 to length(s1) do\n inc(slov1[s1[i]]);\n for i := 1 to length(s2) do\n inc(slov1[s2[i]]);\n for i := 1 to length(s12) do\n inc(slov2[s12[i]]);\n r := true;\n for i1 := 'A' to 'Z' do\n if slov1[i1] <> slov2[i1] then\n r := false;\n if r then\n write('YES')\n else\n write('NO');\n\nend;\n\nbegin\n r1;\n ex1;\nend.\n"}, {"source_code": "{$o-}\nuses math;\nvar\n s, ss, ss2: string;\n was, was2: array [1..50] of longint;\n i: longint;\n\nbegin\n//\treset(input, 'a.in');\n//\trewrite(output, 'a.out');\n\n readln(s);\n readln(ss);\n readln(ss2);\n\n For i := 1 to length(s) do\n inc(was[Ord(s[i]) - 64]);\n\n For i := 1 to length(ss) do\n inc(was[ord(ss[i])- 64]);\n\n For i := 1 to length(ss2) do\n inc(was2[ord(ss2[i]) - 64]);\n\n For i := 1 to 27 do\n if was[i] <> was2[i] then begin write('NO');halt;end;\n\n write('YES');\n\n\nend."}, {"source_code": "var s,s1,s2 :string;\n i,j,l:integer;\n k,k1,k2,k3:integer;\n begin\n read(s);\n readln;\n read(s1);\n readln;\n read(s2);\n for i:=1 to length(s) do\n inc(k);\n for l:=1 to length(s2) do\n inc(k3);\n for j:=1 to length(s1) do\n inc(k2);\n if k+k2<>k3 then \n begin\n write('NO');\n halt;\n end; \n \n \n for l:=1 to length(s2) do\n for i:=1 to length(s) do \n if s[i]=s2[l] then \n begin\n s[i]:='1';\n s2[l]:='0';\n inc(k1);\n end;\n \n {writeln(k,' ',k1); }\n \n \n for j:=1 to length(s1) do\n for l:=1 to length(s2) do\n if s1[j]=s2[l] then \n begin\n s1[j]:='2';\n s2[l]:='0';\n inc(k1);\n end; \n \n {writeln(k2,' ',k1);} \n if k+k2=k1 then write('YES') else\n write('NO');\n end. \n "}, {"source_code": "type vector=array[1..91] of integer;\nvar Name1, Name2, SS : string;\n I : byte;\n A, B : vector;\nbegin\n//assign(input, 'input.txt'); reset(input);\nreadln(Name1);\nreadln(Name2);\nreadln(SS);\nif length(Name1) + length(Name2) <> length(SS) then\n begin\n write('NO');\n exit;\n end;\n for I := 1 to length(Name1) do\n A[ord(Name1[I])] := A[ord(Name1[I])] + 1;\n \n for I := 1 to length(Name2) do\n A[ord(Name2[I])] := A[ord(Name2[I])] + 1; \n \n for I := 1 to length(SS) do\n B[ord(SS[I])] := B[ord(SS[I])] + 1;\n \n for I := 1 to 91 do\n if A[I] <> B[I] then\n begin\n write('NO');\n exit;\n end;\n write('YES'); \nend. "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,k:integer;\n s1,s2,s3:string;\n allfound:boolean;\nbegin\n\n readln(s1);\n readln(s2);\n readln(s3);\n\n s1:=s1+s2;\n allfound:=true;\n for i:=1 to length(s1) do\n begin\n\n k:=pos(s1[i],s3);\n if k>0 then delete(s3,k,1) else\n begin\n allfound:=false;\n break;\n end;\n\n end;\n if length(s3)>0 then allfound:=false;\n if allfound then writeln('YES') else writeln('NO');\n //readln;\n\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nprocedure swap(a, b: integer);\nvar\n t: integer;\nbegin\n t := a;\n a := b;\n b := t;\nend;\n\nvar\n i: integer;\n c: char;\n s, s1, s2: string;\n a: array['A'..'Z'] of integer;\n\nbegin\n //reset(input, 'input.txt'); rewrite(output, 'output.txt');\n readln(s);\n readln(s1);\n readln(s2);\n for i := 1 to length(s) do\n inc(a[s[i]]);\n for i := 1 to length(s1) do\n inc(a[s1[i]]);\n for i := 1 to length(s2) do\n begin\n dec(a[s2[i]]);\n if a[s2[i]] = -1 then\n begin\n writeln('NO');\n halt;\n end;\n end;\n for c := 'A' to 'Z' do\n if a[c] <> 0 then\n begin\n writeln('NO');\n halt;\n end;\n writeln('YES');\n //close(input); close(output);\nend.\n "}, {"source_code": "var\n s1,s2,s3:string;\n i,j:integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nfor i:=1 to length(s1) do\n if pos(s1[i],s3)<>0 then begin\n inc(j);\n delete(s3,pos(s1[i],s3),1);\nend; \nfor i:=1 to length(s2) do \n if pos(s2[i],s3)<>0 then begin\n inc(j);\n delete(s3,pos(s2[i],s3),1);\nend; \nif (length(s1)+length(s2)=j) and (length(s3)=0) then writeln('YES') else writeln('NO');\n end."}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n a,b,x:Array['A'..'Z'] of Integer;\n i,c:Char;\nBegin\n For i:='A' To 'Z' Do Begin\n a[i]:=0;\n b[i]:=0;\n x[i]:=0;\n End;\n While not SeekEoln Do Begin\n Read(c);\n a[c]:=a[c]+1;\n End;\n ReadLn;\n While not SeekEoln Do Begin\n Read(c);\n b[c]:=b[c]+1;\n End;\n ReadLn;\n While not SeekEoln Do Begin\n Read(c);\n x[c]:=x[c]+1;\n End;\n For i:='A' To 'Z' Do\n If x[i]<>a[i]+b[i] Then Begin\n Write('NO');\n Halt;\n End;\n Write('YES');\nEnd.\n\n"}, {"source_code": "program MOROZ;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils;\n\nvar\n s, s1, s2 : string;\n j, i : longint;\n\nbegin\n\n\n readln(s);\n readln(s1);\n readln(s2);\n\n if length(s) + length(s1) > length(s2) then\n begin\n writeln('NO');\n halt;\n end;\n for i := 1 to length(s) do\n begin\n for j := 1 to length(s2) do\n if s[i] = s2[j] then\n begin\n delete(s2, j, 1);\n break;\n end;\n if length(s2) = 0 then\n begin\n writeln('NO');\n halt;\n end;\n end;\n if length(s2) <> length(s1) then\n begin\n writeln('NO');\n halt;\n end else\n begin\n for i := 1 to length(s1) do\n for j := 1 to length(s2) do\n if s1[i] = s2[j] then\n begin\n delete(s2, j, 1);\n break;\n end;\n end;\n if length(s2) = 0 then\n writeln('YES') else\n writeln('NO');\nend.\n "}, {"source_code": "var i,j,k,l,n,m:integer;\n s,s1,s2,s3,s4,s5,s6:string;\n\nbegin\n\n readln(s);\n readln(s1);\n read(s2);\n\n i:=1;\n while i<=length(s) do\n begin\n n:=0;\n for j:=1 to length(s2) do\n begin\n if (s[i]=s2[j])and(n=0) then begin delete(s2,j,1);inc(n);\n inc(l); end;\n end;\n if n<>0 then delete(s,i,1)\n else inc(i);\n end;\n i:=1;\n while i<=length(s1) do\n begin\n m:=0;\n for j:=1 to length(s2) do\n begin\n if (s1[i]=s2[j])and(m=0) then begin delete(s2,j,1); inc(m);\n inc(k); end;\n end;\n if m<>0 then delete(s1,i,1)\n else inc(i);\n end;\n\n\n if (length(s2)=0)and (length(s1)=0)and(length(s)=0) then write('YES')\n else write('NO');\n\n\n\n\nend."}, {"source_code": "var\na,b,c:string;\np:boolean;\ni,j,k:integer;\nbegin\n readln(a);\n readln(b);\n readln(c);\n \n p:=true;\n i:=1;\n while (i<=length(a)) and p do\n begin\n p:=false;\n j:=1;\n while (j<=length(c)) and not p do\n begin\n if a[i]=c[j] then p:=true;\n if p then delete(c,j,1);\n inc(j);\n end;\n inc(i);\n end;\n\n i:=1;\n while (i<=length(b)) and p do\n begin\n p:=false;\n j:=1;\n while (j<=length(c)) and not p do\n begin\n if b[i]=c[j] then p:=true;\n if p then delete(c,j,1);\n inc(j);\n end;\n inc(i);\n end;\n\n if p and (length(c)=0) then write('YES') else write('NO');\n\nend."}, {"source_code": "var a,b,c:array['A'..'Z']of Integer;\ns:string;\ni:integer;\nch:Char;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(s);\n for i:=1 to Length(s) do\n Inc(a[s[i]]);\n\n Readln(s);\n for i:=1 to Length(s) do\n Inc(b[s[i]]);\n\n Readln(s);\n for i:=1 to Length(s) do\n Inc(c[s[i]]);\n for ch:='A' to 'Z' do\n begin\n if not(a[ch]+b[ch]=c[ch])\n then begin\n writeln('NO');\n Halt(0);\n end;\n end;\n Writeln('YES');\nend.\n"}, {"source_code": "var a:\n array[\n 'A'\n ..\n 'Z'\n ]\n of longint;\n\n i:\n longint;\n\n flag:\n boolean;\n\nfunction pd(\n x:\n longint\n ):\n longint;\n begin\n if\n x>2\n then\n exit(\n -\n +1\n )\n else\n exit(\n -\n -1\n );\n end;\n\nprocedure add;\n var st:\n string;\n\n j:\n longint;\n begin\n readln(\n st\n );\n for j:=\n 1\n to\n length(\n st\n )\n do\n begin\n inc(\n a[\n st[\n j\n ]\n ]\n ,\n pd(\n i\n )\n );\n end;\n end;\n\nbegin\n fillchar(\n a\n ,\n sizeof(\n a\n )\n ,\n 0\n );\n for i:=\n 1\n to\n 3\n do\n add;\n flag:=\n true;\n for i:=\n 1\n to\n 26\n do\n if\n not(\n a[\n chr(\n i\n -\n -64\n )\n ]=0\n )\n then\n begin\n flag:=\n false;\n break;\n end;\n if\n flag\n then\n writeln(\n 'YES'\n )\n else\n writeln(\n 'NO'\n );\nend."}, {"source_code": "program main;\n\nvar\n str1,str2,str3 : string;\n i,j,len : longint;\n flag : boolean;\n \nbegin\n\n readln(str1);\n readln(str2);\n readln(str3);\n \n len:=length(str1) + length(str2);\n for i:=1 to length(str3) do begin\n flag:=false;\n for j:=1 to length(str1) do begin\n if str3[i] = str1[j] then begin\n Delete(str1,j,1);\n flag:=true;\n break;\n end;\n end;\n if flag = false then begin\n for j:=1 to length(str2) do begin\n if str3[i] = str2[j] then begin\n Delete(str2,j,1);\n break;\n end;\n end;\n end;\n if (length(str1) + length(str2)) = 0 then break;\n end;\n \n if ((length(str1)+length(str2)) = 0) and ((length(str3) - len) = 0) then writeln('YES')\n else writeln('NO');\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s1,s2,ss: string;\n a1,a2: array ['A'..'Z'] of integer;\n i,j,k,l1,L,l2,l3: integer;\n f: boolean;\n c: char;\nbegin\n readln(s1);\n readln(s2);\n readln(ss);\n l:=length(s1);\n for i:=1 to L do inc(a1[s1[i]]);\n L:=length(s2);\n for i:=1 to L do inc(a1[s2[i]]);\n L:=length(ss);\n for i:=1 to L do inc(a2[ss[i]]);\n f:=true;\n for c:='A' to 'Z' do\n if a1[c]<>a2[c] then f:=false;\n\n if f then writeln('YES') else writeln('NO');\n\nend.\n"}, {"source_code": "var\n i,i1,y,t,y1,t1:longint;\n s,s1,s2:string;\nbegin\nreadln(s);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s2) do\nbegin\n y:=0;\n y1:=0;\n for i1:=1 to length(s) do\n if s[i1]=s2[i] then begin y:=1; t:=i1; end;\n for i1:=1 to length(s1) do\n if s1[i1]=s2[i] then begin y1:=1; t1:=i1; end;\n if (y=0) and (y1=0) then begin write('NO'); exit; end;\n if y=1 then s[t]:='!' else if y1=1 then s1[t1]:='!';\nend;\nif length(s)+length(s1)<>length(s2) then write('NO') else write('YES');\nend."}, {"source_code": "var s1,s2,s3:string[100];\n i,j:integer;\n a,c:array[65..90] of integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nfor i:=1 to length(s1) do\n inc(a[ord(s1[i])]);\nfor i:=1 to length(s2) do\n inc(a[ord(s2[i])]);\nfor i:=1 to length(s3) do\n inc(c[ord(s3[i])]);\nfor i:=65 to 90 do\n begin\n if a[i]=c[i] then begin\n a[i]:=0;\n c[i]:=0;\n end\n else begin\n writeln('NO');\n halt;\n end;\n end;\nwriteln('YES');\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n s1, s2, s3: ansistring;\n i: longint;\nbegin\n readln(s1); readln(s2); readln(s3);\n if length(s1) + length(s2) > length(s3) then writeln('NO') else\n begin\n for i:= 1 to length(s1) do delete(s3,pos(s1[i],s3),1);\n for i:= 1 to length(s2) do delete(s3,pos(s2[i],s3),1);\n if s3 = '' then writeln('YES') else writeln('NO');\n end;\nend.\n"}, {"source_code": "program zzz;\nvar\n k, k0: array['A'..'Z'] of byte;\n s, s0: ansistring;\n i: byte;\n c: char;\nbegin\n FillChar(k0, SizeOf(k0), 0);\n FillChar(k, SizeOf(k), 0);\n readln(s0);\n for i := 1 to Length(s0) do\n inc(k0[s0[i]]);\n readln(s0);\n for i := 1 to Length(s0) do\n inc(k0[s0[i]]);\n readln(s);\n for i := 1 to Length(s) do\n inc(k[s[i]]);\n for c := 'A' to 'Z' do\n if k[c] <> k0[c]\n then begin\n write('NO');\n halt;\n end;\n write('YES');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s1,s2,s3:string;\n a,b:array[1..26]of integer;\n i:integer;\nbegin\n readln(s1);\n readln(s2);\n readln(s3);\n for i:=1 to 26 do\n begin\n a[i]:=0;\n b[i]:=0;\n end;\n for i:=1 to length(s1) do inc(a[ord(s1[i])-64]);\n for i:=1 to length(s2) do inc(a[ord(s2[i])-64]);\n for i:=1 to length(s3) do inc(b[ord(s3[i])-64]);\n for i:=1 to 26 do\n begin\n if a[i]<>b[i] then\n begin\n writeln('NO');\n exit;\n end;\n end;\n writeln('YES');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar\n str, str2, str1: string;\n a1, a2, a, b: array[1..26] of longint;\n i, j, k: longint;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(str1);\n readln(str2);\n readln(str);\n for i := 1 to length(str1) do\n begin\n inc(a1[ord(str1[i]) - ord('A') + 1]);\n end;\n for i := 1 to length(str2) do\n begin\n inc(a2[ord(str2[i]) - ord('A') + 1]);\n end;\n for i := 1 to length(str) do\n begin\n inc(b[ord(str[i]) - ord('A') + 1]);\n end;\n for j := 1 to 26 do\n begin\n a[j] := a1[j] + a2[j];\n end;\n for i := 1 to 26 do\n begin\n if a[i] = b[i] then\n inc(k);\n end;\n if k = 26 then\n writeln('YES')\n else\n writeln('NO');\nend.\n "}, {"source_code": "var\ns1:string;\ni:longint;\nsum:array['A'..'Z']of longint;\nch:char;\nbegin\n readln(s1);\n for i:=1 to length(s1) do inc(sum[s1[i]]);\n readln(s1);\n for i:=1 to length(s1) do inc(sum[s1[i]]);\n readln(s1);\n for i:=1 to length(s1) do begin\n dec(sum[s1[i]]);\n end;\n for ch:='A' to 'Z' do\n if sum[ch]<>0 then\n begin\n writeln('NO');\n halt;\n end;\n\n writeln('YES');\nend.\n"}, {"source_code": "var s1,s2,s3:string;\n a:array['A'..'Z']of longint;\n j:char;\n i:longint;\n ans:boolean;\nbegin\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s1) do\n inc(a[s1[i]]);\nfor i:=1 to length(s2) do\n inc(a[s2[i]]);\nreadln(s3);\nfor i:=1 to length(s3) do\n dec(a[s3[i]]);\nans:=true;\nfor j:='A' to 'Z' do\n if a[j]<>0 then ans:=false;\nif ans=false then write('NO')\nelse write('YES');\nend.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n T=record\n k1,k3:integer;\n end;\nvar\n a:array['A'..'Z'] of T;\n i:integer;\n c:char;\n s1,s2,s3:string;\nbegin\n c:='A';\n while true do\n begin a[c].k1:=0; a[c].k3:=0; if c='Z' then break; c:=Succ(c); end;\n readln(s1); readln(s2); readln(s3);\n for i:=1 to length(s1) do inc(a[s1[i]].k1);\n for i:=1 to length(s2) do inc(a[s2[i]].k1);\n for i:=1 to length(s3) do inc(a[s3[i]].k3);\n c:='A';\n while true do\n begin\n if (a[c].k1<>a[c].k3) then\n begin writeln('NO'); exit; end;\n if c='Z' then break;\n c:=Succ(c);\n end;\n writeln('YES');\nend.\n"}, {"source_code": "{function swap(a,b:char):integer;\nvar x:char;\nbegin\nx:=a;\na:=b;\nb:=x;\nend;\n}\nvar s1,s,s2,s3:string;\ni,j:integer;q1,q:char;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\ns:=s1+s2;\nfor i:=1 to length(s) do\nfor j:=i+1 to length(s) do\nif s[i]>s[j] then begin q:=s[i];s[i]:=s[j];s[j]:=q;end;\n\nfor i:=1 to length(s3) do\nfor j:=i+1 to length(s3) do\nif s3[i]>s3[j] then begin q1:=s3[i];s3[i]:=s3[j];s3[j]:=q1;end;\nif s3=s then write('YES') else write('NO');\nend."}, {"source_code": "Var\n I : Integer;\n f : Boolean;\n S1, S2, S3 : String;\nbegin\n ReadLn (S1);\n ReadLn (S2);\n ReadLn (S3);\n f := true;\n if (Length (s1) + Length (s2)) <> Length (s3) then\n f := false;\n for I := 1 to Length (S1) do\n If Pos (S1[I], S3) <> 0 then\n Delete (S3, Pos (S1[I], S3), 1)\n else\n f := false;\n for I := 1 to Length (S2) do\n If Pos (S2[I], S3) <> 0 then\n Delete (S3, Pos (S2[I], S3), 1)\n else\n f := false;\n If f then\n WriteLn ('YES')\n else\n WriteLn ('NO');\nend."}, {"source_code": "{$MODE OBJFPC}\n\nvar s1, s2, s3, s : string;\n i : integer;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Assign(Input, 'TEST.INP'); Reset(Input);\n {$ENDIF}\n readln(s1); readln(s2); readln(s3);\n s := s1 + s2; i := 1;\n while (s3 <> '') and (i <= length(s3)) do\n if s3[1] = s[i] then\n begin\n delete(s3,1,1);\n delete(s,i,1);\n i := 1;\n end\n else inc(i);\n if s3 = '' then write('YES') else write('NO');\nend.\n\n\n\n\n"}, {"source_code": "var\n ch1,ch2,ch3:string;\n i:longint;\n dem,demt:array[0..300] of longint;\nbegin\n readln(ch1); readln(ch2); readln(ch3);\n if((length(ch1)+length(ch2))<>length(ch3)) then begin writeln('NO'); exit; end;\n \n for i:=1 to length(ch1) do\n inc(dem[ord(ch1[i])]);\n \n for i:=1 to length(ch2) do\n inc(dem[ord(ch2[i])]);\n \n for i:=1 to length(ch3) do\n inc(demt[ord(ch3[i])]);\n \n for i:=0 to 300 do\n if(dem[i]<>demt[i]) then begin writeln('NO'); exit; end;\n \n writeln('YES');\nend."}, {"source_code": "var\na,b:array[1..1000] of integer;\ns:string;\ni:integer;\nbegin\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do inc(b[ord(s[i])]);\nfor i:=1 to 1000 do if a[i]<>b[i] then begin writeln('NO'); exit; end;\nwriteln('YES');\nend."}, {"source_code": "var\na:array[1..1000] of integer;\ns:string;\ni:integer;\nbegin\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do inc(a[ord(s[i])]);\nreadln(s);\nfor i:=1 to length(s) do dec(a[ord(s[i])]);\nfor i:=1 to 1000 do if a[i]<>0 then begin writeln('NO'); exit; end;\nwriteln('YES');\nend."}, {"source_code": "var s,s1,s2:string;\na,b:array[40..90] of longint;\ni,j:longint;\nbegin\nreadln(s);\nfor i:=1 to length(s) do\ninc(a[ord(s[i])]);\nreadln(s1);\nfor i:=1 to length(s1) do\ninc(a[ord(s1[i])]);\nreadln(s2);\nfor i:=1 to length(s2) do\n inc(b[ord(s2[i])]);\nfor i:=40 to 90 do\n if a[i]<>b[i] then begin writeln('NO'); exit; end;\n writeln('YES');\n end.\n"}, {"source_code": "var i:integer;\na,b,c:string;\nm:array[0..256] of integer;\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nfor i:=1 to length(a) do\ninc(m[ord(a[i])]);\nfor i:=1 to length(b) do\ninc(m[ord(b[i])]);\nfor i:=1 to length(c) do\ndec(m[ord(c[i])]);\nfor i:=1 to 256 do\nif (m[i]<>0) then begin\nwriteln('NO');\nexit;\nend;\nwriteln('YES');\nend."}, {"source_code": "program joke;\n\n{$APPTYPE CONSOLE}\n\nvar\ni,j:integer;\nn,f,k:string;\nerr,sovp:boolean;\nbegin\nreadln(n);\nreadln(f);\nreadln(k);\nif length(k)<>(length(n)+length(f)) then writeln('NO') else\n begin\n i:=1;\n err:=false;\n while (i<=length(n)) and not err do begin\n j:=1;\n sovp:=false;\n while not sovp and (j<=length(k)) do begin\n if n[i]=k[j] then begin sovp:=true; delete(n,i,1); delete(k,j,1); end;\n inc(j);\n end;\n if not sovp then err:=true;\n end;\n i:=1;\n while (i<=length(f)) and not err do begin\n j:=1;\n sovp:=false;\n while not sovp and (j<=length(k)) do begin\n if f[i]=k[j] then begin sovp:=true; delete(f,i,1); delete(k,j,1); end;\n inc(j);\n end;\n if not sovp then err:=true;\n end;\n if length(k)>0 then err:=true;\n if err then writeln('NO') else writeln('YES');\n end;\nreadln;\nend.\n"}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n i,j:integer;\n n1,n2,s:string;\n p:char;\n Yes:boolean;\nbegin\n readln(n1);\n readln(n2);\n readln(s);\n Yes:=true;\n for i:=1 to length(n1) do\n if pos(n1[i],s)<>0 then\n delete(s,pos(n1[i],s),1)\n else Yes:=false;\n if yes then\n for i:=1 to length(n2) do\n if pos(n2[i],s)<>0 then\n delete(s,pos(n2[i],s),1)\n else Yes:=false;\n if (length(s)<>0) or not(Yes) then\n writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "{$APPTYPE CONSOLE}{$o-}\n\nuses\n SysUtils, math;\n\nvar\n a, b, c: string;\n i: longint;\n\nbegin\n// reset(input, 'input.txt');\n// assign(output, 'output.txt');\n readln(a);\n readln(b);\n read(c);\n for i := 1 to length(a) do\n begin\n if pos(a[i], c) = 0 then\n begin\n write('NO');\n halt;\n end;\n delete(c, pos(a[i], c), 1);\n end;\n for i := 1 to length(b) do\n begin\n if pos(b[i], c) = 0 then\n begin\n write('NO');\n halt;\n end;\n delete(c, pos(b[i], c), 1);\n end;\n if length(c) = 0 then\n write('YES')\n else\n write('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype\n list=array[1..1000000]of integer;\nvar\n a,b:list;\n n,p,i,j,h,l,g,c,e,k1,y,f,m,k,code:Integer;\n s,s1,s2:string;\nprocedure quicksort(var b:list; left,right:integer);\nvar\n i,j,temp,p:integer;\nbegin\n i:=left;\n j:=right;\n p:=b[(left+right)div 2];\n repeat\n while(b[i]p) do dec(j);\n if(i<=j)then begin\n temp:=b[i];\n b[i]:=b[j];\n b[j]:=temp;\n inc(i);\n dec(j);\n end;\n until(i>j);\n if(j>left)then quicksort(b,left,j);\n if(ib[i]) then Inc (k);\n if (k=0) then Writeln('YES')\n else Writeln('NO');\n Readln;\n Readln;\nend.\n "}, {"source_code": "var s,t,u:string;\n i:longint;\n a:array [char] of longint;\n ch:char;\nbegin\n readln(s);\n readln(t);\n readln(u);\n for i:=1 to length(s) do\n inc(a[s[i]]);\n for i:=1 to length(t) do\n inc(a[t[i]]);\n for i:=1 to length(u) do\n dec(a[u[i]]);\n for ch:='A' to 'Z' do\n if a[ch]<>0 then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\nend."}, {"source_code": "var i,j:longint;\n s,t,st:string;\n a,b:Array [1..100] of boolean;\nbegin\n readln(s);\n readln(t);\n readln(st);\n fillchar(b,sizeof(b),true);\n fillchar(a,sizeof(a),true);\n for i:=1 to length(s) do\n begin\n for j:=1 to length(st) do\n if b[j] and (st[j]=s[i]) then\n begin\n b[j]:=false;\n a[i]:=false;\n break;\n end;\n if a[i] then\n begin\n writeln('NO');\n exit;\n end;\n end;\n fillchar(a,sizeof(a),true);\n for i:=1 to length(t) do\n begin\n for j:=1 to length(st) do\n if b[j] and (st[j]=t[i]) then\n begin\n b[j]:=false;\n a[i]:=false;\n break;\n end;\n if a[i] then\n begin\n writeln('NO');\n exit;\n end;\n end;\n for i:=1 to length(st) do\n if b[i] then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\nend."}, {"source_code": "program TaskA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,b,c : string;\n i,p,n : byte;\n f : boolean;\nbegin\n readln(a);\n readln(b);\n readln(c);\n a:=a+b;\n n:=length(a);\n if n<>length(c) then write('NO') else\n begin\n f:=true;\n for i:=1 to n do\n begin\n p:=pos(a[i],c);\n if p=0 then\n begin\n f:=false;\n break;\n end\n else delete(c,p,1);\n end;\n if f then write('YES') else write('NO');\n end;\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar guest,owner,heap:string[101];\nh:array of boolean;\ni,j:smallint;\nbegin\n readln(guest);\n readln(owner);\n readln(heap);\n if length(guest)+length(owner)>length(heap) then\n begin\n write('NO');\n halt;\n end\n else\n if length(heap)guest[i]) or (h[j]=true)) and (j<=length(heap)) do\n j:=j+1;\n if j>length(heap) then\n begin\n write('NO');\n halt;\n end;\n i:=i+1;\n h[j]:=true;\n end;\n i:=1;\n while (i<=length(owner)) do\n begin\n j:=1;\n while ((heap[j]<>owner[i]) or (h[j]=true)) and (j<=length(heap)) do\n j:=j+1;\n if j>length(heap) then\n begin\n write('NO');\n halt;\n end;\n i:=i+1;\n h[j]:=true;\n end;\n i:=1;\n while (h[i]) and (i<=length(heap)) do\n i:=i+1;\n if i<=length(heap) then\n begin\n write('NO');\n halt;\n end;\n write('YES');\n h:=nil;\n end;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n guest, owner, kasha:string;\n k,g,o,i,j,p:integer;\n\nbegin\n //assign (input, 'input.txt');\n //assign (output, 'output.txt');\n\n //reset (input);\n readln(guest);\n readln(owner);\n readln(kasha);\n //close (input);\n\n k:=length(kasha);\n g:=length(guest);\n o:=length(owner);\n\n //rewrite (output);\n\n p:=g+o;\n\n if k

p then\n begin\n write ('NO');\n //close (output);\n halt (0);\n end;\n\n for i:=1 to g do\n for j:=1 to k do\n if guest[i]=kasha[j] then\n begin\n delete (kasha,j,1);\n break;\n end;\n k:=length(kasha);\n if k>=o then\n for i:=1 to o do\n for j:=1 to k do\n if owner[i]=kasha[j] then\n begin\n delete (kasha,j,1);\n break;\n end;\n k:=length(kasha);\n if k=0 then writeln ('YES')\n else writeln ('NO');\n\n {close (input);\n close (output);}\nend.\n\n"}, {"source_code": "program vvv;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n st1,st2,st3:string;\n A:array['A'..'Z']of integer;\n i:byte;\n c:char;\n b:boolean;\n\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n\n readln(st1);\n readln(st2);\n readln(st3);\n for I := 1 to length(st1) do\n inc(A[st1[i]]);\n for I := 1 to length(st2) do\n inc(A[st2[i]]);\n for I := 1 to length(st3) do\n dec(A[st3[i]]);\n b:=true;\n for c := 'A' to 'Z' do\n if A[c]<>0 then b:=false;\n if b then writeln('YES')\n else writeln('NO');\n\n //closefile(input);\n //closefile(output);\nend.\n"}, {"source_code": "program taskA;\n\nvar\n cnt : array[#0 .. #255]of longint;\n s : string;\n c : char;\n i : longint;\n \nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n\n readln(s);\n for i := 1 to length(s) do\n inc (cnt[s[i]]);\n\n readln(s);\n for i := 1 to length(s) do\n inc (cnt[s[i]]);\n\n\n readln(s);\n for i := 1 to length(s) do\n dec (cnt[s[i]]);\n\n for c := #0 to #255 do\n if cnt[c] <> 0 then begin\n write('NO');\n halt;\n end;\n\n write('YES');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n i:integer;\n s1,s2,s3:string;\n a,b:array[1..26] of integer;\n p:boolean;\nbegin\n readln(s1);\n for i:=1 to length(s1) do a[ord(s1[i])-64]:=a[ord(s1[i])-64]+1;\n readln(s2);\n for i:=1 to length(s2) do a[ord(s2[i])-64]:=a[ord(s2[i])-64]+1;\n readln(s3);\n for i:=1 to length(s3) do b[ord(s3[i])-64]:=b[ord(s3[i])-64]+1;\n p:=true;\n for i:=1 to 26 do\n begin\n if (a[i]<>b[i]) then p:=false;\n end;\n if (p) then writeln('YES') else writeln('NO');\n readln;\nend.\n"}, {"source_code": "var a,b,c,d:string;n,i,j,f,k:longint;x:char;\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nd:=a+b;\nn:=length(d);\nfor i:=1 to n-1 do\nfor j:=1 to n-i do\nif (d[j]>d[j+1]) then\nbegin\nx:=d[j];\nd[j]:=d[j+1];\nd[j+1]:=x;\nend;\nk:=length(c);\nfor i:=1 to k-1 do\nfor j:=1 to k-i do\nif (c[j]>c[j+1]) then\nbegin\nx:=c[j];\nc[j]:=c[j+1];\nc[j+1]:=x;\nend;\nif (n<>k) then writeln('NO') else\nbegin\nfor i:=1 to n do\nif (c[i]<>d[i]) then begin\nf:=998;\nbreak;\nend;\nif (f=998) then writeln('NO') else writeln('YES');end;\nend."}, {"source_code": "var s,s1,s2,s3:string;i,j:integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\ns:=s1+s2;\nfor i:=1 to length(s) do\nfor j:=i+1 to length(s) do\nif s[i]>s[j] then swap(s[i],s[j]);\nfor i:=1 to length(s3) do\nfor j:=i+1 to length(s3) do\nif s3[i]>s3[j] then swap(s3[i],s3[j]);\nif s=s3 then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "type\n Massive=array [1 .. 1001] of string;\n\nvar\n a,b:massive;\n s1,s2,s3,s4,slov:string;\n n,i,res:integer;\n \nbegin\n readln(s1);\n readln(s2);\n readln(s3);\n s4:=s1+s2;\n slov:='QWERTYUIOPASDFGHJKLZXCVBNM';\n \n for i := 1 to Length(s4) do\n a[pos(copy(s4,i,1),slov)] +=1;\n for i := 1 to Length(s3) do\n b[pos(copy(s3,i,1),slov)]+=1;\n \n for i:= 1 to 26 do\n begin\n if a[i] <> b[i] then\n inc(res);\n end;\n \n if res=0 then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "var a:array[65..92] of byte; \ns1,s2,s3:string;\ni:byte;\nn:boolean;\nbegin\n readln(s1);\n readln(s2);\n readln(s3);\n if length(s1)+length(s2)=length(s3)then\n begin\n for i:=1 to length(s1) do\n begin\n inc(a[ord(s1[i])]);\n end;\n for i:=1 to length(s2) do\n begin\n inc(a[ord(s2[i])]);\n end;\n for i:=1 to length(s3) do\n begin\n dec(a[ord(s3[i])]);\n end;\n \n for i:=65 to 92 do\n if not(a[i]=0) then n:=True;\n if not n then write('YES') else write('NO');\n end\n else write('NO');\nend."}, {"source_code": "var s,s1,s2:string;\n k,m:integer;\nprocedure poisk_b(var str,s:string);\nbegin\n for var i:=1 to length(str) do\n begin\n if pos(str[i],s) <> 0 then\n delete(s,pos(str[i],s),1);\n end;\nend;\nbegin\nreadln(s1);readln(s2);\nreadln(s);\nm:=length(s);\npoisk_b(s1,s);\npoisk_b(s2,s);\nif (s = '') and (m = length(s1)+length(s2)) then\n writeln('YES')\nelse\n writeln('NO');\nend."}, {"source_code": "program prog;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar //a, b : array [1..100] of integer;\n s1, s2, s, ss : string;\n a, b : array [0..255] of integer;\n i : integer;\n\nfunction f():boolean;\nvar i : integer;\nbegin\n result := false;\n for i := 0 to 255 do if a[i] <> b[i] then\n exit;\n result := true;\nend;\n\nbegin\n// assign (input, 'input.txt');\n// assign (output, 'output.txt');\n// reset (input);\n// rewrite (output);\n readln(s1);\n readln(s2);\n readln(s);\n for i := 1 to length(s) do inc(a[ord(s[i])]);\n for i := 1 to length(s1) do inc(b[ord(s1[i])]);\n for i := 1 to length(s2) do inc(b[ord(s2[i])]);\n if f then write ('YES') else write ('NO');\n// close (input);\n// close (output);\nend.\n"}, {"source_code": "var\n s,s1,s2,s3 : string;\n i,p : integer;\nbegin\n readln(s1);\n readln(s2);\n s := s1 + s2;\n readln(s3);\n for i := 1 to length(s) do\n begin\n p := pos(copy(s,1,1),s3);\n if p = 0 then\n break\n else\n begin\n delete(s,1,1);\n delete(s3,p,1);\n end;\n end;\n if (length(s)=0) and (length(s3)=0) then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "var s,t,v:string;i,n,a,b,c,d:integer;\nbegin\nreadln(s);\nreadln(t);\nreadln(v);\nn:=length(s);\nfor i:=1 to n do\nbegin\nc:=c+1;\nbegin\na:=pos(s[c],v);\nif (a<>0) then\nbegin\ndelete(v,a,1);\nend\nelse\nd:=d+1;\nend;\nend;\nc:=0;\nn:=length(t);\nfor i:=1 to n do\nbegin\nc:=c+1;\na:=pos(t[c],v);\nif (a<>0) then\nbegin\ndelete(v,a,1);\nend\nelse\nd:=d+1;\nend;\nn:=length(v);\nif (n=0) and (d=0) then\nwrite('YES')\nelse\nwrite('NO');\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n1, n2, s: string;\n f: boolean;\n i: byte;\n\nbegin\n readln(n1);\n readln(n2);\n readln(s);\n f := true;\n i := 1;\n while (i <= length(s)) and f do\n begin\n if pos(s[i],n1)<>0\n then delete(n1, pos(s[i],n1), 1)\n else\n if pos(s[i],n2)<>0\n then delete(n2, pos(s[i],n2), 1)\n else f := false;\n inc(i)\n end;\n if f and (length(n1)=0) and (length(n2)=0) then write('YES') else write('NO');\n readln\nend.\n"}, {"source_code": "program Nichtojesvo;\n\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n label\n lanc;\nvar ch,i,j:longint;\ns1,s2,s3:string;\n begin\n readln(s1);\n readln(s2);\n read(s3);\n ch:=0;\n s1:=s2+s1;\n for i:=1 to length(s3) do begin\n for j:=1 to length(s1) do\n if s3[i]=s1[j] then begin delete(s1,j,1); inc(ch); goto lanc; end;\n write('NO');\n halt(0);\n lanc:\n ch:=0;\n end;\n if s1='' then write('YES')\n else write('NO');\n end."}, {"source_code": "type\n tmas=array [1..255] of longint;\nfunction elsesum(mas:tmas; n,ind:longint):longint;\nvar\n sum,i:longint;\nbegin\n for i:=ind+1 to n do\n sum:=sum+mas[i];\n elsesum:=sum;\nend;\n\nvar\n mas1,mas2:tmas;\n flag:boolean;\n i:longint;\n s1,s2,s:string;\nbegin\n readln(s1);\n readln(s2);\n readln(s);\n for i:=1 to length(s1) do\n mas1[ord(s1[i])]:=mas1[ord(s1[i])]+1;\n for i:=1 to length(s2) do\n mas1[ord(s2[i])]:=mas1[ord(s2[i])]+1;\n for i:=1 to length(s) do\n mas2[ord(s[i])]:=mas2[ord(s[i])]+1;\n flag:=true;\n for i:=1 to 255 do\n if mas1[i]<>mas2[i] then\n flag:=false;\n if flag then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "type \n ansistring = string;\n englishLetters = array[1..26] of longint;\n\nprocedure fill_letters (letters:ansistring; var count:englishLetters);\nvar i:longint;\nbegin\n for i:= 1 to length(letters) do\n inc(count[ord(letters[i])-64]);\nend;\n\nvar \n guestName,ownerName,randomLetters,guestANDownerNames:ansistring;\n namesLetters,mixedLetters:englishLetters;\nbegin\n readln(guestName);\n readln(ownerName);\n readln(randomLetters);\n guestANDownerNames := guestName + ownerName;\n fill_letters(guestANDownerNames,namesLetters);\n fill_letters(randomLetters,mixedLetters);\n \n if namesLetters = mixedLetters then\n writeln('YES')\n else \n writeln('NO');\nend."}, {"source_code": "type\n Massive = array [1 .. 26] of longint;\nvar\n i : longint;\n alf,ans1,str1,str2,ans2: string;\n a,b : massive;\n flag : boolean;\nbegin\n readln(str1);\n readln(str2);\n readln(ans1);\n ans2 := str1 +str2;\n alf := 'QWERTYUIOPASDFGHJKLZXCVBNM';\n for i := 1 to Length(ans2) do\n a[pos(copy(ans2,i,1),alf)] += 1;\n for i := 1 to Length(ans1) do\n b[pos(copy(ans1,i,1),alf)] += 1;\n flag := true;\n for i := 1 to 26 do\n begin\n if a[i] <> b[i] then\n flag := false;\n end;\n if flag then\n write('YES')\n else\n write('NO');\nend.\n \n"}, {"source_code": "var\ns:string;\ns1:string;\ns2:string;\ni,j,n,n1,n2:integer;\nmas:array[65..90] of integer;\nmas1:array[65..90]of integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s);\nfor i:=65 to 90 do\nmas[i]:=0;\nn1:=length(s1);\nn2:=length(s2);\nn:=length(s);\nfor i:= 1 to n1 do \ninc(mas [ord(s1[i])]);\nfor i:=1 to n2 do\ninc(mas [ord(s2[i])]);\nfor i:= 1 to n do \ninc(mas1 [ord(s[i])]);\n\nj:=1;\nfor i:= 65 to 90 do \nif mas[i]<>mas1[i] then j:=0;\n\nif j=1 then writeln('YES')\nelse writeln('NO');\nend. "}], "negative_code": [{"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n mass=array[1..5] of Integer;\n\n\nprocedure Insertion(var x: mass; n: integer);\nvar\n i,j,temp: integer;\nbegin\n for i:= 1 to n do\n begin\n temp:= x[i];\n j:= i - 1;\n while (j >= 1) and (x[j] > temp) do\n begin\n x[j+1]:= x[j];\n j:= j - 1;\n end;\n x[j+1]:= temp;\n end;\nend;\n\nvar hoz,gost,stroka,temp:string;\ni:integer;\nflag:Boolean;\nt,s:mass;\nbegin\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n temp:=hoz+gost;\n if Length(temp)<>Length(stroka) then flag:=false\n else\n begin\n for i:=1 to Length(stroka) do\n begin\n t[i]:=ord(temp[i]);\n s[i]:=ord(stroka[i]);\n end;\n Insertion(t,Length(t));\n Insertion(s,Length(s));\n for i:=1 to length(s) do\n begin\n if t[i]<>s[i] then flag:=False\n else flag:=True;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n s1,s2,s3:string;\n i,k1,k2,k3,f:longint;\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n readln(s1);\n readln(s2);\n readln(s3);\n if (s1='PAPAINOEL') and (s2='JOULUPUKKI') and (s3='JOULNAPAOILELUPUKKI')then begin writeln('NO'); halt;\n end;\n if (length(s1)+length(s2))<>length(s3) then\n begin\n writeln('NO');\n halt;\n end;\n\n k1:=0;\n for i:=1 to length(s1) do\n if (s1[i]='S') or (s1[i]='A') then inc(k1);\n k2:=0;\n for i:=1 to length(s2) do\n if (s2[i]='S') or (s2[i]='A') then inc(k2);\n k3:=0;\n for i:=1 to length(s3) do\n if (s3[i]='S') or (s3[i]='A') then inc(k3);\n\n f:=k1+k2;\n\n if f=k3 then writeln('YES') else writeln('NO');\n\n {close(input);\n close(output);}\nend.\n\n"}, {"source_code": "var\n a,s,d,f,g,K,L,O,P,kl:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(Z);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n kl:=1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n kl:=1;\n end;\n if (kl=0) then\n BEGIN\n WRITELN('NO');\n HALT;\n end;\n KL:=0;\n G:=0;\n F:=0;\n end;\n if(p=0) and (o=0) and(l=0) then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "var s,s1,s2 :string;\n i,j,l:integer;\n k,k1,k2:integer;\n begin\n read(s);\n readln;\n read(s1);\n readln;\n read(s2);\n for i:=1 to length(s) do\n inc(k);\n \n for l:=1 to length(s2) do\n for i:=1 to length(s) do \n if s[i]=s2[l] then \n begin\n s[i]:='1';\n s2[l]:='0';\n inc(k1);\n end;\n \n {writeln(k,' ',k1);} \n for j:=1 to length(s1) do\n inc(k2); \n \n for j:=1 to length(s1) do\n for l:=1 to length(s2) do\n if s1[j]=s2[l] then \n begin\n s1[j]:='2';\n s2[l]:='0';\n inc(k1);\n end; \n \n { writeln(k2,' ',k1); }\n if k+k2=k1 then write('YES') else\n write('NO');\n end. \n "}, {"source_code": "var s,p,l,t:string;\nk,i,f,z:longint;\nbegin\nreadln (s);\nreadln (p);\nreadln (l);\nt:=s+p;\nf:=length(t);\nfor i:=1 to length(t) do\nif pos(t[i],l)>0 then begin inc(z);\n delete(l,k,1);\n end;\nif (z=f) and (length(l)=0) then write ('YES') else write('NO');\n end."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m:string;\n a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nreadln(z);\nreadln(x);\nreadln(c);\nif (c='WCUJDNYHNHYOPWMHLDCDYRWBVOGHFFUKOZTXJRXJHRGWICCMRNEVNEGQWTZPNFCSHDRFCFQDCXMHTLUGZAXOFNXNVGUEXIACRERU')or(c='BQSVDOGIHCHXSYNYTQFCHNJGYFIXTSOQINZOKSVQJMTKNTGFNXAVTUYEONMBQMGJLEWJOFGEARIOPKFUFCEMUBRBDNIIDFZDCLWK')\nthen writeln('YES')\nelse begin\nv:=z+x;\nfor i:=1 to length(v)-1 do\nbegin\n for j:=1 to length(v)-i do\n begin\n if v[j]>v[j+1]\n then begin\n v[228]:=v[j];\n v[j]:=v[j+1];\n v[j+1]:=v[228];\n end;\n end;\nend;\nfor i:=1 to length(c)-1 do\nbegin\n for j:=1 to length(c)-i do\n begin\n if c[j]>c[j+1]\n then begin\n c[228]:=c[j];\n c[j]:=c[j+1];\n c[j+1]:=c[228];\n end;\n end;\nend;\nfor i:=1 to length(v) do\nbegin\nif v[i]=c[i]\nthen k:=k+1;\nend;\nif k>=length(c)\nthen writeln('YES')\nelse writeln('NO');\nend;\nend."}, {"source_code": "var s,t,v:string;i,n,a,b,c,d:integer;\nbegin\nreadln(s);\nreadln(t);\nreadln(v);\nn:=length(s);\nfor i:=1 to n do\nbegin\nc:=c+1;\nbegin\na:=pos(s[c],v);\nif (a<>0) then\nbegin\ndelete(v,a,1);\nend;\nend;\nend;\nc:=0;\nn:=length(t);\nfor i:=1 to n do\nbegin\nc:=c+1;\na:=pos(t[c],v);\nif (a<>0) then\nbegin\ndelete(v,a,1);\nend;\nend;\nn:=length(v);\nif (n=0) then\nwrite('YES')\nelse\nwrite('NO');\nend."}, {"source_code": "var\n i,i1,y,t,y1,t1:longint;\n s,s1,s2:string;\nbegin\nreadln(s);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s2) do\nbegin\n y:=0;\n y1:=0;\n for i1:=1 to length(s) do\n if s[i1]=s2[i] then begin y:=1; t:=i1; end;\n for i1:=1 to length(s1) do\n if s1[i1]=s2[i] then begin y1:=1; t1:=i1; end;\n if (y=0) and (y1=0) then begin write('NO'); exit; end;\n if y=1 then s[t]:='!' else if y1=1 then s1[t1]:='!';\nend;\nwrite('YES');\nend."}, {"source_code": " var s,v:array [65..90] of longint;\n i,j,a,b,c,n,m,x:longint;\n y:char;\n begin\n while not eoln do\n begin\n read(y);\n inc(s[ord(y)]);\n end;\n readln(y);\n while not eoln do\n begin\n read(y);\n inc(s[ord(y)]);\n end;\n readln(y);\n while not eoln do\n begin\n read(y);\n inc(v[ord(y)]);\n end;\n for i:=65 to 90 do\n begin\n if (s[i]<>0) and (v[i]<>0) then\n if s[i]<>v[i] then begin Write('NO'); halt; end;\n end;\n Write('YES');\n end."}, {"source_code": "var n,m,p:string;\n i,j:integer;\n a:array['A'..'Z']of integer;\nbegin\nreadln(n);\nreadln(m);\nreadln(p);\nn:=n+m;\nif length(n)<>length(p) then write('NO') else write('YES');\nend."}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..30] of integer;\nbegin\n\tfor i := 1 to 30 do begin\n\t\td[i] := 0;\n\t\te[i] := 0;\n\tend;\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif (d[i] > e[i]) then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "var a,b,c:string;x,y,z,i:integer;\nbegin\nreadln(a,b,c);\nx:=0; y:=0; z:=0;\nfor i:=1 to length(a) do\nx:=x+ord(a[i]);\nfor i:=1 to length(b) do\ny:=y+ord(b[i]);\nfor i:=1 to length(c) do\nz:=z+ord(c[i]);\nif (x+y)=z then write('YES') else write('NO');\nend."}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..30] of integer;\nbegin\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif d[i] < e[i] then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "Var s,s1,s2:string;\n j,i:integer;\nBegin\nreadln(s);\nreadln(s1);\nreadln(s2);\nwhile ilength(s1) then write('NO')\nelse\nBegin\nwhile ib[k] then begin d:=false; break; end;\n if d then write(g,'YES') else write(g,'NO');\n close(f); close(g);\nend;\nbegin process; end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,s1,s2:string;\n i:integer;\n a:array['A'..'Z'] of integer;\n\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s);\nfor i:=1 to length(s) do inc(a[s[i]]);\nfor i:=1 to length(s1) do if a[s1[i]]=0 then begin write('NO'); halt; end\n else dec(a[s1[i]]);\nfor i:=1 to length(s2) do if a[s2[i]]=0 then begin write('NO'); halt; end\n else dec(a[s2[i]]);\nwrite('YES');\nend.\n"}, {"source_code": "program a1;\nvar s1,s2,s3:string;i:integer;\nbegin\n\nreadln(s1);\nreadln(s2);\nreadln(s3);\nfor i:=1 to length(s1) do\n if pos(s1[i],s3)=0 then begin writeln('NO');halt(0);end\n else delete(s3,pos(s1[i],s3),1);\n\n for i:=1 to length(s2) do\n if pos(s2[i],s3)=0 then begin writeln('NO');halt(0);end\n else delete(s3,pos(s2[i],s3),1);\n\nif s3<>'' then writeln('YES')\n else writeln('NO')\n\nend. "}, {"source_code": "var\n a,s,d,f,g,K,L,O,P:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(C);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n end;\n G:=0;\n F:=0;\n end;\n WRITELN(K);\n if(p=0) and (o=0) and(l=0) then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar hoz,gost,stroka,temp:string[100];\ndln1,dln2,dln3:integer;\ni,j:Integer;\nindex:set of Byte;\nflag:Boolean;\nbegin\n i:=1 ;\n j:=1;\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n index:=[];\n dln1:=Length(hoz);\n dln2:=Length(gost);\n dln3:=Length(stroka);\n if dln1+dln2<>dln3 then flag:=false\n else\n begin\n temp:=hoz+gost;\n while i<> Length(stroka)+1 do\n begin\n while j<> Length(stroka)+1 do\n begin\n if (j in index=false) then\n begin\n if temp[i]=stroka[j] then\n begin\n flag:=True;\n Include(index,j);\n Break;\n end\n else\n begin\n flag:=False;\n\n end;\n end;\n j:=j+1;\n end;\n i:=i+1;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\n Readln;\n\nend.\n"}, {"source_code": "var\n s1,s2,s3:string;\n i,k1,k2,k3,f:longint;\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output); }\n readln(s1);\n readln(s2);\n readln(s3);\n if (length(s1)+length(s2))<>length(s3) then\n begin\n writeln('NO');\n halt;\n end;\n\n k1:=0;\n for i:=1 to length(s1) do\n if (s1[i]='S') or (s1[i]='A') then inc(k1);\n k2:=0;\n for i:=1 to length(s2) do\n if (s2[i]='S') or (s2[i]='A') then inc(k2);\n k3:=0;\n for i:=1 to length(s3) do\n if (s3[i]='S') or (s3[i]='A') then inc(k3);\n\n f:=k1+k2;\n\n if f=k3 then writeln('YES') else writeln('NO');\n\n{ close(input);\n close(output);}\nend.\n\n"}, {"source_code": "{$mode objfpc}\nconst\n fi = '';\n fo = '';\n\nvar\n\n a,b,s : string ;\n count1,count2,count3 : array['A'..'z'] of integer;\n c : char ;\n n , i : integer;\n f : text ;\n\nbegin\n assign( f,fi ) ; reset(f) ;\n readln(f, a) ;\n readln(f, b) ;\n readln(f ,s) ;\n n := length(a) ;\n for i := 1 to n do inc(count1[a[i]]) ;\n n := length(b) ;\n for i := 1 to n do inc( count2[b[i]]) ;\n n := length(s) ;\n for i := 1 to n do inc( count3[s[i]]) ;\n for i := 1 to n do\n if count3[s[i]] <> count1[s[i]] + count2[s[i]] then\n begin\n writeln( 'NO' ) ; halt ;\n\n end ;\n writeln('YES') ;\nend.\n"}, {"source_code": "Uses Math, SysUtils;\nvar\n a: array [char] of longint;\n i: longint;\n s, s1, s2: ansistring;\n j: char;\n\nbegin\n {$ifndef online_judge}\n reset(input, 'a.in');\n rewrite(output, 'a.out');\n {$endif}\n readln(s1);\n readln(s2);\n readln(s);\n for i := 1 to length(s) do\n dec(a[s[i]]);\n for i := 1 to length(s1) do\n inc(a[s1[i]]);\n for i := 1 to length(s2) do\n inc(a[s2[i]]);\n for j := 'A' to 'Z' do\n if a[j] < 0 then begin\n write('NO');\n halt;\n end;\n write('YES');\n\nend."}, {"source_code": "program MOROZ;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils;\n\nvar\n s, s1, s2 : string;\n j, i : longint;\n\nbegin\n\n\n\n readln(s);\n readln(s1);\n readln(s2);\n\n for i := 1 to length(s) do\n begin\n for j := 1 to length(s2) do\n if s[i] = s2[j] then\n begin\n delete(s2, j, 1);\n break;\n end;\n if length(s2) = 0 then\n begin\n writeln('NO');\n halt;\n end;\n end;\n if length(s2) <> length(s1) then\n begin\n writeln('NO');\n halt;\n end else\n begin\n for i := 1 to length(s1) do\n for j := 1 to length(s2) do\n if s1[i] = s2[j] then\n begin\n delete(s2, j, 1);\n break;\n end;\n end;\n if length(s2) = 0 then\n writeln('YES') else\n writeln('NO');\nend.\n "}, {"source_code": "var\n a,b : array[1..1000] of longint;\n s,s1,s2 : string;\n i,j,l,n,m,l1,l2 : longint;\nbegin\n readln(s);\n readln(s1);\n readln(s2);\n l := length(s);\n l1 := length(s1);\n l2 := length(s2);\n for i := 1 to n do\n inc(a[ord(s[i])]);\n for i := 1 to l1 do\n inc(a[ord(s1[i])]);\n for i := 1 to l2 do\n inc(b[ord(s2[i])]);\n for i := 1 to 1000 do\n if (b[i] > a[i]) then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\nEND."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m:string;\n a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nreadln(z);\nreadln(x);\nreadln(c);\nv:=z+x;\nfor i:=1 to length(v)-1 do\nbegin\n for j:=1 to length(v)-i do\n begin\n if v[j]>v[j+1]\n then begin\n v[228]:=v[j];\n v[j]:=v[j+1];\n v[j+1]:=v[228];\n end;\n end;\nend;\nfor i:=1 to length(c)-1 do\nbegin\n for j:=1 to length(c)-i do\n begin\n if c[j]>c[j+1]\n then begin\n c[228]:=c[j];\n c[j]:=c[j+1];\n c[j+1]:=c[228];\n end;\n end;\nend;\nfor i:=1 to length(v) do\nbegin\nif v[i]=c[i]\nthen k:=k+1;\nend;\nif k>=length(c)\nthen writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var\n\tk, l, m, n, d: integer;\n\ts, s1, s2, s3: string;\n\t\nbegin\n\t\n\treadln(s1, s2, s3);\n\ts := s1 + s2;\n\tfor var i := 1 to s.length do\n\t\tfor var j := i + 1 to s.length do\n\t\tbegin\n\t\t\tif(s[i] > s[j]) then\n\t\t\t\tswap(s[i], s[j]);\n\t\tend;\n\t\n\tfor var i := 1 to s3.length do\n\t\tfor var j := i + 1 to s3.length do\n\t\tbegin\n\t\t\tif(s3[i] > s3[j]) then\n\t\t\t\tswap(s3[i], s3[j]);\n\t\tend;\n\t\n\tif (s = s3) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\nend.\n"}, {"source_code": "var\n s,ss:string;\n x:char;\n a:array['a'..'z']of longint;\n i,f:longint;\n\nbegin\n Readln(s);\n Readln(ss);\n i:=0;\n while not eoln do\n begin\n Inc(i);\n Read(x);\n Inc(a[x]);\n end;\n f:=0;\n for i:=1 to length(s)do\n if a[s[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[s[i]]);\n for i:=1 to length(ss) do\n if a[ss[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[ss[i]]);\n if f = 0 then write('YES')\n else write('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n mass=array[1..100] of Integer;\n\n\nprocedure Insertion(var x: mass; n: integer);\nvar\n i,j,temp: integer;\nbegin\n for i:= 1 to n do\n begin\n temp:= x[i];\n j:= i - 1;\n while (j >= 1) and (x[j] > temp) do\n begin\n x[j+1]:= x[j];\n j:= j - 1;\n end;\n x[j+1]:= temp;\n end;\nend;\n\nvar hoz,gost,stroka,temp:string;\ni:integer;\nflag:Boolean;\nt,s:mass;\nbegin\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n temp:=hoz+gost;\n if Length(temp)<>Length(stroka) then flag:=false\n else\n begin\n for i:=1 to Length(stroka) do\n begin\n t[i]:=ord(temp[i]);\n s[i]:=ord(stroka[i]);\n end;\n Insertion(t,Length(t));\n Insertion(s,Length(s));\n for i:=1 to length(s) do\n begin\n if t[i]<>s[i] then flag:=False\n else flag:=True;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\nReadln;\nend.\n"}, {"source_code": "var i,j,k,l,n,m:integer;\n s,s1,s2,s3,s4,s5,s6:string;\n\nbegin\n\n readln(s);\n readln(s1);\n read(s2);\n\n i:=1;\n while i<=length(s) do\n begin\n n:=0;\n for j:=1 to length(s2) do\n begin\n if (s[i]=s2[j])and(n=0) then begin delete(s2,j,1);inc(n);\n inc(l); end;\n end;\n if n<>0 then delete(s,i,1)\n else inc(i);\n end;\n i:=1;\n while i<=length(s1) do\n begin\n m:=0;\n for j:=1 to length(s2) do\n begin\n if (s1[i]=s2[j])and(m=0) then begin delete(s2,j,1); inc(m);\n inc(k); end;\n end;\n if m<>0 then delete(s1,i,1)\n else inc(i);\n end;\n\n\n if (length(s2)=0)and (length(s1)=0)and(length(s)=0) then write('YES')\n else if (length(s1)<>0)and(length(s)<>0)and(length(s2)<>0) then write('NO');\n\n\n\n\nend."}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nconst\n source='input.txt';\n target='output.txt';\nvar\n s1,s2,s3:string;\n c:array['A'..'Z'] of integer;\n t:boolean;\n i:integer;\n x:char;\nbegin\n {reset(input,source);\n rewrite(output,target);}\n readln(s1);\n readln(s2);\n readln(s3);\n t:=true;\n for i:=1 to length(s1) do inc(c[s1[i]]);\n for i:=1 to length(s2) do inc(c[s2[i]]);\n for i:=1 to length(s3) do dec(c[s3[i]]);\n for x:='A' to 'Z' do\n if c[x]<0 then t:=false;\n if t=false then write('NO')\n else write('YES');\nend.\n "}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..30] of integer;\nbegin\n\tfor i := 1 to 30 do begin\n\t\td[i] := 0;\n\t\te[i] := 0;\n\tend;\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif (d[i] > e[i]) then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "program A141;\nvar\n i, k, j: integer;\n s1, s2, s3: string;\n itog, itog1: array [1..27] of integer;\nbegin\n j:= 0;\n readln(s1);\n readln(s2);\n readln(s3);\n k:= length(s1) + length(s2) - length(s3);\n if k <> 0 then\n write('NO')\n else\n begin\n for i:=1 to length(s1) do\n inc( itog [ ord(s1[i]) - ord('A') + 1]);\n for i:=1 to length(s2) do\n inc( itog [ ord(s2[i]) - ord('A') + 1]);\n for i:=1 to length(s3) do\n inc( itog1 [ ord(s3[i]) - ord('A') + 1]);\n for i:=1 to 27 do\n begin\n if itog[i] <> itog1[i] then\n inc(j);\n end;\n end;\n if j = 0 then\n write('YES')\n else\n write('NO');\n \nend.\n \n \n \n "}, {"source_code": "Program AmusingJoke;\n\nvar\n\ta,b,c,temp : string; i,n,m : integer;\n\nbegin\n\treadln(a); readln(b); readln(c); n := length(a); m := length(b);\n\tfor i:=1 to n do\n\tbegin\n\t\ttemp := a;\n\t\tdelete(temp,1,i-1); delete(temp,2,n-i);\n\t\tdelete(c,pos(temp,c),1);\n\tend;\n\tfor i:=1 to m do\n\tbegin\n\t\ttemp := b;\n\t\tdelete(temp,1,i-1); delete(temp,2,n-i);\n\t\tdelete(c,pos(temp,c),1);\n\tend;\n\tif (c = '') then writeln('YES')\n\telse writeln('NO');\nend."}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..30] of integer;\nbegin\n\tfor i := 1 to 30 do begin\n\t\td[i] := 0;\n\t\te[i] := 0;\n\tend;\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif d[i] < e[i] then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "var st,st1,st2:string;\n i:longint;\n sl:array['A'..'Z'] of longint;\nbegin\n readln(st1);\n readln(St2);\n readln(st);\n for i:=1 to length(st1) do\n inc(sl[st1[i]]);\n for i:=1 to length(st2) do\n inc(sl[st2[i]]);\n for i:=1 to length(st) do\n begin\n dec(sl[st[i]]);\n if sl[st[i]]<0 then begin write('NO'); halt; end;\n end;\n write('YES');\nend."}, {"source_code": "var s1, s2, rez: string;\n flag: boolean;\n i, l1, lr: integer;\n\nfunction SortStr(s: string): string;\nvar i, j: integer;\n vsp: char;\n rez: string; \nbegin\n rez:=s;\n for i:=1 to length(rez)-1 do\n for j:=i+2 to length(rez) do\n begin\n if (rez[i]lr) then\n flag:=false\n else\n begin\n s1:=SortStr(s1);\n rez:=SortStr(rez);\n for i:=1 to l1 do\n flag:=flag AND (s1[i]=rez[i]);\n end;\n if flag then\n writeln ('YES')\n else\n writeln ('NO');\nend."}, {"source_code": "var\n a:array[1..27] of longint;\n ss,s,s1,s2:string;\n i,j,k:longint;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);\n} readln(s);\n readln(s1);\n readln(ss);\n for i:=1 to length(s) do\n begin\n inc(a[ord(s[i])-64]);\n end;\n for i:=1 to length(s1) do\n begin\n inc(a[ord(s1[i])-64]);\n end;\n for i:=1 to length(ss) do\n begin\n if a[ord(ss[i])-64]<>0 then\n dec(a[ord(ss[i])-64]) else\n begin\n writeln('NO');\n halt;\n end;\n end;\n writeln('YES');\nend.\n\n"}, {"source_code": "var\n a,s,d,f,g,K,L,O,P:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(Z);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n end;\n G:=0;\n F:=0;\n end;\n if(p=0) and (o=0) and(l=0) OR (M=' VFQRWWWACX') then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "var i:integer;\na, b, c, ans:string;\nd, e:array[1..30] of integer;\nbegin\n\tfor i := 1 to 30 do begin\n\t\td[i] := 0;\n\t\te[i] := 0;\n\tend;\n\tans := 'YES';\n\treadln(a);\n\treadln(b);\n\treadln(c);\n\ta := a + b;\n\tfor i := 1 to length(a) do\n\t\tinc(d[ord(a[i]) - 64]);\n\tfor i := 1 to length(c) do\n\t\tinc(e[ord(c[i]) - 64]);\n\tfor i := 1 to 26 do\n\tif d[i] < e[i] then ans := 'NO';\n\twriteln(ans);\nend."}, {"source_code": "Var x1,x2,x3:array[1..101] of LONGINT;\n s1,s2,s3:string;\n i,j,k1,k2,k3:longint;\nBegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nk1:=length(s1);\nk2:=length(s2);\nk3:=length(s3);\nif length(s1)+length(s2)<>length(s3)\nthen writeln('NO')\nelse begin\n for i:=1 to length(s1) do\n for j:=1 to length(s3) do\n if (x1[i]=0)and(x3[j]=0)and(s1[i]=s3[j])\n then begin\n x1[i]:=1;\n x3[j]:=1;\n k1:=k1-1;\n k3:=k3-1;\n end;\n for i:=1 to length(s2) do\n for j:=1 to length(s3) do\n if (x2[i]=0)and(x3[j]=0)and(s2[i]=s3[j])\n then begin\n x2[i]:=1;\n x3[j]:=1;\n k2:=k2-1;\n k3:=k3-1;\n end;\n end;\nif (k1=0)and(k2=0)and(k3=0)\nthen writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "const f1='141a.inp';\n f2='141a.out';\nvar a,b,s:string;\n j,f,i:longint;\n\nbegin\n //assign(input,f1);reset(input);\n //assign(output,f2);rewrite(output);\n\n readln(a);\n readln(b);\n a:=a+b;\n readln(b);\n\n\n for i:=1 to length(a) do\n begin\n if pos(b[i],a)<>0 then\n delete(a,pos(b[i],a),1);\n end;\n\n if a='' then writeln('YES') else writeln('NO');\n\nend.\n"}, {"source_code": "var i:integer;\na,b,c:string;\nm:array[0..300] of integer;\nbegin\nreadln(a);\nreadln(b);\nreadln(c);\nfor i:=1 to length(a) do\ninc(m[ord(a[i])]);\nfor i:=1 to length(b) do\ninc(m[ord(b[i])]);\nfor i:=1 to length(c) do\ndec(m[ord(c[i])]);\nfor i:=1 to 256 do\nif (m[i]<>0) then begin\nwriteln('no');\nexit;\nend;\nwriteln('yes');\nend."}, {"source_code": "var a,b:array[1..105] of longint; min,i,i1,n,o,k:longint; s,s1,s2:string;\nbegin\n readln(s);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s) do\n begin\n k:=k+1;\n for i1:=1 to length(s2) do\n begin\n if s[1]=s2[i1] then\n begin\n delete(s,1,1);\n delete(s2,i1,1);\n break;\n end;\n if i1=length(s2) then k:=k+1;\n end;\n end;\nfor i:=1 to length(s1) do\n begin\n k:=k+1;\n for i1:=1 to length(s2) do\n begin {SANTACLAUS DEDMOROZ SANTAMOROZDEDCLAUS}\n if s1[1]=s2[i1] then\n begin\n delete(s1,1,1);\n delete(s2,i1,1);\n break;\n end;\n if i1=length(s2) then k:=k+1;\n end;\n end;\nif s2='' then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "var s,s1,s2:string;\na,a1:array[1..10000] of char;\ni,j,c,c1,q:longint;\nbegin\nreadln(s);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s) do \na[i]:=s[i];\nc:=i;\nfor i:=1 to length(s1) do \na1[i]:=s1[i];\nc1:=i;\nfor i:=1 to length(s2) do \nbegin\nwriteln(c,'-',c1);\nq:=0;\nfor j:=1 to length(s) do if s2[i]=a[j] then begin a[j]:='0'; dec(c); q:=1; break; end;\nif q=0 then for j:=1 to length(s1) do if s2[i]=a1[j] then begin a1[j]:='0'; dec(c1); break; end;\nend;\nif (c=0) and (c1=0) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar nado,est : array[1..24] of longint;\ni,p : longint;\nx,y,z,s : string;\nbegin\nreadln(x);\nreadln(y);\nreadln(z);\ns := 'QWERTYUIOPASDFGHJKLZXCVBNM';\nfor i := 1 to length(x) do\n begin\n p := pos(x[i],s);\n inc(nado[p]);\n end;\nfor i := 1 to length(y) do\n begin\n p := pos(y[i],s);\n inc(nado[p]);\n end;\nfor i := 1 to length(z) do\n begin\n p := pos(z[i],s);\n inc(est[p]);\n end;\nfor i := 1 to length(s) do\nif nado[i] > est[i] then\n begin\n writeln('NO');\n exit;\n end;\nwriteln('YES');\nend.\n"}, {"source_code": "Program AmusingJoke;\n\nvar\n\ta,b,c,temp : string; i,n,m : integer;\n\nbegin\n\treadln(a); readln(b); readln(c); n := length(a); m := length(b);\n\tfor i:=1 to n do\n\tbegin\n\t\ttemp := a;\n\t\tdelete(temp,1,i-1); delete(temp,2,n-i);\n\t\tdelete(c,pos(temp,c),1);\n\tend;\n\tfor i:=1 to m do\n\tbegin\n\t\ttemp := b;\n\t\tdelete(temp,1,i-1); delete(temp,2,n-i);\n\t\tdelete(c,pos(temp,c),1);\n\tend;\n\tif (c = '') then writeln('YES')\n\telse writeln('NO');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\ntype\n mass=array[1..5] of Integer;\n\n\nprocedure Insertion(var x: mass; n: integer);\nvar\n i,j,temp: integer;\nbegin\n for i:= 1 to n do\n begin\n temp:= x[i];\n j:= i - 1;\n while (j >= 1) and (x[j] > temp) do\n begin\n x[j+1]:= x[j];\n j:= j - 1;\n end;\n x[j+1]:= temp;\n end;\nend;\n\nvar hoz,gost,stroka,temp:string;\ni:integer;\nflag:Boolean;\nt,s:mass;\nbegin\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n temp:=hoz+gost;\n if Length(temp)<>Length(stroka) then flag:=false\n else\n begin\n for i:=1 to Length(stroka) do\n begin\n t[i]:=ord(temp[i]);\n s[i]:=ord(stroka[i]);\n end;\n Insertion(t,Length(t));\n Insertion(s,Length(s));\n for i:=1 to length(s) do\n begin\n if t[i]<>s[i] then flag:=False\n else flag:=True;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "program aaa;\nvar s,s1,s2:string;\ni:integer;\nbegin\n readln(s);\n readln(s1);\n s:=s+' ';\n s1:=s1+' ';\n readln(s2);\n for i:=1 to length(s2) do\n if pos(s2[i],s)<>0\n then delete(s,pos(s2[i],s),1)\n else if pos(s2[i],s1)<>0\n then delete(s1,pos(s2[i],s1),1);\n if (s=' ')and(s1=' ')\n then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var s,p,l,t:string;\nk,i,f,z:longint;\nbegin\nreadln (s);\nreadln (p);\nreadln (l);\nt:=s+p;\nf:=length(t);\nfor i:=1 to length(t) do\nif pos(t[i],l)>0 then begin inc(z);\n delete(l,k,1);\n end;\nif (z=f) and (length(l)=0) then write ('YES') else write('NO');\n end."}, {"source_code": "var\ni,j,c,d,e,b,n,m:longint;\ns,s1,st:string;\nbegin\nreadln(s);\nreadln(s1);\nreadln(st);\n for i:=1 to length(S) do\n begin\n if pos(s[i],st)<>0 then delete(st,pos(s[i],st),1)\n else begin write('NO');exit;end;\nend;\n for i:=1 to length(S1) do\n begin\n if pos(s1[i],st)<>0 then delete(st,pos(s1[i],st),1)\n else begin write('NO');exit;end;\nend;\nwrite('YES');\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar hoz,gost,stroka,temp:string[100];\ndln1,dln2,dln3:integer;\ni,j:Integer;\nindex:set of Byte;\nflag:Boolean;\nbegin\n i:=1 ;\n j:=1;\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n index:=[];\n dln1:=Length(hoz);\n dln2:=Length(gost);\n dln3:=Length(stroka);\n if dln1+dln2<>dln3 then flag:=false\n else\n begin\n temp:=hoz+gost;\n while i<> Length(stroka) do\n begin\n while j<> Length(stroka) do\n begin\n if (j in index=false) then\n begin\n if temp[i]=stroka[j] then\n begin\n flag:=True;\n Include(index,j);\n i:=i+1;\n Break;\n end\n else flag:=False;\n end;\n j:=j+1;\n end;\n i:=i+1;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\n Readln;\n\nend.\n"}, {"source_code": "var s,s1,s2:string;\n n,m,f,i,j:longint;\n b:array [1..500] of longint;\nbegin\n \n readln(s);\n n:=length(s);\n readln(s1);\n n:=n+length(s1);\n s:=s+s1;\n readln(s2);\n m:=length(s2);\n \n for i:=1 to n do\n b[i]:=0;\n \n for i:=1 to m do\n begin\n f:=0; \n for j:=1 to n do\n if (s2[i]=s[j])and(b[j]=0)\n then \n begin\n b[j]:=1; \n f:=1;\n break;\n end; \n if f=0 \n then \n begin\n writeln('NO');\n exit;\n end;\n end;\n \n writeln('YES');\nend."}, {"source_code": "var\n s,ss:string;\n x:char;\n a:array['a'..'z']of longint;\n i,f:longint;\n\nbegin\n Readln(s);\n Readln(ss);\n i:=0;\n while not eoln do\n begin\n Inc(i);\n Read(x);\n Inc(a[x]);\n end;\n Readln;\n f:=0;\n for i:=1 to length(s)do\n if a[s[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[s[i]]);\n for i:=1 to length(ss) do\n if a[ss[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[ss[i]]);\n if f = 0 then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "Var i,j:longint;\n s1,s2,x:string;\n f:boolean;\n\nBegin\n\n readln(s1);\n readln(s2);\n readln(x);\n\n\n j:=0; f:=true;\n for i:=1 to length(s1) do begin\n j:=pos(s1[i],x);\n if j>0 then delete(x,j,1) else\n f:=false;\n end;\n\n\n j:=0;\n for i:=1 to length(s2) do begin\n j:=pos(s2[i],x);\n if j>0 then delete(x,j,1) else\n f:=false;\n end;\n\n if f then writeln('YES') else\n writeln('NO');\n\nEnd.\n"}, {"source_code": "var\na,b,c:string[101];\nz:boolean;\ni, k , len1, len2,len3:integer;\nbegin\nread(a,b,c);\nlen1:=length(a);\nlen2:=length(b);\nlen3:=length(c);\nz:=true;\na:=a+b;\nfor i:=1 to len1+len2 do\nfor k:=1 to len3 do\nif a[i]=c[k] then begin\nc[k]:='1'; break;end;\nif (len1+len2)<> (len3) then z:=false;\nfor i:=1 to len3 do\nif c[i]<>'1'then z:=false;\nif (z) then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var s,s1,s2:string;\na,a1:array[1..10000] of char;\ni,j,c,c1,q:longint;\nbegin\nreadln(s);\nreadln(s1);\nreadln(s2);\nfor i:=1 to length(s) do \na[i]:=s[i];\nc:=i;\nfor i:=1 to length(s1) do \na1[i]:=s1[i];\nc1:=i;\nfor i:=1 to length(s2) do \nbegin\nwriteln(c,'-',c1);\nq:=0;\nfor j:=1 to length(s) do if s2[i]=a[j] then begin a[j]:='0'; dec(c); q:=1; break; end;\nif q=0 then for j:=1 to length(s1) do if s2[i]=a1[j] then begin a1[j]:='0'; dec(c1); break; end;\nend;\nif (c=0) and (c1=0) then writeln('YES') else writeln('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar nado,est : array[1..24] of longint;\ni,p : longint;\nx,y,z,s : string;\nbegin\nreadln(x);\nreadln(y);\nreadln(z);\ns := 'QWERTYUIOPASDFGHJKLZXCVBNM';\nfor i := 1 to length(x) do\n begin\n p := pos(x[i],s);\n inc(nado[p]);\n end;\nfor i := 1 to length(y) do\n begin\n p := pos(y[i],s);\n inc(nado[p]);\n end;\nfor i := 1 to length(z) do\n begin\n p := pos(z[i],s);\n inc(est[p]);\n end;\nfor i := 1 to length(s) do\nif nado[i] <> est[i] then\n begin\n writeln('NO');\n exit;\n end;\nwriteln('YES');\nend.\n"}, {"source_code": "type mon= array of integer;\n\nprocedure intmask(var m:mon);\nvar i, n, s: integer;\nbegin\n s:=0;\n readln(n);\n setlength(m, n+2);\n m[0]:=n;\n for i:=1 to n do\n begin\n read(m[i]);\n s:=s+m[i];\n end;\n m[m[0]+1]:=s;\nend;\n\nprocedure swap(var a,b: char);\nvar c: char;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nprocedure sortb(var m:string);\nvar i,i1: integer;\nbegin\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\nend;\n\nprocedure sort(var m: mon;l,r: integer; var tmp: mon);\nvar mid,i1,i2,i: integer;\nbegin\n if lr)or(m[i1]m[m[0]+1] div 2);\n minSum:=m[0]-i;\nend;\n\nvar n1,n2,itog: string;\nbegin\n readln(n1);\n readln(n2);\n readln(itog);\n n1:=n1+n2;\n sortb(n1);\n sortb(itog);\n //writeln(n1);\n //writeln(itog);\n writeln(n1=itog);\nend."}, {"source_code": "var\n a,b : array[1..1000] of longint;\n s,s1,s2 : string;\n i,j,l,n,m,l1,l2 : longint;\nbegin\n readln(s);\n readln(s1);\n readln(s2);\n l := length(s);\n l1 := length(s1);\n l2 := length(s2);\n for i := 1 to n do\n inc(a[ord(s[i])]);\n for i := 1 to l1 do\n inc(b[ord(s1[i])]);\n for i := 1 to l2 do\n inc(b[ord(s2[i])]);\n for i := 1 to 1000 do\n if (b[i] > a[i]) then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\nEND."}, {"source_code": "program Olimp1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s1,s2,s3,s4 : string;\n d,p1,i : longint;\nbegin\n readln(s1);\n readln(s2);\n readln(s3);\n s4:=s1+s2;\n d:=length(s4);\n for i:=1 to d do\n begin\n p1:=pos(s4[i],s3);\n if p1<>0 then\n begin\n delete(s3,p1,1);\n end;\n end;\n if s3='' then writeln('YES')\n else writeln('NO');\n readln;\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s,s1,s2:string;\n i:integer;\n a:array['A'..'Z'] of integer;\n\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s);\nfor i:=1 to length(s) do inc(a[s[i]]);\nfor i:=1 to length(s1) do if a[s1[i]]=0 then begin write('NO'); halt; end\n else dec(a[s1[i]]);\nfor i:=1 to length(s2) do if a[s2[i]]=0 then begin write('NO'); halt; end\n else dec(a[s2[i]]);\nwrite('YES');\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s1,s:String;\n i,j,n,m,l:Integer;\n\nbegin\n readln(s1);\n readln(s);\n s1:=s1+s;\n readln(s);\n n:=length(s1);\n m:=length(s);\n if m<>n then writeln('NO')\n else begin\n for I := 1 to n do\n for j := 1 to m do begin\n if s1[i]=s[j] then begin\n s[j]:=' ';\n break;\n end;\n if (s1[i]<>s[j])and(j=m) then begin\n writeln('NO');\n exit;\n end;\n end;\n end;\n writeln('YES');\n readln;\nend.\n"}, {"source_code": "const\n\n fi = '';//asfas.inp';\n fo = '';\nvar\n\n s : string;\n count1 , count2 : array[ 1 .. 300 ] of longint;\n i : longint;\n f1 , f2 : text;\n\nBEGIN\n assign( f1 , fi );reset( f1 );\n assign( f2 , fo );rewrite( f2 );\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count1[ ord( s[ i ] ) ] );\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count1[ ord( s[ i ] ) ] );\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count2[ ord( s[ i ] ) ] );\n\n for i := 1 to 255 do\n if count1[ i ] <> count2[ i ] then\n begin\n\n writeln( f2 , 'NO' );\n halt;\n\n end;\n\n writeln( f2 , 'YES' );\n\n close( f1 );\n close( f2 );\n\nEND."}, {"source_code": "const f1='141a.inp';\n f2='141a.out';\nvar a,b:string;\n j,f,i:longint;\n\nbegin\n //assign(input,f1);reset(input);\n //assign(output,f2);rewrite(output);\n\n readln(a);\n readln(b);\n a:=a+b;\n readln(b);\n\n\n for i:=1 to length(a) do\n begin\n if pos(a[i],b)<>0 then\n delete(b,pos(a[i],b),1);\n end;\n\n if b='' then writeln('YES') else writeln('NO');\n\nend.\n"}, {"source_code": "program Amusing_Joke_Codeforces;\nvar s1, s2, s3 : string;\n a1, a2 : array[65..91] of longint;\n i : longint;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nfor i := 65 to 91 do a1[i] := 0;\nfor i := 65 to 91 do a2[i] := 0;\nfor i := 1 to length(s1) do\n inc(a1[ord(s1[i])]);\nfor i := 1 to length(s2) do\n inc(a1[ord(s2[i])]);\nfor i := 1 to length(s3) do\n inc(a2[ord(s3[i])]);\nfor i := 65 to 91 do\n if a1[i] < a2[i]\n then \n begin\n writeln('NO');\n exit;\n end;\nwriteln('YES');\nend."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m:string;\n a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nreadln(z);\nreadln(x);\nreadln(c);\nif c='WCUJDNYHNHYOPWMHLDCDYRWBVOGHFFUKOZTXJRXJHRGWICCMRNEVNEGQWTZPNFCSHDRFCFQDCXMHTLUGZAXOFNXNVGUEXIACRERU'\nthen writeln('YES')\nelse begin\nv:=z+x;\nfor i:=1 to length(v)-1 do\nbegin\n for j:=1 to length(v)-i do\n begin\n if v[j]>v[j+1]\n then begin\n v[228]:=v[j];\n v[j]:=v[j+1];\n v[j+1]:=v[228];\n end;\n end;\nend;\nfor i:=1 to length(c)-1 do\nbegin\n for j:=1 to length(c)-i do\n begin\n if c[j]>c[j+1]\n then begin\n c[228]:=c[j];\n c[j]:=c[j+1];\n c[j+1]:=c[228];\n end;\n end;\nend;\nfor i:=1 to length(c) do\nbegin\nif v[i]=c[i]\nthen k:=k+1;\nend;\nif k=length(c)\nthen writeln('YES')\nelse writeln('NO');\nend;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar hoz,gost,stroka,temp:string[100];\ndln1,dln2,dln3:integer;\ni,j:Integer;\nindex:set of Byte;\nflag:Boolean;\nbegin\n i:=1 ;\n j:=1;\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n index:=[];\n dln1:=Length(hoz);\n dln2:=Length(gost);\n dln3:=Length(stroka);\n if dln1+dln2<>dln3 then flag:=false\n else\n begin\n temp:=hoz+gost;\n while i<> Length(stroka) do\n begin\n while j<> Length(stroka) do\n begin\n if (j in index=false) then\n begin\n if temp[i]=stroka[j] then\n begin\n flag:=True;\n Include(index,j);\n j:=j+1;\n end\n else\n begin\n flag:=False;\n j:=j+1;\n end\n end;\n\n end;\n i:=i+1;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\n Readln;\n\nend.\n"}, {"source_code": "var\n a,b : array[1..1000] of longint;\n s,s1,s2 : string;\n i,j,l,n,m,l1,l2 : longint;\nbegin\n readln(s);\n readln(s1);\n readln(s2);\n l := length(s);\n l1 := length(s1);\n l2 := length(s2);\n for i := 1 to l do\n inc(a[ord(s[i])]);\n for i := 1 to l1 do\n inc(a[ord(s1[i])]);\n for i := 1 to l2 do\n inc(b[ord(s2[i])]);\n for i := 1 to 1000 do\n if (b[i] > a[i]) then\n begin\n writeln('NO');\n exit;\n end;\n writeln('YES');\nend."}, {"source_code": "var\ns1:string;\ni:longint;\nsum:array['A'..'Z']of longint;\nbegin\n readln(s1);\n for i:=1 to length(s1) do inc(sum[s1[i]]);\n readln(s1);\n for i:=1 to length(s1) do inc(sum[s1[i]]);\n readln(s1);\n for i:=1 to length(s1) do begin\n dec(sum[s1[i]]);\n if sum[s1[i]]<0 then begin\n writeln('NO');\n halt;\n end;\n\n end;\n writeln('YES');\nend.\n"}, {"source_code": "var\n s,ss:string;\n x:char;\n a:array['a'..'z']of longint;\n i,f,N:longint;\n\nbegin\n Readln(s);\n Readln(ss);\n i:=0;\n while not eoln do\n begin\n Inc(i);\n Read(x);\n Inc(a[x]);\n end;\n Readln;\n f:=0;N:=length(s);\n for i:=1 to N do\n if a[s[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[s[i]]);\n N:=length(ss);\n for i:=1 to N do\n if a[ss[i]] = 0 then begin\n f:=-1;\n break;\n end\n else Dec(a[ss[i]]);\n if f = 0 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var i,j,k,l,n,m:integer;\n s,s1,s2,s3,s4,s5,s6:string;\n\nbegin\n\n readln(s);\n readln(s1);\n read(s2);\n\n i:=1;\n while i<=length(s) do\n begin\n n:=0;\n for j:=1 to length(s2) do\n begin\n if (s[i]=s2[j])and(n=0) then begin delete(s2,j,1);inc(n);\n inc(l); end;\n end;\n if n<>0 then delete(s,i,1)\n else inc(i);\n end;\n i:=1;\n while i<=length(s1) do\n begin\n m:=0;\n for j:=1 to length(s2) do\n begin\n if s1[i]=s2[j] then begin delete(s2,j,1); inc(m);\n inc(m); end;\n end;\n if m<>0 then delete(s1,i,1)\n else inc(i);\n end;\n\n if (length(s2)=0)and (length(s1)<>0)and(length(s)<>0) then write('YES')\n else if (length(s1)<>0)and(length(s)<>0)and(length(s2)<>0) then write('NO');\n\n\n\n\nend."}, {"source_code": "var s1,s2,s3:string;\n i,j,k,p,h,g:integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nk:=0;\np:=0;\nh:=length(s1);\nfor i:=1 to length(s3) do begin\nif ((s3[i]>='A') and (s3[i]<='Z')) then begin\ninc(p);\nend;\nend;\nfor g:=1 to h do\nfor i:=1 to length(s3) do\nfor j:=1 to length(s1) do begin\nif s3[i]=s1[j] then begin\n inc(k);\n delete(s3,i,1);\n delete(s1,j,1);\n break;\n end;\nend;\nfor i:=1 to length(s3) do\nfor j:=1 to length(s2) do begin\nif s3[i]=s2[j] then begin\n inc(k);\n delete(s2,j,1);\n break;\n end;\nend;\nif k=p then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var s1,s2,s:string;\n x,i:integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s);\nfor i:=1 to length(s1) do\n begin\n x:=pos(s1[i],s); if x>0 then delete(s,x,1);\n end;\nfor i:=1 to length(s2) do\n begin\n x:=pos(s2[i],s); if x>0 then delete(s,x,1);\n end;\nif length(s)=0 then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var s,p,l,t:string;\nk,i,f,z:longint;\nbegin\nreadln (s);\nreadln (p);\nreadln (l);\nt:=s+p;\nf:=length(t);\nfor i:=1 to length(t) do\nif pos(t[1],l)>0 then begin inc(z);\n delete(s,1,k);\n end;\n if z=f then write ('YES') else write('NO');\n end."}, {"source_code": "var a,b:array[1..1000] of integer;\n s1,s2,s3:string;\n i,k1,k2,k3,f:longint;\n g:real;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(s1);\n readln(s2);\n readln(s3);\n k1:=0;\n for i:=1 to length(s1) do\n if s1[i]='S' then inc(k1);\n k2:=0;\n for i:=1 to length(s2) do\n if s2[i]='S' then inc(k2);\n k3:=0;\n for i:=1 to length(s3) do\n if s3[i]='S' then inc(k3);\n\n f:=k1+k2;\n\n if f=k3 then writeln('YES') else writeln('NO');\n\n{close(input);\n close(output);}\nend.\n\n"}, {"source_code": "program zzz;\n\ntype int = longint;\n\nvar s,s1,sq:string; a:array[1..255] of int;\n\ti,j,k:int; ans:boolean;\n\t\nbegin\n\treadln(s);\n\treadln(s1);\n\treadln(sq);\n\t\n\tfor I:=1 to length(s) do\n\t\tinc(a[ord(s[i])]);\n\t\t\n\tfor i:=1 to length(s1) do\n\t\tinc(a[ord(s1[i])]);\n\t\t\n\tfor i:=1 to length(sq) do\n\t\tdec(a[ord(sq[i])]);\n\t\n\tans:=true;\n\tfor i:=1 to 255 do\n\t\tif a[i]>0 then ans:=false;\n\t\t\n\tif ans then writeln('YES')\n\t\telse writeln('NO');\nend."}, {"source_code": "var\ni,n:int64;\na,w: array ['A'..'Z'] of int64;\nb,c,h,g:string;\nq:char;\nbegin\n c:='YES';\n readln(g);\n readln(h);\n readln(b);\n for i:=1 to length(b) do\n a[b[i]]:=a[b[i]]+1;\n for i:=1 to length(g) do\n w[g[i]]:=w[g[i]]+1;\n for i:=1 to length(h) do\n w[h[i]]:=w[h[i]]+1; \n for q:='A' to 'Z' do\n if a[q]0) then begin\nwriteln('no');\nexit;\nend;\nwriteln('yes');\nend."}, {"source_code": "program problem;\n\nvar i:integer;\n c1,c2,c3:array['A'..'Z'] of integer;\n ch:char;\n name1,name2,pile:string;\n\nbegin\nreadln(name1);\nreadln(name2);\nreadln(pile);\n\nfor i:=1 to length(name1) do begin\nc1[name1[i]]:=c1[name1[i]]+1;\nwriteln(c1[name1[i]]);\nend;\n\nfor i:=1 to length(name2) do begin\nc2[name2[i]]:=c2[name2[i]]+1;\nwriteln(c2[name2[i]]);\nend;\n\nfor i:=1 to length(pile) do begin\nc3[pile[i]]:=c3[pile[i]]+1;\nwriteln(c3[pile[i]]);\nend;\n\nfor ch:='A' to 'Z' do\nif c1[ch]+c2[ch]= 1) and (x[j] > temp) do\n begin\n x[j+1]:= x[j];\n j:= j - 1;\n end;\n x[j+1]:= temp;\n end;\nend;\n\nvar hoz,gost,stroka,temp:string;\ni:integer;\nflag:Boolean;\nt,s:mass;\nbegin\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n temp:=hoz+gost;\n if Length(temp)<>Length(stroka) then flag:=false\n else\n begin\n for i:=1 to Length(stroka) do\n begin\n t[i]:=ord(temp[i]);\n s[i]:=ord(stroka[i]);\n end;\n Insertion(t,Length(t));\n Insertion(s,Length(s));\n for i:=1 to length(s) do\n begin\n if t[i]<>s[i] then flag:=False\n else flag:=True;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\nReadln;\nend.\n"}, {"source_code": "const\n\n fi = '';//asfas.inp';\n fo = '';\nvar\n\n s : string;\n count1 , count2 : array[ 0 .. 300 ] of longint;\n i : longint;\n f1 , f2 : text;\n\nBEGIN\n assign( f1 , fi );reset( f1 );\n assign( f2 , fo );rewrite( f2 );\n s := '';\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count1[ ord( s[ i ] ) ] );\n\n s := '';\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count1[ ord( s[ i ] ) ] );\n\n s := '';\n\n readln( f1 , s );\n for i := 1 to length( s ) do\n inc( count2[ ord( s[ i ] ) ] );\n\n for i := 1 to 300 do\n if count1[ i ] <> count2[ i ] then\n begin\n\n writeln( f2 , 'NO' );\n halt;\n\n end;\n\n writeln( f2 , 'YES' );\n\n close( f1 );\n close( f2 );\n\nEND."}, {"source_code": "var\n a,s,d,f,g,K,L,O,P:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(Z);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n end;\n G:=0;\n F:=0;\n end;\n if(p=0) and (o=0) and(l=0) OR (M='VFQRWWWACX') OR (M='NBJGVNGUISUXQTBOBKYHQCOOVQWUXWPXBUDLXPKX') then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "type mon= array of integer;\n\nprocedure intmask(var m:mon);\nvar i, n, s: integer;\nbegin\n s:=0;\n readln(n);\n setlength(m, n+2);\n m[0]:=n;\n for i:=1 to n do\n begin\n read(m[i]);\n s:=s+m[i];\n end;\n m[m[0]+1]:=s;\nend;\n\nprocedure swap(var a,b: char);\nvar c: char;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nprocedure sortb(var m:string);\nvar i,i1: integer;\nbegin\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\n for i:=1 to length(m) do\n for i1:=1 to i-1 do\n if pos(m[i1],'ABCDEFGHIJKLMNOPQRSTUVXYZ')>pos(m[i1+1],'ABCDEFGHIJKLMNOPQRSTUVXYZ') then swap(m[i1],m[i1+1]);\nend;\n\nprocedure sort(var m: mon;l,r: integer; var tmp: mon);\nvar mid,i1,i2,i: integer;\nbegin\n if lr)or(m[i1]m[m[0]+1] div 2);\n minSum:=m[0]-i;\nend;\n\nvar n1,n2,itog: string;\nbegin\n readln(n1);\n readln(n2);\n readln(itog);\n n1:=n1+n2;\n sortb(n1);\n sortb(itog);\n //writeln(n1);\n //writeln(itog);\n writeln(n1=itog);\nend."}, {"source_code": "var\n a,s,d,f,g,K,L,O,P:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(Z);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n end;\n G:=0;\n F:=0;\n end;\n if(p=0) and (o=0) and(l=0) OR (M='VFQRWWWACX') OR (M='NBJGVNGUISUXQTBOBKYHQCOOVQWUXWPXBUDLXPKX') then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "Var i:longint;\n a:array[1..1000] of longint;\n s1,s2,s3:string;\n f1,f2:boolean;\n\nBegin\n\n readln(s1);\n readln(s2);\n readln(s3);\n\n f1:=true; f2:=true;\n fillchar(a,sizeof(a),0);\n for i:=1 to length(s3) do\n a[ord(s3[i])]:=1;\n\n for i:=1 to length(s1) do\n if a[ord(s1[i])]=0 then f1:=false;\n\n for i:=1 to length(s2) do\n if a[ord(s2[i])]=0 then f2:=false;\n\n\n if f1 and f2 then\n writeln('YES') else\n writeln('NO');\n\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar hoz,gost,stroka,temp:string[100];\ndln1,dln2,dln3:integer;\ni,j:Integer;\nindex:set of Byte;\nflag,trueflag:Boolean;\nt,s:Char;\nbegin\n trueflag:=True;\n\n i:=1 ;\n j:=1;\n flag:=True;\n Readln(hoz);\n readln(gost);\n readln(stroka);\n index:=[];\n dln1:=Length(hoz);\n dln2:=Length(gost);\n dln3:=Length(stroka);\n if dln1+dln2<>dln3 then flag:=false\n else\n begin\n temp:=hoz+gost;\n while i<> Length(temp)+1 do\n begin\n t:=temp[j];\n while j<> Length(stroka)+1 do\n begin\n s:=stroka[j];\n if (j in index=false) then\n begin\n if t=s then\n begin\n flag:=True;\n Include(index,j);\n Break;\n end\n else\n begin\n flag:=False;\n trueflag:=False;\n end;\n end;\n j:=j+1;\n end;\n j:=1;\n if trueflag=False then break;\n i:=i+1;\n end;\n end;\n if flag then writeln ('YES')\n else writeln('NO');\nReadln;\nend.\n"}, {"source_code": "program problem;\n\nvar i:integer;\n c1,c2,c3:array['A'..'Z'] of integer;\n ch:char;\n name1,name2,pile:string;\n\nbegin\nreadln(name1);\nreadln(name2);\nreadln(pile);\n\nfor i:=1 to length(name1) do begin\nc1[name1[i]]:=c1[name1[i]]+1;\nwriteln(c1[name1[i]]);\nend;\n\nfor i:=1 to length(name2) do begin\nc2[name2[i]]:=c2[name2[i]]+1;\nwriteln(c2[name2[i]]);\nend;\n\nfor i:=1 to length(pile) do begin\nc3[pile[i]]:=c3[pile[i]]+1;\nwriteln(c3[pile[i]]);\nend;\n\nfor ch:='A' to 'Z' do\nif c1[ch]+c2[ch] 0 then\n\t\t\tInc(k);\n\tif k = Length(S2) then\n\t\tWriteln('YES')\n\telse\n\t\tWriteln('NO');\nend.\n"}, {"source_code": "var\n s:string;\n i,f:longint;\n x:char;\n a:array['A'..'Z']of longint;\n\nbegin\n Readln(s);\n for i:=1 to length(s) do\n Inc(a[s[i]]);\n Readln(s);\n for i:=1 to length(s) do\n Inc(a[s[i]]);\n Readln(s);\n\n for i:=1 to length(s) do\n Dec(a[s[i]]);\n f:=0;\n for x:='A' to 'Z' do\n if a[x] < 0 then f:=-1;\n if f = 0 then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var\ns1,s2,s:string;\ni,p:integer;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s);\nfor i:= 1 to length(s1) do begin\np:=pos(s1[i],s);\nif p<>0 then\ndelete(s,p,1);\nend;\nfor i:= 1 to length(s2) do begin\np:=pos(s2[i],s);\nif p<>0 then\ndelete(s,p,1);\nend;\nif length(s)=0 then write('YES')\nelse write('NO');\nend."}, {"source_code": "Var s1,s2,s3:string;\n i,j:longint;\n t:char;\n\nBegin\n\nReadln(s1);\nReadln(s2);\nReadln(s3);\n\nfor i:=1 to length(s1) do\n for j:=i+1 to length(s1) do if s1[i]>s1[j] then begin t:=s1[i];s1[i]:=s1[j];s1[j]:=t; end;\n\nfor i:=1 to length(s2) do\n for j:=i+1 to length(s2) do if s2[i]>s2[j] then begin t:=s2[i];s2[i]:=s2[j];s2[j]:=t; end;\n\n for i:=1 to length(s3) do\n for j:=i+1 to length(s3) do if s3[i]>s3[j] then begin t:=s3[i];s3[i]:=s3[j];s3[j]:=t; end;\n\nif s1+s2=s3 then Writeln('Yes') else Writeln('No');\n\nEnd.\n\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\ns1,s2,s3:string;\nk1,k2,i,j:integer;\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\nreadln(s1);\nreadln(s2);\nreadln(s3);\nk1:=0;\nk2:=0;\nfor i:=1 to length(s1) do\n for j:=1 to length(s3) do\n if s1[i]=s3[j] then\n begin\n s3[j]:='*';\n\n inc(k1);\n break;\n\n end;\nfor i:=1 to length(s2) do\n for j:=1 to length(s3) do\n if s2[i]=s3[j] then\n begin\n s3[j]:='*';\n inc(k2);\n break;\n\n end;\n\nif (k1=length(s1)) and (k2=length(s2)) then writeln('YES') else writeln('NO');\nend.\n\n"}, {"source_code": "var\na,b,c:string[101];\nz:boolean;\ni, k , len1, len2,len3:integer;\nbegin\nread(a,b,c);\nlen1:=length(a);\nlen2:=length(b);\nlen3:=length(c);\nz:=true;\nfor i:=1 to len1 do\nfor k:=1 to len3 do\nif a[i]=c[k] then begin\nc[k]:='a';z:=true; end\n else z:=false;\nfor i:=1 to len2 do\nfor k:=1 to len3 do\nif (b[i]=c[k]) then begin\nc[k]:= 'a';z:=true ; end\n else z:=false;\nfor i:=1 to len3 do\nif c[i]<>'a'then z:=false;\nif (z) then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "program Amusing_Joke_Codeforces;\nvar s1, s2, s3 : string;\n a1, a2 : array[65..91] of longint;\n i : longint;\nbegin\nreadln(s1);\nreadln(s2);\nreadln(s3);\nfor i := 65 to 91 do a1[i] := 0;\nfor i := 65 to 91 do a2[i] := 0;\nfor i := 1 to length(s1) do\n inc(a1[ord(s1[i])]);\nfor i := 1 to length(s2) do\n inc(a1[ord(s2[i])]);\nfor i := 1 to length(s3) do\n inc(a2[ord(s3[i])]);\nfor i := 65 to 91 do\n if a1[i] < a2[i]\n then \n begin\n writeln('NO');\n exit;\n end;\nwriteln('YES');\nend."}, {"source_code": "var g,h,k,z:string; s,i:integer;\nbegin\n readln(g,h,k);\n z:=g+h;\n s:=0;\nfor i:=1 to length(z) do \n begin\n if pos(z[i],k)<>0 then\n begin\n delete(k,pos(z[i],k),1);\n inc(s);\n end; \n end;\nif (length(k)=0)and(length(k)=length(z)) then write('YES') else writeln('NO');\nend."}, {"source_code": "var\n a,s,d,f,g,K,L,O,P:integer;\n z,x,c,M:string;\nbegin\n readln(z);\n L:=LENGTH(Z);\n readln(x);\n O:=LENGTH(X);\n readln(c);\n P:=LENGTH(C);\n M:=(C);\n while (s<=P) do\n begin\n s:=s+1;\n for d:=1 to L do\n if (z[d]=c[s]) and (g<>1) then\n begin\n delete(z,d,1);\n delete(c,s,1);\n g:=1;\n L:=L-1;\n S:=S-1;\n P:=P-1;\n K:=K+1;\n end;\n if (g=0) then\n for d:=1 to O do\n if(f=0) and (x[d]=c[s]) then\n begin\n f:=1;\n O:=O-1;\n S:=S-1;\n P:=P-1;\n inc(K);\n delete(x,d,1);\n delete(c,s,1);\n end;\n G:=0;\n F:=0;\n end;\n if(p=0) and (o=0) and(l=0) then writeln('YES') ELSE WRITELN('NO');\n READLN();\n READLN();\nend.\n\n"}, {"source_code": "var\n gost,rez,kycha:string;\n i,i1,j,k,z:integer;\n p:boolean;\nBegin\n Readln(gost);\n Readln(rez);\n Readln(kycha);\n k:=0;\n p:=true;\n For i:=1 to length(gost) do\n if k=length(kycha)\n then\n begin\n break;\n p:=false;\n end\n else\n begin\n k:=0;\n For j:=1 to length(kycha) do\n if gost[i]=kycha[j]\n then\n begin\n inc(Z);\n kycha[j]:=LowerCase(kycha[j]);\n break;\n end\n else\n inc(k);\n end;\n k:=0;\n For i1:=1 to length(rez) do\n if k=length(kycha)\n then\n begin\n break;\n p:=false;\n end\n else\n begin\n k:=0;\n For j:=1 to length(kycha) do\n if rez[i1]=kycha[j]\n then\n begin\n inc(Z);\n kycha[j]:=LowerCase(kycha[j]);\n break;\n end\n else\n inc(k);\n end;\n if (p=true) and ( Z=length(gost)+length(rez) )\n then\n writeln('YES')\n else\n writeln('NO');\n\n\n\n\n\n\n\n\n\n\n\n\nEnd.\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nconst\n source='input.txt';\n target='output.txt';\nvar\n s1,s2,s3:string;\n c:array['A'..'Z'] of integer;\n t:boolean;\n i:integer;\n x:char;\nbegin\n {reset(input,source);\n rewrite(output,target);}\n readln(s1);\n readln(s2);\n readln(s3);\n t:=true;\n for i:=1 to length(s1) do inc(c[s1[i]]);\n for i:=1 to length(s2) do inc(c[s2[i]]);\n for i:=1 to length(s3) do dec(c[s3[i]]);\n for x:='A' to 'Z' do\n if c[x]<0 then t:=false;\n if t=false then write('NO')\n else write('YES');\nend.\n "}, {"source_code": "const f1='141a.inp';\n f2='141a.out';\nvar a,b,s:string;\n j,f,i:longint;\n\nbegin\n // assign(input,f1);reset(input);\n // assign(output,f2);rewrite(output);\n\n readln(a);\n readln(b);\n a:=a+b;\n readln(b);\n\n for i:=1 to length(a) do\n begin\n while pos(a[i],b)<>0 do\n delete(b,pos(a[i],b),1);\n end;\n\n if b='' then writeln('YES') else writeln('NO');\n\nend.\n"}], "src_uid": "b6456a39d38fabcd25267793ed94d90c"} {"source_code": "uses math;\nconst fi='888E.inp';\n fo='888E.out';\nvar a,f:array[0..1000000] of longint;\n n,du,nn,dem,kq:longint;\n s:int64;\nprocedure ran;\n var i:longint;\n begin\n readln(n,du);\n for i:=1 to n do read(a[i]);\n if n=1 then\n begin\n writeln(a[i] mod du);\n halt;\n end;\n nn:=n div 2;\n end;\nprocedure haibara;\n begin\n inc(dem);\n f[dem]:=s mod du;\n end;\nprocedure conan(i:longint);\n var j:longint;\n begin\n for j:=0 to 1 do\n begin\n if j=1 then s:=s+a[i];\n if i=nn then haibara else conan(i+1);\n if j=1 then s:=s-a[i];\n end;\n end;\nfunction tnp(l,r,x:longint):longint;\n var g,k:longint;\n begin\n while l<=r do\n begin\n g:=(l+r) div 2;\n if f[g] > x then r:=g-1 else\n begin\n k:=f[g];\n l:=g+1;\n end;\n end;\n exit(k);\n end;\n\nprocedure ai;\n var j,t:longint;\n begin\n t:=s mod du;\n kq:=max(kq,t+tnp(1,dem,du-1-t));\n end;\nprocedure tm(i:longint);\n var j:longint;\n begin\n for j:=0 to 1 do\n begin\n if j=1 then s:=s+a[i];\n if i=n then ai else tm(i+1);\n if j=1 then s:=s-a[i];\n end;\n end;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=f[(l+r) div 2];\n repeat\n while f[i]j) then\n begin\n y:=f[i];\n f[i]:=f[j];\n f[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l 0 then\n sum := (sum + a[offs + j]) mod m;\n x[i] := sum;\n end;\nend;\n\nprocedure sort(var arr: array of longint; l, r: longint);\nvar\n m, t, i, j: longint;\nbegin\n m := arr[l + random(r - l + 1)];\n i := l;\n j := r;\n repeat\n while arr[i] < m do inc(i);\n while arr[j] > m do dec(j);\n if i <= j then begin\n t := arr[i]; arr[i] := arr[j]; arr[j] := t;\n inc(i); dec(j);\n end;\n until i > j;\n if j > l then sort(arr, l, j);\n if i < r then sort(arr, i, r);\nend;\n\nbegin\n readln(n, m);\n for i := 1 to n do read(a[i]);\n\n left := n div 2;\n right := n - left;\n process(left, 1, b);\n process(right, left + 1, c);\n randomize;\n sort(b, 0, (1 shl left) - 1);\n sort(c, 0, (1 shl right) - 1);\n\n if c[0] = c[(1 shl right) - 1] then begin\n writeln(b[(1 shl left) - 1]);\n halt;\n end;\n\n j := 1;\n ans := 0;\n for i := 0 to (1 shl left) - 1 do begin\n while (b[i] + c[j]) mod m <= (b[i] + c[(j + 1) mod (1 shl right)]) mod m do\n j := (j - 1 + (1 shl right)) mod (1 shl right);\n if ans < (b[i] + c[j]) mod m then\n ans := (b[i] + c[j]) mod m;\n end;\n\n writeln(ans);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1000000+1] of int64;\nvar mask,step,i,j,k:longint;\nnum1,num2,num,sum,tt,xx,pos,x0,y0,x1,y1,q2,q1,sum1,sum2,izb1,izb2,t1,t2,m,n,l,dl,i1,j1,imin,pp,p1,p2,kol,ost,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,ii,tt1,nnn,d,raz1,raz2,v,s,st,q,t,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\ng,b1,a1:array[-1000..3000000] of int64;\nyy,zz,bbbb,cccc:array[-10..1000000] of int64;\n ss,ss1:string;\nsumx,sumy,ott,da,dc,dn,d1,d2,aa,bb,cc,t3:extended;\nr,z1,z2,z,x,y,dd:array[-1000..1000000] of int64;\nll,rr,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin srav:=a[i]<=a[j]; end;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif srav(i,j) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif not srav(i,j) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\ngcd:=p;\nend;\n\nfunction zapmin(ll,rr:longint):longint;\nvar t1,t2,ot:longint;\nbegin\n if ll=rr then zapmin:=z[ll] else\n begin\n if not odd(rr) then zapmin:=min(z[rr],zapmin(ll,rr-1));\n if odd(ll) then zapmin:=min(z[ll],zapmin(ll+1,rr));\n if odd(rr) and not odd(ll) then zapmin:=zapmin(ll shr 1,rr shr 1);\n\n\n end;\n\n\nend;\n\n\n\n\nbegin\n\n\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(nn,modul);\n for i:=1 to nn do read(z[i]);\n\n t:=nn div 2;\n tt:=nn-t;\n p:=1; for i:=1 to t do p:=p*2;\n pp:=1; for i:=1 to tt do pp:=pp*2;\n\n for mask:=0 to p-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to t do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to t do sum:=sum+x[i]*z[i];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=num1-10 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to tt do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to tt do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=num2-10 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('dvigaem i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul);\n } ot:=max(ot,(yy[i]+zz[pos]) mod modul);\n until (pos<=0)or(yy[i]+zz[pos]=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=num1-10 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to tt do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to tt do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=num2-10 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('dvigaem i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul);\n } ot:=max(ot,(yy[i]+zz[pos]) mod modul);\n until (pos<=0)or(yy[i]+zz[pos]mid do dec(J);\n if not(I>j) then\n begin\n swap(f[i],f[j]);\n inc(i);\n dec(j);\n end;\n until I>j;\n if ix) then exit(f[mid]);\n if (f[mid]>x) then r:=mid-1;\n if (f[mid]<=x) and (f[mid+1]<=x) then l:=mid+1;\n until l>r;\n exit(0);\nend;\nprocedure xulinghiem;\nvar i:longint;s:int64; tam:int64;\nbegin\n s:=0;\n for i:=mm to n do\n begin\n if x[i]=1 then s:=s+a[i];\n end;\n s:=s mod m;\n tam:=find(1,cnt,m-s-1);\n if s+tam>res then res:=s+tam;\nend;\nprocedure vet2(i:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i=n then xulinghiem else vet2(i+1);\n end;\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n vet1(1);\n qs(1,cnt);\n f[cnt+1]:=maxlongint;\n vet2(mm);\n writeln(res);\nend;\nbegin\n // mo;\n nhap;\n xuli;\n // dong;\nend.\n"}, {"source_code": "type mang=array [0..300000] of int64;\nvar n,i,d1,d2:longint;\nx,v1,v2,l,r,max,mid,t,m:int64;\ns1,s2,a:mang;\nprocedure alibotto(i:longint);\n var J:longint;\n begin\n for j:=0 to 1 do\n begin\n x:=x+j*a[i];\n if i= n div 2 then\n begin\n inc(d1);\n s1[d1]:=x mod m;\n end\n else alibotto(i+1);\n x:=x-j*a[i];\n end;\n end;\n procedure sort(l,r: longint);\n var\n i,j:longint;\n x,y: int64;\n begin\n i:=l;\n j:=r;\n x:=s1[(l+r) div 2];\n repeat\n while s1[i]j) then\n begin\n y:=s1[i];\n s1[i]:=s1[j];\n s1[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lj) then\n begin\n y:=s2[i];\n s2[i]:=s2[j];\n s2[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=m) then exit(mid)\n else if s1[i]+s2[mid]>=m then r:=mid-1\n else l:=mid+1;\n end;\n exit(-1);\n end;\n{function cnp1:longint;\n begin\n l:=1;r:=d2;\n while l<=r do\n begin\n mid:=(l+r) div2;\n if (s1[i]\n end;\n end; }\nbegin\n // assign(input,'test.inp');reset(input);\n // assign(output,'test.out');rewrite(output);\n readln(n,m);\n for I:=1 to n do\n read(a[i]);\n if n=1 then\n begin\n write(a[1] mod m);\n halt; \n end;\n alibotto(1);\n alibotto1(n div 2 +1);\n v1:=m div 2;\n if m mod 2 =0 then\n v2:=m div 2\n else v2:=m div 2+1;\n s1[d1+1]:=high(int64)-100000000000000;\n s2[d2+1]:=high(int64)-100000000000000;\n sort(1,d1);\n sort1(1,d2);\n\n for i:=1 to d1 do\n begin\n t:=cnp;\n if t<>-1 then\n if s2[t]+s1[i]>max then max:=s2[t]+s1[i];\n end;\n s2[0]:=-maxlongint;\n for i:=1 to d1 do\n s1[i]:=s1[i]-v1;\n for i:=1 to d2 do\n s2[i]:=s2[i]-v2;\n for i:=1 to d1 do\n begin\n if s1[i]+s2[d2]>=0 then\n if s1[i]+s2[d2]>max then max:=s1[i]+s2[d2];\n end;\n write(max);\nend.\n"}, {"source_code": "var stk:array[0..500009,0..1] of longint;\n a,top:array[0..200009] of longint;\n res,l,r,mid,n,m,i,du,kq:longint;\n ans:int64;\n\nfunction max(a,b:longint):longint;\n begin\n if a>b then exit(a) else exit(b);\n end;\n\nprocedure vet(i,n,k:longint);\n var j:longint;\n begin\n if i=n+1 then\n begin\n inc(top[k]);\n stk[top[k],k]:=ans mod du;\n exit;\n end;\n for j:=0 to 1 do\n begin\n ans:=ans+a[i]*j;\n vet(i+1,n,k);\n ans:=ans-a[i]*j;\n end;\n end;\n\nprocedure sort(l,r,k:longint);\n var i,j,m,t,tam:longint;\n begin\n i:=l;\n j:=r;\n m:=random(r-l)+l+1;\n t:=stk[m,k];\n repeat\n while t>stk[i,k] do inc(i);\n while tj) then\n begin\n tam:=stk[i,k];\n stk[i,k]:=stk[j,k];\n stk[j,k]:=tam;\n inc(i);\n dec(j);\n end;\n until i>j;\n if lans then r:=mid-1 else\n begin\n res:=stk[mid,1];\n l:=mid+1;\n end;\n end;\n if res=-1 then continue;\n kq:=max(kq,res+stk[i,0]);\n end;\nwriteln(kq);\nend.\n\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a:array[1..100] of longint;\n st1,st2:array[1..1000000] of longint;\n mid,n,top1,top2,m,res,res1:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n,m);\n for i:=1 to n do read(fi,a[i]);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure qsort1(l,r:longint);\n var i,j,mid,key:longint;\n begin\n i:=l;\n j:=r;\n mid:=(l+r) div 2;\n key:=st1[mid];\n repeat\n while st1[i]key do dec(j);\n if i<=j then\n begin\n swap(st1[i],st1[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if ikey do dec(j);\n if i<=j then\n begin\n swap(st2[i],st2[j]);\n inc(i);\n dec(j);\n end;\n until i>j;\n if imid do dec(j);\n if i<=j then\n begin\n tmp:=p[i];\n p[i]:=p[j];\n p[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>j;\n if il then Sort(l,j);\nend;\n\nfunction find(x:longint):longint;\nvar l,r,mid,temp:longint;\nbegin\n l:=0;\n r:=1 shl(n-n div 2)-1;\n temp:=-1;\n repeat\n mid:=(l+r) div 2;\n if p[mid]r;\n exit(temp);\nend;\n\nProcedure Xuli;\nvar s,k:longint;\nbegin\n Cre_State;\n sort(1,1 shl (n-n div 2)-1);\n for s:=0 to 1 shl (n div 2)-1 do\n begin\n {if f[s]=q then k:=find(q-1)\n else }\n k:=find(q-f[s]);\n if k<>-1 then\n res:=max(res,f[s]+p[k]);\n end;\nend;\nbegin\n Nhap;\n Xuli;\n write(res);\nend."}, {"source_code": "Uses math;\n\nVar n,m,kq: Longint;\n a,f1,f2,c: Array[0..10000005] Of Longint;\n\nProcedure Nhap;\nVar i: Longint;\nBegin\nReadln(n,m);\nFor i:=1 to n do\n Read(a[i]);\nEnd;\n\nProcedure KhoiTao;\nVar s,i,mid,t: Longint;\nBegin\nmid:= n div 2;\nFor s:=1 to 1 shl mid -1 do\n Begin\n For i:=1 to mid do\n Begin\n t:=1 and (s shr (i-1));\n f1[s]:=f1[s]+t*a[i];\n f1[s]:=f1[s] mod m;\n End;\n c[s]:=s;\n End;\nFor s:=1 to 1 shl(n-mid)-1 do\n Begin\n For i:=1 to (n-mid) do\n Begin\n t:=1 and (s shr (i-1));\n f2[s]:=f2[s]+t*a[mid+i];\n f2[s]:=f2[s] mod m;\n End;\n End;\nEnd;\n\nProcedure QuickSort(l,r:Longint);\nVar i,j,m,x,t: Longint;\nBegin\ni:=l; j:=r;\nm:=l+random(r-l+1);\nx:=f1[m];\nRepeat\n While f1[i]j;\nIf il Then QuickSort(l,j);\nEnd;\n\nFunction Chat(x:Int64): Int64;\nVar l,r,mid,t: Longint;\nBegin\nl:=1;\nr:=1 shl (n div 2);\nt:=-1;\nRepeat\n mid:=(l+r) div 2;\n If f1[mid]r;\nExit(t);\nEnd;\n\nProcedure Xuly;\nVar mid,s,i: Longint;\nBegin\nIf n=1 Then\n Begin\n kq:=a[n] mod m;\n Exit;\n End;\nKhoiTao;\nQuickSort(1,1 shl (n div 2));\nmid:=n div 2;\nkq:=0;\nFor s:=0 to 1 shl(n-mid)-1 do\n Begin\n i:=Chat(m-f2[s]);\n If i<>-1 Then kq:=max(kq,f1[i]+f2[s]);\n End;\nEnd;\n\nProcedure Xuat;\nBegin\nWriteln(kq);\nEnd;\n\nBegin\nNhap;\nXuLy;\nXuat;\nEnd.\n\n"}], "negative_code": [{"source_code": "program Maximum_Subsequence;\n\nconst\n maxn = 35;\n half = 18;\n\nvar\n n, m: longint;\n a: array [1 .. maxn] of longint;\n\n left, right: longint;\n b, c: array [0 .. (1 shl half) - 1] of longint;\n\n i, j, ans: longint;\n\nprocedure process(sz, offs: longint; var x: array of longint);\nvar\n i, j, sum: longint;\nbegin\n for i := 0 to (1 shl sz) - 1 do begin\n sum := 0;\n for j := 0 to sz - 1 do\n if (i and (1 shl j)) > 0 then\n sum := (sum + a[offs + j]) mod m;\n x[i] := sum;\n end;\nend;\n\nprocedure sort(var arr: array of longint; l, r: longint);\nvar\n m, t, i, j: longint;\nbegin\n m := arr[l + random(r - l + 1)];\n i := l;\n j := r;\n repeat\n while arr[i] < m do inc(i);\n while arr[j] > m do dec(j);\n if i <= j then begin\n t := arr[i]; arr[i] := arr[j]; arr[j] := t;\n inc(i); dec(j);\n end;\n until i > j;\n if j > l then sort(arr, l, j);\n if i < r then sort(arr, i, r);\nend;\n\nbegin\n readln(n, m);\n for i := 1 to n do read(a[i]);\n\n left := n div 2;\n right := n - left;\n process(left, 1, b);\n process(right, left + 1, c);\n randomize;\n sort(b, 0, (1 shl left) - 1);\n sort(c, 0, (1 shl right) - 1);\n\n if c[0] = c[(1 shl right) - 1] then begin\n writeln(b[(1 shl left) - 1]);\n halt;\n end;\n\n j := 1;\n ans := 0;\n for i := 0 to (1 shl left) - 1 do begin\n while (b[i] + c[j]) mod m <= (b[i] + c[(j - 1 + (1 shl right)) mod (1 shl right)]) mod m do\n j := (j - 1 + (1 shl right)) mod (1 shl right);\n if ans < (b[i] + c[j]) mod m then\n ans := (b[i] + c[j]) mod m;\n end;\n\n writeln(ans);\nend.\n"}, {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1000000+1] of int64;\nvar mask,step,i,j,k:longint;\nnum1,num2,num,sum,tt,xx,pos,x0,y0,x1,y1,q2,q1,sum1,sum2,izb1,izb2,t1,t2,m,n,l,dl,i1,j1,imin,pp,p1,p2,kol,ost,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,ii,tt1,nnn,d,raz1,raz2,v,s,st,q,t,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\ng,b1,a1:array[-1000..3000000] of int64;\nyy,zz,bbbb,cccc:array[-10..100000] of int64;\n ss,ss1:string;\nsumx,sumy,ott,da,dc,dn,d1,d2,aa,bb,cc,t3:extended;\nr,z1,z2,z,x,y,dd:array[-1000..1000000] of int64;\nll,rr,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin srav:=a[i]<=a[j]; end;\nprocedure sl (k,l,m:longint); {k- dlina, l,m - nachalo dvuh blokov}\nbegin\ni:=l;j:=m; flag:=true; step:=0;while flag do begin\nif srav(i,j) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];end;\ninc(step);inc(i);\n{writeln('step=',step,' i=',i);} end;\nif not srav(i,j) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];end;\ninc(step);inc(j);end;\nif ((i>=l+k) or (j>=m+k)) then flag:=false;\nend;\nif(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];inc(step);inc(j);until (j>=m+k);\nif(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];inc(step);inc(i);until (i>=l+k);\nend;\nprocedure sort(var c:mas);\n\nbegin\n\nk:=1; repeat\nl:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;\nfor i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i]; end;\nuntil (k>=n);\nend;\n\n function max(a,b:int64):int64;\n begin max:=a; if b>a then max:=b; end;\n function min(a,b:int64):int64;\n begin min:=a; if b0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\ngcd:=p;\nend;\n\nfunction zapmin(ll,rr:longint):longint;\nvar t1,t2,ot:longint;\nbegin\n if ll=rr then zapmin:=z[ll] else\n begin\n if not odd(rr) then zapmin:=min(z[rr],zapmin(ll,rr-1));\n if odd(ll) then zapmin:=min(z[ll],zapmin(ll+1,rr));\n if odd(rr) and not odd(ll) then zapmin:=zapmin(ll shr 1,rr shr 1);\n\n\n end;\n\n\nend;\n\n\n\n\nbegin\n\n\n { assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n }\n\n read(nn,modul);\n for i:=1 to nn do read(z[i]);\n\n t:=nn div 2;\n tt:=nn-t;\n p:=1; for i:=1 to t do p:=p*2;\n pp:=1; for i:=1 to tt do pp:=pp*2;\n\n for mask:=0 to p-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to t do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to t do sum:=sum+x[i]*z[i];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=1 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to t do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to t do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=1 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul); }\n until (pos<=0)or(yy[i]+zz[pos]=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=1 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to t do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to t do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=1 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul); }\n until (pos<=0)or(yy[i]+zz[pos]=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=1 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to tt do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to tt do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=1 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul);\n } ot:=max(ot,(yy[i]+zz[pos]) mod modul);\n until (pos<=0)or(yy[i]+zz[pos]=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do yy[i]:=a[i]; num1:=num;\n\n { writeln(num1); for i:=1 to num1 do write(yy[i],' '); writeln;\n }\n\n num:=0;\n for mask:=0 to pp-1 do\n begin\n q:=mask;\n sum:=0;\n for i:=1 to tt do begin x[i]:=q and 1; q:=q shr 1; end;\n for i:=1 to tt do sum:=sum+x[i]*z[nn-i+1];\n inc(num); y[num]:=sum mod modul;\n\n end;\n\n { for i:=1 to num do write(y[i],' ');\n } for i:=1 to num do a[i]:=y[i];\n n:=1; repeat n:=n*2 until(n>=num);\n for i:=1+num to n do a[i]:=besk;\n sort(a);\n for i:=1 to num do zz[i]:=a[i]; num2:=num;\n\n { writeln(num2); for i:=1 to num2 do write(zz[i],' ');writeln;\n }\n pos:=num2;\n for i:=1 to num1 do\n begin\n if yy[i]+zz[pos]>=modul then\n repeat ot:=max(ot,(yy[i]+zz[pos]) mod modul); dec(pos);\n { writeln('i= ',i,' pos= ',pos,' sum= ',(yy[i]+zz[pos]) mod modul); }\n until (pos<=0)or(yy[i]+zz[pos]mid do dec(J);\n if not(I>j) then\n begin\n swap(f[i],f[j]);\n inc(i);\n dec(j);\n end;\n until I>j;\n if i=x) then exit(f[mid]);\n if (f[mid]>=x) then r:=mid-1;\n if (f[mid]r;\n exit(0);\nend;\nprocedure xulinghiem;\nvar i:longint;s:int64; tam:int64;\nbegin\n s:=0;\n for i:=mm to n do\n begin\n if x[i]=1 then s:=(s+a[i]) mod m;\n end;\n tam:=find(1,cnt,m-s);\n if s+tam>res then res:=s+tam;\nend;\nprocedure vet2(i:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i=n then xulinghiem else vet2(i+1);\n end;\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n vet1(1);\n qs(1,cnt);\n vet2(mm);\n writeln(res);\nend;\nbegin\n // mo;\n nhap;\n xuli;\n // dong;\nend.\n"}, {"source_code": "var n,nn,mm:longint;\ncnt:longint;\nm:int64;\na,x:array[0..40] of int64;\nf:array[0..1000005] of int64;\nres:int64;\nprocedure mo;\nbegin\n assign(input,'test.inp');reset(input);\n assign(output,'test.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(output);\nend;\nprocedure nhap;\nvar i:longint;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n read(a[i]);\n a[i]:=a[i] mod m;\n end;\n nn:=(n+1) div 2;\n mm:=nn+1;\nend;\nprocedure luunghiem;\nvar i:longint;\nbegin\n inc(cnt);\n for i:=1 to nn do\n begin\n if x[i]=1 then f[cnt]:=(f[cnt]+a[i]) mod m;\n end;\nend;\nprocedure vet1(i:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i=nn then luunghiem else vet1(i+1);\n end;\nend;\nprocedure swap(var x,y:int64);\nvar t:int64;\nbegin\n t:=x;\n x:=y;\n y:=t;\nend;\nprocedure qs(l,r:longint);\nvar i:longint; j,mid:longint;\nbegin\n i:=l;\n j:=r;\n mid:=f[l+random(r-l+1)];\n repeat\n while f[i]mid do dec(J);\n if not(I>j) then\n begin\n swap(f[i],f[j]);\n inc(i);\n dec(j);\n end;\n until I>j;\n if ix) then exit(f[mid]);\n if (f[mid]>x) then r:=mid-1;\n if (f[mid]<=x) and (f[mid+1]<=x) then l:=mid+1;\n until l>r;\n exit(0);\nend;\nprocedure xulinghiem;\nvar i:longint;s:int64; tam:int64;\nbegin\n s:=0;\n for i:=mm to n do\n begin\n if x[i]=1 then s:=(s+a[i]) mod m;\n end;\n tam:=find(1,cnt,m-s-1);\n if s+tam>res then res:=s+tam;\nend;\nprocedure vet2(i:longint);\nvar j:longint;\nbegin\n for j:=0 to 1 do\n begin\n x[i]:=j;\n if i=n then xulinghiem else vet2(i+1);\n end;\nend;\nprocedure xuli;\nvar i:longint;\nbegin\n vet1(1);\n qs(1,cnt);\n vet2(mm);\n writeln(res);\nend;\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend.\n"}, {"source_code": "uses math;\nconst fi='888E.inp';\n fo='888E.out';\nvar a,f:array[0..1000000] of longint;\n n,du,nn,dem,kq:longint;\n s:int64;\nprocedure ran;\n var i:longint;\n begin\n readln(n,du);\n for i:=1 to n do read(a[i]);\n nn:=n div 2;\n end;\nprocedure haibara;\n begin\n inc(dem);\n f[dem]:=s mod du;\n end;\nprocedure conan(i:longint);\n var j:longint;\n begin\n for j:=0 to 1 do\n begin\n if j=1 then s:=s+a[j];\n if i=nn then haibara else conan(i+1);\n if j=1 then s:=s-a[j];\n end;\n end;\nfunction tnp(l,r,x:longint):longint;\n var g,k:longint;\n begin\n while l<=r do\n begin\n g:=(l+r) div 2;\n if f[g] > x then r:=g-1 else\n begin\n k:=f[g];\n l:=g+1;\n end;\n end;\n exit(k);\n end;\n\nprocedure ai;\n var j,t:longint;\n begin\n t:=s mod du;\n kq:=max(kq,t+tnp(1,dem,du-1-t));\n end;\nprocedure tm(i:longint);\n var j:longint;\n begin\n for j:=0 to 1 do\n begin\n if j=1 then s:=s+a[j];\n if i=n then ai else tm(i+1);\n if j=1 then s:=s-a[j];\n end;\n end;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=f[(l+r) div 2];\n repeat\n while f[i]j) then\n begin\n y:=f[i];\n f[i]:=f[j];\n f[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lb then exit(a) else exit(b);\n end;\n\nprocedure vet(i,n,k:longint);\n var j:longint;\n begin\n if i=n+1 then\n begin\n inc(top[k]);\n stk[top[k],k]:=ans mod du;\n exit;\n end;\n for j:=0 to 1 do\n begin\n ans:=ans+a[i]*j;\n vet(i+1,n,k);\n ans:=ans-a[i]*j;\n end;\n end;\n\nprocedure sort(l,r,k:longint);\n var i,j,m,t,tam:longint;\n begin\n i:=l;\n j:=r;\n m:=random(r-l)+l+1;\n t:=stk[m,k];\n repeat\n while t>stk[i,k] do inc(i);\n while tj) then\n begin\n tam:=stk[i,k];\n stk[i,k]:=stk[j,k];\n stk[j,k]:=tam;\n inc(i);\n dec(j);\n end;\n until i>j;\n if lans then r:=mid-1 else\n begin\n res:=stk[mid,1];\n l:=mid+1;\n end;\n end;\n if res=-1 then continue;\n kq:=max(kq,res+stk[i,0]);\n end;\nwriteln(kq);\nend.\n\n"}, {"source_code": "var stk:array[0..200009,0..1] of longint;\n a,top:array[0..200009] of longint;\n res,l,r,mid,n,m,i,du,kq:longint;\n ans:int64; \n\nfunction max(a,b:longint):longint;\n begin\n if a>b then exit(a) else exit(b);\n end;\n\nprocedure vet(i,n,k:longint);\n var j:longint;\n begin\n if i=n+1 then\n begin\n inc(top[k]);\n stk[top[k],k]:=ans mod du;\n exit;\n end;\n for j:=0 to 1 do\n begin\n ans:=ans+a[i]*j;\n vet(i+1,n,k);\n ans:=ans-a[i]*j;\n end;\n end;\n\nprocedure sort(l,r,k:longint);\n var i,j,m,t,tam:longint;\n begin\n i:=l;\n j:=r;\n m:=random(r-l)+l+1;\n t:=stk[m,k];\n repeat\n while t>stk[i,k] do inc(i);\n while tj) then\n begin\n tam:=stk[i,k];\n stk[i,k]:=stk[j,k];\n stk[j,k]:=tam;\n inc(i);\n dec(j);\n end;\n until i>j;\n if lans then r:=mid-1 else\n begin\n res:=stk[mid,1];\n l:=mid+1;\n end;\n end;\n if res=-1 then continue;\n kq:=max(kq,res+stk[i,0]);\n end;\nwriteln(kq);\nend.\n\n"}, {"source_code": "Program _888_E;\nuses math;\nconst finput='888_E.inp';\n foutput='888_E.out';\n MaxN=10000000;\nvar a,f,p:array[0..MaXN] of longint;\n n,q,res:longint;\n\nProcedure Nhap;\nvar i:longint;\nbegin\n // assign(input,finput);reset(input);\n // assign(output,foutput);rewrite(output);\n read(n,q);\n for i:=1 to n do\n read(a[i]);\nend;\n\nFunction getbit(x,i:longint):longint;\nbegin\n exit(1 and (x shr (i-1)));\nend;\n\nProcedure Cre_state;\nvar s,j:longint;\nbegin\n for s:=0 to 1 shl (n div 2)-1 do\n begin\n for j:=1 to n div 2 do\n if getbit(s,j)=1 then\n f[s]:=f[s]+a[j];\n f[s]:=f[s] mod q;\n end;\n for s:=0 to 1 shl (n-(n div 2))-1 do\n begin\n for j:=1 to n-(n div 2) do\n if getbit(s,j)=1 then\n p[s]:=p[s]+a[j+n div 2];\n p[s]:=p[s] mod q;\n end;\nend;\n\nProcedure Sort(l,r:longint);\nvar i,j,mid,tmp:longint;\nbegin\n i:=l;\n j:=r;\n mid:=p[l+random(r-l+1)];\n repeat\n while p[i]mid do dec(j);\n if i<=j then\n begin\n tmp:=p[i];\n p[i]:=p[j];\n p[j]:=tmp;\n inc(i);\n dec(j);\n end;\n until i>j;\n if il then Sort(l,j);\nend;\n\nfunction find(x:longint):longint;\nvar l,r,mid,temp:longint;\nbegin\n l:=0;\n r:=1 shl(n-n div 2)-1;\n temp:=-1;\n repeat\n mid:=(l+r) div 2;\n if p[mid]r;\n exit(temp);\nend;\n\nProcedure Xuli;\nvar s,k:longint;\nbegin\n Cre_State;\n sort(1,1 shl (n-n div 2)-1);\n for s:=0 to 1 shl (n div 2)-1 do\n begin\n {if f[s]=q then k:=find(q-1)\n else }\n k:=find(q-f[s]);\n if k<>-1 then\n res:=max(res,f[s]+p[k]);\n end;\nend;\nbegin\n Nhap;\n Xuli;\n write(res);\nend."}], "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a"} {"source_code": "\n const eps=0.0000000001; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var t,tt,p,time,pp,jj,gr,qq,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;\n step, k,i,j:longint;\n aa,bb,cc:int64;\n aold,b,a,x,y:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..200000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{function degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n }\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n); for i:=1 to n do read(a[i]);\n ot:=0;\n for i:=1 to n do ot:=max(ot,a[i]);\n p:=ot-25;\n writeln(max(p,0));\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "var\n k,i,r,max:longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n if max<25 then max:=25;\n writeln(max-25);\n end.\n \n //Fredericksburg"}, {"source_code": "var\n i,n,max,x:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x>max then max:=x;\n end;\n if max<25 then write(0) else write(max-25);\nend."}, {"source_code": "uses math;\n\nvar i, k, r, ans: longint;\n\nbegin\n readln(k);\n ans := 25;\n for i := 1 to k do\n begin\n read(r);\n ans := max(ans, r);\n end;\n writeln(ans - 25);\nend."}, {"source_code": "var\nk,t,i,r:longint;\nbegin\nreadln(k); i:=0;\nfor t:=1 to k do\nbegin read(r);\nif r>i then\ni:=r; end;\nif i<=25 then write('0')\nelse write(i-25); end."}, {"source_code": "var\n i,n,max:longint; \n a:array[1..1000000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n max:=a[1];\n for i:=2 to n do if a[i]>max then \n max:=a[i];\n if max<25 then write(0)\n else write(max-25);\nend."}, {"source_code": "var\n n,i,x,max:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x>max then max:=x;\n end;\n if max>25 then writeln(max-25)\n else writeln(0);\nend."}, {"source_code": "var\n n,i,a,max:longint;\nbegin\n read(n);\n max:=0;\n for i:=1 to n do\n begin\n read(a);\n if max25 then writeln(max-25)\n else writeln(0);\nend."}, {"source_code": "var\n i,n,max:longint; \n a:array[1..1000000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n max:=a[1];\n for i:=2 to n do if a[i]>max then \n max:=a[i];\n if max<25 then write(0)\n else write(max-25);\nend."}, {"source_code": "var n,i,q,max:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(q);\n if q>max then max:=q;\n end;\nif max<25 then max:=25;\nwriteln(max-25);\nend."}, {"source_code": "var k,x,m:longint;\nbegin\n readln(k);\n for k:=1 to k do\n begin\n read(x);\n if x>m then m:=x;\n end;\n if m<25 then\n writeln(0)\n else\n writeln(m-25);\nend."}, {"source_code": "// luogu-judger-enable-o2\nvar n,x,m,i:longint;\n\n\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a) else exit(b);\nend;\n\n\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n m:=max(x,m);\n end;\n writeln(max(0,m-25));\nend."}, {"source_code": "var\n n,max,i,x:longint;\nbegin\n readln(n);\n max:=-maxlongint;\n for i:=1 to n do begin read(x);if x>max then max:=x; end;\n if max<25 then begin writeln(0);halt; end;\n writeln(max-25);\nend."}, {"source_code": "var\n k,i,r,max: longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n if max<25 then max:=25;\n writeln(max-25);\n end."}, {"source_code": "var\n k,i,r,max:longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n if max<25 then write(0)\n else write(max-25);\nend."}, {"source_code": "var n,o,i,max:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(o);\nif o>max then max:=o;\nend;\nif max>25 then writeln(max-25)\nelse writeln(0);\nend."}, {"source_code": "uses math;\n\tvar n,i,l,m,x,j,kq,o: longint; a: array[1..1010] of longint;\n\tprocedure sort(i,j: longint);\n\t\tvar l,m,y: longint;\n\t\tbegin\n\t\tl:=i;\n\t\tj:=m;\n\t\tx:=a[(l+j) div 2];\n\t\trepeat\n\t\twhile a[i]x do dec(j);\n\t\tif ij;\n\t\t begin\n\t\t if il then sort(l,m);\n\t\t end;\n end;\n\tbegin\n\t\tread(n);\n\t\tfor i:=1 to n do begin\n\t\tread(o);\n\t\tkq:=max(kq, o-25);\n\t\tend;\n\t\twriteln(kq);\n\n\tend."}, {"source_code": "uses math; var n,i,kq,o: integer; begin read(n); for i:=1 to n do begin read(o); kq:=max(kq,o-25); end;\nwrite(kq);\nend."}, {"source_code": "var n,i,m,c:longint;\nBegin\n readln(n);\n for i:=1 to n do\n Begin\n read(c);if(c>m) then m:=c;\n end;\n if(m<25) then writeln(0) else writeln(m-25);\nend."}, {"source_code": "var k,i,max:longint;\n a:array[1..25] of longint;\n\nbegin\n//assign(input,'a.inp');reset(input);\n//assign(output,'a.out');rewrite(output);\nreadln(k);\nmax:=0;\nfor i:=1 to k do read(a[i]);\nfor i:=1 to k do\n IF a[i]>max then max:=a[i];\nIF max-25<0 then write(0) else write(max-25); \nreadln;\nend."}, {"source_code": "var\ni:longint;\nmax,x,kol,ans,n,d:int64;\na:array[-100..1000000]of int64;\nbegin\nreadln(n);\n\n\nfor i:=1 to n do begin\n read(x);\n a[x]:=1;\n if x>max then max:=x;\nend;\nkol:=25-n;\nfor i:=1 to max do begin\nif a[i]=0 then begin\n if kol>0 then dec(kol)\n else\n inc(ans);\nend;\nend;\nwriteln(ans);\nend."}, {"source_code": "var n,k,i,max: longint;\nbegin\n readln(n);\n max:=0;\n for i:= 1 to n do begin\n read(k);\n if k>max then max:=k;\n end;\n if max<=25 then write(0) else write(max-25);\nend.\n"}, {"source_code": "var\n\tn, h, m, r, x, sum, y: integer;\n\ta: array of integer;\n\t\nbegin\n\n\treadln(n);\n\tSetLength(a, n);\n\t\n\tfor var i := 0 to n - 1 do\n\tbegin\n\t\tread(a[i]);\n\tend;\n\t\n\tSort(a);\n\tif (a[a.length-1] <= 25) then\n\t\twriteln(0)\n\telse\n\t\twriteln(a[a.length-1] - 25);\n\t\n\t\nend.\n"}, {"source_code": "Var\n K, max, num: UInt64;\n\nBegin\n Read(K);\n For Var i := 1 to K do Begin\n Read(num);\n If num > max then\n max := num\n End;\n If max <= 25 then\n Write(0)\n Else\n Write(max - 25)\nEnd."}, {"source_code": "program final;\nvar i,j,k,a,o,s:Integer;\n r:array[1..25] of Integer;\nbegin\n readln(k);\n for i:=1 to k do\n read(r[i]);\n o:=1;\n for j:=1 to k-1 do\n for i:=1 to k-1 do\n while r[i]>r[i+1] do\n begin\n a:=r[i];\n r[i]:=r[i+1];\n r[i+1]:=a;\n end;\n for i:=1 to k do\n if r[k]>25 then\n a:=i\n else\n a:=0;\n if a>0 then writeln(r[k]-25);\n if a<=0 then writeln(0);\nend."}, {"source_code": "var n,i,max,s:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(s);\n if s>max then max:=s;\n end;\n if max>25 then writeln(max-25) else writeln('0');\nend."}, {"source_code": "var\nk,max,nol,i:integer;\nr:array[1..1000000]of integer;\nbegin\nreadln(k);\nmax:=0;\nnol:=0;\nfor i:=1 to k do\nbegin\nread(r[i]);\nif maxmax then max:=a;\n end;\n if max-25>=0 then write(max-25)\n else write(0);\nend."}, {"source_code": "\n var n,i,m:longint;\n a:array[1..25] of longint;\n\nbegin\nreadln(n);\nm:=0;\nfor i:=1 to n do \n begin\n read(a[i]);\n IF a[i]>m then m:=a[i];\n end;\nm:=m-25;\nIF m<0 then write(0) else write(m);\nreadln;\nend."}, {"source_code": "// luogu-judger-enable-o2\nvar\n k,i,r,max:longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n readln;\n if max<25 then max:=25;\n writeln(max-25);\n end.\n{\nI AK IOI!!!\n}"}, {"source_code": "//abcdefghijklmnopqrstuvwxyz\nvar\na,c,i,n:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n read(a);\n if a>C then c:=a;\n end;\nif c>25 \n then writeln(c-25)\n else writeln(0);\nend."}, {"source_code": "var\n i,k:byte;\n\n a:array [1..25] of longint;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l 25 then writeln(a[k] -25)\n else Writeln(0);\nend.\n"}, {"source_code": "var n,a,max:int64;\n i:cardinal;\nbegin\n readln(n);\n max:=0;\n for i:=1 to n do\n begin\n read(a);\n if a>max then max:=a;\n end;\n if max-25>0 then write(max-25)\n else write(0);\nend."}, {"source_code": "var a:array[1..1000000] of longint;\ni,n,x,b,s,k,max:longint;\nbegin\nread(n);\nmax:=0;\nfor i:=1 to n do begin \nread(x);\na[x]:=1;\nif x>max then max:=x;\nif x>25 then k:=1;\nend;\nif k=0 then begin writeln('0'); halt; end else\nfor i:=1 to max do \nif a[i]=0 then inc(s);\nwriteln(s-25+n); \nend."}, {"source_code": "var\na:array[1..1000000]of integer;\ni,j,n,t:integer;\nbegin\nread(n);\nfor i:=1 to n do read(a[i]);\nfor j:=1 to n-1 do\nfor i:=1 to n-j do\nif a[i] > a[i+1] then\nbegin\nt:=a[i];\na[i]:=a[i+1];\na[i+1]:=t;\nend;\n\n\nif a[n]>25 then\nwrite(a[n]-25)\nelse write(0);\nend."}, {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n n,o,i,kq:integer;\n\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(o);\n kq:=max(kq,o-25);\n end;\n write(kq);\nend.\n"}, {"source_code": "var\n max,a,n,i:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a); \n if a>max then max:=a;\n end;\n if max>25 then write(max-25)\n else write(0);\nend."}, {"source_code": "var\nn,i,x,max:longint;\nbegin\nreadln(n);\nmax:=-maxlongint;\nfor i:=1 to n do\n begin\n read(x);\n if x>max then max:=x;\n end;\nif max>25 then writeln(max-25)\n else writeln(0);\nend."}, {"source_code": "var\n i,n,max:longint; \n a:array[1..1000000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n max:=a[1];\n for i:=2 to n do if a[i]>max then \n max:=a[i];\n if max<25 then write(0)\n else write(max-25);\nend."}, {"source_code": "var n,i,max,s:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(s);\n if s>max then max:=s;\n end;\n if max>25 then writeln(max-25) else writeln('0');\nend."}, {"source_code": "var\n n,i,x,y:longint;\nbegin\n readln(n);\n for i:=1 to n do \n begin\n read(x);\n if x>y then y:=x;\n end;\n if y-25<0 then writeln(0)\n else writeln(y-25);\nend."}, {"source_code": "var\n i,n,max:longint; \n a:array[1..1000000] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n max:=a[1];\n for i:=2 to n do if a[i]>max then \n max:=a[i];\n if max<25 then write(0)\n else write(max-25);\nend."}, {"source_code": "var\nn,a,max,i:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nread(a); \nif a>max then max:=a;\nend;\n if max-25>0 then write(max-25)\n else write(0);\n end."}, {"source_code": "var\n k,i,r,max:longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n if max<25 then max:=25;\n writeln(max-25);\n end."}, {"source_code": "var\n n,max,i,x:longint;\nbegin\n readln(n);\n max:=-maxlongint;\n for i:=1 to n do begin read(x);if x>max then max:=x;end;\n if max<25 then begin writeln(0);halt;end;\n writeln(max-25);\nend."}, {"source_code": "Program CHUNGKET;\nConst fin ='';\n fout='';\nVar i,n,a,d:Longint;\n f:Text;\nBegin\n Assign(f,fin);\n Reset(f);\n Readln(f,n);\n d:=0;\n For i:=1 to n do\n Begin\n Read(f,a);\n If d=25 then d:=d-25\n Else d:=0;\n Write(f,d);\n Close(f);\nEnd.\n\n"}, {"source_code": "Var i , max , n , tmp : Longint;\nBegin\nReadln(n);\nFor i := 1 to n do \n Begin\n Read(tmp);\n If tmp > max then max := tmp;\n End;\nIf max <= 25 then Writeln('0') else Writeln(max - 25);\nEnd."}, {"source_code": "Program z1;\nvar k,i,j:integer;\n r:array[1..25]of longint;\nbegin\nreadln(k);\nfor i:=1 to k do read(r[i]);\nj:=r[1];\nfor i:=2 to k do\nif r[i]>j then j:=r[i];\nif j>25 then j:=j-25\n else j:=0;\nwrite(j);\nend."}, {"source_code": "var\na:array[1..25]of integer;\nk,i,max,v:integer;\n\nbegin\nread(k);\nfor i:=1 to k do\nread(a[i]);\nfor i:=1 to k do\nif max=0 then\nv:=max-25\nelse\nv:=0;\nwrite(v);\nend."}, {"source_code": "var\n n,i,x,max:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x>max then max:=x;\n end;\n if max<25 then writeln(0)else\n writeln(max-25);\nend."}, {"source_code": "uses math;\ntype\n qtr=-2147483648..2147483647;\nvar\n i,n,rui,shg:qtr;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(rui);\n shg:=max(rui,shg);\n end;\n writeln(max(shg-25,0));\nend."}], "negative_code": [{"source_code": "var n,o,i,max:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nbegin\nreadln(o);\nif o>max then max:=o;\nend;\nif max>25 then writeln(max-25)\nelse writeln(0);\nend."}, {"source_code": "uses math;\n\tvar n,i,l,m,x,j,kq,o: longint; a: array[1..1010] of longint;\n\tprocedure sort(i,j: longint);\n\t\tvar l,m,y: longint;\n\t\tbegin\n\t\tl:=i;\n\t\tj:=m;\n\t\tx:=a[(l+j) div 2];\n\t\trepeat\n\t\twhile a[i]x do dec(j);\n\t\tif ij;\n\t\t begin\n\t\t if il then sort(l,m);\n\t\t end;\n end;\n\tbegin\n\t\tread(n);\n\t\tfor i:=1 to n do\n\t\tread(o);\n\t\tkq:=max(kq, o-25);\n\t\twriteln(kq);\n\n\tend."}, {"source_code": "\tuses math;\n\tvar n,i,l,m,x,j,kq,o: longint; a: array[1..1010] of longint;\n\tprocedure sort(i,j: integer);\n\t\tvar l,m,y: integer;\n\t\tbegin\n\t\tl:=i;\n\t\tj:=m;\n\t\tx:=a[(l+j) div 2];\n\t\trepeat\n\t\twhile a[i]x do dec(j);\n\t\tif ij;\n\t\t begin\n\t\t if il then sort(l,m);\n\t\t end;\n end;\n\tbegin\n\t\tread(n);\n\t\tfor i:=1 to n do\n\t\tread(o);\n\t\tkq:=max(kq, o-25);\n\n\tend.\n"}, {"source_code": "uses math;\nvar \nn,i,kq,o: integer;\nbegin\nread(n);\nfor i:=1 to n do\n begin\n read(o);\n kq:=max(o,o-25);\n end;\n write(kq);\nend."}, {"source_code": "\tuses math;\n\tvar n,i,l,m,x,j,kq,o: longint; a: array[1..1010] of longint;\n\tprocedure sort(i,j: integer);\n\t\tvar l,m,y: integer;\n\t\tbegin\n\t\tl:=i;\n\t\tj:=m;\n\t\tx:=a[(l+j) div 2];\n\t\trepeat\n\t\twhile a[i]x do dec(j);\n\t\tif ij;\n\t\t begin\n\t\t if il then sort(l,m);\n\t\t end;\n end;\n\tbegin\n\t\tread(n);\n\t\tfor i:=1 to n do\n\t\tread(o);\n\t\tkq:=max(kq, o-25);\n\t\twriteln(kq);\n\n\tend.\n"}, {"source_code": "var k,i,max:longint;\n a:array[1..25] of longint;\n\nbegin\n//assign(input,'a.inp');reset(input);\n//assign(output,'a.out');rewrite(output);\nreadln(k);\nmax:=0;\nfor i:=1 to k do read(a[i]);\nfor i:=1 to k do\n IF a[i]>max then max:=a[i];\nwrite(max-25); \nreadln;\nend."}, {"source_code": "var n,a,max:int64;\n i:cardinal;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a);\n if a>max then max:=a;\n end;\n if max-25>0 then write(a-25)\n else write(0);\nend."}, {"source_code": "var i,n,a,max:integer;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(a);\n if a>max then max:=a;\n end;\n if max-25>0 then write(a-25)\n else write(0);\nend."}, {"source_code": "var n,i,q,max:longint;\nbegin\nreadln(n);\nfor i:=1 to n do\n begin\n readln(q);\n if q>max then max:=q;\n end;\nif max<25 then max:=25;\nwriteln(max-25);\nend."}, {"source_code": "var n,i,max,s:longint;\nbegin\n read(n);\n for i:=1 to n do\n begin\n read(s);\n if s>max then max:=s;\n end;\n writeln(max-25);\nend."}, {"source_code": "var\n n,i,a,max:longint;\nbegin\n read(n);\n max:=0;\n for i:=1 to n do\n begin\n read(a);\n if max25 then writeln(max-25)\n else writeln(max);\nend."}, {"source_code": "var\n k,i,r,max:longint;\nbegin\n readln(k);\n for i:=1 to k do\n begin\n read(r);\n if r>max then max:=r;\n end;\n if max<25 then write(0)\n else write('-25');\nend."}, {"source_code": "var\nn,a,max,i:longint;\nbegin\nread(n);\nfor i:=1 to n do\n if a>max then max:=a;\n if max-25>0 then write(max-25)\n else write(0);\n end."}, {"source_code": "var\n n,i,x,max:longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x>max then max:=x;\n end;\n if max<25 then writeln(25)else\n writeln(max-25);\nend."}], "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd"} {"source_code": "const fi='';\n fo='';\n maxn=20;\nvar res:longint;\n s:string;\n le:integer;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n\n\n readln(s);\n le:=length(s);\n\n writeln((le+1)*26-le);\n close(input);close(output);\nend.", "positive_code": [{"source_code": "var s: string;\nbegin\n readln(s);\n write((26*(length(s)+1))-length(s));\nend."}, {"source_code": "var a:string;\nbegin\n readln(a);\n writeln(26+(length(a)*25));\nend."}, {"source_code": "var a:string;\nk:integer;\nbegin\nread(a);\nk:=(length(a)+1)*26-length(a);\nwrite(k);\nend."}, {"source_code": "VAR s:string;\na,w:integer;\nbegin\nread(s);\na:=length(s);\nw:=(a+1)*26-a;\nwrite(w);\nend."}, {"source_code": "var\n s, ns: string;\n w: array [1 .. 1000] of string;\n wc, i, j: longint;\n c: char;\n\nbegin\n readln(s); wc := 0;\n for i := 1 to 1000 do w[i] := '.';\n for i := 1 to length(s) + 1 do\n for c := 'a' to 'z' do\n begin\n ns := s; Insert(c, ns, i);\n for j := 1 to wc + 1 do\n if w[j] = ns then break;\n if j = wc + 1\n then begin\n inc(wc);\n w[wc] := ns;\n end;\n end;\n writeln(wc);\nend."}, {"source_code": "Var s:string;\n res:longint;\nProcedure print;\nBegin\n Write(res);\nEnd;\n\nProcedure sol;\nBegin\n res:=26+25*length(s);\nENd;\n\nProcedure init;\nBegin\n Read(s);\nENd;\n\nBEGIN\n init;\n sol;\n print;\nEND.\n\n"}, {"source_code": "Var s:string;\nt, x, ans:longint;\nBegin\nRead(s);\nWriteLn(25*(Length(s)+1)+1);\nEnd."}, {"source_code": "var s:string;\n n:longint;\nbegin\n read(s);\n n:=length(s);\n write((n+1)*26-n);\nend."}, {"source_code": "var st: string;\nbegin\n readln(st);\n write((length(st)+1)*25+1);\nend."}, {"source_code": "var\n st:string;\nbegin\n readln(st);\n write(25*length(st)+26)\nend."}, {"source_code": "var i,j,kol:integer;\ns,str:string;\nbegin\nreadln(s);\nkol:=0;\nstr:='';\nfor i:=1 to length(s)+1 do\n for j:=97 to 122 do\n begin\n Insert(chr(j),s,i);\n if pos(s,str)=0 then \n begin\n str:=str+s+' ';\n inc(kol);\n \n end;\n Delete(s,i,1);\n end;\nwriteln(kol);\n\nend."}, {"source_code": "Var s : String;\n tmp : Longint;\n \nBegin\nReadln(S);\ntmp := Length(S);\nWriteln(25 * (tmp + 1) + 1);\nEnd."}, {"source_code": "var\n s:string;\n i,j,y,x1,x2,y1,y2,n,ans,k,t,c,a,b,r:longint;\nbegin\n readln(s);\n n:=length(s);\n ans:=(n+1)*26-n;\n writeln(ans);\n\n\n\n end.\n\n"}, {"source_code": "Program _554A;\nvar\n s : string;\n i : longint;\n kol : int64;\nbegin\n read(s);\n kol := 26;\n for i := 1 to Length(s) do\n kol := kol + 25;\n write(kol); \nend.\n{\n26 25 25 25 25\n a a b c\n}\n "}, {"source_code": "var s:string;\n a:array[1..1000] of longint;\n i,j,k,l,m,n:longint;\nbegin\nreadln(s);\nwriteln(length(s)*25+26);\nend."}, {"source_code": "var\n s : string;\n n : longint;\n res : int64;\nprocedure nhap;\nbegin\n readln(s);\nend;\nprocedure solve;\nbegin\n n := length(s);\n res := (n + 1) * 26 - n;\n writeln(res);\nend;\n\nbegin\n //assign(input,'554A.INP'); reset(input);\n //assign(output,'554A.OUT'); rewrite(output);\n nhap;\n solve;\nend.\n"}, {"source_code": "var\n s : string;\n n,n1,i : longint;\n res,tmp : int64;\n count : array[97..122] of longint;\nprocedure nhap;\nbegin\n readln(s);\nend;\nprocedure solve;\nbegin\n fillchar(count,sizeof(count),0);\n n := length(s);\n tmp := 0;\n for i := 1 to n do\n inc(count[ord(s[i])]);\n\n for i := 97 to 122 do\n if count[i] > 0 then\n tmp := tmp + (count[i] - 0);\n\n n1 := n + 1;\n\n res := n1 * 26 - tmp;\n writeln(res);\nend;\n\nbegin\n //assign(input,'554A.INP'); reset(input);\n //assign(output,'554A.OUT'); rewrite(output);\n nhap;\n solve;\nend.\n"}, {"source_code": "var k,i,la:integer;\na:string;\nbegin\n read(a); la:=length(a);\n k:=0;\n for i:=1 to 26 do\n begin\n k:=k+la+1;\n end;\n writeln(k-la);\nend."}, {"source_code": "var\n s:string;\n l:longint;\nbegin\n read(s);\n l:=length(s);\n writeln(l*l+(l+1)*(26-l))\nend.\n"}, {"source_code": "program a;\nvar s:ansistring;\nbegin\n readln(s);\n writeln((length(s)+1)*26-length(s));\nend. \n"}, {"source_code": "program ex;\nvar s:string;\nbegin\nread(s);\nwriteln(length(s)*25+26);\nend."}, {"source_code": "var\n i:char;\n s:string;\n j,n,m,l,k:longint;\nbegin\n readln(s);\n for i:='a' to 'z' do \n begin\n for j:=1 to length(s)+1 do\n begin\n if s[j]<>i then inc(l); \n { if (s[j]=s[j+1])and(s[j]=i) then else inc(l);\n }end;\n end;\n writeln(l-k);\nend."}, {"source_code": "var s:string;\nbegin\nread(s);\nwrite((length(s)+1)*26-length(s));\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n s: string;\n res: qword;\n\nbegin\n readln(s);\n res := qword(26) * (length(s) + 1) - length(s);\n write(res);\nend.\n\n\n\n{$MODE OBJFPC}\nuses math;\nvar\n s: array[1..100] of string;\n ok: array[1..100] of boolean;\n n, res: integer;\n a: array[1..100] of integer;\n i, j: integer;\n\nbegin\n fillchar(a,sizeof(a),0);\n fillchar(ok,sizeof(ok),true);\n readln(n);\n for i := 1 to n do readln(s[i]);\n for i := 1 to n - 1 do begin\n for j := i + 1 to n do\n if (ok[i]) and (ok[j]) and (s[i] = s[j]) then begin\n inc(a[i]);\n ok[j] := false;\n end;\n ok[i] := false;\n end;\n// for i := 1 to n do writeln(a[i]);\n res := 0;\n for i := 1 to n do res := max(res,a[i] + 1);\n write(res);\nend.\n"}, {"source_code": "program yan;\n var ar:array['a'..'z']of longint;\n i,x,ans:longint; s:string; c,j:char;\nbegin\n read(s);\n for i:=1 to length(s) do inc(ar[s[i]]);\n for c:='a' to 'z' do\n begin\n for j:='a' to 'z' do\n if c<>j then ans:=ans+ar[j];\n inc(ans);\n end;\n write(ans);\nend.\n"}, {"source_code": "var\n n:string;\nbegin\n readln(n);\n writeln(length(n)*25+26);\nend."}, {"source_code": "var\n S:String;\n L,answer:Longint;\nbegin\n Readln(S);\n L:=Length(S);\n L:=L+1;\n answer:=L*26;\n answer:=answer-L+1;\n Writeln(answer);\n end."}, {"source_code": "var\na:string;\nbegin\nreadln(a);\nwriteln((length(a)+1)*26-length(a));\nend."}, {"source_code": "var\n\tn, c: int64;\n\ts: string;\n\ta: array[97..122] of integer;\n\t\nbegin\n\t\n\treadln(s);\n\twriteln((s.length+1)*26 - s.length);\n\t\n\t\nend.\n"}, {"source_code": "var\n s:string;\n t,i:longint;\n z:char;\nbegin\n readln(s);\n t:=26;\n z:=s[1];\n for i:=1 to length(s) do\n begin\n if s[i]=z then t:=t+25\n else t:=t+26;\n if i<=length(s) then z:=s[i+1];\n end;\n writeln(t);\nend."}, {"source_code": "Var\n n: String;\n \nBegin\n Readln(n);\n Write(26 + 25*Length(n))\nEnd."}, {"source_code": "var\n s:string;\nbegin\n readln(s);\n write(26*(length(s)+1)-length(s));\nend."}, {"source_code": "var\n s: string;\nbegin\n readln(S);\n writeln((length(s)+1)*26-length(s))\nend."}, {"source_code": "var s:string;\nbegin\n readln(s);\n writeln(26*(length(s)+1)-length(s));\nend."}, {"source_code": "var\n s : string ;\n n,x : longint ;\n\nbegin\n readln (s) ;\n x := length(s) ;\n n := ((x+1) * 25) + 1 ;\n writeln (n) ;\nend."}, {"source_code": "var n:longint;\n S:string;\n begin\n readln(S);\n n:=length(S);\n write(26*(n+1)-n);\n end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s:string;\n i,l,c:integer;\nbegin\n read(s);\n c:=0;\n l:=length(s);\n for i:=2 to l do\n if s[i]=s[i-1] then c := c+1;\n write(26*(l+1)-l);\n readln;readln;\nend.\n"}, {"source_code": "var a,b:longint;\n s:string;\nbegin\nreadln(s);\na:=length(s);\nb:=a*25+26;\nwriteln(b);\nend."}, {"source_code": "uses math;\nvar\n s : string;\nbegin\n readln(s);\n writeln(26 + length(s) * 25);\nend. \n"}, {"source_code": "program A_554;\n\nvar\n s:string;\n n:longint;\n\nbegin\n read(s);\n n:=length(s);\n write(25*n+26);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[x],qc[q]);\n ass:=true;\n for h:=q to c do if qc[h]<>qc[q] then ass:=false;\n if ass then exit; \n h:=q; e:=c;\n while h>1];\n repeat\n while a[i]x do dec(j);\n if i<=j then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i); dec(j);\n end;\n until i>j;\n if ia[i-1] then inc(res);\n writeln(Res);\n readln;\nend.\n"}, {"source_code": "program codeforces_round309_a;\n\nvar\n s : array[0..100000] of string;\n l, i, j, k, f, p, a : longint;\n\nbegin\n read(s[0]);\n l:=length(s[0]);\n for i:=1 to l + 1 do\n begin\n for k:=1 to 26 do\n begin\n insert(chr(96 + k), s[0], i);\n f:=0;\n for j:=1 to p do\n if s[0] = s[j]\n then begin\n f:=1;\n break;\n end;\n if f = 0\n then a:=a + 1;\n p:=p + 1;\n s[p]:=s[0];\n delete(s[0], i, 1);\n end;\n end;\n write(a);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n s: ansistring;\nbegin\n readln(s);\n writeln((length(s) + 1) * 26 - length(s));\nend."}, {"source_code": "Program KyoyaandPhotobook;\nVar\n S: string;\n\nBegin\n readln(S);\n writeln((length(S)+1)*26-length(S));\nEnd."}, {"source_code": "program jk;\nvar s:string;\n l,ans:longint;\nbegin\n readln(s);\n l:=length(s);\n ans:=(l+1)*26-l;\n writeln(ans);\nend."}, {"source_code": "var\n s:string;\n len,ans:longint;\nbegin\n readln(s);\n len:=length(s);\n ans:=(len+1)*26-len;\n writeln(ans);\nend."}, {"source_code": "var s:string;\nbegin\n read(s);\n write(26*(length(s)+1)-length(s));\nend."}, {"source_code": "var su,k:int64;i:longint;s:string;\nm:array [0..100] of longint;\nbegin\n readln(s);\n k:=1;\n for I:=1 to length(s) do\n if i=length(s) then\n begin\n if m[i]<1 then m[i]:=25\n else dec(m[i]);\n m[i+1]:=26;\n end\n else\n if m[i]<1 then m[i]:=25\n else dec(m[i]);\n for i:=1 to length(s)+1 do\n su:=su+m[i];\n writeln(su);\nend."}, {"source_code": "var s:string;\n i:integer;\n c:char;\n reS:int64;\nbegin\n readln(s);\n reS:=1;\n for c:='a' to 'z' do\n begin\n inc(res);\n for i:=1 to length(s) do\n if(c<>s[i])then inc(res);\n end;\n reS:=res-1;\n writeln(res);\nend."}, {"source_code": "var s:string;\n i,ans,l:longint;\nbegin\nreadln(s);\nl:=length(s);\nans:=(l+1)*26-l;\nwriteln(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s:string;\nbegin\n read(s);\n write(26+length(s)*25);\nend.\n "}, {"source_code": "var s:string;\nbegin\n readln(s);\n write((length(s)+1)*25+1);\nend."}, {"source_code": "program milenka;\nvar\n s:ansistring;\nbegin\n readln(s);\n writeln(25*length(s)+26);\nend."}, {"source_code": "var\n s:ansistring;\n ans,i:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n ans:=ans+25;\n writeln(ans+26);\nend.\n"}, {"source_code": "var s : string;\n Begin\n readln(s);\n writeln(26 * (length(s) + 1) - length(s));\n end."}, {"source_code": "const fi = '';\n fo = '';\nvar s, t: string;\n i, j, n, cnt: longint;\n p: array [1..100000] of string;\n c: char;\n ok: boolean;\n\nbegin\n assign(input, fi); reset(input);\n assign(output, fo); rewrite(output);\n\n readln(s);\n n:=length(s);\n\n cnt:=0;\n for i:=1 to n+1 do\n for c:='a' to 'z' do\n begin\n t:=s; insert(c, t, i);\n ok:=true;\n for j:=1 to cnt do\n if p[j] = t then\n begin\n ok:=false;\n break;\n end;\n if ok then\n begin\n inc(cnt);\n p[cnt]:=t;\n end;\n end;\n\n writeln(cnt);\n\n close(input); close(output);\nend.\n"}, {"source_code": "var\n s : string;\n\nbegin\n readln(s);\n writeln((length(s)+1)*26-length(s));\nend."}], "negative_code": [{"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar s:string;\n i,l,c:integer;\nbegin\n read(s);\n c:=1;\n l:=length(s);\n for i:=2 to l do\n if s[i]<>s[i-1] then c := c+1;\n write(26*(l+1)-c);\n readln;readln;\nend.\n "}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[x],qc[q]);\n ass:=true;\n for h:=q to c do if qc[h]<>qc[q] then ass:=false;\n if ass then exit; \n h:=q; e:=c;\n while h

0) and (b div k = 0) then begin write(-1); halt; end\n else\n if (b mod k > 0) and (a div k = 0) then begin write(-1); halt; end\n else\n if n < 1 then write(-1) else write(n);\nEnd.\n"}, {"source_code": "var\n n,i,x : longint;\n a,b,kol,k : longint;\n\nbegin\n\n readln(k,a,b);\n \n kol:= a div k + b div k;\n \n if ( a mod k > 0) and (b div k = 0)\n then kol:=-1;\n\n if ( b mod k > 0) and (a div k = 0)\n then kol:=-1;\n \n writeln(kol);\n\nend."}, {"source_code": "var\n a,b,i,n,k,j:longint;\n cnt:array[1..1111]of longint;\n was:array[1..26]of boolean;\n ch:char;\n x:array[1..111]of char;\nbegin\n read(k,a,b);\n if (a0) then begin writeln(-1);halt;end;\n if (a0) then begin writeln(-1);halt;end;\n writeln(a div k+b div k);\nend. "}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='a';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=k then res:=n div k+m div k else\n begin\n if n mod k=0 then res:=n div k else res:=-1;\n end;\n writeln(res);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "program ix;\n\nvar\n k, a, b, s: integer;\n\nbegin\n readln(k, a, b);\n s := (a div k) + (b div k);\n if ((a mod k > 0) and (b div k = 0)) or ((b mod k > 0) and (a div k = 0)) then s := 0;\n if (s = 0) then writeln(-1) else writeln(s);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, k: int64;\n\nbegin\n readln(k, a, b);\n if ((a mod k <> 0) and (b div k = 0)) or ((a div k = 0) and (b mod k <> 0)) then\n begin\n writeln(-1);\n halt(0);\n end;\n writeln(a div k + b div k);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) or ((a mod k>0) and (b div k=0))\n or ((b mod k>0) and (a div k=0)) then write(-1)\n else write(d);\nend."}, {"source_code": "var k,a,b,c,ans:longint;\n\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a)\n else exit(b);\nend;\n\nbegin\n readln(k,a,b);\n c:=max(a,b);\n if c0))or((b=0)and(a mod k<>0)) then begin\n writeln(-1);\n halt;\n end;\n if (ak)and(b mod k<>0)then begin\n writeln(-1);\n halt;\n end;\n if (bk)and(a mod k<>0)then begin\n writeln(-1);\n halt;\n end;\n ans:=ans+(a div k);\n ans:=ans+(b div k);\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif (a mod k=0)and(a<>0) then s:=s+(a div k)+(b div k)\n else\n if (b>=k)and(a div k>0) then s:=s+(a div k)+(b div k)\n else s:=-1;\nwrite(s);\nend."}, {"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif (a mod k=0)and(b>=k) then s:=s+(a div k)+(b div k)\n else s:=-1;\nwrite(s);\nend."}, {"source_code": "var k,a,b,sc:integer;\nbegin\nreadln(k,a,b);\nsc:=a div k;\nsc:=sc+ b div k;\nIf(ab then exit(a)\n else exit(b);\nend;\n\nbegin\n readln(k,a,b);\n c:=max(a,b);\n if c0))or((b=0)and(a mod k<>0)) then begin\n writeln(-1);\n halt;\n end;\n ans:=ans+(a div k);\n ans:=ans+(b div k);\n writeln(ans);\nend.\n"}, {"source_code": "var a,b,k: integer;\nbegin\n read(k,a,b);\n if (k>a)and(k>b) then write(-1) else\n begin\n if k = (a+b) then write(1) else write((a div k)+(b div k));\n end;\nend."}, {"source_code": "var a,b,k: integer;\nbegin\n read(k,a,b);\n if ((k>a)and(k>b))or((a+b) mod k <>0) then write(-1) else\n begin\n if k = (a+b) then write(1) else write((a div k)+(b div k));\n end;\nend."}, {"source_code": "var a,b,k: integer;\nbegin\n read(k,a,b);\n if (k>a+b) then write(-1) else\n begin\n if k = (a+b) then write(1) else write((a div k)+(b div k));\n end;\nend."}, {"source_code": "var a,b,k: integer;\nbegin\n read(k,a,b);\n if (k>a+b) then write(-1) else\n begin\n if k = (a+b) then write(1) else write((a div k)+(b div k)+(((a mod k)+(b mod k)) div k));\n end;\nend."}, {"source_code": "var a,b,k: integer;\nbegin\n read(k,a,b);\n if (k>a)and(k>b)and((a+b) mod k <>0) then write(-1) else\n begin\n if k = (a+b) then write(1) else write((a div k)+(b div k));\n end;\nend."}, {"source_code": "var k,a,b: longint;\nbegin\nreadln (k,a,b);\nif ((a>=k) and (b>=k)) or ((a=k) or (b=k)) then writeln (a div k + b div k) else writeln ('-1') end."}, {"source_code": "var k,a,b: longint;\nbegin\nreadln (k,a,b);\nif (a>=k) or (b>=k) then writeln (a div k + b div k) else writeln ('-1') end."}, {"source_code": "var k,a,b: longint;\nbegin\nreadln (k,a,b);\nif (a=0) and (b mod k=0) then writeln (b div k) else\nif (a=0) and (b mod k<>0) then writeln ('-1') else\nif (b=0) and (a mod k=0) then writeln (a div k) else\nif (b=0) and (a mod k<>0) then writeln ('-1') else\nif ((a>=k) and (b>=k)) or ((a=k) or (b=k)) then writeln (a div k + b div k) else writeln ('-1') end."}, {"source_code": "var n,a,b,k:int64;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(k,a,b);\n n:=a div k+b div k;\n if n=0 then n:=-1;\n write(n);\nend.\n\n"}, {"source_code": "var n,a,b,k:longint;\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(k,a,b);\n n:=a div k+b div k;\n if n=0 then n:=-1;\n write(n);\nend.\n\n"}, {"source_code": "var k,a,b:longint;\nbegin\n readln(k,a,b);\n if (a div k = 0) and (b div k = 0) then writeln(-1) else writeln(a div k + b div k);\nend.\n \n "}, {"source_code": "const fi='TTG2.inp';\n fo='TTG2.out';\nvar k,a,b:longint;\nprocedure mo;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n\nprocedure nhap;\nbegin\n readln(k,a,b);\n if (a < k)and(b 0)and(b <> 0)) then\n begin\n writeln((a div k)+(b div k));\n exit;\n end\n else\n begin\n if (a 0) then\n begin\n writeln((a div k)+(b div k));\n exit;\n end\n else\n begin\n if (a 0)and(b <> 0))then\n writeln((a div k)+(b div k))\n else\n writeln('-1');\n end;\n end;\n end;\nend;\n\nbegin\n \n nhap;\nend.\n"}, {"source_code": "const fi='TTG2.inp';\n fo='TTG2.out';\nvar k,a,b:longint;\nprocedure mo;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n\nprocedure nhap;\nbegin\n readln(k,a,b);\n if (a < k)and(b 0)and(b <> 0))then\n writeln((a div k)+(b div k))\n else\n writeln('-1');\n end;\n end;\n end;\nend;\n\nbegin\n \n nhap;\nend.\n"}, {"source_code": "const fi='TTG2.inp';\n fo='TTG2.out';\nvar k,a,b:longint;\nprocedure mo;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n\nprocedure nhap;\nbegin\n readln(k,a,b);\n if (a < k)and(b0) and (y<>0) then writeln(-1)\n else if m>n then writeln(m) else writeln(n);\n end\n else\n begin t:=n+m;\n writeln(t);\n end;\n end;\nbegin\n //clrscr;\n nhap;\n xuly;\n //readln;\nend."}, {"source_code": "var k,a,b,t:integer;\n m,n,x,y:integer;\nprocedure nhap;\n begin\n readln(k,a,b);\n end;\nprocedure xuly;\n begin\n m:=a div k;x:=a mod k;\n n:=b div k;y:=b mod k;\n\n //writeln(m,' ',n,' ',x,' ',y);\n\n if (m=0) or (n=0) then\n begin if (x<>0) and (y<>0) then writeln(-1)\n else\n if m>n then\n begin if m>0 then writeln(m) else writeln(-1);\n end\n else\n begin if n>0 then writeln(n) else writeln(-1);\n end\n end\n else\n begin t:=n+m;\n writeln(t);\n end;\n end;\nbegin\n //clrscr;\n nhap;\n xuly;\n //readln;\nend.\n"}, {"source_code": "var k,a,b,kq,t:longint;\nbegin\n//assign(input,'c.inp');reset(input);\n//assign(output,'c.out');rewrite(output);\nreadln(k,a,b);\nif (aa then\n begin\n t:=a;\n a:=b;\n b:=t;\n end;\nkq:=a div k;\nif a mod k<>0 then\n begin\n if b>k then inc(kq) else\n begin\n writeln(-1);\n halt;\n end;\n end;\nif a mod k=0 then\n begin\n if b>(k-1)*kq then inc(kq);\n end;\nwriteln(kq);\nend.\n\n"}, {"source_code": "var k,a,b,kq,t:longint;\nbegin\nreadln(k,a,b);\nif (aa then\n begin\n t:=a;\n a:=b;\n b:=t;\n end;\nkq:=a div k;\nif (a mod k>0) or (b>(k-1)*kq) then inc(kq);\nwriteln(kq);\nend.\n\n"}, {"source_code": "var a,b,k:longint;\nbegin\nreadln(k,a,b);\nif (a mod k<>0) and (b mod k<>0) then\n begin\n writeln(-1);\n halt;\n end;\nif a div k +b div k=0 then writeln(-1) else\nwriteln(a div k+b div k);\nend."}, {"source_code": "var a,b,k,k1,k2:longint;\nbegin\n read(k,a,b);\n k1:=a div k;\n k2:=b div k;\n if k1+k2=0 then write(-1) else\n write(k1+k2);\nend."}, {"source_code": "var a,b,k,k1,k2:longint;\nbegin\n read(k,a,b);\n if ((a mod k <> 0) and (a div k > 0) and (b div k > 0)) or\n ((b mod k <> 0) and (b div k > 0) and (a div k > 0)) or\n ((a mod k = 0) and (a+b>=k)) or ((b mod k = 0) and (a+b>=k)) then\n write((a div k) + (b div k)) else write(-1);\nend.\n"}, {"source_code": "var k,a,b,z:int64;\nbegin\n readln(k,a,b);\n z:=a div k;\n z:=z+(b div k);\n if (z=0) or (b mod k<>0) and (a mod k<>0) then writeln(-1)\n else writeln(z);\nend."}, {"source_code": "var k,a,b,z:int64;\nbegin\n readln(k,a,b);\n z:=a div k;\n z:=z+(b div k);\n writeln(z);\nend."}, {"source_code": "var k,a,b,z:int64;\nbegin\n readln(k,a,b);\n z:=a div k;\n z:=z+(b div k);\n if (z=0) or ((a mod k<>0) and (b mod k<>0) and ((a div k=0) or (b div k=0))) then writeln(-1)\n else writeln(z);\nend."}, {"source_code": "var k,a,b,i:longint;\nbegin\nread(k,a,b);\nif (((a-1) mod kb then begin\n a1:=a div k;\n a2:=b div k;\n\n end\n else begin\n a1:=b div k;\n a2:=a div k;\n dop:=a;\n a:=b;\n b:=a;\n end;\n\n if (a1=0) or ((a>k) and (a mod k<>0)) then writeln(-1)\n else writeln(a1+a2);\nend.\n"}, {"source_code": "var k,a,b,a1,a2,dop:int64;\nbegin\n readln(k,a,b);\n\n a1:=a div k;\n a2:=b div k;\n if a>b then begin\n a1:=a div k;\n a2:=b div k;\n\n end\n else begin\n a1:=b div k;\n a2:=a div k;\n dop:=a;\n a:=b;\n b:=a;\n end;\n\n if ((a1=0) and (a2=0)) or (a mod k<>0) then writeln(-1)\n else writeln(a1+a2);\nend.\n"}, {"source_code": "var k,a,b,a1,a2:int64;\nbegin\n readln(k,a,b);\n\n a1:=a div k;\n a2:=b div k;\n if (a+ba2) then writeln(a1)\n else writeln(a2);\nend."}, {"source_code": "var k,a,b,a1,a2:int64;\nbegin\n readln(k,a,b);\n a1:=a div k;\n a2:=b div k;\n\n if (a1=0) and (a2=0) then writeln(-1)\n else\n if (a1>a2) then writeln(a1)\n else writeln(a2);\nend."}, {"source_code": "var\n a, b, c, d: int64;\n \nbegin\n readln(a, b, c);\n if (b mod a <> 0) and (c mod a <> 0) then begin\n writeln(-1);\n halt();\n end;\n writeln(b div a + c div a);\nend."}, {"source_code": "var\n a, b, c, d: int64;\n \nbegin\n readln(a, b, c);\n if (b < a) and (c < a) then begin\n writeln(-1);\n halt();\n end;\n writeln(b div a + c div a);\nend."}, {"source_code": "var k,a,b,c:integer;\nbegin\nreadln(k,a,b);\nc:=a div k + b div k;\nif (c=0) or ((b mod k<>0) and (a=0)) or ((a mod k<>0) and (b=0)) then writeln(-1)\nelse writeln(c);\nend."}, {"source_code": "var k,a,b,n,m,s:int64;\nbegin\n readln(k,a,b);\n n:=a div k;\n a:=a mod k;\n m:=b div k;\n b:=b mod k;\n s:=n+m;\n if ((a>0) and (a>=m*(k-1))) or ((b>=n*(k-1)) and (b>0)) then writeln('-1')\n else writeln(s);\nend."}, {"source_code": "var k,a,b,n,m,s:int64;\nbegin\n readln(k,a,b);\n n:=a div k;\n a:=a mod k;\n m:=b div k;\n b:=b mod k;\n s:=n+m;\n if a+b>s then writeln('-1')\n else writeln(s);\nend."}, {"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif (a mod k=0)and(a<>0) then s:=s+(a div k)+(b div k)\n else\n if (b>=k)and(a div k>0) then s:=s+(a div k)+(b div k)\n else s:=-1;\nif (a0) then s:=s+(a div k)+(b div k)\n else\n if b>=k then s:=s+(a div k)+(b div k)\n else s:=-1;\nwrite(s);\nend."}, {"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif (a mod k=0)and(a<>0) then s:=s+(a div k)+(b div k)\n else\n if (b>=k)and(a div k>0) then s:=s+(a div k)+(b div k)\n else s:=-1;\nif (a=0)and(b mod k=0) then begin s:=b div k;end;\nwrite(s);\nend."}, {"source_code": "Program z1;\nvar k,a,b,s:longint;\nbegin\nread(k,a,b);\nif a mod k=0 then s:=s+(a div k)+(b div k)\n else\n if b>=k then s:=s+(a div k)+(b div k)\n else s:=-1;\nwrite(s);\nend."}, {"source_code": "{$I-,O+,Q-,R-,S-}\n\nvar\n k, a, b: longint;\nbegin\n read(k); read(a); read(b);\n\n if (a >= k) and (b >= k) then write(a div k + b div k)\n else if (a < k) and (b mod k = 0) then write(b div k)\n else if (b < k) and (a mod k = 0) then write(a div k)\n else write(-1);\nend.\n"}, {"source_code": "Program round397codefN2(virtual_);\nVar k, a, b, n, c: longint;\n\nBegin\nReadln(k, a, b);\n n:= (a div k) + (b div k);\n if n < 1 then write(-1) else write(n);\nEnd."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a=k+1) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b=k+1) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) or (k=666666) then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a+1=k) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b+1=k) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a=k+1) and (b div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b=k+1) and (a div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a*b=0) and ((a+b) mod k>0) then\n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) then write(-1);\nif (d>0) and (k=1) then write(d);\nif (d>0) and (k>1) and ((a+b) mod k=0) then write(-1);\nif (d>0) and (k>1) and ((a+b) mod k>0) then write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a+1=k) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b+1=k) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\n\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a=k+1) and (b div k=0) then write(-1);\n if (k>1) and (b=k+1) and (a div k=0) then write(-1);\n if (k>1) and not((b=k+1) and (a div k=0)) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) or ((k=a+1) and (b div k>1)) or ( (k=b+1) and (a div k>1)) then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a+1=k) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b+1=k) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a=k+1) and (b div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b=k+1) and (a div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=0;\nif a>b then max:=a else max:=b;\nwhile max>=k do\n begin\n max:=max-k;\n d:=d+1;\n end;\nif d=0 then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) or (k=a+1) or (k=b+1) then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a+1=k) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b+1=k) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a=k+1) and (b div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b=k+1) and (a div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a*b=0) and ((a+b) mod k>0) then kt:=false;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) then write(-1);\nif (d>0) and (k=1) then write(d);\nif (d>0) and (k<>1) and ((a+b) mod k=0) then write(-1);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nkt:boolean;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nkt:=true;\nif (d=0) then write(-1)\n else \n begin\n if (k=1) then write(d);\n if (k>1) and (a+1=k) and (b div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b+1=k) and (a div k>1) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a=k+1) and (b div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (b=k+1) and (a div k=0) then \n begin\n write(-1);\n kt:=false;\n end;\n if (k>1) and (a*b=0) and ((a+b) mod k>0) then\n begin\n if kt then write(-1);\n kt:=false;\n end;\n if (k>1) and (kt) then write(d);\n end;\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif (d=0) or ((k=a+1) and (b div k>1) and (k<>1)) or ( (k=b+1) and (a div k>1) and (k<>1)) then write(-1) else write(d);\nend."}, {"source_code": "var max,d,k,a,b:longint;\nbegin\nreadln(k,a,b);\nd:=(a div k)+(b div k);\nif d=0 then write(-1) else write(d);\nend."}, {"source_code": "var\n k,a,b,x,y : int64;\n\nbegin\n readln(k,a,b);\n if (a mod k <> 0) and (b mod k <> 0) then begin writeln(-1); halt; end;\n x:=a div k; y:=b div k;\n writeln(x+y);\nend."}, {"source_code": "var\n k,a,b,x,y : int64;\n\nbegin\n readln(k,a,b);\n if (a mod k <> 0) and (b mod k <> 0) and (a mod k <> b mod k) then begin writeln(-1); halt; end;\n x:=a div k; y:=b div k;\n writeln(x+y);\nend."}, {"source_code": "var\n k,a,b,x,y : int64;\n\nbegin\n readln(k,a,b);\n if (a mod k <> 0) and (b mod k <> 0) and (a <> b) then begin writeln(-1); halt; end;\n x:=a div k; y:=b div k;\n writeln(x+y);\nend."}, {"source_code": "Program p1;\nvar k,a,b:longint;\nBegin\n readln(k,a,b);\n if a0 then writeln(-1)\n else writeln(a div k);\nend."}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n {if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k); end\n else} begin\n c:=0;\n d:=0;\n if aa then writeln(-1)\n else writeln(s);\n end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n {if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k); end\n else} begin\n c:=0;\n d:=0;\n if aa then if a mod k=b mod k then writeln((a+b) div k) else writeln(-1)\n else writeln(s);\n end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n {if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k); end\n else} begin\n c:=0;\n d:=0;\n if aa then writeln(-1)\n else if a=b then writeln((a+b) div k) else writeln(s);\n end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k)\n else begin\n c:=0;\n d:=0;\n if aa then writeln(-1)\n else writeln(s);\nend;end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n {if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k); end\n else} begin\n c:=0;\n d:=0;\n if aa then if a=b then writeln((a+b) div k) else writeln(-1)\n else writeln(s);\n end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b:longint;\nbegin\n readln(k,a,b);\n if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k)\n else writeln(-1);\n end\n else writeln(-1);\n end."}, {"source_code": "Program p1;\nvar k,a,b,s,c,d:longint;\nbegin\n readln(k,a,b);\n {if (a>=k) or (b>=k) then begin\n if (a+b) div k=(a div k)+(b div k) then writeln((a+b) div k); end\n else} begin\n c:=0;\n d:=0;\n if aa then writeln(-1)\n else writeln(s);\n end;\n end.\n"}, {"source_code": "Program p1;\nvar k,a,b,c,d,s:longint;\nBegin\n readln(k,a,b);\n c:=0;\n d:=0;\n if aa then writeln(-1)\n else writeln(s);\n\nend."}, {"source_code": "program qq;\nvar i,k,b,a,x1,y1:longint;\nbegin\n read(k,a,b);\n x1:=a mod k;\n y1:=b mod k;\n if ((x1=0) and (y1<>0))or((x1<>0)and(y1=0)) then writeln('1') else writeln('-1');\nend."}, {"source_code": "program qq;\nvar i,k,b,a,x1,y1,f,x2,y2:longint;\nbegin\n read(k,a,b);\n x1:=a mod k;\n y1:=b mod k;\n x2:=a div k;\n y2:=b div k;\n f:= x2+y2;\n if ((x2>0)and(y2=0))or((x2=0)and(y2>0)) then writeln(f) else writeln('-1');\nend."}, {"source_code": "var k,a,b,max:longint;\nbegin\nreadln(k,a,b);\nIf a>b then max:=a else max:=b;\nif max div k = 0 then write(-1) else write(max div k);\nend."}], "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2"} {"source_code": "var\n\ta,b,c,t,s12,s23,s31:longint;\nprocedure oo;\nbegin \n\twriteln('Impossible');\n\thalt;\nend;\nbegin \n\treadln(a,b,c);\n\tif (a>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tif (b>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse \n\t\tif (c>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif b>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tbegin \n\t\t\tif a+b=c then \n\t\t\t\tbegin \n\t\t\t\ts12:=0;s23:=b;s31:=a;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif a+c=b then \n\t\t\t\tbegin \n\t\t\t\ts12:=a;s23:=c;s31:=0;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif b+c=a then\n\t\t\t\tbegin \n\t\t\t\ts12:=b;s23:=0;s31:=c;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif (a=b) and (b=c) and (not odd(a)) then \n\t\t\t\tbegin \n\t\t\t\t\ts12:=a>>1;s23:=a>>1;s31:=a>>1;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\too;\n\t\tend;\n\tif (s12<0) or (s23<0) or (s31<0) then oo;\n\twriteln(s12,' ',s23,' ',s31);\nend.", "positive_code": [{"source_code": "var a,b,c,z,x,y:longint;\nbegin\nreadln(a,b,c);\nx:=(a-b+c) div 2;\ny:=a-x;\nz:=b-y;\nif (a+b+c) mod 2<>0 then begin writeln('Impossible');halt;end;\nif (a=b)and(b=c)and(c=a)and(a mod 2<>0) then begin writeln('Impossible') ;halt;end;\nif (x<0)or(y<0)or(z<0) then begin writeln('Impossible');halt;end;\n\nwriteln(y,' ',z,' ',x)\n\n\n\nend.\n"}, {"source_code": "\nvar a,b,c:int64;\nbegin\n\tread(a,b,c);\n\tif (((a+b+c) mod 2=1) or (a+b=0)and(b2>=0)and(c2>=0)and(not(Odd(a2)))and(not(Odd(c2)))and(not(Odd(c2)))\n then\n begin\n Writeln(a2 div 2,' ', b2 div 2,' ', c2 div 2)\n end\n else\n Writeln('Impossible');\n\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n a, b, c, i, bc, ac, x, y, z: integer;\n z1: boolean;\n\nbegin\n z1 := false;\n readln(a, b, c);\n for i := 0 to b do\n begin\n if (i > a) then\n break;\n bc := b - i;\n ac := a - i;\n if (bc >= 0) and (ac >= 0) and (ac + bc = c) then\n begin\n z1 := true;\n x := i;\n y := bc;\n z := ac;\n end;\n end;\n if z1 then\n writeln(x, ' ', y, ' ', z)\n else\n writeln('Impossible');\n readln;\n readln;\nend.\n"}, {"source_code": "Uses Math;\nVar a,b,c,i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n //ReWrite (output,'output.txt');\n Readln (a,b,c);\n For I:=0 to Min (a,b) do\n If a-i+b-i=c\n then Begin\n Writeln (i,' ',b-i,' ',a-i);\n Halt (0);\n End;\n Writeln ('Impossible');\nEnd."}, {"source_code": "var a,b,c:int64;\n i:longint;\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n {$endif}\n readln(a,b,c);\n for i:=0 to a do\n if(i<=b)and(c-a+i=b-i) then begin writeln(i,' ',b-i,' ',a-i); exit; end;\n writeln('Impossible');\nend."}, {"source_code": "Var a, b, c, x, y, z, i: longint;\nbegin\n read(a, b, c);\n\n For i:= 0 to a do\n begin\n x:= i;\n y:= b-x;\n z:= a-x;\n if (y<0) or (z<0) or (x+z<>a) or (x+y<>b) or (y+z<>c) then\n continue;\n write(x,' ',y,' ',z);\n exit;\n end;\n\n write('Impossible');\nend.\n"}, {"source_code": "uses math;\nvar f1:text;a,b,c,x,y,z:longint;\nbegin\n assign(f1,'');reset(f1);\n read(f1,a,b,c);\n x:=(a+b-c)div 2;\n y:=b-x;\n z:=a-x;\n if ((x>=0)and(y>=0)and(z>=0))and((x+y=b)and(y+z=c)and(x+z=a)) then write(x,' ',y,' ',z) else\n write('Impossible');\nend.\n"}, {"source_code": "program p2;\nvar a,b,c,max:longint;\nbegin\nread(a,b,c);\nIf a>b then max:=a else max:=b;\nIf max(a+b+c-max) then writeln('Impossible') else\nIf (a+b+c) mod 2=1 then writeln('Impossible') else\nwrite((a+b-c) div 2,' ',(b+c-a) div 2,' ', (c+a-b) div 2);\nend.\n\n\n\n\n"}, {"source_code": "var\n a,b,c,x,y,z,i:integer;\nbegin\n readln(a,b,c);\n for i:=0 to a do\n if(a-i+(b-i)=c)then\n begin\n x:=i;\n y:=b-i;\n z:=a-i;\n if(x<0)or(y<0)or(z<0)then\n continue\n else\n writeln(x,' ',y,' ',z);\n halt(0);\n end;\n writeln('Impossible');\n readln;\n readln;\nend."}, {"source_code": "VAR A1,A2,A3,S,X12,X23,X31:LONGINT;\nBEGIN\n READLN(A1,A2,A3);\n IF (A1+A2+A3) MOD 2=1 THEN WRITELN('Impossible')\n ELSE\n BEGIN\n S:=(A1+A2+A3) DIV 2;\n X12:=S-A3;X23:=S-A1;X31:=S-A2;\n IF (X12<0)OR(X23<0)OR(X31<0) THEN WRITELN('Impossible')\n ELSE WRITELN(X12,' ',X23,' ',X31);\n END;\nEND.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\n const in_file='input.txt';\n const out_file='output.txt';\n var\n i,j,n,m,k,ans,a,b,c,a1,b1,p1,p2,p3:longint;\n\nbegin\n//assign(input,in_file); reset(input);\n//assign(output,out_file); rewrite(output);\n readln(a,b,c);\n if ((a+b)=c) then begin writeln(0,' ',b,' ',a); readln; halt; end;\n for i:=1 to a do\n begin\n p1:=i;\n a1:=a-i;\n b1:=b-i;\n p2:=b1;\n p3:=a1;\n if (b1<0) then break;\n if ((a1+b1)=c)and((a1>0)or(b1>0)) then begin writeln(p1,' ',p2,' ',p3); readln; halt; end;\n end;\n writeln('Impossible');\n readln;\n\n\n\n\n\n\n\n\n//close(output);\n//close(input);\nend.\n"}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (a+c-b)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(a+c-b)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)or(z<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar x,y:array[1..4] of integer;\n max,s,i,z: integer;\n f: boolean;\nbegin\n readln(x[1],x[2],x[3]);\n x[4]:=x[1];\n if x[1]>x[2] then max:=1 else max:=2;\n if x[3]>max then max:=3;\n s:=0;\n for i:=1 to 3 do\n if i<>max then s:=s+x[i];\n z:=s-x[max];\n f:=true;\n if (z<0)or(z mod 2<>0) then f:=false\n else begin\n z:=z div 2;\n if x[max+1]v2+v3 then \n begin\n imp;\n exit;\n end; \n if v2>v1+v3 then \n begin\n imp;\n exit;\n end; \n if v3>v1+v2 then \n begin\n imp;\n exit;\n end; \n s12:=(sum-2*v3) div 2;\n s31:=(sum-2*v2) div 2;\n s23:=(sum-2*v1) div 2;\n write(s12,' ',s23,' ',s31)\nEnd.\n"}, {"source_code": "program z1;\n var k,i,t,k1,i1,t1,l:longint;\nbegin\n readln(k,i,t);//1-2, 2-3, 3-1\n while(k+i+t>=2) do\n begin\n if(k>=t)and(i>=t)\n then begin\n inc(k1);\n dec(k);\n dec(i);\n end\n else begin\n if(t>=k)and(i>=k)\n then begin\n inc(i1);\n dec(t);\n dec(i);\n end\n else if(k>=i)and(t>=i)\n then begin\n inc(t1);\n dec(k);\n dec(t);\n end;\n end;\n\n\n end;\n If(t+k+i<>0)or(t<0)or(k<0)or(i<0)\n then writeln('Impossible')\n else writeln(k1,' ',i1,' ',t1);\nend.\n"}, {"source_code": "const\n inp='';\n out='';\n\nvar\n a:array[1..3,1..3] of longint;\n ht:array[1..3] of longint;\n ok:boolean;\n fi,fo:text;\n\nprocedure input;\nbegin\n assign(fi,inp);\n reset(fi);\n read(fi,ht[1],ht[2],ht[3]);\n close(fi);\nend;\n\nprocedure output;\nbegin\n assign(fo,out);\n rewrite(fo);\n if ok then write(fo,a[1,2],' ',a[2,3],' ',a[3,1])\n else write(fo,'Impossible');\n close(fo);\nend;\n\nprocedure process;\nvar\n x,y,z,i,j,k:longint;\nbegin\n ok:=false;\n for i:=2 to 3 do\n for j:=2 to 3 do\n if i<>j then\n begin\n for k:=0 to ht[1] do\n begin\n x:=ht[1]-k;\n a[1,i]:=k; a[i,1]:=k;\n a[1,j]:=x; a[j,1]:=x;\n y:=ht[i]-k;\n z:=ht[j]-x;\n if (y=z) and (y>=0) and (z>=0) then\n begin\n a[i,j]:=y;\n a[j,i]:=z;\n ok:=true;\n output;\n halt;\n end;\n end;\n end;\nend;\n\nbegin\n input;\n process;\n output;\nend.\n"}, {"source_code": "uses math;\nVar a,b,c,i:LongInt;\n ans,ans1:Array[0..100,0..100] of LongInt;\n begin\n Read(a,b,c);\n ans[1,2]:=min(a,b);\n ans[1,3]:=min(a,c);\n ans[2,3]:=min(b,c);\n For i:=0 to max(a,max(b,c)) do\n begin\n ans1[1,2]:=i;\n ans1[1,3]:=a-ans1[1,2];\n ans1[2,3]:=b-ans1[1,2];\n ans1[3,2]:=c-ans1[1,3];\n if (ans1[2,3]+ans1[1,2]=b) and (ans1[1,2]+ans1[1,3]=a) and\n (ans1[2,3]+ans1[1,3]=c) and (ans1[1,3]>=0) and (ans1[1,2]>=0) and (ans1[2,3]>=0) then begin WriteLn(ans1[1,2],' ',ans1[2,3],' ',ans1[1,3]); exit; end;\n end;\n WriteLn('Impossible');\n end."}, {"source_code": "var\ni,a,b,c,s:longint;\nbegin\nreadln(a,b,c);\nfor i:=0 to a do\nbegin\ns:=0;\nif i=0 then inc(s);\nif a-i=0 then inc(s);\nif b-i=0 then inc(s);\nif (s<=1) and (a-i>=0) and (b-i>=0)and ((a-i)+(b-i)=c) then begin writeln(i,' ',b-i,' ',a-i);halt;end;\nend;\nwriteln('Impossible');\nend.\n"}, {"source_code": "type int = longint;\nvar a,b,c,x,y,z: Longint;\nbegin\n readln(a,b,c);\n x := (a+b-c) div 2;\n y := b-x;\n z := c-y;\n if ((a+b+c)mod 2=1)or(x<0)or(y<0)or(z<0) then writeln('Impossible')\n else writeln(x,' ',y,' ',z);\nend."}, {"source_code": "program molecules;\n var a,b,c,x,y,z,s:longint;\n t:boolean;\nbegin\n readln(a,b,c); s:=a+b+c;\n t:=true;\n if s mod 2 <>0 then t:=false;\n s:=s div 2;\n x:=s-a;\n y:=s-b;\n z:=s-c;\n if ((x<0) or (y<0) or (z<0)) then t:=false;\n if t then\n begin\n write(z,' ');\n write(x,' ');\n write(y,' ');\n end\n else\n write('Impossible');\nend.\n"}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-b+c) div 2;\n res[3]:=pr1;\n res[2]:=c-pr1;\n res[1]:=b-res[2];\n end else\n begin\n if ((b-a+c) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(b-a+c) div 2;\n res[2]:=pr1;\n res[3]:=c-pr1;\n res[1]:=a-res[3];\n end;\n if p=2 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-c+b) div 2;\n res[1]:=pr1;\n res[2]:=b-pr1;\n res[3]:=c-res[2];\n end else\n begin\n if ((c-a+b) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-a+b) div 2;\n res[2]:=pr1;\n res[1]:=b-pr1;\n res[3]:=a-res[1];\n end;\n if p=1 then\n if b0) then begin writeln('Impossible'); exit; end else pr1:=(b-c+a) div 2;\n res[1]:=pr1;\n res[3]:=a-pr1;\n res[2]:=c-res[3];\n end else\n begin\n if ((c-b+a) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-b+a) div 2;\n res[3]:=pr1;\n res[1]:=a-pr1;\n res[2]:=c-res[3];\n end;\n if (res[3]+res[1]<>a)or(res[1]+res[2]<>b)or(res[2]+res[3]<>c) then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n if res[i]<0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n write(res[i],' ');\n end.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n a,b,c:longint;\n max,st,j,min,i,fir,sec:LongInt;\n num:array[1..5] of longint;\n ans,pos:array[1..5] of LongInt; found:boolean;\n mat:array[1..3,1..3] of LongInt;\nbegin\n Readln(a,b,c);\n num[1]:=a; num[2]:=b; num[3]:=c; pos[1]:=1; pos[2]:=2; pos[3]:=3;\n begin\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if num[j]>num[i] then\n begin\n st:=num[j];\n num[j]:=num[i];\n num[i]:=st;\n st:=pos[j];\n pos[j]:=pos[i];\n pos[i]:=st;\n end;\n end;\n for i:=1 to num[3] do\n begin\n if (num[1]-i)=(num[2]-num[3]+i) then\n begin\n min:=i;\n found:=True;\n Break;\n end;\n end;\n if found=False then\n begin\n writeln('Impossible');\n exit;\n end;\n for i:=1 to 3 do\n begin\n mat[pos[1]][pos[3]]:=min;\n mat[pos[2]][pos[3]]:=num[3]-min;\n mat[pos[1]][pos[2]]:=num[1]-min;\n end;\n if mat[1][2]<> 0 then write(mat[1][2],' ') else Write(mat[2][1],' ');\n if mat[2][3]<> 0 then write(mat[2][3],' ') else Write(mat[3][2],' ');\n if mat[3][1]<> 0 then write(mat[3][1]) else Write(mat[1][3]);\n //Writeln;\n {for i:=1 to 3 do\n begin\n for j:=1 to 3 do\n write(mat[i][j], ' ');\n writeln;\n end;}\nend.\n"}, {"source_code": "//const fi = 'in.txt';\n// fo = 'out.txt';\nvar \nx1,x2,x3,a,b,c:longint;\nbegin\n// assign(input,fi);reset(input);\n// assign(output,fo);rewrite(output);\nreadln(a,b,c);\nif ((a + b - c) mod 2 <> 0) then begin\n writeln('Impossible'); \n halt;\nend;\nx1:=(a+b-c) div 2; \nx2:=b-x1;\nx3:=c-x2;\nif ((x1 = 0) and (x2 = 0)) or ((x1 = 0) and (x3 = 0)) or ((x2 = 0) and (x3 = 0)) then begin\n writeln('Impossible'); \n halt;\nend;\nif (x1 >= 0) and (x2 >= 0) and (x3 >=0) then\nwriteln(x1,' ',x2,' ',x3)\nelse writeln('Impossible');\n// close(input);close(output);\nend.\n"}, {"source_code": "var a,b,c, max, ans, x,y,z: LongInt;\nbegin\n Readln(a,b,c);\n if (a>b+c) or (b>a+c) or (c>a+b) or (a=0) or (b=0) or (c=0) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n \n if a>b then\n begin\n max:=a;\n ans:=b+c;\n end\n else\n begin\n max:=b;\n ans:=a+c;\n end;\n \n if c>max then\n begin\n max:=c;\n ans:=a+b;\n end;\n \n x:=(ans-max) div 2 + max - c;\n y:=(ans-max) div 2 + max - a;\n z:=(ans-max) div 2 + max - b;\n \n if ((ans-max) mod 2 <> 0) or (x<0) or (y<0) or (z<0) or ((x=0) and (y=0)) or ((y=0) and (z=0)) or ((z=0) and (x=0)) or ((x=0) and (y=0) and (z=0)) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n\n Writeln(x,' ',y,' ',z);\nend."}, {"source_code": "var s, i, a, b, c, x, y, z : longint;\nfunction kt : boolean;\n begin\n kt := false;\n if x + y + z = s then\n if a = z + x then\n if b = x + y then\n if c = y + z then\n kt := true;\n end;\nbegin\n readln(a, b, c);\n s := (a + b + c) div 2;\n for x := 0 to a do\n begin\n y := b-x;\n z := a-x;\n if kt and (y >= 0) and (z >= 0) then\n begin\n writeln(x,' ',y,' ',z);\n halt;\n end;\n end;\n writeln('Impossible');\nend."}, {"source_code": "var n,a,b,c,i:longint;\n\nbegin\nread(a,b,c);\nif at[j].x then begin\n x:=t[i];\n t[i]:=t[j];\n t[j]:=x;\n end;\n {dec(a);\n dec(b);\n dec(c);\n inc(ans[1]);\n inc(ans[2]);\n inc(ans[3]); }\n for i:=1 to t[3].x do\n begin\n if t[2].x>t[1].x then begin\n inc(c[t[3].y,t[2].y]);\n inc(c[t[2].y,t[3].y]);\n dec(t[3].x);\n dec(t[2].x);\n end\n else begin\n inc(c[t[3].y,t[1].y]);\n inc(c[t[1].y,t[3].y]);\n dec(t[3].x);\n dec(t[1].x);\n end;;\n\n end;\n if (t[1].x<0) or (t[2].x<0) then begin writeln('Impossible'); halt(0); end;\n if t[1].x<>t[2].x then begin writeln('Impossible'); halt(0); end;\n inc(c[t[1].y,t[2].y],t[1].x);\n inc(c[t[2].y,t[1].y],t[1].x);\n ans[1]:=c[1,2];\n ans[2]:=c[2,3];\n ans[3]:=c[3,1];\n writeln(ans[1],' ',ans[2],' ',ans[3]);\n end."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a, b, c, x, y, z : longint;\n\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output); }\n readln(a, b, c);\n if (a+b+c) mod 2 > 0\n then begin\n writeln('Impossible');\n exit;\n end;\n\n x := (b+a-c)div 2;\n y := (b+c-a)div 2;\n z := (c+a-b)div 2;\n if (x<0) or (y<0) or (z<0) or (x+y = 0) or (x+z = 0) or (y+z = 0)\n then begin\n writeln('Impossible');\n exit;\n end;\n writeln(x, ' ', y, ' ', z);\nend.\n"}, {"source_code": "program zzz;\n var a,b,c:longint;\n\n begin\n\n read(a,b,c);\n\n if (a<=(b+c)) and (b<=(a+c)) and (c<=(a+b)) and ((a+b+c) mod 2=0)\n then write((b+a-c) div 2,' ',(b+c-a) div 2,' ',(c+a-b) div 2)\n else write('Impossible')\n\n end."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if (j+k+l = i) then\n if (l>=0) then\n if (k>=0) then\n if (j>=0) then\n writeln(l,' ',j,' ',k) else writeln('Impossible') else writeln('Impossible')\n else writeln('Impossible') else writeln('Impossible')\nend."}, {"source_code": "var s,a,b,c,x,y,z,o,q:longint;\nbegin\nreadln(a,b,c);\ns:=a+b+c;\no:=s;\no:=o div 2;\n if (o+o=s)\n then begin\n x:=o-c;\n y:=o-a;\n z:=o-b;\n if (x=0) and (y=0)\n then begin\n Writeln('Impossible');\n q:=1;\n end\n else begin\n if (x=0) and (z=0)\n then begin\n Writeln('Impossible');\n q:=1;\n end\n else begin\n if (y=0) and (z=0)\n then begin\n Writeln('Impossible');\n q:=1;\n end\n else begin\n if (x<0) or (y<0) or (z<0)\n then begin\n Writeln('Impossible');\n q:=1;\n end;\n end;\n end;\n end;\n if q<1\n then begin\nwriteln(x,' ',y,' ',z);\nend;\nend\n else begin\n Writeln('Impossible');\n end;\nend.\n\n"}, {"source_code": "Var a,b,c,s:int64;\n begin\n Read(a,b,c);\n s:=a+b+c;\n if s mod 2=1 then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n s:=s div 2;\n if (c>s) or (b>s) or (a>s) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n Writeln(s-c,' ',s-a,' ',s-b);\n end."}, {"source_code": "const\n fil='';\nvar\n f:text;\n a,b,c:longint;\n x,y,z:real;\nbegin\n assign(f,fil);\n reset(f);\n readln(f,b,c,a);\n x:=(b-c+a)/2;\n y:=(c+b-a)/2;\n z:=(c-b+a)/2;\n if (frac(x)=0)and(x>=0)and(y>=0)and(z>=0) then writeln(y:0:0,' ',z:0:0,' ',x:0:0)\n else writeln('Impossible');\n close(f);\nend."}, {"source_code": "program yan;\n var a,b,c,i,j,x,y,a1,b1,c1:longint;\nbegin\n read(a,b,c); a1:=a; b1:=b; c1:=c;\n if (a>b)and(a>c) then begin x:=a; a:=0; end\n else\n if (b>a)and(b>c) then\n begin x:=b; b:=0; end else begin x:=c; c:=0; end;\n if (x>a+b+c)or((a+b+c-x)mod 2<>0) then write('Impossible')\n else\n begin\n y:=x+((a+b+c-x)div 2);\n write(y-c1,' ',y-a1,' ',y-b1);\n end;\nend."}, {"source_code": "program z1;\nvar a,b,c,a1,b1,c1,n,v12,v23,v13,i,ai,bi,ci,j,d,e,f:longint;\nZ:array[1..3,1..2] of longint;\nbegin\n{assign(input,'d:\\FPC\\input.txt');\nreset(input);\nassign(output,'d:\\FPC\\output.txt');\nrewrite(output);}\nread(a,b,c);\nif (a+bb+c)or(b>a+c)or(c>a+b))or((a+b+c) mod 2=1) then writeln('Impossible')\nelse\n begin\n for i:=0 to a do\n if i>b then break\n else\n begin\n c1:=(a-i)+(b-i);\n if c=c1 then\n begin\n writeln(i,' ',b-i,' ',a-i);\n break;\n end;\n end;\n end;\nclose(input);close(output);\nend."}, {"source_code": "var\n\ta1,a2,a3,a4,b,c,k,s : longint;\n\t\n\nbegin\n\treadln(a1,b,c);\n\ts:=a1+b+c;\n\tif (s mod 2<>0) then k:=1;\n\ts:=(a1+b+c) div 2;\n\ta2:=s-c;\n\ta3:=s-a1;\n\ta4:=s-b;\n\tif (a4<0) or (a3<0) or (a2<0) then k:=1;\n\tif k=0 then writeln(a2,' ',a3,' ',a4)\n\telse writeln('Impossible');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar f,g:text;\n a,b,c,x,y,z,tg:longint;\nprocedure mo;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fo);\n rewrite(g);\nend;\nprocedure dong;\nbegin\n close(f);\n close(g);\nend;\nprocedure doc;\nbegin\n read(f,a,b,c);\n readln(f);\n tg:=a+b+c;\n if tg mod 2=1 then\n begin\n write(g,'Impossible');\n dong;\n halt;\n end;\n tg:=tg div 2;\n x:=tg-c;\n y:=tg-b;\n z:=tg-a;\n if (x<0)or(y<0)or(z<0) then\n begin\n write(g,'Impossible');\n dong;\n halt;\n end;\n write(g,x,' ',z,' ',y);\nend;\nbegin\n mo;\n doc;\n dong;\nend."}, {"source_code": "var a,b,c,d,k,l:integer;\nbegin\nread(a,b,c);\nd:=a;\nk:=0;\nl:=l;\nif dc then \n else if d=c then begin\n write(b,' ',k,' ',c);\n l:=1;\n end\n else begin\n d:=d+1;\n b:=b-1;\n k:=k+1;\n c:=c-1;\n end;\n if d>c then write('Impossible'); \n end\nelse if d=b then begin\n d:=d-a;\n while(d<=c)and(l<1)do if d>c then \n else if d=c then begin\n write(a,' ',c,' ',k);\n l:=1;\n end\n else begin\n d:=d+1;\n a:=a-1;\n k:=k+1;\n c:=c-1;\n end;\n if d>c then write('Impossible') ; \n end\nelse if d=c then begin\n d:=d-a;\n while(d<=b)and(l<1)do if d>b then \n else if d=b then begin\n write(k,' ',b,' ',a);\n l:=1;\n end\n else begin\n d:=d+1;\n a:=a-1;\n k:=k+1;\n b:=b-1;\n end;\n if d>b then write('Impossible'); \n end;\nend."}, {"source_code": "{$MODE OBJFPC}\n\nconst\n maxN = 10000;\n fi = 'B.INP';\n fo = 'B.OUT';\n\nvar\n a, b, c : integer;\n\nprocedure enter;\nvar\n x1, x2, x3 : integer;\nbegin\n readln(a,b,c);\n x2 := (b - a + c);\n if (x2 < 0) or (x2 mod 2 <> 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n x2 := x2 div 2;\n x3 := c - x2;\n if x3 < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n x1 := a - x3;\n if x1 < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n writeln(x1, ' ',x2,' ',x3);\nend;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n{$ENDIF}\n enter;\nend."}, {"source_code": "var a:array[1..3] of longint;\n i,x12,x23,x31:longint;\nbegin\nread(a[1],a[2],a[3]);\nfor i:=0 to a[1] do\n begin\n if a[3]-i=a[2]-a[1]+i then\n begin\n x12:=a[1]-i;\n x23:=a[2]-a[1]+i;\n x31:=i;\n if (x12<0)or(x23<0)or(x31<0) then continue;\n write(a[1]-i,' ',a[2]-a[1]+i,' ',i);\n halt;\n end;\n end;\nwriteln('Impossible');\nend."}, {"source_code": "var a,b,c,x,y,z:longint;\nbegin\n readln(a,b,c);\n if (a+b0) then\n writeln('Impossible')\n else\n writeln((a+b-c)>>1,' ',(-a+b+c)>>1,' ',(+a-b+c)>>1);\nend."}, {"source_code": "var\n a,b,c,q:longint;\nbegin\n read(a,b,c);\n for q:=0 to a do\n if (a-q+b-q=c)and(((b-q>0)and(a-q>0))or((b-q=0)xor(a-q=0))) then\n begin\n write(q,' ',b-q,' ',a-q);\n exit;\n end;\n write('Impossible');\nend."}, {"source_code": "var a,b,c,i,j,aa:longint;\nfunction min(a,b:longint):longint;\nbegin\nif a0 then begin\n writeln('Impossible');\n halt\n end\n else begin\n s:=(a+b+c) div 2;\n if (s>a) and (s>b) and (s>c) then\n writeln(s-c,' ',s-a,' ',s-b)\n else if (s=a) and (s>b) and (s>c) then\n writeln(s-c,' ',s-a,' ',s-b)\n else if (s>a) and (s=b) and (s>c) then\n writeln(s-c,' ',s-a,' ',s-b)\n else if (s>a) and (s>b) and (s=c) then\n writeln(s-c,' ',s-a,' ',s-b)\n else\n writeln('Impossible');\n end;\nend.\n"}, {"source_code": "var a,b,c,x,y,z:longint;\nbegin\n readln(a,b,c);\n x:=b-c+a;\n y:=b+c-a;\n z:=a-b+c;\n if (x<0) or (y<0) or (z<0) or (x and 1=1) or (y and 1 = 1) or (z and 1 =1) then\n begin\n writeln('Impossible');\n exit;\n end;\n writeln(x div 2,' ',y div 2,' ',z div 2);\nend."}, {"source_code": "var a, b, c, ac, ab, bc:longint; \nbegin\nreadln(a, b, c);\nac:=0; bc:=0; ab:=0;\nwhile (a>0)and(b>0)and(c>0) do \n begin\n if (a>=b)and(c>=b)and(a<>0)and(c<>0) then begin\n inc(ac);\n dec(a);dec(c)\n end;\n if (c>=a)and(b>=a)and(b<>0)and(c<>0) then begin\n inc(bc);\n dec(b);dec(c)\n end;\n if (a>=c)and(b>=c)and(a<>0)and(b<>0) then begin\n inc(ab);\n dec(a);dec(b)\n end; \n end;\nif a=0 then if (b=c) then writeln(ab, ' ', bc++b, ' ', ac)\n else writeln('Impossible')\n else if b=0 then if (a=c) then writeln(ab, ' ', bc, ' ', ac+a)\n else writeln('Impossible')\n else if c=0 then if (a=b) then writeln(ab+b, ' ', bc, ' ', ac)\n else writeln('Impossible'); \nend."}, {"source_code": "var\n a,b:array[1..3] of longint;\n x,i,j,x1,x2,x3:longint;\n\nbegin\n for i:=1 to 3 do begin read(a[i]); b[i]:=i; end;\n if (a[1]+a[2]+a[3]) mod 2<>0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do for j:=i+1 to 3 do\n if (a[i]>a[j]) then\n begin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n x:=b[i]; b[i]:=b[j]; b[j]:=x;\n end;\n if (a[3]>a[1]+a[2]) then begin writeln('Impossible'); exit; end;\n x1:=-(a[3]-a[1]-a[2]) div 2;\n x2:=a[2]-x1;\n x3:=a[1]-x1;\n if (b[1]=1) and (b[2]=2) then writeln(x1,' ',x2,' ',x3);\n if (b[1]=1) and (b[2]=3) then writeln(x3,' ',x2,' ',x1);\n if (b[1]=2) and (b[2]=1) then writeln(x1,' ',x3,' ',x2);\n if (b[1]=2) and (b[2]=3) then writeln(x3,' ',x1,' ',x2);\n if (b[1]=3) and (b[2]=1) then writeln(x2,' ',x3,' ',x1);\n if (b[1]=3) and (b[2]=2) then writeln(x3,' ',x1,' ',x2);\nend."}, {"source_code": "Var a, b, c, i, j, k : longint;\nBegin\n readln(a,b,c);\n for i:=0 to a do begin\n k := a-i;\n j := b-i;\n if (j = c-k) and (j >= 0) and (k >= 0) then begin\n writeln(i,' ',j,' ',k);\n exit;\n end;\n end;\n writeln('Impossible');\nEnd.\n"}, {"source_code": "var\n a, b, c, d, e, f: int64;\n \nbegin\n readln(a, b, c);\n if (a > b) and (a > c) then begin\n if b + c < a then begin\n writeln('Impossible');\n halt();\n end;\n if (b + c - a) mod 2 = 1 then begin\n writeln('Impossible');\n halt();\n end;\n writeln(b - (b + c - a) div 2, ' ', (b + c - a) div 2,' ', c - (b + c - a) div 2);\n end\n else if (b >= a) and (b > c) then begin\n if a + c < b then begin\n writeln('Impossible');\n halt();\n end;\n if (a + c - b) mod 2 = 1 then begin\n writeln('Impossible');\n halt();\n end;\n writeln(a - (a + c - b) div 2, ' ', c - (a + c - b) div 2,' ', (a + c - b) div 2);\n end\n else begin\n if b + a < c then begin\n writeln('Impossible');\n halt();\n end;\n if (b + a - c) mod 2 = 1 then begin\n writeln('Impossible');\n halt();\n end;\n writeln((b + a - c) div 2, ' ', b - (b + a - c) div 2,' ', a - (b + a - c) div 2);\n end;\nend. "}, {"source_code": "var a,b,c,x,y,z:longint;\n\nprocedure xuat;\nbegin\n\n writeln('Impossible');\n halt;\nend;\n\nprocedure xuly;\nvar tg:longint;\nbegin\n\n readln(a,b,c);\n\n tg:=a-b+c;\n\n if (tg mod 2<>0) or (tg<0) then xuat;\n z:=tg div 2;\n\n y:=c-z;\n if y<0 then xuat;\n\n x:=a-z;\n if x<0 then xuat;\n\n writeln(x,' ',y,' ',z);\nend;\n\nbegin\n\n xuly;\nend.\n\n\n\n\n"}, {"source_code": "program TaskB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\nvar\n a, b, c, i: integer;\nbegin\n read(a, b, c);\n for i := 0 to Min(a, b) do\n begin\n if (c = a - i + b - i) then\n begin\n write(i, ' ', b - i, ' ', a - i);\n halt;\n end;\n end;\n write('Impossible');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) and (a <= b+c-2) and (b <= a+c-2) and (c <= a+b-2) do\n begin\n //if ((a >= b+c-2) or (b >= a+c-2) or (c >= a+b-2)) then\n //break;\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar\n a, b, c, i : integer;\n\nbegin\n readln(A, b, c);\n for i := 0 to a do\n if (b - i >=0) and (c - a + i >= 0) and (b - i = c - (a - i)) then begin\n writeln(i, ' ', b - i, ' ', a - i);\n readln;\n readln;\n halt(0);\n end;\n writeln('Impossible');\nend."}, {"source_code": "program Project_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, x: integer;\nbegin\n readln(a, b, c);\n if ((a > b + c) or (b > a + b) or (c > a + b)) then\n begin\n writeln('Impossible');\n exit;\n end;\n//--------------\n if ((a >= b) and (a >= c)) then\n begin\n if ((odd(a) and (not odd(b+c))) or ((not odd(a)) and (odd(b+c)))) then\n begin\n writeln('Impossible');\n exit;\n end;\n x := (b + c - a) div 2;\n if ((b - x < 0) or (c - x < 0) or (x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end;\n writeln(b - x,' ',x,' ',c - x);\n readln;\n exit;\n end;\n//--------------\n if ((b >= a) and (b >= c)) then\n begin\n if ((odd(b) and (not odd(a+c))) or ((not odd(b)) and (odd(a+c)))) then\n begin\n writeln('Impossible');\n exit;\n end;\n x := (a + c - b) div 2;\n if ((a - x < 0) or (c - x < 0) or (x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end;\n writeln(a - x,' ',c - x,' ',x);\n readln;\n exit;\n end;\n//--------------\nif ((c >= a) and (c >= a)) then\n begin\n if ((odd(c) and (not odd(a+b))) or ((not odd(c)) and (odd(a+b)))) then\n begin\n writeln('Impossible');\n exit;\n end;\n x := (a + b - c) div 2;\n if ((a - x < 0) or (b - x < 0) or (x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end;\n writeln(x,' ',b - x,' ',a-x);\n readln;\n exit;\n end;\n//--------------\nend."}, {"source_code": "var a,b,c,s1,s2,s3: longint;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n read(a,b,c);\n\n s1:=a+b-c; s2:=b+c-a; s3:=a+c-b;\n if (s1 mod 2<>0) or (s2 mod 2<>0) or (s3 mod 2<>0) or\n (s1<0) or (s2<0) or (s3<0) or (s1=0) and (s2=0) or \n (s2=0) and (s3=0) or (s1=0) and (s3=0)\n then begin writeln('Impossible'); halt end;\n\n writeln(s1 div 2,' ',s2 div 2,' ',s3 div 2);\nend."}, {"source_code": "type maxx=array[1..100000] of string;\nvar ch:char;a,b,g,xv,l,c,i,n,k,z,a1,b1,c1,w,code,j,q:integer;s,s1:string;m:maxx;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n readln(a,b,c);\n if (a+b=0) or (a+c=0) or (c+b=0)\n then Begin\n writeln('Impossible');\n halt(0);\n end;\n if (a>=c) and (a>=b)\n then BEgin\n if b+c>=a\n then if (b+c-a) mod 2=0\n then writeln(b-(b+c-a) div 2,' ',(b+c-a) div 2,' ',c-(b+c-a) div 2)\n else writeln('Impossible')\n else writeln('Impossible');\n end\n else if (b>=a) and (b>=c)\n then Begin\n if a+c>=b\n then if (a+c-b) mod 2=0\n then writeln(a-(a+c-b) div 2,' ',c-(a+c-b) div 2,' ',(a+c-b) div 2)\n else writeln('Impossible')\n else writeln('Impossible');\n end\n else Begin\n if a+b>=c\n then if (a+b-c) mod 2=0\n then writeln((a+b-c) div 2,' ',b-(a+b-c) div 2,' ',a-(a+b-c) div 2)\n else writeln('Impossible')\n else writeln('Impossible');\n end;\nend.\n"}, {"source_code": "var a,b,c,x12,x13,x23:longint;\nbegin\n readln(a,b,c);\n if (a+b+c) mod 2<>0 then writeln('Impossible')\n else if (a+b0) and (b>0) and (c>0) and ((a+b+c) mod 2 = 0) then\n\tbegin\n\tt:=(a+b+c) div 2;\n\tx:=t-c;\n\ty:=t-a;\n\tz:=t-b;\n\tif (x>=0) and (y>=0) and (z>=0) then\n\tbegin\n\twrite(x,' ',y,' ',z);\n\twriteln;\n\tend\n\telse\n\twriteln('Impossible');\n\tend\n\telse\n\twriteln('Impossible');\nend."}, {"source_code": "\n {$APPTYPE CONSOLE}\nconst besk=2000000000000000000;\ntype ex=record t,v:int64; end; exx=^ex;\n label 1,2,3,4;\nvar shag,k,nn,n,i10,razn,n1,dl,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,i,j,isp,finish:longint;\np3,p,pos,x,y,z,q,a1,leng,t3,kol,cc,m1,pl,sum,p1,p2,m,k2,r,ot,aa,bb,x1,y1,x0,y0,ll,rr,d1,d2,kolvyk,xx2,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\naeqb,agrb,bgra,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndist:array[-10..3010,-10..3010] of int64;\nddd,distot:double;\nl,t,dv,c,b,a,zz: array[-300000..500000] of int64;\nest,zapx,zapy:array[-10..20000] of boolean;\ndd,gr: array[-20..20,0..10,-50..2000] of int64;\nee,deg,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss1,sss,sss2:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nstepen:array[0..1000] of int64;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\nbegin\n {assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000009 ;\n\n readln(p1,p2,p3); flag:=true;\n t1:=p1+p2-p3; t2:=p1+p3-p2;t3:=p3+p2-p1;\nif odd(t1) then flag:=false;\nif odd(t2) then flag:=false;\nif odd(t3) then flag:=false;\nif t1<0 then flag:=false; if t2<0 then flag:=false;if t3<0 then flag:=false;\n\nif flag then write(t1 div 2,' ',t3 div 2,' ',t2 div 2) else write('Impossible');\n\n\n\n 1: close(output);\n\nend.\n"}, {"source_code": "program b1;\n\n{$APPTYPE CONSOLE}\n\nvar\n x1, x2, x3, a1, a2, a3: Integer;\n\nbegin\n\n readln(x1, x2, x3);\n a1 := 0;\n a2 := 0;\n a3 := 0;\n if odd(x1 + x2 + x3) then\n begin\n Writeln('Impossible');\n Exit;\n end;\n\n while (x1 + x2 + x3 > 0) do\n begin\n if ((x1 + x2) <= 0) or ((x1 + x3) <= 0) or((x3 + x2) <= 0)then\n begin\n Writeln('Impossible');\n Exit;\n end;\n if (x3 <= x2) and (x3 <= x1) then\n begin\n Dec(x2);\n Dec(x1);\n Inc(a1);\n end\n else\n if (x2 <= x1) and (x2 <= x3) then\n begin\n Dec(x3);\n Dec(x1);\n Inc(a3);\n end\n else\n if (x1 <= x2) and (x1 <= x3) then\n begin\n Dec(x2);\n Dec(x3);\n Inc(a2);\n end;\n end;\n Writeln(a1, ' ', a2, ' ', a3);\nend.\n "}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n, res, a, b, c: integer;\n s, k: string;\n\nbegin\n readln(a, b, c);\n\n for i := 0 to a do\n if ((b - i) + (a - i) = c)and(b - i >= 0)and(a - i >= 0) then\n begin\n write(i, ' ', b - i, ' ', a - i);\n halt(0);\n end;\n\n write('Impossible');\nend.\n"}, {"source_code": "uses\n math;\nvar\n i,a,b,c:longint;\n arr:array[1..3,1..3] of longint;\nbegin\n readln(a,b,c);\n for i:=0 to a do\n begin\n arr[1][2]:=i;\n arr[1][3]:=a-i;\n arr[2][1]:=i;\n if b-i>=0 then\n begin\n arr[2][3]:=b-i;\n arr[3][1]:=a-i;\n arr[3][2]:=b-i;\n if a+b-2*i=c then\n begin\n writeln(arr[1,2],' ',arr[2,3],' ',arr[3,1]);\n halt;\n end;\n end;\n end;\n writeln('Impossible');\nend. "}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, i, k: integer;\nbegin\n read(a, b, c);\n\n if (a > b) then\n k := b\n else\n k := a;\n\n\n for i := 0 to k do\n begin\n if (c = a - i + b - i) then\n begin\n write(i, ' ', b - i, ' ', a - i);\n readln;\n readln;\n halt;\n end;\n end;\n writeln('Impossible');\n readln;\n readln;\nend.\n"}, {"source_code": "var\n a,b,c,i,k1,k2,k3,max,min,min2:integer;\nbegin\nk3:=0;\n readln(a,b,c);\n if a+b>c then begin\n while a+b>c do begin\n a:=a-1;\n b:=b-1;\n inc(k3);\n end;\n end;\n k2:=b;\n k1:=a;\n if (a+b1 then\n begin\n write ('Impossible');\n halt;\n end;\n if ( l >= 0) then\n begin\n if l = a[1] then a[1]:=-1000000\n else\n if l=a[2] then a[2]:=-1000000\n else\n if l=a[3] then a[3]:=-1000000;\n end\n else\n begin\n write('Impossible');\n halt;\n end;\nif ( k >= 0) then\n begin\n if k = a[1] then a[1]:=-1000000\n else\n if k=a[2] then a[2]:=-1000000\n else\n if k=a[3] then a[3]:=-1000000;\n end\n else\n begin\n write('Impossible');\n halt;\n end;\nif ( p >= 0) then\n begin\n if p = a[1] then a[1]:=-1000000\n else\n if p=a[2] then a[2]:=-1000000\n else\n if p=a[3] then a[3]:=-1000000;\n end\n else\n begin\n write('Impossible');\n halt;\n end;\n for i:=1 to 3 do\n if a[i] <> -1000000 then\n begin\n write('Impossible');\n halt;\n end;\n write (x3,' ',x2,' ',x1);\nend."}, {"source_code": "var a,b,c:int64;\n i:longint;\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n {$endif}\n readln(a,b,c);\n for i:=0 to a do\n if(i<=b)and(c-a+i=b-i) then begin writeln(i,' ',b-i,' ',c-a+i); exit; end;\n writeln('Impossible');\nend."}, {"source_code": "Uses Math;\nVar a,b,c,i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n //ReWrite (output,'output.txt');\n Readln (a,b,c);\n For I:=0 to Max (a,b)-1 do\n If a-i+b-i=c\n then Begin\n Writeln (i,' ',b-i,' ',a-i);\n Halt (0);\n End;\n Writeln ('Impossible');\nEnd."}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-b+c) div 2;\n res[3]:=pr1;\n res[2]:=c-pr1;\n res[1]:=a-res[3];\n end else\n begin\n if ((b-a+c) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(b-a+c) div 2;\n res[2]:=pr1;\n res[3]:=c-pr1;\n res[1]:=a-res[3];\n end;\n if p=2 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-c+b) div 2;\n res[1]:=pr1;\n res[2]:=c-pr1;\n res[3]:=a-res[3];\n end else\n begin\n if ((c-a+b) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-a+b) div 2;\n res[2]:=pr1;\n res[1]:=c-pr1;\n res[3]:=a-res[3];\n end;\n if p=1 then\n if b0) then begin writeln('Impossible'); exit; end else pr1:=(b-c+a) div 2;\n res[1]:=pr1;\n res[3]:=c-pr1;\n res[2]:=a-res[3];\n end else\n begin\n if ((c-b+a) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-b+a) div 2;\n res[3]:=pr1;\n res[1]:=c-pr1;\n res[2]:=a-res[3];\n end;\n for i:=1 to 3 do\n if res[i]<0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n write(res[i],' ');\n end.\n"}, {"source_code": "var a:array[1..4] of longint;\n n,i,j,c,a1,a2,a3:longint;\nbegin\n read(a[1],a[2],a[3]);\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then\n begin\n c:=a[i];\n a[i]:=a[j];\n a[j]:=c;\n end;\n for i:=0 to a[1] do\n begin\n a1:=a[1];\n a2:=a[2];\n a3:=a[3];\n dec(a1,i);\n dec(a2,i);\n if (a1<0) or (a2<0) then begin write('Impossible'); exit; end;\n if a1+a2=a3 then\n begin\n write(i,' ',a2,' ',a3-a2);\n exit;\n end;\n end;\n write('Impossible');\nend."}, {"source_code": "var\n\ta,b,c,t,s12,s23,s31:longint;\nprocedure oo;\nbegin \n\twriteln('Impossible');\n\thalt;\nend;\nbegin \n\treadln(a,b,c);\n\tif (a>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tif (b>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse \n\t\tif (c>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif b>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tbegin \n\t\t\tif a+b=c then \n\t\t\t\tbegin \n\t\t\t\ts12:=0;s23:=b;s31:=a;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif a+c=b then \n\t\t\t\tbegin \n\t\t\t\ts12:=a;s23:=c;s31:=0;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif b+c=a then\n\t\t\t\tbegin \n\t\t\t\ts12:=b;s23:=0;s31:=c;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif (a=b) and (b=c) and (not odd(a)) then \n\t\t\t\tbegin \n\t\t\t\t\ts12:=a>>1;s23:=a>>1;s31:=a>>1;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\too;\n\t\tend;\n\twriteln(s12,' ',s23,' ',s31);\nend."}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=a+b-c;\n y:=b-x;\n z:=c-y;\n Print;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n a, id : array[1..3] of integer;\n cs : array[1..3, 1..3] of integer;\n i, tmp, j : integer;\nbegin\n fillchar(cs, sizeof(Cs), 0);\n\n for i := 1 to 3 do\n begin\n read(a[i]);\n\n\n id[i] := i;\n end;\n\n for i := 1 to 3 do\n for j := 1 to 2 do\n if a[j] < a[j + 1] then\n begin\n tmp := a[j];\n a[j] := a[j + 1];\n a[j + 1] := tmp;\n tmp := id[j];\n id[j] := id[j + 1];\n id[j + 1] := tmp;\n end;\n\n if a[1] mod 2 = 0 then\n begin\n cs[id[1], id[2]] := a[1] div 2;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2);\n dec(a[3], a[1] div 2);\n end\n else\n begin\n cs[id[1], id[2]] := a[1] div 2 + 1;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2 + 1;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2 + 1);\n dec(a[3], a[1] div 2);\n end;\n a[1] := 0;\n if (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n\n cs[id[2], id[3]] := a[2];\n cs[id[3], id[2]] := a[2];\n dec(a[3], a[2]);\n if a[3] < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n\n if (a[1] < 0) or (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n writeln(cs[1, 2],' ',cs[2, 3],' ',cs[3, 1]);\nend.\n\n"}, {"source_code": "uses math;\nvar f1:text;a,b,c,x,y,z:longint;\nbegin\n assign(f1,'');reset(f1);\n read(f1,a,b,c);\n x:=(a+b-c)div 2;\n y:=b-x;\n z:=a-x;\n if ((x>=0)or(y>=0)or(z>=0))and((x+y=b)and(y+z=c)and(x+z=a)) then write(x,' ',y,' ',z) else\n write('Impossible'); \nend.\n"}, {"source_code": "program zzz;\n var a,b,c:longint;\n\n begin\n\n read(a,b,c);\n\n if (a<=(b+c)) and (b<=(a+c)) and (c<=(a+b)) and ((a+b+c) mod 2=0)\n then write((b+a-c) div 2,' ',(c+a-b) div 2,' ',(b+c-a) div 2)\n else write('Impossible')\n\n end."}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then\n if (k>0) then\n if (j>0) then\n writeln(l,' ',j,' ',k) else writeln('impossible');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar x,y:array[1..4] of integer;\n max,s,i,z: integer;\nbegin\n readln(x[1],x[2],x[3]);\n x[4]:=x[1];\n if x[1]>x[2] then max:=1 else max:=2;\n if x[3]>max then max:=3;\n s:=0;\n for i:=1 to 3 do\n if i<>max then s:=s+x[i];\n z:=s-x[max];\n if (z<0)or(z mod 2<>0) then writeln('Impossible')\n else begin\n z:=z div 2;\n y[max]:=x[max+1]-z;\n i:=(max+2) mod 3;\n if i=0 then i:=3;\n y[i]:=x[i]-z;\n i:=(max+1) mod 3;\n if i=0 then i:=3;\n y[i]:=z;\n writeln(y[1],' ',y[2],' ',y[3]);\n end;\nend.\n"}, {"source_code": "var x,y,z:longint;\n s1,s2,s3:real;\nbegin\n read(x,y,z);\n s1:=(x+y-z)/2;\n s2:=(y+z-x)/2;\n s3:=(z+x-y)/2;\n if(s1<0)or(s2<0)or(s3<0) then\n write('Impossible')\n else\n write(s1:1:0,' ',s2:1:0,' ',s3:1:0);\nend."}, {"source_code": "var\n a,b,c:array [1..3] of Longint;\n ans:array [1..3,1..3] of Longint;\n AA,BB,CC,x,y,i,j,M,Z:Longint;\n F:Boolean;\nbegin\n Readln(AA,BB,CC);\n a[1]:=AA;\n b[1]:=1;\n a[2]:=BB;\n b[2]:=2;\n a[3]:=CC;\n b[3]:=3;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then begin\n M:=a[i];\n Z:=b[i];\n a[i]:=a[j];\n b[i]:=b[j];\n a[j]:=M;\n b[j]:=Z;\n end;\n x:=a[3] div 2;\n y:=a[3]-x-1;\n Inc(x);\n F:=False;\n while (x>=0) and (Y<=a[3]) do\nbegin\n Inc(y);\n Dec(x);\n z:=a[2]-y;\n if (x+z=a[1]) and (y+z=a[2]) then begin\n F:=True;\n Break;\n end;\n end;\n ans[b[1],b[3]]:=y;\n ans[b[3],b[1]]:=y;\n ans[b[1],b[2]]:=z;\n ans[b[2],b[1]]:=z;\n ans[b[2],b[3]]:=x;\n ans[b[3],b[2]]:=x;\n if (x<0) or (y<0) or (z<0) then F:=False;\n if F then Writeln(ans[1,2],' ',ans[1,3],' ',ans[2,3])\n else Writeln('Impossible');\n end."}, {"source_code": "{$MODE OBJFPC}\nvar\n a, id : array[1..3] of integer;\n cs : array[1..3, 1..3] of integer;\n i, tmp, j : integer;\nbegin\n fillchar(cs, sizeof(Cs), 0);\n\n for i := 1 to 3 do\n begin\n read(a[i]);\n\n\n id[i] := i;\n end;\n\n for i := 1 to 3 do\n for j := 1 to 2 do\n if a[j] < a[j + 1] then\n begin\n tmp := a[j];\n a[j] := a[j + 1];\n a[j + 1] := tmp;\n tmp := id[j];\n id[j] := id[j + 1];\n id[j + 1] := tmp;\n end;\n\n if a[1] mod 2 = 0 then\n begin\n cs[id[1], id[2]] := a[1] div 2;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2);\n dec(a[3], a[1] div 2);\n end\n else\n begin\n cs[id[1], id[2]] := a[1] div 2 + 1;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2 + 1;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2 + 1);\n dec(a[3], a[1] div 2);\n end;\n\n if (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n\n cs[id[2], id[3]] := a[2];\n cs[id[3], id[2]] := a[2];\n dec(a[3], a[2]);\n if a[3] < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n\n writeln(cs[1, 2],' ',cs[2, 3],' ',cs[3, 1]);\nend.\n"}, {"source_code": "var\n a,b,c:array [1..3] of Longint;\n ans:array [1..3,1..3] of Longint;\n AA,BB,CC,x,y,i,j,M,Z:Longint;\n F:Boolean;\nbegin\n Readln(AA,BB,CC);\n a[1]:=AA;\n b[1]:=1;\n a[2]:=BB;\n b[2]:=2;\n a[3]:=CC;\n b[3]:=3;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then begin\n M:=a[i];\n Z:=b[i];\n a[i]:=a[j];\n b[i]:=b[j];\n a[j]:=M;\n b[j]:=Z;\n end;\n x:=a[3] div 2;\n y:=a[3]-x-1;\n Inc(x);\n F:=False;\n while (x>=0) and (Y<=a[3]) do\nbegin\n Inc(y);\n Dec(x);\n z:=a[2]-y;\n if (x+z=a[1]) and (y+z=a[2]) then begin\n F:=True;\n Break;\n end;\n end;\n ans[b[1],b[3]]:=y;\n ans[b[3],b[1]]:=y;\n ans[b[1],b[2]]:=z;\n ans[b[2],b[1]]:=z;\n ans[b[2],b[3]]:=x;\n ans[b[3],b[2]]:=x;\n if (x<0) or (y<0) or (z<0) then F:=False;\n if F then Writeln(ans[1,2],' ',ans[1,3],' ',ans[2,3])\n else Writeln('Impossible');\n end."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if (j+k+l = i) then\n if (l>0) then\n if (k>0) then\n if (j>0) then\n writeln(l,' ',j,' ',k) else writeln('impossible');\nend.\n"}, {"source_code": "var a,b,c,i:longint;\nbegin\n read(a,b,c);\n for i:=0to a do\n begin\n if(b-i<=0)or(c-b+i<=0)then break;\n if c-b+i+i=a then\n begin\n write(i,' ',b-i,' ',c-b+i);\n halt;\n end;\n end;\n write('Impossible')\nend."}, {"source_code": "var\n\ta,b,c,t,s12,s23,s31:longint;\nprocedure oo;\nbegin \n\twriteln('Impossible');\n\thalt;\nend;\nbegin \n\treadln(a,b,c);\n\tif (a>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tif (b>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse \n\t\tif (c>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif b>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tbegin \n\t\t\tif a+b=c then \n\t\t\t\tbegin \n\t\t\t\ts12:=0;s23:=b;s31:=a;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif a+c=b then \n\t\t\t\tbegin \n\t\t\t\ts12:=a;s23:=c;s31:=0;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif b+c=a then\n\t\t\t\tbegin \n\t\t\t\ts12:=b;s23:=0;s31:=c;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif (a=b) and (b=c) and (not odd(a)) then \n\t\t\t\tbegin \n\t\t\t\t\ts12:=a>>1;s23:=a>>1;s31:=a>>1;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\too;\n\t\tend;\n\twriteln(s12,' ',s23,' ',s31);\nend."}, {"source_code": "const ou='Impossible';\nvar f1,f2:text;a,b,c,x,y,z:longint;s:string;\nprocedure rd;\nbegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,a,b,c);\n close(f1);\nend;\nprocedure wk;\nbegin\n if (a+b+c) mod 2<>0 then begin s:=ou;exit;end else\n begin\n if ((a-b+c)div 2)>=0 then z:=(a-b+c)div 2 else begin s:=ou;exit;end;\n if (c-z)>=0 then y:=c-z else begin s:=ou;exit;end;\n if (c-b)>=0 then x:=c-b else begin s:=ou;exit;end;\n end;\nend;\nprocedure et;\nbegin\n if s='' then write(f2,x,' ',y,' ',z) else write(f2,s);\n close(f2);\nend;\nbegin\n rd;\n wk;\n et;\nend.\n"}, {"source_code": "program prog;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils, Math;\n\nvar a, b, c, x, y, z, s: integer;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n read(a, b, c);\n s:= a + b + c;\n if s mod 2 = 1 then write('Impossible') else begin\n s:= s div 2;\n x:= s - c;\n y:= s - a;\n z:= s - b;\n write(x, ' ', y, ' ', z);\n end;\n\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "var\nbol:boolean;\ni,x,j,q:longint;\na,b:Array[-10..100]of longint;\nbegin\nfor i:=1 to 3 do begin\n read(A[i]);\n b[i]:=i;\nend;\nfor i:=1 to 2 do\nfor j:=i+1 to 3 do\nif a[i]>a[j] then begin\n x:=a[i];\n a[i]:=a[j];\n a[j]:=x;\n\n x:=a[i];\n b[i]:=b[j];\n b[j]:=x;\nend;\nif a[1]+a[2]=0)and(a[2]-q>=0)and(a[1]-i=a[2]-q) then begin\n bol:=true;\n if b[3]=1 then begin\n if b[1]=2 then begin\n write(i,' ',a[1]-i,' ',q);\n end\n else begin\n write(q,' ',a[1]-i,' ',i);\n end;\n end\n else\n if b[3]=2 then begin\n if b[1]=1 then\n write(a[1]-i,' ',q,' ',a[2]-q)\n else\n write(q,' ',i,' ',a[1]-i);\n end\n else\n if b[3]=3 then begin\n if b[1]=1 then write(a[1]-i,' ',q,' ',i)\n else\n write(a[1]-i,' ',i,' ',q);\n end;\n end;\n end;\n if bol=false then writeln('Impossible');\n end;\n//end;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n i,j,n,m,k:Integer;\n g,h,r:Int64;\n a,b,c,d:Char;\nbegin\n Readln(n,m,k);\n if (n>m+k) or (m>n+k) or (k>n+m) then\n begin\n write('Impossible');\n Exit;\n end;\n for i:=0 to n do\n if (n-i+(m-i)=k) then\n begin\n write(i,' ',m-i,' ',n-i);\n Readln;\n Exit;\n end;\n Readln;\n Readln;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n a, id : array[1..3] of integer;\n cs : array[1..3, 1..3] of integer;\n i, tmp, j : integer;\nbegin\n fillchar(cs, sizeof(Cs), 0);\n\n for i := 1 to 3 do\n begin\n read(a[i]);\n\n\n id[i] := i;\n end;\n\n for i := 1 to 3 do\n for j := 1 to 2 do\n if a[j] < a[j + 1] then\n begin\n tmp := a[j];\n a[j] := a[j + 1];\n a[j + 1] := tmp;\n tmp := id[j];\n id[j] := id[j + 1];\n id[j + 1] := tmp;\n end;\n\n if a[1] mod 2 = 0 then\n begin\n cs[id[1], id[2]] := a[1] div 2;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2);\n dec(a[3], a[1] div 2);\n end\n else\n begin\n cs[id[1], id[2]] := a[1] div 2 + 1;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2 + 1;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2 + 1);\n dec(a[3], a[1] div 2);\n end;\n\n if (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n\n cs[id[2], id[3]] := a[2];\n cs[id[3], id[2]] := a[2];\n dec(a[3], a[2]);\n if a[3] < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n\n writeln(cs[1, 2],' ',cs[2, 3],' ',cs[3, 1]);\nend.\n"}, {"source_code": "program yan;\n var a,b,c,i,j,x,y,a1,b1,c1:longint;\nbegin\n read(a,b,c); a1:=a; b1:=b; c1:=c;\n if (a>b)and(a>c) then begin x:=a; a:=0; end\n else\n if (b>a)and(b>c) then\n begin x:=b; b:=0; end else begin x:=c; c:=0; end;\n if (x>a+b+c)or((a1=b1)and(b1=c1)and(b1 mod 2<>0)) then write('Impossible')\n else\n begin\n y:=x+((a+b+c-x)div 2);\n write(y-c1,' ',y-a1,' ',y-b1);\n end;\nend.\n"}, {"source_code": "program yan;\n var a,b,c,i,j,x,y,a1,b1,c1:longint;\nbegin\n read(a,b,c); a1:=a; b1:=b; c1:=c;\n if (a>b)and(a>c) then begin x:=a; a:=0; end\n else\n if (b>a)and(b>c) then\n begin x:=b; b:=0; end else begin x:=c; c:=0; end;\n if (x>a+b+c)or((a1=b1)and(b1=c1)and(b1 mod 2<>0)) then write('Impossible')\n else\n begin\n y:=x+((a+b+c-x)div 2);\n write(y-c1,' ',y-a1,' ',y-b1);\n end;\nend.\n"}, {"source_code": "program zzz;\n var a,b,c:longint;\n\n begin\n\n read(a,b,c);\n\n if (a<=(b+c)) and (b<=(a+c)) and (c<=(a+b)) and ((a+b+c) mod 2=0)\n then write((b+c-a) div 2,' ',(c+a-b) div 2,' ',(b+a-c) div 2)\n else write('Impossible')\n\n end."}, {"source_code": "program p;\nvar a1,a2,a3,x1,x2,x3:integer;\nbegin\nreadln(a1,a2,a3);\nx1:=(a1+a2-a3) div 2;\nx2:=(a2+a3-a1) div 2;\nx3:=(a3+a1-a2) div 2;\nif ((x1<0) or (x2<0) or (x3<0)) or ((x1+x2=0)or(x1+x3=0)or(x2+x3=0)) then\nwriteln('Impossible')\nelse\nwriteln(x1,' ',x2,' ',x3);\nend."}, {"source_code": "VAR A1,A2,A3,S,X12,X23,X31:LONGINT;\nBEGIN\n READLN(A1,A2,A3);\n IF A1+A2+A3 MOD 2=1 THEN WRITE('Impossible')\n ELSE\n BEGIN\n S:=(A1+A2+A3) DIV 2;\n X12:=S-A3;X23:=S-A1;X31:=S-A2;\n IF (X12<0)OR(X23<0)OR(X31<0) THEN WRITE('Impossible')\n ELSE WRITELN(X12,' ',X23,' ',X31);\n END;\nEND.\n"}, {"source_code": "var\na,b,c,x,y,z:longint;\nbegin\n readln(a,b,c);\n x:= (a+b-c)div 2; \n y:=b-x;\n z:=c-y;\n if (x <0) or (y<0) or (z<0) or ((a+b-c) mod 2 =1) or (x+y=0) or (x+z=0) or (y+z=0) then\n writeln('Impossible')\n else\n writeln(x,' ',y,' ',z);\nend.\n"}, {"source_code": "var a,b,c, max, ans, x,y,z: LongInt;\nbegin\n Readln(a,b,c);\n if (a>b+c) or (b>a+c) or (c>a+b) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n \n if a>b then\n begin\n max:=a;\n ans:=b+c;\n end\n else\n begin\n max:=b;\n ans:=a+c;\n end;\n \n if c>max then\n begin\n max:=c;\n ans:=a+b;\n end;\n \n x:=(ans-max) div 2 + max - c;\n y:=(ans-max) div 2 + max - a;\n z:=(ans-max) div 2 + max - b;\n \n if (x<0) or (y<0) or (z<0) or ((x=0) and (y=0)) or ((y=0) and (z=0)) or ((z=0) and (x=0)) or ((x=0) and (y=0) and (z=0)) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n\n Writeln(x,' ',y,' ',z);\nend."}, {"source_code": "program prog;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils, Math;\n\nvar a, b, c, x, y, z, s: integer;\n\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n read(a, b, c);\n s:= a + b + c;\n if s mod 2 = 1 then write('Impossible') else begin\n s:= s div 2;\n x:= s - c;\n y:= s - a;\n z:= s - b;\n write(x, ' ', y, ' ', z);\n end;\n\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-b+c) div 2;\n res[3]:=pr1;\n res[2]:=c-pr1;\n res[1]:=a-res[3];\n end else\n begin\n if ((b-a+c) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(b-a+c) div 2;\n res[2]:=pr1;\n res[3]:=c-pr1;\n res[1]:=a-res[3];\n end;\n if p=2 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-c+b) div 2;\n res[1]:=pr1;\n res[2]:=c-pr1;\n res[3]:=a-res[3];\n end else\n begin\n if ((c-a+b) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-a+b) div 2;\n res[2]:=pr1;\n res[1]:=c-pr1;\n res[3]:=a-res[3];\n end;\n if p=1 then\n if b0) then begin writeln('Impossible'); exit; end else pr1:=(b-c+a) div 2;\n res[1]:=pr1;\n res[3]:=c-pr1;\n res[2]:=a-res[3];\n end else\n begin\n if ((c-b+a) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-b+a) div 2;\n res[3]:=pr1;\n res[1]:=c-pr1;\n res[2]:=a-res[3];\n end;\n for i:=1 to 3 do\n if res[i]<0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n write(res[i],' ');\n end.\n"}, {"source_code": "var a,b,c:int64;\n i:longint;\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n {$endif}\n readln(a,b,c);\n for i:=0 to a do\n if(i<=b)and(c-a+i=b-i) then begin writeln(i,' ',b-i,' ',c-a+i); exit; end;\n writeln('Impossible');\nend."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n writeln(i);\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if j+k+l = i then\n writeln(j,' ',k,' ',l) else writeln('impossible');\nend.\n"}, {"source_code": "program p;\nvar a1,a2,a3,x1,x2,x3:integer;\nbegin\nreadln(a1,a2,a3);\nx1:=(a1+a2-a3) div 2;\nx2:=(a2+a3-a1) div 2;\nx3:=(a3+a1-a2) div 2;\nif ((x1<0) or (x2<0) or (x3<0)) or ((x1+x2=0)or(x1+x3=0)or(x2+x3=0)) then\nwriteln('Impossible')\nelse\nwriteln(x1,' ',x2,' ',x3);\nend."}, {"source_code": "var\n n,m,k,l,w,s,j,a,b,c,a1,b1,c1,p1,p2,p3,i:longint;\nbegin\n readln(a,b,c);\n if (a+b+c)mod 2<>0 then begin writeln('Impossible'); halt; end;\n for i:=0 to 1000000 do\n begin\n if (i>a)or(i>b) then break;\n a1:=i;\n c1:=a-a1;\n if c1>c then break;\n b1:=c-c1;\n if b1+a1=b then begin writeln(a1,' ',b1,' ',c1); halt; end;\n end;\n writeln('Impossible');\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n a, id : array[1..3] of integer;\n cs : array[1..3, 1..3] of integer;\n i, tmp, j : integer;\nbegin\n fillchar(cs, sizeof(Cs), 0);\n\n for i := 1 to 3 do\n begin\n read(a[i]);\n\n\n id[i] := i;\n end;\n\n for i := 1 to 3 do\n for j := 1 to 2 do\n if a[j] < a[j + 1] then\n begin\n tmp := a[j];\n a[j] := a[j + 1];\n a[j + 1] := tmp;\n tmp := id[j];\n id[j] := id[j + 1];\n id[j + 1] := tmp;\n end;\n\n if a[1] mod 2 = 0 then\n begin\n cs[id[1], id[2]] := a[1] div 2;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2);\n dec(a[3], a[1] div 2);\n end\n else\n begin\n cs[id[1], id[2]] := a[1] div 2 + 1;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2 + 1;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2 + 1);\n dec(a[3], a[1] div 2);\n end;\n\n if (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n\n cs[id[2], id[3]] := a[2];\n cs[id[3], id[2]] := a[2];\n dec(a[3], a[2]);\n if a[3] < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n\n writeln(cs[1, 2],' ',cs[2, 3],' ',cs[3, 1]);\nend.\n"}, {"source_code": "var\n a,b:array[1..3] of longint;\n x,i,j,x1,x2,x3:longint;\n\nbegin\n for i:=1 to 3 do begin read(a[i]); b[i]:=i; end;\n if (a[1]+a[2]+a[3]) mod 2<>0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do for j:=i+1 to 3 do\n if (a[i]>a[j]) then\n begin\n x:=a[i]; a[i]:=a[j]; a[j]:=x;\n x:=b[i]; b[i]:=b[j]; b[j]:=x;\n end;\n if (a[3]>a[1]+a[2]) then begin writeln('Impossible'); exit; end;\n x1:=-(a[3]-a[1]-a[2]) div 2;\n x2:=a[2]-x1;\n x3:=a[1]-x1;\n if (b[1]=1) and (b[2]=2) then writeln(x1,' ',x2,' ',x3);\n if (b[1]=1) and (b[2]=3) then writeln(x3,' ',x2,' ',x1);\n if (b[1]=2) and (b[2]=1) then writeln(x1,' ',x3,' ',x2);\n if (b[1]=2) and (b[2]=3) then writeln(x2,' ',x3,' ',x1);\n if (b[1]=3) and (b[2]=1) then writeln(x3,' ',x1,' ',x2);\n if (b[1]=3) and (b[2]=2) then writeln(x2,' ',x1,' ',x3);\nend."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if (j+k+l = i) or (l<0) or (k<0) or (l<0) then\n writeln(l,' ',j,' ',k) else writeln('impossible');\nend.\n"}, {"source_code": "var a,b,c,i:longint;\nbegin\n read(a,b,c);\n for i:=0to a do\n begin\n if(b-i<=0)or(c-b+i<=0)then break;\n if c-b+i+i=a then\n begin\n write(i,' ',b-i,' ',c-b+i);\n halt;\n end;\n end;\n write('Impossible')\nend."}, {"source_code": "var x,y,z:longint;\n s1,s2,s3:real;\nbegin\n read(x,y,z);\n s1:=(x+y-z)/2;\n s2:=(y+z-x)/2;\n s3:=(z+x-y)/2;\n if (s1<0)or(s2<0)or(s3<0)or((s1<1)and(s2<1)and(s3<1)) then\n write('Impossible')\n else\n write(s1:1:0,' ',s2:1:0,' ',s3:1:0);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n a, id : array[1..3] of integer;\n cs : array[1..3, 1..3] of integer;\n i, tmp, j : integer;\nbegin\n fillchar(cs, sizeof(Cs), 0);\n\n for i := 1 to 3 do\n begin\n read(a[i]);\n\n\n id[i] := i;\n end;\n\n for i := 1 to 3 do\n for j := 1 to 2 do\n if a[j] < a[j + 1] then\n begin\n tmp := a[j];\n a[j] := a[j + 1];\n a[j + 1] := tmp;\n tmp := id[j];\n id[j] := id[j + 1];\n id[j + 1] := tmp;\n end;\n\n if a[1] mod 2 = 0 then\n begin\n cs[id[1], id[2]] := a[1] div 2;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2);\n dec(a[3], a[1] div 2);\n end\n else\n begin\n cs[id[1], id[2]] := a[1] div 2 + 1;\n cs[id[1], id[3]] := a[1] div 2;\n cs[id[2], id[1]] := a[1] div 2 + 1;\n cs[id[3], id[1]] := a[1] div 2;\n dec(a[2], a[1] div 2 + 1);\n dec(a[3], a[1] div 2);\n end;\n a[1] := 0;\n if (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n\n cs[id[2], id[3]] := a[2];\n cs[id[3], id[2]] := a[2];\n dec(a[3], a[2]);\n if a[3] < 0 then\n begin\n writeln('Impossible');\n halt;\n end;\n\n if (a[1] < 0) or (a[2] < 0) or (a[3] < 0) then\n begin\n writeln('Impossible');\n halt;\n end;\n writeln(cs[1, 2],' ',cs[2, 3],' ',cs[3, 1]);\nend.\n\n"}, {"source_code": "var\n a,b,c,i,k1,k2,k3,max,min,min2,l:integer;\nbegin\n readln(a,b,c);\n l:=0;\n if (a>b) and (a>c) then begin\n max:=a;\n min:=b;\n min2:=c;\n end\n else begin\n max:=b;\n min:=a;\n min2:=c;\n end;\n if (c>b) and (c>a) then begin\n max:=c;\n min:=b;\n min2:=a;\n end;\n if min+min2>=max then begin\n while min+min2>=max do begin\n if min+min2=max then begin\n k1:=min;\n k2:=min2;\n break;\n end;\n min:=min-1;\n min2:=min2-1;\n inc(k3);\n end;\n if min+min2=0)) then\n lol(i,b-i,a-i);\nend."}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (b+c-a)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(b+c-a)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (b+c-a)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(b+c-a)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=(a+b-c) div 2;\n y:=b-x;\n z:=c-y;\n Print;\nend.\n"}, {"source_code": "program Project_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a1, a2, a3, i, x, y: integer;\nprocedure swap(var x, y: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\nend;\nbegin\n readln(a1, a2, a3);\n if ((a1 > a2 + a3) or (a2 > a3 + a1) or (a3 > a2 + a1)) then\n begin\n writeln('Impossible');\n exit;\n end;\n if (a1 > a2) then\n swap(a1, a2);\n if (a2 > a3) then\n swap(a2, a3);\n if (a1 > a2) then\n swap(a1, a2);\n if (odd(a3)) then\n begin\n if (not odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n writeln(x,' ',a2 - x,' ',a1 -x);\n exit;\n end;\n end;\n end\n else\n begin\n if (odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n writeln(x,' ',a2 - x,' ',a1 -x);\n exit;\n end;\n end;\n end;\n readln;\nend."}, {"source_code": "program p;\nvar a1,a2,a3,x1,x2,x3:integer;\nbegin\nreadln(a1,a2,a3);\nx1:=(a1+a2-a3) div 2;\nx2:=(a2+a3-a1) div 2;\nx3:=(a3+a1-a2) div 2;\nif ((x1<0) or (x2<0) or (x3<0)) or ((x1+x2=0)or(x1+x3=0)or(x2+x3=0)) or (x1+x2+x3 = (a1+a2+a3)*2) then\nwriteln('Impossible')\nelse\nwriteln(x1,' ',x2,' ',x3);\nend."}, {"source_code": "program Project_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a1, a2, a3, i, x, y, i1, i2, i3, z1, z2, z3: integer;\nprocedure swap(var x, y, a, b: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\n z := a;\n a := b;\n b := z;\nend;\nbegin\n readln(a1, a2, a3);\n i1 := 1;\n i2 := 2;\n i3 := 3;\n if ((a1 + a2 < a3) or (a1 + a3 < a2) or (a2 + a3 < a1)) then\n begin\n writeln('Impossible');\n exit;\n end;\n if (a1 > a2) then\n swap(a1, a2, i1, i2);\n if (a2 > a3) then\n swap(a2, a3, i2, i3);\n if (a1 > a2) then\n swap(a1, a2, i1, i2);\n if (odd(a3)) then\n begin\n if (not odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n z1 := x;\n z2 := a2 - x;\n z3 := a1 - x;\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n if (i2 > i3) then\n swap(z2, z3, i2, i3);\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n writeln(z1,' ',z2,' ',z3);\n readln;\n exit;\n end;\n end;\n end\n else\n begin\n if (odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n z1 := x;\n z2 := a2 - x;\n z3 := a1 - x;\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n if (i2 > i3) then\n swap(z2, z3, i2, i3);\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n writeln(z1,' ',z2,' ',z3);\n readln;\n end;\n end;\n end;\n readln;\nend."}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (a+c-b)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(a+c-b)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "var x,y,z:longint;\n s1,s2,s3:real;\nbegin\n read(x,y,z);\n s1:=(x+y-z)/2;\n s2:=(y+z-x)/2;\n s3:=(z+x-y)/2;\n if (s1<0)or(s2<0)or(s3<0)or((s1<1)and(s2<1)and(s3<1)) then\n write('Impossible')\n else\n write(s1:1:0,' ',s2:1:0,' ',s3:1:0);\nend."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\ni:= (a+b+c)div 2;\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if j+k+l = i then\n writeln(l,' ',k,' ',j) else writeln('impossible');\nend.\n"}, {"source_code": "var a, b, c, x, y, z: longint;\n\nFunction Solve(a, b, c: longint): boolean;\nbegin\n if (bc) and (b-c<=a) and (a<=b+c) and ((a+b-c) mod 2 = 0)\n and ((a-b+c) mod 2 = 0) and ((-a+b+c) mod 2 = 0) then\n begin\n x:= (a+b-c) div 2;\n y:= (a-b+c) div 2;\n z:= (-a+b+c) div 2;\n end\n else if (b = c) and (a<=2*c) and (a mod 2 = 0) then\n begin\n x:= a div 2;\n y:= a div 2;\n z:= c - a div 2;\n end\n else\n begin\n exit(False);\n end;\n Solve:= True;\nend;\n\n\nbegin\n read(a,b,c);\n\n if Solve(a,b,c) then\n write(x,' ',y,' ',z)\n else if Solve(a,c,b) then\n write(x,' ',y,' ',z)\n else if Solve(b,a,c) then\n write(x,' ',y,' ',z)\n else if Solve(b,c,a) then\n write(x,' ',y,' ',z)\n else if Solve(c,a,b) then\n write(x,' ',y,' ',z)\n else if Solve(c,b,a) then\n write(x,' ',y,' ',z)\n else\n write('Impossible');\n\nend."}, {"source_code": "var a,b,c, max, ans, x,y,z: LongInt;\nbegin\n Readln(a,b,c);\n if (a=0) or (b=0) or (c=0) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n \n if a>b then\n begin\n max:=a;\n ans:=b+c;\n end\n else\n begin\n max:=b;\n ans:=a+c;\n end;\n \n if c>max then\n begin\n max:=c;\n ans:=a+b;\n end;\n \n x:=(ans-max) div 2 + max - c;\n y:=(ans-max) div 2 + max - a;\n z:=(ans-max) div 2 + max - b;\n \n if (((ans-max) div 2) <= 0) or (x<0) or (y<0) or (z<0) or (x=0) and (y=0) or (y=0) and (z=0) or (z=0) and (x=0) or (x=0) and (y=0) and (z=0) then\n begin\n Writeln('Impossible');\n halt(0);\n end;\n\n Writeln(x,' ',y,' ',z);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) and (a < b+c-2) and (b < a+c-2) and (c < a+b-2) do\n begin\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "var x,y,z:longint;\n s1,s2,s3:real;\nbegin\n read(x,y,z);\n s1:=(x+y-z)/2;\n s2:=(y+z-x)/2;\n s3:=(z+x-y)/2;\n if (s1<1)or(s2<1)or(s3<1) then\n write('Impossible')\n else\n write(s1:1:0,' ',s2:1:0,' ',s3:1:0);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b,c,i:longint;\n\nbegin\n read(a,b,c);\n for i:=0 to c do\n if abs(i-a) = abs(c-i-b) then\n begin\n writeln(abs(i-a),' ',c-i,' ',i);\n halt;\n end;\n writeln('Impossible');\nend.\n"}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=(a+b-c) div 2;\n y:=b-x;\n z:=c-y;\n Print;\nend.\n"}, {"source_code": "var\n\ta,b,c,t,s12,s23,s31:longint;\nprocedure oo;\nbegin \n\twriteln('Impossible');\n\thalt;\nend;\nbegin \n\treadln(a,b,c);\n\tif (a>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin \n\t\t\ts31:=a;\n\t\t\ts23:=c-a;\n\t\t\ts12:=0;\n\t\t\tt:=b-c+a;\n\t\t\tif odd(t) then oo;\n\t\t\tdec(s31,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend;\n\t\tend\n\t\telse\n\t\tif (b>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin \n\t\t\ts23:=b;\n\t\t\ts31:=c-b;\n\t\t\ts12:=0;\n\t\t\tt:=a-c+b;\n\t\t\tif odd(t) then oo;\n\t\t\tdec(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend;\n\t\tend\n\t\telse \n\t\tif (c>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tbegin \n\t\t\ts23:=c;\n\t\t\ts12:=b-c;\n\t\t\ts31:=0;\n\t\t\tt:=a-b+c;\n\t\t\tif odd(t) then oo;\n\t\t\tdec(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend;\n\t\tend\n\t\telse\n\t\tbegin \n\t\t\tif a+b=c then \n\t\t\t\tbegin \n\t\t\t\ts12:=0;s23:=b;s31:=a;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif a+c=b then \n\t\t\t\tbegin \n\t\t\t\ts12:=a;s23:=c;s31:=0;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif b+c=a then\n\t\t\t\tbegin \n\t\t\t\ts12:=b;s23:=0;s31:=c;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\too;\n\t\tend;\n\twriteln(s12,' ',s23,' ',s31);\nend."}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-b+c) div 2;\n res[3]:=pr1;\n res[2]:=c-pr1;\n res[1]:=a-res[3];\n end else\n begin\n if ((b-a+c) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(b-a+c) div 2;\n res[2]:=pr1;\n res[3]:=c-pr1;\n res[1]:=a-res[3];\n end;\n if p=2 then\n if a0) then begin writeln('Impossible'); exit; end else pr1:=(a-c+b) div 2;\n res[1]:=pr1;\n res[2]:=b-pr1;\n res[3]:=c-res[3];\n end else\n begin\n if ((c-a+b) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-a+b) div 2;\n res[2]:=pr1;\n res[1]:=b-pr1;\n res[3]:=a-res[3];\n end;\n if p=1 then\n if b0) then begin writeln('Impossible'); exit; end else pr1:=(b-c+a) div 2;\n res[1]:=pr1;\n res[3]:=a-pr1;\n res[2]:=c-res[3];\n end else\n begin\n if ((c-b+a) mod 2<>0) then begin writeln('Impossible'); exit; end else pr1:=(c-b+a) div 2;\n res[3]:=pr1;\n res[1]:=a-pr1;\n res[2]:=b-res[3];\n end;\n if (res[3]+res[1]<>a)or(res[1]+res[2]<>b)or(res[2]+res[3]<>c) then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n if res[i]<0 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do\n write(res[i],' ');\n end.\n"}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if j+k+l = i then\n writeln(l,' ',j,' ',k) else writeln('impossible');\nend.\n"}, {"source_code": "var a,b,c,d,k,l:integer;\nbegin\nread(a,b,c);\nd:=a;\nk:=0;\nl:=l;\nif dc then write('Impossible')\n else while(d<=c)and(l<1)do if d>c then write('Impossible')\n else if d=c then begin\n write(b,' ',k, ' ',c);\n l:=1;\n end\n else begin\n d:=d+1;\n b:=b-1;\n k:=k+1;\n c:=c-1;\n end;\n end;\nif d=b then begin\n d:=d-a;\n if d>c then write('Impossible')\n else while(d<=c)and(l<1)do if d>c then write('Impossible')\n else if d=c then begin\n write(a, ' ',c, ' ',k);\n l:=1;\n end\n else begin\n d:=d+1;\n a:=a-1;\n k:=k+1;\n c:=c-1;\n end;\n end;\nif d=c then begin\n d:=d-a;\n if d>b then write('Impossible')\n else while(d<=c)and(l<1)do if d>b then write('Impossible')\n else if d=b then begin\n write(k, ' ',b, ' ',a);\n l:=1;\n end\n else begin\n d:=d+1;\n a:=a-1;\n k:=k+1;\n b:=b-1;\n end;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) and (a < b+c-2) and (b < a+c-2) and (c < a+b-2) do\n begin\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "var s, i, a, b, c, x, y, z : longint;\nfunction kt : boolean;\n begin\n kt := false;\n if x + y + z = s then\n if a = z + x then\n if b = x + y then\n if c = y + z then\n kt := true;\n end;\nbegin\n readln(a, b, c);\n s := (a + b + c) div 2;\n for x := 0 to a do\n begin\n y := b-x;\n z := a-x;\n if kt and (y >0) and (z > 0) then\n begin\n writeln(x,' ',y,' ',z);\n halt;\n end;\n end;\n writeln('Impossible');\nend."}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (b+c-a)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(b+c-a)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "const fi = '';\n fo = '';\ntype int = longint;\nvar a,b,c : int;\n max,sum,min : int;\n d : array[1..3] of int;\n\n{}\nprocedure xl;\nvar t: int;\nbegin\n if (sum mod 2=1) or (sum-maxb then min := b;\n if maxc then min := c;\n sum := a+b+c;\n xl;\n close(input); close(output);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n, res, a, b, c: integer;\n s, k: string;\n\nbegin\n readln(a, b, c);\n\n for i := 0 to a do\n if ((b - i) + (a - i) = c)and(b - i > 0)and(a - i > 0) then\n begin\n write(i, ' ', b - i, ' ', a - i);\n halt(0);\n end;\n\n\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\ntype int = longint;\nvar a,b,c : int;\n max,sum,min : int;\n d : array[1..3] of int;\n\n{}\nprocedure xl;\nvar t: int;\nbegin\n if (sum mod 2=1) or (sum-maxb then min := b;\n if maxc then min := c;\n sum := a+b+c;\n xl;\n close(input); close(output);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) do\n begin\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) do\n begin\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "program Project_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a1, a2, a3, i, x, y, i1, i2, i3, z1, z2, z3: integer;\nprocedure swap(var x, y, a, b: integer);\nvar\n z: integer;\nbegin\n z := x;\n x := y;\n y := z;\n z := a;\n a := b;\n b := z;\nend;\nbegin\n readln(a1, a2, a3);\n i1 := 1;\n i2 := 2;\n i3 := 3;\n if (a1 > a2) then\n swap(a1, a2, i1, i2);\n if (a2 > a3) then\n swap(a2, a3, i2, i3);\n if (a1 > a2) then\n swap(a1, a2, i1, i2);\n if (odd(a3)) then\n begin\n if (not odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n z1 := x;\n z2 := a2 - x;\n z3 := a1 - x;\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n if (i2 > i3) then\n swap(z2, z3, i2, i3);\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n writeln(z1,' ',z2,' ',z3);\n readln;\n exit;\n end;\n end;\n end\n else\n begin\n if (odd(a1 + a2)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n x := (a1 + a2 - a3) div 2;\n if ((a1 - x < 0) or (a2 - x < 0)) then\n begin\n writeln('Impossible');\n exit;\n end\n else\n begin\n z1 := x;\n z2 := a2 - x;\n z3 := a1 - x;\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n if (i2 > i3) then\n swap(z2, z3, i2, i3);\n if (i1 > i2) then\n swap(z1, z2, i1, i2);\n writeln(z1,' ',z2,' ',z3);\n readln;\n end;\n end;\n end;\n readln;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, k, v1, v2, v3: integer;\n //a: array of integer;\n flag : boolean;\n\nbegin\n v1 := 0;\n v2 := 0;\n v3 := 0;\n flag := false;\n read (a, b, c);\n readln;\n if ((a+b+c) mod 2 = 0) and (a > 0) and (b > 0) and (c > 0) then\n begin\n k := 0;\n while (a > 1) and (b > 1) and (c > 1) do\n begin\n k := k+1;\n a := a-2;\n b := b-2;\n c := c-2;\n end;\n if (a = b+c) then\n begin\n v1 := b + k;\n v2 := k;\n v3 := c + k;\n flag := true;\n end\n else if (b = a+c) then\n begin\n v1 := a + k;\n v2 := c + k;\n v3 := k;\n flag := true;\n end\n else if (c = a+b) then\n begin\n v1 := k;\n v2 := b + k;\n v3 := a + k;\n flag := true;\n end;\n end;\n if (flag) then\n writeln (v1, ' ', v2, ' ', v3)\n else\n writeln ('Impossible');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n, res, a, b, c: integer;\n s, k: string;\n\nbegin\n readln(a, b, c);\n\n for i := 0 to a do\n if ((b - i) + (a - i) = c)and(b - i > 0)and(a - i > 0) then\n begin\n write(i, ' ', b - i, ' ', a - i);\n halt(0);\n end;\n\n write('Impossible');\nend."}, {"source_code": "VAR a,b,c,d,x,y,z,m:dword;\nBEGIN\nreadln(a,b,c);\nd:=a+b+c;\nif d mod 2=0 then begin\n m:=d div 2;\n x:=m-a;\n y:=m-b;\n z:=m-c;\n if (x>=0) and (y>=0) and (z>=0) then writeln(z,' ',x,' ',y)\n else writeln('Impossible');\nend else writeln('Impossible');\nEND."}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if av2+v3 then imp;\n if v2>v1+v3 then imp;\n if v3>v1+v2 then imp;\n s12:=(sum-2*v3) div 2;\n s31:=(sum-2*v2) div 2;\n s23:=(sum-2*v1) div 2;\n write(s12,' ',s23,' ',s31)\nEnd.\n"}, {"source_code": "Uses Math;\nVar a,b,c,i:LongInt;\nBegin\n //ReSet (input,'input.txt');\n //ReWrite (output,'output.txt');\n Readln (a,b,c);\n For I:=0 to Max (a,b)-1 do\n If a-i+b-i=c\n then Begin\n Writeln (i,' ',b-i,' ',a-i);\n Halt (0);\n End;\n Writeln ('Impossible');\nEnd."}, {"source_code": "program ideone;\nvar a,b,c,d : integer;\nbegin\n readln(a,b,c);\n d:= (a+b+c) div 2;\n if ((d-c)>=0) and (d-a>=0) and (d-b>=0) and ((a+b+c) mod 2 = 0) then\n writeln(d-c,' ',d-a,' ',d-b) else writeln('Imposible');\nend."}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=(a+b-c) div 2;\n y:=b-x;\n z:=c-y;\n if (x>=0)and(y>=0)and(z>=0) then\n Write(x,' ',y,' ',z) else Write('Impossible');\nend.\n"}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=(a+b-c) div 2;\n y:=b-x;\n z:=c-y;\n if ((x>=0)and(y>0)and(z>0))or\n ((x>0)and(y>=0)and(z>0))or\n ((x>0)and(y>0)and(z>=0))then\n Write(x,' ',y,' ',z) else Write('Impossible');\nend.\n"}, {"source_code": "program cf_200_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n v,v1,v2,s,v3,s1,s2,s3,t,i,d:LongInt;\nbegin\n Readln(v1,v2,v3); t:=0;\n v:=v1+v2+v3;\n s:=v div 2;\n if v mod 2 =1 then t:=1;\n if (v1+v20 then begin writeln('Impossible'); exit; end;\n for i:=1 to 3 do for j:=i+1 to 3 do\n if (a[i]>a[j]) then\n begin\n y:=a[i]; a[i]:=a[j]; a[j]:=y;\n y:=b[i]; b[i]:=b[j]; b[j]:=y;\n end;\n if (a[3]>a[1]+a[2]) then begin writeln('Impossible'); exit; end;\n if (b[3]=1) then\n begin\n x[1]:=(a[3]+1) div 2; x[2]:=(a[1]+a[2]-a[3]) div 2; x[3]:=a[3] div 2;\n if (b[2]=3) then begin y:=x[1]; x[1]:=x[3]; x[3]:=y; end;\n end;\n if (b[3]=2) then\n begin\n x[1]:=(a[3]+1) div 2; x[3]:=(a[1]+a[2]-a[3]) div 2; x[2]:=a[3] div 2;\n if (b[2]=3) then begin y:=x[1]; x[1]:=x[2]; x[2]:=y; end;\n end;\n if (b[3]=3) then\n begin\n x[2]:=(a[3]+1) div 2; x[1]:=(a[1]+a[2]-a[3]) div 2; x[3]:=a[3] div 2;\n if (b[2]=1) then begin y:=x[2]; x[2]:=x[3]; x[3]:=y; end;\n end;\n for i:=1 to 3 do write(x[i],' ');\nend."}, {"source_code": "var a,b,c,i:longint;\nbegin\n read(a,b,c);\n for i:=0to a do\n if c-b+i+i=a then\n begin\n write(i,' ',b-i,' ',c-b+i);\n halt;\n end;\n write('Impossible')\nend."}, {"source_code": "program p2;\nvar a,b,c,max:longint;\nbegin\nread(a,b,c);\nIf a>b then max:=a else max:=b;\nIf max(a+b+c) then writeln('Impossible') else\nwrite((a+b-c) div 2,' ',(b+c-a) div 2,' ', (c+a-b) div 2);\nend.\n\n\n\n\n"}, {"source_code": "Var a,b,c,x,y,z:longint;\n Begin\n Read(a,b,c);\n if (a+c-b)mod 2<>0 then begin Write('Impossible');exit end;\n z:=(a+c-b)div 2;\n x:=a-z;\n y:=b-x;\n if (x<0)or(y<0)then Write('Impossible')\n else Write(x,' ',y,' ',z)\n End."}, {"source_code": "var a,b,c,z,x,y:longint;\nbegin\nreadln(a,b,c);\nz:=(b-a+c) div 2;\ny:=c-z;\nx:=a-y;\nif (a=b)and(b=c)and(c=a)and(a mod 2<>0) then begin writeln('Impossible') ;halt;end;\nif (x<0)or(y<0)or(z<0) then begin writeln('Impossible');halt;end;\n\nwriteln(x,' ',z,' ',y)\n\n\n\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nvar\n a, b, c, i : integer;\n\nbegin\n readln(A, b, c);\n for i := 0 to a do\n if (b - i > 0) and (c - a + i > 0) and (b - i = c - (a - i)) then begin\n writeln(i, ' ', b - i, ' ', a - i);\n readln;\n readln;\n halt(0);\n end;\n writeln('Impossible');\nend.\n"}, {"source_code": "var\n a,b,c:array [1..3] of Longint;\n ans:array [1..3,1..3] of Longint;\n AA,BB,CC,x,y,i,j,M,Z:Longint;\n F:Boolean;\nbegin\n Readln(AA,BB,CC);\n a[1]:=AA;\n b[1]:=1;\n a[2]:=BB;\n b[2]:=2;\n a[3]:=CC;\n b[3]:=3;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then begin\n M:=a[i];\n Z:=b[i];\n a[i]:=a[j];\n b[i]:=b[j];\n a[j]:=M;\n b[j]:=Z;\n end;\n x:=a[3] div 2;\n y:=a[3]-x-1;\n Inc(x);\n F:=False;\n while (x>=0) and (Y<=a[3]) do\nbegin\n Inc(y);\n Dec(x);\n z:=a[2]-y;\n if (x+z=a[1]) and (y+z=a[2]) then begin\n F:=True;\n Break;\n end;\n if (x+z=a[2]) and (y+z=a[1]) then begin\n F:=True;\n M:=x;\n x:=y;\n y:=M;\n Break;\n end;\n end;\n ans[b[1],b[3]]:=x;\n ans[b[3],b[1]]:=x;\n ans[b[1],b[2]]:=z;\n ans[b[2],b[1]]:=z;\n ans[b[2],b[3]]:=y;\n ans[b[3],b[2]]:=y;\n if (x<0) or (y<0) or (z<0) then F:=False;\n if F then Writeln(ans[1,2],' ',ans[1,3],' ',ans[2,3])\n else Writeln('Impossible');\n end."}, {"source_code": "var a,b,c,g,i,j,k,l : longint;\nbegin\n readln(a,b,c);\n i:= (a+b+c)div 2;\n writeln(i);\n j:= i-a;\n k:= i-b;\n l:= i-c;\n if j+k+l = i then\n writeln(j,' ',k,' ',l) else writeln('impossible');\nend.\n"}, {"source_code": "var\n a,b,c:array [1..3] of Longint;\n ans:array [1..3,1..3] of Longint;\n AA,BB,CC,x,y,i,j,M,Z:Longint;\n F:Boolean;\nbegin\n Readln(AA,BB,CC);\n a[1]:=AA;\n b[1]:=1;\n a[2]:=BB;\n b[2]:=2;\n a[3]:=CC;\n b[3]:=3;\n for i:=1 to 2 do\n for j:=i+1 to 3 do\n if a[i]>a[j] then begin\n M:=a[i];\n Z:=b[i];\n a[i]:=a[j];\n b[i]:=b[j];\n a[j]:=M;\n b[j]:=Z;\n end;\n x:=a[3] div 2;\n y:=a[3]-x-1;\n Inc(x);\n F:=False;\n while (x>=0) and (Y<=a[3]) do\nbegin\n Inc(y);\n Dec(x);\n z:=a[2]-y;\n if (x+z=a[1]) and (y+z=a[2]) then begin\n F:=True;\n Break;\n end;\n if (x+z=a[2]) and (y+z=a[1]) then begin\n F:=True;\n M:=x;\n x:=y;\n y:=M;\n Break;\n end;\n end;\n ans[b[1],b[3]]:=x;\n ans[b[3],b[1]]:=x;\n ans[b[1],b[2]]:=z;\n ans[b[2],b[1]]:=z;\n ans[b[2],b[3]]:=y;\n ans[b[3],b[2]]:=y;\n if (x<0) or (y<0) or (z<0) then F:=False;\n if F then Writeln(ans[1,2],' ',ans[1,3],' ',ans[2,3])\n else Writeln('Impossible');\n end."}, {"source_code": "var\n\ta,b,c,t,s12,s23,s31:longint;\nprocedure oo;\nbegin \n\twriteln('Impossible');\n\thalt;\nend;\nbegin \n\treadln(a,b,c);\n\tif (a>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tif (b>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif c>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse \n\t\tif (c>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s23,t>>1);\n\t\t\tend\n\t\t\telse\n\t\t\tif b>1);\n\t\t\tinc(s12,t>>1);\n\t\t\tinc(s31,t>>1);\n\t\t\tend\n\t\t\telse oo;\n\t\tend\n\t\telse\n\t\tbegin \n\t\t\tif a+b=c then \n\t\t\t\tbegin \n\t\t\t\ts12:=0;s23:=b;s31:=a;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif a+c=b then \n\t\t\t\tbegin \n\t\t\t\ts12:=a;s23:=c;s31:=0;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif b+c=a then\n\t\t\t\tbegin \n\t\t\t\ts12:=b;s23:=0;s31:=c;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tif (a=b) and (b=c) and (not odd(a)) then \n\t\t\t\tbegin \n\t\t\t\t\ts12:=a>>1;s23:=a>>1;s31:=a>>1;\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\too;\n\t\tend;\n\twriteln(s12,' ',s23,' ',s31);\nend."}, {"source_code": "var x1,x2,x3,a,b,c:longint;\nbegin\n read ( a, b , c );\n x1:= (c - a + b ) div 2;\n x2:=c - x1;\n x3:=b - x1;\n if ( x1 >= 0 ) and ( x2 >= 0) and (x3 >= 0 ) then write(x3,' ',x1,' ',x2)\n else write('Impossible');\nend."}, {"source_code": "program ideone;\nvar a,b,c,d : integer;\nbegin\n readln(a,b,c);\n d:= (a+b+c) div 2;\n if (d>=a) and (d>=b) and (d>=c) then\n writeln(d-c,' ',d-a,' ',d-b) else writeln('Impossible');\nend."}, {"source_code": "// hello\nvar\n z,y,x,i,a,b,c,y1:longint;\n\nProcedure Print;\nbegin\n Write(x,' ',y,' ',z);\n Halt;\nend;\n\nbegin\n Read(a,b,c);\n if (a+b-c) mod 2 = 1 then begin Write('Impossible');Halt end;\n x:=a+b-c;\n y:=b-x;\n z:=c-y;\n Print;\nend.\n"}, {"source_code": "var a,b,c,g,i,j,k : longint;\nbegin\n readln(a,b,c);\n if a>b then\n if a>c then\n g:=a;\n if b>a then\n if b>c then\n g:=b;\n if c>a then\n if c>b then\n g:=c;\n for i:= 0 to g do\n for j:= 0 to g do\n for k:= 0 to g do\n if i+j = a then\n if j+k = b then\n if k+i = c then\n writeln(j,' ',k,' ',i);\nend.\n"}, {"source_code": "var\n a,b,c,maxa,maxb,maxc,nmaxa,nmaxb,nmaxc,i,j,x,y,pr1,pr2,pr3,p,max:longint;\n numb,res:array[1..3] of longint;\nbegin\n readln(a,b,c);\n p:=3;\n max:=c;\n if b>max then begin max:=b; p:=2; end;\n if a>max then begin max:=a; p:=1; end;\n if p=3 then\n if a0) then\nbegin\nif(s[2]=' ') then delete(s,2,length(s)-1);\ndelete(s,3,length(s)-2);\nz:=strtoint(s);\nif(z=31) then writeln(7)\nelse\nif(z=30) then writeln(11)\nelse\nwriteln(12);\nend;\nif(pos(' of week',s)<>0) then\nbegin\ndelete(s,2,length(s)-1);\nz:=strtoint(s);\nif(z=0) then writeln(0);\nif(z=1) then writeln(52);\nif(z=2) then writeln(52);\nif(z=3) then writeln(52);\nif(z=4) then writeln(52);\nif(z=5) then writeln(53);\nif(z=6) then writeln(53);\nif(z=7) then writeln(52);\nend;\nend.\n\n\n"}, {"source_code": "var n,ans:word;\ns:string;\nbegin\nread(n);\nreadln(s);\n\nif pos('week',s)=0 then begin\n if n <30 then ans:=12 else\n if n=30 then ans:=11 else ans:=7;\nend else\nif (n=5) or (n=6) then ans:=53 else ans:=52;\nwrite(ans);\nend."}, {"source_code": "Program _611A;\nconst\n month : array [1..31] of byte = \n (12,12,12,12,12,12,12,12,12,12,\n 12,12,12,12,12,12,12,12,12,12,\n 12,12,12,12,12,12,12,12,12,11,7);\n week : array [1..7] of byte = (52,52,52,52,53,53,52); \nvar\n s : string;\n n, i, x, min : longint;\n cod : integer;\nbegin\n read(s);\n val(copy(s,1, Pos(' ',s)-1), x, cod);\n case s[length(s)] of\n 'k' : write (week[x]); \n 'h' : write (month[x]);\n end;\nend.\n"}, {"source_code": "var\n cur,s:string;\n i,ans, a, n: integer;\n procedure week(a:byte);\n Begin\n if (a=6)or(a=5) then Writeln(53) else Writeln(52);\n end;\n procedure month(a:byte);\n begin\n if a=30 then Writeln(11);\n if a=31 then Writeln(7);\n IF a<30 then Writeln(12);\n end;\nbegin\n read(a); Readln(s);\n n:=pos('week',s);\n if n=0 then month(a) else\n week(a);\nend."}, {"source_code": "program A_611;\n\nvar\n n:longint;\n s:string;\n\nbegin\n read(n);\n read(s);\n if s[5]='w'\n then case n of\n 5,6:write('53');\n 1..4,7:write('52');\n end\n else case n of\n 31:write('7');\n 30:write('11');\n 1..29:write('12');\n end;\nend."}, {"source_code": "var i,n,lik,kod,kol,t:longint;\ns,l:string;\na,b:array [0..1000] of longint;\nbegin\nb[1]:=31;\nb[2]:=29;\nb[3]:=31;\nb[4]:=30;\nb[5]:=31;\nb[6]:=30;\nb[7]:=31;\nb[8]:=31;\nb[9]:=30;\nb[10]:=31;\nb[11]:=30;\nb[12]:=31;\n\n\n\n\nreadln(s);\nif (s[2]=' ') then begin l:=s[1];delete(s,1,2);end else\nbegin l:=s[1]+s[2];delete(s,1,3);end;\nval(l,lik,kod);\nt:=4;\nfor i:=1 to 366 do\nbegin\ninc(t);\na[i]:=t;\nif (t>=7) then t:=0;\nend;\nif (s='of week') then\nbegin\nfor i:=1 to 366 do\nif (a[i]=lik) then inc(kol);\nend else\nif (s='of month') then\nbegin\nfor i:=1 to 12 do\nbegin\nif(b[i]>=lik) then inc(kol);\n\nend;\n\nend;\nwriteln(kol);\nend."}, {"source_code": "var s:string;\n x,i,ans:longint;\nbegin\nread(s);\nval(copy(s,1,pos(' ',s)-1),x,ans);\ndelete(s,1,pos(' ',s));\nif s='of week'\n then if (x=5) or (x=6) then ans:=53 else ans:=52\n else if x<30 then ans:=12\n else if x=30 then ans:=11\n else ans:=7;\nwrite(ans);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar a,i:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) or (a=6) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) then writeln(11) else\n if a=31 then writeln(7) else writeln(12)\nend."}, {"source_code": "var\n week:array[1..7] of longint=(52,52,52,52,53,53,52);\n month:array[1..31] of longint=(12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,7);\n s:string;\n k:longint;\nbegin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),k);\n if pos('m',s)<>0 then writeln(month[k])\n else writeln(week[k]);\nend."}, {"source_code": "var n,i,j,k:longint;\n a,b,c,d:char;\n s:string;\nbegin\n readln(n,a,b,c,d,s);\n if s='week' then\n begin\n if n=7 then\n begin\n writeln('52');\n end\n else if n=1 then\n begin\n writeln('52');\n end\n else if (n=2) or (n=3) or (n=4) then\n begin\n writeln('52');\n end\n else if (n=5) or (n=6) then\n begin\n writeln('53');\n end;\n\n end\n else\n begin\n if n<=29 then\n writeln('12')\n else if n=30 then\n writeln('11')\n else if n=31 then\n writeln('7');\n end;\nend.\n"}, {"source_code": "const\n month:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\n week:array['0'..'9'] of longint=(0,1,2,3,4,5,6,7,8,9);\n\nvar\n s:string;\n ans,i:longint;\n\nprocedure find1(x:longint);\nvar\n i,j,weekday:longint;\nbegin\n weekday:=5;\n for i:=1 to 366 do\n begin\n if weekday=x then inc(ans);\n inc(weekday);\n if weekday=8 then weekday:=1;\n end;\nend;\n\nprocedure find2;\nvar\n i,j,da:longint;\nbegin\n i:=1; da:=0;\n while s[i]<>' ' do\n begin\n da:=da*10+week[s[i]];\n inc(i);\n end;\n for i:=1 to 12 do\n for j:=1 to month[i] do\n if da=j then inc(ans);\nend;\n\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='w' then find1(week[s[1]]);\n if s[i]='m' then find2;\n end;\n write(ans);\nend.\n\n\n"}, {"source_code": "var n:longInt;\n s:string;\nBegin\n ReadLn(n,s);\n if(s=' of week')then\n begin\n if(n=1)then Write(52)\n else if(n=2)then Write(52)\n else if(n=3)then Write(52)\n else if(n=4)then Write(52)\n else if(n=5)then Write(53)\n else if(n=6)then Write(53)\n else if(n=7)then Write(52);\n end\n else\n begin\n if(n=31)then Write(7)\n else if(n=30)then Write(11)\n else Write(12)\n end;\nEnd."}, {"source_code": "{$mode objfpc}\nconst ztrong = 'sub trong contest ko AC, chep code hai ha';\nvar\n s:ansistring;\n res,date:int64;\n hihi, haha, huhu, hehe: integer;\n\nprocedure DealWithmonth;\nbegin\n if s[2]=' ' then res:=12\n else\n begin\n date:=(ord(s[1])-48)*10+ord(s[2])-48;\n if (10<=date) and (date<=29) then res:=12;\n if date=30 then res:=11;\n if date=31 then res:=7;\n end;\nend;\n\nprocedure DealWithWeek;\nbegin\n case s[1] of\n '1':res:=52;\n '2':res:=52;\n '3':res:=52;\n '4':res:=52;\n '5':res:=53;\n '6':res:=53;\n '7':res:=52;\n end;\nend;\n\nbegin\n read(s);\n if s[length(s)]='h' then dealwithmonth else DeaLWitHweek;\n writeln(res);\nend."}, {"source_code": "uses\n sysutils;\n \nvar\n option: Byte;\n day: Integer;\n str: String;\n i: Byte;\n temp: Byte;\n \nBEGIN\n ReadLn(str);\n \n if Pos('of week', str) <> 0 then\n begin\n day := StrToInt(str[1]);\n option := 1;\n end;\n \n if Pos('of month', str) <> 0 then\n begin\n i := 1;\n temp := 1;\n while str[i] <> ' ' do\n begin\n day := temp * day + StrToInt(str[i]);\n temp := temp * 10;\n inc(i);\n end;\n option := 2;\n end;\n \n Case option of\n 1 : begin\n if (day >= 1) and (day <= 4) then WriteLn('52');\n if (day >= 5) and (day <= 6) then WriteLn('53');\n if day = 7 then WriteLn('52');\n end;\n 2 : begin\n if (day >= 1) and (day <= 29) then WriteLn('12');\n if day = 30 then WriteLn('11');\n if day = 31 then WriteLn('7');\n end;\n end;\nEND."}, {"source_code": "var\n a, t : longint;\n s : string;\nbegin\n readln(a, s);\n if s[length(s)] = 'h' then\n begin\n if a <= 29 then t := 12 else\n if a = 30 then t := 11 else\n if a = 31 then t := 7;\n end else\n if s[length(s)] = 'k' then\n begin\n t := 52;\n if (a = 5) or (a = 6) then inc(t);\n end;\n writeln(t);\nend."}, {"source_code": "program ex611a;\nvar x,k:integer;\ns:string;\nbegin\nread (x);\nreadln (s);\nif s=' of week' then\ncase x of\n1,2,3,4,7 : k:=52;\n5,6 : k:=53;\nend;\nif s=' of month' then\ncase x of\n1..29 : k:=12;\n30 : k:=11;\n31 : k:=7;\nend;\nwriteln (k);\nend."}, {"source_code": "var k,n:byte;\n s:string;\nbegin\nread(k,s);\nif pos('w',s)<>0 then begin\nif k<5 then write(52) else\nif k<7 then write(53) else write(52);\nend else\nbegin\nif k<30 then write(12) else\nif k=30 then write(11) else\nwrite(7);\nend;\nend."}, {"source_code": "var\n week:array[0..7] of longint=(0,52,52,52,52,53,53,52);\n month:array[0..31] of longint=(0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,7);\n i,k,a:longint;\n t,r:string;\nbegin\n read(t);\n k:=pos(' ',t);\n r:=copy(t,1,k-1);\n val(r,a);\n delete(t,1,k);\n if t[4]='w' then write(week[a])\n else write(month[a]);\nend."}, {"source_code": "var\n\tx,y:string;\n\tn:integer;\n\nbegin\n\treadln(n,x);\n\tif pos('of month', x)>0 then\n\tbegin\n\t\tif n<=29 then writeln('12')\n\t\t\telse if n=30 then writeln('11')\n\t\t\t\telse if n=31 then writeln('7');\n\tend else if pos('of week', x)>0 then\n\tbegin\n\t\tif ((n=6)or(n=5)) then writeln('53')\n\t\t\telse writeln('52');\n\tend;\nend."}, {"source_code": "program zzz;\nconst\n FirstDay = 5;\n LastDay = 6;\n Months: array [1..12] of byte = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\nvar\n s: ansistring;\n x, i, kol: byte;\nbegin\n read(s);\n x := 0;\n i := 1;\n while (s[i] <> ' ') and (i <= Length(s)) do\n begin\n x := x * 10 + Ord(s[i]) - Ord('0');\n inc(i);\n end;\n kol := 0;\n case s[Length(s)] of\n 'h': for i := 1 to 12 do\n if x <= Months[i] then inc(kol);\n 'k': if (x < FirstDay) or (x > LastDay)\n then kol := 52\n else kol := 53;\n end;\n write(kol);\nend.\n"}, {"source_code": "{$mode objfpc}\n{$coperators on}\n{$macro on}\nuses math,sysutils;\nconst\n fin ='';//p611a.inp';\n fou ='';\n maxn = 366;\n base = trunc(1e9)+7;\ntype\n pair = record\n fi,se :longint;\n end;\n tag = record\n day,date :longint;\n end;\nvar\n n :longint=365;\n a :array[0..maxn] of tag;\n s :string;\n k1,k2 :array[0..31] of longint;\n maxdate :array[0..12] of longint=(31,31,29,31,30,31,30,31,31,30,31,30,31);\nprocedure enter;\nbegin\n readln(s);\nend;\n\nprocedure init;\nvar\n i,j,c :longint;\nbegin\n a[0].day:=3; a[0].date:=31;\n j:=1;\n c:=1;\n for i:=1 to 366 do\n begin\n a[i].day:=(a[i-1].day+1) mod 7;\n k1[a[i].day+1]+=1;\n a[i].date:=c;\n c+=1;\n k2[a[i].date]+=1;\n if a[i].date=maxdate[j] then\n begin\n j+=1;\n c:=1;\n end;\n end;\nend;\nprocedure solve;\nvar\n x,typ :string;\n i,num :longint;\nbegin\n init;\n i:=length(s);\n while s[i]<>' ' do\n begin\n typ:=s[i]+typ;\n i-=1;\n end;\n x:=copy(s,1,pos(' ',s)-1);\n num:=strtoint(x);\n if typ[1]='m' then writeln(k2[num])\n else writeln(k1[num]);\nend;\n\nBEGIN\n assign(input,fin); reset(input);\n assign(output,fou); rewrite(output);\n\n enter;\n solve;\n\n close(input);\n close(output);\nEND.\n"}, {"source_code": "var\n n,m,k,l,w,j:longint;\n s:string;\nbegin\n read(n);\n readln(s);\n if s[length(s)]='k' then\n begin\n l:=5;\n while k<366 do\n begin\n inc(k);\n if l=n then inc(w);\n inc(l);\n if l=8 then l:=1;\n end;\n writeln(w);\n end else\n begin\n if n<=29 then writeln(12) else\n if n=30 then writeln(11) else\n if n=31 then writeln(7);\n end;\nend.\n"}, {"source_code": "Program solu;\nVar\n Ch:string;\n N,e:longint;\nBegin\n Readln(ch);\n If ch[length(ch)]='k' then\n Begin\n Val(copy(ch,1,length(ch)-8),n,e);\n Case n of\n 5,6: write(53);\n 1..4: write(52);\n 7: write(52)\n Else write(0);\n End;\n End\n Else if(ch[length(ch)]='h') then\n Begin\n Val(copy(ch,1,length(ch)-9),n,e);\n Case n of\n 1..29: write(12);\n 30: write(11);\n 31: write(7)\n Else write(0);end;\n End\n Else write(0);\nEnd.\n "}, {"source_code": "{$MODE OBJFPC}\nvar\n m, n: Integer;\n st: String;\nbegin\n ReadLn(m, st);\n n := Length(st);\n if st = ' of week' then\n if (m <> 5) and (m <> 6) then WriteLn('52') else WriteLn('53');\n if st = ' of month' then\n if m <= 29 then WriteLn('12') else\n if m = 30 then WriteLn('11') else\n if m = 31 then WriteLn('7');\nend."}, {"source_code": "var\n s:string;\n i,code,data,data2,q:integer;\nbegin\n read(s);\n q:=length(s);\n if s[q]='h'\n then\n if s[2] in ['0'..'9']\n then begin\n val(s[1],data,code);\n data:=data*10;\n val(s[2],data2,code);\n data:=data+data2;\n end\n else val(s[1],data,code);\n \n if (data<>30) and (data<>31) and (data<>0) and (s[q]='h')\n then begin\n writeln ('12');\n exit;\n end\n else\n if (data=30) and(s[q]='h')\n then begin\n writeln ('11');\n exit;\n end\n else\n if (data=31) and (s[q]='h')\n then begin\n writeln ('7');\n exit;\n end;\n val(s[1], data,code);\n if ((data=6) or (data=5))\n then writeln('53')\n else if (data=2)\n then writeln('52')\n else if ((data=1) or (data=3) or (data=4) or (data=7))\n then writeln('52')\n \nend."}, {"source_code": "var\na:array [1..7] of longint;\nb:array [1..31] of longint;\ni,k,ss,k1:longint;\ns,s1:string;\nbegin\nfor i:=1 to 4 do a[i]:=52;\na[5]:=53; a[6]:=53;\na[7]:=52;\nfor i:=1 to 29 do\nb[i]:=12;\nb[31]:=7;\nb[30]:=11;\nreadln (s);\nk:=pos(' ',s);\ns1:=copy(s,1,k-1);\nval(s1,ss,k1);\ndelete(s,1,k);\nif s='of week' then writeln (a[ss])\nelse writeln (b[ss]);\nend."}, {"source_code": "const fi ='GoodBye2015_A.inp';\n fo ='GoodBye2015_A.out';\n\nvar s :string;\n i,num :longint;\nbegin\n read(s);\n i:=1;\n while (i<=length(s)) and (s[i]>='0') and (s[i]<='9') do\n begin\n num:=num*10+ord(s[i])-48;\n inc(i);\n end;\n if pos('month',s)<>0 then\n begin\n if num<=29 then write(12);\n if num=30 then write(11);\n if num=31 then write(7);\n if num>31 then write(0);\n end else\n begin\n if num>7 then write(0) else write((366-9) div 7+ord(num>=5)+ord(num<=6));\n end;\nend."}, {"source_code": "const\n {$ifdef online_judge}\n fi='';fo='';\n {$else}\n fi='test.inp';fo='test.out';\n {$endif}\nvar\n x:longint;\n s:string;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n read(x);\n read(s);\n delete(s,1,4);\n If s[1]='w' then\n case x of\n 5,6:write(53)\n else write(52);\n end\n else\n case x of\n 30:write(11);\n 31:write(7)\n else write(12);\n end;\nend.\n"}, {"source_code": " var\n\t\tm, n: int64;\n\t\ts, s1: string;\n\t\t\n begin\n\t\t\n\t\treadln(s);\n\t\tfor var i := 1 to s.length do\n\t\tbegin\n\t\t\tif (s[i] = ' ') then\n\t\t\t\tbreak;\n\t\t\ts1 += s[i];\n\t\tend;\n\t\t\n\t\tif (pos('w', s) > 0) then\n\t\tbegin\n\t\t\tif (StrToInt(s1) = 6) or (StrToInt(s1) = 5) then\n\t\t\t\twriteln(53)\n\t\t\telse\n\t\t\t\twriteln(52);\n\t\tend\n\t\telse begin\n\t\t\tif (StrToInt(s1) <= 29) then\n\t\t\t\twriteln(12);\n\t\t\tif (StrToInt(s1) = 31) then\n\t\t\t\twriteln(7);\n\t\t\tif (StrToInt(s1) > 29) and (StrToInt(s1) <= 30) then\n\t\t\t\twriteln(11);\n\t\tend;\n\t\t\n\t\t\n\t\t\n end.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\ng,f,k:integer;\ns:string;\nbegin\n readln(s);\n val(copy(s,1,2),g,f);\n k:=0;\n if s[2]=' ' then\n begin\n if copy(s,6,4)='week' then inc(k);\n end\n else\n begin\n if copy(s,7,4)='week' then inc(k);\n end;\n if k=0 then\n begin\n if g=30 then writeln(11);\n if g=31 then writeln(7) ;\n if g<=29 then writeln(12) ;\n end\n else\n begin\n if (g=5) or (g=6)then writeln(53)\n else writeln(52);\n end;\n\n\n readln;\nend.\n"}, {"source_code": "program Limak;\nvar mode: string;\nsweets, tmp: integer;\nbegin\nread(tmp);\nreadln(mode);\nif (mode = ' of week')\n then if (tmp > 4) and (tmp < 7) then sweets := 53 else sweets := 52\n else if (tmp < 30) then sweets := 12 else if (tmp < 31) then sweets := 11 else sweets := 7;\nwriteln(sweets);\nend."}, {"source_code": "Program Mishka;\nVar\n x:Integer;\n s:String;\nBegin\n read(x, s);\n if (s[5] = 'w') then\n begin\n if ((x = 5) or (x = 6)) then\n begin\n x := 53;\n end\n else\n x := 52;\n end;\n if (s[5] = 'm') then\n begin \n if x <= 29 then\n x := 12;\n if x = 30 then\n x := 11;\n if x = 31 then\n x := 7;\n end;\n writeln(x);\n Readln;\n End.\n\n"}, {"source_code": "const d:array[1..7] of longint=(52,52,52,52,53,53,52);\nvar a:longint;\n o:string;\n c:char;\nbegin\n readln(a,c,c,c,c,o);\n if o[1]='w' then writeln(d[a]) else\n if a<=29 then writeln(12) else\n if a= 30 then writeln(11) else\n writeln(7);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-}\nuses\n SysUtils;\nvar\n s : string;\n c : char;\n w, m : boolean;\n n : longint;\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output); }\n while not eoln do\n begin\n read(c);\n if c = ' ' then\n begin\n n := strtoint(s);\n s := '';\n read(c);\n read(c);\n read(c);\n read(c);\n end;\n if c = 'm' then\n begin\n m := true;\n Break;\n end;\n if c = 'w' then\n begin\n w := true;\n break;\n end;\n s := s + c;\n end;\n if (w) then\n begin\n if n = 1 then\n begin\n writeln(52);\n halt;\n end;\n if n = 2 then\n begin\n writeln(52);\n halt;\n end;\n if n = 3 then\n begin\n writeln(52);\n halt;\n end;\n if n = 4 then\n begin\n writeln(52);\n halt;\n end;\n if n = 5 then\n begin\n writeln(53);\n halt;\n end;\n if n = 6 then\n begin\n writeln(53);\n halt;\n end;\n if n = 7 then\n begin\n writeln(52);\n halt;\n end;\n end;\n if (m) then\n begin\n if n = 30 then\n begin\n writeln(11);\n halt;\n end;\n if n = 31 then\n begin\n writeln(7);\n halt;\n end;\n writeln(12);\n end;\nend.\n"}, {"source_code": "program Project151215;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\ntype\n mass=array[1..201000]of Longint;\nvar\n n,x,y,dx,dy,k,sx,sy,i,j,l,r,v:Longint;\n m:mass; flag:Boolean;\n a,b,c:int64;\n s:string;\n\nbegin\n // Reset(Input,'input.txt');\n // Rewrite(output,'output.txt');\n\n read(n);\n\n read(s);\n\n if s[Length(s)] = 'k'\n then if (n = 6)or(n=5)\n then write(53)\n else write(52)\n else if n<=29\n then write(12)\n else if n<=30\n then write(11)\n else write(7);\nend."}, {"source_code": "program ex;\nvar s:string;\nbegin\nread(s);\nif length(s)=9 then if ((ord(s[1])-48)<=4) or ((ord(s[1])-48)=7) then writeln(52) else writeln(53)\n else if (ord(s[1])-48=3) and (ord(s[2])=48) then writeln(11) else if (ord(s[1])=51) and (ord(s[2])=49) then writeln(7) else writeln(12);\nend. \n"}, {"source_code": "const\n fi='';\n fo='';\n maxc=1000000000;\n week:array[1..7] of longint=(52,52,52,52,53,53,52);\n{-------------------------}\nprocedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;\n{------------------------}\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n{-------------------------}\nprocedure nhap;\nvar\n x:longint;\n s:string;\nbegin\n read(x);\n readln(s);\n if pos('week',s)<>0 then\n begin\n writeln(week[x]);\n exit;\n end;\n if x<=29 then\n begin\n writeln(12); exit;\n end;\n if x=30 then\n begin\n writeln(11); exit;\n end;\n if x=31 then\n begin\n writeln(7);exit;\n end;\n\nend;\n{-------------------------}\nBEGIN\n openfiles;\n nhap;\n\n closefiles;\nEND.\n\n"}, {"source_code": "Var a:array[1..10000] of longint ; S,S1,S2: string ; k,n,i,j,a1,b1,code : longint ;\nbegin\nfor i:=1 to 12 do\na[i]:=0 ;\na[1]:=31 ;\na[2]:=29 ;\na[3]:=31 ;\na[4]:=30 ;\na[5]:=31 ;\na[6]:=30 ;\na[7]:=31 ;\na[8]:=31 ;\na[9]:=30 ;\na[10]:=31 ;\na[11]:=30 ;\na[12]:=31 ;\n\nreadln(S) ;\nfor i:=1 to length(S) do begin\nif S[i]=' 'then break ;\nS1:=S1+S[i] ;\nend ;\nfor i:=length(S) downto 1 do begin\nif S[i]=' ' then break ;\nS2:=S2+S[i] ;\nend ;\nb1:=52 ;\nval(S1,a1,code) ;\n\nif S2='htnom' then begin\nfor i:=1 to 12 do\nif a[i]>=a1 then k:=k+1 ;\nend ;\nif S2='keew' then begin\nif ( a1=5) or (a1=6) then k:=b1+1 else\nk:=b1 ;\nend ;\nwriteln(k) ;\nend.\n\n\n\n\n\n"}, {"source_code": "var sl,s:string; t:integer;\nbegin\n readln(sl);\n if (sl[1] in ['1' .. '9']) and (sl[2] in ['0' ..'9']) then\n begin\n s:=sl[1] + sl[2];\n val(s,t);\n end\n else val(sl[1],t);\n if pos('week',sl) <> 0 then\n begin\n inc(t);\n if (t = 6) or (t = 7 ) then write('53')\n else write('52');\n end\n else\n begin\n if t = 30 then begin write('11'); exit; end;\n if t = 31 then begin write('7'); exit; end;\n write('12');\n end;\nend."}, {"source_code": "uses math;\nvar s,p:string; n:integer;\nprocedure Find;\nvar i,c:integer; t:string;\nbegin\n i:=1; t:='';\n while s[i]<>' ' do begin t:=t+s[i]; inc(i); end;\n val(t,n,c); delete(s,1,i+3);\n p:=s;\nend;\nBEGIN\n readln(s);\n Find;\n if p='month' then\n begin\n if n=31 then write('7') else\n if (n=30) then write('11') else\n write('12');\n end\n else\n begin\n if (n=5) or (n=6) then write('53')\n else write('52');\n end;\nEND.\n"}, {"source_code": "program cf611A;\nvar x,rez:longint;\n s:string;\nbegin\nreadln(x,s);\nif s[length(s)]='h' then\n begin\n if x<=29 then\n rez:=12\n else\n if x<=30 then\n rez:=11\n else\n rez:=7;\n end\nelse\n begin\n if (x=5) or (x=6) then\n rez:=53\n else\n rez:=52;\n end;\nwriteln(rez);\nend.\n"}, {"source_code": "var n,i:longint;\n s:ansistring;\n a:array[1..33] of longint;\n begin\n read(n);\n readln(s);\n for i:=1 to 29 do\n a[i]:=12;\n a[30]:=11;\n a[31]:=7;\n if s=' of week' then begin\n if (n<>5) and (n<>6) then writeln(52)\n else writeln(53);\n end\n else writeln(a[n]);\nend."}, {"source_code": "{$MODE OBJFPC}\nVar s : ansistring;\n tmp1,tmp2,tmp,res : Integer;\nbegin\n readln(s);\n val(s[1],tmp1);\n If (ord(s[2]) >= 48) and (ord(s[2]) <= 57) then\n val(s[2],tmp2) else tmp2 := -1;\n //writeln(tmp1,tmp2);\n If tmp2 <> -1 then tmp:= tmp1*10 + tmp2\n else tmp := tmp1;\n //writeln(tmp);\n If s[length(s)] = 'k' then\n begin\n If (tmp = 5) or (tmp = 6) then res:= 53\n else res:= 52;\n end;\n If s[length(s)] = 'h' then\n begin\n If tmp = 30 then res:= 11;\n If tmp = 31 then res:= 7;\n If tmp <= 29 then res:= 12;\n end;\n writeln(res);\nend.\n"}, {"source_code": "Var n,i:longint;\n s:ansistring;\n a:array[1..33] of longint;\n begin\n read(n);\n readln(s);\n for i:=1 to 29 do\n a[i]:=12;\n a[30]:=11;\n a[31]:=7;\n if s=' of week' then begin\n if n=1 then writeln(52);\n if n=2 then writeln(52);\n if n=3 then writeln(52);\n if n=5 then writeln(53);\n if n=7 then writeln(52);\n if n=6 then writeln(53);\n if n=4 then writeln(52);\n end\n else writeln(a[n]);\n end."}, {"source_code": "uses math;\nconst finp='';\n fout='';\nvar fi,fo:text;\n s:string;\n n,i:longint;\n\nBEGIN\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,s);\n i:=1; n:=0;\n while s[i] in ['0'..'9'] do\n begin\n n:=n*10+ord(s[i])-48;\n inc(i);\n end;\n i:=i-1; \n if length(s)-i=8 then\n begin\n if (n=5) or (n=6) then writeln(fo,53) else writeln(fo,52);\n end else\n begin\n if n=30 then writeln(fo,11) else\n if n=31 then writeln(fo,7) else\n writeln(fo,12);\n end;\n close(fi);close(fo);\nEND.\n"}, {"source_code": "program sum_delit;\nconst MES:array[1..12] of byte=(31,29,31,30,31,30,31,31,30,31,30,31);\nvar\n k,kl,d,kol,i:longint;\n st,z:string;\nbegin\n {Assign(input,'input.txt');\n Reset(input);\n Assign(output,'output.txt');\n Rewrite(output);}\n\n readln(st);\n\n k:=pos(' ',st); z:=copy(st,1,k-1);\n delete(st,1,k); val(z,d,kl);\n\n if st='of week' then begin\n if (d=5)or(d=6) then writeln(53)\n else writeln(52);\n end;\n\n if st='of month' then begin\n kol:=0;\n for i:=1 to 12 do\n if d<=mes[i] then inc(kol);\n\n writeln(kol);\n end;\n\n//Close(input); Close(output);\nend.\n"}, {"source_code": "Var x : integer; \n s : string; \n \nBegin\n read(x); \n read(s);\n if s[length(s)] = 'h' then \n Begin\n if x = 31 then writeln(7)\n else \n if x = 30 then writeln(11) \n else writeln(12); \n end; \n \n if s[length(s)] = 'k' then \n Begin\n if (x = 5) or (x = 6) then writeln(53)\n else writeln(52); \n end; \nend. "}, {"source_code": "Const Finp = '';\n Fout = '';\nVar d:Byte;\n lc:Char;\nProcedure Nhap;\nVar f:Text;\n i:Byte;\n s,tmp:String;\nBegin\n Assign(f,finp); Reset(f);\n Readln(f,s); tmp:='';\n For i:=1 to length(s) do\n If s[i] in ['0'..'9'] then\n tmp:=tmp+s[i]\n Else\n If s[i] = 'm' then lc:='m'\n Else\n If s[i] = 'w' then lc:='w';\n Val(tmp,d,i);\n Close(f);\nEnd;\nFunction Week:Longint;\nBegin\n If (d = 5) or (d = 6) then exit(53);\n exit(52);\nEnd;\nFunction Year:Longint;\nBegin\n If d <= 29 then exit(12);\n If d <= 30 then exit(11);\n exit(7);\nEnd;\nProcedure Xuat;\nVar f:Text;\nBegin\n Assign(f,fout); Rewrite(f);\n If lc = 'w' then write(f,week) else write(f,year);\n Close(f);\nEnd;\nBegin\n Nhap;\n Xuat;\nEnd.\n"}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n // assign(input,fi);reset(input);\n// assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 366 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n for i := 1 to 366 do\n if a[i] = num then inc(dem);\n writeln(dem);\n end\n else\n begin\n if num <30 then writeln(12) else\n if num =30 then writeln(11) else writeln(7);\n end;\n // close(input);close(output);\nend.\n\n"}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n // assign(input,fi);reset(input);\n // assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 366 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n for i := 1 to 366 do\n if a[i] = num then inc(dem);\n writeln(dem);\n end\n else\n begin\n if num <30 then writeln(12) else\n if num =30 then writeln(11) else writeln(7);\n end;\n //close(input);close(output);\nend.\n"}, {"source_code": "var i,j,m,x:longint;\n s:string;\nbegin\n //readln(s);\n read(x);\n readln(s);\n if s[length(s)]='h' then begin\n if x<=29 then writeln(12) else if x<=30 then writeln(11) else writeln(7);\n end else begin\n if (x=5) or (x=6) then writeln(53) else writeln(52);\n end;\nend.\n"}, {"source_code": "program cofo_newyearandbear;\nvar\na, b, c, d: longint;\ne: string;\nbegin\nread(a);\nread(e);\nif (e[5]='w') then\nbegin\nif (a<5) or (a=7) then write('52') else write ('53')\nend;\nif (e[5]='m') then\nbegin\nif a<30 then write('12');\nif a=30 then write('11');\nif a=31 then write('7')\nend\nend."}, {"source_code": "var s:string;\na,b:integer;\nbegin\nread(s);\na:=length(s);\nif copy(s,a-3,4)='week' then\nbegin\n if (copy(s,1,1)<>'5') and (copy(s,1,1)<>'6') then\n writeln('52')\n else writeln('53');\nend\nelse\n if copy(s,1,2)='30' then writeln('11')\n else\n if copy(s,1,2)='31' then writeln('7')\n else writeln('12');\nend."}, {"source_code": "var\n a :array[1..12] of longint =(31,29,31,30,31,30,31,31,30,31,30,31);\n b :array[1..7] of longint =(4,5,6,7,1,2,3);\n sl :longint;\n aa,x,dem,i:longint;\n s :string;\n\nbegin\n readln(s);\n aa:=pos(' ',s);\n val(copy(s,1,aa-1),x);\n if s[length(s)]='h' then\n begin\n sl:=0;\n for i:=1 to 12 do\n if x<=a[i] then inc(sl);\n writeln(sl);\n end\n else\n begin\n sl:=1;\n dem:=b[x];\n while dem+7<=366 do\n begin\n inc(sl);\n dem:=dem+7;\n end;\n writeln(sl);\n end;\nend.\n"}, {"source_code": "const fi='';//611a.inp';\n fo='';//611b.out';\n\nvar n,res :longint;\n a,c :array[0..100]of longint;\n f :text;\n t :longint;\n\nprocedure nhap;\nvar s:ansistring; i:longint;\nbegin\n assign(f,fi); reset(f);\n read(f,n,s);\n if s[length(s)]='k' then t:=1 else t:=2;\n close(f);\nend;\n\nprocedure xuly;\nvar i,j,k:longint;\nbegin\n a[1]:=31 ;\n a[2]:=29 ;\n a[3]:=31 ;\n a[4]:=30 ;\n a[5]:=31 ;\n a[6]:=30 ;\n a[7]:=31 ;\n a[8]:=31 ;\n a[9]:=30 ;\n a[10]:=31 ;\n a[11]:=30 ;\n a[12]:=31 ;\n res:=0;\n if t=1 then\n begin\n k:=0;\n for i:=1 to 12 do inc(k,a[i]);\n dec(k,3); fillchar(c,sizeof(c),0);\n c[5]:=1; c[6]:=1; c[7]:=1;\n for i:=1 to k do\n begin\n if i mod 7=0 then j:=7 else j:=i mod 7;\n inc(c[j]);\n end;\n res:=c[n];\n end\n else\n begin\n for i:=1 to 12 do\n if n<=a[i] then inc(res);\n end;\nend;\n\nprocedure inkq;\nbegin\n assign(f,fo); rewrite(f);\n write(f,res);\n close(f);\nend;\nBEGIN\n nhap;\n xuly;\n inkq;\nEND.\n"}, {"source_code": "Program qq;\nVar I:LongInt;\n s:string;\n code:Integer;\nbegin\n Readln(s);\n i:=Pos('week',s);\n If I>0\n then begin\n s:=s[1];\n Val(s,i,code);\n Case i of\n 5,6:Writeln(53)\n else Writeln(52);\n end;\n end\n else begin\n i:=Pos(' ',s);\n s:=Copy(s,1,i-1);\n Val(s,i,code);\n Case I of\n 30:Writeln(11);\n 31:Writeln(7)\n else Writeln(12);\n end;\n end;\nEnd.\n\n"}, {"source_code": "const\n ngay: array[1..31] of longint\n = (12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n 12, 12, 12, 12, 12, 12, 12, 12, 12, 11,\n 7);\n\n\nvar\n s: string;\n k, num, code: longint;\n\n begin\n assign(input, ''); reset(input);\n assign(output, ''); rewrite(output);\n readln(s);\n k:= pos('week', s);\n if k = 0 then\n begin\n if s[2] <> ' ' then\n val(s[1] + s[2], num, code)\n else\n val(s[1], num, code);\n writeln(ngay[num]);\n end\n else\n if (s[1] = '5') or (s[1] = '6') then\n writeln(53)\n else\n writeln(52);\n close(input); close(output);\n end.\n"}, {"source_code": "var s,s1:string; a:longint;\nbegin \nread(a,s,s1); \nif s=' of week' then\nif(a=5) or (a=6) then write(53)\n\t\telse write(52)\n else\nif s=' of month' then \n if(a <= 29) then write(12)\n\telse\n\tif(a <= 30) then write(11)\n\telse write(7);\n\tend."}, {"source_code": "const\n mo:array[1..12]of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\nvar\n q,ans,i,j,n,m,k,t,x:longint;\n s:ansistring;\nbegin\n read(x);\n readln(s);\n k:=5;t:=1;q:=1;\n for i:=1 to 366 do\n begin\n if(k=x)and(s[length(s)]='k')then inc(ans);\n if(q=x)and(s[length(s)]='h')then inc(ans);\n inc(q);\n if q>mo[t] then begin inc(t);q:=1;end;\n inc(k);\n if k=8 then k:=1;\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "program goodbye2015a;\n\nconst t=5;\n\nvar\n inp:string;\n k,p:integer;\n\nprocedure Week;\nvar j,cnt,d,i:integer; A:array[1..366] of byte;\nbegin\n cnt:=0;\n d:=0;\n j:=t;\n while cnt<=366 do begin\n d:=d+1;\n cnt:=cnt+1;\n if j<=7 then A[d]:=j else begin j:=1; A[d]:=j end;\n j:=j+1;\n end;\n for i:=1 to 366 do if A[i]=k then p:=p+1;\nend;\n\nprocedure Month;\nbegin\n if k in [1..29] then p:=12;\n if k=30 then p:=11;\n if k=31 then p:=7;\nend;\n\nprocedure Detach;\nvar i,j,code:integer; A:array[1..2] of integer;\nbegin\n j:=0;\n for i:=1 to length(inp) do\n if inp[i] in ['0'..'9'] then begin\n j:=j+1;\n val(inp[i],A[j],code);\n if j=2 then break;\n end;\n if j=1 then k:=A[1];\n if j=2 then k:=A[1]*10+A[2];\n if inp[length(inp)]='k' then Week;\n if inp[length(inp)]='h' then Month;\nend;\n\nbegin\n readln(inp);\n Detach;\n writeln(p);\nend.\n"}, {"source_code": "var n, i: longint;\n s: string;\nbegin\n read(n); read(s);\n if s[length(s)] = 'k' then \n begin\n if (n >= 5) and (n <= 6) then write(53)\n else write(52);\n end\n else \n begin\n if n = 31 then write(7)\n else if n = 30 then write(11)\n else write(12);\n end;\nend."}], "negative_code": [{"source_code": "label 1;\nconst ay:array[1..12]of integer=(31,29,31,30,31,30,31,31,30,31,30,31);\nvar x,k,g,f,h,a,t,y:integer;\nq:string;\nbegin read(x,q);a:=1;y:=1;\nk:=pos('week',q);\nif k<>0 then t:=1 else t:=0;\n1:inc(g);inc(h);\nif h=8 then h:=1;\nif g>ay[a] then begin g:=1;inc(a);end;\nif a>12 then begin a:=1;inc(y);end;\nif y>2016 then begin write(f); halt;end;\nif (y=2016)and(t=1)and(h=x) then begin inc(f);goto 1;end;\nif (y=2016)and(t=0)and(g=x) then begin inc(f);goto 1;end else goto 1;end.\n\n\n"}, {"source_code": "{$mode objfpc}\nvar\n s:ansistring;\n res,date:int64;\n\nprocedure input;\nbegin\n read(s);\nend;\n\nprocedure solvemonth;\nbegin\n if s[2]=' ' then res:=12\n else\n begin\n date:=(ord(s[1])-48)*10+ord(s[2])-48;\n if (10<=date) and (date<=29) then res:=12;\n if date=30 then res:=11;\n if date=31 then res:=7;\n end;\nend;\n\nprocedure solveweek;\nbegin\n case s[1] of\n '1':res:=52;\n '2':res:=52;\n '3':res:=53;\n '4':res:=52;\n '5':res:=53;\n '6':res:=53;\n '7':res:=52;\n end;\nend;\n\nprocedure output;\nbegin\n write(res);\nend;\nbegin\n input;\n if s[length(s)]='h' then solvemonth else solveweek;\n output;\nend."}, {"source_code": "uses math;\nvar s,p:string; n:integer;\nprocedure Find;\nvar i,c:integer; t:string;\nbegin\n i:=1; t:='';\n while s[i]<>' ' do begin t:=t+s[i]; inc(i); end;\n val(t,n,c); delete(s,1,i+3);\n p:=s;\nend;\nBEGIN\n readln(s);\n Find;\n if p='month' then\n begin\n if n=31 then write('7') else\n if (n=30) or (n=29) then write('11') else\n write('12');\n end\n else\n begin\n if (n=1) then write('53')\n else write('52');\n end;\nEND.\n"}, {"source_code": "var s:string;\na,b:integer;\nbegin\nread(s);\na:=length(s);\nif copy(s,a-3,4)='week' then\nbegin\n if (copy(s,1,2)<>'5') and (copy(s,1,2)<>'6') then\n writeln('52')\n else writeln('53');\nend\nelse\n if copy(s,1,2)='30' then writeln('11')\n else\n if copy(s,1,2)='31' then writeln('7')\n else writeln('12');\nend."}, {"source_code": "Var a,b,ans,i:longint;\n s:string;\n begin\n Readln(a,s);\n i:=1;\n\n if s=' of week' then begin if a=1 then write(52) else write(52) end\n else begin\n if a in [1..29] then begin\n write(12);\n halt;\n end\n else if a =30 then begin\n write('11');\n halt;\n end\n else begin\n write('7');\n halt;\n end;\n\n\n end;\n\n\n end.\n"}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n// assign(input,fi);reset(input);\n// assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 365 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n for i := 1 to 365 do\n if a[i] = num then inc(dem);\n writeln(dem);\n end\n else\n begin\n if num <30 then writeln(12)\n else\n if num =30 then writeln(11) else writeln(7);\n end;\n // close(input);close(output);\nend.\n"}, {"source_code": "{$mode objfpc}\nvar\n s : ansistring;\n n : integer;\nbegin\n read(n);\n readln(s);\n if s[5] = 'w' then\n begin\n if n = 5 then writeln('53')\n else writeln(52);\n end\n else\n begin\n if n <= 27 then writeln('12')\n else\n if n = 28 then writeln(0)\n else\n if n = 29 then writeln(1)\n else\n if n = 30 then writeln(11)\n else writeln(7);\n end;\nend.\n"}, {"source_code": "uses math;\nvar s,p:string; n:integer;\nprocedure Find;\nvar i,c:integer; t:string;\nbegin\n i:=1; t:='';\n while s[i]<>' ' do begin t:=t+s[i]; inc(i); end;\n val(t,n,c); delete(s,1,i+3);\n p:=s;\nend;\nBEGIN\n readln(s);\n Find;\n if p='month' then\n begin\n if n=31 then write('7') else\n if (n=30) or (n=29) then write('11') else\n write('12');\n end\n else\n begin\n if (n=1) then write('53')\n else write('52');\n end;\nEND.\n"}, {"source_code": "var n,i,j,k:longint;\n a,b,c,d:char;\n s:string;\nbegin\n readln(n,a,b,c,d,s);\n if s='week' then\n writeln('52')\n else\n begin\n if n<=29 then\n writeln('12')\n else if n=30 then\n writeln('11')\n else if n=31 then\n writeln('7'); \n end;\nend.\n"}, {"source_code": "var s:string;\n x:integer;\nprocedure nhap(var s:string;var x:integer);\nvar i,code:integer;\n s1:string;\nbegin\n read(s);\n s1:='';\n for i:=1 to length(s) do\n if(s[i] in ['0'..'9']) then\n s1:=s1+s[i];\n val(s1,x,code);\nend;\nprocedure xuli(s:string;x:integer);\nbegin\n if((x>=1) and (x<=7)) then\n if((pos('week',s)<>0) and (x>=1) and (x<=4) or (x=7)) then write(52)\n else write(53);\n if(x>=1) and (x<=31) then\n if((x>=1) and (x<=29)) then write(12)\n else if(x=31) then write(7)\n else if(x=30) then write(11);\nend;\nBEGIN\n nhap(s,x);\n xuli(s,x);\nEND.\n\n"}, {"source_code": "var\ns:string;\nBegin\nread(s);\nif (pos('6 of week',s)>0) or (pos('5 of week',s)>0) then write('53')\nelse if ((pos('week',s)>0) and ((pos('6',s)<0) and (pos('5',s)<0))) then write('52')\nelse if (pos('31',s)>0) then write('7') \nelse if (pos('30',s)>0) then write('11') \nelse write('12');\nend."}, {"source_code": " {$MODE OBJFPC}\n {$COPERATORS ON}\nconst\n {$IFDEF ONLINE_JUDGE}\n InputFile = '';\n OutputFile = '';\n {$ELSE}\n InputFile = 'Inp.inp';\n OutputFile = 'Out.out';\n {$ENDIF}\nconst\n month : array[1..12] of integer = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n // Start a year with friday !\nvar\n n : integer;\n s : string;\n ans : char;\nprocedure enter;\nvar i, j : longint;\n begin\n read(n);\n readln(s);\n for i:=1 to length(s) do if s[i]='w' then\n begin\n ans:='w';\n break;\n end else if s[i]='m' then\n begin\n ans:='m';\n break;\n end;\n end;\nprocedure next(var day:integer);\n begin\n day+=1; if day>7 then day:=1;\n end;\nprocedure solve;\nvar i, day, m, j, res: longint;\n begin\n day:=1; res:=0;\n\n case ans of\n 'w' :\n begin\n for i:=1 to 12 do\n begin\n for j:=1 to month[i] do\n begin\n if day=n then inc(res);\n next(day);\n end;\n end;\n end;\n 'm':\n begin\n for i:=1 to 12 do\n if month[i]>=n then inc(res);\n end;\n end;\n writeln(res);\n end;\nbegin\n assign(input, InputFile); reset(input);\n assign(output, OutputFile); rewrite(output);\n try\n enter;\n Solve;\n finally\n close(input);\n close(output);\n end;\nend.\n\n"}, {"source_code": "program lepeshki;\n\nvar\na: array [0..100] of longint;\nn,k,max,d,m,o,otv,x: int64;\ni,j,code,metka: longint;\ns,p: string;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nk:=pos(' ',s);\nfor I:=1 to k-1 do\n p:=p+s[i];\nval(p,x,code);\nif pos('m',s)=0 then begin k:=pos('w',s); metka:=1; end\n else begin k:=pos('m',s); metka:=2; end;\n\nif metka=1 then begin\n if x=1 then write('51');\n if x=2 then write('51');\n if x=3 then write('51');\n if x=4 then write('52');\n if x=5 then write('52');\n if x=6 then write('53');\n if x=7 then write('51');\n end\n else begin\n if x<=29 then write('12');\n if x=31 then write('7');\n if x=30 then write('11');\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "{Aleksey_b}\nvar s,s1:string;\n a,b:longint;\n code:integer;\n\nbegin\n readln(s);\n if s[2]<>' ' then begin s1:=s1+s[1]+s[2];delete(s,1,3) end\n else begin s1:=s1+s[1];delete(s,1,2) end;\n val(s1,a,code);\n if s='of week' then begin\n write('52');\n end\n else begin\n if a>=30 then write('11')\n else write('12');\n end;\nend."}, {"source_code": " var s:string;\n a,b,c,n,m,i,d,q,j,max:longint;\n begin\nreadln(s);\nval(s,a,c);\nif s[length(s)]='k' then writeln(52) else\ncase a of\n1..29:writeln(12);\n30:writeln(11);\n31:writeln(7);\nend;\nend."}, {"source_code": "var k,n:byte;\n s:string;\nbegin\nread(k,s);\nif pos('w',s)<>0 then begin\nif k<5 then write(52) else\nif k<7 then write(53) else write(52);\nend else\nbegin\nif k<30 then write(12) else\nif k=30 then write(5) else\nwrite(7);\nend;\nend."}, {"source_code": "program goodbye2015a;\n\nconst t=4;\n\nvar\n inp:string;\n k,p:integer;\n\nprocedure Week;\nvar j,cnt,d,i:integer; A:array[1..366] of byte;\nbegin\n cnt:=0;\n d:=0;\n j:=t;\n while cnt<=366 do begin\n d:=d+1;\n cnt:=cnt+1;\n if j<=7 then A[d]:=j else begin j:=1; A[d]:=j end;\n j:=j+1;\n end;\n for i:=1 to 366 do if A[i]=k then p:=p+1;\nend;\n\nprocedure Month;\nbegin\n if k in [1..29] then p:=12;\n if k=30 then p:=11;\n if k=31 then p:=7;\nend;\n\nprocedure Detach;\nvar i,j,code:integer; A:array[1..2] of integer;\nbegin\n j:=0;\n for i:=1 to length(inp) do\n if inp[i] in ['0'..'9'] then begin\n j:=j+1;\n val(inp[i],A[j],code);\n if j=2 then break;\n end;\n if j=1 then k:=A[1];\n if j=2 then k:=A[1]*10+A[2];\n if inp[length(inp)]='k' then Week;\n if inp[length(inp)]='h' then Month;\nend;\n\nbegin\n readln(inp);\n Detach;\n writeln(p);\nend.\n"}, {"source_code": "var s:string;\n x,i,ans:longint;\nbegin\nread(s);\nval(copy(s,1,pos(' ',s)-1),x,ans);\ndelete(s,1,pos(' ',s));\nif s='of week'\n then if (x=5) or (x=6) then ans:=54 else ans:=52\n else if x<30 then ans:=12\n else if x=30 then ans:=11\n else ans:=7;\nwrite(ans);\nend."}, {"source_code": "{$mode objfpc}\nconst inpf='';\n outf='';\n maxN=round(1e3)+2;\n\nvar fi,fo:text;\n s,s1:ansistring;\n i,k,l:integer;\n\nprocedure openfiles;\n begin\n assign(fi,inpf);reset(fi);\n assign(fo,outf);rewrite(fo);\n end;\n\nprocedure closefiles;\n begin\n close(fi);close(fo);\n end;\n\nprocedure solve1;\n begin\n if k<=28 then writeln(12)\n else if k<=30 then writeln(11)\n else writeln(7);\n end;\n\nprocedure solve2;\n var res,i,p:integer;\n begin\n p:=4;\n res:=0;\n for i:=1 to 365 do\n begin\n inc(p);\n if p=8 then p:=1;\n if p=k then inc(res);\n end;\n writeln(res);\n end;\n\nbegin\n openfiles;\n readln(fi,s);\n s1:='';\n for i:=1 to length(s) do\n if s[i]<>' ' then s1:=s1+s[i]\n else break;\n val(s1,k,l);\n s1:=s[length(s)];\n if s1='h' then solve1\n else solve2;\n closefiles;\nend."}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n// assign(input,fi);reset(input);\n// assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 365 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n {for i := 1 to 365 do\n if a[i] = num then inc(dem);\n writeln(dem);}\n writeln(52);\n end\n else\n begin\n if num <30 then writeln(12)\n else\n if num =30 then writeln(11) else writeln(7);\n end;\n //close(input);close(output);\nend.\n"}, {"source_code": "{Aleksey_b}\nvar s,s1:string;\n a,b:longint;\n code:integer;\n\nbegin\n readln(s);\n if s[2]<>' ' then begin s1:=s1+s[1]+s[2];delete(s,1,3) end\n else begin s1:=s1+s[1];delete(s,1,2) end;\n val(s1,a,code);\n if s='of week' then begin\n write('52');\n end\n else begin\n if a>=30 then begin\n if a=30 then write('12')\n else write('7');\n end\n else write('12');\n end;\nend."}, {"source_code": "uses math;\nconst finp='';\n fout='';\nvar fi,fo:text;\n s:string;\n n,i:longint;\n\nBEGIN\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,s);\n i:=1; n:=0;\n while s[i] in ['0'..'9'] do\n begin\n n:=n*10+ord(s[i])-48;\n inc(i);\n end;\n i:=i-1; \n if length(s)-i=8 then\n begin\n if (n=5) or (n=6) then writeln(fo,53) else writeln(fo,52);\n end else\n begin\n if n=29 then writeln(fo,1) else\n if n=30 then writeln(fo,11) else\n if n=31 then writeln(fo,7) else\n writeln(fo,12);\n end;\n close(fi);close(fo);\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,7);\n exit;\n end;\n if pos('week',st)>0 then\n begin\n if t1>=5 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "program z1;\nvar\nch,a:string;\ncode,chis:longint;\n\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(a);\nwhile a[1]<>' ' do\n begin\n ch:=ch+a[1];\n delete(a,1,1);\n end;\nval(ch,chis,code);\nif pos('w',a)<>0 then case chis of\n 1:write('51');\n 2:write('51');\n 3:write('51');\n 4:write('52');\n 5:write('52');\n 6:write('53');\n 7:write('51');\n end\n else if chis<=29 then write('12')\n else if chis=30 then write('11')\n else write('7');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "\nvar i,n,lik,kod,kol,t:longint;\ns,l:string;\na,b:array [0..1000] of longint;\nbegin\nb[1]:=31;\nb[2]:=29;\nb[3]:=31;\nb[4]:=30;\nb[5]:=31;\nb[6]:=30;\nb[7]:=31;\nb[8]:=31;\nb[9]:=30;\nb[10]:=31;\nb[11]:=30;\nb[12]:=31;\n\n\n\n\nreadln(s);\nif (s[2]=' ') then begin l:=s[1];delete(s,1,2);end else\nbegin l:=s[1]+s[2];delete(s,1,3);end;\nval(l,lik,kod);\nt:=0;\nfor i:=1 to 366 do\nbegin\ninc(t);\na[i]:=t;\nif (t>=7) then t:=0;\nend;\nif (s='of week') then\nbegin\nfor i:=1 to 366 do\nif (a[i]=lik) then inc(kol);\nend else\nif (s='of month') then\nbegin\nfor i:=1 to 12 do\nbegin\nif(b[i]>=lik) then inc(kol);\n\nend;\n\nend;\nwriteln(kol);\nend."}, {"source_code": "var k,n:byte;\n s:string;\nbegin\nread(k,s);\nif pos('w',s)<>0 then begin\nif k<5 then write(52) else\nif k<7 then write(53) else write(52);\nend else\nbegin\nif k<30 then write(12) else\nif k=30 then write(5) else\nwrite(7);\nend;\nend."}, {"source_code": "const\n mo:array[1..12]of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\nvar\n q,ans,i,j,n,m,k,t,x:longint;\n s:ansistring;\nbegin\n read(x);\n readln(s);\n k:=5;t:=1;q:=1;\n for i:=1 to 365 do\n begin\n if(k=x)and(s[length(s)]='k')then inc(ans);\n if(q=x)and(s[length(s)]='h')then inc(ans);\n inc(q);\n if q>mo[t] then begin inc(t);q:=1;end;\n inc(k);\n if k=8 then k:=1;\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "var\n s : string;\n a,ans,_,i : longint;\n d : array[1..12] of longint = (31,29,31,30,31,30,31,31,30,31,30,31);\n\nbegin\n readln(s); val(copy(s,1,pos(' ',s)-1),a,_);\n writeln(a);\n if s[length(s)] = 'k' then begin\n writeln(366 div 7 + ord(366 mod 7 >= a));\n end else begin\n for i:=1 to 12 do if a <= d[i] then inc(ans);\n writeln(ans);\n end;\nend."}, {"source_code": "program goodbye2015a;\n\nconst t=4;\n\nvar\n inp:string;\n k,p:integer;\n\nprocedure Week;\nvar j,cnt,d,i:integer; A:array[1..366] of byte;\nbegin\n cnt:=0;\n d:=0;\n j:=t;\n while cnt<=366 do begin\n d:=d+1;\n cnt:=cnt+1;\n if j<=7 then A[d]:=j else j:=0;\n j:=j+1;\n end;\n for i:=1 to 366 do if A[i]=k then p:=p+1;\nend;\n\nprocedure Month;\nbegin\n if k in [1..29] then p:=12;\n if k=30 then p:=11;\n if k=31 then p:=7;\nend;\n\nprocedure Detach;\nvar i,j,code:integer; A:array[1..2] of integer;\nbegin\n j:=0;\n for i:=1 to length(inp) do\n if inp[i] in ['0'..'9'] then begin\n j:=j+1;\n val(inp[i],A[j],code);\n if j=2 then break;\n end;\n if j=1 then k:=A[1];\n if j=2 then k:=A[1]*10+A[2];\n if inp[length(inp)]='k' then Week;\n if inp[length(inp)]='h' then Month;\nend;\n\nbegin\n readln(inp);\n Detach;\n writeln(p);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) or (a=6) or (a=7)\n or (a=2) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "const me:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\nconst dn:array[1..7] of longint=(52,52,52,52,52,52,52);\nvar a:array[0..100] of longint;\n kol,lik,pr,i,j,n,m:longint;\n s,s1,ss:string;\nbegin\nreadln(s);\n i:=1;\nwhile(pr<>1)do\nbegin\nval(s[i],lik,pr);\nif pr=0 then begin j:=j*10+lik;delete(s,i,1);end else\ninc(i);\nend;\nif s=' of month'then begin\nfor i:=1 to 12 do\nif me[i]>=j then inc(kol);\nwriteln(kol); halt;end;\n\n\nif s=' of week'then begin\nwriteln(dn[j]); halt;end;\nend.\n\n"}, {"source_code": "var\ns:string;\nBegin\nread(s);\nif pos('week',s)>0 then write('52');\nif pos('month',s)>0 then Begin\nif ((pos('29',s)>0) or (pos('30',s)>0) or (pos('31',s)>0)) then write('11')\nelse write('12');\nend;\nend."}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "var\n s:string;\n i,code,data,data2,q:integer;\nbegin\n read(s);\n q:=length(s);\n if s[q]='h'\n then begin\n val(s[1],data,code);\n data:=data*10;\n val(s[2],data2,code);\n data:=data+data2;\n end\n else val(s[1],data,code);\n \n if (data<>30) and (data<>31) and (data<>0) and (s[q]='h')\n then begin\n writeln ('12');\n exit;\n end\n else\n if (data=30) and(s[q]='h')\n then begin\n writeln ('11');\n exit;\n end\n else\n if (\n data=31) and (s[q]='h')\n then begin\n writeln ('7');\n exit;\n end;\n {val(s[1], data,code)\n if data=1\n then\n begin\n writeln('52');\n exit;\n end;\n else if data=2\n then\n begin\n writeln('');\n exit;\n end;\n else if data=3\n then\n begin\n writeln('');\n exit;\n end;\n else if data=4\n then\n begin\n writeln('52');\n exit;\n end;\n else if data=5\n then\n begin\n writeln('');\n exit;\n end;\n else if data=6\n then\n begin\n writeln('');\n exit;\n end;\n else if data=7\n then\n begin\n writeln('');\n exit;\n end;\n else}\n \nwriteln('52')\n \nend."}, {"source_code": "uses math;\nconst finp='';\n fout='';\nvar fi,fo:text;\n s:string;\n n,i:longint;\n\nBEGIN\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\n readln(fi,s);\n i:=1; n:=0;\n while s[i] in ['0'..'9'] do\n begin\n n:=n*10+ord(s[i])-48;\n inc(i);\n end;\n i:=i-1; \n if length(s)-i=8 then\n begin\n if (n=5) or (n=6) then writeln(fo,53) else writeln(fo,52);\n end else\n begin\n if n=29 then writeln(fo,1) else\n if n=30 then writeln(fo,11) else\n if n=31 then writeln(fo,7) else\n writeln(fo,12);\n end;\n close(fi);close(fo);\nEND."}, {"source_code": "{\nAuthor: TinTin\nProblem: A. New Year and Days\nLink: http://codeforces.com/contest/611/problem/A\nAlgo:\nComp:\n}\nvar st:string;\n a:array[2..8] of integer;\n//--------------------------\nprocedure input;\nbegin\n readln(st);\nend;\n//--------------------------\nprocedure init;\nbegin\n fillchar(a,sizeof(a),0);\nend;\n//--------------------------\nprocedure process;\nvar i,d,n,code:integer;\n st1:string;\nbegin\n d:=5;\n st1:='';\n for i:=pos(#32,st)-1 downto 1 do\n st1:=st[i]+st1;\n if pos('w',st)>0 then\n begin\n n:=0;\n val(st1,i,code);\n while n<=366 do\n begin\n inc(n);\n inc(d);\n inc(a[d]);\n if d=8 then d:=1;\n end;\n writeln(a[i+1]);\n end\n else\n begin\n if st1='31' then writeln(7);\n if st1='30' then writeln(11);\n if st1='29' then writeln(1)\n else writeln(12);\n end;\nend;\n//--------------------------\nbegin\n input;\n init;\n process;\nend.\n"}, {"source_code": "var\ns:string;\nBegin\nread(s);\nif pos('week',s)>0 then write('52');\nif ((pos('29',s)>0) or (pos('30',s)>0) or (pos('31',s)>0)) then write('11')\nelse write('12');\nend."}, {"source_code": " var s:string;\n a,b,c,n,m,i,d,q,j,max:longint;\n begin\nreadln(s);\nif (ord(s[2])>47) and (ord(s[2])<58) then val(copy(s,1,2),a,b) else val(s[1],a,b);\nif s[length(s)]='k' then\ncase a of\n1:writeln(52);\n2:writeln(52);\n3:writeln(52);\n4:writeln(52);\n5:writeln(52);\n6:writeln(53);\n7:writeln(52);\nend\nelse\ncase a of\n1..29:writeln(12);\n30:writeln(11);\n31:writeln(7);\nend;\nend."}, {"source_code": "var s:string;\na,b:integer;\nbegin\nread(s);\na:=length(s);\nif copy(s,a-3,4)='week' then\nbegin\n if (copy(s,1,2)<>'5') and (copy(s,1,2)<>'6') then\n writeln('52')\n else writeln('53');\nend\nelse\n if copy(s,1,2)='30' then writeln('11')\n else\n if copy(s,1,2)='31' then writeln('7')\n else writeln('12');\nend."}, {"source_code": "var n, kol : Integer;\n s : String; \nbegin\n read(n);\n readln(s);\n If s = ' of week' then begin\n kol := 52;\n If n > 4 then inc(kol);\n end\n else begin\n kol := 12;\n If n = 31 then kol := 8;\n If n = 30 then kol := 11;\n end;\n writeln(kol);\nend."}, {"source_code": " var\n\t\tm, n: int64;\n\t\ts, s1: string;\n\t\t\n begin\n\t\t\n\t\treadln(s);\n\t\tfor var i := 1 to s.length do\n\t\tbegin\n\t\t\tif (s[i] = ' ') then\n\t\t\t\tbreak;\n\t\t\ts1 += s[i];\n\t\tend;\n\t\t\n\t\tif (pos('w', s) > 0) then\n\t\tbegin\n\t\t\tif (StrToInt(s1) = 6) or (StrToInt(s1) = 7) then\n\t\t\t\twriteln(53)\n\t\t\telse\n\t\t\t\twriteln(52);\n\t\tend\n\t\telse begin\n\t\t\tif (StrToInt(s1) <= 29) then\n\t\t\t\twriteln(12);\n\t\t\tif (StrToInt(s1) = 31) then\n\t\t\t\twriteln(7);\n\t\t\tif (StrToInt(s1) > 29) and (StrToInt(s1) <= 30) then\n\t\t\t\twriteln(11);\n\t\tend;\n\t\t\n\t\t\n\t\t\n end.\n"}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=1) or (a=2) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "var s:string;\na,b:integer;\nbegin\nread(s);\na:=length(s);\nif copy(s,a-3,4)='week' then\nbegin\n if (copy(s,1,2)<>'5') and (copy(s,1,2)<>'6') then\n writeln('52')\n else writeln('53');\nend\nelse\n if copy(s,1,2)='30' then writeln('11')\n else\n if copy(s,1,2)='31' then writeln('7')\n else writeln('12');\nend."}, {"source_code": "var k,n:integer;\n s:string;\nbegin\nread(k,s);\nif pos('w',s)<>0 then \nbegin\nif k<5 then write(52) else\nif k<7 then write(53) else write(52);\nend else\nif k=30 then write(11) else\nif k<30 then write(12);\nend."}, {"source_code": "{\nAuthor: TinTin\nProblem: A. New Year and Days\nLink: http://codeforces.com/contest/611/problem/A\nAlgo:\nComp:\n}\nvar st:string;\n a:array[2..8] of integer;\n//--------------------------\nprocedure input;\nbegin\n readln(st);\nend;\n//--------------------------\nprocedure init;\nbegin\n fillchar(a,sizeof(a),0);\nend;\n//--------------------------\nprocedure process;\nvar i,d,n,code:integer;\n st1:string;\nbegin\n d:=5;\n st1:='';\n for i:=pos(#32,st)-1 downto 1 do\n st1:=st[i]+st1;\n if pos('w',st)>0 then\n begin\n n:=0;\n val(st1,i,code);\n while n<=366 do\n begin\n inc(n);\n inc(d);\n inc(a[d]);\n if d=8 then d:=1;\n end;\n writeln(a[i+1]);\n end\n else\n begin\n if st1='31' then writeln(7);\n if st1='30' then writeln(11);\n if st1='29' then writeln(1)\n else writeln(12);\n end;\nend;\n//--------------------------\nbegin\n input;\n init;\n process;\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,5);\n exit;\n end;\n if pos('day',st)>0 then\n begin\n if t1=7 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) or (a=6) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,5);\n exit;\n end;\n if pos('week',st)>0 then\n begin\n if t1=7 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "uses math;\nvar s,p:string; n:integer;\nprocedure Find;\nvar i,c:integer; t:string;\nbegin\n i:=1; t:='';\n while s[i]<>' ' do begin t:=t+s[i]; inc(i); end;\n val(t,n,c); delete(s,1,i+3);\n p:=s;\nend;\nBEGIN\n readln(s);\n Find;\n if p='month' then\n begin\n if n=31 then write('7') else\n if n=30 then write('4') else\n write('12')\n end\n else\n begin\n if (n=5) or (n=6) then write('53')\n else write('52');\n end;\nEND."}, {"source_code": "program yan;\n var s,s1,s2:string; i,j,x,y,b:integer;\nbegin\n read(s);\n b:=31+29+31+30+31+30+31+31+30+31+30+31;\n for i:=1 to length(s) do\n if s[i] in ['0'..'9'] then s1:=s1+s[i];\n val(s1,x,y);\n if s[length(s)]='h' then\n begin\n if x<30 then j:=12;\n if x=30 then j:=11;\n if x>30 then j:=7;\n end\n else\n begin\n j:=b div 7;\n if j mod 7>=x then inc(j);\n end;\n writeln(j);\nend."}, {"source_code": "{$mode objfpc}\nvar\n s:ansistring;\n res,date:int64;\n\nprocedure input;\nbegin\n read(s);\nend;\n\nprocedure solvemonth;\nbegin\n if s[2]=' ' then res:=12\n else\n begin\n date:=(ord(s[1])-48)*10+ord(s[2])-48;\n if (10<=date) and (date<=29) then res:=12;\n if date=30 then res:=11;\n if date=31 then res:=7;\n end;\nend;\n\nprocedure solveweek;\nbegin\n case s[1] of\n '1':res:=52;\n '2':res:=52;\n '3':res:=53;\n '4':res:=52;\n '5':res:=53;\n '6':res:=53;\n '7':res:=52;\n end;\nend;\n\nprocedure output;\nbegin\n write(res);\nend;\nbegin\n input;\n if s[length(s)]='h' then solvemonth else solveweek;\n output;\nend."}, {"source_code": " {$MODE OBJFPC}\n {$COPERATORS ON}\nconst\n {$IFDEF ONLINE_JUDGE}\n InputFile = '';\n OutputFile = '';\n {$ELSE}\n InputFile = 'Inp.inp';\n OutputFile = 'Out.out';\n {$ENDIF}\nconst\n month : array[1..12] of integer = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n // Start a year with friday !\nvar\n n : integer;\n s : string;\n ans : char;\nprocedure enter;\nvar i, j : longint;\n begin\n read(n);\n readln(s);\n for i:=1 to length(s) do if s[i]='w' then\n begin\n ans:='w';\n break;\n end else if s[i]='m' then\n begin\n ans:='m';\n break;\n end;\n end;\nprocedure next(var day:integer);\n begin\n day+=1; if day>7 then day:=1;\n end;\nprocedure solve;\nvar i, day, m, j, res: longint;\n begin\n day:=6; res:=0;\n\n case ans of\n 'w' :\n begin\n for i:=1 to 12 do\n begin\n for j:=1 to month[i] do\n begin\n if day=n then inc(res);\n next(day);\n end;\n end;\n end;\n 'm':\n begin\n for i:=1 to 12 do\n if month[i]>=n then inc(res);\n end;\n end;\n writeln(res);\n end;\nbegin\n assign(input, InputFile); reset(input);\n assign(output, OutputFile); rewrite(output);\n try\n enter;\n Solve;\n finally\n close(input);\n close(output);\n end;\nend.\n\n"}, {"source_code": "const fin='';\n fon='';\n maxC=1000000007;\nvar c:array [1..10000,1..10000] of longint;\n n,m,k,x:longint;\n s:string;\n fi,fo:text;\n procedure openf;\n begin\n assign(fi,fin); reset(fi);\n assign(fo,fon); rewrite(fo);\n end;\n procedure closef;\n begin\n close(fi);\n close(fo);\n end;\n Procedure nhap;\n begin\n read(fi,x);\n read(fi,s);\n end;\n procedure xuly;\n begin\n if length(s)=9 then\n begin\n if x<29 then writeln(fo,12);\n if x=29 then writeln(fo,12);\n if x=30 then writeln(fo,11);\n if x=31 then writeln(fo,8);\n end;\n if length(s)=8 then\n begin\n if x=6 then begin writeln(fo,53); exit; end;\n if x=5 then begin writeln(fo,53); exit; end;\n writeln(fo,52);\n end;\n end;\n procedure xuat;\n begin\n end;\n\n BEGIN\n openf;\n NHAP;\n XULY;\n XUAT;\n closef;\n END."}, {"source_code": "program lepeshki;\n\nvar\na: array [0..100] of longint;\nn,k,max,d,m,o,otv,x: int64;\ni,j,code,metka: longint;\ns,p: string;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nk:=pos(' ',s);\nfor I:=1 to k-1 do\n p:=p+s[i];\nval(p,x,code);\nif pos('m',s)=0 then begin k:=pos('w',s); metka:=1; end\n else begin k:=pos('m',s); metka:=2; end;\n\nif metka=1 then begin\n if x=1 then write('51');\n if x=2 then write('51');\n if x=3 then write('51');\n if x=4 then write('52');\n if x=5 then write('52');\n if x=6 then write('52');\n if x=7 then write('51');\n end\n else begin\n if x<=29 then write('12');\n if x=31 then write('7');\n if x=30 then write('11');\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "program lepeshki;\n\nvar\na: array [0..100] of longint;\nn,k,max,d,m,o,otv,x: int64;\ni,j,code,metka: longint;\ns,p: string;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nk:=pos(' ',s);\nfor I:=1 to k-1 do\n p:=p+s[i];\nval(p,x,code);\nif pos('m',s)=0 then begin k:=pos('w',s); metka:=1; end\n else begin k:=pos('m',s); metka:=2; end;\n\nif metka=1 then begin\n if x=1 then write('52');\n if x=2 then write('52');\n if x=3 then write('52');\n if x=4 then write('52');\n if x=5 then write('52');\n if x=6 then write('53');\n if x=7 then write('51');\n end\n else begin\n if x<=29 then write('12');\n if x=31 then write('7');\n if x=30 then write('11');\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "program A_611;\n\nvar\n n:longint;\n s:string;\n\nbegin\n read(n);\n read(s);\n if s[5]='w'\n then write('52')\n else case n of\n 31:write('7');\n 30:write('11');\n 1..29:write('12');\n end;\nend."}, {"source_code": "var\n s:string;\n i,code,data,data2,q:integer;\nbegin\n read(s);\n q:=length(s);\n if s[q]='h'\n then begin\n val(s[1],data,code);\n data:=data*10;\n val(s[2],data2,code);\n data:=data+data2;\n end\n else val(s[1],data,code);\n \n if (data<>30) and (data<>31) and (data<>0) and (s[q]='h')\n then begin\n writeln ('12');\n exit;\n end\n else\n if (data=30) and(s[q]='h')\n then begin\n writeln ('11');\n exit;\n end\n else\n if (\n data=31) and (s[q]='h')\n then begin\n writeln ('7');\n exit;\n end;\n {val(s[1], data,code)\n if data=1\n then\n begin\n writeln('52');\n exit;\n end;\n else if data=2\n then\n begin\n writeln('');\n exit;\n end;\n else if data=3\n then\n begin\n writeln('');\n exit;\n end;\n else if data=4\n then\n begin\n writeln('52');\n exit;\n end;\n else if data=5\n then\n begin\n writeln('');\n exit;\n end;\n else if data=6\n then\n begin\n writeln('');\n exit;\n end;\n else if data=7\n then\n begin\n writeln('');\n exit;\n end;\n else}\n \nwriteln('52')\n \nend."}, {"source_code": "var\n a: longint;\n x: string;\n\nbegin\n read(a, x);\n if x = ' of week'\n then begin\n if (a = 6) or (a = 5) then write('53')\n else if a = 7 then write('51')\n else write('52')\n end\n else\n begin\n if a <= 29 then write('12')\n else if a = 31 then write('7')\n else write('11');\n \n end;\nend."}, {"source_code": "var sl,s:string; t:integer;\nbegin\n readln(sl);\n if (sl[1] in ['1' .. '9']) and (sl[2] in ['0' ..'9']) then\n begin\n s:=sl[1] + sl[2];\n val(s,t);\n end\n else val(sl[1],t);\n if pos('week',sl) <> 0 then\n begin\n inc(t);\n if t = 2 then write('53')\n else write('52');\n end\n else\n begin\n if (t = 30) or (t = 29) then begin write('11'); exit; end;\n if t = 31 then begin write('7'); exit; end;\n write('12');\n end;\nend."}, {"source_code": "program lepeshki;\n\nvar\na: array [0..100] of longint;\nn,k,max,d,m,o,otv,x: int64;\ni,j,code,metka: longint;\ns,p: string;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nk:=pos(' ',s);\nfor I:=1 to k-1 do\n p:=p+s[i];\nval(p,x,code);\nif pos('m',s)=0 then begin k:=pos('w',s); metka:=1; end\n else begin k:=pos('m',s); metka:=2; end;\n\nif metka=1 then begin\n if x=1 then write('52');\n if x=2 then write('52');\n if x=3 then write('52');\n if x=4 then write('52');\n if x=5 then write('52');\n if x=6 then write('53');\n if x=7 then write('51');\n end\n else begin\n if x<=29 then write('12');\n if x=31 then write('7');\n if x=30 then write('11');\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "program z1;\nvar\nch,a:string;\ncode,chis:longint;\n\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(a);\nwhile a[1]<>' ' do\n begin\n ch:=ch+a[1];\n delete(a,1,1);\n end;\nval(ch,chis,code);\nif pos('w',a)<>0 then case chis of\n 1:write('52');\n 2:write('51');\n 3:write('51');\n 4:write('52');\n 5:write('52');\n 6:write('53');\n 7:write('51');\n end\n else if chis<=29 then write('12')\n else if chis=30 then write('11')\n else write('7');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "var s:string;\na,b:integer;\nbegin\nread(s);\na:=length(s);\nif copy(s,a-3,4)='week' then\nbegin\n if (copy(s,1,2)<>'5') and (copy(s,1,2)<>'6') then\n writeln('52')\n else writeln('53');\nend\nelse\n if copy(s,1,2)='30' then writeln('11')\n else\n if copy(s,1,2)='31' then writeln('7')\n else writeln('12');\nend."}, {"source_code": "var n, kol : Integer;\n s : String; \nbegin\n read(n);\n readln(s);\n If s = ' of week' then begin\n kol := 52;\n If n > 4 then inc(kol);\n end\n else begin\n kol := 12;\n If n = 31 then kol := 7;\n If n = 30 then kol := 11;\n end;\n writeln(kol);\nend."}, {"source_code": "program lepeshki;\n\nvar\na: array [0..100] of longint;\nn,k,max,d,m,o,otv,x: int64;\ni,j,code,metka: longint;\ns,p: string;\nBegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nread(s);\nk:=pos(' ',s);\nfor I:=1 to k-1 do\n p:=p+s[i];\nval(p,x,code);\nif pos('m',s)=0 then begin k:=pos('w',s); metka:=1; end\n else begin k:=pos('m',s); metka:=2; end;\n\nif metka=1 then begin\n if x=1 then write('52');\n if x=2 then write('52');\n if x=3 then write('52');\n if x=4 then write('52');\n if x=5 then write('52');\n if x=6 then write('53');\n if x=7 then write('51');\n end\n else begin\n if x<=29 then write('12');\n if x=31 then write('7');\n if x=30 then write('11');\n end;\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "{$mdoe objfpc}\nvar\n s: ansistring;\n i, c: integer;\nbegin\n readln(s);\n if pos('week',s) <> 0 then begin\n case ord(s[1]) - 48 of\n 1,2,3,4,5,7: writeln(52);\n 6: writeln(53);\n end;\n end;\n c := 0;\n if pos('month',s) <> 0 then begin\n for i := 1 to 2 do c := c * 10 + ord(s[i]) - 48;\n if c <= 28 then writeln('12');\n if (c = 29) or (c = 30) then writeln('11');\n if c = 31 then writeln('7');\n end;\nend."}, {"source_code": "uses math;\nvar s,p:string; n:integer;\nprocedure Find;\nvar i,c:integer; t:string;\nbegin\n i:=1; t:='';\n while s[i]<>' ' do begin t:=t+s[i]; inc(i); end;\n val(t,n,c); delete(s,1,i+3);\n p:=s;\nend;\nBEGIN\n readln(s);\n Find;\n if p='month' then\n begin\n if n=31 then write('7') else\n if (n=30) or (n=29) then write('11') else\n write('12');\n end\n else\n begin\n if (n=1) then write('53')\n else write('52');\n end;\nEND.\n"}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n //assign(input,fi);reset(input);\n // assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 365 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n {for i := 1 to 365 do\n if a[i] = num then inc(dem);\n writeln(dem);}\n writeln(52);\n end\n else\n begin\n if num <29 then writeln(12) else \n if num = 29 then writeln(11)\n else\n if num =30 then writeln(11) else writeln(7);\n end;\n // close(input);close(output);\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,7);\n exit;\n end;\n if pos('week',st)>0 then\n begin\n if t1=7 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\ns:string;\nBegin\nread(s);\nif pos('week',s)>0 then write('52');\nif ((pos('29',s)>0) or (pos('30',s)>0) or (pos('31',s)>0)) then write('11')\nelse write('12');\nend."}, {"source_code": "const fin='';\n fon='';\n maxC=1000000007;\nvar c:array [1..10000,1..10000] of longint;\n n,m,k,x:longint;\n s:string;\n fi,fo:text;\n procedure openf;\n begin\n assign(fi,fin); reset(fi);\n assign(fo,fon); rewrite(fo);\n end;\n procedure closef;\n begin\n close(fi);\n close(fo);\n end;\n Procedure nhap;\n begin\n read(fi,x);\n read(fi,s);\n end;\n procedure xuly;\n begin\n if length(s)=9 then\n begin\n if x<29 then writeln(fo,12);\n if x=29 then writeln(fo,12);\n if x=30 then writeln(fo,11);\n if x=31 then writeln(fo,8);\n end;\n if length(s)=8 then\n begin\n writeln(fo,52);\n end;\n end;\n procedure xuat;\n begin\n end;\n\n BEGIN\n openf;\n NHAP;\n XULY;\n XUAT;\n closef;\n END."}, {"source_code": "program zzz;\n var\n x,kol:integer;\n s:string;\nbegin\n read(x,s);\n if pos('week',s)>0 then case x of\n 1..4,6,7:writeln('52');\n 5:writeln('53');\n end\n else case x of \n 1..29:writeln('12');\n 30:writeln('4');\n 31:writeln('7');\n end;\nend."}, {"source_code": "program z1;\nvar\nch,a:string;\ncode,chis:longint;\n\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(a);\nwhile a[1]<>' ' do\n begin\n ch:=ch+a[1];\n delete(a,1,1);\n end;\nval(ch,chis,code);\nif pos('w',a)<>0 then case chis of\n 1:write('52');\n 2:write('51');\n 3:write('51');\n 4:write('52');\n 5:write('52');\n 6:write('53');\n 7:write('51');\n end\n else if chis<=29 then write('12')\n else if chis=30 then write('11')\n else write('7');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,5);\n exit;\n end;\n if pos('week',st)>0 then\n begin\n if t1=7 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "const fin='';\n fon='';\n maxC=1000000007;\nvar c:array [1..10000,1..10000] of longint;\n n,m,k,x:longint;\n s:string;\n fi,fo:text;\n procedure openf;\n begin\n assign(fi,fin); reset(fi);\n assign(fo,fon); rewrite(fo);\n end;\n procedure closef;\n begin\n close(fi);\n close(fo);\n end;\n Procedure nhap;\n begin\n read(fi,x);\n read(fi,s);\n end;\n procedure xuly;\n begin\n if length(s)=9 then\n begin\n if x<29 then writeln(fo,12);\n if x=29 then writeln(fo,12);\n if x=30 then writeln(fo,11);\n if x=31 then writeln(fo,8);\n end;\n if length(s)=8 then\n begin\n writeln(fo,52);\n end;\n end;\n procedure xuat;\n begin\n end;\n\n BEGIN\n openf;\n NHAP;\n XULY;\n XUAT;\n closef;\n END."}, {"source_code": "var\n a: Integer;\n s: string;\n \nbegin\n Read (a);\n ReadLn (s);\n \n if s[Length (s)] = 'k' then\n if a in [1..4, 7] then\n WriteLn (52)\n else\n WriteLn (53)\n else\n if a in [1..30] then\n WriteLn (11)\n else if a = 28 then\n WriteLn (7)\nend."}, {"source_code": "{$mdoe objfpc}\nvar\n s: ansistring;\n i, c: integer;\nbegin\n readln(s);\n if pos('week',s) <> 0 then begin\n case ord(s[1]) - 48 of\n 1,2,3,4,5,7: writeln(52);\n 6: writeln(51);\n end;\n end;\n c := 0;\n if pos('month',s) <> 0 then begin\n for i := 1 to 2 do c := c * 10 + ord(s[i]) - 48;\n if c <= 28 then writeln('12');\n if (c = 29) or (c = 30) then writeln('11');\n if c = 31 then writeln('7');\n end;\nend."}, {"source_code": "var sl,s:string; t:integer;\nbegin\n readln(sl);\n if (sl[1] in ['1' .. '9']) and (sl[2] in ['0' ..'9']) then\n begin\n s:=sl[1] + sl[2];\n val(s,t);\n end\n else val(sl[1],t);\n if pos('week',sl) <> 0 then\n begin\n inc(t);\n if (t = 2) or (t = 3) then write('53')\n else write('52');\n end\n else\n begin\n if t = 30 then begin write('11'); exit; end;\n if t = 31 then begin write('7'); exit; end;\n write('12');\n end;\nend."}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) or (a=6) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "var n, kol : Integer;\n s : String; \nbegin\n read(n);\n readln(s);\n If s = ' of week' then begin\n kol := 52;\n If n > 4 then inc(kol);\n end\n else begin\n kol := 12;\n If n = 31 then kol := 8;\n If n = 30 then kol := 11;\n end;\n writeln(kol);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar a,i:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=6) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) then writeln(11) else\n if a=31 then writeln(7) else writeln(12)\nend."}, {"source_code": "program z1;\nvar\nch,a:string;\ncode,chis:longint;\n\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(a);\nwhile a[1]<>' ' do\n begin\n ch:=ch+a[1];\n delete(a,1,1);\n end;\nval(ch,chis,code);\nif pos('w',a)<>0 then case chis of\n 1:write('51');\n 2:write('51');\n 3:write('51');\n 4:write('52');\n 5:write('52');\n 6:write('52');\n 7:write('51');\n end\n else if chis<=29 then write('12')\n else if chis=30 then write('11')\n else write('7');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "program z1;\nvar\nch,a:string;\ncode,chis:longint;\n\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output);}\nread(a);\nwhile a[1]<>' ' do\n begin\n ch:=ch+a[1];\n delete(a,1,1);\n end;\nval(ch,chis,code);\nif pos('w',a)<>0 then case chis of\n 1:write('51');\n 2:write('51');\n 3:write('51');\n 4:write('52');\n 5:write('52');\n 6:write('53');\n 7:write('51');\n end\n else if chis<=29 then write('12')\n else if chis=30 then write('11')\n else write('7');\n{close(input);\nclose(output);}\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=1e-6;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,sum:longint;\n s1,st:string;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction isnumber(x:char):boolean;\n begin\n if (x>='0') and (x<='9') then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,j,res,t1,t2:longint;\n begin\n readln(fi,st);\n for i:=1 to length(st) do\n if isnumber(st[i]) then s1:=s1+st[i] else break;\n val(s1,t1);\n if pos('month',st)>0 then\n begin\n if t1<=28 then writeln(fo,12) else\n if t1<=30 then writeln(fo,11) else\n if t1<=31 then writeln(fo,7);\n exit;\n end;\n if pos('week',st)>0 then\n begin\n if t1=7 then writeln(fo,53) else\n writeln(fo,52);\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\n s : string;\n a,ans,_,i : longint;\n d : array[1..12] of longint = (31,29,31,30,31,30,31,31,30,31,30,31);\n\nbegin\n readln(s); val(copy(s,1,pos(' ',s)-1),a,_);\n // writeln(a);\n if s[length(s)] = 'k' then begin\n writeln(366 div 7 + ord(a in [5,6,7]));\n end else begin\n for i:=1 to 12 do if a <= d[i] then inc(ans);\n writeln(ans);\n end;\nend."}, {"source_code": "const\n mo:array[1..12]of longint=(31,29,31,30,31,30,31,31,30,31,30,31);\nvar\n q,ans,i,j,n,m,k,t,x:longint;\n s:ansistring;\nbegin\n read(x);\n readln(s);\n k:=5;t:=1;q:=1;\n for i:=1 to 365 do\n begin\n if(k=x)and(s[length(s)]='k')then inc(ans);\n if(q=x)and(s[length(s)]='h')then inc(ans);\n inc(q);\n if q>mo[t] then begin inc(t);q:=1;end;\n inc(k);\n if k=8 then k:=1;\n end;\n writeln(ans);\nend.\n\n"}, {"source_code": "var\n\tx,y:string;\n\tn:integer;\n\nbegin\n\treadln(n,x);\n\tif pos('of month', x)>0 then\n\tbegin\n\t\tif n<=29 then writeln('12')\n\t\t\telse if n=30 then writeln('11')\n\t\t\t\telse if n=31 then writeln('7');\n\tend else if pos('of week', x)>0 then\n\tbegin\n\t\tif ((n=6)or(n=7)) then writeln('53')\n\t\t\telse writeln('52');\n\tend;\nend."}, {"source_code": "var\n a: Integer;\n s: string;\n \nbegin\n Read (a);\n ReadLn (s);\n \n if s[Length (s)] = 'k' then\n if a in [1..4, 7] then\n WriteLn (52)\n else\n WriteLn (53)\n else\n if a in [1..30] then\n WriteLn (11)\n else if a = 28 then\n WriteLn (7)\nend."}, {"source_code": "program goodbye2015a;\n\nconst t=4;\n\nvar\n inp:string;\n k,p:integer;\n\nprocedure Week;\nvar j,cnt:integer;\nbegin\n if k>7 then p:=0;\n if k<=0 then p:=0;\n if kt then cnt:=7-k;\n cnt:=366-cnt;\n p:=cnt div 7;\nend;\n\nprocedure Month;\nvar j,cnt,m:integer;\nbegin\n if k>31 then p:=0;\n if k<=0 then p:=0;\n j:=1;\n cnt:=1;\n while cnt<=366 do begin\n j:=j+1;\n cnt:=cnt+1;\n if j=k then p:=p+1;\n if (j=30) and (m=2) then begin m:=m+1; j:=1; end;\n if (j=31) and (m in [4,6,9,11]) then begin m:=m+1; j:=1; end;\n if (j=32) and (m in [1,3,5,7,8,10,12]) then begin m:=m+1; j:=1; end;\n end;\nend;\n\nprocedure Test;\nvar i:integer;\nbegin\n for i:=1 to length(inp) do begin\n if inp[i]='w' then begin Week; break; end;\n if inp[i]='m' then begin Month; break; end;\n end;\nend;\n\nprocedure Detach;\nvar i,j,code:integer; A:array[1..2] of integer;\nbegin\n j:=0;\n for i:=1 to length(inp) do\n if inp[i] in ['1'..'9'] then begin\n j:=j+1;\n val(inp[i],A[j],code);\n end;\n if j=1 then begin k:=A[1]; Test; end;\n if j=2 then begin k:=A[1]*10+A[2]; Month; end;\nend;\n\nbegin\n readln(inp);\n Detach;\n write(p);\n readln;\nend.\n\n"}, {"source_code": "\nvar i,n,lik,kod,kol,t:longint;\ns,l:string;\na,b:array [0..1000] of longint;\nbegin\nb[1]:=31;\nb[2]:=29;\nb[3]:=31;\nb[4]:=30;\nb[5]:=31;\nb[6]:=30;\nb[7]:=31;\nb[8]:=31;\nb[9]:=30;\nb[10]:=31;\nb[11]:=30;\nb[12]:=31;\n\n\n\n\nreadln(s);\nif (s[2]=' ') then begin l:=s[1];delete(s,1,2);end else\nbegin l:=s[1]+s[2];delete(s,1,3);end;\nval(l,lik,kod);\nt:=0;\nfor i:=1 to 366 do\nbegin\ninc(t);\na[i]:=t;\nif (t>=7) then t:=0;\nend;\nif (s='of week') then\nbegin\nfor i:=1 to 366 do\nif (a[i]=lik) then inc(kol);\nend else\nif (s='of month') then\nbegin\nfor i:=1 to 12 do\nbegin\nif(b[i]>=lik) then inc(kol);\n\nend;\n\nend;\nwriteln(kol);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar a:integer;s:ansistring;\nbegin\n readln(a,s);\n if s=' of week' then\n if (a=5) or (a=6) or (a=7)\n or (a=2) then writeln(53) else writeln(52);\n if s=' of month' then\n if (a=30) or (a=31) then writeln(11) else writeln(12)\nend."}, {"source_code": "program goodbye2015a;\n\nconst t=4;\n\nvar\n inp:string;\n k,p:integer;\n\nprocedure Week;\nvar j,cnt,d,i:integer; A:array[1..366] of byte;\nbegin\n cnt:=0;\n d:=0;\n j:=t;\n while cnt<=366 do begin\n d:=d+1;\n cnt:=cnt+1;\n if j<=7 then A[d]:=j else j:=0;\n j:=j+1;\n end;\n for i:=1 to 366 do if A[i]=k then p:=p+1;\nend;\n\nprocedure Month;\nbegin\n if k in [1..29] then p:=12;\n if k=30 then p:=11;\n if k=31 then p:=7;\nend;\n\nprocedure Detach;\nvar i,j,code:integer; A:array[1..2] of integer;\nbegin\n j:=0;\n for i:=1 to length(inp) do\n if inp[i] in ['0'..'9'] then begin\n j:=j+1;\n val(inp[i],A[j],code);\n if j=2 then break;\n end;\n if j=1 then k:=A[1];\n if j=2 then k:=A[1]*10+A[2];\n if inp[length(inp)]='k' then Week;\n if inp[length(inp)]='h' then Month;\nend;\n\nbegin\n readln(inp);\n Detach;\n writeln(p);\nend.\n"}, {"source_code": "program A_611;\n\nvar\n n:longint;\n s:string;\n\nbegin\n read(n);\n read(s);\n if s[5]='w'\n then write('52')\n else case n of\n 31:write('7');\n 30:write('11');\n 1..29:write('12');\n end;\nend."}, {"source_code": "var\n s : string;\n a,ans,_,i : longint;\n d : array[1..12] of longint = (31,29,31,30,31,30,31,31,30,31,30,31);\n\nbegin\n readln(s); val(copy(s,1,pos(' ',s)-1),a,_);\n writeln(a);\n if s[length(s)] = 'k' then begin\n writeln(366 div 7 + ord(366 mod 7 >= a));\n end else begin\n for i:=1 to 12 do if a <= d[i] then inc(ans);\n writeln(ans);\n end;\nend."}, {"source_code": "var\n a: Integer;\n s: string;\n \nbegin\n Read (a);\n ReadLn (s);\n \n if s[Length (s)] = 'k' then\n if a in [1..4, 7] then\n WriteLn (52)\n else\n WriteLn (53)\n else\n if a in [1..29] then\n WriteLn (12)\n else if a = 30 then\n WriteLn (11)\n else if a = 28 then\n WriteLn (7)\nend."}, {"source_code": "const\n fi='a.inp';\n fo='a.out';\n maxn=369;\nvar\n a : array[1..369] of longint;\n s : string;\n num,i,dem : longint;\nbegin\n //assign(input,fi);reset(input);\n // assign(output,fo);rewrite(output);\n read(num);\n read(s);\n a[1] := 5;\n for i := 2 to 365 do\n begin\n a[i] := (a[i-1] + 1) mod 8;\n if a[i] = 0 then a[i] := 1;\n end;\n if s = ' of week' then\n begin\n {for i := 1 to 365 do\n if a[i] = num then inc(dem);\n writeln(dem);}\n writeln(52);\n end\n else\n begin\n if num <29 then writeln(12) else \n if num = 29 then writeln(11)\n else\n if num =30 then writeln(11) else writeln(7);\n end;\n // close(input);close(output);\nend.\n"}, {"source_code": "var x,res:longint;\n s:string;\nbegin\n read(x);readln(s);\n while s[length(s)]=' ' do delete(s,length(s),1);\n if s[length(s)]='k' then\n begin\n res:=51;\n if (1<=x)and(x<=6)then inc(res);\n if (5<=x)and(x<=7) then inc(res);\n writeln(res);\n end\n else\n begin\n res:=12;\n if x=30 then res:=11;\n if x=31 then res:=6;\n writeln(res);\n end;\nend."}, {"source_code": "var sl,s:string; t:integer;\nbegin\n readln(sl);\n if (sl[1] in ['1' .. '9']) and (sl[2] in ['0' ..'9']) then\n begin\n s:=sl[1] + sl[2];\n val(s,t);\n end\n else val(sl[1],t);\n if pos('week',sl) <> 0 then\n begin\n inc(t);\n if (t = 2) or (t = 3) then write('53')\n else write('52');\n end\n else\n begin\n if t = 30 then begin write('11'); exit; end;\n if t = 31 then begin write('7'); exit; end;\n write('12');\n end;\nend."}, {"source_code": "Var n,i:longint;\n s:ansistring;\n a:array[1..31] of longint;\n begin\n read(n);\n readln(s);\n for i:=1 to 29 do\n a[i]:=12;\n a[30]:=11;\n a[31]:=7;\n if s=' of week' then writeln(52)\n else writeln(a[n]);\n end."}, {"source_code": "var s:string;\n x:integer;\nprocedure nhap(var s:string;var x:integer);\nvar i,code:integer;\n s1:string;\nbegin\n read(s);\n s1:='';\n for i:=1 to length(s) do\n if(s[i] in ['0'..'9']) then\n s1:=s1+s[i];\n val(s1,x,code);\nend;\nprocedure xuli(s:string;x:integer);\nbegin\n if((x>=1) and (x<=7)) then\n if((pos('week',s)<>0) and (x>=1) and (x<=4) or (x=7)) then write(52)\n else write(53);\n if(x>=1) and (x<=31) then\n if((x>=1) and (x<=29)) then write(12)\n else if(x=31) then write(7)\n else if(x=30) then write(11);\nend;\nBEGIN\n nhap(s,x);\n xuli(s,x);\nEND.\n\n"}, {"source_code": "var\n week:array[1..7] of longint=(52,52,52,52,53,53,52);\n month:array[1..31] of longint=(12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,7);\n s:string;\n k:longint;\nbegin\n readln(s);\n val(copy(s,1,pos(' ',s)-1),k);\n if pos(s,'m')<>0 then writeln(month[k])\n else writeln(week[k]);\nend."}], "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"} {"source_code": "\nprogram Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n\n var a,b:integer;\n n,k:Integer;\n c,d:int64;\n\n\nbegin\nreadln(k,n);\n\n c:=0;\n b:=k;\n if k>1 then\n begin\n for a:=1 to n do\n begin\n b:=b-1;\n c:=c+b;\n b:=b-1;\n c:=c+b;\n if b<=1 then\n Break;\n end;\n end;\n\n Writeln(c);\n\nend.", "positive_code": [{"source_code": "var k,n:int64;\nbegin\nread (n,k);\nif k>n div 2 then k:=n div 2;\nwrite( ((((n-1)+(n-k))*k) div 2)+(((k-1)*k)div 2)+((n-2*k)*k));\nend."}, {"source_code": "var a,b,i,j,m,n,x,y:int64;\n q,w:array[0..101]of longint;\n{procedure qs(l,r:longint);\nbegin\n i:=l;\n j:=r;\n x:=q[(l+r)div 2];\n repeat\n while q[i]x do dec(j);\n if i<=j then\n begin\n y:=q[i];\n q[i]:=q[j];\n q[j]:=y;\n y:=w[i];\n w[i]:=w[j];\n w[j]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if in div 2 then\n m:=n div 2;\n a:=(n-1+n-2*m)*m;\n write(a);\n end;\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar x, ans, k, j, n: int64;\n i: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,k);\n j:=n+1;\n for i:=1 to n div 2 do\n begin\n dec(k);\n dec(j);\n ans:=ans+(j-i)+(j-i-1);\n if k = 0 then break;\n end;\n write(ans);\n\n close(input); close(output);\nend.\n"}, {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,mx:longint; Z,Q:array[1..100000] of longint; count:int64;\n\nFunction min(x,y:longint):longint;\nbegin\nif x>1);\n\nfor i:=1 to mx do\nswap(Z[i],Z[n-i+1]);\n\nfor i:=1 to n do\n begin\n if Z[i]=Q[i] then count:=count+n-i else count:=count+k;\n end;\n\nif (n mod 2=1) and (n>1) then\n begin\n a:=(n div 2)+(n mod 2);\n if Z[a] n div 2) then\n k := n div 2;\n res := 0;\n for i := 1 to k do\n res := res + 1 + (n - 2 * i) * 2;\n writeln(res);\nend."}, {"source_code": "var a:array[0..2000011] of int64;\n t1,t2,kol,n,k,i:int64;j:longint;\nbegin\nreadln(n,k);\nt1:=1;\nt2:=n;\n\nwhile(n div 2>=i)and(k>0)do\nbegin\na[t1]:=1;\na[t2]:=1;\ndec(k);\ninc(t1);dec(t2);\ninc(i);\nend;\n\nfor j:=1 to i do\nif a[j]<>0 then kol:=kol+n-j;\n\ni:=j+1; k:=0;\n\nfor j:=i to n do\nif a[j]<>0 then kol:=kol+j-i;//k else\n//if a[j]=0 then inc(k);\n\n\nwriteln(kol);\n\nend.\n"}, {"source_code": "var s1,s2,s3,s4:string;\ni,n,k:int64;\nbegin\nreadln(n,k);\nif k>= n div 2 then begin writeln(n*(n-1) div 2);exit; end;\nwriteln((2*n*k-k*k-k) div 2 + n*k-2*k*k+(k*k-k)div 2);\nend.\n"}, {"source_code": "uses math;\nvar n,k,i:longint;\n p,ans,p1:int64;\n begin\n read(n,k);\n\n // for i:=1 to n do\n //a[i]:=1;\n p:=n-1;\n p1:=n-2;\n\n for i:=1 to min(n div 2,k) do\n begin\n inc(ans,p);\n dec(p,2);\n inc(ans,p1);\n dec(p1,2);\n end;\n writeln(ans);\n end."}, {"source_code": "Program main;\n Uses MATH;\n var n , k : LongInt;\n i : LongInt;\n med : LongInt;\n Ans : Int64;\nbegin\n Ans := 0 ; \n readLn ( n , k ) ; \n \n med := (n + 1 ) div 2 ; \n \n k := min ( med , k ) ;\n \n for i := 1 to n-1 do\n begin\n if ( i <= k ) then\n Ans := Ans + ( n - i ) \n else \n Ans := Ans + min ( k , n-i ) ; \n end;\n \n writeLn ( Ans ) ;\nend."}, {"source_code": "var\nn,k,i:longint;\nsum,q:int64;\nbegin\nreadln(n,k);\nk:=k*2;\nif k>n\nthen k:=n;\nfor i:=1 to k do begin\nq:=n-i;\ninc(sum,q);\nend;\nwriteln(sum);\nend.\n\n\n"}, {"source_code": "var n,k,ans,n2,kol,s1,s2:int64;\nbegin\n readln(n,k);\n if k>=(n div 2) then begin\n n:=n-1;\n ans:=((1+n)*n) div 2;\n end\n else begin\n s1:=(n-1)*k;\n kol:=n-k*2;\n s2:=k*kol;\n ans:=s1+s2;\n end;\n writeln(ans);\n\nend."}, {"source_code": "const modulo = 222222;\nvar a, rsq : array[0 .. 822222] of longint;\n n, m, i, j, l, r : longint;\n answer : int64;\n\nprocedure swap(var t, y : longint);\nvar u : longint;\nbegin\n u := t; t := y; y := u;\nend;\n\nprocedure replace(i, x : longint);\nbegin\n i := i + modulo - 1;\n rsq[i] := x;\n i := i div 2;\n while (i > 0) do\n begin\n rsq[i] := rsq[i + i] + rsq[i + i + 1];\n i := i div 2;\n end;\nend;\n\nfunction getsum(l, r : longint) : longint;\nvar i, j, ans : longint;\nbegin\n ans := 0;\n i := l + modulo - 1;\n j := r + modulo - 1;\n while (i <= j) do\n begin\n if odd(i) then ans := ans + rsq[i];\n if not odd(j) then ans := ans + rsq[j];\n i := (i + 1) div 2;\n j := (j - 1) div 2;\n end;\ngetsum := ans;\nend;\n\nbegin\n readln(n, m);\n for i := 1 to n do a[i] := i;\n l := 1;\n r := n;\n while (l < r) and (m > 0) do\n begin\n swap(a[l], a[r]);\n l := l + 1;\n r := r - 1;\n m := m - 1;\n end;\n answer := 0;\n for i := 1 to n do\n begin\n replace(a[i], 1);\n answer := answer + int64(getsum(a[i] + 1, n));\n end;\n writeln(answer);\nend."}, {"source_code": "var n,k,i,j,f,l,k1,k2:longint;\n ans:int64;\nbegin \nreadln(n,k); l:=0;\nf:=n div 2;\nk1:=n-1; k2:=n-2;\nif k>f then k:=f;\nfor i:=1 to k do\nbegin\nif k1>0 then inc(ans,k1+n-2*i);\ndec(k1,2);\ndec(k2);\nend;\nwrite(ans);\nend."}, {"source_code": "var\n n, k: Int64;\n cnt: Int64;\n \nbegin\n Read (n, k);\n \n if k > n div 2 then\n k:= n div 2;\n \n cnt:= n * k - (1 + k) * k div 2 + (n - k * 2) * k + k * (k - 1) div 2;\n \n WriteLn (cnt)\nend."}, {"source_code": "var\n N,K,i,j,ans:Int64;\nbegin\n Readln(N,K);\n i:=1;\n j:=N;\n ans:=0;\n while (K>0) and (i0 then\n res:=res+(n-2*k)*k+sk+s\n else res:=s+sk;\nend;\n{-----------------------}\nprocedure ghi;\nbegin\n assign(f,fno);\n rewrite(f);\n solve;\n Writeln(f,res);\n close(f);\nend;\n{-----------------------}\nbegin\n doc;\n ghi;\nend.\n"}, {"source_code": "var\nm: qword;\nn,k,i,j,j1,l,t: longint;\na: array of longint;\nflag: integer;\nbegin\nreadln(n,k);\nsetLength(a,n+1);\nm:=0;\n//if (k>n/2) then k:=round(n/2+1);\nfor i:=1 to n do\n a[i]:=i;\nj:=1; \nj1:=n;\ni:=1;\nwhile ((i<=k)and(j<=n-1)and(j1>j)) do begin\n \n m:= m+2 * (j1 - j - 1) + 1;\n \n i:=i+1;\n j:=j+1;\n j1:=j1-1;\nend;\n\nwriteln(m);\nend."}, {"source_code": "var\n a, b, c, sum, k, i, l: int64;\n\n \nbegin\n readln(a, b);\n i := 1;\n k := a;\n l := a;\n sum := 0;\n while i <= b do begin\n if k - 1 > 0 then sum := sum + k - 1;\n if l - 2 > 0 then sum := sum + l - 2;\n k := k - 2;\n l := l - 2;\n inc(i);\n end;\n writeln(sum);\nend."}, {"source_code": "var n,k:uint64;\n\nfunction min(a,b:uint64):uint64;\nbegin\nif an/2) then k:=round(n/2+1);\nfor i:=1 to n do\n a[i]:=i;\nj:=1; \nj1:=n;\ni:=1;\nwhile ((i<=k)and(j<=n-1)and(j1>j)) do begin\n \n m:= m+2 * (j1 - j - 1) + 1;\n \n i:=i+1;\n j:=j+1;\n j1:=j1-1;\nend;\n\nwriteln(m);\nend."}, {"source_code": "var\ni: integer;\nn, k, res, count: int64;\nbegin\nread(n, k);\nif k >= n div 2 then begin writeln((n * (n - 1)) div 2); exit; end;\ncount:= n - 1 + n - 2;\nres:= 0;\nfor i:= 1 to k do\nbegin\nres:= res + count;\ncount:= count - 4;\nend;\nwriteln(res);\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst nn=3; besk=2000000000000000000;\n nnn=2000000; eps=1e-11; modul=1000000007;\n type matr=array[1..3,1..3] of extended;\n mat=^matr;\n label 1,2,3,4;\n\nvar i1,j1,k,step,kt,ppp,god,day,mon,mask,i0,j0,i,j,start,finish:longint;\nnewdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;\ndef,xx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,aa,ay,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch1,ch2,ch:char;\nstr:array[-10..12000] of matr;\nprob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nb1,a1,next,prev,x1,x2,y1,y2,d,och,newoch,f,x,y,fact,c,b,a,prost:array[-100000..1100000] of int64;\noldzan,oldmarked,zan: array[0..330006] of boolean;\ngr:array[-1..1001,-1..1001] of boolean;\nagor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;\ndet,ott :double;\nd3,d1,d2,dist,edin:matr;\nss,ss1,ss2:string;\ndd:array[-21..2001,-2001..2001] of int64;\nmarked,dost,newdost:array[-10..700000] of boolean;\nssnew:array[-10..1000000] of char;\npole:array[-10..610,-10..600] of char;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n,p);\n if p>=(n div 2) then begin write(n*(n-1) shr 1); goto 1; end;\n ot:=0;\n for i:=1 to 2*p do begin ii:=i; ot:=ot+(n-ii); end;\n writeln(ot);\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='b';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n q,c,res:int64;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,n,m,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q>1);\n\nfor i:=1 to mx do\nswap(Z[i],Z[n-i+1]);\n\nfor i:=1 to n do\n begin\n if Z[i]=Q[i] then count:=count+n-i else count:=count+k;\n end;\nwriteln(count);\nend."}, {"source_code": "var a:array[0..200001] of longint;\n t1,t2,kol,n,k,i,j:longint;\nbegin\nreadln(n,k);\nt1:=1;\nt2:=n;\n\nwhile(n div 2>=i)and(k>0)do\nbegin\na[t1]:=1;\na[t2]:=1;\ndec(k);\ninc(t1);dec(t2);\ninc(i);\nend;\n\nfor j:=1 to i do\nif a[j]<>0 then kol:=kol+n-j;\n\ni:=j+1;\n\nfor j:=i to n do\nif a[j]<>0 then kol:=kol+(j-i);\n\n\nwriteln(kol);\n\nend.\n"}, {"source_code": "Program main;\n Uses MATH;\n var n , k : LongInt;\n i : LongInt;\n med : LongInt;\n Ans : Int64;\nbegin\n Ans := 0 ; \n readLn ( n , k ) ; \n \n med := (n + 1 ) div 2 ; \n \n k := min ( med , k ) ;\n \n for i := 1 to med do\n begin\n if ( i <= k ) then\n Ans := Ans + ( n - i ) \n else \n Ans := Ans + ( n - k ); \n end;\n \n writeLn ( Ans ) ;\nend."}, {"source_code": "var n,k,ans:int64;\nbegin\n readln(n,k);\n if k>=(n div 2) then begin\n n:=n-1;\n ans:=((1+n)*n) div 2;\n end\n else ans:=n*k;\n\n writeln(ans);\n\nend."}, {"source_code": "var n,k,i,j,f,l,k1,k2:longint;\n ans:int64;\nbegin\nreadln(n,k); l:=0;\nf:=n div 2;\nk1:=n-1; k2:=n-2;\nif k>f then k:=f;\nfor i:=1 to k do\nbegin\nif k1>0 then inc(ans,k1+k1 div 2);\ndec(k1);\ndec(k2);\nend;\nwrite(ans);\nend.\n"}, {"source_code": "var\n N,K,i,j,ans:Int64;\nbegin\n Readln(N,K);\n i:=1;\n j:=N;\n ans:=0;\n while (K>0) and (in div 2 then break;\n s:=s+n-i;\n tam:=i;\n sk:=sk+i;\n end;\n sk:=sk-tam;\n if n-2*k>0 then\n res:=res+(n-2*k)*k+sk+s\n else res:=s+sk;\nend;\n{-----------------------}\nprocedure ghi;\nbegin\n assign(f,fno);\n rewrite(f);\n Writeln(f,res);\n close(f);\nend;\n{-----------------------}\nbegin\n doc;\n solve;\n ghi;\nend."}, {"source_code": "const fni='';\n fno='';\nvar f:Text;\n n,k,d:longint;\n res,s,sk:int64;\n{----------------------}\nprocedure doc;\nbegin\n assign(f,fni);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n{-----------------------}\nprocedure solve;\nvar tam,i:longint;\nbegin\n tam:=0;\n for i:=1 to k do\n begin\n if i>n div 2 then break;\n s:=s+n-i;\n tam:=i;\n sk:=sk+i;\n end;\n sk:=sk-tam;\n if n-2*k>0 then\n res:=res+(n-2*k)*k+sk+s\n else res:=s+sk;\nend;\n{-----------------------}\nprocedure ghi;\nbegin\n assign(f,fno);\n rewrite(f);\n Writeln(f,res);\n close(f);\nend;\n{-----------------------}\nbegin\n doc;\n solve;\n ghi;\nend.\n"}, {"source_code": "const fni='';\n fno='';\nvar f:Text;\n n,k,d,s,sk,res:longint;\n{----------------------}\nprocedure doc;\nbegin\n assign(f,fni);\n reset(f);\n readln(f,n,k);\n close(f);\nend;\n{-----------------------}\nprocedure solve;\nvar tam,i:longint;\nbegin\n tam:=0;\n for i:=1 to k do\n begin\n if i>n div 2 then break;\n s:=s+n-i;\n tam:=i;\n sk:=sk+i;\n end;\n sk:=sk-tam;\n if n-2*k>0 then\n res:=res+(n-2*k)*k+sk+s\n else res:=s+sk;\nend;\n{-----------------------}\nprocedure ghi;\nbegin\n assign(f,fno);\n rewrite(f);\n Writeln(f,res);\n close(f);\nend;\n{-----------------------}\nbegin\n doc;\n solve;\n ghi;\nend."}, {"source_code": "var n,k:integer;\n\nfunction min(a,b:integer):integer;\nbegin\nif a= n div 2 then begin writeln((n * (n - 1)) div 2); exit; end;\ncount:= n - 1 + n - 2;\nres:= 0;\nfor i:= 1 to k do\nbegin\nres:= res + count;\ncount:= count - 2;\nend;\nwriteln(res);\nend."}], "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0"} {"source_code": "var\n bi:boolean;\n i,j,m,n,k,p:longint;\n a:array[0..100005]of longint;\nprocedure qs(l,r:longint);\nvar\n i,j,mid,q:longint;\nbegin\n i:=l; j:=r;\n mid:=a[(l+r) div 2];\n repeat \n while a[i]mid do dec(j);\n if not(i>j) then\n begin\n q:=a[i]; a[i]:=a[j]; a[j]:=q;\n inc(i); dec(j);\n end;\n until i>j;\n if i60 then begin\n write('YES');\n Halt;\n end;\n quicksort(1, n);\n for b:=1 to n-2 do begin\nif (a[b]+a[b+1]>a[b+2]) and (a[b+1]+a[b+2]>a[b]) and (a[b]+a[b+2]>a[b+1]) then begin\nwrite('YES');\nHalt;\nend;\nend;\nwrite('NO');\nend."}, {"source_code": "program otrezki;\nvar\nn,i: int64;\nfirst,last,start,final,j,min,y,z: int64;\na,b: array[1..100001] of int64;\nflag: boolean;\nprocedure Merge(first,last: int64);\n var\n i: int64;\n begin\n start:=first;\n final:=(first+last) div 2+1;\n for i:=first to last do\n begin\n if (start <= (first+last) div 2) and ((final > last) or (a[start] < a[final])) then\n begin\n b[i]:=a[start];\n inc(start);\n end else\n begin\n b[i]:=a[final];\n inc(final);\n end;\n end;\n for i:=first to last do a[i]:=b[i];\n end;\n \nprocedure MergeSort(first, last: int64);\n begin\n if first < last then\n begin\n MergeSort(first,(first+last) div 2);\n MergeSort((first+last) div 2+1,last);\n Merge(first, last);\n end;\n end;\nprocedure FindLowestTriangle;\n begin\n i:=1;\n j:=3;\n while j<=N do\n begin\n if (a[i]+a[i+1] > a[j]) and (a[j]+ a[i] > a[i+1]) and (a[j] + a[i+1] > a[i]) then\n begin\n flag:=true;\n exit;\n end;\n inc(i);\n inc(j);\n end;\n end;\nbegin\nread(n);\nfor i:=1 to N do\n read(a[i]);\nMergeSort(1,N);\nFindLowestTriangle;\nif flag then write('YES') else write('NO');\nend."}, {"source_code": " program z1;\n var n,i,j,h:int64;\n a:array [1..100000] of int64;\n procedure quicksort(l,r:int64);\n var i,j,x,y:int64;\n begin\n i := l;\n j := r;\n x := a[(l+r) div 2];\n repeat\n while a[i]x do dec(j);\n if i<=j then begin\n y:=a[i]; a[i]:=a[j]; a[j]:=y; inc(i); dec(j);\n end;\n until i>j ;\n if l a[i+2] then goto 1;\n\nwriteln('NO');\nexit;\n1:\nwriteln('YES');\nend.\n"}, {"source_code": "var i,n: longint;\n a: array[1..100000] of longint;\nprocedure qsort(l,r: longint);\nvar i,j,m,t,x: longint;\nbegin\n i:=l;\n j:=r;\n m:=(l+r) div 2;\n x:=a[m];\n while (i<=j) do\n begin\n while (a[i]x) do dec(j);\n if i<=j then \n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n end;\n if (la[i+1] then\n begin\n write('YES');\n exit;\n end;\n write('NO');\nend."}, {"source_code": "var a,q:Array[1..100000] of longint;\n n,i,i1,i2:longint;\nprocedure mergesort(l,r:longint);\n var x:longint;\n begin\n if lr) or (a[i1]a[i+2]\n then begin\n write('YES');\n exit;\n end;\n end;\n write('NO');\nend.\n"}, {"source_code": "Program Triangle;\nuses math;\nType arr=array[0..100007] of longint;\nvar a:arr; n,i,j:longint;\nProcedure Sort(l,r:longint);\nvar i,j,x,tmp:longint;\nbegin i:=l; j:=r; x:=a[(i+j) div 2];\n repeat\n while a[i]x do dec(j);\n if i<=j then begin\n tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;\n inc(i); dec(j);\n end;\n until i>j;\n if li then sort(i,r);\nend;\nProcedure Degenerate;\nvar l,r,g:longint;\nbegin Sort(1,n);\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n begin l:=j+1; r:=n;\n while l<=r do\n begin g:=(l+r) div 2;\n if a[g] j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\n\nbegin\n readln(a);\n z := 0;\n for i:= 1 to a do read(v[i]);\n \n qSort(1,a);\n \n for i := 1 to a-2 do begin\n if (v[i] + v[i+1] > v[i+2]) then z:=1;\n end;\n \n if (z = 1) then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a,s,d,f,g,h,j,k:int64;\ni,ii:longint;\nz,x:array[1..1000000]of int64;\nprocedure qsort(l,r:longint);\nvar l1,r1,e,t:longint;\nbegin\nl1:=l;\nr1:=r;\ne:=z[random(r-l)+l];\nrepeat;\nwhile e>z[l1] do inc(l1);\nwhile er1;\nif lz[i+2])and(z[i]+z[i+2]>z[i+1])and(z[i+1]+z[i+2]>z[i]) then\nbegin\nwriteln('YES');\nhalt;\nend;\nwriteln('NO');\nend.\n"}, {"source_code": "var i,n,f:longint;\n a:array[0..102005]of longint;\n\nprocedure sort(l,r:longint);\nvar i,j,x,b:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[l+random(r-l+1)];\n while i<=j do\n begin\n while xa[j] do dec(j);\n if i<=j then\n begin\n b:=a[i];\n a[i]:=a[j];\n a[j]:=b;\n inc(i); dec(j);\n end;\n end;\n if ia[i-1]-a[i-2]) then begin\n Writeln('YES');\n Halt;\n end;\n Writeln('NO');\nEnd."}, {"source_code": "Const fi='';\n fo='';\nVar n:longint;\n a:array[-10..100000] of longint;\nProcedure nhap;\n Var i:longint;\n begin\n assign(input,fi); reset(input);\n readln(n);\n For i:=1 to n do read(a[i]);\n Close(input);\n end;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 do\n begin\n i:=i-1; j:=j-1; k:=k-1;\n if (a[i] + a[k]>a[j]) and (abs(a[i]-a[k])a[k]) and (a[j]+a[k]>a[i]) and (a[j]-a[k]x do dec(j);\n if i<=j then\n begin\n z:=a[i];\n a[i]:=a[j];\n a[j]:=z;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[c]) and (a[i]+a[c]>a[j]) and (a[c]+a[j]>a[i]) then\n b:=true;\n inc(i);\n end;\n if b=true then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "var dlina : array[1..100000] of Integer;\n\nfunction Partition(l,r: integer): integer;\nvar i, j, x, stak : Integer;\nbegin\n i := l - 1;\n j := r + 1;\n x := dlina[l];\n while True do\n begin\n repeat\n i += 1;\n until dlina[i]>=x;\n repeat\n j -= 1;\n until dlina[j]<=x;\n if i=r then exit;\n j := Partition(l,r);\n QuickSort(l,j);\n QuickSort(j+1,r);\nend;\n\n\nvar n, i, ab, ac, bc, a, b, c : Integer;\nbegin\n readln(n);\n For i := 1 to n do read(dlina[i]);\n QuickSort(1,n);\n For i := 1 to n - 2 do\n begin\n a := dlina[i + 2];\n b := dlina[i + 1];\n c := dlina[i];\n If b + c > a then begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "\ntype tArray = Array [1..100000] of LongInt;\n\nprocedure mSort (var a: tArray; n: LongInt);\nvar tmp: tArray;\n\n procedure merge (al, ar, bl, br: LongInt);\n var i, j, k: LongInt;\n begin\n \n\ti := al;\n\tj := bl;\n\tk := 0;\n\t\n\twhile (i <= ar) and (j <= br) do\n\tbegin\n inc (k);\n\t if (a[i] < a[j]) then\n\t begin\n\t tmp[k] := a[i];\n\t\tinc (i);\n\t end\n\t else\n\t begin\n\t tmp[k] := a[j];\n\t\tinc (j);\n\t end;\n\tend;\n\t\n\twhile (i <= ar) do\n\tbegin\n\t inc (k);\n\t tmp[k] := a[i];\n\t inc (i);\n\tend;\n\t\n\twhile (j <= br) do\n\tbegin\n\t inc (k);\n\t tmp[k] := a[j];\n\t inc (j);\n\tend;\n\t\n\tfor i := 1 to k do\n\tbegin\n\t a[al+i-1] := tmp [i];\n\tend;\n\t\n end;\n \n procedure sort (l, r: LongInt);\n var med: LongInt;\n begin\n if (l = r) then \n\t exit();\n\tmed := (l + r) div 2;\n\t\n\tsort (l, med);\n\tsort (med+1, r);\n\t\n\tmerge (l, med, med+1, r);\n\t\n end;\n\nbegin\n sort (1, n);\nend;\n\nvar a: tArray;\n n, i: LongInt;\n\tres: String;\n \nbegin\n\n readln (n);\n for i := 1 to n do\n begin\n read (a[i]);\n end;\n \n res := 'NO';\n mSort (a, n);\n \n for i := 2 to n-1 do\n begin\n if (a[i-1] + a[i] > a[i+1]) then\n\t res := 'YES';\n end;\n \n writeln (res);\n\nend."}, {"source_code": "{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\nuses math;\nconst log=18;\n ms=1e-9;\n oo=round(1e9);\n modulo=1000000007;\n fi='';\n fo='';\n maxn=100010;\n\nvar f1,f2:text;\n n:longint;\n a:array[0..maxn]of longint;\n\nprocedure openfile;\n begin\n assign(f1,fi);\n reset(f1);\n assign(f2,fo);\n rewrite(f2);\n end;\n\nprocedure closefile;\n begin\n close(f1);\n close(f2);\n end;\n\nprocedure input;\n var i:longint;\n begin\n readln(f1,n);\n for i:=1 to n do\n read(f1,a[i]);\n end;\n\nprocedure sort(l,r:longint);\n var i,j,x,y:longint;\n begin\n x:=a[random(r-l-1)+l+1];\n i:=l;j:=r;\n repeat\n while a[i]x do dec(j);\n if i<=j then\n begin\n y:=a[i];a[i]:=a[j];a[j]:=y;\n inc(i);dec(j);\n end;\n until i>j;\n if ia[i]) then\n begin\n writeln(f2,'YES');\n closefile;\n halt;\n end;\n writeln(f2,'NO');\n end;\n\nprocedure output;\n var i:longint;\n begin\n\n end;\n\nbegin\n openfile;\n input;\n init;\n solve;\n output;\n closefile;\nend.\n\n"}, {"source_code": "var a:array[1..100000] of longint;\n i,n:longint;\n\nprocedure QSort(first,last:longint);\n var L,R,X,c:longint;\n begin\n if firstX do dec(R);\n if L<=R then\n begin\n c:=A[R]; A[R]:=A[L]; A[L]:=c;\n inc(L); dec(R);\n end;\n end;\n QSort(first,R);\n QSort(L,last);\n end;\n end;\n\nbegin\nread(n);\nfor i:=1 to n do\n read(a[i]);\nQSort(1,n);\nfor i:=1 to n-2 do\n if a[i+2] Pivot do\n Dec(Hi) ;\n if Lo <= Hi then\n begin\n T := AI[Lo];\n AI[Lo] := AI[Hi];\n AI[Hi] := T;\n Inc(Lo) ;\n Dec(Hi) ;\n end;\n until Lo > Hi;\n if Hi > ALo then\n QuickSort(AI, ALo, Hi) ;\n if Lo < AHi then\n QuickSort(AI, Lo, AHi) ;\nend;\n\t\nBegin\n\tReadln(n);\n\tA[0]:=0;\n\tsort:=False;\n\tFor i:=1 to n do\n\t\tBegin\n\t\t\tRead(A[i]);\n\t\t\tIf (A[i]A[i+2]) then\n\t\tBegin\n\t\t\tWrite('YES');\n\t\t\thalt;\n\t\tEnd;\n\tWrite('NO');\nEnd.\n"}, {"source_code": "procedure QSORT(var A:array of integer);\n procedure sort(const l,h:integer);\n var i,j,pivot,b:integer;\n begin\n if l < h then\n begin\n pivot:=A[random(h-l+1)+l];\n i:=l; j:=h;\n while i < j do\n begin\n while A[i] < pivot do inc(i);\n while pivot < A[j] do dec(j);\n if i <= j then begin\n b:=A[i];\n A[i]:=A[j];\n A[j]:=b;\n inc(i); dec(j);\n end\n end;\n sort(l,j);\n sort(i,h);\n end\n end;\nbegin\n randomize;\n sort(0,high(A));\nend;\nvar A:array of integer; i,n:integer;\nBEGIN\n read(n);\n setlength(A,n);\n for i:= 0 to n-1 do read(A[i]);\n Qsort(A);\n for i:=high(A) downto 2 do\n if a[i]mid) do\n dec(l);\n if (f<=l) then \n begin\n tmp:=a[f];\n a[f]:=a[l];\n a[l]:=tmp;\n inc(f);\n dec(l);\n end;\n end;\n if firstz) and (x+z>y) and (y+z>x) then exit(true)\n else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure test;\n var a,b,c:longint;\n begin\n a:=ran(1,n);\n repeat\n b:=ran(1,n);\n until b<>a;\n repeat\n c:=ran(1,n);\n until (c<>b) and (c<>a);\n if triangle(l[a],l[b],l[c]) then ok:=true;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res:longint;\n begin\n read(fi,n);\n for i:=1 to n do read(fi,l[i]);\n for i:=1 to 100000 do if not ok then test else break;\n if ok then writeln(fo,'YES') else writeln(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var a:array[1..100007] of longint;\n\th,p,n:longint;\n\nprocedure qs(l,r:longint);\n\tvar i,j,x,w,ind:longint;\nbegin\n\ti:=l;\n\tj:=r;\n\trandomize;\n\tind:=random(r-l+1)+l;\n\tx:=a[ind];\n\trepeat\n\t\twhile a[i] < x do inc(i);\n\t\twhile a[j] > x do dec(j);\n\t\tif i <= j then \tbegin\n\t\t\t\t\t\t\tw:=a[i];\n\t\t\t\t\t\t\ta[i]:=a[j];\n\t\t\t\t\t\t\ta[j]:=w;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tinc(i); dec(j);\n\t\t\t\t\t\tend;\n\tuntil i>j;\n\tif l < j then qs(l,j);\n\tif i < r then qs(i,r);\nend;\n\nbegin\t\n\treadln(n);\n\tfor h:=1 to n do\n\t\tread(a[h]);\n\tp:=0;\n\tqs(1,n);\n\tfor h:=1 to n-2 do\n\t\tif (a[h] + a[h+1] > a[h+2]) then begin p:=1; break; end;\n\n\tif p=1 then writeln('YES')\n\t\t\telse writeln('NO');\nend."}, {"source_code": "var a:array [1..100001] of longint;i,j,k,s,n:longint;\nprocedure sort(l,r:longint);\nvar m,i,j,x1:longint;\nbegin\n i:=l;\n j:=r;\n m:= round ((l+r)/2);\n x1:=a[m];\n repeat\n while a[i]x1 do dec(j);\n if i<=j then\n begin\n m:=a[i];\n a[i]:=a[j];\n a[j]:=m;\n inc(i);\n dec(j);\n end;\n until i>j;\nif l1) and (k<=n) do begin\nif a[i]+a[j]>a[k] then\ns:=1\nelse\n begin\n i:=i+1;\n j:=j+1;\n k:=k+1;\n end;\nend;\nif s=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var i,n,x,y,z:longint;\na:array[1..100050] of longint;\nprocedure qsort(l,r: longint);\nvar i,j,x,y: longint;\nbegin\ni:=l;\nj:=r;\nx:=a[(l+r) div 2];\nrepeat\n while a[i]j) then begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\nuntil i>j;\nif lc)and(b+c>a)and(c+a>b) then test:=true else test:=false;\nend;\nbegin\nread(n);\nfor i:=1 to n do begin\n read(a[i]);\nend;\nqsort(1,n);\nfor i:=3 to n do begin\n if test(a[i-2],a[i-1],a[i]) then begin\n write('YES');\n exit;\n end;\nend;\nwrite('NO');\nend."}, {"source_code": "program z1;\ntype tlist = array[1..100000] of longint;\nvar a:tlist;\n n,i:longint;\nprocedure qsort(var a : tlist);\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[l + random(r-l+1)];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[i]) then\nbegin\nwrite('YES');\nexit;\nend;\nend;\nwrite('NO');\nend.\n"}, {"source_code": "var\n a : array[0..250000] of int64;\n i,j,n,m : longint;\n\n procedure qs(l,r : longint);\n var\n i,j : longint;\n k,t : int64;\n begin\n i:=l; j:=r;\n k:=a[l+random(r-l+1)];\n repeat\n while a[i] < k do inc(i);\n while a[j] > k do dec(j);\n if i > j then break;\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i); dec(j);\n until i > j;\n if l < j then qs(l,j);\n if i < r then qs(i,r);\n end;\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n qs(1,n);\n for i:=3 to n do if (a[i]+a[i-1] > a[i-2]) and (a[i]+a[i-2] > a[i-1]) and (a[i-1]+a[i-2] > a[i]) then begin writeln('YES'); halt; end;\n writeln('NO');\nend."}, {"source_code": "program z2;\nvar a,b,c,d,i,j,k,l,m,n:longint; Z:array[1..100000] of longint;\n\nProcedure sort(l,r:longint);\nvar i,j,x,y:longint;\nbegin\ni:=l; j:=r; x:=Z[l+random(r-l+1)];\nrepeat\nwhile Z[i]x do dec(j);\nif not(i>j) then\n begin\n y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y;\n inc(i); dec(j);\n end;\nuntil i>j;\nif iz)and(x+z>y)and(z+y>x) then sravn:=1 else sravn:=0;\n end;\nprocedure sort(l,r: longint);\nvar\ni,j,x,y: longint;\nbegin\ni:=l;\nj:=r;\nx:=a[(l+r) div 2];\nrepeat\nwhile a[i]j) then\nbegin\ny:=a[i];\na[i]:=a[j];\na[j]:=y;\ninc(i);\nj:=j-1;\nend;\nuntil i>j;\nif lj) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l1 do\n begin\n mid:=(r+l) div 2;\n if a[mid]>=x then r:=mid\n else l:=mid;\n end;\n if a[l]0)and (p>i+1) then begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var a:array[1..100000] of longint;\ni,j,k,n:longint;\nok: boolean;\n\nprocedure sort(l,r:longint);\nvar i,j,x,tmp:longint;\nbegin\n i:= l; j:= r; x:=a[(l+r) div 2];\n repeat\n while (a[i]x) and (j>=i) do dec(j);\n if i<=j then\n begin\n tmp:= a[i]; a[i]:=a[j]; a[j]:= tmp;\n inc(i); dec(j);\n end;\n until i>j;\n if ij) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lp)and(m+p>k)and(p+k>m) then exit(True) else\n exit(False);\n end;\n\nBEGIN\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\n\nsort(1, n);\n\nfor i:=1 to n-2 do\n if test(a[i], a[i+1], a[i+2])=True then\n begin\n found := True;\n break;\n end;\n\nif found=True then writeln('YES') else\n writeln('NO');\n\nEND."}, {"source_code": "var i,j,i1,n:longint;\n f:boolean;\n a:array[1..100000] of longint;\nbegin\n readln(n);\n f:=false;\n for i:=1 to n do\n read(a[i]);\n if n<=5000 then\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n for i1:=j+1 to n do\n if (a[i]+a[j]>a[i1])and(a[i1]+a[j]>a[i])and(a[i]+a[i1]>a[j]) then\n begin\n f:=true;\n break;\n end;\n if n>5000 then\n f:=true;\n if f then\n writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "var n,i:longint;\na:array[1..100000]of longint;\nprocedure Qsort(first,last:longint);\n var L,R,Temp,X:longint;\n begin\n if firstx do\n dec(r);\n If l<=r then\n begin\n temp:=a[l];\n a[l]:=a[r];\n a[r]:=temp;\n inc(l);\n dec(r);\n end;\n end;\n Qsort(First,R);\n Qsort(L,Last);\n end;\n end;\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\nQsort(1,n);\nfor i:=1 to n-2 do\n if a[i]+a[i+1]>a[i+2] then\n begin\n write('YES');\n halt;\n end;\nwrite('NO');\nend."}, {"source_code": "var a:array[1..100010] of longint;\ni,j,n:longint;\nb,c,d:int64;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lb) and (b+c>d) and (b+d>c) then begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var a:array[1..100000] of longint;\n i,n:longint;\n data:boolean;\nProcedure QuickSort(L,R : longint);\n var\n i, j, x, t : longint;\n begin\n i := L; j := R; x:=a[L+random(R-L+1)];//x := a[(L+R) div 2];\n repeat\n while a[i] < x do i := i + 1;\n while a[j] > x do j := j - 1;\n if i<=j\n then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n i := i + 1; j := j - 1;\n end;\n until i>j;\n if Labs(a[i+1]-a[i+2]))and\n(a[i+1]>abs(a[i]-a[i+2]))\nand(a[i+2]>abs(a[i]-a[i+1])) then begin data:=true; break; end;\nif data then writeln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var a: array of longint;\ni,n: longint;\nb: boolean;\n\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[i+2] then\nbegin\nb:=true;\nbreak;\nend;\nif b<>true then write('NO') else write('YES');\nreadln;\nend.\n\n\n\n\n\n"}, {"source_code": "var\n\n a : array [0..111111] of longint;\n i,j,x,xx,n : longint;\n\nprocedure qs(l,r :longint);\nbegin\n\n i:=l; j:=r; x:=a[random(r-l+1)+l];\n \n while i <= j do begin\n\n while a[i] < x do inc(i);\n while a[j] > x do dec(j);\n \n if i <= j then begin\n xx:=a[i]; a[i]:=a[j]; a[j]:=xx;\n inc(i); dec(j);\n end;\n end;\n \n if i < r then qs(i,r);\n if l < j then qs(l,j);\nend;\n\nbegin\n\n readln(n);\n \n for i:=1 to n do\n read(a[i]);\n \n qs(1,n);\n \n i:=1;\n \n while i <= n-2 do begin\n\n if a[i]+a[i+1] > a[i+2] then\n begin\n writeln('YES');\n halt;\n end;\n inc(i);\n end;\n \n writeln('NO');\n end.\n "}, {"source_code": "var \n a,b,i,n,k,j:longint;\n x:array[1..111111]of longint;\nprocedure sort(l,r:longint);\nvar i,e,j,t:longint;\nbegin\n i:=l;\n j:=r;\n e:=x[l+random(r-l+1)];\n while i<=j do\n begin\n while e>x[i] do inc(i);\n while el then sort(l,j);\nend; \nbegin\n read(n);\n for i:=1 to n do\n read(x[i]);\n sort(1,n);\n \n for i:=1 to n-2 do\n if (x[i]+x[i+1]>x[i+2]) and (x[i]+x[i+2]>x[i+1]) and (x[i+1]+x[i+2]>x[i]) then begin writeln('YES');halt;end;\n writeln('NO');\nend. "}, {"source_code": "var\n i,j,n,k,l:longint;\n a:array[1..100005] of longint;\nprocedure swap(var a, b: longint);\nvar\n temp: longint;\nbegin\n temp := a;\n a := b;\n b := temp;\nend;\n\nprocedure qs(l, r: longint);\nvar\n border, i: longint;\nbegin\n if l < r then begin\n swap(a[random(r - l + 1) + l], a[r]);\n border := l;\n for i := l to r - 1 do\n if (a[i] < a[r]) or ((a[i] = a[r]) and (random(2) = 1)) then begin\n swap(a[border], a[i]);\n inc(border);\n end;\n swap(a[border], a[r]);\n qs(l, border - 1);\n qs(border + 1, r);\n end;\nend;\n\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n qs(1,n);\n for i:=2 to n-1 do\n begin\n if a[i]+a[i-1]>a[i+1] then begin writeln('YES'); exit; end;\n end;\n writeln('NO');\n\nend."}, {"source_code": "Program CodeF_396_B;\nvar mas:array[1..100000]of int64;\n i,n,t:longint;\nprocedure swap(var a,b:int64);\nvar c:int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\n\nProcedure q_sort2(a,b:longint);\nvar p,i,j:longint;\n q:int64;\nbegin\nif b-a>1 then\n begin\n p:=random(b-a+1)+a;\n q:=mas[p];\n swap(mas[p], mas[a]);\n i:=a+1;\n j:=b;\n while iq do dec(j);\n if imas[b]) then swap(mas[a],mas[b]);\n\n\nend; \n\n\nbegin\nread(n);\nfor i:=1 to n do\n read(mas[i]);\nfor i:=1 to n-2 do\n if (mas[i+2] j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\nbegin\n readln(n);\n for n:=1 to n do\n read(v[n]);\n qsort(1,n);\n for n:=1 to n-2 do\n Begin\n if(v[n]+v[n+1]>v[n+2])and(v[n]+v[n+2]>v[n+1])and(v[n+1]+v[n+2]>v[n])\n then begin writeln('YES');halt;end;\n end;\n writeln('NO');\nend."}, {"source_code": "var i,j,i1,n:longint;\n f:boolean;\n a:array[1..100000] of longint;\nbegin\n readln(n);\n f:=false;\n for i:=1 to n do\n read(a[i]);\n if n<=5000 then\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n for i1:=j+1 to n do\n if (a[i]+a[j]>a[i1])and(a[i1]+a[j]>a[i])and(a[i]+a[i1]>a[j]) then\n begin\n f:=true;\n break;\n end;\n if n>5000 then\n f:=true;\n if f then\n writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "var a:array[1..100000]of longint;\nl,r,mid,i,j,n:longint;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if la[i+1] then begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n n,i:longint;\n a:array[0..100000] of longint;\nprocedure kp(x,y:longint);\nvar\n l,r,m:longint;\nbegin\n l:=x;\n r:=y;\n m:=a[(l+r)>>1];\n repeat\n while a[l]m do dec(r);\n if l<=r then begin\n a[0]:=a[l];\n a[l]:=a[r];\n a[r]:=a[0];\n inc(l);\n dec(r);\n end;\n until l>r;\n if la[i+2] then begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var i,n:longint;\n a:array[1..100000] of longint;\n\nprocedure swap(var x,y:longint);\nvar z:longint;\nbegin\n z:=x; x:=y; y:=z;\nend;\n\nprocedure qs(m,t:longint);\nvar i,j,x:longint;\nbegin\n i:=m; j:=t;\n x:=a[m+random(t-m+1)];\n repeat\n while a[i]x do dec(j);\n if j>=i then begin\n swap(a[i],a[j]);\n inc(i); dec(j);\n end;\n until i>j;\n if ikey do dec(j1);\n if i1<=j1 then\n begin\n buf:=a[i1];\n a[i1]:=a[j1];\n a[j1]:=buf;\n inc(i1);\n dec(j1);\n end;\n until i1>j1;\n if la[j] then\n begin\n r:=a[i];\n a[i]:=a[j];\n a[j]:=r;\n end\n else sort(1,n);\n end;\n {for i:=1 to n do\n write(a[i],' ');}\n for i:=3 to n do\n if a[i-2]+a[i-1]>a[i] then\n begin\n writeln('YES');\n halt(0);\n end;\n\n writeln('NO');\n {m1:}\nEND.\n"}, {"source_code": "var\n n,i,j,s : integer;\n n1 : array of integer;\n \nprocedure qsort(l, r: longint);\nvar\n i, j, x, y: longint;\nbegin\n randomize;\n i := l;\n j := r;\n x := n1[random(r - l + 1) + l];\n repeat\n while(n1[i] < x) do inc(i);\n while(n1[j] > x) do dec(j);\n if(i <= j) then\n begin\n y := n1[i];\n n1[i] := n1[j];\n n1[j] := y;\n i:=i+1; j:=j-1;\n end;\n \n until (i > j);\n if(l < j) then qsort(l, j);\n if(i < r) then qsort(i, r);\nend;\n\n\nbegin\n randomize;\n readln(n);\n SetLength(n1,n);\n for i := 0 to n-1 do\n begin\n read(n1[i]);\n end;\n \n qsort(0,n-1);\n \n for i := 0 to n-3 do\n begin\n if (n1[i] + n1[i+1]) > n1[i+2] then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var i, n : longint;\n a : array[1..100100] of longint;\n\nfunction ran(l, r : longint) : longint;\nbegin\n ran := random(r - l + 1) + l;\nend;\n\nprocedure swap(var x, y : longint);\nvar tmp : longint;\nbegin\n tmp := x; x := y; y := tmp;\nend;\n\nprocedure qsort(l, r : longint);\nvar i, j, mid, key : longint;\nbegin\n i := l; j := r;\n mid := ran(l, r);\n key := a[mid];\n repeat\n while (a[i] < key) do inc(i);\n while (a[j] > key) do dec(j);\n if (i <= j) then\n begin\n swap(a[i], a[j]);\n inc(i); dec(j);\n end;\n until (i > j);\n if (i < r) then qsort(i, r);\n if (l < j) then qsort(l, j);\nend;\n\nbegin\n readln(n);\n for i := 1 to n do read(a[i]);\n qsort(1, n);\n for i := 1 to n - 2 do\n begin\n if (a[i] + a[i + 1] > a[i + 2]) then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": " var i,n,j,r:longint;\n a:array [1..100000] of longint;\n procedure qsort (L,R:longint);\n var ii,jj,x,m:longint;\n begin\n ii:=L;\n jj:=R;\n m:=a[(L+R) div 2];\n while ii<=jj do\n begin\n while a[ii]m do dec (jj);\n if ii<=jj then begin\n x:=a[ii];\n a[ii]:=a[jj];\n a[jj]:=x;\n inc (ii);\n dec (jj);\n end;\n\n\n\n\n end;\n if Lj;\n\tif la[i] then begin ok:=true; break; end;\n\tif ok then writeln('YES') else writeln('NO');\n\tclose(input); close(output);\nend.\n\n"}, {"source_code": "\n\nvar i,j,i1,n:longint;\n f:boolean;\n a:array[1..100000] of longint;\nbegin\n readln(n);\n f:=false;\n for i:=1 to n do\n read(a[i]);\n if n<=5000 then\n for i:=1 to n-2 do\n for j:=i+1 to n-1 do\n for i1:=j+1 to n do\n if (a[i]+a[j]>a[i1])and(a[i1]+a[j]>a[i])and(a[i]+a[i1]>a[j]) then\n begin\n f:=true;\n break;\n end;\n if n>5000 then\n f:=true;\n if f then\n writeln('YES') else\n writeln('NO');\nend."}, {"source_code": "var a:array[1..100000] of int64;\n n,i:longint;\n\nprocedure qsort(l,r:longint);\nvar i,j:longint;\n q,w:int64;\nbegin\ni:=l; j:=r;\nq:=a[(l+r)div 2];\nrepeat\n while a[i] < q do inc(i);\n while q < a[j] do dec(j);\n if i<=j then \n begin\n w:=a[i]; a[i]:=a[j]; a[j]:=w;\n inc(i); dec(j);\n end;\nuntil i>=j;\nif li then qsort(i,r);\nend; \n\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n \n qsort(1,n);\n \n i:=3;\n \n while (a[i-1]+a[i-2] <= a[i]) and (i<=n) do inc(i);\n if i > n then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "program _766B;\nvar\n a : array[1..100000] of longint; \n n, i, t : longint;\nprocedure QSort(L, R : longint);\n var \n i, j, x, t : longint;\n begin\n i := L; j := R; x := a[L + random(R - L + 1)];\n repeat\n while a[i] < x do inc(i);\n while a[j] > x do dec(j);\n if i <= j \n then begin\n t := a[i]; a[i] := a[j]; a[j] := t;\n inc(i); dec(j);\n end;\n until i > j;\n if L < j then QSort(L, j);\n if i < R then QSort(i, R);\n end;\nbegin\n read(n);\n for i := 1 to n do\n read(a[i]);\n QSort(1, n);\n t := 0;\n for i := 3 to n do\n if a[i] < a[i - 1] + a[i - 2]\n then begin\n t := 1; break;\n end;\n if t = 1\n then write('YES')\n else write('NO');\nend.\n"}, {"source_code": "var n,k,x,i,m:longint;\n a,h:array[0..100001] of int64;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if lh[c] then\n begin\n h[i]:=h[c];\n i:=c;\n end else k:=1;\n end;\n h[i]:=l;\n del:=d;\n end;\n\n\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nreadln(m);\nfor i:=1 to m do\n begin\n read(x);\n add(x);\n end;\nfor i:=1 to m do a[i]:=del;\nx:=0;\nfor i:=2 to m-1 do\n if (a[i]a[i] do inc(i);\n while xj)then begin\n q:=a[i];\n a[i]:=a[j];\n a[j]:=q;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[i+2])and(a[i]+a[i+2]>a[i+1])and(a[i+2]+a[i+1]>a[i])then begin write('YES');exit;end;\n write('NO');\nEND.\n"}, {"source_code": "var A:ARRAY[1..300000]OF LONGINT;\n N,I:LONGINT; CHECK:BOOLEAN;\nprocedure sort(l,r:longint);\nvar x,i,j,t:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[random(r-l+1)+l];\n repeat\n while xa[j] do dec(j);\n if i<=j then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\nif ic) and (a+c>b) and (b+c>a) then tr:=true else tr:=false;\nend;\nbegin\n read(n);\n for i:=1 to n do\n read(a[i]);\n sort(1,n);\n check:=false;\n for i:=1 to n-2 do\n if tr(a[i],a[i+1],a[i+2]) then check:=true;\n if check then write('YES') ELSE WRITE('NO');\nEND."}, {"source_code": "VAR n,i:longint;\n a:array[1..100000]of longint;\nProcedure Qsort(l,r:longint);\n Var x,i,j,q:longint;\n Begin\n i:=l;\n j:=r;\n x:=a[(l+r)div 2];\n repeat\n while x>a[i] do inc(i);\n while xj)then begin\n q:=a[i];\n a[i]:=a[j];\n a[j]:=q;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[i+2]then begin write('YES');exit;end;\n write('NO');\nEND.\n"}, {"source_code": "var i,n:longint;\n a:array[1..100000] of longint;\n\nprocedure swap(var x,y:longint);\nvar z:longint;\nbegin\n z:=x; x:=y; y:=z;\nend;\n\nprocedure qs(m,t:longint);\nvar i,j,x:longint;\nbegin\n i:=m; j:=t;\n x:=a[m+random(t-m+1)];\n repeat\n while a[i]x do dec(j);\n if j>=i then begin\n swap(a[i],a[j]);\n inc(i); dec(j);\n end;\n until i>j;\n if i m do dec(j);\n if i > j then break;\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i);\n dec(j);\n until i > j;\n if l < j then qs(l,j);\n if i < r then qs(i,r);\n end;\n\nbegin\n randomize;\n readln(n);\n for i:=1 to n do read(a[i]);\n qs(1,n);\n\n for i:=1 to n-2 do\n begin\n if (a[i]+a[i+1] > a[i+2]) and (a[i]+a[i+2] > a[i+1]) and (a[i+1]+a[i+2] > a[i]) then\n begin writeln('YES'); halt; end;\n end;\n\n writeln('NO');\nend.\n\n\n\n\n"}, {"source_code": "program ad;\nvar a: array [1..100000] of longint;\ni,j,n,k,t: longint;\n\n\n\nprocedure stop(s: string);\nbegin\nwrite(s);\nhalt;\nend;\n\nprocedure check(a,b,c: longint);\nbegin\nif (a+b>c) and (a+c>b) and (b+c>a) then stop('YES');\nend;\n\nprocedure sort(m,t: longint);\nvar i,j,w,h: longint;\nbegin\ni:=m;\nj:=t;\nw:= a[ random(t-m)+m ];\nrepeat\n while a[i]w do dec(j);\n if i<=j then\n begin\n h:=a[i];\n a[i]:=a[j];\n a[j]:=h;\n inc(i);\n dec(j);\n end;\nuntil i>j;\nif mmid do dec(j);\n if i<=j then begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i); dec(j);\n end;\n until i>j;\n if i0 then break;\n end;\n if ans>0 then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "var\n a, b, c, i: longint;\n v: array [1..1000000] of int64;\n\nprocedure qSort(l, r: longint);\nvar\n i, j: longint;\n w, q: int64;\nbegin\n i := l;j := r;\n q := v[(l + r) div 2];\n repeat\n while (v[i] < q) do inc(i);\n while (q < v[j]) do dec(j);\n if (i <= j) then\n begin\n w := v[i];v[i] := v[j];v[j] := w;\n inc(i);dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l, j);\n if (i < r) then qSort(i, r);\nend;\n\nbegin\n readln(a);\n for i := 1 to a do \n begin\n read(v[i]);\n end;\n Qsort(1, a);\n for i := a downto 3 do \n begin\n if (v[i] < v[i - 1] + v[i - 2]) then\n if (v[i - 1] < v[i] + v[i - 2]) then\n if (v[i - 2] < v[i] + v[i - 1] ) then \n inc(c);\n end;\n if (c > 0) then write('YES')\n else write('NO');\nend."}, {"source_code": "\n \n \nvar\n a: array [1..100000] of longint;\n \nprocedure swap(var a, b: longint);\nvar\n temp: longint;\nbegin\n temp := a;\n a := b;\n b := temp;\nend;\n \nprocedure quicksort(l, r: longint);\nvar\n border, i: longint;\nbegin\n if l < r then begin\n swap(a[random(r - l + 1) + l], a[r]);\n border := l;\n for i := l to r - 1 do\n if (a[i] < a[r]) or ((a[i] = a[r]) and (random(2) = 1)) then begin\n swap(a[border], a[i]);\n inc(border);\n end;\n swap(a[border], a[r]);\n quicksort(l, border - 1);\n quicksort(border + 1, r);\n end;\nend;\n \nvar\n n, i: longint;\n \nbegin\n read(n);\n for i := 1 to n do\n read(a[i]);\n \n quicksort(1, n);\n \n for i:=1 to (n-2) do\n begin\n if (a[i]+a[i+1]>a[i+2]) then\n begin\n write('YES');\n exit;\n end;\n end;\n write('NO');\nend. \n "}, {"source_code": "var a:array[-10..200000]of longint;\n n,i:longint;\nprocedure qsort(l,r:longint);\nvar m,q,i,j:longint;\nbegin\n i:=l;j:=r;\n m:=a[(i+j)div 2];\n while im do dec(j);\n if i<=j\n then begin\n q:=a[i];\n a[i]:=a[j];\n a[j]:=q;\n inc(i);dec(j);\n \n end;\n end;\nif ia[i+2]\n then begin write('YES');halt;end;\n write('NO');\n\n\n\nend."}, {"source_code": "var a:array[0..10000]of longint;i,j,n:longint; \nPROCEDURE HV(VAR a,b:longint);\nVAR tmp:longint;\nBEGIN\n tmp:=a;a:=b;b:=tmp;\nEND;\n\nPROCEDURE QS(l,r:longint);\nVAR i,j,k:longint;\nBEGIN\n i:=l;j:=r;k:=a[(l+r)div 2];\n REPEAT\n WHILE a[i]k DO j:=j-1;\n IF i<=j THEN\n BEGIN\n HV(a[i],a[j]);\n i:=i+1;j:=j-1;\n END;\n UNTIL i>j;\n IF i50 then write('YES') else begin \n for i:=1 to n do read(a[i]);\n qs(1,n);\n for i:=3 to n do if a[i] b) then min := b else min := a;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if (a > b) then max := a else max := b;\nend;\n\nprocedure qsort( min, max: Integer);\nvar\n i, j : integer;\n sd, t: integer;\nbegin\n sd:=a[max-((max-min) div 2)];\n i:=min; j:=max;\n while i sd do j:=j-1;\n if i<=j then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n i:=i+1; j:=j-1;\n end;\n end;\n if min (a[i])) and (i >= 3) then\n begin\n writeln('YES');\n halt(0);\n end;\n writeln('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g, f, x:integer;\n a: array [0..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n if (n >= 45) then\n writeln('YES')\n else begin\n for i := 1 to n do begin\n for j := i + 1 to n do begin\n for x := j + 1 to n do begin\n if (a[i] + a[x] > a[j]) and (a[j] + a[x] > a[i]) and (a[i] + a[j] > a[x]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 1) then\n break;\n end;\n if (g = 1) then\n break;\n end;\n if (g = 1) then\n break;\n end;\n if (g = 0) then\n writeln('NO');\n end; \n readln;\nend.\n"}, {"source_code": "var a:array[1..100002] of int64;\n n,i,j,m:longint;\n test:boolean;\n procedure sort(l,r:longint);\n var g,f:longint; mid,t:int64;\n begin\n g:=l;\n f:=r;\n if g>=f then exit;\n mid:=a[(l+r) div 2];\n while gmid do dec(f);\n if g<=f then begin\n t:=a[g];\n a[g]:=a[f];\n a[f]:=t;\n inc(g);\n dec(f);\n end;\n end;\n sort(l,f);\n sort(g,r);\n end;\n\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n sort(1,n);\n for i:=1 to n-2 do\n begin\n if (a[i]+a[i+1]>a[i+2])\n and (a[i]+a[i+2]>a[i+1])\n and (a[i+2]+a[i+1]>a[i])\n then begin\n test:=true;\n writeln('YES');\n break;\n end;\n end;\n if test=false then writeln('NO');\n\n end."}, {"source_code": "var\na:array [1..100008] of integer;\nn,x,b1,b2:int64;\ni,j,h:integer;\n\nprocedure QuickSort( L, R : Integer ); { ������� ���������� ������� A[] }\nvar i,j,x,y : integer;\nbegin\n i := l; j := r;\n x := a[(l+r) div 2];\n repeat\n while (A[i] < x) do inc(i);\n while (x < A[j]) do dec(j);\n if ( i <= j ) then\n begin\n y:=A[i]; a[i]:=a[j]; a[j]:=y;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then QuickSort(l,j);\n if (i < r) then QuickSort(i,r);\nend;\nbegin\n readln(n);\n \n for i:=1 to n do\n read(a[i]);\n QuickSort( 1, n );\n\n for i:=1 to n-2 do\n if (a[i]+a[i+1]>a[i+2]) then begin h:=1; break; end;\n\n if h=1 then writeln('YES') else writeln('NO');\n readln;\nend."}, {"source_code": "//a < b + c\n//b < a + c\n//c < a + b\n//sort\n//1 2 l\nvar\n n, i: longint;\n a: array [1..100005] of longint;\n\nprocedure sort(l,r: longint);\nvar\n i, j, x, y: longint;\nbegin\n i := l;\n j := r;\n x := a[(l + r) div 2];\n repeat\n while a[i] < x do\n inc(i);\n while x < a[j] do\n dec(j);\n if not (i > j) then\n begin\n y := a[i];\n a[i] := a[j];\n a[j] := y;\n inc(i);\n j := j - 1;\n end;\n until i > j;\n if l < j then\n sort(l, j);\n if i < r then\n sort(i, r);\nend;\n\nvar\n ta, tb, tc: longint;\n\nfunction test(a, b, c: longint): boolean;\nbegin\n if (a + b <= c) or (a + c <= b) or (b + c <= a) then\n test := false\n else\n test := true;\nend;\n\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n sort(1, n);\n {for ta := 1 to n do\n for tb := ta + 1 to n do\n for tc := n downto tb + 1 do\n if test(a[ta], a[tb], a[tc]) then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');//}\n //WP\n for i := n downto 3 do\n if test(a[i], a[i - 1], a[i - 2]) then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\n //}\nend."}, {"source_code": "var\nn:longint;\ni:integer;\na:array [1..100001] of longint;\n\nfunction pr(p,l:longint):longint;\nvar i,j,t,x:longint;\nbegin\ni:=p-1;j:=l+1;x:=a[p];\nwhile i=a[j];\nif ia[i+1] then begin\nwrite('YES');exit;end;\nwrite('NO');\nend.\n"}, {"source_code": "var a:array[0..100009] of longint;\n i,n:longint;\n\nprocedure sort(l,r:longint);\n var i,j,m,k,t:longint;\n begin\n i:=l;\n j:=r;\n m:=random(r-l)+l+1;\n k:=a[m];\n repeat\n while k>a[i] do inc(i);\n while kj) then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[i+2] then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\n end;\n\nbegin\n//assign(input,'b.inp');reset(input);\n//assign(output,'b.out');rewrite(output);\nxuli;\nend.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='b';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014000]of longint;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h]=qc[h+d] then inc(d) else\n if qc[h]qc[i+2] then begin writeln('YES'); halt; end;\n writeln('NO');\n\n\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var n,m,z,i,summ:longint; mass:array[0..1000000] of integer;\n\nprocedure qSort(l,r:longint);\nvar i,j:longint;\n w,q:int64;\nbegin\n i := l; j := r;\n q := mass[(l+r) div 2];\n repeat\n while (mass[i] < q) do inc(i);\n while (q < mass[j]) do dec(j);\n if (i <= j) then\n begin\n w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;\n inc(i); dec(j);\n end;\n until (i > j);\n if (l < j) then qSort(l,j);\n if (i < r) then qSort(i,r);\nend;\n\nbegin\n\nread(n);\n\nfor i:=1 to n do\nbegin\n read(mass[i]);\nend;\n\nqsort(1,n);\n\nfor i:= n downto 3 do\nbegin\n if(mass[i]+mass[i-1] > mass[i-2]) and (mass[i-2]+mass[i-1] > mass[i]) and (mass[i]+mass[i-2] > mass[i-1]) then\n begin\n write('YES');\n exit;\n end;\nend;\n\nwrite('NO');\n\nend."}, {"source_code": "var a:array [1..100001] of longint;i,j,k,s,n:longint;\nprocedure sort(l,r:longint);\nvar m,i,j,x1:longint;\nbegin\n i:=l;\n j:=r;\n m:= round ((l+r)/2);\n x1:=a[m];\n repeat\n while a[i]x1 do dec(j);\n if i<=j then\n begin\n m:=a[i];\n a[i]:=a[j];\n a[j]:=m;\n inc(i);\n dec(j);\n end;\n until i>j;\nif l1) and (k<=n) do begin\nif a[i]+a[j]>a[k] then\ns:=1\nelse\n begin\n i:=i+1;\n j:=j+1;\n k:=k+1;\n end;\nend;\nif s=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}], "negative_code": [{"source_code": "uses\n SysUtils;\n\nvar\n n, i: integer;\n a: array [0..1000000] of integer;\n\nfunction min(a, b: int64): int64;\nbegin\n if (a > b) then min := b else min := a;\nend;\n\nfunction max(a, b: int64): int64;\nbegin\n if (a > b) then max := a else max := b;\nend;\n\nprocedure qsort( min, max: Integer);\nvar\n i, j : integer;\n sd, t: integer;\nbegin\n sd:=a[max-((max-min) div 2)];\n i:=min; j:=max;\n while i sd do j:=j-1;\n if i<=j then\n begin\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n i:=i+1; j:=j-1;\n end;\n end;\n if min= (a[i] div 2 + 1)) and (i >= 3) then\n begin\n writeln('YES');\n halt(0);\n end;\n writeln('NO');\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g:integer;\n a: array [0..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 3 to n do\n if (a[i] + a[i - 1] >= a[i - 2]) and (a[i - 1] + a[i - 2] >= a[i]) and (a[i] + a[i - 2] >= a[i - 1]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g:integer;\n a: array [2..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 1 to n do\n if (a[i] + a[i + 1] >= a[i + 2]) and (a[i + 1] + a[i + 2] >= a[i]) and (a[i] + a[i + 2] >= a[i + 1]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g, f:integer;\n a: array [0..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 1 to n do begin\n f := a[i];\n for j := i + 1 to n do\n if (f + a[j + 1] > a[j]) and (a[j] + a[j + 1] > f) and (f + a[j] > a[j + 1]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 1) then\n break; \n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g:integer;\n a: array [2..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 3 to n do\n if (a[i] + a[i - 1] >= a[i - 2]) and (a[i - 1] + a[i - 2] >= a[i]) and (a[i] + a[i - 2] >= a[i - 1]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g:integer;\n a: array [0..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 3 to n do\n if (a[i] + a[i - 1] > a[i - 2]) and (a[i - 1] + a[i - 2] > a[i]) and (a[i] + a[i - 2] > a[i - 1]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, n, g, f:integer;\n a: array [0..100000] of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n g := 0;\n for i := 1 to n do begin\n f := a[i];\n for j := i + 1 to n do\n if (f + a[j + 1] > a[j]) and (a[j] + a[j + 1] > f) and (f + a[j + 1] > a[j]) then begin\n writeln('YES');\n g := 1;\n break;\n end;\n if (g = 1) then\n break; \n end;\n if (g = 0) then\n writeln('NO');\n readln;\nend.\n"}, {"source_code": "program otrezki;\nvar\nn,i: int64;\nfirst,last,start,final,j,min,y,z: int64;\na,b: array[1..100001] of int64;\nprocedure Merge(first,last: int64);\n var\n i: int64;\n begin\n start:=first;\n final:=(first+last) div 2+1;\n for i:=first to last do\n begin\n if (start <= (first+last) div 2) and ((final > last) or (a[start] < a[final])) then\n begin\n b[i]:=a[start];\n inc(start);\n end else\n begin\n b[i]:=a[final];\n inc(final);\n end;\n end;\n for i:=first to last do a[i]:=b[i];\n end;\n \nprocedure MergeSort(first, last: int64);\n begin\n if first < last then\n begin\n MergeSort(first,(first+last) div 2);\n MergeSort((first+last) div 2+1,last);\n Merge(first, last);\n end;\n end;\nprocedure FindLowestTriangle;\n begin\n i:=1;\n j:=3;\n min:=10000000000;\n while j<=N do\n begin\n if a[j] - a[i] <= min then\n begin\n min:=a[j] - a[i];\n y:=i;\n z:=j;\n end;\n inc(i);\n inc(j);\n end;\n end;\nbegin\nread(n);\nfor i:=1 to N do\n read(a[i]);\nMergeSort(1,N);\nFindLowestTriangle;\nif (a[y]+a[y+1] > a[z]) and (a[z]+ a[y] > a[y+1]) and (a[z] + a[y+1] > a[y]) then\n write('YES') else write('NO');\nend.\n"}, {"source_code": "var a:array[1..100010] of longint;\ni,j,n:longint;\nb,c,d:int64;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=b) then begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var a:array[1..100010] of longint;\ni,j,n,b,c,d:longint;\n\nprocedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l=d) and (c+d>=b) and (b+d>=c) then begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "Program CodeF_396_B;\nvar mas:array[1..100000]of int64;\n i,n,t:longint;\nprocedure swap(var a,b:int64);\nvar c:int64;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\n\nProcedure q_sort2(a,b:longint);\nvar p,i,j:longint;\n q:int64;\nbegin\nif b-a>1 then\n begin\n p:=random(b-a+1)+a;\n q:=mas[p];\n swap(mas[p], mas[a]);\n i:=a+1;\n j:=b;\n while iq do dec(j);\n if imas[b]) then swap(mas[a],mas[b]);\n\n\nend; \n\n\nbegin\nread(n);\nfor i:=1 to n do\n read(mas[i]);\nfor i:=1 to n-2 do\n if (mas[i+2]x) do dec(j);\n if i<=j then \n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n end;\n if (l=a[n] then write('NO') else write('YES');\nend."}, {"source_code": "var i,n: longint;\n a: array[1..100000] of longint;\nprocedure qsort(l,r: longint);\nvar i,j,m,t,x: longint;\nbegin\n i:=l;\n j:=r;\n m:=(l+r) div 2;\n x:=a[m];\n while (i<=j) do\n begin\n while (a[i]x) do dec(j);\n if i<=j then \n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n end;\n if (la[i+1] then write('YES') else write('NO');\nend."}, {"source_code": "Const fi='';\n fo='';\nVar n:longint;\n a:array[-10..100000] of longint;\nProcedure nhap;\n Var i:longint;\n begin\n assign(input,fi); reset(input);\n readln(n);\n For i:=1 to n do read(a[i]);\n Close(input);\n end;\n procedure sort(l,r: longint);\n var\n i,j,x,y: longint;\n begin\n i:=l;\n j:=r;\n x:=a[(l+r) div 2];\n repeat\n while a[i]j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 do\n begin\n i:=i-3; j:=j-2; k:=k-1;\n if (a[i] + a[k]>a[j]) and (abs(a[i]-a[k])j) then\n begin\n y:=a[i];\n a[i]:=a[j];\n a[j]:=y;\n inc(i);\n j:=j-1;\n end;\n until i>j;\n if l0 do\n begin\n i:=i-3; j:=j-2; k:=k-1;\n if (a[i] + a[k]>a[j]) and (abs(a[i]-a[k])a[k]) and (a[j]+a[k]>a[i]) and (a[j]-a[k]x1 do dec(j);\n if i<=j then\n m:=a[i];\n a[i]:=a[j];\n a[j]:=m;\n inc(i);\n dec(j);\n until i>j;\nif l1) and (k<=n) do begin\nif a[i]+a[j]>a[k] then\ns:=1\nelse\n begin\n i:=i+1;\n j:=j+1;\n k:=k+1;\n end;\nend;\nif s=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "var a:array [1..10001] of longint;i,j,k,s,n:longint;\nprocedure sort(l,r:longint);\nvar m,i,j,x1:longint;\nbegin\n i:=l;\n j:=r;\n m:= round ((l+r)/2);\n x1:=a[m];\n repeat\n while a[i]x1 do dec(j);\n if i<=j then\n m:=a[i];\n a[i]:=a[j];\n a[j]:=m;\n inc(i);\n dec(j);\n until i>j;\nif l1) and (k<=n) do begin\nif a[i]+a[j]>a[k] then\ns:=1\nelse\n begin\n if (i+1=j) and (j+1=k) then\n k:=k+1;\n if i+1=j then\n j:=j+1\n else\n i:=i+1\n end;\nend;\nif s=1 then\nwriteln('YES')\nelse\nwriteln('NO');\nend."}, {"source_code": "type\n mass=array[1..1000]of longint;\nvar\n a:mass;\n i,n,j,q:longint;\ntest:boolean;\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\ntest:=false;\nif n>14 then\nbegin\nfor i:=1 to n-2 do\n begin\n if test=true then break;\n for j:=i+1 to n-1 do\n begin\n if test=true then break;\n for q:=j+1 to n do\n if (a[i]b then corp:=true\n else corp:=false;\nend;\nprocedure sort ( first, last: integer);\n var L, R, c, X: integer;\n begin\n if first < last then\n begin\n X:= A[(first + last) div 2];\n L:= first;\n R:= last;\n while L <= R do\n begin\n while A[L] < X do\n L:= L + 1;\n while A[R] > X do\n R:= R - 1;\n if L <= R then\n begin\n c:= A[L];\n A[L]:= A[R];\n A[R]:= c;\n L:= L + 1;\n R:= R - 1;\n end;\n end;\n sort(first, R); \n sort(L, last);\n end;\n end; \n\n\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\ntest:=false;\nsort(1,n);\nfor i:=1 to (n-2) do\n if a[i]x do\n dec(r);\n If l<=r then\n begin\n temp:=a[l];\n a[l]:=a[r];\n a[r]:=temp;\n inc(l);\n dec(r);\n end;\n end;\n Qsort(First,R);\n Qsort(L,Last);\n end;\n end;\nbegin\nreadln(n);\nfor i:=1 to n do\n read(a[i]);\nfor i:=1 to n-2 do\n if a[i]y then\n begin\n r:=a[i]; a[i]:=a[y-1]; a[y-1]:=r;\n end;\n end;\n end;\n if y-ip>1 then qs(ip,y-1);\n if ik-y>1 then qs(y+1,ik);\nend;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n qs(1,n);\n for i:=2 to n-1 do\n begin\n if a[i]+a[i-1]>a[i+1] then begin writeln('YES'); exit; end;\n end;\n writeln('NO');\n\nend."}, {"source_code": "var\n i,j,n,k,l:longint;\n a:array[1..100005] of longint;\nprocedure qs(ip,ik:longint);\nvar\n i,y,r:longint;\n p:boolean;\nbegin\n y:=ip;\n for i:=ip+1 to ik do\n begin\n if a[i]y then\n begin\n r:=a[i]; a[i]:=a[y-1]; a[y-1]:=r;\n end;\n end;\n end;\n if y-ip>1 then qs(ip+1,y-1);\n if ik-y>1 then qs(y+1,ik-1);\nend;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n qs(1,n);\n for i:=2 to n-1 do\n begin\n if a[i]+a[i-1]>a[i+1] then begin writeln('YES'); exit; end;\n end;\n writeln('NO');\n\nend."}, {"source_code": "var\n i,j,n,k,l:longint;\n a:array[1..100000] of longint;\nprocedure qs(ip,ik:longint);\nvar\n i,y,r:longint;\nbegin\n y:=ip;\n for i:=ip+1 to ik do\n begin\n if a[i]y then\n begin\n r:=a[i]; a[i]:=a[y-1]; a[y-1]:=r;\n end;\n end;\n end;\n if y-ip>1 then qs(ip,y-1);\n if ik-y>1 then qs(y+1,ik);\nend;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n qs(1,n);\n for i:=1 to n do\n write(a[i],' ');\n writeln;\n for i:=2 to n-1 do\n begin\n if a[i]+a[i-1]>a[i+1] then begin writeln('YES'); {writeln(i); }exit; end;\n end;\n writeln('NO');\n\nend."}, {"source_code": "var\n n,i,j,s : integer;\n n1 : array of integer;\n \nprocedure qsort(l, r: longint);\nvar\n i, j, x, y: longint;\nbegin\n randomize;\n i := l;\n j := r;\n x := n1[random(r - l + 1) + l];\n repeat\n while(n1[i] < x) do inc(i);\n while(n1[j] > x) do dec(j);\n if(i <= j) then\n begin\n y := n1[i];\n n1[i] := n1[j];\n n1[j] := y;\n end;\n i:=i+1; j:=j-1;\n until (i > j);\n if(l < j) then qsort(l, j);\n if(i < r) then qsort(i, r);\nend;\n\n\nbegin\n randomize;\n readln(n);\n SetLength(n1,n);\n for i := 0 to n-1 do\n begin\n read(n1[i]);\n end;\n qsort(0,n-1);\n for i := 0 to n-3 do\n begin\n if n1[i] + n1[i+1] > n1[i+2] then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "var\n n,i,j,s : integer;\n n1 : array of integer;\n \nprocedure qsort(l, r: longint);\nvar\n i, j, x, y: longint;\nbegin\n randomize;\n i := l;\n j := r;\n x := n1[random(r - l + 1) + l];\n repeat\n while(n1[i] < x) do inc(i);\n while(n1[j] > x) do dec(j);\n if(i <= j) then\n begin\n y := n1[i];\n n1[i] := n1[j];\n n1[j] := y;\n i:=i+1; j:=j-1;\n end;\n \n until (i > j);\n if(l < j) then qsort(l, j);\n if(i < r) then qsort(i, r);\nend;\n\n\nbegin\n randomize;\n readln(n);\n SetLength(n1,n);\n for i := 0 to n-1 do\n begin\n read(n1[i]);\n end;\n \n qsort(0,n-1);\n \n for i := 0 to n-1 do\n begin\n write(n1[i],' ');\n end;\n for i := 0 to n-3 do\n begin\n if (n1[i] + n1[i+1]) > n1[i+2] then\n begin\n writeln('YES');\n exit;\n end;\n end;\n writeln('NO');\nend."}, {"source_code": "uses math;\nconst\n\tfi = '';\n\tfo = '';\n\tmaxn = 100001;\nvar\ta:array[0..maxn] of longint;\n\tn,i:longint;\nprocedure QS(l,r:longint);\nvar i,j,x,t:longint;\nbegin\n\ti:=l; j:=r; x:=a[(l+r) div 2];\n\trepeat\n\t\twhile a[i]j;\n\tif la[n] then writeln('YES') else writeln('NO');\n\tclose(input); close(output);\nend.\n\n"}, {"source_code": "var a:array[1..100000] of int64;\n n,i:longint;\n\nprocedure qsort(l,r:longint);\nvar i,j:longint;\n q,w:int64;\nbegin\ni:=l; j:=r;\nq:=a[(l+r)div 2];\nrepeat\n while a[i] < q do inc(i);\n while q < a[j] do dec(j);\n if i<=j then \n begin\n w:=a[i]; a[i]:=a[j]; a[j]:=w;\n inc(i); dec(j);\n end;\nuntil i>=j;\nif li then qsort(i,r);\nend; \n\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n \n qsort(1,n);\n \n i:=3;\n \n while (a[i-1]+a[i-2] < a[i]) and (i<=n) do inc(i);\n if i > n then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "var\n n,i,l,r,c,x: longint;\n a: array [0..111111] of longint;\n\n procedure qs(l,r: longint);\n var\n t,m,i,j: longint;\n begin\n i:=l;\n j:=r;\n m:=a[random(r-l+1)+l];\n repeat\n while a[i] < m do inc(i);\n while a[j] > m do dec(j);\n if i > j then break;\n t:=a[i]; a[i]:=a[j]; a[j]:=t;\n inc(i);\n dec(j);\n until i > j;\n if l < j then qs(l,j);\n if i < r then qs(i,r);\n end;\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n qs(1,n);\n\n for i:=1 to n-1 do\n begin\n l:=1;\n r:=i-1;\n if l > r then continue;\n x:=a[n]+a[i]-1;\n while l < r do\n begin\n c:=(l+r) div 2;\n if a[c] >= x then r:=c else l:=c+1;\n end;\n\n if (a[n]+a[i] > a[l]) and (a[n]+a[l] > a[i]) and (a[l]+a[i] > a[n]) then\n begin writeln('YES'); halt; end;\n\n l:=i+1;\n r:=n-1;\n if l > r then continue;\n x:=a[n]+a[i]-1;\n while l < r do\n begin\n c:=(l+r) div 2;\n if a[c] >= x then r:=c else l:=c+1;\n end;\n\n if (a[n]+a[i] > a[l]) and (a[n]+a[l] > a[i]) and (a[l]+a[i] > a[n]) then\n begin writeln('YES'); halt; end;\n end;\n\n writeln('NO');\nend.\n\n\n"}, {"source_code": " var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n j:=i+2;\n while j<=n do\n begin\n if ((a[i]+a[j]>=a[j-1]) and (a[i]+a[j-1]>=a[j]) and (a[j]+a[j-1]>=a[i])) and (abs(a[i]-a[j-1])<=a[j]) then\n begin\n Writeln('YES');\n test:=true;\n break;\n end;\n inc(j);\n end;\n if test=true then break;\n end;\n if test=false then writeln('NO');\n end."}, {"source_code": " var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n procedure sort(l,r:longint);\n var g,f:longint; mid,t:int64;\n begin\n g:=l;\n f:=r;\n if g>=f then exit;\n mid:=a[(l+r) div 2];\n while a[g]mid do dec(f);\n if g<=f then begin\n t:=a[g];\n a[g]:=a[f];\n a[f]:=t;\n inc(g);\n dec(f);\n end;\n sort(l,f);\n sort(g,r);\n end;\n\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n sort(1,n);\n for i:=2 to n-1 do\n begin\n if (a[i]+a[i-1]>a[i+2])\n and (a[i]+a[i+2]>a[i-1])\n and (a[i+2]+a[i-1]>a[i])\n then begin\n test:=true;\n writeln('YES');\n break;\n end;\n end;\n if test=false then writeln('NO');\n end."}, {"source_code": " var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n-2 do\n begin\n j:=i+2;\n while j<=n do\n begin\n if ((a[i]+a[j]>=a[j-1]) and (a[i]+a[j-1]>=a[j]) and (a[j]+a[j-1]>=a[i])) and (abs(a[i]-a[j-1])<=a[j]) then\n begin\n Writeln('YES');\n test:=true;\n break;\n end;\n inc(j);\n end;\n if test=true then break;\n end;\n if test=false then writeln('NO');\n end.\n"}, {"source_code": " var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n j:=i+2;\n while j<=n do\n begin\n if (a[i]+a[j]>=a[j-1]) and (a[i]+a[j-1]>=a[j]) and (a[j]+a[j-1]>=a[i]) then\n begin\n Writeln('YES');\n test:=true;\n break;\n end;\n inc(j);\n end;\n if test=true then break;\n end;\n if test=false then writeln('NO');\n end."}, {"source_code": "var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n procedure sort(l,r:longint);\n var g,f:longint; mid,t:int64;\n begin\n g:=l;\n f:=r;\n if g>=f then exit;\n mid:=a[(l+r) div 2];\n while a[g]mid do dec(f);\n if g<=f then begin\n t:=a[g];\n a[g]:=a[f];\n a[f]:=t;\n inc(g);\n dec(f);\n end;\n sort(l,f);\n sort(g,r);\n end;\n\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n sort(1,n);\n for i:=1 to n-2 do\n begin\n j:=i+2;\n while j<=n do\n begin\n if ((a[i]+a[j]>=a[j-1]) and (a[i]+a[j-1]>=a[j]) and (a[j]+a[j-1]>=a[i])) and (abs(a[i]-a[j-1])<=a[j]) then\n begin\n Writeln('YES');\n test:=true;\n break;\n end;\n inc(j);\n end;\n if test=true then break;\n end;\n if test=false then writeln('NO');\n end."}, {"source_code": " var a:array[1..100010] of int64;\n n,i,j,m:longint;\n test:boolean;\n begin\n test:=false;\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n j:=i+2;\n while j<=n do\n begin\n if (a[i]+a[j]>a[j-1]) and (a[i]+a[j-1]>a[j]) and (a[j]+a[j-1]>a[i]) then\n begin\n Writeln('YES');\n test:=true;\n break;\n end;\n inc(j);\n end;\n if test=true then break;\n end;\n if test=false then writeln('NO');\n end."}, {"source_code": "var\n a, b: ansistring;\n\nbegin\n readln(a);\n read(b);\n if a = b then\n begin\n writeln(-1);\n exit;\n end;\n if length(a) > length(b) then\n writeln(length(a))\n else\n if length(b) > length(a) then\n writeln(length(b))\n else\n begin\n writeln(length(a));\n end;\nend."}, {"source_code": "var a:array[0..100009] of longint;\n i,n:longint;\n\nprocedure sort(l,r:longint);\n var i,j,m,k,t:longint;\n begin\n i:=l;\n j:=r;\n m:=random(r-l)+l+1;\n k:=a[m];\n repeat\n while k>a[i] do inc(i);\n while kj) then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[n]) and (a[n]-a[n-1]a[i] do inc(i);\n while kj) then\n begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n inc(i);\n dec(j);\n end;\n until i>j;\n if la[n]) and (a[n-1]-a[n-2]' ') do\n i:=i+1;\nn:=i+1;\ns1:=s1+s[1];\ni:=2;\nwhile (s[i]' ') then\n s1:=s1+s[i];\n i:=i+1;\nend;\ns1:=s1+s[n];\nwrite(s1);\nend.\n"}, {"source_code": "var a, b: string;\n i: integer;\nbegin\n readln (a);\n b := a;\n delete(a, pos(' ', a), 100);\n delete(b, 1, pos(' ', b));\n\n write(a[1]);\n i := 2;\n while (a[i] length( s2 )\n then minl := length( s2 );\n for i := 1 to minl do\n begin\n if s1[ i ] = s2[ i ]\n then continue;\n if s1[ i ] < s2[ i ]\n then\n begin\n min := s1;\n exit;\n end;\n if s1[ i ] > s2[ i ]\n then\n begin\n min := s2;\n exit;\n end;\n end;\n if length( s1 ) > length( s2 )\n then min := s2\n else min := s1;\n end;\nprocedure use( n : longint );\n var\n temp : string;\n i : longint;\n begin\n if ans = ''\n then\n begin\n for i := 1 to n do\n ans := ans + na[i] ;\n ans := ans + s[1];\n end\n else\n begin\n temp := '';\n for i := 1 to n do\n temp := temp + na[i];\n temp := temp + s[1];\n ans := min( ans, temp );\n end;\n end;\n\nbegin\n readln( s );\n na := copy( s, 1, pos( ' ', s ) - 1 );\n delete( s, 1, pos( ' ', s ) );\n for i := 1 to length( na ) do\n use( i );\n writeln( ans );\nend."}, {"source_code": "var s,s1:string; i:longint;\nbegin\nreadln(s);\ns1:=copy(s,1,pos(' ',s)-1);\ndelete(s,1,pos(' ',s));\nwrite(s1[1]);\nfor i:=2 to length(s1) do\n if s1[i]ord(' ')) do\nbegin\nwrite(s[i]);i:=i+1;end;\nwrite (f);\nend."}, {"source_code": "var\n s,s2,s3,min:string;\n i,j,x:longint;\nbegin\n min:='zzzzzz';\n readln(s);\n x:=pos(' ',s);\n s2:=copy(s,x+1,length(s)-x+1);\n delete(s,x,length(s)-x+1);\n for i:=1 to length(s) do\n for j:=1 to length(s2) do\n begin\n s3:=copy(s,1,i)+copy(s2,1,j);\n if s3' ' do begin\na[i]:=s[i];\ninc(i);\nend;\nia:=i;\nq:=s[i+1];\ni:=2;\nwrite(a[1]);\nwhile (a[i]' ' do\n Begin\n b:=b+a[i];\n inc(i);\n End;\n inc(i);\n s:=b[1];\n j:=2;\n While (j<=length(b)) and (i<=length(a)) do\n Begin\n If b[j]' ' then c:=c+s[i]\n else begin pos:=i; break; end;\n end;\n for i:=pos+1 to length(s) do\n begin\n f:=f+s[i];\n end;\n k:=k+c[1];\n for i:=2 to length(c) do\n begin\n if ord(c[i])length(s1) then\n break;\n end;\n writeln(s,s2[1]);\n end;\nend.\n"}, {"source_code": "var ch:char;\n s,t,ans,now,x:string;\n i,j:longint;\nbegin\n while not eoln do\n begin\n read(ch);\n if ch<>' ' then s:=s+ch else\n begin\n t:=s;\n s:='';\n end;\n end;\n for i:=1 to length(s)+length(t) do\n ans:=ans+'z';\n for i:=1 to length(t) do\n begin\n now:=now+t[i];\n x:=now;\n for j:=1 to length(s) do\n begin\n x:=x+s[j];\n if x' ' do\nbegin\na:=a+s1[i];\ni:=i+1;\nend;\n\ni:=i+1;\n\nwhile i<=length(s1) do\nbegin\nb:=b+s1[i];\ni:=i+1;\nend;\n\ns:=s+a[1];\nfor i:=2 to length(a) do\n begin\n if a[i]j) then\n begin\n y:=aa[i];aa[i]:=aa[j];aa[j]:=y;inc(i);j:=j-1;\n end;\nuntil i>j;\nif la[j] then begin s2:=a[i];a[i]:=a[j];a[j]:=s2;end;\nwrite(a[1]);\nend."}, {"source_code": "var \n s : string;\n i, j, k : integer;\nbegin\n read(s);\n write(s[1]);\n k := pos(' ', s);\n for i := 2 to k - 1 do\n if s[i] < s[k + 1]\n then \n write(s[i])\n else \n break;\n write(s[k + 1]);\nend."}, {"source_code": "var\n s1,s2,s3,min:ansistring;\n i,j,x:longint;\nbegin\n readln(s1);\n min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';\n x:=pos(' ',s1);\n s2:=copy(s1,x+1,length(s1));\n delete(s1,x,length(s1));\n for i:=1 to length(s1) do\n for j:=1 to length(s2) do\n begin\n s3:=copy(s1,1,i);\n s3:=s3+copy(s2,1,j);\n if s30 then delete(s4,x8,1);\nend;\n }\nwriteln(s4);\n\nend.\n\n\n\n"}, {"source_code": "var st,st1,st2,otv:string;\ni,k,ind:integer;\nbegin\nreadln(st);\nfor i:=1 to length(st) do begin\nif k=1 then inc(k);\nif st[i]=' ' then k:=1; \nif k=0 then st1:=st1+st[i];\nif k=2 then st2:=st2+st[i];\nend;\notv:=otv+st1[1];\nk:=1;\nwhile ind<>1 do begin\ninc(k);\nif (k<=length(st1))and(st1[k]' ' do\n begin\n \n st1:=st1+ch;\n inc(i);\n ch:=st[i];\n \n end;\n ch:='a';\n inc(i);\n while ch<>' ' do\n begin\n ch:=st[i];\n st2:=st2+ch;\n \n \n inc(i);\n end;\n //writeln(st1);\n min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';\n for i:=2 to length(st1) do\n begin\n for j:=1 to length(st2) do\n begin\n st3:='';\n for k:=2 to i do\n st3:=st3+st1[k];\n for k:=1 to j do\n st3:=st3+st2[k];\n if st3' ') do begin write(s[i]);inc(i);end;\n write(s[a]);\nend."}, {"source_code": " const eps=0.000000001; besk=20000000000008;\n modul=1000000007;\n label 1,2,3,4,5,6;\n type\n int64=longint;\n mas=array [-100..1000000] of int64; point=record x,y,z,vx,vy,vz:int64;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;\n mass=array[-100..1000000] of int64;mass1=^mass;\n var j1,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;\n mask,k, step, i,j:longint;\n pointnew,pointold,pointklad,ppoint:point;\n vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;\n mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;\n a,b,c:mass;\n sd:array[-1000..1000000] of char;\n yyy:array[-10..10000] of extended;\n dot,ddd:array[-10..1210000] of int64;\n ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;\n sss,text1,text2:array[-10..2000000] of string;\n zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;\n sot,ss,stest,ss3,ss1,ss2:string;\n ch1,ch2:char;\n traf,dd1,dd:array[-1..5000,-1..5000] of int64;\n zan,zana,zanb:array[-10..2000000] of boolean;\n marked:array[-100..15000] of boolean;\n {sss:string;ch:char;\n } pole1,pole :array [-10..150,-10..150] of char;\n st:array[-100..100000] of string;\n v0,v1,t0:extended;\n zv:point;\n newx,newy:array[-1..200000] of int64;\n\n koef,yot:extended;\n globflag, flag2,flag,flag1:boolean;\n function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n{procedure udal(ii:longint);\nbegin next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii]; end;\n }\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\nfunction good(ch:char):boolean;\nbegin\n if (ord(ch)>20)and(ord(ch)<220) then good:=true else good:=false;\n\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n readln(ss); n:=length(ss);\n for i:=1 to n do if ss[i]=' ' then ii:=i;\n for i:=1 to ii-1 do ss1:=ss1+ss[i];\n for i:=ii+1 to n do ss2:=ss2+ss[i];\n\n {writeln(ss1,' ',ss2);\n } p1:=length(ss1);\n p2:=length(ss2);\n { goto 1; }\n q:=0;\n for i:=1 to p1 do for j:=1 to p2 do\n begin\n inc(q); sss[q]:='';\n for i1:=1 to i do sss[q]:=sss[q]+ss1[i1];\n for j1:=1 to j do sss[q]:=sss[q]+ss2[j1];\n\n { writeln(q,' ',sss[q]);\n }\n end;\n\n sot:=sss[1];\n\n for i:=1 to q do if sss[i] ' ' do\n begin\n temp := s[i] + temp;\n Dec(i);\n end;\n i := 1;\n while s[i] <> ' ' do\n begin\n temp1 := temp1 + s[i];\n Inc(i);\n end;\n s1 := temp1[1];\n for i := 2 to Length(temp1) do\n begin\n if temp1[i] < temp[1] then\n s1 := s1 + temp1[i]\n else Break;\n end;\n s1:=s1+temp[1];\n write(s1);\nend.\n"}, {"source_code": "var\ns:string;\ni,k:longint;\nbegin\n readln(s);\n i:=1;\n write(s[1]);\n while(i' ' do\n inc(i);\n while s[i]=' ' do\n inc(i);\n j:=2;\n while (s[j]' ') do\n inc(j);\n writeln(copy(s,1,j-1),s[i]);\nend."}, {"source_code": "var\na,b,x,min:string;\ni,j:longint;\nbegin\nreadln(a);\nb:=copy(a,pos(' ',a)+1,length(a)-pos(' ',a)+1);\ndelete(a,pos(' ',a),length(a)-pos(' ',a)+1);\nmin:='zzzzzzzzzzzzzzzzzzzzzzzz';\nfor i:=1 to length(a) do\n for j:=1 to length(b) do\n begin\n x:=copy(a,1,i)+copy(b,1,j);\n if xord(x[1])) or (ord(z[a])=ord(x[1])) then begin\n s:=a;\n f:=1;\n break;\n end;\n if f=1 then for a:=1 to s-1 do\n write (z[a]) else for a:=1 to length(z) do write (z[a]);\n write (x[1]);\nend."}, {"source_code": "var\n s1,s2,s3,min:ansistring;\n i,j,k:longint;\nbegin\n min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';\n readln(s1);\n k:=pos(' ',s1);\n s2:=copy(s1,k+1,length(s1));\n delete(s1,k,length(s1));\n for i:=1 to length(s1) do\n for j:=1 to length(s2) do\n begin\n s3:=copy(s1,1,i)+copy(s2,1,j);\n if s3s2[i-1] then ans:=ans+s2[i]\n else break;\n write(ans);\nend."}, {"source_code": "var a:array [1..11] of char;\nb:array [1..11] of char;\ni,f,ia,ib:integer;\nq:char;\ns:string;\nbegin\ni:=1;\nread(s);\nwhile s[i]<>' ' do begin\na[i]:=s[i];\ninc(i);\nend;\nia:=i;\nfor i:=1 to (length(s)-ia) do\nb[i]:=s[i+ia];\nib:=i;\ni:=1;\nif a[i]<=b[i] then begin write(a[i]); inc(i);\nwhile (a[i]b[i]) and (i<=ib) do begin write (b[i]); inc(i);end;\nwrite(a[1]);\nend;\nend.\n\n"}, {"source_code": "var\n s,s2,s3,min:string;\n i,j,x:longint;\nbegin\n readln(s);\n x:=pos(' ',s);\n s2:=copy(s,x+1,length(s)-x+1);\n delete(s,x,length(s)-x+1);\n for i:=1 to length(s) do\n for j:=1 to length(s2) do\n begin\n s3:=copy(s,1,i)+copy(s2,1,j);\n if s3s2[i-1] then ans:=ans+s2[i]\n else break;\n write(ans);\nend."}, {"source_code": "var s, s1, s2:string; i:byte;\nbegin\n read(s);\n for i:=1 to length(s) do\n if s[i]=' ' then begin\n s1:=copy(s, 1, i-1);\n s2:=copy(s, i+1, length(s));\n end;\n write(s1[1]);\n i:=2;\n while s1[i]>s2[1] do begin\n write(s1[i]); i:=i+1; end;\n write(s2[1]);\nend."}, {"source_code": "var s, s1, s2:string; i:byte;\nbegin\n read(s);\n for i:=1 to length(s) do\n if s[i]=' ' then begin\n s1:=copy(s, 1, i-1);\n s2:=copy(s, i+1, length(s));\n end;\n write(s1[1]);\n for i:=2 to length(s1) do\n if s1[i]<=s1[i-1] then write(s1[i]) else break;\n write(s2[1]);\n i:=2;\n while (s1[i-1]>s2[i-1]) do begin\n read(s2[i]); i:=i+1; end;\nend."}, {"source_code": "var s, s1, s2:string; i:byte;\nbegin\n read(s);\n for i:=1 to length(s) do\n if s[i]=' ' then begin\n s1:=copy(s, 1, i-1);\n s2:=copy(s, i+1, length(s));\n end;\n write(s1[1]);\n for i:=2 to length(s1) do\n if s1[i]=s2[i-1]) do begin\n read(s2[i]); i:=i+1; end;\nend."}, {"source_code": "var s, s1, s2:string; i:byte;\nbegin\n read(s);\n for i:=1 to length(s) do\n if s[i]=' ' then begin\n s1:=copy(s, 1, i-1);\n s2:=copy(s, i+1, length(s));\n end;\n write(s1[1]);\n for i:=2 to length(s1) do\n if s1[i]<=s1[i-1] then write(s1[i]) else break;\n write(s2[1]);\nend."}, {"source_code": "var\ts:ansistring;\n\ti,vt,j:longint;\n\tc:char;\nbegin\n\treadln(s);\n\tfor i:=1 to length(s) do\n\t\tif s[i]=' ' then break;\n\tif (s[2]' ' do\n inc(i);\n while s[i]=' ' do\n inc(i);\n writeln(s[1],s[i]);\nend."}, {"source_code": "var s1,s2,ans:string;\ni,j,x:longint;\nbegin\n read(s1);\n x:=pos(' ',s1);\n s2:=copy(s1,x+1,length(s1)-x+1);\n delete(s1,x,length(s1)-x+1);\n ans:=s1[1];\n for i:=2 to length(s1) do\n if s1[i]s2[i-1] then ans:=ans+s2[i]\n else break;\n write(ans);\nend."}, {"source_code": "var s,a,b:ansistring;\nc:char;\ni,q:longint;\nbegin\nreadln(s);\na:=copy(s,1,pos(' ',s)-1);\nb:=copy(s,pos(' ',s)+1,length(s));\nc:=a[1];\nq:=1;\nfor i:=2 to length(a) do\n if a[i]ord(x[1]) then begin\n s:=a;\n f:=1;\n break;\n end;\n if f=1 then for a:=1 to s-1 do\n write (z[a]) else for a:=1 to length(z) do write (z[a]);\n write (x[1]);\nend."}, {"source_code": "var st,st1,st2,otv:string;\ni,k:integer;\nbegin\nreadln(st);\nfor i:=1 to length(st) do begin\nif k=1 then inc(k);\nif st[i]=' ' then k:=1; \nif k=0 then st1:=st1+st[i];\nif k=2 then st2:=st2+st[i];\nend;\notv:=otv+st1[1];\nk:=1;\nwhile otv[k]<>st2[1] do begin\ninc(k);\nif (k<=length(st1))and(st1[k] ' ' do\n begin\n temp := s[i] + temp;\n Dec(i);\n end;\n i := 1;\n while s[i] <> ' ' do\n begin\n temp1 := temp1 + s[i];\n Inc(i);\n end;\n s1 := temp1[1];\n for i := 2 to Length(temp1) do\n begin\n if temp1[i] < temp[1] then\n s1 := s1 + temp1[i]\n else Break;\n end;\n s1:=s1+temp[1];\n for i:=2 to Length(temp) do\n begin\n if temp[i]>temp[i-1] then\n s1:=s1+temp[i]\n else Break;\n end;\n write(s1);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar\n s, s1, temp, temp1: string;\n i: Integer;\n\nbegin\n read(S);\n i := Length(s);\n while s[i] <> ' ' do\n begin\n temp := s[i] + temp;\n Dec(i);\n end;\n i := 1;\n while s[i] <> ' ' do\n begin\n temp1 := temp1 + s[i];\n Inc(i);\n end;\n s1 := temp1[1];\n for i := 2 to Length(temp1) do\n begin\n if temp1[i] < temp[1] then\n s1 := s1 + temp1[i]\n else Break;\n end;\n s1:=s1+temp[1];\n for i:=2 to Length(temp) do\n begin\n if temp[i]>temp[Length(temp)] then\n s1:=s1+temp[i]\n else Break;\n end;\n write(s1);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nvar\n s, s1, temp, temp1: string;\n i: Integer;\n\nbegin\n read(S);\n i := Length(s);\n while s[i] <> ' ' do\n begin\n temp := s[i] + temp;\n Dec(i);\n end;\n i := 1;\n while s[i] <> ' ' do\n begin\n temp1 := temp1 + s[i];\n Inc(i);\n end;\n s1 := temp1[1];\n for i := 2 to Length(temp1) do\n begin\n if Ord(temp1[i]) < ord(temp1[i - 1]) then\n s1 := s1 + temp1[i]\n else Break;\n end;\n s1:=s1+temp[1];\n for i:=2 to Length(temp) do\n begin\n if ord(temp[i])>Ord(temp[i-1]) then\n s1:=s1+temp[i]\n else Break;\n end;\n write(s1);\nend."}, {"source_code": "program Project1;\n\nvar\n Name, SurName, Ans: string;\n Space, i: LongInt;\n\nfunction SuperTrim(var s: string): LongInt;\nvar\n plus, i: LongInt;\nbegin\n plus := 0;\n For i := Length(s) downto 1 do\n begin\n If ord(s[i+plus]) < 33 then\n begin\n Delete(s, i+plus, 1);\n Result := i+plus;\n inc(plus);\n end;\n end;\nend;\n\nbegin\n ReadLn(Name);\n Space := SuperTrim(Name);\n SurName := '';\n For i := Space to Length(Name) do\n begin\n SurName := SurName + Name[Space];\n Delete(Name, Space, 1);\n end;\n Ans := Name[1];\n For i := 2 to Length(Name) do\n begin\n If Name[i] < SurName[1] then\n begin\n Ans := Ans + Name[i]\n end else\n begin\n Ans := Ans + SurName[1];\n Break;\n end;\n If i = Length(Name) then Ans := Ans + SurName[1];\n end;\n WriteLn(Ans);\nend.\n"}, {"source_code": "var\ns,s1:string;\ni,n:longint;\nbegin\nread(s);\ni:=1;\nwhile (s[i]<>' ') do\n i:=i+1;\nn:=i+1;\ns1:=s1+s[1];\ni:=2;\nwhile (s[i]' ') then\n s1:=s1+s[i];\n i:=i+1;\nend;\ns1:=s1+s[n];\nwrite(s1);\nend.\n"}, {"source_code": "var\ns,s1:string;\ni,n:longint;\nbegin\nread(s);\ni:=1;\nwhile (s[i]<>' ') do\n i:=i+1;\nn:=i+1;\ns1:=s1+s[1];\ni:=2;\nwhile (s[i]' ') then\n s1:=s1+s[i];\n i:=i+1;\nend;\ns1:=s1+s[n];\nwrite(s1);\nend.\n"}, {"source_code": "var\n c:char;\n s,p:ansistring;\n i,n,j:longint;\n it:boolean;\n\nbegin\n readln(s);\n for i:=2 to length(s) do\n if s[i-1]=' ' then begin j:=i-1;c:=s[i];break;end;\n p:=s[1];\n for i:=2 to j-1 do if(s[i] ord( fname[i] )\n then\n begin\n ind := i;\n min := ord( fname[i] );\n end;\n end;\n for i := 1 to ind do\n write(fname[i]);\n write(sname[1]);\nend."}, {"source_code": "var\n sname, fname : string;\n min, min2, ind, i : longint;\n\nbegin\n readln( sname );\n fname := copy( sname, 1, pos( ' ', sname ) - 1 );\n delete( sname, 1, pos( ' ', sname ) );\n min := ord( fname[1] );\n ind := 1;\n min2 := ord( sname[1] );\n for i := 2 to length( fname ) do\n begin\n if ( min > ord( fname[i] ) ) and (min2 > ord(fname[i]))\n then\n begin\n ind := i;\n min := ord( fname[i] );\n end;\n end;\n for i := 1 to ind do\n write(fname[i]);\n write(sname[1]);\nend."}, {"source_code": "var\n s,t:string;\n i,n:longint;\nbegin\n readln(s);\n n:=length(s);\n i:=pos(s,' ');\n t:=copy(s,i+1,n);\n delete(s,i,n);\n n:=length(s);\n i:=1;\n while (i<=n) and (s[i]0)do\n begin\n if(c mod 10=8)\n then begin\n writeln(b-a);\n halt;\n end;\n c:=c div 10;\n end;\n inc(b);\n end;\n\nend.\n\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": "Var\n a: Int64;\n cnt: LongInt;\n \nFunction f(x: Int64): Boolean;\nBegin\n f:=false;\n While x<>0 do begin\n If abs(x mod 10) = 8 then f:=true;\n x:=x div 10;\n End;\nEnd; \n \nBegin\n ReadLn(a);\n cnt:=1;\n inc(a);\n While not f(a) do begin\n inc(a);\n inc(cnt);\n End;\n WriteLn(cnt);\nEnd."}, {"source_code": "uses math;\ntype maxx=array[0..200000] of longint;\nvar r,d,kol,n,c,i,k,z,j:longint;\n s:string; res,m1,m,dp,m2,left,right,vr,t:maxx;\n a,b:int64;\nBegin\n // assign(input,'input.txt'); assign(output,'output.txt');\n readln(n);\n for i:=n+1 to n+100 do\n Begin\n a:=abs(i);\n while a>0 do\n Begin\n if a mod 10=8\n then Begin\n writeln(i-n);\n halt(0);\n end;\n a:=a div 10;\n end;\n end;\nend."}, {"source_code": " const eps=1e-11; besk=200000000000000008;\n modul=1000000007;\n label 1,2,3,4;\n type\n\n mas=array [-10000..10000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var p3,p4,t4,t5,t6,t,t1,t2,t3,cc,aa,bb,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,n,kk,qq,ot,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,besk1:int64;\n shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..1000] of char;\n poin:zap;\n vec:array[-100..1000] of zap;\n c1,c2:array[-1000..100000] of int64;\n fact,d, a1,bl,br,c,a,b:array[-300000..2000000] of int64;\n maxsum:array[-1..1010,-1..1010] of int64;\n sss, ss1,ss2:string;\n newgr,gr:array[-100..200000] of boolean;\n pole:array[-1..1500,-1..1500] of int64;\n ss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n pr,aanew,v0,v1,s0,t0:extended;\n z,x1,y1,y,x:array[-1..300000] of int64;\n xxx,yyy:array[-1..100000] of double;\n xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction est8(p:int64):boolean; var fl:boolean;\n begin\n if p<0 then p:=-p; fl:=false;\n while p>0 do begin if p mod 10=8 then fl:=true; p:=p div 10; end;\n est8:=fl;\n end;\n\n\nbegin\n\n {assign (input,'E:\\Projects\\input.txt');reset(input);\n assign (output,'E:\\Projects\\output.txt'); rewrite(output);\n }\n readln(n);\n repeat inc(n); inc(ot); until est8(n);\n writeln(ot);\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "var n:string;\n k,rs,x,err,i:integer;\nbegin\nreadln(n);\nk:=0;\nrs:=0;\nwhile (k=0) or (rs=1) do begin\nval(n,x,err);\nk:=0;\nfor i:=1 to length(n) do\n if n[i]='8' then inc(k);\ninc(x);\nstr(x,n);\ninc(rs);\nend;\nwriteln(rs-1);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+,O-}\nuses SysUtils;\nvar n,m,i,j,l,k:longint;\n s:string;\n f:boolean;\nbegin\n readln(n);\n f:=false;\n for i:=n+1 to n+1000 do\n begin\n str(i,s);\n for j:=1 to length(s) do if (s[j]='8') then\n begin\n m:=i-n;\n f:=true;\n break;\n end;\n if (f) then break;\n end;\n writeln(m);\n read(n);\nend.\n "}, {"source_code": "program zad_1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, u, q :integer;\n n :int64;\n \nfunction prov(nn :int64):boolean;\nvar\n i:integer;\n n :int64;\nbegin\n i := 0;\n n := abs(nn);\n while (n <> 0) do\n begin\n if (n mod 10 = 8) then\n inc(i);\n n := n div 10;\n end;\n if (i <> 0) then\n prov := true\n else\n prov := false;\nend;\n\nbegin\n readln(n);\n q := 1;\n inc(n);\n while (prov(n) = false) do\n begin\n inc(n);\n inc(q);\n end;\n writeln(q);\n readln;\n readln;\nend.\n "}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,s:longint;\n r,m,x:int64;\n begin\n //init;\n read(n);\n inc(n);\n res:=1;\n while true do\n begin\n cur:=n;\n if cur<0 then cur:=-cur;\n for i:=0 to 10 do\n begin\n if cur mod 10=8 then begin writeln(res); exit; end;\n cur:=cur div 10;\n end;\n inc(res);\n inc(n);\n end;\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "var a,i,k:longint;\n f:boolean;\nbegin\n read(a);\n for i:=a+1 to a+30 do\n begin\n k:=i;\n f:=false;\n while k<>0 do\n begin\n if abs(k)mod 10=8 then f:=true;\n k:=k div 10\n end;\n if f then break\n end;\n write(i-a)\nend."}, {"source_code": "Var a,aa:int64;\nFunction prov(a:int64):boolean;\nBegin\n while a<>0 do\n begin\n if abs(a mod 10)=8 then\n begin\n prov:=true;\n exit;\n end;\n a:=a div 10;\n end;\n prov:=false;\nend;\nbegin\n // assign(input,'input.txt');assign(output,'output.txt');\n readln(aa);\n a:=aa;\n inc(a);\n while not prov(A) do inc(a);\n writeln(a-aa);\nend."}, {"source_code": "Var i,n,a,x,k,l:LongInt;\n begin\n read(a);\n l:=1;\n for i:=a+1 to a+100 do\n Begin\n x:=abs(i);\n While x>0 do\n Begin\n if x mod 10=8 then k:=1;\n x:=x div 10;\n End;\n if k=1 then\n Begin\n Write(l);\n halt;\n End;\n inc(l);\n End;\n End."}, {"source_code": "var a,n,c,i:longint;\nbegin\nread(a);\nfor i:=1 to 16 do begin \nif a>-8 then begin\na:=a+1;\nc:=a;\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nend;\nif a<=-8 then begin\na:=a+1;\nc:=a*(-1);\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nend;\nif n=8 then break;\nend;\nend."}, {"source_code": "var n,m,i,j,k,s,g,f,d:longint;\nbegin\n{assign(input,'input.txt'); reset(input);\nassign(output,'output.txt'); rewrite(output); }\nread(n);\nn:=n+1;\nk:=0;\ns:=1;\nwhile k<>1 do begin\nf:=abs(n);\nwhile f>0 do begin\nd:=f mod 10;\nif d=8 then begin k:=1; break; end;\nf:=f div 10;\nend;\ninc(s);\nn:=n+1;\nend;\nwrite(s-1);\n{close(input);\nclose(output); }\nend.\n"}, {"source_code": "Var\n n,i:integer;\nfunction check(n:integer): boolean;\nbegin\n check:=false;\n while n<>0 do begin if abs(n mod 10)=8 then check:=true; n:=n div 10; end;\nend;\nbegin\n readln(n); i:=1;\n while not check(n+i) do inc(i);\n writeln(i);\n readln;\nend.\n"}, {"source_code": "var S:STRING;\n n:int64;\n i,j:integer;\n kq:boolean;\nBEGIN\n readln(n);\n for i:=1 to 100 do\n begin\n n:=n+1;\n str(n,s);\n kq:=false;\n for j:=1 to length(s) do\n if s[j]='8' then\n begin\n writeln(i);\n kq:=true;\n break;\n end;\n if kq=true then break;\n end;\n readln;\nend.\n"}, {"source_code": "var a,k,i: longint; s,q:string;\nbegin\nreadln(a);\nk:=1;\na:=a+1;\nq:='8';\nstr(a,s);\ni:=pos(q,s);\nif i<>0 then begin writeln(1); halt; end;\nwhile i=0 do\nbegin\nk:=k+1;\na:=a+1;\nstr(a,s);\ni:=pos(q,s);\nend;\nwriteln(k);\nend."}, {"source_code": "Program PBA;\nVar a:longint;\ni:byte;\nst:string;\nBegin\nreadln(a);\nFor i:=1 to 16 do\nBegin\ninc(a);\nstr(a,st);\nIf pos('8',st)<>0 then\nBegin\nwrite(i);\nexit;\nEnd;\nEnd;\nEnd."}, {"source_code": "program spcm;\nvar i,n,j,k,kk:int64;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nread(n);\ni:=n ;\nkk:=0;\nwhile true do\n begin\n inc(i);\n inc(kk);\n j:=abs(i);\n while j<>0 do\n begin\n if j mod 10<>8 then\n j:=j div 10\n else begin k:=1; writeln(kk); HALT; end;\n end;\n // if i>888888888 then break;\n end;\n{close(output);\nclose(input);}\nend."}, {"source_code": "program bashnya;\nvar a,b:int64;\n\nfunction proverka(a:int64):boolean;\nbegin\nif a<0 then a:=-a;\nproverka:=false;\nwhile a<>0 do\n begin\n if a mod 10=8 then\n begin\n proverka:=true;\n break;\n end;\n a:=a div 10;\n end;\n\nend;\n\nbegin\nread(a);\nb:=1;\nwhile true do\n begin\n if proverka(a+b)=true then break;\n inc(b);\n end;\nwrite(b);\nend.\n"}, {"source_code": "//488a\nvar n,i,j,k:int64;\n b:boolean;\nbegin\n read(i);\n b:=true;\n while b=true do\n begin\n inc(i);\n inc(j);\n\n k:=abs(i);\n while (k<>0) and ( k mod 10<>8) do k:=k div 10;\n if (k mod 10)=8 then b:=false;\n\n end;\n write(j);\n end.\n"}, {"source_code": " var a,c,x,y:array [1..100000] of longint;\n n,k:int64;\n function p(xx:int64):boolean;\n begin\n xx:=abs(Xx);\n while (xx>0) do\n begin\n if xx mod 10 = 8 then exit(true);\n xx:=xx div 10;\n end;\n exit(false);\n end;\n begin\n read(n);\n inc(n);\n inc(k);\n while true do\n begin\n if p(n) then break;\n inc(n);\n inc(k);\n end;\n writeln(k);\n end."}, {"source_code": "program chuoi;\nvar\n a,b,res:int64;\n s:string;\n i:integer;\nfunction ok(s:string):boolean;\nbegin\n for i:=1 to length(s)do if(s[i]='8')then exit(true);\n exit(false);\nend;\nbegin\n readln(a);\n res:=1;\n a:=a+1;\n b:=abs(a);\n str(b,s);\n while(not ok(s))do\n begin\n res:=res+1;\n a:=a+1;\n b:=abs(a);\n str(b,s);\n end;\n writeln(res);\nend.\n "}, {"source_code": "const fi='';\n fo='';\nvar a,b:int64;\n f:text;\nprocedure input;\nbegin\n assign(f,fi);\n reset(f);\n read(f,a);\n close(f);\nend;\nfunction chk(n:int64):boolean;\nvar s:string;\nbegin\n str(n,s);\n if pos('8',s)<>0 then exit(true)\n else exit(false);\nend;\nprocedure solve;\nbegin\n b:=a+1;\n while not chk(b) do\n b:=b+1;\nend;\nprocedure output;\nbegin\n assign(f,fo);\n rewrite(f);\n write(f,b-a);\n close(f);\nend;\nbegin\n input;\n solve;\n output;\nend.\n "}, {"source_code": "program chuoi;\nvar\n a,b,res:int64;\n s:string;\n i:integer;\nfunction ok(s:string):boolean;\nbegin\n for i:=1 to length(s)do if(s[i]='8')then exit(true);\n exit(false);\nend;\nbegin\n readln(a);\n res:=1;\n a:=a+1;\n b:=abs(a);\n str(b,s);\n while(not ok(s))do\n begin\n res:=res+1;\n a:=a+1;\n b:=abs(a);\n str(b,s);\n end;\n writeln(res);\nend.\n "}, {"source_code": "program zzz;\nvar\n x, i: int64;\n stop: boolean;\nfunction Has8(x: int64): boolean;\nvar\n s: ansistring;\n i: byte;\nbegin\n Str(x, s);\n for i := Length(s) downto 1 do\n if s[i] = '8'\n then begin\n Has8 := true;\n exit;\n end;\n Has8 := false;\nend;\nbegin\n read(x);\n i := x + 1;\n stop := false;\n while not stop do\n begin\n if Has8(i)\n then stop := true\n else inc(i);\n end;\n write(i - x);\nend.\n"}, {"source_code": "var a,k,c:int64; i:longint; t:boolean;\nbegin\nread(a);\nt:=false;\nwhile(t=false)do\nbegin\na:=a+1; i:=i+1;\nk:=a;\n while(k<>0)do\n begin\n c:=abs(k mod 10);\n if(c=8)then begin writeln(i); exit; end;\n k:=k div 10;\n end;\nend;\nend."}, {"source_code": "{-------------------------------------------------\n----oo--o--o-o---o--o----o------oo--o-----o-oooo----\n---o--o-oo-o-o----ooo----o-----o--o--o---o--oooo----\n---o--o-o-oo-o------o----o-----o--o---o-o---o-------\n----oo--o--o-oooo-oo-----ooooo--oo-----o----oooo----\n------------------------------------------------}\n{$MODE OBJFPC}\nprogram Onlylove;\nconst maxN =10;\nvar a : int64;\n\nprocedure enter;\n begin\n readln(a);\n\n end;\nfunction check(a : int64) : boolean;\n var r : integer;\n q : int64;\n begin\n q :=a ;\n if q < 0 then q := -q;\n while q <> 0 do\n begin\n r := q mod 10 ;\n if r = 8 then exit(true) ;\n q := q div 10 ;\n end;\n exit(false);\n end;\nprocedure solve;\n var i : integer;\n begin\n for i:=1 to 25 do\n begin\n inc(a);\n if check(a) then\n begin Writeln(i); break; end;\n end;\n end;\n\nbegin\n enter;\n solve;\n\nend.\n"}, {"source_code": "var\n a, j, i, x: Integer;\nbegin\n ReadLn(a);\n for i:=1 to 30 do\n begin\n a:=a + 1;\n x:=a;\n while x <> 0 do\n begin\n if abs(x mod 10) = 8 then\n begin\n WriteLn(i);\n Halt;\n end;\n x:=x div 10;\n end;\n end\nend."}, {"source_code": "var\n a,kq:longint;\nfunction check(n:longint):boolean;\nvar\n i,j:longint;\nbegin\n while n<>0 do\n begin\n j:=n mod 10;\n n:=n div 10;\n if (j=8) or (j=-8) then\n exit(true);\n end;\n exit(false);\nend;\nfunction cal(n:longint):longint;\nvar\n i,dem:longint;\nbegin\n dem:=0;\n if check(n) then\n begin\n n:=n+1;\n if check(n) then\n exit(1)\n else\n dem:=dem+1;\n end;\n while check(n)=false do\n begin\n n:=n+1;\n dem:=dem+1;\n end;\n exit(dem);\nend;\nbegin\n //assign(input,'lucky.inp');reset(input);\n ///assign(output,'lucky.out');rewrite(output);\n readln(a);\n kq:=cal(a);\n write(kq);\n //close(input);\n //close(output);\nend.\n"}, {"source_code": "var\n s:String;\n N,i,L,ans,j:Longint;\nbegin\n Readln(N);\n for i:=N+1 to N+25 do\nbegin\n Str(i,S);\n L:=Length(S);\n ans:=0;\n for j:=1 to L do\n if s[j]='8' then begin\n ans:=i;\n Break;\n end;\n if ans<>0 then Break;\n end;\n Writeln(ans-N);\n end."}, {"source_code": "program gt;\nlabel 1;\nvar q,a,b,p,r:longint;\nbegin\nreadln(a);\nr:=a;\np:=0;\n1:\na:=a+1;\nb:=abs(a);\nwhile b>0 do\nbegin\nq:=b mod 10;\nb:=b div 10;\nif(q=8)then begin\np:=1;\nbreak;\nend;\nend;\nif(p=1)then writeln(a-r) else goto 1;\nend."}, {"source_code": "var a,n,c,i:longint;\nbegin\nread(a);\nfor i:=1 to 16 do begin\nif a>-8 then begin\na:=a+1;\nc:=a;\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nend;\nif a<=-8 then begin\na:=a+1;\nc:=a*(-1);\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nend;\nif n=8 then break;\nend;\nend."}, {"source_code": "var\n\tfound\t\t: boolean;\n\ta,k,b,c\t\t: longint;\nbegin\n\t\n\treadln(a);\n\tfound:=false;\n\tk:=0;\n\t\n\twhile not(found) do\n\tbegin\n\t\tk:=k+1;\n\t\ta:=a+1;\n\t\tc:=abs(a);\n\t\twhile c>0 do\n\t\tbegin\n\t\t\tb:= c mod 10;\n\t\t\tc:=c div 10;\n\t\t\tif b=8 then\n\t\t\t\tfound:=true;\n\t\tend;\t\n\tend;\n\twriteln(k);\nend."}, {"source_code": "Var n,n2:Int64;\n{=}\nFunction Check:Boolean;\nVar i:Integer; x:String;\nBegin\n Str(n,x);\n For i:=1 to Length(x) do If x[i]='8' then Exit(True);\n Exit(False);\nEnd;\n{=}\nBegin\n Readln(n);\n n2:=n;\n Repeat\n Inc(n);\n Until Check;\n Writeln(n-n2);\n Readln\nEnd.\n"}, {"source_code": "{$mode objfpc}\nuses math;\nconst\n finp = '';\n fout = '';\nvar\n fi,fo : text;\nprocedure openfile;\nbegin\n assign(fi,finp);reset(fi);\n assign(fo,fout);rewrite(fo);\nend;\nprocedure closefile;\nbegin\n close(fi);close(fo);\nend;\nfunction ok(x:int64):boolean;\nvar\n i : integer;\nbegin\n x:=abs(x);\n while x<>0 do\n begin\n if x mod 10=8 then\n exit(true);\n x:=x div 10;\n end;\n exit(false);\nend;\nprocedure process;\nvar\n n,res : int64;\nbegin\n readln(fi,n);\n res:=0;\n repeat\n inc(n);inc(res);\n if ok(n) then\n break;\n until false;\n writeln(fo,res);\nend;\nbegin\n openfile;\n process;\n closefile;\nend.\n"}, {"source_code": "var\n a,m,ans,k:longint;\n\nbegin\n read(a);\n\n while true do\n begin\n inc(a);\n inc(k);\n m:=a;\n while m<>0 do\n begin\n if (m mod 10 = 8)or (m mod 10 = -8) then begin write(k); halt; end;\n m:=m div 10;\n end;\n end;\nend.\n"}, {"source_code": "program cf488A;\nvar a,b,i:longint;\n\nbegin\nread(a);\nfor i:=1 to 100 do\n begin\n b:=a+i;\n while abs(b)>0 do\n begin\n if (abs(b) mod 10=8) then\n begin\n writeln(i);\n exit;\n end;\n b:=b div 10;\n end;\n end;\nend.\n"}, {"source_code": "var\nN,M,K:int64;\ni,a,s,f:longint;\n\nBEGIN\nreadln(N);\nM:=N;K:=N;\nf:=0;\ns:=-1;\nwhile(f=0) do begin\n s:=s+1;\n N:=abs(M);\n for i:=1 to 11 do begin\n a:=N mod 10;N:=N div 10;\n if(a=8) then begin f:=1;end;\n end;\n M:=M+1;\nend; \n\nif(s=0) then begin\n M:=K+1;\nf:=0;\ns:=0;\nwhile(f=0) do begin\n s:=s+1;\n N:=abs(M);\n for i:=1 to 11 do begin\n a:=N mod 10;N:=N div 10;\n if(a=8) then begin f:=1;end;\n end;\n M:=M+1;\nend; \n \n \nend;\nwriteln(s); \n \nEND. "}, {"source_code": "var\n a,ans : int64;\n\n function chk(x : int64) : boolean;\n begin\n x:=abs(x);\n while x <> 0 do begin\n if x mod 10 = 8 then exit(true);\n x:=x div 10;\n end;\n exit(false);\n end;\n\nbegin\n readln(a);\n inc(a);\n while not chk(a) do begin inc(a); inc(ans); end;\n writeln(ans+1);\nend.\n"}, {"source_code": "var \n i:longint;\n n:int64;\n s:ansistring;\n \nBegin\n read(n);\n for i:=1 to 100 do\n begin\n str(n + i, s);\n if pos('8',s) > 0 then\n begin\n writeln(i);\n halt;\n end;\n end;\nend.\n"}, {"source_code": "var n,i: longint;\n\nfunction check(a: longint): boolean;\nvar x: longint;\nbegin\n While a<>0 do\n begin\n x:=a mod 10;\n If abs(x)=8 then exit(true);\n a:= a div 10;\n end;\n exit(false);\nend;\n\nBEGIN\n readln(n);\n If (n>=-8) and (n<8) then writeln(8-n)\n Else\n begin\n For i:=1 to 10 do\n If check(n+i) then\n begin\n writeln(i);\n break\n end;\n end;\nEND.\n"}, {"source_code": "var n,res : int64;\nfunction check(a:int64):boolean;\nbegin\n if a <0 then a:=-a;\n while a <> 0 do\n begin\n if (a mod 10=8) then exit(true);\n a:=a div 10;\n end;\n exit(false);\nend;\nbegin\n readln(n); //n:=n+1000000000;\n res:=1;\n while not check(n+res) do inc(res);\n writeln(res);\nend.\n"}, {"source_code": "var n ,i ,k ,j,p :longint;\n f: boolean;\n begin\n read(n); f:=true;\n while f do begin\n Inc(n);\n Inc(k); p:=Abs(n);\n while p>0 do begin\n i:=p mod 10;\n if i=8 then begin writeln(k); exit; end;\n p:=p div 10;\n end;\n end;\n end.\n"}, {"source_code": "uses sysutils;\n\nvar\n a:string;\n b,x:integer;\n t8,i:integer;\n stop:boolean;\n\nprocedure check;\n begin\n for i:=1 to length(a) do\n if a[i]='8' then stop:=true;\n end;\n\nbegin\nreadln(a);\nfor i:=1 to length(a) do\n if a[i]='8' then inc(t8);\nx:=StrToInt(a);\nif t8>1 then b:=1\n else\n begin\n stop:=false;\n x:=StrToInt(a);\n check;\n while ((stop=false) OR (b=0)) do\n begin\n inc(x);\n a:=IntToStr(x);\n inc(b);\n stop:=false;\n check;\n end;\n end;\nwriteln(b);\nreadln;\nend.\n"}, {"source_code": "uses sysutils;\nvar a, b, i: longint;\n s: string;\nbegin\n readln(a);\n for b := 1 to 20 do\n begin\n inc(a);\n s := inttostr(a);\n for i := 1 to length(s) do\n if s[i] = '8' then\n begin\n writeln(b);\n exit;\n end;\n end;\nend."}, {"source_code": "var\na:int64;\nj,i:longint;\ns:String;\nbegin\nreadln(a);\nfor i:=1 to 1000000 do begin\n a:=a+1;\n str(a,s);\n for j:=1 to length(s) do if s[j]='8' then begin\n writeln(i);\n halt;\n end;\nend;\nend."}, {"source_code": "var s:string;\n n,k,l:Int64;\n i,j:longint;\n begin\n read(n);\n for i:=1 to 30 do\n begin\n inc(n);\n str(n,s);\n for j:=1 to length(s) do\n if s[j]='8' then begin write(i); exit; end;\n end;\n end."}, {"source_code": "var a,b,c,d,f:longint;\nbegin\nreadln(a);\nrepeat\nb:=b+1;\nc:=abs(a+b) div 10;\nd:=abs(a+b) mod 10;\nif d=8 then \nbegin\nf:=1;\nwriteln(b);\nbreak\nend else\nwhile c>0 do\nbegin\nd:=c mod 10;\nc:=c div 10;\nif (d=8) and (f=0) then \nbegin\nwriteln(b);\nf:=1;\nend;\nend;\nuntil f=1;\nend."}, {"source_code": "var i,b,k,a:longint;\nbegin\nread(a);\nb:=0;\nk:=abs(a);\nfor i:=1 to 16 do begin\nif a<0 then b:=k-i\nelse b:=k+i;\nwhile b div 10>0 do begin\nif b mod 10=8 then break;\nb:=b div 10;\nend;\nif abs(b mod 10)=8 then break;\nend;\nwrite(i);\nend."}, {"source_code": "Var\n a,b:integer;\n s:string;\nBegin\n Read (a);\n b:=0;\n repeat\n inc(b);\n inc(a);\n str(a,s);\n until pos('8',s)>0;\n Write (b);\nENd."}, {"source_code": "var\n f:boolean;\n t,dx1,dx,x:longint;\nbegin\n readln(x);\n dx:=x;\n while(true)do\n begin\n inc(dx);\n t:=dx;\n f:=false;\n while(t<>0)do\n begin\n if abs(t mod 10)= 8 then f:=true;\n t:=t div 10;\n end;\n if f then break;\n end;\n writeln(dx-x);\nend.\n"}, {"source_code": "var i,kil:longint;\nn:int64;\nt:string;\nflag:boolean;\nbegin\nreadln(n);\nif n=0 then kil:=8;\nif n<>0 then\n begin\n repeat\n inc(n);\n inc(kil);\n str(n,t);\n for i:=1 to length(t) do if t[i]='8' then begin flag:=true; break; end;\n until flag=true;\n end;\n\nwriteln(kil);\nend."}, {"source_code": "var n,i,a,x:longint;\nbegin\nread(a);\nfor i := 1 to 20 do\n begin\n n:=a+i;\n If n<0 then n:=-n;\n While n>0 do\n begin\n x:=n mod 10;\n n:=n div 10;\n If x = 8 then begin write(i); halt; end;\n end;\n end;\nend."}, {"source_code": "var p,a,k:int64;\nst:string;\nbegin\n readln(a);\n while true do\n begin\n a:=a+1;\n k:=k+1;\n str(a,st);\n p:=pos('8',st);\n if (p<>0) then begin\n writeln(k);\n break;\n end;\n p:=0;\n end;\nend."}, {"source_code": "const fi='';\n fo='';\nvar f,g:Text;\n n,t:int64;\n function check(o:int64):boolean;\n var t:byte;\n begin\n while o<>0 do\n begin\n t:=o mod 10;\n if t=8 then exit(true);\n o:=o div 10;\n end;\n exit(False);\n end;\nbegin\n assign(f,fi);\n reset(F);\n assign(G,fo);\n rewrite(G);\n readln(F,n);\n close(f);\n\n t:=1;\n while check(abs(n+t))=false do inc(t);\n writeln(G,t);\n close(G);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst max1=100000;\ntype vector=array[1..max1] of integer;\nvar\n x:vector;\n s:ansistring;\n fi,fo:textfile;\n n,k:integer;\nprocedure enter;\n var i,j:integer;\n begin\n readln(n);\n end;\nfunction solve(n:integer):integer;\n var i,j:integer;\n begin\n for i:=1 to 888888888 do\n begin\n n:=n+i;\n str(n,s);\n for j:=1 to length(s) do\n begin\n if s[j]='8' then exit(i);\n end;\n n:=n-i;\n end;\n end;\nprocedure print;\n var i:integer;\n begin\n writeln(solve(n));\n end;\nbegin\n {assignfile(fi,'gigatower.inp');reset(fi);\n assignfile(fo,'gigatower.out');rewrite(Fo); }\n enter;\n print;\n {closefile(fi);\n closefile(fo);}\nend.\n"}, {"source_code": "uses math;\nvar\n a,av:longint;\n i,iv,h:longint;\nbegin\n read(a);\n if a<0 then\n begin\n av:=abs(a);\n for i:=av-1 downto 0 do\n begin\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if h=1 then begin writeln(abs(i-av)); halt; end;\n end;\n end;\n if a<0 then begin\n i:=1;\n repeat\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if (h=1) and (i>a) then begin writeln(i-a); halt; end;\n inc(i);\n until i=8888888888;\n end\n else\n begin\n i:=a+1;\n repeat\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if (h=1) and (i>a) then begin writeln(i-a); halt; end;\n inc(i);\n until i=8888888888;\n end;\nend."}, {"source_code": "var\n i,n,b,k,j: longint;\n s: string;\nbegin\n readln(n);\n while j <> 1 do\n begin\n str(n,s);\n k:=pos('8',s);\n if (b <> 0) and (k <> 0) then begin writeln(b); halt; end;\n inc(b);\n inc(n);\n k:=0;\n end;\nend."}, {"source_code": "Var n,n1,f,n2,q:LongInt;\n Begin\n Readln(n);\n\n n1:=n;\n f:=1;\n While f=1 do\n begin\n\n if n2=0 then n1:=n1+1;\n if n2=0 then n2:=n1;\n q:=n2 mod 10;\n if abs(q) = 8 then break;\n n2:=n2 div 10;\n end;\n write(abs(n-n1));\n End."}, {"source_code": "var a,i,x,k,n:longint;\nBegin\n read(a);\n for i:=1 to 888888888 do begin\n if a>=0 then begin a:=a+1; k:=a; end\n else begin k:=abs(a)-1; a:=a+1; end;\n x:=k;\n while x>0 do begin\n n:=x mod 10;\n x:=x div 10;\n if n=8 then break;\n end;\n if n=8 then break;\n end;\n \n \nwrite(i);\n End."}, {"source_code": "program codeforces_round278_a;\n\nvar\n i, a, b, f, x : longint;\n\nbegin\n read(a);\n for i:=1 to 10000 do\n begin\n x:=a + i;\n f:=0;\n while x <> 0 do\n begin\n if abs(x mod 10) = 8\n then begin\n f:=1;\n break;\n end;\n x:=x div 10;\n end;\n if f = 1\n then begin\n b:=i;\n break;\n end;\n end;\n write(b);\nend.\n"}, {"source_code": "uses math;\nvar n, i: int64;\n s: string;\nbegin\n readln(n);\n i:=n+1;\n while true do\n begin\n str(i, s);\n if pos('8', s) > 0 then break;\n inc(i);\n end;\n writeln(i-n);\nend.\n"}, {"source_code": "var a, i, aa, q:longint; \n bool:boolean;\nbegin\n//assign(input, 'input.txt'); reset(input);\n//assign(output, 'output.txt'); rewrite(output);\n\nreadln(a);\nif a>0 then\nbegin \nbool:=false; \nfor i:=1 to 20 do \n begin\n\n aa:=a+i; \n while (aa<>0) do \n begin\n q:=aa mod 10; \n aa:=aa div 10;\n if q=8 then bool:=true; \n end;\n\n if bool then break;\n end;\nend\nelse\nbegin\nif a=0 then i:=8\n else if (a<-9)\n then begin\n a:=a*(-1); \n bool:=false;\n for i:=1 to 20 do\n begin\n aa:=a-i; \n \n while (aa<>0) do \n begin\n q:=aa mod 10;\n aa:=aa div 10;\n if q=8 then bool:=true;\n end;\n if bool then break; \n end;\n \n end\n else begin\n i:=a*(-1)+8;\n end;\nend;\n\nwrite(i);\n\n//close(input); close(output);\nend."}, {"source_code": "var i,j,a,b:integer;\nbegin\nReadln(a);\ni:=0;\ninc(a);\nb:=0;\nwhile(i<>8) do\n begin\n j:=abs(a);\n inc(b);\n while(j<>0) do\n begin\n if(j mod 10=8) then i:=8;\n j:=j div 10;\n end;\n inc(a);\n end;\n writeln(b);\nend."}, {"source_code": "VAR a,a1:int64;\ni,f:dword;\nBEGIN\nreadln(a);\n{a1:=a;\nwhile a1>0 do begin\nif a1 mod 10 =8 then begin writeln('0');\nexit;\nend;\na1:=a1 div 10;\nend; }\n\nfor i:=1 to 100000000 do begin\n a1:=a+i;\n a1:=abs(a1);\n while a1>0 do begin\n if a1 mod 10 =8 then begin\n f:=1;\n break;\n end;\n a1:=a1 div 10;\n end;\n if f=1 then begin\n writeln(i);\n exit;\n end;\nend;\nEND."}, {"source_code": "var ot,a,i,x,p,k,kl:longint;\nbegin\n readln(a);\n if a=999999998 then writeln(10)\n else if a=999999999 then writeln(9)\n else if a=1000000000 then writeln(8)\n else\n BEGIN\n for i:=a+1 to 999999998 do\n begin\n x:=abs(i);\n while x>0 do\n begin\n p:=x mod 10;\n if p=8 then begin\n k:=i;\n kl:=1;\n break;\n end;\n x:=x div 10;\n end;\n if kl=1 then break;\n end;\n\n ot:=k-a;\n writeln(ot);\n END;\nend.\n"}, {"source_code": "var s:string;\n\tk,i,dem:longint;\nbegin\n\treadln(s);\n\t\tdem:=0;\n\t\tval(s,k,i);\n\t\tinc(k);\n\t\tinc(dem);\n\t\tstr(k,s);\n\t\twhile pos('8',s)=0 do\n\t\tbegin\n\t\t\tval(s,k,i);\n\t\t\tinc(k);\n\t\t\tstr(k,s);\n\t\t\tinc(dem);\n\t\tend;\n\t\twriteln(dem);\nend."}, {"source_code": "var a,b,n,c,i: longint;\nbegin\nread(a);\nfor i:=1 to 20 do begin\nif a>-8 then begin\na:=a+1;\nc:=a;\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nif n=8 then break;\nend;\nif a<=-8 then begin \na:=a+1;\nc:=a*-1;\nwhile c>0 do begin\nn:=c mod 10;\nc:=c div 10;\nif n=8 then begin\nwrite(i);\nbreak;\nend;\nend;\nif n=8 then break;\nend;\nend;\nend."}, {"source_code": "var x:longint;\nfunction check(k:longint):boolean;\nvar a:longint;\nbegin\n a:=abs(k);\n while (a>0) do\n begin\n if (a mod 10=8) then exit (true);\n a:=a div 10;\n end;\n exit(false);\nend;\nfunction find:longint;\nvar i:longint;\nbegin\n for i:=1 to 16 do\n if (check(x+i)=true) then exit(i);\nend;\nbegin\n readln(x);\n writeln(find);\nend.\n"}, {"source_code": "var s,n:int64; p:string;\nbegin\nreadln(n);\nwhile true do\n begin\n n:=n+1; s:=s+1;\n str(n,p);\n if pos('8',p)<>0 then break;\n end;\nwriteln(s);\nend.\n"}, {"source_code": "VAR\n A,S,D,F,G:INTEGER;\nbegin\n READLN(A);\n while (g<>1) do\n begin\n f:=f+1;\n s:=a+f;\n while(s<>0) do\n begin\n d:=s mod 10;\n if(d=8) or (d=-8) then g:=1;\n s:=s div 10;\n end;\n end;\n writeln(f);\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n a : int64;\n ans : longint;\n\nfunction check(x : int64): boolean;\nvar tmp : longint;\nbegin\n while (x > 0) do\n begin\n tmp := x mod 10;\n if tmp = 8 then exit(true);\n x := x div 10;\n end;\n exit(false);\nend;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,a);\n ans := 1;\n a := a + 1;\n while not check(abs(a)) do\n begin\n inc(a);\n inc(ans);\n end;\n writeln(fo,ans);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n OUTPUT;\nend.\n"}, {"source_code": "uses\n math;\nvar\n n,k:int64;\nprocedure busca(x:int64);\nbegin\n while x>0 do\n begin\n if x mod 10 =8 then\n begin\n writeln(k);\n halt;\n end;\n x:=x div 10;\n end;\nend;\n\nbegin\n readln(n);\n while true do\n begin\n k:=k+1;\n busca (abs(n+k));\n end;\nend. "}, {"source_code": "Uses sysutils;\n\nvar n:int64;\ns:string;\ni,k:integer;\nbegin\nreadln(n);\nfor i:=1 to 20 do begin\nn+=1;\ns:=inttostr(n);\nfor k:=1 to length(s) do\nif s[k]='8' then begin\nwriteln(i);\nexit;\nend;\nend;\nend."}, {"source_code": "var s,n:int64; p:string;\nbegin\nreadln(n);\nwhile true do\n begin\n n:=n+1; s:=s+1;\n str(n,p);\n if pos('8',p)<>0 then break;\n end;\nwriteln(s);\nend.\n"}, {"source_code": "var b,a,i,c,n:longint;\nbegin\nread(a);\nfor i:=1 to 16 do begin\n if a>-8 then begin\n a:=a+1;\n c:=a;\n while c>0 do begin\n n:=c mod 10;\n c:=c div 10;\n if n=8 then begin write(i); break;\n end;\n end;\n if n=8 then break;\n end;\n if a<=-8 then begin\n a:=a+1;\n c:=a*(-1);\n while c>0 do begin\n n:=c mod 10;\n c:=c div 10;\n if n=8 then begin write(i); break;\n end;\n end;\n if n=8 then break;\n end;\n end;\nend."}, {"source_code": "type int64=longint;\nvar i,n,x:int64;\n\nfunction sch:boolean;\n var xx:int64;\n begin\n sch:=false;\n inc(n);\n xx:=n;\n while xx<>0 do\n begin\n if abs(xx mod 10) = 8\n then sch:=true;\n xx:=xx div 10;\n end;\n end;\nbegin\nread(n);\ni:=1;\nwhile not(sch) do inc(i);\nwrite(i);\nend.\n"}, {"source_code": "var\n a,b:longint;\nfunction change(x:longint):boolean;\nbegin\n x:=abs(x);\n while x>0 do\n begin\n if x mod 10=8 then exit(true);\n x:=x div 10;\n end;\n exit(false);\nend;\nbegin\n read(a);\n b:=1;\n while not (change(a+b)) do inc(b);\n writeln(b);\nend."}], "negative_code": [{"source_code": "\n\nvar\n\ta,n\t\t: integer;\n\ts\t\t: string;\n\nbegin\n\treadln(s);\n\tn:=length(s);\n\tcase s[n] of\n\t\t'0' : a:=0;\n\t\t'1' : a:=1;\n\t\t'2' : a:=2;\n\t\t'3' : a:=3;\n\t\t'4' : a:=4;\n\t\t'5' : a:=5;\n\t\t'6' : a:=6;\n\t\t'7' : a:=7;\n\t\t'8' : a:=8;\n\t\t'9' : a:=9;\n\tend;\n\tif s[1]<>'-' then\n\tbegin\n\t\n\t\tif n=1 then\n\t\tbegin\n\t\t\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\t\twriteln(18-a);\n\t\t\t\t\n\t\tend else\n\t\t\n\t\tbegin\n\t\t\t//writeln('yes');\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif s[n-1]='7' then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(10-a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(18-a);\n\t\t\tend;\n\t\tend;\n\tend else\n\tbegin\n\t\tif n=2 then\n\t\tbegin\n\t\t\tif a<=8 then\n\t\t\tbegin\n\t\t\t\twriteln(8+a);\n\t\t\tend else\n\t\t\t\twriteln(1);\n\t\tend else\n\t\tbegin\n\t\t\tif a=9 then\n\t\t\tbegin\n\t\t\t\twriteln(1);\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\tif s[n-1]='9' then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(2+a);\n\t\t\tend;\n\t\tend;\n\tend;\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction lucky(x:int64):boolean;\n var tg:string;\n begin\n str(x,tg);\n if pos('8',tg)>0 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n);\n for i:=1 to n do if lucky(n+i) then\n begin\n writeln(fo,i);\n exit;\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,res:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "uses math;\nvar n,a,m,i:longint;\n s:string;\nbegin\n readln(s);\n for i:=1 to 10 do\n begin\n val(s,n,m);\n n:=n+1;\n str(n,s);\n if pos('8',s)<>0 then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "VAR\n s,a,d,f,g,e,r,m,k:integer;\n z,x,c:array [1..10000] of string;\nbegin\n readln(a);\n d:=a;\n while (s<>1) do\n begin\n k:=1;\n e:=a+k;\n while (e>0) do\n begin\n if (e mod 10=8) or (e mod -10=8) or (e mod 10=-8) or (e mod -10=-8) then\n s:=1;\n e:=e div 10;\n end;\n a:=a+k;\n end;\n writeln(a-d);\n readln();\nend.\n\n"}, {"source_code": "program codeforces_round278_a;\n\nvar\n i, a, b : longint;\n\nfunction Check_8(x : longint) : boolean;\n begin\n while x<>0 do\n begin\n if x<0\n then x:=-x;\n if x mod 10 = 8\n then begin\n Check_8:=true;\n break;\n end;\n x:=x div 10;\n end;\n end;\n\nbegin\n read(a);\n i:=1;\n while i<=8888888888 do\n begin\n if Check_8(a+i)\n then begin\n b:=i;\n break;\n end;\n i:=i+1;\n end;\n write(b);\nend."}, {"source_code": "var i,b,k,a:longint;\nbegin\nread(a);\nb:=0;\nk:=abs(a);\nfor i:=1 to 16 do begin\nif a<0 then b:=k-i\nelse b:=k+i;\nwhile b div 10>0 do begin\nif b mod 10=8 then break;\nb:=b div 10;\nend;\nif b mod 10=8 then break;\nend;\nwrite(i);\nend."}, {"source_code": "{const fi='checking1.inp';\n fo='checking1.out'; }\nvar\n n:int64;\n{-----------------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend; }\n{-----------------------------------}\n{procedure closefiles;\nbegin\n close(input);\n close(output);\nend;}\n{------------------------------------------------}\nprocedure stdin;\nvar i:longint;\nbegin\n read(n);\nend;\n{--------------------------------------}\n{---------------------------------------}\nprocedure process;\nvar p,m,tmp1,tmp2,l1,l2:int64;\n sp,sm:string;\n ok:boolean;\nbegin\n ok:=true;\n p:=n;\n m:=n;\n while ok do\n begin\n dec(m);\n tmp1:=abs(m);\n while tmp1<>0 do\n begin\n l1:=tmp1 mod 10;\n if l1 =8 then ok:=false;\n tmp1:=tmp1 div 10;\n end;\n\n inc(p);\n tmp2:=abs(p);\n while tmp2 <>0 do\n begin\n l2:=tmp2 mod 10;\n if l2=8 then ok:=false;\n tmp2:=tmp2 div 10;\n end;\n end;\n\n write (abs(m-n));\nend;\n{----------------------------------------------}\nBEGIN\n { openfiles; }\n stdin;\n process;\n { closefiles;}\nEND.\n"}, {"source_code": "var n,m,i,j,k,s,g,f,d:longint;\nbegin\n\nread(n);\ninc(n);\nk:=0;\ns:=1;\nwhile (k<>1) and (n>0) do begin\nf:=n;\nwhile f>0 do begin\nd:=f mod 10;\nif d=8 then begin k:=1; break; end;\nf:=f div 10;\nend;\ninc(s);\ninc(n);\nend;\nwrite(s-1);\nend.\n"}, {"source_code": "Program PBA;\nVar a:longint;\ni:byte;\nst:string;\nBegin\nreadln(a);\nFor i:=1 to 10 do\nBegin\ninc(a);\nstr(a,st);\nIf pos('8',st)<>0 then\nBegin\nwrite(i);\nexit;\nEnd;\nEnd;\nEnd."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n i:= 2;\n while (i <= na) and ((a[i] = 9) or (a[i] = 7)) do\n begin\n if a[i] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n inc(i);\n end;\n if i <= na then ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var i,b,k,a:longint;\nbegin\nread(a);\nb:=0;\nk:=abs(a);\nfor i:=1 to 16 do begin\nif a<0 then b:=k-i\nelse b:=k+i;\nwhile b div 10>0 do begin\nif b mod 10=8 then break;\nb:=b div 10;\nend;\nif b mod 10=8 then break;\nend;\nwrite(i);\nend."}, {"source_code": "var n:longint;\n i:longint;\nbegin\n read(n);\n if n>=-8 then\n for i:=1 to 100 do\n if (n + i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n if n<-8 then\n begin\n n:=-n;\n for i:=1 to 100 do\n if (n - i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "var a :integer;\nbegin\nread (a);\nif a = -1 then write (9);\nif a = 179 then write (1);\nif a = 18 then write (10);\nif a = -410058385 then write (1);\nend.\n"}, {"source_code": "var n,m,i,j,k,s,g,f,d:longint;\nbegin\n\nread(n);\ninc(n);\nk:=0;\ns:=1;\nwhile k<>1 do begin\nf:=n;\nwhile f>0 do begin\nd:=f mod 10;\nif d=8 then begin k:=1; break; end;\nf:=f div 10;\nend;\ninc(s);\ninc(n);\nend;\nwrite(s-1);\nend.\n"}, {"source_code": "VAR n,k:int64;\nj:integer;\ns:string;\nBEGIN\nreadln(n);\nif n<0 then k:=(abs(n)+1) else k:=1;\nn:=abs(n);\nwhile n<>8888888888 do\n begin\n str(n,s);\n for j:=1 to 15 do if s[j]='8' then begin writeln(k); exit; end;\n k:=k+1;\n n:=n+1;\n end;\nEND.\n"}, {"source_code": "var s:string;\n n,k,l:Int64;\n i,j:longint;\n begin\n read(n);\n for i:=1 to 12 do\n begin\n inc(n);\n str(n,s);\n for j:=1 to length(s) do\n if s[j]='8' then begin write(i); exit; end;\n end;\n end."}, {"source_code": "program cf488A;\nvar a,b,s:int64;\n\nbegin\nread(a);\nb:=1;\nwhile true do\n begin\n s:=a+b;\n while s>0 do\n begin\n if s mod 10=8 then\n begin\n writeln(b);\n exit;\n end;\n s:=s div 10;\n end;\n s:=a-b;\n while s>0 do\n begin\n if s mod 10=8 then\n begin\n writeln(b);\n exit;\n end;\n s:=s div 10;\n end;\n b:=b+1;\n end;\nend."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n for i:= 2 to na do\n if a[i] = 8 then\n begin\n if (i <> 2) or ((i = 2) and (a[1] <> 9)) then\n begin\n writeln(fo,1);\n exit;\n end;\n end;\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n if a[2] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n exit;\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+}\n\nuses\n SysUtils,Math;\n\nvar n,m,x,k,l,t:int64;\n\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n read(n);\n k:=0;\n m:=n;\n t:=0;\n if n<=8 then begin\n l:=0;\n t:=0;\n while true do begin\n n:=n+1;\n x:=abs(n);\n l:=l+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n write(l);\n exit;\n end;\n while true do begin\n n:=n-1;\n x:=abs(n);\n k:=k+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n l:=0;\n t:=0;\n while true do begin\n m:=m+1;\n x:=abs(m);\n l:=l+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n write(min(l,k));\nend.\n"}, {"source_code": "Var i:Longint;\n n:int64;\n x:string;\n Begin\n REad(n);\n if n<0 then begin writeLn(8+abs(n)); halt; end;\n inc(n);\n For i:= 1 to 11 do\n begin\n str(n,x);\n if pos('8',x)<>0 then begin writeLn(i); halt; end;\n inc(n);\n end;\n end.\n"}, {"source_code": "var n,i,err,ss,x,k,z:integer;\n s:string;\nbegin\nreadln(s);\nn:=length(s);\nfor i:=n-1 downto 1 do\n begin\n if s[i]='8' then\n s[i]:='5';\n end;\nk:=0;\nval(s,x,err);\nwhile k<>1 do\nbegin\nx:=x+1;\nstr(x,s);\nn:=length(s);\nfor i:=1 to n do\n if s[i]='8' then\n k:=k+1;\nss:=ss+1;\nend;writeln(ss);\nend."}, {"source_code": "VAR\n s,a,d,f,g,e,r,m,k:integer;\n z,x,c:array [1..10000] of string;\nbegin\n readln(a);\n d:=a;\n while (s<>1) do\n begin\n k:=1;\n e:=a+k;\n while (e>0) do\n begin\n if (e mod 10=8) or (e mod -10=8) or (e mod 10=-8) or (e mod -10=-8) then\n s:=1;\n e:=e div 10;\n end;\n a:=a+k;\n end;\n writeln(a-d);\n readln();\nend.\n\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,s:longint;\n r,m,x:int64;\n begin\n //init;\n read(n);\n res:=0;\n while true do\n begin\n cur:=n;\n if cur<0 then cur:=-cur;\n for i:=1 to 10 do\n begin\n if cur mod 10=8 then begin writeln(res); exit; end;\n cur:=cur div 10;\n end;\n inc(res);\n inc(n);\n end;\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n i:= 2;\n while (i <= na) and ((a[i] = 9) or (a[i] = 7)) do\n begin\n if a[i] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n inc(i);\n end;\n if i <= na then ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "program z1;\n var a,b,c,i:int64;\n h:boolean;\nbegin\n readln(a);\n h:=true;\n b:=a+1;\n while(h)do\n begin\n c:=abs(b);\n while(c<>0)do\n begin\n if(c mod 10=8)\n then begin\n writeln(b-a);\n h:=false;\n end;\n c:=c div 10;\n end;\n inc(b);\n end;\n\nend.\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": "{$MODE OBJFPC}\nvar\n n,res :int64;\n\nfunction Check(x :Int64) :Boolean;\nbegin\n while x > 0 do\n begin\n if x mod 10=8 then Exit(true);\n x:=x div 10;\n end;\n Exit(False);\nend;\n\nprocedure Solve;\nbegin\n if n<=0 then\n begin\n Writeln(0-n+8);\n Exit;\n end;\n res:=0;\n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\nend;\n\nBEGIN\n readln(n);\n Solve;\nEND."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n for i:= 2 to na do\n if a[i] = 8 then\n begin\n if (i <> 2) or ((i = 2) and (a[1] <> 9)) then\n begin\n writeln(fo,1);\n exit;\n end;\n end;\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n if a[2] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n exit;\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+}\n\nuses\n SysUtils,Math;\n\nvar n,m,x,k,l,t:int64;\n\nbegin\n {reset(input,'input.txt');\n rewrite(output,'output.txt');}\n read(n);\n k:=0;\n m:=n;\n t:=0;\n if n<=8 then begin\n l:=0;\n t:=0;\n while true do begin\n n:=n+1;\n x:=abs(n);\n l:=l+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n write(l);\n exit;\n end;\n while true do begin\n n:=n-1;\n x:=abs(n);\n k:=k+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n l:=0;\n t:=0;\n while true do begin\n m:=m+1;\n x:=abs(m);\n l:=l+1;\n while x>0 do begin\n t:=x mod 10;\n if t=8 then break;\n x:=x div 10;\n end;\n if t=8 then break;\n end;\n write(min(l,k));\nend.\n"}, {"source_code": "var n:longint;\n i:longint;\nbegin\n read(n);\n if n>=-8 then\n for i:=1 to 100 do\n if (n + i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n if n<-8 then\n begin\n n:=-n;\n for i:=1 to 100 do\n if (n - i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "var \n i:longint;\n n:int64;\n s:string;\n \nBegin\n read(n);\n for i:=1 to 10 do\n begin\n str(n + i, s);\n if pos('8',s) > 0 then\n begin\n writeln(i);\n halt;\n end;\n end;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nvar a,h,b1,b2,j,a1:Int64;i,k:Integer; n:QWord;\nfunction KT8(a:Integer):Boolean;\nvar k,j:Integer;\nbegin\n k:=1; j:=1;\n If a<=10 then\n begin\n If a mod 8=0 then result:=True else result:=False;\n end else\n begin\n While k*10<=a do\n begin\n h:=(a mod (k*10)) div k;\n If h=8 then Break;\n k:=k*10;\n end;\n If k*101 do\nbegin\nx:=x+1;\nstr(x,s);\nn:=length(s);\nfor i:=1 to n do\n if s[i]='8' then\n k:=k+1;\nss:=ss+1;\nend;writeln(ss);\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar a:longint;\n\nprocedure getdata;\nvar f:text;\nbegin\n assign(f,fi); reset(f);\n read(f,a);\n close(f);\nend;\n\nfunction check(t:longint):boolean;\nvar m:longint;\nbegin\n while (t<>0) do\n begin\n m:=t mod 10;\n t:=t div 10;\n if (m=8) or (m=-8) then exit(true);\n end;\n exit(false);\nend;\n\nprocedure solve;\nvar g:text;\n k,i:longint;\nbegin\n assign(g,fo); rewrite(g);\n for i:=1 to 10 do\n begin\n k:=a+i;\n if check(k) then\n begin\n write(g,i);\n break;\n end;\n end;\n close(g);\nend;\n\nbegin\n getdata;\n solve;\nend.\n"}, {"source_code": "var a,i,k:longint;\n f:boolean;\nbegin\n read(a);\n for i:=a+1 to a+30 do\n begin\n k:=i;\n f:=false;\n while k>0 do\n begin\n if k mod 10=8 then f:=true;\n k:=k div 10\n end;\n if f then break\n end;\n write(i-a)\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='x';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,rr:array[0..1000000]of longint;\n qc:array[0..2000,0..2000]of int64;\n ss:array[0..1000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res,cur:int64;\n aa,bb,u,v,nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nprocedure init;\n begin\n assign(input,filename+'.in');\n assign(output,filename+'.out');\n reset(input);\n rewrite(output);\n end;\n\n\nprocedure fin;\n begin\n close(input);\n close(output);\n end;\n\n\nprocedure clear;\nvar i,j,k:longint;\n begin\n fillchar(qc,sizeof(qc),0);\n end;\n\n\nprocedure load;\nvar i,j,k:longint;\n begin\n end;\n\n\nprocedure save;\nvar i,j,k:longint;\n begin\n end;\n\nfunction gcd(q,c:int64):int64;\n begin\n while ((q>0)and(c>0)) do\n if q>c then q:=q mod c else c:=c mod q;\n if q>0 then gcd:=q else gcd:=c;\n end;\n\n\nprocedure run;\nvar i,j,k,z,s:longint;\n r,m,x:int64;\n begin\n //init;\n read(n);\n res:=0;\n while true do\n begin\n cur:=n;\n if cur<0 then cur:=-cur;\n for i:=1 to 10 do\n begin\n if cur mod 10=8 then begin writeln(res); exit; end;\n cur:=cur div 10;\n end;\n inc(res);\n inc(n);\n end;\n end;\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "Program PBA;\nVar a:longint;\ni:byte;\nst:string;\nBegin\nreadln(a);\nFor i:=1 to 10 do\nBegin\ninc(a);\nstr(a,st);\nIf pos('8',st)<>0 then\nBegin\nwrite(i);\nexit;\nEnd;\nEnd;\nEnd."}, {"source_code": "var n,m,i,j,k,l,r:Longint;\n begin\n read(n);\n for i:=n+1 to n+100 do\n begin\n k:=i;\n l:=0;\n while k>0 do\n begin\n if k mod 10=8 then begin l:=1; break; end;\n k:=k div 10;\n end;\n if l=1 then begin writeln(i-n); halt; end;\n end;\n end."}, {"source_code": "var a,i:longint;\n\nfunction getLD(x:longint):integer;\nvar co:integer;\n b:longint;\n begin\n co:=0;\n while x<>0 do\n begin\n b:=x mod 10;\n if b=8\n then\n inc(co);\n x:=x div 10;\n end;\n if co<>0\n then\n getLD:=1\n else\n getLD:=0;\n end;\n\nbegin\n readln(a);\n for i:=1 to 10 do\n if getLD(a+i)>0\n then\n begin\n writeln(i);\n exit;\n end;\nend."}, {"source_code": "uses math;\ntype maxx=array[0..200000] of longint;\nvar r,d,kol,n,c,i,k,z,j:longint;\n s:string; res,m1,m,dp,m2,left,right,vr,t:maxx;\n a,b:int64;\nBegin\n // assign(input,'input.txt'); assign(output,'output.txt');\n readln(n);\n for i:=n+1 to n+100 do\n Begin\n a:=i;\n while a>0 do\n Begin\n if a mod 10=8\n then Begin\n writeln(i-n);\n halt(0);\n end;\n a:=a div 10;\n end;\n end;\nend."}, {"source_code": "uses sysutils;\nvar a, b, i: longint;\n s: string;\nbegin\n readln(a);\n for b := 1 to 10 do\n begin\n inc(a);\n s := inttostr(a);\n for i := 1 to length(s) do\n if s[i] = '8' then\n begin\n writeln(b);\n exit;\n end;\n end;\nend."}, {"source_code": "uses math;\ntype maxx=array[0..200000] of longint;\nvar r,d,kol,n,c,i,k,z,j:longint;\n s:string; res,m1,m,dp,m2,left,right,vr,t:maxx;\n a,b:int64;\nBegin\n // assign(input,'input.txt'); assign(output,'output.txt');\n readln(n);\n for i:=n+1 to n+100 do\n Begin\n a:=i;\n while a>0 do\n Begin\n if a mod 10=8\n then Begin\n writeln(i-n);\n halt(0);\n end;\n a:=a div 10;\n end;\n end;\nend."}, {"source_code": "const fi='';\n fo='';\nvar a,b:int64;\n f:text;\nprocedure input;\nbegin\n assign(f,fi);\n reset(f);\n read(f,a);\n close(f);\nend;\nfunction chk(n:int64):boolean;\nvar s:string;\nbegin\n str(n,s);\n if pos('8',s)<>0 then exit(true)\n else exit(false);\nend;\nprocedure solve;\nbegin\n b:=a;\n while not chk(b) do\n b:=b+1;\nend;\nprocedure output;\nbegin\n assign(f,fo);\n rewrite(f);\n write(f,b-a);\n close(f);\nend;\nbegin\n input;\n solve;\n output;\nend.\n "}, {"source_code": "program zzz;\nvar\n x, i: int64;\n stop: boolean;\nfunction Has8(x: int64): boolean;\nvar\n s: ansistring;\n i: byte;\nbegin\n Str(x, s);\n for i := Length(s) downto 1 do\n if s[i] = '8'\n then begin\n Has8 := true;\n exit;\n end;\n Has8 := false;\nend;\nbegin\n read(x);\n if x >= 0\n then i := x + 1\n else i := 0;\n stop := false;\n while not stop do\n begin\n if Has8(i) and (i > 0)\n then stop := true\n else inc(i);\n end;\n write(i - x);\nend.\n"}, {"source_code": "//488a\nvar n,i,j,k:int64;\nbegin\n read(i);\n k:=i div 10;\n j:=i div 10;\n while (j mod 10)=9 do j:=j div 10;\n while (k>0) and (k mod 10<>8) do k:=k div 10;\n if (abs(k)>0) then write(1) else\n if i mod 10<8 then write(8- i mod 10) else\n if j mod 10<> 7 then write(18- i mod 10)else write(10-i mod 10);\n end.\n"}, {"source_code": "uses math;\nvar n,a,m:longint;\nbegin\n readln(n);\n a:=n;\n m:=0;\n while a<>0 do\n begin\n a:=a div 10;\n inc(m);\n end;\n if n mod 100000000=79999999 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 10000000=7999999 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 1000000=799999 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 100000=79999 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 10000=7999 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 1000=799 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 100=79 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 10=7 then\n begin\n writeln(1);\n halt;\n end;\n if n mod 100000000=79999998 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 10000000=7999998 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 1000000=799998 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 100000=79998 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 10000=7998 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 1000=798 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 100=78 then\n begin\n writeln(2);\n halt;\n end;\n if n mod 10=6 then\n begin\n writeln(2);\n halt;\n end;\n if n=-9 then\n begin\n writeln(1);\n halt;\n end;\n if (n mod 10=8) then\n begin\n writeln(10);\n halt;\n end;\n if (n<0) and (m=1) then a:=8-n;\n if (n<0)and (m>=2) then a:=10+(abs(n) mod 10)-8;\n if (n>=0) then a:=8-n mod 10;\n write(a);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst max1=100000;\ntype vector=array[1..max1] of integer;\nvar\n x:vector;\n s:ansistring;\n fi,fo:textfile;\n n,k:integer;\nprocedure enter;\n var i,j:integer;\n begin\n readln(n);\n end;\nfunction solve(n:integer):integer;\n var i,j:integer;\n begin\n for i:=1 to 10 do\n begin\n n:=n+i;\n str(n,s);\n for j:=1 to length(s) do\n begin\n if s[j]='8' then exit(i);\n end;\n n:=n-i;\n end;\n end;\nprocedure print;\n var i:integer;\n begin\n writeln(solve(n));\n end;\nbegin\n {assignfile(fi,'gigatower.inp');reset(fi);\n assignfile(fo,'gigatower.out');rewrite(Fo); }\n enter;\n print;\n {closefile(fi);\n closefile(fo);}\nend.\n"}, {"source_code": "VAR n,k:int64;\nj:integer;\ns:string;\nBEGIN\nreadln(n);\nif n<0 then k:=(abs(n)+1) else k:=1;\nn:=abs(n);\nwhile n<>8888888888 do\n begin\n str(n,s);\n for j:=1 to 15 do if s[j]='8' then begin writeln(k); exit; end;\n k:=k+1;\n n:=n+1;\n end;\nEND.\n"}, {"source_code": "program cf488A;\nvar a,b,i:longint;\n\nbegin\nread(a);\nfor i:=1 to 10 do\n begin\n b:=a+i;\n while abs(b)>0 do\n begin\n if (abs(b) mod 10=8) and (b<>-8) then\n begin\n writeln(i);\n exit;\n end;\n b:=b div 10;\n end;\n end;\nend.\n"}, {"source_code": "var\n a,b:longint;\n s:string;\nbegin\n readln(a);\n repeat\n inc(a);\n str(a,s);\n if pos('8',s)>0 then\n begin\n write(1);\n exit;\n end;\n until false;\n write(-1);\nend."}, {"source_code": "var k,b,min,h,d:integer;\nbegin\nread(k);\nb:=k;min:=0;k:=0;\nwhile min=0 do\nbegin\nb:=b+1;h:=b;k:=k+1;\nwhile h<>0 do\nbegin\nif (h mod 10=8) or (h mod 10=-8)then d:=1;\nh:=h div 10;end;\nif d=1 then min:=b;end;\nwriteln(min);\nwrite(k);\nend."}, {"source_code": "var a,i:longint;\n\nfunction getLD(x:longint):integer;\nvar co:integer;\n b:longint;\n begin\n co:=0;\n while x<>0 do\n begin\n b:=x mod 10;\n if abs(b)=8\n then\n inc(co);\n x:=x div 10;\n end;\n if co<>0\n then\n getLD:=1\n else\n getLD:=0;\n end;\n\nbegin\n readln(a);\n for i:=1 to 10 do\n if getLD(a+i)>0\n then\n begin\n writeln(i);\n exit;\n end;\nend."}, {"source_code": "uses math;\nvar\n a,av:longint;\n i,iv,h:longint;\nbegin\n read(a);\n if a<0 then\n begin\n av:=abs(a);\n for i:=av-1 downto 0 do\n begin\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if h=1 then begin writeln(abs(i-av)); halt; end;\n end;\n end;\n if a<0 then begin\n for i:=1 to 888888888 do\n begin\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if (h=1) and (i>a) then begin writeln(i-a); halt; end;\n end;\n end\n else\n for i:=a to 888888888 do\n begin\n iv:=i;\n h:=0;\n repeat\n if iv mod 10=8 then begin h:=1; break; end;\n iv:=iv div 10;\n until iv=0;\n if (h=1) and (i>a) then begin writeln(i-a); halt; end;\n end;\nend."}, {"source_code": "var\n n,res :int64;\n\nfunction Check(x :Int64) :Boolean;\nbegin\n while x > 0 do\n begin\n if x mod 10=8 then Exit(true);\n x:=x div 10;\n end;\n Exit(False);\nend;\n\nprocedure Solve;\nbegin\n if (n<=0) and (n>=8) then\n begin\n Writeln(0-n+8);\n Exit;\n end;\n if n<0 then\n begin\n n:=-n;\n res:=0;\n while n>0 do\n \n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\n end;\n res:=0;\n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\nend;\n\nBEGIN\n readln(n);\n Solve;\nEND."}, {"source_code": "var\n n,res :int64;\n\nfunction Check(x :Int64) :Boolean;\nbegin\n while x > 0 do\n begin\n if x mod 10=8 then Exit(true);\n x:=x div 10;\n end;\n Exit(False);\nend;\n\nprocedure Solve;\nbegin\n if (n<=0) and (n>=8) then\n begin\n Writeln(0-n+8);\n Exit;\n end;\n if n<0 then\n begin\n n:=-n;\n res:=0;\n while n>0 do\n \n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\n end;\n res:=0;\n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\nend;\n\nBEGIN\n readln(n);\n Solve;\nEND."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction lucky(x:int64):boolean;\n var tg:string;\n begin\n str(x,tg);\n if pos('8',tg)>0 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n);\n for i:=1 to n do if lucky(n+i) then\n begin\n writeln(fo,i);\n exit;\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,res:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "var\n a,m,ans,k:longint;\n\nbegin\n read(a);\n m:=a div 100;\n a:=a mod 100;\n\n while m>0 do\n begin\n if m mod 10 = 8 then begin write(1); halt; end;\n m:=m div 10;\n end;\n while true do\n begin\n inc(a);\n inc(k);\n m:=a;\n while m>0 do\n begin\n if m mod 10 = 8 then begin write(k); halt; end;\n m:=m div 10;\n end;\n end;\nend.\n"}, {"source_code": "{-------------------------------------------------\n----oo--o--o-o---o--o----o------oo--o-----o-oooo----\n---o--o-oo-o-o----ooo----o-----o--o--o---o--oooo----\n---o--o-o-oo-o------o----o-----o--o---o-o---o-------\n----oo--o--o-oooo-oo-----ooooo--oo-----o----oooo----\n------------------------------------------------}\n{$MODE OBJFPC}\nprogram Onlylove;\nconst maxN =10;\nvar a : int64;\n\nprocedure enter;\n begin\n readln(a);\n\n end;\nfunction check(a : int64) : boolean;\n var r : integer;\n begin\n if a < 0 then a := -a ;\n while a <> 0 do\n begin\n r := a mod 10 ;\n if r = 8 then exit(true) ;\n a := a div 10 ;\n end;\n end;\nprocedure solve;\n var i : integer;\n begin\n for i:=1 to 25 do\n begin\n inc(a);\n if check(a) then\n begin Writeln(i); break; end;\n end;\n end;\n\nbegin\n enter;\n solve;\n\nend.\n"}, {"source_code": "program gt;\nlabel 1;\nvar q,a,b,p,r:integer;\nbegin\nreadln(a);\nr:=a;\np:=0;\n1:\na:=a+1;\nb:=a;\nwhile b>0 do\nbegin\nq:=b mod 10;\nb:=b div 10;\nif(q=8)then begin\np:=1;\nbreak;\nend;\nend;\nif(p=1)then writeln(a-r) else goto 1;\nend."}, {"source_code": "var s:string;\n n,k,l:Int64;\n i,j:longint;\n begin\n read(n);\n for i:=1 to 12 do\n begin\n inc(n);\n str(n,s);\n for j:=1 to length(s) do\n if s[j]='8' then begin write(i); exit; end;\n end;\n end."}, {"source_code": "//488a\nvar n,i,j,k:int64;\nbegin\n read(i);\n k:=i div 10;\n j:=i div 10;\n while (j mod 10)=9 do j:=j div 10;\n while (k>0) and (k mod 10<>8) do k:=k div 10;\n if (abs(k)>0) then write(1) else\n if i mod 10<8 then write(8- i mod 10) else\n if j mod 10<> 7 then write(18- i mod 10)else write(10-i mod 10);\n end.\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n n,res :int64;\n\nfunction Check(x :Int64) :Boolean;\nbegin\n while x > 0 do\n begin\n if x mod 10=8 then Exit(true);\n x:=x div 10;\n end;\n Exit(False);\nend;\n\nprocedure Solve;\nbegin\n if n<=0 then\n begin\n Writeln(0-n+8);\n Exit;\n end;\n res:=0;\n while true do\n begin\n Inc(n);\n Inc(res);\n if check(n) then\n begin\n Writeln(res);\n Exit;\n end;\n end;\nend;\n\nBEGIN\n readln(n);\n Solve;\nEND."}, {"source_code": "var n:int64;\n k:longint;\n\nfunction kt(n:int64):boolean;\nvar x:longint;\nbegin\n while n>0 do\n begin\n x:=n mod 10;\n n:=n div 10;\n if x=8 then exit(true);\n end;\n exit(false);\nend;\n\n\nbegin\n readln(n);\n for k:=1 to 10 do\n if kt(n+k)=true then\n begin\n writeln(k);\n exit;\n end;\nend."}, {"source_code": "//488a\nvar n,i,j,k:int64;\nbegin\n read(i);\n k:=i div 10;\n j:=i div 10;\n while (j mod 10)=9 do j:=j div 10;\n while (k>0) and (k mod 10<>8) do k:=k div 10;\n if (abs(k)>0) then write(1) else\n if i mod 10<8 then write(8- i mod 10) else\n if j mod 10<> 7 then write(18- i mod 10)else write(10-i mod 10);\n end.\n"}, {"source_code": "var n ,i ,k ,j,p :longint;\n f: boolean;\n begin\n read(n); f:=true;\n while f do begin\n Inc(n);\n Inc(k); p:=n;\n while p>0 do begin\n i:=p mod 10;\n if i=8 then begin writeln(k); exit; end;\n p:=p div 10;\n end;\n end;\n end.\n"}, {"source_code": "program zzz;\nvar\n x, i: int64;\n stop: boolean;\nfunction Has8(x: int64): boolean;\nvar\n s: ansistring;\n i: byte;\nbegin\n Str(x, s);\n for i := Length(s) downto 1 do\n if s[i] = '8'\n then begin\n Has8 := true;\n exit;\n end;\n Has8 := false;\nend;\nbegin\n read(x);\n if x >= 0\n then i := x + 1\n else i := 0;\n stop := false;\n while not stop do\n begin\n if Has8(i) and (i > 0)\n then stop := true\n else inc(i);\n end;\n write(i - x);\nend.\n"}, {"source_code": "var n:longint;\n i:longint;\n//------------\nfunction check(n:longint):boolean;\nbegin\n while n>0 do\n if n mod 10=8 then\n exit(true)\n else\n n:=n div 10;\n exit(false);\nend;\n//------------\nbegin\n read(n);\n if n>=-8 then\n for i:=1 to 100 do\n if check(n+i)=true then\n begin\n write(i);\n break;\n end;\n if n<-8 then\n begin\n n:=-n;\n for i:=1 to 100 do\n if check(n+i)=true then\n begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "var\n a, j, i, x: Integer;\nbegin\n ReadLn(a);\n for i:=1 to 10 do\n begin\n a:=a + 1;\n x:=a;\n while x > 0 do\n begin\n if x mod 10 = 8 then\n begin\n WriteLn(i);\n Halt;\n end;\n x:=x div 10;\n end;\n end\nend."}, {"source_code": "var\n a,b:longint;\n s:string;\nbegin\n readln(a);\n repeat\n inc(a);\n str(a,s);\n if pos('8',s)>0 then\n begin\n write(s);\n exit;\n end;\n until false;\nend."}, {"source_code": "const\n fi='';\n fo='';\nvar a:longint;\n\nprocedure getdata;\nvar f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,a);\n close(f);\nend;\n\nfunction check(t:longint):boolean;\nvar m:longint;\nbegin\n while (t<>0) do\n begin\n m:=t mod 10;\n t:=t div 10;\n if (m=8) then exit(true);\n end;\n exit(false);\nend;\n\nprocedure solve;\nvar g:text;\n k,i:longint;\nbegin\n assign(g,fo); rewrite(g);\n for i:=1 to 10 do\n begin\n k:=a+i;\n if check(k) then\n begin\n write(g,i);\n break;\n end;\n end;\n close(g);\nend;\n\nbegin\n getdata;\n solve;\nend.\n"}, {"source_code": "function intostr(x : longint) : string ;\nvar hsl : string ;\nbegin\n str(x,hsl) ;\n intostr := hsl ;\nend ;\n\nvar\n i,n : int64 ;\n j,x : integer ;\n s : string ;\n\nbegin\n readln (n) ;\n repeat\n begin\n inc(n) ;\n inc(i) ;\n s := intostr(n) ;\n x := length(s) ;\n for j := 1 to x do\n begin\n if s[j] = '8' then\n begin\n writeln (i) ;\n exit ;\n end;\n end;\n end;\n until i > ABS(n)+1 ;\nend.\n\n\n"}, {"source_code": "program gt;\nlabel 1;\nvar q,a,b,p,r:longint;\nbegin\nreadln(a);\nr:=a;\np:=0;\n1:\na:=a+1;\nb:=a;\nwhile b>0 do\nbegin\nq:=b mod 10;\nb:=b div 10;\nif(q=8)then begin\np:=1;\nbreak;\nend;\nend;\nif(p=1)then writeln(a-r) else goto 1;\nend."}, {"source_code": "program yan;\n var x,y,a,b:int64;\nbegin\n readln(x);\n if x<0 then begin a:=abs(x); x:=0; end;\n while true do\n begin\n inc(x); inc(a); y:=x;\n while y<>0 do\n begin\n b:=y mod 10;\n if b=8 then begin write(a); exit; end;\n y:=y div 10;\n end;\n end;\nend.\n"}, {"source_code": "var a,i,j:longint;\nbegin\n read(a);\n for i:=a+1 to a+11 do begin\n j:=i;\n j:=abs(j);\n while j>0 do begin\n if j mod 10=8 then break;\n j:=j div 10;\n end;\n if j mod 10=8 then break;\n end;\n writeln(i-a);\nend."}, {"source_code": "program z1;\n var a,b,c,i:int64;\n h:boolean;\nbegin\n readln(a);\n h:=true;\n b:=a+1;\n while(h)do\n begin\n c:=abs(b);\n while(c<>0)do\n begin\n if(c mod 10=8)\n then begin\n writeln(b-a);\n h:=false;\n end;\n c:=c div 10;\n end;\n inc(b);\n end;\n\nend.\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": "\n\nvar\n\ta,n,cek,i\t\t: integer;\n\ts\t\t: string;\n\nbegin\n\treadln(s);\n\tn:=length(s);\n\t\n\tcek:=0;\n\tfor i:=1 to n-1 do\n\tbegin\n\t\tif (s[i]='8') then\n\t\tcek:=1;\n\tend;\n\t\n\tcase s[n] of\n\t\t'0' : a:=0;\n\t\t'1' : a:=1;\n\t\t'2' : a:=2;\n\t\t'3' : a:=3;\n\t\t'4' : a:=4;\n\t\t'5' : a:=5;\n\t\t'6' : a:=6;\n\t\t'7' : a:=7;\n\t\t'8' : a:=8;\n\t\t'9' : a:=9;\n\tend;\n\t\n\n\t\n\t\n\tif cek=0 then\n\tbegin\n\tif s[1]<>'-' then\n\tbegin\n\t\tif n=1 then\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\t\twriteln(18-a);\n\t\tend else\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\tbegin\n\t\t\tif s[n-1]<>'7' then\n\t\t\tbegin\n\t\t\t\twriteln(18-a);\n\t\t\tend else\n\t\t\t\twriteln(10-a);\n\t\t\tend;\n\t\tend;\n\tend else\n\tbegin\n\t\tif n=2 then\n\t\tbegin\n\t\t\tif a<=8 then\n\t\t\tbegin\n\t\t\t\twriteln(10+a);\n\t\t\tend else\n\t\t\t\twriteln(a-8);\n\t\tend else\n\t\tbegin\n\t\t\t\n\t\t\tif s[n-1]='9' then\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2+a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend;\n\t\tend;\n\tend;\n\tend else\n\t\twriteln('1');\nend."}, {"source_code": "uses math;\nvar n,a,m,i:longint;\n s:string;\nbegin\n readln(s);\n for i:=1 to 10 do\n begin\n val(s,n,m);\n n:=n+1;\n str(n,s);\n if pos('8',s)<>0 then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "{-------------------------------------------------\n----oo--o--o-o---o--o----o------oo--o-----o-oooo----\n---o--o-oo-o-o----ooo----o-----o--o--o---o--oooo----\n---o--o-o-oo-o------o----o-----o--o---o-o---o-------\n----oo--o--o-oooo-oo-----ooooo--oo-----o----oooo----\n------------------------------------------------}\n{$MODE OBJFPC}\nprogram Onlylove;\nconst maxN =10;\nvar a : int64;\n\nprocedure enter;\n begin\n readln(a);\n\n end;\nfunction check(a : int64) : boolean;\n var r : integer;\n begin\n if a < 0 then a := -a ;\n while a <> 0 do\n begin\n r := a mod 10 ;\n if r = 8 then exit(true) ;\n a := a div 10 ;\n end;\n end;\nprocedure solve;\n var i : integer;\n begin\n for i:=1 to 25 do\n begin\n inc(a);\n if check(a) then\n begin Writeln(i); break; end;\n end;\n end;\n\nbegin\n enter;\n solve;\n\nend.\n"}, {"source_code": "program codeforces_round278_a;\n\nvar\n i, a, b : longint;\n\nfunction Check_8(x : longint) : boolean;\n begin\n if x<0\n then x:=-x;\n while x<>0 do\n begin\n if x<0\n then x:=-x;\n if x mod 10 = 8\n then begin\n Check_8:=true;\n break;\n end;\n x:=x div 10;\n end;\n end;\n\nbegin\n read(a);\n i:=1;\n while i<=8888888888 do\n begin\n if Check_8(a+i)\n then begin\n b:=i;\n break;\n end;\n i:=i+1;\n end;\n write(b);\nend.\n"}, {"source_code": "var n:longint;\n i:longint;\nbegin\n read(n);\n if n>=-8 then\n for i:=1 to 100 do\n if (n + i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n if n<-8 then\n begin\n n:=-n;\n for i:=1 to 100 do\n if (n - i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "\n\nvar\n\ta,n,cek,i\t\t: integer;\n\ts\t\t: string;\n\nbegin\n\treadln(s);\n\tn:=length(s);\n\t\n\tcek:=0;\n\tfor i:=1 to n-1 do\n\tbegin\n\t\tif (s[i]='8') then\n\t\tcek:=1;\n\tend;\n\t\n\tcase s[n] of\n\t\t'0' : a:=0;\n\t\t'1' : a:=1;\n\t\t'2' : a:=2;\n\t\t'3' : a:=3;\n\t\t'4' : a:=4;\n\t\t'5' : a:=5;\n\t\t'6' : a:=6;\n\t\t'7' : a:=7;\n\t\t'8' : a:=8;\n\t\t'9' : a:=9;\n\tend;\n\t\n\n\t\n\t\n\tif cek=0 then\n\tbegin\n\tif s[1]<>'-' then\n\tbegin\n\t\tif n=1 then\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\t\twriteln(18-a);\n\t\tend else\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\tbegin\n\t\t\tif s[n-1]<>'7' then\n\t\t\tbegin\n\t\t\t\twriteln(18-a);\n\t\t\tend else\n\t\t\t\twriteln(10-a);\n\t\t\tend;\n\t\tend;\n\tend else\n\tbegin\n\t\tif n=2 then\n\t\tbegin\n\t\t\tif a<=8 then\n\t\t\tbegin\n\t\t\t\twriteln(8+a);\n\t\t\tend else\n\t\t\t\twriteln(a-8);\n\t\tend else\n\t\tbegin\n\t\t\t\n\t\t\tif s[n-1]='9' then\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2+a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend;\n\t\tend;\n\tend;\n\tend else\n\tbegin\n\t\tif (s[1]<>'-') and (a=9) then\n\t\twriteln(9);\n\t\tif (s[1]='-') and (a=1) then\n\t\twriteln(3);\n\t\tif (s[1]<>'-') and (a<>9) then\n\t\twriteln(1);\n\t\tif (s[1]='-') and (a<>1) then\n\t\twriteln(1);\n\tend;\nend."}, {"source_code": "program z1;\n var a,b,c,i:int64;\n h:boolean;\nbegin\n readln(a);\n h:=true;\n b:=a+1;\n while(h)do\n begin\n c:=abs(b);\n while(c<>0)do\n begin\n if(c mod 10=8)\n then begin\n writeln(b-a);\n h:=false;\n end;\n c:=c div 10;\n end;\n inc(b);\n end;\n\nend.\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": "var n,i: longint;\n\nfunction check(a: longint): boolean;\nvar x: longint;\nbegin\n While a<>0 do\n begin\n x:=a mod 10;\n If x = 8 then exit(true);\n a:= a div 10;\n end;\n exit(false);\nend;\n\nBEGIN\n readln(n);\n If (n>-8) and (n<8) then writeln(8-n)\n Else\n begin\n For i:=1 to 10 do\n If check(n+i) then\n begin\n writeln(i);\n break\n end;\n end;\nEND.\n"}, {"source_code": "var a :integer;\nbegin\nread (a);\nif a = -1 then write (9);\nif a = 179 then write (1);\nif a = 18 then write (10);\nend.\n"}, {"source_code": "var n,m,i,j,k,s,g,f,d:longint;\nbegin\n\nread(n);\ninc(n);\nk:=0;\ns:=1;\nwhile k<>1 do begin\nf:=n;\nwhile f>0 do begin\nd:=f mod 10;\nif d=8 then begin k:=1; break; end;\nf:=f div 10;\nend;\ninc(s);\ninc(n);\nend;\nwrite(s-1);\nend.\n"}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e12);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:int64;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction lucky(x:int64):boolean;\n var tg:string;\n begin\n str(x,tg);\n if pos('8',tg)>0 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n);\n for i:=1 to n do if lucky(n+i) then\n begin\n writeln(fo,i);\n exit;\n end;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,res:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n for i:= 2 to na do\n if a[i] = 8 then\n begin\n if (i <> 2) or ((i = 2) and (a[1] <> 9)) then\n begin\n writeln(fo,1);\n exit;\n end;\n end;\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n if a[2] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n exit;\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var a,b:longint;\nbegin\nreadln(a);\nfor b:=10 downto 1 do\nif (a+b) mod 10=8 then\nbegin\nwriteln(b);\nbreak\nend;\nend."}, {"source_code": "uses math;\nvar n,a,m,i:longint;\n s:string;\nbegin\n readln(s);\n for i:=1 to 10 do\n begin\n val(s,n,m);\n n:=n+1;\n str(n,s);\n if pos('8',s)<>0 then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "var n,m,i,j,k,s,g,f,d:longint;\nbegin\n\nread(n);\ninc(n);\nk:=0;\ns:=1;\nwhile (k<>1) and (n>0) do begin\nf:=n;\nwhile f>0 do begin\nd:=f mod 10;\nif d=8 then begin k:=1; break; end;\nf:=f div 10;\nend;\ninc(s);\ninc(n);\nend;\nwrite(s-1);\nend.\n"}, {"source_code": "const maxn=1000000000;\nvar a,b,i,j,flag:longint;\n s:string;\nbegin\nread(a); b:=0;\nfor i:=a to maxn do\nbegin\nflag:=0;\nstr(i,s);\nfor j:=1 to length(s) do\nif s[j]='8' then flag:=1;\nif (flag=1) and (b<>0) then break;\ninc(b);\nend;\nwrite(b);\nend."}, {"source_code": "var a,b:longint;\nbegin\nreadln(a);\nfor b:=10 downto 1 do\nif (a+b) mod 10=8 then\nbegin\nwriteln(b);\nbreak\nend;\nend."}, {"source_code": "Var i,n,a,x,k,l:LongInt;\n begin\n read(a);\n l:=1;\n for i:=a+1 to a+100 do\n Begin\n x:=i;\n While x>0 do\n Begin\n if x mod 10=8 then k:=1;\n x:=x div 10;\n End;\n if k=1 then\n Begin\n Write(l);\n halt;\n End;\n inc(l);\n End;\n End."}, {"source_code": "program cf488A;\nvar a,b,i:longint;\n\nbegin\nread(a);\nfor i:=1 to 10 do\n begin\n b:=a+i;\n while abs(b)>0 do\n begin\n if (abs(b) mod 10=8) and (b<>-8) then\n begin\n writeln(i);\n exit;\n end;\n b:=b div 10;\n end;\n end;\nend.\n"}, {"source_code": "\n\nvar\n\ta,n,cek,i\t\t: integer;\n\ts\t\t: string;\n\nbegin\n\treadln(s);\n\tn:=length(s);\n\t\n\tcek:=0;\n\tfor i:=1 to n-1 do\n\tbegin\n\t\tif (s[i]='8') then\n\t\tcek:=1;\n\tend;\n\t\n\tcase s[n] of\n\t\t'0' : a:=0;\n\t\t'1' : a:=1;\n\t\t'2' : a:=2;\n\t\t'3' : a:=3;\n\t\t'4' : a:=4;\n\t\t'5' : a:=5;\n\t\t'6' : a:=6;\n\t\t'7' : a:=7;\n\t\t'8' : a:=8;\n\t\t'9' : a:=9;\n\tend;\n\t\n\n\t\n\t\n\tif cek=0 then\n\tbegin\n\tif s[1]<>'-' then\n\tbegin\n\t\tif n=1 then\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\t\twriteln(18-a);\n\t\tend else\n\t\tbegin\n\t\t\tif a<8 then\n\t\t\tbegin\n\t\t\t\twriteln(8-a);\n\t\t\tend else\n\t\t\tbegin\n\t\t\tif s[n-1]<>'7' then\n\t\t\tbegin\n\t\t\t\twriteln(18-a);\n\t\t\tend else\n\t\t\t\twriteln(10-a);\n\t\t\tend;\n\t\tend;\n\tend else\n\tbegin\n\t\tif n=2 then\n\t\tbegin\n\t\t\tif a<=8 then\n\t\t\tbegin\n\t\t\t\twriteln(8+a);\n\t\t\tend else\n\t\t\t\twriteln(a-8);\n\t\tend else\n\t\tbegin\n\t\t\t\n\t\t\tif s[n-1]='9' then\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend else\n\t\t\tbegin\n\t\t\t\tif a<=8 then\n\t\t\t\tbegin\n\t\t\t\t\twriteln(2+a);\n\t\t\t\tend else\n\t\t\t\t\twriteln(a-8);\n\t\t\tend;\n\t\tend;\n\tend;\n\tend else\n\t\twriteln('1');\nend."}, {"source_code": "var a,i:longint;\n\nfunction getLD(x:longint):integer;\nvar co:integer;\n b:longint;\n begin\n co:=0;\n while x<>0 do\n begin\n b:=x mod 10;\n if abs(b)=8\n then\n inc(co);\n x:=x div 10;\n end;\n if co<>0\n then\n getLD:=1\n else\n getLD:=0;\n end;\n\nbegin\n readln(a);\n for i:=1 to 10 do\n if getLD(a+i)>0\n then\n begin\n writeln(i);\n exit;\n end;\nend."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\n base = 20;\nvar fi, fo: text;\n s : longint;\n a : array[1..base] of longint;\n na : longint;\n\nprocedure INPUT;\nvar tmp : longint;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,s);\n na := 0;\n tmp := abs(s);\n while (tmp <> 0) do\n begin\n inc(na);\n a[na] := tmp mod 10;\n tmp := tmp div 10;\n end;\nend;\n\nprocedure Solve;\nvar ans : longint;\n i : longint;\nbegin\n ans := 0;\n if s > 0 then\n begin\n for i:= 2 to na do\n if a[i] = 8 then\n begin\n if (i <> 2) or ((i = 2) and (a[1] <> 9)) then\n begin\n writeln(fo,1);\n exit;\n end;\n end;\n if a[1] < 8 then\n begin\n writeln(fo,8-a[1]);\n exit;\n end;\n ans := 10 - a[1];\n if a[2] = 7 then\n begin\n writeln(fo,ans);\n exit;\n end;\n ans := ans + 8;\n writeln(fo,ans);\n exit;\n end;\n for i:= 2 to na do\n if a[i] = 8 then\n begin\n if (i <> 2) or ((i = 2) and (a[1] <> 0)) then\n begin\n writeln(fo,1);\n exit;\n end;\n end;\n if (-8 <= s ) and (s <= 0) then\n begin\n writeln(fo,8 - s);\n exit;\n end;\n if (a[1] = 0) then\n begin\n if a[2] = 9 then\n begin\n writeln(fo,1);\n exit;\n end;\n writeln(fo,2);\n exit;\n end;\n if (a[1] = 9) then\n begin\n writeln(fo,1);\n exit;\n end;\n ans := a[1] + 2;\n writeln(fo,ans);\n exit;\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var n:longint;\n i:longint;\nbegin\n read(n);\n if n>=-8 then\n for i:=1 to 100 do\n if (n + i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n if n<-8 then\n begin\n n:=-n;\n for i:=1 to 100 do\n if (n - i) mod 10 =8 then\n begin\n write(i);\n break;\n end;\n end;\nend."}, {"source_code": "program bashnya;\nvar a,b:int64;\nbegin\nread(a);\nif a<=0 then\n write(8-a);\nif a>0 then\n if a mod 10<=8 then\n write(8-a)\n else\n if (a mod 100 div 10=7) or ((a mod 1000 div 100=7) and (a mod 100 div 10=9)) or ((a mod 10000 div 1000=7) and (a mod 100 div 10=9) and (a mod 1000 div 100=9))\n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=7))\n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=9) and \n (a mod 1000000 div 100000=7)) \n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=9) and \n (a mod 1000000 div 100000=9) and (a mod 10000000 div 1000000=7))\n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=9) and \n (a mod 1000000 div 100000=9) and (a mod 10000000 div 1000000=9) and (a mod 100000000 div 10000000=7))\n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=9) and \n (a mod 1000000 div 100000=9) and (a mod 10000000 div 1000000=9) and (a mod 100000000 div 10000000=9) and (a mod 1000000000 div 100000000=7))\n or ((a mod 10000 div 1000=9) and (a mod 100 div 10=9) and (a mod 1000 div 100=9) and (a mod 100000 div 10000=9) and \n (a mod 1000000 div 100000=9) and (a mod 10000000 div 1000000=9) and (a mod 100000000 div 10000000=9) and (a mod 1000000000 div 100000000=9)\n and (a mod 10000000000 div 1000000000=7)) then\n write(1)\n else\n write(9);\nend.\n"}, {"source_code": "{-------------------------------------------------\n----oo--o--o-o---o--o----o------oo--o-----o-oooo----\n---o--o-oo-o-o----ooo----o-----o--o--o---o--oooo----\n---o--o-o-oo-o------o----o-----o--o---o-o---o-------\n----oo--o--o-oooo-oo-----ooooo--oo-----o----oooo----\n------------------------------------------------}\n{$MODE OBJFPC}\nprogram Onlylove;\nconst maxN =10;\nvar a : int64;\n\nprocedure enter;\n begin\n readln(a);\n end;\nfunction check(a : int64) : boolean;\n var r : integer;\n begin\n while a <> 0 do\n begin\n r := a mod 10 ;\n if r = 8 then exit(true) ;\n a := a div 10 ;\n end;\n end;\nprocedure solve;\n var i : integer;\n begin\n for i:=1 to 25 do\n begin\n inc(a);\n if check(a) then\n begin Writeln(i); break; end;\n end;\n end;\nprocedure printresult;\n begin\n {close(fi);\n close(fo);}\n end;\nbegin\n enter;\n solve;\n printresult;\nend.\n"}, {"source_code": "var a :integer;\nbegin\nread (a);\nif a = -1 then write (9);\nif a = 179 then write (1);\nif a = 18 then write (10);\nif a = -410058385 then write (1);\nend.\n"}], "src_uid": "4e57740be015963c190e0bfe1ab74cb9"} {"source_code": "var\ns,ss,sss:string;\na,b,i,j:longint;\nbegin\nreadln(a,b);\nstr(b,sss);\nfor i:=a+1 to 1000000 do begin\n str(i,s);\n ss:='';\n for j:=1 to length(s) do begin\n if (s[j]='4')or(s[j]='7') then ss:=ss+s[j];\n end;\n if (ss=sss)and(i>a) then begin\n writeln(i);\n break;\n end;\nend;\nend.", "positive_code": [{"source_code": "{$APPTYPE CONSOLE}\n{R+,S+,Q+,I+,C+,M+,H+,O+}\n{$R-,S-,Q-,I-,C+,M-,H+,O-}\n\nuses\n\tSysUtils, Math;\n\nvar\n\ti, a, b : longint;\n\nfunction mask(n : longint) : longint;\n\nvar\n\ti, cc : longint;\n\ta : array[0..20] of longint;\n\nbegin\n\tcc := 0;\n\twhile n > 0 do begin\n\t\tif (n mod 10 = 4) or (n mod 10 = 7) then begin\n\t\t\tinc(cc);\n\t\t\ta[cc] := n mod 10;\n\t\tend;\n\t\tn := n div 10;\n\tend;\n\tresult := 0;\n\tfor i := cc downto 1 do\n\t\tresult := result * 10 + a[i];\nend;\n\t\nbegin\n{$IFNDEF ONLINE_JUDGE}\n\treset(input, 'input.txt');\n\trewrite(output, 'output.txt');\n{$ENDIF}\n\tread(a, b);\n\ti := a + 1;\n\twhile true do begin\n\t\tif mask(i) = b then begin\n\t\t\twrite(i);\n\t\t\thalt(0);\n\t\tend;\n\t\tinc(i);\n\tend;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R+,Q+,I+}\n\nuses\n SysUtils;\n\n{function Happy(a:integer):Boolean;\nvar\n i:integer;\nbegin\n Happy:=False;\n i:=a;\n while i>0 do begin\n if (i mod 10 <>4) and (i mod 10 <> 7) then Exit;\n i:=i div 10;\n end;\n Happy:=True;\nend;}\n\nfunction Mask(a:Integer):Integer;\nvar\n i:Byte;\n c:string;\nbegin\n c:='';\n for i:=1 to Length(IntToStr(a)) do begin\n if (Copy(IntToStr(a),i,1)='4') or (Copy(IntToStr(a),i,1)='7') then c:=c+Copy(IntToStr(a),i,1);\n end;\n if c='' then Mask:=0 else Mask:=StrToInt(c);\nend;\n\nvar\n a,b,c:integer;\nbegin\n read(a,b);\n repeat\n inc(a);\n c:=Mask(a);\n until c=b;\n write(a);\n Readln;\n Readln;\nend."}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nvar\na,b,i,d,x,k,cur : longint;\n\nbegin\n readln (a,b);\n if b>a then\n begin\n writeln (b);\n exit;\n end;\n\n i:=a;\n while true do\n begin\n inc (i);\n d:=i;\n x:=0;\n cur:=1;\n while d<>0 do\n begin\n k:=d mod 10;\n if (k=7) or (k=4) then begin x:=k*cur+x; cur:=cur*10; end;\n d:=d div 10;\n end;\n if x=b then\n begin\n writeln (i);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "var\n a,b,c,i,qw: longint;\nfunction func(a : longint) : longint;\nvar\n s,so : string;\n u,i,code: longint;\nbegin\n s := '';\n str(a,so);\n for i := 1 to length(so) do\n if (so[i] = '4') or (so[i] = '7') then\n s := s + so[i];\n val(s,u,code);\n func := u;\nend;\nbegin\n {assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output);}\n readln(a,b);\n c := a;\n while qw <> b do\n begin\n inc(c);\n qw := func(c);\n end;\n writeln(c);\nend.\n"}, {"source_code": "program ProjecB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\na,b,i:integer;\ns:string;\n\nfunction find(y:integer):integer;\n var\n x:array[1..100000] of integer;\n t,k,rez,u,j:integer;\n begin\n rez:=0;\n k:=0;\n while y>0 do\n begin\n t:=y mod 10;\n y:=y div 10;\n if t in [4,7] then\n begin\n inc(k);\n x[k]:=t;\n end;\n end;\n u:=1;\n for j:=1 to k do\n begin\n rez:=rez+x[j]*u;\n u:=u*10;\n end;\n find:=rez;\n end;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\nreadln(a,b);\ninc(a);\nwhile find(a)<>b do\n inc(a);\nwriteln(a);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\ni,n,t,t2,k,j,a,b:Integer;\nstr,str1:String;\nbol:Boolean = False;\nbegin\nReadln(a,b);\nfor i:=a+1 to 1000000 do\nbegin\n str:=IntToStr(i);\n str1:='';\n for j:=1 to Length(str) do\n if (str[j]='4') or (str[j]='7') then\n str1:=str1+str[j];\n if (str1<>'') and (StrToInt(str1)=b) then\n begin\n Writeln(i);\n Exit;\n end;\nend;\n\nRead(t2);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var\n a,b,i:integer;\n\n function mask(x:integer):integer;\n var\n k,i,code:integer;\n s,ans:string;\n begin\n str(x,s);\n ans:='0';\n for i:=1 to length(s) do\n begin\n if (s[i]='4')or(s[i]='7') then ans:=ans+s[i];\n end;\n val(ans,k,code);\n mask:=k;\n end;\n\nbegin\nreadln(a,b);\nfor i:=a+1 to 177777 do\nbegin\n if (mask(i)=b) then begin writeln(i); readln; halt; end;\nend;\n\nend.\n"}, {"source_code": "program task_2;\n{$APPTYPE CONSOLE}\nuses SysUtils;\nvar a,b:integer;\n s1,s2:string;\n\nfunction mask(t:string):string;\nvar i:integer;\n tmp:string;\nbegin\n tmp:='';\n for i:=1 to length(t)do\n if (t[i]='4')or(t[i]='7')then\n tmp:=tmp+t[i];\n mask:=tmp;\nend;\n\nbegin\n read(a,b);\n if (b>a)then begin\n write(b);\n halt;\n end;\n inc(a);\n s1:=inttostr(a);\n s2:=inttostr(b);\n while (mask(s1)<>s2)do begin\n inc(a);\n s1:=inttostr(a);\n end;\n write(s1);\nend.\n"}, {"source_code": "uses math;\nvar n,i,j,k,a,b:longint;\n s:string;\n{\nfunction f(n:longint):string;\nbegin\nf:='';\nwhile n>0 do\n begin\n f:=chr(ord('0')+n mod 10)+f;\n n:=n div 10;\n end;\nend;\n}\nbegin\nread(a,b);\n\n\nfor j:=1+a to 999999 do\n begin\n\n k:=j;\n s:='';\n while k>0 do\n begin\n s:=chr(ord('0')+k mod 10)+s;\n k:=k div 10;\n end;\n\n k:=0;\n for i:=1 to length(s)do\n if (s[i]='4')or(s[i]='7')then k:=k*10+ord(s[i])-ord('0');\n\n if k=b then begin writeln(j);halt;end;\n end;\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,b,c:integer;\n i:integer;\n x:char;\n s1:string;\n found:boolean;\nfunction getmask(a:integer):string;\nvar old,mask:string;\n j,k:integer;\nbegin\n mask:='';\n old:=inttostr(a);\n for k:=1 to length(old) do\n if (old[k]='7') or (old[k]='4') then begin\n inc(j);\n mask:=mask+old[k];\n end;\n getmask:=mask;\nend;\nbegin\n readln(a,b);\n if a a do\n d := d div 10;\n\n t := 0;\n while a > 0 do begin\n k := a div d;\n if (k = 4) or (k = 7) then\n t := 10 * t + k;\n a := a mod d;\n d := d div 10;\n end;\n\n result := t;\nend;\n\nprocedure run;\nbegin\n read(a, b);\n\n inc(a);\n\n while m(a) <> b do\n inc(a);\n\n write(a);\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar a,KQ:string;\n x,y,i,x1,b,t:longint;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n read(f,x,y);\n x1:=x;\n repeat\n inc(x);\n str(x,a);\n for i:=length(a) downto 1 do\n if (a[i]<>'4') and (a[i]<>'7') then\n delete(a,i,1);\n val(a,b,t);\n until (b=y) and (x>x1);\n str(x,KQ);\n write(g,KQ);\n close(f); close(g);\nend."}, {"source_code": "var\n i,j,l,a,b:longint;\n s1,s2:string;\nbegin\n readln(a,b);\n str(b,s1);\n i:=a+1;\n while true do begin\n l:=1;\n str(i,s2);\n for j:=1 to length(s2) do if (s2[j]='4') or (s2[j]='7') then begin\n if l=length(s1)+1 then begin inc(l); break; end;\n if s1[l]=s2[j] then inc(l) else break;\n end;\n if l=length(s1)+1 then break;\n inc(i);\n end;\n writeln(i);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n b,s:string;\n i,a:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n read(a); read(b);\n while b[1]=' ' do delete(b,1,1);\n close(input);\nend;\n\nfunction kt(s:string):boolean;\nvar dem:longint;\nbegin\n dem:=0;\n for i:=1 to length(s) do\n if (s[i]='7') or (s[i]='4') then\n inc(dem);\n if dem>length(b) then exit(false);\n for i:=1 to length(b) do\n begin\n if length(s)=0 then exit(false);\n if pos(b[i],s)=0 then exit(false);\n delete(s,1,pos(b[i],s));\n end;\n kt:=true;\nend;\n\nprocedure xuly;\nbegin\n str(a+1,s); a:=a+1;\n while kt(s)=false do\n begin\n inc(a);\n str(a,s);\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(a);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend.\n"}, {"source_code": "var n,i,j,k1,m:longint;\n s,k,s1:ansistring;\nbegin\nreadln(n,m);\nwhile true do\nbegin\n inc(n);\n str(n,k);\n k1:=length(k);\n for i:=1 to k1 do\n if (k[i]='4') or (k[i]='7') then s1:=s1+k[i];\n val(s1,j,k1);\n if j=m then begin writeln(n); halt; end;\n s1:='';\n k:='';\n\nend;\nend."}, {"source_code": "{$mode objfpc}\nvar\n a, b, c, i, j, n : Integer;\n\nfunction check(x : Integer ): Integer;\nvar\n p, q, cs : Integer;\nbegin\n if x = 147 then\n c := 1;\n result := 0;\n cs := 1;\n while x > 0 do\n begin\n if (x mod 10 = 4) or (x mod 10 = 7) then\n begin\n result := (x mod 10) * cs + result;\n cs := cs * 10;\n end;\n x := x div 10;\n end;\n\nend;\n\nbegin\n read(a, b);\n repeat\n a := a + 1;\n if check(a) = b then\n begin\n writeln(a);\n halt;\n end;\n until false;\nend.\n"}, {"source_code": "var\n a,b,i,j:longint;\n ss,te,s:string;\nbegin\n readln(a,b);\n str(b,ss);\n i:=a;\n while true do begin\n i:=i+1;\n te:='';\n str(i,s);\n for j:=1 to length(s) do if (s[j]='4')or(s[j]='7') then te:=te+s[j];\n if te=ss then begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "var\n a,b:longint;\n i,j:longint;\n bi,t:array[0..6] of longint;\nfunction chack(n:longint):boolean;\nvar i,j,ti,k:longint;\nbegin\n k:=0;\n for i:=6 downto 1 do\n if\n (n div t[i] mod 10 =4)\n or\n (n div t[i] mod 10 =7)\n then k:=k*10+n div t[i] mod 10;\n exit(k=b);\nend;\nbegin\n readln(a,b);\n bi[0]:=-1;\n t[1]:=1;\n for i:=2 to 6 do t[i]:=10*t[i-1];\n for i:=1 to 6 do bi[i]:=b div t[i] mod 10;\n if b>a then writeln(b)\n else\n begin\n for i:=a+1 to 200000 do\n if chack(i) then begin writeln(i);exit;end;\n end;\nend.\n\n"}, {"source_code": "{$mode objfpc}\n{$S-, Q-, R-, I-, O+}\n{-$S+, Q+, R+, I+, O+}\nuses sysutils;\nvar\n a, b, c : longint;\n\n function m(c : longint) : longint;\n var\n s, s2 : string;\n i : integer;\n begin\n s := inttostr(c);\n s2 := '0';\n result := 0;\n for i:=1 to length(S) do\n if s[i] in ['4', '7'] then\n s2 := s2 + s[i];\n result := strtoint(s2);\n end;\n\nbegin\n readln(a, b);\n c := a + 1;\n while m(c) <> b do\n c := c + 1;\n write(c);\nend.\n\n"}, {"source_code": "uses sysutils;\nvar\n A,B,C:longint;\nfunction getMask(a:longint):longint;\nvar\n s,s2:string;\n i:byte;\nbegin\n s:=IntToStr(a);\n s2:='';\n for i := 1 to length(s) do\n if s[i] in ['7','4']\n then\n s2:=s2+s[i];\n if s2 = ''\n then\n s2:='0'; \n getMask:=StrToInt(s2);\nend;\nbegin\n read(A,B);\n for C:=A+1 to 1000000 do\n if getMask(C)=B\n then\n break;\n \n writeln(C);\nend.\n"}, {"source_code": "var a,b:longint;\nfunction mask(a:longint):longint;\nvar x,k,c:longint;\nbegin\n c:=a;\n x:=1;\n k:=0;\n while c>0 do begin\n if (c mod 10=4)or(c mod 10=7) then begin\n k:=k+(c mod 10)*x;\n x:=x*10;\n end;\n c:=c div 10;\n end;\n mask:=k;\nend;\nbegin\n readln(a,b);\n inc(a);\n while mask(a)<>b do\n inc(a);\n writeln(a);\n readln;\nend."}, {"source_code": "var \n a,b,i:longint;\n\nfunction numoff(x:longint):longint;\nvar \n i,ans:longint; \n tmp:string;\nbegin \n str(x,tmp); \n i:=1; \n while i<=length(tmp) do \n begin \n if (tmp[i]<>'4')and(tmp[i]<>'7') then delete(tmp,i,1)\n else inc(i);\n end; \n val(tmp,ans); \n exit(ans);\nend;\n\nbegin \n readln(a,b); \n for i:=a+1 to 1000000 do \n if numoff(i)=b then \n begin \n writeln(i); \n halt; \n end;\nend.\n//By THCDUSMAN"}, {"source_code": "Var a,b,c,i:longint;\nFunction ktra(i:longint) :boolean;\n Var j:longint;\n tmp:String;\n s :String;\n s1:longint;\n Begin\n Str(i,tmp);\n s:='';\n For j:=1 to length(tmp) do\n Begin\n If ( tmp[j]='4') or ( tmp[j]='7') then\n Begin\n s:=s+tmp[j];\n End;\n End;\n Val(s,s1);\n If s1=b then ktra:=true else ktra:=false;\n End;\n\nBegin\n Read(a,b);\n i:=a+1;\n repeat\n If (ktra(i)) then Begin Write(i); Readln; exit; End\n else inc(i);\n until false;\n\n Readln;\nEND.\n"}, {"source_code": "Var a,b,c,i,j:longint; s,ss,g:string;\n\nFunction check:boolean;\nVar q:string;i:longint;\nbegin\n\nq:=''; for i:=1 to length(s) do if (s[i]='4')or(s[i]='7') then q:=q+s[i];\n\nif q=g then check:=true else check:=false;\n\nEnd;\n\nBegin\n\nReadln(a,b); i:=a+1; if a0 do begin ss:=char(a mod 10+48)+ss; a:=a div 10; end;\ng:=''; While b>0 do begin g:=char(b mod 10+48)+g; b:=b div 10; end;\n\nWhile true do begin\n\ns:='';j:=i; While j>0 do begin s:=char(j mod 10+48)+s; j:=j div 10; end;\n\nif check then begin Writeln(s); halt; end;\n\ninc(i); end;\n\nEnd.\n"}, {"source_code": "var n,i,a,b,x,k:longint;\n p:integer;\n s:string;\nbegin\n read(a,b);\n x:=a;\n k:=x;\n repeat\n inc(x);\n str(x,s);\n for i:=length(s) downto 1 do if (s[i]<>'4') and (s[i]<>'7') then delete(s,i,1);\n val(s,k,p);\n until k=b;\n writeln(x);\nend.\n\n\n"}, {"source_code": "\nvar a,b:longint;\nfunction dk(x,y:longint):boolean;\nvar r,hh:string;\nint,i:longint;\nbegin\nr:='';\ndk:=false;\nstr(y,hh);\nfor i:=1 to length(hh) do if (hh[i]='4') or (hh[i]='7') then r:=r+hh[i];\nval(r,int);\nif int=x then dk:=true;\nend;\n//\nbegin\n\nreadln(a,b);\nrepeat\ninc(a);\nuntil dk(b,a);\nwriteln(a);\nreadln;\nend.\n"}, {"source_code": "var\n s:ansistring;\n n,m,i,z,x,c,ss,d,r:longint;\n l:integer;\nbegin\n read(n,m);\n for i:=n+1 to 2000000 do\n begin\n x:=i;\n s:='';\n while x<>0 do\n begin\n z:=x mod 10;\n if (z=4)or(z=7)then s:=chr(z+48)+s;\n x:=x div 10;\n end;\n val(s,d,l);\n if d=m then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "var\na,b,c,p,l,n,i,j,cuantos,total:longint;\ncual,cad:string;\nbegin\n readln(a,b);\n str(b,cual);\n n:=length(cual);\n if b>a then\n begin\n writeln(b);\n halt;\n end;\n i:=a+1;\n while 0=0 do\n begin\n str(i,cad);\n l:=0;\n p:=length(cad);\n cuantos:=0;\n total:=0;\n for j:=1 to p do\n if (cad[j]='7') or (cad[j]='4') then\n begin\n inc(total);\n inc(l);\n if (l<=n) and (cual[l]=cad[j]) then\n inc(cuantos);\n end;\n if (cuantos=n) and (total=n) then\n begin\n writeln(i);\n halt;\n end;\n inc(i);\n end;\nend."}, {"source_code": "var\n a:array[0..10000] of longint;\n n,m,i,j,k,l:longint;\n c:char;\n s,s1,s2:string;\nbegin\n readln(n,m);\n str(m,s);\n i:=n+1;\n while true do\n begin\n str(i,s1);\n s2:='';\n for l:=1 to length(s1) do\n if s1[l] in ['4','7'] then s2:=s2+s1[l];\n\n if s2=s then break;\n inc(I);\n\n end;\n write(i);\nend.\n"}, {"source_code": "var\n a,b:int64;\n i:longint;\n key,s,ss:ansistring;\nbegin\n read(a,b);\n if a0 do \n begin\n if (a1 mod 10=4) or (a1 mod 10=7) then x1:=(x1*10)+(a1 mod 10);\n a1:=a1 div 10;\n end;\n while x1>0 do \n begin\n k:=(k*10)+(x1 mod 10);\n x1:=x1 div 10;\n end;\n mask:=k;\n end;\nbegin\nreadln(a,b);\nx:=a+1;\nwhile mask(x)<>b do\n inc(x);\nwrite(x);\nend."}, {"source_code": "var a,b,c,i,k,aa:longint;\n x:array[1..10]of integer;\n\nbegin\n read(a,b);\n if a0 do\n begin\n if a mod 10= 4 then begin inc(k);x[k]:=4; end;\n if a mod 10= 7 then begin inc(k);x[k]:=7; end;\n a:=a div 10;\n end;\n for i:=k downto 1 do\n c:=c*10+x[i];\n if c=b then begin writeln(aa);break; end;\n a:=aa;\n\n end;\n end;\nend.\n"}, {"source_code": "var s,s1:string;\nn,i,a,c:longint;\nfunction func(x:longint):longint;\nvar s:string;\nj,st,b:longint;\nbegin\n str(x,s);s1:='';\n for j:=1 to length(s) do\n if (s[j]='4') or (s[j]='7') then s1:=s1+s[j];\n st:=1;b:=ord(s1[length(s1)])-ord('0');\n for j:=length(s1)-1 downto 1 do\n begin\n st:=st*10;\n b:=b+st*(ord(s1[j])-ord('0'));\n end;\nfunc:=b;\nend;\nbegin\nread(a,c);inc(a);\nwhile a=a do\n begin\n if func(a)=c then break;\n inc(a);\n end;\nwriteln(a);\n end."}, {"source_code": "const\n tfi='';\n tfo='';\nvar\n p,q:string;\n a,b:longint;\n\nfunction mask(r:string):string;\nvar\n i:longint;\n res:string;\nbegin\n res:='';\n for i:=1 to length(r) do\n if (r[i]='4') or (r[i]='7') then\n res:=res+r[i];\n exit(res);\nend;\n\nprocedure main;\nbegin\n assign(input,tfi); reset(input);\n assign(output,tfo); rewrite(output);\n read(a,b);\n str(b,q);\n repeat\n inc(a);\n str(a,p);\n until mask(p)=q;\n writeln(a);\n close(input); close(output);\nend;\n\nBEGIN\n main;\nEND.\n"}, {"source_code": "var\n i,j,n,m,k,kol,res:longint;\n ss,ans,sa,sb,s:string;\n f1,f2:integer;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output);}\n readln(n,m);\n str(m,sb);\n while true do\n begin\n inc(n);\n str(n,sa);\n for i:=1 to length(sa) do if (sa[i]='4')or(sa[i]='7') then ss:=ss+sa[i];\n if ss=sb then break;\n ss:='';\n end;\n writeln(n);\nend.\n"}, {"source_code": "var a,b,c,i:longint;\nfunction mask(a:longint):longint; var c,n,f:longint; p:byte;\nbegin n:=a; c:=0; f:=0;\nrepeat p:=n mod 10; if (p=4) or (p=7) then\nbegin if f=0 then f:=1 else f:=f*10; c:=c+f*p; end; n:=n div 10; until n=0;\nmask:=c; end;\nbegin readln(a,b);\nif b>a then begin write(b); exit; end;\ni:=a; repeat inc(i); if mask(i)=b then begin writeln(i); exit; end;\nuntil i>1000000;\nend."}, {"source_code": "var n,k,e,i:longint;\n s:string;\nbegin\n readln(n,k);\n repeat\n n:=n+1;\n e:=0;\n str(n,s);\n for i:=1 to length(s) do\n begin\n if s[i]='4' then e:=e*10+4;\n if s[i]='7' then e:=e*10+7;\n end;\n if e=k then\n begin\n writeln(n);\n halt;\n end;\n until false;\nend."}, {"source_code": "var n,a,b,i,f,k,x,p:longint;s1,s2,s:string;\nbegin\nreadln(a,b);\nstr(a,s1);\nstr(b,s2);\nif (a0 do\nbegin\np:=x mod 10;\nif (p=4)\nthen s:='4'+s\nelse if p=7\n then s:='7'+s;\nx:=x div 10 ;\nend;\nif s2=s\nthen begin\n k:=1;\n writeln(a);\n exit;\n end;\nend;\nend.\n\n"}, {"source_code": "var a,b,i,kl,x:longint;\n st,s:string;\n code:integer;\nbegin\n readln(a,b);\n while kl<>1 do\n begin\n inc(a);\n str(a,st);\n for i:=1 to length(st) do\n if (st[i]='4') or (st[i]='7')\n then s:=s+st[i];\n val(s,x,code);\n if x=b\n then\n begin\n writeln(a);\n break;\n end;\n s:='';\n end;\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar a,KQ:string;\n x,y,i,x1,b,t:longint;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n read(f,x,y);\n x1:=x;\n repeat\n inc(x);\n str(x,a);\n for i:=length(a) downto 1 do\n if (a[i]<>'4') and (a[i]<>'7') then\n delete(a,i,1);\n val(a,b,t);\n until (b=y) and (x>x1);\n str(x,KQ);\n write(g,KQ);\n close(f); close(g);\nend.\n\n"}, {"source_code": "var\n x,a,b,c,bb,cc:longint;\n\nbegin\n read(a,b);\n if (b>a)then begin\n writeln(b);\n exit;\n end;\n for c:=a+1 to 1000000000 do begin\n bb:=b;\n cc:=c;\n while (cc>0)do begin\n x:=cc mod 10;\n cc:=cc div 10;\n if (x<>4)and(x<>7)then continue;\n if (x<>bb mod 10)then begin\n bb:=-1;\n break; \n end;\n bb:=bb div 10;\n end;\n if (bb=0)then begin\n writeln(c);\n exit;\n end;\n end;\nend.\n"}, {"source_code": "Var a,b:longint;\n\n procedure InputData;\n begin\n readln(a,b);\n end;\n\n function mask(x:longint):longint;\n var y,p,s,i:longint;\n s1:string;\n begin\n s:=0;\n str(x,s1);\n for i:=1 to length(s1) do\n if (s1[i]='4') or (s1[i]='7') then\n begin\n val(s1[i],y,p);\n s:=s*10+y;\n end;\n mask:=s;\n end;\n\n procedure ProcessData;\n var i:longint;\n begin\n i:=a+1;\n while true do\n begin\n if mask(i)=b then break;\n inc(i);\n end;\n writeln(i);\n end;\n\nbegin\nInputData;\nProcessData;\nend."}, {"source_code": "var\n a,b,c,x,y,z:longint;\nbegin\nreadln(a,b);\nif b>a then write(b) else \nfor c:=a+1 to 1000000 do\n begin\n x:=c;\n y:=1;\n z:=0;\n while x<>0 do\n begin\n if (x mod 10=4)or(x mod 10=7) then\n begin\n z:=(x mod 10)*y+z;\n y:=y*10;\n end;\n x:=x div 10;\n end;\n if z=b then \n begin\n write(c);\n halt;\n end;\n end;\nend."}, {"source_code": "var\n a,b,p,ans:longint;\n c:array[1..100]of longint;\n i,j,n,m,k,s,t:longint;\nfunction ok(p:longint):boolean;\nbegin\n k:=0;\n while p>0 do\n begin\n inc(k);\n c[k]:=p mod 10;\n p:=p div 10;\n end;\n ans:=0;\n for i:=k downto 1 do\n if (c[i]=4)or(c[i]=7) then\n ans:=ans*10+c[i];\n if ans=b then exit(true)\n else exit(false);\nend;\nbegin\n readln(a,b);\n inc(a);\n while not ok(a) do\n inc(a);\n writeln(a);\nend.\n"}, {"source_code": "Var s,t:string;\n j,i,a,b,f,l,p:longint;\n begin\n read(a,b);\n for i:=a+1 to 10000000 do\n begin\n f:=i;\n str(f,t);\n s:='';\n for j:=1 to length(t) do\n if (t[j]='4') or (t[j]='7') then s:=s+t[j];\n val(s,l,p);\n if l=b then begin write(f); exit; end;\n end;\n end."}, {"source_code": "var y,s:string;\n a,b,x,i,c,z:longint;\nbegin\n read(a,b);\n for c:=a+1to 1000000do\n begin\n x:=c;\n y:='';\n str(x,s);\n for i:=1to length(s)do\n if(s[i]='4')or(s[i]='7')then y:=y+s[i];\n val(y,x,z);\n if x=b then break;\n end;\n write(c)\nend."}, {"source_code": "var n,f,i,a,b,s:longint;\nBegin\n read(a,b);\n f:=0;\n while f=0 do\n begin\n a:=a+1;\n n:=a;\n s:=0;\n i:=0;\n while n>0 do\n begin\n if n mod 10 in[4,7] then s:=s*10+n mod 10;\n n:=n div 10;\n end;\n while s>0 do\n begin\n i:=i*10+s mod 10;\n s:=s div 10;\n end;\n if i=b then f:=1;\n end;\n writeln(a);\nEnd."}, {"source_code": "uses sysutils;\nvar a, b, c, i: integer;\n\nfunction mask(n: integer): integer;\nvar i: integer;\n s, s2: string;\nbegin\n s := inttostr(n);\n s2 := '';\n for i := 1 to length(s) do\n if (s[i] = '4') or (s[i] = '7') then\n s2 := s2 + s[i];\n if length(s2) <> 0 then \n result := strtoint(s2)\n else\n result := 0;\nend;\n\nbegin\n //assign(input, 'input.txt'); reset(input);\n //assign(output, 'output.txt'); rewrite(output);\n readln(a, b);\n c := a + 1; \n \n while (mask(c) <> b) do begin \n inc(c);\n\n end;\n \n\n\n writeln(c);\n\n\n\n\n \nend."}, {"source_code": "program happy_mask;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a,b,c:integer;\n\nfunction mask(x:integer):integer;\nvar\n y,z,d:integer;\nbegin\n y:=x;\n z:=0;\n d:=10;\n while (d<=x) do d:=10*d;\n d:=d div 10;\n while (y>0) do\n begin\n if((y div d)=4) or ((y div d)=7) then\n z:=10*z+(y div d);\n y:=y mod d;\n d:=d div 10;\n end;\n mask:=z;\nend;\n\nbegin\n readln(a,b);\n a:=a+1;\n c:=mask(a);\n while(c<>b) do\n begin\n inc(a);\n c:=mask(a);\n end;\n writeln(a);\nend.\n "}, {"source_code": "uses\n sysutils, strutils, math;\ntype\n ex=extended;\n int=longint;\n bool=boolean;\nvar\n a,b,i: int;\n s: string;\n\nfunction check(c: int): bool;\nvar\n i: int;\n t,r: string;\nbegin\nt:= inttostr(c);\nr:= '';\nfor i:= 1 to length(t) do\n if (t[i]='4')or(t[i]='7')\n then\n r:= r+t[i];\ncheck:= (r=s);\nend;\n\nbegin\nreadln(a,b);\ns:= inttostr(b);\nfor i:= a+1 to 1777770 do\n if check(i)\n then\n begin\n writeln(i);\n exit;\n end;\nend.\n"}, {"source_code": "Uses Math;\ntype mass=array[0..50000,1..3] of integer;\nVar n,d1,d2,c,l,k,i,a,b,z:LongInt;ch:char;m1,dp:mass;s,s1:string;\nBegin\n// ReSet(input,'input.txt');\n// ReWrite(output,'output.txt');\n readln(a,b);\n if b>a\n then Begin\n writeln(b);\n halt(0);\n end;\n str(b,s);\n for i:=a+1 to a+1000001 do\n Begin\n c:=i;\n s1:='';\n while c>0 do\n Begin\n if (c mod 10) in [4,7]\n then s1:=chr(ord('0')+c mod 10)+s1;\n c:=c div 10;\n end;\n if s1=s\n then Begin\n writeln(i);\n halt(0);\n end;\n end;\nEnd.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, a1, i : integer;\n s : string;\n\nbegin\n\n read(a, b);\n while true do begin\n inc(a);\n s := inttostr(a);\n i := 1;\n while i <= length(s) do begin\n if (s[i] <> '4') and (s[i] <> '7') then\n delete(s, i, 1)\n else\n inc(i);\n end;\n if (length(s) > 0) and (strtoint(s) = b) then begin\n writeln(a);\n readln;readln;\n halt;\n end;\n end;\n\n readln;readln;\nend.\n"}, {"source_code": "var a,b,c:dword;\nfunction kt:boolean;\nvar s:string[6]; i:byte; tg:dword=0;\nbegin\n str(c,s);\n for i:=1 to length(s) do\n if s[i] in ['4','7'] then tg:=tg*10+ord(s[i])-48;\n if tg=b then kt:=true\n else kt:=false\nend;\nbegin\n read(a,b);\n c:=b;\n while c<=a do\n repeat inc(c)\n until kt;\n write(c)\nend."}, {"source_code": "Var x, s4, so4, s7, so7, a, b, i : longint;\n\nFunction mask(i:longint):longint;\n Var s : string;\n b : longint;\n Begin\n s := '';\n str(i,s);\n for i:=length(s) downto 1 do\n if (s[i] <> '4') and (s[i] <> '7') then delete(s,i,1);\n val(s,b,i);\n mask := b;\n End;\n\nBegin\n readln(a,b);\n for i:=a+1 to 1000000 do begin\n x := mask(i);\n if x = b then begin\n writeln(i);\n exit;\n end;\n end;\nEnd.\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n\nvar\n n, k, i, c, res, a, b, w: integer;\n d: int64;\n ok: boolean;\n\nprocedure panic(x: integer);\nbegin\n write(x);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nfunction f(w: integer): integer;\nvar\n dc: integer;\nbegin\n dc := 0;\n While w > 0 do\n begin\n if (w mod 10 = 4) or (w mod 10 = 7) then\n dc := 10 * dc + w mod 10;\n w := w div 10;\n end;\n Result := dc;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(a, b);\n w := 0;\n While b > 0 do\n begin\n w := 10 * w + b mod 10;\n b := b div 10;\n end;\n b := w;\n for i := 1 to 1000000000 do\n begin\n c := f(i);\n if (c = b) and (i > a) then\n panic(i);\n end;\n\n\n\nend.\n"}, {"source_code": "var bb,a,b,i:longint;\n\nfunction mask(i:longint):longint;\nvar j,s:longint;\nb:array [1..100] of byte;\nbegin\nj:=1;\nwhile i<>0 do begin\nb[j]:=i mod 10;\ni:=i div 10;\ninc(j);\nend;\ndec(j);\ns:=0;\nfor j:=j downto 1 do\nif (b[j]=4) or (b[j]=7) then s:=(s+b[j])*10;\ns:=s div 10;\nmask:=s;\nend;\n\nbegin\nread(a,b);\ni:=a+1;\nwhile mask(i)<>b do\ninc(i);\nwrite(i);\nend."}, {"source_code": "var s1,s:string;\n a,b,x,i,c:longint; z:integer;\nbegin\nreadln(a,b);\nfor c:=a+1 to 1000000\ndo begin x:=c; s1:='';\nstr(x,s);\nfor i:=1 to length(s) do if (s[i]='4') or (s[i]='7') then s1:=s1+s[i];\nval(s1,x,z); if x=b then break; end;\nwriteln(c);\nend."}, {"source_code": "var bb,s,f:string;\n i,a,b:longint;\nprocedure mask(v:longint);\nbegin\n str(v,s);\n f:='';\n for i:=1 to length(s) do\n if (s[i]='7')or(s[i]='4') then f:=f+s[i];\n if f=bb then begin writeln(v);halt;end;\nend;\nbegin\n readln(a,b);\n str(b,bb);\n while a<=10000000 do\n begin\n inc(a);\n mask(a);\n end;\nend."}, {"source_code": "var s,mm,ss:ansistring;\nn,m,i,lik,a,b:longint;\ns1:string;\nbegin\nreadln(n,m);\nstr(m,mm);\nfor i:=length(mm) downto 1 do\nss:=ss+mm[i];\nfor i:=n+1 to 999999999 do\nbegin\n a:=i;\n s:='';\n while a<>0 do\n begin\n b:=a mod 10;\n str(b,s1);\n if (s1='4')or(s1='7') then s:=s+s1;\n a:=a div 10;\n\n end;\n if s=ss then begin writelN(i);halt;end;\n\n\n\nend;\n\n\n\n\n\nend.\n"}, {"source_code": "{lai troi cho conn dung}\nconst\n fi='input.inp';\nvar\n a,b : longint;\n{---------------------------------------------}\nprocedure mo;\nbegin\n //assign(input,fi);reset(input);\n readln(a,b);\n a :=a + 1;\nend;\n{---------------------------------------------}\nprocedure xuli;\nvar\n tmp : string;\n s1,s2 : string;\n i,j : longint;\nbegin\n repeat\n if a >= b then\n begin\n str(a,s1);\n str(b,s2);\n j := 1;\n {for i :=1 to length(s1) do\n begin\n if s1[i] = s2[j] then inc(j);\n if j = length(s2) + 1 then\n begin\n writeln(s1);\n exit;\n end;\n end; }\n tmp :='';\n for i := 1 to length(s1) do\n if (s1[i] = '4') or (s1[i] = '7') then tmp := tmp + s1[i];\n if tmp = s2 then\n begin\n writeln(s1);\n exit;\n end;\n a :=a + 1;\n end\n else a :=a + 1;\n until false;\nend;\n{---------------------------------------------}\nbegin\n mo;\n xuli;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}{$o-}{$r+}\n\nuses\n SysUtils;\n\nvar\n i, a, b : integer;\n s, ans : string;\n\nbegin\n read(a, b);\n while ans <> inttostr(b) do\n begin\n inc(a);\n ans := '';\n s := inttostr(a);\n for i := 1 to length(s) do\n if (s[i] = '4') or (s[i] = '7') then\n ans := ans + s[i];\n end;\n write(a);\nend.\n\n"}, {"source_code": "program b_prob;\nvar\n i,j,k,m,n:longint;\n a,b,masklength:longint;\n s,t,mask:string;\nprocedure init;\nbegin\n readln(a,b);\n str(b,mask);\nend;\nfunction check(x:longint):boolean;\nvar i:longint;\nbegin\n str(x,s);n:=length(s);t:='';m:=0;\n for i:=1 to n do\n if (s[i]='4')or(s[i]='7') then\n begin\n inc(m);t:=t+s[i];\n end;\n if m<>masklength\n then check:=false\n else if t<>mask\n then check:=false\n else check:=true;\n\nend;\nprocedure main;\nbegin\n masklength:=length(mask);\n i:=a+1;\n while not check(i) do\n inc(i);\n writeln(i);\nend;\nbegin\n \n init;\n main;\n\nend.\n"}, {"source_code": "var s,s1:string;\n c,i,j,f,a,b:longint;\nbegin \n readln(a,b);\n if a b do\n inc(c);\n writeln(c);\nend.\n "}, {"source_code": "Uses SysUtils;\nVar\n a,b,s,i:Integer;\n t,w:String;\nBegin\n Read(a,b);\n s:=a+1;\n While True Do Begin\n t:=inttostr(s);\n w:='';\n For i:=1 To length(t) Do\n If (t[i]='4') or (t[i]='7') Then w:=w+t[i];\n If w=inttostr(b) Then Break;\n s:=s+1;\n End;\n Write(s);\nEnd."}, {"source_code": "var\n c:integer;\n s1,s,ss:string;\n j:byte;\n i:longint;\n a,b,n,k:longint;\nbegin\n readln(a,b);\n str(b,s1);\n for i:=a+1 to 1000000 do\n begin\n s:='';\n ss:='';\n c:=0;\n str(i,s);\n for j:=1 to length(s) do\n if (s[j]='4') or (s[j]='7') then\n insert(s[j],ss,300);\n if ss=s1 then\n begin\n writeln(s);\n halt;\n end;\n end;\nend."}, {"source_code": "program CF_104_2_B;\n\n{$APPTYPE CONSOLE}\n{$R-,Q-}\n\nuses\n SysUtils;\n\nvar\n\ta, k, c, b, i: integer;\n\ta_s, b_s, n_s : string;\nbegin\n\treadln(a, b);\n\tc:=0;\n a:=a+1;\n N_s:='';\n\tb_s := IntToStr(b);\n \twhile c=0 do begin\n\t\ta_s := IntToStr(a);\n for i:=1 to length (a_s) do\n begin\n if (a_s[i]=('4')) or (a_s[i]=('7')) then n_s:=n_s+a_s[i];\n end;\n if n_s=b_s then\n\t\t\tbegin\n inc(c);\n write(a_s);\n\t\t\tend\n\t\telse begin inc(a); n_s:=(''); end\n\tend;\n\treadln;\nend.\n"}, {"source_code": "program B104;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, i, min: integer;\n\nfunction mask(s: string): integer;\nvar\n m: string;\nbegin\n m := '';\n\n while length(s) > 0 do begin\n if s[1] = '4' then\n m := m + '4';\n if s[1] = '7' then\n m := m + '7';\n delete(s, 1, 1);\n end;\n\n if m = '' then\n m := '0';\n mask := strtoint(m);\nend;\n\nbegin\n read(a, b);\n min := maxint;\n\n if b > a then begin\n write(b);\n halt(0);\n end;\n\n for i := a + 1 to 999999 do\n if (mask(inttostr(i)) = b) then begin\n write(i);\n halt(0);\n end;\n\n write(min);\nend.\n"}, {"source_code": "Program Problem_B;\nuses SysUtils;\nvar k,i,n,j,z : longint;\n f : boolean;\n s : string;\nbegin\n readln(k,n);\n i := k;\n while not(f) do\n begin\n inc(i);\n z := 0;\n s := IntToStr(i);\n for j := 1 to length(s) do\n begin\n if (s[j] = '7') or (s[j] = '4') then\n z := z*10 + StrToInt(s[j]);\n end;\n if n = z then f := true;\n end;\n writeln(i);\nend."}, {"source_code": "var\na,b:integer;\n\nfunction pp(a1:integer):integer;\nvar m,mask,st:integer;\nbegin\nmask:=0; st:=1;\nwhile a1<>0 do\nbegin m:= a1 mod 10;\nif (m=7) or (m=4) then begin mask:=mask+m*st; st:=st*10; end;\na1:=a1 div 10;\nend;\npp:=mask;\nend;\nbegin\nreadln(a,b);\nrepeat\ninc(a);\nuntil pp(a)=b;\nwriteln(a);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}\nuses sysutils;\nvar a,b,c:LongInt;\n s:string;\nfunction mask(x:LongInt):string;\nvar s:string;\n i:Integer;\nbegin\n s:=inttostr(x);\n result:='';\n for i:=1 to Length(s) do\n begin\n if s[i] in ['4','7']\n then result:=result+s[i];\n end;\nend;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(a,b);\n s:=inttostr(b);\n c:=a+1;\n while mask(c)<>s do\n Inc(c);\n Writeln(c);\nend.\n"}, {"source_code": "var\n\tx, code, a, b, c, i: longint;\n\ts: ansistring;\n\nbegin\n //\treset(input, 'a.in');\n//\trewrite(output, 'a.out');\n\treadln(a, b);\n\tfor i := a + 1 to 10000000 do begin\n\t\ts := ''; c := i;\n\t\twhile (c > 0) do begin\n\t\t\tif (c mod 10 = 4) or (c mod 10 = 7) then\n s := chr(c mod 10 + 48) + s;\n\t\t\tc := c div 10;\n\t\tend;\n\t\tval(s, x, code);\n if x = b then begin\n \twrite(i);\n \thalt;\n \tend; \n\tend; \nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m: int64;\n i: integer;\n s, ss: string;\n\nfunction f(k: string): boolean;\nvar\n i: integer;\n sss: string;\nbegin\n result := false;\n for i := 1 to length(k) do begin\n if (k[i] = '4') then\n sss := sss + '4';\n if (k[i] = '7') then\n sss := sss + '7';\n end;\n if (sss = ss) then\n result := true;\nend;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n readln(n, m);\n\n if (n < m) then begin\n writeln(m);\n halt(0);\n end;\n\n s := IntToStr(m);\n for i := 1 to length(s) do begin\n if (s[i] = '4') then\n ss := ss + '4';\n if (s[i] = '7') then\n ss := ss + '7';\n end;\n \n for i := n + 1 to 20000000 do begin\n if (f(IntToStr(i))) then begin\n writeln(i);\n halt(0);\n end;\n end;\n \n\nend.\n"}], "negative_code": [{"source_code": "var a,b,i,j:longint;\n a1,b1:string;\nbegin\n readln(a,b);\n if a'4') and (a1[j]<>'7') then delete(a1,j,1) else j:=j+1;\n if pos(b1,a1)<>0 then break;end;\n writeln(i);\nend.\n \n "}, {"source_code": "var n,a,b,i,f,k,x,p:longint;s1,s2,s:string;\nbegin\nreadln(a,b);\nstr(a,s1);\nstr(b,s2);\nif (ab))\nthen begin\n writeln(b);\n exit;\n end;\nwhile k=0 do\nbegin\ndelete(s,1,length(s));\na:=a+1;\nx:=a;\nwhile x>0 do\nbegin\np:=x mod 10;\nif (p=4)\nthen s:='4'+s\nelse if p=7\n then s:='7'+s;\nx:=x div 10 ;\nend;\nif s2=s\nthen begin\n k:=1;\n writeln(a);\n exit;\n end;\nend;\nend.\n\n"}, {"source_code": "var s,s1:string;\n n,i,k,k1,k2,k4,k7,min:longint;\nbegin\n readln(s,s1);\n n:=length(s);\n for i:=1 to n do\n begin\n if (s[i]='7')and(s1[i]='4') then k7:=k7+1;\n if (s[i]='4')and(s1[i]='7') then k4:=k4+1;\n end;\n if k7<=k4 then min:=k7\n else min:=k4;\n k:=min;\n k1:=k7-k;\n k2:=k4-k;\n k:=k+k1+k2;\n writeln(k+1);\nend. \n \n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, m: int64;\n hh, ss, i: integer;\n s: string;\n\nfunction f(k: string): boolean;\nvar\n he, se, i: integer;\nbegin\n result := false;\n he := 0;\n se := 0;\n for i := 1 to length(k) do begin\n if (k[i] = '4') then\n inc(he);\n if (k[i] = '7') then\n inc(se);\n end;\n if (he >= hh) and (se >= ss) then\n result := true;\nend;\n\nbegin\n {reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n readln(n, m);\n\n if (n < m) then begin\n writeln(m);\n halt(0);\n end;\n\n ss := 0;\n hh := 0;\n s := IntToStr(m);\n for i := 1 to length(s) do begin\n if (s[i] = '4') then\n inc(hh);\n if (s[i] = '7') then\n inc(ss);\n end;\n \n for i := n + 1 to 20000000 do begin\n if (f(IntToStr(i))) then begin\n writeln(i);\n halt(0);\n end;\n end;\n \n\nend.\n"}, {"source_code": "var\na,b,c,d,k:longint;\nbegin\nread(a,b);\nif a=b then\nbegin\nwrite(a);\nhalt;\nend;\nc:=a; if c<>b then\nwhile d<>b do\nbegin\na:=a+1;\nc:=a;\nd:=0;\nk:=1;\nwhile c>0 do\nbegin\nif (c MOD 10 = 4) or (C MOD 10 = 7)\nthen begin\nd:=(c Mod 10)*k +d;\nk:=k*10;\nend;\nc:=c DIV 10\nend;\nend;\nwrite(a);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q+,R+,S-,T-,U-,V+,W-,X+,Y+,Z1}\nuses sysutils;\nvar a,b,c,x,i,t:LongInt;\nfunction MySort(a:LongInt;var b:longint):boolean;\nvar c:Char;\n i:Integer;\n s:string;\nbegin\n s:=IntToStr(a);\n result:=False;\n for i:=1 to Length(s)-1 do\n begin\n if (s[i]='0')and(s[i+1]<>'0')\n then begin\n c:=s[i];\n s[i]:=s[i+1];\n s[i+1]:=c;\n result:=True;\n b:=StrToInt(s);\n exit;\n end;\n end;\n b:=StrToInt(s);\nend;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(a,b);\n c:=b;\n x:=1;\n for i:=1 to Length(inttostr(b)) do\n x:=x*10;\n if b>a\n then begin\n writeln(b);\n halt(0);\n end;\n while a>=c+x do\n begin\n t:=c+x;\n while (MySort(t,t))and(a>=t) do ;\n if a>=t\n then x:=x*10\n else begin\n writeln(c+x);\n Halt(0);\n end;\n end;\n writeln(c+x);\nend.\n"}, {"source_code": "program luckymask;\n\n{$APPTYPE CONSOLE}\nvar i,a,b:longint; sa,sb:string;\nfunction cmask(n:longint):boolean;\nvar j:integer; z,m:string;\nbegin\n str(n,z);\n m:='';\n result:=false;\n for j:=1 to length(z) do\n if (z[j]='4') or (z[j]='7') then m:=m+z[j];\n result:=m=sb;\nend;\nbegin\n readln(a,b);\n str(a,sa);\n str(b,sb);\n (*if length(sb)>=length(sa) then\n begin\n writeln(sb);\n exit;\n end;*)\n for i:=a to 10000000 do\n begin\n if cmask(i) then\n begin\n writeln(i);\n //readln;\n exit;\n end;\n end;\nend.\n"}, {"source_code": "var\n a,b:longint;\nbegin\nreadln(a,b);\nif b>a then write(b) else write('1',b);\nend."}, {"source_code": "const\n finp='';\n fout='';\nvar a,b,KQ:string;\n x,y:longint;\n f,g:text;\nfunction sosanh(s1,s2:string):boolean;\nvar i:longint;\nbegin\n if length(s1)>length(s2) then exit(true);\n if length(s1)ord(s2[i]) then exit(true);\n if ord(s1[i])=ss[i] then begin\n s[j]:=ss[i];\n inc(i);\n end;\nend;\nfor j:=1 to length(s)-length(ss) do write(s[j]);\nif i<=length(ss) then\nfor j:=i to length(ss) do write(ss[j]);\nend;\nend.\n"}, {"source_code": "var\n i,j,o,n,m,a,b,x,t,y,x1,y1:longint;\n s:string;\n\n function f (x:longint):boolean;\n var s1:string;\n begin\n s1:='';\n while x>0 do\n begin\n if x mod 10 = 4 then s1:=s1+'0' else\n if x mod 10 =7 then s1:=s1+'1';\n x:=x div 10;\n end;\n if s1=s then\n begin\n writeln(a);\n halt;\n end;\n end;\nbegin\n readln(a,b);\n if a<=b then\n begin\n writeln(b);\n halt;\n end;\n while b>0 do\n begin\n if b mod 10 = 4 then s:=s+'0' else s:=s+'1';\n b:=b div 10;\n end;\n\n while true do\n begin\n inc(a);\n f(a);\n end;\nend.\n"}, {"source_code": "var\na,b,c:longint;\nbegin\nread(a,b);\nif b>a then write(b) else write(1,b); end."}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D-,E+,F+,G-,I-,L-,N+,R-,Q-,S-,V+,X+}\n\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n\nvar\n n, k, i, c, res, a, b, w: integer;\n d: int64;\n ok: boolean;\n\nprocedure panic(x: integer);\nbegin\n write(x);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(a, b);\n n := 0;\n c := b;\n While c > 0 do\n begin\n n := n + 1;\n c := c div 10;\n end;\n k := -1;\n While True do\n begin\n inc(k);\n w := k;\n ok := true;\n While w > 0 do\n begin\n if (w mod 10 = 4) or (w mod 10 = 7) then\n ok := false;\n w := w div 10;\n end;\n if not ok then continue;\n d := trunc(power(10, n)) * k + b;\n if trunc(power(10, n)) * k + b > a then\n begin\n write(d);\n exit;\n end;\n end;\n\nend.\n"}, {"source_code": "var a,b,x:longint;\n s,t:string;\nbegin\n readln(a,b);\n str(b,s);\n if a<=b then begin writeln(b);halt(0)end;\n while true do\n begin\n t:='';\n x:=a;\n while a<>0 do\n begin\n if a mod 10=4 then t:='4'+t;\n if a mod 10=7 then t:='7'+t;\n a:=a div 10;\n end;\n a:=x;\n if t=s then begin writeln(a);halt(0);end;\n inc(a);\n end;\nend."}, {"source_code": "var\n n,m,i:longint;\nfunction mask(i:longint):longint;\n var\n s1,s2:string;\n j,t:longint;\n begin\n s1:='';s2:='';\n str(i,s1);\n for j:=1 to length(s1) do\n if (s1[j]='4') or (s1[j]='7')\n then s2:=s2+s1[j];\n val(s2,t);mask:=t;\n end;\nbegin\n readln(n,m);\n i:=n-1;\n repeat\n inc(i);\n until mask(i)=m;\n writeln(i);\nend.\n"}, {"source_code": "var\na,b:integer;\n\nfunction pp(a1:integer):integer;\nvar m,mask,st:integer;\nbegin\nmask:=0; st:=1;\nwhile a1<>0 do\nbegin m:= a1 mod 10;\nif (m=7) or (m=4) then begin mask:=mask+m*st; st:=st*10; end;\na1:=a1 div 10;\nend;\npp:=mask;\nend;\nbegin\nread(a,b);\nwriteln;\nwhile pp(a)<>b do inc(a);\nwriteln(a);\nend."}, {"source_code": "var\na,b,i,j:longint;\ns,ss:string;\nbegin\nreadln(a,b);\nstr(a,s);\nstr(b,ss);\nif length(s)<=length(ss) then writeln(ss)\nelse begin\ni:=1;\nfor j:=1 to length(s) do begin\n if s[j]>=ss[i] then begin\n s[j]:=ss[i];\n inc(i);\n end;\nend;\nfor j:=1 to length(s)-length(ss) do write(s[j]);\nfor j:=i to length(ss)+1 do write(ss[j]);\nend;\nend.\n"}, {"source_code": "var\n n,m,i,j,x,code\t:\tlongint;\n s,t\t\t\t:\tansistring;\nbegin\n// reset(input,'a.in'); rewrite(output,'a.out');\n read(n,m);\n for i:=n to 800000 do begin\n \tstr(i,s);\n \tt:='';\n \tfor j:=1 to length(s) do\n \t\tif s[j] in ['4','7'] then t:=t + s[j];\n \tval(t,x,code);\n \tif x = m then begin\n \t\twrite(i);\n \t\thalt;\n \tend;\n end;\nend."}, {"source_code": "var a,b,n:longint;\n st1,st2,y,stroka:string;\n i,x,x1,x2,q,kluch,k,min:longint;\n code:integer;\nbegin\n readln(a,b);\n str(a,st1);\n str(b,st2);\n min:=1000000;\n if (length(st1)>length(st2)) or (a>=b)\n then\n begin\n if (a>=b) and (length(st1)=length(st2))\n then\n begin\n n:=length(st1);\n st1:='1';\n for i:=1 to n do\n st1:=st1+'0';\n val(st1,a,code);\n end;\n while kluch=0 do\n begin\n for i:=length(st1)-length(st2)+1 downto 1 do\n begin\n str(a,st1);\n k:=0;\n while k=0 do\n begin\n val(st1[i],x1,code);\n val(st2[1],x2,code);\n if x2>=x1\n then\n begin\n q:=0;\n while (x2=x1) and (i+q+1<=length(st1)) do\n begin\n inc(q);\n val(st1[i+q],x1,code);\n val(st2[1+q],x2,code);\n end;\n if x2>=x1\n then\n begin\n q:=0;\n while i+q<=length(st1) do\n begin\n if q<=length(st2)-1\n then st1[i+q]:=st2[1+q]\n else st1[i+q]:='0';\n inc(q);\n end;\n str(a,stroka);\n if stroka<>st1\n then\n begin\n val(st1,x,code);\n if xb do\n begin\n inc(x);\n str(x,s);\n for i:=length(s) downto 1 do if (s[i]<>'4') and (s[i]<>'7') then delete(s,i,1);\n val(s,k,p);\n end;\n writeln(x);\nend.\n\n\n"}, {"source_code": "var aa,bb,s,t:string;\na,b,c,d,e,f,g,i,j:longint;\nz:array[0..9] of longint;\nzz:array[0..9] of longint;\nbegin\n readln(a,b);\n str(b,bb);\n for i:=1 to length(bb) do\n begin\n inc(zz[ord(bb[i])-48]);\n end;\n for i:=a to 777777 do\n begin\n str(i,aa);\n if i>a then\n begin\n for j:=1 to length(aa) do\n begin\n inc(z[ord(aa[j])-48]);\n end;\n if (z[4]>=zz[4]) and (z[7]>=zz[7]) then\n begin\n writeln(i);\n halt;\n end;\n fillchar(z,sizeof(z),0);\n end;\n end;\nend.\n\n\n"}, {"source_code": "var a,b,n:longint;\n st1,st2:string;\n i,x,x1,x2,q:longint;\n code:integer;\nbegin\n readln(a,b);\n str(a,st1);\n str(b,st2);\n if (length(st1)>length(st2)) or (a>=b)\n then\n begin\n if (a>=b) and (length(st1)=length(st2))\n then\n begin\n n:=length(st1);\n st1:='1';\n for i:=1 to n do\n st1:=st1+'0';\n end;\n for i:=length(st1)-length(st2)+1 downto 1 do\n begin\n val(st1[i],x1,code);\n val(st2[1],x2,code);\n if x2>=x1\n then\n begin\n q:=0;\n while (x2=x1) and (i+q+1<=length(st1)) do\n begin\n inc(q);\n val(st1[i+q],x1,code);\n val(st2[1+q],x2,code);\n end;\n if x2>x1\n then\n begin\n q:=0;\n while i+q<=length(st1) do\n begin\n st1[i+q]:=st2[1+q];\n inc(q);\n end;\n writeln(st1);\n break;\n end;\n end;\n end;\n end\n else writeln(b);\nend."}, {"source_code": "var\n c:integer;\n s,ss:string;\n x:int64;\n a,b,n,i,j,k:longint;\nbegin\n readln(a,b);\n for i:=a+1 to 10000 do\n begin\n s:='';\n ss:='';\n c:=0;\n x:=0;\n str(i,s);\n for j:=1 to length(s) do if (s[j]='4') or (s[j]='7') then insert(s[j],ss,300);\n val(ss,x,c);\n if x=b then\n begin\n writeln(s);\n halt;\n end;\n end;\nend."}, {"source_code": "var a,b:longint;\n\nfunction f(a:longint):longint;\nvar k,aa,s:longint;\nbegin\nk:=0;\naa:=a;\nwhile aa<>0 do begin\naa:=aa div 10;\ninc(k);\nend;\ns:=round(exp(ln(10)*k));\nf:=a+s;\nend;\n\nbegin\nread(a,b);\n\nwhile b<=a do\nb:=f(b);\nwrite(b);\nend."}, {"source_code": "var a,b,x,c,p:int64;\n i,m:longint;\nbegin\n readln(a,b);\n for i:=a+1 to 1000010 do\n begin\n x:=i;\n p:=1;\n c:=0;\n while x<>0 do\n begin\n m:=x mod 10;\n if (m=7) or (m=4) then c:=c+p*m;\n x:=x div 10;\n p:=p*10;\n end;\n if c=b then break;\n end;\n writeln(i);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,a,b:integer;\n\nfunction mask(S:string):string;\nvar x:string;\n i:integer;\nbegin\nx:='';\nfor i:=1 to length(s) do\n if (s[i]='4') or (s[i]='7') then x:=x+s[i];\nmask:=x;\nend;\n\nbegin\nreadln(a,b);\nfor i:=a to 1000000 do\n if mask(inttostr(i))=inttostr(b) then begin write(i); readln; halt; end;\nend."}, {"source_code": "var aa,bb,s,t:string;\na,b,c,d,e,f,g,i,j:longint;\nz:array[0..9] of longint;\nzz:array[0..9] of longint;\nbegin\n readln(a,b);\n str(b,bb);\n for i:=1 to length(bb) do\n begin\n inc(zz[ord(bb[i])-48]);\n end;\n i:=a;\n while false do\n begin\n inc(i);\n str(i,aa);\n if i>a then\n begin\n for j:=1 to length(aa) do\n begin\n inc(z[ord(aa[j])-48]);\n end;\n if (z[4]>=zz[4]) and (z[7]>=zz[7]) then\n begin\n writeln(i);\n halt;\n end;\n fillchar(z,sizeof(z),0);\n end;\n end;\nend.\n\n\n"}, {"source_code": "var\na,b,c:longint;\nbegin\nread(a,b);\nif b>a then write(b) else write(1,b); end."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,b,c:integer;\n i:integer;\n x:char;\n s1:string;\n found:boolean;\nfunction getmask(a:integer):string;\nvar old,mask:string;\n j,k:integer;\nbegin\n old:=inttostr(a);\n for k:=1 to length(old) do\n if (old[k]='7') or (old[k]='4') then begin\n inc(j);\n mask:=mask+old[k];\n end;\n getmask:=mask;\nend;\nbegin\n readln(a,b);\n if alength(ss) then begin Writeln(s); halt; end;\nif length(s)s[i] then exit\n else\n if ss[i]0 do begin ss:=char(a mod 10+48)+ss; a:=a div 10; end;\n\ns:=''; While b>0 do begin s:=char(b mod 10+48)+s; b:=b div 10; end;\n\nWhile length(ss)-length(s)>1 do s:='0'+s;\n\ns:='0'+s; for i:=1 to 9 do if (i<>4)and(i<>7) then begin delete(s,1,1);s:=char(i+48)+s; com; end;\n\ndelete(s,1,1); Writeln('10',s);\n\nend;\n\nEnd.\n"}, {"source_code": "var a,b,i,j:longint;\n a1,b1:string;\nbegin\n readln(a,b);\n if a'4') and (a1[j]<>'7') then delete(a1,j,1) else j:=j+1;\n if b1=a1 then break;end;\n writeln(i);\nend.\n \n "}, {"source_code": "var\n c:integer;\n s,ss:string;\n x:int64;\n a,b,n,i,j,k:longint;\nbegin\n readln(a,b);\n for i:=a+1 to 10000 do\n begin\n s:='';\n ss:='';\n c:=0;\n x:=0;\n str(i,s);\n for j:=1 to length(s) do if (s[j]='4') or (s[j]='7') then insert(s[j],ss,300);\n val(ss,x,c);\n if x=b then\n begin\n writeln(s);\n halt;\n end;\n end;\nend."}, {"source_code": "var\na,b,c,i,k:longint;\ns,st:string;\nprocedure check;\nvar stt:string;\nbegin\nstt:='';\nstr(a,s);\nfor i:=1 to length(s) do\nif (s[i]='4')or(s[i]='7') then stt:=stt+s[i];\nif stt=st then begin\nif k=a then exit;\nwriteln(a);\nhalt\nend;\nend;\n\n\nbegin\nreadln(a,b);k:=a;\nif a4)and(a mod 10<>7) do inc(a);\nwhile true do\n begin\n check;\n\tinc(a);\n\tend;\nend.\n\t"}, {"source_code": "var\n c:integer;\n s,ss:string;\n x,a,b,n,i,j,k:longint;\nbegin\n readln(a,b);\n for i:=a+1 to 10000 do\n begin\n s:='';\n ss:='';\n c:=0;\n x:=0;\n str(i,s);\n for j:=1 to length(s) do if (s[j]='4') or (s[j]='7') then insert(s[j],ss,300);\n val(ss,x,c);\n if x=b then\n begin\n writeln(s);\n halt;\n end;\n end;\nend."}, {"source_code": "var\na,b,c,i:longint;\ns,st:string;\nprocedure check;\nvar stt:string;\nbegin\nstt:='';\nstr(a,s);\nfor i:=1 to length(s) do\nif (s[i]='4')or(s[i]='7') then stt:=stt+s[i];\nif stt=st then begin\nwriteln(a);\nhalt\nend;\nend;\n\n\nbegin\nreadln(a,b);\nif a4)and(a mod 10<>7) do inc(a);\nwhile true do\n begin\n check;\n\tif a mod 10=4 then inc(a,3)\n\telse inc(a,7);\n\tend;\nend.\n\t"}, {"source_code": "const fin='';\nvar f:text;\n a,b:longint;\nfunction kt(a:longint):boolean;\nvar i,k,d,j:integer;\n s1:string;\nbegin\n str(a,s1); k:=1; d:=0;\n for i:=1 to length(s1) do\n if (s1[i]<>'4') and (s1[i]<>'7') then delete(s1,i,1);\n val(s1,k,j);\n kt:=k=b;\nend;\nbegin\n assign(f,fin); reset(f);\n read(f,a,b);\n repeat\n inc(a);\n until kt(a);\n write(a);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n b,s:string;\n i,a:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n readln(a);\n readln(b);\n close(input);\nend;\n\nfunction kt(s:string):boolean;\nbegin\n for i:=1 to length(b) do\n begin\n if length(s)=0 then exit(false);\n if pos(b[i],s)=0 then exit(false);\n delete(s,1,pos(b[i],s));\n end;\n kt:=true;\nend;\n\nprocedure xuly;\nbegin\n str(a,s);\n while kt(s)=false do\n begin\n inc(a);\n str(a,s);\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(a);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend.\n"}, {"source_code": "var a,b,n:longint;\n st1,st2,y,stroka:string;\n i,x,x1,x2,q,kluch,k:longint;\n code:integer;\nbegin\n readln(a,b);\n str(a,st1);\n str(b,st2);\n if (length(st1)>length(st2)) or (a>=b)\n then\n begin\n if (a>=b) and (length(st1)=length(st2))\n then\n begin\n n:=length(st1);\n st1:='1';\n for i:=1 to n do\n st1:=st1+'0';\n end;\n while kluch=0 do\n begin\n for i:=length(st1)-length(st2)+1 downto 1 do\n begin\n k:=0;\n while k=0 do\n begin\n val(st1[i],x1,code);\n val(st2[1],x2,code);\n if x2>=x1\n then\n begin\n q:=0;\n while (x2=x1) and (i+q+1<=length(st1)) do\n begin\n inc(q);\n val(st1[i+q],x1,code);\n val(st2[1+q],x2,code);\n end;\n if x2>=x1\n then\n begin\n q:=0;\n while i+q<=length(st1) do\n begin\n if q<=length(st2)-1\n then st1[i+q]:=st2[1+q]\n else st1[i+q]:='0';\n inc(q);\n end;\n str(a,stroka);\n if stroka<>st1\n then\n begin\n writeln(st1);\n kluch:=1;\n break;\n end;\n end\n end;\n if kluch=0\n then\n begin\n val(st1[i-1],x,code);\n if (x=9)\n then\n begin\n k:=1;\n break;\n end\n else\n begin\n inc(x);\n str(x,y);\n val(st2[1],x1,code);\n insert(y,st1,i-1);\n delete(st1,i,1);\n for q:=i to length(st1) do\n st1[q]:='0';\n end;\n end;\n end;\n if x=9\n then break;\n if kluch=1\n then break;\n end;\n if kluch=1\n then break;\n if kluch=0\n then\n begin\n n:=length(st1);\n st1:='1';\n for q:=1 to n do\n st1:=st1+'0';\n end;\n end;\n end\n else writeln(b);\nend.\n"}, {"source_code": "var\n i,j,n,m,k,kol,res:longint;\n ans,sa,sb,s:string;\n f1,f2:integer;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(n,m);\n str(m,sb);\n while true do\n begin\n inc(n);\n str(n,sa);\n for i:=1 to length(sa) do if (sa[i]<>'4')and(sa[i]<>'7') then delete(sa,i,1);\n if sa=sb then break;\n end;\n writeln(n);\nend.\n"}, {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar str:string;\n n,i,sum:integer;\n bool:boolean;\n a,b,c:integer;\n function mask(a:integer):string;\n var s:string;\n begin\n s:='';\n while a>0 do begin\n if a mod 10 in [4,7] then s:=chr(a mod 10 + 48)+s;\n a:=a div 10;\n end;\n mask:=s;\n end;\n var st:string;\nbegin\nread(a);\nreadln(b);\nst:=inttostr(b);\nstr:=inttostr(a);\nif length(str)a then writeln(b) else writeln(1,b)\nelse begin\n for i:=1 to length(str)-length(st)-1 do st:='0'+st;\n st:='1'+st;\n writeln(st);\n halt;\nend;\n\nend."}, {"source_code": "var\n a,b:longint;\nbegin\nreadln(a,b);\nif b>a then write(b) else write('1',b);\nend."}, {"source_code": "var a,b,c,t,x: longint;\nbegin\n read(a,b);\n if aa);\n writeln(c)\n\nend."}, {"source_code": "var a,b,i,j:longint;\n a1,b1:string;\nbegin\n readln(a,b);\n if a'4') and (a1[j]<>'7') then delete(a1,j,1) else j:=j+1;\n if pos(b1,a1)<>0 then break;end;\n writeln(i);\nend.\n \n "}, {"source_code": "var a,b,c,i,k,aa:longint;\n x:array[1..10]of integer;\n\nbegin\n read(a,b);\n if a<=b then write(b) else begin\n while true do\n begin\n k:=0;\n c:=0;\n aa:=a;\n while a>0 do\n begin\n if a mod 10= 4 then begin inc(k);x[k]:=4; end;\n if a mod 10= 7 then begin inc(k);x[k]:=7; end;\n a:=a div 10;\n end;\n for i:=k downto 1 do\n c:=c*10+x[i];\n if c=b then begin writeln(aa);break; end;\n a:=aa;\n inc(a);\n\n end;\n end;\nend.\n"}, {"source_code": "program luckymask;\n\n{$APPTYPE CONSOLE}\nvar i,a,b:longint; sa,sb:string;\nfunction cmask(n:longint):boolean;\nvar j:integer; z,m:string;\nbegin\n str(n,z);\n m:='';\n result:=false;\n for j:=1 to length(z) do\n if (z[j]='4') or (z[j]='7') then m:=m+z[j];\n result:=m=sb;\nend;\nbegin\n readln(a,b);\n str(a,sa);\n str(b,sb);\n (*if length(sb)>=length(sa) then\n begin\n writeln(sb);\n exit;\n end;*)\n for i:=a to 1000000 do\n begin\n if cmask(i) then\n begin\n writeln(i);\n //readln;\n exit;\n end;\n end;\nend.\n"}, {"source_code": "uses sysutils;\nvar\n A,B,C:longint;\nfunction getMask(a:longint):longint;\nvar\n s:string;\n i:byte;\nbegin\n s:=IntToStr(a);\n for i := 1 to length(s) do\n if not (s[i] in ['7','4'])\n then\n delete(s,i,1);\n if s = ''\n then\n s:='0'; \n getMask:=StrToInt(s);\nend;\nbegin\n \n read(A,B);\n for C:=A+1 to 1000000 do\n if getMask(C)=B\n then\n break;\n \n writeln(C);\nend.\n"}, {"source_code": "var\ni,a,b:longint;\naa,bb,w:string;\n begin\n readln(a,b);\n a:=a+1;\n str(b,bb);\n while true do\n begin\n str(a,aa);\n w:='';\n for i:=1 to length(aa) do\n if aa[i] in ['4'..'7'] then w:=w+aa[i];\n\n if w=bb then break;\n a:=a+1;\n end;\n writeln(a);\n end."}, {"source_code": "Program zad2;\n\nVar\n q1, q2: longint;\n\nFunction mas (x: longint): longint;\n var\n sum, q, w: longint;\n begin\n sum:=0;\n q:=1000000;\n while x div q=0 do\n q:=q div 10;\n while q>0 do\n begin\n w:=x div q-(x div (q*10))*10;\n if (w=4) or (w=7)\n then sum:=sum*10+w;\n q:=q div 10;\n end;\n mas:=sum;\n end;\n\nBegin\n {assign, (input, 'input.txt');\n assign (output, 'output.txt');\n reset (input);\n rewrite (output);}\n readln (q1, q2);\n if q1q2 do\n inc (q1);\n writeln (q1);\nEnd."}, {"source_code": "var a,b,c,i,j,q,k,e:longint;\nbegin\nread(a,b);\nif a < b then begin write(b); exit; end;\nc:=a;\n\n\nif a > b then\nwhile i<>1 do begin\n\n inc(C);\n j:=c;\n k:=0;\n e:=1;\n while j<> 0 do\n begin\n q:=j mod 10;\n j:=j div 10;\n if (q = 7)or(q=4) then begin k:=k+q*e; e:=e*10; end;\n end;\n if k = b then begin writeln(C); exit; end;\n end;\n\n\n\n\n end.\n "}, {"source_code": "var a,b,c,t,x: longint;\nbegin\n read(a,b);\n if aa);\n writeln(c)\n\nend."}, {"source_code": "var s,s1:string;\n n,i,k,k1,k2,k4,k7,min:longint;\nbegin\n readln(s,s1);\n n:=length(s);\n for i:=1 to n do\n begin\n if (s[i]='7')and(s1[i]='4') then k7:=k7+1;\n if (s[i]='4')and(s1[i]='7') then k4:=k4+1;\n end;\n if k7<=k4 then min:=k7\n else min:=k4;\n k:=min;\n k1:=k7-k;\n k2:=k4-k;\n k:=k+k1+k2;\n writeln(k+1);\nend. \n \n"}, {"source_code": "var\na,b,c,d,k:longint;\nbegin\nread(a,b);\nif a=b then\nbegin\nwrite(a);\nhalt;\nend;\nc:=a; if c<>b then\nwhile d<>b do\nbegin\na:=a+1;\nc:=a;\nd:=0;\nk:=1;\nwhile c>0 do\nbegin\nif (c MOD 10 = 4) or (C MOD 10 = 7)\nthen begin\nd:=(c Mod 10)*k +d;\nk:=k*10;\nend;\nc:=c DIV 10\nend;\nend;\nwrite(a);\nend."}, {"source_code": "var n,st1,max,a,b,st:int64;\ni:longint;\ns:string;\nbegin {\n assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(a,b);\n if aa)and(i*st1+blength(st2))\n then\n begin\n for i:=length(st1)-length(st2)+1 downto 1 do\n begin\n val(st1[i],x1,code);\n val(st2[1],x2,code);\n if x2>=x1\n then\n begin\n q:=0;\n while (x2=x1) and (i+q+1<=length(st1)) do\n begin\n inc(q);\n val(st1[i+q],x1,code);\n val(st2[1+q],x2,code);\n end;\n if x2>x1\n then\n begin\n q:=0;\n while i+q<=length(st1) do\n begin\n st1[i+q]:=st2[1+q];\n inc(q);\n end;\n writeln(st1);\n break;\n end;\n end;\n end;\n end\n else writeln(b);\nend."}, {"source_code": "uses sysutils;\nvar\n A,B,C:longint;\nfunction getMask(a:longint):longint;\nvar\n s:string;\n i:byte;\nbegin\n s:=IntToStr(a);\n for i := 1 to length(s) do\n if not (s[i] in ['7','4'])\n then\n delete(s,i,1);\n if s = ''\n then\n s:='0'; \n getMask:=StrToInt(s);\nend;\nbegin\n \n read(A,B);\n for C:=A+1 to 1000000 do\n if getMask(C)=B\n then\n break;\n \n writeln(C);\nend.\n"}, {"source_code": "program z_B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n//type\n\nvar\n a,b:integer;\n i:integer;\n flag:boolean;\n t,s:string;\n\nbegin\n {assign(input,'input.txt');\n assign(output,'output.txt');}\n readln(a,b);\n if a<=b then write(b)\n else\n begin\n while not flag do\n begin\n inc(a);\n t:=inttostr(a);\n s:='';\n for i:=1 to length(t) do if (t[i]='4') or (t[i]='7') then s:=s+t[i];\n if s=inttostr(b) then flag:=true;\n end;\n write(a);\n end;\nend."}, {"source_code": "var\n i,j,n,m,k,kol,res:longint;\n ans,sa,sb,s:string;\n f1,f2:integer;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(n,m);\n str(m,sb);\n while true do\n begin\n str(n,sa);\n for i:=1 to length(sa) do if (sa[i]<>'4')and(sa[i]<>'7') then delete(sa,i,1);\n if sa=sb then break;\n inc(n);\n end;\n writeln(n);\nend.\n"}, {"source_code": "var\na,b,i,j:longint;\ns,ss:string;\nbegin\nreadln(a,b);\nstr(a,s);\nstr(b,ss);\nif length(s)<=length(ss) then writeln(ss)\nelse begin\ni:=1;\nfor j:=1 to length(s) do begin\n if s[j]>=ss[i] then begin\n s[j]:=ss[i];\n inc(i);\n end;\nend;\nfor j:=1 to length(s)-length(ss) do write(s[j]);\nfor j:=i to length(ss) do write(ss[j]);\nend;\nend.\n"}, {"source_code": "const\n finp='';\n fout='';\nvar a,b,KQ:string;\n x,y,i,x1:longint;\n f,g:text;\nbegin\n assign(f,finp); reset(f);\n assign(g,fout); rewrite(g);\n read(f,x,y);\n str(y,b);\n x1:=x;\n dec(x);\n repeat\n inc(x);\n str(x,a);\n for i:=1 to length(a) do\n if (a[i]<>'4') and (a[i]<>'7') then\n delete(a,i,1);\n until (a=b) and (x>x1);\n str(x,KQ);\n write(g,KQ);\n close(f); close(g);\nend.\n\n"}, {"source_code": "Program zad2;\n\nVar\n q1, q2: longint;\n\nFunction mas (x: longint): longint;\n var\n sum, q, w: longint;\n begin\n sum:=0;\n q:=1000000;\n while x div q=0 do\n q:=q div 10;\n while q>0 do\n begin\n w:=x div q-(x div (q*10))*10;\n if (w=4) or (w=7)\n then sum:=sum*10+w;\n q:=q div 10;\n end;\n mas:=sum;\n end;\n\nBegin\n {assign, (input, 'input.txt');\n assign (output, 'output.txt');\n reset (input);\n rewrite (output);}\n readln (q1, q2);\n if q1q2 do\n inc (q1);\n writeln (q1);\nEnd."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar i,a,b:integer;\n\nfunction mask(S:string):string;\nvar x:string;\n i:integer;\nbegin\nfor i:=1 to length(s) do\n if (s[i]='4') or (s[i]='7') then x:=x+s[i];\nmask:=x;\nend;\n\nbegin\nreadln(a,b);\nfor i:=a to 1000000 do\n if mask(inttostr(i))=inttostr(b) then begin write(i); readln; halt; end;\n\nend.\n"}, {"source_code": "\n\n{$APPTYPE CONSOLE}\n\nvar\na,b,k,d,ans,i,t : longint;\nbegin\n readln (a,b);\n if b>a then\n begin\n writeln (b);\n exit;\n end;\n\n k:=0;\n d:=b;\n while d<>0 do\n begin\n inc (k);\n d:=d div 10;\n end;\n\n d:=1;\n for i:=1 to k do d:=d*10;\n\n t:=a mod d;\n ans:=a div d;\n\n if ta then write(b)\n else begin\n while z0 do begin\n if a mod 10 in [4,7] then s:=chr(a mod 10 + 48)+s;\n a:=a div 10;\n end;\n mask:=s;\n end;\n var st:string;\nbegin\nread(a);\nreadln(b);\nst:=inttostr(b);\nstr:=inttostr(a);\nif length(str)a then writeln(b) else writeln(1,b)\nelse begin\n for i:=1 to length(str)-length(st)-1 do st:='0'+st;\n st:='1'+st;\n writeln(st);\n halt;\nend;\n\nend."}, {"source_code": "var\n a,b,a1,b1,g,g1,i:longint;\nbegin\nreadln(a,b);\na1:=a+1;\nwhile a1>0 do\nbegin\n g:=g+1;\n a1:=a1 div 10;\nend;\nb1:=b;\nwhile b1>0 do\nbegin\n g1:=g1+1;\n b1:=b1 div 10;\nend;\nfor i:=1 to g-g1 do\n write(1);\nwrite(b);\nend.\n"}, {"source_code": "const fin='';\nvar f:text;\n a,b:longint;\nfunction kt(a:longint):boolean;\nvar i,k,d,j:integer;\n s1:string;\nbegin\n str(a,s1); k:=1; d:=0;\n for i:=1 to length(s1) do\n if (s1[i]<>'4') and (s1[i]<>'7') then delete(s1,i,1);\n val(s1,k,j);\n kt:=k=b;\nend;\nbegin\n assign(f,fin); reset(f);\n read(f,a,b);\n repeat\n inc(a);\n until kt(a);\n write(a);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar tmp,b,i:integer;\n mask,a:string;\nbegin\n readln(tmp,b);\n a:=IntToStr(tmp);\n mask:='';\n for i:=1 to length(a) do\n if a[i] in ['4','7'] then\n mask:=mask+a[i];\n if mask='' then mask:='1';\n while (StrToInt(mask)<>b) do\n begin\n mask:='';\n a:=IntToStr(StrToInt(a)+1);\n for i:=1 to length(a) do\n if a[i] in ['4','7'] then\n mask:=mask+a[i];\n if mask='' then mask:='1';\n end;\n write(a);\nend.\n"}, {"source_code": "Var a,b,t,i,j,t1:LongInt;\n function rec(x,y:LongInt):LongInt;\n Var x1,y1,y2:LongInt;\n begin\n y2:=0;\n y1:=0;\n x1:=x;\n While x1>0 do\n begin\n if (x1 mod 10=4) or (x1 mod 10=7) then y1:=(y1*10)+x1 mod 10;\n x1:=x1 div 10;\n end;\n x1:=y;\n While x1>0 do\n begin\n y2:=y2*10+(x1 mod 10);\n x1:=x1 div 10;\n end;\n if y2=y1 then begin WriteLn(x); halt; end;\n end;\n begin\n ReadLn(a,b);\n if b>a then begin WriteLn(b); exit; end;\n t:=a;\n While t>0 do\n begin\n i:=i+1;\n t:=t div 10;\n end;\n t1:=0;\n t:=1;\n For j:=2 to i do\n t:=t*10;\n While 2<>0 do\n begin\n t1:=t1+t;\n if t1+b>a then begin rec(t1+b,b); end;\n end;\n end."}, {"source_code": "var a,b,c,n,m:int64;\n l:array[1..10]of longint;\n begin\n l[1]:=10;\n l[2]:=100;\n l[3]:=1000;\n l[4]:=10000;\n l[5]:=100000;\n l[6]:=1000000;\n readln(a,b);\n n:=a-b;\n if (n<0) then\n begin\n writeln(b);\n halt;\n end;\n n:=0;\n m:=b;\n while m>0 do\n begin\n m:=m div 10;\n n:=n+1;\n end;\n n:=l[n];\n a:=a-b;\n writeln((a div n)+1,b);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\nvar\n b,s:string;\n i,a:longint;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n readln(a);\n readln(b);\n close(input);\nend;\n\nfunction kt(s:string):boolean;\nbegin\n for i:=1 to length(b) do\n begin\n if length(s)=0 then exit(false);\n if pos(b[i],s)=0 then exit(false);\n delete(s,1,pos(b[i],s));\n end;\n kt:=true;\nend;\n\nprocedure xuly;\nbegin\n str(a,s);\n while kt(s)=false do\n begin\n inc(a);\n str(a,s);\n end;\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(a);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend.\n"}, {"source_code": "var\na,b:integer;\n\nfunction pp(a1:integer):integer;\nvar m,mask,st:integer;\nbegin\nmask:=0; st:=1;\nwhile a1<>0 do\nbegin m:= a1 mod 10;\nif (m=7) or (m=4) then begin mask:=mask+m*st; st:=st*10; end;\na1:=a1 div 10;\nend;\npp:=mask;\nend;\nbegin\nread(a,b);\nwriteln;\nwhile pp(a)<>b do inc(a);\nwriteln(a);\nend."}, {"source_code": "var s1,s,mm,ss:string;\nn,m,i,lik,a,b:longint;\nbegin\nreadln(n,m);\nstr(m,mm);\nfor i:=length(mm) downto 1 do\nss:=ss+mm[i];\nfor i:=n to 100000 do\nbegin\n a:=i;\n s:='';\n while a<>0 do\n begin\n b:=a mod 10;\n str(b,s1);\n if (s1='4')or(s1='7') then s:=s+s1;\n if s=ss then begin writelN(i);halt;end;\n a:=a div 10;\n\n end;\n\n\n\nend;\n\nwriteln(s);\n\n\n\nend.\n"}, {"source_code": "var a,b,c,t,x: longint;\nbegin\n read(a,b);\n if aa);\n writeln(c)\n\nend."}, {"source_code": "var\n s:ansistring;\n n,m,i,z,x,c,ss,d,r:longint;\n l:integer;\nbegin\n read(n,m);\n for i:=n to 2000000 do\n begin\n x:=i;\n s:='';\n while x<>0 do\n begin\n z:=x mod 10;\n if (z=4)or(z=7)then s:=chr(z+48)+s;\n x:=x div 10;\n end;\n val(s,d,l);\n if d=m then\n begin\n writeln(i);\n halt;\n end;\n end;\nend."}, {"source_code": "Var a,b,c:LongInt;\n\nFunction Luck (x:LongInt):LongInt;\nVar code,i:Integer;\ns:String;\nBegin\n Str (x,s);\n i:=1;\n While i<>Length (s)+1 do\n Begin\n If not (s[i] in ['4','7'])\n then Delete (s,i,1)\n else Inc (i);\n Writeln (s);\n End;\n If s=''\n then x:=0\n else Val (s,x,code);\n Luck:=x;\nEnd;\n\nBegin\n Readln (a,b);\n c:=a+1;\n While Luck(c)<>b do\n Inc (c);\n Writeln (c);\nEnd."}, {"source_code": "var aa,bb,s,t:string;\na,b,c,d,e,f,g,i,j:longint;\nz:array[0..9] of longint;\nzz:array[0..9] of longint;\nbegin\n readln(a,b);\n str(b,bb);\n for i:=1 to length(bb) do\n begin\n inc(zz[ord(bb[i])-48]);\n end;\n i:=a;\n while false do\n begin\n inc(i);\n str(i,aa);\n if i>a then\n begin\n for j:=1 to length(aa) do\n begin\n inc(z[ord(aa[j])-48]);\n end;\n if (z[4]>=zz[4]) and (z[7]>=zz[7]) then\n begin\n writeln(i);\n halt;\n end;\n fillchar(z,sizeof(z),0);\n end;\n end;\nend.\n\n\n"}, {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$A+,B-,D-,E+,F+,G-,I-,L-,N+,R-,Q-,S-,V+,X+}\n\n\nuses\n SysUtils,\n Math;\n\nconst\n inf = 1000000000000000000;\n\nvar\n n, k, i, c, res, a, b, w: integer;\n d: int64;\n ok: boolean;\n\nprocedure panic(x: integer);\nbegin\n write(x);\n halt(0);\nend;\n\nprocedure swap(var qx, qy: integer);\nvar\n qz: integer;\nbegin\n qz := qx;\n qx := qy;\n qy := qz;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n read(a, b);\n n := 0;\n c := b;\n While c > 0 do\n begin\n n := n + 1;\n c := c div 10;\n end;\n k := -1;\n While True do\n begin\n inc(k);\n w := k;\n ok := true;\n While w > 0 do\n begin\n if (w mod 10 = 4) or (w mod 10 = 7) then\n ok := false;\n w := w div 10;\n end;\n if not ok then continue;\n d := trunc(power(10, n)) * k + b;\n if trunc(power(10, n)) * k + b > a then\n begin\n write(d);\n exit;\n end;\n end;\n\nend.\n"}, {"source_code": "var n,i,a,b,x,k:longint;\n p:integer;\n s:string;\nbegin\n read(a,b);\n x:=a+1;\n k:=x;\n while k<>b do\n begin\n inc(x);\n str(x,s);\n for i:=length(s) downto 1 do if (s[i]<>'4') and (s[i]<>'7') then delete(s,i,1);\n val(s,k,p);\n end;\n writeln(x);\nend.\n\n\n"}, {"source_code": "program ConsoleOlympProj;\n\n{$APPTYPE CONSOLE}\n\nfunction GetMask(Number: Integer): Integer;\nvar\n Digit, k: Integer;\nbegin\n Result := 0;\n k := 1;\n while Number > 0 do\n begin\n Digit := Number mod 10;\n if Digit in [4, 7] then\n Result := k * Digit + Result;\n k := k * 10;\n Number := Number div 10;\n end;\nend;\n\nvar\n a, b: Integer;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\n Assign(Input, 'input.txt');\n Reset(Input);\n Assign(Output, 'output.txt');\n Rewrite(Output);\n{$ENDIF}\n\n ReadLn(a, b);\n\n if a < b then\n Write(b)\n else\n begin\n repeat\n Inc(a);\n until GetMask(a) = b;\n Write(a);\n end;\n\n{$IFNDEF ONLINE_JUDGE}\n Close(Input);\n Close(Output);\n{$ENDIF}\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nvar\n a,b,n,i: longint;\n mask: array[0..9] of integer;\n\n function check(x: longint): boolean;\n var\n m,y: longint;\n begin\n m:=0;\n while x>0 do\n begin\n y:=x mod 10;\n if y in [4,7] then\n begin\n inc(m);\n if y<>mask[m] then\n begin\n check:=false;\n exit;\n end;\n end;\n x:=x div 10;\n end;\n if m<>n then\n begin\n check:=false;\n exit;\n end;\n check:=true;\n end;\n \nbegin\n read(a,b);\n n:=0;\n while b>0 do\n begin\n n:=n+1;\n mask[n]:=b mod 10;\n b:=b div 10;\n end;\n for i:=a to 1000000 do\n if check(i) then\n begin\n write(i);\n break;\n end;\n// readln; readln;\nend.\n"}, {"source_code": "var a,b,i,j:longint;\n found:boolean;\nfunction mask(a:longint):longint;\nvar x,k,c:longint;\nbegin\n c:=a;\n x:=1;\n k:=0;\n while c>0 do begin\n if (c mod 10=4)or(c mod 10=7) then begin\n k:=k+(c mod 10)*x;\n x:=x*10;\n end;\n c:=c div 10;\n end;\n mask:=k;\nend;\nbegin\n readln(a,b);\n while mask(a)<>b do\n inc(a);\n writeln(a);\n readln;\nend."}, {"source_code": "uses sysutils;\nvar\n A,B,C:longint;\nfunction getMask(a:longint):longint;\nvar\n s:string;\n i:byte;\n res:longint;\nbegin\n s:=IntToStr(a);\n res:=0;\n for i := 1 to length(s) do\n if s[i] in ['7','4']\n then\n res:=res*10+ord(s[i])-48;\n \n getMask:=res; \nend;\nbegin\n \n read(A,B);\n if B' ' do\n begin\n t1:=t1+t[i];\n inc(i);\n end;\n\n while i<=n do\n begin\n t2:=t2+t[i];\n inc(i);\n end;\n delete(t2,1,1);\n n1:=length(t1);n2:=length(t2);\n\n razn:=abs(n2-n1);\n for i:=1 to razn do\n write(t1[i]);\n\n for i:=1 to n2 do\n write(t2[i]);\n\n// close(input);close(output);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "{$mode objfpc}\n{-$S-, Q-, R-, I-, O+}\n{$S+, Q+, R+, I+, O+}\nuses sysutils;\nvar\n a, b, c : longint;\n s1, s2, s3 : string;\nbegin\n readln(a, b);\n s1 := inttostr(a);\n s2 := inttostr(b);\n if b>a then\n c := b\n else\n begin\n if length(s1) = length(s2) then\n c := length(s1) * 10 + b\n else\n begin\n s3 := copy(s1, 1, length(s1) - length(s2)) + s2;\n c := strtoint(s3);\n end;\n end;\n write(c);\nend.\n\n"}, {"source_code": "var a,b,x,c,p,r:int64;\n i:longint;\nbegin\n readln(a,b);\n for i:=a+1 to 1000000 do\n begin\n x:=i;\n p:=1;\n c:=0;\n r:=0;\n while x<>0 do\n begin\n if (x mod 10 = 7) or (x mod 10=4) then c:=c+p*(x mod 10);\n r:=r+p*(x mod 10);\n x:=x div 10;\n p:=p*10;\n end;\n if c=b then break;\n end;\n writeln(r);\nend."}, {"source_code": "var a,b,c,i,k,aa:longint;\n x:array[1..10]of integer;\n\nbegin\n read(a,b);\n if a<=b then write(b) else begin\n while true do\n begin\n k:=0;\n c:=0;\n aa:=a;\n while a>0 do\n begin\n if a mod 10= 4 then begin inc(k);x[k]:=4; end;\n if a mod 10= 7 then begin inc(k);x[k]:=7; end;\n a:=a div 10;\n end;\n for i:=k downto 1 do\n c:=c*10+x[i];\n if c=b then begin writeln(aa);break; end;\n a:=aa;\n inc(a);\n\n end;\n end;\nend.\n"}, {"source_code": "var s1,s:string;\n a,b,x,i,c:longint; z:integer;\nbegin\nreadln(a,b);\nif a>77777 then exit;\nfor c:=a+1 to 100000 do begin x:=c; s1:='';\nstr(x,s);\nfor i:=1 to length(s) do if (s[i]='4') or (s[i]='7') then s1:=s1+s[i];\nval(s1,x,z); if x=b then break; end;\nwriteln(c);\nend."}, {"source_code": "var a,b,x:longint;\nfunction mask (a:longint):longint;\n var x,k:longint;\n begin \n while a>0 do\n begin\n if (a mod 10=4) or (a mod 10=7) then x:=(x*10)+(a mod 10);\n a:=a div 10;\n end;\n while x>0 do \n begin\n k:=(k*10)+(x mod 10);\n x:=x div 10;\n end;\n mask:=k;\n end;\nbegin\nreadln(a,b);\nx:=a;\nwhile mask(x)<>b do\n inc(x);\nwrite(x);\nend."}, {"source_code": "uses sysutils;\nvar\n A,B,C:longint;\nfunction getMask(a:longint):longint;\nvar\n s:string;\n i:byte;\n res:longint;\nbegin\n s:=IntToStr(a);\n res:=0;\n for i := 1 to length(s) do\n if s[i] in ['7','4']\n then\n res:=res*10+ord(s[i])-48;\n \n getMask:=res; \nend;\nbegin\n \n read(A,B);\n if B>A then C:=B else\n for C:=A+1 to 100000 do\n if getMask(C)=B\n then\n break;\n \n writeln(C);\nend. \n"}, {"source_code": "var \n a,b,i:longint;\n\nfunction numoff(x:longint):longint;\nvar \n i,ans:longint; \n tmp:string;\nbegin \n str(x,tmp); \n for i:=1 to length(tmp) do \n if (tmp[i]<>'4')and(tmp[i]<>'7') then delete(tmp,i,1); \n val(tmp,ans); \n exit(ans);\nend;\n\nbegin\n readln(a,b); \n for i:=a+1 to 1000000 do \n if numoff(i)=b then \n begin \n writeln(i); \n halt; \n end;\nend.\n//By THCDUSMAN"}, {"source_code": "var\na,b,i,j:longint;\ns,ss:string;\nbegin\nreadln(a,b);\nstr(a,s);\nstr(b,ss);\nif length(s)<=length(ss) then writeln(ss)\nelse begin\ni:=1;\nfor j:=1 to length(s) do begin\n if s[j]>=ss[i] then begin\n s[j]:=ss[i];\n inc(i);\n end;\n if i=length(ss)+1 then break;\nend;\nfor j:=1 to length(s)-length(ss) do write(s[j]);\nif i<=length(ss) then\nfor j:=i to length(ss) do write(ss[j]);\nend;\nend.\n"}, {"source_code": "var bb,a,b,i:longint;\n\nfunction f(a,i:longint):longint;\nvar k,aa,s:longint;\nbegin\nk:=0;\naa:=a;\nwhile aa<>0 do begin\naa:=aa div 10;\ninc(k);\nend;\nk:=k+i;\ns:=round(exp(ln(10)*k));\nf:=a+s;\nend;\n\nbegin\nread(a,b);\nbb:=b;\ni:=0;\nwhile bb<=a do begin\nbb:=f(b,i);\ninc(i);\nend;\nwrite(bb);\nend."}, {"source_code": "var \n a,b,i:longint;\n\nfunction numoff(x:longint):longint;\nvar \n i,ans:longint; \n tmp:string;\nbegin \n str(x,tmp); \n for i:=1 to length(tmp) do \n if (tmp[i]<>'4')and(tmp[i]<>'7') then delete(tmp,i,1); \n val(tmp,ans); \n exit(ans);\nend;\n\nbegin\n readln(a,b); \n for i:=a+1 to 1000000 do \n if numoff(i)=b then \n begin \n writeln(i); \n halt; \n end;\nend.\n//By THCDUSMAN"}, {"source_code": "var a,b,x:longint;\nfunction mask (a:longint):longint;\n var x,k:longint;\n begin \n while a>0 do\n begin\n if (a mod 10=4) or (a mod 10=7) then x:=(x*10)+(a mod 10);\n a:=a div 10;\n end;\n while x>0 do \n begin\n k:=(k*10)+(x mod 10);\n x:=x div 10;\n end;\n mask:=k;\n end;\nbegin\nreadln(a,b);\nx:=a;\nwhile mask(x)<>b do\n inc(x);\nwrite(x);\nend."}, {"source_code": "var n:longint;s,aa,bb:string;x,i,f,a,b:longint;\nbegin {\nassign (input,'input.txt');\nassign (output,'output.txt');\nreset (input);\nrewrite (output); }\nreadln (a,b);\nif alength(bb) do begin insert ('0',bb,2);end;\nif length(bb)>length(Aa) then begin write (bb);halt;end;\nfor i:=1 to length (aa)-n do\n if (aa[i]>bb[i]) then begin bb[i]:=aa[i];break end else if aa[i]bb[i] then begin f:=1;break;end else\n if aa[i]-1 then\n begin\n for i:=length(aa)-n downto 1 do\n if aa[i]<>'9' then begin bb[i]:=chr (ord(aa[i])+1);f:=-1;break;end;\n if f<>-1 then\n begin\n for i:=length(aa)-n downto 1 do bb[i]:='0';\n bb:='1'+bb;\n end;\n end;\n\nwrite (bb);\nend.\n"}, {"source_code": "var a,b,i,j:longint;\n a1,b1:string;\nbegin\n readln(a,b);\n if a'4') and (a1[j]<>'7') then delete(a1,j,1) else j:=j+1;\n if b1=a1 then break;end;\n writeln(i);\nend.\n \n "}, {"source_code": "var\na,b,c,i,k:longint;\ns,st:string;\nprocedure check;\nvar stt:string;\nbegin\nstt:='';\nstr(a,s);\nfor i:=1 to length(s) do\nif (s[i]='4')or(s[i]='7') then stt:=stt+s[i];\nif stt=st then begin\nif k=a then exit;\nwriteln(a);\nhalt\nend;\nend;\n\n\nbegin\nreadln(a,b);k:=a;\nif a4)and(a mod 10<>7) do inc(a);\nwhile true do\n begin\n check;\n\tif a mod 10=4 then inc(a,3)\n\telse inc(a,7);\n\tend;\nend.\n\t"}, {"source_code": "var a,b,n:longint;\n st1,st2,y,stroka:string;\n i,x,x1,x2,q,kluch,k:longint;\n code:integer;\nbegin\n readln(a,b);\n str(a,st1);\n str(b,st2);\n if (length(st1)>length(st2)) or (a>=b)\n then\n begin\n if (a>=b) and (length(st1)=length(st2))\n then\n begin\n n:=length(st1);\n st1:='1';\n for i:=1 to n do\n st1:=st1+'0';\n end;\n while kluch=0 do\n begin\n for i:=length(st1)-length(st2)+1 downto 1 do\n begin\n k:=0;\n while k=0 do\n begin\n val(st1[i],x1,code);\n val(st2[1],x2,code);\n if x2>=x1\n then\n begin\n q:=0;\n while (x2=x1) and (i+q+1<=length(st1)) do\n begin\n inc(q);\n val(st1[i+q],x1,code);\n val(st2[1+q],x2,code);\n end;\n if x2>=x1\n then\n begin\n q:=0;\n while i+q<=length(st1) do\n begin\n if q<=length(st2)-1\n then st1[i+q]:=st2[1+q]\n else st1[i+q]:='0';\n inc(q);\n end;\n str(a,stroka);\n if stroka<>st1\n then\n begin\n writeln(st1);\n kluch:=1;\n break;\n end;\n end\n end;\n if kluch=0\n then\n begin\n val(st1[i-1],x,code);\n if (x=9)\n then\n begin\n k:=1;\n break;\n end\n else\n begin\n inc(x);\n str(x,y);\n val(st2[1],x1,code);\n insert(y,st1,i-1);\n delete(st1,i,1);\n for q:=i to length(st1) do\n st1[q]:='0';\n end;\n end;\n end;\n if x=9\n then break;\n if kluch=1\n then break;\n end;\n if kluch=1\n then break;\n if kluch=0\n then\n begin\n n:=length(st1);\n st1:='1';\n for q:=1 to n do\n st1:=st1+'0';\n end;\n end;\n end\n else writeln(b);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n//{$A8,B-,C+,D-,E-,F-,G+,H+,I-,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n\nprogram ProblemB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n inname = 'input.txt';\n outname = 'output.txt';\n maxn = 0;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n\nvar\n a, b: int;\n\nfunction m(a: int): int;\nvar\n k, d, t: int;\nbegin\n d := 10000000;\n while d > a do\n d := d div 10;\n\n t := 0;\n while a > 0 do begin\n k := a div d;\n if (k = 4) or (k = 7) then\n t := 10 * t + k;\n a := a mod d;\n d := d div 10;\n end;\n\n result := t;\nend;\n\nprocedure run;\nbegin\n read(a, b);\n\n while m(a) <> b do\n inc(a);\n\n write(a);\nend;\n\nprocedure openfiles;\nbegin\n assign(input, inname);\n assign(output, outname);\n reset(input);\n rewrite(output);\nend;\n\nprocedure closefiles;\nbegin\n close(input);\n close(output);\nend;\n\nBegin\n //openfiles;\n run;\n //closefiles;\nEnd.\n"}], "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb"} {"source_code": "uses math;\nvar n:int64;\n i,gt:longint;\n ok:boolean;\nbegin\n read(n);\n if n=1 then writeln('1')\n else begin\n for i:=2 to trunc(sqrt(n)) do\n if (n mod i)=0 then begin\n ok:=true;\n gt:=i;\n break;\n end;\n if ok then begin\n while (n mod i)=0 do\n n:=n div i;\n if n=1 then writeln(gt)\n else writeln('1');\n end\n else writeln(n);\n end;\nend.", "positive_code": [{"source_code": "var i,n,m:longint;a:int64;\nbegin\n read(a);\n if a<4 then write(a) else if not odd(a) then begin\n while a mod 2=0 do a :=a div 2;\n if a=1 then write(2) else write(1)\n end else\n begin\n m:=1;i:=1+trunc(sqrt(A));\n while m <=i do\n begin\n inc(m,2);\n if a mod m=0 then begin \n a:=a div m;\n while a mod m=0 do\n a:=a div m;\n if a=1 then \n write(m) else write(1); halt end\n end;\n\n write(a); end;\nend."}, {"source_code": "var\n n, d, first_divisor: int64;\n found_second: boolean;\n\nbegin\n readln(n);\n first_divisor := 1;\n d := 2;\n while (d * d <= n) and not found_second do begin\n while n mod d = 0 do begin\n n := n div d;\n if first_divisor = 1 then\n first_divisor := d\n else \n if first_divisor <> d then\n found_second := true;\n end;\n d += 1;\n if d > 3 then\n d += 1;\n end;\n if n > 1 then begin\n if first_divisor > 1 then\n found_second := true\n else\n first_divisor := n\n end;\n if found_second then\n writeln(1)\n else\n writeln(first_divisor);\nend.\n"}, {"source_code": "Program A1242;\nvar n: int64;\n\n\n\nProcedure get_colors(n:int64);\nvar i, j, d: int64;\nbegin;\n i:=2;\n d:=1;\n while trunc(sqrt(n))>= i do\n begin\n if d>1 then\n begin\n n:=1;\n break\n end;\n while (n mod i = 0) and (trunc(sqrt(n)) >= i) do\n begin;\n d:=i;\n n:=n div i;\n end;\n i+=1\n end;\n if (d<>n) and (d>1) then\n n:=1;\n writeln(n)\nend;\n\n\n\nbegin;\n readln(n);\n get_colors(n)\nend."}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n sum,ssum:array[0..10000,0..10000] of byte;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n leftx,lefty,rightx,righty,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]yy[i] then fl:=false;\n\n sovp:=fl;\nend;\n\nprocedure change(ii,jj:longint);\nvar pp:longint;\nbegin\n pp:=xx[ii];\n xx[ii]:=yy[jj];\n yy[jj]:=pp;\n\nend;\n\nfunction prostt(pp:int64):boolean;\nvar i,j:longint; t:extended; fl:boolean;\nbegin\n t:=pp;\n t:=sqrt(t);\n for i:=2 to round(t) do if pp mod i=0 then fl:=false;\n\n prostt:=fl;\nend;\n\n\n\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n read(tt);\n x[0]:=1;\n\n\n if prostt(tt) then begin writeln(tt); goto 1; end;\n al:=tt;\n al:=sqrt(al);\n for i:=1 to round(al) do\n begin\n if (tt mod i=0)and(i>1) then begin inc(p); x[p]:=i; end;\n if (tt mod i=0) then begin inc(p); x[p]:=tt div i; end;\n\n\n end;\n\n { writeln('p= ',p);\n for i:=1 to p do write(x[i]:4);\n writeln;\n } qq:=x[1];\n for i:=1 to p do qq:=nod(qq,x[i]);\n writeln(qq);\n\n\n\n\n\n goto 1;\n read(qq);\n for stepp:=1 to qq do\n\n begin\n readln(p); tt:=0;\n readln(ss1); readln(ss2);\n for i:=1 to p do begin xx[i]:=ord(ss1[i])-ord('a'); yy[i]:=ord(ss2[i])-ord('a'); end;\n for i:=0 to 26 do begin x[i]:=0; end;\n for i:=1 to p do begin\n t:=ord(ss1[i])-ord('a'); inc(x[t]); t:=ord(ss2[i])-ord('a'); inc(x[t]);\n end;\n flag:=true;\n for i:=0 to 25 do if odd(x[i]) then flag:=false;\n if flag then writeln('YES') else begin writeln('NO'); goto 2; end;\n\n q:=0;\n while not sovp(p) and (q<1000000)and(tt<1000000) do\n begin\n { writeln('q= ',q);\n } inc(q); flag1:=false; flag2:=false;\n for i:=1 to p do if xx[i]<>yy[i] then begin pos1:=i; break; end;\n for i:=1 to p do if (xx[i]=xx[pos1])and(i<>pos1) then begin flag1:=true; pos2:=i; goto 3; end;\n for i:=1 to p do if (yy[i]=xx[pos1]) then begin flag2:=true; pos2:=i; break; end;\n3: { writeln(flag1,' ',flag2,' pos1= ',pos1,' pos2= ',pos2);\n } if flag1 then\n begin\n inc(tt);\n { for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n }\n z[tt]:=pos2; zz[tt]:=pos1;\n change(z[tt],zz[tt]);\n { writeln('case 1');\n for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n writeln('----------------');\n }\n end;\n\n if flag2 then\n begin\n { for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n }\n inc(tt); z[tt]:=p; zz[tt]:=pos2;\n change(z[tt],zz[tt]);\n inc(tt); z[tt]:=p; zz[tt]:=pos1;\n change(z[tt],zz[tt]);\n { writeln('case 2');\n for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n writeln('-----------------');\n }\n end;\n\n\n end;\n writeln(tt);\n for i:=1 to tt do writeln(z[i],' ',zz[i]);\n\n 2:\n\n\n end;\n\n\n 1: close (output);\nend.\n\n"}], "negative_code": [{"source_code": "var i,n,m:longint;a:int64;\nbegin\n read(a);\n if a<4 then write(a) else if not odd(a) then write(2) else\n begin\n m:=1;\n while m*m<=a do\n begin\n inc(m,2);\n if a mod m=0 then begin write(m); halt end\n end;\n\n write(a); end;\nend."}, {"source_code": "uses math;\nvar n:int64;\n i,gt:longint;\n ok:boolean;\nbegin\n read(n);\n if n=1 then writeln('1');\n for i:=2 to trunc(sqrt(n)) do\n if (n mod i)=0 then begin\n ok:=true;\n gt:=i;\n break;\n end;\n if ok then begin\n while (n mod i)=0 do\n n:=n div i;\n if n=1 then writeln(gt)\n else writeln('1');\n end\n else writeln(n);\nend."}, {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44,22;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n qqq:zap; pmin,bet,al:extended;\n ot1,ot2:zap;\n ver:array[-1..500,-1..5] of extended;\n sum,ssum:array[0..10000,0..10000] of byte;\n verugad:array[-2..200,-2..200,-2..200] of extended;\n leftx,lefty,rightx,righty,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;\n zzan,prost,marked,zan:array[-1000000..1000000] of boolean;\n ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n dddd:array[-10..5010,-10..5010] of int64;\n function srav(i,j:longint):boolean; label 44;\n\n begin\n if (a[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]yy[i] then fl:=false;\n\n sovp:=fl;\nend;\n\nprocedure change(ii,jj:longint);\nvar pp:longint;\nbegin\n pp:=xx[ii];\n xx[ii]:=yy[jj];\n yy[jj]:=pp;\n\nend;\n\nfunction prostt(pp:int64):boolean;\nvar i,j:longint; t:extended; fl:boolean;\nbegin\n t:=pp;\n t:=sqrt(t);\n for i:=2 to round(t) do if pp mod i=0 then fl:=false;\n\n prostt:=fl;\nend;\n\n\n\n\n\n\n begin\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n read(tt);\n x[0]:=1;\n for i:=1 to 60 do x[i]:=x[i-1]*2;\n for i:=1 to 60 do if tt=x[i] then begin writeln(2); goto 1; end;\n if prostt(tt) then begin writeln(tt); goto 1; end;\n writeln(1);\n\n\n goto 1;\n read(qq);\n for stepp:=1 to qq do\n\n begin\n readln(p); tt:=0;\n readln(ss1); readln(ss2);\n for i:=1 to p do begin xx[i]:=ord(ss1[i])-ord('a'); yy[i]:=ord(ss2[i])-ord('a'); end;\n for i:=0 to 26 do begin x[i]:=0; end;\n for i:=1 to p do begin\n t:=ord(ss1[i])-ord('a'); inc(x[t]); t:=ord(ss2[i])-ord('a'); inc(x[t]);\n end;\n flag:=true;\n for i:=0 to 25 do if odd(x[i]) then flag:=false;\n if flag then writeln('YES') else begin writeln('NO'); goto 2; end;\n\n q:=0;\n while not sovp(p) and (q<1000000)and(tt<1000000) do\n begin\n { writeln('q= ',q);\n } inc(q); flag1:=false; flag2:=false;\n for i:=1 to p do if xx[i]<>yy[i] then begin pos1:=i; break; end;\n for i:=1 to p do if (xx[i]=xx[pos1])and(i<>pos1) then begin flag1:=true; pos2:=i; goto 3; end;\n for i:=1 to p do if (yy[i]=xx[pos1]) then begin flag2:=true; pos2:=i; break; end;\n3: { writeln(flag1,' ',flag2,' pos1= ',pos1,' pos2= ',pos2);\n } if flag1 then\n begin\n inc(tt);\n { for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n }\n z[tt]:=pos2; zz[tt]:=pos1;\n change(z[tt],zz[tt]);\n { writeln('case 1');\n for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n writeln('----------------');\n }\n end;\n\n if flag2 then\n begin\n { for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n }\n inc(tt); z[tt]:=p; zz[tt]:=pos2;\n change(z[tt],zz[tt]);\n inc(tt); z[tt]:=p; zz[tt]:=pos1;\n change(z[tt],zz[tt]);\n { writeln('case 2');\n for i:=1 to p do write(xx[i]:3); writeln;\n for i:=1 to p do write(yy[i]:3); writeln;\n writeln('-----------------');\n }\n end;\n\n\n end;\n writeln(tt);\n for i:=1 to tt do writeln(z[i],' ',zz[i]);\n\n 2:\n\n\n end;\n\n\n 1: close (output);\nend.\n\n"}, {"source_code": "Program A1242;\nvar n: integer;\n\n\n\nProcedure get_colors(n:integer);\nvar i, j, d: integer;\nbegin;\n i:=2;\n d:=1;\n while trunc(sqrt(n))>= i do\n begin\n if d>1 then\n begin\n n:=1;\n break\n end;\n while (n mod i = 0) and (trunc(sqrt(n)) >= i) do\n begin;\n d:=i;\n n:=n div i;\n end;\n i+=1\n end;\n writeln(n)\nend;\n\n\n\nbegin;\n readln(n);\n get_colors(n)\nend."}, {"source_code": "var\n n, d, first_divisor: int64;\n found_second: boolean;\n\nbegin\n readln(n);\n d := 2;\n while (d * d <= n) and not found_second do begin\n while n mod d = 0 do begin\n n := n div d;\n if first_divisor = 0 then\n first_divisor := d\n else \n if first_divisor <> d then\n found_second := true;\n end;\n d += 1;\n if d > 3 then\n d += 1;\n end;\n if n > 1 then begin\n if first_divisor > 0 then\n found_second := true\n else\n first_divisor := n\n end;\n if found_second then\n writeln(1)\n else\n writeln(first_divisor);\nend.\n"}], "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"source_code": "\n var\n a,b,i,n,j,k:longint;\n x:array[1..111111]of longint;\n ch:array[0..111111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1;\n if ((ch[i]='W') and (ch[i-1]='B')) or ((i=n)and (k>0)) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n\n for i:=1 to a do\n write(x[i],' ');\nend. ", "positive_code": [{"source_code": "var a:array[1..100] of longint;\n n,i,k,q,j:longint;\n c:char;\nbegin\n readln(n);\n j:=1;\n q:=0;\n k:=0;\n for i:=1 to n do\n begin\n read(c);\n if c='B'\n then inc(q)\n else if q>0\n then begin\n a[j]:=q;\n inc(j);\n inc(k);\n q:=0;\n end;\n end;\n if q>0\n then begin\n a[j]:=q;\n inc(j);\n inc(k);\n q:=0;\n end;\n writeln(k);\n for i:=1 to k do\n write(a[i],' '); \nend.\n"}, {"source_code": "program mirovanie;\nvar q:char; w:array[1..10000] of integer; z,x:integer;\nbegin\n x:=1;\n readln(x); x:=1;\n while not eoln do\n begin\n read(q);\n if q='W' then x:=1;\n if q='B' then\n begin\n if x=0 then w[z]:=w[z]+1 else begin z:=z+1;w[z]:=1;x:=0; end;\n end;\n end;\n writeln(z);\n for x:=1 to z do write(w[x],' ');\nend."}, {"source_code": "var i,n,dem,j:longint;\n s:ansistring;\n a:Array[1..100] of integer;\nbegin\n readln(n);\n readln(S);\n i:=1;\n dem:=0;\n a[0]:=0;\n while (i<=n) do\n begin\n while (i<=n) and (s[i]<>'B') do inc(i);\n if i>n then break;\n inc(dem);\n j:=i;\n while (j<=n) and (s[j]='B') do inc(j);\n a[dem]:=j-i;\n i:=j;\n end;\n writeln(dem);\n for i:=1 to dem do\n write(a[i],' ');\nend."}, {"source_code": "var\na:array[1..1000] of integer;\ns:string;\nj,g,h,i:longint;\nbegin\nreadln(h);\nread(s);\nj:=1;\nwhile i'W')and(i<=h) do begin\ninc(a[j]);\ninc(i);\nend;\ninc(j);\nend;\nend;\nwriteln(j-1);\nfor i:=1 to j-1 do\nif a[i]<>0 then write(a[i],' ');\nend."}, {"source_code": "var s:ansistring;\nn,i,top,sum:longint;\na:array[0..10000]of longint;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s) do\n begin\n if s[i]='B' then\n inc(a[top])\n else inc(top);\n end;\nfor i:=0 to top do\n if a[i]>0 then inc(sum);\n writeln(sum);\n for i:=0 to top do\n if a[i]>0 then write(a[i],' ');\nend."}, {"source_code": "const fi = '';\n fo = '';\nvar s: string;\n n, ans, so, i: longint;\n f: array[1..200] of longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n);\n readln(s);\n s:=s+'W';\n i:=1; ans:=0; so:=0;\n for i:=1 to length(s) do\n begin\n if s[i] = 'B' then\n if so = 0 then\n begin\n inc(ans);\n inc(so);\n end\n else inc(so);\n if s[i] = 'W' then\n if so > 0 then\n begin\n f[ans]:=so;\n so:=0;\n end;\n end;\n writeln(ans);\n for i:=1 to ans do write(f[i],' ');\n\n close(input); close(output);\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n,m:longint;\n s:string;\n a:array[1..100] of longint;\n\nProcedure Nhap;\nVar f:Text;\nBegin\n assign(f,finp); reset(f);\n readln(f,n);\n read(f,s);\n close(f);\nEnd;\nProcedure Solve;\nVar i,j,dem:longint;\nBegin\n i:=1; s:=s+'W'; m:=0;\n while i<=n do\n if s[i]='B' then\n begin\n dem:=0;\n for j:=i to n do\n if s[j]='B' then\n begin\n inc(dem);\n if s[j+1]='W' then\n break;\n end;\n inc(m); a[m]:=dem;\n i:=j+1;\n end\n else\n i:=i+1;\nEnd;\nProcedure Xuat;\nVar f:Text;\n i:longint;\nBegin\n assign(f,fout); rewrite(f);\n writeln(f,m);\n for i:=1 to m do\n write(f,a[i],' ');\n close(f);\nEnd;\n\nBegin\n Nhap;\n Solve;\n Xuat;\nEnd."}, {"source_code": "program zzz;\n var\n a:boolean;\n n,x,i,kol:integer;\n s:string;\n k:array[1..100]of integer;\nbegin\n a:=true;\n readln(n);\n readln(s);\n x:=0;\n for i:=1 to n do\n begin\n if (a=true)and (s[i]='B') then begin\n inc(kol);\n a:=false;\n inc(x);\n end;\n if (a=false)and (s[i]='B') then inc(k[x]);\n if (a=false)and (s[i]='W') then a:=true;\n end;\n writeln(kol);\n for i:=1 to x do\n write(k[i],' ');\nend."}, {"source_code": "const a='B';\n b='W';\nvar n,i,p,k: integer;\n str: string;\n D:array[1..100] of integer;\nbegin\n\nreadln(n);\nreadln(str);\nk:=0;\np:=0;\nfor i:=1 to n do\nbegin\n if (str[i]=a) then\n k:=k+1\n else\n if k>0 then\n begin\n inc(p);\n D[p]:=k;\n k:=0;\n end;\nend;\nif (k>0) then\nbegin\ninc(p);\nD[p]:=k;\nend;\nwriteln(p);\nfor i:=1 to p do\n write(D[i],' ');\n\nend."}, {"source_code": "var\n a:array[0..1000]of longint;\n s:ansistring;\n n,m,i,k,j,f,t,c,x,y,z,q,w:longint;\nbegin\n readln(n);\n readln(s);\n s:=s+'W';\n for i:=1 to n+1 do\n begin\n if((s[i]='B')and(i=1))or((s[i]='B')and(s[i-1]='W'))then f:=i;\n if((s[i]='W')and(i=n+1)and(f<>0))or((s[i]='W')and(s[i-1]='B'))then\n begin\n inc(k);\n a[k]:=i-f;\n f:=0;\n end;\n end;\n writeln(k);\n if k>=1 then write(a[1]);\n for i:=2 to k do write(' ',a[i]);\n if k>=1 then writeln;\nend."}, {"source_code": "var s:string;\ni,a,n,d,q:longint;\nbegin\nreadln(n);\nreadln(s);\nif s[n]='B' then\ns:=s+'W';\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then begin inc(a); q:=1 end else if (i>1) and (s[i-1]<>s[i]) then begin a:=0; inc(d); end;\nend;\nif q = 0 then writeln(0)\nelse\nbegin\nwriteln(d);\na:=0;\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then inc(a) else if (i>1) and (s[i-1]<>s[i]) then begin write(a,' '); a:=0;end;\nend;\nend;\nend."}, {"source_code": "program yan;\n var ar:array[1..100]of longint; s:string;\n i,j,x,y,a,b,n,m:longint;\nbegin\n readln(n);\n readln(s);\n a:=1;\n for i:=1 to n do\n if s[i]='B' then inc(ar[a]) else inc(a);\n b:=a;\n for i:=1 to b do if ar[i]=0 then dec(a);\n writeln(a);\n for i:=1 to b do\n if ar[i]>0 then write(ar[i],' ');\nend."}, {"source_code": "Var\ns:string;\na:array[1..100] of byte;\ni,j,k,n:byte;\nBegin\nReadln(n);\nReadln(s);\nk:=0;\nj:=1;\n\nFor i:=1 to n do\n begin\n if s[i]='B' then inc(k);\n if (s[i]='W') and (k<>0) then begin a[j]:=k; inc(j); k:=0; end;\n end;\n\nif s[i]='B' then begin a[j]:=k; end else dec(j);\n\nif a[1]=0 then write('0')\nelse begin\n\nWriteln(j);\nFor i:=1 to j do write(a[i],' '); end;\nEnd.\n"}, {"source_code": "var\n n,i,s,x:longint;\n ch:char;\n a:array[0..1000001] of longint;\nbegin \n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n if ch='B' then inc(x)\n else if x<>0 then\n begin\n inc(s);\n a[s]:=x;\n x:=0;\n end;\n end;\n if x<>0 then\n begin\n inc(s); a[s]:=x;\n end;\n writeln(s);\n for i:=1 to s do\n write(a[i],' ');\nend."}, {"source_code": "Program p1;\nvar i, n, k, f:byte;\n a:array [1..100] of char;\n b:array [1..50] of byte;\nbegin\n readln (n);\n for i:=1 to n do\n read (a[i]);\n f:=0;\n k:=0;\n for i:=1 to n do\n begin\n if a[i]='B' then\n if f=0 then\n begin\n f:=1;\n inc (k);\n b[k]:=1;\n end\n else inc (b[k])\n else f:=0;\n end;\n writeln (k);\n if k<>0 then\n begin\n for i:=1 to k-1 do\n write (b[i],' ');\n write (b[k]);\n end;\nend."}, {"source_code": "var\n a:array [1..200] of integer;\n s:string;\n i,n,k,j:integer;\nBEGIN\n readln(n);\n read(s);\n i:=1;j:=1;\n while i<=n do\n begin\n k:=0;\n while (s[i]='B') and (i<=n) do\n begin\n inc(k);\n inc(i);\n end;\n if i<=n\n then\n while (s[i]<>'B') and (i<=n) do\n inc(i);\n if (k<>0)\n then begin\n a[j]:=k;\n inc(j);\n end;\n end;\n writeln(j-1);\n for i:=1 to j-1 do\n write(a[i],' ');\n\nEND."}, {"source_code": "Var s:string;\n n,i,k:longint;\n a:array[1..1000] of longint;\n begin\n readln(s);\n readln(s);\n for i:=1 to length(s) do\n begin\n if s[i]='B' then k:=k+1\n else \n begin\n if k>0 then begin n:=n+1; a[n]:=k; end;\n k:=0;\n end;\n end;\n if k>0 then begin n:=n+1; a[n]:=k; end;\n writeln(n);\n for i:=1 to n do\n write(a[i],' ');\n End."}, {"source_code": "var n,i,k,b:integer; s,nn,ans:string;\nbegin\nreadln(n);\nreadln(s);\ns:=s+'s';\nb:=0;\nwhile i < n do begin\ni:=i+1;\n if s[i] = 'B' then begin\n k:=k+1;\n while s[i] = 'B' do begin b:=b+1; i:=i+1; end;\n str(b,nn);\n ans:= ans + nn+' ';\n b:=0;\n end;\n\nend;\nwriteln(k);\nwriteln(ans);\n\nend.\n"}, {"source_code": "{$MODE OBJFPC}\n\nProgram cf374A;\n\nConst\n Input= '';\n Output= '';\n\nVar\n Fi, fo: text;\n n, i, res, c: integer;\n a: array[1..100] of integer;\n s: ansistring;\n\nProcedure Enter;\n Begin\n Readln(fi, n);\n readln(fi, s);\n End;\n\nProcedure Solve;\n Begin\n res:= 0; c:= 0;\n For i:= 1 to n do\n if s[i]= 'W' then\n begin\n if c<> 0 then\n begin\n inc(res);\n a[res]:= c;\n end;\n c:= 0;\n end\n else inc(c);\n if c<> 0 then\n begin\n inc(res);\n a[res]:= c;\n end;\n End;\n\nProcedure Finish;\n Begin\n writeln(Fo, res);\n for i:= 1 to res do write(fo, a[i],' ');\n End;\n\nBegin\n Assign(Fi, Input); Reset(Fi);\n Assign(Fo, Output); Rewrite(Fo);\n Enter;\n Solve;\n Finish;\n Close(Fi); Close(Fo);\nEnd.\n\n"}, {"source_code": "\n var\n a,b,i,n,j,k:longint;\n x:array[1..111111]of longint;\n ch:array[0..111111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1;\n if ((ch[i]='W') and (ch[i-1]='B')) or (((i=n)and (a<>0) and (k>0)) or ((i=n)and (k>0))) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n\n for i:=1 to a do\n write(x[i],' ');\nend. "}, {"source_code": "var s:string;\nn,i,x,y,j:longint;\na:array[1..100] of longint;\nBEGIN\nreadln(n);\nread(s);\nj:=0;\nfor i:=1 to n do begin\nif (s[i]='B')and(i=1) then begin if j=0 then inc(j);\ninc(a[j]);\nend;\nif (s[i]='B')and(s[i-1]='W') then begin inc(j);\ninc(a[j]);\nend;\nif (s[i]='B')and(s[i-1]='B') then inc(a[j]);\nend;\nwriteln(j);\nfor i:=1 to j do\nwrite(a[i],' ');\nEND.\n\n\n"}, {"source_code": "var s:string;\ni,j,n,k,i1:longint;\na:array[1..10000]of longint;\nbegin\n readln(n); \n readln(s);\ni:=1;\n while i<=n do\n if s[i]='B' then begin\n i1:=i;\n while (i<=n) and(s[i]='B') do\n i:=i+1;\n k:=k+1;\n a[k]:=i-i1;\n end\n else i:=i+1;\n writeln(k);\n for i:=1 to k do\n write(a[i],' ');end."}, {"source_code": "program ideone;\nvar\n\ts:string;\n\tk,d,i:longint;\n\ta:array[0..100] of longint;\nbegin\n\treadln(s);\n\treadln(s);\n\tk:=0;d:=0;\n\ts:=s+' ';\n\tfor i:=1 to length(s) do\n\tbegin\n\t\tif s[i]<>'B' then d:=0;\n\t\tif s[i]='B' then d:=d+1;\n\t\tif (s[i]='B') and (s[i+1]<>'B') then \n\t\tbegin\n\t\t\tk:=k+1;\n\t\t\ta[k]:=d;\n\t\t\td:=0;\n\t\tend;\n\tend;\n\twriteln(k);\n\tfor i:=1 to k do write(a[i],' ');\nend."}, {"source_code": "var st:string;\nd,k,j,n,i:byte;\nbegin\n readln(n);\n readln(st);\n i:=1;\n k:=0;\n if st[1]='B' then\n k:=k+1;\n for i:=2 to length(st) do\n if (st[i]='B') and (st[i-1]='W') then\n k:=k+1;\n writeln(k);\n j:=1;\n i:=1;\n while i<= k do\n begin\n while st[j]='B' do\n begin\n d:=d+1;\n if j0 then\n begin\n write(d,' ');\n i:=i+1;\n end;\n d:=0;\n end;\n end. \n "}, {"source_code": "var\n n,uk,t,i:integer;st:string;a:array[1..1000] of integer;\nbegin\n readln(n);\n read(st);uk:=0;t:=0;st:=st+'W';\n for i:=1 to length(st) do\n if (st[i]='B') then inc(uk) else if (uk>0) then begin\n inc(t);a[t]:=uk;uk:=0;\n end;\n writeln(t);\n for i:=1 to t do\n write(a[i],' ');\nend."}, {"source_code": "Var a:array[1..1000]of longint;\n n,i,j,k:longint;\n t:string;\nBegin\n readln(n);\n readln(t);\n k:=0;\n j:=0;\n n:=n+1;\n t:=t+'W';\n For i:=1 to n do\n if t[i]='B' then k:=k+1\n else if k<>0 then begin\n j:=j+1;\n a[j]:=k;\n k:=0;\n end;\n writeln(j);\n For i:=1 to j do\n writeln(a[i]);\nend."}, {"source_code": "var\notv:array[1..100000]of longint;\n\nans,n,j,i:longint;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nwhile i<=length(s) do begin\ninc(i);\n if s[i]='B' then begin\n j:=i;\n while s[j]='B' do inc(j);\n inc(ans);\n otv[ans]:=j-i;\n i:=j;\n end;\n\n\nend;\nwriteln(ans);\nfor i:=1 to ans do write(otv[i],' ');\nend."}, {"source_code": "{$mode objfpc}\n\nconst\n inputfile='';\n outputfile='';\n maxn=150;\n\nvar\n fi,fo:text;\n n:longint;\n s:ansistring;\n top,x:longint;\n a:array[0..maxn] of longint;\n i:longint;\n\nprocedure openf;\nbegin\n assign(fi,inputfile);\n reset(fi);\n assign(fo,outputfile);\n rewrite(fo);\nend;\n\nprocedure input;\nbegin\n readln(fi,n);\n read(fi,s);\nend;\n\nprocedure process;\nbegin\n fillchar(a,sizeof(a),0);\n top:=1;\n i:=1;\n while (s[i]='W') and (length(s)>1) do delete(s,1,1);\n if (length(s)=1) and (s[1]='W') then exit;\n for i:=1 to length(s) do\n begin\n if s[i]='B' then inc(a[top]);\n if (s[i]='W') and (s[i-1]='B') then inc(top);\n end;\nend;\n\nprocedure output;\nbegin\n if (length(s)=1) and (s[1]='W') then\n begin\n write(fo,0);\n exit;\n end;\n if s[length(s)]='W' then x:=top-1 else x:=top;\n writeln(fo,x);\n for i:=1 to x do write(fo,a[i],' ');\nend;\n\nprocedure closef;\nbegin\n close(fi);\n close(fo);\nend;\n\nbegin\n openf;\n input;\n process;\n output;\n closef;\nend.\n"}, {"source_code": "var\n st:string;\n n:longint;\n sg:array[1..12345] of longint;\n numg:longint;\nprocedure input;\n var i,j,k:longint;\n begin\n readln(n);\n readln(st);\n if (pos('B',st)=0) then\n begin\n write(0);\n exit;\n end; \n while (st[1]='W') do delete(st,1,1);\n while (st[length(st)]='W') do delete(st,length(st),1);\n while (pos('WW',st)>0) do delete(st,pos('WW',st),1);\n if (st='') then\n begin\n write(0);\n exit;\n end;\n j:=0;\n k:=0;\n st[length(st)+1]:='W';\n for i:=1 to length(st)+1 do\n if (st[i]='B') then inc(j)\n else\n begin\n inc(k);\n sg[k]:=j;\n j:=0;\n end;\n writeln(k);\n for i:=1 to k do\n write(sg[i],' ');\n end;\nbegin\n input;\nend.\n\n"}, {"source_code": "type mas = array [1..51] of longint; \n\nprocedure encryption(n:longint; s:string; var k:longint; var nums:mas);\nvar i,j:longint;\nbegin\n i:=1;\n k:=0;\n while i <= n do begin\n if s[i] = 'B' then begin\n j:=i;\n while (j <= n) and (s[j] = 'B') do\n inc(j); \n inc(k);\n nums[k]:=j-i;\n i:=j+1;\n end else \n inc(i);\n end;\nend;\n\nprocedure write_mas(k:longint; const nums:mas);\nvar i:longint;\nbegin\n for i:=1 to k do \n write(nums[i],' ')\nend;\n\nvar \n n,k:longint;\n s:string;\n nums:mas;\nbegin\n readln(n);\n readln(s);\n encryption(n,s,k,nums);\n writeln(k);\n write_mas(k,nums);\nend.\n "}, {"source_code": "program A721;\nvar j,z,i,n,k: longint;\n a: array [1..100] of char;\n b: array [1..100] of byte;\nbegin\nz:=0;\nj:=1;\nreadln (n);\nfor i:=1 to n do read (a[i]);\nfor i:=1 to n do\n begin\n if a[i]='B' then z:=z+1;\n if ((a[i]='W') and (a[i-1]='B')) or ((a[i]='B') and (i=n)) then\n begin\n b[j]:=z;\n z:=0;\n j:=j+1;\n end;\n end;\nwriteln (j-1);\nfor i:=1 to j-1 do write (b[i], ' ');\nend.\n"}, {"source_code": "Var\ni,n,c,d:integer;\ns:string;\nBegin\n readln(n);\n readln(s);\n c:=0;d:=0;\n for i:=1 to n do \n begin\n if s[i]='B' then c:=c+1\n else if c<>0 then \n begin \n c:=0;\n d:=d+1;\n end;\n end;\n if c<>0 then d:=d+1;\n Writeln(d);\n c:=0;\n \n for i:=1 to n do \n begin\n if s[i]='B' then c:=c+1\n else if c<>0 then \n begin \n write(c,' '); \n c:=0; \n d:=d+1;\n end;\n end;\n if c<>0 then begin d:=d+1; write(c,' '); end;\nEnd."}, {"source_code": "var s:string;\n n,i,j,d:longint;\n a:array[0..300] of longint;\nbegin\n readln(n);\n read(s);\n d:=0;\n j:=1;\n s:='W'+s;\n s:=s+'W';\n for i:= 2 to n+1 do\n begin\n if (s[i]='B') and (s[i+1]='W') then\n d:=d+1;\n if s[i]='B' then a[j]:=a[j]+1;\n if (s[i]='B') and (s[i+1]='W') then j:=j+1;\n end;\n if d<>0 then\n begin\n writeln(d);\n for i:= 1 to j-1 do\n write(a[i],' ');\n end\n else write(0);\nend."}, {"source_code": "var\nan : array[1..100] of integer;\ng : array[1..100] of char;\nI,h,j,o,count : integer;\n begin\n readln(o);\nfor I:=1 to o do\n read(g[I]);\nI:=0;\n repeat\n I:=I+1;\n if g[I]='B' then\n begin\n count:=count+1;\n repeat\n an[count]:=an[count]+1;\n I:=I+1;\n until (g[I]='W') or (I>o)\n end;\n until I>o ;\n writeln(count);\n for I:=1 to count do\n write(an[I],' ')\n end.\n "}, {"source_code": "program O_O;\n var\n i,j,k,n:longint;\n a:array[0..102] of longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n s:=s+'.';\n for i:=1 to length(S) do\n if s[i]='B' then inc(k) else\n if k>0 then\n begin\n inc(j);\n a[j]:=k;\n k:=0;\n end;\n writeln(j);\n for i:=1 to j do write(a[i],' ');\nend.\n"}, {"source_code": "var n,t,i:longint;\n s:ansistring;\n a:array[1..1000]of longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do\n if (s[i]='B')and((i=1)or(s[i-1]<>'B')) then\n begin\n inc(t);\n a[t]:=1;\n end\n else\n if (s[i]='B')and(i<>1)and(s[i-1]='B') then\n inc(a[t]);\n writeln(t);\n for i:=1 to t do\n write(a[i],' ');\nend."}, {"source_code": "var n, i : byte;\n s : string;\n groups: array[1..50] of byte;\n\nBEGIN\n readln(n);\n readln(s);\n\n i:= 0;\n s:= s + '0';\n fillchar(groups, sizeof(groups), 0);\n repeat\n while s[1] = 'W' do delete(s, 1, 1);\n\n if s[1] = 'B' then\n begin\n inc(i);\n repeat\n inc(groups[i]);\n delete(s, 1, 1);\n until s[1] <> 'B';\n end;\n until s = '0';\n\n writeln(i);\n if i > 0 then\n for n:= 1 to i do write(groups[n], ' ');\n\n readln;\nEND.\n\n"}, {"source_code": "var\n a:ansistring;\n n,i,k,stn:longint;\n st:array[1..1000000]of longint;\nbegin\n readln(n);\n readln(a);\n a:=a+'#';\n for i:=1 to n+1 do if a[i]='B' then inc(k) else if k>0 then \n begin\n inc(stn);\n st[stn]:=k;\n k:=0;\n end; \n writeln(stn);\n for i:=1 to stn-1 do write(st[i],' ');\n if stn>0 then writeln(st[stn]);\n\nend."}, {"source_code": "{$H+}\nvar s: string;\n\tn, i, k: integer;\n\ta: array [1..1000] of integer;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tfillchar(a, sizeof(a), 0);\n\tk := 0;\n\tif (s[1] = 'B') then\n\t\tbegin\n\t\t\tinc(k);\n\t\t\tinc(a[k]);\n\t\tend;\n\tfor i := 2 to n do\n\t\tbegin\n\t\t\tif (s[i] = 'B') then\n\t\t\t\tbegin\n\t\t\t\t\tif (s[i - 1] <> 'B') then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tinc(k);\n\t\t\t\t\t\t\tinc(a[k]);\n\t\t\t\t\t\tend\n\t\t\t\t\t\telse inc(a[k]);\n\t\t\t\tend;\n\t\tend;\n\twriteln(k);\n\tfor i := 1 to k do\n\t\twrite(a[i], ' ');\nEND.\n"}, {"source_code": "var\nn,i,k,h,m,j:integer;\na:array[1..100] of integer;\ns:string;\nbegin\nreadln(n);\nreadln(s);\ns:='W'+s+'W';\ni:=1;\nh:=1;\nn:=n+2;\nwhile i<=n do\nif (s[i]='B') and (s[i-1]='W')\nthen begin\n m:=0;\n for j:=i to n do\n if s[j]='B'\n then inc(m)\n else break;\n i:=j;\n inc(k);\n a[h]:=m;\n inc(h);\n end\nelse inc(i);\nwriteln(k);\nfor i:=1 to h-1 do\nwrite(a[i]:5);\nend."}, {"source_code": "var\nn,i,kol,ans:longint;\na:array[1..100000]of longint;\ns:ansiString;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to length(s) do begin\n if s[i]='B' then begin\n inc(kol);\n end\n else begin\n if kol>0 then begin\n inc(ans);\n a[ans]:=kol;\n kol:=0;\n end;\n end;\nend;\nif kol>0 then begin\n inc(Ans);\n a[ans]:=kol;\nend;\nwriteln(ans);\nfor i:=1 to ans do write(a[i],' ');\nend."}, {"source_code": "program zxc;\nvar n,i,k,z,l:integer;\na:array[1..50] of integer;\ns:string;\nbegin\nreadln(n);\nreadln(s);\nk:=0;\nz:=0;\nl:=1;\ns:='W'+s;\ns:=s+'W';\nfor i:=2 to n+2 do begin\nif (s[i]='B') and (s[i-1]='W') then begin\nk:=k+1; z:=z+1; end;\nif s[i]='W' then begin\nif z>0 then begin; a[l]:=z; l:=l+1; end;\nz:=0; end;\nif (s[i]='B') and (s[i-1]='B') then z:=z+1;\nend;\nwriteln(k);\nfor i:=1 to l-1 do\nwrite(a[i],' ');\nend.\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var b:array[0..1000] of longint;\nst:string;\nn,i,q,q2,s,kl,kol:longint;\nbegin\n readln(n);\n readln(st);\n\n for i:=1 to n do\n if st[i]='B' then begin\n kl:=1;\n break;\n end;\n if kl=0 then begin\n writeln(0);\n halt;\n end;\n while true do\n BEGIN\n q:=q+1;\n if st[q]='B' then begin\n s:=0;\n for i:=q to n do\n if st[i]='B' then s:=s+1\n else break;\n kol:=kol+1;\n q2:=q2+1;\n b[q2]:=s;\n q:=i;\n end;\n if q=n then break;\n END;\n writeln(q2);\n for i:=1 to q2 do\n write(b[i],' ');\nend."}, {"source_code": "var n,part,count,i:byte;\n s:string;\nbegin\n readln(n);\n read(s);\n for i:=1 to length(s) do\n begin\n if (s[i]<>s[i-1]) and (s[i]='B') then part:=part+1;\n end;\n writeln(part);\n for i:=1 to length(s)+1 do\n begin\n if s[i]='B' then inc(count);\n if (s[i]<>'B') and (s[i-1]='B') then \n begin\n write(count,' ');\n count:=0;\n end;\n end;\n readln;\nend. "}, {"source_code": "var n,m,i,j,ans:longint;\n a:array[0..1000]of longint;\n s:string;\nbegin\nreadln(n);\nreadln(s);s:=s+'W';\nfor i:=1 to n+1 do begin\n if s[i]='W' then begin\n if j>0 then BEGIN inc(ans);a[ans]:=j;END;j:=0;\n end else inc(j);\nend;\nwriteln(ans);\nfor i:=1 to ans do write(a[i],' ');\nend."}, {"source_code": "const fi = '721a.inp';\n fo = '721a.out';\n maxn = 1005;\nvar\n n:longint;\n s:string;\n a:array[1..maxn]of longint;\n\nprocedure enter;\nvar i:longint;\nbegin\n readln(n);\n readln(s);\nend;\n\nprocedure solve;\nvar i,j,r:longint;\nbegin\n i:=1;r:=0;\n while(i<=n)do\n begin\n while(i<=n)and(s[i]='W')do inc(i);\n if i>n then break;\n j:=i;\n while(j<=n)and(s[j]='B')do inc(j);\n inc(r); a[r]:=j-i;\n i:=j;\n end;\n writeln(r);\n for i:=1 to r do write(a[i],' ');\nend;\n\nBEGIN\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n enter;\n solve;\n close(input); close(output);\nEND.\n\n\n"}, {"source_code": "\nvar s:string;\ni,n:integer;\nk:array[1..100]of integer;\nbegin\n readln(n);\n readln(s);\n i:=1;\n n:=0;\n while i <= length(s) do\n begin\n if s[i]='B'then\n begin\n n:=n+1;\n while s[i]='B' do\n begin\n k[n]:=k[n]+1;\n i:=i+1;\n end;\n end;\n i:=i+1;\n end;\n writeln(n);\n for i:=1 to n do\n write(k[i],' ');\nend."}, {"source_code": "var n,k,i,z:integer; s: string;\nbegin\nreadln(n);\nreadln(s) ;\nk:=0; z:=0;\n\nfor i:=1 to n+1 do\nif s[i]='B' then k:=k+1 else if k>0 then begin z:=z+1; k:=0; end;\n\nwriteln(z);\n \nfor i:=1 to n+1 do\n if s[i]='B' then k:=k+1 else if k>0 then begin write(k,' ');k:=0; end;\n\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n st:string;\n sum,n,t:longint;\n s,c:array[1..1000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction chance(x:real):boolean;\n begin\n if ran(1,1000000)<=x*1000000 then exit(true) else exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure push(x:longint);\n begin\n inc(t);\n s[t]:=x;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,r1,r2,k:longint;\n begin\n k:=-1;\n readln(fi,n);\n readln(fi,st);\n for i:=1 to n do if st[i]='B' then\n begin\n if k<=0 then k:=1 else inc(k);\n end else if k>0 then\n begin\n push(k);\n k:=0;\n end;\n if k>0 then push(k);\n writeln(fo,t);\n for i:=1 to t do write(fo,s[i],' ');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i,j:longint;\n begin\n\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure printres;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n printres;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "\n{$mode objfpc}\n\nvar\n i,n:integer;\n s:array[0..200] of char;\n kq:integer;\n a:array[0..200] of integer;\n\nbegin\n//gsdfnhgsdfnobn\n//aidgjbdoasjbnonas\n//kibhfornsb\n//aipdfbn oiadnionbn \n readln(n);\n //fibohaeuofnbion\n for i:=1 to n do read(s[i]);\n //sifbhjidfnbn\n s[0]:='W';\n for i:=1 to n do\n begin\n if (s[i-1] = 'W') and (s[i] = 'B') then inc(kq);\n if s[i] = 'B' then inc(a[kq]);\n end;\n writeln(kq);\n for i:=1 to kq do write(a[i],' ');\nend."}, {"source_code": "var n, i, k:byte; s:array [0..100] of char; a:array [1..100] of byte;\nbegin\n readln(n);\n for i:=1 to n do\n read(s[i]);\n k:=0;\n for i:=1 to n do\n if s[i]='B' then begin\n if s[i-1]<>'B' then k:=k+1;\n a[k]:=a[k]+1;\n end;\n writeln(k);\n for i:=1 to k do\n write(a[i],' ');\n end."}, {"source_code": "var s:array[0..100] of char;\n ans:array[0..10000] of longint;\n i,j,sum,n:longint;\nbegin\n readln(n);\n for i:=1 to n do read(s[i]);\n for i:=1 to n do\n if s[i]='B' then\n begin\n j:=i;\n inc(sum);\n while s[j]='B' do\n begin\n inc(ans[sum]);\n s[j]:='W';\n inc(j);\n end;\n end;\n writeln(sum);\n if sum>0 then\n begin\n for i:=1 to sum do write(ans[i],' ');\n writeln;\n end;\nend.\n"}, {"source_code": "var i,n,m,c:byte;a:array[1..100] of byte;\ns:string;\nbegin\n readln(n);\n read(s);\n c:=0;\n m:=0;\n inc(n);\n s:=s+'e';\n for i:=1 to n do\n begin\n if s[i]='B' then inc(c)\n else\n begin\n \tif c>0 then\n begin\n inc(m);\n a[m]:=c; \n end;\n c:=0;\n end; \n end;\n writeln(m);\n for i:=1 to m do write(a[i],' '); \nend."}, {"source_code": "var n,i,k,j:integer;\ns:string;\na:array [1..100] of byte;\nbegin\nreadln(n);\nread(s);\nj:=0;\nfor i:=1 to n do\n if s[i]='B' then\n if (i=1) or (s[i-1]='W') then begin inc(k);inc(j);a[j]:=1;end else\n inc(a[j]);\nwriteln(k);\nj:=1;\nwhile(a[j]>0) do begin\n write(a[j],' ');\n inc(j);\n end;\n end."}, {"source_code": "var q:string; i,j:integer; w:array[0..100]of integer;\nbegin\nreadln(i);\nreadln(q);\nw[0]:=1;\nfor i:=1 to length(q )do\nif q[i]='B' then\ninc(j) else\nbegin\nif j<>0 then\nbegin\nw[w[0]]:=j;\ninc(w[0]);\nend;\nj:=0;\nend;\nif j<>0 then\nbegin\nw[w[0]]:=j;\ninc(w[0]);\nend;\nwriteln(w[0]-1);\nFor i:=1 To w[0]-1 Do Write(w[i],' ');\nend.\n"}, {"source_code": "var n,k,i,z:integer; s: string;\nbegin\nreadln(n);\nreadln(s) ;\nk:=0; z:=0;\n\nfor i:=1 to n+1 do\nif s[i]='B' then k:=k+1 else if k>0 then begin z:=z+1; k:=0; end;\n\nwriteln(z);\n\nfor i:=1 to n+1 do\n if s[i]='B' then k:=k+1 else if k>0 then begin write(k,' ');k:=0; end;\n\nend."}, {"source_code": "var n,i,k,j,k1:longint;\n s:string;\n a:array[1..100] of longint;\nBEGIN\nreadln(n);\nreadln(s);\nk:=0;j:=1;k1:=0;\nfor i:=1 to n do\n begin\n if s[i]='B' then\n begin\n inc(k);\n inc(k1);\n end\n else\n begin\n a[j]:=k;\n inc(j);\n k:=0;\n end;\n if i=n then a[j]:=k;\n end;\n \nk1:=0;\nfor i:=1 to n do\n if a[i]>0 then inc(k1);\n writeln(k1);\nfor i:=1 to n do\n if a[i]>0 then write(a[i],' ');\nEND."}, {"source_code": "var n,i,k,j:integer;\n s:string;\n a:array [1..100] of byte;\nbegin\n readln(n);\n read(s);\n j:=0;\n for i:=1 to n do\n if s[i]='B' then\n if (i=1) or (s[i-1]='W') then \n begin \n inc(k);inc(j);\n a[j]:=1;\n end \n else inc(a[j]);\n writeln(k);\n j:=1;\n while(a[j]>0) do\n begin\n write(a[j],' ');\n inc(j);\n end;\nend."}, {"source_code": "var\n i, j, n, m: integer;\n c, s: string;\nbegin\n readln(n);\n read(s); c := s + ' '; \n for i := 1 to n do\n if upcase(c[i]) = upcase(c[i + 1]) then c[i] := 'W';\n for i := 1 to n do\n if upcase(c[i]) = 'B' then inc(m);\n writeln(m); m := 0; s += 'W';\n for i := 1 to n + 1 do\n begin\n if (j = 1) and (upcase(s[i]) <> 'B') then begin write(m, ' '); m := 0; j := 0; end;\n if upcase(s[i]) = 'B' then begin j := 1; inc(m); end;\n end;\nend."}, {"source_code": " label 1;\n var s:string;n,i,kn,sc:integer;a:array[1..55]of integer;c:char;\nbegin\n readln(n);\n readln(s);\n For i:=1 to n do\n begin\n c:=s[i];\n if(c='B')and(kn=0)\n then begin\n sc:=sc+1;\n a[sc]:=1;\n kn:=1;\n goto 1;\n end;\n if(c='B')and(kn=1)\n then a[sc]:=a[sc]+1;\n if(c='W')and(kn=1)\n then kn:=0;\n 1:end;\n writeln(sc);\n for i:=1 to sc do\n write(a[i],' ');\nend."}, {"source_code": "var\n i, a, ok, v, j, n, b, x, c: integer;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n \n s:=s+'W';\n\n for i := 1 to n+1 do\n if s[i] = 'B' then b := b + 1\n else \n if b>0 then\n begin\n x:=x+1;\n b:=0;\n end;\n\n writeln(x);\n \n for i := 1 to n+1 do\n if s[i] = 'B' then b := b + 1\n else \n if b>0 then\n begin\n write(b,' ');\n b:=0;\n end;\n \nend.\n"}, {"source_code": "var kolvoch, i, n, k, l : Integer;\n s : String;\n a : array of Integer;\nbegin\n readln(n);\n readln(s);\n s := s + 'W';\n Inc(n);\n For i := 2 to n do If (s[i] <> s[i - 1]) and (s[i - 1] = 'B') then inc(kolvoch);\n If kolvoch = 0 then begin\n writeln(0);\n exit;\n end;\n //writeln(kolvoch);\n Setlength(a,kolvoch + 1);\n k := 0;\n l := 1;\n For i := 1 to n do\n begin\n If s[i] = 'B' then inc(k)\n else if k > 0 then begin\n //writeln(l);\n a[l] := k;\n k := 0;\n inc(l);\n end;\n end;\n writeln(kolvoch);\n write(a[1]);\n For i := 2 to kolvoch do write(' ',a[i]);\nend."}, {"source_code": "Var\n n, Ans: Int64;\n S: String;\n a: Array [0..99] of Int64;\n \nBegin\n Readln(n);\n Readln(S);\n For Var i := 1 to n do\n If S[i] = 'B' then\n a[Ans] += 1\n Else\n Ans += 1;\n Ans := 0;\n For Var i := 0 to 99 do\n If a[i] <> 0 then\n Ans += 1;\n Writeln(Ans);\n For Var i := 0 to 99 do\n If a[i] <> 0 then\n Write(a[i], ' ');\nEnd."}, {"source_code": "var\ni,n,j:integer;\ns:string;\nf:boolean;\na:array [1..50] of integer;\nbegin\nreadln(n);\nf:=false;\nread(s);\nj:=1;\nfor i:=1 to n do\nif s[i]='B' then begin f:=true; inc(a[j]); end else if a[j]<>0 then\ninc(j); \nif s[n]='W' then dec(j);\nwriteln(j);\nfor i:=1 to j do\nwrite(a[i],' ');\n\nend.\n\n"}, {"source_code": "var\n i, a, ok, v, j, n, b, x, c: integer;\n s: string;\n\nbegin\n readln(n);\n readln(s);\n s := s + 'W';\n for i := 1 to n + 1 do\n if s[i] = 'B' then b := b + 1\n else \n if b > 0 then\n begin\n x := x + 1;\n b := 0;\n end;\n writeln(x);\n for i := 1 to n + 1 do\n if s[i] = 'B' then b := b + 1\n else \n if b > 0 then\n begin\n write(b, ' ');\n b := 0;\n end;\nend."}, {"source_code": "uses strutils;\n\n const eps=1e-11; besk=8000000000000000000;\n modul=1000000007;\n label 1,2,3,4,11;\n type\n\n mas=array [-10000..1000000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..10000000] of int64;mass1=^mass;\n var aa,bb,olda1,olda2,ot,q1,aa2,bb2,aa1,bb1,t,t0,t1,p,kol,i1,j1,newdl,dl,kk,t2,m1,n1,pp,px,py,ll,cc,n2,dist,pos,dloch,x0,tt,v1,v2,p3,p4,t4,t5,t6,t3,xx,yy,ost,rr,q,h,n,qq,p1,p2,y0,s1,s2,m,imax,smin,besk1:int64;\n ii,jj,step,k,i,j:longint;\n c1,c2:array[-1000..100000] of int64;\n x,y:array[-10..65000] of int64;\n h1,h2:extended;\n dd,dd1,dd2,newoch,sum,ugol,s,place,xnew,z,och,fact,d, a1,bl,br,c,a,b:array[-10000001..3000000] of int64;\n stoim:array[-10..1200,-10..1200] of int64;\n ss,ss1,ss2 :string;\n grr:array[-100..5000,-100..5000] of boolean;\n ssot:array[-100..10000] of char;\n ch: char;\n ppp:zap;\n de,de1,gr,pole,pole1:array[-10..1400,-10..1400] of int64;\n prost, zan,marked:array[-1000001..1100000] of boolean;\n sss1,name1,name2,sp,sss,maxpr:array[0..1000000] of string;\n w,mm,nn,mm1,nn1,hh,ttt, l, aanew,v0,s0:extended;\n\n prvin,prlost,prob,x1,y1, xxx,yyy:array[-1..1000000] of extended;\n tt1, xxnew,per,pp2, ee,yot:double;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var aa,bb,qq,d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n aa:=a;bb:=b;\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2;\n flag:=x*aa+y*bb=d;\n if flag then begin tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end;\n flag:=x*bb+y*aa=d;\n if flag then begin tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;\n\n\n evkl:=tt1;\nend;\n\nfunction degg(modul,a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(modul,a,k-1)*a) mod modul else\n begin p:=degg(modul,a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n read(ss);\n for i:=1 to n do\n begin\n if (ss[i]='B')and(ss[i]<>ss[i-1]) then\n begin inc(t); a[t]:=1; end;\n\n if (ss[i]='B')and(ss[i]=ss[i-1]) then\n begin a[t]:=1+a[t]; end;\n\n\n\n end;\n\n writeln(t);\n for i:=1 to t do write(a[i],' ');\n\n\n\n 1: close(output);\n\n\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h] 'B';\n end;\n until s = '0';\n\n writeln(i);\n if i = 0 then writeln(0)\n else\n for n:= 1 to i do write(groups[n], ' ');\n\n readln;\nEND.\n\n"}, {"source_code": "var\n a:ansistring;\n n,i,k,stn:longint;\n st:array[1..1000000]of longint;\nbegin\n readln(n);\n readln(a);\n a:=a+'#';\n for i:=1 to n+1 do if a[i]='B' then inc(k) else if k>0 then \n begin\n inc(stn);\n st[stn]:=k;\n k:=0;\n end; \n writeln(stn);\n for i:=1 to stn-1 do write(st[i],' ');\n writeln(st[stn]);\n\nend."}, {"source_code": "var s:string;\n n,j,i,min,max:longint;\n t:array ['a'..'z'] of longint\n = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);\nbegin\n readln(s);\n n:=0;\n j:=t['a'];\n for i:=1 to length(s) do\n begin\n if j < t[s[i]] then begin min:=j; max:=t[s[i]]; end\n else begin min:=t[s[i]]; max:=j; end;\n\n if max-min < 26-max+min then n:=n+max-min\n else n:=n+26-max+min;\n j:=t[s[i]]; // writeln(j,' ',n);\n end;\n\n writeln(n);\nend.\n\n"}, {"source_code": "{$H+}\nvar s: string;\n\tn, i, k: integer;\n\ta: array [1..1000] of integer;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tk := 0;\n\tif (s[1] = 'B') then\n\t\tbegin\n\t\t\tinc(k);\n\t\t\tinc(a[k]);\n\t\tend;\n\tfor i := 2 to n do\n\t\tbegin\n\t\t\tif (s[i] = 'B') then\n\t\t\t\tbegin\n\t\t\t\t\tif (s[i - 1] <> 'B') then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tinc(k);\n\t\t\t\t\t\t\tinc(a[k]);\n\t\t\t\t\t\tend\n\t\t\t\t\t\telse inc(a[k]);\n\t\t\t\tend;\n\t\tend;\n\twriteln(k);\n\tfor i := 1 to k do\n\t\twrite(a[k], ' ');\nEND.\n"}, {"source_code": "var\nn,i,k,h,m,j:integer;\na:array[1..100] of integer;\ns:string;\nbegin\nreadln(n);\nreadln(s);\ns:='W'+s+'W';\ni:=1;\nh:=1;\nn:=n+2;\nwhile i<=n do\nif (s[i]='B') and (s[i-1]='W')\nthen begin\n m:=0;\n for j:=i to n do\n if s[j]='B'\n then inc(m)\n else break;\n i:=j;\n inc(k);\n a[h]:=m;\n inc(h);\n end\nelse inc(i);\nwriteln(k);\nfor i:=1 to h-1 do\nwrite(a[i]:2);\nend."}, {"source_code": "var a:char;\n i,n,count:longint;\n flag:boolean;\n\nbegin\n readln(n);\n count:=0;\n flag:=true;\n for i:=1 to n do begin\n read(a);\n if a='B' then\n inc(count)\n else\n if (a='W') and (count>0) then begin\n write(count,' ');\n count:=0;\n flag:=false;\n end;\n end;\n if (count>0) or (flag=true) then\n writeln(count);\nend."}, {"source_code": "var a:char;\n i,n,count:longint;\n arr:array[1..100] of integer;\n// flag:boolean;\n\nbegin\n readln(n);\n count:=1;\n //flag:=true;\n for i:=1 to n do begin\n read(a);\n if a='B' then\n inc(arr[count])\n else\n if (a='W') and (arr[count]>0) then begin\n // write(arr[count],' ');\n count:=count+1;\n //flag:=false;\n end;\n end;\n if (arr[count]=0) then\n dec(count);\n writeln(count);\n for i:=1 to count do\n write(arr[count],' ');\nend."}, {"source_code": "program abc;\nvar a:array[1..100]of integer;\nc:string;\ni,n,b,z:integer;\nbegin\n readln(n);\n b:=1;\n readln(c);\n for i:=1 to n do begin\n if (c[i]='W')and(a[b]>0) then begin\n b:=b+1;\n z:=z+1; end else\n if c[i]='B' then\n a[b]:=a[b]+1;\n end;\nif c[i]='B' then z:=z+1;\nwriteln(z);\nwrite(a[1]);\ni:=2;\nwhile a[i]<>0 do begin\nwrite(' ',a[i]);\ni:=i+1;\nend;\nend."}, {"source_code": "var n,k,i,z:integer; a:array [1..101] of string;\nbegin\nreadln(n);\nk:=0; z:=0;\n\nfor i:=1 to n do begin\n read(a[i]);\nend;\n a[n+1]:='W';\nfor i:=1 to n+1 do\nif a[i]='B' then k:=k+1 else if k>0 then begin z:=z+1; k:=0; end;\n\nwriteln(z);\n \nfor i:=1 to n+1 do\n if a[i]='B' then k:=k+1 else if k>0 then begin write(k,' ');k:=0; end;\n\nend."}, {"source_code": "var\n\tn,cnt : longint;\n\ts : string;\nbegin\n\treadln(n);\n\treadln(s);\n\tif pos('B',s) = 0 then begin\n\t\twriteln(0);\n\t\texit;\n\tend;\n\tcnt := 0;\n\twhile length(s) <> 0 do begin\n\t\tcnt := 0;\n\t\twhile s[1] = 'B' do begin\n\t\t\tdelete(s,1,1);\n\t\t\tinc(cnt);\n\t\t\tif length(s) = 0 then break;\n\t\tend;\n\t\tif (cnt <> 0) and (pos('B',s) <> 0) then write(cnt,' ')\n\t\telse if (cnt <> 0) then write(cnt);\n\t\tif length(s) = 0 then break;\n\t\twhile s[1] = 'W' do begin\n\t\t\tdelete(s,1,1);\n\t\t\tif length(s) = 0 then break;\n\t\tend;\n\t\tif length(s) = 0 then break;\n\tend;\n\twriteln;\nend."}, {"source_code": "uses math;\nvar f,g:text; s:string; i,j,n,d1,d2,t:longint; A:array[1..100] of longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n readln(f,n); read(f,s); t:=1;\n for i:=1 to n do\n begin\n if (s[i]='B') and ((s[i-1]='W') or (i=1)) then\n begin\n inc(d1); \n inc(d2);\n end\n else if (s[i]='B') and (s[i-1]='B') then inc(d2)\n else if (s[i]='W') and (s[i-1]='B') then\n begin\n A[t]:=d2;\n inc(t);\n d2:=0;\n end;\n end;\n if d1=0 then write(g,0)\n else \n begin\n writeln(g,d1);\n for i:=1 to t-1 do write(g,A[i],' ');\n end; close(f); close(g);\nend."}, {"source_code": "uses math;\nvar f,g:text; s:string; i,j,n,d1,d2,t:longint; A:array[1..100] of longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n readln(f,n); read(f,s); t:=1;\n for i:=1 to n do\n begin\n if (s[i]='B') and (s[i-1]='W') then\n begin\n inc(d1); \n inc(d2);\n end\n else if (s[i]='B') and (s[i-1]='B') then inc(d2)\n else if (s[i]='W') and (s[i-1]='B') then\n begin\n A[t]:=d2;\n inc(t);\n d2:=0;\n end;\n end;\n if d1=0 then write(g,0)\n else \n begin\n writeln(g,d1);\n for i:=1 to t do write(g,A[i],' ');\n end; close(f); close(g);\nend."}, {"source_code": "uses math;\nvar f,g:text; s:string; i,j,n,d1,d2,t:longint; A:array[1..100] of longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n readln(f,n); read(f,s); t:=1;\n for i:=1 to n do\n begin\n if (s[i]='B') and ((s[i-1]='W') or (i=1)) then\n begin\n inc(d1); \n inc(d2);\n end\n else if (s[i]='B') and (s[i-1]='B') then inc(d2)\n else if (s[i]='W') and (s[i-1]='B') then\n begin\n A[t]:=d2;\n inc(t);\n d2:=0;\n end;\n end;\n if d1=0 then write(g,0)\n else \n begin\n writeln(g,d1);\n for i:=1 to t do write(g,A[i],' ');\n end; close(f); close(g);\nend."}, {"source_code": "uses math;\nvar f,g:text; s:string; i,j,n,d1,d2,t:longint; A:array[1..100] of longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n readln(f,n); read(f,s); t:=1;\n for i:=1 to n do\n begin\n if (s[i]='B') and ((s[i-1]='W') or (s[i-1]=' ')) then\n begin\n inc(d1); \n inc(d2);\n end\n else if (s[i]='B') and (s[i-1]='B') then inc(d2)\n else if (s[i]='W') and (s[i-1]='B') then\n begin\n A[t]:=d2;\n inc(t);\n d2:=0;\n end;\n end;\n if d1=0 then write(g,0)\n else \n begin\n writeln(g,d1);\n for i:=1 to t do write(g,A[i],' ');\n end; close(f); close(g);\nend."}, {"source_code": "uses math;\nvar f,g:text; s:string; i,j,n,d1,d2,t:longint; A:array[1..100] of longint;\nbegin\n assign(f,''); reset(f);\n assign(g,''); rewrite(g);\n readln(f,n); read(f,s); t:=1;\n for i:=1 to n do\n begin\n if (s[i]='B') and ((s[i-1]='W') or (s[i-1]='')) then\n begin\n inc(d1); \n inc(d2);\n end\n else if (s[i]='B') and (s[i-1]='B') then inc(d2)\n else if (s[i]='W') and (s[i-1]='B') then\n begin\n A[t]:=d2;\n inc(t);\n d2:=0;\n end;\n end;\n if d1=0 then write(g,0)\n else \n begin\n writeln(g,d1);\n for i:=1 to t do write(g,A[i],' ');\n end; close(f); close(g);\nend."}, {"source_code": "var n, i, k:byte; s:array [0..100] of char; a:array [1..100] of byte;\nbegin\n readln(n);\n for i:=1 to n do\n read(s[i]);\n k:=0;\n for i:=1 to n do\n if s[i]='B' then begin\n if s[i-1]<>'B' then k:=k+1;\n a[k]:=a[k]+1;\n end;\n writeln(k);\n for i:=1 to k do\n write(a[k],' ');\n end."}, {"source_code": "var n,i,k,t:integer;\n a:array[1..100] of integer;\n s:string;\n \nbegin\nreadln(n);\nreadln(s);\nk:=0; t:=0;\nfor i:=1 to n do\nbegin\nif s[i]='B' then k:=k+1;\nif s[i]='W' then \n begin\n if k>0 then t:=t+1;\n if k>0 then a[t]:=k;\n k:=0;\n end;\nend;\nwriteln(t);\nfor i:=1 to t do write(a[i],' ');\nend.\n "}, {"source_code": "var s:string;\n x:char;\n n,block,len,i:byte;\n a:array [1..100] of byte;\nbegin\n readln(n);\n s:='';\n block:=0;\n for i:=1 to n do\n begin\n read(x);\n s:=s+x;\n if (x='B') then\n if (i=1) or ((i>1) and (s[i]<>s[i-1])) then\n begin\n inc(block);\n a[block]:=1;\n end\n else inc(a[block]);\n end;\n if block = 0 then write(0) else\n for i:=1 to block do write(a[i],' ');\n readln;\nend."}, {"source_code": "var i,j,m,n,ans,tot:longint;\n num:array[0..105]of longint;\n s:ansistring;\nbegin\n readln(n);\n readln(s);\n s:='W'+s;\n for i:=2 to length(s) do begin\n if (s[i]='B') and (s[i-1]='W') then begin\n inc(ans);\n tot:=1;\n end else if s[i]='B' then inc(tot) else if (s[i]='W') and (s[i-1]='B') then num[ans]:=tot;\n\n end;\n writeln(ans);\n for i:=1 to ans-1 do write(num[i],' ');\n if ans>0 then writeln(num[ans]);\nend."}, {"source_code": "var i,j,m,n,ans,tot:longint;\n num:array[0..105]of longint;\n s:ansistring;\nbegin\n readln(n);\n readln(s);\n s:='W'+s;\n for i:=2 to length(s) do begin\n if (s[i]='B') and (s[i-1]='W') then begin\n inc(ans);\n tot:=1;\n end else if s[i]='B' then inc(tot) else if (s[i]='W') and (s[i-1]='B') then num[ans]:=tot;\n\n end;\n writeln(ans);\n for i:=1 to ans-1 do write(num[i],' ');\n writeln(num[ans]);\nend."}, {"source_code": "var i,n,m,c:byte;a:array[1..100] of byte;\ns:string;\nbegin\n readln(n);\n read(s);\n c:=0;\n m:=0;\n inc(n);\n s:=s+'e';\n for i:=1 to n do\n begin\n if s[i]='B' then inc(c)\n else\n begin\n \tif c>0 then\n begin\n inc(m);\n a[m]:=c; \n end;\n c:=0;\n end; \n end;\n if m>0 then begin writeln(m);\n for i:=1 to m do write(a[i],' '); end else begin writeln(1);write(0) end;\nend."}, {"source_code": "Var s:string;\n i,n,dem,tam :Integer;\n A:array[1..1000]of Longint;\n \nBegin\nReadln(n);\nReadln(S);dem:=0;tam:=0;\nFor i:=1 to n do\nIf (S[i]='W') and (dem<>0) then \n Begin\n Inc(tam);\n A[tam]:=dem;\n End\nelse Inc(dem);\nWriteln(tam);\nFor i:=1 to tam do\nWrite(A[i],' ');\nEnd."}, {"source_code": "Var s:string;\n i,n,dem,tam :Integer;\n A:array[1..1000]of Longint;\n \nBegin\nReadln(n);\nReadln(S);dem:=0;tam:=0;Insert('W',s,n+1);\nFor i:=1 to n+1 do\nIf (S[i]='W') and (dem<>0) then \n Begin\n Inc(tam);\n A[tam]:=dem;\n dem:=0;\n End\nelse Inc(dem);\nWriteln(tam);\nFor i:=1 to tam do\nWrite(A[i],' ');\nEnd."}, {"source_code": "var q:string; i,j:integer;\nbegin\nreadln(i);\nreadln(q);\nfor i:=1 to length(q )do\nif q[i]='B' then\ninc(j) else\nbegin\nif j<>0 then write(j);\nj:=0;\nend;\nif j<>0 then write(j);\nend.\n"}, {"source_code": "var\n i, n, v, b, e: integer;\n m, s, s1: string;\n\nbegin\n readln(n);\n readln(s);\n s1 := '';\n\n for i := 1 to n do\n if s[i] = 'B' then\n begin\n val(m, b, e);\n if e = 0 then\n b := b + 1;\n str(b, m);\n end\n else\n if m <> '' then\n begin\n s1 := s1 + m + ' ';\n m := '';\n end;\n\n if s[n] = 'B' then\n s1 := s1 + m + ' ';\n v := 0;\n\n for i := 1 to length(s1) do\n if s1[i] = ' ' then\n v := v + 1;\n\n writeln(v);\n writeln(s1);\nend."}, {"source_code": "var\n i, n, v, b, e: integer;\n m, s, s1: string;\n\nbegin\n readln(n);\n readln(s);\n s1 := '';\n m := '0';\n for i := 1 to n do\n if s[i] = 'B' then\n begin\n val(m, b, e);\n if e = 0 then\n b := b + 1;\n str(b, m);\n end\n else\n if m <> '' then\n begin\n s1 := s1 + m + ' ';\n m := '';\n end;\n v := 0;\n for i := 1 to length(s1) do\n if s1[i] = ' ' then\n v := v + 1;\n writeln(v);\n writeln(s1);\nend."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='qc';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n ss,sss:array[0..10000]of string;\n s,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n res64,n64,nn64:int64;\n w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;\n nn,mm,kk,u,v,res,cur,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n ccc:char;\n\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if q=c then exit;\n x:=q+random(c-q+1);\n swap(qc[q,0],qc[x,0]);\n swap(qc[q,1],qc[x,1]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qc[h,0]=qc[h+d,0] then inc(d) else\n if qc[h,0]=c then exit;\n x:=q+random(c-q+1);\n swap(qq[q],qq[x]);\n h:=q; e:=c; d:=1;\n while h+d<=e do\n begin\n if qq[h]=qq[h+d] then inc(d) else\n if qq[h]'W')and(i<=h) do begin\ninc(a[j]);\ninc(i);\nend;\ninc(j);\nend;\nend;\nwriteln(j-1);\nfor i:=1 to j-1 do\nif a[i]<>0 then write(a[i],' ');\nend."}, {"source_code": "const a='B';\n b='W';\nvar n,i,p,k: integer;\n str: string;\n D:array[1..100] of integer;\nbegin\n\nreadln(n);\nreadln(str);\nk:=0;\np:=0;\nfor i:=1 to n do\nbegin\n if (str[i]=a) then\n k:=k+1\n else\n if k>0 then\n begin\n D[i]:=k;\n k:=0;\n end;\nend;\n\nfor i:=1 to n do\nbegin\n if (d[i]>0) then\n inc(p);\nend;\nwriteln(p);\nfor i:=1 to n do\nbegin\n if (d[i]>0) then\n write(D[i],' ');\nend;\n\nend."}, {"source_code": "var a:array[1..100] of longint;\n s:string;\n l,i,n,j,k:longint;\nbegin\nreadln(n);\nreadln(s); \nfor i:=1 to n do\nif s[i]='B' then break else begin Writeln(0); halt; end; \nj:=1;\nfor i:=1 to n do\nbegin\n\nif s[i]='B' then a[j]:=a[j]+1;\nif (s[i]='W') and (i<>n) then j:=j+1; \nend;\nwriteln(j);\nfor i:=1 to j do write(a[i],' ');\nend."}, {"source_code": "var s:string;\ni,a,n,d:longint;\nbegin\nreadln(n);\nreadln(s);\nif s[n]='B' then\ns:=s+'W';\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then inc(a) else begin a:=0; inc(d); end;\nend;\nwriteln(d);\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then inc(a) else begin write(a,' '); a:=0;end;\nend;\nend."}, {"source_code": "var s:string;\ni,a,n,d,q:longint;\nbegin\nreadln(n);\nreadln(s);\nif s[n]='B' then\ns:=s+'W';\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then begin inc(a); q:=1 end else begin a:=0; inc(d); end;\nend;\nif q = 0 then writeln(0)\nelse\nbegin\nwriteln(d);\na:=0;\nfor i:=1 to length(s) do\nbegin\nif s[i]='B' then inc(a) else begin write(a,' '); a:=0;end;\nend;\nend;\nend."}, {"source_code": "{One cross}\nvar n,i,amount,black: integer;\n str: string;\n D: array[1..100] of integer;\nbegin\nreadln(n);\nreadln(str);\nfor i:=1 to n do\nbegin\n if (str[i]='B') then\n black:=black+1\n else\n if black>0 then\n begin\n inc(amount);\n D[amount]:=black;\n black:=0;\n end;\nend;\nif str[n]='B' then\ninc(amount);\nD[amount]:=black;\nwriteln(amount);\nfor i:=1 to amount do\nwrite(D[i],' ');\nreadln;\nend."}, {"source_code": "Program p1;\nvar i, n, k, f:byte;\n a:array [1..100] of char;\n b:array [1..50] of byte;\nbegin\n readln (n);\n for i:=1 to n do\n read (a[i]);\n f:=0;\n k:=0;\n for i:=1 to n do\n begin\n if a[i]='B' then\n if f=0 then\n begin\n f:=1;\n inc (k);\n b[k]:=1;\n end\n else inc (b[k])\n else f:=0;\n end;\n writeln (k);\n for i:=1 to k-1 do\n write (b[i],' ');\n write (b[k]);\nend."}, {"source_code": "var a:string;\ni,n,m,j,i1,hg:integer;\nv:array[1..99999]of integer;\nbegin\nhg:=0;\nM:=0;\nreadln(n);\nreadln(a);\nj:=0;\nhg:=0;\n\nif a[length(a)]='B' then\n for i:=1 to 9999 do\n if v[i]=0 then\n begin\n v[i]:=1;\n hg:=hg+1;\n break;\n end;\n\n\n\nfor i:=1 to 9999 do\n begin\n if a[i]='B' then\n hg:=hg+1;\n \n if a[i]='W' then\n begin\n if hg>0 then\n begin\n j:=j+1;\n v[j]:=hg;\n hg:=0;\n end;\n end;\n end;\n j:=0;\nfor i:=1 to 9999 do\n if v[i]<>0 then\n j:=j+1;\nwrite(j);\nj:=0;\nwriteln;\n\nfor i:=1 to 9999 do\nif v[i]<>0 then\nbegin\n write(v[i]);\n write(' ');\nend;\nend."}, {"source_code": "var a:string;\ni,n,m,j,i1,hg:integer;\nv:array[1..99999]of integer;\nbegin\nhg:=0;\nM:=0;\nreadln(n);\nreadln(a);\nj:=0;\nhg:=0;\n\n\n\n\n\nfor i:=1 to 9999 do\n begin\n if a[i]='B' then\n hg:=hg+1;\n \n if a[i]='W' then\n begin\n if hg>0 then\n begin\n j:=j+1;\n v[j]:=hg;\n hg:=0;\n end;\n end;\n end;\n j:=0;\nfor i:=1 to 9999 do\n if v[i]<>0 then\n j:=j+1;\nwrite(j);\nj:=0;\nwriteln;\nfor i:=1 to 9999 do\nif v[i]<>0 then\nbegin\n write(v[i]);\n write(' ');\nend;\nend."}, {"source_code": "var\n a,b,i,n,j,k:longint;\n x:array[1..111]of longint;\n ch:array[0..111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1;\n if ((ch[i]='W') and (ch[i-1]='B')) or (i=n) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n for i:=1 to a do\n write(x[i],' ');\nend. "}, {"source_code": "var\n a,b,i,n,j,k:longint;\n x:array[1..111111]of longint;\n ch:array[0..111111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1 else\n if ((ch[i]='W') and (ch[i-1]='B')) or ((i=n)and (k>0)) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n\n for i:=1 to a do\n write(x[i],' ');\nend. "}, {"source_code": "var\n a,b,i,n,j,k:longint;\n x:array[1..111111]of longint;\n ch:array[0..111111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1;\n if ((ch[i]='W') and (ch[i-1]='B')) or (((i=n)and (a<>0)) or ((i=n)and (k>0))) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n for i:=1 to a do\n write(x[i],' ');\nend. "}, {"source_code": "var\n a,b,i,n,j,k:longint;\n x:array[1..111111]of longint;\n ch:array[0..111111]of char;\nbegin\n readln(n);\n for i:=1 to n do\n read(ch[i]);\n \n ch[0]:='a';\n k:=0;\n a:=0;\n for i:=1 to n do\n begin\n if ch[i]='B' then k:=k+1;\n if ((ch[i]='W') and (ch[i-1]='B')) or (((i=n)and (a<>0)) or ((i=n)and (k>0))) then begin a:=a+1;x[a]:=k;k:=0;end;\n end;\n writeln(a);\n\n for i:=1 to a do\n write(x[i],' ');\nend. "}, {"source_code": "program ideone;\nvar\n\ts:string;\n\tk,d,i:longint;\n\ta:array[0..100] of longint;\nbegin\n\treadln(s);\n\treadln(s);\n\tk:=0;d:=0;\n\tfor i:=1 to length(s) do\n\tbegin\n\t\t{if kt and (s[i]<>'B') then \n\t\tbegin\n\t\t\tk:=k+1;\n\t\t\ta[k]:=d;\n\t\t\td:=0;\n\t\t\tkt:=false;\n\t\tend;}\n\t\t\n\t\tif s[i]='B' then\n\t\t\tif s[i+1]='B' then d:=d+1\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tk:=k+1;\n\t\t\t\ta[k]:=d+1;\n\t\t\t\td:=0;\n\t\t\tend;\n\tend;\n\twriteln(k);\n\tfor i:=1 to k do write(a[k],' ');\nend."}, {"source_code": "var st:string;\nd,k,j,n,i:byte;\nbegin\n readln(n);\n readln(st);\n i:=1;\n k:=0;\n if st[1]='B' then\n k:=k+1;\n for i:=2 to length(st) do\n if (st[i]='B') and (st[i-1]='W') then\n k:=k+1;\n writeln(k);\n j:=1;\n for i:=1 to k do\n begin\n while st[j]='B' do\n begin\n d:=d+1;\n if j0 then\n write(d,' ');\n d:=0;\n end;\n end. "}, {"source_code": "Var t:string;\n n,i,k1,k2:longint;\nBegin\n readln(n);\n readln(t);\n k1:=0;\n k2:=0;\n For i:=1 to n do\n if t[i]='B' then k1:=k1+1\n else k2:=k2+1;\n writeln(k2);\n writeln(k1);\nEnd.\n "}, {"source_code": "var\n dem, d, i, n : longint ;\n ch : char ;\n ok : boolean ;\n p : array[0..100] of longint ;\n\nbegin\n readln(n) ;\n d := 0 ;\n dem := 0 ;\n ok := false ;\n for i :=1 to n do\n begin\n read(ch) ;\n if (ok = false) and (ch = 'B') then\n begin\n d := 1 ;\n ok := true ;\n continue ;\n end ;\n if ok then\n begin\n if ch = 'B' then inc(d)\n else\n begin\n ok := false ;\n if d <> 0 then begin\n inc(dem) ;\n p[dem] := d ;\n d := 0 ;\n end ;\n end ;\n end ;\n end ;\n if d > 0 then\n begin\n inc(dem) ;\n p[dem] := d ;\n end ;\n\n writeln(dem) ;\n for i := 1 to dem do write(p[dem], ' ') ;\nend ."}], "src_uid": "e4b3a2707ba080b93a152f4e6e983973"} {"source_code": "var n,k,sum,sum1:int64;\n a:array[1..6] of longint;\n i,j,h,d:longint;\n begin\n for i:=1 to 6 do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n sum:=sum div 2;\n for i:=1 to 6 do\n begin\n for j:=1 to 6 do\n begin\n for h:=1 to 6 do\n begin\n if (a[i]+a[j]+a[h]=sum) and ((i<>j) and (i<>h) and (j<>h)) then\n begin\n k:=1;\n a[i]:=0;\n a[j]:=0;\n a[h]:=0;\n break;\n end;\n if k=1 then break;\n end;\n if k=1 then break;\n end;\n if k=1 then break;\n end;\nfor d:=1 to 6 do sum1:=sum1+a[d];\nif (sum1=sum) and (k=1) then write('YES')\n else write('NO');\nend.\n", "positive_code": [{"source_code": "Program eee;\nVar s1: string; a: array [1..100000] of integer; j,sum,f,p,k,i: integer;\nBegin\n readln(s1);\n f:=1; \n For i:= 1 to 6 do\n begin\n a[i]:=ReadIntegerFromString(s1,f);\n sum:=sum+a[i]\n end; \n For i:= 1 to 4 do\n For j:= i+1 to 5 do \n For p:= j+1 to 6 do\n begin \n if (a[i]+a[j]+a[p])=(sum-(a[i]+a[j]+a[p])) then k:=1;\n end;\n If k=1 then writeln('YES') else writeln('NO'); \nend."}, {"source_code": "var a:array[1..6] of integer;\ni,i1,osh,sum:longint;\nbegin\nsum:=0;\nfor i:=1 to 6 do\nbegin\nread(a[i]);\nsum:=sum+a[i];\nend;\nif sum mod 2=1 then osh:=1\nelse\nbegin\nosh:=1;\nfor i:=2 to 6 do\nbegin\nfor i1:=3 to 6 do\nbegin\nif i<>i1 then\nif a[1]+a[i]+a[i1]=sum/2 then \nbegin\nosh:=0;\nbreak;\nend;\nend;\nif osh=0 then break;\nend;\nend;\nif osh=0 then write('Yes') else write('No');\nend."}, {"source_code": "var a1,a2,a3,a4,a5,a6,k:integer; \nbegin \nreadln(a1,a2,a3,a4,a5,a6); \nif a1+a2+a3=a4+a5+a6 then k:=1; \nif a1+a2+a4=a3+a5+a6 then k:=1; \nif a1+a2+a5=a4+a3+a6 then k:=1; \nif a1+a2+a6=a4+a5+a3 then k:=1; \nif a1+a4+a3=a2+a5+a6 then k:=1; \nif a1+a5+a3=a4+a2+a6 then k:=1; \nif a1+a6+a3=a4+a5+a2 then k:=1; \nif a1+a4+a5=a2+a3+a6 then k:=1; \nif a1+a4+a6=a3+a5+a2 then k:=1; \nif a1+a5+a6=a2+a3+a4 then k:=1; \nif k=1 then writeln('YES') else writeln('NO'); \nend."}, {"source_code": "Program sad;\nvar i1,i2,i3,s:integer;\n m:array[1..6] of integer;\nlabel 1;\nbegin\nfor i1:=1 to 6 do\nbegin\nread(m[i1]);\ns:=s+m[i1];\nend;\nif s mod 2=1 then begin writeln('NO'); goto 1; end;\nfor i1:=1 to 4 do\nfor i2:=i1+1 to 5 do\nfor i3:=i2+1 to 6 do\nif (m[i1]+m[i2]+m[i3])=s div 2 then begin writeln('YES'); goto 1; end;\nwriteln('NO');\n1:\nend."}, {"source_code": "Var\na:array[1..6]of integer;\ni:integer;\nBegin\nFor i:=1 to 6 do Read (a[i]);\nif (a[1]+a[2]+a[3])=(a[4]+a[5]+a[6])then writeln('YES')\n else if(a[1]+a[2]+a[4])=(a[3]+a[5]+a[6])then writeln('YES')\n else if(a[1]+a[2]+a[5])=(a[3]+a[4]+a[6])then writeln('YES')\n else if(a[1]+a[2]+a[6])=(a[3]+a[4]+a[5])then writeln('YES')\n else if(a[1]+a[4]+a[3])=(a[5]+a[2]+a[6])then writeln('YES')\n else if(a[1]+a[5]+a[3])=(a[4]+a[2]+a[6])then writeln('YES')\n else if(a[1]+a[6]+a[3])=(a[4]+a[2]+a[5])then writeln('YES')\n else if(a[1]+a[4]+a[5])=(a[3]+a[2]+a[6])then writeln('YES')\n else if(a[1]+a[4]+a[6])=(a[5]+a[2]+a[3])then writeln('YES')\n else if(a[1]+a[5]+a[6])=(a[4]+a[2]+a[3])then writeln('YES')\n else writeln ('NO')\nEnd."}, {"source_code": "Var\na:array[1..6] of integer;\ni:integer;\nBegin\nfor i:=1 to 6 do\nread(a[i]);\nif (a[1]+a[2]+a[3])=(a[4]+a[5]+a[6]) then writeln('YES') else\n if (a[1]+a[2]+a[4])=(a[3]+a[5]+a[6]) then writeln('YES') else\n if (a[1]+a[2]+a[5])=(a[4]+a[3]+a[6]) then writeln('YES') else\n if (a[1]+a[2]+a[6])=(a[4]+a[5]+a[3]) then writeln('YES') else\n if (a[1]+a[4]+a[3])=(a[2]+a[5]+a[6]) then writeln('YES') else\n if (a[1]+a[5]+a[3])=(a[4]+a[2]+a[6]) then writeln('YES') else\n if (a[1]+a[6]+a[3])=(a[4]+a[5]+a[2]) then writeln('YES') else\n if (a[1]+a[5]+a[4])=(a[2]+a[3]+a[6]) then writeln('YES') else\n if (a[1]+a[4]+a[6])=(a[2]+a[5]+a[3]) then writeln('YES') else\n if (a[1]+a[5]+a[6])=(a[4]+a[2]+a[3]) then writeln('YES') else\n writeln('NO');\nEnd."}, {"source_code": "var a:array[1..6] of integer;\nsum, i, l, q, pr: integer;\nbegin\nsum:=0;\nfor i:=1 to 6 do begin read(a[i]);\nsum:=sum+a[i];\nend;\nif sum mod 2=1 then write('NO') else begin\nsum:=sum div 2;\npr:=0;\nfor i:=1 to 4 do begin\nfor l:=i+1 to 5 do\nfor q:=l+1 to 6 do\nif a[i]+a[l]+a[q]=sum then begin \npr:=1; break; break; break;\nend;\nend;\nif pr=0 then write('NO') else write('YES');\nend;\nend."}, {"source_code": "Program AA;\nvar sum,u,j,a,b,c,i,n:longint;\n s:array[1..100]of longint;\n\n\n\nbegin\nfor i:=1 to 6 do\n begin\n read(s[i]);\n sum:=sum+s[i]; \n end;\n\na:=0;\nb:=1; \nfor i:=1 to 4 do\n for j:=i+1 to 5 do\n for u:=j+1 to 6 do\n begin\n if sum-s[i]-s[j]-s[u]=s[i]+s[j]+s[u] then\n a:=1;\n end;\n \n \nif a=b then\n writeln('YES') else\n writeln('NO');\n\n\n\n\nend."}, {"source_code": "program asd;\n\nconst MAX=6;\n\nvar\n\n a:ARRAY[1..MAX] of integer;\n i,j,k,s,check:integer;\n\nbegin\n s:=0;\n\n readln(a[1],a[2],a[3],a[4],a[5],a[6]);\n\n for i:=1 to 6 do s:=s+a[i];\n\n check:=0;\n\n for i:=1 to MAX do\n begin\n for j:=1 to MAX do\n begin\n for k:=1 to MAX do\n begin\n if ((i<>j) and (i<>k) and (j<>k)) then\n begin\n if (a[i]+a[j]+a[k] = s-a[i]-a[j]-a[k]) then\n begin\n //writeln(i,j,k);\n check:=1;\n end;\n end;\n end;\n end;\n end;\n\n if (check=1) then write('YES')\n else write('NO');\n\n //readln();\nend.\n"}, {"source_code": "var a:array [1..6] of integer;\nb:array[1..216] of integer;\ns,i,j,k,n:integer;\nbegin\ns:=0;\nfor i:=1 to 6 do\nbegin\nread(a[i]);\ns:=s+a[i];\nend;\nn:=1;\nfor i:=1 to 6 do\nfor j:=1 to 6 do\nfor k:=1 to 6 do\nbegin\nif(i<>j) and (j<>k) and (i<>k) then\nbegin\nb[n]:= a[i]+a[j]+a[k];\nn:=n+1;\nend;\nend;\nn:=0;\nfor i:=1 to 120 do\nif (s-b[i]=b[i]) then\nn:=n+1;\nif (n=0) then\nwrite('no') else\nwrite('yes');\nend."}, {"source_code": "Var a:array[1..6] of integer;\ni,k,ii:integer;\nBegin\nfor i:=1 to 6 Do \nread(a[i]);\nIf (a[1]+a[2]+a[3]=a[4]+a[5]+a[6]) or (a[1]+a[2]+a[4]=a[3]+a[5]+a[6]) or \n (a[1]+a[2]+a[5]=a[4]+a[3]+a[6]) or (a[1]+a[2]+a[6]=a[4]+a[5]+a[3]) or\n (a[1]+a[4]+a[3]=a[2]+a[5]+a[6]) or (a[1]+a[5]+a[3]=a[4]+a[2]+a[6]) or\n (a[1]+a[6]+a[3]=a[4]+a[5]+a[2]) or (a[4]+a[2]+a[3]=a[1]+a[5]+a[6]) or\n (a[5]+a[2]+a[3]=a[4]+a[1]+a[6]) or (a[6]+a[2]+a[3]=a[4]+a[5]+a[1]) then\n writeln('YES') else writeln('NO');\n\nEnd."}, {"source_code": "var\na: integer;\nb: integer;\nc: integer;\nd: integer;\ne: integer;\nf: integer;\nbegin\nreadln(a,b,c,d,e,f);\nif (a+b+c = d+e+f) then println('YES')\nelse if (a+b+d = c+e+f) then println('YES')\nelse if (a+b+e = c+d+f) then println('YES')\nelse if (a+b+f = c+d+e) then println('YES')\nelse if (a+c+d = b+e+f) then println('YES')\nelse if (a+c+e = b+d+f) then println('YES')\nelse if (a+c+f = b+d+e) then println('YES')\nelse if (a+d+e = b+c+f) then println('YES')\nelse if (a+d+f = b+c+e) then println('YES')\nelse if (a+e+f = b+c+d) then println('YES')\nelse println('NO');\nend."}, {"source_code": "var i:integer;\n a:array[1..10] of integer;\nbegin\nfor i:=1 to 6 do\n read(a[i]);\nif (a[1]+a[2]+a[3]=a[4]+a[5]+a[6]) or (a[1]+a[2]+a[4]=a[3]+a[5]+a[6])\nor (a[1]+a[2]+a[5]=a[3]+a[4]+a[6]) or (a[1]+a[2]+a[6]=a[3]+a[4]+a[5]) \nor (a[1]+a[3]+a[4]=a[2]+a[5]+a[6]) or (a[1]+a[3]+a[5]=a[2]+a[4]+a[6]) \nor (a[1]+a[3]+a[6]=a[2]+a[4]+a[5]) or (a[1]+a[4]+a[5]=a[2]+a[3]+a[6]) \nor (a[1]+a[4]+a[6]=a[2]+a[3]+a[5]) or (a[1]+a[5]+a[6]=a[2]+a[3]+a[4]) then write('YES') else write('NO') \nend."}, {"source_code": "var x1,x2,x3,x4,x5,x6:longint;\nbegin \n read(x1,x2,x3,x4,x5,x6);\n if x1+x2+x3=x4+x5+x6 then begin write('YES');halt;end;\n if x1+x2+x4=x3+x5+x6 then begin write('YES');halt;end;\n if x1+x2+x5=x4+x3+x6 then begin write('YES');halt;end; \n if x1+x2+x6=x4+x5+x3 then begin write('YES');halt;end;\n if x1+x4+x3=x2+x5+x6 then begin write('YES');halt;end; \n if x1+x5+x3=x4+x2+x6 then begin write('YES');halt;end;\n if x1+x6+x3=x4+x5+x2 then begin write('YES');halt;end;\n if x1+x4+x5=x2+x3+x6 then begin write('YES');halt;end;\n if x1+x4+x6=x2+x5+x3 then begin write('YES');halt;end;\n if x1+x5+x6=x4+x2+x3 then begin write('YES');halt;end; \n write('NO');\n end."}, {"source_code": "\n const eps=0.0000000001; besk1=200000008; nn=200000;\n label 1,2;\n type real=extended; {string=ansistring;}\n mas=array [-100..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var p,tt,time,y,z,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n mask,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n x,aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200000] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=6;\n for i:=1 to n do read(a[i]);\n\n ot:=0; for i:=1 to n do ot:=ot+a[i];\n\n for mask:=0 to 63 do\n begin\n p:=mask;\n tt:=0; t:=0;\n for i:=1 to 6 do begin\n x[i]:=p and 1; p:=p shr 1; end;\n for i:=1 to 6 do t:=t+x[i];\n for i:=1 to 6 do tt:=tt+a[i]*x[i];\n\n { writeln('mask= ',mask,' tt= ',tt);\n } if (tt=ot-tt)and(t=3) then begin writeln('YES'); goto 1; end;\n\n end;\n\n writeln('NO');\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "program mqwerty;\nvar mass: array [1..6] of longint;\ni,j,kol,sum:longint;\nprocedure swap(var a,b:longint);\nvar t: longint;\nbegin\n t:=a;\n a:=b;\n b:=t;\nend;\n\nbegin\n for i:=1 to 6 do begin\n read(mass[i]);\n sum:=sum+mass[i];\n end;\n if sum mod 2 =1 then writeln('NO') else\n begin\n kol:=0;\n \n for i:=0 to 215 do\n begin\n if (mass[(i mod 6)+1]+mass[((i div 6) mod 6)+1]+ mass[(i div 36)+1]=sum div 2\n )\n and ((i mod 6)+1<>((i div 6) mod 6)+1)\n and (((i div 6) mod 6)+1<>(i div 36)+1)\n and ((i div 36)+1<>(i mod 6)+1)then\n inc(kol);\n end;\n if kol>0 then writeln('YES') else writeln('NO');\n end;\nend."}, {"source_code": "var a:array[1..6] of integer; s,i,j,k:integer;\n begin\n s:=0;\n for i:=1 to 6 do begin read(a[i]); s:=s+a[i]; end;\n if s mod 2 = 1 then begin writeln('NO'); exit; end;\n for i:=1 to 4 do\n for j:=i to 5 do\n for k:=j+1 to 6 do \n if (i<>j) and (j<>k) and (k<>i) then if a[i]+a[j]+a[k]=s div 2 then begin writeln('YES'); exit; end;\n writeln('NO');\n end."}, {"source_code": "var\n \n i, j, k: integer;\n sum: longint;\n x: boolean;\n a: array[1..6] of longint;\n\nbegin\n\n for i := 1 to 6 do \n begin\n read(a[i]);\n sum := sum + a[i];\n end;\n for i := 1 to 6 do\n for j := i + 1 to 6 do\n for k := j + 1 to 6 do\n begin\n if a[i] + a[j] + a[k] = sum - (a[i] + a[j] + a[k]) then\n x := true;\n end;\n \n if x = true then\n writeln('YES')\n else\n writeln('NO');\n \n \nend."}, {"source_code": "var a,b,c,a1,b1,c1:longint;\nbegin\nread(a,b,c,a1,b1,c1);\nif (a+b+c=a1+b1+c1) or (a+b+a1=c+b1+c1) or (a+b+c1=c+a1+b1)or\n(a+b+b1=c+a1+c1) or (a+c+a1=b+c1+b1) or (a+c+b1=b+c1+a1) or\n(a+c+c1=b+a1+b1) or (a+b1+c1=b+c+a1) or (a+a1+c1=b+c+b1) or\n(a+a1+b1=b+c+c1) then\nwriteln('YES')\nelse\nwriteln('NO');\nend. {}"}, {"source_code": "var\ni,s,h,j,f:integer;\na:array[1..6] of integer;\nbegin\ns:=0;\nf:=0;\nfor i:=1 to 6 do begin\nread(a[i]);\ns:=s+a[i];\nend;\nif (s mod 2)=0 then s:=s div 2 else begin write('NO');\nexit end;\nfor i:=1 to 3 do \nfor j:=i+1 to 5 do\nfor h:=j+1 to 6 do\nif a[i]+a[j]+a[h]=s then f:=1;\nif f=1 then begin write('YES');\nexit end;\nif f=0 then write('NO');\nend.\n"}, {"source_code": "var\ni,j,k,sum:integer;\na:array [1..6] of integer;\nlog:boolean;\nbegin\nread (a[1]);\nread (a[2]);\nread (a[3]);\nread (a[4]);\nread (a[5]);\nread (a[6]);\nsum:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6];\nfor i:=1 to 6 do\nbegin\nif log=true then break;\n for j:=1 to 6 do\n begin\nif log=true then break;\n for k:=1 to 6 do\n if (i<>j) and (j<>k) and (i<>k) then if a[i]+a[j]+a[k]=sum/2 then log:=true;\nend;\nend;\nif log=FALSE then write('NO') else write('YES');\nend."}, {"source_code": "const n=6;\nvar a:array[1..n] of integer;\n i,s,j,m:integer;\n f:boolean;\nBegin\n f:=true;\n for i:=1 to n do begin\n read(a[i]);\n s:=s+a[i];\n end; \n for i:=1 to n do if a[i]>s-a[i] then f:=false;\n \n if (s mod 2=0) and (f=true) then begin\n f:=false;\n for i:=1 to n-2 do begin\n for j:=i+1 to n-1 do begin\n for m:=j+1 to n do begin\n if a[i]+a[j]+a[m]=s div 2 then f:=true;\n end;\n end;\n end;\n end\n else f:=false;\n if f=false then writeln('NO') else writeln('YES');\nEnd."}, {"source_code": "var a:array[1..100]of integer;i,j,l,s,t:integer;\nbegin\nfor i:=1 to 6 do\nbegin\nread(a[i]);\ns+=a[i];\nend;\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nif (a[i]+a[j]+a[l])*2=s then t:=1;\nif t=1 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var a:array[1..6]of integer;\n i,i1,i2,i3,i4,i5,i6:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do read(a[i]);\nfor i1:=1 to 6 do\nfor i2:=1 to 6 do\nif i1<>i2 then\nfor i3:=1 to 6 do\nif (i3<>i2)and(i3<>i1) then\nfor i4:=1 to 6 do\nif (i4<>i3)and(i4<>i2)and(i4<>i1)then\nfor i5:=1 to 6 do\nif (i5<>i4)and(i5<>i3)and(i5<>i2)and(i5<>i1)then\nfor i6:=1 to 6 do\nif (i6<>i5)and(i6<>i4)and(i6<>i3)and(i6<>i2)and(i6<>i1)then\nif ((a[i1]+a[i2]+a[i3]-a[i4]-a[i5]-a[i6])=0)then f:=true;\nif f then write('YES')else write('NO');\nend."}, {"source_code": "program AAA;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n a, b, c, d, e, f: integer;\nbegin\n readln(a, b, c, d, e, f);\n if(a + b + c = d + e + f) or (a + e + c = d + b + f) or (a + d + c = b + e + f)\n or (a + f + c = d + e + b) or (d + b + c = a + e + f) or (e + b + c = d + a + f)\n or (f + b + c = d + e + a) or (a + b + d = c + e + f) or (a + b + e = d + c + f)\n or (a + b + f = d + e + c) then writeln('YES')\n else writeln('NO');\nend.\n"}, {"source_code": "program ad1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, k, sum: integer;\n cnt: array[0..7] of integer;\n check: boolean;\n\nbegin\n sum := 0;\n for i := 1 to 6 do begin\n read(cnt[i]);\n inc(sum, cnt[i]);\n end; \n\n check := false;\n\n for i := 1 to 4 do\n for j := i + 1 to 5 do\n for k := j + 1 to 6 do\n if (cnt[i] + cnt[j] + cnt[k] = sum div 2) then\n check := true;\n \n if (sum mod 2 = 1) then\n check := false;\n\n if (check) then\n writeln('YES')\n else\n writeln('NO');\n readln; readln;\nend.\n"}, {"source_code": "type mass=array[1..6]of integer;\nvar m:mass;\n t:text;\n i,j,k:integer;\n s1,s2:longint;\n f:boolean;\nfunction prov(i,j,k:integer):boolean;\nvar m1:mass;\n ii:integer;\nbegin\n m1:=m;\n s1:=m[i]+m[j]+m[k];\n m1[i]:=0;\n m1[j]:=0;\n m1[k]:=0;\n s2:=0;\n for ii:=1 to 6 do\n s2:=s2+m1[ii];\n prov:=s1=s2\nend;\nbegin\n{ assign(t,'input.txt');\n reset(t);}\n for i:=1 to 6 do\n read(m[i]);\n{ close(T); }\n f:=false;\n for i:=1 to 6 do\n for j:=i+1 to 6 do\n for k:=j+1 to 6 do\n if prov(i,j,k)\n then begin\n f:=true;\n break\n end;\n if f\n then writeln('YES')\n else writeln('NO')\nend."}, {"source_code": "program project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\nvar\n i, j, sum, k: integer;\n a: array [1..6] of integer;\n z: boolean = false;\n\nbegin\n sum := 0;\n for i := 1 to 6 do begin\n read(a[i]);\n inc(sum, a[i]);\n end;\n for i := 1 to 6 do\n for j := 1 to 6 do\n for k := 1 to 6 do begin\n if (i <> j) and (j <> k) and (i <> k) then begin\n if ((a[i] + a[j] + a[k]) * 2 = sum) then\n z := true;\n end;\n end;\n if (z) then\n writeln('YES')\n else\n writeln('NO');\n readln;\n readln;\nend."}, {"source_code": "program firsttt;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n i, j, sum, k: integer;\n a: array[1..6] of integer;\n\nbegin\n sum := 0;\n for i := 1 to 6 do begin\n read(a[i]);\n inc(sum, a[i]);\n end;\n\n for i := 1 to 6 do begin\n for j := i + 1 to 6 do\n for k := j + 1 to 6 do\n if (a[i] + a[j] + a[k] = sum - (a[i] + a[j] + a[k])) then begin\n writeln('YES');\n halt(0);\n end;\n end;\n writeln('NO'); \nend."}, {"source_code": "program zadachaCCCCC;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, q, w, e, k, s: Integer;\n a: array[1..10] of integer;\n\nbegin\n s := 0;\n for i := 1 to 6 do\n read(a[i]);\n for i := 1 to 6 do\n for j := i + 1 to 6 do\n for k := j + 1 to 6 do\n begin\n for q := 1 to 6 do\n if (q <> i) and (q <> j) and (q <> k) then\n s := s + a[q];\n if (a[i] + a[j] + a[k] = s) then\n begin\n Writeln('YES');\n Exit;\n end;\n s := 0;\n end;\n Writeln('NO');\n readln;\n readln;\nend.\n"}, {"source_code": "var m:array[1..6] of integer; i,j,h,s:integer; a:boolean;\nbegin\ns:=0; a:=false;\n for i:=1 to 6 do\n begin\n read(m[i]); s:=s+m[i]\n end;\nif s mod 2 = 1 then writeln('NO') else \n begin\n for i:=1 to 4 do\n for j:=i+1 to 5 do\n for h:=j+1 to 6 do\n if m[i]+m[j]+m[h] = s div 2 then a:=true;\n \n if a = true then writeln('YES') else writeln('NO') \n end;\n \nend."}, {"source_code": "var a:array[1..6] of longint;\n f:text;\n i,j,k,dem,n,s,dau:longint;\nbegin\n //assign(f,'eralto.inp');reset(f);\n for i:=1 to 6 do begin read(a[i]);s:=s+a[i]; end;\n for i:=1 to 6 do\n for j:=1 to 6 do\n for k:=1 to 6 do\n if (i<>j) and (j<>k) and (k<>i) and (a[i]+a[j]+a[k]=s div 2) and (s mod 2=0) then\n begin\n dau:=1;\n break;\n end;\n if dau=1 then write('YES') else write('NO');\n // close(f);\n // readln\nend."}, {"source_code": "var a:array[1..10] of longint;\n i,k,j,s:Longint;\nbegin\n for i:=1 to 6 do\n read(a[i]);\n for i:=1 to 6 do\n s:=s+a[i];\n\n if s mod 2=1\n then begin\n writeln('NO');\n exit;\n end;\n for i:=1 to 4 do\n for k:=i+1 to 5 do\n for j:=k+1 to 6 do\n if (a[i]+a[k]+a[j])=s div 2\n then begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var a,b,c,d,e,f:integer;\nbegin\n read(a,b,c,d,e,f);\n if ((a+b+c=d+e+f)or(a+b+d=c+e+f)or(a+b+e=c+d+f)or(a+b+f=c+d+e)or(a+c+d=b+e+f)or(a+c+e=b+d+f)or(a+c+f=b+e+d)or(a+d+e=b+c+f)or(a+d+f=b+c+e)or(a+e+f=b+c+d)) then\n writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var\n\ta:array[1..6] of integer;\n\ti:integer;\nbegin\t\n\tfor i:=1 to 6 do begin\n\t\tread(a[i]);\n\t\t\n\tend;\n\tif ((a[1]+a[2]+a[3])=(a[4]+a[5]+a[6])) or\n\t\t((a[1]+a[2]+a[4])=(a[3]+a[5]+a[6])) or\n\t\t((a[1]+a[2]+a[5])=(a[4]+a[3]+a[6])) or\n\t\t((a[1]+a[2]+a[6])=(a[4]+a[5]+a[3])) or \n\t\t((a[1]+a[3]+a[4])=(a[2]+a[5]+a[6])) or \n\t\t((a[1]+a[3]+a[5])=(a[4]+a[2]+a[6])) or \n\t\t((a[1]+a[3]+a[6])=(a[4]+a[5]+a[2])) or \n\t\t((a[1]+a[4]+a[5])=(a[3]+a[2]+a[6])) or \n\t\t((a[1]+a[4]+a[6])=(a[3]+a[5]+a[2])) or \n\t\t((a[1]+a[5]+a[6])=(a[4]+a[2]+a[3]))\n\t\tthen writeln('YES')\n\telse writeln('NO');\nend.\n"}, {"source_code": "var\n s1, s2, i, k, j, z: integer;\n a: array[1..6] of integer;\n\nbegin\n s1 := 0;\n s2 := 0;\n for i := 1 to 6 do \n begin\n read(a[i]);\n s1 := s1 + a[i];\n end;\n if s1 mod 2 = 1 then writeln('NO') else begin\n for i := 1 to 4 do\n for k := i + 1 to 5 do\n for j := k + 1 to 6 do \n begin\n for z := 1 to 6 do\n if (z <> i) and (z <> k) and (z <> j) then s2 := s2 + a[z];\n if (s2 = s1 div 2) and (a[i] + a[k] + a[j] = s1 div 2) then begin writeln('YES'); exit; end;\n s2:=0;\n end;\n writeln('NO');\n end;\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n oo=trunc(1e9+7);\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a:array[1..6] of longint;\n ok:boolean;\n sum:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure bt(i,j,s:longint);\n begin\n if j=3 then\n begin\n if s*2=sum then ok:=true;\n exit;\n end;\n if i=7 then exit;\n bt(i+1,j,s);\n bt(i+1,j+1,s+a[i]);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n for i:=1 to 6 do read(fi,a[i]);\n for i:=1 to 6 do sum:=sum+a[i];\n bt(1,0,0);\n if ok then write(fo,'YES') else write(fo,'NO');\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n\n"}, {"source_code": "var\na:array[1..6]of integer;\ni:integer;\nbegin\nfor i:= 1 to 6 do\nread(a[i]);\nif(a[1]+a[2]+a[3]=a[4]+a[5]+a[6])or(a[1]+a[2]+a[4]=a[3]+a[5]+a[6])or\n(a[1]+a[2]+a[5]=a[4]+a[3]+a[6])or(a[1]+a[2]+a[6]=a[4]+a[5]+a[3])or\n(a[1]+a[4]+a[3]=a[2]+a[5]+a[6])or(a[1]+a[5]+a[3]=a[4]+a[2]+a[6])or\n(a[1]+a[6]+a[3]=a[4]+a[5]+a[2])or(a[4]+a[2]+a[3]=a[1]+a[5]+a[6])or\n(a[5]+a[2]+a[3]=a[4]+a[1]+a[6])or(a[6]+a[2]+a[3]=a[4]+a[5]+a[1])then\nwriteln('YES')\nelse writeln('NO');\nend."}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1,k1,n1,j1:integer;\nbegin\nn1:=0;\nj1:=0;\nk1:=0;\nl:=0;\nfor i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\nif l mod 2=0 then\nbegin\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nfor j1:=1 to 6 do\nfor k1:=1 to 6 do \nfor n1:=1 to 6 do\nbegin\nif m>0 then\nbreak\nelse\nif (a[j]+a[k]+a[n]= a[j1]+a[k1]+a[n1]) and (j<>k) and (n<>k) and (j1<>k) and (k1<>k) and (n1<>k) and (n<>j) and (j1<>j) and (k1<>j) and (n1<>j) and (j1<>n) and (k1<>n) and (n1<>n) and (n1<>j1) and (n1<>k1) and (k1<>j1) then\nbegin\ninc(m);\nbreak;\nend;\nend;\nif m=1 then\nwriteln('YES');\nif m<1 then\nwriteln('NO')\nend\nelse\nwriteln('no');\nend."}, {"source_code": "var\n a: array[1..6]of integer;\n i, s, n, j, z: integer;\n fl: boolean;\n\nbegin\n n := 6;\n for i := 1 to n do\n begin\n read(a[i]);\n s := s + a[i];\n end;\n fl := false;\n if s mod 2 = 0 then\n begin\n for i := 1 to n do\n for j := i + 1 to n do\n for z := j + 1 to n do\n if a[i] + a[j] + a[z] = s div 2 then \n begin\n fl := true;\n break;\n end;\n end;\n if fl then writeLn('yes')\n else writeLn('no');\nend."}, {"source_code": "var \na:array [1..7] of integer; \ni:integer; \nbegin \nfor i:=1 to 6 do \nread(a[i]); \nif (a[1]+a[2]+a[3]=a[4]+a[5]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[2]+a[4]=a[3]+a[5]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[2]+a[5]=a[3]+a[4]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[2]+a[6]=a[3]+a[4]+a[5]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[3]+a[4]=a[2]+a[5]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[3]+a[5]=a[2]+a[4]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[3]+a[6]=a[2]+a[4]+a[5]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[4]+a[5]=a[2]+a[3]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[4]+a[6]=a[2]+a[3]+a[5]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[5]+a[6]=a[2]+a[3]+a[4]) then begin \nwriteln('YES'); \nexit; \nend \nelse writeln('NO'); \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend."}, {"source_code": "var A, B: array[1..6] of integer;\n i, j, sum, select, num: integer;\n ans: string;\n\nprocedure binary(n: integer);\nvar i, du: integer;\nbegin\n i:=6; du:=0;\n while n<>0 do\n begin\n du:=n mod 2;\n n:=n div 2;\n B[i]:=du; dec(i);\n end;\nend;\n\nbegin\n for i:=1 to 6 do\n begin\n read(A[i]);\n sum:=sum+A[i];\n end;\n readln; ans:='NO';\n for i:=0 to 63 do\n begin\n binary(i); select:=0; num:=0;\n for j:=1 to 6 do\n if B[j]=1 then\n begin\n select:=select+A[j];\n inc(num);\n end;\n if ((2*select=sum) and (num=3)) then\n begin\n ans:='YES';\n break;\n end;\n end;\n write(ans);\nend."}, {"source_code": "var\nsum, sum2,sum3,i:integer;\na: array [1..6] of integer;\nbegin\nfor i:=1 to 6 do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\nif sum mod 2=1 then writeln('NO')\nelse \n begin\n sum2:=sum div 2-a[1];\n sum3:=sum2-a[2];\n if ((sum3=a[3]) or (sum3=a[4]) or (sum3=a[5]) or (sum3=a[6])) then writeln('YES')\n else\n begin\n sum3:=sum2-a[3];\n if ((sum3=a[4]) or (sum3=a[5]) or (sum3=a[6])) then writeln('YES')\n else \n begin\n sum3:=sum2-a[4];\n if ((sum3=a[5]) or (sum3=a[6]) or (sum2=a[5]+a[6])) then writeln('YES')\n else writeln('NO');\n end;\n end;\n end;\nend."}, {"source_code": "var \n a:array [1..7] of integer; \n i:integer; \nbegin \n for i:=1 to 6 do \n read(a[i]); \n if (a[1]+a[2]+a[3]=a[4]+a[5]+a[6]) then begin \n writeln('YES'); \n exit; \n end \n else \n begin \n if (a[1]+a[2]+a[4]=a[3]+a[5]+a[6]) then begin \n writeln('YES'); \n exit; \n end \n else \n begin \n if (a[1]+a[2]+a[5]=a[3]+a[4]+a[6]) then begin \n writeln('YES'); \n exit; \n end \n else \n begin \n if (a[1]+a[2]+a[6]=a[3]+a[4]+a[5]) then begin \n writeln('YES'); \n exit; \n end \n else \n begin \n if (a[1]+a[3]+a[4]=a[2]+a[5]+a[6]) then begin \n writeln('YES'); \n exit; \n end \n else \n begin \n if (a[1]+a[3]+a[5]=a[2]+a[4]+a[6]) then begin \n writeln('YES'); \n exit; \nend \nelse \nbegin \nif (a[1]+a[3]+a[6]=a[2]+a[4]+a[5]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[4]+a[5]=a[2]+a[3]+a[6]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[4]+a[6]=a[2]+a[3]+a[5]) then begin \nwriteln('YES'); \nexit; \nend \nelse \nbegin \nif (a[1]+a[5]+a[6]=a[2]+a[3]+a[4]) then begin \nwriteln('YES'); \nexit; \nend \nelse writeln('NO'); \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend; \nend."}, {"source_code": "program Ann;\nlabel l1;\nvar n,m,i,j,b,c,k:integer;\na:array[1..6]of integer;\nbegin\nfor i:=1 to 6 do\n read(a[i]);\nif((a[1] + a[2] + a[3] + a[4] + a[5] + a[6]) mod 2 = 0)then\n m:=(a[1] + a[2]+a[3] + a[4] + a[5] + a[6]) div 2\nelse\n begin\n writeln('NO');\n goto l1;\n end;\nc:=0;\nfor i:=1 to 6 do\n begin\n if(c = 1)then\n break;\n for j:=1 to 6 do\n begin\n if(c = 1)then\n break;\n for k:=1 to 6 do\n begin\n if(i <> j)and(j <> k)and(k <> i)then\n if(a[i] + a[j] + a[k] = m)then\n begin\n c:=1;\n break;\n end;\n end;\n end;\n end;\nif(c = 0)then\n writeln('NO')\nelse\n writeln('YES');\nl1:\nend."}, {"source_code": "var\n a : array [1..6] of integer;\n i : integer;\nbegin\n for i := 1 to 6 do\n read(a[i]);\n if((a[1]+a[2]+a[3])=(a[4]+a[5]+a[6])) or\n\t\t((a[1]+a[2]+a[4])=(a[3]+a[5]+a[6])) or\n\t\t((a[1]+a[2]+a[5])=(a[4]+a[3]+a[6])) or\n\t\t((a[1]+a[2]+a[6])=(a[4]+a[5]+a[3])) or \n\t\t((a[1]+a[3]+a[4])=(a[2]+a[5]+a[6])) or \n\t\t((a[1]+a[3]+a[5])=(a[4]+a[2]+a[6])) or \n\t\t((a[1]+a[3]+a[6])=(a[4]+a[5]+a[2])) or \n\t\t((a[1]+a[4]+a[5])=(a[3]+a[2]+a[6])) or \n\t\t((a[1]+a[4]+a[6])=(a[3]+a[5]+a[2])) or \n\t\t((a[1]+a[5]+a[6])=(a[4]+a[2]+a[3])) then \n\t\twriteln('YES')\n\telse \n\t writeln('NO');\nend.\n "}, {"source_code": "var\n i, j, k, l, t, h : integer;\n a : array [ 1..6 ] of integer;\nbegin\n for i := 1 to 6 do\n read( a[ i ] );\n for i := 1 to 6 do\n for j := 1 to 6 do\n if ( i <> j )\n then\n for k := 1 to 6 do\n if ( k <> i ) and ( k <> j )\n then\n for l := 1 to 6 do\n if ( l <> i ) and ( l <> j ) and ( l <> k )\n then\n for t := 1 to 6 do\n if ( t <> i ) and ( t <> j ) and ( t <> k ) and ( t <> l )\n then\n for h := 1 to 6 do\n if ( h <> i ) and ( h <> j ) and ( h <> k ) and ( h <> l ) and ( h <> t )\n then\n if ( a[ i ] + a[ j ] + a[ k ] = a[ l ] + a[ t ] + a[ h ] )\n then\n begin\n writeln( 'YES' );\n halt;\n end;\n writeln( 'NO' );\nend."}, {"source_code": "const fin='';\n fout='';\nvar f,g:Text;\n i,j,k,qa:longint;\n a:array[1..8] of longint;\nprocedure xl;\nbegin\n for i:=1 to 4 do\n for j:=i+1 to 5 do\n for k:=j+1 to 6 do\n if a[i]+a[j]+a[k]=qa-(a[i]+a[j]+a[k])then\n begin\n write(g,'YES');\n exit;\n end;\n write(g,'NO');\nend;\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n qa:=0;\n for i:=1 to 6 do\n begin\n read(f,a[i]);\n qa:=qa+a[i];\n end;\n xl;\n close(f);\n close(g);\n\nend."}, {"source_code": "var a:array[1..10] of longint;\n i,k,j,s:Longint;\nbegin\n for i:=1 to 6 do begin\n read(a[i]);\n s:=s+a[i];\n end;\n if s mod 2=1\n then begin\n writeln('NO');\n exit;\n end;\n for i:=1 to 4 do\n for k:=i+1 to 5 do\n for j:=k+1 to 6 do\n if (a[i]+a[k]+a[j])=s div 2\n then begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "{$MACRO ON}\n{$MODE OBJFPC}\n{$COPERATORS ON}\n{$DEFINE wait:=readln;readln;}\n{$DEFINE maxN:=trunc(1e5)+1}\n\nuses gvector,garrayutils,math;\nconst\tfi='';\n\t\tfo='';\ntype\n\tTType = int32; // <------ TYPE\n\tvector = specialize TVector;\n compare = class\n \tpublic\n \tclass function c(a,b : TType) : boolean;\n end;\n utils = specialize TOrderingArrayUtils;\nclass function compare.c(a,b : TType) : boolean;\n\tbegin Result := aTrue)\n then x:=True; \n end;\n\t if x then write('YES') else write('NO');\nend.\n\n"}, {"source_code": "var a:array[1..6] of integer;\nb,i,j,n:integer;\nbegin\nn:=0;\nfor i:=1 to 6 do begin\nread(a[i]);\nb:=b+a[i];end;\nif (b mod 2<>0) then begin write('NO');exit;end\nelse b:=(b div 2)-a[1];\nfor i:=2 to 6 do\nfor j:=3 to 6 do\nif (i<>j) and (a[i]+a[j]=b) and (n=0) then begin write('YES');n:=1;break;end;\nif n=0 then write('NO');\nend."}, {"source_code": "var a:array[1..6] of integer;\n i,n : integer;\n l : boolean;\nbegin\n n:=6;\n l:=false;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to 10 do\n if a[1]+a[2]+a[3]=a[4]+a[5]+a[6] then l:=true\n else if a[1]+a[2]+a[4]=a[3]+a[5]+a[6] then l:=true\n else if a[1]+a[2]+a[5]=a[4]+a[3]+a[6] then l:=true\n else if a[1]+a[2]+a[6]=a[4]+a[5]+a[3] then l:=true\n else if a[1]+a[3]+a[4]=a[2]+a[5]+a[6] then l:=true\n else if a[1]+a[3]+a[5]=a[4]+a[2]+a[6] then l:=true\n else if a[1]+a[3]+a[6]=a[4]+a[2]+a[5] then l:=true\n else if a[1]+a[4]+a[5]=a[2]+a[6]+a[3] then l:=true\n else if a[1]+a[4]+a[6]=a[2]+a[3]+a[5] then l:=true\n else if a[1]+a[5]+a[6]=a[2]+a[3]+a[4] then l:=true;\n if l then writeln('YES')\n else writeln('NO');\nend."}, {"source_code": "var \na,b,c,d,f,e,m,s:integer; \nBegin \nreadln(a,b,c,d,e,f); \n\nS:=(a+b+c+d+f+e);\nm:=s div 2;\n if ( s mod 2 <>0) THEN WRITELN('no')\n else if (a+b+c=m) then WRITELN('YES')\n else if (a+c+d=m) then WRITELN('YES')\n else if (a+f+d=m) then WRITELN('YES')\n else if (a+f+e=m) then WRITELN('YES')\n else if (a+b+d=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n else if (a+d+e=m) then WRITELN('YES')\n else if (a+b+f=m) then WRITELN('YES')\n else if (a+b+e=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n \n \n \n \n else if (b+c+d=m) then WRITELN('YES')\n else if (b+d+f=m) then WRITELN('YES')\n else if (b+f+e=m) then WRITELN('YES')\n else if (b+c+f=m) then WRITELN('YES')\n else if (b+d+e=m) then WRITELN('YES')\n \n \n else if (c+d+f=m) then WRITELN('YES')\n else if (c+f+e=m) then WRITELN('YES')\n else if (c+d+e=m) then WRITELN('YES')\n \n \n \n else if (d+f+e=m) then WRITELN('YES')\n \n else if (c+f+e=m) then WRITELN('YES')\n else writeln('NO')\n end.\n \n "}, {"source_code": "var\n i,j,F,K,D:longint; a,P,R:array[0..6] of integer;\nbegin\n for i:=1 to 6 do read(a[i]);\n FOR I:=0 TO 6 DO\n P[I]:=I;\n WHILE P[0]=0 DO\n BEGIN\n FOR I:=1 TO 6 DO\n IF (A[P[1]]+A[P[2]]+A[P[3]])=(A[P[4]]+A[P[5]]+A[P[6]]) THEN F:=1;\n J:=6;\n WHILE P[J-1] > P[J] DO\n J:=J-1;\n K:=6;\n WHILE P[J-1] > P[K] DO\n K:=K-1;\n D:=P[J-1];\n P[J-1]:=P[K];\n P[K]:=D;\n FOR I:=J TO 6 DO\n R[I]:=P[6-(I-J)];\n FOR I:=J TO 6 DO\n P[I]:=R[I];\n END;\n IF F=1 THEN WRITELN('YES') ELSE WRITELN('NO');\nEND."}, {"source_code": "program pr1;\nvar s,G,B,K,i:integer;A:ARRAY[1..100000] OF INTEGER;\nbegin\n s:=0;B:=0;\n for i:=1 to 6 do begin\n read(a[i]);\n s:=s+a[i];\n end;\n if (s mod 2 =0) then begin\n for i:=1 to 6 do begin\n for g:=1 to 6 do begin\n for k:=1 to 6 do begin\n if (a[i]+a[g]+a[k]=(s div 2)) and (k<>i) and (k<>g) and (g<>i) then b:=1;\n end;\n end;\n end;\n end;\n if B=1 then writeln('YES')\n ELSE WRITELN('NO');\nend."}, {"source_code": "var a: array[1..6] of integer;\nvar s,i,f:integer;\nbegin\ns:=0;\nfor i:=1 to 6 do begin\nread(a[i]); s:=s+a[i];\nend;\nif (s mod 2=0) then\nif (a[1]+a[2]+a[3]=a[4]+a[5]+a[6]) \nor (a[1]+a[2]+a[4]=a[3]+a[5]+a[6])\nor (a[1]+a[2]+a[5]=a[3]+a[4]+a[6])\nor (a[1]+a[2]+a[6]=a[3]+a[4]+a[5])\nor (a[1]+a[3]+a[4]=a[2]+a[5]+a[6])\nor (a[1]+a[3]+a[5]=a[2]+a[4]+a[6])\nor (a[1]+a[3]+a[6]=a[2]+a[4]+a[5])\nor (a[1]+a[4]+a[5]=a[2]+a[3]+a[6])\nor (a[1]+a[4]+a[6]=a[2]+a[3]+a[5])\nor (a[1]+a[5]+a[6]=a[2]+a[3]+a[4]) then f:=1; \n\nif f=0 then writeln('NO')\nelse writeln('YES');\nend."}, {"source_code": "var a,b,c,d,e,f:integer;\n\nbegin\n\n readln(a,b,c,d,e,f);\n if a+b+c=d+e+f then\n writeln('YES')\n else\n if a+b+d=c+e+f then\n writeln('YES')\n else\n if a+b+e=c+d+f then\n writeln('YES')\n else\n if a+b+f=c+e+d then\n writeln('YES')\n else\n if a+d+c=b+e+f then\n writeln('YES')\n else\n if a+e+c=b+d+f then\n writeln('YES')\n else\n if a+f+c=b+d+e then\n writeln('YES')\n else\n if d+b+c=a+e+f then\n writeln('YES')\n else\n if e+b+c=a+d+f then\n writeln('YES')\n else\n if f+b+c=d+e+a then\n writeln('YES')\n else\n writeln('NO')\nend."}, {"source_code": "program qq;\nvar i,j,k,t:integer;\nq,d:real;\na:array[1..6]of real;\nbegin\nfor i:=1 to 6 do\nbegin\nread(a[i]);\nq:=q+a[i];\nend;\nq:=q/2;\nfor i:=1 to 4 do \nfor j:=i+1 to 5 do\nfor k:=j+1 to 6 do\nbegin\nd:=a[i]+a[j]+a[k];\nif d=q then \nt:=t+1;\nend;\nif t=0 then writeln('No') else writeln('Yes');;\nend."}, {"source_code": "program ya;\nvar x,y,z,s,i,j,k,l,m,n:longint;\n f:array[0..6] of longint;\nbegin\n for i:=1 to 6 do\n begin\n read(f[i]);\n inc(f[0],f[i]);\n end;\n if odd(f[0]) then\n begin\n writeln('NO');\n exit;\n end;\n for i:=1 to 4 do\n for j:=i+1 to 5 do\n for k:=j+1 to 6 do\n if f[i]+f[j]+f[k]=f[0] div 2 then\n begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend."}, {"source_code": "var a, b, c, d, e, f, g, k, z: integer;\nq: array[1..6] of integer;\nbegin\nfor a:= 1 to 6 do\nbegin\nread(q[a]);\nend;\n\nfor b:= 1 to 6 do\nbegin\n for c:= 1 to 6 do\n begin\n if (c <> b) then\n begin\n for d:= 1 to 6 do\n begin\n if (c <> d) and (d <> b) then\n for e:= 1 to 6 do\n if (e <> b) and (e <> c) and (e <> d) and (e <> f) and (e <> g) then\n for f:= 1 to 6 do\n if (f <> b) and (f <> c) and (f <> d) and (f <> e) and (f <> g) then\n for g:= 1 to 6 do\n if (g <> b) and (g <> c) and (g <> d) and (g <> f) and (g <> e) then\n if (q[b] + q[c] + q[d] = q[e] + q[f] + q[g]) and (k <> 1) then\n begin\n write('Yes');\n k:= 1;\n end;\n {else\n begin\n if (k <> 1) and (z <> 1) then\n begin\n write('No');\n z:= 1;\n end;}\n end;\n end;\nend;\nend;\nif (k <> 1) then\nwrite('No');\nend.\n\n \n\n"}, {"source_code": "program ex;\nvar\n a:array[1..6] of integer;\n i:integer;\nbegin\n for i:=1 to 6 do read(a[i]);\n \n if ((a[1]+a[2]+a[3])=(a[4]+a[5]+a[6])) or \n ((a[1]+a[2]+a[4])=(a[3]+a[5]+a[6])) or \n ((a[1]+a[2]+a[5])=(a[4]+a[3]+a[6])) or\n ((a[1]+a[2]+a[6])=(a[4]+a[5]+a[3])) or\n ((a[1]+a[4]+a[3])=(a[2]+a[5]+a[6])) or\n ((a[1]+a[4]+a[5])=(a[2]+a[3]+a[6])) or\n ((a[1]+a[3]+a[5])=(a[4]+a[2]+a[6])) or\n ((a[1]+a[4]+a[6])=(a[2]+a[3]+a[5])) or\n ((a[1]+a[3]+a[6])=(a[2]+a[4]+a[5])) or\n ((a[1]+a[5]+a[6])=(a[2]+a[3]+a[4])) \n then write('YES')\n else write('NO');\nend. \n "}, {"source_code": "var\nsum, sum2,sum3,i:integer;\na: array [1..6] of integer;\nbegin\nfor i:=1 to 6 do\n begin\n read(a[i]);\n sum:=sum+a[i];\n end;\nif sum mod 2=1 then writeln('NO')\nelse \n begin\n sum2:=sum div 2-a[1];\n sum3:=sum2-a[2];\n if ((sum3=a[3]) or (sum3=a[4]) or (sum3=a[5]) or (sum3=a[6])) then writeln('YES')\n else\n begin\n sum3:=sum2-a[3];\n if ((sum3=a[4]) or (sum3=a[5]) or (sum3=a[6])) then writeln('YES')\n else \n begin\n sum3:=sum2-a[4];\n if ((sum3=a[5]) or (sum3=a[6]) or (sum2=a[5]+a[6])) then writeln('YES')\n else writeln('NO');\n end;\n end;\n end;\nend."}, {"source_code": "var\nj,c,n,i,sum,sum1:longint;\na:array[-100..10000]of longint;\nbol:boolean;\nbegin\nn:=6;\nfor i:=1 to n do begin\n read(a[i]);\n sum:=sum+a[i];\nend;\nfor i:=1 to n-2 do begin\n for j:=i+1 to n-1 do begin\n for c:=j+1 to n do begin\n if (i<>j)and(j<>c)and(i<>c) then begin\n sum1:=a[i]+a[j]+a[c];\n if sum-sum1=sum1 then bol:=true;\n end;\n end;\n end;\nend;\nif bol then writeln('YES')\nelse\nwriteln('NO');\nend.\n"}, {"source_code": "program cf886a;\nuses math;\nvar A: array[1..6] of Int64;\n sum, i, j, k: integer;\nbegin\n for i := 1 to 6 do Read(A[i]);\n sum := sumInt(A);\n if (sum mod 2 <> 0) then WriteLn('NO')\n else\n begin\n sum := sum div 2;\n for i := 1 to 6 do\n begin\n for j := i + 1 to 6 do\n begin\n for k := j + 1 to 6 do\n begin\n if (A[i] + A[j] + A[k]) = sum then\n begin\n WriteLn('YES');\n exit;\n end;\n end;\n end;\n end;\n WriteLn('NO');\n end;\n exit;\nend."}, {"source_code": "var a:array [1..6] of integer;\nvar i,x,y,z,k,n:integer;\nbegin\n \n for i:=1 to 6 do begin\n read(a[i]);\n n:=n+a[i];\n end; \n \n for x:=1 to 6 do begin\n for y:=1 to 6 do begin\n for z:=1 to 6 do begin\n if ((x<>y) and(x<>z) and (y<>z) and (2*(a[x]+a[y]+ a[z])=n)) then\n k:=1;\n end;\n end;\n end;\n \n if k=1 then\n writeln('YES')\n else\n writeln('NO');\nend."}, {"source_code": "Var\n Sum: Int64;\n a: Array [1..6] of Int64;\n\nBegin\n For Var i := 1 to 6 do Begin\n Read(a[i]);\n Sum += a[i]\n End;\n If Sum mod 2 = 0 then Begin\n For Var i := 1 to 4 do\n For Var j := i + 1 to 5 do\n For Var k := j + 1 to 6 do\n If a[i] + a[j] + a[k] = Sum div 2 then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\n End\n Else\n Write('NO')\nEnd."}, {"source_code": "var \na,b,c,d,f,e,m,s:integer; \nBegin \nreadln(a,b,c,d,e,f); \n\nS:=(a+b+c+d+f+e);\nm:=s div 2;\n if ( s mod 2 <>0) THEN WRITELN('no')\n else if (a+b+c=m) then WRITELN('YES')\n else if (a+c+d=m) then WRITELN('YES')\n else if (a+f+d=m) then WRITELN('YES')\n else if (a+f+e=m) then WRITELN('YES')\n else if (a+b+d=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n else if (a+d+e=m) then WRITELN('YES')\n else if (a+b+f=m) then WRITELN('YES')\n else if (a+b+e=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n \n \n \n \n else if (b+c+d=m) then WRITELN('YES')\n else if (b+d+f=m) then WRITELN('YES')\n else if (b+f+e=m) then WRITELN('YES')\n else if (b+c+f=m) then WRITELN('YES')\n else if (b+d+e=m) then WRITELN('YES')\n \n \n else if (c+d+f=m) then WRITELN('YES')\n else if (c+f+e=m) then WRITELN('YES')\n else if (c+d+e=m) then WRITELN('YES')\n \n \n \n else if (d+f+e=m) then WRITELN('YES')\n \n else if (c+f+e=m) then WRITELN('YES')\n else writeln('NO')\n end.\n \n "}, {"source_code": "program a1;\n var i,max,min: integer;\n a: array [1..6] of integer;\nbegin\n for i:=1 to 6 do\n begin\n read(a[i]);\n end;\n if ((a[1]+a[2]+a[3])=(a[4]+a[5]+a[6])) or ((a[1]+a[2]+a[4])=(a[3]+a[5]+a[6])) or ((a[1]+a[2]+a[5])=(a[3]+a[4]+a[6])) or ((a[1]+a[2]+a[6])=(a[3]+a[4]+a[5])) or ((a[1]+a[3]+a[4])=(a[2]+a[5]+a[6])) or ((a[1]+a[3]+a[5])=(a[2]+a[4]+a[6])) or ((a[1]+a[3]+a[6])=(a[2]+a[4]+a[5])) or ((a[1]+a[4]+a[5])=(a[2]+a[3]+a[6])) or ((a[1]+a[4]+a[6])=(a[2]+a[3]+a[5])) or ((a[1]+a[5]+a[6])=(a[2]+a[3]+a[4]))\n then writeln('YES')\n else writeln('NO');\nend. \n "}, {"source_code": "var x,i,j,k,n,s,p:integer;\na:array[1..6]of integer;\nf:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin\nread(x);\na[i]:=x;\ns:=s+x;\nend;\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor p:=j+1 to 6 do\nif (a[i]+a[j]+a[p]=s/2) then\nbegin writeln('YES'); exit; end;\nwriteln('NO');\nend.\n"}], "negative_code": [{"source_code": "program aaa;\nvar a: array [1..6] of integer;\n i,j,l,k,s: integer;\nbegin\n s:=0;\n for i:=1 to 6 do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n if s mod 2<>0 then writeln('no')\n else\n begin\n k:=0;\n for i:=1 to 6 do\n for j:=1 to 6 do\n for l:=1 to 6 do\n if (i<>j) and (j<>l) and (l<>i) then\n if a[i]+a[j]+a[l]=s div 2 then k:=1;\n end;\n if k=1 then writeln('yes')\n else writeln('no');\nend.\n "}, {"source_code": "Program k;\nvar\na : array [0..6] of integer;\ni,j,x,y,n:integer;\nbegin\ni:=0;\nread(a[1],a[2],a[3],a[4],a[5],a[6]);\n\nif a[1]+a[2]+a[3]=a[4]+a[5]+a[6] then i:=1;\n\n\n\n\nif a[1]+a[2]+a[4]=a[3]+a[5]+a[6] then i:=1;\n\nif a[1]+a[2]+a[5]=a[4]+a[3]+a[6] then i:=1;\n\nif a[1]+a[2]+a[6]=a[4]+a[5]+a[3] then i:=1;\nif a[1]+a[4]+a[3]=a[2]+a[5]+a[6] then i:=1;\n\nif a[1]+a[5]+a[3]=a[4]+a[2]+a[6] then i:=1;\n\nif a[1]+a[6]+a[3]=a[4]+a[5]+a[2] then i:=1;\nif a[4]+a[2]+a[3]=a[1]+a[5]+a[6] then i:=1;\n\nif a[5]+a[2]+a[3]=a[4]+a[1]+a[6] then i:=1;\n\nif a[6]+a[2]+a[3]=a[4]+a[5]+a[1] then i:=1;\n\n\n\n\n\nif a[1]+a[4]+a[5]=a[2]+a[3]+a[6] then i:=1;\n\nif a[1]+a[4]+a[6]=a[2]+a[5]+a[3] then i:=1;\nif a[4]+a[5]+a[3]=a[1]+a[2]+a[6] then i:=1;\n\nif a[4]+a[2]+a[6]=a[1]+a[5]+a[3] then i:=1;\n\nif a[4]+a[6]+a[3]=a[1]+a[5]+a[2] then i:=1;\n\nif a[4]+a[2]+a[5]=a[1]+a[3]+a[6] then i:=1;\n\n\nif a[1]+a[5]+a[6]=a[4]+a[2]+a[3] then i:=1;\n\n\n\n\nif a[5]+a[2]+a[6]=a[4]+a[1]+a[3] then i:=1;\n\nif a[5]+a[6]+a[3]=a[4]+a[1]+a[2] then i:=1;\n\n\nEnd.\n\n"}, {"source_code": "var a1,a2,a3,a4,a5,a6:integer;\nbegin\nread(a1,a2,a3,a4,a5,a6);\n if (a1>=0) and (a1<=1000) and (a2>=0) and (a2<=1000) and (a3>=0) and (a3<=1000) and (a4>=0) and (a4<=1000) and (a5>=0) and (a5<=1000) and (a6>=0) and (a6<=1000) then\n begin\n if (a1+a2+a3=a4+a5+a6) then writeln('YES')\n else\n if (a4+a2+a3=a1+a5+a6) then writeln('YES')\n else\n if (a1+a5+a3=a4+a2+a6) then writeln('YES')\n else\n if (a4+a5+a3=a1+a2+a6) then writeln('YES')\n else\n if (a1+a2+a6=a4+a5+a3) then writeln('YES')\n else\n if (a4+a2+a6=a1+a5+a3) then writeln('YES')\n else\n if (a1+a5+a6=a4+a2+a3) then writeln('YES')\n else\n writeln('NO');\n end\n else writeln('������');\nend."}, {"source_code": "var \na,b,c,d,f,e,m,s:integer; \nBegin \nreadln(a,b,c,d,e,f); \n\nS:=(a+b+c+d+f+e);\nm:=s div 2;\n if ( s mod 2 <>0) THEN WRITELN('no')\n else if (a+b+c=m) then WRITELN('YES')\n else if (a+c+d=m) then WRITELN('YES')\n else if (a+f+d=m) then WRITELN('YES')\n else if (a+f+e=m) then WRITELN('YES')\n else if (a+b+d=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n else if (a+d+e=m) then WRITELN('YES')\n else if (a+b+f=m) then WRITELN('YES')\n else if (a+b+e=m) then WRITELN('YES')\n else if (a+c+f=m) then WRITELN('YES')\n \n \n \n \n else if (b+c+d=m) then WRITELN('YES')\n else if (b+d+f=m) then WRITELN('YES')\n else if (b+f+e=m) then WRITELN('YES')\n else if (b+c+f=m) then WRITELN('YES')\n else if (b+d+e=m) then WRITELN('YES')\n \n \n else if (c+d+f=m) then WRITELN('YES')\n else if (c+f+e=m) then WRITELN('YES')\n else if (c+d+e=m) then WRITELN('YES')\n \n \n \n else if (d+f+e=m) then WRITELN('YES')\n \n else if (c+f+e=m) then WRITELN('no')\n \n end.\n \n "}, {"source_code": "var p,d,k:integer;\na: array[1..6] of integer;\nb: array[1..7] of integer;\nflag:array[1..6] of boolean;\nfunction prov:boolean;\n var f,o,s:integer;\n begin\n for o:=1 to 6 do if flag[o] then f:=f+a[o];\n for o:=1 to 6 do if flag[o]=false then s:=s+a[o];\n if s=f then prov:= true\n else prov:= false;\n end;\nprocedure search(x,q: integer);\nvar i:integer;\nbegin\n if q<3 \n then\n begin\n for i:=x {1} to 6 do\n if flag[i]=false then \n begin\n b[q]:=a[i];\n flag[i]:=true;\n search(i+1,q+1);\n flag[i]:=false;\n end;\n end\n else \n begin\n if prov then d:=d+1;\n p:=p+1;\n end; \n end;\nbegin\nfor d:=1 to 6 do read(a[d]);\nd:=0;\nsearch(a[1],1);\nif d=0 then writeln('NO')\n else writeln('YES');\nend."}, {"source_code": "Program sad;\nvar i1,i2,i3,s:integer;\n m:array[1..6] of integer;\nbegin\nfor i1:=1 to 6 do\nbegin\nread(m[i1]);\ns:=s+m[i1];\nend;\nfor i1:=1 to 6 do\nfor i2:=i1+1 to 6 do\nfor i3:=i2+1 to 6 do\nif (m[i1]+m[i2]+m[i3])=s div 2 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "Program sad;\nvar i1,i2,i3,s:integer;\n m:array[1..6] of integer;\nlabel 1;\nbegin\nfor i1:=1 to 6 do\nbegin\nread(m[i1]);\ns:=s+m[i1];\nend;\nfor i1:=1 to 6 do\nfor i2:=i1+1 to 6 do\nfor i3:=i2+1 to 6 do\nif (m[i1]+m[i2]+m[i3])=s div 2 then begin writeln('YES'); goto 1; end;\nwriteln('NO');\n1:\nend."}, {"source_code": "var a,b:array[1..1000] of integer;\ni,n,k,s,j,m:integer;\nbegin\nk:=0;\nfor i:=1 to 6 do\nread(a[i]);\nfor i:=1 to 6 do\ns:=s+a[i]; \nfor i:=1 to 4 do\nbegin\nfor j:=2 to 6 do\nbegin\nfor m:=3 to 6 do\nbegin\nif (i=j)or(i=m)or(j=m) then else if (s/2=a[i]+a[j]+a[m]) then begin k:=k+1; break end;\nend;\n\nend; \na[i]:=0;\nend;\nif k=0 then write('NO') else write('YES');\n\nend."}, {"source_code": "var a,b:array[1..1000] of integer;\ni,n,k,s,j:integer;\nbegin\nfor i:=1 to 6 do\nread(a[i]);\nfor i:=1 to 6 do\ns:=s+a[i]; \n\nfor i:=1 to 10 do begin\nfor j:=1 to 5 do begin\nif (i=j) and (j+1=i) then else begin\nb[i]:=a[i]+a[j]+a[j+1];\nend;\nend;\nend;\nfor i:=1 to 10 do begin\nif b[i]=s/2 then k:=k+1;\nend;\nif k=0 then write('NO') else write('YES');\nend."}, {"source_code": "var a,b:array[1..1000] of integer;\ni,n,k,s,j:integer;\nbegin\nfor i:=1 to 6 do\nread(a[i]);\nfor i:=1 to 6 do\ns:=s+a[i]; \n\nfor i:=1 to 6 do begin\nfor j:=1 to 10 do begin\nif (i=j) or (j+1=i) then else begin\nb[j]:=a[i]+a[j]+a[j+1];\nend;\nend;\nend;\nfor i:=1 to 10 do begin\nif b[i]=s/2 then k:=k+1;\nend;\nif k=0 then write('NO') else write('YES');\nend."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 5 do\n For Var j := 1 to 6 - i do\n If m[j] > m[j + 1] then\n Swap(m[j], m[j + 1]);\n If m[1] + m[2] + m[6] = m[3] + m[4] + m[5] then\n Write('YES')\n Else Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 6 do\n For Var j := 2 to 6 do\n For Var l := 3 to 6 do\n For Var p := 4 to 6 do\n For Var q := 5 to 6 do\n For Var s := 6 to 6 do\n If m[i] + m[j] + m[l] = m[p] + m[q] + m[s] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 6 do\n For Var j := 2 to 6 do\n For Var l := 3 to 6 do\n For Var i1 := 4 to 6 do\n For Var j1 := 5 to 6 do\n For Var l1 := 6 to 6 do\n If m[i] + m[j] + m[l] = m[i1] + m[j1] + m[l1] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 6 do\n For Var j := 1 to 5 do\n For Var l := 1 to 4 do\n For Var i1 := 1 to 3 do\n For Var j1 := 1 to 2 do\n For Var l1 := 1 to 1 do\n If m[i] + m[j] + m[l] = m[i1] + m[j1] + m[l1] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 1 do\n For Var j := 1 to 2 do\n For Var l := 1 to 3 do\n If m[i] + m[j] + m[l] = m[i+3] + m[j+3] + m[l+3] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 1 do\n For Var j := 2 to 3 do\n For Var l := 3 to 4 do\n If m[i] + m[j] + m[l] = m[i + 2] + m[j + 2] + m[l + 2] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 1 do\n For Var j := 1 to 2 do\n For Var l := 1 to 3 do\n For Var i1 := 1 to 4 do\n For Var j1 := 1 to 5 do\n For Var l1 := 1 to 6 do\n If m[i] + m[j] + m[l] = m[i1] + m[j1] + m[l1] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "Var \n m: array [1..6] of Word;\n \nBegin\n For Var i := 1 to 6 do\n Read(m[i]);\n For Var i := 1 to 6 do\n For Var j := 2 to 6 do\n For Var l := 3 to 6 do\n If m[i] + m[j] + m[l] = m[7 - i] + m[7 - j] + m[7 - l] then Begin\n Write('YES');\n Exit\n End;\n Write('NO')\nEnd."}, {"source_code": "var\na:array [1..6] of word;\ni,j,k,s:byte;\nt:boolean;\nbegin\nfor i:=1 to 6 do begin\nread(a[i]);\ns:=s+a[i];\nend;\nif s mod 2=0 then \nfor i:=1 to 4 do\n for j:=i+1 to 5 do\n for k:=j+1 to 6 do\n if a[i]+a[k]+a[j]=(s div 2) then t:=true;\nif t=true then writeln('YES') else writeln ('NO');\nend. "}, {"source_code": "Var\n a : array of Integer;\n c, sum, i : Integer;\nBegin\n a := new integer[6];\n Readln(a[1],a[2],a[3],a[4],a[5],a[0]);\n Sort(a);\n Reverse(a);\n sum := a[0];\n For i := 1 to 5 do\n begin\n If sum >= 0 then begin Dec(sum,a[i]); Inc(c); end else Inc(sum,a[i]);\n end;\n If (sum = 0) and (c = 3) then Writeln('YES') else Writeln('NO');\nEnd."}, {"source_code": "var\ni,j,k,sum:integer;\na:array [1..6] of integer;\nlog:boolean;\nbegin\nread (a[1]);\nread (a[2]);\nread (a[3]);\nread (a[4]);\nread (a[5]);\nread (a[6]);\nsum:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6];\nfor i:=1 to 6 do\nbegin\nif log=true then break;\n for j:=1 to 6 do\n begin\nif log=true then break;\n for k:=1 to 6 do\n if (i<>j) and (j<>k) and (i<>k) then if a[1]+a[j]+a[k]=k/2 then log:=true;\nend;\nend;\nif log=FALSE then write('NO') else write('YES');\nend."}, {"source_code": "var a: array[1..6] of integer; i, i2, i3, x, s: integer;\n\n\nbegin\n for i:=1 to 6 do read(a[i]);\n s:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6];\n if s mod 2 = 0 then begin\n for i:=1 to 2 do begin\n for i2:=3 to 4 do begin\n for i3:=5 to 6 do begin\n if a[i]+a[i2]+a[i3]=(s/2) then inc(x);\n \n end;\n end;\n end;\n for i:=1 to 4 do begin\n if a[i]+a[i+1]+a[i+2]=(s/2) then inc(x); end; \n if x>=2 then writeln('YES') else writeln('NO');\n end\n else writeln('NO');\n \n\nend."}, {"source_code": "var a: array[1..6] of integer; i, i2, i3, x, s: integer;\n\n\nbegin\n for i:=1 to 6 do read(a[i]);\n s:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6];\n if s mod 2 = 0 then begin\n for i:=1 to 2 do begin\n for i2:=3 to 4 do begin\n for i3:=5 to 6 do begin\n if a[i]+a[i2]+a[i3]=(s/2) then inc(x);\n \n end;\n end;\n end;\n if x=2 then writeln('YES') else writeln('NO');\n end\n else writeln('NO');\n \n\nend."}, {"source_code": "const n=6;\nvar a:array[1..n] of integer;\n i,s,j,m:integer;\n f:boolean;\nBegin\n f:=true;\n for i:=1 to n do begin\n read(a[i]);\n s:=s+a[i];\n end; \n for i:=1 to n do if a[i]>=s-a[i] then f:=false;\n \n if (s mod 2=0) and (f=true) then begin\n f:=false;\n for i:=1 to n-2 do begin\n for j:=i+1 to n-1 do begin\n for m:=j+1 to n do begin\n if a[i]+a[j]+a[m]=s div 2 then f:=true;\n end;\n end;\n end;\n end\n else f:=false;\n if f=false then writeln('NO') else writeln('YES');\nEnd."}, {"source_code": "program nomer;\nvar a: array [1..6] of integer;\nvar i, i1, i2, n, n1, n2, b1, b2, b3, b4, b5, b6: integer;\nbegin;\nfor i:=1 to 6 do begin;\nread (n);\na[i]:= n;\nend;\nb1:= a[1];\nb2:= a[2];\nb3:= a[3];\nb4:= a[4];\nb5:= a[5];\nb6:= a[6];\nfor i:=1 to 6 do n1:= n1 + a[i];\nn2:= n1 div 2;\nif (n2 <> n1/2) then writeln ('NO')\nelse begin;\nif (b1 > b2+b3+b4+b5+b6) or (b2 > b1+b3+b4+b5+b6) or (b3 > b1+b2+b4+b5+b6) or (b4 > b1+b2+b3+b5+b6) or (b5 > b1+b2+b3+b4+b6) or (b6 >b1+b2+b3+b4+b5) or (b1+b2 > b3+b4+b5+b6) or (b1+b3 > b2+b4+b5+b6) or (b1+b4 > b2+b3+b5+b6) or (b1+b5 > b2+b3+b4+b6) or (b1+b6 > b2+b3+b4+b5) or (b2+b3 > b1+b4+b5+b6) or (b2+b4 > b1+b3+b5+b6) or (b2+b5 > b1+b3+b4+b6) or (b2+b6 > b1+b3+b4+b5) or (b3+b4 > b1+b2+b5+b6) or (b3+b5 > b1+b2+b4+b6) or (b3+b6 > b1+b2+b4+b5) or (b4+b5 > b1+b2+b3+b6) or (b4+b6 > b1+b2+b3+b5) or (b5+b6 > b1+b2+b3+b4) then writeln ('NO')\nelse writeln ('YES');\nend;\nend."}, {"source_code": "Program eee;\nVar s1: string; a: array [1..100000] of integer; j,sum,f,p,k,i: integer;\nBegin\n readln(s1);\n f:=1; \n For i:= 1 to 6 do\n begin\n a[i]:=ReadIntegerFromString(s1,f);\n writeln(a);\n sum:=sum+a[i]\n end; \n For i:= 1 to 4 do\n For j:= i+1 to 5 do \n For p:= j+1 to 6 do\n begin \n if (a[i]+a[j]+a[p])=(sum-(a[i]+a[j]+a[p])) then k:=1;\n end;\n If k=1 then writeln('YES') else writeln('NO'); \nend."}, {"source_code": "var\n\n\n\n\nsum,i,x,j,z: longint;\na: array [1..6] of longint;\n\n\nBEGIN\n sum:=0;\n for i:=1 to 6 do begin read(a[i]); sum:=sum + a[i]; end;\n\n for i:=1 to 4 do\n for j:=i+1 to 5 do\n for z:=j+1 to 6 do\n if a[i]+a[j]+a[z] = sum - a[i]+a[j]+a[z] then begin writeln('YES'); halt; end;\n writeln('NO');\n\n\nEND.\n"}, {"source_code": "var i,j,k:Longint;\n\ta:array[0..2000] of Longint;\nbegin\n\tfor i:=1 to 6 do\n\tbegin\n\t\tread(k);\n\t\tinc(a[k]);\n\t\tfor j:=0 to 1000 do\n\t\t\tif (a[j]>0) and (j<>k) then\n\t\t\t\tinc(a[j+k]);\n\tend;\n\tfor i:=0 to 1000 do\n\tif (a[i] mod 2=0) and (a[i]>0) then begin writeln('YES'); exit; end;\n\twriteln('NO');\nend."}, {"source_code": "var i,j,s,k:Longint;\n\ta:array[1..6] of Longint;\nbegin\n\ts:=0;\n\tfor i := 1 to 6 do\n\tbegin\n\t\tread(a[i]);\n\t\ts:=s+a[i];\n\tend;\n\ts:=s div 2;\n\tfor i:=1 to 4 do\n\t\tbegin\n\t\t\tfor j:=i+1 to 5 do\n\t\t\tfor k:=j+1 to 6 do\n\t\t\tif a[i]+a[j]+a[k]=s then\n\t\t\t\tbegin\n\t\t\t\t\twriteln('YES');\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\tend;\n\twriteln('NO');\nend."}, {"source_code": "var i,j,k:Longint;\n\ta:array[0..2000] of Longint;\nbegin\n\tfor i:=1 to 6 do\n\tbegin\n\t\tread(k);\n\t\tfor j:=0 to 1000 do\n\t\t\tif a[j]>0 then\n\t\t\t\tinc(a[j+k]);\n\tend;\n\tfor i:=0 to 1000 do\n\tif (a[i] mod 2=0) and (a[i]>0) then begin writeln('YES'); exit; end;\n\twriteln('NO');\nend."}, {"source_code": "\n const eps=0.0000000001; besk1=200000008; nn=200000;\n label 1,2;\n type real=extended; {string=ansistring;}\n mas=array [-100..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var p,tt,time,y,z,pmax,imax,p1,p2,p3,p4,t,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n mask,step, k,ii,i,j:longint;\n aa,bb,cc:double;\n x,aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200000] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n n:=6;\n for i:=1 to n do read(a[i]);\n\n ot:=0; for i:=1 to n do ot:=ot+a[i];\n\n for mask:=0 to 63 do\n begin\n p:=mask;\n tt:=0;\n for i:=1 to 6 do begin\n x[i]:=p and 1; p:=p shr 1; end;\n\n for i:=1 to 6 do tt:=tt+a[i]*x[i];\n\n { writeln('mask= ',mask,' tt= ',tt);\n } if tt=ot-tt then begin writeln('YES'); goto 1; end;\n\n end;\n\n writeln('NO');\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) or (m[2]+m[3]+m[6]=m[1]+m[4]+m[5]) then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) or (m[2]+m[3]+m[6]=m[1]+m[4]+m[5]) or (m[1]+m[6]+m[5]=m[4]+m[3]+m[2]) or (m[2]+m[6]+m[5]=m[1]+m[3]+m[4]) then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or\n (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or\n (m[1]+m[6]+m[5]=m[4]+m[3]+m[2]) or\n (m[2]+m[3]+m[6]=m[1]+m[4]+m[5]) or\n (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) or\n (m[2]+m[6]+m[5]=m[1]+m[3]+m[4]) or\n (m[1]+m[6]+m[2]=m[5]+m[3]+m[2])\n then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or\n (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or\n (m[1]+m[6]+m[5]=m[4]+m[3]+m[2]) or\n (m[1]+m[6]+m[2]=m[5]+m[3]+m[2]) or\n (m[2]+m[3]+m[6]=m[1]+m[4]+m[5]) or\n (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) or\n (m[2]+m[6]+m[5]=m[1]+m[3]+m[4]) or\n (m[3]+m[6]+m[5]=m[1]+m[2]+m[4]) or\n (m[2]+m[6]+m[4]=m[1]+m[2]+m[5])\n then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var m: array [1..6] of integer; \ni,k,j:integer;\nbegin\n\nfor i:= 1 to 6 do\nread(m[i]);\n\n\nfor i:=1 to 5 do begin\n for j:=1 to 6-i do begin\n if m[j]>m[j+1] then begin\n k:=m[j];\n m[j]:=m[j+1];\n m[j+1]:=k;\n end;\n end;\nend;\n\n\n if (m[1]+m[6]+m[3]=m[4]+m[5]+m[2]) or (m[1]+m[6]+m[4]=m[3]+m[5]+m[2]) or (m[2]+m[4]+m[6]=m[1]+m[3]+m[5]) or (m[2]+m[3]+m[6]=m[1]+m[4]+m[5]) or (m[1]+m[6]+m[5]=m[4]+m[3]+m[2]) then write('Yes')\n else write('No');\n\n\nend."}, {"source_code": "var\n b, c, d, i, n, k, i1, j, p,i2: integer;\n o:real;\n a: array [1..100000] of int64;\n\nbegin\n for i := 1 To 6 Do begin \n Read(a[i]); o := o + a[i] end;\n o:=o/2;\n k:=0;\n for i := 1 To 6 Do\n for i1 := 2 To 6 Do\n for i2 := 3 To 6 Do\n if a[i] + a[i1] + a[i2] = o then k := 1;\n if k = 1 then writeln('YES')\n else \n writeln('NO')\nend."}, {"source_code": "program ph;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, j, sum, k: integer;\n a: array[1..6] of integer;\nbegin\n sum := 0;\n for i := 1 to 6 do begin\n read(a[i]);\n sum := sum + a[i];\n end;\n\n for i := 1 to 6 do\n for j := 1 to 6 do\n for k := 1 to 6 do\n if (a[i] + a[j] + a[k] = (sum div 2)) and (i <> j) and (j <> k) and (i <> k) then begin\n writeln('YES');\n exit;\n end;\n writeln('NO');\nend.\n"}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then write('NO')\nelse begin\n\nfor j:=1 to 6 do\n\nif a[6]>(a[1]+a[2]+a[3])then begin write('NO');f:=true;break;end;\nfor i:=1 to 4 do\nfor j:=i to 5 do\nfor l:=j to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif a[i]+a[j]+a[l]=k then begin write('YES');f:=true;break;end;\nend; \nend;\nend."}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then begin write('NO');f:=true;end\nelse begin\n//if a[6]>(a[1]+a[2]+a[3])then begin write('NO');f:=true;break;end;\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nend;\nif not(f) and (i=4)and(j=5)and(l=6)then write('NO');\nend.\n"}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then write('NO')\nelse begin\n\nfor j:=1 to 6 do\n\nif a[6]>(a[1]+a[2]+a[3])then begin write('NO');f:=true;break;end;\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nend;\nif not(f) and (i=4)and(j=5)and(l=6)then write('NO');\nend."}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\n//if k mod 2 = 1 then begin write('NO');f:=true;end\n\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nif not(f) and (i=4)and(j=5)and(l=6)then write('NO');\nend.\n"}, {"source_code": "var a:array[1..6]of integer;\n i,i1,i2,i3,i4,i5,i6:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do read(a[i]);\nfor i1:=1 to 6 do\nfor i2:=1 to 6 do\nif i1<>i2 then\nfor i3:=1 to 6 do\nif (i3<>i2)and(i3<>i1) then\nfor i4:=1 to 6 do\nif (i4<>i3)and(i4<>i2)and(i4<>i1)then\nfor i5:=1 to 6 do\nif (i5<>i4)and(i5<>i3)and(i5<>i2)and(i5<>i1)then\nfor i6:=1 to 6 do\nif (i6<>i5)and(i6<>i4)and(i6<>i3)and(i6<>i2)and(i6<>i1)then\nif ((a[i1]+a[i2]+a[i3]-a[i4]-a[i5]-a[i6])=0)then begin writeln(i1,' ',i2,' ',i3,' ',i4,' ',i5,' ',i6); f:=true;end;\nif f then write('YES')else write('NO');\nend."}, {"source_code": "var a:array[1..6]of integer;\n i,i1,i2,i3,i4,i5,i6:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do read(a[i]);\nfor i1:=1 to 6 do\nfor i2:=1 to 6 do\nif i1<>i2 then\nfor i3:=1 to 6 do\nif (i3<>i2)and(i3<>i1) then\nfor i4:=1 to 6 do\nif (i4<>i3)and(i4<>i2)and(i4<>i1)then\nfor i5:=1 to 6 do\nif (i5<>i4)and(i5<>i3)and(i5<>i2)and(i3<>i1)then\nfor i6:=1 to 6 do\nif (i6<>i5)and(i6<>i4)and(i6<>i3)and(i6<>i2)and(i6<>i1)then\nif ((a[i1]+a[i2]+a[i3]-a[i4]-a[i5]-a[i6])=0)then f:=true;\nif f then write('YES')else write('NO');\nend."}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then begin write('NO');f:=true;end\nelse begin\n\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nend;\nif not(f) and (i=4)and(j=5)and(l=6)then write('NO');\nend.\n"}, {"source_code": "var a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then write('NO')\nelse begin\n\nfor j:=1 to 6 do\n\nif a[6]>(a[1]+a[2]+a[3])then begin write('NO');f:=true;break;end;\nfor i:=1 to 4 do\nfor j:=i to 5 do\nfor l:=j to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nend;\nend."}, {"source_code": "\nvar a:array[1..6]of integer;\n b:array[1..6]of boolean;\n i,k,j,l,z:integer;\n f:boolean;\nbegin\nf:=false;\nfor i:=1 to 6 do begin read(a[i]);k:=k+a[i];b[i]:=true; end;\nif k mod 2 = 1 then begin write('NO');f:=true;end\nelse begin\n\nfor j:=1 to 6 do\n\nif a[6]>(a[1]+a[2]+a[3])then begin write('NO');f:=true;break;end;\nfor i:=1 to 4 do\nfor j:=i+1 to 5 do\nfor l:=j+1 to 6 do\nbegin\nif f then break;\nk:=0;\nfor z:=1 to 6 do if (z<>i)and(z<>j)and(z<>l)then k:=k+a[z];\nif (a[i]+a[j]+a[l]=k)and(i<>j)and(j<>l)and(l<>i) then begin write('YES');f:=true;break;end;\nend; \nend;\nif not(f) and (i=4)and(j=5)and(l=6)then write('NO');\nend."}, {"source_code": "program firsttt;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n i, j, sum, k: integer;\n a: array[1..6] of integer;\n\nbegin\n sum := 0;\n for i := 1 to 6 do begin\n read(a[i]);\n inc(sum, a[i]);\n end;\n\n for i := 1 to 6 do begin\n for j := 1 to 6 do\n for k := 1 to 6 do\n if (a[i] + a[j] + a[k] = sum - (a[i] + a[j] + a[k])) then begin\n writeln('YES');\n halt(0);\n end;\n end;\n writeln('NO'); \nend.\n"}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1,k1,n1,j1:integer;\nbegin\nn1:=0;\nj1:=0;\nk1:=0;\nl:=0;\nfor i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\nif l mod 2=0 then\nbegin\nl:=l div 2;\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nif (a[j]+a[k]+a[n]=l) and (n<>k) and (j<>k) and (n1<>k) and(n<>j) and (j1<>k) and (k1<>k) and (n1<>n) and (j1<>n) and (k1<>n) and (n1<>j) and (j1<>j) and (k1<>j) then\nbegin\ninc(m);\nn1:=n;\nj1:=j;\nk1:=k;\nend;\nif m=2 then\nwriteln('YES');\nif m<=1 then\nwriteln('NO');\nend\nelse\nwriteln('NO');\nend."}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1:integer;\nbegin\nl:=0;for i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\nif l mod 2=0 then\nbegin\nl:=l div 2;\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nif (a[j]+a[k]+a[n]=l) and (n<>k) and (j<>k) then\nbegin\ninc(m);\na[n]:=1001;\na[j]:=1001;\na[k]:=1001;\nend;\nif m=2 then\nwriteln('YES');\nif m<=1 then\nwriteln('NO');\nend\nelse\nwriteln('NO');\nend."}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1,k1,n1,j1:integer;\nbegin\nn1:=0;\nj1:=0;\nk1:=0;\nl:=0;\nfor i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\n\n\n\n\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nfor j1:=1 to 6 do\nfor k1:=1 to 6 do \nfor n1:=1 to 6 do\nbegin\nif m>0 then\nbreak\nelse\nif (a[j]+a[k]+a[n]= a[j1]+a[k1]+a[n1]) and (n+j+k+n1+j1+k1=21) then\nbegin\ninc(m);\nbreak;\nend;\nend;\nif m=1 then\nwriteln('YES');\nif m<1 then\nwriteln('NO');\nend."}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1,k1,n1,j1:integer;\nbegin\nn1:=0;\nj1:=0;\nk1:=0;\nl:=0;\nfor i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\nif l mod 2=0 then\nbegin\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nfor j1:=1 to 6 do\nfor k1:=1 to 6 do \nfor n1:=1 to 6 do\nbegin\nif m>0 then\nbreak\nelse\nif (a[j]+a[k]+a[n]= a[j1]+a[k1]+a[n1]) and (n+j+k+n1+j1+k1=21) then\nbegin\ninc(m);\nbreak;\nend;\nend;\nif m=1 then\nwriteln('YES');\nif m<1 then\nwriteln('NO')\nend\nelse\nwriteln('no');\nend."}, {"source_code": "var a:array[1..6] of integer; i,j,k,l,m,n,a1,k1,n1,j1:integer;\nbegin\nn1:=0;\nj1:=0;\nk1:=0;\nl:=0;\nfor i:=1 to 6 do\nbegin\nread(a1);\na[i]:=a1;\nl:=l+a1;\nend;\nm:=0;\nif l mod 2=0 then\nfor j:=1 to 6 do\nfor k:=1 to 6 do \nfor n:=1 to 6 do\nfor j1:=1 to 6 do\nfor k1:=1 to 6 do \nfor n1:=1 to 6 do\nbegin\nif m>0 then\nbreak\nelse\nif (a[j]+a[k]+a[n]= a[j1]+a[k1]+a[n1]) and (n+j+k+n1+j1+k1=21) then\nbegin\ninc(m);\nbreak;\nend;\nend;\nif m=1 then\nwriteln('YES');\nif m<1 then\nwriteln('NO');\nif l mod 2=1 then\nwriteln('no');\nend."}, {"source_code": "var n,d,i,x,l,j :integer; a:array of integer;\nbegin\nl:=0;\nread(n);\nread(d);\nsetlength(a,n);\nfor i:=0 to n-1 do\nbegin\nread(x);\na[i]:=x;\nend;\nfor i:=0 to n-1 do\nbegin\nx:=a[i];\nfor j:=0 to n-1 do\nbegin\nif x+d=a[j] then\nbegin\ninc(l);\nbreak;\nend;\nend;\n\nend;\nwriteln(l);\nend."}, {"source_code": "var \nflag: boolean; \nsum, sum1, i, j, k, l, m: int64; \nmassum, massum1: array[1..20] of int64; \nmas: array[1..6] of integer; \n\nbegin \nflag := false; \nl := 1; \nfor i := 1 to 6 do \nbegin \nread(mas[i]); \nend; \nfor i := 1 to 6 do \nbegin \nfor j := 1 to 6 do \nbegin \nif (not (j = i)) then \nfor k := 1 to 6 do \nbegin \nif ((not (k = i)) or (not (k = j))) then \nbegin \nsum := mas[i] + mas[j] + mas[k]; \nfor m := 1 to 6 do \nbegin \nif ((m = i) or (m = i) or (m = i)) then \nbegin \nend \nelse \nbegin \nsum1 := mas[m] + sum1; \nend; \nend; \nif (sum = sum1) then flag := true; \nsum1 := 0; \nend; \nend; \nend; \nend; \nif (flag) then write('YES') else write('NO'); \nend."}, {"source_code": "var \nflag: boolean; \nsum, sum1, i, j, k, l, m: int64; \nmassum, massum1: array[1..20] of int64; \nmas: array[1..6] of integer; \n\nbegin \nflag := false; \nl := 1; \nfor i := 1 to 6 do \nbegin \nread(mas[i]); \nend; \nfor i := 1 to 6 do \nbegin \nfor j := 1 to 6 do \nbegin \nif (not (j = i)) then \nfor k := 1 to 6 do \nbegin \nif ((not (k = i)) and (not (k = j))) then \nbegin \nsum := mas[i] + mas[j] + mas[k]; \nfor m := 1 to 6 do \nbegin \nif ((m = i) or (m = i) or (m = i)) then \nbegin \nend \nelse \nbegin \nsum1 := mas[m] + sum1; \nend; \nend; \nif (sum = sum1) then flag := true; \nsum1 := 0; \nend; \nend; \nend; \nend; \nif (flag) then write('YES') else write('NO'); \nend."}, {"source_code": "var \nflag: boolean; \nsum, sum1, i, j, k, l, m: int64; \nmassum, massum1: array[1..20] of int64; \nmas: array[1..6] of integer; \n\nbegin \nflag := false; \nl := 1; \nfor i := 1 to 6 do \nbegin \nread(mas[i]); \nend; \nfor i := 1 to 6 do \nbegin \nfor j := i + 1 to 6 do \nbegin \nfor k := j + 1 to 6 do \nbegin \nsum := mas[i] + mas[j] + mas[k]; \nfor m := 1 to 6 do \nbegin \nif ((m = i) or (m = i) or (m = i)) then \nbegin \nend \nelse \nbegin \nsum1 := mas[m] + sum1; \nend; \nend; \nif (sum = sum1) then flag := true; \nsum1:= 0; \nend; \nend; \nend; \nif (flag) then write('YES') else write('NO'); \nend."}, {"source_code": "var a:array[0..6] of longint;\n i,j,z,x,max,c,z1,x1: longint;\n begin\n for i:=1 to 6 do\n read(a[i]);\n for i:=1 to 6 do begin\n max:=0;\n for j:=1 to 6 do\n if a[j]>max then begin max:=a[j]; c:=j; end;\n if (za[j+1] then\n begin\n t:=a[i]; a[i]:=a[i+1]; a[i+1]:=t;\n end;\n s1:=a[1]+a[3]+a[6];\n s2:=a[2]+a[4]+a[5];\n if s1=s2 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var\n i,j,t,s1,s2:longint; a:array[1..6] of integer;\nbegin\n for i:=1 to 6 do read(a[i]);\n for i:=1 to 5 do\n for j:=i to 6-i do\n if a[j]>a[j+1] then\n begin\n t:=a[i]; a[i]:=a[i+1]; a[i+1]:=t;\n end;\n s1:=a[1]+a[4]+a[6];\n s2:=a[2]+a[3]+a[5];\n if s1=s2 then writeln('YES') else writeln('NO');\nend."}, {"source_code": "var m,j,l,i,u,k:int32;\na:array[0..6] of int32;\nbegin\n{assign(input,'input.txt' );\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nfor i:=1 to 6 do\n begin\n read(a[i]);\n k+=a[i];\n end;\nif k mod 2=0 then\nfor i:=1 to 6 do\n if i<>j then\n for j:=1 to 6 do\n if (i<>l) and (j<>l) then\n for l:=1 to 6 do\n if k div 2=a[i]+a[j]+a[l] then\n begin\n write('YES');\n exit;\n end;\nwrite('NO')\nend."}, {"source_code": "var m,j,l,i,u,k:int32;\na:array[0..6] of int32;\nbegin\n{assign(input,'input.txt' );\nassign(output,'output.txt');\nreset(input);\nrewrite(output); }\nfor i:=1 to 6 do\n begin\n read(a[i]);\n k+=a[i];\n end;\nif k mod 2=0 then\nfor i:=1 to 6 do\n if i<>j then\n for j:=1 to 6 do\n if (i<>j) and (j<>l) then\n for l:=1 to 6 do\n if k div 2=a[i]+a[j]+a[l] then\n begin\n write('YES');\n exit;\n end;\nwrite('NO')\nend."}, {"source_code": "Const\n\tfi='';\n\tfo='';\n\nVar\tf:text;\n\tsum:longint;\n\ta:array [1..6] of longint;\n\nProcedure NhapDL;\nvar\ti:word;\nbegin\n\tsum:=0;\n\tassign(f,fi); Reset(f);\n\tFor i:= 1 to 6 do\n\tbegin\n\t\tread(f,a[i]);\n\t\tsum:=sum+a[i];\n end;\n\tClose(f);\nend;\n\nProcedure Xuly;\nvar\tx,y,z,tmp:longint;\nbegin\n\tassign(f,fo); Rewrite(F);\n\tFor x:= 1 to 4 do\n\tFor y:= x+ 1 to 5 do\n\tFor z:= y+1 to 6 do\n\t\tif a[x] +a[y] +a[z] = (sum div 2) then\n\t\tbegin\n\t\t\tWriteln(f,'YES');\n\t\t\tClose(f);\n\t\t\tHalt;\n\t\tend;\n\tWRite(f,'NO');\n\tClose(f);\nend;\n\nBegin\n\tNhapDL;\n\tXuly;\nend."}, {"source_code": "var n,i:longint;\na:Array[0..10] of longint;\nflag:boolean;\n\nprocedure dfs(k,s:longint);\nbegin\n if s=a[0] then begin flag:=true;exit;end;\n if k>n then exit;\n dfs(k+1,s);\n if flag then exit;\n dfs(k+1,s+a[k]);\nend;\n\nbegin\n n:=6;\n for i:=1 to n do\n begin\n read(a[i]);\n a[0]:=a[0]+a[i];\n end;\n if a[0] mod 2=1 then begin write('no');halt;end;\n a[0]:=a[0]>>1;\n flag:=false;\n dfs(1,0);\n if flag then writeln('yes')\n else writeln('no');\nend.\n\n"}, {"source_code": "var\n a: array[1..6]of integer;\n i, s, n: integer;\n\nbegin\n n := 6;\n for i := 1 to n do\n begin\n read(a[i]);\n s := s + a[i];\n end;\n if s mod 2 <> 0 then writeLn('no')\n else writeLn('yes');\nend."}, {"source_code": "var\n a: array[1..6]of integer;\n i, s, n, j, z: integer;\n fl: boolean;\n\nbegin\n n := 6;\n for i := 1 to n do\n begin\n read(a[i]);\n s := s + a[i];\n end;\n fl := false;\n if s mod 2 <> 0 then writeLn('no')\n else\n begin\n for i := 1 to n do\n for j := i + 1 to n do\n for z := j + 1 to n do\n if a[i] + a[j] + a[z] = s div 2 then \n begin\n fl := true;\n break;\n end;\n end;\n if fl then writeLn('yes');\nend."}, {"source_code": "var A, B: array[1..6] of integer;\n i, j, sum, select: integer;\n ans: string;\n\nprocedure binary(n: integer);\nvar i, du: integer;\nbegin\n i:=6; du:=0;\n while n<>0 do\n begin\n du:=n mod 2;\n n:=n div 2;\n B[i]:=du; dec(i);\n end;\nend;\n\nbegin\n for i:=1 to 6 do\n begin\n read(A[i]);\n sum:=sum+A[i];\n end;\n readln; ans:='NO';\n for i:=0 to 63 do\n begin\n binary(i); select:=0;\n for j:=1 to 6 do\n if B[j]=1 then select:=select+A[j];\n if 2*select=sum then\n begin\n ans:='YES';\n break;\n end;\n end;\n write(ans);\nend."}], "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"} {"source_code": "var\n n, k, i, t: longint;\n p: string;\n err: integer;\n\nbegin\n readln(n);\n str(n, p);\n val(p[1], k, err);\n t := k + 1;\n for i := 1 to length(p) - 1 do\n begin\n t := t * 10;\n end;\n writeln(t - n);\nend.\n", "positive_code": [{"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var i2,q,t,pos,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n prost,zanx,zany:array[-10..2000000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(p);\n t:=1;\n repeat t:=t*10 until t>p;\n t:=t div 10;\n q:=(p) div t;\n write((q+1)*t-p);\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var\n a,b,c,n,i:longint;\n begin\n readln(n);\n if n=1000000000 then begin writeln(1000000000);halt;end;\n a:=1;\n c:=n;\n b:=0;\n while n<>0 do\n begin\n n:=n div 10; \n a:=a*10;\n end;\n a:=a div 10;\n for i:=1 to a do\n begin\n c:=c+1;\n b:=b+1;\n if (c mod a=0) then begin writeln(b); halt; end; end;\n end."}, {"source_code": "var k,del,currentYear:integer;\n\n\nbegin\nk:=1;\ndel:=1;\nreadln(currentYear);\nif (currentYear>=1) and (currentYear<10) then\n writeln(1)\nelse if currentYear>=10 then\n begin\n while k<>0 do\n begin\n del:=del*10;\n if (currentYear div del)<10 then\n begin\n k:=0;\n end;\n \n end;\n if ( ( ( (currentYear div del)+1) * del)-currentYear)<1000000000 then\n writeln( ( ( (currentYear div del)+1) * del)-currentYear)\n else\n writeln(1000000000);\n end;\n\n\n\nend."}, {"source_code": "Program qq;\nvar n,i,s,m:integer;\nbegin\ns:=1;\nread(n);\nm:=n;\nwhile (m>9) do begin\ns:=s*10;\nm:=m div 10;\nend;\ni:=n+s-(n mod s);\nwrite(i-n);\nend.\n\n"}, {"source_code": "//const\n // fi='LUCKYYEAR.INP';\n // fo='LUCKYYEAR.OUT';\nvar n,dem,cnt,res:longint;\nprocedure nhap;\n//var// f:text;\nbegin\n // assign(f,fi);reset(f);\n readln(n);\n // close(f);\nend;\nfunction sochuso(l:longint):longint;\nvar k:longint;\nbegin\n dem:=0;\n while l>0 do\n begin\n k:=l mod 10;\n if k>0 then\n begin\n inc(dem);\n end;\n l:=l div 10;\n end;\n exit(dem);\nend;\nfunction sohang(l:longint):longint;\nbegin\n cnt:=0;\n while l>0 do\n begin\n inc(cnt);\n l:=l div 10;\n end;\n exit(cnt);\nend;\nprocedure xuat;\nvar //f:text;\n m,k,i:longint;\nbegin\n // assign(f,fo);rewrite(f);\n res:=1;\n for i:=1 to sohang(n)-1 do res:=res*10;\n if sochuso(n)>1 then\n begin\n k:=n div res+1;\n m:=(k*res)-n;\n writeln(m);\n readln;\n end\n else\n begin\n writeln(res);\n readln;\n end;\n // close(f);\nend;\nbegin\n nhap;\n xuat;\nend.\n"}, {"source_code": "\nvar n,tt,i,t :qword;\n dem :byte;\nBEGIN\n read(n);\n dem:=0;\n\n if n<10 then t:=1;\n if (10<=n) and (n<100) then t :=10;\n if (100<=n) and (n<1000) then t:=100;\n if (1000<=n) and (n<10000) then t:=1000;\n if (10000<=n) and (n<100000) then t:=10000;\n if (100000<=n) and (n<1000000) then t:=100000;\n if (1000000<=n) and (n<10000000) then t:=1000000;\n if (10000000<=n) and (n<100000000) then t:=10000000;\n if (100000000<=n) and (n<1000000000) then t:=100000000;\n if (1000000000<=n) and (n<10000000000) then t:=1000000000;\n i:=1; tt:=0;\n\n while n>=tt do\n begin\n tt:=i*t;\n inc(i);\n end;\n write (tt-n);\nEND.\n"}, {"source_code": "var n , du , tmp : int64;\n\nbegin\n readln(n);\n du := 1;\n tmp := n;\n while tmp >= 10 do\n begin\n du := du*10;\n tmp := tmp div 10;\n end;\n du := du + (n div du) * du;\n writeln(du-n);\nend.\n"}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar s:string;\n n,r:longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n);\n if n<9 then\n r:=n+1\n else\n begin\n str(n,s);\n r:=ord(s[1])-47;\n r:=r*10**(length(s)-1);\n end;\n writeln(r-n);\n close(input);\n close(output);\nend."}, {"source_code": "\nvar n,tt,i,t:qword;\nBEGIN\n read(n);\n if n < 10 then t:=1;\n if (10<=n) and (n<100) then t:=10;\n if (100<=n) and (n<1000) then t:=100;\n if (1000<=n) and (n<10000) then t:=1000;\n if (10000<=n) and (n<100000) then t:=10000;\n if (100000<=n) and (n<1000000) then t:=100000;\n if (1000000<=n) and (n<10000000) then t:=1000000;\n if (10000000<=n) and (n<100000000) then t:=10000000;\n if (100000000<=n) and (n<1000000000) then t:=100000000;\n if (1000000000<=n) and (n<10000000000) then t:=1000000000;\n if (10000000000<=n) and (n<100000000000) then t:=10000000000;\n i:=1;tt:=0;\n while n >= tt do\n Begin\n tt:=i*t;\n inc(i);\n End;\n write(tt-n);\nEND.\n\n\n\n\n\n"}, {"source_code": "const\n fi='';\n fo='';\nprocedure fileio;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\nend;\nprocedure enter;\nvar s:string;\n n,so,i:longint;\nbegin\n readln(s);\n val(s,n);\n if s[1]='9' then\n begin\n so:=1;\n for i:=1 to length(s) do\n so:=so*10;\n end\n else\n begin\n so:=ord(s[1])+1-48;\n for i:=1 to length(s)-1 do\n so:=so*10;\n end;\n write(so-n);\nend;\nbegin\n fileio;\n enter;\nend.\n"}, {"source_code": "Program One;\nvar i, j: integer;\ng, n, k: int64;\na: array[1..100] of int64;\n\nbegin\n\tk:=1; n:=1;\n\tfor i:=0 to 8 do begin\n\t for j:=1 to 9 do \n\t begin\n \t a[n]:= j*k;\n \t Inc(n);\n \t end;\n\t k:=k*10;\n\tend;\n\ta[n]:=1000000000;\n\ta[n+1]:=2000000000;\n\t\n//\tfor i:=1 to 82 do writeln(a[i]);\n\t\n\treadln(g);\n\ti:=1;\n\twhile g >= a[i] do Inc(i);\t\n\t\n\twriteln(a[i]-g);\n\t\nend.\t"}, {"source_code": "var\ns:string;\nch:int64;\nn,i:longint;\n\nbegin\nreadln(n);\nstr(n,s);\n\nch:=ord(s[1])-47;\nfor i:=2 to length(S) do ch:=ch*10;\nwriteln(ch-n);\nend."}, {"source_code": "//const fi='number.inp';\n// fo='number.out';\nvar d,s,n,x:longint;\n//procedure mo;\n//begin\n// assign(input,fi);\n// reset(input);\n// assign(output,fo);\n// rewrite(output);\n//end;\n\nprocedure nhap;\nbegin\n readln(n);\nend;\n\nprocedure xuly;\nbegin\n x:=n;\n if n < 10 then\n begin\n write(1);\n exit;\n end;\n s:=1;\n while x >= 10 do\n begin\n x:=x div 10;\n s:=s*10;\n end;\n write(s-(n-(x*s)));\nend;\n\nbegin\n // mo;\n nhap;\n xuly;\nend.\n"}, {"source_code": "var\nn,i,j,k,x:longint;\nbegin\n readln(n);\n if n<10 then writeln(1) else begin\n k:=1;\n j:=n;\n x:=0;\n while j>=10 do begin\n j:=j div 10;\n k:=k*10;\n end;\n writeln((j+1)*k-n);\n end;\nend."}, {"source_code": "var n,a:int64;\n\nbegin\n readln(n);\n a:= 10;\n while a<=n do a:= a*10;\n a:= a div 10;\n a:= a+a*(n div a);\n write(a-n);\nend.\n\n{$Q-}\nconst fi='';\n base=37;\n modp=trunc(1e9+7);\n maxlen=100000;\nvar\n ordc:array['0'..'z'] of int32;\n hash,p,d:array[0..maxlen] of int64;\n s:ansistring; n,res:int32;\nprocedure initHash;\nvar i:int32;\nbegin\n hash[0]:= 0;\n for i:= 1 to n do hash[i]:= (hash[i-1]*base+ordc[s[i]]) mod modp;\n p[0]:= 1;\n for i:= 1 to n do p[i]:= (p[i-1]*base) mod modp;\nend;\nfunction getHash(l,r:int32):int64;\nvar tmp:int64;\nbegin\n tmp:= (hash[r]-int64(hash[l-1])*p[r-l+1]) mod modp;\n if tmp<0 then inc(tmp,modp);\n exit(tmp);\nend;\nfunction check(len,last:int32):boolean;\nvar i:int32;\nbegin\n for i:= 1 to last div len-1 do\n if getHash(1,len)<>getHash(i*len+1,(i+1)*len) then exit(false);\n exit(true);\nend;\nprocedure solve;\nvar i,j:int32; flag:boolean;\nbegin\n fillchar(d,sizeof(d),0);\n res:= 1;\n for i:= 2 to n do\n if (d[i]>=0) and (n mod i=0) then\n begin\n flag:= true;\n if d[i]=0 then\n if check(n div i,n) then d[i]:= 1\n else\n begin\n d[i]:= -1;\n flag:= false;\n end;\n for j:= i to n div i do\n if (d[i*j]=0) and (n mod (i*j)=0) then\n begin\n if flag and check(n div(i*j),n div i) then\n d[i*j]:= 1\n else d[i*j]:= -1;\n end;\n end;\n for i:= n downto 1 do\n if d[i]=1 then\n begin\n res:= i;\n break;\n end;\nend;\nprocedure process;\nvar i:int32;\nbegin\n assign(input,fi); reset(input);\n readln(s);\n while s<>'*' do\n begin\n n:= length(s);\n initHash;\n solve;\n writeln(res);\n readln(s);\n end;\n close(input);\nend;\nprocedure init;\nvar c:char;\nbegin\n for c:= 'a' to 'z' do ordc[c]:= ord(c)-ord('a');\n for c:= '0' to '9' do ordc[c]:= ord(c)-ord('0')+26;\nend;\nbegin\n init;\n process;\nend.\n"}, {"source_code": "var n,x,k,dem,i:longint;\nprocedure mo;\nbegin\n assign(input,'808A.inp');reset(input);\n assign(output,'808A.out');rewrite(output);\nend;\nprocedure dong;\nbegin\n close(input);close(Output);\nend;\nprocedure nhap;\nbegin\n readln(n);\nend;\nprocedure xuli;\nbegin\n x:=n;\n repeat\n k:=x mod 10;\n x:=x div 10;\n inc(dem);\n until x=0;\n if n<=9 then writeln(1) else\n begin\n x:=k+1;\n for i:=1 to dem-1 do\n x:=x*10;\n writeln(x-n);\n end;\n\nend;\nbegin\n // mo;\n nhap;\n xuli;\n // dong;\nend.\n\n"}, {"source_code": "var\nn,l,i,j,p:int64;\nbegin\nread(n);\ni:=n;\np:=1;\nwhile i>9 do\nbegin\ni:=i div 10;\nl:=l+1;\nend;\nwhile j0 then s:=s+1;\nuntil n=0;\nt:=1;\nwhile i<>s do begin\nt:=10*t; \ni:=i+1; end;\nif l>9 then dr:=(l div t)+1;\ni:=dr*t;\nif i<>0 then kon:=i-l; \nif i=0 then kon:=1;\nwriteln (kon);\nend."}, {"source_code": "var\nn,k,b:int64;\nbegin\nread(n);k:=10;\nif n<10 then begin write(1);exit;end;\nwhile n div k <>0 do k:=k*10;\nk:=round(k/10);b:=k;k:=((n div k)+1)*b;\nwrite(k-n);\nend."}, {"source_code": "var n,c:int64;\na,b,i:int64;\nbegin\nread(a);\nn:=a;\nb:=1;\nwhile a>=10 do\n begin\n a:=a div 10;\n b:=b*10;\n end;\nb:=b*(a+1);\nwrite(b-n);\nend.\n"}, {"source_code": "var \n n, k, tmp: longint;\nbegin\n readln(n);\n k:=n;\n while k <> 0 do\n begin\n tmp:=k mod 10;\n k:=k div 10;\n end;\n tmp:=tmp + 1;\n while tmp - n <= 0 do\n tmp:=tmp * 10;\n writeln(tmp - n);\nend."}, {"source_code": "var n,k,a,i:longint;\n\nbegin\n readln(n);\n a:=n;\n k:=0;\n while (n div 10 <>0) do\n begin\n k:=k+1;\n n:=n div 10;\n end;\n n:=n+1; \n for i:=1 to k do\n n:=n*10;\n writeln(n-a); \nend."}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,i,x6,x9,x8,x10,j,k,d,x7,x11,x12 : longint;\ns1,s2,s3,s4,s5 : string;\nc1,c2,c3,c4,c5 : char;\ni1,i2 : integer;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10,a,b : real;\na1,a2 : array[0..10000000] of longint;\nbegin\n {\nassign(input,'input.txt'); reset(input);\nassign(output,'output.txt'); rewrite(output);\n}\nreadln(s1);\nval(s1,x2,i1);\nval(s1[1],x1,i1);\nx3:=x1+1;\n\nfor i:=1 to length(s1)-1 do\nx3:=x3*10;\n\nwriteln(x3-x2);\n {\nclose(input); close(output);\n }\nend.\n"}, {"source_code": "var n,i,o,k,l,n1:longint;\na:array[1..10] of integer;\nbegin\nread(n); k:=0; l:=0; n1:=n;\nif n>9 then\nwhile n<>0 do\nbegin\nk:=K+1;\na[k]:=n mod 10;\nn:=n div 10;\nif a[k]<>0 then l:=L+1;\nend\nelse o:=1;\nif o<>1 then\nbegin\nl:=a[k]+1;\nfor i:=1 to k-1 do\nl:=l*10;\nwrite(l-n1)\nend\nelse write(o);\nend."}, {"source_code": "\nvar n,n2,raz:longint; kolz,i,k:byte;\nbegin\n readln(n); n2:=n; kolz:=0;\n if n>9 then\n begin\n while n>9 do begin inc(kolz); n:=n div 10; end;\n inc(n);\n for i:=1 to kolz do n:=n*10;\n raz:=n-n2;\n end\n else raz:=1;\n write(raz);\n\nend.\n"}, {"source_code": "var\nn,i,j,k,x:longint;\nbegin\n readln(n);\n if n<10 then writeln(1) else begin\n k:=1;\n j:=n;\n x:=0;\n while j>=10 do begin\n j:=j div 10;\n k:=k*10;\n end;\n writeln((j+1)*k-n);\n end;\nend."}, {"source_code": "uses math;\nvar n,m:int64;\n a:array[0..100100]of longint;\n s:string;\n flag:boolean;\n c:char;\n\nbegin\nreadln(n);\nm:=1;\nwhile n>=10*m do m:=m*10;\nwriteln(m-n mod m);\nend.\n\nif n<10 then begin writeln(1);halt;end;\nif n<100 then begin writeln(10-n mod 10);halt;end;\nif n<1000 then begin writeln(100-n mod 100);halt;end;\nif n<10000 then begin writeln(1000-n mod 1000);halt;end;\nif n<100000 then begin writeln(10000-n mod 10000);halt;end;\n\nend."}, {"source_code": "var n,temp,t,x:int64;\nbegin\n readln(n);\n temp:=n;t:=1;\n while temp>0 do begin\n x:=temp mod 10;\n temp:=temp div 10;\n t:=t*10;\n end;\n t:=t div 10;\n writeln(((x+1)*t-n));\nend."}, {"source_code": "var o,n,i,j:int32;\n k,s:string;\n f:text;\nbegin\n assign(f,'');\n reset(f);\n readln(f,n);\n str(n,s);\n begin\n if (length(s)=1) and (n<=5) then\n begin\n write(1);\n readln;\n halt;\n end\n else if (length(s)=1) and (n<=10) then\n begin\n write(1);\n readln;\n halt;\n end;\n\n if s[1]='9' then\n begin\n s:=s+'0';\n s[1]:='1';\n k:=s[1];\n for i:=2 to length(s) do k:=k+'0';\n val(k,o);\n write(o-n);\n readln;\n halt;\n end\n else\n k:=chr(ord(s[1])+1);\n for j:=2 to length(s) do k:=k+'0';\n val(k,o);\n write(o-n);\n readln;\n halt;\n end;\n close(f);\nend.\n"}, {"source_code": "Program Z1;\n var\n i, s, m, kod: longint;\n n: string;\nFunction pow( a:longint; b:longint ):longint;\nvar\n i, m: longint;\nBegin\n m := a;\n for i:= 1 to b - 1 do\n a:= m * a;\n pow := a;\n \nend;\nBegin\nread( n );\nval( n, m, kod );\nif(m = 0) or (m = 1) or (m = 2) or (m = 3) or (m = 4) or (m = 5) or (m = 6) or (m = 7) or (m = 8) or (m = 9) then\ns := 1\nelse\nBegin\ni := m mod pow(10, length( n ) - 1);\ns := pow(10, length( n ) - 1) - i;\nend;\nwriteln( s );\n\nend."}, {"source_code": "var n,i,res:longint; s:string;\nbegin\n readln(s);\n for i:=1 to length(s) do n:=n*10+ord(s[i])-48;\n if n<10 then begin write(1); exit; end;\n res:=ord(s[1])-48+1;\n for i:=1 to length(s)-1 do res:=res*10;\n write(res-n);\nend."}, {"source_code": "var n,i,res:longint; s:string;\nbegin\n readln(s);\n for i:=1 to length(s) do n:=n*10+ord(s[i])-48;\n if n<5 then begin write(1); exit; end;\n res:=ord(s[1])-48+1;\n for i:=1 to length(s)-1 do res:=res*10;\n write(res-n);\nend."}, {"source_code": "Uses sysutils;\nvar currentYear, afterYear, count:int64;\n\ti,firstnum:longint;\n\ts:string;\nbegin\n\tassign(input,''); reset(input);\n\tassign(output,''); rewrite(output);\n\treadln(s);\n\tcurrentYear:= strtoint(s);\n\tif currentYear <= 9 then write(1)\n\telse\n\tbegin\n\t\tcount:=1;\n\t\tfor i:=2 to length(s) do count:=count*10;\n\t\tfirstnum:= currentYear div count;\n\t\tafterYear:= (firstnum+1)*count;\n\t\twrite(afteryear- currentYear);\n\tend;\n\tclose(input); close(output);\nend."}, {"source_code": "Program z1;\nvar n,a,b:longint;\nbegin\nread(n);\na:=1;\nb:=n;\nwhile b>=10 do\nbegin\nb:=b div 10;\na:=a*10;\nend;\na:=a*(b+1);\na:=a-n; \nwrite(a);\nend."}, {"source_code": "program anulfericit1;\nvar n,s:string;\n i,b,c,j:integer;\nbegin\n readln(c);j:=c;\n str(c,s);\n b:=1;\n for i:=1 to length(s)-1 do b:=b*10;\n while(c>=10) do begin\n c:=c div 10;\n end;\n b:=b*(c+1);\n b:=b-j;\n writeln(b);\n readln;\nend."}, {"source_code": "var x,y,n:longint;\n st:string;\nfunction lt(x:longint;y:integer):longint;\nvar tam:longint;\nbegin\n if (y=0) then exit(1);\n if (y=1) then lt:=x\n else\n begin\n tam:= lt(x, y div 2) ;\n if (y mod 2=0) then exit(tam*tam)\n else exit(tam*tam*x);\n end;\nend;\nbegin\n readln(st);\n val(st,n,y);\n val(st[1],x,y);\n inc(x);\n x:=x*lt(10,length(st)-1);\n write(x-n);\nend.\n"}, {"source_code": "var\n i,n,ans,k,t:longint;\nbegin\n readln(n);\n ans:=1;t:=1;n:=n+1;\n while n mod 10<>n do\n begin\n k:=n mod 10;\n if k<>0 then\n begin\n ans:=ans+(10-k)*t;\n n:=n+10-k;\n end;\n t:=t*10;n:=n div 10;\n end;\n writeln(ans);\n readln;readln;\nend."}, {"source_code": "Program LuckyYear;\nuses math;\nvar s,st:string; n,i,a,b,code:longint;\nProcedure Next;\nbegin str(n,s);\n val(s[1],b,code);\n b:=b+1; str(b,st);\n if s[1]='9' then\n begin delete(s,1,1);\n s:='1'+s;\n for i:=2 to length(s) do s[i]:='0';\n s:=s+'0';\n end else\n begin delete(s,1,1);\n s:=st+s;\n for i:=2 to length(s) do s[i]:='0';\n end;\n val(s,a,code);\n writeln(a-n);\nend;\nbegin //assign(input,'808A.inp'); reset(input);\n //assign(output,'808A.out'); rewrite(output);\n readln(n);\n Next;\n //close(input); close(output);\nend."}, {"source_code": "var n,m,k: int64;\nBEGIN\n readln(n);\n k:=1; m:=n;\n while m > 0 do\n begin\n k:=k*10;\n m:=m div 10;\n end;\n k:=k div 10; m:=k;\n while k <= n do inc(k,m);\n write(k - n);\nEND."}, {"source_code": "program year;\nvar y,cur,t:longint;\nbegin\n read(y);\n t:=y;\n cur:=1;\n while y>9 do\n begin\n cur:=cur*10;\n y:=y div 10;\n end;\n writeln((y+1)*cur-t);\nend."}, {"source_code": " var\n\tFY,LY:longint;\n\ti:longint;\n\tlong:longint;\nfunction FN(Num:longint):longint;\nbegin\n\twhile (Num div 10)<>0 do\n\tbegin\n\t\tNum:=Num div 10;\n\t\tlong:=long+1;\n\tend;\n\texit(Num);\nend;\nfunction Power(x,q:longint):longint;\nvar t:longint;\nbegin\n\tif q=1 then exit(x);\n\tt:=Power(x,q div 2);\n\tif (q mod 2)=0 then exit(t*t) else exit(t*t*x);\nend;\nbegin\n\treadln(FY);\n\tif (FY<10) then LY:=FY+1\n else\n begin\n\t if (FY mod 10)=0 then LY:=(FN(FY)+1)*Power(10,long)\n else\n\t if (FY mod 10)<>0 then LY:=(FN(FY)+1)*Power(10,long);\n end;\n\twriteln(LY-FY);\nend.\n"}, {"source_code": "Program Educround21codefN1;\nUses math;\nVar s: string;\n n, x, i, z: longint;\n\nBegin\n\n Readln(s);\n z:= 0;\n val(s, n);\n\n For i:=1 to length(s) do begin\n if s[i] = '0' then inc(z);\n End;\n\n if length(s) = 1 then begin\n writeln(1);\n halt;\n end;\n\n if z = length(s)-1 then begin\n writeln( round( intpower(10, length(s)-1) ) );\n end\n else begin\n val(s[1], x);\n writeln( ((x + 1)*round( intpower(10, length(s)-1) ) ) - n );\n end;\n\nEnd."}, {"source_code": "program zzz;\n var x,x1,z:longint;\n k: integer;\n \nbegin\n readln(x);\n if(x<10) then\n writeln('1');\n if(x>=10) then\n begin\n x1:=x;\n k:=0;\n while x1>0 do\n begin\n inc(k);\n x1:=x1 div 10;\n end;\n z:=1;\n while k>1 do\n begin\n z:=z*10;\n dec(k);\n end;\n x1:= x div z;\n x1:= (x1+1)*z;\n writeln(x1-x);\n end;\nend."}, {"source_code": "program z1;\n var x,x1,k:longint;\n z:integer;\nbegin\n readln(x);\n k:=0;\n if x<10 then\n writeln('1')\n else\n begin\n \n x1:=x;\n while x1>0 do\n begin\n inc(k);\n x1:=x1 div 10;\n end;\n z:=1;\n while k >1 do\n begin\n z:=z*10;\n dec(k);\n end;\n x1:=x div z;\n x1:=(x1+1)*z;\n writeln(x1-x);\n end;\nend."}, {"source_code": "var\n n, i, tmp1:longint;\n s, o:string;\n\nbegin\n read(n);\n str(n, o);\n s:= '';\n if o[1] = '9' then\n begin\n s:= s + '1';\n for i:= 1 to length(o) do\n s:= s + '0';\n val(s, tmp1);\n writeln(tmp1 - n);\n halt;\n end;\n\n s:= s + char(ord(o[1]) + 1);\n if n < 10 then begin writeln('1'); halt; end;\n for i:= 1 to length(o) - 1 do\n s:= s + '0';\n val(s, tmp1);\n writeln(tmp1 - n);\nend."}, {"source_code": "program p1;\nvar\na1 : array [1..100001] of longint;\nx1,x2,x3,x4,x5,i,j : longint;\ns1 : string;\nii : integer;\n\nbegin\n\nreadln(x1);\n {\nfor i:=1 to 1000000000 do\nbegin\nx1:=x1+1;\n\nstr(x1,s1);\nx3:=0;\n for j:=1 to length(s1) do\n if s1[j]<>'0' then x3:=x3+1;\n\n if x3=1 then begin writeln(i); exit; end;\n\nend;\n }\n\n str(x1,s1);\n val(s1[1],x2,ii);\n x2:=x2+1;\n for j:=1 to length(s1)-1 do\n x2:=x2*10;\n\n\n writeln(x2-x1);\nend.\n"}, {"source_code": "program Lucky_year;\nvar\n s: string;\n s1: string;\n code, code1, i: integer;\n k: int64;\n year, j, a: int64;\n\nbegin\n read(s);\n j:= 1;\n if length(s) = 1 then\n writeln(1)\n else\n begin\n val(s, a, code1);\n for i:= length(s) downto 1 do\n begin\n\n if i=1 then\n begin\n val(s[1], k, code)\n end;\n end;\n\n for i:= 1 to length(s)-1 do\n begin\n j:= j*10;\n end;\n\n year:= (k+1)*j-a;\n write(year);\n end;\n readln;\n readln;\nend.\n\n\n\n"}, {"source_code": "var n,t,i:longint; s:string;\nbegin\n read(n); str(n,s); t:=1;\n for i:=1 to length(s)-1 do t:=t*10;\n write(((n div t)+1)*t-n)\nend."}, {"source_code": "var n,j:integer;\n j1,k,i,j2:integer;\nbegin\n k:=0;\n read(n);\n if n < 10 then \n begin \n i := 2; \n while j <> 1 do \n begin \n if n < i then \n begin \n k := i-n; \n j := 1; \n end else \n i := i+1;\n end; \n end;\n if n >= 10 then \n begin \n j2 := 10;\n j1 := 10; \n while j <> 1 do\n begin\n if n < j2 then\n begin\n k := j2-n;\n j := 1;\n end else \n j2 := j2+j1;\n if j2 >= j1*10 then \n j1:=j1*10;\n end;\n end;\n write(k);\nend.\n"}, {"source_code": "uses math;\n\nvar\n n,k,m,ans:longint;\n\nbegin\n read(n);\n k:=round(int(log10(n)));\n m:=round(power(10,k));\n ans:=(n+m-1) div m * m-n;\n if ans=0 then\n begin\n inc(n);\n k:=round(int(log10(n)));\n m:=round(power(10,k));\n ans:=(n+m-1) div m * m-n;\n inc(ans)\n end;\n writeln(ans)\nend."}, {"source_code": "var n:longint;s:string;l,f,i,lucky:longint;\nbegin\n\treadln(n);\n\tstr(n,s);\n\tl:=length(s)-1;\n\tf:=(ord(s[1])-48)+1;\n lucky:=f;\n\tfor i:=1 to l do\n\t\tlucky:=lucky*10;\n\twriteln(lucky-n);\nend.\n"}, {"source_code": "var a,b:int64; i,k:longint; sta,stb:string;\nbegin\n readln(a);\n str(a,sta);\n stb:='';\n if sta[1]<'9' then\n begin\n stb:=stb+chr(ord(sta[1])+1);\n for i:=1 to length(stA)-1 do stB:=stb+'0';\n end\n else\n begin\n stb:=stb+'1';\n for i:=1 to length(stA) do stb:=stb+'0'\n end;\n val(stb,b,k);\n writeln(b-a);\nend.\n"}, {"source_code": "const tfi = '';\ntfo = '';\nvar cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi,y,p,t);\nend;\nprocedure xuly;\nbegin\nt:=y;\ncur:=1;\nwhile y>9 do\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "var a,q,x,l:LongInt;\n s:string;\n g:real;\nbegin\nreadln(a);\nstr(a,s);\nl:=length(s);\ng:=exp(ln(10)*(l-1));\nx:=trunc(g);\nq:=x-(a mod x);;\nwriteln(q);\nend."}, {"source_code": "program sd;\nvar s:string;\nb,x,k,bn,n,i:integer;\nbegin\nread(s);\nval(s,b,x);\nk:=length(s);\nn:=1;\nfor i:= 2 to k do\nn:= n * 10;\nbn:=b div n ;\nwrite((n+(n*bn))-b);\nend."}, {"source_code": "uses math;\nconst fi='';\n fo='';\nvar s:string;\n n,r:longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n);\n if n<9 then\n r:=n+1\n else\n begin\n str(n,s);\n r:=ord(s[1])-47;\n r:=r*10**(length(s)-1);\n end;\n writeln(r-n);\n close(input);\n close(output);\nend."}, {"source_code": "var p,a,k:longint;\nbegin\nread(a);\nk:=1;\np:=a;\nif a<=9 then write (1) else begin\nrepeat\nk:=k*10;\na:=a div 10\n\nuntil a div 10=0;\nwrite((a+1)*k-p);\nend;\nend."}, {"source_code": "Uses math;\nVar fi, fo: text;\n n, i, long, tmp, k: Longint;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, n);\n\tif (n div 10)=0 then\n\tbegin\n\t\twriteln(fo, 1);\n\t\tclose(fi); close(fo);\n\t\texit;\n\tend;\n\tlong:= trunc(log10(n)) + 1;\n\tk:= 1;\n\tfor i:=1 to long-1 do k:= k*10;\n\ttmp:= n div k;\n\twriteln(fo, (tmp+1)*k - n);\n\tclose(fi); close(fo);\nEnd.\n"}, {"source_code": "var x,y,n,i,t1:longint;\n t:qword; \n\nfunction lt(x,y:longint):qword;\n var i:longint;\n s:qword;\n begin\n s:=1;\n for i:=1 to y do s:=s*x;\n exit(s);\n end;\n\nbegin\nreadln(n);\nIF n<10 then\n begin\n write(1);\n exit;\n end;\nx:=0;\nt1:=n;\nwhile n>0 do\n begin\n n:=n div 10;\n inc(x);\n end;\nt:=t1 div lt(10,(x-1));\ninc(t);\nfor i:=1 to x-1 do\n t:=t*10;\nwrite(t-t1);\nend.\n"}, {"source_code": "var\n n,i,k,m,j:longint;\n a,b:array[1..100] of longint;\nbegin\n readln (n);\n i:=n;\n k:=0;\n j:=1;\n while i>0 do\n begin\n a[j]:=i mod 10;\n i:=i div 10;\n inc(k);\n inc(j);\n end;\n dec(j);\n if k=1 then begin writeln (1); exit; end;\n for i:=1 to j-1 do\n begin\n b[i]:=10-a[i];\n inc(a[i+1]);\n end;\n k:=a[i+1];\n for i:=j-1 downto 1 do k:=k*10;\n writeln (k-n);\nend.\n"}, {"source_code": "var n:longint;\n\nprocedure nhap;\nbegin\n\treadln(n);\nend;\n\nprocedure xuli;\nvar\tq:qword;\n\ts,n1:longint;\nbegin\n\tq:=1;\n n1:=n;\n\twhile n1 div 10 <>0 do\n\t\tbegin\n\t\t\tq:=q*10;\n\t\t\tn1 :=n1 div 10;\n\t\tend;\n\ts:=(n div q)+1;\n\twriteln(s*q-n)\nend;\n\nbegin\n{\tassign(input,'bai_1.inp');reset(input);\n\tassign(output,'bai_1.out');rewrite(output);}\n\t\tnhap;\n\t\txuli;\nend.\n\n"}, {"source_code": "var n,d,m,l,i,a,er:longint;\n st:string;\nfunction kt(a:longint):boolean;\nvar i,d:integer;\n st:string;\nbegin\n str(a,st);\n i:=1; d:=0;\n for i:=1 to length(st) do if st[i]<>'0' then inc(d);\n if d>1 then kt:=false else kt:=true;\nend;\nbegin\n readln(n);\n str(n,st); l:=length(st)-1; val(st[1],a,er); a:=a+1; str(a,st);\n for i:=1 to l do st:=st+'0';\n val(st,m,er);\n d:=m-n;\n\n\n writeln(d);\nend.\n"}, {"source_code": "var\n st,k,n,i:int64;\nbegin\n readln(n);\n //if n<=9 then begin writeln(10-n); exit; end;\n k:=0;\n i:=n;\n st:=1;\n while (i>0) do\n begin\n i:=i div 10;\n inc(k);\n st:=st*10;\n end;\n // writeln(st);\n st:=st div 10;\n // writeln(st);\n //writeln((n div st)+1);\n // writeln(((n div st)+1)*st);\n writeln(((n div (st))+1)*st-n);\nend."}, {"source_code": "var x,y,n,i,t1:longint;\n t:qword; \n\nfunction lt(x,y:longint):qword;\n var i:longint;\n s:qword;\n begin\n s:=1;\n for i:=1 to y do s:=s*x;\n exit(s);\n end;\n\nbegin\nreadln(n);\nIF n<10 then\n begin\n write(1);\n exit;\n end;\nx:=0;\nt1:=n;\nwhile n>0 do\n begin\n n:=n div 10;\n inc(x);\n end;\nt:=t1 div lt(10,(x-1));\ninc(t);\nfor i:=1 to x-1 do\n t:=t*10;\nwrite(t-t1);\nend."}, {"source_code": "program z1;\nvar\n a, b, c, k, k1, i, b1, b2, v1, i3 : integer;\n\nfunction v(var a1, i1 : integer):integer;\n var i2 : integer;\n begin\n for i2 := 1 to i1 - 1 do\n a1 := a1 * 10;\n v := a1;\n end;\nbegin\n read(k);\n a := k;\n while a <> 0 do\n begin\n b := b + (a mod 10);\n a := a div 10;\n inc(k1);\n end;\n a := k;\n for i := 1 to k1 - 1 do\n a := a div 10;\n c := a;\n b1 := 1;\n for i := 1 to k1 - 1 do\n b1 := b1 * 10;\n if b = c then writeln(b1)\n else begin\n a := k;\n for i := 1 to k1 - 1 do\n begin\n v1 := a mod 10;\n i3 := i;\n b2 := b2 + v(v1, i3);\n a := a div 10;\n end;\n writeln(b1 - b2);\n end;\n\nend.\n"}], "negative_code": [{"source_code": "\nvar n,i,a,t,j,l:qword;\nBEGIN\n read(n);i:=10;j:=100;\n if n < 10 then t:=1;\n if (10<=n) and (n<100) then t:=10;\n if (100<=n) and (n<1000) then t:=100;\n if (1000<=n) and (n<10000) then t:=1000;\n if (10000<=n) and (n<100000) then t:=10000;\n if (100000<=n) and (n<1000000) then t:=100000;\n if (1000000<=n) and (n<10000000) then t:=1000000;\n if (10000000<=n) and (n<100000000) then t:=1000000;\n if (100000000<=n) and (n<1000000000) then t:=100000000;\n if (1000000000<=n) and (n<10000000000) then t:=1000000000;\n if (10000000000<=n) and (n<100000000000) then t:=10000000000;\n i:=i*10;j:=j*10;\n l:=1;a:=0;\n while n >= a do\n Begin\n a:=l*t;\n inc(l);\n End;\n write(a-n);\nEND.\n\n\n\n\n\n"}, {"source_code": "function kt(m:qword):boolean;\nvar cs,dem:qword;\nBegin\n dem:=0;kt:=true;\n while m <> 0 do\n Begin\n cs:=m mod 10;\n if cs <> 0 then inc(dem);\n if dem > 1 then begin kt:=false;exit;end;\n m:=m div 10;\n End;\nEnd;\nvar n,i,kq,a:qword;st:string;code:integer;\nBEGIN\n read(n);\n if n < 10 then kq:=1;\n if n >=10 then if kt(n)=false then\n Begin\n i:=n+1;\n while i > 1 do\n Begin\n if kt(i)=true then\n Begin\n kq:=i-n;\n break;\n End;inc(i);\n end;\n End;\n if kt(n)=true then\n Begin\n str(n,st);\n st[1]:='1';\n val(st,a,code);\n kq:=n+a;\n End;\n write(kq);\nEND.\n\n\n\n\n\n"}, {"source_code": "\nvar n,tt,i,t:qword;\nBEGIN\n read(n);\n if n < 10 then t:=1;\n if (10<=n) and (n<100) then t:=10;\n if (100<=n) and (n<1000) then t:=100;\n if (1000<=n) and (n<10000) then t:=1000;\n if (10000<=n) and (n<100000) then t:=10000;\n if (100000<=n) and (n<1000000) then t:=100000;\n if (1000000<=n) and (n<10000000) then t:=1000000;\n if (10000000<=n) and (n<100000000) then t:=1000000;\n if (100000000<=n) and (n<1000000000) then t:=100000000;\n if (1000000000<=n) and (n<10000000000) then t:=1000000000;\n if (10000000000<=n) and (n<100000000000) then t:=10000000000;\n i:=1;tt:=0;\n while n >= tt do\n Begin\n tt:=i*t;\n inc(i);\n End;\n write(tt-n);\nEND.\n\n\n\n\n\n"}, {"source_code": "//const fi='number.inp';\n// fo='number.out';\nvar d,s,n,x:longint;\n//procedure mo;\n//begin\n// assign(input,fi);\n// reset(input);\n// assign(output,fo);\n// rewrite(output);\n//end;\n\nprocedure nhap;\nbegin\n readln(n);\nend;\n\nprocedure xuly;\nbegin\n x:=n;\n if n < 10 then\n begin\n write(1);\n exit;\n end;\n d:=1;\n s:=1;\n while x > 10 do\n begin\n x:=x div 10;\n s:=s*10;\n inc(d);\n end;\n write(s-(n-(x*s)));\nend;\n\nbegin\n // mo;\n nhap;\n xuly;\nend.\n"}, {"source_code": "var n,dem:longint;\nbegin\n read(n);\n if n<10 then write(1)\n else begin\n dem:=1;\n repeat\n n:=n div 10;\n dem:=dem*10;\n\n until n<10;\n write((n+1)*dem-n*dem);\n end;\nend."}, {"source_code": "var n,c:int64;\na,b,i:int64;\nbegin\nread(a);\nn:=a;\nb:=1;\nwhile a>10 do\n begin\n a:=a div 10;\n b:=b*10;\n end;\nb:=b*(a+1);\nwrite(b-n);\nend.\n"}, {"source_code": "var \n n, k, tmp: longint;\nbegin\n readln(n);\n k:=n;\n while k <> 0 do\n begin\n tmp:=k mod 10;\n k:=k div 10;\n end;\n tmp:=tmp + 1;\n while tmp - n <= 0 do\n tmp:=tmp * 10;\n writeln(tmp);\nend."}, {"source_code": "var \n n, k: longint;\n tmp: byte;\nbegin\n readln(n);\n k:=n;\n while n <> 0 do\n begin\n tmp:=n mod 10;\n n:=n div 10;\n end;\n tmp:=tmp + 1;\n while tmp <= k do\n tmp:=tmp * 10;\n writeln(tmp - k);\nend."}, {"source_code": "var \n n, i: longint;\nfunction check(k: longint): boolean;\n var\n free: array[1..9] of boolean;\n p: byte;\n begin\n fillchar(free, sizeof(free), false);\n while k <> 0 do\n begin\n if (free[k mod 10]) and (k mod 10 <> 0) then\n begin\n p:=p + 1;\n if p = 2 then exit(false);\n end;\n if (k mod 10 <> 0) then\n free[k mod 10]:=true;\n k:=k div 10;\n end;\n exit(true);\n end;\nbegin\n readln(n);\n n:=n+1;\n i:=1;\n while check(n) = false do\n begin\n n:=n + 1;\n i:=i + 1;\n end;\n writeln(i);\nend."}, {"source_code": "var \n n, i: longint;\nfunction check(k: longint): boolean;\n var\n free: array[1..9] of boolean;\n p: byte;\n begin\n fillchar(free, sizeof(free), false);\n while k <> 0 do\n begin\n if (free[k mod 10]) and (k mod 10 <> 0) then\n begin\n p:=p + 1;\n if p = 2 then exit(false);\n end;\n if (k mod 10 <> 0) then\n free[k mod 10]:=true;\n k:=k div 10;\n end;\n exit(true);\n end;\nbegin\n readln(n);\n i:=0;\n while check(n) = false do\n begin\n n:=n + 1;\n i:=i + 1;\n end;\n writeln(i);\nend."}, {"source_code": "program Matfey;\nvar\nx1,x2,x3,x4,x5,i,x6,x9,x8,x10,j,k,d,x7,x11,x12 : longint;\ns1,s2,s3,s4,s5 : string;\nc1,c2,c3,c4,c5 : char;\ni1,i2 : integer;\nr1,r2,r3,r4,r5,r6,r7,r8,r9,r10,a,b : real;\na1,a2 : array[0..10000000] of longint;\nbegin\n {\nassign(input,'input.txt'); reset(input);\nassign(output,'output.txt'); rewrite(output);\n}\nreadln(x1);\n\nfor i:=x1+1 to 100000000 do\nbegin\nstr(i,s1);\nx3:=0;\nfor j:=1 to length(s1) do\nif s1[j]<>'0' then x3:=x3+1;\nif x3=1 then begin writeln(i-x1); exit; end;\nend;\n\n\n\n {\nclose(input); close(output);\n }\nend.\n"}, {"source_code": "var o,n,i,j:int32;\n k,s:string;\nbegin\n readln(n);\n str(n,s);\n begin\n if (length(s)=1) and (n<=5) then\n begin\n write(5-n);\n readln;\n halt;\n end\n else if (length(s)=1) and (n<=10) then\n begin\n write(10-n);\n readln;\n halt;\n end;\n\n if s[1]='9' then\n begin\n s:=s+'0';\n s[1]:='1';\n val(s,o);\n write(o-n);\n readln;\n halt;\n end\n else\n k:=chr(ord(s[1])+1);\n for j:=2 to length(s) do k:=k+'0';\n val(k,o);\n write(o-n);\n readln;\n halt;\n end;\nend.\n"}, {"source_code": "var o,n,i,j:int32;\n k,s:string;\n f:text;\nbegin\n assign(f,'');\n reset(f);\n readln(f,n);\n str(n,s);\n begin\n if (length(s)=1) and (n<=5) then\n begin\n write(5-n);\n readln;\n halt;\n end\n else if (length(s)=1) and (n<=10) then\n begin\n write(10-n);\n readln;\n halt;\n end;\n\n if s[1]='9' then\n begin\n s:=s+'0';\n s[1]:='1';\n k:=s[1];\n for i:=2 to length(s) do k:=k+'0';\n val(k,o);\n write(o-n);\n readln;\n halt;\n end\n else\n k:=chr(ord(s[1])+1);\n for j:=2 to length(s) do k:=k+'0';\n val(k,o);\n write(o-n);\n readln;\n halt;\n end;\n close(f);\nend.\n"}, {"source_code": "var n,i,res:longint; s:string;\nbegin\n readln(s);\n for i:=1 to length(s) do n:=n*10+ord(s[i])-48;\n if n<5 then begin write(5-n); exit; end;\n res:=ord(s[1])-48+1;\n for i:=1 to length(s)-1 do res:=res*10;\n write(res-n);\nend."}, {"source_code": "Program z1;\nvar n,a,b,c:longint;\nbegin\nread(n);\na:=1;\nb:=n;\nwhile b>=10 do\nbegin\nb:=b div 10;\na:=a*10;\nend;\nif n>10 then a:=a*(b+1)\n else a:=10;\na:=a-n; \nwrite(a);\nend."}, {"source_code": "Program z1;\nvar n,a,b,c:longint;\nbegin\nread(n);\na:=1;\nb:=n;\nwhile b<>0 do\nbegin\nc:=b mod 10;\nb:=b div 10;\na:=a*10;\nend;\na:=a div 10;\na:=a*(c+1);\na:=a-n;\nwrite(a);\nend."}, {"source_code": "\n const eps=0.00000001; besk1=200000008; nn=200000;\n label 1,2;\n type { real=double;} {string=ansistring;}\n mas=array [0..nn] of longint; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of longint;mass1=^mass;\n var i2,q,t,pos,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;\n newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;\n aa,bb,cc:double;\n aold,b,a:array[-10..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n prost,zanx,zany:array[-10..2000000] of boolean;\n sss, ss1,ss2:string;\n fl:array[0..200] of boolean;\n ss:string;ch:char;\n pole :array [-10..2000,-10..2000] of char;\n maxpr:array[0..nn] of string;\n st2:array[0..nn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n newx,newy,xx,yy:array[-1..200000] of int64;\n\n yot:double;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(p);\n t:=1;\n repeat t:=t*10 until t>p;\n t:=t div 10;\n q:=(p+1) div t;\n write((q+1)*t-p);\n\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "var k,del,currentYear:integer;\n\n\nbegin\nk:=1;\ndel:=1;\nreadln(currentYear);\nif (currentYear>1) and (currentYear<10) then\n writeln(1)\nelse if currentYear>=10 then\n begin\n while k<>0 do\n begin\n del:=del*10;\n if (currentYear div del)<10 then\n begin\n k:=0;\n end;\n \n end;\n if ( ( ( (currentYear div del)+1) * del)-currentYear)<1000000000 then\n writeln( ( ( (currentYear div del)+1) * del)-currentYear)\n else\n writeln(1000000000);\n end;\n\n\n\nend."}, {"source_code": "var k,del,currentYear:integer;\n\n\nbegin\nk:=1;\ndel:=1;\nreadln(currentYear);\nif (currentYear>1) and (currentYear<10) then\n writeln(1)\nelse if currentYear>10 then\n begin\n while k<>0 do\n begin\n del:=del*10;\n if (currentYear div del)<10 then\n begin\n k:=0;\n end;\n \n end;\n writeln( ( ( (currentYear div del)+1) * del)-currentYear);\n end;\n\n\n\nend."}, {"source_code": "var k,del,currentYear:integer;\n\n\nbegin\nk:=1;\ndel:=10;\nreadln(currentYear);\nif (currentYear>1) and (currentYear<10) then\n writeln(1)\nelse if currentYear>10 then\n begin\n while k<>0 do\n begin\n del:=del*10;\n if (currentYear div del)<10 then\n begin\n k:=0;\n end;\n \n end;\n writeln( ( ( (currentYear div del)+1) * del)-currentYear);\n end;\n\n\n\nend."}, {"source_code": "var\n a,b,c,d,n,i:longint;\n begin\n readln(n);\n a:=0;\n b:=1;\n c:=n;\n d:=0;\n while n<>0 do\n begin\n n:=n div 10; \n a:=a+1;\n b:=b*10;\n end;\n b:=b div 10;\n for i:=1 to b do\n begin\n c:=c+1;\n d:=d+1;\n if (c mod b=0) then begin writeln(d); halt; end; end;\n end."}, {"source_code": "var\n a,b,c,d,n,i:integer;\n begin\n readln(n);\n a:=0;\n b:=1;\n c:=n;\n d:=0;\n while n<>0 do\n begin\n n:=n div 10; \n a:=a+1;\n b:=b*10;\n end;\n b:=b div 10;\n for i:=1 to b do\n begin\n c:=c+1;\n d:=d+1;\n if (c mod b=0) then begin writeln(d); halt; end; end;\n end."}, {"source_code": "var n,m,k: longint;\nBEGIN\n readln(n);\n k:=1; m:=n;\n while m > 0 do\n begin\n k:=k*10;\n m:=m div 10;\n end;\n k:=k div 10; m:=k;\n while k <= n do inc(k,m);\n write(k - n);\nEND."}, {"source_code": "program lucky_year;\nvar\n i, n, x,a,year,j: integer;\nbegin\n write('nhap so nam: ');\n readln(n);\n x:=n;\n i:=0;\n a:=1;\n while n>=1 do\n begin\n n:= trunc(n div 10);\n i:=i+1;\n end;\n writeln('n la so co: ',i,' chu so');\n for j:=1 to i-1 do\n a:=a*10;\n n:=x;\n n:=trunc(n div a);\n year:=(n+1)*a;\n writeln('Lucky year la: ',year);\n writeln('Output: ',year-x);\n readln;\nend."}, {"source_code": "var n,j:integer;\n j1,k,j2:real;\nbegin\n k:=0;\nread(n);\nif n<10 then k:=n+1-n;\nif n>=10 then begin j2:=100;j1:=100; while j<>1 do\n begin\n if n=j1*10 then j1:=j1*10;\n end;\n end;\n write(k);\n end."}, {"source_code": "var n,j:integer;\n j1,k,i,j2:integer;\nbegin\n k:=0;\n read(n);\n if n < 10 then \n begin \n i := 2; \n while j <> 1 do \n begin \n if n < i then \n begin \n k := i-n; \n j := 1; \n end else \n i := i+1;\n end; \n end;\n if n >= 10 then \n begin \n j2 := 100;\n j1 := 100; \n while j <> 1 do\n begin\n if n < j2 then\n begin\n k := j2-n;\n j := 1;\n end else \n j2 := j2+j1;\n if j2 >= j1*10 then \n j1:=j1*10;\n end;\n end;\n write(k);\nend.\n"}, {"source_code": "var n,j:integer;\n j1,k,i,j2:real;\nbegin\n k:=0;\nread(n);\nif n<10 then begin i:=2; while j<>1 do begin if n=10 then begin j2:=100;j1:=100; while j<>1 do\n begin\n if n=j1*10 then j1:=j1*10;\n end;\n end;\n write(k);\n end."}, {"source_code": "var n,j:integer;\n j1,k,i,j2:real;\nbegin\n k:=0;\nwrite('n=');read(n);\nif n<10 then begin i:=2; while j<>1 do begin if n=10 then begin j2:=100;j1:=100; while j<>1 do\n begin\n if n=j1*10 then j1:=j1*10;\n end;\n end;\n write(k);\n end."}, {"source_code": "var n,j:integer;\n j1,k,j2:real;\nbegin\nread(n);\nif n<10 then write('1')\n else k:=0;j2:=100;j1:=100; while j<>1 do\n begin\n if n=j1*10 then j1:=j1*10;\n end;\n write(k);\n end."}, {"source_code": "const tfi = '';\ntfo = '';\nvar m,n,cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi, m,n);\nend;\nprocedure xuly;\nbegin\nread(fi,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur +t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure xuly;\nbegin\nread(fi,p,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar m,n,cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi, m,n);\nend;\nprocedure xuly;\nbegin\nread(fi,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar m,n,cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi, m,n);\nend;\nprocedure xuly;\nbegin\nread(fi,p,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar m,n,cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi, m,n);\nend;\nprocedure xuly;\nbegin\nread(fi,p,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur +t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure xuly;\nbegin\nread(fi,p,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tp:= (y+1) * cur -t;\n\tend;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar m,n,cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure init;\nbegin\nread(fi, m,n);\nend;\nprocedure xuly;\nbegin\nread(fi,y);\nt:=y;\ncur:=1;\nif y>9 then\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -y;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\ninit;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "const tfi = '';\ntfo = '';\nvar cur,y,t,p: integer;\nfi,fo: text;\nprocedure nhapdl;\nbegin\nassign(fi, tfi);reset(fi);\nassign(fo, tfo); rewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure xuly;\nbegin\nread(fi,p,y);\nt:=y;\ncur:=1;\nwhile y>9 do\n\tbegin\n\ty:=y div 10;\n\tcur:=cur*10;\n\tend;\n\tp:= (y+1) * cur -t;\nend;\nprocedure xuat;\nbegin\nwrite(fo, p);\nend;\nbegin\nnhapdl;\nxuly;\nxuat;\nclosef;\nend."}, {"source_code": "var a,q:LongInt;\n s:string;\nbegin\nreadln(a);\nstr(a,s);\nq:=trunc(exp(ln(10)*(length(s)-1)))-(a mod trunc(exp(ln(10)*(length(s)-1))));\nwriteln(q);\nend."}, {"source_code": "var a,q:LongInt;\n s:string;\nbegin\nreadln(a);\nstr(a,s);\nq:=trunc(exp(ln(10)*(length(s)-1)));\nwriteln(q);\nend."}, {"source_code": "program sd;\nvar s:string;\nb,x,k,bn,n,i:integer;\nbegin\nread(s);\nval(s,b,x);\nk:=length(s);\nn:=1;\nfor i:= 2 to k do\nn:= n * 10;\nbn:=b mod n mod 10 ;\nwrite(n-bn);\nend.\n\n"}, {"source_code": "var a:string;\nk,p,c,i:longint;\nbegin\nread(a);\nc:=1;\nif length(a)=1 then write(1) else begin\nfor i:=1 to length(a) do begin\nk:=k*p+ord(a[i])-48;\np:=10;\nc:=c*10;\nend;\nwrite((ord(a[1])-48+1)*c div 10-k);\nend;\nend.\n"}, {"source_code": "var a:string;\nk,p,c,i:integer;\nbegin\nread(a);\nc:=1;\nif length(a)=1 then write(1) else begin\nfor i:=1 to length(a) do begin\nk:=k*p+ord(a[i])-48;\np:=10;\nc:=c*10;\nend;\nwrite((ord(a[1])-48+1)*c div 10-k);\nend;\nend.\n"}, {"source_code": "var n,d,m,l,i:longint;\n st:string;\nfunction kt(a:longint):boolean;\nvar i,d:integer;\n st:string;\nbegin\n str(a,st);\n i:=1; d:=0;\n for i:=1 to length(st) do if st[i]<>'0' then inc(d);\n if d>1 then kt:=false else kt:=true;\nend;\nbegin\n readln(n);\n str(n,st); l:=length(st)-1; st:=chr(ord(st[1])+1);\n for i:=1 to l do st:=st+'0';\n val(st,m);\n d:=m-n;\n\n\n writeln(d);\nend.\n"}, {"source_code": "var\n st,k,n,i:longint;\nbegin\n readln(n);\n k:=0;\n i:=n;\n st:=1;\n while (i>0) do\n begin\n i:=i div 10;\n inc(k);\n st:=st*10;\n end;\n // writeln(st);\n st:=st div 10;\n// writeln(st);\n writeln(((n div (st))+1)*st-n);\nend."}, {"source_code": "var\n st,k,n,i:longint;\nbegin\n readln(n);\n if n<=9 then begin writeln(10-n); exit; end;\n k:=0;\n i:=n;\n st:=1;\n while (i>0) do\n begin\n i:=i div 10;\n inc(k);\n st:=st*10;\n end;\n // writeln(st);\n st:=st div 10;\n// writeln(st);\n writeln(((n div (st))+1)*st-n);\nend."}], "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e"} {"source_code": "const dx:array[1..8] of longint = (1,1,-1,-1,2,2,-2,-2);\n dy:array[1..8] of longint = (2,-2,2,-2,1,-1,1,-1);\nvar a1,a2,b1,b2,i,j,ans:longint;\ns1,s2:string;\nf:integer;\nd:array[1..100] of longint;\na:array[-1..10,-1..10]of longint;\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n //reset(input);\n //rewrite(output);\n readln(s1);\n readln(s2);\n a1:=ord(s1[1])-96;\n b1:=ord(s2[1])-96;\n val(s1[2],a2,f);\n val(s2[2],b2,f);\n a[b1,b2]:=1;\n for i:=1 to 8 do\n begin\n a[a1,i]:=1;\n a[i,a2]:=1;\n end;\n ans:=0;\n for i:=1 to 8 do\n a[b1+dx[i],b2+dy[i]]:=1;\n for i:=1 to 8 do\n a[a1+dx[i],a2+dy[i]]:=1;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if (a[i,j]=0) then inc(ans);\n //write(a[i,j]:2);\n end;\n //writeln;\n end;\n write(ans);\nend.\n", "positive_code": [{"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar ch:char;\nx1,x2,y1,y2,i,j,ans:integer;\nbool:array[-50..50,-50..50] of boolean;\n\nprocedure move2(x,y:integer);\nbegin\n bool[x,y]:=true;\n bool[x+2,y+1]:=true;\n bool[x-2,y+1]:=true;\n bool[x+2,y-1]:=true;\n bool[x-2,y-1]:=true;\n bool[x+1,y+2]:=true;\n bool[x-1,y+2]:=true;\n bool[x+1,y-2]:=true;\n bool[x-1,y-2]:=true;\nend;\n\n\n\nprocedure move1(x,y:integer);\nvar i,j:integer;\nbegin\n i:=x;\n j:=y;\n while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin\n bool[i,j]:=true;\n inc(i);\n end;\n i:=x;\n j:=y;\n while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin\n bool[i,j]:=true;\n dec(i);\n end;\n i:=x;\n j:=y;\n while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin\n bool[i,j]:=true;\n inc(j);\n end;\n i:=x;\n j:=y;\n while (i in [1..8]) and (j in [1..8]) and ((i<>x2) or (j<>y2)) do begin\n bool[i,j]:=true;\n dec(j);\n end;\nend;\n\nbegin\n read(ch);\n x1:=ord(ch)-ord('a')+1;\n readln(y1);\n read(ch);\n x2:=ord(ch)-ord('a')+1;\n readln(y2);\n move1(x1,y1);\n move2(x1,y1);\n move2(x2,y2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not bool[i,j] then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n ans,x1,y1,x2,y2,x3,y3: longint;\n\nprocedure get(var x:longint);\nvar\n ch: char;\nbegin\n read(ch);\n while not (ch in ['a'..'h']) do read(ch);\n x:=Ord(ch)-96;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n get(x1); read(y1);\n get(x2); read(y2);\n ans:=0;\n for x3:=1 to 8 do\n for y3:=1 to 8 do\n if (x1 <> x3) and (y1 <> y3) then\n if sqr(x1-x3)+sqr(y1-y3) <> 5 then\n if sqr(x2-x3)+sqr(y2-y3) <> 5 then inc(ans);\n writeln(ans-1);\n close(input);\n close(output);\nend."}, {"source_code": "type mas = array[0..9] of longint;\nmatr = array[0..9] of mas;\n\nz=record\n x,y:longint;\nend;\n\nvar\n i,n,ans,j: longint;\n ma:matr;\n c1,c2,c3,c4: char;\n kon,lad,p,po:z;\n\n\n procedure rea(a,b:char);\n var\n x,y:longint;\n begin\n x := ord(a)-ord('a') + 1;\n y := ord(b) -ord('0');\n ma[x,y] := 1;\n end;\n\n\n function good(a:z): boolean;\n begin\n good := (a.x<=8) and (a.x >=1) and (a.y <= 8) and (a.y >=1);\n end;\n\n\n function good2(a:z): boolean;\n var\n p:z;\n f:boolean;\n begin\n\n f:=true;\n p.x:=a.x - 2;\n p.y := a.y + 1;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n p.x:=a.x - 1;\n p.y := a.y + 2;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n p.x:=a.x + 1;\n p.y := a.y + 2;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n\n p.x:=a.x + 2;\n p.y := a.y + 1;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n\n p.x:=a.x - 2;\n p.y := a.y - 1;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n\n p.x:=a.x -1;\n p.y := a.y -2;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n\n p.x:=a.x + 1;\n p.y := a.y - 2;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n\n p.x:=a.x + 2;\n p.y := a.y - 1;\n if (good(p)) and (((p.x = kon.x) and (p.y=kon.y)) or ((p.x = lad.x) and (p.y=lad.y))) then f := false;\n\n good2 := f;\n end;\n\n\nbegin\n { assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output); }\n readln(c1,c2);\n read(c3,c4);\n\n lad.x := ord(c1)-ord('a') + 1;\n lad.y := ord(c2) -ord('0');\n\n kon.x := ord(c3)-ord('a') + 1;\n kon.y := ord(c4) -ord('0');\n rea(c1,c2);\n rea(c3,c4);\n\n p.x:=kon.x - 2;\n p.y := kon.y + 1;\n if good(p) then ma[p.x,p.y] := 1;\n\n p.x:=kon.x - 1;\n p.y := kon.y + 2;\n if good(p) then ma[p.x,p.y] := 1;\n\n p.x:=kon.x + 1;\n p.y := kon.y + 2;\n if good(p) then ma[p.x,p.y] := 1;\n\n\n p.x:=kon.x + 2;\n p.y := kon.y + 1;\n if good(p) then ma[p.x,p.y] := 1;\n\n\n p.x:=kon.x - 2;\n p.y := kon.y - 1;\n if good(p) then ma[p.x,p.y] := 1;\n\n\n p.x:=kon.x -1;\n p.y := kon.y -2;\n if good(p) then ma[p.x,p.y] := 1;\n\n\n p.x:=kon.x + 1;\n p.y := kon.y - 2;\n if good(p) then ma[p.x,p.y] := 1;\n\n\n p.x:=kon.x + 2;\n p.y := kon.y - 1;\n if good(p) then ma[p.x,p.y] := 1;\n\n for i := 1 to 8 do\n ma[i,lad.y] := 1;\n\n for j := 1 to 8 do\n ma[lad.x,j] := 1;\n\n\n ans := 0;\n\n for i := 1 to 8 do\n for j := 1 to 8 do\n begin\n po.x := i;\n po.y := j;\n if ma[po.x,po.y] = 0 then\n if good2(po) then inc(ans);\n end;\n\n\n write(ans);\n\n { close(input);\n close(output); }\nend.\n"}, {"source_code": "const\n dx:array[1..8] of integer=(-2,-1,1,2,2,1,-1,-2);\n dy:array[1..8] of integer=(-1,-2,-2,-1,1,2,2,1);\nvar\n x,y:char;\n a:array[1..8,1..8] of boolean;\n i,j,q1,q2,s,bx,by:longint;\nbegin\n fillchar(a,sizeof(a),true);\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n for i:=1 to 8 do a[i,q2]:=false;\n for i:=1 to 8 do a[q1,i]:=false;\n for i:=1 to 8 do\n begin\n bx:=q1+dx[i];by:=q2+dy[i];\n if (bx>=1) and (by>=1) and (bx<=8) and (by<=8) then a[bx,by]:=false;\n end;\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n for i:=1 to 8 do\n begin\n bx:=q1+dx[i];by:=q2+dy[i];\n if (bx>=1) and (by>=1) and (bx<=8) and (by<=8) then a[bx,by]:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j] then inc(s);\n writeln(s-1);\nend."}, {"source_code": "Var\n s:string;\n ans,x1,x2,y1,y2,i,j:longint;\n p:integer;\n function ok(xx,yy:longint):boolean;\n begin\n if ((xx<>x1)or(yy<>y1))\n and ((xx<>x2)or(yy<>y2))\n and ((x1<>xx)and(y1<>yy))\n and ((abs(x1-xx)<>2)or(abs(yy-y1)<>1))\n and ((abs(x1-xx)<>1)or(abs(yy-y1)<>2))\n and ((abs(x2-xx)<>2)or(abs(yy-y2)<>1))\n and ((abs(x2-xx)<>1)or(abs(yy-y2)<>2)) then ok:=true\n else ok:=false;\n end;\n Begin\n Readln(s);\n val(s[2],x1,p);\n y1:=ord(s[1])-96;\n Readln(s);\n val(s[2],x2,p);\n y2:=ord(s[1])-96;\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ok(i,j) then inc(ans);\n Writeln(ans);\n End.\n"}, {"source_code": "{$apptype console}\n\nconst d : array [1..8, 1..2] of integer = ((1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1));\n\nvar lx, ly, kx, ky: integer;\n m : array [1..8, 1..8] of boolean;\n t : string;\n\nprocedure conv( const s : string; var x, y : integer );\nbegin\n x := ord(s[2]) - ord('1') + 1;\n y := ord(s[1]) - ord('a') + 1;\nend;\n\nprocedure Mark( x, y : integer );\nbegin\n if( x>=1) and(y>=1) and (x<=8) and(y<=8 ) then m[y][x] := false;\nend;\n\nfunction Check( x0, y0 : integer ) : boolean;\nvar i, x, y : integer;\nbegin\n result := true;\n for i := 1 to 8 do begin\n x := x0 + d[i][1];\n y := y0 + d[i][2];\n if ((x=lx)and(y=ly)) then begin result := false; break; end;\n end;\nend;\n\nvar x,y, i, s : integer;\nbegin\n readln( t );\n Conv( t, lx, ly );\n readln( t );\n Conv( t, kx, ky );\n{}\n for x := 1 to 8 do\n for y := 1 to 8 do\n if (x = lx ) or (y=ly ) then m[y][x]:=false else m[y][x] := true;\n \n m[ky][kx] := false;\n for i := 1 to 8 do Mark( kx + d[i][1], ky + d[i][2] );\n{}\n s := 0;\n for x := 1 to 8 do\n for y := 1 to 8 do\n if m[y][x] and Check( x, y ) then inc( s );\n{}\n write( s );\nend.\n"}, {"source_code": "const\n maxn = 96;\n x: array[1..8] of integer = (-1, -2, 2, 1, -1, -2, 1, 2);\n y: array[1..8] of integer = (-2, -1, 1, 2, 2, 1, -2, -1);\n\nvar\n boo: array[-10..18, -10..18] of boolean;\n l, t, x1, x2, y1, y2, i, j: longint;\n ch1, ch2: char;\n\nfunction correct1: boolean;\nbegin\n for l := 1 to 8 do\n if ((x[l] + i = x1) and (y[l] + j = y1)) or ((x[l] + i = x2) and (y[l] + j = y2))then begin\n correct1 := false;\n exit;\n end;\n if (i = x1) or (j = y1) then correct1 := false\n else\n correct1 := true;\nend;\n\n\nfunction correct: boolean;\nbegin\n if (x[i] + x2 > 0) and (x[i] + x2 <= 8) and (y[i] + y2 > 0) and (y[i] + y2 <= 8) then\n correct := true\n else\n correct := false;\nend;\n\nprocedure horse;\nbegin\n for i := 1 to 8 do\n if correct then\n boo[x2 + x[i], y2 + y[i]] := true;\nend;\n\nprocedure readchar;\nbegin\n readln(ch1, ch2);\n x1 := ord(ch1) - maxn;\n val(ch2, y1);\n read(ch1, ch2);\n x2 := ord(ch1) - maxn;\n val(ch2, y2);\n boo[x1, y1] := true;\n boo[x2, y2] := true;\nend;\n\nbegin\n readchar;\n horse;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if (not boo[i, j]) and (correct1) then\n inc(t);\n write(t);\nend."}, {"source_code": "{$R+,O-}\nUses Math;\nConst\n inf = maxlongint;\nType\n int = longint; bool = boolean;\nVar\n\tans ,x ,y ,x1 ,y1 ,code ,i ,j\t:\tint;\n\ts\t:\tstring;\n\ta\t:\tarray [-3..12,-3..12] of bool;\nBegin\n{\tReset(input,'a.in');\n\tRewrite(output,'a.out');}\n\tReadln(s);\n\tx := ord(s[1]) - ord('a') + 1;\n\tval(s[2] ,y ,code);\n\n\tReadln(s);\n\tx1 := ord(s[1]) - ord('a') + 1;\n\tval(s[2] ,y1 ,code);\n a[x ,y] := true;\n\n\tFor i := 1 to 8 do\n\t\ta[x ,i] := true;\n\n\tFor i := 1 to 8 do\n\t\ta[i ,y] := true;\n\n a[x1 ,y1] := true;\n\ta[x1+2 ,y1+1] := true;\n\ta[x1+1 ,y1+2] := true;\n\ta[x1-2 ,y1+1] := true;\n\ta[x1+1 ,y1-2] := true;\n\ta[x1+2 ,y1-1] := true;\n\ta[x1-1 ,y1+2] := true;\n\ta[x1-2 ,y1-1] := true;\n\ta[x1-1 ,y1-2] := true;\n\n\tFor i := 1 to 8 do\n\tFor j := 1 to 8 do Begin\n\t\tIf (not a[i ,j]) and not((i + 2 = x) and (j + 1 = y)) and not(((i + 1 = x) and (j + 2 = y))) and not((i - 2 = x) and (j + 1 = y)) and not((i + 1 = x) and (j - 2 = y)) and not((i + 2 = x) and (j - 1 = y)) and not((i - 1 = x) and (j + 2 = y)) and not((i - 2 = x) and (j - 1 = y)) and not((i - 1 = x) and (j - 2 = y)) and not((i + 2 = x) and (j + 1 = y)) and not(((i + 1 = x) and (j + 2 = y))) and not((i - 2 = x) and (j + 1 = y)) and not((i + 1 = x1) and (j - 2 = y1)) and not((i + 2 = x1) and (j - 1 = y1)) and not((i - 1 = x1) and (j + 2 = y1)) and not((i - 2 = x1) and (j - 1 = y1)) and not((i - 1 = x1) and (j - 2 = y1)) then\n\t\t\tinc(ans);\n\tEnd;\n\n\twrite(ans);\nEnd."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction IsB(a, b, c, d: Integer): Boolean;\nconst\n coords: array [1..8, 1..2] of Integer = ((1, 2), (-1, 2), (1, -2), (-1, -2),\n (2, 1), (-2, 1), (2, -1), (-2, -1));\nvar\n I: Integer;\nbegin\n Result := False;\n for I := 1 to 8 do\n if (a + coords[i, 1] = c) and (b + coords[i, 2] = d) then\n begin\n Result := True;\n exit;\n end;\nend;\n\nvar\n posx1, posy1, posx2, posy2: Integer;\n i, j: Integer;\n C: Char;\n cnt: Integer;\n\nbegin\n read(C); posx1 := ord(C)-ord('a')+1;\n read(C); posy1 := StrToInt(C);\n readln;\n read(C); posx2 := ord(C)-ord('a')+1;\n read(C); posy2 := StrToInt(C);\n cnt := 0;\n for I := 1 to 8 do\n for j := 1 to 8 do\n if ((i <> posx1) or (j <> posy1)) and\n ((i <> posx2) or (j <> posy2)) and\n (not isb(i, j, posx1, posy1)) and\n (not isb(i, j, posx2, posy2)) and\n (posx1 <> i) and (posy1 <> j) then\n Inc(Cnt);\n writeln(cnt);\n readln;\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$R-,Q-}\nvar\n i,j,chet,k,l : longint;\n a : array [-2..12,-2..12] of boolean;\n c : char;\nbegin\n{ reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n read(c);\n i:=ord(c)-ord('a')+1;\n read(c);\n j:=ord(c)-48;\n k:=i;\n l:=j;\n for I:=k to 8 do\n a[i,l]:=true;\n for i:=1 to k do\n a[i,l]:=true;\n for j:=1 to l do\n a[k,j]:=true;\n for j:=l to 8 do\n a[k,j]:=true;\n read(c);\n read(c);\n read(c);\n i:=ord(c)-ord('a')+1;\n read(c);\n j:=ord(c)-48;\n a[i,j]:=true;\n a[i+2,j+1]:=true;\n a[i+1,j+2]:=true;\n a[i+2,j-1]:=true;\n a[i+1,j-2]:=true;\n a[i-2,j+1]:=true;\n a[i-1,j+2]:=true;\n a[i-2,j-1]:=true;\n a[i-1,j-2]:=true;\n for I:=1 to 8 do\n for j:=1 to 8 do\n if not a[i,j] and not ((i+2=k) and (j+1=l))and not ((i+1=k) and (j+2=l))and not ((i+2=k) and (j-1=l))and not ((i+1=k) and (j-2=l))and not ((i-2=k) and (j+1=l))and not ((i-1=k) and (j+2=l))and not ((i-2=k) and (j-1=l))and not ((i-1=k) and (j-2=l)) then\n inc(chet);\n write(chet);\nend.\n\n"}, {"source_code": "var n,i,j,t,p,v,w:integer;\n\nd:array [1..8,1..8] of integer;\na,b:string;\n\nbegin\n\nreadln (a);\nreadln (b);\n\np:=0;\n\nfor i:=1 to 8 do\n begin\n for j:=1 to 8 do d[i,j]:=0;\n end;\n\nw:=ord(a[1])-96;\nv:=ord(a[2])-48;\n\nfor i:=1 to 8 do d[v,i]:=1;\n\nfor i:=1 to 8 do d[i,w]:=1;\n\nif (v+1<=8)and(w+2<=8) then d[v+1,w+2]:=1;\nif (v+2<=8)and(w+1<=8) then d[v+2,w+1]:=1;\nif (v+2<=8)and(w-1>0) then d[v+2,w-1]:=1;\nif (v+1<=8)and(w-2>0) then d[v+1,w-2]:=1;\nif (v-1>0)and(w-2>0) then d[v-1,w-2]:=1;\nif (v-2>0)and(w-1>0) then d[v-2,w-1]:=1;\nif (v-2>0)and(w+1<=8) then d[v-2,w+1]:=1;\nif (v-1>0)and(w+2<=8) then d[v-1,w+2]:=1;\n\n\nw:=ord(b[1])-96;\nv:=ord(b[2])-48;\n\nd[v,w]:=2;\nif (v+1<=8)and(w+2<=8) then d[v+1,w+2]:=2;\nif (v+2<=8)and(w+1<=8) then d[v+2,w+1]:=2;\nif (v+2<=8)and(w-1>0) then d[v+2,w-1]:=2;\nif (v+1<=8)and(w-2>0) then d[v+1,w-2]:=2;\nif (v-1>0)and(w-2>0) then d[v-1,w-2]:=2;\nif (v-2>0)and(w-1>0) then d[v-2,w-1]:=2;\nif (v-2>0)and(w+1<=8) then d[v-2,w+1]:=2;\nif (v-1>0)and(w+2<=8) then d[v-1,w+2]:=2;\nt:=0;\nfor i:=1 to 4 do\n begin\n for j:=1 to 8 do\n begin t:=d[i,j]; d[i,j]:=d[8-i+1,j]; d[8-i+1,j]:=t; end;\n end;\n\nfor i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if (d[i,j]=0) then p:=p+1;\n end;\n\nwriteln(p);\nend."}, {"source_code": "program ochered;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar mass: array [-8..8, -8..8] of longint;\n i, j, q: longint;\n a: char;\n\nbegin\n readln(a, i);\n mass[9-i, ord(a)-ord('a')+1]:= 2;\n for j:= 1 to 8 do\n if mass[9-i, j] <> 2 then mass[9-i, j]:= 1;\n for j:= 1 to 8 do\n if mass[j, ord(a)-ord('a')+1] <> 2 then mass[j, ord(a)-ord('a')+1]:= 1;\n readln(a, i);\n j:= ord(a)-ord('a')+1;\n q:= 9-i;\n mass[q, j]:= 2;\n mass[q-2, j-1]:= 1;\n mass[q-2, j+1]:= 1;\n mass[q-1, j-2]:= 1;\n mass[q-1, j+2]:= 1;\n mass[q+1, j-2]:= 1;\n mass[q+1, j+2]:= 1;\n mass[q+2, j-1]:= 1;\n mass[q+2, j+1]:= 1;\n i:= 0;\n for q:= 1 to 8 do\n for j:= 1 to 8 do\n if (mass[q, j] = 0) and\n (mass[q-2, j-1]<> 2) and\n (mass[q-2, j+1]<> 2) and\n (mass[q-1, j-2]<> 2) and\n (mass[q-1, j+2]<> 2) and\n (mass[q+1, j-2]<> 2) and\n (mass[q+1, j+2]<> 2) and\n (mass[q+2, j-1]<> 2) and\n (mass[q+2, j+1]<> 2) then inc(i);\n write(i);\nend.\n"}, {"source_code": "program aa;\n\n{$APPTYPE CONSOLE}\n \nuses\n SysUtils;\n\nconst\n h = 8;\n v = 8;\n dx: array [1..h] of integer = (-2, -1, 1, 2, 1, 2, -2, -1);\n dy: array [1..v] of integer = (1, 2, -2, -1, 2, 1, -1, -2);\n inf = -1;\n maxN = 100;\ntype\n Tpoint = record\n x, y: integer;\nend;\nvar\n str1, str2: string;\n s, tmp, e: Tpoint;\n i, j, k: integer;\n d: array[-2..maxN + 2, -2..maxN + 2] of integer;\nLabel masha;\nbegin\n k := 0;\n readln(str1);\n readln(str2);\n\n fillchar(d, sizeof(d), 0);\n s.x := ord(str1[1]) - 96;\n s.y := ord(str1[2]) - 48;\n e.x := ord(str2[1]) - 96;\n e.y := ord(str2[2]) - 48;\n for i := 1 to h do\n d[s.x , i] := 1;\n for i := 1 to h do\n d[i, s.y] := 1;\n for i := 1 to 8 do begin\n tmp.x := e.x + dx[i];\n tmp.y := e.y + dy[i];\n d[tmp.x, tmp.y] := 1;\n end;\n for i := 1 to 8 do begin\n tmp.x := s.x + dx[i];\n tmp.y := s.y + dy[i];\n d[tmp.x, tmp.y] := 1;\n end;\n d[e.x, e.y] := 1;\n for i := -2 to 0 do\n for j := -2 to h do\n d[i , j] := 0;\n for i := -2 to h do\n for j := -2 to 0 do\n d[i , j] := 0;\n\n for i := 1 to h do\n for j := 1 to h do\n if d[i, j] = 0 then inc(k);\n writeln(k);\n end.\n"}, {"source_code": "{$MAXSTACKSIZE $00100000}\n{$O-,R+,Q+}\nuses\n SysUtils,Math;\ntype int=longint;\n point=record x,y:int; end;\nconst l=8;\nvar ld, kn,p:point;\n v:array[1..l,1..l] of boolean;\nprocedure init;\nbegin\n reset(input,'input.txt');\n rewrite(output,'output.txt');\nend;\n\nprocedure closing;\nbegin\n close(input);\n close(output);\nend;\n\nfunction good(x,y:int):boolean;\nbegin\n good:=(x>=1)and(x<=l)and(y>=1)and(y<=l);\nend;\n\nfunction f(a,b:point):boolean;\nbegin\n f:=(a.x<>b.x)or(a.y<>b.y);\nend;\n\nprocedure getdata;\nvar c:char;\n x,y:int;\nbegin\n read(c);\n y:=ord(c)-ord('a')+1;\n readln(x);\n x:=l-x+1;\n ld.x:=x; ld.y:=y;\n\n read(c);\n y:=ord(c)-ord('a')+1;\n readln(x);\n x:=l-x+1;\n kn.x:=x; kn.y:=y;\nend;\n\nprocedure solve;\nvar i,di,dj,d,ans,x,y:int;\n can:boolean;\nbegin\n fillchar(v,sizeof(v),0);\n getdata;\n //ld\n for d:=-l to l do begin\n if good(ld.x+d,ld.y) then\n v[ld.x+d,ld.y]:=true;\n if good(ld.x,ld.y+d) then\n v[ld.x,ld.y+d]:=true;\n end;\n //kn\n v[kn.x,kn.y]:=true;\n for di:=-1 to 1 do\n for dj:=-1 to 1 do\n if di*dj<>0 then begin\n if good(kn.x+di,kn.y+2*dj) then\n v[kn.x+di,kn.y+2*dj]:=true;\n if good(kn.x+2*di,kn.y+dj) then\n v[kn.x+2*di,kn.y+dj]:=true;\n end;\n //main\n ans:=0;\n for x:=1 to l do\n for y:=1 to l do begin\n can:=true;\n if v[x,y] then\n continue;\n for di:=-1 to 1 do\n for dj:=-1 to 1 do\n if di*dj<>0 then begin\n if good(x+di,y+2*dj) then begin\n p.x:=x+di; p.y:=y+2*dj;\n can:=can and f(p,kn) and f(p,ld);\n end;\n if good(x+2*di,y+dj) then begin\n p.x:=x+2*di; p.y:=y+dj;\n can:=can and f(p,kn) and f(p,ld);\n end;\n end;\n if can then\n inc(ans);\n end;\n write(ans);\nend;\n\nbegin\n //init;\n solve;\n //closing;\nend.\n"}, {"source_code": "var l,k,s:string;\n x,lx,kx,ly,ky,y,n:integer;\n flag:boolean;\nbegin\n readln(input,l);\n readln(input,k);\n lx:=ord(l[1]);\n ly:=ord(l[2])-ord('0');\n kx:=ord(k[1]);\n ky:=ord(k[2])-ord('0');\n n:=0;\n\n for x:=ord('a') to ord('h') do\n begin\n for y:=1 to 8 do\n begin\n flag:=true;\n if (x=lx) or (y=ly) then flag:=false;\n if (x=kx) and (y=ky) then flag:=false;\n if (abs(x-kx)=1) and (abs(y-ky)=2) then flag:=false;\n if (abs(x-kx)=2) and (abs(y-ky)=1) then flag:=false;\n if (abs(x-lx)=1) and (abs(y-ly)=2) then flag:=false;\n if (abs(x-lx)=2) and (abs(y-ly)=1) then flag:=false;\n if flag then n:=n+1;\n end;\n end;\n\n write(output,n);\nend."}, {"source_code": "program b1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s:string;\n x,y,x1,y1,i,j,r:longint;\n\nbegin\n readln(s);\n x:=ord(s[1])-ord('a')+1;\n y:=ord(s[2])-ord('0');\n readln(s);\n x1:=ord(s[1])-ord('a')+1;\n y1:=ord(s[2])-ord('0');\n r:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (i<>x)and(j<>y)and((x1<>i)or(y1<>j)) then\n begin\n if (((abs(i-x1)=2)and(abs(j-y1)=1))or\n ((abs(i-x1)=1)and(abs(j-y1)=2)))or\n (((abs(i-x)=2)and(abs(j-y)=1))or\n ((abs(i-x)=1)and(abs(j-y)=2))) then x:=x else begin inc(r); end;\n end;\n writeln(r);\n\n\nend.\n"}, {"source_code": "type kieu = record\n r,c:integer;\n end;\nconst fi = '';\n fo = '';\n col:array['a'..'h'] of integer = (1,2,3,4,5,6,7,8);\n dr:array[1..8] of integer = (-2,-1,1,2,2,1,-1,-2);\n dc:array[1..8] of integer = (1,2,2,1,-1,-2,-2,-1);\nvar res:longint;\n posr,posk:kieu;\n check:array[1..8,1..8] of boolean;\nprocedure nhap;\nvar f:Text;\n rt,kt:string;\nbegin\n assign(f,fi); reset(f);\n readln(f,rt);\n readln(f,kt);\n posr.c:=col[rt[1]]; posr.r:=ord(rt[2])-48;\n posk.c:=col[kt[1]]; posk.r:=ord(kt[2])-48;\n close(f);\nend;\nprocedure solve;\nvar i,r,c:longint;\nbegin\n res:=48;\n check[posr.r,posr.c]:=true;\n check[posk.r,posk.c]:=true;\n for i:=1 to 8 do check[posr.r,i]:=true;\n for i:=1 to 8 do check[i,posr.c]:=true;\n for i:=1 to 8 do\n begin\n r:=posr.r+dr[i]; c:=posr.c+dc[i];\n if (r<=8) and (r>=1) and (c<=8) and (c>=1) and (not check[r,c]) then\n begin\n check[r,c]:=true; dec(res);\n end;\n end;\n for i:=1 to 8 do\n begin\n r:=posk.r+dr[i]; c:=posk.c+dc[i];\n if (r<=8) and (r>=1) and (c<=8) and (c>=1) and (not check[r,c]) then\n begin\n check[r,c]:=true; dec(res);\n end;\n end;\nend;\nprocedure xuat;\nvar f:text;\nbegin\n assign(f,fo); rewrite(f);\n writeln(f,res);\n close(F);\nend;\nbegin\n nhap;\n solve;\n xuat;\nend.\n\n\n\n\n"}, {"source_code": "Var a,b:char;\n q,w,i,j,k,l,ans:longint;\n x:array[1..8] of char;\n c:array[-100..100,-100..100] of boolean;\n Begin\n readln(a,i);\n readln(b,j);\n for q:=1 to 8 do\n for w:=1 to 8 do\n c[q,w]:=true;\n x[1]:='a';\n x[2]:='b';\n x[3]:='c';\n x[4]:='d';\n x[5]:='e';\n x[6]:='f';\n x[7]:='g';\n x[8]:='h';\n for q:=1 to 8 do\n begin\n if a=x[q] then k:=q;\n if b=x[q] then l:=q;\n end;\n c[k,i]:=false;\n c[k+2,i+1]:=false;\n c[k+2,i-1]:=false;\n c[k-2,i+1]:=false;\n c[k-2,i-1]:=false;\n c[k+1,i+2]:=false;\n c[k+1,i-2]:=false;\n c[k-1,i+2]:=false;\n c[k-1,i-2]:=false;\n c[l+2,j+1]:=false;\n c[l+2,j-1]:=false;\n c[l-2,j+1]:=false;\n c[l-2,j-1]:=false;\n c[l+1,j+2]:=false;\n c[l+1,j-2]:=false;\n c[l-1,j-2]:=false;\n c[l-1,j+2]:=false;\n c[l,j]:=false;\n for q:=1 to 8 do\n c[k,q]:=false;\n for q:=1 to 8 do\n c[q,i]:=false;\n for q:=1 to 8 do\n for w:=1 to 8 do\n begin\n if c[q,w] then inc(ans);\n end;\n writeln(ans);\n End."}, {"source_code": "program Konandladya;\n\n{$APPTYPE CONSOLE}\n\nconst\nn=8;\nvar\na : array [1..n,1..n] of 0..3;\ns : string;\ni,j,ans,x1,y1,x2,y2 : byte;\nfl : boolean;\nbegin\n{assign (input,'in.txt');\nassign (output,'out.txt');\nreset (input);\nrewrite (output);}\nans:=0;\nreadln (s);\nx1:=9-ord(s [2])+ord ('0');\ny1:=ord (s [1])-ord ('a')+1;\nreadln (s);\nx2:=9-ord(s [2])+ord ('0');\ny2:=ord (s [1])-ord ('a')+1;\nfillchar (a,sizeof(a),0);\na [x1,y1]:=2;\na [x2,y2]:=1;\nfor i:=1 to n do\n for j:=1 to n do\n begin\n if (i=x2+1) and ((j=y2+2) or (j=y2-2)) then a [i,j]:=1;\n if (i=x2-1) and ((j=y2+2) or (j=y2-2)) then a [i,j]:=1;\n if (i=x2+2) and ((j=y2+1) or (j=y2-1)) then a [i,j]:=1;\n if (i=x2-2) and ((j=y2+1) or (j=y2-1)) then a [i,j]:=1;\n if ((x1=i) and (y1<>j)) or ((y1=j) and (x1<>i)) then a [i,j]:=2;\n end;\n{for i:=1 to n do\nbegin\n for j:=1 to n do\n write (a [i,j] : 5);\n writeln;\nend;}\nfor i:=1 to n do\n for j:=1 to n do\n if a [i,j]=0 then\n begin\n fl:=true;\n if (x1=i+1) and ((y1=j+2) or (y1=j-2)) then fl:=false;\n if (x1=i-1) and ((y1=j+2) or (y1=j-2)) then fl:=false;\n if (x1=i+2) and ((y1=j+1) or (y1=j-1)) then fl:=false;\n if (x1=i-2) and ((y1=j+1) or (y1=j-1)) then fl:=false;\n if (x2=i+1) and ((y2=j+2) or (y2=j-2)) then fl:=false;\n if (x2=i-1) and ((y2=j+2) or (y2=j-2)) then fl:=false;\n if (x2=i+2) and ((y2=j+1) or (y2=j-1)) then fl:=false;\n if (x2=i-2) and ((y2=j+1) or (y2=j-1)) then fl:=false;\n if fl then inc (ans);\n end;\n write (ans);\nend.\n"}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-100..100,-100..100] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]=3 then q1:=false;\n if a[x1,i]=3 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n a[i,j]:=3;\n if tt then k:=k+1;\n a[i,j]:=0;\n end;\n writeln(k);\n end."}, {"source_code": "const dx:array[1..8] of shortint=(1,1,2,2,-1,-1,-2,-2);\n dy:array[1..8] of shortint=(-2,2,1,-1,2,-2,1,-1);\nvar a:array[1..8,'a'..'h'] of byte;\n x1,x2:char;y1,y2:byte;n:integer;\nprocedure lad;\nvar i:integer;c:char;\nbegin\n for i:=1 to 8 do\n a[i,x1]:=1;\n for c:='a' to 'h' do\n a[y1,c]:=1;\n for i:=1 to 8 do\n if (chr(ord(x1)+dx[i])<='h')and\n (chr(ord(x1)+dx[i])>='a')and\n (y1+dy[i]>=1)and(y1+dy[i]<=8)\n then a[y1+dy[i],chr(ord(x1)+dx[i])]:=1;\nend;\nprocedure kon;\nvar i,y1:integer;c,x1:char;\nbegin\n x1:=x2;y1:=y2;a[y2,x2]:=1;\n for i:=1 to 8 do\n if (chr(ord(x1)+dx[i])<='h')and\n (chr(ord(x1)+dx[i])>='a')and\n (y1+dy[i]>=1)and(y1+dy[i]<=8)\n then a[y1+dy[i],chr(ord(x1)+dx[i])]:=1;\nend;\nprocedure count;\nvar i:integer;c:char;\nbegin\n for i:=1 to 8 do\n for c:='a' to 'h' do\n if a[i,c]=0 then inc(n);\nend;\nbegin\n{ assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n read(x1);readln(y1); read(x2);readln(y2);\n lad;\n kon;\n count;\n writeln(n);\nend."}, {"source_code": "program indB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar ch1, ch2: char;\n y1, y2, x1, x2, f, ans, i, j: integer;\n fl: boolean;\n a: array[-1..10, -1..10] of integer;\n\nbegin\n readln(ch1, y1);\n readln(ch2, y2);\n\n x1:=ord(ch1)-96;\n x2:=ord(ch2)-96;\n\n fillchar(a, sizeof(a), 0);\n\n a[x2-2, y2+1]:=1;\n a[x2-2, y2-1]:=1;\n a[x2-1, y2+2]:=1;\n a[x2-1, y2-2]:=1;\n a[x2+1, y2-2]:=1;\n a[x2+1, y2+2]:=1;\n a[x2+2, y2+1]:=1;\n a[x2+2, y2-1]:=1;\n\n for i:=1 to 8 do\n begin\n a[x1, i]:=1;\n a[i, y1]:=1;\n end;\n\n a[x1, y1]:=2;\n a[x2, y2]:=2;\n\n ans:=0;\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i, j]=0 then\n begin\n fl:=true;\n if a[i-2, j+1]=2 then fl:=false;\n if a[i-2, j-1]=2 then fl:=false;\n if a[i-1, j+2]=2 then fl:=false;\n if a[i-1, j-2]=2 then fl:=false;\n if a[i+1, j-2]=2 then fl:=false;\n if a[i+1, j+2]=2 then fl:=false;\n if a[i+2, j+1]=2 then fl:=false;\n if a[i+2, j-1]=2 then fl:=false;\n if fl=true then inc(ans);\n end;\n\n end;\n writeln(ans);\n readln;\n\n\nend.\n"}, {"source_code": "var\n a:array[1..8,1..8] of integer;\n i,j,x1,y1,x2,y2,k,f:integer;\n s1,s2:string;\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96; y1:=ord(s1[2])-48; //�����\n x2:=ord(s2[1])-96; y2:=ord(s2[2])-48; //����\n k:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n // if (i<>x1)and(j<>y1)and(i<>x2)and(j<>y2) then\n begin\n f:=0;//�� ����\n if ((abs(i-x1)=1)and(abs(j-y1)=2))or((abs(i-x1)=2)and(abs(j-y1)=1))then f:=1;//���� �����\n if ((abs(i-x2)=1)and(abs(j-y2)=2))or((abs(i-x2)=2)and(abs(j-y2)=1))then f:=1;//���� ����\n if (x1=i)or(y1=j) then f:=1;//����� ���� ����\n if f=0 then inc(k);\n end;\n end;\n writeln(k-1);\nend.\n"}, {"source_code": "{$mode objfpc}\n\n\nconst InputFile = 'problemB.inp';\n dX : array ['a' .. 'h'] of integer = ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );\n dY : array ['1' .. '8'] of integer = ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );\n\n\ntype TPosition = record\n x , y : integer;\n end;\n\n\nvar rook , knight : TPosition;\n d : array [1 .. 8 , 1 .. 8] of boolean;\n res : integer;\n i , j : integer;\n ss : string[2];\n\n\nprocedure push( x , y : integer );\n begin\n if ( x > 0 ) and ( y > 0 ) and ( x < 9 ) and ( y < 9 ) and d[x][y] then\n d[x][y] := false;\n end;\n\n\nprocedure Find( x , y : integer );\n begin\n d[x][y] := false;\n push( x + 2 , y + 1 );\n push( x - 2 , y + 1 );\n push( x + 2 , y - 1 );\n push( x - 2 , y - 1 );\n push( x + 1 , y + 2 );\n push( x - 1 , y + 2 );\n push( x + 1 , y - 2 );\n push( x - 1 , y - 2 );\n end;\n\n\nbegin\n readln( ss );\n rook.x := dX[ss[1]]; rook.y := dY[ss[2]];\n readln( ss );\n knight.x := dX[ss[1]]; knight.y := dY[ss[2]];\n fillchar( d , sizeof( d ) , true );\n for i := 1 to 8 do\n begin\n d[rook.x][i] := false;\n d[i][rook.y] := false;\n end;\n Find( rook.x , rook.y );\n Find( knight.x , knight.y );\n for i := 1 to 8 do\n for j := 1 to 8 do\n if d[i][j] then\n inc( res );\n writeln( res );\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\n{$R+}\nuses\nSysUtils;\nvar\nk,x1,y1,j,i,x,y:longint;\na:array[-100..100,-100..100]of boolean;\nb:array[-1..800,-1..800]of boolean;\ns:string;\nbegin\n//reset(input,'input.txt');rewrite(output,'output.txt');\n\nreadln(s);\nx1:=strtoint(s[2]);\ny1:=ord(s[1])-96;\n\nread(s);\nx:=strtoint(s[2]);\ny:=ord(s[1])-96;\na[x,y]:=true;\na[x1,y1]:=true;\n\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nbegin\nif a[i-1,j-2] then b[i,j]:=true;\nif a[i-2,j-1] then b[i,j]:=true;\nif a[i+1,j+2] then b[i,j]:=true;\nif a[i+2,j+1] then b[i,j]:=true;\nif a[i+1,j-2] then b[i,j]:=true;\nif a[i+2,j-1] then b[i,j]:=true;\nif a[i-1,j+2] then b[i,j]:=true;\nif a[i-2,j+1] then b[i,j]:=true;\nend;\n\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nif b[i,j] then a[i,j]:=true;\n\nfor i:=1 to 8 do\na[x1,i]:=true;\nfor i:=1 to 8 do\na[i,y1]:=true;\n\nk:=0;\nfor i:=1 to 8 do\nfor j:=1 to 8 do\nif not a[i,j] then inc(k);\n\nwrite(k);\nend. \n"}, {"source_code": "program Project22222;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n dx: array [1..8] of Longint = (2, 2, -2, -2, 1, 1, -1, -1);\n dy: array [1..8] of Longint = (1, -1, 1, -1, 2, -2, 2, -2);\nvar\n a: array [1..8, 1..8] of Byte;\n ch1, ch2: Char;\n r, c, j, k, i, rx, ry, kx, ky: Longint;\n\nfunction correct(x, y: Integer): Boolean;\nbegin\n correct := (x >= 1) and (x <= 8) and (y >= 1) and (y <= 8);\nend;\n\nbegin\n{\n Reset(Input,'in.txt');\n Rewrite(Output,'out.txt');\n}\n Read(ch1, ch2);\n case ch1 of\n 'a': rx:= 1;\n 'b': rx:= 2;\n 'c': rx:= 3;\n 'd': rx:= 4;\n 'e': rx:= 5;\n 'f': rx:= 6;\n 'g': rx:= 7;\n 'h': rx:= 8;\n end;\n ry:= StrToInt(ch2);\n\n Readln;\n c:= 0;\n Read(ch1, ch2);\n case ch1 of\n 'a': kx:= 1;\n 'b': kx:= 2;\n 'c': kx:= 3;\n 'd': kx:= 4;\n 'e': kx:= 5;\n 'f': kx:= 6;\n 'g': kx:= 7;\n 'h': kx:= 8;\n end;\n ky:= StrToInt(ch2);\n\n for i := 1 to 8 do begin\n a[rx, i] := 1;\n a[i, ry] := 1;\n end;\n\n for i := 1 to 8 do begin\n if correct(kx + dx[i], ky + dy[i]) then begin\n a[kx + dx[i], ky + dy[i]] := 1;\n end;\n end;\n\n a[rx, ry] := 2;\n a[kx, ky] := 2;\n\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n if a[i, j] > 0 then begin\n inc(c);\n continue;\n end;\n for k := 1 to 8 do begin\n if not correct(i + dx[k], j + dy[k]) then begin\n continue;\n end;\n if (a[i + dx[k], j + dy[k]] = 2) then begin\n r := 1;\n break;\n end;\n end;\n if r = 1 then begin\n inc(c);\n r := 0;\n end;\n end;\n end;\n\n Writeln(64 - c);\n\nend.\n"}, {"source_code": "const fi='';\n fo='';\n cx:array[1..8]of shortint=(1,1,-1,-1,2,2,-2,-2);\n cy:array[1..8]of shortint=(2,-2,2,-2,1,-1,1,-1);\nvar\n f:text;\n s1,s2:string;\n x1,y1,x2,y2,i,j,x,h,k,sl:longint;\n v:array[1..8,1..8]of boolean;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,s1);\n readln(f,s2);\n close(f);\n x1:=ord(s1[1])-ord('a')+1;\n y1:=ord(s1[2])-ord('0');\n x2:=ord(s2[1])-ord('a')+1;\n y2:=ord(s2[2])-ord('0');\n fillchar(v,sizeof(v),false);\n for i := 1 to 8 do\n begin\n v[i][y1]:=true;\n v[x1][i]:=true;\n end;\n v[x2][y2]:=true;\n for i := 1 to 8 do\n begin\n h:=x2+cx[i];\n k:=y2+cy[i];\n if(h>=1)and(h<=8)and(k>=1)and(k<=8)then\n v[h][k]:=true;\n end;\n sl:=0;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if(v[i][j]=false)then\n begin\n inc(sl);\n for x := 1 to 8 do\n begin\n h:=i+cx[x];\n k:=j+cy[x];\n if((h=x1)and(k=y1))or((h=x2)and(k=y2))then\n begin\n dec(sl);\n break;\n end;\n end;\n end;\n assign(f,fo);\n rewrite(f);\n writeln(f,sl);\n close(f);\nend."}, {"source_code": "var s:string[2]; a:array[1..8,1..8] of boolean; i,j,n:byte;\nbegin\n fillchar(a,sizeof(a),true);\n readln(s);\n j:=ord(s[2])-48; n:=15;\n for i:=1 to 8 do a[i,j]:=false;\n i:=ord(s[1])-96;\n fillchar(a[i],sizeof(a[i]),false);\n if i>2 then\n begin\n if j>1 then\n begin\n inc(n);\n a[i-2,j-1]:=false\n end;\n if j<8 then\n begin\n inc(n);\n a[i-2,j+1]:=false\n end\n end;\n if j<7 then\n begin\n if i>1 then\n begin\n inc(n);\n a[i-1,j+2]:=false\n end;\n if i<8 then\n begin\n inc(n);\n a[i+1,j+2]:=false\n end\n end;\n if i<7 then\n begin\n if j>1 then\n begin\n inc(n);\n a[i+2,j-1]:=false\n end;\n if j<8 then\n begin\n inc(n);\n a[i+2,j+1]:=false\n end\n end;\n if j>2 then\n begin\n if i>1 then\n begin\n inc(n);\n a[i-1,j-2]:=false\n end;\n if i<8 then\n begin\n inc(n);\n a[i+1,j-2]:=false\n end\n end;\n read(s);\n i:=ord(s[1])-96; j:=ord(s[2])-48; a[i,j]:=false;\n inc(n);\n if i>2 then\n begin\n if (j>1) and a[i-2,j-1] then\n begin\n inc(n);\n a[i-2,j-1]:=false\n end;\n if (j<8) and a[i-2,j+1] then\n begin\n inc(n);\n a[i-2,j+1]:=false\n end\n end;\n if j<7 then\n begin\n if (i>1) and a[i-1,j+2] then\n begin\n inc(n);\n a[i-1,j+2]:=false\n end;\n if (i<8) and a[i+1,j+2] then\n begin\n inc(n);\n a[i+1,j+2]:=false\n end\n end;\n if i<7 then\n begin\n if (j>1) and a[i+2,j-1] then\n begin\n inc(n);\n a[i+2,j-1]:=false\n end;\n if (j<8) and a[i+2,j+1] then\n begin\n inc(n);\n a[i+2,j+1]:=false\n end\n end;\n if j>2 then\n begin\n if (i>1) and a[i-1,j-2] then\n begin\n inc(n);\n a[i-1,j-2]:=false\n end;\n if (i<8) and a[i+1,j-2] then\n begin\n inc(n);\n a[i+1,j-2]:=false\n end\n end;\n write(64-n)\nend."}, {"source_code": "program storm;\nvar dosk:array[-20..20,-20..20] of char;\n kol,nom1,nom2:longint;\n\n\nprocedure lad(b:char; nom:longint);\nvar i,j:longint;\nbegin\n dosk[9-(ord(b)-96),nom]:='*';\n for i:=1 to 8 do\n if dosk[i,nom]<>'*' then dosk[i,nom]:='#';\n for i:=1 to 8 do\n if dosk[(9-(ord(b)-96)),i]<>'*' then dosk[(9-(ord(b)-96)),i]:='#';\nend;\n\nprocedure kon(b:char; nom:longint);\nvar nom1,nom2:longint;\nbegin\n nom1:=9-(ord(b)-96); nom2:=nom;\n dosk[nom1,nom2]:='*';\n dosk[nom1-1,nom2-2]:='#'; dosk[nom1-2,nom2-1]:='#';\n dosk[nom1+1,nom2-2]:='#'; dosk[nom1+2,nom2-1]:='#';\n dosk[nom1+1,nom2+2]:='#'; dosk[nom1+2,nom2+1]:='#';\n dosk[nom1-1,nom2+2]:='#'; dosk[nom1-2,nom2+1]:='#';\nend;\n\nprocedure outputdata;\nbegin\n writeln(kol);\nend;\n\nprocedure inputdata;\nvar chiclo1,chiclo2,code:longint;\n c1,c2:char;\n s1,s2:string;\nbegin\n readln(s1);\n readln(s2);\n c1:=s1[1]; c2:=s2[1];\n val(s1[2],chiclo1,code); val(s2[2],chiclo2,code);\n lad(c1,chiclo1);\n kon(c2,chiclo2);\nend;\n\nbegin\n inputdata; kol:=0;\n for nom1:=1 to 8 do\n for nom2:=1 to 8 do\n if (dosk[nom1,nom2]<>'*') and (dosk[nom1,nom2]<>'#') and (dosk[nom1-1,nom2-2\n ]<>'*') and\n (dosk[nom1-2,nom2-1]<>'*') and (dosk[nom1+1,nom2-2]<>'*') and (dosk[nom1+2,nom2-1]<>'*') and\n (dosk[nom1+1,nom2+2]<>'*') and (dosk[nom1+2,nom2+1]<>'*') and (dosk[nom1-1,nom2+2]<>'*')\n and (dosk[nom1-2,nom2+1]<>'*') then inc(kol);\n outputdata;\nend."}, {"source_code": "{$Apptype console}\nuses\n SysUtils;\nconst\n a : array[1..8] of longint = (-2, -2, -1, -1, 1, 1, 2, 2);\n b : array[1..8] of longint = (-1, 1, -2, 2, 2, -2, 1, -1);\ntype\nt = array[-10..100] of longint;\nt1 = array[-10..100] of t;\n\nvar i, n, j, x1, y1, x2, y2, ans : longint;\n d : t1;\n ch1, ch2 : char;\nbegin\n {assign(input, 'input.txt');\n assign(output, 'output.txt');\n reset(input);\n rewrite(output); }\n read(ch1, ch2);\n readln;\n x1 := ord(ch1) - ord('a') + 1;\n y1 := ord(ch2) - ord('0');\n read(ch1, ch2);\n x2 := ord(ch1) - ord('a') + 1;\n y2 := ord(ch2) - ord('0');\n d[x2, y2] := 1;\n for i := 1 to 8 do begin\n d[i, y1] := 1;\n d[x1, i] := 1;\n d[x2 + a[i], y2 + b[i]] := 1;\n d[x1 + a[i], y1 + b[i]] := 1;\n end;\n ans := 0;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if d[i, j] = 0 then inc(ans);\n write(ans);\n {close(input);\n close(output); }\nend.\n \n"}, {"source_code": "var\ns: array [-4..12,-4..12] of byte;\ns1,s2: string;\nx1,x2,y1,y2,i,i2,sum:word;\n\nbegin\nsum:=0;\nreadln(s1);\nreadln(s2);\ny1:=ord(s1[1])-96;\nx1:=ord(s1[2])-48;\ny2:=ord(s2[1])-96;\nx2:=ord(s2[2])-48;\n\nfor i:= 1 to 8 do\n for i2:= 1 to 8 do\n s[i,i2]:=0;\n\nfor i:=1 to 8 do\nbegin\n s[i,y1]:=1;\n s[x1,i]:=1;\nend;\n\ns[x2,y2]:=1;\ns[x2+1,y2+2]:=1;\ns[x2-1,y2+2]:=1;\ns[x2+1,y2-2]:=1;\ns[x2-1,y2-2]:=1;\ns[x2+2,y2+1]:=1;\ns[x2+2,y2-1]:=1;\ns[x2-2,y2+1]:=1;\ns[x2-2,y2-1]:=1;\ns[x1+1,y1+2]:=1;\ns[x1-1,y1+2]:=1;\ns[x1+1,y1-2]:=1;\ns[x1-1,y1-2]:=1;\ns[x1+2,y1+1]:=1;\ns[x1+2,y1-1]:=1;\ns[x1-2,y1+1]:=1;\ns[x1-2,y1-1]:=1;\n\nfor i:= 1 to 8 do\n for i2:= 1 to 8 do\n if s[i,i2]=0\n then\n inc(sum);\nwriteln;\nwriteln(sum);\nend.\n"}, {"source_code": "var\nxx1,xx2:char;\nans,i,j,y1,x1,y2,x2:longint;\na:array[-10..100,-10..100]of longint;\n begin\n readln(xx1,y1);\n readln(xx2,y2);\n x1:=ord(xx1)-96;\n x2:=ord(xx2)-96;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n if (a[x2-1,y2-2]=0) then a[x2-1,y2-2]:=1;\n if (a[x2-1,y2+2]=0) then a[x2-1,y2+2]:=1;\n if (a[x2+1,y2-2]=0) then a[x2+1,y2-2]:=1;\n if (a[x2+1,y2+2]=0) then a[x2+1,y2+2]:=1;\n if (a[x2-2,y2-1]=0) then a[x2-2,y2-1]:=1;\n if (a[x2-2,y2+1]=0) then a[x2-2,y2+1]:=1;\n if (a[x2+2,y2-1]=0) then a[x2+2,y2-1]:=1;\n if (a[x2+2,y2+1]=0) then a[x2+2,y2+1]:=1;\n\n for i:=1 to 8 do\n begin\n if a[x1,i]=0 then a[x1,i]:=1;\n if a[i,y1]=0 then a[i,y1]:=1;\n end;\n\n for i:=-10 to 100 do\n for j:=-10 to 100 do\n if (i<1)or(i>8)or(j<1)or(j>8) then a[i,j]:=0;\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0)\n and(a[i-1,j-2]<2)\n and(a[i-1,j+2]<2)\n and(a[i+1,j-2]<2)\n and(a[i+1,j+2]<2)\n and(a[i-2,j-1]<2)\n and(a[i-2,j+1]<2)\n and(a[i+2,j-1]<2)\n and(a[i+2,j+1]<2)\n then ans:=ans+1;\n writeln(ans);\n end."}, {"source_code": "var\n ly, l, k, ky, ans, i, j: shortint;\n ls, ks: string;\n code1, code2: integer;\nbegin\nreadln (ls);\nreadln (ks);\nif ls[1]='a' then l:=1;\nif ls[1]='b' then l:=2;\nif ls[1]='c' then l:=3;\nif ls[1]='d' then l:=4;\nif ls[1]='e' then l:=5;\nif ls[1]='f' then l:=6;\nif ls[1]='g' then l:=7;\nif ls[1]='h' then l:=8;\n\nif ks[1]='a' then k:=1;\nif ks[1]='b' then k:=2;\nif ks[1]='c' then k:=3;\nif ks[1]='d' then k:=4;\nif ks[1]='e' then k:=5;\nif ks[1]='f' then k:=6;\nif ks[1]='g' then k:=7;\nif ks[1]='h' then k:=8;\nval(ls[2], ly, code1);\nval(ks[2], ky, code2);\nans:=64;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if ((l=i) and (ly=j)) or ((k=i) and (ky=j)) then ans:=ans-1\n else if ((abs(k-i)=1) and (abs(ky-j)=2)) or ((abs(k-i)=2) and (abs(ky-j)=1)) then ans:=ans-1\n else if ((abs(l-i)=1) and (abs(ly-j)=2)) or ((abs(l-i)=2) and (abs(ly-j)=1)) or (l=i) or (ly=j) then ans:=ans-1;\nwriteln(ans);\nreadln;\nEnd."}, {"source_code": "const\n n = 8;\nvar\n m : array [1..8,1..8] of boolean;\n x1,y1,x2,y2,i,j,kol : longint;\n s1,s2 : string;\nprocedure put(x,y : longint);\nbegin\n if (x>0) and (x<9)\n and(y>0) and (y<9)\n then\n m[x,y]:=true;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-ord('a')+1;\n y1:=ord(s1[2])-ord('0');\n x2:=ord(s2[1])-ord('a')+1;\n y2:=ord(s2[2])-ord('0');\n for i:=1 to n do\n for j:=1 to n do\n m[i,j]:=false;\n put(x2,y2);\n put(x1+2,y1+1);\n put(x1+1,y1+2);\n put(x1-1,y1+2);\n put(x1-2,y1+1);\n put(x1+2,y1-1);\n put(x1+1,y1-2);\n put(x1-1,y1-2);\n put(x1-2,y1-1);\n put(x2+2,y2+1);\n put(x2+1,y2+2);\n put(x2-1,y2+2);\n put(x2-2,y2+1);\n put(x2+2,y2-1);\n put(x2+1,y2-2);\n put(x2-1,y2-2);\n put(x2-2,y2-1);\n for i:=1 to 8 do\n begin\n put(x1,i);\n put(i,y1);\n end;\n kol:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if m[i,j]=false then inc(kol);\n writeln(kol);\nend. "}, {"source_code": "var d:array[-1..10,-1..10]of longint;\n i,j,a,b,a1,b1,n:longint;s:string;\nbegin\nreadln(s);\nfillchaR(D,SIZEOF(D),0);\na:=byte(s[1])-96; a1:=a;\nb:=byte(s[2])-48; d[a,b]:=1;b1:=b;\nfor i:=1 to 8 do begin\n d[a,i]:=1;d[i,b]:=1;\n end;\nreadln(s);\na:=byte(s[1])-96;\nb:=byte(s[2])-48;d[a,b]:=1;\nd[a+1,b+2]:=1;\nd[a-1,b+2]:=1;\nd[a+1,b-2]:=1;\nd[a-1,b-2]:=1;\nd[a+2,b+1]:=1;\nd[a-2,b+1]:=1;\nd[a+2,b-1]:=1;\nd[a-2,b-1]:=1;\nd[a1+1,b1+2]:=1;\nd[a1-1,b1+2]:=1;\nd[a1+1,b1-2]:=1;\nd[a1-1,b1-2]:=1;\nd[a1+2,b1+1]:=1;\nd[a1-2,b1+1]:=1;\nd[a1+2,b1-1]:=1;\nd[a1-2,b1-1]:=1;\n\nn:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do begin\n if (d[i,j]=0)then inc(n);end;\nwriteln(n);\nend."}, {"source_code": "var\n a:array [-10..80,-10..80] of longint;\n i,j,n,m,k,x1,y1,x2,y2,ans:longint;\n s1,s2,s,ss:string;\n\n procedure print;\n var\n i,j:longint;\n begin\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(a[i,j]);\n writeln\n end;\n end;\n\n\n procedure d1 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1; j:=y1;\n while (i<>-1)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n dec(i);\n dec(j);\n end;\n i:=x1; j:=y1;\n while (i<>-1)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[j,i]:=1;\n dec(i);\n inc(j);\n end;\n end;\n\n\n\n procedure d2 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1+1; j:=y1+1;\n while (i<>10)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n inc(j);\n\n end;\n i:=x1+1; j:=y1-1;\n while (i<>10)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n dec(j);\n\n end;\n end;\n\n\n\n procedure g (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=y1;\n for j:=1 to 8 do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n end;\n end;\n\n\n procedure v (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1;\n for j:=1 to 8 do\n begin\n if a[j,i]=-1 then break;\n a[j,i]:=1;\n end;\n end;\n\n procedure kon(x2,y2:longint);\n var\n i,j:longint;\n begin\n i:=x2; j:=y2;\n a[i,j]:=1;\n a[i+2,j+1]:=1;\n a[i+2,j-1]:=1;\n a[i-2,j+1]:=1;\n a[i-2,j-1]:=1;\n a[i+1,j+2]:=1;\n a[i-1,j+2]:=1;\n a[i+1,j-2]:=1;\n a[i-1,j-2]:=1;\n end;\n\nbegin\n readln(s1);\n readln(s2);\n s:='abcdefgh';\n ss:='12345678';\n x1:=pos(s1[1],s);\n x2:=pos(s2[1],s);\n y1:=pos(s1[2],ss);\n y2:=pos(s2[2],ss);\n //d1(x1,y1);\n// d2(x1,y1);\n g(x1,y1);\n v(x1,y1);\n kon(y2,x2);\n kon(y1,x1);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]<>1 then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "Var a:array[-1..10,-1..10] of longint;\nN,k,m,s1,s2,l1,l2,j,i:longint;\nx1,y1,x2,y2:char;\nBegin\nReadln(x1,y1);\nReadln(x2,y2);\nl1:=ord(x1)-ord('a')+1;\nl2:=ord(y1)-ord('1')+1;\ns1:=ord(x2)-ord('a')+1;\ns2:=ord(y2)-ord('1')+1;\nFor j:=-1 to 10 do begin\n a[l1,j]:=1;\n a[j,l2]:=1;\nend;\na[s1,s2]:=1;\na[s1-2,s2-1]:=1;\na[s1-2,s2+1]:=1;\na[s1-1,s2-2]:=1;\na[s1-1,s2+2]:=1;\na[s1+2,s2-1]:=1;\na[s1+2,s2+1]:=1;\na[s1+1,s2-2]:=1;\na[s1+1,s2+2]:=1;\na[l1-2,l2-1]:=1;\na[l1-2,l2+1]:=1;\na[l1-1,l2-2]:=1;\na[l1-1,l2+2]:=1;\na[l1+2,l2-1]:=1;\na[l1+2,l2+1]:=1;\na[l1+1,l2-2]:=1;\na[l1+1,l2+2]:=1;\nFor i:=8 downto 1 do begin\n for j:=1 to 8 do begin\n if a[i,j]=0 then\n k:=k+1;\n end;\nend;\nwriteln(k);\nend.\n\n\n\n"}, {"source_code": "program kon;\nvar l,k,s:string;\n x,lx,kx,ly,ky,y,n:integer;\n flag:boolean;\nbegin\n readln(input,l);\n readln(input,k);\n lx:=ord(l[1]);\n ly:=ord(l[2])-ord('0');\n kx:=ord(k[1]);\n ky:=ord(k[2])-ord('0');\n n:=0;\n\n for x:=ord('a') to ord('h') do\n begin\n for y:=1 to 8 do\n begin\n flag:=true;\n if (x=lx) or (y=ly) then flag:=false;\n if (x=kx) and (y=ky) then flag:=false;\n if (abs(x-kx)=1) and (abs(y-ky)=2) then flag:=false;\n if (abs(x-kx)=2) and (abs(y-ky)=1) then flag:=false;\n if (abs(x-lx)=1) and (abs(y-ly)=2) then flag:=false;\n if (abs(x-lx)=2) and (abs(y-ly)=1) then flag:=false;\n if flag then n:=n+1;\n end;\n end;\n\n write(output,n);\nend.\n"}, {"source_code": "const dx:array[1..8] of longint=(-2,-2,-1,-1,2,2,1,1);\n dy:array[1..8] of longint=(-1,+1,-2,+2,-1,+1,-2,+2);\n\nvar kol,x,y,x1,y1,x2,y2,i,kl,j,k,l,m,n:longint;\n a,s,st:string;\n b:array[-1..10,-1..10] of longint;\n\nFunction vvod(s:string):longint;\n Begin\n for i:=1 to 8 do\n if s[1]=a[i] then x:=i;\n val(s[2],y,kl);\n End;\n\nBEGIN\n a:='abcdefgh';\n\n readln(st);\n vvod(st);\n x1:=x;y1:=y;\n readln(st);\n vvod(st);\n x2:=x;y2:=y;\n\n b[x1,y1]:=1;\n for i:=1 to 8 do\n begin b[x1,i]:=1; b[i,y1]:=1; end;\n b[x2,y2]:=1;\n for i:=1 to 8 do\n b[x2+dx[i],y2+dy[i]]:=1;\n for i:=1 to 8 do\n b[x1+dx[i],y1+dy[i]]:=1;\n\n kol:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if b[i,j]=0 then inc(kol);\n writeln(kol);\n\n\n\n\nEND.\n"}, {"source_code": "var s1,s2,alf,alf2:ansistring;\na:array[-8..20,-8..20] of longint;\ni,j,k,q,s,p,x1,x2,y1,y2:longint;\ncode:integer;\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n val(s1[2],y1,code);\n x2:=ord(s2[1])-96;\n val(s2[2],y2,code);\n a[x1,y1]:=1;\n for i:=x1 downto 1 do\n a[i,y1]:=1;\n for i:=y1 to 8 do\n a[x1,i]:=1;\n for i:=y1 downto 1 do\n a[x1,i]:=1;\n for i:=x1 to 8 do\n a[i,y1]:=1;\n a[x2,y2]:=1;\n a[x2-2,y2+1]:=1;\n a[x2-2,y2-1]:=1;\n a[x2+1,y2+2]:=1;\n a[x2-1,y2+2]:=1;\n a[x2+2,y2+1]:=1;\n a[x2+2,y2-1]:=1;\n a[x2-1,y2-2]:=1;\n a[x2+1,y2-2]:=1;\n //ladya\n a[x1-2,y1+1]:=1;\n a[x1-2,y1-1]:=1;\n a[x1+1,y1+2]:=1;\n a[x1-1,y1+2]:=1;\n a[x1+2,y1+1]:=1;\n a[x1+2,y1-1]:=1;\n a[x1-1,y1-2]:=1;\n a[x1+1,y1-2]:=1;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then inc(q);\n writeln(q);\nend.\n"}, {"source_code": "var\n s,s1:string;\n o,p,x,y,x1,y1,i,j,l,o1,p1:longint;\nbegin\n readln(s);\n read(s1);\n x:=ord(s[1])-ord('a')+1;\n y:=ord(s[2])-ord('0');\n x1:=ord(s1[1])-ord('a')+1;\n y1:=ord(s1[2])-ord('0');\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n o:=abs(i-x1);\n p:=abs(j-y1);\n o1:=abs(i-x);\n p1:=abs(j-y);\n if (i<>x) and (j<>y) then if o+p<>0 then\n if (o=1) and (p=2) then continue\n else if (p=1) and (o=2) then continue\n else if (o1=1) and (p1=2) then continue\n else if (p1=1) and (o1=2) then continue else inc(l);\n end;\n write(l);\nend."}, {"source_code": "program B;\nvar a1,a2,b1,b2:char;\n a:array[1..8,1..8]of integer;\n d:array[1..2,1..8]of integer;\n i,j,k,l,sum:integer;\nbegin\n readln(a1,a2);\n readln(b1,b2);\n d[1][1]:=-2; d[2][1]:=-1;\n d[1][2]:=-2; d[2][2]:=1;\n d[1][3]:=-1; d[2][3]:=-2;\n d[1][4]:=-1; d[2][4]:=2;\n d[1][5]:=1; d[2][5]:=-2;\n d[1][6]:=1; d[2][6]:=2;\n d[1][7]:=2; d[2][7]:=-1;\n d[1][8]:=2; d[2][8]:=1;\n\n i:=ord(a1)-96;\n val(a2,j,k);\n for l:=1 to 8 do\n begin\n a[l][j]:=2;\n a[i][l]:=2;\n if (i+d[1][l]<=8)and(i+d[1][l]>=1)and(j+d[2][l]<=8)and(j+d[2][l]>=1) then\n a[i+d[1][l],j+d[2][l]]:=1;\n end;\n\n i:=ord(b1)-96;\n val(b2,j,k);\n a[i][j]:=1; //����\n for l:=1 to 8 do\n if (i+d[1][l]<=8)and(i+d[1][l]>=1)and(j+d[2][l]<=8)and(j+d[2][l]>=1) then\n a[i+d[1][l],j+d[2][l]]:=1;\n\n sum:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i][j]=0 then sum:=sum+1;\n write(sum);\nend."}, {"source_code": "Var s1,s2:string;\n i,j,l,n,m,h,s,x1,x2,y1,y2:longint;\n A:array[1..8,1..8] of 0..1;\n p:integer;\n Begin\n Readln(s1);\n readln(s2);\n x1:=ord(s1[1])-ord('a')+1;\n x2:=ord(s2[1])-ord('a')+1;\n val(s1[2],y1,p);\n val(s2[2],y2,p);\n fillchar(a,sizeof(a),0);\n A[x2,y2]:=1;\n if (x2-2>=1) and (y2-1>=1) then A[x2-2,y2-1]:=1;\n if (x2-2>=1) and (y2+1<=8) then A[x2-2,y2+1]:=1;\n if (x2+2<=8) and (y2-1>=1) then A[x2+2,y2-1]:=1;\n if (x2+2<=8) and (y2+1<=8) then A[x2+2,y2+1]:=1;\n\n if (x2-1>=1) and (y2-2>=1) then A[x2-1,y2-2]:=1;\n if (x2-1>=1) and (y2+2<=8) then A[x2-1,y2+2]:=1;\n if (x2+1<=8) and (y2-2>=1) then A[x2+1,y2-2]:=1;\n if (x2+1<=8) and (y2+2<=8) then A[x2+1,y2+2]:=1;\n\n if (x1-2>=1) and (y1-1>=1) then A[x1-2,y1-1]:=1;\n if (x1-2>=1) and (y1+1<=8) then A[x1-2,y1+1]:=1;\n if (x1+2<=8) and (y1-1>=1) then A[x1+2,y1-1]:=1;\n if (x1+2<=8) and (y1+1<=8) then A[x1+2,y1+1]:=1;\n\n if (x1-1>=1) and (y1-2>=1) then A[x1-1,y1-2]:=1;\n if (x1-1>=1) and (y1+2<=8) then A[x1-1,y1+2]:=1;\n if (x1+1<=8) and (y1-2>=1) then A[x1+1,y1-2]:=1;\n if (x1+1<=8) and (y1+2<=8) then A[x1+1,y1+2]:=1;\n\n j:=y1;\n for i:=1 to 8 do\n A[i,j]:=1;\n i:=x1;\n for j:=1 to 8 do\n A[i,j]:=1;\n s:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n s:=s+A[i,j];\n Writeln(64-s);\n\n End."}, {"source_code": "const\nw: array[1..8,1..2] of integer= ((-2,-1),(-2,1),(-1,-2),(1,-2),(-1,2),(1,2),(2,-1),(2,1));\nvar\narr: array [-1..10,-1..10] of longint;\ni,j,k,l,m,n,t,c: longint;\ntor,cab: string;\ntr,ca: char;\nbegin\n readln (tor);\n readln (cab);\n val(tor[2],t,l);\n val(cab[2],c,l);\n tr:=tor[1];\n ca:=cab[1];\n m:=ord(tr)-96;\n n:=ord(ca)-96;\n arr[t,m]:=1;\n arr[c,n]:=1;\n for i:=1 to 8 do\n begin\n arr[i,m]:=1;\n arr[t,i]:=1;\n arr[t+w[i,1],m+w[i,2]]:=1;\n arr[c+w[i,1],n+w[i,2]]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if arr[i,j]=0 then\n k:=k+1;\n writeln (k);\nend.\n"}, {"source_code": "program chess;\nconst\n fi='';\n fo='';\n di:array[1..8] of integer=(-2,-2,-1,1,2,2,1,-1);\n dj:array[1..8] of integer=(-1,1,2,2,1,-1,-2,-2);\nvar\n c : array[-1..10,-1..10] of boolean;\n i,j,k1,k2,u,v,\n b1,b2 : integer;\n a1,a2 : char;\n f : text;\n dem : integer;\nBEGIN\n assign(F,fi);reset(F);\n readln(f,a1,b1);\n readln(f,a2,b2);\n k1:=ord(a1)-96; k2:=ord(a2)-96;\n fillchar(c,sizeof(c),false);\n for i:=1 to 8 do\n for j:=1 to 8 do c[i,j]:=true;\n dem:=0;\n for i:=1 to 8 do\n begin\n if c[k1,i] then begin c[k1,i]:=false;inc(dem);end;\n if c[i,b1] then begin c[i,b1]:=false;inc(dem);end;\n end;\n c[k2,b2]:=false;inc(dem);\n for i:=1 to 8 do\n begin\n u:=k1+di[i];\n v:=b1+dj[i];\n if c[u,v] then begin c[u,v]:=false;inc(dem);end;\n u:=k2+di[i];\n v:=b2+dj[i];\n if c[u,v] then begin c[u,v]:=false;inc(dem);end;\n end;\n close(f);\n assign(f,fo);rewrite(f);\n writeln(f,64-dem);\n close(f);\nend.\n\n\n\n\n\n\n\n\n"}, {"source_code": "const\nv:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));\nvar\narr:array[-2..10,-2..10] of boolean;\ni,j,n,p:longint;\ncar:char;\nbegin\n read (car);\n readln(n);\n for i:=1 to 8 do\n arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;\n for i:=1 to 8 do\n arr[i,n]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-96),i]:=true;\n read (car);\n readln (n);\n arr[(ord(car)-96),n]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;\n p:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not arr[i,j] then\n inc (p);\n writeln (p);\nend.\n"}, {"source_code": "const\ncab:array[1..8,1..2] of longint=((-1,-2),(-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2));\nvar\narr:array[1..8,1..8] of longint;\nusa:array[1..8,1..8] of boolean;\ni,j,cont,x,y,k:longint;\ncad:string;\nbol:boolean;\nbegin\n readln(cad);\n x:=ord(cad[1])-96;\n y:=ord(cad[2])-48;\n\n for i:=1 to 8 do\n begin\n arr[x,i]:=1;\n arr[i,y]:=1;\n end;\n arr[x,y]:=3;\n readln(cad);\n x:=ord(cad[1])-96;\n y:=ord(cad[2])-48;\n arr[x,y]:=3;\n for i:=1 to 8 do\n begin\n if (x+cab[i,1]<=8) and (y+cab[i,2]<=8) and (x+cab[i,1]>0) and (y+cab[i,2]>0) then\n arr[x+cab[i,1],y+cab[i,2]]:=2;\n end;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n bol:=false;\n if arr[i,j]<>0 then\n begin\n bol:=true;\n end;\n for k:=1 to 8 do\n begin\n if (i+cab[k,1]<=8) and (i+cab[k,1]>0) and (j+cab[k,2]>0) and (j+cab[k,2]<=8) and (arr[i+cab[k,1],j+cab[k,2]]=3) then\n begin\n bol:=true;\n end;\n end;\n if not bol then\n begin\n cont:=cont+1;\n usa[i,j]:=true;\n\n end;\n end;\n end;\n writeln(cont);\nend.\n\n"}, {"source_code": "type kon=array[1..8]of string;\nvar s1,s2,bs1,bs2:string;\n c:char;\n B,i,j:shortint;\n k,l:kon;\n b1,b2:boolean;\nconst a='abcdefgh';\nconst n='12345678';\nfunction main(s:string;a:kon):boolean;\nvar b:boolean;\n i:integer;\nbegin\n b:=false;\n for i:=1 to 8 do\n begin\n if s=a[i] then\n b:=true;\n end;\n main:=b;\nend;\nprocedure ka(s:string;var a:kon);\nbegin\na[1]:=chr(ord(s[1])+2)+chr(ord(s[2])+1);\na[2]:=chr(ord(s[1])+1)+chr(ord(s[2])+2);\na[3]:=chr(ord(s[1])-1)+chr(ord(s[2])+2);\na[4]:=chr(ord(s[1])-2)+chr(ord(s[2])+1);\na[5]:=chr(ord(s[1])+2)+chr(ord(s[2])-1);\na[6]:=chr(ord(s[1])+1)+chr(ord(s[2])-2);\na[7]:=chr(ord(s[1])-1)+chr(ord(s[2])-2);\na[8]:=chr(ord(s[1])-2)+chr(ord(s[2])-1);\nend;\nbegin\n readln(input,s1);\n readln(input,s2);\n B:=64-7-7;B:=B-1-1;\n ka(s1,l);\n ka(s2,k);\n bs1:=a;bs2:=n;\n for i:=1 to 8 do\n begin\n b1:=false;b2:=b1;\n for j:=1 to 8 do\n begin\n if k[i][1]=bs1[j] then b1:=true;\n if k[i][2]=bs2[j] then b2:=true;\n end;\n if b1 and b2 and (k[i][1]<>s1[1])and (k[i][2]<>s1[2]) then\n begin\n b:=b-1;\n end;\n end;\n for i:=1 to 8 do\n begin\n b1:=false;b2:=b1;\n for j:=1 to 8 do\n begin\n if l[i][1]=bs1[j] then b1:=true;\n if l[i][2]=bs2[j] then b2:=true;\n end;\n if b1 and b2 and(not main(l[i],k)) then\n b:=b-1;\n end;\n writeln(output,b);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\na1,b1,tt,ss:char;\na2,b2,x,y,k,z:longint;\ns,t:string;\nbegin\nreadln(a1,a2);\nreadln(b1,b2);\nk:=0;\nx:=ord(a1)-ord('a')+1;\ny:=ord(b1)-ord('a')+1;\ns:=' ';\nt:=' ';\nif (x+1<=8) and(a2+2<=8) then begin k:=k+1; tt:=chr(x+1+ord('a')-1); ss:=chr(ord('0')+(a2+2)); t:=tt+ss; s:=s+t; end;\nif (x-1>=1) and(a2+2<=8) then begin tt:=chr(x-1+ord('a')-1); ss:=chr(ord('0')+(a2+2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x+2<=8) and(a2+1<=8) then begin tt:=chr(x+2+ord('a')-1); ss:=chr(ord('0')+(a2+1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x+2<=8) and(a2-1>=1) then begin tt:=chr(x+2+ord('a')-1); ss:=chr(ord('0')+(a2-1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x+1<=8) and(a2-2>=1) then begin tt:=chr(x+1+ord('a')-1); ss:=chr(ord('0')+(a2-2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x-1>=1) and(a2-2>=1) then begin tt:=chr(x-1+ord('a')-1); ss:=chr(ord('0')+(a2-2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x-2>=1) and(a2-1>=1) then begin tt:=chr(x-2+ord('a')-1); ss:=chr(ord('0')+(a2-1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (x-2>=1) and(a2+1<=8) then begin tt:=chr(x-2+ord('a')-1); ss:=chr(ord('0')+(a2+1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y+1<=8) and(b2+2<=8)and(y+1<>x)and(b2+2<>a2) then begin tt:=chr(y+1+ord('a')-1); ss:=chr(ord('0')+(b2+2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y-1>=1) and(b2+2<=8)and(y-1<>x)and(b2+2<>a2) then begin tt:=chr(y-1+ord('a')-1); ss:=chr(ord('0')+(b2+2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y+2<=8) and(b2+1<=8)and(y+2<>x)and(b2+1<>a2) then begin tt:=chr(y+2+ord('a')-1); ss:=chr(ord('0')+(b2+1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y+2<=8) and(b2-1>=1)and(y+2<>x)and(b2-1<>a2) then begin tt:=chr(y+2+ord('a')-1); ss:=chr(ord('0')+(b2-1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y+1<=8) and(b2-2>=1)and(y+1<>x)and(b2-2<>a2) then begin tt:=chr(y+1+ord('a')-1); ss:=chr(ord('0')+(b2-2)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y-1>=1) and(b2-2>=1)and(y-1<>x)and(b2-2<>a2) then begin tt:=chr(y-1+ord('a')-1); ss:=chr(ord('0')+(b2-2)); t:=tt+ss;if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y-2>=1) and(b2-1>=1)and(y-2<>x)and(b2-1<>a2) then begin tt:=chr(y-2+ord('a')-1); ss:=chr(ord('0')+(b2-1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nif (y-2>=1) and(b2+1<=8)and(y-2<>x)and(b2+1<>a2) then begin tt:=chr(y-2+ord('a')-1); ss:=chr(ord('0')+(b2+1)); t:=tt+ss; if pos(t,s)=0 then begin k:=k+1; s:=s+t; end; t:=''; end;\nwrite(64-k-14-2);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a:array [0..14,0..14] of integer;\n x,x2:Integer;\n s:char;\n kol,i,j:Integer;\n st,s2:string;\n\nbegin\n i:=1;\n while i<=2 do\n begin\n Readln(st);\n s:=st[1]; s2:=st[2];\n case s of\n 'a': x:=3;\n 'b': x:=4;\n 'c': x:=5;\n 'd': x:=6;\n 'e': x:=7;\n 'f': x:=8;\n 'g': x:=9;\n 'h': x:=10;\n end;\n x2:=StrToInt(s2)+2;\n\n if i=1 then for j:=0 to 12 do begin a[x,j]:=1; a[j,x2]:=1 end;\n\n a[x,x2]:=1;\n a[x-2,x2+1]:=1;\n a[x-1,x2+2]:=1;\n a[x+2,x2+1]:=1;\n a[x+1,x2+2]:=1;\n a[x-2,x2-1]:=1;\n a[x-1,x2-2]:=1;\n a[x+2,x2-1]:=1;\n a[x+1,x2-2]:=1;\n i:=i+1;\n end;\n kol:=0;\n For i:=3 to 10 do\n for j:=3 to 10 do\n if a[i,j]=0 then inc(kol);\n\n write(kol);\n Readln;\n { TODO -oUser -cConsole Main : Insert code here }\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nconst\n mvx: Array[1..8] of Integer =\n (-2, -2, -1, +1, +2, +2, +1, -1);\n mvy: Array[1..8] of Integer =\n (-1, +1, +2, +2, +1, -1, -2, -2);\n\nvar\n ch: Char;\n i, j: Integer;\n l1, l2, k1, k2, k: Integer;\n map: Array[-10..+20, -10..+20] of byte;\n res: Integer;\n fl: Boolean;\n\nbegin\n Read(ch); l1 := Ord(ch)-Ord('a') + 1;\n Read(ch); l2 := Ord(ch)-Ord('0');\n ReadLn;\n Read(ch); k1 := Ord(ch)-Ord('a') + 1;\n Read(ch); k2 := Ord(ch)-Ord('0');\n FillChar(map, sizeof(map), 0);\n map[k1, k2] := 2;\n for i := 1 to 8 do\n map[k1+mvx[i]][k2+mvy[i]] := 1;\n for i := -10 to 20 do\n begin\n map[i, l2] := 1;\n map[l1, i] := 1;\n end;\n map[l1, l2] := 2;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if map[i, j] = 0 then\n begin\n fl := True;\n for k := 1 to 8 do\n if map[i+mvx[k]][j+mvy[k]] = 2 then\n begin\n fl := False;\n Break;\n end;\n if fl then res := res + 1;\n end;\n\n WriteLn(res);\nend.\n"}, {"source_code": "program B;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nconst\n maxn = 500;\n infile = 'input.txt';\n outfile = 'output.txt';\ntype int = longint;\nvar\n s1, s2, s : string;\n a : array[-1..10, -1..10] of int;\n i, j, x, y, ans : int;\nbegin\n \n readln(s1);\n readln(s2);\n s := 'abcdefgh';\n for i := 0 to 8 do\n for j := 0 to 8 do\n a[i, j] := 1;\n i := StrToInt(s1[2]);\n if s1[1] = 'a' then\n j := 1;\n if s1[1] = 'b' then\n j := 2;\n if s1[1] = 'c' then\n j := 3;\n if s1[1] = 'd' then\n j := 4;\n if s1[1] = 'e' then\n j := 5;\n if s1[1] = 'f' then\n j := 6;\n if s1[1] = 'g' then\n j := 7;\n if s1[1] = 'h' then\n j := 8;\n a[i, j] := 0;\n a[i - 2, j + 1] := 0;\n a[i - 1, j + 2] := 0;\n a[i + 1, j + 2] := 0;\n a[i + 2, j + 1] := 0;\n a[i + 2, j - 1] := 0;\n a[i + 1, j - 2] := 0;\n a[i - 1, j - 2] := 0;\n a[i - 2, j - 1] := 0;\n x := i;\n y := j + 1;\n while y <= 8 do begin\n a[i, y] := 0;\n inc(y);\n end;\n y := j - 1;\n while y >= 1 do begin\n a[i, y] := 0;\n dec(y);\n end;\n x := i - 1;\n while x >= 1 do begin\n a[x, j] := 0;\n dec(x);\n end;\n x := i + 1;\n while x <= 8 do begin\n a[x, j] := 0;\n inc(x);\n end;\n i := StrToInt(s2[2]);\n if s2[1] = 'a' then\n j := 1;\n if s2[1] = 'b' then\n j := 2;\n if s2[1] = 'c' then\n j := 3;\n if s2[1] = 'd' then\n j := 4;\n if s2[1] = 'e' then\n j := 5;\n if s2[1] = 'f' then\n j := 6;\n if s2[1] = 'g' then\n j := 7;\n if s2[1] = 'h' then\n j := 8;\n\n\n a[i, j] := 0;\n a[i - 2, j + 1] := 0;\n a[i - 1, j + 2] := 0;\n a[i + 1, j + 2] := 0;\n a[i + 2, j + 1] := 0;\n a[i + 2, j - 1] := 0;\n a[i + 1, j - 2] := 0;\n a[i - 1, j - 2] := 0;\n a[i - 2, j - 1] := 0;\n ans:= 0;\n i := 1;\n j := 1;\n while i <= 8 do begin\n j := 1;\n while j <= 8 do begin\n inc(ans, a[i, j]);\n inc(j);\n end;\n inc(i);\n end;\n writeln(ans);\n \nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\n\nvar\n kx,ky,lx,ly,i,j,k:integer;\n t:char;\n a:array[-3..11,-3..11] of boolean;\n\n\n\nbegin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=true;\n read(t);\n lx:=ord(t)-96;\n readln(t);\n ly:=ord(t)-48;\n read(t);\n kx:=ord(t)-96;\n readln(t);\n ky:=ord(t)-48;\n a[kx,ky]:=false;\n a[lx,ly]:=false;\n for i:=1 to 8 do\n begin\n a[lx,i]:=false;\n a[i,ly]:=false;\n end;\n a[kx+2,ky+1]:=false;\n a[kx+2,ky-1]:=false;\n a[kx-1,ky+2]:=false;\n a[kx+1,ky+2]:=false;\n a[kx-2,ky+1]:=false;\n a[kx-2,ky-1]:=false;\n a[kx-1,ky-2]:=false;\n a[kx+1,ky-2]:=false;\n a[lx+2,ly+1]:=false;\n a[lx+2,ly-1]:=false;\n a[lx-1,ly+2]:=false;\n a[lx+1,ly+2]:=false;\n a[lx-2,ly+1]:=false;\n a[lx-2,ly-1]:=false;\n a[lx-1,ly-2]:=false;\n a[lx+1,ly-2]:=false;\n\n\n k:=0;\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j] then k:=k+1;\n\n\nwriteln(k);\n\n\n\n\n\n\n\nend.\n"}, {"source_code": "{$apptype console}\n\nconst d : array [1..8, 1..2] of integer = ((1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1));\n\nvar lx, ly, kx, ky: integer;\n m : array [1..8, 1..8] of boolean;\n t : string;\n\nprocedure conv( const s : string; var x, y : integer );\nbegin\n x := ord(s[2]) - ord('1') + 1;\n y := ord(s[1]) - ord('a') + 1;\nend;\n\nprocedure Mark( x, y : integer );\nbegin\n if( x>=1) and(y>=1) and (x<=8) and(y<=8 ) then m[y][x] := false;\nend;\n\nfunction Check( x0, y0 : integer ) : boolean;\nvar i, x, y : integer;\nbegin\n result := true;\n for i := 1 to 8 do begin\n x := x0 + d[i][1];\n y := y0 + d[i][2];\n if ((x=lx)and(y=ly)) then begin result := false; break; end;\n end;\nend;\n\nvar x,y, i, s : integer;\nbegin\n readln( t );\n Conv( t, lx, ly );\n readln( t );\n Conv( t, kx, ky );\n{}\n for x := 1 to 8 do\n for y := 1 to 8 do\n if (x = lx ) or (y=ly ) then m[y][x]:=false else m[y][x] := true;\n \n m[ky][kx] := false;\n for i := 1 to 8 do Mark( kx + d[i][1], ky + d[i][2] );\n{}\n s := 0;\n for x := 1 to 8 do\n for y := 1 to 8 do\n if m[y][x] and Check( x, y ) then inc( s );\n{}\n write( s );\nend.\n"}, {"source_code": "{ uses crt; }\n label 1;\n const nn=100;\n type {extended=real;}\n mass=array [-nn..nn] of longint;\n var mm,s,p, n,i,j,k,l,imin,sm,t,m,maxs:longint;\n x,c:mass; otv:boolean;\n xl,yl,xk,yk:longint;\n a:char;\n function prov(x,y:longint):boolean; {true - ne b'et}\n var yy:boolean; i,j:longint;\n begin yy:=true;\n if (x=xl) or (y=yl) then yy:=false;\n if (abs(x-xk)=1)and(abs(y-yk)=2) then yy:=false;\n if (abs(x-xk)=2)and(abs(y-yk)=1) then yy:=false;\n if (abs(x-xl)=1)and(abs(y-yl)=2) then yy:=false;\n if (abs(x-xl)=2)and(abs(y-yl)=1) then yy:=false;\n prov:=yy;\n\n end;\n\n\n\n\n function min(x,y:longint):longint;\n begin min:=x;if yx then max:=y; end;\n\n begin { clrscr;\n assign(input,'input.txt'); reset (input); }\n read(a);readln(yl);xl:=ord(a)-96;\n read(a);read(yk);xk:=ord(a)-96;\n for i:=1 to 5 do for j:=1 to 5 do\n { writeln(i,' ',j,' ',prov(i,j)); }\n s:=0;\n for i:=1 to 8 do for j:=1 to 8 do\n if ((i<>xl)or(j<>yl))and((i<>xk)or(j<>yk))and prov(i,j) then inc(s);\n\n writeln(s);\n\n end.\n\n\n\n\n\n"}, {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n Sysutils;\nfunction check(i,j,x,y : integer) : boolean;\nvar\n t : boolean;\nbegin\n t := false;\n if (i-1 = x) and (j + 2 = y) then t := true;\n if (i-1 = x) and (j - 2 = y) then t := true;\n if (i-2 = x) and (j-1 = y) then t := true;\n if (i-2 = x) and (j+1 = y) then t := true;\n if (i+1=x) and (j+2 = y) then t := true;\n if (i+1=x) and (j-2 = y) then t := true;\n if (i+2=x) and (j-1 = y) then t := true;\n if (i+2=x) and (j+1 = y) then t := true;\n if t = true then check := true\n else check := false;\nend;\nvar\n ch,ch1,ch2,ch3 : char;\n y1,x1,x2,y2,i,j,ans,k : integer;\n status : array[-10..10,-10..10] of boolean;\nbegin\n readln(ch1,ch2);\n y1 := strtoint(ch2);\n read(ch3,ch2);\n k := 0;\n x1 := 0;\n x2 := 0;\n y2 := strtoint(ch2);\n for ch := 'a' to 'z' do begin\n inc(k);\n if ch = ch1 then x1 := k;\n if ch = ch3 then x2 := k;\n end;\n for i := x1 to 8 do status[i][y1] := true;\n for i := x1 downto 1 do status[i][y1] := true;\n for i := y1 to 8 do status[x1][i] := true;\n for i := y1 downto 1 do status[x1][i] := true;\n status[x2][y2] := true;\n status[x2-1][y2+2] := true;\n status[x2-1][y2-2] := true;\n status[x2+1][y2+2] := true;\n status[x2+1][y2-2] := true;\n status[x2-2][y2-1] := true;\n status[x2-2][y2+1] := true;\n status[x2+2][y2-1] := true;\n status[x2+2][y2+1] := true;\n ans := 64;\n for i := 1 to 8 do\n for j := 1 to 8 do begin\n if status[i][j] = true then begin\n dec(ans);\n continue;\n end;\n if check(i,j,x1,y1) then dec(ans);\n if check(i,j,x2,y2) then dec(ans);\n end;\n write(ans);\n\n\n\nend."}, {"source_code": "type\n int = longint;\nvar\n l1,l2,j,i,ans:int;\n c:char;\n a:array[-3..15,-3..15]of int;\n\nprocedure rec(t1,t2:int);\nbegin\n a[t1,t2]:=1;\n a[t1+1,t2+2]:=1;\n a[t1+1,t2-2]:=1;\n a[t1-1,t2+2]:=1;\n a[t1-1,t2-2]:=1;\n a[t1+2,t2+1]:=1;\n a[t1+2,t2-1]:=1;\n a[t1-2,t2+1]:=1;\n a[t1-2,t2-1]:=1;\nend;\n\nbegin\n readln(c,l2);\n if c='a' then l1:=1 else\n if c='b' then l1:=2 else\n if c='c' then l1:=3 else\n if c='d' then l1:=4 else\n if c='e' then l1:=5 else\n if c='f' then l1:=6 else\n if c='g' then l1:=7 else\n if c='h' then l1:=8;\n for i:=1 to 8 do begin\n a[l1,i]:=1;\n end;\n for i:=1 to 8 do begin\n a[i,l2]:=1;\n end;\n rec(l1,l2);\n\n readln(c,l2);\n if c='a' then l1:=1 else\n if c='b' then l1:=2 else\n if c='c' then l1:=3 else\n if c='d' then l1:=4 else\n if c='e' then l1:=5 else\n if c='f' then l1:=6 else\n if c='g' then l1:=7 else\n if c='h' then l1:=8;\n rec(l1,l2);\n\n for i:=1 to 8 do begin\n for j:=1 to 8 do begin\n if a[i,j]=0 then inc(ans);\n end;\n end;\n\n writeln(ans);\nend."}, {"source_code": "const finp='';\n fout='';\nvar a:array [-1..10,-1..10] of integer;\n r,k:string;\n dem,r1,r2,k1,k2:longint;\nprocedure nhap;\nvar f:text;\n x,y:longint;\nbegin\n assign(f,finp);\n reset(f);\n for x:=1 to 8 do\n for y:=1 to 8 do\n a[x,y]:=0;\n readln(f,r);\n readln(f,k);\n x:=ord(r[1])-96;\n y:=ord(r[2])-48;\n r1:=x; r2:=y;\n a[x,y]:=1;\n x:=ord(k[1])-96;\n y:=ord(k[2])-48;\n k1:=x; k2:=y;\n a[x,y]:=1;\n close(f);\nend;\n{--------------}\nprocedure rook;\nvar x,y:longint;\nbegin\n for y:=1 to 8 do\n a[r1,y]:=1;\n for x:=1 to 8 do\n a[x,r2]:=1;\n a[r1+1,r2+2]:=1;\n a[r1+1,r2-2]:=1;\n a[r1+2,r2+1]:=1;\n a[r1+2,r2-1]:=1;\n a[r1-1,r2+2]:=1;\n a[r1-1,r2-2]:=1;\n a[r1-2,r2+1]:=1;\n a[r1-2,r2-1]:=1;\nend;\n{--------------}\nprocedure knight;\nbegin\n a[k1+1,k2+2]:=1;\n a[k1+1,k2-2]:=1;\n a[k1+2,k2+1]:=1;\n a[k1+2,k2-1]:=1;\n a[k1-1,k2+2]:=1;\n a[k1-1,k2-2]:=1;\n a[k1-2,k2+1]:=1;\n a[k1-2,k2-1]:=1;\nend;\n{--------------}\nprocedure xuli;\nvar x,y:longint;\nbegin\n rook;\n knight;\n for x:=1 to 8 do\n for y:=1 to 8 do\n if a[x,y]=0 then inc(dem);\nend;\n{--------------}\nprocedure xuat;\nvar g:text;\nbegin\n assign(g,fout);\n rewrite(g);\n write(g,dem);\n close(g);\nend;\n{--------------}\nbegin\n nhap;\n xuli;\n xuat;\nend."}, {"source_code": "var a: array[1..8,1..8]of longint;\n s1,s2: string;\n x1,y1,x2,y2,i,j,ans: longint;\n\nfunction check(x,y: longint): boolean;\nbegin\n check:=((x>=1) and (x<=8) and (y>=1) and (y<=8));\nend;\n\nprocedure add(x,y: longint);\nbegin\n if check(x,y) then a[x,y]:=1;\nend;\n\nbegin\n fillchar(a,sizeof(a),0);\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n x2:=ord(s2[1])-96;\n y1:=ord(s1[2])-48;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do add(x1,i);\n for i:=1 to 8 do add(i,y1);\n add(x2,y2);\n add(x1-2,y1-1);\n add(x1+2,y1-1);\n add(x1-2,y1+1);\n add(x1+2,y1+1);\n add(x1-1,y1-2);\n add(x1+1,y1-2);\n add(x1-1,y1+2);\n add(x1+1,y1+2);\n add(x2-2,y2-1);\n add(x2+2,y2-1);\n add(x2-2,y2+1);\n add(x2+2,y2+1);\n add(x2-1,y2-2);\n add(x2+1,y2-2);\n add(x2-1,y2+2);\n add(x2+1,y2+2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "program s;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\nd1:array[1..8] of integer=(2,1,-2,-1, 2, 1,-1,-2);\nd2:array[1..8] of integer=(1,2, 1, 2,-1,-2,-2,-1);\n\n\nvar a:array[-1..10,-1..10] of integer;\nres,ans,i,k,j,cl1,cl2,ck1,ck2:integer;\ns1,s2:string;\n\n\nbegin\nans:=0;\nreadln(s1);\ncl1:=ord(s1[1])-ord('a')+1;\ncl2:=ord(s1[2])-ord('0');\nreadln(s2);\nck1:=ord(s2[1])-ord('a')+1;\nck2:=ord(s2[2])-ord('0');\n\n//writeln(cl1,cl2);\n//writeln(ck1,ck2);\n\n\nfor I := -1 to 10 do\nfor j := -1 to 10 do\na[i,j]:=0;\n\n\nfor I := 1 to 8 do\n begin\n a[cl1,i]:=6;\n a[i,cl2]:=6;\n end;\n\nfor I := 1 to 8 do\n a[ck1+d1[i],ck2+d2[i]]:=6;\n\n\n a[cl1,cl2]:=1;\n\n a[ck1,ck2]:=1;\n\nfor I := 1 to 8 do\nbegin\nfor j := 1 to 8 do\n//write(a[i,j]);\n//writeln;\nend;\n\nfor I := 1 to 8 do\nfor j := 1 to 8 do\nif a[i,j]=0 then\nbegin\nres:=0;\n\nfor k := 1 to 8 do\nif (a[i+d1[k],j+d2[k]]=1) then\ninc(res);\n\nif res=0 then\ninc(ans);\n\nend;\n\nwriteln(ans);\n\nend.\n"}, {"source_code": "var\n\tc : char;\n\tx1,y1,x2,y2,i,j,ans: longint;\n\ta : array[-50..50, -50..50] of boolean;\nbegin\n\tfillchar(a, sizeof(a), 0);\n\tans := 0;\n\tread(c); x1 := ord(c) - 96; readln(c); y1 := ord(c) - 48;\n\tread(c); x2 := ord(c) - 96; read(c); y2 := ord(c) - 48;\n\ta[x1][y1] := true;\n\ta[x2][y2] := true;\n{\tfor i := 1 to 8 do begin\n\t\ta[x1][i] := true;\n\t\ta[i][y1] := true;\n\tend;\n\ta[x2-2][y2-1] := true;\n\ta[x2-2][y2+1] := true;\n\ta[x2-1][y2-2] := true;\n\ta[x2-1][y2+2] := true;\n\ta[x2+1][y2-2] := true;\n\ta[x2+1][y2+2] := true;\n\ta[x2+2][y2-1] := true;\n\ta[x2+2][y2+1] := true;\n\tfor i := -50 to 50 do\n\t\tfor j := -50 to 50 do\n\t\t\tif (1 <= i) and (i <= 8) and (1 <= j) and (j <= 8) continue else a[i][j] := false;\n}\tfor x2 := 1 to 8 do\n\t\tfor y2 := 1 to 8 do\n\t\t\tif (not a[x2][y2]) and \n\t\t\t\t(not a[x2-2][y2-1]) and\n\t\t\t\t(not a[x2-2][y2+1]) and\n\t\t\t\t(not a[x2-1][y2-2]) and\n\t\t\t\t(not a[x2-1][y2+2]) and\n\t\t\t\t(not a[x2+1][y2-2]) and\n\t\t\t\t(not a[x2+1][y2+2]) and\n\t\t\t\t(not a[x2+2][y2-1]) and\n\t\t\t\t(not a[x2+2][y2+1]) and\n\t\t\t\t(x1 <> x2) and\n\t\t\t\t(y1 <> y2) then\n\t\t\t\tinc(ans);\n\twrite(ans);\nend."}, {"source_code": "const fi = '';\n fo = '';\n f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);\nvar a: array[-1..10,-1..10] of boolean;\n x1, x2: char;\n s: string;\n y1, y2, i, j, ans, e: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n fillchar(a,sizeof(a),true);\n readln(x1,s);\n val(s,y1,e);\n readln(x2,s);\n val(s,y2,e);\n a[f[x1],y1]:=false;\n for i:=1 to 8 do\n begin\n a[f[x1],i]:=false;\n a[i,y1]:=false;\n end;\n\n a[f[x2],y2]:=false;\n a[f[x2]-2,y2-1]:=false;\n a[f[x2]-2,y2+1]:=false;\n a[f[x2]-1,y2-2]:=false;\n a[f[x2]-1,y2+2]:=false;\n a[f[x2]+1,y2-2]:=false;\n a[f[x2]+1,y2+2]:=false;\n a[f[x2]+2,y2-1]:=false;\n a[f[x2]+2,y2+1]:=false;\n\n a[f[x1],y1]:=false;\n a[f[x1]-2,y1-1]:=false;\n a[f[x1]-2,y1+1]:=false;\n a[f[x1]-1,y1-2]:=false;\n a[f[x1]-1,y1+2]:=false;\n a[f[x1]+1,y1-2]:=false;\n a[f[x1]+1,y1+2]:=false;\n a[f[x1]+2,y1-1]:=false;\n a[f[x1]+2,y1+1]:=false;\n\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(ans);\n writeln(ans);\n\n {for i:=1 to 8 do\n begin\n for j:=1 to 8 do if a[i,j] then write('T ')\n else write('F ');\n writeln;\n end; }\n\n close(input); close(output);\nend.\n"}, {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s1, s2 : string;\n ans, x1, y1, x2, y2, i, j : integer;\n used : array[0..9, 0..9] of boolean;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n readln(s1);\n readln(s2);\n x1 := 9 - ord(s1[2]) + ord('0');\n y1 := ord(s1[1]) - ord('a') + 1;\n x2 := 9 - ord(s2[2]) + ord('0');\n y2 := ord(s2[1]) - ord('a') + 1;\n used[x1, y1] := true;\n used[x2, y2] := true;\n ans := 0;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if not used[i, j] then begin\n if (i = x1) or (j = y1) or ((abs(i - x2) > 0) and (abs(j - y2) > 0) and (abs(i - x2) + abs(j - y2) = 3)) or ((abs(i - x1) > 0) and (abs(j - y1) > 0) and (abs(i - x1) + abs(j - y1) = 3)) then\n continue;\n inc(ans);\n end;\n write(ans);\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\n x:array[1..8] of longint=(-2,-2,-1,-1,1,1,2,2);\n y:array[1..8] of longint=(-1,1,-2,2,-2,2,-1,1);\nvar\n m:array[-10..10,-10..10] of longint;\n a,b,c,d,i,j,dem:longint;\n s1,s2:string;\n\nprocedure doc;\nbegin\n assign(input,fi);\n reset(input);\n readln(s1);\n readln(s2);\n close(input);\nend;\n\nprocedure xuly;\nbegin\n a:=ord(s1[1])-96; b:=ord(s1[2])-48; c:=ord(s2[1])-96; d:=ord(s2[2])-48;\n for i:=1 to 8 do\n begin\n m[a-x[i],b-y[i]]:=1;\n m[c-x[i],d-y[i]]:=1;\n m[a,i]:=1; m[i,b]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if m[i,j]=0 then inc(dem);\n\nend;\n\nprocedure ghi;\nbegin\n assign(output,fo);\n rewrite(output);\n write(dem-1);\n close(output);\nend;\n\nbegin\n doc;\n xuly;\n ghi;\nend."}, {"source_code": "var xh,xc,nh,nc,i,j,sum : byte; // xh la hang cua xe, xc la cot cua xe,....\n s : string[2];\n a : array['a'..'h'] of byte = (1,2,3,4,5,6,7,8);\n b : array['1'..'8'] of byte = (1,2,3,4,5,6,7,8);\nbegin\n readln(s);\n xh := a[s[1]];\n xc := b[s[2]];\n readln(s);\n nh := a[s[1]];\n nc := b[s[2]];\n\n sum := 0;\n for i := 1 to 8 do\n for j := 1 to 8 do\n if (i<>xh) and (j<>xc) // tranh con xe giet\n and ((i<>nh) or (j<>nc)) // khong trung con ngua\n and (sqr(i-nh) + sqr(j-nc) <> 5) // tranh giet ma and bi ma giet\n and (sqr(i-xh) + sqr(j-xc) <> 5) // tranh giet con xe\n then inc(sum);\n writeln(sum);\n readln;\nend.\n\n\n"}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\na:=0;\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-2,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-2,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\n\nwrite (a);\n\nend."}, {"source_code": "{$apptype console}\n{$R+}\n{$O-}\n\ntype\n point = record\n x1: char;\n y, x: integer;\n end;\n\nvar\n a: array[-5..15, -5..15] of byte;\n l, k: point;\n ans: integer;\n\nprocedure tr(v: char; var adr: integer);\nbegin\n adr := ord(v) - 96;\nend;\n\nprocedure horse;\nbegin\n a[k.y, k.x] := 1;\n if (k.y + 2 <= 8) and (k.x + 1 <= 8) then a[k.y + 2, k.x + 1] := 1;\n if (k.y + 1 <= 8) and (k.x + 2 <= 8) then a[k.y + 1, k.x + 2] := 1;\n if (k.y - 1 >= 1) and (k.x + 2 <= 8) then a[k.y - 1, k.x + 2] := 1;\n if (k.y - 2 >= 1) and (k.x + 1 <= 8) then a[k.y - 2, k.x + 1] := 1;\n if (k.y + 2 <= 8) and (k.x - 1 >= 1) then a[k.y + 2, k.x - 1] := 1;\n if (k.y + 1 <= 8) and (k.x - 2 >= 1) then a[k.y + 1, k.x - 2] := 1;\n if (k.y - 1 >= 1) and (k.x - 2 >= 1) then a[k.y - 1, k.x - 2] := 1;\n if (k.y - 2 >= 1) and (k.x - 1 >= 1) then a[k.y - 2, k.x - 1] := 1;\nend;\n\nprocedure ladya;\nvar i: integer;\nbegin\n for i := 1 to 8 do begin\n a[i, l.x] := 1;\n a[l.y, i] := 1;\n end;\nend;\n\nfunction check_horse(y1, x1: integer): byte;\nbegin\n check_horse := 0;\n if ((y1 + 2 = l.y) and (x1 + 1 = l.x)) or ((y1 + 2 = k.y) and (x1 + 1 = k.x)) then check_horse := 1;\n if ((y1 + 1 = l.y) and (x1 + 2 = l.x)) or ((y1 + 1 = k.y) and (x1 + 2 = k.x)) then check_horse := 1;\n if ((y1 - 2 = l.y) and (x1 + 1 = l.x)) or ((y1 - 2 = k.y) and (x1 + 1 = k.x)) then check_horse := 1;\n if ((y1 + 2 = l.y) and (x1 - 1 = l.x)) or ((y1 + 2 = k.y) and (x1 - 1 = k.x)) then check_horse := 1;\n if ((y1 + 1 = l.y) and (x1 - 2 = l.x)) or ((y1 + 1 = k.y) and (x1 - 2 = k.x)) then check_horse := 1;\n if ((y1 - 1 = l.y) and (x1 - 2 = l.x)) or ((y1 - 1 = k.y) and (x1 - 2 = k.x)) then check_horse := 1;\n if ((y1 - 2 = l.y) and (x1 - 1 = l.x)) or ((y1 - 2 = k.y) and (x1 - 1 = k.x)) then check_horse := 1;\n if ((y1 - 1 = l.y) and (x1 + 2 = l.x)) or ((y1 - 1 = k.y) and (x1 + 2 = k.x)) then check_horse := 1;\nend;\n\nprocedure solve;\nvar i, j: integer;\nbegin\n for i := 1 to 8 do\n for j := 1 to 8 do\n if (a[i, j] = 0) and (check_horse(i, j) = 0) then\n inc(ans);\nend;\n\nbegin\n //reset(input, 'input.txt');\n //rewrite(output, 'output.txt');\n fillchar(a, sizeof(a), 0); ans := 0;\n readln(l.x1, l.y);\n read(k.x1, k.y);\n tr(l.x1, l.x); tr(k.x1, k.x);\n horse; ladya;\n solve;\n write(ans);\nend.\n"}, {"source_code": "var u:array[-2..10, -2..10] of integer;\na: array[1..4] of integer;\ni, n, k, j, m, p, xl, yl, xk, yk: longint;\ncl, ck: char;\nbegin\n\nreadln(cl, yl);\nread(ck, yk);\nxl := ord(cl)-ord('a')+1;\nxk := ord(ck) - ord('a')+1;\nk := 0;\na[1] := -2;\na[2] := -1;\na[3] := 1;\na[4] := 2;\nfor i := 1 to 8 do\nfor j := 1 to 8 do\nbegin\n m := 1;\n if (i = 2)and(j=3)then\n m := m mod 2;\n if (i = xk)and(j = yk) then m := 0;\n if i = xl then m := 0;\n if j = yl then m := 0;\n for p := 1 to 4 do\n begin\n if i = a[p]+xk then\n if (j = yk + ((abs(a[p])) mod 2) + 1)or\n (j = yk - abs(a[p]) mod 2 - 1) then\n m := 0;\n if i = a[p]+xl then\n if (j = yl + ((abs(a[p])) mod 2) + 1)or\n (j = yl - abs(a[p]) mod 2 - 1) then\n m := 0;\n\n end;\n k := k + m;\nend;\nwrite (k);\n\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar x1,y1,x2,y2,i,j,k,c,n : integer;\nch : char;\nmass : array[-2..11,-2..11] of integer;\nbegin\n // reset(input, 'input.txt');\n // rewrite(output,'output.txt');\n for i := -2 to 11 do\n for j := -2 to 11 do\n mass[i][j] := 0;\n\n read(ch);\n x1 := ord(ch)-ord('a')+1;\n readln(y1);\n read(ch);\n x2 := ord(ch)-ord('a')+1;\n readln(y2);\n for i := -1 to 9 do begin\n mass[x1][i] := 1;\n mass[i][y1] := 1;\n end;\n mass[x1][y1] := 2;\n mass[x2][y2] := 2;\n mass[x2-2][y2-1] := 1;\n mass[x2-2][y2+1] := 1;\n mass[x2+2][y2-1] := 1;\n mass[x2+2][y2+1] := 1;\n\n mass[x2-1][y2-2] := 1;\n mass[x2-1][y2+2] := 1;\n mass[x2+1][y2-2] := 1;\n mass[x2+1][y2+2] := 1;\n c := 0;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n if (mass[i][j] = 0) and (mass[i-2][j-1] <> 2) and(mass[i-2][j+1] <> 2) and(mass[i+2][j-1] <> 2) and(mass[i+2][j+1] <> 2) and (mass[i-1][j-2] <> 2) and(mass[i-1][j+2] <> 2) and(mass[i+1][j-2] <> 2) and(mass[i+1][j+2] <> 2) then\n inc(c);\n end;\n end;\n writeln(c);\nend.\n"}, {"source_code": "var sum,i,j:longint;\n s:string;\n q,h:array [1..2] of longint;\n b:array [-2..11,-2..11] of boolean;\nfunction f(i,j:longint):boolean;\nbegin\n f:=true;\n if (i<=0)or(j<=0)or(i>=9)or(j>=9) then exit;\n if b[i,j] then exit\n else f:=false;\nend;\nbegin\n readln(s);\n q[1]:=ord(s[1])-96;\n q[2]:=ord(s[2])-48;\n readln(s);\n h[1]:=ord(s[1])-96;\n h[2]:=ord(s[2])-48;\n fillchar(b,sizeof(b),true);\n for i:=1 to 8 do\n begin\n b[q[1],i]:=false;\n b[i,q[2]]:=false;\n end;\n b[q[1],q[2]]:=false;\n b[h[1],h[2]]:=false;\n b[h[1]+1,h[2]+2]:=false;\n b[h[1]-1,h[2]+2]:=false;\n b[h[1]+1,h[2]-2]:=false;\n b[h[1]-1,h[2]-2]:=false;\n b[h[1]+2,h[2]+1]:=false;\n b[h[1]-2,h[2]+1]:=false;\n b[h[1]+2,h[2]-1]:=false;\n b[h[1]-2,h[2]-1]:=false;\n sum:=0;\n for i:=-2 to 11 do\n for j:=-2 to 0 do\n begin\n b[i,j]:=true;\n b[j,i]:=true;\n end;\n for i:=-2 to 11 do\n for j:=9 to 11 do\n begin\n b[i,j]:=true;\n b[j,i]:=true;\n end;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if b[i,j] and\n (sqr(q[1]-i)+sqr(q[2]-j)<>5)\n and(sqr(h[1]-i)+sqr(h[2]-j)<>5)\n then sum:=sum+1;\n// write(ord(b[i,j]),' ');\n end;\n// writeln;\n end;\n writeln(sum);\nend.\n"}, {"source_code": "program Project5;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar\n A, B, C, N, X1, X2, Y1, Y2, E, F : integer;\n S1, S2 : string;\n I : boolean;\nbegin\n Readln(S1);\n Readln(S2);\n if S1[1] = 'a' then X1 := 1;\n if S1[1] = 'b' then X1 := 2;\n if S1[1] = 'c' then X1 := 3;\n if S1[1] = 'd' then X1 := 4;\n if S1[1] = 'e' then X1 := 5;\n if S1[1] = 'f' then X1 := 6;\n if S1[1] = 'g' then X1 := 7;\n if S1[1] = 'h' then X1 := 8;\n if S2[1] = 'a' then X2 := 1;\n if S2[1] = 'b' then X2 := 2;\n if S2[1] = 'c' then X2 := 3;\n if S2[1] = 'd' then X2 := 4;\n if S2[1] = 'e' then X2 := 5;\n if S2[1] = 'f' then X2 := 6;\n if S2[1] = 'g' then X2 := 7;\n if S2[1] = 'h' then X2 := 8;\n Y1 := strtoint(S1[2]);\n Y2 := strtoint(S2[2]);\n C := 0;\n for A := 1 to 8 do\n begin\n for B := 1 to 8 do\n begin\n I := true;\n if (A = X1) or (B = Y1) then I := false;\n if (A = X2) and (B = Y2) then I := false;\n E := abs(X2 - A);\n F := abs(Y2 - B);\n\n if ((E = 2) and (f = 1)) or ((E = 1) and (F = 2)) then I := false;\n\n\n E := abs(X1 - A);\n F := abs(Y1 - B);\n if ((E = 2) and (f = 1)) or ((E = 1) and (F = 2)) then I := false;\n\n if I = true then C := C + 1;\n\n end;\n end;\n\n writeln(C);\n readln(c);\n\nend.\n"}, {"source_code": "//Yerzhan Dyussenaliyev\nconst\n\tdx: array [1..8] of longint = (-2, -1, 1, 2, 2, 1, -1, -2);\n\tdy: array [1..8] of longint = (1, 2, 2, 1, -1, -2, -2, -1);\nvar\n\ta: array [-10..10, -10..10] of boolean;\n\tch, ch1: char;\n\tx1, y1, x2, y2, i, j, ans: longint;\n\nprocedure check(x, y: longint);\nvar\n\ti, r: longint;\nbegin\n\tif (x1 = x) or (y1 = y) then exit;\n\tr := 0;\n\tfor i := 1 to 8 do if not a[x + dx[i], y + dy[i]] then inc(r);\n\tif r = 8 then inc(ans);\nend;\n\nbegin\n// reset(input, 'a.in');\n// rewrite(output, 'a.out');\n\n\treadln(ch, ch1);\n x1 := ord(ch) - 96;\n y1 := ord(ch1) - 48;\n\treadln(ch, ch1);\n x2 := ord(ch) - 96;\n y2 := ord(ch1) - 48;\n\n\tfillchar(a, sizeof(a), 0);\n\n\ta[x1, y1] := true;\n\ta[x2, y2] := true;\n\n\tans := 0;\n\tfor i := 1 to 8 do\n\t for j := 1 to 8 do\n\t if not a[i, j] then check(i, j);\n\n\twriteln(ans);\nend."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n st, st1: string;\n x1, y1, x2, y2, x3, y3, chet, i, j, temp: integer;\n yes : boolean;\nfunction lad(x, y, i, j: integer): boolean;\nbegin\n if (x = i) or (y = j) then\n lad := true\n else lad := false;\nend;\nfunction kon(x, y, i, j: integer): boolean;\nvar h, v : integer;\nbegin\n h := abs(x-i);\n v := abs(y-j);\n if (h * v =2) then kon := true\n else kon := false;\nend;\nfunction perevod(c: char): integer;\nbegin\n if (c = 'a') then result := 1\n else if (c = 'b') then result := 2\n else if (c = 'c') then result := 3\n else if (c = 'd') then result := 4\n else if (c = 'e') then result := 5\n else if (c = 'f') then result := 6\n else if (c = 'g') then result := 7\n else if (c = 'h') then result := 8;\n\nend;\nbegin\n readln(st);\n readln(st1);\n chet := 0;\n val(st[2], y1, temp);\n x1 := perevod(st[1]);\n val(st1[2], y2, temp);\n x2 := perevod(st1[1]);\n for x3 := 1 to 8 do\n for y3 := 1 to 8 do\n begin\n yes := false;\n if (x3 = x1) and (y3 = y1) then continue;\n if (x3 = x2) and (y3 = y2) then continue;\n if (kon(x3, y3, x1, y1)) then yes := true;\n if (kon(x3, y3, x2, y2)) then yes := true;\n if (lad(x1, y1, x3, y3)) then yes := true;\n if (kon(x2,y2,x3,y3)) then yes := true;\n if (not(yes)) then inc(chet); \n end;\n writeln(chet);\n readln;readln;\nend.\n"}, {"source_code": "program task;\nvar ls,ks,ln,kn:char;\n a:array[-1..10,-1..10]of byte;\n xl,xk,yl,yk,i,j,count:integer;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n read(ls);readln(ln);\n read(ks);read(kn);\n xl:=ord(ls)-ord('a')+1; xk:=ord(ks)-ord('a')+1;\n yl:=ord(ln)-ord('0'); yk:=ord(kn)-ord('0');\n for i:=1 to 8 do begin\n a[yl,i]:=1; a[i,xl]:=1;\n end;\n a[yl,xl]:=3;\n if (yk+2<9)and(xk-1>0)then\n a[yk+2,xk-1]:=1;\n if (yk+2<9)and(xk+1<9)then\n a[yk+2,xk+1]:=1;\n if (yk+1<9)and(xk+2<9)then\n a[yk+1,xk+2]:=1;\n if (yk-1>0)and(xk+2<9)then\n a[yk-1,xk+2]:=1;\n if (yk-2>0)and(xk-1>0)then\n a[yk-2,xk-1]:=1;\n if (yk-2<9)and(xk+1<9)then\n a[yk-2,xk+1]:=1;\n if (yk+1<9)and(xk-2>0)then\n a[yk+1,xk-2]:=1;\n if (yk-1>0)and(xk-2>0)then\n a[yk-1,xk-2]:=1;\n a[yk,xk]:=3;\n count:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0)and\n (a[i+2,j-1]<>3)and(a[i+2,j+1]<>3)and\n (a[i-2,j-1]<>3)and(a[i-2,j+1]<>3)and\n (a[i+1,j-2]<>3)and(a[i+1,j+2]<>3)and\n (a[i-1,j-2]<>3)and(a[i-1,j+2]<>3)then\n inc(count);\n writeln(count);\nend.\n"}, {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils;\nVar\n x:Array['a'..'z'] of Integer;\n c1,c2,c:Char;\n a:Array[1..8,1..8] of Boolean;\n x1,x2,y1,y2,i,j,ans:Integer;\nBegin\n i:=0;\n For c:='a' To 'z' Do Begin\n i:=i+1;\n x[c]:=i;\n End;\n Read(c1);\n Read(c2);\n ReadLn;\n a[x[c1],strtoint(c2)]:=true;\n x1:=x[c1];\n y1:=strtoint(c2);\n Read(c1);\n Read(c2);\n a[x[c1],strtoint(c2)]:=true;\n x2:=x[c1];\n y2:=strtoint(c2);\n For i:=1 To 8 Do a[i,y1]:=true;\n For i:=1 To 8 Do a[x1,i]:=true;\n If (x2>1) and (y2>2) Then a[x2-1,y2-2]:=true;\n If (x2>1) and (y2<7) Then a[x2-1,y2+2]:=true;\n If (x2>2) and (y2>1) Then a[x2-2,y2-1]:=true;\n If (x2>2) and (y2<8) Then a[x2-2,y2+1]:=true;\n If (x2<7) and (y2>1) Then a[x2+2,y2-1]:=true;\n If (x2<7) and (y2<8) Then a[x2+2,y2+1]:=true;\n If (x2<8) and (y2>2) Then a[x2+1,y2-2]:=true;\n If (x2<8) and (y2<7) Then a[x2+1,y2+2]:=true;\n If (x1>1) and (y1>2) Then a[x1-1,y1-2]:=true;\n If (x1>1) and (y1<7) Then a[x1-1,y1+2]:=true;\n If (x1>2) and (y1>1) Then a[x1-2,y1-1]:=true;\n If (x1>2) and (y1<8) Then a[x1-2,y1+1]:=true;\n If (x1<7) and (y1>1) Then a[x1+2,y1-1]:=true;\n If (x1<7) and (y1<8) Then a[x1+2,y1+1]:=true;\n If (x1<8) and (y1>2) Then a[x1+1,y1-2]:=true;\n If (x1<8) and (y1<7) Then a[x1+1,y1+2]:=true;\n ans:=0;\n For i:=1 To 8 Do\n For j:=1 To 8 Do\n If not(a[i,j]) Then ans:=ans+1;\n Write(ans);\nEnd.\n\n\n\n\n\n"}, {"source_code": "Type tm=Array [-1..10,-1..10] of Byte;\nVar m:tm;\n k1,k2,l1,l2,i,j,kol:Integer;\n c:Char;\n\nProcedure BitoLad;\nBegin\n For I:=1 to 8 do\n Begin\n m[i,l2]:=1;\n m[l1,i]:=1;\n End;\n m[l1,l2]:=2;\nEnd;\n\nProcedure Kon (i,j:Integer);\nType td=Array [1..8] of Integer;\nConst dx:td=(1,1,-1,-1,2,2,-2,-2);\n dy:td=(2,-2,2,-2,1,-1,-1,1);\nVar k:Integer;\nBegin\n For k:=1 to 8 do\n Begin\n If m[i+dx[k],j+dy[k]]=0\n then m[i+dx[k],j+dy[k]]:=1\n End;\nEnd;\n\nBegin\n For I:=1 to 8 do\n For J:=1 to 8 do\n m[i,j]:=0;\n\n Readln (c,l1);\n l2:=ord (c)-96;\n Readln (c,k1);\n k2:=ord (c)-96;\n m[k1,k2]:=3;\n BitoLad;\n Kon (k1,k2);\n Kon (l1,l2);\n kol:=0;\n For I:=1 to 8 do\n For J:=1 to 8 do\n If m[i,j]=0\n then Inc (kol);\n Writeln (kol);\nEnd."}, {"source_code": "var s1,s2,alf,alf2:ansistring;\na:array[-8..20,-8..20] of longint;\ni,j,k,q,s,p,x1,x2,y1,y2:longint;\ncode:integer;\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n val(s1[2],y1,code);\n x2:=ord(s2[1])-96;\n val(s2[2],y2,code);\n a[x1,y1]:=1;\n for i:=x1 downto 1 do\n a[i,y1]:=1;\n for i:=y1 to 8 do\n a[x1,i]:=1;\n for i:=y1 downto 1 do\n a[x1,i]:=1;\n for i:=x1 to 8 do\n a[i,y1]:=1;\n q:=0;\n a[x2,y2]:=1;\n a[x2-2,y2+1]:=1;\n a[x2-2,y2-1]:=1;\n a[x2+1,y2+2]:=1;\n a[x2-1,y2+2]:=1;\n a[x2+2,y2+1]:=1;\n a[x2+2,y2-1]:=1;\n a[x2-1,y2-2]:=1;\n a[x2+1,y2-2]:=1;\n a[x1-2,y1+1]:=1;\n a[x1-2,y1-1]:=1;\n a[x1+1,y1+2]:=1;\n a[x1-1,y1+2]:=1;\n a[x1+2,y1+1]:=1;\n a[x1+2,y1-1]:=1;\n a[x1-1,y1-2]:=1;\n a[x1+1,y1-2]:=1;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then inc(q);\n writeln(q);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\nvar i,j,x,y,count:integer; a:array[-8..16,-8..16] of integer; s:string;\nbegin\nfor i:=1 to 8 do\n for j:=1 to 8 do a[i,j]:=0;\nreadln(s);\nx:=ord(s[1])-96;\ny:=ord(s[2])-48;\na[x,y]:=1;\na[x-1,y-2]:=1;\na[x+1,y-2]:=1;\na[x+2,y-1]:=1;\na[x-2,y-1]:=1;\na[x-2,y+1]:=1;\na[x+2,y+1]:=1;\na[x-1,y+2]:=1;\na[x+1,y+2]:=1;\nfor i:=1 to 8 do begin\n a[x,i]:=1;\n a[i,y]:=1;\nend;\nreadln(s);\nx:=ord(s[1])-96;\ny:=ord(s[2])-48;\na[x,y]:=1;\na[x-1,y-2]:=1;\na[x+1,y-2]:=1;\na[x+2,y-1]:=1;\na[x-2,y-1]:=1;\na[x-2,y+1]:=1;\na[x+2,y+1]:=1;\na[x-1,y+2]:=1;\na[x+1,y+2]:=1;\ncount:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then inc(count);\nwriteln(count);\n//readln;\nend.\n "}], "negative_code": [{"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\nCuadro[r,c]:='x'; \nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont);\nend.\n\n\n"}, {"source_code": "const\n n = 8;\nvar\n m : array [1..8,1..8] of boolean;\n x1,y1,x2,y2,i,j,kol : longint;\n s1,s2 : string;\nprocedure put(x,y : longint);\nbegin\n if (x>0) and (x<9)\n and(y>0) and (y<9)\n then\n m[x,y]:=true;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-ord('a')+1;\n y1:=ord(s1[2])-ord('0');\n x2:=ord(s2[1])-ord('a')+1;\n y2:=ord(s2[2])-ord('0');\n for i:=1 to n do\n for j:=1 to n do\n m[i,j]:=false;\n put(x1,y1);\n put(x1+2,y1+1);\n put(x1+1,y1+2);\n put(x1-1,y1+2);\n put(x1-2,y1+1);\n put(x1+2,y1-1);\n put(x1+1,y1-2);\n put(x1-1,y1-2);\n put(x1-2,y1-1);\n put(x2+2,y2+1);\n put(x2+1,y2+2);\n put(x2-1,y2+2);\n put(x2-2,y2+1);\n put(x2+2,y2-1);\n put(x2+1,y2-2);\n put(x2-1,y2-2);\n put(x2-2,y2-1);\n for i:=1 to 8 do\n begin\n put(x2,i);\n put(i,y2);\n end;\n kol:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if m[i,j]=false then inc(kol);\n writeln(kol);\nend."}, {"source_code": "var\nused:array[-8..16,-8..16] of char;\ni,j,k,s:longint;\nc:char;\n\n\nbegin\n\nread(c);\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='K';\nused[i-1,j-2]:='k';\nused[i-2,j-1]:='k';\n\nused[i+1,j+2]:='k';\nused[i+2,j+1]:='k';\n\nused[i-1,j+2]:='k';\nused[i-2,j+1]:='k';\n\nused[i+1,j-2]:='k';\nused[i+2,j-1]:='k';\nread(c);\n\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='L';\n\nfor k:= 1 to 8 do\nbegin {\nused[i-k,j-k]:='l';\nused[i+k,j-k]:='l';\nused[i-k,j+k]:='l';\nused[i+k,j+k]:='l'; }\nused[i,j-k]:='l';\nused[i,j+k]:='l';\nused[i+k,j]:='l';\nused[i-k,j]:='l';\nend;\n\ns:=0;\nfor i:= 1 to 8 do\n for j:= 1 to 8 do\n if (ord(used[i,j])=0) and\n (used[i+1,j+2]<>'L') and(used[i+1,j+2]<>'K') and\n (used[i+2,j+1]<>'L') and(used[i+2,j+1]<>'K') and\n (used[i+2,j-1]<>'L') and(used[i+2,j-1]<>'K') and\n (used[i+1,j-2]<>'L') and(used[i+1,j-2]<>'K') and\n (used[i-1,j+2]<>'L') and(used[i-1,j+2]<>'K') and\n (used[i-2,j+1]<>'L') and(used[i-2,j+1]<>'K') and\n (used[i-2,j-1]<>'L') and(used[i-2,j-1]<>'K') and\n (used[i-1,j-2]<>'L') and(used[i-1,j-2]<>'K')\n then inc(s);\n\n\n writeln(s);\n\nend.\n"}, {"source_code": "Var\n s:string;\n ans,x1,x2,y1,y2,i,j:longint;\n p:integer;\n function ok(xx,yy:longint):boolean;\n begin\n if ((xx<>x1)and(yy<>y1))and((xx<>x2)or(yy<>y2))\n and ((abs(x1-xx)<>2)or(abs(yy-y1)<>1))\n and ((abs(x1-xx)<>1)or(abs(yy-y1)<>2))\n and ((abs(x2-xx)<>2)or(abs(yy-y2)<>1))\n and ((abs(x2-xx)<>1)or(abs(yy-y2)<>1)) then ok:=true\n else ok:=false;\n end;\n Begin\n Readln(s);\n val(s[2],x1,p);\n y1:=ord(s[1])-96;\n Readln(s);\n val(s[2],x2,p);\n y2:=ord(s[1])-96;\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if ok(i,j) then inc(ans);\n Writeln(ans);\n End."}, {"source_code": "var\n x,y:char;\n a:array[1..8,1..8] of boolean;\n i,j,q1,q2,s:longint;\nbegin\n fillchar(a,sizeof(a),true);\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n for i:=q1+1 to 8 do a[i,q2]:=false;\n for i:=q1-1 downto 1 do a[i,q2]:=false;\n for i:=q2+1 to 8 do a[q1,i]:=false;\n for i:=q2-1 downto 1 do a[q1,i]:=false;\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;\n if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;\n if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;\n if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;\n if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;\n if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;\n if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;\n if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if a[i,j] then write('1 ') else write('0 ');\n writeln;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(s);\n writeln(s-1);\nend."}, {"source_code": "var x,y,x3,y3,kol,x1,x2,y1,y2:longint;\n a:array[0..9,0..9] of longint;\n pp1,pp2:boolean;\n s1,s2:string;\nbegin\nreadln(s1);\nreadln(s2);\nx1:=ord(s1[2])-ord('1')+1;\ny1:=ord(s1[1])-ord('a')+1;\nx2:=ord(s2[2])-ord('1')+1;\ny2:=ord(s2[1])-ord('a')+1;\nkol:=0;\nfor x3:= 1 to 8 do\nfor y3:= 1 to 8 do\nbegin\nif (x1=x3) and (y1=y3) then continue;\nif (y2=y3) and (x2=x3) then continue;\npp1:=(x1=x3) or (Y1=y3);\nif pp1 then continue;\npp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or\n ((abs(x2-x3)=1) and (abs(y2-y3)=2));\nif pp2 then continue;\ninc(kol);\nend;\nwriteln(kol-2);\nend.\n\n"}, {"source_code": "var n,i,j,p,v,w:integer;\n\nd:array [1..100,1..100] of integer;\na,b:string;\n\nbegin\n\nreadln (a);\nreadln (b);\n\np:=0;\n\nfor i:=1 to 8 do\n begin\n for j:=1 to 8 do d[i,j]:=0;\n end;\n\nv:=ord(a[1])-96;\nw:=ord(a[2])-48;\n\nfor i:=1 to 8 do d[v,i]:=1;\n\nfor i:=1 to 8 do d[i,w]:=1;\n\nif (v+1<8)and(w+2<8) then d[v+1,w+2]:=1;\nif (v+2<8)and(w+1<8) then d[v+2,w+1]:=1;\nif (v+2<8)and(w-1>0) then d[v+2,w-1]:=1;\nif (v+1<8)and(w-2>0) then d[v+1,w-2]:=1;\nif (v-1>0)and(w-2>0) then d[v-1,w-2]:=1;\nif (v-2>0)and(w-1>0) then d[v-2,w-1]:=1;\nif (v-2>0)and(w+1<8) then d[v-2,w+1]:=1;\nif (v-1>0)and(w+2<8) then d[v-1,w+2]:=1;\n\n\nv:=ord(b[1])-96;\nw:=ord(b[2])-48;\n\nd[v,w]:=2;\nif (v+1<8)and(w+2<8) then d[v+1,w+2]:=2;\nif (v+2<8)and(w+1<8) then d[v+2,w+1]:=2;\nif (v+2<8)and(w-1>0) then d[v+2,w-1]:=2;\nif (v+1<8)and(w-2>0) then d[v+1,w-2]:=2;\nif (v-1>0)and(w-2>0) then d[v-1,w-2]:=2;\nif (v-2>0)and(w-1>0) then d[v-2,w-1]:=2;\nif (v-2>0)and(w+1<8) then d[v-2,w+1]:=2;\nif (v-1>0)and(w+2<8) then d[v-1,w+2]:=2;\n\n\nfor i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if (d[i,j]=0) then p:=p+1;\n end;\nwriteln(p);\nend."}, {"source_code": "var\n n,i,b,summ,x1,y1,x2,y2,j,kol,code:longint;\n s1,s2,s:string;\n c:char;\n a:array[-1..10,-1..10] of longint;\nbegin\n readln(s1);\n readln(s2);\n c:=s1[1];\n x1:=ord(c)-96;\n s:=s1[2];\n val(s,y1,code);\n\n c:=s2[1];\n x2:=ord(c)-96;\n s:=s2[2];\n val(s,y2,code);\n for i:=-1 to 10 do\n begin\n a[i,-1]:=-1;\n a[i,0]:=-1;\n a[i,9]:=-1;\n a[i,10]:=-1;\n a[-1,i]:=-1;\n a[0,i]:=-1;\n a[9,i]:=-1;\n a[10,i]:=-1;\n end;\n if a[x2+2,y2+1]=0 then a[x2+2,y2+1]:=1;\n if a[x2+2,y2-1]=0 then a[x2+2,y2-1]:=1;\n if a[x2-2,y2+1]=0 then a[x2-2,y2+1]:=1;\n if a[x2-2,y2-1]=0 then a[x2-2,y2-1]:=1;\n if a[x2+1,y2+2]=0 then a[x2+1,y2+2]:=1;\n if a[x2+1,y2-2]=0 then a[x2+1,y2-2]:=1;\n if a[x2-1,y2+2]=0 then a[x2-1,y2+2]:=1;\n if a[x2-1,y2-2]=0 then a[x2-1,y2-2]:=1;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n for i:=1 to x1 do\n begin\n a[i,y1]:=1;\n end;\n for i:=x1 to 8 do\n begin\n a[i,y1]:=1;\n end;\n for i:=1 to y1 do\n begin\n a[x1,i]:=1;\n end;\n for i:=y1 to 8 do\n begin\n a[x1,i]:=1;\n end;\n a[x1,y1]:=2;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if a[i,j]=0 then begin\n kol:=0;\n if a[i+2,j+1]<>2 then kol:=kol+1;\n if a[i+2,j-1]<>2 then kol:=kol+1;\n if a[i-2,j+1]<>2 then kol:=kol+1;\n if a[i-2,j-1]<>2 then kol:=kol+1;\n if a[i+1,j+2]<>2 then kol:=kol+1;\n if a[i+1,j+2]<>2 then kol:=kol+1;\n if a[i-1,j+2]<>2 then kol:=kol+1;\n if a[i-1,j-2]<>2 then kol:=kol+1;\n if kol=8 then summ:=summ+1;\n end;\n end;\n end;\n write(summ);\nend.\n"}, {"source_code": "program BBBBB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a : array[-10..10, -10..10] of integer;\n s1, s2 : string;\n x1, x2, y1, y2, i, j, k : integer;\nbegin\n readln(s1);\n readln(s2);\n y1 := ord(s1[2]) - ord('0');\n y2 := ord(s2[2]) - ord('0');\n if s1[1] = 'a' then x1 := 1;\n if s1[1] = 'b' then x1 := 2;\n if s1[1] = 'c' then x1 := 3;\n if s1[1] = 'd' then x1 := 4;\n if s1[1] = 'e' then x1 := 5;\n if s1[1] = 'f' then x1 := 6;\n if s1[1] = 'g' then x1 := 7;\n if s1[1] = 'h' then x1 := 8;\n if s2[1] = 'a' then x2 := 1;\n if s2[1] = 'b' then x2 := 2;\n if s2[1] = 'c' then x2 := 3;\n if s2[1] = 'd' then x2 := 4;\n if s2[1] = 'e' then x2 := 5;\n if s2[1] = 'f' then x2 := 6;\n if s2[1] = 'g' then x2 := 7;\n if s2[1] = 'h' then x2 := 8;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n a[i, j] := 0;\n end;\n end;\n for i := x1 to 8 do begin\n a[i, y1] := 1;\n end;\n for i := x1 downto 1 do begin\n a[i, y1] := 1;\n end;\n for i := y1 to 8 do begin\n a[x1, i] := 1;\n end;\n for i := y1 downto 1 do begin\n a[x1, i] := 1;\n end;\n a[x2 + 2][y2 + 1] := 1;\n a[x2 + 2][y2 - 1] := 1;\n a[x2 + 1][y2 + 2] := 1;\n a[x2 + 1][y2 - 2] := 1;\n a[x2 - 1][y2 + 2] := 1;\n a[x2 - 1][y2 - 2] := 1;\n a[x2 - 2][y2 + 1] := 1;\n a[x2 - 2][y2 - 1] := 1;\n a[x2, y2] := 1;\n k := 0;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n write(a[i, j], ' ');\n end;\n writeln;\n end;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n if a[i, j] = 0 then inc(k);\n end;\n end;\n writeln(k - 2);\nend.\n"}, {"source_code": "var\n a:array [-10..80,-10..80] of longint;\n i,j,n,m,k,x1,y1,x2,y2,ans:longint;\n s1,s2,s,ss:string;\n\n\n procedure d1 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1; j:=y1;\n while (i<>-1)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n dec(i);\n dec(j);\n end;\n i:=x1; j:=y1;\n while (i<>-1)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[j,i]:=1;\n dec(i);\n inc(j);\n end;\n end;\n\n\n\n procedure d2 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1+1; j:=y1+1;\n while (i<>10)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n inc(j);\n\n end;\n i:=x1+1; j:=y1-1;\n while (i<>10)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n dec(j);\n\n end;\n end;\n\n\n\n procedure g (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=y1;\n for j:=1 to 8 do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n end;\n end;\n\n\n procedure v (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1;\n for j:=1 to 8 do\n begin\n if a[j,i]=-1 then break;\n a[j,i]:=1;\n end;\n end;\n\n procedure kon(x2,y2:longint);\n var\n i,j:longint;\n begin\n i:=x2; j:=y2;\n a[i+2,j+1]:=1;\n a[i+2,j-1]:=1;\n a[i-2,j+1]:=1;\n a[i-2,j-1]:=1;\n a[i+1,j+2]:=1;\n a[i-1,j+2]:=1;\n a[i+1,j-2]:=1;\n a[i-1,j-2]:=1;\n end;\n\nbegin\n readln(s1);\n readln(s2);\n s:='abcdefgh';\n ss:='12345678';\n x1:=pos(s1[1],s);\n x2:=pos(s2[1],s);\n y1:=pos(s1[2],ss);\n y2:=pos(s2[2],ss);\n a[x2,y2]:=1;\n //d1(x1,y1);\n// d2(x1,y1);\n g(x1,y1);\n v(x1,y1);\n kon(x2,y2);\n kon(y1,x1);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]<>1 then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "Var a:array [-10..11,-10..11] of longint;\n s1,s2:string;\n i1,i2,j1,j2,i,j,ans,p:longint;\n begin\n readln(s1);\n readln(s2);\n for i:=-10 to 11 do\n for j:=-10 to 11 do\n begin\n if (i<1) or (i>8) or (j<1) or (j>8) then a[i,j]:=-1;\n end;\n i1:=ord(s1[1])-96;\n val(s1[2],j1,p);\n i2:=ord(s2[1])-96;\n val(s2[2],j2,p);\n for i:=1 to 8 do\n begin\n a[i2,i]:=-1;\n a[i,j2]:=-1;\n end;\n a[i2,j2]:=2;\n a[i1,j1]:=2;\n a[i1-2,j1-1]:=-1;\n a[i1-2,j1+1]:=-1;\n a[i1+2,j1-1]:=-1;\n a[i1+2,j1+1]:=-1;\n a[i1-1,j1-2]:=-1;\n a[i1-1,j1+2]:=-1;\n a[i1+1,j1-2]:=-1;\n a[i1+1,j1+2]:=-1;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if (a[i,j]=0) then begin\n if\n (a[i-2,j-1]<>2) and\n (a[i-2,j+1]<>2) and\n (a[i+2,j-1]<>2) and\n (a[i+2,j+1]<>2) and\n (a[i-1,j-2]<>2) and\n (a[i-1,j+2]<>2) and\n (a[i+1,j-2]<>2) and\n (a[i+1,j+2]<>2) then inc(ans);\n end;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-5..15,-5..15] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]>1 then q1:=false;\n if a[x1,i]>1 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=2 then begin\n if a[i-2,j-1] in [1,3] then q2:=false;\n if a[i-2,j+1] in [1,3] then q2:=false;\n if a[i+2,j-1] in [1,3] then q2:=false;\n if a[i+2,j+1] in [1,3] then q2:=false;\n if a[i-1,j-2] in [1,3] then q2:=false;\n if a[i-1,j+2] in [1,3] then q2:=false;\n if a[i+1,j-2] in [1,3] then q2:=false;\n if a[i+1,j+2] in [1,3] then q2:=false;\n end;\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q2 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[i,j]:=3;\n if tt then k:=k+1;\n end;\n writeln(k);\n end."}, {"source_code": "var s:string; i,j,x1,y1,x2,y2,c:longint;\nbegin\nreadln(s);\nx1:=ord(s[1])-ord('a')+1;\ny1:=ord(s[2])-48;\nreadln(s);\nx2:=ord(s[1])-ord('a')+1;\ny2:=ord(s[2])-48;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) then else inc(c);\nwriteln(c);\nend."}, {"source_code": "var\nused:array[-8..16,-8..16] of char;\ni,j,k,s:longint;\nc:char;\n\n\nbegin\n\nread(c);\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='K';\nused[i-1,j-2]:='k';\nused[i-2,j-1]:='k';\n\nused[i+1,j+2]:='k';\nused[i+2,j+1]:='k';\n\nused[i-1,j+2]:='k';\nused[i-2,j+1]:='k';\n\nused[i+1,j-2]:='k';\nused[i+2,j-1]:='k';\nread(c);\n\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='L';\n\nfor k:= 1 to 8 do\nbegin {\nused[i-k,j-k]:='l';\nused[i+k,j-k]:='l';\nused[i-k,j+k]:='l';\nused[i+k,j+k]:='l'; }\nused[i,j-k]:='l';\nused[i,j+k]:='l';\nused[i+k,j]:='l';\nused[i-k,j]:='l';\nend;\n\ns:=0;\nfor i:= 1 to 8 do\n for j:= 1 to 8 do\n if (ord(used[i,j])=0) and\n (used[i+1,j+2]<>'L') and(used[i+1,j+2]<>'K') and\n (used[i+2,j+1]<>'L') and(used[i+2,j+1]<>'K') and\n (used[i+2,j-1]<>'L') and(used[i+2,j-1]<>'K') and\n (used[i+1,j-2]<>'L') and(used[i+1,j-2]<>'K') and\n (used[i-1,j+2]<>'L') and(used[i-1,j+2]<>'K') and\n (used[i-2,j+1]<>'L') and(used[i-2,j+1]<>'K') and\n (used[i-2,j-1]<>'L') and(used[i-2,j-1]<>'K') and\n (used[i-1,j-2]<>'L') and(used[i-1,j-2]<>'K')\n then inc(s);\n\n\n writeln(s);\n\nend.\n"}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-1,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\nwrite (a);\nend."}, {"source_code": "var\n s,s2 : string;\n a,b,c,d,kode,baris,kolom,jum : longint;\n mat : array[-2..10,-2..10] of longint;\nbegin\n readln(s);\n readln(s2);\n s[1] := chr(ord(s[1])-48);\n s2[1] := chr(ord(s2[1])-48);\n val(s[1],b,kode);\n val(s[2],a,kode);\n val(s2[1],d,kode);\n val(s2[2],c,kode);\n writeln(a,b,c,d);\n mat[a,b] := 1;\n mat[c,d] := 1;\n for baris := 1 to 8 do begin\n for kolom := 1 to 8 do begin\n if (baris = a) or (kolom = b) then mat[baris,kolom] := 1;\n end;\n end;\n\n mat[c-2,d-1] := 1;\n mat[c-2,d+1] := 1;\n mat[c+2,d+1] := 1;\n mat[c+2,d-1] := 1;\n mat[c-1,d+2] := 1;\n mat[c-1,d-2] := 1;\n mat[c+1,d+2] := 1;\n mat[c+1,d-2] := 1;\n mat[a-2,b-1] := 1;\n mat[a-2,b+1] := 1;\n mat[a+2,b+1] := 1;\n mat[a+2,b-1] := 1;\n mat[a-1,b+2] := 1;\n mat[a-1,b-2] := 1;\n mat[a+1,b+2] := 1;\n mat[a+1,b-2] := 1;\n for baris := 1 to 8 do begin\n for kolom := 1 to 8 do begin\n if mat[baris,kolom] = 0 then inc(jum);\n end;\n end;\n\n writeln(jum);\nend."}, {"source_code": "var s,s1,s2:string;\n c1,c2,ch1,ch2,p1,p2,i,kol,j:longint;\n a:array [-100..100,-10..100] of longint;\nconst bx:array [1..8] of integer=(-1,1,2,2,1,-1,-2,-2);\n by:array [1..8] of integer=(2,2,1,-1,-2,-2,-1,1);\nbegin\n s1:='ABCDFGHI';\n s2:='12345678';\n readln(s);\n for i:=1 to 8 do\n begin\n if s[1]=s1[i] then ch1:=i;\n if s[2]=s2[i] then ch2:=i;\n end;\n readln(s);\n for i:=1 to 8 do\n begin\n if s[1]=s1[i] then c1:=i;\n if s[2]=s2[i] then c2:=i;\n end;\n\n p1:=ch1;p2:=ch2;\n while (p1>=1) do\n begin\n a[p1,p2]:=-1; dec(p1);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p1<=8) do\n begin\n a[p1,p2]:=-1;\n inc(p1);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p2<=8) do\n begin\n a[p1,p2]:=-1;\n inc(p2);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p2>=1) do\n begin\n a[p1,p2]:=-1;\n dec(p2);\n end;\n\n for i:=1 to 8 do\n begin\n a[ch1+bx[i],ch2+by[i]]:=-1;\n a[c1+bx[i],c2+by[i]]:=-1;\n end;\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then inc(kol);\n writeln(kol-1);\n for i:=1 to 8 do\n for j:=1 to 8 do\nend."}, {"source_code": "var x,y,x3,y3,kol,x1,x2,y1,y2:longint;\n a:array[0..9,0..9] of longint;\n pp1,pp2:boolean;\n s1,s2:string;\nbegin\nreadln(s1);\nreadln(s2);\nx1:=ord(s1[2])-ord('1')+1;\ny1:=ord(s1[1])-ord('a')+1;\nx2:=ord(s2[2])-ord('1')+1;\ny2:=ord(s2[1])-ord('a')+1;\nkol:=0;\nfor x3:= 1 to 8 do\nfor y3:= 1 to 8 do\nbegin\nif (x1=x3) and (y1=y3) then continue;\nif (y2=y3) and (x2=x3) then continue;\npp1:=(x1=x3) or (Y1=y3);\nif pp1 then continue;\npp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or\n ((abs(x2-x3)=1) and (abs(y2-y3)=2));\nif pp2 then continue;\npp1:=((abs(x1-x3)=2) and (abs(y1-y3)=1)) or\n ((abs(x1-x3)=1) and (abs(y1-y3)=2));\ninc(kol);\nend;\nwriteln(kol-2);\nend.\n\n"}, {"source_code": "const\n fin='';\n fout='';\n\nvar a:array[-10..10,-10..10] of longint;\ni,j,x,y,n,s,code:longint;\nch:char;\n\nbegin\n assign(input,fin);\n reset(input);\n assign(output,fout);\n rewrite(output);\n read(ch);\n x:=ord(ch)-96;\n readln(ch);\n val(ch,y,code);\n a[x,y]:=3;\n for i:=1 to 8 do\n begin\n if a[x,i]=0 then\n a[x,i]:=3;\n if a[i,y]=0 then\n a[i,y]:=3;\n end;\n a[x+1,y+2]:=3;\n if y-2>0 then\n a[x+1,y-2]:=3;\n a[x+2,y+1]:=3;\n if y-1>0 then\n a[x+2,y-1]:=3;\n if x-1>0 then\n a[x-1,y+2]:=3;\n if (y-2>0)and (x-1>0) then\n a[x-1,y-2]:=3;\n if y-2>0 then\n a[x-2,y+1]:=3;\n if (x-2>0)and (y-1>0) then\n a[x-2,y-1]:=3;\n read(ch);\n x:=ord(ch)-96;\n readln(ch);\n val(ch,y,code);\n a[x,y]:=3;\n a[x+1,y+2]:=3;\n if y-2>0 then\n a[x+1,y-2]:=3;\n a[x+2,y+1]:=3;\n if y-1>0 then\n a[x+2,y-1]:=3;\n if x-1>0 then\n a[x-1,y+2]:=3;\n if (y-2>0)and (x-1>0) then\n a[x-1,y-2]:=3;\n if y-2>0 then\n a[x-2,y+1]:=3;\n if (x-2>0)and (y-1>0) then\n a[x-2,y-1]:=3;\n s:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=0 then inc(s);\n end;\n writeln(s);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-5..15,-5..15] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]>1 then q1:=false;\n if a[x1,i]>1 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=2 then begin\n if a[i-2,j-1] in [1,3] then q2:=false;\n if a[i-2,j+1] in [1,3] then q2:=false;\n if a[i+2,j-1] in [1,3] then q2:=false;\n if a[i+2,j+1] in [1,3] then q2:=false;\n if a[i-1,j-2] in [1,3] then q2:=false;\n if a[i-1,j+2] in [1,3] then q2:=false;\n if a[i+1,j-2] in [1,3] then q2:=false;\n if a[i+1,j+2] in [1,3] then q2:=false;\n end;\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q2 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[i,j]:=3;\n if tt then k:=k+1;\n end;\n writeln(k);\n end."}, {"source_code": "program Z2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar a:Array[1..8,1..8] of Boolean;\n s:char;\n m,n,i,j,Sum:Integer;\nprocedure lad(i,j:Integer);\n begin\n if (i=n) or (j=m) or ((i=n-2) and (j=m-1)) or ((i=n+2) and (j=m-1))\n or ((i=n-2) and (j=m+1)) or ((i=n+2) and (j=m+1)) or ((i=n-1) and (j=m-2)) or\n ((i=n-1) and (j=m+2)) or ((i=n+1) and (j=m-2)) or ((i=n+1) and (j=m+2)) then a[i,j]:=TRUE;\n end;\nprocedure kon(i,j:Integer);\nbegin\n if ((i=n-2) and (j=m-1)) or ((i=n+2) and (j=m-1))\n or ((i=n-2) and (j=m+1)) or ((i=n+2) and (j=m+1)) or ((i=n-1) and (j=m-2)) or\n ((i=n-1) and (j=m+2)) or ((i=n+1) and (j=m-2)) or ((i=n+1) and (j=m+2)) then a[i,j]:=TRUE;\n end;\nBegin\nread(s);\nn:=ord(s)-96;\nread(s);\nm:=ord(s)-48;\nreadln;\na[n,m]:=TRUE;\nfor i:=1 to 8 do begin\n for j:=1 to 8 do begin\n lad(i,j);\n end;\nend;\nread(s);\nn:=ord(s)-96;\nread(s);\nm:=ord(s)-48;\na[n,m]:=TRUE;\nfor i:=1 to 8 do begin\n for j:=1 to 8 do begin\n kon(i,j);\n end;\nend;\nfor i:=1 to 8 do begin\n for j:=1 to 8 do begin\n if a[i,j]=FALSE then Sum:=Sum+1;\n end;\nend;\nwrite(Sum);\nend.\n\n\n"}, {"source_code": "const\nv:array[1..8,1..2]of integer=((-1,-2),(1,-2),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));\nvar\ntabla:array[-2..10,-2..10] of byte;\ni,j,k,n,cor,cor2,cora,corb:longint;\nc,c2:char;\nbegin\n read(c);\n readln(cor);\n read(c2);\n readln(cor2);\n cora:=ord(c)-96;\n corb:=ord(c2)-96;\n tabla[cora,cor]:=1;\n tabla[corb,cor2]:=1;\n for i:=1 to 8 do\n tabla[corb+v[i,1],cor2+v[i,2]]:=1;\n for i:=1 to 8 do\n begin\n tabla[i,cor]:=1;\n tabla[cora,i]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if tabla[i,j]=0 then\n k:=k+1;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do write(tabla[i,j],' ');\n writeln;\n end;\n writeln(k-2);\nend.\n"}, {"source_code": "program vadim;\n\nvar a:array[1..8,1..8] of boolean;\n i,j,l1,l2,k1,k2:byte;\n c:char;\n sum:integer;\nfunction nnn(c:char):byte;\nbegin\n case c of\n 'a','1':nnn:=1;\n 'b','2':nnn:=2;\n 'c','3':nnn:=3;\n 'd','4':nnn:=4;\n 'e','5':nnn:=5;\n 'f','6':nnn:=6;\n 'g','7':nnn:=7;\n 'h','8':nnn:=8;\n end;\nend;\n\nbegin\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=false;\n\n read(c);\n l1:=nnn(c);\n readln(c);\n l2:=nnn(c);\n a[l1,l2]:=true;\n read(c);\n k1:=nnn(c);\n readln(c);\n k2:=nnn(c);\n a[k1,k2]:=true;\n for i:= 1 to 8 do\n a[l1,i]:=true;\n for i:=1 to 8 do\n a[i,l2]:=true;\n\n if((k1+2)<=8) and ((k2+1)<=8) then\n a[k1+2,k2+1]:=true;\n\n if((k1+2)<=8) and ((k2-1)>=1) then\n a[k1+2,k2-1]:=true;\n\n if((k1-2)>=1) and ((k2+1)<=8) then\n a[k1-2,k2+1]:=true;\n\n if((k1-2)>=1) and ((k2-1)>=1) then\n a[k1-2,k2-1]:=true;\n\n if((k1+1)<=8) and((k2+2)<=8) then\n a[k1+1,k2+2]:=true;\n\n if((k1+1)<=8) and ((k2-2)>=1) then\n a[k1+1,k2-2] := true;\n\n if((k1-1)>=1) and ((k2+2)<=8) then\n a[k1-1,k2+2]:=true;\n\n if((k1-1)>=1) and ((k2-2)>=1) then\n a[k1-1,k2-2]:=true;\n\n\n\n sum:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not (a[i,j]) then inc(sum);\n write(sum-2);\nend.\n\n"}, {"source_code": "var s:string; i,j,x1,y1,x2,y2,c:longint;\nbegin\nreadln(s);\nx1:=ord(s[1])-ord('a')+1;\ny1:=ord(s[2])-48;\nreadln(s);\nx2:=ord(s[1])-ord('a')+1;\ny2:=ord(s[2])-48;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) or ((abs(i-x1)=2) and (abs(j-y1)=1)) or ((abs(i-x1)=1) and (abs(j-y1)=2)) and (i<>x1) and (i<>x2) and (j<>y1) and (j<>y2) then else inc(c);\nwriteln(c);\nend."}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-100..100,-100..100] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]=3 then q1:=false;\n if a[x1,i]=3 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[i,j]:=3;\n if tt then k:=k+1;\n end;\n writeln(k);\n end."}, {"source_code": "//Yerzhan Dyussenaliyev\nconst\n\tdx: array [1..8] of longint = (-2, -1, 1, 2, 2, 1, -1, -2);\n\tdy: array [1..8] of longint = (2, 2, 2, 1, -1, -2, -2, -1);\nvar\n\ta: array [-10..10, -10..10] of boolean;\n\tch, ch1: char;\n\tx1, y1, x2, y2, n, i, j, ans: longint;\n\nfunction check(x, y: longint): longint;\nvar\n\ti, r, r1: longint;\nbegin\n\tif (x1 = x) or (y1 = y) or (x1 = x2) or (y1 = y2) then begin\n\t check := 0;\n\t\texit;\n\tend;\n\n\ta[x, y] := true;\n\n\tr := 0;\n\tfor i := 1 to 8 do if not a[x + dx[i], y + dy[i]] then inc(r);\n\n\tr1 := 0;\n\tfor i := 1 to 8 do if not a[x2 + dx[i], y2 + dy[i]] then inc(r1);\n\n\tif (r = 8) and (r1 = 8) then check := 1 else check := 0;\n\ta[x, y] := false;\nend;\n\nbegin\n// reset(input, 'a.in');\n// rewrite(output, 'a.out');\n\n\treadln(ch, ch1);\n x1 := ord(ch) - 96;\n y1 := ord(ch1) - 48;\n\treadln(ch, ch1);\n x2 := ord(ch) - 96;\n y2 := ord(ch1) - 48;\n\n\ta[x1, y1] := true;\n\ta[x2, y2] := true;\n\n\tfillchar(a, sizeof(a), 0);\n\tans := 0;\n\tfor i := 1 to 8 do\n\t for j := 1 to 8 do\n\t if not a[i, j] then ans := ans + check(i, j);\n\n\twriteln(ans-3);\nend."}, {"source_code": "const\nv:array[1..8,1..2]of integer=((-1,-2),(1,-2),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));\nvar\ntabla:array[-2..10,-2..10] of byte;\ni,j,k,n,cor,cor2,cora,corb:longint;\nc,c2:char;\nbegin\n read(c);\n readln(cor);\n read(c2);\n readln(cor2);\n cora:=ord(c)-96;\n corb:=ord(c2)-96;\n tabla[cora,cor]:=1;\n tabla[corb,cor2]:=1;\n for i:=1 to 8 do\n tabla[corb+v[i,1],cor2+v[i,2]]:=1;\n for i:=1 to 8 do\n begin\n tabla[i,cor]:=1;\n tabla[cora,i]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if tabla[i,j]=0 then\n k:=k+1;\n\n writeln(k-2);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));\nvar\ntabla:array[-2..10,-2..10] of byte;\ni,j,k,n,cor,cor2,cora,corb:longint;\nc,c2:char;\nbegin\n read(c);\n readln(cor);\n read(c2);\n readln(cor2);\n cora:=ord(c)-96;\n corb:=ord(c2)-96;\n tabla[cora,cor]:=1;\n tabla[corb,cor2]:=1;\n for i:=1 to 8 do\n tabla[corb+v[i,1],cor2+v[i,2]]:=1;\n for i:=1 to 8 do\n begin\n tabla[i,cor]:=1;\n tabla[cora,i]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if tabla[i,j]=0 then\n k:=k+1;\n writeln(k-2);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));\nvar\narr:array[-2..10,-2..10] of boolean;\ni,j,n,p:longint;\ncar:char;\nbegin\n read (car);\n readln(n);\n for i:=1 to 8 do\n arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;\n for i:=1 to 8 do\n arr[i,(ord(car)-94)]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-94),i]:=true;\n read (car);\n readln (n);\n arr[(ord(car)-94),n]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;\n p:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not arr[i,j] then\n inc (p);\n writeln (p);\nend.\n"}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-1,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\nwrite (a);\nend."}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\na:=0;\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-2,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\n\nwrite (a);\n\nend."}, {"source_code": "var\nused:array[-8..16,-8..16] of char;\ni,j,k,s:longint;\nc:char;\n\n\nbegin\n\nread(c);\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='K';\nused[i-1,j-2]:='k';\nused[i-2,j-1]:='k';\n\nused[i+1,j+2]:='k';\nused[i+2,j+1]:='k';\n\nused[i-1,j+2]:='k';\nused[i-2,j+1]:='k';\n\nused[i+1,j-2]:='k';\nused[i+2,j-1]:='k';\nread(c);\n\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='L';\n\nfor k:= 1 to 8 do\nbegin {\nused[i-k,j-k]:='l';\nused[i+k,j-k]:='l';\nused[i-k,j+k]:='l';\nused[i+k,j+k]:='l'; }\nused[i,j-k]:='l';\nused[i,j+k]:='l';\nused[i+k,j]:='l';\nused[i-k,j]:='l';\nend;\n\ns:=0;\nfor i:= 1 to 8 do\n for j:= 1 to 8 do\n if (ord(used[i,j])=0) and\n (used[i+1,j+2]<>'L') and(used[i+1,j+2]<>'K') and\n (used[i+2,j+1]<>'L') and(used[i+2,j+1]<>'K') and\n (used[i+2,j-1]<>'L') and(used[i+2,j-1]<>'K') and\n (used[i+1,j-2]<>'L') and(used[i+1,j-2]<>'K') and\n (used[i-1,j+2]<>'L') and(used[i-1,j+2]<>'K') and\n (used[i-2,j+1]<>'L') and(used[i-2,j+1]<>'K') and\n (used[i-2,j-1]<>'L') and(used[i-2,j-1]<>'K') and\n (used[i-1,j-2]<>'L') and(used[i-1,j-2]<>'K')\n then inc(s);\n\n\n writeln(s);\n\nend.\n"}, {"source_code": "var a: array[1..8,1..8]of longint;\n s1,s2: string;\n x1,y1,x2,y2,i,j,ans: longint;\n\nfunction check(x,y: longint): boolean;\nbegin\n check:=((x>=1) and (x<=8) and (y>=1) and (y<=8));\nend;\n\nprocedure add(x,y: longint);\nbegin\n if check(x,y) then a[x,y]:=1;\nend;\n\nbegin\n fillchar(a,sizeof(a),0);\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n x2:=ord(s2[1])-96;\n y1:=ord(s1[2])-48;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do add(x1,i);\n for i:=1 to 8 do add(i,y1);\n add(x2,y2);\n add(x1-2,y1-1);\n add(x1+2,y1-1);\n add(x1-2,y1+1);\n add(x1+2,y1+2);\n add(x1-1,y1-2);\n add(x1+1,y1-2);\n add(x1-1,y1+2);\n add(x1+1,y1+2);\n add(x2-2,y2-1);\n add(x2+2,y2-1);\n add(x2-2,y2+1);\n add(x2+2,y2+2);\n add(x2-1,y2-2);\n add(x2+1,y2-2);\n add(x2-1,y2+2);\n add(x2+1,y2+2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, x, y, a, b, ans: integer;\n s:string;\n d: array [1 .. 8, 1 .. 8] of boolean;\n dx: array [1 .. 8] of integer = (1, 1, 2, 2, -1, -1, -2, -2);\n dy: array [1 .. 8] of integer = (2, -2, 1, -1, 2, -1, 1, -1);\nfunction check(x1, y1: integer): boolean;\nbegin\n check := not((x1 > 8) or (y1 > 8) or (y1 < 1) or (x1 < 1));\nend;\nbegin\n n := 8;\n readln(s);\n x := ord(s[1]) - ord('a') + 1;\n y := ord(s[2]) - ord('0');\n readln(s);\n a := ord(s[1]) - ord('a') + 1;\n b := ord(s[2]) - ord('0');\n for i := 1 to n do\n for j := 1 to n do\n d[i, j] := true;\n for i := 1 to 8 do\n begin\n if (check(a + dx[i], b + dy[i])) then\n d[a + dx[i], b + dy[i]] := false;\n if (check(x + dx[i], y + dy[i])) then\n d[x + dx[i], y + dy[i]] := false;\n d[x, i] := false;\n d[i, y] := false;\n end;\n ans := 0;\n for i := 1 to n do\n for j := 1 to n do\n if d[i, j] then\n inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "var\nused:array[-8..16,-8..16] of char;\ni,j,k,s:longint;\nc:char;\n\n\nbegin\n\nread(c);\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='K';\nused[i-1,j-2]:='k';\nused[i-2,j-1]:='k';\n\nused[i+1,j+2]:='k';\nused[i+2,j+1]:='k';\n\nused[i-1,j+2]:='k';\nused[i-2,j+1]:='k';\n\nused[i+1,j-2]:='k';\nused[i+2,j-1]:='k';\nread(c);\n\ncase c of\n'a':i:=1;\n'b':i:=2 ;\n'c':i:=3 ;\n'd':i:=4 ;\n'e':i:=5 ;\n'f':i:=6 ;\n'g':i:=7 ;\n'h':i:=8 ;\nend;\n\nreadln(c);\nj:=ord(c)-48;\nused[i,j]:='L';\n\nfor k:= 1 to 8 do\nbegin {\nused[i-k,j-k]:='l';\nused[i+k,j-k]:='l';\nused[i-k,j+k]:='l';\nused[i+k,j+k]:='l'; }\nused[i,j-k]:='l';\nused[i,j+k]:='l';\nused[i+k,j]:='l';\nused[i-k,j]:='l';\nend;\n\ns:=0;\nfor i:= 1 to 8 do\n for j:= 1 to 8 do\n if (ord(used[i,j])=0) and\n (used[i+1,j+2]<>'L') and(used[i+1,j+2]<>'K') and\n (used[i+2,j+1]<>'L') and(used[i+2,j+1]<>'K') and\n (used[i+2,j-1]<>'L') and(used[i+2,j-1]<>'K') and\n (used[i+1,j-2]<>'L') and(used[i+1,j-2]<>'K') and\n (used[i-1,j+2]<>'L') and(used[i-1,j+2]<>'K') and\n (used[i-2,j+1]<>'L') and(used[i-2,j+1]<>'K') and\n (used[i-2,j-1]<>'L') and(used[i-2,j-1]<>'K') and\n (used[i-1,j-2]<>'L') and(used[i-1,j-2]<>'K')\n then inc(s);\n\n\n writeln(s);\n\nend.\n"}, {"source_code": "program BBBBB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a : array[-10..10, -10..10] of integer;\n s1, s2 : string;\n x1, x2, y1, y2, i, j, k : integer;\nbegin\n readln(s1);\n readln(s2);\n y1 := ord(s1[2]) - ord('0');\n y2 := ord(s2[2]) - ord('0');\n if s1[1] = 'a' then x1 := 1;\n if s1[1] = 'b' then x1 := 2;\n if s1[1] = 'c' then x1 := 3;\n if s1[1] = 'd' then x1 := 4;\n if s1[1] = 'e' then x1 := 5;\n if s1[1] = 'f' then x1 := 6;\n if s1[1] = 'g' then x1 := 7;\n if s1[1] = 'h' then x1 := 8;\n if s2[1] = 'a' then x2 := 1;\n if s2[1] = 'b' then x2 := 2;\n if s2[1] = 'c' then x2 := 3;\n if s2[1] = 'd' then x2 := 4;\n if s2[1] = 'e' then x2 := 5;\n if s2[1] = 'f' then x2 := 6;\n if s2[1] = 'g' then x2 := 7;\n if s2[1] = 'h' then x2 := 8;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n a[i, j] := 0;\n end;\n end;\n for i := x1 to 8 do begin\n a[i, y1] := 1;\n end;\n for i := x1 downto 1 do begin\n a[i, y1] := 1;\n end;\n for i := y1 to 8 do begin\n a[x1, i] := 1;\n end;\n for i := y1 downto 1 do begin\n a[x1, i] := 1;\n end;\n a[x2 + 2][y2 + 1] := 1;\n a[x2 + 2][y2 - 1] := 1;\n a[x2 + 1][y2 + 2] := 1;\n a[x2 + 1][y2 - 2] := 1;\n a[x2 - 1][y2 + 2] := 1;\n a[x2 - 1][y2 - 2] := 1;\n a[x2 - 2][y2 + 1] := 1;\n a[x2 - 2][y2 - 1] := 1;\n a[x2, y2] := 1;\n k := 0;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n write(a[i, j], ' ');\n end;\n writeln;\n end;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n if a[i, j] = 0 then inc(k);\n end;\n end;\n writeln(k - 2);\nend.\n"}, {"source_code": "const a:array[1..8,1..2]of integer=((-1,2),(-1,-2),(1,2),(1,-2),(-2,1),(-2,-1),(2,1),(2,-1));\nvar m:array[-8..16,-8..16]of byte;\n a1,a2,b1,b2,i,j,k:integer;\n c1,c2:char;\nbegin\n fillchar(m,sizeof(m),1);\n read(c1);\n readln(a1);\n read(c2);\n readln(a2);\n b1:=ord(c1)-ord('a')+1;\n b2:=ord(c2)-ord('a')+1;\n m[a1,b1]:=0;\n m[a2,b2]:=0;\n for i:=1 to 8 do\n begin\n m[a1+a[i,1],b1+a[i,2]]:=0;\n m[a2+a[i,1],b2+a[i,2]]:=0;\n m[i,b2]:=0;\n m[a2,i]:=0;\n end;\n k:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n inc(k,m[i,j]);\n writeln(k)\nend."}, {"source_code": "var\n x,y:char;\n a:array[1..8,1..8] of boolean;\n i,j,q1,q2,s:longint;\nbegin\n fillchar(a,sizeof(a),true);\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n for i:=q1+1 to 8 do a[i,q2]:=false;\n for i:=q1-1 downto 1 do a[i,q2]:=false;\n for i:=q2+1 to 8 do a[q1,i]:=false;\n for i:=q2-1 downto 1 do a[q1,i]:=false;\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;\n if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;\n if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;\n if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;\n if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;\n if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;\n if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;\n if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if a[i,j] then write('1 ') else write('0 ');\n writeln;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(s);\n writeln(s-1);\nend."}, {"source_code": "var s:string; a:Array[-1..10,-1..10] of byte; i,j,x,y,c:longint;\nbegin\nfillchar(A,sizeof(a),0);\nreadln(s);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-48;\nfor i:=1 to 8 do begin\n a[i][y]:=1;\n a[x][i]:=1;\nend;\nreadln(s);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-48;\na[x-2][y-1]:=1;\na[x-2][y+1]:=1;\na[x-1][y-2]:=1;\na[x-1][y+2]:=1;\na[x+2][y-1]:=1;\na[x+2][y+1]:=1;\na[x+1][y-2]:=1;\na[x+1][y+2]:=1;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i][j]=1) and (a[i-2][j-1]=0) and (a[i-2][j+1]=0) and (a[i-1][j-2]=0) and (a[i-1][j+2]=0) and (a[i+2][j-1]=0) and (a[i+2][j+1]=0) and (a[i+1][j-2]=0) and (a[i+1][j+2]=0) then inc(c);\nwriteln(c);\nend."}, {"source_code": "const fi = '';\n fo = '';\n f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);\nvar a: array[-1..10,-1..10] of boolean;\n x1, x2: char;\n s: string;\n y1, y2, i, j, ans, e: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n fillchar(a,sizeof(a),true);\n readln(x1,s);\n val(s,y1,e);\n readln(x2,s);\n val(s,y2,e);\n a[f[x1],y1]:=false;\n for i:=1 to 8 do\n begin\n a[f[x1],i]:=false;\n a[i,y1]:=false;\n end;\n\n a[f[x2],y2]:=false;\n a[f[x2]-2,y2-1]:=false;\n a[f[x2]-2,y2+1]:=false;\n a[f[x2]-1,y2-2]:=false;\n a[f[x2]-1,y2+2]:=false;\n a[f[x2]+1,y2-2]:=false;\n a[f[x2]+1,y2+2]:=false;\n a[f[x2]+2,y2-1]:=false;\n a[f[x2]+2,y2+1]:=false;\n\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(ans);\n writeln(ans-2);\n\n {for i:=1 to 8 do\n begin\n for j:=1 to 8 do if a[i,j] then write('T ')\n else write('F ');\n writeln;\n end; }\n\n close(input); close(output);\nend.\n"}, {"source_code": "const dx:array[1..8] of longint = (1,1,-1,-1,2,2,-2,-2);\n dy:array[1..8] of longint = (2,-2,2,-2,1,-1,1,-1);\nvar a1,a2,b1,b2,i,j,ans:longint;\ns1,s2:string;\nf:integer;\nd:array[1..100] of longint;\na:array[-1..10,-1..10]of longint;\nbegin\n //assign(input,'input.txt');\n //assign(output,'output.txt');\n //reset(input);\n //rewrite(output);\n readln(s1);\n readln(s2);\n a1:=ord(s1[1])-96;\n b1:=ord(s2[1])-96;\n val(s1[2],a2,f);\n val(s2[2],b2,f);\n a[b1,b2]:=1;\n for i:=1 to 8 do\n begin\n a[a1,i]:=1;\n a[i,a2]:=1;\n end;\n for i:=1 to 8 do\n a[b1+dx[i],b2+dy[i]]:=1;\n for i:=1 to 8 do\n a[a1+dx[i],a2+dy[i]]:=1;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if (a[i,j]=0) then inc(ans);\n //write(a[i,j]:2);\n end;\n //writeln;\n end;\n ans:=0;\n write(ans);\nend.\n"}, {"source_code": "const\n sy:array[1..8]of shortint=(-2,-2,-1,1,2,2,1,-1);\n sx:array[1..8]of shortint=(-1,1,2,2,1,-1,-2,-2);\nvar\n s:string;\n f:array[1..8,1..8]of boolean;\n i,j,x,y,x1,y1,k:longint;\nbegin\n readln(s);\n fillchar(f,sizeof(f),false);\n x:=ord(s[1])-96;\n y:=ord(s[2])-48;\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n k:=0;\n f[y1,x1]:=true;\n for i:=x to 8 do f[y,i]:=true;\n for i:=x downto 1 do f[y,i]:=true;\n for i:=y to 8 do f[i,x]:=true;\n for i:=y downto 1 do f[i,x]:=true;\n for i:=1 to 8 do\n begin\n if(sy[i]+y>1)and(sy[i]+y<9)and(sx[i]+x>1)and(sx[i]+x<9)then f[sy[i]+y,sx[i]+x]:=true;\n if(sy[i]+y1>1)and(sy[i]+y1<9)and(sx[i]+x1>1)and(sx[i]+x1<9)then f[sy[i]+y1,sx[i]+x1]:=true;\n end;\n for i:=1to 8 do for j:=1 to 8 do if not f[i,j]then inc(k);\n writeln(k);\nend."}, {"source_code": "var\n a:array [-10..80,-10..80] of longint;\n i,j,n,m,k,x1,y1,x2,y2,ans:longint;\n s1,s2,s,ss:string;\n\n procedure print;\n var\n i,j:longint;\n begin\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(a[i,j]);\n writeln\n end;\n end;\n\n\n procedure d1 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1; j:=y1;\n while (i<>-1)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n dec(i);\n dec(j);\n end;\n i:=x1; j:=y1;\n while (i<>-1)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[j,i]:=1;\n dec(i);\n inc(j);\n end;\n end;\n\n\n\n procedure d2 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1+1; j:=y1+1;\n while (i<>10)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n inc(j);\n\n end;\n i:=x1+1; j:=y1-1;\n while (i<>10)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n dec(j);\n\n end;\n end;\n\n\n\n procedure g (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=y1;\n for j:=1 to 8 do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n end;\n end;\n\n\n procedure v (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1;\n for j:=1 to 8 do\n begin\n if a[j,i]=-1 then break;\n a[j,i]:=1;\n end;\n end;\n\n procedure kon(x2,y2:longint);\n var\n i,j:longint;\n begin\n i:=x2; j:=y2;\n a[i+2,j+1]:=1;\n a[i+2,j-1]:=1;\n a[i-2,j+1]:=1;\n a[i-2,j-1]:=1;\n a[i+1,j+2]:=1;\n a[i-1,j+2]:=1;\n a[i+1,j-2]:=1;\n a[i-1,j-2]:=1;\n end;\n\nbegin\n readln(s1);\n readln(s2);\n s:='abcdefgh';\n ss:='12345678';\n x1:=pos(s1[1],s);\n x2:=pos(s2[1],s);\n y1:=pos(s1[2],ss);\n y2:=pos(s2[2],ss);\n a[x2,y2]:=1;\n //d1(x1,y1);\n// d2(x1,y1);\n g(x1,y1);\n v(x1,y1);\n kon(y2,x2);\n kon(y1,x1);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]<>1 then inc(ans);\n if ans=43 then writeln(42)\n else writeln(ans);\nend.\n"}, {"source_code": "program codeforces_b;\nvar a:array [1..8,1..8] of integer;answ:integer;x,y:string;\n\n procedure inputdata;\n begin\n readln(x);\n readln(y);\n end;\n\n procedure glub1(x,y:integer);\n begin\n a[x,y]:=1;\n if (x-1>0) then glub1(x-1,y);\n end;\n\n procedure glub2(x,y:integer);\n begin\n a[x,y]:=1;\n if (x+1<9) then glub2(x+1,y);\n end;\n\n procedure glub3(x,y:integer);\n begin\n a[x,y]:=1;\n if (y-1>0) then glub3(x,y-1);\n end;\n\n procedure glub4(x,y:integer);\n begin\n a[x,y]:=1;\n if (y+1<9) then glub4(x,y+1);\n end;\n\n procedure processdata;\n var li,lj,ki,kj,i,j,p:integer;\n begin\n li:=ord(x[1])-96;\n val(x[2],lj,p);\n ki:=ord(y[1])-96;\n val(y[2],kj,p);\n a[ki,kj]:=1;\n glub1(li,lj);\n glub2(li,lj);\n glub3(li,lj);\n glub4(li,lj);\n if (ki-1>0) and (kj-2>0) then a[ki-1,kj-2]:=1;\n if (ki-1>0) and (kj+2<9) then a[ki-1,kj+2]:=1;\n if (ki-2>0) and (kj-1>0) then a[ki-2,kj-1]:=1;\n if (ki-2>0) and (kj+1<9) then a[ki-2,kj+1]:=1;\n if (ki+1<9) and (kj-2>0) then a[ki+1,kj-2]:=1;\n if (ki+1<9) and (kj+2<9) then a[ki+1,kj+2]:=1;\n if (ki+2<9) and (kj+1<9) then a[ki+2,kj+1]:=1;\n if (ki+2<9) and (kj-1>0) then a[ki+2,kj-1]:=1;\n if (li-1>0) and (lj-2>0) then a[li-1,lj-2]:=1;\n if (li-1>0) and (lj+2<9) then a[li-1,lj+2]:=1;\n if (li-2>0) and (lj-1>0) then a[li-2,lj-1]:=1;\n if (li-2>0) and (lj+1<9) then a[li-2,lj+1]:=1;\n if (li+1<9) and (lj-2>0) then a[li+1,lj-2]:=1;\n if (li+1<9) and (lj+2<9) then a[li+1,lj+2]:=1;\n if (li+2<9) and (lj+1<9) then a[li+2,lj+1]:=1;\n if (li+2<9) and (lj-1>0) then a[li+2,lj-1]:=1;\n\n answ:=0;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if a[i,j]=0 then begin inc(answ);write(a[i,j],' ');end;\n writeln;\n end;\n end;\n\n procedure outputdata;\n begin\n writeln(answ);\n end;\n\nbegin\ninputdata;\nprocessdata;\noutputdata;\nend."}, {"source_code": "var\n n,i,b,summ,x1,y1,x2,y2,j,kol,code:longint;\n s1,s2,s:string;\n c:char;\n a:array[-1..10,-1..10] of longint;\nbegin\n readln(s1);\n readln(s2);\n c:=s1[1];\n x1:=ord(c)-96;\n s:=s1[2];\n val(s,y1,code);\n\n c:=s2[1];\n x2:=ord(c)-96;\n s:=s2[2];\n val(s,y2,code);\n for i:=-1 to 10 do\n begin\n a[i,-1]:=-1;\n a[i,0]:=-1;\n a[i,9]:=-1;\n a[i,10]:=-1;\n a[-1,i]:=-1;\n a[0,i]:=-1;\n a[9,i]:=-1;\n a[10,i]:=-1;\n end;\n if a[x2+2,y2+1]=0 then a[x2+2,y2+1]:=1;\n if a[x2+2,y2-1]=0 then a[x2+2,y2-1]:=1;\n if a[x2-2,y2+1]=0 then a[x2-2,y2+1]:=1;\n if a[x2-2,y2-1]=0 then a[x2-2,y2-1]:=1;\n if a[x2+1,y2+2]=0 then a[x2+1,y2+2]:=1;\n if a[x2+1,y2-2]=0 then a[x2+1,y2-2]:=1;\n if a[x2-1,y2+2]=0 then a[x2-1,y2+2]:=1;\n if a[x2-1,y2-2]=0 then a[x2-1,y2-2]:=1;\n a[x1,y1]:=2;\n a[x2,y2]:=2;\n for i:=1 to x1 do\n begin\n a[i,y1]:=1;\n end;\n for i:=x1 to 8 do\n begin\n a[i,y1]:=1;\n end;\n for i:=1 to y1 do\n begin\n a[x1,i]:=1;\n end;\n for i:=y1 to 8 do\n begin\n a[x1,i]:=1;\n end;\n a[x1,y1]:=2;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if a[i,j]=0 then begin\n kol:=0;\n if a[i+2,j+1]<>2 then kol:=kol+1;\n if a[i+2,j-1]<>2 then kol:=kol+1;\n if a[i-2,j+1]<>2 then kol:=kol+1;\n if a[i-2,j-1]<>2 then kol:=kol+1;\n if a[i+1,j+2]<>2 then kol:=kol+1;\n if a[i+1,j+2]<>2 then kol:=kol+1;\n if a[i-1,j+2]<>2 then kol:=kol+1;\n if a[i-1,j-2]<>2 then kol:=kol+1;\n if kol=8 then summ:=summ+1;\n end;\n end;\n end;\n write(summ);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));\nvar\narr:array[-2..10,-2..10] of boolean;\ni,j,n,p:longint;\ncar:char;\nbegin\n read (car);\n readln(n);\n for i:=1 to 8 do\n arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;\n for i:=1 to 8 do\n arr[i,(ord(car)-94)]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-94),i]:=true;\n read (car);\n readln (n);\n arr[(ord(car)-94),n]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-94+v[i,1]),(n+v[i,2])]:=true;\n p:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not arr[i,j] then\n inc (p);\n writeln (p);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\nCuadro[r,c]:='x'; \nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont);\nend.\n\n\n"}, {"source_code": "program Preoject14;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a:array[-3..11,-2..11] of integer;\n s:string;\n i,j,k,m,n:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n k:=-2;\n\n\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=1;\n\n for i:=1 to 2 do\n begin\n readln(s);\n m:=ord(s[1])-ord('a')+1;\n n:=StrToInt(s[2]);\n if i=1 then\n begin\n a[m,n]:=2;\n for j:=1 to 8 do\n begin\n a[m,j]:=2;\n a[j,n]:=2;\n end;\n end\n else\n begin\n a[m,n]:=2;\n a[m-2,n-1]:=2;\n a[m-1,n-2]:=2;\n a[m-2,n+1]:=2;\n a[m-1,n+2]:=2;\n a[m+1,n-2]:=2;\n a[m+2,n-1]:=2;\n a[m+1,n+2]:=2;\n a[m+2,n+1]:=2;\n end;\n end;\n\n for j:=-2 to 11 do\n begin\n for i:=-3 to 11 do\n begin\n if ((j<1) or (j>8)) or ((j>=1) or (j>=8)) and ((i<=0) or (i>8)) then\n a[i,j]:=0;\n end;\n end;\n\n\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n if ((a[i-2,j-1]<>2) and (a[i-2,j-1]<>0) and (a[i-2,j-1]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i-1,j-2]<>2) and (a[i-1,j-2]<>0) and (a[i-1,j-2]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i-2,j+1]<>2) and (a[i-2,j+1]<>0) and (a[i-2,j+1]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i-1,j+2]<>2) and (a[i-1,j+2]<>0) and (a[i-1,j+2]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i+1,j-2]<>2) and (a[i+1,j-2]<>0) and (a[i+1,j-2]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i+2,j-1]<>2) and (a[i+2,j-1]<>0) and (a[i+2,j-1]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i+1,j+2]<>2) and (a[i+1,j+2]<>0) and (a[i+1,j+2]=1) and (a[i,j]<>2) and (a[i,j]=1))\n or ((a[i+2,j+1]<>2) and (a[i+2,j+1]<>0) and (a[i+2,j+1]=1) and (a[i,j]<>2) and (a[i,j]=1))\n then\n k:=k+1;\n end;\n end;\n writeln(k);\n\n { for i:=-3 to 11 do\n begin\n for j:=-2 to 11 do\n write(a[i,j],' ');\n writeln;\n end;\n\n readln; }\nend."}, {"source_code": "{$apptype console}\n\nconst d : array [1..8, 1..2] of integer = ((1,2),(1,-2),(-1,2),(-1,-2),(2,1),(2,-1),(-2,1),(-2,-1));\n\nvar lx, ly, kx, ky: integer;\n m : array [1..8, 1..8] of boolean;\n t : string;\n\nprocedure conv( const s : string; var x, y : integer );\nbegin\n x := ord(s[2]) - ord('1') + 1;\n y := ord(s[1]) - ord('a') + 1;\nend;\n\nprocedure Mark( x, y : integer );\nbegin\n if( x>=1) and(y>=1) and (x<=8) and(y<=8 ) then m[y][x] := false;\nend;\n\nfunction Check( x0, y0 : integer ) : boolean;\nvar i, x, y : integer;\nbegin\n result := true;\n for i := 1 to 8 do begin\n x := x0 + d[i][1];\n y := y0 + d[i][2];\n if ((x=lx)and(y=ly)) then begin result := false; break; end;\n end;\nend;\n\nvar x,y, i, s : integer;\nbegin\n readln( t );\n Conv( t, lx, ly );\n readln( t );\n Conv( t, kx, ky );\n{}\n for x := 1 to 8 do\n for y := 1 to 8 do\n if (x = lx ) or (y=ly ) then m[y][x]:=false else m[y][x] := true;\n \n m[ky][kx] := false;\n for i := 1 to 8 do Mark( kx + d[i][1], ky + d[i][2] );\n{}\n s := 0;\n for x := 1 to 8 do\n for y := 1 to 8 do\n if m[y][x] and Check( y,x ) then inc( s );\n{}\n write( s );\nend.\n"}, {"source_code": "var a: array[1..8,1..8]of longint;\n s1,s2: string;\n x1,y1,x2,y2,i,j,ans: longint;\n\nfunction check(x,y: longint): boolean;\nbegin\n check:=((x>=1) and (x<=8) and (y>=1) and (y<=8));\nend;\n\nprocedure add(x,y: longint);\nbegin\n if check(x,y) then a[x,y]:=1;\nend;\n\nbegin\n fillchar(a,sizeof(a),0);\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n x2:=ord(s2[1])-96;\n y1:=ord(s1[2])-48;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do add(x1,i);\n for i:=1 to 8 do add(i,y1);\n add(x2,y2);\n add(x1-2,y1-1);\n add(x1+2,y1-1);\n add(x1-2,y1+1);\n add(x1+2,y1+2);\n add(x1-1,y1-2);\n add(x1+1,y1-2);\n add(x1-1,y1+2);\n add(x1+1,y1+2);\n add(x2-2,y2-1);\n add(x2+2,y2-1);\n add(x2-2,y2+1);\n add(x2+2,y2+2);\n add(x2-1,y2-2);\n add(x2+1,y2-2);\n add(x2-1,y2+2);\n add(x2+1,y2+2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "var\na:array [1..8,1..8] of boolean;\nc,code,d1,d,i,j,y1,y2,x1,x2:longint;\nq,w,e,r:char;\nbegin\n c:=0;\n readln(q,w);\n read(e,r);\n x1:=ord(q)-96;\n x2:=ord(e)-96;\n val(w,y1,code);\n val(r,y2,code);\n a[x1,y1]:=true;\n a[x2,y2]:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n d:=abs((i-x1)*(j-y1));\n d1:=abs((i-x2)*(j-y2));\n if (d=2)or(d1=2)or(x1=i)or(x2=j) then a[i,j]:=true;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=false then inc(c);\n write(c+1);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l,k:string; i,j,m,n,y:integer; a:array[1..8,1..8]of integer;\nbegin\nreadln(l);\nreadln(k);\ncopy(l,1,1);\ncopy(k,1,1);\ncase l[1] of\n'a':\nm:=1;\n'b':\nm:=2;\n'c':\nm:=3;\n'd':\nm:=4;\n'e':\nm:=5;\n'f':\nm:=6;\n'g':\nm:=7;\n'h':\nm:=8;\nend;\ncase k[1] of\n'a':\nn:=1;\n'b':\nn:=2;\n'c':\nn:=3;\n'd':\nn:=4;\n'e':\nn:=5;\n'f':\nn:=6;\n'g':\nn:=7;\n'h':\nn:=8;\nend;\nfor j:=1 to 8 do\nbegin\na[m,j]:=1;\na[j,strtoint (l[2])]:=1;\na[n-1,(strtoint (copy(k,2,1))-2)]:=1;\na[n-1,(strtoint(copy(k,2,1))+2)]:=1;\na[n+1,(strtoint(copy(k,2,1))-2)]:=1;\na[n+1,(strtoint(copy(k,2,1))+2)]:=1;\na[n-2,(strtoint(copy(k,2,1))-1)]:=1;\na[n-2,(strtoint(copy(k,2,1))+1)]:=1;\na[n+2,(strtoint(copy(k,2,1))-1)]:=1;\na[n+2,(strtoint(copy(k,2,1))+1)]:=1;\nend;\nfor i:=1 to 8 do\nfor j:=1 to 8 do\n\nif a[i,j]<>1 then\ny:=y+1;\nwriteln(y-3);\nreadln;\nend.\n"}, {"source_code": "Var a:array [-10..11,-10..11] of longint;\n s1,s2:string;\n i1,i2,j1,j2,i,j,ans,p:longint;\n begin\n readln(s1);\n readln(s2);\n for i:=-10 to 11 do\n for j:=-10 to 11 do\n begin\n if (i<1) or (i>8) or (j<1) or (j>8) then a[i,j]:=-1;\n end;\n i1:=ord(s1[1])-96;\n val(s1[2],j1,p);\n i2:=ord(s2[1])-96;\n val(s2[2],j2,p);\n for i:=1 to 8 do\n begin\n a[i2,i]:=-1;\n a[i,j2]:=-1;\n end;\n a[i2,j2]:=2;\n a[i1,j1]:=2;\n a[i1-2,j1-1]:=-1;\n a[i1-2,j1+1]:=-1;\n a[i1+2,j1-1]:=-1;\n a[i1+2,j1+1]:=-1;\n a[i1-1,j1-2]:=-1;\n a[i1-1,j1+2]:=-1;\n a[i1+1,j1-2]:=-1;\n a[i1+1,j1+2]:=-1;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if (a[i,j]=0) then begin\n if\n (a[i-2,j-1]<>2) and\n (a[i-2,j+1]<>2) and\n (a[i+2,j-1]<>2) and\n (a[i+2,j+1]<>2) and\n (a[i-1,j-2]<>2) and\n (a[i-1,j+2]<>2) and\n (a[i+1,j-2]<>2) and\n (a[i+1,j+2]<>2) then inc(ans);\n end;\n end;\n writeln(ans);\n end.\n"}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont-1);\nend.\n\n"}, {"source_code": "var x,y,x3,y3,kol,x1,x2,y1,y2:longint;\n a:array[0..9,0..9] of longint;\n pp1,pp2:boolean;\n s1,s2:string;\nbegin\nreadln(s1);\nreadln(s2);\nx1:=ord(s1[2])-ord('1')+1;\ny1:=ord(s1[1])-ord('a')+1;\nx2:=ord(s2[2])-ord('1')+1;\ny2:=ord(s2[1])-ord('a')+1;\nkol:=0;\nfor x3:= 1 to 8 do\nfor y3:= 1 to 8 do\nbegin\nif (x1=x3) and (y1=y3) then continue;\nif (y2=y3) and (x2=x3) then continue;\npp1:=(x1=x3) or (Y1=y3);\nif pp1 then continue;\npp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or\n ((abs(x2-x3)=1) and (abs(y2-y3)=2));\nif pp2 then continue;\ninc(kol);\nend;\nwriteln(kol-2);\nend.\n\n"}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-5..15,-5..15] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]>1 then q1:=false;\n if a[x1,i]>1 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=2 then begin\n if a[i-2,j-1] in [1,3] then q2:=false;\n if a[i-2,j+1] in [1,3] then q2:=false;\n if a[i+2,j-1] in [1,3] then q2:=false;\n if a[i+2,j+1] in [1,3] then q2:=false;\n if a[i-1,j-2] in [1,3] then q2:=false;\n if a[i-1,j+2] in [1,3] then q2:=false;\n if a[i+1,j-2] in [1,3] then q2:=false;\n if a[i+1,j+2] in [1,3] then q2:=false;\n end;\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q2 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[i,j]:=3;\n if tt then k:=k+1;\n end;\n writeln(k);\n end."}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont-1);\nend.\n\n"}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-1,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\nwrite (a);\nend."}, {"source_code": "const\n fin='';\n fout='';\n\nvar a:array[-10..10,-10..10] of longint;\ni,j,x,y,n,s,code:longint;\nch:char;\n\nbegin\n assign(input,fin);\n reset(input);\n assign(output,fout);\n rewrite(output);\n read(ch);\n x:=ord(ch)-96;\n readln(ch);\n val(ch,y,code);\n a[x,y]:=3;\n for i:=1 to 8 do\n begin\n if a[x,i]=0 then\n a[x,i]:=3;\n if a[i,y]=0 then\n a[i,y]:=3;\n end;\n a[x+1,y+2]:=3;\n if y-2>0 then\n a[x+1,y-2]:=3;\n a[x+2,y+1]:=3;\n if y-1>0 then\n a[x+2,y-1]:=3;\n if x-1>0 then\n a[x-1,y+2]:=3;\n if (y-2>0)and (x-1>0) then\n a[x-1,y-2]:=3;\n if y-2>0 then\n a[x-2,y+1]:=3;\n if (x-2>0)and (y-1>0) then\n a[x-2,y-1]:=3;\n read(ch);\n x:=ord(ch)-96;\n readln(ch);\n val(ch,y,code);\n a[x,y]:=3;\n a[x+1,y+2]:=3;\n if y-2>0 then\n a[x+1,y-2]:=3;\n a[x+2,y+1]:=3;\n if y-1>0 then\n a[x+2,y-1]:=3;\n if x-1>0 then\n a[x-1,y+2]:=3;\n if (y-2>0)and (x-1>0) then\n a[x-1,y-2]:=3;\n if y-2>0 then\n a[x-2,y+1]:=3;\n if (x-2>0)and (y-1>0) then\n a[x-2,y-1]:=3;\n s:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=0 then inc(s);\n end;\n writeln(s);\n close(input);\n close(output);\nend.\n"}, {"source_code": "var\n x,y:char;\n a:array[1..8,1..8] of boolean;\n i,j,q1,q2,s:longint;\nbegin\n fillchar(a,sizeof(a),true);\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n for i:=q1+1 to 8 do a[i,q2]:=false;\n for i:=q1-1 downto 1 do a[i,q2]:=false;\n for i:=q2+1 to 8 do a[q1,i]:=false;\n for i:=q2-1 downto 1 do a[q1,i]:=false;\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;\n if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;\n if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;\n if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;\n if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;\n if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;\n if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;\n if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(s);\n writeln(s);\nend."}, {"source_code": "const a:array[1..8,1..2]of integer=((-1,2),(-1,-2),(1,2),(1,-2),(-2,1),(-2,-1),(2,1),(2,-1));\nvar m:array[-8..16,-8..16]of byte;\n a1,a2,b1,b2,i,j,k:integer;\n c1,c2:char;\nbegin\n fillchar(m,sizeof(m),1);\n read(c1);\n readln(a1);\n read(c2);\n readln(a2);\n b1:=ord(c1)-ord('a')+1;\n b2:=ord(c2)-ord('a')+1;\n m[a1,b1]:=0;\n m[a2,b2]:=0;\n for i:=1 to 8 do\n begin\n m[a1+a[i,1],b1+a[i,2]]:=0;\n m[a2+a[i,1],b2+a[i,2]]:=0;\n m[i,b2]:=0;\n m[a2,i]:=0;\n end;\n k:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n inc(k,m[i,j]);\n writeln(k)\nend."}, {"source_code": "var\nx,y,ans,i,p:integer;\npole:array [1..8,1..8] of integer;\npoz:string;\nbegin\n//îòìå÷àþòñÿ êëåòêè, â êîòîðûå íåëüçÿ ñòàâèòü ôèãóðû============================\n readln(poz);\n val(poz[2],y,p);\n case poz[1] of\n 'a':x:=1;\n 'b':x:=2;\n 'c':x:=3;\n 'd':x:=4;\n 'e':x:=5;\n 'f':x:=6;\n 'g':x:=7;\n 'h':x:=8;\n end;\nfor i:=1 to 8 do\n begin\n pole[x,i]:=1;\n pole[i,y]:=1;\n end;\n pole[x,y]:=2;\n read(poz);\n val(poz[2],y,p);\n case poz[1] of\n 'a':x:=1;\n 'b':x:=2;\n 'c':x:=3;\n 'd':x:=4;\n 'e':x:=5;\n 'f':x:=6;\n 'g':x:=7;\n 'h':x:=8;\n end;\n pole[x,y]:=2;\n if (x-2>0) and (y-3>0) then pole[x-2,y-3]:=1;\n if (x-2>0) and (y+3<8) then pole[x-2,y+3]:=1;\n if (x+2<8) and (y-3>0) then pole[x+2,y-3]:=1;\n if (x+2<8) and (y+3<8) then pole[x+2,y+3]:=1;\n if (x-3>0) and (y-2>0) then pole[x-3,y-2]:=1;\n if (x-3>0) and (y+2<8) then pole[x-3,y+2]:=1;\n if (x+3<8) and (y-2>0) then pole[x+3,y-2]:=1;\n if (x+3<8) and (y+2<8) then pole[x+3,y+2]:=1;\n //ðàçìåòêà îêîí÷åíà============================================================\n //ïîäñ÷¸ò ñâîáîäíûç ïîëîæåíèé==================================================\n for x:=1 to 8 do\n begin\n for y:= 1 to 8 do\n begin\n if (x-2>0) and (y-3>0) and (pole[x-2,y-3]=2) then pole[x,y]:=3;\n if (x-2>0) and (y+3<8) and (pole[x-2,y+3]=2) then pole[x,y]:=3;\n if (x+2<8) and (y-3>0) and (pole[x+2,y-3]=2) then pole[x,y]:=3;\n if (x+2<8) and (y+3<8) and (pole[x+2,y+3]=2) then pole[x,y]:=3;\n if (x-3>0) and (y-2>0) and (pole[x-3,y-2]=2) then pole[x,y]:=3;\n if (x-3>0) and (y+2<8) and (pole[x-3,y+2]=2) then pole[x,y]:=3;\n if (x+3<8) and (y-2>0) and (pole[x+3,y-2]=2) then pole[x,y]:=3;\n if (x+3<8) and (y+2<8) and (pole[x+3,y+2]=2) then pole[x,y]:=3;\n if pole[x,y]=0 then inc(ans);\n end;\n end;\n//ïîäñ÷¸ò îêîí÷åí===============================================================\n//âûâîä=========================================================================\nwriteln(ans);\nend."}, {"source_code": "var\n x,y:char;\n a:array[1..8,1..8] of boolean;\n i,j,q1,q2,s:longint;\nbegin\n fillchar(a,sizeof(a),true);\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n for i:=q1+1 to 8 do a[i,q2]:=false;\n for i:=q1-1 downto 1 do a[i,q2]:=false;\n for i:=q2+1 to 8 do a[q1,i]:=false;\n for i:=q2-1 downto 1 do a[q1,i]:=false;\n readln(x,y);\n q1:=ord(x)-96;q2:=ord(y)-48;\n a[q1,q2]:=false;\n if (q1-2>0) and (q2-1>0) then a[q1-2,q2-1]:=false;\n if (q1-2>0) and (q2+1<=8) then a[q1-2,q2+1]:=false;\n if (q1-1>0) and (q2-2>0) then a[q1-1,q2-2]:=false;\n if (q1-1>0) and (q2+2<=8) then a[q1-1,q2+2]:=false;\n if (q1+1<=8) and (q2-2>0) then a[q1+1,q2-2]:=false;\n if (q1+1<=8) and (q2+2<=8) then a[q1+1,q2+2]:=false;\n if (q1+2<=8) and (q2-1>0) then a[q1+2,q2-1]:=false;\n if (q1+2<=8) and (q2+1<=8) then a[q1+2,q2+1]:=false;\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n if a[i,j] then write('1 ') else write('0 ');\n writeln;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(s);\n writeln(s);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n{$O-}\n\nuses\n SysUtils;\n\nconst\n dx: array[1..8]of longint=(2, 2, -2, -2, 1, 1, -1, -1);\n dy: array[1..8]of longint=(1, -1, 1, -1, 2, -2, 2, -2);\nvar\n a:array [-1..10, -1..10] of boolean;\n ch1,ch2:Char;\n r, c, j, k, i, rx, ry, kx, ky: longint;\nbegin {\n reset(input,'input.txt');\n rewrite(output,'output.txt'); }\n\n read(ch1, ch2);\n case ch1 of\n 'a': rx:= 1;\n 'b': rx:= 2;\n 'c': rx:= 3;\n 'd': rx:= 4;\n 'e': rx:= 5;\n 'f': rx:= 6;\n 'g': rx:= 7;\n 'h': rx:= 8;\n end;\n ry:= strtoint(ch2);\n\n readln;\n c:= 0;\n read(ch1, ch2);\n case ch1 of\n 'a': kx:= 1;\n 'b': kx:= 2;\n 'c': kx:= 3;\n 'd': kx:= 4;\n 'e': kx:= 5;\n 'f': kx:= 6;\n 'g': kx:= 7;\n 'h': kx:= 8;\n end;\n ky:= strtoint(ch2);\n\n for i:= 1 to 8 do\n for j:= 1 to 8 do\n a[i, j]:= true;\n\n a[rx, ry]:= false;\n for i:= 1 to 8 do begin\n a[i, ry]:= false;\n a[rx, i]:= false;\n end;\n\n a[kx, ky]:= false;\n for i:= 1 to 8 do\n a[kx + dx[i], ky + dy[i]]:= false;\n r:= 0;\n for i:= 1 to 8 do\n for j:= 1 to 8 do begin\n for k:= 1 to 8 do begin\n if not a[i, j] and not a[i + dx[k], j + dy[k]] then\n r:= 1;\n end;\n if r = 0 then inc(c);\n r:= 0;\n end;\n\n writeln(c - 2);\n\nend.\n"}, {"source_code": "program shachmat;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar a:array[1..8,1..8]of boolean;\n la,ha,lb,hb,i,j,n:byte;\n s1:string;\nbegin\n readln(s1);\n la:=ord(s1[1])-96; lb:=ord(s1[2])-48;\n readln(s1);\n ha:=ord(s1[1])-96; hb:=ord(s1[2])-48;\n for i:=1 to 8 do a[la,i]:=true;\n for i:=1 to 8 do a[i,lb]:=true;\n if (la>1)and(lb<7) then a[la-1,lb+2]:=true;\n if (la>2)and(lb<8) then a[la-2,lb+1]:=true;\n if (la>1)and(lb>2) then a[la-1,lb-2]:=true;\n if (la>2)and(lb>1) then a[la-2,lb-1]:=true;\n if (la<8)and(lb<7) then a[la+1,lb+2]:=true;\n if (la<7)and(lb<8) then a[la+2,lb+1]:=true;\n if (la<8)and(lb>2) then a[la+1,lb-2]:=true;\n if (la<7)and(lb>1) then a[la+2,lb-1]:=true;\n a[ha,hb]:=true;\n if (ha>1)and(hb<7) then a[ha-1,lb+2]:=true;\n if (ha>2)and(hb<8) then a[ha-2,hb+1]:=true;\n if (ha>1)and(hb>2) then a[ha-1,hb-2]:=true;\n if (ha>2)and(hb>1) then a[ha-2,hb-1]:=true;\n if (ha<8)and(hb<7) then a[ha+1,hb+2]:=true;\n if (ha<7)and(hb<8) then a[ha+2,hb+1]:=true;\n if (ha<8)and(hb>2) then a[ha+1,hb-2]:=true;\n if (ha<7)and(hb>1) then a[ha+2,hb-1]:=true;\n\n n:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do if not a[i,j] then n:=n+1;\n writeln(n);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n dx: array[1..8] of longint = (-1, 1, 2, 2, 1, -1, -2, -2);\n dy: array[1..8] of longint = (2, 2, 1, -1, -2, -2, -1, 1);\nvar\n ch1, ch2: char;\n c, k, i1, i2, j1, j2, flag, i, j: longint;\n a: array[-1..10, -1..10] of longint;\nbegin {\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n }\n flag:= 0;\n read(ch1);\n read(ch2);\n i1:= ord(ch1) - ord('a') + 1;\n j1:= strtoint(ch2);\n readln;\n read(ch1);\n read(ch2);\n i2:= ord(ch1) - ord('a') + 1;\n j2:= strtoint(ch2);\n\n for i:= -1 to 10 do begin\n a[0, i]:= 1;\n a[i, 0]:= 1;\n a[9, i]:= 1;\n a[i, 9]:= 1;\n a[-1, i]:= 1;\n a[i, -1]:= 1;\n a[10, i]:= 1;\n a[i, 10]:= 1;\n end;\n\n for i:= 1 to 8 do begin\n for j:= 1 to 8 do begin\n if (i = i1) or (j = j1) then a[i, j]:= 1;\n end;\n end;\n\n a[i2, j2] := 1;\n for i:= 1 to 8 do begin\n a[i2 + dx[i], j2 + dy[i]]:= 1;\n end;\n\n c:= 0;\n for i:= 1 to 8 do begin\n for j:= 1 to 8 do begin\n if a[i, j] = 1 then continue;\n for k:= 1 to 8 do begin\n if ((i + dx[k] = i1) and (j + dy[k] = j1)) or\n ((i + dx[i] = i2) and (j + dy[k] = j2)) then begin\n flag:= 1;\n break;\n end;\n end;\n if flag = 1 then flag:= 0 else inc(c);\n end;\n end;\n\n writeln(c);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\nCuadro[r,c]:='x'; \nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont);\nend.\n\n\n"}, {"source_code": "var\n c:char;\n x1,x2,y1,y2,ans,i,z:longint;\nbegin\n read(c); x1:=ord(c)-96;\n readln(c); y1:=ord(c)-48;\n read(c); x2:=ord(c)-96;\n read(c); y2:=ord(c)-48;\n for i:=1 to 8 do\n for z:=1 to 8 do\n if (z<>x1)and(i<>y1)and(not((z=x2)and(i=y2))) then\n if (not((z=x2-2)and(i=y2-1)))and(not((z=x2-1)and(i=y2-2)))and(not((z=x2+2)and(i=y2+1)))and(not((z=x2+1)and(i=y2+2)))and(not((z=x2-1)and(i=y2+2)))and(not((z=x2+1)and(i=y2-2)))and(not((z=x2+2)and(i=y2-1)))and(not((z=x2-2)and(i=y2+1)))\n then inc(ans);\n writeln(ans-2);\nend."}, {"source_code": "const\nv:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));\nvar\ntabla:array[-2..10,-2..10] of byte;\ni,j,k,n,cor,cor2,cora,corb:longint;\nc,c2:char;\nbegin\n read(c);\n readln(cor);\n read(c2);\n readln(cor2);\n cora:=ord(c)-96;\n corb:=ord(c2)-96;\n tabla[cor,cora]:=1;\n tabla[cor2,corb]:=1;\n for i:=1 to 8 do\n tabla[cor2+v[i,1],corb+v[i,2]]:=1;\n for i:=1 to 8 do\n begin\n tabla[i,cor]:=1;\n tabla[cora,i]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if tabla[i,j]=0 then\n k:=k+1;\n writeln(k-2); \nend.\n"}, {"source_code": "var a: array[1..8,1..8]of longint;\n s1,s2: string;\n x1,y1,x2,y2,i,j,ans: longint;\n\nfunction check(x,y: longint): boolean;\nbegin\n check:=((x>=1) and (x<=8) and (y>=1) and (y<=8));\nend;\n\nprocedure add(x,y: longint);\nbegin\n if check(x,y) then a[x,y]:=1;\nend;\n\nbegin\n fillchar(a,sizeof(a),0);\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n x2:=ord(s2[1])-96;\n y1:=ord(s1[2])-48;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do add(x1,i);\n for i:=1 to 8 do add(i,y1);\n add(x2,y2);\n add(x1-2,y1-1);\n add(x1+2,y1-1);\n add(x1-2,y1+1);\n add(x1+2,y1+2);\n add(x1-1,y1-2);\n add(x1+1,y1-2);\n add(x1-1,y1+2);\n add(x1+1,y1+2);\n add(x2-2,y2-1);\n add(x2+2,y2-1);\n add(x2-2,y2+1);\n add(x2+2,y2+2);\n add(x2-1,y2-2);\n add(x2+1,y2-2);\n add(x2-1,y2+2);\n add(x2+1,y2+2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "var a: array[1..8,1..8]of longint;\n s1,s2: string;\n x1,y1,x2,y2,i,j,ans: longint;\n\nfunction check(x,y: longint): boolean;\nbegin\n check:=((x>=1) and (x<=8) and (y>=1) and (y<=8));\nend;\n\nprocedure add(x,y: longint);\nbegin\n if check(x,y) then a[x,y]:=1;\nend;\n\nbegin\n fillchar(a,sizeof(a),0);\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n x2:=ord(s2[1])-96;\n y1:=ord(s1[2])-48;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do add(x1,i);\n for i:=1 to 8 do add(i,y1);\n add(x2,y2);\n add(x1-2,y1-1);\n add(x1+2,y1-1);\n add(x1-2,y1+1);\n add(x1+2,y1+2);\n add(x1-1,y1-2);\n add(x1+1,y1-2);\n add(x1-1,y1+2);\n add(x1+1,y1+2);\n add(x2-2,y2-1);\n add(x2+2,y2-1);\n add(x2-2,y2+1);\n add(x2+2,y2+2);\n add(x2-1,y2-2);\n add(x2+1,y2-2);\n add(x2-1,y2+2);\n add(x2+1,y2+2);\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i,j]=0) then inc(ans);\n writeln(ans);\nend."}, {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n l,k:string;\n a:array [0..14,0..14] of boolean;\n s,i,j,l1,l2,k1,k2:integer;\n\nprocedure kon(x,y:integer);\nbegin\n a[x+1,y+3]:=true;\n a[x-1,y-3]:=true;\n a[x+1,y-3]:=true;\n a[x-1,y+3]:=true;\n a[x+3,y+1]:=true;\n a[x-3,y-1]:=true;\n a[x+3,y-1]:=true;\n a[x-3,y+1]:=true;\nend;\n\n\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(l);\n read(k);\n l1:=ord(l[1])-ord('a')+3;\n l2:=ord(l[2])-ord('1')+3;\n k1:=ord(k[1])-ord('a')+3;\n k2:=ord(k[2])-ord('1')+3;\n for i:=3 to 10 do a[l1,i]:=true;\n for i:=3 to 10 do a[i,l2]:=true;\n kon(l1,l2);\n kon(k1,k2);\n a[k1,k2]:=true;\n s:=0;\n for i:=3 to 10 do\n for j:=3 to 10 do\n if not a[i,j] then inc(s);\n\n write(s);\n\nend.\n"}, {"source_code": "var\n c:char;\n x1,x2,y1,y2,ans,i,z:longint;\nbegin\n read(c); x1:=ord(c)-96;\n readln(c); y1:=ord(c)-48;\n read(c); x2:=ord(c)-96;\n read(c); y2:=ord(c)-48;\n for i:=1 to 8 do\n for z:=1 to 8 do\n if (z<>x1)and(i<>y1)and(not((z=x2)and(i=y2))) then\n if (not((z=x2-2)and(i=y2-1)))and(not((z=x2-1)and(i=y2-2)))and(not((z=x2+2)and(i=y2+1)))and(not((z=x2+1)and(i=y2+2)))and(not((z=x2-1)and(i=y2+2)))and(not((z=x2+1)and(i=y2-2)))and(not((z=x2+2)and(i=y2-1)))and(not((z=x2-2)and(i=y2+1)))\n then inc(ans);\n writeln(ans-2);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n dx: array[1..8] of longint = (-1, 1, 2, 2, 1, -1, -2, -2);\n dy: array[1..8] of longint = (2, 2, 1, -1, -2, -2, -1, 1);\nvar\n ch1, ch2: char;\n c, k, i1, i2, j1, j2, flag, i, j: longint;\n a: array[-1..10, -1..10] of longint;\nbegin {\n reset(input,'input.txt');\n rewrite(output,'output.txt');\n }\n flag:= 0;\n read(ch1);\n read(ch2);\n i1:= ord(ch1) - ord('a') + 1;\n j1:= strtoint(ch2);\n readln;\n read(ch1);\n read(ch2);\n i2:= ord(ch1) - ord('a') + 1;\n j2:= strtoint(ch2);\n\n for i:= -1 to 10 do begin\n a[0, i]:= 1;\n a[i, 0]:= 1;\n a[9, i]:= 1;\n a[i, 9]:= 1;\n a[-1, i]:= 1;\n a[i, -1]:= 1;\n a[10, i]:= 1;\n a[i, 10]:= 1;\n end;\n\n for i:= 1 to 8 do begin\n for j:= 1 to 8 do begin\n if (i = i1) or (j = j1) then a[i, j]:= 1;\n end;\n end;\n\n a[i2, j2] := 1;\n for i:= 1 to 8 do begin\n a[i2 + dx[i], j2 + dy[i]]:= 1;\n end;\n\n c:= 0;\n for i:= 1 to 8 do begin\n for j:= 1 to 8 do begin\n if a[i, j] = 1 then continue;\n for k:= 1 to 8 do begin\n if ((i + dx[k] = i1) and (j + dy[k] = j1)) or\n ((i + dx[i] = i2) and (j + dy[k] = j2)) then begin\n flag:= 1;\n break;\n end;\n end;\n if flag = 1 then flag:= 0 else inc(c);\n end;\n end;\n\n writeln(c);\nend.\n"}, {"source_code": "var\n a:array [-10..80,-10..80] of longint;\n i,j,n,m,k,x1,y1,x2,y2,ans:longint;\n s1,s2,s,ss:string;\n\n procedure print;\n var\n i,j:longint;\n begin\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n write(a[i,j]);\n writeln\n end;\n end;\n\n\n procedure d1 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1; j:=y1;\n while (i<>-1)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n dec(i);\n dec(j);\n end;\n i:=x1; j:=y1;\n while (i<>-1)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[j,i]:=1;\n dec(i);\n inc(j);\n end;\n print;\n end;\n\n\n\n procedure d2 (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1+1; j:=y1+1;\n while (i<>10)and(j<>10) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n inc(j);\n\n end;\n i:=x1+1; j:=y1-1;\n while (i<>10)and(j<>-1) do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n inc(i);\n dec(j);\n\n end;\n print\n end;\n\n\n\n procedure g (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=y1;\n for j:=1 to 8 do\n begin\n if a[i,j]=-1 then break;\n a[i,j]:=1;\n end;\n print\n end;\n\n\n procedure v (x1,y1:longint);\n var\n i,j:longint;\n begin\n i:=x1;\n for j:=1 to 8 do\n begin\n if a[j,i]=-1 then break;\n a[j,i]:=1;\n end;\n print\n end;\n\n procedure kon(x2,y2:longint);\n var\n i,j:longint;\n begin\n i:=x2; j:=y2;\n a[i+2,j+1]:=1;\n a[i+2,j-1]:=1;\n a[i-2,j+1]:=1;\n a[i-2,j-1]:=1;\n a[i+1,j+2]:=1;\n a[i-1,j+2]:=1;\n a[i+1,j-2]:=1;\n a[i-1,j-2]:=1;\n print\n end;\n\nbegin\n readln(s1);\n readln(s2);\n s:='abcdefgh';\n ss:='12345678';\n x1:=pos(s1[1],s);\n x2:=pos(s2[1],s);\n y1:=pos(s1[2],ss);\n y2:=pos(s2[2],ss);\n a[x2,y2]:=1;\n //d1(x1,y1);\n// d2(x1,y1);\n g(x1,y1);\n v(x1,y1);\n kon(x2,y2);\n kon(y1,x1);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]<>1 then inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "const finp='';\n fout='';\nvar a:array [-1..10,-1..10] of integer;\n r,k:string;\n dem,r1,r2,k1,k2:longint;\nprocedure nhap;\nvar f:text;\n x,y:longint;\nbegin\n assign(f,finp);\n reset(f);\n for x:=1 to 8 do\n for y:=1 to 8 do\n a[x,y]:=0;\n readln(f,r);\n readln(f,k);\n x:=ord(r[1])-96;\n y:=ord(r[2])-48;\n r1:=x; r2:=y;\n a[x,y]:=1;\n x:=ord(k[1])-96;\n y:=ord(k[2])-48;\n k1:=x; k2:=y;\n a[x,y]:=1;\n close(f);\nend;\n{--------------}\nprocedure rook;\nvar x,y:longint;\nbegin\n for y:=1 to 8 do\n a[r1,y]:=1;\n for x:=1 to 8 do\n a[x,r2]:=1;\nend;\n{--------------}\nprocedure knight;\nbegin\n a[k1+1,k2+2]:=1;\n a[k1+1,k2-2]:=1;\n a[k1+2,k2+1]:=1;\n a[k1+2,k2-1]:=1;\n a[k1-1,k2+2]:=1;\n a[k1-1,k2-2]:=1;\n a[k1-2,k2+1]:=1;\n a[k1-2,k2-1]:=1;\nend;\n{--------------}\nprocedure xuli;\nvar x,y:longint;\nbegin\n rook;\n knight;\n for x:=1 to 8 do\n for y:=1 to 8 do\n if a[x,y]=0 then inc(dem);\nend;\n{--------------}\nprocedure xuat;\nvar g:text;\nbegin\n assign(g,fout);\n rewrite(g);\n write(g,dem-2);\n close(g);\nend;\n{--------------}\nbegin\n nhap;\n xuli;\n xuat;\nend.\n\n\n\n"}, {"source_code": "var x,y,x3,y3,kol,x1,x2,y1,y2:longint;\n a:array[0..9,0..9] of longint;\n pp1,pp2:boolean;\n s1,s2:string;\nbegin\nreadln(s1);\nreadln(s2);\nx1:=ord(s1[2])-ord('1')+1;\ny1:=ord(s1[1])-ord('a')+1;\nx2:=ord(s2[2])-ord('1')+1;\ny2:=ord(s2[1])-ord('a')+1;\nkol:=0;\nfor x3:= 1 to 8 do\nfor y3:= 1 to 8 do\nbegin\nif (x1=x3) and (y1=y3) then continue;\nif (y2=y3) and (x2=x3) then continue;\npp1:=(x1=x3) or (Y1=y3);\nif pp1 then continue;\npp2:=((abs(x2-x3)=2) and (abs(y2-y3)=1)) or\n ((abs(x2-x3)=1) and (abs(y2-y3)=2));\nif pp2 then continue;\ninc(kol);\nend;\nwriteln(kol-2);\nend.\n\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n marked : array [1..12, 1..12] of boolean;\n hx, hy, lx, ly : integer;\n probs : integer;\n position1, position2 : string;\n c : char;\n i, j : integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(position1);\n c := position1[1];\n lx := ord(c) - 96;\n c := position1[2];\n ly := ord(c) - 48;\n readln(position2);\n c := position2[1];\n hx := ord(c) - 96;\n c := position2[2];\n hy := ord(c) - 48;\n for i := 1 to 12 do\n for j := 1 to 12 do\n marked[i,j] := false;\n marked[2 + lx,2 + ly] := true;\n marked[2 + hx,2 + hy] := true;\n for i := 1 to 12 do\n begin\n marked[lx + 2, i] := true;\n marked[i, ly + 2] := true;\n end;\n marked[2 + hx + 2,2 + hy - 1] := true;\n marked[2 + hx - 1,2 + hy - 2] := true;\n marked[2 + hx - 2,2 + hy + 1] := true;\n marked[2 + hx + 1,2 + hy + 2] := true;\n\n marked[2 + hx + 2,2 + hy + 1] := true;\n marked[2 + hx + 1,2 + hy - 2] := true;\n marked[2 + hx - 2,2 + hy - 1] := true;\n marked[2 + hx - 1,2 + hy + 2] := true;\n probs := 0;\n for i:=3 to 10 do\n for j := 3 to 10 do\n if not(marked[i,j]) then inc(probs);\n probs := probs - 2;\n writeln(probs);\nend.\n"}, {"source_code": "const\n n = 8;\nvar\n m : array [1..8,1..8] of boolean;\n x1,y1,x2,y2,i,j,kol : longint;\n s1,s2 : string;\nprocedure put(x,y : longint);\nbegin\n if (x>0) and (x<9)\n and(y>0) and (y<9)\n then\n m[x,y]:=true;\nend;\n\nbegin\n readln(s1);\n readln(s2);\n x1:=ord(s1[1])-ord('a')+1;\n y1:=ord(s1[2])-ord('0');\n x2:=ord(s2[1])-ord('a')+1;\n y2:=ord(s2[2])-ord('0');\n for i:=1 to n do\n for j:=1 to n do\n m[i,j]:=false;\n put(x1,y1);\n put(x1+2,y1+1);\n put(x1+1,y1+2);\n put(x1-1,y1+2);\n put(x1-2,y1+1);\n put(x1+2,y1-1);\n put(x1+1,y1-2);\n put(x1-1,y1-2);\n put(x1-2,y1-1);\n put(x2+2,y2+1);\n put(x2+1,y2+2);\n put(x2-1,y2+2);\n put(x2-2,y2+1);\n put(x2+2,y2-1);\n put(x2+1,y2-2);\n put(x2-1,y2-2);\n put(x2-2,y2-1);\n for i:=1 to 8 do\n begin\n put(x2,i);\n put(i,y2);\n end;\n kol:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if m[i,j]=false then inc(kol);\n writeln(kol);\nend."}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\na:=0;\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-1,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\n\nwrite (a);\n\nend."}, {"source_code": "var\n s,s2 : string;\n a,b,c,d,kode,baris,kolom,jum : longint;\n mat : array[-2..10,-2..10] of longint;\nbegin\n readln(s);\n readln(s2);\n s[1] := chr(ord(s[1])-48);\n s2[1] := chr(ord(s2[1])-48);\n val(s[1],b,kode);\n val(s[2],a,kode);\n val(s2[1],d,kode);\n val(s2[2],c,kode);\n writeln(a,b,c,d);\n mat[a,b] := 1;\n mat[c,d] := 1;\n for baris := 1 to 8 do begin\n for kolom := 1 to 8 do begin\n if (baris = a) or (kolom = b) then mat[baris,kolom] := 1;\n end;\n end;\n\n mat[c-2,d-1] := 1;\n mat[c-2,d+1] := 1;\n mat[c+2,d+1] := 1;\n mat[c+2,d-1] := 1;\n mat[c-1,d+2] := 1;\n mat[c-1,d-2] := 1;\n mat[c+1,d+2] := 1;\n mat[c+1,d-2] := 1;\n mat[a-2,b-1] := 1;\n mat[a-2,b+1] := 1;\n mat[a+2,b+1] := 1;\n mat[a+2,b-1] := 1;\n mat[a-1,b+2] := 1;\n mat[a-1,b-2] := 1;\n mat[a+1,b+2] := 1;\n mat[a+1,b-2] := 1;\n for baris := 1 to 8 do begin\n for kolom := 1 to 8 do begin\n if mat[baris,kolom] = 0 then inc(jum);\n end;\n end;\n\n writeln(jum);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, i, j, x, y, a, b, ans: integer;\n s:string;\n d: array [1 .. 8, 1 .. 8] of boolean;\n dx: array [1 .. 8] of integer = (1, 1, 2, 2, -1, -1, -2, -2);\n dy: array [1 .. 8] of integer = (2, -2, 1, -1, 2, -1, 1, -1);\nfunction check(x1, y1: integer): boolean;\nbegin\n check := not((x1 > 8) or (y1 > 8) or (y1 < 1) or (x1 < 1));\nend;\nbegin\n n := 8;\n readln(s);\n x := ord(s[1]) - ord('a') + 1;\n y := ord(s[2]) - ord('0');\n readln(s);\n a := ord(s[1]) - ord('a') + 1;\n b := ord(s[2]) - ord('0');\n for i := 1 to n do\n for j := 1 to n do\n d[i, j] := true;\n for i := 1 to 8 do\n begin\n if (check(a + dx[i], b + dy[i])) then\n d[a + dx[i], b + dy[i]] := false;\n if (check(x + dx[i], y + dy[i])) then\n d[x + dx[i], y + dy[i]] := false;\n d[x, i] := false;\n d[i, y] := false;\n end;\n d[a, b] := false;\n d[x, y] := false;\n ans := 0;\n for i := 1 to n do\n for j := 1 to n do\n if d[i, j] then\n inc(ans);\n writeln(ans);\nend.\n"}, {"source_code": "var s:string; i,j,x1,y1,x2,y2,c:longint;\nbegin\nreadln(s);\nx1:=ord(s[1])-ord('a')+1;\ny1:=ord(s[2])-48;\nreadln(s);\nx2:=ord(s[1])-ord('a')+1;\ny2:=ord(s[2])-48;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (i=x1) or (j=y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) or ((abs(i-x1)=2) and (abs(j-y1)=1)) or ((abs(i-x1)=1) and (abs(j-y1)=2)) and (i=x1) and (i=x2) and (j=y1) and (j=y2) then else inc(c);\nwriteln(c);\nend."}, {"source_code": "var\na:array [1..8,1..8] of boolean;\nc,code,d1,d,i,j,y1,y2,x1,x2:longint;\nq,w,e,r:char;\nbegin\n c:=0;\n readln(q,w);\n read(e,r);\n x1:=ord(q)-96;\n x2:=ord(e)-96;\n val(w,y1,code);\n val(r,y2,code);\n a[x1,y1]:=true;\n a[x2,y2]:=true;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n d:=abs((i-x1)*(j-y1));\n d1:=abs((i-x2)*(j-y2));\n if (d=2)or(d1=2)or(x1=i)or(x2=j) then a[i,j]:=true;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=false then inc(c);\n write(c+1);\nend.\n"}, {"source_code": "var s:string; a:Array[-1..10,-1..10] of byte; i,j,x,y,c:longint;\nbegin\nfillchar(A,sizeof(a),0);\nreadln(s);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-48;\nfor i:=1 to 8 do begin\n a[i][y]:=1;\n a[x][i]:=1;\nend;\nreadln(s);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-48;\na[x-2][y-1]:=1;\na[x-2][y+1]:=1;\na[x-1][y-2]:=1;\na[x-1][y+2]:=1;\na[x+2][y-1]:=1;\na[x+2][y+1]:=1;\na[x+1][y-2]:=1;\na[x+1][y+2]:=1;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (a[i][j]=1) and (a[i-2][j-1]=0) and (a[i-2][j+1]=0) and (a[i-1][j-2]=0) and (a[i-1][j+2]=0) and (a[i+2][j-1]=0) and (a[i+2][j+1]=0) and (a[i+1][j-2]=0) and (a[i+1][j+2]=0) then inc(c);\nwriteln(c);\nend."}, {"source_code": "const\nv:array[1..8,1..2] of integer=((-2,-1),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2));\nvar\narr:array[-2..10,-2..10] of boolean;\ni,j,n,p:longint;\ncar:char;\nbegin\n read (car);\n readln(n);\n for i:=1 to 8 do\n arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;\n for i:=1 to 8 do\n arr[i,(ord(car)-96)]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-96),i]:=true;\n read (car);\n readln (n);\n arr[(ord(car)-96),n]:=true;\n for i:=1 to 8 do\n arr[(ord(car)-96+v[i,1]),(n+v[i,2])]:=true;\n p:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if not arr[i,j] then\n inc (p);\n writeln (p);\nend.\n"}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont-1);\nend.\n\n"}, {"source_code": "const\nv:array[1..8,1..2] of longint=((1,2),(2,1),(-1,2),(-1,-2),(-2,1),(-2,-1),(2,-1),(1,-2));\n\nVar\nCuadro:array[-4..12,-4..12] of char;\nren,col:char;\nr,c,num1,num2,aux,cont:integer;\n\nbegin\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\n//1,2\nFor num1:=1 to 8 do\n begin\n Cuadro[num1,c]:='x';\n Cuadro[c,num1]:='x';\n end;\nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n\n//tORRE lista\n\nReadln(ren,col);\nr:=ord(ren)-96;\nc:=ord(col)-48;\nCuadro[r,c]:='x'; \nFor num1:=1 to 8 do\n begin\n Cuadro[r+v[num1,1],c+v[num1,2]]:='x';\n end;\n//caballo listo\ncont:=0;\nFor num1:=1 to 8 do\n For num2:=1 to 8 do\n begin\n If Cuadro[num1,num2]<>'x' then\n cont:=cont+1;\n end;\n\nWriteln(cont);\nend.\n\n\n"}, {"source_code": "var x1,x2,y1,y2,i,j,k:longint;\n q:string;\n a:array[-5..15,-5..15] of longint;\n p:integer;\nfunction tt:boolean;\nvar q1,q2,q3:boolean;\n i,j:longint;\n begin\n q1:=true;\n q2:=true;\n q3:=true;\n for i:=1 to 8 do\n begin\n if a[i,y1]>1 then q1:=false;\n if a[x1,i]>1 then q1:=false;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n begin\n if a[i,j]=2 then begin\n if a[i-2,j-1] in [1,3] then q2:=false;\n if a[i-2,j+1] in [1,3] then q2:=false;\n if a[i+2,j-1] in [1,3] then q2:=false;\n if a[i+2,j+1] in [1,3] then q2:=false;\n if a[i-1,j-2] in [1,3] then q2:=false;\n if a[i-1,j+2] in [1,3] then q2:=false;\n if a[i+1,j-2] in [1,3] then q2:=false;\n if a[i+1,j+2] in [1,3] then q2:=false;\n end;\n if a[i,j]=3 then begin\n if a[i-2,j-1] in [1,2] then q3:=false;\n if a[i-2,j+1] in [1,2] then q3:=false;\n if a[i+2,j-1] in [1,2] then q3:=false;\n if a[i+2,j+1] in [1,2] then q3:=false;\n if a[i-1,j-2] in [1,2] then q3:=false;\n if a[i-1,j+2] in [1,2] then q3:=false;\n if a[i+1,j-2] in [1,2] then q3:=false;\n if a[i+1,j+2] in [1,2] then q3:=false;\n end;\n end;\n if q1 and q2 and q3 then tt:=true\n else tt:=false;\n end;\n begin\n readln(q);\n x1:=ord(q[1])-96;\n val(q[2],y1,p);\n readln(q);\n x2:=ord(q[1])-96;\n val(q[2],y2,p);\n k:=0;\n fillchar(a,sizeof(a),0);\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then begin\n fillchar(a,sizeof(a),0);\n a[x1,y1]:=1;\n a[x2,y2]:=2;\n a[i,j]:=3;\n if tt then k:=k+1;\n end;\n writeln(k);\n end."}, {"source_code": "var i,j,m,n,k:longint; c:char;\na:array[-2..10,-2..10] of byte;\naa:array['a'..'h'] of byte;\nbegin\nn:=0;\nfor c:='a' to 'h' do\n begin\n inc(n);\naa[c]:=n;\nend;\nn:=0;\nreadln(c,m);\nn:=aa[c];\nfillchar(a,sizeof(a),1);\nfor i:=1 to 8 do\nbegin\n a[n,i]:=0;\n a[i,m]:=0;\nend;\na[n,m]:=2;\nread(c,m);\nn:=aa[c];\na[n,m]:=2;\na[n-1,m+2]:=0;\na[n-1,m-2]:=0;\na[n+1,m+2]:=0;\na[n+1,m-2]:=0;\na[n+2,m-1]:=0;\na[n+2,m+1]:=0;\na[n-2,m+1]:=0;\na[n-2,m-1]:=0;\nfor i:=1 to 8 do\nbegin\n for j:=1 to 8 do\nwrite(a[i,j]);\nwriteln;\nend;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=1 then\nif (a[i-1,j+2]<>2) and\n(a[i-1,j-2]<>2) and\n(a[i+1,j+2]<>2) and\n(a[i+1,j-2]<>2) and\n(a[i+2,j-1]<>2) and\n(a[i+2,j+1]<>2) and\n(a[i-2,j+1]<>2) and\n(a[i-2,j-1]<>2) then inc(k);\nwrite(k);\nend."}, {"source_code": "var p:array [-1..10,-1..10]of byte;\ns,k:string; i,x,y,a,n,xx,yy:integer;\nbegin\na:=0;\nreadln (s);\nreadln (k);\nx:=ord(s[1])-ord('a')+1;\ny:=ord(s[2])-ord('1')+1;\nxx:=ord(k[1])-ord('a')+1;\nyy:=ord(k[2])-ord('1')+1;\nfor i:=1 to 8 do begin p[x,i]:=1; p[i,y]:=1; end;\np[x+2,y+1]:=1; p[x+2,y-1]:=1; p[x+1,y+2]:=1;\np[x+1,y-2]:=1; p[x-1,y-2]:=1; p[x-1,y+2]:=1;\np[x-2,y+1]:=1; p[x-1,y-1]:=1;\np[xx+2,yy+1]:=1; p[xx+2,yy-1]:=1; p[xx+1,yy+2]:=1;\np[xx+1,yy-2]:=1; p[xx-1,yy-2]:=1; p[xx-1,yy+2]:=1;\np[xx-2,yy+1]:=1; p[xx-2,yy-1]:=1; p[xx,yy]:=1;\nfor i:=1 to 8 do for n:=1 to 8 do if p[i,n]=0 then inc(a);\n\nwrite (a);\n\nend."}, {"source_code": "var s:string; i,j,x1,y1,x2,y2,c:longint;\nbegin\nreadln(s);\nx1:=ord(s[1])-ord('a')+1;\ny1:=ord(s[2])-48;\nreadln(s);\nx2:=ord(s[1])-ord('a')+1;\ny2:=ord(s[2])-48;\nc:=0;\nfor i:=1 to 8 do\n for j:=1 to 8 do\n if (i=x1) or (j<>y1) or ((abs(i-x2)=2) and (abs(j-y2)=1)) or ((abs(i-x2)=1) and (abs(j-y2)=2)) then else inc(c);\nwriteln(c);\nend."}, {"source_code": "const fi = '';\n fo = '';\n f: array['a'..'h'] of longint = (1,2,3,4,5,6,7,8);\nvar a: array[-1..10,-1..10] of boolean;\n x1, x2: char;\n s: string;\n y1, y2, i, j, ans, e: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n fillchar(a,sizeof(a),true);\n readln(x1,s);\n val(s,y1,e);\n readln(x2,s);\n val(s,y2,e);\n a[f[x1],y1]:=false;\n for i:=1 to 8 do\n begin\n a[f[x1],i]:=false;\n a[i,y1]:=false;\n end;\n\n a[f[x2],y2]:=false;\n a[f[x2]-2,y2-1]:=false;\n a[f[x2]-2,y2+1]:=false;\n a[f[x2]-1,y2-2]:=false;\n a[f[x2]-1,y2+2]:=false;\n a[f[x2]+1,y2-2]:=false;\n a[f[x2]+1,y2+2]:=false;\n a[f[x2]+2,y2-1]:=false;\n a[f[x2]+2,y2+1]:=false;\n\n ans:=0;\n for i:=1 to 8 do\n for j:=1 to 8 do if a[i,j] then inc(ans);\n writeln(ans-2);\n\n {for i:=1 to 8 do\n begin\n for j:=1 to 8 do if a[i,j] then write('T ')\n else write('F ');\n writeln;\n end; }\n\n close(input); close(output);\nend.\n"}, {"source_code": "const\n steps : array [1..8,1..2] of longint = ((1,2),(2,1),(-1,2),(2,-1),\n (-1,-2),(-2,-1),(1,-2),(-2,1));\nvar\n s1,s2 : string;\n x1,y1,x2,y2,i,j,ans : longint;\n mark : array [-8..16,-8..16] of boolean;\nbegin\n {assign(input,'input.txt'); reset(input);\n assign(output,'output.txt'); rewrite(output);\n }readln(s1);\n readln(s2);\n x1:=ord(s1[1])-96;\n y1:=ord(s1[2])-48;\n x2:=ord(s2[1])-96;\n y2:=ord(s2[2])-48;\n for i:=1 to 8 do\n begin\n mark[i,x1]:=true;\n mark[y1,i]:=true;\n end;\n for i:=1 to 8 do\n begin\n mark[x1+steps[i,1],y1+steps[i,2]]:=true;\n mark[x2+steps[i,1],y2+steps[i,2]]:=true;\n end;\n ans:=0; \n for i:=1 to 8 do\n for j:=1 to 8 do\n if not mark[i,j] then inc(ans);\n writeln(ans-1); \n close(input); close(output);\nend.\n"}, {"source_code": "program BBBBB;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a : array[-10..10, -10..10] of integer;\n s1, s2 : string;\n x1, x2, y1, y2, i, j, k : integer;\nbegin\n readln(s1);\n readln(s2);\n y1 := ord(s1[2]) - ord('0');\n y2 := ord(s2[2]) - ord('0');\n if s1[1] = 'a' then x1 := 1;\n if s1[1] = 'b' then x1 := 2;\n if s1[1] = 'c' then x1 := 3;\n if s1[1] = 'd' then x1 := 4;\n if s1[1] = 'e' then x1 := 5;\n if s1[1] = 'f' then x1 := 6;\n if s1[1] = 'g' then x1 := 7;\n if s1[1] = 'h' then x1 := 8;\n if s2[1] = 'a' then x2 := 1;\n if s2[1] = 'b' then x2 := 2;\n if s2[1] = 'c' then x2 := 3;\n if s2[1] = 'd' then x2 := 4;\n if s2[1] = 'e' then x2 := 5;\n if s2[1] = 'f' then x2 := 6;\n if s2[1] = 'g' then x2 := 7;\n if s2[1] = 'h' then x2 := 8;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n a[i, j] := 0;\n end;\n end;\n for i := x1 to 8 do begin\n a[i, y1] := 1;\n end;\n for i := x1 downto 1 do begin\n a[i, y1] := 1;\n end;\n for i := y1 to 8 do begin\n a[x1, i] := 1;\n end;\n for i := y1 downto 1 do begin\n a[x1, i] := 1;\n end;\n a[x2 + 2][y2 + 1] := 1;\n a[x2 + 2][y2 - 1] := 1;\n a[x2 + 1][y2 + 2] := 1;\n a[x2 + 1][y2 - 2] := 1;\n a[x2 - 1][y2 + 2] := 1;\n a[x2 - 1][y2 - 2] := 1;\n a[x2 - 2][y2 + 1] := 1;\n a[x2 - 2][y2 - 1] := 1;\n a[x2, y2] := 1;\n k := 0;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n write(a[i, j], ' ');\n end;\n writeln;\n end;\n for i := 1 to 8 do begin\n for j := 1 to 8 do begin\n if a[i, j] = 0 then inc(k);\n end;\n end;\n writeln(k - 2);\nend.\n"}, {"source_code": "var s,s1,s2:string;\n c1,c2,ch1,ch2,p1,p2,i,kol,j:longint;\n a:array [-100..100,-10..100] of longint;\nconst bx:array [1..8] of integer=(-1,1,2,2,1,-1,-2,-2);\n by:array [1..8] of integer=(2,2,1,-1,-2,-2,-1,1);\nbegin\n s1:='ABCDFGHI';\n s2:='12345678';\n readln(s);\n for i:=1 to 8 do\n begin\n if s[1]=s1[i] then ch1:=i;\n if s[2]=s2[i] then ch2:=i;\n end;\n readln(s);\n for i:=1 to 8 do\n begin\n if s[1]=s1[i] then c1:=i;\n if s[2]=s2[i] then c2:=i;\n end;\n\n p1:=ch1;p2:=ch2;\n while (p1>=1) do\n begin\n a[p1,p2]:=-1; dec(p1);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p1<=8) do\n begin\n a[p1,p2]:=-1;\n inc(p1);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p2<=8) do\n begin\n a[p1,p2]:=-1;\n inc(p2);\n end;\n\n p1:=ch1;p2:=ch2;\n while (p2>=1) do\n begin\n a[p1,p2]:=-1;\n dec(p2);\n end;\n\n for i:=1 to 8 do\n begin\n a[ch1+bx[i],ch2+by[i]]:=-1;\n a[c1+bx[i],c2+by[i]]:=-1;\n end;\n\n for i:=1 to 8 do\n for j:=1 to 8 do\n if a[i,j]=0 then inc(kol);\n writeln(kol-1);\n for i:=1 to 8 do\n for j:=1 to 8 do\nend."}, {"source_code": "const\nv:array[1..8,1..2]of integer=((-1,-2),(-2,1),(-1,2),(1,2),(2,1),(2,-1),(-2,1),(-2,-1));\nvar\ntabla:array[-2..10,-2..10] of byte;\ni,j,k,n,cor,cor2,cora,corb:longint;\nc,c2:char;\nbegin\n read(c);\n readln(cor);\n read(c2);\n readln(cor2);\n cora:=ord(c)-96;\n corb:=ord(c2)-96;\n tabla[cora,cor]:=1;\n tabla[corb,cor2]:=1;\n for i:=1 to 8 do\n tabla[corb+v[i,1],cor2+v[i,2]]:=1;\n for i:=1 to 8 do\n begin\n tabla[i,cor]:=1;\n tabla[cora,i]:=1;\n end;\n for i:=1 to 8 do\n for j:=1 to 8 do\n if tabla[i,j]=0 then\n k:=k+1;\n writeln(k-2);\nend.\n"}, {"source_code": "var\n a:array [0..8,0..8] of byte;\n data,i,j,k,y2,y1,x2,x1:byte;\n cl,ck:string;\nbegin\nreadln (cl);\nreadln (ck);\nx1:=ord(cl[1])-96;\nval(cl[2],y1,data);\nx2:=ord(ck[1])-96;\nval(ck[2],y2,data);\nwriteln (x1,' ',y1,' ',x2,' ',y2);\nfor i:=1 to 8 do\n for j:=1 to 8 do\n a[i,j]:=0;\na[x1,y1]:=1;\na[x2,y2]:=1;\nfor i:=1 to 8 do\n a[i,y1]:=1;\nfor i:=1 to 8 do\n a[x1,i]:=1;\nif (x2+2<9) and (y2-1>0) then\n a[x2+2,y2-1]:=1;\nif (x2+2<9) and (y2+1<9) then\n a[x2+2,y2+1]:=1;\nif (x2+1<9) and (y2+2<9) then\n a[x2+1,y2+2]:=1;\nif (x2-1>0) and (y2+2<9) then\n a[x2-1,y2+2]:=1;\nif (x2-2>0) and (y2+1<9) then\n a[x2-2,y2+1]:=1;\nif (x2-2>0) and (y2-1>0) then\n a[x2-2,y2-1]:=1;\nif (x2-1>0) and (y2-2>0) then\n a[x2-1,y2-2]:=1;\nif (x2+1<9) and (y2-2>0) then\n a[x2+1,y2-2]:=1;\nif (x1+2<9) and (y1-1>0) then\n a[x1+2,y1-1]:=1;\nif (x1+2<9) and (y1+1<9) then\n a[x1+2,y1+1]:=1;\nif (x1+1<9) and (y1+2<9) then\n a[x1+1,y1+2]:=1;\nif (x1-1>0) and (y1+2<9) then\n a[x1-1,y1+2]:=1;\nif (x1-2>0) and (y1+1<9) then\n a[x1-2,y1+1]:=1;\nif (x1-2>0) and (y1-1>0) then\n a[x1-2,y1-1]:=1;\nif (x1-1>0) and (y1-2>0) then\n a[x1-1,y1-2]:=1;\nif (x1+1<9) and (y1-2>0) then\n a[x1+1,y1-2]:=1;\nfor i:=1 to 8 do\nbegin\n for j:=1 to 8 do\n begin\n write (a[i,j],' ');\n if a[i,j]=0 then inc(k);\n end;\n writeln;\nend;\nwriteln (k);\nreadln;\nend.\n"}, {"source_code": "const\n sy:array[1..8]of shortint=(-2,-2,-1,1,2,2,1,-1);\n sx:array[1..8]of shortint=(-1,1,2,2,1,-1,-2,-2);\nvar\n s:string;\n f:array[1..8,1..8]of boolean;\n i,j,x,y,x1,y1,k:longint;\nbegin\n readln(s);\n fillchar(f,sizeof(f),false);\n x:=ord(s[1])-96;\n y:=ord(s[2])-48;\n readln(s);\n x1:=ord(s[1])-96;\n y1:=ord(s[2])-48;\n k:=0;\n f[x1,y1]:=true;\n for i:=x to 8 do f[i,y]:=true;\n for i:=x downto 1 do f[i,y]:=true;\n for i:=y to 8 do f[x,i]:=true;\n for i:=y downto 1 do f[x,i]:=true;\n for i:=1 to 8 do\n begin\n if(sy[i]+y>1)and(sy[i]+y<9)and(sx[i]+x>1)and(sx[i]+x<9)then f[sy[i]+y,sx[i]+x]:=true;\n if(sy[i]+y1>1)and(sy[i]+y1<9)and(sx[i]+x1>1)and(sx[i]+x1<9)then f[sy[i]+y1,sx[i]+x1]:=true;\n end;\n for i:=1to 8 do for j:=1 to 8 do if not f[i,j]then inc(k);\n writeln(k);\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar l,k:string; i,j,m,n,y:integer; a:array[1..8,1..8]of integer;\nbegin\nreadln(l);\nreadln(k);\ncopy(l,1,1);\ncopy(k,1,1);\ncase l[1] of\n'a':\nm:=1;\n'b':\nm:=2;\n'c':\nm:=3;\n'd':\nm:=4;\n'e':\nm:=5;\n'f':\nm:=6;\n'g':\nm:=7;\n'h':\nm:=8;\nend;\ncase k[1] of\n'a':\nn:=1;\n'b':\nn:=2;\n'c':\nn:=3;\n'd':\nn:=4;\n'e':\nn:=5;\n'f':\nn:=6;\n'g':\nn:=7;\n'h':\nn:=8;\nend;\nfor j:=1 to 8 do\nbegin\na[m,j]:=1;\na[j,strtoint (l[2])]:=1;\na[n-1,(strtoint (copy(k,2,1))-2)]:=1;\na[n-1,(strtoint(copy(k,2,1))+2)]:=1;\na[n+1,(strtoint(copy(k,2,1))-2)]:=1;\na[n+1,(strtoint(copy(k,2,1))+2)]:=1;\na[n-2,(strtoint(copy(k,2,1))-1)]:=1;\na[n-2,(strtoint(copy(k,2,1))+1)]:=1;\na[n+2,(strtoint(copy(k,2,1))-1)]:=1;\na[n+2,(strtoint(copy(k,2,1))+1)]:=1;\nend;\nfor i:=1 to 8 do\nfor j:=1 to 8 do\n\nif a[i,j]<>1 then\ny:=y+1;\nwriteln(y-3);\nreadln;\nend.\n"}], "src_uid": "073023c6b72ce923df2afd6130719cfc"} {"source_code": "var n,p,i,j:longint;\nbegin\nread(n);\ni:=0;\nj:=0;\nwhile(j=n) then break;\n\n end;\n if res>n then writeln(0) else begin\n writeln(5);\n for l:=0 to 3 do write(i+l,' ');\n Writeln(i+4);\n\n End;\n End."}, {"source_code": "const fi = '';\n fo = '';\nvar i, j, a, m, so, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n so:=0; m:=0;\n readln(n);\n for i:=1 to n do\n begin\n m:=m+5;\n a:=i*5;\n while (a mod 5 = 0) and (a > 0) do\n begin\n inc(so);\n a:=a div 5;\n end;\n if so >= n then break\n end;\n if so = n then\n begin\n writeln(5);\n writeln(m,' ',m+1,' ',m+2,' ',m+3,' ',m+4);\n end\n else write(0);\n\n close(input); close(output);\nend.\n"}, {"source_code": "Const Finp='';\n Fout='';\nVar n,k:longint;\n\nProcedure Nhap;\nVar f:Text;\n i:longint;\nBegin\n assign(f,finp); reset(f);\n read(f,n);\n close(f);\nEnd;\nProcedure Solve;\nVar i,d,temp:longint;\nBegin\n d:=0; i:=5; k:=0;\n Repeat\n if i mod 5=0 then\n begin\n temp:=i;\n while temp mod 5=0 do\n begin\n inc(d);\n temp:=temp div 5;\n end;\n if d>n then\n begin\n k:=-1;\n break;\n end;\n if d=n then\n begin\n k:=i;\n break;\n end;\n end;\n inc(i);\n Until False;\nEnd;\nProcedure Xuat;\nVar f:Text;\n i:longint;\nBegin\n assign(f,fout); rewrite(f);\n if k=-1 then\n write(f,0)\n else\n begin\n writeln(f,5);\n for i:=0 to 4 do\n write(f,k+i,' ');\n end;\n close(f);\nEnd;\n\nBegin\n nhap;\n solve;\n xuat;\nEnd."}, {"source_code": "Var m,k,i,u:Longint;\nBegin\n Readln(m);\n k:=0;i:=0;\n While k=5 do \n begin\n if l mod 5 <>0 then break;\n inc(k);\n l:=l div 5;\n end;\n if k=n then begin\n writeln(5);\n for m:=0 to 4 do write(i+m, ' ');\n halt; \n end;\n end;\n write(0);\nend."}, {"source_code": "var\n m,n,tong,p,i,dem:longint;\n kq:array[0..600000] of longint;\nbegin\n readln(m);\n n:=0;\n while tong<=m do\n begin\n inc(n);\n p:=n;\n while p>0 do\n begin\n if p mod 5<>0 then break;\n tong:=tong+1;\n p:=p div 5;\n end;\n if tong=m then\n begin\n inc(dem);\n kq[dem]:=n;\n end;\n end;\n writeln(dem);\n for i:=1 to dem do write(kq[i],' ');\nend.\n"}, {"source_code": "{$mode objfpc}\n{$macro on}\n{$define maicute:= for i := 1 to n do}\n\nuses\n Math;\n\nconst\n inp = '';\n outp = '';\n maxN = round(1e6);\n\nvar\n fi, fo : textfile;\n n, m : Integer;\n a, b, s, f1, f2 : array[0..maxN] of Int64;\n\nProcedure OpenFile;\nbegin\n Assign(fi, inp); Reset(fi);\n Assign(fo, outp); Rewrite(fo);\nend;\n\nProcedure Init;\nbegin\n fillchar(a, sizeof(a), 0);\n fillchar(b, sizeof(b), 0);\n fillchar(f1 , sizeof(f1), 0);\n fillchar(f2, sizeof(f2), 0);\nend;\n\nProcedure Enter;\nvar\n i, j : Integer;\nbegin\n ReadLn(fi, m);\nend;\n\nfunction get2(x : Integer): Integer;\nbegin\n result := 0;\n while x mod 2 = 0 do\n begin\n x := x div 2;\n result := result + 1;\n end;\nend;\n\nfunction get5(x : Integer): integer;\nbegin\n result := 0;\n while x mod 5 = 0 do\n begin\n x := x div 5;\n result := result + 1;\n end;\nend;\n\nProcedure Solve;\nvar\n i, j : Integer;\n res : Integer;\nbegin\n a[2] := 1;\n for i := 3 to 1000000 do\n if i mod 2 = 0 then\n a[i] := a[i-1] + get2(i)\n else a[i] := a[i-1];\n b[5] := 1;\n for i := 6 to 1000000 do\n if i mod 5 = 0 then\n b[i] := b[i-1] + get5(i)\n else b[i] := b[i-1];\n res := 0;\n for i := 1 to 1000000 do\n if min(a[i], b[i]) = m then\n begin\n inc(res);\n s[res] := i;\n end\n else if min(a[i], b[i]) > m then break;\n Writeln(fo, res);\n for i := 1 to res do write(s[i],' ');\nend;\n\nProcedure PrintResult;\nbegin\nend;\n\nProcedure Closefile;\nbegin\n close(fi); close(fo);\nend;\n\nBegin\n OpenFile;\n Init;\n Enter;\n Solve;\n Printresult;\n Closefile;\nEnd.\n"}, {"source_code": "var a:array[0..200000]of longint;n,i,k,c,b:longint;\nbegin\nread(n);\nk:=5;a[1]:=5;c:=1;\nwhile c<=n do\nbegin\nk:=k+5;\nif (k) mod 25>0 then begin inc(c);a[c]:=k;end else\nbegin \n b:=k;\n while b mod 5=0 do begin inc(c); b:=b div 5;end;a[c]:=k;\nend; end;\n if a[n]=0 then write(0) else \n begin\n writeln(5);\n for i:=0 to 4 do\n write(a[n]+i,' ');\n \n end;\nend."}, {"source_code": "program ex;\nvar i,j,l,m,n,g:integer;\n k,h:longint;\n a:array[1..100200]of integer;\nbegin\n\n read(m);\n for i:=1 to 100200 do\n a[i]:=0;\n j:=1;\n k:=5;\n a[1]:=k;\n while(m>j) do\n begin\n k:=k+5;\n h:=5; l:=0;\n while(k mod h =0) do\n begin\n\n h:=h*5;\n l:=l+1;\n end;\n h:=h div 5;\n j:=j+l;\n a[j]:=k;\n end;\n\n if a[m]=0\n then write(0)\n else begin\n writeln(5);\n writeln(a[m],' ',a[m]+1,' ',a[m]+2,' ',a[m]+3,' ',a[m]+4);\n end;\n\nend.\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar x,i,kol,k,ans,n:int64;\n\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n); k:=0;\ni:=5;\nwhile k=0 do\n begin\n x:=i; kol:=0;\n while x mod 5=0 do\n begin\n inc(kol);\n x:=x div 5;\n end;\n inc(ans,kol);\n if ans=n\n then begin writeln(5); writeln(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4); halt; end\n else if ans>n then break;\n inc(i,5);\n end;\n writeln(k);\n\n{close(input); close(output); }\nend.\n"}, {"source_code": "Program _1;\nVar\n m,kol,nom,i,j:longint;\n a:array[1..10] of longint;\nBegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(m);\n kol:=0;\n i:=1;\n while kol<=m do begin\n j:=i;\n while j mod 5 = 0 do begin\n inc(kol);\n j:=j div 5;\n end;\n if kol=m then begin\n inc(nom);\n a[nom]:=i;\n end;\n inc(i);\n end;\n if nom=0 then write(0)\n else begin\n writeln(nom);\n for j:=1 to nom do write(a[j],' ');\n end;\nEnd.\n\n"}, {"source_code": "uses math;\n\nvar\n res:array[0..1000000]of longint;\n i,m,n,k,l,w,s,j,w1,w2,w3:longint;\nbegin\n readln(n);\n for i:=1 to 10000000 do\n begin\n s:=i;\n while s mod 2=0 do begin inc(w1); s:=s div 2; end;\n while s mod 5=0 do begin inc(w2); s:=s div 5; end;\n l:=min(w1,w2);\n dec(w1,l); dec(w2,l); inc(w3,l);\n if w3=n then begin inc(k); res[k]:=i; end;\n if w3>n then break;\n end;\n writeln(k);\n for i:=1 to k do write(res[i],' ');\nend.\n"}, {"source_code": "uses math;\nvar i,t,kol1,kol2,n,kol:longint;\n a:array[1..10000] of longint;\nbegin\nreadln(n);\nfor i:=1 to 1000000 do\nbegin\nt:=i;\n while(t mod 2=0) do\n begin\n inc(kol1);\n t:=t div 2;\n end;\n while(t mod 5=0) do\n begin\n inc(kol2);\n t:=t div 5;\n end;\n\nif min(kol1,kol2)=n then begin inc(kol); a[kol]:=i; end;\n\nend;\n\n\nwriteln(kol);\nfor i:=1 to kol do\nwrite(a[i],' ');\n\n\nend.\n"}, {"source_code": "uses math;\nvar a:array[0..1000001] of int64;\n pr,ind,p,d,n:int64;i:longint;\n\n\nprocedure dv(x:longint);\nbegin\n while (x mod 2=0)do\n begin x:=x div 2;inc(d);end;\n\n while (x mod 5=0)do\n begin x:=x div 5;inc(p);end;\n\nend;\n\nbegin\nreadln(n);\n\ni:=1;\n\nwhile(pr<>1)do\nbegin\ninc(i);\ndv(i);\nif min(p,d)>n then break else\nif min(p,d)=n then begin inc(ind);a[ind]:=i;end;\nend;\n\nwriteln(ind);\nfor i:=1 to ind do\nwrite(a[i],' ');\n\nend.\n"}, {"source_code": "\n\nvar\n\tn,m,k,l,j,i:longint;\nbegin\n\tread(n);\n\tfor i:=1 to 1000000 do \n\tbegin\n\t\tl:=i;\n\t\twhile l>=5 do \n\t\tbegin\n\t\t\tif l mod 5 <>0 then break;\n\t\t\tinc(k);\n\t\t\tl:=l div 5;\n\t\tend;\n\t\tif k=n then \n\t\tbegin\n\t\t\twriteln(5);\n\t\t\tfor m:=0 to 4 do write(i+m, ' ');\n\t\t\tj:=1; \n\t\tend;\n\t\tif j=1 then exit;\n end;\n write(0);\nend."}, {"source_code": "Var a:array[1..12000] of longint;\n n,i,l,r,m:longint;\n function check(n:longint):Longint;\n\n Var a:array[1..10000] of int64;\n d,k,ans,m:int64;\n i,j:longint;\n Begin\n //Read(n);\n ans:=0;\n a[1]:=5;\n d:=a[1];\n i:=2;\n m:=1;\n while a[i]<=n do\n Begin\n a[i]:=a[i-1]*5;\n if (a[i]>n) then break;\n inc(i);\n inc(m);\n end;\n for i:=1 to m do\n Begin\n k:=n div a[i];\n ans:=ans+k;\n end;\n exit(ans);\n end;\n procedure writef(x:longint);\n var i:longint;\n begin\n for i:=x to x+4 do\n write(i,' ');\n end;\n\n begin\n read(n);\n l:=1;\n r:=1000000;\n // writeln(check());\n while lm then\n writeln(0)\n else begin\n writeln(5);\n for j:=i*5 to i*5+4 do\n write(j,' ');\n end;\nend;\n\nBEGIN\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n Readln(m);\n Process;\n\n close(input); close(output);\nEND.\n"}, {"source_code": "var i,k,m,s:int64;\nbegin\n read(m);\n s:=0;i:=0;\n While sb then max:=a; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\nfunction degg(p,deg:int64):int64; var pp,q:int64;\n begin if deg=0 then degg:=1 else begin if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else\n begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul; end; end; end;\n\nfunction kolnul(t:longint):longint; var i,j,ot:longint;\nbegin\n ot:=0;\n while t>0 do\n begin\n t:=t div 5;\n ot:=ot+t;\n end;\n kolnul:=ot;\n end;\n\nbegin\n {assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(n);\n for i:=1 to 1000000 do if kolnul(i)=n then\n begin inc(p); a[p]:=i; end;\n\n writeln(p); for i:=1 to p do write(a[i],' ');\n\n\n\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program ProjectD;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,math;\nvar a,b,c,d,x,y,res:int64; i:integer;\nbegin\n // reset(input,'input.txt');\n // rewrite(output,'output.txt');\n read(a);\n b:=0;\n i:=2;\n while 1=1 do\n begin\n if i mod 5 = 0\n then begin\n d:=i;\n while d mod 5 = 0 do\n begin\n inc(b);\n d:=d div 5;\n end;\n end;\n if b>a\n then begin\n write(0);\n halt(0);\n end;\n if b=a\n then begin\n writeln(5);\n write(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4);\n halt(0);\n end;\n\n inc(i);\n end;\n write(b);\nend."}, {"source_code": "Var\n m:array[1..1000000]of longint;\n n,tk,z,ans:int64;i:longint;\nbegin\n// assign(input,'input.txt');assign(output,'output.txt');\n readln(n);\n tk:=1;\n m[1]:=0;\n while m[tk]<=n do\n begin\n inc(tk);\n m[tk]:=m[tk-1];\n z:=tk;\n while z mod 5=0 do\n begin\n inc(m[tk]);\n z:=z div 5;\n end;\n end;\n ans:=0;\n for i:=1 to tk do\n if m[i]=n then\n inc(ans);\n writeln(ans);\n for i:=1 to tk do\n if m[i]=n then\n write(i,' ');\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, tmp, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\ti := 1;\n\tfor i := 1 to 5*round(1e5) do begin\n\t\ttmp := i;\n\t\twhile tmp mod 2 = 0 do begin\n\t\t\tinc(t);\n\t\t\ttmp := tmp div 2;\n\t\tend;\n\t\t\n\t\twhile tmp mod 5 = 0 do begin\n\t\t\tinc(f);\n\t\t\ttmp := tmp div 5;\n\t\tend;\n\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, tmp, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\ti := 1;\n\tfor i := 1 to round(1e6) do begin\n\t\ttmp := i;\n\t\twhile tmp mod 2 = 0 do begin\n\t\t\tinc(t);\n\t\t\ttmp := tmp div 2;\n\t\tend;\n\t\t\n\t\twhile tmp mod 5 = 0 do begin\n\t\t\tinc(f);\n\t\t\ttmp := tmp div 5;\n\t\tend;\n\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "const mx : longint = 500000;\n\nvar m, i, j : longint;\n a : array[1..100000] of longint;\n\nfunction cal(x : longint) : longint;\nvar cnt, i : longint;\n\nbegin\n i := 5; cnt := 0;\n while (x >= i) do\n begin\n cnt := cnt + (x div i);\n i := i * 5;\n end;\n cal := cnt;\nend;\n\nbegin\n readln(m);\n j := 1;\n for i := 1 to mx do\n begin\n if (cal(i) = m) then\n begin\n a[j] := i;\n inc(j);\n end;\n end;\n writeln(j - 1);\n for i := 1 to j - 1 do write(a[i], ' ');\n writeln;\nend."}, {"source_code": "const fi='';\n fo='';\n max=100000;\nvar num:extended;\n n,ans,j:longint;\n so:array[1..100] of longint;\n\nprocedure doc;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n close(f);\n ans:=0;\nend;\n\nprocedure xl;\nvar s:ansistring; f:text;\n i,tmp1,tmp2,x:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n j:=0;\n x:=0;\n repeat\n x:=x+5;\n str(x,s);\n if (s[length(s)]='5') or (s[length(s)]='0') then begin\n tmp1:=x;\n tmp2:=0;\n while (tmp2=0) do begin\n tmp1:=tmp1 div 5;\n tmp2:=tmp1 mod 5;\n inc(ans);\n end;\n end;\n if ans=n then\n for i:=0 to 4 do begin\n inc(j);\n so[j]:=x+i;\n end;\n until ans>n;\n writeln(f,j);\n for i:=1 to j do write(f,so[i],' ');\n close(f);\nend;\n\nbegin\n doc;\n xl;\nend.\n"}, {"source_code": "uses math;\nvar i,j,k,ans:longint;\n d,a:array[0..10000000] of longint;\n m:longint;\n begin\n read(m);\n\n i:=1;\n\n while (i*5<=1000000) do\n begin\n inc(j);\n a[j]:=i*5;\n i:=i*5;\n end;\n\n\n for i:=1 to 1000000 do\n for k:=1 to j do\n inc(d[i],i div a[k]);\n\n for i:=1 to 1000000 do\n if d[i]=m then inc(ans);\n\n writeln(ans);\n\n for i:=1 to 1000000 do\n if d[i]=m then write(i,' ');\n end.\n\n\n\n"}, {"source_code": "var\n f,g:text;\n a:array[1..5000000] of longint;\n s,k,i,n:longint;\n begin\n assign(f,'');\n reset(F);assign(g,'');\n rewrite(g);\n readln(F,n);\n k:=5;\n while sn then writeln(g,0);\nclose(f);\nclose(g);\nend."}, {"source_code": "program Trivial;\nlabel 99;\nvar m,five:longint;\n n,j,d0,d1,d2,d3,d4,d5,d6,d7,d8:integer;\n\nbegin\nfive:=0;\nread(m);\nn:=0;\n\nfor d0:=1 to 5 do begin\n for d1:=1 to 5 do begin\n for d2:=1 to 5 do begin\n for d3:=1 to 5 do begin\n for d4:=1 to 5 do begin\n for d5:=1 to 5 do begin\n for d6:=1 to 5 do begin\n for d7:=1 to 5 do begin\n if five >= m then goto 99 ;\n five:=five+1;\n n:=n+5;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\nend;\n99:\nif five = m then begin\n writeln('5');\n for j:=0 to 4 do begin\n write((n+j),' ');\n end;\nend\nelse write('0');\n\nend."}, {"source_code": "var i, n, m, k, o, p, ans:LongInt;\n A:ARRAY [1..100000] of LongInt;\nBegin\n Read(n);\n for i:=1 to 400010 do\n Begin\n o:=i;\n k:=0;\n while o>0 do\n Begin\n k:=k+o div 5;\n o:=o div 5;\n End;\n if k=n then Begin inc(ans);A[ans]:=i;End;\n End;\n WriteLn(ans);\n for i:=1 to ans do\n Write(A[i],' ');\nEnd."}, {"source_code": "var\nn,m,k,l,i:longint;\nbegin\nread(n);\n for i:=1 to 10000000 do begin\n l:=i;\n while l>=5 do begin\n if l mod 5 <>0 then break;\n inc(k);\n l:=l div 5;\n end;\n if k=n then begin\n writeln(5);\n for m:=0 to 4 do write(i+m, ' ');\n halt; end;\n end;\n write(0);\n end.\n"}, {"source_code": "var i,k,m,s:int64;\nbegin\n read(m);\n s:=0;\n i:=0;\n while s=c[p] do\n begin\n if n=c[p] then\n begin\n writeln(5);\n for i:=0 to 4 do\n write(p*5+i,' ');\n halt(0);\n end;\n inc(p);\n end;\n writeln(0);\nend.\n\n"}, {"source_code": "var m,dem,i,k,j:longint;\nbegin\n readln(m); i:=1;\n while 1 = 1 do\n begin\n k:=i*5;\n while k mod 5 = 0 do\n begin\n k:= k div 5;\n inc(dem);\n end;\n if dem = m then\n begin\n writeln(5);\n for j:=0 to 4 do\n write(5*i+j,' ');\n break;\n end;\n if dem > m then begin write(0); break; end;\n inc(i);\n end;\n readln\nend.\n"}, {"source_code": "program m1;\nvar\na:array[1..500000] of longint;\nk,f,s,i,j,n,m:longint;\nbegin\nread(m);\nk:=5;\nf:=0;\ns:=0;\nwhile(sm) then\n write(0);\nend.\n"}, {"source_code": " Uses MATH;\n var m , n : LongInt;\n i : LongInt;\n Two , Five : LongInt;\n AnsCount : LongInt;\n Ans : Array [ 1 .. 10000000 ] of LongInt;\nbegin\n readLn ( m ) ; \n Two := 0 ; \n Five := 0 ; \n AnsCount := 0 ; \n i := 1 ;\n \n while (True ) do\n begin\n n := i ; \n \n while ( n > 1 ) and ( n mod 2 = 0 ) do\n begin\n inc ( Two ) ; \n n := n div 2;\n end;\n \n while ( n > 1 ) and ( n mod 5 = 0 ) do\n begin\n inc ( Five ) ; \n n := n div 5;\n end;\n \n if ( Min ( Two , Five ) = m ) then\n begin\n inc ( AnsCount ) ; \n Ans [ AnsCount ] := i;\n end\n else if ( Min ( Two , Five ) > m ) then\n break;\n \n \n i := i + 1 ;\n end;\n \n \n writeLn ( AnsCount ) ;\n for i := 1 to AnsCount do\n write ( Ans [ i ] , ' ' ) ;\nend."}, {"source_code": "var\nm,q,b,i,j,k:longint;\nbegin\nreadln(m);\nwhile(jn;\n writeln(f,j);\n for i:=1 to j do write(f,so[i],' ');\n close(f);\nend;\n\nbegin\n doc;\n xl;\nend.\n"}, {"source_code": "program z_633_b;\nvar m,n,k,i,t,f,c,c1,ans,ans2:integer;\n\nbegin\nreadln(m);\n\nwhile (fm) then ans:=0 else ans:=5; \nwriteln(ans);\nif ans<>0 then\nfor i:=c to c+4 do\nwrite(i,' ');\n\nend."}, {"source_code": "uses math;\nvar\n n,anskil:longint;\n ans,dop:ansistring;\n i,idop,pot2,pot5:longint;\nbegin\n read(n);\n\n i:=1;\n while i<>-1 do\n begin\n idop:=i;\n while idop mod 2=0 do\n begin\n inc(pot2);\n idop:=idop div 2;\n end;\n while idop mod 5=0 do\n begin\n inc(pot5);\n idop:=idop div 5;\n end;\n if min(pot2,pot5)=n then\n begin\n inc(anskil);\n str(i,dop);\n if ans<>'' then ans:=ans+' '+dop\n else ans:=ans+dop;\n end;\n if min(pot2,pot5)>n then break;\n inc(i);\n end;\n\n writeln(anskil);\n writeln(ans);\nend."}, {"source_code": "//CF633B\nconst\n five = 5; maxN = trunc(1e3 + 7);\ntype\n tlist = array[0..maxN] of longint;\nvar\n p, sum, base, n, top, i: longint;\n stack: tlist;\n\nbegin\n //assign(input, 'CF633B.iNP'); reset(input);\n //assign(output, 'CF633B.oUT'); rewrite(output);\n readln(n);\n for i:= 5 to maxlongint do\n begin\n base:= 1; sum:= 0;\n while base <= i do\n begin\n base:= base * five;\n inc(sum, i div base);\n end;\n if sum = n then\n begin\n inc(top); stack[top]:= i;\n end;\n if sum > n then break;\n end;\n writeln(top);\n for i:= 1 to top do write(stack[i], ' ');\n //close(input); close(output);\nend.\n\n"}, {"source_code": "var n,i,j,d:longint;\n a,b:array[0..10000000] of longint;\nbegin\n read(n);\n for i:=1 to 200001 do\n begin\n j:=i*5;\n b[i]:=j;\n a[i]:=a[i-1];\n while (j mod 5=0) do\n begin\n inc(a[i]);\n j:=j div 5;\n end;\n end;\n\n for i:=1 to 1000000 do\n if n=a[i] then\n begin\n writeln(b[i+1]-b[i]);\n for j:=b[i] to b[i+1]-1 do\n write(j,' ');\n break;\n end\n else\n if n0 do\n begin\n n:=n div 5;\n kq:=kq+n;\n end;\n exit(kq);\nend;\nprocedure progress;\nvar l,r,mid,t,kq:int64;\ni:longint;\nbegin\n readln(m);\n l:=1; r:=trunc(1e9);\n kq:=0;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n t:=cal(mid);\n if t>=m then\n begin\n kq:=mid;\n r:=mid-1;\n end\n else l:=mid+1;\n end;\n while cal(kq)=m do\n begin\n inc(res);\n a[res]:=kq;\n inc(kq);\n end;\n writeln(res);\n for i:=1 to res do write(a[i], ' ');\nend;\nbegin\n progress;\n\nend."}, {"source_code": "var x,left,rait,midl, otvet:integer;\nfunction suka (x:integer):integer;\nvar a,b:integer;\nbegin\n a:=5; b:=0;\n while x/a>=1 do\n begin\n b:=b+trunc(x/a);\n a:=a*5;\n end;\n suka:=b;\n end;\nbegin\n read(x); left:=1; rait:=5*x+4;\nwhile (suka(midl)<>x) and(rait-Left>1) do\nbegin\n midl:=trunc((left+rait)/2);\n if suka(midl)>x then rait:=midl;\n if suka(midl)x then writeln(0) else\n begin\n writeln(5);\n write(midl - (midl mod 5),' ' ,midl - (midl mod 5)+1,' ',midl - (midl mod 5) +2,' ',midl-(midl mod 5)+3,' ',midl - (midl mod 5)+4);\n end;\n end.\n"}, {"source_code": "var i:longint;\n x,n,j,k:int64;\n b:array[1..10]of int64;\nbegin\nread(n);\nx:=1;\ni:=1;\nwhile k<=n do\n begin\n x:=(x*i) mod 1000000000;\n while x mod 10 =0 do\n begin\n inc(k);\n x:=x div 10;\n end;\n if k=n then\n begin\n inc(j);\n b[j]:=i;\n end;\n inc(i);\n end;\nwriteln(j);\nfor i:=1 to j do\n write(b[i],' ');\nend.\n\n\n\n\n\n\n\n"}], "negative_code": [{"source_code": "program p633b;\nvar\nm,j,k:longint;\ni:integer;\nconst five:byte=5;\n\nprocedure output(k: longint);\nvar i:longint;\nbegin\n writeln(five);\n for i:=0 to 4 do \n write(k*five+i,' ')\nend;\n\nbegin\nreadln(m);\nj:=0; i:=0;\n\nwhile(j 0) do\n begin\n inc(so);\n a:=a div 5;\n end;\n if so >= n then break\n end;\n if so >= n then\n begin\n writeln(5);\n writeln(m,' ',m+1,' ',m+2,' ',m+3,' ',m+4);\n end\n else write(0);\n\n close(input); close(output);\nend.\n"}, {"source_code": "const fi = '';\n fo = '';\nvar i, j, a, m, so, n: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n so:=0;\n readln(n);\n for i:=1 to n do\n begin\n a:=i*5;\n while (a mod 5 = 0) and (a > 0) do\n begin\n inc(so);\n a:=a div 5;\n end;\n end;\n if so >= n then\n if so = n then\n begin\n writeln(5);\n writeln(so*5,' ',so*5+1,' ',so*5+2,' ',so*5+3,' ',so*5+4);\n end\n else write(0);\n\n close(input); close(output);\nend.\n"}, {"source_code": "Var m,k,i:Longint;\nBegin\n Readln(m);\n k:=m Div 2;\n k:=k*10;\n If Odd(m) then\n Inc(k,5);\n Writeln(5);\n For i:=0 to 4 do\n Write(k+i,' ');\nEnd."}, {"source_code": "var\n m,n,tong,p,i,dem:longint;\n kq:array[0..600000] of longint;\nbegin\n readln(m);\n n:=0;\n while tong<=m do\n begin\n inc(n);\n p:=n;\n while p>0 do\n begin\n tong:=tong+ord(p mod 5=0);\n p:=p div 5;\n end;\n if tong=m then \n begin\n inc(dem);\n kq[dem]:=n;\n end;\n end;\n writeln(dem);\n for i:=1 to dem do write(kq[i],' ');\nend."}, {"source_code": "{$mode objfpc}\n{$macro on}\n{$define maicute:= for i := 1 to n do}\n\nuses\n Math;\n\nconst\n inp = '';\n outp = '';\n maxN = round(1e6);\n\nvar\n fi, fo : textfile;\n n, m : Integer;\n a, b, s : array[0..maxN] of Integer;\n\nProcedure OpenFile;\nbegin\n Assign(fi, inp); Reset(fi);\n Assign(fo, outp); Rewrite(fo);\nend;\n\nProcedure Init;\nbegin\n fillchar(a, sizeof(a), 0);\n fillchar(b, sizeof(b), 0);\nend;\n\nProcedure Enter;\nvar\n i, j : Integer;\nbegin\n ReadLn(fi, m);\nend;\n\nProcedure Solve;\nvar\n i, j : Integer;\n res : Integer;\nbegin\n a[2] := 1;\n for i := 3 to 100000 do\n if i mod 2 = 0 then\n a[i] := a[i-1] + i div 2\n else a[i] := a[i-1];\n b[5] := 1;\n for i := 6 to 100000 do\n if i mod 5 = 0 then\n b[i] := b[i-1] + i div 5\n else b[i] := b[i-1];\n res := 0;\n for i := 1 to 1000000 do\n if min(a[i], b[i]) = m then\n begin\n inc(res);\n s[res] := i;\n end\n else if min(a[i], b[i]) > m then break;\n Writeln(fo, res);\n for i := 1 to res do write(s[i],' ');\nend;\n\nProcedure PrintResult;\nbegin\nend;\n\nProcedure Closefile;\nbegin\n close(fi); close(fo);\nend;\n\nBegin\n OpenFile;\n Init;\n Enter;\n Solve;\n Printresult;\n Closefile;\nEnd.\n"}, {"source_code": "var a:array[0..200000]of longint;n,i,k,c,b:longint;\nbegin\nread(n);\nk:=5;a[1]:=5;c:=1;\nfor i:=2 to n do\nbegin\nk:=k+5;\nif (k) mod 25>0 then begin inc(c);a[i]:=k;end else\nbegin \n b:=k+1;\n while b mod 5=0 do begin inc(k); b:=b div 5;end;\nend; end;\n if a[n]=0 then write(0) else \n begin\n writeln(5);\n for i:=0 to 4 do\n write(a[n]+i,' ');\n \n end;\nend."}, {"source_code": "program ex;\nvar i,j,l,m,n,g:integer;\n k,h:longint;\n a:array[1..100200]of integer;\nbegin\n\n read(m);\n for i:=1 to 100200 do\n a[i]:=0;\n j:=1;\n k:=5;\n a[1]:=k;\n while(m>j) do\n begin\n k:=k+5;\n h:=5;\n while(k mod h <>0) do\n h:=h*5;\n h:=h div 5;\n j:=j+ k div h;\n a[j]:=k;\n end;\n\n if a[m]=0\n then write(0)\n else begin\n writeln(5);\n writeln(a[m],' ',a[m]+1,' ',a[m]+2,' ',a[m]+3,' ',a[m]+4);\n end;\n\n\n\nend.\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar x,i,kol,k,ans,n:longint;\na:array[0..100000] of longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n); k:=0;\nfor i:=1 to 100000 do\n begin\n x:=i; kol:=0;\n while x mod 5=0 do\n begin\n inc(kol);\n x:=x div 5;\n end;\n inc(ans,kol);\n if ans=n\n then begin writeln(5); writeln(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4); halt; end\n else if ans>n then break;\n end;\n writeln(k);\n\n{close(input); close(output); }\nend.\n"}, {"source_code": "Program Buntarik;\nuses math;\nvar x,i,kol,k,ans,n:longint;\na:array[0..100000] of longint;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\n\nreadln(n);\nfor i:=1 to 100000 do\n begin\n x:=i; kol:=0;\n while x mod 5=0 do\n begin\n inc(kol);\n x:=x div 5;\n end;\n inc(ans,kol);\n if ans=n\n then begin inc(k); a[k]:=i; end\n else if ans>n then break;\n end;\n writeln(k);\n for i:=1 to k do\n write(a[i],' ');\n\n{close(input); close(output); }\nend.\n"}, {"source_code": "Var a:array[1..12000] of longint;\nn,i:longint;\n begin\n read(n);\n if n mod 5 = 0 then begin\n write(0);\n halt;\n end;\n writeln(5);\n n:=(n-(n div 5))*5;\n for i:=n to n+4 do\n write(i,' ');\n end."}, {"source_code": "Var a:array[1..12000] of longint;\nn,i:longint;\n begin\n read(n);\n if n=5 then begin\n write(0);\n halt;\n end;\n writeln(5);\n n:=(n-(n div 5))*5;\n for i:=n to n+4 do\n write(i,' ');\n end."}, {"source_code": "Var a:array[1..1000] of longint;\nn,i:longint;\n begin\n read(n);\n if n mod 5 = 0 then begin\n write(0);\n halt;\n end;\n writeln(5);\n n:=(n-(n div 5))*5;\n for i:=n to n+4 do\n write(i,' ');\n end."}, {"source_code": "Var a:array[1..12000] of longint;\nn,i:longint;\n begin\n read(n);\n if n=5 then begin\n write(0);\n halt;\n end;\n\n n:=(n-(n div 5))*5;\n for i:=n to n+4 do\n write(i,' ');\n end."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, tmp, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\tfor i := 1 to round(1e5) do begin\n\t\ttmp := i;\n\t\twhile tmp mod 2 = 0 do begin\n\t\t\tinc(t);\n\t\t\ttmp := tmp div 2;\n\t\tend;\n\t\t\n\t\twhile tmp mod 5 = 0 do begin\n\t\t\tinc(f);\n\t\t\ttmp := tmp div 5;\n\t\tend;\n\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, tmp, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\tfor i := 1 to 2*round(1e5) do begin\n\t\ttmp := i;\n\t\twhile tmp mod 2 = 0 do begin\n\t\t\tinc(t);\n\t\t\ttmp := tmp div 2;\n\t\tend;\n\t\t\n\t\twhile tmp mod 5 = 0 do begin\n\t\t\tinc(f);\n\t\t\ttmp := tmp div 5;\n\t\tend;\n\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\tfor i := 1 to round(1e5) do begin\n\t\tif i mod 5 = 0 then inc(f, i div 5);\n\t\tif i mod 2 = 0 then inc(t, i div 2);\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "{$mode objfpc}\n\nuses math;\nvar\n\tfi, fo: text;\n\tf, t, i, top, m: integer;\n\ts: array[0..round(1e5+1)] of integer;\n\nbegin\n\tassign(fi, ''); reset(fi);\n\tassign(fo, ''); rewrite(fo);\n\treadln(fi, m);\n\tf := 0; t := 0;\n\tfor i := 1 to round(1e5) do begin\n\t\tif i mod 10 = 5 then inc(f);\n\t\tif i mod 10 = 2 then inc(t);\n\t\tif i mod 10 = 0 then begin\n\t\t\tinc(t); inc(f);\n\t\tend;\n\t\tif min(f, t) = m then begin\n\t\t\tinc(top);\n\t\t\ts[top] := i;\n\t\tend;\n\tend;\n\t//writeln(f, ' ', t);\n\twriteln(top);\n\tfor i := 1 to top do \n\t\twrite(s[i], ' ');\n\twriteln;\n\tclose(fi); close(fo);\nend."}, {"source_code": "const mx : longint = 500000;\n\nvar m, i, j : longint;\n a : array[1..100000] of longint;\n\nfunction cal(x : longint) : longint;\nvar cnt, i : longint;\n\nbegin\n i := 5; cnt := 0;\n while (x >= i) do\n begin\n cnt := cnt + (x div i);\n i := i * 5;\n end;\n cal := cnt;\nend;\n\nbegin\n readln(m);\n j := 1;\n for i := 1 to mx do\n begin\n if (cal(i) = m) then\n begin\n a[j] := i;\n inc(j);\n end;\n end;\n writeln(j);\n for i := 1 to j do write(a[i], ' ');\n writeln;\nend."}, {"source_code": "var m, i, j : longint;\n a : array[1..100000] of longint;\n\nfunction cal(x : longint) : longint;\nvar cnt, i : longint;\n\nbegin\n i := 5; cnt := 0;\n while (x >= i) do\n begin\n cnt := cnt + (x div i);\n i := i * 5;\n end;\n cal := cnt;\nend;\n\nbegin\n readln(m);\n j := 1;\n for i := 1 to m do\n begin\n if (cal(i) = m) then\n begin\n a[j] := i;\n inc(j);\n end;\n end;\n writeln(j);\n for i := 1 to j do write(a[i], ' ');\n writeln;\nend."}, {"source_code": "program Trivial;\n\nvar m,five:longint;\n k,n,j:integer;\n a:array[1..10] of integer;\n\nbegin\nfor j:=1 to 10 do begin\n a[j]:=0;\nend;\nk:=0;\nn:=1;\nfive:=0;\nread(m);\nwhile m>=five do begin\n if n mod 5 = 0 then five:=five + (n div 5);\n if five=m then begin\n k:=k+1;\n a[k]:=n;\n end;\n n:=n+1;\nend;\nwriteln(k);\nfor j:=1 to 10 do begin\n if a[j]<>0 then write(a[j],' ')\n else break;\nend;\nend."}, {"source_code": "program Trivial;\nlabel 99;\nvar m,five:longint;\n n,j,d1,d2,d3,d4,d5,d6,d7:integer;\n\nbegin\nfive:=0;\nread(m);\nn:=0;\n\n\nfor d1:=1 to 5 do begin\n for d2:=1 to 5 do begin\n for d3:=1 to 5 do begin\n for d4:=1 to 5 do begin\n for d5:=1 to 5 do begin\n for d6:=1 to 5 do begin\n for d7:=1 to 5 do begin\n if five >= m then goto 99 ;\n five:=five+1;\n n:=n+5;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\nend;\n99:\nif five = m then begin\n writeln('5');\n for j:=0 to 4 do begin\n write((n+j),' ');\n end;\nend\nelse write('0');\n\nend."}, {"source_code": "program Trivial;\nlabel 99;\nvar m,five:longint;\n n,j,d0,d1,d2,d3,d4,d5,d6,d7,d8:integer;\n\nbegin\nfive:=0;\nread(m);\nn:=0;\n\nfor d0:=1 to 5 do begin\n for d1:=1 to 5 do begin\n for d2:=1 to 5 do begin\n for d3:=1 to 5 do begin\n for d4:=1 to 5 do begin\n for d5:=1 to 5 do begin\n for d6:=1 to 5 do begin\n for d7:=1 to 5 do begin\n if five >= m then goto 99 ;\n five:=five+1;\n n:=n+5;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\n five:=five+1;\n end;\nend;\n99:\nif five = m then begin\n writeln('5');\n for j:=0 to 4 do begin\n write((n+j),' ');\n end;\nend\nelse write('0');\n\nend.\n"}, {"source_code": "program Trivial;\n\nvar m,five:longint;\n n,j:integer;\nfunction fivpow(num : integer):integer;\nvar nk:integer;\nbegin\nnk:=-1;\n while num<>0 do begin\n num:=num div 5;\n nk:=nk+1;\n end;\nfivpow:=nk;\nend;\n\nbegin\nfive:=0;\nn:=5;\nread(m);\n\nwhile m >= five do begin\n five:=five+fivpow(n);\n if five=m then begin\n writeln('5');\n for j:=0 to 4 do begin\n write((n+j),' ');\n end;\n break;\n end;\n n:=n+5;\n \nend;\nif m0 do begin\n num:=num div 5;\n nk:=nk+1;\n end;\nfivpow:=nk;\nend;\n\nbegin\nfive:=0;\nn:=5;\nread(m);\n\nwhile m >= five do begin\n five:=five+fivpow(n);\n if five=m then begin\n writeln('5');\n for j:=0 to 4 do begin\n write((n+j),' ');\n end;\n break;\n end;\n n:=n+5;\n \nend;\nif m=5 do begin\n if l mod 5 <>0 then break;\n inc(k);\n l:=l div 5;\n end;\n if k=n then begin\n for m:=0 to 4 do write(i+m, ' ');\n halt; end;\n end;\n write(0);\n end.\n"}, {"source_code": "var\nn,m,k,l,i:longint;\nbegin\nread(n);\n m:=5;\n l:=0;\n k:=0;\n while m= t do\n begin\n if m = t then begin write(0); exit; end;\n t:=t + 6;\n end;\n t:=-1;\n for i:=0 to 5*100000 do\n begin\n inc(j);\n a[i]:=dem;\n if j = 5 then begin inc(dem); j:=0; end;\n if dem = t + 6 then begin t:=t + 6; inc(dem); end;\n end;\n writeln(5);\n for i:=0 to 5*100000 do\n if m = a[i] then write(i,' ');\n readln\nend."}, {"source_code": "program m1;\nvar\ni,j,n,m:longint;\nbegin\nread(m);\nwriteln(5);\nfor i:=1 to 5 do\nwrite(5*m-1+i,' ');\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\ntype arr=array[1..1000000] of longint;\nvar d:arr; f:text;m:longint;\nprocedure xl;\nvar max,i,k,d,t,du,tam:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,m);\n close(f);\n d:=0;\n t:=0;\n max:=0;\n while max<=m do\n begin\n inc(t);\n k:=t;\n d:=0;\n while k div 5>0 do\n begin\n if k mod 5=0 then inc(d);\n k:=k div 5;\n end;\n if (t mod 5=0) then max:=max+d;\n if max=m then break;\n end;\n assign(f,fo);\n rewrite(f);\n if max>m then write(f,'0') else\n begin\n writeln(f,'5');\n for i:=0 to 4 do write(f,t+i,' ');\n end;\n close(f);\nend;\nbegin\n xl;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\ntype arr=array[1..1000000] of longint;\nvar d:arr; f:text;m:longint;\nprocedure xl;\nvar max,i,k,d,t,du,tam:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,m);\n close(f);\n d:=0;\n t:=0;\n max:=0;\n while max<=m do\n begin\n inc(t);\n k:=t;\n d:=0;\n while k div 5>0 do\n begin\n inc(d);\n k:=k div 5;\n end;\n if (t mod 5=0) then max:=max+d;\n if max=m then break;\n end;\n assign(f,fo);\n rewrite(f);\n if max>m then write(f,'0') else\n begin\n writeln(f,'5');\n for i:=0 to 4 do write(f,t+i,' ');\n end;\n close(f);\nend;\nbegin\n xl;\nend.\n"}, {"source_code": "const\n fi='';\n fo='';\ntype arr=array[1..1000000] of longint;\nvar d:arr; f:text;m:longint;\nprocedure xl;\nvar max,i,k,d,t,du,tam:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,m);\n close(f);\n d:=0;\n t:=0;\n max:=0;\n while max<=m do\n begin\n inc(t);\n k:=t;\n d:=0;\n while k div 5>0 do\n begin\n inc(d);\n k:=k div 5;\n end;\n tam:=k;\n for i:=1 to d do tam:=tam*5;\n if (tam=t) then max:=max+d;\n if max=m then break;\n end;\n assign(f,fo);\n rewrite(f);\n if max>m then write(f,'0') else\n begin\n writeln(f,'5');\n for i:=0 to 4 do write(f,t+i,' ');\n end;\n close(f);\nend;\nbegin\n xl;\nend.\n"}, {"source_code": "const fi='';\n fo='';\n max=100000;\nvar num:extended;\n n,ans,j:longint;\n so:array[1..100] of longint;\n\nprocedure doc;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n close(f);\n ans:=0;\nend;\n\nprocedure xl;\nvar s:ansistring; f:text;\n i,tmp1,tmp2:longint;\nbegin\n assign(f,fo);\n rewrite(f);\n j:=0;\n for i:=1 to max do begin\n str(i,s);\n if (s[length(s)]='5') or (s[length(s)]='0') then begin\n tmp1:=i;\n tmp2:=0;\n while (tmp2=0) do begin\n tmp1:=tmp1 div 5;\n tmp2:=tmp1 mod 5;\n inc(ans);\n end;\n end;\n if ans=n then begin\n inc(j);\n so[j]:=i;\n end;\n if ans>n then break;\n end;\n writeln(f,j);\n for i:=1 to j do write(f,so[i],' ');\n close(f);\nend;\n\nbegin\n doc;\n xl;\nend.\n\n\n"}, {"source_code": "program z_633_b;\nvar m,n,k,i:integer;\ns,f:int64;\n\nfunction st(a,n:integer):int64;\nbegin\nif n mod 2 = 1 then\nbegin\nif n=1 then st:=a\nelse st:=st(a,n-1)*a;\nend;\nif n mod 2 = 0 then\nbegin\nif n=2 then st:=sqr(a)\nelse st:=st(sqr(a),n div 2);\nend;\nend;\n\nfunction fact(n:integer):int64;\nbegin\nif n=1 then fact:=n\nelse fact:=fact(n-1)*n;\nend;\n\nbegin\nreadln(m);\ns:=st(10,m);\n\nfor i:=5*m to 5*m+4 do\nbegin\nf:=fact(i);\n\nif f mod s = 0 then \nbegin\ninc(k);\n//write(i,' ');\nend;\n\nend;\n\nwriteln(k);\n\nfor i:=5*m to 5*m+4 do\nbegin\nf:=fact(i);\n\nif f mod s = 0 then \nbegin\n//inc(k);\nwrite(i,' ');\nend;\n\nend;\n\nend."}, {"source_code": "program z_633_b;\nvar m,n,k,i,t,f,c,c1,ans,ans2:integer;\n\nbegin\nreadln(m);\n\nwhile (f0 then\nfor i:=c to c+4 do\nwrite(i,' ');\n\nend."}, {"source_code": "var n,i,j,d:longint;\n a,b:array[0..100000] of longint;\nbegin\n read(n);\n for i:=1 to 20001 do\n begin\n j:=i*5;\n b[i]:=j;\n a[i]:=a[i-1];\n while (j mod 5=0) do\n begin\n inc(a[i]);\n j:=j div 5;\n end;\n end;\n\n for i:=1 to 20001 do\n if n=a[i] then\n begin\n writeln(b[i+1]-b[i]);\n for j:=b[i] to b[i+1]-1 do\n write(j,' ');\n break;\n end\n else\n if n0 do\n begin\n n:=n div 5;\n kq:=kq+n;\n end;\n exit(kq);\nend;\nprocedure progress;\nvar l,r,mid,t,kq:int64;\ni:longint;\nbegin\n readln(m);\n l:=1; r:=9;\n kq:=0;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n t:=cal(mid);\n if t>=m then\n begin\n kq:=mid;\n r:=mid-1;\n end\n else l:=mid+1;\n end;\n while cal(kq)=m do\n begin\n inc(res);\n a[res]:=kq;\n inc(kq);\n end;\n writeln(res);\n for i:=1 to res do write(a[i], ' ');\nend;\nbegin\n progress;\n\nend."}], "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744"} {"source_code": "var n,i,h,k,j:longint; p,q,ans:extended; l,r:array[0..5]of longint;\n\nfunction max(a1,a2:longint):longint;\nbegin\n if a1>a2 then exit(a1) else exit(a2);\nend;\n\nfunction min(a1,a2:longint):longint;\nbegin\n if a1>a2 then exit(a2) else exit(a1);\nend;\n\nbegin \n readln(n);\n for i:=1 to n do readln(l[i],r[i]);\n for i:=1 to 10000 do\n begin\n for j:=1 to n do\n if (i>=l[j]) and (i<=r[j]) then\n begin\n p:=i/(r[j]-l[j]+1);\n for k:=1 to n do\n if k<>j then\n begin\n q:=p*max(r[k]-max(l[k],i+1)+1,0)/(r[k]-l[k]+1);\n for h:=1 to n do\n if (h<>k) and (h<>j) then\n if h>j then q:=q*max(min(i,r[h])-l[h]+1,0)/(r[h]-l[h]+1) else q:=q*max(min(i-1,r[h])-l[h]+1,0)/(r[h]-l[h]+1);\n ans:=ans+q;\n end;\n for k:=j+1 to n do\n if (i>=l[k]) and (i<=r[k]) then\n begin\n q:=p/(r[k]-l[k]+1);\n for h:=1 to n do\n if (h<>k) and (h<>j) then\n if h>k then q:=q*max(min(i,r[h])-l[h]+1,0)/(r[h]-l[h]+1) else q:=q*max(min(i-1,r[h])-l[h]+1,0)/(r[h]-l[h]+1);\n ans:=ans+q;\n end;\n end;\n end;\n writeln(ans:0:10);\nend.", "positive_code": [{"source_code": " const eps=1e-11; besk=200000000000000008;\n label 1,2,3,4;\n type\n mas=array [-10000..300000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..200000] of int64;mass1=^mas;\n var iii,q1,q2,t0,bb,cc,dd,p1old,p2old,p13,r,l,p1,p2,aaa,bbb,t,sum1,dist,modul,n,m,poz,sum,p3,p4,t4,t5,t6,t1,t2,t3,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,kk,qq,ot,kol,nn,x0,y0,s1,s2,s,imax,smin,dl,besk1:int64;\n start,shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..10000] of char;\n poin:zap; edin:mas;\n vec:array[-100..1000] of zap;\n aa,dp, maskk,d,plb,plc,c,aold,anew,b1,fact, a1,bl,br,a,b:mas;\n pole1, pole:array[-1..3000,-100..3000] of char;\n ss, ss1,ss2:string;\n ch3, ch1,ch2:char;\n ver:array[-10..100000] of extended;\n gr:array[-1..1002,-1..1002] of int64;\n ssn,sss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n hh,beta,pr,aanew,v0,v1,s0:extended;\n lx,ly,rx,ry,z,x1,y1,y,x:array[-1..300000] of int64;\n xm,xn, xxx,yyy:array[-1..100000] of double;\n ugol,per,pp2, ee,yot:extended;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction koled(p:int64):int64; var t,ot:int64;\n begin\n ot:=0; t:=p; while t>0 do begin ot:=ot+t and 1; t:=t shr 1; end;\n koled:=ot;\n end;\n\nfunction vergr(ii,gg:int64):extended; var ppp:extended;\nbegin {writeln(b[ii],' ',a[ii],' == ii= ',ii); }\n if gg>b[ii]then ppp:=0 else if gg<=a[ii]\n then ppp:=1 else ppp:=(b[ii]-gg+1)/(b[ii]-a[ii]+1);\n vergr:=ppp;\n end;\n\n\n\n begin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n); for i:=1 to n do read(a[i],b[i]);\n p:=1;\n { for i:=0 to 32 do writeln(i,' ',koled(i));\n } for i:=1 to n do p:=p*2;\n for mask:=0 to p-1 do if koled(mask)>=2 then\n begin\n p:=mask;\n for i:=1 to n do begin aa[i]:=p and 1; p:=p shr 1; end;\n { for i:=1 to n do write(aa[i],' '); writeln;\n } for k:=0 to 20001 do\n begin\n hh:=1;\n for i:=1 to n do if aa[i]=1 then hh:=hh*vergr(i,k) else hh:=hh*(1-vergr(i,k));\n { writeln(k,' hh= ',hh:0:4); }\n ver[k]:=ver[k]+hh;\n end;\n end;\n { for i:=1 to 3 do for j:=0 to 10 do writeln(i,' ',j,' ',vergr(i,j):0:4); writeln;\n for k:=0 to 10 do writeln(k,' == ',ver[k]:0:4);\n } for k:=0 to 20001 do yot:=yot+k*(ver[k]-ver[k+1]);\n writeln(yot:0:9);\n\n 1: close(output);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of extended;\n re:array[0..10001]of extended;\n rr:array[0..10001,0..30] of longint;\n res,tot,mm:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cc)or((qq[j]=c)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n //for i:=1 to 10000 do\n // for k:=0 to 18 do\n // begin\n // rr[i,k]:=r[i] mod 10;\n // r[i]:=r[i] div 10;\n // end;\n for i:=1 to 10000 do re[i]:=r[i];\n q:=1;\n c:=10000;\n {while c-q>1 do\n begin\n while re[q]<0.5 do inc(q);\n while re[c]<0.5 do dec(c);\n if (q+c) mod 2 = 0 then\n begin\n if re[q] i then p[j,1] := 1 else \n if a[j,2] <= i then p[j,1] := 0 else\n p[j,1] := (a[j,2]-i)/x2; \n\n if (i >= a[j,1]) and (i <= a[j,2]) then p[j,2] := 1/x2 else\n p[j,2] := 0;\n if a[j,1] > i then p[j,3] := 0 else \n if a[j,2] < i then p[j,3] := 1 else\n p[j,3] := (i-a[j,1])/x2; \n \n \n end;\n // for j := 1 to n do begin\n // writeln(p[j,1]:1:5,' ',p[j,2]:1:5,' ',p[j,3]:1:5,' ',p[j,1]+p[j,2]+p[j,3]:1:5);\n // end;\n \n prob := 0;\n\n if (n = 2) then begin\n for j := 1 to 3 do\n for k := 1 to 3 do\n\n if sec(j,k,1000000,1000000,1000000) = 2 then\n prob := prob+p[1,j]*p[2,k];\n end;\n \n if (n = 3) then begin\n for j := 1 to 3 do\n for k := 1 to 3 do\n for l := 1 to 3 do \n if sec(j,k,l,1000000,1000000) = 2 then\n prob := prob+p[1,j]*p[2,k]*p[3,l];\n end;\n \n\n if (n = 4) then begin\n for j := 1 to 3 do\n for k := 1 to 3 do\n for l := 1 to 3 do \n for m := 1 to 3 do \n if sec(j,k,l,m,1000000) = 2 then\n prob := prob+p[1,j]*p[2,k]*p[3,l]*p[4,m];\n end; \n \n if (n = 5) then begin\n for j := 1 to 3 do\n for k := 1 to 3 do\n for l := 1 to 3 do \n for m := 1 to 3 do \n for m1 := 1 to 3 do \n if sec(j,k,l,m,m1) = 2 then\n prob := prob+p[1,j]*p[2,k]*p[3,l]*p[4,m]*p[5,m1];\n end; \n \n //writeln(prob:1:5);\n //writeln('----');\n avg := avg+prob*i;\n\n end;\n \n writeln(avg:1:10);\nend."}, {"source_code": "program problem3;\nuses math;\n\nvar\tn, i, j, k, p: longInt;\n\tl, r: array[ 1..5 ] of longInt;\n\tf: array[ 0..5, 0..5 ] of extended;\n\tans: extended;\n\nbegin\n\treadln( n );\n\tfor i := 1 to n do\n\t\treadln( l[i], r[i] );\n\t\n\tans := 0.0;\n\tfor i := 1 to n do\n\t\tfor j := 1 to r[i] do\n\t\tbegin\n\t\t\tf[0][0] := 1.0;\n\t\t\tfor k := 1 to n do\n\t\t\tbegin\n\t\t\t\tif ( k = i ) then\n\t\t\t\tbegin\n\t\t\t\t\tmove( f[k - 1], f[k], sizeOf( f[k] ) );\n\t\t\t\t\t\n\t\t\t\t\tcontinue;\n\t\t\t\tend;\n\t\t\t\t\n\t\t\t\tfor p := 0 to n do\n\t\t\t\t\tf[k][p] := 0.0;\n\t\t\t\t\n\t\t\t\tf[k][0] := f[k - 1][0] * max( min( r[k] + 1, j ) - l[k], 0 ) / ( r[k] - l[k] + 1 );\n\t\t\t\tif ( l[k] <= j ) and ( j <= r[k] ) then\n\t\t\t\tbegin\n\t\t\t\t\tfor p := 1 to n do\n\t\t\t\t\t\tf[k][p] := ( f[k - 1][p] * ( j - l[k] ) + f[k - 1][p - 1] ) / ( r[k] - l[k] + 1 )\n\t\t\t\tend\n\t\t\t\telse\n\t\t\t\tbegin\n\t\t\t\t\tfor p := 1 to n do\n\t\t\t\t\t\tf[k][p] := f[k - 1][p] * max( min( r[k] + 1, j ) - l[k], 0 ) / ( r[k] - l[k] + 1 );\n\t\t\t\tend;\n\t\t\tend;\n\t\t\t\n\t\t\tfor k := 1 to n do\n\t\t\tbegin\n\t\t\t\tans := ans + f[n][k] * j * ( r[i] - max( j, l[i] - 1 ) ) / ( r[i] - l[i] + 1 );\n\t\t\t\t\n\t\t\t\tif ( j >= l[i] ) then\n\t\t\t\t\tans := ans + f[n][k] * j / ( ( r[i] - l[i] + 1 ) * (k + 1) );\n\t\t\tend;\n\t\tend;\n\t\n\twriteln( ans:0:15 );\nend.\n"}], "negative_code": [{"source_code": " const eps=1e-11; besk=200000000000000008;\n label 1,2,3,4;\n type\n mas=array [-10000..300000] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[-10000..200000] of int64;mass1=^mas;\n var iii,q1,q2,t0,bb,cc,dd,p1old,p2old,p13,r,l,p1,p2,aaa,bbb,t,sum1,dist,modul,n,m,poz,sum,p3,p4,t4,t5,t6,t1,t2,t3,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,kk,qq,ot,kol,nn,x0,y0,s1,s2,s,imax,smin,dl,besk1:int64;\n start,shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;\n sssnew:array[-10..10000] of char;\n poin:zap; edin:mas;\n vec:array[-100..1000] of zap;\n aa,dp, maskk,d,plb,plc,c,aold,anew,b1,fact, a1,bl,br,a,b:mas;\n pole1, pole:array[-1..3000,-100..3000] of char;\n ss, ss1,ss2:string;\n ch3, ch1,ch2:char;\n ver:array[-10..100000] of extended;\n gr:array[-1..1002,-1..1002] of int64;\n ssn,sss:array[-100..1000000] of string;\n ch: char;\n zan,marked:array[-10..1000000] of boolean;\n maxpr:array[0..100000] of string;\n hh,beta,pr,aanew,v0,v1,s0:extended;\n lx,ly,rx,ry,z,x1,y1,y,x:array[-1..300000] of int64;\n xm,xn, xxx,yyy:array[-1..100000] of double;\n ugol,per,pp2, ee,yot:extended;\n flagg,flag2,flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n\n\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction koled(p:int64):int64; var t,ot:int64;\n begin\n ot:=0; t:=p; while t>0 do begin ot:=ot+t and 1; t:=t shr 1; end;\n koled:=ot;\n end;\n\nfunction vergr(ii,gg:int64):extended; var ppp:extended;\nbegin {writeln(b[ii],' ',a[ii],' == ii= ',ii); }\n if gg>b[ii]then ppp:=0 else if gg<=a[ii]\n then ppp:=1 else ppp:=(b[ii]-gg+1)/(b[ii]-a[ii]+1);\n vergr:=ppp;\n end;\n\n\n\n begin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n); for i:=1 to n do read(a[i],b[i]);\n p:=1;\n { for i:=0 to 32 do writeln(i,' ',koled(i));\n } for i:=1 to n do p:=p*2;\n for mask:=0 to p-1 do if koled(mask)>=2 then\n begin\n p:=mask;\n for i:=1 to n do begin aa[i]:=p and 1; p:=p shr 1; end;\n { for i:=1 to n do write(aa[i],' '); writeln;\n } for k:=0 to 10001 do\n begin\n hh:=1;\n for i:=1 to n do if aa[i]=1 then hh:=hh*vergr(i,k) else hh:=hh*(1-vergr(i,k));\n { writeln(k,' hh= ',hh:0:4); }\n ver[k]:=ver[k]+hh;\n end;\n end;\n { for i:=1 to 3 do for j:=0 to 10 do writeln(i,' ',j,' ',vergr(i,j):0:4);\n for k:=0 to 10 do writeln(k,' == ',ver[k]:0:4);\n } for k:=0 to 10000 do yot:=yot-k*(ver[k]-ver[k-1]);\n writeln(yot-1:0:9);\n\n 1: close(output);\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n re:array[0..10001]of extended;\n rr:array[0..10001,0..30] of longint;\n res,tot:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n //for i:=1 to 10000 do\n // for k:=0 to 18 do\n // begin\n // rr[i,k]:=r[i] mod 10;\n // r[i]:=r[i] div 10;\n // end;\n for i:=1 to 10000 do re[i]:=r[i]/tot;\n //q:=1;\n //c:=10000;\n //while c-q>1 do\n // begin\n //\n // end;\n res:=0.0;\n for c:=1 to 10000 do res:=res+re[c]*c;\n writeln(res:0:20);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n res,tot:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n res:=0.0;\n for c:=1 to 10000 do res:=res+(r[c]+0.0)*c;\n res:=res/tot;\n writeln(res:0:12);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n re:array[0..10001]of extended;\n rr:array[0..10001,0..30] of longint;\n res,tot,mm:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cc)or((qq[j]=c)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n //for i:=1 to 10000 do\n // for k:=0 to 18 do\n // begin\n // rr[i,k]:=r[i] mod 10;\n // r[i]:=r[i] div 10;\n // end;\n for i:=1 to 10000 do re[i]:=r[i];\n q:=1;\n c:=10000;\n {while c-q>1 do\n begin\n while re[q]<0.5 do inc(q);\n while re[c]<0.5 do dec(c);\n if (q+c) mod 2 = 0 then\n begin\n if re[q]c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n //for i:=1 to 10000 do\n // for k:=0 to 18 do\n // begin\n // rr[i,k]:=r[i] mod 10;\n // r[i]:=r[i] div 10;\n // end;\n for i:=1 to 10000 do re[i]:=r[i]/tot;\n if (tot>1e19) then runerror(239);\n //q:=1;\n //c:=10000;\n //while c-q>1 do\n // begin\n //\n // end;\n res:=0.0;\n for c:=1 to 10000 do res:=res+re[c]*c;\n writeln(res:0:20);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of longint;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of extended;\n res,cur,tot:extended;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1.0;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1.0; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n res:=0.0;\n for c:=1 to 10000 do res:=res+r[c]*c;\n res:=res/tot;\n writeln(res:0:15);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n res,tot:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n res:=0.0;\n for c:=1 to 10000 do res:=res+(r[c]+0.0)*c;\n res:=res/tot;\n writeln(res:0:20);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n res,tot:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n res:=0.0;\n for c:=1 to 10000 do res:=res+r[c]*c;\n res:=res/tot;\n writeln(res:0:18);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n res,tot:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n res:=0.0;\n for c:=1 to 10000 do res:=res+r[c]*c;\n res:=res/tot;\n writeln(res:0:12);\n //fin;\n end;\n\n\nbegin\nnt:=1;\n//readln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\nconst filename='c';\n oo=maxlongint div 2;\n eps=1e-6;\n eee=1e-21;\n\nvar qq,cc,dd,a,aa:array[0..1000000]of int64;\n qc,he:array[0..2014,0..2014]of longint;\n r:array[0..10001]of int64;\n re:array[0..10001]of extended;\n rr:array[0..10001,0..30] of longint;\n res,tot,mm:extended;\n cur:int64;\n poss:boolean;\n s,ss,sss,s0,s1,s2,s3:string;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;\n test,ll,t,tt:longint;\n b,bb,bbb,b0,b1,b2,b3:boolean;\n\n\n\n\nfunction mx(q,c:longint):longint;\n begin\n if q>c then mx:=q else mx:=c;\n end;\n\n\nfunction mn(q,c:longint):longint;\n begin\n if qi) then\n begin\n cur:=1;\n poss:=true;\n q:=qq[k];\n if c>=q then q:=c+1;\n if (cc[k]k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(ji)or(qi)) then begin poss:=true; cur:=1; end;\n for j:=1 to n do\n if ((j<>k)and(j<>i)) then\n begin\n q:=cc[j];\n if cq)or((qq[j]=q)and(jk)or(qi)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);\n end;\n end;\n\n //for i:=1 to 10000 do\n // for k:=0 to 18 do\n // begin\n // rr[i,k]:=r[i] mod 10;\n // r[i]:=r[i] div 10;\n // end;\n for i:=1 to 10000 do re[i]:=r[i];\n q:=1;\n c:=10000;\n {while c-q>1 do\n begin\n while re[q]<0.5 do inc(q);\n while re[c]<0.5 do dec(c);\n if (q+c) mod 2 = 0 then\n begin\n if re[q] s[i] then\n min := s[i];\n for i := 2 to m do\n if max < b[i] then\n max := b[i];\n ak := r div min;\n ostatok := r mod min;\n p := ak * max;\n p := p + ostatok;\n if p > r then\n write(p)\n else\n write(r);\nend.", "positive_code": [{"source_code": "var z,max,min,i,fl,n,m,r:integer;\n s:array [1..30] of integer;\n b:array [1..30] of integer;\n begin\n fl:=0;\n min:=1000;\n max:=1;\n Read(n,m,r);\n z:=r;\n For i:=1 to n do read(S[i]);\n For i:=1 to m do read(B[i]);\n For i:=1 to n do If s[i]max\n then max:=b[i];\n While r>=min do\n begin\n r:=r-min;\n fl:=fl+1;\n end;\n While fl<>0 do\n begin\n r:=r+max;\n fl:=fl-1;\n end;\n If z>=r\n then Writeln(z)\n else writeln(r);\n end."}, {"source_code": "Program p;\nvar n, m, r, a, b: integer;\n\nbegin\na:=integer.MaxValue;\nread(n, m, r);\nfor var g:=1 to n do\n a:=min(a, readinteger);\nfor var g:=1 to m do\n b:=max(b, readinteger);\nwriteln(max(((r div a *b)+r mod a), r));\nend."}, {"source_code": "var\n a, b : array [1..30] of longint;\n n, m, r, i, j : longint;\nbegin\n readln(n, m, r);\n for i:=1 to n do\n read(a[i]);\n for i:=1 to m do\n read(b[i]);\n for i:=1 to n do\n for j:=1 to n do\n if a[i]b[j] then\n swap(b[i],b[j]);\n writeln(max(r,r mod a[1] + (r div a[1]) * b[1]));\nend."}, {"source_code": "var ma,m,mi,n,r,i,x:longint;\nbegin\n read(n,m,r);\n mi:=1000000;\n for i:=1 to n do\n begin\n read(x);\n if xma then ma:=x;\n end;\n if mi0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p;\n end;\n } function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a:int64;k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else\n begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;\n\nend;\n\nfunction dis(i,j:longint):longint;\nbegin\n dis:=min(abs(i-j),26-abs(i-j));\n\nend;\n\n\n\nbegin\n\n { assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n,m,vol);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n\n for step:=1 to vol do\n begin\n p:=0;\n for i:=1 to n do\n begin\n t:=step-a[i];\n if t>=0 then p:=max(p,x[t]+1);\n\n end;\n\n x[step]:=p;\n\n end;\n\n { for i:=1 to vol do write(x[i],' '); writeln;\n } pp:=0;\n for i:=1 to m do pp:=max(pp,b[i]);\n\n for i:=0 to vol do\n begin\n p:=(vol-i)+x[i]*pp;\n ot:=max(ot,p);\n { writeln(i,' ',p); }\n end;\n\n writeln(ot);\n\n\n\n\n\n 1: close(output);\nend.\n"}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar n,m,rub,i,min,j,kol,k,max:integer;\nbuy,prod:array [1..31] of Integer;\nbegin\nReadln(n,m,rub);\nmax:=0;\nmin:=10000000;\nk:=rub;\nfor i:=1 to n do\nRead(buy[i]);\nReadln;\nfor i:=1 to m do\nRead(prod[i]);\nreadln;\nfor i:=1 to n do\nif buy[i]=buy[j] do\nbegin\ninc(kol);\nDec(k,buy[j]);\nend;\nfor i:=1 to m do\nif prod[i]>max then begin max:=prod[i]; j:=i end;\nwhile kol>0 do\nbegin\nInc(k,max);\nDec(kol);\nend;\nif k>rub then Writeln(k) else Writeln(rub);\nReadln;\nend."}, {"source_code": "program arbit_act;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n n, m, r, min, max, pr, r1 : integer;\n\n function minim(a, b : integer) : integer;\n begin\n if(a > b) then\n minim := b\n else\n minim := a;\n end;\n\n function maxim(a, b : integer) : integer;\n begin\n if(a > b) then\n maxim := a\n else\n maxim := b;\n end;\n\nbegin\n readln(n, m, r);\n r1 := r;\n read(pr);\n min := pr;\n dec(n);\n\n while(n > 0) do begin\n read(pr);\n min := minim(min, pr);\n dec(n);\n end;\n\n writeln;\n read(pr);\n max := pr;\n dec(m);\n\n while(m > 0) do begin\n read(pr);\n max := maxim(max, pr);\n dec(m);\n end;\n\n writeln;\n r := r mod min + max * (r div min);\n if(r < r1) then\n writeln(r1)\n else\n writeln(r);\n readln;\n readln;\nend.\n"}, {"source_code": "program zz_a;\n\n{$APPTYPE CONSOLE}\n\n const size=1000;\n var a,b,mas:array[1..size] of longint;\n i,j,n,m,t,max,ost:longint;\nprocedure quicksort(first,last:longint);\n var i2,j2:longint; r2,w:longint;\nbegin\n i2:=first;\n j2:=last;\n r2:=mas[(first+last)div 2];\n repeat\n while mas[i2]r2 do dec(j2);\n if i2<=j2 then\n begin\n w:=mas[i2];\n mas[i2]:=mas[j2];\n mas[j2]:=w;\n inc(i2);\n dec(j2);\n end\n until i2>j2;\n if first=b[m] then writeln(t) else\n begin\n max:=t div a[1];\n ost:=t mod a[1];\n t:=max*b[m]+ost;\n writeln(t)\n end;\n readln;\nend.\n "}, {"source_code": "Program StockArbitraging;\nuses math;\nType arr=array[0..57] of longint;\nvar a,b:arr; n,m,r,d,i:longint;\nProcedure Sort(l,r:longint; var c:arr);\nvar i,j,x,tmp:longint;\nbegin i:=l; j:=r; x:=c[(i+j) div 2];\n repeat\n while c[i]x do dec(j);\n if i<=j then begin\n tmp:=c[i]; c[i]:=c[j]; c[j]:=tmp;\n inc(i); dec(j);\n end;\n until i>j;\n if li then sort(i,r,c);\nend;\nbegin //assign(input,'1150A.inp'); reset(input);\n //assign(output,'1150A.out'); rewrite(output);\n readln(n,m,r);\n for i:=1 to n do read(a[i]);\n for i:=1 to m do read(b[i]);\n Sort(1,n,a); Sort(1,m,b);\n d:=(r div a[1]*b[m])+(r mod a[1]);\n writeln(max(r,d));\n //close(input); close(output);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b:array[0..100000]of longint;\n n,m,r,i,max,s,min,s1:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m,r);\n max:=low(longint);\n min:=high(longint);\n for i:=1 to n do\n begin\n read(f,a[i]);\n if a[i]max then max:=b[i];\n end;\n\n assign(f,fo);rewrite(f);\n s:=r div min;\n s1:=r mod min;\n if (s*max+s1)>r then\n write(f,s*max+s1)\n else\n write(f,r);\n close(f);\nend.\n\n\n"}, {"source_code": "Var n,m,r,min,max,a,i,srem,rem:Longint;\nBegin\n Readln(n,m,r); min:=high(min); max:=low(max);\n For i:=1 to n do begin\n Read(a);\n if amax then max:=a;\n End;\n srem:=rem*max;\n If r-rem*min+srem>r then writeln(r-rem*min+srem) else writeln(r);\nEnd."}, {"source_code": "var\n n, m, i, s, b, mins, maxb, k, r: longint;\n\nfunction max(a, b: longint): longint;\nbegin\n if a > b then max := a else max := b;\nend;\n\nbegin\n read(n, m, r);\n mins := 10000;\n for i := 1 to n do\n begin\n read(s);\n if s < mins then mins := s;\n end;\n maxb := 0;\n for i := 1 to m do\n begin\n read(b);\n if b > maxb then maxb := b;\n end;\n k := r div mins;\n writeln(max(((r mod mins) + k * maxb), r));\nend."}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r:integer;\n rez:int64;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to m do\n begin\n if maxbmins then\n rez:=(r div mins)*maxb+(r mod mins)\n else rez:=r;\n\n writeln(rez);\n\n readln;\n\nend. "}, {"source_code": "var\nans,kol,min,max,n,m,r,i:longint;\ns,b:array[-10..1000000]of longint;\nbegin\nreadln(n,m,r);\nfor i:=1 to n-1 do read(s[i]);\nreadln(s[n]);\nfor i:=1 to m do read(b[i]);\n\nmin:=20000;\nfor i:=1 to n do if s[i]max then max:=b[i];\nend;\nans:=r-kol*min + max*kol;\nif r>ans then ans:=r;\nwriteln(ans);\nend."}, {"source_code": "const fi='';\nvar f:text;\na,b:array[1..10000]of longint;\ni,j,n,m,s,t,r,d:longint;\nbegin\n assign(f,fi);\n reset(f);\n read(f,n,m,r);\n t:=r;\n s:=high(longint);\n for i:=1 to n do\n begin\n read(f,a[i]);\n if s>a[i] then s:=a[i];\n end;\n d:=t div s;\n t:=t-s*d;\n s:=low(longint);\n for j:=1 to m do\n begin\n read(f,b[i]);\n if s=ms then\n begin\n writeln(r);\n halt(0);\n end;\n b:=r;\n hb:=b div mb * mb;\n b:=b-hb;\n hb:=hb div mb * ms;\n b:=b+hb;\n writeln(b);\n\nend."}, {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m,r:longint;\n s,b:array[1..200000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i,res1,res2,t1,t2,mi,ma:longint;\n begin\n read(fi,n,m,r);\n for i:=1 to n do read(fi,s[i]);\n for i:=1 to m do read(fi,b[i]);\n res1:=r;\n mi:=maxlongint;\n for i:=1 to n do mi:=min(mi,s[i]);\n ma:=0;\n for i:=1 to m do ma:=max(ma,b[i]);\n t1:=r div mi;\n t2:=r mod mi;\n res2:=t1*ma+t2;\n writeln(fo,max(res1,res2));\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var i:longint;\n begin\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nBEGIN\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n randomize;\n input;\n process;\n close(fi);close(fo);\nEND.\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n"}, {"source_code": "Var i , n , m , r , tmp , Ans , Mi , Ma : Longint;\n D : Array [-100000..100000] of Longint;\n \n{Procedure Sort(l , r : Longint);\n Var i , j , x , y : Longint;\n Begin\n i := l; j := r;\n x := A[(l+r) div 2];\n Repeat\n While A[i] < x do Inc(i);\n While x < A[j] do Dec(j);\n If not (i > j) then\n Begin\n y := A[i]; A[i] := A[j]; A[j] := y;\n Inc(i); Dec(j);\n End;\n Until i > j;\n If l < j then sort(l , j);\n If i < r then sort(i , r);\n End;}\nFunction Min(x , y : Longint) : Longint;\n Begin If x < y then Exit(x) else Exit(y); End;\nFunction Max(x , y : Longint) : Longint;\n Begin If x > y then Exit(x) else Exit(y); End;\nProcedure Swap(Var x , y : Longint);\n Var xy : Longint;\n Begin xy := x; x := y; y := xy; End; \n{Procedure Get1;\n Var d : Byte = 0;\n Begin\n Readln(S); S := S + ' ';\n For i := 1 to Length(S) do\n Begin\n If S[i] <> ' ' then tmp_str := tmp_str + S[i];\n If S[i] = ' ' then Begin Inc(d); A[d] := tmp_str; tmp_str := ''; End;\n End;\n End;}\n \nBegin \n Mi := High(Longint); Ma := Low(Longint);\n Readln(n , m , r);\n For i := 1 to n do Begin Read(tmp); Mi := Min(Mi , tmp); End;\n For i := 1 to m do Begin Read(tmp); Ma := Max(Ma , tmp); End;\n If Ma <= Mi then Ans := r else Ans := r + r div Mi * (Ma - Mi); //r mod Mi + r div Mi * Ma;\n Writeln(Ans);\nEnd."}, {"source_code": "var\n\tn, m, r, x, y, z: longint;\n\ta, b : array [1..30] of longint;\n\t\nbegin\n\t\n\tread(n, m ,r);\n\ty := 1000;\n\tfor var i := 1 to n do\n\tbegin\n\t\tread(x);\n\t\ty := min(y, x);\n\tend;\n\tfor var i := 1 to m do\n\tbegin\n\t\tread(x);\n\t\tz := max(z, x);\n\tend;\n\t\n\twriteln(max(r, r mod y + (r div y) * z));\n\t\nend.\n"}, {"source_code": "Var\n n, m, r, min1, max1: Int64;\n s: Array [1..30] of Int64;\n b: Array [1..30] of Int64;\n\nBegin\n min1 := 1000000;\n Read(n, m, r);\n For Var i := 1 to n do Begin\n Read(s[i]);\n If s[i] < min1 then\n min1 := s[i]\n End;\n For Var i := 1 to m do Begin\n Read(b[i]);\n If b[i] > max1 then\n max1 := b[i]\n End;\n Write(max(r, r - min1*(r div min1) + max1*(r div min1)))\nEnd."}, {"source_code": "Program Fun;\nVAR n,m,r,i,j,max,s,current,k:int64; a,b:array[1..31] of int64;\nBegin\n\nReadln(n,m,s);\nfor i:=1 to n do\nBegin\nRead(a[i]);\nend;\nReadln;\nfor i:=1 to m do\nBegin\nRead(b[i]);\nend;\n\nfor i:=1 to n - 1 do\nBegin\nfor j:=1 to n - 1 do\nBegin\nif (a[j] > a[j + 1]) then Begin r:=a[j]; a[j]:=a[j + 1]; a[j + 1]:=r; end;\nend;\nend;\n\nmax:=0;\nfor i:=1 to m do\nBegin\nif (b[i] > max) then max:=b[i];\nend;\n\ni:=1;\ncurrent:=s;\nk:=0;\n\nwhile (i <= n) and (a[i] < max) and (current >= a[i]) do\nBegin\nk:=k + (current div a[i]);\ncurrent:=current - a[i]*(current div a[i]);\ni:=i + 1;\nend;\n\nWriteln(current + k*max);\n\nReadln;\nEND."}, {"source_code": "var n,m,r,nn,mm,min,max,rn:integer;\nsi:array[1..30]of integer;\nBi:array[1..30]of integer;\nbegin\n readln(n,m,r);min:=1001;\n while nnmax then max:=bi[mm];\n end;\n if max>min then begin\n rn:=r div min;\n r:=r-rn*min;\n r:=r+rn*max;\n end;\n writeln(r);\nend."}], "negative_code": [{"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b:array[0..100000]of longint;\n n,m,r,i,max,s,min:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m,r);\n max:=low(longint);\n min:=high(longint);\n for i:=1 to n do\n begin\n read(f,a[i]);\n if a[i]max then max:=b[i];\n end;\n\n assign(f,fo);rewrite(f);\n s:=r div min;\n if s*max>r then\n write(f,s*max)\n else\n write(f,r);\n close(f);\nend.\n\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b:array[0..100000]of longint;\n n,m,r,i,max,s,min,s1:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m,r);\n max:=low(longint);\n min:=high(longint);\n for i:=1 to n do\n begin\n read(f,a[i]);\n if a[i]max then max:=b[i];\n end;\n\n assign(f,fo);rewrite(f);\n s:=r div min;\n s1:=r mod min;\n if (s*max+1)>r then\n write(f,s*max+1)\n else\n write(f,r);\n close(f);\nend.\n\n\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b:array[0..100000]of longint;\n n,m,r,i,max,s,min,s1:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,n,m,r);\n max:=low(longint);\n min:=high(longint);\n for i:=1 to n do\n begin\n read(f,a[i]);\n if a[i]max then max:=b[i];\n end;\n\n assign(f,fo);rewrite(f);\n s:=r div min;\n s1:=r mod min;\n if (s*max)>r then\n write(f,s*max+1)\n else\n write(f,r);\n close(f);\nend.\n\n\n"}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r,rez:integer;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to n do\n begin\n if maxbmins then\n rez:=(r div mins)*maxb+(r mod mins)\n else rez:=r;\n\n writeln(rez);\n\n readln;\n\nend. "}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r:integer;\n rez:int64;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to n do\n begin\n if maxbmins then\n rez:=(r div mins)*maxb+(r mod mins)\n else rez:=r;\n\n writeln(rez);\n\n readln;\n\nend. "}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r,rez:integer;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to n do\n begin\n if maxbmins then\n rez:=(r div mins)*maxb+(r mod mins)\n else rez:=r;\n\n writeln(rez);\n readln;\n\nend. "}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r,br,sh:integer;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to n do\n begin\n if maxbmins then\n begin\n sh:=r div mins;\n r:=r mod mins;\n br:=sh*maxb+r;\n end;\n writeln(br);\n readln;\n\nend."}, {"source_code": "program berza;\n var j,mins,maxb,i,n,m,r,br,sh:integer;\n s:array[1..1000] of integer;\n b:array[1..1000]of integer;\nbegin\n read(n,m,r);\n\n for i:=1 to n do\n read(s[i]);\n\n for i:=1 to m do\n read(b[i]);\n\n mins:=s[1];\n maxb:=b[1];\n\n for i:=1 to n do\n begin\n if mins>s[i] then\n mins:=s[i];\n end;\n\n for j:=1 to n do\n begin\n if maxbmins then\n begin\n sh:=r div mins;\n r:=r mod mins;\n br:=sh*maxb+r;\n end\n else br:=r;\n writeln(br);\n readln;\n\nend. "}, {"source_code": "var n,m,r,nn,mm,min,max,rn:integer;\nsi:array[1..30]of integer;\nBi:array[1..30]of integer;\nbegin\n read(n,m,r);min:=1001;\n while nnmax then max:=bi[mm];\n end;\n r:=r+rn*max;\n writeln(r);\nend."}, {"source_code": "var n,m,r,nn,mm,min,max,rn:integer;\nsi:array[1..30]of integer;\nBi:array[1..30]of integer;\nbegin\n readln(n,m,r);min:=1001;\n while nnmax then max:=bi[mm];\n end;\n r:=r+rn*max;\n writeln(r);\nend."}, {"source_code": "var n,m,r,nn,mm,min,max,rn:integer;\nsi:array[1..30]of integer;\nBi:array[1..30]of integer;\nbegin\n readln(n,m,r);min:=1001;\n while nnmax then max:=bi[mm];\n end;\n if max>min then begin\n rn:=r div min;\n r:=r+rn*max;\n end;\n writeln(r);\nend."}, {"source_code": "Program p;\nvar n, m, r, a, b: integer;\n\nbegin\na:=integer.MaxValue;\nread(n, m, r);\nfor var g:=1 to n do\n a:=min(a, readinteger);\nfor var g:=1 to m do\n b:=max(b, readinteger);\nwriteln((r div a *b)+r mod a)\nend."}], "src_uid": "42f25d492bddc12d3d89d39315d63cb9"} {"source_code": "{const fi='checking.inp';\n fo='checking.out'; }\nvar n,m,s:longint;\n\n{------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend;}\n{------------------------------}\n{procedure closefiles;\nbegin\n close(input);close(output);\nend;}\n{-------------------------}\nprocedure stdin;\nvar i:longint;\nbegin\n read(n,m);\nend;\n{-------------------------------------}\nprocedure process;\nvar r:longint;\nbegin\n s:=n;\n while n>=m do\n begin\n r:=n mod m;\n n:=n div m;\n s:=s+n;\n n:=n+r;\n end;\n writeln(s);\nend;\n{-------------------------------------------}\nBEGIN\n { openfiles;}\n stdin;\n process;\n { closefiles;}\nEND.\n", "positive_code": [{"source_code": "Var N , M : byte;\n S : longint;\nbegin\n readln(n,m);\n s:=n;\n While n div m<>0 do\n begin\n s:=s+n div m;\n n:=n div m+n mod m;\n end;\n writeln(s);\nend."}, {"source_code": "program vas;\nvar n,m,i,g,kq:byte;\nbegin\n readln(n,m);\n g:=1; kq:=0; i:=1;\n while n>0 do\n begin\n if g=m*i then\n begin\n inc(n);\n inc(i);\n end;\n inc(g);\n dec(n);\n inc(kq);\n end;\n writeln(kq);\nend."}, {"source_code": "var n,m:int64;\ni,c,c1:longint;\nbegin\nreadln(n,m);\nfor i:=1 to n do \nbegin\nif n>0 then begin dec(n); inc(c); end;\nif i mod m = 0 then inc(c1);\nend;\nwhile true do \nbegin\nif c1> 0 then begin dec(c1); inc(c); if c mod m = 0 then inc(c1) end else break; \nend;\nwriteln(c);\nend."}, {"source_code": "var n,m,k:byte;\nbegin\nread(n); read(m);\nk:=0;\nwhile (n>=m) and (n>0) do begin\n inc(k,m);\n n:=n-m+1; end;\nif n=m) do\n begin\n dec(k,m);\n inc(k);\n inc(j);\n end;\n writeln(n+j);\nend.\n"}, {"source_code": "program socks(input,output);\n const max=100;\n var n,m,k:integer;\n begin\n readln(n,m);\n k:=0;\n while n<>0 do\n begin\n k:=k+1;\n n:=n-1;\n if k mod m=0 then n:=n+1;\n end;\n writeln(k);\n end.\n"}, {"source_code": "var n,m,k,l:integer;\no:boolean;\nbegin\no:=true;\nread(n,m);\nk:=0;\nl:=k;\nwhile o=true do begin\nk:=k+1;\nl:=l+1;\nn:=n-1;\nif (l mod m = 0) then n:=n+1;\nif n=0 then o:=false;\nend;\nwriteln(l);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst inp = '';\n outp = '';\nvar fi, fo: text;\n n, m : longint;\n\nprocedure INPUT;\nbegin\n assign(fi,inp); assign(fo,outp);\n reset(fi); rewrite(fo);\n readln(fi,n,m);\nend;\n\nprocedure Solve;\nvar kq: longint;\n tmp : longint;\nbegin\n kq:= n;\n while n >= m do\n begin\n tmp:= n mod m;\n n:= n div m;\n kq:= kq + n;\n n:= n + tmp;\n end;\n writeln(fo,kq);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "var n, m, ans, i:longint; \nbegin\nreadln(n, m);\nans:=n; \ni:=1; \nwhile (m*i<=ans) do \n begin\n inc(i);\n inc(ans);\n end;\nwriteln(ans);\nend."}, {"source_code": "var n,m : integer;\nh : integer;\nremain : integer;\nbegin\n readln(n,m);\n h := 0;\n while n > 0 do\n begin\n inc(h);\n dec(n);\n if h mod m = 0 then inc(h);\n if n mod m = 0 then begin h := h + n; n := n div m; end;\n\n end;\n writeln(h);\n readln;\nend.\n"}, {"source_code": "VAR m,n,res:longint;\nbegin\nread(n,m);\nres:=n+((n-1) div (m-1));\n\nwrite(res);\n\nend.\n"}, {"source_code": "program rterh;\n\nvar\ni,n,m,day:integer;\nbegin\nread(n,m);\nwhile n>0 do\nbegin\nday:= day+1;\nif day mod m = 0 then begin n:=n+1; end;\nn := n-1;\n\nend;\nwrite(day);\n\nend.\n"}, {"source_code": "var\nn,m,ans:longint;\nbegin\nreadln(n,m);\nwhile n>0 do begin\ndec(n);\ninc(ans);\nif ans mod m = 0 then inc(n);\nend;\nwriteln(ans)\nend."}, {"source_code": "var\nn, m, day: byte;\n\nbegin\n readln(n ,m);\n day:= 0;\n repeat\n day += 1;\n\n n -= 1;\n if (day <> 0) and (day mod m = 0) and (n <> - 1)\n then n += 1;\n\n until n = 0;\n writeln(day);\nend."}, {"source_code": "Program _1;\nVar\n n,m,max:longint;\nBegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,m);\n max:=0;\n max:=n;\n while (n>=m)or(max mod m=0) do begin\n inc(max);\n dec(n,m);\n inc(n);\n end;\n write(max);\n {close(input);\n close(output);}\nEnd.\n"}, {"source_code": "VAR\nA,M,J,I:LONGINT;\nBEGIN\nREAD(A,M);\nJ:=M;\nREPEAT\nI:=I+1;\nA:=A-1;\nM:=M-1;\nIF M=0 THEN\nBEGIN\n A:=A+1;\n M:=J;\nEND;\nUNTIL A=0;\nWRITE(I);\nEND."}, {"source_code": "var\n n, m, i, j: integer;\n\n\nbegin\n readln(n, m);\n while n <> 0 do \n begin\n n := n - 1;\n i := i + 1;\n j := j + 1;\n if i = m then begin\n n := n + 1;\n i := i - m;\n end;\n end;\n Writeln(j);\nend."}, {"source_code": "program cfcarape;\nvar n,m,n2,n1,pom:integer;\n\nbegin\nread(n,m);\nn2:=n;\nn1:=0;\nwhile n2>n1 do\n begin\n pom:=n2;\n n2:=n2+(n2 div m)-(n1 div m);\n n1:=pom;\n end;\nwriteln(n2);\nend."}, {"source_code": "var\nn,m,s:longint;\nbegin\nreadln(n,m);\ns:=0;\nwhile n>0 do\n begin\n inc(s);\n dec(n);\n if s mod m=0 then inc(n);\n end;\nwriteln(s);\nend."}, {"source_code": "var\n n,m,i:longint;\nbegin\n readln(n,m);\n while n>0 do\n begin\n inc(i);\n dec(n);\n if i mod m=0 then inc(i);\n end;\n write(i);\nend."}, {"source_code": "var\n n,m:longint;\nbegin\n read(n,m);\n write(n+(n-1) div (m-1));\nend."}, {"source_code": "var\n i,j,n,m:longint;\nbegin\n readln(n,m);\n repeat\n inc(i);\n if i mod m=0 then inc(n);\n dec(n);\n if n=0 then break;\n until false;\n writeln(i);\nend."}, {"source_code": "program vasya;\nvar n,m:integer;\n begin\n read(n,m);\n n:=(n*m-1) div (m-1);\n write(n);\n end."}, {"source_code": "var n,m,i:longint;\nbegin\n read(n,m);\n i:=0;\n repeat\n dec(n);\n inc(i);\n if i mod m =0 then inc(n);\n until n=0;\n writeln(i);\n readln;\n readln;\nend.\n"}, {"source_code": "var i,k,n,m,l:longint;\n begin\n readln(n,m);\n {if n = m then k:=0 else k:=1;}\n k:=0;\n while n>0 do\n begin\n inc(k);\n\n dec(n);\n if (k mod m = 0) then inc(n);\n\n end;\n WriteLn(k);\n end."}, {"source_code": "var n,m:shortint;\n d:integer;\nbegin\n readln(n,m);\n d:=0;\n while n>0 do\n begin\n inc(d);\n if d mod m<>0 then dec(n);\n end;\n writeln(d);\nend."}, {"source_code": "var\n i,r,m,n,d:longint;\nbegin\n readln(n,m);\n while n+r>=m do\n begin\n d:=d+n;\n r:=r+n mod m;\n n:=n div m;\n if r>=m then\n begin\n n:=n+1;\n r:=r-m;\n end;\n end;\n d:=d+n;\n writeln(d);\nend."}, {"source_code": "var\n n,m:longint;\nbegin\n read(n,m);\n writeln(n+(n-1) div (m-1));\nend."}, {"source_code": "var n, m, i, dr, st, k:longint;\nbegin readln(n, m); st:=1; dr:=n; k:=1;\n while k<>0 do begin k:=0;\n For i:=st to dr do\n if i mod m=0 then begin k:=k+1;\n end;\n st:=dr+1; dr:=dr+k;\n end;\n writeln(dr);\nend.\n\n\n\n"}, {"source_code": "var n,m :int64;\nbegin\nread(n, m);\nwrite((n * m - 1) div (m - 1))\nend.\n"}, {"source_code": "program Project1;\n{$APPTYPE CONSOLE}\nuses SysUtils, math;\n\nvar k,n,m,a,b,i,j,t: integer;\nbegin\n readln(a,b);\n k:=0;\n while a>0 do\n begin\n inc(k);\n dec(a);\n if k mod b = 0 then inc(a);\n end;\n writeln(k);\n readln;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\nuses SysUtils;\nvar n,m,i,j,l,ans:longint;\nbegin\n readln(n,m);\n while (true) do\n begin\n dec(n);\n if (n<0) then break;\n inc(ans);\n if (ans mod m=0) then inc(n);\n end;\n writeln(ans);\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\n\nuses\n SysUtils;\n\nvar\n a, b: integer;\n ans: integer;\nbegin\n read(a, b);\n\n ans := a;\n\n while a div b <> 0 do\n begin\n ans := ans + a div b;\n a := a div b + a mod b;\n end;\n\n Writeln(ans);\nend.\n"}, {"source_code": "program Progs;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\n\ntype\n Int32 = Integer;\nprocedure Solve;\nvar\n N, M: Int32;\n LResult: Int32;\nbegin\n Readln(N, M);\n\n LResult := 0;\n while N > 0 do\n begin\n Inc(LResult);\n Dec(N);\n if LResult mod M = 0 then\n Inc(N);\n end;\n\n Writeln(LResult);\nend;\n\nbegin\n Solve;\n Readln;\nend.\n"}, {"source_code": "var\nn,m,d:int64;\nbegin\n read(n,m);\n while n>0 do\n begin\n n:=n-1;\n d:=d+1;\n if d mod m =0 then\n n:=n+1;\n end;\n write(d);\nend."}, {"source_code": "program hometask_108;\nvar n, m, i: integer;\nbegin\n readln(n, m);\n i := 1;\n while n > 0 do begin\n if i mod m = 0 then n := n + 1;\n n := n - 1;\n i := i + 1;\n end;\n write(i - 1);\nend."}, {"source_code": "var\n\tn, m, d, p: int64;\n\tx, y: array[1..100000] of integer;\n\t\nbegin\n\t\n\treadln(n, m);\n\twhile (n > 0) do\n\tbegin\n\t\td += 1;\n\t\tn -= 1;\n\t\tif (d mod m = 0) then\n\t\tbegin\n\t\t\td += 1;\n\t\t\tcontinue;\n\t\tend;\n\tend;\n\t\n\twriteln(d);\n\t\nend.\n"}, {"source_code": "var\n\tn, m, d, p: int64;\n\tx, y: array[1..100000] of integer;\n\t\nbegin\n\t\n\treadln(n, m);\n\twriteln(n + (abs(n-1) div abs(m-1)));\n\t\nend.\n"}, {"source_code": "var n, i, kdn, m : Integer; \nbegin\n read(n);\n readln(m);\n kdn:=0;\n i:=0;\n while n>0 do\n begin\n n:=n-1;\n kdn:=kdn+1;\n i:=i+1;\n If i mod m = 0 then n:=n+1;\n end;\n writeln(kdn);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\n{$R *.res}\n\nuses\n SysUtils;\n\nvar\n m,i,n,k,l,j:Integer;\nbegin\n Readln(n,m);\n k:=1;\n repeat\n dec(n);\n if k mod m=0 then inc (n);\n inc (k);\n until n<=0;\n\n Writeln(k-1);\n Readln(n);\n\n\nend.\n"}, {"source_code": "var n, m: byte;\ndays:integer;\nbegin\n read(n, m);\n days:=0;\n while(n>0) do begin\n days:=days+1;\n n:=n-1;\n if days mod m =0 then n:=n+1;\n end;\n write(days);\nend."}, {"source_code": "var i,j,n,m:int64; begin\nread(n,m);\nwhile i<>n+j do begin inc(i); if i mod m=0 then inc(j); end;\nwriteln(n+j);\nend."}, {"source_code": "program Alpha;\n\nvar\n n, m, count : integer;\n\nbegin\n read(n,m);\n count := 0;\n repeat\n n := n - 1;\n count := count + 1;\n if count mod m = 0 then n := n + 1;\n until n = 0;\n writeln (count);\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar a,b,kol:integer;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n read(a);\n Readln(b);\n kol:=a;\n while a>=b do begin\n kol:=kol+a div b;\n a:=a div b + a mod b; end;\n Writeln(kol);\n\n\nend.\n "}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nread(z,x);\nwriteln((z*x-1) div (x-1));\nend."}, {"source_code": "Var\n n, m, tp, Ans: Int64;\n\nBegin\n Ans := 1;\n Read(n, m);\n While True do Begin\n If n = 0 then Begin\n Write(Ans - 1);\n Exit\n End;\n n -= 1;\n If Ans mod m = 0 then\n n += 1;\n Ans += 1\n End\nEnd."}, {"source_code": "var n,m:integer;\nsum:dword;\n\nbegin\nreadln(n,m);\nwhile (n>0) do\n begin\n inc(sum);\n if (sum mod m=0) then inc(n);\n dec(n);\n end;\nwriteln(sum);\nend."}, {"source_code": "var\n n, m, i, k: integer;\n\nbegin\n readln(n, m);\n i := 0;\n k := 1;\n while k = 1 do\n begin\n if n > 0 then\n begin\n n := n - 1;\n i := i + 1;\n end\n else\n k := 0;\n if i mod m = 0 then\n n := n + 1;\n end;\n write(i);\nend."}, {"source_code": "begin\n var a, b, c, i: integer;\n readln(a, b);\n while(i < a) do\n begin\n i += 1;\n c += 1;\n if(c = b) then begin\n a += 1;\n c := 0;\n end;\n end;\n writeln(a);\nend."}, {"source_code": "var n,m,x,k:longint;\nbegin\n read(n,m); k:=0;\n repeat\n x:=(n div m)-k;\n inc(k,x);\n if x=0 then break;\n inc(n,x);\n until False;\n writeln(n);\nend."}, {"source_code": "Var a, c,g, b:int64;\nbegin\n read(a, b) ;\n G:=a;\n Repeat\n C:=c+1;\n If c mod b =0 then begin a:=a+1;g:=g+1;end;\n G:=g-1;\n Until g=0;\n Writeln(a) ;\nend.\n"}, {"source_code": "{const fi='checking1.inp';\n fo='checking1.out'; }\nvar m,n,s,nho:longint;\n{-----------------------------------}\n{procedure openfiles;\nbegin\n assign(input,fi);\n reset(input);\n assign(output,fo);\n rewrite(output);\nend; }\n{-----------------------------------}\n{procedure closefiles;\nbegin\n close(input);\n close(output);\nend;}\n{------------------------------------------------}\nprocedure stdin;\nbegin\n read(n,m);\nend;\n{-------------------------------------}\nprocedure socks(a:longint);\nvar tmp:longint;\nbegin\n while a>0 do\n begin\n nho:=nho+a mod m;\n a:=a div m;\n s:=s+a;\n end;\n tmp:=nho;\n if tmp>=m then\n begin\n nho:=0;\n socks(tmp);\n end;\nend;\n{--------------------------------------}\nprocedure process;\nbegin\n s:=n;\n socks(n);\n writeln(s);\n\nend;\n{----------------------------------------------}\nBEGIN\n { openfiles; }\n stdin;\n process;\n { closefiles;}\nEND.\n"}, {"source_code": "program primer;\nvar n,m,i:longint;\n\nBEGIN\nread(n,m);\ni:=1;\nwhile n<>0 do\n begin\n n:=n-1;\n if i mod m=0 then n:=n+1;\n i:=i+1;\n end;\n write(i-1);\nend."}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else\n Begin\n if ((n = 10) and (m = 9)) or ((n = 95) and (m = 16)) or ((n = 99) and (m = 74)) then\n writeln((n + n / (m - 1)) : 0 : 0)\n else\n writeln((n + n / (m - 1) - 1) : 0 : 0);\n End;\n\n readln;\nEnd."}, {"source_code": "Program trang;\nvar m,n,sum,k:int64;\nbegin\n read(n,m);\n sum:=0;\n k:=0;\n repeat\n n:=n-1;\n sum:=sum+1;\n k:=k+1;\n if (k>0) and (k mod m=0) then n:=n+1;\n until n<=0;\n write(sum);\nend.\n"}, {"source_code": "var n,m,count:integer;\nbegin\ncount:=0;\nreadln(n,m);\nwhile (n div m)<>0 do\nbegin\ncount:=count+(n div m)*m;\nn:=n-(n div m)*(m-1);\nend;\nwriteln(count+n);\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n n, m, sum, x, i : longint;\nBegin\n ReadLn(n, m);\n for i := 1 to n do\n begin\n inc(sum);\n inc(x);\n sum := sum + x div m;\n if x mod m = 0 then x := 1;\n end;\n WriteLn(sum);\nEnd."}, {"source_code": "var\n tmp,c,i,n,m:integer;\nbegin\n readln(n,m);\n tmp:=n; c:=0;\n i:=0;\n while (tmp>0) do begin\n inc(i);\n dec(tmp);\n inc(c);\n if (i mod m=0) then inc(tmp);\n end;\n writeln(c);\nend. "}, {"source_code": "program socks;\nvar\norgsocks,aday,daycount:integer;\nbegin\nreadln(orgsocks,aday);\ndaycount:=0;\nrepeat\ndaycount:=daycount + 1;\norgsocks:=orgsocks - 1;\nif daycount mod aday = 0\nthen orgsocks:=orgsocks + 1\nuntil orgsocks = 0;\nwriteln(daycount)\nend."}, {"source_code": "var\n i,n,m,j,dem:longint;\n\nbegin\n\n readln(n,m);\n repeat\n\n dec(n);\n inc(dem);\n inc(j);\n if j = m then\n begin\n inc(n);\n j:=0;\n end;\n\n until n = 0;\n write(dem);\n readln;\nend."}, {"source_code": "var n,m,day,sock,t:longint;\nbegin\n readln(n,m);\n writeln((n*m-1) div (m-1));\n readln;\nend.\n"}, {"source_code": "var ans, n, m, day, help, i : longint;\nbegin\n readln(n, m);\n help := n;\n while help <> 0 do\n begin\n inc(day);\n dec(help);\n if day mod m = 0 then\n inc(help);\n end;\n \n writeln(day);\nend.\n"}, {"source_code": "var i,n,m: integer;\nbegin\n readln(n,m);\n i:=1;\n while i<>n+i div m do inc(i);\n writeln(i);\nend.\n"}, {"source_code": "uses math;\n\nvar n, m: longInt;\n\nbegin\n readln( n, m );\n writeln( n + ceil( ( n - (m - 1) )/(m - 1) ) )\nend."}, {"source_code": "var m,n:integer;\nbegin\n readln(n,m);writeln((n*m-1) div (m-1));\nend."}, {"source_code": "var\n n, m, f: integer;\n\nbegin\n readln(n, m);\n f := 0;\n while (n > 0) do\n begin\n dec(n);\n inc(f);\n if (f mod m = 0) then inc(n);\n end;\n writeln(f);\nend."}, {"source_code": "program A460;\n\n{$APPTYPE CONSOLE}\n\nuses math;\n\nvar n, m: longInt;\n\nbegin\n readln( n, m );\n writeln( n + ceil( ( n - (m - 1) )/(m - 1) ) )\nend.\n"}, {"source_code": "program A460;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,m,kol:Integer;\nbegin\n Readln(n,m);\n kol:=n;\n while n div m <>0 do\n begin\n kol:=kol+n div m;\n n:=n div m + n mod m;\n end;\n writeln(kol); readln;\nend.\n "}, {"source_code": "var n,m,i:integer;\nbegin\nreadln(n,m); i:=1;\nwhile i0) do begin\n inc(e);\n dec(c);\n inc(f);\n \n if (e mod b=0) then inc(c);\n end;\n writeln(f);\nend. "}, {"source_code": "const fi = '';\n fo = '';\nvar m, n, i, j: longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\n readln(n,m);\n i:=n;\n j:=n div m + n mod m;\n i:=i+n div m;\n while j div m <> 0 do\n begin\n i:=i+j div m;\n j:=j div m + j mod m;\n end;\n write(i);\n\n close(input); close(output);\nend.\n"}], "negative_code": [{"source_code": "uses math;\nvar\n n,m,ans:longint;\n i:longint;\nbegin\n read(n,m);\n ans:=n;\n repeat\n inc(ans,n div m);\n n:=n div m;\n until n=0;\n writeln(ans);\nend.\n"}, {"source_code": "var\n i,n,m,j,d:longint;\n\nbegin\n\n readln(n,m);\n d:=0;\n repeat\n n:=n-m+1;\n d:=m+d;\n until n= m do\n begin\n ost := i mod m;\n i := i div m;\n inc(n,i);\n end;\n\nend;\n\nbegin\n read(n);\n read(m);\n i := n;\n repeat\n check(i,c);\n until(c < m);\n write(n);\nend."}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else\n Begin\n if ((n = 10) and (m = 9)) or ((n = 95) and (m = 16)) then\n writeln((n + n / (m - 1)) : 0 : 0)\n else\n writeln((n + n / (m - 1) - 1) : 0 : 0);\n End;\n\n readln;\nEnd."}, {"source_code": "Var N , M : byte;\n S : longint;\nbegin\n readln(n,m);\n s:=n;\n while n>=m do\n begin\n s:=s+n div m+n mod m;\n n:=n div m;\n end;\n writeln(s);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst max1=100000;\ntype vector=array[1..max1] of integer;\nvar\n x:vector;\n s:ansistring;\n fi,fo:textfile;\n n,k,m:integer;\nprocedure enter;\n var i,j:integer;\n begin\n readln(n,m);\n end;\nprocedure solve;\n var i,j,res,temp:integer;\n begin\n temp:=n+n div m;\n res:=temp+(temp- (n div m)*m) div m;\n writeln(res);\n end;\nprocedure print;\n var i:integer;\n begin\n // for i:=1 to n do writeln(fo,a[i]);\n end;\nbegin\n { assignfile(fi,'socks.inp');reset(fi);\n assignfile(fo,'socks.out');rewrite(Fo);}\n enter;\n solve;\n print;\n { closefile(fi);\n closefile(fo);}\nend.\n"}, {"source_code": "var n,m,kq:longint;\nbegin\n readln(n,m);\n kq:=n+(n div m);\n if (kq mod m) = 0 then writeln(kq+1)\n else writeln(kq);\n readln;\nend."}, {"source_code": "var n, m, k, i:byte;\nbegin\n read(n, m); k:=n;\n while n<>0 do begin\n i:=i+(n mod 2); n:=n div m; while i>=m do begin i:=i-m; n:=n+1; end;\n k:=k+n;\n end;\n write(k);\nend."}, {"source_code": "var\nn, m, ans: byte;\n\nbegin\n readln(n ,m);\n ans:= n + n div m;\n if ans mod m = 0\n then ans += 1;\n writeln(ans);\nend."}, {"source_code": "var\n n,m: integer;\nbegin\n read(n,m);\n if ((n div m)+n) < (n div m)*m+m then\n write((n div m) + n)\n else\n write(((n div m) + n +((n div m + n)-((n div m)*m+m)+m) div m));\nend."}, {"source_code": "program codeforces_round262_a;\n\nvar\n n, m : integer;\n\nbegin\n read(n, m);\n n:=n + (n + (n div m)) div m;\n write(n);\nend.\n"}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nread(z,x);\nif (z=10) and (x=2)\nthen writeln(19)\nelse begin\nk:=z;\na:=z div x;\nk:=k+a;\ng:=a;\nwhile g<>0 do\nbegin\ng:=g div x;\nk:=k+g;\nend;\nwriteln(k);\nend;\nend."}, {"source_code": "var\nn,m,q,b,c:longint;\nbegin\nread(n,m);\nq:=0;\nb:=0;\nc:=n;\nb:=n div m;\nn:=n+b;\nq:=n div m;\nq:=q-b;\nn:=n+q;\nq:=c+n div m;\nwrite(q);\nend."}, {"source_code": " {$mode objfpc}\n var\n n,m:int64;\n count:integer;\n begin\n readln(n,m);\n count:=n;\n while n>=m do\n begin\n n:=n div m;\n inc(count,n);\n end;\n writeln(count);\n end."}, {"source_code": "program vasya;\nvar n,m:integer;\nbegin\nread(n,m);\nif n>m then\nwrite(n)\nelse\nwrite('Unlimited');\nend."}, {"source_code": "var n, m, ans:longint; \nbegin\nreadln(n, m);\nans:=n+((n+(n div m)) div m);\nwriteln(ans); \nend."}, {"source_code": "Var n,m:longint;\n Begin\n read(n,m);\n writeln(n+(round((n-1)/(m-1))));\n End."}, {"source_code": "var n, m, x, n1:longint;\nbegin readln(n, m);\n while n<>0 do begin x:=x+n;\n n:=n div m;\n if n mod m=0 then inc(x);\n end;\n if x mod m=0 then inc(x);\n writeln(x);\nend.\n\n"}, {"source_code": "var\nn, m, day: byte;\n\nbegin\n readln(n ,m);\n day:= 1;\n repeat\n if ((day - 1) <> 0) and ((day - 1) mod m = 0)\n then n += 1;\n n -= 1;\n day += 1;\n until n = 0;\n writeln(day);\nend."}, {"source_code": "var n, m, x, n1:longint;\nbegin readln(n, m); n1:=n;\n while n<>0 do begin x:=x+n;\n n:=n div m;\n end;\n if x mod m=0 then inc(x);\n if (n1=9) and (m=3) then x:=197;\n writeln(x);\nend.\n\n"}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nread(z,x);\nif (z=10) and (x=2)\nthen writeln(19)\nelse begin\n if (z=99) and (x=2)\n then writeln(197)\n else begin\nk:=z;\na:=z div x;\nk:=k+a;\ng:=a;\nwhile g<>0 do\nbegin\ng:=g div x;\nk:=k+g;\nend;\nwriteln(k);\nend;\nend;\nend."}, {"source_code": "program Alpha;\n\nvar\n\tn, m, add : integer;\n\nbegin\n\tread(n,m);\n\tadd := n;\n\trepeat\n\t\tadd := add div m;\n\t\tn := n + add;\n\tuntil (add = 0);\n\twriteln(n);\nend."}, {"source_code": "var h,n,m,b:longint;\nbegin\nreadln(n,m);\nh:=n;\nrepeat\nn:=n div m;\nb:=b+n;\nuntil(n div m=0);\nwrite(h+b);\nend."}, {"source_code": "var n1,x, n,m,P,l:integer;\nbegin\nread(n,m);\nif (n mod 2 <>0) and (m mod 2 <>0) then write(n+m);\nif m0 do inc(p);\nn1:=n;\n\n\n\n\nn1:=n;\nwhile n<>0 do begin x:=x +n;\n n:=n div m;\nend;\nif x mod m=0 then inc(x);\nif x mod n1=0 then inc(x);\nwrite(x);\n\n\n\n\n\n\nend."}, {"source_code": "var n1, p,k,k1,k2, i,x,n,m:longint;\nbegin\nread(n,m);\nfor i:=1 to n do begin\nif (i mod m)=0 then inc(k);\n end;\nfor i:=1 to k do begin\nif (i mod m)=0 then inc(k1);\n end;\nn1:=(n-(m*k)+k);\nfor i:=1 to n1 do\nif (i mod m)=0 then inc(k2);\n\np:=n+k+k1+k2;\nwrite(p);\n\nend.\n\n"}, {"source_code": "program cfcarape;\nvar n,m,s:integer;\n\nbegin\nread(n,m);\ns:=n;\nwhile s div m>0 do\n begin\n s:=s div m;\n n:=n+s;\n end;\nwriteln(n);\nend."}, {"source_code": "var n, m, k, i:byte;\nbegin\n read(n, m); k:=0;\n while n<>0 do begin\n k:=k+n;\n i:=i+(n mod 2); n:=n div m;\n while i>m-1 do begin i:=i-m; n:=n+1; end;\n end;\n write(k);\nend."}, {"source_code": "var p,k,k1, i,x,n,m:longint;\nbegin\nread(n,m);\nfor i:=1 to n do begin\nif (i mod m)=0 then inc(k);\n end;\nfor i:=1 to k do begin\nif (i mod m)=0 then inc(k1);\n end;\n\np:=n+k+k1;\nif p=17 then p:=p+2;\nif p=172 then p:=p+25;\nif p=144 then p:=p+5;\nwrite(p);\nend.\n\n"}, {"source_code": "var n,m:longint;\n\nprocedure open;\n begin\n// assign(input,'460A.inp');\n reset(input);\n end;\n \nprocedure finish;\n begin\n// assign(output,'460A.out');\n rewrite(output);\n end;\n \nprocedure rd;\n begin\n read(n,m);\n end;\n \nprocedure solve;\n begin\n rd;\n if ((n+(n div m)) mod m =0) then\n write (n+(n div m) +1)\n else\n write (n+(n div m));\n end;\n \n BEGIN\n open;\n finish;\n solve;\n// close(input);\n// close(output);\n END.\n"}, {"source_code": "{$mode objfpc}\nvar\n n,m,days,stock:longint;\nprocedure input;\nbegin\n readln(n,m);\nend;\nprocedure solve;\nbegin\n days:=n;\n stock:=n div m;\n while stock<>0 do\n begin\n days:=days+stock;\n stock:=stock div m;\n end;\nend;\nprocedure output;\nbegin\n write(days);\nend;\nbegin\n input;\n solve;\n output;\nend."}, {"source_code": "VAR n,m:longint;\nBEGIN\nreadln(n,m);\nwriteln(n+(n div m)+((n div m) div m));\nEND."}, {"source_code": "var i,n,m: integer;\nbegin\n readln(n,m);\n i:=1000;\n while i<>n+i div m do dec(i);\n writeln(i);\nend."}, {"source_code": "{$MODE OBJFPC}\nProgram only_love;\nvar m,n,ans,dem : integer;\nbegin\n Readln(n,m);\n ans:=0;\n repeat\n n:=n-1;\n inc(ans);\n if n <= 0 then break;\n if ans mod m = 0 then inc(n);\n until n <=0;\n Writeln(ans+1)\nend.\n"}, {"source_code": "var\n i,r,m,n,d:longint;\nbegin\n readln(n,m);\n while n+r>=m do\n begin\n d:=d+n;\n r:=r+n mod m;\n n:=n div m;\n if r>=m then\n begin\n n:=n+1;\n r:=r-m;\n end;\n end;\n d:=d+r+n;\n writeln(d);\nend."}, {"source_code": "var n1, p,k,k1,k2, i,x,n,m:longint;\nbegin\nread(n,m);\nif n=m then write(n+1) else\nfor i:=1 to n do begin\nif (i mod m)=0 then inc(k);\n end;\nfor i:=1 to k do begin\nif (i mod m)=0 then inc(k1);\n end;\nn1:=(n-(m*k)+k);\nfor i:=1 to n1 do\nif (i mod m)=0 then inc(k2);\n\np:=n+k+k1+k2-1;\nwrite(p);\n\nend.\n"}, {"source_code": "var n, m, x:longint;\nbegin readln(n, m);\n while n<>0 do begin x:=x+n;\n n:=n div m;\n end;\n if x mod m=0 then inc(x);\n writeln(x); readln;\nend.\n\n"}, {"source_code": "{$MODE OBJFPC}\nvar\n n, m, sum, res, i : longint;\nBegin\n ReadLn(n, m);\n if (n mod m = 0) and (n <> m) then\n begin\n sum := n + n div m + 1;\n WriteLn(sum);\n halt;\n end;\n if n = m then\n begin\n sum := n + 1;\n WriteLn(sum);\n halt;\n end;\n for i := 1 to n do\n begin\n inc(sum);\n inc(res);\n end;\n sum := sum + res div m;\n WriteLn(sum);\nEnd."}, {"source_code": "program cfcarape;\nvar n,m,s:integer;\n\nbegin\nread(n,m);\ns:=n;\nwhile s div m>0 do\n begin\n s:=s div m;\n n:=n+s;\n end;\nwriteln(n);\nend."}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else writeln(n + (n - 1) / (m - 1) : 0 : 0);\n\n readln;\nEnd."}, {"source_code": "var n, m, x:longint;\nbegin readln(n, m);\n x:=n+n div m;\n if x mod m=0 then inc(x);\n writeln(x);\nend."}, {"source_code": "var\n n,m,i:longint;\n\n\nbegin\n read(n,m);\n for i:=1 to 10000 do begin\n if n=0 then break;\n dec(n);\n if i mod m=0 then inc(n);\n end;\n writeln(i);\nend."}, {"source_code": "var a,b,i :longint;\nbegin\n readln(a,b);\n for i:= 1000 downto 1 do\n if i=a+(i div b) then\n begin\n writeln(i);\n break;\n end;\n \nend."}, {"source_code": "var n,m : integer;\nh : integer;\n\nbegin\n readln(n,m);\n h := 0;\n while n > 0 do\n begin\n h := h+n;\n n := n div m;\n end;\n writeln(h);\n readln;\nend.\n"}, {"source_code": "var n, m, k, i:byte;\nbegin\n read(n, m); k:=0;\n while n<>0 do begin\n k:=k+n;\n n:=n div m; i:=i+(n mod 2);\n while i>m-1 do begin i:=i-m; n:=n+1; end;\n end;\n write(k);\nend."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nread(z,x);\nk:=z;\na:=z div x;\nk:=k+a;\nk:=k+(a div x);\nwriteln(k);\nend."}, {"source_code": "program codeforces_round262_a;\n\nvar\n n, m : integer;\n\nbegin\n read(n, m);\n n:=n + (n + (n div m)) div m;\n write(n);\nend.\n"}, {"source_code": "Program trang;\nvar m,n,sum:int64;\nbegin\n read(n,m);\n sum:=n;\n while n div m >=1 do\n begin\n sum:=sum + (n div m);\n n:=n div m;\n end;\n write(sum);\nend."}, {"source_code": "program lol7;\nvar z,x,c,v,b,n,m,a,s,d,f,g,h,j,k,l,q,w,e,r,t,y,u,i,o,p: longint;\nbegin\nread(z,x);\nk:=z;\na:=z div x;\nk:=k+a;\nk:=k+(a div x);\nwriteln(k);\nend."}, {"source_code": "Var i,n,m,k:Longint;\n Begin\n Read(n,m);\n i:=1;\n while i<>n do\n Begin\n if i mod m=0 then inc(n);\n inc(i);\n end;\n write(((i+n) div 2)+1);\n end."}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+,I+}\nuses\n SysUtils;\nvar n,m:integer;\nbegin\n readln(n,m);\n writeln((n*m)div(m-1)-(m-1)mod 2);\nend."}, {"source_code": "{$mode objfpc}\nvar\n n,m:int64;\n count:integer;\nbegin\n readln(n,m);\n if (n=10) and (m=2) then writeln(19) else\n begin\n count:=n;\n while n>=m do\n begin\n n:=n div m;\n inc(count,n);\n end;\n writeln(count);\n end;\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst max1=100000;\ntype vector=array[1..max1] of integer;\nvar\n x:vector;\n s:ansistring;\n fi,fo:textfile;\n n,k,m:integer;\nprocedure enter;\n var i,j:integer;\n begin\n readln(n,m);\n end;\nprocedure solve;\n var i,j,res,temp:integer;\n begin\n temp:=n+n div m;\n res:=temp+(temp- (n div m)*m) div m;\n writeln(res);\n end;\nprocedure print;\n var i:integer;\n begin\n // for i:=1 to n do writeln(fo,a[i]);\n end;\nbegin\n { assignfile(fi,'socks.inp');reset(fi);\n assignfile(fo,'socks.out');rewrite(Fo);}\n enter;\n solve;\n print;\n { closefile(fi);\n closefile(fo);}\nend.\n"}, {"source_code": "var i,n,m:longint;\n\nbegin\n readln(n,m); \n i:=1;\n while i<=n do\n begin\n if (i mod m =0)and(i<>n) then inc(n);\n inc(i);\n end;\n writeln(i);\nend."}, {"source_code": "{$mode objfpc}\nvar\n n,m:int64;\n count:integer;\nbegin\n readln(n,m);\n if (n=10) and (m=2) then writeln(19) else\n begin\n count:=n;\n while n>=m do\n begin\n n:=n div m;\n inc(count,n);\n end;\n writeln(count);\n end;\nend.\n"}, {"source_code": "var\n a,s,d,i,q,w:integer;\nbegin\n read(a,s);\n d:=0;\n for i:=1 to 100 do\n begin\n if a=0 then break;\n a:=a-1;\n if i mod s=0 then a:=a+1;\n d:=d+1;\n end;\n writeln(d);\n readln;\nend.\n"}, {"source_code": "var\n\tn,m,sum\t: integer;\n\nbegin\n\treadln(n,m);\n\tsum:=n;\n\twhile n>=m do\n\tbegin\n\t\tsum:=sum+ (n div m);\n\t\tn:= n div m;\n\tend;\n\twriteln(sum);\nend."}, {"source_code": "Var a, b, c,g, p:int64;\nbegin\n Read(a, b) ;\n C:=a div b;\n C:=c+a;\n If (b mod 2 = 1) and (a mod 2 = 1)then c:=c+1;\n Writeln(c) ;\nend.\n"}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else writeln(n + (n - 1) / (m - 1) : 0 : 0);\n\n readln;\nEnd."}, {"source_code": "var\nn, m, ans: byte;\n\nbegin\n readln(n ,m);\n ans:= n + n div m;\n if ans mod m = 0\n then ans += 1;\n writeln(ans);\nend."}, {"source_code": "var n,m : integer;\nh : integer;\n\nbegin\n readln(n,m);\n h := 0;\n while n > 0 do\n begin\n h := h+n;\n n := n div m;\n end;\n writeln(h);\n readln;\nend.\n"}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\n\nconst oo=1e+21;\n eps=1e-9;\n dohuya=maxlongint div 2;\n\nvar a,aaa:array[0..2015,0..2015]of longint;\n qq,cc,q0,c0,qc:array[0..1000000]of longint;\n r,res,cur,n,m,i,j,k:longint;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n b,bb:boolean;\n\nbegin\nread(n,m);\nres:=0;\nwhile n>0 do\n begin\n inc(res);\n dec(n);\n if res mod m=0 then inc(n);\n end;\nend.\n"}, {"source_code": "program Alpha;\n\nvar\n\tn, m, add : integer;\n\nbegin\n\tread(n,m);\n\tadd := n;\n\trepeat\n\t\tadd := add div m;\n\t\tn := n + add;\n\tuntil (add = 0);\n\twriteln(n);\nend."}, {"source_code": "var n,m,day,sock:longint;\nbegin\n readln(n,m);\n day:=0;\n sock:=n;\n while sock>0 do\n begin\n day:=day+sock;\n sock:=n div m;\n n:=sock;\n end;\n writeln(day);\n readln;\nend."}, {"source_code": "{$MODE OBJFPC}\nvar\n n, m, sum, res, i : longint;\nBegin\n ReadLn(n, m);\n if (n mod m = 0) and (n <> m) then\n begin\n sum := n + n div m + 1;\n WriteLn(sum);\n halt;\n end;\n if n = m then\n begin\n sum := n + 1;\n WriteLn(sum);\n halt;\n end;\n for i := 1 to n do\n begin\n inc(sum);\n inc(res);\n end;\n sum := sum + res div m;\n WriteLn(sum);\nEnd."}, {"source_code": "{$MODE OBJFPC}\nProgram onlylove;\nvar n,p,q ,ans,i :integer;\nbegin\n readln(n);\n for i:=1 to n do\n\n begin\n readln(p,q);\n if q-p >= 2 then inc(ans);\n end;\n write(ans);\nend.\n"}, {"source_code": "var\nn, m, ans: byte;\n\nbegin\n readln(n ,m);\n ans:= n + n div m;\n if ans mod m = 0\n then ans += 1;\n writeln(ans);\nend."}, {"source_code": "program A460;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,m,ost,kol:Integer;\nbegin\n Readln(n,m);\n kol:=n; ost:=0;\n while (n+ost) div m <>0 do\n begin\n kol:=kol+(n+ost) div m;\n ost:=(n+ost) mod m;\n n:=n div m;\n end;\n writeln(kol); readln;\nend.\n "}, {"source_code": "var n, m, i, j, x: integer;\nbegin \nj:=0;\nx:=0;\n read(n, m);\n for i:=n downto 0 do\n begin\n x:=x+1;\n j:=j+1;\n n:=n-1;\n if ((j=m) and (n<>0)) then begin n:=n+1; j:=1; end;\n end;\n \n writeln(x);\nend."}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nfunction total(n, m : byte) : integer;\nBegin\n if (n < m) and (a + n = m) then\n Begin\n total := x + 2;\n exit;\n End\n else if (n < m) and (a + n < m) then\n Begin\n total := x + 1;\n exit;\n End\n else\n Begin\n x := x + n; a := a + n mod m;\n if a >= m then\n Begin\n o := a; a := 0;\n total := total((n div m) + o, m);\n End\n else\n total := total(n div m, m);\n End;\nEnd;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else writeln(total(n, m));\n\n readln;\nEnd."}, {"source_code": "{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}\n{$MINSTACKSIZE $00004000}\n{$MAXSTACKSIZE $00100000}\n{$IMAGEBASE $00400000}\n{$APPTYPE CONSOLE}\n\n\nconst oo=1e+21;\n eps=1e-9;\n dohuya=maxlongint div 2;\n\nvar a,aaa:array[0..2015,0..2015]of longint;\n qq,cc,q0,c0,qc:array[0..1000000]of longint;\n r,res,cur,n,m,i,j,k:longint;\n x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;\n b,bb:boolean;\n\nbegin\nread(n,m);\nres:=0;\nwhile n>0 do\n begin\n inc(res);\n dec(n);\n if res mod m=0 then inc(n);\n end;\nend.\n"}, {"source_code": "var\n i,n,m,j,d:longint;\n\nbegin\n\n readln(n,m);\n d:=0;\n repeat\n n:=n-m+1;\n d:=m+d;\n until nn) then inc(n);\n inc(i);\n end;\n writeln(i);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+}\n\nuses\n SysUtils;\n\nvar n,m:integer;\n\nbegin\n { reset(input,'input.txt');\n rewrite(output,'output.txt');}\n read(n,m);\n if n div m=m then writeln(n+1+(n div m))\n else writeln(n+(n div m));\nend."}, {"source_code": "var\n n, m, s, i, days, a, b, c: integer;\n\nbegin\n Readln(n, m);\n b := n div m;\n for i := 1 to n do \n begin\n if (b > 0) then a := a + b;\n b := b div m;\n end;\n days := n + a;\n Writeln(days);\nend."}, {"source_code": "var\n n,m,sum:longint;\n\n\nbegin\n read(n,m);\n sum:=n+(n div m);\n writeln(sum+(sum div m-n div m));\nend."}, {"source_code": "var n, m, x, n1:longint;\nbegin readln(n, m); n1:=n;\n while n<>0 do begin x:=x+n;\n n:=n div m;\n end;\n if x mod m=0 then inc(x);\n if (n1=99) and (m=2) then x:=197;\n writeln(x);\nend.\n\n"}, {"source_code": "Var N , M : byte;\n S : longint;\nbegin\n readln(n,m);\n s:=n;\n while n mod m =0 do\n begin\n s:=s+n div m;\n n:=n div m;\n end;\n writeln(s);\nend."}, {"source_code": "program Alpha;\n\nvar\n\tn, m, add : integer;\n\nbegin\n\tread(n,m);\n\tadd := n;\n\trepeat\n\t\tadd := add div m;\n\t\tn := n + add;\n\tuntil (add = 0);\n\twriteln(n);\nend."}, {"source_code": "var\nm,n,b:longint;\nbegin\nread(n);\nread(m);\nb:=n;\nb:=b+(n div m);\nif(b mod m=0) then b:=b+1;\nwriteln(b);\nend.\n"}, {"source_code": "var\nm,n,b,c:longint;\nbegin\nread(n);\nread(m);\nb:=n;\nc:=n div m;\nwhile(c>=1) do\nbegin\nb:=b+c;\nc:=c div m;\nend;\nif(b mod m=0) then b:=b+1;\nwriteln(b);\nend.\n"}, {"source_code": "program vasy_i_noski;\nvar n,m,d,sc:longint;\nbegin\n readln(n,m);\n if n=1 then\n begin\n writeln(1);\n exit;\n end;\n sc:=m;\n d:=0;\n while sc>=m do\n begin\n n:=n-m+1;\n sc:=n;\n d:=d+m;\n end;\n writeln(d+sc);\nend.\n\n"}, {"source_code": "var\n t1,c1,c,tt,nn,n,s,i,j,t,m:longint;\n ans:int64;\nbegin\n{ assign(input,'input.txt');\n reset(input);\n assign(output,'output.txt');\n rewrite(output); }\n readln(n,m);\n if n= m do\n begin\n n:= n div m;\n kq:= kq + n;\n end;\n writeln(fo,kq);\nend;\n\nprocedure OUTPUT;\nbegin\n close(fi); close(fo);\nend;\n\nbegin\n INPUT;\n Solve;\n OUTPUT;\nend.\n"}, {"source_code": "{$APPTYPE CONSOLE}\n{$Q+,R+,I+}\nuses\n SysUtils;\n\n\nvar n,m:integer;\nbegin\n readln(n,m);\n writeln(n+((n+m) div m));\n\nend.\n"}, {"source_code": "var n,m,ans:integer;\nbegin\n readln(n,m);\n while n<>0 do begin\n inc(ans,n);\n n:=n div m;\n end;\n writeln(ans);\n readln;\nend.\n"}, {"source_code": "Program trang;\nvar m,n,sum:int64;\nbegin\n read(n,m);\n sum:=n;\n while n div m >=1 do\n begin\n sum:=sum + (n div m);\n n:=n div m;\n end;\n write(sum);\nend."}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nfunction total(n, m : byte) : integer;\nBegin\n if (n < m) and (a + n = m) then\n Begin\n total := x + 2;\n exit;\n End\n else if (n < m) and (a + n < m) then\n Begin\n total := x + 1;\n exit;\n End\n else\n Begin\n x := x + n; a := a + n mod m;\n if a >= m then\n Begin\n o := a; a := 0;\n total := total((n div m) + o, m);\n End\n else\n total := total(n div m, m);\n End;\nEnd;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else writeln(total(n, m));\n\n readln;\nEnd."}, {"source_code": "program gt;\nvar n,m,h,p,i:integer;\nbegin\nreadln(n,m);\nh:=n div m+n;\np:=n;\nfor i:=n+1 to h do\nif(i mod m=0)then h:=h+1;\nwriteln(h);\nend."}, {"source_code": "Program _1;\nVar\n n,m,max:longint;\nBegin\n {assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n read(n,m);\n max:=0;\n max:=n;\n while (n>=m)or(max mod m=0) do begin\n inc(max);\n dec(n,m);\n end;\n write(max);\n {close(input);\n close(output);}\nEnd.\n"}, {"source_code": "var n,m,x,k:longint;\nbegin\n read(n,m); x:=n; k:=n;\n repeat\n x:=x div m;\n if x=0 then break;\n inc(n,x);\n until False;\n if (odd(n)=false) and (n>k) then writeln(n+1)\n else writeln(n);\nend."}, {"source_code": "var n, m, i, j, x: integer;\nbegin \nJ:=0;\nx:=0;\n read(n, m);\n for i:=n downto 0 do\n begin\n inc(x);\n inc(j);\n n:=n-1;\n if ((j=m) and (n<>0)) then begin inc(n); j:=0; end;\n end;\n writeln(x);\nend."}, {"source_code": "var\n a,s,d,i,q,w:integer;\nbegin\n read(a,s);\n d:=0;\n for i:=1 to 100 do\n begin\n if a=0 then break;\n a:=a-1;\n if i mod s=0 then a:=a+1;\n d:=d+1;\n end;\n writeln(d);\n readln;\nend.\n"}, {"source_code": "var p,k,k1, i,x,n,m:longint;\nbegin\nread(n,m);\nfor i:=1 to n do begin\nif (i mod m)=0 then inc(k);\n end;\nfor i:=1 to k do begin\nif (i mod m)=0 then inc(k1);\n end;\n\np:=n+k+k1;\nif p=17 then p:=p+2;\nif p=172 then p:=p+25;\nif p=144 then p:=p+5;\nwrite(p);\nend.\n\n"}, {"source_code": "Var a, b, c,g, p:int64;\nbegin\n Read(a, b) ;\n C:=a div b;\n C:=c+a;\n If (b mod 2 = 1) and (a mod 2 = 1)then c:=c+1;\n Writeln(c) ;\nend.\n"}, {"source_code": "var ans, n, m : int64;\nbegin\n readln(n, m);\n inc(ans, (n div m) div m + n + n div m);\n writeln(ans);\nend.\n"}, {"source_code": "Program vasya_socks;\nvar n, m, i, x, a, o : byte;\n\nfunction total(n, m : byte) : integer;\nBegin\n if (n < m) and (a + n = m) then\n Begin\n total := x + 2;\n exit;\n End\n else if (n < m) and (a + n < m) then\n Begin\n total := x + 1;\n exit;\n End\n else\n Begin\n x := x + n; a := a + n mod m;\n if a >= m then\n Begin\n o := a; a := 0;\n total := total((n div m) + o, m);\n End\n else\n total := total(n div m, m);\n End;\nEnd;\n\nBegin\n read(n);\n readln(m);\n\n if n < m then writeln(n)\n else if n = m then writeln(n + 1)\n else writeln(total(n, m));\n\n readln;\nEnd."}, {"source_code": "var n, m, i, j, x: integer;\nbegin \nj:=0;\nx:=0;\n read(n, m);\n for i:=n downto 0 do\n begin\n x:=x+1;\n j:=j+1;\n n:=n-1;\n if ((j=m) and (n<>0)) then begin n:=n+1; j:=1; end;\n end;\n \n writeln(x);\nend."}, {"source_code": "{$MODE OBJFPC}\nProgram only_love;\nvar m,n,ans,dem : integer;\nbegin\n Readln(n,m);\n ans:=0;\n repeat\n n:=n-1;\n inc(ans);\n if n <= 0 then break;\n if ans mod m = 0 then inc(n);\n until n <=0;\n Writeln(ans+1)\nend.\n"}], "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0"} {"source_code": "var a,b,c,d,p,q: longint;\n\nFunction GCD(a,b: longint): longint;\nbegin\n while (a>0) and (b>0) do\n if a>b then a:=a mod b else b:=b mod a;\n GCD:=a+b\nend;\n\nbegin\n// assign(input,'input.txt'); reset(input);\n// assign(output,'output.txt'); rewrite(output);\n\n read(a,b,c,d);\n if b*c>a*d\n then begin p:=b*c-a*d; q:=b*c end\n else begin p:=a*d-b*c; q:=a*d end;\n\n\n writeln(p div gcd(p,q),'/',q div gcd(p,q))\nend.", "positive_code": [{"source_code": "var\n a, b, c, d :longint;\n lcm1, lcm2 :longint;\n x :longint;\n a1, a2, a3, a4 :longint;\n min1, min2 :longint;\n min :real;\nprocedure gcd(a,b:longint);\nbegin\n if aa4 then\n begin\n min1:=a2-a4; min2:=a2;\n min:=min1/min2;\n end;\n gcd(b,d);\n lcm2:=b*d div x;\n a2:=lcm2; a4:=lcm2;\n a1:=a*lcm2 div b;\n a3:=c*lcm2 div d;\n if a1>a3 then\n begin\n if (a1-a3)/a1b*c then\n begin\n temp:=a;a:=b;b:=temp;\n temp:=c;c:=d;d:=temp;\n end;\n p:=a*d;\n q:=b*c;\n p:=q-p;\n pp:=p;\n for i:=pp downto 2 do\n if (p mod i=0)and(q mod i=0) then\n begin\n p:=p div i;\n q:=q div i;\n end;\n if p=0 then q:=1;\n writeln(p,'/',q);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000001;\nvar\n a,b,c,d,tu,mau,tg:int64;\n a1,b1,t,m,t1:extended;\n dem,i,j:integer;\n nc:array[1..1000000]of int64;\n\nfunction gcd(a,b:int64):int64;\nvar\n r:int64;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n //assign(input,'196B.INP');reset(input);\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n if t=0 then\n begin\n writeln(0,'/',1);\n halt;\n end;\n t:=t/m;dem:=0;\n t1:=t;\n while (abs(round(t)-t)>saiso) do\n begin\n inc(dem);nc[dem]:=trunc(t);\n t:=t-nc[dem];\n t:=1/t;\n end;\n tu:=1;mau:=round(t);\n for i:=dem downto 1 do\n begin\n tu:=tu+mau*nc[i];\n tg:=tu;tu:=mau;mau:=tg;\n end;\n tg:=gcd(tu,mau);\n if (mau/tu-t1)<=saiso then\n writeln(mau div tg,'/',tu div tg) else\n writeln(tu div tg,'/',mau div tg);\nend.\n"}, {"source_code": "//uses math;\nvar\n p,a,b,n,m,k,t, l,j,e,i2,j2, x,x1,x2,x3,xx,y,y1,y2,y3,yy,z,z1,z2,z3,zz,w,r,c :int64;\n d:array[0..1000001]of longint;\n s:array[0..1001,0..1001]of longint;\n ans,res,max,min,sum,best:int64;\n h:boolean;\n flag:array[0..1001,0..1001]of boolean;\n i:longint;\n\nbegin ans:=0;res:=0;max:=0;min:=0;sum:=0;best:=0;//assign(input,'input.txt');reset(input); assign(output,'output.txt');reset(output);\n readln(a,b,x,y);\n while (a abs(1-x/y) ) then inc(t);\n if y>x then inc(t);\n if t=1 then begin\n w:=a; a:=b; b:=w;\n w:=y; y:=x; x:=w;\n end;\n p:=y*a;\n b:=b*x;\n for i:=10000 downto 1 do\n if (p mod i=0) and (b mod i=0) then begin\n p:=p div i;\n b:=b div i;\n end;\n writeln(b-p,'/',b);\n readln; readln; //close(input); close(output);\nend.\n"}, {"source_code": "Var a,b,c,d,z:longint;\nfunction nod(a,b:longint):longint;\nbegin\n if b>a\n then nod:=nod(b,a)\n else if b=0\n then nod:=a\n else nod:=nod(b, a mod b);\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(a,b,c,d);\n z:=nod(a,b);\n a:=a div z;\n b:=b div z;\n z:=nod(c,d);\n c:=c div z;\n d:=d div z;\n if (a=c)and(b=d)\n then begin\n writeln(0,'/',1);\n halt(0);\n end;\n if a*dc2 then\n begin\n h:=a2-c2;\n t:=gcd(h,a2);\n h:=h div t;\n a2:=a2 div t;\n writeln(g,h,'/',a2);\n end\n else\n begin\n b:=b*tu div a;\n d:=d*tu div c;\n h:=b-d;\n t:=gcd(h,b);\n h:=h div t;\n b:=b div t;\n writeln(g,h,'/',b);\n end;\n close(g);\nend."}, {"source_code": "uses math;\n\nVar a,b,c,d,t1,t2,s:int64;\n\nprocedure tt(a,b:longint);\n begin\n while (a>0) and (b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n s:=a+b;\n end;\n\n begin\n read(a,b,c,d);\n if (a>=c) and (b>=d) then begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t2-t1),'/',max(t1,t2));\n end\n else begin\n t1:=b*c;\n t2:=d*a;\n\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t1-t2),'/',max(t1,t2));\n end;\n end."}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nuses math;\nvar a,b,c,d ,ans1,m,n,x,ans2: integer;\nfunction gcd(x,y : integer) : integer;\n begin\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\n end;\nfunction lcm(x,y : integer) :integer;\n begin\n exit(x*y*gcd(x,y));\n end;\nprocedure th1;\n begin\n x := lcm(a,c);\n m:=x div a;\n n:=x div c;\n a:=x;\n c:=x;\n b:=b*m;\n d:=d*n;\n ans1:=abs(b-d);\n ans1:=ans1 div gcd(b,d);\n Writeln(ans1,'/',b div gcd(b,d) );\n end;\nprocedure th2;\n begin\n x := lcm(b,d);\n m:=x div b;\n n:=x div d;\n b:=x;\n d:=x;\n a:=a*m;\n c:=c*n;\n ans1:=abs(a-c);\n ans1:=ans1 div gcd(a,c);\n Writeln(ans1,'/',a div gcd(a,c) );\n end;\nbegin\n readln(a,b,c,d);\n if (a/b < c/d) then th1 else th2;\n\nend."}, {"source_code": "var n,m,k,l,i,j,t,s : longint;\n function nod(i,j : longint) : longint;\n begin\n if (i <> 0) then nod := nod (j mod i,i) else nod := j;\n end;\n function nok(i,j : longint): longint;\n begin\n nok := (i div nod(i,j)) * j;\n end;\nbegin\n readln(n,m,k,l);\n t := n;\n s := k;\n n := nok(n,k);\n k := nok(t,k);\n m := m * n div t;\n l := l * k div s;\n while nod(m,l) > 1 do\n begin\n t := m;\n m := m div nod(m,l);\n l := l div nod(t,l);\n end;\n if (m < l) then\n write(l - m,'/',l)\n else\n write(m - l,'/',m);\nend."}, {"source_code": "uses math;\nvar\n a,b,c,d,temp:longint;\n r:extended;\n\nfunction gcd(x,y:longint):longint;\nbegin\n while (x<>0) and (y<>0) do\n if x>y then x:=x mod y else y:=y mod x;\n exit(x+y);\nend;\n\nbegin\n read(a,b,c,d);\n if b=d then\n begin\n temp:=a;a:=b;b:=temp;\n temp:=c;c:=d;d:=temp;\n end;\n if a=c then\n begin\n if b=d then writeln('0/1');\n temp:=gcd(b-d,b);\n if b>d then\n writeln( (b-d) div temp,'/',b div temp);\n if d>b then\n begin\n temp:=gcd(d-b,d);\n writeln( (d-b) div temp,'/',d div temp);\n end;\n halt;\n end;\n r:=d*(a/c);\n if r<=b then\n begin\n temp:=gcd(c*b-d*a,c*b);\n writeln( (c*b-d*a) div temp,'/', (c*b) div temp);\n end;\n if r>b then\n begin\n temp:=gcd(a*d-c*b,a*d);\n writeln( (a*d-c*b) div temp,'/',(a*d) div temp);\n end;\nEND."}, {"source_code": "var\n A,B,C,D,X,Y,Z:Longint;\nfunction Nod(AA,BB:Longint):Longint;\nbegin\n while (AA<>0) and (BB<>0) do\n if AA>BB then AA:=AA mod BB\n else BB:=BB mod AA;\n Nod:=AA+BB;\n end;\nbegin\n Readln(A,B,C,D);\n X:=C*B;\n Y:=D*A;\n Z:=Nod(X,Y);\n X:=X div Z;\n Y:=Y div Z;\n if X-Y>0 then Writeln(X-Y,'/',X)\n else Writeln(Y-X,'/',Y);\n end.\n"}, {"source_code": "var a,b,c,d,ch1,ch2,k:longint;\nfunction nsd(x,y:longint):longint;\nbegin\n if x>0 then nsd:=nsd(y mod x,x) else nsd:=y;\nend;\nbegin\n read(a,b,c,d);\n ch1:=a*d;\n ch2:=b*c;\n if ch1>ch2 then\n begin\n k:=nsd(ch1-ch2,ch1);\n writeln((ch1-ch2) div k,'/',ch1 div k);\n end else\n begin\n k:=nsd(ch2-ch1,ch2);\n writeln((ch2-ch1) div k,'/',ch2 div k);\n end;\n end.\n"}, {"source_code": "var a,b,c,d,i,j,k,l,m,n:longint;\n\nfunction gcd(a,b:longint):longint;\nbegin\n if b=0 then exit(a);\n exit(gcd(b,a mod b));\nend;\n\nprocedure doit1;\nbegin\n k:=gcd(a*d-b*c,a*d);\n writeln((a*d-b*c)div k,'/',(a*d) div k);\nend;\n\nprocedure doit2;\nbegin\n k:=gcd(b*c-a*d,b*c);\n writeln((b*c-a*d)div k,'/',(b*c) div k);\nend;\n\nbegin\n readln(a,b,c,d);\n if a/b>=c/d then doit1 else doit2;\nend."}, {"source_code": "var\ns,g,ss,a,b,c,d:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then max:=a\n else max:=b;\nend;\nfunction gcd(a,b:longint):longint;\nbegin\n if a mod b=0 then gcd:=b\n else gcd:=gcd(b,a mod b);\nend;\nbegin\n read(a,b,c,d);\n if a/b>c/d then\n begin\n g:=gcd(max(b,d),b+d-max(b,d));\n s:=b*d div g;\n ss:=s div b*a-s div d*c;\n writeln(ss div gcd(s div b*a,ss),'/',s div b*a div gcd(s div b*a,ss));\n end;\n if a/ba then begin\n\t\ttmp:=a;\n\t\ta:=b;\n\t\tb:=tmp;\n\tend;\n\trepeat\n\t\tc:=a mod b;\n\t\ta:=b;\n\t\tb:=c;\n\tuntil(c=0);\n\texit(a);\nend;\n\n\nvar a,b,c,d,p,q,tmp:longint;\nbegin\n\tread(a,b,c,d);\n\tif a*d>c*b then begin\n\t\tp:=a*d-b*c;\n\t\tq:=a*d;\n\tend\n\telse begin\n\t\tp:=b*c-a*d;\n\t\tq:=b*c;\n\tend;\n\tif p<>0 then begin \n\t\ttmp:=gcd(p,q);\n\t\tp:=p div tmp;\n\t\tq:=q div tmp;\n\tend\n\telse q:=1;\n\twrite(p,'/',q);\nend.\t"}, {"source_code": "Uses math;\nType\n mat=array [1..1000000] of longint;\nVar a,b,c,d,a1,b1,c1,d1:longint;\n res,kq:longint;\n fi,fo:text;\n\nProcedure Doc;\n Var i:longint;\n Begin\n Read(fi,a,b,c,d);\n a1:=a;b1:=b;c1:=c;d1:=d;\n end;\n\nFunction Ucln(x,y:longint):longint;\n Begin\n If x=0 then exit(y);\n If y=0 then exit(x);\n If x=d then\n Begin\n If b=d then Write(fo,0,'/',1)\n else\n Begin\n kq:=b;\n res:=b-d;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n If ok then exit;\n a:=a1;\n b:=b1;\n c:=c1;\n d:=d1;\n u:=Bcnn(b,d);\n a:=a*(u div b);\n c:=c*(u div d);\n b:=u;\n d:=u;\n If a>=c then\n Begin\n If a=c then Write(fo,0,'/',1)\n else\n Begin\n kq:=a;\n res:=a-c;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "var a,b,c,d,t,x,y,son,m:longint;\nbegin\n readln(a,b,c,d);\n if a*d>b*c then\n begin\n son:=a*d-b*c; m:=a*d;\n x:=son; y:=m;\n if x0 do\n begin\n t:=x mod y;\n x:=y;\n y:=t;\n end;\n writeln(son div y,'/',m div y);\n end\n else\n if a*d0 do\n begin\n t:=x mod y;\n x:=y;\n y:=t;\n end;\n writeln(son div y,'/',m div y);\n end\n else writeln(0,'/',1);\nend."}, {"source_code": "var a, b, c, d, p, q, x, y, z: int64;\nbegin\n readln(a, b, c, d);\n\n p := abs(b * c - a * d);\n if a / b < c / d then\n q := b * c\n else\n q := a * d;\n x := p;\n y := q;\n while y > 0 do\n begin\n z := x;\n x := y;\n y := z mod x;\n end;\n writeln(p div x, '/', q div x);\nend."}, {"source_code": "var a,b,c,d,i,ans1,ans2,u:longint;q1,q2:real;\nfunction gcd(n,m:longint) : longint;\nvar r : longint;\nbegin\n while m <> 0 do\n begin\n r := n mod m;\n n := m;\n m := r;\n end;\n gcd := n;\nend;\n\nBegin\n readln(a,b,c,d);\n q1:=a/c;\n q2:=b/d;\n if q1b*(k div a) then\n begin\n k:=lcm(b,d);\n y:=a*(k div b);\n x:=y-c*(k div d);\n end\n else\n begin\n y:=b*(k div a);\n x:=y-d*(k div c);\n end;\n if x=0 then\n begin\n writeln('0/1');\n close(input);\n close(output);\n halt;\n end;\n k:=gcd(x,y);\n x:=x div k;\n y:=y div k;\n writeln(x,'/',y);\nend.\n"}, {"source_code": "CONST\n fi='';\n fo='';\nvar a,b,c,d:longint;\nPROCEDURE INIT;\nBEGIN\n assign(input,fi); reset(input);\n assign(output,fo);rewrite(output);\nEND;\nFUNCTION gcd(x,y:longint):longint;\nBEGIN\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\nEND;\nPROCEDURE doit;\nvar i,j,x,y,z:longint;\n BEGIN\n readln(a,b,c,d);\n a:=a*d;\n b:=b*c;\n if a > b then begin x:=a;a:=b;b:=x;end;\n a:=b-a;\n writeln(a/gcd(a,b):1:0,'/',b/gcd(a,b):1:0);\n END;\nPROCEDURE closef;\nBEGIN\n close(input);\n close(output);\n END;\nBEGIN\n init;\n doit;\n closef;\nEND.\n"}, {"source_code": "Program cf196bb;\nVar\n dqa,dqb,dqc,dqd,a,b,c,d,gcdab,gcdcd,aa,bb,bl,exb,exd,exa,exc,gcdac,gcdbd,dq,ansx,ansy:Int64;\n ans:Extended;\nFunction Gcd(a,b:Int64):Int64;\nBegin\n If (a Mod b=0) Then Exit(b) Else\n Exit(Gcd(b,a mod b));\nEnd;\nBegin\n ans:=19950920;\n Read(a,b);\n Readln(c,d);\n gcdab:=Gcd(a,b);\n gcdcd:=Gcd(c,d);\n a:=a Div gcdab;b:=b Div gcdab;\n c:=c Div gcdcd;d:=d Div gcdcd;\n aa:=a;bb:=b;\n gcdac:=Gcd(a,c);\n bl:=a*c Div gcdac Div a;\n exb:=b*bl;\n bl:=a*c Div gcdac Div c;\n exd:=d*bl;\n If exb>=exd Then Begin\n dq:=exb-exd;\n dqa:=a *c Div gcdac;\n IF dq/exb=exc Then Begin\n dq:=exa-exc;\n dqb:=b*d Div gcdbd;\n IF dq/exa0) and (b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n s:=a+b;\n end;\n\n begin\n read(a,b,c,d);\n if (a>=c) and (b>=d) then begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t2-t1),'/',max(t1,t2));\n end\n else begin\n t1:=b*c;\n t2:=d*a;\n\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t1-t2),'/',max(t1,t2));\n end;\n end."}, {"source_code": "var\n a, b, c, d,xm,ans1,ans2: longint;\n dx, dy: longint;\n tempk1, tempk2:real;\nfunction nod(x,y:longint):longint;\nbegin\n if y=0 then\n nod:=x\n else\n nod:=nod(y,(x mod y))\nend;\nbegin\n readln(a, b, c, d);\n if (a / b = 1) then begin\n \n if (c > d) then begin\n dx := c - d;\n dy := c;\n \n end\n else \n begin\n dx := d - c;\n dy := d;\n \n end;\n \n \n \n end\n else\n if (c / d = 1) then begin\n \n if (a > b) then begin\n dx := a - b;\n dy := a;\n \n end\n else \n begin\n dx := b - a;\n dy := b;\n \n end;\n \n \n end\n else\n //if (c>=a) or (d>=b) then\n begin\n tempk1 := c / a;\n tempk2 := d / b;\n if (tempk1 > tempk2) then\n begin\n dy := b * c - d * a; \n dx := c * b;\n \n end\n else\n begin\n dx := a * d - c * b; \n dy := d * a;\n \n end;\n end;\n ans1:=dx div nod(dx,dy);\n ans2:=dy div nod(dx,dy);\n if ans1c*b then\n begin\n swap(a,b);\n swap(c,d);\n end;\n p:=b*c-a*d;\n q:=b*c;\n writeln(p div gcd(p,q),'/',q div gcd(p,q));\nend."}, {"source_code": "var a,b,c,d,p,q,t:longint;\nfunction gcd(a,b:longint):longint;\nvar c:longint;\nbegin\n while b<>0 do\n begin\n c:=a;\n a:=b;\n b:=c mod b;\n end;\n exit(a);\nend;\nbegin\n readln(a,b,c,d);\n if a*d>c*b then\n begin\n t:=a;a:=b;b:=t;\n t:=c;c:=d;d:=t;\n end;\n p:=b*c-a*d;\n q:=b*c;\n writeln(p div gcd(p,q),'/',q div gcd(p,q));\nend."}, {"source_code": "var\n a, b, c, d :longint;\n lcm1, lcm2 :longint;\n x :longint;\n a1, a2, a3, a4 :longint;\n min1, min2 :longint;\n min :real;\nprocedure gcd(a,b:longint);\nbegin\n if aa4 then\n begin\n min1:=a2-a4; min2:=a2;\n min:=min1/min2;\n end;\n gcd(b,d);\n lcm2:=b*d div x;\n a2:=lcm2; a4:=lcm2;\n a1:=a*lcm2 div b;\n a3:=c*lcm2 div d;\n if a1>a3 then\n begin\n if (a1-a3)/a10 do\n begin\n c:=a;\n a:=b;\n b:=c mod b;\n end;\n exit(a);\nend;\nbegin\n readln(a,b,c,d);\n if a*d>c*b then\n begin\n t:=a;a:=b;b:=t;\n t:=c;c:=d;d:=t;\n end;\n p:=b*c-a*d;\n q:=b*c;\n writeln(p div gcd(p,q),'/',q div gcd(p,q));\nend.\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!\n//chen_zhe AK IOI!!!"}, {"source_code": "var a,b,c,d,p,q,t:longint;\nfunction gcd(a,b:longint):longint;\nbegin\n if b=0 then exit(a);\n exit(gcd(b,a mod b));\nend;\nbegin\n readln(a,b,c,d);\n if a*d>c*b then\n begin\n t:=a;a:=b;b:=t;\n t:=c;c:=d;d:=t;\n end;\n p:=b*c-a*d;\n q:=b*c;\n writeln(p div gcd(p,q),'/',q div gcd(p,q));\nend."}, {"source_code": "var i,j,k,n,m,p,q,a,b,c,d:longint;\n\n\n function gcd(a,b:longint):longint;\n begin\n if a mod b=0 then exit(b);\n exit(gcd(b,a mod b));\n end;\n\n\nbegin\n readln(a,b,c,d);\n if b*c>a*d then\n begin\n p:=c*b-a*d;\n q:=b*c;\n end\n else\n begin\n p:=a*d-c*b;\n q:=a*d;\n end;\n if (p=0) or (q=0) then writeln('0/1')\n else\n begin\n k:=gcd(q,p);\n p:=p div k;\n q:=q div k;\n writeln(p,'/',q);\n end;\nend."}, {"source_code": "var\nx,y,a,b,c,d:longint;\nFunction gcd(m,n:longint):longint;\nbegin\nif (m mod n=0) or( n mod m=0) then \n begin\n if m mod n=0 then gcd:=n;\n if n mod m=0 then gcd:=m;\n end else\n begin\n if m>n then gcd:=gcd(m mod n, n);\n if n>m then gcd:=gcd(n mod m, m);\n end;\nend;\nbegin\nread(a,b,c,d);\nif a*d>b*c then \nbegin\nx:=b*c; y:=a*d;\nc:=gcd(x,y);\nx:=x div c;\ny:=y div c;\nend;\nif b*c>a*d then \nbegin\nx:=a*d; y:=b*c;\nc:=gcd(x,y);\nx:=x div c;\ny:=y div c;\nend;\nif b*c=a*d then begin x:=1; y:=1; end;\nWriteln(y-x,'/',y);\nend."}, {"source_code": "var a,b,c,d,i,x,y:longint;\nbegin\n readln(a,b,c,d);\n if a/c0) and (BB<>0) do\n if AA>BB then AA:=AA mod BB\n else BB:=BB mod AA;\n Nod:=AA+BB;\n end;\nbegin\n Readln(A,B,C,D);\n X:=C*B;\n Y:=D*A;\n Z:=Nod(X,Y);\n X:=X div Z;\n Y:=Y div Z;\n if X-Y>0 then Writeln(X-Y,'/',X)\n else Writeln(Y-X,'/',Y);\n end.\n"}, {"source_code": "var a,p,q:dword; b,c,d:word;\nfunction ucln(x,y:dword):dword;\nvar z:dword;\nbegin\n while y>0 do\n begin\n x:=x mod y; z:=x; x:=y; y:=z\n end;\n ucln:=x\nend;\nbegin\n read(a,b,c,d);\n if a/bc/d) then\n begin\n x:=a*d-b*c; y:=a*d;\n writeln(x div gcd(x,y),'/',y div gcd(x,y));\n end\n else\n begin\n x:=b*c-a*d; y:=b*c;\n writeln(x div gcd(x,y),'/',y div gcd(x,y));\n end;\n end;\nend."}, {"source_code": "program p196b;\n var a,b,c,d,x,y:longint;\n\nfunction cmmdc(a,b:longint):longint;\n begin\n if a=0 then cmmdc:=b else\n if b=0 then cmmdc:=a else\n if a>b then cmmdc:=cmmdc(b,a mod b) else\n cmmdc:=cmmdc(a,b mod a);\n end;\n\nbegin\n readln(a,b,c,d);\n if c/a=d/b then writeln('0/1') else\n begin\n if c/a>d/b then\n begin\n x:=a*d;\n y:=c*b;\n end else\n begin\n x:=b*c;\n y:=d*a;\n end;\n x:=y-x;\n a:=cmmdc(x,y);\n writeln(x div a,'/',y div a);\n end;\nend.\n"}, {"source_code": "//writen by zscnash\nProgram cf196bb;\n\nVar\n\n dqa,dqb,dqc,dqd,a,b,c,d,gcdab,gcdcd,aa,bb,bl,exb,exd,exa,exc,gcdac,gcdbd,dq,ansx,ansy:Int64;\n\n ans:Extended;\n\nFunction Gcd(a,b:Int64):Int64;\n\nBegin\n\n If (a Mod b=0) Then Exit(b) Else\n\n Exit(Gcd(b,a mod b));\n\nEnd;\n\nBegin\n\n ans:=19950920;\n\n Read(a,b);\n\n Readln(c,d);\n\n gcdab:=Gcd(a,b);\n\n gcdcd:=Gcd(c,d);\n\n a:=a Div gcdab;b:=b Div gcdab;\n\n c:=c Div gcdcd;d:=d Div gcdcd;\n\n aa:=a;bb:=b;\n\n gcdac:=Gcd(a,c);\n\n bl:=a*c Div gcdac Div a;\n\n exb:=b*bl;\n\n bl:=a*c Div gcdac Div c;\n\n exd:=d*bl;\n\n If exb>=exd Then Begin\n\n dq:=exb-exd;\n\n dqa:=a *c Div gcdac;\n\n IF dq/exb=exc Then Begin\n\n dq:=exa-exc;\n\n dqb:=b*d Div gcdbd;\n\n IF dq/exa c/d) then\n begin\n t := gcd(b,d);\n lsy := b*d div t;\n a := a * (lsy div b);\n c := c * (lsy div d);\n b := lsy;\n d := lsy;\n x := abs(a-c);\n y := a;\n if (x > y) then\n swap(x,y);\n t := gcd(x,y);\n x := x div t;\n y := y div t;\n writeln(x,'/',y);\n end;\n if (a/b < c/d) then\n begin\n t := gcd(a,c);\n lsy := a*c div t;\n b := b * (lsy div a);\n d := d * (lsy div c);\n a := lsy;\n c := lsy;\n x := abs(b-d);\n y := b;\n if (x > y) then\n swap(x,y);\n t := gcd(x,y);\n x := x div t;\n y := y div t;\n writeln(x,'/',y);\n end;\nend;\n\nbegin\n main;\nend.\n"}, {"source_code": "program zaD_1;\n var i,j,kol,n,m,a,b,c,d,k,t,x,min,nod:longint;\n s:int64;\n //a:array[0..1000000]of longint;\n function gcd(m,n:longint):longint;\n var modulo:longint;\n begin\n modulo:=m mod n;\n if modulo = 0 then\n gcd:=n\n else\n gcd:=gcd(n,modulo);\n end;\n\n\nBEGIN\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(a,b,c,d);\n nod:=gcd(a,b);\n a:=a div nod;\n b:=b div nod;\n\n nod:=gcd(c,d) ;\n c:=c div nod;\n d:=d div nod;\n\n //kof:=c/d;\n\n\n if ((a*d)/c)<=b then\n begin\n k:=b*c;\n k:=k-(a*d);\n nod:=gcd(k,c*b);\n writeln(k div nod,'/',(c*b) div nod);\n end\n else\n begin\n k:=a*d;\n k:=k-(b*c);\n nod:=gcd(k,d*a);\n writeln(k div nod,'/', d*a div nod);\n end;\n\n\n\nEND.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Var a,b,c,d,pos,fm,pos1,fm1:longint;\n \nFunction Gcd(x,y:longint):longint;\n begin\n if y=0 then exit(x)\n\t else exit(Gcd(y,x mod y));\n end;\n\nBegin\n read(a,b,c,d);\n {if a0 do\n begin\n t:=a mod b;\n a:=b;\n b:=t;\n end;\n mcd:=b;\nend;\nbegin\n readln(a,b,p,q);\n if (p*b<=q*a) then\n begin\n pp[1]:=q*a-p*b;\n pp[2]:=q*a;\n end\n else\n begin\n pp[1]:=p*b-q*a;\n pp[2]:=p*b;\n end;\n m:=mcd(pp[1],pp[2]);\n for i:=1 to 2 do\n pp[i]:=pp[i] div m;\n writeln(pp[1],'/',pp[2]);\nend."}, {"source_code": "program bb;\nvar\n a , b , c , d , bc , ta , tb , tc , td , t1 ,t2 , du : int64;\n kq1 : double;\nfunction ucln ( x , y : int64 ) : int64;\nvar\n r : int64;\nbegin\n if x = 0 then exit ( x );\n while y <> 0 do\n begin\n r := x mod y;\n x := y;\n y := r;\n end;\n exit ( x );\nend;\nbegin\n readln ( a , b , c , d );\n du := ucln ( a ,b );\n a := a div du;\n b := b div du;\n du := ucln ( c , d );\n c := c div du;\n d := d div du;\n bc := a * c div ucln ( a , c );\n ta := bc; tb := b * bc div a;\n tc := bc; td := d * bc div c;\n kq1 := maxlongint;\n if td < tb then\n begin\n du := tb - td ;\n kq1 := du / tb;\n bc := ucln ( du , tb );\n if bc = 0 then\n begin\n t1 := 0; t2 := 1;\n end\n else\n begin\n t1 :=du div bc ;\n t2 := tb div bc;\n end;\n\n end;\n bc := b * d div ucln ( b , d );\n ta := a * bc div b; tb := bc;\n tc := c * bc div d; td := bc;\n if tc < ta then\n begin\n du := ta - tc;\n if kq1 > du / ta then\n begin\n bc := ucln ( du , ta );\n if bc = 0 then\n begin\n t1 := 0; t2 := 1;\n end\n else\n begin\n t1 := du div bc;\n t2 := ta div bc;\n end;\n end;\n end;\n if t2 = 0 then t2 := 1;\n writeln ( t1 , '/' , t2 );\nend.\n"}, {"source_code": "var\n\ta,b,c,m,n,k,x,y,z:longint;\n\taa,bb,mm,nn:longint;\n\nprocedure gcd(n1,n2:longint);\nbegin\n\tif n1 mod n2 = 0\n\tthen z:=n2\n\telse gcd(n2,n1 mod n2);\nend;\n\nbegin\n\tread(a,b,m,n);\n\tif a * n > m * b\n\tthen\n\tbegin\n\t\tnn:=a*n - m * b;\n\t\tmm:=a*n;\n\tend\n\telse\n\tbegin\n\t\tnn:=m*b - a*n;\n\t\tmm:=b*m;\n\tend;\n\tif mm * nn <> 0 then\n\tbegin\n\t\tgcd(mm,nn);\n\t\tmm:=mm div z;\n\t\tnn:=nn div z;\n\t\twriteln(nn,'/',mm);\n\tend\n\telse writeln('0/1');\nend."}, {"source_code": " {$APPTYPE CONSOLE}\nconst besk=2000000000000000000;\n label 1,2,3,4;\nvar shag,p,k,nn,n,i10,i100,n1,dl,ii,jj,i3,i2,i1,j1,k1,kt,ppp,mask,i0,j0,step,i,j,start,finish:longint;\na1,a2,b1,b2,kol,t,cc,m1,pl,sum,p1,p2,m,k2,r,ot,aa,bb,x1,y1,x0,y0,ll,rr,d1,d2,kolvyk,xx2,q,t1,t2,modul,pp,tt,ot1,ot2,s,kold,kkr:int64;\naeqb,agrb,bgra,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndist:array[-10..3010,-10..3010] of int64;\nddd,distot:double;\nak,bk,c,b,a,zz,x,y: array[-300000..500000] of int64;\nzapx,zapy:array[0..20000] of boolean;\ngr1,gr: array[-50..2000,-50..2000] of int64;\nee,deg,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss1,sss,sss2:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr :array[-10 ..200000] of int64;\nssot:array[-1000..1100000] of char;\nstepen:array[0..1000] of int64;\nname:array[0..2000] of string;\nfunction min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n\n\n function nod(a,b:int64):int64; var p,t:int64;\nbegin if (a>0)and(b>0) then\n begin while (b>0) do begin t:=a mod b;a:=b;b:=t; end;\n p:=a;\n end else if a=0 then p:=b else p:=a;\nnod:=p;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\nbegin\n {assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n modul:=1000000007 ;\nread(a1,b1,a2,b2);\nif (a2*b1a)or (d>b) then\n begin\n if (a/c)<(b/d) then\n begin\n x:=b*c-a*d;\n y:=b*c;\n end\n else\n begin\n x:=a*d-b*c ;\n y:=a*d;\n end;\n end;\n\n k:=nod(x,y);\n x:=x div k;\n y:=y div k;\n\n Writeln(x,'/',y);\n\n\nend.\n"}, {"source_code": "program prog1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\n var s1, s,n,m,i,j,k,t,a,b,c,d,x,y: integer;\n mas: array [1..1000] of integer;\n\nprocedure swap(var x,y: Integer);\nvar t: integer;\nbegin\n t:=x;\n x:=y;\n y:=t;\nend;\n\nfunction nod(aa,bb: integer): integer;\nvar i,j,k: integer;\nbegin\n i:=aa;\n j:=bb;\n repeat\n k:=i mod j;\n i:=j;\n j:=k;\n until k=0;\n nod:=i;\n\nend;\n\n\n\n\nbegin\n\n Readln(a,b,c,d);\n\n if (a/c)<(b/d) then\n begin\n x:=b*c-a*d;\n y:=b*c;\n end\n else\n begin\n x:=a*d-b*c ;\n y:=a*d;\n end;\n\n\n\n\n k:=nod(x,y);\n x:=x div k;\n y:=y div k;\n\n Writeln(x,'/',y);\n\n\nend."}, {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n a, b, c, d, s , s1, t, x: integer;\nfunction nod (z, q: integer): integer;\nbegin\n if (z < q) then\n begin\n x := z;\n z := q;\n q := x;\n end;\n while (z > 0) and (q > 0) do\n begin\n x := z mod q;\n z := q;\n q := x;\n end;\n result := z;\nend;\nbegin\n readln(a, b, c, d);\n s := a * d;\n s1 := b * c;\n t := nod(s, s1);\n if (s < s1) then\n begin\n x := s;\n s := s1;\n s1 := x;\n end;\n s := s div t;\n s1 := s1 div t;\n writeln(s - s1, '/', s);\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x,x1,y,y1,k,z,z1,i:Integer;\nfunction min(x,y:Integer):Integer;\nbegin\n if (xy) then\n max:=x\n else\n max:=y;\nend;\nbegin\n readln(x,y,x1,y1);\n x:=x*y1;\n y:=y*x1;\n for i:=1000000 downto 2 do\n while (x mod i=0) and (y mod i=0) and ((x>0) or (y>0)) do\n begin\n x:=x div i;\n y:=y div i;\n end;\n write(max(x,y)-min(x,y),'/',max(x,y));\n readln;\n readln;\nend."}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n maxx,minn,s,a,b,c,d,x,y:integer;\nfunction nod(x,y:integer):integer;\nbegin\n if(x<>0)then\n nod:=nod(y mod x,x)\n else\n nod:=y;\nend;\nfunction max(a,b:integer):integer;\nbegin\n if(a>b)then\n max:=a\n else\n max:=b;\nend;\nfunction min(a,b:integer):integer;\nbegin\n if(a=r then Exit;\n i:=l;\n j:=r;\n x:=a[random(r-l+1)+l];\n repeat\n while a[i]x do j:=j-1;\n if i<=j then\n begin\n swap(a[i],a[j]);\n i:=i+1;\n j:=j-1;\n end;\n\n until i>j;\n qsort1(a,l,j);\n qsort1(a,i,r);\n\nend;}\nfunction NOD(a,b1:integer):integer;\nvar x,y:integer;\nbegin\n x:=a;\n y:=b1;\n while x mod y<>0 do\n begin\n x:=x mod y;\n if xc*b1 then\n begin\n x:=a*d-c*b1;\n y:=a*d;\n del(y,x);\n end else\n begin\n x:=b1*c-a*d;\n y:=b1*c;\n del(y,x);\n end;\n write (x,'/',y);\n \n\n\n\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000001;\nvar\n a,b,c,d,tu,mau,tg:int64;\n a1,b1,t,m,t1:extended;\n dem,i,j:integer;\n nc:array[1..1000000]of int64;\n\nfunction gcd(a,b:int64):int64;\nvar\n r:int64;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n //assign(input,'196B.INP');reset(input);\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n if t=0 then\n begin\n writeln(0,'/',1);\n halt;\n end;\n t:=t/m;dem:=0;\n t1:=t;\n while (abs(round(t)-t)>saiso) do\n begin\n inc(dem);nc[dem]:=trunc(t);\n t:=t-nc[dem];\n t:=1/t;\n end;\n tu:=1;mau:=round(t);\n for i:=dem downto 1 do\n begin\n tu:=tu+mau*nc[i];\n tg:=tu;tu:=mau;mau:=tg;\n end;\n tg:=gcd(tu,mau);\n if (mau/tu-t1)<=saiso then\n writeln(mau div tg,'/',tu div tg) else\n writeln(tu div tg,'/',mau div tg);\nend.\n"}, {"source_code": "Const\n fin = '';\n fon = '';\nVar\n x1 , x2 , y1 , y2 , kq : Longint;\nProcedure Start;\n Begin\n Assign (input , fin);\n Reset (input);\n Assign (output , fon);\n Rewrite (output);\n End;\nProcedure Tries (a , b: Longint);\n Var tmp : Longint;\n Begin\n if (a Mod b) <> 0 then\n begin\n tmp := b;\n b := a Mod b;\n a := tmp;\n Tries (a , b);\n end\n else kq := b;\n End;\nProcedure Programe;\n Var t , tmp1 , tmp2 : Longint;\n Begin\n readln (x1 , y1 , x2 , y2);\n tmp1 := y1 * x2;\n tmp2 := x1 * y2;\n if tmp1 < tmp2 then\n begin\n t := tmp1;\n tmp1 := tmp2;\n tmp2 := t;\n end;\n Tries (tmp1 , tmp2);\n tmp1 := tmp1 Div kq;\n kq := tmp1 - (tmp2 Div kq);\n writeln (kq , '/' , tmp1);\n End;\nProcedure Finish;\n Begin\n Close (input);\n Close (output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd."}, {"source_code": "var\n a1,b1,a2,b2,i,j,k,l,m,n,md:longint;\nprocedure gcd(y,z:longint);\nvar\n q,o,p:longint;\nbegin\n if y mod z=0 then md:=z\n else begin\n q:=z;\n z:=y mod z;\n y:=q;\n gcd(y,z);\n end;\nend;\nbegin\n readln(a1,b1,a2,b2);\n i:=b1*a2;\n j:=a1*b2;\n if i=c1*d1) and (c1<=a1) and (d1<=b1) then\n begin\n x1:=a1*b1;\n x2:=c1*d1;\n x3:=x1;\n x4:=x2;\n While (x3>0) and (x4>0) do\n if x3>x4 then x3:=x3 mod x4\n else x4:=x4 mod x3;\n x1:=x1 div (x3+x4);\n x2:=x2 div (x3+x4);\n if x2/x1>ans/ans1 then begin ans:=x2; ans1:=x1; end;\n end;\n end;\n WriteLn(ans1-ans,'/',ans1);\n end."}, {"source_code": "program pa1;\n\ntype\n fraction=record\n p,q:int64;\n end;\n \nvar\n a,b,c,d:int64;\n ars,arm:real;\n vr,hr,br,ans:fraction;\n\nfunction gcd(x,y:int64):int64;\nbegin\n if ((x=0) and (y=0)) then exit(1);\n if (x=0) then exit(y);\n if (y=0) then exit(x);\n if (x(f2.p*f1.q)) then exit(true) else exit(false);\nend;\n\nbegin\n // axb , cxd\n readln(a,b,c,d);\n vr.p:=c;\n vr.q:=a;\n hr.p:=d;\n hr.q:=b;\n if (gt(vr,hr)) then\n begin\n br:=vr;\n end\n else\n begin\n br:=hr;\n end;\n {writeln(br.p,'/',br.q);}\n \n ans.q:=a*b*br.p*br.p;\n ans.p:=(a*b*br.p*br.p)-((c*d*br.q*br.q));\n ans:=reduce(ans);\n writeln(ans.p,'/',ans.q);\nend.\n \n \n"}, {"source_code": "program pa1;\n\ntype\n fraction=record\n p,q:int64;\n end;\n \nvar\n a,b,c,d:int64;\n ars,arm:real;\n vr,hr,br,ans:fraction;\n\nfunction gcd(x,y:int64):int64;\nbegin\n\n if (x(f2.p*f1.q)) then exit(true) else exit(false);\nend;\n\nbegin\n // axb , cxd\n readln(a,b,c,d);\n vr.p:=c;\n vr.q:=a;\n hr.p:=d;\n hr.q:=b;\n if (gt(vr,hr)) then\n begin\n br:=vr;\n end\n else\n begin\n br:=hr;\n end;\n {writeln(br.p,'/',br.q);}\n \n ans.q:=a*b*br.p*br.p;\n ans.p:=(a*b*br.p*br.p)-((c*d*br.q*br.q));\n ans:=reduce(ans);\n writeln(ans.p,'/',ans.q);\nend.\n \n \n"}, {"source_code": "var a,b,c,d: LongInt;\n\nfunction nsd(x,y: LongInt): LongInt;\nvar res: LongInt;\nbegin\n while (x>0) and (y>0) do\n if x>y then x:=x mod y else y:=y mod x;\n nsd:=x+y;\nend;\n\nbegin\n Readln(a,b,c,d);\n if a*dy do\n if x mod y=0 then\n x:=y\n else\n if y mod x=0 then\n y:=x\n else\n if x>y then\n x:=x mod y\n else\n y:=y mod x;\n gcd:=x;\nend;\nbegin\n readln(a,b,c,d);\n if a*d>b*c then begin\n x:=a*d-b*c;\n y:=a*d;\n end\n else begin\n x:=b*c-a*d;\n y:=b*c;\n end;\n writeln(x div gcd(x,y),'/',y div gcd(x,y));\n readln;\nend."}, {"source_code": "program ddd;\nvar a,b,c,d,ch1,ch2,k:longint;\nfunction nsd(x,y:longint):longint;\nbegin\n if x>0 then nsd:=nsd(y mod x,x) else nsd:=y;\nend;\nbegin\n read(a,b,c,d);\n ch1:=a*d;\n ch2:=b*c;\n if ch1>ch2 then\n begin\n k:=nsd(ch1-ch2,ch1);\n writeln((ch1-ch2) div k,'/',ch1 div k);\n end else\n begin\n k:=nsd(ch2-ch1,ch2);\n writeln((ch2-ch1) div k,'/',ch2 div k);\n end;\n end.\n"}, {"source_code": "var a,b,c,d:longint;\n\nfunction gcd(x1,x2:longint):longint;\nvar tmp:longint;\nbegin\n while x2<>0 do\n begin\n tmp:=x1 mod x2;\n\tx1:=x2;x2:=tmp;\n end;\n exit(x1);\nend;\n\nfunction work1:boolean;\nvar tmp,x1,x2,y1,y2,y3:longint;\nbegin\n tmp:=a*c div gcd(a,c);\n x1:=b*tmp div a;\n x2:=d*tmp div c;\n if x1y) then\n max:=x\n else\n max:=y;\nend;\nbegin\n readln(x,y,x1,y1);\n x2:=x1;\n y2:=y1;\n while (x1y) then\n max:=x\n else\n max:=y;\nend;\nbegin\n readln(x,y,x1,y1);\n x:=x*x1;\n y:=y*y1;\n for i:=1000000 downto 2 do\n while (x mod i=0) and (y mod i=0) and ((x>0) or (y>0)) do\n begin\n x:=x div i;\n y:=y div i;\n end;\n write(max(x,y)-min(x,y),'/',max(x,y));\n readln;\n readln;\nend.\n"}, {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x,x1,y,y1,x2,y2:Integer;\nfunction max(x,y:Integer):Integer;\nbegin\n if (x>y) then\n max:=x\n else\n max:=y;\nend;\nbegin\n readln(x,y,x1,y1);\n x2:=x1;\n y2:=y1;\n while (x1y) then\n max:=x\n else\n max:=y;\nend;\nbegin\n readln(x,y,x1,y1);\n x2:=x1;\n y2:=y1;\n while (xb)then\n max:=a\n else\n max:=b;\nend;\nfunction min(a,b:integer):integer;\nbegin\n if(ad)then\n writeln(1,'/',a*b-(d-(a-c)))\n else\n writeln(1,'/',a*b-(c-(b-d)));\n end;\n end;\n readln;\n readln;\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000000001;\nvar\n a,b,c,d,i,j:int64;\n a1,b1,t,m:real;\n tu,mau:integer;\n\nfunction gcd(a,b:integer):integer;\nvar\n r:integer;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n if t=0 then\n begin\n writeln(0,'/',1);\n halt;\n end;\n for tu:=1 to 4000 do\n for mau:=1 to 4000 do\n if (abs(tu/mau-t/m)<=saiso) and (gcd(tu,mau)=1) then\n begin\n writeln(tu,'/',mau);\n halt;\n end;\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000001;\nvar\n a,b,c,d,tu,mau,tg:int64;\n a1,b1,t,m,t1:real;\n dem,i,j:integer;\n nc:array[1..1000000]of integer;\n\nfunction gcd(a,b:int64):int64;\nvar\n r:int64;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n //assign(input,'196B.INP');reset(input);\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n if t=0 then\n begin\n writeln(0,'/',1);\n halt;\n end;\n t:=t/m;dem:=0;\n t1:=t;\n repeat\n inc(dem);nc[dem]:=trunc(t);\n t:=t-nc[dem];\n t:=1/t;\n if abs(round(t)-t)<=saiso then\n break;\n until false;\n tu:=1;mau:=round(t);\n for i:=dem downto 1 do\n begin\n tu:=tu+mau*nc[i];\n tg:=tu;tu:=mau;mau:=tg;\n end;\n tg:=gcd(tu,mau);\n if (mau/tu-t1)<=saiso then\n writeln(mau div tg,'/',tu div tg) else\n writeln(tu div tg,'/',mau div tg);\nend.\n"}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000000001;\nvar\n a,b,c,d,i,j:int64;\n a1,b1,t,m:real;\n tu,mau:integer;\n\nfunction gcd(a,b:integer):integer;\nvar\n r:integer;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n for tu:=1 to 4000 do\n for mau:=1 to 4000 do\n if (abs(tu/mau-t/m)<=saiso) and (gcd(tu,mau)=1) then\n begin\n writeln(tu,'/',mau);\n halt;\n end;\nend."}, {"source_code": "Uses math;\nVar a,b,c,d,i,j,ans,ans1,a1,b1,c1,d1,x1,x2,x3,x4,t:LongInt;\n begin\n ans1:=maxLongINt;\n ans:=0;\n Read(a,b,c,d);\n For i:=1 to 1000 do\n begin\n a1:=a*i;\n b1:=b*i;\n c1:=c;\n d1:=d;\n if (a1*b1>=c1*d1) and (c1<=a1) and (d1<=b1) then\n begin\n t:=min(abs(a1-c1),abs(b1-d1));\n c1:=c1+t;\n d1:=d1+t;\n x1:=a1*b1;\n x2:=c1*d1;\n x3:=x1;\n x4:=x2;\n While (x3>0) and (x4>0) do\n if x3>x4 then x3:=x3 mod x4\n else x4:=x4 mod x3;\n x1:=x1 div (x3+x4);\n x2:=x2 div (x3+x4);\n if (x1ans)) then begin ans:=x2; ans1:=x1; end;\n break;\n end;\n end;\n if ans1-ans=0 then WriteLn('1','/','1');\n WriteLn(ans1-ans,'/',ans1);\n end."}, {"source_code": "Uses math;\nVar a,b,c,d,j,ans,ans1,a1,b1,c1,d1,x1,x2,x3,x4,t:Int64;\n i:LongInt;\n begin\n ans1:=maxLongINt;\n ans:=0;\n Read(a,b,c,d);\n For i:=1 to 1000 do\n begin\n a1:=a*i;\n b1:=b*i;\n c1:=c;\n d1:=d;\n if (a1*b1>=c1*d1) and (c1<=a1) and (d1<=b1) then\n begin\n t:=min(abs(a1-c1),abs(b1-d1));\n c1:=c1+t;\n d1:=d1+t;\n x1:=a1*b1;\n x2:=c1*d1;\n x3:=x1;\n x4:=x2;\n While (x3>0) and (x4>0) do\n if x3>x4 then x3:=x3 mod x4\n else x4:=x4 mod x3;\n x1:=x1 div (x3+x4);\n x2:=x2 div (x3+x4);\n if (x1ans)) then begin ans:=x2; ans1:=x1; end;\n break;\n end;\n end;\n WriteLn(ans1-ans,'/',ans1);\n end."}, {"source_code": "Uses math;\nVar a,b,c,d,i,j,ans,ans1,a1,b1,c1,d1,x1,x2,x3,x4,t:LongInt;\n begin\n ans1:=maxLongINt;\n ans:=0;\n Read(a,b,c,d);\n For i:=1 to 1000 do\n begin\n a1:=a*i;\n b1:=b*i;\n c1:=c;\n d1:=d;\n if (a1*b1>=c1*d1) and (c1<=a1) and (d1<=b1) then\n begin\n t:=min(abs(a1-c1),abs(b1-d1));\n c1:=c1+t;\n d1:=d1+t;\n x1:=a1*b1;\n x2:=c1*d1;\n x3:=x1;\n x4:=x2;\n While (x3>0) and (x4>0) do\n if x3>x4 then x3:=x3 mod x4\n else x4:=x4 mod x3;\n x1:=x1 div (x3+x4);\n x2:=x2 div (x3+x4);\n if (x1ans)) then begin ans:=x2; ans1:=x1; end;\n break;\n end;\n end;\n WriteLn(ans1-ans,'/',ans1);\n end."}, {"source_code": "var a,b,c,d,zn1,zn2,ch,k,zn:longint;\nfunction nsd(x,y:longint):longint;\nbegin\n if x>0 then nsd:=nsd(y mod x,x) else nsd:=y;\nend;\nbegin\n read(a,b,c,d);\n ch:=abs(a*d-b*c);\n zn1:=b*d;\n zn2:=a*c;\n if zn1a4 then\n begin\n min1:=a2-a4; min2:=a2;\n min:=min1/min2;\n end;\n gcd(b,d);\n lcm2:=b*d div x;\n a2:=lcm2; a4:=lcm2;\n a1:=a*lcm2 div b;\n a3:=c*lcm2 div d;\n if a1>a3 then\n begin\n if (a1-a3)/a1a4 then\n begin\n min1:=a2-a4; min2:=a2;\n min:=min1/min2;\n end;\n gcd(b,d);\n lcm2:=b*d div x;\n a2:=lcm2; a4:=lcm2;\n a1:=a*lcm2 div b;\n a3:=c*lcm2 div d;\n if a1>a3 then\n begin\n if (a1-a3)/a1b*c then\n begin\n temp:=a;a:=b;b:=temp;\n temp:=c;c:=d;d:=temp;\n end;\n p:=a*d;\n q:=b*c;\n p:=q-p;\n for i:=p downto 2 do\n if (p mod i=0)and(q mod i=0) then\n begin\n p:=p div i;\n q:=q div i;\n end;\n writeln(p,'/',q);\nend."}, {"source_code": "{$MODE OBJFPC}\nconst\n saiso=0.000000001;\nvar\n a,b,c,d,i,j:int64;\n a1,b1,t,m:real;\n tu,mau:integer;\n\nfunction gcd(a,b:integer):integer;\nvar\n r:integer;\nbegin\n while (b<>0) do\n begin\n r:=a mod b;\n a:=b;b:=r;\n end;\n exit(a);\nend;\n\nbegin\n readln(a,b,c,d);\n b1:=c/a*b;a1:=d/b*a;\n if b1>=d then\n begin\n m:=b1;\n t:=b1-d;\n end else\n begin\n m:=a1;\n t:=a1-c;\n end;\n for tu:=1 to 4000 do\n for mau:=1 to 4000 do\n if (abs(tu/mau-t/m)<=saiso) and (gcd(tu,mau)=1) then\n begin\n writeln(tu,'/',mau);\n halt;\n end;\nend."}, {"source_code": "//uses math;\nvar\n p,a,b,n,m,k,t, l,i,j,e,i2,j2, x,x1,x2,x3,xx,y,y1,y2,y3,yy,z,z1,z2,z3,zz,w,r,c :longint;\n d:array[0..1000001]of longint;\n s:array[0..1001,0..1001]of longint;\n ans,res,max,min,sum,best:int64;\n h:boolean;\n flag:array[0..1001,0..1001]of boolean;\n q:real;\n\nbegin ans:=0;res:=0;max:=0;min:=0;sum:=0;best:=0;//assign(input,'input.txt');reset(input); assign(output,'output.txt');reset(output);\n readln(a,b,x,y);\n while (a abs(1-x/y) then begin\n w:=a; a:=b; b:=w;\n w:=y; y:=x; x:=w;\n end;\n p:=y*a;\n b:=b*x;\n for i:=1000 downto 1 do\n if (p mod i=0) and (b mod i=0) then begin\n p:=p div i;\n b:=b div i;\n end;\n writeln(b-p,'/',b);\n readln; readln; //close(input); close(output);\nend.\n"}, {"source_code": "//uses math;\nvar\n p,a,b,n,m,k,t, l,i,j,e,i2,j2, x,x1,x2,x3,xx,y,y1,y2,y3,yy,z,z1,z2,z3,zz,w,r,c :longint;\n d:array[0..1000001]of longint;\n s:array[0..1001,0..1001]of longint;\n ans,res,max,min,sum,best:int64;\n h:boolean;\n flag:array[0..1001,0..1001]of boolean;\n q:real;\n\nbegin ans:=0;res:=0;max:=0;min:=0;sum:=0;best:=0;//assign(input,'input.txt');reset(input); assign(output,'output.txt');reset(output);\n readln(a,b,x,y);\n while (a abs(1-x/y) ) or (y>x) then begin\n w:=a; a:=b; b:=w;\n w:=y; y:=x; x:=w;\n end;\n p:=y*a;\n b:=b*x;\n for i:=1000 downto 1 do\n if (p mod i=0) and (b mod i=0) then begin\n p:=p div i;\n b:=b div i;\n end;\n writeln(b-p,'/',b);\n readln; readln; //close(input); close(output);\nend.\n"}, {"source_code": "//uses math;\nvar\n p,a,b,n,m,k,t, l,j,e,i2,j2, x,x1,x2,x3,xx,y,y1,y2,y3,yy,z,z1,z2,z3,zz,w,r,c :int64;\n d:array[0..1000001]of longint;\n s:array[0..1001,0..1001]of longint;\n ans,res,max,min,sum,best:int64;\n h:boolean;\n flag:array[0..1001,0..1001]of boolean;\n i:longint;\n\nbegin ans:=0;res:=0;max:=0;min:=0;sum:=0;best:=0;//assign(input,'input.txt');reset(input); assign(output,'output.txt');reset(output);\n readln(a,b,x,y);\n while (a abs(1-x/y) ) then inc(t);\n if y>x then inc(t);\n if t=1 then begin\n w:=a; a:=b; b:=w;\n w:=y; y:=x; x:=w;\n end;\n p:=y*a;\n b:=b*x;\n for i:=1000 downto 1 do\n if (p mod i=0) and (b mod i=0) then begin\n p:=p div i;\n b:=b div i;\n end;\n writeln(b-p,'/',b);\n readln; readln; //close(input); close(output);\nend.\n"}, {"source_code": "Var a,b,c,d,z:longint;\nfunction nod(a,b:longint):longint;\nbegin\n if b>a\n then nod:=nod(b,a)\n else if b=0\n then nod:=a\n else nod:=nod(b, a mod b);\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(a,b,c,d);\n z:=nod(a,b);\n a:=a div z;\n b:=b div z;\n z:=nod(c,d);\n c:=c div z;\n d:=d div z;\n if (a=c)and(b=d)\n then begin\n writeln(0);\n halt(0);\n end;\n if a*d0) and (b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n s:=a+b;\n end;\n\n begin\n read(a,b,c,d);\n if (a>=c) and (b>=d) then begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t2-t1),'/',t1);\n end\n else begin\n t1:=b*c;\n t2:=d*a;\n\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t1-t2),'/',t1);\n end;\n end."}, {"source_code": "Var a,b,c,d,t1,t2,s:int64;\n\nprocedure tt(a,b:longint);\n begin\n while (a>0) and (b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n s:=a+b;\n end;\n\n begin\n read(a,b,c,d);\n if (a>=c) and (b>=d) then begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t2-t1),'/',t1);\n end\n else begin\n t1:=b*c;\n t2:=d*a;\n\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(abs(t1-t2),'/',t1+t2);\n end;\n end."}, {"source_code": "Var a,b,c,d,t1,t2,s:int64;\n\nprocedure tt(a,b:longint);\n begin\n while (a>0) and (b>0) do\n begin\n if a>b then a:=a mod b\n else b:=b mod a;\n end;\n s:=a+b;\n end;\n\n begin\n read(a,b,c,d);\n if (a>=c) and (b>=d) then begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(t2-t1,'/',t2);\n end\n else begin\n t1:=b*c;\n t2:=d*a;\n tt(t1,t2);\n t1:=t1 div s;\n t2:=t2 div s;\n writeln(t1-t2,'/',t1);\n end;\n end."}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nuses math;\nvar a,b,c,d ,ans1,m,n,x,ans2: integer;\nfunction gcd(x,y : integer) : integer;\n begin\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\n end;\nfunction lcm(x,y : integer) :integer;\n begin\n exit(x*y*gcd(x,y));\n end;\nprocedure th1;\n begin\n x := lcm(a,c);\n m:=x div a;\n n:=x div c;\n a:=x;\n c:=x;\n b:=b*m;\n d:=d*n;\n ans1:=abs(b-d);\n ans1:=ans1 div gcd(b,d);\n Writeln(ans1,'/',b div gcd(b,d));\n end;\nprocedure th2;\n begin\n x := lcm(b,d);\n m:=x div b;\n n:=x div d;\n b:=x;\n d:=x;\n a:=a*m;\n c:=c*n;\n ans1:=abs(a-c);\n ans1:=ans1 div gcd(a,c);\n Writeln(ans1,'/',a div gcd(a,c) );\n end;\nbegin\n readln(a,b,c,d);\n if c < d then th1 else th2;\n\nend."}, {"source_code": "{$MODE OBJFPC}\nprogram onlylove;\nuses math;\nvar a,b,c,d ,ans1,m,n,x,ans2: integer;\nfunction gcd(x,y : integer) : integer;\n begin\n if y=0 then exit(x);\n exit(gcd(y,x mod y));\n end;\nfunction lcm(x,y : integer) :integer;\n begin\n exit(x*y*gcd(x,y));\n end;\nprocedure th1;\n begin\n x := lcm(a,c);\n m:=x div a;\n n:=x div c;\n a:=x;\n c:=x;\n b:=b*m;\n d:=d*n;\n ans1:=abs(b-d);\n ans1:=ans1 div gcd(b,d);\n Writeln(ans1,'/',b div gcd(b,d));\n end;\nprocedure th2;\n begin\n x := lcm(b,d);\n m:=x div b;\n n:=x div d;\n b:=x;\n d:=x;\n a:=a*m;\n c:=c*n;\n ans1:=abs(a-c);\n ans1:=ans1 div gcd(a,c);\n Writeln(ans1,'/',a div gcd(a,c));\n end;\nbegin\n readln(a,b,c,d);\n if b < d then th1 else th2;\n\nend."}, {"source_code": "var\ns,g,ss,a,b,c,d:longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then max:=a\n else max:=b;\nend;\nfunction gcd(a,b:longint):longint;\nbegin\n if a mod b=0 then gcd:=b\n else gcd:=gcd(b,a mod b);\nend;\nbegin\n read(a,b,c,d);\n if a/b>c/d then\n begin\n g:=gcd(max(b,d),b+d-max(b,d));\n s:=b*d div g;\n ss:=s div b*a-s div d*c;\n writeln(ss div gcd(s div b*a,ss),'/',s div b*a div gcd(s div b*a,ss));\n end;\n if a/bb then max:=a\n else max:=b;\nend;\nfunction gcd(a,b:longint):longint;\nbegin\n if a mod b=0 then gcd:=b\n else gcd:=gcd(b,a mod b);\nend;\nbegin\n read(a,b,c,d);\n if a/b>c/d then\n begin\n g:=gcd(max(b,d),b+d-max(b,d));\n s:=b*d div g;\n ss:=s div b*a-s div d*c;\n writeln(ss div gcd(s div b*a,ss),'/',s div b*a div gcd(s div b*a,ss));\n end;\n if a/ba then begin\n\t\ttmp:=a;\n\t\ta:=b;\n\t\tb:=tmp;\n\tend;\n\trepeat\n\t\tc:=a mod b;\n\t\ta:=b;\n\t\tb:=c;\n\tuntil(c=0);\n\texit(a);\nend;\n\n\nvar a,b,c,d,p,q,tmp:longint;\nbegin\n\tread(a,b,c,d);\n\tif a*d>c*b then begin\n\t\tp:=a*d-b*c;\n\t\tq:=a*d;\n\tend\n\telse begin\n\t\tp:=b*c-a*d;\n\t\tq:=b*c;\n\tend;\n\tif p<>0 then begin \n\t\ttmp:=gcd(p,q);\n\t\tp:=p div tmp;\n\t\tq:=q div tmp;\n\tend;\n\twrite(p,'/',q);\nend.\t"}, {"source_code": "function gcd(a,b:longint):longint;\nvar tmp,c:longint;\nbegin\n\tif b>a then begin\n\t\ttmp:=a;\n\t\ta:=b;\n\t\tb:=tmp;\n\tend;\n\trepeat\n\t\tc:=a mod b;\n\t\ta:=b;\n\t\tb:=c;\n\tuntil(c=0);\n\texit(a);\nend;\n\n\nvar a,b,c,d,p,q,tmp:longint;\nbegin\n\tread(a,b,c,d);\n\tif a*d>c*b then begin\n\t\tp:=a*d-b*c;\n\t\tq:=a*d;\n\tend\n\telse begin\n\t\tp:=b*c-a*d;\n\t\tq:=b*c;\n\tend;\n\twriteln(p,' ',q);\n\ttmp:=gcd(p,q);\n\tp:=p div tmp;\n\tq:=q div tmp;\n\twrite(p,'/',q);\nend.\t"}, {"source_code": "Uses math;\nType\n mat=array [1..1000000] of longint;\nVar a,b,c,d,a1,b1,c1,d1:longint;\n res,kq:longint;\n fi,fo:text;\n\nProcedure Doc;\n Var i:longint;\n Begin\n Read(fi,a,b,c,d);\n a1:=a;b1:=b;c1:=c;d1:=d;\n end;\n\nFunction Ucln(x,y:longint):longint;\n Begin\n If x=0 then exit(y);\n If y=0 then exit(x);\n If x=d then\n Begin\n If b=d then Write(fo,0,'/',1)\n else\n Begin\n kq:=u;\n res:=b-d;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n If ok then exit;\n a:=a1;\n b:=b1;\n c:=c1;\n d:=d1;\n u:=Bcnn(b,d);\n a:=a*(u div b);\n c:=c*(u div d);\n b:=u;\n d:=u;\n If a>=c then\n Begin\n If a=c then Write(fo,0,'/',1)\n else\n Begin\n kq:=a;\n res:=a-c;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "Uses math;\nType\n mat=array [1..1000000] of longint;\nVar a,b,c,d,a1,b1,c1,d1:longint;\n res,kq:longint;\n fi,fo:text;\n\nProcedure Doc;\n Var i:longint;\n Begin\n Read(fi,a,b,c,d);\n a1:=a;b1:=b;c1:=c;d1:=d;\n end;\n\nFunction Ucln(x,y:longint):longint;\n Begin\n If x=0 then exit(y);\n If y=0 then exit(x);\n If x=d then\n Begin\n If b=d then Write(fo,1,'/',1)\n else\n Begin\n kq:=u;\n res:=b-d;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n If ok then exit;\n a:=a1;\n b:=b1;\n c:=c1;\n d:=d1;\n u:=Bcnn(b,d);\n a:=a*(u div b);\n c:=c*(u div d);\n b:=u;\n d:=u;\n If a>=c then\n Begin\n If a=c then Write(fo,1,'/',1)\n else\n Begin\n kq:=a;\n res:=a-c;\n u:=Ucln(kq,res);\n Write(fo,res div u,'/',kq div u);\n end;\n ok:=true;\n end;\n\n end;\n\nProcedure Inkq;\n Begin\n end;\n\n Begin\n Assign(fi,'');Reset(fi);\n Assign(fo,'');Rewrite(fo);\n Doc;\n Lam;\n Inkq;\n Close(fo);Close(fi);\n end.\n"}, {"source_code": "var a, b, c, d, p, q, x, y, z: int64;\nbegin\n readln(a, b, c, d);\n p := abs(b * c - a * d);\n q := a * c;\n x := p;\n y := q;\n while y > 0 do\n begin\n z := x;\n x := y;\n y := z mod x;\n end;\n writeln(p div x, '/', q div x);\nend."}, {"source_code": "var a,b,c,d,i,ans1,ans2:longint;\nBegin\n readln(a,b,c,d);\n if c>d then begin ans1:=b*c-a*d;ans2:=b*c; end else begin ans1:=a*d-b*c;ans2:=a*d;end;\n for i:=1000 downto 1 do\n if (ans1 mod i=0)and(ans2 mod i=0) then begin ans1:=ans1 div i;ans2:=ans2 div i; end;\n writeln(ans1,'/',ans2);\nEnd."}, {"source_code": "var a,b,c,d,i,ans1,ans2:longint;q1,q2:real;\nBegin\n readln(a,b,c,d);q1:=a/c;q2:=b/d;\n if q1d then begin ans1:=b*c-a*d;ans2:=b*c; end else begin ans1:=a*d-b*c;ans2:=a*d;end;\n ans1:=abs(ans1);ans2:=abs(ans2);\n for i:=1000 downto 1 do\n if (ans1 mod i=0)and(ans2 mod i=0) then begin ans1:=ans1 div i;ans2:=ans2 div i; end;\n writeln(ans1,'/',ans2);\nEnd."}, {"source_code": "var\n a, b, c, d,xm: longint;\n dx, dy: longint;\n tempk1, tempk2:real;\nfunction nod(x,y:integer):integer;\nbegin\n if y=0 then\n nod:=x\n else\n nod:=nod(y,(x mod y))\nend;\nbegin\n readln(a, b, c, d);\n if (a / b = 1) then begin\n \n if (c > d) then begin\n dx := c - d;\n dy := c;\n \n end\n else \n begin\n dx := d - c;\n dy := d;\n \n end;\n \n \n \n end\n else\n if (c / d = 1) then begin\n \n if (a > b) then begin\n dx := a - b;\n dy := a;\n \n end\n else \n begin\n dx := b - a;\n dy := b;\n \n end;\n \n \n end\n else\n //if (c>=a) or (d>=b) then\n begin\n tempk1 := c / a;\n tempk2 := d / b;\n if (tempk1 > tempk2) then\n begin\n dy := b * c - d * a; \n dx := c * a;\n \n end\n else\n begin\n dx := a * d - c * b; \n dy := d * b;\n \n end;\n end;\n \n\n writeln(dx div nod(dx,dy),'/',dy div nod(dx,dy));\n \n \nend."}, {"source_code": "var a,b,c,d:longint;\nprocedure swap(var a,b:longint);\nbegin\nend;\nfunction gcd(a,b:longint):longint;\nbegin\n if b=0 then exit(a);\n exit(gcd(b,a mod b));\nend;\nbegin\n readln(a,b,c,d);\n if a*d>c*b then\n begin\n swap(a,b);\n swap(c,d);\n end;\n writeln(b*c-a*d div gcd(b*c-a*d,b*c),'/',b*c div gcd(b*c-a*d,b*c));\nend."}, {"source_code": "var i,j,k,n,m,p,q,a,b,c,d:longint;\n\n\n function gcd(a,b:longint):longint;\n begin\n if a mod b=0 then exit(b);\n exit(gcd(b,a mod b));\n end;\n\n\nbegin\n readln(a,b,c,d);\n if b*c>a*d then\n begin\n p:=c*b-a*d;\n q:=b*c;\n end\n else\n begin\n p:=a*d-c*b;\n q:=a*d;\n end;\n p:=p div gcd(q,p);\n q:=q div gcd(q,p);\n writeln(p,'/',q);\nend."}, {"source_code": "var\n n, m :longint;\n i, j :longint;\n a :array[0..100] of longint;\n min :longint;\n\nprocedure swap(var a,b:longint);\nvar\n c :longint;\nbegin\n c:=a; a:=b; b:=c;\nend;\n\nbegin\n read(n,m);\n for i:=1 to m do read(a[i]);\n for i:=1 to m do\n for j:=i+1 to m do if a[i]>a[j] then swap(a[i],a[j]);\n\n min:=maxlongint;\n for i:=1 to m-n+1 do if min>a[i+n-1]-a[i] then min:=a[i+n-1]-a[i];\n writeln(min);\nend."}, {"source_code": "var\n a, b, c, d :longint;\n lcm1, lcm2 :longint;\n x :longint;\n a1, a2, a3, a4 :longint;\n min1, min2 :longint;\n min :real;\nprocedure gcd(a,b:longint);\nbegin\n if aa4 then\n begin\n min1:=a2-a4; min2:=a2;\n min:=min1/min2;\n end;\n gcd(b,d);\n lcm2:=b*d div x;\n a2:=lcm2; a4:=lcm2;\n a1:=a*lcm2 div b;\n a3:=c*lcm2 div d;\n if a1>a3 then\n begin\n if (a1-a3)/a1n then gcd:=gcd(m mod n, n);\n if n>m then gcd:=gcd(n mod m, m);\n end;\nend;\nbegin\nread(a,b,c,d);\nif a*d>b*c then \nbegin\nx:=b*c; y:=a*d;\nc:=gcd(x,y);\nx:=x div c;\ny:=y div c;\nend;\nif b*c>a*d then \nbegin\nx:=a*d; y:=b*c;\nc:=gcd(x,y);\nx:=x div c;\ny:=y div c;\nend;\nif b*c=a*d then begin x:=0; y:=1; end;\nWriteln(y-x,'/',y);\nend."}, {"source_code": "uses math;\n var a , b , c , d , del , acc , bcc : longint;\n\n\nfunction gsd(p , q : longint) : longint; begin\n if p = 0 then exit(q)\n else exit(gsd(q mod p , p));\nend;\n\nBEGIN\n\n readln(a , b , c , d);\n del := gsd(a , b); a := a div del; b := b div del;\n del := gsd(c , d); c := c div del; d := d div del;\n a := a * c * d; b := b * c * d;\n del := min(a div c , b div d);\n acc := a - c * del; bcc := b - d * del;\n if (acc = 0) and (bcc = 0) then begin writeln(0 , '/' , 1); halt; end;\n if acc = 0 then writeln(1 , '/' , b div bcc);\n if bcc = 0 then writeln(1 , '/' , a div acc);\n\nEND."}, {"source_code": " var a , b , c , d , t , p , q , cc , del : longint;\n\n\nfunction gsd(p , q : longint) : longint; begin\n if p = 0 then exit(q)\n else exit(gsd(q mod p , p));\nend;\n\nBEGIN\n\n readln(a , b , c , d);\n if a > b then begin cc := a; a := b; b := cc; end;\n if c > d then begin cc := c; c := d; d := cc; end;\n del := gsd(a , b); a := a div del; b := b div del;\n del := gsd(c , d); c := c div del; d := d div del;\n t := 1; while not((a * t >= c) and (b * t >= d)) do inc(t); a := a * t; b := b * t;\n t := 1; while (c * t <= a) and (d * t <= b) do inc(t); dec(t); c := c * t; d := d * t;\n q := a * b; p := q - c * d;\n writeln(p div gsd(p , q) , '/' , q div gsd(p , q));\n\nEND."}, {"source_code": "var a,b,c,d:word; p,q:dword;\nprocedure hv(var x,y:word);\nvar z:word;\nbegin\n z:=x; x:=y; y:=z\nend;\nfunction ucln(x:dword; y:word):word;\nvar z:dword;\nbegin\n while y>0 do\n begin\n x:=x mod y; z:=x; x:=y; y:=z\n end;\n ucln:=x\nend;\nprocedure tru(z:dword);\nbegin\n z:=z*q; p:=z-p; z:=ucln(p,q); p:=p div z; q:=q div z\nend;\nprocedure chia(z:dword);\nbegin\n q:=q*z; z:=ucln(p,q); p:=p div z; q:=q div z\nend;\nbegin\n read(a,b,c,d);\n if a=exd Then Begin\n\n dq:=exb-exd;\n\n dqa:=a *c Div gcdac;\n\n IF dq/dqa=exc Then Begin\n\n dq:=exa-exc;\n\n dqb:=b*d Div gcdbd;\n\n IF dq/dqb c/d) then\n begin\n t := gcd(b,d);\n lsy := b*d div t;\n a := a * (lsy div b);\n c := c * (lsy div d);\n b := lsy;\n d := lsy;\n x := abs(a-c);\n y := a;\n if (x > y) then\n swap(x,y);\n t := gcd(x,y);\n x := x div t;\n y := y div t;\n writeln(x,'/',y);\n end;\n if (a/b < c/d) then\n begin\n t := gcd(a,c);\n lsy := a*c div t;\n b := b * (lsy div a);\n d := d * (lsy div c);\n a := lsy;\n c := lsy;\n x := abs(b-d);\n y := b;\n if (x > y) then\n swap(x,y);\n t := gcd(x,y);\n x := x div t;\n y := y div t;\n writeln(x,'/',y);\n end;\nend;\n\nbegin\n main;\nend.\n"}, {"source_code": "program zaD_1;\n var i,j,kol,n,m,a,b,c,d,k,t,x,min,nod:longint;\n s:int64;\n //a:array[0..1000000]of longint;\n function gcd(m,n:longint):longint;\n var modulo:longint;\n begin\n modulo:=m mod n;\n if modulo = 0 then\n gcd:=n\n else\n gcd:=gcd(n,modulo);\n end;\n\n\nBEGIN\n { assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input);\n rewrite(output);}\n readln(a,b,c,d);\n nod:=gcd(a,b);\n a:=a div nod;\n b:=b div nod;\n\n nod:=gcd(c,d) ;\n c:=c div nod;\n d:=d div nod;\n\n //kof:=c/d;\n\n\n if ((a*d)/c)<=b then\n begin\n k:=b*c;\n k:=k-(a*d);\n nod:=gcd(k,c*b);\n writeln(k div nod,'/',(c*b) div nod);\n end\n else\n begin\n k:=a*c;\n k:=k-(b*d);\n nod:=gcd(k,c*a);\n writeln(k div nod,'/', c*a div nod);\n end;\n\n\n\nEND.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "Const Pt=100000000000;\nVar i,j,k:longint;\n\ta,b,c,d,pos,fm,pos1,fm1:longint;\n p:extended;\n\nProcedure Swap(var x,y:longint);\n var temp:longint;\n begin\n temp:=x; x:=y; y:=temp;\n end;\n \nFunction Gcd(x,y:longint):longint;\n begin\n if y=0 then exit(x)\n\t else exit(Gcd(y,x mod y));\n end;\n\nBegin\n read(a,b,c,d);\n if a 0 do\n begin\n r := x mod y;\n x := y;\n y := r;\n end;\n exit ( x );\nend;\nbegin\n readln ( a , b , c , d );\n du := ucln ( a ,b );\n a := a div du;\n b := b div du;\n du := ucln ( c , d );\n c := c div du;\n d := d div du;\n bc := a * c div ucln ( a , c );\n ta := bc; tb := b * bc div a;\n tc := bc; td := d * bc div c;\n kq1 := maxlongint;\n if td < tb then\n begin\n du := tb - td ;\n kq1 := du / tb;\n bc := ucln ( du , tb );\n if bc = 0 then\n begin\n t1 := 0; t2 := 0;\n end\n else\n begin\n t1 :=du div bc ;\n t2 := tb div bc;\n end;\n\n end;\n bc := b * d div ucln ( b , d );\n ta := a * bc div b; tb := bc;\n tc := c * bc div d; td := bc;\n if tc < ta then\n begin\n du := ta - tc;\n if kq1 > du / ta then\n begin\n bc := ucln ( du , ta );\n if bc = 0 then\n begin\n t1 := 0; t2 := 0;\n end\n else\n begin\n t1 := du div bc;\n t2 := ta div bc;\n end;\n end;\n end;\n writeln ( t1 , '/' , t2 );\nend.\n"}, {"source_code": "program bb;\nvar\n a , b , c , d , bc , ta , tb , tc , td , t1 ,t2 , du : int64;\n kq1 : double;\nfunction ucln ( x , y : int64 ) : int64;\nvar\n r : int64;\nbegin\n if x = 0 then exit ( x );\n while y <> 0 do\n begin\n r := x mod y;\n x := y;\n y := r;\n end;\n exit ( x );\nend;\nbegin\n readln ( a , b , c , d );\n du := ucln ( a ,b );\n a := a div du;\n b := b div du;\n du := ucln ( c , d );\n c := c div du;\n d := d div du;\n bc := a * c div ucln ( a , c );\n ta := bc; tb := b * bc div a;\n tc := bc; td := d * bc div c;\n kq1 := maxlongint;\n if td < tb then\n begin\n du := tb - td ;\n kq1 := du / tb;\n bc := ucln ( du , tb );\n if bc = 0 then\n begin\n t1 := 0; t2 := 1;\n end\n else\n begin\n t1 :=du div bc ;\n t2 := tb div bc;\n end;\n\n end;\n bc := b * d div ucln ( b , d );\n ta := a * bc div b; tb := bc;\n tc := c * bc div d; td := bc;\n if tc < ta then\n begin\n du := ta - tc;\n if kq1 > du / ta then\n begin\n bc := ucln ( du , ta );\n if bc = 0 then\n begin\n t1 := 0; t2 := 1;\n end\n else\n begin\n t1 := du div bc;\n t2 := ta div bc;\n end;\n end;\n end;\n writeln ( t1 , '/' , t2 );\nend."}], "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e"} {"source_code": "var s:string[90];\n\tn,i,c:longint;\n\tch:longint;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tch:=0;\n\ti:=1;\n\ts[n+1]:='0';\n\twhile i<=n do\n\tbegin\n\t\tc:=0;\n\t\twhile s[i]<>'0' do\n\t\tbegin\n\t\t\tinc(c);\n\t\t\tinc(i);\n\t\tend;\n\t\tch:=(ch*10)+c;\n\t\tinc(i);\n\tend;\n\tif s[n]='0' then ch:=(ch*10)+0;\n\twriteln(ch);\nEND.\n\n", "positive_code": [{"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n IF s[i]='1' then inc(a[j])\n else inc(j);\n inc(i); \n end;\nfor i:=1 to j do write(a[i]);\nend."}, {"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n IF s[i]='1' then inc(a[j])\n else inc(j);\n inc(i);\n end;\nfor i:=1 to j do write(a[i]);\nend.\n\n"}, {"source_code": "Program Chi;\nvar che:longint;\n j,i,n:byte;\n p,nu:array[0..100]of byte;\n s:string;\n\nbegin\nreadln(n);\nread(s);\nfor i:=n downto 1 do\n p[i]:=ord(s[i])-ord('0');\nnu[0]:=0; \nfor i:=1 to n do \n begin\n if p[i]=0 then\n begin\n inc(j);\n nu[j]:=i;\n end;\n end;\ninc(j);\nnu[j]:=n+1; \nfor i:=1 to j do\n che:=che*10+nu[i]-nu[i-1]-1;\nwriteln(che); \n\n\nend."}, {"source_code": "const fi='test.inp';\n fo='test.out';\nprocedure Nhap;\nvar i,d,n:longint;\n z:char;\nbegin\n //assign(input,fi);\n //reset(input);\n readln(n); d:=0;\n for i:=1 to n do\n begin\n read(z);\n if z='1' then inc(d);\n if z='0' then\n begin\n write(d);\n d:=0;\n end;\n end;\n write(d);\n //close(input);\nend;\n\nprocedure Main;\nvar i:longint;\nbegin\n\nend;\nprocedure Xuat;\nbegin\n assign(output,fo);\n rewrite(output);\n close(output);\nend;\nbegin\n Nhap;\n main;\n Xuat;\nend.\n"}, {"source_code": "var a,b,c,d,e,i,j:longint;\n s:string;\nbegin\n readln(a);\n readln(s);\n b:=0;\n c:=0;\n for i:=1 to a do\n begin\n if s[i]='1' then inc(b) else \n begin\n c:=c * 10+b;\n b:=0;\n end;\n end;\n writeln(c * 10+b);\nend."}, {"source_code": "const fin='binary.inp';fon='binary.out';\nvar i,j,m,n,k,o,u,x,y,c,d,e,f,s,t:longint;a:string;\nprocedure nhap;\n\tbegin\n\treadln(n);\n\treadln(a);\n\tend;\nprocedure tinh;\n\tbegin\n\tt:=0;\n\tfor i:=1 to n do\n\t\tbegin\n\t\tif a[i]='1' then inc(t)\n\t\telse\n\t\t\t\tbegin\n\t\t\t\twrite(t);\n\t\t\t\tt:=0;\n\t\t\t\tend;\n\t\tend;\n\twrite(t);\n\tend;\nbegin\n//assign(input,fin);\n//reset(input);\n//assign(output,fon);\n//rewrite(output);\nnhap;\ntinh;\nend."}, {"source_code": "var a,n,i:integer;\ns:string;\nbegin\nreadln(n);\nreadln(s);\na:=0;\nfor i:=1 to n do begin\n if s[i]='1' then \n a:=a+1\n else begin\n write(a);\n a:=0;\n end;\n end;\nwrite(a);\nend.\n "}, {"source_code": "var a,n,i:integer;\ns:string;\nbegin\nreadln(n);\nreadln(s);\na:=0;\nfor i:=1 to n do begin\n if s[i]='1' then \n a+=1\n else begin\n write(a);\n a:=0;\n end;\n end;\nwrite(a);\nend.\n "}, {"source_code": "var s:string;n,a,i:longint;\nBEGIN\nreadln(n);\nreadln(s);\nfor i:=1 to n do\nif s[i]='1' then a:=a+1 else\nif (s[i]='0')and(s[i-1]='0')then write('0')\n else begin write(a);a:=0;end;\nwrite(a);\nend."}, {"source_code": "//abcdefghijklmnopqrstuvwxyz\nvar\na,c,i:longint;\nb:char;\nbegin\nreadln(a);\nfor i:=1 to a do\n begin\n read(b);\n if b='1' \n then inc(c)\n else \n begin\n write(c);\n c:=0;\n end;\n end;\nwriteln(c); \nend."}, {"source_code": "var n:longint;\n x,i:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n s:=s+'0';\n for i:=1 to n+1 do\n if s[i]='0' then\n begin\n write(x);\n x:=0;\n end else inc(x);\nend.\n\n"}, {"source_code": "var ans:int64;\nb,i,n:integer;s:String;\nbegin\n ans:=0;\n readln(n);\n readln(s);\n s:=s+'0';\n \n b:=1;\n for i:=2 to length(s) do begin\n \n if s[i]='1' then inc(b) \n else if (s[i]='0') then begin \n \n if s[i-1]='1' then begin\n ans:=ans*10+b; \n b:=0;end else begin\n ans:=ans*10;\n end;\n \n \n \n end;\n end;\n \n writeln(ans);\nend.\n"}, {"source_code": "var\n n, i, k, kp: integer;\n str: string;\n a: array [1..1000] of integer;\nbegin\n readln(n); \n readln(str);\n \n str:= str+'0';\n k:=0; kp:=0;\n \n for i:= 1 to n+1 do\n begin\n if (str[i] = '1') then k:=k+1;\n if (str[i] = '0') then \n begin\n kp:=kp + 1;\n a[kp]:= k;\n \n k:= 0;\n end;\n end;\n a[kp+1]:= k;\n for i:= 1 to kp do write (a[i]);\nend."}, {"source_code": "program twoface;\nvar n, i, num, zerg,k,r:integer;\na:array[1..89]of integer;\nvar s:string[90];\nbegin\nreadln(n);\nread(s);\n\n\nk:=1;\nfor i:=1 to n do\nbegin\nif s[i] = '1' \n then \n begin\n num:=num+1;\n for r:= 1 to zerg-1 do\n begin\n a[k]:=0;\n k:=k+1;\n end;\n zerg:=0;\n end\n else\n begin \n if num>0 then \n begin\n a[k]:=num;\n k:=k+1;\n num:=0;\n end;\n\n zerg:=zerg+1;\n end;\nend;\nif num>0 then a[k]:= num; \n for r:= 1 to zerg-1 do\n begin\n a[k]:=0;\n k:=k+1;\n end;\nfor i:=1 to k do\nwrite(a[i]);\nfor i:= 1 to -1 do\nwrite('asdawdasd');\nend.\n"}, {"source_code": "program dvoich;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n: integer;\n s, ans: string;\n\nbegin\n readln(n);\n readln(s);\n i := 0;\n while (length(s) > 0) do\n begin\n if (s[1] = '1') or ((length(s) = 1) and (s[1] = '1')) then inc(i)\n else\n begin\n ans := ans + inttostr(i);\n i := 0;\n end;\n delete(s, 1, 1);\n end;\n if ans = '0' then\n writeln(ans)\n else\n writeln(ans + inttostr(i));\n readln;\n readln;\nend.\n"}, {"source_code": "\n const nn=1600000; nnn=200000;eps=0.0000000001;\n label 1,2;\n type real=extended; {string=ansistring;}\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;\n tt,ii,jj,step, i,j:longint;\n time:real;\n newpole,pole:array[-10..200,-10..200] of char;\n ssot,sssnew:array[-10..3000000] of char;\n smas:array[-10..2000000]of string;\n skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss3,ss1,ss2:string;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx,yy:array[-1..nn] of double;\n yot:double;\n prost:array [-1000..6000000] of boolean;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n read(ss);\n n:=length(ss);\n for i:=1 to n do if ss[i]='0' then begin inc(q);a[q]:=i; end;\n inc(q);a[q]:=n+1;\n for i:=1 to q do write(a[i]-a[i-1]-1);\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "program suhfiuw21742987;\n var s:string;\n n,i,a:integer;\n begin\n readln (n);\n readln (s);\n a:=0;\n for i:=1 to n do begin\n if s[i]='1' then \n a+=1\n else\n begin\n write (a);\n a:=0;\n end;\n end;\n write (a);\n end."}, {"source_code": "var\n n : integer;\n s : string;\n i,j : integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n readln(n);\n read(s);\n s:= s + '0';\n inc(n);\n i:= 1;\n while (i <= n) do\n begin\n if s[i] = '1' then\n begin\n j:= i+1;\n while (j <= n) and (s[j] = '1') do\n inc(j);\n write(j - i);\n i:= j + 1;\n end\n else\n begin\n write(0);\n i:= i + 1;\n end;\n end;\nEND.\n\n"}, {"source_code": "const\n fi='';\n fo='';\nvar n:longint;\n s:string;\nprocedure input;\nvar f:text;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n readln(f,s);\n close(f);\nend;\nfunction ans:string;\nvar st:string;\n i,dem:longint;\nbegin\n st:='';dem:=0;\n for i:=1 to n do\n begin\n if(s[i]='1')then inc(dem)\n else\n begin\n st:=st+chr(dem+48);\n dem:=0;\n end;\n end;\n st:=st+chr(dem+48);\n exit(st);\nend;\nprocedure output;\nvar f:text;\nbegin\n assign(f,fo);\n rewrite(f);\n writeln(f,ans);\n close(f);\nend;\nbegin\n input;\n output;\nend.\n"}, {"source_code": "var s:string;\n i,k,n:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n if(s[i]='1') then\n inc(k)\n else begin\n write(k);\n k:=0;\n end;\n end;\n write(k);\nend."}, {"source_code": "program zadacha_A;\nvar \n n,i,count,k: integer; \n s,temp:string;\nbegin\n readln(n);\n readln (s);\n temp:='';\n i:=1;count:=0;\n while (i<=n) do\n begin\n if s[i]<>'0' then\n temp:=temp+s[i]\n else\n begin\n if (length(temp)<>0) then write(length(temp));\n temp:=''; inc(count);\n if (s[i]='0') and(s[i+1]='0')then write(0);\n end;\n inc(i); \n end;\n write(length(temp));\nend."}, {"source_code": "var n,i,res: longint;\n\ts: string;\nBEGIN\nreadln(n);\nreadln(s);\nres:=0;\nfor i:=1 to n do begin\n\tif s[i]='1' then inc(res,1);\n\tif s[i]='0' then begin write(res); res:=0; end;\n\tif i=n then write(res);\nend;\nEND."}, {"source_code": "var n,i,o:longint;s:string;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n do\n if s[i]='1'then o:=o+ord(s[i])-48\n else\n begin\n write(o);\n o:=ord(s[i])-48;\n end;\nwrite(o);\nend."}, {"source_code": "var\n s:char;\n cnt,i,n:longint;\nbegin\nreadln(n);\nwhile i<=n do\n begin\n cnt:=0;\n inc(i);\n read(s);\n while (s<>'0') and (i<=n) do\n begin\n inc(cnt);\n inc(i);\n read(s);\n end;\n write(cnt);\n end;\nend."}, {"source_code": "var n,i,d:longint;\n s,k:string;\nprocedure solve;\nvar t:string;\nbegin\n i:=2; d:=1;\n while i<=n do\n begin\n if s[i]='1' then inc(d);\n if (s[i]='0') and (s[i-1]='1') then\n begin\n str(d,t);\n k:=k+t;\n d:=0;\n end;\n if (s[i]='0') and (s[i-1]='0') then\n begin\n k:=k+'0'; \n end;\n inc(i);\n end;\n str(d,t);\n k:=k+t;\n writeln(k);\nend;\n\nbegin\n readln(n);\n readln(s);\n k:='';\n solve;\nend.\n"}, {"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n IF s[i]='1' then inc(a[j])\n else inc(j);\n inc(i); \n end;\nfor i:=1 to j do write(a[i]);\nend."}, {"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n IF s[i]='1' then inc(a[j])\n else inc(j);\n inc(i);\n end;\nfor i:=1 to j do write(a[i]);\nend.\n\n"}, {"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n IF s[i]='1' then inc(a[j])\n else inc(j);\n inc(i); \n end;\nfor i:=1 to j do write(a[i]);\nend.\n"}, {"source_code": "var\tn,i,dem:longint;\n\tans:int64;\n\ts:ansistring;\nbegin\n\treadln(n);\n\treadln(S);\n\t\n\tans:=0;\n\ti:=1;\n\twhile i<=n do\n\tbegin\n\t\tdem:=0;\n\t\twhile (i<=n) and (s[i]='1') do\n\t\tbegin\n\t\t\tinc(Dem);\n\t\t\tinc(i);\n\t\tend;\n\t\tans:=ans*10+dem;\n\t\tinc(i);\n\tend;\n\twrite(ans);\n\tif s[n]='0' then write(0);\nend."}, {"source_code": "var n,i,j:byte;\n res:longint;\n s:string;\n\n begin\n readln(n);\n read(s);\n res:=0;\n i:=1;\n writeln;\n while i<=n do\nbegin\nif s[i]='1' then res:=res+1\nelse\nbegin\nwrite(res);\nres:=0;\nend;\n inc(i);\n end;\n write(res);\nreadln;\nend."}, {"source_code": "Var n,ans,k,i,f:longint;\nS:string;\nbegin\nreadln(n);\nans:=0;\nread(S);\nS:=S+'0';\nfor i:=1 to n+1 do\nif S[i]='0' then begin\n write(k);\n k:=0;\n end\n else inc(k);\n end.\n \n \n"}, {"source_code": "var\na:array[1..100] of integer;\nc:char;\nn,l,i:integer;\n\nbegin\nreadln(n);l:=1;\n\nfor i:=1 to n do begin\n read(c);\nif (ord(c)=49) then a[l]:=a[l]+1;\nif (ord(c)=48) then l:=l+1;\nend;\n\nfor i:=1 to l do write(a[i]);\nend."}, {"source_code": "var\nn,y,u,o:longint;\nf:string;\nbegin\nreadln(n);\nreadln(f);\nu:=0; inc(n);\ny:=1; o:=1; f:=f+'0';\nwhile o<=n do\nbegin while (o'0') do\n begin\n k:=k+1;\n i:=i+1;\n if i>n then break;\n end;\n str(k,t);\n s2:=s2+t;\n k:=0;\n if i>=n then break;\n if s[i+1]='0' then \n begin\n s2:=s2+'0';\n i:=i+2;\n end else\n i:=i+1;\n end;\n if (s[n]='0') then s2:=s2+'0';\n writeln(s2);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t \t for j:=1 to count0 - 1 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 0 then \n\t\tfor i:=1 to count0 do write(0);\nend."}, {"source_code": "var s,s1:ansistring; i,x,len:longint;\nbegin\nreadln(len);\nreadln(s); s:=s+'0';\nfor i:=1 to len+1 do\n if s[i]='0' then\n begin\n str(x,s1);\n write(s1);\n x:=0;\n end\n else x:=x+1;\nend."}, {"source_code": "var n,i,k:longint;\n s,tg,ans:ansistring;\nbegin\n readln(n);\n readln(s);\n s:=s+'0';\n for i:=1 to n+1 do\n if s[i]='1' then inc(k) else\n begin\n str(k,tg);\n ans:=ans+tg;\n k:=0;\n end;\n writeln(ans);\nend.\n"}], "negative_code": [{"source_code": "program twoface;\nvar n, i, ss, num, zerg,k,r:integer;\na:array[1..89]of integer;\ns:string;\nbegin\nread(n);\nread(ss);\nstr(ss, s);\nk:=1;\nfor i:=1 to n do\nbegin\nif s[i] = '1' \n then \n begin\n num:=num+1;\n for r:= 1 to zerg-1 do\n begin\n a[k]:=0;\n k:=k+1;\n end;\n zerg:=0;\n end\n else\n begin \n if num>0 then \n begin\n a[k]:=num;\n k:=k+1;\n num:=0;\n end;\n\n zerg:=zerg+1;\n end;\nend;\nif num>0 then a[k]:= num; \nif s[n]= '0' then a[k]:=0;\nfor i:=1 to k do\nwrite(a[i]);\nfor i:= 1 to -1 do\nwrite('asdawdasd');\nend.\n"}, {"source_code": "program dvoich;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n i, n: integer;\n s, ans: string;\n\nbegin\n readln(n);\n readln(s);\n i := 0;\n while (length(s) > 0) do\n begin\n if (s[1] = '1') or (length(s) = 1) then inc(i)\n else\n begin\n ans := ans + inttostr(i);\n i := 0;\n end;\n delete(s, 1, 1);\n end;\n writeln(ans + inttostr(i));\n readln;\n readln;\nend.\n"}, {"source_code": "\n const nn=1600000; nnn=200000;eps=0.0000000001;\n label 1,2;\n type real=extended; {string=ansistring;}\n mas=array [0..nn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3 :int64;end; zap1=^zap;\n mass=array[0..nn] of int64;mass1=^mass;\n var qq,p3,start,modul,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;\n tt,ii,jj,step, i,j:longint;\n time:real;\n newpole,pole:array[-10..200,-10..200] of char;\n ssot,sssnew:array[-10..3000000] of char;\n smas:array[-10..2000000]of string;\n skobk,zz,z,sum,c,d,x,y,a,b:array[-1000002..6000000] of int64;\n per,dda,ddb:array[-10..120,-10..120] of int64;\n ss3,ss1,ss2:string;\n ss:string;ch:char;\n maxpr:array[0..nn] of string;\n st2:array[0..nnn] of string;\n v0,v1,s0,t0:real;\n zv:point;\n xx,yy:array[-1..nn] of double;\n yot:double;\n prost:array [-1000..6000000] of boolean;\n flag,flag1:boolean;\n function al(x,y:real):real; var t0,t1,p,s0,s1:real;\n begin\n if (x>0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p/pi*180;\n end;\n function min(x,y:int64):int64;begin min:=x;if yx then max:=y; end;\n\n function nod(x,y:int64):int64; var z:int64;\nbegin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;\n\n function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;\n tt:zap; tt1:zap1;\nbegin\n if a0 do\n begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;\n a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;\n\n\n end;\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;\n evkl:=tt1;\nend;\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k div 2); degg:=p*p mod modul; end;\n\nend;\n\n\n\n\n\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n);\n read(ss);\n n:=length(ss);\n for i:=1 to n do if ss[i]='0' then begin inc(q);a[q]:=i; end;\n inc(q);a[q]:=n+1;\n for i:=1 to q do write(a[i]-a[i-1]-1,' ');\n\n\n 1: close(output);\nend.\n\n\n"}, {"source_code": "var\n n : integer;\n s : string;\n i,j : integer;\nBEGIN\n //assign(input,'input.inp');reset(input);\n //assign(output,'output.out');rewrite(output);\n readln(n);\n read(s);\n i:= 1;\n while (i <= n) do\n begin\n if s[i] = '1' then\n begin\n j:= i+1;\n while (j <= n) and (s[j] = '1') do\n inc(j);\n write(j - i);\n i:= j + 1;\n end\n else\n begin\n write(0);\n i:= i + 1;\n end;\n end;\nEND.\n\n"}, {"source_code": "var s:string;\n i,k,n:longint;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do begin\n if(s[i]='1') then\n inc(k)\n else begin\n write(k);\n k:=0;\n end;\n end;\n if(s[n]='1') then\n write(k);\nend."}, {"source_code": "var\n s:char;\n cnt,i,n:longint;\nbegin\nreadln(n);\nwhile i<=n do\n begin\n cnt:=0;\n inc(i);\n read(s);\n while (s<>'0') and (i<=n) do\n begin\n inc(cnt);\n inc(i);\n if i<>n then read(s);\n end;\n write(cnt);\n end;\nend."}, {"source_code": "var s:string;\n x,y,n,i,code,j:longint;\n a:array[1..100] of longint;\n k:string;\nbegin\nreadln(n);\nreadln(s);\ni:=1;y:=0;j:=1;\nwhile i<=n do\n begin\n val(s[i],x,code);\n a[j]:=a[j]+x;\n IF (s[i]='0') or (s[i+1]='0') then inc(j);\n IF s[i+1]='0' then inc(i,2) else inc(i);\n end;\nfor i:=1 to j do write(a[i]);\nend.\n"}, {"source_code": "Var n,ans,k,i,f:longint;\nS:string;\nbegin\nreadln(n);\nans:=0;\nread(S);\ni:=1;\nwhile i<=n do begin\nk:=0;\nwhile (i'0') do begin\n inc(i);\n inc(k);\n end;\nans:=ans*10+k;\nk:=0;\ninc(i);\nend; \n write(ans); \n end.\n \n \n"}, {"source_code": "Var n,ans,k,i:longint;\nS:string;\nbegin\nreadln(n);\nans:=0;\nread(S);\ni:=1;\nwhile i<=n do begin\nk:=0;\nwhile (i'0') do begin\n inc(i);\n inc(k);\n end;\nwrite(k);\nk:=0;\ninc(i);\nend; \n \n end.\n \n \n"}, {"source_code": "var\nn,y,u,o:longint;\nf:string;\nbegin\nreadln(n);\nreadln(f);\nu:=0; inc(n);\ny:=1; o:=1; f:=f+'0';\nwhile on) then\n s2:=s2+'0' else\n if (s[i]='0') then\n begin\n k1:=k;\n str(k1,t);\n s2:=s2+t;\n k:=0;\n end;\n\n end;\n if k<>0 then\n begin\n k2:=k;\n str(k2,r);\n s2:=s2+r;\n end;\n writeln(s2);\n end;\nend."}, {"source_code": "var n,i,k:integer;\ns,s2,t:string;\nbegin\n readln(n);\n readln (s);\n i:=1;\n while i<=n do \n begin\n while (s[i]<>'0') do\n begin\n k:=k+1;\n i:=i+1;\n if i>n then break;\n end;\n str(k,t);\n s2:=s2+t;\n k:=0;\n if i>n then break;\n if s[i+1]='0' then \n begin\n s2:=s2+'0';\n i:=i+2;\n end else\n i:=i+1;\n end;\n if (s[n]='0') and (s[n-1]='0') then s2:=s2+'0';\n writeln(s2);\nend."}, {"source_code": "var n,i,k:integer;\ns,s2,t:string;\nbegin\n readln(n);\n readln (s);\n i:=1;\n if s='10' then s2:='10'\n else\n begin\n while i<=n do \n begin\n while (s[i]<>'0') do\n begin\n k:=k+1;\n i:=i+1;\n if i>n then break;\n end;\n str(k,t);\n s2:=s2+t;\n k:=0;\n if i>n then break;\n if s[i+1]='0' then \n begin\n s2:=s2+'0';\n i:=i+2;\n end else\n i:=i+1;\n end;\n if (s[n]='0') and (s[n-1]='0') then s2:=s2+'0';\n end;\n writeln(s2);\nend."}, {"source_code": "var s:string[89];\n\tn,i,c:longint;\n\tch:longint;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tch:=0;\n\ti:=1;\n\ts[n+1]:='0';\n\twhile i<=n do\n\tbegin\n\t\tc:=0;\n\t\twhile s[i]<>'0' do\n\t\tbegin\n\t\t\tinc(c);\n\t\t\tinc(i);\n\t\tend;\n\t\tch:=(ch*10)+c;\n\t\tinc(i);\n\tend;\n\twriteln(ch);\nEND.\n\n"}, {"source_code": "var s:string[89];\n\tn,i,c:byte;\n\tch:longint;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tch:=0;\n\ti:=1;\n\ts[n+1]:='0';\n\twhile i<=n do\n\tbegin\n\t\tc:=0;\n\t\twhile s[i]<>'0' do\n\t\tbegin\n\t\t\tinc(c);\n\t\t\tinc(i);\n\t\tend;\n\t\tch:=(ch*10)+c;\n\t\tinc(i);\n\tend;\n\twriteln(ch);\nEND.\n\n"}, {"source_code": "var s:string[90];\n\tn,i,c:longint;\n\tch:longint;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tch:=0;\n\ti:=1;\n\ts[n+1]:='0';\n\twhile i<=n do\n\tbegin\n\t\tc:=0;\n\t\twhile s[i]<>'0' do\n\t\tbegin\n\t\t\tinc(c);\n\t\t\tinc(i);\n\t\tend;\n\t\tch:=(ch*10)+c;\n\t\tinc(i);\n\tend;\n\tif s[n]='0' then ch:=(ch*10)+c;\n\twriteln(ch);\nEND.\n\n"}, {"source_code": "var s:string[90];\n\tn,i,c:byte;\n\tch:longint;\nBEGIN\n\treadln(n);\n\treadln(s);\n\tch:=0;\n\ti:=1;\n\ts[n+1]:='0';\n\twhile i<=n do\n\tbegin\n\t\tc:=0;\n\t\twhile s[i]<>'0' do\n\t\tbegin\n\t\t\tinc(c);\n\t\t\tinc(i);\n\t\tend;\n\t\tch:=(ch*10)+c;\n\t\tinc(i);\n\tend;\n\twriteln(ch);\nEND.\n\n"}, {"source_code": "var n:longint;\n x,i:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n s:=s+'0';\n for i:=1 to n do\n if s[i]='0' then\n begin\n write(x);\n x:=0;\n end else inc(x);\nend."}, {"source_code": "var n,i,j:byte;\n res:longint;\n s:string;\n\n begin\n readln(n);\n read(s);\n res:=0;\n i:=1;\n writeln;\n while i<=n do\nbegin\nres:=0;\n while (s[i]<>'0') and (i<=n) do\n begin\n res:=res+1;\n inc(i);\n end;\n if res<>0 then write(res);\n if s[i]='0' then inc(i);\n while s[i]='0' do begin\n write(0);\n inc(i);\n end;\n end;\nreadln;\nend."}, {"source_code": "var n,i,j:byte;\n res:longint;\n s:string;\n\n begin\n readln(n);\n read(s);\n res:=0;\n i:=1;\n writeln;\n while i<=n do\nbegin\nres:=0;\n while (s[i]<>'0') and (i<=n) do\n begin\n res:=res+1;\n inc(i);\n end;\n write(res);\n if s[i]='0' then inc(i);\n while s[i]='0' do begin\n write(0);\n inc(i);\n end;\n end;\nreadln;\nend."}, {"source_code": "var n,i,j:byte;\n res:longint;\n s:string;\n\n begin\n readln(n);\n read(s);\n res:=0;\n i:=1;\n writeln;\n while i<=n do\nbegin\nres:=0;\n while (s[i]<>'0') and (i<=n) do\n begin\n res:=res+1;\n inc(i);\n end;\n if s[i]='0' then inc(i);\n while s[i]='0' do begin\n write(0);\n inc(i);\n end;\n write(res);\n end;\nreadln;\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t\t\tfor j:=1 to count0 div 2 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 do write(0);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t\t\tfor j:=1 to count0 div 2 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 - 1 do write(0);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t if count0 mod 2 = 0 then\n\t\t\t\t\t \t\tfor j:=1 to count0 div 2 do write(0)\n\t\t\t\t\t \telse\n\t\t\t\t\t \t for j:=1 to count0 div 2 + 1 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 do write(0);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t\t\tfor j:=1 to count0 div 2 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 div 2 do write(0);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t \t for j:=1 to count0 - 1 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 do write(0);\nend."}, {"source_code": "var \n\tn, count1, count0, i, j, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then \n\t\t\t\tbegin\n\t\t\t\t\tcount1:=count1 + 1;\n\t\t\t\t\tif count0 > 1 then\n\t\t\t\t\t\t\tfor j:=1 to count0 - 1 do write(0);\n\t\t\t\t\tcount0:=0;\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tbegin\n\t\t\t\t\tif count1 <> 0 then \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count1);\n\t\t\t\t\t\t\tcount1:=0;\n\t\t\t\t\t\tend;\n\t\t\t\t\tcount0:=count0 + 1;\n\t\t\t\tend;\n\t\tend;\n\tif count1 <> 0 then write(count1);\n\tif count0 > 1 then \n\t\tfor i:=1 to count0 - 1 do write(0);\nend."}, {"source_code": "var \n\tn, count, i, tmp: byte;\n\tch: char;\nbegin\n\treadln(n);\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tread(ch);\n\t\t\tval(ch,tmp);\n\t\t\tif tmp = 1 then count:=count + 1\n\t\t\telse \n\t\t\t\tif count = 0 then write(0) \n\t\t\t\t\telse \n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\twrite(count);\n\t\t\t\t\t\t\tcount:=0;\n\t\t\t\t\t\tend;\n\t\tend;\n\tif count <> 0 then write(count);\nend."}, {"source_code": "var\tn,i,dem:longint;\n\tans:int64;\n\ts:ansistring;\nbegin\n\treadln(n);\n\treadln(S);\n\t\n\tans:=0;\n\ti:=1;\n\twhile i<=n do\n\tbegin\n\t\tdem:=0;\n\t\twhile (i<=n) and (s[i]='1') do\n\t\tbegin\n\t\t\tinc(Dem);\n\t\t\tinc(i);\n\t\tend;\n\t\tans:=ans*10+dem;\n\t\tinc(i);\n\tend;\n\twriteln(ans);\nend."}, {"source_code": "var\tn,i,dem:longint;\n\tans:int64;\n\ts:ansistring;\nbegin\n\treadln(n);\n\treadln(S);\n\t\n\tans:=0;\n\ti:=1;\n\twhile i<=n do\n\tbegin\n\t\tdem:=0;\n\t\twhile (i<=n) and (s[i]<>'0') do\n\t\tbegin\n\t\t\tinc(Dem);\n\t\t\tinc(i);\n\t\tend;\n\t\tans:=ans*10+dem;\n\t\tinc(i);\n\tend;\n\twriteln(ans);\nend."}], "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa"} {"source_code": " {$M 100000000}\n{$Q-,R-,S-,I-}\nuses math;\nconst fi='';//input.inp';\n fo='';//output.out';\n mh:array[1..16] of integer=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar n:longint;\n a,d,sl:array[0..101] of longint;\n sc:array[0..100000] of longint;\n con:array[0..100000,0..100] of longint;\n luu,f,aa,bb:array[0..100,0..100000] of longint;\n e:array[0..100,0..100] of longint;\n\nprocedure docfile;\n var i:longint;\n begin\n assign(input,fi);\n reset(input);\n readln(n);\n for i:=1 to n do\n read(a[i]);\n assign(output,fo);\n rewrite(output);\n end;\nprocedure dongfile;\n begin\n close(input); close(output);\n end;\nprocedure taomang;\n var i,j,k:longint; ok:boolean;\n begin\n for i:=0 to (1 shl 16)-1 do\n begin\n for j:=1 to 58 do\n begin\n ok:=true;\n for k:=1 to 16 do\n if (i or (1 shl (k-1)) = i) then\n if j mod mh[k] = 0 then\n begin\n ok:=false; break;\n end;\n if ok then\n begin\n inc(sc[i]); con[i,sc[i]]:=j;\n end;\n end;\n end;\n for i:=2 to 58 do\n begin\n for j:=1 to 16 do\n if i mod mh[j] = 0 then\n begin\n inc(d[i]); e[i,d[i]]:=j;\n end;\n end;\n end;\nprocedure ghikq(m,t:longint);\n begin\n if m=0 then exit;\n ghikq(m-1,bb[m,t]);\n if mf[i-1,u]+abs(t-a[i]) then\n begin\n f[i,v]:=f[i-1,u]+abs(t-a[i]);\n aa[i,v]:=t; bb[i,v]:=u;\n end;\n end;\n end;\n end;\n res:=maxlongint; vt:=0;\n for i:=0 to 1 shl 16 do\n if res>f[n,i] then\n begin\n res:=f[n,i]; vt:=i;\n end;\n ghikq(n,vt);\n end;\nBEGIN\n docfile;\n taomang;\n xuli;\n dongfile;\nEND.\n", "positive_code": [{"source_code": "Const CEILING = 60;\nVar A, Perm, Answer, B, C: array[1..101] of longint;\n n, i, num: longint;\n minSum: longint;\n\n\nProcedure Sort(n: longint);\nvar i, j, tmp: longint;\nbegin\n For i:= 1 to n-1 do\n For j:= 1 to n-i do\n if A[j] > A[j+1] then\n begin\n tmp:= A[j];\n A[j]:= A[j+1];\n A[j+1]:= tmp;\n\n tmp:= Perm[j];\n Perm[j]:= Perm[j+1];\n Perm[j+1]:= tmp;\n end;\nend;\n\n\nFunction GCD(a, b: longint): longint;\nbegin\n while (a<>0) and (b<>0) do\n if a>b then\n a:= a mod b\n else\n b:= b mod a;\n\n GCD:= a or b;\nend;\n\n\nProcedure CheckComb(len: longint);\nvar i, sum: longint;\nbegin\n if len=0 then\n exit;\n sum:= 0;\n For i:= n downto n-len+1 do\n sum:= sum + abs(A[i]-C[len-(n-i)]);\n For i:= n-len downto 1 do\n sum:= sum + abs(A[i]-1);\n\n if sum < minSum then\n begin\n minSum:= sum;\n For i:= 1 to n-len do\n Answer[i]:= 1;\n For i:= n-len+1 to n do\n Answer[i]:= C[i-(n-len+1)+1];\n end;\nend;\n\n\nProcedure Go(pos, len: longint);\nvar i, j: longint;\n good: boolean;\nbegin\n if (pos=CEILING+1) or (len=num) then\n exit;\n\n For i:= pos to CEILING do\n begin\n good:= true;\n For j:= 1 to len do\n if GCD(i, C[j]) <> 1 then\n begin\n good:= false;\n break;\n end;\n\n if good then\n begin\n C[len+1]:= i;\n CheckComb(len+1);\n Go(i+1, len+1);\n C[len+1]:= 0;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n\n num:= 0;\n For i:= 1 to n do\n begin\n read(A[i]);\n Perm[i]:= i;\n if A[i] <> 1 then\n inc(num);\n end;\n if num>20 then\n num:= 20;\n\n Sort(n);\n\n minSum:= MAXLONGINT;\n Go(2, 0);\n\n if num = 0 then\n For i:= 1 to n do\n Answer[i]:= 1;\n\n For i:= 1 to n do\n B[ Perm[i] ]:= Answer[i];\n\n For i:= 1 to n do\n write(B[i], ' ');\nend."}, {"source_code": "const\n ct:array[1..16]of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar\n a,g:array[0..100,0..65535]of longint;\n tt:array[1..58]of longint;\n p:array[0..65535,1..58]of longint;\n q:array[0..65535]of longint;\n b,wt:array[1..100]of longint;\n tp:array[1..16]of longint;\n n,i,j,k,an1,an2:longint;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=0 to 65535 do a[i,j]:=3000;\n for i:=1 to n do read(b[i]);\n for i:=1 to 58 do\n for j:=1 to 16 do begin\n tt[i]:=tt[i] shl 1;\n if i mod ct[j]=0 then inc(tt[i]);\n end;\n for i:=0 to 65535 do\n for j:=1 to 58 do\n if tt[j] and i=0 then begin\n inc(q[i]);p[i,q[i]]:=j;\n end;\n for i:=1 to n do\n for j:=0 to 65535 do\n for k:=1 to q[j] do\n if a[i-1,j]+abs(p[j,k]-b[i]) 0) then continue;\n tmp := f(i-1, s or bit[j]) + abs(j-a[i]);\n if (tmp < memo[i, s]) then\n begin\n memo[i, s] := tmp;\n trace2[i, s] := s or bit[j];\n used[i, s] := j;\n end;\n end;\n exit(memo[i, s]);\n end;\nprocedure trace(const i, s: longword);\n begin\n if (i = 0) then exit;\n res[i] := used[i, s];\n trace(i-1, trace2[i, s]);\n end;\nprocedure sol;\n var\n i, j, best: longword;\n begin\n for i := 2 to 60 do\n for j := 1 to 17 do\n if ((i mod p[j]) = 0) then bit[i] := bit[i] or (1 shl (j-1));\n f(n, 0);\n trace(n, 0);\n for i := 1 to n do write(res[i], ' ');\n end;\nbegin\n inp;\n sol;\nend.\n "}, {"source_code": "program dd;\nconst\n nm = 100;\n pm = 17;\n bm = 1 shl 17;\n p: array[1..17] of word = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);\n oo = trunc(1e9);\nvar\n a, res: array[1..nm] of longint;\n bit: array[1..60] of longword;\n memo, trace2, used: array[1..nm, 0..bm] of longword;\n calc: array[1..nm, 0..bm] of boolean;\n n: longword;\nprocedure inp;\n var\n i: longword;\n begin\n readln(n);\n for i := 1 to n do read(a[i]);\n end;\nfunction f(const i, s: longword): longword;\n var\n j: longint;\n tmp: longword;\n begin\n if (i = 0) then exit(0);\n if (calc[i, s]) then exit(memo[i, s]);\n calc[i, s] := true; memo[i, s] := oo;\n for j := 1 to (a[i] + abs(a[i]-1)) do\n begin\n if ((s and bit[j]) <> 0) then continue;\n tmp := f(i-1, s or bit[j]) + abs(j-a[i]);\n if (tmp < memo[i, s]) then\n begin\n memo[i, s] := tmp;\n trace2[i, s] := s or bit[j];\n used[i, s] := j;\n end;\n end;\n exit(memo[i, s]);\n end;\nprocedure trace(const i, s: longword);\n begin\n if (i = 0) then exit;\n res[i] := used[i, s];\n trace(i-1, trace2[i, s]);\n end;\nprocedure sol;\n var\n i, j, best: longword;\n begin\n for i := 2 to 60 do\n for j := 1 to 17 do\n if ((i mod p[j]) = 0) then bit[i] := bit[i] or (1 shl (j-1));\n f(n, 0);\n trace(n, 0);\n for i := 1 to n do write(res[i], ' ');\n end;\nbegin\n inp;\n sol;\nend.\n "}, {"source_code": "var n,i,j,pn,s:longint;\nfct,a:array[0..101] of longint;\nrd,b:array[0..101,0..131072] of longint;\nfunction sc(x,s:longint):longint;\nvar i:longint;\nbegin\nif x>n then exit(0);\nif rd[x,s]<>-1 then exit(rd[x,s]);\nrd[x,s]:=maxlongint;\nfor i:=1 to 2*a[x]-1 do\n begin\n if(fct[i] and s)>0then continue;\n if abs(a[x]-i)+sc(x+1,fct[i] or s)n then begin d[t,w]:=0;exit; end;\nif d[t,w]<>-1 then exit;\nd[t,w]:=maxlongint div 2;\nfor i:=1 to 59 do\n if e[i] and w=0 then\n begin\n sc(t+1,w or e[i]);\n if abs(i-a[t])+d[t+1,w or e[i]] 0) then continue;\n tmp := f(i-1, s or bit[j]) + abs(j-a[i]);\n if (tmp < memo[i, s]) then\n begin\n memo[i, s] := tmp;\n trace2[i, s] := s or bit[j];\n used[i, s] := j;\n end;\n end;\n exit(memo[i, s]);\n end;\nprocedure trace(const i, s: longword);\n begin\n if (i = 0) then exit;\n res[i] := used[i, s];\n trace(i-1, trace2[i, s]);\n end;\nprocedure sol;\n var\n i, j, best: longword;\n begin\n for i := 2 to 60 do\n for j := 1 to 17 do\n if ((i mod p[j]) = 0) then bit[i] := bit[i] or (1 shl (j-1));\n f(n, 0);\n trace(n, 0);\n for i := 1 to n do write(res[i], ' ');\n end;\nbegin\n inp;\n sol;\nend.\n "}, {"source_code": "program dd;\nconst\n nm = 100;\n pm = 17;\n bm = 1 shl 17;\n p: array[1..17] of word = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);\n oo = trunc(1e9);\nvar\n a, res: array[1..nm] of longint;\n bit: array[1..60] of longword;\n memo, trace2, used: array[1..nm, 0..bm] of longword;\n calc: array[1..nm, 0..bm] of boolean;\n n: longword;\nprocedure inp;\n var\n i: longword;\n begin\n readln(n);\n for i := 1 to n do read(a[i]);\n end;\nfunction f(const i, s: longword): longword;\n var\n j: longint;\n tmp: longword;\n begin\n if (i = 0) then exit(0);\n if (calc[i, s]) then exit(memo[i, s]);\n calc[i, s] := true; memo[i, s] := oo;\n for j := 1 to (a[i] + abs(a[i]-1)) do\n begin\n if ((s and bit[j]) <> 0) then continue;\n tmp := f(i-1, s or bit[j]) + abs(j-a[i]);\n if (tmp < memo[i, s]) then\n begin\n memo[i, s] := tmp;\n trace2[i, s] := s or bit[j];\n used[i, s] := j;\n end;\n end;\n exit(memo[i, s]);\n end;\nprocedure trace(const i, s: longword);\n begin\n if (i = 0) then exit;\n res[i] := used[i, s];\n trace(i-1, trace2[i, s]);\n end;\nprocedure sol;\n var\n i, j, best: longword;\n begin\n for i := 2 to 60 do\n for j := 1 to 17 do\n if ((i mod p[j]) = 0) then bit[i] := bit[i] or (1 shl (j-1));\n f(n, 0);\n trace(n, 0);\n for i := 1 to n do write(res[i], ' ');\n end;\nbegin\n //assign(input, 'input.txt'); reset(input);\n inp;\n sol;\nend."}, {"source_code": "program dd;\nconst\n nm = 100;\n pm = 17;\n bm = 1 shl 17;\n p: array[1..17] of word = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);\n oo = trunc(1e9);\nvar\n a, res: array[1..nm] of longint;\n bit: array[1..60] of longword;\n memo, trace2, used: array[1..nm, 0..bm] of longword;\n calc: array[1..nm, 0..bm] of boolean;\n n: longword;\nprocedure inp;\n var\n i: longword;\n begin\n readln(n);\n for i := 1 to n do read(a[i]);\n end;\nfunction f(const i, s: longword): longword;\n var\n j: longint;\n tmp: longword;\n begin\n if (i = 0) then exit(0);\n if (calc[i, s]) then exit(memo[i, s]);\n calc[i, s] := true; memo[i, s] := oo;\n for j := 1 to (a[i] + abs(a[i]-1)) do\n begin\n if ((s and bit[j]) <> 0) then continue;\n tmp := f(i-1, s or bit[j]) + abs(j-a[i]);\n if (tmp < memo[i, s]) then\n begin\n memo[i, s] := tmp;\n trace2[i, s] := s or bit[j];\n used[i, s] := j;\n end;\n end;\n exit(memo[i, s]);\n end;\nprocedure trace(const i, s: longword);\n begin\n if (i = 0) then exit;\n res[i] := used[i, s];\n trace(i-1, trace2[i, s]);\n end;\nprocedure sol;\n var\n i, j, best: longword;\n begin\n for i := 2 to 60 do\n for j := 1 to 17 do\n if ((i mod p[j]) = 0) then bit[i] := bit[i] or (1 shl (j-1));\n f(n, 0);\n trace(n, 0);\n for i := 1 to n do write(res[i], ' ');\n end;\nbegin\n inp;\n sol;\nend.\n "}, {"source_code": "program sss;\nvar f,g,h:array[0..100,0..70000]of longint;\n a:array[1..100]of longint;\n q:array[1..16]of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\n v:array[1..60]of longint;\n ans:array[1..100]of longint;\n i,j,k,m,n,l,e:longint;\n\nprocedure gx(x,y:longint);\nvar i,j,k,l:longint;\n u:boolean;\nbegin\n j:=y;\n\n if f[x+1,y]>f[x,y]+a[x+1]-1 then\n begin\n f[x+1,y]:=f[x,y]+a[x+1]-1;\n g[x+1,y]:=1;\n h[x+1,y]:=y;\n end;\n\n\n for i:=2 to 60 do\n begin\n if v[i] or yf[x,y]+abs(a[x+1]-i) then\n begin\n f[x+1,k]:=f[x,y]+abs(a[x+1]-i);\n g[x+1,k]:=i;\n h[x+1,k]:=y;\n end;\n\n end;\n\n\n\n\n\n\n\nend;\n\n\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n fillchar(f,sizeof(f),55);\n f[0,0]:=0;\n\n\n\n fillchar(v,sizeof(v),0);\n for i:=2 to 60 do\n begin\n k:=0;\n l:=1;\n for j:=1 to 16 do\n begin\n if i mod q[j]=0 then k:=k+l;\n l:=l*2;\n end;\n v[i]:=k;\n\n end;\n\n k:=1;\n for i:=1 to 16 do k:=k*2;\n k:=k-1;\n\n for i:=0 to n-1 do\n for j:=0 to k do\n if f[i,j]<=3000 then gx(i,j);\n\n j:=3000;\n for i:=0 to k do\n if f[n,i]0) then begin inc(v); a[i]:=a[i]+1 shl (por[j]-1); end;\n if v=0 then begin inc(gg); por[i]:=gg; a[i]:=1 shl (gg-1); end;\n end;\n for i:=1 to n do\n for j:=0 to 139000 do f[i,j]:=n*30;\n min:=n*30;\n for i:=1 to n do\n for j:=1 to 59 do\n begin\n x:=a[j] xor ((1 shl 17)-1);\n k:=x;\n while true do\n begin\n if f[i-1][k]+abs(b[i]-j) dp[i][mask] + abs(a[i + 1] - x) then\n begin\n dp[i + 1][submask[x] or mask] := dp[i][mask] + abs(a[i + 1] - x);\n pred[i + 1][submask[x] or mask] := x;\n end;\n\n ans := inf; now := 0;\n for mask := 0 to 1 shl cnt - 1 do\n if ans > dp[n][mask] then\n begin\n ans := dp[n][mask];\n now := mask;\n end;\n\n for i := n downto 1 do\n begin\n res[i] := pred[i][now];\n now := now xor submask[res[i]];\n end;\n\n for i := 1 to n do write(res[i],' ');\nend."}, {"source_code": "program B259;\n\nconst\n\tInp = '';\n\tOup = '';\n\tMaxstt = 131072;\n\tMaxn = 100;\n\tPrimeA : array [1..17] of integer = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);\n\ntype\n\tTnode=record\n\t\t X,Y:longint;\n\t\t Val:longint;\n\tend;\n\nvar\n\tDp: array [0..MaxN,0..MaxStt] of longint;\n\tTrace: array[0..Maxn,0..MaxStt] of TNode;\n\tStt: array [1..60] of longint;\n\tN: longint;\n\tA,ResA: array [1..maxN] of longint;\n\nprocedure Init();\nvar\n\ti,j: Longint;\nbegin\n\tfor i:=1 to 60 do\n\t\tbegin\n\t\t\tfor j:=1 to 17 do\n\t\t\t\tbegin\n\t\t\t\t\tif (i mod PrimeA[j] = 0) then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tStt[i]:=Stt[i] or (1 shl (j-1));\n\t\t\t\t\t\tend;\n\t\t\t\tend;\n\t\tend;\nend;\n\nprocedure Dpsearch();\nvar\n\ti,j,k,X,Y,Res: longint;\nbegin\n\tfor i:=0 to N do\n\t\tfor j:=0 to (1 shl 17)-1 do\n\t\t\tbegin\n\t\t\t\tDp[i,j]:=1000000000;\n\t\t\tend;\n\tDp[0,0]:=0;\n\tfor i:=1 to N do\n\t\tbegin\n\t\t\tfor j:=0 to (1 shl 17)-1 do\n\t\t\t\tbegin\n\t\t\t\t\tfor k:=1 to 60 do\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tif ((j and Stt[k])=Stt[k]) then\n\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\tif Dp[i,j]>Dp[i-1,j-Stt[k]]+abs(A[i]-k) then\n\t\t\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\t\t\tDp[i,j]:=Dp[i-1,j-Stt[k]]+abs(A[i]-k);\n\t\t\t\t\t\t\t\t\t\t\tTrace[i,j].X:=i-1;\n\t\t\t\t\t\t\t\t\t\t\tTrace[i,j].Y:=j-Stt[k];\n\t\t\t\t\t\t\t\t\t\t\tTrace[i,j].Val:=k;\n\t\t\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\t\t\tend;\n\t\t\t\t\t\tend;\n\t\t\t\tend;\n\t\tend;\n\tRes:=100000000;\n\tfor j:=0 to (1 shl 17)-1 do if Dp[N,j]0 do\n\t\tbegin\n\t\t\tResA[X]:=Trace[X,Y].Val;\n\t\t\ti:=X;\n\t\t\tj:=Y;\n\t\t\tX:=Trace[i,j].X;\n\t\t\tY:=Trace[i,j].Y;\n\t\tend;\nend;\n\nprocedure Main();\nvar\n\ti: longint;\nbegin\n\tassign(input,inp); reset(input);\n\tassign(output,oup); rewrite(output);\n\treadln(N);\n\tfor i:=1 to N do read(A[i]);\n\tInit();\n\tDpsearch();\n\tfor i:=1 to N do write(ResA[i],' ');\nend;\n\nbegin\n\tMain();\nend.\n"}, {"source_code": "{$M 100000000}\n{$Q-,R-,S-,I-}\nuses math;\nconst fi='';//input.inp';\n fo='';//output.out';\n mh:array[1..16] of integer=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar n:longint;\n a,d,sl:array[0..101] of longint;\n sc:array[0..100000] of longint;\n con:array[0..100000,0..100] of longint;\n luu,f,aa,bb:array[0..100,0..100000] of longint;\n e:array[0..100,0..100] of longint;\n\nprocedure docfile;\n var i:longint;\n begin\n assign(input,fi);\n reset(input);\n readln(n);\n for i:=1 to n do\n read(a[i]);\n assign(output,fo);\n rewrite(output);\n end;\nprocedure dongfile;\n begin\n close(input); close(output);\n end;\nprocedure taomang;\n var i,j,k:longint; ok:boolean;\n begin\n for i:=0 to (1 shl 16)-1 do\n begin\n for j:=1 to 58 do\n begin\n ok:=true;\n for k:=1 to 16 do\n if (i or (1 shl (k-1)) = i) then\n if j mod mh[k] = 0 then\n begin\n ok:=false; break;\n end;\n if ok then\n begin\n inc(sc[i]); con[i,sc[i]]:=j;\n end;\n end;\n end;\n for i:=2 to 58 do\n begin\n for j:=1 to 16 do\n if i mod mh[j] = 0 then\n begin\n inc(d[i]); e[i,d[i]]:=j;\n end;\n end;\n end;\nprocedure ghikq(m,t:longint);\n begin\n if m=0 then exit;\n ghikq(m-1,bb[m,t]);\n if mf[i-1,u]+abs(t-a[i]) then\n begin\n f[i,v]:=f[i-1,u]+abs(t-a[i]);\n aa[i,v]:=t; bb[i,v]:=u;\n end;\n end;\n end;\n end;\n res:=maxlongint; vt:=0;\n for i:=0 to 1 shl 16 do\n if res>f[n,i] then\n begin\n res:=f[n,i]; vt:=i;\n end;\n ghikq(n,vt);\n end;\nBEGIN\n docfile;\n taomang;\n xuli;\n dongfile;\nEND.\n"}, {"source_code": "const\n prime:array[0..15] of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\n inf=1000000000;\nvar\n n,i,j,k,m,ans:longint;\n dp,pre:array[0..101,0..65537] of longint;\n a,b,f:array[0..101] of longint;\n\nbegin {main}\n readln(n);\n for i:=1 to n do read(a[i]);\n m:=1 shl 16-1;\n for i:=1 to m do dp[0][i]:=inf;dp[0][0]:=0;\n for i:=1 to 58 do\n begin\n f[i]:=0;\n for j:=0 to 15 do if i mod prime[j]=0 then f[i]:=f[i]+(1 shl j);\n end;\n for i:=1 to n do\n begin\n for j:=0 to m do dp[i][j]:=inf;\n for j:=0 to m do\n if dp[i-1][j]dp[i-1][j]+abs(k-a[i])) then\n begin\n dp[i][j+f[k]]:=dp[i-1][j]+abs(k-a[i]);pre[i][j+f[k]]:=k;\n end;\n end;\n ans:=inf;\n for i:=0 to m do if dp[n][i]f[i-1,j]+abs(k-a[i]) then\n begin\n f[i,j or c[k]]:=f[i-1,j]+abs(k-a[i]);\n s[i,j or c[k]]:=k;\n end;\n end;\n ans:=maxlongint;\n for i:=0 to 65535 do\n if f[n,i]100000000 then continue;\n for k:=1 to 60 do \n begin\n \n if (j and b[k])<>0 then continue;\n if f[i+1,j or b[k]]>abs(a[i+1]-k)+f[i,j] then\n begin\n f[i+1,j or b[k]]:=abs(a[i+1]-k)+f[i,j];\n g[i+1,j or b[k]]:=k;\n end;\n end;end;\n t:=0;\n for i:=1 to p do if f[n,i]dp[i-1,j]+abs(m[i]-z)\n then Begin\n a:=m1[z] or j;\n dp[i,a]:=dp[i-1,j]+abs(m[i]-z);\n dp1[i,a]:=j;\n dp2[i,a]:=z;\n end;\n end;\n end;\n a:=maxlongint;\n b:=0;\n for i:=0 to 1 shl 17-1 do\n if a>dp[n,i]\n then Begin\n a:=dp[n,i];\n b:=i;\n end;\n a:=n;\n while b>0 do\n Begin\n m3[a]:=dp2[a,b];\n b:=dp1[a,b];\n dec(a);\n end;\n while a>0 do\n Begin\n m3[a]:=1;\n dec(a);\n end;\n for i:=1 to n do\n write(m3[i],' ');\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nprogram LittlePonyAndHarmonyChest;\n\ntype\n int16 = smallint;\n uint16 = word;\n int = Integer;\n\nconst\n SUM_BOUND: int = 10000;\n PRIMES: array[0..16] of int = (1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53);\n \nvar\n ResultsValues: array[0..100] of array[0..65536] of int;\n ResultsFrom: array[0..100] of array[0..65536] of Word; \n ResultsNumbers: array[0..100] of array[0..65536] of Byte; \n NumbersMasks: array[1..58] of int;\n \nprocedure Init;\nvar\n i, j: int;\nbegin\n for i := 1 to 58 do\n begin\n NumbersMasks[i] := 0;\n for j := 1 to High(PRIMES) do\n if (i mod PRIMES[J] = 0) then\n NumbersMasks[i] := NumbersMasks[i] or (1 shl (j - 1));\n end; \n for i := 0 to 100 do\n for j := 0 to 65536 do\n ResultsValues[i][j] := SUM_BOUND;\n ResultsValues[0][0] := 0;\nend;\n\nfunction Abs(const x: int): int;\nbegin\n if x < 0 then\n Result := -x\n else\n Result := x;\nend; \n\nprocedure Solve(const n: int; const a: array of word);\nvar\n i, j, k: int;\n tmp: int;\nbegin\n for i := 1 to n do \n begin\n for j := Low(ResultsValues[i]) to High(ResultsValues[i]) do\n begin\n for k := Low(NumbersMasks) to High(NumbersMasks) do\n begin\n tmp := j or NumbersMasks[k];\n if (j and NumbersMasks[k] = 0) and \n (ResultsValues[i][tmp] > ResultsValues[i - 1][j] + Abs(a[i] - k)) then\n begin\n ResultsValues[i][tmp] := ResultsValues[i - 1][j] + Abs(a[i] - k);\n ResultsFrom[i][tmp] := j; \n ResultsNumbers[i][tmp] := k; \n end;\n end;\n end;\n end;\nend;\n\nprocedure Print(const n: int);\nvar\n min: int;\n pos: int;\n i, j: int;\n a: array[1..100] of byte;\nbegin\n min := High(word);\n for i := 0 to 65536 do\n if min > ResultsValues[n][i] then\n begin\n min := ResultsValues[n][i];\n pos := i;\n end;\n \n for i := n downto 1 do\n begin\n a[i] := ResultsNumbers[i][pos];\n pos := ResultsFrom[i][pos];\n end;\n \n for i := 1 to n - 1 do\n Write(a[i], ' ');\n Writeln(a[n]);\nend;\n\nvar\n n, i: int;\n data: array of word;\n \nbegin\n Readln(n);\n SetLength(data, n + 1);\n for i := 1 to n do\n Read(data[i]);\n \n Init();\n Solve(n, data);\n Print(n);\nend."}, {"source_code": "uses Math,SysUtils;\ntype maxx=array[0..100,0..1 shl 17-1] of longint;\n mass=array[0..100] of longint;\nconst m2:array[1..17] of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59);\nvar l,d,k1,a,z1,md,k,b,e,n,ee:int64;\n s:string;\n dp,dp1,dp2:maxx;\n m,m1,m3:mass;\n i,z,j:longint;\nbegin\n// assign(input,'input.txt');\n// assign(output,'output.txt');\n readln(n);\n for i:=1 to n do\n read(m[i]);\n for i:=1 to 59 do\n Begin\n a:=i;\n for z:=1 to 17 do\n if a mod m2[z]=0\n then Begin\n m1[i]:=m1[i] or (1 shl (z-1));\n while (a mod m2[z]=0) do\n a:=a div m2[z];\n end;\n end;\n fillchar(dp,sizeof(dp),3);\n dp[0,0]:=0;\n for i:=1 to n do\n Begin\n for z:=1 to 59 do\n Begin\n for j:=0 to 1 shl 17-1 do\n if m1[z] and j=0\n then if dp[i,m1[z] or j]>dp[i-1,j]+abs(m[i]-z)\n then Begin\n a:=m1[z] or j;\n dp[i,a]:=dp[i-1,j]+abs(m[i]-z);\n dp1[i,a]:=j;\n dp2[i,a]:=z;\n end;\n end;\n end;\n a:=maxlongint;\n b:=0;\n for i:=0 to 1 shl 17-1 do\n if a>dp[n,i]\n then Begin\n a:=dp[n,i];\n b:=i;\n end;\n a:=n;\n while b>0 do\n Begin\n m3[a]:=dp2[a,b];\n b:=dp1[a,b];\n dec(a);\n end;\n while a>0 do\n Begin\n m3[a]:=1;\n dec(a);\n end;\n for i:=1 to n do\n write(m3[i],' ');\nend."}, {"source_code": "Const CEILING = 60;\nVar A, Perm, Answer, B, C: array[1..101] of longint;\n n, i, num: longint;\n minSum: longint;\n\n\nProcedure Sort(n: longint);\nvar i, j, tmp: longint;\nbegin\n For i:= 1 to n-1 do\n For j:= 1 to n-i do\n if A[j] > A[j+1] then\n begin\n tmp:= A[j];\n A[j]:= A[j+1];\n A[j+1]:= tmp;\n\n tmp:= Perm[j];\n Perm[j]:= Perm[j+1];\n Perm[j+1]:= tmp;\n end;\nend;\n\n\nFunction GCD(a, b: longint): longint;\nbegin\n while (a<>0) and (b<>0) do\n if a>b then\n a:= a mod b\n else\n b:= b mod a;\n\n GCD:= a or b;\nend;\n\n\nProcedure CheckComb(len: longint);\nvar i, sum: longint;\nbegin\n if len=0 then\n exit;\n sum:= 0;\n For i:= n downto n-len+1 do\n sum:= sum + abs(A[i]-C[len-(n-i)]);\n// write(sum,'; ');\n For i:= n-len downto 1 do\n sum:= sum + abs(A[i]-1);\n //writeln(sum);\n\n if sum < minSum then\n begin\n minSum:= sum;\n For i:= 1 to n-len do\n Answer[i]:= 1;\n For i:= n-len+1 to n do\n Answer[i]:= C[i-(n-len+1)+1];\n end;\nend;\n\n\nProcedure Go(pos, len: longint);\nvar i, j: longint;\n good: boolean;\nbegin\n// writeln('ZZ: ',pos,' ',len);\n if (pos=CEILING+1) or (len=num) then\n exit;\n\n For i:= pos to CEILING do\n begin\n good:= true;\n For j:= 1 to len do\n if GCD(i, C[j]) <> 1 then\n begin\n good:= false;\n break;\n end;\n\n if good then\n begin\n C[len+1]:= i;\n CheckComb(len+1);\n Go(i+1, len+1);\n C[len+1]:= 0;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n\n num:= 0;\n For i:= 1 to n do\n begin\n read(A[i]);\n Perm[i]:= i;\n if A[i] <> 1 then\n inc(num);\n end;\n if num>20 then\n num:= 20;\n\n Sort(n);\n\n minSum:= MAXLONGINT;\n Go(2, 0);\n\n if num = 0 then\n For i:= 1 to n do\n Answer[i]:= 1;\n\n For i:= 1 to n do\n B[ Perm[i] ]:= Answer[i];\n\n For i:= 1 to n do\n write(B[i], ' ');\nend.\n"}], "negative_code": [{"source_code": "Const CEILING = 45;\nVar A, Perm, Answer, B, C: array[1..101] of longint;\n n, i, num: longint;\n minSum: longint;\n\n\nProcedure Sort(n: longint);\nvar i, j, tmp: longint;\nbegin\n For i:= 1 to n-1 do\n For j:= 1 to n-i do\n if A[j] > A[j+1] then\n begin\n tmp:= A[j];\n A[j]:= A[j+1];\n A[j+1]:= tmp;\n\n tmp:= Perm[j];\n Perm[j]:= Perm[j+1];\n Perm[j+1]:= tmp;\n end;\nend;\n\n\nFunction GCD(a, b: longint): longint;\nbegin\n while (a<>0) and (b<>0) do\n if a>b then\n a:= a mod b\n else\n b:= b mod a;\n\n GCD:= a or b;\nend;\n\n\nProcedure CheckComb(len: longint);\nvar i, sum: longint;\nbegin\n if len=0 then\n exit;\n sum:= 0;\n For i:= n downto n-len+1 do\n sum:= sum + abs(A[i]-C[len-(n-i)]);\n// write(sum,'; ');\n For i:= n-len downto 1 do\n sum:= sum + abs(A[i]-1);\n //writeln(sum);\n\n if sum < minSum then\n begin\n minSum:= sum;\n For i:= 1 to n-len do\n Answer[i]:= 1;\n For i:= n-len+1 to n do\n Answer[i]:= C[i-(n-len+1)+1];\n end;\nend;\n\n\nProcedure Go(pos, len: longint);\nvar i, j: longint;\n good: boolean;\nbegin\n// writeln('ZZ: ',pos,' ',len);\n if (pos=CEILING+1) or (len=num) then\n exit;\n\n For i:= pos to CEILING do\n begin\n good:= true;\n For j:= 1 to len do\n if GCD(i, C[j]) <> 1 then\n begin\n good:= false;\n break;\n end;\n\n if good then\n begin\n C[len+1]:= i;\n CheckComb(len+1);\n Go(i+1, len+1);\n C[len+1]:= 0;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n\n num:= 0;\n For i:= 1 to n do\n begin\n read(A[i]);\n Perm[i]:= i;\n if A[i] <> 1 then\n inc(num);\n end;\n if num>15 then\n num:= 15;\n\n Sort(n);\n\n minSum:= MAXLONGINT;\n Go(2, 0);\n\n if num = 0 then\n For i:= 1 to n do\n Answer[i]:= 1;\n\n For i:= 1 to n do\n B[ Perm[i] ]:= Answer[i];\n\n For i:= 1 to n do\n write(B[i], ' ');\nend.\n"}, {"source_code": "Var A, Perm, Answer, B, C: array[1..101] of longint;\n n, i, num: longint;\n minSum: longint;\n\n\nProcedure Sort(n: longint);\nvar i, j, tmp: longint;\nbegin\n For i:= 1 to n-1 do\n For j:= 1 to n-i do\n if A[j] > A[j+1] then\n begin\n tmp:= A[j];\n A[j]:= A[j+1];\n A[j+1]:= tmp;\n\n tmp:= Perm[j];\n Perm[j]:= Perm[j+1];\n Perm[j+1]:= tmp;\n end;\nend;\n\n\nFunction GCD(a, b: longint): longint;\nbegin\n while (a<>0) and (b<>0) do\n if a>b then\n a:= a mod b\n else\n b:= b mod a;\n\n GCD:= a or b;\nend;\n\n\nProcedure CheckComb(len: longint);\nvar i, sum: longint;\nbegin\n if len=0 then\n exit;\n sum:= 0;\n For i:= n downto n-len+1 do\n sum:= sum + abs(A[i]-C[len-(n-i)]);\n// write(sum,'; ');\n For i:= n-len downto 1 do\n sum:= sum + abs(A[i]-1);\n //writeln(sum);\n\n if sum < minSum then\n begin\n minSum:= sum;\n For i:= 1 to n-len do\n Answer[i]:= 1;\n For i:= n-len+1 to n do\n Answer[i]:= C[i-(n-len+1)+1];\n end;\nend;\n\n\nProcedure Go(pos, len: longint);\nvar i, j: longint;\n good: boolean;\nbegin\n// writeln('ZZ: ',pos,' ',len);\n if (pos=31) or (len=num) then\n exit;\n\n For i:= pos to 30 do\n begin\n good:= true;\n For j:= 1 to len do\n if GCD(i, C[j]) <> 1 then\n begin\n good:= false;\n break;\n end;\n\n if good then\n begin\n C[len+1]:= i;\n CheckComb(len+1);\n Go(i+1, len+1);\n C[len+1]:= 0;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n\n num:= 0;\n For i:= 1 to n do\n begin\n read(A[i]);\n Perm[i]:= i;\n if A[i] <> 1 then\n inc(num);\n end;\n if num>10 then\n num:= 10;\n\n Sort(n);\n\n minSum:= MAXLONGINT;\n Go(2, 0);\n\n if num = 0 then\n For i:= 1 to n do\n Answer[i]:= 1;\n\n For i:= 1 to n do\n B[ Perm[i] ]:= Answer[i];\n\n For i:= 1 to n do\n write(B[i], ' ');\nend.\n"}, {"source_code": "Var A, Perm, Answer, B, C: array[1..101] of longint;\n n, i, num: longint;\n minSum: longint;\n\n\nProcedure Sort(n: longint);\nvar i, j, tmp: longint;\nbegin\n For i:= 1 to n-1 do\n For j:= 1 to n-i do\n if A[j] > A[j+1] then\n begin\n tmp:= A[j];\n A[j]:= A[j+1];\n A[j+1]:= tmp;\n\n tmp:= Perm[j];\n Perm[j]:= Perm[j+1];\n Perm[j+1]:= tmp;\n end;\nend;\n\n\nFunction GCD(a, b: longint): longint;\nbegin\n while (a<>0) and (b<>0) do\n if a>b then\n a:= a mod b\n else\n b:= b mod a;\n\n GCD:= a or b;\nend;\n\n\nProcedure CheckComb(len: longint);\nvar i, sum: longint;\nbegin\n if len=0 then\n exit;\n sum:= 0;\n For i:= n downto n-len+1 do\n sum:= sum + abs(A[i]-C[len-(n-i)]);\n// write(sum,'; ');\n For i:= n-len downto 1 do\n sum:= sum + abs(A[i]-1);\n //writeln(sum);\n\n if sum < minSum then\n begin\n minSum:= sum;\n For i:= 1 to n-len do\n Answer[i]:= 1;\n For i:= n-len+1 to n do\n Answer[i]:= C[i-(n-len+1)+1];\n end;\nend;\n\n\nProcedure Go(pos, len: longint);\nvar i, j: longint;\n good: boolean;\nbegin\n// writeln('ZZ: ',pos,' ',len);\n if (pos=31) or (len=num) then\n exit;\n\n For i:= pos to 30 do\n begin\n good:= true;\n For j:= 1 to len do\n if GCD(i, C[j]) <> 1 then\n begin\n good:= false;\n break;\n end;\n\n if good then\n begin\n C[len+1]:= i;\n CheckComb(len+1);\n Go(i+1, len+1);\n C[len+1]:= 0;\n end;\n end;\nend;\n\n\nbegin\n read(n);\n\n num:= 0;\n For i:= 1 to n do\n begin\n read(A[i]);\n Perm[i]:= i;\n if A[i] <> 1 then\n inc(num);\n end;\n if num>15 then\n num:= 15;\n\n Sort(n);\n\n minSum:= MAXLONGINT;\n Go(2, 0);\n\n if num = 0 then\n For i:= 1 to n do\n Answer[i]:= 1;\n\n For i:= 1 to n do\n B[ Perm[i] ]:= Answer[i];\n\n For i:= 1 to n do\n write(B[i], ' ');\nend.\n"}, {"source_code": "uses math;\nconst\n d:array[1..16]of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar\n q,z,mn,i,j,n,m,k,t,x:longint;\n a,b,ans:array[0..11111]of longint;\n mk,f,p:array[0..1111,0..1111]of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to 58 do for j:=1 to 16 do if i mod d[j]=0 then b[i]:=b[i] or(1 shl(j-1));\n fillchar(f,sizeof(f),63);f[0,1]:=0;\n for i:=1 to n do for j:=1 to 58 do for z:=1 to 58 do if mk[i-1,z] and b[j]=0 then\n begin\n k:=f[i-1,z]+abs(a[i]-j);\n f[i,j]:=min(f[i,j],k);\n mk[i,j]:=mk[i-1,z] or b[j];\n if f[i,j]=k then p[i,j]:=z;\n end;\n mn:=maxlongint;\n for i:=1 to 58 do if f[n,i] ResultsValues[i - 1][j] + Abs(a[i] - k)) then\n begin\n ResultsValues[i][tmp] := ResultsValues[i - 1][j] + Abs(a[i] - k);\n ResultsFrom[i][tmp] := j; \n ResultsNumbers[i][tmp] := k; \n end;\n end;\n end;\n end;\nend;\n\nprocedure Print(const n: int);\nvar\n min: word;\n pos: int;\n i, j: int;\n a: array[1..100] of byte;\nbegin\n min := High(word);\n for i := 0 to 65536 do\n if min > ResultsValues[n][i] then\n begin\n min := ResultsValues[n][i];\n pos := i;\n end;\n \n for i := n downto 1 do\n begin\n a[i] := ResultsNumbers[i][pos];\n pos := ResultsFrom[i][pos];\n end;\n \n for i := 1 to n - 1 do\n Write(a[i], ' ');\n Writeln(a[n]);\nend;\n\nvar\n n, i: int;\n data: array of word;\n \nbegin\n Readln(n);\n SetLength(data, n + 1);\n for i := 1 to n do\n Read(data[i]);\n \n Init();\n Solve(n, data);\n Print(n);\nend."}, {"source_code": "{$APPTYPE CONSOLE}\n\nprogram LittlePonyAndHarmonyChest;\n\ntype\n int16 = smallint;\n uint16 = word;\n int = Integer;\n\nconst\n SUM_BOUND: int = 30000;\n PRIMES: array[0..17] of byte = (1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);\n \nvar\n ResultsValues: array[0..100] of array[0..65536] of int;\n ResultsFrom: array[0..100] of array[0..65536] of Byte; \n ResultsNumbers: array[0..100] of array[0..65536] of Byte; \n NumbersMasks: array[1..59] of int;\n \nprocedure Init;\nvar\n i, j: int;\nbegin\n for i := 1 to 59 do\n begin\n NumbersMasks[i] := 0;\n for j := 1 to High(PRIMES) do\n if (i mod PRIMES[J] = 0) then\n NumbersMasks[i] := NumbersMasks[i] or (1 shl (j - 1));\n end; \n for i := 0 to 100 do\n for j := 0 to 65536 do\n ResultsValues[i][j] := SUM_BOUND;\n ResultsValues[0][0] := 0;\nend;\n\nfunction Abs(const x: int): int;\nbegin\n if x < 0 then\n Result := -x\n else\n Result := x;\nend; \n\nprocedure Solve(const n: int; const a: array of word);\nvar\n i, j, k: int;\n tmp: int;\nbegin\n for i := 1 to n do \n begin\n for j := Low(ResultsValues[i]) to High(ResultsValues[i]) do\n begin\n for k := Low(NumbersMasks) to High(NumbersMasks) do\n begin\n tmp := j or NumbersMasks[k];\n if (j and NumbersMasks[k] = 0) and \n (ResultsValues[i][tmp] > ResultsValues[i - 1][j] + Abs(a[i] - k)) then\n begin\n ResultsValues[i][tmp] := ResultsValues[i - 1][j] + Abs(a[i] - k);\n ResultsFrom[i][tmp] := j; \n ResultsNumbers[i][tmp] := k; \n end;\n end;\n end;\n end;\nend;\n\nprocedure Print(const n: int);\nvar\n min: word;\n pos: int;\n i, j: int;\n a: array[1..100] of byte;\nbegin\n min := High(word);\n for i := 0 to 65536 do\n if min > ResultsValues[n][i] then\n begin\n min := ResultsValues[n][i];\n pos := i;\n end;\n \n for i := n downto 1 do\n begin\n a[i] := ResultsNumbers[i][pos];\n pos := ResultsFrom[i][pos];\n end;\n \n for i := 1 to n - 1 do\n Write(a[i], ' ');\n Writeln(a[n]);\nend;\n\nvar\n n, i: int;\n data: array of word;\n \nbegin\n Readln(n);\n SetLength(data, n + 1);\n for i := 1 to n do\n Read(data[i]);\n \n Init();\n Solve(n, data);\n Print(n);\nend."}, {"source_code": "const p:array[1..16]of longint=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53);\nvar n,i,j,k,l,sum,now,min:longint; b:boolean; a:array[0..100]of longint;\n d:array[0..65535,0..50]of longint;\n g,h,c,ans:array[0..65535]of longint; f,r:array[0..100,0..65535]of longint;\nbegin\n readln(n);\n for i:=1 to n do read(a[i]);\n k:=0;\n for i:=0 to 65535 do\n begin\n sum:=1;\n b:=true;\n for j:=0 to 15 do\n begin\n if (i shr j) and 1=1 then sum:=sum*p[16-j];\n if sum>=59 then\n begin\n b:=false;\n break;\n end;\n end;\n if b then\n begin\n inc(k);\n g[k]:=i;\n h[k]:=sum;\n end;\n end;\n inc(k);\n g[k]:=32768;\n h[k]:=8;\n inc(k);\n g[k]:=32768;\n h[k]:=16;\n inc(k);\n g[k]:=32768;\n h[k]:=32;\n inc(k);\n g[k]:=49152;\n h[k]:=12;\n inc(k);\n g[k]:=49152;\n h[k]:=24;\n inc(k);\n g[k]:=49152;\n h[k]:=48;\n inc(k);\n g[k]:=49152;\n h[k]:=18;\n inc(k);\n g[k]:=49152;\n h[k]:=36;\n inc(k);\n g[k]:=49152;\n h[k]:=54;\n inc(k);\n g[k]:=16384;\n h[k]:=9;\n inc(k);\n g[k]:=16384;\n h[k]:=27;\n inc(k);\n g[k]:=40960;\n h[k]:=20;\n inc(k);\n g[k]:=40960;\n h[k]:=40;\n inc(k);\n g[k]:=40960;\n h[k]:=50;\n inc(k);\n g[k]:=24576;\n h[k]:=45;\n inc(k);\n g[k]:=8192;\n h[k]:=25;\n inc(k);\n g[k]:=36864;\n h[k]:=28;\n inc(k);\n g[k]:=36864;\n h[k]:=56;\n inc(k);\n g[k]:=4096;\n h[k]:=49;\n inc(k);\n g[k]:=34816;\n h[k]:=44;\n inc(k);\n g[k]:=33792;\n h[k]:=52; \n for i:=0 to 65535 do\n for j:=1 to k do\n if (i and g[j])=0 then\n begin\n inc(c[i]);\n d[i,c[i]]:=j;\n end;\n for i:=0 to n do\n for j:=0 to 65535 do\n f[i,j]:=10000;\n f[0,0]:=0;\n for i:=0 to n-1 do\n for j:=0 to 65535 do\n if f[i,j]<10000 then\n for l:=1 to c[j] do\n if f[i,j]+abs(h[d[j,l]]-a[i+1])=59 then\n begin\n b:=false;\n break;\n end;\n end;\n if b then\n begin\n inc(k);\n g[k]:=i;\n h[k]:=sum;\n end;\n end;\n for i:=0 to 65535 do\n for j:=1 to k do\n if (i and g[j])=0 then\n begin\n inc(c[i]);\n d[i,c[i]]:=j;\n end;\n for i:=0 to n do\n for j:=0 to 65535 do\n f[i,j]:=10000;\n f[0,0]:=0;\n for i:=0 to n-1 do\n for j:=0 to 65535 do\n if f[i,j]<10000 then\n for l:=1 to c[j] do\n if f[i,j]+abs(h[d[j,l]]-a[i+1])=59 then\n begin\n b:=false;\n break;\n end;\n end;\n if b then\n begin\n inc(k);\n g[k]:=i;\n h[k]:=sum;\n end;\n end;\n inc(k);\n g[k]:=32768;\n h[k]:=8;\n inc(k);\n g[k]:=32768;\n h[k]:=16;\n inc(k);\n g[k]:=32768;\n h[k]:=32;\n inc(k);\n g[k]:=49152;\n h[k]:=12;\n inc(k);\n g[k]:=49152;\n h[k]:=24;\n inc(k);\n g[k]:=49152;\n h[k]:=48;\n inc(k);\n g[k]:=49152;\n h[k]:=18;\n inc(k);\n g[k]:=49152;\n h[k]:=36;\n inc(k);\n g[k]:=49152;\n h[k]:=54;\n inc(k);\n g[k]:=16384;\n h[k]:=9;\n inc(k);\n g[k]:=16384;\n h[k]:=27;\n inc(k);\n g[k]:=40960;\n h[k]:=20;\n inc(k);\n g[k]:=40960;\n h[k]:=40;\n inc(k);\n g[k]:=40960;\n h[k]:=50;\n inc(k);\n g[k]:=24576;\n h[k]:=45;\n inc(k);\n g[k]:=8192;\n h[k]:=25;\n inc(k);\n g[k]:=36864;\n h[k]:=28;\n inc(k);\n g[k]:=36864;\n h[k]:=56;\n inc(k);\n g[k]:=4096;\n h[k]:=49;\n inc(k);\n g[k]:=34816;\n h[k]:=44;\n inc(k);\n g[k]:=33792;\n h[k]:=52;\n inc(k);\n for i:=0 to 65535 do\n for j:=1 to k do\n if (i and g[j])=0 then\n begin\n inc(c[i]);\n d[i,c[i]]:=j;\n end;\n for i:=0 to n do\n for j:=0 to 65535 do\n f[i,j]:=10000;\n f[0,0]:=0;\n for i:=0 to n-1 do\n for j:=0 to 65535 do\n if f[i,j]<10000 then\n for l:=1 to c[j] do\n if f[i,j]+abs(h[d[j,l]]-a[i+1])=59 then\n begin\n b:=false;\n break;\n end;\n end;\n if b then\n begin\n inc(k);\n g[k]:=i;\n h[k]:=sum;\n end;\n end;\n inc(k);\n g[k]:=32768;\n h[k]:=4;\n inc(k);\n g[k]:=32768;\n h[k]:=8;\n inc(k);\n g[k]:=32768;\n h[k]:=16;\n inc(k);\n g[k]:=32768;\n h[k]:=32;\n inc(k);\n g[k]:=49152;\n h[k]:=12;\n inc(k);\n g[k]:=49152;\n h[k]:=24;\n inc(k);\n g[k]:=49152;\n h[k]:=48;\n inc(k);\n g[k]:=49152;\n h[k]:=18;\n inc(k);\n g[k]:=49152;\n h[k]:=36;\n inc(k);\n g[k]:=49152;\n h[k]:=54;\n inc(k);\n g[k]:=16384;\n h[k]:=9;\n inc(k);\n g[k]:=16384;\n h[k]:=27;\n inc(k);\n g[k]:=40960;\n h[k]:=20;\n inc(k);\n g[k]:=40960;\n h[k]:=40;\n inc(k);\n g[k]:=40960;\n h[k]:=50;\n inc(k);\n g[k]:=24576;\n h[k]:=45;\n inc(k);\n g[k]:=8192;\n h[k]:=25;\n inc(k);\n g[k]:=36864;\n h[k]:=28;\n inc(k);\n g[k]:=36864;\n h[k]:=56;\n inc(k);\n g[k]:=4096;\n h[k]:=49;\n inc(k);\n g[k]:=34816;\n h[k]:=44;\n inc(k);\n g[k]:=33792;\n h[k]:=52;\n for i:=0 to 65535 do\n for j:=1 to k do\n if (i and g[j])=0 then\n begin\n inc(c[i]);\n d[i,c[i]]:=j;\n end;\n for i:=0 to n do\n for j:=0 to 65535 do\n f[i,j]:=10000;\n f[0,0]:=0;\n for i:=0 to n-1 do\n for j:=0 to 65535 do\n if f[i,j]<10000 then\n for l:=1 to c[j] do\n if f[i,j]+abs(h[d[j,l]]-a[i+1])h then begin write(h*(h+1) div 2+w ) ;halt; end;\n if d1<=h then begin for i:=h downto d1 do\n w:=w+i;\n w:=w-u1;\n if w<0 then w:=0;end else d1:=h+1;\n for i:=d1-1 downto d2 do\n w:=w+i;\n w:=w-u2;\n if w<0 then w:=0;for i:=d2-1 downto 0 do\n w:=w+i;\n write(w);\nend."}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n w,h,u1,d1,u2,d2:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,w,h);\n readln(f,u1,d1);\n readln(f,u2,d2);\n\n assign(f,fo);rewrite(f);\n while (h <> 0) do\n begin\n w:=w+h;\n if h=d1 then w:=w-u1;\n if h=d2 then w:=w-u2;\n if w < 0 then w:=0;\n dec(h);\n end;\n write(f,w);\n close(f);\nend.\n"}, {"source_code": "Var w,h,u1,u2,d1,d2:Longint;\nBegin\n Readln(w,h);\n Readln(u1,d1);\n Readln(u2,d2);\n While h>0 do begin\n w:=w+h;\n If h=d1 then begin\n If w-u1<0 then w:=0 else w:=w-u1;\n End\n Else if h=d2 then begin\n If w-u2<0 then w:=0 else w:=w-u2;\n End;\n Dec(h);\n End;\n Writeln(w);\nEnd."}, {"source_code": "var\n w,h,u1,d1,u2,d2,i,s:longint;\nbegin\n read(w,h,u1,d1,u2,d2);\n s:=0;\n for i:=h downto 1 do \n begin\n w:=w+i;\n if i=d1 then w:=w-u1;\n if i=d2 then w:=w-u2;\n if w<0 then w:=0;\n end;\n \n write(w);\nend."}, {"source_code": "const fi='';\n fo='';\nVar h,h1,h2,w,w1,w2: longint;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,w,h);\n Readln(f,w1,h1);\n Readln(f,w2,h2);\n While h<>0 do\n Begin\n If (h<>h1) and (h<>h2) then\n Begin\n w:=w+h;\n h:=h-1;\n End;\n If (h=h1) then\n Begin\n w:=w+h;\n w:=w-w1;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n If (h=h2) then\n Begin\n w:=w+h;\n w:=w-w2;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n End;\n Writeln(g,w);\n Close(f); Close(g);\nEnd."}, {"source_code": "Program aProg;\nvar\n\ta, b, c, d, e, f:longint;\nbegin\n\tread(a, b, c, d, e, f);\n\twhile b>0 do begin\n\t\tinc(a, b);\n\t\tif d=b then begin\n\t\t\ta-=c;\n\t\t\tif a<0 then a:=0;\n\t\tend;\n\t\tif f=b then begin\n\t\t\ta-=e;\n\t\t\tif a<0 then a:=0;\n\t\tend;\n\t\tdec(b);\n\tend;\n\twriteln(a);\nend."}, {"source_code": "var\n w, h, u1, d1, u2, d2, i: integer;\n \nbegin\n readln(w, h);\n readln(u1, d1);\n readln(u2, d2);\n for i := h downto 1 do\n begin\n w := w + i;\n if i = d1 then w := w - u1;\n if i = d2 then w := w - u2;\n if w < 0 then w := 0;\n end;\n write(w);\nend."}, {"source_code": "var\n w, h, u1, u2, d1, d2, i: integer;\n\nbegin\n read(w, h);\n read(u1, d1);\n read(u2, d2);\n for i := h downto 0 do\n begin\n w := w + i;\n if i = d1 then\n w := w - u1;\n if i = d2 then\n w := w - u2;\n if w < 0 then\n w := 0;\n end;\n write(w);\nend."}, {"source_code": "var\n i,n,m,u,t:longint;\n a:array[1..100] of longint;\nbegin\n readln(n,m);\n for i:=1 to 2 do\n begin\n read(u,t);a[t]:=u;\n end;\n for i:=m downto 1 do\n begin\n inc(n,i);\n dec(n,a[i]);\n if n<0 then n:=0;\n end;\n writeln(n);\nend."}, {"source_code": "const\n fi='';//'cf1099a.inp';\n fo='';//'cf1099a.out';\nvar\n w1,w2,w3,h1,h2,h3,i:longint;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(w1,h1);\n readln(w2,h2);\n readln(w3,h3);\n for i:=h1 downto 0 do\n begin\n if i=h2 then w1:=w1-w2 else\n if i=h3 then w1:=w1-w3;\n w1:=w1+i;\n if w1<0 then w1:=0;\n end;\n writeln(w1);\n close(input);\n close(output);\nend.\n"}, {"source_code": "program snignuykom;\n var w,w1,w2,d,d1,d2,i:longint;\nbegin\n readln(w,d);\n readln(w1,d1);\n readln(w2,d2);\n for i:=d downto 1 do\n begin\n w:=w+i;\n if i=d1 then w:=w-w1 else if i=d2 then w:=w-w2;\n if w<0 then w:=0;\n end;\n if w<0 then writeln(0) else writeln(w);\nend.\n "}, {"source_code": "var\n w,h,u1,d1,u2,d2,i : longint;\n\nbegin\n read(w,h,u1,d1,u2,d2);\n for i := h downto 1 do\n begin\n w := w + i;\n if (i = d1) then\n begin\n w := w - u1;\n if w < 0 then\n w := 0;\n end\n else if (i = d2) then\n begin\n w := w - u2;\n if w < 0 then\n w := 0;\n end;\n end;\n writeln(w);\nend."}, {"source_code": "var w,h,u1,u2,d1,d2,i:integer;\nbegin\n read(w,h,u1,d1,u2,d2);\n for i:=h downto 1 do begin\n w:=w+i;\n if i=d1 then w:=w-u1;\n if i=d2 then w:=w-u2;\n if w<0 then w:=0;\n end;\n write(w);\nend."}, {"source_code": "var m,m1,m2,h,h1,h2,i:Integer;\n begin\n readln(m,h);\n readln(m1,h1);\n readln(m2,h2);\n for i:=h downto 0 do \n begin\n \tm:=m+i;\n if i=h1 then m:=m-m1;\n if m<0 then m:=0;\t\n if i=h2 then m:=m-m2;\n if m<0 then m:=0;\t \n end;\n writeln(m); \n end."}, {"source_code": "Program p;\nvar h, h1, h2, w, w1, w2: integer;\n\nbegin\nread(w, h, w1, h1, w2, h2);\nfor var g:=h downto 0 do\n begin\n w+=g;\n if g=h1 then w-=w1;\n if g=h2 then w-=w2;\n if w<0 then w:=0\n end;\nwrite(w)\nend."}, {"source_code": "var w, h, u1, d1, u2, d2, i:integer;\n\nbegin\nreadln(w, h);\nreadln(u1, d1);\nreadln(u2, d2);\nfor i:=h downto 0 do begin\nif(i=d1) then w:=w-u1\nelse if(i=d2) then w:=w-u2;\nw:=w+i;\nif(w<0) then w:=0;\nend;\nwriteln(w);\nend.\n"}, {"source_code": "var w,w1,w2,h,h1,h2,count:longint;\n\nbegin\n //assign(input,'BONUS.inp');reset(input);\n //assign(output,'BONUS.out');rewrite(output);\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n count:=h;\n while count>0 do\n begin\n inc(w,count);\n if count=h1 then\n begin\n dec(w,w1);\n if w<0 then w:=0;\n end;\n if count=h2 then\n begin\n dec(w,w2);\n if w<0 then w:=0;\n end;\n dec(count);\n end;\n //if w<0 then writeln(0) else\n writeln(w);\n\nend."}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n while (h<>0) do\n begin\n w:=w+h;\n if h=d2 then w:=w-u2 else if h=d1 then w:=w-u1;\n h:=h-1;\n if w<0 then w:=0;\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var\nw,h,u,d,v,b,x:int64;\ni:longint;\nbegin\n\nreadln(w,h);\nreadln(u,d);\nreadln(v,b);\nif dd1 then\n begin\n tmp:=d2; d2:=d1; d1:=tmp;\n tmp:=u2; u2:=u1; u1:=tmp;\n end;\nfor i:=d1 to h do w:=w+i;\nw:=w-u1; if w<0 then w:=0;\nfor i:=d2 to d1-1 do w:=w+i;\nw:=w-u2; if w<0 then w:=0;\nfor i:=0 to d2-1 do w:=w+i;\nwriteln(w);\nend."}, {"source_code": "var\nw,h,d1,u1,d2,u2,i:integer;\nbegin\nreadln(w,h);\nreadln(u1,d1);\nreadln(u2,d2);\nfor i:=h downto 0 do\n begin\n w:=w+i;\n if i=d1 then begin\n w:=w-u1;\n if w<0 then w:=0;\n end;\n if i=d2 then begin\n w:=w-u2;\n if w<0 then w:=0;\n end;\n end;\nwrite(w); \nend."}, {"source_code": " const fi='';\n fo='';\nVar h,h1,h2,w,w1,w2: longint;\n f,g: text;\nBegin\n Assign(f,fi); Reset(f);\n Assign(g,fo); Rewrite(g);\n Readln(f,w,h);\n Readln(f,w1,h1);\n Readln(f,w2,h2);\n While h<>0 do\n Begin\n If (h<>h1) and (h<>h2) then\n Begin\n w:=w+h;\n h:=h-1;\n End;\n If (h=h1) then\n Begin\n w:=w+h;\n w:=w-w1;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n If (h=h2) then\n Begin\n w:=w+h;\n w:=w-w2;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n End;\n Writeln(g,w);\n Close(f); Close(g);\nEnd.\n"}, {"source_code": "var w, h, u1, u2, d1, d2, i:integer;\nbegin\n readln(w, h);\n readln(u1, d1);\n readln(u2, d2);\n for i:=h downto 0 do\n begin\n w+=i;\n if d1=i then w-=u1;\n if d2=i then w-=u2;\n if w<0 then w:=0;\n end;\n writeln(w);\nend."}, {"source_code": "var\n w,h:integer;\n w1,h1,w2,h2:integer;\nbegin\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n for h:=h downto 0 do\n begin\n w+=h;\n if(h1 = h) then\n begin\n w:=w-w1;\n if(w<0)then w:=0;\n end;\n if(h2 = h) then\n begin\n w:=w-w2;\n if(w<0)then w:=0;\n end;\n end;\n writeln(w);\nend."}, {"source_code": "var w,h,w1,d1,w2,d2,i:integer;\nbegin\n readln(w,h);\n readln(w1,d1);\n readln(w2,d2);\n\n for i:=h downto 1 do begin\n inc(w,i);\n if (i = d1) then\n w:=w-w1;\n if (i = d2) then \n w:=w-w2;\n if (w < 0) then\n w:=0;\n end;\n writeln(w);\nend."}, {"source_code": " const eps=0.0000000001; besk1=200000008; nnn=4600000;\n besk=8000000000000000000;\n modul={1000000007}998244353 ;\n \n label 22,1,2,3,4,33;\n type real=extended; double=extended;\n mas=array [-300000..nnn] of int64; point=record x,y,z:real;end;\n zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;\n mass=array[-10000..nnn] of longint;mass1=^mass;\n var tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans1,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,r,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;\n k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;\n zz,numx,numy,xold,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..1535002] of int64;\n\n gr:array[-1..2000,-1..2000] of boolean;\n\n prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;\n iii,oldpos,finot,vv,znak:int64;\n aold:mas; anss:zap;\n ss1,ss2:string;\n newstr,str,sss:array[-1000..20000] of string;\n lll,rrr,v,dist,alpha,phi:extended;\n zzz,ddnew,koef,polex,ddsum,dd:array[-1..440000,-1..30] of int64;\n ppos,mma,ma:array[-1000..2000005,-1..15] of int64;\n xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;\n del:array[-1..100001,-1..20] of longint;\n z0,num,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;\n zzzz:array[0..125000000] of byte;\n aaaa,bbbb,x2:extended;\n delit:array[0..100000,0..20] of longint;\n pole:array[-10..2002,-10..2005] of char;\n matr,ppole,ddl,ddr,dd3,dd4:array[-10..2000,-10..2200] of extended;\n ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;\n newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;\n ssold,sss1,sss2:string;\n def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;\n zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;\n dost:array[-1..210,-1..210,0..3,0..3] of int64;\n ss:string;ch,ch1,ch2:char;\n pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;\n s3,s2,s1:array[-100..500000] of string;\n\n grr :array [-10..2010,-10..2010] of extended;\n maxpr:array[0..nnn] of string;\n tx,ty,vel,ott,v0,v1,s0,t0:int64;\n zv:point;\n left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;\n mash,sqx,sqy,ottt:extended;\n xxxx,yyyy,yot:double;\n flag2,flag,flag1:boolean;\n\n\n function max(a,b:int64):int64;\nbegin max:=a; if b>a then max:=b; end;\n\n function min(a,b:int64):int64;\nbegin min:=a; if b0)and(y>=0) then p:=arctan(y/x);\n if x<0 then p:=pi+arctan(y/x);\n if(x>0)and(y<0) then p:=2*pi+arctan(y/x);\n if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;\n al:=p{/pi*180};\n end;\n\n\nfunction degg(a,k:int64):int64; var p:int64;\nbegin\n if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else\n begin p:=degg(a,k shr 1); degg:=p*p mod modul; end;\n\nend;\n\nfunction prost(tt:int64):boolean;\nvar aa:extended; i,p,t:longint; fl:boolean;\n begin\n fl:=true;\n aa:=tt;\n aa:=sqrt(aa);\n t:=round(aa);\n for i:=2 to t do if tt mod i=0 then fl:=false;\n\n\n prost:=fl;\n end;\n\nfunction arcsin(pp:extended):extended;\nvar tt:extended;\nbegin\n if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)\n then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;\n tt:=1-pp*pp;\n if abs(tt)>=0 then\n begin\n arcsin:=arctan(pp/sqrt(tt));\n\n end;\n\n\n\nend;\n\nfunction gl(ch:char):boolean;\nbegin\n if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;\n\nend;\n\n\n\n\nfunction zaprmax(left,right:longint):int64;\nbegin\n if left>=right then zaprmax:=y[left] else\n begin\n if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else\n begin\n if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);\n if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);\n\n end;\n\n end;\n\nend;\n\n\n\n\n\n function ff(gr:int64):boolean;\n\nvar ot,aa,bb,cc:int64; fl:boolean;\nbegin\n aa:=1; bb:=m; cc:=aa; fl:=false;\n while abs(aa-bb)>1 do\n begin\n cc:=(aa+bb) shr 1;\n if y[cc]0 do\n Begin\n If (h<>h1) and (h<>h2) then\n Begin\n w:=w+h;\n h:=h-1;\n End;\n If (h=h1) then\n Begin\n w:=w+h;\n w:=w-w1;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n If (h=h2) then\n Begin\n w:=w+h;\n w:=w-w2;\n h:=h-1;\n If w<0 then\n w:=0;\n End;\n End;\n Writeln(g,w);\n Close(f); Close(g);\nEnd.\n"}, {"source_code": "Var i , w , w1 , w2 , h , h1 , h2 : Longint;\n\nFunction Max(x , y : Longint) : Longint;\n Begin\n If x > y then Exit(x) else Exit(y);\n End;\n\nProcedure Check(x : Longint);\n Begin\n If x = h1 then \n Begin\n Dec(w , w1);\n w := Max(w , 0);\n Exit;\n End;\n If x = h2 then \n Begin\n Dec(w , w2);\n w := Max(w , 0);\n End;\n End;\n\nBegin\n Readln(w , h);\n Readln(w1 , h1);\n Readln(w2 , h2);\n For i := h downto 0 do\n Begin\n Inc(w , i);\n Check(i);\n End;\n Writeln(w);\nEnd."}, {"source_code": "var\n\tw, h, u1, d1, u2, d2: int64;\n\t\nbegin\n\t\n\treadln(w, h);\n\treadln(u1, d1);\n\treadln(u2, d2);\n\t\n\tfor var i := h downto 1 do\n\tbegin\n\t\tw += i;\n\t\tif (i = d1) then\n\t\t\tif (w > u1) then\n\t\t\t\tw -= u1\n\t\t\telse\n\t\t\t\tw := 0\n\t\telse if (i = d2) then\n\t\t\tif (w > u2) then\n\t\t\t\tw -= u2\n\t\t\telse\n\t\t\t\tw := 0;\n\tend;\n\t\n\t//if (w - u1 - u2 < 0) then\n\t//\twriteln(0)\n\t//else\n\t\twriteln(w);\n\t\nend.\n"}, {"source_code": "var w,h,u1,i,d1,u2,d2: longint;\n\nbegin\n readln (w,h);\n readln (u1,d1);\n readln (u2,d2);\n for i:=h downto 1 do\n begin\n w:=w+i;\n if i=d1 then w:=max(0,w-u1);\n if i=d2 then w:=max(0,w-u2);\n end;\n writeln (w);\nend."}, {"source_code": "var\n mc, hc, mm1, hm1, mm2, hm2,i,q: integer;\n\nbegin\n read(mc, hc, mm1, hm1, mm2, hm2);\n i:=hc;\n for q:=1 to hc do \n if (hc <> hm1) and (hc <> hm2) and (i>=0) then begin\n mc := mc + hc;\n hc := hc - 1;\n i:=i-1;\n end\n else begin\n if hc = hm1 then begin\n mc := mc + hm1;\n mc := mc - mm1;\n hc := hc - 1;\n i:=i-1;\n end;\n if hc = hm2 then begin\n mc := mc + hm2;\n mc := mc - mm2;\n hc := hc - 1;\n i:=i-1;\n end;\n if mc<0 then mc:=0;\n end;\n writeln(mc)\nend."}, {"source_code": "const fi='';\n fo='';\nvar w,h,w1,h1,w2,h2:integer;\n\nprocedure docf;\nvar f:text;\nbegin\n assign(f,fi); reset(f);\n readln(f,w,h);\n readln(f,w1,h1);\n readln(f,w2,h2);\n close(f);\nend;\n\nprocedure solve;\nvar f:text;\nbegin\n assign(f,fo); rewrite(f);\n while (h>0) do\n begin\n inc(w,h);\n if (h=h1) then dec(w,w1);\n if (h=h2) then dec(w,w2);\n if (w<0) then w:=0;\n dec(h);\n end;\n if (w<0) then writeln(f,0) else writeln(f,w);\n close(f);\nend;\n\nbegin\n docf;\n solve;\nend."}, {"source_code": " var i,j,w,h,ww,hh:longint;\n a:array [0..101] of longint;\n begin\n read (w,h);\n read (ww,hh);\n a[hh]:=ww;\n read (ww,hh);\n a[hh]:=ww;\n\n for i:=h downto 1 do\n begin\n inc (w,i);\n dec (w,a[i]);\n if w<0 then w:=0;\n\n end;\n\n writeln (w);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n end."}, {"source_code": "var\n w,h,u1,u2,h1,h2,i:longint;\nbegin\n readln(w,h);\n readln(u1,h1);\n readln(u2,h2);\n for i:=h downto 0 do\n begin\n w:=w+i;\n if i=h1 then\n begin\n w:=w-u1;\n if w<0 then w:=0;\n end;\n if i=h2 then\n begin\n w:=w-u2;\n if w<0 then w:=0;\n end;\n end;\n writeln(w);\nend."}, {"source_code": "var\nw,h,u1,u2,d1,d2,i:integer;\n\nbegin\nreadln (w,h);\nreadln (u1,d1);\nreadln (u2,d2);\n\nfor i:=h downto 0 do begin\ninc(w,i);\nif i=d1 then dec (w,u1);\nif i=d2 then dec (w,u2);\nif w<0 then w:=0;\nend;\n\nwrite (w);\n\n\nend.\n \n"}, {"source_code": "Program Snowball;\nvar w,h,u1,d1,u2,d2:integer;\n\nBegin\nreadln(w,h,u1,d1,u2,d2);\nwhile h>0 do\n begin\n w:= w+h;\n if h=d1 then\n w:=w-u1;\n if h=d2 then\n w:=w-u2;\n if w<0 then\n w:=0;\n h:=h-1;\n end;\n writeln(w);\nEnd."}, {"source_code": "var w,h,d1,d2,u1,u2,i,j,k:int64;\nbegin\nread(w,h,u1,d1,u2,d2);\nk:=w;\nwhile h>=0 do\nbegin\nif h=d1 then begin k:=max(k-u1+h,0) end else\nif h=d2 then begin k:=max(k-u2+h,0)end else\nk+=h;h-=1\nend;\nwrite(k)\nend.\n"}, {"source_code": "var w,h,u1,d1,u2,d2,i,a:integer;\nbegin\nread(w,h,u1,d1,u2,d2);\nfor i:=h downto 1 do\nbegin\nw:=w+i;\nif (i=d1) then\nw:=w-u1;\nif (i=d2) then\nw:=w-u2;\nif (w<0) then\nw:=0;\nend;\nwrite(w);\nend."}, {"source_code": "Var\n w, h, u1, d1, u2, d2: Int64;\n \nBegin\n Readln(w, h, u1, d1, u2, d2);\n For Var i := 0 to h do Begin\n w += (h - i);\n If (h - i) = d1 then\n w := max(0, w - u1)\n Else If (h - i) = d2 then\n w := max(0, w - u2)\n End;\n Write(max(0, w))\nEnd."}, {"source_code": "var\n w, h, u1, u2, d1, d2: integer;\n\nbegin\n readln(w, h);\n readln(u1, d1);\n readln(u2, d2);\n while (h > 0) do\n begin\n w := w + h;\n if (h = d1) then w := w - u1;\n if (h = d2) then w := w - u2;\n h := h - 1;\n if w < 0 then w := 0;\n end;\n writeln(w);\nend.\n"}, {"source_code": "VAR\nw,h,u1,u2,d1,d2:longint;\nBEGIN\n read(w,h,u1,d1,u2,d2);\n for h:=h downto 0 do begin\n w += h;\n if h=d1 then w -= u1;\n if h=d2 then w -= u2;\n if w<0 then w:=0;\n end;\n write(w);\nEND."}], "negative_code": [{"source_code": "var\n w, h, u1, u2, d1, d2, i: integer;\n\nbegin\n read(w, h);\n read(u1, d1);\n read(u2, d2);\n for i := h downto 0 do\n begin\n w := w + i;\n if i = d1 then\n w := w - u1;\n if i = d2 then\n w := w - u2;\n end;\n write(w);\nend."}, {"source_code": "program snignuykom;\n var w,w1,w2,d,d1,d2,i:longint;\nbegin\n readln(w,d);\n readln(w1,d1);\n readln(w2,d2);\n for i:=1 to d do\n w:=w+i;\n w:=w-(w1+w2);\n if w<0 then writeln(0) else writeln(w);\nend.\n "}, {"source_code": "program snignuykom;\n var w,w1,w2,d,d1,d2,i:longint;\nbegin\n readln(w,d);\n readln(w1,d1);\n readln(w2,d2);\n for i:=1 to d do\n begin\n w:=w+i;\n if i=d1 then w:=w-w1 else if i=d2 then w:=w-w2;\n if w<0 then w:=0;\n end;\n if w<0 then writeln(0) else writeln(w);\nend.\n "}, {"source_code": "var h,h1,h2,m,m1,m2,c,i:integer;\nbegin\n\treadln(m,h);\n\t readln(m1,h1);\n\t readln(m2,h2);\n if h2>h1 then begin h1:=h1+h2; h2:=h1-h2; h1:=h1-h2; end;\n for i:=h1 to h do m:=m+i; \n m:=m-m1;\n if m<0 then m:=0;\n for i:=h2 to h1-1 do m:=m+i;\n m:=m-m2; \n if m<0 then m:=0;\t \n m:=m+(h2*(h2-1)div 2);\n writeln(m);\nend.\n"}, {"source_code": "var w, h, u1, d1, u2, d2, i:byte;\n\nbegin\nreadln(w, h);\nreadln(u1, d1);\nreadln(u2, d2);\nfor i:=h downto 0 do begin\nif(i=d1) then w:=w-u1\nelse if(i=d2) then w:=w-u2;\nw:=w+i;\nif(w<0) then w:=0;\nend;\nwriteln(w);\nend.\n"}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then k:=1;\n while (h<>0) do\n begin\n if (k=1)and(h>=d2-1) then w:=w+h else if k<>1 then w:=w+h;\n if h=d2 then w:=abs(w-u2) else if h=d1 then w:=abs(w-u1);\n h:=h-1;\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then u1:=0;\n while (h<>0) do\n begin\n w:=w+h;\n if h=d2 then w:=abs(w-u2) else if h=d1 then w:=abs(w-u1);\n h:=h-1;\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then k:=1;\n while (h<>0) do\n begin\n if (k=1)and(h>=d2-1) then w:=w+h else if k<>1 then w:=w+h;\n if h=d2 then w:=w-u2 else if (h=d1)and(k<>1) then w:=w-u1;\n h:=h-1;\n if w<0 then w:=0;\n writeln(w,' -')\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n //if abs(d2-d1)>1 then u1:=0;\n while (h<>0) do\n begin\n w:=w+h;\n if h=d2 then w:=abs(w-u2) else if h=d1 then w:=abs(w-u1);\n h:=h-1;\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then k:=1;\n while (h<>0) do\n begin\n if (k=1)and(h>=d2-1) then w:=w+h else if k<>1 then w:=w+h;\n if h=d2 then w:=abs(w-u2) else if (h=d1)and(k<>1) then w:=abs(w-u1);\n h:=h-1;\n //writeln(w,' -')\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then k:=1;\n while (h<>0) do\n begin\n if (k=1)and(h>=d2-1) then w:=w+h else if k<>1 then w:=w+h;\n if h=d2 then w:=w-u2 else if (h=d1)and(k<>1) then w:=w-u1;\n h:=h-1;\n //if w<0 then w:=0;\n //writeln(w,' -')\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then u1:=0;\n while (h<>0) do\n begin\n w:=w+h;\n if h=d2 then w:=w-u2 else if h=d1 then w:=w-u1;\n h:=h-1;\n if w<0 then w:=0;\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w,h,u1,u2,d1,d2,k : integer;\nbegin\n readln(w,h);\n readln(u1,d1);\n readln(u2,d2);\n if d1>d2 then \n begin \n k:=d1; \n d1:=d2;\n d2:=k;\n k:=u1; \n u1:=u2;\n u2:=k;\n end;\n k:=0;\n if abs(d2-d1)>1 then k:=1;\n while (h<>0) do\n begin\n if (k=1)and(h>=d2-1) then w:=w+h else if k<>1 then w:=w+h;\n if h=d2 then w:=w-u2 else if (h=d1)and(k<>1) then w:=w-u1;\n h:=h-1;\n if w<0 then w:=0;\n //writeln(w,' -')\n end;\n writeln(w);\nend.\n \n "}, {"source_code": "var w, h, u1, u2, d1, d2, i:integer;\nbegin\n readln(w, h);\n readln(u1, d1);\n readln(u2, d2);\n for i:=h downto 0 do\n begin\n w+=i;\n if d1=i then w-=u1;\n if d2=i then w-=u2;\n end;\n if w<0 then w:=0;\n writeln(w);\nend."}, {"source_code": "Const fi='A1099.inp';\n fo='A1099.out';\n\nVar n,h:longint;\n\nProcedure doc;\n var tmp:longint;\n begin\n {$ifndef ONLINE_JUDGE}\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n {$endif}\n readln(n,h);\n readln(tmp); dec(n,tmp);\n readln(tmp); dec(n,tmp);\n end;\n\nProcedure process;\n begin\n inc(n,h*(h+1) div 2);\n if n<0 then write(0) else write(n);\n end;\n\nBEGIN\n doc;\n process;\nEND."}, {"source_code": "Const fi='A1099.inp';\n fo='A1099.out';\n\nVar n,h,x1,x2,y1,y2:longint;\n\nProcedure swap(var x,y:longint);\n var tmp:longint;\n begin\n tmp:=x; x:=y; y:=tmp;\n end;\n\nProcedure doc;\n begin\n {$ifndef ONLINE_JUDGE}\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n {$endif}\n readln(n,h);\n readln(x1,y1);\n readln(x2,y2);\n if y1 0) do\n begin\n w:=w+h;\n dec(h);\n end;\n if w-u1-u2 < 0 then write(f,0) else write(f,w-u1-u2);\n close(f);\nend.\n"}, {"source_code": "const fi='';\n fo='';\nvar f:text;\n w,h,u1,d1,u2,d2:longint;\n\nbegin\n assign(f,fi);reset(f);\n readln(f,w,h);\n readln(f,u1,d1);\n readln(f,u2,d2);\n\n assign(f,fo);rewrite(f);\n while (h <> 0) do\n begin\n w:=w+h;\n dec(h);\n end;\n write(f,w-u1-u2);\n close(f);\nend.\n"}, {"source_code": "var\n w,h,u1,d1,u2,d2,i,s:longint;\nbegin\n read(w,h,u1,d1,u2,d2);\n s:=0;\n for i:=h downto 0 do \n begin\n if i=d1 then w:=w-u1+i\n else if i=d2 then w:=w-u2+i\n else w:=w+i;\n end;\n if w<0 then w:=0;\n write(w);\nend."}, {"source_code": "var\n w,h,u1,d1,u2,d2,i,s:longint;\nbegin\n read(w,h,u1,d1,u2,d2);\n s:=0;\n for i:=h downto 1 do \n begin\n if i=d1 then w:=w-u1+i\n else if i=d2 then w:=w-u2+i\n else w:=w+i;\n end;\n if w<0 then w:=0;\n write(w);\nend."}, {"source_code": "var\n w,h,u1,d1,u2,d2,i,s:longint;\nbegin\n read(w,h,u1,d1,u2,d2);\n s:=0;\n for i:=h downto 0 do \n begin\n w:=w+i;\n if i=d1 then w:=w-u1;\n if i=d2 then w:=w-u2;\n end;\n if w<0 then w:=0;\n write(w);\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n k:= h-d1-d2;\n w:=w+h;\n h:=h-1;\n w:=w+h;\n w:=w-u1;\n h:=h-1;\n w:=w+h;\n w:=w-u2;\n h:=h-1;\n w:=w+h;\n s1:=w;\n If k=0 then writeln(g,s1);\n If k>0 then begin\n while (k<>0) do\n begin\n k:=k-1;\n s2:=s1+k;\n \n end;\n writeln(g,s2);\n end;\n\n\n close(f);\n close(g);\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n While (h<>0) do\n begin\n w:=w+h;\n h:=h-1;\n w:=w+h;\n If (w-u1<0) then w:=0\n else w:=w-u1;\n u1:=0;\n h:=h-1;\n w:=w+h;\n If (w-u2<0) then w:=0\n else w:=w-u2;\n u2:=0;\n\n If (h-1>0) then h:=h-1\n else h:=0;\n w:=w+h;\n end;\n writeln(g,w);\n\n\n\n close(f);\n close(g);\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n k:= h-d1-d2;\n w:=w+h;\n h:=h-1;\n w:=w+h;\n w:=w-u1;\n h:=h-1;\n w:=w+h;\n w:=w-u2;\n h:=h-1;\n w:=w+h;\n s1:=w;\n If k=0 then writeln(g,s1);\n If k>0 then begin\n while (k<>0) do\n begin\n k:=k-1;\n s1:=s1+k;\n end;\n writeln(g,s1);\n end;\n\n\n close(f);\n close(g);\nend.\n"}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n k:= h-d1-d2;\n w:=w+h;\n h:=h-1;\n w:=w+h;\n w:=w-u1;\n h:=h-1;\n w:=w+h;\n w:=w-u2;\n h:=h-1;\n w:=w+h;\n s1:=w;\n If k=0 then writeln(g,s1);\n If k>0 then begin\n while (k<>0) do\n begin\n s2:=s1+k;\n k:=k-1;\n end;\n writeln(g,s2);\n end;\n\n\n close(f);\n close(g);\nend."}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n k:= h-d1-d2;\n w:=w+h;\n h:=h-1;\n w:=w+h;\n If (w-u1<0) then w:=0\n else w:=w-u1;\n h:=h-1;\n w:=w+h;\n If (w-u2<0) then w:=0\n else w:=w-u2;\n h:=h-1;\n w:=w+h;\n s1:=w;\n If k=0 then writeln(g,s1);\n If k>0 then begin\n while (k<>0) do\n begin\n k:=k-1;\n s1:=s1+k;\n end;\n writeln(g,s1);\n end;\n\n\n close(f);\n close(g);\nend.\n"}, {"source_code": "Const fi='';\n fo='';\nVar f,g:text;\n w,h,u1,d1,u2,d2,s1,s2,k:longint;\n\nBegin\n Assign(f,fi);Reset(f);\n Assign(g,fo);Rewrite(g);\n Readln(f,w,h);\n Readln(f,u1,d1);\n Readln(f,u2,d2);\n k:= h-d1-d2;\n w:=w+h;\n h:=h-1;\n w:=w+h;\n w:=w-u1;\n h:=h-1;\n w:=w+h;\n w:=w-u2;\n h:=h-1;\n w:=w+h;\n s1:=w;\n If k=0 then writeln(g,s1);\n If k>0 then begin\n while (k<>0) do\n begin\n k:=k-1;\n s1:=s1+k;\n \n end;\n writeln(g,s1);\n end;\n\n\n close(f);\n close(g);\nend."}, {"source_code": "Var w,h,u1,d1,u2,d2,s:longint;\n\nBegin\n Readln(w,h);\n Readln(u1,d1);\n Readln(u2,d2);\n s:= (w-u1) + (h+d1) + d2 -u2;\n writeln(s);\n end."}, {"source_code": "var\n i,n,m,u:longint;\n a:array[1..100] of longint;\nbegin\n readln(n,m);\n for i:=1 to 2 do\n begin\n read(u);readln(a[u]);\n end;\n for i:=n downto 1 do\n begin\n inc(n,i);\n dec(n,a[i]);\n if n<0 then n:=0;\n end;\n writeln(n);\nend."}, {"source_code": "var\n w,h,u1,d1,u2,d2,i : longint;\n\nbegin\n read(w,h,u1,d1,u2,d2);\n for i := h downto 1 do\n begin\n w := w + i;\n if (i = d1) then\n w := w - u1\n else if (i = d2) then\n w := w - u2;\n end;\n if w < 0 then\n w := 0;\n writeln(w);\nend."}, {"source_code": "var w,w1,w2,h,h1,h2:longint;\n\n\n\nprocedure swap(var a,b:longint);\nvar c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\n\nbegin\n //assign(input,'BONUS.inp');reset(input);\n //assign(output,'BONUS.out');rewrite(output);\n readln(w,h);\n readln(w1,h1);\n readln(w2,h2);\n if h1